@rr0/ufoathome 0.191.0 → 0.192.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist-embed-scene/rr0-scene.mjs +6 -6
- package/dist-embed-scene/trafficRuntime-CL5yz3t-.js +2 -0
- package/dist-embed-sighting/CaseMessages_en-Bv5lKWl_.js +1 -0
- package/dist-embed-sighting/CaseMessages_es-BhZv_CtC.js +1 -0
- package/dist-embed-sighting/CaseMessages_fr-C5V5YNc_.js +1 -0
- package/dist-embed-sighting/CaseMessages_it-NPdAZwa_.js +1 -0
- package/dist-embed-sighting/{CaseReportExport-DlX7cYJN.js → CaseReportExport-dMWWJNIh.js} +1 -1
- package/dist-embed-sighting/rr0-sighting.mjs +324 -286
- package/dist-embed-sighting/trafficRuntime-BUvbWOcl.js +2 -0
- package/dist-embed-sighting-editor/{CaseReportExport-C84tqwtO.js → CaseReportExport-ByPXoIiq.js} +1 -1
- package/dist-embed-sighting-editor/rr0-sighting-editor.mjs +37 -11
- package/dist-embed-sighting-editor/trafficRuntime-DwnTE9-7.js +2 -0
- package/package.json +1 -1
- package/dist-embed-scene/trafficRuntime-DRDMbo2X.js +0 -2
- package/dist-embed-sighting/CaseMessages_en-CBS5QChl.js +0 -1
- package/dist-embed-sighting/CaseMessages_es-DAMl4aTC.js +0 -1
- package/dist-embed-sighting/CaseMessages_fr-C3wQxAk_.js +0 -1
- package/dist-embed-sighting/CaseMessages_it-CyrREg6v.js +0 -1
- package/dist-embed-sighting/trafficRuntime-CuYrKvX9.js +0 -2
- package/dist-embed-sighting-editor/trafficRuntime-Cqj3IpvH.js +0 -2
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./BeamSystem-CaNus1WN.js","./LaserBeam-BQWS_xWa.js","./BeamEditor-Dj1Wt50v.js","./ParameterForm-BHRESNZ4.js","./TimelineTracks-Cjt0OHJS.js","./LaunchSimulation-BU7X_C8t.js","./LaunchPlume-DVsshxQE.js","./LaunchEditor-CjpESdIe.js","./ReentryEditor-DpNPIxOG.js","./ContrailSystem-ChG1viIv.js","./ContrailGrowth-DwHS8If9.js","./LanternEditor-iByq1q3j.js","./SkyLantern-BKxwl7Po.js","./BirdEditor-CKpe681e.js","./BirdFlock-B2SbkMme.js","./DroneEditor-BDDLiZPp.js","./DroneFlight-BTFHGVWd.js","./trafficRuntime-
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./BeamSystem-CaNus1WN.js","./LaserBeam-BQWS_xWa.js","./BeamEditor-Dj1Wt50v.js","./ParameterForm-BHRESNZ4.js","./TimelineTracks-Cjt0OHJS.js","./LaunchSimulation-BU7X_C8t.js","./LaunchPlume-DVsshxQE.js","./LaunchEditor-CjpESdIe.js","./ReentryEditor-DpNPIxOG.js","./ContrailSystem-ChG1viIv.js","./ContrailGrowth-DwHS8If9.js","./LanternEditor-iByq1q3j.js","./SkyLantern-BKxwl7Po.js","./BirdEditor-CKpe681e.js","./BirdFlock-B2SbkMme.js","./DroneEditor-BDDLiZPp.js","./DroneFlight-BTFHGVWd.js","./trafficRuntime-CL5yz3t-.js","./GenerativeKit-BmhvjjzB.js","./browser-CltifEM0.js","./VideoExport-B8ZhHNnd.js"])))=>i.map(i=>d[i]);
|
|
2
2
|
const n3="modulepreload",s3=function(o,t){return new URL(o,t).href},My={},dt=function(t,e,i){let n=Promise.resolve();if(e&&e.length>0){let r=function(h){return Promise.all(h.map(u=>Promise.resolve(u).then(d=>({status:"fulfilled",value:d}),d=>({status:"rejected",reason:d}))))};const a=document.getElementsByTagName("link"),c=document.querySelector("meta[property=csp-nonce]"),l=c?.nonce||c?.getAttribute("nonce");n=r(e.map(h=>{if(h=s3(h,i),h in My)return;My[h]=!0;const u=h.endsWith(".css"),d=u?'[rel="stylesheet"]':"";if(!!i)for(let g=a.length-1;g>=0;g--){const m=a[g];if(m.href===h&&(!u||m.rel==="stylesheet"))return}else if(document.querySelector(`link[href="${h}"]${d}`))return;const p=document.createElement("link");if(p.rel=u?"stylesheet":n3,u||(p.as="script"),p.crossOrigin="",p.href=h,l&&p.setAttribute("nonce",l),document.head.appendChild(p),u)return new Promise((g,m)=>{p.addEventListener("load",g),p.addEventListener("error",()=>m(new Error(`Unable to preload CSS for ${h}`)))})}))}function s(r){const a=new Event("vite:preloadError",{cancelable:!0});if(a.payload=r,window.dispatchEvent(a),!a.defaultPrevented)throw r}return n.then(r=>{for(const a of r||[])a.status==="rejected"&&s(a.reason);return t().catch(s)})};class r3 extends Error{constructor(t,e,i){super(typeof e=="number"&&Number.isInteger(e)&&e>=1?`This ${t} file is in version ${e} of its format; this UFO@home reads version ${i}. Read it with the UFO@home that reads its version.`:`This ${t} file states ${JSON.stringify(e)} as its format version, which is not a version.`),this.format=t,this.found=e,this.supported=i,this.name="FormatVersionError"}said(t){return t.replace("{found}",typeof this.found=="number"?String(this.found):JSON.stringify(this.found)).replace("{supported}",String(this.supported))}}class la{static CURRENT={sighting:4,case:1,interview:1};static SCHEMA_BASE="https://ufoathome.org/schema";static schemaUrl(t,e=la.CURRENT[t]){return`${la.SCHEMA_BASE}/${e}/${t}.schema.json`}static of(t){if(typeof t!="object"||t===null)return 1;const e=t.version;return e===void 0?1:typeof e=="object"&&e!==null&&"value"in e?e.value:e}static recording(t){return la.check(t,"sighting")}static check(t,e){const i=la.of(t),n=la.CURRENT[e];if(typeof i!="number"||!Number.isInteger(i)||i!==n)throw new r3(e,i,n);return t}}const gb=Math.PI/180,Y0=111320;function ae(o,t,e,i){const n=Y0*Math.cos(e*gb),s=(o-e)*Y0;return{x:(t-i)*n,z:-s}}function zs(o,t,e,i){const n=Y0*Math.cos(e*gb),s=-t,r=o;return{lat:e+s/Y0,lng:i+r/n}}class Zl{static HALF_SPAN_MS=2e3;static MIN_SPEED_MS=1;static at(t,e,i){const n=t.event.place?.[0],s=t.observerTrack;if(!n)return 0;const r=g=>{const m=s.getInterpolatedPoseAt(Math.max(0,g));if(!m||m.lat===void 0||m.lng===void 0)return;const M=ae(m.lat,m.lng,n.lat,n.lng);return{eastM:M.x,northM:-M.z,heading:m.headingDeg,aboveM:m.elevationM??0,altitudeM:m.altitudeM}},a=r(e-Zl.HALF_SPAN_MS),c=r(e+Zl.HALF_SPAN_MS),l=r(e);if(!a||!c||!l)return 0;const h=Math.hypot(c.eastM-a.eastM,c.northM-a.northM),u=2*Zl.HALF_SPAN_MS/1e3;if(h/u<Zl.MIN_SPEED_MS)return 0;const d=c.altitudeM!==void 0&&a.altitudeM!==void 0?c.altitudeM-a.altitudeM:i.heightAt(c.eastM,c.northM)+c.aboveM-i.heightAt(a.eastM,a.northM)-a.aboveM,f=Math.atan2(d,h)*180/Math.PI;if(l.heading===void 0)return f;const p=Math.atan2(c.eastM-a.eastM,c.northM-a.northM)*180/Math.PI;return f*Math.max(0,Math.cos((l.heading-p)*Math.PI/180))}}class er{static sessionDeclared=!1;static isLive(t){return t!==void 0&&typeof AudioContext<"u"&&t instanceof AudioContext}static unlock(t){if(er.declarePlayback(),t.state!=="running")try{Promise.resolve(t.resume()).catch(()=>{});const e=t.createBufferSource();e.buffer=t.createBuffer(1,1,22050),e.connect(t.destination),e.start(0)}catch{}}static declarePlayback(){if(!(er.sessionDeclared||typeof navigator>"u")){er.sessionDeclared=!0;try{const t=navigator.audioSession;t&&(t.type="playback")}catch{}}}}const a3=.08,vy=.15,yy=2,o3=2e3;class xy{context;constructor(t){this.context=t}noiseBuffer;voices=new Map;level=1;master;paused=!0;requested=[];resume(){if(!this.context){if(typeof AudioContext>"u")return;try{this.context=new AudioContext}catch(t){console.warn("VehicleAudio: Web Audio unavailable, vehicles stay silent:",t);return}}er.isLive(this.context)&&er.unlock(this.context),this.apply()}setLevel(t){this.level=t,this.master&&(this.master.gain.value=t)}setPaused(t){t!==this.paused&&(this.paused=t,this.apply())}setVoices(t){this.requested=t,this.apply()}dispose(){for(const t of[...this.voices.keys()])this.release(t);er.isLive(this.context)&&this.context.close(),this.context=void 0,this.master=void 0}masterOf(t){return this.master||(this.master=t.createGain(),this.master.gain.value=this.level,this.master.connect(t.destination)),this.master}apply(){const t=this.context;if(!t)return;const e=this.paused?[]:this.requested.filter(n=>n.inside||n.distanceM<o3),i=new Set(e.map(n=>n.id));for(const n of[...this.voices.keys()])i.has(n)||this.release(n);for(const n of e){const s=this.voices.get(n.id)??this.build(t,n.id);this.retarget(t,s,n)}}build(t,e){const i=t.createGain();i.gain.value=0;const n=t.createBiquadFilter();n.type="lowpass",n.connect(i).connect(this.masterOf(t));const s=t.createOscillator();s.type="sawtooth";const r=t.createOscillator();r.type="sine";const a=t.createGain(),c=t.createBiquadFilter();c.type="lowpass",c.frequency.value=900,s.connect(c),r.connect(c),c.connect(a).connect(n);const l=()=>{const w=t.createBufferSource();return w.buffer=this.noise(t),w.loop=!0,w.loopStart=Math.random()*yy*.5,w},h=l(),u=t.createBiquadFilter();u.type="bandpass",u.Q.value=4;const d=t.createGain();h.connect(u).connect(d).connect(n);const f=l(),p=t.createBiquadFilter();p.type="lowpass",p.frequency.value=600;const g=t.createGain();f.connect(p).connect(g).connect(n);const m=l(),M=t.createBiquadFilter();M.type="bandpass",M.frequency.value=1400,M.Q.value=.7;const v=t.createGain();m.connect(M).connect(v).connect(n);const x=[s,r,h,f,m];for(const w of x)w.start();const y={nodes:[i,n,a,c,u,d,p,g,M,v,...x],sources:x,firing:s,crank:r,knock:u,engineGain:a,knockGain:d,roadGain:g,windGain:v,cabin:n,output:i};return this.voices.set(e,y),y}retarget(t,e,{profile:i,state:n,noise:s,inside:r,windowsOpen:a,distanceM:c}){const l=t.currentTime,h=(v,x)=>v.setTargetAtTime(x,l,a3),u=n.rpm/60,d=u*i.cylinders/2,f=Math.min(1,n.rpm/i.shiftUpRpm),p=Math.min(1.5,n.speedMps/30);h(e.firing.frequency,d),h(e.crank.frequency,u),h(e.knock.frequency,d*3),h(e.engineGain.gain,i.engineGain*(.25+.75*n.load)*(.5+.5*f)*.3),h(e.knockGain.gain,i.roughness*(.2+.8*n.load)*.4),h(e.roadGain.gain,i.roadGain*p**1.5*.8);const g=!r||a;h(e.windGain.gain,p**2*(g?.5:.06));const m=r?a?3500:700:8e3/(1+c/60);h(e.cabin.frequency,m);const M=r?.5:Math.min(1,8/Math.max(c,1));h(e.output.gain,M*s)}release(t){const e=this.voices.get(t);if(!e)return;this.voices.delete(t);const i=this.context;i&&(e.output.gain.setTargetAtTime(0,i.currentTime,vy/3),setTimeout(()=>{for(const n of e.sources)try{n.stop()}catch{}for(const n of e.nodes)n.disconnect()},vy*1e3*3))}noise(t){if(this.noiseBuffer)return this.noiseBuffer;const e=t.createBuffer(1,t.sampleRate*yy,t.sampleRate),i=e.getChannelData(0);for(let n=0;n<i.length;n++)i[n]=Math.random()*2-1;return this.noiseBuffer=e,e}}class $c{static MODES=["off","position","dipped","main","fog"];static DISPLAY_GAIN=.006;static TOE_IN_DEG=.6;static AUTO_BELOW_SUN_DEG=-1;static BEAMS={off:void 0,position:void 0,dipped:{candela:25e3,halfAngleDeg:24,pitchDeg:2.5,penumbra:1,color:"#fff2d8"},main:{candela:12e4,halfAngleDeg:14,pitchDeg:.4,penumbra:.85,color:"#fff6e6"},fog:{candela:9e3,halfAngleDeg:38,pitchDeg:5,penumbra:1,color:"#ffe9b0"}};static isMode(t){return typeof t=="string"&&$c.MODES.includes(t)}static at(t,e,i){if(!e||e.length===0)return t;let n=e[0];for(const s of e){if(s.t>i)break;n=s}return n.mode}static auto(t){return t<$c.AUTO_BELOW_SUN_DEG?"dipped":"off"}static lamps(t){return t!=="off"}}const wy=2;function K0(o){return o==="building"||o==="vehicle"}const Mb={aircraft:{id:"poly-google-airliner"},tree:{id:"jungle-jim-tree-large-a"},observer:{id:"makehuman-farmer-40s"},entity:{id:"makehuman-farmer-40s"}},c3=["makehuman-farmer-40s","makehuman-man-overalls","makehuman-man-jacket","makehuman-old-man","makehuman-woman"];function Sy(o,t){let e=0;for(const i of t)e=e*31+i.charCodeAt(0)>>>0;return{id:o[e%o.length]}}const l3=["jungle-jim-tree-large-a","jungle-jim-tree-medium-a","jungle-jim-tree-large-b","jungle-jim-tree-medium-b","jungle-jim-tree-large-c","jungle-jim-tree-medium-c","jagobo-tree-maple-a","jagobo-tree-maple-b","jagobo-tree-aspen-a","jagobo-tree-aspen-b","nicholas-3d-tree-a","nicholas-3d-tree-b","nicholas-3d-tree-c"];function c1(o){return o.model?o.model:o.kind==="tree"&&o.id!==void 0?Sy(l3,o.id):(o.kind==="observer"||o.kind==="entity")&&o.id!==void 0?Sy(c3,o.id):Mb[o.kind]}function vb(o,t){const e=$c.at(o.headlights,o.headlightKeyframes,t);return e!==void 0?e:tv(o,t)?"dipped":"off"}class cd{static DEFAULT_KIND="airliner-narrow";static kindOf(t,e){if(t.kind!=="aircraft"||!cd.flies(t))return;const i=t.aircraftSound??e??cd.DEFAULT_KIND;return i==="silent"?void 0:i}static flies(t){return(t.track??[]).some(e=>(e.altitudeM??0)>0)}}const h3=-.5;function u3(o){return o.kind==="streetlight"&&o.origin!==void 0&&o.lit===void 0&&!o.litKeyframes?.length}function tv(o,t,e){if(e!==void 0&&u3(o))return e<h3;const i=o.litKeyframes;if(!i||i.length===0)return o.lit??!1;let n=i[0];for(const s of i){if(s.t>t)break;n=s}return n.lit}function by(o,t){const e=o.observerKeyframes;if(!e||e.length===0)return{side:o.observerSide,facing:o.observerFacing};let i=e[0];for(const n of e){if(n.t>t)break;i=n}return{side:i.side,facing:i.facing}}function yb(o,t){const e=Vc(o,t);return e.intensity<=0?!1:e.pattern.kind==="steady"?!0:wb(o,t,t+1)>.5}const xb=100;function Vc(o,t){let e;for(const i of o.keyframes??[]){if(i.t>t)break;e=i}return{intensity:e?.intensity??o.intensity??1,pattern:e?.pattern??o.pattern}}function wb(o,t,e){const i=o.keyframes??[];if(i.length===0)return om(o.pattern,t,e);const n=[t,...i.map(r=>r.t).filter(r=>r>t&&r<e),e];if(e<=t)return Vc(o,t).intensity>0?om(Vc(o,t).pattern,t,e):0;let s=0;for(let r=0;r<n.length-1;r++){const a=Vc(o,n[r]);a.intensity>0&&(s+=om(a.pattern,n[r],n[r+1])*(n[r+1]-n[r]))}return s/(e-t)}function om(o,t,e){if(o.kind==="steady")return 1;const{perMinute:i,dutyCycle:n,phase:s=0}=o,r=Math.min(Math.max(n,0),1);if(r===0||i<=0)return 0;const a=6e4/i,c=t/a+s,l=e/a+s;if(l<=c)return Math.min(Math.max(c-Math.floor(c),0),r)<r?1:0;const h=u=>Math.floor(u)*r+Math.min(u-Math.floor(u),r);return(h(l)-h(c))/(l-c)}function ga(o,t){const e=o.track,i={eastM:o.eastM,northM:o.northM,altitudeM:0,headingDeg:o.headingDeg};if(!e||e.length===0)return i;if(e.length===1||t<=e[0].t)return Ey(e[0],o);const n=e[e.length-1];if(t>=n.t)return Ey(n,o);for(let s=0;s<e.length-1;s++){const r=e[s],a=e[s+1];if(t<r.t||t>a.t)continue;const c=a.t-r.t,l=c===0?0:(t-r.t)/c;return{eastM:r.eastM+(a.eastM-r.eastM)*l,northM:r.northM+(a.northM-r.northM)*l,altitudeM:(r.altitudeM??0)+((a.altitudeM??0)-(r.altitudeM??0))*l,headingDeg:r.headingDeg??o.headingDeg}}return i}function d3(o,t){const e=(o.track??[]).filter(i=>i.gazeAzimuthDeg!==void 0);if(e.length!==0){if(t<=e[0].t)return e[0].gazeAzimuthDeg;for(let i=0;i<e.length-1;i++){const n=e[i],s=e[i+1];if(t>s.t)continue;const r=s.t-n.t,a=r===0?0:(t-n.t)/r,c=((s.gazeAzimuthDeg-n.gazeAzimuthDeg)%360+540)%360-180;return((n.gazeAzimuthDeg+c*a)%360+360)%360}return e[e.length-1].gazeAzimuthDeg}}function Ey(o,t){return{eastM:o.eastM,northM:o.northM,altitudeM:o.altitudeM??0,headingDeg:o.headingDeg??t.headingDeg}}class ld{static BY_KIND={car:{cylinders:4,idleRpm:800,kmhPer1000Rpm:[8,14,21,29,37,45],shiftUpRpm:3e3,shiftDownRpm:1300,engineGain:.6,roadGain:.5,roughness:.15},generic:{cylinders:4,idleRpm:800,kmhPer1000Rpm:[8,14,21,29,37,45],shiftUpRpm:3e3,shiftDownRpm:1300,engineGain:.6,roadGain:.5,roughness:.15},van:{cylinders:4,idleRpm:750,kmhPer1000Rpm:[7,12,19,27,35,42],shiftUpRpm:2600,shiftDownRpm:1200,engineGain:.8,roadGain:.7,roughness:.45},truck:{cylinders:6,idleRpm:600,kmhPer1000Rpm:[5,8,12,17,23,30,38,48],shiftUpRpm:1900,shiftDownRpm:1e3,engineGain:1,roadGain:.9,roughness:.55},motorcycle:{cylinders:2,idleRpm:1100,kmhPer1000Rpm:[12,18,24,30,35,40],shiftUpRpm:6e3,shiftDownRpm:2500,engineGain:.9,roadGain:.3,roughness:.3}};static of(t){return ld.BY_KIND[t??"generic"]??ld.BY_KIND.generic}}class Yn{static ROAD_KINDS=["car","van","truck","motorcycle","generic"];static OPEN_AIR=[0,0,0,0,0,0,0,0];static ROAD_CLOSED_DB=[10,14,18,22,25,28,30,32];static WINDOWS_OPEN_DB=[2,3,4,5,6,7,8,9];static FUSELAGE_DB=[14,18,23,28,32,36,38,40];static CANOPY_DB=[3,4,6,8,10,12,14,16];static CANOPIED=["glider","balloon","ultralight"];static isRoad(t){return Yn.ROAD_KINDS.includes(t)}static roadOf(t){return t&&Yn.isRoad(t.kind)?t.kind:void 0}static aircraftOf(t){return t&&!Yn.isRoad(t.kind)?t.kind:void 0}static transmission(t){const e=Yn.insulationDb(t),i=[3,4,5].map(n=>e[n]);return 10**(-(i.reduce((n,s)=>n+s,0)/i.length)/20)}static insulationDb(t){return t?t.windowsOpen===!0?Yn.WINDOWS_OPEN_DB:Yn.isRoad(t.kind)?Yn.ROAD_CLOSED_DB:Yn.CANOPIED.includes(t.kind)?Yn.CANOPY_DB:Yn.FUSELAGE_DB:Yn.OPEN_AIR}}class Ic{constructor(t,e){this.samples=t,this.startMs=e}static SAMPLE_MS=100;static STANDING_MPS=.3;static of(t,e,i,n){const s=Ic.SAMPLE_MS,r=[];for(let l=i;l<=n+s/2;l+=s){const h=e(l-s/2),u=e(l+s/2);if(!h||!u)return;r.push(Math.hypot(u.eastM-h.eastM,u.northM-h.northM)/(s/1e3))}const a=[];let c=1;for(let l=0;l<r.length;l++){const h=r[l],u=(r[Math.min(l+1,r.length-1)]-r[Math.max(l-1,0)])/(2*s/1e3);if(h<Ic.STANDING_MPS){c=1,a.push({speedMps:h,rpm:t.idleRpm,load:.1,gear:0});continue}const d=h*3.6,f=M=>d/t.kmhPer1000Rpm[M-1]*1e3;for(;c<t.kmhPer1000Rpm.length&&f(c)>t.shiftUpRpm;)c++;for(;c>1&&f(c)<t.shiftDownRpm;)c--;const p=Math.max(f(c),t.idleRpm*(1+.3*Math.min(1,h/3))),g=.15+.5*Math.min(1,(h/35)**2),m=u>.15?Math.min(1,g+u/2.5):u<-.3?.05:g;a.push({speedMps:h,rpm:p,load:m,gear:c})}return new Ic(a,i)}at(t){const e=(t-this.startMs)/Ic.SAMPLE_MS,i=Math.min(Math.max(Math.floor(e),0),this.samples.length-1),n=this.samples[i],s=this.samples[Math.min(i+1,this.samples.length-1)],r=Math.min(Math.max(e-i,0),1);return{speedMps:n.speedMps+(s.speedMps-n.speedMps)*r,rpm:n.rpm+(s.rpm-n.rpm)*r,load:n.load+(s.load-n.load)*r,gear:r<.5?n.gear:s.gear}}}class $0{drives=new Map;at(t,e){const i=[],n=t.event.place?.[0],s=h=>{const u=t.observerTrack.getInterpolatedPoseAt(h),d=u?.lat??n?.lat,f=u?.lng??n?.lng;if(d===void 0||f===void 0||!n)return;const p=ae(d,f,n.lat,n.lng);return{eastM:p.x,northM:-p.z}},r=Math.max(t.observerTrack.duration,(t.event.durationSeconds??0)*1e3),a=t.vehicle,c=Yn.roadOf(a);if(a&&c){const h=ld.of(c),u=this.drive(`observer:${c}`,$0.trackKey(t),()=>Ic.of(h,s,0,r));u&&i.push({id:"observer",profile:h,state:u.at(e),noise:a.noise??1,inside:!0,windowsOpen:a.windowsOpen===!0,distanceM:0})}const l=s(e);for(const h of t.decor){if(!h.engine||!l)continue;const u=ld.of(h.engine.kind),d=m=>{const M=ga(h,m);return{eastM:M.eastM,northM:M.northM}},f=this.drive(`decor:${h.id}`,$0.decorKey(h,r),()=>Ic.of(u,d,0,r));if(!f)continue;const p=ga(h,e),g=Math.hypot(p.eastM-l.eastM,p.northM-l.northM,p.altitudeM);i.push({id:`decor:${h.id}`,profile:u,state:f.at(e),noise:h.engine.noise??1,inside:!1,windowsOpen:!0,distanceM:g})}return i}drive(t,e,i){const n=this.drives.get(t);if(n&&n.key===e)return n.drive;const s=i();return this.drives.set(t,{key:e,drive:s}),s}static trackKey(t){return t.observerTrack.allKeyframes.map(i=>`${i.t}:${i.pose.lat}:${i.pose.lng}`).join(";")}static decorKey(t,e){return`${e}|${t.eastM},${t.northM}|`+(t.track??[]).map(i=>`${i.t}:${i.eastM}:${i.northM}`).join(";")}}const ev=1e3,f3=.65,p3=.05,Np={cloudCover:0,cloudDarkness:0,precipitationType:"none",precipitationIntensity:0,windDirectionDeg:0,windSpeed:0,storm:!1};function q0(o){if(o.cloudLayers!==void 0)return o.cloudLayers;const t=[],e=o.lowerCloudCover??o.cloudCover;return e>0&&t.push({id:"lower",type:"cumulus",baseM:o.cloudBaseM??ev,thicknessM:650,coverage:e,sizeM:1400,density:1,darkness:o.cloudDarkness}),(o.highCloudCover??0)>0&&t.push({id:"cirrus",type:"cirrus",baseM:8e3,thicknessM:400,coverage:o.highCloudCover,sizeM:2200,density:.35,darkness:o.cloudDarkness,iceCrystalAlignment:o.iceCrystalAlignment}),t}const Ay=864e5,_y=4e4;function m3(o){const t=Math.floor(o.getTime()/Ay);return{elapsedMs:o.getTime()-t*Ay,shiftM:{x:Ty.unit(t,2654435761)*_y,z:Ty.unit(t,2246822507)*_y}}}class Ty{static unit(t,e){let i=Math.imul(t|0,e)^e;return i=Math.imul(i^i>>>15,739982445),i=Math.imul(i^i>>>12,695872825),i^=i>>>15,(i>>>0)/4294967295*2-1}}function Ry(o,t,e,i,n,s,r){const a=i?.lat!==void 0&&i.lng!==void 0&&n?.lat!==void 0&&n.lng!==void 0?ae(n.lat,n.lng,i.lat,i.lng):{x:0,z:0};if(r){const h=t.getInterpolatedWeatherAt(0)??e,u=s===void 0?void 0:h.cloudLayers?.find(p=>p.id===s),d=(u?.windDirectionDeg??h.windDirectionDeg)*Math.PI/180,f=(u?.windSpeed??h.windSpeed)*r.elapsedMs/1e3;a.x+=r.shiftM.x-Math.sin(d)*f,a.z+=r.shiftM.z+Math.cos(d)*f}const c=Math.max(0,o),l=[0,...t.allKeyframes.map(h=>h.t).filter(h=>h>0&&h<c),c];for(let h=1;h<l.length;h++){const u=l[h-1],d=l[h]-u;if(d===0)continue;const f=32;for(let p=0;p<=f;p++){const g=t.getInterpolatedWeatherAt(u+d*p/f)??e,m=s===void 0?void 0:g.cloudLayers?.find(y=>y.id===s),M=(m?.windDirectionDeg??g.windDirectionDeg)*Math.PI/180,v=p===0||p===f?1:p%2===0?2:4,x=(m?.windSpeed??g.windSpeed)*d/1e3/f/3*v;a.x-=Math.sin(M)*x,a.z+=Math.cos(M)*x}}return a}const g3="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAGAAAABgCAMAAADVRocKAAAARVBMVEX9sST/uyTfoCjNlSikfCqRcCx8Yy21hipTSi4TITEMHTEuMzBqWC3/wSRUX207SFj8/PyaoakmNUd5gYxBPy90fIfMz9RsB4kZAAACEUlEQVRo3u2XyXbDIAxFLeapjts6/f9PrQA3JymT25Cd3iY5xtYVIB6wLCQSiUQikUgk0nzBoVdFZ1xIpaTQbJnPACaNdYeskWwuAhaZoltnUemfnNkL4N49KEI8n0YAEXMvEWISAWQZPw2Xk1MIoF1dSNAzCMy6JsGyCR0wrkMwT3cBeDt+FH8aEHoA68LbM8HRHXQ3f0RE3/jXOOFX+s4djrKpIbzS7K+MmLrxlWCNR8mczjMw92Ar4dZLDXG4kzXinAECcOUPL3jMdN2294/GQGVG4EMHxORNJXoCfG6oT1trvDGM7iIA9N6aTOuuEbB9ra6FyCYr2gjge+fjA4CIi2uujYRoOBSw0A5/D0hT0X4PW0xtuotNpQPYtkt/fdtyM0LP6ZvOI2DtvoxtJWHvx38AxIkevLwXQ2TOA66DziYfLwC4r5wbIlwJo1ys8+VOBMy7/sxdjwIap49lVC3UePZp1mmyit4SuGUf11pjoTHVRVzXUaXFVt87kuEBsWZ055Q+2sXA76LbZYsvKR1ubvJqbKd5swl+GPI31p6L/sNYuDTe3jo+GBdr1J+P9PGawbRUw9VhleD/3ffT9uZ7DhtX1JNHL2CmNRXxYZhwSwBd3aJTyU85/GKOwhxBf5RnVk+75OSiuu+Ax4PQ3Jsg1hTeMUMwJgQp+PKCe2a+JuefFwQnkUgkEolEIpFerW8TL0hlNl2QVAAAAABJRU5ErkJggg==",M3=`
|
|
3
3
|
<div class="stage" id="stage">
|
|
4
4
|
<div class="frame" id="frame">
|
|
@@ -1932,9 +1932,9 @@ button:has(> .icon:only-child) { display: inline-flex; align-items: center; just
|
|
|
1932
1932
|
`}class Ro{static DEFAULT_WITHIN_M=200;static DEFAULT_SPEED_KMH=50;static read(t){if(!t||typeof t!="object")return;const e=t,i=r=>typeof r=="number"&&Number.isFinite(r)&&r>=0?r:void 0,n={};for(const r of["cars","trucks","people","talking","withinM"]){const a=i(e[r]);a!==void 0&&(n[r]=a)}const s=Array.isArray(e.roads)?e.roads.flatMap(r=>{if(!r||typeof r!="object")return[];const a=r,c=i(a.distanceM),l=i(a.vehiclesPerMinute);if(c===void 0||l===void 0)return[];const h={distanceM:c,vehiclesPerMinute:l},u=i(a.trucksPerMinute);u!==void 0&&(h.trucksPerMinute=u);const d=i(a.speedKmh);return d!==void 0&&(h.speedKmh=d),[h]}):[];return s.length>0&&(n.roads=s),Object.keys(n).length>0?n:void 0}static says(t){return t!==void 0&&Object.keys(t).some(e=>e!=="roads"||(t.roads?.length??0)>0)}}class Zr{static KINDS=["beams","launches","reentries"];static statedKinds(t){return Object.keys(t??{}).filter(e=>Array.isArray(t[e])&&t[e].length>0)}static isEmpty(t){return Zr.statedKinds(t).length===0}static written(t){const e=Zr.statedKinds(t);if(e.length===0)return;const i={};for(const n of e)i[n]=t[n];return i}static read(t,e){const i=e,n={};for(const r of Zr.statedKinds(t))n[r]=t[r];for(const r of Zr.KINDS){const a=[...t?.[r]??[],...i?.[r]??[]];a.length>0&&(n[r]=a)}let s=e;if(i&&Zr.KINDS.some(r=>r in i)){const{beams:r,launches:a,reentries:c,...l}=i;s=Zr.isReading(l)?l:void 0}return{skyEvents:Zr.written(n),interpretation:s}}static isReading(t){return(t.bodies?.length??0)>0||t.title!==void 0||(t.smoke?.length??0)>0}}function Hu(o){return[...o].sort((t,e)=>t.t-e.t)}function uf(o,t){let e;for(const i of Hu(o)){if(i.t>t)break;e=i}return e}const ym=Math.PI/180,df=180/Math.PI;class da{constructor(t,e,i){this.kind=t,this.canvasHeightPx=e,this.fovDeg=i;const n=i*ym/2;this.focalPx=t==="equidistant"?e/2/n:e/2/Math.tan(n)}focalPx;static of(t,e,i){return new da(t.projection,e,i)}degToPx(t){const e=t*ym;return this.kind==="equidistant"?this.focalPx*e:2*this.focalPx*Math.tan(e/2)}pxToDeg(t){return this.kind==="equidistant"?t/this.focalPx*df:2*Math.atan(t/(2*this.focalPx))*df}angleDegToRadiusPx(t){const e=t*ym;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*df:Math.atan(t/this.focalPx)*df}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(fi.angularWidthDeg(t))}}class vn{static fovOf(t,e){return ke(t,e)?.fovDeg??Ji.fieldOfViewDeg(t.instrument)}static toAngular(t){this.eachKeyframe(t,(e,i)=>{const n=i.ofBounds(e.bounds);return e.angular?.widthDeg===n.widthDeg&&e.angular.heightDeg===n.heightDeg?e:{...e,angular:n}})}static toBounds(t){this.eachKeyframe(t,(e,i)=>this.sizedFromAngle(e,i))}static sizedFromAngle(t,e){if(!t.angular)return t;const{width:i,height:n}=e.toBoundsSize(t.angular),s={x:t.bounds.x+(t.bounds.width-i)/2,y:t.bounds.y+(t.bounds.height-n)/2,width:i,height:n};if(t.kind!=="polygon")return{...t,bounds:s};const r=t.bounds.width===0?1:i/t.bounds.width,a=t.bounds.height===0?1:n/t.bounds.height;return{...t,bounds:s,points:t.points.map(c=>({x:c.x*r,y:c.y*a}))}}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)<vn.UNMOVED_PX&&Math.abs(s.y-e.bounds.y)<vn.UNMOVED_PX)return e;const r=this.aimFrom(t,i,n,e.bounds);return r?{...e,aim:r}:e})}static UNMOVED_PX=.01;static aimOf(t,e,i){const n=da.of(t.instrument,fi.CANVAS_HEIGHT_PX,this.fovOf(t,e));return this.aimFrom(t,n,ke(t,e),i)}static aimFrom(t,e,i,n){if(i?.headingDeg===void 0)return;const s=this.frameCentre(t),r=e.radiusPxToAngleDeg(n.x+n.width/2-s.x),a=e.radiusPxToAngleDeg(s.y-(n.y+n.height/2));return{azimuthDeg:((i.headingDeg+r)%360+360)%360,altitudeDeg:i.pitchDeg+a}}static toPosition(t){this.eachKeyframe(t,(e,i,n)=>this.placedByAim(t,e,i,n))}static placedByAim(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 derivable(t){const e=new Set,i=new Map,n=new Map;return t.timeline.allKeyframes.forEach((s,r)=>{const a=ke(t,s.t),c=da.of(t.instrument,fi.CANVAS_HEIGHT_PX,this.fovOf(t,s.t));for(const{sourceId:l,shape:h}of s.shapes){const u=n.get(l),d=i.get(l);if(n.set(l,h),!u||!d){i.set(l,h);continue}const f=Object.fromEntries(Object.entries(h).filter(([m,M])=>m!=="bounds"&&m!=="points"&&JSON.stringify(M)!==JSON.stringify(u[m]))),p={...d,...f},g=this.placedByAim(t,this.sizedFromAngle(p,c),c,a);vn.near(g,h)?(e.add(`${r}:${l}`),i.set(l,p)):i.set(l,h)}}),(s,r)=>e.has(`${s}:${r}`)}static SAME_PX=1e-6;static near(t,e){const i=(r,a)=>Math.abs(r-a)<=vn.SAME_PX*Math.max(1,Math.abs(a)),n=t.bounds,s=e.bounds;return!i(n.x,s.x)||!i(n.y,s.y)||!i(n.width,s.width)||!i(n.height,s.height)?!1:e.kind!=="polygon"||t.kind!=="polygon"?!0:t.points.length===e.points.length&&t.points.every((r,a)=>i(r.x,e.points[a].x)&&i(r.y,e.points[a].y))}static positionOf(t,e,i,n,s){if(s?.headingDeg===void 0)return;const r=this.frameCentre(t),a=this.shortestArc(e.azimuthDeg-s.headingDeg),c=e.altitudeDeg-s.pitchDeg;return{x:r.x+this.offAxisPx(n,a)-i.width/2,y:r.y-this.offAxisPx(n,c)-i.height/2}}static frameCentre(t){return{x:Ji.frameWidthPx(t.instrument,fi.CANVAS_HEIGHT_PX)/2,y:fi.CANVAS_HEIGHT_PX/2}}static shortestArc(t){return(t%360+540)%360-180}static offAxisPx(t,e){return Math.abs(e)>=vn.OFF_CANVAS_DEG?Math.sign(e)*vn.OFF_CANVAS_PX:t.angleDegToRadiusPx(e)}static OFF_CANVAS_DEG=89;static OFF_CANVAS_PX=1e5;static reproject(t,e,i){const n=Ji.frameWidthPx(e,fi.CANVAS_HEIGHT_PX)/2,s=Ji.frameWidthPx(t.instrument,fi.CANVAS_HEIGHT_PX)/2,r=fi.CANVAS_HEIGHT_PX/2;for(const a of[...t.timeline.allKeyframes]){const c=this.fovOf(t,a.t),l=i?.get(a.t)??c,h=da.of(e,fi.CANVAS_HEIGHT_PX,l),u=da.of(t.instrument,fi.CANVAS_HEIGHT_PX,c);t.timeline.addKeyframe(a.t,a.shapes.map(d=>{const{bounds:f}=d.shape,p=f.x+f.width/2-n,g=f.y+f.height/2-r,m=Math.hypot(p,g),M=m===0?1:u.angleDegToRadiusPx(h.radiusPxToAngleDeg(m))/m,v={...f,x:s+p*M-f.width/2,y:r+g*M-f.height/2};return{...d,shape:{...d.shape,bounds:v}}}))}this.toBounds(t)}static eachKeyframe(t,e){const{timeline:i}=t;for(const n of[...i.allKeyframes]){const s=ke(t,n.t),r=this.fovOf(t,n.t),a=da.of(t.instrument,fi.CANVAS_HEIGHT_PX,r);let c=!1;const l=n.shapes.map(h=>{const u=e(h.shape,a,s);return u===h.shape?h:(c=!0,{...h,shape:u})});c&&i.addKeyframe(n.t,l)}}}class ys{static isRelative(t){return t!==void 0&&typeof t.eastM=="number"&&typeof t.northM=="number"}static isAbsolute(t){return t!==void 0&&typeof t.lat=="number"&&typeof t.lng=="number"}static referenceOf(t,e){return e.references.find(i=>(i.id??void 0)===(t.relativeTo??void 0))}static resolve(t,e){if(ys.isRelative(t)){const i=ys.referenceOf(t,e);return i?{eastM:i.eastM+t.eastM,northM:i.northM+t.northM}:void 0}return ys.isAbsolute(t)&&e.origin?ys.toLocal(t,e.origin):void 0}static restated(t,e,i){if(ys.isRelative(t)){const s=ys.referenceOf(t,i);return s?ys.relative(e.eastM-s.eastM,e.northM-s.northM,t.relativeTo):void 0}if(!i.origin)return t;const n=ys.toGeo(e,i.origin);return{lat:ys.degrees(n.lat),lng:ys.degrees(n.lng)}}static relative(t,e,i){const n={eastM:ys.metres(t),northM:ys.metres(e)};return i!==void 0&&(n.relativeTo=i),n}static toLocal(t,e){const i=ae(t.lat,t.lng,e.lat,e.lng);return{eastM:i.x,northM:-i.z}}static toGeo(t,e){return zs(t.eastM,-t.northM,e.lat,e.lng)}static metres(t){return Math.round(t*100)/100}static degrees(t){return Math.round(t*1e7)/1e7}}class is{static restatedDecor(t){const e=is.originOf(t);return t.decor.map(i=>{let n=i;if(i.saidPosition){const s=is.restated(i.saidPosition,i,is.frameAt(t,0,e,i.id));JSON.stringify(s)!==JSON.stringify(i.saidPosition)&&(n={...i,saidPosition:s},s||delete n.saidPosition)}if(i.track?.some(s=>s.saidPosition)){const s=i.track.map(r=>{if(!r.saidPosition)return r;const a=is.restated(r.saidPosition,r,is.frameAt(t,r.t,e,i.id));if(JSON.stringify(a)===JSON.stringify(r.saidPosition))return r;const c={...r,saidPosition:a};return a||delete c.saidPosition,c});n={...n,track:s}}return n})}static restatedObserverTrack(t){const e=t.observerTrack.toJSON(),i=is.originOf(t);return!i||!e.keyframes.some(n=>n.pose.saidPosition)?e:{...e,keyframes:e.keyframes.map(n=>{const{pose:s}=n;if(!s.saidPosition||s.lat===void 0||s.lng===void 0)return n;const r=ys.toLocal({lat:s.lat,lng:s.lng},i),a=is.restated(s.saidPosition,r,is.frameAt(t,n.t,i));if(JSON.stringify(a)===JSON.stringify(s.saidPosition))return n;const c={...s,saidPosition:a};return a||delete c.saidPosition,{...n,pose:c}})}}static restatedInterpretation(t){const e=t.interpretation;if(!e?.bodies.some(n=>n.track.some(s=>s.saidPosition)))return e;const i=is.originOf(t);return{...e,bodies:e.bodies.map(n=>n.track.some(s=>s.saidPosition)?{...n,track:n.track.map(s=>{if(!s.saidPosition)return s;const r=s.eastM!==void 0&&s.northM!==void 0?is.restated(s.saidPosition,{eastM:s.eastM,northM:s.northM},is.frameAt(t,s.t,i)):void 0;if(JSON.stringify(r)===JSON.stringify(s.saidPosition))return s;const a={...s,saidPosition:r};return r||delete a.saidPosition,a})}:n)}}static originOf(t){const e=t.observerTrack.getInterpolatedPoseAt(0),i=t.event.place?.[0],n=e?.lat??i?.lat,s=e?.lng??i?.lng;return typeof n=="number"&&typeof s=="number"?{lat:n,lng:s}:void 0}static frameAt(t,e,i,n){const s=[{label:"",eastM:0,northM:0},...t.decor.filter(r=>r.id!==n).map(r=>{const{eastM:a,northM:c}=ga(r,e);return{id:r.id,label:r.id,eastM:a,northM:c}})];return{origin:i,references:s}}static restated(t,e,i){return ys.restated(t,{eastM:e.eastM,northM:e.northM},i)}}class li{constructor(t,e,i){this.params=t,this.from=e,this.origin=t.path[0],this.cos0=Math.cos(t.path[0].lat*Math.PI/180),this.points=t.path.map(r=>this.local(r)),this.cumulative=[0];for(let r=1;r<this.points.length;r++){const a=this.points[r-1],c=this.points[r];this.cumulative.push(this.cumulative[r-1]+Math.hypot(c.e-a.e,c.n-a.n))}this.distances=[];let n=0;for(let r=e;r<=i+li.BEYOND_MS;r+=li.STEP_MS)this.distances.push(n),n+=this.speedAt(r)*li.STEP_MS/1e3;this.shift=this.project(this.local(t.through))-this.distanceAt(t.through.t);const s=[];for(let r=e;r<=i;r+=li.SAMPLE_MS)s.push({t:r,place:this.placeAt(r)});this.sampleOrigin=s[0].place,this.sampleCos=Math.cos(this.sampleOrigin.lat*Math.PI/180),this.samples=s.map(({t:r,place:a})=>({t:r,e:(a.lng-this.sampleOrigin.lng)*Math.PI/180*li.R*this.sampleCos,n:(a.lat-this.sampleOrigin.lat)*Math.PI/180*li.R}))}static R=63710088e-1;static STEP_MS=100;static SAMPLE_MS=2e3;static BEYOND_MS=8e4;origin;cos0;points;cumulative;distances;shift;samples;sampleOrigin;sampleCos;get start(){return this.sampleOrigin}stateAt(t){const e=this.samples,i=e.length-2;let n=0;for(;n<i&&e[n+1].t<t;)n++;const s=e[n],r=e[n+1],a=(t-s.t)/(r.t-s.t),c=p=>[n>0?p[n-1]:2*p[n]-p[n+1],p[n],p[n+1],n+2<p.length?p[n+2]:2*p[n+1]-p[n]],l=e.map(p=>p.e),h=e.map(p=>p.n),u=li.catmull(c(l),a),d=li.catmull(c(h),a),f=(Math.atan2(li.slope(c(l),a),li.slope(c(h),a))*180/Math.PI%360+360)%360;return{eastM:u,northM:d,roadDeg:f,lat:this.sampleOrigin.lat+d/li.R*180/Math.PI,lng:this.sampleOrigin.lng+u/(li.R*this.sampleCos)*180/Math.PI}}bearingAt(t,e){const i=this.local(this.placeAt(t)),n=this.local(e);return(Math.atan2(n.e-i.e,n.n-i.n)*180/Math.PI%360+360)%360}get sampleTimes(){return this.samples.map(t=>t.t)}placeAt(t){const e=this.along(this.distanceAt(t)+this.shift);return{lat:this.origin.lat+e.n/li.R*180/Math.PI,lng:this.origin.lng+e.e/(li.R*this.cos0)*180/Math.PI}}distanceAt(t){const e=Math.max(0,Math.min(this.distances.length-1,Math.round((t-this.from)/li.STEP_MS)));return this.distances[e]}speedAt(t){const e=this.params.speedDivisors?li.linear(this.params.speedDivisors.map(({t:i,divisor:n,step:s})=>({t:i,value:n,step:s})),t):1;return li.linear(this.params.speeds.map(({t:i,kmh:n,step:s})=>({t:i,value:n,step:s})),t)/3.6/e}local(t){return{e:(t.lng-this.origin.lng)*Math.PI/180*li.R*this.cos0,n:(t.lat-this.origin.lat)*Math.PI/180*li.R}}along(t){const e=this.points;let i=0;for(;i<e.length-2&&this.cumulative[i+1]<t;)i++;const n=e[i],s=e[i+1],r=(t-this.cumulative[i])/(this.cumulative[i+1]-this.cumulative[i]);return{e:n.e+(s.e-n.e)*r,n:n.n+(s.n-n.n)*r}}project(t){let e=1/0,i=0;for(let n=0;n<this.points.length-1;n++){const s=this.points[n],r=this.points[n+1],a=r.e-s.e,c=r.n-s.n,l=Math.max(0,Math.min(1,((t.e-s.e)*a+(t.n-s.n)*c)/(a*a+c*c))),h=Math.hypot(s.e+a*l-t.e,s.n+c*l-t.n);h<e&&(e=h,i=this.cumulative[n]+l*Math.hypot(a,c))}return i}static linear(t,e){if(e<=t[0].t)return t[0].value;for(let i=0;i<t.length-1;i++){const n=t[i],s=t[i+1];if(s.step&&e<s.t)return n.value;if(e<=s.t)return n.value+(s.value-n.value)*(e-n.t)/(s.t-n.t)}return t[t.length-1].value}static catmull([t,e,i,n],s){return .5*(2*e+(i-t)*s+(2*t-5*e+4*i-n)*s*s+(3*e-t-3*i+n)*s**3)}static slope([t,e,i,n],s){return .5*(i-t+2*(2*t-5*e+4*i-n)*s+3*(3*e-t-3*i+n)*s*s)}}class ti{constructor(t,e,i,n,s,r){this.drive=t,this.eye=e,this.lookAhead=i,this.lean=n,this.watch=s,this.times=t.sampleTimes;const a=i.pitchShare??1;this.aimed=[];for(const c of this.times){const l=t.bearingAt(c,i.target),h=this.aimed[this.aimed.length-1];this.aimed.push(h===void 0?l:h+ti.signed(l-h))}this.pitched=this.times.map(c=>r(c)*a)}static STEP_MS=250;static DENSE_MS=50;static SETTLED_MS=700;static TURN_S=.4;static TURN_S_PER_DEG=.5/150;static ROAD_PITCH_DEG=-1;static SHOULDER={x:-.08,y:0,z:-.07};static TWIST_FROM_DEG=60;aimed;pitched;times;poses(t,e){const i=[];for(let u=t;u<e;u+=ti.STEP_MS)i.push(u);i.push(e);const n=new Map(i.map(u=>{const d=this.sample(u);return[u,ti.signed(d.headingDeg-d.roadDeg)]})),s=u=>n.get(i.reduce((d,f)=>Math.abs(f-u)<Math.abs(d-u)?f:d)),r=this.schedule(s,e),a=this.watch?.t,c=r.map(([u,d],f)=>{if(f===0)return 0;if(u===a&&this.lean)return this.lean.params.turnS;const p=this.sample(u);return ti.turnS(this.target(r[f-1][1],p),this.target(d,p))}),l=new Set(i),h=r.map(([u],d)=>[u,c[d]]);this.lean&&h.push([this.lean.t,this.lean.params.turnS],[this.lean.t+this.lean.params.holdS*1e3,this.lean.params.turnS]);for(const[u,d]of h){const f=Math.round(u+d*1e3+ti.SETTLED_MS)+ti.DENSE_MS;for(let p=Math.round(u);p<f;p+=ti.DENSE_MS)p>=t&&p<=e&&l.add(p)}return[...l].sort((u,d)=>u-d).map(u=>{const d=this.sample(u),[f,p]=this.gaze(r,c,d),g=this.drive.stateAt(u);return{t:u,headingDeg:f,pitchDeg:p,eye:this.eyeAt(u,ti.signed(f-d.roadDeg)),roadDeg:g.roadDeg,lat:g.lat,lng:g.lng}})}schedule(t,e){const i=[],n=this.lookAhead,s=this.watch?.t??e;let r=0;for(;r<s;){if(Math.abs(t(r))<=n.glanceBeyondDeg){(i.length===0||i[i.length-1][1]!=="watch")&&i.push([r,"watch"]),r+=ti.STEP_MS;continue}if(i.push([r,"glance"]),r+=n.glanceS*1e3,r>=s)break;i.push([r,"road"]),r+=n.roadS*1e3}if(!this.watch)return i;const a=this.watch.params;r=s,i.push([r,"mirror"]),r+=a.firstS*1e3;let c=0;for(;r<e;){const l=r<a.glancesUntil&&c%2===0?"glance":"road";i.push([r,l]),r+=(l==="glance"?a.glanceS:a.roadS)*1e3,i.push([r,"mirror"]),r+=a.mirrorS*1e3,c++}return i}sample(t){const e=this.times,i=e.length-2;let n=0;for(;n<i&&e[n+1]<t;)n++;const s=(t-e[n])/(e[n+1]-e[n]),r=a=>[n>0?a[n-1]:2*a[n]-a[n+1],a[n],a[n+1],n+2<a.length?a[n+2]:2*a[n+1]-a[n]];return{t,roadDeg:this.drive.stateAt(t).roadDeg,headingDeg:(li.catmull(r(this.aimed),s)%360+360)%360,pitchDeg:li.catmull(r(this.pitched),s),eye:this.eyeAt(t,0)}}target(t,e){const{roadDeg:i,headingDeg:n,pitchDeg:s,eye:r}=e;if(t==="glance")return[n,s];if(t==="watch"){const u=ti.signed(n-i),d=this.lookAhead.keepDeg,f=u-d*Math.tanh(u/d),p=u?f/u:0;return[ti.normalized(i+f),ti.ROAD_PITCH_DEG+(s-ti.ROAD_PITCH_DEG)*p]}if(t==="road"||!this.watch)return[i,ti.ROAD_PITCH_DEG];const a=this.watch.params.mirror,c={x:a.x-r.x,y:a.y-r.y,z:a.z-r.z},l=Math.atan2(-c.x,-c.z)*180/Math.PI,h=Math.atan2(c.y,Math.hypot(c.x,c.z))*180/Math.PI;return[ti.normalized(i-l),h]}gaze(t,e,i,n){const s=i.t;let r=n??0;if(n===void 0&&s>=t[0][0])for(let m=0;m<t.length;m++)t[m][0]<=s&&(r=m);const[a,c]=this.target(t[r][1],i);if(r===0)return[a,c];const l=e[r]*1e3,h=s-t[r][0];if(h>l+ti.SETTLED_MS)return[a,c];const[u,d]=this.gaze(t,e,i,r-1);if(h<l){const m=h/l,M=-2*m**3+3*m*m+(m**3-m*m)*Sn.ARRIVAL;return[ti.normalized(u+ti.signed(a-u)*M),d+(c-d)*M]}const f=ti.signed(a-u),p=h-l,g=Sn.ARRIVAL/l*p*Math.exp(-p/Math.min(Sn.SETTLE_MS,.4*l));return[ti.normalized(a+f*g),c+(c-d)*g]}leanAt(t){if(!this.lean)return 0;const{holdS:e,turnS:i}=this.lean.params,n=(t-this.lean.t)/1e3;return n<0||n>e+i?0:ti.smooth(Math.min(1,n/i,(e+i-n)/i))}eyeAt(t,e){const i=this.leanAt(t),n=this.lean?.params.offsetM??{x:0,y:0,z:0},s=ti.smooth((Math.abs(e)-ti.TWIST_FROM_DEG)/(180-ti.TWIST_FROM_DEG)),r=ti.SHOULDER;return{x:this.eye.x+n.x*i+r.x*s,y:this.eye.y+n.y*i+r.y*s,z:this.eye.z+n.z*i+r.z*s}}static turnS(t,e){return ti.TURN_S+ti.TURN_S_PER_DEG*Math.hypot(ti.signed(e[0]-t[0]),e[1]-t[1])}static smooth(t){const e=Math.min(1,Math.max(0,t));return e*e*e*(10-15*e+6*e*e)}static signed(t){return((t+540)%360+360)%360-180}static normalized(t){return(t%360+360)%360}}const xm=Math.PI/180;class Lt{constructor(t,e,i){this.body=t,this.ground=e,this.eyeAt=i;const n=Lt.placedInWorld.get(t);if(n){this.keys=n.keys,this.motionKeys=n.motionKeys,this.turnKeys=n.turnKeys,this.lightKeys=n.lightKeys;return}const s=[...t.track].sort((r,a)=>r.t-a.t);this.keys=this.place(s,i),this.motionKeys=new Map,this.turnKeys=new Map,this.lightKeys=new Map;for(const r of s)Lt.collect(this.motionKeys,r.t,r.motions),Lt.collect(this.turnKeys,r.t,r.turns),Lt.collect(this.lightKeys,r.t,r.lights);!t.withObserver&&s.every(r=>r.azimuthDeg===void 0&&r.altitudeDeg===void 0)&&Lt.placedInWorld.set(t,{keys:this.keys,motionKeys:this.motionKeys,turnKeys:this.turnKeys,lightKeys:this.lightKeys})}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,finish:"matt",luminanceCdM2:0,transparency:0,haloScale:1};keys;static placedInWorld=new WeakMap;motionKeys;turnKeys;lightKeys;static collect(t,e,i){for(const[n,s]of Object.entries(i??{})){const r=t.get(n)??[];r.push({t:e,value:s}),t.set(n,r)}}motionsAt(t){return Lt.channelsAt(this.motionKeys,t,0)}lightsAt(t){return this.lightKeys.size>0?Lt.channelsAt(this.lightKeys,t,void 0):void 0}static channelsAt(t,e,i){const n={};for(const[s,r]of t){let a=r.length-1;for(;a>=0&&r[a].t>e;)a--;if(a<0){i!==void 0&&(n[s]=i);continue}const c=r[a],l=r[Math.min(a+1,r.length-1)],h=l===c||l.t===c.t?0:Math.min(1,(e-c.t)/(l.t-c.t));n[s]=Lt.lerp(c.value,l.value,h)}return n}static eyeOf(t,e,i){const n=ke(t,0),s=ke(t,e),a=n?.lat!==void 0&&n.lng!==void 0&&s?.lat!==void 0&&s.lng!==void 0?ae(s.lat,s.lng,n.lat,n.lng):void 0,c=a?a.x:0,l=a?-a.z:0;return{eastM:c,northM:l,upM:i.heightAt(c,l)+Lt.EYE_HEIGHT_M+(s?.elevationM??0),headingDeg:s?.headingDeg}}static lineOfSightMeetsGround(t,e,i,n){const s=Lt.directionOf(e,i),r=l=>t.upM+s.upM*l-n.heightAt(t.eastM+s.eastM*l,t.northM+s.northM*l);let a=0,c=0;for(;c<Lt.MAX_RANGE_M;){if(c=a+Math.max(.5,a*.01),r(c)<=0){for(let l=0;l<30;l++){const h=(a+c)/2;r(h)<=0?c=h:a=h}return c}a=c}}static directionOf(t,e){const i=t*xm,n=e*xm;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=0,n=e.length-1;for(;i<n;){const g=i+n+1>>1;e[g].t>t?n=g-1:i=g}const s=i,r=e[s];if(!r.present)return;const a=e[Math.min(s+1,e.length-1)],c=a===r||a.t===r.t?0:Math.min(1,(t-r.t)/(a.t-r.t)),l=this.body.withObserver&&r.carried&&a.carried?this.eyeAt(t):void 0,h=l?l.eastM+Lt.lerp(r.carried.eastM,a.carried.eastM,c):Lt.lerp(r.eastM,a.eastM,c),u=l?l.northM+Lt.lerp(r.carried.northM,a.carried.northM,c):Lt.lerp(r.northM,a.northM,c),d={widthM:Lt.lerp(r.sizeM.widthM,a.sizeM.widthM,c),lengthM:Lt.lerp(r.sizeM.lengthM,a.sizeM.lengthM,c),heightM:Lt.lerp(r.sizeM.heightM,a.sizeM.heightM,c)},f={headingDeg:Lt.lerpAngle(r.attitude.headingDeg,a.attitude.headingDeg,c),pitchDeg:Lt.lerp(r.attitude.pitchDeg,a.attitude.pitchDeg,c),rollDeg:Lt.lerp(r.attitude.rollDeg,a.attitude.rollDeg,c)};let p;if(l)p=l.upM+Lt.lerp(r.carried.upM,a.carried.upM,c);else if("aboveGroundM"in r.vertical&&"aboveGroundM"in a.vertical){const g=Lt.lerp(r.vertical.aboveGroundM,a.vertical.aboveGroundM,c);p=this.groundUnderFootprint(h,u,d,f.headingDeg)+g+d.heightM/2}else p=Lt.lerp(this.centreUpOf(r),this.centreUpOf(a),c);return{id:this.body.id,model:this.body.model,modelParameters:this.body.modelParameters,flicker:this.body.flicker,explains:this.body.explains??[],...this.body.ensemble?{ensemble:this.body.ensemble}:{},...this.body.shadow===!1?{shadow:!1}:{},...this.body.lightFromBelow?{lightFromBelow:this.body.lightFromBelow}:{},outlineNode:this.body.outlineNode,eastM:h,northM:u,upM:p,sizeM:d,attitude:f,appearance:{color:Lt.lerpColor(r.appearance.color,a.appearance.color,c),albedo:Lt.lerp(r.appearance.albedo,a.appearance.albedo,c),finish:c<1?r.appearance.finish:a.appearance.finish,luminanceCdM2:Lt.lerp(r.appearance.luminanceCdM2,a.appearance.luminanceCdM2,c),transparency:Lt.lerp(r.appearance.transparency,a.appearance.transparency,c),haloScale:Lt.lerp(r.appearance.haloScale,a.appearance.haloScale,c)},flame:Lt.flameBetween(r.flame,a.flame,c),motions:this.motionsAt(t),...this.turnKeys.size>0?{turns:Lt.channelsAt(this.turnKeys,t,0)}:{},lights:this.lightsAt(t),...this.body.lamps?.length?{lamps:this.body.lamps}:{},throwsFlame:this.body.track.some(g=>g.flame!==void 0&&g.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,r={...i<1?n:s,lengthM:Lt.lerp(n.lengthM,s.lengthM,i),widthM:Lt.lerp(n.widthM,s.widthM,i),luminanceCdM2:Lt.lerp(n.luminanceCdM2,s.luminanceCdM2,i)};return r.luminanceCdM2>0?r:void 0}centreUpOf(t){if(!("upM"in t.vertical))return this.groundUnderFootprint(t.eastM,t.northM,t.sizeM,t.attitude.headingDeg)+t.vertical.aboveGroundM+t.sizeM.heightM/2;const e=t.vertical.fromGround;if(!e)return t.vertical.upM-(this.ground.dropAt?.(t.eastM,t.northM)??0);const i=t.vertical.upM+this.ground.heightAt(e.eastM,e.northM);return Math.max(i,this.groundUnderFootprint(t.eastM,t.northM,t.sizeM,t.attitude.headingDeg)+t.sizeM.heightM/2)}groundUnderFootprint(t,e,i,n){const s=n*xm,r={eastM:Math.cos(s),northM:-Math.sin(s)},a={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+r.eastM*u+a.eastM*d,e+r.northM*u+a.northM*d))}return c}place(t,e){const i=[];let n;for(const s of t){const r=s.sizeM??n?.sizeM??Lt.DEFAULT_SIZE,a={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??Lt.DEFAULT_APPEARANCE.color,albedo:s.appearance?.albedo??n?.appearance.albedo??Lt.DEFAULT_APPEARANCE.albedo,finish:s.appearance?.finish??n?.appearance.finish??Lt.DEFAULT_APPEARANCE.finish,luminanceCdM2:s.appearance?.luminanceCdM2??n?.appearance.luminanceCdM2??Lt.DEFAULT_APPEARANCE.luminanceCdM2,transparency:s.appearance?.transparency??n?.appearance.transparency??Lt.DEFAULT_APPEARANCE.transparency,haloScale:s.appearance?.haloScale??n?.appearance.haloScale??Lt.DEFAULT_APPEARANCE.haloScale},l=this.positionOf(s,r,e)??(n&&{eastM:n.eastM,northM:n.northM,vertical:this.verticalOf(s,r)??n.vertical});if(!l)continue;const h=s.flame??n?.flame,u=s.present??n?.present??!0;if(n={t:s.t,...l,sizeM:r,attitude:a,appearance:c,flame:h,present:u},this.body.withObserver&&s.azimuthDeg!==void 0&&s.distanceM!==void 0){const d=Lt.directionOf(s.azimuthDeg,s.altitudeDeg??0);n.carried={eastM:d.eastM*s.distanceM,northM:d.northM*s.distanceM,upM:d.upM*s.distanceM}}i.push(n)}return i}verticalOf(t,e){if(t.onGround)return{aboveGroundM:0};if(t.altitudeAboveGroundM!==void 0)return{aboveGroundM:t.altitudeAboveGroundM};if(t.altitudeM!==void 0)return{upM:t.altitudeM+e.heightM/2,fromGround:this.body.altitudeFrom}}positionOf(t,e,i){if(t.eastM!==void 0&&t.northM!==void 0)return{eastM:t.eastM,northM:t.northM,vertical:this.verticalOf(t,e)??{aboveGroundM:0}};if(t.azimuthDeg===void 0||t.altitudeDeg===void 0)return;const n=i(t.t);if(!n)return;const s=t.distanceM??(t.onGround?Lt.lineOfSightMeetsGround(n,t.azimuthDeg,t.altitudeDeg,this.ground):void 0);if(s===void 0)return;const r=Lt.directionOf(t.azimuthDeg,t.altitudeDeg),a=n.eastM+r.eastM*s,c=n.northM+r.northM*s;return{eastM:a,northM:c,vertical:this.verticalOf(t,e)??{upM:n.upM+r.upM*s}}}static lerp(t,e,i){return t+(e-t)*i}static lerpColor(t,e,i){const n=Lt.rgbOf(t),s=Lt.rgbOf(e);return!n||!s?i<1?t:e:"#"+n.map((r,a)=>Math.round(Lt.lerp(r,s[a],i)).toString(16).padStart(2,"0")).join("")}static rgbOf(t){const e=/^#([0-9a-f]{3}|[0-9a-f]{6})$/i.exec(t);if(!e)return;const i=e[1].length===3?e[1].replace(/./g,"$&$&"):e[1];return[0,2,4].map(n=>parseInt(i.slice(n,n+2),16))}static lerpAngle(t,e,i){const n=((e-t)%360+540)%360-180;return((t+n*i)%360+360)%360}}class Ls{static ANONYMOUS_OBSERVER="observer";static observerId(t){return t.observer?.id??Ls.ANONYMOUS_OBSERVER}static shapeIds(t){const e=new Set(t.timeline.sourceIds);for(const i of t.events??[])if(i.eventType==="appearance")for(const n of i.params?.parts??[])e.add(n.sourceId);return[...e]}static ids(t){const e=new Map,i=(n,s)=>{n!==void 0&&e.set(n,[...e.get(n)??[],s])};i(Ls.observerId(t),"observer");for(const n of Ls.shapeIds(t))i(n,"shape");for(const n of t.timeline.allGroups)i(n.id,"group");for(const n of t.interpretation?.bodies??[])i(n.id,"body");for(const n of t.decor)i(n.id,"decor");return e}static kindOf(t,e){if(e===void 0)return;const i=Ls.ids(t).get(e);return i?.length===1?i[0]:void 0}static partOf(t){const e=t?.indexOf("/")??-1;if(!(t===void 0||e<=0||e===t.length-1))return{element:t.slice(0,e),part:t.slice(e+1)}}static hasPart(t,e,i){if(e==="body")return!0;if(e!=="decor")return!1;const n=t.decor.find(s=>s.id===i.element);return!!(n?.lights?.some(s=>s.id===i.part)||n?.groups?.some(s=>s.id===i.part))}static isObserver(t,e){return e.who===Ls.observerId(t)}static isPhenomenon(t,e){return e.who===void 0?!1:t.timeline.groupOf(e.who)!==void 0||Ls.shapeIds(t).includes(e.who)}static within(t,e){const i=new Set([e]),n=s=>{for(const r of t.timeline.groupOf(s)?.members??[])i.has(r)||(i.add(r),n(r))};return n(e),i}static renamed(t,e,i){if(e!==i)for(const n of t.events??[])n.who===e&&(n.who=i)}static issues(t){const e=[],i=Ls.ids(t);for(const[n,s]of i)s.length>1&&e.push({kind:"duplicate-id",id:n,path:s.join(", ")});return(t.events??[]).forEach((n,s)=>{const r=Ls.partOf(n.who);r&&i.get(r.element)?.length===1&&Ls.hasPart(t,i.get(r.element)[0],r)||(n.who===void 0||!i.has(n.who))&&e.push({kind:"unknown-who",id:n.who??"",path:`events.${s}.who`})}),e}}class Se{constructor(t,e,i){this.travel=t;const n=t.params,s=t.until??i;let r=Se.unit(n.from),a=Se.towards(r,Se.unit(n.towards));const c=e.map(h=>{const u=h.params,d=u.side==="left"?1:-1;return{from:h.t,to:h.until??h.t,radians:u.byDeg*Math.PI/180*(u.seenFrom==="craft"?-d:d)}}),l=Se.STEP_MS;for(let h=t.t;h<=s;h+=l){this.directions.push(Se.direction(r));for(const f of c){const p=f.to-f.from;if(p<=0)continue;const g=f.radians*(Se.smooth((h+l-f.from)/p)-Se.smooth((h-f.from)/p));g&&(a=Se.add(Se.scale(a,Math.cos(g)),Se.scale(Se.cross(a,r),Math.sin(g))))}const u=Se.speedAt(n.speeds,h)*l/1e3*Math.PI/180,d=Se.add(Se.scale(r,Math.cos(u)),Se.scale(a,Math.sin(u)));a=Se.add(Se.scale(a,Math.cos(u)),Se.scale(r,-Math.sin(u))),r=d}}static STEP_MS=5;directions=[];at(t){const e=Math.round((t-this.travel.t)/Se.STEP_MS);return this.directions[Math.max(0,Math.min(this.directions.length-1,e))]}sizeAt(t){const e=this.travel.params;return e.sizeBy!=="altitude"?e.sizeDeg:e.sizeDeg*Math.max(.1,Math.sin(Math.max(this.at(t).altitudeDeg,1)*Math.PI/180))}static speedAt(t,e){if(t.length===0)return 0;if(e<=t[0].t)return t[0].degPerS;for(let i=1;i<t.length;i++){const n=t[i-1],s=t[i];if(s.step&&e<s.t)return n.degPerS;if(e<s.t)return n.degPerS+(s.degPerS-n.degPerS)*Se.smooth((e-n.t)/(s.t-n.t))}return t[t.length-1].degPerS}static smooth(t){const e=Math.max(0,Math.min(1,t));return e*e*(3-2*e)}static unit(t){const e=t.azimuthDeg*Math.PI/180,i=t.altitudeDeg*Math.PI/180;return[Math.cos(i)*Math.sin(e),Math.cos(i)*Math.cos(e),Math.sin(i)]}static direction(t){return{azimuthDeg:(Math.atan2(t[0],t[1])*180/Math.PI%360+360)%360,altitudeDeg:Math.asin(Math.max(-1,Math.min(1,t[2])))*180/Math.PI}}static towards(t,e){const i=Se.add(e,Se.scale(t,-Se.dot(t,e))),n=Math.hypot(...i)||1;return Se.scale(i,1/n)}static toScreen(t,e,i){const[n,s,r]=Se.basis(e,i),a=Se.unit(t),c=Se.dot(a,n);return[Se.dot(a,s)/c,Se.dot(a,r)/c]}static fromScreen(t,e,i,n){const[s,r,a]=Se.basis(i,n),c=[s[0]+t*r[0]+e*a[0],s[1]+t*r[1]+e*a[1],s[2]+t*r[2]+e*a[2]],l=Math.hypot(...c);return Se.direction([c[0]/l,c[1]/l,c[2]/l])}static basis(t,e){const i=t*Math.PI/180,n=e*Math.PI/180;return[[Math.cos(n)*Math.sin(i),Math.cos(n)*Math.cos(i),Math.sin(n)],[Math.cos(i),-Math.sin(i),0],[-Math.sin(n)*Math.sin(i),-Math.sin(n)*Math.cos(i),Math.cos(n)]]}static dot(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]}static cross(t,e){return[t[1]*e[2]-t[2]*e[1],t[2]*e[0]-t[0]*e[2],t[0]*e[1]-t[1]*e[0]]}static add(t,e){return[t[0]+e[0],t[1]+e[1],t[2]+e[2]]}static scale(t,e){return[t[0]*e,t[1]*e,t[2]*e]}}class Do{constructor(t,e){this.sighting=t,this.events=e}static FOV_DEG=60;keyframes(){const t=this.events.filter(c=>c.eventType==="look").sort((c,l)=>c.t-l.t),e=this.events.filter(c=>c.eventType==="walk").sort((c,l)=>c.t-l.t),i=this.events.filter(c=>c.eventType==="follow").sort((c,l)=>c.t-l.t);if(t.length===0&&e.length===0)return[];const n=new Set([0]);for(const c of[...t,...e,...i])n.add(c.t),c.until!==void 0&&n.add(c.until);const s=c=>{let l;for(const h of e){const u=h.params;if(c<=h.t)return l??u.from;if(h.until===void 0||c>=h.until)l=u.to;else return}return l??this.sighting.event.place?.[0]},r=c=>([...t].reverse().find(h=>h.t<=c)??t[0])?.params??{headingDeg:0,pitchDeg:0},a=[...n].sort((c,l)=>c-l).flatMap(c=>{const l=s(c);if(!l)return[];const h=r(c);return[{t:c,pose:Do.pose(l,h.headingDeg,h.pitchDeg,h.fovDeg)}]});for(const c of a)this.sighting.observerTrack.addKeyframe(c.t,c.pose);for(const c of i)this.follow(c,r(c.t));return[...this.sighting.observerTrack.allKeyframes]}follow(t,e){const i=t.params;if(this.followSky(t,e))return;const n=this.sighting.interpretation?.bodies.find(h=>h.id===i.target);if(!n)return;const s={heightAt:()=>0},r=h=>Lt.eyeOf(this.sighting,h,s),a=new Lt(n,s,r),c=t.until??1/0;let l=e;for(const h of n.track){if(h.t<=t.t||h.t>=c)continue;const u=a.at(h.t),d=r(h.t),f=this.sighting.observerTrack.getInterpolatedPoseAt(h.t);if(!u||!d||!f)continue;const p=u.eastM-d.eastM,g=u.northM-d.northM,m=u.upM-d.upM;l={headingDeg:(Math.atan2(p,g)*180/Math.PI%360+360)%360,pitchDeg:Math.atan2(m,Math.hypot(p,g))*180/Math.PI},this.sighting.observerTrack.addKeyframe(h.t,{...f,headingDeg:l.headingDeg,pitchDeg:l.pitchDeg})}if(Number.isFinite(c)){const h=this.sighting.observerTrack.getInterpolatedPoseAt(c);h&&this.sighting.observerTrack.addKeyframe(c,{...h,headingDeg:l.headingDeg,pitchDeg:l.pitchDeg})}}static FOLLOW_SKY_MS=25;static CATCH_UP_MS=900;static OVERHEAD_DEG=78;static HIGHEST_PITCH_DEG=88;followSky(t,e){const i=t.params,n=Ls.within(this.sighting,i.target),s=this.sighting.events??[],r=s.find(M=>M.eventType==="travel"&&M.who!==void 0&&n.has(M.who));if(!r)return!1;const a=this.sighting.event.durationSeconds!==void 0?this.sighting.event.durationSeconds*1e3:r.until??t.t,c=new Se(r,s.filter(M=>M.eventType==="turn"&&M.who!==void 0&&n.has(M.who)),a),l=t.until??a,h=(i.lagS??0)*1e3,u=(i.reactionS??0)*1e3,d=[],f=this.sighting.sampleMs??Do.FOLLOW_SKY_MS;for(let M=t.t;M<=l;M+=f)d.push(M);const p=d.map(M=>c.at(Math.max(r.t,M-h))),g=p.map(M=>M.azimuthDeg),m=p.flatMap((M,v)=>M.altitudeDeg>Do.OVERHEAD_DEG?[v]:[]);if(m.length>0){const M=Math.max(0,m[0]-1),v=Math.min(d.length-1,m[m.length-1]+1),x=g[M],y=(g[v]-x+540)%360-180;for(let w=M;w<=v;w++)g[w]=((x+y*Se.smooth((w-M)/(v-M)))%360+360)%360}return d.forEach((M,v)=>{const x=Se.smooth((M-t.t-u)/Do.CATCH_UP_MS),y=(g[v]-e.headingDeg+540)%360-180,w=Math.min(p[v].altitudeDeg,Do.HIGHEST_PITCH_DEG),b=this.sighting.observerTrack.getInterpolatedPoseAt(M)??this.sighting.observerTrack.getLatestPoseAt(M);if(!b)return;const E=S=>Math.round(S*100)/100;this.sighting.observerTrack.addKeyframe(M,{...b,headingDeg:E(((e.headingDeg+y*x)%360+360)%360),pitchDeg:E(e.pitchDeg+(w-e.pitchDeg)*x)})}),!0}static pose(t,e,i,n=Do.FOV_DEG){return{lat:t.lat,lng:t.lng,elevationM:0,headingDeg:e,pitchDeg:i,fovDeg:n}}}class Yo{constructor(t,e,i,n){this.body=t,this.events=e,this.endMs=i,this.sampleMs=n}static SAMPLE_MS=250;track(){const t=new Map,e=l=>{const h=t.get(l.t);t.set(l.t,h?{...h,...l,motions:{...h.motions,...l.motions},...h.turns||l.turns?{turns:{...h.turns,...l.turns}}:{},...h.lights||l.lights?{lights:{...h.lights,...l.lights}}:{}}:l)};for(const l of this.body.track)e({...l});const i=[...this.events].sort((l,h)=>l.t-h.t),n=new Map,s=new Map,r=new Map;let a=0;for(const l of this.body.track){for(const[h,u]of Object.entries(l.motions??{}))n.set(h,u);for(const[h,u]of Object.entries(l.turns??{}))s.set(h,u);for(const[h,u]of Object.entries(l.lights??{}))r.set(h,u);l.attitude?.headingDeg!==void 0&&(a=l.attitude.headingDeg)}let c=this.startPlace();for(const l of i){const h=Yo.partOf(l.who,this.body.id);if(h!==void 0&&(l.eventType==="light"||l.eventType==="blink")){for(const u of this.leavesOf(h))this.switchLight(u,l,r,e,d=>t.get(d)?.lights?.[u]);continue}if(h!==void 0){if(l.eventType!=="spin"&&l.eventType!=="turn")continue;const u=s.get(h)??0,d=l.until??l.t,f=l.eventType==="spin"?u+360*l.params.turnsPerS*(d-l.t)/1e3:l.params.headingDeg;e({t:l.t,turns:{[h]:u}}),e({t:d,turns:{[h]:f}}),s.set(h,f);continue}if((l.eventType==="motion"||l.eventType==="spin")&&l.params?.motion){const u=l.params,d=u.motion,f=n.get(d)??0,p=l.until??l.t,g=l.eventType==="motion"?u.to:f+u.turnsPerS*(p-l.t)/1e3;e({t:l.t,motions:{[d]:f}}),e({t:p,motions:{[d]:g}}),n.set(d,g)}else if(l.eventType==="rise"&&c){const u=l.params,d=l.until??l.t,f=u.angleDeg*Math.PI/180,p=(u.headingDeg??0)*Math.PI/180,g=c,m=M=>{const v=u.stops===!1?M*M:M*M*M*(10-15*M+6*M*M),x=u.distanceM*v;return{eastM:g.eastM+x*Math.sin(f)*Math.sin(p),northM:g.northM+x*Math.sin(f)*Math.cos(p),aboveGroundM:g.aboveGroundM+x*Math.cos(f)}};for(let M=l.t;M<d;M+=this.sampleMs??Yo.SAMPLE_MS)e(Yo.key(M,m((M-l.t)/(d-l.t))));c=m(1),e(Yo.key(d,c))}else if(l.eventType==="turn"){const u=l.params;e({t:l.t,attitude:{headingDeg:a}}),e({t:l.until??l.t,attitude:{headingDeg:u.headingDeg}}),a=u.headingDeg}else l.eventType==="vanish"&&e({t:l.t,present:!1})}return[...t.values()].sort((l,h)=>l.t-h.t)}static ride(t,e,i){const n=e.params,s=e.until??1/0,r=new Map(t.track.map(a=>[a.t,{...a}]));for(const a of i.track){if(a.t<e.t||a.t>s||(a.present===!1&&r.set(a.t,{...r.get(a.t),t:a.t,present:!1}),a.eastM===void 0||a.northM===void 0))continue;const c=(a.onGround?0:a.altitudeAboveGroundM??0)+n.aboveM;r.set(a.t,{...r.get(a.t),t:a.t,eastM:a.eastM,northM:a.northM,altitudeAboveGroundM:c})}return[...r.values()].sort((a,c)=>a.t-c.t)}switchLight(t,e,i,n,s){const r=i.get(t)??0,a=e.eventType==="light"?e.until:e.until??this.endMs,c=(l,h)=>n({t:l,lights:{[t]:h}});if(e.t>0&&s(e.t-1)===void 0&&c(e.t-1,r),e.eventType==="light"){const l=e.params.cdM2;if(c(e.t,l),a===void 0){i.set(t,l);return}c(a-1,l)}else{const l=e.params;if(a===void 0)return;const h=l.cdM2??r;let u=e.t,d=!0;for(;u<a;){const f=Math.min(Math.round(u+1e3*(d?l.onS:l.offS)),a);if(f<=u)break;c(u,d?h:0),c(f-1,d?h:0),u=f,d=!d}}c(a,r),i.set(t,r)}leavesOf(t,e=new Set){const i=this.body.groups?.find(n=>n.id===t);return!i||e.has(t)?[t]:(e.add(t),i.members.flatMap(n=>this.leavesOf(n,e)))}static partOf(t,e){return t!==void 0&&t.startsWith(`${e}/`)&&t.length>e.length+1?t.slice(e.length+1):void 0}startPlace(){const t=this.body.track.find(e=>e.eastM!==void 0&&e.northM!==void 0);return t&&{eastM:t.eastM,northM:t.northM,aboveGroundM:t.onGround?0:t.altitudeAboveGroundM??0}}static key(t,e){return e.aboveGroundM<=0?{t,eastM:e.eastM,northM:e.northM,onGround:!0}:{t,eastM:e.eastM,northM:e.northM,altitudeAboveGroundM:e.aboveGroundM}}}class Nd{constructor(t,e,i){this.object=t,this.events=e,this.endMs=i}lights(){const t=new Map,e=[...this.events].sort((i,n)=>i.t-n.t);for(const i of e){const n=Nd.partOf(i.who,this.object.id);if(!(n===void 0||i.eventType!=="light"&&i.eventType!=="blink"))for(const s of this.leavesOf(n)){const r=this.object.lights?.find(a=>a.id===s);r&&t.set(s,this.switched(r,t.get(s)??[],i))}}return(this.object.lights??[]).map(i=>t.has(i.id)?{...i,keyframes:t.get(i.id)}:i)}switched(t,e,i){const n=Nd.stateAt(t,e,i.t),s=i.eventType==="light"?i.until:i.until??this.endMs,r=[];if(i.eventType==="light")r.push({t:i.t,intensity:i.params.intensity,pattern:n.pattern});else{const c=i.params,l=c.onS+c.offS;if(s===void 0||l<=0)return e;const h=l*1e3,u=(-i.t/h%1+1)%1,d={kind:"flash",perMinute:60/l,dutyCycle:c.onS/l,...u?{phase:u}:{}},f=c.intensity??(n.intensity>0?n.intensity:t.intensity??1);r.push({t:i.t,intensity:f,pattern:d})}s!==void 0&&r.push({t:s,intensity:n.intensity,pattern:n.pattern});const a=new Set(r.map(c=>c.t));return[...e.filter(c=>!a.has(c.t)),...r].sort((c,l)=>c.t-l.t)}static stateAt(t,e,i){const n=e.filter(s=>s.t<=i).at(-1);return{intensity:n?.intensity??t.intensity??1,pattern:n?.pattern??t.pattern}}leavesOf(t,e=new Set){const i=this.object.groups?.find(n=>n.id===t);return!i||e.has(t)?[t]:(e.add(t),i.members.flatMap(n=>this.leavesOf(n,e)))}static partOf(t,e){return t!==void 0&&t.startsWith(`${e}/`)&&t.length>e.length+1?t.slice(e.length+1):void 0}}class Sh{static observer(t){const e=t.allKeyframes,i=e.map(s=>Sh.said(s.pose)),n=e.filter((s,r)=>r>0&&r<e.length-1&&i[r]===i[r-1]&&i[r]===i[r+1]);for(const s of n)t.removeKeyframeAt(s.t)}static said(t){return JSON.stringify(t,(e,i)=>typeof i=="number"?Math.round(i*1e10)/1e10:i)}static timeline(t){const e=new Map;for(const i of t.allKeyframes)for(const n of i.shapes){const s=e.get(n.sourceId)??[];s.push({t:i.t,said:Sh.said(n.shape)}),e.set(n.sourceId,s)}for(const[i,n]of e){const s=n.filter((r,a)=>a>0&&a<n.length-1&&r.said===n[a-1].said&&r.said===n[a+1].said);for(const r of s)t.removeShapeAt(r.t,i)}}}class J0{constructor(t,e){this.end=e;const i=[...t].sort((n,s)=>n.t-s.t);this.rolls=i.filter(n=>n.eventType==="roll"),this.vibrations=i.filter(n=>n.eventType==="vibrate"),this.spirals=i.filter(n=>n.eventType==="spiral")}static SPIRAL_OPENS=4;static THINNEST=.08;rolls;vibrations;spirals;rollAt(t){let e=0,i=0;for(const n of this.rolls){if(t<n.t)break;const s=n.params,r=this.progress(n,t);i=e+(s.toDeg-e)*(s.andBack?Math.sin(Math.PI*Se.smooth(r)):Se.smooth(r)),s.andBack||(e=s.toDeg)}for(const n of this.spirals){if(t<n.t)break;const s=n.params;i=e+(s.clockwise?1:-1)*s.rollDeg*this.progress(n,t)}return i}acrossShareAt(t){return Math.max(J0.THINNEST,Math.abs(Math.cos(this.rollAt(t)*Math.PI/180)))}sidewaysAt(t,e){let i=0;for(const n of this.vibrations){const s=n.until??this.end;if(t<n.t||t>=s)continue;const r=n.params,a=Se.smooth((t-n.t)/(r.riseS*1e3))*Math.max(0,1-(t-n.t)/(s-n.t));i+=r.amplitudeShare*e*a*Math.sin(2*Math.PI*r.hz*(t-n.t)/1e3)}return i}spiralAt(t){const e=[...this.spirals].reverse().find(a=>a.t<=t);if(!e)return;const i=e.params,n=this.progress(e,t),s=Math.tan(i.radiusDeg*Math.PI/180)*Se.smooth(n*J0.SPIRAL_OPENS)*(1-i.shrink*Se.smooth(n)),r=-(i.clockwise?1:-1)*2*Math.PI*i.turns*n;return[s*(Math.cos(r)-1),s*Math.sin(r)]}progress(t,e){const i=t.until??this.end;return i<=t.t?1:Math.max(0,Math.min(1,(e-t.t)/(i-t.t)))}}class Ps{constructor(t,e,i,n){this.sighting=t,this.stand=e;const s=i.filter(a=>a.eventType==="appearance").sort((a,c)=>a.t-c.t);this.vanishAt=i.find(a=>a.eventType==="vanish")?.t;const r=this.vanishAt??n;this.path=e.eventType==="travel"?new Se(e,i.filter(a=>a.eventType==="turn"),n):void 0,this.motion=this.path?new J0(i,e.until??n):void 0,this.looks=s.map((a,c)=>({t:a.t,until:a.until??s[c+1]?.t??r,parts:a.params.parts})),this.blinks=i.filter(a=>a.eventType==="blink").map(a=>({t:a.t,until:a.until??r,parts:a.who===void 0?[]:t.timeline.leavesOf(a.who),params:a.params}))}static SAMPLE_MS=2e3;static TRAVEL_SAMPLE_MS=25;static MOTION_MS=40;static SPIRAL_AHEAD_MS=20;static R=63710088e-1;looks;blinks;vanishAt;path;motion;timeline(){const t=new Map,e=(r,a)=>{const c=this.state(a,r);c&&(t.has(r)||t.set(r,new Map),t.get(r).set(a,c))},i=[...new Set(this.looks.flatMap(r=>r.parts.map(a=>a.sourceId)))];this.looks.forEach((r,a)=>{const c=this.looks[a+1];for(const l of i){if(!r.parts.some(d=>d.sourceId===l)){e(r.t,l),c?.parts.some(d=>d.sourceId===l)&&e(c.t-1,l);continue}const u=this.sighting.sampleMs??(this.path?Ps.TRAVEL_SAMPLE_MS:Ps.SAMPLE_MS);for(let d=r.t;d<r.until;d+=u)e(d,l);e(r.until-1,l)}});for(const r of this.blinks)for(const[a,c]of this.phases(r))for(const l of r.parts)e(a,l),e(c-1,l);if(this.vanishAt!==void 0)for(const r of i)e(this.vanishAt,r);const n=[...t.keys()].sort((r,a)=>r-a).map(r=>({t:r,shapes:[...t.get(r).values()]})),s=new Map;for(const r of n)for(const a of r.shapes){const c=a.shape.angle,l=s.get(a.sourceId);if(c===void 0)continue;const h=l===void 0?c:c+2*Math.PI*Math.round((l-c)/(2*Math.PI));a.shape.angle=Math.round(h*1e4)/1e4,s.set(a.sourceId,h)}return{keyframes:n,order:i,groups:[]}}phases(t){const e=[];let i=!0;for(let n=t.t;n<t.until;){const s=Math.min(n+(i?t.params.onS:t.params.offS)*1e3,t.until);e.push([n,s]),n=s,i=!i}return e}off(t,e){for(const i of this.blinks){if(e<i.t||e>=i.until||!i.parts.includes(t))continue;if(this.phases(i).findIndex(([s,r])=>e>=s&&e<r)%2===1)return i.params.off}}state(t,e){const i=[...this.looks].reverse().find(l=>l.t<=e)??this.looks[0],n=i?.parts.find(l=>l.sourceId===t),r=(n?i:this.looks.find(l=>l.t>e&&l.parts.some(h=>h.sourceId===t))??[...this.looks].reverse().find(l=>l.parts.some(h=>h.sourceId===t)))?.parts.find(l=>l.sourceId===t);if(!r)return;const a=!n||this.vanishAt!==void 0&&e>=this.vanishAt,c=a?void 0:this.off(t,e);return this.path?{sourceId:t,shape:this.onPath(r,e,c,a)}:{sourceId:t,shape:Ps.shape(r,this.geometry(e),c,a)}}onPath(t,e,i,n){const s=this.path,r=this.sighting.observerTrack.getInterpolatedPoseAt(e)??this.sighting.observerTrack.getLatestPoseAt(e),a=r?.headingDeg??0,c=r?.pitchDeg??0,l=this.motion,h=S=>Se.toScreen(s.at(S),a,c),u=(S,A)=>{const R=Math.hypot(A[0]-S[0],A[1]-S[1])||1;return[(A[0]-S[0])/R,(A[1]-S[1])/R]};let d=h(e),[f,p]=u(h(e-Ps.MOTION_MS),h(e+Ps.MOTION_MS));const g=s.sizeAt(e),m=Math.tan(l.sidewaysAt(e,g)*Math.PI/180);d=[d[0]-m*p,d[1]+m*f];const M=l.spiralAt(e);if(M){const S=l.spiralAt(e+Ps.SPIRAL_AHEAD_MS),A=h(e),R=h(e+Ps.SPIRAL_AHEAD_MS);d=[d[0]+M[0],d[1]+M[1]],[f,p]=u([A[0]+M[0],A[1]+M[1]],[R[0]+S[0],R[1]+S[1]])}const v=l.acrossShareAt(e),x={...t,heightShare:(t.heightShare??t.widthShare)*v,...t.upShare===void 0?{}:{upShare:t.upShare*v}},y=Math.tan(g*(x.alongShare??0)*Math.PI/180),w=Math.tan(g*(x.upShare??0)*Math.PI/180),b=Se.fromScreen(d[0]+y*f-w*p,d[1]+y*p+w*f,a,c),E=Ps.shape(x,{...b,sizeDeg:g},i,n,!0);return E.angle=Math.atan2(-p,f),E}geometry(t){const e=this.stand.params,i=this.sighting.observerTrack.getInterpolatedPoseAt(t)??this.sighting.observerTrack.getLatestPoseAt(t),n=i?.lat!==void 0&&i.lng!==void 0?{lat:i.lat,lng:i.lng}:this.sighting.event.place?.[0]??e.place;return Ps.seenFrom(e,n,t)}static seenFrom(t,e,i){const n=(t.place.lng-e.lng)*Math.PI/180*Ps.R*Math.cos(e.lat*Math.PI/180),s=(t.place.lat-e.lat)*Math.PI/180*Ps.R,r=Math.hypot(n,s),a=li.linear(t.metres.map(({t:l,widthM:h,step:u})=>({t:l,value:h,step:u})),i),c=li.linear(t.metres.map(({t:l,heightM:h,step:u})=>({t:l,value:h,step:u})),i);return{azimuthDeg:(Math.atan2(n,s)*180/Math.PI%360+360)%360,altitudeDeg:Math.atan2(c,r)*180/Math.PI,sizeDeg:2*Math.atan(a/(2*r))*180/Math.PI}}static shape(t,e,i,n,s=!1){const r=e.sizeDeg,a=Math.max(t.minWidthDeg??0,r*t.widthShare),c=t.kind==="oval"&&t.heightShare===void 0?a:Math.max(t.minHeightDeg??0,r*(t.heightShare??t.widthShare)),l=s?e.altitudeDeg:e.altitudeDeg+r*(t.upShare??0),h=s?e.azimuthDeg:e.azimuthDeg+r*(t.alongShare??0)/Math.cos(l*Math.PI/180),u=(p,g)=>Math.round(p*10**g)/10**g,d=t.kind==="polygon"?{kind:"polygon",bounds:{x:300,y:170,width:100,height:100*c/a},points:(t.points??[]).map(p=>({x:u(p.x*100,2),y:u(p.y*100*c/a,2)}))}:{kind:"oval",bounds:{x:320,y:180,width:2,height:2}};Object.assign(d,{color:i?.color??t.color,angle:0,transparency:n?1:i?.transparency??t.transparency??0,haloScale:t.halo??0,selected:!1,...t.blur===void 0?{}:{blur:t.blur},...t.title===void 0?{}:{title:t.title},angular:{widthDeg:u(a,4),heightDeg:u(c,4)},aim:{azimuthDeg:u((h%360+360)%360,3),altitudeDeg:u(l,3)}});const f=i&&"brightness"in i?i.brightness:t.brightness;return f!=null&&(d.brightness=n?0:f),d}}class Oe{static STANDING_EYE_M=1.6;static METERS_PER_DEGREE=111320;static expand(t){Oe.expandBodies(t),Oe.expandObserver(t),Oe.expandFlights(t),Oe.expandDecorLights(t),Oe.expandPhenomenon(t)}static expandDecorLights(t){for(const e of t.decor){if(!e.lights?.length||e.lights.some(s=>s.keyframes?.length))continue;const i=(t.events??[]).filter(s=>Nd.partOf(s.who,e.id)!==void 0);if(i.length===0)continue;const n=JSON.stringify(e.lights);e.lights=new Nd(e,i,Oe.endOf(t)).lights(),t.eventsExpansion??={decorTracks:{}},t.eventsExpansion.decorLights={...t.eventsExpansion.decorLights,[e.id]:{stated:n,expanded:JSON.stringify(e.lights)}}}}static writtenLights(t,e,i){const n=t.eventsExpansion?.decorLights?.[e];return n&&JSON.stringify(i)===n.expanded?JSON.parse(n.stated):i}static expandPhenomenon(t){if(t.timeline.allKeyframes.length>0)return;const e=Oe.stands(t);for(const i of e){const n=Ls.within(t,i.who),s=(t.events??[]).filter(a=>a.who!==void 0&&n.has(a.who)),r=new Ps(t,i,s,i.until??Oe.endOf(t)).timeline();for(const a of Zd.fromJSON(r).allKeyframes)t.timeline.addKeyframe(a.t,a.shapes)}e.length!==0&&(Sh.timeline(t.timeline),t.eventsExpansion??={decorTracks:{}},t.eventsExpansion.timelinePending=!0)}static stands(t){return(t.events??[]).filter(e=>(e.eventType==="stand"||e.eventType==="travel")&&Ls.isPhenomenon(t,e))}static shapesOf(t){const{groups:e,...i}=t.timeline.toJSON();return JSON.stringify(i)}static timelineWithoutShapes(t){const e=t.timeline.toJSON().groups??[];return e.length>0?{keyframes:[],groups:e}:{keyframes:[]}}static settle(t){t.eventsExpansion?.timelinePending&&(vn.toAngular(t),vn.toAim(t),t.eventsExpansion.timeline=Oe.shapesOf(t),t.eventsExpansion.timelinePending=!1)}static timelineIsExpanded(t){return t.eventsExpansion?.timeline!==void 0&&t.eventsExpansion.timeline===Oe.shapesOf(t)}static expandFlights(t){const e=t.observerTrack.allKeyframes[0]?.pose??t.event.place?.[0];if(e?.lat===void 0||e.lng===void 0)return;const i=Math.cos(e.lat*Math.PI/180);for(const n of t.events??[]){if(n.eventType!=="fly"||n.who===void 0)continue;const s=t.decor.find(g=>g.id===n.who);if(!s||s.track?.length)continue;const r=n.params,a=n.until??Oe.endOf(t),c=r.headingDeg*Math.PI/180,l=(r.from.lng-e.lng)*Math.PI/180*Oe.R*i,h=(r.from.lat-e.lat)*Math.PI/180*Oe.R,u=r.speeds.map(({t:g,kmh:m,step:M})=>({t:g,value:m/3.6,step:M})),d=r.heights.map(({t:g,altitudeM:m,step:M})=>({t:g,value:m,step:M})),f=g=>{const m=Math.sign(g-r.at.t)*Oe.FLY_STEP_MS;let M=0;for(let v=r.at.t;m!==0&&(m>0?v<g:v>g);v+=m){const x=m>0?Math.min(g,v+m):Math.max(g,v+m);M+=(li.linear(u,v)+li.linear(u,x))/2*(x-v)/1e3}return M},p=[];for(let g=n.t;g<=a;g+=li.SAMPLE_MS){const m=r.at.metresBefore-f(g);p.push({t:g,eastM:l-Math.sin(c)*m,northM:h-Math.cos(c)*m,altitudeM:li.linear(d,g),headingDeg:r.headingDeg})}s.track=p,s.eastM=p[0].eastM,s.northM=p[0].northM,s.headingDeg=r.headingDeg,t.eventsExpansion??={decorTracks:{}},t.eventsExpansion.decorTracks[s.id]=JSON.stringify(p)}}static R=63710088e-1;static FLY_STEP_MS=100;static expandObserver(t){const e=(t.events??[]).filter(g=>Ls.isObserver(t,g)),i=e.find(g=>g.eventType==="drive"),n=e.find(g=>g.eventType==="lookAhead");if(t.observerTrack.allKeyframes.length>0)return;if(!i){new Do(t,e).keyframes().length>0&&(Sh.observer(t.observerTrack),t.eventsExpansion={...t.eventsExpansion,observerTrack:JSON.stringify(t.observerTrack.toJSON()),decorTracks:t.eventsExpansion?.decorTracks??{}});return}if(!n)return;const s=i.until??Oe.endOf(t),r=i.params,a=new li(r,i.t,s),c=e.find(g=>g.eventType==="lean"),l=e.find(g=>g.eventType==="watch"),u=new ti(a,r.eye,n.params,c&&{t:c.t,params:c.params},l&&{t:l.t,params:l.params},g=>{const m=Oe.stands(t).find(v=>v.eventType==="stand");if(!m)return Oe.phenomenonPitchAt(t,g);const M=a.stateAt(g);return Ps.seenFrom(m.params,{lat:M.lat,lng:M.lng},g).altitudeDeg}).poses(i.t,s),d=u.map(g=>({t:g.t,pose:{lat:g.lat,lng:g.lng,elevationM:g.eye.y-Oe.STANDING_EYE_M,headingDeg:g.headingDeg,pitchDeg:g.pitchDeg,fovDeg:r.fovDeg??60}}));for(const g of d)t.observerTrack.addKeyframe(g.t,g.pose);Sh.observer(t.observerTrack);const f={observerTrack:JSON.stringify(t.observerTrack.toJSON()),decorTracks:{}},p=r.vehicle===void 0?void 0:t.decor.find(g=>g.id===r.vehicle);if(p&&!p.track?.length){const g=u[0],m=v=>Math.cos(v*Math.PI/180),M=u.map(v=>{const x=v.roadDeg*Math.PI/180,y=-v.eye.z,w=v.eye.x,b=(v.lng-g.lng)*Oe.METERS_PER_DEGREE*m(v.lat),E=(v.lat-g.lat)*Oe.METERS_PER_DEGREE;return{t:v.t,eastM:b-y*Math.sin(x)-w*Math.cos(x),northM:E-y*Math.cos(x)+w*Math.sin(x),altitudeM:0,headingDeg:v.roadDeg}});p.track=M,p.eastM=M[0].eastM,p.northM=M[0].northM,p.headingDeg=M[0].headingDeg,f.decorTracks[p.id]=JSON.stringify(M)}t.eventsExpansion={...t.eventsExpansion,...f}}static expandBodies(t){const e=t.interpretation?.bodies??[],i=n=>(t.events??[]).some(s=>s.who===n.id&&s.eventType==="ride");for(const n of[...e.filter(s=>!i(s)),...e.filter(i)]){const s=(t.events??[]).filter(h=>h.who===n.id||Yo.partOf(h.who,n.id)!==void 0);if(s.length===0)continue;const r=Math.min(...s.map(h=>h.t));if(n.track.some(h=>h.t>r))continue;const a=JSON.stringify(n.track),c=s.find(h=>h.eventType==="ride"),l=c&&e.find(h=>h.id===c.params.in);n.track=c?l?Yo.ride(n,c,l):n.track:new Yo(n,s,Oe.endOf(t),t.sampleMs).track(),t.eventsExpansion??={decorTracks:{}},t.eventsExpansion.bodies={...t.eventsExpansion.bodies,[n.id]:{stated:a,expanded:JSON.stringify(n.track)}}}}static writtenInterpretation(t,e){const i=t.eventsExpansion?.bodies;return!e||!i?e:{...e,bodies:e.bodies.map(n=>{const s=i[n.id];return s&&JSON.stringify(n.track)===s.expanded?{...n,track:JSON.parse(s.stated)}:n})}}static refresh(t){const e=t.observerTrack.allKeyframes.length===0||Oe.observerTrackIsExpanded(t),i=t.timeline.allKeyframes.length===0||Oe.timelineIsExpanded(t);Oe.again(t,e,i)}static reset(t){Oe.again(t,!0,Oe.stands(t).length>0)}static again(t,e,i){for(const s of t.interpretation?.bodies??[]){const r=t.eventsExpansion?.bodies?.[s.id];r&&JSON.stringify(s.track)===r.expanded&&(s.track=JSON.parse(r.stated))}for(const s of t.decor)s.lights&&(s.lights=Oe.writtenLights(t,s.id,s.lights));if(e){for(const s of Object.keys(t.eventsExpansion?.decorTracks??{})){const r=t.decor.find(a=>a.id===s);r&&delete r.track}t.observerTrack.clear()}const n=t.timeline.toJSON().groups??[];if(i){for(const s of[...t.timeline.sourceIds])t.timeline.removeSource(s);t.timeline.setGroups(n,!1)}t.eventsExpansion=void 0,Oe.expand(t),i&&t.timeline.pruneGroups(),i&&(vn.toBounds(t),vn.toPosition(t)),Oe.settle(t)}static bodiesAreExpanded(t){const e=t.eventsExpansion?.bodies??{};return(t.interpretation?.bodies??[]).every(i=>!e[i.id]||JSON.stringify(i.track)===e[i.id].expanded)}static observerTrackIsExpanded(t){return t.eventsExpansion?.observerTrack!==void 0&&t.eventsExpansion.observerTrack===JSON.stringify(t.observerTrack.toJSON())}static decorTrackIsExpanded(t,e,i){const n=t.eventsExpansion?.decorTracks[e];return n!==void 0&&n===JSON.stringify(i)}static phenomenonPitchAt(t,e){let i;for(const n of t.timeline.sourceIds){const s=t.timeline.getInterpolatedShapeAt(e,n),r=s?.aim?.altitudeDeg;if(!s||s.transparency>=1||r===void 0)continue;const a=(s.angular?.widthDeg??0)*(s.angular?.heightDeg??0);(!i||a>i.area)&&(i={area:a,altitude:r})}return i?.altitude??0}static endOf(t){return t.event.durationSeconds!==void 0?t.event.durationSeconds*1e3:Math.max(...(t.events??[]).map(e=>e.until??e.t))}}function Ob(o){return fr.restore(Nb(o),o.provenance)}function Nb(o,t=!1){return vn.toAngular(o),vn.toAim(o),{version:4,id:o.id,time:j0.write(o.event.time),endTime:j0.write(o.event.endTime),durationSeconds:o.event.durationSeconds,durationText:o.event.durationText,utcOffsetHours:o.event.utcOffsetHours,timeZone:o.event.timeZone,place:kb.write(o.event.place),observer:o.observer,account:o.account,sources:o.sources?.length?o.sources:void 0,sway:o.sway,vehicle:o.vehicle,description:o.event.description,image:o.event.image,summary:o.event.summary,summaryTime:o.event.summaryTime,tags:o.event.tags,timeline:!t&&Oe.timelineIsExpanded(o)?Oe.timelineWithoutShapes(o):o.timeline.toJSON(),observerTrack:!t&&Oe.observerTrackIsExpanded(o)?void 0:is.restatedObserverTrack(o),events:o.events?.length?o.events:void 0,weatherTrack:o.weatherTrack.toJSON(),soundTrack:o.soundTrack.toJSON(),weather:o.weather,decor:is.restatedDecor(o).map(e=>{if(!t&&e.lights&&(e={...e,lights:Oe.writtenLights(o,e.id,e.lights)}),t||!Oe.decorTrackIsExpanded(o,e.id,e.track))return e;const{track:i,...n}=e;return n}),milestones:o.milestones.length>0?o.milestones:void 0,references:o.references.length>0?o.references:void 0,roads:o.roads.length>0?o.roads:void 0,traces:o.traces.length>0?o.traces:void 0,weatherSource:o.weatherSource,instrument:o.instrumentId,exposureSeconds:o.exposureSeconds,iso:o.iso,film:o.film,metering:o.metering,sampleMs:o.sampleMs,lens:o.lens,lighting:o.lighting,lightPollution:o.lightPollution,around:Ro.says(o.around)?o.around:void 0,observerMap:o.observerMap,interpretation:t?is.restatedInterpretation(o):Oe.writtenInterpretation(o,is.restatedInterpretation(o)),variants:o.variants.length>0?o.variants:void 0,skyEvents:Zr.written(o.skyEvents),skySources:o.skySources===!1?!1:void 0,snapshots:o.snapshots,modules:o.modules?.length?o.modules:void 0}}function K_(o){return o.observer?.id??"observer"}function Lb(o){const t=la.check(o,"sighting"),{recording:e,provenance:i}=fr.strip(t),n=$_(e);return n.provenance=i,n}function $_(o){const t=[],e=new Bp({eventType:"sighting",time:j0.read(o.time),endTime:j0.read(o.endTime),durationSeconds:o.durationSeconds,durationText:o.durationText,utcOffsetHours:o.utcOffsetHours,timeZone:o.timeZone,place:kb.read(o.place),description:o.description,image:o.image,summary:o.summary,summaryTime:o.summaryTime,tags:o.tags},Zd.fromJSON(o.timeline,t,!1),o.observerTrack?ud.fromJSON(o.observerTrack):new ud,o.weatherTrack?dd.fromJSON(o.weatherTrack):new dd,o.soundTrack?fd.fromJSON(o.soundTrack):new fd,o.observer&&{id:o.observer.id,title:o.observer.title,lastName:o.observer.lastName,firstNames:o.observer.firstNames},o.id,o.weather,(o.decor??[]).map(n=>{if(!n.facade?.plain)return n;const{plain:s,...r}=n.facade;return{...n,facade:{...r,openings:"plain"}}}),o.weatherSource,o.instrument,o.exposureSeconds??o.observerTrack?.keyframes.map(n=>n.pose.exposureSeconds).find(n=>n!==void 0),Hu(o.milestones??[]),o.references??[],o.roads??[],o.traces??[]);e.account=o.account,e.sources=o.sources,e.sway=o.sway,e.iso=o.iso,e.film=o.film,e.metering=o.metering,e.sampleMs=o.sampleMs,e.lens=o.lens,e.lighting=o.lighting,e.lightPollution=o.lightPollution,e.around=Ro.read(o.around),e.observerMap=o.observerMap,e.vehicle=o.vehicle,e.events=o.events?.map(n=>n.who===void 0?{...n,who:K_(o)}:n);const i=Zr.read(o.skyEvents,o.interpretation);return e.interpretation=i.interpretation,e.variants=Array.isArray(o.variants)?o.variants:[],e.skyEvents=i.skyEvents,e.skySources=o.skySources===!1?!1:void 0,e.snapshots=o.snapshots,e.modules=Array.isArray(o.modules)?o.modules.filter(n=>typeof n=="string"):void 0,e.loadIssues=t,Oe.expand(e),e.timeline.pruneGroups(),vn.toBounds(e),vn.toPosition(e),Oe.settle(e),e}class j0{static read(t){return t===void 0||t.trim()===""?void 0:P_(t)}static write(t){if(t===void 0)return;const e=O_(t);return e===""?void 0:e}}class kb{static read(t){if(t?.locations?.length)return t.locations.map(({lat:e,lng:i})=>({lat:e,lng:i,...t.name===void 0?{}:{name:t.name}}))}static write(t){if(!t?.length)return;const e=t.find(i=>i.name)?.name;return{...e===void 0?{}:{name:e},locations:t.map(({lat:i,lng:n})=>({lat:i,lng:n}))}}}const q_=Object.freeze(Object.defineProperty({__proto__:null,fromSightingJson:Lb,plainSightingJson:Nb,toSightingJson:Ob},Symbol.toStringTag,{value:"Module"}));class Ld{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}","out-of-range":"{path}: {found} is outside {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=Ld.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=>` ${Ld.text(n)}`);console.warn(`UFO@home: ${t.length} problem(s) in ${e??"this recording"}:
|
|
1933
1933
|
${i.join(`
|
|
1934
1934
|
`)}`)}}class lr{constructor(t){this.format=t}issues(t){const e=[];return this.object(t,this.format,"",e),e}object(t,e,i,n){if(!lr.isObject(t)){n.push({kind:"wrong-type",path:i||"(the file)",expected:"object",found:lr.typeOf(t)});return}for(const[s,r]of Object.entries(t)){const a=i?`${i}.${s}`:s,c=e[s];c?this.field(r,c,a,n):n.push({kind:"unknown-key",path:a})}}field(t,e,i,n){if(lr.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):lr.isObject(t)||n.push({kind:"wrong-type",path:i,expected:"object",found:lr.typeOf(t)});return;case"array":Array.isArray(t)?e.fields&&t.forEach((s,r)=>{const a=lr.isStated(s)?s.value:s;this.object(a,e.fields,`${i}.${r}`,n)}):n.push({kind:"wrong-type",path:i,expected:"array",found:lr.typeOf(t)});return;default:typeof t!==e.type?n.push({kind:"wrong-type",path:i,expected:e.type,found:lr.typeOf(t)}):typeof t=="number"&&(e.minimum!==void 0&&t<e.minimum||e.maximum!==void 0&&t>e.maximum)&&n.push({kind:"out-of-range",path:i,expected:`${e.minimum??"−∞"}–${e.maximum??"∞"}`,found:String(t)})}}static STATED_KEYS=new Set(["value","basis","rationale","how","range","source"]);static isObject(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}static isStated(t){return lr.isObject(t)&&"value"in t&&Object.keys(t).every(e=>lr.STATED_KEYS.has(e))}static typeOf(t){return Array.isArray(t)?"array":t===null?"null":typeof t}}class ns{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 r=s>0?ns.travelDegOver(t,e,i,i+n*1e3)/s/ns.PIXELS_PER_INSTANT:0,a=ns.flashesOver(t,n)*ns.INSTANTS_PER_FLASH,c=Math.ceil(Math.max(r,a));return c<2?1:Math.min(ns.MAX_INSTANTS,c)}static travelDegOver(t,e,i,n){let s=0;for(const r of t){if(!r.track||r.track.length<2)continue;const a=ns.directionAt(r,e,i),c=ns.directionAt(r,e,n),l=Math.min(1,Math.max(-1,a.x*c.x+a.y*c.y+a.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=ga(t,i),s=n.eastM,r=n.altitudeM-e,a=n.northM,c=Math.hypot(s,r,a);return c===0?{x:0,y:1,z:0}:{x:s/c,y:r/c,z:a/c}}static bodyInstants(t,e,i,n,s){if(!(n>i)||!(s>0))return 1;let r=0;for(const c of t){const l=ns.bodyAt(c,i),h=ns.bodyAt(c,n);if(!l||!h)continue;const u={x:l.eastM,y:l.upM-e,z:l.northM},d={x:h.eastM,y:h.upM-e,z:h.northM},f=Math.hypot(u.x,u.y,u.z),p=Math.hypot(d.x,d.y,d.z);if(f===0||p===0)continue;const g=Math.min(1,Math.max(-1,(u.x*d.x+u.y*d.y+u.z*d.z)/f/p));let m=Math.acos(g)*180/Math.PI,M=0;for(const v of Object.keys(h.motions))M=Math.max(M,Math.abs(h.motions[v]-(l.motions[v]??h.motions[v])));M>0&&(m+=M*2*(h.halfWidthM/Math.max(p,.001))*180/Math.PI),r=Math.max(r,m)}const a=Math.ceil(r/s/ns.PIXELS_PER_INSTANT);return a<2?1:Math.min(ns.MAX_INSTANTS,a)}static bodyAt(t,e){const i=t.track;if(i.length===0||e<i[0].t||e>i[i.length-1].t)return;let n=0,s=i.length-1;for(;s-n>1;){const d=n+s>>1;i[d].t<=e?n=d:s=d}const r=i[n],a=i[s];if(r.eastM===void 0||r.northM===void 0||a.eastM===void 0||a.northM===void 0)return;const c=a.t>r.t?(e-r.t)/(a.t-r.t):0,l=(d,f)=>d+(f-d)*c,h={};for(const d of Object.keys(a.motions??{})){const f=r.motions?.[d],p=a.motions[d];h[d]=f===void 0?p:l(f,p)}const u=i.find(d=>d.sizeM)?.sizeM?.widthM??1;return{eastM:l(r.eastM,a.eastM),northM:l(r.northM,a.northM),upM:l(r.altitudeM??0,a.altitudeM??0),halfWidthM:u/2,motions:h}}}function I0(o,t){for(const e of o){const i=e.toLowerCase().split("-")[0];if(t.includes(i))return i}return"en"}class Lo{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}}}Nt.register(Fn,()=>new Cc);Nt.register(Fh,()=>new xh);Nt.register(Or,()=>new av);Nt.register(Uh,()=>new wh);Nt.register(pd,()=>new ov);Nt.register(zh,()=>new yd);Nt.register(kh,()=>new vd);Nt.register(Bh,()=>new xd);Nt.register(tc,()=>new Hh);Nt.register(Lh,()=>new Md);Nt.register(Us,()=>new zi);Nt.register(Go,()=>new bd);Nt.register(Mn,()=>new Pc);Nt.register(Vo,()=>new Ed);Nt.register(md,()=>new cv);Nt.register(Wo,()=>new Ad);Nt.register(Ho,()=>new Sd);Nt.register(Xo,()=>new _d);Nt.register(qc,()=>new Td);Nt.register(Bo,()=>new wd);Nt.register(Ss,()=>new je);Nt.register(qa,()=>new Id);Nt.register(mn,()=>new ie);Nt.register(Za,()=>new Cd);Nt.register(gd,()=>new zp);Nt.register(Ja,()=>new Od);Nt.register($a,()=>new Dd);Nt.register(ja,()=>new Pd);Nt.register(Z0,()=>new T_);Nt.register(Ka,()=>new Rd);class Cr{constructor(t){this.preferences=t}read(t){var e,i;if(t===void 0)return;if(typeof t=="string")return t===""?void 0:t;for(const s of this.preferences){const r=(e=t[s])!==null&&e!==void 0?e:t[Cr.base(s)];if(r)return r}const n=new Set(this.preferences.map(s=>Cr.base(s)));for(const[s,r]of Object.entries(t))if(r&&n.has(Cr.base(s)))return r;return(i=Object.values(t).find(s=>s))!==null&&i!==void 0?i:void 0}write(t,e,i){var n,s;const r=e?.trim()?e.trim():void 0;if(t===void 0||typeof t=="string")return r;const a={...t},c=(s=(n=Object.keys(a).find(l=>l===i))!==null&&n!==void 0?n:Object.keys(a).find(l=>Cr.base(l)===Cr.base(i)))!==null&&s!==void 0?s:i;return r===void 0?delete a[c]:a[c]=r,Object.keys(a).length===0?void 0:a}static base(t){return t.toLowerCase().split("-")[0]}}Cr.any=new Cr([]);var O2;(function(o){o.abductee="abductee",o.actor="actor",o.artist="artist",o.anthropologist="anthropologist",o.archeologist="archeologist",o.astronaut="astronaut",o.astronomer="astronomer",o.astrologist="astrologist",o.astrophysicist="astrophysicist",o.banker="banker",o.barman="barman",o.biologist="biologist",o.biochemist="biochemist",o.biophysicist="biophysicist",o.bishop="bishop",o.businessman="businessman",o.botanist="botanist",o.cameraman="cameraman",o.chemist="chemist",o.contactee="contactee",o.cryptozoologist="cryptozoologist",o.dentist="dentist",o.director="director",o.diplomat="diplomat",o.diver="diver",o.electronics="electronics",o.engineer="engineer",o.ethnologist="ethnologist",o.exobiologist="exobiologist",o.farmer="farmer",o.firefighter="firefighter",o.flightAttendant="flightAttendant",o.geologist="geologist",o.geophysicist="geophysicist",o.geographer="geographer",o.historian="historian",o.houseWife="houseWife",o.hypnotherapist="hypnotherapist",o.illusionist="illusionist",o.journalist="journalist",o.judge="judge",o.lawyer="lawyer",o.leader="leader",o.librarian="librarian",o.logger="logger",o.mathematician="mathematician",o.mechanic="mechanic",o.meteorologist="meteorologist",o.military="military",o.musician="musician",o.neurologist="neurologist",o.neuroscientist="neuroscientist",o.neuropsychiatrist="neuropsychiatrist",o.nurse="nurse",o.oceanographer="oceanographer",o.painter="painter",o.parapsychologist="parapsychologist",o.philosopher="philosopher",o.photographer="photographer",o.physician="physician",o.physicist="physicist",o.pilot="pilot",o.politician="politician",o.policeman="policeman",o.priest="priest",o.producer="producer",o.prospector="prospector",o.psychologist="psychologist",o.psychiatrist="psychiatrist",o.radioastronomer="radioastronomer",o.radioamateur="radioamateur",o.salesman="salesman",o.sailor="sailor",o.sociologist="sociologist",o.softwareEngineer="softwareEngineer",o.stuntman="stuntman",o.taxiDriver="taxiDriver",o.teacher="teacher",o.telegrapher="telegrapher",o.truckDriver="truckDriver",o.ufologist="ufologist",o.ufoWitness="ufoWitness",o.ufoWitness2="ufoWitness2",o.worker="worker",o.writer="writer"})(O2||(O2={}));var N2;(function(o){o.neutral="neutral",o.male="male",o.female="female"})(N2||(N2={}));class Z_ extends Error{constructor(t,e){super(t),this.cause=e}}class hv extends Z_{constructor(t=hv.defaultMessage,e){super(t,e)}}hv.defaultMessage="Assertion failed";var L2;(function(o){o.country="country",o.region="region",o.department="department",o.city="city",o.company="company"})(L2||(L2={}));var k2;(function(o){o.at="at",o.au="au",o.ar="ar",o.be="be",o.br="br",o.ca="ca",o.ch="ch",o.cn="cn",o.cl="cl",o.co="co",o.cy="cy",o.de="de",o.dk="dk",o.do="do",o.dz="dz",o.gr="gr",o.ec="ec",o.eg="eg",o.es="es",o.fi="fi",o.fr="fr",o.ga="ga",o.ge="ge",o.hu="hu",o.in="in",o.ie="ie",o.ir="ir",o.il="il",o.it="it",o.jp="jp",o.kr="kr",o.ma="ma",o.mx="mx",o.my="my",o.mz="mz",o.nl="nl",o.no="no",o.nz="nz",o.pa="pa",o.pe="pe",o.ph="ph",o.pl="pl",o.pt="pt",o.ro="ro",o.ru="ru",o.sc="sc",o.tr="tr",o.ua="ua",o.uk="uk",o.us="us",o.sa="sa",o.se="se",o.su="su",o.tn="tn",o.tw="tw",o.ve="ve",o.za="za"})(k2||(k2={}));const J_=["en","fr","es","it"];class Gs{static catalog(t){const e=new Map;return{load(i){const n=Gs.languageOf(i);let s=e.get(n);return s||(s=t[n](),e.set(n,s),s.catch(()=>e.delete(n))),s}}}static none(){return new Proxy({},{get:()=>""})}static blank(){const t=new Proxy(()=>t,{get:(e,i)=>i===Symbol.toPrimitive?()=>"":i===Symbol.iterator?function*(){}:i==="toString"||i==="valueOf"?()=>"":i==="then"?void 0:t,apply:()=>t,has:()=>!1,ownKeys:()=>[],getOwnPropertyDescriptor:()=>{}});return t}static languageOf(t){const e=t.toLowerCase().split("-")[0];return J_.includes(e)?e:"en"}}const C0=["en","fr","es","it"],j_={en:()=>dt(()=>import("./UfoMessages_en-A8Ku1B0Y.js"),[],import.meta.url).then(o=>o.ufoMessages_en),fr:()=>dt(()=>import("./UfoMessages_fr-CGkQBn5r.js"),[],import.meta.url).then(o=>o.ufoMessages_fr),es:()=>dt(()=>import("./UfoMessages_es-CO-v8Jl6.js"),[],import.meta.url).then(o=>o.ufoMessages_es),it:()=>dt(()=>import("./UfoMessages_it-BScqxIaH.js"),[],import.meta.url).then(o=>o.ufoMessages_it)},Q_=Gs.catalog(j_),t5=Gs.catalog({en:()=>dt(()=>import("./SceneNames_en-Dn90NisJ.js"),[],import.meta.url).then(o=>o.sceneNames_en),fr:()=>dt(()=>import("./SceneNames_fr-rltu5c_j.js"),[],import.meta.url).then(o=>o.sceneNames_fr),es:()=>dt(()=>import("./SceneNames_es-DH6GZWja.js"),[],import.meta.url).then(o=>o.sceneNames_es),it:()=>dt(()=>import("./SceneNames_it-DsNshdIp.js"),[],import.meta.url).then(o=>o.sceneNames_it)});function e5(o){return t5.load(o)}const Fb=Math.PI/180,i5=180/Math.PI,n5=256,Ub=19,s5=1.25;function zb(o,t){return 156543.03392*Math.cos(o*Fb)/2**t}function Bb(o,t){return zb(o,t)*n5}function r5(o,t){let e=0;for(;e<Ub&&Bb(o,e+1)>=t;)e++;return e}function uv(o,t){return Bb(o,t)}function Hb(o,t){const e=t*s5;let i=0;for(;i<Ub&&zb(o,i)>e;)i++;return i}function P0(o){const t=o*Fb;return(1-Math.log(Math.tan(t)+1/Math.cos(t))/Math.PI)/2}function Gb(o,t,e){const i=2**e;return{x:(o+180)/360*i,y:P0(t)*i}}function Vb(o,t,e){const i=P0(o.north),n=P0(o.south);return{x:(t-o.west)/(o.east-o.west),y:(P0(e)-i)/(n-i)}}function a5(o,t,e){const{x:i,y:n}=Gb(o,t,e);return{x:Math.floor(i),y:Math.floor(n),z:e}}function o5(o){const t=2**o.z,e=o.x/t*360-180,i=(o.x+1)/t*360-180,n=F2(o.y,t);return{south:F2(o.y+1,t),north:n,west:e,east:i}}function F2(o,t){const e=o/t;return Math.atan(Math.sinh(Math.PI*(1-2*e)))*i5}function Wb(o,t,e,i){const n=a5(o,t,e),s=Math.floor(i/2),r=[];for(let l=-s;l<=s;l++)for(let h=-s;h<=s;h++)r.push({x:n.x+h,y:n.y+l,z:e});const a=r.map(o5),c={south:Math.min(...a.map(l=>l.south)),north:Math.max(...a.map(l=>l.north)),west:Math.min(...a.map(l=>l.west)),east:Math.max(...a.map(l=>l.east))};return{tiles:r,bounds:c}}const c5="#2ec4ff";class Ec{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 r=Math.hypot(s.x-t,s.y-e);r>s.radius||r>n||(i=s,n=r)}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),this.paintTraces(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=Vb(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()}paintTraces(t){const{ctx:e}=this;for(const i of t.traces??[]){const n=i.points.map(r=>this.toCanvas(t.bounds,r.lat,r.lng));if(n.length===0)continue;const s=i.color??c5;if(i.kind==="point")e.beginPath(),e.moveTo(n[0].x,n[0].y-6),e.lineTo(n[0].x+6,n[0].y),e.lineTo(n[0].x,n[0].y+6),e.lineTo(n[0].x-6,n[0].y),e.closePath(),e.fillStyle=s,e.fill(),e.lineWidth=1.5,e.strokeStyle="rgba(0, 0, 0, 0.8)",e.stroke();else{e.beginPath(),e.moveTo(n[0].x,n[0].y);for(const r of n.slice(1))e.lineTo(r.x,r.y);i.kind==="polygon"&&e.closePath(),e.lineJoin="round",e.setLineDash([]),e.strokeStyle="rgba(0, 0, 0, 0.65)",e.lineWidth=4.5,e.stroke(),e.setLineDash([9,5]),e.strokeStyle=s,e.lineWidth=2.5,e.stroke(),e.setLineDash([])}if(i.label){e.font="11px sans-serif",e.textAlign="left",e.textBaseline="middle";let r=n[0];if(i.kind==="line"&&t.position){const a=this.toCanvas(t.bounds,t.position.lat,t.position.lng);r=n.reduce((c,l)=>Math.hypot(l.x-a.x,l.y-a.y)>Math.hypot(c.x-a.x,c.y-a.y)?l:c)}this.paintOutlinedText(i.label,r.x+9,r.y-9)}}}paintCone(t,e){const{headingDeg:i,coneHalfAngleDeg:n}=t;if(i===void 0||n===void 0)return;const{ctx:s}=this,r=this.toCanvas(t.bounds,e.lat,e.lng),a=Math.hypot(this.width,this.height),c=(i-90)*Math.PI/180,l=n*Math.PI/180;s.save(),s.beginPath(),s.moveTo(r.x,r.y),s.arc(r.x,r.y,a,c-l,c+l),s.closePath();const h=s.createRadialGradient(r.x,r.y,0,r.x,r.y,a);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:Ec.MARKER_RADIUS_PX}),e.beginPath(),e.arc(n.x,n.y,Ec.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(r=>{if(!r.current)return!1;const a=ae(r.lat,r.lng,e.lat,e.lng);return Math.hypot(a.x,a.z)<=Ec.ON_MARKER_M});i.beginPath(),i.arc(n.x,n.y,s?Ec.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 r=(t.south+t.north)/2,c=Math.abs(ae(r,t.east,r,t.west).x)/this.width,l=Ec.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 r=n?`${n} ${s}`:s;n&&this.ctx.measureText(r).width>e?(i.push(n),n=s):n=r}return n&&i.push(n),i}}class gi{static MIN_ZOOM=.25;static MAX_ZOOM=64;static MIN_SPAN_M=400;static MARGIN=.6;static IMAGERY_PX=768;static fitted(t,e){return gi.including(t.boundsAround(gi.MIN_SPAN_M,gi.MARGIN),e)}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(gi.MAX_ZOOM,Math.max(gi.MIN_ZOOM,this.zoom*i)),s=this.centerX+(t-.5)/this.zoom,r=this.centerY+(e-.5)/this.zoom;this.centerX=s-(t-.5)/n,this.centerY=r-(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=gi.mercatorY01(e.north),s=gi.mercatorY01(e.south),r=gi.mercatorY01(i.north),a=gi.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=((r+a)/2-n)/(s-n)}keepInView(t,e,i){if(!this.changed)return!1;const n=this.boundsWithin(t),s=gi.mercatorY01(n.north),r=gi.mercatorY01(n.south),a=(e.lng-n.west)/(n.east-n.west),c=(gi.mercatorY01(e.lat)-s)/(r-s);return a>=i&&a<=1-i&&c>=i&&c<=1-i?!1:(this.panBy(.5-a,.5-c),!0)}boundsWithin(t){if(!this.changed)return t;const e=.5/this.zoom,i=gi.mercatorY01(t.north),n=gi.mercatorY01(t.south),s=t.east-t.west;return{west:t.west+(this.centerX-e)*s,east:t.west+(this.centerX+e)*s,north:gi.latitudeAt(i+(this.centerY-e)*(n-i)),south:gi.latitudeAt(i+(this.centerY+e)*(n-i))}}static including(t,e,i=3){const n=(t.north+t.south)/2,s=(t.east+t.west)/2,r=ae(n,t.east,n,s).x;let a=r;for(const c of e){const{x:l,z:h}=ae(c.lat,c.lng,n,s),u=Math.max(Math.abs(l),Math.abs(h));u<=r*i&&(a=Math.max(a,u*1.15))}return a<=r?t:{north:zs(0,-a,n,s).lat,south:zs(0,a,n,s).lat,east:zs(a,0,n,s).lng,west:zs(-a,0,n,s).lng}}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=gi.mercatorY01(t.north),s=gi.mercatorY01(t.south);return{lat:gi.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 rr=256,l5=3,h5=129,u5=7,d5=32768;class Xb{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(ae(i,t.east,i,t.west).x),r=Math.abs(ae(t.north,n,t.south,n).z),a=Math.max(s,r);let c=r5(i,a),l=l5;if(e.width>=h5){const g=M=>2*Math.ceil((a/uv(i,M)+1)/2)+1;let m=Hb(i,a/(e.width-1)/2);for(;m>c&&g(m)>u5;)m--;m>c&&(c=m,l=g(m))}const{tiles:h}=Wb(n,i,c,l),u=l*rr,d=new Float32Array(u*u),f=h[0];await Promise.all(h.map(g=>this.decodeTileInto(g,f,d,u)));const p=new Float32Array(e.width*e.height);for(let g=0;g<e.height;g++){const m=t.north+(t.south-t.north)*(g/(e.height-1));for(let M=0;M<e.width;M++){const v=t.west+(t.east-t.west)*(M/(e.width-1));p[g*e.width+M]=this.sampleAt(m,v,c,f,d,u)}}return{heights:p,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)),r=await this.fetchImpl(s);if(!r.ok)throw new Error(`Elevation tile fetch failed (${r.status}): ${s}`);const a=await createImageBitmap(await r.blob()),c=document.createElement("canvas");c.width=rr,c.height=rr;const l=c.getContext("2d");if(!l)throw new Error("2D canvas context unavailable");l.drawImage(a,0,0);const{data:h}=l.getImageData(0,0,rr,rr),u=(t.x-e.x)*rr,d=(t.y-e.y)*rr;for(let f=0;f<rr;f++)for(let p=0;p<rr;p++){const g=(f*rr+p)*4,m=h[g]*256+h[g+1]+h[g+2]/256-d5,M=u+p,v=d+f;i[v*n+M]=m}}sampleAt(t,e,i,n,s,r){const{x:a,y:c}=Gb(e,t,i),l=(a-n.x)*rr,h=(c-n.y)*rr,u=Math.max(0,Math.min(r-1,Math.floor(l))),d=Math.max(0,Math.min(r-1,Math.floor(h))),f=Math.min(r-1,u+1),p=Math.min(r-1,d+1),g=l-u,m=h-d,M=s[d*r+u],v=s[d*r+f],x=s[p*r+u],y=s[p*r+f],w=M+(v-M)*g,b=x+(y-x)*g;return w+(b-w)*m}}class Hp{constructor(t,e,i,n){this.width=t,this.height=e,this.samples=i,this.values=n}at(t,e,i=0){return this.values[(e*this.width+t)*this.samples+i]}static parse(t){const e=new DataView(t);if(t.byteLength<8||e.getUint16(0)!==18761||e.getUint16(2,!0)!==42)throw new Error("Not a little-endian TIFF");const i=e.getUint32(4,!0),n=e.getUint16(i,!0),s=new Map;for(let M=0;M<n;M++){const v=i+2+M*12;s.set(e.getUint16(v,!0),{type:e.getUint16(v+2,!0),count:e.getUint32(v+4,!0),value:e.getUint32(v+8,!0)})}const r=(M,v)=>{const x=s.get(M);if(x===void 0){if(v===void 0)throw new Error(`TIFF without tag ${M}`);return v}return x.type===3?x.value&65535:x.value},a=M=>{const v=s.get(M);if(v===void 0)throw new Error(`TIFF without tag ${M}`);const x=v.type===3?2:4,y=[];if(v.count*x<=4){const w=new DataView(new ArrayBuffer(4));w.setUint32(0,v.value,!0);for(let b=0;b<v.count;b++)y.push(x===2?w.getUint16(b*2,!0):w.getUint32(0,!0))}else for(let w=0;w<v.count;w++)y.push(x===2?e.getUint16(v.value+w*2,!0):e.getUint32(v.value+w*4,!0));return y};if(r(259,1)!==1)throw new Error("Compressed TIFF");if(s.has(322))throw new Error("Tiled TIFF");const c=r(256),l=r(257),h=r(277,1),u=a(258)[0],d=r(339,1)===3;if(!(d&&u===32||!d&&u===8))throw new Error(`Unsupported TIFF samples: ${u} bits`);const f=a(273),p=a(279),g=new Uint8Array(c*l*h*(u/8));let m=0;for(let M=0;M<f.length&&m<g.length;M++){const v=Math.min(p[M],g.length-m);g.set(new Uint8Array(t,f[M],v),m),m+=v}if(m<g.length)throw new Error("Truncated TIFF");return new Hp(c,l,h,d?new Float32Array(g.buffer):g)}}class fo extends Error{constructor(t,e){super(e),this.reason=t,this.name="SurroundingsUnavailableError"}}class f5{constructor(t,e,i,n,s){this.heights=t,this.plants=e,this.buildings=i,this.size=n,this.metresPerPixel=s}structureAt(t,e){const i=Math.floor(t/this.metresPerPixel+this.size/2),n=Math.floor(this.size/2-e/this.metresPerPixel);if(i<0||n<0||i>=this.size||n>=this.size)return;const s=n*this.size+i;if(!(this.plants[s]||this.buildings[s]))return this.heights[s]}tallestStructureNear(t,e,i){let n;const s=Math.ceil(i/this.metresPerPixel);for(let r=-s;r<=s;r++)for(let a=-s;a<=s;a++){if(Math.hypot(a,r)*this.metresPerPixel>i)continue;const c=this.structureAt(t+a*this.metresPerPixel,e+r*this.metresPerPixel);c!==void 0&&(n===void 0||c>n)&&(n=c)}return n}}class Fe{static covers(t,e){return t>=41.2&&t<=51.3&&e>=-5.4&&e<=9.8}static WMS="https://data.geopf.fr/wms-r/wms";static WFS="https://data.geopf.fr/wfs/ows";static HEIGHT_LAYER="IGNF_LIDAR-HD_MNH_ELEVATION.ELEVATIONGRIDCOVERAGE.LAMB93";static CLASS_LAYER="IGNF_LIDAR-HD_CLASS";static PHOTO_LAYER="ORTHOIMAGERY.ORTHOPHOTOS";static MAX_PHOTO_PIXELS=1e3;static METRES_PER_PIXEL=.5;static MAX_RADIUS_M=3e3;static MAX_LIDAR_RADIUS_M=150;static NO_DATA=-9999;static METRES_PER_DEGREE=111320;fetchImpl;wms;wfs;constructor(t={}){this.fetchImpl=t.fetchImpl??fetch.bind(globalThis),this.wms=t.wmsEndpoint??Fe.WMS,this.wfs=t.wfsEndpoint??Fe.WFS}static radius(t){return Math.min(t,Fe.MAX_RADIUS_M)}static lidarRadius(t){return Math.min(t,Fe.MAX_LIDAR_RADIUS_M)}async lidar(t,e){const i=Fe.lidarRadius(e),n=Math.ceil(2*i/Fe.METRES_PER_PIXEL),[s,r]=await Promise.all([this.raster(t,i,n,Fe.HEIGHT_LAYER),this.raster(t,i,n,Fe.CLASS_LAYER)]);if(s.samples!==1||r.samples<3)throw new fo("unreachable","The survey answered in a layout this does not read");const a=s.values;if(a.every(u=>u===Fe.NO_DATA))throw new fo("no-coverage","No LiDAR HD survey here yet");const c=new Uint8Array(n*n),l=new Uint8Array(n*n);for(let u=0;u<n*n;u++){const d=r.values[u*r.samples],f=r.values[u*r.samples+1],p=r.values[u*r.samples+2];c[u]=f>d&&f>p?1:0,l[u]=d>120&&f<90&&p<90?1:0}const h=2*i/n;return{size:n,metresPerPixel:h,heights:a,vegetation:c,building:l,structures:new f5(a,c,l,n,h)}}async laserDate(t){return Fe.latest(await this.dated("IGNF_LIDAR-HD_METADONNEE:metadata","geom","date_fin_acquisition",t))}async photoDate(t){return Fe.latest(await this.dated("ORTHOIMAGERY.ORTHOPHOTOS.GRAPHE-MOSAIQUAGE:graphe_bdortho","geom","date_vol",t))}static latest(t){return t.map(i=>/^\d{4}-\d{2}-\d{2}/.exec(String(i??""))?.[0]).filter(i=>i!==void 0).sort().at(-1)}async dated(t,e,i,n){const r=[n.lng-1e-4,n.lat-1e-4,n.lng+1e-4,n.lat+1e-4].map(a=>a.toFixed(6)).join(",");try{return(await this.features(t,`BBOX(${e},${r},'EPSG:4326')`,i,20)).map(a=>a.properties[i])}catch{return[]}}async photo(t,e){const i=Fe.radius(e),n=Math.min(Fe.MAX_PHOTO_PIXELS,Math.ceil(2*i/Fe.METRES_PER_PIXEL)),s=await this.raster(t,i,n,Fe.PHOTO_LAYER);if(s.samples<3)throw new fo("unreachable","The photograph came in a layout this does not read");return{size:n,metresPerPixel:2*i/n,samples:s.samples,values:s.values}}async vectors(t,e,i){const n=Fe.radius(e),s=n/Fe.METRES_PER_DEGREE,r=n/(Fe.METRES_PER_DEGREE*Math.cos(t.lat*Math.PI/180)),c=`BBOX(geometrie,${[t.lng-r,t.lat-s,t.lng+r,t.lat+s].map(M=>M.toFixed(6)).join(",")},'EPSG:4326')`,[l,h,u,d,f,p]=await Promise.all([this.features("construction_lineaire",`${c} AND nature='Pont'`,"nature,geometrie"),this.features("troncon_de_route",`${c} AND position_par_rapport_au_sol>'0'`,"nature,largeur_de_chaussee,position_par_rapport_au_sol,nom_voie_ban_gauche,nom_voie_ban_droite,cpx_toponyme_route_nommee,geometrie"),this.features("troncon_de_voie_ferree",`${c} AND position_par_rapport_au_sol>'0'`,"position_par_rapport_au_sol,geometrie").catch(()=>[]),this.features("ligne_electrique",c,"voltage,geometrie"),i?this.features("batiment",c,Fe.BUILDING_PROPERTIES,5e3):Promise.resolve([]),i?this.features("zone_d_activite_ou_d_interet",c,"toponyme,categorie,geometrie",100).catch(()=>[]):Promise.resolve([])]),g=i?await this.wholeWorship(p,f,[t.lng-r,t.lat-s,t.lng+r,t.lat+s]):[],m=[...f,...g];return{bridges:l,elevatedRoads:h,elevatedRailways:u,lines:d,buildings:m,zones:p,mapDate:Fe.latest(m.map(M=>M.properties.date_modification))}}static BUILDING_PROPERTIES="cleabs,nature,usage_1,hauteur,nombre_d_etages,materiaux_des_murs,materiaux_de_la_toiture,date_d_apparition,date_modification,geometrie";static MAX_WHOLE_M=300;async wholeWorship(t,e,i){const[n,s,r,a]=i,c=Fe.MAX_WHOLE_M/Fe.METRES_PER_DEGREE;let l;for(const u of t){if(u.properties.categorie!=="Religieux")continue;const[d,f,p,g]=Fe.extent(u);if(d>=n&&f>=s&&p<=r&&g<=a)continue;const m=[Math.max(d,n-c),Math.max(f,s-c),Math.min(p,r+c),Math.min(g,a+c)];l=l?[Math.min(l[0],m[0]),Math.min(l[1],m[1]),Math.max(l[2],m[2]),Math.max(l[3],m[3])]:m}if(!l)return[];const h=new Set(e.map(u=>u.properties.cleabs));try{return(await this.features("batiment",`BBOX(geometrie,${l.map(d=>d.toFixed(6)).join(",")},'EPSG:4326')`,Fe.BUILDING_PROPERTIES,1e3)).filter(d=>!h.has(d.properties.cleabs))}catch{return[]}}static extent(t){let e=1/0,i=1/0,n=-1/0,s=-1/0;const r=a=>{Array.isArray(a)&&typeof a[0]=="number"?(e=Math.min(e,a[0]),n=Math.max(n,a[0]),i=Math.min(i,a[1]),s=Math.max(s,a[1])):Array.isArray(a)&&a.forEach(r)};return r(t.geometry.coordinates),[e,i,n,s]}async elevatedRoadLines(t){const e=`BBOX(geometrie,${[t.west,t.south,t.east,t.north].map(s=>s.toFixed(6)).join(",")},'EPSG:4326')`,i=await this.features("troncon_de_route",`${e} AND position_par_rapport_au_sol>'0'`,"geometrie",300),n=[];for(const s of i){const{type:r,coordinates:a}=s.geometry,c=r==="LineString"?[a]:r==="MultiLineString"?a:[];for(const l of c)n.push(l.map(h=>({lat:h[1],lng:h[0]})))}return n}async waterSurfaces(t){const e=`BBOX(geometrie,${[t.west,t.south,t.east,t.north].map(i=>i.toFixed(6)).join(",")},'EPSG:4326')`;return this.features("surface_hydrographique",`${e} AND position_par_rapport_au_sol='0' AND persistance='Permanent'`,"cleabs,nature,geometrie",500)}async roads(t){const e=`BBOX(geometrie,${[t.west,t.south,t.east,t.north].map(i=>i.toFixed(6)).join(",")},'EPSG:4326')`;return this.features("troncon_de_route",`${e} AND nature<>'Sentier' AND nature<>'Escalier' AND position_par_rapport_au_sol>='0'`,"cleabs,nature,largeur_de_chaussee,nombre_de_voies,sens_de_circulation,vitesse_moyenne_vl,urbain,nom_voie_ban_gauche,nom_voie_ban_droite,cpx_toponyme_route_nommee,geometrie",3e3)}async railways(t){const e=`BBOX(geometrie,${[t.west,t.south,t.east,t.north].map(i=>i.toFixed(6)).join(",")},'EPSG:4326')`;return this.features("troncon_de_voie_ferree",`${e} AND etat_de_l_objet='En service'`,"cleabs,nature,electrifie,largeur,nombre_de_voies,position_par_rapport_au_sol,cpx_toponyme,geometrie",3e3)}async raster(t,e,i,n){const s=e/Fe.METRES_PER_DEGREE,r=e/(Fe.METRES_PER_DEGREE*Math.cos(t.lat*Math.PI/180)),a=new URLSearchParams({SERVICE:"WMS",VERSION:"1.3.0",REQUEST:"GetMap",LAYERS:n,STYLES:"",CRS:"EPSG:4326",BBOX:[t.lat-s,t.lng-r,t.lat+s,t.lng+r].map(l=>l.toFixed(6)).join(","),WIDTH:String(i),HEIGHT:String(i),FORMAT:"image/geotiff"});let c;try{c=await this.fetchImpl(`${this.wms}?${a}`)}catch(l){throw new fo("unreachable",l instanceof Error?l.message:String(l))}if(!c.ok)throw new fo("unreachable",`The survey answered ${c.status}`);try{return Hp.parse(await c.arrayBuffer())}catch(l){throw new fo("unreachable",l instanceof Error?l.message:String(l))}}async features(t,e,i,n=200){const s=new URLSearchParams({SERVICE:"WFS",VERSION:"2.0.0",REQUEST:"GetFeature",TYPENAMES:t.includes(":")?t:`BDTOPO_V3:${t}`,SRSNAME:"EPSG:4326",OUTPUTFORMAT:"application/json",COUNT:String(n),CQL_FILTER:e,PROPERTYNAME:i});let r;try{r=await this.fetchImpl(`${this.wfs}?${s}`)}catch(c){throw new fo("unreachable",c instanceof Error?c.message:String(c))}if(!r.ok)throw new fo("unreachable",`The map answered ${r.status}`);return(await r.json()).features??[]}}class Io{static NEAR_M=15;static ALIGNED_DEG=30;static LONG_ENOUGH_M=15;static SAMPLE_M=5;static follows(t,e){if(t.length<2||e.length<2)return!1;const i=e[0],n=e.map(a=>ae(a.lat,a.lng,i.lat,i.lng)),s=t.map(a=>ae(a.lat,a.lng,i.lat,i.lng));let r=0;for(let a=0;a<s.length-1;a++){const c=s[a],l=s[a+1],h=Math.hypot(l.x-c.x,l.z-c.z);if(h<1e-6)continue;const u=Math.max(1,Math.ceil(h/Io.SAMPLE_M)),d=Math.atan2(l.x-c.x,-(l.z-c.z));for(let f=0;f<=u;f++){const p=f/u,g=Io.nearest(n,c.x+(l.x-c.x)*p,c.z+(l.z-c.z)*p);g.distanceM>Io.NEAR_M||Io.angleBetween(d,g.heading)<=Io.ALIGNED_DEG&&(r+=h/u)}}return r>=Io.LONG_ENOUGH_M}static nearest(t,e,i){let n={distanceM:1/0,heading:0};for(let s=0;s<t.length-1;s++){const r=t[s],a=t[s+1],c=a.x-r.x,l=a.z-r.z,h=c*c+l*l,u=h<1e-9?0:Math.max(0,Math.min(1,((e-r.x)*c+(i-r.z)*l)/h)),d=Math.hypot(e-(r.x+c*u),i-(r.z+l*u));d<n.distanceM&&(n={distanceM:d,heading:Math.atan2(c,-l)})}return n}static angleBetween(t,e){const i=Math.abs((t-e)*180/Math.PI%180);return Math.min(i,180-i)}}class Pe{static WMS="https://data.geopf.fr/wms-r/wms";static LAYERS=["IGNF_LIDAR-HD_MNT_ELEVATION.ELEVATIONGRIDCOVERAGE.LAMB93","ELEVATION.ELEVATIONGRIDCOVERAGE.HIGHRES"];static METRES_PER_PIXEL=4;static METRES_PER_DEGREE=111320;static CLASS_LAYER="IGNF_LIDAR-HD_CLASS";static SURFACE_LAYER="IGNF_LIDAR-HD_MNS_ELEVATION.ELEVATIONGRIDCOVERAGE.LAMB93";static DECK=[240,240,0];static NO_CLASS=[0,0,0];static DECK_END_PIXELS=3;static DECK_HALF_WIDTH_M=8;static DECK_APPROACH_M=10;static DECK_STRAIGHT_MAX_M=200;static MIN_PIXELS=8;static MAX_PIXELS=700;static NO_DATA_BELOW=-100;static COARSE_METRES_PER_PIXEL=20;static MESH_FROM_VERTICES=33;static FINE_SPACING_M=7;static MAX_SEGMENTS=256;static MAX_HOLE_SHARE=.05;static DEFAULT_TIMEOUT_MS=12e3;static MAX_WINDOW_M=50;fetchImpl;wms;timeoutMs;maxWindowM;geoplatform;constructor(t={}){this.fetchImpl=t.fetchImpl??fetch.bind(globalThis),this.wms=t.wmsEndpoint??Pe.WMS,this.timeoutMs=t.timeoutMs??Pe.DEFAULT_TIMEOUT_MS,this.maxWindowM=t.maxWindowM??Pe.MAX_WINDOW_M,this.geoplatform=new Fe({fetchImpl:this.fetchImpl,wmsEndpoint:this.wms,wfsEndpoint:t.wfsEndpoint})}async getElevationGrid(t,e,i){const n={lat:(t.south+t.north)/2,lng:(t.west+t.east)/2};if(!Fe.covers(n.lat,n.lng))throw new Error("The IGN's relief covers France only");const s=Math.abs(ae(n.lat,t.east,n.lat,t.west).x),r=Math.abs(ae(t.north,n.lng,t.south,n.lng).z);e=this.finer(e,s,r);const a={x:s/Math.max(1,e.width-1),y:r/Math.max(1,e.height-1)},c={x:Math.min(a.x,this.maxWindowM),y:Math.min(a.y,this.maxWindowM)},l={south:t.south-c.y/Pe.METRES_PER_DEGREE,north:t.north+c.y/Pe.METRES_PER_DEGREE,west:t.west-c.x/(Pe.METRES_PER_DEGREE*Math.cos(n.lat*Math.PI/180)),east:t.east+c.x/(Pe.METRES_PER_DEGREE*Math.cos(n.lat*Math.PI/180))},h=g=>Math.min(Pe.MAX_PIXELS,Math.max(Pe.MIN_PIXELS,Math.ceil(g/Pe.METRES_PER_PIXEL))),u={width:h(s+2*c.x),height:h(r+2*c.y)},d={x:(s+2*c.x)/u.width,y:(r+2*c.y)/u.height};let f=new Error("No layer of the IGN's relief answered");const p=Math.max(d.x,d.y)>Pe.COARSE_METRES_PER_PIXEL;for(const g of p?[...Pe.LAYERS].reverse():Pe.LAYERS)try{const m=await this.heights(l,u,g);g===Pe.LAYERS[0]&&await this.layBridgeDecks(m,l,u,i?.route);const M=this.sample(m,e,t,l,d,a);if(M)return{heights:M,width:e.width,height:e.height,bounds:t};f=new Error(`${g} does not cover this place`)}catch(m){f=m}throw f}finer(t,e,i){if(t.width<Pe.MESH_FROM_VERTICES||t.height<Pe.MESH_FROM_VERTICES)return t;const n=(s,r)=>{const a=Math.ceil(s/Pe.FINE_SPACING_M),c=Math.max(r-1,Math.min(Pe.MAX_SEGMENTS,a));return c%2===0?c:c+1};return{width:n(e,t.width)+1,height:n(i,t.height)+1}}async raster(t,e,i){const n=new URLSearchParams({SERVICE:"WMS",VERSION:"1.3.0",REQUEST:"GetMap",LAYERS:i,STYLES:"",CRS:"EPSG:4326",BBOX:[t.south,t.west,t.north,t.east].map(r=>r.toFixed(6)).join(","),WIDTH:String(e.width),HEIGHT:String(e.height),FORMAT:"image/geotiff"}),s=await this.fetchImpl(`${this.wms}?${n}`,{signal:AbortSignal.timeout(this.timeoutMs)});if(!s.ok)throw new Error(`The IGN's relief answered ${s.status}`);return Hp.parse(await s.arrayBuffer())}async heights(t,e,i){const n=await this.raster(t,e,i);if(n.samples!==1||!(n.values instanceof Float32Array))throw new Error("The IGN's relief came in a layout this does not read");return n}async layBridgeDecks(t,e,i,n){if(!(!n||n.length<2)&&!(!(t.values instanceof Float32Array)||!t.values.some(s=>s>Pe.NO_DATA_BELOW)))try{const s=(await this.geoplatform.elevatedRoadLines({west:e.west,south:e.south,east:e.east,north:e.north})).filter(a=>Io.follows(n,a));if(s.length===0)return;const r=Float32Array.from(t.values);await this.layClassifiedDecks(t,e,i,s),this.layRouteDecks(t,r,e,s)}catch{}}async layClassifiedDecks(t,e,i,n){try{const s=await this.raster(e,i,Pe.CLASS_LAYER);if(s.samples<3||s.width!==t.width||s.height!==t.height)return;const r=(m,[M,v,x])=>s.values[m*s.samples]===M&&s.values[m*s.samples+1]===v&&s.values[m*s.samples+2]===x,a=t.width,c=t.height,l=new Uint8Array(a*c);let h=!1;for(let m=0;m<l.length;m++)r(m,Pe.DECK)&&(l[m]=1,h=!0);if(!h)return;const u=Pe.DECK_END_PIXELS,d=[];for(let m=0;m<l.length;m++){if(l[m]!==1)continue;const M=m%a,v=(m-M)/a;for(let x=-u;x<=u;x++)for(let y=-u;y<=u;y++){const w=M+y,b=v+x;if(w<0||b<0||w>=a||b>=c)continue;const E=b*a+w;l[E]===0&&r(E,Pe.NO_CLASS)&&d.push(E)}}for(const m of d)l[m]=1;const f=this.paint(n,e,a,c),p=this.touching(l,f,a,c);if(p.every(m=>m===0))return;const g=await this.heights(e,i,Pe.SURFACE_LAYER);if(g.width!==a||g.height!==c)return;for(let m=0;m<p.length;m++){if(p[m]===0)continue;const M=g.values[m];Number.isFinite(M)&&M>Pe.NO_DATA_BELOW&&M>t.values[m]&&(t.values[m]=M)}}catch{}}layRouteDecks(t,e,i,n){const{width:s,height:r}=t,a=(i.north+i.south)/2,c=(i.east-i.west)*Pe.METRES_PER_DEGREE*Math.cos(a*Math.PI/180),l=(i.north-i.south)*Pe.METRES_PER_DEGREE,h=c/s,u=l/r,d=M=>({x:(M.lng-i.west)/(i.east-i.west)*c,y:(i.north-M.lat)/(i.north-i.south)*l}),f=(M,v)=>{const x=Math.floor(M/h),y=Math.floor(v/u);if(x<0||y<0||x>=s||y>=r)return;const w=e[y*s+x];return Number.isFinite(w)&&w>Pe.NO_DATA_BELOW?w:void 0},p=Pe.DECK_HALF_WIDTH_M,g=Pe.DECK_APPROACH_M,m=(M,v)=>{const x=Math.hypot(M.x-v.x,M.y-v.y)||1,y={x:(M.x-v.x)/x,y:(M.y-v.y)/x},w=[0,g/2,g].map(b=>f(M.x+y.x*b,M.y+y.y*b)).filter(b=>b!==void 0);return w.length>0?Math.max(...w):void 0};for(const M of Pe.chains(n.map(v=>v.map(d)))){const v=[0];for(let D=1;D<M.length;D++)v.push(v[D-1]+Math.hypot(M[D].x-M[D-1].x,M[D].y-M[D-1].y));const x=v[v.length-1];if(x<1||x>Pe.DECK_STRAIGHT_MAX_M)continue;const y=m(M[0],M[1]),w=m(M[M.length-1],M[M.length-2]);if(y===void 0||w===void 0)continue;const b=p+g,E=Math.max(0,Math.floor((Math.min(...M.map(D=>D.x))-b)/h)),S=Math.min(s-1,Math.ceil((Math.max(...M.map(D=>D.x))+b)/h)),A=Math.max(0,Math.floor((Math.min(...M.map(D=>D.y))-b)/u)),R=Math.min(r-1,Math.ceil((Math.max(...M.map(D=>D.y))+b)/u));for(let D=A;D<=R;D++)for(let I=E;I<=S;I++){const P=Pe.nearestAlong(M,v,{x:(I+.5)*h,y:(D+.5)*u});if(P.distance>p||P.s<-g||P.s>x+g)continue;const L=y+(w-y)*Math.min(1,Math.max(0,P.s/x)),O=D*s+I;e[O]>=L||(t.values[O]=L)}}}static chains(t){const e=t.filter(s=>s.length>=2).map(s=>[...s]),i=[],n=(s,r)=>Math.hypot(s.x-r.x,s.y-r.y)<=1;for(;e.length>0;){let s=e.shift(),r=!0;for(;r;){r=!1;for(let a=0;a<e.length;a++){const c=e[a],l=s[0],h=s[s.length-1];if(n(h,c[0]))s=[...s,...c.slice(1)];else if(n(h,c[c.length-1]))s=[...s,...[...c].reverse().slice(1)];else if(n(l,c[c.length-1]))s=[...c.slice(0,-1),...s];else if(n(l,c[0]))s=[...[...c].reverse().slice(0,-1),...s];else continue;e.splice(a,1),r=!0;break}}i.push(s)}return i}static nearestAlong(t,e,i){let n={s:0,distance:1/0};for(let s=0;s<t.length-1;s++){const r=t[s],a=t[s+1],c=a.x-r.x,l=a.y-r.y,h=c*c+l*l;if(h<1e-9)continue;let u=((i.x-r.x)*c+(i.y-r.y)*l)/h;s>0&&(u=Math.max(0,u)),s<t.length-2&&(u=Math.min(1,u));const d=Math.hypot(i.x-(r.x+c*u),i.y-(r.y+l*u));d<n.distance&&(n={s:e[s]+u*Math.sqrt(h),distance:d})}return n}paint(t,e,i,n){const s=new Uint8Array(i*n),r=c=>(c-e.west)/(e.east-e.west)*i,a=c=>(e.north-c)/(e.north-e.south)*n;for(const c of t)for(let l=0;l<c.length-1;l++){const h=r(c[l].lng),u=a(c[l].lat),d=r(c[l+1].lng),f=a(c[l+1].lat),p=Math.max(1,Math.ceil(Math.hypot(d-h,f-u)*2));for(let g=0;g<=p;g++){const m=Math.floor(h+(d-h)*g/p),M=Math.floor(u+(f-u)*g/p);for(let v=-1;v<=1;v++)for(let x=-1;x<=1;x++){const y=m+x,w=M+v;y>=0&&w>=0&&y<i&&w<n&&(s[w*i+y]=1)}}}return s}touching(t,e,i,n){const s=new Uint8Array(t.length),r=new Uint8Array(t.length);for(let a=0;a<t.length;a++){if(t[a]===0||r[a]===1)continue;const c=[],l=[a];r[a]=1;let h=!1;for(;l.length>0;){const u=l.pop();c.push(u),e[u]===1&&(h=!0);const d=u%i,f=(u-d)/i;for(let p=-1;p<=1;p++)for(let g=-1;g<=1;g++){const m=d+g,M=f+p;if(m<0||M<0||m>=i||M>=n)continue;const v=M*i+m;t[v]===1&&r[v]===0&&(r[v]=1,l.push(v))}}if(h)for(const u of c)s[u]=1}return s}sample(t,e,i,n,s,r){const{width:a,height:c}=e,l=new Float32Array(a*c),h=new Uint8Array(a*c),u=Math.min(r.x,this.maxWindowM)/s.x,d=Math.min(r.y,this.maxWindowM)/s.y;let f=0;for(let p=0;p<c;p++){const g=i.north+(i.south-i.north)*(c===1?.5:p/(c-1)),m=(n.north-g)/(n.north-n.south)*t.height-.5;for(let M=0;M<a;M++){const x=(i.west+(i.east-i.west)*(a===1?.5:M/(a-1))-n.west)/(n.east-n.west)*t.width-.5,y=u>1||d>1?this.tent(t,x,m,Math.max(1,u),Math.max(1,d)):this.bilinear(t,x,m),w=p*a+M;y===void 0?f++:(l[w]=y,h[w]=1)}}if(!(f===a*c||f/(a*c)>Pe.MAX_HOLE_SHARE))return this.fill(l,h,a,c),l}tent(t,e,i,n,s){let r=0,a=0,c=0;const l=Math.max(0,Math.ceil(i-s)),h=Math.min(t.height-1,Math.floor(i+s)),u=Math.max(0,Math.ceil(e-n)),d=Math.min(t.width-1,Math.floor(e+n));for(let f=l;f<=h;f++){const p=1-Math.abs(f-i)/s;if(!(p<=0))for(let g=u;g<=d;g++){const m=p*(1-Math.abs(g-e)/n);if(m<=0)continue;c+=m;const M=t.at(g,f);!Number.isFinite(M)||M<Pe.NO_DATA_BELOW||(r+=m*M,a+=m)}}return c>0&&a>=c*.5?r/a:void 0}bilinear(t,e,i){const n=Math.max(0,Math.min(t.width-1,Math.floor(e))),s=Math.max(0,Math.min(t.height-1,Math.floor(i))),r=Math.min(t.width-1,n+1),a=Math.min(t.height-1,s+1),c=Math.max(0,Math.min(1,e-n)),l=Math.max(0,Math.min(1,i-s)),h=t.at(n,s),u=t.at(r,s),d=t.at(n,a),f=t.at(r,a);for(const m of[h,u,d,f])if(!Number.isFinite(m)||m<Pe.NO_DATA_BELOW)return;const p=h+(u-h)*c,g=d+(f-d)*c;return p+(g-p)*l}fill(t,e,i,n){let s=e.reduce((r,a)=>r+(a?0:1),0);for(;s>0;){const r=[];for(let a=0;a<n;a++)for(let c=0;c<i;c++){const l=a*i+c;if(e[l])continue;let h=0,u=0;for(let d=-1;d<=1;d++)for(let f=-1;f<=1;f++){const p=a+d,g=c+f;p<0||g<0||p>=n||g>=i||!e[p*i+g]||(h+=t[p*i+g],u++)}u>0&&r.push([l,h/u])}if(r.length===0)return;for(const[a,c]of r)t[a]=c,e[a]=1;s-=r.length}}}class p5{providers;constructor(...t){this.providers=t}async getElevationGrid(t,e,i){let n=new Error("No source of relief to ask");for(const s of this.providers)try{return await s.getElevationGrid(t,e,i)}catch(r){n=r}throw n}}const O0=256,m5=5;async function Yb(o,t,e,i){const n=(o.south+o.north)/2,s=(o.west+o.east)/2,r=Math.abs(ae(n,o.east,n,o.west).x),a=Math.abs(ae(o.north,s,o.south,s).z),c=Math.max(r,a),{zoom:l,gridSize:h}=g5(n,c,Math.max(t.width,t.height)),{tiles:u,bounds:d}=Wb(s,n,l,h),f=h*O0,p=document.createElement("canvas");p.width=f,p.height=f;const g=p.getContext("2d");if(!g)throw new Error("2D canvas context unavailable");const m=u[0];await Promise.all(u.map(async y=>{const w=e(y),b=await i(w);if(!b.ok)throw new Error(`Imagery tile fetch failed (${b.status}): ${w}`);const E=await createImageBitmap(await b.blob());g.drawImage(E,(y.x-m.x)*O0,(y.y-m.y)*O0)}));const M=Math.min(Math.max(t.width,t.height),f);if(M===f)return{source:p,width:f,height:f,bounds:d};const v=document.createElement("canvas");v.width=M,v.height=M;const x=v.getContext("2d");if(!x)throw new Error("2D canvas context unavailable");return x.drawImage(p,0,0,f,f,0,0,M,M),{source:v,width:M,height:M,bounds:d}}function g5(o,t,e){let i=Hb(o,t/Math.max(1,e)),n=U2(o,i,t);for(;n>m5&&i>0;)i--,n=U2(o,i,t);return{zoom:i,gridSize:n,mPerPixel:uv(o,i)/O0}}function U2(o,t,e){const i=Math.ceil(e/2/uv(o,t));return Math.max(3,2*i+1)}class Kb{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 Yb(t,e,i=>this.tileUrlTemplate.replace("{z}",String(i.z)).replace("{y}",String(i.y)).replace("{x}",String(i.x)),this.fetchImpl)}}class ks{static ENDPOINTS=["https://overpass-api.de/api/interpreter","https://overpass.kumi.systems/api/interpreter","https://overpass.private.coffee/api/interpreter"];static FRANCE_ENDPOINT="https://overpass.openstreetmap.fr/api/interpreter";static FRANCE={south:41.3,west:-5.2,north:51.1,east:9.6};static endpointsFor(t,e=ks.ENDPOINTS){const i=/\((-?\d+(?:\.\d+)?),(-?\d+(?:\.\d+)?),(-?\d+(?:\.\d+)?),(-?\d+(?:\.\d+)?)\)/.exec(t);if(!i)return[...e];const[n,s,r,a]=i.slice(1).map(Number),c=(n+r)/2,l=(s+a)/2,h=ks.FRANCE;return c>=h.south&&c<=h.north&&l>=h.west&&l<=h.east?[ks.FRANCE_ENDPOINT,...e.filter(d=>d!==ks.FRANCE_ENDPOINT)]:[...e]}fetchImpl;endpoints;constructor(t={}){this.fetchImpl=t.fetchImpl??fetch.bind(globalThis),this.endpoints=t.endpoints}static queue=Promise.resolve();static HANG_MS=4e4;static RETRY_MS=4e3;query(t){return this.queued(()=>this.ask(t))}queued(t){const e=ks.queue.then(t,t);return ks.queue=e.catch(()=>{}),e}async ask(t){let e;for(const i of this.endpoints??ks.endpointsFor(t))for(let n=0;n<2;n++){try{const s=await this.fetchImpl(`${i}?data=${encodeURIComponent(t)}`,{signal:AbortSignal.timeout(ks.HANG_MS)});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,ks.RETRY_MS))}throw e??new Error("No Overpass instance answered")}}class Co{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;client;constructor(t={}){this.client=new ks(t)}async getRoads(t){const e=`${t.south},${t.west},${t.north},${t.east}`,i=`[out:json][timeout:30];way["highway"~"^(${Co.DRIVABLE.join("|")})$"](${e});out geom;`;return this.waysFrom(await this.client.query(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:Co.surfaceOf(s),widthM:Co.widthOf(s),...Co.paintOf(s),points:n.map(r=>({lat:r.lat,lng:r.lon}))})}return e}static paintOf(t){const e=t.highway??"",i=t.junction==="roundabout"||t.junction==="circular",n=t.oneway,s=n==="yes"||n==="1"||n==="true"||n===void 0&&(e==="motorway"||i),r=n==="-1"||n==="reverse",a=Number.parseInt(t.lanes??"",10),c=Number.parseInt(t.maxspeed??"",10),l=i?"roundabout":e==="motorway"?"motorway":e.endsWith("_link")?"slip":(e==="trunk"||e==="primary")&&(s||r)?"dual":e?"road":void 0;return{...l?{kind:l}:{},...Number.isFinite(a)&&a>0?{lanes:a}:{},...n!==void 0||e==="motorway"||i?{direction:r?"backward":s?"forward":"both"}:{},...Number.isFinite(c)&&c>0?{speedKmh:c}:{}}}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:Co.WIDTH_M[t.highway]??Co.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 wm="https://ufoathome.org/roads/index.json";class th{attributionRead;contemporaryRead;fetchImpl;indexUrls;fallback;index;static shared=new Map;sharing;constructor(t={}){this.sharing=!t.fetchImpl,this.fetchImpl=t.fetchImpl??fetch.bind(globalThis),this.indexUrls=t.indexUrls??th.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(){if(this.index)return this.index;if(!this.sharing)return this.index=this.fetchFirstAvailable();const t=this.indexUrls.join(`
|
|
1935
|
-
`);let e=th.shared.get(t);return e||(e=this.fetchFirstAvailable(),th.shared.set(t,e),e.then(i=>{i.length===0&&th.shared.delete(t)})),this.index=e}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.
|
|
1936
|
-
`);let e=eh.shared.get(t);return e||(e=this.fetchFirstAvailable(),eh.shared.set(t,e),e.then(i=>{i.length===0&&eh.shared.delete(t)})),this.index=e}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.191.0")}`,e=typeof location>"u"?void 0:new URL("/water/index.json",location.href).href;return(e&&e!==Sm?[e,Sm]:[Sm]).map(i=>i+t)}}class Rs{constructor(t){this.water=t}static CACHE_NAME="rr0-water";static MAX_AGE_MS=720*3600*1e3;static FORMAT=1;static MAX_STORED=400;static asked=new Map;get attribution(){return this.water.attribution}async getWater(t){const e=Rs.key(t);let i=Rs.asked.get(e);return i===void 0&&(i=this.recalled(e,t),Rs.asked.set(e,i),i.catch(()=>Rs.asked.delete(e))),structuredClone(await i)}static forget(){Rs.asked.clear()}static key(t){return`v${Rs.FORMAT}/${[t.north,t.south,t.east,t.west].map(e=>e.toFixed(5)).join("/")}`}async recalled(t,e){const i=await Rs.openCache(),n=Rs.request(t);if(i)try{const r=await i.match(n);if(r){const{savedAt:a,surfaces:c}=await r.json();if(Date.now()-a<Rs.MAX_AGE_MS&&Array.isArray(c))return c;await i.delete(n)}}catch{}const s=await this.water.getWater(e);return i&&Rs.store(i,n,s),s}static async store(t,e,i){try{const n={savedAt:Date.now(),surfaces:i};await t.put(e,new Response(JSON.stringify(n),{headers:{"Content-Type":"application/json"}}));const s=await t.keys();for(const r of s.slice(0,Math.max(0,s.length-Rs.MAX_STORED)))await t.delete(r)}catch{}}static async openCache(){try{return typeof caches>"u"?void 0:await caches.open(Rs.CACHE_NAME)}catch{return}}static request(t){const e=typeof location>"u"?"http://localhost":location.origin;return new Request(`${e}/__water__/${encodeURIComponent(t)}`)}}class Fo{attribution="Railways © IGN, BD TOPO (Licence Ouverte 2.0), as drawn today";contemporary=!0;static BY_NATURE={"Voie ferrée principale":{kind:"rail"},LGV:{kind:"rail",highSpeed:!0},"Voie de service":{kind:"rail",service:!0},Métro:{kind:"subway"},Tramway:{kind:"tram"},"Transport urbain":{kind:"light_rail"},"Funiculaire ou crémaillère":{kind:"funicular"}};static GAUGE_MM={Normale:1435,Etroite:1e3,Étroite:1e3,Large:1668};static NO_ALTITUDE=-1e3;platform;constructor(t={}){this.platform=new Fe(t)}static covers(t){return Fe.covers((t.south+t.north)/2,(t.west+t.east)/2)}async getRailways(t){return(await this.platform.railways(t)).flatMap((i,n)=>Fo.linesOf(i,n))}static linesOf(t,e){const{type:i,coordinates:n}=t.geometry,s=i==="LineString"?[n]:i==="MultiLineString"?n:[],r=Fo.BY_NATURE[String(t.properties.nature??"")];if(!r)return[];const a=String(t.properties.cleabs??`ign-rail-${e}`),c=Number(t.properties.nombre_de_voies),l=Number(t.properties.position_par_rapport_au_sol),h=t.properties.cpx_toponyme,u=Fo.GAUGE_MM[String(t.properties.largeur??"")]??1435,d=Fo.electrificationOf(r.kind,u,t.properties.electrifie);return s.flatMap((f,p)=>{const g=f.map(m=>({lat:m[1],lng:m[0],...m.length>2&&Number.isFinite(m[2])&&m[2]>Fo.NO_ALTITUDE?{altitudeM:m[2]}:{}}));return g.length<2?[]:[{id:s.length>1?`${a}-${p}`:a,...typeof h=="string"&&h.length>0?{name:h}:{},kind:r.kind,...r.service?{service:!0}:{},...r.highSpeed?{highSpeed:!0}:{},gaugeMm:u,tracks:Number.isInteger(c)&&c>0?c:1,...d?{electrification:d}:{},level:Number.isFinite(l)?l:0,points:g}]})}static electrificationOf(t,e,i){if(i===!1)return"none";if(i===!0){if(t==="subway")return"third_rail";if(!(t==="funicular"||e<1435))return"overhead"}}}class Xn{static NEAR_M=15;static ALIGNED_DEG=30;static SAMPLE_M=10;static ROUTES="train|subway|light_rail|tram|monorail";static KINDS="rail|light_rail|subway|tram|narrow_gauge|funicular|preserved";client;constructor(t={}){this.client=new ks(t)}async named(t,e){if(t.length===0)return[...t];const i=`${e.south},${e.west},${e.north},${e.east}`,n=`[out:json][timeout:120];way["railway"~"^(${Xn.KINDS})$"](${i})->.w;.w out tags geom;rel(bw.w)["route"~"^(${Xn.ROUTES})$"];out body;`;return Xn.apply(t,await this.client.query(n),e)}static apply(t,e,i){const n={lat:(i.north+i.south)/2,lng:(i.east+i.west)/2},s=Xn.ways(e,n);return s.length===0?[...t]:t.map(r=>{const a=r.points.map(M=>ae(M.lat,M.lng,n.lat,n.lng)),c=new Map,l=new Map,h=new Map;let u=0;const d=s.filter(M=>M.service===!!r.service);for(const M of Xn.samples(a)){u++;const v=Xn.waysAt(d,M);if(v.length===0)continue;const[x]=v;x.name&&c.set(x.name,(c.get(x.name)??0)+1),x.voltageV&&l.set(x.voltageV,(l.get(x.voltageV)??0)+1);for(const y of new Set(v.flatMap(w=>w.services)))h.set(y,(h.get(y)??0)+1)}const f=M=>[...M.entries()].sort((v,x)=>x[1]-v[1])[0]?.[0],p=r.name??f(c),g=r.voltageV??(r.electrification==="none"?void 0:f(l)),m=[...h.entries()].filter(([,M])=>M*4>=u).sort((M,v)=>v[1]-M[1]||M[0].localeCompare(v[0])).map(([M])=>M);return{...r,...p?{name:p}:{},...g?{voltageV:g}:{},...m.length>0?{services:m}:{}}})}static serviceOf(t){const e=t.name?.split(" : ")[0].replace(/\s*\([^)]*\)\s*$/,"").trim();return e||[t.network,t.ref].filter(Boolean).join(" ")||void 0}static servicesByWay(t){const e=new Map;for(const i of t.elements??[]){if(i.type!=="relation"||!i.tags)continue;const n=Xn.serviceOf(i.tags);if(n)for(const s of i.members??[]){if(s.type!=="way"||s.ref===void 0)continue;const r=e.get(s.ref)??new Set;r.add(n),e.set(s.ref,r)}}return e}static voltageOf(t){const e=Number.parseInt((t.voltage??"").split(";")[0],10);return Number.isFinite(e)&&e>0?e:void 0}static ways(t,e){const i=Xn.servicesByWay(t),n=[];for(const s of t.elements??[]){if(s.type!=="way"||!s.geometry||s.geometry.length<2)continue;const r=s.tags??{},a=Xn.voltageOf(r);n.push({service:!!r.service||r.usage==="industrial",...r.name?{name:r.name}:{},...a?{voltageV:a}:{},services:[...i.get(s.id??-1)??[]],path:s.geometry.map(c=>ae(c.lat,c.lon,e.lat,e.lng))})}return n}static samples(t){const e=[];for(let i=0;i<t.length-1;i++){const n=Math.hypot(t[i+1].x-t[i].x,t[i+1].z-t[i].z);if(n<1e-6)continue;const s=(t[i+1].x-t[i].x)/n,r=(t[i+1].z-t[i].z)/n;for(let a=Xn.SAMPLE_M/2;a<n;a+=Xn.SAMPLE_M)e.push({x:t[i].x+s*a,z:t[i].z+r*a,dx:s,dz:r})}return e}static waysAt(t,e){const i=Math.cos(Xn.ALIGNED_DEG*Math.PI/180),n=[];for(const s of t){let r;for(let a=0;a<s.path.length-1;a++){const c=s.path[a],l=s.path[a+1],h=l.x-c.x,u=l.z-c.z,d=Math.hypot(h,u);if(d<1e-6||Math.abs((h*e.dx+u*e.dz)/d)<i)continue;const f=Math.max(0,Math.min(1,((e.x-c.x)*h+(e.z-c.z)*u)/(d*d))),p=Math.hypot(e.x-(c.x+h*f),e.z-(c.z+u*f));p<=Xn.NEAR_M&&(r===void 0||p<r)&&(r=p)}r!==void 0&&n.push({way:s,distance:r})}return n.sort((s,r)=>s.distance-r.distance).map(({way:s})=>s)}}class ih{attribution="Railways © OpenStreetMap contributors, as surveyed today";contemporary=!0;static KINDS=["rail","light_rail","tram","subway","narrow_gauge","funicular","preserved"];client;constructor(t={}){this.client=new ks(t)}async getRailways(t){const e=`${t.south},${t.west},${t.north},${t.east}`,i=`[out:json][timeout:25];way["railway"~"^(${ih.KINDS.join("|")})$"](${e})->.w;.w out tags geom;rel(bw.w)["route"~"^(${Xn.ROUTES})$"];out body;`;return this.linesFrom(await this.client.query(i))}linesFrom(t){const e=[],i=Xn.servicesByWay(t);for(const n of t.elements??[]){const s=n.geometry,r=n.tags;if(n.type==="relation"||!r||!s||s.length<2)continue;const a=[...i.get(n.id??-1)??[]].sort(),c=Xn.voltageOf(r),l=ih.kindOf(r),h=Number.parseInt((r.gauge??"").split(";")[0],10),u=Number.parseInt(r.tracks??"",10),d=ih.electrificationOf(r.electrified),f=r.highspeed==="yes"||Number.parseInt(r.maxspeed??"",10)>=250;e.push({id:`osm-rail-${n.id??e.length}`,...r.name?{name:r.name}:{},...a.length>0?{services:a}:{},...c?{voltageV:c}:{},kind:l,...r.service||r.usage==="industrial"?{service:!0}:{},...f?{highSpeed:!0}:{},gaugeMm:Number.isFinite(h)&&h>300?h:r.railway==="narrow_gauge"?1e3:1435,tracks:Number.isFinite(u)&&u>0?u:1,...d?{electrification:d}:{},level:ih.levelOf(r),points:s.map(p=>({lat:p.lat,lng:p.lon}))})}return e}static kindOf(t){switch(t.railway){case"tram":return"tram";case"subway":return"subway";case"light_rail":return"light_rail";case"funicular":return"funicular";default:return"rail"}}static electrificationOf(t){if(t!==void 0){if(t==="no")return"none";if(t==="contact_line"||t==="yes")return"overhead";if(t==="rail"||t==="4th_rail"||t==="ground-level_power_supply")return"third_rail"}}static levelOf(t){const e=Number.parseInt(t.layer??"",10);return t.tunnel&&t.tunnel!=="no"?Number.isFinite(e)&&e<0?e:-1:t.covered==="yes"&&t.location==="underground"?-1:t.bridge&&t.bridge!=="no"?Number.isFinite(e)&&e>0?e:1:0}}class y5{constructor(t,e){this.regional=t,this.worldwide=e}attribution="Railways © IGN, BD TOPO, in France; © OpenStreetMap contributors elsewhere, as drawn today";contemporary=!0;async getRailways(t){if(!Fo.covers(t))return this.worldwide.getRailways(t);let e;try{if(e=await this.regional.getRailways(t),e.length>0)return e}catch{}try{return await this.worldwide.getRailways(t)}catch(i){if(e)return e;throw i}}}class dn{constructor(t,e=Date.now){this.railways=t,this.now=e}static CACHE_NAME="rr0-railways";static MAX_AGE_MS=720*3600*1e3;static FORMAT=1;static MAX_STORED=400;static RETRY_AFTER_MS=300*1e3;static asked=new Map;static failedAt=-1/0;get attribution(){return this.railways.attribution}get contemporary(){return this.railways.contemporary}async getRailways(t){const e=dn.key(t);let i=dn.asked.get(e)??dn.containing(t);if(i===void 0){const n=this.recalled(e,t);i={bounds:t,answer:n},dn.asked.set(e,i),n.catch(()=>dn.asked.delete(e))}return structuredClone(await i.answer)}static forget(){dn.asked.clear(),dn.failedAt=-1/0}static key(t){return`v${dn.FORMAT}/${[t.north,t.south,t.east,t.west].map(e=>e.toFixed(5)).join("/")}`}static containing(t){for(const e of dn.asked.values()){const i=e.bounds;if(i.north>=t.north&&i.south<=t.south&&i.east>=t.east&&i.west<=t.west)return e}}async recalled(t,e){const i=await dn.openCache(),n=dn.request(t);let s;if(i)try{const a=await i.match(n);if(a){const{savedAt:c,lines:l}=await a.json();if(Array.isArray(l)){if(this.now()-c<dn.MAX_AGE_MS)return l;s=l}}}catch{}if(this.now()-dn.failedAt<dn.RETRY_AFTER_MS){if(s)return s;throw new Error("The railway survey failed a moment ago: not asked again yet")}let r;try{r=await this.railways.getRailways(e)}catch(a){if(dn.failedAt=this.now(),s)return s;throw a}return i&&dn.store(i,n,{savedAt:this.now(),lines:r}),r}static async store(t,e,i){try{await t.delete(e),await t.put(e,new Response(JSON.stringify(i),{headers:{"Content-Type":"application/json"}}));const n=await t.keys();for(const s of n.slice(0,Math.max(0,n.length-dn.MAX_STORED)))await t.delete(s)}catch{}}static async openCache(){try{return typeof caches>"u"?void 0:await caches.open(dn.CACHE_NAME)}catch{return}}static request(t){const e=typeof location>"u"?"http://localhost":location.origin;return new Request(`${e}/__railways__/${encodeURIComponent(t)}`)}}const bm="https://ufoathome.org/railways/index.json";class nh{contemporary=!0;attributionRead;fetchImpl;indexUrls;fallback;index;static shared=new Map;sharing;constructor(t={}){this.sharing=!t.fetchImpl,this.fetchImpl=t.fetchImpl??fetch.bind(globalThis),this.indexUrls=t.indexUrls??nh.defaultIndexUrls(),this.fallback=t.fallback}get attribution(){return this.attributionRead??this.fallback?.attribution??"Railways © OpenStreetMap contributors"}async getRailways(t){const e=await this.held(t);if(e)return e;if(!this.fallback)return[];const i=await this.fallback.getRailways(t);return this.attributionRead=this.fallback.attribution,i}async held(t){const i=(await this.load().catch(()=>[])).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?.lines)?(this.attributionRead=s.attribution,s.lines):void 0}catch{return}}load(){if(this.index)return this.index;if(!this.sharing)return this.index=this.fetchFirstAvailable();const t=this.indexUrls.join(`
|
|
1937
|
-
`);let e=nh.shared.get(t);return e||(e=this.fetchFirstAvailable(),nh.shared.set(t,e),e.then(i=>{i.length===0&&nh.shared.delete(t)})),this.index=e}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.191.0")}`,e=typeof location>"u"?void 0:new URL("/railways/index.json",location.href).href;return(e&&e!==bm?[e,bm]:[bm]).map(i=>i+t)}}function $b(){return{elevation:qb(),imagery:Zb(),roads:x5(),water:w5(),railways:S5()}}function qb(){return new p5(new Pe,new Xb)}function Zb(){return new Kb}function x5(){return new th({fallback:new M5(new ko,new Co)})}function w5(){return new eh({fallback:new Rs(new v5(new kd,new Ac))})}function S5(){return new nh({fallback:new dn(new y5(new Fo,new ih))})}const b5=new Set,bh="show-observer-map",Eh="hide-milestones",Oc="minified";class He extends HTMLElement{static get observedAttributes(){return["src",bh,Eh,Oc]}shadow;stageElement;canvas;canvasRenderer;chromeCanvas;chromeRenderer;chromeResizeObserver=typeof ResizeObserver>"u"?void 0:new ResizeObserver(()=>{this.chromeDirty&&this.refresh()});chromeDirty=!1;tooltip;toolbar;issuesBox;issuesButton;issuesPanel;playPauseButton;fullscreenButton;cornerButtons;observerMapButton;referencesButton;tracesButton;tracesShownState=!0;referenceOpacityInput;referencesShownState=!0;accountHidden=!1;referenceViews=new Map;referencesMenu;referenceOpacityTouched=!1;milestonesButton;observerMapPanel;observerMapCanvas;observerMapRenderer;mapZoomInButton;mapZoomOutButton;mapFitButton;observerMapView=new gi;observerMapDrag;suppressObserverMapClick=!1;observerMapImageryTimer;observerPlacing=!1;seekInput;playbackFlash;milestoneMarks;citedMarks;cited=[];milestoneCaption;timeStartLabel;timeEndLabel;timePill;muteButton;volumeInput;controlsRow;momentsBox;momentsButton;momentsCurrent;momentsMenu;moreButton;controlsRight;seekSegments;seekDot;playerTitleBox;seekPreview;seekPreviewCanvas;seekPreviewTitle;seekPreviewTime;observerPath;observerMapBounds;observerMapImagery;observerMapImageryBounds;observerMapImageryViewWidth=0;observerMapImageryLoading=!1;observerMapImageryCredit;observerMapImageryFailed=!1;creditShownExternally=!1;lookYawDeg=0;lookPitchDeg=0;milestonesShown=!0;currentSighting=Bp.create();issues=[];issueCheck=0;sightingAudio=new P2;liveSightingAudio;hearInto(t){t?(this.liveSightingAudio??=this.sightingAudio,this.sightingAudio=new P2(t)):this.liveSightingAudio&&(this.sightingAudio.dispose(),this.sightingAudio=this.liveSightingAudio,this.liveSightingAudio=void 0)}soundPreview;player;loopEnabled=!1;playbackBeforeClick;highlightedSourceIds=new Set;paintsShapes=!0;steadyObserver=!1;static LIVE_BODY_MAX_RATE=2;get steadyBody(){return this.steadyObserver||this.player.playbackState!=="playing"||this.player.playbackRate>He.LIVE_BODY_MAX_RATE}selectionShown=!0;overlayPainter;enableClickToPlay=!0;fullscreenTarget;ready=Promise.resolve();messages;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");He.setIcon(this.moreButton,t?Qt.UNFOLDED:Qt.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()}videoElement;videoButton;set filmer(t){if(this.videoElement?.remove(),this.videoButton?.panel.remove(),this.videoButton=void 0,this.videoElement=void 0,!t){this.fitControls();return}const e=document.createElement("button");e.type="button",e.id="video-button",e.innerHTML=Qt.VIDEO,this.videoElement=e,this.labelVideoButton(),e.addEventListener("click",i=>{i.stopPropagation(),this.loadVideoButton(t,e)},{once:!0}),this.moreButton.after(e),this.fitControls()}async loadVideoButton(t,e){const{VideoButton:i}=await dt(async()=>{const{VideoButton:s}=await import("./VideoButton-Cy_r767Z.js");return{VideoButton:s}},[],import.meta.url);if(this.videoElement!==e)return;const n=new i(t,e);this.videoButton=n,this.messages&&(n.messages=this.messages),this.stageElement.append(n.panel),n.open()}labelVideoButton(){const t=this.videoElement;!t||this.videoButton||(t.title=this.messages?.recordVideo??"",t.setAttribute("aria-label",t.title))}get filmDescription(){return this.messages?.videoDescription}get hasObserverMap(){return this.observerPath!==void 0}mapBeforeFilm;filmMap(t){t!==void 0?(this.mapBeforeFilm??=!this.observerMapPanel.hidden,t&&this.observerPath&&this.setObserverMapOpen(!0)):this.mapBeforeFilm!==void 0&&(this.setObserverMapOpen(this.mapBeforeFilm&&this.observerPath!==void 0),this.mapBeforeFilm=void 0)}filmChrome(t){const e=this.currentTime,i=t.caption&&this.sighting.milestones.length>0?uf(this.sighting.milestones,e):void 0,n=i?this.said.read(i.label)??"":void 0,s=this.canvas.getBoundingClientRect(),r=t.map&&!this.observerMapPanel.hidden?this.observerMapPanel.getBoundingClientRect():void 0;return{...i?{caption:{label:n,note:this.said.read(i.note)}}:{},...t.time?{time:this.formatPosition(e)}:{},...r&&s.width>0&&s.height>0?{map:{canvas:this.observerMapCanvas,left:(r.left-s.left)/s.width,top:(r.top-s.top)/s.height,width:r.width/s.width,height:r.height/s.height}}:{}}}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)<He.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>=gi.MAX_ZOOM,this.mapZoomOutButton.disabled=this.observerMapView.zoomFactor<=gi.MIN_ZOOM,this.paintObserverMap(this.currentTime),this.scheduleObserverMapImagery()}scheduleObserverMapImagery(){this.observerMapImageryTimer===void 0&&(this.observerMapImageryTimer=setTimeout(()=>{this.observerMapImageryTimer=void 0,this.loadObserverMapImagery()},He.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=gi.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>${x3}</style>${y3}`,this.shadow.appendChild(t.content.cloneNode(!0)),this.stageElement=this.shadow.getElementById("stage"),this.canvas=this.shadow.getElementById("canvas"),this.canvasRenderer=new Gh(this.canvas.getContext("2d")),this.chromeCanvas=this.shadow.getElementById("chrome"),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",a=>{a.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.tracesButton=this.shadow.getElementById("traces"),this.referenceOpacityInput=this.shadow.getElementById("reference-opacity"),this.referencesMenu=this.shadow.getElementById("references-menu"),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 Ec(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.citedMarks=this.shadow.getElementById("cited-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.playerTitleBox=this.shadow.getElementById("player-title"),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",a=>{a.key!=="Enter"&&a.key!==" "||(a.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.miniPlayed=this.shadow.getElementById("mini-played"),this.miniRemaining=this.shadow.getElementById("mini-remaining"),this.miniMuteButton=this.shadow.getElementById("mini-mute"),this.miniDot=this.shadow.getElementById("mini-dot"),this.miniScrubTime=this.shadow.getElementById("mini-scrub-time");const e=this.shadow.getElementById("mini-bar"),i=e.querySelector(".mini-track"),n=a=>{const c=i.getBoundingClientRect(),l=this.player.seekableDuration;if(c.width<=0||l<=0)return;const h=Math.min(Math.max((a.clientX-c.left)/c.width,0),1)*l;this.player.seek(h),this.miniScrubTime.textContent=this.formatElapsedAt(h),this.miniScrubTime.style.left=this.miniDot.style.left};let s=!1;e.addEventListener("pointerdown",a=>{a.button===0&&(a.stopPropagation(),e.setPointerCapture(a.pointerId),e.classList.add("scrubbing"),s=this.playRequested,this.pause(),this.miniScrubTime.hidden=!1,n(a))}),e.addEventListener("pointermove",a=>{e.hasPointerCapture(a.pointerId)&&n(a)});const r=a=>{e.classList.contains("scrubbing")&&(e.classList.remove("scrubbing"),e.hasPointerCapture(a.pointerId)&&e.releasePointerCapture(a.pointerId),this.miniScrubTime.hidden=!0,s&&this.play())};e.addEventListener("pointerup",r),e.addEventListener("pointercancel",r),e.addEventListener("click",a=>a.stopPropagation()),this.miniMuteButton.addEventListener("click",a=>{a.stopPropagation(),this.toggleMuted()}),this.stageElement.addEventListener("pointerenter",this.handleMinifiedEnter),this.stageElement.addEventListener("pointerleave",this.handleMinifiedLeave),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.tracesButton.addEventListener("click",()=>this.toggleTraces()),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.announceReveal()}),this.seekInput.addEventListener("pointerdown",a=>{this.suspendForScrub(),this.seekSnapArmed=!0,this.nameMarkUnder(a),this.seekPreview.hidden=!0,this.beginTouchScrub(a)}),this.seekInput.addEventListener("pointerup",a=>{this.seekSnapArmed=!1,this.endTouchScrub(a)}),this.seekInput.addEventListener("pointercancel",a=>this.endTouchScrub(a)),this.seekInput.addEventListener("pointermove",a=>{this.nameMarkUnder(a),this.hoverSeek(a),this.touchScrub(a)}),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 a of["touchend","click"])this.stageElement.addEventListener(a,()=>this.sightingAudio.resume(),!0);this.stageElement.addEventListener("pointermove",()=>this.touchedStage()),this.canvas.addEventListener("click",a=>{if(!(!this.enableClickToPlay||this.minified)){if(this.tapRevealedOnly){this.tapRevealedOnly=!1;return}a.detail<=1&&(this.playbackBeforeClick={state:this.playbackState,time:this.currentTime}),this.togglePlayPause()}}),this.canvas.addEventListener("dblclick",a=>{!this.enableClickToPlay||this.minified||(a.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.chromeResizeObserver?.observe(this.chromeCanvas),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.updateTracesButton(),this.updateMilestonesButton(),this.refresh()}connectedCallback(){this.saidTexts=void 0,this.ready=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.chromeResizeObserver?.disconnect(),this.controlsFitObserver?.disconnect(),this.controlsMutations?.disconnect(),this.exitSimulatedFullscreen(),this.sightingAudio.dispose()}attributeChangedCallback(t,e,i){if(t==="src"&&i&&i!==e&&this.isConnected&&this.loadFromSrc(i),t===bh&&this.applyObserverMapDefault(),t===Eh&&this.setMilestonesShown(!this.hasAttribute(Eh)),t===Oc){const n=this.minified;this.stageElement.classList.toggle("minified",n),n&&e===null&&(this.muted=!0),this.updateStartState()}}get minified(){return this.hasAttribute(Oc)}miniPlayed;miniRemaining;miniMuteButton;handleMinifiedEnter=t=>{!this.minified||t.pointerType==="touch"||(this.minifiedHovered=!0,this.play())};minifiedHovered=!1;handleMinifiedLeave=t=>{!this.minified||t.pointerType==="touch"||(this.minifiedHovered=!1,this.pause(),this.dispatchEvent(new CustomEvent(jb)))};started=!1;updateStartState(){this.playRequested&&(this.started=!0);const t=!this.started&&this.enableClickToPlay;this.stageElement.classList.toggle("unstarted",t),t&&!this.minified?this.canvas.title=this.messages?.clickToPlay??"":this.canvas.removeAttribute("title")}async loadFromSrc(t){this.sightingData=await hd.recording(t)}get sightingData(){return Ob(this.currentSighting)}set sightingData(t){const e=la.recording(t);this.player.stop(),this.soundPreview=void 0,this.sightingAudio.silence(),this.currentSighting=Lb(e),this.observerMapSnapshotSource&&(this.observerMapSnapshot=this.observerMapSnapshotSource(this.currentSighting.snapshots)),this.issuesPanel.hidden=!0,this.issuesButton.setAttribute("aria-expanded","false"),this.reportIssues(e,this.currentSighting),this.observerMapView.reset(),this.mapFitButton.hidden=!0,this.observerMapAsked=!1,this.player=this.createPlayer(),this.started=!1,this.syncPlayerTitle(),this.updateTimeLabels(),this.updatePlayPauseButton(),this.refresh(),this.applyObserverMapDefault(),this.minified&&this.minifiedHovered&&this.play()}set playerTitle(t){this.titleOverride=t,this.syncPlayerTitle()}titleOverride;set titleShown(t){this.titleHidden=!t,this.syncPlayerTitle()}get titleShown(){return!this.titleHidden}titleHidden=!1;syncPlayerTitle(){const t=this.said.read(this.titleOverride)??this.said.read(this.currentSighting.observer?.title)??"";this.playerTitleBox.textContent=t,this.playerTitleBox.hidden=t===""||this.titleHidden}get recordingIssues(){return this.issues}async reportIssues(t,e){const i=++this.issueCheck;let n=[];try{const{default:s}=await dt(async()=>{const{default:r}=await import("./sightingSchema-CgwoRMl-.js");return{default:r}},[],import.meta.url);n=new lr(s).issues(t)}catch{}i===this.issueCheck&&(this.issues=[...n,...e.loadIssues],Ld.warn(this.issues,e.id),this.renderIssues(),this.dispatchEvent(new CustomEvent(A5,{detail:{issues:this.issues},bubbles:!0,composed:!0})))}renderIssues(){if(!this.messages)return;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=Ld.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(){if(!(this.player.seekableDuration<=0||this.playbackState==="playing")){if(this.clockHeld){this.playAfterHold=!0,this.announcePlayRequest();return}this.togglePlayPause()}}get playRequested(){return this.playbackState==="playing"||this.playAfterHold}announcePlayRequest(){this.announceReveal(),this.dispatchEvent(new CustomEvent("playrequest"))}announceReveal(){this.started=!0,this.updateStartState(),this.dispatchEvent(new CustomEvent("revealrequest"))}clockHeld=!1;playAfterHold=!1;holdClock(t){if(t!==this.clockHeld){if(this.clockHeld=t,t){if(this.playbackState!=="playing")return;this.playAfterHold=!0,this.player.pause(),this.soundPreview=void 0,this.sightingAudio.silence(),this.refresh(),this.updatePlayPauseButton();return}this.playAfterHold&&(this.playAfterHold=!1,!(this.player.seekableDuration<=0||this.playbackState==="playing")&&(this.sightingAudio.resume(),this.player.play(),this.updatePlayPauseButton()))}}pause(){this.playAfterHold=!1,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}set citedMoments(t){this.cited=[...t],this.refreshCitedMarks()}refreshCitedMarks(){const t=this.player.seekableDuration;this.citedMarks.replaceChildren(...(t>0?this.cited:[]).map(e=>{const i=document.createElement("button");i.type="button",i.className="cited-mark",i.innerHTML=Ie.INTERVIEW,i.style.left=`${Math.min(Math.max(e.at*1e3/t,0),1)*100}%`;const n=e.quote??"";return i.title=n,i.setAttribute("aria-label",n),i.addEventListener("click",()=>this.player.seek(e.at*1e3)),i}))}sayTimeMoved(t){Math.abs(t-this.timeSaid)<He.TIME_SAID_EVERY_MS||(this.timeSaid=t,this.dispatchEvent(new CustomEvent(E5,{bubbles:!0,composed:!0,detail:{at:t/1e3}})))}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 playbackRate(){return this.player.playbackRate}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.updateMuteButton(),this.updateTimeLabels(),this.seekInput.max=String(this.player.seekableDuration),this.refreshMilestoneMarks(),this.updateMilestonesButton(),this.updateObserverMap(),this.updateReferences(),this.updateTracesButton(),this.player.seek(this.player.time)}repaintOverlay(){this.quietFrame=!0;try{this.player.seek(this.player.time)}finally{this.quietFrame=!1}}quietFrame=!1;hostControls(t){const e=[this.milestonesButton,this.referencesButton,this.referenceOpacityInput,this.tracesButton,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)}get severalReferences(){return this.currentSighting.references.length>1}toggleReferences(){if(this.severalReferences){this.toggleReferencesMenu();return}this.referencesShownState=!this.referencesShownState,this.updateReferencesButton(),this.dispatchReferenceView()}updateReferences(){const t=this.currentSighting.references;if(!this.referenceOpacityTouched&&t.length>0){const e=String(t[0].opacity);this.referenceOpacityInput.value!==e&&(this.referenceOpacityInput.value=e,this.severalReferences||this.dispatchReferenceView())}for(const e of[...this.referenceViews.keys()])t.some(i=>i.id===e)||this.referenceViews.delete(e);this.severalReferences?this.referencesMenu.hidden||this.renderReferencesMenu():this.closeReferencesMenu(),this.updateReferencesButton(),this.severalReferences&&this.dispatchReferenceView()}viewOfReference(t){let e=this.referenceViews.get(t.id);return e||(e={shown:!0,opacity:t.opacity},this.referenceViews.set(t.id,e)),e}toggleReferencesMenu(){this.referencesMenu.hidden?this.openReferencesMenu():this.closeReferencesMenu()}openReferencesMenu(){this.renderReferencesMenu(),this.referencesMenu.hidden=!1,this.placeReferencesMenu(),this.referencesButton.setAttribute("aria-expanded","true"),document.addEventListener("pointerdown",this.handleReferencesMenuOutside,!0),document.addEventListener("keydown",this.handleReferencesMenuKey,!0)}closeReferencesMenu(){this.referencesMenu.hidden||(this.referencesMenu.hidden=!0,this.referencesButton.setAttribute("aria-expanded","false"),document.removeEventListener("pointerdown",this.handleReferencesMenuOutside,!0),document.removeEventListener("keydown",this.handleReferencesMenuKey,!0))}handleReferencesMenuOutside=t=>{const e=t.composedPath();e.includes(this.referencesMenu)||e.includes(this.referencesButton)||this.closeReferencesMenu()};handleReferencesMenuKey=t=>{t.key==="Escape"&&(this.closeReferencesMenu(),this.referencesButton.focus())};placeReferencesMenu(){const t=this.referencesButton.getBoundingClientRect(),e=this.referencesMenu,i=4;e.style.bottom=`${Math.max(i,window.innerHeight-t.top+i)}px`,e.style.top="auto";const n=e.getBoundingClientRect().width;e.style.left=`${Math.max(i,Math.min(t.left,window.innerWidth-n-i))}px`}renderReferencesMenu(){const t=this.currentSighting.references.map(e=>{const i=this.viewOfReference(e),n=this.said.read(e.title)??e.id,s=document.createElement("div");s.className="reference-row";const r=document.createElement("label"),a=document.createElement("input");a.type="checkbox",a.checked=i.shown;const c=document.createElement("span");c.textContent=n,c.title=n,r.append(a,c);const l=document.createElement("input");return l.type="range",l.min="0",l.max="1",l.step="0.05",l.value=String(i.opacity),l.title=this.messages?.referenceOpacity??"",l.setAttribute("aria-label",`${this.messages?.referenceOpacity??""}: ${n}`),l.disabled=!i.shown,a.addEventListener("change",()=>{i.shown=a.checked,l.disabled=!i.shown,this.updateReferencesButton(),this.dispatchReferenceView()}),l.addEventListener("input",()=>{i.opacity=Number(l.value),this.dispatchReferenceView()}),s.append(r,l),s});this.referencesMenu.setAttribute("aria-label",this.messages?.referencesMenu??""),this.referencesMenu.replaceChildren(...t)}updateReferencesButton(){const t=this.currentSighting.references.length>0,e=this.severalReferences,i=e?this.currentSighting.references.some(s=>this.viewOfReference(s).shown):this.referencesShownState;this.referencesButton.hidden=!t,this.referenceOpacityInput.hidden=!t||!this.referencesShownState||e,this.referencesButton.setAttribute("aria-pressed",String(i)),e?this.referencesButton.setAttribute("aria-haspopup","true"):this.referencesButton.removeAttribute("aria-haspopup"),He.setIcon(this.referencesButton,i?Qt.PICTURES_ON:Qt.PICTURES_OFF);const n=e?this.messages?.referencesMenu??"":this.referencesShownState?this.messages?.hideReferences??"":this.messages?.showReferences??"";this.referencesButton.title=n,this.referencesButton.setAttribute("aria-label",n),this.referenceOpacityInput.title=this.messages?.referenceOpacity??"",this.referenceOpacityInput.setAttribute("aria-label",this.messages?.referenceOpacity??"")}get tracesShown(){return this.tracesShownState}toggleTraces(){this.tracesShownState=!this.tracesShownState,this.updateTracesButton(),this.updateObserverMap(),this.dispatchEvent(new CustomEvent("traceview",{detail:{shown:this.tracesShown}}))}updateTracesButton(){this.tracesButton.hidden=this.currentSighting.traces.length===0,this.tracesButton.setAttribute("aria-pressed",String(this.tracesShownState)),He.setIcon(this.tracesButton,this.tracesShownState?Qt.TRACES_ON:Qt.TRACES_OFF);const t=this.tracesShownState?this.messages?.hideTraces??"":this.messages?.showTraces??"";this.tracesButton.title=t,this.tracesButton.setAttribute("aria-label",t)}dispatchReferenceView(){const t=this.severalReferences?Object.fromEntries(this.currentSighting.references.map(e=>[e.id,{...this.viewOfReference(e)}])):void 0;this.dispatchEvent(new CustomEvent("referenceview",{detail:{shown:this.referencesShown,opacity:this.referenceOpacity,views:t}}))}refreshMilestoneMarks(){const t=this.player.seekableDuration,e=t>0?Hu(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)??"",r=this.said.read(i.note),a=r?`${s} — ${r}`:s;return n.title=a,n.setAttribute("aria-label",a),n.dataset.t=String(i.t),n.addEventListener("click",()=>this.player.seek(i.t)),n})),this.refreshCitedMarks(),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 r=this.said.read(i.label)??"",a=this.said.read(i.note);return s.textContent=a?`${r} — ${a}`:r,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(r=>r>0&&r<t))].sort((r,a)=>r-a):[],Math.max(t,0)];this.seekSegmentList=[];const s=[];for(let r=0;r<n.length-1;r++){const a=document.createElement("div");a.className="seek-segment",a.style.flexGrow=String(Math.max(n[r+1]-n[r],1));const c=document.createElement("i");c.className="seek-hover";const l=document.createElement("i");l.className="seek-played",a.append(c,l),s.push(a),this.seekSegmentList.push({start:n[r],end:n[r+1],element:a,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}%`}paintMiniProgress(t){const e=this.player.seekableDuration,i=`${e>0?Math.min(Math.max(t/e,0),1)*100:0}%`;this.miniPlayed.style.width=i,this.miniDot.style.left=i,this.miniRemaining.textContent=this.formatRemaining(t)}miniDot;miniScrubTime;paintSeekProgress(t){for(const i of this.seekSegmentList)i.played.style.width=He.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){if(t.buttons!==0){this.seekPreview.hidden=!0;return}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,r=this.seekSegmentList.length-1;this.seekSegmentList.forEach((f,p)=>{f.hover.style.width=He.fillOf(f,s),f.element.classList.toggle("hovered",s>=f.start&&(s<f.end||p===r))});const a=this.milestonesShown?this.sighting.milestones:[],c=a.length>0?uf(a,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)}paintChrome(t){const e=this.chromeCanvas.getContext("2d"),i=this.overlayPainter!==void 0||this.selectionShown;if(!i&&!this.chromeDirty)return;const n=this.chromeCanvas.clientWidth,s=this.chromeCanvas.clientHeight;if(!e||typeof e.setTransform!="function"||n===0||s===0){t(this.canvasRenderer);return}const r=window.devicePixelRatio||1,a=Math.max(1,Math.round(n*r)),c=Math.max(1,Math.round(s*r));this.chromeCanvas.width!==a&&(this.chromeCanvas.width=a),this.chromeCanvas.height!==c&&(this.chromeCanvas.height=c),e.setTransform(1,0,0,1,0,0),e.clearRect(0,0,a,c),this.chromeDirty=!1,i&&(e.setTransform(a/this.canvas.width,0,0,c/this.canvas.height,0,0),this.chromeRenderer??=new Gh(e),this.chromeDirty=!0,t(this.chromeRenderer))}chromeDraw;repaintChrome(){this.chromeDraw&&this.overlayPainter&&this.paintChrome(this.chromeDraw)}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=He.MARK_SNAP_PX/i*e;let s;for(const r of this.milestoneMarks.children){const a=Number(r.dataset.t);Math.abs(a-t)>n||(!s||Math.abs(a-t)<Math.abs(s.t-t))&&(s={t:a,name:r.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?uf(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=ns.windowEndingAt(t,this.currentSighting.exposure??0);if(e.ms<He.SHORTEST_VISIBLE_EXPOSURE_MS)return[t];const i=Math.min(He.MAX_EXPOSURE_STEPS,Math.max(2,Math.round(e.ms/He.SHORTEST_VISIBLE_EXPOSURE_MS))),n=Math.ceil(this.travelPxOver(e.fromMs,e.ms)/He.EXPOSURE_STEP_PX),s=Math.min(He.MAX_TRAVEL_STEPS,Math.max(i,n)),r=[];for(let a=0;a<s;a++)r.push(e.fromMs+e.ms*a/(s-1));return r}travelPxOver(t,e){const i=this.shapesAt(t),n=this.shapesAt(t+e);let s=0;for(const[r,a]of i){const c=n.get(r);if(!c)continue;const l=c.bounds.x+c.bounds.width/2-(a.bounds.x+a.bounds.width/2),h=c.bounds.y+c.bounds.height/2-(a.bounds.y+a.bounds.height/2);s=Math.max(s,Math.hypot(l,h))}return s}shapeAt(t,e,i){if(!this.accountHidden)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=Ji.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}}timeSaid=Number.NEGATIVE_INFINITY;static TIME_SAID_EVERY_MS=100;onFrame(t,e){this.sayTimeMoved(t),this.canvasRenderer.clear(this.canvas.width,this.canvas.height);const i=this.playbackState!=="playing"?this.highlightedSourceIds:b5;this.canvasRenderer.setStarPoints(Ji.starPointsOf(this.sighting.instrument,ke(this.sighting,t)?.fNumber));const n=(ke(this.sighting,t)?.rollDeg??0)+this.gaitAt(t).rollDeg;this.canvasRenderer.setRoll(n*Math.PI/180);const s=this.exposureInstants(t),r=this.frameShift;if(this.paintsShapes)for(const c of s)for(const[,l]of c.shapes){const h=c.share,u=h===1?l:{...l,transparency:1-(1-l.transparency)*h};this.canvasRenderer.paintShape(this.shifted(u,r))}for(const[c,l]of s[0].shapes)!this.selectionShown||!i.has(c)||(this.paintsShapes?i.size===1?this.canvasRenderer.paintShape({...l,selected:!0}):this.canvasRenderer.paintMemberOutline(l):this.canvasRenderer.paintSelectionOnly(this.shifted(l,r)));const a=this.selectionShown&&i.size>1?Zs.groupBoundsFor([...e].filter(([c])=>i.has(c)).map(([,c])=>c.bounds)):void 0;this.chromeDraw=c=>{a&&c.paintGroupHandles(a),this.overlayPainter?.(c)},this.paintChrome(this.chromeDraw),this.mapShapeBounds=s.flatMap(c=>[...c.shapes.values()].filter(l=>l.transparency<1).map(l=>this.shifted(l,r).bounds)),this.keepObserverMapClear(),this.seekInput.value=String(t),this.paintSeekProgress(t),this.minified&&this.paintMiniProgress(t),this.timeStartLabel.textContent=this.formatPosition(t),this.showMilestoneAt(t),this.paintObserverMap(t),this.playbackState==="playing"||this.liveSightingAudio?(this.soundPreview=void 0,this.sightingAudio.setSound(z_(this.currentSighting,t))):this.soundPreview?this.sightingAudio.setSound(this.soundPreview):this.sightingAudio.silence(),this.updatePlayPauseButton(),!this.quietFrame&&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 B_(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*He.SEEK_KEY_STEP_MS)))}else t.key===" "&&(t.preventDefault(),this.togglePlayPause())};togglePlayPause(){if(!(this.player.seekableDuration<=0)){if(this.player.playbackState==="playing")this.player.pause(),this.soundPreview=void 0,this.sightingAudio.silence(),this.refresh();else if(this.clockHeld){this.playAfterHold=!this.playAfterHold,this.playAfterHold&&this.announcePlayRequest();return}else this.announcePlayRequest(),this.sightingAudio.resume(),this.player.play();this.updatePlayPauseButton(),this.flashPlayback()}}flashPlayback(){const t=this.playbackFlash;t.innerHTML=this.player.playbackState==="playing"?Qt.PLAY:Qt.PAUSE,t.classList.remove("flashing"),t.offsetWidth,t.classList.add("flashing")}static icons=new WeakMap;static setIcon(t,e){He.icons.get(t)!==e&&(He.icons.set(t,e),t.innerHTML=e)}set captionHeld(t){this.stageElement.classList.toggle("caption-held",t)}set controlsHeld(t){this.stageElement.classList.toggle("controls-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},He.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.stageElement.classList.contains("touched"))&&this.revealControls(),this.wasPlaying=t,this.updateStartState(),He.setIcon(this.playPauseButton,t?Qt.PAUSE:Qt.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(),this.dispatchEvent(new CustomEvent("observermapchange",{bubbles:!0,composed:!0,detail:{open:t}}))}get observerMapOpen(){return!this.observerMapPanel.hidden}get milestonesVisible(){return this.milestonesShown}observerMapAsked=!1;applyObserverMapDefault(){const t=this.getAttribute(bh),e=t===null?this.sighting.observerMap??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;He.setIcon(this.observerMapButton,t?Qt.MAP_ON:Qt.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=yh.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.tracesShownState?this.currentSighting.traces.flatMap(n=>n.points):[],i=gi.fitted(this.observerPath,e);(!this.observerMapBounds||!this.sameGround(this.observerMapBounds,i))&&(this.observerMapBounds&&this.observerMapView.refit(this.observerMapBounds,i),this.observerMapBounds=i,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.observerMapSnapshotImagery?this.observerMapImageryBounds!==void 0:!this.observerMapImageryNeededFor(t)))return;const e=this.observerMapView.changed,i=e?gi.expand(t,He.OBSERVER_MAP_IMAGERY_AHEAD):t,n=gi.IMAGERY_PX*(e?1+2*He.OBSERVER_MAP_IMAGERY_AHEAD:1);this.observerMapImageryBounds=i,this.observerMapImageryViewWidth=t.east-t.west,this.observerMapImageryLoading=!0;const s=this.observerMapSnapshotImagery,r=s?void 0:Zb();try{const a=r?await r.getImageryTexture(i,{width:n,height:n}):await s.getImagery();if(this.observerMapImageryBounds!==i)return;this.observerMapImagery=a,this.observerMapImageryCredit=(r??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?gi.expand(t,He.OBSERVER_MAP_IMAGERY_LOOKAHEAD):t,s=n.west>=i.west&&n.east<=i.east&&n.south>=i.south&&n.north<=i.north,r=t.east-t.west>this.observerMapImageryViewWidth/2;return!s||!r}get observerMapCredit(){return this.observerMapImageryCredit}set observerMapSnapshot(t){t!==this.observerMapSnapshotImagery&&(this.observerMapSnapshotImagery=t,this.observerMapImagery=void 0,this.observerMapImageryCredit=void 0,this.observerMapImageryFailed=!1,this.observerMapImageryBounds=void 0,this.observerMapImageryLoading=!1,this.observerMapPanel.hidden||(this.loadObserverMapImagery(),this.paintObserverMap(this.currentTime)))}get observerMapSnapshot(){return this.observerMapSnapshotImagery}observerMapSnapshotImagery;observerMapSnapshotSource;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],r=He.OBSERVER_MAP_CLEARANCE_PX,a=i(...n,0),c=i(...s,0);if(this.observerMapPanel.classList.toggle("subject-overlap",a&&c&&!this.observerMapAsked),this.observerMapPanel.classList.contains("on-the-left")){!a&&(c||!i(n[0],n[1],r))&&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=ke(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},He.OBSERVER_MAP_FOLLOW_MARGIN)&&this.scheduleObserverMapImagery();const i=this.currentSighting.instrument,n=[],s=this.currentSighting.milestones.length>0?uf(this.currentSighting.milestones,t):void 0;for(const r of this.milestonesShown?Hu(this.currentSighting.milestones):[]){const a=ke(this.currentSighting,r.t);a?.lat===void 0||a.lng===void 0||n.push({label:this.said.read(r.label)??"",note:this.said.read(r.note),t:r.t,lat:a.lat,lng:a.lng,current:r===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?da.of(i,this.canvas.height,e.fovDeg).halfWidthAngleDeg(Ji.aspectOf(i)):void 0,markers:n,traces:(this.tracesShownState?this.currentSighting.traces:[]).map(r=>({kind:r.kind,points:r.points,color:r.color,label:this.said.read(r.title)})),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,Hu(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??"",He.setIcon(this.milestonesButton,this.milestonesShown?Qt.MILESTONES_ON:Qt.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=ke(this.currentSighting,0);return e?.lat===void 0||e.lng===void 0?[]:this.currentSighting.decor.filter(i=>i.kind!=="crop").map(i=>{const n=ga(i,t),{lat:s,lng:r}=zs(n.eastM,-n.northM,e.lat,e.lng);return{lat:s,lng:r,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=ke(this.currentSighting,this.currentTime),s=da.of(this.currentSighting.instrument,this.canvas.height,n?.fovDeg??60);return{x:-s.angleDegToRadiusPx(e),y:s.angleDegToRadiusPx(i)}}gaitAt(t){return oi.bodyAt(this.currentSighting,t,this.steadyBody)}mutedState=!1;get muted(){return this.mutedState}set muted(t){t!==this.mutedState&&(this.mutedState=t,!t&&this.volumeState===0&&(this.volumeState=He.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.hasSound&&(this.muted=!this.mutedState)}ambientSound;get audible(){return this.hasSound}refreshSoundControls(){this.updateMuteButton()}get hasSound(){return this.currentSighting.soundTrack.allKeyframes.length>0||this.ambientSound?.(this.currentSighting)===!0}updateMuteButton(){const t=!this.hasSound;this.miniMuteButton.hidden=t,this.miniMuteButton.setAttribute("aria-pressed",String(this.mutedState)),He.setIcon(this.miniMuteButton,this.mutedState?Qt.MUTED:Qt.VOLUME);const e=this.mutedState?this.messages?.unmute??"":this.messages?.mute??"";if(this.miniMuteButton.title=e,this.miniMuteButton.setAttribute("aria-label",e),this.muteButton.disabled=t,this.volumeInput.hidden=t,t){He.setIcon(this.muteButton,Qt.MUTED),this.muteButton.title=this.messages?.noSound??"",this.muteButton.setAttribute("aria-label",this.messages?.noSound??""),this.muteButton.setAttribute("aria-pressed","true");return}He.setIcon(this.muteButton,this.mutedState?Qt.MUTED:Qt.VOLUME);const i=this.mutedState?this.messages?.unmute??"":this.messages?.mute??"";this.muteButton.title=i,this.muteButton.setAttribute("aria-label",i),this.muteButton.setAttribute("aria-pressed",String(this.mutedState)),this.volumeInput.value=String(this.level)}updateFullscreenButton(){const t=this.simulatedFullscreen||document.fullscreenElement===this.fullscreenTarget;He.setIcon(this.fullscreenButton,t?Qt.EXIT_FULLSCREEN:Qt.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 Cr(Lo.preferencesFor(this))}saidTexts;async loadLocaleMessages(){const t=I0(Lo.preferencesFor(this),C0);if(t===this.messagesLanguage)return;this.messagesLanguage=t;const e=await Q_.load(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.videoButton&&(this.videoButton.messages=t),this.labelVideoButton(),this.volumeInput.title=t.volume,this.volumeInput.setAttribute("aria-label",t.volume),this.updateMoreButton(),this.updateStartState(),this.referencesMenu.hidden||this.renderReferencesMenu(),this.refreshMilestoneMarks(),this.paintObserverMap(this.currentTime),this.updateTimeLabelTitles(),this.updatePlayPauseButton(),this.updateFullscreenButton(),this.updateMuteButton(),this.updateObserverMapButton(),this.updateReferencesButton(),this.updateTracesButton(),this.updateMilestonesButton(),this.renderIssues()}updateTimeLabels(){const t=this.currentSighting.event,e=k_(t);this.realDurationMs=e!==void 0&&e>0?e:void 0,this.realStartMs=t.time?u1(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.paintMiniProgress(this.player.time),this.updateTimeLabelTitles()}formatPosition(t){if(this.realDurationMs===void 0)return po(t);const e=this.currentSighting.timeline.duration,i=e>0&&t<=e?t/e*this.realDurationMs:t;return this.canShowClockTime?B2(z2(this.realStartMs+i)):po(i)}formatElapsedAt(t){const e=this.currentSighting.timeline.duration;return this.realDurationMs===void 0?po(t):po(e>0&&t<=e?t/e*this.realDurationMs:t)}formatRemaining(t){const e=this.currentSighting.timeline.duration;if(this.realDurationMs===void 0)return po(Math.max(0,e-t));const i=e>0&&t<=e?t/e*this.realDurationMs:t;return po(Math.max(0,this.realDurationMs-i))}formatEndOfTimeline(){return this.realDurationMs===void 0?po(this.currentSighting.timeline.duration):this.canShowClockTime?B2(z2(this.realStartMs+this.realDurationMs)):po(this.realDurationMs)}}function z2(o){const t=new Date(o);return{hour:t.getUTCHours(),minute:t.getUTCMinutes(),second:t.getUTCSeconds()}}function B2(o){if(o.hour===void 0)return"0:00";const t=e=>String(e).padStart(2,"0");return o.second?`${t(o.hour)}:${t(o.minute??0)}:${t(o.second)}`:`${t(o.hour)}:${t(o.minute??0)}`}function po(o){const t=Math.round(o/1e3),e=Math.floor(t/60),i=t%60;return`${e}:${String(i).padStart(2,"0")}`}const f1="rr0-ufo";function Jb(){customElements.get(f1)||customElements.define(f1,He)}const E5="timechange",A5="recordingissues",jb="minifiedreset";/**
|
|
1935
|
+
`);let e=th.shared.get(t);return e||(e=this.fetchFirstAvailable(),th.shared.set(t,e),e.then(i=>{i.length===0&&th.shared.delete(t)})),this.index=e}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.192.0")}`,e=typeof location>"u"?void 0:new URL("/roads/index.json",location.href).href;return(e&&e!==wm?[e,wm]:[wm]).map(i=>i+t)}}class ko{attribution="Roads © IGN, BD TOPO (Licence Ouverte 2.0), as drawn today";contemporary=!0;static BY_NATURE={"Type autoroutier":{surface:"paved",widthM:11},"Route à 2 chaussées":{surface:"paved",widthM:7},"Route à 1 chaussée":{surface:"paved",widthM:5.5},"Rond-point":{surface:"paved",widthM:6},Bretelle:{surface:"paved",widthM:5},"Route empierrée":{surface:"gravel",widthM:3.5},Chemin:{surface:"dirt",widthM:3},"Piste cyclable":{surface:"paved",widthM:2.5}};static DEFAULT={surface:"paved",widthM:5};static KINDS={"Type autoroutier":"motorway","Route à 2 chaussées":"dual","Route à 1 chaussée":"road","Rond-point":"roundabout",Bretelle:"slip"};static DIRECTIONS={"Double sens":"both","Sens direct":"forward","Sens inverse":"backward"};platform;constructor(t={}){this.platform=new Fe(t)}static covers(t){return Fe.covers((t.south+t.north)/2,(t.west+t.east)/2)}async getRoads(t){return(await this.platform.roads(t)).flatMap((i,n)=>ko.wayOf(i,n))}static wayOf(t,e){if(t.geometry.type!=="LineString")return[];const i=t.geometry.coordinates.map(([d,f])=>({lat:f,lng:d}));if(i.length<2)return[];const n=String(t.properties.nature??""),s=ko.BY_NATURE[n]??ko.DEFAULT,r=Number(t.properties.largeur_de_chaussee),a=Number(t.properties.nombre_de_voies),c=Number(t.properties.vitesse_moyenne_vl),l=ko.DIRECTIONS[String(t.properties.sens_de_circulation??"")],h=ko.KINDS[n],u=[t.properties.cpx_toponyme_route_nommee,t.properties.nom_voie_ban_gauche,t.properties.nom_voie_ban_droite].find(d=>typeof d=="string"&&d.length>0);return[{id:String(t.properties.cleabs??`ign-${e}`),...u?{name:u}:{},surface:s.surface,widthM:Number.isFinite(r)&&r>0?r:s.widthM,...t.properties.urbain===!0?{urban:!0}:{},...h?{kind:h}:{},...Number.isInteger(a)&&a>0?{lanes:a}:{},...l?{direction:l}:{},...Number.isFinite(c)&&c>0?{speedKmh:c}:{},points:i}]}}class M5{constructor(t,e){this.regional=t,this.worldwide=e}attribution="Roads © IGN, BD TOPO, in France; © OpenStreetMap contributors elsewhere, as drawn today";contemporary=!0;async getRoads(t){if(ko.covers(t))try{const e=await this.regional.getRoads(t);if(e.length>0)return e}catch{}return this.worldwide.getRoads(t)}}class kd{attribution="Water © IGN, BD TOPO (Licence Ouverte 2.0)";platform;constructor(t={}){this.platform=new Fe(t)}static covers(t){return Fe.covers((t.south+t.north)/2,(t.west+t.east)/2)}async getWater(t){return(await this.platform.waterSurfaces(t)).flatMap((i,n)=>kd.surfacesOf(i,n))}static surfacesOf(t,e){const{type:i,coordinates:n}=t.geometry,s=i==="Polygon"?[n]:i==="MultiPolygon"?n:[],r=String(t.properties.cleabs??`ign-water-${e}`);return s.flatMap((a,c)=>{const l=a.map(h=>kd.open(h.map(u=>({lat:u[1],lng:u[0]})))).filter(h=>h.length>=3);return l.length>0?[{id:s.length>1?`${r}-${c}`:r,rings:l}]:[]})}static open(t){const e=t[0],i=t[t.length-1];return t.length>1&&e.lat===i.lat&&e.lng===i.lng?t.slice(0,-1):t}}class Ac{attribution="Water © OpenStreetMap contributors";client;constructor(t={}){this.client=new ks(t)}async getWater(t){const e=`${t.south},${t.west},${t.north},${t.east}`,i=`[out:json][timeout:30];(way["natural"="water"](${e});way["waterway"="riverbank"](${e});)->.w;(relation["natural"="water"](${e});relation["waterway"="riverbank"](${e});)->.r;.w out geom;.r out body;way(r.r)(${e});out geom;`;return Ac.surfacesFrom(await this.client.query(i))}static surfacesFrom(t){const e=t.elements??[],i=new Map;for(const r of e)r.type==="way"&&r.id!==void 0&&r.geometry&&i.set(r.id,r.geometry.map(a=>({lat:a.lat,lng:a.lon})));const n=[],s=new Set;for(const r of e){if(r.type!=="relation")continue;const a=l=>(r.members??[]).filter(h=>h.type==="way"&&h.role===l&&h.ref!==void 0&&i.has(h.ref)).map(h=>(s.add(h.ref),i.get(h.ref))),c=Ac.rings(a("inner"));for(const[l,h]of Ac.rings(a("outer")).entries()){const u=c.filter(d=>Ac.contains(h,d[0]));n.push({id:`osm-r${r.id}-${l}`,rings:[h,...u]})}}for(const r of e)if(!(r.type!=="way"||!r.tags||r.id===void 0||s.has(r.id))&&!(r.tags.natural!=="water"&&r.tags.waterway!=="riverbank"))for(const a of Ac.rings([i.get(r.id)??[]]))n.push({id:`osm-w${r.id}`,rings:[a]});return n}static rings(t){const e=(s,r)=>s.lat===r.lat&&s.lng===r.lng,i=t.filter(s=>s.length>=2).map(s=>[...s]),n=[];for(;i.length>0;){let s=i.pop(),r=!0;for(;!e(s[0],s[s.length-1])&&r;){r=!1;for(let a=0;a<i.length;a++){const c=i[a],l=s[s.length-1];if(e(l,c[0]))s=[...s,...c.slice(1)];else if(e(l,c[c.length-1]))s=[...s,...[...c].reverse().slice(1)];else continue;i.splice(a,1),r=!0;break}}s.length>=4&&e(s[0],s[s.length-1])&&n.push(s.slice(0,-1))}return n}static contains(t,e){let i=!1;for(let n=0,s=t.length-1;n<t.length;s=n++){const r=t[n],a=t[s];r.lat>e.lat!=a.lat>e.lat&&e.lng<(a.lng-r.lng)*(e.lat-r.lat)/(a.lat-r.lat)+r.lng&&(i=!i)}return i}}class v5{constructor(t,e){this.regional=t,this.worldwide=e}attribution="Water © IGN, BD TOPO, in France; © OpenStreetMap contributors elsewhere";async getWater(t){if(kd.covers(t))try{const e=await this.regional.getWater(t);if(e.length>0)return e}catch{}return this.worldwide.getWater(t)}}const Sm="https://ufoathome.org/water/index.json";class eh{attributionRead;fetchImpl;indexUrls;fallback;index;static shared=new Map;sharing;constructor(t={}){this.sharing=!t.fetchImpl,this.fetchImpl=t.fetchImpl??fetch.bind(globalThis),this.indexUrls=t.indexUrls??eh.defaultIndexUrls(),this.fallback=t.fallback}get attribution(){return this.attributionRead??this.fallback?.attribution??"Water © OpenStreetMap contributors"}async getWater(t){const e=await this.held(t);if(e)return e;if(!this.fallback)return[];const i=await this.fallback.getWater(t);return this.attributionRead=this.fallback.attribution,i}async held(t){const i=(await this.load().catch(()=>[])).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?.surfaces)?(this.attributionRead=s.attribution,s.surfaces):void 0}catch{return}}load(){if(this.index)return this.index;if(!this.sharing)return this.index=this.fetchFirstAvailable();const t=this.indexUrls.join(`
|
|
1936
|
+
`);let e=eh.shared.get(t);return e||(e=this.fetchFirstAvailable(),eh.shared.set(t,e),e.then(i=>{i.length===0&&eh.shared.delete(t)})),this.index=e}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.192.0")}`,e=typeof location>"u"?void 0:new URL("/water/index.json",location.href).href;return(e&&e!==Sm?[e,Sm]:[Sm]).map(i=>i+t)}}class Rs{constructor(t){this.water=t}static CACHE_NAME="rr0-water";static MAX_AGE_MS=720*3600*1e3;static FORMAT=1;static MAX_STORED=400;static asked=new Map;get attribution(){return this.water.attribution}async getWater(t){const e=Rs.key(t);let i=Rs.asked.get(e);return i===void 0&&(i=this.recalled(e,t),Rs.asked.set(e,i),i.catch(()=>Rs.asked.delete(e))),structuredClone(await i)}static forget(){Rs.asked.clear()}static key(t){return`v${Rs.FORMAT}/${[t.north,t.south,t.east,t.west].map(e=>e.toFixed(5)).join("/")}`}async recalled(t,e){const i=await Rs.openCache(),n=Rs.request(t);if(i)try{const r=await i.match(n);if(r){const{savedAt:a,surfaces:c}=await r.json();if(Date.now()-a<Rs.MAX_AGE_MS&&Array.isArray(c))return c;await i.delete(n)}}catch{}const s=await this.water.getWater(e);return i&&Rs.store(i,n,s),s}static async store(t,e,i){try{const n={savedAt:Date.now(),surfaces:i};await t.put(e,new Response(JSON.stringify(n),{headers:{"Content-Type":"application/json"}}));const s=await t.keys();for(const r of s.slice(0,Math.max(0,s.length-Rs.MAX_STORED)))await t.delete(r)}catch{}}static async openCache(){try{return typeof caches>"u"?void 0:await caches.open(Rs.CACHE_NAME)}catch{return}}static request(t){const e=typeof location>"u"?"http://localhost":location.origin;return new Request(`${e}/__water__/${encodeURIComponent(t)}`)}}class Fo{attribution="Railways © IGN, BD TOPO (Licence Ouverte 2.0), as drawn today";contemporary=!0;static BY_NATURE={"Voie ferrée principale":{kind:"rail"},LGV:{kind:"rail",highSpeed:!0},"Voie de service":{kind:"rail",service:!0},Métro:{kind:"subway"},Tramway:{kind:"tram"},"Transport urbain":{kind:"light_rail"},"Funiculaire ou crémaillère":{kind:"funicular"}};static GAUGE_MM={Normale:1435,Etroite:1e3,Étroite:1e3,Large:1668};static NO_ALTITUDE=-1e3;platform;constructor(t={}){this.platform=new Fe(t)}static covers(t){return Fe.covers((t.south+t.north)/2,(t.west+t.east)/2)}async getRailways(t){return(await this.platform.railways(t)).flatMap((i,n)=>Fo.linesOf(i,n))}static linesOf(t,e){const{type:i,coordinates:n}=t.geometry,s=i==="LineString"?[n]:i==="MultiLineString"?n:[],r=Fo.BY_NATURE[String(t.properties.nature??"")];if(!r)return[];const a=String(t.properties.cleabs??`ign-rail-${e}`),c=Number(t.properties.nombre_de_voies),l=Number(t.properties.position_par_rapport_au_sol),h=t.properties.cpx_toponyme,u=Fo.GAUGE_MM[String(t.properties.largeur??"")]??1435,d=Fo.electrificationOf(r.kind,u,t.properties.electrifie);return s.flatMap((f,p)=>{const g=f.map(m=>({lat:m[1],lng:m[0],...m.length>2&&Number.isFinite(m[2])&&m[2]>Fo.NO_ALTITUDE?{altitudeM:m[2]}:{}}));return g.length<2?[]:[{id:s.length>1?`${a}-${p}`:a,...typeof h=="string"&&h.length>0?{name:h}:{},kind:r.kind,...r.service?{service:!0}:{},...r.highSpeed?{highSpeed:!0}:{},gaugeMm:u,tracks:Number.isInteger(c)&&c>0?c:1,...d?{electrification:d}:{},level:Number.isFinite(l)?l:0,points:g}]})}static electrificationOf(t,e,i){if(i===!1)return"none";if(i===!0){if(t==="subway")return"third_rail";if(!(t==="funicular"||e<1435))return"overhead"}}}class Xn{static NEAR_M=15;static ALIGNED_DEG=30;static SAMPLE_M=10;static ROUTES="train|subway|light_rail|tram|monorail";static KINDS="rail|light_rail|subway|tram|narrow_gauge|funicular|preserved";client;constructor(t={}){this.client=new ks(t)}async named(t,e){if(t.length===0)return[...t];const i=`${e.south},${e.west},${e.north},${e.east}`,n=`[out:json][timeout:120];way["railway"~"^(${Xn.KINDS})$"](${i})->.w;.w out tags geom;rel(bw.w)["route"~"^(${Xn.ROUTES})$"];out body;`;return Xn.apply(t,await this.client.query(n),e)}static apply(t,e,i){const n={lat:(i.north+i.south)/2,lng:(i.east+i.west)/2},s=Xn.ways(e,n);return s.length===0?[...t]:t.map(r=>{const a=r.points.map(M=>ae(M.lat,M.lng,n.lat,n.lng)),c=new Map,l=new Map,h=new Map;let u=0;const d=s.filter(M=>M.service===!!r.service);for(const M of Xn.samples(a)){u++;const v=Xn.waysAt(d,M);if(v.length===0)continue;const[x]=v;x.name&&c.set(x.name,(c.get(x.name)??0)+1),x.voltageV&&l.set(x.voltageV,(l.get(x.voltageV)??0)+1);for(const y of new Set(v.flatMap(w=>w.services)))h.set(y,(h.get(y)??0)+1)}const f=M=>[...M.entries()].sort((v,x)=>x[1]-v[1])[0]?.[0],p=r.name??f(c),g=r.voltageV??(r.electrification==="none"?void 0:f(l)),m=[...h.entries()].filter(([,M])=>M*4>=u).sort((M,v)=>v[1]-M[1]||M[0].localeCompare(v[0])).map(([M])=>M);return{...r,...p?{name:p}:{},...g?{voltageV:g}:{},...m.length>0?{services:m}:{}}})}static serviceOf(t){const e=t.name?.split(" : ")[0].replace(/\s*\([^)]*\)\s*$/,"").trim();return e||[t.network,t.ref].filter(Boolean).join(" ")||void 0}static servicesByWay(t){const e=new Map;for(const i of t.elements??[]){if(i.type!=="relation"||!i.tags)continue;const n=Xn.serviceOf(i.tags);if(n)for(const s of i.members??[]){if(s.type!=="way"||s.ref===void 0)continue;const r=e.get(s.ref)??new Set;r.add(n),e.set(s.ref,r)}}return e}static voltageOf(t){const e=Number.parseInt((t.voltage??"").split(";")[0],10);return Number.isFinite(e)&&e>0?e:void 0}static ways(t,e){const i=Xn.servicesByWay(t),n=[];for(const s of t.elements??[]){if(s.type!=="way"||!s.geometry||s.geometry.length<2)continue;const r=s.tags??{},a=Xn.voltageOf(r);n.push({service:!!r.service||r.usage==="industrial",...r.name?{name:r.name}:{},...a?{voltageV:a}:{},services:[...i.get(s.id??-1)??[]],path:s.geometry.map(c=>ae(c.lat,c.lon,e.lat,e.lng))})}return n}static samples(t){const e=[];for(let i=0;i<t.length-1;i++){const n=Math.hypot(t[i+1].x-t[i].x,t[i+1].z-t[i].z);if(n<1e-6)continue;const s=(t[i+1].x-t[i].x)/n,r=(t[i+1].z-t[i].z)/n;for(let a=Xn.SAMPLE_M/2;a<n;a+=Xn.SAMPLE_M)e.push({x:t[i].x+s*a,z:t[i].z+r*a,dx:s,dz:r})}return e}static waysAt(t,e){const i=Math.cos(Xn.ALIGNED_DEG*Math.PI/180),n=[];for(const s of t){let r;for(let a=0;a<s.path.length-1;a++){const c=s.path[a],l=s.path[a+1],h=l.x-c.x,u=l.z-c.z,d=Math.hypot(h,u);if(d<1e-6||Math.abs((h*e.dx+u*e.dz)/d)<i)continue;const f=Math.max(0,Math.min(1,((e.x-c.x)*h+(e.z-c.z)*u)/(d*d))),p=Math.hypot(e.x-(c.x+h*f),e.z-(c.z+u*f));p<=Xn.NEAR_M&&(r===void 0||p<r)&&(r=p)}r!==void 0&&n.push({way:s,distance:r})}return n.sort((s,r)=>s.distance-r.distance).map(({way:s})=>s)}}class ih{attribution="Railways © OpenStreetMap contributors, as surveyed today";contemporary=!0;static KINDS=["rail","light_rail","tram","subway","narrow_gauge","funicular","preserved"];client;constructor(t={}){this.client=new ks(t)}async getRailways(t){const e=`${t.south},${t.west},${t.north},${t.east}`,i=`[out:json][timeout:25];way["railway"~"^(${ih.KINDS.join("|")})$"](${e})->.w;.w out tags geom;rel(bw.w)["route"~"^(${Xn.ROUTES})$"];out body;`;return this.linesFrom(await this.client.query(i))}linesFrom(t){const e=[],i=Xn.servicesByWay(t);for(const n of t.elements??[]){const s=n.geometry,r=n.tags;if(n.type==="relation"||!r||!s||s.length<2)continue;const a=[...i.get(n.id??-1)??[]].sort(),c=Xn.voltageOf(r),l=ih.kindOf(r),h=Number.parseInt((r.gauge??"").split(";")[0],10),u=Number.parseInt(r.tracks??"",10),d=ih.electrificationOf(r.electrified),f=r.highspeed==="yes"||Number.parseInt(r.maxspeed??"",10)>=250;e.push({id:`osm-rail-${n.id??e.length}`,...r.name?{name:r.name}:{},...a.length>0?{services:a}:{},...c?{voltageV:c}:{},kind:l,...r.service||r.usage==="industrial"?{service:!0}:{},...f?{highSpeed:!0}:{},gaugeMm:Number.isFinite(h)&&h>300?h:r.railway==="narrow_gauge"?1e3:1435,tracks:Number.isFinite(u)&&u>0?u:1,...d?{electrification:d}:{},level:ih.levelOf(r),points:s.map(p=>({lat:p.lat,lng:p.lon}))})}return e}static kindOf(t){switch(t.railway){case"tram":return"tram";case"subway":return"subway";case"light_rail":return"light_rail";case"funicular":return"funicular";default:return"rail"}}static electrificationOf(t){if(t!==void 0){if(t==="no")return"none";if(t==="contact_line"||t==="yes")return"overhead";if(t==="rail"||t==="4th_rail"||t==="ground-level_power_supply")return"third_rail"}}static levelOf(t){const e=Number.parseInt(t.layer??"",10);return t.tunnel&&t.tunnel!=="no"?Number.isFinite(e)&&e<0?e:-1:t.covered==="yes"&&t.location==="underground"?-1:t.bridge&&t.bridge!=="no"?Number.isFinite(e)&&e>0?e:1:0}}class y5{constructor(t,e){this.regional=t,this.worldwide=e}attribution="Railways © IGN, BD TOPO, in France; © OpenStreetMap contributors elsewhere, as drawn today";contemporary=!0;async getRailways(t){if(!Fo.covers(t))return this.worldwide.getRailways(t);let e;try{if(e=await this.regional.getRailways(t),e.length>0)return e}catch{}try{return await this.worldwide.getRailways(t)}catch(i){if(e)return e;throw i}}}class dn{constructor(t,e=Date.now){this.railways=t,this.now=e}static CACHE_NAME="rr0-railways";static MAX_AGE_MS=720*3600*1e3;static FORMAT=1;static MAX_STORED=400;static RETRY_AFTER_MS=300*1e3;static asked=new Map;static failedAt=-1/0;get attribution(){return this.railways.attribution}get contemporary(){return this.railways.contemporary}async getRailways(t){const e=dn.key(t);let i=dn.asked.get(e)??dn.containing(t);if(i===void 0){const n=this.recalled(e,t);i={bounds:t,answer:n},dn.asked.set(e,i),n.catch(()=>dn.asked.delete(e))}return structuredClone(await i.answer)}static forget(){dn.asked.clear(),dn.failedAt=-1/0}static key(t){return`v${dn.FORMAT}/${[t.north,t.south,t.east,t.west].map(e=>e.toFixed(5)).join("/")}`}static containing(t){for(const e of dn.asked.values()){const i=e.bounds;if(i.north>=t.north&&i.south<=t.south&&i.east>=t.east&&i.west<=t.west)return e}}async recalled(t,e){const i=await dn.openCache(),n=dn.request(t);let s;if(i)try{const a=await i.match(n);if(a){const{savedAt:c,lines:l}=await a.json();if(Array.isArray(l)){if(this.now()-c<dn.MAX_AGE_MS)return l;s=l}}}catch{}if(this.now()-dn.failedAt<dn.RETRY_AFTER_MS){if(s)return s;throw new Error("The railway survey failed a moment ago: not asked again yet")}let r;try{r=await this.railways.getRailways(e)}catch(a){if(dn.failedAt=this.now(),s)return s;throw a}return i&&dn.store(i,n,{savedAt:this.now(),lines:r}),r}static async store(t,e,i){try{await t.delete(e),await t.put(e,new Response(JSON.stringify(i),{headers:{"Content-Type":"application/json"}}));const n=await t.keys();for(const s of n.slice(0,Math.max(0,n.length-dn.MAX_STORED)))await t.delete(s)}catch{}}static async openCache(){try{return typeof caches>"u"?void 0:await caches.open(dn.CACHE_NAME)}catch{return}}static request(t){const e=typeof location>"u"?"http://localhost":location.origin;return new Request(`${e}/__railways__/${encodeURIComponent(t)}`)}}const bm="https://ufoathome.org/railways/index.json";class nh{contemporary=!0;attributionRead;fetchImpl;indexUrls;fallback;index;static shared=new Map;sharing;constructor(t={}){this.sharing=!t.fetchImpl,this.fetchImpl=t.fetchImpl??fetch.bind(globalThis),this.indexUrls=t.indexUrls??nh.defaultIndexUrls(),this.fallback=t.fallback}get attribution(){return this.attributionRead??this.fallback?.attribution??"Railways © OpenStreetMap contributors"}async getRailways(t){const e=await this.held(t);if(e)return e;if(!this.fallback)return[];const i=await this.fallback.getRailways(t);return this.attributionRead=this.fallback.attribution,i}async held(t){const i=(await this.load().catch(()=>[])).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?.lines)?(this.attributionRead=s.attribution,s.lines):void 0}catch{return}}load(){if(this.index)return this.index;if(!this.sharing)return this.index=this.fetchFirstAvailable();const t=this.indexUrls.join(`
|
|
1937
|
+
`);let e=nh.shared.get(t);return e||(e=this.fetchFirstAvailable(),nh.shared.set(t,e),e.then(i=>{i.length===0&&nh.shared.delete(t)})),this.index=e}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.192.0")}`,e=typeof location>"u"?void 0:new URL("/railways/index.json",location.href).href;return(e&&e!==bm?[e,bm]:[bm]).map(i=>i+t)}}function $b(){return{elevation:qb(),imagery:Zb(),roads:x5(),water:w5(),railways:S5()}}function qb(){return new p5(new Pe,new Xb)}function Zb(){return new Kb}function x5(){return new th({fallback:new M5(new ko,new Co)})}function w5(){return new eh({fallback:new Rs(new v5(new kd,new Ac))})}function S5(){return new nh({fallback:new dn(new y5(new Fo,new ih))})}const b5=new Set,bh="show-observer-map",Eh="hide-milestones",Oc="minified";class He extends HTMLElement{static get observedAttributes(){return["src",bh,Eh,Oc]}shadow;stageElement;canvas;canvasRenderer;chromeCanvas;chromeRenderer;chromeResizeObserver=typeof ResizeObserver>"u"?void 0:new ResizeObserver(()=>{this.chromeDirty&&this.refresh()});chromeDirty=!1;tooltip;toolbar;issuesBox;issuesButton;issuesPanel;playPauseButton;fullscreenButton;cornerButtons;observerMapButton;referencesButton;tracesButton;tracesShownState=!0;referenceOpacityInput;referencesShownState=!0;accountHidden=!1;referenceViews=new Map;referencesMenu;referenceOpacityTouched=!1;milestonesButton;observerMapPanel;observerMapCanvas;observerMapRenderer;mapZoomInButton;mapZoomOutButton;mapFitButton;observerMapView=new gi;observerMapDrag;suppressObserverMapClick=!1;observerMapImageryTimer;observerPlacing=!1;seekInput;playbackFlash;milestoneMarks;citedMarks;cited=[];milestoneCaption;timeStartLabel;timeEndLabel;timePill;muteButton;volumeInput;controlsRow;momentsBox;momentsButton;momentsCurrent;momentsMenu;moreButton;controlsRight;seekSegments;seekDot;playerTitleBox;seekPreview;seekPreviewCanvas;seekPreviewTitle;seekPreviewTime;observerPath;observerMapBounds;observerMapImagery;observerMapImageryBounds;observerMapImageryViewWidth=0;observerMapImageryLoading=!1;observerMapImageryCredit;observerMapImageryFailed=!1;creditShownExternally=!1;lookYawDeg=0;lookPitchDeg=0;milestonesShown=!0;currentSighting=Bp.create();issues=[];issueCheck=0;sightingAudio=new P2;liveSightingAudio;hearInto(t){t?(this.liveSightingAudio??=this.sightingAudio,this.sightingAudio=new P2(t)):this.liveSightingAudio&&(this.sightingAudio.dispose(),this.sightingAudio=this.liveSightingAudio,this.liveSightingAudio=void 0)}soundPreview;player;loopEnabled=!1;playbackBeforeClick;highlightedSourceIds=new Set;paintsShapes=!0;steadyObserver=!1;static LIVE_BODY_MAX_RATE=2;get steadyBody(){return this.steadyObserver||this.player.playbackState!=="playing"||this.player.playbackRate>He.LIVE_BODY_MAX_RATE}selectionShown=!0;overlayPainter;enableClickToPlay=!0;fullscreenTarget;ready=Promise.resolve();messages;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");He.setIcon(this.moreButton,t?Qt.UNFOLDED:Qt.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()}videoElement;videoButton;set filmer(t){if(this.videoElement?.remove(),this.videoButton?.panel.remove(),this.videoButton=void 0,this.videoElement=void 0,!t){this.fitControls();return}const e=document.createElement("button");e.type="button",e.id="video-button",e.innerHTML=Qt.VIDEO,this.videoElement=e,this.labelVideoButton(),e.addEventListener("click",i=>{i.stopPropagation(),this.loadVideoButton(t,e)},{once:!0}),this.moreButton.after(e),this.fitControls()}async loadVideoButton(t,e){const{VideoButton:i}=await dt(async()=>{const{VideoButton:s}=await import("./VideoButton-Cy_r767Z.js");return{VideoButton:s}},[],import.meta.url);if(this.videoElement!==e)return;const n=new i(t,e);this.videoButton=n,this.messages&&(n.messages=this.messages),this.stageElement.append(n.panel),n.open()}labelVideoButton(){const t=this.videoElement;!t||this.videoButton||(t.title=this.messages?.recordVideo??"",t.setAttribute("aria-label",t.title))}get filmDescription(){return this.messages?.videoDescription}get hasObserverMap(){return this.observerPath!==void 0}mapBeforeFilm;filmMap(t){t!==void 0?(this.mapBeforeFilm??=!this.observerMapPanel.hidden,t&&this.observerPath&&this.setObserverMapOpen(!0)):this.mapBeforeFilm!==void 0&&(this.setObserverMapOpen(this.mapBeforeFilm&&this.observerPath!==void 0),this.mapBeforeFilm=void 0)}filmChrome(t){const e=this.currentTime,i=t.caption&&this.sighting.milestones.length>0?uf(this.sighting.milestones,e):void 0,n=i?this.said.read(i.label)??"":void 0,s=this.canvas.getBoundingClientRect(),r=t.map&&!this.observerMapPanel.hidden?this.observerMapPanel.getBoundingClientRect():void 0;return{...i?{caption:{label:n,note:this.said.read(i.note)}}:{},...t.time?{time:this.formatPosition(e)}:{},...r&&s.width>0&&s.height>0?{map:{canvas:this.observerMapCanvas,left:(r.left-s.left)/s.width,top:(r.top-s.top)/s.height,width:r.width/s.width,height:r.height/s.height}}:{}}}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)<He.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>=gi.MAX_ZOOM,this.mapZoomOutButton.disabled=this.observerMapView.zoomFactor<=gi.MIN_ZOOM,this.paintObserverMap(this.currentTime),this.scheduleObserverMapImagery()}scheduleObserverMapImagery(){this.observerMapImageryTimer===void 0&&(this.observerMapImageryTimer=setTimeout(()=>{this.observerMapImageryTimer=void 0,this.loadObserverMapImagery()},He.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=gi.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>${x3}</style>${y3}`,this.shadow.appendChild(t.content.cloneNode(!0)),this.stageElement=this.shadow.getElementById("stage"),this.canvas=this.shadow.getElementById("canvas"),this.canvasRenderer=new Gh(this.canvas.getContext("2d")),this.chromeCanvas=this.shadow.getElementById("chrome"),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",a=>{a.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.tracesButton=this.shadow.getElementById("traces"),this.referenceOpacityInput=this.shadow.getElementById("reference-opacity"),this.referencesMenu=this.shadow.getElementById("references-menu"),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 Ec(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.citedMarks=this.shadow.getElementById("cited-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.playerTitleBox=this.shadow.getElementById("player-title"),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",a=>{a.key!=="Enter"&&a.key!==" "||(a.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.miniPlayed=this.shadow.getElementById("mini-played"),this.miniRemaining=this.shadow.getElementById("mini-remaining"),this.miniMuteButton=this.shadow.getElementById("mini-mute"),this.miniDot=this.shadow.getElementById("mini-dot"),this.miniScrubTime=this.shadow.getElementById("mini-scrub-time");const e=this.shadow.getElementById("mini-bar"),i=e.querySelector(".mini-track"),n=a=>{const c=i.getBoundingClientRect(),l=this.player.seekableDuration;if(c.width<=0||l<=0)return;const h=Math.min(Math.max((a.clientX-c.left)/c.width,0),1)*l;this.player.seek(h),this.miniScrubTime.textContent=this.formatElapsedAt(h),this.miniScrubTime.style.left=this.miniDot.style.left};let s=!1;e.addEventListener("pointerdown",a=>{a.button===0&&(a.stopPropagation(),e.setPointerCapture(a.pointerId),e.classList.add("scrubbing"),s=this.playRequested,this.pause(),this.miniScrubTime.hidden=!1,n(a))}),e.addEventListener("pointermove",a=>{e.hasPointerCapture(a.pointerId)&&n(a)});const r=a=>{e.classList.contains("scrubbing")&&(e.classList.remove("scrubbing"),e.hasPointerCapture(a.pointerId)&&e.releasePointerCapture(a.pointerId),this.miniScrubTime.hidden=!0,s&&this.play())};e.addEventListener("pointerup",r),e.addEventListener("pointercancel",r),e.addEventListener("click",a=>a.stopPropagation()),this.miniMuteButton.addEventListener("click",a=>{a.stopPropagation(),this.toggleMuted()}),this.stageElement.addEventListener("pointerenter",this.handleMinifiedEnter),this.stageElement.addEventListener("pointerleave",this.handleMinifiedLeave),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.tracesButton.addEventListener("click",()=>this.toggleTraces()),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.announceReveal()}),this.seekInput.addEventListener("pointerdown",a=>{this.suspendForScrub(),this.seekSnapArmed=!0,this.nameMarkUnder(a),this.seekPreview.hidden=!0,this.beginTouchScrub(a)}),this.seekInput.addEventListener("pointerup",a=>{this.seekSnapArmed=!1,this.endTouchScrub(a)}),this.seekInput.addEventListener("pointercancel",a=>this.endTouchScrub(a)),this.seekInput.addEventListener("pointermove",a=>{this.nameMarkUnder(a),this.hoverSeek(a),this.touchScrub(a)}),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 a of["touchend","click"])this.stageElement.addEventListener(a,()=>this.sightingAudio.resume(),!0);this.stageElement.addEventListener("pointermove",()=>this.touchedStage()),this.canvas.addEventListener("click",a=>{if(!(!this.enableClickToPlay||this.minified)){if(this.tapRevealedOnly){this.tapRevealedOnly=!1;return}a.detail<=1&&(this.playbackBeforeClick={state:this.playbackState,time:this.currentTime}),this.togglePlayPause()}}),this.canvas.addEventListener("dblclick",a=>{!this.enableClickToPlay||this.minified||(a.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.chromeResizeObserver?.observe(this.chromeCanvas),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.updateTracesButton(),this.updateMilestonesButton(),this.refresh()}connectedCallback(){this.saidTexts=void 0,this.ready=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.chromeResizeObserver?.disconnect(),this.controlsFitObserver?.disconnect(),this.controlsMutations?.disconnect(),this.exitSimulatedFullscreen(),this.sightingAudio.dispose()}attributeChangedCallback(t,e,i){if(t==="src"&&i&&i!==e&&this.isConnected&&this.loadFromSrc(i),t===bh&&this.applyObserverMapDefault(),t===Eh&&this.setMilestonesShown(!this.hasAttribute(Eh)),t===Oc){const n=this.minified;this.stageElement.classList.toggle("minified",n),n&&e===null&&(this.muted=!0),this.updateStartState()}}get minified(){return this.hasAttribute(Oc)}miniPlayed;miniRemaining;miniMuteButton;handleMinifiedEnter=t=>{!this.minified||t.pointerType==="touch"||(this.minifiedHovered=!0,this.play())};minifiedHovered=!1;handleMinifiedLeave=t=>{!this.minified||t.pointerType==="touch"||(this.minifiedHovered=!1,this.pause(),this.dispatchEvent(new CustomEvent(jb)))};started=!1;updateStartState(){this.playRequested&&(this.started=!0);const t=!this.started&&this.enableClickToPlay;this.stageElement.classList.toggle("unstarted",t),t&&!this.minified?this.canvas.title=this.messages?.clickToPlay??"":this.canvas.removeAttribute("title")}async loadFromSrc(t){this.sightingData=await hd.recording(t)}get sightingData(){return Ob(this.currentSighting)}set sightingData(t){const e=la.recording(t);this.player.stop(),this.soundPreview=void 0,this.sightingAudio.silence(),this.currentSighting=Lb(e),this.observerMapSnapshotSource&&(this.observerMapSnapshot=this.observerMapSnapshotSource(this.currentSighting.snapshots)),this.issuesPanel.hidden=!0,this.issuesButton.setAttribute("aria-expanded","false"),this.reportIssues(e,this.currentSighting),this.observerMapView.reset(),this.mapFitButton.hidden=!0,this.observerMapAsked=!1,this.player=this.createPlayer(),this.started=!1,this.syncPlayerTitle(),this.updateTimeLabels(),this.updatePlayPauseButton(),this.refresh(),this.applyObserverMapDefault(),this.minified&&this.minifiedHovered&&this.play()}set playerTitle(t){this.titleOverride=t,this.syncPlayerTitle()}titleOverride;set titleShown(t){this.titleHidden=!t,this.syncPlayerTitle()}get titleShown(){return!this.titleHidden}titleHidden=!1;syncPlayerTitle(){const t=this.said.read(this.titleOverride)??this.said.read(this.currentSighting.observer?.title)??"";this.playerTitleBox.textContent=t,this.playerTitleBox.hidden=t===""||this.titleHidden}get recordingIssues(){return this.issues}async reportIssues(t,e){const i=++this.issueCheck;let n=[];try{const{default:s}=await dt(async()=>{const{default:r}=await import("./sightingSchema-CgwoRMl-.js");return{default:r}},[],import.meta.url);n=new lr(s).issues(t)}catch{}i===this.issueCheck&&(this.issues=[...n,...e.loadIssues],Ld.warn(this.issues,e.id),this.renderIssues(),this.dispatchEvent(new CustomEvent(A5,{detail:{issues:this.issues},bubbles:!0,composed:!0})))}renderIssues(){if(!this.messages)return;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=Ld.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(){if(!(this.player.seekableDuration<=0||this.playbackState==="playing")){if(this.clockHeld){this.playAfterHold=!0,this.announcePlayRequest();return}this.togglePlayPause()}}get playRequested(){return this.playbackState==="playing"||this.playAfterHold}announcePlayRequest(){this.announceReveal(),this.dispatchEvent(new CustomEvent("playrequest"))}announceReveal(){this.started=!0,this.updateStartState(),this.dispatchEvent(new CustomEvent("revealrequest"))}clockHeld=!1;playAfterHold=!1;holdClock(t){if(t!==this.clockHeld){if(this.clockHeld=t,t){if(this.playbackState!=="playing")return;this.playAfterHold=!0,this.player.pause(),this.soundPreview=void 0,this.sightingAudio.silence(),this.refresh(),this.updatePlayPauseButton();return}this.playAfterHold&&(this.playAfterHold=!1,!(this.player.seekableDuration<=0||this.playbackState==="playing")&&(this.sightingAudio.resume(),this.player.play(),this.updatePlayPauseButton()))}}pause(){this.playAfterHold=!1,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}set citedMoments(t){this.cited=[...t],this.refreshCitedMarks()}refreshCitedMarks(){const t=this.player.seekableDuration;this.citedMarks.replaceChildren(...(t>0?this.cited:[]).map(e=>{const i=document.createElement("button");i.type="button",i.className="cited-mark",i.innerHTML=Ie.INTERVIEW,i.style.left=`${Math.min(Math.max(e.at*1e3/t,0),1)*100}%`;const n=e.quote??"";return i.title=n,i.setAttribute("aria-label",n),i.addEventListener("click",()=>this.player.seek(e.at*1e3)),i}))}sayTimeMoved(t){Math.abs(t-this.timeSaid)<He.TIME_SAID_EVERY_MS||(this.timeSaid=t,this.dispatchEvent(new CustomEvent(E5,{bubbles:!0,composed:!0,detail:{at:t/1e3}})))}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 playbackRate(){return this.player.playbackRate}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.updateMuteButton(),this.updateTimeLabels(),this.seekInput.max=String(this.player.seekableDuration),this.refreshMilestoneMarks(),this.updateMilestonesButton(),this.updateObserverMap(),this.updateReferences(),this.updateTracesButton(),this.player.seek(this.player.time)}repaintOverlay(){this.quietFrame=!0;try{this.player.seek(this.player.time)}finally{this.quietFrame=!1}}quietFrame=!1;hostControls(t){const e=[this.milestonesButton,this.referencesButton,this.referenceOpacityInput,this.tracesButton,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)}get severalReferences(){return this.currentSighting.references.length>1}toggleReferences(){if(this.severalReferences){this.toggleReferencesMenu();return}this.referencesShownState=!this.referencesShownState,this.updateReferencesButton(),this.dispatchReferenceView()}updateReferences(){const t=this.currentSighting.references;if(!this.referenceOpacityTouched&&t.length>0){const e=String(t[0].opacity);this.referenceOpacityInput.value!==e&&(this.referenceOpacityInput.value=e,this.severalReferences||this.dispatchReferenceView())}for(const e of[...this.referenceViews.keys()])t.some(i=>i.id===e)||this.referenceViews.delete(e);this.severalReferences?this.referencesMenu.hidden||this.renderReferencesMenu():this.closeReferencesMenu(),this.updateReferencesButton(),this.severalReferences&&this.dispatchReferenceView()}viewOfReference(t){let e=this.referenceViews.get(t.id);return e||(e={shown:!0,opacity:t.opacity},this.referenceViews.set(t.id,e)),e}toggleReferencesMenu(){this.referencesMenu.hidden?this.openReferencesMenu():this.closeReferencesMenu()}openReferencesMenu(){this.renderReferencesMenu(),this.referencesMenu.hidden=!1,this.placeReferencesMenu(),this.referencesButton.setAttribute("aria-expanded","true"),document.addEventListener("pointerdown",this.handleReferencesMenuOutside,!0),document.addEventListener("keydown",this.handleReferencesMenuKey,!0)}closeReferencesMenu(){this.referencesMenu.hidden||(this.referencesMenu.hidden=!0,this.referencesButton.setAttribute("aria-expanded","false"),document.removeEventListener("pointerdown",this.handleReferencesMenuOutside,!0),document.removeEventListener("keydown",this.handleReferencesMenuKey,!0))}handleReferencesMenuOutside=t=>{const e=t.composedPath();e.includes(this.referencesMenu)||e.includes(this.referencesButton)||this.closeReferencesMenu()};handleReferencesMenuKey=t=>{t.key==="Escape"&&(this.closeReferencesMenu(),this.referencesButton.focus())};placeReferencesMenu(){const t=this.referencesButton.getBoundingClientRect(),e=this.referencesMenu,i=4;e.style.bottom=`${Math.max(i,window.innerHeight-t.top+i)}px`,e.style.top="auto";const n=e.getBoundingClientRect().width;e.style.left=`${Math.max(i,Math.min(t.left,window.innerWidth-n-i))}px`}renderReferencesMenu(){const t=this.currentSighting.references.map(e=>{const i=this.viewOfReference(e),n=this.said.read(e.title)??e.id,s=document.createElement("div");s.className="reference-row";const r=document.createElement("label"),a=document.createElement("input");a.type="checkbox",a.checked=i.shown;const c=document.createElement("span");c.textContent=n,c.title=n,r.append(a,c);const l=document.createElement("input");return l.type="range",l.min="0",l.max="1",l.step="0.05",l.value=String(i.opacity),l.title=this.messages?.referenceOpacity??"",l.setAttribute("aria-label",`${this.messages?.referenceOpacity??""}: ${n}`),l.disabled=!i.shown,a.addEventListener("change",()=>{i.shown=a.checked,l.disabled=!i.shown,this.updateReferencesButton(),this.dispatchReferenceView()}),l.addEventListener("input",()=>{i.opacity=Number(l.value),this.dispatchReferenceView()}),s.append(r,l),s});this.referencesMenu.setAttribute("aria-label",this.messages?.referencesMenu??""),this.referencesMenu.replaceChildren(...t)}updateReferencesButton(){const t=this.currentSighting.references.length>0,e=this.severalReferences,i=e?this.currentSighting.references.some(s=>this.viewOfReference(s).shown):this.referencesShownState;this.referencesButton.hidden=!t,this.referenceOpacityInput.hidden=!t||!this.referencesShownState||e,this.referencesButton.setAttribute("aria-pressed",String(i)),e?this.referencesButton.setAttribute("aria-haspopup","true"):this.referencesButton.removeAttribute("aria-haspopup"),He.setIcon(this.referencesButton,i?Qt.PICTURES_ON:Qt.PICTURES_OFF);const n=e?this.messages?.referencesMenu??"":this.referencesShownState?this.messages?.hideReferences??"":this.messages?.showReferences??"";this.referencesButton.title=n,this.referencesButton.setAttribute("aria-label",n),this.referenceOpacityInput.title=this.messages?.referenceOpacity??"",this.referenceOpacityInput.setAttribute("aria-label",this.messages?.referenceOpacity??"")}get tracesShown(){return this.tracesShownState}toggleTraces(){this.tracesShownState=!this.tracesShownState,this.updateTracesButton(),this.updateObserverMap(),this.dispatchEvent(new CustomEvent("traceview",{detail:{shown:this.tracesShown}}))}updateTracesButton(){this.tracesButton.hidden=this.currentSighting.traces.length===0,this.tracesButton.setAttribute("aria-pressed",String(this.tracesShownState)),He.setIcon(this.tracesButton,this.tracesShownState?Qt.TRACES_ON:Qt.TRACES_OFF);const t=this.tracesShownState?this.messages?.hideTraces??"":this.messages?.showTraces??"";this.tracesButton.title=t,this.tracesButton.setAttribute("aria-label",t)}dispatchReferenceView(){const t=this.severalReferences?Object.fromEntries(this.currentSighting.references.map(e=>[e.id,{...this.viewOfReference(e)}])):void 0;this.dispatchEvent(new CustomEvent("referenceview",{detail:{shown:this.referencesShown,opacity:this.referenceOpacity,views:t}}))}refreshMilestoneMarks(){const t=this.player.seekableDuration,e=t>0?Hu(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)??"",r=this.said.read(i.note),a=r?`${s} — ${r}`:s;return n.title=a,n.setAttribute("aria-label",a),n.dataset.t=String(i.t),n.addEventListener("click",()=>this.player.seek(i.t)),n})),this.refreshCitedMarks(),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 r=this.said.read(i.label)??"",a=this.said.read(i.note);return s.textContent=a?`${r} — ${a}`:r,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(r=>r>0&&r<t))].sort((r,a)=>r-a):[],Math.max(t,0)];this.seekSegmentList=[];const s=[];for(let r=0;r<n.length-1;r++){const a=document.createElement("div");a.className="seek-segment",a.style.flexGrow=String(Math.max(n[r+1]-n[r],1));const c=document.createElement("i");c.className="seek-hover";const l=document.createElement("i");l.className="seek-played",a.append(c,l),s.push(a),this.seekSegmentList.push({start:n[r],end:n[r+1],element:a,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}%`}paintMiniProgress(t){const e=this.player.seekableDuration,i=`${e>0?Math.min(Math.max(t/e,0),1)*100:0}%`;this.miniPlayed.style.width=i,this.miniDot.style.left=i,this.miniRemaining.textContent=this.formatRemaining(t)}miniDot;miniScrubTime;paintSeekProgress(t){for(const i of this.seekSegmentList)i.played.style.width=He.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){if(t.buttons!==0){this.seekPreview.hidden=!0;return}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,r=this.seekSegmentList.length-1;this.seekSegmentList.forEach((f,p)=>{f.hover.style.width=He.fillOf(f,s),f.element.classList.toggle("hovered",s>=f.start&&(s<f.end||p===r))});const a=this.milestonesShown?this.sighting.milestones:[],c=a.length>0?uf(a,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)}paintChrome(t){const e=this.chromeCanvas.getContext("2d"),i=this.overlayPainter!==void 0||this.selectionShown;if(!i&&!this.chromeDirty)return;const n=this.chromeCanvas.clientWidth,s=this.chromeCanvas.clientHeight;if(!e||typeof e.setTransform!="function"||n===0||s===0){t(this.canvasRenderer);return}const r=window.devicePixelRatio||1,a=Math.max(1,Math.round(n*r)),c=Math.max(1,Math.round(s*r));this.chromeCanvas.width!==a&&(this.chromeCanvas.width=a),this.chromeCanvas.height!==c&&(this.chromeCanvas.height=c),e.setTransform(1,0,0,1,0,0),e.clearRect(0,0,a,c),this.chromeDirty=!1,i&&(e.setTransform(a/this.canvas.width,0,0,c/this.canvas.height,0,0),this.chromeRenderer??=new Gh(e),this.chromeDirty=!0,t(this.chromeRenderer))}chromeDraw;repaintChrome(){this.chromeDraw&&this.overlayPainter&&this.paintChrome(this.chromeDraw)}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=He.MARK_SNAP_PX/i*e;let s;for(const r of this.milestoneMarks.children){const a=Number(r.dataset.t);Math.abs(a-t)>n||(!s||Math.abs(a-t)<Math.abs(s.t-t))&&(s={t:a,name:r.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?uf(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=ns.windowEndingAt(t,this.currentSighting.exposure??0);if(e.ms<He.SHORTEST_VISIBLE_EXPOSURE_MS)return[t];const i=Math.min(He.MAX_EXPOSURE_STEPS,Math.max(2,Math.round(e.ms/He.SHORTEST_VISIBLE_EXPOSURE_MS))),n=Math.ceil(this.travelPxOver(e.fromMs,e.ms)/He.EXPOSURE_STEP_PX),s=Math.min(He.MAX_TRAVEL_STEPS,Math.max(i,n)),r=[];for(let a=0;a<s;a++)r.push(e.fromMs+e.ms*a/(s-1));return r}travelPxOver(t,e){const i=this.shapesAt(t),n=this.shapesAt(t+e);let s=0;for(const[r,a]of i){const c=n.get(r);if(!c)continue;const l=c.bounds.x+c.bounds.width/2-(a.bounds.x+a.bounds.width/2),h=c.bounds.y+c.bounds.height/2-(a.bounds.y+a.bounds.height/2);s=Math.max(s,Math.hypot(l,h))}return s}shapeAt(t,e,i){if(!this.accountHidden)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=Ji.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}}timeSaid=Number.NEGATIVE_INFINITY;static TIME_SAID_EVERY_MS=100;onFrame(t,e){this.sayTimeMoved(t),this.canvasRenderer.clear(this.canvas.width,this.canvas.height);const i=this.playbackState!=="playing"?this.highlightedSourceIds:b5;this.canvasRenderer.setStarPoints(Ji.starPointsOf(this.sighting.instrument,ke(this.sighting,t)?.fNumber));const n=(ke(this.sighting,t)?.rollDeg??0)+this.gaitAt(t).rollDeg;this.canvasRenderer.setRoll(n*Math.PI/180);const s=this.exposureInstants(t),r=this.frameShift;if(this.paintsShapes)for(const c of s)for(const[,l]of c.shapes){const h=c.share,u=h===1?l:{...l,transparency:1-(1-l.transparency)*h};this.canvasRenderer.paintShape(this.shifted(u,r))}for(const[c,l]of s[0].shapes)!this.selectionShown||!i.has(c)||(this.paintsShapes?i.size===1?this.canvasRenderer.paintShape({...l,selected:!0}):this.canvasRenderer.paintMemberOutline(l):this.canvasRenderer.paintSelectionOnly(this.shifted(l,r)));const a=this.selectionShown&&i.size>1?Zs.groupBoundsFor([...e].filter(([c])=>i.has(c)).map(([,c])=>c.bounds)):void 0;this.chromeDraw=c=>{a&&c.paintGroupHandles(a),this.overlayPainter?.(c)},this.paintChrome(this.chromeDraw),this.mapShapeBounds=s.flatMap(c=>[...c.shapes.values()].filter(l=>l.transparency<1).map(l=>this.shifted(l,r).bounds)),this.keepObserverMapClear(),this.seekInput.value=String(t),this.paintSeekProgress(t),this.minified&&this.paintMiniProgress(t),this.timeStartLabel.textContent=this.formatPosition(t),this.showMilestoneAt(t),this.paintObserverMap(t),this.playbackState==="playing"||this.liveSightingAudio?(this.soundPreview=void 0,this.sightingAudio.setSound(z_(this.currentSighting,t))):this.soundPreview?this.sightingAudio.setSound(this.soundPreview):this.sightingAudio.silence(),this.updatePlayPauseButton(),!this.quietFrame&&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 B_(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*He.SEEK_KEY_STEP_MS)))}else t.key===" "&&(t.preventDefault(),this.togglePlayPause())};togglePlayPause(){if(!(this.player.seekableDuration<=0)){if(this.player.playbackState==="playing")this.player.pause(),this.soundPreview=void 0,this.sightingAudio.silence(),this.refresh();else if(this.clockHeld){this.playAfterHold=!this.playAfterHold,this.playAfterHold&&this.announcePlayRequest();return}else this.announcePlayRequest(),this.sightingAudio.resume(),this.player.play();this.updatePlayPauseButton(),this.flashPlayback()}}flashPlayback(){const t=this.playbackFlash;t.innerHTML=this.player.playbackState==="playing"?Qt.PLAY:Qt.PAUSE,t.classList.remove("flashing"),t.offsetWidth,t.classList.add("flashing")}static icons=new WeakMap;static setIcon(t,e){He.icons.get(t)!==e&&(He.icons.set(t,e),t.innerHTML=e)}set captionHeld(t){this.stageElement.classList.toggle("caption-held",t)}set controlsHeld(t){this.stageElement.classList.toggle("controls-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},He.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.stageElement.classList.contains("touched"))&&this.revealControls(),this.wasPlaying=t,this.updateStartState(),He.setIcon(this.playPauseButton,t?Qt.PAUSE:Qt.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(),this.dispatchEvent(new CustomEvent("observermapchange",{bubbles:!0,composed:!0,detail:{open:t}}))}get observerMapOpen(){return!this.observerMapPanel.hidden}get milestonesVisible(){return this.milestonesShown}observerMapAsked=!1;applyObserverMapDefault(){const t=this.getAttribute(bh),e=t===null?this.sighting.observerMap??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;He.setIcon(this.observerMapButton,t?Qt.MAP_ON:Qt.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=yh.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.tracesShownState?this.currentSighting.traces.flatMap(n=>n.points):[],i=gi.fitted(this.observerPath,e);(!this.observerMapBounds||!this.sameGround(this.observerMapBounds,i))&&(this.observerMapBounds&&this.observerMapView.refit(this.observerMapBounds,i),this.observerMapBounds=i,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.observerMapSnapshotImagery?this.observerMapImageryBounds!==void 0:!this.observerMapImageryNeededFor(t)))return;const e=this.observerMapView.changed,i=e?gi.expand(t,He.OBSERVER_MAP_IMAGERY_AHEAD):t,n=gi.IMAGERY_PX*(e?1+2*He.OBSERVER_MAP_IMAGERY_AHEAD:1);this.observerMapImageryBounds=i,this.observerMapImageryViewWidth=t.east-t.west,this.observerMapImageryLoading=!0;const s=this.observerMapSnapshotImagery,r=s?void 0:Zb();try{const a=r?await r.getImageryTexture(i,{width:n,height:n}):await s.getImagery();if(this.observerMapImageryBounds!==i)return;this.observerMapImagery=a,this.observerMapImageryCredit=(r??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?gi.expand(t,He.OBSERVER_MAP_IMAGERY_LOOKAHEAD):t,s=n.west>=i.west&&n.east<=i.east&&n.south>=i.south&&n.north<=i.north,r=t.east-t.west>this.observerMapImageryViewWidth/2;return!s||!r}get observerMapCredit(){return this.observerMapImageryCredit}set observerMapSnapshot(t){t!==this.observerMapSnapshotImagery&&(this.observerMapSnapshotImagery=t,this.observerMapImagery=void 0,this.observerMapImageryCredit=void 0,this.observerMapImageryFailed=!1,this.observerMapImageryBounds=void 0,this.observerMapImageryLoading=!1,this.observerMapPanel.hidden||(this.loadObserverMapImagery(),this.paintObserverMap(this.currentTime)))}get observerMapSnapshot(){return this.observerMapSnapshotImagery}observerMapSnapshotImagery;observerMapSnapshotSource;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],r=He.OBSERVER_MAP_CLEARANCE_PX,a=i(...n,0),c=i(...s,0);if(this.observerMapPanel.classList.toggle("subject-overlap",a&&c&&!this.observerMapAsked),this.observerMapPanel.classList.contains("on-the-left")){!a&&(c||!i(n[0],n[1],r))&&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=ke(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},He.OBSERVER_MAP_FOLLOW_MARGIN)&&this.scheduleObserverMapImagery();const i=this.currentSighting.instrument,n=[],s=this.currentSighting.milestones.length>0?uf(this.currentSighting.milestones,t):void 0;for(const r of this.milestonesShown?Hu(this.currentSighting.milestones):[]){const a=ke(this.currentSighting,r.t);a?.lat===void 0||a.lng===void 0||n.push({label:this.said.read(r.label)??"",note:this.said.read(r.note),t:r.t,lat:a.lat,lng:a.lng,current:r===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?da.of(i,this.canvas.height,e.fovDeg).halfWidthAngleDeg(Ji.aspectOf(i)):void 0,markers:n,traces:(this.tracesShownState?this.currentSighting.traces:[]).map(r=>({kind:r.kind,points:r.points,color:r.color,label:this.said.read(r.title)})),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,Hu(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??"",He.setIcon(this.milestonesButton,this.milestonesShown?Qt.MILESTONES_ON:Qt.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=ke(this.currentSighting,0);return e?.lat===void 0||e.lng===void 0?[]:this.currentSighting.decor.filter(i=>i.kind!=="crop").map(i=>{const n=ga(i,t),{lat:s,lng:r}=zs(n.eastM,-n.northM,e.lat,e.lng);return{lat:s,lng:r,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=ke(this.currentSighting,this.currentTime),s=da.of(this.currentSighting.instrument,this.canvas.height,n?.fovDeg??60);return{x:-s.angleDegToRadiusPx(e),y:s.angleDegToRadiusPx(i)}}gaitAt(t){return oi.bodyAt(this.currentSighting,t,this.steadyBody)}mutedState=!1;get muted(){return this.mutedState}set muted(t){t!==this.mutedState&&(this.mutedState=t,!t&&this.volumeState===0&&(this.volumeState=He.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.hasSound&&(this.muted=!this.mutedState)}ambientSound;get audible(){return this.hasSound}refreshSoundControls(){this.updateMuteButton()}get hasSound(){return this.currentSighting.soundTrack.allKeyframes.length>0||this.ambientSound?.(this.currentSighting)===!0}updateMuteButton(){const t=!this.hasSound;this.miniMuteButton.hidden=t,this.miniMuteButton.setAttribute("aria-pressed",String(this.mutedState)),He.setIcon(this.miniMuteButton,this.mutedState?Qt.MUTED:Qt.VOLUME);const e=this.mutedState?this.messages?.unmute??"":this.messages?.mute??"";if(this.miniMuteButton.title=e,this.miniMuteButton.setAttribute("aria-label",e),this.muteButton.disabled=t,this.volumeInput.hidden=t,t){He.setIcon(this.muteButton,Qt.MUTED),this.muteButton.title=this.messages?.noSound??"",this.muteButton.setAttribute("aria-label",this.messages?.noSound??""),this.muteButton.setAttribute("aria-pressed","true");return}He.setIcon(this.muteButton,this.mutedState?Qt.MUTED:Qt.VOLUME);const i=this.mutedState?this.messages?.unmute??"":this.messages?.mute??"";this.muteButton.title=i,this.muteButton.setAttribute("aria-label",i),this.muteButton.setAttribute("aria-pressed",String(this.mutedState)),this.volumeInput.value=String(this.level)}updateFullscreenButton(){const t=this.simulatedFullscreen||document.fullscreenElement===this.fullscreenTarget;He.setIcon(this.fullscreenButton,t?Qt.EXIT_FULLSCREEN:Qt.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 Cr(Lo.preferencesFor(this))}saidTexts;async loadLocaleMessages(){const t=I0(Lo.preferencesFor(this),C0);if(t===this.messagesLanguage)return;this.messagesLanguage=t;const e=await Q_.load(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.videoButton&&(this.videoButton.messages=t),this.labelVideoButton(),this.volumeInput.title=t.volume,this.volumeInput.setAttribute("aria-label",t.volume),this.updateMoreButton(),this.updateStartState(),this.referencesMenu.hidden||this.renderReferencesMenu(),this.refreshMilestoneMarks(),this.paintObserverMap(this.currentTime),this.updateTimeLabelTitles(),this.updatePlayPauseButton(),this.updateFullscreenButton(),this.updateMuteButton(),this.updateObserverMapButton(),this.updateReferencesButton(),this.updateTracesButton(),this.updateMilestonesButton(),this.renderIssues()}updateTimeLabels(){const t=this.currentSighting.event,e=k_(t);this.realDurationMs=e!==void 0&&e>0?e:void 0,this.realStartMs=t.time?u1(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.paintMiniProgress(this.player.time),this.updateTimeLabelTitles()}formatPosition(t){if(this.realDurationMs===void 0)return po(t);const e=this.currentSighting.timeline.duration,i=e>0&&t<=e?t/e*this.realDurationMs:t;return this.canShowClockTime?B2(z2(this.realStartMs+i)):po(i)}formatElapsedAt(t){const e=this.currentSighting.timeline.duration;return this.realDurationMs===void 0?po(t):po(e>0&&t<=e?t/e*this.realDurationMs:t)}formatRemaining(t){const e=this.currentSighting.timeline.duration;if(this.realDurationMs===void 0)return po(Math.max(0,e-t));const i=e>0&&t<=e?t/e*this.realDurationMs:t;return po(Math.max(0,this.realDurationMs-i))}formatEndOfTimeline(){return this.realDurationMs===void 0?po(this.currentSighting.timeline.duration):this.canShowClockTime?B2(z2(this.realStartMs+this.realDurationMs)):po(this.realDurationMs)}}function z2(o){const t=new Date(o);return{hour:t.getUTCHours(),minute:t.getUTCMinutes(),second:t.getUTCSeconds()}}function B2(o){if(o.hour===void 0)return"0:00";const t=e=>String(e).padStart(2,"0");return o.second?`${t(o.hour)}:${t(o.minute??0)}:${t(o.second)}`:`${t(o.hour)}:${t(o.minute??0)}`}function po(o){const t=Math.round(o/1e3),e=Math.floor(t/60),i=t%60;return`${e}:${String(i).padStart(2,"0")}`}const f1="rr0-ufo";function Jb(){customElements.get(f1)||customElements.define(f1,He)}const E5="timechange",A5="recordingissues",jb="minifiedreset";/**
|
|
1938
1938
|
* @license
|
|
1939
1939
|
* Copyright 2010-2026 Three.js Authors
|
|
1940
1940
|
* SPDX-License-Identifier: MIT
|
|
@@ -8293,7 +8293,7 @@ ${l.fragmentShader.replace("#include <emissivemap_fragment>",`#include <emissive
|
|
|
8293
8293
|
gl_FragColor = vec4(around * wall, wall + (1.0 - wall) * uAbsorption);
|
|
8294
8294
|
}
|
|
8295
8295
|
`,transparent:!0,depthWrite:!1,side:An,fog:!1,blending:Zc,blendSrc:Jc,blendDst:Fd})}static wallReflectance(t,e,i){const n=i(t,1,e);return 2*n/(1+n)}static DISCS={uDiscDirection:{value:[new _(0,1,0),new _(0,1,0)]},uDiscCosRadius:{value:[2,2]},uDiscRadiance:{value:[new _,new _]}};static DISC_INDEX={sun:0,moon:1};static setDisc(t,e){const i=cs.DISC_INDEX[t],n=cs.DISCS;if(!e){n.uDiscCosRadius.value[i]=2,n.uDiscRadiance.value[i].set(0,0,0);return}n.uDiscDirection.value[i].set(...e.direction).normalize(),n.uDiscCosRadius.value[i]=Math.cos(e.radiusRad),n.uDiscRadiance.value[i].set(...e.radiance)}setSurroundings(t){this.uniforms.uSurroundings.value=t}static reflectedResponse(t,e){return Ht.respond(e*Ht.relativeOfResponse(Math.max(t,1e-5)))}}class Is{static SIZE=64;static MOVE_M=.01;holder=new ki;cameras=[];faces=[];target=new qe(Is.SIZE,Is.SIZE);white=new Es({color:new at(1,1,1),side:An});scene=new ir;cabin;meshes=0;eye=new _;scratch=new _;constructor(){const t=[[new _(1,0,0),new _(0,1,0)],[new _(-1,0,0),new _(0,1,0)],[new _(0,1,0),new _(0,0,1)],[new _(0,-1,0),new _(0,0,-1)],[new _(0,0,1),new _(0,1,0)],[new _(0,0,-1),new _(0,1,0)]];for(const[e,i]of t){const n=new Kn(90,1,.02,20);n.up.copy(i),n.lookAt(e),this.holder.add(n),this.cameras.push(n),this.faces.push(new Uint8Array(Is.SIZE*Is.SIZE*4))}this.scene.background=new at(0,0,0)}get any(){return this.cabin!==void 0}update(t,e,i){if(!e){this.forget();return}e.updateWorldMatrix(!0,!0);const n=this.scratch.copy(i);e.worldToLocal(n);let s=0;e.traverse(r=>{r.isMesh&&s++}),!(e===this.cabin&&s===this.meshes&&n.distanceTo(this.eye)<Is.MOVE_M)&&(this.cabin=e,this.meshes=s,this.eye.copy(n),this.draw(t,e))}hides(t){if(!this.cabin)return!1;this.holder.updateWorldMatrix(!0,!0);for(let e=0;e<6;e++){const i=this.cameras[e],n=this.scratch.copy(t).transformDirection(i.matrixWorldInverse);if(n.z>=0)continue;const s=n.x/-n.z,r=n.y/-n.z;if(Math.abs(s)>1||Math.abs(r)>1)continue;const a=Math.min(Is.SIZE-1,Math.floor((s+1)/2*Is.SIZE)),c=Math.min(Is.SIZE-1,Math.floor((r+1)/2*Is.SIZE));return this.faces[e][(c*Is.SIZE+a)*4]>127}return!1}forget(){this.holder.removeFromParent(),this.cabin=void 0,this.meshes=0}dispose(){this.forget(),this.target.dispose(),this.white.dispose()}draw(t,e){e.add(this.holder),this.holder.position.copy(this.eye),this.holder.updateWorldMatrix(!0,!0);const i=[];e.traverse(r=>{const a=r;if(!a.isMesh||!a.visible||(Array.isArray(a.material)?a.material:[a.material]).every(h=>h instanceof cs))return;const l=new pt(a.geometry,this.white);l.matrixAutoUpdate=!1,l.matrix.copy(a.matrixWorld),l.matrixWorld.copy(a.matrixWorld),i.push(l)});for(const r of i)this.scene.add(r);const n=t.getRenderTarget(),s=t.shadowMap.autoUpdate;t.shadowMap.autoUpdate=!1;for(let r=0;r<6;r++){const a=this.cameras[r];a.updateMatrixWorld(!0),t.setRenderTarget(this.target),t.clear(),t.render(this.scene,a),Ep.now(t,this.target,0,0,Is.SIZE,Is.SIZE,this.faces[r])}t.setRenderTarget(n),t.shadowMap.autoUpdate=s;for(const r of i)r.removeFromParent()}}const Ag="https://ufoathome.org/models/index.json";class id{attribution="3D models re-hosted by UFO@home, each under its own author's licence";fetchImpl;indexUrls;loading;static shared=new Map;sharing;constructor(t={}){this.sharing=!t.fetchImpl,this.fetchImpl=t.fetchImpl??fetch.bind(globalThis),this.indexUrls=t.indexUrls??uN()}async entries(t){const e=await this.load();return t?e.filter(i=>[i.kind].flat().includes(t)):e}async entry(t){return(await this.load()).find(e=>e.id===t)}load(){if(this.loading)return this.loading;if(!this.sharing)return this.loading=this.fetchFirstAvailable();const t=this.indexUrls.join(`
|
|
8296
|
-
`);let e=id.shared.get(t);return e||(e=this.fetchFirstAvailable(),id.shared.set(t,e),e.then(i=>{i.length===0&&id.shared.delete(t)})),this.loading=e}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 uN(){const o=`?v=${encodeURIComponent("0.
|
|
8296
|
+
`);let e=id.shared.get(t);return e||(e=this.fetchFirstAvailable(),id.shared.set(t,e),e.then(i=>{i.length===0&&id.shared.delete(t)})),this.loading=e}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 uN(){const o=`?v=${encodeURIComponent("0.192.0")}`,t=typeof location>"u"?void 0:new URL("/models/index.json",location.href).href;return(t&&t!==Ag?[t,Ag]:[Ag]).map(e=>e+o)}const dN=Te.point("decorModels").provide(Te.BUILT_IN,[{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 id}]);class UA{constructor(t,e=dN){this.preferredId=t,this.sources=e}attribution="3D models, each under its own author's licence";built=new Map;catalogues(){const t=this.sources.find(i=>i.id===this.preferredId)??this.sources[0];return(t?[t,...this.sources.filter(i=>i!==t)]:[]).map(i=>{let n=this.built.get(i);return n||(n=i.create(),this.built.set(i,n)),n})}entries(t){const e=this.catalogues()[0];return e?e.entries(t):Promise.resolve([])}async entry(t){for(const e of this.catalogues()){const i=await e.entry(t).catch(()=>{});if(i)return i}}async moduleOf(t){const e=Te.point("decorModels");for(const i of this.sources){const n=e.ownerOf(i.id);if(!(n===void 0||n===Te.BUILT_IN)&&await this.catalogueOf(i).entry(t).catch(()=>{}))return n}}catalogueOf(t){return this.catalogues(),this.built.get(t)}}async function _g(o){const{GLTFLoader:t}=await dt(async()=>{const{GLTFLoader:i}=await import("./GLTFLoader-CKDxld-A.js");return{GLTFLoader:i}},[],import.meta.url),e=new t;return new Promise((i,n)=>{e.load(o,s=>i(Object.assign(s.scene,{animations:s.animations})),void 0,s=>n(new Error(`Could not load 3D model ${o}: ${s instanceof Error?s.message:String(s)}`)))})}const zA=["ellipsoid","sphere","disc","cylinder","cone","box","torus","figure"],eS=Math.PI/180;class qs{static candelaToward(t,e,i){const n=t.lamps;if(!n||n.length===0)return 0;const s=t.attitude.headingDeg*eS,r={east:Math.sin(s),north:Math.cos(s)},a={east:Math.cos(s),north:-Math.sin(s)};let c=0;for(const l of n){const{intensity:h}=Vc(l,i);if(!(h>0)||!yb(l,i))continue;const u={eastM:t.eastM+a.east*l.offsetM.x+r.east*l.offsetM.z,northM:t.northM+a.north*l.offsetM.x+r.north*l.offsetM.z,upM:t.upM+l.offsetM.y},d=l.beamDeg===void 0?1:qs.beamShare(l.beamDeg,r,u,e);c+=xb*h*d}return c}static magnitudeOf(t){return-14.18-2.5*Math.log10(t)}static TYCHO={diameterDeg(t){if(!(t>0))return 0;const e=qs.magnitudeOf(t);return qs.TYCHO_FIRST_ARCSEC*Math.pow(10,qs.TYCHO_PER_MAGNITUDE*(1-e))/3600}};static TYCHO_FIRST_ARCSEC=150;static TYCHO_PER_MAGNITUDE=Math.log10(150/18)/5;static seeingOf(t){const e=t.event.place?.[0],i=t.event.time,n=JSON.stringify([i,e?.lat,e?.lng,t.event.utcOffsetHours]),s=qs.seeings.get(t.event);if(s?.key===n)return s.seeing;const r=qs.seeingFrom(t,e,i);return qs.seeings.set(t.event,{key:n,seeing:r}),r}static seeings=new WeakMap;static seeingFrom(t,e,i){if(!e||typeof e.lat!="number"||typeof e.lng!="number"||i?.hour===void 0)return;const n=bc(i,e.lng,t.event.utcOffsetHours);return n&&zu("Sun",n,{lat:e.lat,lng:e.lng,elevationM:0}).altitudeDeg<=qs.NIGHT_SUN_DEG?qs.TYCHO:void 0}static NIGHT_SUN_DEG=-6;static luxAt(t,e){return e>0?t/(e*e):0}static beamShare(t,e,i,n){const s=n.eastM-i.eastM,r=n.northM-i.northM,a=n.upM-i.upM,c=Math.hypot(s,r,a);if(c===0)return 1;const l=(s*e.east+r*e.north)/c;if(l<=0)return 0;const h=Math.log(.5)/Math.log(Math.cos(t*eS));return Math.pow(l,h)}}const Ll=Math.PI/180,Su=180/Math.PI;class ci{constructor(t,e,i,n){this.timeline=t,this.tolerance=e,this.sizeHowOf=i,this.seeing=n}static DIRECTION_TOLERANCE_DEG=1;static SIZE_TOLERANCE=1.5;static RINGS=12;static SEGMENTS=24;projectionWithLights(t,e,i,n){const s=ci.projectionOf(t,e,n);if(!s||!this.seeing||!t.lamps?.length)return s;const r=Math.hypot(t.eastM-e.eastM,t.northM-e.northM,t.upM-e.upM),a=this.seeing.diameterDeg(qs.luxAt(qs.candelaToward(t,e,i),r));return a>s.angular.widthDeg||a>s.angular.heightDeg?{aim:s.aim,angular:{widthDeg:Math.max(s.angular.widthDeg,a),heightDeg:Math.max(s.angular.heightDeg,a)},lightSized:!0}:s}static sizeHows(t,e){return(i,n)=>{const s=t.allKeyframes;for(let r=s.length-1;r>=0;r--){const a=s[r];if(a.t>i)continue;const c=a.shapes.findIndex(h=>h.sourceId===n);if(c<0||!a.shapes[c].shape.angular)continue;const l=`timeline.keyframes.${r}.shapes.${c}.shape.angular`;return(e.at(l)??e.at(`${l}.widthDeg`))?.how}}}static lawsOf(t,e){return{direction(i,n,s){const r=t.law({kind:"heading",value:i.azimuthDeg},e),a=Math.abs(((n.azimuthDeg-i.azimuthDeg)%360+540)%360-180),c=t.law({kind:"elevation",value:i.altitudeDeg},e),l=Math.max(ci.DIRECTION_TOLERANCE_DEG,s);return a>(r.high??i.azimuthDeg)-i.azimuthDeg+l||n.altitudeDeg>(c.high??i.altitudeDeg)+l||n.altitudeDeg<(c.low??i.altitudeDeg)-l},size(i,n,s){const r=t.law({kind:"angularSize",value:i,how:s},e);return n<(r.low??i)/ci.SIZE_TOLERANCE||n>(r.high??i)*ci.SIZE_TOLERANCE}}}at(t,e,i,n){const s=[],r=new Map,a=[];for(const c of e){if(c.ensemble&&c.explains.length>0){const l=r.get(c.ensemble);l?l.push(c):r.set(c.ensemble,[c]);continue}a.push({id:c.id,explains:c.explains,predicted:this.projectionWithLights(c,i,t,n?.(c))})}for(const[c,l]of r){const h=l.flatMap(u=>n?.(u)??ci.outlineOf(u));a.push({id:c,explains:l[0].explains,predicted:ci.projectionOf(l[0],i,h)})}for(const c of a){const l=c.predicted;if(l)for(const h of c.explains){const u=this.timeline.getInterpolatedShapeAt(t,h);!u||u.transparency>=1||s.push({...ci.compare(h,c.id,{aim:u.aim,angular:u.angular,sizeHow:this.sizeHowOf?.(t,h)},{aim:l.aim,angular:l.angular},this.tolerance),...l.lightSized?{lightSized:!0}:{},title:u.title})}}return s}static compare(t,e,i,n,s){const r=[],a=i.aim?ci.separationDeg(i.aim,n.aim):void 0;if(a!==void 0){const u=Math.max(i.angular?.widthDeg??0,n.angular.widthDeg)/2;(s?s.direction(i.aim,n.aim,u):a>Math.max(ci.DIRECTION_TOLERANCE_DEG,u))&&r.push("direction")}const c=i.angular&&i.angular.widthDeg>0?n.angular.widthDeg/i.angular.widthDeg:void 0,l=i.angular&&i.angular.heightDeg>0?n.angular.heightDeg/i.angular.heightDeg:void 0,h=(u,d)=>s?s.size(d,d*u,i.sizeHow):!ci.withinSize(u);return c!==void 0&&h(c,i.angular.widthDeg)&&r.push("width"),l!==void 0&&h(l,i.angular.heightDeg)&&r.push("height"),{sourceId:t,bodyId:e,stated:i,predicted:n,separationDeg:a,widthRatio:c,heightRatio:l,disagreements:r}}static projectionOf(t,e,i){const n=i&&i.length>0?i:ci.outlineOf(t),s=i&&i.length>0?ci.centreOf(i):t,r=ci.normalized({eastM:s.eastM-e.eastM,northM:s.northM-e.northM,upM:s.upM-e.upM});if(!r)return;const a=ci.normalized({eastM:r.northM,northM:-r.eastM,upM:0})??{eastM:1,northM:0,upM:0},c=ci.cross(a,r);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},g=ci.dot(p,r);if(g<=0)return;const m=Math.atan2(ci.dot(p,a),g),M=Math.atan2(ci.dot(p,c),g);l=Math.min(l,m),h=Math.max(h,m),u=Math.min(u,M),d=Math.max(d,M)}return{aim:{azimuthDeg:(Math.atan2(r.eastM,r.northM)*Su+360)%360,altitudeDeg:Math.asin(Math.max(-1,Math.min(1,r.upM)))*Su},angular:{widthDeg:(h-l)*Su,heightDeg:(d-u)*Su}}}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*Ll,n=e.altitudeDeg*Ll,s=Math.sin(i)*Math.sin(n)+Math.cos(i)*Math.cos(n)*Math.cos((t.azimuthDeg-e.azimuthDeg)*Ll);return Math.acos(Math.max(-1,Math.min(1,s)))*Su}static withinSize(t){return t<=ci.SIZE_TOLERANCE&&t>=1/ci.SIZE_TOLERANCE}static outlineOf(t){const e=t.sizeM.widthM/2,i=t.sizeM.lengthM/2,n=t.sizeM.heightM/2,s=[],r=t.model.url===void 0?t.model.id:void 0;if(r!==void 0&&r!=="box"&&zA.includes(r))for(let u=0;u<=ci.RINGS;u++){const d=u/ci.RINGS*Math.PI;for(let f=0;f<ci.SEGMENTS;f++){const p=f/ci.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*Ll,l=t.attitude.pitchDeg*Ll,h=t.attitude.rollDeg*Ll;return s.map(([u,d,f])=>{const p=u*Math.cos(h)+f*Math.sin(h),g=-u*Math.sin(h)+f*Math.cos(h),m=d*Math.cos(l)-g*Math.sin(l),M=d*Math.sin(l)+g*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+M}})}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}}class js{static MIN_ANGLE_RAD=.002;static FILL=(1-Math.exp(-4))/4;static MAX_SHARE=.3;mesh;constructor(t,e){this.mesh=new pt(new ps(2,2),new De({uniforms:{uColor:{value:new at(0,0,0)},uRadius:{value:1}},vertexShader:js.VERTEX,fragmentShader:js.FRAGMENT,transparent:!0,depthWrite:!1,blending:Dn,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*js.MIN_ANGLE_RAD),r=js.FILL*Math.PI*s*s;return{radiusM:s,luminanceCdM2:i*Math.min(js.MAX_SHARE,e/r)}}static conserving(t){return Math.sqrt(t/(js.MAX_SHARE*js.FILL*Math.PI))}static VERTEX=`
|
|
8297
8297
|
uniform float uRadius;
|
|
8298
8298
|
varying vec2 vOffset;
|
|
8299
8299
|
void main() {
|
|
@@ -8935,7 +8935,7 @@ void main() {
|
|
|
8935
8935
|
gl_FragColor = vec4(color, tex.a * uOpacity * (1.0 - blur * 0.5));
|
|
8936
8936
|
}
|
|
8937
8937
|
`;function qS(o){const e=document.createElement("canvas");e.width=128,e.height=128;const i=e.getContext("2d"),n=128/2-2,s=128/2,r=128/2,a="#010101",c="#f4f1e2";i.fillStyle=a,i.beginPath(),i.arc(s,r,n,0,Math.PI*2),i.fill();const l=$r(o.illuminatedFraction,0,1),h=o.phaseFraction<.5,u=n*Math.abs(1-2*l),d=l<.5;return i.save(),i.beginPath(),i.arc(s,r,n,0,Math.PI*2),i.clip(),i.fillStyle=c,i.beginPath(),h?(i.arc(s,r,n,-Math.PI/2,Math.PI/2,!1),i.ellipse(s,r,u,n,0,Math.PI/2,-Math.PI/2,d)):(i.arc(s,r,n,Math.PI/2,-Math.PI/2,!1),i.ellipse(s,r,u,n,0,-Math.PI/2,Math.PI/2,d)),i.fill(),i.restore(),new oc(e)}function uL(o){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(o,64,68),new oc(t)}function t1(o){let t=o;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 Dp{constructor(t,e){this.source=t,this.create=e}scene;wanted;pumping=!1;disposed=!1;static PATIENCE_FRAMES=600;static SCENE_WIDTH_PX=480;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"),t.setAttribute("always-live",""),Object.assign(t.style,{position:"fixed",left:"-10000px",top:"0",width:`${Dp.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<Dp.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}}}class Mi{static held=new Map;static loaded=new Map;static generation=0;static address(t,e){const i=e??(typeof location>"u"?"http://localhost/":location.href);return new URL(t,i).href}static hold(t,e){Mi.held.set(t,e),Mi.loaded.delete(t),Mi.generation++}static release(){if(Mi.held.size!==0){for(const t of Mi.held.keys())Mi.loaded.delete(t);Mi.held.clear(),Mi.generation++}}static bytes(t,e=fetch.bind(globalThis)){const i=Mi.held.get(t);if(i)return Promise.resolve(i);let n=Mi.loaded.get(t);return n||(n=e(t).then(async s=>{if(!s.ok)throw new Error(`Frozen data not found (${s.status}): ${t}`);return new Uint8Array(await s.arrayBuffer())}),Mi.loaded.set(t,n),n.catch(()=>Mi.loaded.delete(t))),n}static async json(t){return JSON.parse(new TextDecoder().decode(await Mi.bytes(t)))}static async zip(t){const e=await Mi.bytes(t),{unzipSync:i}=await dt(async()=>{const{unzipSync:n}=await import("./browser-CltifEM0.js");return{unzipSync:n}},[],import.meta.url);return i(e)}}class wa{static SAME_BOUNDS_DEG=1e-9;loaded=!1;ready;list=[];constructor(t){this.ready=t.then(e=>{this.list=e},()=>{}).finally(()=>{this.loaded=!0})}nearest(t,e){let i,n=1/0;for(const s of this.list){if(s.far)continue;const{x:r,z:a}=ae(s.lat,s.lng,t,e),c=Math.hypot(r,a);c<n&&(n=c,i=s)}return i}farRingOf(t,e){return this.list.find(i=>i.far&&Math.abs(i.lat-t)<=wa.SAME_BOUNDS_DEG&&Math.abs(i.lng-e)<=wa.SAME_BOUNDS_DEG)}static boundsOf(t){return Qu(t.lat,t.lng,t.radiusM)}static sameBounds(t,e){const i=(n,s)=>Math.abs(n-s)<=wa.SAME_BOUNDS_DEG;return i(t.north,e.north)&&i(t.south,e.south)&&i(t.east,e.east)&&i(t.west,e.west)}static contains(t,e){return t.north>=e.north&&t.south<=e.south&&t.east>=e.east&&t.west<=e.west}static samePatches(t,e){return t.length===e.length&&t.every((i,n)=>i.lat===e[n].lat&&i.lng===e[n].lng&&i.radiusM===e[n].radiusM&&i.far===e[n].far)}}class Ip{static async encode(t){const{zipSync:e,strToU8:i}=await dt(async()=>{const{zipSync:r,strToU8:a}=await import("./browser-CltifEM0.js");return{zipSync:r,strToU8:a}},[],import.meta.url),n={},s={version:1,takenOn:t.takenOn,attribution:t.attribution,patches:t.patches.map((r,a)=>{const c=`${a}.f32`;return n[c]=Ip.byPlane(r.grid.heights),{lat:r.lat,lng:r.lng,radiusM:r.radiusM,...r.far?{far:r.far}:{},bounds:r.grid.bounds,width:r.grid.width,height:r.grid.height,file:c}})};return n["index.json"]=i(JSON.stringify(s,null,1)),e(n,{level:9})}static decode(t){const e=t["index.json"];if(!e)throw new Error("A relief annex without its index");const i=JSON.parse(new TextDecoder().decode(e));return{takenOn:i.takenOn,attribution:i.attribution,patches:i.patches.flatMap(n=>{const s=t[n.file];if(!s||s.length!==n.width*n.height*4)return[];const r={heights:Ip.fromPlanes(s),width:n.width,height:n.height,bounds:n.bounds};return[{lat:n.lat,lng:n.lng,radiusM:n.radiusM,...n.far?{far:n.far}:{},grid:r}]})}}static byPlane(t){const e=new Uint8Array(t.buffer,t.byteOffset,t.byteLength),i=t.length,n=new Uint8Array(e.length);for(let s=0;s<i;s++)for(let r=0;r<4;r++)n[r*i+s]=e[s*4+r];return n}static fromPlanes(t){const e=t.length/4,i=new Uint8Array(t.length);for(let n=0;n<e;n++)for(let s=0;s<4;s++)i[n*4+s]=t[s*e+n];return new Float32Array(i.buffer)}}class ny{constructor(t){this.annex=t}async getElevationGrid(t,e,i){const{patches:n}=await this.annex,s=n.find(a=>wa.sameBounds(wa.boundsOf(a),t));if(s)return{...s.grid,heights:new Float32Array(s.grid.heights)};const r=n.find(a=>wa.contains(a.grid.bounds,t));if(r)return ny.resample(r.grid,t,e);throw new Error("The snapshots relief does not hold this ground")}static resample(t,e,i){const{width:n,height:s}=i,r=new Float32Array(n*s),a=t.bounds.east-t.bounds.west,c=t.bounds.north-t.bounds.south;for(let l=0;l<s;l++){const h=e.north-(e.north-e.south)*(s>1?l/(s-1):0),u=Math.min(t.height-1,Math.max(0,(t.bounds.north-h)/c*(t.height-1))),d=Math.floor(u),f=Math.min(t.height-1,d+1),p=u-d;for(let g=0;g<n;g++){const m=e.west+(e.east-e.west)*(n>1?g/(n-1):0),M=Math.min(t.width-1,Math.max(0,(m-t.bounds.west)/a*(t.width-1))),v=Math.floor(M),x=Math.min(t.width-1,v+1),y=M-v,w=(S,A)=>t.heights[S*t.width+A],b=w(d,v)*(1-y)+w(d,x)*y,E=w(f,v)*(1-y)+w(f,x)*y;r[l*n+g]=b*(1-p)+E*p}}return{heights:r,width:n,height:s,bounds:e}}}function KA(o,t){return o.find(e=>e.id===t)??o[0]}class dL{attribution;fetchImpl;tileUrlTemplate;constructor(t={}){this.fetchImpl=t.fetchImpl??fetch.bind(globalThis);const e=t.year??2024;this.tileUrlTemplate=`https://tiles.maps.eox.at/wmts/1.0.0/s2cloudless-${e}_3857/default/g/{z}/{y}/{x}.jpg`,this.attribution=`EOxCloudless https://cloudless.eox.at by EOX IT Services GmbH (Contains modified Copernicus Sentinel data ${e})`}async getImageryTexture(t,e){return Yb(t,e,i=>this.tileUrlTemplate.replace("{z}",String(i.z)).replace("{y}",String(i.y)).replace("{x}",String(i.x)),this.fetchImpl)}}Te.point("elevation").provide(Te.BUILT_IN,[{id:"ign-mnt",name:"IGN LiDAR HD / RGE ALTI",credit:"Relief © IGN, LiDAR HD and RGE ALTI (Licence Ouverte 2.0) in France; © AWS Open Data (SRTM, ETOPO1) elsewhere",creditUrl:"https://geoservices.ign.fr/lidarhd",create:()=>qb()},{id:"aws-terrarium",name:"AWS Terrain Tiles",credit:"© AWS Open Data (SRTM, ETOPO1)",creditUrl:"https://registry.opendata.aws/terrain-tiles/",create:()=>new Xb}]);const $A=Te.point("imagery").provide(Te.BUILT_IN,[{id:"esri-world",name:"Esri World Imagery",credit:"Imagery © Esri, Maxar, Earthstar Geographics, and the GIS User Community",creditUrl:"https://www.arcgis.com/home/item.html?id=10df2279f9684e4a9f6a7f08febac2a9",create:o=>new Kb({fetchImpl:o})},{id:"eox-s2cloudless",name:"EOX Sentinel-2 cloudless",credit:"EOxCloudless by EOX IT Services GmbH (contains modified Copernicus Sentinel data)",creditUrl:"https://cloudless.eox.at",create:o=>new dL({fetchImpl:o})}]);class ZS{static async encode(t){const{zipSync:e,strToU8:i}=await dt(async()=>{const{zipSync:c,strToU8:l}=await import("./browser-CltifEM0.js");return{zipSync:c,strToU8:l}},[],import.meta.url),n={},s={};let r=0;for(const[c,l]of t.tiles){const h=`tiles/${r++}`;n[h]=l.bytes,s[c]={file:h,type:l.type}}const a={version:1,takenOn:t.takenOn,source:t.source,attribution:t.attribution,patches:t.patches,map:t.map,tiles:s};return n["index.json"]=i(JSON.stringify(a,null,1)),e(n,{level:0})}static decode(t){const e=t["index.json"];if(!e)throw new Error("An imagery annex without its index");const i=JSON.parse(new TextDecoder().decode(e)),n=new Map;for(const[s,{file:r,type:a}]of Object.entries(i.tiles)){const c=t[r];c&&n.set(s,{bytes:c,type:a})}return{takenOn:i.takenOn,source:i.source,attribution:i.attribution,patches:i.patches,map:i.map,tiles:n}}}class sm{constructor(t,e=""){this.annex=t,this.attributionStated=e}provider;attributionRead;get attribution(){return this.attributionRead??this.attributionStated}async getImageryTexture(t,e){return(await(this.provider??=this.annex.then(n=>(this.attributionRead=n.attribution,KA($A,n.source).create(sm.fetchFrom(n.tiles)))))).getImageryTexture(t,e)}static fetchFrom(t){return async e=>{const i=typeof e=="string"?e:e instanceof URL?e.href:e.url,n=t.get(i);return n?new Response(n.bytes,{status:200,headers:{"content-type":n.type}}):new Response(null,{status:404})}}}class fL{constructor(t,e=""){this.annex=t,this.attributionStated=e}picture;attributionRead;get attribution(){return this.attributionRead??this.attributionStated}getImagery(){return this.picture??=this.annex.then(t=>{if(!t.map)throw new Error("An imagery annex that holds no map");return this.attributionRead=t.attribution,KA($A,t.source).create(sm.fetchFrom(t.tiles)).getImageryTexture(t.map.bounds,{width:t.map.pixels,height:t.map.pixels})})}}class sy{constructor(t){this.annex=t}attributionRead;contemporaryRead;async itemsFor(t){const e=await this.annex;return this.attributionRead=e.attribution,this.contemporaryRead=e.contemporary,e.patches.find(i=>wa.sameBounds(wa.boundsOf(i),t))?.items??[]}}class pL{constructor(t,e=""){this.attributionStated=e,this.reader=new sy(t)}reader;get attribution(){return this.reader.attributionRead??this.attributionStated}get contemporary(){return this.reader.contemporaryRead??!0}getRoads(t){return this.reader.itemsFor(t)}}class mL{constructor(t,e=""){this.attributionStated=e,this.reader=new sy(t)}reader;get attribution(){return this.reader.attributionRead??this.attributionStated}getWater(t){return this.reader.itemsFor(t)}}class gL{constructor(t,e=""){this.attributionStated=e,this.reader=new sy(t)}reader;get attribution(){return this.reader.attributionRead??this.attributionStated}get contemporary(){return this.reader.contemporaryRead??!0}getRailways(t){return this.reader.itemsFor(t)}}class Cp{static providers(t,e,i){const n=f=>vh.held(t,f),s=n("relief"),r=n("imagery"),a=n("roads"),c=n("water"),l=n("railways");if(!s&&!r&&!a&&!c&&!l)return i;const h=f=>Mi.address(f.src,e),u=[],d={...i};if(s){const f=Mi.zip(h(s)).then(p=>Ip.decode(p));d.elevation=new ny(f),u.push(f.then(p=>p.patches))}if(r){const f=Mi.zip(h(r)).then(p=>ZS.decode(p));d.imagery=new sm(f,r.attribution),u.push(f.then(p=>p.patches))}if(a){const f=Mi.json(h(a));d.roads=new pL(f,a.attribution),u.push(f.then(p=>p.patches))}if(c){const f=Mi.json(h(c));d.water=new mL(f,c.attribution),u.push(f.then(p=>p.patches))}if(l){const f=Mi.json(h(l));d.railways=new gL(f,l.attribution),u.push(f.then(p=>p.patches))}return d.patches=new wa(Cp.firstRead(u)),d}static map(t,e){const i=Mi.zip(Mi.address(t.src,e)).then(n=>ZS.decode(n));return new fL(i,t.attribution)}static async firstRead(t){for(const e of t)try{const i=await e;if(i.length>0)return i.map(({lat:n,lng:s,radiusM:r,far:a})=>({lat:n,lng:s,radiusM:r,...a?{far:a}:{}}))}catch{}return[]}}const Xl="https://en.wikipedia.org/wiki/Kodachrome",wc="https://en.wikipedia.org/wiki/Kodacolor_(still_photography)",ML="https://en.wikipedia.org/wiki/Kodak_Tri-X",Yl="https://en.wikipedia.org/wiki/List_of_discontinued_photographic_films",ka="https://www.kodak.com/en/motion/page/chronology-of-film/",Ys=(o,t)=>[{format:"135",from:o,to:t},{format:"120",from:o,to:t}],Fa=(o,t)=>[{format:"35mm-cine",from:o,to:t}],JS=[{id:"kodacolor",name:"Kodacolor",kind:"negative",iso:32,formats:Ys(1942,1963),source:wc},{id:"kodacolor-x",name:"Kodacolor-X",kind:"negative",iso:80,formats:[...Ys(1963,1974),{format:"126",from:1963,to:1974}],source:wc},{id:"kodacolor-ii",name:"Kodacolor II",kind:"negative",iso:100,formats:[...Ys(1973),{format:"126",from:1973}],source:wc},{id:"kodacolor-400",name:"Kodacolor 400",kind:"negative",iso:400,formats:Ys(1977),source:wc},{id:"kodacolor-vr-100",name:"Kodacolor VR 100",kind:"negative",iso:100,formats:Ys(1982,1986),source:wc},{id:"kodacolor-vr-200",name:"Kodacolor VR 200",kind:"negative",iso:200,formats:[...Ys(1982,1986),{format:"126",from:1982,to:1986}],source:wc},{id:"kodacolor-vr-400",name:"Kodacolor VR 400",kind:"negative",iso:400,formats:Ys(1982,1986),source:wc},{id:"agfacolor-cn17",name:"Agfacolor CN17",kind:"negative",iso:40,formats:Ys(1956,1971),source:Yl},{id:"agfacolor-cns",name:"Agfacolor CNS",kind:"negative",iso:80,formats:[...Ys(1968,1975),{format:"126",from:1968,to:1975}],source:Yl},{id:"agfacolor-cns-2",name:"Agfacolor CNS 2",kind:"negative",iso:80,formats:[...Ys(1971,1982),{format:"126",from:1971,to:1982}],source:Yl},{id:"agfacolor-cns-400",name:"Agfacolor CNS 400",kind:"negative",iso:400,formats:Ys(1978,1984),source:Yl},{id:"kodachrome",name:"Kodachrome",kind:"slide",iso:10,formats:[{format:"135",from:1936,to:1962}],source:Xl},{id:"kodachrome-ii",name:"Kodachrome II",kind:"slide",iso:25,formats:[{format:"135",from:1961,to:1974}],source:Xl},{id:"kodachrome-x",name:"Kodachrome-X",kind:"slide",iso:64,formats:[{format:"135",from:1962,to:1974},{format:"126",from:1963,to:1974}],source:Xl},{id:"kodachrome-25",name:"Kodachrome 25",kind:"slide",iso:25,formats:[{format:"135",from:1974,to:2001}],source:Xl},{id:"kodachrome-64",name:"Kodachrome 64",kind:"slide",iso:64,formats:[{format:"135",from:1974,to:2009},{format:"126",from:1974,to:1993}],source:Xl},{id:"kodachrome-200",name:"Kodachrome 200",kind:"slide",iso:200,formats:[{format:"135",from:1988,to:2007}],source:Xl},{id:"agfachrome-ct18",name:"Agfachrome CT18",kind:"slide",iso:50,formats:[...Ys(1958,1984),{format:"126",from:1958,to:1984}],source:Yl},{id:"agfachrome-ct21",name:"Agfachrome CT21",kind:"slide",iso:100,formats:[{format:"135",from:1974,to:1984}],source:Yl},{id:"tri-x",name:"Kodak Tri-X",kind:"negative",monochrome:!0,iso:400,formats:Ys(1954),source:ML},{id:"eastman-5247-1950",name:"Eastman Color Negative 5247 (1950)",kind:"negative",iso:16,formats:Fa(1950,1952),source:ka},{id:"eastman-5248-1952",name:"Eastman Color Negative 5248 (1952)",kind:"negative",iso:16,formats:Fa(1952,1959),source:ka},{id:"eastman-5250",name:"Eastman Color Negative 5250",kind:"negative",iso:32,formats:Fa(1959,1962),source:ka},{id:"eastman-5251",name:"Eastman Color Negative 5251",kind:"negative",iso:50,light:"tungsten",formats:Fa(1962,1968),source:ka},{id:"eastman-5254",name:"Eastman Color Negative 5254",kind:"negative",iso:100,light:"tungsten",formats:Fa(1968,1976),source:ka},{id:"eastman-5247-1974",name:"Eastman Color Negative II 5247 (1974)",kind:"negative",iso:64,formats:Fa(1974,1983),source:ka},{id:"eastman-5294",name:"Eastman High Speed Negative 5294",kind:"negative",iso:400,light:"tungsten",formats:Fa(1983),source:ka},{id:"eastman-5297",name:"Eastman High Speed Daylight 5297",kind:"negative",iso:250,formats:Fa(1986,1997),source:ka},{id:"eastman-5245",name:"Eastman EXR 50D 5245",kind:"negative",iso:50,formats:Fa(1989),source:ka}];class qd{static byId(t){return JS.find(e=>e.id===t)}static forInstrument(t){return JS.filter(e=>e.formats.some(i=>i.format===t.filmFormat))}static gap(t,e,i){const n=t.formats.find(s=>s.format===e.filmFormat);if(!(!n||i===void 0)){if(i<n.from)return{kind:"before",from:n.from};if(n.to!==void 0&&i>n.to)return{kind:"after",to:n.to}}}static possible(t,e){return qd.forInstrument(t).filter(i=>qd.gap(i,t,e)===void 0)}static mediumOf(t,e){return!t||!e?t:{...t,kind:e.kind,iso:e.iso,monochrome:e.monochrome}}}class gh{constructor(t){this.annex=t}static SAME_PLACE_DEG=1e-6;static SAME_TIME_MS=1e3;async between(t,e,i){let n;try{n=await this.annex}catch{return{status:"failed"}}const s=c=>Math.abs(c.lat-t.lat)<=gh.SAME_PLACE_DEG&&Math.abs(c.lng-t.lng)<=gh.SAME_PLACE_DEG,a=n.answers.find(c=>s(c)&&Math.abs(c.startMs-e)<=gh.SAME_TIME_MS&&Math.abs(c.endMs-i)<=gh.SAME_TIME_MS)??n.answers.find(c=>c.startMs<=e&&c.endMs>=i);return a?a.answer:{status:"failed"}}}const e1=7.5,i1=9;class qr{static cache=new Map;static load(t){let e=qr.cache.get(t);return e||(e=fetch(t).then(i=>i.arrayBuffer()).then(i=>qr.parse(i)),qr.cache.set(t,e)),e}static upTo(t,e){const i=t.filter((r,a)=>a===0||t[a-1].magnitudeLimit<e);if(i.length<=1)return qr.load(t[0].url);const n=i.map(r=>r.url).join(`
|
|
8938
|
-
`);let s=qr.cache.get(n);return s||(s=Promise.all(i.map(r=>qr.load(r.url))).then(r=>r.reduce((a,c)=>qr.concat(a,c))),qr.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 r=new Float32Array(n.length+s.length);return r.set(n,0),r.set(s,n.length),r};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 ai{constructor(t){if(this.heights=t,t.length!==ai.WIDTH*ai.HEIGHT)throw new Error(`a lunar relief has ${ai.WIDTH*ai.HEIGHT} samples, not ${t.length}`)}static SAMPLES_PER_DEGREE=16;static WIDTH=360*ai.SAMPLES_PER_DEGREE;static HEIGHT=180*ai.SAMPLES_PER_DEGREE;static UNIT_KM=.1;static REFERENCE_RADIUS_KM=1737.4;static BAND_FROM_DEG=74;static BAND_TO_DEG=106;heightKm(t,e){const i=ai.SAMPLES_PER_DEGREE,n=(e%360+360)%360*i-.5,s=(90-t)*i-.5,r=Math.floor(n),a=Math.floor(s),c=n-r,l=s-a,h=(f,p)=>{const g=(f%ai.WIDTH+ai.WIDTH)%ai.WIDTH,m=Math.min(ai.HEIGHT-1,Math.max(0,p));return this.heights[m*ai.WIDTH+g]},u=h(r,a)*(1-c)+h(r+1,a)*c,d=h(r,a+1)*(1-c)+h(r+1,a+1)*c;return(u*(1-l)+d*l)*ai.UNIT_KM}static inBand(t,e){const i=Math.PI/180,n=Math.acos(Math.cos(t*i)*Math.cos(e*i))*180/Math.PI;return n>=ai.BAND_FROM_DEG&&n<=ai.BAND_TO_DEG}static withBump(t,e,i,n=.4){const s=new Int8Array(ai.WIDTH*ai.HEIGHT),r=ai.SAMPLES_PER_DEGREE,a=Math.ceil(n*r),c=Math.floor(e*r),l=Math.floor((90-t)*r);for(let h=-a;h<=a;h++)for(let u=-a;u<=a;u++)Math.hypot(u,h)<=a&&(s[(l+h)*ai.WIDTH+(c+u+ai.WIDTH)%ai.WIDTH]=Math.round(i/ai.UNIT_KM));return new ai(s)}static smooth(){return new ai(new Int8Array(ai.WIDTH*ai.HEIGHT))}}class dr{static SAMPLES=5760;static SEARCH_FROM_DEG=87;static SEARCH_TO_DEG=90.2;static SEARCH_STEP_DEG=.0625;static profile(t,e,i,n=dr.SAMPLES){const{s,u:r,w:a,distanceKm:c}=dr.frame(t,e),l=Math.PI/180,h=new Float32Array(n),u=ai.REFERENCE_RADIUS_KM;for(let d=0;d<n;d++){const f=d/n*2*Math.PI,p=Math.cos(f),g=Math.sin(f),m=p*r[0]+g*a[0],M=p*r[1]+g*a[1],v=p*r[2]+g*a[2];let x=0;for(let y=dr.SEARCH_FROM_DEG;y<=dr.SEARCH_TO_DEG;y+=dr.SEARCH_STEP_DEG){const w=Math.cos(y*l),b=Math.sin(y*l),E=w*s[0]+b*m,S=w*s[1]+b*M,A=w*s[2]+b*v,R=Math.asin(Math.max(-1,Math.min(1,A)))/l,D=Math.atan2(S,E)/l,I=u+i.heightKm(R,D),P=Math.atan2(I*b,c-I*w);P>x&&(x=P)}h[d]=x/l}return{radiusDeg:h,meanRadiusDeg:Math.asin(u/c)/l}}static frame(t,e){const i=new nc(e.lat,e.lng,e.elevationM),n=ro(t),s=bM(t,i,!1),r=new Be(s.x-n.x,s.y-n.y,s.z-n.z,n.t),a=Math.hypot(r.x,r.y,r.z)*dr.AU_KM,c=dr.bodyFixed(t),l=c(r),h=Math.hypot(l[0],l[1],l[2]),u=[l[0]/h,l[1]/h,l[2]/h],d=kO(t,i),f=Yv(d),p=io(d,new Be(-r.x,-r.y,-r.z,n.t)),g=Math.asin(p.z/Math.hypot(p.x,p.y,p.z)),m=Math.atan2(-p.y,p.x),M=new Be(-Math.sin(g)*Math.cos(m),Math.sin(g)*Math.sin(m),Math.cos(g),n.t),v=new Be(-Math.sin(m),-Math.cos(m),0,n.t);return{s:u,u:c(io(f,M)),w:c(io(f,v)),distanceKm:a}}static surfacePoint(t,e,i,n){const{s,u:r,w:a}=dr.frame(t,e),c=Math.PI/180,l=[0,1,2].map(u=>Math.cos(i*c)*r[u]+Math.sin(i*c)*a[u]),h=[0,1,2].map(u=>Math.cos(n*c)*s[u]+Math.sin(n*c)*l[u]);return{latDeg:Math.asin(h[2])/c,lonDeg:Math.atan2(h[1],h[0])/c}}static radiusAt(t,e){const i=t.radiusDeg.length,n=(e/360*i%i+i)%i,s=Math.floor(n),r=n-s;return t.radiusDeg[s]*(1-r)+t.radiusDeg[(s+1)%i]*r}static uncoveredFraction(t,e,i){const n=t.radiusDeg.length,s=i.upDeg*i.upDeg+i.rightDeg*i.rightDeg;let r=0;for(let a=0;a<n;a++){const c=a/n*2*Math.PI,l=Math.cos(c),h=Math.sin(c),u=l*i.upDeg+h*i.rightDeg,d=u*u-s+e*e;if(d<=0)continue;const f=Math.sqrt(d),p=u+f;if(p<=0)continue;const g=Math.max(0,u-f),m=Math.max(g,t.radiusDeg[a]);p>m&&(r+=.5*(p*p-m*m))}return Math.min(1,Math.max(0,r*(2*Math.PI/n)/(Math.PI*e*e)))}static AU_KM=1495978707e-1;static bodyFixed(t){const e=jO(gt.Moon,t),i=Math.PI/180,n=e.ra*15*i,s=e.dec*i,r=e.spin*i,a=(l,[h,u,d])=>[Math.cos(l)*h+Math.sin(l)*u,-Math.sin(l)*h+Math.cos(l)*u,d],c=(l,[h,u,d])=>[h,Math.cos(l)*u+Math.sin(l)*d,-Math.sin(l)*u+Math.cos(l)*d];return l=>a(r,c(Math.PI/2-s,a(Math.PI/2+n,[l.x,l.y,l.z])))}static subObserverPoint(t,e){const i=new nc(e.lat,e.lng,e.elevationM),n=ro(t),s=bM(t,i,!1),r=dr.bodyFixed(t)(new Be(s.x-n.x,s.y-n.y,s.z-n.z,n.t)),a=Math.hypot(r[0],r[1],r[2]);return{latDeg:Math.asin(r[2]/a)*180/Math.PI,lonDeg:Math.atan2(r[1],r[0])*180/Math.PI}}}class rd{static cache=new Map;static load(t){let e=rd.cache.get(t);return e||(e=rd.fetchRelief(t).catch(()=>{}),rd.cache.set(t,e)),e}static async fetchRelief(t){const e=await fetch(t);if(!e.ok)return;let i=new Uint8Array(await e.arrayBuffer());if(i[0]===31&&i[1]===139){if(typeof DecompressionStream>"u")return;const n=new Blob([i]).stream().pipeThrough(new DecompressionStream("gzip"));i=new Uint8Array(await new Response(n).arrayBuffer())}return new ai(new Int8Array(i.buffer,i.byteOffset,i.length))}}const ry=Gs.catalog({en:()=>dt(()=>import("./PerceptionMessages_en-B2O6DR64.js"),[],import.meta.url).then(o=>o.perceptionMessages_en),fr:()=>dt(()=>import("./PerceptionMessages_fr-B59TnGBC.js"),[],import.meta.url).then(o=>o.perceptionMessages_fr),es:()=>dt(()=>import("./PerceptionMessages_es-BmkP6OqD.js"),[],import.meta.url).then(o=>o.perceptionMessages_es),it:()=>dt(()=>import("./PerceptionMessages_it-DPlxRmxu.js"),[],import.meta.url).then(o=>o.perceptionMessages_it)});class Pp{static ID="color-vision";static MATRICES={protan:[.152286,1.052583,-.204868,.114503,.786281,.099216,-.003882,-.048116,1.051998],deutan:[.367322,.860646,-.227968,.280085,.672501,.047413,-.01182,.04294,.968881],tritan:[1.255528,-.076749,-.178779,-.078411,.930809,.147602,.004733,.691367,.3039]};id=Pp.ID;messages=ry;sources=["Machado, Oliveira, Fernandes, A Physiologically-based Model for Simulation of Color Vision Deficiency, IEEE TVCG 15(6), 2009"];settings=[{id:"type",kind:"choice",default:"normal",choices:[{id:"normal"},{id:"protan"},{id:"deutan"},{id:"tritan"}]},{id:"severity",kind:"number",default:100,min:0,max:100,step:5,unit:"%"}];perceive(t){const e=Pp.MATRICES[String(t.type)];if(!e)return Bs.NONE;const i=Number(t.severity??100),n=Math.max(0,Math.min(100,Number.isFinite(i)?i:100))/100;return{colorMatrix:e.map((r,a)=>Bs.IDENTITY[a]+(r-Bs.IDENTITY[a])*n),contrastGain:1}}}class ay{static ID="fatigue";id=ay.ID;messages=ry;sources=["Studies of contrast sensitivity during prolonged sleep deprivation (60 hours, naval officers): no significant change"];settings=[{id:"hoursAwake",kind:"number",default:0,min:0,max:72,step:1,unit:"h"}];perceive(t){return Bs.NONE}}class Tc{static ID="intoxication";static MEASURED_LEVEL=.08;static MEASURED_LOSS_DB=.9;static MAX_EFFECT_LEVEL=.1;static MAX_LEVEL=.5;id=Tc.ID;messages=ry;sources=["Frontiers in Neuroscience, 2022, doi:10.3389/fnins.2022.873671 (contrast sensitivity at about 0.08 % blood alcohol)"];settings=[{id:"bloodAlcohol",kind:"number",default:0,min:0,max:Tc.MAX_LEVEL,step:.01,unit:"%",also:{unit:"g/L",factor:10,digits:1}}];perceive(t){const e=Number(t.bloodAlcohol??0),i=Math.max(0,Math.min(Tc.MAX_EFFECT_LEVEL,Number.isFinite(e)?e:0));if(i===0)return Bs.NONE;const n=i/Tc.MEASURED_LEVEL*Tc.MEASURED_LOSS_DB;return{colorMatrix:Bs.IDENTITY,contrastGain:10**(-n/20)}}}const vL=o=>o.sources[0]??o.id,yL=Te.point("perception").provide(Te.BUILT_IN,[new Pp,new Tc,new ay].map(o=>({id:o.id,name:o.id,credit:vL(o),creditUrl:"https://ufoathome.org/docs/sources/",create:()=>o})));class Rc{static built=new WeakMap;static get ALL(){return yL.map(t=>{let e=Rc.built.get(t);return e||(e=t.create(),Rc.built.set(t,e)),e})}static byId(t){return Rc.ALL.find(e=>e.id===t)}static perceptionOf(t){return Rc.ALL.reduce((e,i)=>Bs.combine(e,i.perceive(t?.[i.id]??{})),Bs.NONE)}static compact(t){const e={},i=Rc.ALL;for(const[n,s]of Object.entries(t))!i.some(r=>r.id===n)&&Object.keys(s??{}).length>0&&(e[n]=s);for(const n of i){const s=t[n.id]??{},r=Object.fromEntries(n.settings.filter(a=>s[a.id]!==void 0&&s[a.id]!==a.default).map(a=>[a.id,s[a.id]]));Object.keys(r).length>0&&(e[n.id]=r)}return Object.keys(e).length>0?e:void 0}}class Dc{static NONE={id:"none",name:"No filter",opticalDensity:0};static SOLAR_VISUAL={id:"solar-visual",name:"Solar filter for the eye (OD 5)",opticalDensity:5,usableWith:["eye","binoculars","telescope"]};static SOLAR_PHOTO={id:"solar-photo",name:"Solar film for a camera (OD 3.8)",opticalDensity:3.8,usableWith:["camera","dslr","phone","telescope"]};static ALL=[Dc.NONE,Dc.SOLAR_VISUAL,Dc.SOLAR_PHOTO];static usableWith(t,e){return!t.usableWith||t.usableWith.includes(e.category)}static byId(t){return Dc.ALL.find(e=>e.id===t)??Dc.NONE}static transmittance(t){return 10**-t.opticalDensity}static magnitudes(t){return 2.5*t.opticalDensity}}class jS{names;constructor(t){this.names=t??Gs.blank(),this.loaded=t!==void 0}loaded;body(t){return this.names.bodies[t]??t}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){return this.names.decorKinds[t]}point(t){return Yc.point(t,this.loaded?this.names.compassPoints:void 0)}towards(t){return Yc.towards(t,this.loaded?this.names:void 0)}}class jr{static STANDARD_GAUGE_MM=1435;static METRE_GAUGE_MM=1e3;static kind(t,e){return t.highSpeed?e.highSpeed:t.service?e.service:e.kinds[t.kind]}static name(t,e){const i=t.name??jr.kind(t,e);return t.services?.length?`${i} — ${t.services.join(", ")}`:i}static voltage(t,e){return t>=1e3?`${(t/1e3).toLocaleString(e,{maximumFractionDigits:1})} kV`:`${t.toLocaleString(e)} V`}static detail(t,e,i,n){const{line:s}=t,r=[];s.name&&r.push(jr.kind(s,e).toLocaleLowerCase(n)),r.push(s.tracks>1?e.tracks.replace("{count}",String(s.tracks)):e.singleTrack);const a=s.voltageV?jr.voltage(s.voltageV,n):void 0;if(t.contactM!==void 0){const c=t.contactM.toLocaleString(n,{minimumFractionDigits:2,maximumFractionDigits:2});r.push((a?e.overheadVoltage.replace("{voltage}",a):e.overhead).replace("{height}",c))}else s.electrification==="third_rail"?r.push(a?e.thirdRailVoltage.replace("{voltage}",a):e.thirdRail):s.electrification==="none"&&r.push(e.notElectrified);return s.gaugeMm===jr.METRE_GAUGE_MM?r.push(e.metreGauge):s.gaugeMm!==jr.STANDARD_GAUGE_MM&&r.push(e.gauge.replace("{mm}",s.gaugeMm.toLocaleString(n))),r.push(e.distance.replace("{distance}",i(t.distanceM))),s.services?.length?`${jr.name(s,e)}; ${r.join(", ")}`:`${jr.name(s,e)} — ${r.join(", ")}`}}class ad{constructor(t,e){this.element=t,this.onChange=e,t.addEventListener("error",()=>{this.url=void 0,this.release()})}shown=!1;url;get up(){return this.shown}show(t,e,i=!0){const n=ad.resolve(t,e);if(this.url=n,!n||!i){this.release();return}this.element.src=n,this.element.hidden=!1;const s=this.shown;this.shown=!0,s||this.onChange()}release(){this.shown&&(this.shown=!1,this.element.hidden=!0,this.element.removeAttribute("src"),this.onChange())}restore(){this.url&&this.show(this.url)}static resolve(t,e){if(!(typeof t!="string"||t.trim()===""))try{const i=new URL(t.trim(),e??location.href);return i.protocol!=="https:"&&i.protocol!=="http:"?void 0:i.origin===ad.PUBLISHED_ORIGIN&&ad.isDevelopmentHost(location.hostname)?location.origin+i.pathname:i.href}catch{return}}static PUBLISHED_ORIGIN="https://ufoathome.org";static isDevelopmentHost(t){return t==="localhost"||t==="127.0.0.1"||t==="[::1]"||t.endsWith(".localhost")}}const xL="Global Meteor Network",wL="https://globalmeteornetwork.org/data/",SL="“Thunder” by Jerimee",bL="https://creativecommons.org/licenses/by/3.0/",EL="CC BY 3.0";class Qn{static fill(t,e){t.innerHTML="";const i=d=>t.appendChild(d),n=e.currentTerrainAttribution;n&&i(Qn.text(n));const s=e.currentRoadAttribution;s&&i(Qn.text(s));const r=e.currentWaterAttribution;r&&i(Qn.text(r));const a=e.currentRailwayAttribution;a&&i(Qn.text(a));const c=e.ufoElement.observerMapCredit;c&&!n?.includes(c)&&i(Qn.text(c));for(const d of e.decorModelCredits){const f=d.author?` — ${d.author}`:"",p=document.createElement("li");d.sourceUrl?p.append(Qn.link(d.sourceUrl,d.title),document.createTextNode(`${f} (${d.license})`)):p.textContent=`${d.title}${f} (${d.license})`,i(p)}for(const d of e.ufoElement.sighting.references){if(!d.credit)continue;const f=document.createElement("li");d.creditUrl?f.appendChild(Qn.link(d.creditUrl,d.credit)):f.textContent=d.credit,i(f)}if(e.ufoElement.sighting.traces.length>0){const d=new Cr(Lo.preferencesFor(e)),f=new Set(e.ufoElement.sighting.traces.map(p=>d.read(p.source)).filter(p=>!!p));for(const p of f)i(Qn.text(p))}const l=e.satelliteState;if(l.status==="ready"&&l.credit){const d=document.createElement("li");d.appendChild(Qn.link(l.creditUrl??"",l.credit)),i(d)}if(e.fireballState.status==="ready"&&e.fireballState.records.length>0){const d=document.createElement("li");d.append(Qn.link(wL,xL),document.createTextNode(" (CC BY 4.0)")),i(d)}const h=e.aircraftState;if(h.status==="ready"&&h.shown>0){const d=document.createElement("li");if(d.appendChild(Qn.link(h.creditUrl,h.credit)),i(d),h.trailCredit){const f=document.createElement("li");f.appendChild(Qn.link(h.trailCredit.creditUrl,h.trailCredit.credit)),i(f)}}const u=Qn.text(`${SL} (`);u.append(Qn.link(bL,EL),document.createTextNode(")")),i(u)}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}}class Gi{static OCTAVES=[63,125,250,500,1e3,2e3,4e3,8e3];static STANDARD={temperatureC:15,relativeHumidity:.7,pressureKPa:101.325};static REFERENCE_PRESSURE_KPA=101.325;static REFERENCE_TEMPERATURE_K=293.15;static TRIPLE_POINT_K=273.16;static speedOfSound(t){return 20.0468*Math.sqrt(t+273.15)}static absorptionDbPerKm(t,e=Gi.STANDARD){const i=e.temperatureC+273.15,n=Gi.REFERENCE_TEMPERATURE_K,s=e.pressureKPa/Gi.REFERENCE_PRESSURE_KPA,r=10**(-6.8346*(Gi.TRIPLE_POINT_K/i)**1.261+4.6151),a=e.relativeHumidity*100*r/s,c=s*(24+40400*a*(.02+a)/(.391+a)),l=s*(i/n)**-.5*(9+280*a*Math.exp(-4.17*((i/n)**(-1/3)-1))),h=t*t;return 8.686*h*(184e-13*(1/s)*Math.sqrt(i/n)+(i/n)**-2.5*(.01275*Math.exp(-2239.1/i)/(c+h/c)+.1068*Math.exp(-3352/i)/(l+h/l)))*1e3}static aWeightingDb(t){const e=t*t,i=12194**2*e*e/((e+20.6**2)*Math.sqrt((e+107.7**2)*(e+737.9**2))*(e+12194**2));return 20*Math.log10(i)+2}static sumDb(t){return 10*Math.log10(t.reduce((e,i)=>e+10**(i/10),0))}}const AL=new URL(""+new URL("rain-BvWZrB9h.ogg",import.meta.url).href,import.meta.url).href,_L=new URL(""+new URL("wind-BjklexY7.ogg",import.meta.url).href,import.meta.url).href,QS=new URL(""+new URL("thunder-DA48qs_v.wav",import.meta.url).href,import.meta.url).href,TL=20,RL=1,DL=7,IL=.35,tb=.4,eb=40,ib=.5,CL=Math.SQRT2;class Gc{context;constructor(t){this.context=t}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};around;aroundRequested={rms:0,shape:[]};level=1;share=1;master;output(t){return this.master||(this.master=t.createGain(),this.master.gain.value=this.gain,this.master.connect(t.destination)),this.master}get gain(){return this.level*this.share}setLevel(t){this.level=t,this.master&&(this.master.gain.value=this.gain)}setOutsideHeard(t){this.share=Math.min(1,Math.max(0,t)),this.master&&(this.master.gain.value=this.gain)}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}}er.isLive(this.context)&&er.unlock(this.context),this.applyAround()}setAround(t,e){const i=this.aroundRequested;i.rms===Math.max(0,t)&&i.shape.length===e.length&&i.shape.every((n,s)=>n===e[s])||(this.aroundRequested={rms:Math.max(0,t),shape:e},this.applyAround())}applyAround(){const t=this.context;if(!t)return;const{rms:e,shape:i}=this.aroundRequested,n=this.paused?0:e;if(n===0&&!this.around)return;const s=this.around??(this.around=this.buildAround(t)),r=t.currentTime;s.gain.gain.setTargetAtTime(n,r,ib),Gi.OCTAVES.forEach((a,c)=>{const l=Math.sqrt(Math.min(1,1.11*a/(t.sampleRate/2)))/Math.sqrt(3);s.bands[c].gain.setTargetAtTime((i[c]??0)/l,r,ib)})}buildAround(t){const e=t.createBuffer(1,Math.floor(t.sampleRate*DL),t.sampleRate),i=e.getChannelData(0);for(let g=0;g<i.length;g++)i[g]=Math.random()*2-1;const n=t.createBufferSource();n.buffer=e,n.loop=!0;const s=Math.floor(t.sampleRate*eb),r=t.createBuffer(1,s,t.sampleRate),a=Array.from({length:Math.round(eb*tb)},()=>Math.random()*2-1),c=r.getChannelData(0),l=t.sampleRate/tb;for(let g=0;g<s;g++){const m=g/l,M=Math.floor(m),v=m-M,x=v*v*(3-2*v);c[g]=a[M%a.length]*(1-x)+a[(M+1)%a.length]*x}const h=t.createBufferSource();h.buffer=r,h.loop=!0;const u=t.createGain();u.gain.value=IL;const d=t.createGain();d.gain.value=1,h.connect(u).connect(d.gain);const f=t.createGain();f.gain.value=0,d.connect(f).connect(this.output(t));const p=Gi.OCTAVES.map(g=>{const m=t.createBiquadFilter();m.type="bandpass",m.frequency.value=g,m.Q.value=CL;const M=t.createGain();return M.gain.value=0,n.connect(m).connect(M).connect(d),M});return n.start(),h.start(),{sources:[n,h],nodes:[u,d,f,...p],bands:p,gain:f}}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 r=++this.ambientToken;this.stopSource(this.ambientSource,this.ambientGain),this.ambientSource=void 0,this.ambientGain=void 0,n!=="none"&&this.startLoop(AL,this.ambientVolume).then(a=>this.applyIfCurrent(a,r,()=>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/TL,1);const s=i>RL;if(s!==this.windActive){this.windActive=s;const r=++this.windToken;this.stopSource(this.windSource,this.windGain),this.windSource=void 0,this.windGain=void 0,s&&this.startLoop(_L,this.windVolume).then(a=>this.applyIfCurrent(a,r,()=>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),this.applyAround()}playThunder(){!this.context||this.paused||this.playOneShot(QS,.9)}playDetonation(t){const e=this.context;if(!e||this.paused)return;const i=Math.min(1,Math.max(0,t)),n=e.createBufferSource();n.buffer=this.crackBuffer(e);const s=e.createBiquadFilter();s.type="lowpass",s.frequency.value=Gc.CRACK_CUTOFF_HZ;const r=e.createGain();r.gain.value=i,n.connect(s).connect(r).connect(this.output(e)),n.start(),this.playOneShot(QS,i,Gc.DETONATION_RATE)}static DETONATION_RATE=.8;static CRACK_CUTOFF_HZ=2500;static CRACK_DECAY_S=.25;crackBuffer(t){if(this.crack?.sampleRate===t.sampleRate)return this.crack;const e=Math.round(t.sampleRate*Gc.CRACK_DECAY_S*6),i=t.createBuffer(1,e,t.sampleRate),n=i.getChannelData(0);for(let s=0;s<e;s++){const r=s/t.sampleRate;n[s]=(Math.random()*2-1)*Math.min(1,r/.005)*Math.exp(-r/Gc.CRACK_DECAY_S)}return this.crack=i,i}crack;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;for(const t of this.around?.sources??[])try{t.stop()}catch{}for(const t of this.around?.nodes??[])t.disconnect();this.around=void 0,er.isLive(this.context)&&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 r=i.createGain();return r.gain.value=e,s.connect(r).connect(this.output(i)),s.start(),{source:s,gain:r}}catch(n){console.warn("Weather ambient sound failed to load, staying silent:",n);return}}async playOneShot(t,e,i=1){const n=this.context;if(n)try{const s=await this.getBuffer(t),r=n.createBufferSource();r.buffer=s,r.playbackRate.value=i;const a=n.createGain();a.gain.value=e,r.connect(a).connect(this.output(n)),r.start()}catch(s){console.warn("Thunder sound failed to load:",s)}}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()}}const PL={rollingA:[83.1,89.2,87.7,93.1,100.1,96.7,86.8,76.2],rollingB:[30,41.5,38.9,25.7,32.5,37.2,39,40],propulsionA:[97.9,92.5,90.7,87.2,84.7,88,84.4,77.1],propulsionB:[-1.3,7.2,7.7,8,8,8,8,8]},OL={rollingA:[91.7,96.2,98.2,104.9,105.1,98.5,91.1,85.6],rollingB:[30,33.5,31.3,25.4,31.8,37.1,38.6,40.6],propulsionA:[108.8,104.2,103.5,102.9,102.6,98.5,93.8,87.5],propulsionB:[0,3,4.6,5,5,5,5,5]},n1=70,NL=55+10*Math.log10(2*Math.PI),s1=5,LL=2;class gn{static vehiclePowerDbA(t,e){return Gi.sumDb(gn.vehiclePowerBands(t,e).map((i,n)=>i+Gi.aWeightingDb(Gi.OCTAVES[n])))}static vehiclePowerBands(t,e){const i=t?OL:PL,n=Math.max(e,1);return Gi.OCTAVES.map((s,r)=>{const a=i.rollingA[r]+i.rollingB[r]*Math.log10(n/n1),c=i.propulsionA[r]+i.propulsionB[r]*(n-n1)/n1;return Gi.sumDb([a,c])})}static dbA(t,e=!0){if(!Ro.says(t))return-1/0;const i=t.withinM??Ro.DEFAULT_WITHIN_M,n=Ro.DEFAULT_SPEED_KMH,s=[gn.counted(t.cars,gn.vehiclePowerDbA(!1,n),i,s1),gn.counted(t.trucks,gn.vehiclePowerDbA(!0,n),i,s1),e?gn.counted(t.talking,NL,i,LL):-1/0,...(t.roads??[]).map(r=>gn.road(r.distanceM,r.vehiclesPerMinute,r.trucksPerMinute??0,r.speedKmh??n))].filter(r=>Number.isFinite(r));return s.length>0?Gi.sumDb(s):-1/0}static vehicleShape(t){if(!Ro.says(t))return;const e=t.withinM??Ro.DEFAULT_WITHIN_M,i=Ro.DEFAULT_SPEED_KMH,n=l=>{const h=gn.counted(l?t.trucks:t.cars,gn.vehiclePowerDbA(l,i),e,s1),u=(t.roads??[]).map(f=>{const p=Math.min(f.trucksPerMinute??0,f.vehiclesPerMinute);return l?gn.road(f.distanceM,p,p,f.speedKmh??i):gn.road(f.distanceM,f.vehiclesPerMinute-p,0,f.speedKmh??i)}),d=[h,...u].filter(Number.isFinite);return d.length>0?10**(Gi.sumDb(d)/10):0},s=n(!1),r=n(!0);if(s+r===0)return;const a=Gi.OCTAVES.map(()=>0);for(const[l,h]of[[s,!1],[r,!0]]){if(l===0)continue;const u=gn.vehiclePowerBands(h,i),d=Gi.sumDb(u.map((f,p)=>f+Gi.aWeightingDb(Gi.OCTAVES[p])));u.forEach((f,p)=>a[p]+=l*10**((f-d)/10))}const c=Math.sqrt(a.reduce((l,h)=>l+h,0));return a.map(l=>Math.sqrt(l)/c)}static counted(t,e,i,n){if(!t)return-1/0;const s=Math.min(n,i*.99),r=t*Math.log(i/s)/(Math.PI*(i*i-s*s));return e+10*Math.log10(r)}static road(t,e,i,n){const s=Math.min(i,e),r=(c,l)=>c>0?gn.vehiclePowerDbA(l,n)+10*Math.log10(c/(1e3*Math.max(n,1))):-1/0,a=Gi.sumDb([r((e-s)*60,!1),r(s*60,!0)].filter(Number.isFinite));return Number.isFinite(a)?a-10*Math.log10(Math.PI*Math.max(t,1)):-1/0}}class wi{static BASE_DB_A=30;static OUTDOOR_SHAPE_DB=[-12,-7,-5,-5,-7,-11,-17,-25];static HEADROOM_DB=10.5;static AROUND_BED_PLAYED=!1;static WIND_DB_A=[[0,10],[1,28],[2,36],[3,40],[5,46],[8,52],[12,58],[20,66]];static RAIN_DB_A=[[0,0],[.1,42],[.3,50],[.6,58],[1,65]];static BED_RMS=.2;static MINIMUM_REFERENCE=.008;static WIND_BED_MIN_MS=1;static WIND_BED_FULL_MS=20;static dbA(t,e){const i=[wi.BASE_DB_A,wi.along(wi.WIND_DB_A,t.windSpeed),gn.dbA(e)].filter(Number.isFinite);return(t.precipitationType==="rain"||t.precipitationType==="hail")&&i.push(wi.along(wi.RAIN_DB_A,t.precipitationIntensity)),10*Math.log10(i.filter(n=>n>0).reduce((n,s)=>n+10**(s/10),0))}static bedVolume(t){const e=t.windSpeed>wi.WIND_BED_MIN_MS?Math.min(t.windSpeed/wi.WIND_BED_FULL_MS,1):0,i=t.precipitationType==="hail"?Math.min(1,t.precipitationIntensity*1.3+.2):t.precipitationType==="rain"?t.precipitationIntensity:0;return Math.hypot(e,i)}static referenceAmplitude(t,e){return Math.max(Math.hypot(wi.BED_RMS*wi.bedVolume(t),wi.aroundReference(e)),wi.MINIMUM_REFERENCE)}static aroundReference(t){const e=gn.dbA(t);return!Number.isFinite(e)||e<=wi.BASE_DB_A?0:wi.MINIMUM_REFERENCE*10**((e-wi.BASE_DB_A)/20)}static aroundBedRms(t){if(!wi.AROUND_BED_PLAYED)return 0;const e=gn.dbA(t,!1);return!Number.isFinite(e)||e<=wi.BASE_DB_A?0:Math.min(wi.BED_RMS,wi.MINIMUM_REFERENCE*10**((e-wi.BASE_DB_A-wi.HEADROOM_DB)/20))}static bedPlays(t,e){return wi.bedVolume(t)>0||wi.aroundBedRms(e)>0}static shapeDb(t,e){const i=10**(wi.dbA(t,e)/10),n=gn.dbA(e,!1),s=Number.isFinite(n)?10**(n/10):0,r=Math.max(0,i-s),a=wi.OUTDOOR_SHAPE_DB,c=10**(Gi.sumDb(a)/10),h=gn.vehicleShape(e)?.map((p,g)=>p*p*10**(Gi.aWeightingDb(Gi.OCTAVES[g])/10)),u=h?.reduce((p,g)=>p+g,0)??1,d=Gi.OCTAVES.map((p,g)=>r*10**(a[g]/10)/c+(h?s*h[g]/u:0)),f=d.reduce((p,g)=>p+g,0);return d.map(p=>10*Math.log10(p/f))}static aroundBedShape(t){return gn.vehicleShape(t)}static along(t,e){if(e<=t[0][0])return t[0][1];for(let i=1;i<t.length;i++)if(e<=t[i][0]){const[n,s]=t[i-1],[r,a]=t[i];return s+(a-s)*(e-n)/(r-n)}return t[t.length-1][1]}}class Ga{constructor(t){this.elements=t;const{eccentricity:e,perihelionAu:i}=t,[n,s]=this.perifocalAxes(),r=Math.sqrt(Ga.SUN_GM_AU3_PER_DAY2*(1+e)/i);this.perihelionPosition=this.scale(n,i),this.perihelionVelocity=this.scale(s,r),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,r=1-i*i/s*Ga.stumpffC(n),a=e-i*i*i/Math.sqrt(Ga.SUN_GM_AU3_PER_DAY2)*Ga.stumpffS(n);return{x:r*this.perihelionPosition.x+a*this.perihelionVelocity.x,y:r*this.perihelionPosition.y+a*this.perihelionVelocity.y,z:r*this.perihelionPosition.z+a*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(Ga.SUN_GM_AU3_PER_DAY2)*Math.abs(t),n=a=>{const c=this.inverseSemiMajorAxis*a*a,l=this.elements.perihelionAu;return(1-this.inverseSemiMajorAxis*l)*a*a*a*Ga.stumpffS(c)+l*a};let s=Math.max(1,i/this.elements.perihelionAu);for(;n(s)<i;)s*=2;let r=0;for(let a=0;a<Ga.MAX_ITERATIONS&&s-r>1e-13*Math.max(1,s);a++){const c=(r+s)/2;n(c)<i?r=c:s=c}return e*(r+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),r=Math.cos(e),a=Math.sin(e),c=Math.cos(i),l=Math.sin(i);return[{x:n*r-s*a*c,y:s*r+n*a*c,z:a*l},{x:-n*a-s*r*c,y:-s*a+n*r*c,z:r*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 qA=[{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 kL{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 qA.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=pi(e),s=this.earthPositionAt(n),r=this.apparentPositionOf(t,2451545+n.tt,s),a=this.subtract(r,s),c=this.length(r),l=this.length(a),h=this.tailEndAt(t,r,s,c,n,e,i),u=this.horizontalOf(a,n,e,i);return{apparition:t,position:u,...h,heliocentricDistanceAu:c,earthDistanceAu:l,elongationDeg:this.angleBetween(a,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,r,a){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,r,a),tailLengthDeg:this.angleBetween(h,l)}}static apparentPositionOf(t,e,i){const n=this.orbitOf(t);let s=n.positionAt(e);for(let r=0;r<2;r++){const a=this.length(this.subtract(s,i))/this.LIGHT_SPEED_AU_PER_DAY;s=n.positionAt(e-a)}return s}static horizontalOf(t,e,i,n){const s=io(PO(),new Be(t.x,t.y,t.z,e)),r=io(AA(e),s),a=bM(e,new nc(n.lat,n.lng,n.elevationM),!0),c=new Be(r.x-a.x,r.y-a.y,r.z-a.z,e),l=tm(c);return qv(l.ra,l.dec,i,n)}static earthPositionAt(t){return io(CO(),jo(gt.Earth,t))}static julianDayOf(t){return 2451545+pi(t).tt}static orbitOf(t){const e=this.orbits.get(t.id);if(e)return e;const i=new Ga(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 r1=[{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 nb{static UNIX_EPOCH_JD=24405875e-1;static aroundDate(t){const e=this.julianDayOf(t);return r1.filter(i=>this.magnitudeAt(i,e)!==void 0)}static appearancesAt(t,e){const i=this.julianDayOf(t),n=[];for(const s of r1){const r=this.magnitudeAt(s,i);r!==void 0&&n.push({outburst:s,position:Ir.ofJ2000(s.raHours,s.decDeg,t,e),magnitude:r})}return n.sort((s,r)=>s.magnitude-r.magnitude)}static brightestAt(t,e){return this.appearancesAt(t,e)[0]}static byId(t){return r1.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[r,a]=i[s-1]??i[0],[c,l]=i[s]??i[0];if(c===r)return a;const h=Math.min(1,Math.max(0,(n-r)/(c-r)));return a+h*(l-a)}static julianDayOf(t){return t.getTime()/864e5+this.UNIX_EPOCH_JD}}const FL=[{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}],Op=6.5;class a1{static activeAt(t){return FL.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)),r=this.dayOfYear(this.asDate(t.end)),a=this.wrappedDelta(i,s),c=this.wrappedDelta(s,n),l=this.wrappedDelta(r,s);return a<0?a<-c?0:1+a/c:a>0?a>l?0:1-a/l:1}static observedRatePerHour(t,e,i,n=Op){if(e<=0)return 0;const s=Op-n;return t*Math.sin(e*Math.PI/180)/Math.pow(i,s)}static radiantPosition(t,e,i){return Ir.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 qi{static QUIET_RATE_PER_HOUR=2;static APEX_RATE_PER_HOUR=8;static POPULATION_INDEX=3;static apexPosition(t,e){const i=pi(t),n=new Zp(0,lO(t).elon-90,1),s=io(FO(i),$v(n,i)),r=tm(s);return qv(r.ra,r.dec,t,e)}static observedRatePerHour(t,e=Op){const i=qi.APEX_RATE_PER_HOUR*Math.max(0,Math.sin(t*Math.PI/180)),n=Op-e;return(qi.QUIET_RATE_PER_HOUR+i)/Math.pow(qi.POPULATION_INDEX,n)}static schedule(t){const e=new em(t.seed^1542469173);return pr.schedule(t).map(i=>{const n=qi.toCartesian({altitudeDeg:Math.asin(e.next())*180/Math.PI,azimuthDeg:e.between(0,360)}),s=i.fromRadiantDeg*Math.PI/180,r=qi.turnAround(n,e.between(0,360)),a={x:n.x*Math.cos(s)+r.x*Math.sin(s),y:n.y*Math.cos(s)+r.y*Math.sin(s),z:n.z*Math.cos(s)+r.z*Math.sin(s)};return{...i,radiant:qi.toHorizontal(a),bearingDeg:qi.bearingFrom(a,n)}})}static turnAround(t,e){const[i,n]=qi.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]=qi.basisAround(t),s=t.x*e.x+t.y*e.y+t.z*e.z,r=qi.normalise({x:e.x-t.x*s,y:e.y-t.y*s,z:e.z-t.z*s});return(Math.atan2(r.x*n.x+r.y*n.y+r.z*n.z,r.x*i.x+r.y*i.y+r.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=qi.normalise(qi.cross(t,e));return[i,qi.normalise(qi.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=qi.toCartesian(t.radiant??{altitudeDeg:90,azimuthDeg:0}),i=qi.turnAround(e,t.bearingDeg),n=t.fromRadiantDeg*Math.PI/180;return qi.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 sb="https://ufoathome.org/tle/index.json";class ts{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??ts.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(sb)||t.push(sb),t}static FIRST_SNAPSHOT="2021-02-22";async covers(t){const e=Date.parse(`${ts.FIRST_SNAPSHOT}T00:00:00Z`)-ts.MAX_ELEMENT_AGE_DAYS*ts.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)-ts.MAX_ELEMENT_AGE_DAYS*ts.DAY_MS&&t.getTime()<=Date.parse(n.to)+ts.MAX_ELEMENT_AGE_DAYS*ts.DAY_MS):!1}async at(t){const e=await this.loadIndex();if(!e)return;const{index:i,base:n}=e,s=[],r=[];for(const a of Object.keys(i.kinds)){const c=await this.kindAt(a,t,i,n);s.push(...c),r.push(this.coverageOf(a,t,i,c.length>0))}return{objects:s,coverage:r,credit:i.credit,creditUrl:i.source}}async kindAt(t,e,i,n){const s=e.getTime(),r=i.binDays*ts.DAY_MS,a=Math.floor(s/r),c=s-a*r<r/2?a-1:a+1,l=new Set(i.kinds[t].bins),h=[a,c].map(g=>new Date(g*r).toISOString().slice(0,10)).filter(g=>l.has(g));if(h.length===0)return[];const[u,...d]=await Promise.all([this.json(new URL(`objects-${t}.json`,n).href),...h.map(g=>this.binary(new URL(`${t}/${g}.bin`,n).href))]),f=new Map;for(const g of d)for(const m of ts.decode(g,i.recordBytes)){const M=f.get(m.norad);(!M||Math.abs(m.epochMs-s)<Math.abs(M.epochMs-s))&&f.set(m.norad,m)}const p=[];for(const g of f.values()){const m=Math.abs(g.epochMs-s)/ts.DAY_MS;if(m>ts.MAX_ELEMENT_AGE_DAYS)continue;const M=u[g.norad]??{name:String(g.norad)};M.launch&&Date.parse(`${M.launch}T00:00:00Z`)>s||p.push({norad:g.norad,name:M.name,kind:t,launch:M.launch,stdMag:M.stdMag,elements:g,ageDays:m})}return p}coverageOf(t,e,i,n){const{from:s,to:r}=i.kinds[t],a=e.getTime(),c=ts.MAX_ELEMENT_AGE_DAYS*ts.DAY_MS,l=n?"covered":a<Date.parse(s)-c?"before":a>Date.parse(r)+c?"after":"gap";return{kind:t,status:l,from:s,to:r}}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 UL{lowerM;upperM;add(t,e){if(!(t<=0)){if(e.behindM!==void 0){const i=fi.sizeMAt(e.behindM,t);this.lowerM=this.lowerM===void 0?i:Math.max(this.lowerM,i)}if(e.inFrontM!==void 0){const i=fi.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:fi.distanceMAt(this.lowerM,t),maxM:this.upperM===void 0?void 0:fi.distanceMAt(this.upperM,t)}}clear(){this.lowerM=void 0,this.upperM=void 0}}class Kc{static DEG_PER_SECOND=360/86164.0905;static degOver(t){return Math.max(0,t)*Kc.DEG_PER_SECOND}static instants(t,e){if(!(e>0))return 1;const i=Kc.degOver(t)/e;return i<1?1:Math.min(Kc.MAX_INSTANTS,Math.max(2,Math.ceil(i)))}static MAX_INSTANTS=64}class Wn{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 Kc.DEG_PER_SECOND*3600}static graspOf(t,e={}){if(t.visualAid)return Wn.visualAidGrasp(t,e.focalLengthMm);const i=e.exposureSeconds??t.exposureSeconds,n=e.fNumber??t.fNumber;if(i===void 0||n===void 0||!(i>0)||!(n>0))return Wn.EYE;const s=e.focalLengthMm??t.frame?.focalLengthMm??Wn.UNKNOWN_CAMERA_FOCAL_MM,r=s/n,a=Wn.resolutionArcsec(t,s,r);return{apertureMm:r,exposureSeconds:Math.min(i,Wn.trailLimitedSeconds(a)),resolutionArcsec:a}}static visualAidGrasp(t,e){const i=t.visualAid,n=Wn.EYE,s=e??t.frame?.focalLengthMm,r=i.magnification??(s!==void 0&&i.eyepieceFocalMm?s/i.eyepieceFocalMm:1),a=Math.min(i.apertureMm,n.apertureMm*r);return{apertureMm:Math.max(a,n.apertureMm),exposureSeconds:n.exposureSeconds,resolutionArcsec:n.resolutionArcsec/Math.max(1,Math.min(r,i.apertureMm/n.apertureMm))}}static resolutionArcsec(t,e,i){const s=(t.detailUm??Wn.UNKNOWN_CAMERA_DETAIL_UM)/1e3/e*Wn.ARCSEC_PER_RADIAN,r=1.22*Wn.WAVELENGTH_M/(i/1e3)*Wn.ARCSEC_PER_RADIAN;return Math.max(s,r)}static trailLimitedSeconds(t){return t/Wn.skyDriftArcsecPerSecond}static gainOverEye(t,e={}){const i=Wn.graspOf(t,e),n=Wn.EYE,s=(i.apertureMm/n.apertureMm)**2,r=i.exposureSeconds/n.exposureSeconds,a=(n.resolutionArcsec/i.resolutionArcsec)**2;return 1.25*Math.log10(s*r*a)}static gainFor(t,e){const i=e.fieldOfViewDeg===void 0?void 0:Ji.focalLengthMmFor(t,e.fieldOfViewDeg);return Wn.gainOverEye(t,{fNumber:e.fNumber,focalLengthMm:i,exposureSeconds:e.exposureSeconds})}}const rb=111320,Ou=Math.PI/180,zL=1.02,BL=1;class od{static of(t,e){const i=od.sightings(t,e);if(i.length<2)return;const n=od.baseline(i);if(!n)return;const{near:s,far:r,closedM:a}=n,c=Math.tan(r.widthDeg/2*Ou)===0?0:Math.tan(s.widthDeg/2*Ou)/Math.tan(r.widthDeg/2*Ou);if(c<zL)return;const l=a/(c-1),h=fi.sizeMAt(l,s.widthDeg),u=i.map(d=>({t:d.t,m:fi.distanceMAt(h,d.widthDeg)}));return{widthM:h,distanceM:u,nearestM:Math.min(...u.map(d=>d.m)),fromT:r.t,toT:s.t,closedM:a}}static sightings(t,e){return t.timeline.allKeyframes.flatMap(i=>{const n=i.shapes.find(a=>a.sourceId===e)?.shape,s=n?.angular?.widthDeg,r=ke(t,i.t);return s===void 0||s<=0||r?.lat===void 0||r.lng===void 0?[]:[{t:i.t,widthDeg:s,lat:r.lat,lng:r.lng,sightAzimuthDeg:n?.aim?.azimuthDeg??r.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=od.closedAlongSight(i,n),[r,a,c]=s>=0?[n,i,s]:[i,n,-s];c<BL||r.widthDeg<=a.widthDeg||(!e||c>e.closedM)&&(e={near:r,far:a,closedM:c})}return e}static closedAlongSight(t,e){const i=(e.lat-t.lat)*rb,n=(e.lng-t.lng)*rb*Math.cos(t.lat*Ou),s=(t.sightAzimuthDeg??0)*Ou;return i*Math.cos(s)+n*Math.sin(s)}}class vs{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:vs.atLeastNearest(t.statedM),basis:"stated"};if(t.hypothesisM!==void 0&&t.hypothesisM>0)return{distanceM:vs.atLeastNearest(t.hypothesisM),basis:"hypothesis"};if(t.derivedM!==void 0&&t.derivedM>0)return{distanceM:vs.atLeastNearest(t.derivedM),basis:"derived"};const e=vs.largest(t.range?.minM,t.crossing?.behindM),i=vs.smallest(t.range?.maxM,t.crossing?.inFrontM),n=e===void 0?void 0:e*vs.MARGIN,s=i===void 0?void 0:i/vs.MARGIN;return n!==void 0&&s!==void 0?{distanceM:vs.atLeastNearest(n<=s?Math.sqrt(n*s):n),basis:"bounded"}:n!==void 0?{distanceM:vs.atLeastNearest(n),basis:"bounded"}:s!==void 0&&s<vs.CONVENTIONAL_M?{distanceM:vs.atLeastNearest(s),basis:"bounded"}:{distanceM:vs.CONVENTIONAL_M,basis:"conventional"}}static atLeastNearest(t){return Math.max(vs.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)}}class Pt{static A=6378137;static E2=.00669437999014;static DEG=Math.PI/180;static STANDARD_DISTANCE_KM=100;static DEFAULT_COLOR="#ffb347";static DEFAULT_TRAIN_S=4;static DEFAULT_CRUMBLING={perS:1.2,lifeS:4,magnitudeDrop:3,dropBack:.3,spreadKmS:1,sinkKmS:.6,trainS:2.5};static DEFAULT_BURST={perS:12,lifeS:3.5,magnitudeDrop:3.5,dropBack:.5,spreadKmS:1.5,sinkKmS:.9,trainS:2};static FLARE_MAGNITUDES=.5;static shedsOf(t){return t.sheds?t.sheds:[Pt.DEFAULT_CRUMBLING,...Pt.flareBursts(t)]}static flareBursts(t){const e=t.lightCurve??[],i=[];for(let n=1;n<e.length-1;n++){const s=e[n];e[n-1].absoluteMagnitude-s.absoluteMagnitude<Pt.FLARE_MAGNITUDES||e[n+1].absoluteMagnitude-s.absoluteMagnitude<Pt.FLARE_MAGNITUDES||i.push({...Pt.DEFAULT_BURST,fromT:s.t-1e3,untilT:s.t+1500})}return i}static FADE_MS=1e3;static FADED_MAGNITUDE=8;static TRAIN_POINTS=8;static leadAt(t,e){const i=t.track;if(i.length<2||e<i[0].t||e>i[i.length-1].t)return;let n=0;for(;n<i.length-2&&i[n+1].t<e;)n++;const s=i[n],r=i[n+1],a=r.t-s.t,c=a>0?(e-s.t)/a:0,[l,h]=Pt.alongGreatCircle(s,r,c);return{lat:l,lng:h,heightM:(s.altitudeKm+(r.altitudeKm-s.altitudeKm)*c)*1e3}}static mayDazzle(t){const e=Math.max(1,Math.min(...t.track.map(n=>n.altitudeKm))),i=5*Math.log10(e/Pt.STANDARD_DISTANCE_KM);return t.fragments.some(n=>Math.min(n.absoluteMagnitude,...(n.lightCurve??[]).map(r=>r.absoluteMagnitude))+i<=Pt.DAZZLING_MAGNITUDE)}static detonationsOf(t,e){const i=[];for(const n of t)n.fragments.forEach((s,r)=>{const a=Pt.piecesOf(n).find(l=>l.id===(s.id??String(r)));if(!a)return;const c=(s.lightCurve??[]).filter((l,h,u)=>(h===0||u[h-1].absoluteMagnitude>=l.absoluteMagnitude)&&(h===u.length-1||u[h+1].absoluteMagnitude>l.absoluteMagnitude)).map(l=>({t:l.t,magnitude:l.absoluteMagnitude}));c.push({t:a.untilT,magnitude:a.magnitudeAt(a.untilT)});for(const l of c){if(l.magnitude>Pt.DETONATING_MAGNITUDE||l.t<a.fromT||l.t>a.untilT)continue;const h=Pt.pieceAt(n,a,l.t);if(!h||h.heightM>Pt.AUDIBLE_BELOW_KM*1e3||i.some(d=>d.flashT===l.t&&d.reentryId===n.id))continue;const u=Pt.seenFrom(e,h).distanceKm;i.push({reentryId:n.id,flashT:l.t,t:l.t+u/Pt.SOUND_KM_S*1e3,distanceKm:u,loudness:Math.min(1,(.3+(Pt.DETONATING_MAGNITUDE-l.magnitude)/15)*Math.min(1,30/u))})}});return i.sort((n,s)=>n.t-s.t)}static DETONATING_MAGNITUDE=-12;static AUDIBLE_BELOW_KM=50;static SOUND_KM_S=.31;static DAZZLING_MAGNITUDE=-11;static absoluteMagnitudeAt(t,e){const i=t.lightCurve;if(!i||i.length===0)return t.absoluteMagnitude;if(e<=i[0].t)return i[0].absoluteMagnitude;for(let n=1;n<i.length;n++){const s=i[n-1],r=i[n];if(e<=r.t)return s.absoluteMagnitude+(r.absoluteMagnitude-s.absoluteMagnitude)*(e-s.t)/Math.max(r.t-s.t,1)}return i[i.length-1].absoluteMagnitude}static viewsAt(t,e,i){const n=[];for(const s of t)for(const r of Pt.piecesOf(s)){if(e<r.fromT||e>r.untilT)continue;const a=Pt.pieceAt(s,r,e);if(!a)continue;const c=Pt.seenFrom(i,a);if(c.altitudeDeg<0)continue;const l=Math.min(Pt.FADE_MS,(r.untilT-r.fromT)/4),h=l>0?Math.min(1,(e-r.fromT)/l,(r.untilT-e)/l):1,u=r.magnitudeAt(e)+5*Math.log10(c.distanceKm/Pt.STANDARD_DISTANCE_KM),d=u+(1-h)*Math.max(0,Pt.FADED_MAGNITUDE-u),f=[c];for(let p=1;p<=Pt.TRAIN_POINTS;p++){const g=Math.min(r.trainMs*p/Pt.TRAIN_POINTS,e-r.fromT),m=Pt.pieceAt(s,r,e-g);if(!m||(f.push(Pt.seenFrom(i,m)),g>=e-r.fromT))break}n.push({reentryId:s.id,fragmentId:r.id,head:c,magnitude:d,fade:h,color:r.color,train:f})}return n}static piecesOf(t){const e=Pt.pieces.get(t);if(e)return e;const i=t.track[0]?.t??0,n=t.track[t.track.length-1]?.t??0,s=[];return t.fragments.forEach((r,a)=>{const c=(r.lagS??0)*1e3,l={id:r.id??String(a),fromT:r.fromT??i,untilT:r.untilT??n,lagMsAt:()=>c,acrossKmAt:()=>0,belowKmAt:()=>0,magnitudeAt:h=>Pt.absoluteMagnitudeAt(r,h),color:r.color??Pt.DEFAULT_COLOR,trainMs:(r.trainS??Pt.DEFAULT_TRAIN_S)*1e3};s.push(l),Pt.shedsOf(r).forEach((h,u)=>s.push(...Pt.shedPieces(l,h,u)))}),Pt.pieces.set(t,s),s}static pieces=new WeakMap;static shedPieces(t,e,i=0){const n=e.fromT??t.fromT,s=Math.min(e.untilT??t.untilT,t.untilT);if(!(e.perS>0)||s<=n)return[];const r=Math.floor((s-n)/1e3*e.perS),a=e.spreadKmS??.3,c=e.sinkKmS??.3,l=e.trainS!==void 0?e.trainS*1e3:t.trainMs*(2/3),h=[];for(let u=0;u<r;u++){const d=E=>Pt.hash(`${t.id}/${i}/${u}/${E}`),f=n+(u+d(1))/e.perS*1e3,p=e.lifeS*(.4+1.2*d(2))*1e3,g=e.magnitudeDrop*(.5-.5*Math.log(1-.999*d(3))),m=e.dropBack*(.5+d(4)),M=a*(2*d(5)-1),v=c*(.5+d(6)),x=t.lagMsAt(f),y=t.acrossKmAt(f),w=t.belowKmAt(f),b=E=>Math.max(0,E-f)/1e3;h.push({id:`${t.id}.${i}.${u}`,fromT:f,untilT:Math.min(f+p,Pt.endOf(t)),lagMsAt:E=>x+1e3*Pt.lagOfBraking(2*m,b(E)),acrossKmAt:E=>y+M*b(E),belowKmAt:E=>w+v*b(E),magnitudeAt:E=>t.magnitudeAt(Math.min(E,t.untilT))+g,color:t.color,trainMs:l})}return h}static lagOfBraking(t,e){return t<=0||e<=0?0:e-(1-Math.exp(-t*e))/t}static endOf(t){return t.untilT}static hash(t){let e=2166136261;for(let i=0;i<t.length;i++)e^=t.charCodeAt(i),e=Math.imul(e,16777619);return(e>>>0)/4294967296}static pieceAt(t,e,i){const n=i-e.lagMsAt(i),s=Pt.leadAt(t,n);if(!s)return;const r=e.acrossKmAt(i),a=s.heightM-e.belowKmAt(i)*1e3;if(r===0)return{...s,heightM:a};const c=Pt.leadAt(t,n-1e3)??s;return{...Pt.across(c,s,r),heightM:a}}static across(t,e,i){const n=Pt.DEG,s=t.lat*n,r=e.lat*n,a=(e.lng-t.lng)*n,c=Math.atan2(Math.sin(a)*Math.cos(r),Math.cos(s)*Math.sin(r)-Math.sin(s)*Math.cos(r)*Math.cos(a))+Math.PI/2,l=i/6371,h=Math.asin(Math.sin(r)*Math.cos(l)+Math.cos(r)*Math.sin(l)*Math.cos(c)),u=e.lng*n+Math.atan2(Math.sin(c)*Math.sin(l)*Math.cos(r),Math.cos(l)-Math.sin(r)*Math.sin(h));return{lat:h/n,lng:u/n}}static seenFrom(t,e){const i=Pt.ecef(t),n=Pt.ecef(e),s=n[0]-i[0],r=n[1]-i[1],a=n[2]-i[2],c=t.lat*Pt.DEG,l=t.lng*Pt.DEG,h=-Math.sin(l)*s+Math.cos(l)*r,u=-Math.sin(c)*Math.cos(l)*s-Math.sin(c)*Math.sin(l)*r+Math.cos(c)*a,d=Math.cos(c)*Math.cos(l)*s+Math.cos(c)*Math.sin(l)*r+Math.sin(c)*a,f=Math.hypot(h,u,d);return{altitudeDeg:Math.asin(d/f)/Pt.DEG,azimuthDeg:(Math.atan2(h,u)/Pt.DEG+360)%360,distanceKm:f/1e3}}static ecef(t){const e=t.lat*Pt.DEG,i=t.lng*Pt.DEG,n=Math.sin(e),s=Pt.A/Math.sqrt(1-Pt.E2*n*n);return[(s+t.heightM)*Math.cos(e)*Math.cos(i),(s+t.heightM)*Math.cos(e)*Math.sin(i),(s*(1-Pt.E2)+t.heightM)*n]}static alongGreatCircle(t,e,i){const n=h=>{const u=h.lat*Pt.DEG,d=h.lng*Pt.DEG;return[Math.cos(u)*Math.cos(d),Math.cos(u)*Math.sin(d),Math.sin(u)]},s=n(t),r=n(e),a=Math.max(-1,Math.min(1,s[0]*r[0]+s[1]*r[1]+s[2]*r[2])),c=Math.acos(a);let l;if(c<1e-12)l=s;else{const h=Math.sin((1-i)*c)/Math.sin(c),u=Math.sin(i*c)/Math.sin(c);l=[s[0]*h+r[0]*u,s[1]*h+r[1]*u,s[2]*h+r[2]*u]}return[Math.atan2(l[2],Math.hypot(l[0],l[1]))/Pt.DEG,Math.atan2(l[1],l[0])/Pt.DEG]}}class Mh{static typed=new Map;static of(t){return Mh.typed.get(t)}static set(t,e){const i=e.trim();i===""?Mh.typed.delete(t):Mh.typed.set(t,i)}static forget(){Mh.typed.clear()}}class oy{static FIRST_DAY="2022-01-01";static mayCover(t){return new Date(t).toISOString().slice(0,10)>=oy.FIRST_DAY}}class ab{constructor(t,e,i){this.citation=t,this.covers=e,this.load=i}loading;mayCover(t){return this.covers(t)}async between(t,e,i,n){try{return await(await this.provider()).between(t,e,i,n)}catch{return{status:"failed"}}}async describe(t,e){try{return await(await this.provider()).describe?.(t,e)}catch{return}}provider(){if(!this.loading){const t=this.load();this.loading=t,t.catch(()=>{this.loading===t&&(this.loading=void 0)})}return this.loading}}const HL="Aircraft positions: adsb.lol feeders and contributors, Open Database License 1.0 (https://www.adsb.lol/docs/open-data/historical/)",GL="Aircraft positions: Flightradar24 API (https://fr24api.flightradar24.com/)",ob="flightradar24",VL=Te.point("aircraft").provide(Te.BUILT_IN,[{id:"adsb-lol",name:"adsb.lol",credit:"adsb.lol feeders and contributors, ODbL 1.0",creditUrl:"https://www.adsb.lol/docs/open-data/historical/",create:()=>new ab(HL,o=>oy.mayCover(o),async()=>new(await dt(async()=>{const{AdsbLolArchiveProvider:o}=await import("./AdsbLolArchiveProvider-BtF4baVw.js");return{AdsbLolArchiveProvider:o}},[],import.meta.url)).AdsbLolArchiveProvider)},{id:ob,name:"Flightradar24",credit:"Flightradar24, on your own subscription",creditUrl:"https://fr24api.flightradar24.com/",keyUrl:"https://fr24api.flightradar24.com/key-management",create:()=>new ab(GL,o=>o>=Date.UTC(2016,4,11)&&o<=Date.now(),async()=>new(await dt(async()=>{const{Flightradar24Provider:o}=await import("./Flightradar24Provider-BBj_wixV.js");return{Flightradar24Provider:o}},[],import.meta.url)).Flightradar24Provider({token:()=>Mh.of(ob)}))}]);class kn{static MAX_GAP_S=60;static FT_TO_M=.3048;static EARTH_RADIUS_KM=6371;static seenFrom(t,e,i){const n=kn.positionAt(t,i);if(!n)return;const s=Pt.seenFrom(e,n.geo);if(!(s.altitudeDeg<0))return{track:t,sky:s,altitudeFt:n.altitudeFt,groundSpeedKt:n.groundSpeedKt,trackDeg:n.trackDeg,angularRateDegPerS:kn.angularRate(t,e,i)}}static viewsAt(t,e,i){return t.flatMap(n=>kn.seenFrom(n,e,i)??[])}static groundDistanceKm(t,e){const i=Math.PI/180,n=Math.sin((e.lat-t.lat)*i/2)**2+Math.cos(t.lat*i)*Math.cos(e.lat*i)*Math.sin((e.lng-t.lng)*i/2)**2;return 2*kn.EARTH_RADIUS_KM*Math.asin(Math.min(1,Math.sqrt(n)))}static wrapLongitude(t){return((t+180)%360+360)%360-180}static positionAt(t,e){const i=t.points;if(i.length===0||e<i[0].t||e>i[i.length-1].t)return;let n=0;for(;n<i.length-1&&i[n+1].t<=e;)n++;const s=i[n],r=i[n+1]??s,a=r.t-s.t;if(a>kn.MAX_GAP_S*1e3)return;const c=a>0?(e-s.t)/a:0,l=s.altitudeFt+(r.altitudeFt-s.altitudeFt)*c,h=(r.lng-s.lng+540)%360-180;return{geo:{lat:s.lat+(r.lat-s.lat)*c,lng:kn.wrapLongitude(s.lng+h*c),heightM:l*kn.FT_TO_M},altitudeFt:l,groundSpeedKt:s.groundSpeedKt,trackDeg:s.trackDeg}}static angularRate(t,e,i){const n=kn.positionAt(t,i-500),s=kn.positionAt(t,i+500);if(!n||!s)return;const r=kn.unit(Pt.seenFrom(e,n.geo)),a=kn.unit(Pt.seenFrom(e,s.geo)),c=Math.min(1,Math.max(-1,r[0]*a[0]+r[1]*a[1]+r[2]*a[2]));return Math.acos(c)*180/Math.PI}static unit(t){const e=t.altitudeDeg*Math.PI/180,i=t.azimuthDeg*Math.PI/180;return[Math.cos(e)*Math.sin(i),Math.cos(e)*Math.cos(i),Math.sin(e)]}}class Nn{constructor(t){this.boxes=t;for(const i of t){const n=Math.hypot(i.halfWidthM,i.halfLengthM),[s,r]=[Nn.cell(i.eastM-n),Nn.cell(i.eastM+n)],[a,c]=[Nn.cell(i.northM-n),Nn.cell(i.northM+n)];for(let l=s;l<=r;l++)for(let h=a;h<=c;h++){const u=Nn.key(l,h),d=this.cells.get(u);d?d.push(i):this.cells.set(u,[i])}}let e=2166136261;for(const i of t)for(const n of[i.eastM,i.northM,i.cos,i.halfWidthM,i.halfLengthM,i.topM])e=Math.imul(e^Math.round(n*10),16777619);this.signature=t.length===0?"":`${t.length}:${(e>>>0).toString(36)}`}static NONE=new Nn([]);static SOLID=new Set(["building","tree","wall","mound","terrace","shrub"]);static CELL_M=16;static last;signature;cells=new Map;static of(t,e){const i=[];for(const s of t){if(!Nn.SOLID.has(s.kind)||(s.track?.length??0)>0)continue;const r=e(s);if(!(r.heightM>0)||!(r.widthM>0)||!(r.lengthM>0))continue;const a=(s.headingDeg??0)*Math.PI/180;i.push({eastM:s.eastM,northM:s.northM,cos:Math.cos(a),sin:Math.sin(a),halfWidthM:r.widthM/2,halfLengthM:r.lengthM/2,topM:r.heightM})}const n=new Nn(i);return Nn.last?.signature===n.signature?Nn.last.obstacles:(Nn.last={signature:n.signature,obstacles:n},n)}get empty(){return this.boxes.length===0}inside(t,e,i,n=0){const s=this.cells.get(Nn.key(Nn.cell(t),Nn.cell(e)));if(s)for(const r of s){if(i>r.topM+n)continue;const a=t-r.eastM,c=e-r.northM,l=a*r.sin+c*r.cos,h=a*r.cos-c*r.sin,u=r.halfLengthM+n-Math.abs(l),d=r.halfWidthM+n-Math.abs(h);if(u<=0||d<=0)continue;const f=r.topM+n-i;if(u<d){const g=Math.sign(l)||1;return{box:r,nx:r.sin*g,ny:r.cos*g,depthM:u,belowTopM:f}}const p=Math.sign(h)||1;return{box:r,nx:r.cos*p,ny:-r.sin*p,depthM:d,belowTopM:f}}}static cell(t){return Math.floor(t/Nn.CELL_M)}static key(t,e){return(t+32768)*65536+(e+32768)}}const cb="https://ufoathome.org/fireballs/index.json";class ca{static FIRST_MONTH="2018-12";static STRIKING_MAGNITUDE=-1;static COLOR="#eef2ff";static TRAIN_S=.3;fetchImpl;indexUrls;index;months=new Map;constructor(t={}){this.fetchImpl=t.fetchImpl??fetch.bind(globalThis),this.indexUrls=t.indexUrls??ca.defaultIndexUrls()}static defaultIndexUrls(){const t=[];return typeof location<"u"&&/^https?:$/.test(location.protocol)&&t.push(new URL("/fireballs/index.json",location.href).href),t.includes(cb)||t.push(cb),t}static mayCover(t){return new Date(t).toISOString().slice(0,7)>=ca.FIRST_MONTH}async credit(){return(await this.loadIndex())?.index.credit}async between(t,e){if(!ca.mayCover(e))return;const i=await this.loadIndex();if(!i)return;const n=new Set([new Date(t).toISOString().slice(0,7),new Date(e).toISOString().slice(0,7)]);return[...n].some(r=>r>=i.index.from&&r<=i.index.to)?(await Promise.all([...n].filter(r=>i.index.months.includes(r)).map(r=>this.monthOf(r,i.base)))).flat().filter(r=>r.t>=t&&r.t<=e):void 0}static seenFrom(t,e){const i=ca.peakFraction(t),n={lat:t.from[0]+(t.to[0]-t.from[0])*i,lng:t.from[1]+(t.to[1]-t.from[1])*i,heightM:t.peakHeightKm*1e3},s=Pt.seenFrom(e,n);if(!(s.altitudeDeg<0))return{record:t,peak:s,magnitude:t.peakMagnitude+5*Math.log10(s.distanceKm/Pt.STANDARD_DISTANCE_KM)}}static asReentry(t,e){const i=t.t-e,n=i+Math.max(t.durationS,.1)*1e3;return{id:`gmn-${t.id}`,track:[{t:i,lat:t.from[0],lng:t.from[1],altitudeKm:t.from[2]},{t:n,lat:t.to[0],lng:t.to[1],altitudeKm:t.to[2]}],fragments:[{absoluteMagnitude:t.peakMagnitude,color:ca.COLOR,trainS:ca.TRAIN_S}]}}static peakFraction(t){const e=t.from[2]-t.to[2];return Math.abs(e)<1e-6?.5:Math.min(1,Math.max(0,(t.from[2]-t.peakHeightKm)/e))}loadIndex(){return this.index??=(async()=>{for(const t of this.indexUrls)try{const e=await this.fetchImpl(t);if(e.ok)return{index:await e.json(),base:t}}catch{}})(),this.index}monthOf(t,e){let i=this.months.get(t);return i||(i=this.fetchImpl(new URL(`${t}.json`,e).href).then(n=>n.ok?n.json():[]).catch(()=>[]),this.months.set(t,i)),i}}class Ii{static built=new WeakMap;static computers=new WeakMap;static loading=new WeakMap;static loaded(t,e){return e.every(i=>Ii.itemsOf(t,i.key).length===0||Ii.computers.has(i))}static load(t,e){return Promise.all(e.filter(i=>Ii.itemsOf(t,i.key).length>0&&!Ii.computers.has(i)).map(i=>{let n=Ii.loading.get(i);return n||(n=i.compute().then(s=>{Ii.computers.set(i,s)}),n.catch(()=>Ii.loading.delete(i)),Ii.loading.set(i,n)),n.catch(()=>{})})).then(()=>{})}static of(t){let e=Ii.built.get(t);return e||(e=t.create(),Ii.built.set(t,e)),e}static itemsOf(t,e){const i=t?.[e];return Array.isArray(i)?i:[]}static computes(t,e){return e.some(i=>Ii.itemsOf(t,i.key).length>0)}static expand(t,e,i){return Ii.expandWithKinds(t,e,i).interpretation}static expandWithKinds(t,e,i){const n=new Map,s=new Map;if(!t||!Ii.computes(t,e))return{interpretation:t,kindOf:n,phenomenonOf:s};const r=e.flatMap(a=>Ii.itemsOf(t,a.key).flatMap(c=>{const l=Ii.computers.get(a);if(!l)return[];const h=l(c,i),u=a.phenomenon?.(c);for(const d of h)n.set(d.id,a),u&&s.set(d.id,u);return h}));return{interpretation:{...t,bodies:[...t.bodies,...r]},kindOf:n,phenomenonOf:s}}static computedPart(t,e){const i={};for(const n of e){const s=Ii.itemsOf(t,n.key);s.length>0&&(i[n.key]=[...s])}return i}static saysNothing(t,e){return t.bodies.length===0&&t.title===void 0&&t.smoke===void 0&&e.every(i=>t[i.key]===void 0)}}const WL=Gs.catalog({en:()=>dt(()=>import("./FlareKindMessages_en-j3CY_TxX.js"),[],import.meta.url).then(o=>o.flareKindMessages_en),fr:()=>dt(()=>import("./FlareKindMessages_fr-B2MezoN2.js"),[],import.meta.url).then(o=>o.flareKindMessages_fr),es:()=>dt(()=>import("./FlareKindMessages_es-CZgrFIOO.js"),[],import.meta.url).then(o=>o.flareKindMessages_es),it:()=>dt(()=>import("./FlareKindMessages_it-CmZmb3RP.js"),[],import.meta.url).then(o=>o.flareKindMessages_it)}),lb={key:"flares",messages:WL,phenomenon:()=>"DecoyFlare",compute:()=>dt(async()=>{const{DecoyFlare:o}=await import("./DecoyFlare-DUt1_LcW.js");return{DecoyFlare:o}},[],import.meta.url).then(({DecoyFlare:o})=>t=>o.bodiesOf(t))},XL=Gs.catalog({en:()=>dt(()=>import("./LanternKindMessages_en-CQXdJ-k6.js"),[],import.meta.url).then(o=>o.lanternKindMessages_en),fr:()=>dt(()=>import("./LanternKindMessages_fr-D7tQa_tQ.js"),[],import.meta.url).then(o=>o.lanternKindMessages_fr),es:()=>dt(()=>import("./LanternKindMessages_es-BOO6kPjs.js"),[],import.meta.url).then(o=>o.lanternKindMessages_es),it:()=>dt(()=>import("./LanternKindMessages_it-B8J-29Mj.js"),[],import.meta.url).then(o=>o.lanternKindMessages_it)}),hb={key:"lanterns",messages:XL,phenomenon:()=>"SkyLantern",compute:()=>dt(async()=>{const{SkyLantern:o}=await import("./SkyLantern-BKxwl7Po.js");return{SkyLantern:o}},[],import.meta.url).then(({SkyLantern:o})=>(t,e)=>o.bodiesOf(t,e?.obstacles)),editor:()=>dt(async()=>{const{LanternEditor:o}=await import("./LanternEditor-iByq1q3j.js");return{LanternEditor:o}},__vite__mapDeps([11,3,12]),import.meta.url).then(({LanternEditor:o})=>(t,e,i)=>new o(t,e,i))},YL=Gs.catalog({en:()=>dt(()=>import("./BirdKindMessages_en-c_-L7frF.js"),[],import.meta.url).then(o=>o.birdKindMessages_en),fr:()=>dt(()=>import("./BirdKindMessages_fr-C1TuqqEj.js"),[],import.meta.url).then(o=>o.birdKindMessages_fr),es:()=>dt(()=>import("./BirdKindMessages_es-8Zo2t0o4.js"),[],import.meta.url).then(o=>o.birdKindMessages_es),it:()=>dt(()=>import("./BirdKindMessages_it-DQZcrCkf.js"),[],import.meta.url).then(o=>o.birdKindMessages_it)}),ub={key:"birds",messages:YL,phenomenon:()=>"Birds",compute:()=>dt(async()=>{const{BirdFlock:o}=await import("./BirdFlock-B2SbkMme.js").then(t=>t.b);return{BirdFlock:o}},[],import.meta.url).then(({BirdFlock:o})=>(t,e)=>o.bodiesOf(t,e?.obstacles)),editor:()=>dt(async()=>{const{BirdEditor:o}=await import("./BirdEditor-CKpe681e.js");return{BirdEditor:o}},__vite__mapDeps([13,3,14,4]),import.meta.url).then(({BirdEditor:o})=>(t,e,i)=>new o(t,e,i))},KL=Gs.catalog({en:()=>dt(()=>import("./DroneKindMessages_en-CLygXcsv.js"),[],import.meta.url).then(o=>o.droneKindMessages_en),fr:()=>dt(()=>import("./DroneKindMessages_fr-CAX15_pk.js"),[],import.meta.url).then(o=>o.droneKindMessages_fr),es:()=>dt(()=>import("./DroneKindMessages_es-B9XFRYnQ.js"),[],import.meta.url).then(o=>o.droneKindMessages_es),it:()=>dt(()=>import("./DroneKindMessages_it-CSGsCaJQ.js"),[],import.meta.url).then(o=>o.droneKindMessages_it)}),db={quadcopter:"ConsumerDrone",saucer:"ConsumerDrone","fixed-wing":"MilitaryDrone"},fb={key:"drones",messages:KL,phenomenon:o=>db[o.airframe]??db.quadcopter,compute:()=>dt(async()=>{const{DroneFlight:o}=await import("./DroneFlight-BTFHGVWd.js").then(t=>t.c);return{DroneFlight:o}},[],import.meta.url).then(({DroneFlight:o})=>t=>o.bodiesOf(t)),editor:()=>dt(async()=>{const{DroneEditor:o}=await import("./DroneEditor-BDDLiZPp.js");return{DroneEditor:o}},__vite__mapDeps([15,3,16,4]),import.meta.url).then(({DroneEditor:o})=>(t,e,i)=>new o(t,e,i))},$L=Te.point("interpretations").provide(Te.BUILT_IN,[{id:lb.key,name:"Decoy flares",credit:"UFO@home",creditUrl:"https://ufoathome.org/docs/format/",create:()=>lb},{id:hb.key,name:"Sky lanterns",credit:"UFO@home",creditUrl:"https://ufoathome.org/docs/format/",create:()=>hb},{id:ub.key,name:"Birds",credit:"UFO@home",creditUrl:"https://ufoathome.org/docs/format/",create:()=>ub},{id:fb.key,name:"Drones",credit:"UFO@home",creditUrl:"https://ufoathome.org/docs/format/",create:()=>fb}]);class o1{static kinds(){return $L.map(t=>Ii.of(t))}}Jb();const qL="satellites-change",ZL="fireballs-change",JL="references-change",jL="aircraft-change",QL="rr0-confrontation",pb="comet:",mb="nova:",t7=new URL(""+new URL("lunar-relief.bin-ByThqxUn.gz",import.meta.url).href,import.meta.url).href,e7=new URL(""+new URL("stars-mag7.5-B43R6Wvg.bin",import.meta.url).href,import.meta.url).href,i7=new URL(""+new URL("stars-mag7.5-9-BLV2tFmZ.bin",import.meta.url).href,import.meta.url).href,n7=-18,s7={sun:{altitudeDeg:-3,azimuthDeg:180,magnitude:-26.7},moon:{altitudeDeg:-90,azimuthDeg:0,phase:{phaseFraction:0,illuminatedFraction:0},magnitude:-12.7},planets:[]},R0={lat:0,lng:0,elevationM:0,headingDeg:void 0,pitchDeg:0,fovDeg:60};class ve 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",bh,Eh,Oc]}shadow;stageElement;frameElement;sceneCanvas;busyElement;busyNote;loaderNote;loaderNotVideo;ufoElement;sceneRenderer;hoverTooltip;ghostPath;flightMark;markedFlight;holding=!1;resizeObserver;sizeEstimates=new Map;sizeEstimatesFor;approaches={key:"",of:new Map};distanceHypotheses=new Map;depths=new Map;directionScratch=new _;meteorScheduleFor;lightningScheduleFor;lightningFlashes=[];lastLightningT;lastTimeMs=0;interpretationShown;confrontationReadings=[];confrontationTolerance;confrontationSignature="";comparing=!1;inTheRound=!0;lastSkyKey;starCatalog;starCatalogRequest=0;static tleArchive=new ts;satellitesFor;satelliteRequest=0;satelliteStatus="none";satellites;satellitePassesMemo;static fireballArchive=new ca;fireballs;static aircraftProviders=new Map;static SOUND_LOOKBACK_MS=3e5;static TRAIL_LOOKBACK_MS=36e5;static TRAIL_MAX_AIRCRAFT=60;static NO_CONTRAILS=[];static upperAirProviders=new Map;static NO_PRESENCE=new Map;aircraftSource=VL[0];static trafficRuntimeLoading;static trafficRuntime;static loadTrafficRuntime(){return ve.trafficRuntimeLoading??=dt(()=>import("./trafficRuntime-DRDMbo2X.js"),__vite__mapDeps([17,10]),import.meta.url).then(t=>ve.trafficRuntime=t),ve.trafficRuntimeLoading.catch(()=>{ve.trafficRuntimeLoading=void 0}),ve.trafficRuntimeLoading}traffic;lastSun;get sunAltitudeDeg(){return this.sceneRenderer.sunAltitudeDeg??this.lastSun?.altitudeDeg}decorMemo;seatedMemo;starCatalogDepth=0;weatherAudio=new Gc;vehicleAudio=new xy;aircraftAudio;vehicleHearing=new $0;decorAircraftHearing;bodyHearing;decorModelSounds=new Map;decorModelsAsked=new Set;thunderTimeoutId;handleFullscreenChange=()=>{this.resizeToStage(),this.hoverTooltip.hidden=!0;for(const t of[this.hoverTooltip,this.shadow.getElementById("credits-panel")])t&&typeof t.hidePopover=="function"&&t.matches(":popover-open")&&t.hidePopover();this.tooltipOver=document.fullscreenElement};handlePointerMove=t=>{if(this.lastHover={clientX:t.clientX,clientY:t.clientY,altKey:t.altKey},this.ghostMissedSinceMs=void 0,this.hoverFrame!==void 0&&t.altKey===this.hoverAlt){this.hoverPending=!0;return}this.hoverAlt=t.altKey,this.hoverAt(this.lastHover),this.hoverFrame===void 0&&(this.hoverFrame=requestAnimationFrame(()=>{this.hoverFrame=void 0,this.hoverPending&&this.lastHover&&this.hoverAt(this.lastHover),this.hoverPending=!1}))};ghostMissedSinceMs;static GHOST_KEPT_MS=600;ghostStillUnder(t,e){const i=this.ufoElement.canvasElement.getBoundingClientRect();if(i.width===0||i.height===0)return!0;const n=(t.clientX-i.left)/i.width*2-1,s=1-(t.clientY-i.top)/i.height*2;return this.sceneRenderer.ghostsReadableAt(n,s)?this.sceneRenderer.pickGhostAt(n,s)?(this.ghostMissedSinceMs=void 0,!0):(this.ghostMissedSinceMs??=e,e-this.ghostMissedSinceMs>ve.GHOST_KEPT_MS):!1}hoverFrame;hoverPending=!1;hoverAlt=!1;lastPlayingHoverMs=0;static PLAYING_HOVER_MS=150;lastHover;tooltipOver=null;hoverAt(t){if(this.showCompassFor({hovered:!0}),this.holding){this.hoverTooltip.hidden=!0;return}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 r=(t.clientX-i.left)/i.width*2-1,a=-((t.clientY-i.top)/i.height*2-1);if(!this.ghostPath.hasAttribute("hidden")&&!this.sceneRenderer.ghostsReadableAt(r,a))return;const c=this.pickAt(r,a,!0,t.altKey);c?this.showHoverTooltip(t,t.altKey&&c.detail?c.detail():c.name):this.hoverTooltip.hidden=!0,this.showGhostPath(c?.path,i)}showGhostPath(t,e){if(!t){this.ghostPath.toggleAttribute("hidden",!0);return}const i=this.stageElement.getBoundingClientRect(),n=d=>({x:e.left-i.left+(d.x+1)/2*e.width,y:e.top-i.top+(1-d.y)/2*e.height}),s=n(t.from),r=n(t.to),a=n({x:0,y:0});this.ghostPath.setAttribute("viewBox",`0 0 ${i.width} ${i.height}`);const[c,l,h,u]=Array.from(this.ghostPath.children);for(const d of[c,l])d.setAttribute("x1",String(s.x)),d.setAttribute("y1",String(s.y)),d.setAttribute("x2",String(r.x)),d.setAttribute("y2",String(r.y));h.setAttribute("cx",String(a.x)),h.setAttribute("cy",String(a.y)),u.setAttribute("cx",String(r.x)),u.setAttribute("cy",String(r.y)),this.ghostPath.toggleAttribute("hidden",!1)}pickAt(t,e,i=!0,n=!1){const s=this.naming,r=s.names;if(n&&this.sceneRenderer.pickDropAt(t,e)){const b=r.ghostTooltip,E=b.drop[this.ufoElement.sighting.lens?.glass??"lens"];return{kind:"drop",name:E,detail:()=>b.dropDetail.replace("{name}",E)}}const a=this.sceneRenderer.pickBodyAt(t,e);if(a)return{kind:"sky",id:a,name:this.bodyName(a)};const c=this.interpretationShown?this.sceneRenderer.pickInterpretationBodyAt(t,e):void 0,l=c?this.interpretationShown?.bodies.find(b=>b.id===c):void 0,h=l?this.said.read(l.title)||this.explainedName(l.explains)||this.kindName(l):void 0;if(c!==void 0&&h)return{kind:"body",id:c,name:h};const u=this.skyEventPickAt(t,e,(b,E)=>!E.inSky);if(u)return u;const d=i?this.ghostPick(t,e):void 0;if(d)return d;if(this.sceneRenderer.pickAfterimageAt(t,e)){const b=this.naming.names.afterimageTooltip;return{kind:"afterimage",name:b.name,detail:()=>b.detail.replace("{name}",b.name)}}const f=this.pickDecorAt(t,e)??this.sceneRenderer.pickPeakAt(t,e),p=f?this.ufoElement.sighting.decor.find(b=>b.id===f):void 0;if(p){const b=this.said.read(p.title)||s.decorKind(p.kind);return{kind:"decor",id:p.id,name:b,detail:()=>this.decorTooltip(p,b)}}const g=this.sceneRenderer.pickRailwayAt(t,e);if(g){const b=r.railwayTooltip;return{kind:"railway",id:g.line.id,name:jr.name(g.line,b),detail:()=>jr.detail(g,b,E=>this.distanceText(E))}}const m=this.trafficTooltipAt(t,e);if(m)return{kind:"traffic",name:m};const M=this.skyEventPickAt(t,e,(b,E)=>E.inSky===!0&&!b.pickedAfterSatellites);if(M)return M;const v=this.sceneRenderer.pickSatelliteAt(t,e);if(v)return{kind:"satellite",name:r.satelliteTooltip.replace("{name}",v.name).replace("{mag}",v.magnitude.toLocaleString(void 0,{maximumFractionDigits:1})).replace("{height}",Math.round(v.heightKm).toLocaleString())};const x=this.skyEventPickAt(t,e,(b,E)=>E.inSky===!0&&b.pickedAfterSatellites===!0);if(x)return x;const y=this.sceneRenderer.pickOpticsAt(t,e);if(y){const b=r.opticsTooltips[y.id].replace("{angle}",String(Math.round(y.angleDeg??0)));return{kind:"optics",id:y.id,name:b.split(" — ")[0],detail:()=>b}}const w=this.sceneRenderer.pickStarAt(t,e);if(w){const b=w.star.mag,E=w.altitudeDeg,S=E<0?r.starTooltipBelow:r.starTooltip,A=s.star(w.star);return{kind:"star",name:A,detail:()=>S.replace("{name}",A).replace("{mag}",b.toLocaleString(void 0,{maximumFractionDigits:Math.abs(b)<1?2:1})).replace("{alt}",String(Math.round(Math.abs(E))))}}}ghostLights=new Map;static GHOST_LIGHT_KEPT_MS=1e3;lightOfGhost(t,e){const i=this.ufoElement.canvasElement,n={x:8/Math.max(1,i.clientWidth),y:8/Math.max(1,i.clientHeight)},s=`${Math.round(t/n.x)}:${Math.round(e/n.y)}`,r=performance.now(),a=this.ghostLights.get(s);if(a&&r-a.atMs<ve.GHOST_LIGHT_KEPT_MS)return a.light;let c=this.shiningDecorNear(t,e,2*Math.max(n.x,n.y)),l;if(!c)for(const[h,u]of[[0,0],[1,0],[-1,0],[0,1],[0,-1],[1,1],[-1,1],[1,-1],[-1,-1]]){const d=this.pickAt(t+h*n.x,e+u*n.y,!1);if(d?.kind==="star")l??=d;else if(d){c=d;break}}return c??=this.shiningDecorNear(t,e,6*Math.max(n.x,n.y)),c??=l,this.ghostLights.size>256&&this.ghostLights.clear(),this.ghostLights.set(s,{light:c??null,atMs:r}),c??null}ghostPick(t,e){const i=this.sceneRenderer.pickGhostAt(t,e);if(!i)return;const n=this.naming.names.ghostTooltip,s=i.beyond?{kind:"sky",id:"sun",name:this.bodyName("sun")}:this.lightOfGhost(i.source.x,i.source.y)??void 0,r=(s?.kind==="star"?s.name.split(" — ")[0]:s?.name)??n.unnamed,a=i.ghost,l=(Ze.scatters(a)?n.halo:a.cause==="glass"?n.double:n.ghost).replace("{name}",r),h=a.scale<0?n.opposite:a.scale===1?n.around:n.sameSide;return{kind:"ghost",id:s?.id,name:l,detail:()=>n.detail.replace("{name}",l).replace("{cause}",n.causes[a.cause??"lens"]).replace("{where}",h),path:{from:{x:2*(a.offset?.[0]??0)+a.scale*i.source.x,y:2*(a.offset?.[1]??0)+a.scale*i.source.y},to:i.source}}}shiningDecorNear(t,e,i){let n;for(const s of this.ufoElement.sighting.decor){if(!(s.kind==="streetlight"||s.kind==="trafficlight"||(s.lights?.length??0)>0||s.kind==="vehicle"&&s.lit))continue;const a=this.sceneRenderer.decorScreenBox(s.id);if(!a)continue;const c=Math.hypot(Math.max(a.minX-t,0,t-a.maxX),Math.max(a.minY-e,0,e-a.maxY));if(c>i||n&&c>=n.distance)continue;const l=this.said.read(s.title)||this.naming.decorKind(s.kind);n={distance:c,pick:{kind:"decor",id:s.id,name:l}}}return n?.pick}glassWettingOf(t){const e=JSON.stringify([t.lens,t.instrumentId,t.weatherTrack.allKeyframes.map(i=>[i.t,i.weather.precipitationType,i.weather.precipitationIntensity,i.weather.windDirectionDeg,i.weather.windSpeed])]);if(this.glassWetting?.sighting!==t||this.glassWetting.key!==e){const i=new Uc(n=>{if(!Ze.records(t.instrument)||!Ze.falling(t.lens))return 0;const s=iu(t,n*1e3),r=ke(t,n*1e3);return(s.precipitationAmount??1)*Ze.impactRate(s,t.lens?.glass,r&&{headingDeg:r.headingDeg??0,pitchDeg:r.pitchDeg,windFromDeg:s.windDirectionDeg,windSpeedMS:s.windSpeed})});this.glassWetting={sighting:t,key:e,wetting:i}}return this.glassWetting.wetting}glassWetting;get skyEventsShown(){return this.skyEventsOf(this.ufoElement.sighting)}skyEventsStartDate;skyEventsMerged;skyEventsOf(t){const e=t.skyEvents,i=this.fireballs?.reentries,n=this.skyEventsMerged;if(n&&n.stated===e&&n.fireballs===i)return n.shown;const s=i?.length?{...e,reentries:[...e?.reentries??[],...i]}:e;return this.skyEventsMerged={stated:e,fireballs:i,shown:s},s}skyEventTexts=new Map;skyEventTextsLanguage;loadSkyEventTexts(t){const e=I0(Lo.preferencesFor(this),C0);e!==this.skyEventTextsLanguage&&(this.skyEventTexts.clear(),this.skyEventTextsLanguage=e);for(const i of t)this.skyEventTexts.has(i)||i.messages.load(e).then(n=>{this.skyEventTextsLanguage===e&&this.skyEventTexts.set(i,n)},()=>{})}skyEventPickAt(t,e,i){const n=this.skyEventsShown;if(!n)return;const s=this.sceneRenderer.pickSkyEventAt(t,e,i),r=s?NM.map(d=>to.of(d)).find(d=>d.key===s.kind):void 0,a=s&&r?to.eventsOf(n,r).find(d=>d.id===s.id):void 0;if(!s||!r||!a)return;const c=this.skyEventTexts.get(r);if(!c){this.loadSkyEventTexts([r]);return}const l=this.said.read(a.title)||c.name,h=r.describe?.(a,s,{said:this.said,texts:c,name:l,distance:d=>this.distanceText(d)}),u=h?.detail??(s.distanceM!==void 0?`${l}, ${this.distanceText(s.distanceM)}`:void 0);return{kind:r.pickKind??"skyEvent",id:a.id,name:h?.name??l,...u!==void 0?{detail:()=>u}:{}}}distanceText(t){return t>=1e3?`${(t/1e3).toLocaleString(void 0,{maximumFractionDigits:1})} km`:`${t.toLocaleString(void 0,{maximumFractionDigits:t<10?1:0})} m`}decorTooltip(t,e){const i=h=>h.toLocaleString(void 0,{maximumFractionDigits:h<10?1:0}),n=ut.sizeOf(t),s=this.sceneRenderer.decorDistanceM(t.id),r=s===void 0?"":this.distanceText(s),c=this.naming.names.decorTooltip.replace("{name}",e).replace("{size}",`${i(n.widthM)} × ${i(n.lengthM)} × ${i(n.heightM)} m`),l=this.said.read(t.note);return l?`${c.replace("{distance}",r)}. ${l}`:c.replace("{distance}",r)}computedKinds=new Map;computedKindTexts=new Map;bodyModelKinds=new Map;showInterpretation(t){const e=o1.kinds(),i=this.obstaclesOf(this.ufoElement.sighting.decor);this.interpretationObstacles=i;const{interpretation:n,kindOf:s}=Ii.expandWithKinds(t,e,{obstacles:i});if(this.interpretationAsked=t,this.interpretationShown=n,this.computedKinds=s,this.loadComputedKindTexts(),Ii.loaded(t,e))return;const r=Ii.load(t,e);this.sceneRenderer.holdUntil(r),r.then(()=>{this.interpretationAsked!==t||!Ii.loaded(t,e)||(this.showInterpretation(t),this.ufoElement.refreshSoundControls(),this.updateAstronomy(this.lastTimeMs),this.ufoElement.repaintChrome())})}interpretationAsked;interpretationObstacles=Nn.NONE;obstaclesMadeOf;obstaclesOf(t){return this.obstaclesMadeOf?.decor!==t&&(this.obstaclesMadeOf={decor:t,obstacles:Nn.of(t,e=>ut.sizeOf(e))}),this.obstaclesMadeOf.obstacles}recomputeAmongNewDecor(){const t=this.interpretationAsked;!t||!Ii.computes(t,o1.kinds())||this.obstaclesOf(this.ufoElement.sighting.decor).signature!==this.interpretationObstacles.signature&&(this.showInterpretation(t),this.ufoElement.refreshSoundControls())}computedInterpretation(t){const e=o1.kinds(),i=Ii.loaded(t,e)?Promise.resolve():Ii.load(t,e),{interpretation:n,phenomenonOf:s}=Ii.expandWithKinds(t,e,{obstacles:this.obstaclesOf(this.ufoElement.sighting.decor)});return{interpretation:n??t,phenomenonOf:s,loaded:i}}loadComputedKindTexts(){const t=this.namesLanguage;if(t)for(const e of new Set(this.computedKinds.values()))this.computedKindTexts.has(e)||e.messages.load(t).then(i=>{t===this.namesLanguage&&this.computedKindTexts.set(e,i)}).catch(()=>{})}kindName(t){const e=this.computedKinds.get(t.id),i=e?this.computedKindTexts.get(e):void 0;if(i?.name)return i.name;const n=t.model.id;if(n==="figure")return this.naming.decorKind("entity");if(!n||t.model.url!==void 0)return;if(!this.bodyModelKinds.has(n)){this.bodyModelKinds.set(n,void 0),this.sceneRenderer.entryOfDecorModel(n).then(r=>this.bodyModelKinds.set(n,[r?.kind].flat()[0])).catch(()=>{});return}const s=this.bodyModelKinds.get(n);return s&&this.naming.decorKind(s)||void 0}explainedName(t){if(!t?.length)return;const e=this.ufoElement.sighting.timeline.allKeyframes,i=t.map(n=>{for(const s of e){const r=this.said.read(s.shapes.find(a=>a.sourceId===n)?.shape.title);if(r)return r}}).filter(n=>!!n);return i.length?i.join(", "):void 0}bodyName(t){const e=t.startsWith(pb)?t.slice(pb.length):void 0,i=e?qA.find(s=>s.id===e):void 0;if(i)return this.naming.comet(i);const n=t.startsWith(mb)?nb.byId(t.slice(mb.length)):void 0;return n?this.naming.nova(n):this.naming.body(t)}get naming(){return this.sceneNaming}sceneNaming=new jS;namesLanguage;ready=Promise.resolve();async loadSceneNames(){const t=I0(Lo.preferencesFor(this),C0);if(t===this.namesLanguage)return;this.namesLanguage=t;const e=await e5(t);t===this.namesLanguage&&(this.applySceneNaming(new jS(e)),this.computedKindTexts.clear(),this.loadComputedKindTexts())}setBusy(t,e=""){this.busyElement.hidden=!t,this.busyNote.textContent=t?e:"",this.busyElement.setAttribute("aria-label",e),this.busyElement.setAttribute("aria-busy",String(t))}renderLoaderText(t,e){let i=0;const n=(s,r)=>{s.setAttribute("aria-label",r),s.replaceChildren(),r.split(" ").forEach((a,c)=>{c>0&&s.append(" ");const l=document.createElement("span");l.className="scene-loader-word",l.setAttribute("aria-hidden","true");for(const h of a){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,t.loaded&&(this.creditsButton.title=t.names.credits,this.creditsButton.setAttribute("aria-label",t.names.credits),this.renderLoaderText(t.names.notAVideo,t.names.isASimulation),this.sceneRenderer.setCompassPoints(t.names.compassPoints))}showHoverTooltip(t,e){const i=this.hoverTooltip;if(i.textContent=e,i.hidden=!1,typeof i.showPopover=="function"){const u=document.fullscreenElement;i.matches(":popover-open")&&u!==this.tooltipOver&&i.hidePopover(),i.matches(":popover-open")||i.showPopover(),this.tooltipOver=u}const{innerWidth:n,innerHeight:s}=window,r=12,a=4,c=Math.min(t.clientX+r,n-i.offsetWidth-a),l=t.clientY+r,h=l+i.offsetHeight+a>s?t.clientY-r-i.offsetHeight:l;i.style.left=`${Math.max(a,c)}px`,i.style.top=`${Math.max(a,h)}px`}handlePointerLeave=()=>{this.lastHover=void 0,this.hoverTooltip.hidden=!0,this.ghostPath.toggleAttribute("hidden",!0),this.showCompassFor({hovered:!1})};hearDetonations(t,e,i,n){const s=`${i.lat.toFixed(4)},${i.lng.toFixed(4)}`,r=this.detonationsFor;(!r||s!==r.key||t.length!==r.reentries.length||t.some((l,h)=>l!==r.reentries[h]))&&(this.detonationsFor={reentries:[...t],key:s,detonations:t.length?Pt.detonationsOf(t,i):[]});const a=this.detonationsFor.detonations;if(n)return;const c=this.lastDetonationT;if(this.lastDetonationT=e,!(c===void 0||e<c||e-c>ve.DETONATION_JUMP_MS||this.ufoElement.playbackState!=="playing"))for(const l of a)l.t>c&&l.t<=e&&this.weatherAudio.playDetonation(l.loudness)}detonates(t){const e=[...t.skyEvents?.reentries??[],...this.fireballs?.reentries??[]],i=ke(t,0),n=t.event.place?.[0],s=i?.lat??n?.lat,r=i?.lng??n?.lng;return e.length>0&&s!==void 0&&r!==void 0&&Pt.detonationsOf(e,{lat:s,lng:r,heightM:this.altitudeOf(i)}).length>0}detonationsFor;lastDetonationT;static DETONATION_JUMP_MS=2e3;handleLightningFlash(t){if(clearTimeout(this.thunderTimeoutId),this.filmSound){this.filmThunderAtMs=this.lastTimeMs+pn.thunderDelayMs(t)*this.ufoElement.playbackRate;return}this.thunderTimeoutId=window.setTimeout(()=>this.weatherAudio.playThunder(),pn.thunderDelayMs(t))}handleFirstInteraction=()=>{this.weatherAudio.resume(),this.vehicleAudio.resume(),this.aircraftAudio?.resume(),!this.interacted&&(this.interacted=!0,this.setWeather(iu(this.ufoElement.sighting,this.lastTimeMs)))};interacted=!1;applyLevel(){if(this.filmSound)return;const t=this.ufoElement.level;this.weatherAudio.setLevel(t),this.vehicleAudio.setLevel(t),this.aircraftAudio?.setLevel(t)}handlePageGesture=()=>{this.ufoElement.playbackState==="playing"&&this.handleFirstInteraction()};unlockIfAlreadyActivated(){this.interacted||navigator.userActivation?.hasBeenActive&&this.handleFirstInteraction()}static GESTURES=["pointerdown","pointerup","touchend","click","keydown"];handleTimeUpdate=t=>{if(this.lastTimeMs=t.detail.time,this.syncAnimationsToPlayback(),this.updateAstronomy(this.lastTimeMs),this.ufoElement.playbackState==="playing"){this.sceneRenderer.frame(performance.now());const e=performance.now();this.lastHover&&!this.ghostPath.hasAttribute("hidden")&&e-this.lastPlayingHoverMs>=ve.PLAYING_HOVER_MS&&(this.lastPlayingHoverMs=e,this.ghostStillUnder(this.lastHover,e)&&this.hoverAt(this.lastHover))}this.placeFlightMark(),this.ufoElement.repaintChrome()};syncAnimationsToPlayback(){const t=this.ufoElement.playbackState==="playing",e=t||this.filming;this.sceneRenderer.setAnimationsRunning(e,e);const i=t||this.filmSound!==void 0;this.weatherAudio.setPaused(!i),this.vehicleAudio.setPaused(!i),this.aircraftAudio?.setPaused(!i),t&&this.unlockIfAlreadyActivated(),t||clearTimeout(this.thunderTimeoutId)}constructor(){super(),this.shadow=this.attachShadow({mode:"open"});const t=document.createElement("template");t.innerHTML=`<style>${v3}</style>${M3}`,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 lt(this.sceneCanvas),this.sceneRenderer.onReferencesSettled=()=>this.dispatchEvent(new CustomEvent(JL));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.busyElement=this.shadow.getElementById("scene-busy"),this.busyNote=this.shadow.getElementById("scene-busy-note"),this.loader=e,this.poster=new ad(this.shadow.getElementById("scene-poster"),()=>{this.loader.style.animationDelay=!this.poster.up&&this.holding?"0s":"",this.applyHold()}),this.sceneRenderer.onFirstFrameHold=s=>{this.holding=s,this.applyHold()},this.hoverTooltip=this.shadow.getElementById("hover-tooltip"),this.ghostPath=this.shadow.getElementById("ghost-path"),this.flightMark=this.shadow.getElementById("flight-mark"),this.ufoElement=document.createElement(f1),this.ufoElement.classList.add("ufo-overlay"),this.ufoElement.paintsShapes=!1,this.ufoElement.observerMapSnapshotSource=s=>this.snapshotMapOf(s),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"&&Qn.fill(n,this)}),this.sceneRenderer.onMapSubjectBounds=s=>this.ufoElement.setMapSubjectBounds(s),this.ufoElement.addEventListener("timeupdate",this.handleTimeUpdate),this.ufoElement.addEventListener("revealrequest",()=>this.poster.release()),this.ufoElement.addEventListener(jb,()=>this.poster.restore()),this.ufoElement.seekPreviewPainter=(s,r)=>this.seekPreviewOf(r).paint(s,r),typeof VideoEncoder<"u"&&typeof OffscreenCanvas<"u"&&(this.ufoElement.filmer={film:(s,r,a)=>this.film(s,r,a),generativeKit:(s,r,a)=>this.generativeKit(s,r,a),fileName:()=>this.filmFileName(),kitFileName:()=>this.filmFileName().replace(/\.mp4$/," - kit.zip"),pictureSize:()=>this.filmPictureSize(),hasMap:()=>this.ufoElement.hasObserverMap,durationS:()=>this.ufoElement.seekableDuration/this.filmRate()/1e3,positionS:()=>this.ufoElement.currentTime/this.filmRate()/1e3}),this.ufoElement.addEventListener("mutedchange",()=>this.applyLevel()),this.ufoElement.ambientSound=s=>s.vehicle!==void 0||s.decor.some(r=>r.engine!==void 0)||s.decor.some(r=>cd.kindOf(r,this.decorModelSounds.get(r.model?.id??""))!==void 0)||this.interpretationShown?.bodies.some(r=>r.sound)===!0||s.weatherTrack.allKeyframes.some(r=>r.weather.precipitationType!=="none"||r.weather.windSpeed>1)||this.detonates(s)||(this.traffic?.audible?.size??0)>0,this.ufoElement.addEventListener("referenceview",s=>this.applyReferenceView(s.detail)),this.ufoElement.addEventListener("traceview",s=>this.sceneRenderer.setTracesShown(s.detail.shown)),this.ufoElement.canvasElement.addEventListener("pointermove",this.handlePointerMove),this.ufoElement.canvasElement.addEventListener("pointerleave",this.handlePointerLeave);for(const s of ve.GESTURES)this.addEventListener(s,this.handleFirstInteraction,!0)}get said(){return this.saidTexts??=new Cr(Lo.preferencesFor(this))}saidTexts;traceLabelsFor;observerHeadlightsAt(t,e){const i=t.vehicle;return!i||!Yn.isRoad(i.kind)?void 0:{setting:$c.at(i.headlights??"auto",i.headlightKeyframes,e)??"auto",headingDeg:this.travelHeadingAt(t,e)}}travelHeadingAt(t,e){const i=ke(t,e);if(!i)return 0;for(const n of[400,-400]){const s=ke(t,e+n);if(!s||i.lat===void 0||i.lng===void 0||s.lat===void 0||s.lng===void 0)break;const r=ae(s.lat,s.lng,i.lat,i.lng);if(Math.hypot(r.x,r.z)<.8)continue;return(Math.atan2(r.x,-r.z)*180/Math.PI+(n<0?180:0)+360)%360}return i.headingDeg??0}routeCache;routeOf(t){const e=t.allKeyframes;if(this.routeCache?.track===t&&this.routeCache.count===e.length)return this.routeCache.route;const i=e.flatMap(s=>s.pose.lat!==void 0&&s.pose.lng!==void 0?[{lat:s.pose.lat,lng:s.pose.lng}]:[]),n=i.length>=2?i:void 0;return this.routeCache={track:t,count:e.length,route:n},n}traceLabels(t){const e=Lo.preferencesFor(this).join();if(this.traceLabelsFor?.traces!==t||this.traceLabelsFor.language!==e){const i=new Map;for(const n of t){const s=this.said.read(n.title);s&&i.set(n.id,s)}this.traceLabelsFor={traces:t,language:e,labels:i}}return this.traceLabelsFor.labels}connectedCallback(){Te.changes.addEventListener("change",this.onModulesChanged),this.saidTexts=void 0,this.ready=this.loadSceneNames(),this.sceneRenderer.restoreContext(),this.resizeToStage(),this.updateAstronomy(this.lastTimeMs),this.loadStars(),this.resizeObserver=new ResizeObserver(()=>this.resizeToStage()),this.resizeObserver.observe(this.frameElement),this.watchVisibility(),document.addEventListener("fullscreenchange",this.handleFullscreenChange);for(const e of ve.GESTURES)document.addEventListener(e,this.handlePageGesture,!0);const t=this.getAttribute("src");t&&this.loadFromSrc(t)}watchVisibility(){this.visibilityObserver?.disconnect(),!(typeof IntersectionObserver>"u"||this.hasAttribute("always-live"))&&(this.visibilityObserver=new IntersectionObserver(t=>{if(t[t.length-1].isIntersecting){this.sceneRenderer.resume();return}this.ufoElement.pause(),this.sceneRenderer.suspend()},{rootMargin:"100px"}),this.visibilityObserver.observe(this))}visibilityObserver;disconnectedCallback(){Te.changes.removeEventListener("change",this.onModulesChanged),this.visibilityObserver?.disconnect(),this.resizeObserver?.disconnect(),document.removeEventListener("fullscreenchange",this.handleFullscreenChange);for(const t of ve.GESTURES)document.removeEventListener(t,this.handlePageGesture,!0);this.sceneRenderer.stopTwinkle(),clearTimeout(this.thunderTimeoutId),this.weatherAudio.dispose(),this.vehicleAudio.dispose(),this.aircraftAudio?.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===bh||t===Eh||t===Oc)&&i!==e&&this.forwardPlayerAttributes(),t===Oc&&this.stageElement.classList.toggle("minified",i!==null)}forwardPlayerAttributes(){for(const t of[bh,Eh,Oc]){const e=this.getAttribute(t);e===null?this.ufoElement.removeAttribute(t):this.ufoElement.setAttribute(t,e)}}setCompassForced(t){this.showCompassFor({forced:t})}compassHovered=!1;compassForced=!1;showCompassFor(t){this.compassHovered=t.hovered??this.compassHovered,this.compassForced=t.forced??this.compassForced,this.sceneRenderer.setCompassForced(this.compassForced||this.compassHovered)}lookToward(t){const e=ke(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}=ae(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.setOutsideHeard(Yn.transmission(this.ufoElement.sighting.vehicle)),this.weatherAudio.setAmbient(t.precipitationType,t.precipitationIntensity*(t.precipitationAmount??1),t.windSpeed);const e=this.ufoElement.sighting.around;this.weatherAudio.setAround(wi.aroundBedRms(e),wi.aroundBedShape(e)??[])}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)}decorScreenBox(t){return this.sceneRenderer.decorScreenBox(t)}decorDrawnOffset(t){return this.sceneRenderer.decorDrawnOffset(t)}decorGroundPointAt(t,e,i,n=0){return this.sceneRenderer.decorGroundPointAt(t,e,i,n)}decorMetresPerNdcY(t){return this.sceneRenderer.decorMetresPerNdcY(t)}decorGrabHeightAt(t,e,i){return this.sceneRenderer.decorGrabHeightAt(t,e,i)}bodyScreenBox(t){return this.sceneRenderer.bodyScreenBox(t)}pickPlacedBodyAt(t,e){return this.sceneRenderer.pickPlacedBodyAt(t,e)}resumeWeatherAudio(){this.weatherAudio.resume(),this.vehicleAudio.resume(),this.aircraftAudio?.resume()}async loadFromSrc(t){const e=hd.recording(t);this.holdForNewScene(e);const i=await e;this.documentUrl=new URL(t,location.href).href,this.showPoster(i.image,this.documentUrl,!this.ufoElement.playRequested),this.sightingData=i}loader;poster;showPoster(t,e,i=!0){this.poster.show(t,e,i)}applyHold(){const t=this.holding,e=this.poster.up;this.loader.hidden=!t||e,t&&(this.hoverTooltip.hidden=!0),this.ufoElement.captionHeld=t||e,this.ufoElement.controlsHeld=t||e,this.ufoElement.holdClock(t)}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){const e=la.recording(t);this.ufoElement.playerTitle=void 0,this.ufoElement.sightingData=e,this.requireModules(e.modules),this.upperAirHeardLive=void 0,this.seekPreview?.recordingChanged(e),this.showInterpretation(this.inTheRound?this.ufoElement.sighting.interpretation:void 0),this.syncAccountHidden(),this.applyFrameFormat(),this.lastTimeMs=0,this.sceneRenderer.compileNextFrameOffThread(),this.updateAstronomy(0)}onModulesChanged=t=>{t.detail==="skyEvents"&&this.sceneRenderer.setSkyEvents(this.skyEventsShown,!0,this.skyEventsStartDate)};requireModules(t){if(!t?.length)return;const e=this.documentUrl,i=dt(async()=>{const{ModuleSession:n}=await import("./ModuleSession-Hj3QwLuw.js");return{ModuleSession:n}},[],import.meta.url).then(({ModuleSession:n})=>n.shared.require(t,e)).then(()=>this.sceneRenderer.setDecorModelProvider(new UA));this.sceneRenderer.holdUntil(i)}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 Dp(this,()=>document.createElement(QM))}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.imageSmoothingQuality="high",e.drawImage(this.sceneCanvas,0,0,t.width,t.height),!0):!1}filmName;filmFileName(){return`${(this.filmName??"").replace(/[\\/:*?"<>|\u0000-\u001f]+/g," ").replace(/\s+/g," ").trim()||"observation"}.mp4`}filming=!1;async film(t,e,i){const[{VideoExport:n},{FilmChrome:s}]=await Promise.all([dt(()=>import("./VideoExport-B8ZhHNnd.js").then(a=>a.a),[],import.meta.url),dt(()=>import("./FilmChrome-DYiyzoB_.js"),[],import.meta.url)]),r=await s.loadLogo();return this.filmScene(t,a=>n.film({...a,frameAt:(c,l,h)=>a.frameAt(c,l,h)?(s.paint(h,this.ufoElement.filmChrome(t),r),!0):!1},e,i))}async generativeKit(t,e,i){const[{GenerativeKit:n},{generativeKitMessages:s},{toSightingJson:r}]=await Promise.all([dt(()=>import("./GenerativeKit-BmhvjjzB.js"),__vite__mapDeps([18,19,20]),import.meta.url),dt(()=>import("./GenerativeKitMessages-BhHcmiXg.js"),[],import.meta.url),dt(()=>Promise.resolve().then(()=>q_),void 0,import.meta.url)]),a=I0(Lo.preferencesFor(this),C0),[c]=await Promise.all([s.load(a),this.sceneRenderer.loadControlPasses()]),l=this.sceneRenderer.areReferencesShown;this.sceneRenderer.setReferencesShown(!1);try{return await this.filmScene({...t,caption:!1,time:!1,map:!1},h=>n.make({film:h,drawControlPasses:()=>this.sceneRenderer.drawControlPasses(),recording:r(this.ufoElement.sighting),title:this.filmName??"",source:h.about?.source,language:a},c,e,i))}finally{this.sceneRenderer.setReferencesShown(l)}}async filmScene(t,e){if(this.filming)throw new Error("Already filming");const i=this.ufoElement,n=i.currentTime;i.pause();const s={width:this.sceneCanvas.clientWidth,height:this.sceneCanvas.clientHeight},r=t.height&&s.height>0?t.height/s.height:this.sceneRenderer.maxPixelRatio;this.filming=!0,this.sceneRenderer.holdPixelRatio(r),i.filmMap(t.map),this.syncAnimationsToPlayback();try{const a=t.height??this.sceneCanvas.height,c=t.height&&s.height>0?Math.round(t.height*s.width/s.height):this.sceneCanvas.width,l=this.filmRate(),h=Math.min(i.seekableDuration,t.toS!==void 0?t.toS*1e3*l:i.seekableDuration),u=Math.min(h,Math.max(0,(t.fromS??0)*1e3*l));return await e({fromMs:u,toMs:h,rate:l,width:c,height:a,frameAt:(d,f,p)=>this.filmFrameAt(d,f,p),hearInto:d=>this.hearInto(d),about:{title:this.filmName,description:i.filmDescription,source:this.documentUrl?new URL(this.documentUrl,location.href).href:void 0}})}finally{this.filming=!1,this.sceneRenderer.holdPixelRatio(void 0),i.filmMap(void 0),i.currentTime=n,this.syncAnimationsToPlayback()}}filmRate(){const t=this.ufoElement.playbackRate;return t>0?t:1}filmPictureSize(){const t=this.sceneRenderer.maxPixelRatio;return{width:Math.round(this.sceneCanvas.clientWidth*t),height:Math.round(this.sceneCanvas.clientHeight*t)}}filmSound;liveSound;filmThunderAtMs;hearInto(t){if(t){this.liveSound??={weather:this.weatherAudio,vehicle:this.vehicleAudio,aircraft:this.aircraftAudio},this.filmSound=t,this.weatherAudio=new Gc(t),this.vehicleAudio=new xy(t);const e=ve.trafficRuntime;this.aircraftAudio=this.liveSound.aircraft&&e?this.newAircraftAudio(e):void 0}else this.liveSound&&(this.weatherAudio.dispose(),this.vehicleAudio.dispose(),this.aircraftAudio?.dispose(),this.weatherAudio=this.liveSound.weather,this.vehicleAudio=this.liveSound.vehicle,this.aircraftAudio=this.liveSound.aircraft,this.liveSound=void 0,this.filmSound=void 0,this.filmThunderAtMs=void 0);this.ufoElement.hearInto(t),this.syncAnimationsToPlayback()}filmFrameAt(t,e,i){this.ufoElement.currentTime!==t&&(this.ufoElement.currentTime=t),this.filmThunderAtMs!==void 0&&t>=this.filmThunderAtMs&&(this.filmThunderAtMs=void 0,this.weatherAudio.playThunder()),this.sceneRenderer.render();const n=this.sceneRenderer.framesDrawn;return this.sceneRenderer.frame(e),this.sceneRenderer.framesDrawn===n?!1:(i.drawImage(this.sceneCanvas,0,0,i.canvas.width,i.canvas.height),!0)}referenceAspect(t){return this.sceneRenderer.referenceAspect(t)}screenPointOf(t){return this.sceneRenderer.screenPointOf(t)}horizonPointAt(t){const e=t*Math.PI/180,i=this.sceneRenderer.screenPointOf(new _(Math.sin(e),0,-Math.cos(e)));return i&&{x:(i.ndcX+1)/2,y:(1-i.ndcY)/2}}directionAt(t,e){return this.sceneRenderer.directionAt(t,e)}referenceFailure(t){return this.sceneRenderer.referenceFailure(t)}applyReferenceView(t){this.sceneRenderer.setReferencesShown(t.shown);for(const e of this.ufoElement.sighting.references){const i=t.views?.[e.id];this.sceneRenderer.setReferenceView(e.id,{opacity:i?i.shown?i.opacity:0:t.opacity})}}get currentTerrainAttribution(){return this.sceneRenderer.currentTerrainAttribution}get currentRoadAttribution(){return this.sceneRenderer.currentRoadAttribution}get currentWaterAttribution(){return this.sceneRenderer.currentWaterAttribution}get currentRailwayAttribution(){return this.sceneRenderer.currentRailwayAttribution}setTerrainProviders(t){this.liveTerrainProviders=t,this.snapshotKey=void 0,this.applySnapshots(this.ufoElement.sighting.snapshots)}liveTerrainProviders;snapshotKey="none";applySnapshots(t){const e=vh.isEmpty(t)?"none":`${JSON.stringify(t)}
|
|
8938
|
+
`);let s=qr.cache.get(n);return s||(s=Promise.all(i.map(r=>qr.load(r.url))).then(r=>r.reduce((a,c)=>qr.concat(a,c))),qr.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 r=new Float32Array(n.length+s.length);return r.set(n,0),r.set(s,n.length),r};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 ai{constructor(t){if(this.heights=t,t.length!==ai.WIDTH*ai.HEIGHT)throw new Error(`a lunar relief has ${ai.WIDTH*ai.HEIGHT} samples, not ${t.length}`)}static SAMPLES_PER_DEGREE=16;static WIDTH=360*ai.SAMPLES_PER_DEGREE;static HEIGHT=180*ai.SAMPLES_PER_DEGREE;static UNIT_KM=.1;static REFERENCE_RADIUS_KM=1737.4;static BAND_FROM_DEG=74;static BAND_TO_DEG=106;heightKm(t,e){const i=ai.SAMPLES_PER_DEGREE,n=(e%360+360)%360*i-.5,s=(90-t)*i-.5,r=Math.floor(n),a=Math.floor(s),c=n-r,l=s-a,h=(f,p)=>{const g=(f%ai.WIDTH+ai.WIDTH)%ai.WIDTH,m=Math.min(ai.HEIGHT-1,Math.max(0,p));return this.heights[m*ai.WIDTH+g]},u=h(r,a)*(1-c)+h(r+1,a)*c,d=h(r,a+1)*(1-c)+h(r+1,a+1)*c;return(u*(1-l)+d*l)*ai.UNIT_KM}static inBand(t,e){const i=Math.PI/180,n=Math.acos(Math.cos(t*i)*Math.cos(e*i))*180/Math.PI;return n>=ai.BAND_FROM_DEG&&n<=ai.BAND_TO_DEG}static withBump(t,e,i,n=.4){const s=new Int8Array(ai.WIDTH*ai.HEIGHT),r=ai.SAMPLES_PER_DEGREE,a=Math.ceil(n*r),c=Math.floor(e*r),l=Math.floor((90-t)*r);for(let h=-a;h<=a;h++)for(let u=-a;u<=a;u++)Math.hypot(u,h)<=a&&(s[(l+h)*ai.WIDTH+(c+u+ai.WIDTH)%ai.WIDTH]=Math.round(i/ai.UNIT_KM));return new ai(s)}static smooth(){return new ai(new Int8Array(ai.WIDTH*ai.HEIGHT))}}class dr{static SAMPLES=5760;static SEARCH_FROM_DEG=87;static SEARCH_TO_DEG=90.2;static SEARCH_STEP_DEG=.0625;static profile(t,e,i,n=dr.SAMPLES){const{s,u:r,w:a,distanceKm:c}=dr.frame(t,e),l=Math.PI/180,h=new Float32Array(n),u=ai.REFERENCE_RADIUS_KM;for(let d=0;d<n;d++){const f=d/n*2*Math.PI,p=Math.cos(f),g=Math.sin(f),m=p*r[0]+g*a[0],M=p*r[1]+g*a[1],v=p*r[2]+g*a[2];let x=0;for(let y=dr.SEARCH_FROM_DEG;y<=dr.SEARCH_TO_DEG;y+=dr.SEARCH_STEP_DEG){const w=Math.cos(y*l),b=Math.sin(y*l),E=w*s[0]+b*m,S=w*s[1]+b*M,A=w*s[2]+b*v,R=Math.asin(Math.max(-1,Math.min(1,A)))/l,D=Math.atan2(S,E)/l,I=u+i.heightKm(R,D),P=Math.atan2(I*b,c-I*w);P>x&&(x=P)}h[d]=x/l}return{radiusDeg:h,meanRadiusDeg:Math.asin(u/c)/l}}static frame(t,e){const i=new nc(e.lat,e.lng,e.elevationM),n=ro(t),s=bM(t,i,!1),r=new Be(s.x-n.x,s.y-n.y,s.z-n.z,n.t),a=Math.hypot(r.x,r.y,r.z)*dr.AU_KM,c=dr.bodyFixed(t),l=c(r),h=Math.hypot(l[0],l[1],l[2]),u=[l[0]/h,l[1]/h,l[2]/h],d=kO(t,i),f=Yv(d),p=io(d,new Be(-r.x,-r.y,-r.z,n.t)),g=Math.asin(p.z/Math.hypot(p.x,p.y,p.z)),m=Math.atan2(-p.y,p.x),M=new Be(-Math.sin(g)*Math.cos(m),Math.sin(g)*Math.sin(m),Math.cos(g),n.t),v=new Be(-Math.sin(m),-Math.cos(m),0,n.t);return{s:u,u:c(io(f,M)),w:c(io(f,v)),distanceKm:a}}static surfacePoint(t,e,i,n){const{s,u:r,w:a}=dr.frame(t,e),c=Math.PI/180,l=[0,1,2].map(u=>Math.cos(i*c)*r[u]+Math.sin(i*c)*a[u]),h=[0,1,2].map(u=>Math.cos(n*c)*s[u]+Math.sin(n*c)*l[u]);return{latDeg:Math.asin(h[2])/c,lonDeg:Math.atan2(h[1],h[0])/c}}static radiusAt(t,e){const i=t.radiusDeg.length,n=(e/360*i%i+i)%i,s=Math.floor(n),r=n-s;return t.radiusDeg[s]*(1-r)+t.radiusDeg[(s+1)%i]*r}static uncoveredFraction(t,e,i){const n=t.radiusDeg.length,s=i.upDeg*i.upDeg+i.rightDeg*i.rightDeg;let r=0;for(let a=0;a<n;a++){const c=a/n*2*Math.PI,l=Math.cos(c),h=Math.sin(c),u=l*i.upDeg+h*i.rightDeg,d=u*u-s+e*e;if(d<=0)continue;const f=Math.sqrt(d),p=u+f;if(p<=0)continue;const g=Math.max(0,u-f),m=Math.max(g,t.radiusDeg[a]);p>m&&(r+=.5*(p*p-m*m))}return Math.min(1,Math.max(0,r*(2*Math.PI/n)/(Math.PI*e*e)))}static AU_KM=1495978707e-1;static bodyFixed(t){const e=jO(gt.Moon,t),i=Math.PI/180,n=e.ra*15*i,s=e.dec*i,r=e.spin*i,a=(l,[h,u,d])=>[Math.cos(l)*h+Math.sin(l)*u,-Math.sin(l)*h+Math.cos(l)*u,d],c=(l,[h,u,d])=>[h,Math.cos(l)*u+Math.sin(l)*d,-Math.sin(l)*u+Math.cos(l)*d];return l=>a(r,c(Math.PI/2-s,a(Math.PI/2+n,[l.x,l.y,l.z])))}static subObserverPoint(t,e){const i=new nc(e.lat,e.lng,e.elevationM),n=ro(t),s=bM(t,i,!1),r=dr.bodyFixed(t)(new Be(s.x-n.x,s.y-n.y,s.z-n.z,n.t)),a=Math.hypot(r[0],r[1],r[2]);return{latDeg:Math.asin(r[2]/a)*180/Math.PI,lonDeg:Math.atan2(r[1],r[0])*180/Math.PI}}}class rd{static cache=new Map;static load(t){let e=rd.cache.get(t);return e||(e=rd.fetchRelief(t).catch(()=>{}),rd.cache.set(t,e)),e}static async fetchRelief(t){const e=await fetch(t);if(!e.ok)return;let i=new Uint8Array(await e.arrayBuffer());if(i[0]===31&&i[1]===139){if(typeof DecompressionStream>"u")return;const n=new Blob([i]).stream().pipeThrough(new DecompressionStream("gzip"));i=new Uint8Array(await new Response(n).arrayBuffer())}return new ai(new Int8Array(i.buffer,i.byteOffset,i.length))}}const ry=Gs.catalog({en:()=>dt(()=>import("./PerceptionMessages_en-B2O6DR64.js"),[],import.meta.url).then(o=>o.perceptionMessages_en),fr:()=>dt(()=>import("./PerceptionMessages_fr-B59TnGBC.js"),[],import.meta.url).then(o=>o.perceptionMessages_fr),es:()=>dt(()=>import("./PerceptionMessages_es-BmkP6OqD.js"),[],import.meta.url).then(o=>o.perceptionMessages_es),it:()=>dt(()=>import("./PerceptionMessages_it-DPlxRmxu.js"),[],import.meta.url).then(o=>o.perceptionMessages_it)});class Pp{static ID="color-vision";static MATRICES={protan:[.152286,1.052583,-.204868,.114503,.786281,.099216,-.003882,-.048116,1.051998],deutan:[.367322,.860646,-.227968,.280085,.672501,.047413,-.01182,.04294,.968881],tritan:[1.255528,-.076749,-.178779,-.078411,.930809,.147602,.004733,.691367,.3039]};id=Pp.ID;messages=ry;sources=["Machado, Oliveira, Fernandes, A Physiologically-based Model for Simulation of Color Vision Deficiency, IEEE TVCG 15(6), 2009"];settings=[{id:"type",kind:"choice",default:"normal",choices:[{id:"normal"},{id:"protan"},{id:"deutan"},{id:"tritan"}]},{id:"severity",kind:"number",default:100,min:0,max:100,step:5,unit:"%"}];perceive(t){const e=Pp.MATRICES[String(t.type)];if(!e)return Bs.NONE;const i=Number(t.severity??100),n=Math.max(0,Math.min(100,Number.isFinite(i)?i:100))/100;return{colorMatrix:e.map((r,a)=>Bs.IDENTITY[a]+(r-Bs.IDENTITY[a])*n),contrastGain:1}}}class ay{static ID="fatigue";id=ay.ID;messages=ry;sources=["Studies of contrast sensitivity during prolonged sleep deprivation (60 hours, naval officers): no significant change"];settings=[{id:"hoursAwake",kind:"number",default:0,min:0,max:72,step:1,unit:"h"}];perceive(t){return Bs.NONE}}class Tc{static ID="intoxication";static MEASURED_LEVEL=.08;static MEASURED_LOSS_DB=.9;static MAX_EFFECT_LEVEL=.1;static MAX_LEVEL=.5;id=Tc.ID;messages=ry;sources=["Frontiers in Neuroscience, 2022, doi:10.3389/fnins.2022.873671 (contrast sensitivity at about 0.08 % blood alcohol)"];settings=[{id:"bloodAlcohol",kind:"number",default:0,min:0,max:Tc.MAX_LEVEL,step:.01,unit:"%",also:{unit:"g/L",factor:10,digits:1}}];perceive(t){const e=Number(t.bloodAlcohol??0),i=Math.max(0,Math.min(Tc.MAX_EFFECT_LEVEL,Number.isFinite(e)?e:0));if(i===0)return Bs.NONE;const n=i/Tc.MEASURED_LEVEL*Tc.MEASURED_LOSS_DB;return{colorMatrix:Bs.IDENTITY,contrastGain:10**(-n/20)}}}const vL=o=>o.sources[0]??o.id,yL=Te.point("perception").provide(Te.BUILT_IN,[new Pp,new Tc,new ay].map(o=>({id:o.id,name:o.id,credit:vL(o),creditUrl:"https://ufoathome.org/docs/sources/",create:()=>o})));class Rc{static built=new WeakMap;static get ALL(){return yL.map(t=>{let e=Rc.built.get(t);return e||(e=t.create(),Rc.built.set(t,e)),e})}static byId(t){return Rc.ALL.find(e=>e.id===t)}static perceptionOf(t){return Rc.ALL.reduce((e,i)=>Bs.combine(e,i.perceive(t?.[i.id]??{})),Bs.NONE)}static compact(t){const e={},i=Rc.ALL;for(const[n,s]of Object.entries(t))!i.some(r=>r.id===n)&&Object.keys(s??{}).length>0&&(e[n]=s);for(const n of i){const s=t[n.id]??{},r=Object.fromEntries(n.settings.filter(a=>s[a.id]!==void 0&&s[a.id]!==a.default).map(a=>[a.id,s[a.id]]));Object.keys(r).length>0&&(e[n.id]=r)}return Object.keys(e).length>0?e:void 0}}class Dc{static NONE={id:"none",name:"No filter",opticalDensity:0};static SOLAR_VISUAL={id:"solar-visual",name:"Solar filter for the eye (OD 5)",opticalDensity:5,usableWith:["eye","binoculars","telescope"]};static SOLAR_PHOTO={id:"solar-photo",name:"Solar film for a camera (OD 3.8)",opticalDensity:3.8,usableWith:["camera","dslr","phone","telescope"]};static ALL=[Dc.NONE,Dc.SOLAR_VISUAL,Dc.SOLAR_PHOTO];static usableWith(t,e){return!t.usableWith||t.usableWith.includes(e.category)}static byId(t){return Dc.ALL.find(e=>e.id===t)??Dc.NONE}static transmittance(t){return 10**-t.opticalDensity}static magnitudes(t){return 2.5*t.opticalDensity}}class jS{names;constructor(t){this.names=t??Gs.blank(),this.loaded=t!==void 0}loaded;body(t){return this.names.bodies[t]??t}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){return this.names.decorKinds[t]}point(t){return Yc.point(t,this.loaded?this.names.compassPoints:void 0)}towards(t){return Yc.towards(t,this.loaded?this.names:void 0)}}class jr{static STANDARD_GAUGE_MM=1435;static METRE_GAUGE_MM=1e3;static kind(t,e){return t.highSpeed?e.highSpeed:t.service?e.service:e.kinds[t.kind]}static name(t,e){const i=t.name??jr.kind(t,e);return t.services?.length?`${i} — ${t.services.join(", ")}`:i}static voltage(t,e){return t>=1e3?`${(t/1e3).toLocaleString(e,{maximumFractionDigits:1})} kV`:`${t.toLocaleString(e)} V`}static detail(t,e,i,n){const{line:s}=t,r=[];s.name&&r.push(jr.kind(s,e).toLocaleLowerCase(n)),r.push(s.tracks>1?e.tracks.replace("{count}",String(s.tracks)):e.singleTrack);const a=s.voltageV?jr.voltage(s.voltageV,n):void 0;if(t.contactM!==void 0){const c=t.contactM.toLocaleString(n,{minimumFractionDigits:2,maximumFractionDigits:2});r.push((a?e.overheadVoltage.replace("{voltage}",a):e.overhead).replace("{height}",c))}else s.electrification==="third_rail"?r.push(a?e.thirdRailVoltage.replace("{voltage}",a):e.thirdRail):s.electrification==="none"&&r.push(e.notElectrified);return s.gaugeMm===jr.METRE_GAUGE_MM?r.push(e.metreGauge):s.gaugeMm!==jr.STANDARD_GAUGE_MM&&r.push(e.gauge.replace("{mm}",s.gaugeMm.toLocaleString(n))),r.push(e.distance.replace("{distance}",i(t.distanceM))),s.services?.length?`${jr.name(s,e)}; ${r.join(", ")}`:`${jr.name(s,e)} — ${r.join(", ")}`}}class ad{constructor(t,e){this.element=t,this.onChange=e,t.addEventListener("error",()=>{this.url=void 0,this.release()})}shown=!1;url;get up(){return this.shown}show(t,e,i=!0){const n=ad.resolve(t,e);if(this.url=n,!n||!i){this.release();return}this.element.src=n,this.element.hidden=!1;const s=this.shown;this.shown=!0,s||this.onChange()}release(){this.shown&&(this.shown=!1,this.element.hidden=!0,this.element.removeAttribute("src"),this.onChange())}restore(){this.url&&this.show(this.url)}static resolve(t,e){if(!(typeof t!="string"||t.trim()===""))try{const i=new URL(t.trim(),e??location.href);return i.protocol!=="https:"&&i.protocol!=="http:"?void 0:i.origin===ad.PUBLISHED_ORIGIN&&ad.isDevelopmentHost(location.hostname)?location.origin+i.pathname:i.href}catch{return}}static PUBLISHED_ORIGIN="https://ufoathome.org";static isDevelopmentHost(t){return t==="localhost"||t==="127.0.0.1"||t==="[::1]"||t.endsWith(".localhost")}}const xL="Global Meteor Network",wL="https://globalmeteornetwork.org/data/",SL="“Thunder” by Jerimee",bL="https://creativecommons.org/licenses/by/3.0/",EL="CC BY 3.0";class Qn{static fill(t,e){t.innerHTML="";const i=d=>t.appendChild(d),n=e.currentTerrainAttribution;n&&i(Qn.text(n));const s=e.currentRoadAttribution;s&&i(Qn.text(s));const r=e.currentWaterAttribution;r&&i(Qn.text(r));const a=e.currentRailwayAttribution;a&&i(Qn.text(a));const c=e.ufoElement.observerMapCredit;c&&!n?.includes(c)&&i(Qn.text(c));for(const d of e.decorModelCredits){const f=d.author?` — ${d.author}`:"",p=document.createElement("li");d.sourceUrl?p.append(Qn.link(d.sourceUrl,d.title),document.createTextNode(`${f} (${d.license})`)):p.textContent=`${d.title}${f} (${d.license})`,i(p)}for(const d of e.ufoElement.sighting.references){if(!d.credit)continue;const f=document.createElement("li");d.creditUrl?f.appendChild(Qn.link(d.creditUrl,d.credit)):f.textContent=d.credit,i(f)}if(e.ufoElement.sighting.traces.length>0){const d=new Cr(Lo.preferencesFor(e)),f=new Set(e.ufoElement.sighting.traces.map(p=>d.read(p.source)).filter(p=>!!p));for(const p of f)i(Qn.text(p))}const l=e.satelliteState;if(l.status==="ready"&&l.credit){const d=document.createElement("li");d.appendChild(Qn.link(l.creditUrl??"",l.credit)),i(d)}if(e.fireballState.status==="ready"&&e.fireballState.records.length>0){const d=document.createElement("li");d.append(Qn.link(wL,xL),document.createTextNode(" (CC BY 4.0)")),i(d)}const h=e.aircraftState;if(h.status==="ready"&&h.shown>0){const d=document.createElement("li");if(d.appendChild(Qn.link(h.creditUrl,h.credit)),i(d),h.trailCredit){const f=document.createElement("li");f.appendChild(Qn.link(h.trailCredit.creditUrl,h.trailCredit.credit)),i(f)}}const u=Qn.text(`${SL} (`);u.append(Qn.link(bL,EL),document.createTextNode(")")),i(u)}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}}class Gi{static OCTAVES=[63,125,250,500,1e3,2e3,4e3,8e3];static STANDARD={temperatureC:15,relativeHumidity:.7,pressureKPa:101.325};static REFERENCE_PRESSURE_KPA=101.325;static REFERENCE_TEMPERATURE_K=293.15;static TRIPLE_POINT_K=273.16;static speedOfSound(t){return 20.0468*Math.sqrt(t+273.15)}static absorptionDbPerKm(t,e=Gi.STANDARD){const i=e.temperatureC+273.15,n=Gi.REFERENCE_TEMPERATURE_K,s=e.pressureKPa/Gi.REFERENCE_PRESSURE_KPA,r=10**(-6.8346*(Gi.TRIPLE_POINT_K/i)**1.261+4.6151),a=e.relativeHumidity*100*r/s,c=s*(24+40400*a*(.02+a)/(.391+a)),l=s*(i/n)**-.5*(9+280*a*Math.exp(-4.17*((i/n)**(-1/3)-1))),h=t*t;return 8.686*h*(184e-13*(1/s)*Math.sqrt(i/n)+(i/n)**-2.5*(.01275*Math.exp(-2239.1/i)/(c+h/c)+.1068*Math.exp(-3352/i)/(l+h/l)))*1e3}static aWeightingDb(t){const e=t*t,i=12194**2*e*e/((e+20.6**2)*Math.sqrt((e+107.7**2)*(e+737.9**2))*(e+12194**2));return 20*Math.log10(i)+2}static sumDb(t){return 10*Math.log10(t.reduce((e,i)=>e+10**(i/10),0))}}const AL=new URL(""+new URL("rain-BvWZrB9h.ogg",import.meta.url).href,import.meta.url).href,_L=new URL(""+new URL("wind-BjklexY7.ogg",import.meta.url).href,import.meta.url).href,QS=new URL(""+new URL("thunder-DA48qs_v.wav",import.meta.url).href,import.meta.url).href,TL=20,RL=1,DL=7,IL=.35,tb=.4,eb=40,ib=.5,CL=Math.SQRT2;class Gc{context;constructor(t){this.context=t}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};around;aroundRequested={rms:0,shape:[]};level=1;share=1;master;output(t){return this.master||(this.master=t.createGain(),this.master.gain.value=this.gain,this.master.connect(t.destination)),this.master}get gain(){return this.level*this.share}setLevel(t){this.level=t,this.master&&(this.master.gain.value=this.gain)}setOutsideHeard(t){this.share=Math.min(1,Math.max(0,t)),this.master&&(this.master.gain.value=this.gain)}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}}er.isLive(this.context)&&er.unlock(this.context),this.applyAround()}setAround(t,e){const i=this.aroundRequested;i.rms===Math.max(0,t)&&i.shape.length===e.length&&i.shape.every((n,s)=>n===e[s])||(this.aroundRequested={rms:Math.max(0,t),shape:e},this.applyAround())}applyAround(){const t=this.context;if(!t)return;const{rms:e,shape:i}=this.aroundRequested,n=this.paused?0:e;if(n===0&&!this.around)return;const s=this.around??(this.around=this.buildAround(t)),r=t.currentTime;s.gain.gain.setTargetAtTime(n,r,ib),Gi.OCTAVES.forEach((a,c)=>{const l=Math.sqrt(Math.min(1,1.11*a/(t.sampleRate/2)))/Math.sqrt(3);s.bands[c].gain.setTargetAtTime((i[c]??0)/l,r,ib)})}buildAround(t){const e=t.createBuffer(1,Math.floor(t.sampleRate*DL),t.sampleRate),i=e.getChannelData(0);for(let g=0;g<i.length;g++)i[g]=Math.random()*2-1;const n=t.createBufferSource();n.buffer=e,n.loop=!0;const s=Math.floor(t.sampleRate*eb),r=t.createBuffer(1,s,t.sampleRate),a=Array.from({length:Math.round(eb*tb)},()=>Math.random()*2-1),c=r.getChannelData(0),l=t.sampleRate/tb;for(let g=0;g<s;g++){const m=g/l,M=Math.floor(m),v=m-M,x=v*v*(3-2*v);c[g]=a[M%a.length]*(1-x)+a[(M+1)%a.length]*x}const h=t.createBufferSource();h.buffer=r,h.loop=!0;const u=t.createGain();u.gain.value=IL;const d=t.createGain();d.gain.value=1,h.connect(u).connect(d.gain);const f=t.createGain();f.gain.value=0,d.connect(f).connect(this.output(t));const p=Gi.OCTAVES.map(g=>{const m=t.createBiquadFilter();m.type="bandpass",m.frequency.value=g,m.Q.value=CL;const M=t.createGain();return M.gain.value=0,n.connect(m).connect(M).connect(d),M});return n.start(),h.start(),{sources:[n,h],nodes:[u,d,f,...p],bands:p,gain:f}}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 r=++this.ambientToken;this.stopSource(this.ambientSource,this.ambientGain),this.ambientSource=void 0,this.ambientGain=void 0,n!=="none"&&this.startLoop(AL,this.ambientVolume).then(a=>this.applyIfCurrent(a,r,()=>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/TL,1);const s=i>RL;if(s!==this.windActive){this.windActive=s;const r=++this.windToken;this.stopSource(this.windSource,this.windGain),this.windSource=void 0,this.windGain=void 0,s&&this.startLoop(_L,this.windVolume).then(a=>this.applyIfCurrent(a,r,()=>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),this.applyAround()}playThunder(){!this.context||this.paused||this.playOneShot(QS,.9)}playDetonation(t){const e=this.context;if(!e||this.paused)return;const i=Math.min(1,Math.max(0,t)),n=e.createBufferSource();n.buffer=this.crackBuffer(e);const s=e.createBiquadFilter();s.type="lowpass",s.frequency.value=Gc.CRACK_CUTOFF_HZ;const r=e.createGain();r.gain.value=i,n.connect(s).connect(r).connect(this.output(e)),n.start(),this.playOneShot(QS,i,Gc.DETONATION_RATE)}static DETONATION_RATE=.8;static CRACK_CUTOFF_HZ=2500;static CRACK_DECAY_S=.25;crackBuffer(t){if(this.crack?.sampleRate===t.sampleRate)return this.crack;const e=Math.round(t.sampleRate*Gc.CRACK_DECAY_S*6),i=t.createBuffer(1,e,t.sampleRate),n=i.getChannelData(0);for(let s=0;s<e;s++){const r=s/t.sampleRate;n[s]=(Math.random()*2-1)*Math.min(1,r/.005)*Math.exp(-r/Gc.CRACK_DECAY_S)}return this.crack=i,i}crack;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;for(const t of this.around?.sources??[])try{t.stop()}catch{}for(const t of this.around?.nodes??[])t.disconnect();this.around=void 0,er.isLive(this.context)&&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 r=i.createGain();return r.gain.value=e,s.connect(r).connect(this.output(i)),s.start(),{source:s,gain:r}}catch(n){console.warn("Weather ambient sound failed to load, staying silent:",n);return}}async playOneShot(t,e,i=1){const n=this.context;if(n)try{const s=await this.getBuffer(t),r=n.createBufferSource();r.buffer=s,r.playbackRate.value=i;const a=n.createGain();a.gain.value=e,r.connect(a).connect(this.output(n)),r.start()}catch(s){console.warn("Thunder sound failed to load:",s)}}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()}}const PL={rollingA:[83.1,89.2,87.7,93.1,100.1,96.7,86.8,76.2],rollingB:[30,41.5,38.9,25.7,32.5,37.2,39,40],propulsionA:[97.9,92.5,90.7,87.2,84.7,88,84.4,77.1],propulsionB:[-1.3,7.2,7.7,8,8,8,8,8]},OL={rollingA:[91.7,96.2,98.2,104.9,105.1,98.5,91.1,85.6],rollingB:[30,33.5,31.3,25.4,31.8,37.1,38.6,40.6],propulsionA:[108.8,104.2,103.5,102.9,102.6,98.5,93.8,87.5],propulsionB:[0,3,4.6,5,5,5,5,5]},n1=70,NL=55+10*Math.log10(2*Math.PI),s1=5,LL=2;class gn{static vehiclePowerDbA(t,e){return Gi.sumDb(gn.vehiclePowerBands(t,e).map((i,n)=>i+Gi.aWeightingDb(Gi.OCTAVES[n])))}static vehiclePowerBands(t,e){const i=t?OL:PL,n=Math.max(e,1);return Gi.OCTAVES.map((s,r)=>{const a=i.rollingA[r]+i.rollingB[r]*Math.log10(n/n1),c=i.propulsionA[r]+i.propulsionB[r]*(n-n1)/n1;return Gi.sumDb([a,c])})}static dbA(t,e=!0){if(!Ro.says(t))return-1/0;const i=t.withinM??Ro.DEFAULT_WITHIN_M,n=Ro.DEFAULT_SPEED_KMH,s=[gn.counted(t.cars,gn.vehiclePowerDbA(!1,n),i,s1),gn.counted(t.trucks,gn.vehiclePowerDbA(!0,n),i,s1),e?gn.counted(t.talking,NL,i,LL):-1/0,...(t.roads??[]).map(r=>gn.road(r.distanceM,r.vehiclesPerMinute,r.trucksPerMinute??0,r.speedKmh??n))].filter(r=>Number.isFinite(r));return s.length>0?Gi.sumDb(s):-1/0}static vehicleShape(t){if(!Ro.says(t))return;const e=t.withinM??Ro.DEFAULT_WITHIN_M,i=Ro.DEFAULT_SPEED_KMH,n=l=>{const h=gn.counted(l?t.trucks:t.cars,gn.vehiclePowerDbA(l,i),e,s1),u=(t.roads??[]).map(f=>{const p=Math.min(f.trucksPerMinute??0,f.vehiclesPerMinute);return l?gn.road(f.distanceM,p,p,f.speedKmh??i):gn.road(f.distanceM,f.vehiclesPerMinute-p,0,f.speedKmh??i)}),d=[h,...u].filter(Number.isFinite);return d.length>0?10**(Gi.sumDb(d)/10):0},s=n(!1),r=n(!0);if(s+r===0)return;const a=Gi.OCTAVES.map(()=>0);for(const[l,h]of[[s,!1],[r,!0]]){if(l===0)continue;const u=gn.vehiclePowerBands(h,i),d=Gi.sumDb(u.map((f,p)=>f+Gi.aWeightingDb(Gi.OCTAVES[p])));u.forEach((f,p)=>a[p]+=l*10**((f-d)/10))}const c=Math.sqrt(a.reduce((l,h)=>l+h,0));return a.map(l=>Math.sqrt(l)/c)}static counted(t,e,i,n){if(!t)return-1/0;const s=Math.min(n,i*.99),r=t*Math.log(i/s)/(Math.PI*(i*i-s*s));return e+10*Math.log10(r)}static road(t,e,i,n){const s=Math.min(i,e),r=(c,l)=>c>0?gn.vehiclePowerDbA(l,n)+10*Math.log10(c/(1e3*Math.max(n,1))):-1/0,a=Gi.sumDb([r((e-s)*60,!1),r(s*60,!0)].filter(Number.isFinite));return Number.isFinite(a)?a-10*Math.log10(Math.PI*Math.max(t,1)):-1/0}}class wi{static BASE_DB_A=30;static OUTDOOR_SHAPE_DB=[-12,-7,-5,-5,-7,-11,-17,-25];static HEADROOM_DB=10.5;static AROUND_BED_PLAYED=!1;static WIND_DB_A=[[0,10],[1,28],[2,36],[3,40],[5,46],[8,52],[12,58],[20,66]];static RAIN_DB_A=[[0,0],[.1,42],[.3,50],[.6,58],[1,65]];static BED_RMS=.2;static MINIMUM_REFERENCE=.008;static WIND_BED_MIN_MS=1;static WIND_BED_FULL_MS=20;static dbA(t,e){const i=[wi.BASE_DB_A,wi.along(wi.WIND_DB_A,t.windSpeed),gn.dbA(e)].filter(Number.isFinite);return(t.precipitationType==="rain"||t.precipitationType==="hail")&&i.push(wi.along(wi.RAIN_DB_A,t.precipitationIntensity)),10*Math.log10(i.filter(n=>n>0).reduce((n,s)=>n+10**(s/10),0))}static bedVolume(t){const e=t.windSpeed>wi.WIND_BED_MIN_MS?Math.min(t.windSpeed/wi.WIND_BED_FULL_MS,1):0,i=t.precipitationType==="hail"?Math.min(1,t.precipitationIntensity*1.3+.2):t.precipitationType==="rain"?t.precipitationIntensity:0;return Math.hypot(e,i)}static referenceAmplitude(t,e){return Math.max(Math.hypot(wi.BED_RMS*wi.bedVolume(t),wi.aroundReference(e)),wi.MINIMUM_REFERENCE)}static aroundReference(t){const e=gn.dbA(t);return!Number.isFinite(e)||e<=wi.BASE_DB_A?0:wi.MINIMUM_REFERENCE*10**((e-wi.BASE_DB_A)/20)}static aroundBedRms(t){if(!wi.AROUND_BED_PLAYED)return 0;const e=gn.dbA(t,!1);return!Number.isFinite(e)||e<=wi.BASE_DB_A?0:Math.min(wi.BED_RMS,wi.MINIMUM_REFERENCE*10**((e-wi.BASE_DB_A-wi.HEADROOM_DB)/20))}static bedPlays(t,e){return wi.bedVolume(t)>0||wi.aroundBedRms(e)>0}static shapeDb(t,e){const i=10**(wi.dbA(t,e)/10),n=gn.dbA(e,!1),s=Number.isFinite(n)?10**(n/10):0,r=Math.max(0,i-s),a=wi.OUTDOOR_SHAPE_DB,c=10**(Gi.sumDb(a)/10),h=gn.vehicleShape(e)?.map((p,g)=>p*p*10**(Gi.aWeightingDb(Gi.OCTAVES[g])/10)),u=h?.reduce((p,g)=>p+g,0)??1,d=Gi.OCTAVES.map((p,g)=>r*10**(a[g]/10)/c+(h?s*h[g]/u:0)),f=d.reduce((p,g)=>p+g,0);return d.map(p=>10*Math.log10(p/f))}static aroundBedShape(t){return gn.vehicleShape(t)}static along(t,e){if(e<=t[0][0])return t[0][1];for(let i=1;i<t.length;i++)if(e<=t[i][0]){const[n,s]=t[i-1],[r,a]=t[i];return s+(a-s)*(e-n)/(r-n)}return t[t.length-1][1]}}class Ga{constructor(t){this.elements=t;const{eccentricity:e,perihelionAu:i}=t,[n,s]=this.perifocalAxes(),r=Math.sqrt(Ga.SUN_GM_AU3_PER_DAY2*(1+e)/i);this.perihelionPosition=this.scale(n,i),this.perihelionVelocity=this.scale(s,r),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,r=1-i*i/s*Ga.stumpffC(n),a=e-i*i*i/Math.sqrt(Ga.SUN_GM_AU3_PER_DAY2)*Ga.stumpffS(n);return{x:r*this.perihelionPosition.x+a*this.perihelionVelocity.x,y:r*this.perihelionPosition.y+a*this.perihelionVelocity.y,z:r*this.perihelionPosition.z+a*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(Ga.SUN_GM_AU3_PER_DAY2)*Math.abs(t),n=a=>{const c=this.inverseSemiMajorAxis*a*a,l=this.elements.perihelionAu;return(1-this.inverseSemiMajorAxis*l)*a*a*a*Ga.stumpffS(c)+l*a};let s=Math.max(1,i/this.elements.perihelionAu);for(;n(s)<i;)s*=2;let r=0;for(let a=0;a<Ga.MAX_ITERATIONS&&s-r>1e-13*Math.max(1,s);a++){const c=(r+s)/2;n(c)<i?r=c:s=c}return e*(r+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),r=Math.cos(e),a=Math.sin(e),c=Math.cos(i),l=Math.sin(i);return[{x:n*r-s*a*c,y:s*r+n*a*c,z:a*l},{x:-n*a-s*r*c,y:-s*a+n*r*c,z:r*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 qA=[{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 kL{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 qA.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=pi(e),s=this.earthPositionAt(n),r=this.apparentPositionOf(t,2451545+n.tt,s),a=this.subtract(r,s),c=this.length(r),l=this.length(a),h=this.tailEndAt(t,r,s,c,n,e,i),u=this.horizontalOf(a,n,e,i);return{apparition:t,position:u,...h,heliocentricDistanceAu:c,earthDistanceAu:l,elongationDeg:this.angleBetween(a,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,r,a){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,r,a),tailLengthDeg:this.angleBetween(h,l)}}static apparentPositionOf(t,e,i){const n=this.orbitOf(t);let s=n.positionAt(e);for(let r=0;r<2;r++){const a=this.length(this.subtract(s,i))/this.LIGHT_SPEED_AU_PER_DAY;s=n.positionAt(e-a)}return s}static horizontalOf(t,e,i,n){const s=io(PO(),new Be(t.x,t.y,t.z,e)),r=io(AA(e),s),a=bM(e,new nc(n.lat,n.lng,n.elevationM),!0),c=new Be(r.x-a.x,r.y-a.y,r.z-a.z,e),l=tm(c);return qv(l.ra,l.dec,i,n)}static earthPositionAt(t){return io(CO(),jo(gt.Earth,t))}static julianDayOf(t){return 2451545+pi(t).tt}static orbitOf(t){const e=this.orbits.get(t.id);if(e)return e;const i=new Ga(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 r1=[{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 nb{static UNIX_EPOCH_JD=24405875e-1;static aroundDate(t){const e=this.julianDayOf(t);return r1.filter(i=>this.magnitudeAt(i,e)!==void 0)}static appearancesAt(t,e){const i=this.julianDayOf(t),n=[];for(const s of r1){const r=this.magnitudeAt(s,i);r!==void 0&&n.push({outburst:s,position:Ir.ofJ2000(s.raHours,s.decDeg,t,e),magnitude:r})}return n.sort((s,r)=>s.magnitude-r.magnitude)}static brightestAt(t,e){return this.appearancesAt(t,e)[0]}static byId(t){return r1.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[r,a]=i[s-1]??i[0],[c,l]=i[s]??i[0];if(c===r)return a;const h=Math.min(1,Math.max(0,(n-r)/(c-r)));return a+h*(l-a)}static julianDayOf(t){return t.getTime()/864e5+this.UNIX_EPOCH_JD}}const FL=[{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}],Op=6.5;class a1{static activeAt(t){return FL.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)),r=this.dayOfYear(this.asDate(t.end)),a=this.wrappedDelta(i,s),c=this.wrappedDelta(s,n),l=this.wrappedDelta(r,s);return a<0?a<-c?0:1+a/c:a>0?a>l?0:1-a/l:1}static observedRatePerHour(t,e,i,n=Op){if(e<=0)return 0;const s=Op-n;return t*Math.sin(e*Math.PI/180)/Math.pow(i,s)}static radiantPosition(t,e,i){return Ir.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 qi{static QUIET_RATE_PER_HOUR=2;static APEX_RATE_PER_HOUR=8;static POPULATION_INDEX=3;static apexPosition(t,e){const i=pi(t),n=new Zp(0,lO(t).elon-90,1),s=io(FO(i),$v(n,i)),r=tm(s);return qv(r.ra,r.dec,t,e)}static observedRatePerHour(t,e=Op){const i=qi.APEX_RATE_PER_HOUR*Math.max(0,Math.sin(t*Math.PI/180)),n=Op-e;return(qi.QUIET_RATE_PER_HOUR+i)/Math.pow(qi.POPULATION_INDEX,n)}static schedule(t){const e=new em(t.seed^1542469173);return pr.schedule(t).map(i=>{const n=qi.toCartesian({altitudeDeg:Math.asin(e.next())*180/Math.PI,azimuthDeg:e.between(0,360)}),s=i.fromRadiantDeg*Math.PI/180,r=qi.turnAround(n,e.between(0,360)),a={x:n.x*Math.cos(s)+r.x*Math.sin(s),y:n.y*Math.cos(s)+r.y*Math.sin(s),z:n.z*Math.cos(s)+r.z*Math.sin(s)};return{...i,radiant:qi.toHorizontal(a),bearingDeg:qi.bearingFrom(a,n)}})}static turnAround(t,e){const[i,n]=qi.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]=qi.basisAround(t),s=t.x*e.x+t.y*e.y+t.z*e.z,r=qi.normalise({x:e.x-t.x*s,y:e.y-t.y*s,z:e.z-t.z*s});return(Math.atan2(r.x*n.x+r.y*n.y+r.z*n.z,r.x*i.x+r.y*i.y+r.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=qi.normalise(qi.cross(t,e));return[i,qi.normalise(qi.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=qi.toCartesian(t.radiant??{altitudeDeg:90,azimuthDeg:0}),i=qi.turnAround(e,t.bearingDeg),n=t.fromRadiantDeg*Math.PI/180;return qi.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 sb="https://ufoathome.org/tle/index.json";class ts{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??ts.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(sb)||t.push(sb),t}static FIRST_SNAPSHOT="2021-02-22";async covers(t){const e=Date.parse(`${ts.FIRST_SNAPSHOT}T00:00:00Z`)-ts.MAX_ELEMENT_AGE_DAYS*ts.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)-ts.MAX_ELEMENT_AGE_DAYS*ts.DAY_MS&&t.getTime()<=Date.parse(n.to)+ts.MAX_ELEMENT_AGE_DAYS*ts.DAY_MS):!1}async at(t){const e=await this.loadIndex();if(!e)return;const{index:i,base:n}=e,s=[],r=[];for(const a of Object.keys(i.kinds)){const c=await this.kindAt(a,t,i,n);s.push(...c),r.push(this.coverageOf(a,t,i,c.length>0))}return{objects:s,coverage:r,credit:i.credit,creditUrl:i.source}}async kindAt(t,e,i,n){const s=e.getTime(),r=i.binDays*ts.DAY_MS,a=Math.floor(s/r),c=s-a*r<r/2?a-1:a+1,l=new Set(i.kinds[t].bins),h=[a,c].map(g=>new Date(g*r).toISOString().slice(0,10)).filter(g=>l.has(g));if(h.length===0)return[];const[u,...d]=await Promise.all([this.json(new URL(`objects-${t}.json`,n).href),...h.map(g=>this.binary(new URL(`${t}/${g}.bin`,n).href))]),f=new Map;for(const g of d)for(const m of ts.decode(g,i.recordBytes)){const M=f.get(m.norad);(!M||Math.abs(m.epochMs-s)<Math.abs(M.epochMs-s))&&f.set(m.norad,m)}const p=[];for(const g of f.values()){const m=Math.abs(g.epochMs-s)/ts.DAY_MS;if(m>ts.MAX_ELEMENT_AGE_DAYS)continue;const M=u[g.norad]??{name:String(g.norad)};M.launch&&Date.parse(`${M.launch}T00:00:00Z`)>s||p.push({norad:g.norad,name:M.name,kind:t,launch:M.launch,stdMag:M.stdMag,elements:g,ageDays:m})}return p}coverageOf(t,e,i,n){const{from:s,to:r}=i.kinds[t],a=e.getTime(),c=ts.MAX_ELEMENT_AGE_DAYS*ts.DAY_MS,l=n?"covered":a<Date.parse(s)-c?"before":a>Date.parse(r)+c?"after":"gap";return{kind:t,status:l,from:s,to:r}}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 UL{lowerM;upperM;add(t,e){if(!(t<=0)){if(e.behindM!==void 0){const i=fi.sizeMAt(e.behindM,t);this.lowerM=this.lowerM===void 0?i:Math.max(this.lowerM,i)}if(e.inFrontM!==void 0){const i=fi.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:fi.distanceMAt(this.lowerM,t),maxM:this.upperM===void 0?void 0:fi.distanceMAt(this.upperM,t)}}clear(){this.lowerM=void 0,this.upperM=void 0}}class Kc{static DEG_PER_SECOND=360/86164.0905;static degOver(t){return Math.max(0,t)*Kc.DEG_PER_SECOND}static instants(t,e){if(!(e>0))return 1;const i=Kc.degOver(t)/e;return i<1?1:Math.min(Kc.MAX_INSTANTS,Math.max(2,Math.ceil(i)))}static MAX_INSTANTS=64}class Wn{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 Kc.DEG_PER_SECOND*3600}static graspOf(t,e={}){if(t.visualAid)return Wn.visualAidGrasp(t,e.focalLengthMm);const i=e.exposureSeconds??t.exposureSeconds,n=e.fNumber??t.fNumber;if(i===void 0||n===void 0||!(i>0)||!(n>0))return Wn.EYE;const s=e.focalLengthMm??t.frame?.focalLengthMm??Wn.UNKNOWN_CAMERA_FOCAL_MM,r=s/n,a=Wn.resolutionArcsec(t,s,r);return{apertureMm:r,exposureSeconds:Math.min(i,Wn.trailLimitedSeconds(a)),resolutionArcsec:a}}static visualAidGrasp(t,e){const i=t.visualAid,n=Wn.EYE,s=e??t.frame?.focalLengthMm,r=i.magnification??(s!==void 0&&i.eyepieceFocalMm?s/i.eyepieceFocalMm:1),a=Math.min(i.apertureMm,n.apertureMm*r);return{apertureMm:Math.max(a,n.apertureMm),exposureSeconds:n.exposureSeconds,resolutionArcsec:n.resolutionArcsec/Math.max(1,Math.min(r,i.apertureMm/n.apertureMm))}}static resolutionArcsec(t,e,i){const s=(t.detailUm??Wn.UNKNOWN_CAMERA_DETAIL_UM)/1e3/e*Wn.ARCSEC_PER_RADIAN,r=1.22*Wn.WAVELENGTH_M/(i/1e3)*Wn.ARCSEC_PER_RADIAN;return Math.max(s,r)}static trailLimitedSeconds(t){return t/Wn.skyDriftArcsecPerSecond}static gainOverEye(t,e={}){const i=Wn.graspOf(t,e),n=Wn.EYE,s=(i.apertureMm/n.apertureMm)**2,r=i.exposureSeconds/n.exposureSeconds,a=(n.resolutionArcsec/i.resolutionArcsec)**2;return 1.25*Math.log10(s*r*a)}static gainFor(t,e){const i=e.fieldOfViewDeg===void 0?void 0:Ji.focalLengthMmFor(t,e.fieldOfViewDeg);return Wn.gainOverEye(t,{fNumber:e.fNumber,focalLengthMm:i,exposureSeconds:e.exposureSeconds})}}const rb=111320,Ou=Math.PI/180,zL=1.02,BL=1;class od{static of(t,e){const i=od.sightings(t,e);if(i.length<2)return;const n=od.baseline(i);if(!n)return;const{near:s,far:r,closedM:a}=n,c=Math.tan(r.widthDeg/2*Ou)===0?0:Math.tan(s.widthDeg/2*Ou)/Math.tan(r.widthDeg/2*Ou);if(c<zL)return;const l=a/(c-1),h=fi.sizeMAt(l,s.widthDeg),u=i.map(d=>({t:d.t,m:fi.distanceMAt(h,d.widthDeg)}));return{widthM:h,distanceM:u,nearestM:Math.min(...u.map(d=>d.m)),fromT:r.t,toT:s.t,closedM:a}}static sightings(t,e){return t.timeline.allKeyframes.flatMap(i=>{const n=i.shapes.find(a=>a.sourceId===e)?.shape,s=n?.angular?.widthDeg,r=ke(t,i.t);return s===void 0||s<=0||r?.lat===void 0||r.lng===void 0?[]:[{t:i.t,widthDeg:s,lat:r.lat,lng:r.lng,sightAzimuthDeg:n?.aim?.azimuthDeg??r.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=od.closedAlongSight(i,n),[r,a,c]=s>=0?[n,i,s]:[i,n,-s];c<BL||r.widthDeg<=a.widthDeg||(!e||c>e.closedM)&&(e={near:r,far:a,closedM:c})}return e}static closedAlongSight(t,e){const i=(e.lat-t.lat)*rb,n=(e.lng-t.lng)*rb*Math.cos(t.lat*Ou),s=(t.sightAzimuthDeg??0)*Ou;return i*Math.cos(s)+n*Math.sin(s)}}class vs{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:vs.atLeastNearest(t.statedM),basis:"stated"};if(t.hypothesisM!==void 0&&t.hypothesisM>0)return{distanceM:vs.atLeastNearest(t.hypothesisM),basis:"hypothesis"};if(t.derivedM!==void 0&&t.derivedM>0)return{distanceM:vs.atLeastNearest(t.derivedM),basis:"derived"};const e=vs.largest(t.range?.minM,t.crossing?.behindM),i=vs.smallest(t.range?.maxM,t.crossing?.inFrontM),n=e===void 0?void 0:e*vs.MARGIN,s=i===void 0?void 0:i/vs.MARGIN;return n!==void 0&&s!==void 0?{distanceM:vs.atLeastNearest(n<=s?Math.sqrt(n*s):n),basis:"bounded"}:n!==void 0?{distanceM:vs.atLeastNearest(n),basis:"bounded"}:s!==void 0&&s<vs.CONVENTIONAL_M?{distanceM:vs.atLeastNearest(s),basis:"bounded"}:{distanceM:vs.CONVENTIONAL_M,basis:"conventional"}}static atLeastNearest(t){return Math.max(vs.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)}}class Pt{static A=6378137;static E2=.00669437999014;static DEG=Math.PI/180;static STANDARD_DISTANCE_KM=100;static DEFAULT_COLOR="#ffb347";static DEFAULT_TRAIN_S=4;static DEFAULT_CRUMBLING={perS:1.2,lifeS:4,magnitudeDrop:3,dropBack:.3,spreadKmS:1,sinkKmS:.6,trainS:2.5};static DEFAULT_BURST={perS:12,lifeS:3.5,magnitudeDrop:3.5,dropBack:.5,spreadKmS:1.5,sinkKmS:.9,trainS:2};static FLARE_MAGNITUDES=.5;static shedsOf(t){return t.sheds?t.sheds:[Pt.DEFAULT_CRUMBLING,...Pt.flareBursts(t)]}static flareBursts(t){const e=t.lightCurve??[],i=[];for(let n=1;n<e.length-1;n++){const s=e[n];e[n-1].absoluteMagnitude-s.absoluteMagnitude<Pt.FLARE_MAGNITUDES||e[n+1].absoluteMagnitude-s.absoluteMagnitude<Pt.FLARE_MAGNITUDES||i.push({...Pt.DEFAULT_BURST,fromT:s.t-1e3,untilT:s.t+1500})}return i}static FADE_MS=1e3;static FADED_MAGNITUDE=8;static TRAIN_POINTS=8;static leadAt(t,e){const i=t.track;if(i.length<2||e<i[0].t||e>i[i.length-1].t)return;let n=0;for(;n<i.length-2&&i[n+1].t<e;)n++;const s=i[n],r=i[n+1],a=r.t-s.t,c=a>0?(e-s.t)/a:0,[l,h]=Pt.alongGreatCircle(s,r,c);return{lat:l,lng:h,heightM:(s.altitudeKm+(r.altitudeKm-s.altitudeKm)*c)*1e3}}static mayDazzle(t){const e=Math.max(1,Math.min(...t.track.map(n=>n.altitudeKm))),i=5*Math.log10(e/Pt.STANDARD_DISTANCE_KM);return t.fragments.some(n=>Math.min(n.absoluteMagnitude,...(n.lightCurve??[]).map(r=>r.absoluteMagnitude))+i<=Pt.DAZZLING_MAGNITUDE)}static detonationsOf(t,e){const i=[];for(const n of t)n.fragments.forEach((s,r)=>{const a=Pt.piecesOf(n).find(l=>l.id===(s.id??String(r)));if(!a)return;const c=(s.lightCurve??[]).filter((l,h,u)=>(h===0||u[h-1].absoluteMagnitude>=l.absoluteMagnitude)&&(h===u.length-1||u[h+1].absoluteMagnitude>l.absoluteMagnitude)).map(l=>({t:l.t,magnitude:l.absoluteMagnitude}));c.push({t:a.untilT,magnitude:a.magnitudeAt(a.untilT)});for(const l of c){if(l.magnitude>Pt.DETONATING_MAGNITUDE||l.t<a.fromT||l.t>a.untilT)continue;const h=Pt.pieceAt(n,a,l.t);if(!h||h.heightM>Pt.AUDIBLE_BELOW_KM*1e3||i.some(d=>d.flashT===l.t&&d.reentryId===n.id))continue;const u=Pt.seenFrom(e,h).distanceKm;i.push({reentryId:n.id,flashT:l.t,t:l.t+u/Pt.SOUND_KM_S*1e3,distanceKm:u,loudness:Math.min(1,(.3+(Pt.DETONATING_MAGNITUDE-l.magnitude)/15)*Math.min(1,30/u))})}});return i.sort((n,s)=>n.t-s.t)}static DETONATING_MAGNITUDE=-12;static AUDIBLE_BELOW_KM=50;static SOUND_KM_S=.31;static DAZZLING_MAGNITUDE=-11;static absoluteMagnitudeAt(t,e){const i=t.lightCurve;if(!i||i.length===0)return t.absoluteMagnitude;if(e<=i[0].t)return i[0].absoluteMagnitude;for(let n=1;n<i.length;n++){const s=i[n-1],r=i[n];if(e<=r.t)return s.absoluteMagnitude+(r.absoluteMagnitude-s.absoluteMagnitude)*(e-s.t)/Math.max(r.t-s.t,1)}return i[i.length-1].absoluteMagnitude}static viewsAt(t,e,i){const n=[];for(const s of t)for(const r of Pt.piecesOf(s)){if(e<r.fromT||e>r.untilT)continue;const a=Pt.pieceAt(s,r,e);if(!a)continue;const c=Pt.seenFrom(i,a);if(c.altitudeDeg<0)continue;const l=Math.min(Pt.FADE_MS,(r.untilT-r.fromT)/4),h=l>0?Math.min(1,(e-r.fromT)/l,(r.untilT-e)/l):1,u=r.magnitudeAt(e)+5*Math.log10(c.distanceKm/Pt.STANDARD_DISTANCE_KM),d=u+(1-h)*Math.max(0,Pt.FADED_MAGNITUDE-u),f=[c];for(let p=1;p<=Pt.TRAIN_POINTS;p++){const g=Math.min(r.trainMs*p/Pt.TRAIN_POINTS,e-r.fromT),m=Pt.pieceAt(s,r,e-g);if(!m||(f.push(Pt.seenFrom(i,m)),g>=e-r.fromT))break}n.push({reentryId:s.id,fragmentId:r.id,head:c,magnitude:d,fade:h,color:r.color,train:f})}return n}static piecesOf(t){const e=Pt.pieces.get(t);if(e)return e;const i=t.track[0]?.t??0,n=t.track[t.track.length-1]?.t??0,s=[];return t.fragments.forEach((r,a)=>{const c=(r.lagS??0)*1e3,l={id:r.id??String(a),fromT:r.fromT??i,untilT:r.untilT??n,lagMsAt:()=>c,acrossKmAt:()=>0,belowKmAt:()=>0,magnitudeAt:h=>Pt.absoluteMagnitudeAt(r,h),color:r.color??Pt.DEFAULT_COLOR,trainMs:(r.trainS??Pt.DEFAULT_TRAIN_S)*1e3};s.push(l),Pt.shedsOf(r).forEach((h,u)=>s.push(...Pt.shedPieces(l,h,u)))}),Pt.pieces.set(t,s),s}static pieces=new WeakMap;static shedPieces(t,e,i=0){const n=e.fromT??t.fromT,s=Math.min(e.untilT??t.untilT,t.untilT);if(!(e.perS>0)||s<=n)return[];const r=Math.floor((s-n)/1e3*e.perS),a=e.spreadKmS??.3,c=e.sinkKmS??.3,l=e.trainS!==void 0?e.trainS*1e3:t.trainMs*(2/3),h=[];for(let u=0;u<r;u++){const d=E=>Pt.hash(`${t.id}/${i}/${u}/${E}`),f=n+(u+d(1))/e.perS*1e3,p=e.lifeS*(.4+1.2*d(2))*1e3,g=e.magnitudeDrop*(.5-.5*Math.log(1-.999*d(3))),m=e.dropBack*(.5+d(4)),M=a*(2*d(5)-1),v=c*(.5+d(6)),x=t.lagMsAt(f),y=t.acrossKmAt(f),w=t.belowKmAt(f),b=E=>Math.max(0,E-f)/1e3;h.push({id:`${t.id}.${i}.${u}`,fromT:f,untilT:Math.min(f+p,Pt.endOf(t)),lagMsAt:E=>x+1e3*Pt.lagOfBraking(2*m,b(E)),acrossKmAt:E=>y+M*b(E),belowKmAt:E=>w+v*b(E),magnitudeAt:E=>t.magnitudeAt(Math.min(E,t.untilT))+g,color:t.color,trainMs:l})}return h}static lagOfBraking(t,e){return t<=0||e<=0?0:e-(1-Math.exp(-t*e))/t}static endOf(t){return t.untilT}static hash(t){let e=2166136261;for(let i=0;i<t.length;i++)e^=t.charCodeAt(i),e=Math.imul(e,16777619);return(e>>>0)/4294967296}static pieceAt(t,e,i){const n=i-e.lagMsAt(i),s=Pt.leadAt(t,n);if(!s)return;const r=e.acrossKmAt(i),a=s.heightM-e.belowKmAt(i)*1e3;if(r===0)return{...s,heightM:a};const c=Pt.leadAt(t,n-1e3)??s;return{...Pt.across(c,s,r),heightM:a}}static across(t,e,i){const n=Pt.DEG,s=t.lat*n,r=e.lat*n,a=(e.lng-t.lng)*n,c=Math.atan2(Math.sin(a)*Math.cos(r),Math.cos(s)*Math.sin(r)-Math.sin(s)*Math.cos(r)*Math.cos(a))+Math.PI/2,l=i/6371,h=Math.asin(Math.sin(r)*Math.cos(l)+Math.cos(r)*Math.sin(l)*Math.cos(c)),u=e.lng*n+Math.atan2(Math.sin(c)*Math.sin(l)*Math.cos(r),Math.cos(l)-Math.sin(r)*Math.sin(h));return{lat:h/n,lng:u/n}}static seenFrom(t,e){const i=Pt.ecef(t),n=Pt.ecef(e),s=n[0]-i[0],r=n[1]-i[1],a=n[2]-i[2],c=t.lat*Pt.DEG,l=t.lng*Pt.DEG,h=-Math.sin(l)*s+Math.cos(l)*r,u=-Math.sin(c)*Math.cos(l)*s-Math.sin(c)*Math.sin(l)*r+Math.cos(c)*a,d=Math.cos(c)*Math.cos(l)*s+Math.cos(c)*Math.sin(l)*r+Math.sin(c)*a,f=Math.hypot(h,u,d);return{altitudeDeg:Math.asin(d/f)/Pt.DEG,azimuthDeg:(Math.atan2(h,u)/Pt.DEG+360)%360,distanceKm:f/1e3}}static ecef(t){const e=t.lat*Pt.DEG,i=t.lng*Pt.DEG,n=Math.sin(e),s=Pt.A/Math.sqrt(1-Pt.E2*n*n);return[(s+t.heightM)*Math.cos(e)*Math.cos(i),(s+t.heightM)*Math.cos(e)*Math.sin(i),(s*(1-Pt.E2)+t.heightM)*n]}static alongGreatCircle(t,e,i){const n=h=>{const u=h.lat*Pt.DEG,d=h.lng*Pt.DEG;return[Math.cos(u)*Math.cos(d),Math.cos(u)*Math.sin(d),Math.sin(u)]},s=n(t),r=n(e),a=Math.max(-1,Math.min(1,s[0]*r[0]+s[1]*r[1]+s[2]*r[2])),c=Math.acos(a);let l;if(c<1e-12)l=s;else{const h=Math.sin((1-i)*c)/Math.sin(c),u=Math.sin(i*c)/Math.sin(c);l=[s[0]*h+r[0]*u,s[1]*h+r[1]*u,s[2]*h+r[2]*u]}return[Math.atan2(l[2],Math.hypot(l[0],l[1]))/Pt.DEG,Math.atan2(l[1],l[0])/Pt.DEG]}}class Mh{static typed=new Map;static of(t){return Mh.typed.get(t)}static set(t,e){const i=e.trim();i===""?Mh.typed.delete(t):Mh.typed.set(t,i)}static forget(){Mh.typed.clear()}}class oy{static FIRST_DAY="2022-01-01";static mayCover(t){return new Date(t).toISOString().slice(0,10)>=oy.FIRST_DAY}}class ab{constructor(t,e,i){this.citation=t,this.covers=e,this.load=i}loading;mayCover(t){return this.covers(t)}async between(t,e,i,n){try{return await(await this.provider()).between(t,e,i,n)}catch{return{status:"failed"}}}async describe(t,e){try{return await(await this.provider()).describe?.(t,e)}catch{return}}provider(){if(!this.loading){const t=this.load();this.loading=t,t.catch(()=>{this.loading===t&&(this.loading=void 0)})}return this.loading}}const HL="Aircraft positions: adsb.lol feeders and contributors, Open Database License 1.0 (https://www.adsb.lol/docs/open-data/historical/)",GL="Aircraft positions: Flightradar24 API (https://fr24api.flightradar24.com/)",ob="flightradar24",VL=Te.point("aircraft").provide(Te.BUILT_IN,[{id:"adsb-lol",name:"adsb.lol",credit:"adsb.lol feeders and contributors, ODbL 1.0",creditUrl:"https://www.adsb.lol/docs/open-data/historical/",create:()=>new ab(HL,o=>oy.mayCover(o),async()=>new(await dt(async()=>{const{AdsbLolArchiveProvider:o}=await import("./AdsbLolArchiveProvider-BtF4baVw.js");return{AdsbLolArchiveProvider:o}},[],import.meta.url)).AdsbLolArchiveProvider)},{id:ob,name:"Flightradar24",credit:"Flightradar24, on your own subscription",creditUrl:"https://fr24api.flightradar24.com/",keyUrl:"https://fr24api.flightradar24.com/key-management",create:()=>new ab(GL,o=>o>=Date.UTC(2016,4,11)&&o<=Date.now(),async()=>new(await dt(async()=>{const{Flightradar24Provider:o}=await import("./Flightradar24Provider-BBj_wixV.js");return{Flightradar24Provider:o}},[],import.meta.url)).Flightradar24Provider({token:()=>Mh.of(ob)}))}]);class kn{static MAX_GAP_S=60;static FT_TO_M=.3048;static EARTH_RADIUS_KM=6371;static seenFrom(t,e,i){const n=kn.positionAt(t,i);if(!n)return;const s=Pt.seenFrom(e,n.geo);if(!(s.altitudeDeg<0))return{track:t,sky:s,altitudeFt:n.altitudeFt,groundSpeedKt:n.groundSpeedKt,trackDeg:n.trackDeg,angularRateDegPerS:kn.angularRate(t,e,i)}}static viewsAt(t,e,i){return t.flatMap(n=>kn.seenFrom(n,e,i)??[])}static groundDistanceKm(t,e){const i=Math.PI/180,n=Math.sin((e.lat-t.lat)*i/2)**2+Math.cos(t.lat*i)*Math.cos(e.lat*i)*Math.sin((e.lng-t.lng)*i/2)**2;return 2*kn.EARTH_RADIUS_KM*Math.asin(Math.min(1,Math.sqrt(n)))}static wrapLongitude(t){return((t+180)%360+360)%360-180}static positionAt(t,e){const i=t.points;if(i.length===0||e<i[0].t||e>i[i.length-1].t)return;let n=0;for(;n<i.length-1&&i[n+1].t<=e;)n++;const s=i[n],r=i[n+1]??s,a=r.t-s.t;if(a>kn.MAX_GAP_S*1e3)return;const c=a>0?(e-s.t)/a:0,l=s.altitudeFt+(r.altitudeFt-s.altitudeFt)*c,h=(r.lng-s.lng+540)%360-180;return{geo:{lat:s.lat+(r.lat-s.lat)*c,lng:kn.wrapLongitude(s.lng+h*c),heightM:l*kn.FT_TO_M},altitudeFt:l,groundSpeedKt:s.groundSpeedKt,trackDeg:s.trackDeg}}static angularRate(t,e,i){const n=kn.positionAt(t,i-500),s=kn.positionAt(t,i+500);if(!n||!s)return;const r=kn.unit(Pt.seenFrom(e,n.geo)),a=kn.unit(Pt.seenFrom(e,s.geo)),c=Math.min(1,Math.max(-1,r[0]*a[0]+r[1]*a[1]+r[2]*a[2]));return Math.acos(c)*180/Math.PI}static unit(t){const e=t.altitudeDeg*Math.PI/180,i=t.azimuthDeg*Math.PI/180;return[Math.cos(e)*Math.sin(i),Math.cos(e)*Math.cos(i),Math.sin(e)]}}class Nn{constructor(t){this.boxes=t;for(const i of t){const n=Math.hypot(i.halfWidthM,i.halfLengthM),[s,r]=[Nn.cell(i.eastM-n),Nn.cell(i.eastM+n)],[a,c]=[Nn.cell(i.northM-n),Nn.cell(i.northM+n)];for(let l=s;l<=r;l++)for(let h=a;h<=c;h++){const u=Nn.key(l,h),d=this.cells.get(u);d?d.push(i):this.cells.set(u,[i])}}let e=2166136261;for(const i of t)for(const n of[i.eastM,i.northM,i.cos,i.halfWidthM,i.halfLengthM,i.topM])e=Math.imul(e^Math.round(n*10),16777619);this.signature=t.length===0?"":`${t.length}:${(e>>>0).toString(36)}`}static NONE=new Nn([]);static SOLID=new Set(["building","tree","wall","mound","terrace","shrub"]);static CELL_M=16;static last;signature;cells=new Map;static of(t,e){const i=[];for(const s of t){if(!Nn.SOLID.has(s.kind)||(s.track?.length??0)>0)continue;const r=e(s);if(!(r.heightM>0)||!(r.widthM>0)||!(r.lengthM>0))continue;const a=(s.headingDeg??0)*Math.PI/180;i.push({eastM:s.eastM,northM:s.northM,cos:Math.cos(a),sin:Math.sin(a),halfWidthM:r.widthM/2,halfLengthM:r.lengthM/2,topM:r.heightM})}const n=new Nn(i);return Nn.last?.signature===n.signature?Nn.last.obstacles:(Nn.last={signature:n.signature,obstacles:n},n)}get empty(){return this.boxes.length===0}inside(t,e,i,n=0){const s=this.cells.get(Nn.key(Nn.cell(t),Nn.cell(e)));if(s)for(const r of s){if(i>r.topM+n)continue;const a=t-r.eastM,c=e-r.northM,l=a*r.sin+c*r.cos,h=a*r.cos-c*r.sin,u=r.halfLengthM+n-Math.abs(l),d=r.halfWidthM+n-Math.abs(h);if(u<=0||d<=0)continue;const f=r.topM+n-i;if(u<d){const g=Math.sign(l)||1;return{box:r,nx:r.sin*g,ny:r.cos*g,depthM:u,belowTopM:f}}const p=Math.sign(h)||1;return{box:r,nx:r.cos*p,ny:-r.sin*p,depthM:d,belowTopM:f}}}static cell(t){return Math.floor(t/Nn.CELL_M)}static key(t,e){return(t+32768)*65536+(e+32768)}}const cb="https://ufoathome.org/fireballs/index.json";class ca{static FIRST_MONTH="2018-12";static STRIKING_MAGNITUDE=-1;static COLOR="#eef2ff";static TRAIN_S=.3;fetchImpl;indexUrls;index;months=new Map;constructor(t={}){this.fetchImpl=t.fetchImpl??fetch.bind(globalThis),this.indexUrls=t.indexUrls??ca.defaultIndexUrls()}static defaultIndexUrls(){const t=[];return typeof location<"u"&&/^https?:$/.test(location.protocol)&&t.push(new URL("/fireballs/index.json",location.href).href),t.includes(cb)||t.push(cb),t}static mayCover(t){return new Date(t).toISOString().slice(0,7)>=ca.FIRST_MONTH}async credit(){return(await this.loadIndex())?.index.credit}async between(t,e){if(!ca.mayCover(e))return;const i=await this.loadIndex();if(!i)return;const n=new Set([new Date(t).toISOString().slice(0,7),new Date(e).toISOString().slice(0,7)]);return[...n].some(r=>r>=i.index.from&&r<=i.index.to)?(await Promise.all([...n].filter(r=>i.index.months.includes(r)).map(r=>this.monthOf(r,i.base)))).flat().filter(r=>r.t>=t&&r.t<=e):void 0}static seenFrom(t,e){const i=ca.peakFraction(t),n={lat:t.from[0]+(t.to[0]-t.from[0])*i,lng:t.from[1]+(t.to[1]-t.from[1])*i,heightM:t.peakHeightKm*1e3},s=Pt.seenFrom(e,n);if(!(s.altitudeDeg<0))return{record:t,peak:s,magnitude:t.peakMagnitude+5*Math.log10(s.distanceKm/Pt.STANDARD_DISTANCE_KM)}}static asReentry(t,e){const i=t.t-e,n=i+Math.max(t.durationS,.1)*1e3;return{id:`gmn-${t.id}`,track:[{t:i,lat:t.from[0],lng:t.from[1],altitudeKm:t.from[2]},{t:n,lat:t.to[0],lng:t.to[1],altitudeKm:t.to[2]}],fragments:[{absoluteMagnitude:t.peakMagnitude,color:ca.COLOR,trainS:ca.TRAIN_S}]}}static peakFraction(t){const e=t.from[2]-t.to[2];return Math.abs(e)<1e-6?.5:Math.min(1,Math.max(0,(t.from[2]-t.peakHeightKm)/e))}loadIndex(){return this.index??=(async()=>{for(const t of this.indexUrls)try{const e=await this.fetchImpl(t);if(e.ok)return{index:await e.json(),base:t}}catch{}})(),this.index}monthOf(t,e){let i=this.months.get(t);return i||(i=this.fetchImpl(new URL(`${t}.json`,e).href).then(n=>n.ok?n.json():[]).catch(()=>[]),this.months.set(t,i)),i}}class Ii{static built=new WeakMap;static computers=new WeakMap;static loading=new WeakMap;static loaded(t,e){return e.every(i=>Ii.itemsOf(t,i.key).length===0||Ii.computers.has(i))}static load(t,e){return Promise.all(e.filter(i=>Ii.itemsOf(t,i.key).length>0&&!Ii.computers.has(i)).map(i=>{let n=Ii.loading.get(i);return n||(n=i.compute().then(s=>{Ii.computers.set(i,s)}),n.catch(()=>Ii.loading.delete(i)),Ii.loading.set(i,n)),n.catch(()=>{})})).then(()=>{})}static of(t){let e=Ii.built.get(t);return e||(e=t.create(),Ii.built.set(t,e)),e}static itemsOf(t,e){const i=t?.[e];return Array.isArray(i)?i:[]}static computes(t,e){return e.some(i=>Ii.itemsOf(t,i.key).length>0)}static expand(t,e,i){return Ii.expandWithKinds(t,e,i).interpretation}static expandWithKinds(t,e,i){const n=new Map,s=new Map;if(!t||!Ii.computes(t,e))return{interpretation:t,kindOf:n,phenomenonOf:s};const r=e.flatMap(a=>Ii.itemsOf(t,a.key).flatMap(c=>{const l=Ii.computers.get(a);if(!l)return[];const h=l(c,i),u=a.phenomenon?.(c);for(const d of h)n.set(d.id,a),u&&s.set(d.id,u);return h}));return{interpretation:{...t,bodies:[...t.bodies,...r]},kindOf:n,phenomenonOf:s}}static computedPart(t,e){const i={};for(const n of e){const s=Ii.itemsOf(t,n.key);s.length>0&&(i[n.key]=[...s])}return i}static saysNothing(t,e){return t.bodies.length===0&&t.title===void 0&&t.smoke===void 0&&e.every(i=>t[i.key]===void 0)}}const WL=Gs.catalog({en:()=>dt(()=>import("./FlareKindMessages_en-j3CY_TxX.js"),[],import.meta.url).then(o=>o.flareKindMessages_en),fr:()=>dt(()=>import("./FlareKindMessages_fr-B2MezoN2.js"),[],import.meta.url).then(o=>o.flareKindMessages_fr),es:()=>dt(()=>import("./FlareKindMessages_es-CZgrFIOO.js"),[],import.meta.url).then(o=>o.flareKindMessages_es),it:()=>dt(()=>import("./FlareKindMessages_it-CmZmb3RP.js"),[],import.meta.url).then(o=>o.flareKindMessages_it)}),lb={key:"flares",messages:WL,phenomenon:()=>"DecoyFlare",compute:()=>dt(async()=>{const{DecoyFlare:o}=await import("./DecoyFlare-DUt1_LcW.js");return{DecoyFlare:o}},[],import.meta.url).then(({DecoyFlare:o})=>t=>o.bodiesOf(t))},XL=Gs.catalog({en:()=>dt(()=>import("./LanternKindMessages_en-CQXdJ-k6.js"),[],import.meta.url).then(o=>o.lanternKindMessages_en),fr:()=>dt(()=>import("./LanternKindMessages_fr-D7tQa_tQ.js"),[],import.meta.url).then(o=>o.lanternKindMessages_fr),es:()=>dt(()=>import("./LanternKindMessages_es-BOO6kPjs.js"),[],import.meta.url).then(o=>o.lanternKindMessages_es),it:()=>dt(()=>import("./LanternKindMessages_it-B8J-29Mj.js"),[],import.meta.url).then(o=>o.lanternKindMessages_it)}),hb={key:"lanterns",messages:XL,phenomenon:()=>"SkyLantern",compute:()=>dt(async()=>{const{SkyLantern:o}=await import("./SkyLantern-BKxwl7Po.js");return{SkyLantern:o}},[],import.meta.url).then(({SkyLantern:o})=>(t,e)=>o.bodiesOf(t,e?.obstacles)),editor:()=>dt(async()=>{const{LanternEditor:o}=await import("./LanternEditor-iByq1q3j.js");return{LanternEditor:o}},__vite__mapDeps([11,3,12]),import.meta.url).then(({LanternEditor:o})=>(t,e,i)=>new o(t,e,i))},YL=Gs.catalog({en:()=>dt(()=>import("./BirdKindMessages_en-c_-L7frF.js"),[],import.meta.url).then(o=>o.birdKindMessages_en),fr:()=>dt(()=>import("./BirdKindMessages_fr-C1TuqqEj.js"),[],import.meta.url).then(o=>o.birdKindMessages_fr),es:()=>dt(()=>import("./BirdKindMessages_es-8Zo2t0o4.js"),[],import.meta.url).then(o=>o.birdKindMessages_es),it:()=>dt(()=>import("./BirdKindMessages_it-DQZcrCkf.js"),[],import.meta.url).then(o=>o.birdKindMessages_it)}),ub={key:"birds",messages:YL,phenomenon:()=>"Birds",compute:()=>dt(async()=>{const{BirdFlock:o}=await import("./BirdFlock-B2SbkMme.js").then(t=>t.b);return{BirdFlock:o}},[],import.meta.url).then(({BirdFlock:o})=>(t,e)=>o.bodiesOf(t,e?.obstacles)),editor:()=>dt(async()=>{const{BirdEditor:o}=await import("./BirdEditor-CKpe681e.js");return{BirdEditor:o}},__vite__mapDeps([13,3,14,4]),import.meta.url).then(({BirdEditor:o})=>(t,e,i)=>new o(t,e,i))},KL=Gs.catalog({en:()=>dt(()=>import("./DroneKindMessages_en-CLygXcsv.js"),[],import.meta.url).then(o=>o.droneKindMessages_en),fr:()=>dt(()=>import("./DroneKindMessages_fr-CAX15_pk.js"),[],import.meta.url).then(o=>o.droneKindMessages_fr),es:()=>dt(()=>import("./DroneKindMessages_es-B9XFRYnQ.js"),[],import.meta.url).then(o=>o.droneKindMessages_es),it:()=>dt(()=>import("./DroneKindMessages_it-CSGsCaJQ.js"),[],import.meta.url).then(o=>o.droneKindMessages_it)}),db={quadcopter:"ConsumerDrone",saucer:"ConsumerDrone","fixed-wing":"MilitaryDrone"},fb={key:"drones",messages:KL,phenomenon:o=>db[o.airframe]??db.quadcopter,compute:()=>dt(async()=>{const{DroneFlight:o}=await import("./DroneFlight-BTFHGVWd.js").then(t=>t.c);return{DroneFlight:o}},[],import.meta.url).then(({DroneFlight:o})=>t=>o.bodiesOf(t)),editor:()=>dt(async()=>{const{DroneEditor:o}=await import("./DroneEditor-BDDLiZPp.js");return{DroneEditor:o}},__vite__mapDeps([15,3,16,4]),import.meta.url).then(({DroneEditor:o})=>(t,e,i)=>new o(t,e,i))},$L=Te.point("interpretations").provide(Te.BUILT_IN,[{id:lb.key,name:"Decoy flares",credit:"UFO@home",creditUrl:"https://ufoathome.org/docs/format/",create:()=>lb},{id:hb.key,name:"Sky lanterns",credit:"UFO@home",creditUrl:"https://ufoathome.org/docs/format/",create:()=>hb},{id:ub.key,name:"Birds",credit:"UFO@home",creditUrl:"https://ufoathome.org/docs/format/",create:()=>ub},{id:fb.key,name:"Drones",credit:"UFO@home",creditUrl:"https://ufoathome.org/docs/format/",create:()=>fb}]);class o1{static kinds(){return $L.map(t=>Ii.of(t))}}Jb();const qL="satellites-change",ZL="fireballs-change",JL="references-change",jL="aircraft-change",QL="rr0-confrontation",pb="comet:",mb="nova:",t7=new URL(""+new URL("lunar-relief.bin-ByThqxUn.gz",import.meta.url).href,import.meta.url).href,e7=new URL(""+new URL("stars-mag7.5-B43R6Wvg.bin",import.meta.url).href,import.meta.url).href,i7=new URL(""+new URL("stars-mag7.5-9-BLV2tFmZ.bin",import.meta.url).href,import.meta.url).href,n7=-18,s7={sun:{altitudeDeg:-3,azimuthDeg:180,magnitude:-26.7},moon:{altitudeDeg:-90,azimuthDeg:0,phase:{phaseFraction:0,illuminatedFraction:0},magnitude:-12.7},planets:[]},R0={lat:0,lng:0,elevationM:0,headingDeg:void 0,pitchDeg:0,fovDeg:60};class ve 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",bh,Eh,Oc]}shadow;stageElement;frameElement;sceneCanvas;busyElement;busyNote;loaderNote;loaderNotVideo;ufoElement;sceneRenderer;hoverTooltip;ghostPath;flightMark;markedFlight;holding=!1;resizeObserver;sizeEstimates=new Map;sizeEstimatesFor;approaches={key:"",of:new Map};distanceHypotheses=new Map;depths=new Map;directionScratch=new _;meteorScheduleFor;lightningScheduleFor;lightningFlashes=[];lastLightningT;lastTimeMs=0;interpretationShown;confrontationReadings=[];confrontationTolerance;confrontationSignature="";comparing=!1;inTheRound=!0;lastSkyKey;starCatalog;starCatalogRequest=0;static tleArchive=new ts;satellitesFor;satelliteRequest=0;satelliteStatus="none";satellites;satellitePassesMemo;static fireballArchive=new ca;fireballs;static aircraftProviders=new Map;static SOUND_LOOKBACK_MS=3e5;static TRAIL_LOOKBACK_MS=36e5;static TRAIL_MAX_AIRCRAFT=60;static NO_CONTRAILS=[];static upperAirProviders=new Map;static NO_PRESENCE=new Map;aircraftSource=VL[0];static trafficRuntimeLoading;static trafficRuntime;static loadTrafficRuntime(){return ve.trafficRuntimeLoading??=dt(()=>import("./trafficRuntime-CL5yz3t-.js"),__vite__mapDeps([17,10]),import.meta.url).then(t=>ve.trafficRuntime=t),ve.trafficRuntimeLoading.catch(()=>{ve.trafficRuntimeLoading=void 0}),ve.trafficRuntimeLoading}traffic;lastSun;get sunAltitudeDeg(){return this.sceneRenderer.sunAltitudeDeg??this.lastSun?.altitudeDeg}decorMemo;seatedMemo;starCatalogDepth=0;weatherAudio=new Gc;vehicleAudio=new xy;aircraftAudio;vehicleHearing=new $0;decorAircraftHearing;bodyHearing;decorModelSounds=new Map;decorModelsAsked=new Set;thunderTimeoutId;handleFullscreenChange=()=>{this.resizeToStage(),this.hoverTooltip.hidden=!0;for(const t of[this.hoverTooltip,this.shadow.getElementById("credits-panel")])t&&typeof t.hidePopover=="function"&&t.matches(":popover-open")&&t.hidePopover();this.tooltipOver=document.fullscreenElement};handlePointerMove=t=>{if(this.lastHover={clientX:t.clientX,clientY:t.clientY,altKey:t.altKey},this.ghostMissedSinceMs=void 0,this.hoverFrame!==void 0&&t.altKey===this.hoverAlt){this.hoverPending=!0;return}this.hoverAlt=t.altKey,this.hoverAt(this.lastHover),this.hoverFrame===void 0&&(this.hoverFrame=requestAnimationFrame(()=>{this.hoverFrame=void 0,this.hoverPending&&this.lastHover&&this.hoverAt(this.lastHover),this.hoverPending=!1}))};ghostMissedSinceMs;static GHOST_KEPT_MS=600;ghostStillUnder(t,e){const i=this.ufoElement.canvasElement.getBoundingClientRect();if(i.width===0||i.height===0)return!0;const n=(t.clientX-i.left)/i.width*2-1,s=1-(t.clientY-i.top)/i.height*2;return this.sceneRenderer.ghostsReadableAt(n,s)?this.sceneRenderer.pickGhostAt(n,s)?(this.ghostMissedSinceMs=void 0,!0):(this.ghostMissedSinceMs??=e,e-this.ghostMissedSinceMs>ve.GHOST_KEPT_MS):!1}hoverFrame;hoverPending=!1;hoverAlt=!1;lastPlayingHoverMs=0;static PLAYING_HOVER_MS=150;lastHover;tooltipOver=null;hoverAt(t){if(this.showCompassFor({hovered:!0}),this.holding){this.hoverTooltip.hidden=!0;return}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 r=(t.clientX-i.left)/i.width*2-1,a=-((t.clientY-i.top)/i.height*2-1);if(!this.ghostPath.hasAttribute("hidden")&&!this.sceneRenderer.ghostsReadableAt(r,a))return;const c=this.pickAt(r,a,!0,t.altKey);c?this.showHoverTooltip(t,t.altKey&&c.detail?c.detail():c.name):this.hoverTooltip.hidden=!0,this.showGhostPath(c?.path,i)}showGhostPath(t,e){if(!t){this.ghostPath.toggleAttribute("hidden",!0);return}const i=this.stageElement.getBoundingClientRect(),n=d=>({x:e.left-i.left+(d.x+1)/2*e.width,y:e.top-i.top+(1-d.y)/2*e.height}),s=n(t.from),r=n(t.to),a=n({x:0,y:0});this.ghostPath.setAttribute("viewBox",`0 0 ${i.width} ${i.height}`);const[c,l,h,u]=Array.from(this.ghostPath.children);for(const d of[c,l])d.setAttribute("x1",String(s.x)),d.setAttribute("y1",String(s.y)),d.setAttribute("x2",String(r.x)),d.setAttribute("y2",String(r.y));h.setAttribute("cx",String(a.x)),h.setAttribute("cy",String(a.y)),u.setAttribute("cx",String(r.x)),u.setAttribute("cy",String(r.y)),this.ghostPath.toggleAttribute("hidden",!1)}pickAt(t,e,i=!0,n=!1){const s=this.naming,r=s.names;if(n&&this.sceneRenderer.pickDropAt(t,e)){const b=r.ghostTooltip,E=b.drop[this.ufoElement.sighting.lens?.glass??"lens"];return{kind:"drop",name:E,detail:()=>b.dropDetail.replace("{name}",E)}}const a=this.sceneRenderer.pickBodyAt(t,e);if(a)return{kind:"sky",id:a,name:this.bodyName(a)};const c=this.interpretationShown?this.sceneRenderer.pickInterpretationBodyAt(t,e):void 0,l=c?this.interpretationShown?.bodies.find(b=>b.id===c):void 0,h=l?this.said.read(l.title)||this.explainedName(l.explains)||this.kindName(l):void 0;if(c!==void 0&&h)return{kind:"body",id:c,name:h};const u=this.skyEventPickAt(t,e,(b,E)=>!E.inSky);if(u)return u;const d=i?this.ghostPick(t,e):void 0;if(d)return d;if(this.sceneRenderer.pickAfterimageAt(t,e)){const b=this.naming.names.afterimageTooltip;return{kind:"afterimage",name:b.name,detail:()=>b.detail.replace("{name}",b.name)}}const f=this.pickDecorAt(t,e)??this.sceneRenderer.pickPeakAt(t,e),p=f?this.ufoElement.sighting.decor.find(b=>b.id===f):void 0;if(p){const b=this.said.read(p.title)||s.decorKind(p.kind);return{kind:"decor",id:p.id,name:b,detail:()=>this.decorTooltip(p,b)}}const g=this.sceneRenderer.pickRailwayAt(t,e);if(g){const b=r.railwayTooltip;return{kind:"railway",id:g.line.id,name:jr.name(g.line,b),detail:()=>jr.detail(g,b,E=>this.distanceText(E))}}const m=this.trafficTooltipAt(t,e);if(m)return{kind:"traffic",name:m};const M=this.skyEventPickAt(t,e,(b,E)=>E.inSky===!0&&!b.pickedAfterSatellites);if(M)return M;const v=this.sceneRenderer.pickSatelliteAt(t,e);if(v)return{kind:"satellite",name:r.satelliteTooltip.replace("{name}",v.name).replace("{mag}",v.magnitude.toLocaleString(void 0,{maximumFractionDigits:1})).replace("{height}",Math.round(v.heightKm).toLocaleString())};const x=this.skyEventPickAt(t,e,(b,E)=>E.inSky===!0&&b.pickedAfterSatellites===!0);if(x)return x;const y=this.sceneRenderer.pickOpticsAt(t,e);if(y){const b=r.opticsTooltips[y.id].replace("{angle}",String(Math.round(y.angleDeg??0)));return{kind:"optics",id:y.id,name:b.split(" — ")[0],detail:()=>b}}const w=this.sceneRenderer.pickStarAt(t,e);if(w){const b=w.star.mag,E=w.altitudeDeg,S=E<0?r.starTooltipBelow:r.starTooltip,A=s.star(w.star);return{kind:"star",name:A,detail:()=>S.replace("{name}",A).replace("{mag}",b.toLocaleString(void 0,{maximumFractionDigits:Math.abs(b)<1?2:1})).replace("{alt}",String(Math.round(Math.abs(E))))}}}ghostLights=new Map;static GHOST_LIGHT_KEPT_MS=1e3;lightOfGhost(t,e){const i=this.ufoElement.canvasElement,n={x:8/Math.max(1,i.clientWidth),y:8/Math.max(1,i.clientHeight)},s=`${Math.round(t/n.x)}:${Math.round(e/n.y)}`,r=performance.now(),a=this.ghostLights.get(s);if(a&&r-a.atMs<ve.GHOST_LIGHT_KEPT_MS)return a.light;let c=this.shiningDecorNear(t,e,2*Math.max(n.x,n.y)),l;if(!c)for(const[h,u]of[[0,0],[1,0],[-1,0],[0,1],[0,-1],[1,1],[-1,1],[1,-1],[-1,-1]]){const d=this.pickAt(t+h*n.x,e+u*n.y,!1);if(d?.kind==="star")l??=d;else if(d){c=d;break}}return c??=this.shiningDecorNear(t,e,6*Math.max(n.x,n.y)),c??=l,this.ghostLights.size>256&&this.ghostLights.clear(),this.ghostLights.set(s,{light:c??null,atMs:r}),c??null}ghostPick(t,e){const i=this.sceneRenderer.pickGhostAt(t,e);if(!i)return;const n=this.naming.names.ghostTooltip,s=i.beyond?{kind:"sky",id:"sun",name:this.bodyName("sun")}:this.lightOfGhost(i.source.x,i.source.y)??void 0,r=(s?.kind==="star"?s.name.split(" — ")[0]:s?.name)??n.unnamed,a=i.ghost,l=(Ze.scatters(a)?n.halo:a.cause==="glass"?n.double:n.ghost).replace("{name}",r),h=a.scale<0?n.opposite:a.scale===1?n.around:n.sameSide;return{kind:"ghost",id:s?.id,name:l,detail:()=>n.detail.replace("{name}",l).replace("{cause}",n.causes[a.cause??"lens"]).replace("{where}",h),path:{from:{x:2*(a.offset?.[0]??0)+a.scale*i.source.x,y:2*(a.offset?.[1]??0)+a.scale*i.source.y},to:i.source}}}shiningDecorNear(t,e,i){let n;for(const s of this.ufoElement.sighting.decor){if(!(s.kind==="streetlight"||s.kind==="trafficlight"||(s.lights?.length??0)>0||s.kind==="vehicle"&&s.lit))continue;const a=this.sceneRenderer.decorScreenBox(s.id);if(!a)continue;const c=Math.hypot(Math.max(a.minX-t,0,t-a.maxX),Math.max(a.minY-e,0,e-a.maxY));if(c>i||n&&c>=n.distance)continue;const l=this.said.read(s.title)||this.naming.decorKind(s.kind);n={distance:c,pick:{kind:"decor",id:s.id,name:l}}}return n?.pick}glassWettingOf(t){const e=JSON.stringify([t.lens,t.instrumentId,t.weatherTrack.allKeyframes.map(i=>[i.t,i.weather.precipitationType,i.weather.precipitationIntensity,i.weather.windDirectionDeg,i.weather.windSpeed])]);if(this.glassWetting?.sighting!==t||this.glassWetting.key!==e){const i=new Uc(n=>{if(!Ze.records(t.instrument)||!Ze.falling(t.lens))return 0;const s=iu(t,n*1e3),r=ke(t,n*1e3);return(s.precipitationAmount??1)*Ze.impactRate(s,t.lens?.glass,r&&{headingDeg:r.headingDeg??0,pitchDeg:r.pitchDeg,windFromDeg:s.windDirectionDeg,windSpeedMS:s.windSpeed})});this.glassWetting={sighting:t,key:e,wetting:i}}return this.glassWetting.wetting}glassWetting;get skyEventsShown(){return this.skyEventsOf(this.ufoElement.sighting)}skyEventsStartDate;skyEventsMerged;skyEventsOf(t){const e=t.skyEvents,i=this.fireballs?.reentries,n=this.skyEventsMerged;if(n&&n.stated===e&&n.fireballs===i)return n.shown;const s=i?.length?{...e,reentries:[...e?.reentries??[],...i]}:e;return this.skyEventsMerged={stated:e,fireballs:i,shown:s},s}skyEventTexts=new Map;skyEventTextsLanguage;loadSkyEventTexts(t){const e=I0(Lo.preferencesFor(this),C0);e!==this.skyEventTextsLanguage&&(this.skyEventTexts.clear(),this.skyEventTextsLanguage=e);for(const i of t)this.skyEventTexts.has(i)||i.messages.load(e).then(n=>{this.skyEventTextsLanguage===e&&this.skyEventTexts.set(i,n)},()=>{})}skyEventPickAt(t,e,i){const n=this.skyEventsShown;if(!n)return;const s=this.sceneRenderer.pickSkyEventAt(t,e,i),r=s?NM.map(d=>to.of(d)).find(d=>d.key===s.kind):void 0,a=s&&r?to.eventsOf(n,r).find(d=>d.id===s.id):void 0;if(!s||!r||!a)return;const c=this.skyEventTexts.get(r);if(!c){this.loadSkyEventTexts([r]);return}const l=this.said.read(a.title)||c.name,h=r.describe?.(a,s,{said:this.said,texts:c,name:l,distance:d=>this.distanceText(d)}),u=h?.detail??(s.distanceM!==void 0?`${l}, ${this.distanceText(s.distanceM)}`:void 0);return{kind:r.pickKind??"skyEvent",id:a.id,name:h?.name??l,...u!==void 0?{detail:()=>u}:{}}}distanceText(t){return t>=1e3?`${(t/1e3).toLocaleString(void 0,{maximumFractionDigits:1})} km`:`${t.toLocaleString(void 0,{maximumFractionDigits:t<10?1:0})} m`}decorTooltip(t,e){const i=h=>h.toLocaleString(void 0,{maximumFractionDigits:h<10?1:0}),n=ut.sizeOf(t),s=this.sceneRenderer.decorDistanceM(t.id),r=s===void 0?"":this.distanceText(s),c=this.naming.names.decorTooltip.replace("{name}",e).replace("{size}",`${i(n.widthM)} × ${i(n.lengthM)} × ${i(n.heightM)} m`),l=this.said.read(t.note);return l?`${c.replace("{distance}",r)}. ${l}`:c.replace("{distance}",r)}computedKinds=new Map;computedKindTexts=new Map;bodyModelKinds=new Map;showInterpretation(t){const e=o1.kinds(),i=this.obstaclesOf(this.ufoElement.sighting.decor);this.interpretationObstacles=i;const{interpretation:n,kindOf:s}=Ii.expandWithKinds(t,e,{obstacles:i});if(this.interpretationAsked=t,this.interpretationShown=n,this.computedKinds=s,this.loadComputedKindTexts(),Ii.loaded(t,e))return;const r=Ii.load(t,e);this.sceneRenderer.holdUntil(r),r.then(()=>{this.interpretationAsked!==t||!Ii.loaded(t,e)||(this.showInterpretation(t),this.ufoElement.refreshSoundControls(),this.updateAstronomy(this.lastTimeMs),this.ufoElement.repaintChrome())})}interpretationAsked;interpretationObstacles=Nn.NONE;obstaclesMadeOf;obstaclesOf(t){return this.obstaclesMadeOf?.decor!==t&&(this.obstaclesMadeOf={decor:t,obstacles:Nn.of(t,e=>ut.sizeOf(e))}),this.obstaclesMadeOf.obstacles}recomputeAmongNewDecor(){const t=this.interpretationAsked;!t||!Ii.computes(t,o1.kinds())||this.obstaclesOf(this.ufoElement.sighting.decor).signature!==this.interpretationObstacles.signature&&(this.showInterpretation(t),this.ufoElement.refreshSoundControls())}computedInterpretation(t){const e=o1.kinds(),i=Ii.loaded(t,e)?Promise.resolve():Ii.load(t,e),{interpretation:n,phenomenonOf:s}=Ii.expandWithKinds(t,e,{obstacles:this.obstaclesOf(this.ufoElement.sighting.decor)});return{interpretation:n??t,phenomenonOf:s,loaded:i}}loadComputedKindTexts(){const t=this.namesLanguage;if(t)for(const e of new Set(this.computedKinds.values()))this.computedKindTexts.has(e)||e.messages.load(t).then(i=>{t===this.namesLanguage&&this.computedKindTexts.set(e,i)}).catch(()=>{})}kindName(t){const e=this.computedKinds.get(t.id),i=e?this.computedKindTexts.get(e):void 0;if(i?.name)return i.name;const n=t.model.id;if(n==="figure")return this.naming.decorKind("entity");if(!n||t.model.url!==void 0)return;if(!this.bodyModelKinds.has(n)){this.bodyModelKinds.set(n,void 0),this.sceneRenderer.entryOfDecorModel(n).then(r=>this.bodyModelKinds.set(n,[r?.kind].flat()[0])).catch(()=>{});return}const s=this.bodyModelKinds.get(n);return s&&this.naming.decorKind(s)||void 0}explainedName(t){if(!t?.length)return;const e=this.ufoElement.sighting.timeline.allKeyframes,i=t.map(n=>{for(const s of e){const r=this.said.read(s.shapes.find(a=>a.sourceId===n)?.shape.title);if(r)return r}}).filter(n=>!!n);return i.length?i.join(", "):void 0}bodyName(t){const e=t.startsWith(pb)?t.slice(pb.length):void 0,i=e?qA.find(s=>s.id===e):void 0;if(i)return this.naming.comet(i);const n=t.startsWith(mb)?nb.byId(t.slice(mb.length)):void 0;return n?this.naming.nova(n):this.naming.body(t)}get naming(){return this.sceneNaming}sceneNaming=new jS;namesLanguage;ready=Promise.resolve();async loadSceneNames(){const t=I0(Lo.preferencesFor(this),C0);if(t===this.namesLanguage)return;this.namesLanguage=t;const e=await e5(t);t===this.namesLanguage&&(this.applySceneNaming(new jS(e)),this.computedKindTexts.clear(),this.loadComputedKindTexts())}setBusy(t,e=""){this.busyElement.hidden=!t,this.busyNote.textContent=t?e:"",this.busyElement.setAttribute("aria-label",e),this.busyElement.setAttribute("aria-busy",String(t))}renderLoaderText(t,e){let i=0;const n=(s,r)=>{s.setAttribute("aria-label",r),s.replaceChildren(),r.split(" ").forEach((a,c)=>{c>0&&s.append(" ");const l=document.createElement("span");l.className="scene-loader-word",l.setAttribute("aria-hidden","true");for(const h of a){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,t.loaded&&(this.creditsButton.title=t.names.credits,this.creditsButton.setAttribute("aria-label",t.names.credits),this.renderLoaderText(t.names.notAVideo,t.names.isASimulation),this.sceneRenderer.setCompassPoints(t.names.compassPoints))}showHoverTooltip(t,e){const i=this.hoverTooltip;if(i.textContent=e,i.hidden=!1,typeof i.showPopover=="function"){const u=document.fullscreenElement;i.matches(":popover-open")&&u!==this.tooltipOver&&i.hidePopover(),i.matches(":popover-open")||i.showPopover(),this.tooltipOver=u}const{innerWidth:n,innerHeight:s}=window,r=12,a=4,c=Math.min(t.clientX+r,n-i.offsetWidth-a),l=t.clientY+r,h=l+i.offsetHeight+a>s?t.clientY-r-i.offsetHeight:l;i.style.left=`${Math.max(a,c)}px`,i.style.top=`${Math.max(a,h)}px`}handlePointerLeave=()=>{this.lastHover=void 0,this.hoverTooltip.hidden=!0,this.ghostPath.toggleAttribute("hidden",!0),this.showCompassFor({hovered:!1})};hearDetonations(t,e,i,n){const s=`${i.lat.toFixed(4)},${i.lng.toFixed(4)}`,r=this.detonationsFor;(!r||s!==r.key||t.length!==r.reentries.length||t.some((l,h)=>l!==r.reentries[h]))&&(this.detonationsFor={reentries:[...t],key:s,detonations:t.length?Pt.detonationsOf(t,i):[]});const a=this.detonationsFor.detonations;if(n)return;const c=this.lastDetonationT;if(this.lastDetonationT=e,!(c===void 0||e<c||e-c>ve.DETONATION_JUMP_MS||this.ufoElement.playbackState!=="playing"))for(const l of a)l.t>c&&l.t<=e&&this.weatherAudio.playDetonation(l.loudness)}detonates(t){const e=[...t.skyEvents?.reentries??[],...this.fireballs?.reentries??[]],i=ke(t,0),n=t.event.place?.[0],s=i?.lat??n?.lat,r=i?.lng??n?.lng;return e.length>0&&s!==void 0&&r!==void 0&&Pt.detonationsOf(e,{lat:s,lng:r,heightM:this.altitudeOf(i)}).length>0}detonationsFor;lastDetonationT;static DETONATION_JUMP_MS=2e3;handleLightningFlash(t){if(clearTimeout(this.thunderTimeoutId),this.filmSound){this.filmThunderAtMs=this.lastTimeMs+pn.thunderDelayMs(t)*this.ufoElement.playbackRate;return}this.thunderTimeoutId=window.setTimeout(()=>this.weatherAudio.playThunder(),pn.thunderDelayMs(t))}handleFirstInteraction=()=>{this.weatherAudio.resume(),this.vehicleAudio.resume(),this.aircraftAudio?.resume(),!this.interacted&&(this.interacted=!0,this.setWeather(iu(this.ufoElement.sighting,this.lastTimeMs)))};interacted=!1;applyLevel(){if(this.filmSound)return;const t=this.ufoElement.level;this.weatherAudio.setLevel(t),this.vehicleAudio.setLevel(t),this.aircraftAudio?.setLevel(t)}handlePageGesture=()=>{this.ufoElement.playbackState==="playing"&&this.handleFirstInteraction()};unlockIfAlreadyActivated(){this.interacted||navigator.userActivation?.hasBeenActive&&this.handleFirstInteraction()}static GESTURES=["pointerdown","pointerup","touchend","click","keydown"];handleTimeUpdate=t=>{if(this.lastTimeMs=t.detail.time,this.syncAnimationsToPlayback(),this.updateAstronomy(this.lastTimeMs),this.ufoElement.playbackState==="playing"){this.sceneRenderer.frame(performance.now());const e=performance.now();this.lastHover&&!this.ghostPath.hasAttribute("hidden")&&e-this.lastPlayingHoverMs>=ve.PLAYING_HOVER_MS&&(this.lastPlayingHoverMs=e,this.ghostStillUnder(this.lastHover,e)&&this.hoverAt(this.lastHover))}this.placeFlightMark(),this.ufoElement.repaintChrome()};syncAnimationsToPlayback(){const t=this.ufoElement.playbackState==="playing",e=t||this.filming;this.sceneRenderer.setAnimationsRunning(e,e);const i=t||this.filmSound!==void 0;this.weatherAudio.setPaused(!i),this.vehicleAudio.setPaused(!i),this.aircraftAudio?.setPaused(!i),t&&this.unlockIfAlreadyActivated(),t||clearTimeout(this.thunderTimeoutId)}constructor(){super(),this.shadow=this.attachShadow({mode:"open"});const t=document.createElement("template");t.innerHTML=`<style>${v3}</style>${M3}`,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 lt(this.sceneCanvas),this.sceneRenderer.onReferencesSettled=()=>this.dispatchEvent(new CustomEvent(JL));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.busyElement=this.shadow.getElementById("scene-busy"),this.busyNote=this.shadow.getElementById("scene-busy-note"),this.loader=e,this.poster=new ad(this.shadow.getElementById("scene-poster"),()=>{this.loader.style.animationDelay=!this.poster.up&&this.holding?"0s":"",this.applyHold()}),this.sceneRenderer.onFirstFrameHold=s=>{this.holding=s,this.applyHold()},this.hoverTooltip=this.shadow.getElementById("hover-tooltip"),this.ghostPath=this.shadow.getElementById("ghost-path"),this.flightMark=this.shadow.getElementById("flight-mark"),this.ufoElement=document.createElement(f1),this.ufoElement.classList.add("ufo-overlay"),this.ufoElement.paintsShapes=!1,this.ufoElement.observerMapSnapshotSource=s=>this.snapshotMapOf(s),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"&&Qn.fill(n,this)}),this.sceneRenderer.onMapSubjectBounds=s=>this.ufoElement.setMapSubjectBounds(s),this.ufoElement.addEventListener("timeupdate",this.handleTimeUpdate),this.ufoElement.addEventListener("revealrequest",()=>this.poster.release()),this.ufoElement.addEventListener(jb,()=>this.poster.restore()),this.ufoElement.seekPreviewPainter=(s,r)=>this.seekPreviewOf(r).paint(s,r),typeof VideoEncoder<"u"&&typeof OffscreenCanvas<"u"&&(this.ufoElement.filmer={film:(s,r,a)=>this.film(s,r,a),generativeKit:(s,r,a)=>this.generativeKit(s,r,a),fileName:()=>this.filmFileName(),kitFileName:()=>this.filmFileName().replace(/\.mp4$/," - kit.zip"),pictureSize:()=>this.filmPictureSize(),hasMap:()=>this.ufoElement.hasObserverMap,durationS:()=>this.ufoElement.seekableDuration/this.filmRate()/1e3,positionS:()=>this.ufoElement.currentTime/this.filmRate()/1e3}),this.ufoElement.addEventListener("mutedchange",()=>this.applyLevel()),this.ufoElement.ambientSound=s=>s.vehicle!==void 0||s.decor.some(r=>r.engine!==void 0)||s.decor.some(r=>cd.kindOf(r,this.decorModelSounds.get(r.model?.id??""))!==void 0)||this.interpretationShown?.bodies.some(r=>r.sound)===!0||s.weatherTrack.allKeyframes.some(r=>r.weather.precipitationType!=="none"||r.weather.windSpeed>1)||this.detonates(s)||(this.traffic?.audible?.size??0)>0,this.ufoElement.addEventListener("referenceview",s=>this.applyReferenceView(s.detail)),this.ufoElement.addEventListener("traceview",s=>this.sceneRenderer.setTracesShown(s.detail.shown)),this.ufoElement.canvasElement.addEventListener("pointermove",this.handlePointerMove),this.ufoElement.canvasElement.addEventListener("pointerleave",this.handlePointerLeave);for(const s of ve.GESTURES)this.addEventListener(s,this.handleFirstInteraction,!0)}get said(){return this.saidTexts??=new Cr(Lo.preferencesFor(this))}saidTexts;traceLabelsFor;observerHeadlightsAt(t,e){const i=t.vehicle;return!i||!Yn.isRoad(i.kind)?void 0:{setting:$c.at(i.headlights??"auto",i.headlightKeyframes,e)??"auto",headingDeg:this.travelHeadingAt(t,e)}}travelHeadingAt(t,e){const i=ke(t,e);if(!i)return 0;for(const n of[400,-400]){const s=ke(t,e+n);if(!s||i.lat===void 0||i.lng===void 0||s.lat===void 0||s.lng===void 0)break;const r=ae(s.lat,s.lng,i.lat,i.lng);if(Math.hypot(r.x,r.z)<.8)continue;return(Math.atan2(r.x,-r.z)*180/Math.PI+(n<0?180:0)+360)%360}return i.headingDeg??0}routeCache;routeOf(t){const e=t.allKeyframes;if(this.routeCache?.track===t&&this.routeCache.count===e.length)return this.routeCache.route;const i=e.flatMap(s=>s.pose.lat!==void 0&&s.pose.lng!==void 0?[{lat:s.pose.lat,lng:s.pose.lng}]:[]),n=i.length>=2?i:void 0;return this.routeCache={track:t,count:e.length,route:n},n}traceLabels(t){const e=Lo.preferencesFor(this).join();if(this.traceLabelsFor?.traces!==t||this.traceLabelsFor.language!==e){const i=new Map;for(const n of t){const s=this.said.read(n.title);s&&i.set(n.id,s)}this.traceLabelsFor={traces:t,language:e,labels:i}}return this.traceLabelsFor.labels}connectedCallback(){Te.changes.addEventListener("change",this.onModulesChanged),this.saidTexts=void 0,this.ready=this.loadSceneNames(),this.sceneRenderer.restoreContext(),this.resizeToStage(),this.updateAstronomy(this.lastTimeMs),this.loadStars(),this.resizeObserver=new ResizeObserver(()=>this.resizeToStage()),this.resizeObserver.observe(this.frameElement),this.watchVisibility(),document.addEventListener("fullscreenchange",this.handleFullscreenChange);for(const e of ve.GESTURES)document.addEventListener(e,this.handlePageGesture,!0);const t=this.getAttribute("src");t&&this.loadFromSrc(t)}watchVisibility(){this.visibilityObserver?.disconnect(),!(typeof IntersectionObserver>"u"||this.hasAttribute("always-live"))&&(this.visibilityObserver=new IntersectionObserver(t=>{if(t[t.length-1].isIntersecting){this.sceneRenderer.resume();return}this.ufoElement.pause(),this.sceneRenderer.suspend()},{rootMargin:"100px"}),this.visibilityObserver.observe(this))}visibilityObserver;disconnectedCallback(){Te.changes.removeEventListener("change",this.onModulesChanged),this.visibilityObserver?.disconnect(),this.resizeObserver?.disconnect(),document.removeEventListener("fullscreenchange",this.handleFullscreenChange);for(const t of ve.GESTURES)document.removeEventListener(t,this.handlePageGesture,!0);this.sceneRenderer.stopTwinkle(),clearTimeout(this.thunderTimeoutId),this.weatherAudio.dispose(),this.vehicleAudio.dispose(),this.aircraftAudio?.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===bh||t===Eh||t===Oc)&&i!==e&&this.forwardPlayerAttributes(),t===Oc&&this.stageElement.classList.toggle("minified",i!==null)}forwardPlayerAttributes(){for(const t of[bh,Eh,Oc]){const e=this.getAttribute(t);e===null?this.ufoElement.removeAttribute(t):this.ufoElement.setAttribute(t,e)}}setCompassForced(t){this.showCompassFor({forced:t})}compassHovered=!1;compassForced=!1;showCompassFor(t){this.compassHovered=t.hovered??this.compassHovered,this.compassForced=t.forced??this.compassForced,this.sceneRenderer.setCompassForced(this.compassForced||this.compassHovered)}lookToward(t){const e=ke(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}=ae(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.setOutsideHeard(Yn.transmission(this.ufoElement.sighting.vehicle)),this.weatherAudio.setAmbient(t.precipitationType,t.precipitationIntensity*(t.precipitationAmount??1),t.windSpeed);const e=this.ufoElement.sighting.around;this.weatherAudio.setAround(wi.aroundBedRms(e),wi.aroundBedShape(e)??[])}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)}decorScreenBox(t){return this.sceneRenderer.decorScreenBox(t)}decorDrawnOffset(t){return this.sceneRenderer.decorDrawnOffset(t)}decorGroundPointAt(t,e,i,n=0){return this.sceneRenderer.decorGroundPointAt(t,e,i,n)}decorMetresPerNdcY(t){return this.sceneRenderer.decorMetresPerNdcY(t)}decorGrabHeightAt(t,e,i){return this.sceneRenderer.decorGrabHeightAt(t,e,i)}bodyScreenBox(t){return this.sceneRenderer.bodyScreenBox(t)}pickPlacedBodyAt(t,e){return this.sceneRenderer.pickPlacedBodyAt(t,e)}resumeWeatherAudio(){this.weatherAudio.resume(),this.vehicleAudio.resume(),this.aircraftAudio?.resume()}async loadFromSrc(t){const e=hd.recording(t);this.holdForNewScene(e);const i=await e;this.documentUrl=new URL(t,location.href).href,this.showPoster(i.image,this.documentUrl,!this.ufoElement.playRequested),this.sightingData=i}loader;poster;showPoster(t,e,i=!0){this.poster.show(t,e,i)}applyHold(){const t=this.holding,e=this.poster.up;this.loader.hidden=!t||e,t&&(this.hoverTooltip.hidden=!0),this.ufoElement.captionHeld=t||e,this.ufoElement.controlsHeld=t||e,this.ufoElement.holdClock(t)}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){const e=la.recording(t);this.ufoElement.playerTitle=void 0,this.ufoElement.sightingData=e,this.requireModules(e.modules),this.upperAirHeardLive=void 0,this.seekPreview?.recordingChanged(e),this.showInterpretation(this.inTheRound?this.ufoElement.sighting.interpretation:void 0),this.syncAccountHidden(),this.applyFrameFormat(),this.lastTimeMs=0,this.sceneRenderer.compileNextFrameOffThread(),this.updateAstronomy(0)}onModulesChanged=t=>{t.detail==="skyEvents"&&this.sceneRenderer.setSkyEvents(this.skyEventsShown,!0,this.skyEventsStartDate)};requireModules(t){if(!t?.length)return;const e=this.documentUrl,i=dt(async()=>{const{ModuleSession:n}=await import("./ModuleSession-Hj3QwLuw.js");return{ModuleSession:n}},[],import.meta.url).then(({ModuleSession:n})=>n.shared.require(t,e)).then(()=>this.sceneRenderer.setDecorModelProvider(new UA));this.sceneRenderer.holdUntil(i)}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 Dp(this,()=>document.createElement(QM))}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.imageSmoothingQuality="high",e.drawImage(this.sceneCanvas,0,0,t.width,t.height),!0):!1}filmName;filmFileName(){return`${(this.filmName??"").replace(/[\\/:*?"<>|\u0000-\u001f]+/g," ").replace(/\s+/g," ").trim()||"observation"}.mp4`}filming=!1;async film(t,e,i){const[{VideoExport:n},{FilmChrome:s}]=await Promise.all([dt(()=>import("./VideoExport-B8ZhHNnd.js").then(a=>a.a),[],import.meta.url),dt(()=>import("./FilmChrome-DYiyzoB_.js"),[],import.meta.url)]),r=await s.loadLogo();return this.filmScene(t,a=>n.film({...a,frameAt:(c,l,h)=>a.frameAt(c,l,h)?(s.paint(h,this.ufoElement.filmChrome(t),r),!0):!1},e,i))}async generativeKit(t,e,i){const[{GenerativeKit:n},{generativeKitMessages:s},{toSightingJson:r}]=await Promise.all([dt(()=>import("./GenerativeKit-BmhvjjzB.js"),__vite__mapDeps([18,19,20]),import.meta.url),dt(()=>import("./GenerativeKitMessages-BhHcmiXg.js"),[],import.meta.url),dt(()=>Promise.resolve().then(()=>q_),void 0,import.meta.url)]),a=I0(Lo.preferencesFor(this),C0),[c]=await Promise.all([s.load(a),this.sceneRenderer.loadControlPasses()]),l=this.sceneRenderer.areReferencesShown;this.sceneRenderer.setReferencesShown(!1);try{return await this.filmScene({...t,caption:!1,time:!1,map:!1},h=>n.make({film:h,drawControlPasses:()=>this.sceneRenderer.drawControlPasses(),recording:r(this.ufoElement.sighting),title:this.filmName??"",source:h.about?.source,language:a},c,e,i))}finally{this.sceneRenderer.setReferencesShown(l)}}async filmScene(t,e){if(this.filming)throw new Error("Already filming");const i=this.ufoElement,n=i.currentTime;i.pause();const s={width:this.sceneCanvas.clientWidth,height:this.sceneCanvas.clientHeight},r=t.height&&s.height>0?t.height/s.height:this.sceneRenderer.maxPixelRatio;this.filming=!0,this.sceneRenderer.holdPixelRatio(r),i.filmMap(t.map),this.syncAnimationsToPlayback();try{const a=t.height??this.sceneCanvas.height,c=t.height&&s.height>0?Math.round(t.height*s.width/s.height):this.sceneCanvas.width,l=this.filmRate(),h=Math.min(i.seekableDuration,t.toS!==void 0?t.toS*1e3*l:i.seekableDuration),u=Math.min(h,Math.max(0,(t.fromS??0)*1e3*l));return await e({fromMs:u,toMs:h,rate:l,width:c,height:a,frameAt:(d,f,p)=>this.filmFrameAt(d,f,p),hearInto:d=>this.hearInto(d),about:{title:this.filmName,description:i.filmDescription,source:this.documentUrl?new URL(this.documentUrl,location.href).href:void 0}})}finally{this.filming=!1,this.sceneRenderer.holdPixelRatio(void 0),i.filmMap(void 0),i.currentTime=n,this.syncAnimationsToPlayback()}}filmRate(){const t=this.ufoElement.playbackRate;return t>0?t:1}filmPictureSize(){const t=this.sceneRenderer.maxPixelRatio;return{width:Math.round(this.sceneCanvas.clientWidth*t),height:Math.round(this.sceneCanvas.clientHeight*t)}}filmSound;liveSound;filmThunderAtMs;hearInto(t){if(t){this.liveSound??={weather:this.weatherAudio,vehicle:this.vehicleAudio,aircraft:this.aircraftAudio},this.filmSound=t,this.weatherAudio=new Gc(t),this.vehicleAudio=new xy(t);const e=ve.trafficRuntime;this.aircraftAudio=this.liveSound.aircraft&&e?this.newAircraftAudio(e):void 0}else this.liveSound&&(this.weatherAudio.dispose(),this.vehicleAudio.dispose(),this.aircraftAudio?.dispose(),this.weatherAudio=this.liveSound.weather,this.vehicleAudio=this.liveSound.vehicle,this.aircraftAudio=this.liveSound.aircraft,this.liveSound=void 0,this.filmSound=void 0,this.filmThunderAtMs=void 0);this.ufoElement.hearInto(t),this.syncAnimationsToPlayback()}filmFrameAt(t,e,i){this.ufoElement.currentTime!==t&&(this.ufoElement.currentTime=t),this.filmThunderAtMs!==void 0&&t>=this.filmThunderAtMs&&(this.filmThunderAtMs=void 0,this.weatherAudio.playThunder()),this.sceneRenderer.render();const n=this.sceneRenderer.framesDrawn;return this.sceneRenderer.frame(e),this.sceneRenderer.framesDrawn===n?!1:(i.drawImage(this.sceneCanvas,0,0,i.canvas.width,i.canvas.height),!0)}referenceAspect(t){return this.sceneRenderer.referenceAspect(t)}screenPointOf(t){return this.sceneRenderer.screenPointOf(t)}horizonPointAt(t){const e=t*Math.PI/180,i=this.sceneRenderer.screenPointOf(new _(Math.sin(e),0,-Math.cos(e)));return i&&{x:(i.ndcX+1)/2,y:(1-i.ndcY)/2}}directionAt(t,e){return this.sceneRenderer.directionAt(t,e)}referenceFailure(t){return this.sceneRenderer.referenceFailure(t)}applyReferenceView(t){this.sceneRenderer.setReferencesShown(t.shown);for(const e of this.ufoElement.sighting.references){const i=t.views?.[e.id];this.sceneRenderer.setReferenceView(e.id,{opacity:i?i.shown?i.opacity:0:t.opacity})}}get currentTerrainAttribution(){return this.sceneRenderer.currentTerrainAttribution}get currentRoadAttribution(){return this.sceneRenderer.currentRoadAttribution}get currentWaterAttribution(){return this.sceneRenderer.currentWaterAttribution}get currentRailwayAttribution(){return this.sceneRenderer.currentRailwayAttribution}setTerrainProviders(t){this.liveTerrainProviders=t,this.snapshotKey=void 0,this.applySnapshots(this.ufoElement.sighting.snapshots)}liveTerrainProviders;snapshotKey="none";applySnapshots(t){const e=vh.isEmpty(t)?"none":`${JSON.stringify(t)}
|
|
8939
8939
|
${this.documentUrl??""}
|
|
8940
8940
|
${Mi.generation}`;if(e===this.snapshotKey)return;const i=this.snapshotKey!==void 0&&this.traffic?.set!==void 0;this.snapshotKey=e,this.sceneRenderer.setTerrainProviders(Cp.providers(t,this.documentUrl,this.liveTerrainProviders??$b())),this.ufoElement.observerMapSnapshot=this.snapshotMapOf(t),i&&(this.traffic=void 0,this.decorMemo=void 0)}snapshotMapOf(t){const e=vh.held(t,"map");if(!e)return;const i=`${Mi.address(e.src,this.documentUrl)}
|
|
8941
8941
|
${Mi.generation}`;return this.snapshotMap?.key!==i&&(this.snapshotMap={key:i,imagery:Cp.map(e,this.documentUrl)}),this.snapshotMap.imagery}snapshotMap;setDecorModelProvider(t){this.sceneRenderer.setDecorModelProvider(t)}get decorModelCredits(){return[...new Map(this.sceneRenderer.currentDecorModelCredits.map(e=>[`${e.title}|${e.author??""}|${e.license}|${e.sourceUrl??""}`,e])).values()]}applyFrameFormat(){const t=this.ufoElement.sighting.instrument,e=fi.CANVAS_HEIGHT_PX,i=Ji.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:e1,url:this.getAttribute("star-catalog-src")??e7},{magnitudeLimit:i1,url:this.getAttribute("deep-star-catalog-src")??i7}],e=this.instrumentReach(),i=++this.starCatalogRequest;this.starCatalogDepth=e>e1?i1:e1;const n=await qr.upTo(t,e);i===this.starCatalogRequest&&(this.starCatalog=n,this.sceneRenderer.compileNextFrameOffThread(),this.updateAstronomy(this.lastTimeMs))}ensureStarsDeepEnough(){!this.starCatalog||this.starCatalogDepth>=i1||this.instrumentReach()<=this.starCatalogDepth||this.loadStars()}instrumentReach(){const t=this.ufoElement.sighting,e=Wn.gainFor(t.instrument,{fNumber:ke(t,0)?.fNumber,fieldOfViewDeg:vn.fovOf(t,0),exposureSeconds:t.exposure});return H0(n7,e)}updateAstronomy(t){this.ensureStarsDeepEnough(),this.applySceneAt(t);const e=ns.windowEndingAt(t,this.exposureSeconds()),i=e.seconds,n=this.degreesPerPixelAt(t),s=Kc.instants(i,n),r=Math.max(s,this.ufoElement.exposureTimes(t).length,ns.instants(this.decorWithTraffic(this.ufoElement.sighting),ke(this.ufoElement.sighting,t)?.elevationM??0,e.fromMs,i,n),ns.bodyInstants(this.interpretationShown?.bodies??[],ke(this.ufoElement.sighting,t)?.elevationM??0,e.fromMs,t,n));if(r<=1){this.sceneRenderer.setExposure(1);return}const a=this.ufoElement.sighting.observerTrack.turnIsViewOnly(e.fromMs,t)?t:void 0;this.sceneRenderer.setExposure(r,c=>this.applySceneAt(e.fromMs+e.ms*c/(r-1),{viewAt:a,sky:Math.floor(c*s/r)!==Math.floor((c-1)*s/r),stepMs:e.ms/r}))}exposureSeconds(){return this.ufoElement.sighting.exposure??0}degreesPerPixelAt(t){const e=this.sceneCanvas.height;return e<=0?0:vn.fovOf(this.ufoElement.sighting,t)/e}roadGradeAt(t,e){return t.observerTrack.allKeyframes.length<2?0:Zl.at(t,e,this.sceneRenderer.bodyGround)}get roadGradeDeg(){return this.roadGradeAt(this.ufoElement.sighting,this.ufoElement.currentTime)}applySceneAt(t,e){const i=this.ufoElement.sighting;e||this.sceneRenderer.setRecordingTime(t),this.setWeather(iu(i,t)),this.sceneRenderer.setInstrument(i.instrument,ke(i,t)?.fNumber),this.sceneRenderer.setLightPollution(i.lightPollution),e||this.vehicleAudio.setVoices(this.vehicleHearing.at(i,t)),e||this.pushAircraftSound(i,t),this.updateMeteorShower(i,t),this.updateLightning(i,t,e!==void 0),this.sceneRenderer.setDecor(this.seatedDecor(this.decorWithTraffic(i),t)),this.recomputeAmongNewDecor(),this.sceneRenderer.setDecorPresence(this.traffic?.set?.presence??ve.NO_PRESENCE),this.sceneRenderer.setDecorSunlight(this.trafficSunlight(t)),this.sceneRenderer.setContrails(this.traffic?.contrails??ve.NO_CONTRAILS),this.sceneRenderer.setContrailSunlight(this.contrailSunlight(t));const n=ke(i,t);this.sceneRenderer.setReferences(i.references,n?.lat!==void 0&&n.lng!==void 0?{lat:n.lat,lng:n.lng}:void 0),e||this.sceneRenderer.setReferencesTime({t,playing:this.ufoElement.playbackState==="playing",timeScale:this.ufoElement.playbackRate});const s=ke(i,0),r=eu(i,0),a=bc(i.event.time??{},n?.lng??R0.lng,i.event.utcOffsetHours),c=i.weatherSource!==void 0&&a?m3(a):void 0,l=Object.fromEntries(q0(eu(i,t)).map(P=>[P.id,Ry(t,i.weatherTrack,r,s,n,P.id,P.instances?.length?void 0:c)]));this.sceneRenderer.setCloudOffset(Ry(t,i.weatherTrack,r,s,n,void 0,c),l);const h=e?.viewAt!==void 0?ke(i,e.viewAt):void 0,u=n&&h?{...n,headingDeg:h.headingDeg,pitchDeg:h.pitchDeg,rollDeg:h.rollDeg,fovDeg:h.fovDeg}:n;this.sceneRenderer.setObserverPose(u?{...u,pitchDeg:u.pitchDeg+this.roadGradeAt(i,e?.viewAt??t)}:R0),this.sceneRenderer.setLensOptics(this.lensOpticsAt(t)),this.sceneRenderer.setInstrumentGain(Wn.gainFor(i.instrument,{fNumber:n?.fNumber,fieldOfViewDeg:vn.fovOf(i,t),exposureSeconds:i.exposure}),i.instrument.detailUm!==void 0,Dc.byId(n?.filter).opticalDensity),this.sceneRenderer.setMedium(qd.mediumOf(i.instrument.medium,qd.byId(i.film)),i.exposure,n?.fNumber??i.instrument.fNumber,i.iso,i.metering),this.sceneRenderer.setLensGhosts(Ze.optics(i.instrument,n?.fNumber??i.instrument.fNumber,i.lens,this.glassWettingOf(i).stateAt(t/1e3),t)),this.sceneRenderer.setPerception(Rc.perceptionOf(i.account?.observerPerception)),this.sceneRenderer.setGait(oi.bodyAt(i,t,this.ufoElement.steadyBody)),this.sceneRenderer.updateDecorAnchoring(ke(i,0),n,t),this.placeBodiesAt(t,e===void 0),this.sceneRenderer.updateDecorLitState(t,e?.stepMs??0),this.applySnapshots(i.snapshots),this.sceneRenderer.setObserverRoute(this.routeOf(i.observerTrack)),this.sceneRenderer.setObserverHeadlights(this.observerHeadlightsAt(i,t)),this.sceneRenderer.setTerrainOrigin(n?.lat,n?.lng,()=>{this.placeBodiesAt(this.lastTimeMs,!0),this.sceneRenderer.render()}),this.sceneRenderer.setStatedRoads(i.roads),this.sceneRenderer.setTraces(i.traces,this.traceLabels(i.traces)),this.pushPhenomenaAt(t);const d=n?.lat??R0.lat,f=n?.lng??R0.lng,p=bc(i.event.time??{},f,i.event.utcOffsetHours),g={lat:d,lng:f,elevationM:this.altitudeOf(n)};this.pushSatellitesAt(p,t,g),this.ensureFireballs(p);const m=this.skyEventsOf(i),M=m?.reentries??[];this.hearDetonations(M,t,{lat:d,lng:f,heightM:g.elevationM},e!==void 0);const v=M.filter(P=>Pt.mayDazzle(P));if(this.sceneRenderer.setRetinaHistory(v.length===0?void 0:P=>{const L=ke(i,P),O={lat:L?.lat??d,lng:L?.lng??f,heightM:L?this.altitudeOf(L):g.elevationM};return{views:Pt.viewsAt(v,P,O),pose:L}},i),this.skyEventsStartDate=p,this.sceneRenderer.setSkyEvents(m,!1,p),m&&this.loadSkyEventTexts(NM.map(P=>to.of(P)).filter(P=>to.eventsOf(m,P).length>0&&!this.skyEventTexts.has(P))),e&&!e.sky)return;if(this.sceneRenderer.setSkyUnknown(!p),!p){this.sceneRenderer.setAstronomy(s7);return}const x=new Date(p.getTime()+t),y=Math.max(1,Math.round(.25*this.degreesPerPixelAt(t)/Kc.DEG_PER_SECOND*1e3)),w=Math.max(1e-8,this.degreesPerPixelAt(t)*.1),b=`${Math.floor(x.getTime()/y)}|${Math.round(d/w)}|${Math.round(f/w)}|${Math.round(g.elevationM)}|${this.starCatalog?this.starCatalogDepth:0}`;if(b===this.lastSkyKey){this.sceneRenderer.render();return}this.lastSkyKey=b;const E=zu("Sun",x,g),S=zu("Moon",x,g);let A=rn.separationOf(E,S)<1?rn.viewAt(x,g):void 0;if(A){const P=rn.offsetOf(E,S,A.separationDeg);if(A.obscuration>ve.LIMB_FROM_OBSCURATION){const L=this.limbFor(x,g);L&&(A={...A,obscuration:1-dr.uncoveredFraction(L,A.sunRadiusDeg,P),limb:L})}A={...A,horizonShare:rn.horizonShare(A,P,E.altitudeDeg,E.azimuthDeg,oa.distanceKm(x,g))}}const R={...E,magnitude:gg("Sun",x)-2.5*Math.log10(rn.beamFraction(A))};this.lastSun={altitudeDeg:R.altitudeDeg,azimuthDeg:R.azimuthDeg};const D={...S,phase:t8(x),magnitude:gg("Moon",x),radiusDeg:oa.apparentRadiusDeg(x,g)},I=QO.map(P=>({body:P,position:zu(P,x,g),magnitude:gg(P,x)}));this.sceneRenderer.setAstronomy({sun:R,moon:D,planets:I,comet:this.cometAt(x,g),novae:nb.appearancesAt(x,g).map(({outburst:P,position:L,magnitude:O})=>({id:P.id,position:L,magnitude:O})),stars:this.starCatalog?{catalog:this.starCatalog,date:x,observer:g}:void 0,frame:{date:x,observer:g},localHour:((x.getUTCHours()+x.getUTCMinutes()/60+(i.event.utcOffsetHours??Math.round(f/15)))%24+24)%24,eclipse:A}),this.ufoElement.setSunAltitude(R.altitudeDeg)}static LIMB_FROM_OBSCURATION=.98;limbRelief;limbRequested=!1;limbCache;limbFor(t,e){if(!this.limbRelief){this.limbRequested||(this.limbRequested=!0,rd.load(t7).then(s=>{this.limbRelief=s,this.lastSkyKey="",s&&this.isConnected&&this.updateAstronomy(this.lastTimeMs)}));return}const i=this.limbCache;if(i&&Math.abs(t.getTime()-i.atMs)<5e3&&i.lat===e.lat&&i.lng===e.lng&&i.elevationM===e.elevationM)return i.profile;const n=dr.profile(t,e,this.limbRelief);return this.limbCache={profile:n,atMs:t.getTime(),lat:e.lat,lng:e.lng,elevationM:e.elevationM},n}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 r of this.satellites.passes.positionsAt(n,i,-1))r.magnitude!==void 0&&s.push({norad:r.object.norad,name:r.object.name,position:{altitudeDeg:r.altitudeDeg,azimuthDeg:r.azimuthDeg},magnitude:r.magnitude,heightKm:r.heightKm});this.sceneRenderer.setSatellites(s)}ensureFireballs(t){const e=this.ufoElement.sighting,i=Math.max((e.event.durationSeconds??0)*1e3,this.ufoElement.seekableDuration),n=t?.getTime(),s=e.skySources!==!1,r=n===void 0||!s?"":`${n}+${i}`;if(this.fireballs?.key===r)return;if(!s){this.fireballs={key:r,status:"outside",reentries:[]};return}if(n===void 0||!ca.mayCover(n+i)){this.fireballs={key:r,status:"outside",reentries:[]};return}const a={key:r,status:"loading",reentries:[]};this.fireballs=a,ve.fireballArchive.between(n,n+i).then(c=>{a.status=c?"ready":"unavailable",a.records=c??[],a.reentries=a.records.map(l=>ca.asReentry(l,n)),!(this.fireballs!==a||!this.isConnected)&&(this.dispatchEvent(new CustomEvent(ZL)),a.reentries.length>0&&this.updateAstronomy(this.lastTimeMs))})}decorWithTraffic(t){const e=this.ensureTraffic(t);if(!e||e.objects.length===0)return t.decor;const i=this.decorMemo;if(i&&i.base===t.decor&&i.traffic===e.objects)return i.merged;const n=[...t.decor,...e.objects];return this.decorMemo={base:t.decor,traffic:e.objects,merged:n},n}seatedDecor(t,e){if(!t.some(r=>r.observerKeyframes?.length))return t;const i=t.map(r=>{if(!r.observerKeyframes?.length)return"";const a=by(r,e);return`${a.side??"-"}/${a.facing??"-"}`}).join("|"),n=this.seatedMemo;if(n&&n.base===t&&n.seats===i)return n.seated;const s=t.map(r=>{if(!r.observerKeyframes?.length)return r;const a=by(r,e);return{...r,observerSide:a.side,observerFacing:a.facing}});return this.seatedMemo={base:t,seats:i,seated:s},s}ensureTraffic(t){const e=ke(t,0),i=e?.lng===void 0?void 0:bc(t.event.time??{},e.lng,t.event.utcOffsetHours),n=Math.max((t.event.durationSeconds??0)*1e3,this.ufoElement.seekableDuration),s=i?.getTime(),r=s===void 0||e?.lat===void 0||e.lng===void 0?"":`${this.aircraftSource.id}|${s}+${n}|${e.lat.toFixed(3)},${e.lng.toFixed(3)}|${Math.round(e.elevationM??0)}|${Math.round(this.sceneRenderer.groundAltitudeM)}`;if(t.skySources===!1){this.traffic?.status!=="byHand"&&(this.traffic={key:"byHand",status:"byHand"},this.upperAirHeardLive=void 0);return}if(this.traffic?.key===r)return this.traffic.set;if(this.upperAirHeardLive=void 0,r===""||s===void 0||e?.lat===void 0||e.lng===void 0){this.traffic={key:r,status:"outside"};return}let a=ve.aircraftProviders.get(this.aircraftSource.id);if(a||ve.aircraftProviders.set(this.aircraftSource.id,a=this.aircraftSource.create()),a.mayCover&&!a.mayCover(s+n)){this.traffic={key:r,status:"outside"};return}const c={key:r,status:"loading",startMs:s,observer:{lat:e.lat,lng:e.lng}};this.traffic=c;const l={lat:e.lat,lng:e.lng,heightM:this.sceneRenderer.groundAltitudeM},h=kn.MAX_GAP_S*1e3,u=ve.SOUND_LOOKBACK_MS,d={lat:e.lat,lng:e.lng,elevationM:this.altitudeOf(e)},f=(p,g)=>p.TrafficDecor.from(c.tracks??[],l,s,p.TrafficDecor.MAX_OBJECTS,{models:g,sunElevationAt:m=>this.sunElevationAt(m,d)});a.between(l,s-u,s+n+h).then(async p=>{if(this.traffic!==c)return;if(p.status!=="found"){c.status=p.status==="outside"?"outside":"unavailable",p.status==="failed"&&(c.problem=p.problem,c.creditsSpent=p.creditsSpent),this.announceTraffic();return}let g;try{g=await ve.loadTrafficRuntime()}catch{this.traffic===c&&(c.status="unavailable",this.announceTraffic());return}this.traffic===c&&(c.status="ready",c.tracks=p.tracks,c.partial=p.partial,c.creditsSpent=p.creditsSpent,c.set=f(g),this.startAircraftSound(c,g),this.announceTraffic(),this.describeTraffic(a,c,g,f),c.set.shown>0&&(this.readUpperAir(c,g,s-u,s+n+h),this.readTrailTraffic(a,c,g,l,s-ve.TRAIL_LOOKBACK_MS,s+n+h)))})}trafficSunlight(t){const e=new Map,i=this.traffic,n=i?.set,s=this.lastSun;if(!n||!s||i.startMs===void 0||!i.observer)return e;for(const[r,a]of n.presence){if(t<a.fromMs||t>a.untilMs)continue;const c=n.flights.get(r),l=c?kn.positionAt(c,i.startMs+t):void 0;l&&e.set(r,{heightM:l.geo.heightM,sunElevationDeg:ws.sunElevationDeg(s,i.observer,l.geo)})}return e}trafficTooltipAt(t,e){const i=this.sceneRenderer.pickTrafficAt(t,e),n=i?this.trafficInfoAt(i):void 0;if(!n)return;const s=this.naming;return ve.trafficRuntime?.TrafficTooltip.text(n,s.names.trafficTooltip,a=>s.towards(a))}trafficInfoAt(t){const e=this.traffic,i=e?.set?.flights.get(t);if(!e||!i||e.startMs===void 0||!e.observer)return;const n=ve.trafficRuntime;if(!n)return;const s=e.descriptions?.get(Je.keyOf(i)),r=ke(this.ufoElement.sighting,this.lastTimeMs),a={lat:e.observer.lat,lng:e.observer.lng,heightM:this.altitudeOf(r)},c=iu(this.ufoElement.sighting,this.lastTimeMs),l=this.ufoElement.sighting.around,h=n.AmbientNoise.dbA(c,l),u=n.TrafficInfos.at(i,s,a,e.startMs+this.lastTimeMs,{ambientDbA:h,ambientShapeDb:n.AmbientNoise.shapeDb(c,l)}),d=u&&this.contrailAt(t,this.lastTimeMs);return u&&d?{...u,contrail:d}:u}contrailAt(t,e){const i=this.traffic?.contrails?.find(s=>s.id===t);if(!i)return;let n;for(const s of i.points){if(s.tMs>e)break;n=s}return n?.forms?{persistent:n.persistent,iceRelativeHumidity:n.iceRelativeHumidity}:void 0}startAircraftSound(t,e){this.aircraftAudio??=this.newAircraftAudio(e),this.sortOutAudible(t,e)}sortOutAudible(t,e){if(!t.set||!t.observer)return;const i={windSpeed:0,precipitationType:"none",precipitationIntensity:0};t.audible=e.TrafficSound.candidates(t.set.flights,t.descriptions??new Map,Je.keyOf,{...t.observer,heightM:this.sceneRenderer.groundAltitudeM},{ambientDbA:e.AmbientNoise.dbA(i,this.ufoElement.sighting.around),ambientShapeDb:e.AmbientNoise.shapeDb(i,this.ufoElement.sighting.around)}),this.ufoElement.refreshSoundControls()}pushAircraftSound(t,e){this.startDecorAircraftSound(t),this.startBodySound(),this.startRideSound(t);const i=this.aircraftAudio;if(!i)return;const n=ve.trafficRuntime;if(!n){i.setVoices([]);return}const s=ke(t,e),r=iu(t,e),a={ambientDbA:n.AmbientNoise.dbA(r,t.around),referenceAmplitude:n.AmbientNoise.referenceAmplitude(r,t.around),ambientShapeDb:n.AmbientNoise.shapeDb(r,t.around),expandUnderKnee:!n.AmbientNoise.bedPlays(r,t.around)},c=t.event.place?.[0],l={lat:s?.lat??c?.lat,lng:s?.lng??c?.lng},h=l.lat!==void 0&&l.lng!==void 0?{lat:l.lat,lng:l.lng,heightM:s?.elevationM??0}:void 0,u=M=>this.decorModelSounds.get(M.model?.id??""),d=!t.vehicle&&h?n.DecorAircraftHearing.ridden(t,e,h,u):void 0,f=t.vehicle??(d?{kind:d.kind}:void 0),p=f?n.CabinHearing.voice(f,a):void 0,g={...a,ambientDbA:Math.max(a.ambientDbA,p?.levelDbA??0),...f?{throughDb:Yn.insulationDb(f)}:{}},m=this.trafficVoices(e,s,g,n);h&&(this.decorAircraftHearing??=new n.DecorAircraftHearing,m.push(...this.decorAircraftHearing.voices(t,e,h,g,u)),m.push(...this.bodyVoices(t,e,g,n)),p&&m.push(p),m.sort((M,v)=>v.levelDbA-M.levelDbA),m.length=Math.min(m.length,4)),i.setVoices(m,s?.headingDeg??0)}startRideSound(t){this.aircraftAudio||Yn.aircraftOf(t.vehicle)===void 0||(ve.trafficRuntime?this.aircraftAudio=this.newAircraftAudio(ve.trafficRuntime):ve.loadTrafficRuntime().catch(()=>{}))}startBodySound(){this.aircraftAudio||!this.interpretationShown?.bodies.some(t=>t.sound)||(ve.trafficRuntime?this.aircraftAudio=this.newAircraftAudio(ve.trafficRuntime):ve.loadTrafficRuntime().catch(()=>{}))}bodyVoices(t,e,i,n){const s=this.interpretationShown,r=t.event.place?.[0];if(!s||!r||!s.bodies.some(f=>f.sound))return[];const a=this.sceneRenderer.bodyGround,c=f=>Lt.eyeOf(t,f,a),l=c(e);if(!l)return[];const h=new Map,u=(f,p)=>{let g=h.get(f.id);return g||h.set(f.id,g=new Lt(f,a,c)),g.at(p)};this.bodyHearing??=new n.BodyHearing;const d=Math.max(t.observerTrack.duration,(t.event.durationSeconds??0)*1e3);return this.bodyHearing.voices(s.bodies,u,l,r,e,d,i)}trafficVoices(t,e,i,n){const s=this.traffic,r=s?.set;if(!s||!r||!s.audible||s.startMs===void 0||!s.observer)return[];const a={lat:s.observer.lat,lng:s.observer.lng,heightM:this.altitudeOf(e)};return n.TrafficSound.voices(s.audible,r.flights,s.descriptions??new Map,Je.keyOf,a,s.startMs+t,i)}startDecorAircraftSound(t){const e=t.decor.filter(n=>n.kind==="aircraft"&&n.track?.some(s=>(s.altitudeM??0)>0));if(e.length===0)return;for(const n of e){const s=n.model?.id;n.aircraftSound||!s||n.model?.url!==void 0||this.decorModelSounds.has(s)||(this.decorModelSounds.set(s,void 0),this.decorModelsAsked.add(s),this.sceneRenderer.entryOfDecorModel(s).then(r=>{this.decorModelSounds.set(s,r?.parameters?.sound),this.decorModelsAsked.delete(s),this.ufoElement.refreshSoundControls(),this.startDecorAircraftSound(t)}))}if(e.some(n=>{if(n.aircraftSound)return n.aircraftSound!=="silent";const s=n.model?.id;return!s||n.model?.url!==void 0?!0:!this.decorModelsAsked.has(s)&&this.decorModelSounds.get(s)!=="silent"})){if(this.aircraftAudio||ve.trafficRuntime){!this.aircraftAudio&&ve.trafficRuntime&&(this.aircraftAudio=this.newAircraftAudio(ve.trafficRuntime));return}ve.loadTrafficRuntime().catch(()=>{})}}newAircraftAudio(t){const e=new t.AircraftAudio(this.filmSound);return this.filmSound||e.setLevel(this.ufoElement.level),(this.interacted||this.filmSound)&&e.resume(),e.setPaused(this.ufoElement.playbackState!=="playing"&&!this.filmSound),e}get aircraftFlights(){return[...this.declaredFlights,...this.recordedFlights]}get declaredFlights(){return this.ufoElement.sighting.decor.filter(t=>t.kind==="aircraft"&&cd.flies(t)).map(t=>{const e=this.sceneRenderer.decorSkyPoint(t.id);return{key:Je.declaredKeyOf(t.id),type:this.said.read(t.title)||this.naming.decorKind(t.kind),sky:e?.sky,altitudeFt:e?e.altitudeM/.3048:void 0,firstMs:0,drawn:e!==void 0,declared:!0}})}get recordedFlights(){const t=this.traffic;if(!t?.tracks||t.startMs===void 0||!t.observer)return[];const e=t.startMs,i=this.observerAt(this.lastTimeMs,t.observer),n=new Set([...t.set?.flights.values()??[]].map(a=>Je.keyOf(a))),s=t.nearestPassKm??=new Map(t.tracks.map(a=>[Je.keyOf(a),Math.min(...a.points.map(c=>kn.groundDistanceKm(t.observer,c)))])),r=this.ufoElement.seekableDuration;return[...t.tracks].sort((a,c)=>s.get(Je.keyOf(a))-s.get(Je.keyOf(c))).map(a=>{const c=Je.keyOf(a),l=t.descriptions?.get(c),h=t.models?.get(c),u=kn.seenFrom(a,i,e+this.lastTimeMs),d=a.points.find(f=>f.t>=e)?.t;return{key:c,type:h?.basis==="type"?h.name:l?.type,registration:l?.registration,sky:u?.sky,altitudeFt:u?.altitudeFt,firstMs:d!==void 0&&d-e<=r?d-e:void 0,drawn:n.has(c)}})}lookAtFlight(t,e=this.lastTimeMs){const i=this.traffic,n=ke(this.ufoElement.sighting,e),s=Je.declaredIdOf(t);if(s!==void 0){const c=this.sceneRenderer.decorSkyPoint(s);return!c||n?.headingDeg===void 0?!1:(this.setLookOffset(((c.sky.azimuthDeg-n.headingDeg)%360+540)%360-180,c.sky.altitudeDeg-(n.pitchDeg??0)),!0)}const r=i?.tracks?.find(c=>Je.keyOf(c)===t);if(!i?.observer||i.startMs===void 0||!r||n?.headingDeg===void 0)return!1;const a=kn.seenFrom(r,this.observerAt(e,i.observer),i.startMs+e);return a?(this.setLookOffset(((a.sky.azimuthDeg-n.headingDeg)%360+540)%360-180,a.sky.altitudeDeg-(n.pitchDeg??0)),!0):!1}markFlight(t){this.markedFlight=t,this.placeFlightMark()}placeFlightMark(){const t=this.markedFlight,e=t===void 0?void 0:this.sceneRenderer.flightScreenPoint(t);if(this.flightMark.toggleAttribute("hidden",!e),!e)return;const i=this.sceneCanvas.getBoundingClientRect(),n=this.stageElement.getBoundingClientRect(),s=i.left-n.left+(e.ndcX+1)/2*i.width,r=i.top-n.top+(1-e.ndcY)/2*i.height;for(const a of Array.from(this.flightMark.children))a.setAttribute("cx",String(s)),a.setAttribute("cy",String(r))}altitudeOf(t){return this.sceneRenderer.groundAltitudeM+(t?.elevationM??0)}observerAt(t,e){const i=ke(this.ufoElement.sighting,t);return{lat:i?.lat??e.lat,lng:i?.lng??e.lng,heightM:this.altitudeOf(i)}}announceTraffic(){this.isConnected&&(this.dispatchEvent(new CustomEvent(jL)),this.updateAstronomy(this.lastTimeMs))}async describeTraffic(t,e,i,n){if(!t.describe||!e.set||!e.tracks)return;const s=new Set([...e.set.flights.values()].map(l=>Je.keyOf(l))),r=e.tracks.filter(l=>s.has(Je.keyOf(l))&&l.points.length>0),a=new Map,c=new Map;await Promise.all(r.map(async l=>{const h=new Date(l.points[0].t).toISOString().slice(0,10),u=await t.describe(l,h).catch(()=>{});u&&(c.set(Je.keyOf(l),u),a.set(Je.keyOf(l),i.AircraftModels.of(u)))})),!(this.traffic!==e||a.size===0)&&(e.descriptions=c,e.models=a,e.set=n(i,a),this.planContrails(e,i),this.sortOutAudible(e,i),this.announceTraffic())}async readTrailTraffic(t,e,i,n,s,r){if(e.startMs===void 0)return;const a=await t.between(n,s,r).catch(()=>{});if(this.traffic!==e||a?.status!=="found")return;const c=a.tracks.filter(u=>u.points.some(d=>d.altitudeFt>=i.AircraftContrails.MIN_ALTITUDE_FT)),l=new Map(e.models??[]);if(t.describe&&await Promise.all(c.filter(u=>u.points.length>0&&!l.has(Je.keyOf(u))).map(async u=>{const d=await t.describe(u,new Date(u.points[0].t).toISOString().slice(0,10)).catch(()=>{});d&&l.set(Je.keyOf(u),i.AircraftModels.of(d))})),this.traffic!==e||e.startMs===void 0)return;const h=i.TrafficDecor.from(c,n,e.startMs,ve.TRAIL_MAX_AIRCRAFT,{models:l});e.trailSet=ve.alignTrailIds(h,e.set),e.models=new Map([...l,...e.models??[]]),this.planContrails(e,i),this.announceTraffic()}static alignTrailIds(t,e){if(!e)return t;const i=new Map;for(const[a,c]of e.flights){const l=e.presence.get(a);if(l)for(const[h,u]of t.flights){const d=t.presence.get(h);!d||Je.keyOf(u)!==Je.keyOf(c)||d.fromMs<=l.untilMs&&l.fromMs<=d.untilMs&&i.set(h,a)}}const n=a=>i.get(a)??`${a}-trail`,s=new Set(i.values()),r=e.objects.filter(a=>!s.has(a.id));return{...t,objects:[...t.objects.map(a=>({...a,id:n(a.id)})),...r],presence:new Map([...[...t.presence].map(([a,c])=>[n(a),c]),...r.map(a=>[a.id,e.presence.get(a.id)])]),flights:new Map([...[...t.flights].map(([a,c])=>[n(a),c]),...r.map(a=>[a.id,e.flights.get(a.id)])])}}async readUpperAir(t,e,i,n){if(!t.observer)return;const s=vh.held(this.ufoElement.sighting.snapshots,"upperAir");let r;if(s){const l=Mi.address(s.src,this.documentUrl);r=ve.upperAirProviders.get(l),r||ve.upperAirProviders.set(l,r=new gh(Mi.json(l)))}else{const l=this.upperAirSource??e.UPPER_AIR_SOURCES[0];r=ve.upperAirProviders.get(l.id),r||ve.upperAirProviders.set(l.id,r=l.create())}const a={lat:t.observer.lat,lng:t.observer.lng},c=await r.between(a,i,n);this.traffic!==t||c.status!=="found"||(s||(this.upperAirHeardLive={...a,startMs:i,endMs:n,answer:c}),t.air=c.samples,t.airSource=c.source,this.planContrails(t,e),this.announceTraffic())}planContrails(t,e){const i=t.trailSet??t.set;!i||!t.air||t.startMs===void 0||(t.contrails=e.AircraftContrails.plan(i,t.models,t.air,t.startMs))}contrailSunlight(t){const e=new Map,i=this.traffic,n=i?.trailSet??i?.set,s=this.lastSun;if(!i||!n||!s||!i.contrails?.length||i.startMs===void 0||!i.observer)return e;for(const r of i.contrails){const a=n.presence.get(r.id),c=n.flights.get(r.id);if(!a||!c)continue;const l=kn.positionAt(c,i.startMs+Math.min(a.untilMs,Math.max(a.fromMs,t)));l&&e.set(r.id,{heightM:l.geo.heightM,sunElevationDeg:ws.sunElevationDeg(s,i.observer,l.geo)})}return e}sunElevationAt(t,e){const i=zu("Sun",new Date(t.t),e);return ws.sunElevationDeg(i,e,t)}upperAirSource;upperAirHeardLive;get upperAirHeard(){return this.upperAirHeardLive}setUpperAirSource(t){t.id!==this.upperAirSource?.id&&(this.upperAirSource=t,this.traffic=void 0,this.decorMemo=void 0,this.updateAstronomy(this.lastTimeMs))}setAircraftSource(t,e=!1){!e&&t.id===this.aircraftSource.id||(this.aircraftSource=t,this.traffic=void 0,this.decorMemo=void 0,this.updateAstronomy(this.lastTimeMs))}get aircraftState(){const t=this.traffic?.contrails?.length?this.upperAirSource??ve.trafficRuntime?.UPPER_AIR_SOURCES[0]:void 0;return{trailCredit:t&&{credit:t.credit,creditUrl:t.creditUrl},status:this.traffic?.status??"none",problem:this.traffic?.problem,partial:this.traffic?.partial,creditsSpent:this.traffic?.creditsSpent,total:this.traffic?.set?.total??0,shown:this.traffic?.set?.shown??0,credit:this.aircraftSource.credit,creditUrl:this.aircraftSource.creditUrl}}get fireballState(){return{status:this.fireballs?.status??"none",records:this.fireballs?.records??[]}}ensureSatellites(t){this.ufoElement.sighting.skySources===!1&&(t=void 0);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=r=>{i===this.satelliteRequest&&(this.satelliteStatus=r,this.isConnected&&this.dispatchEvent(new CustomEvent(qL)))},s=ve.tleArchive;(async()=>{if(!await s.covers(t))return n("outside");const[r,a]=await Promise.all([s.at(t),dt(()=>import("./SatellitePasses-Pfro2-0Z.js"),[],import.meta.url)]);if(i===this.satelliteRequest){if(!r)return n("unavailable");this.satellites={snapshot:r,passes:new a.SatellitePasses(r.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}}burningCandidates(){return{reentries:this.ufoElement.sighting.skyEvents?.reentries??[],fireballs:this.fireballs?.reentries??[]}}trafficCandidates(){const t=this.traffic;if(!(t?.status!=="ready"||!t.tracks||t.startMs===void 0))return{tracks:t.tracks,startMs:t.startMs,describe:e=>t.descriptions?.get(Je.keyOf(e))}}satellitePositionsAt(t){const e=this.satellites,i=this.ufoElement.sighting,n=ke(i,0),s=i.event.place?.[0],r=n?.lat??s?.lat,a=n?.lng??s?.lng;if(!(!e||r===void 0||a===void 0))return e.passes.positionsAt(t,{lat:r,lng:a,elevationM:this.altitudeOf(n)})}satellitePassesDuring(t){const e=this.satellites,i=this.ufoElement.sighting,n=ke(i,0),s=i.event.place?.[0],r=n?.lat??s?.lat,a=n?.lng??s?.lng;if(!e||r===void 0||a===void 0)return[];const c=bc(i.event.time??{},a,i.event.utcOffsetHours);if(!c)return[];const l=Math.min(Math.max(t,0),4*36e5),h={lat:r,lng:a,elevationM:this.altitudeOf(n)},u=JSON.stringify([this.satellitesFor,c.getTime(),r,a,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=kL.brightestAt(t,e);if(i)return{id:i.apparition.id,position:i.position,tailEnd:i.tailEnd,magnitude:i.magnitude}}approachOf(t,e){return this.approaches.of.has(e)||this.approaches.of.set(e,od.of(t,e)),this.approaches.of.get(e)}pushPhenomenaAt(t){const e=this.ufoElement.sighting;e!==this.sizeEstimatesFor&&(this.sizeEstimates.clear(),this.distanceHypotheses.clear(),this.sizeEstimatesFor=e);const i=JSON.stringify([e.timeline.allKeyframes.map(g=>[g.t,g.shapes.map(m=>[m.sourceId,m.shape.angular?.widthDeg,m.shape.aim?.azimuthDeg])]),e.observerTrack.allKeyframes,e.event.place?.[0]]);i!==this.approaches.key&&(this.approaches={key:i,of:new Map});const n=e.timeline,s=this.ufoElement.canvasElement,r=this.ufoElement.frameShiftPx,a=this.projectionAt(t),c=new Map,l=new Map,h=new Set;for(const g of n.sourceIds){const m=n.getInterpolatedShapeAt(t,g);if(!m)continue;const M={...m,bounds:{...m.bounds,x:m.bounds.x+r.x,y:m.bounds.y+r.y}};c.set(g,M);const v=m.aim?this.sceneRenderer.screenPointOf(Ns.directionOf(m.aim,this.directionScratch)):{ndcX:(M.bounds.x+M.bounds.width/2)/s.width*2-1,ndcY:-((M.bounds.y+M.bounds.height/2)/s.height*2-1)},x=v!==void 0&&Math.abs(v.ndcX)<=1&&Math.abs(v.ndcY)<=1,y=x?this.sceneRenderer.decorDistancesAt(v.ndcX,v.ndcY,g):{};h.add(g),(x||m.aim)&&h.delete(g);const w=m.angular?.widthDeg??a.pxToDeg(m.bounds.width),b=this.sizeEstimateOf(g);b.add(w,y);const E=this.approachOf(e,g);l.set(g,vs.resolve({hypothesisM:this.distanceHypotheses.get(g),derivedM:E&&w>0?fi.distanceMAt(E.widthM,w):void 0,range:b.distanceRangeAt(w),crossing:y}))}for(const[g,m]of c)for(const[M,v]of c){if(M===g||v.transparency>=1||v.bounds.width*v.bounds.height<=m.bounds.width*m.bounds.height||!(m.bounds.x>=v.bounds.x&&m.bounds.y>=v.bounds.y&&m.bounds.x+m.bounds.width<=v.bounds.x+v.bounds.width&&m.bounds.y+m.bounds.height<=v.bounds.y+v.bounds.height))continue;const y=l.get(M);y&&l.set(g,{distanceM:y.distanceM*.999,basis:y.basis});break}this.depths=l;const u=n.sourceIds,d=[];for(const[g,m]of c)d.push({sourceId:g,shape:m,distanceM:l.get(g).distanceM,renderOrder:u.indexOf(g),aim:m.aim,hidden:h.has(g)||this.interpretationShown!==void 0&&(!this.comparing||m.transparency>=1),ghost:this.interpretationShown!==void 0&&this.comparing});const f=ke(e,t),p=(f?.rollDeg??0)+oi.bodyAt(e,t,this.ufoElement.steadyBody).rollDeg;this.sceneRenderer.setPhenomena(d,{projection:a,canvasWidthPx:s.width,canvasHeightPx:s.height,scale:Math.max(1,this.sceneCanvas.height/Math.max(1,s.height)),starPoints:Ji.starPointsOf(e.instrument,f?.fNumber),rollRad:p*Math.PI/180})}get interpretation(){return this.interpretationShown}set interpretation(t){this.showInterpretation(t),this.ufoElement.playerTitle=t?.title,this.ufoElement.refreshSoundControls(),this.syncAccountHidden(),this.updateAstronomy(this.lastTimeMs),this.ufoElement.repaintChrome()}redrawSky(){this.updateAstronomy(this.lastTimeMs)}syncAccountHidden(){this.ufoElement.accountHidden=this.interpretationShown!==void 0&&!this.comparing}get accountInTheRound(){return this.inTheRound}set accountInTheRound(t){this.inTheRound=t}get compareAccount(){return this.comparing}set compareAccount(t){t!==this.comparing&&(this.comparing=t,this.syncAccountHidden(),this.updateAstronomy(this.lastTimeMs),this.ufoElement.repaintChrome())}get confrontation(){return this.confrontationReadings}groundAlong(t,e,i){const n=this.sceneRenderer.bodyGround,s=Lt.eyeOf(this.ufoElement.sighting,i,n);return s?Lt.lineOfSightMeetsGround(s,t,e,n):void 0}bodyMaskedBy(t,e){return this.sceneRenderer.bodyMaskedByDecor(t,e)}bodyReading(t,e){const i=this.sceneRenderer.bodyGround,n=this.ufoElement.sighting,s=d=>Lt.eyeOf(n,d,i),r=new Lt(t,i,s).at(e),a=s(e);if(!r||!a)return;const c=r.eastM-a.eastM,l=r.northM-a.northM,h=r.upM-a.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:r.eastM,northM:r.northM,aboveGroundM:r.upM-r.sizeM.heightM/2-i.heightAt(r.eastM,r.northM),sizeM:r.sizeM,attitude:r.attitude,appearance:r.appearance}}bodyProjectionAt(t,e){const i=this.sceneRenderer.bodyGround,n=this.ufoElement.sighting,s=c=>Lt.eyeOf(n,c,i),r=new Lt(t,i,s).at(e),a=s(e);return r&&a?ci.projectionOf(r,a):void 0}directionToDecor(t){return this.sceneRenderer.directionToDecor(t)}directionToBody(t,e){const i=this.sceneRenderer.bodyGround,n=this.ufoElement.sighting,s=p=>Lt.eyeOf(n,p,i),r=new Lt(t,i,s),a=r.at(e)?e:t.track[0]?.t,c=a===void 0?void 0:r.at(a),l=a===void 0?void 0:s(a);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=[],r=[];const a=this.sceneRenderer.bodyGround,c=p=>Lt.eyeOf(n,p,a);i&&(s=i.bodies.map(p=>new Lt(p,a,c).at(t)).filter(p=>p!==void 0));const l=eu(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&&(r=new ci(n.timeline,this.confrontationTolerance,ci.sizeHows(n.timeline,n.provenance),qs.seeingOf(n)).at(t,s,d,p=>p.outlineNode?this.sceneRenderer.bodyOutline?.(p.id,p.outlineNode):void 0)),this.confrontationReadings=r,!e)return;const f=JSON.stringify(r);f!==this.confrontationSignature&&(this.confrontationSignature=f,this.dispatchEvent(new CustomEvent(QL,{detail:r})))}async pictureAt(t,e=640){const i=document.createElement("canvas");i.width=e,i.height=Math.round(e*(this.sceneCanvas.height||9)/(this.sceneCanvas.width||16));let n=!1;for(const s of[1200,0]){this.showAt(t),n=!1;for(let r=0;r<900&&!n;r++)await new Promise(a=>requestAnimationFrame(()=>a())),n=this.snapshotTo(i);if(!n)return;s&&await new Promise(r=>setTimeout(r,s))}return i.toDataURL("image/jpeg",.85)}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(r=>r.t>n&&r.t<=e).pop();s&&eu(t,s.t).storm&&this.handleLightningFlash(s)}ensureLightningSchedule(t){const e=eu(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],r=n?.year!==void 0?bc(n,s?.lng??0,t.event.utcOffsetHours):void 0,a=(t.event.durationSeconds??0)*1e3||t.timeline.duration||2e4,c=Math.round((r?.getTime()??0)/1e3)+Math.round((s?.lat??0)*1e3)+7;this.lightningFlashes=pn.schedule({durationMs:a,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,t.skySources])}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?bc(i,e.lng,t.event.utcOffsetHours):void 0;if(!n||e?.lat===void 0||e.lng===void 0||t.skySources===!1){this.sceneRenderer.setMeteorShower([],0,0);return}const s={lat:e.lat,lng:e.lng,elevationM:0},r=(t.event.durationSeconds??0)*1e3||t.timeline.duration||2e4,a=Math.round(n.getTime()/1e3)+Math.round(e.lat*1e3),c=qi.schedule({ratePerHour:qi.observedRatePerHour(qi.apexPosition(n,s).altitudeDeg),durationMs:r,velocityKmS:qi.TYPICAL_VELOCITY_KM_S,seed:a}),l=a1.activeAt(n).map(u=>{const d=a1.radiantPosition(u.shower,n,s);return{entry:u,position:d,rate:a1.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=pr.schedule({ratePerHour:l.rate,durationMs:r,velocityKmS:l.entry.shower.velocityKmS,seed:a+1});this.sceneRenderer.setMeteorShower([...h,...c],l.position.altitudeDeg,l.position.azimuthDeg)}groundHides(t,e){return this.sceneRenderer.groundHidesDirection(t,e)}get groundKey(){return this.sceneRenderer.groundKey}meteorByRank(t,e=Number.POSITIVE_INFINITY){this.ensureMeteorSchedule(this.ufoElement.sighting);const i=[...this.sceneRenderer.meteorSchedule].filter(r=>r.t+r.durationMs<=this.ufoElement.seekableDuration).filter(r=>pr.magnitudeOf(r)<=e).filter(r=>{const a=this.sceneRenderer.meteorMidpoint(r);return a!==void 0&&!this.sceneRenderer.groundHidesDirection(a.altitudeDeg,a.azimuthDeg)}).sort((r,a)=>a.brightness-r.brightness);if(i.length===0)return;const n=i[t%i.length],s=this.sceneRenderer.meteorMidpoint(n);if(s)return{t:Math.round(n.t+n.durationMs*.45),...s}}lensOpticsAt(t){const e=this.ufoElement.sighting,i=e.instrument,n=i.frame,s=ke(e,t),r=s?.fNumber??i.fNumber;if(!n||r===void 0)return;const a=Ji.focalLengthMmFor(i,vn.fovOf(e,t));if(a!==void 0)return{focalLengthMm:a,fNumber:r,focusDistance:s?.focusDistanceM??0,frameHeightMm:n.heightMm}}projectionAt(t){const e=this.ufoElement.sighting;return da.of(e.instrument,fi.CANVAS_HEIGHT_PX,vn.fovOf(e,t))}sizeEstimateOf(t){let e=this.sizeEstimates.get(t);return e||(e=new UL,this.sizeEstimates.set(t,e)),e}}const QM="rr0-scene";function r7(){Jb(),customElements.get(QM)||customElements.define(QM,ve)}r7();export{Xu as $,er as A,we as B,at as C,cd as D,De as E,pe as F,We as G,Ve as H,x7 as I,ta as J,St as K,Uw as L,Te as M,so as N,Yn as O,Qt as P,l7 as Q,Pt as R,Gi as S,Je as T,NR as U,_ as V,qe as W,c5 as X,tM as Y,Js as Z,dt as _,kn as a,Ov as a$,oc as a0,Kl as a1,Es as a2,An as a3,v7 as a4,$c as a5,Dn as a6,bi as a7,ii as a8,Qi as a9,gx as aA,M7 as aB,w7 as aC,yE as aD,tr as aE,ff as aF,_m as aG,K5 as aH,ec as aI,w1 as aJ,ji as aK,Ta as aL,QT as aM,di as aN,h7 as aO,d7 as aP,SE as aQ,f7 as aR,nr as aS,wE as aT,kx as aU,KT as aV,BA as aW,ip as aX,j1 as aY,FE as aZ,Pv as a_,$n as aa,Ep as ab,ds as ac,p7 as ad,Un as ae,Gn as af,Li as ag,ln as ah,ps as ai,ki as aj,Ld as ak,Er as al,Jl as am,HL as an,oy as ao,GL as ap,a7 as aq,c7 as ar,o7 as as,ef as at,y7 as au,g7 as av,rp as aw,zE as ax,dp as ay,u7 as az,wi as b,ze as b0,ba as b1,tf as b2,Ct as b3,En as b4,Ie as b5,Zr as b6,Cr as b7,Lo as b8,I0 as b9,xb as bA,Cv as bB,Jo as bC,Ea as bD,As as bE,fs as bF,Zh as bG,tn as bH,fr as ba,C0 as bb,ys as bc,ya as bd,Si as be,nc as bf,Kd as bg,gt as bh,rO as bi,Dh as bj,Wt as bk,ah as bl,Uv as bm,Ht as bn,Tr as bo,ca as bp,a1 as bq,zu as br,e5 as bs,bc as bt,ke as bu,Nn as bv,k_ as bw,eu as bx,Ii as by,o1 as bz,is as c,Xb as d,Gs as e,Yb as f,FR as g,Vt as h,Kn as i,Dr as j,Re as k,zs as l,tt as m,ae as n,pt as o,$u as p,Me as q,ga as r,Ya as s,ye as t,yr as u,S7 as v,lp as w,m7 as x,Ge as y,vr as z};
|