@rr0/ufoathome 0.81.6 → 0.81.8
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.
|
@@ -864,16 +864,16 @@ canvas[data-cursor="rotate"] {
|
|
|
864
864
|
.toolbar.auto-hide .toolbar-inner {
|
|
865
865
|
overflow: hidden;
|
|
866
866
|
}
|
|
867
|
-
.stage.paused .auto-hide,
|
|
867
|
+
.stage.paused:not(.quiet) .auto-hide,
|
|
868
868
|
.stage.touched .auto-hide {
|
|
869
869
|
opacity: 1;
|
|
870
870
|
pointer-events: auto;
|
|
871
871
|
}
|
|
872
|
-
.stage.paused .toolbar.auto-hide,
|
|
872
|
+
.stage.paused:not(.quiet) .toolbar.auto-hide,
|
|
873
873
|
.stage.touched .toolbar.auto-hide {
|
|
874
874
|
grid-template-rows: 1fr;
|
|
875
875
|
}
|
|
876
|
-
.stage.paused .toolbar.auto-hide .toolbar-inner,
|
|
876
|
+
.stage.paused:not(.quiet) .toolbar.auto-hide .toolbar-inner,
|
|
877
877
|
.stage.touched .toolbar.auto-hide .toolbar-inner {
|
|
878
878
|
overflow: visible;
|
|
879
879
|
}
|
|
@@ -1296,12 +1296,22 @@ canvas[data-cursor="rotate"] {
|
|
|
1296
1296
|
accent-color: #fff;
|
|
1297
1297
|
transition: width 0.15s ease, margin 0.15s ease, opacity 0.15s ease;
|
|
1298
1298
|
}
|
|
1299
|
-
.volume:hover input[type="range"],
|
|
1300
1299
|
.volume:has(:focus-visible) input[type="range"] {
|
|
1301
1300
|
width: 4.5em;
|
|
1302
1301
|
margin: 0 0.6em 0 0.3em;
|
|
1303
1302
|
opacity: 1;
|
|
1304
1303
|
}
|
|
1304
|
+
/* Unfolded by hovering ONLY where there is a hover. On a touch screen the first tap on a control whose
|
|
1305
|
+
:hover rule changes the page is taken for the hover and does nothing else — which is the mute button
|
|
1306
|
+
asking for two taps, the first of them unfolding a slider nobody wanted. There the slider stays
|
|
1307
|
+
folded, and a tap is the click it is: a phone has its own volume keys. */
|
|
1308
|
+
@media (hover: hover) {
|
|
1309
|
+
.volume:hover input[type="range"] {
|
|
1310
|
+
width: 4.5em;
|
|
1311
|
+
margin: 0 0.6em 0 0.3em;
|
|
1312
|
+
opacity: 1;
|
|
1313
|
+
}
|
|
1314
|
+
}
|
|
1305
1315
|
.time-separator {
|
|
1306
1316
|
opacity: 0.75;
|
|
1307
1317
|
}
|
|
@@ -1340,7 +1350,7 @@ canvas[data-cursor="rotate"] {
|
|
|
1340
1350
|
}
|
|
1341
1351
|
`,Qo=[{id:"eye",name:"Naked eye",flare:0,projection:"equidistant",stabilization:.97},{id:"rectilinear-lens",name:"Camera, unknown device",projection:"rectilinear",fNumber:8,fNumberRange:{min:2,max:22},exposureSeconds:1/250,exposureRangeSeconds:{min:1/1e3,max:8},apertureBlades:6},{id:"instamatic-126",name:"Instamatic, 126 film",projection:"rectilinear",frame:{widthMm:28,heightMm:28,focalLengthMm:43},fNumber:11,exposureSeconds:1/90,years:{from:1963,to:1988},apertureBlades:5,detailUm:20,medium:{kind:"negative",iso:64}},{id:"slr-35mm-50",name:"35 mm SLR, 50 mm lens",projection:"rectilinear",frame:{widthMm:36,heightMm:24,focalLengthMm:50},fNumber:8,fNumberRange:{min:2,max:16},exposureSeconds:1/250,exposureRangeSeconds:{min:1/1e3,max:3600},years:{from:1959},apertureBlades:6,detailUm:20,medium:{kind:"negative",iso:100}},{id:"slr-35mm-zoom",name:"35 mm SLR, 70-210 mm zoom",projection:"rectilinear",frame:{widthMm:36,heightMm:24,focalLengthMm:135,focalRangeMm:{minMm:70,maxMm:210}},fNumber:8,fNumberRange:{min:4,max:22},exposureSeconds:1/250,exposureRangeSeconds:{min:1/1e3,max:3600},apertureBlades:8,years:{from:1975},detailUm:20,medium:{kind:"negative",iso:100}},{id:"phone-landscape",name:"Phone, held sideways",projection:"rectilinear",frame:{widthMm:7.6,heightMm:5.7,focalLengthMm:5.7},fNumber:1.8,exposureSeconds:1/120,exposureRangeSeconds:{min:1/8e3,max:10},years:{from:2007},apertureBlades:void 0,detailUm:1.4,medium:{kind:"sensor",iso:100,autoExposure:!0}},{id:"phone-portrait",name:"Phone, held upright",projection:"rectilinear",frame:{widthMm:5.7,heightMm:7.6,focalLengthMm:5.7},fNumber:1.8,exposureSeconds:1/120,exposureRangeSeconds:{min:1/8e3,max:10},years:{from:2007},apertureBlades:void 0,detailUm:1.4,medium:{kind:"sensor",iso:100,autoExposure:!0}}];class fi{static get default(){return Qo[0]}static byId(t){return Qo.find(e=>e.id===t)??this.default}static UNAIDED_FIELD_DEG=60;static UNAIDED_ASPECT=16/9;static fieldOfViewDeg(t){const e=t.frame;return e?2*Math.atan(e.heightMm/(2*e.focalLengthMm))*180/Math.PI:fi.UNAIDED_FIELD_DEG}static aspectOf(t){const e=t.frame;return e?e.widthMm/e.heightMm:fi.UNAIDED_ASPECT}static frameWidthPx(t,e){return Math.round(e*fi.aspectOf(t))}static availableAt(t){return t===void 0?Qo:Qo.filter(e=>!e.years||t>=e.years.from&&(e.years.to===void 0||t<=e.years.to))}static fieldOfViewDegAt(t,e){const i=t.frame;if(!(!i||e<=0))return 2*Math.atan(i.heightMm/(2*e))*180/Math.PI}static focalLengthMmFor(t,e){const i=t.frame;if(!(!i||e<=0||e>=180))return i.heightMm/(2*Math.tan(e*Math.PI/360))}static bladesShowing(t,e){const i=e??t.fNumber;if(i===void 0||t.apertureBlades===void 0)return 0;const n=t.fNumberRange;return!n||n.max<=n.min?1:Math.max(0,Math.min(1,(i-n.min)/(n.max-n.min)))}static LENS_FLARE_ARTIFACTS=1;static flareArtifactsOf(t){return t.flare??fi.LENS_FLARE_ARTIFACTS}static starPointsOf(t){const e=t.apertureBlades;return e===void 0||e<3?0:e%2===0?e:e*2}}class yr{constructor(t){this.points=t}static STATIONARY_M=5;static of(t){const e=[];for(const i of t.observerTrack.allKeyframes){const{lat:n,lng:s,headingDeg:a}=i.pose;n===void 0||s===void 0||e.push({t:i.t,lat:n,lng:s,headingDeg:a})}if(e.length===0){const i=t.event.place?.[0];if(!i)return;e.push({t:0,lat:i.lat,lng:i.lng})}return new yr(e)}static TRAVEL_M=50;get travels(){return this.spanM>yr.TRAVEL_M}get moved(){return this.spanM>yr.STATIONARY_M}get spanM(){const t=this.box,e=(t.south+t.north)/2,i=(t.west+t.east)/2;return Math.max(Math.abs(ai(e,t.east,e,t.west).x),Math.abs(ai(t.north,i,t.south,i).z))}get center(){const t=this.box;return{lat:(t.south+t.north)/2,lng:(t.west+t.east)/2}}boundsAround(t,e){const{lat:i,lng:n}=this.center,s=Math.max(this.spanM*(1+e),t)/2;return{north:_s(0,-s,i,n).lat,south:_s(0,s,i,n).lat,east:_s(s,0,i,n).lng,west:_s(-s,0,i,n).lng}}get box(){const t=this.points.map(i=>i.lat),e=this.points.map(i=>i.lng);return{south:Math.min(...t),north:Math.max(...t),west:Math.min(...e),east:Math.max(...e)}}}class mn{constructor(t,e){this.rotationPassed=t,this.scale=e}static SWAY_M=.012;static BREATH_M=.003;static DRIFT_YAW_DEG=.5;static DRIFT_PITCH_DEG=.4;static DRIFT_ROLL_DEG=.3;static GAZE_DRIFT_SHARE=.35;static HAND_HELD_S=.5;static HZ=[.11,.23,.17,.29,.37,.07];static of(t){const e=t.event.tags?.includes("paralysis")||(t.exposure??0)>mn.HAND_HELD_S,i=t.sway??(e?0:1);if(i>0)return new mn(Math.max(1-(t.instrument.stabilization??0),mn.GAZE_DRIFT_SHARE),i)}offsetAt(t){const e=t/1e3,i=this.scale,n=(u,d)=>Math.sin(2*Math.PI*u*e+d),[s,a,o,c,l,h]=mn.HZ;return{eastM:i*mn.SWAY_M*(.7*n(s,.3)+.3*n(c,1.9)),northM:i*mn.SWAY_M*(.6*n(o,2.2)+.4*n(l,.8)),upM:i*mn.BREATH_M*n(a,0),yawDeg:i*this.rotationPassed*mn.DRIFT_YAW_DEG*(.6*n(h,1.1)+.4*n(c,2.7)),pitchDeg:i*this.rotationPassed*mn.DRIFT_PITCH_DEG*(.5*n(a,1.6)+.5*n(o,.4)),rollDeg:i*this.rotationPassed*mn.DRIFT_ROLL_DEG*n(s,2.9)}}}class _e{constructor(t,e){this.stretches=t,this.rotationPassed=e}static REFERENCE_SPEED_M_PER_S=1.4;static REFERENCE_STEP_HZ=1.9;static CADENCE_EXPONENT=.43;static RISE_M_PER_M_PER_S=.0175;static SWAY_M=.0175;static SLOWEST_WALK_M_PER_S=.2;static FASTEST_WALK_M_PER_S=2.2;static HEAD_ROLL_DEG=1.5;static HEAD_PITCH_DEG=1.25;static HEAD_YAW_DEG=1;static STOP_LURCH_M=.035;static STOP_PITCH_DEG=3;static START_LURCH_M=.015;static START_PITCH_DEG=1.2;static JOLT_HZ=1.4;static JOLT_DECAY_S=.35;static JOLT_LASTS_MS=1500;static STILL=Object.freeze({eastM:0,northM:0,upM:0,rollDeg:0,pitchDeg:0,yawDeg:0});static of(t){const e=yr.of(t);if(!e||e.points.length<2)return;const i=[];let n=0;for(let s=1;s<e.points.length;s++){const a=e.points[s-1],o=e.points[s],c=(o.t-a.t)/1e3;if(c<=0)continue;const l=ai(o.lat,o.lng,a.lat,a.lng),h=l.x,u=-l.z,d=Math.hypot(h,u),f=d/c,p=_e.stepHzFor(f);i.push({startMs:a.t,endMs:o.t,speedMPerS:f,eastUnit:d>0?h/d:0,northUnit:d>0?u/d:0,stepHz:p,stepsBefore:n,rampsIn:!0,rampsOut:!0}),n+=p*c}for(let s=0;s<i.length;s++){const a=i[s-1],o=i[s+1];i[s].rampsIn=a===void 0||a.stepHz===0,i[s].rampsOut=o===void 0||o.stepHz===0}if(i.some(s=>s.stepHz>0))return new _e(i,1-(t.instrument.stabilization??0))}static bodyAt(t,e,i=!1){const n=_e.of(t)?.offsetAt(e)??_e.STILL;return i?n:_e.add(n,mn.of(t)?.offsetAt(e))}static stepHzFor(t){return t<_e.SLOWEST_WALK_M_PER_S||t>_e.FASTEST_WALK_M_PER_S?0:_e.REFERENCE_STEP_HZ*Math.pow(t/_e.REFERENCE_SPEED_M_PER_S,_e.CADENCE_EXPONENT)}offsetAt(t){return _e.add(this.cycleAt(t),this.joltAt(t))}joltAt(t){for(const e of this.stretches){if(e.stepHz===0)continue;const i=e.speedMPerS/_e.REFERENCE_SPEED_M_PER_S,n=(o,c,l,h)=>{if(o<0||o>_e.JOLT_LASTS_MS)return;const u=o/1e3,d=Math.exp(-u/_e.JOLT_DECAY_S)*Math.sin(2*Math.PI*_e.JOLT_HZ*u),f=h*c*i*d;return{eastM:f*e.eastUnit,northM:f*e.northUnit,upM:-Math.abs(f)*.3,rollDeg:0,pitchDeg:-h*l*i*d*this.rotationPassed,yawDeg:0}},s=e.rampsOut?n(t-e.endMs,_e.STOP_LURCH_M,_e.STOP_PITCH_DEG,1):void 0;if(s)return s;const a=e.rampsIn?n(t-e.startMs,_e.START_LURCH_M,_e.START_PITCH_DEG,-1):void 0;if(a)return a}}static add(t,e){return e?{eastM:t.eastM+e.eastM,northM:t.northM+e.northM,upM:t.upM+e.upM,rollDeg:t.rollDeg+e.rollDeg,pitchDeg:t.pitchDeg+e.pitchDeg,yawDeg:t.yawDeg+e.yawDeg}:t}cycleAt(t){const e=this.stretches.find(c=>t>=c.startMs&&t<=c.endMs);if(!e||e.stepHz===0)return _e.STILL;const i=e.stepsBefore+e.stepHz*(t-e.startMs)/1e3,n=2*Math.PI*i,s=this.amplitudeAt(e,t),a=_e.SWAY_M*s*Math.cos(n/2),o=s*this.rotationPassed*e.speedMPerS/_e.REFERENCE_SPEED_M_PER_S;return{eastM:a*e.northUnit,northM:-a*e.eastUnit,upM:_e.RISE_M_PER_M_PER_S*e.speedMPerS*s*Math.cos(n),rollDeg:_e.HEAD_ROLL_DEG*o*Math.cos(n/2),pitchDeg:-1.25*o*Math.cos(n),yawDeg:_e.HEAD_YAW_DEG*o*Math.cos(n/2)}}amplitudeAt(t,e){const i=1e3/t.stepHz,n=Math.min(i,(t.endMs-t.startMs)/2);if(n<=0)return 1;const s=e-t.startMs,a=t.endMs-e,o=Math.min(t.rampsIn?s/n:1,t.rampsOut?a/n:1,1);return(1-Math.cos(Math.PI*Math.max(o,0)))/2}}class Te{static MOON_ANGULAR_WIDTH_DEG=.5237;static CANVAS_WIDTH_PX=640;static CANVAS_HEIGHT_PX=360;static angularWidthDeg(t){return 2*Math.atan(t.sizeM/(2*t.distanceM))*180/Math.PI}static inMoons(t){return t/Te.MOON_ANGULAR_WIDTH_DEG}static lerpAngular(t,e,i){if(!(!t||!e))return{widthDeg:t.widthDeg+(e.widthDeg-t.widthDeg)*i,heightDeg:t.heightDeg+(e.heightDeg-t.heightDeg)*i}}static sizeMAt(t,e){return 2*t*Math.tan(e*Math.PI/360)}static distanceMAt(t,e){return t/(2*Math.tan(e*Math.PI/360))}}function uv(r,t,e){if(!r||!t)return e<1?r:t;const i=((t.azimuthDeg-r.azimuthDeg)%360+540)%360-180;return{azimuthDeg:((r.azimuthDeg+i*e)%360+360)%360,altitudeDeg:r.altitudeDeg+(t.altitudeDeg-r.altitudeDeg)*e}}function dv(r,t,e){const{bounds:i}=r;return t>=i.x&&t<=i.x+i.width&&e>=i.y&&e<=i.y+i.height}function Ki(r,t,e){return r+(t-r)*e}function sf(r){const t=/^#([0-9a-f]{6})$/i.exec(r);if(!t)return;const e=parseInt(t[1],16);return[e>>16&255,e>>8&255,e&255]}function fv(r){return`#${r.map(t=>Math.round(t).toString(16).padStart(2,"0")).join("")}`}function pv(r,t,e){const i=sf(r),n=sf(t);return!i||!n?e<1?r:t:fv([Ki(i[0],n[0],e),Ki(i[1],n[1],e),Ki(i[2],n[2],e)])}function mv(r,t,e){const i={x:Ki(r.bounds.x,t.bounds.x,e),y:Ki(r.bounds.y,t.bounds.y,e),width:Ki(r.bounds.width,t.bounds.width,e),height:Ki(r.bounds.height,t.bounds.height,e)},n=Ki(r.angle,t.angle,e),s=Ki(r.transparency,t.transparency,e),a=Ki(r.haloScale,t.haloScale,e),o=Ki(r.blur??0,t.blur??0,e),c=Ki(r.brightness??0,t.brightness??0,e),l=pv(r.color,t.color,e),h=Te.lerpAngular(r.angular,t.angular,e),u=uv(r.aim,t.aim,e);return r.kind==="polygon"&&t.kind==="polygon"&&r.points.length===t.points.length?{...r,bounds:i,angle:n,transparency:s,haloScale:a,blur:o,brightness:c,color:l,angular:h,aim:u,points:r.points.map((d,f)=>({x:Ki(d.x,t.points[f].x,e),y:Ki(d.y,t.points[f].y,e)}))}:{...e<1?r:t,bounds:i,angle:n,transparency:s,haloScale:a,blur:o,brightness:c,color:l,angular:h,aim:u}}class va{static DEFAULT_COLOR="#e8e6df";static complete(t,e=[]){const i=new Map;return t.map((n,s)=>({keyframe:n,index:s})).sort((n,s)=>n.keyframe.t-s.keyframe.t).map(({keyframe:n,index:s})=>({t:n.t,shapes:(n.shapes??[]).map((a,o)=>{const c=`timeline.keyframes.${s}.shapes.${o}.shape`,l=va.completed(a,i.get(a.sourceId),c,e);return i.set(a.sourceId,l),{sourceId:a.sourceId,shape:l}})}))}static completed(t,e,i,n){const s=t.shape??{},a=e??va.firstAppearance(s,i,n),o={...a};s.bounds&&e&&(e.aim||e.angular)&&!s.aim&&!s.angular&&n.push({kind:"pixels-over-angles",path:i}),s.bounds&&(s.aim||delete o.aim,s.angular||delete o.angular);const c=s.kind??a.kind??"oval",l={...o,...s,kind:c};if(c==="polygon"&&!l.points){n.push({kind:"defaulted",path:`${i}.points`,expected:"rectangle"});const{width:h,height:u}=l.bounds;return{...l,points:[{x:0,y:0},{x:h,y:0},{x:h,y:u},{x:0,y:u}]}}return l}static firstAppearance(t,e,i){return t.kind||i.push({kind:"defaulted",path:`${e}.kind`,expected:'"oval"'}),t.color||i.push({kind:"defaulted",path:`${e}.color`,expected:`"${va.DEFAULT_COLOR}"`}),!t.bounds&&!t.aim&&i.push({kind:"unplaced",path:e}),!t.bounds&&!t.angular&&i.push({kind:"unsized",path:e}),{kind:t.kind??"oval",bounds:{...va.NEUTRAL_BOUNDS},color:va.DEFAULT_COLOR,angle:0,transparency:0,haloScale:0,selected:!1}}static NEUTRAL_BOUNDS={x:Te.CANVAS_WIDTH_PX/2,y:Te.CANVAS_HEIGHT_PX/2,width:1,height:1}}class kl{keyframes=[];order=[];groups=[];addKeyframe(t,e){const i=this.findInsertIndex(t);if(this.keyframes[i]?.t===t){const n=new Set(e.map(s=>s.sourceId));this.keyframes[i]={t,shapes:[...this.keyframes[i].shapes.filter(s=>!n.has(s.sourceId)),...e]}}else this.keyframes.splice(i,0,{t,shapes:[...e]});for(const n of e)this.order.includes(n.sourceId)||this.order.push(n.sourceId)}findInsertIndex(t){let e=0,i=this.keyframes.length;for(;e<i;){const n=e+i>>>1;this.keyframes[n].t<t?e=n+1:i=n}return e}getKeyframeAt(t){const e=this.findInsertIndex(t),i=this.keyframes[e];return i?.t===t?i:void 0}getShapeAt(t,e){return this.getKeyframeAt(t)?.shapes.find(i=>i.sourceId===e)?.shape}getLatestShapeAt(t,e){let i=this.findInsertIndex(t);for(this.keyframes[i]?.t!==t&&(i-=1);i>=0;i--){const n=this.keyframes[i].shapes.find(s=>s.sourceId===e);if(n)return n.shape}}getInterpolatedShapeAt(t,e){const i=this.findShapeAtOrBefore(t,e);if(i?.t===t)return i.shape;const n=this.findShapeAtOrAfter(t,e);return i?n?mv(i.shape,n.shape,(t-i.t)/(n.t-i.t)):i.shape:n?.shape}findShapeAtOrBefore(t,e){let i=this.findInsertIndex(t);for(this.keyframes[i]?.t!==t&&(i-=1);i>=0;i--){const n=this.keyframes[i].shapes.find(s=>s.sourceId===e);if(n)return{t:this.keyframes[i].t,shape:n.shape}}}findShapeAtOrAfter(t,e){for(let i=this.findInsertIndex(t);i<this.keyframes.length;i++){const n=this.keyframes[i].shapes.find(s=>s.sourceId===e);if(n)return{t:this.keyframes[i].t,shape:n.shape}}}hitTest(t,e,i,n){const s=this.sourceIds;for(let a=s.length-1;a>=0;a--){if(n?.has(s[a]))continue;const o=this.getInterpolatedShapeAt(t,s[a]);if(o&&dv(o,e,i))return{sourceId:s[a],shape:o}}}removeSource(t){for(let e=this.keyframes.length-1;e>=0;e--){const i=this.keyframes[e].shapes.filter(n=>n.sourceId!==t);i.length===0?this.keyframes.splice(e,1):i.length!==this.keyframes[e].shapes.length&&(this.keyframes[e]={t:this.keyframes[e].t,shapes:i})}this.order=this.order.filter(e=>e!==t),this.removeFromGroup(t)}group(t){if(!(t.length<2)){for(const e of t)this.removeFromGroup(e);this.groups.push([...t])}}ungroup(t){const e=this.groups.findIndex(i=>i.includes(t));e!==-1&&this.groups.splice(e,1)}groupMembers(t){return this.groups.find(e=>e.includes(t))}removeFromGroup(t){const e=this.groups.findIndex(n=>n.includes(t));if(e===-1)return;const i=this.groups[e].filter(n=>n!==t);i.length<2?this.groups.splice(e,1):this.groups[e]=i}bringToFront(t){const e=this.order.indexOf(t);e!==-1&&(this.order.splice(e,1),this.order.push(t))}sendToBack(t){const e=this.order.indexOf(t);e!==-1&&(this.order.splice(e,1),this.order.unshift(t))}get duration(){return this.keyframes.length===0?0:this.keyframes[this.keyframes.length-1].t}get sourceIds(){return[...this.order]}get allKeyframes(){return this.keyframes}toJSON(){return{keyframes:this.keyframes,order:this.order,groups:this.groups}}static fromJSON(t,e){const i=new kl;for(const n of va.complete(t.keyframes??[],e))i.addKeyframe(n.t,n.shapes);if(t.order){const n=i.order.filter(s=>!t.order.includes(s));i.order=[...t.order,...n]}return t.groups&&(i.groups=t.groups.map(n=>n.filter(s=>i.order.includes(s))).filter(n=>n.length>=2)),i}}function gv(r,t,e){return Math.max(t,Math.min(e,r))}function vv(r,t,e){const i=((t-r)%360+540)%360-180;return((r+i*e)%360+360)%360}function Ga(r,t,e){return r+(t-r)*e}function Mv(r,t,e){return{lat:r.lat===void 0||t.lat===void 0?void 0:Ga(r.lat,t.lat,e),lng:r.lng===void 0||t.lng===void 0?void 0:Ga(r.lng,t.lng,e),elevationM:Ga(r.elevationM,t.elevationM,e),headingDeg:r.headingDeg===void 0||t.headingDeg===void 0?void 0:vv(r.headingDeg,t.headingDeg,e),pitchDeg:Ga(r.pitchDeg,t.pitchDeg,e),rollDeg:Ga(r.rollDeg??0,t.rollDeg??0,e),fovDeg:Ga(r.fovDeg,t.fovDeg,e),fNumber:r.fNumber,focusDistanceM:r.focusDistanceM}}class Ia{static at(t,e,i,n,s){const a=t[i],c=t[i+1]-a;if(c<=0)return e[i];const l=Ia.tangent(t,e,i,s),h=Ia.tangent(t,e,i+1,s),u=(n-a)/c,d=u*u,f=d*u;return(2*f-3*d+1)*e[i]+(f-2*d+u)*c*l+(-2*f+3*d)*e[i+1]+(f-d)*c*h}static BRAKE_S=.8;static paced(t,e,i,n){if(!i&&!n)return t;const s=e>0?Math.min(.5,Ia.BRAKE_S/e):.5;if(i&&n){const o=1/(1-s);return t<=s?o*t*t/(2*s):t>=1-s?1-o*(1-t)*(1-t)/(2*s):o*(t-s/2)}const a=o=>{const c=1/(1-s/2);if(o<=1-s)return c*o;const l=o-(1-s);return c*(1-s)+c*(l-l*l/(2*s))};return n?a(t):1-a(1-t)}static tangent(t,e,i,n){const s=t.length-1,a=f=>(e[f+1]-e[f])/(t[f+1]-t[f]||1);if(i===0)return n?0:a(0);if(i===s)return n?0:a(s-1);const o=a(i-1),c=a(i);if(o*c<=0)return 0;const l=t[i]-t[i-1],h=t[i+1]-t[i],u=2*h+l,d=h+2*l;return(u+d)/(u/o+d/c)}}class Lo{keyframes=[];addKeyframe(t,e){const i=this.findInsertIndex(t);this.keyframes[i]?.t===t?this.keyframes[i]={t,pose:e}:this.keyframes.splice(i,0,{t,pose:e})}clear(){this.keyframes.length=0}removeKeyframeAt(t){const e=this.findInsertIndex(t);this.keyframes[e]?.t===t&&this.keyframes.splice(e,1)}findInsertIndex(t){let e=0,i=this.keyframes.length;for(;e<i;){const n=e+i>>>1;this.keyframes[n].t<t?e=n+1:i=n}return e}getLatestPoseAt(t){let e=this.findInsertIndex(t);return this.keyframes[e]?.t!==t&&(e-=1),e>=0?this.keyframes[e].pose:void 0}getInterpolatedPoseAt(t){const e=this.findInsertIndex(t),i=this.keyframes[e]?.t===t?this.keyframes[e]:this.keyframes[e-1];if(i?.t===t)return i.pose;const n=this.keyframes[e]?.t===t?void 0:this.keyframes[e];if(!i)return n?.pose;if(!n)return i.pose;const s=Mv(i.pose,n.pose,gv((t-i.t)/(n.t-i.t),0,1));return this.humanly(e-1,t,s)}humanly(t,e,i){const n=Math.max(0,t-1),s=Math.min(this.keyframes.length-1,t+2),a=this.keyframes.slice(n,s+1),o=t-n,c=a.map(y=>y.t),l=(y,M)=>{const b=a.map(w=>y(w.pose));if(!b.some(w=>w===void 0))return Ia.at(c,b,o,e,M)},h=a.map(y=>y.pose.headingDeg);let u;if(h.every(y=>y!==void 0)){const y=[h[0]];for(let M=1;M<h.length;M++)y.push(y[M-1]+((h[M]-h[M-1])%360+540)%360-180);u=(Ia.at(c,y,o,e,!0)%360+360)%360}const d=this.keyframes[t],f=this.keyframes[t+1],p=(y,M)=>y.lat===M.lat&&y.lng===M.lng&&y.elevationM===M.elevationM,v=!p(d.pose,f.pose),m=v&&t>0&&p(this.keyframes[t-1].pose,d.pose),g=v&&t+2<this.keyframes.length&&p(f.pose,this.keyframes[t+2].pose);let S;if(m||g){const y=Ia.paced((e-d.t)/(f.t-d.t),(f.t-d.t)/1e3,m,g),M=(b,w)=>b===void 0||w===void 0?void 0:b+(w-b)*y;S={lat:M(d.pose.lat,f.pose.lat),lng:M(d.pose.lng,f.pose.lng),elevationM:M(d.pose.elevationM,f.pose.elevationM)}}return{...i,lat:S?S.lat:l(y=>y.lat,!1)??i.lat,lng:S?S.lng:l(y=>y.lng,!1)??i.lng,elevationM:S?S.elevationM:l(y=>y.elevationM,!1)??i.elevationM,headingDeg:u??i.headingDeg,pitchDeg:l(y=>y.pitchDeg,!0)??i.pitchDeg,rollDeg:l(y=>y.rollDeg??0,!0)??i.rollDeg,fovDeg:l(y=>y.fovDeg,!0)??i.fovDeg}}get duration(){return this.keyframes.length===0?0:this.keyframes[this.keyframes.length-1].t}get allKeyframes(){return this.keyframes}toJSON(){return{keyframes:this.keyframes}}static fromJSON(t){const e=new Lo;for(const i of t.keyframes)e.addKeyframe(i.t,i.pose);return e}}class Ws{static MAX_CHANGE_PER_S=.05;points;followed;constructor(t){let e="none",i=0;this.points=t.map(({t:n,weather:s})=>(s.precipitationType!=="none"&&(e=s.precipitationType,i=s.precipitationIntensity),{t:n,lastFalling:e,lastFallingIntensity:i,intensity:s.precipitationType==="none"?0:s.precipitationIntensity,type:s.precipitationType})),this.followed=[];for(let n=0;n<this.points.length;n++){if(n===0){this.followed.push(this.points[0].intensity);continue}const s=this.points[n-1],a=this.points[n];this.followed.push(Ws.follow(this.followed[n-1],s.intensity,a.intensity,(a.t-s.t)/1e3,(a.t-s.t)/1e3))}}at(t){if(this.points.length===0||t<this.points[0].t)return;let e=this.points.length-1;for(;e>0&&this.points[e].t>t;)e--;const i=this.points[e],n=this.points[e+1],s=n?Ws.follow(this.followed[e],i.intensity,n.intensity,(n.t-i.t)/1e3,(t-i.t)/1e3):Ws.follow(this.followed[e],i.intensity,i.intensity,1,(t-i.t)/1e3);return{type:Ws.typeBetween(i,n,t,s),intensity:s,character:Ws.characterBetween(i,n,t)}}static characterBetween(t,e,i){return t.type==="none"?e&&e.type!=="none"?e.intensity:t.lastFallingIntensity:!e||e.type==="none"?t.intensity:t.intensity+(e.intensity-t.intensity)*(i-t.t)/(e.t-t.t||1)}static typeBetween(t,e,i,n){return t.type==="none"?e&&e.type!=="none"&&i>t.t?e.type:n>0?t.lastFalling:"none":e&&e.type==="none"&&n<=0?"none":t.type}static follow(t,e,i,n,s){const a=Ws.MAX_CHANGE_PER_S,o=n>0?(i-e)/n:0,c=u=>e+o*Math.min(Math.max(u,0),n);let l=t,h=0;for(let u=0;u<8&&h<s;u++){const d=c(h)-l;if(Math.abs(d)<1e-9){const y=h<n?o:0;if(Math.abs(y)<=a){const b=h<n?Math.min(s,n):s;l=c(b),h=b;continue}const M=Math.min(s,n);l+=Math.sign(y)*a*(M-h),h=M;continue}const f=Math.sign(d),p=h<n?o:0,v=a-f*p,m=v>0?h+Math.abs(d)/v:1/0,g=h<n?n:1/0,S=Math.min(s,m,g);l+=f*a*(S-h),h=S,S===m&&(l=c(h))}return Math.min(1,Math.max(0,l))}}function ze(r,t,e){return r+(t-r)*e}function Qd(r,t,e){const i=((t-r)%360+540)%360-180;return((r+i*e)%360+360)%360}function xv(r,t,e){return Math.max(t,Math.min(e,r))}function yv(r=[],t=[],e){if(!(!r.length&&!t.length))return[...new Set([...r.map(i=>i.id),...t.map(i=>i.id)])].map(i=>{const n=r.find(c=>c.id===i),s=t.find(c=>c.id===i),a=n??{...s,density:0},o=s??{...n,density:0};return{...a,eastM:ze(a.eastM,o.eastM,e),northM:ze(a.northM,o.northM,e),baseM:ze(a.baseM,o.baseM,e),thicknessM:ze(a.thicknessM,o.thicknessM,e),widthM:ze(a.widthM,o.widthM,e),depthM:ze(a.depthM,o.depthM,e),rotationDeg:Qd(a.rotationDeg,o.rotationDeg,e),density:ze(a.density,o.density,e),darkness:ze(a.darkness??0,o.darkness??0,e)}})}function _v(r,t,e){if(r.cloudLayers===void 0&&t.cloudLayers===void 0)return;const i=fl(r),n=fl(t);return e>=1?n.map(a=>({...a})):[...new Set([...i.map(a=>a.id),...n.map(a=>a.id)])].map(a=>{const o=i.find(u=>u.id===a),c=n.find(u=>u.id===a),l=o??{...c,coverage:0},h=c??{...o,coverage:0};return{...l,instances:yv(o?.instances,c?.instances,e),baseM:ze(l.baseM,h.baseM,e),thicknessM:ze(l.thicknessM,h.thicknessM,e),coverage:ze(l.coverage,h.coverage,e),sizeM:ze(l.sizeM,h.sizeM,e),density:ze(l.density,h.density,e),darkness:ze(l.darkness??r.cloudDarkness,h.darkness??t.cloudDarkness,e),iceCrystalAlignment:l.iceCrystalAlignment===void 0||h.iceCrystalAlignment===void 0?void 0:ze(l.iceCrystalAlignment,h.iceCrystalAlignment,e),windSpeed:l.windSpeed===void 0&&h.windSpeed===void 0?void 0:ze(l.windSpeed??r.windSpeed,h.windSpeed??t.windSpeed,e),windDirectionDeg:l.windDirectionDeg===void 0&&h.windDirectionDeg===void 0?void 0:Qd(l.windDirectionDeg??r.windDirectionDeg,h.windDirectionDeg??t.windDirectionDeg,e)}})}function Sv(r,t,e){return{cloudLayers:_v(r,t,e),cloudCover:ze(r.cloudCover,t.cloudCover,e),cloudDarkness:ze(r.cloudDarkness,t.cloudDarkness,e),highCloudCover:r.highCloudCover===void 0||t.highCloudCover===void 0?void 0:ze(r.highCloudCover,t.highCloudCover,e),iceCrystalAlignment:r.iceCrystalAlignment===void 0||t.iceCrystalAlignment===void 0?void 0:ze(r.iceCrystalAlignment,t.iceCrystalAlignment,e),lowerCloudCover:r.lowerCloudCover===void 0||t.lowerCloudCover===void 0?void 0:ze(r.lowerCloudCover,t.lowerCloudCover,e),cloudBaseM:r.cloudBaseM===void 0||t.cloudBaseM===void 0?void 0:ze(r.cloudBaseM,t.cloudBaseM,e),relativeHumidity:r.relativeHumidity===void 0||t.relativeHumidity===void 0?void 0:ze(r.relativeHumidity,t.relativeHumidity,e),precipitationType:e<1?r.precipitationType:t.precipitationType,precipitationIntensity:ze(r.precipitationIntensity,t.precipitationIntensity,e),windDirectionDeg:Qd(r.windDirectionDeg,t.windDirectionDeg,e),windSpeed:ze(r.windSpeed,t.windSpeed,e),storm:e<1?r.storm:t.storm}}class Oo{keyframes=[];ramp;addKeyframe(t,e){this.ramp=void 0;const i=this.findInsertIndex(t);this.keyframes[i]?.t===t?this.keyframes[i]={t,weather:e}:this.keyframes.splice(i,0,{t,weather:e})}clear(){this.ramp=void 0,this.keyframes.length=0}removeKeyframeAt(t){this.ramp=void 0;const e=this.findInsertIndex(t);this.keyframes[e]?.t===t&&this.keyframes.splice(e,1)}findInsertIndex(t){let e=0,i=this.keyframes.length;for(;e<i;){const n=e+i>>>1;this.keyframes[n].t<t?e=n+1:i=n}return e}getLatestWeatherAt(t){let e=this.findInsertIndex(t);return this.keyframes[e]?.t!==t&&(e-=1),e>=0?this.keyframes[e].weather:void 0}getInterpolatedWeatherAt(t){const e=this.findInsertIndex(t),i=this.keyframes[e]?.t===t?this.keyframes[e]:this.keyframes[e-1];if(i?.t===t)return i.weather;const n=this.keyframes[e]?.t===t?void 0:this.keyframes[e];return i?n?Sv(i.weather,n.weather,xv((t-i.t)/(n.t-i.t),0,1)):i.weather:n?.weather}getActualWeatherAt(t){const e=this.getInterpolatedWeatherAt(t);if(!e)return;const i=(this.ramp??=new Ws(this.keyframes)).at(t);if(!i)return e;const{type:n,intensity:s,character:a}=i,o=a>0?Math.min(1,s/a):n==="none"?0:1;return{...e,precipitationType:n,precipitationIntensity:a,precipitationAmount:o}}get duration(){return this.keyframes.length===0?0:this.keyframes[this.keyframes.length-1].t}get allKeyframes(){return this.keyframes}toJSON(){return{keyframes:this.keyframes}}static fromJSON(t){const e=new Oo;for(const i of t.keyframes)e.addKeyframe(i.t,i.weather);return e}}class No{keyframes=[];addKeyframe(t,e){const i=this.findInsertIndex(t);this.keyframes[i]?.t===t?this.keyframes[i]={t,sound:e}:this.keyframes.splice(i,0,{t,sound:e})}clear(){this.keyframes.length=0}removeKeyframeAt(t){const e=this.findInsertIndex(t);this.keyframes[e]?.t===t&&this.keyframes.splice(e,1)}getLatestSoundAt(t){let e=this.findInsertIndex(t);return this.keyframes[e]?.t!==t&&(e-=1),e>=0?this.keyframes[e].sound:void 0}getInterpolatedSoundAt(t){const e=this.findInsertIndex(t),i=this.keyframes[e]?.t===t?this.keyframes[e]:this.keyframes[e-1];if(i?.t===t)return i.sound;const n=this.keyframes[e]?.t===t?void 0:this.keyframes[e];if(!i)return n?.sound;if(!n)return i.sound;const s=(t-i.t)/(n.t-i.t);return this.lerp(i.sound,n.sound,Math.max(0,Math.min(1,s)))}get duration(){return this.keyframes.length===0?0:this.keyframes[this.keyframes.length-1].t}get allKeyframes(){return this.keyframes}toJSON(){return{keyframes:this.keyframes}}static fromJSON(t){const e=new No;for(const i of t.keyframes)e.addKeyframe(i.t,i.sound);return e}lerp(t,e,i){return{kind:i<1?t.kind:e.kind,volume:t.volume+(e.volume-t.volume)*i,pitchHz:t.pitchHz+(e.pitchHz-t.pitchHz)*i,src:i<1?t.src:e.src}}findInsertIndex(t){let e=0,i=this.keyframes.length;for(;e<i;){const n=e+i>>>1;this.keyframes[n].t<t?e=n+1:i=n}return e}}const bv=100,wv={kind:"none",volume:0,pitchHz:bv};class Mn{constructor(t){this.entries=t}static empty(){return new Mn(new Map)}get size(){return this.entries.size}at(t){return this.entries.get(t)}paths(){return[...this.entries.keys()]}set(t,e){e.basis==="stated"&&e.rationale===void 0?this.entries.delete(t):this.entries.set(t,e)}clear(t){for(const e of this.entries.keys())(e===t||e.startsWith(`${t}.`))&&this.entries.delete(e)}static strip(t){const e=new Mn(new Map);return{recording:Mn.stripValue(t,[],e),provenance:e}}static restore(t,e){if(e.size===0)return t;const i=structuredClone(t);for(const n of e.paths()){const s=e.at(n),a=n.split("."),o=Mn.holderOf(i,a);if(!o)continue;const c=a[a.length-1],l=o[c];l!==void 0&&(s.of!==void 0&&JSON.stringify(s.of)!==JSON.stringify(l)||(o[c]={value:l,...s.basis==="stated"?{}:{basis:s.basis},...s.rationale===void 0?{}:{rationale:s.rationale}}))}return i}static isWrapper(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)&&"value"in t}static stripValue(t,e,i){return Mn.isWrapper(t)?(i.set(e.join("."),{basis:t.basis??"stated",...t.rationale===void 0?{}:{rationale:t.rationale},of:t.value}),Mn.stripValue(t.value,e,i)):Array.isArray(t)?t.map((n,s)=>Mn.stripValue(n,[...e,String(s)],i)):typeof t=="object"&&t!==null?Object.fromEntries(Object.entries(t).map(([n,s])=>[n,Mn.stripValue(s,[...e,n],i)])):t}static holderOf(t,e){let i=t;for(const n of e.slice(0,-1)){if(typeof i!="object"||i===null)return;i=i[n]}return typeof i=="object"&&i!==null?i:void 0}}function wu(r){if(r.year!==void 0)return Date.UTC(r.year,(r.month??1)-1,r.day??1,r.hour??0,r.minute??0,r.second??0)}function af(r){return(((r.day??0)*24+(r.hour??0))*60+(r.minute??0))*6e4+(r.second??0)*1e3}const Ev=["year","month","day","hour","minute"],Av=["day","hour","minute"];function rf(r,t){return t.filter(e=>r[e]!==void 0).join(",")}function Tv(r){if(r.durationSeconds!==void 0)return r.durationSeconds*1e3;if(!r.time||!r.endTime)return;const t=r.time.year!==void 0&&r.endTime.year!==void 0,e=t?Ev:Av,i=rf(r.time,e);if(!(i===""||i!==rf(r.endTime,e)))return t?wu(r.endTime)-wu(r.time):af(r.endTime)-af(r.time)}class zl{constructor(t,e,i,n,s,a,o,c,l=[],h,u,d,f=[],p=[],v=[]){this.event=t,this.timeline=e,this.observerTrack=i,this.weatherTrack=n,this.soundTrack=s,this.observer=a,this.id=o,this.weather=c,this.decor=l,this.weatherSource=h,this.instrumentId=u,this.exposureSeconds=d,this.milestones=f,this.references=p,this.roads=v}provenance=Mn.empty();loadIssues=[];account;sources;interpretation;sway;lightPollution;iso;vehicle;get observerCount(){return 1+this.decor.filter(t=>t.kind==="observer").length}get exposure(){return this.exposureSeconds??this.instrument.exposureSeconds}get instrument(){return fi.byId(this.instrumentId)}static create(t,e,i){return new zl({eventType:"sighting",time:t,place:e},new kl,new Lo,new Oo,new No,i)}}const Rv=0,Dv=0;function di(r,t){const e=r.observerTrack.getInterpolatedPoseAt(t);if(e)return e;const i=r.event.place?.[0];if(i)return{lat:i.lat,lng:i.lng,elevationM:Rv,headingDeg:void 0,pitchDeg:Dv,fovDeg:fi.fieldOfViewDeg(r.instrument)}}function Vr(r,t){return r.weatherTrack.getInterpolatedWeatherAt(t)??r.weather??jd}function of(r,t){return r.weatherTrack.getActualWeatherAt(t)??r.weather??jd}function Iv(r,t){return r.soundTrack.getInterpolatedSoundAt(t)??wv}class Cv{constructor(t,e){this.timeline=t,this.onFrame=e}rafId=null;state="stopped";currentT=0;lastWallTime=0;playbackRate=1;loop=!1;onEnded;durationOverrideMs=0;get seekableDuration(){return Math.max(this.timeline.duration,this.durationOverrideMs)}play(){if(this.state==="playing")return;this.currentT>=this.seekableDuration&&(this.currentT=0,this.resolveFrame(0)),this.state="playing",this.lastWallTime=performance.now();const t=()=>{if(this.state!=="playing")return;const e=performance.now();if(this.currentT+=(e-this.lastWallTime)*this.playbackRate,this.lastWallTime=e,this.currentT>=this.seekableDuration){if(this.loop&&this.seekableDuration>0){this.currentT%=this.seekableDuration,this.resolveFrame(this.currentT),this.rafId=requestAnimationFrame(t);return}this.currentT=this.seekableDuration,this.stop(),this.resolveFrame(this.currentT),this.onEnded?.();return}this.resolveFrame(this.currentT),this.rafId=requestAnimationFrame(t)};this.rafId=requestAnimationFrame(t)}pause(){this.state==="playing"&&(this.state="paused",this.rafId!==null&&(cancelAnimationFrame(this.rafId),this.rafId=null))}stop(){this.state="stopped",this.rafId!==null&&(cancelAnimationFrame(this.rafId),this.rafId=null)}seek(t){this.currentT=Math.max(0,Math.min(t,this.seekableDuration)),this.resolveFrame(this.currentT)}get playbackState(){return this.state}get time(){return this.currentT}resolveFrame(t){const e=new Map;for(const i of this.timeline.sourceIds){const n=this.timeline.getInterpolatedShapeAt(t,i);n&&e.set(i,n)}this.onFrame(t,e)}}const og=["nw","n","ne","e","se","s","sw","w"],Pv=24,tc=8,Lv=3,Ov=8;function ec(r,t,e){const i=r.x-t.x,n=r.y-t.y,s=Math.cos(e),a=Math.sin(e);return{x:t.x+i*s-n*a,y:t.y+i*a+n*s}}function Wr(r){return{x:r.x+r.width/2,y:r.y+r.height/2}}const Nv={nw:{left:!0,top:!0},n:{top:!0},ne:{right:!0,top:!0},e:{right:!0},se:{right:!0,bottom:!0},s:{bottom:!0},sw:{left:!0,bottom:!0},w:{left:!0}};class cn{static handlePointsFor(t){const{x:e,y:i,width:n,height:s}=t.bounds,a={nw:{x:e,y:i},n:{x:e+n/2,y:i},ne:{x:e+n,y:i},e:{x:e+n,y:i+s/2},se:{x:e+n,y:i+s},s:{x:e+n/2,y:i+s},sw:{x:e,y:i+s},w:{x:e,y:i+s/2},rotate:{x:e+n/2,y:i-Pv}},o=Wr(t.bounds),c={};for(const l of Object.keys(a))c[l]=ec(a[l],o,t.angle);return c}static hitTestHandle(t,e,i=8,n=[...og,"rotate"]){const s=cn.handlePointsFor(t);for(const a of n)if(Math.hypot(e.x-s[a].x,e.y-s[a].y)<=i)return a}static HANDLE_DIRECTION_DEG={e:0,se:45,s:90,sw:135,w:180,nw:225,n:270,ne:315};static resizeAxisFor(t,e){const n=((cn.HANDLE_DIRECTION_DEG[t]+e*180/Math.PI)%180+180)%180/45,s=["ew","nwse","ns","nesw"];return s[Math.round(n)%s.length]}static resizeBounds(t,e,i,n){const s=Wr(t),a=ec(n,s,-e),{x:o,y:c,width:l,height:h}=t,u=Nv[i];let d=o,f=c,p=o+l,v=c+h;return u.left&&(d=Math.min(a.x,p-tc)),u.right&&(p=Math.max(a.x,d+tc)),u.top&&(f=Math.min(a.y,v-tc)),u.bottom&&(v=Math.max(a.y,f+tc)),{x:d,y:f,width:p-d,height:v-f}}static resizeShape(t,e,i){if(e==="rotate")throw new Error("resizeShape does not accept the rotate handle");const{width:n,height:s}=t.bounds,a=cn.resizeBounds(t.bounds,t.angle,e,i);if(t.kind==="oval")return{...t,bounds:a};const o=n===0?1:a.width/n,c=s===0?1:a.height/s;return{...t,bounds:a,points:t.points.map(l=>({x:l.x*o,y:l.y*c}))}}static rotateShape(t,e){const i=Wr(t.bounds),n=Math.atan2(e.y-i.y,e.x-i.x)+Math.PI/2;return{...t,angle:n}}static groupBoundsFor(t){const e=Math.min(...t.map(a=>a.x)),i=Math.min(...t.map(a=>a.y)),n=Math.max(...t.map(a=>a.x+a.width)),s=Math.max(...t.map(a=>a.y+a.height));return{x:e,y:i,width:n-e,height:s-i}}static vertexPointsFor(t){const e=Wr(t.bounds);return t.points.map(i=>ec({x:t.bounds.x+i.x,y:t.bounds.y+i.y},e,t.angle))}static hitTestVertex(t,e,i=Ov){const n=cn.vertexPointsFor(t);let s,a=i;return n.forEach((o,c)=>{const l=Math.hypot(e.x-o.x,e.y-o.y);l<=a&&(a=l,s=c)}),s}static toLocalPoint(t,e){const i=Wr(t.bounds),n=ec(e,i,-t.angle);return{x:n.x-t.bounds.x,y:n.y-t.bounds.y}}static moveVertex(t,e,i){const n=t.points.map((u,d)=>d===e?cn.toLocalPoint(t,i):u),s=Math.min(...n.map(u=>u.x)),a=Math.min(...n.map(u=>u.y)),o=Math.max(...n.map(u=>u.x)),c=Math.max(...n.map(u=>u.y)),l={x:t.bounds.x+s,y:t.bounds.y+a,width:o-s,height:c-a},h=n.map(u=>({x:u.x-s,y:u.y-a}));return{...t,bounds:l,points:h}}static insertVertexNear(t,e){const i=cn.toLocalPoint(t,e),{points:n}=t;let s=n.length-1,a=1/0;for(let c=0;c<n.length;c++){const l=n[c],h=n[(c+1)%n.length],u=cn.distanceToSegment(i,l,h);u<a&&(a=u,s=c)}const o=[...n.slice(0,s+1),i,...n.slice(s+1)];return{...t,points:o}}static distanceToSegment(t,e,i){const n=i.x-e.x,s=i.y-e.y,a=n*n+s*s,o=a===0?0:Math.max(0,Math.min(1,((t.x-e.x)*n+(t.y-e.y)*s)/a)),c=e.x+o*n,l=e.y+o*s;return Math.hypot(t.x-c,t.y-l)}static deleteVertex(t,e){return t.points.length<=Lv?t:{...t,points:t.points.filter((i,n)=>n!==e)}}}const Eu=6,ic=Eu/2,cf=20,lf=24,hf=9,uf=6,df=7,ff=6,Gn=4;class Fo{constructor(t){this.ctx=t}starPoints=0;roll=0;clear(t,e){this.ctx.clearRect(0,0,t,e)}static paintExtent(t){const{x:e,y:i,width:n,height:s}=t.bounds,a=e+n/2,o=i+s/2,c=t.angle%(2*Math.PI)!==0,l=Math.hypot(n,s)/2,h=c?l:n/2,u=c?l:s/2,d=Math.max(n,s)/2,f=t.brightness??0,p=f>0?Math.max(d*(1+hf*f),ff*f)-d:0,v=f>0?d*(1+df*f)-d:0,m=3*lf*(t.blur??0)+1.5*cf*t.haloScale,g=Math.max(p,v,0)+m+2;return{x:a-h-g,y:o-u-g,width:2*(h+g),height:2*(u+g)}}paintInto(t,e,i,n=!1){this.ctx.save(),this.ctx.scale(i,i),this.ctx.translate(-e.x,-e.y);const s=t.selected?{...t,selected:!1}:t;n?this.paintGhost(s,1.5):this.paintShape(s),this.ctx.restore()}paintShape(t){this.ctx.save(),this.ctx.globalAlpha=1-t.transparency;const e=t.blur??0;e>0&&(this.ctx.filter=`blur(${(lf*e).toFixed(2)}px)`);const i=t.brightness??0;i>0&&this.paintDazzle(t,i),t.haloScale>0&&this.paintHalo(t),this.paintBase(t),this.ctx.restore(),t.selected&&this.paintSelectionHandles(t)}setStarPoints(t){this.starPoints=Math.max(0,Math.floor(t))}setRoll(t){this.roll=t}paintDazzle(t,e){const{x:i,y:n,width:s,height:a}=t.bounds,o=i+s/2,c=n+a/2,l=Math.max(s,a)/2,h=Math.max(l*(1+hf*e),ff*e);if(h<=0)return;this.ctx.save(),this.ctx.globalCompositeOperation="lighter";const u=this.ctx.createRadialGradient(o,c,0,o,c,h);for(let d=0;d<=uf;d++){const f=d/uf,p=1/(1+24*f*f);this.ctx.globalAlpha=1,u.addColorStop(f,this.withAlpha(t.color,p*e*.55))}if(this.ctx.fillStyle=u,this.ctx.beginPath(),this.ctx.arc(o,c,h,0,2*Math.PI),this.ctx.fill(),this.starPoints>0){const d=l*(1+df*e);this.ctx.lineWidth=Math.max(1,l*.12),this.ctx.lineCap="round";for(let f=0;f<this.starPoints;f++){const p=f/this.starPoints*Math.PI*2+this.roll,v=o+Math.cos(p)*d,m=c+Math.sin(p)*d,g=this.ctx.createLinearGradient(o,c,v,m);g.addColorStop(0,this.withAlpha(t.color,e*.55)),g.addColorStop(.35,this.withAlpha(t.color,e*.22)),g.addColorStop(1,this.withAlpha(t.color,0)),this.ctx.strokeStyle=g,this.ctx.beginPath(),this.ctx.moveTo(o,c),this.ctx.lineTo(v,m),this.ctx.stroke()}}this.ctx.restore()}dazzledFill(t,e){if(e<=0)return t.color;const i=/^#([0-9a-f]{6})$/i.exec(t.color.trim());if(!i)return t.color;const n=Number.parseInt(i[1],16),s=a=>Math.round(a+(255-a)*e);return`rgb(${s(n>>16&255)}, ${s(n>>8&255)}, ${s(n&255)})`}withAlpha(t,e){const i=Math.max(0,Math.min(1,e)),n=/^#([0-9a-f]{6})$/i.exec(t.trim());if(!n)return t;const s=Number.parseInt(n[1],16);return`rgba(${s>>16&255}, ${s>>8&255}, ${s&255}, ${i.toFixed(3)})`}paintBase(t){this.ctx.fillStyle=this.dazzledFill(t,t.brightness??0),this.tracePath(t),this.ctx.fill()}paintGhost(t,e){this.ctx.save(),this.tracePath(t),this.ctx.setLineDash([e*3,e*2]),this.ctx.lineWidth=e,this.ctx.strokeStyle=t.color,this.ctx.stroke(),this.ctx.restore()}tracePath(t){if(this.ctx.beginPath(),t.kind==="oval"){const{x:e,y:i,width:n,height:s}=t.bounds,a=n/2,o=s/2;this.ctx.ellipse(e+a,i+o,a,o,t.angle,0,2*Math.PI)}else{const{x:e,y:i,width:n,height:s}=t.bounds;this.ctx.save(),this.ctx.translate(e+n/2,i+s/2),this.ctx.rotate(t.angle),this.ctx.translate(-n/2,-s/2),t.points.forEach((a,o)=>{o===0?this.ctx.moveTo(a.x,a.y):this.ctx.lineTo(a.x,a.y)}),this.ctx.closePath(),this.ctx.restore()}}paintHalo(t){this.ctx.save(),this.ctx.shadowColor=t.color,this.ctx.shadowBlur=cf*t.haloScale,this.paintBase(t),this.ctx.restore()}paintSelectionHandles(t){this.paintHandleFrame(cn.handlePointsFor(t),{includeRotate:!0}),t.kind==="polygon"&&this.paintVertexHandles(t)}paintVertexHandles(t){this.ctx.fillStyle="#39f";for(const e of cn.vertexPointsFor(t))this.ctx.beginPath(),this.ctx.ellipse(e.x,e.y,Gn,Gn,0,0,2*Math.PI),this.ctx.fill()}paintMemberOutline(t){this.paintOutline(cn.handlePointsFor(t))}paintSelectionOnly(t){this.paintSelectionHandles(t)}paintPictureFrame(t,e,i){const n=this.ctx;if(n.save(),t&&t.length===4){n.strokeStyle="#39f",n.lineWidth=1.5,n.setLineDash([6,4]),n.beginPath(),n.moveTo(t[0].x,t[0].y);for(const s of t.slice(1))n.lineTo(s.x,s.y);n.closePath(),n.stroke(),n.setLineDash([])}for(const s of e){const a=Fo.landmarkColour(s.residualDeg),o=s.selected?3:2;s.selected&&(n.strokeStyle="#fff",n.lineWidth=o+3,n.beginPath(),n.ellipse(s.picture.x,s.picture.y,Gn+2,Gn+2,0,0,2*Math.PI),n.stroke()),s.scene&&(n.strokeStyle=a,n.lineWidth=1,n.beginPath(),n.moveTo(s.picture.x,s.picture.y),n.lineTo(s.scene.x,s.scene.y),n.stroke(),n.fillStyle=a,n.beginPath(),n.ellipse(s.scene.x,s.scene.y,Gn,Gn,0,0,2*Math.PI),n.fill()),n.strokeStyle=a,n.lineWidth=o,n.beginPath(),n.ellipse(s.picture.x,s.picture.y,Gn+2,Gn+2,0,0,2*Math.PI),n.stroke(),this.paintLabel(s.label,s.picture.x+Gn+5,s.picture.y-Gn-2,a)}i&&this.paintLabel(i,8,8,"#fff",13),n.restore()}static landmarkColour(t){return t===void 0?"#ffb000":t<=1?"#3c3":t<=3?"#ffb000":"#f33"}paintLabel(t,e,i,n,s=11){const a=this.ctx;a.save(),a.font=`${s}px system-ui, sans-serif`,a.textBaseline="top";const o=a.measureText(t).width;a.fillStyle="rgba(0, 0, 0, 0.6)",a.fillRect(e-3,i-2,o+6,s+4),a.fillStyle=n,a.fillText(t,e,i),a.restore()}paintGroupHandles(t){this.paintHandleFrame(cn.handlePointsFor({bounds:t,angle:0}),{includeRotate:!0})}paintOutline(t){this.ctx.strokeStyle="lightgray",this.ctx.beginPath(),this.ctx.moveTo(t.nw.x,t.nw.y),this.ctx.lineTo(t.ne.x,t.ne.y),this.ctx.lineTo(t.se.x,t.se.y),this.ctx.lineTo(t.sw.x,t.sw.y),this.ctx.closePath(),this.ctx.stroke()}paintHandleFrame(t,{includeRotate:e}){this.paintOutline(t),this.ctx.fillStyle="lightgray";for(const i of og){const n=t[i];this.ctx.fillRect(n.x-ic,n.y-ic,Eu,Eu)}e&&(this.ctx.beginPath(),this.ctx.moveTo(t.n.x,t.n.y),this.ctx.lineTo(t.rotate.x,t.rotate.y),this.ctx.stroke(),this.ctx.beginPath(),this.ctx.ellipse(t.rotate.x,t.rotate.y,ic+1,ic+1,0,0,2*Math.PI),this.ctx.fill())}}const pf=.05,mf=.08,gf=2,vf=3,Fv=14,Uv=.02;class kv{context;voice;voiceToken=0;buffers=new Map;noiseBuffer;crackleBuffer;requested;level=1;master;output(t){return this.master||(this.master=t.createGain(),this.master.gain.value=this.level,this.master.connect(t.destination)),this.master}setLevel(t){this.level=t,this.master&&(this.master.gain.value=t)}resume(){if(!this.context){if(typeof AudioContext>"u")return;try{this.context=new AudioContext}catch(t){console.warn("SightingAudio: Web Audio unavailable, the sighting stays silent:",t);return}}Da.unlock(this.context)}setSound(t){if(this.requested=t,!this.context)return;const e=this.keyFor(t);if(!e){this.silence();return}if(this.voice?.key!==e){this.stopVoice();const i=++this.voiceToken;e.startsWith("src:")?this.buildRecordedVoice(t.src,e,i):this.voice=this.buildSynthesizedVoice(t,e)}this.applyTo(this.voice,t)}silence(){this.voiceToken++,this.stopVoice()}dispose(){this.silence(),this.context?.close(),this.context=void 0,this.master=void 0,this.buffers.clear(),this.noiseBuffer=void 0,this.crackleBuffer=void 0}keyFor(t){if(!(t.volume<=0))return t.src?`src:${t.src}`:t.kind==="none"?void 0:t.kind}applyTo(t,e){const i=this.context;if(!t||!i)return;const n=i.currentTime;t.volumeParam.setTargetAtTime(Math.max(0,Math.min(1,e.volume))*t.gainScale,n,pf);for(const{param:s,ratio:a}of t.pitch)s.setTargetAtTime(Math.min(e.pitchHz*a,i.sampleRate/2-1),n,pf)}buildSynthesizedVoice(t,e){const i=this.context;if(i)switch(t.kind){case"hum":return this.buildHum(i,e);case"whistle":return this.buildWhistle(i,e);case"rumble":return this.buildRumble(i,e);case"crackle":return this.buildCrackle(i,e);default:return}}buildHum(t,e){const i=t.createOscillator();i.type="sawtooth";const n=t.createOscillator();n.type="sawtooth";const s=t.createBiquadFilter();s.type="lowpass",s.Q.value=1;const a=t.createGain();return a.gain.value=0,i.connect(s),n.connect(s),s.connect(a).connect(this.output(t)),i.start(),n.start(),{key:e,nodes:[s,a],sources:[i,n],volumeParam:a.gain,gainScale:.16,pitch:[{param:i.frequency,ratio:1},{param:n.frequency,ratio:1.006},{param:s.frequency,ratio:6}]}}buildWhistle(t,e){const i=t.createOscillator();i.type="sine";const n=t.createOscillator();n.type="sine",n.frequency.value=5;const s=t.createGain(),a=t.createGain();return a.gain.value=0,n.connect(s).connect(i.frequency),i.connect(a).connect(this.output(t)),i.start(),n.start(),{key:e,nodes:[s,a],sources:[i,n],volumeParam:a.gain,gainScale:.22,pitch:[{param:i.frequency,ratio:1},{param:s.gain,ratio:.012}]}}buildRumble(t,e){const i=t.createBufferSource();i.buffer=this.brownNoise(t),i.loop=!0;const n=t.createBiquadFilter();n.type="lowpass",n.Q.value=.8;const s=t.createGain();return s.gain.value=0,i.connect(n).connect(s).connect(this.output(t)),i.start(),{key:e,nodes:[n,s],sources:[i],volumeParam:s.gain,gainScale:1.4,pitch:[{param:n.frequency,ratio:1}]}}buildCrackle(t,e){const i=t.createBufferSource();i.buffer=this.whiteNoise(t),i.loop=!0;const n=t.createBiquadFilter();n.type="bandpass",n.Q.value=1.2;const s=t.createGain();s.gain.value=0;const a=t.createBufferSource();a.buffer=this.crackleEnvelope(t),a.loop=!0;const o=t.createGain();return o.gain.value=0,a.connect(o).connect(s.gain),i.connect(n).connect(s).connect(this.output(t)),i.start(),a.start(),{key:e,nodes:[n,s,o],sources:[i,a],volumeParam:o.gain,gainScale:.9,pitch:[{param:n.frequency,ratio:4}]}}async buildRecordedVoice(t,e,i){const n=this.context;if(!n)return;let s;try{s=await this.getBuffer(t)}catch(c){console.warn("SightingAudio: the recorded sound failed to load, staying silent:",c);return}if(i!==this.voiceToken||!this.context)return;const a=n.createBufferSource();a.buffer=s,a.loop=!0;const o=n.createGain();o.gain.value=0,a.connect(o).connect(this.output(n)),a.start(),this.voice={key:e,nodes:[o],sources:[a],volumeParam:o.gain,gainScale:1,pitch:[]},this.requested&&this.applyTo(this.voice,this.requested)}async getBuffer(t){const e=this.context;if(!e)throw new Error("SightingAudio: AudioContext not ready — resume() must be called first");let i=this.buffers.get(t);return i||(i=fetch(t).then(n=>{if(!n.ok)throw new Error(`Audio fetch failed (${n.status}): ${t}`);return n.arrayBuffer()}).then(n=>e.decodeAudioData(n)),this.buffers.set(t,i)),i}whiteNoise(t){if(!this.noiseBuffer){const e=t.createBuffer(1,Math.floor(t.sampleRate*gf),t.sampleRate),i=e.getChannelData(0);for(let n=0;n<i.length;n++)i[n]=Math.random()*2-1;this.noiseBuffer=e}return this.noiseBuffer}brownNoise(t){const e=t.createBuffer(1,Math.floor(t.sampleRate*gf),t.sampleRate),i=e.getChannelData(0);let n=0,s=0;for(let a=0;a<i.length;a++)n=(n+.02*(Math.random()*2-1))/1.02,i[a]=n,s=Math.max(s,Math.abs(n));if(s>0)for(let a=0;a<i.length;a++)i[a]/=s;return e}crackleEnvelope(t){if(!this.crackleBuffer){const e=t.createBuffer(1,Math.floor(t.sampleRate*vf),t.sampleRate),i=e.getChannelData(0),n=Math.max(1,Math.floor(Uv*t.sampleRate)),s=Math.round(vf*Fv);for(let a=0;a<s;a++){const o=Math.floor(Math.random()*i.length),c=.4+Math.random()*.6;for(let l=0;l<n&&o+l<i.length;l++)i[o+l]=Math.max(i[o+l],c*(1-l/n))}this.crackleBuffer=e}return this.crackleBuffer}stopVoice(){const t=this.voice,e=this.context;if(this.voice=void 0,!t||!e)return;const i=e.currentTime;t.volumeParam.cancelScheduledValues(i),t.volumeParam.setTargetAtTime(0,i,mf/3);const n=i+mf;for(const s of t.sources){s.onended=()=>{s.disconnect();for(const a of t.nodes)a.disconnect()};try{s.stop(n)}catch{s.disconnect();for(const a of t.nodes)a.disconnect()}}}}class Zt{static svg(t){return`<svg viewBox="0 0 24 24" width="1.5em" height="1.5em" aria-hidden="true" focusable="false"><path d="${t}" fill="currentColor"/></svg>`}static outline(t){return`<svg viewBox="0 0 24 24" width="1.5em" height="1.5em" aria-hidden="true" focusable="false"><path d="${t}" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linejoin="round" stroke-linecap="round"/></svg>`}static solid(t){return`<svg viewBox="0 0 24 24" width="1.5em" height="1.5em" aria-hidden="true" focusable="false"><path d="${t}" fill="currentColor" fill-rule="evenodd"/></svg>`}static BOOKMARK="M6 3.5h12a.5.5 0 0 1 .5.5v16.5L12 16.8l-6.5 3.7V4a.5.5 0 0 1 .5-.5z";static PICTURE="M5 4h14a2 2 0 0 1 2 2v12a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2z";static PICTURE_HILLS="M4.5 17.5l4.5-6 3 4 2.5-3 5 5z";static PIN="M12 21.5s-6.5-5.7-6.5-10.8a6.5 6.5 0 0 1 13 0c0 5.1-6.5 10.8-6.5 10.8z";static PIN_HOLE="M12 8.4a2.4 2.4 0 1 0 0 4.8 2.4 2.4 0 0 0 0-4.8z";static MILESTONES_OFF=Zt.outline(Zt.BOOKMARK);static MILESTONES_ON=Zt.solid(Zt.BOOKMARK);static PICTURES_OFF=Zt.outline(`${Zt.PICTURE}${Zt.PICTURE_HILLS}`);static PICTURES_ON=Zt.solid(`${Zt.PICTURE}${Zt.PICTURE_HILLS}`);static MAP_OFF=Zt.outline(`${Zt.PIN}${Zt.PIN_HOLE}`);static MAP_ON=Zt.solid(`${Zt.PIN}${Zt.PIN_HOLE}`);static SHARE=Zt.outline("M14 4l7 7-7 7v-4.2C8.6 13.8 5.4 15.6 3.5 19c.6-5.6 3.4-9.6 10.5-10.8V4z");static FOLDED=Zt.svg("M15.4 7.4 14 6l-6 6 6 6 1.4-1.4L10.8 12z");static UNFOLDED=Zt.svg("M8.6 16.6 10 18l6-6-6-6-1.4 1.4 4.6 4.6z");static PLAY=Zt.svg("M7.4 5v14l11-7z");static PAUSE=Zt.svg("M6 5h4v14H6zM14 5h4v14h-4z");static VOLUME=Zt.svg("M2 9.5v5h3.5l4.5 4.5V5L5.5 9.5H2zm12.5 2.5A4 4 0 0 0 12.5 8.5v7A4 4 0 0 0 14.5 12zM12.5 4.2v2.1a6.5 6.5 0 0 1 0 11.4v2.1a8.6 8.6 0 0 0 0-15.6z");static MUTED=Zt.svg("M2 9.5v5h3.5l4.5 4.5V5L5.5 9.5H2zM15 9.8l1.4-1.4 2.6 2.6 2.6-2.6 1.4 1.4-2.6 2.6 2.6 2.6-1.4 1.4-2.6-2.6-2.6 2.6-1.4-1.4 2.6-2.6z");static ENTER_FULLSCREEN=Zt.svg("M5 5h5v2H7v3H5V5zm9 0h5v5h-2V7h-3V5zM5 14h2v3h3v2H5v-5zm12 0h2v5h-5v-2h3v-3z");static EXIT_FULLSCREEN=Zt.svg("M8 5h2v5H5V8h3V5zm6 0h2v3h3v2h-5V5zM5 14h5v5H8v-3H5v-2zm9 0h5v2h-3v3h-2v-5z")}function So(r){return[...r].sort((t,e)=>t.t-e.t)}function ih(r,t){let e;for(const i of So(r)){if(i.t>t)break;e=i}return e}const nh=Math.PI/180,nc=180/Math.PI;class Ss{constructor(t,e,i){this.kind=t,this.canvasHeightPx=e,this.fovDeg=i;const n=i*nh/2;this.focalPx=t==="equidistant"?e/2/n:e/2/Math.tan(n)}focalPx;static of(t,e,i){return new Ss(t.projection,e,i)}degToPx(t){const e=t*nh;return this.kind==="equidistant"?this.focalPx*e:2*this.focalPx*Math.tan(e/2)}pxToDeg(t){return this.kind==="equidistant"?t/this.focalPx*nc:2*Math.atan(t/(2*this.focalPx))*nc}angleDegToRadiusPx(t){const e=t*nh;return this.kind==="equidistant"?this.focalPx*e:this.focalPx*Math.tan(e)}halfWidthAngleDeg(t){return this.radiusPxToAngleDeg(this.canvasHeightPx*t/2)}radiusPxToAngleDeg(t){return this.kind==="equidistant"?t/this.focalPx*nc:Math.atan(t/this.focalPx)*nc}ofBounds(t){return{widthDeg:this.pxToDeg(t.width),heightDeg:this.pxToDeg(t.height)}}toBoundsSize(t){return{width:this.degToPx(t.widthDeg),height:this.degToPx(t.heightDeg)}}widthPx(t){return this.degToPx(Te.angularWidthDeg(t))}}class Ji{static fovOf(t,e){return di(t,e)?.fovDeg??fi.fieldOfViewDeg(t.instrument)}static toAngular(t){this.eachKeyframe(t,(e,i)=>({...e,angular:i.ofBounds(e.bounds)}))}static toBounds(t){this.eachKeyframe(t,(e,i)=>{if(!e.angular)return e;const{width:n,height:s}=i.toBoundsSize(e.angular),a={x:e.bounds.x+(e.bounds.width-n)/2,y:e.bounds.y+(e.bounds.height-s)/2,width:n,height:s};if(e.kind!=="polygon")return{...e,bounds:a};const o=e.bounds.width===0?1:n/e.bounds.width,c=e.bounds.height===0?1:s/e.bounds.height;return{...e,bounds:a,points:e.points.map(l=>({x:l.x*o,y:l.y*c}))}})}static toAim(t){this.eachKeyframe(t,(e,i,n)=>{const s=e.aim&&this.positionOf(t,e.aim,e.bounds,i,n);if(s&&Math.abs(s.x-e.bounds.x)<Ji.UNMOVED_PX&&Math.abs(s.y-e.bounds.y)<Ji.UNMOVED_PX)return e;const a=this.aimFrom(t,i,n,e.bounds);return a?{...e,aim:a}:e})}static UNMOVED_PX=.01;static aimOf(t,e,i){const n=Ss.of(t.instrument,Te.CANVAS_HEIGHT_PX,this.fovOf(t,e));return this.aimFrom(t,n,di(t,e),i)}static aimFrom(t,e,i,n){if(i?.headingDeg===void 0)return;const s=this.frameCentre(t),a=e.radiusPxToAngleDeg(n.x+n.width/2-s.x),o=e.radiusPxToAngleDeg(s.y-(n.y+n.height/2));return{azimuthDeg:((i.headingDeg+a)%360+360)%360,altitudeDeg:i.pitchDeg+o}}static toPosition(t){this.eachKeyframe(t,(e,i,n)=>{const s=e.aim&&this.positionOf(t,e.aim,e.bounds,i,n);return s?{...e,bounds:{...e.bounds,...s}}:e})}static positionOf(t,e,i,n,s){if(s?.headingDeg===void 0)return;const a=this.frameCentre(t),o=this.shortestArc(e.azimuthDeg-s.headingDeg),c=e.altitudeDeg-s.pitchDeg;return{x:a.x+this.offAxisPx(n,o)-i.width/2,y:a.y-this.offAxisPx(n,c)-i.height/2}}static frameCentre(t){return{x:fi.frameWidthPx(t.instrument,Te.CANVAS_HEIGHT_PX)/2,y:Te.CANVAS_HEIGHT_PX/2}}static shortestArc(t){return(t%360+540)%360-180}static offAxisPx(t,e){return Math.abs(e)>=Ji.OFF_CANVAS_DEG?Math.sign(e)*Ji.OFF_CANVAS_PX:t.angleDegToRadiusPx(e)}static OFF_CANVAS_DEG=89;static OFF_CANVAS_PX=1e5;static reproject(t,e,i){const n=fi.frameWidthPx(e,Te.CANVAS_HEIGHT_PX)/2,s=fi.frameWidthPx(t.instrument,Te.CANVAS_HEIGHT_PX)/2,a=Te.CANVAS_HEIGHT_PX/2;for(const o of[...t.timeline.allKeyframes]){const c=this.fovOf(t,o.t),l=i?.get(o.t)??c,h=Ss.of(e,Te.CANVAS_HEIGHT_PX,l),u=Ss.of(t.instrument,Te.CANVAS_HEIGHT_PX,c);t.timeline.addKeyframe(o.t,o.shapes.map(d=>{const{bounds:f}=d.shape,p=f.x+f.width/2-n,v=f.y+f.height/2-a,m=Math.hypot(p,v),g=m===0?1:u.angleDegToRadiusPx(h.radiusPxToAngleDeg(m))/m,S={...f,x:s+p*g-f.width/2,y:a+v*g-f.height/2};return{...d,shape:{...d.shape,bounds:S}}}))}this.toBounds(t)}static eachKeyframe(t,e){const{timeline:i}=t;for(const n of[...i.allKeyframes]){const s=di(t,n.t),a=this.fovOf(t,n.t),o=Ss.of(t.instrument,Te.CANVAS_HEIGHT_PX,a);i.addKeyframe(n.t,n.shapes.map(c=>({...c,shape:e(c.shape,o,s)})))}}}function zv(r){return Mn.restore(Bv(r),r.provenance)}function Bv(r){return Ji.toAngular(r),Ji.toAim(r),{version:1,id:r.id,time:r.event.time,endTime:r.event.endTime,durationSeconds:r.event.durationSeconds,utcOffsetHours:r.event.utcOffsetHours,timeZone:r.event.timeZone,place:r.event.place,observer:r.observer,account:r.account,sources:r.sources?.length?r.sources:void 0,sway:r.sway,vehicle:r.vehicle,description:r.event.description,tags:r.event.tags,timeline:r.timeline.toJSON(),observerTrack:r.observerTrack.toJSON(),weatherTrack:r.weatherTrack.toJSON(),soundTrack:r.soundTrack.toJSON(),weather:r.weather,decor:r.decor,milestones:r.milestones.length>0?r.milestones:void 0,references:r.references.length>0?r.references:void 0,roads:r.roads.length>0?r.roads:void 0,weatherSource:r.weatherSource,instrument:r.instrumentId,exposureSeconds:r.exposureSeconds,iso:r.iso,lightPollution:r.lightPollution,interpretation:r.interpretation}}function Hv(r){const{recording:t,provenance:e}=Mn.strip(r),i=Gv(t);return i.provenance=e,i}function Gv(r){const t=[],e=new zl({eventType:"sighting",time:r.time,endTime:r.endTime,durationSeconds:r.durationSeconds,utcOffsetHours:r.utcOffsetHours,timeZone:r.timeZone,place:r.place,description:r.description,tags:r.tags},kl.fromJSON(r.timeline,t),r.observerTrack?Lo.fromJSON(r.observerTrack):new Lo,r.weatherTrack?Oo.fromJSON(r.weatherTrack):new Oo,r.soundTrack?No.fromJSON(r.soundTrack):new No,r.observer&&{id:r.observer.id,title:r.observer.title,lastName:r.observer.lastName,firstNames:r.observer.firstNames},r.id,r.weather,r.decor??[],r.weatherSource,r.instrument,r.exposureSeconds??r.observerTrack?.keyframes.map(i=>i.pose.exposureSeconds).find(i=>i!==void 0),So(r.milestones??[]),r.references??[],r.roads??[]);return e.account=r.account,e.sources=r.sources,e.sway=r.sway,e.iso=r.iso,e.lightPollution=r.lightPollution,e.vehicle=r.vehicle,e.interpretation=r.interpretation,e.loadIssues=t,Ji.toBounds(e),Ji.toPosition(e),e}class Pr{static EN={"unknown-key":"{path}: unknown key, ignored","wrong-type":"{path}: expected {expected}, found {found}","not-in-list":"{path}: {found} is not one of {expected}",defaulted:"{path}: missing, {expected} used",unplaced:"{path}: no aim (and no bounds), drawn at the middle of the view",unsized:"{path}: no angular size (and no bounds), drawn one pixel wide","pixels-over-angles":"{path}: bounds restated without aim or angular, so the shape follows the pixels"};static text(t,e=Pr.EN){return e[t.kind].replace("{path}",t.path).replace("{expected}",t.expected??"").replace("{found}",t.found??"")}static warn(t,e){if(t.length===0)return;const i=t.map(n=>` ${Pr.text(n)}`);console.warn(`UFO@home: ${t.length} problem(s) in ${e??"this recording"}:
|
|
1342
1352
|
${i.join(`
|
|
1343
|
-
`)}`)}}class An{constructor(t){this.format=t}issues(t){const e=[];return this.object(t,this.format,"",e),e}object(t,e,i,n){if(!An.isObject(t)){n.push({kind:"wrong-type",path:i||"(the file)",expected:"object",found:An.typeOf(t)});return}for(const[s,a]of Object.entries(t)){const o=i?`${i}.${s}`:s,c=e[s];c?this.field(a,c,o,n):n.push({kind:"unknown-key",path:o})}}field(t,e,i,n){if(An.isStated(t)){this.field(t.value,e,i,n);return}if(!(e.loose||t===void 0||t===null))switch(e.type){case"enum":(typeof t!="string"||!e.values?.includes(t))&&n.push({kind:"not-in-list",path:i,expected:(e.values??[]).map(s=>`"${s}"`).join(", "),found:JSON.stringify(t)});return;case"object":e.fields?this.object(t,e.fields,i,n):An.isObject(t)||n.push({kind:"wrong-type",path:i,expected:"object",found:An.typeOf(t)});return;case"array":Array.isArray(t)?e.fields&&t.forEach((s,a)=>{const o=An.isStated(s)?s.value:s;this.object(o,e.fields,`${i}.${a}`,n)}):n.push({kind:"wrong-type",path:i,expected:"array",found:An.typeOf(t)});return;default:typeof t!==e.type&&n.push({kind:"wrong-type",path:i,expected:e.type,found:An.typeOf(t)})}}static isObject(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}static isStated(t){return An.isObject(t)&&"value"in t&&Object.keys(t).every(e=>e==="value"||e==="basis"||e==="rationale")}static typeOf(t){return Array.isArray(t)?"array":t===null?"null":typeof t}}class Cn{static PIXELS_PER_INSTANT=2;static INSTANTS_PER_FLASH=2;static MAX_INSTANTS=512;static windowEndingAt(t,e){const i=Number.isFinite(e)?Math.max(0,e):0,n=Math.max(0,t-i*1e3),s=Math.max(0,t-n);return{fromMs:n,toMs:t,ms:s,seconds:s/1e3}}static instants(t,e,i,n,s){if(!(n>0))return 1;const a=s>0?Cn.travelDegOver(t,e,i,i+n*1e3)/s/Cn.PIXELS_PER_INSTANT:0,o=Cn.flashesOver(t,n)*Cn.INSTANTS_PER_FLASH,c=Math.ceil(Math.max(a,o));return c<2?1:Math.min(Cn.MAX_INSTANTS,c)}static travelDegOver(t,e,i,n){let s=0;for(const a of t){if(!a.track||a.track.length<2)continue;const o=Cn.directionAt(a,e,i),c=Cn.directionAt(a,e,n),l=Math.min(1,Math.max(-1,o.x*c.x+o.y*c.y+o.z*c.z));s=Math.max(s,Math.acos(l)*180/Math.PI)}return s}static flashesOver(t,e){let i=0;for(const n of t)for(const s of n.lights??[])s.pattern.kind==="flash"&&(i=Math.max(i,s.pattern.perMinute));return i/60*e}static directionAt(t,e,i){const n=Co(t,i),s=n.eastM,a=n.altitudeM-e,o=n.northM,c=Math.hypot(s,a,o);return c===0?{x:0,y:1,z:0}:{x:s/c,y:a/c,z:o/c}}}function cg(r,t){for(const e of r){const i=e.toLowerCase().split("-")[0];if(t.includes(i))return i}return"en"}class pl{static preferencesFor(t){const e=navigator.languages??[],i=this.declaredFor(t);return i?[i,...e]:e}static declaredFor(t){for(let e=t;e;){const i=e.closest("[lang]")?.getAttribute("lang")?.trim();if(i)return i;const n=e.getRootNode();e=n instanceof ShadowRoot?n.host:void 0}}}class Ks{constructor(t){this.preferences=t}read(t){if(t===void 0||typeof t=="string")return t===""?void 0:t;for(const i of this.preferences){const n=t[i]??t[Ks.base(i)];if(n)return n}const e=new Set(this.preferences.map(i=>Ks.base(i)));for(const[i,n]of Object.entries(t))if(n&&e.has(Ks.base(i)))return n;return Object.values(t).find(i=>i)??void 0}write(t,e,i){const n=e?.trim()?e.trim():void 0;if(t===void 0||typeof t=="string")return n;const s={...t},a=Object.keys(s).find(o=>o===i)??Object.keys(s).find(o=>Ks.base(o)===Ks.base(i))??i;return n===void 0?delete s[a]:s[a]=n,Object.keys(s).length===0?void 0:s}static base(t){return t.toLowerCase().split("-")[0]}}const lg=["en","fr","es","it"],Vv={en:()=>is(()=>Promise.resolve().then(()=>Yv),void 0,import.meta.url).then(r=>r.ufoMessages_en),fr:()=>is(()=>import("./UfoMessages_fr-BnjRvJ7U.js"),[],import.meta.url).then(r=>r.ufoMessages_fr),es:()=>is(()=>import("./UfoMessages_es-Cm0EH1RY.js"),[],import.meta.url).then(r=>r.ufoMessages_es),it:()=>is(()=>import("./UfoMessages_it-BsE5MTYw.js"),[],import.meta.url).then(r=>r.ufoMessages_it)};function Wv(r){return Vv[r]()}function Xv(r){switch(r){case"fr":return is(()=>import("./SceneNames_fr-BbDQV822.js"),[],import.meta.url).then(t=>t.sceneNames_fr);case"es":return is(()=>import("./SceneNames_es-D17SooUd.js"),[],import.meta.url).then(t=>t.sceneNames_es);case"it":return is(()=>import("./SceneNames_it-DLcaIKpK.js"),[],import.meta.url).then(t=>t.sceneNames_it);default:return Promise.resolve(void 0)}}const hg={play:"Play",pause:"Pause",noDuration:"No observation duration",currentPosition:"Current position",duration:"Duration",switchToElapsed:"click to show elapsed time",switchToClockTime:"click to show the time of day",fullscreen:"Fullscreen",exitFullscreen:"Exit fullscreen",mute:"Mute",unmute:"Unmute",moments:"Moments",moreControls:"More controls",fewerControls:"Fewer controls",showObserverMap:"Show where the observer was",hideObserverMap:"Hide where the observer was",mapImageryUnavailable:"Aerial imagery unavailable",zoomMapIn:"Zoom in",zoomMapOut:"Zoom out",fitMap:"Back to the whole path",placeObserverHere:"Put the observer here",showReferences:"Show the pictures of the place",hideReferences:"Hide the pictures of the place",referenceOpacity:"Picture opacity",showMilestones:"Show the account's moments",hideMilestones:"Hide the account's moments",observerHere:"The observer, here",decorHere:"Scenery",recordingIssues:"{count} problem(s) in this recording: it may not play as its author meant",issueTemplates:Pr.EN},Yv=Object.freeze(Object.defineProperty({__proto__:null,ufoMessages_en:hg},Symbol.toStringTag,{value:"Module"})),ug=Math.PI/180,qv=180/Math.PI,$v=256,dg=19,Kv=1.25;function fg(r,t){return 156543.03392*Math.cos(r*ug)/2**t}function pg(r,t){return fg(r,t)*$v}function Zv(r,t){let e=0;for(;e<dg&&pg(r,e+1)>=t;)e++;return e}function mg(r,t){return pg(r,t)}function Jv(r,t){const e=t*Kv;let i=0;for(;i<dg&&fg(r,i)>e;)i++;return i}function el(r){const t=r*ug;return(1-Math.log(Math.tan(t)+1/Math.cos(t))/Math.PI)/2}function gg(r,t,e){const i=2**e;return{x:(r+180)/360*i,y:el(t)*i}}function vg(r,t,e){const i=el(r.north),n=el(r.south);return{x:(t-r.west)/(r.east-r.west),y:(el(e)-i)/(n-i)}}function jv(r,t,e){const{x:i,y:n}=gg(r,t,e);return{x:Math.floor(i),y:Math.floor(n),z:e}}function Qv(r){const t=2**r.z,e=r.x/t*360-180,i=(r.x+1)/t*360-180,n=Mf(r.y,t);return{south:Mf(r.y+1,t),north:n,west:e,east:i}}function Mf(r,t){const e=r/t;return Math.atan(Math.sinh(Math.PI*(1-2*e)))*qv}function Mg(r,t,e,i){const n=jv(r,t,e),s=Math.floor(i/2),a=[];for(let l=-s;l<=s;l++)for(let h=-s;h<=s;h++)a.push({x:n.x+h,y:n.y+l,z:e});const o=a.map(Qv),c={south:Math.min(...o.map(l=>l.south)),north:Math.max(...o.map(l=>l.north)),west:Math.min(...o.map(l=>l.west)),east:Math.max(...o.map(l=>l.east))};return{tiles:a,bounds:c}}class Ma{constructor(t){this.ctx=t}static SCALE_STEPS_M=[5e3,2e3,1e3,500,200,100,50,20,10,5];static MARKER_RADIUS_PX=8.5;static ON_MARKER_M=3;targets=[];hitTest(t,e){let i,n=1/0;for(const s of this.targets){const a=Math.hypot(s.x-t,s.y-e);a>s.radius||a>n||(i=s,n=a)}return i}get width(){return this.ctx.canvas.width}get height(){return this.ctx.canvas.height}paint(t){const{ctx:e}=this;e.save(),this.targets=[],e.clearRect(0,0,this.width,this.height),this.paintGround(t),this.paintNight(t.nightFraction),this.paintPath(t),t.position?(this.paintCone(t,t.position),this.paintDecor(t),this.paintMarkers(t),this.paintObserver(t,t.position)):(this.paintDecor(t),this.paintMarkers(t)),this.paintNorth(),this.paintFooter(t.bounds,t.attribution),e.restore()}toCanvas(t,e,i){const n=vg(t,i,e);return{x:n.x*this.width,y:n.y*this.height}}paintGround(t){const{ctx:e}=this;e.fillStyle="#1d2321",e.fillRect(0,0,this.width,this.height);const i=t.imagery;if(!i)return;const n=this.toCanvas(t.bounds,i.bounds.north,i.bounds.west),s=this.toCanvas(t.bounds,i.bounds.south,i.bounds.east);e.drawImage(i.source,n.x,n.y,s.x-n.x,s.y-n.y)}paintNight(t=0){if(t<=0)return;const{ctx:e}=this;e.save(),e.fillStyle=`rgba(6, 12, 30, ${Math.min(t,1)*.78})`,e.fillRect(0,0,this.width,this.height),e.restore()}paintDecor(t){const{ctx:e}=this;for(const i of t.decor){const n=this.toCanvas(t.bounds,i.lat,i.lng);if(i.label&&this.targets.push({kind:"decor",label:i.label,lat:i.lat,lng:i.lng,x:n.x,y:n.y,radius:7}),e.beginPath(),e.rect(n.x-3.5,n.y-3.5,7,7),e.fillStyle="rgba(120, 220, 255, 0.85)",e.fill(),e.lineWidth=1.5,e.strokeStyle="rgba(0, 0, 0, 0.7)",e.stroke(),i.headingDeg===void 0)continue;const s=(i.headingDeg-90)*Math.PI/180;e.beginPath(),e.moveTo(n.x,n.y),e.lineTo(n.x+Math.cos(s)*10,n.y+Math.sin(s)*10),e.lineWidth=3,e.strokeStyle="rgba(0, 0, 0, 0.6)",e.stroke(),e.lineWidth=1.5,e.strokeStyle="rgba(120, 220, 255, 0.9)",e.stroke()}}paintPath(t){if(!t.path.moved)return;const{ctx:e}=this,i=t.path.points.map(n=>this.toCanvas(t.bounds,n.lat,n.lng));e.beginPath(),e.moveTo(i[0].x,i[0].y);for(const n of i.slice(1))e.lineTo(n.x,n.y);e.lineJoin="round",e.lineCap="round",e.strokeStyle="rgba(0, 0, 0, 0.65)",e.lineWidth=5,e.stroke(),e.strokeStyle="rgba(255, 255, 255, 0.9)",e.lineWidth=2,e.stroke()}paintCone(t,e){const{headingDeg:i,coneHalfAngleDeg:n}=t;if(i===void 0||n===void 0)return;const{ctx:s}=this,a=this.toCanvas(t.bounds,e.lat,e.lng),o=Math.hypot(this.width,this.height),c=(i-90)*Math.PI/180,l=n*Math.PI/180;s.save(),s.beginPath(),s.moveTo(a.x,a.y),s.arc(a.x,a.y,o,c-l,c+l),s.closePath();const h=s.createRadialGradient(a.x,a.y,0,a.x,a.y,o);h.addColorStop(0,"rgba(255, 224, 130, 0.55)"),h.addColorStop(.35,"rgba(255, 224, 130, 0.22)"),h.addColorStop(1,"rgba(255, 224, 130, 0)"),s.fillStyle=h,s.fill(),s.restore()}paintMarkers(t){const{ctx:e}=this;e.textAlign="center",e.textBaseline="middle",e.font="bold 10px sans-serif";for(const i of[...t.markers].sort((n,s)=>Number(n.current)-Number(s.current))){const n=this.toCanvas(t.bounds,i.lat,i.lng);this.targets.push({kind:"milestone",label:i.note?`${i.label} — ${i.note}`:i.label,lat:i.lat,lng:i.lng,t:i.t,x:n.x,y:n.y,radius:Ma.MARKER_RADIUS_PX}),e.beginPath(),e.arc(n.x,n.y,Ma.MARKER_RADIUS_PX,0,Math.PI*2),e.fillStyle=i.current?"rgba(255, 224, 130, 0.95)":"rgba(0, 0, 0, 0.55)",e.fill(),e.lineWidth=2,e.strokeStyle="rgba(255, 255, 255, 0.9)",e.stroke(),e.fillStyle=i.current?"#1d2321":"#fff",e.fillText(i.label,n.x,n.y)}}paintObserver(t,e){const{ctx:i}=this,n=this.toCanvas(t.bounds,e.lat,e.lng);t.observerLabel&&this.targets.push({kind:"observer",label:t.observerLabel,lat:e.lat,lng:e.lng,x:n.x,y:n.y,radius:8});const s=t.markers.some(a=>{if(!a.current)return!1;const o=ai(a.lat,a.lng,e.lat,e.lng);return Math.hypot(o.x,o.z)<=Ma.ON_MARKER_M});i.beginPath(),i.arc(n.x,n.y,s?Ma.MARKER_RADIUS_PX+2.5:5.5,0,Math.PI*2),s||(i.fillStyle="#ff5a3c",i.fill()),i.lineWidth=4,i.strokeStyle="rgba(0, 0, 0, 0.5)",i.stroke(),i.lineWidth=s?3:2.5,i.strokeStyle=s?"#ff5a3c":"#fff",i.stroke()}paintNorth(){const{ctx:t}=this,e=this.width-14,i=16;t.beginPath(),t.moveTo(e,i-9),t.lineTo(e-4.5,i+5),t.lineTo(e,i+2),t.lineTo(e+4.5,i+5),t.closePath(),t.fillStyle="rgba(255, 255, 255, 0.92)",t.strokeStyle="rgba(0, 0, 0, 0.6)",t.lineWidth=1,t.fill(),t.stroke(),t.font="bold 9px sans-serif",t.textAlign="center",t.textBaseline="top",t.strokeText("N",e,i+6),t.fillText("N",e,i+6)}paintFooter(t,e){const{ctx:i}=this;i.font="9px sans-serif",i.textBaseline="bottom";const n=e?this.wrap(e,this.width-20):[];let s=this.height-4;i.textAlign="right";for(const f of n.slice().reverse())this.paintOutlinedText(f,this.width-6,s),s-=11;const a=(t.south+t.north)/2,c=Math.abs(ai(a,t.east,a,t.west).x)/this.width,l=Ma.SCALE_STEPS_M.find(f=>f/c<=this.width/3);if(l===void 0)return;const h=l/c,u=8,d=s-3;i.lineWidth=3,i.strokeStyle="rgba(0, 0, 0, 0.6)",i.beginPath(),i.moveTo(u,d),i.lineTo(u+h,d),i.stroke(),i.lineWidth=1.5,i.strokeStyle="rgba(255, 255, 255, 0.95)",i.stroke(),i.textAlign="left",this.paintOutlinedText(l>=1e3?`${l/1e3} km`:`${l} m`,u,d-3)}paintOutlinedText(t,e,i){const{ctx:n}=this;n.lineWidth=3,n.strokeStyle="rgba(0, 0, 0, 0.75)",n.strokeText(t,e,i),n.fillStyle="#fff",n.fillText(t,e,i)}wrap(t,e){const i=[];let n="";for(const s of t.split(" ")){const a=n?`${n} ${s}`:s;n&&this.ctx.measureText(a).width>e?(i.push(n),n=s):n=a}return n&&i.push(n),i}}class Ye{static MIN_ZOOM=.25;static MAX_ZOOM=64;zoom=1;centerX=.5;centerY=.5;get changed(){return this.zoom!==1||this.centerX!==.5||this.centerY!==.5}get zoomFactor(){return this.zoom}reset(){this.zoom=1,this.centerX=.5,this.centerY=.5}zoomAt(t,e,i){const n=Math.min(Ye.MAX_ZOOM,Math.max(Ye.MIN_ZOOM,this.zoom*i)),s=this.centerX+(t-.5)/this.zoom,a=this.centerY+(e-.5)/this.zoom;this.centerX=s-(t-.5)/n,this.centerY=a-(e-.5)/n,this.zoom=n}panBy(t,e){this.centerX-=t/this.zoom,this.centerY-=e/this.zoom}refit(t,e){if(!this.changed)return;const i=this.boundsWithin(t),n=Ye.mercatorY01(e.north),s=Ye.mercatorY01(e.south),a=Ye.mercatorY01(i.north),o=Ye.mercatorY01(i.south);this.zoom=(e.east-e.west)/(i.east-i.west),this.centerX=((i.west+i.east)/2-e.west)/(e.east-e.west),this.centerY=((a+o)/2-n)/(s-n)}keepInView(t,e,i){if(!this.changed)return!1;const n=this.boundsWithin(t),s=Ye.mercatorY01(n.north),a=Ye.mercatorY01(n.south),o=(e.lng-n.west)/(n.east-n.west),c=(Ye.mercatorY01(e.lat)-s)/(a-s);return o>=i&&o<=1-i&&c>=i&&c<=1-i?!1:(this.panBy(.5-o,.5-c),!0)}boundsWithin(t){if(!this.changed)return t;const e=.5/this.zoom,i=Ye.mercatorY01(t.north),n=Ye.mercatorY01(t.south),s=t.east-t.west;return{west:t.west+(this.centerX-e)*s,east:t.west+(this.centerX+e)*s,north:Ye.latitudeAt(i+(this.centerY-e)*(n-i)),south:Ye.latitudeAt(i+(this.centerY+e)*(n-i))}}static expand(t,e){const i=t.east-t.west,n=t.north-t.south;return{west:t.west-i*e,east:t.east+i*e,south:t.south-n*e,north:t.north+n*e}}static pointAt(t,e,i){const n=Ye.mercatorY01(t.north),s=Ye.mercatorY01(t.south);return{lat:Ye.latitudeAt(n+i*(s-n)),lng:t.west+e*(t.east-t.west)}}static mercatorY01(t){const e=t*Math.PI/180;return(1-Math.log(Math.tan(e)+1/Math.cos(e))/Math.PI)/2}static latitudeAt(t){return Math.atan(Math.sinh(Math.PI*(1-2*t)))*180/Math.PI}}const fn=256,xf=3,t2=32768;class e2{fetchImpl;tileUrlTemplate;constructor(t={}){this.fetchImpl=t.fetchImpl??fetch.bind(globalThis),this.tileUrlTemplate=t.tileUrlTemplate??"https://s3.amazonaws.com/elevation-tiles-prod/terrarium/{z}/{x}/{y}.png"}async getElevationGrid(t,e){const i=(t.south+t.north)/2,n=(t.west+t.east)/2,s=Math.abs(ai(i,t.east,i,t.west).x),a=Math.abs(ai(t.north,n,t.south,n).z),o=Zv(i,Math.max(s,a)),{tiles:c}=Mg(n,i,o,xf),l=xf*fn,h=new Float32Array(l*l),u=c[0];await Promise.all(c.map(f=>this.decodeTileInto(f,u,h,l)));const d=new Float32Array(e.width*e.height);for(let f=0;f<e.height;f++){const p=t.north+(t.south-t.north)*(f/(e.height-1));for(let v=0;v<e.width;v++){const m=t.west+(t.east-t.west)*(v/(e.width-1));d[f*e.width+v]=this.sampleAt(p,m,o,u,h,l)}}return{heights:d,width:e.width,height:e.height,bounds:t}}async decodeTileInto(t,e,i,n){const s=this.tileUrlTemplate.replace("{z}",String(t.z)).replace("{x}",String(t.x)).replace("{y}",String(t.y)),a=await this.fetchImpl(s);if(!a.ok)throw new Error(`Elevation tile fetch failed (${a.status}): ${s}`);const o=await createImageBitmap(await a.blob()),c=document.createElement("canvas");c.width=fn,c.height=fn;const l=c.getContext("2d");if(!l)throw new Error("2D canvas context unavailable");l.drawImage(o,0,0);const{data:h}=l.getImageData(0,0,fn,fn),u=(t.x-e.x)*fn,d=(t.y-e.y)*fn;for(let f=0;f<fn;f++)for(let p=0;p<fn;p++){const v=(f*fn+p)*4,m=h[v]*256+h[v+1]+h[v+2]/256-t2,g=u+p,S=d+f;i[S*n+g]=m}}sampleAt(t,e,i,n,s,a){const{x:o,y:c}=gg(e,t,i),l=(o-n.x)*fn,h=(c-n.y)*fn,u=Math.max(0,Math.min(a-1,Math.floor(l))),d=Math.max(0,Math.min(a-1,Math.floor(h))),f=Math.min(a-1,u+1),p=Math.min(a-1,d+1),v=l-u,m=h-d,g=s[d*a+u],S=s[d*a+f],y=s[p*a+u],M=s[p*a+f],b=g+(S-g)*v,w=y+(M-y)*v;return b+(w-b)*m}}const il=256,i2=5;async function n2(r,t,e,i){const n=(r.south+r.north)/2,s=(r.west+r.east)/2,a=Math.abs(ai(n,r.east,n,r.west).x),o=Math.abs(ai(r.north,s,r.south,s).z),c=Math.max(a,o),{zoom:l,gridSize:h}=s2(n,c,Math.max(t.width,t.height)),{tiles:u,bounds:d}=Mg(s,n,l,h),f=h*il,p=document.createElement("canvas");p.width=f,p.height=f;const v=p.getContext("2d");if(!v)throw new Error("2D canvas context unavailable");const m=u[0];await Promise.all(u.map(async M=>{const b=e(M),w=await i(b);if(!w.ok)throw new Error(`Imagery tile fetch failed (${w.status}): ${b}`);const T=await createImageBitmap(await w.blob());v.drawImage(T,(M.x-m.x)*il,(M.y-m.y)*il)}));const g=Math.min(Math.max(t.width,t.height),f);if(g===f)return{source:p,width:f,height:f,bounds:d};const S=document.createElement("canvas");S.width=g,S.height=g;const y=S.getContext("2d");if(!y)throw new Error("2D canvas context unavailable");return y.drawImage(p,0,0,f,f,0,0,g,g),{source:S,width:g,height:g,bounds:d}}function s2(r,t,e){let i=Jv(r,t/Math.max(1,e)),n=yf(r,i,t);for(;n>i2&&i>0;)i--,n=yf(r,i,t);return{zoom:i,gridSize:n,mPerPixel:mg(r,i)/il}}function yf(r,t,e){const i=Math.ceil(e/2/mg(r,t));return Math.max(3,2*i+1)}class a2{attribution="Imagery © Esri, Maxar, Earthstar Geographics, and the GIS User Community";fetchImpl;tileUrlTemplate;constructor(t={}){this.fetchImpl=t.fetchImpl??fetch.bind(globalThis),this.tileUrlTemplate=t.tileUrlTemplate??"https://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/{z}/{y}/{x}"}async getImageryTexture(t,e){return n2(t,e,i=>this.tileUrlTemplate.replace("{z}",String(i.z)).replace("{y}",String(i.y)).replace("{x}",String(i.x)),this.fetchImpl)}}class Tn{attribution="Roads © OpenStreetMap contributors, as surveyed today";contemporary=!0;static DRIVABLE=["motorway","trunk","primary","secondary","tertiary","unclassified","residential","service","track","motorway_link","trunk_link","primary_link","secondary_link","tertiary_link"];static WIDTH_M={motorway:11,trunk:9,primary:8,secondary:7,tertiary:6.5,unclassified:5.5,residential:5.5,service:4,track:3.5};static DEFAULT_WIDTH_M=5;static ENDPOINTS=["https://overpass-api.de/api/interpreter","https://overpass.kumi.systems/api/interpreter","https://overpass.private.coffee/api/interpreter"];fetchImpl;endpoints;constructor(t={}){this.fetchImpl=t.fetchImpl??fetch.bind(globalThis),this.endpoints=t.endpoints??Tn.ENDPOINTS}static queue=Promise.resolve();static RETRY_MS=4e3;async getRoads(t){const e=`${t.south},${t.west},${t.north},${t.east}`,i=`[out:json][timeout:30];way["highway"~"^(${Tn.DRIVABLE.join("|")})$"](${e});out geom;`;return this.waysFrom(await this.queued(()=>this.ask(i)))}waysFrom(t){const e=[];for(const i of t.elements??[]){const n=i.geometry,s=i.tags;!s||!n||n.length<2||e.push({id:`osm-${i.id??e.length}`,name:s.name,surface:Tn.surfaceOf(s),widthM:Tn.widthOf(s),points:n.map(a=>({lat:a.lat,lng:a.lon}))})}return e}queued(t){const e=Tn.queue.then(t,t);return Tn.queue=e.catch(()=>{}),e}async ask(t){let e;for(const i of this.endpoints)for(let n=0;n<2;n++){try{const s=await this.fetchImpl(`${i}?data=${encodeURIComponent(t)}`);if(s.ok)return await s.json();if(e=new Error(`${new URL(i).host} refused (${s.status})`),s.status!==429&&s.status!==504)break}catch(s){e=new Error(`${new URL(i).host} unreachable (${String(s)})`);break}await new Promise(s=>setTimeout(s,Tn.RETRY_MS))}throw e??new Error("No Overpass instance answered")}static widthOf(t){const e=Number.parseFloat(t.width??t.est_width??"");if(Number.isFinite(e)&&e>0)return e;const i=Number.parseInt(t.lanes??"",10);return Number.isFinite(i)&&i>0?i*3.5:Tn.WIDTH_M[t.highway]??Tn.DEFAULT_WIDTH_M}static surfaceOf(t){const e=t.surface;return e==="dirt"||e==="earth"||e==="mud"?"dirt":e==="gravel"||e==="fine_gravel"||e==="compacted"||e==="ground"||e==="sand"||e==="unpaved"?"gravel":e?"paved":t.highway==="track"?"gravel":"paved"}}const sh="https://ufoathome.org/roads/index.json";class t0{attributionRead;contemporaryRead;fetchImpl;indexUrls;fallback;index;constructor(t={}){this.fetchImpl=t.fetchImpl??fetch.bind(globalThis),this.indexUrls=t.indexUrls??t0.defaultIndexUrls(),this.fallback=t.fallback}get attribution(){return this.attributionRead??this.fallback?.attribution??"Roads © OpenStreetMap contributors"}get contemporary(){return this.contemporaryRead??this.fallback?.contemporary??!0}async getRoads(t){const e=await this.held(t);if(e)return e;if(!this.fallback)return[];const i=await this.fallback.getRoads(t);return this.attributionRead=this.fallback.attribution,this.contemporaryRead=this.fallback.contemporary,i}async held(t){let e;try{e=await this.load()}catch{return}const i=e.find(({entry:n})=>n.north>=t.north&&n.south<=t.south&&n.east>=t.east&&n.west<=t.west);if(i)try{const n=await this.fetchImpl(new URL(i.entry.file,i.indexUrl).href);if(!n.ok)return;const s=await n.json();return Array.isArray(s?.ways)?(this.attributionRead=s.attribution,this.contemporaryRead=s.contemporary,s.ways):void 0}catch{return}}load(){return this.index??=this.fetchFirstAvailable(),this.index}async fetchFirstAvailable(){for(const t of this.indexUrls)try{const e=await this.fetchImpl(t);if(!e.ok)continue;const i=await e.json();if(Array.isArray(i?.entries))return i.entries.map(n=>({entry:n,indexUrl:t}))}catch{}return[]}static defaultIndexUrls(){const t=`?v=${encodeURIComponent("0.81.6")}`,e=typeof location>"u"?void 0:new URL("/roads/index.json",location.href).href;return(e&&e!==sh?[e,sh]:[sh]).map(i=>i+t)}}function r2(){return{elevation:new e2,imagery:xg(),roads:o2()}}function xg(){return new a2}function o2(){return new t0({fallback:new Tn})}const c2=new Set,_r="show-observer-map",Sr="hide-milestones";class fe extends HTMLElement{static get observedAttributes(){return["src",_r,Sr]}shadow;stageElement;canvas;canvasRenderer;tooltip;toolbar;issuesBox;issuesButton;issuesPanel;playPauseButton;static OBSERVER_MAP_MIN_SPAN_M=400;static OBSERVER_MAP_MARGIN=.6;static OBSERVER_MAP_IMAGERY_PX=768;fullscreenButton;cornerButtons;observerMapButton;referencesButton;referenceOpacityInput;referencesShownState=!0;referenceOpacityTouched=!1;milestonesButton;observerMapPanel;observerMapCanvas;observerMapRenderer;mapZoomInButton;mapZoomOutButton;mapFitButton;observerMapView=new Ye;observerMapDrag;suppressObserverMapClick=!1;observerMapImageryTimer;observerPlacing=!1;seekInput;playbackFlash;milestoneMarks;milestoneCaption;timeStartLabel;timeEndLabel;timePill;muteButton;volumeInput;controlsRow;momentsBox;momentsButton;momentsCurrent;momentsMenu;moreButton;controlsRight;seekSegments;seekDot;seekPreview;seekPreviewCanvas;seekPreviewTitle;seekPreviewTime;observerPath;observerMapBounds;observerMapImagery;observerMapImageryBounds;observerMapImageryViewWidth=0;observerMapImageryLoading=!1;observerMapImageryCredit;observerMapImageryFailed=!1;creditShownExternally=!1;lookYawDeg=0;lookPitchDeg=0;milestonesShown=!0;currentSighting=zl.create();issues=[];issueCheck=0;sightingAudio=new kv;soundPreview;player;loopEnabled=!1;playbackBeforeClick;highlightedSourceIds=new Set;paintsShapes=!0;steadyObserver=!1;selectionShown=!0;overlayPainter;enableClickToPlay=!0;fullscreenTarget;messages=hg;realDurationMs;realStartMs;showClockTime=!0;handleFullscreenChange=()=>{this.updateFullscreenButton(),this.updateMuteButton(),this.resizeObserverMap()};controlsFitObserver=typeof ResizeObserver>"u"?void 0:new ResizeObserver(()=>this.fitControls());controlsMutations;fitControls(){const t=this.controlsRow,e=t.classList.contains("more-open"),i=()=>t.scrollWidth>t.clientWidth+1,n=!this.momentsMenu.hidden;if(this.momentsMenu.hidden=!0,t.classList.remove("narrow","more-open","nomoments","compact","tiny"),t.clientWidth>0&&i()){t.classList.add("narrow");for(const s of["nomoments","compact","tiny"]){if(!i())break;t.classList.add(s)}e&&t.classList.add("more-open")}this.momentsMenu.hidden=!n,this.updateMoreButton()}setControlsFolded(t){this.controlsRow.classList.toggle("more-open",!t),this.updateMoreButton()}updateMoreButton(){const t=this.controlsRow.classList.contains("more-open");fe.setIcon(this.moreButton,t?Zt.UNFOLDED:Zt.FOLDED);const e=t?this.messages.fewerControls:this.messages.moreControls;this.moreButton.title=e,this.moreButton.setAttribute("aria-label",e),this.moreButton.setAttribute("aria-expanded",String(t))}addControl(t){this.controlsRight.insertBefore(t,this.fullscreenButton.parentElement===this.controlsRight?this.fullscreenButton:null),this.fitControls()}observerMapResizeObserver=typeof ResizeObserver>"u"?void 0:new ResizeObserver(()=>this.resizeObserverMap());resizeObserverMap(){this.observerMapPanel.hidden||(this.sizeObserverMapCanvas(),this.paintObserverMap(this.currentTime))}simulatedFullscreen=!1;styleBeforeSimulatedFullscreen;bodyOverflowBeforeSimulatedFullscreen;handleSimulatedFullscreenKey=t=>{t.key==="Escape"&&this.exitSimulatedFullscreen()};handlePointerMove=t=>{const e=this.canvasPointFromEvent(t),i=e&&this.shapeAt(e.x,e.y),n=this.said.read(i?.shape.title);if(!n){this.tooltip.hidden=!0;return}this.tooltip.textContent=n,this.tooltip.hidden=!1;const s=this.stageElement.getBoundingClientRect();this.tooltip.style.left=`${t.clientX-s.left+12}px`,this.tooltip.style.top=`${t.clientY-s.top+12}px`};handleObserverMapPointerMove=t=>{if(this.dragObserverMap(t))return;const e=this.observerMapTargetFrom(t);if(!e){if(!this.observerPlacing){this.tooltip.hidden=!0,this.observerMapCanvas.style.cursor="grab";return}this.observerMapCanvas.style.cursor="crosshair",this.showObserverMapTooltip(t,this.messages.placeObserverHere);return}this.observerMapCanvas.style.cursor="pointer",this.showObserverMapTooltip(t,e.label)};showObserverMapTooltip(t,e){this.tooltip.textContent=e,this.tooltip.hidden=!1;const i=this.stageElement.getBoundingClientRect();this.tooltip.style.left=`${t.clientX-i.left+12}px`,this.tooltip.style.top=`${t.clientY-i.top+12}px`}handleObserverMapClick=t=>{if(this.suppressObserverMapClick){this.suppressObserverMapClick=!1;return}const e=this.observerMapTargetFrom(t);if(!e){this.observerPlacing&&this.placeObserverFrom(t);return}if(e.kind==="milestone"&&e.t!==void 0){this.player.seek(e.t);return}this.dispatchEvent(new CustomEvent("lookat",{detail:{lat:e.lat,lng:e.lng,kind:e.kind},bubbles:!0,composed:!0}))};observerMapTargetFrom(t){const e=this.observerMapCanvas.getBoundingClientRect();if(!(e.width===0||e.height===0))return this.observerMapRenderer.hitTest((t.clientX-e.left)/e.width*this.observerMapCanvas.width,(t.clientY-e.top)/e.height*this.observerMapCanvas.height)}handlePointerLeave=()=>{this.tooltip.hidden=!0};handleObserverMapPointerDown=t=>{t.button===0&&(this.suppressObserverMapClick=!1,this.observerMapDrag={pointerId:t.pointerId,startX:t.clientX,startY:t.clientY,lastX:t.clientX,lastY:t.clientY,moved:!1})};handleObserverMapPointerUp=t=>{const e=this.observerMapDrag;!e||e.pointerId!==t.pointerId||(this.observerMapDrag=void 0,this.observerMapCanvas.classList.remove("dragging"),e.moved&&(this.suppressObserverMapClick=!0,this.paintObserverMap(this.currentTime),this.observerMapCanvas.hasPointerCapture?.(t.pointerId)&&this.observerMapCanvas.releasePointerCapture(t.pointerId)))};dragObserverMap(t){const e=this.observerMapDrag;if(!e||e.pointerId!==t.pointerId)return!1;if(!e.moved){if(Math.hypot(t.clientX-e.startX,t.clientY-e.startY)<fe.OBSERVER_MAP_DRAG_PX)return!1;e.moved=!0,this.tooltip.hidden=!0,this.observerMapCanvas.classList.add("dragging"),this.observerMapCanvas.setPointerCapture?.(t.pointerId)}const i=this.observerMapCanvas.getBoundingClientRect();return i.width>0&&i.height>0&&(this.observerMapView.panBy((t.clientX-e.lastX)/i.width,(t.clientY-e.lastY)/i.height),this.observerMapViewChanged()),e.lastX=t.clientX,e.lastY=t.clientY,!0}static OBSERVER_MAP_DRAG_PX=4;handleObserverMapWheel=t=>{t.preventDefault();const e=this.observerMapCanvas.getBoundingClientRect();if(e.width===0||e.height===0)return;const i=t.deltaMode===0?t.deltaY:t.deltaY*40;this.zoomObserverMap((t.clientX-e.left)/e.width,(t.clientY-e.top)/e.height,Math.exp(-i*.002))};zoomObserverMap(t,e,i){this.observerMapView.zoomAt(t,e,i),this.observerMapViewChanged()}observerMapViewChanged(){this.mapFitButton.hidden=!this.observerMapView.changed,this.mapZoomInButton.disabled=this.observerMapView.zoomFactor>=Ye.MAX_ZOOM,this.mapZoomOutButton.disabled=this.observerMapView.zoomFactor<=Ye.MIN_ZOOM,this.paintObserverMap(this.currentTime),this.scheduleObserverMapImagery()}scheduleObserverMapImagery(){this.observerMapImageryTimer===void 0&&(this.observerMapImageryTimer=setTimeout(()=>{this.observerMapImageryTimer=void 0,this.loadObserverMapImagery()},fe.OBSERVER_MAP_IMAGERY_DELAY_MS))}static OBSERVER_MAP_FOLLOW_MARGIN=.1;static OBSERVER_MAP_IMAGERY_DELAY_MS=300;get observerMapViewBounds(){return this.observerMapBounds&&this.observerMapView.boundsWithin(this.observerMapBounds)}placeObserverFrom(t){const e=this.observerMapViewBounds,i=this.observerMapCanvas.getBoundingClientRect();if(!e||i.width===0||i.height===0)return;const n=Ye.pointAt(e,(t.clientX-i.left)/i.width,(t.clientY-i.top)/i.height);this.dispatchEvent(new CustomEvent("observerplace",{detail:n,bubbles:!0,composed:!0}))}constructor(){super(),this.shadow=this.attachShadow({mode:"open"});const t=document.createElement("template");t.innerHTML=`<style>${hv}</style>${lv}`,this.shadow.appendChild(t.content.cloneNode(!0)),this.stageElement=this.shadow.getElementById("stage"),this.canvas=this.shadow.getElementById("canvas"),this.canvasRenderer=new Fo(this.canvas.getContext("2d")),this.tooltip=this.shadow.getElementById("tooltip"),this.toolbar=this.shadow.getElementById("toolbar"),this.issuesBox=this.shadow.getElementById("issues"),this.issuesButton=this.shadow.getElementById("issues-button"),this.issuesPanel=this.shadow.getElementById("issues-panel"),this.issuesButton.addEventListener("click",e=>{e.stopPropagation(),this.issuesPanel.hidden=!this.issuesPanel.hidden,this.issuesButton.setAttribute("aria-expanded",String(!this.issuesPanel.hidden))}),this.playPauseButton=this.shadow.getElementById("play-pause"),this.fullscreenButton=this.shadow.getElementById("fullscreen"),this.cornerButtons=this.shadow.getElementById("corner-buttons"),this.observerMapButton=this.shadow.getElementById("observer-map"),this.referencesButton=this.shadow.getElementById("references"),this.referenceOpacityInput=this.shadow.getElementById("reference-opacity"),this.milestonesButton=this.shadow.getElementById("milestones"),this.observerMapPanel=this.shadow.getElementById("observer-map-panel"),this.observerMapCanvas=this.shadow.getElementById("observer-map-canvas"),this.observerMapRenderer=new Ma(this.observerMapCanvas.getContext("2d")),this.mapZoomInButton=this.shadow.getElementById("map-zoom-in"),this.mapZoomOutButton=this.shadow.getElementById("map-zoom-out"),this.mapFitButton=this.shadow.getElementById("map-fit"),this.seekInput=this.shadow.getElementById("seek"),this.playbackFlash=this.shadow.getElementById("playback-flash"),this.milestoneMarks=this.shadow.getElementById("milestone-marks"),this.milestoneCaption=this.shadow.getElementById("milestone-caption"),this.timeStartLabel=this.shadow.getElementById("time-start"),this.timeEndLabel=this.shadow.getElementById("time-end"),this.timePill=this.shadow.getElementById("time"),this.muteButton=this.shadow.getElementById("mute"),this.controlsRight=this.shadow.getElementById("controls-right"),this.seekSegments=this.shadow.getElementById("seek-segments"),this.seekDot=this.shadow.getElementById("seek-dot"),this.seekPreview=this.shadow.getElementById("seek-preview"),this.seekPreviewCanvas=this.shadow.getElementById("seek-preview-canvas"),this.seekPreviewTitle=this.shadow.getElementById("seek-preview-title"),this.seekPreviewTime=this.shadow.getElementById("seek-preview-time"),this.timePill.addEventListener("click",()=>this.toggleTimeDisplay()),this.timePill.addEventListener("keydown",e=>{e.key!=="Enter"&&e.key!==" "||(e.preventDefault(),this.toggleTimeDisplay())}),this.volumeInput=this.shadow.getElementById("volume"),this.controlsRow=this.shadow.querySelector(".controls"),this.momentsBox=this.shadow.getElementById("moments"),this.momentsButton=this.shadow.getElementById("moments-button"),this.momentsCurrent=this.shadow.getElementById("moments-current"),this.momentsMenu=this.shadow.getElementById("moments-menu"),this.momentsButton.addEventListener("click",()=>this.toggleMomentsMenu()),this.moreButton=this.shadow.getElementById("controls-more"),this.moreButton.addEventListener("click",()=>this.setControlsFolded(this.controlsRow.classList.contains("more-open"))),this.muteButton.addEventListener("click",()=>this.toggleMuted()),this.volumeInput.addEventListener("input",()=>{this.setVolume(Number(this.volumeInput.value))}),this.fullscreenTarget=this.stageElement,this.playPauseButton.addEventListener("click",()=>this.togglePlayPause()),this.fullscreenButton.addEventListener("click",()=>this.toggleFullscreen()),this.addEventListener("keydown",this.handleFullscreenKey),this.observerMapButton.addEventListener("click",()=>this.toggleObserverMap()),this.referencesButton.addEventListener("click",()=>this.toggleReferences()),this.referenceOpacityInput.addEventListener("input",()=>{this.referenceOpacityTouched=!0,this.dispatchReferenceView()}),this.milestonesButton.addEventListener("click",()=>this.toggleMilestones()),this.observerMapCanvas.addEventListener("pointermove",this.handleObserverMapPointerMove),this.observerMapCanvas.addEventListener("pointerleave",this.handlePointerLeave),this.observerMapCanvas.addEventListener("click",this.handleObserverMapClick),this.observerMapCanvas.addEventListener("pointerdown",this.handleObserverMapPointerDown),this.observerMapCanvas.addEventListener("pointerup",this.handleObserverMapPointerUp),this.observerMapCanvas.addEventListener("pointercancel",this.handleObserverMapPointerUp),this.observerMapCanvas.addEventListener("wheel",this.handleObserverMapWheel,{passive:!1}),this.mapZoomInButton.addEventListener("click",()=>this.zoomObserverMap(.5,.5,2)),this.mapZoomOutButton.addEventListener("click",()=>this.zoomObserverMap(.5,.5,.5)),this.mapFitButton.addEventListener("click",()=>{this.observerMapView.reset(),this.observerMapViewChanged()}),this.seekInput.addEventListener("input",()=>this.player.seek(this.snapSeekToMark(Number(this.seekInput.value)))),this.seekInput.addEventListener("pointerdown",e=>{this.suspendForScrub(),this.seekSnapArmed=!0,this.nameMarkUnder(e),this.beginTouchScrub(e)}),this.seekInput.addEventListener("pointerup",e=>{this.seekSnapArmed=!1,this.endTouchScrub(e)}),this.seekInput.addEventListener("pointercancel",e=>this.endTouchScrub(e)),this.seekInput.addEventListener("pointermove",e=>{this.nameMarkUnder(e),this.hoverSeek(e),this.touchScrub(e)}),this.seekInput.addEventListener("pointerleave",()=>{this.seekInput.removeAttribute("title"),this.leaveSeek()}),this.seekInput.addEventListener("keydown",this.handleSeekKey),this.stageElement.addEventListener("pointerdown",()=>{this.handlePointerDown(),this.touchedStage()},!0);for(const e of["touchend","click"])this.stageElement.addEventListener(e,()=>this.sightingAudio.resume(),!0);this.stageElement.addEventListener("pointermove",()=>this.touchedStage()),this.canvas.addEventListener("click",e=>{if(this.enableClickToPlay){if(this.tapRevealedOnly){this.tapRevealedOnly=!1;return}e.detail<=1&&(this.playbackBeforeClick={state:this.playbackState,time:this.currentTime}),this.togglePlayPause()}}),this.canvas.addEventListener("dblclick",e=>{this.enableClickToPlay&&(e.preventDefault(),this.restorePlayback(),this.toggleFullscreen())}),this.canvas.addEventListener("pointermove",this.handlePointerMove),this.canvas.addEventListener("pointerleave",this.handlePointerLeave),document.addEventListener("fullscreenchange",this.handleFullscreenChange),document.addEventListener("pointerdown",this.handleMomentsDismiss,!0),document.addEventListener("keydown",this.handleMomentsDismiss,!0),document.addEventListener("visibilitychange",this.handleVisibility),window.addEventListener("pagehide",this.handleHidden),document.addEventListener("pointerup",this.handlePointerRelease,!0),document.addEventListener("pointercancel",this.handlePointerRelease,!0),this.observerMapResizeObserver?.observe(this.observerMapPanel),this.controlsFitObserver?.observe(this.controlsRow),this.controlsFitObserver?.observe(this.controlsRow.querySelector(".controls-left")),typeof MutationObserver<"u"&&(this.controlsMutations=new MutationObserver(()=>this.fitControls()),this.controlsMutations.observe(this.controlsRight,{attributes:!0,attributeFilter:["hidden"],childList:!0,subtree:!0})),this.hostControls(void 0),this.player=this.createPlayer(),this.updateTimeLabels(),this.updatePlayPauseButton(),this.updateFullscreenButton(),this.updateMuteButton(),this.updateObserverMapButton(),this.updateReferencesButton(),this.updateMilestonesButton(),this.refresh()}connectedCallback(){this.saidTexts=void 0,this.loadLocaleMessages();const t=this.getAttribute("src");t&&this.loadFromSrc(t)}disconnectedCallback(){document.removeEventListener("fullscreenchange",this.handleFullscreenChange),document.removeEventListener("pointerdown",this.handleMomentsDismiss,!0),document.removeEventListener("keydown",this.handleMomentsDismiss,!0),document.removeEventListener("visibilitychange",this.handleVisibility),window.removeEventListener("pagehide",this.handleHidden),document.removeEventListener("pointerup",this.handlePointerRelease,!0),document.removeEventListener("pointercancel",this.handlePointerRelease,!0),window.clearTimeout(this.controlsIdleTimer),this.observerMapResizeObserver?.disconnect(),this.controlsFitObserver?.disconnect(),this.controlsMutations?.disconnect(),this.exitSimulatedFullscreen(),this.sightingAudio.dispose()}attributeChangedCallback(t,e,i){t==="src"&&i&&i!==e&&this.isConnected&&this.loadFromSrc(i),t===_r&&this.applyObserverMapDefault(),t===Sr&&this.setMilestonesShown(!this.hasAttribute(Sr))}async loadFromSrc(t){this.sightingData=await rg.json(t)}get sightingData(){return zv(this.currentSighting)}set sightingData(t){this.player.stop(),this.soundPreview=void 0,this.sightingAudio.silence(),this.currentSighting=Hv(t),this.issuesPanel.hidden=!0,this.issuesButton.setAttribute("aria-expanded","false"),this.reportIssues(t,this.currentSighting),this.observerMapView.reset(),this.mapFitButton.hidden=!0,this.observerMapAsked=!1,this.player=this.createPlayer(),this.updateTimeLabels(),this.updatePlayPauseButton(),this.refresh(),this.applyObserverMapDefault()}get recordingIssues(){return this.issues}async reportIssues(t,e){const i=++this.issueCheck;let n=[];try{const{default:s}=await is(async()=>{const{default:a}=await import("./sightingSchema-DOOSOVWK.js");return{default:a}},[],import.meta.url);n=new An(s).issues(t)}catch{}i===this.issueCheck&&(this.issues=[...n,...e.loadIssues],Pr.warn(this.issues,e.id),this.renderIssues(),this.dispatchEvent(new CustomEvent(l2,{detail:{issues:this.issues},bubbles:!0,composed:!0})))}renderIssues(){const t=this.issues.length;this.issuesBox.hidden=t===0,this.shadow.getElementById("issues-count").textContent=String(t);const e=this.messages.recordingIssues.replace("{count}",String(t));this.issuesButton.title=e,this.issuesButton.setAttribute("aria-label",e),this.shadow.getElementById("issues-title").textContent=e,this.shadow.getElementById("issues-list").replaceChildren(...this.issues.map(i=>{const n=document.createElement("li");return n.textContent=Pr.text(i,this.messages.issueTemplates),n}))}get sighting(){return this.currentSighting}previewSound(t){this.soundPreview=t,this.sightingAudio.resume(),this.sightingAudio.setSound(t)}stopSoundPreview(){this.soundPreview=void 0,this.sightingAudio.silence()}get canvasElement(){return this.canvas}get renderer(){return this.canvasRenderer}get currentTime(){return this.player.time}set currentTime(t){this.player.seek(t)}get seekableDuration(){return this.player.seekableDuration}get autoReplayEnabled(){return this.loopEnabled}set autoReplayEnabled(t){t!==this.loopEnabled&&this.toggleLoop()}play(){this.player.seekableDuration<=0||this.playbackState==="playing"||this.togglePlayPause()}pause(){this.playbackState==="playing"&&this.togglePlayPause()}get positionLabel(){return this.timeStartLabel.textContent??""}get durationLabel(){return this.timeEndLabel.textContent??""}get showingClockTime(){return this.canShowClockTime}get canSwitchTimeDisplay(){return this.realStartMs!==void 0}toggleTimeDisplay(){this.canSwitchTimeDisplay&&(this.showClockTime=!this.showClockTime,this.updateTimeLabels(),this.updateTimeLabelTitles(),this.dispatchEvent(new CustomEvent("timedisplaychange",{bubbles:!0,composed:!0})))}get canShowClockTime(){return this.realStartMs!==void 0&&this.showClockTime}set showToolbar(t){this.toolbar.classList.toggle("hidden",!t),t?this.controlsRight.appendChild(this.fullscreenButton):this.cornerButtons.appendChild(this.fullscreenButton)}get playbackState(){return this.player.playbackState}get selectedSourceIds(){return this.highlightedSourceIds}get durationSeconds(){return this.currentSighting.event.durationSeconds}set durationSeconds(t){this.currentSighting.event.durationSeconds=t,this.updateTimeLabels(),this.refresh(),this.updatePlayPauseButton()}set selectedSourceIds(t){const e=new Set(t);e.size===this.highlightedSourceIds.size&&[...e].every(n=>this.highlightedSourceIds.has(n))||(this.highlightedSourceIds=e,this.refresh())}hasVisibleShapeAt(t,e){return this.shapeAt(t,e)!==void 0}refresh(){this.applyFrameFormat(),this.updateTimeLabels(),this.seekInput.max=String(this.player.seekableDuration),this.refreshMilestoneMarks(),this.updateMilestonesButton(),this.updateObserverMap(),this.updateReferences(),this.player.seek(this.player.time)}hostControls(t){const e=[this.milestonesButton,this.referencesButton,this.referenceOpacityInput,this.observerMapButton];if(t)for(const i of e)t.appendChild(i);else{const i=this.fullscreenButton.parentElement===this.controlsRight?this.fullscreenButton:null;for(const n of e)this.controlsRight.insertBefore(n,i)}}get referencesShown(){return this.referencesShownState}get referenceOpacity(){return Number(this.referenceOpacityInput.value)}toggleReferences(){this.referencesShownState=!this.referencesShownState,this.updateReferencesButton(),this.dispatchReferenceView()}updateReferences(){const t=this.currentSighting.references;!this.referenceOpacityTouched&&t.length>0&&(this.referenceOpacityInput.value=String(t[0].opacity)),this.updateReferencesButton()}updateReferencesButton(){const t=this.currentSighting.references.length>0;this.referencesButton.hidden=!t,this.referenceOpacityInput.hidden=!t||!this.referencesShownState,this.referencesButton.setAttribute("aria-pressed",String(this.referencesShownState)),fe.setIcon(this.referencesButton,this.referencesShownState?Zt.PICTURES_ON:Zt.PICTURES_OFF);const e=this.referencesShownState?this.messages.hideReferences:this.messages.showReferences;this.referencesButton.title=e,this.referencesButton.setAttribute("aria-label",e),this.referenceOpacityInput.title=this.messages.referenceOpacity,this.referenceOpacityInput.setAttribute("aria-label",this.messages.referenceOpacity)}dispatchReferenceView(){this.dispatchEvent(new CustomEvent("referenceview",{detail:{shown:this.referencesShown,opacity:this.referenceOpacity}}))}refreshMilestoneMarks(){const t=this.player.seekableDuration,e=t>0?So(this.sighting.milestones):[];this.milestoneMarks.replaceChildren(...e.map(i=>{const n=document.createElement("button");n.type="button",n.className="milestone-mark",n.style.left=`${Math.min(Math.max(i.t/t,0),1)*100}%`;const s=this.said.read(i.label)??"",a=this.said.read(i.note),o=a?`${s} — ${a}`:s;return n.title=o,n.setAttribute("aria-label",o),n.dataset.t=String(i.t),n.addEventListener("click",()=>this.player.seek(i.t)),n})),this.refreshSeekSegments(t,e.map(i=>i.t)),this.refreshMomentsPicker(e)}refreshMomentsPicker(t){const e=this.milestonesShown&&t.length>0;this.momentsBox.hidden=!e,this.closeMomentsMenu(),this.momentsMenu.replaceChildren(...t.map(i=>{const n=document.createElement("li"),s=document.createElement("button");s.type="button",s.dataset.t=String(i.t);const a=this.said.read(i.label)??"",o=this.said.read(i.note);return s.textContent=o?`${a} — ${o}`:a,s.addEventListener("click",()=>{this.player.seek(i.t),this.closeMomentsMenu()}),n.appendChild(s),n})),this.momentsButton.title=this.messages.moments,this.showCurrentMoment(void 0)}showCurrentMoment(t){const i=(t?this.said.read(t.label)??"":"")||this.messages.moments;this.momentsCurrent.textContent!==i&&(this.momentsCurrent.textContent=i);for(const n of this.momentsMenu.querySelectorAll("button")){const s=t!==void 0&&Number(n.dataset.t)===t.t;n.getAttribute("aria-current")==="true"!==s&&n.setAttribute("aria-current",String(s))}}toggleMomentsMenu(){this.momentsMenu.hidden?(this.momentsMenu.hidden=!1,this.momentsButton.setAttribute("aria-expanded","true")):this.closeMomentsMenu()}closeMomentsMenu(){this.momentsMenu.hidden=!0,this.momentsButton.setAttribute("aria-expanded","false")}handleMomentsDismiss=t=>{if(!this.momentsMenu.hidden){if(t instanceof KeyboardEvent){t.key==="Escape"&&this.closeMomentsMenu();return}t.composedPath().some(e=>e===this.momentsMenu||e===this.momentsButton)||this.closeMomentsMenu()}};seekSegmentList=[];refreshSeekSegments(t,e){const n=[0,...this.milestonesShown&&t>0?[...new Set(e.filter(a=>a>0&&a<t))].sort((a,o)=>a-o):[],Math.max(t,0)];this.seekSegmentList=[];const s=[];for(let a=0;a<n.length-1;a++){const o=document.createElement("div");o.className="seek-segment",o.style.flexGrow=String(Math.max(n[a+1]-n[a],1));const c=document.createElement("i");c.className="seek-hover";const l=document.createElement("i");l.className="seek-played",o.append(c,l),s.push(o),this.seekSegmentList.push({start:n[a],end:n[a+1],element:o,played:l,hover:c})}this.seekSegments.replaceChildren(...s),this.paintSeekProgress(this.player.time)}static fillOf(t,e){const i=t.end-t.start,n=i>0?(e-t.start)/i:e>=t.end?1:0;return`${Math.min(Math.max(n,0),1)*100}%`}paintSeekProgress(t){for(const i of this.seekSegmentList)i.played.style.width=fe.fillOf(i,t);const e=this.player.seekableDuration;this.seekDot.style.left=`${e>0?Math.min(Math.max(t/e,0),1)*100:0}%`}hoverSeek(t){const e=this.seekInput.getBoundingClientRect(),i=this.player.seekableDuration;if(e.width<=0||i<=0)return;const n=Math.min(Math.max((t.clientX-e.left)/e.width,0),1),s=n*i,a=this.seekSegmentList.length-1;this.seekSegmentList.forEach((f,p)=>{f.hover.style.width=fe.fillOf(f,s),f.element.classList.toggle("hovered",s>=f.start&&(s<f.end||p===a))});const o=this.milestonesShown?this.sighting.milestones:[],c=o.length>0?ih(o,s):void 0,l=c?this.said.read(c.label)??"":"",h=c?this.said.read(c.note):void 0,u=h?`${l} — ${h}`:l;this.seekPreviewTitle.textContent=u,this.seekPreviewTime.textContent=this.formatPosition(s),this.seekPreview.hidden=!1;const d=this.seekPreview.offsetWidth;this.seekPreview.style.left=`${Math.min(Math.max(n*e.width-d/2,0),Math.max(e.width-d,0))}px`,this.paintSeekPreview(s)}leaveSeek(){for(const t of this.seekSegmentList)t.hover.style.width="0",t.element.classList.remove("hovered");this.seekPreview.hidden=!0}seekPreviewPainter;paintSeekPreview(t){const e=this.seekPreviewPainter;this.seekPreviewCanvas.hidden=e===void 0,e?.(t,this.seekPreviewCanvas)}scrubbingPointer;beginTouchScrub(t){if(t.pointerType!=="mouse"){this.scrubbingPointer=t.pointerId;try{this.seekInput.setPointerCapture(t.pointerId)}catch{}this.seekToPointer(t)}}touchScrub(t){t.pointerId===this.scrubbingPointer&&this.seekToPointer(t)}endTouchScrub(t){t.pointerId===this.scrubbingPointer&&(this.scrubbingPointer=void 0,this.seekToPointer(t))}seekToPointer(t){const e=this.seekInput.getBoundingClientRect(),i=this.player.seekableDuration;if(e.width<=0||i<=0)return;const n=Math.min(Math.max((t.clientX-e.left)/e.width,0),1);this.player.seek(this.snapSeekToMark(n*i))}seekSnapArmed=!1;static MARK_SNAP_PX=6;markNear(t){const e=this.player.seekableDuration,i=this.seekInput.getBoundingClientRect().width;if(e<=0||i<=0)return;const n=fe.MARK_SNAP_PX/i*e;let s;for(const a of this.milestoneMarks.children){const o=Number(a.dataset.t);Math.abs(o-t)>n||(!s||Math.abs(o-t)<Math.abs(s.t-t))&&(s={t:o,name:a.title})}return s}snapSeekToMark(t){return this.seekSnapArmed?(this.seekSnapArmed=!1,this.markNear(t)?.t??t):t}nameMarkUnder(t){const e=this.seekInput.getBoundingClientRect(),i=this.player.seekableDuration;if(e.width<=0||i<=0)return;const n=(t.clientX-e.left)/e.width*i,s=this.markNear(n);s?this.seekInput.title=s.name:this.seekInput.removeAttribute("title")}showMilestoneAt(t){const e=this.milestonesShown&&this.sighting.milestones.length>0?ih(this.sighting.milestones,t):void 0;if(this.milestoneCaption.hidden=e===void 0,this.showCurrentMoment(e),!e)return;const i=document.createElement("b");i.textContent=this.said.read(e.label)??"";const n=this.said.read(e.note),s=n?` — ${n}`:"";this.milestoneCaption.replaceChildren(i,document.createTextNode(s))}exposureInstants(t){const e=this.exposureTimes(t),i=1/e.length;return e.map(n=>({shapes:this.shapesAt(n),share:i}))}exposureTimes(t=this.currentTime){const e=Cn.windowEndingAt(t,this.currentSighting.exposure??0);if(e.ms<fe.SHORTEST_VISIBLE_EXPOSURE_MS)return[t];const i=Math.min(fe.MAX_EXPOSURE_STEPS,Math.max(2,Math.round(e.ms/fe.SHORTEST_VISIBLE_EXPOSURE_MS))),n=Math.ceil(this.travelPxOver(e.fromMs,e.ms)/fe.EXPOSURE_STEP_PX),s=Math.min(fe.MAX_TRAVEL_STEPS,Math.max(i,n)),a=[];for(let o=0;o<s;o++)a.push(e.fromMs+e.ms*o/(s-1));return a}travelPxOver(t,e){const i=this.shapesAt(t),n=this.shapesAt(t+e);let s=0;for(const[a,o]of i){const c=n.get(a);if(!c)continue;const l=c.bounds.x+c.bounds.width/2-(o.bounds.x+o.bounds.width/2),h=c.bounds.y+c.bounds.height/2-(o.bounds.y+o.bounds.height/2);s=Math.max(s,Math.hypot(l,h))}return s}shapeAt(t,e,i){for(const n of this.exposureTimes()){const s=this.currentSighting.timeline.hitTest(n,t,e,i);if(s)return s}}shapesAt(t){const e=new Map;for(const i of this.currentSighting.timeline.sourceIds){const n=this.currentSighting.timeline.getInterpolatedShapeAt(t,i);n&&e.set(i,n)}return e}static SHORTEST_VISIBLE_EXPOSURE_MS=20;static MAX_EXPOSURE_STEPS=48;static EXPOSURE_STEP_PX=2;static MAX_TRAVEL_STEPS=320;applyFrameFormat(){const t=fi.frameWidthPx(this.currentSighting.instrument,this.canvas.height);if(this.canvas.width===t)return;this.canvas.width=t,this.canvas.parentElement?.style.setProperty("--frame-aspect",`${t} / ${this.canvas.height}`)}canvasPointFromEvent(t){const e=this.canvas.getBoundingClientRect();if(!(e.width===0||e.height===0))return{x:(t.clientX-e.left)/e.width*this.canvas.width,y:(t.clientY-e.top)/e.height*this.canvas.height}}onFrame(t,e){this.canvasRenderer.clear(this.canvas.width,this.canvas.height);const i=this.playbackState!=="playing"?this.highlightedSourceIds:c2;this.canvasRenderer.setStarPoints(fi.starPointsOf(this.sighting.instrument));const n=(di(this.sighting,t)?.rollDeg??0)+this.gaitAt(t).rollDeg;this.canvasRenderer.setRoll(n*Math.PI/180);const s=this.exposureInstants(t),a=this.frameShift;if(this.paintsShapes)for(const o of s)for(const[,c]of o.shapes){const l=o.share,h=l===1?c:{...c,transparency:1-(1-c.transparency)*l};this.canvasRenderer.paintShape(this.shifted(h,a))}for(const[o,c]of s[0].shapes)!this.selectionShown||!i.has(o)||(this.paintsShapes?i.size===1?this.canvasRenderer.paintShape({...c,selected:!0}):this.canvasRenderer.paintMemberOutline(c):this.canvasRenderer.paintSelectionOnly(this.shifted(c,a)));if(this.selectionShown&&i.size>1){const o=cn.groupBoundsFor([...e].filter(([c])=>i.has(c)).map(([,c])=>c.bounds));this.canvasRenderer.paintGroupHandles(o)}this.overlayPainter?.(this.canvasRenderer),this.mapShapeBounds=s.flatMap(o=>[...o.shapes.values()].filter(c=>c.transparency<1).map(c=>this.shifted(c,a).bounds)),this.keepObserverMapClear(),this.seekInput.value=String(t),this.paintSeekProgress(t),this.timeStartLabel.textContent=this.formatPosition(t),this.showMilestoneAt(t),this.paintObserverMap(t),this.playbackState==="playing"?(this.soundPreview=void 0,this.sightingAudio.setSound(Iv(this.currentSighting,t))):this.soundPreview?this.sightingAudio.setSound(this.soundPreview):this.sightingAudio.silence(),this.updatePlayPauseButton(),this.dispatchEvent(new CustomEvent("timeupdate",{detail:{time:t}}))}shifted(t,e){return e.x===0&&e.y===0?t:{...t,bounds:{...t.bounds,x:t.bounds.x+e.x,y:t.bounds.y+e.y}}}createPlayer(){const t=new Cv(this.currentSighting.timeline,(e,i)=>this.onFrame(e,i));return t.loop=this.loopEnabled,t.onEnded=()=>{this.updatePlayPauseButton(),this.dispatchEvent(new CustomEvent("ended",{bubbles:!0,composed:!0}))},t}static SEEK_KEY_STEP_MS=5e3;handleFullscreenKey=t=>{t.key.toLowerCase()!=="f"||t.altKey||t.ctrlKey||t.metaKey||!this.enableClickToPlay||t.composedPath().some(i=>i instanceof HTMLElement&&(i.isContentEditable||["INPUT","TEXTAREA","SELECT"].includes(i.tagName)&&i.type!=="range"))||(t.preventDefault(),this.toggleFullscreen())};handleSeekKey=t=>{if(t.altKey||t.ctrlKey||t.metaKey)return;const e=t.key==="ArrowLeft"?-1:t.key==="ArrowRight"?1:0;if(e){t.preventDefault();const i=this.player.seekableDuration;this.player.seek(Math.min(i,Math.max(0,this.player.time+e*fe.SEEK_KEY_STEP_MS)))}else t.key===" "&&(t.preventDefault(),this.togglePlayPause())};togglePlayPause(){this.player.seekableDuration<=0||(this.player.playbackState==="playing"?(this.player.pause(),this.soundPreview=void 0,this.sightingAudio.silence(),this.refresh()):(this.sightingAudio.resume(),this.player.play()),this.updatePlayPauseButton(),this.flashPlayback())}flashPlayback(){const t=this.playbackFlash;t.innerHTML=this.player.playbackState==="playing"?Zt.PLAY:Zt.PAUSE,t.classList.remove("flashing"),t.offsetWidth,t.classList.add("flashing")}static icons=new WeakMap;static setIcon(t,e){fe.icons.get(t)!==e&&(fe.icons.set(t,e),t.innerHTML=e)}set captionHeld(t){this.stageElement.classList.toggle("caption-held",t)}static CONTROLS_IDLE_MS=3e3;controlsIdleTimer;wasPlaying=!1;tapRevealedOnly=!1;get hoverless(){return typeof matchMedia=="function"&&matchMedia("(hover: none)").matches}touchedStage(){if(!this.hoverless)return;this.player.playbackState==="playing"&&!this.stageElement.classList.contains("touched")&&(this.tapRevealedOnly=!0),this.revealControls()}pointerHeld=!1;handlePointerDown=()=>{this.pointerHeld=!0};resumeAfterScrub=!1;suspendForScrub(){this.player.playbackState==="playing"&&(this.resumeAfterScrub=!0,this.stopPlaying())}stopPlaying(){this.player.pause(),this.soundPreview=void 0,this.sightingAudio.silence(),this.refresh(),this.updatePlayPauseButton()}resumeFromScrub(){this.resumeAfterScrub&&(this.resumeAfterScrub=!1,this.sightingAudio.resume(),this.player.play(),this.updatePlayPauseButton())}handleHidden=()=>{this.player.playbackState==="playing"&&this.stopPlaying(),this.resumeAfterScrub=!1};handleVisibility=()=>{document.visibilityState==="hidden"&&this.handleHidden()};handlePointerRelease=()=>{this.resumeAfterScrub&&window.setTimeout(()=>this.resumeFromScrub(),0),this.pointerHeld&&(this.pointerHeld=!1,this.hoverless&&this.stageElement.classList.contains("touched")&&this.revealControls())};revealControls(){this.stageElement.classList.add("touched"),window.clearTimeout(this.controlsIdleTimer),this.player.playbackState==="playing"&&(this.pointerHeld||!this.momentsMenu.hidden||(this.controlsIdleTimer=window.setTimeout(()=>{this.stageElement.classList.remove("touched"),this.tapRevealedOnly=!1},fe.CONTROLS_IDLE_MS)))}updatePlayPauseButton(){const t=this.player.playbackState==="playing";this.stageElement.classList.toggle("paused",!t),t!==this.wasPlaying&&t&&this.hoverless&&this.revealControls(),this.wasPlaying=t,fe.setIcon(this.playPauseButton,t?Zt.PAUSE:Zt.PLAY);const e=this.player.seekableDuration>0;this.playPauseButton.disabled=!e;const i=e?t?this.messages.pause:this.messages.play:this.messages.noDuration;this.playPauseButton.title=i,this.playPauseButton.setAttribute("aria-label",i)}toggleLoop(){this.loopEnabled=!this.loopEnabled,this.player.loop=this.loopEnabled}restorePlayback(){const t=this.playbackBeforeClick;t&&(this.currentTime=t.time,t.state==="playing"?this.play():this.pause())}get canUseNativeFullscreen(){return typeof this.fullscreenTarget.requestFullscreen=="function"&&document.fullscreenEnabled}toggleFullscreen(){if(!this.canUseNativeFullscreen){this.simulatedFullscreen?this.exitSimulatedFullscreen():this.enterSimulatedFullscreen();return}document.fullscreenElement?document.exitFullscreen():this.fullscreenTarget.requestFullscreen().catch(t=>{console.error("<rr0-ufo>: requestFullscreen() failed —",t)})}enterSimulatedFullscreen(){const t=this.fullscreenTarget;this.styleBeforeSimulatedFullscreen=t.getAttribute("style")??"",this.bodyOverflowBeforeSimulatedFullscreen=document.body.style.overflow;const e=t.style;e.setProperty("position","fixed"),e.setProperty("inset","0"),e.setProperty("margin","0"),e.setProperty("max-width","none"),e.setProperty("max-height","none"),e.setProperty("aspect-ratio","auto"),e.setProperty("z-index","2147483647"),e.setProperty("background","#000"),e.setProperty("width","100vw"),e.setProperty("width","100dvw"),e.setProperty("height","100vh"),e.setProperty("height","100dvh"),document.body.style.overflow="hidden",this.simulatedFullscreen=!0,document.addEventListener("keydown",this.handleSimulatedFullscreenKey),this.updateFullscreenButton(),this.updateMuteButton()}exitSimulatedFullscreen(){if(!this.simulatedFullscreen)return;const t=this.fullscreenTarget;this.styleBeforeSimulatedFullscreen?t.setAttribute("style",this.styleBeforeSimulatedFullscreen):t.removeAttribute("style"),document.body.style.overflow=this.bodyOverflowBeforeSimulatedFullscreen??"",this.simulatedFullscreen=!1,document.removeEventListener("keydown",this.handleSimulatedFullscreenKey),this.updateFullscreenButton(),this.updateMuteButton()}toggleObserverMap(){const t=this.observerMapPanel.hidden;this.observerMapAsked=t,this.setObserverMapOpen(t),this.keepObserverMapClear()}observerMapAsked=!1;applyObserverMapDefault(){const t=this.getAttribute(_r),e=t===null?this.observerPath?.travels===!0:t!=="false";this.setObserverMapOpen(e&&this.observerPath!==void 0)}setObserverMapOpen(t){this.observerMapPanel.hidden=!t,this.observerMapPanel.removeAttribute("title"),this.observerMapButton.setAttribute("aria-pressed",String(t)),this.updateObserverMapButton(),t&&(this.sizeObserverMapCanvas(),this.loadObserverMapImagery(),this.paintObserverMap(this.currentTime))}updateObserverMapButton(){const t=!this.observerMapPanel.hidden;fe.setIcon(this.observerMapButton,t?Zt.MAP_ON:Zt.MAP_OFF);const e=t?this.messages.hideObserverMap:this.messages.showObserverMap;this.observerMapButton.title=e,this.observerMapButton.setAttribute("aria-label",e);const i=[[this.mapZoomInButton,this.messages.zoomMapIn],[this.mapZoomOutButton,this.messages.zoomMapOut],[this.mapFitButton,this.messages.fitMap]];for(const[n,s]of i)n.title=s,n.setAttribute("aria-label",s)}updateObserverMap(){const t=this.observerPath!==void 0;if(this.observerPath=yr.of(this.currentSighting),this.observerMapButton.hidden=this.observerPath===void 0,!t&&this.observerPath&&this.applyObserverMapDefault(),!this.observerPath){this.setObserverMapOpen(!1),this.observerMapBounds=void 0;return}const e=this.observerPath.boundsAround(fe.OBSERVER_MAP_MIN_SPAN_M,fe.OBSERVER_MAP_MARGIN);(!this.observerMapBounds||!this.sameGround(this.observerMapBounds,e))&&(this.observerMapBounds&&this.observerMapView.refit(this.observerMapBounds,e),this.observerMapBounds=e,this.observerMapImagery=void 0,this.observerMapImageryCredit=void 0,this.observerMapImageryFailed=!1,this.observerMapImageryBounds=void 0,this.observerMapImageryLoading=!1,this.observerMapPanel.hidden||this.loadObserverMapImagery())}sameGround(t,e){const i=Math.abs(t.east-t.west)/20;return Math.abs(t.north-e.north)<i&&Math.abs(t.south-e.south)<i&&Math.abs(t.west-e.west)<i&&Math.abs(t.east-e.east)<i}async loadObserverMapImagery(){const t=this.observerMapViewBounds;if(!t||this.observerMapPanel.hidden||this.observerMapImageryLoading||!this.observerMapImageryNeededFor(t))return;const e=this.observerMapView.changed,i=e?Ye.expand(t,fe.OBSERVER_MAP_IMAGERY_AHEAD):t,n=fe.OBSERVER_MAP_IMAGERY_PX*(e?1+2*fe.OBSERVER_MAP_IMAGERY_AHEAD:1);this.observerMapImageryBounds=i,this.observerMapImageryViewWidth=t.east-t.west,this.observerMapImageryLoading=!0;const s=xg();try{const a=await s.getImageryTexture(i,{width:n,height:n});if(this.observerMapImageryBounds!==i)return;this.observerMapImagery=a,this.observerMapImageryCredit=s.attribution,this.observerMapImageryFailed=!1}catch{if(this.observerMapImageryBounds!==i)return;this.observerMapImageryFailed=this.observerMapImagery===void 0}finally{this.observerMapImageryBounds===i&&(this.observerMapImageryLoading=!1)}this.paintObserverMap(this.currentTime),this.scheduleObserverMapImagery()}static OBSERVER_MAP_IMAGERY_AHEAD=.5;static OBSERVER_MAP_IMAGERY_LOOKAHEAD=.25;observerMapImageryNeededFor(t){const e=this.observerMapImageryBounds;if(!e)return!0;const i=this.observerMapImagery?.bounds??e,n=this.observerMapView.changed?Ye.expand(t,fe.OBSERVER_MAP_IMAGERY_LOOKAHEAD):t,s=n.west>=i.west&&n.east<=i.east&&n.south>=i.south&&n.north<=i.north,a=t.east-t.west>this.observerMapImageryViewWidth/2;return!s||!a}get observerMapCredit(){return this.observerMapImageryCredit}get observerMapFooterLine(){return this.observerMapImageryFailed?this.messages.mapImageryUnavailable:this.creditShownExternally?void 0:this.observerMapImageryCredit}mapShapeBounds=[];mapSceneBounds=[];setMapSubjectBounds(t){this.mapSceneBounds=t.map(e=>({x:e.x*this.canvas.width,y:e.y*this.canvas.height,width:e.width*this.canvas.width,height:e.height*this.canvas.height})),this.keepObserverMapClear()}keepObserverMapClear(){if(this.observerMapPanel.hidden)return;const t=this.observerMapBoxPx;if(!t)return;const e=[...this.mapShapeBounds,...this.mapSceneBounds],i=(l,h,u)=>{for(const d of e)if(!(d.x+d.width<l-u||d.x>h+u)&&!(d.y>t.bottom+u||d.y+d.height<t.top-u))return!0;return!1},n=[this.canvas.width-t.width,this.canvas.width],s=[0,t.width],a=fe.OBSERVER_MAP_CLEARANCE_PX,o=i(...n,0),c=i(...s,0);if(this.observerMapPanel.classList.toggle("subject-overlap",o&&c&&!this.observerMapAsked),this.observerMapPanel.classList.contains("on-the-left")){!o&&(c||!i(n[0],n[1],a))&&this.observerMapPanel.classList.remove("on-the-left");return}i(n[0],n[1],0)&&!i(s[0],s[1],0)&&this.observerMapPanel.classList.add("on-the-left")}observerMapBoxPx;static OBSERVER_MAP_CLEARANCE_PX=24;sizeObserverMapCanvas(){const t=this.observerMapPanel.clientWidth;if(t===0)return;const e=Math.round(t*(globalThis.devicePixelRatio??1));this.measureObserverMapBox(),this.observerMapCanvas.width!==e&&(this.observerMapCanvas.width=e,this.observerMapCanvas.height=e)}measureObserverMapBox(){const t=this.observerMapPanel.getBoundingClientRect(),e=this.canvas.getBoundingClientRect();if(e.width===0||e.height===0)return;const i=this.canvas.width/e.width,n=this.canvas.height/e.height;this.observerMapBoxPx={width:t.width*i,top:(t.top-e.top)*n,bottom:(t.bottom-e.top)*n}}paintObserverMap(t){if(this.observerMapPanel.hidden||!this.observerPath||!this.observerMapBounds)return;const e=di(this.currentSighting,t);e?.lat!==void 0&&e.lng!==void 0&&!this.observerMapDrag?.moved&&this.observerMapView.keepInView(this.observerMapBounds,{lat:e.lat,lng:e.lng},fe.OBSERVER_MAP_FOLLOW_MARGIN)&&this.scheduleObserverMapImagery();const i=this.currentSighting.instrument,n=[],s=this.currentSighting.milestones.length>0?ih(this.currentSighting.milestones,t):void 0;for(const a of this.milestonesShown?So(this.currentSighting.milestones):[]){const o=di(this.currentSighting,a.t);o?.lat===void 0||o.lng===void 0||n.push({label:this.said.read(a.label)??"",note:this.said.read(a.note),t:a.t,lat:o.lat,lng:o.lng,current:a===s})}this.observerMapRenderer.paint({bounds:this.observerMapViewBounds,imagery:this.observerMapImagery,path:this.observerPath,position:e?.lat!==void 0&&e.lng!==void 0?{lat:e.lat,lng:e.lng}:void 0,headingDeg:e?.headingDeg===void 0?void 0:e.headingDeg+this.lookYawDeg,coneHalfAngleDeg:e?Ss.of(i,this.canvas.height,e.fovDeg).halfWidthAngleDeg(fi.aspectOf(i)):void 0,markers:n,decor:this.observerMapDecorAt(t),observerLabel:this.said.read(this.currentSighting.observer?.title)??this.messages.observerHere,nightFraction:this.observerMapNightFraction,attribution:this.observerMapFooterLine})}toggleMilestones(){this.setMilestonesShown(!this.milestonesShown)}setMilestonesShown(t){this.milestonesShown=t,this.milestoneMarks.hidden=!t,this.momentsBox.hidden=!t||this.sighting.milestones.length===0,this.refreshSeekSegments(this.player.seekableDuration,So(this.sighting.milestones).map(e=>e.t)),this.milestonesButton.setAttribute("aria-pressed",String(t)),this.updateMilestonesButton(),this.showMilestoneAt(this.currentTime),this.paintObserverMap(this.currentTime)}updateMilestonesButton(){this.milestonesButton.hidden=this.currentSighting.milestones.length===0,this.momentsButton.title=this.messages.moments,fe.setIcon(this.milestonesButton,this.milestonesShown?Zt.MILESTONES_ON:Zt.MILESTONES_OFF);const t=this.milestonesShown?this.messages.hideMilestones:this.messages.showMilestones;this.milestonesButton.title=t,this.milestonesButton.setAttribute("aria-label",t)}observerMapDecorAt(t){const e=di(this.currentSighting,0);return e?.lat===void 0||e.lng===void 0?[]:this.currentSighting.decor.filter(i=>i.kind!=="crop").map(i=>{const n=Co(i,t),{lat:s,lng:a}=_s(n.eastM,-n.northM,e.lat,e.lng);return{lat:s,lng:a,headingDeg:n.headingDeg,label:this.said.read(i.title)??this.messages.decorHere}})}observerMapNightFraction;setSunAltitude(t){const e=t===void 0?void 0:Math.max(0,Math.min(1,-t/12));e!==this.observerMapNightFraction&&(this.observerMapNightFraction=e,this.paintObserverMap(this.currentTime))}setLookOffset(t,e){t===this.lookYawDeg&&e===this.lookPitchDeg||(this.lookYawDeg=t,this.lookPitchDeg=e,this.refresh())}get frameShiftPx(){return this.frameShift}get frameShift(){const t=this.gaitAt(this.currentTime),e=this.lookYawDeg+t.yawDeg,i=this.lookPitchDeg+t.pitchDeg;if(e===0&&i===0)return{x:0,y:0};const n=di(this.currentSighting,this.currentTime),s=Ss.of(this.currentSighting.instrument,this.canvas.height,n?.fovDeg??60);return{x:-s.angleDegToRadiusPx(e),y:s.angleDegToRadiusPx(i)}}gaitAt(t){return _e.bodyAt(this.currentSighting,t,this.steadyObserver)}mutedState=!1;get muted(){return this.mutedState}set muted(t){t!==this.mutedState&&(this.mutedState=t,!t&&this.volumeState===0&&(this.volumeState=fe.RESTORED_VOLUME),this.applyLevel())}volumeState=1;static RESTORED_VOLUME=.5;get volume(){return this.volumeState}set volume(t){this.setVolume(t)}setVolume(t){this.volumeState=Math.min(Math.max(t,0),1),this.mutedState=this.volumeState===0,this.applyLevel()}get level(){return this.mutedState?0:this.volumeState}applyLevel(){this.sightingAudio.setLevel(this.level),this.updateMuteButton(),this.dispatchEvent(new CustomEvent("mutedchange",{bubbles:!0,composed:!0,detail:{muted:this.mutedState,volume:this.volumeState}}))}toggleMuted(){this.muted=!this.mutedState}updateMuteButton(){fe.setIcon(this.muteButton,this.mutedState?Zt.MUTED:Zt.VOLUME);const t=this.mutedState?this.messages.unmute:this.messages.mute;this.muteButton.title=t,this.muteButton.setAttribute("aria-label",t),this.muteButton.setAttribute("aria-pressed",String(this.mutedState)),this.volumeInput.value=String(this.level)}updateFullscreenButton(){const t=this.simulatedFullscreen||document.fullscreenElement===this.fullscreenTarget;fe.setIcon(this.fullscreenButton,t?Zt.EXIT_FULLSCREEN:Zt.ENTER_FULLSCREEN),this.fullscreenButton.title=t?this.messages.exitFullscreen:this.messages.fullscreen,this.fullscreenButton.setAttribute("aria-label",this.fullscreenButton.title)}get said(){return this.saidTexts??=new Ks(pl.preferencesFor(this))}saidTexts;async loadLocaleMessages(){const t=cg(pl.preferencesFor(this),lg);if(t===this.messagesLanguage||t==="en"&&this.messagesLanguage===void 0)return;this.messagesLanguage=t;const e=await Wv(t);this.messagesLanguage===t&&this.applyMessages(e)}messagesLanguage;updateTimeLabelTitles(){const t=this.showClockTime?this.messages.switchToElapsed:this.messages.switchToClockTime,e=this.canSwitchTimeDisplay?` — ${t}`:"";this.timeStartLabel.title=this.messages.currentPosition+e,this.timeEndLabel.title=this.messages.duration+e,this.timePill.classList.toggle("switchable",this.canSwitchTimeDisplay),this.canSwitchTimeDisplay?(this.timePill.setAttribute("role","button"),this.timePill.setAttribute("tabindex","0")):(this.timePill.removeAttribute("role"),this.timePill.removeAttribute("tabindex"))}applyMessages(t){this.messages=t,this.updateTimeLabelTitles(),this.updatePlayPauseButton(),this.updateFullscreenButton(),this.updateMuteButton(),this.updateObserverMapButton(),this.updateReferencesButton(),this.updateMilestonesButton(),this.renderIssues()}updateTimeLabels(){const t=this.currentSighting.event,e=Tv(t);this.realDurationMs=e!==void 0&&e>0?e:void 0,this.realStartMs=t.time?wu(t.time):void 0;const i=this.currentSighting.timeline.duration;this.player.playbackRate=this.realDurationMs!==void 0&&i>0?i/this.realDurationMs:1,this.player.durationOverrideMs=i>0?0:this.realDurationMs??0,this.timeEndLabel.textContent=this.formatEndOfTimeline(),this.timeStartLabel.textContent=this.formatPosition(this.player.time),this.updateTimeLabelTitles()}formatPosition(t){if(this.realDurationMs===void 0)return sc(t);const e=this.currentSighting.timeline.duration,i=e>0&&t<=e?t/e*this.realDurationMs:t;return this.canShowClockTime?Sf(_f(this.realStartMs+i)):sc(i)}formatEndOfTimeline(){return this.realDurationMs===void 0?sc(this.currentSighting.timeline.duration):this.canShowClockTime?Sf(_f(this.realStartMs+this.realDurationMs)):sc(this.realDurationMs)}}function _f(r){const t=new Date(r);return{hour:t.getUTCHours(),minute:t.getUTCMinutes(),second:t.getUTCSeconds()}}function Sf(r){if(r.hour===void 0)return"0:00";const t=e=>String(e).padStart(2,"0");return r.second?`${t(r.hour)}:${t(r.minute??0)}:${t(r.second)}`:`${t(r.hour)}:${t(r.minute??0)}`}function sc(r){const t=Math.round(r/1e3),e=Math.floor(t/60),i=t%60;return`${e}:${String(i).padStart(2,"0")}`}const Au="rr0-ufo";function yg(){customElements.get(Au)||customElements.define(Au,fe)}const l2="recordingissues";/**
|
|
1353
|
+
`)}`)}}class An{constructor(t){this.format=t}issues(t){const e=[];return this.object(t,this.format,"",e),e}object(t,e,i,n){if(!An.isObject(t)){n.push({kind:"wrong-type",path:i||"(the file)",expected:"object",found:An.typeOf(t)});return}for(const[s,a]of Object.entries(t)){const o=i?`${i}.${s}`:s,c=e[s];c?this.field(a,c,o,n):n.push({kind:"unknown-key",path:o})}}field(t,e,i,n){if(An.isStated(t)){this.field(t.value,e,i,n);return}if(!(e.loose||t===void 0||t===null))switch(e.type){case"enum":(typeof t!="string"||!e.values?.includes(t))&&n.push({kind:"not-in-list",path:i,expected:(e.values??[]).map(s=>`"${s}"`).join(", "),found:JSON.stringify(t)});return;case"object":e.fields?this.object(t,e.fields,i,n):An.isObject(t)||n.push({kind:"wrong-type",path:i,expected:"object",found:An.typeOf(t)});return;case"array":Array.isArray(t)?e.fields&&t.forEach((s,a)=>{const o=An.isStated(s)?s.value:s;this.object(o,e.fields,`${i}.${a}`,n)}):n.push({kind:"wrong-type",path:i,expected:"array",found:An.typeOf(t)});return;default:typeof t!==e.type&&n.push({kind:"wrong-type",path:i,expected:e.type,found:An.typeOf(t)})}}static isObject(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}static isStated(t){return An.isObject(t)&&"value"in t&&Object.keys(t).every(e=>e==="value"||e==="basis"||e==="rationale")}static typeOf(t){return Array.isArray(t)?"array":t===null?"null":typeof t}}class Cn{static PIXELS_PER_INSTANT=2;static INSTANTS_PER_FLASH=2;static MAX_INSTANTS=512;static windowEndingAt(t,e){const i=Number.isFinite(e)?Math.max(0,e):0,n=Math.max(0,t-i*1e3),s=Math.max(0,t-n);return{fromMs:n,toMs:t,ms:s,seconds:s/1e3}}static instants(t,e,i,n,s){if(!(n>0))return 1;const a=s>0?Cn.travelDegOver(t,e,i,i+n*1e3)/s/Cn.PIXELS_PER_INSTANT:0,o=Cn.flashesOver(t,n)*Cn.INSTANTS_PER_FLASH,c=Math.ceil(Math.max(a,o));return c<2?1:Math.min(Cn.MAX_INSTANTS,c)}static travelDegOver(t,e,i,n){let s=0;for(const a of t){if(!a.track||a.track.length<2)continue;const o=Cn.directionAt(a,e,i),c=Cn.directionAt(a,e,n),l=Math.min(1,Math.max(-1,o.x*c.x+o.y*c.y+o.z*c.z));s=Math.max(s,Math.acos(l)*180/Math.PI)}return s}static flashesOver(t,e){let i=0;for(const n of t)for(const s of n.lights??[])s.pattern.kind==="flash"&&(i=Math.max(i,s.pattern.perMinute));return i/60*e}static directionAt(t,e,i){const n=Co(t,i),s=n.eastM,a=n.altitudeM-e,o=n.northM,c=Math.hypot(s,a,o);return c===0?{x:0,y:1,z:0}:{x:s/c,y:a/c,z:o/c}}}function cg(r,t){for(const e of r){const i=e.toLowerCase().split("-")[0];if(t.includes(i))return i}return"en"}class pl{static preferencesFor(t){const e=navigator.languages??[],i=this.declaredFor(t);return i?[i,...e]:e}static declaredFor(t){for(let e=t;e;){const i=e.closest("[lang]")?.getAttribute("lang")?.trim();if(i)return i;const n=e.getRootNode();e=n instanceof ShadowRoot?n.host:void 0}}}class Ks{constructor(t){this.preferences=t}read(t){if(t===void 0||typeof t=="string")return t===""?void 0:t;for(const i of this.preferences){const n=t[i]??t[Ks.base(i)];if(n)return n}const e=new Set(this.preferences.map(i=>Ks.base(i)));for(const[i,n]of Object.entries(t))if(n&&e.has(Ks.base(i)))return n;return Object.values(t).find(i=>i)??void 0}write(t,e,i){const n=e?.trim()?e.trim():void 0;if(t===void 0||typeof t=="string")return n;const s={...t},a=Object.keys(s).find(o=>o===i)??Object.keys(s).find(o=>Ks.base(o)===Ks.base(i))??i;return n===void 0?delete s[a]:s[a]=n,Object.keys(s).length===0?void 0:s}static base(t){return t.toLowerCase().split("-")[0]}}const lg=["en","fr","es","it"],Vv={en:()=>is(()=>Promise.resolve().then(()=>Yv),void 0,import.meta.url).then(r=>r.ufoMessages_en),fr:()=>is(()=>import("./UfoMessages_fr-BnjRvJ7U.js"),[],import.meta.url).then(r=>r.ufoMessages_fr),es:()=>is(()=>import("./UfoMessages_es-Cm0EH1RY.js"),[],import.meta.url).then(r=>r.ufoMessages_es),it:()=>is(()=>import("./UfoMessages_it-BsE5MTYw.js"),[],import.meta.url).then(r=>r.ufoMessages_it)};function Wv(r){return Vv[r]()}function Xv(r){switch(r){case"fr":return is(()=>import("./SceneNames_fr-BbDQV822.js"),[],import.meta.url).then(t=>t.sceneNames_fr);case"es":return is(()=>import("./SceneNames_es-D17SooUd.js"),[],import.meta.url).then(t=>t.sceneNames_es);case"it":return is(()=>import("./SceneNames_it-DLcaIKpK.js"),[],import.meta.url).then(t=>t.sceneNames_it);default:return Promise.resolve(void 0)}}const hg={play:"Play",pause:"Pause",noDuration:"No observation duration",currentPosition:"Current position",duration:"Duration",switchToElapsed:"click to show elapsed time",switchToClockTime:"click to show the time of day",fullscreen:"Fullscreen",exitFullscreen:"Exit fullscreen",mute:"Mute",unmute:"Unmute",moments:"Moments",moreControls:"More controls",fewerControls:"Fewer controls",showObserverMap:"Show where the observer was",hideObserverMap:"Hide where the observer was",mapImageryUnavailable:"Aerial imagery unavailable",zoomMapIn:"Zoom in",zoomMapOut:"Zoom out",fitMap:"Back to the whole path",placeObserverHere:"Put the observer here",showReferences:"Show the pictures of the place",hideReferences:"Hide the pictures of the place",referenceOpacity:"Picture opacity",showMilestones:"Show the account's moments",hideMilestones:"Hide the account's moments",observerHere:"The observer, here",decorHere:"Scenery",recordingIssues:"{count} problem(s) in this recording: it may not play as its author meant",issueTemplates:Pr.EN},Yv=Object.freeze(Object.defineProperty({__proto__:null,ufoMessages_en:hg},Symbol.toStringTag,{value:"Module"})),ug=Math.PI/180,qv=180/Math.PI,$v=256,dg=19,Kv=1.25;function fg(r,t){return 156543.03392*Math.cos(r*ug)/2**t}function pg(r,t){return fg(r,t)*$v}function Zv(r,t){let e=0;for(;e<dg&&pg(r,e+1)>=t;)e++;return e}function mg(r,t){return pg(r,t)}function Jv(r,t){const e=t*Kv;let i=0;for(;i<dg&&fg(r,i)>e;)i++;return i}function el(r){const t=r*ug;return(1-Math.log(Math.tan(t)+1/Math.cos(t))/Math.PI)/2}function gg(r,t,e){const i=2**e;return{x:(r+180)/360*i,y:el(t)*i}}function vg(r,t,e){const i=el(r.north),n=el(r.south);return{x:(t-r.west)/(r.east-r.west),y:(el(e)-i)/(n-i)}}function jv(r,t,e){const{x:i,y:n}=gg(r,t,e);return{x:Math.floor(i),y:Math.floor(n),z:e}}function Qv(r){const t=2**r.z,e=r.x/t*360-180,i=(r.x+1)/t*360-180,n=Mf(r.y,t);return{south:Mf(r.y+1,t),north:n,west:e,east:i}}function Mf(r,t){const e=r/t;return Math.atan(Math.sinh(Math.PI*(1-2*e)))*qv}function Mg(r,t,e,i){const n=jv(r,t,e),s=Math.floor(i/2),a=[];for(let l=-s;l<=s;l++)for(let h=-s;h<=s;h++)a.push({x:n.x+h,y:n.y+l,z:e});const o=a.map(Qv),c={south:Math.min(...o.map(l=>l.south)),north:Math.max(...o.map(l=>l.north)),west:Math.min(...o.map(l=>l.west)),east:Math.max(...o.map(l=>l.east))};return{tiles:a,bounds:c}}class Ma{constructor(t){this.ctx=t}static SCALE_STEPS_M=[5e3,2e3,1e3,500,200,100,50,20,10,5];static MARKER_RADIUS_PX=8.5;static ON_MARKER_M=3;targets=[];hitTest(t,e){let i,n=1/0;for(const s of this.targets){const a=Math.hypot(s.x-t,s.y-e);a>s.radius||a>n||(i=s,n=a)}return i}get width(){return this.ctx.canvas.width}get height(){return this.ctx.canvas.height}paint(t){const{ctx:e}=this;e.save(),this.targets=[],e.clearRect(0,0,this.width,this.height),this.paintGround(t),this.paintNight(t.nightFraction),this.paintPath(t),t.position?(this.paintCone(t,t.position),this.paintDecor(t),this.paintMarkers(t),this.paintObserver(t,t.position)):(this.paintDecor(t),this.paintMarkers(t)),this.paintNorth(),this.paintFooter(t.bounds,t.attribution),e.restore()}toCanvas(t,e,i){const n=vg(t,i,e);return{x:n.x*this.width,y:n.y*this.height}}paintGround(t){const{ctx:e}=this;e.fillStyle="#1d2321",e.fillRect(0,0,this.width,this.height);const i=t.imagery;if(!i)return;const n=this.toCanvas(t.bounds,i.bounds.north,i.bounds.west),s=this.toCanvas(t.bounds,i.bounds.south,i.bounds.east);e.drawImage(i.source,n.x,n.y,s.x-n.x,s.y-n.y)}paintNight(t=0){if(t<=0)return;const{ctx:e}=this;e.save(),e.fillStyle=`rgba(6, 12, 30, ${Math.min(t,1)*.78})`,e.fillRect(0,0,this.width,this.height),e.restore()}paintDecor(t){const{ctx:e}=this;for(const i of t.decor){const n=this.toCanvas(t.bounds,i.lat,i.lng);if(i.label&&this.targets.push({kind:"decor",label:i.label,lat:i.lat,lng:i.lng,x:n.x,y:n.y,radius:7}),e.beginPath(),e.rect(n.x-3.5,n.y-3.5,7,7),e.fillStyle="rgba(120, 220, 255, 0.85)",e.fill(),e.lineWidth=1.5,e.strokeStyle="rgba(0, 0, 0, 0.7)",e.stroke(),i.headingDeg===void 0)continue;const s=(i.headingDeg-90)*Math.PI/180;e.beginPath(),e.moveTo(n.x,n.y),e.lineTo(n.x+Math.cos(s)*10,n.y+Math.sin(s)*10),e.lineWidth=3,e.strokeStyle="rgba(0, 0, 0, 0.6)",e.stroke(),e.lineWidth=1.5,e.strokeStyle="rgba(120, 220, 255, 0.9)",e.stroke()}}paintPath(t){if(!t.path.moved)return;const{ctx:e}=this,i=t.path.points.map(n=>this.toCanvas(t.bounds,n.lat,n.lng));e.beginPath(),e.moveTo(i[0].x,i[0].y);for(const n of i.slice(1))e.lineTo(n.x,n.y);e.lineJoin="round",e.lineCap="round",e.strokeStyle="rgba(0, 0, 0, 0.65)",e.lineWidth=5,e.stroke(),e.strokeStyle="rgba(255, 255, 255, 0.9)",e.lineWidth=2,e.stroke()}paintCone(t,e){const{headingDeg:i,coneHalfAngleDeg:n}=t;if(i===void 0||n===void 0)return;const{ctx:s}=this,a=this.toCanvas(t.bounds,e.lat,e.lng),o=Math.hypot(this.width,this.height),c=(i-90)*Math.PI/180,l=n*Math.PI/180;s.save(),s.beginPath(),s.moveTo(a.x,a.y),s.arc(a.x,a.y,o,c-l,c+l),s.closePath();const h=s.createRadialGradient(a.x,a.y,0,a.x,a.y,o);h.addColorStop(0,"rgba(255, 224, 130, 0.55)"),h.addColorStop(.35,"rgba(255, 224, 130, 0.22)"),h.addColorStop(1,"rgba(255, 224, 130, 0)"),s.fillStyle=h,s.fill(),s.restore()}paintMarkers(t){const{ctx:e}=this;e.textAlign="center",e.textBaseline="middle",e.font="bold 10px sans-serif";for(const i of[...t.markers].sort((n,s)=>Number(n.current)-Number(s.current))){const n=this.toCanvas(t.bounds,i.lat,i.lng);this.targets.push({kind:"milestone",label:i.note?`${i.label} — ${i.note}`:i.label,lat:i.lat,lng:i.lng,t:i.t,x:n.x,y:n.y,radius:Ma.MARKER_RADIUS_PX}),e.beginPath(),e.arc(n.x,n.y,Ma.MARKER_RADIUS_PX,0,Math.PI*2),e.fillStyle=i.current?"rgba(255, 224, 130, 0.95)":"rgba(0, 0, 0, 0.55)",e.fill(),e.lineWidth=2,e.strokeStyle="rgba(255, 255, 255, 0.9)",e.stroke(),e.fillStyle=i.current?"#1d2321":"#fff",e.fillText(i.label,n.x,n.y)}}paintObserver(t,e){const{ctx:i}=this,n=this.toCanvas(t.bounds,e.lat,e.lng);t.observerLabel&&this.targets.push({kind:"observer",label:t.observerLabel,lat:e.lat,lng:e.lng,x:n.x,y:n.y,radius:8});const s=t.markers.some(a=>{if(!a.current)return!1;const o=ai(a.lat,a.lng,e.lat,e.lng);return Math.hypot(o.x,o.z)<=Ma.ON_MARKER_M});i.beginPath(),i.arc(n.x,n.y,s?Ma.MARKER_RADIUS_PX+2.5:5.5,0,Math.PI*2),s||(i.fillStyle="#ff5a3c",i.fill()),i.lineWidth=4,i.strokeStyle="rgba(0, 0, 0, 0.5)",i.stroke(),i.lineWidth=s?3:2.5,i.strokeStyle=s?"#ff5a3c":"#fff",i.stroke()}paintNorth(){const{ctx:t}=this,e=this.width-14,i=16;t.beginPath(),t.moveTo(e,i-9),t.lineTo(e-4.5,i+5),t.lineTo(e,i+2),t.lineTo(e+4.5,i+5),t.closePath(),t.fillStyle="rgba(255, 255, 255, 0.92)",t.strokeStyle="rgba(0, 0, 0, 0.6)",t.lineWidth=1,t.fill(),t.stroke(),t.font="bold 9px sans-serif",t.textAlign="center",t.textBaseline="top",t.strokeText("N",e,i+6),t.fillText("N",e,i+6)}paintFooter(t,e){const{ctx:i}=this;i.font="9px sans-serif",i.textBaseline="bottom";const n=e?this.wrap(e,this.width-20):[];let s=this.height-4;i.textAlign="right";for(const f of n.slice().reverse())this.paintOutlinedText(f,this.width-6,s),s-=11;const a=(t.south+t.north)/2,c=Math.abs(ai(a,t.east,a,t.west).x)/this.width,l=Ma.SCALE_STEPS_M.find(f=>f/c<=this.width/3);if(l===void 0)return;const h=l/c,u=8,d=s-3;i.lineWidth=3,i.strokeStyle="rgba(0, 0, 0, 0.6)",i.beginPath(),i.moveTo(u,d),i.lineTo(u+h,d),i.stroke(),i.lineWidth=1.5,i.strokeStyle="rgba(255, 255, 255, 0.95)",i.stroke(),i.textAlign="left",this.paintOutlinedText(l>=1e3?`${l/1e3} km`:`${l} m`,u,d-3)}paintOutlinedText(t,e,i){const{ctx:n}=this;n.lineWidth=3,n.strokeStyle="rgba(0, 0, 0, 0.75)",n.strokeText(t,e,i),n.fillStyle="#fff",n.fillText(t,e,i)}wrap(t,e){const i=[];let n="";for(const s of t.split(" ")){const a=n?`${n} ${s}`:s;n&&this.ctx.measureText(a).width>e?(i.push(n),n=s):n=a}return n&&i.push(n),i}}class Ye{static MIN_ZOOM=.25;static MAX_ZOOM=64;zoom=1;centerX=.5;centerY=.5;get changed(){return this.zoom!==1||this.centerX!==.5||this.centerY!==.5}get zoomFactor(){return this.zoom}reset(){this.zoom=1,this.centerX=.5,this.centerY=.5}zoomAt(t,e,i){const n=Math.min(Ye.MAX_ZOOM,Math.max(Ye.MIN_ZOOM,this.zoom*i)),s=this.centerX+(t-.5)/this.zoom,a=this.centerY+(e-.5)/this.zoom;this.centerX=s-(t-.5)/n,this.centerY=a-(e-.5)/n,this.zoom=n}panBy(t,e){this.centerX-=t/this.zoom,this.centerY-=e/this.zoom}refit(t,e){if(!this.changed)return;const i=this.boundsWithin(t),n=Ye.mercatorY01(e.north),s=Ye.mercatorY01(e.south),a=Ye.mercatorY01(i.north),o=Ye.mercatorY01(i.south);this.zoom=(e.east-e.west)/(i.east-i.west),this.centerX=((i.west+i.east)/2-e.west)/(e.east-e.west),this.centerY=((a+o)/2-n)/(s-n)}keepInView(t,e,i){if(!this.changed)return!1;const n=this.boundsWithin(t),s=Ye.mercatorY01(n.north),a=Ye.mercatorY01(n.south),o=(e.lng-n.west)/(n.east-n.west),c=(Ye.mercatorY01(e.lat)-s)/(a-s);return o>=i&&o<=1-i&&c>=i&&c<=1-i?!1:(this.panBy(.5-o,.5-c),!0)}boundsWithin(t){if(!this.changed)return t;const e=.5/this.zoom,i=Ye.mercatorY01(t.north),n=Ye.mercatorY01(t.south),s=t.east-t.west;return{west:t.west+(this.centerX-e)*s,east:t.west+(this.centerX+e)*s,north:Ye.latitudeAt(i+(this.centerY-e)*(n-i)),south:Ye.latitudeAt(i+(this.centerY+e)*(n-i))}}static expand(t,e){const i=t.east-t.west,n=t.north-t.south;return{west:t.west-i*e,east:t.east+i*e,south:t.south-n*e,north:t.north+n*e}}static pointAt(t,e,i){const n=Ye.mercatorY01(t.north),s=Ye.mercatorY01(t.south);return{lat:Ye.latitudeAt(n+i*(s-n)),lng:t.west+e*(t.east-t.west)}}static mercatorY01(t){const e=t*Math.PI/180;return(1-Math.log(Math.tan(e)+1/Math.cos(e))/Math.PI)/2}static latitudeAt(t){return Math.atan(Math.sinh(Math.PI*(1-2*t)))*180/Math.PI}}const fn=256,xf=3,t2=32768;class e2{fetchImpl;tileUrlTemplate;constructor(t={}){this.fetchImpl=t.fetchImpl??fetch.bind(globalThis),this.tileUrlTemplate=t.tileUrlTemplate??"https://s3.amazonaws.com/elevation-tiles-prod/terrarium/{z}/{x}/{y}.png"}async getElevationGrid(t,e){const i=(t.south+t.north)/2,n=(t.west+t.east)/2,s=Math.abs(ai(i,t.east,i,t.west).x),a=Math.abs(ai(t.north,n,t.south,n).z),o=Zv(i,Math.max(s,a)),{tiles:c}=Mg(n,i,o,xf),l=xf*fn,h=new Float32Array(l*l),u=c[0];await Promise.all(c.map(f=>this.decodeTileInto(f,u,h,l)));const d=new Float32Array(e.width*e.height);for(let f=0;f<e.height;f++){const p=t.north+(t.south-t.north)*(f/(e.height-1));for(let v=0;v<e.width;v++){const m=t.west+(t.east-t.west)*(v/(e.width-1));d[f*e.width+v]=this.sampleAt(p,m,o,u,h,l)}}return{heights:d,width:e.width,height:e.height,bounds:t}}async decodeTileInto(t,e,i,n){const s=this.tileUrlTemplate.replace("{z}",String(t.z)).replace("{x}",String(t.x)).replace("{y}",String(t.y)),a=await this.fetchImpl(s);if(!a.ok)throw new Error(`Elevation tile fetch failed (${a.status}): ${s}`);const o=await createImageBitmap(await a.blob()),c=document.createElement("canvas");c.width=fn,c.height=fn;const l=c.getContext("2d");if(!l)throw new Error("2D canvas context unavailable");l.drawImage(o,0,0);const{data:h}=l.getImageData(0,0,fn,fn),u=(t.x-e.x)*fn,d=(t.y-e.y)*fn;for(let f=0;f<fn;f++)for(let p=0;p<fn;p++){const v=(f*fn+p)*4,m=h[v]*256+h[v+1]+h[v+2]/256-t2,g=u+p,S=d+f;i[S*n+g]=m}}sampleAt(t,e,i,n,s,a){const{x:o,y:c}=gg(e,t,i),l=(o-n.x)*fn,h=(c-n.y)*fn,u=Math.max(0,Math.min(a-1,Math.floor(l))),d=Math.max(0,Math.min(a-1,Math.floor(h))),f=Math.min(a-1,u+1),p=Math.min(a-1,d+1),v=l-u,m=h-d,g=s[d*a+u],S=s[d*a+f],y=s[p*a+u],M=s[p*a+f],b=g+(S-g)*v,w=y+(M-y)*v;return b+(w-b)*m}}const il=256,i2=5;async function n2(r,t,e,i){const n=(r.south+r.north)/2,s=(r.west+r.east)/2,a=Math.abs(ai(n,r.east,n,r.west).x),o=Math.abs(ai(r.north,s,r.south,s).z),c=Math.max(a,o),{zoom:l,gridSize:h}=s2(n,c,Math.max(t.width,t.height)),{tiles:u,bounds:d}=Mg(s,n,l,h),f=h*il,p=document.createElement("canvas");p.width=f,p.height=f;const v=p.getContext("2d");if(!v)throw new Error("2D canvas context unavailable");const m=u[0];await Promise.all(u.map(async M=>{const b=e(M),w=await i(b);if(!w.ok)throw new Error(`Imagery tile fetch failed (${w.status}): ${b}`);const T=await createImageBitmap(await w.blob());v.drawImage(T,(M.x-m.x)*il,(M.y-m.y)*il)}));const g=Math.min(Math.max(t.width,t.height),f);if(g===f)return{source:p,width:f,height:f,bounds:d};const S=document.createElement("canvas");S.width=g,S.height=g;const y=S.getContext("2d");if(!y)throw new Error("2D canvas context unavailable");return y.drawImage(p,0,0,f,f,0,0,g,g),{source:S,width:g,height:g,bounds:d}}function s2(r,t,e){let i=Jv(r,t/Math.max(1,e)),n=yf(r,i,t);for(;n>i2&&i>0;)i--,n=yf(r,i,t);return{zoom:i,gridSize:n,mPerPixel:mg(r,i)/il}}function yf(r,t,e){const i=Math.ceil(e/2/mg(r,t));return Math.max(3,2*i+1)}class a2{attribution="Imagery © Esri, Maxar, Earthstar Geographics, and the GIS User Community";fetchImpl;tileUrlTemplate;constructor(t={}){this.fetchImpl=t.fetchImpl??fetch.bind(globalThis),this.tileUrlTemplate=t.tileUrlTemplate??"https://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/{z}/{y}/{x}"}async getImageryTexture(t,e){return n2(t,e,i=>this.tileUrlTemplate.replace("{z}",String(i.z)).replace("{y}",String(i.y)).replace("{x}",String(i.x)),this.fetchImpl)}}class Tn{attribution="Roads © OpenStreetMap contributors, as surveyed today";contemporary=!0;static DRIVABLE=["motorway","trunk","primary","secondary","tertiary","unclassified","residential","service","track","motorway_link","trunk_link","primary_link","secondary_link","tertiary_link"];static WIDTH_M={motorway:11,trunk:9,primary:8,secondary:7,tertiary:6.5,unclassified:5.5,residential:5.5,service:4,track:3.5};static DEFAULT_WIDTH_M=5;static ENDPOINTS=["https://overpass-api.de/api/interpreter","https://overpass.kumi.systems/api/interpreter","https://overpass.private.coffee/api/interpreter"];fetchImpl;endpoints;constructor(t={}){this.fetchImpl=t.fetchImpl??fetch.bind(globalThis),this.endpoints=t.endpoints??Tn.ENDPOINTS}static queue=Promise.resolve();static RETRY_MS=4e3;async getRoads(t){const e=`${t.south},${t.west},${t.north},${t.east}`,i=`[out:json][timeout:30];way["highway"~"^(${Tn.DRIVABLE.join("|")})$"](${e});out geom;`;return this.waysFrom(await this.queued(()=>this.ask(i)))}waysFrom(t){const e=[];for(const i of t.elements??[]){const n=i.geometry,s=i.tags;!s||!n||n.length<2||e.push({id:`osm-${i.id??e.length}`,name:s.name,surface:Tn.surfaceOf(s),widthM:Tn.widthOf(s),points:n.map(a=>({lat:a.lat,lng:a.lon}))})}return e}queued(t){const e=Tn.queue.then(t,t);return Tn.queue=e.catch(()=>{}),e}async ask(t){let e;for(const i of this.endpoints)for(let n=0;n<2;n++){try{const s=await this.fetchImpl(`${i}?data=${encodeURIComponent(t)}`);if(s.ok)return await s.json();if(e=new Error(`${new URL(i).host} refused (${s.status})`),s.status!==429&&s.status!==504)break}catch(s){e=new Error(`${new URL(i).host} unreachable (${String(s)})`);break}await new Promise(s=>setTimeout(s,Tn.RETRY_MS))}throw e??new Error("No Overpass instance answered")}static widthOf(t){const e=Number.parseFloat(t.width??t.est_width??"");if(Number.isFinite(e)&&e>0)return e;const i=Number.parseInt(t.lanes??"",10);return Number.isFinite(i)&&i>0?i*3.5:Tn.WIDTH_M[t.highway]??Tn.DEFAULT_WIDTH_M}static surfaceOf(t){const e=t.surface;return e==="dirt"||e==="earth"||e==="mud"?"dirt":e==="gravel"||e==="fine_gravel"||e==="compacted"||e==="ground"||e==="sand"||e==="unpaved"?"gravel":e?"paved":t.highway==="track"?"gravel":"paved"}}const sh="https://ufoathome.org/roads/index.json";class t0{attributionRead;contemporaryRead;fetchImpl;indexUrls;fallback;index;constructor(t={}){this.fetchImpl=t.fetchImpl??fetch.bind(globalThis),this.indexUrls=t.indexUrls??t0.defaultIndexUrls(),this.fallback=t.fallback}get attribution(){return this.attributionRead??this.fallback?.attribution??"Roads © OpenStreetMap contributors"}get contemporary(){return this.contemporaryRead??this.fallback?.contemporary??!0}async getRoads(t){const e=await this.held(t);if(e)return e;if(!this.fallback)return[];const i=await this.fallback.getRoads(t);return this.attributionRead=this.fallback.attribution,this.contemporaryRead=this.fallback.contemporary,i}async held(t){let e;try{e=await this.load()}catch{return}const i=e.find(({entry:n})=>n.north>=t.north&&n.south<=t.south&&n.east>=t.east&&n.west<=t.west);if(i)try{const n=await this.fetchImpl(new URL(i.entry.file,i.indexUrl).href);if(!n.ok)return;const s=await n.json();return Array.isArray(s?.ways)?(this.attributionRead=s.attribution,this.contemporaryRead=s.contemporary,s.ways):void 0}catch{return}}load(){return this.index??=this.fetchFirstAvailable(),this.index}async fetchFirstAvailable(){for(const t of this.indexUrls)try{const e=await this.fetchImpl(t);if(!e.ok)continue;const i=await e.json();if(Array.isArray(i?.entries))return i.entries.map(n=>({entry:n,indexUrl:t}))}catch{}return[]}static defaultIndexUrls(){const t=`?v=${encodeURIComponent("0.81.8")}`,e=typeof location>"u"?void 0:new URL("/roads/index.json",location.href).href;return(e&&e!==sh?[e,sh]:[sh]).map(i=>i+t)}}function r2(){return{elevation:new e2,imagery:xg(),roads:o2()}}function xg(){return new a2}function o2(){return new t0({fallback:new Tn})}const c2=new Set,_r="show-observer-map",Sr="hide-milestones";class fe extends HTMLElement{static get observedAttributes(){return["src",_r,Sr]}shadow;stageElement;canvas;canvasRenderer;tooltip;toolbar;issuesBox;issuesButton;issuesPanel;playPauseButton;static OBSERVER_MAP_MIN_SPAN_M=400;static OBSERVER_MAP_MARGIN=.6;static OBSERVER_MAP_IMAGERY_PX=768;fullscreenButton;cornerButtons;observerMapButton;referencesButton;referenceOpacityInput;referencesShownState=!0;referenceOpacityTouched=!1;milestonesButton;observerMapPanel;observerMapCanvas;observerMapRenderer;mapZoomInButton;mapZoomOutButton;mapFitButton;observerMapView=new Ye;observerMapDrag;suppressObserverMapClick=!1;observerMapImageryTimer;observerPlacing=!1;seekInput;playbackFlash;milestoneMarks;milestoneCaption;timeStartLabel;timeEndLabel;timePill;muteButton;volumeInput;controlsRow;momentsBox;momentsButton;momentsCurrent;momentsMenu;moreButton;controlsRight;seekSegments;seekDot;seekPreview;seekPreviewCanvas;seekPreviewTitle;seekPreviewTime;observerPath;observerMapBounds;observerMapImagery;observerMapImageryBounds;observerMapImageryViewWidth=0;observerMapImageryLoading=!1;observerMapImageryCredit;observerMapImageryFailed=!1;creditShownExternally=!1;lookYawDeg=0;lookPitchDeg=0;milestonesShown=!0;currentSighting=zl.create();issues=[];issueCheck=0;sightingAudio=new kv;soundPreview;player;loopEnabled=!1;playbackBeforeClick;highlightedSourceIds=new Set;paintsShapes=!0;steadyObserver=!1;selectionShown=!0;overlayPainter;enableClickToPlay=!0;fullscreenTarget;messages=hg;realDurationMs;realStartMs;showClockTime=!0;handleFullscreenChange=()=>{this.updateFullscreenButton(),this.updateMuteButton(),this.resizeObserverMap()};controlsFitObserver=typeof ResizeObserver>"u"?void 0:new ResizeObserver(()=>this.fitControls());controlsMutations;fitControls(){const t=this.controlsRow,e=t.classList.contains("more-open"),i=()=>t.scrollWidth>t.clientWidth+1,n=!this.momentsMenu.hidden;if(this.momentsMenu.hidden=!0,t.classList.remove("narrow","more-open","nomoments","compact","tiny"),t.clientWidth>0&&i()){t.classList.add("narrow");for(const s of["nomoments","compact","tiny"]){if(!i())break;t.classList.add(s)}e&&t.classList.add("more-open")}this.momentsMenu.hidden=!n,this.updateMoreButton()}setControlsFolded(t){this.controlsRow.classList.toggle("more-open",!t),this.updateMoreButton()}updateMoreButton(){const t=this.controlsRow.classList.contains("more-open");fe.setIcon(this.moreButton,t?Zt.UNFOLDED:Zt.FOLDED);const e=t?this.messages.fewerControls:this.messages.moreControls;this.moreButton.title=e,this.moreButton.setAttribute("aria-label",e),this.moreButton.setAttribute("aria-expanded",String(t))}addControl(t){this.controlsRight.insertBefore(t,this.fullscreenButton.parentElement===this.controlsRight?this.fullscreenButton:null),this.fitControls()}observerMapResizeObserver=typeof ResizeObserver>"u"?void 0:new ResizeObserver(()=>this.resizeObserverMap());resizeObserverMap(){this.observerMapPanel.hidden||(this.sizeObserverMapCanvas(),this.paintObserverMap(this.currentTime))}simulatedFullscreen=!1;styleBeforeSimulatedFullscreen;bodyOverflowBeforeSimulatedFullscreen;handleSimulatedFullscreenKey=t=>{t.key==="Escape"&&this.exitSimulatedFullscreen()};handlePointerMove=t=>{const e=this.canvasPointFromEvent(t),i=e&&this.shapeAt(e.x,e.y),n=this.said.read(i?.shape.title);if(!n){this.tooltip.hidden=!0;return}this.tooltip.textContent=n,this.tooltip.hidden=!1;const s=this.stageElement.getBoundingClientRect();this.tooltip.style.left=`${t.clientX-s.left+12}px`,this.tooltip.style.top=`${t.clientY-s.top+12}px`};handleObserverMapPointerMove=t=>{if(this.dragObserverMap(t))return;const e=this.observerMapTargetFrom(t);if(!e){if(!this.observerPlacing){this.tooltip.hidden=!0,this.observerMapCanvas.style.cursor="grab";return}this.observerMapCanvas.style.cursor="crosshair",this.showObserverMapTooltip(t,this.messages.placeObserverHere);return}this.observerMapCanvas.style.cursor="pointer",this.showObserverMapTooltip(t,e.label)};showObserverMapTooltip(t,e){this.tooltip.textContent=e,this.tooltip.hidden=!1;const i=this.stageElement.getBoundingClientRect();this.tooltip.style.left=`${t.clientX-i.left+12}px`,this.tooltip.style.top=`${t.clientY-i.top+12}px`}handleObserverMapClick=t=>{if(this.suppressObserverMapClick){this.suppressObserverMapClick=!1;return}const e=this.observerMapTargetFrom(t);if(!e){this.observerPlacing&&this.placeObserverFrom(t);return}if(e.kind==="milestone"&&e.t!==void 0){this.player.seek(e.t);return}this.dispatchEvent(new CustomEvent("lookat",{detail:{lat:e.lat,lng:e.lng,kind:e.kind},bubbles:!0,composed:!0}))};observerMapTargetFrom(t){const e=this.observerMapCanvas.getBoundingClientRect();if(!(e.width===0||e.height===0))return this.observerMapRenderer.hitTest((t.clientX-e.left)/e.width*this.observerMapCanvas.width,(t.clientY-e.top)/e.height*this.observerMapCanvas.height)}handlePointerLeave=()=>{this.tooltip.hidden=!0};handleObserverMapPointerDown=t=>{t.button===0&&(this.suppressObserverMapClick=!1,this.observerMapDrag={pointerId:t.pointerId,startX:t.clientX,startY:t.clientY,lastX:t.clientX,lastY:t.clientY,moved:!1})};handleObserverMapPointerUp=t=>{const e=this.observerMapDrag;!e||e.pointerId!==t.pointerId||(this.observerMapDrag=void 0,this.observerMapCanvas.classList.remove("dragging"),e.moved&&(this.suppressObserverMapClick=!0,this.paintObserverMap(this.currentTime),this.observerMapCanvas.hasPointerCapture?.(t.pointerId)&&this.observerMapCanvas.releasePointerCapture(t.pointerId)))};dragObserverMap(t){const e=this.observerMapDrag;if(!e||e.pointerId!==t.pointerId)return!1;if(!e.moved){if(Math.hypot(t.clientX-e.startX,t.clientY-e.startY)<fe.OBSERVER_MAP_DRAG_PX)return!1;e.moved=!0,this.tooltip.hidden=!0,this.observerMapCanvas.classList.add("dragging"),this.observerMapCanvas.setPointerCapture?.(t.pointerId)}const i=this.observerMapCanvas.getBoundingClientRect();return i.width>0&&i.height>0&&(this.observerMapView.panBy((t.clientX-e.lastX)/i.width,(t.clientY-e.lastY)/i.height),this.observerMapViewChanged()),e.lastX=t.clientX,e.lastY=t.clientY,!0}static OBSERVER_MAP_DRAG_PX=4;handleObserverMapWheel=t=>{t.preventDefault();const e=this.observerMapCanvas.getBoundingClientRect();if(e.width===0||e.height===0)return;const i=t.deltaMode===0?t.deltaY:t.deltaY*40;this.zoomObserverMap((t.clientX-e.left)/e.width,(t.clientY-e.top)/e.height,Math.exp(-i*.002))};zoomObserverMap(t,e,i){this.observerMapView.zoomAt(t,e,i),this.observerMapViewChanged()}observerMapViewChanged(){this.mapFitButton.hidden=!this.observerMapView.changed,this.mapZoomInButton.disabled=this.observerMapView.zoomFactor>=Ye.MAX_ZOOM,this.mapZoomOutButton.disabled=this.observerMapView.zoomFactor<=Ye.MIN_ZOOM,this.paintObserverMap(this.currentTime),this.scheduleObserverMapImagery()}scheduleObserverMapImagery(){this.observerMapImageryTimer===void 0&&(this.observerMapImageryTimer=setTimeout(()=>{this.observerMapImageryTimer=void 0,this.loadObserverMapImagery()},fe.OBSERVER_MAP_IMAGERY_DELAY_MS))}static OBSERVER_MAP_FOLLOW_MARGIN=.1;static OBSERVER_MAP_IMAGERY_DELAY_MS=300;get observerMapViewBounds(){return this.observerMapBounds&&this.observerMapView.boundsWithin(this.observerMapBounds)}placeObserverFrom(t){const e=this.observerMapViewBounds,i=this.observerMapCanvas.getBoundingClientRect();if(!e||i.width===0||i.height===0)return;const n=Ye.pointAt(e,(t.clientX-i.left)/i.width,(t.clientY-i.top)/i.height);this.dispatchEvent(new CustomEvent("observerplace",{detail:n,bubbles:!0,composed:!0}))}constructor(){super(),this.shadow=this.attachShadow({mode:"open"});const t=document.createElement("template");t.innerHTML=`<style>${hv}</style>${lv}`,this.shadow.appendChild(t.content.cloneNode(!0)),this.stageElement=this.shadow.getElementById("stage"),this.canvas=this.shadow.getElementById("canvas"),this.canvasRenderer=new Fo(this.canvas.getContext("2d")),this.tooltip=this.shadow.getElementById("tooltip"),this.toolbar=this.shadow.getElementById("toolbar"),this.issuesBox=this.shadow.getElementById("issues"),this.issuesButton=this.shadow.getElementById("issues-button"),this.issuesPanel=this.shadow.getElementById("issues-panel"),this.issuesButton.addEventListener("click",e=>{e.stopPropagation(),this.issuesPanel.hidden=!this.issuesPanel.hidden,this.issuesButton.setAttribute("aria-expanded",String(!this.issuesPanel.hidden))}),this.playPauseButton=this.shadow.getElementById("play-pause"),this.fullscreenButton=this.shadow.getElementById("fullscreen"),this.cornerButtons=this.shadow.getElementById("corner-buttons"),this.observerMapButton=this.shadow.getElementById("observer-map"),this.referencesButton=this.shadow.getElementById("references"),this.referenceOpacityInput=this.shadow.getElementById("reference-opacity"),this.milestonesButton=this.shadow.getElementById("milestones"),this.observerMapPanel=this.shadow.getElementById("observer-map-panel"),this.observerMapCanvas=this.shadow.getElementById("observer-map-canvas"),this.observerMapRenderer=new Ma(this.observerMapCanvas.getContext("2d")),this.mapZoomInButton=this.shadow.getElementById("map-zoom-in"),this.mapZoomOutButton=this.shadow.getElementById("map-zoom-out"),this.mapFitButton=this.shadow.getElementById("map-fit"),this.seekInput=this.shadow.getElementById("seek"),this.playbackFlash=this.shadow.getElementById("playback-flash"),this.milestoneMarks=this.shadow.getElementById("milestone-marks"),this.milestoneCaption=this.shadow.getElementById("milestone-caption"),this.timeStartLabel=this.shadow.getElementById("time-start"),this.timeEndLabel=this.shadow.getElementById("time-end"),this.timePill=this.shadow.getElementById("time"),this.muteButton=this.shadow.getElementById("mute"),this.controlsRight=this.shadow.getElementById("controls-right"),this.seekSegments=this.shadow.getElementById("seek-segments"),this.seekDot=this.shadow.getElementById("seek-dot"),this.seekPreview=this.shadow.getElementById("seek-preview"),this.seekPreviewCanvas=this.shadow.getElementById("seek-preview-canvas"),this.seekPreviewTitle=this.shadow.getElementById("seek-preview-title"),this.seekPreviewTime=this.shadow.getElementById("seek-preview-time"),this.timePill.addEventListener("click",()=>this.toggleTimeDisplay()),this.timePill.addEventListener("keydown",e=>{e.key!=="Enter"&&e.key!==" "||(e.preventDefault(),this.toggleTimeDisplay())}),this.volumeInput=this.shadow.getElementById("volume"),this.controlsRow=this.shadow.querySelector(".controls"),this.momentsBox=this.shadow.getElementById("moments"),this.momentsButton=this.shadow.getElementById("moments-button"),this.momentsCurrent=this.shadow.getElementById("moments-current"),this.momentsMenu=this.shadow.getElementById("moments-menu"),this.momentsButton.addEventListener("click",()=>this.toggleMomentsMenu()),this.moreButton=this.shadow.getElementById("controls-more"),this.moreButton.addEventListener("click",()=>this.setControlsFolded(this.controlsRow.classList.contains("more-open"))),this.muteButton.addEventListener("click",()=>this.toggleMuted()),this.volumeInput.addEventListener("input",()=>{this.setVolume(Number(this.volumeInput.value))}),this.fullscreenTarget=this.stageElement,this.playPauseButton.addEventListener("click",()=>this.togglePlayPause()),this.fullscreenButton.addEventListener("click",()=>this.toggleFullscreen()),this.addEventListener("keydown",this.handleFullscreenKey),this.observerMapButton.addEventListener("click",()=>this.toggleObserverMap()),this.referencesButton.addEventListener("click",()=>this.toggleReferences()),this.referenceOpacityInput.addEventListener("input",()=>{this.referenceOpacityTouched=!0,this.dispatchReferenceView()}),this.milestonesButton.addEventListener("click",()=>this.toggleMilestones()),this.observerMapCanvas.addEventListener("pointermove",this.handleObserverMapPointerMove),this.observerMapCanvas.addEventListener("pointerleave",this.handlePointerLeave),this.observerMapCanvas.addEventListener("click",this.handleObserverMapClick),this.observerMapCanvas.addEventListener("pointerdown",this.handleObserverMapPointerDown),this.observerMapCanvas.addEventListener("pointerup",this.handleObserverMapPointerUp),this.observerMapCanvas.addEventListener("pointercancel",this.handleObserverMapPointerUp),this.observerMapCanvas.addEventListener("wheel",this.handleObserverMapWheel,{passive:!1}),this.mapZoomInButton.addEventListener("click",()=>this.zoomObserverMap(.5,.5,2)),this.mapZoomOutButton.addEventListener("click",()=>this.zoomObserverMap(.5,.5,.5)),this.mapFitButton.addEventListener("click",()=>{this.observerMapView.reset(),this.observerMapViewChanged()}),this.seekInput.addEventListener("input",()=>this.player.seek(this.snapSeekToMark(Number(this.seekInput.value)))),this.seekInput.addEventListener("pointerdown",e=>{this.suspendForScrub(),this.seekSnapArmed=!0,this.nameMarkUnder(e),this.beginTouchScrub(e)}),this.seekInput.addEventListener("pointerup",e=>{this.seekSnapArmed=!1,this.endTouchScrub(e)}),this.seekInput.addEventListener("pointercancel",e=>this.endTouchScrub(e)),this.seekInput.addEventListener("pointermove",e=>{this.nameMarkUnder(e),this.hoverSeek(e),this.touchScrub(e)}),this.seekInput.addEventListener("pointerleave",()=>{this.seekInput.removeAttribute("title"),this.leaveSeek()}),this.seekInput.addEventListener("keydown",this.handleSeekKey),this.stageElement.addEventListener("pointerdown",()=>{this.handlePointerDown(),this.touchedStage()},!0);for(const e of["touchend","click"])this.stageElement.addEventListener(e,()=>this.sightingAudio.resume(),!0);this.stageElement.addEventListener("pointermove",()=>this.touchedStage()),this.canvas.addEventListener("click",e=>{if(this.enableClickToPlay){if(this.tapRevealedOnly){this.tapRevealedOnly=!1;return}e.detail<=1&&(this.playbackBeforeClick={state:this.playbackState,time:this.currentTime}),this.togglePlayPause()}}),this.canvas.addEventListener("dblclick",e=>{this.enableClickToPlay&&(e.preventDefault(),this.restorePlayback(),this.toggleFullscreen())}),this.canvas.addEventListener("pointermove",this.handlePointerMove),this.canvas.addEventListener("pointerleave",this.handlePointerLeave),document.addEventListener("fullscreenchange",this.handleFullscreenChange),document.addEventListener("pointerdown",this.handleMomentsDismiss,!0),document.addEventListener("keydown",this.handleMomentsDismiss,!0),document.addEventListener("visibilitychange",this.handleVisibility),window.addEventListener("pagehide",this.handleHidden),document.addEventListener("pointerup",this.handlePointerRelease,!0),document.addEventListener("pointercancel",this.handlePointerRelease,!0),this.observerMapResizeObserver?.observe(this.observerMapPanel),this.controlsFitObserver?.observe(this.controlsRow),this.controlsFitObserver?.observe(this.controlsRow.querySelector(".controls-left")),typeof MutationObserver<"u"&&(this.controlsMutations=new MutationObserver(()=>this.fitControls()),this.controlsMutations.observe(this.controlsRight,{attributes:!0,attributeFilter:["hidden"],childList:!0,subtree:!0})),this.hostControls(void 0),this.player=this.createPlayer(),this.updateTimeLabels(),this.updatePlayPauseButton(),this.updateFullscreenButton(),this.updateMuteButton(),this.updateObserverMapButton(),this.updateReferencesButton(),this.updateMilestonesButton(),this.refresh()}connectedCallback(){this.saidTexts=void 0,this.loadLocaleMessages();const t=this.getAttribute("src");t&&this.loadFromSrc(t)}disconnectedCallback(){document.removeEventListener("fullscreenchange",this.handleFullscreenChange),document.removeEventListener("pointerdown",this.handleMomentsDismiss,!0),document.removeEventListener("keydown",this.handleMomentsDismiss,!0),document.removeEventListener("visibilitychange",this.handleVisibility),window.removeEventListener("pagehide",this.handleHidden),document.removeEventListener("pointerup",this.handlePointerRelease,!0),document.removeEventListener("pointercancel",this.handlePointerRelease,!0),window.clearTimeout(this.controlsIdleTimer),this.observerMapResizeObserver?.disconnect(),this.controlsFitObserver?.disconnect(),this.controlsMutations?.disconnect(),this.exitSimulatedFullscreen(),this.sightingAudio.dispose()}attributeChangedCallback(t,e,i){t==="src"&&i&&i!==e&&this.isConnected&&this.loadFromSrc(i),t===_r&&this.applyObserverMapDefault(),t===Sr&&this.setMilestonesShown(!this.hasAttribute(Sr))}async loadFromSrc(t){this.sightingData=await rg.json(t)}get sightingData(){return zv(this.currentSighting)}set sightingData(t){this.player.stop(),this.soundPreview=void 0,this.sightingAudio.silence(),this.currentSighting=Hv(t),this.issuesPanel.hidden=!0,this.issuesButton.setAttribute("aria-expanded","false"),this.reportIssues(t,this.currentSighting),this.observerMapView.reset(),this.mapFitButton.hidden=!0,this.observerMapAsked=!1,this.player=this.createPlayer(),this.updateTimeLabels(),this.updatePlayPauseButton(),this.refresh(),this.applyObserverMapDefault()}get recordingIssues(){return this.issues}async reportIssues(t,e){const i=++this.issueCheck;let n=[];try{const{default:s}=await is(async()=>{const{default:a}=await import("./sightingSchema-DOOSOVWK.js");return{default:a}},[],import.meta.url);n=new An(s).issues(t)}catch{}i===this.issueCheck&&(this.issues=[...n,...e.loadIssues],Pr.warn(this.issues,e.id),this.renderIssues(),this.dispatchEvent(new CustomEvent(l2,{detail:{issues:this.issues},bubbles:!0,composed:!0})))}renderIssues(){const t=this.issues.length;this.issuesBox.hidden=t===0,this.shadow.getElementById("issues-count").textContent=String(t);const e=this.messages.recordingIssues.replace("{count}",String(t));this.issuesButton.title=e,this.issuesButton.setAttribute("aria-label",e),this.shadow.getElementById("issues-title").textContent=e,this.shadow.getElementById("issues-list").replaceChildren(...this.issues.map(i=>{const n=document.createElement("li");return n.textContent=Pr.text(i,this.messages.issueTemplates),n}))}get sighting(){return this.currentSighting}previewSound(t){this.soundPreview=t,this.sightingAudio.resume(),this.sightingAudio.setSound(t)}stopSoundPreview(){this.soundPreview=void 0,this.sightingAudio.silence()}get canvasElement(){return this.canvas}get renderer(){return this.canvasRenderer}get currentTime(){return this.player.time}set currentTime(t){this.player.seek(t)}get seekableDuration(){return this.player.seekableDuration}get autoReplayEnabled(){return this.loopEnabled}set autoReplayEnabled(t){t!==this.loopEnabled&&this.toggleLoop()}play(){this.player.seekableDuration<=0||this.playbackState==="playing"||this.togglePlayPause()}pause(){this.playbackState==="playing"&&this.togglePlayPause()}get positionLabel(){return this.timeStartLabel.textContent??""}get durationLabel(){return this.timeEndLabel.textContent??""}get showingClockTime(){return this.canShowClockTime}get canSwitchTimeDisplay(){return this.realStartMs!==void 0}toggleTimeDisplay(){this.canSwitchTimeDisplay&&(this.showClockTime=!this.showClockTime,this.updateTimeLabels(),this.updateTimeLabelTitles(),this.dispatchEvent(new CustomEvent("timedisplaychange",{bubbles:!0,composed:!0})))}get canShowClockTime(){return this.realStartMs!==void 0&&this.showClockTime}set showToolbar(t){this.toolbar.classList.toggle("hidden",!t),t?this.controlsRight.appendChild(this.fullscreenButton):this.cornerButtons.appendChild(this.fullscreenButton)}get playbackState(){return this.player.playbackState}get selectedSourceIds(){return this.highlightedSourceIds}get durationSeconds(){return this.currentSighting.event.durationSeconds}set durationSeconds(t){this.currentSighting.event.durationSeconds=t,this.updateTimeLabels(),this.refresh(),this.updatePlayPauseButton()}set selectedSourceIds(t){const e=new Set(t);e.size===this.highlightedSourceIds.size&&[...e].every(n=>this.highlightedSourceIds.has(n))||(this.highlightedSourceIds=e,this.refresh())}hasVisibleShapeAt(t,e){return this.shapeAt(t,e)!==void 0}refresh(){this.applyFrameFormat(),this.updateTimeLabels(),this.seekInput.max=String(this.player.seekableDuration),this.refreshMilestoneMarks(),this.updateMilestonesButton(),this.updateObserverMap(),this.updateReferences(),this.player.seek(this.player.time)}hostControls(t){const e=[this.milestonesButton,this.referencesButton,this.referenceOpacityInput,this.observerMapButton];if(t)for(const i of e)t.appendChild(i);else{const i=this.fullscreenButton.parentElement===this.controlsRight?this.fullscreenButton:null;for(const n of e)this.controlsRight.insertBefore(n,i)}}get referencesShown(){return this.referencesShownState}get referenceOpacity(){return Number(this.referenceOpacityInput.value)}toggleReferences(){this.referencesShownState=!this.referencesShownState,this.updateReferencesButton(),this.dispatchReferenceView()}updateReferences(){const t=this.currentSighting.references;!this.referenceOpacityTouched&&t.length>0&&(this.referenceOpacityInput.value=String(t[0].opacity)),this.updateReferencesButton()}updateReferencesButton(){const t=this.currentSighting.references.length>0;this.referencesButton.hidden=!t,this.referenceOpacityInput.hidden=!t||!this.referencesShownState,this.referencesButton.setAttribute("aria-pressed",String(this.referencesShownState)),fe.setIcon(this.referencesButton,this.referencesShownState?Zt.PICTURES_ON:Zt.PICTURES_OFF);const e=this.referencesShownState?this.messages.hideReferences:this.messages.showReferences;this.referencesButton.title=e,this.referencesButton.setAttribute("aria-label",e),this.referenceOpacityInput.title=this.messages.referenceOpacity,this.referenceOpacityInput.setAttribute("aria-label",this.messages.referenceOpacity)}dispatchReferenceView(){this.dispatchEvent(new CustomEvent("referenceview",{detail:{shown:this.referencesShown,opacity:this.referenceOpacity}}))}refreshMilestoneMarks(){const t=this.player.seekableDuration,e=t>0?So(this.sighting.milestones):[];this.milestoneMarks.replaceChildren(...e.map(i=>{const n=document.createElement("button");n.type="button",n.className="milestone-mark",n.style.left=`${Math.min(Math.max(i.t/t,0),1)*100}%`;const s=this.said.read(i.label)??"",a=this.said.read(i.note),o=a?`${s} — ${a}`:s;return n.title=o,n.setAttribute("aria-label",o),n.dataset.t=String(i.t),n.addEventListener("click",()=>this.player.seek(i.t)),n})),this.refreshSeekSegments(t,e.map(i=>i.t)),this.refreshMomentsPicker(e)}refreshMomentsPicker(t){const e=this.milestonesShown&&t.length>0;this.momentsBox.hidden=!e,this.closeMomentsMenu(),this.momentsMenu.replaceChildren(...t.map(i=>{const n=document.createElement("li"),s=document.createElement("button");s.type="button",s.dataset.t=String(i.t);const a=this.said.read(i.label)??"",o=this.said.read(i.note);return s.textContent=o?`${a} — ${o}`:a,s.addEventListener("click",()=>{this.player.seek(i.t),this.closeMomentsMenu()}),n.appendChild(s),n})),this.momentsButton.title=this.messages.moments,this.showCurrentMoment(void 0)}showCurrentMoment(t){const i=(t?this.said.read(t.label)??"":"")||this.messages.moments;this.momentsCurrent.textContent!==i&&(this.momentsCurrent.textContent=i);for(const n of this.momentsMenu.querySelectorAll("button")){const s=t!==void 0&&Number(n.dataset.t)===t.t;n.getAttribute("aria-current")==="true"!==s&&n.setAttribute("aria-current",String(s))}}toggleMomentsMenu(){this.momentsMenu.hidden?(this.momentsMenu.hidden=!1,this.momentsButton.setAttribute("aria-expanded","true")):this.closeMomentsMenu()}closeMomentsMenu(){this.momentsMenu.hidden=!0,this.momentsButton.setAttribute("aria-expanded","false")}handleMomentsDismiss=t=>{if(!this.momentsMenu.hidden){if(t instanceof KeyboardEvent){t.key==="Escape"&&this.closeMomentsMenu();return}t.composedPath().some(e=>e===this.momentsMenu||e===this.momentsButton)||this.closeMomentsMenu()}};seekSegmentList=[];refreshSeekSegments(t,e){const n=[0,...this.milestonesShown&&t>0?[...new Set(e.filter(a=>a>0&&a<t))].sort((a,o)=>a-o):[],Math.max(t,0)];this.seekSegmentList=[];const s=[];for(let a=0;a<n.length-1;a++){const o=document.createElement("div");o.className="seek-segment",o.style.flexGrow=String(Math.max(n[a+1]-n[a],1));const c=document.createElement("i");c.className="seek-hover";const l=document.createElement("i");l.className="seek-played",o.append(c,l),s.push(o),this.seekSegmentList.push({start:n[a],end:n[a+1],element:o,played:l,hover:c})}this.seekSegments.replaceChildren(...s),this.paintSeekProgress(this.player.time)}static fillOf(t,e){const i=t.end-t.start,n=i>0?(e-t.start)/i:e>=t.end?1:0;return`${Math.min(Math.max(n,0),1)*100}%`}paintSeekProgress(t){for(const i of this.seekSegmentList)i.played.style.width=fe.fillOf(i,t);const e=this.player.seekableDuration;this.seekDot.style.left=`${e>0?Math.min(Math.max(t/e,0),1)*100:0}%`}hoverSeek(t){const e=this.seekInput.getBoundingClientRect(),i=this.player.seekableDuration;if(e.width<=0||i<=0)return;const n=Math.min(Math.max((t.clientX-e.left)/e.width,0),1),s=n*i,a=this.seekSegmentList.length-1;this.seekSegmentList.forEach((f,p)=>{f.hover.style.width=fe.fillOf(f,s),f.element.classList.toggle("hovered",s>=f.start&&(s<f.end||p===a))});const o=this.milestonesShown?this.sighting.milestones:[],c=o.length>0?ih(o,s):void 0,l=c?this.said.read(c.label)??"":"",h=c?this.said.read(c.note):void 0,u=h?`${l} — ${h}`:l;this.seekPreviewTitle.textContent=u,this.seekPreviewTime.textContent=this.formatPosition(s),this.seekPreview.hidden=!1;const d=this.seekPreview.offsetWidth;this.seekPreview.style.left=`${Math.min(Math.max(n*e.width-d/2,0),Math.max(e.width-d,0))}px`,this.paintSeekPreview(s)}leaveSeek(){for(const t of this.seekSegmentList)t.hover.style.width="0",t.element.classList.remove("hovered");this.seekPreview.hidden=!0}seekPreviewPainter;paintSeekPreview(t){const e=this.seekPreviewPainter;this.seekPreviewCanvas.hidden=e===void 0,e?.(t,this.seekPreviewCanvas)}scrubbingPointer;beginTouchScrub(t){if(t.pointerType!=="mouse"){this.scrubbingPointer=t.pointerId;try{this.seekInput.setPointerCapture(t.pointerId)}catch{}this.seekToPointer(t)}}touchScrub(t){t.pointerId===this.scrubbingPointer&&this.seekToPointer(t)}endTouchScrub(t){t.pointerId===this.scrubbingPointer&&(this.scrubbingPointer=void 0,this.seekToPointer(t))}seekToPointer(t){const e=this.seekInput.getBoundingClientRect(),i=this.player.seekableDuration;if(e.width<=0||i<=0)return;const n=Math.min(Math.max((t.clientX-e.left)/e.width,0),1);this.player.seek(this.snapSeekToMark(n*i))}seekSnapArmed=!1;static MARK_SNAP_PX=6;markNear(t){const e=this.player.seekableDuration,i=this.seekInput.getBoundingClientRect().width;if(e<=0||i<=0)return;const n=fe.MARK_SNAP_PX/i*e;let s;for(const a of this.milestoneMarks.children){const o=Number(a.dataset.t);Math.abs(o-t)>n||(!s||Math.abs(o-t)<Math.abs(s.t-t))&&(s={t:o,name:a.title})}return s}snapSeekToMark(t){return this.seekSnapArmed?(this.seekSnapArmed=!1,this.markNear(t)?.t??t):t}nameMarkUnder(t){const e=this.seekInput.getBoundingClientRect(),i=this.player.seekableDuration;if(e.width<=0||i<=0)return;const n=(t.clientX-e.left)/e.width*i,s=this.markNear(n);s?this.seekInput.title=s.name:this.seekInput.removeAttribute("title")}showMilestoneAt(t){const e=this.milestonesShown&&this.sighting.milestones.length>0?ih(this.sighting.milestones,t):void 0;if(this.milestoneCaption.hidden=e===void 0,this.showCurrentMoment(e),!e)return;const i=document.createElement("b");i.textContent=this.said.read(e.label)??"";const n=this.said.read(e.note),s=n?` — ${n}`:"";this.milestoneCaption.replaceChildren(i,document.createTextNode(s))}exposureInstants(t){const e=this.exposureTimes(t),i=1/e.length;return e.map(n=>({shapes:this.shapesAt(n),share:i}))}exposureTimes(t=this.currentTime){const e=Cn.windowEndingAt(t,this.currentSighting.exposure??0);if(e.ms<fe.SHORTEST_VISIBLE_EXPOSURE_MS)return[t];const i=Math.min(fe.MAX_EXPOSURE_STEPS,Math.max(2,Math.round(e.ms/fe.SHORTEST_VISIBLE_EXPOSURE_MS))),n=Math.ceil(this.travelPxOver(e.fromMs,e.ms)/fe.EXPOSURE_STEP_PX),s=Math.min(fe.MAX_TRAVEL_STEPS,Math.max(i,n)),a=[];for(let o=0;o<s;o++)a.push(e.fromMs+e.ms*o/(s-1));return a}travelPxOver(t,e){const i=this.shapesAt(t),n=this.shapesAt(t+e);let s=0;for(const[a,o]of i){const c=n.get(a);if(!c)continue;const l=c.bounds.x+c.bounds.width/2-(o.bounds.x+o.bounds.width/2),h=c.bounds.y+c.bounds.height/2-(o.bounds.y+o.bounds.height/2);s=Math.max(s,Math.hypot(l,h))}return s}shapeAt(t,e,i){for(const n of this.exposureTimes()){const s=this.currentSighting.timeline.hitTest(n,t,e,i);if(s)return s}}shapesAt(t){const e=new Map;for(const i of this.currentSighting.timeline.sourceIds){const n=this.currentSighting.timeline.getInterpolatedShapeAt(t,i);n&&e.set(i,n)}return e}static SHORTEST_VISIBLE_EXPOSURE_MS=20;static MAX_EXPOSURE_STEPS=48;static EXPOSURE_STEP_PX=2;static MAX_TRAVEL_STEPS=320;applyFrameFormat(){const t=fi.frameWidthPx(this.currentSighting.instrument,this.canvas.height);if(this.canvas.width===t)return;this.canvas.width=t,this.canvas.parentElement?.style.setProperty("--frame-aspect",`${t} / ${this.canvas.height}`)}canvasPointFromEvent(t){const e=this.canvas.getBoundingClientRect();if(!(e.width===0||e.height===0))return{x:(t.clientX-e.left)/e.width*this.canvas.width,y:(t.clientY-e.top)/e.height*this.canvas.height}}onFrame(t,e){this.canvasRenderer.clear(this.canvas.width,this.canvas.height);const i=this.playbackState!=="playing"?this.highlightedSourceIds:c2;this.canvasRenderer.setStarPoints(fi.starPointsOf(this.sighting.instrument));const n=(di(this.sighting,t)?.rollDeg??0)+this.gaitAt(t).rollDeg;this.canvasRenderer.setRoll(n*Math.PI/180);const s=this.exposureInstants(t),a=this.frameShift;if(this.paintsShapes)for(const o of s)for(const[,c]of o.shapes){const l=o.share,h=l===1?c:{...c,transparency:1-(1-c.transparency)*l};this.canvasRenderer.paintShape(this.shifted(h,a))}for(const[o,c]of s[0].shapes)!this.selectionShown||!i.has(o)||(this.paintsShapes?i.size===1?this.canvasRenderer.paintShape({...c,selected:!0}):this.canvasRenderer.paintMemberOutline(c):this.canvasRenderer.paintSelectionOnly(this.shifted(c,a)));if(this.selectionShown&&i.size>1){const o=cn.groupBoundsFor([...e].filter(([c])=>i.has(c)).map(([,c])=>c.bounds));this.canvasRenderer.paintGroupHandles(o)}this.overlayPainter?.(this.canvasRenderer),this.mapShapeBounds=s.flatMap(o=>[...o.shapes.values()].filter(c=>c.transparency<1).map(c=>this.shifted(c,a).bounds)),this.keepObserverMapClear(),this.seekInput.value=String(t),this.paintSeekProgress(t),this.timeStartLabel.textContent=this.formatPosition(t),this.showMilestoneAt(t),this.paintObserverMap(t),this.playbackState==="playing"?(this.soundPreview=void 0,this.sightingAudio.setSound(Iv(this.currentSighting,t))):this.soundPreview?this.sightingAudio.setSound(this.soundPreview):this.sightingAudio.silence(),this.updatePlayPauseButton(),this.dispatchEvent(new CustomEvent("timeupdate",{detail:{time:t}}))}shifted(t,e){return e.x===0&&e.y===0?t:{...t,bounds:{...t.bounds,x:t.bounds.x+e.x,y:t.bounds.y+e.y}}}createPlayer(){const t=new Cv(this.currentSighting.timeline,(e,i)=>this.onFrame(e,i));return t.loop=this.loopEnabled,t.onEnded=()=>{this.updatePlayPauseButton(),this.dispatchEvent(new CustomEvent("ended",{bubbles:!0,composed:!0}))},t}static SEEK_KEY_STEP_MS=5e3;handleFullscreenKey=t=>{t.key.toLowerCase()!=="f"||t.altKey||t.ctrlKey||t.metaKey||!this.enableClickToPlay||t.composedPath().some(i=>i instanceof HTMLElement&&(i.isContentEditable||["INPUT","TEXTAREA","SELECT"].includes(i.tagName)&&i.type!=="range"))||(t.preventDefault(),this.toggleFullscreen())};handleSeekKey=t=>{if(t.altKey||t.ctrlKey||t.metaKey)return;const e=t.key==="ArrowLeft"?-1:t.key==="ArrowRight"?1:0;if(e){t.preventDefault();const i=this.player.seekableDuration;this.player.seek(Math.min(i,Math.max(0,this.player.time+e*fe.SEEK_KEY_STEP_MS)))}else t.key===" "&&(t.preventDefault(),this.togglePlayPause())};togglePlayPause(){this.player.seekableDuration<=0||(this.player.playbackState==="playing"?(this.player.pause(),this.soundPreview=void 0,this.sightingAudio.silence(),this.refresh()):(this.sightingAudio.resume(),this.player.play()),this.updatePlayPauseButton(),this.flashPlayback())}flashPlayback(){const t=this.playbackFlash;t.innerHTML=this.player.playbackState==="playing"?Zt.PLAY:Zt.PAUSE,t.classList.remove("flashing"),t.offsetWidth,t.classList.add("flashing")}static icons=new WeakMap;static setIcon(t,e){fe.icons.get(t)!==e&&(fe.icons.set(t,e),t.innerHTML=e)}set captionHeld(t){this.stageElement.classList.toggle("caption-held",t)}static CONTROLS_IDLE_MS=3e3;controlsIdleTimer;wasPlaying=!1;quietControlsValue=!1;get quietControls(){return this.quietControlsValue}set quietControls(t){this.quietControlsValue=t,this.stageElement.classList.toggle("quiet",t)}tapRevealedOnly=!1;get hoverless(){return typeof matchMedia=="function"&&matchMedia("(hover: none)").matches}touchedStage(){if(!this.hoverless)return;this.player.playbackState==="playing"&&!this.stageElement.classList.contains("touched")&&(this.tapRevealedOnly=!0),this.revealControls()}pointerHeld=!1;handlePointerDown=()=>{this.pointerHeld=!0};resumeAfterScrub=!1;suspendForScrub(){this.player.playbackState==="playing"&&(this.resumeAfterScrub=!0,this.stopPlaying())}stopPlaying(){this.player.pause(),this.soundPreview=void 0,this.sightingAudio.silence(),this.refresh(),this.updatePlayPauseButton()}resumeFromScrub(){this.resumeAfterScrub&&(this.resumeAfterScrub=!1,this.sightingAudio.resume(),this.player.play(),this.updatePlayPauseButton())}handleHidden=()=>{this.player.playbackState==="playing"&&this.stopPlaying(),this.resumeAfterScrub=!1};handleVisibility=()=>{document.visibilityState==="hidden"&&this.handleHidden()};handlePointerRelease=()=>{this.resumeAfterScrub&&window.setTimeout(()=>this.resumeFromScrub(),0),this.pointerHeld&&(this.pointerHeld=!1,this.hoverless&&this.stageElement.classList.contains("touched")&&this.revealControls())};revealControls(){this.stageElement.classList.add("touched"),window.clearTimeout(this.controlsIdleTimer),this.player.playbackState==="playing"&&(this.pointerHeld||!this.momentsMenu.hidden||(this.controlsIdleTimer=window.setTimeout(()=>{this.stageElement.classList.remove("touched"),this.tapRevealedOnly=!1},fe.CONTROLS_IDLE_MS)))}updatePlayPauseButton(){const t=this.player.playbackState==="playing";this.stageElement.classList.toggle("paused",!t),t!==this.wasPlaying&&t&&this.hoverless&&!this.quietControlsValue&&this.revealControls(),this.wasPlaying=t,fe.setIcon(this.playPauseButton,t?Zt.PAUSE:Zt.PLAY);const e=this.player.seekableDuration>0;this.playPauseButton.disabled=!e;const i=e?t?this.messages.pause:this.messages.play:this.messages.noDuration;this.playPauseButton.title=i,this.playPauseButton.setAttribute("aria-label",i)}toggleLoop(){this.loopEnabled=!this.loopEnabled,this.player.loop=this.loopEnabled}restorePlayback(){const t=this.playbackBeforeClick;t&&(this.currentTime=t.time,t.state==="playing"?this.play():this.pause())}get canUseNativeFullscreen(){return typeof this.fullscreenTarget.requestFullscreen=="function"&&document.fullscreenEnabled}toggleFullscreen(){if(!this.canUseNativeFullscreen){this.simulatedFullscreen?this.exitSimulatedFullscreen():this.enterSimulatedFullscreen();return}document.fullscreenElement?document.exitFullscreen():this.fullscreenTarget.requestFullscreen().catch(t=>{console.error("<rr0-ufo>: requestFullscreen() failed —",t)})}enterSimulatedFullscreen(){const t=this.fullscreenTarget;this.styleBeforeSimulatedFullscreen=t.getAttribute("style")??"",this.bodyOverflowBeforeSimulatedFullscreen=document.body.style.overflow;const e=t.style;e.setProperty("position","fixed"),e.setProperty("inset","0"),e.setProperty("margin","0"),e.setProperty("max-width","none"),e.setProperty("max-height","none"),e.setProperty("aspect-ratio","auto"),e.setProperty("z-index","2147483647"),e.setProperty("background","#000"),e.setProperty("width","100vw"),e.setProperty("width","100dvw"),e.setProperty("height","100vh"),e.setProperty("height","100dvh"),document.body.style.overflow="hidden",this.simulatedFullscreen=!0,document.addEventListener("keydown",this.handleSimulatedFullscreenKey),this.updateFullscreenButton(),this.updateMuteButton()}exitSimulatedFullscreen(){if(!this.simulatedFullscreen)return;const t=this.fullscreenTarget;this.styleBeforeSimulatedFullscreen?t.setAttribute("style",this.styleBeforeSimulatedFullscreen):t.removeAttribute("style"),document.body.style.overflow=this.bodyOverflowBeforeSimulatedFullscreen??"",this.simulatedFullscreen=!1,document.removeEventListener("keydown",this.handleSimulatedFullscreenKey),this.updateFullscreenButton(),this.updateMuteButton()}toggleObserverMap(){const t=this.observerMapPanel.hidden;this.observerMapAsked=t,this.setObserverMapOpen(t),this.keepObserverMapClear()}observerMapAsked=!1;applyObserverMapDefault(){const t=this.getAttribute(_r),e=t===null?this.observerPath?.travels===!0:t!=="false";this.setObserverMapOpen(e&&this.observerPath!==void 0)}setObserverMapOpen(t){this.observerMapPanel.hidden=!t,this.observerMapPanel.removeAttribute("title"),this.observerMapButton.setAttribute("aria-pressed",String(t)),this.updateObserverMapButton(),t&&(this.sizeObserverMapCanvas(),this.loadObserverMapImagery(),this.paintObserverMap(this.currentTime))}updateObserverMapButton(){const t=!this.observerMapPanel.hidden;fe.setIcon(this.observerMapButton,t?Zt.MAP_ON:Zt.MAP_OFF);const e=t?this.messages.hideObserverMap:this.messages.showObserverMap;this.observerMapButton.title=e,this.observerMapButton.setAttribute("aria-label",e);const i=[[this.mapZoomInButton,this.messages.zoomMapIn],[this.mapZoomOutButton,this.messages.zoomMapOut],[this.mapFitButton,this.messages.fitMap]];for(const[n,s]of i)n.title=s,n.setAttribute("aria-label",s)}updateObserverMap(){const t=this.observerPath!==void 0;if(this.observerPath=yr.of(this.currentSighting),this.observerMapButton.hidden=this.observerPath===void 0,!t&&this.observerPath&&this.applyObserverMapDefault(),!this.observerPath){this.setObserverMapOpen(!1),this.observerMapBounds=void 0;return}const e=this.observerPath.boundsAround(fe.OBSERVER_MAP_MIN_SPAN_M,fe.OBSERVER_MAP_MARGIN);(!this.observerMapBounds||!this.sameGround(this.observerMapBounds,e))&&(this.observerMapBounds&&this.observerMapView.refit(this.observerMapBounds,e),this.observerMapBounds=e,this.observerMapImagery=void 0,this.observerMapImageryCredit=void 0,this.observerMapImageryFailed=!1,this.observerMapImageryBounds=void 0,this.observerMapImageryLoading=!1,this.observerMapPanel.hidden||this.loadObserverMapImagery())}sameGround(t,e){const i=Math.abs(t.east-t.west)/20;return Math.abs(t.north-e.north)<i&&Math.abs(t.south-e.south)<i&&Math.abs(t.west-e.west)<i&&Math.abs(t.east-e.east)<i}async loadObserverMapImagery(){const t=this.observerMapViewBounds;if(!t||this.observerMapPanel.hidden||this.observerMapImageryLoading||!this.observerMapImageryNeededFor(t))return;const e=this.observerMapView.changed,i=e?Ye.expand(t,fe.OBSERVER_MAP_IMAGERY_AHEAD):t,n=fe.OBSERVER_MAP_IMAGERY_PX*(e?1+2*fe.OBSERVER_MAP_IMAGERY_AHEAD:1);this.observerMapImageryBounds=i,this.observerMapImageryViewWidth=t.east-t.west,this.observerMapImageryLoading=!0;const s=xg();try{const a=await s.getImageryTexture(i,{width:n,height:n});if(this.observerMapImageryBounds!==i)return;this.observerMapImagery=a,this.observerMapImageryCredit=s.attribution,this.observerMapImageryFailed=!1}catch{if(this.observerMapImageryBounds!==i)return;this.observerMapImageryFailed=this.observerMapImagery===void 0}finally{this.observerMapImageryBounds===i&&(this.observerMapImageryLoading=!1)}this.paintObserverMap(this.currentTime),this.scheduleObserverMapImagery()}static OBSERVER_MAP_IMAGERY_AHEAD=.5;static OBSERVER_MAP_IMAGERY_LOOKAHEAD=.25;observerMapImageryNeededFor(t){const e=this.observerMapImageryBounds;if(!e)return!0;const i=this.observerMapImagery?.bounds??e,n=this.observerMapView.changed?Ye.expand(t,fe.OBSERVER_MAP_IMAGERY_LOOKAHEAD):t,s=n.west>=i.west&&n.east<=i.east&&n.south>=i.south&&n.north<=i.north,a=t.east-t.west>this.observerMapImageryViewWidth/2;return!s||!a}get observerMapCredit(){return this.observerMapImageryCredit}get observerMapFooterLine(){return this.observerMapImageryFailed?this.messages.mapImageryUnavailable:this.creditShownExternally?void 0:this.observerMapImageryCredit}mapShapeBounds=[];mapSceneBounds=[];setMapSubjectBounds(t){this.mapSceneBounds=t.map(e=>({x:e.x*this.canvas.width,y:e.y*this.canvas.height,width:e.width*this.canvas.width,height:e.height*this.canvas.height})),this.keepObserverMapClear()}keepObserverMapClear(){if(this.observerMapPanel.hidden)return;const t=this.observerMapBoxPx;if(!t)return;const e=[...this.mapShapeBounds,...this.mapSceneBounds],i=(l,h,u)=>{for(const d of e)if(!(d.x+d.width<l-u||d.x>h+u)&&!(d.y>t.bottom+u||d.y+d.height<t.top-u))return!0;return!1},n=[this.canvas.width-t.width,this.canvas.width],s=[0,t.width],a=fe.OBSERVER_MAP_CLEARANCE_PX,o=i(...n,0),c=i(...s,0);if(this.observerMapPanel.classList.toggle("subject-overlap",o&&c&&!this.observerMapAsked),this.observerMapPanel.classList.contains("on-the-left")){!o&&(c||!i(n[0],n[1],a))&&this.observerMapPanel.classList.remove("on-the-left");return}i(n[0],n[1],0)&&!i(s[0],s[1],0)&&this.observerMapPanel.classList.add("on-the-left")}observerMapBoxPx;static OBSERVER_MAP_CLEARANCE_PX=24;sizeObserverMapCanvas(){const t=this.observerMapPanel.clientWidth;if(t===0)return;const e=Math.round(t*(globalThis.devicePixelRatio??1));this.measureObserverMapBox(),this.observerMapCanvas.width!==e&&(this.observerMapCanvas.width=e,this.observerMapCanvas.height=e)}measureObserverMapBox(){const t=this.observerMapPanel.getBoundingClientRect(),e=this.canvas.getBoundingClientRect();if(e.width===0||e.height===0)return;const i=this.canvas.width/e.width,n=this.canvas.height/e.height;this.observerMapBoxPx={width:t.width*i,top:(t.top-e.top)*n,bottom:(t.bottom-e.top)*n}}paintObserverMap(t){if(this.observerMapPanel.hidden||!this.observerPath||!this.observerMapBounds)return;const e=di(this.currentSighting,t);e?.lat!==void 0&&e.lng!==void 0&&!this.observerMapDrag?.moved&&this.observerMapView.keepInView(this.observerMapBounds,{lat:e.lat,lng:e.lng},fe.OBSERVER_MAP_FOLLOW_MARGIN)&&this.scheduleObserverMapImagery();const i=this.currentSighting.instrument,n=[],s=this.currentSighting.milestones.length>0?ih(this.currentSighting.milestones,t):void 0;for(const a of this.milestonesShown?So(this.currentSighting.milestones):[]){const o=di(this.currentSighting,a.t);o?.lat===void 0||o.lng===void 0||n.push({label:this.said.read(a.label)??"",note:this.said.read(a.note),t:a.t,lat:o.lat,lng:o.lng,current:a===s})}this.observerMapRenderer.paint({bounds:this.observerMapViewBounds,imagery:this.observerMapImagery,path:this.observerPath,position:e?.lat!==void 0&&e.lng!==void 0?{lat:e.lat,lng:e.lng}:void 0,headingDeg:e?.headingDeg===void 0?void 0:e.headingDeg+this.lookYawDeg,coneHalfAngleDeg:e?Ss.of(i,this.canvas.height,e.fovDeg).halfWidthAngleDeg(fi.aspectOf(i)):void 0,markers:n,decor:this.observerMapDecorAt(t),observerLabel:this.said.read(this.currentSighting.observer?.title)??this.messages.observerHere,nightFraction:this.observerMapNightFraction,attribution:this.observerMapFooterLine})}toggleMilestones(){this.setMilestonesShown(!this.milestonesShown)}setMilestonesShown(t){this.milestonesShown=t,this.milestoneMarks.hidden=!t,this.momentsBox.hidden=!t||this.sighting.milestones.length===0,this.refreshSeekSegments(this.player.seekableDuration,So(this.sighting.milestones).map(e=>e.t)),this.milestonesButton.setAttribute("aria-pressed",String(t)),this.updateMilestonesButton(),this.showMilestoneAt(this.currentTime),this.paintObserverMap(this.currentTime)}updateMilestonesButton(){this.milestonesButton.hidden=this.currentSighting.milestones.length===0,this.momentsButton.title=this.messages.moments,fe.setIcon(this.milestonesButton,this.milestonesShown?Zt.MILESTONES_ON:Zt.MILESTONES_OFF);const t=this.milestonesShown?this.messages.hideMilestones:this.messages.showMilestones;this.milestonesButton.title=t,this.milestonesButton.setAttribute("aria-label",t)}observerMapDecorAt(t){const e=di(this.currentSighting,0);return e?.lat===void 0||e.lng===void 0?[]:this.currentSighting.decor.filter(i=>i.kind!=="crop").map(i=>{const n=Co(i,t),{lat:s,lng:a}=_s(n.eastM,-n.northM,e.lat,e.lng);return{lat:s,lng:a,headingDeg:n.headingDeg,label:this.said.read(i.title)??this.messages.decorHere}})}observerMapNightFraction;setSunAltitude(t){const e=t===void 0?void 0:Math.max(0,Math.min(1,-t/12));e!==this.observerMapNightFraction&&(this.observerMapNightFraction=e,this.paintObserverMap(this.currentTime))}setLookOffset(t,e){t===this.lookYawDeg&&e===this.lookPitchDeg||(this.lookYawDeg=t,this.lookPitchDeg=e,this.refresh())}get frameShiftPx(){return this.frameShift}get frameShift(){const t=this.gaitAt(this.currentTime),e=this.lookYawDeg+t.yawDeg,i=this.lookPitchDeg+t.pitchDeg;if(e===0&&i===0)return{x:0,y:0};const n=di(this.currentSighting,this.currentTime),s=Ss.of(this.currentSighting.instrument,this.canvas.height,n?.fovDeg??60);return{x:-s.angleDegToRadiusPx(e),y:s.angleDegToRadiusPx(i)}}gaitAt(t){return _e.bodyAt(this.currentSighting,t,this.steadyObserver)}mutedState=!1;get muted(){return this.mutedState}set muted(t){t!==this.mutedState&&(this.mutedState=t,!t&&this.volumeState===0&&(this.volumeState=fe.RESTORED_VOLUME),this.applyLevel())}volumeState=1;static RESTORED_VOLUME=.5;get volume(){return this.volumeState}set volume(t){this.setVolume(t)}setVolume(t){this.volumeState=Math.min(Math.max(t,0),1),this.mutedState=this.volumeState===0,this.applyLevel()}get level(){return this.mutedState?0:this.volumeState}applyLevel(){this.sightingAudio.setLevel(this.level),this.updateMuteButton(),this.dispatchEvent(new CustomEvent("mutedchange",{bubbles:!0,composed:!0,detail:{muted:this.mutedState,volume:this.volumeState}}))}toggleMuted(){this.muted=!this.mutedState}updateMuteButton(){fe.setIcon(this.muteButton,this.mutedState?Zt.MUTED:Zt.VOLUME);const t=this.mutedState?this.messages.unmute:this.messages.mute;this.muteButton.title=t,this.muteButton.setAttribute("aria-label",t),this.muteButton.setAttribute("aria-pressed",String(this.mutedState)),this.volumeInput.value=String(this.level)}updateFullscreenButton(){const t=this.simulatedFullscreen||document.fullscreenElement===this.fullscreenTarget;fe.setIcon(this.fullscreenButton,t?Zt.EXIT_FULLSCREEN:Zt.ENTER_FULLSCREEN),this.fullscreenButton.title=t?this.messages.exitFullscreen:this.messages.fullscreen,this.fullscreenButton.setAttribute("aria-label",this.fullscreenButton.title)}get said(){return this.saidTexts??=new Ks(pl.preferencesFor(this))}saidTexts;async loadLocaleMessages(){const t=cg(pl.preferencesFor(this),lg);if(t===this.messagesLanguage||t==="en"&&this.messagesLanguage===void 0)return;this.messagesLanguage=t;const e=await Wv(t);this.messagesLanguage===t&&this.applyMessages(e)}messagesLanguage;updateTimeLabelTitles(){const t=this.showClockTime?this.messages.switchToElapsed:this.messages.switchToClockTime,e=this.canSwitchTimeDisplay?` — ${t}`:"";this.timeStartLabel.title=this.messages.currentPosition+e,this.timeEndLabel.title=this.messages.duration+e,this.timePill.classList.toggle("switchable",this.canSwitchTimeDisplay),this.canSwitchTimeDisplay?(this.timePill.setAttribute("role","button"),this.timePill.setAttribute("tabindex","0")):(this.timePill.removeAttribute("role"),this.timePill.removeAttribute("tabindex"))}applyMessages(t){this.messages=t,this.updateTimeLabelTitles(),this.updatePlayPauseButton(),this.updateFullscreenButton(),this.updateMuteButton(),this.updateObserverMapButton(),this.updateReferencesButton(),this.updateMilestonesButton(),this.renderIssues()}updateTimeLabels(){const t=this.currentSighting.event,e=Tv(t);this.realDurationMs=e!==void 0&&e>0?e:void 0,this.realStartMs=t.time?wu(t.time):void 0;const i=this.currentSighting.timeline.duration;this.player.playbackRate=this.realDurationMs!==void 0&&i>0?i/this.realDurationMs:1,this.player.durationOverrideMs=i>0?0:this.realDurationMs??0,this.timeEndLabel.textContent=this.formatEndOfTimeline(),this.timeStartLabel.textContent=this.formatPosition(this.player.time),this.updateTimeLabelTitles()}formatPosition(t){if(this.realDurationMs===void 0)return sc(t);const e=this.currentSighting.timeline.duration,i=e>0&&t<=e?t/e*this.realDurationMs:t;return this.canShowClockTime?Sf(_f(this.realStartMs+i)):sc(i)}formatEndOfTimeline(){return this.realDurationMs===void 0?sc(this.currentSighting.timeline.duration):this.canShowClockTime?Sf(_f(this.realStartMs+this.realDurationMs)):sc(this.realDurationMs)}}function _f(r){const t=new Date(r);return{hour:t.getUTCHours(),minute:t.getUTCMinutes(),second:t.getUTCSeconds()}}function Sf(r){if(r.hour===void 0)return"0:00";const t=e=>String(e).padStart(2,"0");return r.second?`${t(r.hour)}:${t(r.minute??0)}:${t(r.second)}`:`${t(r.hour)}:${t(r.minute??0)}`}function sc(r){const t=Math.round(r/1e3),e=Math.floor(t/60),i=t%60;return`${e}:${String(i).padStart(2,"0")}`}const Au="rr0-ufo";function yg(){customElements.get(Au)||customElements.define(Au,fe)}const l2="recordingissues";/**
|
|
1344
1354
|
* @license
|
|
1345
1355
|
* Copyright 2010-2026 Three.js Authors
|
|
1346
1356
|
* SPDX-License-Identifier: MIT
|
|
@@ -6174,7 +6184,7 @@ vec3 finish(vec3 relative, vec4 overlay) {
|
|
|
6174
6184
|
* @fileoverview Astronomy calculation library for browser scripting and Node.js.
|
|
6175
6185
|
* @author Don Cross <cosinekitty@gmail.com>
|
|
6176
6186
|
* @license MIT
|
|
6177
|
-
*/const R0=173.1446326846693,Sa=14959787069098932e-8,Ee=.017453292519943295,Yp=.26179938779914946,os=57.29577951308232,p1=3.819718634205488,Hb=365.24217,qp=new Date("2000-01-01T12:00:00Z"),ms=2*Math.PI,Hs=3600*(180/Math.PI),gr=484813681109536e-20,m1=10800*60,Gb=2*m1,$p=7292115e-11,Vb=m1/Math.PI,Wb=-.17-5*Math.log10(Vb),Td=.996647180302104,Xb=Td*Td,Rd=6378.1366,Yb=Rd/Sa,g1=81.30056,D0=.0002959122082855911,Dd=2825345909524226e-22,Id=8459715185680659e-23,Cd=1292024916781969e-23,Pd=1524358900784276e-23;function Cl(r){if(r!==!0&&r!==!1)throw console.trace(),`Value is not boolean: ${r}`;return r}function Si(r){if(!Number.isFinite(r))throw console.trace(),`Value is not a finite number: ${r}`;return r}function lr(r){return r-Math.floor(r)}function qb(r,t){const e=r.x*r.x+r.y*r.y+r.z*r.z;if(Math.abs(e)<1e-8)throw"AngleBetween: first vector is too short.";const i=t.x*t.x+t.y*t.y+t.z*t.z;if(Math.abs(i)<1e-8)throw"AngleBetween: second vector is too short.";const n=(r.x*t.x+r.y*t.y+r.z*t.z)/Math.sqrt(e*i);return n<=-1?180:n>=1?0:os*Math.acos(n)}var wt;(function(r){r.Sun="Sun",r.Moon="Moon",r.Mercury="Mercury",r.Venus="Venus",r.Earth="Earth",r.Mars="Mars",r.Jupiter="Jupiter",r.Saturn="Saturn",r.Uranus="Uranus",r.Neptune="Neptune",r.Pluto="Pluto",r.SSB="SSB",r.EMB="EMB",r.Star1="Star1",r.Star2="Star2",r.Star3="Star3",r.Star4="Star4",r.Star5="Star5",r.Star6="Star6",r.Star7="Star7",r.Star8="Star8"})(wt||(wt={}));const $b=[wt.Star1,wt.Star2,wt.Star3,wt.Star4,wt.Star5,wt.Star6,wt.Star7,wt.Star8],Kb=[{ra:0,dec:0,dist:0},{ra:0,dec:0,dist:0},{ra:0,dec:0,dist:0},{ra:0,dec:0,dist:0},{ra:0,dec:0,dist:0},{ra:0,dec:0,dist:0},{ra:0,dec:0,dist:0},{ra:0,dec:0,dist:0}];function Zb(r){const t=$b.indexOf(r);return t>=0?Kb[t]:null}function I0(r){const t=Zb(r);return t&&t.dist>0?t:null}var Ai;(function(r){r[r.From2000=0]="From2000",r[r.Into2000=1]="Into2000"})(Ai||(Ai={}));const ss={Mercury:[[[[4.40250710144,0,0],[.40989414977,1.48302034195,26087.9031415742],[.050462942,4.47785489551,52175.8062831484],[.00855346844,1.16520322459,78263.70942472259],[.00165590362,4.11969163423,104351.61256629678],[.00034561897,.77930768443,130439.51570787099],[7583476e-11,3.71348404924,156527.41884944518]],[[26087.90313685529,0,0],[.01131199811,6.21874197797,26087.9031415742],[.00292242298,3.04449355541,52175.8062831484],[.00075775081,6.08568821653,78263.70942472259],[.00019676525,2.80965111777,104351.61256629678]]],[[[.11737528961,1.98357498767,26087.9031415742],[.02388076996,5.03738959686,52175.8062831484],[.01222839532,3.14159265359,0],[.0054325181,1.79644363964,78263.70942472259],[.0012977877,4.83232503958,104351.61256629678],[.00031866927,1.58088495658,130439.51570787099],[7963301e-11,4.60972126127,156527.41884944518]],[[.00274646065,3.95008450011,26087.9031415742],[.00099737713,3.14159265359,0]]],[[[.39528271651,0,0],[.07834131818,6.19233722598,26087.9031415742],[.00795525558,2.95989690104,52175.8062831484],[.00121281764,6.01064153797,78263.70942472259],[.00021921969,2.77820093972,104351.61256629678],[4354065e-11,5.82894543774,130439.51570787099]],[[.0021734774,4.65617158665,26087.9031415742],[.00044141826,1.42385544001,52175.8062831484]]]],Venus:[[[[3.17614666774,0,0],[.01353968419,5.59313319619,10213.285546211],[.00089891645,5.30650047764,20426.571092422],[5477194e-11,4.41630661466,7860.4193924392],[3455741e-11,2.6996444782,11790.6290886588],[2372061e-11,2.99377542079,3930.2096962196],[1317168e-11,5.18668228402,26.2983197998],[1664146e-11,4.25018630147,1577.3435424478],[1438387e-11,4.15745084182,9683.5945811164],[1200521e-11,6.15357116043,30639.856638633]],[[10213.28554621638,0,0],[.00095617813,2.4640651111,10213.285546211],[7787201e-11,.6247848222,20426.571092422]]],[[[.05923638472,.26702775812,10213.285546211],[.00040107978,1.14737178112,20426.571092422],[.00032814918,3.14159265359,0]],[[.00287821243,1.88964962838,10213.285546211]]],[[[.72334820891,0,0],[.00489824182,4.02151831717,10213.285546211],[1658058e-11,4.90206728031,20426.571092422],[1378043e-11,1.12846591367,11790.6290886588],[1632096e-11,2.84548795207,7860.4193924392],[498395e-11,2.58682193892,9683.5945811164],[221985e-11,2.01346696541,19367.1891622328],[237454e-11,2.55136053886,15720.8387848784]],[[.00034551041,.89198706276,10213.285546211]]]],Earth:[[[[1.75347045673,0,0],[.03341656453,4.66925680415,6283.0758499914],[.00034894275,4.62610242189,12566.1516999828],[3417572e-11,2.82886579754,3.523118349],[3497056e-11,2.74411783405,5753.3848848968],[3135899e-11,3.62767041756,77713.7714681205],[2676218e-11,4.41808345438,7860.4193924392],[2342691e-11,6.13516214446,3930.2096962196],[1273165e-11,2.03709657878,529.6909650946],[1324294e-11,.74246341673,11506.7697697936],[901854e-11,2.04505446477,26.2983197998],[1199167e-11,1.10962946234,1577.3435424478],[857223e-11,3.50849152283,398.1490034082],[779786e-11,1.17882681962,5223.6939198022],[99025e-10,5.23268072088,5884.9268465832],[753141e-11,2.53339052847,5507.5532386674],[505267e-11,4.58292599973,18849.2275499742],[492392e-11,4.20505711826,775.522611324],[356672e-11,2.91954114478,.0673103028],[284125e-11,1.89869240932,796.2980068164],[242879e-11,.34481445893,5486.777843175],[317087e-11,5.84901948512,11790.6290886588],[271112e-11,.31486255375,10977.078804699],[206217e-11,4.80646631478,2544.3144198834],[205478e-11,1.86953770281,5573.1428014331],[202318e-11,2.45767790232,6069.7767545534],[126225e-11,1.08295459501,20.7753954924],[155516e-11,.83306084617,213.299095438]],[[6283.0758499914,0,0],[.00206058863,2.67823455808,6283.0758499914],[4303419e-11,2.63512233481,12566.1516999828]],[[8721859e-11,1.07253635559,6283.0758499914]]],[[],[[.00227777722,3.4137662053,6283.0758499914],[3805678e-11,3.37063423795,12566.1516999828]]],[[[1.00013988784,0,0],[.01670699632,3.09846350258,6283.0758499914],[.00013956024,3.05524609456,12566.1516999828],[308372e-10,5.19846674381,77713.7714681205],[1628463e-11,1.17387558054,5753.3848848968],[1575572e-11,2.84685214877,7860.4193924392],[924799e-11,5.45292236722,11506.7697697936],[542439e-11,4.56409151453,3930.2096962196],[47211e-10,3.66100022149,5884.9268465832],[85831e-11,1.27079125277,161000.6857376741],[57056e-11,2.01374292245,83996.84731811189],[55736e-11,5.2415979917,71430.69561812909],[174844e-11,3.01193636733,18849.2275499742],[243181e-11,4.2734953079,11790.6290886588]],[[.00103018607,1.10748968172,6283.0758499914],[1721238e-11,1.06442300386,12566.1516999828]],[[4359385e-11,5.78455133808,6283.0758499914]]]],Mars:[[[[6.20347711581,0,0],[.18656368093,5.0503710027,3340.6124266998],[.01108216816,5.40099836344,6681.2248533996],[.00091798406,5.75478744667,10021.8372800994],[.00027744987,5.97049513147,3.523118349],[.00010610235,2.93958560338,2281.2304965106],[.00012315897,.84956094002,2810.9214616052],[8926784e-11,4.15697846427,.0172536522],[8715691e-11,6.11005153139,13362.4497067992],[6797556e-11,.36462229657,398.1490034082],[7774872e-11,3.33968761376,5621.8429232104],[3575078e-11,1.6618650571,2544.3144198834],[4161108e-11,.22814971327,2942.4634232916],[3075252e-11,.85696614132,191.4482661116],[2628117e-11,.64806124465,3337.0893083508],[2937546e-11,6.07893711402,.0673103028],[2389414e-11,5.03896442664,796.2980068164],[2579844e-11,.02996736156,3344.1355450488],[1528141e-11,1.14979301996,6151.533888305],[1798806e-11,.65634057445,529.6909650946],[1264357e-11,3.62275122593,5092.1519581158],[1286228e-11,3.06796065034,2146.1654164752],[1546404e-11,2.91579701718,1751.539531416],[1024902e-11,3.69334099279,8962.4553499102],[891566e-11,.18293837498,16703.062133499],[858759e-11,2.4009381194,2914.0142358238],[832715e-11,2.46418619474,3340.5951730476],[83272e-10,4.49495782139,3340.629680352],[712902e-11,3.66335473479,1059.3819301892],[748723e-11,3.82248614017,155.4203994342],[723861e-11,.67497311481,3738.761430108],[635548e-11,2.92182225127,8432.7643848156],[655162e-11,.48864064125,3127.3133312618],[550474e-11,3.81001042328,.9803210682],[55275e-10,4.47479317037,1748.016413067],[425966e-11,.55364317304,6283.0758499914],[415131e-11,.49662285038,213.299095438],[472167e-11,3.62547124025,1194.4470102246],[306551e-11,.38052848348,6684.7479717486],[312141e-11,.99853944405,6677.7017350506],[293198e-11,4.22131299634,20.7753954924],[302375e-11,4.48618007156,3532.0606928114],[274027e-11,.54222167059,3340.545116397],[281079e-11,5.88163521788,1349.8674096588],[231183e-11,1.28242156993,3870.3033917944],[283602e-11,5.7688543494,3149.1641605882],[236117e-11,5.75503217933,3333.498879699],[274033e-11,.13372524985,3340.6797370026],[299395e-11,2.78323740866,6254.6266625236]],[[3340.61242700512,0,0],[.01457554523,3.60433733236,3340.6124266998],[.00168414711,3.92318567804,6681.2248533996],[.00020622975,4.26108844583,10021.8372800994],[3452392e-11,4.7321039319,3.523118349],[2586332e-11,4.60670058555,13362.4497067992],[841535e-11,4.45864030426,2281.2304965106]],[[.00058152577,2.04961712429,3340.6124266998],[.00013459579,2.45738706163,6681.2248533996]]],[[[.03197134986,3.76832042431,3340.6124266998],[.00298033234,4.10616996305,6681.2248533996],[.00289104742,0,0],[.00031365539,4.4465105309,10021.8372800994],[34841e-9,4.7881254926,13362.4497067992]],[[.00217310991,6.04472194776,3340.6124266998],[.00020976948,3.14159265359,0],[.00012834709,1.60810667915,6681.2248533996]]],[[[1.53033488271,0,0],[.1418495316,3.47971283528,3340.6124266998],[.00660776362,3.81783443019,6681.2248533996],[.00046179117,4.15595316782,10021.8372800994],[8109733e-11,5.55958416318,2810.9214616052],[7485318e-11,1.77239078402,5621.8429232104],[5523191e-11,1.3643630377,2281.2304965106],[382516e-10,4.49407183687,13362.4497067992],[2306537e-11,.09081579001,2544.3144198834],[1999396e-11,5.36059617709,3337.0893083508],[2484394e-11,4.9254563992,2942.4634232916],[1960195e-11,4.74249437639,3344.1355450488],[1167119e-11,2.11260868341,5092.1519581158],[1102816e-11,5.00908403998,398.1490034082],[899066e-11,4.40791133207,529.6909650946],[992252e-11,5.83861961952,6151.533888305],[807354e-11,2.10217065501,1059.3819301892],[797915e-11,3.44839203899,796.2980068164],[740975e-11,1.49906336885,2146.1654164752]],[[.01107433345,2.03250524857,3340.6124266998],[.00103175887,2.37071847807,6681.2248533996],[128772e-9,0,0],[.0001081588,2.70888095665,10021.8372800994]],[[.00044242249,.47930604954,3340.6124266998],[8138042e-11,.86998389204,6681.2248533996]]]],Jupiter:[[[[.59954691494,0,0],[.09695898719,5.06191793158,529.6909650946],[.00573610142,1.44406205629,7.1135470008],[.00306389205,5.41734730184,1059.3819301892],[.00097178296,4.14264726552,632.7837393132],[.00072903078,3.64042916389,522.5774180938],[.00064263975,3.41145165351,103.0927742186],[.00039806064,2.29376740788,419.4846438752],[.00038857767,1.27231755835,316.3918696566],[.00027964629,1.7845459182,536.8045120954],[.0001358973,5.7748104079,1589.0728952838],[8246349e-11,3.5822792584,206.1855484372],[8768704e-11,3.63000308199,949.1756089698],[7368042e-11,5.0810119427,735.8765135318],[626315e-10,.02497628807,213.299095438],[6114062e-11,4.51319998626,1162.4747044078],[4905396e-11,1.32084470588,110.2063212194],[5305285e-11,1.30671216791,14.2270940016],[5305441e-11,4.18625634012,1052.2683831884],[4647248e-11,4.69958103684,3.9321532631],[3045023e-11,4.31676431084,426.598190876],[2609999e-11,1.56667394063,846.0828347512],[2028191e-11,1.06376530715,3.1813937377],[1764763e-11,2.14148655117,1066.49547719],[1722972e-11,3.88036268267,1265.5674786264],[1920945e-11,.97168196472,639.897286314],[1633223e-11,3.58201833555,515.463871093],[1431999e-11,4.29685556046,625.6701923124],[973272e-11,4.09764549134,95.9792272178]],[[529.69096508814,0,0],[.00489503243,4.2208293947,529.6909650946],[.00228917222,6.02646855621,7.1135470008],[.00030099479,4.54540782858,1059.3819301892],[.0002072092,5.45943156902,522.5774180938],[.00012103653,.16994816098,536.8045120954],[6067987e-11,4.42422292017,103.0927742186],[5433968e-11,3.98480737746,419.4846438752],[4237744e-11,5.89008707199,14.2270940016]],[[.00047233601,4.32148536482,7.1135470008],[.00030649436,2.929777887,529.6909650946],[.00014837605,3.14159265359,0]]],[[[.02268615702,3.55852606721,529.6909650946],[.00109971634,3.90809347197,1059.3819301892],[.00110090358,0,0],[8101428e-11,3.60509572885,522.5774180938],[6043996e-11,4.25883108339,1589.0728952838],[6437782e-11,.30627119215,536.8045120954]],[[.00078203446,1.52377859742,529.6909650946]]],[[[5.20887429326,0,0],[.25209327119,3.49108639871,529.6909650946],[.00610599976,3.84115365948,1059.3819301892],[.00282029458,2.57419881293,632.7837393132],[.00187647346,2.07590383214,522.5774180938],[.00086792905,.71001145545,419.4846438752],[.00072062974,.21465724607,536.8045120954],[.00065517248,5.9799588479,316.3918696566],[.00029134542,1.67759379655,103.0927742186],[.00030135335,2.16132003734,949.1756089698],[.00023453271,3.54023522184,735.8765135318],[.00022283743,4.19362594399,1589.0728952838],[.00023947298,.2745803748,7.1135470008],[.00013032614,2.96042965363,1162.4747044078],[970336e-10,1.90669633585,206.1855484372],[.00012749023,2.71550286592,1052.2683831884],[7057931e-11,2.18184839926,1265.5674786264],[6137703e-11,6.26418240033,846.0828347512],[2616976e-11,2.00994012876,1581.959348283]],[[.0127180152,2.64937512894,529.6909650946],[.00061661816,3.00076460387,1059.3819301892],[.00053443713,3.89717383175,522.5774180938],[.00031185171,4.88276958012,536.8045120954],[.00041390269,0,0]]]],Saturn:[[[[.87401354025,0,0],[.11107659762,3.96205090159,213.299095438],[.01414150957,4.58581516874,7.1135470008],[.00398379389,.52112032699,206.1855484372],[.00350769243,3.30329907896,426.598190876],[.00206816305,.24658372002,103.0927742186],[792713e-9,3.84007056878,220.4126424388],[.00023990355,4.66976924553,110.2063212194],[.00016573588,.43719228296,419.4846438752],[.00014906995,5.76903183869,316.3918696566],[.0001582029,.93809155235,632.7837393132],[.00014609559,1.56518472,3.9321532631],[.00013160301,4.44891291899,14.2270940016],[.00015053543,2.71669915667,639.897286314],[.00013005299,5.98119023644,11.0457002639],[.00010725067,3.12939523827,202.2533951741],[5863206e-11,.23656938524,529.6909650946],[5227757e-11,4.20783365759,3.1813937377],[6126317e-11,1.76328667907,277.0349937414],[5019687e-11,3.17787728405,433.7117378768],[459255e-10,.61977744975,199.0720014364],[4005867e-11,2.24479718502,63.7358983034],[2953796e-11,.98280366998,95.9792272178],[387367e-10,3.22283226966,138.5174968707],[2461186e-11,2.03163875071,735.8765135318],[3269484e-11,.77492638211,949.1756089698],[1758145e-11,3.2658010994,522.5774180938],[1640172e-11,5.5050445305,846.0828347512],[1391327e-11,4.02333150505,323.5054166574],[1580648e-11,4.37265307169,309.2783226558],[1123498e-11,2.83726798446,415.5524906121],[1017275e-11,3.71700135395,227.5261894396],[848642e-11,3.1915017083,209.3669421749]],[[213.2990952169,0,0],[.01297370862,1.82834923978,213.299095438],[.00564345393,2.88499717272,7.1135470008],[.00093734369,1.06311793502,426.598190876],[.00107674962,2.27769131009,206.1855484372],[.00040244455,2.04108104671,220.4126424388],[.00019941774,1.2795439047,103.0927742186],[.00010511678,2.7488034213,14.2270940016],[6416106e-11,.38238295041,639.897286314],[4848994e-11,2.43037610229,419.4846438752],[4056892e-11,2.92133209468,110.2063212194],[3768635e-11,3.6496533078,3.9321532631]],[[.0011644133,1.17988132879,7.1135470008],[.00091841837,.0732519584,213.299095438],[.00036661728,0,0],[.00015274496,4.06493179167,206.1855484372]]],[[[.04330678039,3.60284428399,213.299095438],[.00240348302,2.85238489373,426.598190876],[.00084745939,0,0],[.00030863357,3.48441504555,220.4126424388],[.00034116062,.57297307557,206.1855484372],[.0001473407,2.11846596715,639.897286314],[9916667e-11,5.79003188904,419.4846438752],[6993564e-11,4.7360468972,7.1135470008],[4807588e-11,5.43305312061,316.3918696566]],[[.00198927992,4.93901017903,213.299095438],[.00036947916,3.14159265359,0],[.00017966989,.5197943111,426.598190876]]],[[[9.55758135486,0,0],[.52921382865,2.39226219573,213.299095438],[.01873679867,5.2354960466,206.1855484372],[.01464663929,1.64763042902,426.598190876],[.00821891141,5.93520042303,316.3918696566],[.00547506923,5.0153261898,103.0927742186],[.0037168465,2.27114821115,220.4126424388],[.00361778765,3.13904301847,7.1135470008],[.00140617506,5.70406606781,632.7837393132],[.00108974848,3.29313390175,110.2063212194],[.00069006962,5.94099540992,419.4846438752],[.00061053367,.94037691801,639.897286314],[.00048913294,1.55733638681,202.2533951741],[.00034143772,.19519102597,277.0349937414],[.00032401773,5.47084567016,949.1756089698],[.00020936596,.46349251129,735.8765135318],[9796004e-11,5.20477537945,1265.5674786264],[.00011993338,5.98050967385,846.0828347512],[208393e-9,1.52102476129,433.7117378768],[.00015298404,3.0594381494,529.6909650946],[6465823e-11,.17732249942,1052.2683831884],[.00011380257,1.7310542704,522.5774180938],[3419618e-11,4.94550542171,1581.959348283]],[[.0618298134,.2584351148,213.299095438],[.00506577242,.71114625261,206.1855484372],[.00341394029,5.79635741658,426.598190876],[.00188491195,.47215589652,220.4126424388],[.00186261486,3.14159265359,0],[.00143891146,1.40744822888,7.1135470008]],[[.00436902572,4.78671677509,213.299095438]]]],Uranus:[[[[5.48129294297,0,0],[.09260408234,.89106421507,74.7815985673],[.01504247898,3.6271926092,1.4844727083],[.00365981674,1.89962179044,73.297125859],[.00272328168,3.35823706307,149.5631971346],[.00070328461,5.39254450063,63.7358983034],[.00068892678,6.09292483287,76.2660712756],[.00061998615,2.26952066061,2.9689454166],[.00061950719,2.85098872691,11.0457002639],[.0002646877,3.14152083966,71.8126531507],[.00025710476,6.11379840493,454.9093665273],[.0002107885,4.36059339067,148.0787244263],[.00017818647,1.74436930289,36.6485629295],[.00014613507,4.73732166022,3.9321532631],[.00011162509,5.8268179635,224.3447957019],[.0001099791,.48865004018,138.5174968707],[9527478e-11,2.95516862826,35.1640902212],[7545601e-11,5.236265824,109.9456887885],[4220241e-11,3.23328220918,70.8494453042],[40519e-9,2.277550173,151.0476698429],[3354596e-11,1.0654900738,4.4534181249],[2926718e-11,4.62903718891,9.5612275556],[349034e-10,5.48306144511,146.594251718],[3144069e-11,4.75199570434,77.7505439839],[2922333e-11,5.35235361027,85.8272988312],[2272788e-11,4.36600400036,70.3281804424],[2051219e-11,1.51773566586,.1118745846],[2148602e-11,.60745949945,38.1330356378],[1991643e-11,4.92437588682,277.0349937414],[1376226e-11,2.04283539351,65.2203710117],[1666902e-11,3.62744066769,380.12776796],[1284107e-11,3.11347961505,202.2533951741],[1150429e-11,.93343589092,3.1813937377],[1533221e-11,2.58594681212,52.6901980395],[1281604e-11,.54271272721,222.8603229936],[1372139e-11,4.19641530878,111.4301614968],[1221029e-11,.1990065003,108.4612160802],[946181e-11,1.19253165736,127.4717966068],[1150989e-11,4.17898916639,33.6796175129]],[[74.7815986091,0,0],[.00154332863,5.24158770553,74.7815985673],[.00024456474,1.71260334156,1.4844727083],[9258442e-11,.4282973235,11.0457002639],[8265977e-11,1.50218091379,63.7358983034],[915016e-10,1.41213765216,149.5631971346]]],[[[.01346277648,2.61877810547,74.7815985673],[623414e-9,5.08111189648,149.5631971346],[.00061601196,3.14159265359,0],[9963722e-11,1.61603805646,76.2660712756],[992616e-10,.57630380333,73.297125859]],[[.00034101978,.01321929936,74.7815985673]]],[[[19.21264847206,0,0],[.88784984413,5.60377527014,74.7815985673],[.03440836062,.32836099706,73.297125859],[.0205565386,1.7829515933,149.5631971346],[.0064932241,4.52247285911,76.2660712756],[.00602247865,3.86003823674,63.7358983034],[.00496404167,1.40139935333,454.9093665273],[.00338525369,1.58002770318,138.5174968707],[.00243509114,1.57086606044,71.8126531507],[.00190522303,1.99809394714,1.4844727083],[.00161858838,2.79137786799,148.0787244263],[.00143706183,1.38368544947,11.0457002639],[.00093192405,.17437220467,36.6485629295],[.00071424548,4.24509236074,224.3447957019],[.00089806014,3.66105364565,109.9456887885],[.00039009723,1.66971401684,70.8494453042],[.00046677296,1.39976401694,35.1640902212],[.00039025624,3.36234773834,277.0349937414],[.00036755274,3.88649278513,146.594251718],[.00030348723,.70100838798,151.0476698429],[.00029156413,3.180563367,77.7505439839],[.00022637073,.72518687029,529.6909650946],[.00011959076,1.7504339214,984.6003316219],[.00025620756,5.25656086672,380.12776796]],[[.01479896629,3.67205697578,74.7815985673]]]],Neptune:[[[[5.31188633046,0,0],[.0179847553,2.9010127389,38.1330356378],[.01019727652,.48580922867,1.4844727083],[.00124531845,4.83008090676,36.6485629295],[.00042064466,5.41054993053,2.9689454166],[.00037714584,6.09221808686,35.1640902212],[.00033784738,1.24488874087,76.2660712756],[.00016482741,7727998e-11,491.5579294568],[9198584e-11,4.93747051954,39.6175083461],[899425e-10,.27462171806,175.1660598002]],[[38.13303563957,0,0],[.00016604172,4.86323329249,1.4844727083],[.00015744045,2.27887427527,38.1330356378]]],[[[.03088622933,1.44104372644,38.1330356378],[.00027780087,5.91271884599,76.2660712756],[.00027623609,0,0],[.00015355489,2.52123799551,36.6485629295],[.00015448133,3.50877079215,39.6175083461]]],[[[30.07013205828,0,0],[.27062259632,1.32999459377,38.1330356378],[.01691764014,3.25186135653,36.6485629295],[.00807830553,5.18592878704,1.4844727083],[.0053776051,4.52113935896,35.1640902212],[.00495725141,1.5710564165,491.5579294568],[.00274571975,1.84552258866,175.1660598002],[.0001201232,1.92059384991,1021.2488945514],[.00121801746,5.79754470298,76.2660712756],[.00100896068,.3770272493,73.297125859],[.00135134092,3.37220609835,39.6175083461],[7571796e-11,1.07149207335,388.4651552382]]]]};function Jb(r){var t,e,i,n,s,a,o;const c=2e3+(r-14)/Hb;return c<-500?(t=(c-1820)/100,-20+32*t*t):c<500?(t=c/100,e=t*t,i=t*e,n=e*e,s=e*i,a=i*i,10583.6-1014.41*t+33.78311*e-5.952053*i-.1798452*n+.022174192*s+.0090316521*a):c<1600?(t=(c-1e3)/100,e=t*t,i=t*e,n=e*e,s=e*i,a=i*i,1574.2-556.01*t+71.23472*e+.319781*i-.8503463*n-.005050998*s+.0083572073*a):c<1700?(t=c-1600,e=t*t,i=t*e,120-.9808*t-.01532*e+i/7129):c<1800?(t=c-1700,e=t*t,i=t*e,n=e*e,8.83+.1603*t-.0059285*e+13336e-8*i-n/1174e3):c<1860?(t=c-1800,e=t*t,i=t*e,n=e*e,s=e*i,a=i*i,o=i*n,13.72-.332447*t+.0068612*e+.0041116*i-37436e-8*n+121272e-10*s-1699e-10*a+875e-12*o):c<1900?(t=c-1860,e=t*t,i=t*e,n=e*e,s=e*i,7.62+.5737*t-.251754*e+.01680668*i-.0004473624*n+s/233174):c<1920?(t=c-1900,e=t*t,i=t*e,n=e*e,-2.79+1.494119*t-.0598939*e+.0061966*i-197e-6*n):c<1941?(t=c-1920,e=t*t,i=t*e,21.2+.84493*t-.0761*e+.0020936*i):c<1961?(t=c-1950,e=t*t,i=t*e,29.07+.407*t-e/233+i/2547):c<1986?(t=c-1975,e=t*t,i=t*e,45.45+1.067*t-e/260-i/718):c<2005?(t=c-2e3,e=t*t,i=t*e,n=e*e,s=e*i,63.86+.3345*t-.060374*e+.0017275*i+651814e-9*n+2373599e-11*s):c<2050?(t=c-2e3,62.92+.32217*t+.005589*t*t):c<2150?(t=(c-1820)/100,-20+32*t*t-.5628*(2150-c)):(t=(c-1820)/100,-20+32*t*t)}let jb=Jb;function Kp(r){return r+jb(r)/86400}class Rr{constructor(t){if(t instanceof Rr){this.date=t.date,this.ut=t.ut,this.tt=t.tt;return}const e=1e3*3600*24;if(t instanceof Date&&Number.isFinite(t.getTime())){this.date=t,this.ut=(t.getTime()-qp.getTime())/e,this.tt=Kp(this.ut);return}if(Number.isFinite(t)){this.date=new Date(qp.getTime()+t*e),this.ut=t,this.tt=Kp(this.ut);return}throw"Argument must be a Date object, an AstroTime object, or a numeric UTC Julian date."}static FromTerrestrialTime(t){let e=new Rr(t);for(;;){const i=t-e.tt;if(Math.abs(i)<1e-12)return e;e=e.AddDays(i)}}toString(){return this.date.toISOString()}AddDays(t){return new Rr(this.ut+t)}}function $e(r){return r instanceof Rr?r:new Rr(r)}function Qb(r){function t(d){return d%Gb*gr}const e=r.tt/36525,i=t(128710479305e-5+e*1295965810481e-4),n=t(335779.526232+e*17395272628478e-4),s=t(107226070369e-5+e*1602961601209e-3),a=t(450160.398036-e*69628905431e-4);let o=Math.sin(a),c=Math.cos(a),l=(-172064161-174666*e)*o+33386*c,h=(92052331+9086*e)*c+15377*o,u=2*(n-s+a);return o=Math.sin(u),c=Math.cos(u),l+=(-13170906-1675*e)*o-13696*c,h+=(5730336-3015*e)*c-4587*o,u=2*(n+a),o=Math.sin(u),c=Math.cos(u),l+=(-2276413-234*e)*o+2796*c,h+=(978459-485*e)*c+1374*o,u=2*a,o=Math.sin(u),c=Math.cos(u),l+=(2074554+207*e)*o-698*c,h+=(-897492+470*e)*c-291*o,o=Math.sin(i),c=Math.cos(i),l+=(1475877-3633*e)*o+11817*c,h+=(73871-184*e)*c-1924*o,{dpsi:-135e-6+l*1e-7,deps:388e-6+h*1e-7}}function v1(r){var t=r.tt/36525,e=((((-434e-10*t-576e-9)*t+.0020034)*t-1831e-7)*t-46.836769)*t+84381.406;return e/3600}var Uc;function Zo(r){if(!Uc||Math.abs(Uc.tt-r.tt)>1e-6){const t=Qb(r),e=v1(r),i=e+t.deps/3600;Uc={tt:r.tt,dpsi:t.dpsi,deps:t.deps,ee:t.dpsi*Math.cos(e*Ee)/15,mobl:e,tobl:i}}return Uc}function tw(r,t){const e=r*Ee,i=Math.cos(e),n=Math.sin(e);return[t[0],t[1]*i-t[2]*n,t[1]*n+t[2]*i]}function ew(r,t){return tw(v1(r),t)}function iw(r){const t=r.tt/36525;function e(Ct,_t){const kt=[];let zt;for(zt=0;zt<=_t-Ct;++zt)kt.push(0);return{min:Ct,array:kt}}function i(Ct,_t,kt,zt){const Bt=[];for(let Me=0;Me<=_t-Ct;++Me)Bt.push(e(kt,zt));return{min:Ct,array:Bt}}function n(Ct,_t,kt){const zt=Ct.array[_t-Ct.min];return zt.array[kt-zt.min]}function s(Ct,_t,kt,zt){const Bt=Ct.array[_t-Ct.min];Bt.array[kt-Bt.min]=zt}let a,o,c,l,h,u,d,f,p,v,m,g,S,y,M,b,w,T,x,A,C,I,P,V=i(-6,6,1,4),X=i(-6,6,1,4);function L(Ct,_t){return n(V,Ct,_t)}function B(Ct,_t){return n(X,Ct,_t)}function k(Ct,_t,kt){return s(V,Ct,_t,kt)}function $(Ct,_t,kt){return s(X,Ct,_t,kt)}function tt(Ct,_t,kt,zt,Bt){Bt(Ct*kt-_t*zt,_t*kt+Ct*zt)}function J(Ct){return Math.sin(ms*Ct)}d=t*t,p=0,P=0,m=0,g=3422.7;var it=J(.19833+.05611*t),rt=J(.27869+.04508*t),Vt=J(.16827-.36903*t),jt=J(.34734-5.37261*t),qt=J(.10498-5.37899*t),q=J(.42681-.41855*t),at=J(.14943-5.37511*t);for(T=.84*it+.31*rt+14.27*Vt+7.26*jt+.28*qt+.24*q,x=2.94*it+.31*rt+14.27*Vt+9.34*jt+1.12*qt+.83*q,A=-6.4*it-1.89*q,C=.21*it+.31*rt+14.27*Vt-88.7*jt-15.3*qt+.24*q-1.86*at,I=T-A,f=-3332e-9*J(.59734-5.37261*t)-539e-9*J(.35498-5.37899*t)-64e-9*J(.39943-5.37511*t),S=ms*lr(.60643382+1336.85522467*t-313e-8*d)+T/Hs,y=ms*lr(.37489701+1325.55240982*t+2565e-8*d)+x/Hs,M=ms*lr(.99312619+99.99735956*t-44e-8*d)+A/Hs,b=ms*lr(.25909118+1342.2278298*t-892e-8*d)+C/Hs,w=ms*lr(.82736186+1236.85308708*t-397e-8*d)+I/Hs,h=1;h<=4;++h){switch(h){case 1:c=y,o=4,l=1.000002208;break;case 2:c=M,o=3,l=.997504612-.002495388*t;break;case 3:c=b,o=4,l=1.000002708+139.978*f;break;case 4:c=w,o=6,l=1;break;default:throw`Internal error: I = ${h}`}for(k(0,h,1),k(1,h,Math.cos(c)*l),$(0,h,0),$(1,h,Math.sin(c)*l),u=2;u<=o;++u)tt(L(u-1,h),B(u-1,h),L(1,h),B(1,h),(Ct,_t)=>(k(u,h,Ct),$(u,h,_t)));for(u=1;u<=o;++u)k(-u,h,L(u,h)),$(-u,h,-B(u,h))}function nt(Ct,_t,kt,zt){for(var Bt={x:1,y:0},Me=[0,Ct,_t,kt,zt],xe=1;xe<=4;++xe)Me[xe]!==0&&tt(Bt.x,Bt.y,L(Me[xe],xe),B(Me[xe],xe),(Ke,He)=>(Bt.x=Ke,Bt.y=He));return Bt}function z(Ct,_t,kt,zt,Bt,Me,xe,Ke){var He=nt(Bt,Me,xe,Ke);p+=Ct*He.y,P+=_t*He.y,m+=kt*He.x,g+=zt*He.x}z(13.902,14.06,-.001,.2607,0,0,0,4),z(.403,-4.01,.394,.0023,0,0,0,3),z(2369.912,2373.36,.601,28.2333,0,0,0,2),z(-125.154,-112.79,-.725,-.9781,0,0,0,1),z(1.979,6.98,-.445,.0433,1,0,0,4),z(191.953,192.72,.029,3.0861,1,0,0,2),z(-8.466,-13.51,.455,-.1093,1,0,0,1),z(22639.5,22609.07,.079,186.5398,1,0,0,0),z(18.609,3.59,-.094,.0118,1,0,0,-1),z(-4586.465,-4578.13,-.077,34.3117,1,0,0,-2),z(3.215,5.44,.192,-.0386,1,0,0,-3),z(-38.428,-38.64,.001,.6008,1,0,0,-4),z(-.393,-1.43,-.092,.0086,1,0,0,-6),z(-.289,-1.59,.123,-.0053,0,1,0,4),z(-24.42,-25.1,.04,-.3,0,1,0,2),z(18.023,17.93,.007,.1494,0,1,0,1),z(-668.146,-126.98,-1.302,-.3997,0,1,0,0),z(.56,.32,-.001,-.0037,0,1,0,-1),z(-165.145,-165.06,.054,1.9178,0,1,0,-2),z(-1.877,-6.46,-.416,.0339,0,1,0,-4),z(.213,1.02,-.074,.0054,2,0,0,4),z(14.387,14.78,-.017,.2833,2,0,0,2),z(-.586,-1.2,.054,-.01,2,0,0,1),z(769.016,767.96,.107,10.1657,2,0,0,0),z(1.75,2.01,-.018,.0155,2,0,0,-1),z(-211.656,-152.53,5.679,-.3039,2,0,0,-2),z(1.225,.91,-.03,-.0088,2,0,0,-3),z(-30.773,-34.07,-.308,.3722,2,0,0,-4),z(-.57,-1.4,-.074,.0109,2,0,0,-6),z(-2.921,-11.75,.787,-.0484,1,1,0,2),z(1.267,1.52,-.022,.0164,1,1,0,1),z(-109.673,-115.18,.461,-.949,1,1,0,0),z(-205.962,-182.36,2.056,1.4437,1,1,0,-2),z(.233,.36,.012,-.0025,1,1,0,-3),z(-4.391,-9.66,-.471,.0673,1,1,0,-4),z(.283,1.53,-.111,.006,1,-1,0,4),z(14.577,31.7,-1.54,.2302,1,-1,0,2),z(147.687,138.76,.679,1.1528,1,-1,0,0),z(-1.089,.55,.021,0,1,-1,0,-1),z(28.475,23.59,-.443,-.2257,1,-1,0,-2),z(-.276,-.38,-.006,-.0036,1,-1,0,-3),z(.636,2.27,.146,-.0102,1,-1,0,-4),z(-.189,-1.68,.131,-.0028,0,2,0,2),z(-7.486,-.66,-.037,-.0086,0,2,0,0),z(-8.096,-16.35,-.74,.0918,0,2,0,-2),z(-5.741,-.04,0,-9e-4,0,0,2,2),z(.255,0,0,0,0,0,2,1),z(-411.608,-.2,0,-.0124,0,0,2,0),z(.584,.84,0,.0071,0,0,2,-1),z(-55.173,-52.14,0,-.1052,0,0,2,-2),z(.254,.25,0,-.0017,0,0,2,-3),z(.025,-1.67,0,.0031,0,0,2,-4),z(1.06,2.96,-.166,.0243,3,0,0,2),z(36.124,50.64,-1.3,.6215,3,0,0,0),z(-13.193,-16.4,.258,-.1187,3,0,0,-2),z(-1.187,-.74,.042,.0074,3,0,0,-4),z(-.293,-.31,-.002,.0046,3,0,0,-6),z(-.29,-1.45,.116,-.0051,2,1,0,2),z(-7.649,-10.56,.259,-.1038,2,1,0,0),z(-8.627,-7.59,.078,-.0192,2,1,0,-2),z(-2.74,-2.54,.022,.0324,2,1,0,-4),z(1.181,3.32,-.212,.0213,2,-1,0,2),z(9.703,11.67,-.151,.1268,2,-1,0,0),z(-.352,-.37,.001,-.0028,2,-1,0,-1),z(-2.494,-1.17,-.003,-.0017,2,-1,0,-2),z(.36,.2,-.012,-.0043,2,-1,0,-4),z(-1.167,-1.25,.008,-.0106,1,2,0,0),z(-7.412,-6.12,.117,.0484,1,2,0,-2),z(-.311,-.65,-.032,.0044,1,2,0,-4),z(.757,1.82,-.105,.0112,1,-2,0,2),z(2.58,2.32,.027,.0196,1,-2,0,0),z(2.533,2.4,-.014,-.0212,1,-2,0,-2),z(-.344,-.57,-.025,.0036,0,3,0,-2),z(-.992,-.02,0,0,1,0,2,2),z(-45.099,-.02,0,-.001,1,0,2,0),z(-.179,-9.52,0,-.0833,1,0,2,-2),z(-.301,-.33,0,.0014,1,0,2,-4),z(-6.382,-3.37,0,-.0481,1,0,-2,2),z(39.528,85.13,0,-.7136,1,0,-2,0),z(9.366,.71,0,-.0112,1,0,-2,-2),z(.202,.02,0,0,1,0,-2,-4),z(.415,.1,0,.0013,0,1,2,0),z(-2.152,-2.26,0,-.0066,0,1,2,-2),z(-1.44,-1.3,0,.0014,0,1,-2,2),z(.384,-.04,0,0,0,1,-2,-2),z(1.938,3.6,-.145,.0401,4,0,0,0),z(-.952,-1.58,.052,-.013,4,0,0,-2),z(-.551,-.94,.032,-.0097,3,1,0,0),z(-.482,-.57,.005,-.0045,3,1,0,-2),z(.681,.96,-.026,.0115,3,-1,0,0),z(-.297,-.27,.002,-9e-4,2,2,0,-2),z(.254,.21,-.003,0,2,-2,0,-2),z(-.25,-.22,.004,.0014,1,3,0,-2),z(-3.996,0,0,4e-4,2,0,2,0),z(.557,-.75,0,-.009,2,0,2,-2),z(-.459,-.38,0,-.0053,2,0,-2,2),z(-1.298,.74,0,4e-4,2,0,-2,0),z(.538,1.14,0,-.0141,2,0,-2,-2),z(.263,.02,0,0,1,1,2,0),z(.426,.07,0,-6e-4,1,1,-2,-2),z(-.304,.03,0,3e-4,1,-1,2,0),z(-.372,-.19,0,-.0027,1,-1,-2,2),z(.418,0,0,0,0,0,4,0),z(-.33,-.04,0,0,3,0,2,0);function Tt(Ct,_t,kt,zt,Bt){return Ct*nt(_t,kt,zt,Bt).y}v=0,v+=Tt(-526.069,0,0,1,-2),v+=Tt(-3.352,0,0,1,-4),v+=Tt(44.297,1,0,1,-2),v+=Tt(-6,1,0,1,-4),v+=Tt(20.599,-1,0,1,0),v+=Tt(-30.598,-1,0,1,-2),v+=Tt(-24.649,-2,0,1,0),v+=Tt(-2,-2,0,1,-2),v+=Tt(-22.571,0,1,1,-2),v+=Tt(10.985,0,-1,1,-2),p+=.82*J(.7736-62.5512*t)+.31*J(.0466-125.1025*t)+.35*J(.5785-25.1042*t)+.66*J(.4591+1335.8075*t)+.64*J(.313-91.568*t)+1.14*J(.148+1331.2898*t)+.21*J(.5918+1056.5859*t)+.44*J(.5784+1322.8595*t)+.24*J(.2275-5.7374*t)+.28*J(.2965+2.6929*t)+.33*J(.3132+6.3368*t),a=b+P/Hs;let Nt=(1.000002708+139.978*f)*(18518.511+1.189+m)*Math.sin(a)-6.24*Math.sin(3*a)+v;return{geo_eclip_lon:ms*lr((S+p/Hs)/ms),geo_eclip_lat:Math.PI/(180*3600)*Nt,distance_au:Hs*Yb/(.999953253*g)}}function M1(r,t){return[r.rot[0][0]*t[0]+r.rot[1][0]*t[1]+r.rot[2][0]*t[2],r.rot[0][1]*t[0]+r.rot[1][1]*t[1]+r.rot[2][1]*t[2],r.rot[0][2]*t[0]+r.rot[1][2]*t[1]+r.rot[2][2]*t[2]]}function Pl(r,t,e){const i=C0(t,e);return M1(i,r)}function C0(r,t){const e=r.tt/36525;let i=84381.406,n=((((-951e-10*e+132851e-9)*e-.00114045)*e-1.0790069)*e+5038.481507)*e,s=((((3337e-10*e-467e-9)*e-.00772503)*e+.0512623)*e-.025754)*e+i,a=((((-56e-9*e+170663e-9)*e-.00121197)*e-2.3814292)*e+10.556403)*e;i*=gr,n*=gr,s*=gr,a*=gr;const o=Math.sin(i),c=Math.cos(i),l=Math.sin(-n),h=Math.cos(-n),u=Math.sin(-s),d=Math.cos(-s),f=Math.sin(a),p=Math.cos(a),v=p*h-l*f*d,m=p*l*c+f*d*h*c-o*f*u,g=p*l*o+f*d*h*o+c*f*u,S=-f*h-l*p*d,y=-f*l*c+p*d*h*c-o*p*u,M=-f*l*o+p*d*h*o+c*p*u,b=l*u,w=-u*h*c-o*d,T=-u*h*o+d*c;if(t===Ai.Into2000)return new aa([[v,m,g],[S,y,M],[b,w,T]]);if(t===Ai.From2000)return new aa([[v,S,b],[m,y,w],[g,M,T]]);throw"Invalid precess direction"}function nw(r){const t=.779057273264+.00273781191135448*r.ut,e=r.ut%1;let i=360*((t+e)%1);return i<0&&(i+=360),i}let kc;function Kl(r){if(!kc||kc.tt!==r.tt){const t=r.tt/36525;let e=15*Zo(r).ee;const i=nw(r);let s=((e+.014506+((((-368e-10*t-29956e-9)*t-44e-8)*t+1.3915817)*t+4612.156534)*t)/3600+i)%360/15;s<0&&(s+=24),kc={tt:r.tt,st:s}}return kc.st}function sw(r){const t=$e(r);return Kl(t)}function x1(r,t){const e=r.latitude*Ee,i=Math.sin(e),n=Math.cos(e),s=1/Math.hypot(n,Td*i),a=Xb*s,o=r.height/1e3,c=Rd*s+o,l=Rd*a+o,h=(15*t+r.longitude)*Ee,u=Math.sin(h),d=Math.cos(h);return{pos:[c*n*d/Sa,c*n*u/Sa,l*i/Sa],vel:[-$p*c*n*u*86400/Sa,$p*c*n*d*86400/Sa,0]}}function Ld(r,t,e){const i=P0(t,e);return M1(i,r)}function P0(r,t){const e=Zo(r),i=e.mobl*Ee,n=e.tobl*Ee,s=e.dpsi*gr,a=Math.cos(i),o=Math.sin(i),c=Math.cos(n),l=Math.sin(n),h=Math.cos(s),u=Math.sin(s),d=h,f=-u*a,p=-u*o,v=u*c,m=h*a*c+o*l,g=h*o*c-a*l,S=u*l,y=h*a*l-o*c,M=h*o*l+a*c;if(t===Ai.From2000)return new aa([[d,v,S],[f,m,y],[p,g,M]]);if(t===Ai.Into2000)return new aa([[d,f,p],[v,m,g],[S,y,M]]);throw"Invalid precess direction"}function L0(r,t,e){return e===Ai.Into2000?Pl(Ld(r,t,e),t,e):Ld(Pl(r,t,e),t,e)}function aw(r,t){const e=Kl(r),i=x1(t,e).pos;return L0(i,r,Ai.Into2000)}class Fe{constructor(t,e,i,n){this.x=t,this.y=e,this.z=i,this.t=n}Length(){return Math.hypot(this.x,this.y,this.z)}}class Qs{constructor(t,e,i,n,s,a,o){this.x=t,this.y=e,this.z=i,this.vx=n,this.vy=s,this.vz=a,this.t=o}}class Zl{constructor(t,e,i){this.lat=Si(t),this.lon=Si(e),this.dist=Si(i)}}class Od{constructor(t,e,i,n){this.ra=Si(t),this.dec=Si(e),this.dist=Si(i),this.vec=n}}class aa{constructor(t){this.rot=t}}class rw{constructor(t,e,i,n){this.azimuth=Si(t),this.altitude=Si(e),this.ra=Si(i),this.dec=Si(n)}}class ow{constructor(t,e,i){this.vec=t,this.elat=Si(e),this.elon=Si(i)}}function y1(r,t){return new Fe(r[0],r[1],r[2],t)}function cw(r,t){const e=y1(r,t),i=e.x*e.x+e.y*e.y,n=Math.sqrt(i+e.z*e.z);if(i===0){if(e.z===0)throw"Indeterminate sky coordinates";return new Od(0,e.z<0?-90:90,n,e)}let s=p1*Math.atan2(e.y,e.x);s<0&&(s+=24);const a=os*Math.atan2(r[2],Math.sqrt(i));return new Od(s,a,n,e)}function Yh(r,t){const e=r*Ee,i=Math.cos(e),n=Math.sin(e);return[i*t[0]+n*t[1],i*t[1]-n*t[0],t[2]]}function _1(r,t,e,i,n){let s=$e(r);O0(t),Si(e),Si(i);const a=Math.sin(t.latitude*Ee),o=Math.cos(t.latitude*Ee),c=Math.sin(t.longitude*Ee),l=Math.cos(t.longitude*Ee),h=Math.sin(i*Ee),u=Math.cos(i*Ee),d=Math.sin(e*Yp),f=Math.cos(e*Yp);let p=[o*l,o*c,a],v=[-a*l,-a*c,o],m=[c,-l,0];const g=-15*Kl(s);let S=Yh(g,p),y=Yh(g,v),M=Yh(g,m),b=[u*f,u*d,h];const w=b[0]*S[0]+b[1]*S[1]+b[2]*S[2],T=b[0]*y[0]+b[1]*y[1]+b[2]*y[2],x=b[0]*M[0]+b[1]*M[1]+b[2]*M[2];let A=Math.hypot(T,x),C;A>0?(C=-os*Math.atan2(x,T),C<0&&(C+=360)):C=0;let I=os*Math.atan2(A,w),P=e,V=i;if(n){let X=I,L=I1(n,90-I);if(I-=L,L>0&&I>3e-4){const B=Math.sin(I*Ee),k=Math.cos(I*Ee),$=Math.sin(X*Ee),tt=Math.cos(X*Ee),J=[];for(let it=0;it<3;++it)J.push((b[it]-tt*S[it])/$*B+S[it]*k);A=Math.hypot(J[0],J[1]),A>0?(P=p1*Math.atan2(J[1],J[0]),P<0&&(P+=24)):P=0,V=os*Math.atan2(J[2],A)}}return new rw(C,90-I,P,V)}function O0(r){if(!(r instanceof N0))throw`Not an instance of the Observer class: ${r}`;if(Si(r.latitude),Si(r.longitude),Si(r.height),r.latitude<-90||r.latitude>90)throw`Latitude ${r.latitude} is out of range. Must be -90..+90.`;return r}class N0{constructor(t,e,i){this.latitude=t,this.longitude=e,this.height=i,O0(this)}}function lw(r){const t=$e(r).AddDays(-1/R0),e=Ir(ss.Earth,t),i=[-e.x,-e.y,-e.z],[n,s,a]=L0(i,t,Ai.From2000),o=Ee*Zo(t).tobl,c=Math.cos(o),l=Math.sin(o),h=new Fe(n,s,a,t);return S1(h,c,l)}function hw(r,t,e,i,n){O0(e),Cl(i),Cl(n);const s=$e(t),a=aw(s,e),o=Wd(r,s,n),c=[o.x-a[0],o.y-a[1],o.z-a[2]],l=L0(c,s,Ai.From2000);return cw(l,s)}function uw(r,t,e){const i=$e(r),n=Kl(i);let s=x1(t,n).pos;return y1(s,i)}function S1(r,t,e){const i=r.x,n=r.y*t+r.z*e,s=-r.y*e+r.z*t,a=Math.hypot(i,n);let o=0;a>0&&(o=os*Math.atan2(n,i),o<0&&(o+=360));let c=os*Math.atan2(s,a),l=new Fe(i,n,s,r.t);return new ow(l,c,o)}function Nd(r){const t=Zo(r.t),e=[r.x,r.y,r.z],i=Pl(e,r.t,Ai.From2000),[n,s,a]=Ld(i,r.t,Ai.From2000),o=new Fe(n,s,a,r.t),c=t.tobl*Ee;return S1(o,Math.cos(c),Math.sin(c))}function Ur(r){const t=$e(r),e=iw(t),i=e.distance_au*Math.cos(e.geo_eclip_lat),n=[i*Math.cos(e.geo_eclip_lon),i*Math.sin(e.geo_eclip_lon),e.distance_au*Math.sin(e.geo_eclip_lat)],s=ew(t,n),a=Pl(s,t,Ai.Into2000);return new Fe(a[0],a[1],a[2],t)}function b1(r){const t=$e(r),e=1e-5,i=t.AddDays(-e),n=t.AddDays(+e),s=Ur(i),a=Ur(n);return new Qs((s.x+a.x)/2,(s.y+a.y)/2,(s.z+a.z)/2,(a.x-s.x)/(2*e),(a.y-s.y)/(2*e),(a.z-s.z)/(2*e),t)}function dw(r){const t=$e(r),e=b1(t),i=1+g1;return new Qs(e.x/i,e.y/i,e.z/i,e.vx/i,e.vy/i,e.vz/i,t)}function Dr(r,t,e){let i=1,n=0;for(let s of r){let a=0;for(let[c,l,h]of s)a+=c*Math.cos(l+t*h);let o=i*a;e&&(o%=ms),n+=o,i*=t}return n}function qh(r,t){let e=1,i=0,n=0,s=0;for(let a of r){let o=0,c=0;for(let[l,h,u]of a){let d=h+t*u;o+=l*u*Math.sin(d),s>0&&(c+=l*Math.cos(d))}n+=s*i*c-e*o,i=e,e*=t,++s}return n}const xo=365250,Fd=0,Ud=1,kd=2;function zd(r){return new Li(r[0]+44036e-11*r[1]-190919e-12*r[2],-479966e-12*r[0]+.917482137087*r[1]-.397776982902*r[2],.397776982902*r[1]+.917482137087*r[2])}function w1(r,t,e){const i=e*Math.cos(t),n=Math.cos(r),s=Math.sin(r);return[i*n,i*s,e*Math.sin(t)]}function Ir(r,t){const e=t.tt/xo,i=Dr(r[Fd],e,!0),n=Dr(r[Ud],e,!1),s=Dr(r[kd],e,!1),a=w1(i,n,s);return zd(a).ToAstroVector(t)}function Bd(r,t){const e=t/xo,i=Dr(r[Fd],e,!0),n=Dr(r[Ud],e,!1),s=Dr(r[kd],e,!1),a=qh(r[Fd],e),o=qh(r[Ud],e),c=qh(r[kd],e),l=Math.cos(i),h=Math.sin(i),u=Math.cos(n),d=Math.sin(n),f=+(c*u*l)-s*d*l*o-s*u*h*a,p=+(c*u*h)-s*d*h*o+s*u*l*a,v=+(c*d)+s*u*o,m=w1(i,n,s),g=[f/xo,p/xo,v/xo],S=zd(m),y=zd(g);return new Ua(t,S,y)}function zc(r,t,e,i){const n=i/(i+D0),s=Ir(ss[e],t);r.x+=n*s.x,r.y+=n*s.y,r.z+=n*s.z}function fw(r){const t=new Fe(0,0,0,r);return zc(t,r,wt.Jupiter,Dd),zc(t,r,wt.Saturn,Id),zc(t,r,wt.Uranus,Cd),zc(t,r,wt.Neptune,Pd),t}const Hd=51,pw=29200,vr=146,gs=201,Ta=[[-73e4,[-26.118207232108,-14.376168177825,3.384402515299],[.0016339372163656,-.0027861699588508,-.0013585880229445]],[-700800,[41.974905202127,-.448502952929,-12.770351505989],[.00073458569351457,.0022785014891658,.00048619778602049]],[-671600,[14.706930780744,44.269110540027,9.353698474772],[-.00210001479998,.00022295915939915,.00070143443551414]],[-642400,[-29.441003929957,-6.43016153057,6.858481011305],[.00084495803960544,-.0030783914758711,-.0012106305981192]],[-613200,[39.444396946234,-6.557989760571,-13.913760296463],[.0011480029005873,.0022400006880665,.00035168075922288]],[-584e3,[20.2303809507,43.266966657189,7.382966091923],[-.0019754081700585,.00053457141292226,.00075929169129793]],[-554800,[-30.65832536462,2.093818874552,9.880531138071],[61010603013347e-18,-.0031326500935382,-.00099346125151067]],[-525600,[35.737703251673,-12.587706024764,-14.677847247563],[.0015802939375649,.0021347678412429,.00019074436384343]],[-496400,[25.466295188546,41.367478338417,5.216476873382],[-.0018054401046468,.0008328308359951,.00080260156912107]],[-467200,[-29.847174904071,10.636426313081,12.297904180106],[-.00063257063052907,-.0029969577578221,-.00074476074151596]],[-438e3,[30.774692107687,-18.236637015304,-14.945535879896],[.0020113162005465,.0019353827024189,-20937793168297e-19]],[-408800,[30.243153324028,38.656267888503,2.938501750218],[-.0016052508674468,.0011183495337525,.00083333973416824]],[-379600,[-27.288984772533,18.643162147874,14.023633623329],[-.0011856388898191,-.0027170609282181,-.00049015526126399]],[-350400,[24.519605196774,-23.245756064727,-14.626862367368],[.0024322321483154,.0016062008146048,-.00023369181613312]],[-321200,[34.505274805875,35.125338586954,.557361475637],[-.0013824391637782,.0013833397561817,.00084823598806262]],[-292e3,[-23.275363915119,25.818514298769,15.055381588598],[-.0016062295460975,-.0023395961498533,-.00024377362639479]],[-262800,[17.050384798092,-27.180376290126,-13.608963321694],[.0028175521080578,.0011358749093955,-.00049548725258825]],[-233600,[38.093671910285,30.880588383337,-1.843688067413],[-.0011317697153459,.0016128814698472,.00084177586176055]],[-204400,[-18.197852930878,31.932869934309,15.438294826279],[-.0019117272501813,-.0019146495909842,-19657304369835e-18]],[-175200,[8.528924039997,-29.618422200048,-11.805400994258],[.0031034370787005,.0005139363329243,-.00077293066202546]],[-146e3,[40.94685725864,25.904973592021,-4.256336240499],[-.00083652705194051,.0018129497136404,.0008156422827306]],[-116800,[-12.326958895325,36.881883446292,15.217158258711],[-.0021166103705038,-.001481442003599,.00017401209844705]],[-87600,[-.633258375909,-30.018759794709,-9.17193287495],[.0032016994581737,-.00025279858672148,-.0010411088271861]],[-58400,[42.936048423883,20.344685584452,-6.588027007912],[-.00050525450073192,.0019910074335507,.00077440196540269]],[-29200,[-5.975910552974,40.61180995846,14.470131723673],[-.0022184202156107,-.0010562361130164,.00033652250216211]],[0,[-9.875369580774,-27.978926224737,-5.753711824704],[.0030287533248818,-.0011276087003636,-.0012651326732361]],[29200,[43.958831986165,14.214147973292,-8.808306227163],[-.00014717608981871,.0021404187242141,.00071486567806614]],[58400,[.67813676352,43.094461639362,13.243238780721],[-.0022358226110718,-.00063233636090933,.00047664798895648]],[87600,[-18.282602096834,-23.30503958666,-1.766620508028],[.0025567245263557,-.0019902940754171,-.0013943491701082]],[116800,[43.873338744526,7.700705617215,-10.814273666425],[.00023174803055677,.0022402163127924,.00062988756452032]],[146e3,[7.392949027906,44.382678951534,11.629500214854],[-.002193281545383,-.00021751799585364,.00059556516201114]],[175200,[-24.981690229261,-16.204012851426,2.466457544298],[.001819398914958,-.0026765419531201,-.0013848283502247]],[204400,[42.530187039511,.845935508021,-12.554907527683],[.00065059779150669,.0022725657282262,.00051133743202822]],[233600,[13.999526486822,44.462363044894,9.669418486465],[-.0021079296569252,.00017533423831993,.00069128485798076]],[262800,[-29.184024803031,-7.371243995762,6.493275957928],[.00093581363109681,-.0030610357109184,-.0012364201089345]],[292e3,[39.831980671753,-6.078405766765,-13.909815358656],[.0011117769689167,.0022362097830152,.00036230548231153]],[321200,[20.294955108476,43.417190420251,7.450091985932],[-.0019742157451535,.00053102050468554,.00075938408813008]],[350400,[-30.66999230216,2.318743558955,9.973480913858],[45605107450676e-18,-.0031308219926928,-.00099066533301924]],[379600,[35.626122155983,-12.897647509224,-14.777586508444],[.0016015684949743,.0021171931182284,.00018002516202204]],[408800,[26.133186148561,41.232139187599,5.00640132622],[-.0017857704419579,.00086046232702817,.00080614690298954]],[438e3,[-29.57674022923,11.863535943587,12.631323039872],[-.00072292830060955,-.0029587820140709,-.000708242964503]],[467200,[29.910805787391,-19.159019294,-15.013363865194],[.0020871080437997,.0018848372554514,-38528655083926e-18]],[496400,[31.375957451819,38.050372720763,2.433138343754],[-.0015546055556611,.0011699815465629,.00083565439266001]],[525600,[-26.360071336928,20.662505904952,14.414696258958],[-.0013142373118349,-.0026236647854842,-.00042542017598193]],[554800,[22.599441488648,-24.508879898306,-14.484045731468],[.0025454108304806,.0014917058755191,-.00030243665086079]],[584e3,[35.877864013014,33.894226366071,-.224524636277],[-.0012941245730845,.0014560427668319,.00084762160640137]],[613200,[-21.538149762417,28.204068269761,15.321973799534],[-.001731211740901,-.0021939631314577,-.0001631691327518]],[642400,[13.971521374415,-28.339941764789,-13.083792871886],[.0029334630526035,.00091860931752944,-.00059939422488627]],[671600,[39.526942044143,28.93989736011,-2.872799527539],[-.0010068481658095,.001702113288809,.00083578230511981]],[700800,[-15.576200701394,34.399412961275,15.466033737854],[-.0020098814612884,-.0017191109825989,70414782780416e-18]],[73e4,[4.24325283709,-30.118201690825,-10.707441231349],[.0031725847067411,.0001609846120227,-.00090672150593868]]];class Li{constructor(t,e,i){this.x=t,this.y=e,this.z=i}clone(){return new Li(this.x,this.y,this.z)}ToAstroVector(t){return new Fe(this.x,this.y,this.z,t)}static zero(){return new Li(0,0,0)}quadrature(){return this.x*this.x+this.y*this.y+this.z*this.z}add(t){return new Li(this.x+t.x,this.y+t.y,this.z+t.z)}sub(t){return new Li(this.x-t.x,this.y-t.y,this.z-t.z)}incr(t){this.x+=t.x,this.y+=t.y,this.z+=t.z}decr(t){this.x-=t.x,this.y-=t.y,this.z-=t.z}mul(t){return new Li(t*this.x,t*this.y,t*this.z)}div(t){return new Li(this.x/t,this.y/t,this.z/t)}mean(t){return new Li((this.x+t.x)/2,(this.y+t.y)/2,(this.z+t.z)/2)}neg(){return new Li(-this.x,-this.y,-this.z)}}class Ua{constructor(t,e,i){this.tt=t,this.r=e,this.v=i}clone(){return new Ua(this.tt,this.r,this.v)}sub(t){return new Ua(this.tt,this.r.sub(t.r),this.v.sub(t.v))}}function mw(r){let[t,[e,i,n],[s,a,o]]=r;return new Ua(t,new Li(e,i,n),new Li(s,a,o))}function Bc(r,t,e,i){const n=i/(i+D0),s=Bd(ss[e],t);return r.r.incr(s.r.mul(n)),r.v.incr(s.v.mul(n)),s}function ro(r,t,e){const i=e.sub(r),n=i.quadrature();return i.mul(t/(n*Math.sqrt(n)))}class Jl{constructor(t){let e=new Ua(t,new Li(0,0,0),new Li(0,0,0));this.Jupiter=Bc(e,t,wt.Jupiter,Dd),this.Saturn=Bc(e,t,wt.Saturn,Id),this.Uranus=Bc(e,t,wt.Uranus,Cd),this.Neptune=Bc(e,t,wt.Neptune,Pd),this.Jupiter.r.decr(e.r),this.Jupiter.v.decr(e.v),this.Saturn.r.decr(e.r),this.Saturn.v.decr(e.v),this.Uranus.r.decr(e.r),this.Uranus.v.decr(e.v),this.Neptune.r.decr(e.r),this.Neptune.v.decr(e.v),this.Sun=new Ua(t,e.r.mul(-1),e.v.mul(-1))}Acceleration(t){let e=ro(t,D0,this.Sun.r);return e.incr(ro(t,Dd,this.Jupiter.r)),e.incr(ro(t,Id,this.Saturn.r)),e.incr(ro(t,Cd,this.Uranus.r)),e.incr(ro(t,Pd,this.Neptune.r)),e}}class jl{constructor(t,e,i,n){this.tt=t,this.r=e,this.v=i,this.a=n}clone(){return new jl(this.tt,this.r.clone(),this.v.clone(),this.a.clone())}}class E1{constructor(t,e){this.bary=t,this.grav=e}}function Ll(r,t,e,i){return new Li(t.x+r*(e.x+r*i.x/2),t.y+r*(e.y+r*i.y/2),t.z+r*(e.z+r*i.z/2))}function Zp(r,t,e){return new Li(t.x+r*e.x,t.y+r*e.y,t.z+r*e.z)}function Gd(r,t){const e=r-t.tt,i=new Jl(r),n=Ll(e,t.r,t.v,t.a),s=i.Acceleration(n).mean(t.a),a=Ll(e,t.r,t.v,s),o=t.v.add(s.mul(e)),c=i.Acceleration(a),l=new jl(r,a,o,c);return new E1(i,l)}const gw=[];function A1(r,t){const e=Math.floor(r);return e<0?0:e>=t?t-1:e}function Vd(r){const t=mw(r),e=new Jl(t.tt),i=t.r.add(e.Sun.r),n=t.v.add(e.Sun.v),s=e.Acceleration(i),a=new jl(t.tt,i,n,s);return new E1(e,a)}function vw(r,t){const e=Ta[0][0];if(t<e||t>Ta[Hd-1][0])return null;const i=A1((t-e)/pw,Hd-1);if(!r[i]){const s=r[i]=[];s[0]=Vd(Ta[i]).grav,s[gs-1]=Vd(Ta[i+1]).grav;let a,o=s[0].tt;for(a=1;a<gs-1;++a)s[a]=Gd(o+=vr,s[a-1]).grav;o=s[gs-1].tt;var n=[];for(n[gs-1]=s[gs-1],a=gs-2;a>0;--a)n[a]=Gd(o-=vr,n[a+1]).grav;for(a=gs-2;a>0;--a){const c=a/(gs-1);s[a].r=s[a].r.mul(1-c).add(n[a].r.mul(c)),s[a].v=s[a].v.mul(1-c).add(n[a].v.mul(c)),s[a].a=s[a].a.mul(1-c).add(n[a].a.mul(c))}}return r[i]}function Jp(r,t,e){let i=Vd(r);const n=Math.ceil((t-i.grav.tt)/e);for(let s=0;s<n;++s)i=Gd(s+1===n?t:i.grav.tt+e,i.grav);return i}function T1(r,t){let e,i,n;const s=vw(gw,r.tt);if(s){const a=A1((r.tt-s[0].tt)/vr,gs-1),o=s[a],c=s[a+1],l=o.a.mean(c.a),h=Ll(r.tt-o.tt,o.r,o.v,l),u=Zp(r.tt-o.tt,o.v,l),d=Ll(r.tt-c.tt,c.r,c.v,l),f=Zp(r.tt-c.tt,c.v,l),p=(r.tt-o.tt)/vr;e=h.mul(1-p).add(d.mul(p)),i=u.mul(1-p).add(f.mul(p))}else{let a;r.tt<Ta[0][0]?a=Jp(Ta[0],r.tt,-vr):a=Jp(Ta[Hd-1],r.tt,+vr),e=a.grav.r,i=a.grav.v,n=a.bary}return n||(n=new Jl(r.tt)),e=e.sub(n.Sun.r),i=i.sub(n.Sun.v),new Qs(e.x,e.y,e.z,i.x,i.y,i.z,r)}function ia(r,t){var e=$e(t);if(r in ss)return Ir(ss[r],e);if(r===wt.Pluto){const a=T1(e);return new Fe(a.x,a.y,a.z,e)}if(r===wt.Sun)return new Fe(0,0,0,e);if(r===wt.Moon){var i=Ir(ss.Earth,e),n=Ur(e);return new Fe(i.x+n.x,i.y+n.y,i.z+n.z,e)}if(r===wt.EMB){const a=Ir(ss.Earth,e),o=Ur(e),c=1+g1;return new Fe(a.x+o.x/c,a.y+o.y/c,a.z+o.z/c,e)}if(r===wt.SSB)return fw(e);const s=I0(r);if(s){const a=new Zl(s.dec,15*s.ra,s.dist);return F0(a,e)}throw`HelioVector: Unknown body "${r}"`}function Mw(r,t){let e=t,i=0;for(let n=0;n<10;++n){const s=r(e),a=s.Length()/R0;if(a>1)throw"Object is too distant for light-travel solver.";const o=t.AddDays(-a);if(i=Math.abs(o.tt-e.tt),i<1e-9)return s;e=o}throw`Light-travel time solver did not converge: dt = ${i}`}class xw{constructor(t,e,i,n){this.observerBody=t,this.targetBody=e,this.aberration=i,this.observerPos=n}Position(t){this.aberration&&(this.observerPos=ia(this.observerBody,t));const e=ia(this.targetBody,t);return new Fe(e.x-this.observerPos.x,e.y-this.observerPos.y,e.z-this.observerPos.z,t)}}function yw(r,t,e,i){Cl(i);const n=$e(r);if(I0(e)){const o=ia(e,n);if(i){const l=Sw(t,n),h=new Fe(o.x-l.x,o.y-l.y,o.z-l.z,n),u=R0/h.Length();return new Fe(h.x+l.vx/u,h.y+l.vy/u,h.z+l.vz/u,n)}const c=ia(t,n);return new Fe(o.x-c.x,o.y-c.y,o.z-c.z,n)}let s;i?s=new Fe(0,0,0,n):s=ia(t,n);const a=new xw(t,e,i,s);return Mw(o=>a.Position(o),n)}function Wd(r,t,e){Cl(e);const i=$e(t);switch(r){case wt.Earth:return new Fe(0,0,0,i);case wt.Moon:return Ur(i);default:const n=yw(i,wt.Earth,r,e);return n.t=i,n}}function _w(r,t){return new Qs(r.r.x,r.r.y,r.r.z,r.v.x,r.v.y,r.v.z,t)}function Sw(r,t){const e=$e(t);switch(r){case wt.Sun:return new Qs(0,0,0,0,0,0,e);case wt.SSB:const i=new Jl(e.tt);return new Qs(-i.Sun.r.x,-i.Sun.r.y,-i.Sun.r.z,-i.Sun.v.x,-i.Sun.v.y,-i.Sun.v.z,e);case wt.Mercury:case wt.Venus:case wt.Earth:case wt.Mars:case wt.Jupiter:case wt.Saturn:case wt.Uranus:case wt.Neptune:const n=Bd(ss[r],e.tt);return _w(n,e);case wt.Pluto:return T1(e);case wt.Moon:case wt.EMB:const s=Bd(ss.Earth,e.tt),a=r==wt.Moon?b1(e):dw(e);return new Qs(a.x+s.r.x,a.y+s.r.y,a.z+s.r.z,a.vx+s.v.x,a.vy+s.v.y,a.vz+s.v.z,e);default:if(I0(r)){const o=ia(r,e);return new Qs(o.x,o.y,o.z,0,0,0,e)}throw`HelioState: Unsupported body "${r}"`}}function bw(r){for(;r<0;)r+=360;for(;r>=360;)r-=360;return r}function ww(r,t,e){if(r===wt.Earth||t===wt.Earth)throw"The Earth does not have a longitude as seen from itself.";const i=$e(e),n=Wd(r,i,!1),s=Nd(n),a=Wd(t,i,!1),o=Nd(a);return bw(s.elon-o.elon)}function Ew(r,t,e,i){let n,s=0,a=0,o=0;switch(r){case wt.Mercury:n=-.6,s=4.98,a=-4.88,o=3.02;break;case wt.Venus:t<163.6?(n=-4.47,s=1.03,a=.57,o=.13):(n=.98,s=-1.02);break;case wt.Mars:n=-1.52,s=1.6;break;case wt.Jupiter:n=-9.4,s=.5;break;case wt.Uranus:n=-7.19,s=.25;break;case wt.Neptune:n=-6.87;break;case wt.Pluto:n=-1,s=4;break;default:throw`VisualMagnitude: unsupported body ${r}`}const c=t/100;let l=n+c*(s+c*(a+c*o));return l+=5*Math.log10(e*i),l}function Aw(r,t,e,i,n){const s=Nd(i),a=Ee*28.06,o=Ee*(169.51+382e-7*n.tt),c=Ee*s.elat,l=Ee*s.elon,h=Math.asin(Math.sin(c)*Math.cos(a)-Math.cos(c)*Math.sin(a)*Math.sin(l-o)),u=Math.sin(Math.abs(h));let d=-9+.044*r;return d+=u*(-2.6+1.2*u),d+=5*Math.log10(t*e),{mag:d,ring_tilt:os*h}}function Tw(r,t,e){let i=r*Ee,n=i*i,s=n*n,a=-12.717+1.49*Math.abs(i)+.0431*s;const o=385000.6/Sa;let c=e/o;return a+=5*Math.log10(t*c),a}class Rw{constructor(t,e,i,n,s,a,o,c){this.time=t,this.mag=e,this.phase_angle=i,this.helio_dist=n,this.geo_dist=s,this.gc=a,this.hc=o,this.ring_tilt=c,this.phase_fraction=(1+Math.cos(Ee*i))/2}}function R1(r,t){if(r===wt.Earth)throw"The illumination of the Earth is not defined.";const e=$e(t),i=Ir(ss.Earth,e);let n,s,a,o;r===wt.Sun?(a=new Fe(-i.x,-i.y,-i.z,e),s=new Fe(0,0,0,e),n=0):(r===wt.Moon?(a=Ur(e),s=new Fe(i.x+a.x,i.y+a.y,i.z+a.z,e)):(s=ia(r,t),a=new Fe(s.x-i.x,s.y-i.y,s.z-i.z,e)),n=qb(a,s));let c=a.Length(),l=s.Length(),h;if(r===wt.Sun)o=Wb+5*Math.log10(c);else if(r===wt.Moon)o=Tw(n,l,c);else if(r===wt.Saturn){const u=Aw(n,l,c,a,e);o=u.mag,h=u.ring_tilt}else o=Ew(r,n,l,c);return new Rw(e,o,n,l,c,a,s,h)}function Dw(r){return ww(wt.Moon,wt.Sun,r)}var jp;(function(r){r[r.Pericenter=0]="Pericenter",r[r.Apocenter=1]="Apocenter"})(jp||(jp={}));function D1(r,t){return new aa([[t.rot[0][0]*r.rot[0][0]+t.rot[1][0]*r.rot[0][1]+t.rot[2][0]*r.rot[0][2],t.rot[0][1]*r.rot[0][0]+t.rot[1][1]*r.rot[0][1]+t.rot[2][1]*r.rot[0][2],t.rot[0][2]*r.rot[0][0]+t.rot[1][2]*r.rot[0][1]+t.rot[2][2]*r.rot[0][2]],[t.rot[0][0]*r.rot[1][0]+t.rot[1][0]*r.rot[1][1]+t.rot[2][0]*r.rot[1][2],t.rot[0][1]*r.rot[1][0]+t.rot[1][1]*r.rot[1][1]+t.rot[2][1]*r.rot[1][2],t.rot[0][2]*r.rot[1][0]+t.rot[1][2]*r.rot[1][1]+t.rot[2][2]*r.rot[1][2]],[t.rot[0][0]*r.rot[2][0]+t.rot[1][0]*r.rot[2][1]+t.rot[2][0]*r.rot[2][2],t.rot[0][1]*r.rot[2][0]+t.rot[1][1]*r.rot[2][1]+t.rot[2][1]*r.rot[2][2],t.rot[0][2]*r.rot[2][0]+t.rot[1][2]*r.rot[2][1]+t.rot[2][2]*r.rot[2][2]]])}function F0(r,t){t=$e(t);const e=r.lat*Ee,i=r.lon*Ee,n=r.dist*Math.cos(e);return new Fe(n*Math.cos(i),n*Math.sin(i),r.dist*Math.sin(e),t)}function U0(r){const t=Iw(r);return new Od(t.lon/15,t.lat,t.dist,r)}function Iw(r){const t=r.x*r.x+r.y*r.y,e=Math.sqrt(t+r.z*r.z);let i,n;if(t===0){if(r.z===0)throw"Zero-length vector not allowed.";n=0,i=r.z<0?-90:90}else n=os*Math.atan2(r.y,r.x),n<0&&(n+=360),i=os*Math.atan2(r.z,Math.sqrt(t));return new Zl(i,n,e)}function I1(r,t){let e;if(Si(t),t<-90||t>90)return 0;if(r==="normal"||r==="jplhor"){let i=t;i<-1&&(i=-1),e=1.02/Math.tan((i+10.3/(i+5.11))*Ee)/60,r==="normal"&&t<-1&&(e*=(t+90)/89)}else if(!r)e=0;else throw`Invalid refraction option: ${r}`;return e}function Cr(r,t){return new Fe(r.rot[0][0]*t.x+r.rot[1][0]*t.y+r.rot[2][0]*t.z,r.rot[0][1]*t.x+r.rot[1][1]*t.y+r.rot[2][1]*t.z,r.rot[0][2]*t.x+r.rot[1][2]*t.y+r.rot[2][2]*t.z,t.t)}function Cw(){return new aa([[1,0,0],[0,.9174821430670688,-.3977769691083922],[0,.3977769691083922,.9174821430670688]])}function Pw(){return new aa([[1,0,0],[0,.9174821430670688,.3977769691083922],[0,-.3977769691083922,.9174821430670688]])}function C1(r){r=$e(r);const t=C0(r,Ai.From2000),e=P0(r,Ai.From2000);return D1(t,e)}function Lw(r){r=$e(r);const t=P0(r,Ai.Into2000),e=C0(r,Ai.Into2000);return D1(t,e)}function Ow(r){const e=Zo($e(r)).tobl*Ee,i=Math.cos(e),n=Math.sin(e);return new aa([[1,0,0],[0,+i,+n],[0,-n,+i]])}var Qp;(function(r){r.Penumbral="penumbral",r.Partial="partial",r.Annular="annular",r.Total="total"})(Qp||(Qp={}));var tm;(function(r){r[r.Invalid=0]="Invalid",r[r.Ascending=1]="Ascending",r[r.Descending=-1]="Descending"})(tm||(tm={}));const Nw=["Venus","Mars","Jupiter","Saturn"];function P1(r){return new N0(r.lat,r.lng,r.elevationM)}function k0(r,t,e,i,n=!0){const s=_1(e,P1(i),r,t,n?"normal":void 0);return{altitudeDeg:s.altitude,azimuthDeg:s.azimuth}}class Pn{up;north;west;constructor(t,e){const i=$e(t),n=Math.sin(e.lat*vs),s=Math.cos(e.lat*vs),a=Math.sin(e.lng*vs),o=Math.cos(e.lng*vs),c=-15*sw(i),l=Lw(i);this.up=Pn.rotate(l,Pn.spin(c,[s*o,s*a,n]),i),this.north=Pn.rotate(l,Pn.spin(c,[-n*o,-n*a,s]),i),this.west=Pn.rotate(l,Pn.spin(c,[a,-o,0]),i)}static ofJ2000(t,e,i,n,s=!0){const a=$e(i),o=F0(new Zl(e,t*15,1),a),c=U0(Cr(C1(a),o));return k0(c.ra,c.dec,i,n,s)}position(t,e){const i=Math.sin(e*vs),n=Math.cos(e*vs),s=Math.sin(t*im),a=Math.cos(t*im),o=n*a,c=n*s,l=i,h=o*this.up[0]+c*this.up[1]+l*this.up[2],u=o*this.north[0]+c*this.north[1]+l*this.north[2],d=o*this.west[0]+c*this.west[1]+l*this.west[2],f=Math.hypot(u,d);let p=0;f>0&&(p=-em*Math.atan2(d,u),p<0&&(p+=360));let v=em*Math.atan2(f,h);return v-=I1("normal",90-v),{altitudeDeg:90-v,azimuthDeg:p}}static spin(t,[e,i,n]){const s=Math.cos(t*vs),a=Math.sin(t*vs);return[s*e+a*i,s*i-a*e,n]}static rotate(t,[e,i,n],s){const a=Cr(t,new Fe(e,i,n,s));return[a.x,a.y,a.z]}}const vs=Math.PI/180,em=180/Math.PI,im=15*vs;function $h(r,t,e){const i=P1(e),n=hw(wt[r],t,i,!0,!0),s=_1(t,i,n.ra,n.dec,"normal");return{altitudeDeg:s.altitude,azimuthDeg:s.azimuth}}function Kh(r,t){return R1(wt[r],t).mag}function Fw(r){const t=Dw(r),e=R1(wt.Moon,r);return{phaseFraction:t/360,illuminatedFraction:e.phase_fraction}}const Uw=2e3,kw=3,zw=20;function Hc(r,t,e){if(r.year===void 0&&r.month===void 0&&r.day===void 0&&r.hour===void 0)return;const i=r.year!==void 0,n=r.year??Uw,s=r.month??(i?1:kw),a=r.day??(i?1:zw),o=e??Math.round(t/15);return new Date(Date.UTC(n,s-1,a,(r.hour??12)-o,r.minute??0,r.second??0))}const nm=["N","NNE","NE","ENE","E","ESE","SE","SSE","S","SSW","SW","WSW","W","WNW","NW","NNW"];class Ca{static POINT_DEG=360/16;static point(t,e=nm){const i=(t%360+360)%360,n=Math.round(i/Ca.POINT_DEG)%16;return e[n]}static POINTS=nm;static towards(t,e){return e?e.towards(Ca.point(t,e.compassPoints)):`to the ${Ca.point(t)}`}}class Kn{static ANCHOR="vec4 diffuseColor = vec4( diffuse, opacity );";static CORE=.18;static RIM=.5;static FALLOFF={core:Kn.CORE,rim:Kn.RIM};static apply(t){t.transparent=!0,t.depthWrite=!1,t.onBeforeCompile=e=>{e.fragmentShader=Kn.patch(e.fragmentShader)}}static patch(t){return t.replace(Kn.ANCHOR,`float distanceFromCentre = length( gl_PointCoord - vec2( 0.5 ) );
|
|
6187
|
+
*/const R0=173.1446326846693,Sa=14959787069098932e-8,Ee=.017453292519943295,Yp=.26179938779914946,os=57.29577951308232,p1=3.819718634205488,Hb=365.24217,qp=new Date("2000-01-01T12:00:00Z"),ms=2*Math.PI,Hs=3600*(180/Math.PI),gr=484813681109536e-20,m1=10800*60,Gb=2*m1,$p=7292115e-11,Vb=m1/Math.PI,Wb=-.17-5*Math.log10(Vb),Td=.996647180302104,Xb=Td*Td,Rd=6378.1366,Yb=Rd/Sa,g1=81.30056,D0=.0002959122082855911,Dd=2825345909524226e-22,Id=8459715185680659e-23,Cd=1292024916781969e-23,Pd=1524358900784276e-23;function Cl(r){if(r!==!0&&r!==!1)throw console.trace(),`Value is not boolean: ${r}`;return r}function Si(r){if(!Number.isFinite(r))throw console.trace(),`Value is not a finite number: ${r}`;return r}function lr(r){return r-Math.floor(r)}function qb(r,t){const e=r.x*r.x+r.y*r.y+r.z*r.z;if(Math.abs(e)<1e-8)throw"AngleBetween: first vector is too short.";const i=t.x*t.x+t.y*t.y+t.z*t.z;if(Math.abs(i)<1e-8)throw"AngleBetween: second vector is too short.";const n=(r.x*t.x+r.y*t.y+r.z*t.z)/Math.sqrt(e*i);return n<=-1?180:n>=1?0:os*Math.acos(n)}var wt;(function(r){r.Sun="Sun",r.Moon="Moon",r.Mercury="Mercury",r.Venus="Venus",r.Earth="Earth",r.Mars="Mars",r.Jupiter="Jupiter",r.Saturn="Saturn",r.Uranus="Uranus",r.Neptune="Neptune",r.Pluto="Pluto",r.SSB="SSB",r.EMB="EMB",r.Star1="Star1",r.Star2="Star2",r.Star3="Star3",r.Star4="Star4",r.Star5="Star5",r.Star6="Star6",r.Star7="Star7",r.Star8="Star8"})(wt||(wt={}));const $b=[wt.Star1,wt.Star2,wt.Star3,wt.Star4,wt.Star5,wt.Star6,wt.Star7,wt.Star8],Kb=[{ra:0,dec:0,dist:0},{ra:0,dec:0,dist:0},{ra:0,dec:0,dist:0},{ra:0,dec:0,dist:0},{ra:0,dec:0,dist:0},{ra:0,dec:0,dist:0},{ra:0,dec:0,dist:0},{ra:0,dec:0,dist:0}];function Zb(r){const t=$b.indexOf(r);return t>=0?Kb[t]:null}function I0(r){const t=Zb(r);return t&&t.dist>0?t:null}var Ai;(function(r){r[r.From2000=0]="From2000",r[r.Into2000=1]="Into2000"})(Ai||(Ai={}));const ss={Mercury:[[[[4.40250710144,0,0],[.40989414977,1.48302034195,26087.9031415742],[.050462942,4.47785489551,52175.8062831484],[.00855346844,1.16520322459,78263.70942472259],[.00165590362,4.11969163423,104351.61256629678],[.00034561897,.77930768443,130439.51570787099],[7583476e-11,3.71348404924,156527.41884944518]],[[26087.90313685529,0,0],[.01131199811,6.21874197797,26087.9031415742],[.00292242298,3.04449355541,52175.8062831484],[.00075775081,6.08568821653,78263.70942472259],[.00019676525,2.80965111777,104351.61256629678]]],[[[.11737528961,1.98357498767,26087.9031415742],[.02388076996,5.03738959686,52175.8062831484],[.01222839532,3.14159265359,0],[.0054325181,1.79644363964,78263.70942472259],[.0012977877,4.83232503958,104351.61256629678],[.00031866927,1.58088495658,130439.51570787099],[7963301e-11,4.60972126127,156527.41884944518]],[[.00274646065,3.95008450011,26087.9031415742],[.00099737713,3.14159265359,0]]],[[[.39528271651,0,0],[.07834131818,6.19233722598,26087.9031415742],[.00795525558,2.95989690104,52175.8062831484],[.00121281764,6.01064153797,78263.70942472259],[.00021921969,2.77820093972,104351.61256629678],[4354065e-11,5.82894543774,130439.51570787099]],[[.0021734774,4.65617158665,26087.9031415742],[.00044141826,1.42385544001,52175.8062831484]]]],Venus:[[[[3.17614666774,0,0],[.01353968419,5.59313319619,10213.285546211],[.00089891645,5.30650047764,20426.571092422],[5477194e-11,4.41630661466,7860.4193924392],[3455741e-11,2.6996444782,11790.6290886588],[2372061e-11,2.99377542079,3930.2096962196],[1317168e-11,5.18668228402,26.2983197998],[1664146e-11,4.25018630147,1577.3435424478],[1438387e-11,4.15745084182,9683.5945811164],[1200521e-11,6.15357116043,30639.856638633]],[[10213.28554621638,0,0],[.00095617813,2.4640651111,10213.285546211],[7787201e-11,.6247848222,20426.571092422]]],[[[.05923638472,.26702775812,10213.285546211],[.00040107978,1.14737178112,20426.571092422],[.00032814918,3.14159265359,0]],[[.00287821243,1.88964962838,10213.285546211]]],[[[.72334820891,0,0],[.00489824182,4.02151831717,10213.285546211],[1658058e-11,4.90206728031,20426.571092422],[1378043e-11,1.12846591367,11790.6290886588],[1632096e-11,2.84548795207,7860.4193924392],[498395e-11,2.58682193892,9683.5945811164],[221985e-11,2.01346696541,19367.1891622328],[237454e-11,2.55136053886,15720.8387848784]],[[.00034551041,.89198706276,10213.285546211]]]],Earth:[[[[1.75347045673,0,0],[.03341656453,4.66925680415,6283.0758499914],[.00034894275,4.62610242189,12566.1516999828],[3417572e-11,2.82886579754,3.523118349],[3497056e-11,2.74411783405,5753.3848848968],[3135899e-11,3.62767041756,77713.7714681205],[2676218e-11,4.41808345438,7860.4193924392],[2342691e-11,6.13516214446,3930.2096962196],[1273165e-11,2.03709657878,529.6909650946],[1324294e-11,.74246341673,11506.7697697936],[901854e-11,2.04505446477,26.2983197998],[1199167e-11,1.10962946234,1577.3435424478],[857223e-11,3.50849152283,398.1490034082],[779786e-11,1.17882681962,5223.6939198022],[99025e-10,5.23268072088,5884.9268465832],[753141e-11,2.53339052847,5507.5532386674],[505267e-11,4.58292599973,18849.2275499742],[492392e-11,4.20505711826,775.522611324],[356672e-11,2.91954114478,.0673103028],[284125e-11,1.89869240932,796.2980068164],[242879e-11,.34481445893,5486.777843175],[317087e-11,5.84901948512,11790.6290886588],[271112e-11,.31486255375,10977.078804699],[206217e-11,4.80646631478,2544.3144198834],[205478e-11,1.86953770281,5573.1428014331],[202318e-11,2.45767790232,6069.7767545534],[126225e-11,1.08295459501,20.7753954924],[155516e-11,.83306084617,213.299095438]],[[6283.0758499914,0,0],[.00206058863,2.67823455808,6283.0758499914],[4303419e-11,2.63512233481,12566.1516999828]],[[8721859e-11,1.07253635559,6283.0758499914]]],[[],[[.00227777722,3.4137662053,6283.0758499914],[3805678e-11,3.37063423795,12566.1516999828]]],[[[1.00013988784,0,0],[.01670699632,3.09846350258,6283.0758499914],[.00013956024,3.05524609456,12566.1516999828],[308372e-10,5.19846674381,77713.7714681205],[1628463e-11,1.17387558054,5753.3848848968],[1575572e-11,2.84685214877,7860.4193924392],[924799e-11,5.45292236722,11506.7697697936],[542439e-11,4.56409151453,3930.2096962196],[47211e-10,3.66100022149,5884.9268465832],[85831e-11,1.27079125277,161000.6857376741],[57056e-11,2.01374292245,83996.84731811189],[55736e-11,5.2415979917,71430.69561812909],[174844e-11,3.01193636733,18849.2275499742],[243181e-11,4.2734953079,11790.6290886588]],[[.00103018607,1.10748968172,6283.0758499914],[1721238e-11,1.06442300386,12566.1516999828]],[[4359385e-11,5.78455133808,6283.0758499914]]]],Mars:[[[[6.20347711581,0,0],[.18656368093,5.0503710027,3340.6124266998],[.01108216816,5.40099836344,6681.2248533996],[.00091798406,5.75478744667,10021.8372800994],[.00027744987,5.97049513147,3.523118349],[.00010610235,2.93958560338,2281.2304965106],[.00012315897,.84956094002,2810.9214616052],[8926784e-11,4.15697846427,.0172536522],[8715691e-11,6.11005153139,13362.4497067992],[6797556e-11,.36462229657,398.1490034082],[7774872e-11,3.33968761376,5621.8429232104],[3575078e-11,1.6618650571,2544.3144198834],[4161108e-11,.22814971327,2942.4634232916],[3075252e-11,.85696614132,191.4482661116],[2628117e-11,.64806124465,3337.0893083508],[2937546e-11,6.07893711402,.0673103028],[2389414e-11,5.03896442664,796.2980068164],[2579844e-11,.02996736156,3344.1355450488],[1528141e-11,1.14979301996,6151.533888305],[1798806e-11,.65634057445,529.6909650946],[1264357e-11,3.62275122593,5092.1519581158],[1286228e-11,3.06796065034,2146.1654164752],[1546404e-11,2.91579701718,1751.539531416],[1024902e-11,3.69334099279,8962.4553499102],[891566e-11,.18293837498,16703.062133499],[858759e-11,2.4009381194,2914.0142358238],[832715e-11,2.46418619474,3340.5951730476],[83272e-10,4.49495782139,3340.629680352],[712902e-11,3.66335473479,1059.3819301892],[748723e-11,3.82248614017,155.4203994342],[723861e-11,.67497311481,3738.761430108],[635548e-11,2.92182225127,8432.7643848156],[655162e-11,.48864064125,3127.3133312618],[550474e-11,3.81001042328,.9803210682],[55275e-10,4.47479317037,1748.016413067],[425966e-11,.55364317304,6283.0758499914],[415131e-11,.49662285038,213.299095438],[472167e-11,3.62547124025,1194.4470102246],[306551e-11,.38052848348,6684.7479717486],[312141e-11,.99853944405,6677.7017350506],[293198e-11,4.22131299634,20.7753954924],[302375e-11,4.48618007156,3532.0606928114],[274027e-11,.54222167059,3340.545116397],[281079e-11,5.88163521788,1349.8674096588],[231183e-11,1.28242156993,3870.3033917944],[283602e-11,5.7688543494,3149.1641605882],[236117e-11,5.75503217933,3333.498879699],[274033e-11,.13372524985,3340.6797370026],[299395e-11,2.78323740866,6254.6266625236]],[[3340.61242700512,0,0],[.01457554523,3.60433733236,3340.6124266998],[.00168414711,3.92318567804,6681.2248533996],[.00020622975,4.26108844583,10021.8372800994],[3452392e-11,4.7321039319,3.523118349],[2586332e-11,4.60670058555,13362.4497067992],[841535e-11,4.45864030426,2281.2304965106]],[[.00058152577,2.04961712429,3340.6124266998],[.00013459579,2.45738706163,6681.2248533996]]],[[[.03197134986,3.76832042431,3340.6124266998],[.00298033234,4.10616996305,6681.2248533996],[.00289104742,0,0],[.00031365539,4.4465105309,10021.8372800994],[34841e-9,4.7881254926,13362.4497067992]],[[.00217310991,6.04472194776,3340.6124266998],[.00020976948,3.14159265359,0],[.00012834709,1.60810667915,6681.2248533996]]],[[[1.53033488271,0,0],[.1418495316,3.47971283528,3340.6124266998],[.00660776362,3.81783443019,6681.2248533996],[.00046179117,4.15595316782,10021.8372800994],[8109733e-11,5.55958416318,2810.9214616052],[7485318e-11,1.77239078402,5621.8429232104],[5523191e-11,1.3643630377,2281.2304965106],[382516e-10,4.49407183687,13362.4497067992],[2306537e-11,.09081579001,2544.3144198834],[1999396e-11,5.36059617709,3337.0893083508],[2484394e-11,4.9254563992,2942.4634232916],[1960195e-11,4.74249437639,3344.1355450488],[1167119e-11,2.11260868341,5092.1519581158],[1102816e-11,5.00908403998,398.1490034082],[899066e-11,4.40791133207,529.6909650946],[992252e-11,5.83861961952,6151.533888305],[807354e-11,2.10217065501,1059.3819301892],[797915e-11,3.44839203899,796.2980068164],[740975e-11,1.49906336885,2146.1654164752]],[[.01107433345,2.03250524857,3340.6124266998],[.00103175887,2.37071847807,6681.2248533996],[128772e-9,0,0],[.0001081588,2.70888095665,10021.8372800994]],[[.00044242249,.47930604954,3340.6124266998],[8138042e-11,.86998389204,6681.2248533996]]]],Jupiter:[[[[.59954691494,0,0],[.09695898719,5.06191793158,529.6909650946],[.00573610142,1.44406205629,7.1135470008],[.00306389205,5.41734730184,1059.3819301892],[.00097178296,4.14264726552,632.7837393132],[.00072903078,3.64042916389,522.5774180938],[.00064263975,3.41145165351,103.0927742186],[.00039806064,2.29376740788,419.4846438752],[.00038857767,1.27231755835,316.3918696566],[.00027964629,1.7845459182,536.8045120954],[.0001358973,5.7748104079,1589.0728952838],[8246349e-11,3.5822792584,206.1855484372],[8768704e-11,3.63000308199,949.1756089698],[7368042e-11,5.0810119427,735.8765135318],[626315e-10,.02497628807,213.299095438],[6114062e-11,4.51319998626,1162.4747044078],[4905396e-11,1.32084470588,110.2063212194],[5305285e-11,1.30671216791,14.2270940016],[5305441e-11,4.18625634012,1052.2683831884],[4647248e-11,4.69958103684,3.9321532631],[3045023e-11,4.31676431084,426.598190876],[2609999e-11,1.56667394063,846.0828347512],[2028191e-11,1.06376530715,3.1813937377],[1764763e-11,2.14148655117,1066.49547719],[1722972e-11,3.88036268267,1265.5674786264],[1920945e-11,.97168196472,639.897286314],[1633223e-11,3.58201833555,515.463871093],[1431999e-11,4.29685556046,625.6701923124],[973272e-11,4.09764549134,95.9792272178]],[[529.69096508814,0,0],[.00489503243,4.2208293947,529.6909650946],[.00228917222,6.02646855621,7.1135470008],[.00030099479,4.54540782858,1059.3819301892],[.0002072092,5.45943156902,522.5774180938],[.00012103653,.16994816098,536.8045120954],[6067987e-11,4.42422292017,103.0927742186],[5433968e-11,3.98480737746,419.4846438752],[4237744e-11,5.89008707199,14.2270940016]],[[.00047233601,4.32148536482,7.1135470008],[.00030649436,2.929777887,529.6909650946],[.00014837605,3.14159265359,0]]],[[[.02268615702,3.55852606721,529.6909650946],[.00109971634,3.90809347197,1059.3819301892],[.00110090358,0,0],[8101428e-11,3.60509572885,522.5774180938],[6043996e-11,4.25883108339,1589.0728952838],[6437782e-11,.30627119215,536.8045120954]],[[.00078203446,1.52377859742,529.6909650946]]],[[[5.20887429326,0,0],[.25209327119,3.49108639871,529.6909650946],[.00610599976,3.84115365948,1059.3819301892],[.00282029458,2.57419881293,632.7837393132],[.00187647346,2.07590383214,522.5774180938],[.00086792905,.71001145545,419.4846438752],[.00072062974,.21465724607,536.8045120954],[.00065517248,5.9799588479,316.3918696566],[.00029134542,1.67759379655,103.0927742186],[.00030135335,2.16132003734,949.1756089698],[.00023453271,3.54023522184,735.8765135318],[.00022283743,4.19362594399,1589.0728952838],[.00023947298,.2745803748,7.1135470008],[.00013032614,2.96042965363,1162.4747044078],[970336e-10,1.90669633585,206.1855484372],[.00012749023,2.71550286592,1052.2683831884],[7057931e-11,2.18184839926,1265.5674786264],[6137703e-11,6.26418240033,846.0828347512],[2616976e-11,2.00994012876,1581.959348283]],[[.0127180152,2.64937512894,529.6909650946],[.00061661816,3.00076460387,1059.3819301892],[.00053443713,3.89717383175,522.5774180938],[.00031185171,4.88276958012,536.8045120954],[.00041390269,0,0]]]],Saturn:[[[[.87401354025,0,0],[.11107659762,3.96205090159,213.299095438],[.01414150957,4.58581516874,7.1135470008],[.00398379389,.52112032699,206.1855484372],[.00350769243,3.30329907896,426.598190876],[.00206816305,.24658372002,103.0927742186],[792713e-9,3.84007056878,220.4126424388],[.00023990355,4.66976924553,110.2063212194],[.00016573588,.43719228296,419.4846438752],[.00014906995,5.76903183869,316.3918696566],[.0001582029,.93809155235,632.7837393132],[.00014609559,1.56518472,3.9321532631],[.00013160301,4.44891291899,14.2270940016],[.00015053543,2.71669915667,639.897286314],[.00013005299,5.98119023644,11.0457002639],[.00010725067,3.12939523827,202.2533951741],[5863206e-11,.23656938524,529.6909650946],[5227757e-11,4.20783365759,3.1813937377],[6126317e-11,1.76328667907,277.0349937414],[5019687e-11,3.17787728405,433.7117378768],[459255e-10,.61977744975,199.0720014364],[4005867e-11,2.24479718502,63.7358983034],[2953796e-11,.98280366998,95.9792272178],[387367e-10,3.22283226966,138.5174968707],[2461186e-11,2.03163875071,735.8765135318],[3269484e-11,.77492638211,949.1756089698],[1758145e-11,3.2658010994,522.5774180938],[1640172e-11,5.5050445305,846.0828347512],[1391327e-11,4.02333150505,323.5054166574],[1580648e-11,4.37265307169,309.2783226558],[1123498e-11,2.83726798446,415.5524906121],[1017275e-11,3.71700135395,227.5261894396],[848642e-11,3.1915017083,209.3669421749]],[[213.2990952169,0,0],[.01297370862,1.82834923978,213.299095438],[.00564345393,2.88499717272,7.1135470008],[.00093734369,1.06311793502,426.598190876],[.00107674962,2.27769131009,206.1855484372],[.00040244455,2.04108104671,220.4126424388],[.00019941774,1.2795439047,103.0927742186],[.00010511678,2.7488034213,14.2270940016],[6416106e-11,.38238295041,639.897286314],[4848994e-11,2.43037610229,419.4846438752],[4056892e-11,2.92133209468,110.2063212194],[3768635e-11,3.6496533078,3.9321532631]],[[.0011644133,1.17988132879,7.1135470008],[.00091841837,.0732519584,213.299095438],[.00036661728,0,0],[.00015274496,4.06493179167,206.1855484372]]],[[[.04330678039,3.60284428399,213.299095438],[.00240348302,2.85238489373,426.598190876],[.00084745939,0,0],[.00030863357,3.48441504555,220.4126424388],[.00034116062,.57297307557,206.1855484372],[.0001473407,2.11846596715,639.897286314],[9916667e-11,5.79003188904,419.4846438752],[6993564e-11,4.7360468972,7.1135470008],[4807588e-11,5.43305312061,316.3918696566]],[[.00198927992,4.93901017903,213.299095438],[.00036947916,3.14159265359,0],[.00017966989,.5197943111,426.598190876]]],[[[9.55758135486,0,0],[.52921382865,2.39226219573,213.299095438],[.01873679867,5.2354960466,206.1855484372],[.01464663929,1.64763042902,426.598190876],[.00821891141,5.93520042303,316.3918696566],[.00547506923,5.0153261898,103.0927742186],[.0037168465,2.27114821115,220.4126424388],[.00361778765,3.13904301847,7.1135470008],[.00140617506,5.70406606781,632.7837393132],[.00108974848,3.29313390175,110.2063212194],[.00069006962,5.94099540992,419.4846438752],[.00061053367,.94037691801,639.897286314],[.00048913294,1.55733638681,202.2533951741],[.00034143772,.19519102597,277.0349937414],[.00032401773,5.47084567016,949.1756089698],[.00020936596,.46349251129,735.8765135318],[9796004e-11,5.20477537945,1265.5674786264],[.00011993338,5.98050967385,846.0828347512],[208393e-9,1.52102476129,433.7117378768],[.00015298404,3.0594381494,529.6909650946],[6465823e-11,.17732249942,1052.2683831884],[.00011380257,1.7310542704,522.5774180938],[3419618e-11,4.94550542171,1581.959348283]],[[.0618298134,.2584351148,213.299095438],[.00506577242,.71114625261,206.1855484372],[.00341394029,5.79635741658,426.598190876],[.00188491195,.47215589652,220.4126424388],[.00186261486,3.14159265359,0],[.00143891146,1.40744822888,7.1135470008]],[[.00436902572,4.78671677509,213.299095438]]]],Uranus:[[[[5.48129294297,0,0],[.09260408234,.89106421507,74.7815985673],[.01504247898,3.6271926092,1.4844727083],[.00365981674,1.89962179044,73.297125859],[.00272328168,3.35823706307,149.5631971346],[.00070328461,5.39254450063,63.7358983034],[.00068892678,6.09292483287,76.2660712756],[.00061998615,2.26952066061,2.9689454166],[.00061950719,2.85098872691,11.0457002639],[.0002646877,3.14152083966,71.8126531507],[.00025710476,6.11379840493,454.9093665273],[.0002107885,4.36059339067,148.0787244263],[.00017818647,1.74436930289,36.6485629295],[.00014613507,4.73732166022,3.9321532631],[.00011162509,5.8268179635,224.3447957019],[.0001099791,.48865004018,138.5174968707],[9527478e-11,2.95516862826,35.1640902212],[7545601e-11,5.236265824,109.9456887885],[4220241e-11,3.23328220918,70.8494453042],[40519e-9,2.277550173,151.0476698429],[3354596e-11,1.0654900738,4.4534181249],[2926718e-11,4.62903718891,9.5612275556],[349034e-10,5.48306144511,146.594251718],[3144069e-11,4.75199570434,77.7505439839],[2922333e-11,5.35235361027,85.8272988312],[2272788e-11,4.36600400036,70.3281804424],[2051219e-11,1.51773566586,.1118745846],[2148602e-11,.60745949945,38.1330356378],[1991643e-11,4.92437588682,277.0349937414],[1376226e-11,2.04283539351,65.2203710117],[1666902e-11,3.62744066769,380.12776796],[1284107e-11,3.11347961505,202.2533951741],[1150429e-11,.93343589092,3.1813937377],[1533221e-11,2.58594681212,52.6901980395],[1281604e-11,.54271272721,222.8603229936],[1372139e-11,4.19641530878,111.4301614968],[1221029e-11,.1990065003,108.4612160802],[946181e-11,1.19253165736,127.4717966068],[1150989e-11,4.17898916639,33.6796175129]],[[74.7815986091,0,0],[.00154332863,5.24158770553,74.7815985673],[.00024456474,1.71260334156,1.4844727083],[9258442e-11,.4282973235,11.0457002639],[8265977e-11,1.50218091379,63.7358983034],[915016e-10,1.41213765216,149.5631971346]]],[[[.01346277648,2.61877810547,74.7815985673],[623414e-9,5.08111189648,149.5631971346],[.00061601196,3.14159265359,0],[9963722e-11,1.61603805646,76.2660712756],[992616e-10,.57630380333,73.297125859]],[[.00034101978,.01321929936,74.7815985673]]],[[[19.21264847206,0,0],[.88784984413,5.60377527014,74.7815985673],[.03440836062,.32836099706,73.297125859],[.0205565386,1.7829515933,149.5631971346],[.0064932241,4.52247285911,76.2660712756],[.00602247865,3.86003823674,63.7358983034],[.00496404167,1.40139935333,454.9093665273],[.00338525369,1.58002770318,138.5174968707],[.00243509114,1.57086606044,71.8126531507],[.00190522303,1.99809394714,1.4844727083],[.00161858838,2.79137786799,148.0787244263],[.00143706183,1.38368544947,11.0457002639],[.00093192405,.17437220467,36.6485629295],[.00071424548,4.24509236074,224.3447957019],[.00089806014,3.66105364565,109.9456887885],[.00039009723,1.66971401684,70.8494453042],[.00046677296,1.39976401694,35.1640902212],[.00039025624,3.36234773834,277.0349937414],[.00036755274,3.88649278513,146.594251718],[.00030348723,.70100838798,151.0476698429],[.00029156413,3.180563367,77.7505439839],[.00022637073,.72518687029,529.6909650946],[.00011959076,1.7504339214,984.6003316219],[.00025620756,5.25656086672,380.12776796]],[[.01479896629,3.67205697578,74.7815985673]]]],Neptune:[[[[5.31188633046,0,0],[.0179847553,2.9010127389,38.1330356378],[.01019727652,.48580922867,1.4844727083],[.00124531845,4.83008090676,36.6485629295],[.00042064466,5.41054993053,2.9689454166],[.00037714584,6.09221808686,35.1640902212],[.00033784738,1.24488874087,76.2660712756],[.00016482741,7727998e-11,491.5579294568],[9198584e-11,4.93747051954,39.6175083461],[899425e-10,.27462171806,175.1660598002]],[[38.13303563957,0,0],[.00016604172,4.86323329249,1.4844727083],[.00015744045,2.27887427527,38.1330356378]]],[[[.03088622933,1.44104372644,38.1330356378],[.00027780087,5.91271884599,76.2660712756],[.00027623609,0,0],[.00015355489,2.52123799551,36.6485629295],[.00015448133,3.50877079215,39.6175083461]]],[[[30.07013205828,0,0],[.27062259632,1.32999459377,38.1330356378],[.01691764014,3.25186135653,36.6485629295],[.00807830553,5.18592878704,1.4844727083],[.0053776051,4.52113935896,35.1640902212],[.00495725141,1.5710564165,491.5579294568],[.00274571975,1.84552258866,175.1660598002],[.0001201232,1.92059384991,1021.2488945514],[.00121801746,5.79754470298,76.2660712756],[.00100896068,.3770272493,73.297125859],[.00135134092,3.37220609835,39.6175083461],[7571796e-11,1.07149207335,388.4651552382]]]]};function Jb(r){var t,e,i,n,s,a,o;const c=2e3+(r-14)/Hb;return c<-500?(t=(c-1820)/100,-20+32*t*t):c<500?(t=c/100,e=t*t,i=t*e,n=e*e,s=e*i,a=i*i,10583.6-1014.41*t+33.78311*e-5.952053*i-.1798452*n+.022174192*s+.0090316521*a):c<1600?(t=(c-1e3)/100,e=t*t,i=t*e,n=e*e,s=e*i,a=i*i,1574.2-556.01*t+71.23472*e+.319781*i-.8503463*n-.005050998*s+.0083572073*a):c<1700?(t=c-1600,e=t*t,i=t*e,120-.9808*t-.01532*e+i/7129):c<1800?(t=c-1700,e=t*t,i=t*e,n=e*e,8.83+.1603*t-.0059285*e+13336e-8*i-n/1174e3):c<1860?(t=c-1800,e=t*t,i=t*e,n=e*e,s=e*i,a=i*i,o=i*n,13.72-.332447*t+.0068612*e+.0041116*i-37436e-8*n+121272e-10*s-1699e-10*a+875e-12*o):c<1900?(t=c-1860,e=t*t,i=t*e,n=e*e,s=e*i,7.62+.5737*t-.251754*e+.01680668*i-.0004473624*n+s/233174):c<1920?(t=c-1900,e=t*t,i=t*e,n=e*e,-2.79+1.494119*t-.0598939*e+.0061966*i-197e-6*n):c<1941?(t=c-1920,e=t*t,i=t*e,21.2+.84493*t-.0761*e+.0020936*i):c<1961?(t=c-1950,e=t*t,i=t*e,29.07+.407*t-e/233+i/2547):c<1986?(t=c-1975,e=t*t,i=t*e,45.45+1.067*t-e/260-i/718):c<2005?(t=c-2e3,e=t*t,i=t*e,n=e*e,s=e*i,63.86+.3345*t-.060374*e+.0017275*i+651814e-9*n+2373599e-11*s):c<2050?(t=c-2e3,62.92+.32217*t+.005589*t*t):c<2150?(t=(c-1820)/100,-20+32*t*t-.5628*(2150-c)):(t=(c-1820)/100,-20+32*t*t)}let jb=Jb;function Kp(r){return r+jb(r)/86400}class Rr{constructor(t){if(t instanceof Rr){this.date=t.date,this.ut=t.ut,this.tt=t.tt;return}const e=1e3*3600*24;if(t instanceof Date&&Number.isFinite(t.getTime())){this.date=t,this.ut=(t.getTime()-qp.getTime())/e,this.tt=Kp(this.ut);return}if(Number.isFinite(t)){this.date=new Date(qp.getTime()+t*e),this.ut=t,this.tt=Kp(this.ut);return}throw"Argument must be a Date object, an AstroTime object, or a numeric UTC Julian date."}static FromTerrestrialTime(t){let e=new Rr(t);for(;;){const i=t-e.tt;if(Math.abs(i)<1e-12)return e;e=e.AddDays(i)}}toString(){return this.date.toISOString()}AddDays(t){return new Rr(this.ut+t)}}function $e(r){return r instanceof Rr?r:new Rr(r)}function Qb(r){function t(d){return d%Gb*gr}const e=r.tt/36525,i=t(128710479305e-5+e*1295965810481e-4),n=t(335779.526232+e*17395272628478e-4),s=t(107226070369e-5+e*1602961601209e-3),a=t(450160.398036-e*69628905431e-4);let o=Math.sin(a),c=Math.cos(a),l=(-172064161-174666*e)*o+33386*c,h=(92052331+9086*e)*c+15377*o,u=2*(n-s+a);return o=Math.sin(u),c=Math.cos(u),l+=(-13170906-1675*e)*o-13696*c,h+=(5730336-3015*e)*c-4587*o,u=2*(n+a),o=Math.sin(u),c=Math.cos(u),l+=(-2276413-234*e)*o+2796*c,h+=(978459-485*e)*c+1374*o,u=2*a,o=Math.sin(u),c=Math.cos(u),l+=(2074554+207*e)*o-698*c,h+=(-897492+470*e)*c-291*o,o=Math.sin(i),c=Math.cos(i),l+=(1475877-3633*e)*o+11817*c,h+=(73871-184*e)*c-1924*o,{dpsi:-135e-6+l*1e-7,deps:388e-6+h*1e-7}}function v1(r){var t=r.tt/36525,e=((((-434e-10*t-576e-9)*t+.0020034)*t-1831e-7)*t-46.836769)*t+84381.406;return e/3600}var Uc;function Zo(r){if(!Uc||Math.abs(Uc.tt-r.tt)>1e-6){const t=Qb(r),e=v1(r),i=e+t.deps/3600;Uc={tt:r.tt,dpsi:t.dpsi,deps:t.deps,ee:t.dpsi*Math.cos(e*Ee)/15,mobl:e,tobl:i}}return Uc}function tw(r,t){const e=r*Ee,i=Math.cos(e),n=Math.sin(e);return[t[0],t[1]*i-t[2]*n,t[1]*n+t[2]*i]}function ew(r,t){return tw(v1(r),t)}function iw(r){const t=r.tt/36525;function e(Ct,_t){const kt=[];let zt;for(zt=0;zt<=_t-Ct;++zt)kt.push(0);return{min:Ct,array:kt}}function i(Ct,_t,kt,zt){const Bt=[];for(let Me=0;Me<=_t-Ct;++Me)Bt.push(e(kt,zt));return{min:Ct,array:Bt}}function n(Ct,_t,kt){const zt=Ct.array[_t-Ct.min];return zt.array[kt-zt.min]}function s(Ct,_t,kt,zt){const Bt=Ct.array[_t-Ct.min];Bt.array[kt-Bt.min]=zt}let a,o,c,l,h,u,d,f,p,v,m,g,S,y,M,b,w,T,x,A,C,I,P,V=i(-6,6,1,4),X=i(-6,6,1,4);function L(Ct,_t){return n(V,Ct,_t)}function B(Ct,_t){return n(X,Ct,_t)}function k(Ct,_t,kt){return s(V,Ct,_t,kt)}function $(Ct,_t,kt){return s(X,Ct,_t,kt)}function tt(Ct,_t,kt,zt,Bt){Bt(Ct*kt-_t*zt,_t*kt+Ct*zt)}function J(Ct){return Math.sin(ms*Ct)}d=t*t,p=0,P=0,m=0,g=3422.7;var it=J(.19833+.05611*t),rt=J(.27869+.04508*t),Vt=J(.16827-.36903*t),jt=J(.34734-5.37261*t),qt=J(.10498-5.37899*t),q=J(.42681-.41855*t),at=J(.14943-5.37511*t);for(T=.84*it+.31*rt+14.27*Vt+7.26*jt+.28*qt+.24*q,x=2.94*it+.31*rt+14.27*Vt+9.34*jt+1.12*qt+.83*q,A=-6.4*it-1.89*q,C=.21*it+.31*rt+14.27*Vt-88.7*jt-15.3*qt+.24*q-1.86*at,I=T-A,f=-3332e-9*J(.59734-5.37261*t)-539e-9*J(.35498-5.37899*t)-64e-9*J(.39943-5.37511*t),S=ms*lr(.60643382+1336.85522467*t-313e-8*d)+T/Hs,y=ms*lr(.37489701+1325.55240982*t+2565e-8*d)+x/Hs,M=ms*lr(.99312619+99.99735956*t-44e-8*d)+A/Hs,b=ms*lr(.25909118+1342.2278298*t-892e-8*d)+C/Hs,w=ms*lr(.82736186+1236.85308708*t-397e-8*d)+I/Hs,h=1;h<=4;++h){switch(h){case 1:c=y,o=4,l=1.000002208;break;case 2:c=M,o=3,l=.997504612-.002495388*t;break;case 3:c=b,o=4,l=1.000002708+139.978*f;break;case 4:c=w,o=6,l=1;break;default:throw`Internal error: I = ${h}`}for(k(0,h,1),k(1,h,Math.cos(c)*l),$(0,h,0),$(1,h,Math.sin(c)*l),u=2;u<=o;++u)tt(L(u-1,h),B(u-1,h),L(1,h),B(1,h),(Ct,_t)=>(k(u,h,Ct),$(u,h,_t)));for(u=1;u<=o;++u)k(-u,h,L(u,h)),$(-u,h,-B(u,h))}function nt(Ct,_t,kt,zt){for(var Bt={x:1,y:0},Me=[0,Ct,_t,kt,zt],xe=1;xe<=4;++xe)Me[xe]!==0&&tt(Bt.x,Bt.y,L(Me[xe],xe),B(Me[xe],xe),(Ke,He)=>(Bt.x=Ke,Bt.y=He));return Bt}function z(Ct,_t,kt,zt,Bt,Me,xe,Ke){var He=nt(Bt,Me,xe,Ke);p+=Ct*He.y,P+=_t*He.y,m+=kt*He.x,g+=zt*He.x}z(13.902,14.06,-.001,.2607,0,0,0,4),z(.403,-4.01,.394,.0023,0,0,0,3),z(2369.912,2373.36,.601,28.2333,0,0,0,2),z(-125.154,-112.79,-.725,-.9781,0,0,0,1),z(1.979,6.98,-.445,.0433,1,0,0,4),z(191.953,192.72,.029,3.0861,1,0,0,2),z(-8.466,-13.51,.455,-.1093,1,0,0,1),z(22639.5,22609.07,.079,186.5398,1,0,0,0),z(18.609,3.59,-.094,.0118,1,0,0,-1),z(-4586.465,-4578.13,-.077,34.3117,1,0,0,-2),z(3.215,5.44,.192,-.0386,1,0,0,-3),z(-38.428,-38.64,.001,.6008,1,0,0,-4),z(-.393,-1.43,-.092,.0086,1,0,0,-6),z(-.289,-1.59,.123,-.0053,0,1,0,4),z(-24.42,-25.1,.04,-.3,0,1,0,2),z(18.023,17.93,.007,.1494,0,1,0,1),z(-668.146,-126.98,-1.302,-.3997,0,1,0,0),z(.56,.32,-.001,-.0037,0,1,0,-1),z(-165.145,-165.06,.054,1.9178,0,1,0,-2),z(-1.877,-6.46,-.416,.0339,0,1,0,-4),z(.213,1.02,-.074,.0054,2,0,0,4),z(14.387,14.78,-.017,.2833,2,0,0,2),z(-.586,-1.2,.054,-.01,2,0,0,1),z(769.016,767.96,.107,10.1657,2,0,0,0),z(1.75,2.01,-.018,.0155,2,0,0,-1),z(-211.656,-152.53,5.679,-.3039,2,0,0,-2),z(1.225,.91,-.03,-.0088,2,0,0,-3),z(-30.773,-34.07,-.308,.3722,2,0,0,-4),z(-.57,-1.4,-.074,.0109,2,0,0,-6),z(-2.921,-11.75,.787,-.0484,1,1,0,2),z(1.267,1.52,-.022,.0164,1,1,0,1),z(-109.673,-115.18,.461,-.949,1,1,0,0),z(-205.962,-182.36,2.056,1.4437,1,1,0,-2),z(.233,.36,.012,-.0025,1,1,0,-3),z(-4.391,-9.66,-.471,.0673,1,1,0,-4),z(.283,1.53,-.111,.006,1,-1,0,4),z(14.577,31.7,-1.54,.2302,1,-1,0,2),z(147.687,138.76,.679,1.1528,1,-1,0,0),z(-1.089,.55,.021,0,1,-1,0,-1),z(28.475,23.59,-.443,-.2257,1,-1,0,-2),z(-.276,-.38,-.006,-.0036,1,-1,0,-3),z(.636,2.27,.146,-.0102,1,-1,0,-4),z(-.189,-1.68,.131,-.0028,0,2,0,2),z(-7.486,-.66,-.037,-.0086,0,2,0,0),z(-8.096,-16.35,-.74,.0918,0,2,0,-2),z(-5.741,-.04,0,-9e-4,0,0,2,2),z(.255,0,0,0,0,0,2,1),z(-411.608,-.2,0,-.0124,0,0,2,0),z(.584,.84,0,.0071,0,0,2,-1),z(-55.173,-52.14,0,-.1052,0,0,2,-2),z(.254,.25,0,-.0017,0,0,2,-3),z(.025,-1.67,0,.0031,0,0,2,-4),z(1.06,2.96,-.166,.0243,3,0,0,2),z(36.124,50.64,-1.3,.6215,3,0,0,0),z(-13.193,-16.4,.258,-.1187,3,0,0,-2),z(-1.187,-.74,.042,.0074,3,0,0,-4),z(-.293,-.31,-.002,.0046,3,0,0,-6),z(-.29,-1.45,.116,-.0051,2,1,0,2),z(-7.649,-10.56,.259,-.1038,2,1,0,0),z(-8.627,-7.59,.078,-.0192,2,1,0,-2),z(-2.74,-2.54,.022,.0324,2,1,0,-4),z(1.181,3.32,-.212,.0213,2,-1,0,2),z(9.703,11.67,-.151,.1268,2,-1,0,0),z(-.352,-.37,.001,-.0028,2,-1,0,-1),z(-2.494,-1.17,-.003,-.0017,2,-1,0,-2),z(.36,.2,-.012,-.0043,2,-1,0,-4),z(-1.167,-1.25,.008,-.0106,1,2,0,0),z(-7.412,-6.12,.117,.0484,1,2,0,-2),z(-.311,-.65,-.032,.0044,1,2,0,-4),z(.757,1.82,-.105,.0112,1,-2,0,2),z(2.58,2.32,.027,.0196,1,-2,0,0),z(2.533,2.4,-.014,-.0212,1,-2,0,-2),z(-.344,-.57,-.025,.0036,0,3,0,-2),z(-.992,-.02,0,0,1,0,2,2),z(-45.099,-.02,0,-.001,1,0,2,0),z(-.179,-9.52,0,-.0833,1,0,2,-2),z(-.301,-.33,0,.0014,1,0,2,-4),z(-6.382,-3.37,0,-.0481,1,0,-2,2),z(39.528,85.13,0,-.7136,1,0,-2,0),z(9.366,.71,0,-.0112,1,0,-2,-2),z(.202,.02,0,0,1,0,-2,-4),z(.415,.1,0,.0013,0,1,2,0),z(-2.152,-2.26,0,-.0066,0,1,2,-2),z(-1.44,-1.3,0,.0014,0,1,-2,2),z(.384,-.04,0,0,0,1,-2,-2),z(1.938,3.6,-.145,.0401,4,0,0,0),z(-.952,-1.58,.052,-.013,4,0,0,-2),z(-.551,-.94,.032,-.0097,3,1,0,0),z(-.482,-.57,.005,-.0045,3,1,0,-2),z(.681,.96,-.026,.0115,3,-1,0,0),z(-.297,-.27,.002,-9e-4,2,2,0,-2),z(.254,.21,-.003,0,2,-2,0,-2),z(-.25,-.22,.004,.0014,1,3,0,-2),z(-3.996,0,0,4e-4,2,0,2,0),z(.557,-.75,0,-.009,2,0,2,-2),z(-.459,-.38,0,-.0053,2,0,-2,2),z(-1.298,.74,0,4e-4,2,0,-2,0),z(.538,1.14,0,-.0141,2,0,-2,-2),z(.263,.02,0,0,1,1,2,0),z(.426,.07,0,-6e-4,1,1,-2,-2),z(-.304,.03,0,3e-4,1,-1,2,0),z(-.372,-.19,0,-.0027,1,-1,-2,2),z(.418,0,0,0,0,0,4,0),z(-.33,-.04,0,0,3,0,2,0);function Tt(Ct,_t,kt,zt,Bt){return Ct*nt(_t,kt,zt,Bt).y}v=0,v+=Tt(-526.069,0,0,1,-2),v+=Tt(-3.352,0,0,1,-4),v+=Tt(44.297,1,0,1,-2),v+=Tt(-6,1,0,1,-4),v+=Tt(20.599,-1,0,1,0),v+=Tt(-30.598,-1,0,1,-2),v+=Tt(-24.649,-2,0,1,0),v+=Tt(-2,-2,0,1,-2),v+=Tt(-22.571,0,1,1,-2),v+=Tt(10.985,0,-1,1,-2),p+=.82*J(.7736-62.5512*t)+.31*J(.0466-125.1025*t)+.35*J(.5785-25.1042*t)+.66*J(.4591+1335.8075*t)+.64*J(.313-91.568*t)+1.14*J(.148+1331.2898*t)+.21*J(.5918+1056.5859*t)+.44*J(.5784+1322.8595*t)+.24*J(.2275-5.7374*t)+.28*J(.2965+2.6929*t)+.33*J(.3132+6.3368*t),a=b+P/Hs;let Nt=(1.000002708+139.978*f)*(18518.511+1.189+m)*Math.sin(a)-6.24*Math.sin(3*a)+v;return{geo_eclip_lon:ms*lr((S+p/Hs)/ms),geo_eclip_lat:Math.PI/(180*3600)*Nt,distance_au:Hs*Yb/(.999953253*g)}}function M1(r,t){return[r.rot[0][0]*t[0]+r.rot[1][0]*t[1]+r.rot[2][0]*t[2],r.rot[0][1]*t[0]+r.rot[1][1]*t[1]+r.rot[2][1]*t[2],r.rot[0][2]*t[0]+r.rot[1][2]*t[1]+r.rot[2][2]*t[2]]}function Pl(r,t,e){const i=C0(t,e);return M1(i,r)}function C0(r,t){const e=r.tt/36525;let i=84381.406,n=((((-951e-10*e+132851e-9)*e-.00114045)*e-1.0790069)*e+5038.481507)*e,s=((((3337e-10*e-467e-9)*e-.00772503)*e+.0512623)*e-.025754)*e+i,a=((((-56e-9*e+170663e-9)*e-.00121197)*e-2.3814292)*e+10.556403)*e;i*=gr,n*=gr,s*=gr,a*=gr;const o=Math.sin(i),c=Math.cos(i),l=Math.sin(-n),h=Math.cos(-n),u=Math.sin(-s),d=Math.cos(-s),f=Math.sin(a),p=Math.cos(a),v=p*h-l*f*d,m=p*l*c+f*d*h*c-o*f*u,g=p*l*o+f*d*h*o+c*f*u,S=-f*h-l*p*d,y=-f*l*c+p*d*h*c-o*p*u,M=-f*l*o+p*d*h*o+c*p*u,b=l*u,w=-u*h*c-o*d,T=-u*h*o+d*c;if(t===Ai.Into2000)return new aa([[v,m,g],[S,y,M],[b,w,T]]);if(t===Ai.From2000)return new aa([[v,S,b],[m,y,w],[g,M,T]]);throw"Invalid precess direction"}function nw(r){const t=.779057273264+.00273781191135448*r.ut,e=r.ut%1;let i=360*((t+e)%1);return i<0&&(i+=360),i}let kc;function Kl(r){if(!kc||kc.tt!==r.tt){const t=r.tt/36525;let e=15*Zo(r).ee;const i=nw(r);let s=((e+.014506+((((-368e-10*t-29956e-9)*t-44e-8)*t+1.3915817)*t+4612.156534)*t)/3600+i)%360/15;s<0&&(s+=24),kc={tt:r.tt,st:s}}return kc.st}function sw(r){const t=$e(r);return Kl(t)}function x1(r,t){const e=r.latitude*Ee,i=Math.sin(e),n=Math.cos(e),s=1/Math.hypot(n,Td*i),a=Xb*s,o=r.height/1e3,c=Rd*s+o,l=Rd*a+o,h=(15*t+r.longitude)*Ee,u=Math.sin(h),d=Math.cos(h);return{pos:[c*n*d/Sa,c*n*u/Sa,l*i/Sa],vel:[-$p*c*n*u*86400/Sa,$p*c*n*d*86400/Sa,0]}}function Ld(r,t,e){const i=P0(t,e);return M1(i,r)}function P0(r,t){const e=Zo(r),i=e.mobl*Ee,n=e.tobl*Ee,s=e.dpsi*gr,a=Math.cos(i),o=Math.sin(i),c=Math.cos(n),l=Math.sin(n),h=Math.cos(s),u=Math.sin(s),d=h,f=-u*a,p=-u*o,v=u*c,m=h*a*c+o*l,g=h*o*c-a*l,S=u*l,y=h*a*l-o*c,M=h*o*l+a*c;if(t===Ai.From2000)return new aa([[d,v,S],[f,m,y],[p,g,M]]);if(t===Ai.Into2000)return new aa([[d,f,p],[v,m,g],[S,y,M]]);throw"Invalid precess direction"}function L0(r,t,e){return e===Ai.Into2000?Pl(Ld(r,t,e),t,e):Ld(Pl(r,t,e),t,e)}function aw(r,t){const e=Kl(r),i=x1(t,e).pos;return L0(i,r,Ai.Into2000)}class Ue{constructor(t,e,i,n){this.x=t,this.y=e,this.z=i,this.t=n}Length(){return Math.hypot(this.x,this.y,this.z)}}class Qs{constructor(t,e,i,n,s,a,o){this.x=t,this.y=e,this.z=i,this.vx=n,this.vy=s,this.vz=a,this.t=o}}class Zl{constructor(t,e,i){this.lat=Si(t),this.lon=Si(e),this.dist=Si(i)}}class Od{constructor(t,e,i,n){this.ra=Si(t),this.dec=Si(e),this.dist=Si(i),this.vec=n}}class aa{constructor(t){this.rot=t}}class rw{constructor(t,e,i,n){this.azimuth=Si(t),this.altitude=Si(e),this.ra=Si(i),this.dec=Si(n)}}class ow{constructor(t,e,i){this.vec=t,this.elat=Si(e),this.elon=Si(i)}}function y1(r,t){return new Ue(r[0],r[1],r[2],t)}function cw(r,t){const e=y1(r,t),i=e.x*e.x+e.y*e.y,n=Math.sqrt(i+e.z*e.z);if(i===0){if(e.z===0)throw"Indeterminate sky coordinates";return new Od(0,e.z<0?-90:90,n,e)}let s=p1*Math.atan2(e.y,e.x);s<0&&(s+=24);const a=os*Math.atan2(r[2],Math.sqrt(i));return new Od(s,a,n,e)}function Yh(r,t){const e=r*Ee,i=Math.cos(e),n=Math.sin(e);return[i*t[0]+n*t[1],i*t[1]-n*t[0],t[2]]}function _1(r,t,e,i,n){let s=$e(r);O0(t),Si(e),Si(i);const a=Math.sin(t.latitude*Ee),o=Math.cos(t.latitude*Ee),c=Math.sin(t.longitude*Ee),l=Math.cos(t.longitude*Ee),h=Math.sin(i*Ee),u=Math.cos(i*Ee),d=Math.sin(e*Yp),f=Math.cos(e*Yp);let p=[o*l,o*c,a],v=[-a*l,-a*c,o],m=[c,-l,0];const g=-15*Kl(s);let S=Yh(g,p),y=Yh(g,v),M=Yh(g,m),b=[u*f,u*d,h];const w=b[0]*S[0]+b[1]*S[1]+b[2]*S[2],T=b[0]*y[0]+b[1]*y[1]+b[2]*y[2],x=b[0]*M[0]+b[1]*M[1]+b[2]*M[2];let A=Math.hypot(T,x),C;A>0?(C=-os*Math.atan2(x,T),C<0&&(C+=360)):C=0;let I=os*Math.atan2(A,w),P=e,V=i;if(n){let X=I,L=I1(n,90-I);if(I-=L,L>0&&I>3e-4){const B=Math.sin(I*Ee),k=Math.cos(I*Ee),$=Math.sin(X*Ee),tt=Math.cos(X*Ee),J=[];for(let it=0;it<3;++it)J.push((b[it]-tt*S[it])/$*B+S[it]*k);A=Math.hypot(J[0],J[1]),A>0?(P=p1*Math.atan2(J[1],J[0]),P<0&&(P+=24)):P=0,V=os*Math.atan2(J[2],A)}}return new rw(C,90-I,P,V)}function O0(r){if(!(r instanceof N0))throw`Not an instance of the Observer class: ${r}`;if(Si(r.latitude),Si(r.longitude),Si(r.height),r.latitude<-90||r.latitude>90)throw`Latitude ${r.latitude} is out of range. Must be -90..+90.`;return r}class N0{constructor(t,e,i){this.latitude=t,this.longitude=e,this.height=i,O0(this)}}function lw(r){const t=$e(r).AddDays(-1/R0),e=Ir(ss.Earth,t),i=[-e.x,-e.y,-e.z],[n,s,a]=L0(i,t,Ai.From2000),o=Ee*Zo(t).tobl,c=Math.cos(o),l=Math.sin(o),h=new Ue(n,s,a,t);return S1(h,c,l)}function hw(r,t,e,i,n){O0(e),Cl(i),Cl(n);const s=$e(t),a=aw(s,e),o=Wd(r,s,n),c=[o.x-a[0],o.y-a[1],o.z-a[2]],l=L0(c,s,Ai.From2000);return cw(l,s)}function uw(r,t,e){const i=$e(r),n=Kl(i);let s=x1(t,n).pos;return y1(s,i)}function S1(r,t,e){const i=r.x,n=r.y*t+r.z*e,s=-r.y*e+r.z*t,a=Math.hypot(i,n);let o=0;a>0&&(o=os*Math.atan2(n,i),o<0&&(o+=360));let c=os*Math.atan2(s,a),l=new Ue(i,n,s,r.t);return new ow(l,c,o)}function Nd(r){const t=Zo(r.t),e=[r.x,r.y,r.z],i=Pl(e,r.t,Ai.From2000),[n,s,a]=Ld(i,r.t,Ai.From2000),o=new Ue(n,s,a,r.t),c=t.tobl*Ee;return S1(o,Math.cos(c),Math.sin(c))}function Ur(r){const t=$e(r),e=iw(t),i=e.distance_au*Math.cos(e.geo_eclip_lat),n=[i*Math.cos(e.geo_eclip_lon),i*Math.sin(e.geo_eclip_lon),e.distance_au*Math.sin(e.geo_eclip_lat)],s=ew(t,n),a=Pl(s,t,Ai.Into2000);return new Ue(a[0],a[1],a[2],t)}function b1(r){const t=$e(r),e=1e-5,i=t.AddDays(-e),n=t.AddDays(+e),s=Ur(i),a=Ur(n);return new Qs((s.x+a.x)/2,(s.y+a.y)/2,(s.z+a.z)/2,(a.x-s.x)/(2*e),(a.y-s.y)/(2*e),(a.z-s.z)/(2*e),t)}function dw(r){const t=$e(r),e=b1(t),i=1+g1;return new Qs(e.x/i,e.y/i,e.z/i,e.vx/i,e.vy/i,e.vz/i,t)}function Dr(r,t,e){let i=1,n=0;for(let s of r){let a=0;for(let[c,l,h]of s)a+=c*Math.cos(l+t*h);let o=i*a;e&&(o%=ms),n+=o,i*=t}return n}function qh(r,t){let e=1,i=0,n=0,s=0;for(let a of r){let o=0,c=0;for(let[l,h,u]of a){let d=h+t*u;o+=l*u*Math.sin(d),s>0&&(c+=l*Math.cos(d))}n+=s*i*c-e*o,i=e,e*=t,++s}return n}const xo=365250,Fd=0,Ud=1,kd=2;function zd(r){return new Li(r[0]+44036e-11*r[1]-190919e-12*r[2],-479966e-12*r[0]+.917482137087*r[1]-.397776982902*r[2],.397776982902*r[1]+.917482137087*r[2])}function w1(r,t,e){const i=e*Math.cos(t),n=Math.cos(r),s=Math.sin(r);return[i*n,i*s,e*Math.sin(t)]}function Ir(r,t){const e=t.tt/xo,i=Dr(r[Fd],e,!0),n=Dr(r[Ud],e,!1),s=Dr(r[kd],e,!1),a=w1(i,n,s);return zd(a).ToAstroVector(t)}function Bd(r,t){const e=t/xo,i=Dr(r[Fd],e,!0),n=Dr(r[Ud],e,!1),s=Dr(r[kd],e,!1),a=qh(r[Fd],e),o=qh(r[Ud],e),c=qh(r[kd],e),l=Math.cos(i),h=Math.sin(i),u=Math.cos(n),d=Math.sin(n),f=+(c*u*l)-s*d*l*o-s*u*h*a,p=+(c*u*h)-s*d*h*o+s*u*l*a,v=+(c*d)+s*u*o,m=w1(i,n,s),g=[f/xo,p/xo,v/xo],S=zd(m),y=zd(g);return new Ua(t,S,y)}function zc(r,t,e,i){const n=i/(i+D0),s=Ir(ss[e],t);r.x+=n*s.x,r.y+=n*s.y,r.z+=n*s.z}function fw(r){const t=new Ue(0,0,0,r);return zc(t,r,wt.Jupiter,Dd),zc(t,r,wt.Saturn,Id),zc(t,r,wt.Uranus,Cd),zc(t,r,wt.Neptune,Pd),t}const Hd=51,pw=29200,vr=146,gs=201,Ta=[[-73e4,[-26.118207232108,-14.376168177825,3.384402515299],[.0016339372163656,-.0027861699588508,-.0013585880229445]],[-700800,[41.974905202127,-.448502952929,-12.770351505989],[.00073458569351457,.0022785014891658,.00048619778602049]],[-671600,[14.706930780744,44.269110540027,9.353698474772],[-.00210001479998,.00022295915939915,.00070143443551414]],[-642400,[-29.441003929957,-6.43016153057,6.858481011305],[.00084495803960544,-.0030783914758711,-.0012106305981192]],[-613200,[39.444396946234,-6.557989760571,-13.913760296463],[.0011480029005873,.0022400006880665,.00035168075922288]],[-584e3,[20.2303809507,43.266966657189,7.382966091923],[-.0019754081700585,.00053457141292226,.00075929169129793]],[-554800,[-30.65832536462,2.093818874552,9.880531138071],[61010603013347e-18,-.0031326500935382,-.00099346125151067]],[-525600,[35.737703251673,-12.587706024764,-14.677847247563],[.0015802939375649,.0021347678412429,.00019074436384343]],[-496400,[25.466295188546,41.367478338417,5.216476873382],[-.0018054401046468,.0008328308359951,.00080260156912107]],[-467200,[-29.847174904071,10.636426313081,12.297904180106],[-.00063257063052907,-.0029969577578221,-.00074476074151596]],[-438e3,[30.774692107687,-18.236637015304,-14.945535879896],[.0020113162005465,.0019353827024189,-20937793168297e-19]],[-408800,[30.243153324028,38.656267888503,2.938501750218],[-.0016052508674468,.0011183495337525,.00083333973416824]],[-379600,[-27.288984772533,18.643162147874,14.023633623329],[-.0011856388898191,-.0027170609282181,-.00049015526126399]],[-350400,[24.519605196774,-23.245756064727,-14.626862367368],[.0024322321483154,.0016062008146048,-.00023369181613312]],[-321200,[34.505274805875,35.125338586954,.557361475637],[-.0013824391637782,.0013833397561817,.00084823598806262]],[-292e3,[-23.275363915119,25.818514298769,15.055381588598],[-.0016062295460975,-.0023395961498533,-.00024377362639479]],[-262800,[17.050384798092,-27.180376290126,-13.608963321694],[.0028175521080578,.0011358749093955,-.00049548725258825]],[-233600,[38.093671910285,30.880588383337,-1.843688067413],[-.0011317697153459,.0016128814698472,.00084177586176055]],[-204400,[-18.197852930878,31.932869934309,15.438294826279],[-.0019117272501813,-.0019146495909842,-19657304369835e-18]],[-175200,[8.528924039997,-29.618422200048,-11.805400994258],[.0031034370787005,.0005139363329243,-.00077293066202546]],[-146e3,[40.94685725864,25.904973592021,-4.256336240499],[-.00083652705194051,.0018129497136404,.0008156422827306]],[-116800,[-12.326958895325,36.881883446292,15.217158258711],[-.0021166103705038,-.001481442003599,.00017401209844705]],[-87600,[-.633258375909,-30.018759794709,-9.17193287495],[.0032016994581737,-.00025279858672148,-.0010411088271861]],[-58400,[42.936048423883,20.344685584452,-6.588027007912],[-.00050525450073192,.0019910074335507,.00077440196540269]],[-29200,[-5.975910552974,40.61180995846,14.470131723673],[-.0022184202156107,-.0010562361130164,.00033652250216211]],[0,[-9.875369580774,-27.978926224737,-5.753711824704],[.0030287533248818,-.0011276087003636,-.0012651326732361]],[29200,[43.958831986165,14.214147973292,-8.808306227163],[-.00014717608981871,.0021404187242141,.00071486567806614]],[58400,[.67813676352,43.094461639362,13.243238780721],[-.0022358226110718,-.00063233636090933,.00047664798895648]],[87600,[-18.282602096834,-23.30503958666,-1.766620508028],[.0025567245263557,-.0019902940754171,-.0013943491701082]],[116800,[43.873338744526,7.700705617215,-10.814273666425],[.00023174803055677,.0022402163127924,.00062988756452032]],[146e3,[7.392949027906,44.382678951534,11.629500214854],[-.002193281545383,-.00021751799585364,.00059556516201114]],[175200,[-24.981690229261,-16.204012851426,2.466457544298],[.001819398914958,-.0026765419531201,-.0013848283502247]],[204400,[42.530187039511,.845935508021,-12.554907527683],[.00065059779150669,.0022725657282262,.00051133743202822]],[233600,[13.999526486822,44.462363044894,9.669418486465],[-.0021079296569252,.00017533423831993,.00069128485798076]],[262800,[-29.184024803031,-7.371243995762,6.493275957928],[.00093581363109681,-.0030610357109184,-.0012364201089345]],[292e3,[39.831980671753,-6.078405766765,-13.909815358656],[.0011117769689167,.0022362097830152,.00036230548231153]],[321200,[20.294955108476,43.417190420251,7.450091985932],[-.0019742157451535,.00053102050468554,.00075938408813008]],[350400,[-30.66999230216,2.318743558955,9.973480913858],[45605107450676e-18,-.0031308219926928,-.00099066533301924]],[379600,[35.626122155983,-12.897647509224,-14.777586508444],[.0016015684949743,.0021171931182284,.00018002516202204]],[408800,[26.133186148561,41.232139187599,5.00640132622],[-.0017857704419579,.00086046232702817,.00080614690298954]],[438e3,[-29.57674022923,11.863535943587,12.631323039872],[-.00072292830060955,-.0029587820140709,-.000708242964503]],[467200,[29.910805787391,-19.159019294,-15.013363865194],[.0020871080437997,.0018848372554514,-38528655083926e-18]],[496400,[31.375957451819,38.050372720763,2.433138343754],[-.0015546055556611,.0011699815465629,.00083565439266001]],[525600,[-26.360071336928,20.662505904952,14.414696258958],[-.0013142373118349,-.0026236647854842,-.00042542017598193]],[554800,[22.599441488648,-24.508879898306,-14.484045731468],[.0025454108304806,.0014917058755191,-.00030243665086079]],[584e3,[35.877864013014,33.894226366071,-.224524636277],[-.0012941245730845,.0014560427668319,.00084762160640137]],[613200,[-21.538149762417,28.204068269761,15.321973799534],[-.001731211740901,-.0021939631314577,-.0001631691327518]],[642400,[13.971521374415,-28.339941764789,-13.083792871886],[.0029334630526035,.00091860931752944,-.00059939422488627]],[671600,[39.526942044143,28.93989736011,-2.872799527539],[-.0010068481658095,.001702113288809,.00083578230511981]],[700800,[-15.576200701394,34.399412961275,15.466033737854],[-.0020098814612884,-.0017191109825989,70414782780416e-18]],[73e4,[4.24325283709,-30.118201690825,-10.707441231349],[.0031725847067411,.0001609846120227,-.00090672150593868]]];class Li{constructor(t,e,i){this.x=t,this.y=e,this.z=i}clone(){return new Li(this.x,this.y,this.z)}ToAstroVector(t){return new Ue(this.x,this.y,this.z,t)}static zero(){return new Li(0,0,0)}quadrature(){return this.x*this.x+this.y*this.y+this.z*this.z}add(t){return new Li(this.x+t.x,this.y+t.y,this.z+t.z)}sub(t){return new Li(this.x-t.x,this.y-t.y,this.z-t.z)}incr(t){this.x+=t.x,this.y+=t.y,this.z+=t.z}decr(t){this.x-=t.x,this.y-=t.y,this.z-=t.z}mul(t){return new Li(t*this.x,t*this.y,t*this.z)}div(t){return new Li(this.x/t,this.y/t,this.z/t)}mean(t){return new Li((this.x+t.x)/2,(this.y+t.y)/2,(this.z+t.z)/2)}neg(){return new Li(-this.x,-this.y,-this.z)}}class Ua{constructor(t,e,i){this.tt=t,this.r=e,this.v=i}clone(){return new Ua(this.tt,this.r,this.v)}sub(t){return new Ua(this.tt,this.r.sub(t.r),this.v.sub(t.v))}}function mw(r){let[t,[e,i,n],[s,a,o]]=r;return new Ua(t,new Li(e,i,n),new Li(s,a,o))}function Bc(r,t,e,i){const n=i/(i+D0),s=Bd(ss[e],t);return r.r.incr(s.r.mul(n)),r.v.incr(s.v.mul(n)),s}function ro(r,t,e){const i=e.sub(r),n=i.quadrature();return i.mul(t/(n*Math.sqrt(n)))}class Jl{constructor(t){let e=new Ua(t,new Li(0,0,0),new Li(0,0,0));this.Jupiter=Bc(e,t,wt.Jupiter,Dd),this.Saturn=Bc(e,t,wt.Saturn,Id),this.Uranus=Bc(e,t,wt.Uranus,Cd),this.Neptune=Bc(e,t,wt.Neptune,Pd),this.Jupiter.r.decr(e.r),this.Jupiter.v.decr(e.v),this.Saturn.r.decr(e.r),this.Saturn.v.decr(e.v),this.Uranus.r.decr(e.r),this.Uranus.v.decr(e.v),this.Neptune.r.decr(e.r),this.Neptune.v.decr(e.v),this.Sun=new Ua(t,e.r.mul(-1),e.v.mul(-1))}Acceleration(t){let e=ro(t,D0,this.Sun.r);return e.incr(ro(t,Dd,this.Jupiter.r)),e.incr(ro(t,Id,this.Saturn.r)),e.incr(ro(t,Cd,this.Uranus.r)),e.incr(ro(t,Pd,this.Neptune.r)),e}}class jl{constructor(t,e,i,n){this.tt=t,this.r=e,this.v=i,this.a=n}clone(){return new jl(this.tt,this.r.clone(),this.v.clone(),this.a.clone())}}class E1{constructor(t,e){this.bary=t,this.grav=e}}function Ll(r,t,e,i){return new Li(t.x+r*(e.x+r*i.x/2),t.y+r*(e.y+r*i.y/2),t.z+r*(e.z+r*i.z/2))}function Zp(r,t,e){return new Li(t.x+r*e.x,t.y+r*e.y,t.z+r*e.z)}function Gd(r,t){const e=r-t.tt,i=new Jl(r),n=Ll(e,t.r,t.v,t.a),s=i.Acceleration(n).mean(t.a),a=Ll(e,t.r,t.v,s),o=t.v.add(s.mul(e)),c=i.Acceleration(a),l=new jl(r,a,o,c);return new E1(i,l)}const gw=[];function A1(r,t){const e=Math.floor(r);return e<0?0:e>=t?t-1:e}function Vd(r){const t=mw(r),e=new Jl(t.tt),i=t.r.add(e.Sun.r),n=t.v.add(e.Sun.v),s=e.Acceleration(i),a=new jl(t.tt,i,n,s);return new E1(e,a)}function vw(r,t){const e=Ta[0][0];if(t<e||t>Ta[Hd-1][0])return null;const i=A1((t-e)/pw,Hd-1);if(!r[i]){const s=r[i]=[];s[0]=Vd(Ta[i]).grav,s[gs-1]=Vd(Ta[i+1]).grav;let a,o=s[0].tt;for(a=1;a<gs-1;++a)s[a]=Gd(o+=vr,s[a-1]).grav;o=s[gs-1].tt;var n=[];for(n[gs-1]=s[gs-1],a=gs-2;a>0;--a)n[a]=Gd(o-=vr,n[a+1]).grav;for(a=gs-2;a>0;--a){const c=a/(gs-1);s[a].r=s[a].r.mul(1-c).add(n[a].r.mul(c)),s[a].v=s[a].v.mul(1-c).add(n[a].v.mul(c)),s[a].a=s[a].a.mul(1-c).add(n[a].a.mul(c))}}return r[i]}function Jp(r,t,e){let i=Vd(r);const n=Math.ceil((t-i.grav.tt)/e);for(let s=0;s<n;++s)i=Gd(s+1===n?t:i.grav.tt+e,i.grav);return i}function T1(r,t){let e,i,n;const s=vw(gw,r.tt);if(s){const a=A1((r.tt-s[0].tt)/vr,gs-1),o=s[a],c=s[a+1],l=o.a.mean(c.a),h=Ll(r.tt-o.tt,o.r,o.v,l),u=Zp(r.tt-o.tt,o.v,l),d=Ll(r.tt-c.tt,c.r,c.v,l),f=Zp(r.tt-c.tt,c.v,l),p=(r.tt-o.tt)/vr;e=h.mul(1-p).add(d.mul(p)),i=u.mul(1-p).add(f.mul(p))}else{let a;r.tt<Ta[0][0]?a=Jp(Ta[0],r.tt,-vr):a=Jp(Ta[Hd-1],r.tt,+vr),e=a.grav.r,i=a.grav.v,n=a.bary}return n||(n=new Jl(r.tt)),e=e.sub(n.Sun.r),i=i.sub(n.Sun.v),new Qs(e.x,e.y,e.z,i.x,i.y,i.z,r)}function ia(r,t){var e=$e(t);if(r in ss)return Ir(ss[r],e);if(r===wt.Pluto){const a=T1(e);return new Ue(a.x,a.y,a.z,e)}if(r===wt.Sun)return new Ue(0,0,0,e);if(r===wt.Moon){var i=Ir(ss.Earth,e),n=Ur(e);return new Ue(i.x+n.x,i.y+n.y,i.z+n.z,e)}if(r===wt.EMB){const a=Ir(ss.Earth,e),o=Ur(e),c=1+g1;return new Ue(a.x+o.x/c,a.y+o.y/c,a.z+o.z/c,e)}if(r===wt.SSB)return fw(e);const s=I0(r);if(s){const a=new Zl(s.dec,15*s.ra,s.dist);return F0(a,e)}throw`HelioVector: Unknown body "${r}"`}function Mw(r,t){let e=t,i=0;for(let n=0;n<10;++n){const s=r(e),a=s.Length()/R0;if(a>1)throw"Object is too distant for light-travel solver.";const o=t.AddDays(-a);if(i=Math.abs(o.tt-e.tt),i<1e-9)return s;e=o}throw`Light-travel time solver did not converge: dt = ${i}`}class xw{constructor(t,e,i,n){this.observerBody=t,this.targetBody=e,this.aberration=i,this.observerPos=n}Position(t){this.aberration&&(this.observerPos=ia(this.observerBody,t));const e=ia(this.targetBody,t);return new Ue(e.x-this.observerPos.x,e.y-this.observerPos.y,e.z-this.observerPos.z,t)}}function yw(r,t,e,i){Cl(i);const n=$e(r);if(I0(e)){const o=ia(e,n);if(i){const l=Sw(t,n),h=new Ue(o.x-l.x,o.y-l.y,o.z-l.z,n),u=R0/h.Length();return new Ue(h.x+l.vx/u,h.y+l.vy/u,h.z+l.vz/u,n)}const c=ia(t,n);return new Ue(o.x-c.x,o.y-c.y,o.z-c.z,n)}let s;i?s=new Ue(0,0,0,n):s=ia(t,n);const a=new xw(t,e,i,s);return Mw(o=>a.Position(o),n)}function Wd(r,t,e){Cl(e);const i=$e(t);switch(r){case wt.Earth:return new Ue(0,0,0,i);case wt.Moon:return Ur(i);default:const n=yw(i,wt.Earth,r,e);return n.t=i,n}}function _w(r,t){return new Qs(r.r.x,r.r.y,r.r.z,r.v.x,r.v.y,r.v.z,t)}function Sw(r,t){const e=$e(t);switch(r){case wt.Sun:return new Qs(0,0,0,0,0,0,e);case wt.SSB:const i=new Jl(e.tt);return new Qs(-i.Sun.r.x,-i.Sun.r.y,-i.Sun.r.z,-i.Sun.v.x,-i.Sun.v.y,-i.Sun.v.z,e);case wt.Mercury:case wt.Venus:case wt.Earth:case wt.Mars:case wt.Jupiter:case wt.Saturn:case wt.Uranus:case wt.Neptune:const n=Bd(ss[r],e.tt);return _w(n,e);case wt.Pluto:return T1(e);case wt.Moon:case wt.EMB:const s=Bd(ss.Earth,e.tt),a=r==wt.Moon?b1(e):dw(e);return new Qs(a.x+s.r.x,a.y+s.r.y,a.z+s.r.z,a.vx+s.v.x,a.vy+s.v.y,a.vz+s.v.z,e);default:if(I0(r)){const o=ia(r,e);return new Qs(o.x,o.y,o.z,0,0,0,e)}throw`HelioState: Unsupported body "${r}"`}}function bw(r){for(;r<0;)r+=360;for(;r>=360;)r-=360;return r}function ww(r,t,e){if(r===wt.Earth||t===wt.Earth)throw"The Earth does not have a longitude as seen from itself.";const i=$e(e),n=Wd(r,i,!1),s=Nd(n),a=Wd(t,i,!1),o=Nd(a);return bw(s.elon-o.elon)}function Ew(r,t,e,i){let n,s=0,a=0,o=0;switch(r){case wt.Mercury:n=-.6,s=4.98,a=-4.88,o=3.02;break;case wt.Venus:t<163.6?(n=-4.47,s=1.03,a=.57,o=.13):(n=.98,s=-1.02);break;case wt.Mars:n=-1.52,s=1.6;break;case wt.Jupiter:n=-9.4,s=.5;break;case wt.Uranus:n=-7.19,s=.25;break;case wt.Neptune:n=-6.87;break;case wt.Pluto:n=-1,s=4;break;default:throw`VisualMagnitude: unsupported body ${r}`}const c=t/100;let l=n+c*(s+c*(a+c*o));return l+=5*Math.log10(e*i),l}function Aw(r,t,e,i,n){const s=Nd(i),a=Ee*28.06,o=Ee*(169.51+382e-7*n.tt),c=Ee*s.elat,l=Ee*s.elon,h=Math.asin(Math.sin(c)*Math.cos(a)-Math.cos(c)*Math.sin(a)*Math.sin(l-o)),u=Math.sin(Math.abs(h));let d=-9+.044*r;return d+=u*(-2.6+1.2*u),d+=5*Math.log10(t*e),{mag:d,ring_tilt:os*h}}function Tw(r,t,e){let i=r*Ee,n=i*i,s=n*n,a=-12.717+1.49*Math.abs(i)+.0431*s;const o=385000.6/Sa;let c=e/o;return a+=5*Math.log10(t*c),a}class Rw{constructor(t,e,i,n,s,a,o,c){this.time=t,this.mag=e,this.phase_angle=i,this.helio_dist=n,this.geo_dist=s,this.gc=a,this.hc=o,this.ring_tilt=c,this.phase_fraction=(1+Math.cos(Ee*i))/2}}function R1(r,t){if(r===wt.Earth)throw"The illumination of the Earth is not defined.";const e=$e(t),i=Ir(ss.Earth,e);let n,s,a,o;r===wt.Sun?(a=new Ue(-i.x,-i.y,-i.z,e),s=new Ue(0,0,0,e),n=0):(r===wt.Moon?(a=Ur(e),s=new Ue(i.x+a.x,i.y+a.y,i.z+a.z,e)):(s=ia(r,t),a=new Ue(s.x-i.x,s.y-i.y,s.z-i.z,e)),n=qb(a,s));let c=a.Length(),l=s.Length(),h;if(r===wt.Sun)o=Wb+5*Math.log10(c);else if(r===wt.Moon)o=Tw(n,l,c);else if(r===wt.Saturn){const u=Aw(n,l,c,a,e);o=u.mag,h=u.ring_tilt}else o=Ew(r,n,l,c);return new Rw(e,o,n,l,c,a,s,h)}function Dw(r){return ww(wt.Moon,wt.Sun,r)}var jp;(function(r){r[r.Pericenter=0]="Pericenter",r[r.Apocenter=1]="Apocenter"})(jp||(jp={}));function D1(r,t){return new aa([[t.rot[0][0]*r.rot[0][0]+t.rot[1][0]*r.rot[0][1]+t.rot[2][0]*r.rot[0][2],t.rot[0][1]*r.rot[0][0]+t.rot[1][1]*r.rot[0][1]+t.rot[2][1]*r.rot[0][2],t.rot[0][2]*r.rot[0][0]+t.rot[1][2]*r.rot[0][1]+t.rot[2][2]*r.rot[0][2]],[t.rot[0][0]*r.rot[1][0]+t.rot[1][0]*r.rot[1][1]+t.rot[2][0]*r.rot[1][2],t.rot[0][1]*r.rot[1][0]+t.rot[1][1]*r.rot[1][1]+t.rot[2][1]*r.rot[1][2],t.rot[0][2]*r.rot[1][0]+t.rot[1][2]*r.rot[1][1]+t.rot[2][2]*r.rot[1][2]],[t.rot[0][0]*r.rot[2][0]+t.rot[1][0]*r.rot[2][1]+t.rot[2][0]*r.rot[2][2],t.rot[0][1]*r.rot[2][0]+t.rot[1][1]*r.rot[2][1]+t.rot[2][1]*r.rot[2][2],t.rot[0][2]*r.rot[2][0]+t.rot[1][2]*r.rot[2][1]+t.rot[2][2]*r.rot[2][2]]])}function F0(r,t){t=$e(t);const e=r.lat*Ee,i=r.lon*Ee,n=r.dist*Math.cos(e);return new Ue(n*Math.cos(i),n*Math.sin(i),r.dist*Math.sin(e),t)}function U0(r){const t=Iw(r);return new Od(t.lon/15,t.lat,t.dist,r)}function Iw(r){const t=r.x*r.x+r.y*r.y,e=Math.sqrt(t+r.z*r.z);let i,n;if(t===0){if(r.z===0)throw"Zero-length vector not allowed.";n=0,i=r.z<0?-90:90}else n=os*Math.atan2(r.y,r.x),n<0&&(n+=360),i=os*Math.atan2(r.z,Math.sqrt(t));return new Zl(i,n,e)}function I1(r,t){let e;if(Si(t),t<-90||t>90)return 0;if(r==="normal"||r==="jplhor"){let i=t;i<-1&&(i=-1),e=1.02/Math.tan((i+10.3/(i+5.11))*Ee)/60,r==="normal"&&t<-1&&(e*=(t+90)/89)}else if(!r)e=0;else throw`Invalid refraction option: ${r}`;return e}function Cr(r,t){return new Ue(r.rot[0][0]*t.x+r.rot[1][0]*t.y+r.rot[2][0]*t.z,r.rot[0][1]*t.x+r.rot[1][1]*t.y+r.rot[2][1]*t.z,r.rot[0][2]*t.x+r.rot[1][2]*t.y+r.rot[2][2]*t.z,t.t)}function Cw(){return new aa([[1,0,0],[0,.9174821430670688,-.3977769691083922],[0,.3977769691083922,.9174821430670688]])}function Pw(){return new aa([[1,0,0],[0,.9174821430670688,.3977769691083922],[0,-.3977769691083922,.9174821430670688]])}function C1(r){r=$e(r);const t=C0(r,Ai.From2000),e=P0(r,Ai.From2000);return D1(t,e)}function Lw(r){r=$e(r);const t=P0(r,Ai.Into2000),e=C0(r,Ai.Into2000);return D1(t,e)}function Ow(r){const e=Zo($e(r)).tobl*Ee,i=Math.cos(e),n=Math.sin(e);return new aa([[1,0,0],[0,+i,+n],[0,-n,+i]])}var Qp;(function(r){r.Penumbral="penumbral",r.Partial="partial",r.Annular="annular",r.Total="total"})(Qp||(Qp={}));var tm;(function(r){r[r.Invalid=0]="Invalid",r[r.Ascending=1]="Ascending",r[r.Descending=-1]="Descending"})(tm||(tm={}));const Nw=["Venus","Mars","Jupiter","Saturn"];function P1(r){return new N0(r.lat,r.lng,r.elevationM)}function k0(r,t,e,i,n=!0){const s=_1(e,P1(i),r,t,n?"normal":void 0);return{altitudeDeg:s.altitude,azimuthDeg:s.azimuth}}class Pn{up;north;west;constructor(t,e){const i=$e(t),n=Math.sin(e.lat*vs),s=Math.cos(e.lat*vs),a=Math.sin(e.lng*vs),o=Math.cos(e.lng*vs),c=-15*sw(i),l=Lw(i);this.up=Pn.rotate(l,Pn.spin(c,[s*o,s*a,n]),i),this.north=Pn.rotate(l,Pn.spin(c,[-n*o,-n*a,s]),i),this.west=Pn.rotate(l,Pn.spin(c,[a,-o,0]),i)}static ofJ2000(t,e,i,n,s=!0){const a=$e(i),o=F0(new Zl(e,t*15,1),a),c=U0(Cr(C1(a),o));return k0(c.ra,c.dec,i,n,s)}position(t,e){const i=Math.sin(e*vs),n=Math.cos(e*vs),s=Math.sin(t*im),a=Math.cos(t*im),o=n*a,c=n*s,l=i,h=o*this.up[0]+c*this.up[1]+l*this.up[2],u=o*this.north[0]+c*this.north[1]+l*this.north[2],d=o*this.west[0]+c*this.west[1]+l*this.west[2],f=Math.hypot(u,d);let p=0;f>0&&(p=-em*Math.atan2(d,u),p<0&&(p+=360));let v=em*Math.atan2(f,h);return v-=I1("normal",90-v),{altitudeDeg:90-v,azimuthDeg:p}}static spin(t,[e,i,n]){const s=Math.cos(t*vs),a=Math.sin(t*vs);return[s*e+a*i,s*i-a*e,n]}static rotate(t,[e,i,n],s){const a=Cr(t,new Ue(e,i,n,s));return[a.x,a.y,a.z]}}const vs=Math.PI/180,em=180/Math.PI,im=15*vs;function $h(r,t,e){const i=P1(e),n=hw(wt[r],t,i,!0,!0),s=_1(t,i,n.ra,n.dec,"normal");return{altitudeDeg:s.altitude,azimuthDeg:s.azimuth}}function Kh(r,t){return R1(wt[r],t).mag}function Fw(r){const t=Dw(r),e=R1(wt.Moon,r);return{phaseFraction:t/360,illuminatedFraction:e.phase_fraction}}const Uw=2e3,kw=3,zw=20;function Hc(r,t,e){if(r.year===void 0&&r.month===void 0&&r.day===void 0&&r.hour===void 0)return;const i=r.year!==void 0,n=r.year??Uw,s=r.month??(i?1:kw),a=r.day??(i?1:zw),o=e??Math.round(t/15);return new Date(Date.UTC(n,s-1,a,(r.hour??12)-o,r.minute??0,r.second??0))}const nm=["N","NNE","NE","ENE","E","ESE","SE","SSE","S","SSW","SW","WSW","W","WNW","NW","NNW"];class Ca{static POINT_DEG=360/16;static point(t,e=nm){const i=(t%360+360)%360,n=Math.round(i/Ca.POINT_DEG)%16;return e[n]}static POINTS=nm;static towards(t,e){return e?e.towards(Ca.point(t,e.compassPoints)):`to the ${Ca.point(t)}`}}class Kn{static ANCHOR="vec4 diffuseColor = vec4( diffuse, opacity );";static CORE=.18;static RIM=.5;static FALLOFF={core:Kn.CORE,rim:Kn.RIM};static apply(t){t.transparent=!0,t.depthWrite=!1,t.onBeforeCompile=e=>{e.fragmentShader=Kn.patch(e.fragmentShader)}}static patch(t){return t.replace(Kn.ANCHOR,`float distanceFromCentre = length( gl_PointCoord - vec2( 0.5 ) );
|
|
6178
6188
|
// Outside the inscribed circle there is no star at all — this is what kills the corners.
|
|
6179
6189
|
if ( distanceFromCentre > ${Kn.RIM.toFixed(2)} ) discard;
|
|
6180
6190
|
float glare = 1.0 - smoothstep( ${Kn.CORE.toFixed(2)}, ${Kn.RIM.toFixed(2)}, distanceFromCentre );
|
|
@@ -7190,7 +7200,7 @@ void main()
|
|
|
7190
7200
|
if (ice <= 0.0) discard;
|
|
7191
7201
|
gl_FragColor = vec4(iceHaloLight(dir, ice), 1.0);
|
|
7192
7202
|
}
|
|
7193
|
-
`,transparent:!0,blending:Ni,depthWrite:!1,side:Ve,fog:!1}),this.object=new Dt(new oi(Ci.RADIUS,64,32),this.material),this.object.renderOrder=-1,this.object.frustumCulled=!1,this.object.visible=!1;const i=this.material.uniforms;this.deckUniforms={uSource:i.uSource,uUp:i.uUp,uStrength:i.uStrength,uTint:i.uTint,uMap:i.uMap,uGain:i.uGain,uHaloShown:{value:0}}}deckUniforms;shown=!1;hostedByDeck=!1;set hosted(t){this.hostedByDeck=t,this.show(this.shown)}show(t){this.shown=t,this.object.visible=t&&!this.hostedByDeck,this.deckUniforms.uHaloShown.value=t?1:0}get awaitingFirstDisplay(){return this.tracing&&!this.everDisplayed}setUrgent(t){this.urgent=t}set onReady(t){this.onRepaint=t}update(t,e,i,n,s,a){const o=this.material.uniforms;if(i<=0){o.uStrength.value=0,this.show(!1),this.stopWork();return}o.uSource.value.set(t.x,t.y,t.z).normalize(),o.uStrength.value=i,o.uTint.value.set(n[0],n[1],n[2]),o.uIceCover.value=s.cover,o.uIceHeight.value=s.layerHeight,this.show(this.everDisplayed),this.requestMap(e,a)}requestMap(t,e){if(!(!(Math.abs(t-this.mappedAltitudeDeg)<Ci.ALTITUDE_STEP_DEG)||!(Math.abs(e-this.mappedAlignment)<Ci.ALIGNMENT_STEP))){this.next=void 0;return}if(this.tracing){if(this.tracingFor(t,e)){this.next=void 0;return}if(!(!(Math.abs(t-this.pendingAltitudeDeg)<Ci.LEAP_ALTITUDE_DEG)||!(Math.abs(e-this.pendingAlignment)<Ci.LEAP_ALIGNMENT))){this.next={sourceAltitudeDeg:t,alignment:e};return}}this.next=void 0,this.pendingAltitudeDeg=t,this.pendingAlignment=e,this.sky.begin(t,e),this.tracing=!0,this.scheduleWork()}pendingAltitudeDeg=Number.NaN;pendingAlignment=Number.NaN;next;tracingFor(t,e){return this.tracing&&Math.abs(t-this.pendingAltitudeDeg)<Ci.ALTITUDE_STEP_DEG&&Math.abs(e-this.pendingAlignment)<Ci.ALIGNMENT_STEP}scheduleWork(){if(this.workHandle!==void 0)return;const t=()=>{if(this.workHandle=void 0,!this.tracing)return;const e=performance.now(),i=this.urgent?Ci.URGENT_BUDGET_MS:Ci.BUDGET_MS;do this.sky.trace(Ci.RAYS_PER_BATCH);while(this.sky.tracedRays<Ci.RAYS&&performance.now()-e<i);if(this.sky.tracedRays>=Ci.RAYS){this.publish(),this.tracing=!1,this.mappedAltitudeDeg=this.pendingAltitudeDeg,this.mappedAlignment=this.pendingAlignment;const s=this.next;s&&this.requestMap(s.sourceAltitudeDeg,s.alignment);return}this.workHandle=requestAnimationFrame(t)};this.workHandle=requestAnimationFrame(t)}stopWork(){this.workHandle!==void 0&&cancelAnimationFrame(this.workHandle),this.workHandle=void 0,this.tracing=!1,this.next=void 0}publish(){const e=this.sky.harvest().data;for(let i=0,n=0;n<e.length;i+=4,n+=3)this.texels[i]=Fn.toHalfFloat(e[n]),this.texels[i+1]=Fn.toHalfFloat(e[n+1]),this.texels[i+2]=Fn.toHalfFloat(e[n+2]),this.texels[i+3]=1;this.texture.needsUpdate=!0,this.everDisplayed=!0,this.show(this.material.uniforms.uStrength.value>0),this.onRepaint?.()}dispose(){this.stopWork(),this.texture.dispose(),this.object.geometry.dispose(),this.material.dispose()}}class yi{static MAX_CONCURRENT=24;static POINTS=8;static SEGMENTS=yi.POINTS-1;static ACROSS=3;static VERTICES_PER_SEGMENT=(yi.ACROSS-1)*6;static RADIUS=840;static MIN_HALF_WIDTH_DEG=.05;static BRIGHT_HALF_WIDTH_DEG=.22;object;positions;colors;meteors=[];radiantAltitudeDeg=0;radiantAzimuthDeg=0;constructor(){const t=yi.MAX_CONCURRENT*yi.SEGMENTS*yi.VERTICES_PER_SEGMENT;this.positions=new Float32Array(t*3),this.colors=new Float32Array(t*3);const e=new ce;e.setAttribute("position",new ie(this.positions,3)),e.setAttribute("color",new ie(this.colors,3)),e.setDrawRange(0,0),this.object=new Dt(e,new _n({vertexColors:!0,transparent:!0,blending:Ni,depthWrite:!1,fog:!1,side:ji})),this.object.frustumCulled=!1}get schedule(){return this.meteors}setShower(t,e,i){this.meteors=t,this.radiantAltitudeDeg=e,this.radiantAzimuthDeg=i}update(t){const e=this.object.geometry;if(this.meteors.length===0){e.setDrawRange(0,0);return}const i=Pa.aliveAt(this.meteors,t).slice(0,yi.MAX_CONCURRENT);let n=0;for(const{meteor:s,progress:a}of i){const o=this.radiantOf(s);if(!o)continue;const c=hi(o.altitudeDeg,o.azimuthDeg,1),[l,h]=this.basisAround(c),u=s.fromRadiantDeg+a*s.lengthDeg,d=Math.max(s.fromRadiantDeg,u-s.lengthDeg*.6),f=Math.min(1,(1-a)*2.5),p=this.turn(l,h,s.bearingDeg),v=(.15+.85*s.brightness)*f,m=y=>v*y**1.6,g=y=>this.onSphere(c,p,d+(u-d)*y),S=y=>yi.RADIUS*((yi.MIN_HALF_WIDTH_DEG+yi.BRIGHT_HALF_WIDTH_DEG*s.brightness*y)*Math.PI/180);for(let y=1;y<yi.POINTS;y++){const M=(y-1)/yi.SEGMENTS,b=y/yi.SEGMENTS;n=this.pushRibbon(n,g(M),g(b),S(M),S(b),m(M),m(b))}}e.setDrawRange(0,n),e.getAttribute("position").needsUpdate=!0,e.getAttribute("color").needsUpdate=!0}midpointOf(t){const e=this.radiantOf(t);if(!e)return;const i=hi(e.altitudeDeg,e.azimuthDeg,1),[n,s]=this.basisAround(i),a=this.turn(n,s,t.bearingDeg),o=this.onSphere(i,a,t.fromRadiantDeg+t.lengthDeg/2),c=Math.hypot(o.x,o.y,o.z)||1;return{altitudeDeg:Math.asin(o.y/c)*180/Math.PI,azimuthDeg:(Math.atan2(o.x,-o.z)*180/Math.PI+360)%360}}radiantOf(t){return t.radiant?t.radiant:this.radiantAltitudeDeg>0?{altitudeDeg:this.radiantAltitudeDeg,azimuthDeg:this.radiantAzimuthDeg}:void 0}pushRibbon(t,e,i,n,s,a,o){const c=this.normalise(this.cross(this.normalise(e),this.normalise(this.subtract(i,e))));for(let l=0;l<yi.ACROSS-1;l++){const h=l-1,u=l,d=this.across(e,c,n,h),f=this.across(i,c,s,h),p=this.across(e,c,n,u),v=this.across(i,c,s,u),m=(g,S)=>g===0?S:0;t=this.push(t,d,m(h,a)),t=this.push(t,f,m(h,o)),t=this.push(t,p,m(u,a)),t=this.push(t,f,m(h,o)),t=this.push(t,v,m(u,o)),t=this.push(t,p,m(u,a))}return t}across(t,e,i,n){return{x:t.x+e.x*i*n,y:t.y+e.y*i*n,z:t.z+e.z*i*n}}push(t,e,i){const n=t*3;this.positions[n]=e.x,this.positions[n+1]=e.y,this.positions[n+2]=e.z;const s=At.relativeOfResponse(Math.max(0,Math.min(1,i)));return this.colors[n]=s*.9,this.colors[n+1]=s*.95,this.colors[n+2]=s,t+1}turn(t,e,i){const n=i*Math.PI/180,s=Math.cos(n),a=Math.sin(n);return{x:t.x*s+e.x*a,y:t.y*s+e.y*a,z:t.z*s+e.z*a}}onSphere(t,e,i){const n=i*Math.PI/180,s=Math.cos(n),a=Math.sin(n);return{x:(t.x*s+e.x*a)*yi.RADIUS,y:(t.y*s+e.y*a)*yi.RADIUS,z:(t.z*s+e.z*a)*yi.RADIUS}}basisAround(t){const e=Math.abs(t.y)<.9?{x:0,y:1,z:0}:{x:1,y:0,z:0},i=this.normalise(this.cross(t,e));return[i,this.normalise(this.cross(t,i))]}subtract(t,e){return{x:t.x-e.x,y:t.y-e.y,z:t.z-e.z}}cross(t,e){return{x:t.y*e.z-t.z*e.y,y:t.z*e.x-t.x*e.z,z:t.x*e.y-t.y*e.x}}normalise(t){const e=Math.hypot(t.x,t.y,t.z)||1;return{x:t.x/e,y:t.y/e,z:t.z/e}}dispose(){this.object.geometry.dispose(),this.object.material.dispose()}}class Oe{constructor(t,e={}){this.size=t,this.span=Math.min(t.lengthM,Math.max(0,e.spanM??t.lengthM)),this.bank=(t.lengthM-this.span)/2,this.deck=Math.min(t.heightM,e.deckThicknessM??Oe.DEFAULT_DECK_THICKNESS_M),this.railHeight=e.railing?.heightM??Oe.DEFAULT_RAILING_HEIGHT_M,this.postSpacing=Math.max(.3,e.railing?.postSpacingM??Oe.DEFAULT_POST_SPACING_M),this.rails=Math.max(0,Math.round(e.railing?.rails??Oe.DEFAULT_RAILS))}static DEFAULT_DECK_THICKNESS_M=1.2;static DEFAULT_RAILING_HEIGHT_M=1.05;static DEFAULT_POST_SPACING_M=1.5;static DEFAULT_RAILS=2;static BANK_SLOPE=1.5;static ABUTMENT_THICKNESS_M=1;static POST_SIDE_M=.08;static RAIL_HEIGHT_M=.08;static RAIL_DEPTH_M=.06;static BANK_STATIONS=12;static NATURAL_SIZE=Object.freeze({widthM:9,lengthM:40,heightM:6.5});span;bank;deck;railHeight;postSpacing;rails;roadAt(t){const e=Math.abs(t)-this.span/2;return e<=0?this.size.heightM:this.bank<=0?0:Math.max(0,this.size.heightM*(1-e/this.bank))}build(){const{widthM:t,heightM:e}=this.size,i=this.span/2,n=[];if(this.span>0){n.push(Oe.box(t,this.deck,this.span,0,e-this.deck/2,0));for(const c of[-1,1]){const l=e-this.deck;l>0&&this.bank>0&&n.push(Oe.box(t+1,l,Oe.ABUTMENT_THICKNESS_M,0,l/2,c*(i-Oe.ABUTMENT_THICKNESS_M/2)))}}const s=[];this.span>0&&s.push(Oe.box(t,.04,this.span,0,e+.02,0));const a=[];for(const c of[-1,1])this.bank<=0||(a.push(this.embankment(c)),s.push(this.bankRoad(c)));const o=[];for(const c of[-1,1])o.push(...this.railing(c*(t/2-Oe.POST_SIDE_M)));return{concrete:Oe.merge(n),road:Oe.merge(s),earth:Oe.merge(a),railing:Oe.merge(o)}}embankment(t){const e=this.size.widthM/2,i=this.stations(t),n=[],s=(l,h,u,d)=>{n.push(l.x,l.y,l.z,h.x,h.y,h.z,u.x,u.y,u.z,l.x,l.y,l.z,u.x,u.y,u.z,d.x,d.y,d.z)},a=l=>{const h=this.roadAt(l),u=e+Oe.BANK_SLOPE*h;return{leftFoot:new R(-u,0,l),leftTop:new R(-e,h,l),rightTop:new R(e,h,l),rightFoot:new R(u,0,l)}};for(let l=1;l<i.length;l++){const h=a(i[l-1]),u=a(i[l]),d=t>0,f=(p,v,m,g)=>d?s(p,v,m,g):s(g,m,v,p);f(h.leftFoot,h.leftTop,u.leftTop,u.leftFoot),f(h.leftTop,h.rightTop,u.rightTop,u.leftTop),f(h.rightTop,h.rightFoot,u.rightFoot,u.rightTop)}const o=a(i[0]);t>0?s(o.leftFoot,o.rightFoot,o.rightTop,o.leftTop):s(o.leftTop,o.rightTop,o.rightFoot,o.leftFoot);const c=new ce;return c.setAttribute("position",new de(n,3)),c.computeVertexNormals(),c}bankRoad(t){const e=this.size.widthM/2,i=this.stations(t),n=[];for(let a=1;a<i.length;a++){const o=i[a-1],c=i[a],l=this.roadAt(o)+.02,h=this.roadAt(c)+.02,u=t>0?[[-e,l,o],[e,l,o],[e,h,c],[-e,h,c]]:[[-e,h,c],[e,h,c],[e,l,o],[-e,l,o]];for(const d of[0,2,1,0,3,2])n.push(...u[d])}const s=new ce;return s.setAttribute("position",new de(n,3)),s.computeVertexNormals(),s}stations(t){const e=[];for(let i=0;i<=Oe.BANK_STATIONS;i++)e.push(t*(this.span/2+this.bank*i/Oe.BANK_STATIONS));return e}railing(t){const e=this.size.lengthM/2,i=Math.max(1,Math.round(this.size.lengthM/this.postSpacing)),n=[];for(let o=0;o<=i;o++)n.push(-e+this.size.lengthM*o/i);const s=[],a=Oe.POST_SIDE_M;for(const o of n)s.push(Oe.box(a,this.railHeight,a,t,this.roadAt(o)+this.railHeight/2,o));for(let o=1;o<=this.rails;o++){const c=this.railHeight*o/this.rails-Oe.RAIL_HEIGHT_M/2;for(let l=1;l<n.length;l++){const h=new R(t,this.roadAt(n[l-1])+c,n[l-1]),u=new R(t,this.roadAt(n[l])+c,n[l]);s.push(Oe.beam(h,u))}}return s}static box(t,e,i,n,s,a){return new Wi(t,e,i).translate(n,s,a)}static beam(t,e){const i=new R().subVectors(e,t),n=new Wi(Oe.RAIL_DEPTH_M,Oe.RAIL_HEIGHT_M,i.length()),s=new Qi().setFromUnitVectors(new R(0,0,1),i.clone().normalize()),a=new R().addVectors(t,e).multiplyScalar(.5);return n.applyMatrix4(new Jt().compose(a,s,new R(1,1,1)))}static merge(t){const e=t.map(c=>c.getIndex()?c.toNonIndexed():c),i=e.reduce((c,l)=>c+l.getAttribute("position").count,0),n=new Float32Array(i*3),s=new Float32Array(i*3);let a=0;for(const c of e){const l=c.getAttribute("position"),h=c.getAttribute("normal");n.set(l.array,a*3),h&&s.set(h.array,a*3),a+=l.count}const o=new ce;o.setAttribute("position",new de(n,3)),o.setAttribute("normal",new de(s,3));for(const c of t)c.dispose();for(const c of e)c.dispose();return o}}const Zh=Math.PI/180;function Ue(r,t,e,i,n=!1){const s=n?new _n({color:new st(...e)}):new zr({color:new st(...e)}),a=new Dt(t,s);return a.position.y=i,a.userData={emissive:n},a.castShadow=!n,a.receiveShadow=!n,r.add(a),a}const Jh=.25,l5=.002,h5=100,u5=1500,d5=.25,f5=1e3,p5=.15;function m5(r){const t=/^#([0-9a-f]{6})$/i.exec(r);if(!t)return[1,1,1];const e=parseInt(t[1],16);return[(e>>16&255)/255,(e>>8&255)/255,(e&255)/255]}const g5=[.32,.32,.3],O1=[1,.85,.5],v5=[.25,.25,.25],N1=[1,.97,.85],M5=[.55,.68,.72],Jn=.03,jn=.05,F1={front:0,behind:Math.PI,left:Math.PI/2,right:-Math.PI/2,"front-left":Math.PI/2,"behind-left":Math.PI/2,"front-right":-Math.PI/2,"behind-right":-Math.PI/2};function Bi(r,t){return r?.[t]}function Qn(r,t,e,i,n,s,a,o){if(o===void 0)return;const c=new zr({color:new st(...M5),transparent:!0,opacity:o/100}),l=new Dt(new Wi(t,e,i),c);l.position.set(n,s,a),r.add(l)}const vn=.05,jh=[.6,.58,.53],rm=[.5,.5,.48];function Mr(r,t,e,i,n,s,a,o){const c=new zr({color:new st(...o),side:Ve}),l=new Dt(new Wi(t,e,i),c);l.position.set(n,s,a),r.add(l)}function x5(r,t,e,i,n,s,a,o,c){const l=(i-s)/2,h=(p,v,m,g)=>{p<=0||(t?Mr(r,p,v,vn,m,o+g,a,c):Mr(r,vn,v,p,a,o+g,m,c))};h(e,l,0,i/2-l/2),h(e,l,0,-(i/2-l/2));const u=[...n].sort((p,v)=>p.center-v.center);let d=-e/2;for(const p of u){const m=p.center-p.main/2-d;h(m,s,d+m/2,0),d=p.center+p.main/2}const f=e/2-d;h(f,s,d+f/2,0)}function U1(r,t,e,i,n,s,a,o,c,l){const h=(i+n)/2,u=n-i,d=(f,p,v,m)=>{f.length===0?p?Mr(r,v,u,vn,0,h,m,jh):Mr(r,vn,u,v,m,h,0,jh):x5(r,p,v,u,f,s,m,h,jh)};d(a,!0,t*2,-e+vn),d(o,!0,t*2,e-vn),d(c,!1,e*2,-t+vn),d(l,!1,e*2,t-vn),Mr(r,t*2,vn,e*2,0,i+vn,0,rm),Mr(r,t*2,vn,e*2,0,n-vn,0,rm)}function Xd(r,t,e,i){switch(r){case"front":return{x:0,z:-(e-i)};case"behind":return{x:0,z:e-i};case"left":return{x:-(t-i),z:0};case"right":return{x:t-i,z:0};case"front-left":return{x:-(t-i),z:-ts};case"front-right":return{x:t-i,z:-ts};case"behind-left":return{x:-(t-i),z:ts};case"behind-right":return{x:t-i,z:ts}}}function k1(r,t,e,i,n,s,a){const o=$d();o.scale.setScalar(i),o.rotation.y=F1[t];const{x:c,z:l}=Xd(t,n,s,a);o.position.set(c,e,l),r.add(o)}const Yd=6,qd=6,$s=3,oo=1.4,co=$s*.5,z1=1.2,B1=.35,y5=.75,_5=1.6;function om(r,t,e,i){const n=new Ce,s=Math.max(1,r+1),a=s*$s;Ue(n,new Wi(Yd,a,qd),[.55,.54,.5],a/2);const o=Yd/2,c=qd/2;for(let l=0;l<s;l++){const h=l*$s+$s/2;Qn(n,oo,co,jn,0,h,-c-Jn,Bi(t,"front")),Qn(n,oo,co,jn,0,h,c+Jn,Bi(t,"behind")),Qn(n,jn,co,oo,-o-Jn,h,0,Bi(t,"left")),Qn(n,jn,co,oo,o+Jn,h,0,Bi(t,"right"))}if(e){const l=Math.min(Math.max(i??0,0),s-1);k1(n,e,l*$s,.72,o,c,z1);const h=u=>Bi(t,u)!==void 0?[{main:oo,center:0}]:[];U1(n,o,c,l*$s,(l+1)*$s,co,h("front"),h("behind"),h("left"),h("right"))}return n}function cm(){const r=new Ce,t=[[0,0,.55,.5],[.4,.1,.35,.4],[-.35,-.2,.4,.38],[.1,-.4,.35,.36],[-.15,.4,.3,.34]];for(const[e,i,n,s]of t){const a=new oi(n,10,7);a.scale(1,.85,1),a.translate(e,0,i),Ue(r,a,[.26,.28,.17],s)}return r}function S5(r){const t=new Ce,e=new Oe(ui.sizeOf(r),r.bridge).build();Ue(t,e.concrete,[.6,.6,.58],0);const i=Ue(t,e.road,[.2,.2,.21],0),n=Ue(t,e.earth,[.3,.36,.22],0);for(const s of[i,n])s.material.side=ji;return Ue(t,e.railing,[.5,.52,.55],0),t}function lm(){const r=new Ce;return Ue(r,new cs(.15,.22,2,8),[.32,.22,.14],1),Ue(r,new kr(1.4,3,8),[.16,.32,.14],3.5),r}const hm=.275,b5=.35,w5=.9,E5=34,A5=8,T5=1.4;function um(){const r=new Ce,t=new oi(hm,7,3,0,Math.PI*2,0,Math.PI/2);t.scale(1,b5/hm,1);const e=ui.repeatOnGrid(t,E5,w5,A5,T5),i=Ue(r,e,[.26,.28,.22],0);return i.castShadow=!0,i.userData.cropBasePositions=e.getAttribute("position").array.slice(),i.userData.cropVerticesPerClump=t.getAttribute("position").count,t.dispose(),r}function dm(){const r=new Ce,t=new oi(1,7,3,0,Math.PI*2,0,Math.PI/2);return Ue(r,t,[.38,.36,.32],0),r}function fm(r){const t=new Ce;return Ue(t,new cs(.05,.08,5,8),[.28,.28,.3],2.5),Ue(t,new oi(.25,12,8),r?O1:g5,5.1,!0),t}const R5=[.08,.08,.08],Vs=.8,dr=1,Yn=1.7,Qh=.6,fa=.4,Wc=1.2,hr=.7,ts=.5,D5=Yn;function pm(r,t,e){const i=new Ce;Ue(i,new Wi(1.8,1.4,4.2),[.45,.14,.14],.7),Ue(i,new Wi(Vs*2,Qh,dr*2),[.4,.12,.12],Yn);for(const s of[-1.4,1.4])for(const a of[-.95,.95]){const o=Ue(i,new cs(.4,.4,.3,12),R5,.4);o.rotation.z=Math.PI/2,o.position.x=a,o.position.z=s}const n=r?N1:v5;for(const s of[-.7,.7])Ue(i,new oi(.15,8,6),n,.7,!0).position.set(s,.7,-2.1);if(Qn(i,Wc,fa,jn,0,Yn,-dr-Jn,Bi(t,"front")),Qn(i,Wc,fa,jn,0,Yn,dr+Jn,Bi(t,"behind")),Qn(i,jn,fa,hr,-Vs-Jn,Yn,-ts,Bi(t,"front-left")),Qn(i,jn,fa,hr,-Vs-Jn,Yn,ts,Bi(t,"behind-left")),Qn(i,jn,fa,hr,Vs+Jn,Yn,-ts,Bi(t,"front-right")),Qn(i,jn,fa,hr,Vs+Jn,Yn,ts,Bi(t,"behind-right")),e){k1(i,e,y5,.5,Vs,dr,B1);const s=(c,l)=>{const h=[];return Bi(t,c)!==void 0&&h.push({main:hr,center:-ts}),Bi(t,l)!==void 0&&h.push({main:hr,center:ts}),h},a=Bi(t,"front")!==void 0?[{main:Wc,center:0}]:[],o=Bi(t,"behind")!==void 0?[{main:Wc,center:0}]:[];U1(i,Vs,dr,Yn-Qh/2,Yn+Qh/2,fa,a,o,s("front-left","behind-left"),s("front-right","behind-right"))}return i}const mm=new Map;function gm(r,t){if(!r)return;const e=[[r.lengthM,t.lengthM],[r.heightM,t.heightM],[r.widthM,t.widthM]];for(const[i,n]of e)if(i!==void 0&&n>1e-6)return i/n}function tu(r,t){return t>1e-6?r/t:1}const H1=[.95,.9,.82],vm=[.72,.74,.78];function Mm(){const r=new Ce;Ue(r,new cs(.25,.3,1.5,10),vm,.75),Ue(r,new oi(.26,10,8),vm,1.74);const t=Ue(r,new kr(.07,.16,8),H1,1.74);return t.rotation.x=-Math.PI/2,t.position.z=-.22,r}function $d(){const r=new Ce;Ue(r,new cs(.25,.3,1.5,10),[.3,.3,.35],.75),Ue(r,new oi(.22,10,8),[.62,.52,.46],1.72);const t=Ue(r,new kr(.07,.16,8),H1,1.72);return t.rotation.x=-Math.PI/2,t.position.z=-.2,r}const I5=17,xm=18.5,eu=[.16,.16,.18];function ym(){const r=new Ce,t=Ue(r,new cs(1.8,1.8,xm*2,10),eu,0);t.rotation.x=Math.PI/2,Ue(r,new Wi(I5*2,.5,4.5),eu,0);const e=Ue(r,new Wi(.4,5.5,4),eu,3);return e.position.z=-xm+2,r}class ui{static GROWS_FROM_GROUND=new Set(["tree","shrub","crop","mound"]);static groundUnderFootprint(t,e,i,n,s,a=0){const o=ui.sizeOf(t);if(a>o.heightM)return s(e,i);const c=(n??0)*Math.PI/180,l=Math.min(21,Math.max(2,Math.ceil(o.lengthM/.75)+1)),h=Math.min(21,Math.max(2,Math.ceil(o.widthM/.75)+1)),u=ui.GROWS_FROM_GROUND.has(t.kind);let d=u?1/0:-1/0;for(let f=0;f<l;f++){const p=(f/(l-1)-.5)*o.lengthM;for(let v=0;v<h;v++){const m=(v/(h-1)-.5)*o.widthM,g=e+Math.sin(c)*p+Math.cos(c)*m,S=i-Math.cos(c)*p+Math.sin(c)*m;d=u?Math.min(d,s(g,S)):Math.max(d,s(g,S))}}return Number.isFinite(d)?d:s(e,i)}static occupantView(t){const e=t.observerSide;if(!e)throw new Error("occupantView requires object.observerSide to be set");const{x:i,z:n}=t.kind==="vehicle"?Xd(e,Vs,dr,B1):Xd(e,Yd/2,qd/2,z1),s=t.kind==="vehicle"?D5:(t.occupiedFloor??0)*$s+_5,a=(t.headingDeg??0)-F1[e]/Zh,o=this.scaleFor(t);return{x:i*o.x,z:n*o.z,eyeY:s*o.y,headingDeg:a}}static BODY_NAME="decor-body";static bodyOf(t){return t.getObjectByName(ui.BODY_NAME)??t}static repeatOnGrid(t,e,i,n,s){const a=t.getAttribute("position"),o=t.getAttribute("normal"),c=t.getIndex();if(!c)throw new Error("repeatOnGrid needs an indexed geometry");const l=a.count,h=e*n,u=new Float32Array(l*h*3),d=new Float32Array(l*h*3),f=new Uint32Array(c.count*h),p=-((e-1)*i)/2,v=-((n-1)*s)/2;let m=0;for(let S=0;S<n;S++)for(let y=0;y<e;y++,m++){const M=v+S*s,b=p+y*i;for(let w=0;w<l;w++){const T=(m*l+w)*3;u[T]=a.getX(w)+M,u[T+1]=a.getY(w),u[T+2]=a.getZ(w)+b,d[T]=o.getX(w),d[T+1]=o.getY(w),d[T+2]=o.getZ(w)}for(let w=0;w<c.count;w++)f[m*c.count+w]=c.getX(w)+m*l}const g=new ce;return g.setAttribute("position",new de(u,3)),g.setAttribute("normal",new de(d,3)),g.setIndex(new g0(f,1)),g}static fitCropToGround(t,e){t.updateMatrixWorld(!0);const i=new R;t.traverse(n=>{const s=n,a=s.userData.cropBasePositions,o=s.userData.cropVerticesPerClump;if(!s.isMesh||!a||!o)return;const c=s.geometry.getAttribute("position"),l=new Jt().copy(s.matrixWorld).invert();for(let h=0;h<c.count;h+=o){i.set(a[h*3],0,a[h*3+2]).applyMatrix4(s.matrixWorld),i.y=e(i.x,i.z),i.applyMatrix4(l);for(let u=h;u<h+o;u++)c.setY(u,a[u*3+1]+i.y)}c.needsUpdate=!0,s.geometry.computeBoundingBox(),s.geometry.computeBoundingSphere()})}static paint(t,e){t.traverse(i=>{const n=i,s=n.userData;if(!n.isMesh||s?.emissive)return;const a=n.material;a?.color&&a.color.set(e)})}static build(t,e){const i=t.kind==="building"?om(t.floors??tf,t.windows,t.observerSide,t.occupiedFloor):t.kind==="tree"?lm():t.kind==="shrub"?cm():t.kind==="bridge"?S5(t):t.kind==="crop"?um():t.kind==="mound"?dm():t.kind==="streetlight"?fm(e):t.kind==="vehicle"?pm(e,t.windows,t.observerSide):t.kind==="aircraft"?ym():t.kind==="entity"?Mm():$d();t.color&&this.paint(i,t.color);const n=this.scaleFor(t),s=new Ce;return i.name=ui.BODY_NAME,i.scale.copy(n),s.add(i),t.headingDeg!==void 0&&(s.rotation.y=-t.headingDeg*Zh),this.addLights(s,t.lights),s}static scaleFor(t){const e=t.sizeM;if(!e||t.kind==="bridge")return new R(1,1,1);const i=this.naturalSize(t.kind,t.floors);return new R(e.widthM===void 0?1:tu(e.widthM,i.widthM),e.heightM===void 0?1:tu(e.heightM,i.heightM),e.lengthM===void 0?1:tu(e.lengthM,i.lengthM))}static naturalSize(t,e){const i=t==="building"?Math.max(1,(e??tf)+1):0;if(t==="bridge")return Oe.NATURAL_SIZE;const n=`${t}:${i}`,s=mm.get(n);if(s)return s;const a=t==="building"?om(i-1,void 0,void 0,void 0):t==="tree"?lm():t==="shrub"?cm():t==="crop"?um():t==="mound"?dm():t==="streetlight"?fm(!1):t==="vehicle"?pm(!1,void 0,void 0):t==="aircraft"?ym():t==="entity"?Mm():$d(),o=new Vi().setFromObject(a),c={widthM:o.max.x-o.min.x,heightM:o.max.y-o.min.y,lengthM:o.max.z-o.min.z};return this.dispose(a),mm.set(n,c),c}static usesModel(t){return t.model!==void 0&&!(t.observerSide!==void 0&&ng(t.kind))}static applyModel(t,e,i,n={}){const s=this.bodyOf(t),a=new Ce;a.name=ui.BODY_NAME,i.rotation.y=-(n.headingOffsetDeg??0)*Zh,i.updateMatrixWorld(!0);const o=new Vi().setFromObject(i),c={lengthM:o.max.z-o.min.z,heightM:o.max.y-o.min.y,widthM:o.max.x-o.min.x},l=gm(e.sizeM,c)??gm(n.depictedSizeM,c)??1;i.scale.multiplyScalar(l);const h=o.getCenter(new R).multiplyScalar(l);i.position.x-=h.x,i.position.z-=h.z,i.position.y-=e.kind==="aircraft"?h.y:o.min.y*l,i.traverse(u=>{u instanceof Dt&&(u.castShadow=!0,u.receiveShadow=!0)}),a.add(i),s.parent?(s.parent.add(a),s.removeFromParent()):t.add(a),this.dispose(s)}static sizeOf(t){const e=this.naturalSize(t.kind,t.floors);return{widthM:t.sizeM?.widthM??e.widthM,lengthM:t.sizeM?.lengthM??e.lengthM,heightM:t.sizeM?.heightM??e.heightM}}static addLights(t,e){for(const i of e??[]){const n=m5(i.color),s=Ue(t,new oi(Jh,8,6),n,i.offsetM.y,!0);s.position.set(i.offsetM.x,i.offsetM.y,i.offsetM.z),s.userData={emissive:!0,lightId:i.id,lightColor:n},s.visible=!1}}static setLights(t,e,i,n,s=0,a=1,o=l5){if(!e||e.length===0)return;const c=new Map(e.map(d=>[d.id,d])),l=Math.max(1,n*o/Jh),h=Jh*l,u=a/(Math.PI*h*h);for(const d of t.children){if(!(d instanceof Dt))continue;const f=d.userData.lightId;if(!f)continue;const p=c.get(f);if(!p)continue;const v=s>0?sg(p,i,i+s):av(p,i)?1:0;d.visible=v>0;const m=d.material,g=d.userData.lightColor;if(g){const S=v*h5*(p.intensity??1)*u;m.color.setRGB(g[0]*S,g[1]*S,g[2]*S)}d.scale.setScalar(l)}}static setLit(t,e,i,n=1){const[s,a,o]=e==="streetlight"?[u5,d5,O1]:[f5,p5,N1],c=i?s*n/(Math.PI*a*a):0,l=[o[0]*c,o[1]*c,o[2]*c];t.traverse(h=>{const u=h.userData;!(h instanceof Dt)||!u.emissive||u.lightId||h.material.color.setRGB(...l)})}static dispose(t){t.traverse(e=>{if(!(e instanceof Dt))return;e.geometry.dispose();const i=e.material;for(const n of Array.isArray(i)?i:[i])n.dispose()})}}const iu="https://ufoathome.org/models/index.json";class C5{attribution="3D models re-hosted by UFO@home, each under its own author's licence";fetchImpl;indexUrls;loading;constructor(t={}){this.fetchImpl=t.fetchImpl??fetch.bind(globalThis),this.indexUrls=t.indexUrls??P5()}async entries(t){const e=await this.load();return t?e.filter(i=>i.kind===t):e}async entry(t){return(await this.load()).find(e=>e.id===t)}load(){return this.loading??=this.fetchFirstAvailable(),this.loading}async fetchFirstAvailable(){for(const t of this.indexUrls){const e=await this.fetchIndex(t);if(e)return e}return[]}async fetchIndex(t){try{const e=await this.fetchImpl(t);if(!e.ok)return;const i=await e.json();return Array.isArray(i?.models)?i.models.map(({file:n,...s})=>({...s,url:new URL(n,t).href})):void 0}catch{return}}}function P5(){const r=`?v=${encodeURIComponent("0.81.6")}`,t=typeof location>"u"?void 0:new URL("/models/index.json",location.href).href;return(t&&t!==iu?[t,iu]:[iu]).map(e=>e+r)}const L5=[{id:"ufoathome",name:"UFO@home",credit:"3D models re-hosted by UFO@home, each under its own author's licence",creditUrl:"https://ufoathome.org/models/",create:()=>new C5}];async function _m(r){const{GLTFLoader:t}=await is(async()=>{const{GLTFLoader:i}=await import("./GLTFLoader-BumifFuq.js");return{GLTFLoader:i}},[],import.meta.url),e=new t;return new Promise((i,n)=>{e.load(r,s=>i(Object.assign(s.scene,{animations:s.animations})),void 0,s=>n(new Error(`Could not load 3D model ${r}: ${s instanceof Error?s.message:String(s)}`)))})}const G1=["ellipsoid","sphere","disc","cylinder","cone","box","torus","figure"];class ln{static MIN_ANGLE_RAD=.002;static FILL=(1-Math.exp(-4))/4;static MAX_SHARE=.3;mesh;constructor(t,e){this.mesh=new Dt(new Xi(2,2),new le({uniforms:{uColor:{value:new st(0,0,0)},uRadius:{value:1}},vertexShader:ln.VERTEX,fragmentShader:ln.FRAGMENT,transparent:!0,depthWrite:!1,blending:Ni,toneMapped:!1})),this.mesh.name=t,this.mesh.frustumCulled=!1,this.mesh.renderOrder=e,this.mesh.visible=!1}shine(t,e,i){this.mesh.visible=!0,this.mesh.position.set(t.x,t.y,t.z),this.mesh.material.uniforms.uRadius.value=e,this.mesh.material.uniforms.uColor.value.setRGB(i[0],i[1],i[2])}hide(){this.mesh.visible=!1}dispose(){this.mesh.geometry.dispose(),this.mesh.material.dispose()}static spread(t,e,i,n){const s=Math.max(t,n*ln.MIN_ANGLE_RAD),a=ln.FILL*Math.PI*s*s;return{radiusM:s,luminanceCdM2:i*Math.min(ln.MAX_SHARE,e/a)}}static conserving(t){return Math.sqrt(t/(ln.MAX_SHARE*ln.FILL*Math.PI))}static VERTEX=`
|
|
7203
|
+
`,transparent:!0,blending:Ni,depthWrite:!1,side:Ve,fog:!1}),this.object=new Dt(new oi(Ci.RADIUS,64,32),this.material),this.object.renderOrder=-1,this.object.frustumCulled=!1,this.object.visible=!1;const i=this.material.uniforms;this.deckUniforms={uSource:i.uSource,uUp:i.uUp,uStrength:i.uStrength,uTint:i.uTint,uMap:i.uMap,uGain:i.uGain,uHaloShown:{value:0}}}deckUniforms;shown=!1;hostedByDeck=!1;set hosted(t){this.hostedByDeck=t,this.show(this.shown)}show(t){this.shown=t,this.object.visible=t&&!this.hostedByDeck,this.deckUniforms.uHaloShown.value=t?1:0}get awaitingFirstDisplay(){return this.tracing&&!this.everDisplayed}setUrgent(t){this.urgent=t}set onReady(t){this.onRepaint=t}update(t,e,i,n,s,a){const o=this.material.uniforms;if(i<=0){o.uStrength.value=0,this.show(!1),this.stopWork();return}o.uSource.value.set(t.x,t.y,t.z).normalize(),o.uStrength.value=i,o.uTint.value.set(n[0],n[1],n[2]),o.uIceCover.value=s.cover,o.uIceHeight.value=s.layerHeight,this.show(this.everDisplayed),this.requestMap(e,a)}requestMap(t,e){if(!(!(Math.abs(t-this.mappedAltitudeDeg)<Ci.ALTITUDE_STEP_DEG)||!(Math.abs(e-this.mappedAlignment)<Ci.ALIGNMENT_STEP))){this.next=void 0;return}if(this.tracing){if(this.tracingFor(t,e)){this.next=void 0;return}if(!(!(Math.abs(t-this.pendingAltitudeDeg)<Ci.LEAP_ALTITUDE_DEG)||!(Math.abs(e-this.pendingAlignment)<Ci.LEAP_ALIGNMENT))){this.next={sourceAltitudeDeg:t,alignment:e};return}}this.next=void 0,this.pendingAltitudeDeg=t,this.pendingAlignment=e,this.sky.begin(t,e),this.tracing=!0,this.scheduleWork()}pendingAltitudeDeg=Number.NaN;pendingAlignment=Number.NaN;next;tracingFor(t,e){return this.tracing&&Math.abs(t-this.pendingAltitudeDeg)<Ci.ALTITUDE_STEP_DEG&&Math.abs(e-this.pendingAlignment)<Ci.ALIGNMENT_STEP}scheduleWork(){if(this.workHandle!==void 0)return;const t=()=>{if(this.workHandle=void 0,!this.tracing)return;const e=performance.now(),i=this.urgent?Ci.URGENT_BUDGET_MS:Ci.BUDGET_MS;do this.sky.trace(Ci.RAYS_PER_BATCH);while(this.sky.tracedRays<Ci.RAYS&&performance.now()-e<i);if(this.sky.tracedRays>=Ci.RAYS){this.publish(),this.tracing=!1,this.mappedAltitudeDeg=this.pendingAltitudeDeg,this.mappedAlignment=this.pendingAlignment;const s=this.next;s&&this.requestMap(s.sourceAltitudeDeg,s.alignment);return}this.workHandle=requestAnimationFrame(t)};this.workHandle=requestAnimationFrame(t)}stopWork(){this.workHandle!==void 0&&cancelAnimationFrame(this.workHandle),this.workHandle=void 0,this.tracing=!1,this.next=void 0}publish(){const e=this.sky.harvest().data;for(let i=0,n=0;n<e.length;i+=4,n+=3)this.texels[i]=Fn.toHalfFloat(e[n]),this.texels[i+1]=Fn.toHalfFloat(e[n+1]),this.texels[i+2]=Fn.toHalfFloat(e[n+2]),this.texels[i+3]=1;this.texture.needsUpdate=!0,this.everDisplayed=!0,this.show(this.material.uniforms.uStrength.value>0),this.onRepaint?.()}dispose(){this.stopWork(),this.texture.dispose(),this.object.geometry.dispose(),this.material.dispose()}}class yi{static MAX_CONCURRENT=24;static POINTS=8;static SEGMENTS=yi.POINTS-1;static ACROSS=3;static VERTICES_PER_SEGMENT=(yi.ACROSS-1)*6;static RADIUS=840;static MIN_HALF_WIDTH_DEG=.05;static BRIGHT_HALF_WIDTH_DEG=.22;object;positions;colors;meteors=[];radiantAltitudeDeg=0;radiantAzimuthDeg=0;constructor(){const t=yi.MAX_CONCURRENT*yi.SEGMENTS*yi.VERTICES_PER_SEGMENT;this.positions=new Float32Array(t*3),this.colors=new Float32Array(t*3);const e=new ce;e.setAttribute("position",new ie(this.positions,3)),e.setAttribute("color",new ie(this.colors,3)),e.setDrawRange(0,0),this.object=new Dt(e,new _n({vertexColors:!0,transparent:!0,blending:Ni,depthWrite:!1,fog:!1,side:ji})),this.object.frustumCulled=!1}get schedule(){return this.meteors}setShower(t,e,i){this.meteors=t,this.radiantAltitudeDeg=e,this.radiantAzimuthDeg=i}update(t){const e=this.object.geometry;if(this.meteors.length===0){e.setDrawRange(0,0);return}const i=Pa.aliveAt(this.meteors,t).slice(0,yi.MAX_CONCURRENT);let n=0;for(const{meteor:s,progress:a}of i){const o=this.radiantOf(s);if(!o)continue;const c=hi(o.altitudeDeg,o.azimuthDeg,1),[l,h]=this.basisAround(c),u=s.fromRadiantDeg+a*s.lengthDeg,d=Math.max(s.fromRadiantDeg,u-s.lengthDeg*.6),f=Math.min(1,(1-a)*2.5),p=this.turn(l,h,s.bearingDeg),v=(.15+.85*s.brightness)*f,m=y=>v*y**1.6,g=y=>this.onSphere(c,p,d+(u-d)*y),S=y=>yi.RADIUS*((yi.MIN_HALF_WIDTH_DEG+yi.BRIGHT_HALF_WIDTH_DEG*s.brightness*y)*Math.PI/180);for(let y=1;y<yi.POINTS;y++){const M=(y-1)/yi.SEGMENTS,b=y/yi.SEGMENTS;n=this.pushRibbon(n,g(M),g(b),S(M),S(b),m(M),m(b))}}e.setDrawRange(0,n),e.getAttribute("position").needsUpdate=!0,e.getAttribute("color").needsUpdate=!0}midpointOf(t){const e=this.radiantOf(t);if(!e)return;const i=hi(e.altitudeDeg,e.azimuthDeg,1),[n,s]=this.basisAround(i),a=this.turn(n,s,t.bearingDeg),o=this.onSphere(i,a,t.fromRadiantDeg+t.lengthDeg/2),c=Math.hypot(o.x,o.y,o.z)||1;return{altitudeDeg:Math.asin(o.y/c)*180/Math.PI,azimuthDeg:(Math.atan2(o.x,-o.z)*180/Math.PI+360)%360}}radiantOf(t){return t.radiant?t.radiant:this.radiantAltitudeDeg>0?{altitudeDeg:this.radiantAltitudeDeg,azimuthDeg:this.radiantAzimuthDeg}:void 0}pushRibbon(t,e,i,n,s,a,o){const c=this.normalise(this.cross(this.normalise(e),this.normalise(this.subtract(i,e))));for(let l=0;l<yi.ACROSS-1;l++){const h=l-1,u=l,d=this.across(e,c,n,h),f=this.across(i,c,s,h),p=this.across(e,c,n,u),v=this.across(i,c,s,u),m=(g,S)=>g===0?S:0;t=this.push(t,d,m(h,a)),t=this.push(t,f,m(h,o)),t=this.push(t,p,m(u,a)),t=this.push(t,f,m(h,o)),t=this.push(t,v,m(u,o)),t=this.push(t,p,m(u,a))}return t}across(t,e,i,n){return{x:t.x+e.x*i*n,y:t.y+e.y*i*n,z:t.z+e.z*i*n}}push(t,e,i){const n=t*3;this.positions[n]=e.x,this.positions[n+1]=e.y,this.positions[n+2]=e.z;const s=At.relativeOfResponse(Math.max(0,Math.min(1,i)));return this.colors[n]=s*.9,this.colors[n+1]=s*.95,this.colors[n+2]=s,t+1}turn(t,e,i){const n=i*Math.PI/180,s=Math.cos(n),a=Math.sin(n);return{x:t.x*s+e.x*a,y:t.y*s+e.y*a,z:t.z*s+e.z*a}}onSphere(t,e,i){const n=i*Math.PI/180,s=Math.cos(n),a=Math.sin(n);return{x:(t.x*s+e.x*a)*yi.RADIUS,y:(t.y*s+e.y*a)*yi.RADIUS,z:(t.z*s+e.z*a)*yi.RADIUS}}basisAround(t){const e=Math.abs(t.y)<.9?{x:0,y:1,z:0}:{x:1,y:0,z:0},i=this.normalise(this.cross(t,e));return[i,this.normalise(this.cross(t,i))]}subtract(t,e){return{x:t.x-e.x,y:t.y-e.y,z:t.z-e.z}}cross(t,e){return{x:t.y*e.z-t.z*e.y,y:t.z*e.x-t.x*e.z,z:t.x*e.y-t.y*e.x}}normalise(t){const e=Math.hypot(t.x,t.y,t.z)||1;return{x:t.x/e,y:t.y/e,z:t.z/e}}dispose(){this.object.geometry.dispose(),this.object.material.dispose()}}class Ne{constructor(t,e={}){this.size=t,this.span=Math.min(t.lengthM,Math.max(0,e.spanM??t.lengthM)),this.bank=(t.lengthM-this.span)/2,this.deck=Math.min(t.heightM,e.deckThicknessM??Ne.DEFAULT_DECK_THICKNESS_M),this.railHeight=e.railing?.heightM??Ne.DEFAULT_RAILING_HEIGHT_M,this.postSpacing=Math.max(.3,e.railing?.postSpacingM??Ne.DEFAULT_POST_SPACING_M),this.rails=Math.max(0,Math.round(e.railing?.rails??Ne.DEFAULT_RAILS))}static DEFAULT_DECK_THICKNESS_M=1.2;static DEFAULT_RAILING_HEIGHT_M=1.05;static DEFAULT_POST_SPACING_M=1.5;static DEFAULT_RAILS=2;static BANK_SLOPE=1.5;static ABUTMENT_THICKNESS_M=1;static POST_SIDE_M=.08;static RAIL_HEIGHT_M=.08;static RAIL_DEPTH_M=.06;static BANK_STATIONS=12;static NATURAL_SIZE=Object.freeze({widthM:9,lengthM:40,heightM:6.5});span;bank;deck;railHeight;postSpacing;rails;roadAt(t){const e=Math.abs(t)-this.span/2;return e<=0?this.size.heightM:this.bank<=0?0:Math.max(0,this.size.heightM*(1-e/this.bank))}build(){const{widthM:t,heightM:e}=this.size,i=this.span/2,n=[];if(this.span>0){n.push(Ne.box(t,this.deck,this.span,0,e-this.deck/2,0));for(const c of[-1,1]){const l=e-this.deck;l>0&&this.bank>0&&n.push(Ne.box(t+1,l,Ne.ABUTMENT_THICKNESS_M,0,l/2,c*(i-Ne.ABUTMENT_THICKNESS_M/2)))}}const s=[];this.span>0&&s.push(Ne.box(t,.04,this.span,0,e+.02,0));const a=[];for(const c of[-1,1])this.bank<=0||(a.push(this.embankment(c)),s.push(this.bankRoad(c)));const o=[];for(const c of[-1,1])o.push(...this.railing(c*(t/2-Ne.POST_SIDE_M)));return{concrete:Ne.merge(n),road:Ne.merge(s),earth:Ne.merge(a),railing:Ne.merge(o)}}embankment(t){const e=this.size.widthM/2,i=this.stations(t),n=[],s=(l,h,u,d)=>{n.push(l.x,l.y,l.z,h.x,h.y,h.z,u.x,u.y,u.z,l.x,l.y,l.z,u.x,u.y,u.z,d.x,d.y,d.z)},a=l=>{const h=this.roadAt(l),u=e+Ne.BANK_SLOPE*h;return{leftFoot:new R(-u,0,l),leftTop:new R(-e,h,l),rightTop:new R(e,h,l),rightFoot:new R(u,0,l)}};for(let l=1;l<i.length;l++){const h=a(i[l-1]),u=a(i[l]),d=t>0,f=(p,v,m,g)=>d?s(p,v,m,g):s(g,m,v,p);f(h.leftFoot,h.leftTop,u.leftTop,u.leftFoot),f(h.leftTop,h.rightTop,u.rightTop,u.leftTop),f(h.rightTop,h.rightFoot,u.rightFoot,u.rightTop)}const o=a(i[0]);t>0?s(o.leftFoot,o.rightFoot,o.rightTop,o.leftTop):s(o.leftTop,o.rightTop,o.rightFoot,o.leftFoot);const c=new ce;return c.setAttribute("position",new de(n,3)),c.computeVertexNormals(),c}bankRoad(t){const e=this.size.widthM/2,i=this.stations(t),n=[];for(let a=1;a<i.length;a++){const o=i[a-1],c=i[a],l=this.roadAt(o)+.02,h=this.roadAt(c)+.02,u=t>0?[[-e,l,o],[e,l,o],[e,h,c],[-e,h,c]]:[[-e,h,c],[e,h,c],[e,l,o],[-e,l,o]];for(const d of[0,2,1,0,3,2])n.push(...u[d])}const s=new ce;return s.setAttribute("position",new de(n,3)),s.computeVertexNormals(),s}stations(t){const e=[];for(let i=0;i<=Ne.BANK_STATIONS;i++)e.push(t*(this.span/2+this.bank*i/Ne.BANK_STATIONS));return e}railing(t){const e=this.size.lengthM/2,i=Math.max(1,Math.round(this.size.lengthM/this.postSpacing)),n=[];for(let o=0;o<=i;o++)n.push(-e+this.size.lengthM*o/i);const s=[],a=Ne.POST_SIDE_M;for(const o of n)s.push(Ne.box(a,this.railHeight,a,t,this.roadAt(o)+this.railHeight/2,o));for(let o=1;o<=this.rails;o++){const c=this.railHeight*o/this.rails-Ne.RAIL_HEIGHT_M/2;for(let l=1;l<n.length;l++){const h=new R(t,this.roadAt(n[l-1])+c,n[l-1]),u=new R(t,this.roadAt(n[l])+c,n[l]);s.push(Ne.beam(h,u))}}return s}static box(t,e,i,n,s,a){return new Wi(t,e,i).translate(n,s,a)}static beam(t,e){const i=new R().subVectors(e,t),n=new Wi(Ne.RAIL_DEPTH_M,Ne.RAIL_HEIGHT_M,i.length()),s=new Qi().setFromUnitVectors(new R(0,0,1),i.clone().normalize()),a=new R().addVectors(t,e).multiplyScalar(.5);return n.applyMatrix4(new Jt().compose(a,s,new R(1,1,1)))}static merge(t){const e=t.map(c=>c.getIndex()?c.toNonIndexed():c),i=e.reduce((c,l)=>c+l.getAttribute("position").count,0),n=new Float32Array(i*3),s=new Float32Array(i*3);let a=0;for(const c of e){const l=c.getAttribute("position"),h=c.getAttribute("normal");n.set(l.array,a*3),h&&s.set(h.array,a*3),a+=l.count}const o=new ce;o.setAttribute("position",new de(n,3)),o.setAttribute("normal",new de(s,3));for(const c of t)c.dispose();for(const c of e)c.dispose();return o}}const Zh=Math.PI/180;function ke(r,t,e,i,n=!1){const s=n?new _n({color:new st(...e)}):new zr({color:new st(...e)}),a=new Dt(t,s);return a.position.y=i,a.userData={emissive:n},a.castShadow=!n,a.receiveShadow=!n,r.add(a),a}const Jh=.25,l5=.002,h5=100,u5=1500,d5=.25,f5=1e3,p5=.15;function m5(r){const t=/^#([0-9a-f]{6})$/i.exec(r);if(!t)return[1,1,1];const e=parseInt(t[1],16);return[(e>>16&255)/255,(e>>8&255)/255,(e&255)/255]}const g5=[.32,.32,.3],O1=[1,.85,.5],v5=[.25,.25,.25],N1=[1,.97,.85],M5=[.55,.68,.72],Jn=.03,jn=.05,F1={front:0,behind:Math.PI,left:Math.PI/2,right:-Math.PI/2,"front-left":Math.PI/2,"behind-left":Math.PI/2,"front-right":-Math.PI/2,"behind-right":-Math.PI/2};function Bi(r,t){return r?.[t]}function Qn(r,t,e,i,n,s,a,o){if(o===void 0)return;const c=new zr({color:new st(...M5),transparent:!0,opacity:o/100}),l=new Dt(new Wi(t,e,i),c);l.position.set(n,s,a),r.add(l)}const vn=.05,jh=[.6,.58,.53],rm=[.5,.5,.48];function Mr(r,t,e,i,n,s,a,o){const c=new zr({color:new st(...o),side:Ve}),l=new Dt(new Wi(t,e,i),c);l.position.set(n,s,a),r.add(l)}function x5(r,t,e,i,n,s,a,o,c){const l=(i-s)/2,h=(p,v,m,g)=>{p<=0||(t?Mr(r,p,v,vn,m,o+g,a,c):Mr(r,vn,v,p,a,o+g,m,c))};h(e,l,0,i/2-l/2),h(e,l,0,-(i/2-l/2));const u=[...n].sort((p,v)=>p.center-v.center);let d=-e/2;for(const p of u){const m=p.center-p.main/2-d;h(m,s,d+m/2,0),d=p.center+p.main/2}const f=e/2-d;h(f,s,d+f/2,0)}function U1(r,t,e,i,n,s,a,o,c,l){const h=(i+n)/2,u=n-i,d=(f,p,v,m)=>{f.length===0?p?Mr(r,v,u,vn,0,h,m,jh):Mr(r,vn,u,v,m,h,0,jh):x5(r,p,v,u,f,s,m,h,jh)};d(a,!0,t*2,-e+vn),d(o,!0,t*2,e-vn),d(c,!1,e*2,-t+vn),d(l,!1,e*2,t-vn),Mr(r,t*2,vn,e*2,0,i+vn,0,rm),Mr(r,t*2,vn,e*2,0,n-vn,0,rm)}function Xd(r,t,e,i){switch(r){case"front":return{x:0,z:-(e-i)};case"behind":return{x:0,z:e-i};case"left":return{x:-(t-i),z:0};case"right":return{x:t-i,z:0};case"front-left":return{x:-(t-i),z:-ts};case"front-right":return{x:t-i,z:-ts};case"behind-left":return{x:-(t-i),z:ts};case"behind-right":return{x:t-i,z:ts}}}function k1(r,t,e,i,n,s,a){const o=$d();o.scale.setScalar(i),o.rotation.y=F1[t];const{x:c,z:l}=Xd(t,n,s,a);o.position.set(c,e,l),r.add(o)}const Yd=6,qd=6,$s=3,oo=1.4,co=$s*.5,z1=1.2,B1=.35,y5=.75,_5=1.6;function om(r,t,e,i){const n=new Ce,s=Math.max(1,r+1),a=s*$s;ke(n,new Wi(Yd,a,qd),[.55,.54,.5],a/2);const o=Yd/2,c=qd/2;for(let l=0;l<s;l++){const h=l*$s+$s/2;Qn(n,oo,co,jn,0,h,-c-Jn,Bi(t,"front")),Qn(n,oo,co,jn,0,h,c+Jn,Bi(t,"behind")),Qn(n,jn,co,oo,-o-Jn,h,0,Bi(t,"left")),Qn(n,jn,co,oo,o+Jn,h,0,Bi(t,"right"))}if(e){const l=Math.min(Math.max(i??0,0),s-1);k1(n,e,l*$s,.72,o,c,z1);const h=u=>Bi(t,u)!==void 0?[{main:oo,center:0}]:[];U1(n,o,c,l*$s,(l+1)*$s,co,h("front"),h("behind"),h("left"),h("right"))}return n}function cm(){const r=new Ce,t=[[0,0,.55,.5],[.4,.1,.35,.4],[-.35,-.2,.4,.38],[.1,-.4,.35,.36],[-.15,.4,.3,.34]];for(const[e,i,n,s]of t){const a=new oi(n,10,7);a.scale(1,.85,1),a.translate(e,0,i),ke(r,a,[.26,.28,.17],s)}return r}function S5(r){const t=new Ce,e=new Ne(ui.sizeOf(r),r.bridge).build();ke(t,e.concrete,[.6,.6,.58],0);const i=ke(t,e.road,[.2,.2,.21],0),n=ke(t,e.earth,[.3,.36,.22],0);for(const s of[i,n])s.material.side=ji;return ke(t,e.railing,[.5,.52,.55],0),t}function lm(){const r=new Ce;return ke(r,new cs(.15,.22,2,8),[.32,.22,.14],1),ke(r,new kr(1.4,3,8),[.16,.32,.14],3.5),r}const hm=.275,b5=.35,w5=.9,E5=34,A5=8,T5=1.4;function um(){const r=new Ce,t=new oi(hm,7,3,0,Math.PI*2,0,Math.PI/2);t.scale(1,b5/hm,1);const e=ui.repeatOnGrid(t,E5,w5,A5,T5),i=ke(r,e,[.26,.28,.22],0);return i.castShadow=!0,i.userData.cropBasePositions=e.getAttribute("position").array.slice(),i.userData.cropVerticesPerClump=t.getAttribute("position").count,t.dispose(),r}function dm(){const r=new Ce,t=new oi(1,7,3,0,Math.PI*2,0,Math.PI/2);return ke(r,t,[.38,.36,.32],0),r}function fm(r){const t=new Ce;return ke(t,new cs(.05,.08,5,8),[.28,.28,.3],2.5),ke(t,new oi(.25,12,8),r?O1:g5,5.1,!0),t}const R5=[.08,.08,.08],Vs=.8,dr=1,Yn=1.7,Qh=.6,fa=.4,Wc=1.2,hr=.7,ts=.5,D5=Yn;function pm(r,t,e){const i=new Ce;ke(i,new Wi(1.8,1.4,4.2),[.45,.14,.14],.7),ke(i,new Wi(Vs*2,Qh,dr*2),[.4,.12,.12],Yn);for(const s of[-1.4,1.4])for(const a of[-.95,.95]){const o=ke(i,new cs(.4,.4,.3,12),R5,.4);o.rotation.z=Math.PI/2,o.position.x=a,o.position.z=s}const n=r?N1:v5;for(const s of[-.7,.7])ke(i,new oi(.15,8,6),n,.7,!0).position.set(s,.7,-2.1);if(Qn(i,Wc,fa,jn,0,Yn,-dr-Jn,Bi(t,"front")),Qn(i,Wc,fa,jn,0,Yn,dr+Jn,Bi(t,"behind")),Qn(i,jn,fa,hr,-Vs-Jn,Yn,-ts,Bi(t,"front-left")),Qn(i,jn,fa,hr,-Vs-Jn,Yn,ts,Bi(t,"behind-left")),Qn(i,jn,fa,hr,Vs+Jn,Yn,-ts,Bi(t,"front-right")),Qn(i,jn,fa,hr,Vs+Jn,Yn,ts,Bi(t,"behind-right")),e){k1(i,e,y5,.5,Vs,dr,B1);const s=(c,l)=>{const h=[];return Bi(t,c)!==void 0&&h.push({main:hr,center:-ts}),Bi(t,l)!==void 0&&h.push({main:hr,center:ts}),h},a=Bi(t,"front")!==void 0?[{main:Wc,center:0}]:[],o=Bi(t,"behind")!==void 0?[{main:Wc,center:0}]:[];U1(i,Vs,dr,Yn-Qh/2,Yn+Qh/2,fa,a,o,s("front-left","behind-left"),s("front-right","behind-right"))}return i}const mm=new Map;function gm(r,t){if(!r)return;const e=[[r.lengthM,t.lengthM],[r.heightM,t.heightM],[r.widthM,t.widthM]];for(const[i,n]of e)if(i!==void 0&&n>1e-6)return i/n}function tu(r,t){return t>1e-6?r/t:1}const H1=[.95,.9,.82],vm=[.72,.74,.78];function Mm(){const r=new Ce;ke(r,new cs(.25,.3,1.5,10),vm,.75),ke(r,new oi(.26,10,8),vm,1.74);const t=ke(r,new kr(.07,.16,8),H1,1.74);return t.rotation.x=-Math.PI/2,t.position.z=-.22,r}function $d(){const r=new Ce;ke(r,new cs(.25,.3,1.5,10),[.3,.3,.35],.75),ke(r,new oi(.22,10,8),[.62,.52,.46],1.72);const t=ke(r,new kr(.07,.16,8),H1,1.72);return t.rotation.x=-Math.PI/2,t.position.z=-.2,r}const I5=17,xm=18.5,eu=[.16,.16,.18];function ym(){const r=new Ce,t=ke(r,new cs(1.8,1.8,xm*2,10),eu,0);t.rotation.x=Math.PI/2,ke(r,new Wi(I5*2,.5,4.5),eu,0);const e=ke(r,new Wi(.4,5.5,4),eu,3);return e.position.z=-xm+2,r}class ui{static GROWS_FROM_GROUND=new Set(["tree","shrub","crop","mound"]);static groundUnderFootprint(t,e,i,n,s,a=0){const o=ui.sizeOf(t);if(a>o.heightM)return s(e,i);const c=(n??0)*Math.PI/180,l=Math.min(21,Math.max(2,Math.ceil(o.lengthM/.75)+1)),h=Math.min(21,Math.max(2,Math.ceil(o.widthM/.75)+1)),u=ui.GROWS_FROM_GROUND.has(t.kind);let d=u?1/0:-1/0;for(let f=0;f<l;f++){const p=(f/(l-1)-.5)*o.lengthM;for(let v=0;v<h;v++){const m=(v/(h-1)-.5)*o.widthM,g=e+Math.sin(c)*p+Math.cos(c)*m,S=i-Math.cos(c)*p+Math.sin(c)*m;d=u?Math.min(d,s(g,S)):Math.max(d,s(g,S))}}return Number.isFinite(d)?d:s(e,i)}static occupantView(t){const e=t.observerSide;if(!e)throw new Error("occupantView requires object.observerSide to be set");const{x:i,z:n}=t.kind==="vehicle"?Xd(e,Vs,dr,B1):Xd(e,Yd/2,qd/2,z1),s=t.kind==="vehicle"?D5:(t.occupiedFloor??0)*$s+_5,a=(t.headingDeg??0)-F1[e]/Zh,o=this.scaleFor(t);return{x:i*o.x,z:n*o.z,eyeY:s*o.y,headingDeg:a}}static BODY_NAME="decor-body";static bodyOf(t){return t.getObjectByName(ui.BODY_NAME)??t}static repeatOnGrid(t,e,i,n,s){const a=t.getAttribute("position"),o=t.getAttribute("normal"),c=t.getIndex();if(!c)throw new Error("repeatOnGrid needs an indexed geometry");const l=a.count,h=e*n,u=new Float32Array(l*h*3),d=new Float32Array(l*h*3),f=new Uint32Array(c.count*h),p=-((e-1)*i)/2,v=-((n-1)*s)/2;let m=0;for(let S=0;S<n;S++)for(let y=0;y<e;y++,m++){const M=v+S*s,b=p+y*i;for(let w=0;w<l;w++){const T=(m*l+w)*3;u[T]=a.getX(w)+M,u[T+1]=a.getY(w),u[T+2]=a.getZ(w)+b,d[T]=o.getX(w),d[T+1]=o.getY(w),d[T+2]=o.getZ(w)}for(let w=0;w<c.count;w++)f[m*c.count+w]=c.getX(w)+m*l}const g=new ce;return g.setAttribute("position",new de(u,3)),g.setAttribute("normal",new de(d,3)),g.setIndex(new g0(f,1)),g}static fitCropToGround(t,e){t.updateMatrixWorld(!0);const i=new R;t.traverse(n=>{const s=n,a=s.userData.cropBasePositions,o=s.userData.cropVerticesPerClump;if(!s.isMesh||!a||!o)return;const c=s.geometry.getAttribute("position"),l=new Jt().copy(s.matrixWorld).invert();for(let h=0;h<c.count;h+=o){i.set(a[h*3],0,a[h*3+2]).applyMatrix4(s.matrixWorld),i.y=e(i.x,i.z),i.applyMatrix4(l);for(let u=h;u<h+o;u++)c.setY(u,a[u*3+1]+i.y)}c.needsUpdate=!0,s.geometry.computeBoundingBox(),s.geometry.computeBoundingSphere()})}static paint(t,e){t.traverse(i=>{const n=i,s=n.userData;if(!n.isMesh||s?.emissive)return;const a=n.material;a?.color&&a.color.set(e)})}static build(t,e){const i=t.kind==="building"?om(t.floors??tf,t.windows,t.observerSide,t.occupiedFloor):t.kind==="tree"?lm():t.kind==="shrub"?cm():t.kind==="bridge"?S5(t):t.kind==="crop"?um():t.kind==="mound"?dm():t.kind==="streetlight"?fm(e):t.kind==="vehicle"?pm(e,t.windows,t.observerSide):t.kind==="aircraft"?ym():t.kind==="entity"?Mm():$d();t.color&&this.paint(i,t.color);const n=this.scaleFor(t),s=new Ce;return i.name=ui.BODY_NAME,i.scale.copy(n),s.add(i),t.headingDeg!==void 0&&(s.rotation.y=-t.headingDeg*Zh),this.addLights(s,t.lights),s}static scaleFor(t){const e=t.sizeM;if(!e||t.kind==="bridge")return new R(1,1,1);const i=this.naturalSize(t.kind,t.floors);return new R(e.widthM===void 0?1:tu(e.widthM,i.widthM),e.heightM===void 0?1:tu(e.heightM,i.heightM),e.lengthM===void 0?1:tu(e.lengthM,i.lengthM))}static naturalSize(t,e){const i=t==="building"?Math.max(1,(e??tf)+1):0;if(t==="bridge")return Ne.NATURAL_SIZE;const n=`${t}:${i}`,s=mm.get(n);if(s)return s;const a=t==="building"?om(i-1,void 0,void 0,void 0):t==="tree"?lm():t==="shrub"?cm():t==="crop"?um():t==="mound"?dm():t==="streetlight"?fm(!1):t==="vehicle"?pm(!1,void 0,void 0):t==="aircraft"?ym():t==="entity"?Mm():$d(),o=new Vi().setFromObject(a),c={widthM:o.max.x-o.min.x,heightM:o.max.y-o.min.y,lengthM:o.max.z-o.min.z};return this.dispose(a),mm.set(n,c),c}static usesModel(t){return t.model!==void 0&&!(t.observerSide!==void 0&&ng(t.kind))}static applyModel(t,e,i,n={}){const s=this.bodyOf(t),a=new Ce;a.name=ui.BODY_NAME,i.rotation.y=-(n.headingOffsetDeg??0)*Zh,i.updateMatrixWorld(!0);const o=new Vi().setFromObject(i),c={lengthM:o.max.z-o.min.z,heightM:o.max.y-o.min.y,widthM:o.max.x-o.min.x},l=gm(e.sizeM,c)??gm(n.depictedSizeM,c)??1;i.scale.multiplyScalar(l);const h=o.getCenter(new R).multiplyScalar(l);i.position.x-=h.x,i.position.z-=h.z,i.position.y-=e.kind==="aircraft"?h.y:o.min.y*l,i.traverse(u=>{u instanceof Dt&&(u.castShadow=!0,u.receiveShadow=!0)}),a.add(i),s.parent?(s.parent.add(a),s.removeFromParent()):t.add(a),this.dispose(s)}static sizeOf(t){const e=this.naturalSize(t.kind,t.floors);return{widthM:t.sizeM?.widthM??e.widthM,lengthM:t.sizeM?.lengthM??e.lengthM,heightM:t.sizeM?.heightM??e.heightM}}static addLights(t,e){for(const i of e??[]){const n=m5(i.color),s=ke(t,new oi(Jh,8,6),n,i.offsetM.y,!0);s.position.set(i.offsetM.x,i.offsetM.y,i.offsetM.z),s.userData={emissive:!0,lightId:i.id,lightColor:n},s.visible=!1}}static setLights(t,e,i,n,s=0,a=1,o=l5){if(!e||e.length===0)return;const c=new Map(e.map(d=>[d.id,d])),l=Math.max(1,n*o/Jh),h=Jh*l,u=a/(Math.PI*h*h);for(const d of t.children){if(!(d instanceof Dt))continue;const f=d.userData.lightId;if(!f)continue;const p=c.get(f);if(!p)continue;const v=s>0?sg(p,i,i+s):av(p,i)?1:0;d.visible=v>0;const m=d.material,g=d.userData.lightColor;if(g){const S=v*h5*(p.intensity??1)*u;m.color.setRGB(g[0]*S,g[1]*S,g[2]*S)}d.scale.setScalar(l)}}static setLit(t,e,i,n=1){const[s,a,o]=e==="streetlight"?[u5,d5,O1]:[f5,p5,N1],c=i?s*n/(Math.PI*a*a):0,l=[o[0]*c,o[1]*c,o[2]*c];t.traverse(h=>{const u=h.userData;!(h instanceof Dt)||!u.emissive||u.lightId||h.material.color.setRGB(...l)})}static dispose(t){t.traverse(e=>{if(!(e instanceof Dt))return;e.geometry.dispose();const i=e.material;for(const n of Array.isArray(i)?i:[i])n.dispose()})}}const iu="https://ufoathome.org/models/index.json";class C5{attribution="3D models re-hosted by UFO@home, each under its own author's licence";fetchImpl;indexUrls;loading;constructor(t={}){this.fetchImpl=t.fetchImpl??fetch.bind(globalThis),this.indexUrls=t.indexUrls??P5()}async entries(t){const e=await this.load();return t?e.filter(i=>i.kind===t):e}async entry(t){return(await this.load()).find(e=>e.id===t)}load(){return this.loading??=this.fetchFirstAvailable(),this.loading}async fetchFirstAvailable(){for(const t of this.indexUrls){const e=await this.fetchIndex(t);if(e)return e}return[]}async fetchIndex(t){try{const e=await this.fetchImpl(t);if(!e.ok)return;const i=await e.json();return Array.isArray(i?.models)?i.models.map(({file:n,...s})=>({...s,url:new URL(n,t).href})):void 0}catch{return}}}function P5(){const r=`?v=${encodeURIComponent("0.81.8")}`,t=typeof location>"u"?void 0:new URL("/models/index.json",location.href).href;return(t&&t!==iu?[t,iu]:[iu]).map(e=>e+r)}const L5=[{id:"ufoathome",name:"UFO@home",credit:"3D models re-hosted by UFO@home, each under its own author's licence",creditUrl:"https://ufoathome.org/models/",create:()=>new C5}];async function _m(r){const{GLTFLoader:t}=await is(async()=>{const{GLTFLoader:i}=await import("./GLTFLoader-BumifFuq.js");return{GLTFLoader:i}},[],import.meta.url),e=new t;return new Promise((i,n)=>{e.load(r,s=>i(Object.assign(s.scene,{animations:s.animations})),void 0,s=>n(new Error(`Could not load 3D model ${r}: ${s instanceof Error?s.message:String(s)}`)))})}const G1=["ellipsoid","sphere","disc","cylinder","cone","box","torus","figure"];class ln{static MIN_ANGLE_RAD=.002;static FILL=(1-Math.exp(-4))/4;static MAX_SHARE=.3;mesh;constructor(t,e){this.mesh=new Dt(new Xi(2,2),new le({uniforms:{uColor:{value:new st(0,0,0)},uRadius:{value:1}},vertexShader:ln.VERTEX,fragmentShader:ln.FRAGMENT,transparent:!0,depthWrite:!1,blending:Ni,toneMapped:!1})),this.mesh.name=t,this.mesh.frustumCulled=!1,this.mesh.renderOrder=e,this.mesh.visible=!1}shine(t,e,i){this.mesh.visible=!0,this.mesh.position.set(t.x,t.y,t.z),this.mesh.material.uniforms.uRadius.value=e,this.mesh.material.uniforms.uColor.value.setRGB(i[0],i[1],i[2])}hide(){this.mesh.visible=!1}dispose(){this.mesh.geometry.dispose(),this.mesh.material.dispose()}static spread(t,e,i,n){const s=Math.max(t,n*ln.MIN_ANGLE_RAD),a=ln.FILL*Math.PI*s*s;return{radiusM:s,luminanceCdM2:i*Math.min(ln.MAX_SHARE,e/a)}}static conserving(t){return Math.sqrt(t/(ln.MAX_SHARE*ln.FILL*Math.PI))}static VERTEX=`
|
|
7194
7204
|
uniform float uRadius;
|
|
7195
7205
|
varying vec2 vOffset;
|
|
7196
7206
|
void main() {
|
|
@@ -7610,7 +7620,7 @@ cloudPoint = (modelMatrix * vec4(transformed, 1.0)).xyz - cameraPosition;`);let
|
|
|
7610
7620
|
}
|
|
7611
7621
|
outColor = xyzs;
|
|
7612
7622
|
}
|
|
7613
|
-
`}class
|
|
7623
|
+
`}class Fe{static AIRGLOW_LAYER_ALTITUDE_M=9e4;static SUN_MAGNITUDE=-26.74;tables;material;onChange;state;drawnKey="";hasViews=!1;adaptingLuminance=1;get adaptation(){return this.adaptingLuminance*this.exposureScale}get sceneAdaptation(){return this.adaptingLuminance}ambientColours;reading=!1;exposureScale=1;seenByEye=!0;readAgain=!1;constructor(t,e){this.onChange=e,this.tables=new Wt(t),this.tables.setMedium(new Ft),this.material=new le({glslVersion:Sl,side:Ve,depthWrite:!1,uniforms:{uSunView:{value:this.tables.sunViewTexture},uMoonView:{value:this.tables.moonViewTexture},uSunAzimuth:{value:new xt(0,-1)},uMoonAzimuth:{value:new xt(0,-1)},uMoonScale:{value:0},uObserverRadius:{value:Ft.GROUND_RADIUS_M+2},uAirglow:{value:new ne(...Fe.airglowXyzs())},uArtificial:{value:new ne(0,0,0,0)},uRodShare:{value:0},uInverseSemiSaturation:{value:1},uExposureScale:{value:1}},vertexShader:`
|
|
7614
7624
|
varying vec3 vDirection;
|
|
7615
7625
|
void main() {
|
|
7616
7626
|
vDirection = (modelMatrix * vec4(position, 1.0)).xyz - cameraPosition;
|
|
@@ -7635,7 +7645,7 @@ cloudPoint = (modelMatrix * vec4(transformed, 1.0)).xyz - cameraPosition;`);let
|
|
|
7635
7645
|
uniform float uExposureScale;
|
|
7636
7646
|
const float PI = 3.141592653589793;
|
|
7637
7647
|
const float GROUND = ${Ft.GROUND_RADIUS_M.toFixed(1)};
|
|
7638
|
-
const float AIRGLOW_RATIO = ${(Ft.GROUND_RADIUS_M/(Ft.GROUND_RADIUS_M+
|
|
7648
|
+
const float AIRGLOW_RATIO = ${(Ft.GROUND_RADIUS_M/(Ft.GROUND_RADIUS_M+Fe.AIRGLOW_LAYER_ALTITUDE_M)).toFixed(6)};
|
|
7639
7649
|
const float EXTINCTION = ${Mt.EXTINCTION_PER_AIR_MASS.toFixed(4)};
|
|
7640
7650
|
const float ARTIFICIAL_ZENITH_FRACTION = ${Mt.scatteredFraction(90).toFixed(6)};
|
|
7641
7651
|
const vec2 VIEW_SIZE = vec2(${Wt.SKY_VIEW_WIDTH}.0, ${Wt.SKY_VIEW_HEIGHT}.0);
|
|
@@ -7694,7 +7704,7 @@ cloudPoint = (modelMatrix * vec4(transformed, 1.0)).xyz - cameraPosition;`);let
|
|
|
7694
7704
|
gl_FragColor = vec4(relativeOf(light.xyz, light.w), 1.0);
|
|
7695
7705
|
#include <colorspace_fragment>
|
|
7696
7706
|
}
|
|
7697
|
-
`})}get supported(){return this.tables.supported}get ready(){return this.hasViews}get ambient(){return this.ready?this.ambientColours:void 0}setInstrument(t,e){const i=t?10**(.4*e):1;i===this.exposureScale&&this.seenByEye===!t||(this.exposureScale=i,this.seenByEye=!t,this.material.uniforms.uExposureScale.value=i,this.applyAdaptation(this.adaptingLuminance),this.onChange())}setConditions(t){this.tables.setMedium(new Ft(t)),this.tables.ready||(this.drawnKey="")}advance(t){!this.supported||this.tables.ready||this.tables.advance(t)&&this.state&&this.draw(this.state)}invalidate(){this.tables.invalidate(),this.drawnKey="",this.hasViews=!1}update(t){this.state=t,this.tables.ready?this.draw(t):this.hasViews||this.applyAdaptation(
|
|
7707
|
+
`})}get supported(){return this.tables.supported}get ready(){return this.hasViews}get ambient(){return this.ready?this.ambientColours:void 0}setInstrument(t,e){const i=t?10**(.4*e):1;i===this.exposureScale&&this.seenByEye===!t||(this.exposureScale=i,this.seenByEye=!t,this.material.uniforms.uExposureScale.value=i,this.applyAdaptation(this.adaptingLuminance),this.onChange())}setConditions(t){this.tables.setMedium(new Ft(t)),this.tables.ready||(this.drawnKey="")}advance(t){!this.supported||this.tables.ready||this.tables.advance(t)&&this.state&&this.draw(this.state)}invalidate(){this.tables.invalidate(),this.drawnKey="",this.hasViews=!1}update(t){this.state=t,this.tables.ready?this.draw(t):this.hasViews||this.applyAdaptation(Fe.predictedZenithLuminance(t))}dispose(){this.tables.dispose(),this.material.dispose()}draw(t){const e=[t.altitudeM.toFixed(0),t.sun.altitudeDeg.toFixed(3),t.moon.altitudeDeg.toFixed(3),t.lightPollution??""].join(":"),i=this.material.uniforms;if(i.uArtificial.value.set(...Fe.artificialXyzs(t.lightPollution)),i.uSunAzimuth.value.copy(Fe.azimuthVector(t.sun.azimuthDeg)),i.uMoonAzimuth.value.copy(Fe.azimuthVector(t.moon.azimuthDeg)),i.uMoonScale.value=10**(-.4*(t.moon.magnitude-Fe.SUN_MAGNITUDE)),i.uObserverRadius.value=Ft.GROUND_RADIUS_M+Math.max(t.altitudeM,2),e!==this.drawnKey){this.tables.renderSkyViews(t.altitudeM,t.sun.altitudeDeg,t.moon.altitudeDeg);const n=!this.hasViews;this.hasViews=!0,this.drawnKey=e,n&&!this.ambientColours&&this.adaptFromViews(this.tables.readSkyViewNow("sun"),this.tables.readSkyViewNow("moon"),t),this.readBack()}this.onChange()}async readBack(){if(this.reading){this.readAgain=!0;return}this.reading=!0;let t=!1;try{const[e,i]=await Promise.all([this.tables.readSkyView("sun"),this.tables.readSkyView("moon")]),n=this.state;n&&this.adaptFromViews(e,i,n)}catch{t=!0,this.drawnKey=""}finally{this.reading=!1}if(t){this.readAgain=!1;return}this.readAgain&&(this.readAgain=!1,this.readBack())}adaptToSurroundings(t){if(!(t>0)||!(this.clearAdaptation>0))return!1;const e=t/this.clearAdaptation;return Math.abs(Math.log(e/this.surroundingsFactor))<.05?!1:(this.surroundingsFactor=e,this.views&&this.state?this.adaptFromViews(this.views.sun,this.views.moon,this.state):this.applyAdaptation(this.clearAdaptation*e),!0)}resetSurroundings(){this.surroundingsFactor=1}surroundingsFactor=1;clearAdaptation=0;views;adaptFromViews(t,e,i){this.views={sun:t,moon:e};const n=10**(-.4*(i.moon.magnitude-Fe.SUN_MAGNITUDE)),s=Fe.airglowXyzs(),a=Fe.artificialXyzs(i.lightPollution),o=(y,M,b=!0)=>{const w=(90-y)*Math.PI/180,T=Wt.skyViewUv(i.altitudeM,w,Fe.azimuthBetween(M,i.sun.azimuthDeg)),x=Wt.skyViewUv(i.altitudeM,w,Fe.azimuthBetween(M,i.moon.azimuthDeg)),A=Fe.bilinear(t,T.u,T.v),C=Fe.bilinear(e,x.u,x.v),I=b&&y>0?Fe.airglowFactor(y):0,P=y>0?Mt.artificialShape(y):0;return[0,1,2,3].map(V=>A[V]+n*C[V]+s[V]*I+a[V]*P)};let c=0,l=0;for(let y=5;y<90;y+=10){const M=Math.cos(y*Math.PI/180);for(let b=0;b<360;b+=30)c+=M*Math.log(Math.max(o(y,b)[1],1e-9)),l+=M}this.clearAdaptation=Math.exp(c/l),this.applyAdaptation(this.clearAdaptation*this.surroundingsFactor);const h=([y,M,b,w])=>{const T=this.exposureScale,x=this.adaptingLuminance*T;return At.relativeOf([y*T,M*T,b*T],w*T,x,0)},u=(y,M,b=!0)=>h(o(y,M,b)),d=[0,0,0,0],f=5*Math.PI/180,p=20*Math.PI/180;for(let y=2.5;y<90;y+=5){const M=y*Math.PI/180,b=Math.sin(M)*Math.cos(M)*f*p;for(let w=10;w<360;w+=20){const T=o(y,w);for(let x=0;x<4;x++)d[x]+=T[x]*b}}const v=[0,0,0],m=[0,0,0];for(let y=0;y<360;y+=20){const M=u(2,y),b=u(2,y,!1);for(let w=0;w<3;w++)v[w]+=M[w]/18,m[w]+=b[w]/18}const g=this.ambientColours,S=this.announcedAdaptation;this.ambientColours={zenith:u(90,0),horizon:v,airlight:m,skyIrradiance:h(d),scale:this.relativeScale},this.announcedAdaptation=this.adaptingLuminance,!(g&&Fe.alike(S,this.adaptingLuminance)&&g.zenith.every((y,M)=>Fe.alike(y,this.ambientColours.zenith[M]))&&g.horizon.every((y,M)=>Fe.alike(y,v[M])))&&this.onChange()}announcedAdaptation=0;static alike(t,e){return t===e||Math.abs(t-e)<=.01*Math.max(Math.abs(t),Math.abs(e))}relativeOfLuminance(t,e){const[i,n,s]=t,a=.2126*i+.7152*n+.0722*s,o=a>0?e/a:0,c=[o*(.4124*i+.3576*n+.1805*s),e,o*(.0193*i+.1192*n+.9505*s)],l=this.exposureScale,h=this.adaptingLuminance*l;return At.relativeOf([c[0]*l,c[1]*l,c[2]*l],c[1]*l,h,0)}get rodShare(){const t=this.adaptingLuminance*this.exposureScale;return this.seenByEye?At.rodShare(t):0}get relativeScale(){const t=this.adaptingLuminance*this.exposureScale;return this.exposureScale/At.semiSaturation(t)}applyAdaptation(t){this.adaptingLuminance=t;const e=t*this.exposureScale;this.material.uniforms.uRodShare.value=0,this.material.uniforms.uInverseSemiSaturation.value=1/At.semiSaturation(e)}static predictedZenithLuminance(t){const e=n=>90-n.altitudeDeg,i=Mt.magPerArcsec2({altitudeDeg:t.sun.altitudeDeg,separationDeg:e(t.sun)},{phaseAngleDeg:t.moon.phaseAngleDeg,altitudeDeg:t.moon.altitudeDeg,separationDeg:e(t.moon)},90,t.lightPollution);return Mt.toNanolamberts(i)*Fe.CANDELAS_PER_NANOLAMBERT}static CANDELAS_PER_NANOLAMBERT=1e-5/Math.PI;static airglowXyzs(){const t=Mt.toNanolamberts(Mt.AIRGLOW_MAG_PER_ARCSEC2)*Fe.CANDELAS_PER_NANOLAMBERT;return[t*.3127/.329,t,t*(1-.3127-.329)/.329,t]}static artificialXyzs(t){const e=Mt.artificialZenithNanolamberts(t)*Fe.CANDELAS_PER_NANOLAMBERT;return[e*.4369/.4041,e,e*(1-.4369-.4041)/.4041,e]}static airglowFactor(t){const e=Math.cos(t*Math.PI/180)**2,i=Ft.GROUND_RADIUS_M/(Ft.GROUND_RADIUS_M+Fe.AIRGLOW_LAYER_ALTITUDE_M),n=1/Math.sqrt(Math.max(1-i*i*e,1e-4)),s=1/Math.sqrt(Math.max(1-.96*e,.001));return n*10**(-.4*Mt.EXTINCTION_PER_AIR_MASS*(s-1))}static azimuthVector(t){const e=t*Math.PI/180;return new xt(Math.sin(e),-Math.cos(e))}static azimuthBetween(t,e){const i=Math.abs(t-e)%360;return(i>180?360-i:i)*Math.PI/180}static bilinear(t,e,i){const n=Wt.SKY_VIEW_WIDTH,s=Wt.SKY_VIEW_HEIGHT,a=Math.min(Math.max(e*n-.5,0),n-1),o=Math.min(Math.max(i*s-.5,0),s-1),c=Math.floor(a),l=Math.floor(o),h=Math.min(c+1,n-1),u=Math.min(l+1,s-1),d=a-c,f=o-l,p=(v,m,g)=>t[(v*n+m)*4+g];return[0,1,2,3].map(v=>(p(l,c,v)*(1-d)+p(l,h,v)*d)*(1-f)+(p(u,c,v)*(1-d)+p(u,h,v)*d)*f)}}class ta{static DRY_OPTICAL_DEPTH=.08;static GROWTH_EXPONENT=.3;static MAX_RELATIVE_HUMIDITY=.95;static OPTICAL_DEPTH_STEP=.02;static relativeHumidity(t,e){const i=n=>Math.exp(17.625*n/(243.04+n));return Math.min(Math.max(i(e)/i(t),0),1)}static opticalDepth(t){const e=Math.min(Math.max(t,0),ta.MAX_RELATIVE_HUMIDITY);return ta.DRY_OPTICAL_DEPTH*(1-e)**-.3}static steppedOpticalDepth(t){const e=ta.OPTICAL_DEPTH_STEP;return Math.round(ta.opticalDepth(t)/e)*e}}class xn{static CHANNEL_WAVELENGTHS_NM=[680,550,440];static KOSCHMIEDER=-Math.log(.02);static PRECIPITATION_EXTINCTION_PER_KM={rain:{a:.365,b:.63},snow:{a:1.023,b:.72},hail:{a:.365,b:.63}};static FULL_INTENSITY_MM_PER_H=8;rayleigh;aerosol;constructor(t=Ft.DEFAULT_AEROSOL_OPTICAL_DEPTH,e=0){const[i,n,s]=xn.CHANNEL_WAVELENGTHS_NM;this.rayleigh=[Ft.rayleighAt(i),Ft.rayleighAt(n),Ft.rayleighAt(s)];const a=o=>t/Ft.AEROSOL_SCALE_HEIGHT_M*(o/550)**-1.3;this.aerosol=[a(i)+e,a(n)+e,a(s)+e],this.precipitationPerM=e}precipitationPerM;static of(t){const e=t.relativeHumidity===void 0?void 0:ta.opticalDepth(t.relativeHumidity);return new xn(e,xn.precipitationExtinction(t))}static precipitationExtinction(t){const e=t.precipitationIntensity*(t.precipitationAmount??1);if(t.precipitationType==="none"||!(e>0))return 0;const i=xn.PRECIPITATION_EXTINCTION_PER_KM[t.precipitationType],n=e*xn.FULL_INTENSITY_MM_PER_H;return i.a*n**i.b/1e3}transmittance(t,e,i){const n=xn.meanDensity(t,e,Ft.RAYLEIGH_SCALE_HEIGHT_M),s=xn.meanDensity(t,e,Ft.AEROSOL_SCALE_HEIGHT_M);return[0,1,2].map(a=>Math.exp(-(this.rayleigh[a]*n+this.aerosol[a]*s)*i))}transmittanceFromSpace(t,e){const i=Math.max(e,0),n=1/(Math.sin(i*Math.PI/180)+.50572*(i+6.07995)**-1.6364),s=Ft.RAYLEIGH_SCALE_HEIGHT_M*Ft.rayleighDensity(t),a=Ft.AEROSOL_SCALE_HEIGHT_M*Ft.aerosolDensity(t);return[0,1,2].map(o=>Math.exp(-(this.rayleigh[o]*s+(this.aerosol[o]-this.precipitationPerM)*a)*n))}extinctionAt(t){return{rayleigh:this.rayleigh[1]*Ft.rayleighDensity(t),aerosol:this.aerosol[1]*Ft.aerosolDensity(t)}}visibilityM(t){const{rayleigh:e,aerosol:i}=this.extinctionAt(t);return xn.KOSCHMIEDER/(e+i)}get rayleighRatios(){return[this.rayleigh[0]/this.rayleigh[1],1,this.rayleigh[2]/this.rayleigh[1]]}static meanDensity(t,e,i){const n=Math.max(t,0),s=Math.max(e,0),a=s-n;return Math.abs(a)<.01?Math.exp(-n/i):i*(Math.exp(-n/i)-Math.exp(-s/i))/a}}class La extends m0{constructor(){super(new st(0,0,0),0,0),La.install()}setAir(t,e,i){const{rayleigh:n,aerosol:s}=t.extinctionAt(e);this.near=n,this.far=s,this.color.setRGB(i[0],i[1],i[2])}static fadeRim(t,e,i){t.transparent=!0,t.onBeforeCompile=n=>{n.fragmentShader=n.fragmentShader.replace("#include <fog_fragment>",`#include <fog_fragment>
|
|
7698
7708
|
#ifdef USE_FOG
|
|
7699
7709
|
gl_FragColor.a *= 1.0 - smoothstep(${e.toFixed(1)}, ${i.toFixed(1)}, length(vAerialWorld.xz - cameraPosition.xz));
|
|
7700
7710
|
#endif`)},t.customProgramCacheKey=()=>`aerial-rim-${e.toFixed(1)}-${i.toFixed(1)}`,t.needsUpdate=!0}static installed=!1;static install(){if(La.installed)return;La.installed=!0;const t=new xn(1),e=t.rayleighRatios,i=[t.aerosol[0]/t.aerosol[1],1,t.aerosol[2]/t.aerosol[1]],n=o=>`vec3(${o.map(c=>c.toFixed(4)).join(", ")})`,s=Ft.RAYLEIGH_SCALE_HEIGHT_M.toFixed(1),a=Ft.AEROSOL_SCALE_HEIGHT_M.toFixed(1);Xt.fog_pars_vertex=`
|
|
@@ -7753,7 +7763,7 @@ cloudPoint = (modelMatrix * vec4(transformed, 1.0)).xyz - cameraPosition;`);let
|
|
|
7753
7763
|
vec3 light = texture2D(uMap, vec2((along * (uSteps - 1.0) + 0.5) / uSteps, 0.5)).rgb;
|
|
7754
7764
|
gl_FragColor = vec4(light, 1.0);
|
|
7755
7765
|
}
|
|
7756
|
-
`,transparent:!0,blending:Ni,depthWrite:!1,side:Ve,fog:!1});this.object=new Dt(new oi(B0.RADIUS,128,32,0,Math.PI*2,0,pe.MAX_ANGLE_RAD),e),this.object.renderOrder=-1,this.object.frustumCulled=!1,this.object.visible=!1}show(t,e){if(!t||!e){this.object.visible=!1;return}this.towards.set(t.x,t.y,t.z).normalize(),this.object.quaternion.setFromUnitVectors(this.up,this.towards),this.object.material.uniforms.uSource.value.copy(this.towards);for(let i=0;i<pe.STEPS;i++){for(let n=0;n<3;n++)this.texels[i*4+n]=Fn.toHalfFloat(Math.min(e[i*3+n],6e4));this.texels[i*4+3]=Fn.toHalfFloat(1)}this.texture.needsUpdate=!0,this.object.visible=!0}dispose(){this.object.geometry.dispose(),this.object.material.dispose(),this.texture.dispose()}}class Nl{constructor(t){this.generator=t}static SIZE=128;target=new Wo(Nl.SIZE,{type:qe,generateMipmaps:!1,minFilter:oe,magFilter:oe});camera=new b0(.1,2e5,this.target);filteredTarget;capturedAtMs=-1/0;capturedVersion;get sharp(){return this.target.texture}get filtered(){return this.filteredTarget?.texture}capture(t,e,i,n=[]){const s=t.shadowMap.autoUpdate;let a=!1;e.traverse(c=>{const l=c;l.isLight&&l.castShadow&&l.shadow&&!l.shadow.map&&(a=!0)}),t.shadowMap.autoUpdate=a?s:!1;const o=n.map(c=>c.visible);for(const c of n)c.visible=!1;this.camera.position.copy(i),this.camera.update(t,e),n.forEach((c,l)=>{c.visible=o[l]}),t.shadowMap.autoUpdate=s,this.filteredTarget=this.generator.fromCubemap(this.target.texture,this.filteredTarget),this.capturedAtMs=performance.now()}dispose(){this.target.dispose(),this.filteredTarget?.dispose()}}class on{static REFRESH_MS=250;generator;eye;probes=new Map;constructor(t){on.install(),this.generator=new gd(t),this.eye=new Nl(this.generator)}static decor;refresh(t,e,i,n,s,a,o,c=[],l,h=on.REFRESH_MS){for(const m of[...this.probes.keys()])n.some(g=>g.id===m&&g.shiny)||(this.probes.get(m).dispose(),this.probes.delete(m));const u=[{probe:this.eye}];for(const m of n){if(!m.shiny)continue;let g=this.probes.get(m.id);g||(g=new Nl(this.generator),this.probes.set(m.id,g)),u.push({probe:g,reflector:m})}const d=performance.now(),f=()=>u.filter(({probe:m})=>m.capturedVersion!==o),p=f().filter(({probe:m})=>d-m.capturedAtMs>=h);if(p.length>0){const m=p.reduce((g,S)=>S.probe.capturedAtMs<g.probe.capturedAtMs?S:g);if(m.reflector){const g=m.reflector.holder.getWorldPosition(this.scratch);m.probe.capture(t,e,g,[m.reflector.holder,...s]),on.reflectOn(m.reflector.holder,m.probe)}else{m.probe.capture(t,e,i,[...s,...c]),l?.(m.probe.sharp),on.decor=m.probe.filtered;for(const g of a)on.reflectOn(g,m.probe);for(const g of n)g.shiny||on.reflectOn(g.holder,m.probe)}m.probe.capturedVersion=o}const v=f();if(v.length!==0)return Math.max(16,Math.min(...v.map(({probe:m})=>h-(d-m.capturedAtMs))))}scratch=new R;static reflectOn(t,e={filtered:on.decor}){t.traverse(i=>{const n=i.material;for(const s of Array.isArray(n)?n:n?[n]:[])s instanceof Yo?e.sharp&&s.setSurroundings(e.sharp):s instanceof ya&&e.filtered&&s.envMap!==e.filtered&&(s.envMap=e.filtered,s.needsUpdate=!0)})}dispose(){this.eye.dispose();for(const t of this.probes.values())t.dispose();this.generator.dispose()}static installed=!1;static install(){if(on.installed)return;on.installed=!0;const t="iblIrradiance += getIBLIrradiance( geometryNormal );";if(!Xt.lights_fragment_maps.includes(t)){console.warn("Reflections: three's lights_fragment_maps changed; the environment will light diffusely too");return}Xt.lights_fragment_maps=Xt.lights_fragment_maps.replace(t,"// The sky's diffuse light is the hemisphere light's (see Reflections).")}}function F5(r,t){return JSON.stringify(r.cloudLayers)===JSON.stringify(t.cloudLayers)&&r.cloudCover===t.cloudCover&&r.cloudDarkness===t.cloudDarkness&&r.cloudBaseM===t.cloudBaseM&&r.highCloudCover===t.highCloudCover&&r.iceCrystalAlignment===t.iceCrystalAlignment&&r.lowerCloudCover===t.lowerCloudCover&&r.relativeHumidity===t.relativeHumidity&&r.precipitationType===t.precipitationType&&r.precipitationIntensity===t.precipitationIntensity&&r.precipitationAmount===t.precipitationAmount&&r.windDirectionDeg===t.windDirectionDeg&&r.windSpeed===t.windSpeed&&r.storm===t.storm}const qc=900,nu=1,Sm=4,bm=5,wm=.5,_o=900,U5=6371e3,k5=3e4;function Em(r){const t=Math.sqrt(2*U5*Math.max(r,0));return Math.max(_o,Math.min(t,k5))}const su=.5,au=850,Am=.03,sn=850,ho=300,Gs=120,z5=700,B5=.04,uo=4,ru=1.5,Tm=-1,H5=6,Kd=-4,G5=2,V5=20,$c=2600,W5=.97,X5=.38,Kc=Kd,Rm=1500,Y5=400,q5=[0,45,90,135,180,225,270,315],$5=2,K5=16,Dm=4e3,Im=880,Zc=40,Cm=60,Z5=10,J5=1,j5=150,Q5=55,tE=.5,eE=17,Pm=.265,Lm=[[0,0],...Array.from({length:8},(r,t)=>{const e=t*Math.PI/4;return[Math.cos(e)*Pm,Math.sin(e)*Pm]})],ou=700,cu=250/Jd,iE=12,Om=5,lu=6,pa=[.92,.92,.95],hu=[.15,.15,.19],uu={snow:{fallSpeedMPerS:2,size:.3,color:new st(1,1,1),driftSensitivity:1,radiusM:25,topYM:20,opacity:.75,poolSize:2400},hail:{fallSpeedMPerS:14,size:.5,color:new st(.95,.98,1),driftSensitivity:.25,radiusM:25,topYM:10,opacity:.95,poolSize:1200}},fr=0,du=0,nE=150,fu=3e3,fo=20,sE=15,Nm=fr,aE=40,Fm=1,rE=9;function pu(r){return Fm+(rE-Fm)*r}const Um=new st(.75,.82,.92),oE=10,cE=.5;function km(r){return xr(r/oE,cE,1)}const ma=200,zm=.18,Bm=.32,lE=.35,Hm=new st(.85,.9,.98),Gm=5,Vm=.85,Wm=.01;function hE(r,t,e=1){return Math.round(r*(Wm+(1-Wm)*t)*e)}function uE(r,t){return JSON.stringify(r.cloudLayers)===JSON.stringify(t.cloudLayers)&&r.cloudCover===t.cloudCover&&r.cloudDarkness===t.cloudDarkness&&r.cloudBaseM===t.cloudBaseM&&r.highCloudCover===t.highCloudCover&&r.iceCrystalAlignment===t.iceCrystalAlignment&&r.lowerCloudCover===t.lowerCloudCover}const Xm=230,Ym=.7,qm=.05,dE=.6,fE=.7,pE=.15,$m=.35,mE=3,gE=1/12,vE=.5,Xn=new st(.82,.86,1),ME=2500,xE=1.6,mu=15,yE={Venus:new st(1,.96,.85),Mars:new st(1,.55,.4),Jupiter:new st(.95,.87,.72),Saturn:new st(.92,.86,.68)};class ke{renderer;scene=new Ts;phenomena=new In(this.scene);references=new Rn(this.scene,()=>this.render());camera;celestialGroup=new Ce;skyMesh;skyGradientMaterial;scatteredSky;lastAstronomy;skyColoursStale=!1;scatteredSkyFrameId=null;skyHoldUntilMs=void 0;onFirstFrameHold;firstFrameReady(){return(!this.scatteredSky||this.scatteredSky.ambient!==void 0)&&!this.iceHalos?.awaitingFirstDisplay}sceneSettled(){return this.firstFrameReady()&&this.arrivalsPending===0&&this.eyeSettledVersion>=this.lastArrivalVersion}arrivalsPending=0;eyeSettledVersion=-1;lastArrivalVersion=0;awaitArrival(t,e){if(this.skyHoldUntilMs===null)return t;this.arrivalsPending++;let i=!0;const n=()=>{i&&(i=!1,this.arrivalsPending--,this.lastArrivalVersion=this.sceneVersion,this.skyHoldUntilMs&&this.redrawHeld())},s=e===void 0?void 0:setTimeout(n,e);return t.finally(()=>{clearTimeout(s),n()})}static ROADS_PATIENCE_MS=1500;redrawHeld(){this.frameDirty=!0,!(this.animationFrameId!==null||this.framesDriven||this.flushFrameId!==null)&&(this.flushFrameId=requestAnimationFrame(()=>{this.flushFrameId=null,this.drawIfDirty()}))}holdForNewScene(t){this.surroundings=void 0,this.scatteredSky?.resetSurroundings(),this.startHold(),t&&this.awaitArrival(t).catch(()=>{})}startHold(){this.skyHoldUntilMs=performance.now()+Dm,this.eyeSettledVersion=-1,this.lastArrivalVersion=this.sceneVersion+1,this.iceHalos?.setUrgent(!0),this.onFirstFrameHold?.(!0),setTimeout(()=>this.render(),Dm+20)}groundMesh;terrainMesh;terrainProviders;terrainOrigin;terrainBuildToken=0;terrainAttribution;roadSystem=new gn;roadAttribution;roadWays;statedRoads=[];decorModelProvider=L5[0].create();decorModelToken=0;decorModelCredits=new Map;bodySystem=new ue(t=>this.awaitArrival(this.loadBodyModel(t)),()=>this.render(),()=>this.relativeScale);bodyOrigin={x:0,z:0};starTiers=[];bodyMeshes=new Map;hitAreas=new Map;glareSprites=new Map;decorObjects=[];decorGroups=new Map;decorReferencePose;decorCurrentPose;decorTime=0;celestialLight=new mp(16777215,0);celestialLightTarget=new Be;skyLight=new rx(16777215,0,0);streetlightLights=new Map;compassSprites=[];showCompass=!1;compassHovered=!1;compassForced=!1;animationFrameId=null;resolution;cssSize={width:1,height:1};frameDirty=!1;flushFrameId=null;framesDriven=!1;lastFrameTimeMs;raycaster=new cl;weather=jd;observerElevationM=0;siteElevationM=0;air=new xn;groundRadius=_o;terrainRadius=_o;cloudRendering="volume";layeredClouds;cloudLayerOffsetsM={};cloudOffsetM=new R;cloudFieldOffset=new R;cloudMesh;cirrusMesh;cirrusMaterial;cirrusUniforms;cloudMaterial;cloudUniforms;precipitationPoints;precipitationPositions;precipitationPhase;precipitationSpeedJitter;precipitationWobbleFreqJitter;precipitationWobbleAmpJitter;precipitationBounceRemaining;precipitationBounceHeight;precipitationBounceDuration;precipitationBounceVelX;precipitationBounceVelZ;precipitationUniforms;rainSystem;rainSplashSystem;rainCameraDirection=new R;rainLastVerticalFacing=-1;rainViewportSize=new xt;lightningArmed=!1;lightningFlashes=[];lightningLevel=0;lightningBolt;lightningLight=new mp(16777215,0);baseFogColor=[0,0,0];lastSunPosition;lensFlare;sunUnhiddenFraction=1;lensFlareArtifactIntensity=0;sunWorldPosition=new R;sunVisible=!1;lensFlareScratch=new R;sunOcclusionRaycaster=new cl;sunOcclusionDirectionScratch=new R;sunOcclusionRightScratch=new R;sunOcclusionUpScratch=new R;ufoOcclusionRaycaster=new cl;projectionKind="rectilinear";starPoints=0;namedStars=[];equidistantPass;depthOfFieldPass;finishPass;exposureAccumulation;exposureInstants=1;get developingExposure(){return this.exposureInstants>1&&this.exposureInstantAt!==void 0}static EXPOSURE_BUDGET_MS=12;static exposureInstantsPerFrame(t){return Math.max(3,Math.round(6e6/Math.max(1,t)))}exposureFrameId=null;exposureInstantsDone=0;exposureInstantAt;restatingExposure=!1;lensOptics;instrumentMagnitudeGain=0;lightPollution;meteorSystem;cometTail;satelliteField;iceHalos;lunarDiffraction;lunarDiffractionKey="";rainbow;skyGlow;cometKey;novaKeys=new Set;constructor(t,e=r2()){this.renderer=new xb({canvas:t,antialias:!0}),this.resolution=new ve(Math.min(window.devicePixelRatio||1,2),this.renderer.getContext()),this.renderer.setPixelRatio(this.resolution.pixelRatio),this.renderer.shadowMap.enabled=!0,this.renderer.shadowMap.type=bo,this.camera=new Zi(60,t.width/Math.max(t.height,1),.1,qc*1.2),this.camera.position.set(0,1.6,0),this.terrainProviders=e,this.celestialLight.shadow.mapSize.set(1024,1024),this.celestialLight.shadow.camera.left=-Gs,this.celestialLight.shadow.camera.right=Gs,this.celestialLight.shadow.camera.top=Gs,this.celestialLight.shadow.camera.bottom=-Gs,this.celestialLight.shadow.camera.near=sn-ho,this.celestialLight.shadow.camera.far=sn+ho,this.celestialLight.shadow.bias=-.03/(2*ho),this.celestialLight.shadow.normalBias=B5,this.celestialLight.target=this.celestialLightTarget,this.lightningLight.color.copy(Xn),this.scene.add(this.celestialLight,this.celestialLightTarget,this.skyLight,this.lightningLight),this.scene.add(this.celestialGroup),this.scene.add(this.bodySystem.group),this.scene.add(this.roadSystem.group);const i=new Ne(this.renderer,()=>{this.skyColoursStale=!0,this.render()});i.supported?this.scatteredSky=i:i.dispose()}get currentTerrainAttribution(){return this.terrainAttribution}get currentRoadAttribution(){return this.roadAttribution}resize(t,e){this.cssSize.width=t,this.cssSize.height=e,this.renderer.setSize(t,e,!1),this.camera.aspect=t/Math.max(e,1),this.camera.updateProjectionMatrix(),this.render()}setCloudRendering(t){t!==this.cloudRendering&&(this.cloudTransmissionMemo.clear(),this.cloudRendering=t,this.layeredClouds?.dispose(),this.layeredClouds=void 0,this.buildClouds(),this.buildCirrus(),this.render())}setCloudOffset(t,e={}){this.cloudOffsetM.set(t.x,0,t.z),this.cloudLayerOffsetsM=e,this.layeredClouds?.setOffsets(t,e),this.cloudFieldOffset.set(t.x*cu,0,t.z*cu);for(const i of[this.cloudUniforms,this.cirrusUniforms])i?.fieldOffset.value.copy(this.cloudFieldOffset);this.iceHalos?.setCloudOffset(this.layeredClouds?.cirrusMask?.offset??this.cloudFieldOffset)}setObserverPose(t){const e=((t.rollDeg??0)+this.gaitOffset.rollDeg)*qi,i=(t.pitchDeg+this.lookPitchDeg+this.gaitOffset.pitchDeg)*qi;if(t.headingDeg!==void 0?this.camera.rotation.set(i,-(t.headingDeg+this.lookYawDeg+this.gaitOffset.yawDeg)*qi,e,"YXZ"):this.camera.rotation.set(i,this.camera.rotation.y,e,"YXZ"),t.elevationM!==this.observerElevationM&&(this.observerElevationM=t.elevationM,this.syncCloudLayer(),Math.abs(Em(t.elevationM)-this.groundRadius)>1&&(this.buildGround(),this.celestialGroup.scale.setScalar(this.groundRadius/_o),this.camera.far=Math.max(qc*1.2,this.groundRadius*2.5),this.camera.updateProjectionMatrix())),this.terrainMesh&&this.terrainOrigin&&t.lat!==void 0&&t.lng!==void 0){const n=ai(this.terrainOrigin.lat,this.terrainOrigin.lng,t.lat,t.lng);this.terrainMesh.position.x=n.x,this.terrainMesh.position.z=n.z}this.poseCameraY=this.groundYUnder(0,0)+1.6+t.elevationM,this.camera.position.y=this.poseCameraY,this.celestialGroup.position.y=this.camera.position.y,this.camera.fov!==t.fovDeg&&(this.camera.fov=t.fovDeg,this.camera.updateProjectionMatrix(),this.updateCompassScale())}setTerrainProviders(t){this.stopTerrainFade(),this.terrainProviders=t,this.disposeMesh(this.terrainMesh),this.terrainMesh=void 0,this.terrainOrigin=void 0,this.terrainAttribution=void 0,this.roadSystem.clear(),this.roadAttribution=void 0,this.roadWays=void 0,this.applyGroundDepthWrite(),this.terrainBuildToken++}setTerrainOrigin(t,e,i){if(t===void 0||e===void 0)return;const n=this.groundRadius;if(this.terrainOrigin&&Math.abs(this.terrainRadius-n)<n*.1){const{x:c,z:l}=ai(t,e,this.terrainOrigin.lat,this.terrainOrigin.lng);if(Math.sqrt(c*c+l*l)<j5*(n/_o))return}const s=this.terrainOrigin,a=this.terrainRadius;(!s||s.lat!==t||s.lng!==e)&&(this.roadSystem.clear(),this.roadAttribution=void 0),this.terrainOrigin={lat:t,lng:e},this.terrainRadius=n;const o=++this.terrainBuildToken;this.awaitArrival(Xw(t,e,this.terrainProviders,n)).then(({mesh:c,attribution:l,originElevationM:h})=>{if(o!==this.terrainBuildToken)return;this.setSiteElevation(h??0);const u=this.terrainMesh,d=s?ai(t,e,s.lat,s.lng):void 0;u&&d&&Math.hypot(d.x,d.z)<=a&&(c.position.y=u.position.y+this.groundYOfPatch(u,d.x,d.z)),u&&d&&Math.hypot(d.x,d.z)<=a?this.crossfadeTerrain(c,u):this.disposeMesh(this.terrainMesh),c.renderOrder=J5,this.terrainMesh=c,this.compileNextFrameOffThread(),this.terrainAttribution=l,this.scene.add(c),this.applyGroundDepthWrite(),this.decorCurrentPose&&(this.setObserverPose(this.decorCurrentPose),this.updateDecorAnchoring(this.decorReferencePose,this.decorCurrentPose,this.decorTime)),this.buildRoads(t,e,n),this.drapeStatedRoads(),this.render(),i?.()}).catch(c=>{console.warn("Terrain build failed, keeping the flat ground fallback:",c),i?.()})}static TERRAIN_CROSSFADE_MS=1200;fadingTerrain;crossfadeTerrain(t,e){this.stopTerrainFade();const i=t.material;i.opacity=0,i.polygonOffset=!0,i.polygonOffsetFactor=-1,i.polygonOffsetUnits=-4;const n=performance.now(),s=()=>{const a=Math.min(1,(performance.now()-n)/ke.TERRAIN_CROSSFADE_MS);if(i.opacity=a*a*(3-2*a),this.render(),a<1&&this.fadingTerrain){this.fadingTerrain.frameId=requestAnimationFrame(s);return}i.polygonOffset=!1,i.opacity=1,this.fadingTerrain&&this.disposeMesh(this.fadingTerrain.mesh),this.fadingTerrain=void 0,this.render()};this.fadingTerrain={mesh:e,frameId:requestAnimationFrame(s)}}stopTerrainFade(){if(!this.fadingTerrain)return;cancelAnimationFrame(this.fadingTerrain.frameId),this.disposeMesh(this.fadingTerrain.mesh),this.fadingTerrain=void 0;const t=this.terrainMesh?.material;t&&(t.opacity=1,t.polygonOffset=!1)}static ROADS_MAX_RADIUS_M=5e3;buildRoads(t,e,i){const n=this.terrainProviders.roads;if(!n||i>ke.ROADS_MAX_RADIUS_M){this.roadSystem.clear(),this.roadAttribution=void 0;return}const s=this.roadWays;if(s&&s.lat===t&&s.lng===e&&s.radiusM===i){this.drapeRoads(s.ways,t,e,n.contemporary);return}this.awaitArrival(n.getRoads(L1(t,e,i)),ke.ROADS_PATIENCE_MS).then(a=>{this.terrainOrigin?.lat!==t||this.terrainOrigin?.lng!==e||(this.roadWays={lat:t,lng:e,radiusM:i,ways:a},this.drapeRoads(a,t,e,n.contemporary))}).catch(a=>{console.warn("Roads unavailable, drawing none:",a)})}setStatedRoads(t){t!==this.statedRoads&&(this.statedRoads=t,this.drapeStatedRoads(),this.render())}drapeStatedRoads(){const t=this.terrainMesh;t&&(this.roadSystem.group.position.copy(t.position),this.roadSystem.setStated(this.statedRoads,(e,i)=>this.groundYOfPatch(t,e,i)))}drapeRoads(t,e,i,n){const s=this.terrainMesh;s&&(this.roadSystem.group.position.copy(s.position),this.roadSystem.set(t,e,i,(a,o)=>this.groundYOfPatch(s,a,o),n),this.roadAttribution=t.length>0?this.terrainProviders.roads?.attribution:void 0,this.compileNextFrameOffThread(),this.render())}setShowCompass(t){this.showCompass!==t&&(this.showCompass=t,this.disposeCompassLabels(),t&&this.buildCompassLabels(),this.render())}setCompassPoints(t){this.compassPoints!==t&&(this.compassPoints=t,this.showCompass&&(this.disposeCompassLabels(),this.buildCompassLabels(),this.render()))}compassPoints;applyLensFlareTint(t){if(!this.lensFlare)return;const e=Q5*(this.sunArriving[1]/eE);this.lensFlare.uniforms.uColorGain.value.setRGB(e*t[0],e*t[1],e*t[2]),this.applyDazzleStrength()}applyDazzleStrength(){if(!this.lensFlare)return;const[t,e,i]=this.sunArriving,n=Math.max(e,1e-30);this.lensFlare.uniforms.uDazzleColour.value.setRGB(t/n,1,i/n),this.lensFlare.uniforms.uVeilStrength.value=Pi.K*e*this.sunUnhiddenFraction}sunArriving=[0,0,0];setCompassHovered(t){this.compassHovered!==t&&(this.compassHovered=t,this.updateCompassVisibility())}setCompassForced(t){this.compassForced!==t&&(this.compassForced=t,this.updateCompassVisibility())}updateCompassVisibility(){const t=this.compassHovered||this.compassForced;if(this.compassSprites.some(e=>e.visible!==t)){for(const e of this.compassSprites)e.visible=t;this.developingExposure?this.exposureInstantsDone>0&&this.presentExposure():this.render()}}setWeather(t){if(F5(this.weather,t))return;this.cloudTransmissionMemo.clear();const e=this.weather;this.weather=t;const i=!uE(e,t),n=e.precipitationType!==t.precipitationType,s=e.precipitationIntensity!==t.precipitationIntensity||e.precipitationAmount!==t.precipitationAmount;(e.relativeHumidity!==t.relativeHumidity||n||s)&&(this.air=xn.of(t),this.applyAir(),this.scatteredSky?.setConditions({aerosolOpticalDepth:t.relativeHumidity===void 0?void 0:ta.steppedOpticalDepth(t.relativeHumidity)}),this.pumpScatteredSky()),i&&(this.buildClouds(),this.buildCirrus()),n?this.buildPrecipitation():s&&this.updatePrecipitationDensity(),this.lastAstronomy&&(i&&(this.buildIceHalos(this.lastAstronomy.sun,this.lastAstronomy.moon),this.buildLunarDiffraction(this.lastAstronomy.moon)),(i||n||s)&&this.buildRainbow(this.lastAstronomy.sun,this.lastAstronomy.moon)),this.lightningArmed=t.storm&&t.cloudDarkness>=vE,this.syncAnimationLoop(),this.render()}setDecor(t){if(this.decorObjects!==t){this.decorObjects=t,this.decorModelToken++,this.decorModelCredits.clear();for(const e of this.decorGroups.values())e.removeFromParent(),ui.dispose(e);this.decorGroups.clear(),this.streetlightLights.clear();for(const e of t){const i=ui.build(e,e.lit??!1);this.scene.add(i),this.decorGroups.set(e.id,i),e.kind==="streetlight"&&this.addStreetlightLight(e.id,i),this.awaitArrival(this.loadDecorModel(e,this.decorModelToken))}this.celestialLight.castShadow=this.decorGroups.size>0||this.bodySystem.any}}setDecorModelProvider(t){this.decorModelProvider=t;const e=this.decorObjects;this.decorObjects=[],this.setDecor(e)}get currentDecorModelCredits(){return[...this.decorModelCredits.values(),...this.bodySystem.modelCredits]}get bodyGround(){const{x:t,z:e}=this.bodyOrigin,i=this.groundYUnder(t,e);return{heightAt:(n,s)=>this.groundYUnder(t+n,e-s)-i}}setBodies(t,e=0,i=t.map(a=>a.id),n=[],s){const{x:a,z:o}=this.bodyOrigin,c=this.scatteredSky;this.bodySystem.set(t,{originX:a,originZ:o,originGroundY:this.groundYUnder(a,o),eye:this.camera.position,groundYAt:(h,u)=>this.groundYUnder(h,u),wind:s,light:this.plumeLight(),occluders:[...this.decorGroups.values()],transmittance:(h,u,d)=>this.transmittanceTo(h,u,d)},e,c?(h,u)=>c.relativeOfLuminance(h,u):void 0,i),this.bodySystem.setSmoke(n,e),this.bodySystem.any&&(this.celestialLight.castShadow=!0),this.fitShadowToBodies();const l=this.bodySystem.furthestFrom(this.camera.position)*1.2;l>this.camera.far&&(this.camera.far=l,this.camera.updateProjectionMatrix())}plumeLight(){const t=this.celestialLight.color,e=this.celestialLight.intensity*.5,i=this.skyLight.color,n=this.skyLight.groundColor,s=this.skyLight.intensity,a=(o,c,l)=>(o*e+(c+l)/2*s)/Math.PI;return[a(t.r,i.r,n.r),a(t.g,i.g,n.g),a(t.b,i.b,n.b)]}bodyOutline(t,e){return this.bodySystem.outlineOf(t,e)}documentUrl;modelUrl(t){return t.url?this.documentRelative(t.url):void 0}documentRelative(t){if(t.startsWith("data:"))return t;const e=this.documentUrl??(typeof location>"u"?void 0:location.href);return e?new URL(t,e).href:t}async loadBodyModel(t){const e=t.url?void 0:t.id?await this.decorModelProvider.entry(t.id):void 0,i=this.modelUrl(t)??e?.url,n=t.credit??e?.credit;if(!(!i||!n))return{scene:await _m(i),credit:n,headingOffsetDeg:t.headingOffsetDeg??e?.headingOffsetDeg}}async loadDecorModel(t,e){const i=t.model;if(!(!i||!ui.usesModel(t)))try{const n=i.url?void 0:i.id?await this.decorModelProvider.entry(i.id):void 0,s=this.modelUrl(i)??n?.url,a=i.credit??n?.credit;if(!s||!a)return;const o=await _m(s);if(e!==this.decorModelToken)return;const c=this.decorGroups.get(t.id);if(!c)return;on.reflectOn(o),ui.applyModel(c,t,o,{headingOffsetDeg:i.headingOffsetDeg??n?.headingOffsetDeg,depictedSizeM:n?.sizeM}),this.decorModelCredits.set(t.id,a),this.render()}catch(n){console.warn(`Keeping the built-in shape for decor "${t.id}":`,n)}}updateDecorAnchoring(t,e,i=0){this.decorReferencePose=t,this.decorCurrentPose=e,this.decorTime=i;const n=t?.lat!==void 0&&t.lng!==void 0&&e?.lat!==void 0&&e?.lng!==void 0?ai(t.lat,t.lng,e.lat,e.lng):{x:0,z:0},s=this.decorObjects.find(l=>l.observerSide!==void 0&&ng(l.kind));if(this.terrainMesh&&this.terrainOrigin&&e?.lat!==void 0&&e.lng!==void 0){const l=ai(this.terrainOrigin.lat,this.terrainOrigin.lng,e.lat,e.lng);this.terrainMesh.position.x=l.x-(s?0:this.gaitOffset.eastM),this.terrainMesh.position.z=l.z+(s?0:this.gaitOffset.northM),this.roadSystem.group.position.copy(this.terrainMesh.position)}s||(n.x-=this.gaitOffset.eastM,n.z+=this.gaitOffset.northM,this.camera.position.y=this.poseCameraY+this.gaitOffset.upM,this.celestialGroup.position.y=this.camera.position.y);const a={x:0,z:0};let o=0;if(s){const l=ui.occupantView(s),h=-(s.headingDeg??0)*qi,u=l.x*Math.cos(h)+l.z*Math.sin(h),d=-l.x*Math.sin(h)+l.z*Math.cos(h),f=s.eastM+n.x,p=-s.northM+n.z;a.x=-(f+u),a.z=-(p+d),this.camera.position.y=this.groundYUnder(f,p)+l.eyeY,this.camera.rotation.set(this.indoorLookPitchDeg*qi,-(l.headingDeg+this.indoorLookYawDeg)*qi,0,"YXZ")}this.bodyOrigin={x:n.x+a.x,z:n.z+a.z},this.placeShadowFrustum();for(const l of this.decorObjects){const h=this.decorGroups.get(l.id);if(!h)continue;const u=Co(l,i),d=u.eastM+n.x+a.x,f=-u.northM+n.z+a.z,p=this.terrainMesh,v=`${p?.geometry.uuid}:${(d-(p?.position.x??0)).toFixed(3)}:${(f-(p?.position.z??0)).toFixed(3)}:${(p?.position.y??0).toFixed(3)}:${u.headingDeg}:${u.altitudeM}`;if(h.userData.footprintKey!==v&&(h.userData.footprintGroundY=this.groundUnderFootprint(l,d,f,u.headingDeg,u.altitudeM),h.userData.footprintKey=v),h.position.set(d,h.userData.footprintGroundY+u.altitudeM,f),l.kind==="crop"){const m=Math.hypot(d,f);h.visible=m<=nE}if(u.headingDeg!==void 0&&(h.rotation.y=-u.headingDeg*qi),l.kind==="crop"&&h.visible){const m=this.terrainMesh,g=[m?.geometry.uuid,d-(m?.position.x??0),f-(m?.position.z??0),h.position.y-(m?.position.y??0),u.headingDeg,u.altitudeM].map(S=>typeof S=="number"?S.toFixed(4):S).join(":");h.userData.cropGroundKey!==g&&(ui.fitCropToGround(h,(S,y)=>this.groundYUnder(S,y)+u.altitudeM),h.userData.cropGroundKey=g)}o=Math.max(o,h.position.distanceTo(this.camera.position))}const c=Math.max(qc*1.2,this.groundRadius*2.5,o*1.2);Math.abs(this.camera.far-c)>1&&(this.camera.far=c,this.camera.updateProjectionMatrix())}groundYUnder(t,e){const i=this.terrainMesh;return i?i.position.y+this.groundYOfPatch(i,t-i.position.x,e-i.position.z):du}groundYOfPatch(t,e,i){const n=t.geometry.getAttribute("position"),s=Math.round(Math.sqrt(n.count));if(s<2||s*s!==n.count)return du;const a=n.getX(0),o=n.getX(s-1),c=n.getZ(0),l=n.getZ((s-1)*s),h=xr((e-a)/(o-a)*(s-1),0,s-1),u=xr((i-c)/(l-c)*(s-1),0,s-1);if(!Number.isFinite(h)||!Number.isFinite(u))return du;const d=Math.min(Math.floor(h),s-2),f=Math.min(Math.floor(u),s-2),p=h-d,v=u-f,m=(b,w)=>n.getY(b*s+w),g=m(f,d),S=m(f,d+1),y=m(f+1,d),M=m(f+1,d+1);return p+v<=1?g+(S-g)*p+(y-g)*v:M+(y-M)*(1-p)+(S-M)*(1-v)}groundUnderFootprint(t,e,i,n,s=0){return ui.groundUnderFootprint(t,e,i,n,(a,o)=>this.groundYUnder(a,o),s)}lookYawDeg=0;lookPitchDeg=0;poseCameraY=1.6;setGait(t){this.gaitOffset=t}gaitOffset={eastM:0,northM:0,upM:0,rollDeg:0,pitchDeg:0,yawDeg:0};setLookOffset(t,e){this.lookYawDeg=t,this.lookPitchDeg=e}indoorLookYawDeg=0;indoorLookPitchDeg=0;setIndoorLook(t,e){this.indoorLookYawDeg=t,this.indoorLookPitchDeg=e}medium;setMedium(t,e,i,n){const s=t&&e!==void 0&&e>0&&i!==void 0&&i>0?{kind:t.kind,iso:n??t.iso,autoExposure:t.autoExposure===!0,exposureSeconds:e,fNumber:i}:void 0;JSON.stringify(s)!==JSON.stringify(this.medium)&&(this.medium=s,this.render())}applyMedium(){const t=this.medium,e=Math.max(this.relativeScale,1e-30);if(!t){Hi.uMedium.value=0;return}Hi.uMedium.value=t.kind==="negative"?1:t.kind==="slide"?2:3;const i=t.autoExposure?this.scatteredSky?.sceneAdaptation:void 0;Hi.uMediumExposure.value=i!==void 0&&i>0?1/(e*i):.065*t.exposureSeconds*t.iso/(t.fNumber*t.fNumber*e)}grain;lampBloomRadiusRad(){if(!this.grain)return;const t=this.camera.fov*Math.PI/180,e=this.grain.frameHeightMm/(2*Math.tan(t/2)),i=Math.max(1,this.renderer.getDrawingBufferSize(this.bloomSize).y);return Math.max(this.grain.detailUm*.001/e,t/i)}bloomSize=new xt;updateDecorLitState(t,e=0){const i=this.lampBloomRadiusRad();for(const n of this.decorObjects){const s=this.decorGroups.get(n.id);if(s&&n.lights?.length&&ui.setLights(s,n.lights,t,s.position.distanceTo(this.camera.position),e,this.relativeScale,i),n.kind!=="streetlight"&&n.kind!=="vehicle")continue;const a=this.decorGroups.get(n.id);if(!a)continue;const o=sv(n,t);ui.setLit(a,n.kind,o,this.relativeScale);const c=this.streetlightLights.get(n.id);c&&(c.visible=o)}}addStreetlightLight(t,e){const i=ui.bodyOf(e),n=i.children.find(a=>a.userData.emissive);if(!n)return;const s=new Qg(16764006,Rm*this.relativeScale,Y5);s.position.copy(n.position).multiply(i.scale),s.castShadow=!0,s.shadow.mapSize.set(512,512),s.shadow.bias=-.002,e.add(s),this.streetlightLights.set(t,s)}setAstronomy(t){(!this.lastAstronomy||Math.abs(this.lastAstronomy.sun.altitudeDeg-t.sun.altitudeDeg)>2)&&(this.surroundings=void 0,this.scatteredSky?.resetSurroundings()),this.lastAstronomy=t,this.scatteredSky?.update(this.scatteredSkyState(t)),this.skyHoldUntilMs===void 0&&this.startHold(),this.pumpScatteredSky(),this.lastSunPosition=t.sun,this.buildSky(t.sun),this.buildGround();const e=this.magnitudeLimitOf(t);this.buildStars(t.stars,e),this.placeBodies(t,e),this.buildIceHalos(t.sun,t.moon),this.buildRainbow(t.sun,t.moon),this.applySkyColours(t),this.syncAnimationLoop(),this.render()}static relativeSkyOf(t,e){const i=a=>{const o=On.luminanceOf(a);if(!(o>0))return[0,0,0];const c=At.relativeOfResponse(o)/o;return[a[0]*c,a[1]*c,a[2]*c]},n=i(t.zenith),s=i(t.horizon);return{zenith:n,horizon:s,airlight:s,skyIrradiance:[n[0]*Math.PI,n[1]*Math.PI,n[2]*Math.PI],scale:e}}placeBodies(t,e){this.bodiesScale=this.relativeScale,this.setBodyMesh("sun",t.sun,uo,new st(1,.96,.88),t.sun.magnitude),this.setMoonMesh(t.moon,e),this.buildPlanets(t.planets,e),this.buildComet(t.comet,e),this.buildNovae(t.novae??[],e)}bodiesScale=0;applySkyColours(t){this.skyColoursStale=!1,this.bodiesScale!==this.relativeScale&&(this.placeBodies(t,this.magnitudeLimitOf(t)),this.applyDazzleStrength(),this.buildIceHalos(t.sun,t.moon),this.buildRainbow(t.sun,t.moon));const e=this.scatteredSky?.ambient??ke.relativeSkyOf(Ed(t.sun.altitudeDeg),this.relativeScale),i=e,n=this.lightUnderClouds(t),s=a=>n?[0,1,2].map(o=>a[o]*n.through+n.radiance[o]*(1-n.through)):[a[0],a[1],a[2]];this.baseFogColor=[i.horizon[0],i.horizon[1],i.horizon[2]],this.airlight=s(i.airlight),this.skyMesh&&this.skyGradientMaterial&&(this.skyMesh.material=this.scatteredSky?.ready?this.scatteredSky.material:this.skyGradientMaterial),this.updateCelestialLight(t,e),this.updateCloudLighting(t.sun,this.baseFogColor),ae.setEye(this.scatteredSky?.rodShare??0,this.relativeScale),this.updateTwinkle(this.twinkleSeconds);for(const a of this.streetlightLights.values())a.intensity=Rm*this.relativeScale;this.buildSkyGlow(t,i.zenith),this.applyAir(),this.buildLunarDiffraction(t.moon)}reflections;sceneVersion=0;reflectionTimer;buildLunarDiffraction(t){const e=this.scatteredSky?.ready?this.scatteredSky:void 0;if(t.altitudeDeg<-.5||!e){this.lunarDiffraction?.show(void 0),this.lunarDiffractionKey="";return}const i=this.weather.relativeHumidity,n=(i===void 0?Ft.DEFAULT_AEROSOL_OPTICAL_DEPTH:ta.opticalDepth(i))*Ft.aerosolDensity(this.siteElevationM+this.observerElevationM),s=this.cloudTransmission(t),a=-Math.log(Math.max(this.cloudTransmission(t,!0),1e-4)),o=pe.aureoleScale(n,pe.airMass(t.altitudeDeg))*s,c=pe.coronaScale(a),l=pe.illuminanceOf(t.magnitude),h=[t.altitudeDeg.toFixed(1),t.azimuthDeg.toFixed(1),t.magnitude.toFixed(2),o.toExponential(2),c.toExponential(2),Math.log10(Math.max(e.adaptation,1e-12)).toFixed(2)].join(":");if(h===this.lunarDiffractionKey)return;this.lunarDiffractionKey=h,this.lunarDiffraction||(this.lunarDiffraction=new B0,this.celestialGroup.add(this.lunarDiffraction.object));const u=pe.profile(pe.HAZE_COARSE_MODE),d=pe.profile(pe.CLOUD_DROPLETS),f=Xp(t.altitudeDeg),p=new Float32Array(pe.STEPS*3);let v=0;for(let y=0;y<pe.STEPS;y++){const M=y*3,b=[0,1,2].map(T=>l*f[T]*(o*u[M+T]+c*d[M+T])),w=On.shown(b,On.luminanceOf(b),(T,x)=>e.relativeOfLuminance(T,x));p.set(w,M),v=Math.max(v,On.response(w))}const{x:m,y:g,z:S}=hi(t.altitudeDeg,t.azimuthDeg,1);this.lunarDiffraction.show(v>1/200?{x:m,y:g,z:S}:void 0,p)}applyAir(){this.scene.fog instanceof La||(this.scene.fog=new La),this.scene.fog.setAir(this.air,this.siteElevationM,this.airlight)}airlight=[0,0,0];transmittanceTo(t,e,i){const n=this.camera.position;return this.air.transmittance(this.siteElevationM+n.y,this.siteElevationM+e,Math.hypot(t-n.x,e-n.y,i-n.z))}setSiteElevation(t){Math.abs(t-this.siteElevationM)<1||(this.siteElevationM=t,this.applyAir(),this.lastAstronomy&&this.scatteredSky?.update(this.scatteredSkyState(this.lastAstronomy)))}scatteredSkyState(t){return{altitudeM:this.siteElevationM+this.observerElevationM+1.6,lightPollution:this.lightPollution,sun:{altitudeDeg:t.sun.altitudeDeg,azimuthDeg:t.sun.azimuthDeg,magnitude:t.sun.magnitude},moon:{altitudeDeg:t.moon.altitudeDeg,azimuthDeg:t.moon.azimuthDeg,magnitude:t.moon.magnitude,phaseAngleDeg:Mt.phaseAngleOf(t.moon.phase.illuminatedFraction)}}}pumpScatteredSky(){const t=this.scatteredSky;!t||t.tables.ready||this.scatteredSkyFrameId!==null||this.contextReleased||(this.scatteredSkyFrameId=requestAnimationFrame(()=>{this.scatteredSkyFrameId=null,!this.contextReleased&&(t.advance(this.skyHoldUntilMs?K5:$5),this.pumpScatteredSky())}))}cancelScatteredSkyPump(){this.scatteredSkyFrameId!==null&&(cancelAnimationFrame(this.scatteredSkyFrameId),this.scatteredSkyFrameId=null)}setSatellites(t){if(t.length===0&&!this.satelliteField?.count)return;this.satelliteField||(this.satelliteField=new c5(au),this.celestialGroup.add(this.satelliteField.object));const e=this.lastAstronomy?this.magnitudeLimitOf(this.lastAstronomy):Ad(-90,this.instrumentMagnitudeGain);this.satelliteField.set(t,e,i=>this.cloudTransmission(i),(i,n)=>this.arrivingIlluminance(i,n,1)),this.render()}pickSatelliteAt(t,e){if(!this.satelliteField?.count)return;this.aimAtScreenPoint(this.raycaster,t,e);const i=Math.cos(Am*this.camera.fov*Math.PI/180),n=this.satelliteField.nearest(this.raycaster.ray.direction,i);return n&&this.groundHides(t,e)?void 0:n}updateCelestialLight(t,e){const i=this.relativeScale,n=t.sun.altitudeDeg>=Kc,s=!n&&t.moon.altitudeDeg>=Kc,a=n?t.sun:t.moon,o=[0,0,0],c=Math.max(0,Math.sin(Math.max(a.altitudeDeg,0)*qi)),l=n||s?this.cloudTransmission(a):1,h=-Math.log(Math.max(l,1e-6)),u=Math.max(0,1/(1+.1125*h)-l),d=[0,0,0];if(n||s){const S=pe.illuminanceOf(a.magnitude)*i,y=this.air.transmittanceFromSpace(this.siteElevationM+this.observerElevationM,a.altitudeDeg);for(let T=0;T<3;T++)o[T]=S*y[T]*l,d[T]=S*y[T]*u*c,this.cloudBeam[T]=S*y[T];const{x:M,y:b,z:w}=hi(a.altitudeDeg,a.azimuthDeg,1);this.cloudBeamDirection.set(M,b,w)}else this.cloudBeam.fill(0);const f=this.surroundings;if(f)this.skyLight.color.setRGB(f.up[0]*i,f.up[1]*i,f.up[2]*i),this.skyLight.groundColor.setRGB(f.down[0]*i,f.down[1]*i,f.down[2]*i);else{const S=this.skyCloudTransmission(),y=e.skyIrradiance,M=[0,1,2].map(w=>y[w]*S+d[w]);this.skyLight.color.setRGB(M[0],M[1],M[2]);const b=Wt.GROUND_ALBEDO;this.skyLight.groundColor.setRGB(b*(M[0]+o[0]*c),b*(M[1]+o[1]*c),b*(M[2]+o[2]*c))}if(this.skyLight.intensity=1,!n&&!s){this.celestialLight.intensity=0;return}const{x:p,y:v,z:m}=hi(a.altitudeDeg,a.azimuthDeg,1);this.lightDirection.set(p,v,m),this.placeShadowFrustum();const g=Math.max(o[0],o[1],o[2],1e-30);this.celestialLight.color.setRGB(o[0]/g,o[1]/g,o[2]/g),this.celestialLight.intensity=g,this.celestialLight.castShadow=this.decorGroups.size>0||this.bodySystem.any}lightDirection=new R(0,1,0);placeShadowFrustum(){const t=this.lightDirection,e=this.celestialLight.shadow.camera,i=(e.right-e.left)/this.celestialLight.shadow.mapSize.x,n=this.shadowAxisX.crossVectors(this.shadowUp,t);n.lengthSq()<1e-8&&n.set(1,0,0),n.normalize();const s=this.shadowAxisY.crossVectors(t,n).normalize(),a=this.shadowWorld.set(this.bodyOrigin.x,0,this.bodyOrigin.z),o=l=>{const h=a.dot(l)/i;return(h-Math.round(h))*i},c=this.celestialLightTarget.position.set(0,0,0).addScaledVector(n,o(n)).addScaledVector(s,o(s));this.celestialLightTarget.updateMatrixWorld(),this.celestialLight.position.copy(c).addScaledVector(t,this.shadowLightDistanceM)}fitShadowToBodies(){const t=this.bodySystem.reachFrom(this.camera.position),e=Math.min(z5,Math.max(Gs,Math.ceil(t*1.25/20)*20));if(e===this.shadowHalfExtentM)return;this.shadowHalfExtentM=e;const i=this.celestialLight.shadow,n=i.camera;n.left=-e,n.right=e,n.top=e,n.bottom=-e;const s=Math.max(ho,e*(ho/Gs));this.shadowLightDistanceM=Math.max(sn,s+10),n.near=this.shadowLightDistanceM-s,n.far=this.shadowLightDistanceM+s,n.updateProjectionMatrix(),i.bias=-.03/(2*s);const a=e>2*Gs?2048:1024;i.mapSize.x!==a&&(i.mapSize.set(a,a),i.map?.dispose(),i.map=null),this.placeShadowFrustum()}shadowHalfExtentM=Gs;shadowLightDistanceM=sn;shadowUp=new R(0,1,0);shadowAxisX=new R;shadowAxisY=new R;shadowWorld=new R;skyCloudTransmission(){let t=this.cloudTransmission({altitudeDeg:90,azimuthDeg:0}),e=1;for(const i of[20,45,70]){const n=i*qi,s=Math.sin(n)*Math.cos(n)*2;for(let a=0;a<360;a+=60)t+=s*this.cloudTransmission({altitudeDeg:i,azimuthDeg:a}),e+=s}return t/e}cloudBeam=[0,0,0];cloudBeamDirection=new R(0,1,0);get relativeScale(){return this.scatteredSky?.relativeScale??1/At.semiSaturation(At.DAYLIGHT_ANCHOR_CD_M2)}setMeteorShower(t,e,i){this.meteorSystem||(this.meteorSystem=new yi,this.celestialGroup.add(this.meteorSystem.object)),this.meteorSystem.setShower(t,e,i)}get meteorSchedule(){return this.meteorSystem?.schedule??[]}meteorMidpoint(t){return this.meteorSystem?.midpointOf(t)}updateMeteors(t){this.meteorSystem?.update(t)}setInstrument(t){this.projectionKind=t.projection,this.grain=t.detailUm!==void 0&&t.frame?{detailUm:t.detailUm,frameHeightMm:t.frame.heightMm}:void 0;const e=fi.starPointsOf(t),i=fi.flareArtifactsOf(t);e===this.starPoints&&i===this.lensFlareArtifactIntensity||(this.starPoints=e,this.lensFlareArtifactIntensity=i,this.lensFlare&&(this.lensFlare.uniforms.uStarPoints.value=e,this.lensFlare.uniforms.uFlareIntensity.value=i),this.render())}magnitudeLimitOf(t){const e=Mt.starLossMagnitudes(t.sun.altitudeDeg,{phaseAngleDeg:Mt.phaseAngleOf(t.moon.phase.illuminatedFraction),altitudeDeg:t.moon.altitudeDeg},this.lightPollution);return Ad(t.sun.altitudeDeg,this.instrumentMagnitudeGain,e)}setLightPollution(t){t!==this.lightPollution&&(this.lightPollution=t,this.lastAstronomy&&this.scatteredSky?.update(this.scatteredSkyState(this.lastAstronomy)))}setInstrumentGain(t,e=!1){this.instrumentMagnitudeGain=Number.isFinite(t)?t:0,this.scatteredSky?.setInstrument(e,this.instrumentMagnitudeGain)}render(){this.restatingExposure||(this.sceneVersion++,this.frameDirty=!0,this.resolution.noteChange(performance.now()),!(this.animationFrameId!==null||this.framesDriven||this.flushFrameId!==null)&&(this.flushFrameId=requestAnimationFrame(()=>{this.flushFrameId=null,this.drawIfDirty()})))}drawIfDirty(){if(!(!this.frameDirty||this.contextReleased)){if(this.skyColoursStale&&this.lastAstronomy&&this.applySkyColours(this.lastAstronomy),this.compileBeforeNextDraw){this.compileBeforeNextDraw=!1;const t=this.compileOffThread().then(()=>{this.compiling===t&&(this.compiling=void 0,this.render())});this.compiling=t;return}if(!this.compiling){if(this.skyHoldUntilMs){if(!this.sceneSettled()&&performance.now()<this.skyHoldUntilMs){this.firstFrameReady()&&this.refreshReflections(!0);return}this.skyHoldUntilMs=null,this.iceHalos?.setUrgent(!1),this.onFirstFrameHold?.(!1),this.skyColoursStale&&this.lastAstronomy&&this.applySkyColours(this.lastAstronomy)}this.frameDirty=!1,this.refreshReflections(),this.resolution.beginDrawing();try{this.renderOnce(),this.drawn++}finally{this.resolution.endDrawing()}this.developingExposure&&this.startExposure()}}}drawn=0;get framesDrawn(){return this.drawn}compileBeforeNextDraw=!1;compiling;static COMPILE_WAIT_MS=1500;compileOffThread(){const t=this.renderer.compile(this.scene,this.camera);if(!this.renderer.extensions.get("KHR_parallel_shader_compile"))return Promise.resolve();const e=this.renderer.properties,i=performance.now()+ke.COMPILE_WAIT_MS;return new Promise(n=>{const s=()=>{if(this.contextReleased)return n();for(const a of t){const o=e.get(a)?.currentProgram;(!o||o.isReady())&&t.delete(a)}t.size===0||performance.now()>i?n():setTimeout(s,10)};s()})}compileNextFrameOffThread(){this.compileBeforeNextDraw=!0}contextReleased=!1;releaseContext(){this.contextReleased||(this.contextReleased=!0,this.stopTwinkle(),this.cancelFlush(),this.cancelExposure(),this.compiling=void 0,this.cancelScatteredSkyPump(),this.renderer.forceContextLoss())}restoreContext(){this.contextReleased&&(this.contextReleased=!1,this.renderer.forceContextRestore(),this.scatteredSky?.invalidate(),this.pumpScatteredSky(),this.compileNextFrameOffThread(),this.syncAnimationLoop(),this.render())}cancelFlush(){this.flushFrameId!==null&&(cancelAnimationFrame(this.flushFrameId),this.flushFrameId=null)}frame(t){if(this.animationsRunning){const e=this.lastFrameTimeMs===void 0?0:t-this.lastFrameTimeMs;this.lastFrameTimeMs=t,this.hasAnimations()&&this.animate(t,e);const i=this.resolution.ratioFor(t,e);i!==this.renderer.getPixelRatio()&&this.applyPixelRatio(i)}this.drawIfDirty()}refreshReflections(t=!1){this.reflections??=new on(this.renderer);const e=[...this.compassSprites,...this.lensFlare?[this.lensFlare.mesh]:[],...[...this.glareSprites.values()].map(o=>o.mesh)],i=[...this.starTiers.map(o=>o.points),...[...this.bodyMeshes.values()].filter(o=>o instanceof xs),...[this.rainSystem?.points,this.precipitationPoints,this.rainSplashSystem?.points].filter(o=>o!==void 0)],n=this.relativeScale,s=this.sceneVersion,a=this.reflections.refresh(this.renderer,this.scene,this.camera.position,this.bodySystem.reflectors,e,[...this.decorGroups.values()],s,i,o=>this.measureSurroundings(o,n,s),t?0:on.REFRESH_MS);a===void 0||this.reflectionTimer||(this.reflectionTimer=setTimeout(()=>{this.reflectionTimer=void 0,this.frameDirty=!0,!(this.animationFrameId!==null||this.framesDriven||this.flushFrameId!==null)&&(this.flushFrameId=requestAnimationFrame(()=>{this.flushFrameId=null,this.drawIfDirty()}))},a))}measureSurroundings(t,e,i){const n=this.lastAstronomy;if(!n)return;this.probeIrradiance??=new Ro;const s=[n.sun,n.moon].filter(a=>a.altitudeDeg>-2).map(a=>hi(a.altitudeDeg,a.azimuthDeg,1));this.probeIrradiance.measure(this.renderer,t,s,a=>{const o=f=>f.map(p=>p/e),c=this.surroundings,l={up:o(a.up),down:o(a.down)},h=(f,p)=>f.some((v,m)=>Math.abs(v-p[m])>.03*Math.max(Math.abs(v),Math.abs(p[m]),1e-12)),u=!c||h(c.up,l.up)||h(c.down,l.down);u&&(this.surroundings=l),this.eyeSettledVersion=-1;const d=this.scatteredSky?.adaptToSurroundings(Math.exp(a.logAverage)/e)??!1;if(!u&&!d){this.eyeSettledVersion=i,this.skyHoldUntilMs&&this.redrawHeld();return}this.skyColoursStale=!0,this.render()})}lightUnderClouds(t){const e=this.surroundings;if(!e)return;const i=t.sun.altitudeDeg>=Kc?t.sun:t.moon.altitudeDeg>=Kc?t.moon:void 0;if(!i)return;const n=this.relativeScale/Math.PI;return{through:this.cloudTransmission(i),radiance:[e.up[0]*n,e.up[1]*n,e.up[2]*n]}}probeIrradiance;surroundings;animate(t,e){const i=Math.min(e/1e3,gE);this.twinkleSeconds=t/1e3,this.updateTwinkle(this.twinkleSeconds),this.updatePrecipitation(t/1e3,i),this.updateRain(i),this.lensFlare&&(this.lensFlare.uniforms.uTime.value=t/1e3),this.developingExposure||(this.frameDirty=!0)}setMaxPixelRatio(t){this.resolution.maximum=t,this.renderer.getPixelRatio()>this.resolution.maximum&&this.applyPixelRatio(this.resolution.maximum)}applyPixelRatio(t){this.renderer.setPixelRatio(t),this.renderer.setSize(this.cssSize.width,this.cssSize.height,!1),this.frameDirty=!0}setExposure(t,e){const i=e?Math.max(1,Math.round(t)):1;if(i===this.exposureInstants&&(i===1||e===this.exposureInstantAt)){this.exposureInstantAt=e;return}this.exposureInstants=i,this.exposureInstantAt=e,i===1&&(this.cancelExposure(),this.exposureAccumulation?.dispose(),this.exposureAccumulation=void 0),this.render()}renderOnce(t){if(this.onMapSubjectBounds){const a=this.mapSubjectBounds();t?this.exposureSubjectBounds.push(...a):this.onMapSubjectBounds(a)}const e=this.usableEquidistantPass();this.phenomena.setCloudLayers(this.layeredClouds?.volumes??[]),this.phenomena.place(this.camera,(a,o,c)=>this.directionAtScreenPoint(a,o,c),a=>this.screenPointOf(a)),this.references.place(this.camera);const i=Math.max(this.phenomena.furthestM,this.references.furthestM)*1.2;i>this.camera.far&&(this.camera.far=i,this.camera.updateProjectionMatrix()),Hi.uRodShare.value=this.scatteredSky?.rodShare??0,Hi.uRelativeScale.value=this.relativeScale,this.applyMedium();const n=this.references.any||this.phenomena.any||this.compassSprites.some(a=>a.visible);Hi.uHasOverlay.value=n?1:0;const s=n?a=>this.renderOverlayPasses(a):void 0;if(this.skyGlow?.setDestinationEncoded(!1),!e){this.updateLensFlarePosition();const a=this.usableDepthOfFieldPass();a?a.render(this.renderer,this.scene,this.camera,s,t):this.usableFinishPass().render(this.renderer,this.scene,this.camera,s,void 0,t);return}e.render(this.renderer,this.scene,this.camera,this.camera.fov,()=>this.updateLensFlarePosition(),s,a=>{this.lensFlare&&(this.lensFlare.mesh.visible=a?!1:this.sunVisible)},()=>this.renderDazzleOnResample(),t)}renderOverlayPasses(t=this.camera){this.renderReferencesPass(t),this.renderPhenomenaPass(t),this.renderHudPass(t)}renderHudPass(t){if(!this.compassSprites.some(n=>n.visible))return;const e=this.renderer.autoClear,i=this.renderer.shadowMap.autoUpdate;this.renderer.autoClear=!1,this.renderer.shadowMap.autoUpdate=!1,t.layers.set(bm),this.renderer.render(this.scene,t),t.layers.set(0),this.renderer.autoClear=e,this.renderer.shadowMap.autoUpdate=i}renderReferencesPass(t){if(!this.references.any)return;const e=this.renderer.autoClear,i=this.renderer.shadowMap.autoUpdate;this.renderer.autoClear=!1,this.renderer.shadowMap.autoUpdate=!1,t.layers.set(W1),this.renderer.render(this.scene,t),t.layers.set(0),this.renderer.autoClear=e,this.renderer.shadowMap.autoUpdate=i}setReferences(t,e){this.references.set(t.map(i=>{const n=this.documentRelative(i.src);return n===i.src?i:{...i,src:n}}),void 0,e)}referenceAspect(t){return this.references.aspectOf(t)}directionAt(t,e){return this.directionAtScreenPoint(t,e,new R)}referenceFailedToLoad(t){return this.references.failedToLoad(this.documentRelative(t))}setReferencesShown(t){this.references.setShown(t),this.render()}setReferenceView(t,e){this.references.setView(t,e),this.render()}renderPhenomenaPass(t){if(!this.phenomena.any)return;const e=this.renderer.autoClear,i=this.renderer.shadowMap.autoUpdate;this.renderer.autoClear=!1,this.renderer.shadowMap.autoUpdate=!1,this.renderer.clearDepth();for(const n of this.decorObjects){const s=this.decorGroups.get(n.id);s&&ke.markDecorDepth(s,n.kind!=="crop")}t.layers.set(nu),this.scene.overrideMaterial=this.decorDepthMaterial,this.renderer.render(this.scene,t),this.scene.overrideMaterial=null,t.layers.set(V1),this.renderer.render(this.scene,t),t.layers.set(0),this.renderer.autoClear=e,this.renderer.shadowMap.autoUpdate=i}decorDepthMaterial=new _n({colorWrite:!1});static markDecorDepth(t,e){t.traverse(i=>{if(!(i instanceof Dt))return;const n=Array.isArray(i.material)?i.material[0]:i.material;e&&n.depthWrite!==!1&&n.blending!==Ni?i.layers.enable(nu):i.layers.disable(nu)})}startExposure(){this.cancelExposure(),this.exposureSubjectBounds=[];const t=this.renderer.getDrawingBufferSize(new xt),e=Math.max(1,Math.round(t.x)),i=Math.max(1,Math.round(t.y));this.exposureAccumulation||(this.exposureAccumulation=new Tb(e,i)),this.exposureAccumulation.resize(e,i),this.exposureAccumulation.open(this.renderer),this.exposureInstantsDone=0,this.exposureFrameId=requestAnimationFrame(()=>this.developExposure())}developExposure(){this.exposureFrameId=null;const t=this.exposureInstantAt,e=this.exposureAccumulation;if(!t||!e)return;const i=1/this.exposureInstants;this.resolution.beginDrawing();const n=performance.now()+ke.EXPOSURE_BUDGET_MS,s=ke.exposureInstantsPerFrame(e.instantTarget.scene.width*e.instantTarget.scene.height);let a=0;do{this.restateAt(t,this.exposureInstantsDone);const o=this.compassSprites.map(c=>c.visible);for(const c of this.compassSprites)c.visible=!1;try{this.renderOnce(e.instantTarget)}finally{this.compassSprites.forEach((c,l)=>{c.visible=o[l]})}e.add(this.renderer,i),this.exposureInstantsDone++,a++}while(this.exposureInstantsDone<this.exposureInstants&&performance.now()<n&&a<s);this.restateAt(t,0),this.presentExposure(),this.resolution.endDrawing(),this.exposureInstantsDone<this.exposureInstants&&(this.exposureFrameId=requestAnimationFrame(()=>this.developExposure()))}presentExposure(){if(Hi.uRodShare.value=this.scatteredSky?.rodShare??0,Hi.uHasOverlay.value=1,Hi.uRelativeScale.value=this.relativeScale,this.applyMedium(),this.exposureAccumulation?.develop(this.renderer,this.exposureInstants/this.exposureInstantsDone),this.onMapSubjectBounds?.(this.exposureSubjectBounds),!this.compassSprites.some(s=>s.visible))return;const t=new Ts,e=new Un(-1,1,1,-1,0,2),i=Zc/(Im*Math.tan(Cm*qi/2));for(const s of this.compassSprites){if(!s.visible)continue;const a=s.getWorldPosition(new R).sub(this.camera.position).normalize(),o=this.screenPointOf(a);if(!o)continue;const c=new jr(s.material);c.position.set(o.ndcX,o.ndcY,-1),c.scale.set(i/this.camera.aspect,i,1),t.add(c)}const n=this.renderer.autoClear;this.renderer.autoClear=!1;try{this.renderer.render(t,e)}finally{this.renderer.autoClear=n}}onMapSubjectBounds;exposureSubjectBounds=[];static MAP_SUBJECT_NEAREST_M=8;mapSubjectBounds(){const t=[],e=new Vi,i=new R,n=this.camera.getWorldDirection(new R),s=this.decorObjects.filter(o=>o.track?.length||o.kind==="aircraft"||o.kind==="vehicle").map(o=>this.decorGroups.get(o.id)),a=this.bodySystem.reflectors.map(o=>o.holder);for(const o of[...s,...a]){if(!o?.visible||(e.setFromObject(o),e.isEmpty())||e.distanceToPoint(this.camera.position)<ke.MAP_SUBJECT_NEAREST_M)continue;let c=1/0,l=-1/0,h=1/0,u=-1/0;for(const d of[e.min.x,e.max.x])for(const f of[e.min.y,e.max.y])for(const p of[e.min.z,e.max.z]){if(i.set(d,f,p).sub(this.camera.position).normalize(),i.dot(n)<=0)continue;const v=this.screenPointOf(i);if(!v)continue;const m=(v.ndcX+1)/2,g=(1-v.ndcY)/2;c=Math.min(c,m),l=Math.max(l,m),h=Math.min(h,g),u=Math.max(u,g)}c=Math.max(c,0),l=Math.min(l,1),h=Math.max(h,0),u=Math.min(u,1),l>=c&&u>=h&&t.push({x:c,y:h,width:l-c,height:u-h})}return t}restateAt(t,e){this.restatingExposure=!0;try{t(e)}finally{this.restatingExposure=!1}}cancelExposure(){this.exposureFrameId!==null&&(cancelAnimationFrame(this.exposureFrameId),this.exposureFrameId=null)}setLensOptics(t){const e=this.lensOptics;this.lensOptics=t,(e===void 0!=(t===void 0)||e&&t&&(e.focalLengthMm!==t.focalLengthMm||e.fNumber!==t.fNumber||e.focusDistance!==t.focusDistance||e.frameHeightMm!==t.frameHeightMm))&&(t&&this.depthOfFieldPass&&this.depthOfFieldPass.setLens(t.focalLengthMm,t.fNumber,t.focusDistance,t.frameHeightMm),this.render())}usableDepthOfFieldPass(){const t=this.lensOptics;if(!t)return;const e=this.renderer.getDrawingBufferSize(new xt),i=Math.max(1,Math.round(e.x)),n=Math.max(1,Math.round(e.y));return this.depthOfFieldPass||(this.depthOfFieldPass=new Do(i,n)),this.depthOfFieldPass.resize(i,n),this.depthOfFieldPass.setLens(t.focalLengthMm,t.fNumber,t.focusDistance,t.frameHeightMm),this.depthOfFieldPass}usableFinishPass(){const t=this.renderer.getDrawingBufferSize(new xt);return this.finishPass?this.finishPass.resize(t.x,t.y):this.finishPass=new z0(t.x,t.y),this.finishPass}usableEquidistantPass(){if(this.projectionKind!=="equidistant")return;const t=this.renderer.getDrawingBufferSize(new xt);return this.equidistantPass?this.equidistantPass.resize(t.x,t.y):this.equidistantPass=new We(t.x,t.y),this.equidistantPass}aimAtScreenPoint(t,e,i){const n=this.projectionKind==="equidistant"?this.equidistantPass:void 0;if(!n){t.setFromCamera(new xt(e,i),this.camera);return}const s=n.directionFor(e,i,this.camera.fov);this.camera.updateMatrixWorld(),t.ray.origin.setFromMatrixPosition(this.camera.matrixWorld),t.ray.direction.set(s.x,s.y,s.z).applyQuaternion(this.camera.quaternion).normalize(),t.camera=this.camera}pickCloudAt(t,e){return this.layeredClouds?.pickInstance(this.cloudDirectionAt(t,e))}cloudDirectionAt(t,e){return this.directionAtScreenPoint(t,e,new R)}directionAtScreenPoint(t,e,i){return this.aimAtScreenPoint(this.ufoOcclusionRaycaster,t,e),i.copy(this.ufoOcclusionRaycaster.ray.direction)}screenPointOf(t){this.camera.updateMatrixWorld();const e=this.screenPointScratch.copy(t).applyQuaternion(this.screenPointQuaternion.copy(this.camera.quaternion).invert()),i=this.renderer.getDrawingBufferSize(this.screenPointSize),n=i.x/Math.max(i.y,1);if(this.projectionKind==="equidistant"&&this.equidistantPass)return We.ndcFor(e,this.camera.fov,n);if(e.z>=0)return;const s=Math.tan(this.camera.fov/2*qi);return{ndcX:e.x/-e.z/(n*s),ndcY:e.y/-e.z/s}}screenPointScratch=new R;screenPointQuaternion=new Qi;screenPointSize=new xt;updateLensFlarePosition(){const t=this.lensFlare;if(!t)return;if(!this.sunVisible){t.mesh.visible=!1;return}if(this.camera.updateMatrixWorld(),this.lensFlareScratch.copy(this.sunWorldPosition).applyMatrix4(this.camera.matrixWorldInverse),this.lensFlareScratch.z>0){t.mesh.visible=!1;return}const e=this.sunVisibleFraction();if(e<=0){t.mesh.visible=!1;return}t.mesh.visible=!0,this.sunUnhiddenFraction=e,this.applyDazzleStrength();const i=this.lensFlareScratch.copy(this.sunWorldPosition).project(this.camera);t.uniforms.uLensPosition.value.set(i.x,i.y);const n=this.renderer.domElement.width,s=this.renderer.domElement.height;t.uniforms.uResolution.value.set(n,s),t.uniforms.uTanHalfFov.value=Math.tan(this.camera.fov*Math.PI/360)}renderDazzleOnResample(){const t=this.lensFlare;if(!t||!this.sunVisible)return;const e=this.sunVisibleFraction();if(e<=0)return;this.sunUnhiddenFraction=e,this.applyDazzleStrength();const i=this.screenPointOf(this.lensFlareScratch.copy(this.sunWorldPosition).sub(this.camera.position).normalize());if(!i)return;const n=this.renderer.getDrawingBufferSize(this.screenPointSize);t.uniforms.uLensPosition.value.set(i.ndcX,i.ndcY),t.uniforms.uResolution.value.set(n.x,n.y),t.uniforms.uEquidistant.value=1,t.uniforms.uHalfFovRad.value=this.camera.fov*Math.PI/360;const s=this.renderer.autoClear;this.renderer.autoClear=!1,t.mesh.visible=!0,t.mesh.layers.enable(Sm),this.camera.layers.set(Sm),this.renderer.render(this.scene,this.camera),this.camera.layers.set(0),t.mesh.visible=!1,t.uniforms.uEquidistant.value=0,this.renderer.autoClear=s}sunVisibleFraction(){this.raycastableDecor().length>0&&this.scene.updateMatrixWorld();let t=0;for(const e of Lm)this.isSunOccluded(e[0],e[1])||t++;return t/Lm.length}raycastableDecor(){const t=[];for(const e of this.decorObjects){if(e.kind==="crop")continue;const i=this.decorGroups.get(e.id);i&&t.push(i)}return t}isSunOccluded(t=0,e=0){const i=this.raycastableDecor();if(!this.groundMesh&&!this.terrainMesh&&i.length===0)return!1;const n=this.sunOcclusionDirectionScratch.copy(this.sunWorldPosition).sub(this.camera.position),s=n.length();if(n.normalize(),t!==0||e!==0){const o=Math.PI/180,c=this.sunOcclusionRightScratch.set(n.z,0,-n.x);c.lengthSq()<1e-9&&c.set(1,0,0),c.normalize();const l=this.sunOcclusionUpScratch.crossVectors(c,n).normalize();n.addScaledVector(c,t*o).addScaledVector(l,e*o).normalize()}if(this.groundBlocks(this.camera.position,n,s))return!0;if(i.length===0)return!1;this.sunOcclusionRaycaster.set(this.camera.position,n);const a=this.sunOcclusionRaycaster.intersectObjects(i,!0)[0];return a!==void 0&&a.distance<s}groundBlocks(t,e,i,n=0){const s=this.groundMesh;if(s&&e.y<0){const m=(s.position.y-t.y)/e.y;if(m>n&&m<i){const g=t.x+e.x*m-s.position.x,S=t.z+e.z*m-s.position.z;if(Math.hypot(g,S)<=this.groundRadius)return!0}}const a=this.terrainMesh;if(!a)return!1;const o=a.geometry.getAttribute("position"),c=Math.round(Math.sqrt(o.count));if(c<2||c*c!==o.count)return!1;const l=[a.position.x+o.getX(0),a.position.x+o.getX(c-1)],h=[a.position.z+o.getZ(0),a.position.z+o.getZ((c-1)*c)],u=Math.min(Math.abs(l[1]-l[0]),Math.abs(h[1]-h[0]))/(c-1);if(!(u>0))return!1;let d=n,f=i;for(const[m,g,S]of[[t.x,e.x,l],[t.z,e.z,h]]){const y=Math.min(S[0],S[1]),M=Math.max(S[0],S[1]);if(Math.abs(g)<1e-12){if(m<y||m>M)return!1;continue}const b=(y-m)/g,w=(M-m)/g;d=Math.max(d,Math.min(b,w)),f=Math.min(f,Math.max(b,w))}if(!(f>d))return!1;const p=Math.hypot(e.x,e.z),v=Math.min(4096,Math.max(8,Math.ceil((f-d)*p/(u/2))));for(let m=0;m<=v;m++){const g=d+(f-d)*m/v,S=t.x+e.x*g,y=t.y+e.y*g,M=t.z+e.z*g;if(y<=this.groundYUnder(S,M))return!0}return!1}setPhenomena(t,e){this.phenomena.set(t,e)}decorDistancesAt(t,e,i){this.aimAtScreenPoint(this.ufoOcclusionRaycaster,t,e),this.ufoOcclusionRaycaster.near=wm;let n,s;for(const a of this.decorObjects){if(a.kind==="crop")continue;const o=this.decorGroups.get(a.id);if(!o)continue;const c=this.ufoOcclusionRaycaster.intersectObject(o,!0)[0];c&&(a.occludesSourceIds?.includes(i)?n=n===void 0?c.distance:Math.max(n,c.distance):s=s===void 0?c.distance:Math.min(s,c.distance))}return{behindM:n,inFrontM:s}}pickBodyAt(t,e){this.aimAtScreenPoint(this.raycaster,t,e);const i=[...this.hitAreas.entries()],n=this.raycaster.intersectObjects(i.map(([,s])=>s))[0];if(n&&!this.groundHides(t,e))return i.find(([,s])=>s===n.object)?.[0]}pickStarAt(t,e){if(this.namedStars.length===0)return;this.aimAtScreenPoint(this.raycaster,t,e);const i=this.raycaster.ray.direction,n=Math.cos(Am*this.camera.fov*Math.PI/180);let s,a=n;for(const o of this.namedStars){const c=o.direction.dot(i);c>a&&(a=c,s={star:o.star,altitudeDeg:o.altitudeDeg})}return s&&this.groundHides(t,e)?void 0:s}groundHides(t,e){if(!this.terrainMesh&&!this.groundMesh)return!1;this.aimAtScreenPoint(this.ufoOcclusionRaycaster,t,e);const i=this.ufoOcclusionRaycaster.ray;return this.groundBlocks(i.origin,i.direction,1/0,wm)}bodyScreenBox(t){const e=this.bodySystem.boxOf(t,this.bodyBoxScratch);if(!e)return;let i=1/0,n=1/0,s=-1/0,a=-1/0;for(let o=0;o<8;o++){const c=this.bodyCornerScratch.set(o&1?e.max.x:e.min.x,o&2?e.max.y:e.min.y,o&4?e.max.z:e.min.z),l=this.screenPointOf(c.sub(this.camera.position).normalize());if(!l)return;i=Math.min(i,l.ndcX),s=Math.max(s,l.ndcX),n=Math.min(n,l.ndcY),a=Math.max(a,l.ndcY)}return{minX:i,minY:n,maxX:s,maxY:a}}bodyBoxScratch=new Vi;bodyCornerScratch=new R;pickPlacedBodyAt(t,e){return this.aimAtScreenPoint(this.raycaster,t,e),this.bodySystem.pick(this.raycaster)}pickDecorAt(t,e){this.aimAtScreenPoint(this.raycaster,t,e);const i=[...this.decorGroups.entries()],n=this.raycaster.intersectObjects(i.map(([,a])=>a),!0)[0];if(!n)return;let s=n.object;for(;s&&!i.some(([,a])=>a===s);)s=s.parent;return i.find(([,a])=>a===s)?.[0]}dispose(){this.stopTerrainFade(),this.stopTwinkle(),this.cancelFlush(),this.phenomena.clear(),this.references.disposeAll(),this.terrainBuildToken++,this.cancelScatteredSkyPump(),this.skyMesh&&this.skyGradientMaterial&&(this.skyMesh.material=this.skyGradientMaterial),this.scatteredSky?.dispose(),this.scatteredSky=void 0,this.disposeMesh(this.skyMesh),this.disposeMesh(this.groundMesh),this.disposeMesh(this.terrainMesh),this.roadSystem.dispose(),this.disposeCloudSystem(),this.disposeCirrus(),this.disposePrecipitationPoints(),this.disposeRain(),this.disposeStarTiers(),this.meteorSystem?.dispose(),this.meteorSystem=void 0,this.iceHalos?.dispose(),this.iceHalos=void 0,this.rainbow?.dispose(),this.rainbow=void 0,this.skyGlow?.dispose(),this.skyGlow=void 0,this.depthOfFieldPass?.dispose(),this.finishPass?.dispose(),this.depthOfFieldPass=void 0,this.cancelExposure(),this.exposureAccumulation?.dispose(),this.exposureAccumulation=void 0,this.cometTail?.dispose(),this.cometTail=void 0,this.satelliteField?.dispose(),this.satelliteField=void 0,this.lightningBolt?.dispose(),this.lightningBolt=void 0;for(const t of this.bodyMeshes.values())this.disposeMesh(t);this.bodyMeshes.clear(),this.novaKeys.clear();for(const t of[...this.hitAreas.keys()])this.disposeHitArea(t);for(const t of[...this.glareSprites.keys()])this.disposeGlare(t);this.disposeCompassLabels();for(const t of this.decorGroups.values())ui.dispose(t);this.decorGroups.clear(),this.streetlightLights.clear(),this.lensFlare&&(this.lensFlare.mesh.removeFromParent(),this.lensFlare.mesh.geometry.dispose(),this.lensFlare.mesh.material.dispose(),this.lensFlare=void 0),this.renderer.dispose()}animationsRunning=!1;startTwinkle(){if(this.animationFrameId!==null||!this.needsAnimationLoop())return;this.cancelFlush();const t=e=>{this.frame(e),this.animationFrameId=requestAnimationFrame(t)};this.animationFrameId=requestAnimationFrame(t)}setAnimationsRunning(t,e=!1){const i=t&&e;if(t===this.animationsRunning&&i===this.framesDriven)return;const n=this.animationsRunning;this.animationsRunning=t,this.framesDriven=i,t&&!n&&(this.lastFrameTimeMs=void 0,this.resolution.reset());const s=!t&&this.renderer.getPixelRatio()!==this.resolution.maximum;s&&this.applyPixelRatio(this.resolution.maximum),this.syncAnimationLoop(),(!t||this.frameDirty)&&this.render(),s&&this.drawIfDirty()}stopTwinkle(){this.animationFrameId!==null&&(cancelAnimationFrame(this.animationFrameId),this.animationFrameId=null)}needsAnimationLoop(){return this.animationsRunning&&!this.framesDriven&&this.hasAnimations()}hasAnimations(){return this.starTiers.length>0||this.precipitationPoints!==void 0||this.rainSystem!==void 0||this.lensFlare!==void 0&&this.sunVisible}syncAnimationLoop(){this.needsAnimationLoop()?this.startTwinkle():this.stopTwinkle()}buildSky(t){const e=this.skyMesh?.geometry??new oi(qc,32,16),i=e.attributes.position,n=e.getAttribute("color")??new de(new Float32Array(i.count*3),3);for(let a=0;a<i.count;a++){const{altitudeDeg:o,azimuthDeg:c}=Ib(i.getX(a),i.getY(a),i.getZ(a)),l=kb(o,c,t.azimuthDeg,t.altitudeDeg);n.setXYZ(a,l[0],l[1],l[2])}if(n.needsUpdate=!0,this.skyMesh)return;e.setAttribute("color",n);const s=new _n({vertexColors:!0,side:Ve,fog:!1,depthWrite:!1});this.skyGradientMaterial=s,this.skyMesh=new Dt(e,s),this.skyMesh.renderOrder=-1,this.celestialGroup.add(this.skyMesh)}buildGround(){const t=Em(this.observerElevationM);if(this.groundMesh&&t===this.groundRadius)return;this.disposeMesh(this.groundMesh),this.groundRadius=t;const e=new M0(this.groundRadius,48),i=new zr({color:new st(su,su,su),fog:!0});La.fadeRim(i,this.groundRadius*.75,this.groundRadius),this.groundMesh=new Dt(e,i),this.groundMesh.rotation.x=-Math.PI/2,this.groundMesh.position.y=0,this.groundMesh.receiveShadow=!0,this.scene.add(this.groundMesh),this.applyGroundDepthWrite()}applyGroundDepthWrite(){const t=this.groundMesh?.material;if(!t)return;const e=this.terrainMesh===void 0;t.depthWrite!==e&&(t.depthWrite=e,t.needsUpdate=!0)}cloudTransmission(t,e=!1){const i=`${t.altitudeDeg.toFixed(1)}:${t.azimuthDeg.toFixed(1)}:${Math.round(this.cloudOffsetM.x/10)}:${Math.round(this.cloudOffsetM.z/10)}:${Math.round(this.observerElevationM)}:`+Object.entries(this.cloudLayerOffsetsM).map(([a,o])=>`${a}=${Math.round(o.x/10)},${Math.round(o.z/10)}`).join(";")+(e?":water":""),n=this.cloudTransmissionMemo.get(i);if(n!==void 0)return n;this.cloudTransmissionMemo.size>256&&this.cloudTransmissionMemo.clear();const s=this.computeCloudTransmission(t,e);return this.cloudTransmissionMemo.set(i,s),s}cloudTransmissionMemo=new Map;computeCloudTransmission(t,e=!1){const i=hi(t.altitudeDeg,t.azimuthDeg,1);if(this.layeredClouds)return this.layeredClouds.transmissionAt(i,e);let n=1;const s=this.lowerCloudCover();s>0&&(n*=1-ge.alphaAt(i,Math.abs(this.cloudLayerOffset()),s,this.cloudFieldOffset)*W5);const a=e?0:this.weather.highCloudCover??0;return a>0&&(n*=1-ge.iceAlphaAt(i,$c,a,this.cloudFieldOffset)*X5),Math.max(0,Math.min(1,n))}setBodyMesh(t,e,i,n,s){if(e.altitudeDeg<Kd){this.disposeMesh(this.bodyMeshes.get(t)),this.bodyMeshes.delete(t),this.disposeHitArea(t),this.disposeGlare(t),t==="sun"&&(this.sunVisible=!1);return}const{x:a,y:o,z:c}=hi(e.altitudeDeg,e.azimuthDeg,sn),l=Xp(e.altitudeDeg),h=this.cloudTransmission(e),u=this.arrivingIlluminance(e,s,h),d=ke.unitLuminance(n);let f=this.bodyMeshes.get(t);if(t==="sun"){const p=Math.PI*(i/sn)**2,v=[0,1,2].map(m=>Math.min(ke.BRIGHTEST_RELATIVE,d[m]*u[m]/p));f instanceof Dt||(this.disposeMesh(f),f=new Dt(new oi(1,16,16),new _n({fog:!1})),this.celestialGroup.add(f),this.bodyMeshes.set(t,f)),f.material.color.setRGB(v[0],v[1],v[2]),f.scale.setScalar(i)}else{if(!(f instanceof xs)){this.disposeMesh(f);const m=new ce;m.setAttribute("position",new ie(new Float32Array(3),3)),m.setAttribute("color",new ie(new Float32Array(3),3)),f=new xs(m,ae.material(To[To.length-1].size,!1)),ae.track(f),this.celestialGroup.add(f),this.bodyMeshes.set(t,f)}const p=f.geometry.getAttribute("color"),v=t.startsWith("comet:")?this.pointToPixel():1;p.setXYZ(0,d[0]*u[0]*v,d[1]*u[1]*v,d[2]*u[2]*v),p.needsUpdate=!0}if(f.position.set(a,o,c),this.setHitArea(t,a,o,c,i),t==="sun"&&(this.sunArriving=u),t.startsWith("comet:")?this.disposeGlare(t):t!=="sun"&&this.setGlare(t,a,o,c,u,i/sn*(180/Math.PI),ke.POINT_VEIL_HOLD_DEG),t==="sun"){this.sunVisible=!0;const p=this.celestialGroup.scale.x;this.sunWorldPosition.set(a*p,o*p+this.celestialGroup.position.y,c*p),this.lensFlare||(this.lensFlare=o5(),this.lensFlare.uniforms.uOpacity.value=tE,this.lensFlare.uniforms.uFlareIntensity.value=this.lensFlareArtifactIntensity,this.lensFlare.uniforms.uStarPoints.value=this.starPoints,this.scene.add(this.lensFlare.mesh)),this.applyLensFlareTint(l)}}setMoonMesh(t,e){const i="moon";if(t.magnitude>e||t.altitudeDeg<Kd){this.disposeMesh(this.bodyMeshes.get(i)),this.bodyMeshes.delete(i),this.disposeHitArea(i),this.disposeGlare(i);return}const{x:n,y:s,z:a}=hi(t.altitudeDeg,t.azimuthDeg,sn),o=this.cloudTransmission(t),c=this.arrivingIlluminance(t,t.magnitude,o),l=Math.max(xr(t.phase.illuminatedFraction,0,1),.01)*Math.PI*(uo/sn)**2,h=new st(...c.map(f=>Math.min(ke.BRIGHTEST_RELATIVE,f/l))),u=`${t.phase.phaseFraction<.5}:${Math.round(xr(t.phase.illuminatedFraction,0,1)*500)}`;let d=this.bodyMeshes.get(i);if(d instanceof jr)d.userData.phaseKey!==u&&(d.material.map?.dispose(),d.material.map=Zm(t.phase),d.userData.phaseKey=u),d.material.color.copy(h);else{this.disposeMesh(d),d=new jr(new ol({map:Zm(t.phase),color:h,fog:!1})),d.userData.phaseKey=u;const f=uo*2;d.scale.set(f,f,1),this.celestialGroup.add(d),this.bodyMeshes.set(i,d)}d.position.set(n,s,a),this.setHitArea(i,n,s,a,uo),this.setGlare(i,n,s,a,c,uo/sn*(180/Math.PI))}bentLight(t,e,i=G5){const[n,s,a]=this.arrivingIlluminance(t,e,1),o=Math.max(s,1e-30);return{scale:s/i,tint:[n/o,1,a/o]}}static litBySky(t,e){return ke.litScratch.setRGB(t.r*e[0],t.g*e[1],t.b*e[2])}static litScratch=new st;pointToPixel(){const t=Math.max(1,this.renderer.getDrawingBufferSize(this.pointScratch).y),e=(this.camera.fov*Math.PI/180/t)**2;return Math.min(1,ae.CONE_SOLID_ANGLE/e)}pointScratch=new xt;static POINT_VEIL_HOLD_DEG=.25;static BRIGHTEST_RELATIVE=6e4;arrivingIlluminance(t,e,i){const n=this.air.transmittanceFromSpace(this.siteElevationM+this.observerElevationM,t.altitudeDeg),s=pe.illuminanceOf(e)*i*this.relativeScale;return[n[0]*s,n[1]*s,n[2]*s]}static unitLuminance(t){const e=On.luminanceOf([t.r,t.g,t.b]);return e>0?[t.r/e,t.g/e,t.b/e]:[1,1,1]}setHitArea(t,e,i,n,s){let a=this.hitAreas.get(t);if(!a){const c=new ol({transparent:!0,opacity:0,depthTest:!1,depthWrite:!1,fog:!1});a=new jr(c),this.celestialGroup.add(a),this.hitAreas.set(t,a)}a.position.set(e,i,n);const o=s*H5;a.scale.set(o,o,1)}disposeHitArea(t){const e=this.hitAreas.get(t);e&&(e.removeFromParent(),e.material.dispose(),this.hitAreas.delete(t))}setGlare(t,e,i,n,s,a,o=0){if(Pi.radiusDeg(Pi.K*Math.max(...s))<=Math.max(a,o)){this.disposeGlare(t);return}let c=this.glareSprites.get(t);c||(c=new Pi(`veil:${t}`),this.celestialGroup.add(c.mesh),this.glareSprites.set(t,c)),c.shine({x:e,y:i,z:n},s,a,o)}disposeGlare(t){const e=this.glareSprites.get(t);e&&(e.mesh.removeFromParent(),e.dispose(),this.glareSprites.delete(t))}buildComet(t,e){const i=t&&`comet:${t.id}`;if(!t||!i||t.magnitude>e){this.disposeComet();return}this.cometKey&&this.cometKey!==i&&this.disposeComet();const n=Mo(t.magnitude,e),s=Xh(n);this.cometKey=i,this.setBodyMesh(i,t.position,ru*(.5+.5*n),new st(s,s,s),t.magnitude),this.cometTail||(this.cometTail=new rn(sn),this.celestialGroup.add(this.cometTail.object)),this.cometTail.set(t.position,t.tailEnd,n)}buildIceHalos(t,e){this.iceHalos||(this.iceHalos=new Ci,this.iceHalos.setCloudOffset(this.cloudFieldOffset),this.iceHalos.onReady=()=>this.render(),this.celestialGroup.add(this.iceHalos.object)),this.iceHalos.setUrgent(!!this.skyHoldUntilMs);const i=this.highCloudCover(),n=this.layeredClouds?.cirrusMask;if(this.iceHalos.setCloudOffset(n?.offset??this.cloudFieldOffset),this.layeredClouds?.hostHalo(this.iceHalos),i===void 0){this.iceHalos.update({x:0,y:1,z:0},-1,0,[1,1,1],{cover:0,layerHeight:$c},0);return}const s=this.lowerCloudCover(),a=me.deckLitUntilDeg(me.DECK_HEIGHT_M),o=t.altitudeDeg>-a?t:e,c=this.bentLight(o,o===t?Ne.SUN_MAGNITUDE:e.magnitude),l=me.strength(i,s,o.altitudeDeg,a)*c.scale,{x:h,y:u,z:d}=hi(o.altitudeDeg,o.azimuthDeg,1);this.iceHalos.update({x:h,y:u,z:d},o.altitudeDeg,l,c.tint,{cover:n?.cover??i,layerHeight:n?.layerHeight??$c},n?.iceCrystalAlignment??this.weather.iceCrystalAlignment??rv)}buildRainbow(t,e){this.rainbow||(this.rainbow=new Aa,this.celestialGroup.add(this.rainbow.object));const i=this.weather.precipitationType==="rain"?this.weather.precipitationIntensity*(this.weather.precipitationAmount??1):0,n=t.altitudeDeg>0,s=n?t:e,a=this.lowerCloudCover(),o=this.bentLight(s,n?Ne.SUN_MAGNITUDE:e.magnitude,V5),c=an.strength(i,a,s.altitudeDeg)*o.scale;if(c<=0){this.rainbow.update({x:0,y:1,z:0},0,[1,1,1],!0);return}const{x:l,y:h,z:u}=hi(s.altitudeDeg,s.azimuthDeg,1);this.rainbow.update({x:l,y:h,z:u},c,o.tint,n)}buildSkyGlow(t,e){if(!t.frame){this.skyGlow?.hide();return}this.skyGlow||(this.skyGlow=new Xs,this.skyGlow.onReady=()=>this.render(),this.celestialGroup.add(this.skyGlow.object));const{date:i,observer:n}=t.frame,s=Dn.galactic(i,n),a=ke.directionOf(s.centre),o=ke.directionOf(s.rotation),c=ke.directionOf(s.pole),l=new Yt().set(a.x,a.y,a.z,o.x,o.y,o.z,c.x,c.y,c.z),h=ke.directionOf(Dn.eclipticPole(i,n)),u=ke.directionOf(t.sun),d=u.clone().addScaledVector(h,-u.dot(h)).normalize();this.skyGlow.update({galactic:l,eclipticPole:h,sunLongitude:d,sunDirection:u,sunAltitudeDeg:t.sun.altitudeDeg,moon:{direction:ke.directionOf(t.moon),altitudeDeg:t.moon.altitudeDeg,phaseAngleDeg:Mt.phaseAngleOf(t.moon.phase.illuminatedFraction)},lightPollution:this.lightPollution,skyColor:new R(e[0],e[1],e[2])})}static directionOf(t){const{x:e,y:i,z:n}=hi(t.altitudeDeg,t.azimuthDeg,1);return new R(e,i,n).normalize()}buildNovae(t,e){const i=new Set;for(const n of t){if(n.magnitude>e)continue;const s=`nova:${n.id}`;i.add(s);const a=Mo(n.magnitude,e),o=Xh(a);this.setBodyMesh(s,n.position,ru*(.5+.5*a),new st(o,o,o),n.magnitude)}for(const n of this.novaKeys)i.has(n)||(this.disposeMesh(this.bodyMeshes.get(n)),this.bodyMeshes.delete(n),this.disposeHitArea(n),this.disposeGlare(n));this.novaKeys=i}disposeComet(){this.cometTail?.set(void 0,void 0,0),this.cometKey&&(this.disposeMesh(this.bodyMeshes.get(this.cometKey)),this.bodyMeshes.delete(this.cometKey),this.disposeHitArea(this.cometKey),this.disposeGlare(this.cometKey),this.cometKey=void 0)}buildPlanets(t,e){const i=new Set(["sun","moon",...this.cometKey?[this.cometKey]:[],...this.novaKeys]);for(const n of t){if(n.magnitude>e)continue;i.add(n.body);const s=Mo(n.magnitude,e),a=Xh(s),o=yE[n.body]??new st(1,1,1),c=new st(o.r*a,o.g*a,o.b*a),l=ru*(.5+.5*s);this.setBodyMesh(n.body,n.position,l,c,n.magnitude)}for(const n of[...this.bodyMeshes.keys()])i.has(n)||(this.disposeMesh(this.bodyMeshes.get(n)),this.bodyMeshes.delete(n),this.disposeHitArea(n),this.disposeGlare(n))}buildStars(t,e){if(this.namedStars=[],!t||t.catalog.count===0){this.disposeStarTiers(),this.syncAnimationLoop();return}const{catalog:i,date:n,observer:s}=t,a=new Pn(n,s),o=gu(1337),c=[],l=this.siteElevationM+this.observerElevationM;for(let h=0;h<i.count;h++){const u=i.mag[h];if(u>e)break;const{altitudeDeg:d,azimuthDeg:f}=a.position(i.ra[h],i.dec[h]);if(d<Tm)continue;const{x:p,y:v,z:m}=hi(d,f,au);c.push({x:p,y:v,z:m,brightness:Mo(u,e),illuminance:this.air.transmittanceFromSpace(l,d).map(g=>g*pe.illuminanceOf(u)),phase:o()*Math.PI*2,speedFactor:.7+o()*.6})}for(const h of Bw){if(h.mag>e)continue;const{altitudeDeg:u,azimuthDeg:d}=a.position(h.raHours,h.decDeg);if(u<Tm)continue;const{x:f,y:p,z:v}=hi(u,d,au);this.namedStars.push({star:h,direction:new R(f,p,v).normalize(),altitudeDeg:u})}this.starTiers=To.map((h,u)=>{const d=c.filter(b=>f1(b.brightness)===u),f=new Float32Array(d.length*3),p=new Float32Array(d.length),v=new Float32Array(d.length*3),m=new Float32Array(d.length),g=new Float32Array(d.length);d.forEach((b,w)=>{f[w*3]=b.x,f[w*3+1]=b.y,f[w*3+2]=b.z,p[w]=b.brightness,v.set(b.illuminance,w*3),m[w]=b.phase,g[w]=b.speedFactor});const S=new ce;S.setAttribute("position",new ie(f,3)),S.setAttribute("seed",new ie(m.map(b=>b/(2*Math.PI)),1));const y=new ie(new Float32Array(d.length*3),3);S.setAttribute("color",y);let M=this.starTiers[u]?.points;return M?(M.geometry.dispose(),M.geometry=S):(M=new xs(S,ae.material(h.size)),ae.track(M),this.celestialGroup.add(M)),{points:M,colorAttribute:y,brightness:p,illuminance:v,phase:m,speedFactor:g}}),this.starColoursRelative=Number.NaN,this.updateTwinkle(this.twinkleSeconds),this.startTwinkle()}twinkleSeconds=0;starColoursRelative=Number.NaN;updateTwinkle(t){ae.setTime(t);const e=this.relativeScale;if(e!==this.starColoursRelative){this.starColoursRelative=e;for(const i of this.starTiers){const n=i.colorAttribute.array;for(let s=0;s<i.brightness.length;s++)n[s*3]=i.illuminance[s*3]*e,n[s*3+1]=i.illuminance[s*3+1]*e,n[s*3+2]=i.illuminance[s*3+2]*e;i.colorAttribute.needsUpdate=!0}}}buildClouds(){if(this.cloudRendering==="volume"||this.weather.cloudLayers!==void 0){this.layeredClouds||(this.disposeCloudSystem(),this.layeredClouds=new Ar(this.celestialGroup,ou,this.cloudRendering)),this.disposeCirrus(),this.layeredClouds.hostHalo(this.iceHalos),this.layeredClouds.update(this.weather,this.observerElevationM+1.6),this.layeredClouds.setOffsets(this.cloudOffsetM,this.cloudLayerOffsetsM),this.lastSunPosition&&this.updateCloudLighting(this.lastSunPosition,this.baseFogColor);return}const t=this.lowerCloudCover();if(t<=0){this.disposeCloudSystem();return}const e=this.weather.cloudDarkness,i=new st(pa[0]+(hu[0]-pa[0])*e,pa[1]+(hu[1]-pa[1])*e,pa[2]+(hu[2]-pa[2])*e);if(this.cloudMesh&&this.cloudUniforms){this.cloudUniforms.coverage.value=t,this.cloudUniforms.baseColor.value.copy(i),this.syncCloudLayer(),this.lastSunPosition&&this.updateCloudLighting(this.lastSunPosition,this.baseFogColor);return}this.disposeCloudSystem();const{material:n,uniforms:s}=yd(i,t,Math.abs(this.cloudLayerOffset()));this.cloudMaterial=n,this.cloudUniforms=s,s.fieldOffset.value.copy(this.cloudFieldOffset),this.lastSunPosition&&this.updateCloudLighting(this.lastSunPosition,this.baseFogColor);const a=_d(ou);this.cloudMesh=new Dt(a,n),this.faceCloudDeck(this.cloudMesh,this.cloudLayerOffset()),this.celestialGroup.add(this.cloudMesh)}lowerCloudCover(){return this.weather.cloudLayers?1-this.weather.cloudLayers.filter(t=>t.type!=="cirrus").reduce((t,e)=>t*(1-e.coverage),1):this.weather.lowerCloudCover??this.weather.cloudCover}highCloudCover(){return this.weather.cloudLayers?1-this.weather.cloudLayers.filter(t=>t.type==="cirrus").reduce((t,e)=>t*(1-e.coverage),1):this.weather.highCloudCover}buildCirrus(){const t=this.weather.highCloudCover??0;if(this.layeredClouds||t<=0){this.disposeCirrus();return}if(this.cirrusMesh&&this.cirrusUniforms){this.cirrusUniforms.coverage.value=t,this.lastSunPosition&&this.updateCloudLighting(this.lastSunPosition,this.baseFogColor);return}const{material:e,uniforms:i}=yd(new st(...pa),t,$c,1);this.cirrusMaterial=e,this.cirrusUniforms=i,i.fieldOffset.value.copy(this.cloudFieldOffset),this.lastSunPosition&&this.updateCloudLighting(this.lastSunPosition,this.baseFogColor),this.cirrusMesh=new Dt(_d(ou*1.04),e),this.cirrusMesh.renderOrder=Om-1,this.celestialGroup.add(this.cirrusMesh)}disposeCirrus(){this.cirrusMesh&&(this.cirrusMesh.removeFromParent(),this.cirrusMesh.geometry.dispose()),this.cirrusMaterial?.dispose(),this.cirrusMesh=void 0,this.cirrusMaterial=void 0,this.cirrusUniforms=void 0}syncCloudLayer(){this.layeredClouds?.update(this.weather,this.observerElevationM+1.6);const t=this.cloudLayerOffset();this.cloudUniforms&&(this.cloudUniforms.layerHeight.value=Math.abs(t)),this.cloudMesh&&this.faceCloudDeck(this.cloudMesh,t)}faceCloudDeck(t,e){const i=e<0;t.scale.y=i?-1:1,t.renderOrder=i?Ar.deckOrder(!0,0,1):Om}cloudLayerOffset(){const e=((this.weather.cloudBaseM??Jd)-this.observerElevationM)*cu;return Math.sign(e||1)*Math.max(Math.abs(e),iE)}updateCloudLighting(t,e){const i=[this.cloudUniforms,this.cirrusUniforms].filter(u=>u!==void 0);if(i.length===0&&!this.layeredClouds)return;const n=this.cloudBeamDirection,[s,a,o]=this.cloudBeam.map(u=>u/Math.PI),c=this.lightningLevel*mu*this.relativeScale/Math.PI,l=new st(e[0]+Xn.r*c,e[1]+Xn.g*c,e[2]+Xn.b*c);this.layeredClouds?.setLighting(n.clone(),new st(s,a,o),l,l);const h=Math.max(0,n.y);for(const u of i)u.sunDir.value.copy(n),u.sunColor.value.setRGB(s*h,a*h,o*h),u.ambientColor.value.copy(l)}disposeCloudSystem(){this.layeredClouds?.dispose(),this.layeredClouds=void 0,this.cloudMesh&&(this.cloudMesh.removeFromParent(),this.cloudMesh.geometry.dispose()),this.cloudMaterial?.dispose(),this.cloudMesh=void 0,this.cloudMaterial=void 0,this.cloudUniforms=void 0}disposePrecipitationPoints(){this.precipitationPoints&&(this.precipitationPoints.removeFromParent(),this.precipitationPoints.geometry.dispose(),this.precipitationPoints.material.dispose()),this.precipitationPoints=void 0,this.precipitationPositions=void 0,this.precipitationPhase=void 0,this.precipitationSpeedJitter=void 0,this.precipitationWobbleFreqJitter=void 0,this.precipitationWobbleAmpJitter=void 0,this.precipitationBounceRemaining=void 0,this.precipitationBounceHeight=void 0,this.precipitationBounceDuration=void 0,this.precipitationBounceVelX=void 0,this.precipitationBounceVelZ=void 0,this.precipitationUniforms=void 0}precipitationCount(t){return hE(t,this.weather.precipitationIntensity,this.weather.precipitationAmount??1)}updatePrecipitationDensity(){const t=[[this.rainSystem?.points,fu],[this.rainSplashSystem?.points,ma],[this.precipitationPoints,this.weather.precipitationType==="none"||this.weather.precipitationType==="rain"?void 0:uu[this.weather.precipitationType].poolSize]];for(const[e,i]of t)e&&i!==void 0&&e.geometry.setDrawRange(0,this.precipitationCount(i));this.rainSystem&&(this.rainSystem.uniforms.uSpeedStreak.value=km(pu(this.weather.precipitationIntensity)))}buildPrecipitation(){this.disposePrecipitationPoints(),this.disposeRain();const t=this.weather.precipitationType;if(t==="none")return;if(t==="rain"){this.buildRain();return}const e=uu[t],i=e.poolSize,n=gu(9001),s=new Float32Array(i*3),a=new Float32Array(i),o=new Float32Array(i),c=new Float32Array(i),l=new Float32Array(i),h=new Float32Array(i),u=new Float32Array(i),d=new Float32Array(i),f=new Float32Array(i),p=new Float32Array(i);for(let y=0;y<i;y++){const M=n()*Math.PI*2,b=n()*e.radiusM;s[y*3]=Math.cos(M)*b,s[y*3+1]=fr+n()*(e.topYM-fr),s[y*3+2]=Math.sin(M)*b,a[y]=n()*Math.PI*2,o[y]=.7+n()*.6,c[y]=.6+n()*.8,l[y]=.4+n()*1.2}const v=new ce;v.setAttribute("position",new ie(s,3)),v.setDrawRange(0,this.precipitationCount(i));const m={uSize:{value:e.size},uScale:{value:.5*this.renderer.domElement.height},uOpacity:{value:e.opacity},uColor:{value:e.color.clone()},uHazeColor:{value:new st(...this.baseFogColor)},uTexture:{value:_E(t)},uNearFocusDistance:{value:Gm},uHazeDistance:{value:e.radiusM*Vm}},g=new le({uniforms:m,vertexShader:TE,fragmentShader:RE,transparent:!0,depthWrite:!1});this.precipitationUniforms=m;const S=new xs(v,g);S.renderOrder=lu,this.scene.add(S),this.precipitationPoints=S,this.precipitationPositions=s,this.precipitationPhase=a,this.precipitationSpeedJitter=o,this.precipitationWobbleFreqJitter=c,this.precipitationWobbleAmpJitter=l,this.precipitationBounceRemaining=h,this.precipitationBounceHeight=u,this.precipitationBounceDuration=d,this.precipitationBounceVelX=f,this.precipitationBounceVelZ=p}updatePrecipitation(t,e){if(!this.precipitationPoints||!this.precipitationPositions||!this.precipitationPhase||!this.precipitationSpeedJitter)return;this.precipitationUniforms?.uHazeColor.value.setRGB(...this.baseFogColor);const i=this.weather.precipitationType;if(i==="none"||i==="rain")return;const n=uu[i];if(this.precipitationUniforms?.uColor.value.copy(ke.litBySky(n.color,this.baseFogColor)),e<=0)return;const s=this.weather.windDirectionDeg*qi,a=Math.sin(s)*this.weather.windSpeed*n.driftSensitivity,o=-Math.cos(s)*this.weather.windSpeed*n.driftSensitivity,c=this.precipitationPositions,l=this.precipitationPhase,h=this.precipitationSpeedJitter,u=this.precipitationWobbleFreqJitter,d=this.precipitationWobbleAmpJitter,f=this.precipitationBounceRemaining,p=this.precipitationBounceHeight,v=this.precipitationBounceDuration,m=this.precipitationBounceVelX,g=this.precipitationBounceVelZ,S=i==="snow"&&u&&d,y=i==="hail"&&f&&p&&v&&m&&g;for(let M=0,b=0;M<c.length;M+=3,b++){if(y&&f[b]>0){if(f[b]-=e,f[b]<=0){const x=Math.random()*Math.PI*2,A=Math.sqrt(Math.random())*n.radiusM;c[M]=Math.cos(x)*A,c[M+1]=n.topYM,c[M+2]=Math.sin(x)*A,f[b]=0}else{const x=1-f[b]/v[b];c[M+1]=fr+Math.sin(Math.PI*x)*p[b],c[M]=Jc(c[M]+(a+m[b])*e,n.radiusM),c[M+2]=Jc(c[M+2]+(o+g[b])*e,n.radiusM)}continue}let w=0,T=0;if(S){const x=dE*u[b],A=fE*d[b];w=Math.sin(t*x*Math.PI*2+l[b])*A,T=Math.sin(t*x*Math.PI*2+l[b]+Math.PI/2)*A}if(c[M]+=(a+w)*e,c[M+1]-=n.fallSpeedMPerS*h[b]*e,c[M+2]+=(o+T)*e,c[M]=Jc(c[M],n.radiusM),c[M+2]=Jc(c[M+2],n.radiusM),c[M+1]<fr){if(y){p[b]=$m*(.2+Math.random()*1.6),v[b]=pE*(.5+Math.random()),f[b]=v[b];const C=Math.random()*Math.PI*2,I=mE*(p[b]/$m);m[b]=Math.cos(C)*I,g[b]=Math.sin(C)*I,c[M+1]=fr;continue}const x=Math.random()*Math.PI*2,A=Math.sqrt(Math.random())*n.radiusM;c[M]=Math.cos(x)*A,c[M+1]=n.topYM,c[M+2]=Math.sin(x)*A}}this.precipitationPoints.geometry.attributes.position.needsUpdate=!0}buildRain(){const t=pu(this.weather.precipitationIntensity);this.rainSystem=n5({count:fu,radiusM:fo,heightM:sE,bottomYM:Nm,overallSpeed:aE,color:Um.clone(),opacity:.85,visibleCount:this.precipitationCount(fu),speedStreak:km(t),pixelSize:Xm,seed:9001,nearFocusDistanceM:Gm,hazeDistanceM:fo*Vm,hazeColor:new st(...this.baseFogColor)}),this.rainLastVerticalFacing=-1,this.syncRainSlant(),this.rainSystem.points.renderOrder=lu,this.scene.add(this.rainSystem.points),this.buildRainSplashes()}buildRainSplashes(){const t=gu(4242),e=new Float32Array(ma*3),i=new Float32Array(ma),n=new Float32Array(ma),s=new Float32Array(ma);for(let h=0;h<ma;h++){const u=t()*Math.PI*2,d=Math.sqrt(t())*fo;e[h*3]=Math.cos(u)*d,e[h*3+1]=Nm,e[h*3+2]=Math.sin(u)*d,n[h]=Km(zm,Bm),i[h]=t()*n[h],s[h]=i[h]/n[h]}const a=new ce;a.setAttribute("position",new ie(e,3));const o=new ie(s,1);a.setAttribute("aLife",o),a.setDrawRange(0,this.precipitationCount(ma));const c=new le({uniforms:{uMaxSize:{value:lE},uScale:{value:.5*this.renderer.domElement.height},uColor:{value:Hm.clone()},uTexture:{value:wE()}},vertexShader:EE,fragmentShader:AE,transparent:!0,depthWrite:!1}),l=new xs(a,c);l.renderOrder=lu,this.scene.add(l),this.rainSplashSystem={points:l,positions:e,life:i,duration:n,lifeAttribute:o}}disposeRain(){this.rainSystem&&(this.rainSystem.points.removeFromParent(),this.rainSystem.points.geometry.dispose(),this.rainSystem.points.material.dispose()),this.rainSystem=void 0,this.disposeRainSplashes()}disposeRainSplashes(){this.rainSplashSystem&&(this.rainSplashSystem.points.removeFromParent(),this.rainSplashSystem.points.geometry.dispose(),this.rainSplashSystem.points.material.dispose()),this.rainSplashSystem=void 0}syncRainSlant(){const t=this.rainSystem;if(!t)return;const e=this.weather.windDirectionDeg*qi;t.uniforms.uDropVelocity.value.set(Math.sin(e)*this.weather.windSpeed,-pu(this.weather.precipitationIntensity),-Math.cos(e)*this.weather.windSpeed);const i=this.renderer.getSize(this.rainViewportSize);t.uniforms.uAspect.value=i.x/Math.max(i.y,1)}updateRain(t){const e=this.rainSystem;if(!e)return;e.uniforms.uTime.value+=t,e.uniforms.uHazeColor.value.setRGB(...this.baseFogColor),e.uniforms.uColor.value.copy(ke.litBySky(Um,this.baseFogColor));const i=this.rainSplashSystem?.points.material?.uniforms?.uColor;i&&i.value.copy(ke.litBySky(Hm,this.baseFogColor));const n=this.weather.windDirectionDeg*qi,s=Math.sin(n)*this.weather.windSpeed,a=-Math.cos(n)*this.weather.windSpeed,o=fo,c=h=>(h%(o*2)+o*3)%(o*2)-o;e.uniforms.uWindOffset.value.set(c(e.uniforms.uWindOffset.value.x+s*t),c(e.uniforms.uWindOffset.value.y+a*t)),this.syncRainSlant(),this.camera.getWorldDirection(this.rainCameraDirection);const l=Math.abs(this.rainCameraDirection.y);if(Math.abs(l-this.rainLastVerticalFacing)>.001){this.rainLastVerticalFacing=l;const h=Ym+(1-Ym)*(1-l),u=qm+(1-qm)*(1-l);e.uniforms.uUvSquash.value=u,e.uniforms.uPixelSize.value=Xm*h*(.5+.5*u)}this.updateRainSplashes(t)}updateRainSplashes(t){const e=this.rainSplashSystem;if(!e||t<=0)return;const{positions:i,life:n,duration:s,lifeAttribute:a}=e,o=a.array;for(let c=0,l=0;c<i.length;c+=3,l++){if(n[l]+=t,n[l]>=s[l]){const h=Math.random()*Math.PI*2,u=Math.sqrt(Math.random())*fo;i[c]=Math.cos(h)*u,i[c+2]=Math.sin(h)*u,s[l]=Km(zm,Bm),n[l]=0}o[l]=n[l]/s[l]}e.points.geometry.attributes.position.needsUpdate=!0,a.needsUpdate=!0}setLightning(t){this.lightningFlashes=t}updateLightning(t){let e,i=0;if(this.lightningArmed)for(const c of this.lightningFlashes){if(c.t>t)break;const l=pi.brightnessAt(c,t);l>i&&(e=c,i=l)}const n=e?Math.min(1,Math.max(.1,(ME/e.distanceM)**2)):0,s=i*n*(e?.cloudToGround?1:.6);if(s===this.lightningLevel&&!e?.cloudToGround)return;if(this.lightningLevel=s,this.scene.fog){const c=this.scene.fog,l=s*mu*this.relativeScale/Math.PI;c.color.setRGB(this.airlight[0]+Xn.r*l,this.airlight[1]+Xn.g*l,this.airlight[2]+Xn.b*l)}const a=this.skyMesh?.material?.color;if(a){const c=s*xE;a.setRGB(1+c*Xn.r,1+c*Xn.g,1+c*Xn.b)}if(this.lastSunPosition&&this.updateCloudLighting(this.lastSunPosition,this.baseFogColor),this.lightningLight.intensity=s*mu*this.relativeScale,e){const{x:c,y:l,z:h}=hi(25,e.azimuthDeg,sn);this.lightningLight.position.set(c,l,h)}this.lightningBolt||(this.lightningBolt=new qs(sn*.95),this.celestialGroup.add(this.lightningBolt.object));const o=this.weather.cloudBaseM??1500;this.lightningBolt.set(e,i,o),this.render()}buildCompassLabels(){this.compassSprites=q5.map(t=>{const e=Ca.point(t,this.compassPoints),i=new ol({map:DE(e),depthTest:!1,fog:!1}),n=new jr(i),{x:s,y:a,z:o}=hi(0,t,Im);return n.position.set(s,a,o),n.scale.set(Zc,Zc,1),n.renderOrder=Z5,n.layers.set(bm),n.visible=this.compassHovered||this.compassForced,this.celestialGroup.add(n),n}),this.updateCompassScale()}updateCompassScale(){const t=this.camera.fov*Math.PI/360,e=Cm*Math.PI/360,i=Zc*Math.tan(t)/Math.tan(e);for(const n of this.compassSprites)n.scale.set(i,i,1)}disposeCompassLabels(){for(const t of this.compassSprites)t.removeFromParent(),t.material.map?.dispose(),t.material.dispose();this.compassSprites=[]}disposeStarTiers(){for(const t of this.starTiers)this.disposeMesh(t.points);this.starTiers=[]}disposeMesh(t){if(!t)return;t.removeFromParent(),"geometry"in t&&t.geometry.dispose();const e=t.material;for(const i of Array.isArray(e)?e:[e]){const n=i.map;n&&n.dispose(),i.dispose()}}}const qi=Math.PI/180;function xr(r,t,e){return Math.max(t,Math.min(e,r))}function Km(r,t){return r+Math.random()*(t-r)}function Jc(r,t){return(r%(t*2)+t*3)%(t*2)-t}let jc,Qc;function _E(r){switch(r){case"snow":return SE();case"hail":return bE()}}function SE(){if(jc)return jc;const r=64,t=document.createElement("canvas");t.width=r,t.height=r;const e=t.getContext("2d"),i=e.createRadialGradient(r/2,r/2,0,r/2,r/2,r/2);return i.addColorStop(0,"rgba(255,255,255,0.95)"),i.addColorStop(.5,"rgba(255,255,255,0.55)"),i.addColorStop(1,"rgba(255,255,255,0)"),e.fillStyle=i,e.fillRect(0,0,r,r),jc=new Is(t),jc}function bE(){if(Qc)return Qc;const r=64,t=document.createElement("canvas");t.width=r,t.height=r;const e=t.getContext("2d"),i=e.createRadialGradient(r/2,r/2,0,r/2,r/2,r/2);return i.addColorStop(0,"rgba(255,255,255,1)"),i.addColorStop(.55,"rgba(255,255,255,0.95)"),i.addColorStop(.8,"rgba(255,255,255,0.4)"),i.addColorStop(1,"rgba(255,255,255,0)"),e.fillStyle=i,e.fillRect(0,0,r,r),Qc=new Is(t),Qc}let tl;function wE(){if(tl)return tl;const r=64,t=document.createElement("canvas");t.width=r,t.height=r;const e=t.getContext("2d"),i=e.createRadialGradient(r/2,r/2,0,r/2,r/2,r/2);return i.addColorStop(0,"rgba(255,255,255,0)"),i.addColorStop(.4,"rgba(255,255,255,0)"),i.addColorStop(.6,"rgba(255,255,255,0.9)"),i.addColorStop(.8,"rgba(255,255,255,0.25)"),i.addColorStop(1,"rgba(255,255,255,0)"),e.fillStyle=i,e.fillRect(0,0,r,r),tl=new Is(t),tl}const EE=`
|
|
7766
|
+
`,transparent:!0,blending:Ni,depthWrite:!1,side:Ve,fog:!1});this.object=new Dt(new oi(B0.RADIUS,128,32,0,Math.PI*2,0,pe.MAX_ANGLE_RAD),e),this.object.renderOrder=-1,this.object.frustumCulled=!1,this.object.visible=!1}show(t,e){if(!t||!e){this.object.visible=!1;return}this.towards.set(t.x,t.y,t.z).normalize(),this.object.quaternion.setFromUnitVectors(this.up,this.towards),this.object.material.uniforms.uSource.value.copy(this.towards);for(let i=0;i<pe.STEPS;i++){for(let n=0;n<3;n++)this.texels[i*4+n]=Fn.toHalfFloat(Math.min(e[i*3+n],6e4));this.texels[i*4+3]=Fn.toHalfFloat(1)}this.texture.needsUpdate=!0,this.object.visible=!0}dispose(){this.object.geometry.dispose(),this.object.material.dispose(),this.texture.dispose()}}class Nl{constructor(t){this.generator=t}static SIZE=128;target=new Wo(Nl.SIZE,{type:qe,generateMipmaps:!1,minFilter:oe,magFilter:oe});camera=new b0(.1,2e5,this.target);filteredTarget;capturedAtMs=-1/0;capturedVersion;get sharp(){return this.target.texture}get filtered(){return this.filteredTarget?.texture}capture(t,e,i,n=[]){const s=t.shadowMap.autoUpdate;let a=!1;e.traverse(c=>{const l=c;l.isLight&&l.castShadow&&l.shadow&&!l.shadow.map&&(a=!0)}),t.shadowMap.autoUpdate=a?s:!1;const o=n.map(c=>c.visible);for(const c of n)c.visible=!1;this.camera.position.copy(i),this.camera.update(t,e),n.forEach((c,l)=>{c.visible=o[l]}),t.shadowMap.autoUpdate=s,this.filteredTarget=this.generator.fromCubemap(this.target.texture,this.filteredTarget),this.capturedAtMs=performance.now()}dispose(){this.target.dispose(),this.filteredTarget?.dispose()}}class on{static REFRESH_MS=250;generator;eye;probes=new Map;constructor(t){on.install(),this.generator=new gd(t),this.eye=new Nl(this.generator)}static decor;refresh(t,e,i,n,s,a,o,c=[],l,h=on.REFRESH_MS){for(const m of[...this.probes.keys()])n.some(g=>g.id===m&&g.shiny)||(this.probes.get(m).dispose(),this.probes.delete(m));const u=[{probe:this.eye}];for(const m of n){if(!m.shiny)continue;let g=this.probes.get(m.id);g||(g=new Nl(this.generator),this.probes.set(m.id,g)),u.push({probe:g,reflector:m})}const d=performance.now(),f=()=>u.filter(({probe:m})=>m.capturedVersion!==o),p=f().filter(({probe:m})=>d-m.capturedAtMs>=h);if(p.length>0){const m=p.reduce((g,S)=>S.probe.capturedAtMs<g.probe.capturedAtMs?S:g);if(m.reflector){const g=m.reflector.holder.getWorldPosition(this.scratch);m.probe.capture(t,e,g,[m.reflector.holder,...s]),on.reflectOn(m.reflector.holder,m.probe)}else{m.probe.capture(t,e,i,[...s,...c]),l?.(m.probe.sharp),on.decor=m.probe.filtered;for(const g of a)on.reflectOn(g,m.probe);for(const g of n)g.shiny||on.reflectOn(g.holder,m.probe)}m.probe.capturedVersion=o}const v=f();if(v.length!==0)return Math.max(16,Math.min(...v.map(({probe:m})=>h-(d-m.capturedAtMs))))}scratch=new R;static reflectOn(t,e={filtered:on.decor}){t.traverse(i=>{const n=i.material;for(const s of Array.isArray(n)?n:n?[n]:[])s instanceof Yo?e.sharp&&s.setSurroundings(e.sharp):s instanceof ya&&e.filtered&&s.envMap!==e.filtered&&(s.envMap=e.filtered,s.needsUpdate=!0)})}dispose(){this.eye.dispose();for(const t of this.probes.values())t.dispose();this.generator.dispose()}static installed=!1;static install(){if(on.installed)return;on.installed=!0;const t="iblIrradiance += getIBLIrradiance( geometryNormal );";if(!Xt.lights_fragment_maps.includes(t)){console.warn("Reflections: three's lights_fragment_maps changed; the environment will light diffusely too");return}Xt.lights_fragment_maps=Xt.lights_fragment_maps.replace(t,"// The sky's diffuse light is the hemisphere light's (see Reflections).")}}function F5(r,t){return JSON.stringify(r.cloudLayers)===JSON.stringify(t.cloudLayers)&&r.cloudCover===t.cloudCover&&r.cloudDarkness===t.cloudDarkness&&r.cloudBaseM===t.cloudBaseM&&r.highCloudCover===t.highCloudCover&&r.iceCrystalAlignment===t.iceCrystalAlignment&&r.lowerCloudCover===t.lowerCloudCover&&r.relativeHumidity===t.relativeHumidity&&r.precipitationType===t.precipitationType&&r.precipitationIntensity===t.precipitationIntensity&&r.precipitationAmount===t.precipitationAmount&&r.windDirectionDeg===t.windDirectionDeg&&r.windSpeed===t.windSpeed&&r.storm===t.storm}const qc=900,nu=1,Sm=4,bm=5,wm=.5,_o=900,U5=6371e3,k5=3e4;function Em(r){const t=Math.sqrt(2*U5*Math.max(r,0));return Math.max(_o,Math.min(t,k5))}const su=.5,au=850,Am=.03,sn=850,ho=300,Gs=120,z5=700,B5=.04,uo=4,ru=1.5,Tm=-1,H5=6,Kd=-4,G5=2,V5=20,$c=2600,W5=.97,X5=.38,Kc=Kd,Rm=1500,Y5=400,q5=[0,45,90,135,180,225,270,315],$5=2,K5=16,Dm=4e3,Im=880,Zc=40,Cm=60,Z5=10,J5=1,j5=150,Q5=55,tE=.5,eE=17,Pm=.265,Lm=[[0,0],...Array.from({length:8},(r,t)=>{const e=t*Math.PI/4;return[Math.cos(e)*Pm,Math.sin(e)*Pm]})],ou=700,cu=250/Jd,iE=12,Om=5,lu=6,pa=[.92,.92,.95],hu=[.15,.15,.19],uu={snow:{fallSpeedMPerS:2,size:.3,color:new st(1,1,1),driftSensitivity:1,radiusM:25,topYM:20,opacity:.75,poolSize:2400},hail:{fallSpeedMPerS:14,size:.5,color:new st(.95,.98,1),driftSensitivity:.25,radiusM:25,topYM:10,opacity:.95,poolSize:1200}},fr=0,du=0,nE=150,fu=3e3,fo=20,sE=15,Nm=fr,aE=40,Fm=1,rE=9;function pu(r){return Fm+(rE-Fm)*r}const Um=new st(.75,.82,.92),oE=10,cE=.5;function km(r){return xr(r/oE,cE,1)}const ma=200,zm=.18,Bm=.32,lE=.35,Hm=new st(.85,.9,.98),Gm=5,Vm=.85,Wm=.01;function hE(r,t,e=1){return Math.round(r*(Wm+(1-Wm)*t)*e)}function uE(r,t){return JSON.stringify(r.cloudLayers)===JSON.stringify(t.cloudLayers)&&r.cloudCover===t.cloudCover&&r.cloudDarkness===t.cloudDarkness&&r.cloudBaseM===t.cloudBaseM&&r.highCloudCover===t.highCloudCover&&r.iceCrystalAlignment===t.iceCrystalAlignment&&r.lowerCloudCover===t.lowerCloudCover}const Xm=230,Ym=.7,qm=.05,dE=.6,fE=.7,pE=.15,$m=.35,mE=3,gE=1/12,vE=.5,Xn=new st(.82,.86,1),ME=2500,xE=1.6,mu=15,yE={Venus:new st(1,.96,.85),Mars:new st(1,.55,.4),Jupiter:new st(.95,.87,.72),Saturn:new st(.92,.86,.68)};class Oe{renderer;scene=new Ts;phenomena=new In(this.scene);references=new Rn(this.scene,()=>this.render());camera;celestialGroup=new Ce;skyMesh;skyGradientMaterial;scatteredSky;lastAstronomy;skyColoursStale=!1;scatteredSkyFrameId=null;skyHoldUntilMs=void 0;onFirstFrameHold;firstFrameReady(){return(!this.scatteredSky||this.scatteredSky.ambient!==void 0)&&!this.iceHalos?.awaitingFirstDisplay}sceneSettled(){return this.firstFrameReady()&&this.arrivalsPending===0&&this.eyeSettledVersion>=this.lastArrivalVersion}arrivalsPending=0;eyeSettledVersion=-1;lastArrivalVersion=0;awaitArrival(t,e){if(this.skyHoldUntilMs===null)return t;this.arrivalsPending++;let i=!0;const n=()=>{i&&(i=!1,this.arrivalsPending--,this.lastArrivalVersion=this.sceneVersion,this.skyHoldUntilMs&&this.redrawHeld())},s=e===void 0?void 0:setTimeout(n,e);return e!==void 0&&(this.arrivalDeadlineMs=Math.max(this.arrivalDeadlineMs,performance.now()+e),this.skyHoldUntilMs&&this.arrivalDeadlineMs>this.skyHoldUntilMs&&(this.skyHoldUntilMs=this.arrivalDeadlineMs,setTimeout(()=>this.render(),e+20))),t.finally(()=>{clearTimeout(s),n()})}static ROADS_PATIENCE_MS=4e3;static TERRAIN_PATIENCE_MS=12e3;arrivalDeadlineMs=0;redrawHeld(){this.frameDirty=!0,!(this.animationFrameId!==null||this.framesDriven||this.flushFrameId!==null)&&(this.flushFrameId=requestAnimationFrame(()=>{this.flushFrameId=null,this.drawIfDirty()}))}holdForNewScene(t){this.surroundings=void 0,this.scatteredSky?.resetSurroundings(),this.startHold(),t&&this.awaitArrival(t).catch(()=>{})}startHold(){this.skyHoldUntilMs=Math.max(performance.now()+Dm,this.arrivalDeadlineMs),this.eyeSettledVersion=-1,this.lastArrivalVersion=this.sceneVersion+1,this.iceHalos?.setUrgent(!0),this.onFirstFrameHold?.(!0),setTimeout(()=>this.render(),Dm+20)}groundMesh;terrainMesh;terrainProviders;terrainOrigin;terrainBuildToken=0;terrainAttribution;roadSystem=new gn;roadAttribution;roadWays;statedRoads=[];decorModelProvider=L5[0].create();decorModelToken=0;decorModelCredits=new Map;bodySystem=new ue(t=>this.awaitArrival(this.loadBodyModel(t)),()=>this.render(),()=>this.relativeScale);bodyOrigin={x:0,z:0};starTiers=[];bodyMeshes=new Map;hitAreas=new Map;glareSprites=new Map;decorObjects=[];decorGroups=new Map;decorReferencePose;decorCurrentPose;decorTime=0;celestialLight=new mp(16777215,0);celestialLightTarget=new Be;skyLight=new rx(16777215,0,0);streetlightLights=new Map;compassSprites=[];showCompass=!1;compassHovered=!1;compassForced=!1;animationFrameId=null;resolution;cssSize={width:1,height:1};frameDirty=!1;flushFrameId=null;framesDriven=!1;lastFrameTimeMs;raycaster=new cl;weather=jd;observerElevationM=0;siteElevationM=0;air=new xn;groundRadius=_o;terrainRadius=_o;cloudRendering="volume";layeredClouds;cloudLayerOffsetsM={};cloudOffsetM=new R;cloudFieldOffset=new R;cloudMesh;cirrusMesh;cirrusMaterial;cirrusUniforms;cloudMaterial;cloudUniforms;precipitationPoints;precipitationPositions;precipitationPhase;precipitationSpeedJitter;precipitationWobbleFreqJitter;precipitationWobbleAmpJitter;precipitationBounceRemaining;precipitationBounceHeight;precipitationBounceDuration;precipitationBounceVelX;precipitationBounceVelZ;precipitationUniforms;rainSystem;rainSplashSystem;rainCameraDirection=new R;rainLastVerticalFacing=-1;rainViewportSize=new xt;lightningArmed=!1;lightningFlashes=[];lightningLevel=0;lightningBolt;lightningLight=new mp(16777215,0);baseFogColor=[0,0,0];lastSunPosition;lensFlare;sunUnhiddenFraction=1;lensFlareArtifactIntensity=0;sunWorldPosition=new R;sunVisible=!1;lensFlareScratch=new R;sunOcclusionRaycaster=new cl;sunOcclusionDirectionScratch=new R;sunOcclusionRightScratch=new R;sunOcclusionUpScratch=new R;ufoOcclusionRaycaster=new cl;projectionKind="rectilinear";starPoints=0;namedStars=[];equidistantPass;depthOfFieldPass;finishPass;exposureAccumulation;exposureInstants=1;get developingExposure(){return this.exposureInstants>1&&this.exposureInstantAt!==void 0}static EXPOSURE_BUDGET_MS=12;static exposureInstantsPerFrame(t){return Math.max(3,Math.round(6e6/Math.max(1,t)))}exposureFrameId=null;exposureInstantsDone=0;exposureInstantAt;restatingExposure=!1;lensOptics;instrumentMagnitudeGain=0;lightPollution;meteorSystem;cometTail;satelliteField;iceHalos;lunarDiffraction;lunarDiffractionKey="";rainbow;skyGlow;cometKey;novaKeys=new Set;constructor(t,e=r2()){this.renderer=new xb({canvas:t,antialias:!0}),this.resolution=new ve(Math.min(window.devicePixelRatio||1,2),this.renderer.getContext()),this.renderer.setPixelRatio(this.resolution.pixelRatio),this.renderer.shadowMap.enabled=!0,this.renderer.shadowMap.type=bo,this.camera=new Zi(60,t.width/Math.max(t.height,1),.1,qc*1.2),this.camera.position.set(0,1.6,0),this.terrainProviders=e,this.celestialLight.shadow.mapSize.set(1024,1024),this.celestialLight.shadow.camera.left=-Gs,this.celestialLight.shadow.camera.right=Gs,this.celestialLight.shadow.camera.top=Gs,this.celestialLight.shadow.camera.bottom=-Gs,this.celestialLight.shadow.camera.near=sn-ho,this.celestialLight.shadow.camera.far=sn+ho,this.celestialLight.shadow.bias=-.03/(2*ho),this.celestialLight.shadow.normalBias=B5,this.celestialLight.target=this.celestialLightTarget,this.lightningLight.color.copy(Xn),this.scene.add(this.celestialLight,this.celestialLightTarget,this.skyLight,this.lightningLight),this.scene.add(this.celestialGroup),this.scene.add(this.bodySystem.group),this.scene.add(this.roadSystem.group);const i=new Fe(this.renderer,()=>{this.skyColoursStale=!0,this.render()});i.supported?this.scatteredSky=i:i.dispose()}get currentTerrainAttribution(){return this.terrainAttribution}get currentRoadAttribution(){return this.roadAttribution}resize(t,e){this.cssSize.width=t,this.cssSize.height=e,this.renderer.setSize(t,e,!1),this.camera.aspect=t/Math.max(e,1),this.camera.updateProjectionMatrix(),this.render()}setCloudRendering(t){t!==this.cloudRendering&&(this.cloudTransmissionMemo.clear(),this.cloudRendering=t,this.layeredClouds?.dispose(),this.layeredClouds=void 0,this.buildClouds(),this.buildCirrus(),this.render())}setCloudOffset(t,e={}){this.cloudOffsetM.set(t.x,0,t.z),this.cloudLayerOffsetsM=e,this.layeredClouds?.setOffsets(t,e),this.cloudFieldOffset.set(t.x*cu,0,t.z*cu);for(const i of[this.cloudUniforms,this.cirrusUniforms])i?.fieldOffset.value.copy(this.cloudFieldOffset);this.iceHalos?.setCloudOffset(this.layeredClouds?.cirrusMask?.offset??this.cloudFieldOffset)}setObserverPose(t){const e=((t.rollDeg??0)+this.gaitOffset.rollDeg)*qi,i=(t.pitchDeg+this.lookPitchDeg+this.gaitOffset.pitchDeg)*qi;if(t.headingDeg!==void 0?this.camera.rotation.set(i,-(t.headingDeg+this.lookYawDeg+this.gaitOffset.yawDeg)*qi,e,"YXZ"):this.camera.rotation.set(i,this.camera.rotation.y,e,"YXZ"),t.elevationM!==this.observerElevationM&&(this.observerElevationM=t.elevationM,this.syncCloudLayer(),Math.abs(Em(t.elevationM)-this.groundRadius)>1&&(this.buildGround(),this.celestialGroup.scale.setScalar(this.groundRadius/_o),this.camera.far=Math.max(qc*1.2,this.groundRadius*2.5),this.camera.updateProjectionMatrix())),this.terrainMesh&&this.terrainOrigin&&t.lat!==void 0&&t.lng!==void 0){const n=ai(this.terrainOrigin.lat,this.terrainOrigin.lng,t.lat,t.lng);this.terrainMesh.position.x=n.x,this.terrainMesh.position.z=n.z}this.poseCameraY=this.groundYUnder(0,0)+1.6+t.elevationM,this.camera.position.y=this.poseCameraY,this.celestialGroup.position.y=this.camera.position.y,this.camera.fov!==t.fovDeg&&(this.camera.fov=t.fovDeg,this.camera.updateProjectionMatrix(),this.updateCompassScale())}setTerrainProviders(t){this.stopTerrainFade(),this.terrainProviders=t,this.disposeMesh(this.terrainMesh),this.terrainMesh=void 0,this.terrainOrigin=void 0,this.terrainAttribution=void 0,this.roadSystem.clear(),this.roadAttribution=void 0,this.roadWays=void 0,this.applyGroundDepthWrite(),this.terrainBuildToken++}setTerrainOrigin(t,e,i){if(t===void 0||e===void 0)return;const n=this.groundRadius;if(this.terrainOrigin&&Math.abs(this.terrainRadius-n)<n*.1){const{x:c,z:l}=ai(t,e,this.terrainOrigin.lat,this.terrainOrigin.lng);if(Math.sqrt(c*c+l*l)<j5*(n/_o))return}const s=this.terrainOrigin,a=this.terrainRadius;(!s||s.lat!==t||s.lng!==e)&&(this.roadSystem.clear(),this.roadAttribution=void 0),this.terrainOrigin={lat:t,lng:e},this.terrainRadius=n;const o=++this.terrainBuildToken;this.awaitArrival(Xw(t,e,this.terrainProviders,n),Oe.TERRAIN_PATIENCE_MS).then(({mesh:c,attribution:l,originElevationM:h})=>{if(o!==this.terrainBuildToken)return;this.setSiteElevation(h??0);const u=this.terrainMesh,d=s?ai(t,e,s.lat,s.lng):void 0;u&&d&&Math.hypot(d.x,d.z)<=a&&(c.position.y=u.position.y+this.groundYOfPatch(u,d.x,d.z)),u&&d&&Math.hypot(d.x,d.z)<=a?this.crossfadeTerrain(c,u):this.disposeMesh(this.terrainMesh),c.renderOrder=J5,this.terrainMesh=c,this.compileNextFrameOffThread(),this.terrainAttribution=l,this.scene.add(c),this.applyGroundDepthWrite(),this.decorCurrentPose&&(this.setObserverPose(this.decorCurrentPose),this.updateDecorAnchoring(this.decorReferencePose,this.decorCurrentPose,this.decorTime)),this.buildRoads(t,e,n),this.drapeStatedRoads(),this.render(),i?.()}).catch(c=>{console.warn("Terrain build failed, keeping the flat ground fallback:",c),i?.()})}static TERRAIN_CROSSFADE_MS=1200;fadingTerrain;crossfadeTerrain(t,e){this.stopTerrainFade();const i=t.material;i.opacity=0,i.polygonOffset=!0,i.polygonOffsetFactor=-1,i.polygonOffsetUnits=-4;const n=performance.now(),s=()=>{const a=Math.min(1,(performance.now()-n)/Oe.TERRAIN_CROSSFADE_MS);if(i.opacity=a*a*(3-2*a),this.render(),a<1&&this.fadingTerrain){this.fadingTerrain.frameId=requestAnimationFrame(s);return}i.polygonOffset=!1,i.opacity=1,this.fadingTerrain&&this.disposeMesh(this.fadingTerrain.mesh),this.fadingTerrain=void 0,this.render()};this.fadingTerrain={mesh:e,frameId:requestAnimationFrame(s)}}stopTerrainFade(){if(!this.fadingTerrain)return;cancelAnimationFrame(this.fadingTerrain.frameId),this.disposeMesh(this.fadingTerrain.mesh),this.fadingTerrain=void 0;const t=this.terrainMesh?.material;t&&(t.opacity=1,t.polygonOffset=!1)}static ROADS_MAX_RADIUS_M=5e3;buildRoads(t,e,i){const n=this.terrainProviders.roads;if(!n||i>Oe.ROADS_MAX_RADIUS_M){this.roadSystem.clear(),this.roadAttribution=void 0;return}const s=this.roadWays;if(s&&s.lat===t&&s.lng===e&&s.radiusM===i){this.drapeRoads(s.ways,t,e,n.contemporary);return}this.awaitArrival(n.getRoads(L1(t,e,i)),Oe.ROADS_PATIENCE_MS).then(a=>{this.terrainOrigin?.lat!==t||this.terrainOrigin?.lng!==e||(this.roadWays={lat:t,lng:e,radiusM:i,ways:a},this.drapeRoads(a,t,e,n.contemporary))}).catch(a=>{console.warn("Roads unavailable, drawing none:",a)})}setStatedRoads(t){t!==this.statedRoads&&(this.statedRoads=t,this.drapeStatedRoads(),this.render())}drapeStatedRoads(){const t=this.terrainMesh;t&&(this.roadSystem.group.position.copy(t.position),this.roadSystem.setStated(this.statedRoads,(e,i)=>this.groundYOfPatch(t,e,i)))}drapeRoads(t,e,i,n){const s=this.terrainMesh;s&&(this.roadSystem.group.position.copy(s.position),this.roadSystem.set(t,e,i,(a,o)=>this.groundYOfPatch(s,a,o),n),this.roadAttribution=t.length>0?this.terrainProviders.roads?.attribution:void 0,this.compileNextFrameOffThread(),this.render())}setShowCompass(t){this.showCompass!==t&&(this.showCompass=t,this.disposeCompassLabels(),t&&this.buildCompassLabels(),this.render())}setCompassPoints(t){this.compassPoints!==t&&(this.compassPoints=t,this.showCompass&&(this.disposeCompassLabels(),this.buildCompassLabels(),this.render()))}compassPoints;applyLensFlareTint(t){if(!this.lensFlare)return;const e=Q5*(this.sunArriving[1]/eE);this.lensFlare.uniforms.uColorGain.value.setRGB(e*t[0],e*t[1],e*t[2]),this.applyDazzleStrength()}applyDazzleStrength(){if(!this.lensFlare)return;const[t,e,i]=this.sunArriving,n=Math.max(e,1e-30);this.lensFlare.uniforms.uDazzleColour.value.setRGB(t/n,1,i/n),this.lensFlare.uniforms.uVeilStrength.value=Pi.K*e*this.sunUnhiddenFraction}sunArriving=[0,0,0];setCompassHovered(t){this.compassHovered!==t&&(this.compassHovered=t,this.updateCompassVisibility())}setCompassForced(t){this.compassForced!==t&&(this.compassForced=t,this.updateCompassVisibility())}updateCompassVisibility(){const t=this.compassHovered||this.compassForced;if(this.compassSprites.some(e=>e.visible!==t)){for(const e of this.compassSprites)e.visible=t;this.developingExposure?this.exposureInstantsDone>0&&this.presentExposure():this.render()}}setWeather(t){if(F5(this.weather,t))return;this.cloudTransmissionMemo.clear();const e=this.weather;this.weather=t;const i=!uE(e,t),n=e.precipitationType!==t.precipitationType,s=e.precipitationIntensity!==t.precipitationIntensity||e.precipitationAmount!==t.precipitationAmount;(e.relativeHumidity!==t.relativeHumidity||n||s)&&(this.air=xn.of(t),this.applyAir(),this.scatteredSky?.setConditions({aerosolOpticalDepth:t.relativeHumidity===void 0?void 0:ta.steppedOpticalDepth(t.relativeHumidity)}),this.pumpScatteredSky()),i&&(this.buildClouds(),this.buildCirrus()),n?this.buildPrecipitation():s&&this.updatePrecipitationDensity(),this.lastAstronomy&&(i&&(this.buildIceHalos(this.lastAstronomy.sun,this.lastAstronomy.moon),this.buildLunarDiffraction(this.lastAstronomy.moon)),(i||n||s)&&this.buildRainbow(this.lastAstronomy.sun,this.lastAstronomy.moon)),this.lightningArmed=t.storm&&t.cloudDarkness>=vE,this.syncAnimationLoop(),this.render()}setDecor(t){if(this.decorObjects!==t){this.decorObjects=t,this.decorModelToken++,this.decorModelCredits.clear();for(const e of this.decorGroups.values())e.removeFromParent(),ui.dispose(e);this.decorGroups.clear(),this.streetlightLights.clear();for(const e of t){const i=ui.build(e,e.lit??!1);this.scene.add(i),this.decorGroups.set(e.id,i),e.kind==="streetlight"&&this.addStreetlightLight(e.id,i),this.awaitArrival(this.loadDecorModel(e,this.decorModelToken))}this.celestialLight.castShadow=this.decorGroups.size>0||this.bodySystem.any}}setDecorModelProvider(t){this.decorModelProvider=t;const e=this.decorObjects;this.decorObjects=[],this.setDecor(e)}get currentDecorModelCredits(){return[...this.decorModelCredits.values(),...this.bodySystem.modelCredits]}get bodyGround(){const{x:t,z:e}=this.bodyOrigin,i=this.groundYUnder(t,e);return{heightAt:(n,s)=>this.groundYUnder(t+n,e-s)-i}}setBodies(t,e=0,i=t.map(a=>a.id),n=[],s){const{x:a,z:o}=this.bodyOrigin,c=this.scatteredSky;this.bodySystem.set(t,{originX:a,originZ:o,originGroundY:this.groundYUnder(a,o),eye:this.camera.position,groundYAt:(h,u)=>this.groundYUnder(h,u),wind:s,light:this.plumeLight(),occluders:[...this.decorGroups.values()],transmittance:(h,u,d)=>this.transmittanceTo(h,u,d)},e,c?(h,u)=>c.relativeOfLuminance(h,u):void 0,i),this.bodySystem.setSmoke(n,e),this.bodySystem.any&&(this.celestialLight.castShadow=!0),this.fitShadowToBodies();const l=this.bodySystem.furthestFrom(this.camera.position)*1.2;l>this.camera.far&&(this.camera.far=l,this.camera.updateProjectionMatrix())}plumeLight(){const t=this.celestialLight.color,e=this.celestialLight.intensity*.5,i=this.skyLight.color,n=this.skyLight.groundColor,s=this.skyLight.intensity,a=(o,c,l)=>(o*e+(c+l)/2*s)/Math.PI;return[a(t.r,i.r,n.r),a(t.g,i.g,n.g),a(t.b,i.b,n.b)]}bodyOutline(t,e){return this.bodySystem.outlineOf(t,e)}documentUrl;modelUrl(t){return t.url?this.documentRelative(t.url):void 0}documentRelative(t){if(t.startsWith("data:"))return t;const e=this.documentUrl??(typeof location>"u"?void 0:location.href);return e?new URL(t,e).href:t}async loadBodyModel(t){const e=t.url?void 0:t.id?await this.decorModelProvider.entry(t.id):void 0,i=this.modelUrl(t)??e?.url,n=t.credit??e?.credit;if(!(!i||!n))return{scene:await _m(i),credit:n,headingOffsetDeg:t.headingOffsetDeg??e?.headingOffsetDeg}}async loadDecorModel(t,e){const i=t.model;if(!(!i||!ui.usesModel(t)))try{const n=i.url?void 0:i.id?await this.decorModelProvider.entry(i.id):void 0,s=this.modelUrl(i)??n?.url,a=i.credit??n?.credit;if(!s||!a)return;const o=await _m(s);if(e!==this.decorModelToken)return;const c=this.decorGroups.get(t.id);if(!c)return;on.reflectOn(o),ui.applyModel(c,t,o,{headingOffsetDeg:i.headingOffsetDeg??n?.headingOffsetDeg,depictedSizeM:n?.sizeM}),this.decorModelCredits.set(t.id,a),this.render()}catch(n){console.warn(`Keeping the built-in shape for decor "${t.id}":`,n)}}updateDecorAnchoring(t,e,i=0){this.decorReferencePose=t,this.decorCurrentPose=e,this.decorTime=i;const n=t?.lat!==void 0&&t.lng!==void 0&&e?.lat!==void 0&&e?.lng!==void 0?ai(t.lat,t.lng,e.lat,e.lng):{x:0,z:0},s=this.decorObjects.find(l=>l.observerSide!==void 0&&ng(l.kind));if(this.terrainMesh&&this.terrainOrigin&&e?.lat!==void 0&&e.lng!==void 0){const l=ai(this.terrainOrigin.lat,this.terrainOrigin.lng,e.lat,e.lng);this.terrainMesh.position.x=l.x-(s?0:this.gaitOffset.eastM),this.terrainMesh.position.z=l.z+(s?0:this.gaitOffset.northM),this.roadSystem.group.position.copy(this.terrainMesh.position)}s||(n.x-=this.gaitOffset.eastM,n.z+=this.gaitOffset.northM,this.camera.position.y=this.poseCameraY+this.gaitOffset.upM,this.celestialGroup.position.y=this.camera.position.y);const a={x:0,z:0};let o=0;if(s){const l=ui.occupantView(s),h=-(s.headingDeg??0)*qi,u=l.x*Math.cos(h)+l.z*Math.sin(h),d=-l.x*Math.sin(h)+l.z*Math.cos(h),f=s.eastM+n.x,p=-s.northM+n.z;a.x=-(f+u),a.z=-(p+d),this.camera.position.y=this.groundYUnder(f,p)+l.eyeY,this.camera.rotation.set(this.indoorLookPitchDeg*qi,-(l.headingDeg+this.indoorLookYawDeg)*qi,0,"YXZ")}this.bodyOrigin={x:n.x+a.x,z:n.z+a.z},this.placeShadowFrustum();for(const l of this.decorObjects){const h=this.decorGroups.get(l.id);if(!h)continue;const u=Co(l,i),d=u.eastM+n.x+a.x,f=-u.northM+n.z+a.z,p=this.terrainMesh,v=`${p?.geometry.uuid}:${(d-(p?.position.x??0)).toFixed(3)}:${(f-(p?.position.z??0)).toFixed(3)}:${(p?.position.y??0).toFixed(3)}:${u.headingDeg}:${u.altitudeM}`;if(h.userData.footprintKey!==v&&(h.userData.footprintGroundY=this.groundUnderFootprint(l,d,f,u.headingDeg,u.altitudeM),h.userData.footprintKey=v),h.position.set(d,h.userData.footprintGroundY+u.altitudeM,f),l.kind==="crop"){const m=Math.hypot(d,f);h.visible=m<=nE}if(u.headingDeg!==void 0&&(h.rotation.y=-u.headingDeg*qi),l.kind==="crop"&&h.visible){const m=this.terrainMesh,g=[m?.geometry.uuid,d-(m?.position.x??0),f-(m?.position.z??0),h.position.y-(m?.position.y??0),u.headingDeg,u.altitudeM].map(S=>typeof S=="number"?S.toFixed(4):S).join(":");h.userData.cropGroundKey!==g&&(ui.fitCropToGround(h,(S,y)=>this.groundYUnder(S,y)+u.altitudeM),h.userData.cropGroundKey=g)}o=Math.max(o,h.position.distanceTo(this.camera.position))}const c=Math.max(qc*1.2,this.groundRadius*2.5,o*1.2);Math.abs(this.camera.far-c)>1&&(this.camera.far=c,this.camera.updateProjectionMatrix())}groundYUnder(t,e){const i=this.terrainMesh;return i?i.position.y+this.groundYOfPatch(i,t-i.position.x,e-i.position.z):du}groundYOfPatch(t,e,i){const n=t.geometry.getAttribute("position"),s=Math.round(Math.sqrt(n.count));if(s<2||s*s!==n.count)return du;const a=n.getX(0),o=n.getX(s-1),c=n.getZ(0),l=n.getZ((s-1)*s),h=xr((e-a)/(o-a)*(s-1),0,s-1),u=xr((i-c)/(l-c)*(s-1),0,s-1);if(!Number.isFinite(h)||!Number.isFinite(u))return du;const d=Math.min(Math.floor(h),s-2),f=Math.min(Math.floor(u),s-2),p=h-d,v=u-f,m=(b,w)=>n.getY(b*s+w),g=m(f,d),S=m(f,d+1),y=m(f+1,d),M=m(f+1,d+1);return p+v<=1?g+(S-g)*p+(y-g)*v:M+(y-M)*(1-p)+(S-M)*(1-v)}groundUnderFootprint(t,e,i,n,s=0){return ui.groundUnderFootprint(t,e,i,n,(a,o)=>this.groundYUnder(a,o),s)}lookYawDeg=0;lookPitchDeg=0;poseCameraY=1.6;setGait(t){this.gaitOffset=t}gaitOffset={eastM:0,northM:0,upM:0,rollDeg:0,pitchDeg:0,yawDeg:0};setLookOffset(t,e){this.lookYawDeg=t,this.lookPitchDeg=e}indoorLookYawDeg=0;indoorLookPitchDeg=0;setIndoorLook(t,e){this.indoorLookYawDeg=t,this.indoorLookPitchDeg=e}medium;setMedium(t,e,i,n){const s=t&&e!==void 0&&e>0&&i!==void 0&&i>0?{kind:t.kind,iso:n??t.iso,autoExposure:t.autoExposure===!0,exposureSeconds:e,fNumber:i}:void 0;JSON.stringify(s)!==JSON.stringify(this.medium)&&(this.medium=s,this.render())}applyMedium(){const t=this.medium,e=Math.max(this.relativeScale,1e-30);if(!t){Hi.uMedium.value=0;return}Hi.uMedium.value=t.kind==="negative"?1:t.kind==="slide"?2:3;const i=t.autoExposure?this.scatteredSky?.sceneAdaptation:void 0;Hi.uMediumExposure.value=i!==void 0&&i>0?1/(e*i):.065*t.exposureSeconds*t.iso/(t.fNumber*t.fNumber*e)}grain;lampBloomRadiusRad(){if(!this.grain)return;const t=this.camera.fov*Math.PI/180,e=this.grain.frameHeightMm/(2*Math.tan(t/2)),i=Math.max(1,this.renderer.getDrawingBufferSize(this.bloomSize).y);return Math.max(this.grain.detailUm*.001/e,t/i)}bloomSize=new xt;updateDecorLitState(t,e=0){const i=this.lampBloomRadiusRad();for(const n of this.decorObjects){const s=this.decorGroups.get(n.id);if(s&&n.lights?.length&&ui.setLights(s,n.lights,t,s.position.distanceTo(this.camera.position),e,this.relativeScale,i),n.kind!=="streetlight"&&n.kind!=="vehicle")continue;const a=this.decorGroups.get(n.id);if(!a)continue;const o=sv(n,t);ui.setLit(a,n.kind,o,this.relativeScale);const c=this.streetlightLights.get(n.id);c&&(c.visible=o)}}addStreetlightLight(t,e){const i=ui.bodyOf(e),n=i.children.find(a=>a.userData.emissive);if(!n)return;const s=new Qg(16764006,Rm*this.relativeScale,Y5);s.position.copy(n.position).multiply(i.scale),s.castShadow=!0,s.shadow.mapSize.set(512,512),s.shadow.bias=-.002,e.add(s),this.streetlightLights.set(t,s)}setAstronomy(t){(!this.lastAstronomy||Math.abs(this.lastAstronomy.sun.altitudeDeg-t.sun.altitudeDeg)>2)&&(this.surroundings=void 0,this.scatteredSky?.resetSurroundings()),this.lastAstronomy=t,this.scatteredSky?.update(this.scatteredSkyState(t)),this.skyHoldUntilMs===void 0&&this.startHold(),this.pumpScatteredSky(),this.lastSunPosition=t.sun,this.buildSky(t.sun),this.buildGround();const e=this.magnitudeLimitOf(t);this.buildStars(t.stars,e),this.placeBodies(t,e),this.buildIceHalos(t.sun,t.moon),this.buildRainbow(t.sun,t.moon),this.applySkyColours(t),this.syncAnimationLoop(),this.render()}static relativeSkyOf(t,e){const i=a=>{const o=On.luminanceOf(a);if(!(o>0))return[0,0,0];const c=At.relativeOfResponse(o)/o;return[a[0]*c,a[1]*c,a[2]*c]},n=i(t.zenith),s=i(t.horizon);return{zenith:n,horizon:s,airlight:s,skyIrradiance:[n[0]*Math.PI,n[1]*Math.PI,n[2]*Math.PI],scale:e}}placeBodies(t,e){this.bodiesScale=this.relativeScale,this.setBodyMesh("sun",t.sun,uo,new st(1,.96,.88),t.sun.magnitude),this.setMoonMesh(t.moon,e),this.buildPlanets(t.planets,e),this.buildComet(t.comet,e),this.buildNovae(t.novae??[],e)}bodiesScale=0;applySkyColours(t){this.skyColoursStale=!1,this.bodiesScale!==this.relativeScale&&(this.placeBodies(t,this.magnitudeLimitOf(t)),this.applyDazzleStrength(),this.buildIceHalos(t.sun,t.moon),this.buildRainbow(t.sun,t.moon));const e=this.scatteredSky?.ambient??Oe.relativeSkyOf(Ed(t.sun.altitudeDeg),this.relativeScale),i=e,n=this.lightUnderClouds(t),s=a=>n?[0,1,2].map(o=>a[o]*n.through+n.radiance[o]*(1-n.through)):[a[0],a[1],a[2]];this.baseFogColor=[i.horizon[0],i.horizon[1],i.horizon[2]],this.airlight=s(i.airlight),this.skyMesh&&this.skyGradientMaterial&&(this.skyMesh.material=this.scatteredSky?.ready?this.scatteredSky.material:this.skyGradientMaterial),this.updateCelestialLight(t,e),this.updateCloudLighting(t.sun,this.baseFogColor),ae.setEye(this.scatteredSky?.rodShare??0,this.relativeScale),this.updateTwinkle(this.twinkleSeconds);for(const a of this.streetlightLights.values())a.intensity=Rm*this.relativeScale;this.buildSkyGlow(t,i.zenith),this.applyAir(),this.buildLunarDiffraction(t.moon)}reflections;sceneVersion=0;reflectionTimer;buildLunarDiffraction(t){const e=this.scatteredSky?.ready?this.scatteredSky:void 0;if(t.altitudeDeg<-.5||!e){this.lunarDiffraction?.show(void 0),this.lunarDiffractionKey="";return}const i=this.weather.relativeHumidity,n=(i===void 0?Ft.DEFAULT_AEROSOL_OPTICAL_DEPTH:ta.opticalDepth(i))*Ft.aerosolDensity(this.siteElevationM+this.observerElevationM),s=this.cloudTransmission(t),a=-Math.log(Math.max(this.cloudTransmission(t,!0),1e-4)),o=pe.aureoleScale(n,pe.airMass(t.altitudeDeg))*s,c=pe.coronaScale(a),l=pe.illuminanceOf(t.magnitude),h=[t.altitudeDeg.toFixed(1),t.azimuthDeg.toFixed(1),t.magnitude.toFixed(2),o.toExponential(2),c.toExponential(2),Math.log10(Math.max(e.adaptation,1e-12)).toFixed(2)].join(":");if(h===this.lunarDiffractionKey)return;this.lunarDiffractionKey=h,this.lunarDiffraction||(this.lunarDiffraction=new B0,this.celestialGroup.add(this.lunarDiffraction.object));const u=pe.profile(pe.HAZE_COARSE_MODE),d=pe.profile(pe.CLOUD_DROPLETS),f=Xp(t.altitudeDeg),p=new Float32Array(pe.STEPS*3);let v=0;for(let y=0;y<pe.STEPS;y++){const M=y*3,b=[0,1,2].map(T=>l*f[T]*(o*u[M+T]+c*d[M+T])),w=On.shown(b,On.luminanceOf(b),(T,x)=>e.relativeOfLuminance(T,x));p.set(w,M),v=Math.max(v,On.response(w))}const{x:m,y:g,z:S}=hi(t.altitudeDeg,t.azimuthDeg,1);this.lunarDiffraction.show(v>1/200?{x:m,y:g,z:S}:void 0,p)}applyAir(){this.scene.fog instanceof La||(this.scene.fog=new La),this.scene.fog.setAir(this.air,this.siteElevationM,this.airlight)}airlight=[0,0,0];transmittanceTo(t,e,i){const n=this.camera.position;return this.air.transmittance(this.siteElevationM+n.y,this.siteElevationM+e,Math.hypot(t-n.x,e-n.y,i-n.z))}setSiteElevation(t){Math.abs(t-this.siteElevationM)<1||(this.siteElevationM=t,this.applyAir(),this.lastAstronomy&&this.scatteredSky?.update(this.scatteredSkyState(this.lastAstronomy)))}scatteredSkyState(t){return{altitudeM:this.siteElevationM+this.observerElevationM+1.6,lightPollution:this.lightPollution,sun:{altitudeDeg:t.sun.altitudeDeg,azimuthDeg:t.sun.azimuthDeg,magnitude:t.sun.magnitude},moon:{altitudeDeg:t.moon.altitudeDeg,azimuthDeg:t.moon.azimuthDeg,magnitude:t.moon.magnitude,phaseAngleDeg:Mt.phaseAngleOf(t.moon.phase.illuminatedFraction)}}}pumpScatteredSky(){const t=this.scatteredSky;!t||t.tables.ready||this.scatteredSkyFrameId!==null||this.contextReleased||(this.scatteredSkyFrameId=requestAnimationFrame(()=>{this.scatteredSkyFrameId=null,!this.contextReleased&&(t.advance(this.skyHoldUntilMs?K5:$5),this.pumpScatteredSky())}))}cancelScatteredSkyPump(){this.scatteredSkyFrameId!==null&&(cancelAnimationFrame(this.scatteredSkyFrameId),this.scatteredSkyFrameId=null)}setSatellites(t){if(t.length===0&&!this.satelliteField?.count)return;this.satelliteField||(this.satelliteField=new c5(au),this.celestialGroup.add(this.satelliteField.object));const e=this.lastAstronomy?this.magnitudeLimitOf(this.lastAstronomy):Ad(-90,this.instrumentMagnitudeGain);this.satelliteField.set(t,e,i=>this.cloudTransmission(i),(i,n)=>this.arrivingIlluminance(i,n,1)),this.render()}pickSatelliteAt(t,e){if(!this.satelliteField?.count)return;this.aimAtScreenPoint(this.raycaster,t,e);const i=Math.cos(Am*this.camera.fov*Math.PI/180),n=this.satelliteField.nearest(this.raycaster.ray.direction,i);return n&&this.groundHides(t,e)?void 0:n}updateCelestialLight(t,e){const i=this.relativeScale,n=t.sun.altitudeDeg>=Kc,s=!n&&t.moon.altitudeDeg>=Kc,a=n?t.sun:t.moon,o=[0,0,0],c=Math.max(0,Math.sin(Math.max(a.altitudeDeg,0)*qi)),l=n||s?this.cloudTransmission(a):1,h=-Math.log(Math.max(l,1e-6)),u=Math.max(0,1/(1+.1125*h)-l),d=[0,0,0];if(n||s){const S=pe.illuminanceOf(a.magnitude)*i,y=this.air.transmittanceFromSpace(this.siteElevationM+this.observerElevationM,a.altitudeDeg);for(let T=0;T<3;T++)o[T]=S*y[T]*l,d[T]=S*y[T]*u*c,this.cloudBeam[T]=S*y[T];const{x:M,y:b,z:w}=hi(a.altitudeDeg,a.azimuthDeg,1);this.cloudBeamDirection.set(M,b,w)}else this.cloudBeam.fill(0);const f=this.surroundings;if(f)this.skyLight.color.setRGB(f.up[0]*i,f.up[1]*i,f.up[2]*i),this.skyLight.groundColor.setRGB(f.down[0]*i,f.down[1]*i,f.down[2]*i);else{const S=this.skyCloudTransmission(),y=e.skyIrradiance,M=[0,1,2].map(w=>y[w]*S+d[w]);this.skyLight.color.setRGB(M[0],M[1],M[2]);const b=Wt.GROUND_ALBEDO;this.skyLight.groundColor.setRGB(b*(M[0]+o[0]*c),b*(M[1]+o[1]*c),b*(M[2]+o[2]*c))}if(this.skyLight.intensity=1,!n&&!s){this.celestialLight.intensity=0;return}const{x:p,y:v,z:m}=hi(a.altitudeDeg,a.azimuthDeg,1);this.lightDirection.set(p,v,m),this.placeShadowFrustum();const g=Math.max(o[0],o[1],o[2],1e-30);this.celestialLight.color.setRGB(o[0]/g,o[1]/g,o[2]/g),this.celestialLight.intensity=g,this.celestialLight.castShadow=this.decorGroups.size>0||this.bodySystem.any}lightDirection=new R(0,1,0);placeShadowFrustum(){const t=this.lightDirection,e=this.celestialLight.shadow.camera,i=(e.right-e.left)/this.celestialLight.shadow.mapSize.x,n=this.shadowAxisX.crossVectors(this.shadowUp,t);n.lengthSq()<1e-8&&n.set(1,0,0),n.normalize();const s=this.shadowAxisY.crossVectors(t,n).normalize(),a=this.shadowWorld.set(this.bodyOrigin.x,0,this.bodyOrigin.z),o=l=>{const h=a.dot(l)/i;return(h-Math.round(h))*i},c=this.celestialLightTarget.position.set(0,0,0).addScaledVector(n,o(n)).addScaledVector(s,o(s));this.celestialLightTarget.updateMatrixWorld(),this.celestialLight.position.copy(c).addScaledVector(t,this.shadowLightDistanceM)}fitShadowToBodies(){const t=this.bodySystem.reachFrom(this.camera.position),e=Math.min(z5,Math.max(Gs,Math.ceil(t*1.25/20)*20));if(e===this.shadowHalfExtentM)return;this.shadowHalfExtentM=e;const i=this.celestialLight.shadow,n=i.camera;n.left=-e,n.right=e,n.top=e,n.bottom=-e;const s=Math.max(ho,e*(ho/Gs));this.shadowLightDistanceM=Math.max(sn,s+10),n.near=this.shadowLightDistanceM-s,n.far=this.shadowLightDistanceM+s,n.updateProjectionMatrix(),i.bias=-.03/(2*s);const a=e>2*Gs?2048:1024;i.mapSize.x!==a&&(i.mapSize.set(a,a),i.map?.dispose(),i.map=null),this.placeShadowFrustum()}shadowHalfExtentM=Gs;shadowLightDistanceM=sn;shadowUp=new R(0,1,0);shadowAxisX=new R;shadowAxisY=new R;shadowWorld=new R;skyCloudTransmission(){let t=this.cloudTransmission({altitudeDeg:90,azimuthDeg:0}),e=1;for(const i of[20,45,70]){const n=i*qi,s=Math.sin(n)*Math.cos(n)*2;for(let a=0;a<360;a+=60)t+=s*this.cloudTransmission({altitudeDeg:i,azimuthDeg:a}),e+=s}return t/e}cloudBeam=[0,0,0];cloudBeamDirection=new R(0,1,0);get relativeScale(){return this.scatteredSky?.relativeScale??1/At.semiSaturation(At.DAYLIGHT_ANCHOR_CD_M2)}setMeteorShower(t,e,i){this.meteorSystem||(this.meteorSystem=new yi,this.celestialGroup.add(this.meteorSystem.object)),this.meteorSystem.setShower(t,e,i)}get meteorSchedule(){return this.meteorSystem?.schedule??[]}meteorMidpoint(t){return this.meteorSystem?.midpointOf(t)}updateMeteors(t){this.meteorSystem?.update(t)}setInstrument(t){this.projectionKind=t.projection,this.grain=t.detailUm!==void 0&&t.frame?{detailUm:t.detailUm,frameHeightMm:t.frame.heightMm}:void 0;const e=fi.starPointsOf(t),i=fi.flareArtifactsOf(t);e===this.starPoints&&i===this.lensFlareArtifactIntensity||(this.starPoints=e,this.lensFlareArtifactIntensity=i,this.lensFlare&&(this.lensFlare.uniforms.uStarPoints.value=e,this.lensFlare.uniforms.uFlareIntensity.value=i),this.render())}magnitudeLimitOf(t){const e=Mt.starLossMagnitudes(t.sun.altitudeDeg,{phaseAngleDeg:Mt.phaseAngleOf(t.moon.phase.illuminatedFraction),altitudeDeg:t.moon.altitudeDeg},this.lightPollution);return Ad(t.sun.altitudeDeg,this.instrumentMagnitudeGain,e)}setLightPollution(t){t!==this.lightPollution&&(this.lightPollution=t,this.lastAstronomy&&this.scatteredSky?.update(this.scatteredSkyState(this.lastAstronomy)))}setInstrumentGain(t,e=!1){this.instrumentMagnitudeGain=Number.isFinite(t)?t:0,this.scatteredSky?.setInstrument(e,this.instrumentMagnitudeGain)}render(){this.restatingExposure||(this.sceneVersion++,this.frameDirty=!0,this.resolution.noteChange(performance.now()),!(this.animationFrameId!==null||this.framesDriven||this.flushFrameId!==null)&&(this.flushFrameId=requestAnimationFrame(()=>{this.flushFrameId=null,this.drawIfDirty()})))}drawIfDirty(){if(!(!this.frameDirty||this.contextReleased)){if(this.skyColoursStale&&this.lastAstronomy&&this.applySkyColours(this.lastAstronomy),this.compileBeforeNextDraw){this.compileBeforeNextDraw=!1;const t=this.compileOffThread().then(()=>{this.compiling===t&&(this.compiling=void 0,this.render())});this.compiling=t;return}if(!this.compiling){if(this.skyHoldUntilMs){if(!this.sceneSettled()&&performance.now()<this.skyHoldUntilMs){this.firstFrameReady()&&this.refreshReflections(!0);return}this.skyHoldUntilMs=null,this.iceHalos?.setUrgent(!1),this.onFirstFrameHold?.(!1),this.skyColoursStale&&this.lastAstronomy&&this.applySkyColours(this.lastAstronomy)}this.frameDirty=!1,this.refreshReflections(),this.resolution.beginDrawing();try{this.renderOnce(),this.drawn++}finally{this.resolution.endDrawing()}this.developingExposure&&this.startExposure()}}}drawn=0;get framesDrawn(){return this.drawn}compileBeforeNextDraw=!1;compiling;static COMPILE_WAIT_MS=1500;compileOffThread(){const t=this.renderer.compile(this.scene,this.camera);if(!this.renderer.extensions.get("KHR_parallel_shader_compile"))return Promise.resolve();const e=this.renderer.properties,i=performance.now()+Oe.COMPILE_WAIT_MS;return new Promise(n=>{const s=()=>{if(this.contextReleased)return n();for(const a of t){const o=e.get(a)?.currentProgram;(!o||o.isReady())&&t.delete(a)}t.size===0||performance.now()>i?n():setTimeout(s,10)};s()})}compileNextFrameOffThread(){this.compileBeforeNextDraw=!0}contextReleased=!1;releaseContext(){this.contextReleased||(this.contextReleased=!0,this.stopTwinkle(),this.cancelFlush(),this.cancelExposure(),this.compiling=void 0,this.cancelScatteredSkyPump(),this.renderer.forceContextLoss())}restoreContext(){this.contextReleased&&(this.contextReleased=!1,this.renderer.forceContextRestore(),this.scatteredSky?.invalidate(),this.pumpScatteredSky(),this.compileNextFrameOffThread(),this.syncAnimationLoop(),this.render())}cancelFlush(){this.flushFrameId!==null&&(cancelAnimationFrame(this.flushFrameId),this.flushFrameId=null)}frame(t){if(this.animationsRunning){const e=this.lastFrameTimeMs===void 0?0:t-this.lastFrameTimeMs;this.lastFrameTimeMs=t,this.hasAnimations()&&this.animate(t,e);const i=this.resolution.ratioFor(t,e);i!==this.renderer.getPixelRatio()&&this.applyPixelRatio(i)}this.drawIfDirty()}refreshReflections(t=!1){this.reflections??=new on(this.renderer);const e=[...this.compassSprites,...this.lensFlare?[this.lensFlare.mesh]:[],...[...this.glareSprites.values()].map(o=>o.mesh)],i=[...this.starTiers.map(o=>o.points),...[...this.bodyMeshes.values()].filter(o=>o instanceof xs),...[this.rainSystem?.points,this.precipitationPoints,this.rainSplashSystem?.points].filter(o=>o!==void 0)],n=this.relativeScale,s=this.sceneVersion,a=this.reflections.refresh(this.renderer,this.scene,this.camera.position,this.bodySystem.reflectors,e,[...this.decorGroups.values()],s,i,o=>this.measureSurroundings(o,n,s),t?0:on.REFRESH_MS);a===void 0||this.reflectionTimer||(this.reflectionTimer=setTimeout(()=>{this.reflectionTimer=void 0,this.frameDirty=!0,!(this.animationFrameId!==null||this.framesDriven||this.flushFrameId!==null)&&(this.flushFrameId=requestAnimationFrame(()=>{this.flushFrameId=null,this.drawIfDirty()}))},a))}measureSurroundings(t,e,i){const n=this.lastAstronomy;if(!n)return;this.probeIrradiance??=new Ro;const s=[n.sun,n.moon].filter(a=>a.altitudeDeg>-2).map(a=>hi(a.altitudeDeg,a.azimuthDeg,1));this.probeIrradiance.measure(this.renderer,t,s,a=>{const o=f=>f.map(p=>p/e),c=this.surroundings,l={up:o(a.up),down:o(a.down)},h=(f,p)=>f.some((v,m)=>Math.abs(v-p[m])>.03*Math.max(Math.abs(v),Math.abs(p[m]),1e-12)),u=!c||h(c.up,l.up)||h(c.down,l.down);u&&(this.surroundings=l),this.eyeSettledVersion=-1;const d=this.scatteredSky?.adaptToSurroundings(Math.exp(a.logAverage)/e)??!1;if(!u&&!d){this.eyeSettledVersion=i,this.skyHoldUntilMs&&this.redrawHeld();return}this.skyColoursStale=!0,this.render()})}lightUnderClouds(t){const e=this.surroundings;if(!e)return;const i=t.sun.altitudeDeg>=Kc?t.sun:t.moon.altitudeDeg>=Kc?t.moon:void 0;if(!i)return;const n=this.relativeScale/Math.PI;return{through:this.cloudTransmission(i),radiance:[e.up[0]*n,e.up[1]*n,e.up[2]*n]}}probeIrradiance;surroundings;animate(t,e){const i=Math.min(e/1e3,gE);this.twinkleSeconds=t/1e3,this.updateTwinkle(this.twinkleSeconds),this.updatePrecipitation(t/1e3,i),this.updateRain(i),this.lensFlare&&(this.lensFlare.uniforms.uTime.value=t/1e3),this.developingExposure||(this.frameDirty=!0)}setMaxPixelRatio(t){this.resolution.maximum=t,this.renderer.getPixelRatio()>this.resolution.maximum&&this.applyPixelRatio(this.resolution.maximum)}applyPixelRatio(t){this.renderer.setPixelRatio(t),this.renderer.setSize(this.cssSize.width,this.cssSize.height,!1),this.frameDirty=!0}setExposure(t,e){const i=e?Math.max(1,Math.round(t)):1;if(i===this.exposureInstants&&(i===1||e===this.exposureInstantAt)){this.exposureInstantAt=e;return}this.exposureInstants=i,this.exposureInstantAt=e,i===1&&(this.cancelExposure(),this.exposureAccumulation?.dispose(),this.exposureAccumulation=void 0),this.render()}renderOnce(t){if(this.onMapSubjectBounds){const a=this.mapSubjectBounds();t?this.exposureSubjectBounds.push(...a):this.onMapSubjectBounds(a)}const e=this.usableEquidistantPass();this.phenomena.setCloudLayers(this.layeredClouds?.volumes??[]),this.phenomena.place(this.camera,(a,o,c)=>this.directionAtScreenPoint(a,o,c),a=>this.screenPointOf(a)),this.references.place(this.camera);const i=Math.max(this.phenomena.furthestM,this.references.furthestM)*1.2;i>this.camera.far&&(this.camera.far=i,this.camera.updateProjectionMatrix()),Hi.uRodShare.value=this.scatteredSky?.rodShare??0,Hi.uRelativeScale.value=this.relativeScale,this.applyMedium();const n=this.references.any||this.phenomena.any||this.compassSprites.some(a=>a.visible);Hi.uHasOverlay.value=n?1:0;const s=n?a=>this.renderOverlayPasses(a):void 0;if(this.skyGlow?.setDestinationEncoded(!1),!e){this.updateLensFlarePosition();const a=this.usableDepthOfFieldPass();a?a.render(this.renderer,this.scene,this.camera,s,t):this.usableFinishPass().render(this.renderer,this.scene,this.camera,s,void 0,t);return}e.render(this.renderer,this.scene,this.camera,this.camera.fov,()=>this.updateLensFlarePosition(),s,a=>{this.lensFlare&&(this.lensFlare.mesh.visible=a?!1:this.sunVisible)},()=>this.renderDazzleOnResample(),t)}renderOverlayPasses(t=this.camera){this.renderReferencesPass(t),this.renderPhenomenaPass(t),this.renderHudPass(t)}renderHudPass(t){if(!this.compassSprites.some(n=>n.visible))return;const e=this.renderer.autoClear,i=this.renderer.shadowMap.autoUpdate;this.renderer.autoClear=!1,this.renderer.shadowMap.autoUpdate=!1,t.layers.set(bm),this.renderer.render(this.scene,t),t.layers.set(0),this.renderer.autoClear=e,this.renderer.shadowMap.autoUpdate=i}renderReferencesPass(t){if(!this.references.any)return;const e=this.renderer.autoClear,i=this.renderer.shadowMap.autoUpdate;this.renderer.autoClear=!1,this.renderer.shadowMap.autoUpdate=!1,t.layers.set(W1),this.renderer.render(this.scene,t),t.layers.set(0),this.renderer.autoClear=e,this.renderer.shadowMap.autoUpdate=i}setReferences(t,e){this.references.set(t.map(i=>{const n=this.documentRelative(i.src);return n===i.src?i:{...i,src:n}}),void 0,e)}referenceAspect(t){return this.references.aspectOf(t)}directionAt(t,e){return this.directionAtScreenPoint(t,e,new R)}referenceFailedToLoad(t){return this.references.failedToLoad(this.documentRelative(t))}setReferencesShown(t){this.references.setShown(t),this.render()}setReferenceView(t,e){this.references.setView(t,e),this.render()}renderPhenomenaPass(t){if(!this.phenomena.any)return;const e=this.renderer.autoClear,i=this.renderer.shadowMap.autoUpdate;this.renderer.autoClear=!1,this.renderer.shadowMap.autoUpdate=!1,this.renderer.clearDepth();for(const n of this.decorObjects){const s=this.decorGroups.get(n.id);s&&Oe.markDecorDepth(s,n.kind!=="crop")}t.layers.set(nu),this.scene.overrideMaterial=this.decorDepthMaterial,this.renderer.render(this.scene,t),this.scene.overrideMaterial=null,t.layers.set(V1),this.renderer.render(this.scene,t),t.layers.set(0),this.renderer.autoClear=e,this.renderer.shadowMap.autoUpdate=i}decorDepthMaterial=new _n({colorWrite:!1});static markDecorDepth(t,e){t.traverse(i=>{if(!(i instanceof Dt))return;const n=Array.isArray(i.material)?i.material[0]:i.material;e&&n.depthWrite!==!1&&n.blending!==Ni?i.layers.enable(nu):i.layers.disable(nu)})}startExposure(){this.cancelExposure(),this.exposureSubjectBounds=[];const t=this.renderer.getDrawingBufferSize(new xt),e=Math.max(1,Math.round(t.x)),i=Math.max(1,Math.round(t.y));this.exposureAccumulation||(this.exposureAccumulation=new Tb(e,i)),this.exposureAccumulation.resize(e,i),this.exposureAccumulation.open(this.renderer),this.exposureInstantsDone=0,this.exposureFrameId=requestAnimationFrame(()=>this.developExposure())}developExposure(){this.exposureFrameId=null;const t=this.exposureInstantAt,e=this.exposureAccumulation;if(!t||!e)return;const i=1/this.exposureInstants;this.resolution.beginDrawing();const n=performance.now()+Oe.EXPOSURE_BUDGET_MS,s=Oe.exposureInstantsPerFrame(e.instantTarget.scene.width*e.instantTarget.scene.height);let a=0;do{this.restateAt(t,this.exposureInstantsDone);const o=this.compassSprites.map(c=>c.visible);for(const c of this.compassSprites)c.visible=!1;try{this.renderOnce(e.instantTarget)}finally{this.compassSprites.forEach((c,l)=>{c.visible=o[l]})}e.add(this.renderer,i),this.exposureInstantsDone++,a++}while(this.exposureInstantsDone<this.exposureInstants&&performance.now()<n&&a<s);this.restateAt(t,0),this.presentExposure(),this.resolution.endDrawing(),this.exposureInstantsDone<this.exposureInstants&&(this.exposureFrameId=requestAnimationFrame(()=>this.developExposure()))}presentExposure(){if(Hi.uRodShare.value=this.scatteredSky?.rodShare??0,Hi.uHasOverlay.value=1,Hi.uRelativeScale.value=this.relativeScale,this.applyMedium(),this.exposureAccumulation?.develop(this.renderer,this.exposureInstants/this.exposureInstantsDone),this.onMapSubjectBounds?.(this.exposureSubjectBounds),!this.compassSprites.some(s=>s.visible))return;const t=new Ts,e=new Un(-1,1,1,-1,0,2),i=Zc/(Im*Math.tan(Cm*qi/2));for(const s of this.compassSprites){if(!s.visible)continue;const a=s.getWorldPosition(new R).sub(this.camera.position).normalize(),o=this.screenPointOf(a);if(!o)continue;const c=new jr(s.material);c.position.set(o.ndcX,o.ndcY,-1),c.scale.set(i/this.camera.aspect,i,1),t.add(c)}const n=this.renderer.autoClear;this.renderer.autoClear=!1;try{this.renderer.render(t,e)}finally{this.renderer.autoClear=n}}onMapSubjectBounds;exposureSubjectBounds=[];static MAP_SUBJECT_NEAREST_M=8;mapSubjectBounds(){const t=[],e=new Vi,i=new R,n=this.camera.getWorldDirection(new R),s=this.decorObjects.filter(o=>o.track?.length||o.kind==="aircraft"||o.kind==="vehicle").map(o=>this.decorGroups.get(o.id)),a=this.bodySystem.reflectors.map(o=>o.holder);for(const o of[...s,...a]){if(!o?.visible||(e.setFromObject(o),e.isEmpty())||e.distanceToPoint(this.camera.position)<Oe.MAP_SUBJECT_NEAREST_M)continue;let c=1/0,l=-1/0,h=1/0,u=-1/0;for(const d of[e.min.x,e.max.x])for(const f of[e.min.y,e.max.y])for(const p of[e.min.z,e.max.z]){if(i.set(d,f,p).sub(this.camera.position).normalize(),i.dot(n)<=0)continue;const v=this.screenPointOf(i);if(!v)continue;const m=(v.ndcX+1)/2,g=(1-v.ndcY)/2;c=Math.min(c,m),l=Math.max(l,m),h=Math.min(h,g),u=Math.max(u,g)}c=Math.max(c,0),l=Math.min(l,1),h=Math.max(h,0),u=Math.min(u,1),l>=c&&u>=h&&t.push({x:c,y:h,width:l-c,height:u-h})}return t}restateAt(t,e){this.restatingExposure=!0;try{t(e)}finally{this.restatingExposure=!1}}cancelExposure(){this.exposureFrameId!==null&&(cancelAnimationFrame(this.exposureFrameId),this.exposureFrameId=null)}setLensOptics(t){const e=this.lensOptics;this.lensOptics=t,(e===void 0!=(t===void 0)||e&&t&&(e.focalLengthMm!==t.focalLengthMm||e.fNumber!==t.fNumber||e.focusDistance!==t.focusDistance||e.frameHeightMm!==t.frameHeightMm))&&(t&&this.depthOfFieldPass&&this.depthOfFieldPass.setLens(t.focalLengthMm,t.fNumber,t.focusDistance,t.frameHeightMm),this.render())}usableDepthOfFieldPass(){const t=this.lensOptics;if(!t)return;const e=this.renderer.getDrawingBufferSize(new xt),i=Math.max(1,Math.round(e.x)),n=Math.max(1,Math.round(e.y));return this.depthOfFieldPass||(this.depthOfFieldPass=new Do(i,n)),this.depthOfFieldPass.resize(i,n),this.depthOfFieldPass.setLens(t.focalLengthMm,t.fNumber,t.focusDistance,t.frameHeightMm),this.depthOfFieldPass}usableFinishPass(){const t=this.renderer.getDrawingBufferSize(new xt);return this.finishPass?this.finishPass.resize(t.x,t.y):this.finishPass=new z0(t.x,t.y),this.finishPass}usableEquidistantPass(){if(this.projectionKind!=="equidistant")return;const t=this.renderer.getDrawingBufferSize(new xt);return this.equidistantPass?this.equidistantPass.resize(t.x,t.y):this.equidistantPass=new We(t.x,t.y),this.equidistantPass}aimAtScreenPoint(t,e,i){const n=this.projectionKind==="equidistant"?this.equidistantPass:void 0;if(!n){t.setFromCamera(new xt(e,i),this.camera);return}const s=n.directionFor(e,i,this.camera.fov);this.camera.updateMatrixWorld(),t.ray.origin.setFromMatrixPosition(this.camera.matrixWorld),t.ray.direction.set(s.x,s.y,s.z).applyQuaternion(this.camera.quaternion).normalize(),t.camera=this.camera}pickCloudAt(t,e){return this.layeredClouds?.pickInstance(this.cloudDirectionAt(t,e))}cloudDirectionAt(t,e){return this.directionAtScreenPoint(t,e,new R)}directionAtScreenPoint(t,e,i){return this.aimAtScreenPoint(this.ufoOcclusionRaycaster,t,e),i.copy(this.ufoOcclusionRaycaster.ray.direction)}screenPointOf(t){this.camera.updateMatrixWorld();const e=this.screenPointScratch.copy(t).applyQuaternion(this.screenPointQuaternion.copy(this.camera.quaternion).invert()),i=this.renderer.getDrawingBufferSize(this.screenPointSize),n=i.x/Math.max(i.y,1);if(this.projectionKind==="equidistant"&&this.equidistantPass)return We.ndcFor(e,this.camera.fov,n);if(e.z>=0)return;const s=Math.tan(this.camera.fov/2*qi);return{ndcX:e.x/-e.z/(n*s),ndcY:e.y/-e.z/s}}screenPointScratch=new R;screenPointQuaternion=new Qi;screenPointSize=new xt;updateLensFlarePosition(){const t=this.lensFlare;if(!t)return;if(!this.sunVisible){t.mesh.visible=!1;return}if(this.camera.updateMatrixWorld(),this.lensFlareScratch.copy(this.sunWorldPosition).applyMatrix4(this.camera.matrixWorldInverse),this.lensFlareScratch.z>0){t.mesh.visible=!1;return}const e=this.sunVisibleFraction();if(e<=0){t.mesh.visible=!1;return}t.mesh.visible=!0,this.sunUnhiddenFraction=e,this.applyDazzleStrength();const i=this.lensFlareScratch.copy(this.sunWorldPosition).project(this.camera);t.uniforms.uLensPosition.value.set(i.x,i.y);const n=this.renderer.domElement.width,s=this.renderer.domElement.height;t.uniforms.uResolution.value.set(n,s),t.uniforms.uTanHalfFov.value=Math.tan(this.camera.fov*Math.PI/360)}renderDazzleOnResample(){const t=this.lensFlare;if(!t||!this.sunVisible)return;const e=this.sunVisibleFraction();if(e<=0)return;this.sunUnhiddenFraction=e,this.applyDazzleStrength();const i=this.screenPointOf(this.lensFlareScratch.copy(this.sunWorldPosition).sub(this.camera.position).normalize());if(!i)return;const n=this.renderer.getDrawingBufferSize(this.screenPointSize);t.uniforms.uLensPosition.value.set(i.ndcX,i.ndcY),t.uniforms.uResolution.value.set(n.x,n.y),t.uniforms.uEquidistant.value=1,t.uniforms.uHalfFovRad.value=this.camera.fov*Math.PI/360;const s=this.renderer.autoClear;this.renderer.autoClear=!1,t.mesh.visible=!0,t.mesh.layers.enable(Sm),this.camera.layers.set(Sm),this.renderer.render(this.scene,this.camera),this.camera.layers.set(0),t.mesh.visible=!1,t.uniforms.uEquidistant.value=0,this.renderer.autoClear=s}sunVisibleFraction(){this.raycastableDecor().length>0&&this.scene.updateMatrixWorld();let t=0;for(const e of Lm)this.isSunOccluded(e[0],e[1])||t++;return t/Lm.length}raycastableDecor(){const t=[];for(const e of this.decorObjects){if(e.kind==="crop")continue;const i=this.decorGroups.get(e.id);i&&t.push(i)}return t}isSunOccluded(t=0,e=0){const i=this.raycastableDecor();if(!this.groundMesh&&!this.terrainMesh&&i.length===0)return!1;const n=this.sunOcclusionDirectionScratch.copy(this.sunWorldPosition).sub(this.camera.position),s=n.length();if(n.normalize(),t!==0||e!==0){const o=Math.PI/180,c=this.sunOcclusionRightScratch.set(n.z,0,-n.x);c.lengthSq()<1e-9&&c.set(1,0,0),c.normalize();const l=this.sunOcclusionUpScratch.crossVectors(c,n).normalize();n.addScaledVector(c,t*o).addScaledVector(l,e*o).normalize()}if(this.groundBlocks(this.camera.position,n,s))return!0;if(i.length===0)return!1;this.sunOcclusionRaycaster.set(this.camera.position,n);const a=this.sunOcclusionRaycaster.intersectObjects(i,!0)[0];return a!==void 0&&a.distance<s}groundBlocks(t,e,i,n=0){const s=this.groundMesh;if(s&&e.y<0){const m=(s.position.y-t.y)/e.y;if(m>n&&m<i){const g=t.x+e.x*m-s.position.x,S=t.z+e.z*m-s.position.z;if(Math.hypot(g,S)<=this.groundRadius)return!0}}const a=this.terrainMesh;if(!a)return!1;const o=a.geometry.getAttribute("position"),c=Math.round(Math.sqrt(o.count));if(c<2||c*c!==o.count)return!1;const l=[a.position.x+o.getX(0),a.position.x+o.getX(c-1)],h=[a.position.z+o.getZ(0),a.position.z+o.getZ((c-1)*c)],u=Math.min(Math.abs(l[1]-l[0]),Math.abs(h[1]-h[0]))/(c-1);if(!(u>0))return!1;let d=n,f=i;for(const[m,g,S]of[[t.x,e.x,l],[t.z,e.z,h]]){const y=Math.min(S[0],S[1]),M=Math.max(S[0],S[1]);if(Math.abs(g)<1e-12){if(m<y||m>M)return!1;continue}const b=(y-m)/g,w=(M-m)/g;d=Math.max(d,Math.min(b,w)),f=Math.min(f,Math.max(b,w))}if(!(f>d))return!1;const p=Math.hypot(e.x,e.z),v=Math.min(4096,Math.max(8,Math.ceil((f-d)*p/(u/2))));for(let m=0;m<=v;m++){const g=d+(f-d)*m/v,S=t.x+e.x*g,y=t.y+e.y*g,M=t.z+e.z*g;if(y<=this.groundYUnder(S,M))return!0}return!1}setPhenomena(t,e){this.phenomena.set(t,e)}decorDistancesAt(t,e,i){this.aimAtScreenPoint(this.ufoOcclusionRaycaster,t,e),this.ufoOcclusionRaycaster.near=wm;let n,s;for(const a of this.decorObjects){if(a.kind==="crop")continue;const o=this.decorGroups.get(a.id);if(!o)continue;const c=this.ufoOcclusionRaycaster.intersectObject(o,!0)[0];c&&(a.occludesSourceIds?.includes(i)?n=n===void 0?c.distance:Math.max(n,c.distance):s=s===void 0?c.distance:Math.min(s,c.distance))}return{behindM:n,inFrontM:s}}pickBodyAt(t,e){this.aimAtScreenPoint(this.raycaster,t,e);const i=[...this.hitAreas.entries()],n=this.raycaster.intersectObjects(i.map(([,s])=>s))[0];if(n&&!this.groundHides(t,e))return i.find(([,s])=>s===n.object)?.[0]}pickStarAt(t,e){if(this.namedStars.length===0)return;this.aimAtScreenPoint(this.raycaster,t,e);const i=this.raycaster.ray.direction,n=Math.cos(Am*this.camera.fov*Math.PI/180);let s,a=n;for(const o of this.namedStars){const c=o.direction.dot(i);c>a&&(a=c,s={star:o.star,altitudeDeg:o.altitudeDeg})}return s&&this.groundHides(t,e)?void 0:s}groundHides(t,e){if(!this.terrainMesh&&!this.groundMesh)return!1;this.aimAtScreenPoint(this.ufoOcclusionRaycaster,t,e);const i=this.ufoOcclusionRaycaster.ray;return this.groundBlocks(i.origin,i.direction,1/0,wm)}bodyScreenBox(t){const e=this.bodySystem.boxOf(t,this.bodyBoxScratch);if(!e)return;let i=1/0,n=1/0,s=-1/0,a=-1/0;for(let o=0;o<8;o++){const c=this.bodyCornerScratch.set(o&1?e.max.x:e.min.x,o&2?e.max.y:e.min.y,o&4?e.max.z:e.min.z),l=this.screenPointOf(c.sub(this.camera.position).normalize());if(!l)return;i=Math.min(i,l.ndcX),s=Math.max(s,l.ndcX),n=Math.min(n,l.ndcY),a=Math.max(a,l.ndcY)}return{minX:i,minY:n,maxX:s,maxY:a}}bodyBoxScratch=new Vi;bodyCornerScratch=new R;pickPlacedBodyAt(t,e){return this.aimAtScreenPoint(this.raycaster,t,e),this.bodySystem.pick(this.raycaster)}pickDecorAt(t,e){this.aimAtScreenPoint(this.raycaster,t,e);const i=[...this.decorGroups.entries()],n=this.raycaster.intersectObjects(i.map(([,a])=>a),!0)[0];if(!n)return;let s=n.object;for(;s&&!i.some(([,a])=>a===s);)s=s.parent;return i.find(([,a])=>a===s)?.[0]}dispose(){this.stopTerrainFade(),this.stopTwinkle(),this.cancelFlush(),this.phenomena.clear(),this.references.disposeAll(),this.terrainBuildToken++,this.cancelScatteredSkyPump(),this.skyMesh&&this.skyGradientMaterial&&(this.skyMesh.material=this.skyGradientMaterial),this.scatteredSky?.dispose(),this.scatteredSky=void 0,this.disposeMesh(this.skyMesh),this.disposeMesh(this.groundMesh),this.disposeMesh(this.terrainMesh),this.roadSystem.dispose(),this.disposeCloudSystem(),this.disposeCirrus(),this.disposePrecipitationPoints(),this.disposeRain(),this.disposeStarTiers(),this.meteorSystem?.dispose(),this.meteorSystem=void 0,this.iceHalos?.dispose(),this.iceHalos=void 0,this.rainbow?.dispose(),this.rainbow=void 0,this.skyGlow?.dispose(),this.skyGlow=void 0,this.depthOfFieldPass?.dispose(),this.finishPass?.dispose(),this.depthOfFieldPass=void 0,this.cancelExposure(),this.exposureAccumulation?.dispose(),this.exposureAccumulation=void 0,this.cometTail?.dispose(),this.cometTail=void 0,this.satelliteField?.dispose(),this.satelliteField=void 0,this.lightningBolt?.dispose(),this.lightningBolt=void 0;for(const t of this.bodyMeshes.values())this.disposeMesh(t);this.bodyMeshes.clear(),this.novaKeys.clear();for(const t of[...this.hitAreas.keys()])this.disposeHitArea(t);for(const t of[...this.glareSprites.keys()])this.disposeGlare(t);this.disposeCompassLabels();for(const t of this.decorGroups.values())ui.dispose(t);this.decorGroups.clear(),this.streetlightLights.clear(),this.lensFlare&&(this.lensFlare.mesh.removeFromParent(),this.lensFlare.mesh.geometry.dispose(),this.lensFlare.mesh.material.dispose(),this.lensFlare=void 0),this.renderer.dispose()}animationsRunning=!1;startTwinkle(){if(this.animationFrameId!==null||!this.needsAnimationLoop())return;this.cancelFlush();const t=e=>{this.frame(e),this.animationFrameId=requestAnimationFrame(t)};this.animationFrameId=requestAnimationFrame(t)}setAnimationsRunning(t,e=!1){const i=t&&e;if(t===this.animationsRunning&&i===this.framesDriven)return;const n=this.animationsRunning;this.animationsRunning=t,this.framesDriven=i,t&&!n&&(this.lastFrameTimeMs=void 0,this.resolution.reset());const s=!t&&this.renderer.getPixelRatio()!==this.resolution.maximum;s&&this.applyPixelRatio(this.resolution.maximum),this.syncAnimationLoop(),(!t||this.frameDirty)&&this.render(),s&&this.drawIfDirty()}stopTwinkle(){this.animationFrameId!==null&&(cancelAnimationFrame(this.animationFrameId),this.animationFrameId=null)}needsAnimationLoop(){return this.animationsRunning&&!this.framesDriven&&this.hasAnimations()}hasAnimations(){return this.starTiers.length>0||this.precipitationPoints!==void 0||this.rainSystem!==void 0||this.lensFlare!==void 0&&this.sunVisible}syncAnimationLoop(){this.needsAnimationLoop()?this.startTwinkle():this.stopTwinkle()}buildSky(t){const e=this.skyMesh?.geometry??new oi(qc,32,16),i=e.attributes.position,n=e.getAttribute("color")??new de(new Float32Array(i.count*3),3);for(let a=0;a<i.count;a++){const{altitudeDeg:o,azimuthDeg:c}=Ib(i.getX(a),i.getY(a),i.getZ(a)),l=kb(o,c,t.azimuthDeg,t.altitudeDeg);n.setXYZ(a,l[0],l[1],l[2])}if(n.needsUpdate=!0,this.skyMesh)return;e.setAttribute("color",n);const s=new _n({vertexColors:!0,side:Ve,fog:!1,depthWrite:!1});this.skyGradientMaterial=s,this.skyMesh=new Dt(e,s),this.skyMesh.renderOrder=-1,this.celestialGroup.add(this.skyMesh)}buildGround(){const t=Em(this.observerElevationM);if(this.groundMesh&&t===this.groundRadius)return;this.disposeMesh(this.groundMesh),this.groundRadius=t;const e=new M0(this.groundRadius,48),i=new zr({color:new st(su,su,su),fog:!0});La.fadeRim(i,this.groundRadius*.75,this.groundRadius),this.groundMesh=new Dt(e,i),this.groundMesh.rotation.x=-Math.PI/2,this.groundMesh.position.y=0,this.groundMesh.receiveShadow=!0,this.scene.add(this.groundMesh),this.applyGroundDepthWrite()}applyGroundDepthWrite(){const t=this.groundMesh?.material;if(!t)return;const e=this.terrainMesh===void 0;t.depthWrite!==e&&(t.depthWrite=e,t.needsUpdate=!0)}cloudTransmission(t,e=!1){const i=`${t.altitudeDeg.toFixed(1)}:${t.azimuthDeg.toFixed(1)}:${Math.round(this.cloudOffsetM.x/10)}:${Math.round(this.cloudOffsetM.z/10)}:${Math.round(this.observerElevationM)}:`+Object.entries(this.cloudLayerOffsetsM).map(([a,o])=>`${a}=${Math.round(o.x/10)},${Math.round(o.z/10)}`).join(";")+(e?":water":""),n=this.cloudTransmissionMemo.get(i);if(n!==void 0)return n;this.cloudTransmissionMemo.size>256&&this.cloudTransmissionMemo.clear();const s=this.computeCloudTransmission(t,e);return this.cloudTransmissionMemo.set(i,s),s}cloudTransmissionMemo=new Map;computeCloudTransmission(t,e=!1){const i=hi(t.altitudeDeg,t.azimuthDeg,1);if(this.layeredClouds)return this.layeredClouds.transmissionAt(i,e);let n=1;const s=this.lowerCloudCover();s>0&&(n*=1-ge.alphaAt(i,Math.abs(this.cloudLayerOffset()),s,this.cloudFieldOffset)*W5);const a=e?0:this.weather.highCloudCover??0;return a>0&&(n*=1-ge.iceAlphaAt(i,$c,a,this.cloudFieldOffset)*X5),Math.max(0,Math.min(1,n))}setBodyMesh(t,e,i,n,s){if(e.altitudeDeg<Kd){this.disposeMesh(this.bodyMeshes.get(t)),this.bodyMeshes.delete(t),this.disposeHitArea(t),this.disposeGlare(t),t==="sun"&&(this.sunVisible=!1);return}const{x:a,y:o,z:c}=hi(e.altitudeDeg,e.azimuthDeg,sn),l=Xp(e.altitudeDeg),h=this.cloudTransmission(e),u=this.arrivingIlluminance(e,s,h),d=Oe.unitLuminance(n);let f=this.bodyMeshes.get(t);if(t==="sun"){const p=Math.PI*(i/sn)**2,v=[0,1,2].map(m=>Math.min(Oe.BRIGHTEST_RELATIVE,d[m]*u[m]/p));f instanceof Dt||(this.disposeMesh(f),f=new Dt(new oi(1,16,16),new _n({fog:!1})),this.celestialGroup.add(f),this.bodyMeshes.set(t,f)),f.material.color.setRGB(v[0],v[1],v[2]),f.scale.setScalar(i)}else{if(!(f instanceof xs)){this.disposeMesh(f);const m=new ce;m.setAttribute("position",new ie(new Float32Array(3),3)),m.setAttribute("color",new ie(new Float32Array(3),3)),f=new xs(m,ae.material(To[To.length-1].size,!1)),ae.track(f),this.celestialGroup.add(f),this.bodyMeshes.set(t,f)}const p=f.geometry.getAttribute("color"),v=t.startsWith("comet:")?this.pointToPixel():1;p.setXYZ(0,d[0]*u[0]*v,d[1]*u[1]*v,d[2]*u[2]*v),p.needsUpdate=!0}if(f.position.set(a,o,c),this.setHitArea(t,a,o,c,i),t==="sun"&&(this.sunArriving=u),t.startsWith("comet:")?this.disposeGlare(t):t!=="sun"&&this.setGlare(t,a,o,c,u,i/sn*(180/Math.PI),Oe.POINT_VEIL_HOLD_DEG),t==="sun"){this.sunVisible=!0;const p=this.celestialGroup.scale.x;this.sunWorldPosition.set(a*p,o*p+this.celestialGroup.position.y,c*p),this.lensFlare||(this.lensFlare=o5(),this.lensFlare.uniforms.uOpacity.value=tE,this.lensFlare.uniforms.uFlareIntensity.value=this.lensFlareArtifactIntensity,this.lensFlare.uniforms.uStarPoints.value=this.starPoints,this.scene.add(this.lensFlare.mesh)),this.applyLensFlareTint(l)}}setMoonMesh(t,e){const i="moon";if(t.magnitude>e||t.altitudeDeg<Kd){this.disposeMesh(this.bodyMeshes.get(i)),this.bodyMeshes.delete(i),this.disposeHitArea(i),this.disposeGlare(i);return}const{x:n,y:s,z:a}=hi(t.altitudeDeg,t.azimuthDeg,sn),o=this.cloudTransmission(t),c=this.arrivingIlluminance(t,t.magnitude,o),l=Math.max(xr(t.phase.illuminatedFraction,0,1),.01)*Math.PI*(uo/sn)**2,h=new st(...c.map(f=>Math.min(Oe.BRIGHTEST_RELATIVE,f/l))),u=`${t.phase.phaseFraction<.5}:${Math.round(xr(t.phase.illuminatedFraction,0,1)*500)}`;let d=this.bodyMeshes.get(i);if(d instanceof jr)d.userData.phaseKey!==u&&(d.material.map?.dispose(),d.material.map=Zm(t.phase),d.userData.phaseKey=u),d.material.color.copy(h);else{this.disposeMesh(d),d=new jr(new ol({map:Zm(t.phase),color:h,fog:!1})),d.userData.phaseKey=u;const f=uo*2;d.scale.set(f,f,1),this.celestialGroup.add(d),this.bodyMeshes.set(i,d)}d.position.set(n,s,a),this.setHitArea(i,n,s,a,uo),this.setGlare(i,n,s,a,c,uo/sn*(180/Math.PI))}bentLight(t,e,i=G5){const[n,s,a]=this.arrivingIlluminance(t,e,1),o=Math.max(s,1e-30);return{scale:s/i,tint:[n/o,1,a/o]}}static litBySky(t,e){return Oe.litScratch.setRGB(t.r*e[0],t.g*e[1],t.b*e[2])}static litScratch=new st;pointToPixel(){const t=Math.max(1,this.renderer.getDrawingBufferSize(this.pointScratch).y),e=(this.camera.fov*Math.PI/180/t)**2;return Math.min(1,ae.CONE_SOLID_ANGLE/e)}pointScratch=new xt;static POINT_VEIL_HOLD_DEG=.25;static BRIGHTEST_RELATIVE=6e4;arrivingIlluminance(t,e,i){const n=this.air.transmittanceFromSpace(this.siteElevationM+this.observerElevationM,t.altitudeDeg),s=pe.illuminanceOf(e)*i*this.relativeScale;return[n[0]*s,n[1]*s,n[2]*s]}static unitLuminance(t){const e=On.luminanceOf([t.r,t.g,t.b]);return e>0?[t.r/e,t.g/e,t.b/e]:[1,1,1]}setHitArea(t,e,i,n,s){let a=this.hitAreas.get(t);if(!a){const c=new ol({transparent:!0,opacity:0,depthTest:!1,depthWrite:!1,fog:!1});a=new jr(c),this.celestialGroup.add(a),this.hitAreas.set(t,a)}a.position.set(e,i,n);const o=s*H5;a.scale.set(o,o,1)}disposeHitArea(t){const e=this.hitAreas.get(t);e&&(e.removeFromParent(),e.material.dispose(),this.hitAreas.delete(t))}setGlare(t,e,i,n,s,a,o=0){if(Pi.radiusDeg(Pi.K*Math.max(...s))<=Math.max(a,o)){this.disposeGlare(t);return}let c=this.glareSprites.get(t);c||(c=new Pi(`veil:${t}`),this.celestialGroup.add(c.mesh),this.glareSprites.set(t,c)),c.shine({x:e,y:i,z:n},s,a,o)}disposeGlare(t){const e=this.glareSprites.get(t);e&&(e.mesh.removeFromParent(),e.dispose(),this.glareSprites.delete(t))}buildComet(t,e){const i=t&&`comet:${t.id}`;if(!t||!i||t.magnitude>e){this.disposeComet();return}this.cometKey&&this.cometKey!==i&&this.disposeComet();const n=Mo(t.magnitude,e),s=Xh(n);this.cometKey=i,this.setBodyMesh(i,t.position,ru*(.5+.5*n),new st(s,s,s),t.magnitude),this.cometTail||(this.cometTail=new rn(sn),this.celestialGroup.add(this.cometTail.object)),this.cometTail.set(t.position,t.tailEnd,n)}buildIceHalos(t,e){this.iceHalos||(this.iceHalos=new Ci,this.iceHalos.setCloudOffset(this.cloudFieldOffset),this.iceHalos.onReady=()=>this.render(),this.celestialGroup.add(this.iceHalos.object)),this.iceHalos.setUrgent(!!this.skyHoldUntilMs);const i=this.highCloudCover(),n=this.layeredClouds?.cirrusMask;if(this.iceHalos.setCloudOffset(n?.offset??this.cloudFieldOffset),this.layeredClouds?.hostHalo(this.iceHalos),i===void 0){this.iceHalos.update({x:0,y:1,z:0},-1,0,[1,1,1],{cover:0,layerHeight:$c},0);return}const s=this.lowerCloudCover(),a=me.deckLitUntilDeg(me.DECK_HEIGHT_M),o=t.altitudeDeg>-a?t:e,c=this.bentLight(o,o===t?Fe.SUN_MAGNITUDE:e.magnitude),l=me.strength(i,s,o.altitudeDeg,a)*c.scale,{x:h,y:u,z:d}=hi(o.altitudeDeg,o.azimuthDeg,1);this.iceHalos.update({x:h,y:u,z:d},o.altitudeDeg,l,c.tint,{cover:n?.cover??i,layerHeight:n?.layerHeight??$c},n?.iceCrystalAlignment??this.weather.iceCrystalAlignment??rv)}buildRainbow(t,e){this.rainbow||(this.rainbow=new Aa,this.celestialGroup.add(this.rainbow.object));const i=this.weather.precipitationType==="rain"?this.weather.precipitationIntensity*(this.weather.precipitationAmount??1):0,n=t.altitudeDeg>0,s=n?t:e,a=this.lowerCloudCover(),o=this.bentLight(s,n?Fe.SUN_MAGNITUDE:e.magnitude,V5),c=an.strength(i,a,s.altitudeDeg)*o.scale;if(c<=0){this.rainbow.update({x:0,y:1,z:0},0,[1,1,1],!0);return}const{x:l,y:h,z:u}=hi(s.altitudeDeg,s.azimuthDeg,1);this.rainbow.update({x:l,y:h,z:u},c,o.tint,n)}buildSkyGlow(t,e){if(!t.frame){this.skyGlow?.hide();return}this.skyGlow||(this.skyGlow=new Xs,this.skyGlow.onReady=()=>this.render(),this.celestialGroup.add(this.skyGlow.object));const{date:i,observer:n}=t.frame,s=Dn.galactic(i,n),a=Oe.directionOf(s.centre),o=Oe.directionOf(s.rotation),c=Oe.directionOf(s.pole),l=new Yt().set(a.x,a.y,a.z,o.x,o.y,o.z,c.x,c.y,c.z),h=Oe.directionOf(Dn.eclipticPole(i,n)),u=Oe.directionOf(t.sun),d=u.clone().addScaledVector(h,-u.dot(h)).normalize();this.skyGlow.update({galactic:l,eclipticPole:h,sunLongitude:d,sunDirection:u,sunAltitudeDeg:t.sun.altitudeDeg,moon:{direction:Oe.directionOf(t.moon),altitudeDeg:t.moon.altitudeDeg,phaseAngleDeg:Mt.phaseAngleOf(t.moon.phase.illuminatedFraction)},lightPollution:this.lightPollution,skyColor:new R(e[0],e[1],e[2])})}static directionOf(t){const{x:e,y:i,z:n}=hi(t.altitudeDeg,t.azimuthDeg,1);return new R(e,i,n).normalize()}buildNovae(t,e){const i=new Set;for(const n of t){if(n.magnitude>e)continue;const s=`nova:${n.id}`;i.add(s);const a=Mo(n.magnitude,e),o=Xh(a);this.setBodyMesh(s,n.position,ru*(.5+.5*a),new st(o,o,o),n.magnitude)}for(const n of this.novaKeys)i.has(n)||(this.disposeMesh(this.bodyMeshes.get(n)),this.bodyMeshes.delete(n),this.disposeHitArea(n),this.disposeGlare(n));this.novaKeys=i}disposeComet(){this.cometTail?.set(void 0,void 0,0),this.cometKey&&(this.disposeMesh(this.bodyMeshes.get(this.cometKey)),this.bodyMeshes.delete(this.cometKey),this.disposeHitArea(this.cometKey),this.disposeGlare(this.cometKey),this.cometKey=void 0)}buildPlanets(t,e){const i=new Set(["sun","moon",...this.cometKey?[this.cometKey]:[],...this.novaKeys]);for(const n of t){if(n.magnitude>e)continue;i.add(n.body);const s=Mo(n.magnitude,e),a=Xh(s),o=yE[n.body]??new st(1,1,1),c=new st(o.r*a,o.g*a,o.b*a),l=ru*(.5+.5*s);this.setBodyMesh(n.body,n.position,l,c,n.magnitude)}for(const n of[...this.bodyMeshes.keys()])i.has(n)||(this.disposeMesh(this.bodyMeshes.get(n)),this.bodyMeshes.delete(n),this.disposeHitArea(n),this.disposeGlare(n))}buildStars(t,e){if(this.namedStars=[],!t||t.catalog.count===0){this.disposeStarTiers(),this.syncAnimationLoop();return}const{catalog:i,date:n,observer:s}=t,a=new Pn(n,s),o=gu(1337),c=[],l=this.siteElevationM+this.observerElevationM;for(let h=0;h<i.count;h++){const u=i.mag[h];if(u>e)break;const{altitudeDeg:d,azimuthDeg:f}=a.position(i.ra[h],i.dec[h]);if(d<Tm)continue;const{x:p,y:v,z:m}=hi(d,f,au);c.push({x:p,y:v,z:m,brightness:Mo(u,e),illuminance:this.air.transmittanceFromSpace(l,d).map(g=>g*pe.illuminanceOf(u)),phase:o()*Math.PI*2,speedFactor:.7+o()*.6})}for(const h of Bw){if(h.mag>e)continue;const{altitudeDeg:u,azimuthDeg:d}=a.position(h.raHours,h.decDeg);if(u<Tm)continue;const{x:f,y:p,z:v}=hi(u,d,au);this.namedStars.push({star:h,direction:new R(f,p,v).normalize(),altitudeDeg:u})}this.starTiers=To.map((h,u)=>{const d=c.filter(b=>f1(b.brightness)===u),f=new Float32Array(d.length*3),p=new Float32Array(d.length),v=new Float32Array(d.length*3),m=new Float32Array(d.length),g=new Float32Array(d.length);d.forEach((b,w)=>{f[w*3]=b.x,f[w*3+1]=b.y,f[w*3+2]=b.z,p[w]=b.brightness,v.set(b.illuminance,w*3),m[w]=b.phase,g[w]=b.speedFactor});const S=new ce;S.setAttribute("position",new ie(f,3)),S.setAttribute("seed",new ie(m.map(b=>b/(2*Math.PI)),1));const y=new ie(new Float32Array(d.length*3),3);S.setAttribute("color",y);let M=this.starTiers[u]?.points;return M?(M.geometry.dispose(),M.geometry=S):(M=new xs(S,ae.material(h.size)),ae.track(M),this.celestialGroup.add(M)),{points:M,colorAttribute:y,brightness:p,illuminance:v,phase:m,speedFactor:g}}),this.starColoursRelative=Number.NaN,this.updateTwinkle(this.twinkleSeconds),this.startTwinkle()}twinkleSeconds=0;starColoursRelative=Number.NaN;updateTwinkle(t){ae.setTime(t);const e=this.relativeScale;if(e!==this.starColoursRelative){this.starColoursRelative=e;for(const i of this.starTiers){const n=i.colorAttribute.array;for(let s=0;s<i.brightness.length;s++)n[s*3]=i.illuminance[s*3]*e,n[s*3+1]=i.illuminance[s*3+1]*e,n[s*3+2]=i.illuminance[s*3+2]*e;i.colorAttribute.needsUpdate=!0}}}buildClouds(){if(this.cloudRendering==="volume"||this.weather.cloudLayers!==void 0){this.layeredClouds||(this.disposeCloudSystem(),this.layeredClouds=new Ar(this.celestialGroup,ou,this.cloudRendering)),this.disposeCirrus(),this.layeredClouds.hostHalo(this.iceHalos),this.layeredClouds.update(this.weather,this.observerElevationM+1.6),this.layeredClouds.setOffsets(this.cloudOffsetM,this.cloudLayerOffsetsM),this.lastSunPosition&&this.updateCloudLighting(this.lastSunPosition,this.baseFogColor);return}const t=this.lowerCloudCover();if(t<=0){this.disposeCloudSystem();return}const e=this.weather.cloudDarkness,i=new st(pa[0]+(hu[0]-pa[0])*e,pa[1]+(hu[1]-pa[1])*e,pa[2]+(hu[2]-pa[2])*e);if(this.cloudMesh&&this.cloudUniforms){this.cloudUniforms.coverage.value=t,this.cloudUniforms.baseColor.value.copy(i),this.syncCloudLayer(),this.lastSunPosition&&this.updateCloudLighting(this.lastSunPosition,this.baseFogColor);return}this.disposeCloudSystem();const{material:n,uniforms:s}=yd(i,t,Math.abs(this.cloudLayerOffset()));this.cloudMaterial=n,this.cloudUniforms=s,s.fieldOffset.value.copy(this.cloudFieldOffset),this.lastSunPosition&&this.updateCloudLighting(this.lastSunPosition,this.baseFogColor);const a=_d(ou);this.cloudMesh=new Dt(a,n),this.faceCloudDeck(this.cloudMesh,this.cloudLayerOffset()),this.celestialGroup.add(this.cloudMesh)}lowerCloudCover(){return this.weather.cloudLayers?1-this.weather.cloudLayers.filter(t=>t.type!=="cirrus").reduce((t,e)=>t*(1-e.coverage),1):this.weather.lowerCloudCover??this.weather.cloudCover}highCloudCover(){return this.weather.cloudLayers?1-this.weather.cloudLayers.filter(t=>t.type==="cirrus").reduce((t,e)=>t*(1-e.coverage),1):this.weather.highCloudCover}buildCirrus(){const t=this.weather.highCloudCover??0;if(this.layeredClouds||t<=0){this.disposeCirrus();return}if(this.cirrusMesh&&this.cirrusUniforms){this.cirrusUniforms.coverage.value=t,this.lastSunPosition&&this.updateCloudLighting(this.lastSunPosition,this.baseFogColor);return}const{material:e,uniforms:i}=yd(new st(...pa),t,$c,1);this.cirrusMaterial=e,this.cirrusUniforms=i,i.fieldOffset.value.copy(this.cloudFieldOffset),this.lastSunPosition&&this.updateCloudLighting(this.lastSunPosition,this.baseFogColor),this.cirrusMesh=new Dt(_d(ou*1.04),e),this.cirrusMesh.renderOrder=Om-1,this.celestialGroup.add(this.cirrusMesh)}disposeCirrus(){this.cirrusMesh&&(this.cirrusMesh.removeFromParent(),this.cirrusMesh.geometry.dispose()),this.cirrusMaterial?.dispose(),this.cirrusMesh=void 0,this.cirrusMaterial=void 0,this.cirrusUniforms=void 0}syncCloudLayer(){this.layeredClouds?.update(this.weather,this.observerElevationM+1.6);const t=this.cloudLayerOffset();this.cloudUniforms&&(this.cloudUniforms.layerHeight.value=Math.abs(t)),this.cloudMesh&&this.faceCloudDeck(this.cloudMesh,t)}faceCloudDeck(t,e){const i=e<0;t.scale.y=i?-1:1,t.renderOrder=i?Ar.deckOrder(!0,0,1):Om}cloudLayerOffset(){const e=((this.weather.cloudBaseM??Jd)-this.observerElevationM)*cu;return Math.sign(e||1)*Math.max(Math.abs(e),iE)}updateCloudLighting(t,e){const i=[this.cloudUniforms,this.cirrusUniforms].filter(u=>u!==void 0);if(i.length===0&&!this.layeredClouds)return;const n=this.cloudBeamDirection,[s,a,o]=this.cloudBeam.map(u=>u/Math.PI),c=this.lightningLevel*mu*this.relativeScale/Math.PI,l=new st(e[0]+Xn.r*c,e[1]+Xn.g*c,e[2]+Xn.b*c);this.layeredClouds?.setLighting(n.clone(),new st(s,a,o),l,l);const h=Math.max(0,n.y);for(const u of i)u.sunDir.value.copy(n),u.sunColor.value.setRGB(s*h,a*h,o*h),u.ambientColor.value.copy(l)}disposeCloudSystem(){this.layeredClouds?.dispose(),this.layeredClouds=void 0,this.cloudMesh&&(this.cloudMesh.removeFromParent(),this.cloudMesh.geometry.dispose()),this.cloudMaterial?.dispose(),this.cloudMesh=void 0,this.cloudMaterial=void 0,this.cloudUniforms=void 0}disposePrecipitationPoints(){this.precipitationPoints&&(this.precipitationPoints.removeFromParent(),this.precipitationPoints.geometry.dispose(),this.precipitationPoints.material.dispose()),this.precipitationPoints=void 0,this.precipitationPositions=void 0,this.precipitationPhase=void 0,this.precipitationSpeedJitter=void 0,this.precipitationWobbleFreqJitter=void 0,this.precipitationWobbleAmpJitter=void 0,this.precipitationBounceRemaining=void 0,this.precipitationBounceHeight=void 0,this.precipitationBounceDuration=void 0,this.precipitationBounceVelX=void 0,this.precipitationBounceVelZ=void 0,this.precipitationUniforms=void 0}precipitationCount(t){return hE(t,this.weather.precipitationIntensity,this.weather.precipitationAmount??1)}updatePrecipitationDensity(){const t=[[this.rainSystem?.points,fu],[this.rainSplashSystem?.points,ma],[this.precipitationPoints,this.weather.precipitationType==="none"||this.weather.precipitationType==="rain"?void 0:uu[this.weather.precipitationType].poolSize]];for(const[e,i]of t)e&&i!==void 0&&e.geometry.setDrawRange(0,this.precipitationCount(i));this.rainSystem&&(this.rainSystem.uniforms.uSpeedStreak.value=km(pu(this.weather.precipitationIntensity)))}buildPrecipitation(){this.disposePrecipitationPoints(),this.disposeRain();const t=this.weather.precipitationType;if(t==="none")return;if(t==="rain"){this.buildRain();return}const e=uu[t],i=e.poolSize,n=gu(9001),s=new Float32Array(i*3),a=new Float32Array(i),o=new Float32Array(i),c=new Float32Array(i),l=new Float32Array(i),h=new Float32Array(i),u=new Float32Array(i),d=new Float32Array(i),f=new Float32Array(i),p=new Float32Array(i);for(let y=0;y<i;y++){const M=n()*Math.PI*2,b=n()*e.radiusM;s[y*3]=Math.cos(M)*b,s[y*3+1]=fr+n()*(e.topYM-fr),s[y*3+2]=Math.sin(M)*b,a[y]=n()*Math.PI*2,o[y]=.7+n()*.6,c[y]=.6+n()*.8,l[y]=.4+n()*1.2}const v=new ce;v.setAttribute("position",new ie(s,3)),v.setDrawRange(0,this.precipitationCount(i));const m={uSize:{value:e.size},uScale:{value:.5*this.renderer.domElement.height},uOpacity:{value:e.opacity},uColor:{value:e.color.clone()},uHazeColor:{value:new st(...this.baseFogColor)},uTexture:{value:_E(t)},uNearFocusDistance:{value:Gm},uHazeDistance:{value:e.radiusM*Vm}},g=new le({uniforms:m,vertexShader:TE,fragmentShader:RE,transparent:!0,depthWrite:!1});this.precipitationUniforms=m;const S=new xs(v,g);S.renderOrder=lu,this.scene.add(S),this.precipitationPoints=S,this.precipitationPositions=s,this.precipitationPhase=a,this.precipitationSpeedJitter=o,this.precipitationWobbleFreqJitter=c,this.precipitationWobbleAmpJitter=l,this.precipitationBounceRemaining=h,this.precipitationBounceHeight=u,this.precipitationBounceDuration=d,this.precipitationBounceVelX=f,this.precipitationBounceVelZ=p}updatePrecipitation(t,e){if(!this.precipitationPoints||!this.precipitationPositions||!this.precipitationPhase||!this.precipitationSpeedJitter)return;this.precipitationUniforms?.uHazeColor.value.setRGB(...this.baseFogColor);const i=this.weather.precipitationType;if(i==="none"||i==="rain")return;const n=uu[i];if(this.precipitationUniforms?.uColor.value.copy(Oe.litBySky(n.color,this.baseFogColor)),e<=0)return;const s=this.weather.windDirectionDeg*qi,a=Math.sin(s)*this.weather.windSpeed*n.driftSensitivity,o=-Math.cos(s)*this.weather.windSpeed*n.driftSensitivity,c=this.precipitationPositions,l=this.precipitationPhase,h=this.precipitationSpeedJitter,u=this.precipitationWobbleFreqJitter,d=this.precipitationWobbleAmpJitter,f=this.precipitationBounceRemaining,p=this.precipitationBounceHeight,v=this.precipitationBounceDuration,m=this.precipitationBounceVelX,g=this.precipitationBounceVelZ,S=i==="snow"&&u&&d,y=i==="hail"&&f&&p&&v&&m&&g;for(let M=0,b=0;M<c.length;M+=3,b++){if(y&&f[b]>0){if(f[b]-=e,f[b]<=0){const x=Math.random()*Math.PI*2,A=Math.sqrt(Math.random())*n.radiusM;c[M]=Math.cos(x)*A,c[M+1]=n.topYM,c[M+2]=Math.sin(x)*A,f[b]=0}else{const x=1-f[b]/v[b];c[M+1]=fr+Math.sin(Math.PI*x)*p[b],c[M]=Jc(c[M]+(a+m[b])*e,n.radiusM),c[M+2]=Jc(c[M+2]+(o+g[b])*e,n.radiusM)}continue}let w=0,T=0;if(S){const x=dE*u[b],A=fE*d[b];w=Math.sin(t*x*Math.PI*2+l[b])*A,T=Math.sin(t*x*Math.PI*2+l[b]+Math.PI/2)*A}if(c[M]+=(a+w)*e,c[M+1]-=n.fallSpeedMPerS*h[b]*e,c[M+2]+=(o+T)*e,c[M]=Jc(c[M],n.radiusM),c[M+2]=Jc(c[M+2],n.radiusM),c[M+1]<fr){if(y){p[b]=$m*(.2+Math.random()*1.6),v[b]=pE*(.5+Math.random()),f[b]=v[b];const C=Math.random()*Math.PI*2,I=mE*(p[b]/$m);m[b]=Math.cos(C)*I,g[b]=Math.sin(C)*I,c[M+1]=fr;continue}const x=Math.random()*Math.PI*2,A=Math.sqrt(Math.random())*n.radiusM;c[M]=Math.cos(x)*A,c[M+1]=n.topYM,c[M+2]=Math.sin(x)*A}}this.precipitationPoints.geometry.attributes.position.needsUpdate=!0}buildRain(){const t=pu(this.weather.precipitationIntensity);this.rainSystem=n5({count:fu,radiusM:fo,heightM:sE,bottomYM:Nm,overallSpeed:aE,color:Um.clone(),opacity:.85,visibleCount:this.precipitationCount(fu),speedStreak:km(t),pixelSize:Xm,seed:9001,nearFocusDistanceM:Gm,hazeDistanceM:fo*Vm,hazeColor:new st(...this.baseFogColor)}),this.rainLastVerticalFacing=-1,this.syncRainSlant(),this.rainSystem.points.renderOrder=lu,this.scene.add(this.rainSystem.points),this.buildRainSplashes()}buildRainSplashes(){const t=gu(4242),e=new Float32Array(ma*3),i=new Float32Array(ma),n=new Float32Array(ma),s=new Float32Array(ma);for(let h=0;h<ma;h++){const u=t()*Math.PI*2,d=Math.sqrt(t())*fo;e[h*3]=Math.cos(u)*d,e[h*3+1]=Nm,e[h*3+2]=Math.sin(u)*d,n[h]=Km(zm,Bm),i[h]=t()*n[h],s[h]=i[h]/n[h]}const a=new ce;a.setAttribute("position",new ie(e,3));const o=new ie(s,1);a.setAttribute("aLife",o),a.setDrawRange(0,this.precipitationCount(ma));const c=new le({uniforms:{uMaxSize:{value:lE},uScale:{value:.5*this.renderer.domElement.height},uColor:{value:Hm.clone()},uTexture:{value:wE()}},vertexShader:EE,fragmentShader:AE,transparent:!0,depthWrite:!1}),l=new xs(a,c);l.renderOrder=lu,this.scene.add(l),this.rainSplashSystem={points:l,positions:e,life:i,duration:n,lifeAttribute:o}}disposeRain(){this.rainSystem&&(this.rainSystem.points.removeFromParent(),this.rainSystem.points.geometry.dispose(),this.rainSystem.points.material.dispose()),this.rainSystem=void 0,this.disposeRainSplashes()}disposeRainSplashes(){this.rainSplashSystem&&(this.rainSplashSystem.points.removeFromParent(),this.rainSplashSystem.points.geometry.dispose(),this.rainSplashSystem.points.material.dispose()),this.rainSplashSystem=void 0}syncRainSlant(){const t=this.rainSystem;if(!t)return;const e=this.weather.windDirectionDeg*qi;t.uniforms.uDropVelocity.value.set(Math.sin(e)*this.weather.windSpeed,-pu(this.weather.precipitationIntensity),-Math.cos(e)*this.weather.windSpeed);const i=this.renderer.getSize(this.rainViewportSize);t.uniforms.uAspect.value=i.x/Math.max(i.y,1)}updateRain(t){const e=this.rainSystem;if(!e)return;e.uniforms.uTime.value+=t,e.uniforms.uHazeColor.value.setRGB(...this.baseFogColor),e.uniforms.uColor.value.copy(Oe.litBySky(Um,this.baseFogColor));const i=this.rainSplashSystem?.points.material?.uniforms?.uColor;i&&i.value.copy(Oe.litBySky(Hm,this.baseFogColor));const n=this.weather.windDirectionDeg*qi,s=Math.sin(n)*this.weather.windSpeed,a=-Math.cos(n)*this.weather.windSpeed,o=fo,c=h=>(h%(o*2)+o*3)%(o*2)-o;e.uniforms.uWindOffset.value.set(c(e.uniforms.uWindOffset.value.x+s*t),c(e.uniforms.uWindOffset.value.y+a*t)),this.syncRainSlant(),this.camera.getWorldDirection(this.rainCameraDirection);const l=Math.abs(this.rainCameraDirection.y);if(Math.abs(l-this.rainLastVerticalFacing)>.001){this.rainLastVerticalFacing=l;const h=Ym+(1-Ym)*(1-l),u=qm+(1-qm)*(1-l);e.uniforms.uUvSquash.value=u,e.uniforms.uPixelSize.value=Xm*h*(.5+.5*u)}this.updateRainSplashes(t)}updateRainSplashes(t){const e=this.rainSplashSystem;if(!e||t<=0)return;const{positions:i,life:n,duration:s,lifeAttribute:a}=e,o=a.array;for(let c=0,l=0;c<i.length;c+=3,l++){if(n[l]+=t,n[l]>=s[l]){const h=Math.random()*Math.PI*2,u=Math.sqrt(Math.random())*fo;i[c]=Math.cos(h)*u,i[c+2]=Math.sin(h)*u,s[l]=Km(zm,Bm),n[l]=0}o[l]=n[l]/s[l]}e.points.geometry.attributes.position.needsUpdate=!0,a.needsUpdate=!0}setLightning(t){this.lightningFlashes=t}updateLightning(t){let e,i=0;if(this.lightningArmed)for(const c of this.lightningFlashes){if(c.t>t)break;const l=pi.brightnessAt(c,t);l>i&&(e=c,i=l)}const n=e?Math.min(1,Math.max(.1,(ME/e.distanceM)**2)):0,s=i*n*(e?.cloudToGround?1:.6);if(s===this.lightningLevel&&!e?.cloudToGround)return;if(this.lightningLevel=s,this.scene.fog){const c=this.scene.fog,l=s*mu*this.relativeScale/Math.PI;c.color.setRGB(this.airlight[0]+Xn.r*l,this.airlight[1]+Xn.g*l,this.airlight[2]+Xn.b*l)}const a=this.skyMesh?.material?.color;if(a){const c=s*xE;a.setRGB(1+c*Xn.r,1+c*Xn.g,1+c*Xn.b)}if(this.lastSunPosition&&this.updateCloudLighting(this.lastSunPosition,this.baseFogColor),this.lightningLight.intensity=s*mu*this.relativeScale,e){const{x:c,y:l,z:h}=hi(25,e.azimuthDeg,sn);this.lightningLight.position.set(c,l,h)}this.lightningBolt||(this.lightningBolt=new qs(sn*.95),this.celestialGroup.add(this.lightningBolt.object));const o=this.weather.cloudBaseM??1500;this.lightningBolt.set(e,i,o),this.render()}buildCompassLabels(){this.compassSprites=q5.map(t=>{const e=Ca.point(t,this.compassPoints),i=new ol({map:DE(e),depthTest:!1,fog:!1}),n=new jr(i),{x:s,y:a,z:o}=hi(0,t,Im);return n.position.set(s,a,o),n.scale.set(Zc,Zc,1),n.renderOrder=Z5,n.layers.set(bm),n.visible=this.compassHovered||this.compassForced,this.celestialGroup.add(n),n}),this.updateCompassScale()}updateCompassScale(){const t=this.camera.fov*Math.PI/360,e=Cm*Math.PI/360,i=Zc*Math.tan(t)/Math.tan(e);for(const n of this.compassSprites)n.scale.set(i,i,1)}disposeCompassLabels(){for(const t of this.compassSprites)t.removeFromParent(),t.material.map?.dispose(),t.material.dispose();this.compassSprites=[]}disposeStarTiers(){for(const t of this.starTiers)this.disposeMesh(t.points);this.starTiers=[]}disposeMesh(t){if(!t)return;t.removeFromParent(),"geometry"in t&&t.geometry.dispose();const e=t.material;for(const i of Array.isArray(e)?e:[e]){const n=i.map;n&&n.dispose(),i.dispose()}}}const qi=Math.PI/180;function xr(r,t,e){return Math.max(t,Math.min(e,r))}function Km(r,t){return r+Math.random()*(t-r)}function Jc(r,t){return(r%(t*2)+t*3)%(t*2)-t}let jc,Qc;function _E(r){switch(r){case"snow":return SE();case"hail":return bE()}}function SE(){if(jc)return jc;const r=64,t=document.createElement("canvas");t.width=r,t.height=r;const e=t.getContext("2d"),i=e.createRadialGradient(r/2,r/2,0,r/2,r/2,r/2);return i.addColorStop(0,"rgba(255,255,255,0.95)"),i.addColorStop(.5,"rgba(255,255,255,0.55)"),i.addColorStop(1,"rgba(255,255,255,0)"),e.fillStyle=i,e.fillRect(0,0,r,r),jc=new Is(t),jc}function bE(){if(Qc)return Qc;const r=64,t=document.createElement("canvas");t.width=r,t.height=r;const e=t.getContext("2d"),i=e.createRadialGradient(r/2,r/2,0,r/2,r/2,r/2);return i.addColorStop(0,"rgba(255,255,255,1)"),i.addColorStop(.55,"rgba(255,255,255,0.95)"),i.addColorStop(.8,"rgba(255,255,255,0.4)"),i.addColorStop(1,"rgba(255,255,255,0)"),e.fillStyle=i,e.fillRect(0,0,r,r),Qc=new Is(t),Qc}let tl;function wE(){if(tl)return tl;const r=64,t=document.createElement("canvas");t.width=r,t.height=r;const e=t.getContext("2d"),i=e.createRadialGradient(r/2,r/2,0,r/2,r/2,r/2);return i.addColorStop(0,"rgba(255,255,255,0)"),i.addColorStop(.4,"rgba(255,255,255,0)"),i.addColorStop(.6,"rgba(255,255,255,0.9)"),i.addColorStop(.8,"rgba(255,255,255,0.25)"),i.addColorStop(1,"rgba(255,255,255,0)"),e.fillStyle=i,e.fillRect(0,0,r,r),tl=new Is(t),tl}const EE=`
|
|
7757
7767
|
uniform float uMaxSize;
|
|
7758
7768
|
uniform float uScale;
|
|
7759
7769
|
attribute float aLife;
|
|
@@ -7819,4 +7829,4 @@ void main() {
|
|
|
7819
7829
|
gl_FragColor = vec4(color, tex.a * uOpacity * (1.0 - blur * 0.5));
|
|
7820
7830
|
}
|
|
7821
7831
|
`;function Zm(r){const e=document.createElement("canvas");e.width=128,e.height=128;const i=e.getContext("2d"),n=128/2-2,s=128/2,a=128/2,o="#010101",c="#f4f1e2";i.fillStyle=o,i.beginPath(),i.arc(s,a,n,0,Math.PI*2),i.fill();const l=xr(r.illuminatedFraction,0,1),h=r.phaseFraction<.5,u=n*Math.abs(1-2*l),d=l<.5;return i.save(),i.beginPath(),i.arc(s,a,n,0,Math.PI*2),i.clip(),i.fillStyle=c,i.beginPath(),h?(i.arc(s,a,n,-Math.PI/2,Math.PI/2,!1),i.ellipse(s,a,u,n,0,Math.PI/2,-Math.PI/2,d)):(i.arc(s,a,n,Math.PI/2,-Math.PI/2,!1),i.ellipse(s,a,u,n,0,-Math.PI/2,Math.PI/2,d)),i.fill(),i.restore(),new Is(e)}function DE(r){const t=document.createElement("canvas");t.width=128,t.height=128;const e=t.getContext("2d");return e.fillStyle="rgba(0, 0, 0, 0.55)",e.beginPath(),e.arc(64,64,60,0,Math.PI*2),e.fill(),e.fillStyle="#ffffff",e.font="bold 52px sans-serif",e.textAlign="center",e.textBaseline="middle",e.fillText(r,64,68),new Is(t)}function gu(r){let t=r;return function(){t|=0,t=t+1831565813|0;let i=Math.imul(t^t>>>15,1|t);return i=i+Math.imul(i^i>>>7,61|i)^i,((i^i>>>14)>>>0)/4294967296}}class Fl{constructor(t,e){this.source=t,this.create=e}scene;wanted;pumping=!1;disposed=!1;static PATIENCE_FRAMES=600;static SCENE_WIDTH_PX=320;paint(t,e){this.disposed||(this.wanted={t,canvas:e},this.pumping||this.pump())}recordingChanged(t){this.scene&&(this.scene.sightingData=t)}dispose(){this.disposed=!0,this.scene?.remove(),this.scene=void 0}ensureScene(){if(this.scene)return this.scene;const t=this.create();return t.setAttribute("max-pixel-ratio","1"),Object.assign(t.style,{position:"fixed",left:"-10000px",top:"0",width:`${Fl.SCENE_WIDTH_PX}px`,visibility:"hidden",pointerEvents:"none"}),document.body.appendChild(t),t.documentUrl=this.source.documentUrl,t.accountInTheRound=this.source.accountInTheRound,t.sightingData=this.source.sightingData,this.scene=t,t}async pump(){this.pumping=!0;try{for(;this.wanted&&!this.disposed;){const{t,canvas:e}=this.wanted;this.wanted=void 0;const i=this.ensureScene();i.interpretation!==this.source.interpretation&&(i.interpretation=this.source.interpretation),i.compareAccount!==this.source.compareAccount&&(i.compareAccount=this.source.compareAccount),i.showAt(t);for(let n=0;n<Fl.PATIENCE_FRAMES&&!this.wanted&&!this.disposed&&(await new Promise(s=>requestAnimationFrame(()=>s())),!this.wanted);n++)if(i.snapshotTo(e)){e.dataset.ready="true";break}}}finally{this.pumping=!1}}}const vu=7.5,Mu=9;class qn{static cache=new Map;static load(t){let e=qn.cache.get(t);return e||(e=fetch(t).then(i=>i.arrayBuffer()).then(i=>qn.parse(i)),qn.cache.set(t,e)),e}static upTo(t,e){const i=t.filter((a,o)=>o===0||t[o-1].magnitudeLimit<e);if(i.length<=1)return qn.load(t[0].url);const n=i.map(a=>a.url).join(`
|
|
7822
|
-
`);let s=qn.cache.get(n);return s||(s=Promise.all(i.map(a=>qn.load(a.url))).then(a=>a.reduce((o,c)=>qn.concat(o,c))),qn.cache.set(n,s)),s}static parse(t){const e=t.byteLength/(4*Float32Array.BYTES_PER_ELEMENT),i=e*Float32Array.BYTES_PER_ELEMENT;return{count:e,ra:new Float32Array(t,0*i,e),dec:new Float32Array(t,1*i,e),mag:new Float32Array(t,2*i,e),ci:new Float32Array(t,3*i,e)}}static concat(t,e){const i=(n,s)=>{const a=new Float32Array(n.length+s.length);return a.set(n,0),a.set(s,n.length),a};return{count:t.count+e.count,ra:i(t.ra,e.ra),dec:i(t.dec,e.dec),mag:i(t.mag,e.mag),ci:i(t.ci,e.ci)}}}class Jm{constructor(t){this.names=t}body(t,e){return this.names?.bodies[t]??e}star(t){return this.names?.stars[t.name]??t.name}comet(t){return this.names?.comets[t.id]??t.name}nova(t){return this.names?.novae[t.id]??t.name}satelliteClass(t){return this.names?.satelliteClasses[t.id]??t.name}shower(t){return this.names?.showers[t.id]??t.name}lightRig(t){return this.names?.lightRigs[t.id]??t.name}instrument(t){return this.names?.instruments[t.id]??t.name}decorKind(t,e){return this.names?.decorKinds[t]??e}point(t){return Ca.point(t,this.names?.compassPoints)}towards(t){return Ca.towards(t,this.names)}}const IE="“Thunder” by Jerimee",CE="https://creativecommons.org/licenses/by/3.0/",PE="CC BY 3.0";class $n{static fill(t,e){t.innerHTML="";const i=l=>t.appendChild(l),n=e.currentTerrainAttribution;n&&i($n.text(n));const s=e.currentRoadAttribution;s&&i($n.text(s));const a=e.ufoElement.observerMapCredit;a&&!n?.includes(a)&&i($n.text(a));for(const l of e.decorModelCredits){const h=l.author?` — ${l.author}`:"",u=document.createElement("li");l.sourceUrl?u.append($n.link(l.sourceUrl,l.title),document.createTextNode(`${h} (${l.license})`)):u.textContent=`${l.title}${h} (${l.license})`,i(u)}for(const l of e.ufoElement.sighting.references){if(!l.credit)continue;const h=document.createElement("li");l.creditUrl?h.appendChild($n.link(l.creditUrl,l.credit)):h.textContent=l.credit,i(h)}const o=e.satelliteState;if(o.status==="ready"&&o.credit){const l=document.createElement("li");l.appendChild($n.link(o.creditUrl??"",o.credit)),i(l)}const c=$n.text(`${IE} (`);c.append($n.link(CE,PE),document.createTextNode(")")),i(c)}static text(t){const e=document.createElement("li");return e.textContent=t,e}static link(t,e){const i=document.createElement("a");return i.href=t,i.target="_blank",i.rel="noopener",i.textContent=e,i}}const LE=new URL(""+new URL("rain-BvWZrB9h.ogg",import.meta.url).href,import.meta.url).href,OE=new URL(""+new URL("wind-BjklexY7.ogg",import.meta.url).href,import.meta.url).href,NE=new URL(""+new URL("thunder-DA48qs_v.wav",import.meta.url).href,import.meta.url).href,FE=20,UE=1;class kE{context;buffers=new Map;ambientSource;ambientGain;ambientKey="none";ambientToken=0;ambientVolume=0;windSource;windGain;windActive=!1;windToken=0;windVolume=0;paused=!0;requested={type:"none",intensity:0,windSpeed:0};level=1;master;output(t){return this.master||(this.master=t.createGain(),this.master.gain.value=this.level,this.master.connect(t.destination)),this.master}setLevel(t){this.level=t,this.master&&(this.master.gain.value=t)}resume(){if(!this.context){if(typeof AudioContext>"u")return;try{this.context=new AudioContext}catch(t){console.warn("WeatherAudio: Web Audio unavailable, weather sounds disabled:",t);return}}Da.unlock(this.context)}setAmbient(t,e,i){if(this.requested={type:t,intensity:e,windSpeed:i},!this.context)return;this.paused&&(t="none",e=0,i=0);const n=t==="rain"||t==="hail"?t:"none";if(this.ambientVolume=n==="hail"?Math.min(1,e*1.3+.2):n==="rain"?e:0,n!==this.ambientKey){this.ambientKey=n;const a=++this.ambientToken;this.stopSource(this.ambientSource,this.ambientGain),this.ambientSource=void 0,this.ambientGain=void 0,n!=="none"&&this.startLoop(LE,this.ambientVolume).then(o=>this.applyIfCurrent(o,a,()=>this.ambientToken,c=>{this.ambientSource=c?.source,this.ambientGain=c?.gain,c&&(c.gain.gain.value=this.ambientVolume)}))}else this.ambientGain&&(this.ambientGain.gain.value=this.ambientVolume);this.windVolume=Math.min(i/FE,1);const s=i>UE;if(s!==this.windActive){this.windActive=s;const a=++this.windToken;this.stopSource(this.windSource,this.windGain),this.windSource=void 0,this.windGain=void 0,s&&this.startLoop(OE,this.windVolume).then(o=>this.applyIfCurrent(o,a,()=>this.windToken,c=>{this.windSource=c?.source,this.windGain=c?.gain,c&&(c.gain.gain.value=this.windVolume)}))}else this.windGain&&(this.windGain.gain.value=this.windVolume)}setPaused(t){if(t===this.paused)return;this.paused=t;const{type:e,intensity:i,windSpeed:n}=this.requested;this.setAmbient(e,i,n)}playThunder(){!this.context||this.paused||this.playOneShot(NE,.9)}dispose(){this.ambientToken++,this.windToken++,this.stopSource(this.ambientSource,this.ambientGain),this.stopSource(this.windSource,this.windGain),this.ambientSource=void 0,this.ambientGain=void 0,this.windSource=void 0,this.windGain=void 0,this.context?.close(),this.context=void 0,this.master=void 0,this.buffers.clear()}applyIfCurrent(t,e,i,n){if(e!==i()){t?.source.stop();return}n(t)}async startLoop(t,e){const i=this.context;if(i)try{const n=await this.getBuffer(t),s=i.createBufferSource();s.buffer=n,s.loop=!0;const a=i.createGain();return a.gain.value=e,s.connect(a).connect(this.output(i)),s.start(),{source:s,gain:a}}catch(n){console.warn("Weather ambient sound failed to load, staying silent:",n);return}}async playOneShot(t,e){const i=this.context;if(i)try{const n=await this.getBuffer(t),s=i.createBufferSource();s.buffer=n;const a=i.createGain();a.gain.value=e,s.connect(a).connect(this.output(i)),s.start()}catch(n){console.warn("Thunder sound failed to load:",n)}}async getBuffer(t){const e=this.context;if(!e)throw new Error("WeatherAudio: AudioContext not ready — resume() must be called first");let i=this.buffers.get(t);return i||(i=fetch(t).then(n=>{if(!n.ok)throw new Error(`Audio fetch failed (${n.status}): ${t}`);return n.arrayBuffer()}).then(n=>e.decodeAudioData(n)),this.buffers.set(t,i)),i}stopSource(t,e){try{t?.stop()}catch{}t?.disconnect(),e?.disconnect()}}class Ms{constructor(t){this.elements=t;const{eccentricity:e,perihelionAu:i}=t,[n,s]=this.perifocalAxes(),a=Math.sqrt(Ms.SUN_GM_AU3_PER_DAY2*(1+e)/i);this.perihelionPosition=this.scale(n,i),this.perihelionVelocity=this.scale(s,a),this.inverseSemiMajorAxis=(1-e)/i}static SUN_GM_AU3_PER_DAY2=.0002959122082855911;static MAX_ITERATIONS=200;perihelionPosition;perihelionVelocity;inverseSemiMajorAxis;positionAt(t){const e=t-this.elements.perihelionJd,i=this.universalAnomaly(e),n=this.inverseSemiMajorAxis*i*i,s=this.elements.perihelionAu,a=1-i*i/s*Ms.stumpffC(n),o=e-i*i*i/Math.sqrt(Ms.SUN_GM_AU3_PER_DAY2)*Ms.stumpffS(n);return{x:a*this.perihelionPosition.x+o*this.perihelionVelocity.x,y:a*this.perihelionPosition.y+o*this.perihelionVelocity.y,z:a*this.perihelionPosition.z+o*this.perihelionVelocity.z}}heliocentricDistanceAt(t){const e=this.positionAt(t);return Math.hypot(e.x,e.y,e.z)}universalAnomaly(t){if(t===0)return 0;const e=Math.sign(t),i=Math.sqrt(Ms.SUN_GM_AU3_PER_DAY2)*Math.abs(t),n=o=>{const c=this.inverseSemiMajorAxis*o*o,l=this.elements.perihelionAu;return(1-this.inverseSemiMajorAxis*l)*o*o*o*Ms.stumpffS(c)+l*o};let s=Math.max(1,i/this.elements.perihelionAu);for(;n(s)<i;)s*=2;let a=0;for(let o=0;o<Ms.MAX_ITERATIONS&&s-a>1e-13*Math.max(1,s);o++){const c=(a+s)/2;n(c)<i?a=c:s=c}return e*(a+s)/2}perifocalAxes(){const t=this.elements.ascendingNodeDeg*Math.PI/180,e=this.elements.argumentOfPerihelionDeg*Math.PI/180,i=this.elements.inclinationDeg*Math.PI/180,n=Math.cos(t),s=Math.sin(t),a=Math.cos(e),o=Math.sin(e),c=Math.cos(i),l=Math.sin(i);return[{x:n*a-s*o*c,y:s*a+n*o*c,z:o*l},{x:-n*o-s*a*c,y:-s*o+n*a*c,z:a*l}]}scale(t,e){return{x:t.x*e,y:t.y*e,z:t.z*e}}static stumpffC(t){if(Math.abs(t)<1e-6)return 1/2-t/24+t*t/720;if(t>0)return(1-Math.cos(Math.sqrt(t)))/t;const e=Math.sqrt(-t);return(Math.cosh(e)-1)/-t}static stumpffS(t){if(Math.abs(t)<1e-6)return 1/6-t/120+t*t/5040;if(t>0){const i=Math.sqrt(t);return(i-Math.sin(i))/(i*i*i)}const e=Math.sqrt(-t);return(Math.sinh(e)-e)/(e*e*e)}}const X1=[{id:"halley-1910",designation:"1P/Halley",name:"Halley's Comet",orbit:{eccentricity:.9672960498922706,perihelionAu:.5872100477652511,inclinationDeg:162.218798367122,ascendingNodeDeg:58.56208298700436,argumentOfPerihelionDeg:111.7366940639061,perihelionJd:2.4187816784171113e6},peakMagnitude:0,peakOn:"1910-05-20",absoluteMagnitude:4.72,activityExponent:4,tailLengthDeg:100,tailLengthAu:.1638,note:"Passed 0.15 au from Earth on 20 May 1910, and the Earth crossed the outer tail the day before — the apparition that produced a genuine public panic."},{id:"brooks-1911",designation:"C/1911 O1",name:"Comet Brooks",orbit:{eccentricity:.9876404970138669,perihelionAu:.4898172916113738,inclinationDeg:33.34043866978714,ascendingNodeDeg:293.7022074981857,argumentOfPerihelionDeg:153.5578007321686,perihelionJd:2.4193378856140426e6},peakMagnitude:2,peakOn:"1911-10-25",absoluteMagnitude:5.59,activityExponent:4},{id:"skjellerup-maristany-1927",designation:"C/1927 X1",name:"Comet Skjellerup-Maristany",orbit:{eccentricity:.999839726885059,perihelionAu:.1761569619628186,inclinationDeg:85.1125991950808,ascendingNodeDeg:78.24360172472711,argumentOfPerihelionDeg:47.15877857390136,perihelionJd:2.4252326808989984e6},peakMagnitude:-6,peakOn:"1927-12-15",absoluteMagnitude:1.19,activityExponent:4,note:"One of the few comets of the century seen in full daylight."},{id:"de-kock-paraskevopoulos-1941",designation:"C/1941 B2",name:"Comet de Kock-Paraskevopoulos",orbit:{eccentricity:.9991026715181549,perihelionAu:.7900329662827822,inclinationDeg:168.2039226531089,ascendingNodeDeg:43.10609347214336,argumentOfPerihelionDeg:268.6990344196369,perihelionJd:2430022157765061e-9},peakMagnitude:2,peakOn:"1941-02-05",absoluteMagnitude:5.01,activityExponent:4},{id:"southern-1947",designation:"C/1947 X1",name:"the Southern Comet",orbit:{eccentricity:.9998424430916737,perihelionAu:.1100045955093761,inclinationDeg:138.5113919632757,ascendingNodeDeg:337.3114969669252,argumentOfPerihelionDeg:196.1820121395961,perihelionJd:2.4325220864727003e6},peakMagnitude:-3,peakOn:"1947-12-08",absoluteMagnitude:3.01,activityExponent:4,note:"A bright southern-hemisphere comet of December 1947, the month the American sighting wave of that year was still being argued over."},{id:"eclipse-1948",designation:"C/1948 V1",name:"the Eclipse Comet",orbit:{eccentricity:.9999130678247334,perihelionAu:.1354437057263306,inclinationDeg:23.11668597152911,ascendingNodeDeg:211.0454985994762,argumentOfPerihelionDeg:107.2474157073104,perihelionJd:2.4328519265329437e6},peakMagnitude:-2,peakOn:"1948-11-01",absoluteMagnitude:4.79,activityExponent:4,note:"Found during the total solar eclipse of 1 November 1948, which is how a comet that bright had gone unnoticed: it had been hidden in the Sun's glare."},{id:"arend-roland-1957",designation:"C/1956 R1",name:"Comet Arend-Roland",orbit:{eccentricity:1.0002570255357,perihelionAu:.3160532361485914,inclinationDeg:119.9440863251822,ascendingNodeDeg:215.8548157717755,argumentOfPerihelionDeg:308.775920364167,perihelionJd:2.4359365327396123e6},peakMagnitude:.5,peakOn:"1957-04-25",absoluteMagnitude:3.96,activityExponent:4,note:"Showed a spike pointing back TOWARD the Sun in late April 1957 — a real anti-tail, and much reported at the time."},{id:"mrkos-1957",designation:"C/1957 P1",name:"Comet Mrkos",orbit:{eccentricity:.9993521583504134,perihelionAu:.3549238508212375,inclinationDeg:93.9433042053929,ascendingNodeDeg:68.32441518619923,argumentOfPerihelionDeg:40.31823675802871,perihelionJd:243605193752228e-8},peakMagnitude:1,peakOn:"1957-08-05",absoluteMagnitude:5.07,activityExponent:4,note:"The second bright naked-eye comet of 1957, four months after Arend-Roland."},{id:"seki-lines-1962",designation:"C/1962 C1",name:"Comet Seki-Lines",orbit:{eccentricity:1.000003791331562,perihelionAu:.03139689112215131,inclinationDeg:65.01487186102287,ascendingNodeDeg:304.6776602796538,argumentOfPerihelionDeg:11.47295326312573,perihelionJd:2437756163010178e-9},peakMagnitude:-2.5,peakOn:"1962-04-01",absoluteMagnitude:9.3,activityExponent:4},{id:"ikeya-seki-1965",designation:"C/1965 S1",name:"Comet Ikeya-Seki",orbit:{eccentricity:.9999141178248997,perihelionAu:.007785966366889336,inclinationDeg:141.8642315267051,ascendingNodeDeg:346.9951764632611,argumentOfPerihelionDeg:69.04909813996062,perihelionJd:2.4390546837018197e6},peakMagnitude:-10,peakOn:"1965-10-21",alsoRecordedMagnitude:2,alsoRecordedOn:"1965-10-30",absoluteMagnitude:5.26,activityExponent:4.002,tailLengthDeg:25,tailLengthAu:.5048,note:"A sungrazer that passed 450 000 km above the Sun's surface and was seen beside it in broad daylight — the brightest comet of the twentieth century. It then stood in the dawn sky for a fortnight with a tail some 25 degrees long, which is the second magnitude recorded here."},{id:"bennett-1970",designation:"C/1969 Y1",name:"Comet Bennett",orbit:{eccentricity:.9962979048768408,perihelionAu:.5376209981502136,inclinationDeg:90.03975717147327,ascendingNodeDeg:224.6576652531314,argumentOfPerihelionDeg:354.1494209173161,perihelionJd:2.4406655455270996e6},peakMagnitude:0,peakOn:"1970-03-26",absoluteMagnitude:3.36,activityExponent:4},{id:"white-ortiz-bolelli-1970",designation:"C/1970 K1",name:"Comet White-Ortiz-Bolelli",orbit:{eccentricity:.9999488875801225,perihelionAu:.00884411465256722,inclinationDeg:138.9520738221631,ascendingNodeDeg:336.8194095816687,argumentOfPerihelionDeg:61.10224765396615,perihelionJd:2.4407209807728203e6},peakMagnitude:1,peakOn:"1970-05-22",absoluteMagnitude:4.35,activityExponent:4},{id:"kohoutek-1973",designation:"C/1973 E1",name:"Comet Kohoutek",orbit:{eccentricity:1.000007152175185,perihelionAu:.1424250377812859,inclinationDeg:14.30414984159355,ascendingNodeDeg:258.4893339663974,argumentOfPerihelionDeg:37.79772760699667,perihelionJd:2442044930687027e-9},peakMagnitude:0,peakOn:"1974-01-05",absoluteMagnitude:4.89,activityExponent:4,note:"Announced in advance as the comet of the century and remembered for disappointing: it was an ordinary naked-eye object, not the spectacle the press had promised."},{id:"west-1976",designation:"C/1975 V1",name:"Comet West",orbit:{eccentricity:1.000017859625611,perihelionAu:.1966006188461085,inclinationDeg:43.07319920579427,ascendingNodeDeg:118.9189245655447,argumentOfPerihelionDeg:358.4315101259072,perihelionJd:2442833721841768e-9},peakMagnitude:-3,peakOn:"1976-02-25",absoluteMagnitude:4.41,activityExponent:4,tailLengthDeg:30,tailLengthAu:.4325,note:"Broke into four pieces at perihelion. Barely reported at the time — the press had been burned by Kohoutek two years earlier."},{id:"iras-araki-alcock-1983",designation:"C/1983 H1",name:"Comet IRAS-Araki-Alcock",orbit:{eccentricity:.9898409731606003,perihelionAu:.9913412593828502,inclinationDeg:73.25000846947029,ascendingNodeDeg:49.10235754476374,argumentOfPerihelionDeg:192.8506176754439,perihelionJd:2.4454757545235856e6},peakMagnitude:1.7,peakOn:"1983-05-11",absoluteMagnitude:9.04,activityExponent:4,note:"Passed 0.031 au from Earth on 11 May 1983, one of the closest cometary approaches on record: it crossed a quarter of the sky in a night, which no other comet in this list did."},{id:"halley-1986",designation:"1P/Halley",name:"Halley's Comet",orbit:{eccentricity:.9672792271749998,perihelionAu:.5871034488173393,inclinationDeg:162.2422242700916,ascendingNodeDeg:58.85993640671803,argumentOfPerihelionDeg:111.8655480539208,perihelionJd:2.4464709589610207e6},peakMagnitude:2.1,peakOn:"1986-03-10",absoluteMagnitude:2.71,activityExponent:4,note:"The worst-placed return in two thousand years — famous, expected, and for most observers a faint smudge."},{id:"hyakutake-1996",designation:"C/1996 B2",name:"Comet Hyakutake",orbit:{eccentricity:.9997295133739305,perihelionAu:.2302272039470452,inclinationDeg:124.923592343765,ascendingNodeDeg:188.0454295899424,argumentOfPerihelionDeg:130.1724036582639,perihelionJd:2.4502048946148166e6},peakMagnitude:0,peakOn:"1996-03-25",absoluteMagnitude:4.75,activityExponent:4,tailLengthDeg:80,tailLengthAu:1,note:"Passed 0.10 au from Earth in March 1996, five weeks BEFORE perihelion, with a tail measured at some 80 degrees — the longest of the modern era."},{id:"hale-bopp-1997",designation:"C/1995 O1",name:"Comet Hale-Bopp",orbit:{eccentricity:.9951314746156615,perihelionAu:.9141695067003724,inclinationDeg:89.43017155012492,ascendingNodeDeg:282.470602866853,argumentOfPerihelionDeg:130.5872524854533,perihelionJd:2450539633099368e-9},peakMagnitude:-.8,peakOn:"1997-04-01",absoluteMagnitude:-1.06,activityExponent:4,tailLengthDeg:20,tailLengthAu:.9938,note:"Visible to the naked eye for about eighteen months, longer than any comet on record."},{id:"mcnaught-2007",designation:"C/2006 P1",name:"Comet McNaught",orbit:{eccentricity:1.00001811603225,perihelionAu:.1707325614080681,inclinationDeg:77.83726446452654,ascendingNodeDeg:267.4149080498975,argumentOfPerihelionDeg:155.9756130642756,perihelionJd:2454113298753579e-9},peakMagnitude:-5.5,peakOn:"2007-01-13",absoluteMagnitude:2.53,activityExponent:4,tailLengthDeg:35,tailLengthAu:.5009,note:"The brightest comet since Ikeya-Seki, seen in daylight beside the Sun in January 2007."},{id:"lovejoy-2011",designation:"C/2011 W3",name:"Comet Lovejoy",orbit:{eccentricity:.999915056276912,perihelionAu:.005553783989325053,inclinationDeg:134.3558712062691,ascendingNodeDeg:326.3693517957772,argumentOfPerihelionDeg:53.50991655176601,perihelionJd:2455911511809431e-9},peakMagnitude:-3,peakOn:"2011-12-16",alsoRecordedMagnitude:1.5,alsoRecordedOn:"2011-12-22",absoluteMagnitude:3.51,activityExponent:1.194,note:"A sungrazer that was expected to be destroyed at perihelion and came out the other side, to stand in the southern dawn sky for the rest of December — which is the second magnitude recorded here."},{id:"panstarrs-2013",designation:"C/2011 L4",name:"Comet PANSTARRS",orbit:{eccentricity:1.000032542889696,perihelionAu:.301544229714915,inclinationDeg:84.2081978367921,ascendingNodeDeg:65.66588626213694,argumentOfPerihelionDeg:333.6516444379993,perihelionJd:2456361669960698e-9},peakMagnitude:1,peakOn:"2013-03-10",absoluteMagnitude:5.98,activityExponent:4},{id:"neowise-2020",designation:"C/2020 F3",name:"Comet NEOWISE",orbit:{eccentricity:.9991782081129224,perihelionAu:.2946512466331692,inclinationDeg:128.9375043020912,ascendingNodeDeg:61.01042991771634,argumentOfPerihelionDeg:37.2786526292898,perihelionJd:2.4590341788972816e6},peakMagnitude:.9,peakOn:"2020-07-08",absoluteMagnitude:5.79,activityExponent:4,tailLengthDeg:10,tailLengthAu:.1808,note:"The first comet since Hale-Bopp that ordinary observers in the northern hemisphere saw without being told where to look."},{id:"tsuchinshan-atlas-2024",designation:"C/2023 A3",name:"Comet Tsuchinshan-ATLAS",orbit:{eccentricity:1.000020192843226,perihelionAu:.3914228969475176,inclinationDeg:139.1105462619479,ascendingNodeDeg:21.55945689078845,argumentOfPerihelionDeg:308.4913086299446,perihelionJd:2460581242087108e-9},peakMagnitude:0,peakOn:"2024-10-14",absoluteMagnitude:3.97,activityExponent:4,tailLengthDeg:20,tailLengthAu:.1902,note:"Briefly reported far brighter around 9 October 2024, when it stood almost between the observer and the Sun and forward-scattered the light through its own dust — a geometry this catalog's brightness model does not attempt, so what is stored is the ordinary evening-sky peak a few days later."}];class zE{static WINDOW_DAYS=200;static TWILIGHT_ELONGATION_DEG=15;static LIGHT_SPEED_AU_PER_DAY=173.144632674;static orbits=new Map;static aroundDate(t){const e=this.julianDayOf(t);return X1.filter(i=>Math.abs(e-i.orbit.perihelionJd)<=this.WINDOW_DAYS)}static brightestAt(t,e){return this.aroundDate(t).map(i=>this.appearanceOf(i,t,e)).sort((i,n)=>i.magnitude-n.magnitude)[0]}static appearanceOf(t,e,i){const n=$e(e),s=this.earthPositionAt(n),a=this.apparentPositionOf(t,2451545+n.tt,s),o=this.subtract(a,s),c=this.length(a),l=this.length(o),h=this.tailEndAt(t,a,s,c,n,e,i),u=this.horizontalOf(o,n,e,i);return{apparition:t,position:u,...h,heliocentricDistanceAu:c,earthDistanceAu:l,elongationDeg:this.angleBetween(o,this.subtract({x:0,y:0,z:0},s)),magnitude:this.magnitudeAt(t,c,l)}}static magnitudeAt(t,e,i){const n=t.absoluteMagnitude+5*Math.log10(i)+2.5*t.activityExponent*Math.log10(e);return Math.max(n,t.peakMagnitude)}static tailEndAt(t,e,i,n,s,a,o){if(t.tailLengthAu===void 0)return{};const c=1+t.tailLengthAu/n,l=this.subtract({x:e.x*c,y:e.y*c,z:e.z*c},i),h=this.subtract(e,i);return{tailEnd:this.horizontalOf(l,s,a,o),tailLengthDeg:this.angleBetween(h,l)}}static apparentPositionOf(t,e,i){const n=this.orbitOf(t);let s=n.positionAt(e);for(let a=0;a<2;a++){const o=this.length(this.subtract(s,i))/this.LIGHT_SPEED_AU_PER_DAY;s=n.positionAt(e-o)}return s}static horizontalOf(t,e,i,n){const s=Cr(Pw(),new Fe(t.x,t.y,t.z,e)),a=Cr(C1(e),s),o=uw(e,new N0(n.lat,n.lng,n.elevationM)),c=new Fe(a.x-o.x,a.y-o.y,a.z-o.z,e),l=U0(c);return k0(l.ra,l.dec,i,n)}static earthPositionAt(t){return Cr(Cw(),ia(wt.Earth,t))}static julianDayOf(t){return 2451545+$e(t).tt}static orbitOf(t){const e=this.orbits.get(t.id);if(e)return e;const i=new Ms(t.orbit);return this.orbits.set(t.id,i),i}static subtract(t,e){return{x:t.x-e.x,y:t.y-e.y,z:t.z-e.z}}static length(t){return Math.hypot(t.x,t.y,t.z)}static angleBetween(t,e){const i=(t.x*e.x+t.y*e.y+t.z*e.z)/(this.length(t)*this.length(e)||1);return Math.acos(Math.min(1,Math.max(-1,i)))*180/Math.PI}}const xu=[{id:"sn-1006",kind:"supernova",designation:"SN 1006",name:"Supernova of 1006",raHours:15.03947,decDeg:-42.09694,peakMagnitude:-7.5,peakJd:2088620,startJd:2088620,lightCurve:[[0,-7.5],[29,-5.9],[60,-4.9],[106,-3.2],[166,-1.9],[258,-1],[350,.5],[364,.7],[411,1.2],[456,1.8],[484,2.5],[785.5,7]],source:"Winkler, Gupta & Long 2003 (peak); decline borrowed from SN 1572",note:"The brightest stellar event in recorded history, seen in daylight, low in the southern sky from Europe and the Near East. The decline is modelled, not recorded, and falls below the naked eye after about two years where the chronicles speak of three."},{id:"sn-1054",kind:"supernova",designation:"SN 1054",name:"Supernova of 1054",raHours:5.5755,decDeg:22.0175,peakMagnitude:-6,peakJd:2106216,startJd:2106216,lightCurve:[[0,-6],[23,-4],[642,6]],source:"Chinese chronicles (Song huiyao), via Stephenson & Green 2002",note:"The explosion that left the Crab Nebula. Its magnitude is an estimate; the two durations are recorded."},{id:"sn-1181",kind:"supernova",designation:"SN 1181",name:"Supernova of 1181",raHours:.88645,decDeg:67.50067,peakMagnitude:0,peakJd:2152636,startJd:2152636,lightCurve:[[0,0],[185,6]],source:"Chinese and Japanese chronicles, via Stephenson & Green 2002",note:"Circumpolar from Europe and China, so never set. Its peak magnitude is uncertain by at least a magnitude."},{id:"sn-1572",kind:"supernova",designation:"SN 1572",name:"Tycho's Supernova",raHours:.42264,decDeg:64.14083,peakMagnitude:-4,peakJd:2295551,startJd:2295546,lightCurve:[[0,-3],[5,-4],[34,-2.4],[65,-1.4],[111,.3],[171,1.6],[263,2.5],[355,4],[369,4.2],[416,4.7],[461,5.3],[489,6]],source:"Tycho Brahe and contemporaries, reduced by Ruiz-Lapuente 2004",note:"Circumpolar from northern Europe. Tycho showed it had no parallax, so it was not in the air: a new star, beyond the Moon."},{id:"sn-1604",kind:"supernova",designation:"SN 1604",name:"Kepler's Supernova",raHours:17.51125,decDeg:-21.48733,peakMagnitude:-2.95,peakJd:2307210,startJd:2307191,lightCurve:[[0,.23],[3,-1.3],[6,-2.08],[9,-2.17],[19,-2.95],[27,-2.95],[32,-1.95],[36,-1.52],[86,.9],[96,.45],[103,1],[114,1.2],[118,1.55],[133,1.95],[137,2.3],[170,2.25],[185,2.25],[194,2.4],[197,2.9],[308,4.45],[324,4.45],[339,4.95],[364,4.7]],source:"Kepler, Fabricius, Maestlin and the Korean court astronomers, reduced by Ruiz-Lapuente 2017",note:"The last supernova in our Galaxy seen with the naked eye. It went behind the Sun from mid-November 1604 to January 1605, which is the gap in its record."},{id:"t-crb-1866",kind:"nova",designation:"T CrB",name:"Nova Coronae Borealis 1866",raHours:15.99171,decDeg:25.92017,peakMagnitude:2,peakJd:2402734,startJd:2402734,lightCurve:[[0,2],[1.5,3],[2.5,3.11],[6.5,5.18],[8.5,5.75],[10.5,6.85],[11.5,6.8],[12.5,7.5],[16,8.18],[32,9.27],[38,9.2],[40,8.95],[44,9.4],[48,9.07],[54,9.4],[58,9.21],[79,9.44],[107,9.26],[111,9.01],[115,8.21],[119,7.96],[159,7.51],[179,7.57],[183,7.97],[191,7.66],[199,8.2],[207,8.31],[211,8.83],[215,8.65],[223,8.97],[297,8.9],[345,9.25],[377,9.07],[425,9.3],[537,9.3]],source:"Recorded peak (Birmingham); curve borrowed from its 1946 eruption",note:"The first eruption of the recurrent nova T CrB to be seen. The decline is its 1946 one."},{id:"t-aur-1891",kind:"nova",designation:"T Aur",name:"Nova Aurigae 1891",raHours:5.53309,decDeg:30.44583,peakMagnitude:4.49,peakJd:2412083,startJd:2412079,lightCurve:[[0,5.28],[4,4.49],[24,4.58],[40,4.97],[52,4.95],[56,4.5],[60,4.9],[68,4.88],[72,5.25],[76,4.93],[84,5.44],[88,7.23],[96,8.85],[100,10.44]],source:"AAVSO, binned by Strope, Schaefer & Henden 2010"},{id:"gk-per-1901",kind:"nova",designation:"GK Per",name:"Nova Persei 1901",raHours:3.52,decDeg:43.90431,peakMagnitude:.19,peakJd:24154395e-1,startJd:24154377e-1,lightCurve:[[0,2.7],[.8,.86],[1.8,.19],[2.3,.2],[5.8,1.78],[11.8,2.54],[12.8,2.98],[17.8,3.62],[18.8,3.35],[19.8,3.77],[20.8,3.59],[22.8,3.95],[24.8,3.82],[25.6,4.99],[25.9,4.89],[26.6,3.69],[27.6,3.94],[27.9,4.61],[28.6,5.28],[28.9,4.46],[29.9,3.8],[30.9,4.27],[31.6,5.21],[31.9,5.22],[32.9,3.88],[33.9,4.19],[34.6,4.85],[35.6,4.8],[36.6,4.23],[37.6,4.44],[38.9,4.15],[39.7,5.19],[40.6,5.39],[40.9,5.35],[41.9,4.01],[42.6,4.5],[42.9,4.49],[43.6,5.53],[44,5.23],[44.6,5.61],[44.9,5.5],[45.9,4.17],[46.9,4.69],[47.6,5.5],[48.6,5.59],[49.6,5.14],[49.9,4.48],[50.6,4.45],[50.9,4.55],[51.6,5.47],[52.6,5.74],[53.7,5.66],[55.7,4.41],[56.7,5.43],[58.7,5.81],[58.9,5.58],[59.7,5.64],[59.9,4.76],[60.9,4.26],[61.9,5.62],[62.7,5.85],[62.9,5.53],[63.7,5.8],[64.9,4.28],[65.6,5.33],[66.7,5.87],[66.9,5.56],[68.7,5.7],[68.9,5.3],[69.7,4.47],[70.7,5.65],[72.9,5.98],[73.9,5.71],[74.7,4.98],[74.9,4.46],[75.7,4.87],[76.9,6.05],[77.6,5.76],[78,6],[78.7,5.95],[80.7,4.98],[81.9,5.85],[82.7,6.02],[84.7,5.41],[84.9,5.08],[85.7,5.17],[85.9,5.6],[87,6.1],[88.8,6.2],[89.7,4.96],[89.9,4.93],[90.7,5.9],[91.9,6.32],[92.7,5.86],[93.1,6.24],[93.7,5.38],[93.9,6.2],[96.1,6.12],[97.1,6.37],[97.6,5.12],[98,5.85],[99.3,6.35],[101.3,6.12],[101.7,5.25],[102.3,4.95],[102.7,6.12],[103.2,5.83],[104.7,6.37],[105,6.13],[106,6.22],[106.7,4.88],[107.7,6.3],[108.1,6.4],[109,6],[109.7,5.16],[110,5.82],[112.1,5.89],[113.1,5.5],[115.7,5.8],[116,6.11],[118.7,5.68],[119,6.23],[119.7,5.85],[120,6.12],[121,4.62],[121.8,5.9],[123,5.48],[125,6.05],[126,5.89],[130.9,6.11],[146.1,6.02],[155.6,6.26],[180.4,6.09],[190.4,6.39],[245.5,6.87],[266.2,6.77],[301.1,7.16],[321.5,7.07],[346.5,7.87],[375.7,7.86],[385.8,8.09],[389.8,8.55],[406.1,8.33],[416.5,8.59],[445.9,8.62],[472.1,9.24],[565.9,9.74],[571,9.4],[589.8,9.76]],source:"AAVSO, binned by Strope, Schaefer & Henden 2010",note:"Discovered on 21 February 1901 by Thomas Anderson in Edinburgh, and the brightest nova of the century until V603 Aql."},{id:"dn-gem-1912",kind:"nova",designation:"DN Gem",name:"Nova Geminorum 1912",raHours:6.9151,decDeg:32.14108,peakMagnitude:3.58,peakJd:241947675e-2,startJd:241947275e-2,lightCurve:[[0,11.7],[1,4.5],[4,3.58],[5,4.45],[5.5,5.32],[6,5.53],[6.5,5.11],[8,5.43],[8.5,5.16],[11,5.53],[11.5,5.13],[12,5.18],[13.75,4.5],[15.75,5.3],[18.75,6],[19.75,5.55],[26.75,6],[28.75,5.9],[31.75,6.6],[32.75,6.2],[33.75,6.5],[36.75,6.55],[39.75,6.2],[40.75,6.75],[41.75,7],[44.75,6.75],[52.75,6.75],[54.75,7.23],[58.25,7.5],[62.25,7.3],[64.25,7.47],[66.25,8.1],[70.25,7.5],[72.25,8.1],[78.25,7.55],[80.25,8.2],[86.25,7.2],[90.25,7.3],[92.25,7.8],[152.25,7.2],[160.25,7.4],[166.25,8.2],[168.25,8.2],[170.25,7.3],[180.25,7.4],[182.25,8],[186.25,7.5],[190.25,7.6],[192.25,8],[211.25,7.75],[227.25,8],[275.25,7.78],[315.25,8.6],[331.25,7.79],[339.25,8.27],[363.25,8.61],[443.25,8.93],[451.25,9.2],[535.25,10.3],[567.25,9.9],[615.25,10.8],[631.25,10.63],[647.25,10.88],[679.25,10.8],[695.25,11.07],[727.25,11]],source:"AAVSO, binned by Strope, Schaefer & Henden 2010"},{id:"v603-aql-1918",kind:"nova",designation:"V603 Aql",name:"Nova Aquilae 1918",raHours:18.81518,decDeg:.58414,peakMagnitude:-.5,peakJd:242175475e-2,startJd:242174875e-2,lightCurve:[[0,11.3],[2,10.5],[4,6.6],[4.5,1.04],[6,-.5],[6.5,.18],[10,1.1],[10.5,.95],[12.75,1.89],[21.75,3.07],[23.75,3.76],[29.75,3.16],[34.75,3.5],[36.75,3.86],[44.75,3.79],[48.75,4.43],[52.75,3.84],[56.75,3.95],[57.75,4.04],[58.75,4.49],[59.75,4.42],[60.75,4.69],[62.75,4.6],[63.75,4.11],[64.75,3.97],[68.75,4.18],[70.75,4.65],[71.75,4.51],[73.75,4.73],[75.75,4.44],[79.75,4.85],[83.75,4.43],[89.75,4.88],[92.75,4.86],[94.75,4.58],[96.75,4.92],[99.75,5.05],[163.25,5.45],[167.25,5.7],[179.25,5.48],[191.25,5.8],[203.25,5.5],[247.25,5.9],[251.25,6.25],[257.25,5.5],[265.25,6.13],[281.25,6.33],[345.25,6.3],[385.25,6.73],[393.25,6.43],[425.25,6.71],[433.25,6.56],[461.25,7.27],[525.25,7.6],[541.25,7.47],[637.25,8.3],[669.25,8.17],[717.25,8.55],[749.25,8.4],[765.25,8.68],[885.25,8.75],[949.25,9.4],[1013.25,9.19],[1141.25,9.57],[1269.25,9.48],[1333.25,9.95],[1653.25,9.94],[1781.25,10.28],[1909.25,10.34],[2037.25,10.1],[2101.25,10.46],[2165.25,10.51],[2357.25,10.3],[2549.25,10.77],[2741.25,10.46],[2869.25,10.83],[3125.25,10.71],[3317.25,11.22],[3381.25,10.91],[3637.25,11.42],[3829.25,10.96],[3893.25,11.65],[3957.25,11.63],[4085.25,11.14],[4213.25,11.48],[4277.25,10.7],[4341.25,11.42],[4405.25,11.47],[4469.25,11.06],[4533.25,11.08],[4597.25,11.7],[4725.25,11.45],[4789.25,10.94]],source:"AAVSO, binned by Strope, Schaefer & Henden 2010",note:"The brightest nova of the modern era, at magnitude -0.5 on 9-10 June 1918: as bright as Vega, in a summer evening sky, in wartime."},{id:"v476-cyg-1920",kind:"nova",designation:"V476 Cyg",name:"Nova Cygni 1920",raHours:19.97347,decDeg:53.61858,peakMagnitude:1.94,peakJd:242256025e-2,startJd:242255925e-2,lightCurve:[[0,2.7],[1,1.94],[3,2.07],[4.5,2.95],[8.25,4],[31.75,6.41],[35.75,7.23],[37.75,7.08],[41.75,7.33],[43.75,7.92],[45.75,8.2],[51.75,8.59],[63.75,8.82],[65.75,9.25],[71.75,8.93],[85.75,9.43],[87.75,9.05],[95.75,9.2],[97.75,8.67],[99.75,9.07],[112.75,8.78],[120.75,9.03],[128.75,8.67],[144.75,8.94],[152.75,8.73],[168.75,8.79],[176.75,9.28],[192.75,9],[216.75,9.6],[232.75,9.27],[240.75,9.5],[288.75,9.4],[296.75,9.6],[304.75,9.3],[320.75,9.73],[328.75,9.5],[336.75,9.8],[428.75,9.61],[476.75,10.01],[492.75,9.76],[508.75,9.87],[524.75,9.65],[556.75,9.87],[572.75,9.65],[620.75,10.22],[668.75,10.44],[684.75,10.23],[716.75,10.33],[756.75,10.66],[884.75,10.59],[948.75,10.96],[1108.75,10.96]],source:"AAVSO, binned by Strope, Schaefer & Henden 2010"},{id:"rr-pic-1925",kind:"nova",designation:"RR Pic",name:"Nova Pictoris 1925",raHours:6.59335,decDeg:-62.64008,peakMagnitude:.95,peakJd:24243085e-1,startJd:24242995e-1,lightCurve:[[0,2.43],[5,2.35],[6,2.1],[7,2.4],[9,.95],[13,1.8],[14,1.7],[16,2.15],[18,2.2],[19,1.9],[23,3.1],[27,3.05],[31.5,3.58],[43.5,3.08],[47.5,3.15],[57.5,2.3],[59.5,1.65],[63.5,3.03],[65.5,2.84],[67.5,3.16],[69.5,2.4],[71.5,2.04],[73.5,2.05],[75.5,2.55],[79.5,3],[83.5,3.15],[116.5,3.54],[120.5,3.78],[124.5,3.67],[136.5,4.18],[148.5,4.34],[154.5,4.17],[194.5,4.43],[226.5,4.93],[234.5,4.8],[242.5,5.4],[250.5,5.5],[266.5,5.15],[298.5,5.6],[362.5,5.4],[414.5,5.7],[430.5,5.5],[494.5,6.2],[718.5,6.52],[830.5,6.3],[862.5,6.6],[878.5,6.4],[910.5,6.77],[958.5,6.67],[1062.5,7.07],[1318.5,7.35],[1590.5,8.12],[1718.5,8.25],[2486.5,8.59],[2614.5,8.47],[2742.5,8.7],[3382.5,8.6],[3766.5,8.97],[4022.5,8.79],[4150.5,9.22],[6710.5,10.29],[7414.5,11.03],[8438.5,10.96]],source:"AAVSO, binned by Strope, Schaefer & Henden 2010",note:"A slow nova, and a southern one: more than two months within two magnitudes of its peak."},{id:"dq-her-1934",kind:"nova",designation:"DQ Her",name:"Nova Herculis 1934",raHours:18.12507,decDeg:45.85906,peakMagnitude:1.56,peakJd:24277935e-1,startJd:242778675e-2,lightCurve:[[0,3.4],[1.5,2.4],[3,2.67],[5.75,2.01],[6.75,1.56],[7.75,1.59],[11.75,2.97],[12.75,2.31],[14.75,3.07],[15.75,2.56],[16.75,2.51],[19.75,2.68],[23.75,2.53],[24.75,2.27],[26.75,2.58],[30.75,2.24],[31.75,2.63],[32.75,2.66],[34.75,2.11],[39.75,2.71],[41.75,2.31],[43.75,2.37],[46.75,3.64],[47.75,3.21],[50.75,3.23],[52.75,2.66],[55.75,2.56],[58.75,2.97],[60.75,2.77],[61.75,3.36],[63.75,3.43],[64.75,2.89],[65.75,3.22],[68.75,3.52],[69.75,2.95],[70.75,3.06],[71.75,2.7],[76.75,3.65],[79.75,3.74],[81.75,3.21],[83.75,3.75],[87.75,3.69],[92.75,4.04],[94.75,4.8],[97.75,4.24],[98.75,4.52],[100.75,4.08],[101.75,4.43],[105.75,4.58],[106.75,4.33],[107.75,4.73],[108.75,6.57],[109.75,8.08],[110.75,8.15],[111.75,8.56],[113.75,8.45],[114.75,9.15],[115.75,9.15],[116.75,9.59],[117.75,9.43],[118.75,9.8],[122.75,10.5],[123.75,10.28],[124.75,10.93],[127.75,10.83],[129.75,11.87],[131.75,12.42],[135.75,12.5],[137.75,12.9],[138.75,12.77],[139.75,13],[143.75,12],[144.75,12.33],[146.75,12.35],[147.75,11.64],[148.75,11.83],[150.75,10.9],[151.75,10.78],[152.75,11.17],[154.75,10.32],[155.75,10.4],[165.25,9.24],[185.25,7.74],[225.25,6.8],[273.25,6.72],[321.25,6.97],[333.25,6.79],[353.25,7],[357.25,6.82],[377.25,6.88],[401.25,7.29],[409.25,6.8],[413.25,6.8],[419.25,7.1],[435.25,7.09],[451.25,7.4],[475.25,7],[555.25,7.48],[823.25,7.83],[855.25,8.18],[1135.25,8.43],[1823.25,9.98],[1887.25,9.71],[2015.25,10.55],[2335.25,10.95]],source:"AAVSO, binned by Strope, Schaefer & Henden 2010",note:"Lost about ten magnitudes in a few weeks from April 1935, when dust condensed around it, then came back to naked-eye brightness."},{id:"cp-lac-1936",kind:"nova",designation:"CP Lac",name:"Nova Lacertae 1936",raHours:22.26142,decDeg:55.61703,peakMagnitude:2.02,peakJd:242834025e-2,startJd:242833825e-2,lightCurve:[[0,4.03],[.5,2.9],[1,2.45],[2,2.02],[2.5,2.61],[4,3],[4.5,3.35],[5,3.3],[9.25,4.59],[14.25,5.45],[22.25,6.03],[23.25,6.3],[26.25,6.23],[38.25,6.74],[41.25,6.61],[50.25,7.35],[53.25,7.27],[57.25,7.7],[58.25,7.54],[60.25,7.55],[61.25,7.79],[71.25,7.6],[74.25,7.81],[76.25,8.3],[77.25,7.79],[86.25,8.21],[87.25,8],[88.25,8.25],[92.25,8.17],[94.25,8.47],[102.25,8.27],[103.25,8.7],[104.25,8.4],[110.25,8.66],[116.75,8.55],[122.75,8.83],[126.75,8.7],[140.75,9.06],[154.75,9.01],[164.75,9.36],[170.75,9.18],[174.75,9.48],[186.75,9.42],[188.75,9.73],[192.75,9.53],[200.75,9.74],[202.75,9.5],[204.75,9.77],[208.75,9.6],[214.75,9.75],[216.75,10.05],[222.75,9.7],[232.75,10.03],[236.75,9.82],[250.75,10.1],[254.75,9.9],[260.75,10.1],[264.75,9.8],[266.75,10.15],[268.75,10],[274.75,10.2],[276.75,9.9],[292.75,10.6],[294.75,10.6],[298.75,10.1],[318.75,10.35],[320.75,10.6],[322.75,10.3],[328.75,10.65],[332.75,10.3],[338.75,10.7],[348.75,10.53],[350.75,10.7],[354.75,10.37],[358.75,10.58],[365.75,10.43],[373.75,10.85],[421.75,10.94]],source:"AAVSO, binned by Strope, Schaefer & Henden 2010"},{id:"cp-pup-1942",kind:"nova",designation:"CP Pup",name:"Nova Puppis 1942",raHours:8.19613,decDeg:-35.35139,peakMagnitude:.73,peakJd:243067675e-2,startJd:243067275e-2,lightCurve:[[0,.95],[4,.73],[4.5,1.3],[5.5,1.47],[6,2.01],[7.75,2.88],[8.75,2.97],[10.75,3.5],[11.75,4.02],[13.75,4.4],[14.75,3.8],[17.75,5],[18.75,4.93],[19.75,5.48],[23.75,5.5],[25.75,5.65],[26.75,5.99],[33.25,6.28],[45.25,6.6],[57.25,6.41],[81.25,6.85],[89.25,6.5],[97.25,6.67],[101.25,7],[113.25,6.66],[125.25,7.1],[135.25,6.96],[231.25,7.86],[279.25,7.8],[327.25,8.33],[407.25,8.18],[423.25,8.59],[471.25,8.53],[503.25,8.99],[551.25,8.97],[567.25,8.7],[583.25,9.47],[615.25,8.95],[655.25,9.5],[751.25,9.55],[815.25,10.09],[847.25,10.02],[879.25,10.48],[911.25,10.34],[1023.25,10.79],[1279.25,10.9]],source:"AAVSO, binned by Strope, Schaefer & Henden 2010",note:"One of the fastest bright novae: two magnitudes gone in four days."},{id:"t-crb-1946",kind:"nova",designation:"T CrB",name:"Nova Coronae Borealis 1946",raHours:15.99171,decDeg:25.92017,peakMagnitude:2.5,peakJd:2431860,startJd:2431860,lightCurve:[[0,2.5],[1.5,3.5],[2.5,3.61],[6.5,5.68],[8.5,6.25],[10.5,7.35],[11.5,7.3],[12.5,8],[16,8.68],[32,9.77],[38,9.7],[40,9.45],[44,9.9],[48,9.57],[54,9.9],[58,9.71],[79,9.94],[107,9.76],[111,9.51],[115,8.71],[119,8.46],[159,8.01],[179,8.07],[183,8.47],[191,8.16],[199,8.7],[207,8.81],[211,9.33],[215,9.15],[223,9.47],[297,9.4],[345,9.75],[377,9.57],[425,9.8],[537,9.8]],source:"AAVSO, binned by Strope, Schaefer & Henden 2010",note:"A recurrent nova. It erupted in 1866 and in 1946, and a third eruption was expected from 2024 on."},{id:"v446-her-1960",kind:"nova",designation:"V446 Her",name:"Nova Herculis 1960",raHours:18.956,decDeg:13.24147,peakMagnitude:4.83,peakJd:24370038e-1,startJd:24370033e-1,lightCurve:[[0,5.2],[.5,4.83],[2,4.9],[2.5,5.4],[3,5.05],[3.5,5.57],[4,5.25],[5,5.5],[6.5,5.4],[7.2,5.78],[8.2,5.6],[9.2,5.98],[10.2,5.92],[11.2,6.21],[16.2,6.1],[17.2,6.23],[18.2,7.2],[19.2,6.51],[20.2,6.78],[26.2,6.97],[27.2,7.24],[28.2,7.13],[29.2,7.45],[31.2,7.2],[40.7,7.57],[44.7,8.25],[46.7,7.84],[56.7,8.15],[60.7,8.9],[70.7,8.7],[72.7,8.14],[76.7,8.71],[80.7,8.47],[82.7,8.87],[86.7,8.57],[90.7,8.93],[107.7,9.11],[111.7,8.94],[115.7,9.27],[139.7,9.38],[151.7,9.91],[155.7,9.72],[173.7,10.51],[221.7,10.95]],source:"AAVSO, binned by Strope, Schaefer & Henden 2010"},{id:"v533-her-1963",kind:"nova",designation:"V533 Her",name:"Nova Herculis 1963",raHours:18.23902,decDeg:41.85614,peakMagnitude:3,peakJd:24380605e-1,startJd:24380565e-1,lightCurve:[[0,8],[4,3],[4.5,3],[8,4],[13,3.95],[15,4.6],[21,4.53],[24,5.05],[27,5.15],[32,4.76],[34,4.98],[35,5.39],[37,5.43],[41,6.04],[49,6.02],[56.5,6.34],[60.5,6.11],[74.5,6.72],[102.5,6.99],[137.5,7.81],[197.5,8.31],[217.5,8.8],[225.5,8.57],[233.5,9.03],[237.5,8.78],[277.5,9.44],[301.5,9.46],[315.5,9.86],[323.5,9.73],[339.5,10.05],[355.5,10.74],[363.5,10.32],[371.5,10.6],[387.5,10.69],[427.5,10.38],[435.5,10.84],[443.5,10.74],[451.5,11.33],[459.5,10.98],[467.5,11.17],[507.5,11.16],[539.5,11.66],[603.5,11.7],[619.5,12.05],[651.5,12.03],[659.5,11.74],[667.5,10.9]],source:"AAVSO, binned by Strope, Schaefer & Henden 2010"},{id:"hr-del-1967",kind:"nova",designation:"HR Del",name:"Nova Delphini 1967",raHours:20.70565,decDeg:19.16092,peakMagnitude:3.58,peakJd:2439838,startJd:2439646,lightCurve:[[0,11.9],[6,11.8],[12,8.8],[16,8.3],[20,6.7],[30,5.8],[36,5.51],[66,5.55],[78,5.35],[86,4.89],[96,5],[108,4.75],[136,5.13],[152,4.83],[182,4.93],[186,4.59],[192,3.58],[202,5],[220,5.46],[226,5.14],[230,5.45],[232,5.14],[236,5],[242,5.08],[244,4.59],[246,4.45],[254,5.3],[256,4.75],[260,5.69],[268,4.8],[274,4.94],[276,5.45],[280,5.2],[282,5.51],[286,5.58],[292,4.95],[294,5.16],[298,4.94],[311,5.09],[335,4.4],[367,5.76],[407,6.16],[423,6.55],[603,7.43],[907,8.32],[1451,9.41],[2347,10.75]],source:"AAVSO, binned by Strope, Schaefer & Henden 2010",note:"An exceptionally slow nova: rose over months and stayed near magnitude 4 to 5 for most of 1967 and 1968."},{id:"lv-vul-1968",kind:"nova",designation:"LV Vul",name:"Nova Vulpeculae 1968",raHours:19.80012,decDeg:27.1715,peakMagnitude:4.5,peakJd:243996425e-2,startJd:243996325e-2,lightCurve:[[0,5],[1,4.5],[2,5],[2.5,4.86],[3,5.1],[3.5,4.88],[4,5.1],[5,4.9],[7,5.4],[8,5.23],[10.5,5.42],[12,5.82],[13,5.4],[13.5,5.74],[14,5.7],[14.5,6.08],[15,5.75],[15.5,5.86],[16,5.6],[17,5.8],[18,5.6],[20.5,6.34],[21,6.2],[22.5,6.84],[23,6.57],[24,6.98],[24.5,6.3],[25,7.1],[26,6.65],[34.25,7.48],[35.25,7.23],[39.25,7.32],[44.25,7.76],[45.25,7.49],[46.25,7.78],[50.25,7.84],[51.25,8.1],[53.25,7.9],[54.25,8.13],[56.25,8],[57.75,8.24],[67.75,8.52],[75.75,8.38],[83.75,8.69],[89.75,8.59],[125.75,9.32],[127.75,9.33],[129.75,8.98],[131.75,9.29],[135.75,9.43],[212.75,9.9],[220.75,10.16],[228.75,10.03],[236.75,10.3],[244.75,10.16],[264.75,10.54],[280.75,10.45],[296.75,10.79],[328.75,10.78]],source:"AAVSO, binned by Strope, Schaefer & Henden 2010"},{id:"fh-ser-1970",kind:"nova",designation:"FH Ser",name:"Nova Serpentis 1970",raHours:18.51307,decDeg:2.61444,peakMagnitude:4.5,peakJd:244063425e-2,startJd:244063125e-2,lightCurve:[[0,7],[2,5],[3,4.5],[3.5,5],[4.5,4.6],[5.5,5],[6.5,4.68],[12.25,4.66],[16.25,5.3],[17.25,5.72],[18.25,5.3],[19.25,5.2],[23.25,5.84],[24.25,5.68],[27.25,5.9],[30.25,5.47],[32.25,5.9],[34.25,5.7],[43.25,6.28],[45.25,6.1],[50.25,6.62],[52.25,6.47],[57.25,6.63],[60.25,7.08],[61.25,6.87],[62.25,7.2],[63.25,6.85],[64.25,7.68],[65.25,7.3],[66.25,8.3],[67.25,7.93],[69.25,9.15],[71.25,9.2],[72.25,9.63],[74.25,9.9],[76.25,9.7],[77.25,10.25],[78.25,10.1],[79.25,10.4],[80.25,10.23],[81.25,10.57],[83.25,10.64],[85.25,10.35],[86.25,11.2],[87.25,10.1],[89.25,11.2],[96.25,11.35],[100.25,11.95],[102.25,11.1],[104.25,11.65],[106.25,11.5],[108.25,12.07],[114.75,11.32],[118.75,11.28],[122.75,10.93],[130.75,10.85],[134.75,10.52],[154.75,10.65],[162.75,10.12],[174.75,9.98],[178.75,10.34],[186.75,9.98],[214.75,10.25],[224.75,10.02],[240.75,10.2],[264.75,10],[272.75,10.2],[280.75,10.05],[288.75,10.4],[296.75,10],[348.75,10.7],[396.75,10.3],[444.75,10.73],[460.75,10.59],[540.75,10.94],[556.75,10.82]],source:"AAVSO, binned by Strope, Schaefer & Henden 2010"},{id:"v1500-cyg-1975",kind:"nova",designation:"V1500 Cyg",name:"Nova Cygni 1975",raHours:21.19349,decDeg:48.15056,peakMagnitude:1.88,peakJd:244265525e-2,startJd:244265425e-2,lightCurve:[[0,2.44],[1,1.88],[1.5,1.88],[2.5,2.41],[3,3.38],[4,4.28],[8.25,5.81],[11.25,6.46],[22.25,7.35],[33.25,7.73],[34.25,7.97],[37.25,7.86],[40.25,8.3],[43.25,8.19],[48.25,8.6],[49.25,8.46],[66.25,9.04],[70.25,8.93],[75.25,9.23],[76.25,9.03],[80.25,9.39],[81.25,9.19],[83.25,9.35],[84.25,9.13],[86.25,9.39],[89.25,9.32],[90.25,9.54],[93.25,9.37],[105.75,9.86],[193.75,10.43],[201.75,10.7],[209.75,10.47],[257.75,10.94],[265.75,10.81]],source:"AAVSO, binned by Strope, Schaefer & Henden 2010",note:"One of the fastest novae on record: discovered on 29 August 1975, at its peak of magnitude 1.9 within two days, and two magnitudes down again two days later."},{id:"v842-cen-1986",kind:"nova",designation:"V842 Cen",name:"Nova Centauri 1986",raHours:14.59794,decDeg:-57.6265,peakMagnitude:4.9,peakJd:244675975e-2,startJd:244675725e-2,lightCurve:[[0,5.6],[2.5,4.9],[3.5,5.1],[15.5,5.1],[17.5,5.75],[18.5,5.4],[20.5,5.5],[22.5,5.95],[30.5,6.15],[31.5,6.3],[32,7.5],[34.5,7.2],[38.5,7.5],[39,7],[41.5,7.15],[42.5,6.7],[44.5,7.23],[45.5,6.6],[53,9.3]],source:"AAVSO, binned by Strope, Schaefer & Henden 2010"},{id:"sn-1987a",kind:"supernova",designation:"SN 1987A",name:"Supernova 1987A",raHours:5.59111,decDeg:-69.26975,peakMagnitude:2.98,peakJd:24469425e-1,startJd:24468495e-1,lightCurve:[[0,6.36],[1,6.11],[2,4.63],[4,4.45],[32,3.97],[56,3.15],[93,2.98],[105,3.35],[118,4.11],[134,4.43],[504,8.15],[617,10.27]],source:"V photometry compiled by the Open Supernova Catalog (Sternberg catalogue, IAU circulars, CTIO)",note:"In the Large Magellanic Cloud, 160 000 light years away: the nearest supernova since Kepler's, and invisible north of about 20° N."},{id:"v1974-cyg-1992",kind:"nova",designation:"V1974 Cyg",name:"Nova Cygni 1992",raHours:20.50879,decDeg:52.63078,peakMagnitude:4.27,peakJd:24486753e-1,startJd:24486718e-1,lightCurve:[[0,7.2],[1,5.23],[2,4.62],[3.5,4.27],[4.5,4.59],[6,4.5],[7,4.78],[7.5,4.52],[8,4.82],[10.7,5.25],[11.7,5.66],[16.7,5.85],[21.7,6.47],[22.7,6.3],[27.7,6.46],[29.7,6.83],[34.7,6.9],[35.7,7.25],[36.7,7],[37.7,7.16],[39.7,7.03],[43.7,7.41],[45.7,7.26],[50.7,7.45],[57.7,7.78],[58.7,8.13],[61.7,7.92],[64.7,8.19],[65.7,7.99],[71.7,8.22],[76.7,8.01],[128.2,8.72],[176.2,8.89],[192.2,9.15],[216.2,9.28],[232.2,9.07],[236.2,9.3],[390.2,10.99]],source:"AAVSO, binned by Strope, Schaefer & Henden 2010"},{id:"v382-vel-1999",kind:"nova",designation:"V382 Vel",name:"Nova Velorum 1999",raHours:10.74678,decDeg:-52.42533,peakMagnitude:2.88,peakJd:245132225e-2,startJd:245132075e-2,lightCurve:[[0,2.99],[1.5,2.88],[2.5,3.46],[4.5,3.98],[5,4.32],[5.5,4.23],[7.5,4.85],[21.75,6.67],[30.25,7.2],[40.25,7.41],[93.25,7.95],[97.25,8.25],[101.25,8],[113.25,7.96],[129.25,8.5],[155.25,8.47],[163.25,9.1],[179.25,9],[187.25,8.7],[195.25,9.15],[211.25,9.23],[235.25,9.8],[243.25,9.71],[299.25,10.42],[383.25,10.52],[415.25,10.81]],source:"AAVSO, binned by Strope, Schaefer & Henden 2010"},{id:"v1494-aql-1999",kind:"nova",designation:"V1494 Aql",name:"Nova Aquilae 1999",raHours:19.38482,decDeg:4.9555,peakMagnitude:4.11,peakJd:245151575e-2,startJd:245151425e-2,lightCurve:[[0,5.15],[.5,4.86],[1,4.27],[1.5,4.11],[2.5,4.35],[5,5.48],[10.5,6.26],[14.25,6.28],[20.25,7.43],[24.25,7.25],[25.25,7.63],[27.25,7.7],[29.25,7.42],[33.25,8.08],[35.25,8.03],[36.25,7.6],[37.25,7.6],[46.25,8.5],[54.25,8.28],[56.25,8.63],[58.25,8.4],[61.25,9.53],[62.25,9],[64.25,9.13],[69.25,8.58],[70.25,8.9],[72.25,8.88],[75.25,8.57],[77.25,9],[79.25,8.8],[81.25,9.7],[83.25,9.6],[85.25,9.8],[86.75,9.5],[88.75,9.54],[90.75,8.9],[92.75,8.85],[96.75,9.63],[102.75,9.7],[104.75,8.98],[106.75,8.73],[116.75,9.63],[118.75,9.6],[120.75,9.07],[122.75,9.26],[124.75,9.8],[128.75,9.36],[134.75,9.75],[147.75,9.92],[155.75,9.81],[259.75,10.96]],source:"AAVSO, binned by Strope, Schaefer & Henden 2010"},{id:"v4743-sgr-2002",kind:"nova",designation:"V4743 Sgr",name:"Nova Sagittarii 2002",raHours:19.01926,decDeg:-22.00167,peakMagnitude:5,peakJd:245253775e-2,startJd:245253675e-2,lightCurve:[[0,5.2],[1,5],[2,5.89],[2.5,5.91],[3.5,6.43],[5,6.45],[5.5,6.86],[6,6.59],[7,6.77],[7.5,7.31],[8.5,6.99],[9,7.09],[10.5,7.86],[11,7.58],[11.5,7.89],[15.75,8.33],[17.75,8.18],[18.75,8.58],[19.75,8.44],[22.75,8.83],[23.75,8.6],[24.75,8.85],[27.75,8.83],[30.75,9.4],[31.75,9.09],[36.25,9.08],[38.25,9.34],[62.25,9.75],[66.25,10.1],[70.25,9.7],[74.25,10],[171.25,10.9]],source:"AAVSO, binned by Strope, Schaefer & Henden 2010"},{id:"rs-oph-2006",kind:"nova",designation:"RS Oph",name:"Nova Ophiuchi 2006",raHours:17.83699,decDeg:-6.70792,peakMagnitude:4.8,peakJd:2453779,startJd:2453779,lightCurve:[[0,4.8],[1.25,4.97],[2.75,5.78],[3.25,5.7],[3.75,6.24],[4.25,6.05],[4.75,6.38],[5.25,6.3],[8.5,7.25],[14.5,7.95],[24.5,8.55],[29.5,9.08],[48,9.87],[80,10.28],[107,11.54],[119,11.54],[139,11.98],[147,11.83],[163,12.03],[171,11.97],[175,11.65],[183,11.84],[195,11.64],[203,11.8],[207,12.13],[219,11.45],[277,11.68],[325,11],[341,11.53],[357,11.62],[373,11.3],[405,11.5],[421,11.17],[469,10.96],[501,11.22],[549,10.75],[581,11.08],[597,10.98]],source:"AAVSO, binned by Strope, Schaefer & Henden 2010",note:"A recurrent nova, erupting every twenty years or so (1898, 1907, 1933, 1945, 1958, 1967, 1985, 2006, 2021)."},{id:"v1280-sco-2007",kind:"nova",designation:"V1280 Sco",name:"Nova Scorpii 2007",raHours:16.96145,decDeg:-32.34325,peakMagnitude:3.8,peakJd:2454149,startJd:2454136,lightCurve:[[0,9.7],[13,3.8],[34,5.8],[103,15]],source:"AAVSO (discovery, peak, dust minimum); t2 from Das et al. 2008",note:"Faded from sight quickly when dust formed around it, three weeks after its peak."},{id:"v339-del-2013",kind:"nova",designation:"V339 Del",name:"Nova Delphini 2013",raHours:20.39186,decDeg:20.76772,peakMagnitude:4.4,peakJd:24565214e-1,startJd:24565214e-1,lightCurve:[[0,4.4],[11,6.4],[20,7.4]],source:"Gehrz et al. 2015 (peak, t2, t3)",note:"High in the summer evening sky of the northern hemisphere, and widely photographed."},{id:"v1369-cen-2013",kind:"nova",designation:"V1369 Cen",name:"Nova Centauri 2013",raHours:13.9126,decDeg:-59.15114,peakMagnitude:3.48,peakJd:245663965e-2,startJd:24566285e-1,lightCurve:[[0,5.33],[1.57,4.08],[2.75,3.73],[4.57,4.16],[5.96,4.15],[10.26,3.77],[11.15,3.48],[12.14,3.74],[14.17,4.78],[15.46,4.97],[23.16,4.22],[26.25,4.32],[27.31,4.82],[29.56,5.11],[32.66,4.71],[33.84,4.86],[36.05,4.46],[37.15,4.99],[41.42,4.59],[42.37,4.93],[43.37,4.82],[44.54,5.09],[49.95,5.38],[51.99,5.82],[54.21,5.77]],source:"AAVSO, binned by day, as plotted by Izzo 2017 (arXiv:1704.07214, figure 1)",note:"Discovered on 2 December 2013 by John Seach at magnitude 5.5, it flared several times, reaching about 3.3 around 14 December: the brightest nova of the century so far, and a southern one."},{id:"rs-oph-2021",kind:"nova",designation:"RS Oph",name:"Nova Ophiuchi 2021",raHours:17.83699,decDeg:-6.70792,peakMagnitude:4.6,peakJd:2459436,startJd:2459435,lightCurve:[[0,5],[1,4.6],[2.25,4.77],[3.75,5.58],[4.25,5.5],[4.75,6.04],[5.25,5.85],[5.75,6.18],[6.25,6.1],[9.5,7.05],[15.5,7.75],[25.5,8.35],[30.5,8.88],[49,9.67],[81,10.08],[108,11.34],[120,11.34],[140,11.78],[148,11.63],[164,11.83],[172,11.77],[176,11.45],[184,11.64],[196,11.44],[204,11.6],[208,11.93],[220,11.25],[278,11.48],[326,10.8],[342,11.33],[358,11.42],[374,11.1],[406,11.3],[422,10.97],[470,10.76],[502,11.02],[550,10.55],[582,10.88],[598,10.78]],source:"Recorded discovery and peak (8 and 9 August 2021); curve borrowed from its 2006 eruption",note:"RS Oph's latest eruption, discovered on 8 August 2021. The decline is its 2006 one."}];class jm{static UNIX_EPOCH_JD=24405875e-1;static aroundDate(t){const e=this.julianDayOf(t);return xu.filter(i=>this.magnitudeAt(i,e)!==void 0)}static appearancesAt(t,e){const i=this.julianDayOf(t),n=[];for(const s of xu){const a=this.magnitudeAt(s,i);a!==void 0&&n.push({outburst:s,position:Pn.ofJ2000(s.raHours,s.decDeg,t,e),magnitude:a})}return n.sort((s,a)=>s.magnitude-a.magnitude)}static brightestAt(t,e){return this.appearancesAt(t,e)[0]}static byId(t){return xu.find(e=>e.id===t)}static magnitudeAt(t,e){const i=t.lightCurve,n=e-t.startJd;if(i.length===0||n<i[0][0]||n>i[i.length-1][0])return;let s=1;for(;s<i.length-1&&i[s][0]<n;)s++;const[a,o]=i[s-1]??i[0],[c,l]=i[s]??i[0];if(c===a)return o;const h=Math.min(1,Math.max(0,(n-a)/(c-a)));return o+h*(l-o)}static julianDayOf(t){return t.getTime()/864e5+this.UNIX_EPOCH_JD}}const BE=[{id:"quadrantids",code:"QUA",name:"Quadrantids",radiantRaHours:15.33,radiantDecDeg:49.7,start:{month:12,day:28},peak:{month:1,day:3},end:{month:1,day:12},peakZhr:110,velocityKmS:41,populationIndex:2.1},{id:"lyrids",code:"LYR",name:"April Lyrids",radiantRaHours:18.13,radiantDecDeg:33.3,start:{month:4,day:16},peak:{month:4,day:22},end:{month:4,day:25},peakZhr:18,velocityKmS:49,populationIndex:2.1},{id:"eta-aquariids",code:"ETA",name:"eta Aquariids",radiantRaHours:22.53,radiantDecDeg:-1,start:{month:4,day:19},peak:{month:5,day:6},end:{month:5,day:28},peakZhr:50,velocityKmS:66,populationIndex:2.4},{id:"alpha-capricornids",code:"CAP",name:"alpha Capricornids",radiantRaHours:20.47,radiantDecDeg:-9.2,start:{month:7,day:3},peak:{month:7,day:30},end:{month:8,day:15},peakZhr:5,velocityKmS:23,populationIndex:2.5},{id:"southern-delta-aquariids",code:"SDA",name:"Southern delta Aquariids",radiantRaHours:22.67,radiantDecDeg:-16.4,start:{month:7,day:12},peak:{month:7,day:30},end:{month:8,day:23},peakZhr:25,velocityKmS:41,populationIndex:3.2},{id:"perseids",code:"PER",name:"Perseids",radiantRaHours:3.22,radiantDecDeg:58,start:{month:7,day:17},peak:{month:8,day:12},end:{month:8,day:24},peakZhr:100,velocityKmS:59,populationIndex:2.2},{id:"southern-taurids",code:"STA",name:"Southern Taurids",radiantRaHours:3.47,radiantDecDeg:13,start:{month:9,day:10},peak:{month:10,day:10},end:{month:11,day:20},peakZhr:5,velocityKmS:27,populationIndex:2.3},{id:"draconids",code:"DRA",name:"October Draconids",radiantRaHours:17.47,radiantDecDeg:54,start:{month:10,day:6},peak:{month:10,day:8},end:{month:10,day:10},peakZhr:10,velocityKmS:20,populationIndex:2.6},{id:"orionids",code:"ORI",name:"Orionids",radiantRaHours:6.35,radiantDecDeg:15.6,start:{month:10,day:2},peak:{month:10,day:21},end:{month:11,day:7},peakZhr:20,velocityKmS:66,populationIndex:2.5},{id:"northern-taurids",code:"NTA",name:"Northern Taurids",radiantRaHours:3.87,radiantDecDeg:22,start:{month:10,day:20},peak:{month:11,day:12},end:{month:12,day:10},peakZhr:5,velocityKmS:29,populationIndex:2.3},{id:"leonids",code:"LEO",name:"Leonids",radiantRaHours:10.13,radiantDecDeg:21.6,start:{month:11,day:6},peak:{month:11,day:17},end:{month:11,day:30},peakZhr:15,velocityKmS:71,populationIndex:2.5},{id:"geminids",code:"GEM",name:"Geminids",radiantRaHours:7.47,radiantDecDeg:32.3,start:{month:12,day:4},peak:{month:12,day:14},end:{month:12,day:17},peakZhr:150,velocityKmS:35,populationIndex:2.6},{id:"ursids",code:"URS",name:"Ursids",radiantRaHours:14.47,radiantDecDeg:75.3,start:{month:12,day:17},peak:{month:12,day:22},end:{month:12,day:26},peakZhr:10,velocityKmS:33,populationIndex:3}],Ul=6.5;class yu{static activeAt(t){return BE.flatMap(e=>{const i=this.nearness(e,t);return i<=0?[]:[{shower:e,zhr:e.peakZhr*i,nearness:i}]})}static nearness(t,e){const i=this.dayOfYear(e),n=this.dayOfYear(this.asDate(t.start)),s=this.dayOfYear(this.asDate(t.peak)),a=this.dayOfYear(this.asDate(t.end)),o=this.wrappedDelta(i,s),c=this.wrappedDelta(s,n),l=this.wrappedDelta(a,s);return o<0?o<-c?0:1+o/c:o>0?o>l?0:1-o/l:1}static observedRatePerHour(t,e,i,n=Ul){if(e<=0)return 0;const s=Ul-n;return t*Math.sin(e*Math.PI/180)/Math.pow(i,s)}static radiantPosition(t,e,i){return Pn.ofJ2000(t.radiantRaHours,t.radiantDecDeg,e,i)}static dayOfYear(t){const e=Date.UTC(t.getUTCFullYear(),0,1);return Math.floor((Date.UTC(t.getUTCFullYear(),t.getUTCMonth(),t.getUTCDate())-e)/864e5)+1}static asDate(t){return new Date(Date.UTC(2001,t.month-1,t.day))}static wrappedDelta(t,e){const i=t-e;return i>182?i-365:i<-182?i+365:i}}class ti{static QUIET_RATE_PER_HOUR=2;static APEX_RATE_PER_HOUR=8;static POPULATION_INDEX=3;static apexPosition(t,e){const i=$e(t),n=new Zl(0,lw(t).elon-90,1),s=Cr(Ow(i),F0(n,i)),a=U0(s);return k0(a.ra,a.dec,t,e)}static observedRatePerHour(t,e=Ul){const i=ti.APEX_RATE_PER_HOUR*Math.max(0,Math.sin(t*Math.PI/180)),n=Ul-e;return(ti.QUIET_RATE_PER_HOUR+i)/Math.pow(ti.POPULATION_INDEX,n)}static schedule(t){const e=new Ql(t.seed^1542469173);return Pa.schedule(t).map(i=>{const n=ti.toCartesian({altitudeDeg:Math.asin(e.next())*180/Math.PI,azimuthDeg:e.between(0,360)}),s=i.fromRadiantDeg*Math.PI/180,a=ti.turnAround(n,e.between(0,360)),o={x:n.x*Math.cos(s)+a.x*Math.sin(s),y:n.y*Math.cos(s)+a.y*Math.sin(s),z:n.z*Math.cos(s)+a.z*Math.sin(s)};return{...i,radiant:ti.toHorizontal(o),bearingDeg:ti.bearingFrom(o,n)}})}static turnAround(t,e){const[i,n]=ti.basisAround(t),s=e*Math.PI/180;return{x:i.x*Math.cos(s)+n.x*Math.sin(s),y:i.y*Math.cos(s)+n.y*Math.sin(s),z:i.z*Math.cos(s)+n.z*Math.sin(s)}}static bearingFrom(t,e){const[i,n]=ti.basisAround(t),s=t.x*e.x+t.y*e.y+t.z*e.z,a=ti.normalise({x:e.x-t.x*s,y:e.y-t.y*s,z:e.z-t.z*s});return(Math.atan2(a.x*n.x+a.y*n.y+a.z*n.z,a.x*i.x+a.y*i.y+a.z*i.z)*180/Math.PI%360+360)%360}static basisAround(t){const e=Math.abs(t.y)<.9?{x:0,y:1,z:0}:{x:1,y:0,z:0},i=ti.normalise(ti.cross(t,e));return[i,ti.normalise(ti.cross(t,i))]}static toHorizontal(t){const e=Math.hypot(t.x,t.y,t.z)||1;return{altitudeDeg:Math.asin(Math.min(1,Math.max(-1,t.y/e)))*180/Math.PI,azimuthDeg:(Math.atan2(t.x,-t.z)*180/Math.PI%360+360)%360}}static appearanceOf(t){const e=ti.toCartesian(t.radiant??{altitudeDeg:90,azimuthDeg:0}),i=ti.turnAround(e,t.bearingDeg),n=t.fromRadiantDeg*Math.PI/180;return ti.toHorizontal({x:e.x*Math.cos(n)+i.x*Math.sin(n),y:e.y*Math.cos(n)+i.y*Math.sin(n),z:e.z*Math.cos(n)+i.z*Math.sin(n)})}static toCartesian(t){const e=t.altitudeDeg*Math.PI/180,i=t.azimuthDeg*Math.PI/180,n=Math.cos(e);return{x:n*Math.sin(i),y:Math.sin(e),z:-n*Math.cos(i)}}static cross(t,e){return{x:t.y*e.z-t.z*e.y,y:t.z*e.x-t.x*e.z,z:t.x*e.y-t.y*e.x}}static normalise(t){const e=Math.hypot(t.x,t.y,t.z)||1;return{x:t.x/e,y:t.y/e,z:t.z/e}}static TYPICAL_VELOCITY_KM_S=40}const Qm="https://ufoathome.org/tle/index.json";class Ii{static MAX_ELEMENT_AGE_DAYS=7;static DAY_MS=864e5;fetchImpl;indexUrls;index;files=new Map;constructor(t={}){this.fetchImpl=t.fetchImpl??fetch.bind(globalThis),this.indexUrls=t.indexUrls??Ii.defaultIndexUrls()}static defaultIndexUrls(){const t=[];return typeof location<"u"&&/^https?:$/.test(location.protocol)&&t.push(new URL("/tle/index.json",location.href).href),t.includes(Qm)||t.push(Qm),t}static FIRST_SNAPSHOT="2021-02-22";async covers(t){const e=Date.parse(`${Ii.FIRST_SNAPSHOT}T00:00:00Z`)-Ii.MAX_ELEMENT_AGE_DAYS*Ii.DAY_MS;if(t.getTime()<e)return!1;const i=await this.loadIndex();return i?Object.values(i.index.kinds).some(n=>t.getTime()>=Date.parse(n.from)-Ii.MAX_ELEMENT_AGE_DAYS*Ii.DAY_MS&&t.getTime()<=Date.parse(n.to)+Ii.MAX_ELEMENT_AGE_DAYS*Ii.DAY_MS):!1}async at(t){const e=await this.loadIndex();if(!e)return;const{index:i,base:n}=e,s=[],a=[];for(const o of Object.keys(i.kinds)){const c=await this.kindAt(o,t,i,n);s.push(...c),a.push(this.coverageOf(o,t,i,c.length>0))}return{objects:s,coverage:a,credit:i.credit,creditUrl:i.source}}async kindAt(t,e,i,n){const s=e.getTime(),a=i.binDays*Ii.DAY_MS,o=Math.floor(s/a),c=s-o*a<a/2?o-1:o+1,l=new Set(i.kinds[t].bins),h=[o,c].map(v=>new Date(v*a).toISOString().slice(0,10)).filter(v=>l.has(v));if(h.length===0)return[];const[u,...d]=await Promise.all([this.json(new URL(`objects-${t}.json`,n).href),...h.map(v=>this.binary(new URL(`${t}/${v}.bin`,n).href))]),f=new Map;for(const v of d)for(const m of Ii.decode(v,i.recordBytes)){const g=f.get(m.norad);(!g||Math.abs(m.epochMs-s)<Math.abs(g.epochMs-s))&&f.set(m.norad,m)}const p=[];for(const v of f.values()){const m=Math.abs(v.epochMs-s)/Ii.DAY_MS;if(m>Ii.MAX_ELEMENT_AGE_DAYS)continue;const g=u[v.norad]??{name:String(v.norad)};g.launch&&Date.parse(`${g.launch}T00:00:00Z`)>s||p.push({norad:v.norad,name:g.name,kind:t,launch:g.launch,stdMag:g.stdMag,elements:v,ageDays:m})}return p}coverageOf(t,e,i,n){const{from:s,to:a}=i.kinds[t],o=e.getTime(),c=Ii.MAX_ELEMENT_AGE_DAYS*Ii.DAY_MS,l=n?"covered":o<Date.parse(s)-c?"before":o>Date.parse(a)+c?"after":"gap";return{kind:t,status:l,from:s,to:a}}static decode(t,e){const i=new DataView(t),n=[];for(let s=0;s+e<=t.byteLength;s+=e)n.push({norad:i.getUint32(s,!0),epochMs:i.getFloat64(s+4,!0),bstar:i.getFloat32(s+12,!0),inclinationDeg:i.getFloat32(s+16,!0),raanDeg:i.getFloat32(s+20,!0),eccentricity:i.getFloat32(s+24,!0),argOfPerigeeDeg:i.getFloat32(s+28,!0),meanAnomalyDeg:i.getFloat32(s+32,!0),meanMotion:i.getFloat64(s+36,!0)});return n}loadIndex(){return this.index??=(async()=>{for(const t of this.indexUrls)try{const e=await this.fetchImpl(t);if(!e.ok)continue;return{index:await e.json(),base:t}}catch{}})(),this.index}json(t){return this.cached(t,async e=>e.json())}binary(t){return this.cached(t,async e=>e.arrayBuffer())}cached(t,e){let i=this.files.get(t);return i||(i=this.fetchImpl(t).then(n=>{if(!n.ok)throw new Error(`${t}: ${n.status}`);return e(n)}),i.catch(()=>this.files.delete(t)),this.files.set(t,i)),i}}class HE{lowerM;upperM;add(t,e){if(!(t<=0)){if(e.behindM!==void 0){const i=Te.sizeMAt(e.behindM,t);this.lowerM=this.lowerM===void 0?i:Math.max(this.lowerM,i)}if(e.inFrontM!==void 0){const i=Te.sizeMAt(e.inFrontM,t);this.upperM=this.upperM===void 0?i:Math.min(this.upperM,i)}}}get sizeRange(){return{minM:this.lowerM,maxM:this.upperM}}get empty(){return this.lowerM===void 0&&this.upperM===void 0}get contradictory(){return this.lowerM!==void 0&&this.upperM!==void 0&&this.lowerM>this.upperM}distanceRangeAt(t){return t<=0?{}:{minM:this.lowerM===void 0?void 0:Te.distanceMAt(this.lowerM,t),maxM:this.upperM===void 0?void 0:Te.distanceMAt(this.upperM,t)}}clear(){this.lowerM=void 0,this.upperM=void 0}}class Oa{static DEG_PER_SECOND=360/86164.0905;static degOver(t){return Math.max(0,t)*Oa.DEG_PER_SECOND}static instants(t,e){if(!(e>0))return 1;const i=Oa.degOver(t)/e;return i<1?1:Math.min(Oa.MAX_INSTANTS,Math.max(2,Math.ceil(i)))}static MAX_INSTANTS=64}class zi{static EYE={apertureMm:7,exposureSeconds:.1,resolutionArcsec:60};static WAVELENGTH_M=55e-8;static ARCSEC_PER_RADIAN=180*3600/Math.PI;static UNKNOWN_CAMERA_FOCAL_MM=50;static UNKNOWN_CAMERA_DETAIL_UM=20;static get skyDriftArcsecPerSecond(){return Oa.DEG_PER_SECOND*3600}static graspOf(t,e={}){const i=e.exposureSeconds??t.exposureSeconds,n=e.fNumber??t.fNumber;if(i===void 0||n===void 0||!(i>0)||!(n>0))return zi.EYE;const s=e.focalLengthMm??t.frame?.focalLengthMm??zi.UNKNOWN_CAMERA_FOCAL_MM,a=s/n,o=zi.resolutionArcsec(t,s,a);return{apertureMm:a,exposureSeconds:Math.min(i,zi.trailLimitedSeconds(o)),resolutionArcsec:o}}static resolutionArcsec(t,e,i){const s=(t.detailUm??zi.UNKNOWN_CAMERA_DETAIL_UM)/1e3/e*zi.ARCSEC_PER_RADIAN,a=1.22*zi.WAVELENGTH_M/(i/1e3)*zi.ARCSEC_PER_RADIAN;return Math.max(s,a)}static trailLimitedSeconds(t){return t/zi.skyDriftArcsecPerSecond}static gainOverEye(t,e={}){const i=zi.graspOf(t,e),n=zi.EYE,s=(i.apertureMm/n.apertureMm)**2,a=i.exposureSeconds/n.exposureSeconds,o=(n.resolutionArcsec/i.resolutionArcsec)**2;return 1.25*Math.log10(s*a*o)}static gainFor(t,e){const i=e.fieldOfViewDeg===void 0?void 0:fi.focalLengthMmFor(t,e.fieldOfViewDeg);return zi.gainOverEye(t,{fNumber:e.fNumber,focalLengthMm:i,exposureSeconds:e.exposureSeconds})}}const tg=111320,po=Math.PI/180,GE=1.02,VE=1;class Io{static of(t,e){const i=Io.sightings(t,e);if(i.length<2)return;const n=Io.baseline(i);if(!n)return;const{near:s,far:a,closedM:o}=n,c=Math.tan(a.widthDeg/2*po)===0?0:Math.tan(s.widthDeg/2*po)/Math.tan(a.widthDeg/2*po);if(c<GE)return;const l=o/(c-1),h=Te.sizeMAt(l,s.widthDeg),u=i.map(d=>({t:d.t,m:Te.distanceMAt(h,d.widthDeg)}));return{widthM:h,distanceM:u,nearestM:Math.min(...u.map(d=>d.m)),fromT:a.t,toT:s.t,closedM:o}}static sightings(t,e){return t.timeline.allKeyframes.flatMap(i=>{const n=i.shapes.find(o=>o.sourceId===e)?.shape,s=n?.angular?.widthDeg,a=di(t,i.t);return s===void 0||s<=0||a?.lat===void 0||a.lng===void 0?[]:[{t:i.t,widthDeg:s,lat:a.lat,lng:a.lng,sightAzimuthDeg:n?.aim?.azimuthDeg??a.headingDeg}]}).sort((i,n)=>i.t-n.t)}static baseline(t){let e;for(const i of t)for(const n of t){if(i.t>=n.t)continue;const s=Io.closedAlongSight(i,n),[a,o,c]=s>=0?[n,i,s]:[i,n,-s];c<VE||a.widthDeg<=o.widthDeg||(!e||c>e.closedM)&&(e={near:a,far:o,closedM:c})}return e}static closedAlongSight(t,e){const i=(e.lat-t.lat)*tg,n=(e.lng-t.lng)*tg*Math.cos(t.lat*po),s=(t.sightAzimuthDeg??0)*po;return i*Math.cos(s)+n*Math.sin(s)}}class ki{static CONVENTIONAL_M=5;static NEAREST_M=.2;static MARGIN=1.1;static resolve(t){if(t.statedM!==void 0&&t.statedM>0)return{distanceM:ki.atLeastNearest(t.statedM),basis:"stated"};if(t.hypothesisM!==void 0&&t.hypothesisM>0)return{distanceM:ki.atLeastNearest(t.hypothesisM),basis:"hypothesis"};if(t.derivedM!==void 0&&t.derivedM>0)return{distanceM:ki.atLeastNearest(t.derivedM),basis:"derived"};const e=ki.largest(t.range?.minM,t.crossing?.behindM),i=ki.smallest(t.range?.maxM,t.crossing?.inFrontM),n=e===void 0?void 0:e*ki.MARGIN,s=i===void 0?void 0:i/ki.MARGIN;return n!==void 0&&s!==void 0?{distanceM:ki.atLeastNearest(n<=s?Math.sqrt(n*s):n),basis:"bounded"}:n!==void 0?{distanceM:ki.atLeastNearest(n),basis:"bounded"}:s!==void 0&&s<ki.CONVENTIONAL_M?{distanceM:ki.atLeastNearest(s),basis:"bounded"}:{distanceM:ki.CONVENTIONAL_M,basis:"conventional"}}static atLeastNearest(t){return Math.max(ki.NEAREST_M,t)}static largest(...t){const e=t.filter(i=>i!==void 0&&i>0);return e.length===0?void 0:Math.max(...e)}static smallest(...t){const e=t.filter(i=>i!==void 0&&i>0);return e.length===0?void 0:Math.min(...e)}}const _u=Math.PI/180;class te{constructor(t,e,i){this.body=t,this.ground=e;const n=[...t.track].sort((s,a)=>s.t-a.t);this.keys=this.place(n,i);for(const s of n)te.collect(this.motionKeys,s.t,s.motions),te.collect(this.lightKeys,s.t,s.lights)}static EYE_HEIGHT_M=1.6;static MAX_RANGE_M=3e4;static DEFAULT_SIZE={widthM:1,lengthM:1,heightM:1};static DEFAULT_APPEARANCE={color:"#c8c8c8",albedo:.5,luminanceCdM2:0};keys;motionKeys=new Map;lightKeys=new Map;static collect(t,e,i){for(const[n,s]of Object.entries(i??{})){const a=t.get(n)??[];a.push({t:e,value:s}),t.set(n,a)}}motionsAt(t){return te.channelsAt(this.motionKeys,t,0)}lightsAt(t){return this.lightKeys.size>0?te.channelsAt(this.lightKeys,t,void 0):void 0}static channelsAt(t,e,i){const n={};for(const[s,a]of t){let o=a.length-1;for(;o>=0&&a[o].t>e;)o--;if(o<0){i!==void 0&&(n[s]=i);continue}const c=a[o],l=a[Math.min(o+1,a.length-1)],h=l===c||l.t===c.t?0:Math.min(1,(e-c.t)/(l.t-c.t));n[s]=te.lerp(c.value,l.value,h)}return n}static eyeOf(t,e,i){const n=di(t,0),s=di(t,e),o=n?.lat!==void 0&&n.lng!==void 0&&s?.lat!==void 0&&s.lng!==void 0?ai(s.lat,s.lng,n.lat,n.lng):void 0,c=o?o.x:0,l=o?-o.z:0;return{eastM:c,northM:l,upM:i.heightAt(c,l)+te.EYE_HEIGHT_M+(s?.elevationM??0),headingDeg:s?.headingDeg}}static lineOfSightMeetsGround(t,e,i,n){const s=te.directionOf(e,i),a=l=>t.upM+s.upM*l-n.heightAt(t.eastM+s.eastM*l,t.northM+s.northM*l);let o=0,c=0;for(;c<te.MAX_RANGE_M;){if(c=o+Math.max(.5,o*.01),a(c)<=0){for(let l=0;l<30;l++){const h=(o+c)/2;a(h)<=0?c=h:o=h}return c}o=c}}static directionOf(t,e){const i=t*_u,n=e*_u;return{eastM:Math.sin(i)*Math.cos(n),northM:Math.cos(i)*Math.cos(n),upM:Math.sin(n)}}at(t){const e=this.keys;if(e.length===0||t<e[0].t)return;let i=e.length-1;for(;i>0&&e[i].t>t;)i--;const n=e[i];if(!n.present)return;const s=e[Math.min(i+1,e.length-1)],a=s===n||s.t===n.t?0:Math.min(1,(t-n.t)/(s.t-n.t)),o=te.lerp(n.eastM,s.eastM,a),c=te.lerp(n.northM,s.northM,a),l={widthM:te.lerp(n.sizeM.widthM,s.sizeM.widthM,a),lengthM:te.lerp(n.sizeM.lengthM,s.sizeM.lengthM,a),heightM:te.lerp(n.sizeM.heightM,s.sizeM.heightM,a)},h={headingDeg:te.lerpAngle(n.attitude.headingDeg,s.attitude.headingDeg,a),pitchDeg:te.lerp(n.attitude.pitchDeg,s.attitude.pitchDeg,a),rollDeg:te.lerp(n.attitude.rollDeg,s.attitude.rollDeg,a)};let u;if("aboveGroundM"in n.vertical&&"aboveGroundM"in s.vertical){const d=te.lerp(n.vertical.aboveGroundM,s.vertical.aboveGroundM,a);u=this.groundUnderFootprint(o,c,l,h.headingDeg)+d+l.heightM/2}else u=te.lerp(this.centreUpOf(n),this.centreUpOf(s),a);return{id:this.body.id,model:this.body.model,explains:this.body.explains??[],outlineNode:this.body.outlineNode,eastM:o,northM:c,upM:u,sizeM:l,attitude:h,appearance:{color:(a<1?n:s).appearance.color,albedo:te.lerp(n.appearance.albedo,s.appearance.albedo,a),luminanceCdM2:te.lerp(n.appearance.luminanceCdM2,s.appearance.luminanceCdM2,a)},flame:te.flameBetween(n.flame,s.flame,a),motions:this.motionsAt(t),lights:this.lightsAt(t),throwsFlame:this.body.track.some(d=>d.flame!==void 0&&d.flame.luminanceCdM2>0)}}static flameBetween(t,e,i){if(!t||t.luminanceCdM2<=0)return i>=1&&e&&e.luminanceCdM2>0?e:void 0;const n=t,s=e??t,a={...i<1?n:s,lengthM:te.lerp(n.lengthM,s.lengthM,i),widthM:te.lerp(n.widthM,s.widthM,i),luminanceCdM2:te.lerp(n.luminanceCdM2,s.luminanceCdM2,i)};return a.luminanceCdM2>0?a:void 0}centreUpOf(t){return"upM"in t.vertical?t.vertical.upM:this.groundUnderFootprint(t.eastM,t.northM,t.sizeM,t.attitude.headingDeg)+t.vertical.aboveGroundM+t.sizeM.heightM/2}groundUnderFootprint(t,e,i,n){const s=n*_u,a={eastM:Math.cos(s),northM:-Math.sin(s)},o={eastM:Math.sin(s),northM:Math.cos(s)};let c=this.ground.heightAt(t,e);for(const[l,h]of[[-1,-1],[1,-1],[-1,1],[1,1]]){const u=l*i.widthM/2,d=h*i.lengthM/2;c=Math.max(c,this.ground.heightAt(t+a.eastM*u+o.eastM*d,e+a.northM*u+o.northM*d))}return c}place(t,e){const i=[];let n;for(const s of t){const a=s.sizeM??n?.sizeM??te.DEFAULT_SIZE,o={headingDeg:s.attitude?.headingDeg??n?.attitude.headingDeg??0,pitchDeg:s.attitude?.pitchDeg??n?.attitude.pitchDeg??0,rollDeg:s.attitude?.rollDeg??n?.attitude.rollDeg??0},c={color:s.appearance?.color??n?.appearance.color??te.DEFAULT_APPEARANCE.color,albedo:s.appearance?.albedo??n?.appearance.albedo??te.DEFAULT_APPEARANCE.albedo,luminanceCdM2:s.appearance?.luminanceCdM2??n?.appearance.luminanceCdM2??te.DEFAULT_APPEARANCE.luminanceCdM2},l=this.positionOf(s,e)??(n&&{eastM:n.eastM,northM:n.northM,vertical:this.verticalOf(s)??n.vertical});if(!l)continue;const h=s.flame??n?.flame,u=s.present??n?.present??!0;n={t:s.t,...l,sizeM:a,attitude:o,appearance:c,flame:h,present:u},i.push(n)}return i}verticalOf(t){if(t.onGround)return{aboveGroundM:0};if(t.altitudeAboveGroundM!==void 0)return{aboveGroundM:t.altitudeAboveGroundM}}positionOf(t,e){if(t.eastM!==void 0&&t.northM!==void 0)return{eastM:t.eastM,northM:t.northM,vertical:this.verticalOf(t)??{aboveGroundM:0}};if(t.azimuthDeg===void 0||t.altitudeDeg===void 0)return;const i=e(t.t);if(!i)return;const n=t.distanceM??(t.onGround?te.lineOfSightMeetsGround(i,t.azimuthDeg,t.altitudeDeg,this.ground):void 0);if(n===void 0)return;const s=te.directionOf(t.azimuthDeg,t.altitudeDeg),a=i.eastM+s.eastM*n,o=i.northM+s.northM*n;return{eastM:a,northM:o,vertical:this.verticalOf(t)??{upM:i.upM+s.upM*n}}}static lerp(t,e,i){return t+(e-t)*i}static lerpAngle(t,e,i){const n=((e-t)%360+540)%360-180;return((t+n*i)%360+360)%360}}const ur=Math.PI/180,mo=180/Math.PI;class Qe{constructor(t){this.timeline=t}static DIRECTION_TOLERANCE_DEG=1;static SIZE_TOLERANCE=1.5;static RINGS=12;static SEGMENTS=24;at(t,e,i,n){const s=[];for(const a of e){const o=Qe.projectionOf(a,i,n?.(a));if(o)for(const c of a.explains){const l=this.timeline.getInterpolatedShapeAt(t,c);!l||l.transparency>=1||s.push({...Qe.compare(c,a.id,{aim:l.aim,angular:l.angular},o),title:l.title})}}return s}static compare(t,e,i,n){const s=[],a=i.aim?Qe.separationDeg(i.aim,n.aim):void 0;if(a!==void 0){const l=Math.max(i.angular?.widthDeg??0,n.angular.widthDeg)/2;a>Math.max(Qe.DIRECTION_TOLERANCE_DEG,l)&&s.push("direction")}const o=i.angular&&i.angular.widthDeg>0?n.angular.widthDeg/i.angular.widthDeg:void 0,c=i.angular&&i.angular.heightDeg>0?n.angular.heightDeg/i.angular.heightDeg:void 0;return o!==void 0&&!Qe.withinSize(o)&&s.push("width"),c!==void 0&&!Qe.withinSize(c)&&s.push("height"),{sourceId:t,bodyId:e,stated:i,predicted:n,separationDeg:a,widthRatio:o,heightRatio:c,disagreements:s}}static projectionOf(t,e,i){const n=i&&i.length>0?i:Qe.outlineOf(t),s=i&&i.length>0?Qe.centreOf(i):t,a=Qe.normalized({eastM:s.eastM-e.eastM,northM:s.northM-e.northM,upM:s.upM-e.upM});if(!a)return;const o=Qe.normalized({eastM:a.northM,northM:-a.eastM,upM:0})??{eastM:1,northM:0,upM:0},c=Qe.cross(o,a);let l=1/0,h=-1/0,u=1/0,d=-1/0;for(const f of n){const p={eastM:f.eastM-e.eastM,northM:f.northM-e.northM,upM:f.upM-e.upM},v=Qe.dot(p,a);if(v<=0)return;const m=Math.atan2(Qe.dot(p,o),v),g=Math.atan2(Qe.dot(p,c),v);l=Math.min(l,m),h=Math.max(h,m),u=Math.min(u,g),d=Math.max(d,g)}return{aim:{azimuthDeg:(Math.atan2(a.eastM,a.northM)*mo+360)%360,altitudeDeg:Math.asin(Math.max(-1,Math.min(1,a.upM)))*mo},angular:{widthDeg:(h-l)*mo,heightDeg:(d-u)*mo}}}static centreOf(t){const e=i=>(Math.min(...t.map(n=>n[i]))+Math.max(...t.map(n=>n[i])))/2;return{eastM:e("eastM"),northM:e("northM"),upM:e("upM")}}static separationDeg(t,e){const i=t.altitudeDeg*ur,n=e.altitudeDeg*ur,s=Math.sin(i)*Math.sin(n)+Math.cos(i)*Math.cos(n)*Math.cos((t.azimuthDeg-e.azimuthDeg)*ur);return Math.acos(Math.max(-1,Math.min(1,s)))*mo}static withinSize(t){return t<=Qe.SIZE_TOLERANCE&&t>=1/Qe.SIZE_TOLERANCE}static outlineOf(t){const e=t.sizeM.widthM/2,i=t.sizeM.lengthM/2,n=t.sizeM.heightM/2,s=[],a=t.model.url===void 0?t.model.id:void 0;if(a!==void 0&&a!=="box"&&G1.includes(a))for(let u=0;u<=Qe.RINGS;u++){const d=u/Qe.RINGS*Math.PI;for(let f=0;f<Qe.SEGMENTS;f++){const p=f/Qe.SEGMENTS*2*Math.PI;s.push([e*Math.sin(d)*Math.cos(p),i*Math.sin(d)*Math.sin(p),n*Math.cos(d)])}}else for(const u of[-e,e])for(const d of[-i,i])for(const f of[-n,n])s.push([u,d,f]);const c=t.attitude.headingDeg*ur,l=t.attitude.pitchDeg*ur,h=t.attitude.rollDeg*ur;return s.map(([u,d,f])=>{const p=u*Math.cos(h)+f*Math.sin(h),v=-u*Math.sin(h)+f*Math.cos(h),m=d*Math.cos(l)-v*Math.sin(l),g=d*Math.sin(l)+v*Math.cos(l);return{eastM:t.eastM+p*Math.cos(c)+m*Math.sin(c),northM:t.northM-p*Math.sin(c)+m*Math.cos(c),upM:t.upM+g}})}static dot(t,e){return t.eastM*e.eastM+t.northM*e.northM+t.upM*e.upM}static cross(t,e){return{eastM:t.northM*e.upM-t.upM*e.northM,northM:t.upM*e.eastM-t.eastM*e.upM,upM:t.eastM*e.northM-t.northM*e.eastM}}static normalized(t){const e=Math.hypot(t.eastM,t.northM,t.upM);return e>1e-9?{eastM:t.eastM/e,northM:t.northM/e,upM:t.upM/e}:void 0}}yg();const WE={sun:"Sun",moon:"Moon",Venus:"Venus",Mars:"Mars",Jupiter:"Jupiter",Saturn:"Saturn"},XE="{name} — mag {mag}, {alt}° above the horizon",YE="{name} — satellite, mag {mag}, {height} km up",qE="satellites-change",$E="rr0-confrontation",KE="{name} — mag {mag}, {alt}° below the horizontal",Su="Credits",eg="comet:",ig="nova:",ZE={building:"Building",tree:"Tree",shrub:"Shrub",bridge:"Bridge",crop:"Crop row",mound:"Stone heap",streetlight:"Streetlight",vehicle:"Vehicle",observer:"Observer",aircraft:"Aircraft",entity:"Being"},JE=new URL(""+new URL("stars-mag7.5-B43R6Wvg.bin",import.meta.url).href,import.meta.url).href,jE=new URL(""+new URL("stars-mag7.5-9-BLV2tFmZ.bin",import.meta.url).href,import.meta.url).href,QE=-18,tA={sun:{altitudeDeg:-3,azimuthDeg:180,magnitude:-26.7},moon:{altitudeDeg:-90,azimuthDeg:0,phase:{phaseFraction:0,illuminatedFraction:0},magnitude:-12.7},planets:[]},bu={lat:0,lng:0,elevationM:0,headingDeg:void 0,pitchDeg:0,fovDeg:60};class H0 extends HTMLElement{creditsButton;set ownCredits(t){this.creditsButton.hidden=!t}static get observedAttributes(){return["src","star-catalog-src","deep-star-catalog-src","show-compass","max-pixel-ratio",_r,Sr]}shadow;stageElement;frameElement;sceneCanvas;loaderNote;loaderNotVideo;ufoElement;sceneRenderer;hoverTooltip;resizeObserver;sizeEstimates=new Map;sizeEstimatesFor;distanceHypotheses=new Map;depths=new Map;directionScratch=new R;meteorScheduleFor;lightningScheduleFor;lightningFlashes=[];lastLightningT;lastTimeMs=0;interpretationShown;confrontationReadings=[];confrontationSignature="";comparing=!1;inTheRound=!0;lastSkyKey;starCatalog;starCatalogRequest=0;static tleArchive=new Ii;satellitesFor;satelliteRequest=0;satelliteStatus="none";satellites;satellitePassesMemo;starCatalogDepth=0;weatherAudio=new kE;vehicleAudio=new nv;vehicleHearing=new dl;animateWhilePausedValue=!1;set animateWhilePaused(t){t!==this.animateWhilePausedValue&&(this.animateWhilePausedValue=t,this.syncAnimationsToPlayback())}get animateWhilePaused(){return this.animateWhilePausedValue}thunderTimeoutId;handleFullscreenChange=()=>this.resizeToStage();handlePointerMove=t=>{this.sceneRenderer.setCompassHovered(!0);const e=this.ufoElement.canvasElement,i=e.getBoundingClientRect();if(i.width===0||i.height===0)return;const n=(t.clientX-i.left)/i.width*e.width,s=(t.clientY-i.top)/i.height*e.height;if(this.ufoElement.hasVisibleShapeAt(n,s)){this.hoverTooltip.hidden=!0;return}const a=(t.clientX-i.left)/i.width*2-1,o=-((t.clientY-i.top)/i.height*2-1),c=this.naming,l=c.names,h=this.sceneRenderer.pickBodyAt(a,o);if(h){this.showHoverTooltip(t,this.bodyName(h));return}const u=this.sceneRenderer.pickDecorAt(a,o),d=u?this.ufoElement.sighting.decor.find(v=>v.id===u):void 0;if(d){this.showHoverTooltip(t,this.said.read(d.title)||c.decorKind(d.kind,ZE[d.kind]));return}const f=this.sceneRenderer.pickSatelliteAt(a,o);if(f){this.showHoverTooltip(t,(l?.satelliteTooltip??YE).replace("{name}",f.name).replace("{mag}",f.magnitude.toLocaleString(void 0,{maximumFractionDigits:1})).replace("{height}",Math.round(f.heightKm).toLocaleString()));return}const p=this.sceneRenderer.pickStarAt(a,o);if(p){const v=p.star.mag,m=p.altitudeDeg,g=m<0?l?.starTooltipBelow??KE:l?.starTooltip??XE;this.showHoverTooltip(t,g.replace("{name}",c.star(p.star)).replace("{mag}",v.toLocaleString(void 0,{maximumFractionDigits:Math.abs(v)<1?2:1})).replace("{alt}",String(Math.round(Math.abs(m)))));return}this.hoverTooltip.hidden=!0};bodyName(t){const e=t.startsWith(eg)?t.slice(eg.length):void 0,i=e?X1.find(a=>a.id===e):void 0;if(i)return this.naming.comet(i);const n=t.startsWith(ig)?jm.byId(t.slice(ig.length)):void 0;if(n)return this.naming.nova(n);const s=WE[t];return s===void 0?t:this.naming.body(t,s)}get naming(){return this.sceneNaming}sceneNaming=new Jm;namesLanguage="en";async loadSceneNames(){const t=cg(pl.preferencesFor(this),lg);if(t===this.namesLanguage)return;this.namesLanguage=t;const e=await Xv(t);t===this.namesLanguage&&this.applySceneNaming(new Jm(e))}renderLoaderText(t,e){let i=0;const n=(s,a)=>{s.setAttribute("aria-label",a),s.replaceChildren(),a.split(" ").forEach((o,c)=>{c>0&&s.append(" ");const l=document.createElement("span");l.className="scene-loader-word",l.setAttribute("aria-hidden","true");for(const h of o){const u=document.createElement("span");u.className="scene-loader-letter",u.style.setProperty("--i",String(i++)),u.textContent=h,l.append(u)}s.append(l),i++})};n(this.loaderNotVideo,t),i+=6,n(this.loaderNote,e)}applySceneNaming(t){this.sceneNaming=t;const e=t.names?.credits??Su;this.creditsButton.title=e,this.creditsButton.setAttribute("aria-label",e),t.names&&this.renderLoaderText(t.names.notAVideo,t.names.isASimulation),this.sceneRenderer.setCompassPoints(t.names?.compassPoints)}showHoverTooltip(t,e){this.hoverTooltip.textContent=e,this.hoverTooltip.hidden=!1;const i=this.stageElement.getBoundingClientRect();this.hoverTooltip.style.left=`${t.clientX-i.left+12}px`,this.hoverTooltip.style.top=`${t.clientY-i.top+12}px`}handlePointerLeave=()=>{this.hoverTooltip.hidden=!0,this.sceneRenderer.setCompassHovered(!1)};handleLightningFlash(t){clearTimeout(this.thunderTimeoutId),this.thunderTimeoutId=window.setTimeout(()=>this.weatherAudio.playThunder(),pi.thunderDelayMs(t))}handleFirstInteraction=()=>{this.weatherAudio.resume(),this.vehicleAudio.resume(),!this.interacted&&(this.interacted=!0,this.setWeather(of(this.ufoElement.sighting,this.lastTimeMs)))};interacted=!1;handleTimeUpdate=t=>{this.lastTimeMs=t.detail.time,this.syncAnimationsToPlayback(),this.updateAstronomy(this.lastTimeMs),this.ufoElement.playbackState==="playing"&&this.sceneRenderer.frame(performance.now())};syncAnimationsToPlayback(){const t=this.ufoElement.playbackState==="playing",e=t||this.animateWhilePaused;this.sceneRenderer.setAnimationsRunning(e,t),this.weatherAudio.setPaused(!t),this.vehicleAudio.setPaused(!t),t||clearTimeout(this.thunderTimeoutId)}constructor(){super(),this.shadow=this.attachShadow({mode:"open"});const t=document.createElement("template");t.innerHTML=`<style>${cv}</style>${ov}`,this.shadow.appendChild(t.content.cloneNode(!0)),this.stageElement=this.shadow.getElementById("stage"),this.frameElement=this.shadow.getElementById("frame"),this.sceneCanvas=this.shadow.getElementById("scene-canvas"),this.sceneRenderer=new ke(this.sceneCanvas);const e=this.shadow.getElementById("scene-loader");this.loaderNote=this.shadow.getElementById("scene-loader-note"),this.loaderNotVideo=this.shadow.getElementById("scene-loader-not-video"),this.renderLoaderText("This is not a video","It is a real-time simulation."),this.sceneRenderer.onFirstFrameHold=s=>{e.hidden=!s,this.ufoElement.captionHeld=s},this.hoverTooltip=this.shadow.getElementById("hover-tooltip"),this.ufoElement=document.createElement(Au),this.ufoElement.classList.add("ufo-overlay"),this.ufoElement.paintsShapes=!1,this.forwardPlayerAttributes(),this.ufoElement.addEventListener("lookat",s=>this.lookToward(s.detail)),this.ufoElement.style.setProperty("--ufo-canvas-background","transparent"),this.ufoElement.style.setProperty("--ufo-canvas-border","none"),this.ufoElement.fullscreenTarget=this.stageElement,this.shadow.getElementById("ufo-slot").replaceWith(this.ufoElement),this.ufoElement.creditShownExternally=!0,this.creditsButton=this.shadow.getElementById("credits-button");const i=this.shadow.getElementById("credits-panel"),n=this.shadow.getElementById("credits-list");i.addEventListener("beforetoggle",s=>{s.newState==="open"&&$n.fill(n,this)}),this.creditsButton.title=Su,this.creditsButton.setAttribute("aria-label",Su),this.sceneRenderer.onMapSubjectBounds=s=>this.ufoElement.setMapSubjectBounds(s),this.ufoElement.addEventListener("timeupdate",this.handleTimeUpdate),this.ufoElement.seekPreviewPainter=(s,a)=>this.seekPreviewOf(a).paint(s,a),this.ufoElement.addEventListener("mutedchange",()=>this.weatherAudio.setLevel(this.ufoElement.level)),this.ufoElement.addEventListener("referenceview",s=>this.applyReferenceView(s.detail)),this.ufoElement.canvasElement.addEventListener("pointermove",this.handlePointerMove),this.ufoElement.canvasElement.addEventListener("pointerleave",this.handlePointerLeave);for(const s of["pointerdown","pointerup","touchend","click","keydown"])this.addEventListener(s,this.handleFirstInteraction,!0)}get said(){return this.saidTexts??=new Ks(pl.preferencesFor(this))}saidTexts;connectedCallback(){this.saidTexts=void 0,this.loadSceneNames(),this.sceneRenderer.restoreContext(),this.resizeToStage(),this.updateAstronomy(this.lastTimeMs),this.loadStars(),this.resizeObserver=new ResizeObserver(()=>this.resizeToStage()),this.resizeObserver.observe(this.frameElement),document.addEventListener("fullscreenchange",this.handleFullscreenChange);const t=this.getAttribute("src");t&&this.loadFromSrc(t)}disconnectedCallback(){this.resizeObserver?.disconnect(),document.removeEventListener("fullscreenchange",this.handleFullscreenChange),this.sceneRenderer.stopTwinkle(),clearTimeout(this.thunderTimeoutId),this.weatherAudio.dispose(),this.vehicleAudio.dispose(),this.seekPreview?.dispose(),this.seekPreview=void 0,queueMicrotask(()=>{this.isConnected||this.sceneRenderer.releaseContext()})}attributeChangedCallback(t,e,i){if(t==="src"&&i&&i!==e&&this.isConnected&&this.loadFromSrc(i),(t==="star-catalog-src"||t==="deep-star-catalog-src")&&i!==e&&this.isConnected&&this.loadStars(),t==="show-compass"&&i!==e&&this.sceneRenderer.setShowCompass(this.hasAttribute("show-compass")),t==="max-pixel-ratio"&&i!==e){const n=Number(i);this.sceneRenderer.setMaxPixelRatio(Number.isFinite(n)&&n>0?n:Math.min(window.devicePixelRatio||1,2))}(t===_r||t===Sr)&&i!==e&&this.forwardPlayerAttributes()}forwardPlayerAttributes(){for(const t of[_r,Sr]){const e=this.getAttribute(t);e===null?this.ufoElement.removeAttribute(t):this.ufoElement.setAttribute(t,e)}}setCompassForced(t){this.sceneRenderer.setCompassForced(t)}lookToward(t){const e=di(this.ufoElement.sighting,this.lastTimeMs);if(t.kind==="observer"||e?.lat===void 0||e.lng===void 0||e.headingDeg===void 0){this.setLookOffset(0,0);return}const{x:i,z:n}=ai(t.lat,t.lng,e.lat,e.lng);if(Math.hypot(i,n)<1)return this.setLookOffset(0,0);const s=(Math.atan2(i,-n)*180/Math.PI+360)%360;this.setLookOffset(((s-e.headingDeg)%360+540)%360-180,-e.pitchDeg)}setLookOffset(t,e){this.sceneRenderer.setLookOffset(t,e),this.ufoElement.setLookOffset(t,e),this.updateAstronomy(this.lastTimeMs)}setIndoorLook(t,e){this.sceneRenderer.setIndoorLook(t,e)}setCloudRendering(t){this.sceneRenderer.setCloudRendering(t)}setWeather(t){this.sceneRenderer.setWeather(t),this.weatherAudio.setAmbient(t.precipitationType,t.precipitationIntensity*(t.precipitationAmount??1),t.windSpeed)}pickCloudAt(t,e){return this.sceneRenderer.pickCloudAt(t,e)}cloudDirectionAt(t,e){return this.sceneRenderer.cloudDirectionAt(t,e)}pickDecorAt(t,e){return this.sceneRenderer.pickDecorAt(t,e)}bodyScreenBox(t){return this.sceneRenderer.bodyScreenBox(t)}pickPlacedBodyAt(t,e){return this.sceneRenderer.pickPlacedBodyAt(t,e)}resumeWeatherAudio(){this.weatherAudio.resume(),this.vehicleAudio.resume()}async loadFromSrc(t){const e=rg.json(t);this.holdForNewScene(e);const i=await e;this.documentUrl=new URL(t,location.href).href,this.sightingData=i}holdForNewScene(t){this.sceneRenderer.holdForNewScene(t)}get documentUrl(){return this.sceneRenderer.documentUrl}set documentUrl(t){this.sceneRenderer.documentUrl=t}get sightingData(){return this.ufoElement.sightingData}set sightingData(t){this.ufoElement.sightingData=t,this.seekPreview?.recordingChanged(t),this.interpretationShown=this.inTheRound?this.ufoElement.sighting.interpretation:void 0,this.applyFrameFormat(),this.lastTimeMs=0,this.sceneRenderer.compileNextFrameOffThread(),this.updateAstronomy(0)}seekPreview;seekPreviewOf(t){const e=this.sceneCanvas.width>0&&this.sceneCanvas.height>0?this.sceneCanvas.width/this.sceneCanvas.height:1.7777777777777777,i=Math.round(t.width/e);return t.height!==i&&(t.height=i),this.seekPreview??=new Fl(this,()=>document.createElement(Zd))}showAt(t){this.ufoElement.currentTime=t,this.framesAtAsk=this.sceneRenderer.framesDrawn}framesAtAsk=0;snapshotTo(t){if(this.sceneRenderer.frame(performance.now()),this.sceneRenderer.framesDrawn===this.framesAtAsk)return!1;const e=t.getContext("2d");return e?(e.drawImage(this.sceneCanvas,0,0,t.width,t.height),!0):!1}referenceAspect(t){return this.sceneRenderer.referenceAspect(t)}screenPointOf(t){return this.sceneRenderer.screenPointOf(t)}directionAt(t,e){return this.sceneRenderer.directionAt(t,e)}referenceFailedToLoad(t){return this.sceneRenderer.referenceFailedToLoad(t)}applyReferenceView(t){this.sceneRenderer.setReferencesShown(t.shown);for(const e of this.ufoElement.sighting.references)this.sceneRenderer.setReferenceView(e.id,{opacity:t.opacity})}get currentTerrainAttribution(){return this.sceneRenderer.currentTerrainAttribution}get currentRoadAttribution(){return this.sceneRenderer.currentRoadAttribution}setTerrainProviders(t){this.sceneRenderer.setTerrainProviders(t)}setDecorModelProvider(t){this.sceneRenderer.setDecorModelProvider(t)}get decorModelCredits(){return this.sceneRenderer.currentDecorModelCredits}applyFrameFormat(){const t=this.ufoElement.sighting.instrument,e=Te.CANVAS_HEIGHT_PX,i=fi.frameWidthPx(t,e);this.frameElement.style.setProperty("--frame-aspect",`${i} / ${e}`)}resizeToStage(){const t=this.frameElement.getBoundingClientRect(),e=Math.max(1,Math.round(t.width)),i=Math.max(1,Math.round(t.height));this.sceneCanvas.width=e,this.sceneCanvas.height=i,this.sceneRenderer.resize(e,i)}async loadStars(){const t=[{magnitudeLimit:vu,url:this.getAttribute("star-catalog-src")??JE},{magnitudeLimit:Mu,url:this.getAttribute("deep-star-catalog-src")??jE}],e=this.instrumentReach(),i=++this.starCatalogRequest;this.starCatalogDepth=e>vu?Mu:vu;const n=await qn.upTo(t,e);i===this.starCatalogRequest&&(this.starCatalog=n,this.sceneRenderer.compileNextFrameOffThread(),this.updateAstronomy(this.lastTimeMs))}ensureStarsDeepEnough(){!this.starCatalog||this.starCatalogDepth>=Mu||this.instrumentReach()<=this.starCatalogDepth||this.loadStars()}instrumentReach(){const t=this.ufoElement.sighting,e=zi.gainFor(t.instrument,{fNumber:di(t,0)?.fNumber,fieldOfViewDeg:Ji.fovOf(t,0),exposureSeconds:t.exposure});return Ad(QE,e)}updateAstronomy(t){this.ensureStarsDeepEnough(),this.applySceneAt(t);const e=Cn.windowEndingAt(t,this.exposureSeconds()),i=e.seconds,n=this.degreesPerPixelAt(t),s=Oa.instants(i,n),a=Math.max(s,this.ufoElement.exposureTimes(t).length,Cn.instants(this.ufoElement.sighting.decor,di(this.ufoElement.sighting,t)?.elevationM??0,e.fromMs,i,n));if(a<=1){this.sceneRenderer.setExposure(1);return}this.sceneRenderer.setExposure(a,o=>this.applySceneAt(e.fromMs+e.ms*o/(a-1),{sky:Math.floor(o*s/a)!==Math.floor((o-1)*s/a),stepMs:e.ms/a}))}exposureSeconds(){return this.ufoElement.sighting.exposure??0}degreesPerPixelAt(t){const e=this.sceneCanvas.height;return e<=0?0:Ji.fovOf(this.ufoElement.sighting,t)/e}applySceneAt(t,e){const i=this.ufoElement.sighting;this.setWeather(of(i,t)),this.sceneRenderer.setInstrument(i.instrument),this.sceneRenderer.setLightPollution(i.lightPollution),e||this.vehicleAudio.setVoices(this.vehicleHearing.at(i,t)),this.updateMeteorShower(i,t),this.updateLightning(i,t,e!==void 0),this.sceneRenderer.setDecor(i.decor);const n=di(i,t);this.sceneRenderer.setReferences(i.references,n?.lat!==void 0&&n.lng!==void 0?{lat:n.lat,lng:n.lng}:void 0);const s=di(i,0),a=Vr(i,0),o=Object.fromEntries(fl(Vr(i,t)).map(y=>[y.id,nf(t,i.weatherTrack,a,s,n,y.id)]));this.sceneRenderer.setCloudOffset(nf(t,i.weatherTrack,a,s,n),o),this.sceneRenderer.setObserverPose(n??bu),this.sceneRenderer.setLensOptics(this.lensOpticsAt(t)),this.sceneRenderer.setInstrumentGain(zi.gainFor(i.instrument,{fNumber:n?.fNumber,fieldOfViewDeg:Ji.fovOf(i,t),exposureSeconds:i.exposure}),i.instrument.detailUm!==void 0),this.sceneRenderer.setMedium(i.instrument.medium,i.exposure,n?.fNumber??i.instrument.fNumber,i.iso),this.sceneRenderer.setGait(_e.bodyAt(i,t,this.ufoElement.steadyObserver)),this.sceneRenderer.updateDecorAnchoring(di(i,0),n,t),this.placeBodiesAt(t,e===void 0),this.sceneRenderer.updateDecorLitState(t,e?.stepMs??0),this.sceneRenderer.setTerrainOrigin(n?.lat,n?.lng,()=>{this.placeBodiesAt(this.lastTimeMs,!0),this.sceneRenderer.render()}),this.sceneRenderer.setStatedRoads(i.roads),this.pushPhenomenaAt(t);const c=n?.lat??bu.lat,l=n?.lng??bu.lng,h=Hc(i.event.time??{},l,i.event.utcOffsetHours),u={lat:c,lng:l,elevationM:n?.elevationM??0};if(this.pushSatellitesAt(h,t,u),e&&!e.sky)return;if(!h){this.sceneRenderer.setAstronomy(tA);return}const d=new Date(h.getTime()+t),f=Math.max(1,Math.round(.25*this.degreesPerPixelAt(t)/Oa.DEG_PER_SECOND*1e3)),p=Math.max(1e-8,this.degreesPerPixelAt(t)*.1),v=`${Math.floor(d.getTime()/f)}|${Math.round(c/p)}|${Math.round(l/p)}|${Math.round(u.elevationM)}|${this.starCatalog?this.starCatalogDepth:0}`;if(v===this.lastSkyKey){this.sceneRenderer.render();return}this.lastSkyKey=v;const m={...$h("Sun",d,u),magnitude:Kh("Sun",d)},g={...$h("Moon",d,u),phase:Fw(d),magnitude:Kh("Moon",d)},S=Nw.map(y=>({body:y,position:$h(y,d,u),magnitude:Kh(y,d)}));this.sceneRenderer.setAstronomy({sun:m,moon:g,planets:S,comet:this.cometAt(d,u),novae:jm.appearancesAt(d,u).map(({outburst:y,position:M,magnitude:b})=>({id:y.id,position:M,magnitude:b})),stars:this.starCatalog?{catalog:this.starCatalog,date:d,observer:u}:void 0,frame:{date:d,observer:u}}),this.ufoElement.setSunAltitude(m.altitudeDeg)}pushSatellitesAt(t,e,i){if(this.ensureSatellites(t),!t||!this.satellites){this.sceneRenderer.setSatellites([]);return}const n=new Date(t.getTime()+e),s=[];for(const a of this.satellites.passes.positionsAt(n,i,-1))a.magnitude!==void 0&&s.push({norad:a.object.norad,name:a.object.name,position:{altitudeDeg:a.altitudeDeg,azimuthDeg:a.azimuthDeg},magnitude:a.magnitude,heightKm:a.heightKm});this.sceneRenderer.setSatellites(s)}ensureSatellites(t){const e=t?String(t.getTime()):"";if(e===this.satellitesFor)return;this.satellitesFor=e,this.satellites=void 0,this.satellitePassesMemo=void 0;const i=++this.satelliteRequest;if(!t){this.satelliteStatus="none";return}this.satelliteStatus="loading";const n=a=>{i===this.satelliteRequest&&(this.satelliteStatus=a,this.isConnected&&this.dispatchEvent(new CustomEvent(qE)))},s=H0.tleArchive;(async()=>{if(!await s.covers(t))return n("outside");const[a,o]=await Promise.all([s.at(t),is(()=>import("./SatellitePasses-Pfro2-0Z.js"),[],import.meta.url)]);if(i===this.satelliteRequest){if(!a)return n("unavailable");this.satellites={snapshot:a,passes:new o.SatellitePasses(a.objects)},n("ready"),this.isConnected&&this.updateAstronomy(this.lastTimeMs)}})().catch(()=>n("unavailable"))}get satelliteState(){const t=this.satellites?.snapshot;return{status:this.satelliteStatus,coverage:t?.coverage,credit:t?.credit,creditUrl:t?.creditUrl}}satellitePassesDuring(t){const e=this.satellites,i=this.ufoElement.sighting,n=di(i,0),s=i.event.place?.[0],a=n?.lat??s?.lat,o=n?.lng??s?.lng;if(!e||a===void 0||o===void 0)return[];const c=Hc(i.event.time??{},o,i.event.utcOffsetHours);if(!c)return[];const l=Math.min(Math.max(t,0),4*36e5),h={lat:a,lng:o,elevationM:n?.elevationM??0},u=JSON.stringify([this.satellitesFor,c.getTime(),a,o,h.elevationM,l]);if(this.satellitePassesMemo?.key===u)return this.satellitePassesMemo.passes;const d=Math.max(10,Math.ceil(l/1e3/600)),f=e.passes.passesDuring(c,new Date(c.getTime()+l),h,d);return this.satellitePassesMemo={key:u,passes:f},f}cometAt(t,e){const i=zE.brightestAt(t,e);if(i)return{id:i.apparition.id,position:i.position,tailEnd:i.tailEnd,magnitude:i.magnitude}}pushPhenomenaAt(t){const e=this.ufoElement.sighting;e!==this.sizeEstimatesFor&&(this.sizeEstimates.clear(),this.distanceHypotheses.clear(),this.sizeEstimatesFor=e);const i=e.timeline,n=this.ufoElement.canvasElement,s=this.ufoElement.frameShiftPx,a=this.projectionAt(t),o=new Map,c=new Map,l=new Set;for(const p of i.sourceIds){const v=i.getInterpolatedShapeAt(t,p);if(!v)continue;const m={...v,bounds:{...v.bounds,x:v.bounds.x+s.x,y:v.bounds.y+s.y}};o.set(p,m);const g=v.aim?this.sceneRenderer.screenPointOf(In.directionOf(v.aim,this.directionScratch)):{ndcX:(m.bounds.x+m.bounds.width/2)/n.width*2-1,ndcY:-((m.bounds.y+m.bounds.height/2)/n.height*2-1)},S=g!==void 0&&Math.abs(g.ndcX)<=1&&Math.abs(g.ndcY)<=1,y=S?this.sceneRenderer.decorDistancesAt(g.ndcX,g.ndcY,p):{};l.add(p),(S||v.aim)&&l.delete(p);const M=v.angular?.widthDeg??a.pxToDeg(v.bounds.width),b=this.sizeEstimateOf(p);b.add(M,y);const w=Io.of(e,p);c.set(p,ki.resolve({hypothesisM:this.distanceHypotheses.get(p),derivedM:w&&M>0?Te.distanceMAt(w.widthM,M):void 0,range:b.distanceRangeAt(M),crossing:y}))}for(const[p,v]of o)for(const[m,g]of o){if(m===p||g.transparency>=1||g.bounds.width*g.bounds.height<=v.bounds.width*v.bounds.height||!(v.bounds.x>=g.bounds.x&&v.bounds.y>=g.bounds.y&&v.bounds.x+v.bounds.width<=g.bounds.x+g.bounds.width&&v.bounds.y+v.bounds.height<=g.bounds.y+g.bounds.height))continue;const y=c.get(m);y&&c.set(p,{distanceM:y.distanceM*.999,basis:y.basis});break}this.depths=c;const h=i.sourceIds,u=[];for(const[p,v]of o)u.push({sourceId:p,shape:v,distanceM:c.get(p).distanceM,renderOrder:h.indexOf(p),aim:v.aim,hidden:l.has(p)||this.interpretationShown!==void 0&&(!this.comparing||v.transparency>=1),ghost:this.interpretationShown!==void 0&&this.comparing});const f=(di(e,t)?.rollDeg??0)+_e.bodyAt(e,t,this.ufoElement.steadyObserver).rollDeg;this.sceneRenderer.setPhenomena(u,{projection:a,canvasWidthPx:n.width,canvasHeightPx:n.height,scale:Math.max(1,this.sceneCanvas.height/Math.max(1,n.height)),starPoints:fi.starPointsOf(e.instrument),rollRad:f*Math.PI/180})}get interpretation(){return this.interpretationShown}set interpretation(t){this.interpretationShown=t,this.updateAstronomy(this.lastTimeMs)}get accountInTheRound(){return this.inTheRound}set accountInTheRound(t){this.inTheRound=t}get compareAccount(){return this.comparing}set compareAccount(t){this.comparing=t,this.updateAstronomy(this.lastTimeMs)}get confrontation(){return this.confrontationReadings}groundAlong(t,e,i){const n=this.sceneRenderer.bodyGround,s=te.eyeOf(this.ufoElement.sighting,i,n);return s?te.lineOfSightMeetsGround(s,t,e,n):void 0}bodyReading(t,e){const i=this.sceneRenderer.bodyGround,n=this.ufoElement.sighting,s=d=>te.eyeOf(n,d,i),a=new te(t,i,s).at(e),o=s(e);if(!a||!o)return;const c=a.eastM-o.eastM,l=a.northM-o.northM,h=a.upM-o.upM,u=Math.hypot(c,l);return{azimuthDeg:(Math.atan2(c,l)*180/Math.PI+360)%360,altitudeDeg:Math.atan2(h,u)*180/Math.PI,distanceM:Math.hypot(u,h),eastM:a.eastM,northM:a.northM,aboveGroundM:a.upM-a.sizeM.heightM/2-i.heightAt(a.eastM,a.northM),sizeM:a.sizeM,attitude:a.attitude,appearance:a.appearance}}directionToBody(t,e){const i=this.sceneRenderer.bodyGround,n=this.ufoElement.sighting,s=p=>te.eyeOf(n,p,i),a=new te(t,i,s),o=a.at(e)?e:t.track[0]?.t,c=o===void 0?void 0:a.at(o),l=o===void 0?void 0:s(o);if(!c||!l)return;const h=c.eastM-l.eastM,u=c.northM-l.northM,d=c.upM-l.upM,f=Math.hypot(h,u);if(!(f===0&&d===0))return{azimuthDeg:(Math.atan2(h,u)*180/Math.PI+360)%360,altitudeDeg:Math.atan2(d,f)*180/Math.PI}}placeBodiesAt(t,e){const i=this.interpretationShown,n=this.ufoElement.sighting;let s=[],a=[];const o=this.sceneRenderer.bodyGround,c=p=>te.eyeOf(n,p,o);i&&(s=i.bodies.map(p=>new te(p,o,c).at(t)).filter(p=>p!==void 0));const l=Vr(n,t),h=l.windDirectionDeg*Math.PI/180,u={x:l.windSpeed*Math.sin(h),z:-l.windSpeed*Math.cos(h)};this.sceneRenderer.setBodies(s,t/1e3,i?.bodies.map(p=>p.id)??[],i?.smoke??[],u);const d=i&&this.comparing?c(t):void 0;if(d&&(a=new Qe(n.timeline).at(t,s,d,p=>p.outlineNode?this.sceneRenderer.bodyOutline?.(p.id,p.outlineNode):void 0)),this.confrontationReadings=a,!e)return;const f=JSON.stringify(a);f!==this.confrontationSignature&&(this.confrontationSignature=f,this.dispatchEvent(new CustomEvent($E,{detail:a})))}setDistanceHypothesis(t,e){e===void 0||!(e>0)?this.distanceHypotheses.delete(t):this.distanceHypotheses.set(t,e),this.updateAstronomy(this.lastTimeMs)}depthOf(t){return this.depths.get(t)}sizeRangeOf(t){return this.sizeEstimateOf(t).sizeRange}distanceRangeAt(t,e){const i=this.ufoElement.sighting.timeline.getInterpolatedShapeAt(e,t);if(!i)return{};const n=i.angular?.widthDeg??this.projectionAt(e).pxToDeg(i.bounds.width);return this.sizeEstimateOf(t).distanceRangeAt(n)}sizeContradictory(t){return this.sizeEstimateOf(t).contradictory}updateMeteorShower(t,e){this.ensureMeteorSchedule(t),this.sceneRenderer.updateMeteors(e)}updateLightning(t,e,i){if(this.ensureLightningSchedule(t),this.sceneRenderer.updateLightning(e),i)return;const n=this.lastLightningT;if(this.lastLightningT=e,n===void 0||e<n||this.ufoElement.playbackState!=="playing")return;const s=this.lightningFlashes.filter(a=>a.t>n&&a.t<=e).pop();s&&Vr(t,s.t).storm&&this.handleLightningFlash(s)}ensureLightningSchedule(t){const e=Vr(t,0).precipitationIntensity,i=`${this.meteorInputsOf(t)}|${e}`;if(i===this.lightningScheduleFor)return;this.lightningScheduleFor=i;const n=t.event.time,s=t.event.place?.[0],a=n?.year!==void 0?Hc(n,s?.lng??0,t.event.utcOffsetHours):void 0,o=(t.event.durationSeconds??0)*1e3||t.timeline.duration||2e4,c=Math.round((a?.getTime()??0)/1e3)+Math.round((s?.lat??0)*1e3)+7;this.lightningFlashes=pi.schedule({durationMs:o,seed:c,intensity:e}),this.sceneRenderer.setLightning(this.lightningFlashes)}ensureMeteorSchedule(t){const e=this.meteorInputsOf(t);e!==this.meteorScheduleFor&&(this.meteorScheduleFor=e,this.scheduleMeteors(t))}meteorInputsOf(t){const e=t.event.place?.[0],i=t.event.time;return JSON.stringify([e?.lat,e?.lng,i?.year,i?.month,i?.day,i?.hour,i?.minute,i?.second,t.event.utcOffsetHours,t.event.durationSeconds,t.timeline.duration])}scheduleMeteors(t){const e=t.event.place?.[0],i=t.event.time,n=e?.lat!==void 0&&e.lng!==void 0&&i?.year!==void 0?Hc(i,e.lng,t.event.utcOffsetHours):void 0;if(!n||e?.lat===void 0||e.lng===void 0){this.sceneRenderer.setMeteorShower([],0,0);return}const s={lat:e.lat,lng:e.lng,elevationM:0},a=(t.event.durationSeconds??0)*1e3||t.timeline.duration||2e4,o=Math.round(n.getTime()/1e3)+Math.round(e.lat*1e3),c=ti.schedule({ratePerHour:ti.observedRatePerHour(ti.apexPosition(n,s).altitudeDeg),durationMs:a,velocityKmS:ti.TYPICAL_VELOCITY_KM_S,seed:o}),l=yu.activeAt(n).map(u=>{const d=yu.radiantPosition(u.shower,n,s);return{entry:u,position:d,rate:yu.observedRatePerHour(u.zhr,d.altitudeDeg,u.shower.populationIndex)}}).sort((u,d)=>d.rate-u.rate)[0];if(!l||l.rate<=0){this.sceneRenderer.setMeteorShower(c,0,0);return}const h=Pa.schedule({ratePerHour:l.rate,durationMs:a,velocityKmS:l.entry.shower.velocityKmS,seed:o+1});this.sceneRenderer.setMeteorShower([...h,...c],l.position.altitudeDeg,l.position.azimuthDeg)}meteorByRank(t){this.ensureMeteorSchedule(this.ufoElement.sighting);const e=[...this.sceneRenderer.meteorSchedule].filter(s=>s.t+s.durationMs<=this.ufoElement.seekableDuration).sort((s,a)=>a.brightness-s.brightness);if(e.length===0)return;const i=e[t%e.length],n=this.sceneRenderer.meteorMidpoint(i);if(n)return{t:Math.round(i.t+i.durationMs*.45),...n}}lensOpticsAt(t){const e=this.ufoElement.sighting,i=e.instrument,n=i.frame,s=di(e,t),a=s?.fNumber??i.fNumber;if(!n||a===void 0)return;const o=fi.focalLengthMmFor(i,Ji.fovOf(e,t));if(o!==void 0)return{focalLengthMm:o,fNumber:a,focusDistance:s?.focusDistanceM??0,frameHeightMm:n.heightMm}}projectionAt(t){const e=this.ufoElement.sighting;return Ss.of(e.instrument,Te.CANVAS_HEIGHT_PX,Ji.fovOf(e,t))}sizeEstimateOf(t){let e=this.sizeEstimates.get(t);return e||(e=new HE,this.sizeEstimates.set(t,e)),e}}const Zd="rr0-scene";function eA(){yg(),customElements.get(Zd)||customElements.define(Zd,H0)}eA();export{LM as $,rA as A,ie as B,st as C,mp as D,Dt as E,hA as F,cA as G,Vg as H,oA as I,lA as J,xs as K,Ko as L,XM as M,ac as N,Be as O,Qg as P,Qi as Q,zo as R,Gi as S,iA as T,Ce as U,xt as V,Zi as W,aA as X,Un as Y,Gg as Z,lp as _,sA as a,vl as a0,dd as a1,wl as a2,bi as a3,Jg as a4,y0 as a5,_0 as a6,re as a7,na as a8,$o as a9,Vi as aa,Rs as ab,nA as b,fA as c,yl as d,dA as e,Jt as f,R as g,jf as h,uA as i,pA as j,DM as k,wa as l,oh as m,P2 as n,oe as o,Re as p,Nu as q,wi as r,Wg as s,Ds as t,zM as u,ya as v,ji as w,_n as x,we as y,ce as z};
|
|
7832
|
+
`);let s=qn.cache.get(n);return s||(s=Promise.all(i.map(a=>qn.load(a.url))).then(a=>a.reduce((o,c)=>qn.concat(o,c))),qn.cache.set(n,s)),s}static parse(t){const e=t.byteLength/(4*Float32Array.BYTES_PER_ELEMENT),i=e*Float32Array.BYTES_PER_ELEMENT;return{count:e,ra:new Float32Array(t,0*i,e),dec:new Float32Array(t,1*i,e),mag:new Float32Array(t,2*i,e),ci:new Float32Array(t,3*i,e)}}static concat(t,e){const i=(n,s)=>{const a=new Float32Array(n.length+s.length);return a.set(n,0),a.set(s,n.length),a};return{count:t.count+e.count,ra:i(t.ra,e.ra),dec:i(t.dec,e.dec),mag:i(t.mag,e.mag),ci:i(t.ci,e.ci)}}}class Jm{constructor(t){this.names=t}body(t,e){return this.names?.bodies[t]??e}star(t){return this.names?.stars[t.name]??t.name}comet(t){return this.names?.comets[t.id]??t.name}nova(t){return this.names?.novae[t.id]??t.name}satelliteClass(t){return this.names?.satelliteClasses[t.id]??t.name}shower(t){return this.names?.showers[t.id]??t.name}lightRig(t){return this.names?.lightRigs[t.id]??t.name}instrument(t){return this.names?.instruments[t.id]??t.name}decorKind(t,e){return this.names?.decorKinds[t]??e}point(t){return Ca.point(t,this.names?.compassPoints)}towards(t){return Ca.towards(t,this.names)}}const IE="“Thunder” by Jerimee",CE="https://creativecommons.org/licenses/by/3.0/",PE="CC BY 3.0";class $n{static fill(t,e){t.innerHTML="";const i=l=>t.appendChild(l),n=e.currentTerrainAttribution;n&&i($n.text(n));const s=e.currentRoadAttribution;s&&i($n.text(s));const a=e.ufoElement.observerMapCredit;a&&!n?.includes(a)&&i($n.text(a));for(const l of e.decorModelCredits){const h=l.author?` — ${l.author}`:"",u=document.createElement("li");l.sourceUrl?u.append($n.link(l.sourceUrl,l.title),document.createTextNode(`${h} (${l.license})`)):u.textContent=`${l.title}${h} (${l.license})`,i(u)}for(const l of e.ufoElement.sighting.references){if(!l.credit)continue;const h=document.createElement("li");l.creditUrl?h.appendChild($n.link(l.creditUrl,l.credit)):h.textContent=l.credit,i(h)}const o=e.satelliteState;if(o.status==="ready"&&o.credit){const l=document.createElement("li");l.appendChild($n.link(o.creditUrl??"",o.credit)),i(l)}const c=$n.text(`${IE} (`);c.append($n.link(CE,PE),document.createTextNode(")")),i(c)}static text(t){const e=document.createElement("li");return e.textContent=t,e}static link(t,e){const i=document.createElement("a");return i.href=t,i.target="_blank",i.rel="noopener",i.textContent=e,i}}const LE=new URL(""+new URL("rain-BvWZrB9h.ogg",import.meta.url).href,import.meta.url).href,OE=new URL(""+new URL("wind-BjklexY7.ogg",import.meta.url).href,import.meta.url).href,NE=new URL(""+new URL("thunder-DA48qs_v.wav",import.meta.url).href,import.meta.url).href,FE=20,UE=1;class kE{context;buffers=new Map;ambientSource;ambientGain;ambientKey="none";ambientToken=0;ambientVolume=0;windSource;windGain;windActive=!1;windToken=0;windVolume=0;paused=!0;requested={type:"none",intensity:0,windSpeed:0};level=1;master;output(t){return this.master||(this.master=t.createGain(),this.master.gain.value=this.level,this.master.connect(t.destination)),this.master}setLevel(t){this.level=t,this.master&&(this.master.gain.value=t)}resume(){if(!this.context){if(typeof AudioContext>"u")return;try{this.context=new AudioContext}catch(t){console.warn("WeatherAudio: Web Audio unavailable, weather sounds disabled:",t);return}}Da.unlock(this.context)}setAmbient(t,e,i){if(this.requested={type:t,intensity:e,windSpeed:i},!this.context)return;this.paused&&(t="none",e=0,i=0);const n=t==="rain"||t==="hail"?t:"none";if(this.ambientVolume=n==="hail"?Math.min(1,e*1.3+.2):n==="rain"?e:0,n!==this.ambientKey){this.ambientKey=n;const a=++this.ambientToken;this.stopSource(this.ambientSource,this.ambientGain),this.ambientSource=void 0,this.ambientGain=void 0,n!=="none"&&this.startLoop(LE,this.ambientVolume).then(o=>this.applyIfCurrent(o,a,()=>this.ambientToken,c=>{this.ambientSource=c?.source,this.ambientGain=c?.gain,c&&(c.gain.gain.value=this.ambientVolume)}))}else this.ambientGain&&(this.ambientGain.gain.value=this.ambientVolume);this.windVolume=Math.min(i/FE,1);const s=i>UE;if(s!==this.windActive){this.windActive=s;const a=++this.windToken;this.stopSource(this.windSource,this.windGain),this.windSource=void 0,this.windGain=void 0,s&&this.startLoop(OE,this.windVolume).then(o=>this.applyIfCurrent(o,a,()=>this.windToken,c=>{this.windSource=c?.source,this.windGain=c?.gain,c&&(c.gain.gain.value=this.windVolume)}))}else this.windGain&&(this.windGain.gain.value=this.windVolume)}setPaused(t){if(t===this.paused)return;this.paused=t;const{type:e,intensity:i,windSpeed:n}=this.requested;this.setAmbient(e,i,n)}playThunder(){!this.context||this.paused||this.playOneShot(NE,.9)}dispose(){this.ambientToken++,this.windToken++,this.stopSource(this.ambientSource,this.ambientGain),this.stopSource(this.windSource,this.windGain),this.ambientSource=void 0,this.ambientGain=void 0,this.windSource=void 0,this.windGain=void 0,this.context?.close(),this.context=void 0,this.master=void 0,this.buffers.clear()}applyIfCurrent(t,e,i,n){if(e!==i()){t?.source.stop();return}n(t)}async startLoop(t,e){const i=this.context;if(i)try{const n=await this.getBuffer(t),s=i.createBufferSource();s.buffer=n,s.loop=!0;const a=i.createGain();return a.gain.value=e,s.connect(a).connect(this.output(i)),s.start(),{source:s,gain:a}}catch(n){console.warn("Weather ambient sound failed to load, staying silent:",n);return}}async playOneShot(t,e){const i=this.context;if(i)try{const n=await this.getBuffer(t),s=i.createBufferSource();s.buffer=n;const a=i.createGain();a.gain.value=e,s.connect(a).connect(this.output(i)),s.start()}catch(n){console.warn("Thunder sound failed to load:",n)}}async getBuffer(t){const e=this.context;if(!e)throw new Error("WeatherAudio: AudioContext not ready — resume() must be called first");let i=this.buffers.get(t);return i||(i=fetch(t).then(n=>{if(!n.ok)throw new Error(`Audio fetch failed (${n.status}): ${t}`);return n.arrayBuffer()}).then(n=>e.decodeAudioData(n)),this.buffers.set(t,i)),i}stopSource(t,e){try{t?.stop()}catch{}t?.disconnect(),e?.disconnect()}}class Ms{constructor(t){this.elements=t;const{eccentricity:e,perihelionAu:i}=t,[n,s]=this.perifocalAxes(),a=Math.sqrt(Ms.SUN_GM_AU3_PER_DAY2*(1+e)/i);this.perihelionPosition=this.scale(n,i),this.perihelionVelocity=this.scale(s,a),this.inverseSemiMajorAxis=(1-e)/i}static SUN_GM_AU3_PER_DAY2=.0002959122082855911;static MAX_ITERATIONS=200;perihelionPosition;perihelionVelocity;inverseSemiMajorAxis;positionAt(t){const e=t-this.elements.perihelionJd,i=this.universalAnomaly(e),n=this.inverseSemiMajorAxis*i*i,s=this.elements.perihelionAu,a=1-i*i/s*Ms.stumpffC(n),o=e-i*i*i/Math.sqrt(Ms.SUN_GM_AU3_PER_DAY2)*Ms.stumpffS(n);return{x:a*this.perihelionPosition.x+o*this.perihelionVelocity.x,y:a*this.perihelionPosition.y+o*this.perihelionVelocity.y,z:a*this.perihelionPosition.z+o*this.perihelionVelocity.z}}heliocentricDistanceAt(t){const e=this.positionAt(t);return Math.hypot(e.x,e.y,e.z)}universalAnomaly(t){if(t===0)return 0;const e=Math.sign(t),i=Math.sqrt(Ms.SUN_GM_AU3_PER_DAY2)*Math.abs(t),n=o=>{const c=this.inverseSemiMajorAxis*o*o,l=this.elements.perihelionAu;return(1-this.inverseSemiMajorAxis*l)*o*o*o*Ms.stumpffS(c)+l*o};let s=Math.max(1,i/this.elements.perihelionAu);for(;n(s)<i;)s*=2;let a=0;for(let o=0;o<Ms.MAX_ITERATIONS&&s-a>1e-13*Math.max(1,s);o++){const c=(a+s)/2;n(c)<i?a=c:s=c}return e*(a+s)/2}perifocalAxes(){const t=this.elements.ascendingNodeDeg*Math.PI/180,e=this.elements.argumentOfPerihelionDeg*Math.PI/180,i=this.elements.inclinationDeg*Math.PI/180,n=Math.cos(t),s=Math.sin(t),a=Math.cos(e),o=Math.sin(e),c=Math.cos(i),l=Math.sin(i);return[{x:n*a-s*o*c,y:s*a+n*o*c,z:o*l},{x:-n*o-s*a*c,y:-s*o+n*a*c,z:a*l}]}scale(t,e){return{x:t.x*e,y:t.y*e,z:t.z*e}}static stumpffC(t){if(Math.abs(t)<1e-6)return 1/2-t/24+t*t/720;if(t>0)return(1-Math.cos(Math.sqrt(t)))/t;const e=Math.sqrt(-t);return(Math.cosh(e)-1)/-t}static stumpffS(t){if(Math.abs(t)<1e-6)return 1/6-t/120+t*t/5040;if(t>0){const i=Math.sqrt(t);return(i-Math.sin(i))/(i*i*i)}const e=Math.sqrt(-t);return(Math.sinh(e)-e)/(e*e*e)}}const X1=[{id:"halley-1910",designation:"1P/Halley",name:"Halley's Comet",orbit:{eccentricity:.9672960498922706,perihelionAu:.5872100477652511,inclinationDeg:162.218798367122,ascendingNodeDeg:58.56208298700436,argumentOfPerihelionDeg:111.7366940639061,perihelionJd:2.4187816784171113e6},peakMagnitude:0,peakOn:"1910-05-20",absoluteMagnitude:4.72,activityExponent:4,tailLengthDeg:100,tailLengthAu:.1638,note:"Passed 0.15 au from Earth on 20 May 1910, and the Earth crossed the outer tail the day before — the apparition that produced a genuine public panic."},{id:"brooks-1911",designation:"C/1911 O1",name:"Comet Brooks",orbit:{eccentricity:.9876404970138669,perihelionAu:.4898172916113738,inclinationDeg:33.34043866978714,ascendingNodeDeg:293.7022074981857,argumentOfPerihelionDeg:153.5578007321686,perihelionJd:2.4193378856140426e6},peakMagnitude:2,peakOn:"1911-10-25",absoluteMagnitude:5.59,activityExponent:4},{id:"skjellerup-maristany-1927",designation:"C/1927 X1",name:"Comet Skjellerup-Maristany",orbit:{eccentricity:.999839726885059,perihelionAu:.1761569619628186,inclinationDeg:85.1125991950808,ascendingNodeDeg:78.24360172472711,argumentOfPerihelionDeg:47.15877857390136,perihelionJd:2.4252326808989984e6},peakMagnitude:-6,peakOn:"1927-12-15",absoluteMagnitude:1.19,activityExponent:4,note:"One of the few comets of the century seen in full daylight."},{id:"de-kock-paraskevopoulos-1941",designation:"C/1941 B2",name:"Comet de Kock-Paraskevopoulos",orbit:{eccentricity:.9991026715181549,perihelionAu:.7900329662827822,inclinationDeg:168.2039226531089,ascendingNodeDeg:43.10609347214336,argumentOfPerihelionDeg:268.6990344196369,perihelionJd:2430022157765061e-9},peakMagnitude:2,peakOn:"1941-02-05",absoluteMagnitude:5.01,activityExponent:4},{id:"southern-1947",designation:"C/1947 X1",name:"the Southern Comet",orbit:{eccentricity:.9998424430916737,perihelionAu:.1100045955093761,inclinationDeg:138.5113919632757,ascendingNodeDeg:337.3114969669252,argumentOfPerihelionDeg:196.1820121395961,perihelionJd:2.4325220864727003e6},peakMagnitude:-3,peakOn:"1947-12-08",absoluteMagnitude:3.01,activityExponent:4,note:"A bright southern-hemisphere comet of December 1947, the month the American sighting wave of that year was still being argued over."},{id:"eclipse-1948",designation:"C/1948 V1",name:"the Eclipse Comet",orbit:{eccentricity:.9999130678247334,perihelionAu:.1354437057263306,inclinationDeg:23.11668597152911,ascendingNodeDeg:211.0454985994762,argumentOfPerihelionDeg:107.2474157073104,perihelionJd:2.4328519265329437e6},peakMagnitude:-2,peakOn:"1948-11-01",absoluteMagnitude:4.79,activityExponent:4,note:"Found during the total solar eclipse of 1 November 1948, which is how a comet that bright had gone unnoticed: it had been hidden in the Sun's glare."},{id:"arend-roland-1957",designation:"C/1956 R1",name:"Comet Arend-Roland",orbit:{eccentricity:1.0002570255357,perihelionAu:.3160532361485914,inclinationDeg:119.9440863251822,ascendingNodeDeg:215.8548157717755,argumentOfPerihelionDeg:308.775920364167,perihelionJd:2.4359365327396123e6},peakMagnitude:.5,peakOn:"1957-04-25",absoluteMagnitude:3.96,activityExponent:4,note:"Showed a spike pointing back TOWARD the Sun in late April 1957 — a real anti-tail, and much reported at the time."},{id:"mrkos-1957",designation:"C/1957 P1",name:"Comet Mrkos",orbit:{eccentricity:.9993521583504134,perihelionAu:.3549238508212375,inclinationDeg:93.9433042053929,ascendingNodeDeg:68.32441518619923,argumentOfPerihelionDeg:40.31823675802871,perihelionJd:243605193752228e-8},peakMagnitude:1,peakOn:"1957-08-05",absoluteMagnitude:5.07,activityExponent:4,note:"The second bright naked-eye comet of 1957, four months after Arend-Roland."},{id:"seki-lines-1962",designation:"C/1962 C1",name:"Comet Seki-Lines",orbit:{eccentricity:1.000003791331562,perihelionAu:.03139689112215131,inclinationDeg:65.01487186102287,ascendingNodeDeg:304.6776602796538,argumentOfPerihelionDeg:11.47295326312573,perihelionJd:2437756163010178e-9},peakMagnitude:-2.5,peakOn:"1962-04-01",absoluteMagnitude:9.3,activityExponent:4},{id:"ikeya-seki-1965",designation:"C/1965 S1",name:"Comet Ikeya-Seki",orbit:{eccentricity:.9999141178248997,perihelionAu:.007785966366889336,inclinationDeg:141.8642315267051,ascendingNodeDeg:346.9951764632611,argumentOfPerihelionDeg:69.04909813996062,perihelionJd:2.4390546837018197e6},peakMagnitude:-10,peakOn:"1965-10-21",alsoRecordedMagnitude:2,alsoRecordedOn:"1965-10-30",absoluteMagnitude:5.26,activityExponent:4.002,tailLengthDeg:25,tailLengthAu:.5048,note:"A sungrazer that passed 450 000 km above the Sun's surface and was seen beside it in broad daylight — the brightest comet of the twentieth century. It then stood in the dawn sky for a fortnight with a tail some 25 degrees long, which is the second magnitude recorded here."},{id:"bennett-1970",designation:"C/1969 Y1",name:"Comet Bennett",orbit:{eccentricity:.9962979048768408,perihelionAu:.5376209981502136,inclinationDeg:90.03975717147327,ascendingNodeDeg:224.6576652531314,argumentOfPerihelionDeg:354.1494209173161,perihelionJd:2.4406655455270996e6},peakMagnitude:0,peakOn:"1970-03-26",absoluteMagnitude:3.36,activityExponent:4},{id:"white-ortiz-bolelli-1970",designation:"C/1970 K1",name:"Comet White-Ortiz-Bolelli",orbit:{eccentricity:.9999488875801225,perihelionAu:.00884411465256722,inclinationDeg:138.9520738221631,ascendingNodeDeg:336.8194095816687,argumentOfPerihelionDeg:61.10224765396615,perihelionJd:2.4407209807728203e6},peakMagnitude:1,peakOn:"1970-05-22",absoluteMagnitude:4.35,activityExponent:4},{id:"kohoutek-1973",designation:"C/1973 E1",name:"Comet Kohoutek",orbit:{eccentricity:1.000007152175185,perihelionAu:.1424250377812859,inclinationDeg:14.30414984159355,ascendingNodeDeg:258.4893339663974,argumentOfPerihelionDeg:37.79772760699667,perihelionJd:2442044930687027e-9},peakMagnitude:0,peakOn:"1974-01-05",absoluteMagnitude:4.89,activityExponent:4,note:"Announced in advance as the comet of the century and remembered for disappointing: it was an ordinary naked-eye object, not the spectacle the press had promised."},{id:"west-1976",designation:"C/1975 V1",name:"Comet West",orbit:{eccentricity:1.000017859625611,perihelionAu:.1966006188461085,inclinationDeg:43.07319920579427,ascendingNodeDeg:118.9189245655447,argumentOfPerihelionDeg:358.4315101259072,perihelionJd:2442833721841768e-9},peakMagnitude:-3,peakOn:"1976-02-25",absoluteMagnitude:4.41,activityExponent:4,tailLengthDeg:30,tailLengthAu:.4325,note:"Broke into four pieces at perihelion. Barely reported at the time — the press had been burned by Kohoutek two years earlier."},{id:"iras-araki-alcock-1983",designation:"C/1983 H1",name:"Comet IRAS-Araki-Alcock",orbit:{eccentricity:.9898409731606003,perihelionAu:.9913412593828502,inclinationDeg:73.25000846947029,ascendingNodeDeg:49.10235754476374,argumentOfPerihelionDeg:192.8506176754439,perihelionJd:2.4454757545235856e6},peakMagnitude:1.7,peakOn:"1983-05-11",absoluteMagnitude:9.04,activityExponent:4,note:"Passed 0.031 au from Earth on 11 May 1983, one of the closest cometary approaches on record: it crossed a quarter of the sky in a night, which no other comet in this list did."},{id:"halley-1986",designation:"1P/Halley",name:"Halley's Comet",orbit:{eccentricity:.9672792271749998,perihelionAu:.5871034488173393,inclinationDeg:162.2422242700916,ascendingNodeDeg:58.85993640671803,argumentOfPerihelionDeg:111.8655480539208,perihelionJd:2.4464709589610207e6},peakMagnitude:2.1,peakOn:"1986-03-10",absoluteMagnitude:2.71,activityExponent:4,note:"The worst-placed return in two thousand years — famous, expected, and for most observers a faint smudge."},{id:"hyakutake-1996",designation:"C/1996 B2",name:"Comet Hyakutake",orbit:{eccentricity:.9997295133739305,perihelionAu:.2302272039470452,inclinationDeg:124.923592343765,ascendingNodeDeg:188.0454295899424,argumentOfPerihelionDeg:130.1724036582639,perihelionJd:2.4502048946148166e6},peakMagnitude:0,peakOn:"1996-03-25",absoluteMagnitude:4.75,activityExponent:4,tailLengthDeg:80,tailLengthAu:1,note:"Passed 0.10 au from Earth in March 1996, five weeks BEFORE perihelion, with a tail measured at some 80 degrees — the longest of the modern era."},{id:"hale-bopp-1997",designation:"C/1995 O1",name:"Comet Hale-Bopp",orbit:{eccentricity:.9951314746156615,perihelionAu:.9141695067003724,inclinationDeg:89.43017155012492,ascendingNodeDeg:282.470602866853,argumentOfPerihelionDeg:130.5872524854533,perihelionJd:2450539633099368e-9},peakMagnitude:-.8,peakOn:"1997-04-01",absoluteMagnitude:-1.06,activityExponent:4,tailLengthDeg:20,tailLengthAu:.9938,note:"Visible to the naked eye for about eighteen months, longer than any comet on record."},{id:"mcnaught-2007",designation:"C/2006 P1",name:"Comet McNaught",orbit:{eccentricity:1.00001811603225,perihelionAu:.1707325614080681,inclinationDeg:77.83726446452654,ascendingNodeDeg:267.4149080498975,argumentOfPerihelionDeg:155.9756130642756,perihelionJd:2454113298753579e-9},peakMagnitude:-5.5,peakOn:"2007-01-13",absoluteMagnitude:2.53,activityExponent:4,tailLengthDeg:35,tailLengthAu:.5009,note:"The brightest comet since Ikeya-Seki, seen in daylight beside the Sun in January 2007."},{id:"lovejoy-2011",designation:"C/2011 W3",name:"Comet Lovejoy",orbit:{eccentricity:.999915056276912,perihelionAu:.005553783989325053,inclinationDeg:134.3558712062691,ascendingNodeDeg:326.3693517957772,argumentOfPerihelionDeg:53.50991655176601,perihelionJd:2455911511809431e-9},peakMagnitude:-3,peakOn:"2011-12-16",alsoRecordedMagnitude:1.5,alsoRecordedOn:"2011-12-22",absoluteMagnitude:3.51,activityExponent:1.194,note:"A sungrazer that was expected to be destroyed at perihelion and came out the other side, to stand in the southern dawn sky for the rest of December — which is the second magnitude recorded here."},{id:"panstarrs-2013",designation:"C/2011 L4",name:"Comet PANSTARRS",orbit:{eccentricity:1.000032542889696,perihelionAu:.301544229714915,inclinationDeg:84.2081978367921,ascendingNodeDeg:65.66588626213694,argumentOfPerihelionDeg:333.6516444379993,perihelionJd:2456361669960698e-9},peakMagnitude:1,peakOn:"2013-03-10",absoluteMagnitude:5.98,activityExponent:4},{id:"neowise-2020",designation:"C/2020 F3",name:"Comet NEOWISE",orbit:{eccentricity:.9991782081129224,perihelionAu:.2946512466331692,inclinationDeg:128.9375043020912,ascendingNodeDeg:61.01042991771634,argumentOfPerihelionDeg:37.2786526292898,perihelionJd:2.4590341788972816e6},peakMagnitude:.9,peakOn:"2020-07-08",absoluteMagnitude:5.79,activityExponent:4,tailLengthDeg:10,tailLengthAu:.1808,note:"The first comet since Hale-Bopp that ordinary observers in the northern hemisphere saw without being told where to look."},{id:"tsuchinshan-atlas-2024",designation:"C/2023 A3",name:"Comet Tsuchinshan-ATLAS",orbit:{eccentricity:1.000020192843226,perihelionAu:.3914228969475176,inclinationDeg:139.1105462619479,ascendingNodeDeg:21.55945689078845,argumentOfPerihelionDeg:308.4913086299446,perihelionJd:2460581242087108e-9},peakMagnitude:0,peakOn:"2024-10-14",absoluteMagnitude:3.97,activityExponent:4,tailLengthDeg:20,tailLengthAu:.1902,note:"Briefly reported far brighter around 9 October 2024, when it stood almost between the observer and the Sun and forward-scattered the light through its own dust — a geometry this catalog's brightness model does not attempt, so what is stored is the ordinary evening-sky peak a few days later."}];class zE{static WINDOW_DAYS=200;static TWILIGHT_ELONGATION_DEG=15;static LIGHT_SPEED_AU_PER_DAY=173.144632674;static orbits=new Map;static aroundDate(t){const e=this.julianDayOf(t);return X1.filter(i=>Math.abs(e-i.orbit.perihelionJd)<=this.WINDOW_DAYS)}static brightestAt(t,e){return this.aroundDate(t).map(i=>this.appearanceOf(i,t,e)).sort((i,n)=>i.magnitude-n.magnitude)[0]}static appearanceOf(t,e,i){const n=$e(e),s=this.earthPositionAt(n),a=this.apparentPositionOf(t,2451545+n.tt,s),o=this.subtract(a,s),c=this.length(a),l=this.length(o),h=this.tailEndAt(t,a,s,c,n,e,i),u=this.horizontalOf(o,n,e,i);return{apparition:t,position:u,...h,heliocentricDistanceAu:c,earthDistanceAu:l,elongationDeg:this.angleBetween(o,this.subtract({x:0,y:0,z:0},s)),magnitude:this.magnitudeAt(t,c,l)}}static magnitudeAt(t,e,i){const n=t.absoluteMagnitude+5*Math.log10(i)+2.5*t.activityExponent*Math.log10(e);return Math.max(n,t.peakMagnitude)}static tailEndAt(t,e,i,n,s,a,o){if(t.tailLengthAu===void 0)return{};const c=1+t.tailLengthAu/n,l=this.subtract({x:e.x*c,y:e.y*c,z:e.z*c},i),h=this.subtract(e,i);return{tailEnd:this.horizontalOf(l,s,a,o),tailLengthDeg:this.angleBetween(h,l)}}static apparentPositionOf(t,e,i){const n=this.orbitOf(t);let s=n.positionAt(e);for(let a=0;a<2;a++){const o=this.length(this.subtract(s,i))/this.LIGHT_SPEED_AU_PER_DAY;s=n.positionAt(e-o)}return s}static horizontalOf(t,e,i,n){const s=Cr(Pw(),new Ue(t.x,t.y,t.z,e)),a=Cr(C1(e),s),o=uw(e,new N0(n.lat,n.lng,n.elevationM)),c=new Ue(a.x-o.x,a.y-o.y,a.z-o.z,e),l=U0(c);return k0(l.ra,l.dec,i,n)}static earthPositionAt(t){return Cr(Cw(),ia(wt.Earth,t))}static julianDayOf(t){return 2451545+$e(t).tt}static orbitOf(t){const e=this.orbits.get(t.id);if(e)return e;const i=new Ms(t.orbit);return this.orbits.set(t.id,i),i}static subtract(t,e){return{x:t.x-e.x,y:t.y-e.y,z:t.z-e.z}}static length(t){return Math.hypot(t.x,t.y,t.z)}static angleBetween(t,e){const i=(t.x*e.x+t.y*e.y+t.z*e.z)/(this.length(t)*this.length(e)||1);return Math.acos(Math.min(1,Math.max(-1,i)))*180/Math.PI}}const xu=[{id:"sn-1006",kind:"supernova",designation:"SN 1006",name:"Supernova of 1006",raHours:15.03947,decDeg:-42.09694,peakMagnitude:-7.5,peakJd:2088620,startJd:2088620,lightCurve:[[0,-7.5],[29,-5.9],[60,-4.9],[106,-3.2],[166,-1.9],[258,-1],[350,.5],[364,.7],[411,1.2],[456,1.8],[484,2.5],[785.5,7]],source:"Winkler, Gupta & Long 2003 (peak); decline borrowed from SN 1572",note:"The brightest stellar event in recorded history, seen in daylight, low in the southern sky from Europe and the Near East. The decline is modelled, not recorded, and falls below the naked eye after about two years where the chronicles speak of three."},{id:"sn-1054",kind:"supernova",designation:"SN 1054",name:"Supernova of 1054",raHours:5.5755,decDeg:22.0175,peakMagnitude:-6,peakJd:2106216,startJd:2106216,lightCurve:[[0,-6],[23,-4],[642,6]],source:"Chinese chronicles (Song huiyao), via Stephenson & Green 2002",note:"The explosion that left the Crab Nebula. Its magnitude is an estimate; the two durations are recorded."},{id:"sn-1181",kind:"supernova",designation:"SN 1181",name:"Supernova of 1181",raHours:.88645,decDeg:67.50067,peakMagnitude:0,peakJd:2152636,startJd:2152636,lightCurve:[[0,0],[185,6]],source:"Chinese and Japanese chronicles, via Stephenson & Green 2002",note:"Circumpolar from Europe and China, so never set. Its peak magnitude is uncertain by at least a magnitude."},{id:"sn-1572",kind:"supernova",designation:"SN 1572",name:"Tycho's Supernova",raHours:.42264,decDeg:64.14083,peakMagnitude:-4,peakJd:2295551,startJd:2295546,lightCurve:[[0,-3],[5,-4],[34,-2.4],[65,-1.4],[111,.3],[171,1.6],[263,2.5],[355,4],[369,4.2],[416,4.7],[461,5.3],[489,6]],source:"Tycho Brahe and contemporaries, reduced by Ruiz-Lapuente 2004",note:"Circumpolar from northern Europe. Tycho showed it had no parallax, so it was not in the air: a new star, beyond the Moon."},{id:"sn-1604",kind:"supernova",designation:"SN 1604",name:"Kepler's Supernova",raHours:17.51125,decDeg:-21.48733,peakMagnitude:-2.95,peakJd:2307210,startJd:2307191,lightCurve:[[0,.23],[3,-1.3],[6,-2.08],[9,-2.17],[19,-2.95],[27,-2.95],[32,-1.95],[36,-1.52],[86,.9],[96,.45],[103,1],[114,1.2],[118,1.55],[133,1.95],[137,2.3],[170,2.25],[185,2.25],[194,2.4],[197,2.9],[308,4.45],[324,4.45],[339,4.95],[364,4.7]],source:"Kepler, Fabricius, Maestlin and the Korean court astronomers, reduced by Ruiz-Lapuente 2017",note:"The last supernova in our Galaxy seen with the naked eye. It went behind the Sun from mid-November 1604 to January 1605, which is the gap in its record."},{id:"t-crb-1866",kind:"nova",designation:"T CrB",name:"Nova Coronae Borealis 1866",raHours:15.99171,decDeg:25.92017,peakMagnitude:2,peakJd:2402734,startJd:2402734,lightCurve:[[0,2],[1.5,3],[2.5,3.11],[6.5,5.18],[8.5,5.75],[10.5,6.85],[11.5,6.8],[12.5,7.5],[16,8.18],[32,9.27],[38,9.2],[40,8.95],[44,9.4],[48,9.07],[54,9.4],[58,9.21],[79,9.44],[107,9.26],[111,9.01],[115,8.21],[119,7.96],[159,7.51],[179,7.57],[183,7.97],[191,7.66],[199,8.2],[207,8.31],[211,8.83],[215,8.65],[223,8.97],[297,8.9],[345,9.25],[377,9.07],[425,9.3],[537,9.3]],source:"Recorded peak (Birmingham); curve borrowed from its 1946 eruption",note:"The first eruption of the recurrent nova T CrB to be seen. The decline is its 1946 one."},{id:"t-aur-1891",kind:"nova",designation:"T Aur",name:"Nova Aurigae 1891",raHours:5.53309,decDeg:30.44583,peakMagnitude:4.49,peakJd:2412083,startJd:2412079,lightCurve:[[0,5.28],[4,4.49],[24,4.58],[40,4.97],[52,4.95],[56,4.5],[60,4.9],[68,4.88],[72,5.25],[76,4.93],[84,5.44],[88,7.23],[96,8.85],[100,10.44]],source:"AAVSO, binned by Strope, Schaefer & Henden 2010"},{id:"gk-per-1901",kind:"nova",designation:"GK Per",name:"Nova Persei 1901",raHours:3.52,decDeg:43.90431,peakMagnitude:.19,peakJd:24154395e-1,startJd:24154377e-1,lightCurve:[[0,2.7],[.8,.86],[1.8,.19],[2.3,.2],[5.8,1.78],[11.8,2.54],[12.8,2.98],[17.8,3.62],[18.8,3.35],[19.8,3.77],[20.8,3.59],[22.8,3.95],[24.8,3.82],[25.6,4.99],[25.9,4.89],[26.6,3.69],[27.6,3.94],[27.9,4.61],[28.6,5.28],[28.9,4.46],[29.9,3.8],[30.9,4.27],[31.6,5.21],[31.9,5.22],[32.9,3.88],[33.9,4.19],[34.6,4.85],[35.6,4.8],[36.6,4.23],[37.6,4.44],[38.9,4.15],[39.7,5.19],[40.6,5.39],[40.9,5.35],[41.9,4.01],[42.6,4.5],[42.9,4.49],[43.6,5.53],[44,5.23],[44.6,5.61],[44.9,5.5],[45.9,4.17],[46.9,4.69],[47.6,5.5],[48.6,5.59],[49.6,5.14],[49.9,4.48],[50.6,4.45],[50.9,4.55],[51.6,5.47],[52.6,5.74],[53.7,5.66],[55.7,4.41],[56.7,5.43],[58.7,5.81],[58.9,5.58],[59.7,5.64],[59.9,4.76],[60.9,4.26],[61.9,5.62],[62.7,5.85],[62.9,5.53],[63.7,5.8],[64.9,4.28],[65.6,5.33],[66.7,5.87],[66.9,5.56],[68.7,5.7],[68.9,5.3],[69.7,4.47],[70.7,5.65],[72.9,5.98],[73.9,5.71],[74.7,4.98],[74.9,4.46],[75.7,4.87],[76.9,6.05],[77.6,5.76],[78,6],[78.7,5.95],[80.7,4.98],[81.9,5.85],[82.7,6.02],[84.7,5.41],[84.9,5.08],[85.7,5.17],[85.9,5.6],[87,6.1],[88.8,6.2],[89.7,4.96],[89.9,4.93],[90.7,5.9],[91.9,6.32],[92.7,5.86],[93.1,6.24],[93.7,5.38],[93.9,6.2],[96.1,6.12],[97.1,6.37],[97.6,5.12],[98,5.85],[99.3,6.35],[101.3,6.12],[101.7,5.25],[102.3,4.95],[102.7,6.12],[103.2,5.83],[104.7,6.37],[105,6.13],[106,6.22],[106.7,4.88],[107.7,6.3],[108.1,6.4],[109,6],[109.7,5.16],[110,5.82],[112.1,5.89],[113.1,5.5],[115.7,5.8],[116,6.11],[118.7,5.68],[119,6.23],[119.7,5.85],[120,6.12],[121,4.62],[121.8,5.9],[123,5.48],[125,6.05],[126,5.89],[130.9,6.11],[146.1,6.02],[155.6,6.26],[180.4,6.09],[190.4,6.39],[245.5,6.87],[266.2,6.77],[301.1,7.16],[321.5,7.07],[346.5,7.87],[375.7,7.86],[385.8,8.09],[389.8,8.55],[406.1,8.33],[416.5,8.59],[445.9,8.62],[472.1,9.24],[565.9,9.74],[571,9.4],[589.8,9.76]],source:"AAVSO, binned by Strope, Schaefer & Henden 2010",note:"Discovered on 21 February 1901 by Thomas Anderson in Edinburgh, and the brightest nova of the century until V603 Aql."},{id:"dn-gem-1912",kind:"nova",designation:"DN Gem",name:"Nova Geminorum 1912",raHours:6.9151,decDeg:32.14108,peakMagnitude:3.58,peakJd:241947675e-2,startJd:241947275e-2,lightCurve:[[0,11.7],[1,4.5],[4,3.58],[5,4.45],[5.5,5.32],[6,5.53],[6.5,5.11],[8,5.43],[8.5,5.16],[11,5.53],[11.5,5.13],[12,5.18],[13.75,4.5],[15.75,5.3],[18.75,6],[19.75,5.55],[26.75,6],[28.75,5.9],[31.75,6.6],[32.75,6.2],[33.75,6.5],[36.75,6.55],[39.75,6.2],[40.75,6.75],[41.75,7],[44.75,6.75],[52.75,6.75],[54.75,7.23],[58.25,7.5],[62.25,7.3],[64.25,7.47],[66.25,8.1],[70.25,7.5],[72.25,8.1],[78.25,7.55],[80.25,8.2],[86.25,7.2],[90.25,7.3],[92.25,7.8],[152.25,7.2],[160.25,7.4],[166.25,8.2],[168.25,8.2],[170.25,7.3],[180.25,7.4],[182.25,8],[186.25,7.5],[190.25,7.6],[192.25,8],[211.25,7.75],[227.25,8],[275.25,7.78],[315.25,8.6],[331.25,7.79],[339.25,8.27],[363.25,8.61],[443.25,8.93],[451.25,9.2],[535.25,10.3],[567.25,9.9],[615.25,10.8],[631.25,10.63],[647.25,10.88],[679.25,10.8],[695.25,11.07],[727.25,11]],source:"AAVSO, binned by Strope, Schaefer & Henden 2010"},{id:"v603-aql-1918",kind:"nova",designation:"V603 Aql",name:"Nova Aquilae 1918",raHours:18.81518,decDeg:.58414,peakMagnitude:-.5,peakJd:242175475e-2,startJd:242174875e-2,lightCurve:[[0,11.3],[2,10.5],[4,6.6],[4.5,1.04],[6,-.5],[6.5,.18],[10,1.1],[10.5,.95],[12.75,1.89],[21.75,3.07],[23.75,3.76],[29.75,3.16],[34.75,3.5],[36.75,3.86],[44.75,3.79],[48.75,4.43],[52.75,3.84],[56.75,3.95],[57.75,4.04],[58.75,4.49],[59.75,4.42],[60.75,4.69],[62.75,4.6],[63.75,4.11],[64.75,3.97],[68.75,4.18],[70.75,4.65],[71.75,4.51],[73.75,4.73],[75.75,4.44],[79.75,4.85],[83.75,4.43],[89.75,4.88],[92.75,4.86],[94.75,4.58],[96.75,4.92],[99.75,5.05],[163.25,5.45],[167.25,5.7],[179.25,5.48],[191.25,5.8],[203.25,5.5],[247.25,5.9],[251.25,6.25],[257.25,5.5],[265.25,6.13],[281.25,6.33],[345.25,6.3],[385.25,6.73],[393.25,6.43],[425.25,6.71],[433.25,6.56],[461.25,7.27],[525.25,7.6],[541.25,7.47],[637.25,8.3],[669.25,8.17],[717.25,8.55],[749.25,8.4],[765.25,8.68],[885.25,8.75],[949.25,9.4],[1013.25,9.19],[1141.25,9.57],[1269.25,9.48],[1333.25,9.95],[1653.25,9.94],[1781.25,10.28],[1909.25,10.34],[2037.25,10.1],[2101.25,10.46],[2165.25,10.51],[2357.25,10.3],[2549.25,10.77],[2741.25,10.46],[2869.25,10.83],[3125.25,10.71],[3317.25,11.22],[3381.25,10.91],[3637.25,11.42],[3829.25,10.96],[3893.25,11.65],[3957.25,11.63],[4085.25,11.14],[4213.25,11.48],[4277.25,10.7],[4341.25,11.42],[4405.25,11.47],[4469.25,11.06],[4533.25,11.08],[4597.25,11.7],[4725.25,11.45],[4789.25,10.94]],source:"AAVSO, binned by Strope, Schaefer & Henden 2010",note:"The brightest nova of the modern era, at magnitude -0.5 on 9-10 June 1918: as bright as Vega, in a summer evening sky, in wartime."},{id:"v476-cyg-1920",kind:"nova",designation:"V476 Cyg",name:"Nova Cygni 1920",raHours:19.97347,decDeg:53.61858,peakMagnitude:1.94,peakJd:242256025e-2,startJd:242255925e-2,lightCurve:[[0,2.7],[1,1.94],[3,2.07],[4.5,2.95],[8.25,4],[31.75,6.41],[35.75,7.23],[37.75,7.08],[41.75,7.33],[43.75,7.92],[45.75,8.2],[51.75,8.59],[63.75,8.82],[65.75,9.25],[71.75,8.93],[85.75,9.43],[87.75,9.05],[95.75,9.2],[97.75,8.67],[99.75,9.07],[112.75,8.78],[120.75,9.03],[128.75,8.67],[144.75,8.94],[152.75,8.73],[168.75,8.79],[176.75,9.28],[192.75,9],[216.75,9.6],[232.75,9.27],[240.75,9.5],[288.75,9.4],[296.75,9.6],[304.75,9.3],[320.75,9.73],[328.75,9.5],[336.75,9.8],[428.75,9.61],[476.75,10.01],[492.75,9.76],[508.75,9.87],[524.75,9.65],[556.75,9.87],[572.75,9.65],[620.75,10.22],[668.75,10.44],[684.75,10.23],[716.75,10.33],[756.75,10.66],[884.75,10.59],[948.75,10.96],[1108.75,10.96]],source:"AAVSO, binned by Strope, Schaefer & Henden 2010"},{id:"rr-pic-1925",kind:"nova",designation:"RR Pic",name:"Nova Pictoris 1925",raHours:6.59335,decDeg:-62.64008,peakMagnitude:.95,peakJd:24243085e-1,startJd:24242995e-1,lightCurve:[[0,2.43],[5,2.35],[6,2.1],[7,2.4],[9,.95],[13,1.8],[14,1.7],[16,2.15],[18,2.2],[19,1.9],[23,3.1],[27,3.05],[31.5,3.58],[43.5,3.08],[47.5,3.15],[57.5,2.3],[59.5,1.65],[63.5,3.03],[65.5,2.84],[67.5,3.16],[69.5,2.4],[71.5,2.04],[73.5,2.05],[75.5,2.55],[79.5,3],[83.5,3.15],[116.5,3.54],[120.5,3.78],[124.5,3.67],[136.5,4.18],[148.5,4.34],[154.5,4.17],[194.5,4.43],[226.5,4.93],[234.5,4.8],[242.5,5.4],[250.5,5.5],[266.5,5.15],[298.5,5.6],[362.5,5.4],[414.5,5.7],[430.5,5.5],[494.5,6.2],[718.5,6.52],[830.5,6.3],[862.5,6.6],[878.5,6.4],[910.5,6.77],[958.5,6.67],[1062.5,7.07],[1318.5,7.35],[1590.5,8.12],[1718.5,8.25],[2486.5,8.59],[2614.5,8.47],[2742.5,8.7],[3382.5,8.6],[3766.5,8.97],[4022.5,8.79],[4150.5,9.22],[6710.5,10.29],[7414.5,11.03],[8438.5,10.96]],source:"AAVSO, binned by Strope, Schaefer & Henden 2010",note:"A slow nova, and a southern one: more than two months within two magnitudes of its peak."},{id:"dq-her-1934",kind:"nova",designation:"DQ Her",name:"Nova Herculis 1934",raHours:18.12507,decDeg:45.85906,peakMagnitude:1.56,peakJd:24277935e-1,startJd:242778675e-2,lightCurve:[[0,3.4],[1.5,2.4],[3,2.67],[5.75,2.01],[6.75,1.56],[7.75,1.59],[11.75,2.97],[12.75,2.31],[14.75,3.07],[15.75,2.56],[16.75,2.51],[19.75,2.68],[23.75,2.53],[24.75,2.27],[26.75,2.58],[30.75,2.24],[31.75,2.63],[32.75,2.66],[34.75,2.11],[39.75,2.71],[41.75,2.31],[43.75,2.37],[46.75,3.64],[47.75,3.21],[50.75,3.23],[52.75,2.66],[55.75,2.56],[58.75,2.97],[60.75,2.77],[61.75,3.36],[63.75,3.43],[64.75,2.89],[65.75,3.22],[68.75,3.52],[69.75,2.95],[70.75,3.06],[71.75,2.7],[76.75,3.65],[79.75,3.74],[81.75,3.21],[83.75,3.75],[87.75,3.69],[92.75,4.04],[94.75,4.8],[97.75,4.24],[98.75,4.52],[100.75,4.08],[101.75,4.43],[105.75,4.58],[106.75,4.33],[107.75,4.73],[108.75,6.57],[109.75,8.08],[110.75,8.15],[111.75,8.56],[113.75,8.45],[114.75,9.15],[115.75,9.15],[116.75,9.59],[117.75,9.43],[118.75,9.8],[122.75,10.5],[123.75,10.28],[124.75,10.93],[127.75,10.83],[129.75,11.87],[131.75,12.42],[135.75,12.5],[137.75,12.9],[138.75,12.77],[139.75,13],[143.75,12],[144.75,12.33],[146.75,12.35],[147.75,11.64],[148.75,11.83],[150.75,10.9],[151.75,10.78],[152.75,11.17],[154.75,10.32],[155.75,10.4],[165.25,9.24],[185.25,7.74],[225.25,6.8],[273.25,6.72],[321.25,6.97],[333.25,6.79],[353.25,7],[357.25,6.82],[377.25,6.88],[401.25,7.29],[409.25,6.8],[413.25,6.8],[419.25,7.1],[435.25,7.09],[451.25,7.4],[475.25,7],[555.25,7.48],[823.25,7.83],[855.25,8.18],[1135.25,8.43],[1823.25,9.98],[1887.25,9.71],[2015.25,10.55],[2335.25,10.95]],source:"AAVSO, binned by Strope, Schaefer & Henden 2010",note:"Lost about ten magnitudes in a few weeks from April 1935, when dust condensed around it, then came back to naked-eye brightness."},{id:"cp-lac-1936",kind:"nova",designation:"CP Lac",name:"Nova Lacertae 1936",raHours:22.26142,decDeg:55.61703,peakMagnitude:2.02,peakJd:242834025e-2,startJd:242833825e-2,lightCurve:[[0,4.03],[.5,2.9],[1,2.45],[2,2.02],[2.5,2.61],[4,3],[4.5,3.35],[5,3.3],[9.25,4.59],[14.25,5.45],[22.25,6.03],[23.25,6.3],[26.25,6.23],[38.25,6.74],[41.25,6.61],[50.25,7.35],[53.25,7.27],[57.25,7.7],[58.25,7.54],[60.25,7.55],[61.25,7.79],[71.25,7.6],[74.25,7.81],[76.25,8.3],[77.25,7.79],[86.25,8.21],[87.25,8],[88.25,8.25],[92.25,8.17],[94.25,8.47],[102.25,8.27],[103.25,8.7],[104.25,8.4],[110.25,8.66],[116.75,8.55],[122.75,8.83],[126.75,8.7],[140.75,9.06],[154.75,9.01],[164.75,9.36],[170.75,9.18],[174.75,9.48],[186.75,9.42],[188.75,9.73],[192.75,9.53],[200.75,9.74],[202.75,9.5],[204.75,9.77],[208.75,9.6],[214.75,9.75],[216.75,10.05],[222.75,9.7],[232.75,10.03],[236.75,9.82],[250.75,10.1],[254.75,9.9],[260.75,10.1],[264.75,9.8],[266.75,10.15],[268.75,10],[274.75,10.2],[276.75,9.9],[292.75,10.6],[294.75,10.6],[298.75,10.1],[318.75,10.35],[320.75,10.6],[322.75,10.3],[328.75,10.65],[332.75,10.3],[338.75,10.7],[348.75,10.53],[350.75,10.7],[354.75,10.37],[358.75,10.58],[365.75,10.43],[373.75,10.85],[421.75,10.94]],source:"AAVSO, binned by Strope, Schaefer & Henden 2010"},{id:"cp-pup-1942",kind:"nova",designation:"CP Pup",name:"Nova Puppis 1942",raHours:8.19613,decDeg:-35.35139,peakMagnitude:.73,peakJd:243067675e-2,startJd:243067275e-2,lightCurve:[[0,.95],[4,.73],[4.5,1.3],[5.5,1.47],[6,2.01],[7.75,2.88],[8.75,2.97],[10.75,3.5],[11.75,4.02],[13.75,4.4],[14.75,3.8],[17.75,5],[18.75,4.93],[19.75,5.48],[23.75,5.5],[25.75,5.65],[26.75,5.99],[33.25,6.28],[45.25,6.6],[57.25,6.41],[81.25,6.85],[89.25,6.5],[97.25,6.67],[101.25,7],[113.25,6.66],[125.25,7.1],[135.25,6.96],[231.25,7.86],[279.25,7.8],[327.25,8.33],[407.25,8.18],[423.25,8.59],[471.25,8.53],[503.25,8.99],[551.25,8.97],[567.25,8.7],[583.25,9.47],[615.25,8.95],[655.25,9.5],[751.25,9.55],[815.25,10.09],[847.25,10.02],[879.25,10.48],[911.25,10.34],[1023.25,10.79],[1279.25,10.9]],source:"AAVSO, binned by Strope, Schaefer & Henden 2010",note:"One of the fastest bright novae: two magnitudes gone in four days."},{id:"t-crb-1946",kind:"nova",designation:"T CrB",name:"Nova Coronae Borealis 1946",raHours:15.99171,decDeg:25.92017,peakMagnitude:2.5,peakJd:2431860,startJd:2431860,lightCurve:[[0,2.5],[1.5,3.5],[2.5,3.61],[6.5,5.68],[8.5,6.25],[10.5,7.35],[11.5,7.3],[12.5,8],[16,8.68],[32,9.77],[38,9.7],[40,9.45],[44,9.9],[48,9.57],[54,9.9],[58,9.71],[79,9.94],[107,9.76],[111,9.51],[115,8.71],[119,8.46],[159,8.01],[179,8.07],[183,8.47],[191,8.16],[199,8.7],[207,8.81],[211,9.33],[215,9.15],[223,9.47],[297,9.4],[345,9.75],[377,9.57],[425,9.8],[537,9.8]],source:"AAVSO, binned by Strope, Schaefer & Henden 2010",note:"A recurrent nova. It erupted in 1866 and in 1946, and a third eruption was expected from 2024 on."},{id:"v446-her-1960",kind:"nova",designation:"V446 Her",name:"Nova Herculis 1960",raHours:18.956,decDeg:13.24147,peakMagnitude:4.83,peakJd:24370038e-1,startJd:24370033e-1,lightCurve:[[0,5.2],[.5,4.83],[2,4.9],[2.5,5.4],[3,5.05],[3.5,5.57],[4,5.25],[5,5.5],[6.5,5.4],[7.2,5.78],[8.2,5.6],[9.2,5.98],[10.2,5.92],[11.2,6.21],[16.2,6.1],[17.2,6.23],[18.2,7.2],[19.2,6.51],[20.2,6.78],[26.2,6.97],[27.2,7.24],[28.2,7.13],[29.2,7.45],[31.2,7.2],[40.7,7.57],[44.7,8.25],[46.7,7.84],[56.7,8.15],[60.7,8.9],[70.7,8.7],[72.7,8.14],[76.7,8.71],[80.7,8.47],[82.7,8.87],[86.7,8.57],[90.7,8.93],[107.7,9.11],[111.7,8.94],[115.7,9.27],[139.7,9.38],[151.7,9.91],[155.7,9.72],[173.7,10.51],[221.7,10.95]],source:"AAVSO, binned by Strope, Schaefer & Henden 2010"},{id:"v533-her-1963",kind:"nova",designation:"V533 Her",name:"Nova Herculis 1963",raHours:18.23902,decDeg:41.85614,peakMagnitude:3,peakJd:24380605e-1,startJd:24380565e-1,lightCurve:[[0,8],[4,3],[4.5,3],[8,4],[13,3.95],[15,4.6],[21,4.53],[24,5.05],[27,5.15],[32,4.76],[34,4.98],[35,5.39],[37,5.43],[41,6.04],[49,6.02],[56.5,6.34],[60.5,6.11],[74.5,6.72],[102.5,6.99],[137.5,7.81],[197.5,8.31],[217.5,8.8],[225.5,8.57],[233.5,9.03],[237.5,8.78],[277.5,9.44],[301.5,9.46],[315.5,9.86],[323.5,9.73],[339.5,10.05],[355.5,10.74],[363.5,10.32],[371.5,10.6],[387.5,10.69],[427.5,10.38],[435.5,10.84],[443.5,10.74],[451.5,11.33],[459.5,10.98],[467.5,11.17],[507.5,11.16],[539.5,11.66],[603.5,11.7],[619.5,12.05],[651.5,12.03],[659.5,11.74],[667.5,10.9]],source:"AAVSO, binned by Strope, Schaefer & Henden 2010"},{id:"hr-del-1967",kind:"nova",designation:"HR Del",name:"Nova Delphini 1967",raHours:20.70565,decDeg:19.16092,peakMagnitude:3.58,peakJd:2439838,startJd:2439646,lightCurve:[[0,11.9],[6,11.8],[12,8.8],[16,8.3],[20,6.7],[30,5.8],[36,5.51],[66,5.55],[78,5.35],[86,4.89],[96,5],[108,4.75],[136,5.13],[152,4.83],[182,4.93],[186,4.59],[192,3.58],[202,5],[220,5.46],[226,5.14],[230,5.45],[232,5.14],[236,5],[242,5.08],[244,4.59],[246,4.45],[254,5.3],[256,4.75],[260,5.69],[268,4.8],[274,4.94],[276,5.45],[280,5.2],[282,5.51],[286,5.58],[292,4.95],[294,5.16],[298,4.94],[311,5.09],[335,4.4],[367,5.76],[407,6.16],[423,6.55],[603,7.43],[907,8.32],[1451,9.41],[2347,10.75]],source:"AAVSO, binned by Strope, Schaefer & Henden 2010",note:"An exceptionally slow nova: rose over months and stayed near magnitude 4 to 5 for most of 1967 and 1968."},{id:"lv-vul-1968",kind:"nova",designation:"LV Vul",name:"Nova Vulpeculae 1968",raHours:19.80012,decDeg:27.1715,peakMagnitude:4.5,peakJd:243996425e-2,startJd:243996325e-2,lightCurve:[[0,5],[1,4.5],[2,5],[2.5,4.86],[3,5.1],[3.5,4.88],[4,5.1],[5,4.9],[7,5.4],[8,5.23],[10.5,5.42],[12,5.82],[13,5.4],[13.5,5.74],[14,5.7],[14.5,6.08],[15,5.75],[15.5,5.86],[16,5.6],[17,5.8],[18,5.6],[20.5,6.34],[21,6.2],[22.5,6.84],[23,6.57],[24,6.98],[24.5,6.3],[25,7.1],[26,6.65],[34.25,7.48],[35.25,7.23],[39.25,7.32],[44.25,7.76],[45.25,7.49],[46.25,7.78],[50.25,7.84],[51.25,8.1],[53.25,7.9],[54.25,8.13],[56.25,8],[57.75,8.24],[67.75,8.52],[75.75,8.38],[83.75,8.69],[89.75,8.59],[125.75,9.32],[127.75,9.33],[129.75,8.98],[131.75,9.29],[135.75,9.43],[212.75,9.9],[220.75,10.16],[228.75,10.03],[236.75,10.3],[244.75,10.16],[264.75,10.54],[280.75,10.45],[296.75,10.79],[328.75,10.78]],source:"AAVSO, binned by Strope, Schaefer & Henden 2010"},{id:"fh-ser-1970",kind:"nova",designation:"FH Ser",name:"Nova Serpentis 1970",raHours:18.51307,decDeg:2.61444,peakMagnitude:4.5,peakJd:244063425e-2,startJd:244063125e-2,lightCurve:[[0,7],[2,5],[3,4.5],[3.5,5],[4.5,4.6],[5.5,5],[6.5,4.68],[12.25,4.66],[16.25,5.3],[17.25,5.72],[18.25,5.3],[19.25,5.2],[23.25,5.84],[24.25,5.68],[27.25,5.9],[30.25,5.47],[32.25,5.9],[34.25,5.7],[43.25,6.28],[45.25,6.1],[50.25,6.62],[52.25,6.47],[57.25,6.63],[60.25,7.08],[61.25,6.87],[62.25,7.2],[63.25,6.85],[64.25,7.68],[65.25,7.3],[66.25,8.3],[67.25,7.93],[69.25,9.15],[71.25,9.2],[72.25,9.63],[74.25,9.9],[76.25,9.7],[77.25,10.25],[78.25,10.1],[79.25,10.4],[80.25,10.23],[81.25,10.57],[83.25,10.64],[85.25,10.35],[86.25,11.2],[87.25,10.1],[89.25,11.2],[96.25,11.35],[100.25,11.95],[102.25,11.1],[104.25,11.65],[106.25,11.5],[108.25,12.07],[114.75,11.32],[118.75,11.28],[122.75,10.93],[130.75,10.85],[134.75,10.52],[154.75,10.65],[162.75,10.12],[174.75,9.98],[178.75,10.34],[186.75,9.98],[214.75,10.25],[224.75,10.02],[240.75,10.2],[264.75,10],[272.75,10.2],[280.75,10.05],[288.75,10.4],[296.75,10],[348.75,10.7],[396.75,10.3],[444.75,10.73],[460.75,10.59],[540.75,10.94],[556.75,10.82]],source:"AAVSO, binned by Strope, Schaefer & Henden 2010"},{id:"v1500-cyg-1975",kind:"nova",designation:"V1500 Cyg",name:"Nova Cygni 1975",raHours:21.19349,decDeg:48.15056,peakMagnitude:1.88,peakJd:244265525e-2,startJd:244265425e-2,lightCurve:[[0,2.44],[1,1.88],[1.5,1.88],[2.5,2.41],[3,3.38],[4,4.28],[8.25,5.81],[11.25,6.46],[22.25,7.35],[33.25,7.73],[34.25,7.97],[37.25,7.86],[40.25,8.3],[43.25,8.19],[48.25,8.6],[49.25,8.46],[66.25,9.04],[70.25,8.93],[75.25,9.23],[76.25,9.03],[80.25,9.39],[81.25,9.19],[83.25,9.35],[84.25,9.13],[86.25,9.39],[89.25,9.32],[90.25,9.54],[93.25,9.37],[105.75,9.86],[193.75,10.43],[201.75,10.7],[209.75,10.47],[257.75,10.94],[265.75,10.81]],source:"AAVSO, binned by Strope, Schaefer & Henden 2010",note:"One of the fastest novae on record: discovered on 29 August 1975, at its peak of magnitude 1.9 within two days, and two magnitudes down again two days later."},{id:"v842-cen-1986",kind:"nova",designation:"V842 Cen",name:"Nova Centauri 1986",raHours:14.59794,decDeg:-57.6265,peakMagnitude:4.9,peakJd:244675975e-2,startJd:244675725e-2,lightCurve:[[0,5.6],[2.5,4.9],[3.5,5.1],[15.5,5.1],[17.5,5.75],[18.5,5.4],[20.5,5.5],[22.5,5.95],[30.5,6.15],[31.5,6.3],[32,7.5],[34.5,7.2],[38.5,7.5],[39,7],[41.5,7.15],[42.5,6.7],[44.5,7.23],[45.5,6.6],[53,9.3]],source:"AAVSO, binned by Strope, Schaefer & Henden 2010"},{id:"sn-1987a",kind:"supernova",designation:"SN 1987A",name:"Supernova 1987A",raHours:5.59111,decDeg:-69.26975,peakMagnitude:2.98,peakJd:24469425e-1,startJd:24468495e-1,lightCurve:[[0,6.36],[1,6.11],[2,4.63],[4,4.45],[32,3.97],[56,3.15],[93,2.98],[105,3.35],[118,4.11],[134,4.43],[504,8.15],[617,10.27]],source:"V photometry compiled by the Open Supernova Catalog (Sternberg catalogue, IAU circulars, CTIO)",note:"In the Large Magellanic Cloud, 160 000 light years away: the nearest supernova since Kepler's, and invisible north of about 20° N."},{id:"v1974-cyg-1992",kind:"nova",designation:"V1974 Cyg",name:"Nova Cygni 1992",raHours:20.50879,decDeg:52.63078,peakMagnitude:4.27,peakJd:24486753e-1,startJd:24486718e-1,lightCurve:[[0,7.2],[1,5.23],[2,4.62],[3.5,4.27],[4.5,4.59],[6,4.5],[7,4.78],[7.5,4.52],[8,4.82],[10.7,5.25],[11.7,5.66],[16.7,5.85],[21.7,6.47],[22.7,6.3],[27.7,6.46],[29.7,6.83],[34.7,6.9],[35.7,7.25],[36.7,7],[37.7,7.16],[39.7,7.03],[43.7,7.41],[45.7,7.26],[50.7,7.45],[57.7,7.78],[58.7,8.13],[61.7,7.92],[64.7,8.19],[65.7,7.99],[71.7,8.22],[76.7,8.01],[128.2,8.72],[176.2,8.89],[192.2,9.15],[216.2,9.28],[232.2,9.07],[236.2,9.3],[390.2,10.99]],source:"AAVSO, binned by Strope, Schaefer & Henden 2010"},{id:"v382-vel-1999",kind:"nova",designation:"V382 Vel",name:"Nova Velorum 1999",raHours:10.74678,decDeg:-52.42533,peakMagnitude:2.88,peakJd:245132225e-2,startJd:245132075e-2,lightCurve:[[0,2.99],[1.5,2.88],[2.5,3.46],[4.5,3.98],[5,4.32],[5.5,4.23],[7.5,4.85],[21.75,6.67],[30.25,7.2],[40.25,7.41],[93.25,7.95],[97.25,8.25],[101.25,8],[113.25,7.96],[129.25,8.5],[155.25,8.47],[163.25,9.1],[179.25,9],[187.25,8.7],[195.25,9.15],[211.25,9.23],[235.25,9.8],[243.25,9.71],[299.25,10.42],[383.25,10.52],[415.25,10.81]],source:"AAVSO, binned by Strope, Schaefer & Henden 2010"},{id:"v1494-aql-1999",kind:"nova",designation:"V1494 Aql",name:"Nova Aquilae 1999",raHours:19.38482,decDeg:4.9555,peakMagnitude:4.11,peakJd:245151575e-2,startJd:245151425e-2,lightCurve:[[0,5.15],[.5,4.86],[1,4.27],[1.5,4.11],[2.5,4.35],[5,5.48],[10.5,6.26],[14.25,6.28],[20.25,7.43],[24.25,7.25],[25.25,7.63],[27.25,7.7],[29.25,7.42],[33.25,8.08],[35.25,8.03],[36.25,7.6],[37.25,7.6],[46.25,8.5],[54.25,8.28],[56.25,8.63],[58.25,8.4],[61.25,9.53],[62.25,9],[64.25,9.13],[69.25,8.58],[70.25,8.9],[72.25,8.88],[75.25,8.57],[77.25,9],[79.25,8.8],[81.25,9.7],[83.25,9.6],[85.25,9.8],[86.75,9.5],[88.75,9.54],[90.75,8.9],[92.75,8.85],[96.75,9.63],[102.75,9.7],[104.75,8.98],[106.75,8.73],[116.75,9.63],[118.75,9.6],[120.75,9.07],[122.75,9.26],[124.75,9.8],[128.75,9.36],[134.75,9.75],[147.75,9.92],[155.75,9.81],[259.75,10.96]],source:"AAVSO, binned by Strope, Schaefer & Henden 2010"},{id:"v4743-sgr-2002",kind:"nova",designation:"V4743 Sgr",name:"Nova Sagittarii 2002",raHours:19.01926,decDeg:-22.00167,peakMagnitude:5,peakJd:245253775e-2,startJd:245253675e-2,lightCurve:[[0,5.2],[1,5],[2,5.89],[2.5,5.91],[3.5,6.43],[5,6.45],[5.5,6.86],[6,6.59],[7,6.77],[7.5,7.31],[8.5,6.99],[9,7.09],[10.5,7.86],[11,7.58],[11.5,7.89],[15.75,8.33],[17.75,8.18],[18.75,8.58],[19.75,8.44],[22.75,8.83],[23.75,8.6],[24.75,8.85],[27.75,8.83],[30.75,9.4],[31.75,9.09],[36.25,9.08],[38.25,9.34],[62.25,9.75],[66.25,10.1],[70.25,9.7],[74.25,10],[171.25,10.9]],source:"AAVSO, binned by Strope, Schaefer & Henden 2010"},{id:"rs-oph-2006",kind:"nova",designation:"RS Oph",name:"Nova Ophiuchi 2006",raHours:17.83699,decDeg:-6.70792,peakMagnitude:4.8,peakJd:2453779,startJd:2453779,lightCurve:[[0,4.8],[1.25,4.97],[2.75,5.78],[3.25,5.7],[3.75,6.24],[4.25,6.05],[4.75,6.38],[5.25,6.3],[8.5,7.25],[14.5,7.95],[24.5,8.55],[29.5,9.08],[48,9.87],[80,10.28],[107,11.54],[119,11.54],[139,11.98],[147,11.83],[163,12.03],[171,11.97],[175,11.65],[183,11.84],[195,11.64],[203,11.8],[207,12.13],[219,11.45],[277,11.68],[325,11],[341,11.53],[357,11.62],[373,11.3],[405,11.5],[421,11.17],[469,10.96],[501,11.22],[549,10.75],[581,11.08],[597,10.98]],source:"AAVSO, binned by Strope, Schaefer & Henden 2010",note:"A recurrent nova, erupting every twenty years or so (1898, 1907, 1933, 1945, 1958, 1967, 1985, 2006, 2021)."},{id:"v1280-sco-2007",kind:"nova",designation:"V1280 Sco",name:"Nova Scorpii 2007",raHours:16.96145,decDeg:-32.34325,peakMagnitude:3.8,peakJd:2454149,startJd:2454136,lightCurve:[[0,9.7],[13,3.8],[34,5.8],[103,15]],source:"AAVSO (discovery, peak, dust minimum); t2 from Das et al. 2008",note:"Faded from sight quickly when dust formed around it, three weeks after its peak."},{id:"v339-del-2013",kind:"nova",designation:"V339 Del",name:"Nova Delphini 2013",raHours:20.39186,decDeg:20.76772,peakMagnitude:4.4,peakJd:24565214e-1,startJd:24565214e-1,lightCurve:[[0,4.4],[11,6.4],[20,7.4]],source:"Gehrz et al. 2015 (peak, t2, t3)",note:"High in the summer evening sky of the northern hemisphere, and widely photographed."},{id:"v1369-cen-2013",kind:"nova",designation:"V1369 Cen",name:"Nova Centauri 2013",raHours:13.9126,decDeg:-59.15114,peakMagnitude:3.48,peakJd:245663965e-2,startJd:24566285e-1,lightCurve:[[0,5.33],[1.57,4.08],[2.75,3.73],[4.57,4.16],[5.96,4.15],[10.26,3.77],[11.15,3.48],[12.14,3.74],[14.17,4.78],[15.46,4.97],[23.16,4.22],[26.25,4.32],[27.31,4.82],[29.56,5.11],[32.66,4.71],[33.84,4.86],[36.05,4.46],[37.15,4.99],[41.42,4.59],[42.37,4.93],[43.37,4.82],[44.54,5.09],[49.95,5.38],[51.99,5.82],[54.21,5.77]],source:"AAVSO, binned by day, as plotted by Izzo 2017 (arXiv:1704.07214, figure 1)",note:"Discovered on 2 December 2013 by John Seach at magnitude 5.5, it flared several times, reaching about 3.3 around 14 December: the brightest nova of the century so far, and a southern one."},{id:"rs-oph-2021",kind:"nova",designation:"RS Oph",name:"Nova Ophiuchi 2021",raHours:17.83699,decDeg:-6.70792,peakMagnitude:4.6,peakJd:2459436,startJd:2459435,lightCurve:[[0,5],[1,4.6],[2.25,4.77],[3.75,5.58],[4.25,5.5],[4.75,6.04],[5.25,5.85],[5.75,6.18],[6.25,6.1],[9.5,7.05],[15.5,7.75],[25.5,8.35],[30.5,8.88],[49,9.67],[81,10.08],[108,11.34],[120,11.34],[140,11.78],[148,11.63],[164,11.83],[172,11.77],[176,11.45],[184,11.64],[196,11.44],[204,11.6],[208,11.93],[220,11.25],[278,11.48],[326,10.8],[342,11.33],[358,11.42],[374,11.1],[406,11.3],[422,10.97],[470,10.76],[502,11.02],[550,10.55],[582,10.88],[598,10.78]],source:"Recorded discovery and peak (8 and 9 August 2021); curve borrowed from its 2006 eruption",note:"RS Oph's latest eruption, discovered on 8 August 2021. The decline is its 2006 one."}];class jm{static UNIX_EPOCH_JD=24405875e-1;static aroundDate(t){const e=this.julianDayOf(t);return xu.filter(i=>this.magnitudeAt(i,e)!==void 0)}static appearancesAt(t,e){const i=this.julianDayOf(t),n=[];for(const s of xu){const a=this.magnitudeAt(s,i);a!==void 0&&n.push({outburst:s,position:Pn.ofJ2000(s.raHours,s.decDeg,t,e),magnitude:a})}return n.sort((s,a)=>s.magnitude-a.magnitude)}static brightestAt(t,e){return this.appearancesAt(t,e)[0]}static byId(t){return xu.find(e=>e.id===t)}static magnitudeAt(t,e){const i=t.lightCurve,n=e-t.startJd;if(i.length===0||n<i[0][0]||n>i[i.length-1][0])return;let s=1;for(;s<i.length-1&&i[s][0]<n;)s++;const[a,o]=i[s-1]??i[0],[c,l]=i[s]??i[0];if(c===a)return o;const h=Math.min(1,Math.max(0,(n-a)/(c-a)));return o+h*(l-o)}static julianDayOf(t){return t.getTime()/864e5+this.UNIX_EPOCH_JD}}const BE=[{id:"quadrantids",code:"QUA",name:"Quadrantids",radiantRaHours:15.33,radiantDecDeg:49.7,start:{month:12,day:28},peak:{month:1,day:3},end:{month:1,day:12},peakZhr:110,velocityKmS:41,populationIndex:2.1},{id:"lyrids",code:"LYR",name:"April Lyrids",radiantRaHours:18.13,radiantDecDeg:33.3,start:{month:4,day:16},peak:{month:4,day:22},end:{month:4,day:25},peakZhr:18,velocityKmS:49,populationIndex:2.1},{id:"eta-aquariids",code:"ETA",name:"eta Aquariids",radiantRaHours:22.53,radiantDecDeg:-1,start:{month:4,day:19},peak:{month:5,day:6},end:{month:5,day:28},peakZhr:50,velocityKmS:66,populationIndex:2.4},{id:"alpha-capricornids",code:"CAP",name:"alpha Capricornids",radiantRaHours:20.47,radiantDecDeg:-9.2,start:{month:7,day:3},peak:{month:7,day:30},end:{month:8,day:15},peakZhr:5,velocityKmS:23,populationIndex:2.5},{id:"southern-delta-aquariids",code:"SDA",name:"Southern delta Aquariids",radiantRaHours:22.67,radiantDecDeg:-16.4,start:{month:7,day:12},peak:{month:7,day:30},end:{month:8,day:23},peakZhr:25,velocityKmS:41,populationIndex:3.2},{id:"perseids",code:"PER",name:"Perseids",radiantRaHours:3.22,radiantDecDeg:58,start:{month:7,day:17},peak:{month:8,day:12},end:{month:8,day:24},peakZhr:100,velocityKmS:59,populationIndex:2.2},{id:"southern-taurids",code:"STA",name:"Southern Taurids",radiantRaHours:3.47,radiantDecDeg:13,start:{month:9,day:10},peak:{month:10,day:10},end:{month:11,day:20},peakZhr:5,velocityKmS:27,populationIndex:2.3},{id:"draconids",code:"DRA",name:"October Draconids",radiantRaHours:17.47,radiantDecDeg:54,start:{month:10,day:6},peak:{month:10,day:8},end:{month:10,day:10},peakZhr:10,velocityKmS:20,populationIndex:2.6},{id:"orionids",code:"ORI",name:"Orionids",radiantRaHours:6.35,radiantDecDeg:15.6,start:{month:10,day:2},peak:{month:10,day:21},end:{month:11,day:7},peakZhr:20,velocityKmS:66,populationIndex:2.5},{id:"northern-taurids",code:"NTA",name:"Northern Taurids",radiantRaHours:3.87,radiantDecDeg:22,start:{month:10,day:20},peak:{month:11,day:12},end:{month:12,day:10},peakZhr:5,velocityKmS:29,populationIndex:2.3},{id:"leonids",code:"LEO",name:"Leonids",radiantRaHours:10.13,radiantDecDeg:21.6,start:{month:11,day:6},peak:{month:11,day:17},end:{month:11,day:30},peakZhr:15,velocityKmS:71,populationIndex:2.5},{id:"geminids",code:"GEM",name:"Geminids",radiantRaHours:7.47,radiantDecDeg:32.3,start:{month:12,day:4},peak:{month:12,day:14},end:{month:12,day:17},peakZhr:150,velocityKmS:35,populationIndex:2.6},{id:"ursids",code:"URS",name:"Ursids",radiantRaHours:14.47,radiantDecDeg:75.3,start:{month:12,day:17},peak:{month:12,day:22},end:{month:12,day:26},peakZhr:10,velocityKmS:33,populationIndex:3}],Ul=6.5;class yu{static activeAt(t){return BE.flatMap(e=>{const i=this.nearness(e,t);return i<=0?[]:[{shower:e,zhr:e.peakZhr*i,nearness:i}]})}static nearness(t,e){const i=this.dayOfYear(e),n=this.dayOfYear(this.asDate(t.start)),s=this.dayOfYear(this.asDate(t.peak)),a=this.dayOfYear(this.asDate(t.end)),o=this.wrappedDelta(i,s),c=this.wrappedDelta(s,n),l=this.wrappedDelta(a,s);return o<0?o<-c?0:1+o/c:o>0?o>l?0:1-o/l:1}static observedRatePerHour(t,e,i,n=Ul){if(e<=0)return 0;const s=Ul-n;return t*Math.sin(e*Math.PI/180)/Math.pow(i,s)}static radiantPosition(t,e,i){return Pn.ofJ2000(t.radiantRaHours,t.radiantDecDeg,e,i)}static dayOfYear(t){const e=Date.UTC(t.getUTCFullYear(),0,1);return Math.floor((Date.UTC(t.getUTCFullYear(),t.getUTCMonth(),t.getUTCDate())-e)/864e5)+1}static asDate(t){return new Date(Date.UTC(2001,t.month-1,t.day))}static wrappedDelta(t,e){const i=t-e;return i>182?i-365:i<-182?i+365:i}}class ti{static QUIET_RATE_PER_HOUR=2;static APEX_RATE_PER_HOUR=8;static POPULATION_INDEX=3;static apexPosition(t,e){const i=$e(t),n=new Zl(0,lw(t).elon-90,1),s=Cr(Ow(i),F0(n,i)),a=U0(s);return k0(a.ra,a.dec,t,e)}static observedRatePerHour(t,e=Ul){const i=ti.APEX_RATE_PER_HOUR*Math.max(0,Math.sin(t*Math.PI/180)),n=Ul-e;return(ti.QUIET_RATE_PER_HOUR+i)/Math.pow(ti.POPULATION_INDEX,n)}static schedule(t){const e=new Ql(t.seed^1542469173);return Pa.schedule(t).map(i=>{const n=ti.toCartesian({altitudeDeg:Math.asin(e.next())*180/Math.PI,azimuthDeg:e.between(0,360)}),s=i.fromRadiantDeg*Math.PI/180,a=ti.turnAround(n,e.between(0,360)),o={x:n.x*Math.cos(s)+a.x*Math.sin(s),y:n.y*Math.cos(s)+a.y*Math.sin(s),z:n.z*Math.cos(s)+a.z*Math.sin(s)};return{...i,radiant:ti.toHorizontal(o),bearingDeg:ti.bearingFrom(o,n)}})}static turnAround(t,e){const[i,n]=ti.basisAround(t),s=e*Math.PI/180;return{x:i.x*Math.cos(s)+n.x*Math.sin(s),y:i.y*Math.cos(s)+n.y*Math.sin(s),z:i.z*Math.cos(s)+n.z*Math.sin(s)}}static bearingFrom(t,e){const[i,n]=ti.basisAround(t),s=t.x*e.x+t.y*e.y+t.z*e.z,a=ti.normalise({x:e.x-t.x*s,y:e.y-t.y*s,z:e.z-t.z*s});return(Math.atan2(a.x*n.x+a.y*n.y+a.z*n.z,a.x*i.x+a.y*i.y+a.z*i.z)*180/Math.PI%360+360)%360}static basisAround(t){const e=Math.abs(t.y)<.9?{x:0,y:1,z:0}:{x:1,y:0,z:0},i=ti.normalise(ti.cross(t,e));return[i,ti.normalise(ti.cross(t,i))]}static toHorizontal(t){const e=Math.hypot(t.x,t.y,t.z)||1;return{altitudeDeg:Math.asin(Math.min(1,Math.max(-1,t.y/e)))*180/Math.PI,azimuthDeg:(Math.atan2(t.x,-t.z)*180/Math.PI%360+360)%360}}static appearanceOf(t){const e=ti.toCartesian(t.radiant??{altitudeDeg:90,azimuthDeg:0}),i=ti.turnAround(e,t.bearingDeg),n=t.fromRadiantDeg*Math.PI/180;return ti.toHorizontal({x:e.x*Math.cos(n)+i.x*Math.sin(n),y:e.y*Math.cos(n)+i.y*Math.sin(n),z:e.z*Math.cos(n)+i.z*Math.sin(n)})}static toCartesian(t){const e=t.altitudeDeg*Math.PI/180,i=t.azimuthDeg*Math.PI/180,n=Math.cos(e);return{x:n*Math.sin(i),y:Math.sin(e),z:-n*Math.cos(i)}}static cross(t,e){return{x:t.y*e.z-t.z*e.y,y:t.z*e.x-t.x*e.z,z:t.x*e.y-t.y*e.x}}static normalise(t){const e=Math.hypot(t.x,t.y,t.z)||1;return{x:t.x/e,y:t.y/e,z:t.z/e}}static TYPICAL_VELOCITY_KM_S=40}const Qm="https://ufoathome.org/tle/index.json";class Ii{static MAX_ELEMENT_AGE_DAYS=7;static DAY_MS=864e5;fetchImpl;indexUrls;index;files=new Map;constructor(t={}){this.fetchImpl=t.fetchImpl??fetch.bind(globalThis),this.indexUrls=t.indexUrls??Ii.defaultIndexUrls()}static defaultIndexUrls(){const t=[];return typeof location<"u"&&/^https?:$/.test(location.protocol)&&t.push(new URL("/tle/index.json",location.href).href),t.includes(Qm)||t.push(Qm),t}static FIRST_SNAPSHOT="2021-02-22";async covers(t){const e=Date.parse(`${Ii.FIRST_SNAPSHOT}T00:00:00Z`)-Ii.MAX_ELEMENT_AGE_DAYS*Ii.DAY_MS;if(t.getTime()<e)return!1;const i=await this.loadIndex();return i?Object.values(i.index.kinds).some(n=>t.getTime()>=Date.parse(n.from)-Ii.MAX_ELEMENT_AGE_DAYS*Ii.DAY_MS&&t.getTime()<=Date.parse(n.to)+Ii.MAX_ELEMENT_AGE_DAYS*Ii.DAY_MS):!1}async at(t){const e=await this.loadIndex();if(!e)return;const{index:i,base:n}=e,s=[],a=[];for(const o of Object.keys(i.kinds)){const c=await this.kindAt(o,t,i,n);s.push(...c),a.push(this.coverageOf(o,t,i,c.length>0))}return{objects:s,coverage:a,credit:i.credit,creditUrl:i.source}}async kindAt(t,e,i,n){const s=e.getTime(),a=i.binDays*Ii.DAY_MS,o=Math.floor(s/a),c=s-o*a<a/2?o-1:o+1,l=new Set(i.kinds[t].bins),h=[o,c].map(v=>new Date(v*a).toISOString().slice(0,10)).filter(v=>l.has(v));if(h.length===0)return[];const[u,...d]=await Promise.all([this.json(new URL(`objects-${t}.json`,n).href),...h.map(v=>this.binary(new URL(`${t}/${v}.bin`,n).href))]),f=new Map;for(const v of d)for(const m of Ii.decode(v,i.recordBytes)){const g=f.get(m.norad);(!g||Math.abs(m.epochMs-s)<Math.abs(g.epochMs-s))&&f.set(m.norad,m)}const p=[];for(const v of f.values()){const m=Math.abs(v.epochMs-s)/Ii.DAY_MS;if(m>Ii.MAX_ELEMENT_AGE_DAYS)continue;const g=u[v.norad]??{name:String(v.norad)};g.launch&&Date.parse(`${g.launch}T00:00:00Z`)>s||p.push({norad:v.norad,name:g.name,kind:t,launch:g.launch,stdMag:g.stdMag,elements:v,ageDays:m})}return p}coverageOf(t,e,i,n){const{from:s,to:a}=i.kinds[t],o=e.getTime(),c=Ii.MAX_ELEMENT_AGE_DAYS*Ii.DAY_MS,l=n?"covered":o<Date.parse(s)-c?"before":o>Date.parse(a)+c?"after":"gap";return{kind:t,status:l,from:s,to:a}}static decode(t,e){const i=new DataView(t),n=[];for(let s=0;s+e<=t.byteLength;s+=e)n.push({norad:i.getUint32(s,!0),epochMs:i.getFloat64(s+4,!0),bstar:i.getFloat32(s+12,!0),inclinationDeg:i.getFloat32(s+16,!0),raanDeg:i.getFloat32(s+20,!0),eccentricity:i.getFloat32(s+24,!0),argOfPerigeeDeg:i.getFloat32(s+28,!0),meanAnomalyDeg:i.getFloat32(s+32,!0),meanMotion:i.getFloat64(s+36,!0)});return n}loadIndex(){return this.index??=(async()=>{for(const t of this.indexUrls)try{const e=await this.fetchImpl(t);if(!e.ok)continue;return{index:await e.json(),base:t}}catch{}})(),this.index}json(t){return this.cached(t,async e=>e.json())}binary(t){return this.cached(t,async e=>e.arrayBuffer())}cached(t,e){let i=this.files.get(t);return i||(i=this.fetchImpl(t).then(n=>{if(!n.ok)throw new Error(`${t}: ${n.status}`);return e(n)}),i.catch(()=>this.files.delete(t)),this.files.set(t,i)),i}}class HE{lowerM;upperM;add(t,e){if(!(t<=0)){if(e.behindM!==void 0){const i=Te.sizeMAt(e.behindM,t);this.lowerM=this.lowerM===void 0?i:Math.max(this.lowerM,i)}if(e.inFrontM!==void 0){const i=Te.sizeMAt(e.inFrontM,t);this.upperM=this.upperM===void 0?i:Math.min(this.upperM,i)}}}get sizeRange(){return{minM:this.lowerM,maxM:this.upperM}}get empty(){return this.lowerM===void 0&&this.upperM===void 0}get contradictory(){return this.lowerM!==void 0&&this.upperM!==void 0&&this.lowerM>this.upperM}distanceRangeAt(t){return t<=0?{}:{minM:this.lowerM===void 0?void 0:Te.distanceMAt(this.lowerM,t),maxM:this.upperM===void 0?void 0:Te.distanceMAt(this.upperM,t)}}clear(){this.lowerM=void 0,this.upperM=void 0}}class Oa{static DEG_PER_SECOND=360/86164.0905;static degOver(t){return Math.max(0,t)*Oa.DEG_PER_SECOND}static instants(t,e){if(!(e>0))return 1;const i=Oa.degOver(t)/e;return i<1?1:Math.min(Oa.MAX_INSTANTS,Math.max(2,Math.ceil(i)))}static MAX_INSTANTS=64}class zi{static EYE={apertureMm:7,exposureSeconds:.1,resolutionArcsec:60};static WAVELENGTH_M=55e-8;static ARCSEC_PER_RADIAN=180*3600/Math.PI;static UNKNOWN_CAMERA_FOCAL_MM=50;static UNKNOWN_CAMERA_DETAIL_UM=20;static get skyDriftArcsecPerSecond(){return Oa.DEG_PER_SECOND*3600}static graspOf(t,e={}){const i=e.exposureSeconds??t.exposureSeconds,n=e.fNumber??t.fNumber;if(i===void 0||n===void 0||!(i>0)||!(n>0))return zi.EYE;const s=e.focalLengthMm??t.frame?.focalLengthMm??zi.UNKNOWN_CAMERA_FOCAL_MM,a=s/n,o=zi.resolutionArcsec(t,s,a);return{apertureMm:a,exposureSeconds:Math.min(i,zi.trailLimitedSeconds(o)),resolutionArcsec:o}}static resolutionArcsec(t,e,i){const s=(t.detailUm??zi.UNKNOWN_CAMERA_DETAIL_UM)/1e3/e*zi.ARCSEC_PER_RADIAN,a=1.22*zi.WAVELENGTH_M/(i/1e3)*zi.ARCSEC_PER_RADIAN;return Math.max(s,a)}static trailLimitedSeconds(t){return t/zi.skyDriftArcsecPerSecond}static gainOverEye(t,e={}){const i=zi.graspOf(t,e),n=zi.EYE,s=(i.apertureMm/n.apertureMm)**2,a=i.exposureSeconds/n.exposureSeconds,o=(n.resolutionArcsec/i.resolutionArcsec)**2;return 1.25*Math.log10(s*a*o)}static gainFor(t,e){const i=e.fieldOfViewDeg===void 0?void 0:fi.focalLengthMmFor(t,e.fieldOfViewDeg);return zi.gainOverEye(t,{fNumber:e.fNumber,focalLengthMm:i,exposureSeconds:e.exposureSeconds})}}const tg=111320,po=Math.PI/180,GE=1.02,VE=1;class Io{static of(t,e){const i=Io.sightings(t,e);if(i.length<2)return;const n=Io.baseline(i);if(!n)return;const{near:s,far:a,closedM:o}=n,c=Math.tan(a.widthDeg/2*po)===0?0:Math.tan(s.widthDeg/2*po)/Math.tan(a.widthDeg/2*po);if(c<GE)return;const l=o/(c-1),h=Te.sizeMAt(l,s.widthDeg),u=i.map(d=>({t:d.t,m:Te.distanceMAt(h,d.widthDeg)}));return{widthM:h,distanceM:u,nearestM:Math.min(...u.map(d=>d.m)),fromT:a.t,toT:s.t,closedM:o}}static sightings(t,e){return t.timeline.allKeyframes.flatMap(i=>{const n=i.shapes.find(o=>o.sourceId===e)?.shape,s=n?.angular?.widthDeg,a=di(t,i.t);return s===void 0||s<=0||a?.lat===void 0||a.lng===void 0?[]:[{t:i.t,widthDeg:s,lat:a.lat,lng:a.lng,sightAzimuthDeg:n?.aim?.azimuthDeg??a.headingDeg}]}).sort((i,n)=>i.t-n.t)}static baseline(t){let e;for(const i of t)for(const n of t){if(i.t>=n.t)continue;const s=Io.closedAlongSight(i,n),[a,o,c]=s>=0?[n,i,s]:[i,n,-s];c<VE||a.widthDeg<=o.widthDeg||(!e||c>e.closedM)&&(e={near:a,far:o,closedM:c})}return e}static closedAlongSight(t,e){const i=(e.lat-t.lat)*tg,n=(e.lng-t.lng)*tg*Math.cos(t.lat*po),s=(t.sightAzimuthDeg??0)*po;return i*Math.cos(s)+n*Math.sin(s)}}class ki{static CONVENTIONAL_M=5;static NEAREST_M=.2;static MARGIN=1.1;static resolve(t){if(t.statedM!==void 0&&t.statedM>0)return{distanceM:ki.atLeastNearest(t.statedM),basis:"stated"};if(t.hypothesisM!==void 0&&t.hypothesisM>0)return{distanceM:ki.atLeastNearest(t.hypothesisM),basis:"hypothesis"};if(t.derivedM!==void 0&&t.derivedM>0)return{distanceM:ki.atLeastNearest(t.derivedM),basis:"derived"};const e=ki.largest(t.range?.minM,t.crossing?.behindM),i=ki.smallest(t.range?.maxM,t.crossing?.inFrontM),n=e===void 0?void 0:e*ki.MARGIN,s=i===void 0?void 0:i/ki.MARGIN;return n!==void 0&&s!==void 0?{distanceM:ki.atLeastNearest(n<=s?Math.sqrt(n*s):n),basis:"bounded"}:n!==void 0?{distanceM:ki.atLeastNearest(n),basis:"bounded"}:s!==void 0&&s<ki.CONVENTIONAL_M?{distanceM:ki.atLeastNearest(s),basis:"bounded"}:{distanceM:ki.CONVENTIONAL_M,basis:"conventional"}}static atLeastNearest(t){return Math.max(ki.NEAREST_M,t)}static largest(...t){const e=t.filter(i=>i!==void 0&&i>0);return e.length===0?void 0:Math.max(...e)}static smallest(...t){const e=t.filter(i=>i!==void 0&&i>0);return e.length===0?void 0:Math.min(...e)}}const _u=Math.PI/180;class te{constructor(t,e,i){this.body=t,this.ground=e;const n=[...t.track].sort((s,a)=>s.t-a.t);this.keys=this.place(n,i);for(const s of n)te.collect(this.motionKeys,s.t,s.motions),te.collect(this.lightKeys,s.t,s.lights)}static EYE_HEIGHT_M=1.6;static MAX_RANGE_M=3e4;static DEFAULT_SIZE={widthM:1,lengthM:1,heightM:1};static DEFAULT_APPEARANCE={color:"#c8c8c8",albedo:.5,luminanceCdM2:0};keys;motionKeys=new Map;lightKeys=new Map;static collect(t,e,i){for(const[n,s]of Object.entries(i??{})){const a=t.get(n)??[];a.push({t:e,value:s}),t.set(n,a)}}motionsAt(t){return te.channelsAt(this.motionKeys,t,0)}lightsAt(t){return this.lightKeys.size>0?te.channelsAt(this.lightKeys,t,void 0):void 0}static channelsAt(t,e,i){const n={};for(const[s,a]of t){let o=a.length-1;for(;o>=0&&a[o].t>e;)o--;if(o<0){i!==void 0&&(n[s]=i);continue}const c=a[o],l=a[Math.min(o+1,a.length-1)],h=l===c||l.t===c.t?0:Math.min(1,(e-c.t)/(l.t-c.t));n[s]=te.lerp(c.value,l.value,h)}return n}static eyeOf(t,e,i){const n=di(t,0),s=di(t,e),o=n?.lat!==void 0&&n.lng!==void 0&&s?.lat!==void 0&&s.lng!==void 0?ai(s.lat,s.lng,n.lat,n.lng):void 0,c=o?o.x:0,l=o?-o.z:0;return{eastM:c,northM:l,upM:i.heightAt(c,l)+te.EYE_HEIGHT_M+(s?.elevationM??0),headingDeg:s?.headingDeg}}static lineOfSightMeetsGround(t,e,i,n){const s=te.directionOf(e,i),a=l=>t.upM+s.upM*l-n.heightAt(t.eastM+s.eastM*l,t.northM+s.northM*l);let o=0,c=0;for(;c<te.MAX_RANGE_M;){if(c=o+Math.max(.5,o*.01),a(c)<=0){for(let l=0;l<30;l++){const h=(o+c)/2;a(h)<=0?c=h:o=h}return c}o=c}}static directionOf(t,e){const i=t*_u,n=e*_u;return{eastM:Math.sin(i)*Math.cos(n),northM:Math.cos(i)*Math.cos(n),upM:Math.sin(n)}}at(t){const e=this.keys;if(e.length===0||t<e[0].t)return;let i=e.length-1;for(;i>0&&e[i].t>t;)i--;const n=e[i];if(!n.present)return;const s=e[Math.min(i+1,e.length-1)],a=s===n||s.t===n.t?0:Math.min(1,(t-n.t)/(s.t-n.t)),o=te.lerp(n.eastM,s.eastM,a),c=te.lerp(n.northM,s.northM,a),l={widthM:te.lerp(n.sizeM.widthM,s.sizeM.widthM,a),lengthM:te.lerp(n.sizeM.lengthM,s.sizeM.lengthM,a),heightM:te.lerp(n.sizeM.heightM,s.sizeM.heightM,a)},h={headingDeg:te.lerpAngle(n.attitude.headingDeg,s.attitude.headingDeg,a),pitchDeg:te.lerp(n.attitude.pitchDeg,s.attitude.pitchDeg,a),rollDeg:te.lerp(n.attitude.rollDeg,s.attitude.rollDeg,a)};let u;if("aboveGroundM"in n.vertical&&"aboveGroundM"in s.vertical){const d=te.lerp(n.vertical.aboveGroundM,s.vertical.aboveGroundM,a);u=this.groundUnderFootprint(o,c,l,h.headingDeg)+d+l.heightM/2}else u=te.lerp(this.centreUpOf(n),this.centreUpOf(s),a);return{id:this.body.id,model:this.body.model,explains:this.body.explains??[],outlineNode:this.body.outlineNode,eastM:o,northM:c,upM:u,sizeM:l,attitude:h,appearance:{color:(a<1?n:s).appearance.color,albedo:te.lerp(n.appearance.albedo,s.appearance.albedo,a),luminanceCdM2:te.lerp(n.appearance.luminanceCdM2,s.appearance.luminanceCdM2,a)},flame:te.flameBetween(n.flame,s.flame,a),motions:this.motionsAt(t),lights:this.lightsAt(t),throwsFlame:this.body.track.some(d=>d.flame!==void 0&&d.flame.luminanceCdM2>0)}}static flameBetween(t,e,i){if(!t||t.luminanceCdM2<=0)return i>=1&&e&&e.luminanceCdM2>0?e:void 0;const n=t,s=e??t,a={...i<1?n:s,lengthM:te.lerp(n.lengthM,s.lengthM,i),widthM:te.lerp(n.widthM,s.widthM,i),luminanceCdM2:te.lerp(n.luminanceCdM2,s.luminanceCdM2,i)};return a.luminanceCdM2>0?a:void 0}centreUpOf(t){return"upM"in t.vertical?t.vertical.upM:this.groundUnderFootprint(t.eastM,t.northM,t.sizeM,t.attitude.headingDeg)+t.vertical.aboveGroundM+t.sizeM.heightM/2}groundUnderFootprint(t,e,i,n){const s=n*_u,a={eastM:Math.cos(s),northM:-Math.sin(s)},o={eastM:Math.sin(s),northM:Math.cos(s)};let c=this.ground.heightAt(t,e);for(const[l,h]of[[-1,-1],[1,-1],[-1,1],[1,1]]){const u=l*i.widthM/2,d=h*i.lengthM/2;c=Math.max(c,this.ground.heightAt(t+a.eastM*u+o.eastM*d,e+a.northM*u+o.northM*d))}return c}place(t,e){const i=[];let n;for(const s of t){const a=s.sizeM??n?.sizeM??te.DEFAULT_SIZE,o={headingDeg:s.attitude?.headingDeg??n?.attitude.headingDeg??0,pitchDeg:s.attitude?.pitchDeg??n?.attitude.pitchDeg??0,rollDeg:s.attitude?.rollDeg??n?.attitude.rollDeg??0},c={color:s.appearance?.color??n?.appearance.color??te.DEFAULT_APPEARANCE.color,albedo:s.appearance?.albedo??n?.appearance.albedo??te.DEFAULT_APPEARANCE.albedo,luminanceCdM2:s.appearance?.luminanceCdM2??n?.appearance.luminanceCdM2??te.DEFAULT_APPEARANCE.luminanceCdM2},l=this.positionOf(s,e)??(n&&{eastM:n.eastM,northM:n.northM,vertical:this.verticalOf(s)??n.vertical});if(!l)continue;const h=s.flame??n?.flame,u=s.present??n?.present??!0;n={t:s.t,...l,sizeM:a,attitude:o,appearance:c,flame:h,present:u},i.push(n)}return i}verticalOf(t){if(t.onGround)return{aboveGroundM:0};if(t.altitudeAboveGroundM!==void 0)return{aboveGroundM:t.altitudeAboveGroundM}}positionOf(t,e){if(t.eastM!==void 0&&t.northM!==void 0)return{eastM:t.eastM,northM:t.northM,vertical:this.verticalOf(t)??{aboveGroundM:0}};if(t.azimuthDeg===void 0||t.altitudeDeg===void 0)return;const i=e(t.t);if(!i)return;const n=t.distanceM??(t.onGround?te.lineOfSightMeetsGround(i,t.azimuthDeg,t.altitudeDeg,this.ground):void 0);if(n===void 0)return;const s=te.directionOf(t.azimuthDeg,t.altitudeDeg),a=i.eastM+s.eastM*n,o=i.northM+s.northM*n;return{eastM:a,northM:o,vertical:this.verticalOf(t)??{upM:i.upM+s.upM*n}}}static lerp(t,e,i){return t+(e-t)*i}static lerpAngle(t,e,i){const n=((e-t)%360+540)%360-180;return((t+n*i)%360+360)%360}}const ur=Math.PI/180,mo=180/Math.PI;class Qe{constructor(t){this.timeline=t}static DIRECTION_TOLERANCE_DEG=1;static SIZE_TOLERANCE=1.5;static RINGS=12;static SEGMENTS=24;at(t,e,i,n){const s=[];for(const a of e){const o=Qe.projectionOf(a,i,n?.(a));if(o)for(const c of a.explains){const l=this.timeline.getInterpolatedShapeAt(t,c);!l||l.transparency>=1||s.push({...Qe.compare(c,a.id,{aim:l.aim,angular:l.angular},o),title:l.title})}}return s}static compare(t,e,i,n){const s=[],a=i.aim?Qe.separationDeg(i.aim,n.aim):void 0;if(a!==void 0){const l=Math.max(i.angular?.widthDeg??0,n.angular.widthDeg)/2;a>Math.max(Qe.DIRECTION_TOLERANCE_DEG,l)&&s.push("direction")}const o=i.angular&&i.angular.widthDeg>0?n.angular.widthDeg/i.angular.widthDeg:void 0,c=i.angular&&i.angular.heightDeg>0?n.angular.heightDeg/i.angular.heightDeg:void 0;return o!==void 0&&!Qe.withinSize(o)&&s.push("width"),c!==void 0&&!Qe.withinSize(c)&&s.push("height"),{sourceId:t,bodyId:e,stated:i,predicted:n,separationDeg:a,widthRatio:o,heightRatio:c,disagreements:s}}static projectionOf(t,e,i){const n=i&&i.length>0?i:Qe.outlineOf(t),s=i&&i.length>0?Qe.centreOf(i):t,a=Qe.normalized({eastM:s.eastM-e.eastM,northM:s.northM-e.northM,upM:s.upM-e.upM});if(!a)return;const o=Qe.normalized({eastM:a.northM,northM:-a.eastM,upM:0})??{eastM:1,northM:0,upM:0},c=Qe.cross(o,a);let l=1/0,h=-1/0,u=1/0,d=-1/0;for(const f of n){const p={eastM:f.eastM-e.eastM,northM:f.northM-e.northM,upM:f.upM-e.upM},v=Qe.dot(p,a);if(v<=0)return;const m=Math.atan2(Qe.dot(p,o),v),g=Math.atan2(Qe.dot(p,c),v);l=Math.min(l,m),h=Math.max(h,m),u=Math.min(u,g),d=Math.max(d,g)}return{aim:{azimuthDeg:(Math.atan2(a.eastM,a.northM)*mo+360)%360,altitudeDeg:Math.asin(Math.max(-1,Math.min(1,a.upM)))*mo},angular:{widthDeg:(h-l)*mo,heightDeg:(d-u)*mo}}}static centreOf(t){const e=i=>(Math.min(...t.map(n=>n[i]))+Math.max(...t.map(n=>n[i])))/2;return{eastM:e("eastM"),northM:e("northM"),upM:e("upM")}}static separationDeg(t,e){const i=t.altitudeDeg*ur,n=e.altitudeDeg*ur,s=Math.sin(i)*Math.sin(n)+Math.cos(i)*Math.cos(n)*Math.cos((t.azimuthDeg-e.azimuthDeg)*ur);return Math.acos(Math.max(-1,Math.min(1,s)))*mo}static withinSize(t){return t<=Qe.SIZE_TOLERANCE&&t>=1/Qe.SIZE_TOLERANCE}static outlineOf(t){const e=t.sizeM.widthM/2,i=t.sizeM.lengthM/2,n=t.sizeM.heightM/2,s=[],a=t.model.url===void 0?t.model.id:void 0;if(a!==void 0&&a!=="box"&&G1.includes(a))for(let u=0;u<=Qe.RINGS;u++){const d=u/Qe.RINGS*Math.PI;for(let f=0;f<Qe.SEGMENTS;f++){const p=f/Qe.SEGMENTS*2*Math.PI;s.push([e*Math.sin(d)*Math.cos(p),i*Math.sin(d)*Math.sin(p),n*Math.cos(d)])}}else for(const u of[-e,e])for(const d of[-i,i])for(const f of[-n,n])s.push([u,d,f]);const c=t.attitude.headingDeg*ur,l=t.attitude.pitchDeg*ur,h=t.attitude.rollDeg*ur;return s.map(([u,d,f])=>{const p=u*Math.cos(h)+f*Math.sin(h),v=-u*Math.sin(h)+f*Math.cos(h),m=d*Math.cos(l)-v*Math.sin(l),g=d*Math.sin(l)+v*Math.cos(l);return{eastM:t.eastM+p*Math.cos(c)+m*Math.sin(c),northM:t.northM-p*Math.sin(c)+m*Math.cos(c),upM:t.upM+g}})}static dot(t,e){return t.eastM*e.eastM+t.northM*e.northM+t.upM*e.upM}static cross(t,e){return{eastM:t.northM*e.upM-t.upM*e.northM,northM:t.upM*e.eastM-t.eastM*e.upM,upM:t.eastM*e.northM-t.northM*e.eastM}}static normalized(t){const e=Math.hypot(t.eastM,t.northM,t.upM);return e>1e-9?{eastM:t.eastM/e,northM:t.northM/e,upM:t.upM/e}:void 0}}yg();const WE={sun:"Sun",moon:"Moon",Venus:"Venus",Mars:"Mars",Jupiter:"Jupiter",Saturn:"Saturn"},XE="{name} — mag {mag}, {alt}° above the horizon",YE="{name} — satellite, mag {mag}, {height} km up",qE="satellites-change",$E="rr0-confrontation",KE="{name} — mag {mag}, {alt}° below the horizontal",Su="Credits",eg="comet:",ig="nova:",ZE={building:"Building",tree:"Tree",shrub:"Shrub",bridge:"Bridge",crop:"Crop row",mound:"Stone heap",streetlight:"Streetlight",vehicle:"Vehicle",observer:"Observer",aircraft:"Aircraft",entity:"Being"},JE=new URL(""+new URL("stars-mag7.5-B43R6Wvg.bin",import.meta.url).href,import.meta.url).href,jE=new URL(""+new URL("stars-mag7.5-9-BLV2tFmZ.bin",import.meta.url).href,import.meta.url).href,QE=-18,tA={sun:{altitudeDeg:-3,azimuthDeg:180,magnitude:-26.7},moon:{altitudeDeg:-90,azimuthDeg:0,phase:{phaseFraction:0,illuminatedFraction:0},magnitude:-12.7},planets:[]},bu={lat:0,lng:0,elevationM:0,headingDeg:void 0,pitchDeg:0,fovDeg:60};class H0 extends HTMLElement{creditsButton;set ownCredits(t){this.creditsButton.hidden=!t}static get observedAttributes(){return["src","star-catalog-src","deep-star-catalog-src","show-compass","max-pixel-ratio",_r,Sr]}shadow;stageElement;frameElement;sceneCanvas;loaderNote;loaderNotVideo;ufoElement;sceneRenderer;hoverTooltip;resizeObserver;sizeEstimates=new Map;sizeEstimatesFor;distanceHypotheses=new Map;depths=new Map;directionScratch=new R;meteorScheduleFor;lightningScheduleFor;lightningFlashes=[];lastLightningT;lastTimeMs=0;interpretationShown;confrontationReadings=[];confrontationSignature="";comparing=!1;inTheRound=!0;lastSkyKey;starCatalog;starCatalogRequest=0;static tleArchive=new Ii;satellitesFor;satelliteRequest=0;satelliteStatus="none";satellites;satellitePassesMemo;starCatalogDepth=0;weatherAudio=new kE;vehicleAudio=new nv;vehicleHearing=new dl;animateWhilePausedValue=!1;set animateWhilePaused(t){t!==this.animateWhilePausedValue&&(this.animateWhilePausedValue=t,this.syncAnimationsToPlayback())}get animateWhilePaused(){return this.animateWhilePausedValue}thunderTimeoutId;handleFullscreenChange=()=>this.resizeToStage();handlePointerMove=t=>{this.sceneRenderer.setCompassHovered(!0);const e=this.ufoElement.canvasElement,i=e.getBoundingClientRect();if(i.width===0||i.height===0)return;const n=(t.clientX-i.left)/i.width*e.width,s=(t.clientY-i.top)/i.height*e.height;if(this.ufoElement.hasVisibleShapeAt(n,s)){this.hoverTooltip.hidden=!0;return}const a=(t.clientX-i.left)/i.width*2-1,o=-((t.clientY-i.top)/i.height*2-1),c=this.naming,l=c.names,h=this.sceneRenderer.pickBodyAt(a,o);if(h){this.showHoverTooltip(t,this.bodyName(h));return}const u=this.sceneRenderer.pickDecorAt(a,o),d=u?this.ufoElement.sighting.decor.find(v=>v.id===u):void 0;if(d){this.showHoverTooltip(t,this.said.read(d.title)||c.decorKind(d.kind,ZE[d.kind]));return}const f=this.sceneRenderer.pickSatelliteAt(a,o);if(f){this.showHoverTooltip(t,(l?.satelliteTooltip??YE).replace("{name}",f.name).replace("{mag}",f.magnitude.toLocaleString(void 0,{maximumFractionDigits:1})).replace("{height}",Math.round(f.heightKm).toLocaleString()));return}const p=this.sceneRenderer.pickStarAt(a,o);if(p){const v=p.star.mag,m=p.altitudeDeg,g=m<0?l?.starTooltipBelow??KE:l?.starTooltip??XE;this.showHoverTooltip(t,g.replace("{name}",c.star(p.star)).replace("{mag}",v.toLocaleString(void 0,{maximumFractionDigits:Math.abs(v)<1?2:1})).replace("{alt}",String(Math.round(Math.abs(m)))));return}this.hoverTooltip.hidden=!0};bodyName(t){const e=t.startsWith(eg)?t.slice(eg.length):void 0,i=e?X1.find(a=>a.id===e):void 0;if(i)return this.naming.comet(i);const n=t.startsWith(ig)?jm.byId(t.slice(ig.length)):void 0;if(n)return this.naming.nova(n);const s=WE[t];return s===void 0?t:this.naming.body(t,s)}get naming(){return this.sceneNaming}sceneNaming=new Jm;namesLanguage="en";async loadSceneNames(){const t=cg(pl.preferencesFor(this),lg);if(t===this.namesLanguage)return;this.namesLanguage=t;const e=await Xv(t);t===this.namesLanguage&&this.applySceneNaming(new Jm(e))}renderLoaderText(t,e){let i=0;const n=(s,a)=>{s.setAttribute("aria-label",a),s.replaceChildren(),a.split(" ").forEach((o,c)=>{c>0&&s.append(" ");const l=document.createElement("span");l.className="scene-loader-word",l.setAttribute("aria-hidden","true");for(const h of o){const u=document.createElement("span");u.className="scene-loader-letter",u.style.setProperty("--i",String(i++)),u.textContent=h,l.append(u)}s.append(l),i++})};n(this.loaderNotVideo,t),i+=6,n(this.loaderNote,e)}applySceneNaming(t){this.sceneNaming=t;const e=t.names?.credits??Su;this.creditsButton.title=e,this.creditsButton.setAttribute("aria-label",e),t.names&&this.renderLoaderText(t.names.notAVideo,t.names.isASimulation),this.sceneRenderer.setCompassPoints(t.names?.compassPoints)}showHoverTooltip(t,e){this.hoverTooltip.textContent=e,this.hoverTooltip.hidden=!1;const i=this.stageElement.getBoundingClientRect();this.hoverTooltip.style.left=`${t.clientX-i.left+12}px`,this.hoverTooltip.style.top=`${t.clientY-i.top+12}px`}handlePointerLeave=()=>{this.hoverTooltip.hidden=!0,this.sceneRenderer.setCompassHovered(!1)};handleLightningFlash(t){clearTimeout(this.thunderTimeoutId),this.thunderTimeoutId=window.setTimeout(()=>this.weatherAudio.playThunder(),pi.thunderDelayMs(t))}handleFirstInteraction=()=>{this.weatherAudio.resume(),this.vehicleAudio.resume(),!this.interacted&&(this.interacted=!0,this.setWeather(of(this.ufoElement.sighting,this.lastTimeMs)))};interacted=!1;handleTimeUpdate=t=>{this.lastTimeMs=t.detail.time,this.syncAnimationsToPlayback(),this.updateAstronomy(this.lastTimeMs),this.ufoElement.playbackState==="playing"&&this.sceneRenderer.frame(performance.now())};syncAnimationsToPlayback(){const t=this.ufoElement.playbackState==="playing",e=t||this.animateWhilePaused;this.sceneRenderer.setAnimationsRunning(e,t),this.weatherAudio.setPaused(!t),this.vehicleAudio.setPaused(!t),t||clearTimeout(this.thunderTimeoutId)}constructor(){super(),this.shadow=this.attachShadow({mode:"open"});const t=document.createElement("template");t.innerHTML=`<style>${cv}</style>${ov}`,this.shadow.appendChild(t.content.cloneNode(!0)),this.stageElement=this.shadow.getElementById("stage"),this.frameElement=this.shadow.getElementById("frame"),this.sceneCanvas=this.shadow.getElementById("scene-canvas"),this.sceneRenderer=new Oe(this.sceneCanvas);const e=this.shadow.getElementById("scene-loader");this.loaderNote=this.shadow.getElementById("scene-loader-note"),this.loaderNotVideo=this.shadow.getElementById("scene-loader-not-video"),this.renderLoaderText("This is not a video","It is a real-time simulation."),this.sceneRenderer.onFirstFrameHold=s=>{e.hidden=!s,this.ufoElement.captionHeld=s},this.hoverTooltip=this.shadow.getElementById("hover-tooltip"),this.ufoElement=document.createElement(Au),this.ufoElement.classList.add("ufo-overlay"),this.ufoElement.paintsShapes=!1,this.forwardPlayerAttributes(),this.ufoElement.addEventListener("lookat",s=>this.lookToward(s.detail)),this.ufoElement.style.setProperty("--ufo-canvas-background","transparent"),this.ufoElement.style.setProperty("--ufo-canvas-border","none"),this.ufoElement.fullscreenTarget=this.stageElement,this.shadow.getElementById("ufo-slot").replaceWith(this.ufoElement),this.ufoElement.creditShownExternally=!0,this.creditsButton=this.shadow.getElementById("credits-button");const i=this.shadow.getElementById("credits-panel"),n=this.shadow.getElementById("credits-list");i.addEventListener("beforetoggle",s=>{s.newState==="open"&&$n.fill(n,this)}),this.creditsButton.title=Su,this.creditsButton.setAttribute("aria-label",Su),this.sceneRenderer.onMapSubjectBounds=s=>this.ufoElement.setMapSubjectBounds(s),this.ufoElement.addEventListener("timeupdate",this.handleTimeUpdate),this.ufoElement.seekPreviewPainter=(s,a)=>this.seekPreviewOf(a).paint(s,a),this.ufoElement.addEventListener("mutedchange",()=>this.weatherAudio.setLevel(this.ufoElement.level)),this.ufoElement.addEventListener("referenceview",s=>this.applyReferenceView(s.detail)),this.ufoElement.canvasElement.addEventListener("pointermove",this.handlePointerMove),this.ufoElement.canvasElement.addEventListener("pointerleave",this.handlePointerLeave);for(const s of["pointerdown","pointerup","touchend","click","keydown"])this.addEventListener(s,this.handleFirstInteraction,!0)}get said(){return this.saidTexts??=new Ks(pl.preferencesFor(this))}saidTexts;connectedCallback(){this.saidTexts=void 0,this.loadSceneNames(),this.sceneRenderer.restoreContext(),this.resizeToStage(),this.updateAstronomy(this.lastTimeMs),this.loadStars(),this.resizeObserver=new ResizeObserver(()=>this.resizeToStage()),this.resizeObserver.observe(this.frameElement),document.addEventListener("fullscreenchange",this.handleFullscreenChange);const t=this.getAttribute("src");t&&this.loadFromSrc(t)}disconnectedCallback(){this.resizeObserver?.disconnect(),document.removeEventListener("fullscreenchange",this.handleFullscreenChange),this.sceneRenderer.stopTwinkle(),clearTimeout(this.thunderTimeoutId),this.weatherAudio.dispose(),this.vehicleAudio.dispose(),this.seekPreview?.dispose(),this.seekPreview=void 0,queueMicrotask(()=>{this.isConnected||this.sceneRenderer.releaseContext()})}attributeChangedCallback(t,e,i){if(t==="src"&&i&&i!==e&&this.isConnected&&this.loadFromSrc(i),(t==="star-catalog-src"||t==="deep-star-catalog-src")&&i!==e&&this.isConnected&&this.loadStars(),t==="show-compass"&&i!==e&&this.sceneRenderer.setShowCompass(this.hasAttribute("show-compass")),t==="max-pixel-ratio"&&i!==e){const n=Number(i);this.sceneRenderer.setMaxPixelRatio(Number.isFinite(n)&&n>0?n:Math.min(window.devicePixelRatio||1,2))}(t===_r||t===Sr)&&i!==e&&this.forwardPlayerAttributes()}forwardPlayerAttributes(){for(const t of[_r,Sr]){const e=this.getAttribute(t);e===null?this.ufoElement.removeAttribute(t):this.ufoElement.setAttribute(t,e)}}setCompassForced(t){this.sceneRenderer.setCompassForced(t)}lookToward(t){const e=di(this.ufoElement.sighting,this.lastTimeMs);if(t.kind==="observer"||e?.lat===void 0||e.lng===void 0||e.headingDeg===void 0){this.setLookOffset(0,0);return}const{x:i,z:n}=ai(t.lat,t.lng,e.lat,e.lng);if(Math.hypot(i,n)<1)return this.setLookOffset(0,0);const s=(Math.atan2(i,-n)*180/Math.PI+360)%360;this.setLookOffset(((s-e.headingDeg)%360+540)%360-180,-e.pitchDeg)}setLookOffset(t,e){this.sceneRenderer.setLookOffset(t,e),this.ufoElement.setLookOffset(t,e),this.updateAstronomy(this.lastTimeMs)}setIndoorLook(t,e){this.sceneRenderer.setIndoorLook(t,e)}setCloudRendering(t){this.sceneRenderer.setCloudRendering(t)}setWeather(t){this.sceneRenderer.setWeather(t),this.weatherAudio.setAmbient(t.precipitationType,t.precipitationIntensity*(t.precipitationAmount??1),t.windSpeed)}pickCloudAt(t,e){return this.sceneRenderer.pickCloudAt(t,e)}cloudDirectionAt(t,e){return this.sceneRenderer.cloudDirectionAt(t,e)}pickDecorAt(t,e){return this.sceneRenderer.pickDecorAt(t,e)}bodyScreenBox(t){return this.sceneRenderer.bodyScreenBox(t)}pickPlacedBodyAt(t,e){return this.sceneRenderer.pickPlacedBodyAt(t,e)}resumeWeatherAudio(){this.weatherAudio.resume(),this.vehicleAudio.resume()}async loadFromSrc(t){const e=rg.json(t);this.holdForNewScene(e);const i=await e;this.documentUrl=new URL(t,location.href).href,this.sightingData=i}holdForNewScene(t){this.sceneRenderer.holdForNewScene(t)}get documentUrl(){return this.sceneRenderer.documentUrl}set documentUrl(t){this.sceneRenderer.documentUrl=t}get sightingData(){return this.ufoElement.sightingData}set sightingData(t){this.ufoElement.sightingData=t,this.seekPreview?.recordingChanged(t),this.interpretationShown=this.inTheRound?this.ufoElement.sighting.interpretation:void 0,this.applyFrameFormat(),this.lastTimeMs=0,this.sceneRenderer.compileNextFrameOffThread(),this.updateAstronomy(0)}seekPreview;seekPreviewOf(t){const e=this.sceneCanvas.width>0&&this.sceneCanvas.height>0?this.sceneCanvas.width/this.sceneCanvas.height:1.7777777777777777,i=Math.round(t.width/e);return t.height!==i&&(t.height=i),this.seekPreview??=new Fl(this,()=>document.createElement(Zd))}showAt(t){this.ufoElement.currentTime=t,this.framesAtAsk=this.sceneRenderer.framesDrawn}framesAtAsk=0;snapshotTo(t){if(this.sceneRenderer.frame(performance.now()),this.sceneRenderer.framesDrawn===this.framesAtAsk)return!1;const e=t.getContext("2d");return e?(e.drawImage(this.sceneCanvas,0,0,t.width,t.height),!0):!1}referenceAspect(t){return this.sceneRenderer.referenceAspect(t)}screenPointOf(t){return this.sceneRenderer.screenPointOf(t)}directionAt(t,e){return this.sceneRenderer.directionAt(t,e)}referenceFailedToLoad(t){return this.sceneRenderer.referenceFailedToLoad(t)}applyReferenceView(t){this.sceneRenderer.setReferencesShown(t.shown);for(const e of this.ufoElement.sighting.references)this.sceneRenderer.setReferenceView(e.id,{opacity:t.opacity})}get currentTerrainAttribution(){return this.sceneRenderer.currentTerrainAttribution}get currentRoadAttribution(){return this.sceneRenderer.currentRoadAttribution}setTerrainProviders(t){this.sceneRenderer.setTerrainProviders(t)}setDecorModelProvider(t){this.sceneRenderer.setDecorModelProvider(t)}get decorModelCredits(){return this.sceneRenderer.currentDecorModelCredits}applyFrameFormat(){const t=this.ufoElement.sighting.instrument,e=Te.CANVAS_HEIGHT_PX,i=fi.frameWidthPx(t,e);this.frameElement.style.setProperty("--frame-aspect",`${i} / ${e}`)}resizeToStage(){const t=this.frameElement.getBoundingClientRect(),e=Math.max(1,Math.round(t.width)),i=Math.max(1,Math.round(t.height));this.sceneCanvas.width=e,this.sceneCanvas.height=i,this.sceneRenderer.resize(e,i)}async loadStars(){const t=[{magnitudeLimit:vu,url:this.getAttribute("star-catalog-src")??JE},{magnitudeLimit:Mu,url:this.getAttribute("deep-star-catalog-src")??jE}],e=this.instrumentReach(),i=++this.starCatalogRequest;this.starCatalogDepth=e>vu?Mu:vu;const n=await qn.upTo(t,e);i===this.starCatalogRequest&&(this.starCatalog=n,this.sceneRenderer.compileNextFrameOffThread(),this.updateAstronomy(this.lastTimeMs))}ensureStarsDeepEnough(){!this.starCatalog||this.starCatalogDepth>=Mu||this.instrumentReach()<=this.starCatalogDepth||this.loadStars()}instrumentReach(){const t=this.ufoElement.sighting,e=zi.gainFor(t.instrument,{fNumber:di(t,0)?.fNumber,fieldOfViewDeg:Ji.fovOf(t,0),exposureSeconds:t.exposure});return Ad(QE,e)}updateAstronomy(t){this.ensureStarsDeepEnough(),this.applySceneAt(t);const e=Cn.windowEndingAt(t,this.exposureSeconds()),i=e.seconds,n=this.degreesPerPixelAt(t),s=Oa.instants(i,n),a=Math.max(s,this.ufoElement.exposureTimes(t).length,Cn.instants(this.ufoElement.sighting.decor,di(this.ufoElement.sighting,t)?.elevationM??0,e.fromMs,i,n));if(a<=1){this.sceneRenderer.setExposure(1);return}this.sceneRenderer.setExposure(a,o=>this.applySceneAt(e.fromMs+e.ms*o/(a-1),{sky:Math.floor(o*s/a)!==Math.floor((o-1)*s/a),stepMs:e.ms/a}))}exposureSeconds(){return this.ufoElement.sighting.exposure??0}degreesPerPixelAt(t){const e=this.sceneCanvas.height;return e<=0?0:Ji.fovOf(this.ufoElement.sighting,t)/e}applySceneAt(t,e){const i=this.ufoElement.sighting;this.setWeather(of(i,t)),this.sceneRenderer.setInstrument(i.instrument),this.sceneRenderer.setLightPollution(i.lightPollution),e||this.vehicleAudio.setVoices(this.vehicleHearing.at(i,t)),this.updateMeteorShower(i,t),this.updateLightning(i,t,e!==void 0),this.sceneRenderer.setDecor(i.decor);const n=di(i,t);this.sceneRenderer.setReferences(i.references,n?.lat!==void 0&&n.lng!==void 0?{lat:n.lat,lng:n.lng}:void 0);const s=di(i,0),a=Vr(i,0),o=Object.fromEntries(fl(Vr(i,t)).map(y=>[y.id,nf(t,i.weatherTrack,a,s,n,y.id)]));this.sceneRenderer.setCloudOffset(nf(t,i.weatherTrack,a,s,n),o),this.sceneRenderer.setObserverPose(n??bu),this.sceneRenderer.setLensOptics(this.lensOpticsAt(t)),this.sceneRenderer.setInstrumentGain(zi.gainFor(i.instrument,{fNumber:n?.fNumber,fieldOfViewDeg:Ji.fovOf(i,t),exposureSeconds:i.exposure}),i.instrument.detailUm!==void 0),this.sceneRenderer.setMedium(i.instrument.medium,i.exposure,n?.fNumber??i.instrument.fNumber,i.iso),this.sceneRenderer.setGait(_e.bodyAt(i,t,this.ufoElement.steadyObserver)),this.sceneRenderer.updateDecorAnchoring(di(i,0),n,t),this.placeBodiesAt(t,e===void 0),this.sceneRenderer.updateDecorLitState(t,e?.stepMs??0),this.sceneRenderer.setTerrainOrigin(n?.lat,n?.lng,()=>{this.placeBodiesAt(this.lastTimeMs,!0),this.sceneRenderer.render()}),this.sceneRenderer.setStatedRoads(i.roads),this.pushPhenomenaAt(t);const c=n?.lat??bu.lat,l=n?.lng??bu.lng,h=Hc(i.event.time??{},l,i.event.utcOffsetHours),u={lat:c,lng:l,elevationM:n?.elevationM??0};if(this.pushSatellitesAt(h,t,u),e&&!e.sky)return;if(!h){this.sceneRenderer.setAstronomy(tA);return}const d=new Date(h.getTime()+t),f=Math.max(1,Math.round(.25*this.degreesPerPixelAt(t)/Oa.DEG_PER_SECOND*1e3)),p=Math.max(1e-8,this.degreesPerPixelAt(t)*.1),v=`${Math.floor(d.getTime()/f)}|${Math.round(c/p)}|${Math.round(l/p)}|${Math.round(u.elevationM)}|${this.starCatalog?this.starCatalogDepth:0}`;if(v===this.lastSkyKey){this.sceneRenderer.render();return}this.lastSkyKey=v;const m={...$h("Sun",d,u),magnitude:Kh("Sun",d)},g={...$h("Moon",d,u),phase:Fw(d),magnitude:Kh("Moon",d)},S=Nw.map(y=>({body:y,position:$h(y,d,u),magnitude:Kh(y,d)}));this.sceneRenderer.setAstronomy({sun:m,moon:g,planets:S,comet:this.cometAt(d,u),novae:jm.appearancesAt(d,u).map(({outburst:y,position:M,magnitude:b})=>({id:y.id,position:M,magnitude:b})),stars:this.starCatalog?{catalog:this.starCatalog,date:d,observer:u}:void 0,frame:{date:d,observer:u}}),this.ufoElement.setSunAltitude(m.altitudeDeg)}pushSatellitesAt(t,e,i){if(this.ensureSatellites(t),!t||!this.satellites){this.sceneRenderer.setSatellites([]);return}const n=new Date(t.getTime()+e),s=[];for(const a of this.satellites.passes.positionsAt(n,i,-1))a.magnitude!==void 0&&s.push({norad:a.object.norad,name:a.object.name,position:{altitudeDeg:a.altitudeDeg,azimuthDeg:a.azimuthDeg},magnitude:a.magnitude,heightKm:a.heightKm});this.sceneRenderer.setSatellites(s)}ensureSatellites(t){const e=t?String(t.getTime()):"";if(e===this.satellitesFor)return;this.satellitesFor=e,this.satellites=void 0,this.satellitePassesMemo=void 0;const i=++this.satelliteRequest;if(!t){this.satelliteStatus="none";return}this.satelliteStatus="loading";const n=a=>{i===this.satelliteRequest&&(this.satelliteStatus=a,this.isConnected&&this.dispatchEvent(new CustomEvent(qE)))},s=H0.tleArchive;(async()=>{if(!await s.covers(t))return n("outside");const[a,o]=await Promise.all([s.at(t),is(()=>import("./SatellitePasses-Pfro2-0Z.js"),[],import.meta.url)]);if(i===this.satelliteRequest){if(!a)return n("unavailable");this.satellites={snapshot:a,passes:new o.SatellitePasses(a.objects)},n("ready"),this.isConnected&&this.updateAstronomy(this.lastTimeMs)}})().catch(()=>n("unavailable"))}get satelliteState(){const t=this.satellites?.snapshot;return{status:this.satelliteStatus,coverage:t?.coverage,credit:t?.credit,creditUrl:t?.creditUrl}}satellitePassesDuring(t){const e=this.satellites,i=this.ufoElement.sighting,n=di(i,0),s=i.event.place?.[0],a=n?.lat??s?.lat,o=n?.lng??s?.lng;if(!e||a===void 0||o===void 0)return[];const c=Hc(i.event.time??{},o,i.event.utcOffsetHours);if(!c)return[];const l=Math.min(Math.max(t,0),4*36e5),h={lat:a,lng:o,elevationM:n?.elevationM??0},u=JSON.stringify([this.satellitesFor,c.getTime(),a,o,h.elevationM,l]);if(this.satellitePassesMemo?.key===u)return this.satellitePassesMemo.passes;const d=Math.max(10,Math.ceil(l/1e3/600)),f=e.passes.passesDuring(c,new Date(c.getTime()+l),h,d);return this.satellitePassesMemo={key:u,passes:f},f}cometAt(t,e){const i=zE.brightestAt(t,e);if(i)return{id:i.apparition.id,position:i.position,tailEnd:i.tailEnd,magnitude:i.magnitude}}pushPhenomenaAt(t){const e=this.ufoElement.sighting;e!==this.sizeEstimatesFor&&(this.sizeEstimates.clear(),this.distanceHypotheses.clear(),this.sizeEstimatesFor=e);const i=e.timeline,n=this.ufoElement.canvasElement,s=this.ufoElement.frameShiftPx,a=this.projectionAt(t),o=new Map,c=new Map,l=new Set;for(const p of i.sourceIds){const v=i.getInterpolatedShapeAt(t,p);if(!v)continue;const m={...v,bounds:{...v.bounds,x:v.bounds.x+s.x,y:v.bounds.y+s.y}};o.set(p,m);const g=v.aim?this.sceneRenderer.screenPointOf(In.directionOf(v.aim,this.directionScratch)):{ndcX:(m.bounds.x+m.bounds.width/2)/n.width*2-1,ndcY:-((m.bounds.y+m.bounds.height/2)/n.height*2-1)},S=g!==void 0&&Math.abs(g.ndcX)<=1&&Math.abs(g.ndcY)<=1,y=S?this.sceneRenderer.decorDistancesAt(g.ndcX,g.ndcY,p):{};l.add(p),(S||v.aim)&&l.delete(p);const M=v.angular?.widthDeg??a.pxToDeg(v.bounds.width),b=this.sizeEstimateOf(p);b.add(M,y);const w=Io.of(e,p);c.set(p,ki.resolve({hypothesisM:this.distanceHypotheses.get(p),derivedM:w&&M>0?Te.distanceMAt(w.widthM,M):void 0,range:b.distanceRangeAt(M),crossing:y}))}for(const[p,v]of o)for(const[m,g]of o){if(m===p||g.transparency>=1||g.bounds.width*g.bounds.height<=v.bounds.width*v.bounds.height||!(v.bounds.x>=g.bounds.x&&v.bounds.y>=g.bounds.y&&v.bounds.x+v.bounds.width<=g.bounds.x+g.bounds.width&&v.bounds.y+v.bounds.height<=g.bounds.y+g.bounds.height))continue;const y=c.get(m);y&&c.set(p,{distanceM:y.distanceM*.999,basis:y.basis});break}this.depths=c;const h=i.sourceIds,u=[];for(const[p,v]of o)u.push({sourceId:p,shape:v,distanceM:c.get(p).distanceM,renderOrder:h.indexOf(p),aim:v.aim,hidden:l.has(p)||this.interpretationShown!==void 0&&(!this.comparing||v.transparency>=1),ghost:this.interpretationShown!==void 0&&this.comparing});const f=(di(e,t)?.rollDeg??0)+_e.bodyAt(e,t,this.ufoElement.steadyObserver).rollDeg;this.sceneRenderer.setPhenomena(u,{projection:a,canvasWidthPx:n.width,canvasHeightPx:n.height,scale:Math.max(1,this.sceneCanvas.height/Math.max(1,n.height)),starPoints:fi.starPointsOf(e.instrument),rollRad:f*Math.PI/180})}get interpretation(){return this.interpretationShown}set interpretation(t){this.interpretationShown=t,this.updateAstronomy(this.lastTimeMs)}get accountInTheRound(){return this.inTheRound}set accountInTheRound(t){this.inTheRound=t}get compareAccount(){return this.comparing}set compareAccount(t){this.comparing=t,this.updateAstronomy(this.lastTimeMs)}get confrontation(){return this.confrontationReadings}groundAlong(t,e,i){const n=this.sceneRenderer.bodyGround,s=te.eyeOf(this.ufoElement.sighting,i,n);return s?te.lineOfSightMeetsGround(s,t,e,n):void 0}bodyReading(t,e){const i=this.sceneRenderer.bodyGround,n=this.ufoElement.sighting,s=d=>te.eyeOf(n,d,i),a=new te(t,i,s).at(e),o=s(e);if(!a||!o)return;const c=a.eastM-o.eastM,l=a.northM-o.northM,h=a.upM-o.upM,u=Math.hypot(c,l);return{azimuthDeg:(Math.atan2(c,l)*180/Math.PI+360)%360,altitudeDeg:Math.atan2(h,u)*180/Math.PI,distanceM:Math.hypot(u,h),eastM:a.eastM,northM:a.northM,aboveGroundM:a.upM-a.sizeM.heightM/2-i.heightAt(a.eastM,a.northM),sizeM:a.sizeM,attitude:a.attitude,appearance:a.appearance}}directionToBody(t,e){const i=this.sceneRenderer.bodyGround,n=this.ufoElement.sighting,s=p=>te.eyeOf(n,p,i),a=new te(t,i,s),o=a.at(e)?e:t.track[0]?.t,c=o===void 0?void 0:a.at(o),l=o===void 0?void 0:s(o);if(!c||!l)return;const h=c.eastM-l.eastM,u=c.northM-l.northM,d=c.upM-l.upM,f=Math.hypot(h,u);if(!(f===0&&d===0))return{azimuthDeg:(Math.atan2(h,u)*180/Math.PI+360)%360,altitudeDeg:Math.atan2(d,f)*180/Math.PI}}placeBodiesAt(t,e){const i=this.interpretationShown,n=this.ufoElement.sighting;let s=[],a=[];const o=this.sceneRenderer.bodyGround,c=p=>te.eyeOf(n,p,o);i&&(s=i.bodies.map(p=>new te(p,o,c).at(t)).filter(p=>p!==void 0));const l=Vr(n,t),h=l.windDirectionDeg*Math.PI/180,u={x:l.windSpeed*Math.sin(h),z:-l.windSpeed*Math.cos(h)};this.sceneRenderer.setBodies(s,t/1e3,i?.bodies.map(p=>p.id)??[],i?.smoke??[],u);const d=i&&this.comparing?c(t):void 0;if(d&&(a=new Qe(n.timeline).at(t,s,d,p=>p.outlineNode?this.sceneRenderer.bodyOutline?.(p.id,p.outlineNode):void 0)),this.confrontationReadings=a,!e)return;const f=JSON.stringify(a);f!==this.confrontationSignature&&(this.confrontationSignature=f,this.dispatchEvent(new CustomEvent($E,{detail:a})))}setDistanceHypothesis(t,e){e===void 0||!(e>0)?this.distanceHypotheses.delete(t):this.distanceHypotheses.set(t,e),this.updateAstronomy(this.lastTimeMs)}depthOf(t){return this.depths.get(t)}sizeRangeOf(t){return this.sizeEstimateOf(t).sizeRange}distanceRangeAt(t,e){const i=this.ufoElement.sighting.timeline.getInterpolatedShapeAt(e,t);if(!i)return{};const n=i.angular?.widthDeg??this.projectionAt(e).pxToDeg(i.bounds.width);return this.sizeEstimateOf(t).distanceRangeAt(n)}sizeContradictory(t){return this.sizeEstimateOf(t).contradictory}updateMeteorShower(t,e){this.ensureMeteorSchedule(t),this.sceneRenderer.updateMeteors(e)}updateLightning(t,e,i){if(this.ensureLightningSchedule(t),this.sceneRenderer.updateLightning(e),i)return;const n=this.lastLightningT;if(this.lastLightningT=e,n===void 0||e<n||this.ufoElement.playbackState!=="playing")return;const s=this.lightningFlashes.filter(a=>a.t>n&&a.t<=e).pop();s&&Vr(t,s.t).storm&&this.handleLightningFlash(s)}ensureLightningSchedule(t){const e=Vr(t,0).precipitationIntensity,i=`${this.meteorInputsOf(t)}|${e}`;if(i===this.lightningScheduleFor)return;this.lightningScheduleFor=i;const n=t.event.time,s=t.event.place?.[0],a=n?.year!==void 0?Hc(n,s?.lng??0,t.event.utcOffsetHours):void 0,o=(t.event.durationSeconds??0)*1e3||t.timeline.duration||2e4,c=Math.round((a?.getTime()??0)/1e3)+Math.round((s?.lat??0)*1e3)+7;this.lightningFlashes=pi.schedule({durationMs:o,seed:c,intensity:e}),this.sceneRenderer.setLightning(this.lightningFlashes)}ensureMeteorSchedule(t){const e=this.meteorInputsOf(t);e!==this.meteorScheduleFor&&(this.meteorScheduleFor=e,this.scheduleMeteors(t))}meteorInputsOf(t){const e=t.event.place?.[0],i=t.event.time;return JSON.stringify([e?.lat,e?.lng,i?.year,i?.month,i?.day,i?.hour,i?.minute,i?.second,t.event.utcOffsetHours,t.event.durationSeconds,t.timeline.duration])}scheduleMeteors(t){const e=t.event.place?.[0],i=t.event.time,n=e?.lat!==void 0&&e.lng!==void 0&&i?.year!==void 0?Hc(i,e.lng,t.event.utcOffsetHours):void 0;if(!n||e?.lat===void 0||e.lng===void 0){this.sceneRenderer.setMeteorShower([],0,0);return}const s={lat:e.lat,lng:e.lng,elevationM:0},a=(t.event.durationSeconds??0)*1e3||t.timeline.duration||2e4,o=Math.round(n.getTime()/1e3)+Math.round(e.lat*1e3),c=ti.schedule({ratePerHour:ti.observedRatePerHour(ti.apexPosition(n,s).altitudeDeg),durationMs:a,velocityKmS:ti.TYPICAL_VELOCITY_KM_S,seed:o}),l=yu.activeAt(n).map(u=>{const d=yu.radiantPosition(u.shower,n,s);return{entry:u,position:d,rate:yu.observedRatePerHour(u.zhr,d.altitudeDeg,u.shower.populationIndex)}}).sort((u,d)=>d.rate-u.rate)[0];if(!l||l.rate<=0){this.sceneRenderer.setMeteorShower(c,0,0);return}const h=Pa.schedule({ratePerHour:l.rate,durationMs:a,velocityKmS:l.entry.shower.velocityKmS,seed:o+1});this.sceneRenderer.setMeteorShower([...h,...c],l.position.altitudeDeg,l.position.azimuthDeg)}meteorByRank(t){this.ensureMeteorSchedule(this.ufoElement.sighting);const e=[...this.sceneRenderer.meteorSchedule].filter(s=>s.t+s.durationMs<=this.ufoElement.seekableDuration).sort((s,a)=>a.brightness-s.brightness);if(e.length===0)return;const i=e[t%e.length],n=this.sceneRenderer.meteorMidpoint(i);if(n)return{t:Math.round(i.t+i.durationMs*.45),...n}}lensOpticsAt(t){const e=this.ufoElement.sighting,i=e.instrument,n=i.frame,s=di(e,t),a=s?.fNumber??i.fNumber;if(!n||a===void 0)return;const o=fi.focalLengthMmFor(i,Ji.fovOf(e,t));if(o!==void 0)return{focalLengthMm:o,fNumber:a,focusDistance:s?.focusDistanceM??0,frameHeightMm:n.heightMm}}projectionAt(t){const e=this.ufoElement.sighting;return Ss.of(e.instrument,Te.CANVAS_HEIGHT_PX,Ji.fovOf(e,t))}sizeEstimateOf(t){let e=this.sizeEstimates.get(t);return e||(e=new HE,this.sizeEstimates.set(t,e)),e}}const Zd="rr0-scene";function eA(){yg(),customElements.get(Zd)||customElements.define(Zd,H0)}eA();export{LM as $,rA as A,ie as B,st as C,mp as D,Dt as E,hA as F,cA as G,Vg as H,oA as I,lA as J,xs as K,Ko as L,XM as M,ac as N,Be as O,Qg as P,Qi as Q,zo as R,Gi as S,iA as T,Ce as U,xt as V,Zi as W,aA as X,Un as Y,Gg as Z,lp as _,sA as a,vl as a0,dd as a1,wl as a2,bi as a3,Jg as a4,y0 as a5,_0 as a6,re as a7,na as a8,$o as a9,Vi as aa,Rs as ab,nA as b,fA as c,yl as d,dA as e,Jt as f,R as g,jf as h,uA as i,pA as j,DM as k,wa as l,oh as m,P2 as n,oe as o,Re as p,Nu as q,wi as r,Wg as s,Ds as t,zM as u,ya as v,ji as w,_n as x,we as y,ce as z};
|