@rr0/ufoathome 0.188.0 → 0.188.1
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/{BirdEditor-B76KBLOl.js → BirdEditor-C7dHFbA6.js} +1 -1
- package/dist-embed-scene/LanternEditor-D2mmscWP.js +24 -0
- package/dist-embed-scene/{ModuleSession-CwJVkcpn.js → ModuleSession-BAeWIbSU.js} +2 -2
- package/dist-embed-scene/{ModuleThree-BHjFJ_bC.js → ModuleThree-BLw9W-dX.js} +1 -1
- package/dist-embed-scene/rr0-scene.mjs +7 -7
- package/dist-embed-sighting/{BeamEditor-DBOpFVUB.js → BeamEditor-B1s17C_I.js} +1 -1
- package/dist-embed-sighting/{BeamSystem-5WJWP1Ad.js → BeamSystem-DTraCa17.js} +1 -1
- package/dist-embed-sighting/{BirdEditor-mGkxSXV0.js → BirdEditor-B__-UnpK.js} +1 -1
- package/dist-embed-sighting/{CaseReportExport-Bq5fbuEj.js → CaseReportExport-DbGfu7DP.js} +1 -1
- package/dist-embed-sighting/{GLTFLoader-BrNCkGT3.js → GLTFLoader-61IhKnLS.js} +1 -1
- package/dist-embed-sighting/LanternEditor-DIun2igg.js +24 -0
- package/dist-embed-sighting/{LaserBeam-BuVmy_0s.js → LaserBeam-R7ItI6m-.js} +1 -1
- package/dist-embed-sighting/{LaunchEditor-CTMGimHR.js → LaunchEditor-CbQXmqaL.js} +1 -1
- package/dist-embed-sighting/{LaunchPlume-Quo7JzI8.js → LaunchPlume-uRfBKA0Y.js} +1 -1
- package/dist-embed-sighting/{LaunchSimulation-DZ4pDnrh.js → LaunchSimulation-DgsYJUKz.js} +1 -1
- package/dist-embed-sighting/{ModuleSession-xCJtw_IT.js → ModuleSession-CDsk4Atg.js} +2 -2
- package/dist-embed-sighting/ModuleThree-ZXC7TlGn.js +1 -0
- package/dist-embed-sighting/{ParameterForm-D4tIZ54J.js → ParameterForm-CkZQ1FlH.js} +1 -1
- package/dist-embed-sighting/{ReentryEditor-gT2NnDI5.js → ReentryEditor-DS0nJdBD.js} +2 -2
- package/dist-embed-sighting/{ReentrySimulation-BnYP6UwW.js → ReentrySimulation-BDnSb3zB.js} +1 -1
- package/dist-embed-sighting/{TimelineTracks-BjJwL-DC.js → TimelineTracks-CvGxdpGb.js} +1 -1
- package/dist-embed-sighting/rr0-sighting.mjs +13 -13
- package/dist-embed-sighting-editor/{BallesterGuaspAssessor-BpmT6OKS.js → BallesterGuaspAssessor-DysBC5VV.js} +1 -1
- package/dist-embed-sighting-editor/{BeamEditor-BawKO8H-.js → BeamEditor-DQcdww5w.js} +1 -1
- package/dist-embed-sighting-editor/{BeamSystem-BA8EOscq.js → BeamSystem-d2pPAwht.js} +1 -1
- package/dist-embed-sighting-editor/{BirdEditor-BDOoYRVO.js → BirdEditor-CsyXenUx.js} +1 -1
- package/dist-embed-sighting-editor/{CaseReportExport-B_eY0L0k.js → CaseReportExport-Cc4W9Lim.js} +1 -1
- package/dist-embed-sighting-editor/{ContrailSystem-expk-hcJ.js → ContrailSystem-B4tXvQXF.js} +1 -1
- package/dist-embed-sighting-editor/{ControlPasses-DjuFMJPj.js → ControlPasses-Bo1RUT7-.js} +1 -1
- package/dist-embed-sighting-editor/{CoverageAssessor-OL8FwC51.js → CoverageAssessor-tRNaBy0f.js} +1 -1
- package/dist-embed-sighting-editor/{GLTFLoader-BLDypTtN.js → GLTFLoader-B3aYB7cS.js} +1 -1
- package/dist-embed-sighting-editor/{HeadlightSystem-Dm_TsC1R.js → HeadlightSystem-YWAhxcbe.js} +1 -1
- package/dist-embed-sighting-editor/{HynekAssessor-DAYUme2x.js → HynekAssessor-IoHDLJUa.js} +1 -1
- package/dist-embed-sighting-editor/LanternEditor-BYeK9kFU.js +24 -0
- package/dist-embed-sighting-editor/{LaserBeam-D5ZQPR6m.js → LaserBeam-DOGz1dOz.js} +1 -1
- package/dist-embed-sighting-editor/{LaunchEditor-DAq_SFrv.js → LaunchEditor-0BCDGChg.js} +1 -1
- package/dist-embed-sighting-editor/{LaunchPlume-DUxOB50r.js → LaunchPlume-DdX9-Rlw.js} +1 -1
- package/dist-embed-sighting-editor/{LaunchSimulation-DIzy0Xw3.js → LaunchSimulation-BkdI45NE.js} +1 -1
- package/dist-embed-sighting-editor/{ModuleConformance-DuH_TuHw.js → ModuleConformance-C-KZlNCi.js} +2 -2
- package/dist-embed-sighting-editor/{ModuleSession-BBUcHOq4.js → ModuleSession-B8U-T57q.js} +2 -2
- package/dist-embed-sighting-editor/ModuleThree-Ce5HhfdG.js +1 -0
- package/dist-embed-sighting-editor/{ModulesPanelElement-SCFylxD6.js → ModulesPanelElement-BndWwnmX.js} +3 -3
- package/dist-embed-sighting-editor/{NearestApproach-Bubj_A1N.js → NearestApproach-C48vgZ_Z.js} +1 -1
- package/dist-embed-sighting-editor/{PoherAssessor-0QbtKuaf.js → PoherAssessor-DRLbEZBS.js} +1 -1
- package/dist-embed-sighting-editor/{RailwaySystem-BdEv3g84.js → RailwaySystem-SB2r1oRG.js} +1 -1
- package/dist-embed-sighting-editor/{ReentryEditor-DWR69i5W.js → ReentryEditor-JhfAVd18.js} +1 -1
- package/dist-embed-sighting-editor/{ReentrySimulation-CFa2_NSJ.js → ReentrySimulation-DpIG9b07.js} +1 -1
- package/dist-embed-sighting-editor/{ReferenceSystem-Bm9Javlm.js → ReferenceSystem-DlpoDXXV.js} +1 -1
- package/dist-embed-sighting-editor/{TraceSystem-DfSwlqhV.js → TraceSystem-Cz4lbziC.js} +2 -2
- package/dist-embed-sighting-editor/{WaterSystem-D3WEELlK.js → WaterSystem-C39XDvNY.js} +2 -2
- package/dist-embed-sighting-editor/rr0-sighting-editor.mjs +18 -16
- package/package.json +1 -1
- package/dist-embed-scene/LanternEditor-BRH4wcQ9.js +0 -9
- package/dist-embed-sighting/LanternEditor-F5ApaFs3.js +0 -9
- package/dist-embed-sighting/ModuleThree-D1QGUDll.js +0 -1
- package/dist-embed-sighting-editor/LanternEditor-Bi-khJJw.js +0 -9
- package/dist-embed-sighting-editor/ModuleThree-C9HnaBjO.js +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./LanternEditor-
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./LanternEditor-DIun2igg.js","./ParameterForm-CkZQ1FlH.js","./SkyLantern--RJZtEMU.js","./BirdEditor-B__-UnpK.js","./BirdFlock-BbObIeXW.js","./TimelineTracks-CvGxdpGb.js","./HynekAssessor-CJ9APziM.js","./NearestApproach-iBLl7o1g.js","./BallesterGuaspAssessor-CLQvJKlm.js","./CoverageAssessor-BSoRnjHD.js","./BeamSystem-DTraCa17.js","./LaserBeam-R7ItI6m-.js","./BeamEditor-B1s17C_I.js","./LaunchSimulation-DgsYJUKz.js","./LaunchPlume-uRfBKA0Y.js","./LaunchEditor-CbQXmqaL.js","./ReentryEditor-DS0nJdBD.js","./ContrailSystem-C1pCwq7H.js","./ContrailGrowth-DwHS8If9.js","./trafficRuntime-CFgDqQz4.js","./GenerativeKit-BmhvjjzB.js","./browser-CltifEM0.js","./VideoExport-B8ZhHNnd.js"])))=>i.map(i=>d[i]);
|
|
2
2
|
class Z3 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 lr{static CURRENT={sighting:4,case:1,interview:1};static SCHEMA_BASE="https://ufoathome.org/schema";static schemaUrl(t,e=lr.CURRENT[t]){return`${lr.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 lr.check(t,"sighting")}static check(t,e){const i=lr.of(t),n=lr.CURRENT[e];if(typeof i!="number"||!Number.isInteger(i)||i!==n)throw new Z3(e,i,n);return t}}class Je{constructor(t){this.entries=t}static free(t){return t?.basis==="assumed"||t?.basis==="fitted"}static empty(){return new Je(new Map)}get size(){return this.entries.size}at(t){return this.entries.get(t)}paths(){return[...this.entries.keys()]}sourced(){return[...this.entries].filter(([,t])=>t.source!==void 0).map(([t,e])=>({path:t,basis:e.basis,source:e.source}))}interviewsCited(){const t=[];for(const{source:e}of this.sourced()){const i=e.said?.interview;i!==void 0&&!t.includes(i)&&t.push(i)}return t}pathsFromInterview(t){return this.sourced().filter(({source:e})=>e.said!==void 0&&e.said.interview===t).map(({path:e})=>e)}set(t,e){e.basis==="stated"&&e.rationale===void 0&&e.how===void 0&&e.range===void 0&&e.source===void 0?this.entries.delete(t):this.entries.set(t,e)}clear(t){for(const e of this.entries.keys())(e===t||e.startsWith(`${t}.`))&&this.entries.delete(e)}static strip(t){const e=new Je(new Map);return{recording:Je.stripValue(t,[],e),provenance:e}}static restore(t,e){if(e.size===0)return t;const i={...t},n=new Set([i]);for(const s of e.paths()){const r=e.at(s),a=s.split("."),c=Je.writableHolderOf(i,a,n);if(!c)continue;const l=a[a.length-1],h=c[l];h!==void 0&&(r.of!==void 0&&JSON.stringify(r.of)!==JSON.stringify(h)||(c[l]={value:h,...r.basis==="stated"?{}:{basis:r.basis},...r.rationale===void 0?{}:{rationale:r.rationale},...r.how===void 0?{}:{how:r.how},...r.range===void 0?{}:{range:r.range},...r.source===void 0?{}:{source:r.source}}))}return i}static isWrapper(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)&&"value"in t}static stripValue(t,e,i){return Je.isWrapper(t)?(i.set(e.join("."),{basis:t.basis??"stated",...t.rationale===void 0?{}:{rationale:t.rationale},...t.how===void 0?{}:{how:t.how},...t.range===void 0?{}:{range:t.range},...t.source===void 0?{}:{source:t.source},of:t.value}),Je.stripValue(t.value,e,i)):Array.isArray(t)?t.map((n,s)=>Je.stripValue(n,[...e,String(s)],i)):typeof t=="object"&&t!==null?Object.fromEntries(Object.entries(t).map(([n,s])=>[n,Je.stripValue(s,[...e,n],i)])):t}static writableHolderOf(t,e,i){let n=t;for(const s of e.slice(0,-1)){const r=n[s];if(typeof r!="object"||r===null)return;if(i.has(r)){n=r;continue}const a=Array.isArray(r)?[...r]:{...r};i.add(a),n[s]=a,n=a}return n}}class Xh{static ISO=/^P(?:(\d+(?:[.,]\d+)?)W)?(?:(\d+(?:[.,]\d+)?)D)?(?:T(?:(\d+(?:[.,]\d+)?)H)?(?:(\d+(?:[.,]\d+)?)M)?(?:(\d+(?:[.,]\d+)?)S)?)?$/;static seconds(t){const e=t.trim().toUpperCase(),i=Xh.ISO.exec(e);if(!i||e==="P"||e.endsWith("T"))return;const[,n,s,r,a,c]=i,l=u=>u===void 0?0:Number(u.replace(",",".")),h=l(n)*604800+l(s)*86400+l(r)*3600+l(a)*60+l(c);return Number.isFinite(h)?h:void 0}static parse(t){let e=t.trim();if(e==="")return;const i=e.slice(-1),n="?~%".includes(i)?i:"";n!==""&&(e=e.slice(0,-1).trim());const s=e.split("/");if(s.length>2)return;const r=s.map(u=>Xh.seconds(u));if(r.some(u=>u===void 0))return;const[a,c]=r,l=Math.min(a,c??a),h=Math.max(a,c??a);return{doubt:n,minSeconds:l,maxSeconds:h,chosenSeconds:(l+h)/2}}static isExact(t){const e=Xh.parse(t);return e!==void 0&&e.doubt===""&&e.minSeconds===e.maxSeconds}static format(t){const e=Math.max(0,Math.round(t*10)/10),i=Math.floor(e/3600),n=Math.floor(e%3600/60),s=Math.round(e%60*10)/10;return`PT${`${i>0?`${i}H`:""}${n>0?`${n}M`:""}${s>0||i===0&&n===0?`${s}S`:""}`}`}static say(t){const e=Math.round(t*10)/10;if(e<60)return`${e} s`;const i=Math.floor(e/3600),n=Math.floor(e%3600/60),s=Math.round(e%60*10)/10,r=[];return i>0&&r.push(`${i} h`),n>0&&r.push(`${n} min`),s>0&&r.push(`${s} s`),r.join(" ")}}class mi{static MOON_ANGULAR_WIDTH_DEG=.5237;static CANVAS_WIDTH_PX=640;static CANVAS_HEIGHT_PX=360;static angularWidthDeg(t){return 2*Math.atan(t.sizeM/(2*t.distanceM))*180/Math.PI}static inMoons(t){return t/mi.MOON_ANGULAR_WIDTH_DEG}static lerpAngular(t,e,i){if(!(!t||!e))return{widthDeg:t.widthDeg+(e.widthDeg-t.widthDeg)*i,heightDeg:t.heightDeg+(e.heightDeg-t.heightDeg)*i}}static sizeMAt(t,e){return 2*t*Math.tan(e*Math.PI/360)}static distanceMAt(t,e){return t/(2*Math.tan(e*Math.PI/360))}}function J3(o,t,e){if(!o||!t)return e<1?o:t;const i=((t.azimuthDeg-o.azimuthDeg)%360+540)%360-180;return{azimuthDeg:((o.azimuthDeg+i*e)%360+360)%360,altitudeDeg:o.altitudeDeg+(t.altitudeDeg-o.altitudeDeg)*e}}function j3(o,t,e){const{bounds:i}=o;return t>=i.x&&t<=i.x+i.width&&e>=i.y&&e<=i.y+i.height}function Bs(o,t,e){return o+(t-o)*e}function c2(o){const t=/^#([0-9a-f]{6})$/i.exec(o);if(!t)return;const e=parseInt(t[1],16);return[e>>16&255,e>>8&255,e&255]}function Q3(o){return`#${o.map(t=>Math.round(t).toString(16).padStart(2,"0")).join("")}`}function t_(o,t,e){const i=c2(o),n=c2(t);return!i||!n?e<1?o:t:Q3([Bs(i[0],n[0],e),Bs(i[1],n[1],e),Bs(i[2],n[2],e)])}function e_(o,t,e){const i={x:Bs(o.bounds.x,t.bounds.x,e),y:Bs(o.bounds.y,t.bounds.y,e),width:Bs(o.bounds.width,t.bounds.width,e),height:Bs(o.bounds.height,t.bounds.height,e)},n=Bs(o.angle,t.angle,e),s=Bs(o.transparency,t.transparency,e),r=Bs(o.haloScale,t.haloScale,e),a=Bs(o.blur??0,t.blur??0,e),c=Bs(o.brightness??0,t.brightness??0,e),l=t_(o.color,t.color,e),h=mi.lerpAngular(o.angular,t.angular,e),u=J3(o.aim,t.aim,e);return o.kind==="polygon"&&t.kind==="polygon"&&o.points.length===t.points.length?{...o,bounds:i,angle:n,transparency:s,haloScale:r,blur:a,brightness:c,color:l,angular:h,aim:u,points:o.points.map((d,f)=>({x:Bs(d.x,t.points[f].x,e),y:Bs(d.y,t.points[f].y,e)}))}:{...e<1?o:t,bounds:i,angle:n,transparency:s,haloScale:r,blur:a,brightness:c,color:l,angular:h,aim:u}}class Vo{static DEFAULT_COLOR="#e8e6df";static complete(t,e=[]){const i=new Map;return t.map((n,s)=>({keyframe:n,index:s})).sort((n,s)=>n.keyframe.t-s.keyframe.t).map(({keyframe:n,index:s})=>({t:n.t,shapes:(n.shapes??[]).map((r,a)=>{const c=`timeline.keyframes.${s}.shapes.${a}.shape`,l=Vo.completed(r,i.get(r.sourceId),c,e);return i.set(r.sourceId,l),{sourceId:r.sourceId,shape:l}})}))}static thin(t,e){const i=new Map,n=new Set;return t.map((s,r)=>({t:s.t,shapes:s.shapes.map(a=>{const c=i.get(a.sourceId);if(i.set(a.sourceId,a.shape),!c)return{sourceId:a.sourceId,shape:a.shape};const l=Vo.thinned(a.shape,c);if(e){const h=l;e(r,a.sourceId)?(delete h.bounds,delete h.points,n.add(a.sourceId)):n.delete(a.sourceId)&&(h.bounds=a.shape.bounds,a.shape.kind==="polygon"&&(h.points=a.shape.points),a.shape.aim&&(h.aim=a.shape.aim),a.shape.angular&&(h.angular=a.shape.angular))}return{sourceId:a.sourceId,shape:l}})}))}static thinned(t,e){const i=e,n={};for(const[s,r]of Object.entries(t))(typeof r=="object"&&r!==null&&!Array.isArray(r)&&"value"in r||r!==i[s]&&JSON.stringify(r)!==JSON.stringify(i[s]))&&(n[s]=r);return"bounds"in n&&(t.aim&&(n.aim=t.aim),t.angular&&(n.angular=t.angular)),n}static completed(t,e,i,n){const s=t.shape??{},r=e??Vo.firstAppearance(s,i,n),a={...r};s.bounds&&e&&(e.aim||e.angular)&&!s.aim&&!s.angular&&n.push({kind:"pixels-over-angles",path:i}),s.bounds&&(s.aim||delete a.aim,s.angular||delete a.angular);const c=s.kind??r.kind??"oval",l={...a,...s,kind:c};if(c==="polygon"&&!l.points){n.push({kind:"defaulted",path:`${i}.points`,expected:"rectangle"});const{width:h,height:u}=l.bounds;return{...l,points:[{x:0,y:0},{x:h,y:0},{x:h,y:u},{x:0,y:u}]}}return l}static firstAppearance(t,e,i){return t.kind||i.push({kind:"defaulted",path:`${e}.kind`,expected:'"oval"'}),t.color||i.push({kind:"defaulted",path:`${e}.color`,expected:`"${Vo.DEFAULT_COLOR}"`}),!t.bounds&&!t.aim&&i.push({kind:"unplaced",path:e}),!t.bounds&&!t.angular&&i.push({kind:"unsized",path:e}),{kind:t.kind??"oval",bounds:{...Vo.NEUTRAL_BOUNDS},color:Vo.DEFAULT_COLOR,angle:0,transparency:0,haloScale:0,selected:!1}}static NEUTRAL_BOUNDS={x:mi.CANVAS_WIDTH_PX/2,y:mi.CANVAS_HEIGHT_PX/2,width:1,height:1}}class Tf{keyframes=[];order=[];groups=[];span=0;addKeyframe(t,e){const i=this.findInsertIndex(t);if(this.keyframes[i]?.t===t){const n=new Set(e.map(s=>s.sourceId));this.keyframes[i]={t,shapes:[...this.keyframes[i].shapes.filter(s=>!n.has(s.sourceId)),...e]}}else this.keyframes.splice(i,0,{t,shapes:[...e]});for(const n of e)this.order.includes(n.sourceId)||this.order.push(n.sourceId)}findInsertIndex(t){let e=0,i=this.keyframes.length;for(;e<i;){const n=e+i>>>1;this.keyframes[n].t<t?e=n+1:i=n}return e}getKeyframeAt(t){const e=this.findInsertIndex(t),i=this.keyframes[e];return i?.t===t?i:void 0}getShapeAt(t,e){return this.getKeyframeAt(t)?.shapes.find(i=>i.sourceId===e)?.shape}getLatestShapeAt(t,e){let i=this.findInsertIndex(t);for(this.keyframes[i]?.t!==t&&(i-=1);i>=0;i--){const n=this.keyframes[i].shapes.find(s=>s.sourceId===e);if(n)return n.shape}}getInterpolatedShapeAt(t,e){const i=this.findShapeAtOrBefore(t,e);if(i?.t===t)return i.shape;const n=this.findShapeAtOrAfter(t,e);return i?n?e_(i.shape,n.shape,(t-i.t)/(n.t-i.t)):i.shape:n?.shape}findShapeAtOrBefore(t,e){let i=this.findInsertIndex(t);for(this.keyframes[i]?.t!==t&&(i-=1);i>=0;i--){const n=this.keyframes[i].shapes.find(s=>s.sourceId===e);if(n)return{t:this.keyframes[i].t,shape:n.shape}}}findShapeAtOrAfter(t,e){for(let i=this.findInsertIndex(t);i<this.keyframes.length;i++){const n=this.keyframes[i].shapes.find(s=>s.sourceId===e);if(n)return{t:this.keyframes[i].t,shape:n.shape}}}hitTest(t,e,i,n){const s=this.sourceIds;for(let r=s.length-1;r>=0;r--){if(n?.has(s[r]))continue;const a=this.getInterpolatedShapeAt(t,s[r]);if(a&&j3(a,e,i))return{sourceId:s[r],shape:a}}}removeSource(t){for(let e=this.keyframes.length-1;e>=0;e--){const i=this.keyframes[e].shapes.filter(n=>n.sourceId!==t);i.length===0?this.keyframes.splice(e,1):i.length!==this.keyframes[e].shapes.length&&(this.keyframes[e]={t:this.keyframes[e].t,shapes:i})}this.order=this.order.filter(e=>e!==t),this.removeFromGroup(t)}removeShapeAt(t,e){const i=this.findInsertIndex(t),n=this.keyframes[i];if(n?.t!==t)return;const s=n.shapes.filter(r=>r.sourceId!==e);s.length===0?this.keyframes.splice(i,1):s.length!==n.shapes.length&&(this.keyframes[i]={t,shapes:s})}group(t,e){const i=new Set(t),n=[];for(const r of t){const a=this.topOf(r),c=a!==r&&this.leavesOf(a).every(l=>i.has(l))?a:r;c===r&&a!==r&&this.removeFromGroup(r),n.includes(c)||n.push(c)}if(n.length<2)return;const s=e??this.freshGroupId();return this.groups.push({id:s,members:n}),s}ungroup(t){const e=this.topOf(t);e!==t&&(this.groups=this.groups.filter(i=>i.id!==e))}groupMembers(t){const e=this.topOf(t);return e===t?void 0:this.leavesOf(e)}get allGroups(){return this.groups}setGroups(t,e=!0){this.groups=t.map(i=>({...i,members:[...i.members]})),e&&this.pruneGroups()}groupOf(t){return this.groups.find(e=>e.id===t)}leavesOf(t,e=new Set){const i=this.groupOf(t);return i?e.has(t)?[]:(e.add(t),i.members.flatMap(n=>this.leavesOf(n,e))):[t]}parentOf(t){return this.groups.find(e=>e.members.includes(t))}topOf(t){let e=t;for(let i=this.parentOf(e),n=0;i&&n<100;i=this.parentOf(e),n++)e=i.id;return e}freshGroupId(){for(let t=this.groups.length+1;;t++){const e=`group-${t}`;if(!this.groupOf(e)&&!this.order.includes(e))return e}}removeFromGroup(t){const e=this.parentOf(t);e&&(e.members=e.members.filter(i=>i!==t),this.collapse())}pruneGroups(){const t=e=>this.order.includes(e)||this.groupOf(e)!==void 0;for(const e of this.groups)e.members=e.members.filter(t);this.collapse()}collapse(){for(let t=this.groups.find(e=>e.members.length<2);t;t=this.groups.find(e=>e.members.length<2)){const e=t;this.groups=this.groups.filter(i=>i!==e);for(const i of this.groups)i.members=i.members.flatMap(n=>n===e.id?e.members:[n])}}bringToFront(t){const e=this.order.indexOf(t);e!==-1&&(this.order.splice(e,1),this.order.push(t))}sendToBack(t){const e=this.order.indexOf(t);e!==-1&&(this.order.splice(e,1),this.order.unshift(t))}get duration(){const t=this.keyframes.length===0?0:this.keyframes[this.keyframes.length-1].t;return Math.max(t,this.span)}get hasSpan(){return this.span>0}setSpan(t){this.span=Math.max(0,t)}get sourceIds(){return[...this.order]}get allKeyframes(){return this.keyframes}toJSON(){return this.span>0?{keyframes:this.keyframes,order:this.order,groups:this.groupsJson(),span:this.span}:{keyframes:this.keyframes,order:this.order,groups:this.groupsJson()}}groupsJson(){return this.groups.map(t=>({...t,members:[...t.members]}))}static fromJSON(t,e,i=!0){const n=new Tf;for(const s of Vo.complete(t.keyframes??[],e))n.addKeyframe(s.t,s.shapes);if(t.span!==void 0&&t.span>0&&(n.span=t.span),t.order){const s=n.order.filter(r=>!t.order.includes(r));n.order=[...t.order,...s]}return t.groups&&(n.groups=t.groups.filter(s=>typeof s?.id=="string"&&Array.isArray(s.members)).map(s=>({...s,members:[...s.members]})),i&&n.pruneGroups()),n}}function i_(o,t,e){return Math.max(t,Math.min(e,o))}function n_(o,t,e){const i=((t-o)%360+540)%360-180;return((o+i*e)%360+360)%360}function Rc(o,t,e){return o+(t-o)*e}function s_(o,t,e){return{lat:o.lat===void 0||t.lat===void 0?void 0:Rc(o.lat,t.lat,e),lng:o.lng===void 0||t.lng===void 0?void 0:Rc(o.lng,t.lng,e),elevationM:Rc(o.elevationM,t.elevationM,e),...o.altitudeM!==void 0&&t.altitudeM!==void 0?{altitudeM:Rc(o.altitudeM,t.altitudeM,e)}:{},headingDeg:o.headingDeg===void 0||t.headingDeg===void 0?void 0:n_(o.headingDeg,t.headingDeg,e),pitchDeg:Rc(o.pitchDeg,t.pitchDeg,e),rollDeg:Rc(o.rollDeg??0,t.rollDeg??0,e),fovDeg:Rc(o.fovDeg,t.fovDeg,e),fNumber:o.fNumber,focusDistanceM:o.focusDistanceM,filter:o.filter}}class An{static at(t,e,i,n,s){const r=t[i],c=t[i+1]-r;if(c<=0)return e[i];const l=An.tangent(t,e,i,s),h=An.tangent(t,e,i+1,s),u=(n-r)/c,d=u*u,f=d*u;return(2*f-3*d+1)*e[i]+(f-2*d+u)*c*l+(-2*f+3*d)*e[i+1]+(f-d)*c*h}static SETTLE_MS=120;static ARRIVAL=.5;static gaze(t,e,i,n){const s=t[i],a=t[i+1]-s;if(a<=0)return e[i];const c=h=>h+1<e.length?e[h+1]===e[h]:!0,l=e[i+1]!==e[i];if(l&&c(i+1)){const h=An.tangent(t,e,i,!0),u=An.ARRIVAL*(e[i+1]-e[i])/a;return An.hermite(e[i],h,e[i+1],u,a,(n-s)/a)}return!l&&i>0&&e[i-1]!==e[i]?e[i]+An.settle(t,e,i,n-s,a):An.at(t,e,i,n,!0)}static settle(t,e,i,n,s){const r=t[i]-t[i-1];if(r<=0||n<=0)return 0;const a=An.ARRIVAL*(e[i]-e[i-1])/r,c=Math.min(An.SETTLE_MS,.4*r),l=Number.isFinite(s)?(1-Math.min(1,n/s))**2:1;return a*n*Math.exp(-n/c)*l}static hermite(t,e,i,n,s,r){const a=r*r,c=a*r;return(2*c-3*a+1)*t+(c-2*a+r)*s*e+(-2*c+3*a)*i+(c-a)*s*n}static BRAKE_S=.8;static paced(t,e,i,n){if(!i&&!n)return t;const s=e>0?Math.min(.5,An.BRAKE_S/e):.5;if(i&&n){const a=1/(1-s);return t<=s?a*t*t/(2*s):t>=1-s?1-a*(1-t)*(1-t)/(2*s):a*(t-s/2)}const r=a=>{const c=1/(1-s/2);if(a<=1-s)return c*a;const l=a-(1-s);return c*(1-s)+c*(l-l*l/(2*s))};return n?r(t):1-r(1-t)}static tangent(t,e,i,n){const s=t.length-1,r=f=>(e[f+1]-e[f])/(t[f+1]-t[f]||1);if(i===0)return n?0:r(0);if(i===s)return n?0:r(s-1);const a=r(i-1),c=r(i);if(a*c<=0)return 0;const l=t[i]-t[i-1],h=t[i+1]-t[i],u=2*h+l,d=h+2*l;return(u+d)/(u/a+d/c)}}class Ud{keyframes=[];addKeyframe(t,e,i){const n=this.findInsertIndex(t),s=this.keyframes[n]?.t===t?this.keyframes[n]:void 0,a=i??s?.viewOnly?{t,pose:e,viewOnly:!0}:{t,pose:e};s?this.keyframes[n]=a:this.keyframes.splice(n,0,a)}setViewOnly(t,e){const i=this.findInsertIndex(t),n=this.keyframes[i];n?.t===t&&(this.keyframes[i]=e?{...n,viewOnly:!0}:{t:n.t,pose:n.pose})}turnIsViewOnly(t,e){if(this.keyframes.length===0)return!1;const i=Math.max(0,this.findInsertIndex(t)-(this.keyframes[this.findInsertIndex(t)]?.t===t?0:1));for(let n=i;n<this.keyframes.length;n++){const s=this.keyframes[n];if(s.viewOnly)return!0;if(s.t>=e)break}return!1}clear(){this.keyframes.length=0}removeKeyframeAt(t){const e=this.findInsertIndex(t);this.keyframes[e]?.t===t&&this.keyframes.splice(e,1)}findInsertIndex(t){let e=0,i=this.keyframes.length;for(;e<i;){const n=e+i>>>1;this.keyframes[n].t<t?e=n+1:i=n}return e}getLatestPoseAt(t){let e=this.findInsertIndex(t);return this.keyframes[e]?.t!==t&&(e-=1),e>=0?this.keyframes[e].pose:void 0}getInterpolatedPoseAt(t){const e=this.findInsertIndex(t),i=this.keyframes[e]?.t===t?this.keyframes[e]:this.keyframes[e-1];if(i?.t===t)return i.pose;const n=this.keyframes[e]?.t===t?void 0:this.keyframes[e];if(!i)return n?.pose;if(!n)return this.settledAfterEnd(e-1,t);const s=s_(i.pose,n.pose,i_((t-i.t)/(n.t-i.t),0,1));return this.humanly(e-1,t,s)}settledAfterEnd(t,e){const i=this.keyframes[t];if(t<1)return i.pose;const n=this.keyframes[t-1],s=[n.t,i.t],r=(h,u)=>h===void 0||u===void 0?0:An.settle(s,[h,u],1,e-i.t,1/0),a=n.pose.headingDeg===void 0||i.pose.headingDeg===void 0?void 0:((i.pose.headingDeg-n.pose.headingDeg)%360+540)%360-180,c=i.pose.headingDeg===void 0||a===void 0?i.pose.headingDeg:((i.pose.headingDeg+r(0,a))%360+360)%360,l=i.pose.pitchDeg+r(n.pose.pitchDeg,i.pose.pitchDeg);return c===i.pose.headingDeg&&l===i.pose.pitchDeg?i.pose:{...i.pose,headingDeg:c,pitchDeg:l}}humanly(t,e,i){const n=Math.max(0,t-1),s=Math.min(this.keyframes.length-1,t+2),r=this.keyframes.slice(n,s+1),a=t-n,c=r.map(y=>y.t),l=(y,b)=>{const S=r.map(E=>y(E.pose));if(!S.some(E=>E===void 0))return An.at(c,S,a,e,b)},h=y=>{const b=r.map(S=>y(S.pose));if(!b.some(S=>S===void 0))return An.gaze(c,b,a,e)},u=r.map(y=>y.pose.headingDeg);let d;if(u.every(y=>y!==void 0)){const y=[u[0]];for(let b=1;b<u.length;b++)y.push(y[b-1]+((u[b]-u[b-1])%360+540)%360-180);d=(An.gaze(c,y,a,e)%360+360)%360}const f=this.keyframes[t],p=this.keyframes[t+1],m=(y,b)=>y.lat===b.lat&&y.lng===b.lng&&y.elevationM===b.elevationM,g=!m(f.pose,p.pose),v=g&&t>0&&m(this.keyframes[t-1].pose,f.pose),M=g&&t+2<this.keyframes.length&&m(p.pose,this.keyframes[t+2].pose);let w;if(v||M){const y=An.paced((e-f.t)/(p.t-f.t),(p.t-f.t)/1e3,v,M),b=(S,E)=>S===void 0||E===void 0?void 0:S+(E-S)*y;w={lat:b(f.pose.lat,p.pose.lat),lng:b(f.pose.lng,p.pose.lng),elevationM:b(f.pose.elevationM,p.pose.elevationM)}}return{...i,lat:w?w.lat:l(y=>y.lat,!1)??i.lat,lng:w?w.lng:l(y=>y.lng,!1)??i.lng,elevationM:w?w.elevationM:l(y=>y.elevationM,!1)??i.elevationM,headingDeg:d??i.headingDeg,pitchDeg:h(y=>y.pitchDeg)??i.pitchDeg,rollDeg:l(y=>y.rollDeg??0,!0)??i.rollDeg,fovDeg:l(y=>y.fovDeg,!0)??i.fovDeg}}get duration(){return this.keyframes.length===0?0:this.keyframes[this.keyframes.length-1].t}get allKeyframes(){return this.keyframes}toJSON(){return{keyframes:this.keyframes}}static fromJSON(t){const e=new Ud;for(const i of t.keyframes)e.addKeyframe(i.t,i.pose,i.viewOnly);return e}}class Wo{static MAX_CHANGE_PER_S=.05;points;followed;constructor(t){let e="none",i=0;this.points=t.map(({t:n,weather:s})=>(s.precipitationType!=="none"&&(e=s.precipitationType,i=s.precipitationIntensity),{t:n,lastFalling:e,lastFallingIntensity:i,intensity:s.precipitationType==="none"?0:s.precipitationIntensity,type:s.precipitationType})),this.followed=[];for(let n=0;n<this.points.length;n++){if(n===0){this.followed.push(this.points[0].intensity);continue}const s=this.points[n-1],r=this.points[n];this.followed.push(Wo.follow(this.followed[n-1],s.intensity,r.intensity,(r.t-s.t)/1e3,(r.t-s.t)/1e3))}}at(t){if(this.points.length===0||t<this.points[0].t)return;let e=this.points.length-1;for(;e>0&&this.points[e].t>t;)e--;const i=this.points[e],n=this.points[e+1],s=n?Wo.follow(this.followed[e],i.intensity,n.intensity,(n.t-i.t)/1e3,(t-i.t)/1e3):Wo.follow(this.followed[e],i.intensity,i.intensity,1,(t-i.t)/1e3);return{type:Wo.typeBetween(i,n,t,s),intensity:s,character:Wo.characterBetween(i,n,t)}}static characterBetween(t,e,i){return t.type==="none"?e&&e.type!=="none"?e.intensity:t.lastFallingIntensity:!e||e.type==="none"?t.intensity:t.intensity+(e.intensity-t.intensity)*(i-t.t)/(e.t-t.t||1)}static typeBetween(t,e,i,n){return t.type==="none"?e&&e.type!=="none"&&i>t.t?e.type:n>0?t.lastFalling:"none":e&&e.type==="none"&&n<=0?"none":t.type}static follow(t,e,i,n,s){const r=Wo.MAX_CHANGE_PER_S,a=n>0?(i-e)/n:0,c=u=>e+a*Math.min(Math.max(u,0),n);let l=t,h=0;for(let u=0;u<8&&h<s;u++){const d=c(h)-l;if(Math.abs(d)<1e-9){const w=h<n?a:0;if(Math.abs(w)<=r){const b=h<n?Math.min(s,n):s;l=c(b),h=b;continue}const y=Math.min(s,n);l+=Math.sign(w)*r*(y-h),h=y;continue}const f=Math.sign(d),p=h<n?a:0,m=r-f*p,g=m>0?h+Math.abs(d)/m:1/0,v=h<n?n:1/0,M=Math.min(s,g,v);l+=f*r*(M-h),h=M,M===g&&(l=c(h))}return Math.min(1,Math.max(0,l))}}const GM=1e3,r_=.65,a_=.05,bm={cloudCover:0,cloudDarkness:0,precipitationType:"none",precipitationIntensity:0,windDirectionDeg:0,windSpeed:0,storm:!1};function I0(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??GM,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}function _i(o,t,e){return o+(t-o)*e}function VM(o,t,e){const i=((t-o)%360+540)%360-180;return((o+i*e)%360+360)%360}function o_(o,t,e){return Math.max(t,Math.min(e,o))}function c_(o=[],t=[],e){if(!(!o.length&&!t.length))return[...new Set([...o.map(i=>i.id),...t.map(i=>i.id)])].map(i=>{const n=o.find(c=>c.id===i),s=t.find(c=>c.id===i),r=n??{...s,density:0},a=s??{...n,density:0};return{...r,eastM:_i(r.eastM,a.eastM,e),northM:_i(r.northM,a.northM,e),baseM:_i(r.baseM,a.baseM,e),thicknessM:_i(r.thicknessM,a.thicknessM,e),widthM:_i(r.widthM,a.widthM,e),depthM:_i(r.depthM,a.depthM,e),rotationDeg:VM(r.rotationDeg,a.rotationDeg,e),density:_i(r.density,a.density,e),darkness:_i(r.darkness??0,a.darkness??0,e)}})}function l_(o,t,e){if(o.cloudLayers===void 0&&t.cloudLayers===void 0)return;const i=I0(o),n=I0(t);return e>=1?n.map(r=>({...r})):[...new Set([...i.map(r=>r.id),...n.map(r=>r.id)])].map(r=>{const a=i.find(u=>u.id===r),c=n.find(u=>u.id===r),l=a??{...c,coverage:0},h=c??{...a,coverage:0};return{...l,instances:c_(a?.instances,c?.instances,e),baseM:_i(l.baseM,h.baseM,e),thicknessM:_i(l.thicknessM,h.thicknessM,e),coverage:_i(l.coverage,h.coverage,e),sizeM:_i(l.sizeM,h.sizeM,e),density:_i(l.density,h.density,e),darkness:_i(l.darkness??o.cloudDarkness,h.darkness??t.cloudDarkness,e),iceCrystalAlignment:l.iceCrystalAlignment===void 0||h.iceCrystalAlignment===void 0?void 0:_i(l.iceCrystalAlignment,h.iceCrystalAlignment,e),windSpeed:l.windSpeed===void 0&&h.windSpeed===void 0?void 0:_i(l.windSpeed??o.windSpeed,h.windSpeed??t.windSpeed,e),windDirectionDeg:l.windDirectionDeg===void 0&&h.windDirectionDeg===void 0?void 0:VM(l.windDirectionDeg??o.windDirectionDeg,h.windDirectionDeg??t.windDirectionDeg,e)}})}function h_(o,t,e){return{cloudLayers:l_(o,t,e),cloudCover:_i(o.cloudCover,t.cloudCover,e),cloudDarkness:_i(o.cloudDarkness,t.cloudDarkness,e),highCloudCover:o.highCloudCover===void 0||t.highCloudCover===void 0?void 0:_i(o.highCloudCover,t.highCloudCover,e),iceCrystalAlignment:o.iceCrystalAlignment===void 0||t.iceCrystalAlignment===void 0?void 0:_i(o.iceCrystalAlignment,t.iceCrystalAlignment,e),rareIceCrystals:o.rareIceCrystals===void 0||t.rareIceCrystals===void 0?void 0:_i(o.rareIceCrystals,t.rareIceCrystals,e),lowerCloudCover:o.lowerCloudCover===void 0||t.lowerCloudCover===void 0?void 0:_i(o.lowerCloudCover,t.lowerCloudCover,e),cloudBaseM:o.cloudBaseM===void 0||t.cloudBaseM===void 0?void 0:_i(o.cloudBaseM,t.cloudBaseM,e),relativeHumidity:o.relativeHumidity===void 0||t.relativeHumidity===void 0?void 0:_i(o.relativeHumidity,t.relativeHumidity,e),visibilityKm:o.visibilityKm===void 0||t.visibilityKm===void 0?void 0:_i(o.visibilityKm,t.visibilityKm,e),precipitationType:e<1?o.precipitationType:t.precipitationType,precipitationIntensity:_i(o.precipitationIntensity,t.precipitationIntensity,e),windDirectionDeg:VM(o.windDirectionDeg,t.windDirectionDeg,e),windSpeed:_i(o.windSpeed,t.windSpeed,e),storm:e<1?o.storm:t.storm}}class zd{keyframes=[];ramp;addKeyframe(t,e){this.ramp=void 0;const i=this.findInsertIndex(t);this.keyframes[i]?.t===t?this.keyframes[i]={t,weather:e}:this.keyframes.splice(i,0,{t,weather:e})}clear(){this.ramp=void 0,this.keyframes.length=0}removeKeyframeAt(t){this.ramp=void 0;const e=this.findInsertIndex(t);this.keyframes[e]?.t===t&&this.keyframes.splice(e,1)}findInsertIndex(t){let e=0,i=this.keyframes.length;for(;e<i;){const n=e+i>>>1;this.keyframes[n].t<t?e=n+1:i=n}return e}getLatestWeatherAt(t){let e=this.findInsertIndex(t);return this.keyframes[e]?.t!==t&&(e-=1),e>=0?this.keyframes[e].weather:void 0}getInterpolatedWeatherAt(t){const e=this.findInsertIndex(t),i=this.keyframes[e]?.t===t?this.keyframes[e]:this.keyframes[e-1];if(i?.t===t)return i.weather;const n=this.keyframes[e]?.t===t?void 0:this.keyframes[e];return i?n?h_(i.weather,n.weather,o_((t-i.t)/(n.t-i.t),0,1)):i.weather:n?.weather}getActualWeatherAt(t){const e=this.getInterpolatedWeatherAt(t);if(!e)return;const i=(this.ramp??=new Wo(this.keyframes)).at(t);if(!i)return e;const{type:n,intensity:s,character:r}=i,a=r>0?Math.min(1,s/r):n==="none"?0:1;return{...e,precipitationType:n,precipitationIntensity:r,precipitationAmount:a}}get duration(){return this.keyframes.length===0?0:this.keyframes[this.keyframes.length-1].t}get allKeyframes(){return this.keyframes}toJSON(){return{keyframes:this.keyframes}}static fromJSON(t){const e=new zd;for(const i of t.keyframes)e.addKeyframe(i.t,{...bm,...i.weather});return e}}class Bd{keyframes=[];addKeyframe(t,e){const i=this.findInsertIndex(t);this.keyframes[i]?.t===t?this.keyframes[i]={t,sound:e}:this.keyframes.splice(i,0,{t,sound:e})}clear(){this.keyframes.length=0}removeKeyframeAt(t){const e=this.findInsertIndex(t);this.keyframes[e]?.t===t&&this.keyframes.splice(e,1)}getLatestSoundAt(t){let e=this.findInsertIndex(t);return this.keyframes[e]?.t!==t&&(e-=1),e>=0?this.keyframes[e].sound:void 0}getInterpolatedSoundAt(t){const e=this.findInsertIndex(t),i=this.keyframes[e]?.t===t?this.keyframes[e]:this.keyframes[e-1];if(i?.t===t)return i.sound;const n=this.keyframes[e]?.t===t?void 0:this.keyframes[e];if(!i)return n?.sound;if(!n)return i.sound;const s=(t-i.t)/(n.t-i.t);return this.lerp(i.sound,n.sound,Math.max(0,Math.min(1,s)))}get duration(){return this.keyframes.length===0?0:this.keyframes[this.keyframes.length-1].t}get allKeyframes(){return this.keyframes}toJSON(){return{keyframes:this.keyframes}}static fromJSON(t){const e=new Bd;for(const i of t.keyframes)e.addKeyframe(i.t,i.sound);return e}lerp(t,e,i){return{kind:i<1?t.kind:e.kind,volume:t.volume+(e.volume-t.volume)*i,pitchHz:t.pitchHz+(e.pitchHz-t.pitchHz)*i,src:i<1?t.src:e.src}}findInsertIndex(t){let e=0,i=this.keyframes.length;for(;e<i;){const n=e+i>>>1;this.keyframes[n].t<t?e=n+1:i=n}return e}}const u_=100,d_={kind:"none",volume:0,pitchHz:u_};class Sa{static MAX_SPECKS=4;static BROADCAST_35MM={framesPerSecond:24,contrast:1.6,tint:[.99,.98,.92],softness:1.6/480,specksPerFrame:1.15,speckRadius:1.6/480,speckRadiusMax:4.5/480,weave:[.25/640,.6/480],grain:.008};static hash(t,e){const i=Math.sin(t*127.1+e*311.7)*43758.5453;return i-Math.floor(i)}static frameAt(t,e){return Math.floor(e*t.framesPerSecond/1e3)}static frame(t,e){const i=a=>Sa.hash(e,a),n=a=>(i(a)+i(a+1)+i(a+2)-1.5)*2,s=Math.min(1,t.specksPerFrame/Sa.MAX_SPECKS),r=[];for(let a=0;a<Sa.MAX_SPECKS;a++){const c=10+a*6;if(i(c)>=s)continue;const l=i(c+3)**3;r.push({u:i(c+1),v:i(c+2),radius:t.speckRadius*.6+l*(t.speckRadiusMax-t.speckRadius*.6),kept:.25+.4*i(c+4)})}return{weave:[n(1)*t.weave[0],n(4)*t.weave[1]],specks:r,seed:i(7)}}}class yh{static DEFAULT_FOCAL_MM=50;static FOCAL_RANGE_MM={minMm:14,maxMm:135};static BODIES=[{id:"eos-450d",name:"Canon EOS 450D (APS-C)",widthMm:22.2,heightMm:14.8,pixelUm:5.2,year:2008},{id:"eos-60da",name:"Canon EOS 60Da (APS-C)",widthMm:22.3,heightMm:14.9,pixelUm:4.3,year:2012},{id:"eos-70d",name:"Canon EOS 70D (APS-C)",widthMm:22.5,heightMm:15,pixelUm:4.1,year:2013},{id:"eos-80d",name:"Canon EOS 80D (APS-C)",widthMm:22.3,heightMm:14.9,pixelUm:3.7,year:2016},{id:"eos-7d",name:"Canon EOS 7D (APS-C)",widthMm:22.3,heightMm:14.9,pixelUm:4.1,year:2009},{id:"eos-7d-ii",name:"Canon EOS 7D Mark II (APS-C)",widthMm:22.4,heightMm:15,pixelUm:4.1,year:2014},{id:"eos-5d",name:"Canon EOS 5D (full frame)",widthMm:35.8,heightMm:23.9,pixelUm:8.2,year:2005},{id:"eos-5d-ii",name:"Canon EOS 5D Mark II (full frame)",widthMm:36,heightMm:24,pixelUm:6.4,year:2008},{id:"eos-5d-iii",name:"Canon EOS 5D Mark III (full frame)",widthMm:36,heightMm:24,pixelUm:6.25,year:2012},{id:"eos-5d-iv",name:"Canon EOS 5D Mark IV (full frame)",widthMm:36,heightMm:24,pixelUm:5.36,year:2016},{id:"eos-6d",name:"Canon EOS 6D (full frame)",widthMm:35.8,heightMm:23.9,pixelUm:6.55,year:2012},{id:"eos-6d-ii",name:"Canon EOS 6D Mark II (full frame)",widthMm:36,heightMm:24,pixelUm:5.77,year:2017},{id:"nikon-d3",name:"Nikon D3 / D700 (full frame)",widthMm:36,heightMm:23.9,pixelUm:8.44,year:2007},{id:"nikon-d7000",name:"Nikon D7000 (DX)",widthMm:23.6,heightMm:15.6,pixelUm:4.78,year:2010},{id:"nikon-d7100",name:"Nikon D7100 / D7200 (DX)",widthMm:23.5,heightMm:15.6,pixelUm:3.9,year:2013},{id:"nikon-d500",name:"Nikon D500 / D7500 (DX)",widthMm:23.5,heightMm:15.7,pixelUm:4.2,year:2016}];static instruments(){return yh.BODIES.map(t=>({id:t.id,category:"dslr",name:t.name,projection:"rectilinear",frame:{widthMm:t.widthMm,heightMm:t.heightMm,focalLengthMm:yh.DEFAULT_FOCAL_MM,focalRangeMm:yh.FOCAL_RANGE_MM},fNumber:8,fNumberRange:{min:1.4,max:22},exposureSeconds:1/250,exposureRangeSeconds:{min:1/8e3,max:3600},years:{from:t.year},apertureBlades:7,detailUm:t.pixelUm,medium:{kind:"sensor",iso:100}}))}static names(){return Object.fromEntries(yh.BODIES.map(t=>[t.id,t.name]))}}class Nr{static DEFAULT_EYEPIECE_MM=26;static DEFAULT_APPARENT_FIELD_DEG=52;static FIELD_STOP_MM=2*Nr.DEFAULT_EYEPIECE_MM*Math.tan(Nr.DEFAULT_APPARENT_FIELD_DEG*Math.PI/360);static RANGE={min:26/40*.63,max:26/6*3};static BINOCULARS=[{id:"binoculars-zeiss-6x30",name:"Carl Zeiss 6x30",magnification:6,apertureMm:30,trueFieldDeg:5,fromYear:1960},{id:"binoculars-zeiss-dialyt-10x40",name:"Carl Zeiss Dialyt 10x40 B T*",magnification:10,apertureMm:40,trueFieldDeg:6.3,fromYear:1975},{id:"binoculars-jenoptem-10x50",name:"Jenoptem 10x50 W",magnification:10,apertureMm:50,trueFieldDeg:7.3,fromYear:1960},{id:"binoculars-swarovski-7x50-habicht",name:"Swarovski 7x50 SL Habicht",magnification:7,apertureMm:50,trueFieldDeg:6.6,fromYear:1960},{id:"binoculars-swarovski-7x50-slc",name:"Swarovski 7x50 SLC",magnification:7,apertureMm:50,trueFieldDeg:7.1,fromYear:1990},{id:"binoculars-nikon-10x42-edg",name:"Nikon 10x42 EDG",magnification:10,apertureMm:42,trueFieldDeg:6.5,fromYear:2011},{id:"binoculars-canon-15x50-is",name:"Canon 15x50 IS All Weather",magnification:15,apertureMm:50,trueFieldDeg:4.5,fromYear:2008},{id:"binoculars-celestron-15x70",name:"Celestron 15x70 SkyMaster",magnification:15,apertureMm:70,trueFieldDeg:4.4,fromYear:1990},{id:"binoculars-miyauchi-25x141",name:"Miyauchi BR-141 Galaxy 45 25x141",magnification:25,apertureMm:141,trueFieldDeg:2.6,fromYear:2e3}];static TELESCOPES=[{id:"telescope-generic-60-700",name:"Telescope 60/700",apertureMm:60,focalLengthMm:700},{id:"telescope-generic-60-1000",name:"Telescope 60/1000",apertureMm:60,focalLengthMm:1e3},{id:"telescope-celestron-onyx-80edf",name:"Celestron Onyx 80EDF",apertureMm:80,focalLengthMm:500,fromYear:2010},{id:"telescope-celestron-c5",name:"Celestron C5 f/10",apertureMm:125,focalLengthMm:1250,fromYear:1970},{id:"telescope-celestron-c8",name:"Celestron C8 f/10",apertureMm:203,focalLengthMm:2032,fromYear:1970},{id:"telescope-celestron-c11",name:"Celestron C11 f/10",apertureMm:280,focalLengthMm:2800,fromYear:1970},{id:"telescope-celestron-c14",name:"Celestron C14 f/11",apertureMm:355.6,focalLengthMm:3910,fromYear:1970},{id:"telescope-meade-etx-80",name:"Meade ETX 80 f/5",apertureMm:80,focalLengthMm:400,fromYear:1996},{id:"telescope-meade-etx-90",name:"Meade ETX 90 f/13.8",apertureMm:90,focalLengthMm:1242,fromYear:1996},{id:"telescope-meade-etx-125",name:"Meade ETX 125 f/15",apertureMm:127,focalLengthMm:1900,fromYear:1996},{id:"telescope-meade-lx200-8",name:"Meade LX200 8 in f/10",apertureMm:200,focalLengthMm:2e3,fromYear:1992},{id:"telescope-meade-lx200-10",name:"Meade LX200 10 in f/10",apertureMm:250,focalLengthMm:2500,fromYear:1992},{id:"telescope-meade-lx200-12",name:"Meade LX200 12 in f/10",apertureMm:305,focalLengthMm:3048,fromYear:1992},{id:"telescope-meade-lx200-14",name:"Meade LX200 14 in f/10",apertureMm:355,focalLengthMm:3556,fromYear:1992},{id:"telescope-meade-lx200-16",name:"Meade LX200 16 in f/10",apertureMm:406,focalLengthMm:4064,fromYear:1992}];static instruments(){const t=Nr.BINOCULARS.map(n=>({id:n.id,category:"binoculars",name:n.name,projection:"rectilinear",visualAid:{apertureMm:n.apertureMm,magnification:n.magnification,trueFieldDeg:n.trueFieldDeg},...n.fromYear!==void 0?{years:{from:n.fromYear}}:{}})),e=Nr.FIELD_STOP_MM,i=Nr.TELESCOPES.map(n=>({id:n.id,category:"telescope",name:n.name,projection:"rectilinear",frame:{widthMm:e*16/9,heightMm:e,focalLengthMm:n.focalLengthMm,focalRangeMm:{minMm:n.focalLengthMm*Nr.RANGE.min,maxMm:n.focalLengthMm*Nr.RANGE.max}},visualAid:{apertureMm:n.apertureMm,eyepieceFocalMm:Nr.DEFAULT_EYEPIECE_MM},...n.fromYear!==void 0?{years:{from:n.fromYear}}:{}}));return[...t,...i]}static names(){return Object.fromEntries(Nr.instruments().map(t=>[t.id,t.name]))}}const Ff=[{id:"eye",category:"eye",name:"Naked eye",projection:"equidistant",stabilization:.97},{id:"rectilinear-lens",category:"camera",name:"Camera, unknown device",projection:"rectilinear",fNumber:8,fNumberRange:{min:2,max:22},exposureSeconds:1/250,exposureRangeSeconds:{min:1/1e3,max:8},apertureBlades:6},{id:"roamer-1-120",filmFormat:"120",category:"camera",name:"Roamer 1, 120 film",projection:"rectilinear",frame:{widthMm:74,heightMm:60,focalLengthMm:100},fNumber:11,exposureSeconds:1/50,years:{from:1930,to:1965},detailUm:40,medium:{kind:"negative",iso:125}},{id:"instamatic-126",filmFormat:"126",category:"camera",name:"Instamatic, 126 film",projection:"rectilinear",frame:{widthMm:28,heightMm:28,focalLengthMm:43},fNumber:11,exposureSeconds:1/90,years:{from:1963,to:1988},apertureBlades:5,detailUm:20,medium:{kind:"negative",iso:64}},{id:"slr-35mm-50",filmFormat:"135",category:"camera",name:"35 mm SLR, 50 mm lens",projection:"rectilinear",frame:{widthMm:36,heightMm:24,focalLengthMm:50},fNumber:8,fNumberRange:{min:2,max:16},exposureSeconds:1/250,exposureRangeSeconds:{min:1/1e3,max:3600},years:{from:1959},apertureBlades:6,detailUm:20,medium:{kind:"negative",iso:100}},{id:"cine-35mm-broadcast",filmFormat:"35mm-cine",category:"camera",name:"35 mm film camera, seen on television",projection:"rectilinear",frame:{widthMm:21.3,heightMm:16,focalLengthMm:50,focalRangeMm:{minMm:18,maxMm:300}},fNumber:11,fNumberRange:{min:2,max:22},exposureSeconds:1/48,exposureRangeSeconds:{min:1/96,max:1/24},years:{from:1950,to:1995},apertureBlades:6,detailUm:15,medium:{kind:"negative",iso:100,print:Sa.BROADCAST_35MM}},{id:"slr-35mm-zoom",filmFormat:"135",category:"camera",name:"35 mm SLR, 70-210 mm zoom",projection:"rectilinear",frame:{widthMm:36,heightMm:24,focalLengthMm:135,focalRangeMm:{minMm:70,maxMm:210}},fNumber:8,fNumberRange:{min:4,max:22},exposureSeconds:1/250,exposureRangeSeconds:{min:1/1e3,max:3600},apertureBlades:8,years:{from:1975},detailUm:20,medium:{kind:"negative",iso:100}},{id:"phone-landscape",category:"phone",name:"Phone, held sideways",projection:"rectilinear",frame:{widthMm:7.6,heightMm:5.7,focalLengthMm:5.7},fNumber:1.8,exposureSeconds:1/120,exposureRangeSeconds:{min:1/8e3,max:10},years:{from:2007},apertureBlades:void 0,detailUm:1.4,medium:{kind:"sensor",iso:100,autoExposure:!0,maxIso:3200,metering:"highlights",development:"computational"}},{id:"phone-portrait",category:"phone",name:"Phone, held upright",projection:"rectilinear",frame:{widthMm:5.7,heightMm:7.6,focalLengthMm:5.7},fNumber:1.8,exposureSeconds:1/120,exposureRangeSeconds:{min:1/8e3,max:10},years:{from:2007},apertureBlades:void 0,detailUm:1.4,medium:{kind:"sensor",iso:100,autoExposure:!0,maxIso:3200,metering:"highlights",development:"computational"}},{id:"dashcam",mounted:!0,category:"video",name:"Dashcam",projection:"equidistant",frame:{widthMm:5.76,heightMm:3.24,focalLengthMm:3.2},fNumber:2,exposureSeconds:1/30,exposureRangeSeconds:{min:1/1e4,max:1/30},years:{from:2008},apertureBlades:void 0,detailUm:3,medium:{kind:"sensor",iso:100,autoExposure:!0,maxIso:1600,metering:"average",exposureFollowMs:500}},{id:"cctv",mounted:!0,category:"video",name:"Security camera",projection:"rectilinear",frame:{widthMm:4.8,heightMm:3.6,focalLengthMm:3.6},fNumber:2,exposureSeconds:1/50,exposureRangeSeconds:{min:1/1e5,max:1/50},years:{from:1990},apertureBlades:void 0,detailUm:6,medium:{kind:"sensor",iso:100,autoExposure:!0,maxIso:1600,metering:"average",exposureFollowMs:500}},...yh.instruments(),...Nr.instruments()];class Ti{static get default(){return Ff[0]}static byId(t){return Ff.find(e=>e.id===t)??this.default}static UNAIDED_FIELD_DEG=60;static UNAIDED_ASPECT=16/9;static fieldOfViewDeg(t){const e=t.frame;return e?Ti.fieldOf(t.projection,e.heightMm,e.focalLengthMm):t.visualAid?.trueFieldDeg??Ti.UNAIDED_FIELD_DEG}static fieldOf(t,e,i){return(t==="equidistant"?e/i:2*Math.atan(e/(2*i)))*180/Math.PI}static aspectOf(t){const e=t.frame;return e?e.widthMm/e.heightMm:Ti.UNAIDED_ASPECT}static frameWidthPx(t,e){return Math.round(e*Ti.aspectOf(t))}static CATEGORIES=["eye","camera","dslr","phone","video","binoculars","telescope"];static unavailability(t,e){const i=t.years;if(!(e===void 0||!i)){if(e<i.from)return{kind:"before",from:i.from};if(i.to!==void 0&&e>i.to)return{kind:"after",to:i.to}}}static availableAt(t){return t===void 0?Ff:Ff.filter(e=>!e.years||t>=e.years.from&&(e.years.to===void 0||t<=e.years.to))}static fieldOfViewDegAt(t,e){const i=t.frame;if(!(!i||e<=0))return Ti.fieldOf(t.projection,i.heightMm,e)}static focalLengthMmFor(t,e){const i=t.frame;if(!(!i||e<=0||e>=180))return t.projection==="equidistant"?i.heightMm/(e*Math.PI/180):i.heightMm/(2*Math.tan(e*Math.PI/360))}static bladesShowing(t,e){if(t.apertureBlades===void 0)return 0;const i=e??t.fNumber,n=t.fNumberRange?.min;if(i===void 0||n===void 0)return 1;const s=Math.max(0,Math.min(1,(i/n-1)/.3));return s*s*(3-2*s)}static starPointsOf(t,e){const i=t.apertureBlades;return i===void 0||i<3||Ti.bladesShowing(t,e)<.5?0:i%2===0?i:i*2}}class js extends Error{}class xm{constructor(t){this.name=t}validate(t){return!0}}class QS extends xm{min;max;constructor(t,e,i){super(t),this.min=e,this.max=i}validate(t){if(typeof t!="number")throw new js(`${this.name} value must be a number, but was ${t}`);if(t<this.min||t>this.max)throw new js(`${this.name} value must be >= ${this.min} and <= ${this.max}, but was ${t}`);return super.validate(t)}}class wi{name;min;max;duration;subUnit;validator;constructor(t,e,i,n,s=new QS(t,e,i)){this.name=t,this.min=e,this.max=i,this.subUnit=n,this.duration=n?(n.max-n.min+1)*n.duration:1,this.validator=s}validate(t){return this.validator.validate(t)}[Symbol.iterator](){let t=this.min;return{next:()=>{const e={done:t>this.max,value:t};return t++,e}}}}class WM{millisecond;second;minute;hour;day;month;year}class f_ extends WM{}class tE extends f_{millisecond=new wi("millisecond",0,999,void 0);second=new wi("second",0,59,this.millisecond);minute=new wi("minute",0,59,this.second);hour=new wi("hour",0,23,this.minute);day=new wi("day",1,31,this.hour);month=new wi("month",1,12,this.day);year=new wi("year",0,9999,this.month)}const le=new tE;class eE extends QS{constructor(t=1,e=12){super("month",t,e)}}class wh extends wi{static Month28=new wh(28);static Month29=new wh(29);static ThirtyDays=new wh(30);static ThirtyOneDays=new wh(31);constructor(t,e=new eE(1,t)){super("month",1,t,le.day,e)}static create(t,e){switch(t){case 1:case 3:case 5:case 7:case 8:case 10:case 12:return this.ThirtyOneDays;case 2:return e%4===0?this.Month29:this.Month28;case 4:case 6:case 9:case 11:return this.ThirtyDays;default:throw new js("Unsupported month",t,e)}}}class Ea{static instance=new Ea;render(t){return t.value.toString()}}class ms{unit;#t;constructor(t,e){this.unit=e,this.value=typeof t=="number"?t:t.value}get value(){return this.#t}set value(t){this.unit.validate(t),this.#t=t}get duration(){return this.value*this.unit.duration}#e(t){if(this.constructor.name!==t.constructor.name)throw new xm(`${this.unit.name} "${this.toString()}" cannot be compared with ${t.unit?.name} "${t.toString()}"`)}compare(t){return this.#e(t),this.value-t.value}isEqual(t){return this.compare(t)===0}isBefore(t){return this.compare(t)<0}isAfter(t){return this.compare(t)>0}previous(t=this.unit){const e=this.value-1;return new this.constructor(e,t)}next(t=this.unit){const e=this.value+1;return new this.constructor(e,t)}toString(t=Ea.instance){return t.render(this)}toSpec(){return{value:this.value}}toJSON(){return this.toSpec()}}class Nt{static#t=new Map;static register(t,e){Nt.#t.set(t,e)}static get(t){const e=Nt.#t.get(t);if(!e)throw new js(`No default parser registered for ${t.name}: import "@rr0/time/defaults" or pass a parser to fromString()`);return e()}}class cu extends ms{constructor(t=new Date().getFullYear(),e=le.year){super(t,e)}static fromString(t,e=Nt.get(cu)){return new cu(e.parse(t))}}class Ha extends Ea{static default=new Ha("0",2);constructor(t,e){super(),this.char=t,this.size=e}render(t){return super.render(t).padStart(this.size,this.char)}}class lu extends ms{constructor(t=new Date().getMonth()+1,e=le.month){super(t,e)}static fromString(t,e=Nt.get(lu)){return new lu(e.parse(t))}toString(t=Ha.default){return super.toString(t)}}class hu extends ms{constructor(t=new Date().getDate(),e=le.day){super(t,e)}static fromString(t,e=Nt.get(hu)){const i=e.parse(t);return new hu(i)}toString(t=Ha.default){return super.toString(t)}}class uu extends ms{constructor(t=new Date().getHours(),e=le.hour){super(t,e)}static fromString(t,e=Nt.get(uu)){return new uu(e.parse(t))}toString(t=Ha.default){return super.toString(t)}}class du extends ms{constructor(t=new Date().getMinutes(),e=le.minute){super(t,e)}static fromString(t,e=Nt.get(du)){return new du(e.parse(t))}toString(t=Ha.default){return super.toString(t)}}class fu extends ms{constructor(t=new Date().getSeconds(),e=le.second){super(t,e)}static fromString(t,e=Nt.get(fu)){return new fu(e.parse(t),le.second)}toString(t=Ha.default){return super.toString(t)}}class Ec extends ms{static renderer=new Ha("0",3);constructor(t,e=le.millisecond){super(t,e)}static parseFraction(t){return parseInt(t.padEnd(3,"0").substring(0,3),10)}toString(t=Ec.renderer){return super.toString(t)}}class p_{render(t){return t.toString()}}class m_ extends p_{render(t){const e=t.value,i=Math.abs(e),n=Math.floor(i/60),s=i%60;if(n===0&&s===0)return"Z";{const r=e<0?"-":"+",a=n.toString().padStart(2,"0"),c=s>0?":"+s.toString().padEnd(2,"0"):"";return r+a+c}}}class yc{value;name="timeshift";renderer;constructor(t=0){this.value=t}static fromString(t,e=Nt.get(yc),i=void 0){const n=e.parse(t,i);return new yc(n)}toString(t=new m_){return t.render(this)}toSpec(){return{value:this.value}}toJSON(){return this.toSpec()}}class ls{static timeshift(t,e){return t+(ls.isDaylight(e)?60:0)}static isDaylight(t){const{year:e,month:i,day:n}=t,s=t.hour??12;if(![e,i,n].every(Number.isInteger))throw new RangeError("Daylight saving time depends on the year, month and day");const r=ls.rule(e);if(!r)return!1;const a=ls.rank(i,n,s);return a>=ls.rank(r.start.month,r.start.day,2)&&a<ls.rank(r.end.month,r.end.day,2)}static rule(t){if(t<1967)return;const e={month:10,day:ls.sunday(t,10,-1)};return t>=2007?{start:{month:3,day:ls.sunday(t,3,2)},end:{month:11,day:ls.sunday(t,11,1)}}:t>=1987?{start:{month:4,day:ls.sunday(t,4,1)},end:e}:t===1975?{start:{month:2,day:23},end:e}:t===1974?{start:{month:1,day:6},end:e}:{start:{month:4,day:ls.sunday(t,4,-1)},end:e}}static sunday(t,e,i){const n=new Date(Date.UTC(2e3,e-1,1));n.setUTCFullYear(t);const s=1+(7-n.getUTCDay())%7;if(i>0)return s+7*(i-1);const r=[31,ls.isLeap(t)?29:28,31,30,31,30,31,31,30,31,30,31][e-1];let a=s;for(;a+7<=r;)a+=7;return a}static isLeap(t){return t%4===0&&(t%100!==0||t%400===0)}static rank(t,e,i){return(t*100+e)*100+i}}const g_={name:"PST",timeshift:"-08",title:"Pacific Standard Time (US)"},v_={name:"PDT",timeshift:"-07",title:"Pacific Daylight Time (US)"},M_={name:"MDT",timeshift:"-06",title:"Mountain Standard Time (US)"},y_={name:"MST",timeshift:"-07",title:"Mountain Daylight Time (US)"},w_={name:"PT",timeshift:o=>ls.timeshift(-480,o),title:"Pacific Time (US)"},b_={name:"MT",timeshift:o=>ls.timeshift(-420,o),title:"Mountain Time (US)"},x_={name:"CT",timeshift:o=>ls.timeshift(-360,o),title:"Central Time (US)"},S_={name:"ET",timeshift:o=>ls.timeshift(-300,o),title:"Eastern Time (US)"},E_={name:"CWT",timeshift:"-05",title:"Central War Time (US)"},A_={name:"CDT",timeshift:"-05",title:"Central Daylight Time"},__={name:"EST",timeshift:"-05",title:"Eastern Standard Time (US)"},T_={name:"EDT",timeshift:"-04",title:"Eastern Time (US)"},R_={name:"AST",timeshift:"-04",title:"Atlantic Standard Time (US)"},I_={name:"ADT",timeshift:"-03",title:"Atlantic Daylight Time (US)"},D_={name:"UTC",timeshift:"Z",title:"Coordinated Universal Time"},C_={name:"Z",timeshift:"Z",title:"UTC"},O_={name:"GMT",timeshift:"Z",title:"Greenwich Mean Time"},P_={name:"BST",timeshift:"+01",title:"British Summer Time"},L_={name:"CEST",timeshift:"+02",title:"Central European Summer Time"},N_={name:"CET",timeshift:"+01",title:"Central European Time"},k_={name:"MSK",timeshift:"+03",title:"Moscow Time (RU)"},F_={name:"IST",timeshift:"+05:30",title:"Indian Standard Time"},U_={name:"BJT",timeshift:"+08",title:"Beijing Time"},z_={name:"CST",timeshift:"-06",title:"Central Standard Time"},B_={name:"JST",timeshift:"+09",title:"Japan Standard Time"},H_={name:"AEST",timeshift:"+10",title:"Australian Eastern Standard Time"},G_={name:"NZST",timeshift:"+12",title:"New Zealand Standard Time"},V_={name:"LST",timeshift:"?",title:"Local Sideral Time"},l2=[I_,H_,R_,U_,P_,z_,A_,N_,L_,x_,E_,T_,__,S_,O_,F_,B_,V_,M_,k_,y_,b_,G_,v_,g_,w_,D_,C_];class Sm{static instance=new Sm;renderComponent(t,e){return t[e].toString()}renderSecond(t){return this.renderComponent(t,"second")+(t.millisecond?"."+t.millisecond.toString():"")}render(t){const e=[];t.year&&e.push(this.renderComponent(t,"year")),t.month&&e.push(this.renderComponent(t,"month")),t.day&&e.push(this.renderComponent(t,"day"));const i=[];t.hour&&i.push(this.renderComponent(t,"hour")),t.minute&&i.push(this.renderComponent(t,"minute")),t.second&&i.push(this.renderSecond(t));const n=e.join("-"),s=t.timeshift?t.timeshift.toString():"",r=i.join(":")+s;return n+(r.length>0?"T"+r:"")}}class Hc extends js{constructor(t="method is abstract"){super(t)}}class XM{units;constructor(t){this.units=t}newYear(t){throw new Hc}newMonth(t){throw new Hc}newDay(t){throw new Hc}newHour(t){throw new Hc}newMinute(t){throw new Hc}newSecond(t){throw new Hc}}class W_ extends WM{millisecond=new wi("milliseconds",Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER,void 0);second=new wi("seconds",Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER,this.millisecond);minute=new wi("minutes",Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER,this.second);hour=new wi("hours",Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER,this.minutes);day=new wi("days",Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER,this.hour);month=new wi("months",Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER,this.day);year=new wi("years",Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER,this.month)}const Rf=new W_;class Em{static instance=new Em;render(t){const e=Wr.toSpec(t);let i="P";const n=e.years;n&&(i+=n.toString()+"Y");const s=e.months;s&&(i+=s.toString(Ea.instance)+"MM");const r=e.days;r&&(i+=r.toString(Ea.instance)+"D");const a=e.hours;a&&(i+=a.toString(Ea.instance)+"H");const c=e.minutes;c&&(i+=c.toString(Ea.instance)+"M");const l=e.seconds;return l&&(i+=l.toString(Ea.instance)+"S"),i}}class Wr extends ms{constructor(t={years:new Date().getFullYear(),months:new Date().getMonth(),days:new Date().getDate(),hours:new Date().getHours(),minutes:new Date().getMinutes(),seconds:new Date().getSeconds(),milliseconds:new Date().getMilliseconds()}){super({value:typeof t=="number"?t:+(t.years?t.years*le.year.duration:0)+(t.months?t.months*le.month.duration:0)+(t.days?t.days*le.day.duration:0)+(t.hours?t.hours*le.hour.duration:0)+(t.minutes?t.minutes*le.minute.duration:0)+(t.seconds?t.seconds*le.second.duration:0)},new wi("millisecond",0,Number.MAX_SAFE_INTEGER,void 0))}static toSpec(t,e=$_){let i=typeof t=="number"?t:t.value;const n=i>0?1:-1;i=Math.abs(i);const s={},r=i/le.year.duration,a=Math.floor(r);a>0&&(s.years=e.newYear(n*a),i-=a*le.year.duration);const c=i/le.month.duration,l=Math.floor(c);l>0&&(s.months=e.newMonth(n*l),i-=l*le.month.duration);const h=i/le.day.duration,u=Math.floor(h);u>0&&(s.days=e.newDay(n*u),i-=u*le.day.duration);const d=i/le.hour.duration,f=Math.floor(d);f>0&&(s.hours=e.newHour(n*f),i-=f*le.hour.duration);const p=i/le.minute.duration,m=Math.floor(p);m>0&&(s.minutes=e.newMinute(n*m),i-=m*le.minute.duration);const g=i/le.second.duration,v=Math.floor(n*g);return v>0&&(s.seconds=e.newSecond(v)),s}static fromString(t,e=Nt.get(Wr)){return new Wr(e.parse(t))}static between(t,e){const i=e.getTime(),n=t.getTime();return new Wr(i-n)}toSpec(){return Wr.toSpec(this)}toString(t=Em.instance){return t.render(this)}}class iE extends XM{constructor(t){super(t)}newYear(t){return new cu(t,this.units.year)}newMonth(t){return new lu(t,this.units.month)}newDay(t){return new hu(t,this.units.day)}newHour(t){return new uu(t,this.units.hour)}newMinute(t){return new du(t,this.units.minute)}newSecond(t){return new fu(t,this.units.second)}newMillisecond(t){return new Ec(t,this.units.millisecond)}newTimeshift(t){return new yc(typeof t=="number"?t:t.value)}}const X_=new iE(le),$_=new iE(Rf);class Gn{#t;#e;#i;#n;#s;#r;#a;#o;constructor(t={year:new Date().getFullYear(),month:new Date().getMonth()+1,day:new Date().getDate(),hour:new Date().getHours(),minute:new Date().getMinutes(),second:new Date().getSeconds(),timeshift:Gn.timeshiftOf(new Date)}){this.year=t.year,this.month=t.month,this.day=t.day,this.hour=t.hour,this.minute=t.minute,this.second=t.second,this.millisecond=t.millisecond,this.timeshift=t.timeshift}get year(){return this.#t}set year(t){const e=typeof t=="number";this.#t&&e?this.#t.value=t:this.#t=e?this.factory.newYear(t):!t||t.start||t instanceof ms?t:this.factory.newYear(t)}get month(){return this.#e}set month(t){const e=typeof t=="number";this.#e&&e?this.#e.value=t:this.#e=e?this.factory.newMonth(t):!t||t.start||t instanceof ms?t:this.factory.newMonth(t)}get day(){return this.#i}set day(t){const e=typeof t=="number";this.#i&&e?this.#i.value=t:this.#i=e?this.factory.newDay(t):!t||t.start||t instanceof ms?t:this.factory.newDay(t)}get hour(){return this.#n}set hour(t){const e=typeof t=="number";this.#n&&e?this.#n.value=t:this.#n=e?this.factory.newHour(t):!t||t.start||t instanceof ms?t:this.factory.newHour(t)}get minute(){return this.#s}set minute(t){const e=typeof t=="number";this.#s&&e?this.#s.value=t:this.#s=e?this.factory.newMinute(t):!t||t.start||t instanceof ms?t:this.factory.newMinute(t)}get second(){return this.#r}set second(t){const e=typeof t=="number";this.#r&&e?this.#r.value=t:this.#r=e?this.factory.newSecond(t):!t||t.start||t instanceof ms?t:this.factory.newSecond(t)}get millisecond(){return this.#a}set millisecond(t){const e=typeof t=="number";this.#a&&e?this.#a.value=t:this.#a=e||t&&!(t instanceof ms)?this.factory.newMillisecond(t):t}get timeshift(){return this.#o}set timeshift(t){const e=typeof t=="number";this.#o&&e?this.#o.value=t:this.#o=e||t&&!(t instanceof yc)?this.factory.newTimeshift(t):t}get factory(){return X_}static fromString(t,e=Nt.get(Gn)){const{year:i,month:n,day:s,hour:r,minute:a,second:c,millisecond:l,timeshift:h}=e.parse(t);return new Gn({year:i,month:n,day:s,hour:r,minute:a,second:c,millisecond:l,timeshift:h})}static timeshiftOf(t){return-t.getTimezoneOffset()||0}static fromDate(t){return new Gn({year:t.getFullYear(),month:t.getMonth()+1,day:t.getDate(),hour:t.getHours(),minute:t.getMinutes(),second:t.getSeconds(),timeshift:Gn.timeshiftOf(t)})}static newInstance(){const t=new Date().toISOString(),e=t.indexOf("."),i=t.substring(0,e)+t.substring(e+4);return Gn.fromString(i)}#c(t){if(this.constructor.name!==t.constructor.name)throw new xm(`Date "${this.toString()}" cannot be compared with "${t.toString()}"`)}compare(t){return this.#c(t),this.getTime()-t.getTime()}delta(t){const e=this.compare(t);return new Wr(e)}getTime(){return(this.year?.duration||0)+(this.month?.duration||0)+(this.day?.duration||0)+(this.hour?.duration||0)+(this.minute?.duration||0)+(this.second?.duration||0)+(this.millisecond?.duration||0)}isEqual(t){return this.compare(t)===0}isBefore(t){return this.compare(t)<0}isAfter(t){return this.compare(t)>0}clone(){return new Gn(this.toSpec())}previous(){let t=this.clone();try{t.second=this.second.previous()}catch{try{t.minute=this.minute.previous()}catch{try{t.hour=this.hour.previous()}catch{try{t.day=this.day.previous()}catch{try{t.month=this.month.previous()}catch{t.year=this.year.previous()}}}}}return t}next(){let t=this.clone();try{t.second=this.second.next()}catch{try{t.minute=this.minute.next()}catch{try{t.hour=this.hour.next()}catch{try{t.day=this.day.next()}catch{try{t.month=this.month.next()}catch{t.year=this.year.next()}}}}}return t}toString(t=Sm.instance){return t.render(this)}toSpec(){const t={},e=this.year?.toSpec();e&&(t.year=e);const i=this.month?.toSpec();i&&(t.month=i);const n=this.day?.toSpec();n&&(t.day=n);const s=this.hour?.toSpec();s&&(t.hour=s);const r=this.minute?.toSpec();r&&(t.minute=r);const a=this.second?.toSpec();a&&(t.second=a);const c=this.millisecond?.toSpec();c&&(t.millisecond=c);const l=this.timeshift?.toSpec();return l&&(t.timeshift=l),t}toJSON(){return this.toSpec()}}class $M{static instance=new $M;render(t){return(t.start?t.start.toString():"")+"/"+(t.end?t.end.toString():"")}}class Hd{constructor(t,e){this.start=t,this.end=e}_start;get start(){return this._start}set start(t){if(typeof t=="string"&&(t=Gn.fromString(t)),t&&!(t instanceof Gn)&&!(t instanceof Wr))throw new js("Interval start is not a level 0 date or duration: "+t);this._start=t}_end;get end(){return this._end}set end(t){if(typeof t=="string"&&(t=Gn.fromString(t)),t&&!(t instanceof Gn)&&!(t instanceof Wr))throw new js("Interval end is not a level 0 date or duration: "+t);this._end=t}static fromString(t,e=Nt.get(Hd)){const{start:i,end:n}=e.parse(t);return new Hd(i,n)}toString(t=$M.instance){return t.render(this)}[Symbol.iterator](){let t=this.start;return{next:()=>{const e={done:t>this.end,value:t};return t++,e}}}}class If extends Ea{static instance=new If(Ha.default);constructor(t){super(),this.valueRenderer=t}render(t){return(this.valueRenderer?this.valueRenderer.render(t):super.render(t))+this.qualifier(t)}qualifier(t){return t.uncertain?t.approximate?"%":"?":t.approximate?"~":""}}class Ua extends ms{#t;#e;constructor(t,e){super(t,e),this.#t=t.uncertain||!1,this.#e=t.approximate||!1}get uncertain(){return this.#t}set uncertain(t){return this.#t=t}get approximate(){return this.#e}set approximate(t){return this.#e=t}isCertainAndPrecise(){return!this.approximate&&!this.uncertain}isEqual(t){return this.isCertainAndPrecise()&&super.isEqual(t)}isBefore(t){return this.isCertainAndPrecise()&&super.isBefore(t)}isAfter(t){return this.isCertainAndPrecise()&&super.isAfter(t)}toString(t=If.instance){return super.toString(t)}toSpec(){return{...super.toSpec(),uncertain:this.uncertain,approximate:this.approximate}}toJSON(){return this.toSpec()}}class nE extends tE{year=new wi("year",-9999,9999,this.month);yearExtended=new wi("year",Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER,this.month)}const h0=new nE;class sc extends Ua{constructor(t,e=h0.year){super(t,e)}static fromString(t,e=h0.year,i=Nt.get(sc)){const n=i.parse(t),s=n.value.start;if(t.startsWith("Y")&&(e=h0.yearExtended),s!==void 0){const r=new sc(Object.assign({...n},{value:Math.max(s,e.min)})),a=new sc(Object.assign({...n},{value:Math.min(n.value.end,e.max)}));return{start:r,end:a}}else return new sc(n,e)}}class sE extends xm{monthValidator=new eE;validate(t){switch(t){case 21:case 22:case 23:case 24:return!0;default:return this.monthValidator.validate(t)}}}class rc extends Ua{constructor(t,e=new wi(le.month.name,1,24,le.day,new sE)){super(t,e)}static fromString(t,e=Nt.get(rc)){const i=e.parse(t),n=i.value.start;if(n!==void 0){let s=le.month;const r=new rc(Object.assign({...i},{value:Math.max(n,s.min)})),a=new rc(Object.assign({...i},{value:Math.min(i.value.end,s.max)}));return{start:r,end:a}}else return new rc(i)}toString(t){return super.toString(t).padStart(2,"0")}}class ac extends Ua{constructor(t,e=le.day){super(t,e)}static fromString(t,e=Nt.get(ac)){const i=e.parse(t),n=i.value.start;if(n!==void 0){let s=le.day;const r=new ac(Object.assign({...i},{value:Math.max(n,s.min)})),a=new ac(Object.assign({...i},{value:Math.min(i.value.end,s.max)}));return{start:r,end:a}}else return new ac(i)}toString(t){return super.toString(t).padStart(2,"0")}}class oc extends Ua{constructor(t,e=le.hour){super(t,e)}static fromString(t,e=Nt.get(oc)){const i=e.parse(t),n=i.value.start;if(n!==void 0){let s=le.hour;const r=new oc(Object.assign({...i},{value:Math.max(n,s.min)})),a=new oc(Object.assign({...i},{value:Math.min(i.value.end,s.max)}));return{start:r,end:a}}else return new oc(i)}}class cc extends Ua{constructor(t,e=le.minute){super(t,e)}static fromString(t,e=Nt.get(cc)){const i=e.parse(t),n=i.value.start;if(n!==void 0){const s=le.minute,r=new cc(Object.assign({...i},{value:Math.max(n,s.min)})),a=new cc(Object.assign({...i},{value:Math.min(i.value.end,s.max)}));return{start:r,end:a}}else return new cc(i)}toString(t=If.instance){return super.toString(t)}}class lc extends Ua{constructor(t,e=le.second){super(t,e)}static fromString(t,e=Nt.get(lc)){const i=e.parse(t),n=i.value.start;if(n!==void 0){const s=le.second,r=new lc(Object.assign({...i},{value:Math.max(n,s.min)})),a=new lc(Object.assign({...i},{value:Math.min(i.value.end,s.max)}));return{start:r,end:a}}else return new lc(i)}}class gl extends yc{static fromString(t,e=Nt.get(gl),i=void 0){return new gl(e.parse(t,i))}}class rE extends XM{constructor(t){super(t)}newYear(t){return new sc(t,this.units.year)}newMonth(t){return new rc(t,this.units.month)}newDay(t){return new ac(t,this.units.day)}newHour(t){return new oc(t,this.units.hour)}newMinute(t){return new cc(t,this.units.minute)}newSecond(t){return new lc(t,this.units.second)}newMillisecond(t){return new Ec(t,this.units.millisecond)}newTimeshift(t){return new gl(typeof t=="number"?t:t.value)}}const Y_=new rE(h0),K_=new rE(Rf);class Ys extends Gn{constructor(t){super(t)}get factory(){return Y_}get uncertain(){return this.year?.uncertain===!0||this.month?.uncertain===!0||this.day?.uncertain===!0||this.hour?.uncertain===!0||this.minute?.uncertain===!0||this.second?.uncertain===!0}get approximate(){return this.year?.approximate===!0||this.month?.approximate===!0||this.day?.approximate===!0||this.hour?.approximate===!0||this.minute?.approximate===!0||this.second?.approximate===!0}static fromDate(t){return new Ys({year:t.getFullYear(),month:t.getMonth()+1,day:t.getDate(),hour:t.getHours(),minute:t.getMinutes(),second:t.getSeconds(),timeshift:Gn.timeshiftOf(t)})}static fromString(t,e=Nt.get(Ys)){const i=e.parse(t);return new Ys(i)}static newInstance(){const t=new Date().toISOString(),e=t.indexOf("."),i=t.substring(0,e)+t.substring(e+4);return Ys.fromString(i)}clone(){return new Ys(this.toSpec())}}const En=Object.freeze({year:"year",month:"month",day:"day",hour:"hour",minute:"minute",second:"second",timeshift:"timeshift",uncertain:"uncertain",approximate:"approx"});class Am extends Em{static instance=new Am;render(t){return super.render(t)}}class wn extends Ua{constructor(t){super(typeof t=="number"||t.hasOwnProperty("value")?t:{value:wn.getValue(t,En.year)+wn.getValue(t,En.month)+wn.getValue(t,En.day)+wn.getValue(t,En.hour)+wn.getValue(t,En.minute)+wn.getValue(t,En.second),uncertain:wn.getBoolean(t,En.uncertain),approximate:wn.getBoolean(t,"approximate")},Rf.millisecond)}static getBoolean(t,e){return t[e]||t[En.year+"s"]?.[e]||t[En.month+"s"]?.[e]||t[En.day+"s"]?.[e]||t[En.hour+"s"]?.[e]||t[En.minute+"s"]?.[e]||t[En.second+"s"]?.[e]||!1}static getValue(t,e){let i=0,n=t[e+"s"];if(n instanceof Ua?n=n.value:typeof t=="number"&&(n=t),n){const s=le[e];i=n*s.duration}return i}static toSpec(t,e=K_){return{...Wr.toSpec(t,e),uncertain:t.uncertain||!1,approximate:t.approximate||!1}}static fromString(t,e=Nt.get(wn)){const i=e.parse(t);return new wn(i)}static between(t,e){const i=e.getTime(),n=t.getTime();return new wn(i-n)}toString(t=Am.instance){return super.toString(t)}toSpec(){return wn.toSpec(this)}}class Gd extends Hd{constructor(t,e){super(t,e)}get start(){return this._start}set start(t){if(typeof t=="string"&&(super.start=Ys.fromString(t)),t&&!(t instanceof Ys)&&!(t instanceof wn))throw new js("Interval start is not a level 1 date or duration: "+t);this._start=t}get end(){return this._end}set end(t){if(typeof t=="string"&&(t=Ys.fromString(t)),t&&!(t instanceof Ys)&&!(t instanceof wn))throw new js("Interval end is not a level 1 date or duration: "+t);this._end=t}static fromString(t,e=Nt.get(Gd)){const{start:i,end:n}=e.parse(t);return new Gd(i,n)}}class Au extends Ua{uncertainComponent;approximateComponent;constructor(t,e){super(t,e),this.uncertainComponent=t.uncertainComponent||!1,this.approximateComponent=t.approximateComponent||!1}get uncertain(){return super.uncertain||this.uncertainComponent}set uncertain(t){return super.uncertain=t}get approximate(){return super.approximate||this.approximateComponent}set approximate(t){return super.approximate=t}get uncertainGroup(){return super.uncertain}get approximateGroup(){return super.approximate}toSpec(){return{...super.toSpec(),uncertain:this.uncertainGroup,approximate:this.approximateGroup,uncertainComponent:this.uncertainComponent,approximateComponent:this.approximateComponent}}toJSON(){return this.toSpec()}}class q_ extends nE{year=new wi("year",Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER,this.month)}const q1=new q_;class lo extends Au{constructor(t,e=q1.year){super(t,e)}static fromString(t,e=q1.year,i=Nt.get(lo)){const n=i.parse(t),s=n.value.start;if(s!==void 0){const r=new lo(Object.assign({...n},{value:Math.max(s,e.min)})),a=new lo(Object.assign({...n},{value:Math.min(n.value.end,e.max)})),c={start:r,end:a},l=n.value.estimate;return l&&(c.estimate=l),c}else return new lo(n)}}class Z_ extends sE{validate(t){switch(t){case 25:case 26:case 27:case 28:case 29:case 30:case 31:case 32:case 33:case 34:case 35:case 36:case 37:case 38:case 39:case 40:case 41:return!0;default:return super.validate(t)}}}class ho extends Au{constructor(t,e=new wi(le.month.name,1,41,le.day,new Z_)){super(t,e)}static fromString(t,e=Nt.get(ho)){const i=e.parse(t),n=i.value.start;if(n!==void 0){const s=le.month,r=new ho(Object.assign({...i},{value:Math.max(n,s.min)})),a=new ho(Object.assign({...i},{value:Math.min(i.value.end,s.max)}));return{start:r,end:a}}else return new ho(i)}toString(t){return super.toString(t).padStart(2,"0")}}class uo extends Au{constructor(t,e=le.day){super(t,e)}static fromString(t,e=Nt.get(uo)){const i=e.parse(t),n=i.value.start;if(n!==void 0){const s=le.day,r=new uo(Object.assign({...i},{value:Math.max(n,s.min)})),a=new uo(Object.assign({...i},{value:Math.min(i.value.end,s.max)}));return{start:r,end:a}}else return new uo(i)}toString(t){return super.toString(t).padStart(2,"0")}}class fo extends Au{constructor(t,e=le.hour){super(t,e)}static fromString(t,e=Nt.get(fo)){const i=e.parse(t),n=i.value.start;if(n!==void 0){const s=le.hour,r=new fo(Object.assign({...i},{value:Math.max(n,s.min)})),a=new fo(Object.assign({...i},{value:Math.min(i.value.end,s.max)}));return{start:r,end:a}}else return new fo(i)}}class po extends Au{constructor(t,e=le.minute){super(t,e)}static fromString(t,e=Nt.get(po)){const i=e.parse(t),n=i.value.start;if(n!==void 0){const s=le.minute,r=new po(Object.assign({...i},{value:Math.max(n,s.min)})),a=new po(Object.assign({...i},{value:Math.min(i.value.end,s.max)}));return{start:r,end:a}}else return new po(i)}}class mo extends Au{constructor(t,e=le.second){super(t,e)}static fromString(t,e=le.second,i=Nt.get(mo)){const n=i.parse(t),s=n.value.start;if(s!==void 0){const r=new mo(Object.assign({...n},{value:Math.max(s,e.min)})),a=new mo(Object.assign({...n},{value:Math.min(n.value.end,e.max)}));return{start:r,end:a}}else return new mo(n,e)}}class aE extends gl{}class J_ extends If{qualifier(){return""}}class Xo extends Sm{static instance=new Xo;static valueRenderer=new J_(Ha.default);static names=["year","month","day","hour","minute","second"];static qualifier(t,e){return t?e?"%":"?":e?"~":""}renderComponent(t,e){const i=t[e],n=Xo.names.slice(Xo.names.indexOf(e)+1).map(a=>t[a]).filter(Boolean),s=Xo.qualifier(i.uncertainComponent,i.approximateComponent),r=Xo.qualifier(i.uncertainGroup&&!i.uncertainComponent&&!n.some(a=>a.uncertain),i.approximateGroup&&!i.approximateComponent&&!n.some(a=>a.approximate));return s+i.toString(Xo.valueRenderer)+r}}class oE extends XM{constructor(t){super(t)}newYear(t){return new lo(t,this.units.year)}newMonth(t){return new ho(t,this.units.month)}newDay(t){return new uo(t,this.units.day)}newHour(t){return new fo(t,this.units.hour)}newMinute(t){return new po(t,this.units.minute)}newSecond(t){return new mo(t,this.units.second)}newMillisecond(t){return new Ec(t,this.units.millisecond)}newTimeshift(t){return new aE(typeof t=="number"?t:t.value)}}const j_=new oE(q1),Q_=new oE(Rf);class Cs extends Ys{constructor(t){super(t)}toString(t=Xo.instance){return super.toString(t)}get year(){return super.year}set year(t){super.year=t}get month(){return super.month}set month(t){super.month=t}get factory(){return j_}static fromDate(t){return new Cs({year:t.getFullYear(),month:t.getMonth()+1,day:t.getDate(),hour:t.getHours(),minute:t.getMinutes(),second:t.getSeconds(),timeshift:Gn.timeshiftOf(t)})}static fromString(t,e=Nt.get(Cs)){const i=e.parse(t);return new Cs(i)}static newInstance(){const t=new Date().toISOString(),e=t.indexOf("."),i=t.substring(0,e)+t.substring(e+4);return Cs.fromString(i)}clone(){return new Cs(this.toSpec())}}class _o{regExp;constructor(t,e){this.name=t,this.regExp=new RegExp(`^(?:${e})$`)}regexGroups(t){const e=this.regExp.exec(t);if(!e)throw new js(`Invalid ${this.name} "${t}"`);return e.groups}parseGroups(t){throw new Hc(`${this.constructor.name} is abstract`)}parse(t){const e=this.regexGroups(t);return this.parseGroups(e)}}class bh extends Am{static instance=new bh;static designators=[["years","Y"],["months","MM"],["days","D"],["hours","H"],["minutes","M"],["seconds","S"]];static qualifier(t,e){return t?e?"%":"?":e?"~":""}render(t){const e=bh.qualifier(t.uncertainDuration,t.approximateDuration);if(!t.hasQualifiedComponent)return e+super.render(t);let i=e+"P";for(const[n,s]of bh.designators){const r=t.components[n];r&&(i+=bh.qualifier(r.uncertainComponent,r.approximateComponent)+r.value+s)}return i}}class Mn extends wn{#t;constructor(t){if(super(typeof t=="number"?t:{value:Mn.valueFromSpec(t),uncertain:t.uncertain===!0,approximate:t.approximate===!0},Rf.millisecond),typeof t!="number"){const e={};for(const i of Mn.componentNames)t[i]instanceof Ua&&(e[i]=t[i]);Object.keys(e).length>0&&(this.#t=e)}}static componentNames=["years","months","days","hours","minutes","seconds"];get components(){return this.#t}#e(t){return this.#t?Object.values(this.#t).some(e=>e[t]):!1}get uncertainDuration(){return super.uncertain}get approximateDuration(){return super.approximate}get uncertain(){return super.uncertain||this.#e("uncertain")}set uncertain(t){super.uncertain=t}get approximate(){return super.approximate||this.#e("approximate")}set approximate(t){super.approximate=t}get hasQualifiedComponent(){return this.#t?Object.values(this.#t).some(t=>t.uncertainComponent||t.approximateComponent):!1}static valueFromSpec(t){return Mn.getValue(t,En.year)+Mn.getValue(t,En.month)+Mn.getValue(t,En.day)+Mn.getValue(t,En.hour)+Mn.getValue(t,En.minute)+Mn.getValue(t,En.second)}static toSpec(t,e=Q_){const i=wn.toSpec(t,e);if(t instanceof Mn&&t.hasQualifiedComponent)for(const n of Mn.componentNames)delete i[n],t.components[n]&&(i[n]=t.components[n]);return i}static fromString(t,e=Nt.get(Mn)){const i=e.parse(t);return new Mn(i)}static between(t,e){const i=e.getTime(),n=t.getTime();return new Mn(i-n)}toSpec(){return Mn.toSpec(this)}toString(t=bh.instance){return super.toString(t)}}class Vd extends Gd{get start(){return this._start}set start(t){if(typeof t=="string"&&(super.start=Cs.fromString(t)),t&&!(t instanceof Cs)&&!(t instanceof Mn))throw new js("Interval start is not a level 2 date or duration: "+t);this._start=t}get end(){return this._end}set end(t){if(typeof t=="string"&&(t=Cs.fromString(t)),t&&!(t instanceof Cs)&&!(t instanceof Mn))throw new js("Interval end is not a level 2 date or duration: "+t);this._end=t}static fromString(t,e=Nt.get(Vd)){const{start:i,end:n}=e.parse(t);return new Vd(i,n)}}class D0 extends Set{constructor(t,e){super(t),this.exclusive=e}has(t){const e=t.toString().replace("..","/");for(const i of this)if(i.toString()===e)return!0;return!1}static fromString(t,e=Nt.get(D0)){const{exclusive:i,values:n}=e.parse(t);return new D0(n,i)}}class To extends _o{constructor(t,e){super(t,e)}static read(t){return{value:t?parseInt(t,10):void 0}}parseGroups(t){return To.read(t[this.name])}parse(t){if(t.startsWith("-"))throw new js(`${this.name} cannot be negative`);return super.parse(t)}}class F{static groupName(...t){return t.reduce((e,i)=>e?e+i.charAt(0).toUpperCase()+i.substring(1):i,"")}static group(t,...e){return`(?<${t}>${e.join("")})`}static optional(t){return t+"?"}static nonCapturingGroup(...t){return`(?:${t.join("")})`}static optionalGroup(t,...e){return F.optional(F.group(t,...e))}static optionalNonCapturingGroup(...t){return F.optional(F.nonCapturingGroup(...t))}static numberGroup(t,e,i,n="\\d"){return F.group(t,`${i||""}[${n}]${e}`)}}const h2="yearValue";class Wd extends To{static format(t=""){return F.numberGroup(F.groupName(t,h2),"{4}",void 0)}constructor(){super(h2,Wd.format())}}const u2="monthValue";class Xd extends To{static format(t=""){return F.numberGroup(F.groupName(t,u2),"{1,2}",void 0)}constructor(){super(u2,Xd.format())}}const d2="dayValue";class $h extends To{static format(t=""){return F.numberGroup(F.groupName(t,d2),"{1,2}",void 0)}constructor(){super(d2,$h.format())}}const f2="hourValue";class Yh extends To{static format(t=""){return F.numberGroup(F.groupName(t,f2),"{1,2}",void 0)}constructor(){super(f2,Yh.format())}}const p2="minuteValue";class $d extends To{static format(t=""){return F.numberGroup(F.groupName(t,p2),"{1,2}",void 0)}constructor(){super(p2,$d.format())}}const m2="secondValue";class Yd extends To{static format(t=""){return F.numberGroup(F.groupName(t,m2),"{1,2}",void 0)}constructor(){super(m2,Yd.format())}}const g2="timeshiftValue",v2="shiftHour",M2="shiftMinute";class pu extends _o{static format(t=""){return l2.map(e=>e.name).join("|")+"|"+F.nonCapturingGroup(F.group(t+v2,F.numberGroup(F.groupName(t,g2),"{2}","[+-]")),F.optionalNonCapturingGroup(":?",F.numberGroup(F.groupName(t,M2),"{2}",void 0)))}constructor(){super(g2,pu.format())}parse(t,e){let i=0;const n=l2.find(s=>s.name===t);if(n){if(typeof n.timeshift=="function")try{return n.timeshift(e??{})}catch(s){throw new js(`The time zone ${t} depends on the date: ${s.message}`)}t=n.timeshift}if(t!=="Z"){const s=this.regexGroups(t),r=s[v2];r&&(i+=parseInt(r,10)*60);const a=s[M2];a&&(i+=parseInt(a,10))}return i}}const y2="year",w2="month",b2="day",x2="hour",S2="minute",E2="second",A2="millisecond",_2="timeshift";class jc extends _o{static format(t=""){return F.group(F.groupName(t,y2),Wd.format(t))+F.optionalNonCapturingGroup("-",F.group(F.groupName(t,w2),Xd.format(t)),F.optionalNonCapturingGroup("-",F.group(F.groupName(t,b2),$h.format(t)),F.optionalNonCapturingGroup("[T ]",F.group(F.groupName(t,x2),Yh.format(t)),":?",F.group(F.groupName(t,S2),$d.format(t)),F.optionalNonCapturingGroup(":",F.group(F.groupName(t,E2),Yd.format(t)),F.optionalNonCapturingGroup("[.,]",F.group(F.groupName(t,A2),"\\d+"))),"\\s*",F.optionalGroup(F.groupName(t,_2),pu.format(t)))))}constructor(){super("date",jc.format())}parse(t){const e=this.regexGroups(t),i=e[y2],n=e[w2],s=e[b2],r=e[x2],a=e[S2],c=e[E2],l=e[A2],h=e[_2],u=i?new cu(Wd.read(i)):void 0,d=n?Xd.read(n):void 0;return{year:u,month:d?new lu(d,wh.create(d.value,u?.value)):void 0,day:s?new hu($h.read(s)):void 0,hour:r?new uu(Yh.read(r)):void 0,minute:a?new du($d.read(a)):void 0,second:c?new fu(Yd.read(c)):void 0,millisecond:l?Ec.parseFraction(l):void 0,timeshift:h?yc.fromString(h,new pu,{year:u?.value,month:d?.value,day:s?$h.read(s).value:void 0,hour:r?Yh.read(r).value:void 0}):void 0}}}const T2="years",qm="months",tT="days",R2="hours",I2="minutes",D2="seconds";class YM extends _o{static format(t=""){return"P"+F.optionalNonCapturingGroup(F.numberGroup(F.groupName(t,T2),"+",void 0,"\\d"),"Y")+F.optionalNonCapturingGroup(F.numberGroup(F.groupName(t,qm),"+",void 0,"\\d"),"MM")+F.optionalNonCapturingGroup(F.numberGroup(F.groupName(t,tT),"+",void 0,"\\d"),"D")+F.optionalNonCapturingGroup(F.numberGroup(F.groupName(t,R2),"+",void 0,"\\d"),"H")+F.optionalNonCapturingGroup(F.numberGroup(F.groupName(t,I2),"+",void 0,"\\d"),"M")+F.optionalNonCapturingGroup(F.numberGroup(F.groupName(t,D2),"+",void 0,"\\d"),"S")}constructor(){super("duration",YM.format())}parseGroups(t){return{years:t[T2],months:t[qm],days:t[qm],hours:t[R2],minutes:t[I2],seconds:t[D2]}}}const Zm="start",Jm="end";class KM extends _o{static format=F.group(Zm,jc.format(Zm))+"/"+F.group(Jm,jc.format(Jm));constructor(){super("interval",KM.format)}parse(t){const e=this.regexGroups(t),i=e[Zm],n=e[Jm];return{start:i?Gn.fromString(i,new jc):void 0,end:n?Gn.fromString(n,new jc):void 0}}}class Pi extends To{static uncertainGroup="uncertain";static approximateGroup="approx";static uncertainAndApproximateGroup=Pi.uncertainGroup+Pi.approximateGroup;constructor(t,e){super(t,e)}static qualifierFormat(t,e){return F.optionalGroup(t,`\\${e}`)}static formatSuffix(t){return this.qualifierFormat(F.groupName(Pi.uncertainGroup,t),"?")+this.qualifierFormat(F.groupName(Pi.approximateGroup,t),"~")+this.qualifierFormat(F.groupName(Pi.uncertainAndApproximateGroup,t),"%")}static numberFormat(t,e,i){return F.numberGroup(t,e,i,"\\dX")+this.formatSuffix(t)}getValueAndSign(t){let e=t[this.name],i;return e.charAt(0)==="-"?(i=-1,e=e.substring(1)):i=1,{valueStr:e,sign:i}}parseGroups(t){const{valueStr:e,sign:i}=this.getValueAndSign(t);let n=0,s;for(s=0;s<e.length;s++){const l=e[s];if(l==="X")break;n=n*10+parseInt(l,10)}if(s<e.length){let l=1;for(let d=0;d<e.length-s;d++)l*=10;const h=i*n*l,u=h+l-1;n={start:h,end:u}}else n*=i;const r=t[F.groupName(Pi.uncertainAndApproximateGroup,this.name)],a=t[F.groupName(Pi.approximateGroup,this.name)]||r,c=t[F.groupName(Pi.uncertainGroup,this.name)]||r;return{value:n,approximate:a?!!a:!1,uncertain:c?!!c:!1}}}const C2="yearValue";class Kd extends Pi{constructor(){super(C2,Kd.format())}static format(t=""){return"Y?"+Pi.numberFormat(F.groupName(t,C2),"+","[-]?")}parse(t){const e=this.regexGroups(t);return this.parseGroups(e)}}const O2="monthValue";class qd extends Pi{static format(t=""){return Pi.numberFormat(F.groupName(t,O2),"{1,2}",void 0)}constructor(){super(O2,qd.format())}}const P2="dayValue";class Zd extends Pi{static format(t=""){return Pi.numberFormat(F.groupName(t,P2),"{1,2}",void 0)}constructor(){super(P2,Zd.format())}}const L2="hourValue";class Jd extends Pi{static format(t=""){return Pi.numberFormat(F.groupName(t,L2),"{1,2}",void 0)}constructor(){super(L2,Jd.format())}}const N2="minuteValue";class jd extends Pi{static format(t=""){return Pi.numberFormat(F.groupName(t,N2),"{1,2}",void 0)}constructor(){super(N2,jd.format())}}const k2="secondValue";class Qd extends Pi{static format(t=""){return Pi.numberFormat(F.groupName(t,k2),"{1,2}",void 0)}constructor(){super(k2,Qd.format())}}class tf extends pu{}class Vi extends _o{static yearGroup="year";static monthGroup="month";static dayGroup="day";static hourGroup="hour";static minuteGroup="minute";static secondGroup="second";static millisecondGroup="millisecond";static timeshiftGroup="timeshift";constructor(t=Vi.format()){super("date",t)}static format(t=""){return F.group(F.groupName(t,Vi.yearGroup),Kd.format(t))+F.optionalNonCapturingGroup("-",F.group(F.groupName(t,Vi.monthGroup),qd.format(t)),F.optionalNonCapturingGroup("-",F.group(F.groupName(t,Vi.dayGroup),Zd.format(t)),F.optionalNonCapturingGroup("[T ]",F.group(F.groupName(t,Vi.hourGroup),Jd.format(t)),":",F.group(F.groupName(t,Vi.minuteGroup),jd.format(t)),F.optionalNonCapturingGroup(":",F.group(F.groupName(t,Vi.secondGroup),Qd.format(t)),F.optionalNonCapturingGroup("[.,]",F.group(F.groupName(t,Vi.millisecondGroup),"\\d+"))),F.optionalGroup(F.groupName(t,Vi.timeshiftGroup),tf.format(t)))))}parseGroups(t){const e=t[Vi.millisecondGroup],i=e?Ec.parseFraction(e):void 0,n=t[Vi.secondGroup],s=n?lc.fromString(n,new Qd):void 0,r=t[Vi.minuteGroup];let a;r&&(a=cc.fromString(r,new jd),a.uncertain=a.uncertain||s?.uncertain||!1,a.approximate=a.approximate||s?.approximate||!1);const c=t[Vi.hourGroup];let l;c&&(l=oc.fromString(c,new Jd),l.uncertain=l.uncertain||a?.uncertain||!1,l.approximate=l.approximate||a?.approximate||!1);const h=t[Vi.dayGroup];let u;h&&(u=ac.fromString(h,new Zd),u.uncertain=u.uncertain||l?.uncertain||!1,u.approximate=u.approximate||l?.approximate||!1);const d=t[Vi.monthGroup];let f;d&&(f=rc.fromString(d,new qd),f.uncertain=f.uncertain||u?.uncertain||!1,f.approximate=f.approximate||u?.approximate||!1);const p=t[Vi.yearGroup];let m;p&&(m=sc.fromString(p,void 0,new Kd),m.uncertain=m.uncertain||f?.uncertain||!1,m.approximate=m.approximate||f?.approximate||!1);const g=t[Vi.timeshiftGroup],v=g?gl.fromString(g,new tf,{year:m?.value,month:f?.value,day:u?.value,hour:l?.value}):void 0;return{year:m,month:f,day:u,hour:l,minute:a,second:s,millisecond:i,timeshift:v}}}const F2="years",U2="months",z2="days",B2="hours",H2="minutes",G2="seconds";class Qc extends Pi{static format(t=""){return"P"+F.optionalNonCapturingGroup(F.numberGroup(F.groupName(t,F2),"+",void 0,"\\d"),"Y")+F.optionalNonCapturingGroup(F.numberGroup(F.groupName(t,U2),"+",void 0,"\\d"),"MM")+F.optionalNonCapturingGroup(F.numberGroup(F.groupName(t,z2),"+",void 0,"\\d"),"D")+F.optionalNonCapturingGroup(F.numberGroup(F.groupName(t,B2),"+",void 0,"\\d"),"H")+F.optionalNonCapturingGroup(F.numberGroup(F.groupName(t,H2),"+",void 0,"\\d"),"M")+F.optionalNonCapturingGroup(F.numberGroup(F.groupName(t,G2),"+",void 0,"\\d"),"S")+this.formatSuffix(t)}constructor(){super("duration",Qc.format())}parseGroups(t){return{years:t[F2],months:t[U2],days:t[z2],hours:t[B2],minutes:t[H2],seconds:t[G2],uncertain:!!t[Pi.uncertainGroup],approximate:!!t[Pi.approximateGroup]}}}const eT="dates",jm="start",Qm="end",V2="durations",tg="durationMin",eg="durationMax";class qM extends _o{static format=F.group(eT,F.optionalGroup(jm,F.group("openStart","\\.\\.")+"|"+Vi.format(jm))+"/"+F.optionalGroup(Qm,F.group("openEnd","\\.\\.")+"|"+Vi.format(Qm)))+"|"+F.group(V2,F.group(tg,Qc.format(tg))+"/"+F.group(eg,Qc.format(eg)));constructor(t="interval",e=qM.format){super(t,e)}parseGroups(t){let e,i;if(t[V2]){const s=t[tg];e=wn.fromString(s,new Qc);const r=t[eg];i=wn.fromString(r,new Qc)}else{const s=t[jm];switch(s){case void 0:e=null;break;case"..":e=void 0;break;default:e=Ys.fromString(s,new Vi)}const r=t[Qm];switch(r){case void 0:i=null;break;case"..":i=void 0;break;default:i=Ys.fromString(r,new Vi)}}return{start:e,end:i}}}class Ke extends Pi{static uncertainGroup="uncertain1";static approximateGroup="approx1";static uncertainAndApproximateGroup=Ke.uncertainGroup+Ke.approximateGroup;constructor(t,e){super(t,e)}static numberFormat(t,e,i){return this.qualifierFormat(F.groupName(Ke.uncertainGroup,t),"?")+this.qualifierFormat(F.groupName(Ke.approximateGroup,t),"~")+this.qualifierFormat(F.groupName(Ke.uncertainAndApproximateGroup,t),"%")+Pi.numberFormat(t,e,i)}parseGroups(t){const e=super.parseGroups(t),i=t[F.groupName(Ke.uncertainAndApproximateGroup,this.name)];return(t[F.groupName(Ke.uncertainGroup,this.name)]||i)&&(e.uncertainComponent=!0),(t[F.groupName(Ke.approximateGroup,this.name)]||i)&&(e.approximateComponent=!0),e}}const Du="yearValue",W2="exp",X2="signif";class ef extends Ke{constructor(){super(Du,ef.format())}static format(t=""){return"Y?"+F.nonCapturingGroup(F.group(F.groupName(t,W2),"[-]?\\d+E\\d+")+"|"+Ke.numberFormat(F.groupName(t,Du),"+","[-]?")+F.optionalGroup(F.groupName(t,X2),"S\\d+"))}parseGroups(t){const e=t[W2];if(e){const r=e.indexOf("E"),a=parseInt(e.substring(r+1),10),l=parseInt(e.substring(0,r),10)*Math.pow(10,a);t[Du]=l.toString()}const i=t[X2],n=t[Du];if(i){const r=parseInt(i.substring(1),10),{valueStr:a,sign:c}=this.getValueAndSign(t);let l="";for(let h=0;h<a.length;h++)l+=h<r?a.charAt(h):"X";t[Du]=(c<0?"-":"")+l}const s=super.parseGroups(t);return i&&(s.value.estimate=parseInt(n,10)),s}parse(t){const e=this.regexGroups(t);return this.parseGroups(e)}}const $2="monthValue";class nf extends Ke{static format(t=""){return Ke.numberFormat(F.groupName(t,$2),"{1,2}",void 0)}constructor(){super($2,nf.format())}}const Y2="dayValue";class sf extends Ke{static format(t=""){return Ke.numberFormat(F.groupName(t,Y2),"{1,2}",void 0)}constructor(){super(Y2,sf.format())}}const K2="hourValue";class rf extends Ke{static format(t=""){return Ke.numberFormat(F.groupName(t,K2),"{1,2}",void 0)}constructor(){super(K2,rf.format())}}const q2="secondValue";class af extends Ke{static format(t=""){return Ke.numberFormat(F.groupName(t,q2),"{1,2}",void 0)}constructor(){super(q2,af.format())}}const Z2="minuteValue";class of extends Ke{static format(t=""){return Ke.numberFormat(F.groupName(t,Z2),"{1,2}",void 0)}constructor(){super(Z2,of.format())}}class iT extends tf{}class ti extends _o{static yearGroup=Vi.yearGroup;static monthGroup="month";static dayGroup="day";static hourGroup="hour";static minuteGroup="minute";static secondGroup="second";static millisecondGroup="millisecond";static timeshiftGroup="timeshift";constructor(){super("date",ti.format())}static format(t=""){return F.group(F.groupName(t,ti.yearGroup),ef.format(t))+F.optionalNonCapturingGroup("-",F.group(F.groupName(t,ti.monthGroup),nf.format(t)),F.optionalNonCapturingGroup("-",F.group(F.groupName(t,ti.dayGroup),sf.format(t)),F.optionalNonCapturingGroup("[T ]",F.group(F.groupName(t,ti.hourGroup),rf.format(t)),":",F.group(F.groupName(t,ti.minuteGroup),of.format(t)),F.optionalNonCapturingGroup(":",F.group(F.groupName(t,ti.secondGroup),af.format(t)),F.optionalNonCapturingGroup("[.,]",F.group(F.groupName(t,ti.millisecondGroup),"\\d+"))),F.optionalGroup(F.groupName(t,ti.timeshiftGroup),iT.format(t)))))}parseGroups(t){const e=t[ti.millisecondGroup],i=e?Ec.parseFraction(e):void 0,n=t[ti.secondGroup];let s;n&&(s=mo.fromString(n,void 0,new af),s.uncertain=s?.uncertain||!1,s.approximate=s?.approximate||!1);const r=t[ti.minuteGroup];let a;r&&(a=po.fromString(r,new of),a.uncertain=a.uncertain||s?.uncertain||!1,a.approximate=a.approximate||s?.approximate||!1);const c=t[ti.hourGroup];let l;c&&(l=fo.fromString(c,new rf),l.uncertain=l.uncertain||a?.uncertain||!1,l.approximate=l.approximate||a?.approximate||!1);const h=t[ti.dayGroup];let u;h&&(u=uo.fromString(h,new sf),u.uncertain=u.uncertain||l?.uncertain||!1,u.approximate=u.approximate||l?.approximate||!1);const d=t[ti.monthGroup];let f;d&&(f=ho.fromString(d,new nf),f.uncertain=f.uncertain||u?.uncertain||!1,f.approximate=f.approximate||u?.approximate||!1);const p=t[ti.yearGroup];let m;p&&(m=lo.fromString(p,void 0,new ef),m.uncertain=m.uncertain||f?.uncertain||!1,m.approximate=m.approximate||f?.approximate||!1);const g=t[ti.timeshiftGroup],v=g?aE.fromString(g,new tf,{year:m?.value,month:f?.value,day:u?.value,hour:l?.value}):void 0;return{year:m,month:f,day:u,hour:l,minute:a,second:s,millisecond:i,timeshift:v}}}const J2="durationValue";class ZM extends Ke{static format(t=""){return"^"+Ke.numberFormat(F.groupName(t,J2),"+",void 0)}constructor(){super(J2,ZM.format())}}class nT extends WM{millisecond=new wi("millisecond",0,Number.MAX_SAFE_INTEGER,void 0);second=new wi("second",0,Number.MAX_SAFE_INTEGER,this.millisecond);minute=new wi("minute",0,Number.MAX_SAFE_INTEGER,this.second);hour=new wi("hour",0,Number.MAX_SAFE_INTEGER,this.minute);day=new wi("day",1,Number.MAX_SAFE_INTEGER,this.hour);month=new wi("month",1,Number.MAX_SAFE_INTEGER,this.day);year=new wi("year",0,Number.MAX_SAFE_INTEGER,this.month)}const Il=new nT;class ne extends Ke{static yearsGroup="years";static monthsGroup="months";static isoMonthsGroup="isoMonths";static daysGroup="days";static hoursGroup="hours";static minutesGroup="minutes";static secondsGroup="seconds";static durationGroup="duration";static suffixGroup="durationSuffix";static componentParser=new ZM;static componentFormat(t,e,i,n,s=""){const r=F.group(F.groupName(t,ne.quantityGroup(e)),Ke.numberFormat(F.groupName(t,i),"+",void 0,"\\d"));return F.group(F.groupName(t,e),r,n,s)}static quantityGroup(t){return t+"Quantity"}static isoMonthsLookahead="(?=[?~%]?\\d+D|T)";constructor(){super("duration",ne.format())}static format(t=""){const e=F.groupName(t,ne.durationGroup);return this.qualifierFormat(F.groupName(Ke.uncertainGroup,e),"?")+this.qualifierFormat(F.groupName(Ke.approximateGroup,e),"~")+this.qualifierFormat(F.groupName(Ke.uncertainAndApproximateGroup,e),"%")+"P"+F.optional(ne.componentFormat(t,ne.yearsGroup,ti.yearGroup,"Y"))+F.optionalNonCapturingGroup(ne.componentFormat(t,ne.monthsGroup,ti.monthGroup,"MM")+"|"+ne.componentFormat(t,ne.isoMonthsGroup,"isoMonth","M",ne.isoMonthsLookahead))+F.optional(ne.componentFormat(t,ne.daysGroup,ti.dayGroup,"D"))+"T?"+F.optional(ne.componentFormat(t,ne.hoursGroup,ti.hourGroup,"H"))+F.optional(ne.componentFormat(t,ne.minutesGroup,ti.minuteGroup,"M"))+F.optional(ne.componentFormat(t,ne.secondsGroup,ti.secondGroup,"S"))+F.optionalGroup(F.groupName(t,ne.suffixGroup),"[?~%]")}static parseComponent(t,e,i){const n=ne.componentParser.parse(t);return new e(n,i)}parseGroups(t){const e=t[ne.quantityGroup(ne.secondsGroup)];let i;e&&(i=ne.parseComponent(e,mo,Il.second),i.uncertain=!!t[F.groupName(Ke.uncertainGroup,ne.secondsGroup)]||!1,i.approximate=!!t[F.groupName(Ke.approximateGroup,ne.secondsGroup)]||!1);const n=t[ne.quantityGroup(ne.minutesGroup)];let s;n&&(s=ne.parseComponent(n,po,Il.minute),s.uncertain=s.uncertain||i?.uncertain||!1,s.approximate=s.approximate||i?.approximate||!1);const r=t[ne.quantityGroup(ne.hoursGroup)];let a;r&&(a=ne.parseComponent(r,fo,Il.hour),a.uncertain=a.uncertain||s?.uncertain||!1,a.approximate=a.approximate||s?.approximate||!1);const c=t[ne.quantityGroup(ne.daysGroup)];let l;c&&(l=ne.parseComponent(c,uo,Il.day),l.uncertain=l.uncertain||a?.uncertain||!1,l.approximate=l.approximate||a?.approximate||!1);const h=t[ne.quantityGroup(ne.monthsGroup)]||t[ne.quantityGroup(ne.isoMonthsGroup)];let u;h&&(u=ne.parseComponent(h,ho,Il.month),u.uncertain=u.uncertain||l?.uncertain||!1,u.approximate=u.approximate||l?.approximate||!1);const d=t[ne.quantityGroup(ne.yearsGroup)];let f;d&&(f=ne.parseComponent(d,lo,Il.year),f.uncertain=f.uncertain||u?.uncertain||!1,f.approximate=f.approximate||u?.approximate||!1);const p=t[ne.suffixGroup],m=!!t[F.groupName(Ke.uncertainAndApproximateGroup,ne.durationGroup)]||p==="%",g=m||!!t[F.groupName(Ke.uncertainGroup,ne.durationGroup)]||p==="?",v=m||!!t[F.groupName(Ke.approximateGroup,ne.durationGroup)]||p==="~";return{years:f,months:u,days:l,hours:a,minutes:s,seconds:i,uncertain:g,approximate:v}}}const sT="dates",ig="start",ng="end",j2="durations",sg="durationMin",rg="durationMax";class _m extends _o{static format=F.group(sT,F.optionalGroup(ig,F.group("openStart","\\.\\.")+"|"+ti.format(ig))+"/"+F.optionalGroup(ng,F.group("openEnd","\\.\\.")+"|"+ti.format(ng)))+"|"+F.group(j2,F.group(sg,ne.format(sg))+"/"+F.group(rg,ne.format(rg)));constructor(t="interval",e=_m.format){super(t,e)}parseGroups(t){let e,i;if(t[j2]){const s=t[sg];e=Mn.fromString(s,new ne);const r=t[rg];i=Mn.fromString(r,new ne)}else{const s=t[ig];switch(s){case void 0:e=null;break;case"..":e=void 0;break;default:e=Cs.fromString(s,new ti)}const r=t[ng];switch(r){case void 0:i=null;break;case"..":i=void 0;break;default:i=Cs.fromString(r,new ti)}}return{start:e,end:i}}}class rT{parse(t){t=t.trim();const e=t.startsWith("["),n=t.substring(1,t.length-1).split(","),s=[];for(const r of n){let a;r.includes("..")?a=Vd.fromString(r.replace("..","/"),new _m):a=Cs.fromString(r,new ti),s.push(a)}return{values:s,exclusive:e}}}const cE=["spring","summer","autumn","winter"],Z1=21,aT=32,oT=/^(?<hour>[01]?\d|2[0-3]):(?<minute>[0-5]\d)(?::(?<second>[0-5]\d))?[?~%]?$/;let cT;function lT(){return cT??=new ti}function Dl(o){return typeof o?.value=="number"?o.value:void 0}function qs(o){const t=o.trim();if(/^\d{1,2}:/.test(t)){const r=oT.exec(t)?.groups;return r?{year:void 0,month:void 0,day:void 0,hour:Number(r.hour),minute:Number(r.minute),second:r.second?Number(r.second):void 0,raw:t}:void 0}let e;try{e=Cs.fromString(t,lT())}catch{return}const i=Dl(e.year),n=Dl(e.month),s=n!==void 0&&n>=Z1&&n<=aT;if(!(e.timeshift||i!==void 0&&Math.abs(i)>9999)&&!(n!==void 0&&n>12&&!s)&&!(s&&(e.day||e.hour)))return{year:i,month:s?void 0:n,...s?{season:cE[(n-Z1)%4]}:{},day:Dl(e.day),hour:Dl(e.hour),minute:Dl(e.minute),second:Dl(e.second),raw:t}}function xh(o){if(o.raw!==void 0)return o.raw;if(o.year===void 0){if(o.hour===void 0)return"";let e=`${String(o.hour).padStart(2,"0")}:${String(o.minute??0).padStart(2,"0")}`;return o.second!==void 0&&(e+=`:${String(o.second).padStart(2,"0")}`),e}let t=String(o.year).padStart(4,"0");return o.season!==void 0?`${t}-${Z1+cE.indexOf(o.season)}`:(o.month===void 0||(t+=`-${String(o.month).padStart(2,"0")}`,o.day===void 0)||(t+=`-${String(o.day).padStart(2,"0")}`,o.hour===void 0)||(t+=`T${String(o.hour).padStart(2,"0")}:${String(o.minute??0).padStart(2,"0")}`,o.second!==void 0&&(t+=`:${String(o.second).padStart(2,"0")}`)),t)}function J1(o){if(o.year!==void 0)return Date.UTC(o.year,(o.month??1)-1,o.day??1,o.hour??0,o.minute??0,o.second??0)}function Q2(o){return(((o.day??0)*24+(o.hour??0))*60+(o.minute??0))*6e4+(o.second??0)*1e3}const hT=["year","month","day","hour","minute"],uT=["day","hour","minute"];function tw(o,t){return t.filter(e=>o[e]!==void 0).join(",")}function lE(o){if(o.durationSeconds!==void 0)return o.durationSeconds*1e3;const t=o.durationText===void 0?void 0:Xh.parse(o.durationText);if(t)return t.chosenSeconds*1e3;if(!o.time||!o.endTime)return;const e=o.time.year!==void 0&&o.endTime.year!==void 0,i=e?hT:uT,n=tw(o.time,i);if(!(n===""||n!==tw(o.endTime,i)))return e?J1(o.endTime)-J1(o.time):Q2(o.endTime)-Q2(o.time)}class Tm{constructor(t,e,i,n,s,r,a,c,l=[],h,u,d,f=[],p=[],m=[],g=[]){this.event=t,this.timeline=e,this.observerTrack=i,this.weatherTrack=n,this.soundTrack=s,this.observer=r,this.id=a,this.weather=c,this.decor=l,this.weatherSource=h,this.instrumentId=u,this.exposureSeconds=d,this.milestones=f,this.references=p,this.roads=m,this.traces=g}provenance=Je.empty();loadIssues=[];account;sources;interpretation;variants=[];skyEvents;snapshots;modules;sway;lightPollution;observerMap;iso;film;metering;lens;lighting;vehicle;events;eventsExpansion;sampleMs;get observerCount(){return 1+this.decor.filter(t=>t.kind==="observer").length}get exposure(){return this.exposureSeconds??this.instrument.exposureSeconds}get instrument(){return Ti.byId(this.instrumentId)}static create(t,e,i){return new Tm({eventType:"sighting",time:t,place:e},new Tf,new Ud,new zd,new Bd,i)}}const dT=0,fT=0;function Oe(o,t){const e=o.observerTrack.getInterpolatedPoseAt(t);if(e)return e;const i=o.event.place?.[0];if(i)return{lat:i.lat,lng:i.lng,elevationM:dT,headingDeg:void 0,pitchDeg:fT,fovDeg:Ti.fieldOfViewDeg(o.instrument)}}function mh(o,t){return o.weatherTrack.getInterpolatedWeatherAt(t)??o.weather??bm}function Cu(o,t){return o.weatherTrack.getActualWeatherAt(t)??o.weather??bm}function hE(o,t){return o.soundTrack.getInterpolatedSoundAt(t)??d_}class la{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 la.statedKinds(t).length===0}static written(t){const e=la.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 la.statedKinds(t))n[r]=t[r];for(const r of la.KINDS){const a=[...t?.[r]??[],...i?.[r]??[]];a.length>0&&(n[r]=a)}let s=e;if(i&&la.KINDS.some(r=>r in i)){const{beams:r,launches:a,reentries:c,...l}=i;s=la.isReading(l)?l:void 0}return{skyEvents:la.written(n),interpretation:s}}static isReading(t){return(t.bodies?.length??0)>0||t.title!==void 0||(t.smoke?.length??0)>0}}function md(o){return[...o].sort((t,e)=>t.t-e.t)}function Uf(o,t){let e;for(const i of md(o)){if(i.t>t)break;e=i}return e}const ag=Math.PI/180,zf=180/Math.PI;class Aa{constructor(t,e,i){this.kind=t,this.canvasHeightPx=e,this.fovDeg=i;const n=i*ag/2;this.focalPx=t==="equidistant"?e/2/n:e/2/Math.tan(n)}focalPx;static of(t,e,i){return new Aa(t.projection,e,i)}degToPx(t){const e=t*ag;return this.kind==="equidistant"?this.focalPx*e:2*this.focalPx*Math.tan(e/2)}pxToDeg(t){return this.kind==="equidistant"?t/this.focalPx*zf:2*Math.atan(t/(2*this.focalPx))*zf}angleDegToRadiusPx(t){const e=t*ag;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*zf:Math.atan(t/this.focalPx)*zf}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(mi.angularWidthDeg(t))}}class bn{static fovOf(t,e){return Oe(t,e)?.fovDeg??Ti.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)<bn.UNMOVED_PX&&Math.abs(s.y-e.bounds.y)<bn.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=Aa.of(t.instrument,mi.CANVAS_HEIGHT_PX,this.fovOf(t,e));return this.aimFrom(t,n,Oe(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=Oe(t,s.t),c=Aa.of(t.instrument,mi.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(([g,v])=>g!=="bounds"&&g!=="points"&&JSON.stringify(v)!==JSON.stringify(u[g]))),p={...d,...f},m=this.placedByAim(t,this.sizedFromAngle(p,c),c,a);bn.near(m,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)<=bn.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:Ti.frameWidthPx(t.instrument,mi.CANVAS_HEIGHT_PX)/2,y:mi.CANVAS_HEIGHT_PX/2}}static shortestArc(t){return(t%360+540)%360-180}static offAxisPx(t,e){return Math.abs(e)>=bn.OFF_CANVAS_DEG?Math.sign(e)*bn.OFF_CANVAS_PX:t.angleDegToRadiusPx(e)}static OFF_CANVAS_DEG=89;static OFF_CANVAS_PX=1e5;static reproject(t,e,i){const n=Ti.frameWidthPx(e,mi.CANVAS_HEIGHT_PX)/2,s=Ti.frameWidthPx(t.instrument,mi.CANVAS_HEIGHT_PX)/2,r=mi.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=Aa.of(e,mi.CANVAS_HEIGHT_PX,l),u=Aa.of(t.instrument,mi.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,m=f.y+f.height/2-r,g=Math.hypot(p,m),v=g===0?1:u.angleDegToRadiusPx(h.radiusPxToAngleDeg(g))/g,M={...f,x:s+p*v-f.width/2,y:r+m*v-f.height/2};return{...d,shape:{...d.shape,bounds:M}}}))}this.toBounds(t)}static eachKeyframe(t,e){const{timeline:i}=t;for(const n of[...i.allKeyframes]){const s=Oe(t,n.t),r=this.fovOf(t,n.t),a=Aa.of(t.instrument,mi.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 vl{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"&&vl.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<vl.AUTO_BELOW_SUN_DEG?"dipped":"off"}static lamps(t){return t!=="off"}}function pT(o){return o==="vehicle"?["front","behind","front-left","front-right","behind-left","behind-right"]:["front","behind","left","right"]}const mT=90,C0=2;function uE(o){return o==="building"||o==="vehicle"}function gT(o,t){return o==="building"?!0:o==="vehicle"?t!=="front"&&t!=="behind":!1}function mu(o){return o==="building"||o==="vehicle"}const dE={aircraft:{id:"poly-google-airliner"},tree:{id:"jungle-jim-tree-large-a"},observer:{id:"makehuman-farmer-40s"},entity:{id:"makehuman-farmer-40s"}},vT=["makehuman-farmer-40s","makehuman-man-overalls","makehuman-man-jacket","makehuman-old-man","makehuman-woman"];function ew(o,t){let e=0;for(const i of t)e=e*31+i.charCodeAt(0)>>>0;return{id:o[e%o.length]}}const MT=["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 O0(o){return o.model?o.model:o.kind==="tree"&&o.id!==void 0?ew(MT,o.id):(o.kind==="observer"||o.kind==="entity")&&o.id!==void 0?ew(vT,o.id):dE[o.kind]}function fE(o,t){const e=vl.at(o.headlights,o.headlightKeyframes,t);return e!==void 0?e:Rm(o,t)?"dipped":"off"}class cf{static DEFAULT_KIND="airliner-narrow";static kindOf(t,e){if(t.kind!=="aircraft"||!cf.flies(t))return;const i=t.aircraftSound??e??cf.DEFAULT_KIND;return i==="silent"?void 0:i}static flies(t){return(t.track??[]).some(e=>(e.altitudeM??0)>0)}}const yT=-.5;function wT(o){return o.kind==="streetlight"&&o.origin!==void 0&&o.lit===void 0&&!o.litKeyframes?.length}function Rm(o,t,e){if(e!==void 0&&wT(o))return e<yT;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 iw(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 bT(o,t){const e=Kh(o,t);return e.intensity<=0?!1:e.pattern.kind==="steady"?!0:pE(o,t,t+1)>.5}function Kh(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 pE(o,t,e){const i=o.keyframes??[];if(i.length===0)return og(o.pattern,t,e);const n=[t,...i.map(r=>r.t).filter(r=>r>t&&r<e),e];if(e<=t)return Kh(o,t).intensity>0?og(Kh(o,t).pattern,t,e):0;let s=0;for(let r=0;r<n.length-1;r++){const a=Kh(o,n[r]);a.intensity>0&&(s+=og(a.pattern,n[r],n[r+1])*(n[r+1]-n[r]))}return s/(e-t)}function og(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 Xr(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 nw(e[0],o);const n=e[e.length-1];if(t>=n.t)return nw(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 xT(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 nw(o,t){return{eastM:o.eastM,northM:o.northM,altitudeM:o.altitudeM??0,headingDeg:o.headingDeg??t.headingDeg}}const mE=Math.PI/180,P0=111320;function oe(o,t,e,i){const n=P0*Math.cos(e*mE),s=(o-e)*P0;return{x:(t-i)*n,z:-s}}function Zs(o,t,e,i){const n=P0*Math.cos(e*mE),s=-t,r=o;return{lat:e+s/P0,lng:i+r/n}}class Ts{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(Ts.isRelative(t)){const i=Ts.referenceOf(t,e);return i?{eastM:i.eastM+t.eastM,northM:i.northM+t.northM}:void 0}return Ts.isAbsolute(t)&&e.origin?Ts.toLocal(t,e.origin):void 0}static restated(t,e,i){if(Ts.isRelative(t)){const s=Ts.referenceOf(t,i);return s?Ts.relative(e.eastM-s.eastM,e.northM-s.northM,t.relativeTo):void 0}if(!i.origin)return t;const n=Ts.toGeo(e,i.origin);return{lat:Ts.degrees(n.lat),lng:Ts.degrees(n.lng)}}static relative(t,e,i){const n={eastM:Ts.metres(t),northM:Ts.metres(e)};return i!==void 0&&(n.relativeTo=i),n}static toLocal(t,e){const i=oe(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 hs{static restatedDecor(t){const e=hs.originOf(t);return t.decor.map(i=>{let n=i;if(i.saidPosition){const s=hs.restated(i.saidPosition,i,hs.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=hs.restated(r.saidPosition,r,hs.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=hs.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=Ts.toLocal({lat:s.lat,lng:s.lng},i),a=hs.restated(s.saidPosition,r,hs.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=hs.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?hs.restated(s.saidPosition,{eastM:s.eastM,northM:s.northM},hs.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}=Xr(r,e);return{id:r.id,label:r.id,eastM:a,northM:c}})];return{origin:i,references:s}}static restated(t,e,i){return Ts.restated(t,{eastM:e.eastM,northM:e.northM},i)}}class ui{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+ui.BEYOND_MS;r+=ui.STEP_MS)this.distances.push(n),n+=this.speedAt(r)*ui.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+=ui.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*ui.R*this.sampleCos,n:(a.lat-this.sampleOrigin.lat)*Math.PI/180*ui.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=ui.catmull(c(l),a),d=ui.catmull(c(h),a),f=(Math.atan2(ui.slope(c(l),a),ui.slope(c(h),a))*180/Math.PI%360+360)%360;return{eastM:u,northM:d,roadDeg:f,lat:this.sampleOrigin.lat+d/ui.R*180/Math.PI,lng:this.sampleOrigin.lng+u/(ui.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/ui.R*180/Math.PI,lng:this.origin.lng+e.e/(ui.R*this.cos0)*180/Math.PI}}distanceAt(t){const e=Math.max(0,Math.min(this.distances.length-1,Math.round((t-this.from)/ui.STEP_MS)));return this.distances[e]}speedAt(t){const e=this.params.speedDivisors?ui.linear(this.params.speedDivisors.map(({t:i,divisor:n,step:s})=>({t:i,value:n,step:s})),t):1;return ui.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*ui.R*this.cos0,n:(t.lat-this.origin.lat)*Math.PI/180*ui.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 ii{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+ii.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+=ii.STEP_MS)i.push(u);i.push(e);const n=new Map(i.map(u=>{const d=this.sample(u);return[u,ii.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 ii.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+ii.SETTLED_MS)+ii.DENSE_MS;for(let p=Math.round(u);p<f;p+=ii.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),m=this.drive.stateAt(u);return{t:u,headingDeg:f,pitchDeg:p,eye:this.eyeAt(u,ii.signed(f-d.roadDeg)),roadDeg:m.roadDeg,lat:m.lat,lng:m.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+=ii.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:(ui.catmull(r(this.aimed),s)%360+360)%360,pitchDeg:ui.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=ii.signed(n-i),d=this.lookAhead.keepDeg,f=u-d*Math.tanh(u/d),p=u?f/u:0;return[ii.normalized(i+f),ii.ROAD_PITCH_DEG+(s-ii.ROAD_PITCH_DEG)*p]}if(t==="road"||!this.watch)return[i,ii.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[ii.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 g=0;g<t.length;g++)t[g][0]<=s&&(r=g);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+ii.SETTLED_MS)return[a,c];const[u,d]=this.gaze(t,e,i,r-1);if(h<l){const g=h/l,v=-2*g**3+3*g*g+(g**3-g*g)*An.ARRIVAL;return[ii.normalized(u+ii.signed(a-u)*v),d+(c-d)*v]}const f=ii.signed(a-u),p=h-l,m=An.ARRIVAL/l*p*Math.exp(-p/Math.min(An.SETTLE_MS,.4*l));return[ii.normalized(a+f*m),c+(c-d)*m]}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:ii.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=ii.smooth((Math.abs(e)-ii.TWIST_FROM_DEG)/(180-ii.TWIST_FROM_DEG)),r=ii.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 ii.TURN_S+ii.TURN_S_PER_DEG*Math.hypot(ii.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 cg=Math.PI/180;class Ct{constructor(t,e,i){this.body=t,this.ground=e,this.eyeAt=i;const n=Ct.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)Ct.collect(this.motionKeys,r.t,r.motions),Ct.collect(this.turnKeys,r.t,r.turns),Ct.collect(this.lightKeys,r.t,r.lights);!t.withObserver&&s.every(r=>r.azimuthDeg===void 0&&r.altitudeDeg===void 0)&&Ct.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 Ct.channelsAt(this.motionKeys,t,0)}lightsAt(t){return this.lightKeys.size>0?Ct.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]=Ct.lerp(c.value,l.value,h)}return n}static eyeOf(t,e,i){const n=Oe(t,0),s=Oe(t,e),a=n?.lat!==void 0&&n.lng!==void 0&&s?.lat!==void 0&&s.lng!==void 0?oe(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)+Ct.EYE_HEIGHT_M+(s?.elevationM??0),headingDeg:s?.headingDeg}}static lineOfSightMeetsGround(t,e,i,n){const s=Ct.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<Ct.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*cg,n=e*cg;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 m=i+n+1>>1;e[m].t>t?n=m-1:i=m}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+Ct.lerp(r.carried.eastM,a.carried.eastM,c):Ct.lerp(r.eastM,a.eastM,c),u=l?l.northM+Ct.lerp(r.carried.northM,a.carried.northM,c):Ct.lerp(r.northM,a.northM,c),d={widthM:Ct.lerp(r.sizeM.widthM,a.sizeM.widthM,c),lengthM:Ct.lerp(r.sizeM.lengthM,a.sizeM.lengthM,c),heightM:Ct.lerp(r.sizeM.heightM,a.sizeM.heightM,c)},f={headingDeg:Ct.lerpAngle(r.attitude.headingDeg,a.attitude.headingDeg,c),pitchDeg:Ct.lerp(r.attitude.pitchDeg,a.attitude.pitchDeg,c),rollDeg:Ct.lerp(r.attitude.rollDeg,a.attitude.rollDeg,c)};let p;if(l)p=l.upM+Ct.lerp(r.carried.upM,a.carried.upM,c);else if("aboveGroundM"in r.vertical&&"aboveGroundM"in a.vertical){const m=Ct.lerp(r.vertical.aboveGroundM,a.vertical.aboveGroundM,c);p=this.groundUnderFootprint(h,u,d,f.headingDeg)+m+d.heightM/2}else p=Ct.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:Ct.lerpColor(r.appearance.color,a.appearance.color,c),albedo:Ct.lerp(r.appearance.albedo,a.appearance.albedo,c),finish:c<1?r.appearance.finish:a.appearance.finish,luminanceCdM2:Ct.lerp(r.appearance.luminanceCdM2,a.appearance.luminanceCdM2,c),transparency:Ct.lerp(r.appearance.transparency,a.appearance.transparency,c),haloScale:Ct.lerp(r.appearance.haloScale,a.appearance.haloScale,c)},flame:Ct.flameBetween(r.flame,a.flame,c),motions:this.motionsAt(t),...this.turnKeys.size>0?{turns:Ct.channelsAt(this.turnKeys,t,0)}:{},lights:this.lightsAt(t),throwsFlame:this.body.track.some(m=>m.flame!==void 0&&m.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:Ct.lerp(n.lengthM,s.lengthM,i),widthM:Ct.lerp(n.widthM,s.widthM,i),luminanceCdM2:Ct.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*cg,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??Ct.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??Ct.DEFAULT_APPEARANCE.color,albedo:s.appearance?.albedo??n?.appearance.albedo??Ct.DEFAULT_APPEARANCE.albedo,finish:s.appearance?.finish??n?.appearance.finish??Ct.DEFAULT_APPEARANCE.finish,luminanceCdM2:s.appearance?.luminanceCdM2??n?.appearance.luminanceCdM2??Ct.DEFAULT_APPEARANCE.luminanceCdM2,transparency:s.appearance?.transparency??n?.appearance.transparency??Ct.DEFAULT_APPEARANCE.transparency,haloScale:s.appearance?.haloScale??n?.appearance.haloScale??Ct.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=Ct.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?Ct.lineOfSightMeetsGround(n,t.azimuthDeg,t.altitudeDeg,this.ground):void 0);if(s===void 0)return;const r=Ct.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=Ct.rgbOf(t),s=Ct.rgbOf(e);return!n||!s?i<1?t:e:"#"+n.map((r,a)=>Math.round(Ct.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 Ws{static ANONYMOUS_OBSERVER="observer";static observerId(t){return t.observer?.id??Ws.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(Ws.observerId(t),"observer");for(const n of Ws.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=Ws.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===Ws.observerId(t)}static isPhenomenon(t,e){return e.who===void 0?!1:t.timeline.groupOf(e.who)!==void 0||Ws.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=Ws.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=Ws.partOf(n.who);r&&i.get(r.element)?.length===1&&Ws.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 Ee{constructor(t,e,i){this.travel=t;const n=t.params,s=t.until??i;let r=Ee.unit(n.from),a=Ee.towards(r,Ee.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=Ee.STEP_MS;for(let h=t.t;h<=s;h+=l){this.directions.push(Ee.direction(r));for(const f of c){const p=f.to-f.from;if(p<=0)continue;const m=f.radians*(Ee.smooth((h+l-f.from)/p)-Ee.smooth((h-f.from)/p));m&&(a=Ee.add(Ee.scale(a,Math.cos(m)),Ee.scale(Ee.cross(a,r),Math.sin(m))))}const u=Ee.speedAt(n.speeds,h)*l/1e3*Math.PI/180,d=Ee.add(Ee.scale(r,Math.cos(u)),Ee.scale(a,Math.sin(u)));a=Ee.add(Ee.scale(a,Math.cos(u)),Ee.scale(r,-Math.sin(u))),r=d}}static STEP_MS=5;directions=[];at(t){const e=Math.round((t-this.travel.t)/Ee.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)*Ee.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=Ee.add(e,Ee.scale(t,-Ee.dot(t,e))),n=Math.hypot(...i)||1;return Ee.scale(i,1/n)}static toScreen(t,e,i){const[n,s,r]=Ee.basis(e,i),a=Ee.unit(t),c=Ee.dot(a,n);return[Ee.dot(a,s)/c,Ee.dot(a,r)/c]}static fromScreen(t,e,i,n){const[s,r,a]=Ee.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 Ee.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 $o{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:$o.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=>Ct.eyeOf(this.sighting,h,s),a=new Ct(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,m=u.northM-d.northM,g=u.upM-d.upM;l={headingDeg:(Math.atan2(p,m)*180/Math.PI%360+360)%360,pitchDeg:Math.atan2(g,Math.hypot(p,m))*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=Ws.within(this.sighting,i.target),s=this.sighting.events??[],r=s.find(v=>v.eventType==="travel"&&v.who!==void 0&&n.has(v.who));if(!r)return!1;const a=this.sighting.event.durationSeconds!==void 0?this.sighting.event.durationSeconds*1e3:r.until??t.t,c=new Ee(r,s.filter(v=>v.eventType==="turn"&&v.who!==void 0&&n.has(v.who)),a),l=t.until??a,h=(i.lagS??0)*1e3,u=(i.reactionS??0)*1e3,d=[],f=this.sighting.sampleMs??$o.FOLLOW_SKY_MS;for(let v=t.t;v<=l;v+=f)d.push(v);const p=d.map(v=>c.at(Math.max(r.t,v-h))),m=p.map(v=>v.azimuthDeg),g=p.flatMap((v,M)=>v.altitudeDeg>$o.OVERHEAD_DEG?[M]:[]);if(g.length>0){const v=Math.max(0,g[0]-1),M=Math.min(d.length-1,g[g.length-1]+1),w=m[v],y=(m[M]-w+540)%360-180;for(let b=v;b<=M;b++)m[b]=((w+y*Ee.smooth((b-v)/(M-v)))%360+360)%360}return d.forEach((v,M)=>{const w=Ee.smooth((v-t.t-u)/$o.CATCH_UP_MS),y=(m[M]-e.headingDeg+540)%360-180,b=Math.min(p[M].altitudeDeg,$o.HIGHEST_PITCH_DEG),S=this.sighting.observerTrack.getInterpolatedPoseAt(v)??this.sighting.observerTrack.getLatestPoseAt(v);if(!S)return;const E=x=>Math.round(x*100)/100;this.sighting.observerTrack.addKeyframe(v,{...S,headingDeg:E(((e.headingDeg+y*w)%360+360)%360),pitchDeg:E(e.pitchDeg+(b-e.pitchDeg)*w)})}),!0}static pose(t,e,i,n=$o.FOV_DEG){return{lat:t.lat,lng:t.lng,elevationM:0,headingDeg:e,pitchDeg:i,fovDeg:n}}}class hc{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=hc.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,m=l.eventType==="motion"?u.to:f+u.turnsPerS*(p-l.t)/1e3;e({t:l.t,motions:{[d]:f}}),e({t:p,motions:{[d]:m}}),n.set(d,m)}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,m=c,g=v=>{const M=u.stops===!1?v*v:v*v*v*(10-15*v+6*v*v),w=u.distanceM*M;return{eastM:m.eastM+w*Math.sin(f)*Math.sin(p),northM:m.northM+w*Math.sin(f)*Math.cos(p),aboveGroundM:m.aboveGroundM+w*Math.cos(f)}};for(let v=l.t;v<d;v+=this.sampleMs??hc.SAMPLE_MS)e(hc.key(v,g((v-l.t)/(d-l.t))));c=g(1),e(hc.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 lf{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=lf.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=lf.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 qh{static observer(t){const e=t.allKeyframes,i=e.map(s=>qh.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:qh.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 L0{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*Ee.smooth(r)):Ee.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(L0.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=Ee.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)*Ee.smooth(n*L0.SPIRAL_OPENS)*(1-i.shrink*Ee.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 Hs{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 Ee(e,i.filter(a=>a.eventType==="turn"),n):void 0,this.motion=this.path?new L0(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?Hs.TRAVEL_SAMPLE_MS:Hs.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:Hs.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=x=>Ee.toScreen(s.at(x),a,c),u=(x,A)=>{const T=Math.hypot(A[0]-x[0],A[1]-x[1])||1;return[(A[0]-x[0])/T,(A[1]-x[1])/T]};let d=h(e),[f,p]=u(h(e-Hs.MOTION_MS),h(e+Hs.MOTION_MS));const m=s.sizeAt(e),g=Math.tan(l.sidewaysAt(e,m)*Math.PI/180);d=[d[0]-g*p,d[1]+g*f];const v=l.spiralAt(e);if(v){const x=l.spiralAt(e+Hs.SPIRAL_AHEAD_MS),A=h(e),T=h(e+Hs.SPIRAL_AHEAD_MS);d=[d[0]+v[0],d[1]+v[1]],[f,p]=u([A[0]+v[0],A[1]+v[1]],[T[0]+x[0],T[1]+x[1]])}const M=l.acrossShareAt(e),w={...t,heightShare:(t.heightShare??t.widthShare)*M,...t.upShare===void 0?{}:{upShare:t.upShare*M}},y=Math.tan(m*(w.alongShare??0)*Math.PI/180),b=Math.tan(m*(w.upShare??0)*Math.PI/180),S=Ee.fromScreen(d[0]+y*f-b*p,d[1]+y*p+b*f,a,c),E=Hs.shape(w,{...S,sizeDeg:m},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 Hs.seenFrom(e,n,t)}static seenFrom(t,e,i){const n=(t.place.lng-e.lng)*Math.PI/180*Hs.R*Math.cos(e.lat*Math.PI/180),s=(t.place.lat-e.lat)*Math.PI/180*Hs.R,r=Math.hypot(n,s),a=ui.linear(t.metres.map(({t:l,widthM:h,step:u})=>({t:l,value:h,step:u})),i),c=ui.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,m)=>Math.round(p*10**m)/10**m,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 Ne{static STANDING_EYE_M=1.6;static METERS_PER_DEGREE=111320;static expand(t){Ne.expandBodies(t),Ne.expandObserver(t),Ne.expandFlights(t),Ne.expandDecorLights(t),Ne.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=>lf.partOf(s.who,e.id)!==void 0);if(i.length===0)continue;const n=JSON.stringify(e.lights);e.lights=new lf(e,i,Ne.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=Ne.stands(t);for(const i of e){const n=Ws.within(t,i.who),s=(t.events??[]).filter(a=>a.who!==void 0&&n.has(a.who)),r=new Hs(t,i,s,i.until??Ne.endOf(t)).timeline();for(const a of Tf.fromJSON(r).allKeyframes)t.timeline.addKeyframe(a.t,a.shapes)}e.length!==0&&(qh.timeline(t.timeline),t.eventsExpansion??={decorTracks:{}},t.eventsExpansion.timelinePending=!0)}static stands(t){return(t.events??[]).filter(e=>(e.eventType==="stand"||e.eventType==="travel")&&Ws.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&&(bn.toAngular(t),bn.toAim(t),t.eventsExpansion.timeline=Ne.shapesOf(t),t.eventsExpansion.timelinePending=!1)}static timelineIsExpanded(t){return t.eventsExpansion?.timeline!==void 0&&t.eventsExpansion.timeline===Ne.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(m=>m.id===n.who);if(!s||s.track?.length)continue;const r=n.params,a=n.until??Ne.endOf(t),c=r.headingDeg*Math.PI/180,l=(r.from.lng-e.lng)*Math.PI/180*Ne.R*i,h=(r.from.lat-e.lat)*Math.PI/180*Ne.R,u=r.speeds.map(({t:m,kmh:g,step:v})=>({t:m,value:g/3.6,step:v})),d=r.heights.map(({t:m,altitudeM:g,step:v})=>({t:m,value:g,step:v})),f=m=>{const g=Math.sign(m-r.at.t)*Ne.FLY_STEP_MS;let v=0;for(let M=r.at.t;g!==0&&(g>0?M<m:M>m);M+=g){const w=g>0?Math.min(m,M+g):Math.max(m,M+g);v+=(ui.linear(u,M)+ui.linear(u,w))/2*(w-M)/1e3}return v},p=[];for(let m=n.t;m<=a;m+=ui.SAMPLE_MS){const g=r.at.metresBefore-f(m);p.push({t:m,eastM:l-Math.sin(c)*g,northM:h-Math.cos(c)*g,altitudeM:ui.linear(d,m),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(m=>Ws.isObserver(t,m)),i=e.find(m=>m.eventType==="drive"),n=e.find(m=>m.eventType==="lookAhead");if(t.observerTrack.allKeyframes.length>0)return;if(!i){new $o(t,e).keyframes().length>0&&(qh.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??Ne.endOf(t),r=i.params,a=new ui(r,i.t,s),c=e.find(m=>m.eventType==="lean"),l=e.find(m=>m.eventType==="watch"),u=new ii(a,r.eye,n.params,c&&{t:c.t,params:c.params},l&&{t:l.t,params:l.params},m=>{const g=Ne.stands(t).find(M=>M.eventType==="stand");if(!g)return Ne.phenomenonPitchAt(t,m);const v=a.stateAt(m);return Hs.seenFrom(g.params,{lat:v.lat,lng:v.lng},m).altitudeDeg}).poses(i.t,s),d=u.map(m=>({t:m.t,pose:{lat:m.lat,lng:m.lng,elevationM:m.eye.y-Ne.STANDING_EYE_M,headingDeg:m.headingDeg,pitchDeg:m.pitchDeg,fovDeg:r.fovDeg??60}}));for(const m of d)t.observerTrack.addKeyframe(m.t,m.pose);qh.observer(t.observerTrack);const f={observerTrack:JSON.stringify(t.observerTrack.toJSON()),decorTracks:{}},p=r.vehicle===void 0?void 0:t.decor.find(m=>m.id===r.vehicle);if(p&&!p.track?.length){const m=u[0],g=M=>Math.cos(M*Math.PI/180),v=u.map(M=>{const w=M.roadDeg*Math.PI/180,y=-M.eye.z,b=M.eye.x,S=(M.lng-m.lng)*Ne.METERS_PER_DEGREE*g(M.lat),E=(M.lat-m.lat)*Ne.METERS_PER_DEGREE;return{t:M.t,eastM:S-y*Math.sin(w)-b*Math.cos(w),northM:E-y*Math.cos(w)+b*Math.sin(w),altitudeM:0,headingDeg:M.roadDeg}});p.track=v,p.eastM=v[0].eastM,p.northM=v[0].northM,p.headingDeg=v[0].headingDeg,f.decorTracks[p.id]=JSON.stringify(v)}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||hc.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?hc.ride(n,c,l):n.track:new hc(n,s,Ne.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||Ne.observerTrackIsExpanded(t),i=t.timeline.allKeyframes.length===0||Ne.timelineIsExpanded(t);Ne.again(t,e,i)}static reset(t){Ne.again(t,!0,Ne.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=Ne.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,Ne.expand(t),i&&t.timeline.pruneGroups(),i&&(bn.toBounds(t),bn.toPosition(t)),Ne.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 gE(o){return Je.restore(vE(o),o.provenance)}function vE(o,t=!1){return bn.toAngular(o),bn.toAim(o),{version:4,id:o.id,time:N0.write(o.event.time),endTime:N0.write(o.event.endTime),durationSeconds:o.event.durationSeconds,durationText:o.event.durationText,utcOffsetHours:o.event.utcOffsetHours,timeZone:o.event.timeZone,place:ME.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&&Ne.timelineIsExpanded(o)?Ne.timelineWithoutShapes(o):o.timeline.toJSON(),observerTrack:!t&&Ne.observerTrackIsExpanded(o)?void 0:hs.restatedObserverTrack(o),events:o.events?.length?o.events:void 0,weatherTrack:o.weatherTrack.toJSON(),soundTrack:o.soundTrack.toJSON(),weather:o.weather,decor:hs.restatedDecor(o).map(e=>{if(!t&&e.lights&&(e={...e,lights:Ne.writtenLights(o,e.id,e.lights)}),t||!Ne.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,observerMap:o.observerMap,interpretation:t?hs.restatedInterpretation(o):Ne.writtenInterpretation(o,hs.restatedInterpretation(o)),variants:o.variants.length>0?o.variants:void 0,skyEvents:la.written(o.skyEvents),snapshots:o.snapshots,modules:o.modules?.length?o.modules:void 0}}function ST(o){return o.observer?.id??"observer"}function JM(o){const t=lr.check(o,"sighting"),{recording:e,provenance:i}=Je.strip(t),n=ET(e);return n.provenance=i,n}function ET(o){const t=[],e=new Tm({eventType:"sighting",time:N0.read(o.time),endTime:N0.read(o.endTime),durationSeconds:o.durationSeconds,durationText:o.durationText,utcOffsetHours:o.utcOffsetHours,timeZone:o.timeZone,place:ME.read(o.place),description:o.description,image:o.image,summary:o.summary,summaryTime:o.summaryTime,tags:o.tags},Tf.fromJSON(o.timeline,t,!1),o.observerTrack?Ud.fromJSON(o.observerTrack):new Ud,o.weatherTrack?zd.fromJSON(o.weatherTrack):new zd,o.soundTrack?Bd.fromJSON(o.soundTrack):new Bd,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),md(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.observerMap=o.observerMap,e.vehicle=o.vehicle,e.events=o.events?.map(n=>n.who===void 0?{...n,who:ST(o)}:n);const i=la.read(o.skyEvents,o.interpretation);return e.interpretation=i.interpretation,e.variants=Array.isArray(o.variants)?o.variants:[],e.skyEvents=i.skyEvents,e.snapshots=o.snapshots,e.modules=Array.isArray(o.modules)?o.modules.filter(n=>typeof n=="string"):void 0,e.loadIssues=t,Ne.expand(e),e.timeline.pruneGroups(),bn.toBounds(e),bn.toPosition(e),Ne.settle(e),e}class N0{static read(t){return t===void 0||t.trim()===""?void 0:qs(t)}static write(t){if(t===void 0)return;const e=xh(t);return e===""?void 0:e}}class ME{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 AT=Object.freeze(Object.defineProperty({__proto__:null,fromSightingJson:JM,plainSightingJson:vE,toSightingJson:gE},Symbol.toStringTag,{value:"Module"}));class yE{id="consolidated";title="Consolidated readings (UFO@home)";law(t,e){const i=t.value,n=t.basis==="measured"||t.basis==="established";switch(t.kind){case"time":return t.how==="clock"||n?{shape:"range",low:-1,high:1,note:"timeClock",params:{minutes:1},status:"argued",sources:["Bullard 2014"]}:t.how==="anchored"?{shape:"range",low:-2,high:2,note:"timeAnchored",params:{minutes:2},status:"argued",sources:["Bullard 2014"]}:{shape:"range",low:-6,high:6,note:"timeEstimated",params:{minutes:6},status:"single",sources:["Rospars 2023"]};case"duration":return{shape:"range",low:i/3,high:i*3,note:"duration",params:{factor:3},status:"consolidated",sources:["Rospars 2023","Peiniger 1998b"]};case"elevation":return t.how==="instrument"||n?{shape:"range",low:i-2,high:i+2,note:"measuredInstrument",params:{degrees:2},status:"argued",sources:[]}:t.how==="landmark"?{shape:"range",low:i-5,high:i+5,note:"measuredLandmark",params:{degrees:5},status:"argued",sources:[]}:{shape:"range",low:Math.max(0,i*.3),high:i,note:"elevationOver",status:"consolidated",sources:["Wertheimer 1968","van Utrecht 2023"]};case"heading":return t.how==="instrument"||n?{shape:"range",low:i-5,high:i+5,note:"measuredInstrument",params:{degrees:5},status:"argued",sources:[]}:t.how==="landmark"?{shape:"range",low:i-10,high:i+10,note:"measuredLandmark",params:{degrees:10},status:"argued",sources:[]}:{shape:"range",low:i-45,high:i+45,note:"headingCross",params:{degrees:45},status:"consolidated",sources:["Rospars 2023","Passot 2023"]};case"angularSize":return this.sizeLaw(i,t.how,e);case"distance":return n||["occlusion","known-size","triangulation"].includes(t.how??"")||t.basis==="derived"?{shape:"anchored",note:"distanceAnchored",status:"consolidated",sources:["Hartmann 1968"]}:{shape:"uninformative",note:"distanceNotData",params:{factor:10},status:"consolidated",sources:["Hartmann 1968","Rospars 2023"]}}}sizeLaw(t,e,i){const n=mc.moonFactor(i);return n!==void 0?{shape:"range",low:t/n/1.1,high:t/n*1.1,note:"sizeMoon",params:{factor:n},status:"individual",sources:[]}:e==="arm-length-gauge"?{shape:"range",low:t/1.2,high:t*1.2,note:"sizeGauge",params:{percent:20},status:"argued",sources:[]}:e==="shown-on-the-spot"?{shape:"range",low:t/1.17,high:t/1.02,note:"sizeShown",status:"contested",sources:["Keul 2015"]}:e==="recalled-object"?{shape:"range",low:t/1.3,high:t,note:"sizeRecalled",status:"contested",sources:["Keul 2015"]}:{shape:"range",low:t/4,high:t/3,note:"sizeArm",params:{from:3,to:4},status:"contested",sources:["Peiniger 1998a"]}}parameters(t,e){const i=mc.moonFactor(t);return[e==="clock"?{id:"clock",note:"clockClock",params:{minutes:1},status:"argued"}:e==="anchored"?{id:"clock",note:"clockAnchored",params:{minutes:2},status:"argued"}:{id:"clock",note:"clockEstimated",params:{minutes:6},status:"single"},{id:"date",note:"dateShift",params:{percent:2},status:"single"},{id:"heading",note:"headingRotation",params:{degrees:45},status:"consolidated"},{id:"elevation",note:"elevationCompression",status:"consolidated"},i!==void 0?{id:"size",note:"sizeMoon",params:{factor:i},status:"individual"}:this.sizeParameter(),{id:"duration",note:"durationFactor",params:{factor:3},status:"consolidated"}]}sizeParameter(){return{id:"size",note:"sizeArm",params:{from:3,to:4},status:"contested"}}}class _T extends yE{id="keul";title="Keul (sizes shown on the spot)";sizeLaw(t,e,i){return mc.moonFactor(i)!==void 0||e==="arm-length-gauge"||e==="recalled-object"?super.sizeLaw(t,e,i):{shape:"range",low:t/1.17,high:t/1.02,note:"sizeShown",status:"contested",sources:["Keul 2015"]}}sizeParameter(){return{id:"size",note:"sizeShown",status:"contested"}}}class mc{static MOON_DEG=.52;static MODELS=[new yE,new _T];static HOW={time:["clock","anchored","estimated"],duration:["clock","anchored","estimated"],angularSize:["shown-on-the-spot","arm-length-gauge","recalled-object"],elevation:["instrument","landmark","estimated"],heading:["instrument","landmark","estimated"],distance:["occlusion","known-size","triangulation","estimated"]};static byId(t){return mc.MODELS.find(e=>e.id===t)??mc.MODELS[0]}static moonFactor(t){const e=t?.moonShownDeg;return e!==void 0&&e>0?e/mc.MOON_DEG:void 0}static rounded(t){return t===0||!Number.isFinite(t)?t:Number(t.toPrecision(2))}}const wE=["ellipsoid","sphere","disc","cylinder","cone","box","torus","figure"],Cl=Math.PI/180,Ou=180/Math.PI;class si{constructor(t,e){this.timeline=t,this.tolerance=e}static DIRECTION_TOLERANCE_DEG=1;static SIZE_TOLERANCE=1.5;static RINGS=12;static SEGMENTS=24;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(si.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){const s=t.law({kind:"angularSize",value:i},e);return n<(s.low??i)/si.SIZE_TOLERANCE||n>(s.high??i)*si.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:si.projectionOf(c,i,n?.(c))})}for(const[c,l]of r){const h=l.flatMap(u=>n?.(u)??si.outlineOf(u));a.push({id:c,explains:l[0].explains,predicted:si.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({...si.compare(h,c.id,{aim:u.aim,angular:u.angular},l,this.tolerance),title:u.title})}}return s}static compare(t,e,i,n,s){const r=[],a=i.aim?si.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(si.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):!si.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:si.outlineOf(t),s=i&&i.length>0?si.centreOf(i):t,r=si.normalized({eastM:s.eastM-e.eastM,northM:s.northM-e.northM,upM:s.upM-e.upM});if(!r)return;const a=si.normalized({eastM:r.northM,northM:-r.eastM,upM:0})??{eastM:1,northM:0,upM:0},c=si.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},m=si.dot(p,r);if(m<=0)return;const g=Math.atan2(si.dot(p,a),m),v=Math.atan2(si.dot(p,c),m);l=Math.min(l,g),h=Math.max(h,g),u=Math.min(u,v),d=Math.max(d,v)}return{aim:{azimuthDeg:(Math.atan2(r.eastM,r.northM)*Ou+360)%360,altitudeDeg:Math.asin(Math.max(-1,Math.min(1,r.upM)))*Ou},angular:{widthDeg:(h-l)*Ou,heightDeg:(d-u)*Ou}}}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*Cl,n=e.altitudeDeg*Cl,s=Math.sin(i)*Math.sin(n)+Math.cos(i)*Math.cos(n)*Math.cos((t.azimuthDeg-e.azimuthDeg)*Cl);return Math.acos(Math.max(-1,Math.min(1,s)))*Ou}static withinSize(t){return t<=si.SIZE_TOLERANCE&&t>=1/si.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"&&wE.includes(r))for(let u=0;u<=si.RINGS;u++){const d=u/si.RINGS*Math.PI;for(let f=0;f<si.SEGMENTS;f++){const p=f/si.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*Cl,l=t.attitude.pitchDeg*Cl,h=t.attitude.rollDeg*Cl;return s.map(([u,d,f])=>{const p=u*Math.cos(h)+f*Math.sin(h),m=-u*Math.sin(h)+f*Math.cos(h),g=d*Math.cos(l)-m*Math.sin(l),v=d*Math.sin(l)+m*Math.cos(l);return{eastM:t.eastM+p*Math.cos(c)+g*Math.sin(c),northM:t.northM-p*Math.sin(c)+g*Math.cos(c),upM:t.upM+v}})}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}}const Pu=Math.PI/180;class yn{constructor(t,e,i,n,s={}){this.instants=e,this.said=n,this.references=s,this.confrontation=new si(t.timeline,i),this.eyeAt=r=>Ct.eyeOf(t,r,yn.FLAT)}static LIMITS={azimuth:45,altitude:30,distance:10,size:10,time:1e4};static SUFFICIENT=.5;static MEASURABLE=.5;static STEPS=12;static HALVINGS=8;static FLAT={heightAt:()=>0};confrontation;expected=new Set;nominalAgreement=0;best;eyeAt;static forAccount(t){const e=JM(t),i=Je.strip(t).recording.timeline?.keyframes??[],n=new Map,s=f=>yn.traced(e.provenance,f),r=mc.MODELS[0],a=e.account?.conditions,c={},l=(f,p,m)=>{const g=c[f];c[f]=g?{lower:Math.max(g.lower,p),upper:Math.min(g.upper,m)}:{lower:p,upper:m}};i.forEach((f,p)=>f.shapes.forEach((m,g)=>{const v=`timeline.keyframes.${p}.shapes.${g}.shape`,M={direction:s(`${v}.aim`),size:s(`${v}.angular`)};(M.direction||M.size)&&n.set(`${f.t}/${m.sourceId}`,M);const w=m.shape.aim;if(!M.direction||!w)return;const y=b=>e.provenance.at(`${v}.aim.${b}`)??e.provenance.at(`${v}.aim`);for(const[b,S,E,x]of[["azimuth","heading",w.azimuthDeg,"azimuthDeg"],["altitude","elevation",w.altitudeDeg,"altitudeDeg"]]){const A=y(x),T=r.law({kind:S,value:E,basis:A?.basis,how:A?.how},a);T.low!==void 0&&T.high!==void 0&&l(b,T.low-E,T.high-E)}}));const u=r.law({kind:"distance",value:1},a).params?.factor;typeof u=="number"&&(c.distance={lower:1/u,upper:u});const d=si.lawsOf(r,a);return new yn(e,i.map(f=>f.t),d,n,c)}of(t,e){const i=t.filter((a,c)=>yn.isFree(e,c)),n=this.score(t);this.expected=new Set(n.outcomes.keys()),this.nominalAgreement=this.agreementOf(n.outcomes),this.best=void 0;const s={holds:n.outcomes.size>0&&this.nominalAgreement===1,agreement:this.nominalAgreement,compared:n.outcomes.size,instants:n.instants,...n.separations.length?{medianSeparationDeg:yn.median(n.separations)}:{},freeBodies:i.map(a=>a.id),fixedBodies:t.filter(a=>!i.includes(a)).map(a=>a.id),margins:[]};if(this.nominalAgreement===0)return s;for(const a of i)for(const c of this.knobsOf(a))s.margins.push(this.marginOf(t,a,c));s.margins.sort((a,c)=>a.coverage!==void 0&&c.coverage!==void 0?a.coverage-c.coverage:a.coverage!==void 0?-1:c.coverage!==void 0?1:a.share-c.share),this.best&&(s.better=this.best);const r=s.margins.filter(a=>a.coverage!==void 0);return r.length>0&&yn.measurable(s)&&(s.sufficient=r.every(a=>a.coverage>=yn.SUFFICIENT)),s}static traced(t,e){return t.paths().some(i=>(i===e||i.startsWith(`${e}.`))&&!Je.free(t.at(i)))}static measurable(t){return t.compared>0&&t.agreement>=yn.MEASURABLE}static isFree(t,e){const i=`interpretation.bodies.${e}`;return t.paths().some(n=>(n===i||n.startsWith(`${i}.`))&&Je.free(t.at(n)))}knobsOf(t){const e=!this.said||[...this.said.values()].some(n=>n.size),i=e?["azimuth","distance","time"]:["azimuth","time"];return t.track.some(n=>n.altitudeDeg!==void 0||n.altitudeM!==void 0||n.altitudeAboveGroundM!==void 0)&&i.splice(1,0,"altitude"),e&&t.track.some(n=>n.sizeM!==void 0)&&i.push("size"),i}marginOf(t,e,i){const n=yn.LIMITS[i],s=i==="distance"||i==="size",r=(f,p)=>s?Math.exp(p*f*Math.log(n)):p*f*n,a=(f,p)=>{const m=i==="time"?t:t.map(v=>v===e?this.turned(e,i,r(f,p)):v),g=this.agreementOf(this.score(m,i==="time"?{body:e,ms:r(f,p)}:void 0).outcomes);return g>this.nominalAgreement+1e-9&&(!this.best||g>this.best.agreement)&&(this.best={bodyId:e.id,knob:i,amount:r(f,p),agreement:g}),g>=this.nominalAgreement-1e-9},c=f=>{let p=0;for(let m=1;m<=yn.STEPS;m++){const g=(m/yn.STEPS)**2;if(!a(g,f)){let v=g;for(let M=0;M<yn.HALVINGS;M++){const w=(p+v)/2;a(w,f)?p=w:v=w}return{x:p,reached:!1}}p=g}return{x:1,reached:!0}},l=c(-1),h=c(1),u={bodyId:e.id,knob:i,lower:r(l.x,-1),upper:r(h.x,1),lowerReached:l.reached,upperReached:h.reached,share:Math.min(l.x,h.x)},d=this.references[i];if(d){const f=(p,m,g)=>{const v=s?Math.log(m):m;return g||Math.abs(v)<1e-9?1:Math.min(1,(s?Math.log(p):p)/v)};u.reference=d,u.coverage=Math.min(f(u.lower,d.lower,l.reached),f(u.upper,d.upper,h.reached))}return u}turned(t,e,i){const n=structuredClone(t);return n.track=n.track.map(s=>this.turnedKey(s,e,i)),n}turnedKey(t,e,i){switch(e){case"time":return{...t,t:t.t+i};case"size":return t.sizeM?{...t,sizeM:{widthM:t.sizeM.widthM*i,lengthM:t.sizeM.lengthM*i,heightM:t.sizeM.heightM*i}}:t;case"distance":return this.scaledKey(t,i);case"azimuth":return this.swungKey(t,i);case"altitude":return this.raisedKey(t,i)}}scaledKey(t,e){if(t.eastM===void 0||t.northM===void 0)return t.distanceM===void 0?t:{...t,distanceM:t.distanceM*e};const i=this.eyeAt(t.t)??{eastM:0,northM:0,upM:0},n={...t,eastM:i.eastM+(t.eastM-i.eastM)*e,northM:i.northM+(t.northM-i.northM)*e};return t.altitudeM!==void 0&&(n.altitudeM=i.upM+(t.altitudeM-i.upM)*e),t.altitudeAboveGroundM!==void 0&&(n.altitudeAboveGroundM=i.upM+(t.altitudeAboveGroundM-i.upM)*e),n}swungKey(t,e){if(t.eastM===void 0||t.northM===void 0)return t.azimuthDeg===void 0?t:{...t,azimuthDeg:((t.azimuthDeg+e)%360+360)%360};const i=this.eyeAt(t.t)??{eastM:0,northM:0},n=t.eastM-i.eastM,s=t.northM-i.northM,r=Math.cos(e*Pu),a=Math.sin(e*Pu);return{...t,eastM:i.eastM+n*r+s*a,northM:i.northM+s*r-n*a}}raisedKey(t,e){if(t.eastM===void 0||t.northM===void 0)return t.altitudeDeg===void 0?t:{...t,altitudeDeg:Math.max(-90,Math.min(90,t.altitudeDeg+e))};const i=t.altitudeM??t.altitudeAboveGroundM;if(i===void 0||t.onGround)return t;const n=this.eyeAt(t.t)??{eastM:0,northM:0,upM:0},s=Math.hypot(t.eastM-n.eastM,t.northM-n.northM),r=Math.atan2(i-n.upM,s)+e*Pu,a=n.upM+s*Math.tan(Math.max(-89*Pu,Math.min(89*Pu,r)));return t.altitudeM!==void 0?{...t,altitudeM:a}:{...t,altitudeAboveGroundM:a}}comparisons(t){const e=t.map(n=>new Ct(n,yn.FLAT,this.eyeAt)),i=[];for(const n of this.instants){const s=this.eyeAt(n);if(!s)continue;const r=e.map(a=>a.at(n)).filter(a=>a!==void 0);for(const a of this.confrontation.at(n,r,s)){const c=this.said?this.said.get(`${n}/${a.sourceId}`):{direction:!0,size:!0};if(!c)continue;const l=a.disagreements.filter(h=>h==="direction"?c.direction:c.size);i.push({t:n,sourceId:a.sourceId,...c.direction&&a.stated.aim?{said:{azimuthDeg:a.stated.aim.azimuthDeg,altitudeDeg:a.stated.aim.altitudeDeg}}:{},predicted:{azimuthDeg:a.predicted.aim.azimuthDeg,altitudeDeg:a.predicted.aim.altitudeDeg},...c.direction&&a.separationDeg!==void 0?{separationDeg:a.separationDeg}:{},agrees:l.length===0})}}return i}agreementOf(t){if(this.expected.size===0)return 0;let e=0;for(const i of this.expected)t.get(i)===!0&&e++;return e/this.expected.size}score(t,e){const i=t.map(c=>({body:c,placement:new Ct(c,yn.FLAT,this.eyeAt)})),n=({body:c,placement:l},h)=>{const u=l.at(h);if(!u||e?.body!==c)return u;const d=c.track,f=Math.min(Math.max(h-e.ms,d[0].t),d[d.length-1].t);return l.at(f)??u};let s=0;const r=[],a=new Map;for(const c of this.instants){const l=this.eyeAt(c);if(!l)continue;const h=i.map(f=>n(f,c)).filter(f=>f!==void 0),u=this.confrontation.at(c,h,l);let d=!1;for(const f of u){const p=`${c}/${f.sourceId}`,m=this.said?this.said.get(p):{direction:!0,size:!0};if(!m)continue;d=!0;const g=f.disagreements.filter(v=>v==="direction"?m.direction:m.size);a.set(p,a.get(p)===!0||g.length===0),m.direction&&f.separationDeg!==void 0&&r.push(f.separationDeg)}d&&s++}return{instants:s,outcomes:a,separations:r}}static median(t){const e=[...t].sort((n,s)=>n-s),i=Math.floor(e.length/2);return e.length%2?e[i]:(e[i-1]+e[i])/2}}Nt.register(Gn,()=>new jc);Nt.register(hu,()=>new $h);Nt.register(Wr,()=>new YM);Nt.register(uu,()=>new Yh);Nt.register(Hd,()=>new KM);Nt.register(du,()=>new $d);Nt.register(lu,()=>new Xd);Nt.register(fu,()=>new Yd);Nt.register(yc,()=>new pu);Nt.register(cu,()=>new Wd);Nt.register(Ys,()=>new Vi);Nt.register(ac,()=>new Zd);Nt.register(wn,()=>new Qc);Nt.register(oc,()=>new Jd);Nt.register(Gd,()=>new qM);Nt.register(cc,()=>new jd);Nt.register(rc,()=>new qd);Nt.register(lc,()=>new Qd);Nt.register(gl,()=>new tf);Nt.register(sc,()=>new Kd);Nt.register(Cs,()=>new ti);Nt.register(uo,()=>new sf);Nt.register(Mn,()=>new ne);Nt.register(fo,()=>new rf);Nt.register(Vd,()=>new _m);Nt.register(po,()=>new of);Nt.register(ho,()=>new nf);Nt.register(mo,()=>new af);Nt.register(D0,()=>new rT);Nt.register(lo,()=>new ef);class es{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[es.base(s)];if(r)return r}const n=new Set(this.preferences.map(s=>es.base(s)));for(const[s,r]of Object.entries(t))if(r&&n.has(es.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=>es.base(l)===es.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]}}es.any=new es([]);var sw;(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"})(sw||(sw={}));var rw;(function(o){o.neutral="neutral",o.male="male",o.female="female"})(rw||(rw={}));const TT="modulepreload",RT=function(o,t){return new URL(o,t).href},aw={},st=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=RT(h,i),h in aw)return;aw[h]=!0;const u=h.endsWith(".css"),d=u?'[rel="stylesheet"]':"";if(!!i)for(let m=a.length-1;m>=0;m--){const g=a[m];if(g.href===h&&(!u||g.rel==="stylesheet"))return}else if(document.querySelector(`link[href="${h}"]${d}`))return;const p=document.createElement("link");if(p.rel=u?"stylesheet":TT,u||(p.as="script"),p.crossOrigin="",p.href=h,l&&p.setAttribute("nonce",l),document.head.appendChild(p),u)return new Promise((m,g)=>{p.addEventListener("load",m),p.addEventListener("error",()=>g(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 IT extends Error{constructor(t,e){super(t),this.cause=e}}class jM extends IT{constructor(t=jM.defaultMessage,e){super(t,e)}}jM.defaultMessage="Assertion failed";var ow;(function(o){o.country="country",o.region="region",o.department="department",o.city="city",o.company="company"})(ow||(ow={}));var cw;(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"})(cw||(cw={}));function Mo(o,t){for(const e of o){const i=e.toLowerCase().split("-")[0];if(t.includes(i))return i}return"en"}class Ks{static preferencesFor(t){const e=navigator.languages??[],i=this.declaredFor(t);return i?[i,...e]:e}static declaredFor(t){for(let e=t;e;){const i=e.closest("[lang]")?.getAttribute("lang")?.trim();if(i)return i;const n=e.getRootNode();e=n instanceof ShadowRoot?n.host:void 0}}}class Ia{static count=0;static css(t){return`${t} { text-transform: none; letter-spacing: normal; word-spacing: normal; font-style: normal; font-variant: normal;
|
|
3
3
|
text-align: start; text-indent: 0; text-decoration: none; white-space: normal; }
|
|
4
4
|
${t}:popover-open { position: fixed; inset: auto; margin: 0 0 .35em; border: 0; position-area: top span-right; position-try-fallbacks: flip-block, flip-inline, flip-block flip-inline; }`}static attach(t,e){const i=`--rr0-help-${++Ia.count}`;t.style.setProperty("anchor-name",i),e.style.setProperty("position-anchor",i),e.setAttribute("popover","manual"),e.hidden=!0}static show(t,e){t.hidden=!e,!(typeof t.showPopover!="function"||!t.isConnected)&&(e&&!t.matches(":popover-open")?t.showPopover():!e&&t.matches(":popover-open")&&t.hidePopover())}}class zr extends HTMLElement{static TAG="rr0-hint";static CSS=`
|
|
@@ -748,7 +748,7 @@ ${SE.CSS}
|
|
|
748
748
|
margin: 0.4em 0 0;
|
|
749
749
|
padding-left: 1.2em;
|
|
750
750
|
}
|
|
751
|
-
`;class da{static NAMES=["weather","place","lightPollution","decor"];static KEYS={weather:["weatherTrack","weatherSource"],place:["place"],lightPollution:["lightPollution"],decor:["decor"]};static annexName(t,e){return`${t}.${e.replace(/[A-Z]/g,i=>`-${i.toLowerCase()}`)}.json`}static taken(t,e){const i={};if(t==="decor")return Array.isArray(e.decor)&&(i.decor=e.decor.filter(da.surveyed)),i;for(const n of da.KEYS[t])e[n]!==void 0&&(i[n]=e[n]);return i}static strip(t,e){if(t==="decor"){const i=Array.isArray(e.decor)?e.decor.filter(n=>!da.surveyed(n)):[];i.length>0?e.decor=i:delete e.decor;return}for(const i of da.KEYS[t])delete e[i]}static put(t,e,i){if(t==="decor"){if(!Array.isArray(i.decor))return;const n=Array.isArray(e.decor)?e.decor.filter(s=>!da.surveyed(s)):[];e.decor=[...n,...i.decor];return}for(const n of da.KEYS[t])i[n]!==void 0&&(e[n]=i[n])}static surveyed(t){return typeof t=="object"&&t!==null&&typeof t.origin=="string"}static fromFile(t,e){return t?.[e]!==void 0&&t[e].live!==!0}}class Zh{static NAMES=["relief","imagery","roads","water","railways","upperAir","map"];static TERRAIN=["relief","imagery","roads","water","railways"];static held(t,e){if(!t||t.live)return;const i=t[e];return i&&!i.live&&!i.refresh&&i.src!==void 0?i:void 0}static isLive(t,e){return t?.live===!0||t?.[e]?.live===!0}static annexName(t,e){const i=e==="relief"||e==="imagery"||e==="map"?"zip":"json",n=e.replace(/[A-Z]/g,s=>`-${s.toLowerCase()}`);return`${t}.${n}.${i}`}static isEmpty(t){return!t||!t.live&&Zh.NAMES.every(e=>!t[e])&&da.NAMES.every(e=>!t[e])}}class Ol extends Error{constructor(t,e,i){super(`${t}: ${e}${i===void 0?"":` (HTTP ${i})`}`),this.kind=t,this.url=e,this.status=i,this.name="SightingFetchError"}}class Ar{static async recording(t){const e=await Ar.json(t);for(const i of da.NAMES){const n=e?.snapshots?.[i];if(!(!n?.src||n.live))try{const s=lr.recording(await Ar.json(new URL(n.src,new URL(t,location.href)).href));da.put(i,e,s)}catch{}}return e}static async json(t){const e=new URL(t,location.href);if(location.protocol==="https:"&&e.protocol==="http:")throw new Ol("mixed-content",t);let i;try{i=await fetch(t)}catch{throw await this.diagnose(t,e)}if(!i.ok)throw new Ol("status",t,i.status);try{return await i.json()}catch{throw new Ol("malformed",t)}}static async diagnose(t,e){if(e.origin===location.origin)return new Ol("unreachable",t);try{return await fetch(t,{mode:"no-cors"}),new Ol("cors",t)}catch{return new Ol("unreachable",t)}}}class ki{static built=new WeakMap;static computers=new WeakMap;static loading=new WeakMap;static loaded(t,e){return e.every(i=>ki.itemsOf(t,i.key).length===0||ki.computers.has(i))}static load(t,e){return Promise.all(e.filter(i=>ki.itemsOf(t,i.key).length>0&&!ki.computers.has(i)).map(i=>{let n=ki.loading.get(i);return n||(n=i.compute().then(s=>{ki.computers.set(i,s)}),n.catch(()=>ki.loading.delete(i)),ki.loading.set(i,n)),n.catch(()=>{})})).then(()=>{})}static of(t){let e=ki.built.get(t);return e||(e=t.create(),ki.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=>ki.itemsOf(t,i.key).length>0)}static expand(t,e,i){return ki.expandWithKinds(t,e,i).interpretation}static expandWithKinds(t,e,i){const n=new Map;if(!t||!ki.computes(t,e))return{interpretation:t,kindOf:n};const s=e.flatMap(r=>ki.itemsOf(t,r.key).flatMap(a=>{const c=ki.computers.get(r);if(!c)return[];const l=c(a,i);for(const h of l)n.set(h.id,r);return l}));return{interpretation:{...t,bodies:[...t.bodies,...s]},kindOf:n}}static computedPart(t,e){const i={};for(const n of e){const s=ki.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)}}class EE extends Error{constructor(t,e,i,n){super(`Module "${t}" gives "${i}" at ${e}, which module "${n}" already gives`),this.moduleId=t,this.point=e,this.sourceId=i,this.ownerId=n,this.name="ModuleConflictError"}}class KT{constructor(t){this.id=t}sources=[];owners=new Map;ownerOf(t){return this.owners.get(t)}conflict(t,e){for(const i of e){const n=this.owners.get(i.id);if(n!==void 0&&n!==t)return{sourceId:i.id,ownerId:n}}}provide(t,e){const i=this.conflict(t,e);if(i)throw new EE(t,this.id,i.sourceId,i.ownerId);this.withdraw(t);const n=t===Ie.BUILT_IN?this.sources.findIndex(s=>this.owners.get(s.id)!==Ie.BUILT_IN):-1;n<0?this.sources.push(...e):this.sources.splice(n,0,...e);for(const s of e)this.owners.set(s.id,t);return this.sources}withdraw(t){for(let e=this.sources.length-1;e>=0;e--){const i=this.sources[e].id;this.owners.get(i)===t&&(this.sources.splice(e,1),this.owners.delete(i))}}}class Ie{static BUILT_IN="ufoathome";static changes=new EventTarget;static points=new Map;static modules=new Map;static point(t){let e=Ie.points.get(t);return e||(e=new KT(t),Ie.points.set(t,e)),e}static install(t){if(t.id===Ie.BUILT_IN)throw new Error(`"${Ie.BUILT_IN}" is the id of the built-in module`);const e=Ie.contributionsOf(t);for(const[s,r]of e){const a=Ie.point(s).conflict(t.id,r);if(a)throw new EE(t.id,s,a.sourceId,a.ownerId)}const i=new Set(e.map(([s])=>s)),n=Ie.modules.get(t.id);if(n)for(const[s]of Ie.contributionsOf(n))i.add(s);for(const s of i)Ie.point(s).withdraw(t.id);for(const[s,r]of e)Ie.point(s).provide(t.id,r);Ie.modules.set(t.id,t);for(const s of i)Ie.announce(s)}static uninstall(t){const e=Ie.modules.get(t);if(e){Ie.modules.delete(t);for(const[i]of Ie.contributionsOf(e))Ie.point(i).withdraw(t),Ie.announce(i)}}static installed(){return[...Ie.modules.values()]}static contributionsOf(t){return Object.entries(t.contributes).filter(e=>Array.isArray(e[1])&&e[1].length>0)}static announce(t){Ie.changes.dispatchEvent(new CustomEvent("change",{detail:t}))}}const qT=Nn.catalog({en:()=>st(()=>import("./FlareKindMessages_en-j3CY_TxX.js"),[],import.meta.url).then(o=>o.flareKindMessages_en),fr:()=>st(()=>import("./FlareKindMessages_fr-B2MezoN2.js"),[],import.meta.url).then(o=>o.flareKindMessages_fr),es:()=>st(()=>import("./FlareKindMessages_es-CZgrFIOO.js"),[],import.meta.url).then(o=>o.flareKindMessages_es),it:()=>st(()=>import("./FlareKindMessages_it-CmZmb3RP.js"),[],import.meta.url).then(o=>o.flareKindMessages_it)}),lw={key:"flares",messages:qT,compute:()=>st(async()=>{const{DecoyFlare:o}=await import("./DecoyFlare-DUt1_LcW.js");return{DecoyFlare:o}},[],import.meta.url).then(({DecoyFlare:o})=>t=>o.bodiesOf(t))},ZT=Nn.catalog({en:()=>st(()=>import("./LanternKindMessages_en-CQXdJ-k6.js"),[],import.meta.url).then(o=>o.lanternKindMessages_en),fr:()=>st(()=>import("./LanternKindMessages_fr-D7tQa_tQ.js"),[],import.meta.url).then(o=>o.lanternKindMessages_fr),es:()=>st(()=>import("./LanternKindMessages_es-BOO6kPjs.js"),[],import.meta.url).then(o=>o.lanternKindMessages_es),it:()=>st(()=>import("./LanternKindMessages_it-B8J-29Mj.js"),[],import.meta.url).then(o=>o.lanternKindMessages_it)}),hw={key:"lanterns",messages:ZT,compute:()=>st(async()=>{const{SkyLantern:o}=await import("./SkyLantern--RJZtEMU.js");return{SkyLantern:o}},[],import.meta.url).then(({SkyLantern:o})=>(t,e)=>o.bodiesOf(t,e?.obstacles)),editor:()=>st(async()=>{const{LanternEditor:o}=await import("./LanternEditor-F5ApaFs3.js");return{LanternEditor:o}},__vite__mapDeps([0,1,2]),import.meta.url).then(({LanternEditor:o})=>(t,e,i)=>new o(t,e,i))},JT=Nn.catalog({en:()=>st(()=>import("./BirdKindMessages_en-c_-L7frF.js"),[],import.meta.url).then(o=>o.birdKindMessages_en),fr:()=>st(()=>import("./BirdKindMessages_fr-C1TuqqEj.js"),[],import.meta.url).then(o=>o.birdKindMessages_fr),es:()=>st(()=>import("./BirdKindMessages_es-8Zo2t0o4.js"),[],import.meta.url).then(o=>o.birdKindMessages_es),it:()=>st(()=>import("./BirdKindMessages_it-DQZcrCkf.js"),[],import.meta.url).then(o=>o.birdKindMessages_it)}),uw={key:"birds",messages:JT,compute:()=>st(async()=>{const{BirdFlock:o}=await import("./BirdFlock-BbObIeXW.js").then(t=>t.b);return{BirdFlock:o}},[],import.meta.url).then(({BirdFlock:o})=>(t,e)=>o.bodiesOf(t,e?.obstacles)),editor:()=>st(async()=>{const{BirdEditor:o}=await import("./BirdEditor-mGkxSXV0.js");return{BirdEditor:o}},__vite__mapDeps([3,1,4,5]),import.meta.url).then(({BirdEditor:o})=>(t,e,i)=>new o(t,e,i))},jT=Ie.point("interpretations").provide(Ie.BUILT_IN,[{id:lw.key,name:"Decoy flares",credit:"UFO@home",creditUrl:"https://ufoathome.org/docs/format/",create:()=>lw},{id:hw.key,name:"Sky lanterns",credit:"UFO@home",creditUrl:"https://ufoathome.org/docs/format/",create:()=>hw},{id:uw.key,name:"Birds",credit:"UFO@home",creditUrl:"https://ufoathome.org/docs/format/",create:()=>uw}]);class k0{static kinds(){return jT.map(t=>ki.of(t))}}class Ui{static SIGHTING_EVENT="sighting";static INTERPRETATION_EVENT="interpretation";static INTERVIEW_EVENT="interview";static check(t){return lr.check(t,"case")}static isCase(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)&&Array.isArray(t.events)&&!("timeline"in t)}static sightingUrls(t,e){return(t.events??[]).filter(i=>i.eventType===Ui.SIGHTING_EVENT&&!i.interpretationOf&&typeof i.url=="string"&&i.url!=="").map(i=>new URL(i.url,e).href)}static accountIds(t,e,i,n){const s=(t.events??[]).filter(r=>r.eventType===Ui.SIGHTING_EVENT&&r.id!==void 0&&typeof r.url=="string"&&i!==void 0&&new URL(r.url,e).href===i).map(r=>r.id);return n!==void 0&&s.push(n),s}static interpretationEvents(t,e){const i=[e].flat().filter(n=>!!n);return i.length===0?[]:(t.events??[]).filter(n=>n.eventType===Ui.INTERPRETATION_EVENT?n.sighting!==void 0&&i.includes(n.sighting):n.eventType!==Ui.SIGHTING_EVENT||n.interpretationOf===void 0?!1:[n.interpretationOf].flat().some(s=>i.includes(s))).map(n=>n)}static problems(t,e){const i=t.events??[],n=new Set,s=new Set;for(const a of i)a.id!==void 0&&(n.has(a.id)&&s.add(a.id),n.add(a.id));const r=[];for(const a of i){const c=a.eventType===Ui.SIGHTING_EVENT?a.interpretationOf:a.eventType===Ui.INTERVIEW_EVENT?a.interviewOf:void 0;if(c!==void 0)for(const l of[c].flat())!n.has(l)&&!e.includes(l)&&r.push({reading:a.url??a.id??"",reference:l})}return{duplicateIds:[...s],unresolved:r}}static async interpretationOf(t,e,i){if(t.bodies)return Ui.withModelsFrom(Je.strip({title:t.title,bodies:t.bodies??[],smoke:t.smoke,findings:t.findings,...ki.computedPart(t,k0.kinds())}).recording,e);if(!t.url)return{title:t.title,bodies:[]};const n=new URL(t.url,e).href,s=await i(n),r="timeline"in s&&s.interpretation?s.interpretation:s;return Ui.withModelsFrom(Je.strip({title:t.title??r.title,bodies:r.bodies??[],smoke:r.smoke,findings:r.findings,...ki.computedPart(r,k0.kinds())}).recording,n)}static withModelsFrom(t,e){return{...t,bodies:t.bodies.map(i=>i.model?.url?{...i,model:{...i.model,url:new URL(i.model.url,e).href}}:i)}}}/**
|
|
751
|
+
`;class da{static NAMES=["weather","place","lightPollution","decor"];static KEYS={weather:["weatherTrack","weatherSource"],place:["place"],lightPollution:["lightPollution"],decor:["decor"]};static annexName(t,e){return`${t}.${e.replace(/[A-Z]/g,i=>`-${i.toLowerCase()}`)}.json`}static taken(t,e){const i={};if(t==="decor")return Array.isArray(e.decor)&&(i.decor=e.decor.filter(da.surveyed)),i;for(const n of da.KEYS[t])e[n]!==void 0&&(i[n]=e[n]);return i}static strip(t,e){if(t==="decor"){const i=Array.isArray(e.decor)?e.decor.filter(n=>!da.surveyed(n)):[];i.length>0?e.decor=i:delete e.decor;return}for(const i of da.KEYS[t])delete e[i]}static put(t,e,i){if(t==="decor"){if(!Array.isArray(i.decor))return;const n=Array.isArray(e.decor)?e.decor.filter(s=>!da.surveyed(s)):[];e.decor=[...n,...i.decor];return}for(const n of da.KEYS[t])i[n]!==void 0&&(e[n]=i[n])}static surveyed(t){return typeof t=="object"&&t!==null&&typeof t.origin=="string"}static fromFile(t,e){return t?.[e]!==void 0&&t[e].live!==!0}}class Zh{static NAMES=["relief","imagery","roads","water","railways","upperAir","map"];static TERRAIN=["relief","imagery","roads","water","railways"];static held(t,e){if(!t||t.live)return;const i=t[e];return i&&!i.live&&!i.refresh&&i.src!==void 0?i:void 0}static isLive(t,e){return t?.live===!0||t?.[e]?.live===!0}static annexName(t,e){const i=e==="relief"||e==="imagery"||e==="map"?"zip":"json",n=e.replace(/[A-Z]/g,s=>`-${s.toLowerCase()}`);return`${t}.${n}.${i}`}static isEmpty(t){return!t||!t.live&&Zh.NAMES.every(e=>!t[e])&&da.NAMES.every(e=>!t[e])}}class Ol extends Error{constructor(t,e,i){super(`${t}: ${e}${i===void 0?"":` (HTTP ${i})`}`),this.kind=t,this.url=e,this.status=i,this.name="SightingFetchError"}}class Ar{static async recording(t){const e=await Ar.json(t);for(const i of da.NAMES){const n=e?.snapshots?.[i];if(!(!n?.src||n.live))try{const s=lr.recording(await Ar.json(new URL(n.src,new URL(t,location.href)).href));da.put(i,e,s)}catch{}}return e}static async json(t){const e=new URL(t,location.href);if(location.protocol==="https:"&&e.protocol==="http:")throw new Ol("mixed-content",t);let i;try{i=await fetch(t)}catch{throw await this.diagnose(t,e)}if(!i.ok)throw new Ol("status",t,i.status);try{return await i.json()}catch{throw new Ol("malformed",t)}}static async diagnose(t,e){if(e.origin===location.origin)return new Ol("unreachable",t);try{return await fetch(t,{mode:"no-cors"}),new Ol("cors",t)}catch{return new Ol("unreachable",t)}}}class ki{static built=new WeakMap;static computers=new WeakMap;static loading=new WeakMap;static loaded(t,e){return e.every(i=>ki.itemsOf(t,i.key).length===0||ki.computers.has(i))}static load(t,e){return Promise.all(e.filter(i=>ki.itemsOf(t,i.key).length>0&&!ki.computers.has(i)).map(i=>{let n=ki.loading.get(i);return n||(n=i.compute().then(s=>{ki.computers.set(i,s)}),n.catch(()=>ki.loading.delete(i)),ki.loading.set(i,n)),n.catch(()=>{})})).then(()=>{})}static of(t){let e=ki.built.get(t);return e||(e=t.create(),ki.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=>ki.itemsOf(t,i.key).length>0)}static expand(t,e,i){return ki.expandWithKinds(t,e,i).interpretation}static expandWithKinds(t,e,i){const n=new Map;if(!t||!ki.computes(t,e))return{interpretation:t,kindOf:n};const s=e.flatMap(r=>ki.itemsOf(t,r.key).flatMap(a=>{const c=ki.computers.get(r);if(!c)return[];const l=c(a,i);for(const h of l)n.set(h.id,r);return l}));return{interpretation:{...t,bodies:[...t.bodies,...s]},kindOf:n}}static computedPart(t,e){const i={};for(const n of e){const s=ki.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)}}class EE extends Error{constructor(t,e,i,n){super(`Module "${t}" gives "${i}" at ${e}, which module "${n}" already gives`),this.moduleId=t,this.point=e,this.sourceId=i,this.ownerId=n,this.name="ModuleConflictError"}}class KT{constructor(t){this.id=t}sources=[];owners=new Map;ownerOf(t){return this.owners.get(t)}conflict(t,e){for(const i of e){const n=this.owners.get(i.id);if(n!==void 0&&n!==t)return{sourceId:i.id,ownerId:n}}}provide(t,e){const i=this.conflict(t,e);if(i)throw new EE(t,this.id,i.sourceId,i.ownerId);this.withdraw(t);const n=t===Ie.BUILT_IN?this.sources.findIndex(s=>this.owners.get(s.id)!==Ie.BUILT_IN):-1;n<0?this.sources.push(...e):this.sources.splice(n,0,...e);for(const s of e)this.owners.set(s.id,t);return this.sources}withdraw(t){for(let e=this.sources.length-1;e>=0;e--){const i=this.sources[e].id;this.owners.get(i)===t&&(this.sources.splice(e,1),this.owners.delete(i))}}}class Ie{static BUILT_IN="ufoathome";static changes=new EventTarget;static points=new Map;static modules=new Map;static point(t){let e=Ie.points.get(t);return e||(e=new KT(t),Ie.points.set(t,e)),e}static install(t){if(t.id===Ie.BUILT_IN)throw new Error(`"${Ie.BUILT_IN}" is the id of the built-in module`);const e=Ie.contributionsOf(t);for(const[s,r]of e){const a=Ie.point(s).conflict(t.id,r);if(a)throw new EE(t.id,s,a.sourceId,a.ownerId)}const i=new Set(e.map(([s])=>s)),n=Ie.modules.get(t.id);if(n)for(const[s]of Ie.contributionsOf(n))i.add(s);for(const s of i)Ie.point(s).withdraw(t.id);for(const[s,r]of e)Ie.point(s).provide(t.id,r);Ie.modules.set(t.id,t);for(const s of i)Ie.announce(s)}static uninstall(t){const e=Ie.modules.get(t);if(e){Ie.modules.delete(t);for(const[i]of Ie.contributionsOf(e))Ie.point(i).withdraw(t),Ie.announce(i)}}static installed(){return[...Ie.modules.values()]}static contributionsOf(t){return Object.entries(t.contributes).filter(e=>Array.isArray(e[1])&&e[1].length>0)}static announce(t){Ie.changes.dispatchEvent(new CustomEvent("change",{detail:t}))}}const qT=Nn.catalog({en:()=>st(()=>import("./FlareKindMessages_en-j3CY_TxX.js"),[],import.meta.url).then(o=>o.flareKindMessages_en),fr:()=>st(()=>import("./FlareKindMessages_fr-B2MezoN2.js"),[],import.meta.url).then(o=>o.flareKindMessages_fr),es:()=>st(()=>import("./FlareKindMessages_es-CZgrFIOO.js"),[],import.meta.url).then(o=>o.flareKindMessages_es),it:()=>st(()=>import("./FlareKindMessages_it-CmZmb3RP.js"),[],import.meta.url).then(o=>o.flareKindMessages_it)}),lw={key:"flares",messages:qT,compute:()=>st(async()=>{const{DecoyFlare:o}=await import("./DecoyFlare-DUt1_LcW.js");return{DecoyFlare:o}},[],import.meta.url).then(({DecoyFlare:o})=>t=>o.bodiesOf(t))},ZT=Nn.catalog({en:()=>st(()=>import("./LanternKindMessages_en-CQXdJ-k6.js"),[],import.meta.url).then(o=>o.lanternKindMessages_en),fr:()=>st(()=>import("./LanternKindMessages_fr-D7tQa_tQ.js"),[],import.meta.url).then(o=>o.lanternKindMessages_fr),es:()=>st(()=>import("./LanternKindMessages_es-BOO6kPjs.js"),[],import.meta.url).then(o=>o.lanternKindMessages_es),it:()=>st(()=>import("./LanternKindMessages_it-B8J-29Mj.js"),[],import.meta.url).then(o=>o.lanternKindMessages_it)}),hw={key:"lanterns",messages:ZT,compute:()=>st(async()=>{const{SkyLantern:o}=await import("./SkyLantern--RJZtEMU.js");return{SkyLantern:o}},[],import.meta.url).then(({SkyLantern:o})=>(t,e)=>o.bodiesOf(t,e?.obstacles)),editor:()=>st(async()=>{const{LanternEditor:o}=await import("./LanternEditor-DIun2igg.js");return{LanternEditor:o}},__vite__mapDeps([0,1,2]),import.meta.url).then(({LanternEditor:o})=>(t,e,i)=>new o(t,e,i))},JT=Nn.catalog({en:()=>st(()=>import("./BirdKindMessages_en-c_-L7frF.js"),[],import.meta.url).then(o=>o.birdKindMessages_en),fr:()=>st(()=>import("./BirdKindMessages_fr-C1TuqqEj.js"),[],import.meta.url).then(o=>o.birdKindMessages_fr),es:()=>st(()=>import("./BirdKindMessages_es-8Zo2t0o4.js"),[],import.meta.url).then(o=>o.birdKindMessages_es),it:()=>st(()=>import("./BirdKindMessages_it-DQZcrCkf.js"),[],import.meta.url).then(o=>o.birdKindMessages_it)}),uw={key:"birds",messages:JT,compute:()=>st(async()=>{const{BirdFlock:o}=await import("./BirdFlock-BbObIeXW.js").then(t=>t.b);return{BirdFlock:o}},[],import.meta.url).then(({BirdFlock:o})=>(t,e)=>o.bodiesOf(t,e?.obstacles)),editor:()=>st(async()=>{const{BirdEditor:o}=await import("./BirdEditor-B__-UnpK.js");return{BirdEditor:o}},__vite__mapDeps([3,1,4,5]),import.meta.url).then(({BirdEditor:o})=>(t,e,i)=>new o(t,e,i))},jT=Ie.point("interpretations").provide(Ie.BUILT_IN,[{id:lw.key,name:"Decoy flares",credit:"UFO@home",creditUrl:"https://ufoathome.org/docs/format/",create:()=>lw},{id:hw.key,name:"Sky lanterns",credit:"UFO@home",creditUrl:"https://ufoathome.org/docs/format/",create:()=>hw},{id:uw.key,name:"Birds",credit:"UFO@home",creditUrl:"https://ufoathome.org/docs/format/",create:()=>uw}]);class k0{static kinds(){return jT.map(t=>ki.of(t))}}class Ui{static SIGHTING_EVENT="sighting";static INTERPRETATION_EVENT="interpretation";static INTERVIEW_EVENT="interview";static check(t){return lr.check(t,"case")}static isCase(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)&&Array.isArray(t.events)&&!("timeline"in t)}static sightingUrls(t,e){return(t.events??[]).filter(i=>i.eventType===Ui.SIGHTING_EVENT&&!i.interpretationOf&&typeof i.url=="string"&&i.url!=="").map(i=>new URL(i.url,e).href)}static accountIds(t,e,i,n){const s=(t.events??[]).filter(r=>r.eventType===Ui.SIGHTING_EVENT&&r.id!==void 0&&typeof r.url=="string"&&i!==void 0&&new URL(r.url,e).href===i).map(r=>r.id);return n!==void 0&&s.push(n),s}static interpretationEvents(t,e){const i=[e].flat().filter(n=>!!n);return i.length===0?[]:(t.events??[]).filter(n=>n.eventType===Ui.INTERPRETATION_EVENT?n.sighting!==void 0&&i.includes(n.sighting):n.eventType!==Ui.SIGHTING_EVENT||n.interpretationOf===void 0?!1:[n.interpretationOf].flat().some(s=>i.includes(s))).map(n=>n)}static problems(t,e){const i=t.events??[],n=new Set,s=new Set;for(const a of i)a.id!==void 0&&(n.has(a.id)&&s.add(a.id),n.add(a.id));const r=[];for(const a of i){const c=a.eventType===Ui.SIGHTING_EVENT?a.interpretationOf:a.eventType===Ui.INTERVIEW_EVENT?a.interviewOf:void 0;if(c!==void 0)for(const l of[c].flat())!n.has(l)&&!e.includes(l)&&r.push({reading:a.url??a.id??"",reference:l})}return{duplicateIds:[...s],unresolved:r}}static async interpretationOf(t,e,i){if(t.bodies)return Ui.withModelsFrom(Je.strip({title:t.title,bodies:t.bodies??[],smoke:t.smoke,findings:t.findings,...ki.computedPart(t,k0.kinds())}).recording,e);if(!t.url)return{title:t.title,bodies:[]};const n=new URL(t.url,e).href,s=await i(n),r="timeline"in s&&s.interpretation?s.interpretation:s;return Ui.withModelsFrom(Je.strip({title:t.title??r.title,bodies:r.bodies??[],smoke:r.smoke,findings:r.findings,...ki.computedPart(r,k0.kinds())}).recording,n)}static withModelsFrom(t,e){return{...t,bodies:t.bodies.map(i=>i.model?.url?{...i,model:{...i.model,url:new URL(i.model.url,e).href}}:i)}}}/**
|
|
752
752
|
@preserve
|
|
753
753
|
|
|
754
754
|
Astronomy library for JavaScript (browser and Node.js).
|
|
@@ -6827,9 +6827,9 @@ button:has(> .icon:only-child) { display: inline-flex; align-items: center; just
|
|
|
6827
6827
|
`}class xf{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=xf.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=>` ${xf.text(n)}`);console.warn(`UFO@home: ${t.length} problem(s) in ${e??"this recording"}:
|
|
6828
6828
|
${i.join(`
|
|
6829
6829
|
`)}`)}}class wr{constructor(t){this.format=t}issues(t){const e=[];return this.object(t,this.format,"",e),e}object(t,e,i,n){if(!wr.isObject(t)){n.push({kind:"wrong-type",path:i||"(the file)",expected:"object",found:wr.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(wr.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):wr.isObject(t)||n.push({kind:"wrong-type",path:i,expected:"object",found:wr.typeOf(t)});return;case"array":Array.isArray(t)?e.fields&&t.forEach((s,r)=>{const a=wr.isStated(s)?s.value:s;this.object(a,e.fields,`${i}.${r}`,n)}):n.push({kind:"wrong-type",path:i,expected:"array",found:wr.typeOf(t)});return;default:typeof t!==e.type?n.push({kind:"wrong-type",path:i,expected:e.type,found:wr.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 wr.isObject(t)&&"value"in t&&Object.keys(t).every(e=>wr.STATED_KEYS.has(e))}static typeOf(t){return Array.isArray(t)?"array":t===null?"null":typeof t}}class us{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?us.travelDegOver(t,e,i,i+n*1e3)/s/us.PIXELS_PER_INSTANT:0,a=us.flashesOver(t,n)*us.INSTANTS_PER_FLASH,c=Math.ceil(Math.max(r,a));return c<2?1:Math.min(us.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=us.directionAt(r,e,i),c=us.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=Xr(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=us.bodyAt(c,i),h=us.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 m=Math.min(1,Math.max(-1,(u.x*d.x+u.y*d.y+u.z*d.z)/f/p));let g=Math.acos(m)*180/Math.PI,v=0;for(const M of Object.keys(h.motions))v=Math.max(v,Math.abs(h.motions[M]-(l.motions[M]??h.motions[M])));v>0&&(g+=v*2*(h.halfWidthM/Math.max(p,.001))*180/Math.PI),r=Math.max(r,g)}const a=Math.ceil(r/s/us.PIXELS_PER_INSTANT);return a<2?1:Math.min(us.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}}}const XA=Math.PI/180,PL=180/Math.PI,LL=256,$A=19,NL=1.25;function YA(o,t){return 156543.03392*Math.cos(o*XA)/2**t}function KA(o,t){return YA(o,t)*LL}function kL(o,t){let e=0;for(;e<$A&&KA(o,e+1)>=t;)e++;return e}function Fy(o,t){return KA(o,t)}function qA(o,t){const e=t*NL;let i=0;for(;i<$A&&YA(o,i)>e;)i++;return i}function M0(o){const t=o*XA;return(1-Math.log(Math.tan(t)+1/Math.cos(t))/Math.PI)/2}function ZA(o,t,e){const i=2**e;return{x:(o+180)/360*i,y:M0(t)*i}}function JA(o,t,e){const i=M0(o.north),n=M0(o.south);return{x:(t-o.west)/(o.east-o.west),y:(M0(e)-i)/(n-i)}}function FL(o,t,e){const{x:i,y:n}=ZA(o,t,e);return{x:Math.floor(i),y:Math.floor(n),z:e}}function UL(o){const t=2**o.z,e=o.x/t*360-180,i=(o.x+1)/t*360-180,n=vx(o.y,t);return{south:vx(o.y+1,t),north:n,west:e,east:i}}function vx(o,t){const e=o/t;return Math.atan(Math.sinh(Math.PI*(1-2*e)))*PL}function jA(o,t,e,i){const n=FL(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(UL),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 zL="#2ec4ff";class Wc{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=JA(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??zL;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:Wc.MARKER_RADIUS_PX}),e.beginPath(),e.arc(n.x,n.y,Wc.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=oe(r.lat,r.lng,e.lat,e.lng);return Math.hypot(a.x,a.z)<=Wc.ON_MARKER_M});i.beginPath(),i.arc(n.x,n.y,s?Wc.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(oe(r,t.east,r,t.west).x)/this.width,l=Wc.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 Mi{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 Mi.including(t.boundsAround(Mi.MIN_SPAN_M,Mi.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(Mi.MAX_ZOOM,Math.max(Mi.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=Mi.mercatorY01(e.north),s=Mi.mercatorY01(e.south),r=Mi.mercatorY01(i.north),a=Mi.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=Mi.mercatorY01(n.north),r=Mi.mercatorY01(n.south),a=(e.lng-n.west)/(n.east-n.west),c=(Mi.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=Mi.mercatorY01(t.north),n=Mi.mercatorY01(t.south),s=t.east-t.west;return{west:t.west+(this.centerX-e)*s,east:t.west+(this.centerX+e)*s,north:Mi.latitudeAt(i+(this.centerY-e)*(n-i)),south:Mi.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=oe(n,t.east,n,s).x;let a=r;for(const c of e){const{x:l,z:h}=oe(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=Mi.mercatorY01(t.north),s=Mi.mercatorY01(t.south);return{lat:Mi.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 vr=256,BL=3,HL=129,GL=7,VL=32768;class QA{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(oe(i,t.east,i,t.west).x),r=Math.abs(oe(t.north,n,t.south,n).z),a=Math.max(s,r);let c=kL(i,a),l=BL;if(e.width>=HL){const m=v=>2*Math.ceil((a/Fy(i,v)+1)/2)+1;let g=qA(i,a/(e.width-1)/2);for(;g>c&&m(g)>GL;)g--;g>c&&(c=g,l=m(g))}const{tiles:h}=jA(n,i,c,l),u=l*vr,d=new Float32Array(u*u),f=h[0];await Promise.all(h.map(m=>this.decodeTileInto(m,f,d,u)));const p=new Float32Array(e.width*e.height);for(let m=0;m<e.height;m++){const g=t.north+(t.south-t.north)*(m/(e.height-1));for(let v=0;v<e.width;v++){const M=t.west+(t.east-t.west)*(v/(e.width-1));p[m*e.width+v]=this.sampleAt(g,M,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=vr,c.height=vr;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,vr,vr),u=(t.x-e.x)*vr,d=(t.y-e.y)*vr;for(let f=0;f<vr;f++)for(let p=0;p<vr;p++){const m=(f*vr+p)*4,g=h[m]*256+h[m+1]+h[m+2]/256-VL,v=u+p,M=d+f;i[M*n+v]=g}}sampleAt(t,e,i,n,s,r){const{x:a,y:c}=ZA(e,t,i),l=(a-n.x)*vr,h=(c-n.y)*vr,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),m=l-u,g=h-d,v=s[d*r+u],M=s[d*r+f],w=s[p*r+u],y=s[p*r+f],b=v+(M-v)*m,S=w+(y-w)*m;return b+(S-b)*g}}class Hm{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 v=0;v<n;v++){const M=i+2+v*12;s.set(e.getUint16(M,!0),{type:e.getUint16(M+2,!0),count:e.getUint32(M+4,!0),value:e.getUint32(M+8,!0)})}const r=(v,M)=>{const w=s.get(v);if(w===void 0){if(M===void 0)throw new Error(`TIFF without tag ${v}`);return M}return w.type===3?w.value&65535:w.value},a=v=>{const M=s.get(v);if(M===void 0)throw new Error(`TIFF without tag ${v}`);const w=M.type===3?2:4,y=[];if(M.count*w<=4){const b=new DataView(new ArrayBuffer(4));b.setUint32(0,M.value,!0);for(let S=0;S<M.count;S++)y.push(w===2?b.getUint16(S*2,!0):b.getUint32(0,!0))}else for(let b=0;b<M.count;b++)y.push(w===2?e.getUint16(M.value+b*2,!0):e.getUint32(M.value+b*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),m=new Uint8Array(c*l*h*(u/8));let g=0;for(let v=0;v<f.length&&g<m.length;v++){const M=Math.min(p[v],m.length-g);m.set(new Uint8Array(t,f[v],M),g),g+=M}if(g<m.length)throw new Error("Truncated TIFF");return new Hm(c,l,h,d?new Float32Array(m.buffer):m)}}class Uo extends Error{constructor(t,e){super(e),this.reason=t,this.name="SurroundingsUnavailableError"}}class WL{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 ze{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??ze.WMS,this.wfs=t.wfsEndpoint??ze.WFS}static radius(t){return Math.min(t,ze.MAX_RADIUS_M)}static lidarRadius(t){return Math.min(t,ze.MAX_LIDAR_RADIUS_M)}async lidar(t,e){const i=ze.lidarRadius(e),n=Math.ceil(2*i/ze.METRES_PER_PIXEL),[s,r]=await Promise.all([this.raster(t,i,n,ze.HEIGHT_LAYER),this.raster(t,i,n,ze.CLASS_LAYER)]);if(s.samples!==1||r.samples<3)throw new Uo("unreachable","The survey answered in a layout this does not read");const a=s.values;if(a.every(u=>u===ze.NO_DATA))throw new Uo("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 WL(a,c,l,n,h)}}async laserDate(t){return ze.latest(await this.dated("IGNF_LIDAR-HD_METADONNEE:metadata","geom","date_fin_acquisition",t))}async photoDate(t){return ze.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=ze.radius(e),n=Math.min(ze.MAX_PHOTO_PIXELS,Math.ceil(2*i/ze.METRES_PER_PIXEL)),s=await this.raster(t,i,n,ze.PHOTO_LAYER);if(s.samples<3)throw new Uo("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=ze.radius(e),s=n/ze.METRES_PER_DEGREE,r=n/(ze.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(v=>v.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,ze.BUILDING_PROPERTIES,5e3):Promise.resolve([]),i?this.features("zone_d_activite_ou_d_interet",c,"toponyme,categorie,geometrie",100).catch(()=>[]):Promise.resolve([])]),m=i?await this.wholeWorship(p,f,[t.lng-r,t.lat-s,t.lng+r,t.lat+s]):[],g=[...f,...m];return{bridges:l,elevatedRoads:h,elevatedRailways:u,lines:d,buildings:g,zones:p,mapDate:ze.latest(g.map(v=>v.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=ze.MAX_WHOLE_M/ze.METRES_PER_DEGREE;let l;for(const u of t){if(u.properties.categorie!=="Religieux")continue;const[d,f,p,m]=ze.extent(u);if(d>=n&&f>=s&&p<=r&&m<=a)continue;const g=[Math.max(d,n-c),Math.max(f,s-c),Math.min(p,r+c),Math.min(m,a+c)];l=l?[Math.min(l[0],g[0]),Math.min(l[1],g[1]),Math.max(l[2],g[2]),Math.max(l[3],g[3])]:g}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')`,ze.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/ze.METRES_PER_DEGREE,r=e/(ze.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 Uo("unreachable",l instanceof Error?l.message:String(l))}if(!c.ok)throw new Uo("unreachable",`The survey answered ${c.status}`);try{return Hm.parse(await c.arrayBuffer())}catch(l){throw new Uo("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 Uo("unreachable",c instanceof Error?c.message:String(c))}if(!r.ok)throw new Uo("unreachable",`The map answered ${r.status}`);return(await r.json()).features??[]}}class Yo{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=>oe(a.lat,a.lng,i.lat,i.lng)),s=t.map(a=>oe(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/Yo.SAMPLE_M)),d=Math.atan2(l.x-c.x,-(l.z-c.z));for(let f=0;f<=u;f++){const p=f/u,m=Yo.nearest(n,c.x+(l.x-c.x)*p,c.z+(l.z-c.z)*p);m.distanceM>Yo.NEAR_M||Yo.angleBetween(d,m.heading)<=Yo.ALIGNED_DEG&&(r+=h/u)}}return r>=Yo.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 Le{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??Le.WMS,this.timeoutMs=t.timeoutMs??Le.DEFAULT_TIMEOUT_MS,this.maxWindowM=t.maxWindowM??Le.MAX_WINDOW_M,this.geoplatform=new ze({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(!ze.covers(n.lat,n.lng))throw new Error("The IGN's relief covers France only");const s=Math.abs(oe(n.lat,t.east,n.lat,t.west).x),r=Math.abs(oe(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/Le.METRES_PER_DEGREE,north:t.north+c.y/Le.METRES_PER_DEGREE,west:t.west-c.x/(Le.METRES_PER_DEGREE*Math.cos(n.lat*Math.PI/180)),east:t.east+c.x/(Le.METRES_PER_DEGREE*Math.cos(n.lat*Math.PI/180))},h=m=>Math.min(Le.MAX_PIXELS,Math.max(Le.MIN_PIXELS,Math.ceil(m/Le.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)>Le.COARSE_METRES_PER_PIXEL;for(const m of p?[...Le.LAYERS].reverse():Le.LAYERS)try{const g=await this.heights(l,u,m);m===Le.LAYERS[0]&&await this.layBridgeDecks(g,l,u,i?.route);const v=this.sample(g,e,t,l,d,a);if(v)return{heights:v,width:e.width,height:e.height,bounds:t};f=new Error(`${m} does not cover this place`)}catch(g){f=g}throw f}finer(t,e,i){if(t.width<Le.MESH_FROM_VERTICES||t.height<Le.MESH_FROM_VERTICES)return t;const n=(s,r)=>{const a=Math.ceil(s/Le.FINE_SPACING_M),c=Math.max(r-1,Math.min(Le.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 Hm.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>Le.NO_DATA_BELOW)))try{const s=(await this.geoplatform.elevatedRoadLines({west:e.west,south:e.south,east:e.east,north:e.north})).filter(a=>Yo.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,Le.CLASS_LAYER);if(s.samples<3||s.width!==t.width||s.height!==t.height)return;const r=(g,[v,M,w])=>s.values[g*s.samples]===v&&s.values[g*s.samples+1]===M&&s.values[g*s.samples+2]===w,a=t.width,c=t.height,l=new Uint8Array(a*c);let h=!1;for(let g=0;g<l.length;g++)r(g,Le.DECK)&&(l[g]=1,h=!0);if(!h)return;const u=Le.DECK_END_PIXELS,d=[];for(let g=0;g<l.length;g++){if(l[g]!==1)continue;const v=g%a,M=(g-v)/a;for(let w=-u;w<=u;w++)for(let y=-u;y<=u;y++){const b=v+y,S=M+w;if(b<0||S<0||b>=a||S>=c)continue;const E=S*a+b;l[E]===0&&r(E,Le.NO_CLASS)&&d.push(E)}}for(const g of d)l[g]=1;const f=this.paint(n,e,a,c),p=this.touching(l,f,a,c);if(p.every(g=>g===0))return;const m=await this.heights(e,i,Le.SURFACE_LAYER);if(m.width!==a||m.height!==c)return;for(let g=0;g<p.length;g++){if(p[g]===0)continue;const v=m.values[g];Number.isFinite(v)&&v>Le.NO_DATA_BELOW&&v>t.values[g]&&(t.values[g]=v)}}catch{}}layRouteDecks(t,e,i,n){const{width:s,height:r}=t,a=(i.north+i.south)/2,c=(i.east-i.west)*Le.METRES_PER_DEGREE*Math.cos(a*Math.PI/180),l=(i.north-i.south)*Le.METRES_PER_DEGREE,h=c/s,u=l/r,d=v=>({x:(v.lng-i.west)/(i.east-i.west)*c,y:(i.north-v.lat)/(i.north-i.south)*l}),f=(v,M)=>{const w=Math.floor(v/h),y=Math.floor(M/u);if(w<0||y<0||w>=s||y>=r)return;const b=e[y*s+w];return Number.isFinite(b)&&b>Le.NO_DATA_BELOW?b:void 0},p=Le.DECK_HALF_WIDTH_M,m=Le.DECK_APPROACH_M,g=(v,M)=>{const w=Math.hypot(v.x-M.x,v.y-M.y)||1,y={x:(v.x-M.x)/w,y:(v.y-M.y)/w},b=[0,m/2,m].map(S=>f(v.x+y.x*S,v.y+y.y*S)).filter(S=>S!==void 0);return b.length>0?Math.max(...b):void 0};for(const v of Le.chains(n.map(M=>M.map(d)))){const M=[0];for(let I=1;I<v.length;I++)M.push(M[I-1]+Math.hypot(v[I].x-v[I-1].x,v[I].y-v[I-1].y));const w=M[M.length-1];if(w<1||w>Le.DECK_STRAIGHT_MAX_M)continue;const y=g(v[0],v[1]),b=g(v[v.length-1],v[v.length-2]);if(y===void 0||b===void 0)continue;const S=p+m,E=Math.max(0,Math.floor((Math.min(...v.map(I=>I.x))-S)/h)),x=Math.min(s-1,Math.ceil((Math.max(...v.map(I=>I.x))+S)/h)),A=Math.max(0,Math.floor((Math.min(...v.map(I=>I.y))-S)/u)),T=Math.min(r-1,Math.ceil((Math.max(...v.map(I=>I.y))+S)/u));for(let I=A;I<=T;I++)for(let D=E;D<=x;D++){const O=Le.nearestAlong(v,M,{x:(D+.5)*h,y:(I+.5)*u});if(O.distance>p||O.s<-m||O.s>w+m)continue;const N=y+(b-y)*Math.min(1,Math.max(0,O.s/w)),P=I*s+D;e[P]>=N||(t.values[P]=N)}}}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 m=0;m<=p;m++){const g=Math.floor(h+(d-h)*m/p),v=Math.floor(u+(f-u)*m/p);for(let M=-1;M<=1;M++)for(let w=-1;w<=1;w++){const y=g+w,b=v+M;y>=0&&b>=0&&y<i&&b<n&&(s[b*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 m=-1;m<=1;m++){const g=d+m,v=f+p;if(g<0||v<0||g>=i||v>=n)continue;const M=v*i+g;t[M]===1&&r[M]===0&&(r[M]=1,l.push(M))}}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 m=i.north+(i.south-i.north)*(c===1?.5:p/(c-1)),g=(n.north-m)/(n.north-n.south)*t.height-.5;for(let v=0;v<a;v++){const w=(i.west+(i.east-i.west)*(a===1?.5:v/(a-1))-n.west)/(n.east-n.west)*t.width-.5,y=u>1||d>1?this.tent(t,w,g,Math.max(1,u),Math.max(1,d)):this.bilinear(t,w,g),b=p*a+v;y===void 0?f++:(l[b]=y,h[b]=1)}}if(!(f===a*c||f/(a*c)>Le.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 m=u;m<=d;m++){const g=p*(1-Math.abs(m-e)/n);if(g<=0)continue;c+=g;const v=t.at(m,f);!Number.isFinite(v)||v<Le.NO_DATA_BELOW||(r+=g*v,a+=g)}}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 g of[h,u,d,f])if(!Number.isFinite(g)||g<Le.NO_DATA_BELOW)return;const p=h+(u-h)*c,m=d+(f-d)*c;return p+(m-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,m=c+f;p<0||m<0||p>=n||m>=i||!e[p*i+m]||(h+=t[p*i+m],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 XL{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 y0=256,$L=5;async function t3(o,t,e,i){const n=(o.south+o.north)/2,s=(o.west+o.east)/2,r=Math.abs(oe(n,o.east,n,o.west).x),a=Math.abs(oe(o.north,s,o.south,s).z),c=Math.max(r,a),{zoom:l,gridSize:h}=YL(n,c,Math.max(t.width,t.height)),{tiles:u,bounds:d}=jA(s,n,l,h),f=h*y0,p=document.createElement("canvas");p.width=f,p.height=f;const m=p.getContext("2d");if(!m)throw new Error("2D canvas context unavailable");const g=u[0];await Promise.all(u.map(async y=>{const b=e(y),S=await i(b);if(!S.ok)throw new Error(`Imagery tile fetch failed (${S.status}): ${b}`);const E=await createImageBitmap(await S.blob());m.drawImage(E,(y.x-g.x)*y0,(y.y-g.y)*y0)}));const v=Math.min(Math.max(t.width,t.height),f);if(v===f)return{source:p,width:f,height:f,bounds:d};const M=document.createElement("canvas");M.width=v,M.height=v;const w=M.getContext("2d");if(!w)throw new Error("2D canvas context unavailable");return w.drawImage(p,0,0,f,f,0,0,v,v),{source:M,width:v,height:v,bounds:d}}function YL(o,t,e){let i=qA(o,t/Math.max(1,e)),n=Mx(o,i,t);for(;n>$L&&i>0;)i--,n=Mx(o,i,t);return{zoom:i,gridSize:n,mPerPixel:Fy(o,i)/y0}}function Mx(o,t,e){const i=Math.ceil(e/2/Fy(o,t));return Math.max(3,2*i+1)}class e3{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 t3(t,e,i=>this.tileUrlTemplate.replace("{z}",String(i.z)).replace("{y}",String(i.y)).replace("{x}",String(i.x)),this.fetchImpl)}}class Xs{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=Xs.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=Xs.FRANCE;return c>=h.south&&c<=h.north&&l>=h.west&&l<=h.east?[Xs.FRANCE_ENDPOINT,...e.filter(d=>d!==Xs.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=Xs.queue.then(t,t);return Xs.queue=e.catch(()=>{}),e}async ask(t){let e;for(const i of this.endpoints??Xs.endpointsFor(t))for(let n=0;n<2;n++){try{const s=await this.fetchImpl(`${i}?data=${encodeURIComponent(t)}`,{signal:AbortSignal.timeout(Xs.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,Xs.RETRY_MS))}throw e??new Error("No Overpass instance answered")}}class Ko{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 Xs(t)}async getRoads(t){const e=`${t.south},${t.west},${t.north},${t.east}`,i=`[out:json][timeout:30];way["highway"~"^(${Ko.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:Ko.surfaceOf(s),widthM:Ko.widthOf(s),...Ko.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:Ko.WIDTH_M[t.highway]??Ko.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 Qg="https://ufoathome.org/roads/index.json";class Ih{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??Ih.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(`
|
|
6830
|
-
`);let e=Ih.shared.get(t);return e||(e=this.fetchFirstAvailable(),Ih.shared.set(t,e),e.then(i=>{i.length===0&&Ih.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.188.
|
|
6831
|
-
`);let e=Dh.shared.get(t);return e||(e=this.fetchFirstAvailable(),Dh.shared.set(t,e),e.then(i=>{i.length===0&&Dh.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.188.0")}`,e=typeof location>"u"?void 0:new URL("/water/index.json",location.href).href;return(e&&e!==t1?[e,t1]:[t1]).map(i=>i+t)}}class Fs{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=Fs.key(t);let i=Fs.asked.get(e);return i===void 0&&(i=this.recalled(e,t),Fs.asked.set(e,i),i.catch(()=>Fs.asked.delete(e))),structuredClone(await i)}static forget(){Fs.asked.clear()}static key(t){return`v${Fs.FORMAT}/${[t.north,t.south,t.east,t.west].map(e=>e.toFixed(5)).join("/")}`}async recalled(t,e){const i=await Fs.openCache(),n=Fs.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<Fs.MAX_AGE_MS&&Array.isArray(c))return c;await i.delete(n)}}catch{}const s=await this.water.getWater(e);return i&&Fs.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-Fs.MAX_STORED)))await t.delete(r)}catch{}}static async openCache(){try{return typeof caches>"u"?void 0:await caches.open(Fs.CACHE_NAME)}catch{return}}static request(t){const e=typeof location>"u"?"http://localhost":location.origin;return new Request(`${e}/__water__/${encodeURIComponent(t)}`)}}class ic{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 ze(t)}static covers(t){return ze.covers((t.south+t.north)/2,(t.west+t.east)/2)}async getRailways(t){return(await this.platform.railways(t)).flatMap((i,n)=>ic.linesOf(i,n))}static linesOf(t,e){const{type:i,coordinates:n}=t.geometry,s=i==="LineString"?[n]:i==="MultiLineString"?n:[],r=ic.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=ic.GAUGE_MM[String(t.properties.largeur??"")]??1435,d=ic.electrificationOf(r.kind,u,t.properties.electrifie);return s.flatMap((f,p)=>{const m=f.map(g=>({lat:g[1],lng:g[0],...g.length>2&&Number.isFinite(g[2])&&g[2]>ic.NO_ALTITUDE?{altitudeM:g[2]}:{}}));return m.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:m}]})}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 Jn{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 Xs(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"~"^(${Jn.KINDS})$"](${i})->.w;.w out tags geom;rel(bw.w)["route"~"^(${Jn.ROUTES})$"];out body;`;return Jn.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=Jn.ways(e,n);return s.length===0?[...t]:t.map(r=>{const a=r.points.map(v=>oe(v.lat,v.lng,n.lat,n.lng)),c=new Map,l=new Map,h=new Map;let u=0;const d=s.filter(v=>v.service===!!r.service);for(const v of Jn.samples(a)){u++;const M=Jn.waysAt(d,v);if(M.length===0)continue;const[w]=M;w.name&&c.set(w.name,(c.get(w.name)??0)+1),w.voltageV&&l.set(w.voltageV,(l.get(w.voltageV)??0)+1);for(const y of new Set(M.flatMap(b=>b.services)))h.set(y,(h.get(y)??0)+1)}const f=v=>[...v.entries()].sort((M,w)=>w[1]-M[1])[0]?.[0],p=r.name??f(c),m=r.voltageV??(r.electrification==="none"?void 0:f(l)),g=[...h.entries()].filter(([,v])=>v*4>=u).sort((v,M)=>M[1]-v[1]||v[0].localeCompare(M[0])).map(([v])=>v);return{...r,...p?{name:p}:{},...m?{voltageV:m}:{},...g.length>0?{services:g}:{}}})}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=Jn.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=Jn.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=Jn.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=>oe(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=Jn.SAMPLE_M/2;a<n;a+=Jn.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(Jn.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<=Jn.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 Ch{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 Xs(t)}async getRailways(t){const e=`${t.south},${t.west},${t.north},${t.east}`,i=`[out:json][timeout:25];way["railway"~"^(${Ch.KINDS.join("|")})$"](${e})->.w;.w out tags geom;rel(bw.w)["route"~"^(${Jn.ROUTES})$"];out body;`;return this.linesFrom(await this.client.query(i))}linesFrom(t){const e=[],i=Jn.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=Jn.voltageOf(r),l=Ch.kindOf(r),h=Number.parseInt((r.gauge??"").split(";")[0],10),u=Number.parseInt(r.tracks??"",10),d=Ch.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:Ch.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 ZL{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(!ic.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 mn{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=mn.key(t);let i=mn.asked.get(e)??mn.containing(t);if(i===void 0){const n=this.recalled(e,t);i={bounds:t,answer:n},mn.asked.set(e,i),n.catch(()=>mn.asked.delete(e))}return structuredClone(await i.answer)}static forget(){mn.asked.clear(),mn.failedAt=-1/0}static key(t){return`v${mn.FORMAT}/${[t.north,t.south,t.east,t.west].map(e=>e.toFixed(5)).join("/")}`}static containing(t){for(const e of mn.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 mn.openCache(),n=mn.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<mn.MAX_AGE_MS)return l;s=l}}}catch{}if(this.now()-mn.failedAt<mn.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(mn.failedAt=this.now(),s)return s;throw a}return i&&mn.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-mn.MAX_STORED)))await t.delete(s)}catch{}}static async openCache(){try{return typeof caches>"u"?void 0:await caches.open(mn.CACHE_NAME)}catch{return}}static request(t){const e=typeof location>"u"?"http://localhost":location.origin;return new Request(`${e}/__railways__/${encodeURIComponent(t)}`)}}const e1="https://ufoathome.org/railways/index.json";class Oh{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??Oh.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(`
|
|
6832
|
-
`);let e=Oh.shared.get(t);return e||(e=this.fetchFirstAvailable(),Oh.shared.set(t,e),e.then(i=>{i.length===0&&Oh.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.188.0")}`,e=typeof location>"u"?void 0:new URL("/railways/index.json",location.href).href;return(e&&e!==e1?[e,e1]:[e1]).map(i=>i+t)}}function i3(){return{elevation:n3(),imagery:s3(),roads:JL(),water:jL(),railways:QL()}}function n3(){return new XL(new Le,new QA)}function s3(){return new e3}function JL(){return new Ih({fallback:new KL(new ec,new Ko)})}function jL(){return new Dh({fallback:new Fs(new qL(new Sf,new Xc))})}function QL(){return new Oh({fallback:new mn(new ZL(new ic,new Ch))})}const tN=new Set,Pa="show-observer-map",La="hide-milestones",sl="minified";class Ve extends HTMLElement{static get observedAttributes(){return["src",Pa,La,sl]}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 Mi;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=Tm.create();issues=[];issueCheck=0;sightingAudio=new gx;liveSightingAudio;hearInto(t){t?(this.liveSightingAudio??=this.sightingAudio,this.sightingAudio=new gx(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>Ve.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");Ve.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 st(async()=>{const{VideoButton:s}=await import("./VideoButton-C62NkJrH.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)<Ve.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>=Mi.MAX_ZOOM,this.mapZoomOutButton.disabled=this.observerMapView.zoomFactor<=Mi.MIN_ZOOM,this.paintObserverMap(this.currentTime),this.scheduleObserverMapImagery()}scheduleObserverMapImagery(){this.observerMapImageryTimer===void 0&&(this.observerMapImageryTimer=setTimeout(()=>{this.observerMapImageryTimer=void 0,this.loadObserverMapImagery()},Ve.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=Mi.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>${AL}</style>${EL}`,this.shadow.appendChild(t.content.cloneNode(!0)),this.stageElement=this.shadow.getElementById("stage"),this.canvas=this.shadow.getElementById("canvas"),this.canvasRenderer=new xu(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 Wc(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===Pa&&this.applyObserverMapDefault(),t===La&&this.setMilestonesShown(!this.hasAttribute(La)),t===sl){const n=this.minified;this.stageElement.classList.toggle("minified",n),n&&e===null&&(this.muted=!0),this.updateStartState()}}get minified(){return this.hasAttribute(sl)}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(o3)))};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 Ar.recording(t)}get sightingData(){return gE(this.currentSighting)}set sightingData(t){const e=lr.recording(t);this.player.stop(),this.soundPreview=void 0,this.sightingAudio.silence(),this.currentSighting=JM(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 st(async()=>{const{default:r}=await import("./sightingSchema-Dk010uUD.js");return{default:r}},[],import.meta.url);n=new wr(s).issues(t)}catch{}i===this.issueCheck&&(this.issues=[...n,...e.loadIssues],xf.warn(this.issues,e.id),this.renderIssues(),this.dispatchEvent(new CustomEvent(eN,{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=xf.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=we.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)<Ve.TIME_SAID_EVERY_MS||(this.timeSaid=t,this.dispatchEvent(new CustomEvent(a3,{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"),Ve.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)),Ve.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?md(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=Ve.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=Ve.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 xu(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=Ve.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=us.windowEndingAt(t,this.currentSighting.exposure??0);if(e.ms<Ve.SHORTEST_VISIBLE_EXPOSURE_MS)return[t];const i=Math.min(Ve.MAX_EXPOSURE_STEPS,Math.max(2,Math.round(e.ms/Ve.SHORTEST_VISIBLE_EXPOSURE_MS))),n=Math.ceil(this.travelPxOver(e.fromMs,e.ms)/Ve.EXPOSURE_STEP_PX),s=Math.min(Ve.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=Ti.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:tN;this.canvasRenderer.setStarPoints(Ti.starPointsOf(this.sighting.instrument,Oe(this.sighting,t)?.fNumber));const n=(Oe(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?ar.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(hE(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 _L(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*Ve.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){Ve.icons.get(t)!==e&&(Ve.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},Ve.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(),Ve.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(Pa),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;Ve.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=iu.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=Mi.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?Mi.expand(t,Ve.OBSERVER_MAP_IMAGERY_AHEAD):t,n=Mi.IMAGERY_PX*(e?1+2*Ve.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:s3();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?Mi.expand(t,Ve.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=Ve.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=Oe(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},Ve.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?md(this.currentSighting.milestones):[]){const a=Oe(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?Aa.of(i,this.canvas.height,e.fovDeg).halfWidthAngleDeg(Ti.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,md(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??"",Ve.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=Oe(this.currentSighting,0);return e?.lat===void 0||e.lng===void 0?[]:this.currentSighting.decor.filter(i=>i.kind!=="crop").map(i=>{const n=Xr(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=Oe(this.currentSighting,this.currentTime),s=Aa.of(this.currentSighting.instrument,this.canvas.height,n?.fovDeg??60);return{x:-s.angleDegToRadiusPx(e),y:s.angleDegToRadiusPx(i)}}gaitAt(t){return hi.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=Ve.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)),Ve.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){Ve.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}Ve.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;Ve.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 es(Ks.preferencesFor(this))}saidTexts;async loadLocaleMessages(){const t=Mo(Ks.preferencesFor(this),yo);if(t===this.messagesLanguage)return;this.messagesLanguage=t;const e=await OT.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=lE(t);this.realDurationMs=e!==void 0&&e>0?e:void 0,this.realStartMs=t.time?J1(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 zo(t);const e=this.currentSighting.timeline.duration,i=e>0&&t<=e?t/e*this.realDurationMs:t;return this.canShowClockTime?wx(yx(this.realStartMs+i)):zo(i)}formatElapsedAt(t){const e=this.currentSighting.timeline.duration;return this.realDurationMs===void 0?zo(t):zo(e>0&&t<=e?t/e*this.realDurationMs:t)}formatRemaining(t){const e=this.currentSighting.timeline.duration;if(this.realDurationMs===void 0)return zo(Math.max(0,e-t));const i=e>0&&t<=e?t/e*this.realDurationMs:t;return zo(Math.max(0,this.realDurationMs-i))}formatEndOfTimeline(){return this.realDurationMs===void 0?zo(this.currentSighting.timeline.duration):this.canShowClockTime?wx(yx(this.realStartMs+this.realDurationMs)):zo(this.realDurationMs)}}function yx(o){const t=new Date(o);return{hour:t.getUTCHours(),minute:t.getUTCMinutes(),second:t.getUTCSeconds()}}function wx(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 zo(o){const t=Math.round(o/1e3),e=Math.floor(t/60),i=t%60;return`${e}:${String(i).padStart(2,"0")}`}const pM="rr0-ufo";function r3(){customElements.get(pM)||customElements.define(pM,Ve)}const a3="timechange",eN="recordingissues",o3="minifiedreset",iN=`
|
|
6830
|
+
`);let e=Ih.shared.get(t);return e||(e=this.fetchFirstAvailable(),Ih.shared.set(t,e),e.then(i=>{i.length===0&&Ih.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.188.1")}`,e=typeof location>"u"?void 0:new URL("/roads/index.json",location.href).href;return(e&&e!==Qg?[e,Qg]:[Qg]).map(i=>i+t)}}class ec{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 ze(t)}static covers(t){return ze.covers((t.south+t.north)/2,(t.west+t.east)/2)}async getRoads(t){return(await this.platform.roads(t)).flatMap((i,n)=>ec.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=ec.BY_NATURE[n]??ec.DEFAULT,r=Number(t.properties.largeur_de_chaussee),a=Number(t.properties.nombre_de_voies),c=Number(t.properties.vitesse_moyenne_vl),l=ec.DIRECTIONS[String(t.properties.sens_de_circulation??"")],h=ec.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 KL{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(ec.covers(t))try{const e=await this.regional.getRoads(t);if(e.length>0)return e}catch{}return this.worldwide.getRoads(t)}}class Sf{attribution="Water © IGN, BD TOPO (Licence Ouverte 2.0)";platform;constructor(t={}){this.platform=new ze(t)}static covers(t){return ze.covers((t.south+t.north)/2,(t.west+t.east)/2)}async getWater(t){return(await this.platform.waterSurfaces(t)).flatMap((i,n)=>Sf.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=>Sf.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 Xc{attribution="Water © OpenStreetMap contributors";client;constructor(t={}){this.client=new Xs(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 Xc.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=Xc.rings(a("inner"));for(const[l,h]of Xc.rings(a("outer")).entries()){const u=c.filter(d=>Xc.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 Xc.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 qL{constructor(t,e){this.regional=t,this.worldwide=e}attribution="Water © IGN, BD TOPO, in France; © OpenStreetMap contributors elsewhere";async getWater(t){if(Sf.covers(t))try{const e=await this.regional.getWater(t);if(e.length>0)return e}catch{}return this.worldwide.getWater(t)}}const t1="https://ufoathome.org/water/index.json";class Dh{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??Dh.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(`
|
|
6831
|
+
`);let e=Dh.shared.get(t);return e||(e=this.fetchFirstAvailable(),Dh.shared.set(t,e),e.then(i=>{i.length===0&&Dh.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.188.1")}`,e=typeof location>"u"?void 0:new URL("/water/index.json",location.href).href;return(e&&e!==t1?[e,t1]:[t1]).map(i=>i+t)}}class Fs{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=Fs.key(t);let i=Fs.asked.get(e);return i===void 0&&(i=this.recalled(e,t),Fs.asked.set(e,i),i.catch(()=>Fs.asked.delete(e))),structuredClone(await i)}static forget(){Fs.asked.clear()}static key(t){return`v${Fs.FORMAT}/${[t.north,t.south,t.east,t.west].map(e=>e.toFixed(5)).join("/")}`}async recalled(t,e){const i=await Fs.openCache(),n=Fs.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<Fs.MAX_AGE_MS&&Array.isArray(c))return c;await i.delete(n)}}catch{}const s=await this.water.getWater(e);return i&&Fs.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-Fs.MAX_STORED)))await t.delete(r)}catch{}}static async openCache(){try{return typeof caches>"u"?void 0:await caches.open(Fs.CACHE_NAME)}catch{return}}static request(t){const e=typeof location>"u"?"http://localhost":location.origin;return new Request(`${e}/__water__/${encodeURIComponent(t)}`)}}class ic{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 ze(t)}static covers(t){return ze.covers((t.south+t.north)/2,(t.west+t.east)/2)}async getRailways(t){return(await this.platform.railways(t)).flatMap((i,n)=>ic.linesOf(i,n))}static linesOf(t,e){const{type:i,coordinates:n}=t.geometry,s=i==="LineString"?[n]:i==="MultiLineString"?n:[],r=ic.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=ic.GAUGE_MM[String(t.properties.largeur??"")]??1435,d=ic.electrificationOf(r.kind,u,t.properties.electrifie);return s.flatMap((f,p)=>{const m=f.map(g=>({lat:g[1],lng:g[0],...g.length>2&&Number.isFinite(g[2])&&g[2]>ic.NO_ALTITUDE?{altitudeM:g[2]}:{}}));return m.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:m}]})}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 Jn{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 Xs(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"~"^(${Jn.KINDS})$"](${i})->.w;.w out tags geom;rel(bw.w)["route"~"^(${Jn.ROUTES})$"];out body;`;return Jn.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=Jn.ways(e,n);return s.length===0?[...t]:t.map(r=>{const a=r.points.map(v=>oe(v.lat,v.lng,n.lat,n.lng)),c=new Map,l=new Map,h=new Map;let u=0;const d=s.filter(v=>v.service===!!r.service);for(const v of Jn.samples(a)){u++;const M=Jn.waysAt(d,v);if(M.length===0)continue;const[w]=M;w.name&&c.set(w.name,(c.get(w.name)??0)+1),w.voltageV&&l.set(w.voltageV,(l.get(w.voltageV)??0)+1);for(const y of new Set(M.flatMap(b=>b.services)))h.set(y,(h.get(y)??0)+1)}const f=v=>[...v.entries()].sort((M,w)=>w[1]-M[1])[0]?.[0],p=r.name??f(c),m=r.voltageV??(r.electrification==="none"?void 0:f(l)),g=[...h.entries()].filter(([,v])=>v*4>=u).sort((v,M)=>M[1]-v[1]||v[0].localeCompare(M[0])).map(([v])=>v);return{...r,...p?{name:p}:{},...m?{voltageV:m}:{},...g.length>0?{services:g}:{}}})}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=Jn.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=Jn.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=Jn.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=>oe(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=Jn.SAMPLE_M/2;a<n;a+=Jn.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(Jn.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<=Jn.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 Ch{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 Xs(t)}async getRailways(t){const e=`${t.south},${t.west},${t.north},${t.east}`,i=`[out:json][timeout:25];way["railway"~"^(${Ch.KINDS.join("|")})$"](${e})->.w;.w out tags geom;rel(bw.w)["route"~"^(${Jn.ROUTES})$"];out body;`;return this.linesFrom(await this.client.query(i))}linesFrom(t){const e=[],i=Jn.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=Jn.voltageOf(r),l=Ch.kindOf(r),h=Number.parseInt((r.gauge??"").split(";")[0],10),u=Number.parseInt(r.tracks??"",10),d=Ch.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:Ch.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 ZL{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(!ic.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 mn{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=mn.key(t);let i=mn.asked.get(e)??mn.containing(t);if(i===void 0){const n=this.recalled(e,t);i={bounds:t,answer:n},mn.asked.set(e,i),n.catch(()=>mn.asked.delete(e))}return structuredClone(await i.answer)}static forget(){mn.asked.clear(),mn.failedAt=-1/0}static key(t){return`v${mn.FORMAT}/${[t.north,t.south,t.east,t.west].map(e=>e.toFixed(5)).join("/")}`}static containing(t){for(const e of mn.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 mn.openCache(),n=mn.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<mn.MAX_AGE_MS)return l;s=l}}}catch{}if(this.now()-mn.failedAt<mn.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(mn.failedAt=this.now(),s)return s;throw a}return i&&mn.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-mn.MAX_STORED)))await t.delete(s)}catch{}}static async openCache(){try{return typeof caches>"u"?void 0:await caches.open(mn.CACHE_NAME)}catch{return}}static request(t){const e=typeof location>"u"?"http://localhost":location.origin;return new Request(`${e}/__railways__/${encodeURIComponent(t)}`)}}const e1="https://ufoathome.org/railways/index.json";class Oh{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??Oh.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(`
|
|
6832
|
+
`);let e=Oh.shared.get(t);return e||(e=this.fetchFirstAvailable(),Oh.shared.set(t,e),e.then(i=>{i.length===0&&Oh.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.188.1")}`,e=typeof location>"u"?void 0:new URL("/railways/index.json",location.href).href;return(e&&e!==e1?[e,e1]:[e1]).map(i=>i+t)}}function i3(){return{elevation:n3(),imagery:s3(),roads:JL(),water:jL(),railways:QL()}}function n3(){return new XL(new Le,new QA)}function s3(){return new e3}function JL(){return new Ih({fallback:new KL(new ec,new Ko)})}function jL(){return new Dh({fallback:new Fs(new qL(new Sf,new Xc))})}function QL(){return new Oh({fallback:new mn(new ZL(new ic,new Ch))})}const tN=new Set,Pa="show-observer-map",La="hide-milestones",sl="minified";class Ve extends HTMLElement{static get observedAttributes(){return["src",Pa,La,sl]}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 Mi;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=Tm.create();issues=[];issueCheck=0;sightingAudio=new gx;liveSightingAudio;hearInto(t){t?(this.liveSightingAudio??=this.sightingAudio,this.sightingAudio=new gx(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>Ve.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");Ve.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 st(async()=>{const{VideoButton:s}=await import("./VideoButton-C62NkJrH.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)<Ve.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>=Mi.MAX_ZOOM,this.mapZoomOutButton.disabled=this.observerMapView.zoomFactor<=Mi.MIN_ZOOM,this.paintObserverMap(this.currentTime),this.scheduleObserverMapImagery()}scheduleObserverMapImagery(){this.observerMapImageryTimer===void 0&&(this.observerMapImageryTimer=setTimeout(()=>{this.observerMapImageryTimer=void 0,this.loadObserverMapImagery()},Ve.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=Mi.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>${AL}</style>${EL}`,this.shadow.appendChild(t.content.cloneNode(!0)),this.stageElement=this.shadow.getElementById("stage"),this.canvas=this.shadow.getElementById("canvas"),this.canvasRenderer=new xu(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 Wc(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===Pa&&this.applyObserverMapDefault(),t===La&&this.setMilestonesShown(!this.hasAttribute(La)),t===sl){const n=this.minified;this.stageElement.classList.toggle("minified",n),n&&e===null&&(this.muted=!0),this.updateStartState()}}get minified(){return this.hasAttribute(sl)}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(o3)))};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 Ar.recording(t)}get sightingData(){return gE(this.currentSighting)}set sightingData(t){const e=lr.recording(t);this.player.stop(),this.soundPreview=void 0,this.sightingAudio.silence(),this.currentSighting=JM(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 st(async()=>{const{default:r}=await import("./sightingSchema-Dk010uUD.js");return{default:r}},[],import.meta.url);n=new wr(s).issues(t)}catch{}i===this.issueCheck&&(this.issues=[...n,...e.loadIssues],xf.warn(this.issues,e.id),this.renderIssues(),this.dispatchEvent(new CustomEvent(eN,{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=xf.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=we.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)<Ve.TIME_SAID_EVERY_MS||(this.timeSaid=t,this.dispatchEvent(new CustomEvent(a3,{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"),Ve.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)),Ve.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?md(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=Ve.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=Ve.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 xu(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=Ve.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=us.windowEndingAt(t,this.currentSighting.exposure??0);if(e.ms<Ve.SHORTEST_VISIBLE_EXPOSURE_MS)return[t];const i=Math.min(Ve.MAX_EXPOSURE_STEPS,Math.max(2,Math.round(e.ms/Ve.SHORTEST_VISIBLE_EXPOSURE_MS))),n=Math.ceil(this.travelPxOver(e.fromMs,e.ms)/Ve.EXPOSURE_STEP_PX),s=Math.min(Ve.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=Ti.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:tN;this.canvasRenderer.setStarPoints(Ti.starPointsOf(this.sighting.instrument,Oe(this.sighting,t)?.fNumber));const n=(Oe(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?ar.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(hE(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 _L(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*Ve.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){Ve.icons.get(t)!==e&&(Ve.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},Ve.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(),Ve.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(Pa),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;Ve.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=iu.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=Mi.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?Mi.expand(t,Ve.OBSERVER_MAP_IMAGERY_AHEAD):t,n=Mi.IMAGERY_PX*(e?1+2*Ve.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:s3();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?Mi.expand(t,Ve.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=Ve.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=Oe(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},Ve.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?md(this.currentSighting.milestones):[]){const a=Oe(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?Aa.of(i,this.canvas.height,e.fovDeg).halfWidthAngleDeg(Ti.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,md(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??"",Ve.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=Oe(this.currentSighting,0);return e?.lat===void 0||e.lng===void 0?[]:this.currentSighting.decor.filter(i=>i.kind!=="crop").map(i=>{const n=Xr(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=Oe(this.currentSighting,this.currentTime),s=Aa.of(this.currentSighting.instrument,this.canvas.height,n?.fovDeg??60);return{x:-s.angleDegToRadiusPx(e),y:s.angleDegToRadiusPx(i)}}gaitAt(t){return hi.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=Ve.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)),Ve.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){Ve.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}Ve.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;Ve.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 es(Ks.preferencesFor(this))}saidTexts;async loadLocaleMessages(){const t=Mo(Ks.preferencesFor(this),yo);if(t===this.messagesLanguage)return;this.messagesLanguage=t;const e=await OT.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=lE(t);this.realDurationMs=e!==void 0&&e>0?e:void 0,this.realStartMs=t.time?J1(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 zo(t);const e=this.currentSighting.timeline.duration,i=e>0&&t<=e?t/e*this.realDurationMs:t;return this.canShowClockTime?wx(yx(this.realStartMs+i)):zo(i)}formatElapsedAt(t){const e=this.currentSighting.timeline.duration;return this.realDurationMs===void 0?zo(t):zo(e>0&&t<=e?t/e*this.realDurationMs:t)}formatRemaining(t){const e=this.currentSighting.timeline.duration;if(this.realDurationMs===void 0)return zo(Math.max(0,e-t));const i=e>0&&t<=e?t/e*this.realDurationMs:t;return zo(Math.max(0,this.realDurationMs-i))}formatEndOfTimeline(){return this.realDurationMs===void 0?zo(this.currentSighting.timeline.duration):this.canShowClockTime?wx(yx(this.realStartMs+this.realDurationMs)):zo(this.realDurationMs)}}function yx(o){const t=new Date(o);return{hour:t.getUTCHours(),minute:t.getUTCMinutes(),second:t.getUTCSeconds()}}function wx(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 zo(o){const t=Math.round(o/1e3),e=Math.floor(t/60),i=t%60;return`${e}:${String(i).padStart(2,"0")}`}const pM="rr0-ufo";function r3(){customElements.get(pM)||customElements.define(pM,Ve)}const a3="timechange",eN="recordingissues",o3="minifiedreset",iN=`
|
|
6833
6833
|
varying vec3 vDir;
|
|
6834
6834
|
varying vec3 vWorldDir;
|
|
6835
6835
|
|
|
@@ -7980,7 +7980,7 @@ float roadNoise(vec2 p) {
|
|
|
7980
7980
|
if (fromEdge < reach) discard;
|
|
7981
7981
|
}
|
|
7982
7982
|
#endif
|
|
7983
|
-
}`)},t.customProgramCacheKey=()=>i?"rr0-road-grain-verge":"rr0-road-grain"}resample(t){const e=[];for(let n=0;n<t.length-1;n++){const s=t[n],r=t[n+1],a=Math.hypot(r.x-s.x,r.z-s.z),c=Math.max(1,Math.ceil(a/this.stepM));for(let l=0;l<c;l++){const h=l/c;e.push({x:s.x+(r.x-s.x)*h,z:s.z+(r.z-s.z)*h})}}const i=t[t.length-1];return i&&e.push({x:i.x,z:i.z}),e}}class ra{static CELL_M=40;cells=new Map;constructor(t,e){e.forEach((i,n)=>{const s=t[n].widthM/2+.3;for(let r=1;r<i.length;r++){const a=i[r-1].x,c=i[r-1].z,l=i[r].x-a,h=i[r].z-c,u={way:n,ax:a,az:c,dx:l,dz:h,length2:l*l+h*h,reach:s},d=Math.floor((Math.min(a,i[r].x)-s)/ra.CELL_M),f=Math.floor((Math.max(a,i[r].x)+s)/ra.CELL_M),p=Math.floor((Math.min(c,i[r].z)-s)/ra.CELL_M),m=Math.floor((Math.max(c,i[r].z)+s)/ra.CELL_M);for(let g=d;g<=f;g++)for(let v=p;v<=m;v++){const M=ra.key(g,v),w=this.cells.get(M);w?w.push(u):this.cells.set(M,[u])}}})}static key(t,e){return(t+5e4)*100003+(e+5e4)}onAnotherCarriageway(t,e,i){const n=this.cells.get(ra.key(Math.floor(t/ra.CELL_M),Math.floor(e/ra.CELL_M)));if(!n)return!1;for(const s of n){if(s.way===i)continue;const r=s.length2===0?0:Math.max(0,Math.min(1,((t-s.ax)*s.dx+(e-s.az)*s.dz)/s.length2));if(Math.hypot(t-(s.ax+s.dx*r),e-(s.az+s.dz*r))<s.reach)return!0}return!1}}class Di{constructor(t,e=[]){this.lamps=e;for(const i of t){const n=Math.hypot(i.halfAlongM,i.halfAcrossM),s=Math.floor((i.x-n)/Di.CELL_M),r=Math.floor((i.x+n)/Di.CELL_M),a=Math.floor((i.z-n)/Di.CELL_M),c=Math.floor((i.z+n)/Di.CELL_M);for(let l=s;l<=r;l++)for(let h=a;h<=c;h++){const u=Di.key(l,h),d=this.cells.get(u);d?d.push(i):this.cells.set(u,[i])}}}static REACH_M=16;static NEAREST_M=1;static SAMPLES_M=[-3,0,3];static CELL_M=32;cells=new Map;across(t,e,i,n){const s=[],r=[];for(const a of Di.SAMPLES_M){const c=t+i*a,l=e+n*a,h=this.wall(c,l,-n,i),u=this.wall(c,l,n,-i);h!==void 0&&s.push(h),u!==void 0&&r.push(u)}return{leftM:Di.agreed(s),rightM:Di.agreed(r)}}lampsAlong(t){const e=[];for(const i of this.lamps){let n;for(let s=1;s<t.length;s++){const r=t[s-1].x,a=t[s-1].z,c=t[s].x-r,l=t[s].z-a,h=c*c+l*l;if(h===0)continue;const u=((i.x-r)*c+(i.z-a)*l)/h;if(u<0||u>1)continue;const d=Math.sqrt(h),f=((i.x-r)*-l+(i.z-a)*c)/d;(!n||Math.abs(f)<n.distance)&&(n={distance:Math.abs(f),lateral:f})}n&&n.distance<=Di.REACH_M&&e.push(n.lateral)}return e}near(t){if(t.length===0)return!1;if(this.lampsAlong(t).length>0)return!0;const e=Di.REACH_M+Math.max(...Di.SAMPLES_M.map(Math.abs)),i=t.map(s=>s.x),n=t.map(s=>s.z);for(let s=Math.floor((Math.min(...i)-e)/Di.CELL_M);s<=Math.floor((Math.max(...i)+e)/Di.CELL_M);s++)for(let r=Math.floor((Math.min(...n)-e)/Di.CELL_M);r<=Math.floor((Math.max(...n)+e)/Di.CELL_M);r++)if(this.cells.has(Di.key(s,r)))return!0;return!1}static agreed(t){if(!(t.length<2))return t.sort((e,i)=>e-i),t[Math.floor((t.length-1)/2)]}wall(t,e,i,n){let s;const r=new Set,a=Di.CELL_M/2;for(let c=0;c<=Di.REACH_M+a;c+=a){const l=this.cells.get(Di.key(Math.floor((t+i*c)/Di.CELL_M),Math.floor((e+n*c)/Di.CELL_M)));for(const h of l??[]){if(r.has(h))continue;r.add(h);const u=Di.hit(h,t,e,i,n);u!==void 0&&u<=Di.REACH_M&&(s===void 0||u<s)&&(s=u)}}return s!==void 0&&s>=Di.NEAREST_M?s:void 0}static hit(t,e,i,n,s){const r=e-t.x,a=i-t.z,c=[r*t.alongX+a*t.alongZ,-r*t.alongZ+a*t.alongX],l=[n*t.alongX+s*t.alongZ,-n*t.alongZ+s*t.alongX],h=[t.halfAlongM,t.halfAcrossM];let u=-1/0,d=1/0;for(let f=0;f<2;f++){if(Math.abs(l[f])<1e-9){if(Math.abs(c[f])>h[f])return;continue}const p=(-h[f]-c[f])/l[f],m=(h[f]-c[f])/l[f];u=Math.max(u,Math.min(p,m)),d=Math.min(d,Math.max(p,m))}if(!(d<u||d<0||u<0))return u}static key(t,e){return(t+5e4)*100003+(e+5e4)}}const LN=Nn.catalog({en:()=>st(()=>import("./BeamKindMessages_en-5RezNkyz.js"),[],import.meta.url).then(o=>o.beamKindMessages_en),fr:()=>st(()=>import("./BeamKindMessages_fr--28-36OI.js"),[],import.meta.url).then(o=>o.beamKindMessages_fr),es:()=>st(()=>import("./BeamKindMessages_es-B5vSWVjK.js"),[],import.meta.url).then(o=>o.beamKindMessages_es),it:()=>st(()=>import("./BeamKindMessages_it-X53Fuf2U.js"),[],import.meta.url).then(o=>o.beamKindMessages_it)}),Tx={key:"beams",messages:LN,pickKind:"beam",simulation:()=>st(async()=>{const{BeamSystem:o}=await import("./BeamSystem-
|
|
7983
|
+
}`)},t.customProgramCacheKey=()=>i?"rr0-road-grain-verge":"rr0-road-grain"}resample(t){const e=[];for(let n=0;n<t.length-1;n++){const s=t[n],r=t[n+1],a=Math.hypot(r.x-s.x,r.z-s.z),c=Math.max(1,Math.ceil(a/this.stepM));for(let l=0;l<c;l++){const h=l/c;e.push({x:s.x+(r.x-s.x)*h,z:s.z+(r.z-s.z)*h})}}const i=t[t.length-1];return i&&e.push({x:i.x,z:i.z}),e}}class ra{static CELL_M=40;cells=new Map;constructor(t,e){e.forEach((i,n)=>{const s=t[n].widthM/2+.3;for(let r=1;r<i.length;r++){const a=i[r-1].x,c=i[r-1].z,l=i[r].x-a,h=i[r].z-c,u={way:n,ax:a,az:c,dx:l,dz:h,length2:l*l+h*h,reach:s},d=Math.floor((Math.min(a,i[r].x)-s)/ra.CELL_M),f=Math.floor((Math.max(a,i[r].x)+s)/ra.CELL_M),p=Math.floor((Math.min(c,i[r].z)-s)/ra.CELL_M),m=Math.floor((Math.max(c,i[r].z)+s)/ra.CELL_M);for(let g=d;g<=f;g++)for(let v=p;v<=m;v++){const M=ra.key(g,v),w=this.cells.get(M);w?w.push(u):this.cells.set(M,[u])}}})}static key(t,e){return(t+5e4)*100003+(e+5e4)}onAnotherCarriageway(t,e,i){const n=this.cells.get(ra.key(Math.floor(t/ra.CELL_M),Math.floor(e/ra.CELL_M)));if(!n)return!1;for(const s of n){if(s.way===i)continue;const r=s.length2===0?0:Math.max(0,Math.min(1,((t-s.ax)*s.dx+(e-s.az)*s.dz)/s.length2));if(Math.hypot(t-(s.ax+s.dx*r),e-(s.az+s.dz*r))<s.reach)return!0}return!1}}class Di{constructor(t,e=[]){this.lamps=e;for(const i of t){const n=Math.hypot(i.halfAlongM,i.halfAcrossM),s=Math.floor((i.x-n)/Di.CELL_M),r=Math.floor((i.x+n)/Di.CELL_M),a=Math.floor((i.z-n)/Di.CELL_M),c=Math.floor((i.z+n)/Di.CELL_M);for(let l=s;l<=r;l++)for(let h=a;h<=c;h++){const u=Di.key(l,h),d=this.cells.get(u);d?d.push(i):this.cells.set(u,[i])}}}static REACH_M=16;static NEAREST_M=1;static SAMPLES_M=[-3,0,3];static CELL_M=32;cells=new Map;across(t,e,i,n){const s=[],r=[];for(const a of Di.SAMPLES_M){const c=t+i*a,l=e+n*a,h=this.wall(c,l,-n,i),u=this.wall(c,l,n,-i);h!==void 0&&s.push(h),u!==void 0&&r.push(u)}return{leftM:Di.agreed(s),rightM:Di.agreed(r)}}lampsAlong(t){const e=[];for(const i of this.lamps){let n;for(let s=1;s<t.length;s++){const r=t[s-1].x,a=t[s-1].z,c=t[s].x-r,l=t[s].z-a,h=c*c+l*l;if(h===0)continue;const u=((i.x-r)*c+(i.z-a)*l)/h;if(u<0||u>1)continue;const d=Math.sqrt(h),f=((i.x-r)*-l+(i.z-a)*c)/d;(!n||Math.abs(f)<n.distance)&&(n={distance:Math.abs(f),lateral:f})}n&&n.distance<=Di.REACH_M&&e.push(n.lateral)}return e}near(t){if(t.length===0)return!1;if(this.lampsAlong(t).length>0)return!0;const e=Di.REACH_M+Math.max(...Di.SAMPLES_M.map(Math.abs)),i=t.map(s=>s.x),n=t.map(s=>s.z);for(let s=Math.floor((Math.min(...i)-e)/Di.CELL_M);s<=Math.floor((Math.max(...i)+e)/Di.CELL_M);s++)for(let r=Math.floor((Math.min(...n)-e)/Di.CELL_M);r<=Math.floor((Math.max(...n)+e)/Di.CELL_M);r++)if(this.cells.has(Di.key(s,r)))return!0;return!1}static agreed(t){if(!(t.length<2))return t.sort((e,i)=>e-i),t[Math.floor((t.length-1)/2)]}wall(t,e,i,n){let s;const r=new Set,a=Di.CELL_M/2;for(let c=0;c<=Di.REACH_M+a;c+=a){const l=this.cells.get(Di.key(Math.floor((t+i*c)/Di.CELL_M),Math.floor((e+n*c)/Di.CELL_M)));for(const h of l??[]){if(r.has(h))continue;r.add(h);const u=Di.hit(h,t,e,i,n);u!==void 0&&u<=Di.REACH_M&&(s===void 0||u<s)&&(s=u)}}return s!==void 0&&s>=Di.NEAREST_M?s:void 0}static hit(t,e,i,n,s){const r=e-t.x,a=i-t.z,c=[r*t.alongX+a*t.alongZ,-r*t.alongZ+a*t.alongX],l=[n*t.alongX+s*t.alongZ,-n*t.alongZ+s*t.alongX],h=[t.halfAlongM,t.halfAcrossM];let u=-1/0,d=1/0;for(let f=0;f<2;f++){if(Math.abs(l[f])<1e-9){if(Math.abs(c[f])>h[f])return;continue}const p=(-h[f]-c[f])/l[f],m=(h[f]-c[f])/l[f];u=Math.max(u,Math.min(p,m)),d=Math.min(d,Math.max(p,m))}if(!(d<u||d<0||u<0))return u}static key(t,e){return(t+5e4)*100003+(e+5e4)}}const LN=Nn.catalog({en:()=>st(()=>import("./BeamKindMessages_en-5RezNkyz.js"),[],import.meta.url).then(o=>o.beamKindMessages_en),fr:()=>st(()=>import("./BeamKindMessages_fr--28-36OI.js"),[],import.meta.url).then(o=>o.beamKindMessages_fr),es:()=>st(()=>import("./BeamKindMessages_es-B5vSWVjK.js"),[],import.meta.url).then(o=>o.beamKindMessages_es),it:()=>st(()=>import("./BeamKindMessages_it-X53Fuf2U.js"),[],import.meta.url).then(o=>o.beamKindMessages_it)}),Tx={key:"beams",messages:LN,pickKind:"beam",simulation:()=>st(async()=>{const{BeamSystem:o}=await import("./BeamSystem-DTraCa17.js");return{BeamSystem:o}},__vite__mapDeps([10,11]),import.meta.url).then(({BeamSystem:o})=>()=>new o),editor:()=>st(async()=>{const{BeamEditor:o}=await import("./BeamEditor-B1s17C_I.js");return{BeamEditor:o}},__vite__mapDeps([12,11,1,5]),import.meta.url).then(({BeamEditor:o})=>(t,e,i)=>new o(t,e,i)),reachM:(o,t)=>de.beamReachFor(o,t),describe:(o,t,{texts:e,name:i,distance:n})=>({name:i,detail:e.detail.replace("{name}",i).replace("{wavelength}",String(o.wavelengthNm)).replace("{power}",o.powerW.toLocaleString()).replace("{distance}",n(t.distanceM??0))})},NN=Nn.catalog({en:()=>st(()=>import("./LaunchKindMessages_en-Batvnyw3.js"),[],import.meta.url).then(o=>o.launchKindMessages_en),fr:()=>st(()=>import("./LaunchKindMessages_fr-CoojboIk.js"),[],import.meta.url).then(o=>o.launchKindMessages_fr),es:()=>st(()=>import("./LaunchKindMessages_es-KYyQ9gbu.js"),[],import.meta.url).then(o=>o.launchKindMessages_es),it:()=>st(()=>import("./LaunchKindMessages_it-9HA3cjgP.js"),[],import.meta.url).then(o=>o.launchKindMessages_it)}),Rx={key:"launches",messages:NN,pickKind:"plume",simulation:()=>st(async()=>{const{LaunchSimulation:o}=await import("./LaunchSimulation-DgsYJUKz.js");return{LaunchSimulation:o}},__vite__mapDeps([13,14]),import.meta.url).then(({LaunchSimulation:o})=>()=>new o),editor:()=>st(async()=>{const{LaunchEditor:o}=await import("./LaunchEditor-CbQXmqaL.js");return{LaunchEditor:o}},__vite__mapDeps([15,1,14,5]),import.meta.url).then(({LaunchEditor:o})=>(t,e,i)=>new o(t,e,i)),describe:(o,t,{said:e,texts:i,distance:n})=>{const s=t.detail,r=e.read(o.title)||o.vehicle?.mission||i.name,a=s.release===void 0||s.release==="burn"?void 0:o.jets?.find((l,h)=>`jet:${l.id??h}`===s.release),c=s.release===void 0||s.release==="burn"?i.ascent:a?.kind==="vent"?i.vent:i.burn;return{name:r,detail:i.detail.replace("{name}",r).replace("{part}",c).replace("{distance}",n(s.centre.distanceKm*1e3)).replace("{height}",Math.round(s.heightKm??0).toLocaleString())}}},kN=Nn.catalog({en:()=>st(()=>import("./ReentryKindMessages_en-Cbgk3paQ.js"),[],import.meta.url).then(o=>o.reentryKindMessages_en),fr:()=>st(()=>import("./ReentryKindMessages_fr-D9r9x2bK.js"),[],import.meta.url).then(o=>o.reentryKindMessages_fr),es:()=>st(()=>import("./ReentryKindMessages_es-DwgJQanC.js"),[],import.meta.url).then(o=>o.reentryKindMessages_es),it:()=>st(()=>import("./ReentryKindMessages_it-DQ-J5YpD.js"),[],import.meta.url).then(o=>o.reentryKindMessages_it)}),Ix={key:"reentries",messages:kN,pickKind:"reentry",pickedAfterSatellites:!0,simulation:()=>st(async()=>{const{ReentrySimulation:o}=await import("./ReentrySimulation-BDnSb3zB.js");return{ReentrySimulation:o}},[],import.meta.url).then(({ReentrySimulation:o})=>()=>new o),editor:()=>st(async()=>{const{ReentryEditor:o}=await import("./ReentryEditor-DS0nJdBD.js");return{ReentryEditor:o}},__vite__mapDeps([16,1,5]),import.meta.url).then(({ReentryEditor:o})=>(t,e,i)=>new o(t,e,i)),describe:(o,t,{said:e,texts:i})=>{const n=t.detail,s=(o.title?e.read(o.title):"")||o.object?.name||i.name,r=n.view.head,a=6371,c=Math.sqrt(a**2+r.distanceKm**2+2*a*r.distanceKm*Math.sin(r.altitudeDeg*Math.PI/180))-a;return{name:(n.view.fragmentId.includes(".")?i.fragment:i.piece).replace("{name}",s).replace("{mag}",n.magnitude.toLocaleString(void 0,{maximumFractionDigits:1})).replace("{height}",Math.round(c).toLocaleString()).replace("{distance}",Math.round(r.distanceKm).toLocaleString())}}},xM=Ie.point("skyEvents").provide(Ie.BUILT_IN,[{id:Rx.key,name:"Launches",credit:"UFO@home",creditUrl:"https://ufoathome.org/docs/format/",create:()=>Rx},{id:Tx.key,name:"Beams",credit:"UFO@home",creditUrl:"https://ufoathome.org/docs/format/",create:()=>Tx},{id:Ix.key,name:"Fireballs",credit:"UFO@home",creditUrl:"https://ufoathome.org/docs/format/",create:()=>Ix}]);class vo{static built=new WeakMap;static of(t){let e=vo.built.get(t);return e||(e=t.create(),vo.built.set(t,e)),e}static eventsOf(t,e){const i=t?.[e.key];return Array.isArray(i)?i:[]}}const FN=18,UN=.55,zN=.5,BN=.4,HN=2,GN=`
|
|
7984
7984
|
attribute float aSpeed;
|
|
7985
7985
|
uniform float uTime;
|
|
7986
7986
|
uniform float uOverallSpeed;
|
|
@@ -9042,7 +9042,7 @@ ${l.fragmentShader.replace("#include <emissivemap_fragment>",`#include <emissive
|
|
|
9042
9042
|
gl_FragColor = vec4(around * wall, wall + (1.0 - wall) * uAbsorption);
|
|
9043
9043
|
}
|
|
9044
9044
|
`,transparent:!0,depthWrite:!1,side:Rn,fog:!1,blending:wl,blendSrc:bl,blendDst:df})}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=gs.DISC_INDEX[t],n=gs.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 zs{static SIZE=64;static MOVE_M=.01;holder=new Bi;cameras=[];faces=[];target=new je(zs.SIZE,zs.SIZE);white=new Ps({color:new ot(1,1,1),side:Rn});scene=new fr;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 ts(90,1,.02,20);n.up.copy(i),n.lookAt(e),this.holder.add(n),this.cameras.push(n),this.faces.push(new Uint8Array(zs.SIZE*zs.SIZE*4))}this.scene.background=new ot(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)<zs.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(zs.SIZE-1,Math.floor((s+1)/2*zs.SIZE)),c=Math.min(zs.SIZE-1,Math.floor((r+1)/2*zs.SIZE));return this.faces[e][(c*zs.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 gs))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),um.now(t,this.target,0,0,zs.SIZE,zs.SIZE,this.faces[r])}t.setRenderTarget(n),t.shadowMap.autoUpdate=s;for(const r of i)r.removeFromParent()}}const f1="https://ufoathome.org/models/index.json";class Cd{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??T8()}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(`
|
|
9045
|
-
`);let e=Cd.shared.get(t);return e||(e=this.fetchFirstAvailable(),Cd.shared.set(t,e),e.then(i=>{i.length===0&&Cd.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 T8(){const o=`?v=${encodeURIComponent("0.188.
|
|
9045
|
+
`);let e=Cd.shared.get(t);return e||(e=this.fetchFirstAvailable(),Cd.shared.set(t,e),e.then(i=>{i.length===0&&Cd.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 T8(){const o=`?v=${encodeURIComponent("0.188.1")}`,t=typeof location>"u"?void 0:new URL("/models/index.json",location.href).href;return(t&&t!==f1?[t,f1]:[f1]).map(e=>e+o)}const R8=Ie.point("decorModels").provide(Ie.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 Cd}]);class T3{constructor(t,e=R8){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=Ie.point("decorModels");for(const i of this.sources){const n=e.ownerOf(i.id);if(!(n===void 0||n===Ie.BUILT_IN)&&await this.catalogueOf(i).entry(t).catch(()=>{}))return n}}catalogueOf(t){return this.catalogues(),this.built.get(t)}}async function p1(o){const{GLTFLoader:t}=await st(async()=>{const{GLTFLoader:i}=await import("./GLTFLoader-61IhKnLS.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)}`)))})}class or{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 bs(2,2),new Ce({uniforms:{uColor:{value:new ot(0,0,0)},uRadius:{value:1}},vertexShader:or.VERTEX,fragmentShader:or.FRAGMENT,transparent:!0,depthWrite:!1,blending:On,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*or.MIN_ANGLE_RAD),r=or.FILL*Math.PI*s*s;return{radiusM:s,luminanceCdM2:i*Math.min(or.MAX_SHARE,e/r)}}static conserving(t){return Math.sqrt(t/(or.MAX_SHARE*or.FILL*Math.PI))}static VERTEX=`
|
|
9046
9046
|
uniform float uRadius;
|
|
9047
9047
|
varying vec2 vOffset;
|
|
9048
9048
|
void main() {
|
|
@@ -9684,7 +9684,7 @@ void main() {
|
|
|
9684
9684
|
gl_FragColor = vec4(color, tex.a * uOpacity * (1.0 - blur * 0.5));
|
|
9685
9685
|
}
|
|
9686
9686
|
`;function BS(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=oa(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 _c(e)}function Tk(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 _c(t)}function G1(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 gm{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:`${gm.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<gm.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 yi{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){yi.held.set(t,e),yi.loaded.delete(t),yi.generation++}static release(){if(yi.held.size!==0){for(const t of yi.held.keys())yi.loaded.delete(t);yi.held.clear(),yi.generation++}}static bytes(t,e=fetch.bind(globalThis)){const i=yi.held.get(t);if(i)return Promise.resolve(i);let n=yi.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())}),yi.loaded.set(t,n),n.catch(()=>yi.loaded.delete(t))),n}static async json(t){return JSON.parse(new TextDecoder().decode(await yi.bytes(t)))}static async zip(t){const e=await yi.bytes(t),{unzipSync:i}=await st(async()=>{const{unzipSync:n}=await import("./browser-CltifEM0.js");return{unzipSync:n}},[],import.meta.url);return i(e)}}class Fa{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}=oe(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)<=Fa.SAME_BOUNDS_DEG&&Math.abs(i.lng-e)<=Fa.SAME_BOUNDS_DEG)}static boundsOf(t){return Rd(t.lat,t.lng,t.radiusM)}static sameBounds(t,e){const i=(n,s)=>Math.abs(n-s)<=Fa.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 vm{static async encode(t){const{zipSync:e,strToU8:i}=await st(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]=vm.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:vm.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 $y{constructor(t){this.annex=t}async getElevationGrid(t,e,i){const{patches:n}=await this.annex,s=n.find(a=>Fa.sameBounds(Fa.boundsOf(a),t));if(s)return{...s.grid,heights:new Float32Array(s.grid.heights)};const r=n.find(a=>Fa.contains(a.grid.bounds,t));if(r)return $y.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 m=0;m<n;m++){const g=e.west+(e.east-e.west)*(n>1?m/(n-1):0),v=Math.min(t.width-1,Math.max(0,(g-t.bounds.west)/a*(t.width-1))),M=Math.floor(v),w=Math.min(t.width-1,M+1),y=v-M,b=(x,A)=>t.heights[x*t.width+A],S=b(d,M)*(1-y)+b(d,w)*y,E=b(f,M)*(1-y)+b(f,w)*y;r[l*n+m]=S*(1-p)+E*p}}return{heights:r,width:n,height:s,bounds:e}}}function N3(o,t){return o.find(e=>e.id===t)??o[0]}class Rk{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 t3(t,e,i=>this.tileUrlTemplate.replace("{z}",String(i.z)).replace("{y}",String(i.y)).replace("{x}",String(i.x)),this.fetchImpl)}}Ie.point("elevation").provide(Ie.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:()=>n3()},{id:"aws-terrarium",name:"AWS Terrain Tiles",credit:"© AWS Open Data (SRTM, ETOPO1)",creditUrl:"https://registry.opendata.aws/terrain-tiles/",create:()=>new QA}]);const k3=Ie.point("imagery").provide(Ie.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 e3({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 Rk({fetchImpl:o})}]);class HS{static async encode(t){const{zipSync:e,strToU8:i}=await st(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 $m{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,N3(k3,n.source).create($m.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 Ik{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,N3(k3,t.source).create($m.fetchFrom(t.tiles)).getImageryTexture(t.map.bounds,{width:t.map.pixels,height:t.map.pixels})})}}class Yy{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=>Fa.sameBounds(Fa.boundsOf(i),t))?.items??[]}}class Dk{constructor(t,e=""){this.attributionStated=e,this.reader=new Yy(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 Ck{constructor(t,e=""){this.attributionStated=e,this.reader=new Yy(t)}reader;get attribution(){return this.reader.attributionRead??this.attributionStated}getWater(t){return this.reader.itemsFor(t)}}class Ok{constructor(t,e=""){this.attributionStated=e,this.reader=new Yy(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 Mm{static providers(t,e,i){const n=f=>Zh.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=>yi.address(f.src,e),u=[],d={...i};if(s){const f=yi.zip(h(s)).then(p=>vm.decode(p));d.elevation=new $y(f),u.push(f.then(p=>p.patches))}if(r){const f=yi.zip(h(r)).then(p=>HS.decode(p));d.imagery=new $m(f,r.attribution),u.push(f.then(p=>p.patches))}if(a){const f=yi.json(h(a));d.roads=new Dk(f,a.attribution),u.push(f.then(p=>p.patches))}if(c){const f=yi.json(h(c));d.water=new Ck(f,c.attribution),u.push(f.then(p=>p.patches))}if(l){const f=yi.json(h(l));d.railways=new Ok(f,l.attribution),u.push(f.then(p=>p.patches))}return d.patches=new Fa(Mm.firstRead(u)),d}static map(t,e){const i=yi.zip(yi.address(t.src,e)).then(n=>HS.decode(n));return new Ik(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 fh="https://en.wikipedia.org/wiki/Kodachrome",Bc="https://en.wikipedia.org/wiki/Kodacolor_(still_photography)",Pk="https://en.wikipedia.org/wiki/Kodak_Tri-X",ph="https://en.wikipedia.org/wiki/List_of_discontinued_photographic_films",Ja="https://www.kodak.com/en/motion/page/chronology-of-film/",ir=(o,t)=>[{format:"135",from:o,to:t},{format:"120",from:o,to:t}],ja=(o,t)=>[{format:"35mm-cine",from:o,to:t}],GS=[{id:"kodacolor",name:"Kodacolor",kind:"negative",iso:32,formats:ir(1942,1963),source:Bc},{id:"kodacolor-x",name:"Kodacolor-X",kind:"negative",iso:80,formats:[...ir(1963,1974),{format:"126",from:1963,to:1974}],source:Bc},{id:"kodacolor-ii",name:"Kodacolor II",kind:"negative",iso:100,formats:[...ir(1973),{format:"126",from:1973}],source:Bc},{id:"kodacolor-400",name:"Kodacolor 400",kind:"negative",iso:400,formats:ir(1977),source:Bc},{id:"kodacolor-vr-100",name:"Kodacolor VR 100",kind:"negative",iso:100,formats:ir(1982,1986),source:Bc},{id:"kodacolor-vr-200",name:"Kodacolor VR 200",kind:"negative",iso:200,formats:[...ir(1982,1986),{format:"126",from:1982,to:1986}],source:Bc},{id:"kodacolor-vr-400",name:"Kodacolor VR 400",kind:"negative",iso:400,formats:ir(1982,1986),source:Bc},{id:"agfacolor-cn17",name:"Agfacolor CN17",kind:"negative",iso:40,formats:ir(1956,1971),source:ph},{id:"agfacolor-cns",name:"Agfacolor CNS",kind:"negative",iso:80,formats:[...ir(1968,1975),{format:"126",from:1968,to:1975}],source:ph},{id:"agfacolor-cns-2",name:"Agfacolor CNS 2",kind:"negative",iso:80,formats:[...ir(1971,1982),{format:"126",from:1971,to:1982}],source:ph},{id:"agfacolor-cns-400",name:"Agfacolor CNS 400",kind:"negative",iso:400,formats:ir(1978,1984),source:ph},{id:"kodachrome",name:"Kodachrome",kind:"slide",iso:10,formats:[{format:"135",from:1936,to:1962}],source:fh},{id:"kodachrome-ii",name:"Kodachrome II",kind:"slide",iso:25,formats:[{format:"135",from:1961,to:1974}],source:fh},{id:"kodachrome-x",name:"Kodachrome-X",kind:"slide",iso:64,formats:[{format:"135",from:1962,to:1974},{format:"126",from:1963,to:1974}],source:fh},{id:"kodachrome-25",name:"Kodachrome 25",kind:"slide",iso:25,formats:[{format:"135",from:1974,to:2001}],source:fh},{id:"kodachrome-64",name:"Kodachrome 64",kind:"slide",iso:64,formats:[{format:"135",from:1974,to:2009},{format:"126",from:1974,to:1993}],source:fh},{id:"kodachrome-200",name:"Kodachrome 200",kind:"slide",iso:200,formats:[{format:"135",from:1988,to:2007}],source:fh},{id:"agfachrome-ct18",name:"Agfachrome CT18",kind:"slide",iso:50,formats:[...ir(1958,1984),{format:"126",from:1958,to:1984}],source:ph},{id:"agfachrome-ct21",name:"Agfachrome CT21",kind:"slide",iso:100,formats:[{format:"135",from:1974,to:1984}],source:ph},{id:"tri-x",name:"Kodak Tri-X",kind:"negative",monochrome:!0,iso:400,formats:ir(1954),source:Pk},{id:"eastman-5247-1950",name:"Eastman Color Negative 5247 (1950)",kind:"negative",iso:16,formats:ja(1950,1952),source:Ja},{id:"eastman-5248-1952",name:"Eastman Color Negative 5248 (1952)",kind:"negative",iso:16,formats:ja(1952,1959),source:Ja},{id:"eastman-5250",name:"Eastman Color Negative 5250",kind:"negative",iso:32,formats:ja(1959,1962),source:Ja},{id:"eastman-5251",name:"Eastman Color Negative 5251",kind:"negative",iso:50,light:"tungsten",formats:ja(1962,1968),source:Ja},{id:"eastman-5254",name:"Eastman Color Negative 5254",kind:"negative",iso:100,light:"tungsten",formats:ja(1968,1976),source:Ja},{id:"eastman-5247-1974",name:"Eastman Color Negative II 5247 (1974)",kind:"negative",iso:64,formats:ja(1974,1983),source:Ja},{id:"eastman-5294",name:"Eastman High Speed Negative 5294",kind:"negative",iso:400,light:"tungsten",formats:ja(1983),source:Ja},{id:"eastman-5297",name:"Eastman High Speed Daylight 5297",kind:"negative",iso:250,formats:ja(1986,1997),source:Ja},{id:"eastman-5245",name:"Eastman EXR 50D 5245",kind:"negative",iso:50,formats:ja(1989),source:Ja}];class Af{static byId(t){return GS.find(e=>e.id===t)}static forInstrument(t){return GS.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 Af.forInstrument(t).filter(i=>Af.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 Hh{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)<=Hh.SAME_PLACE_DEG&&Math.abs(c.lng-t.lng)<=Hh.SAME_PLACE_DEG,a=n.answers.find(c=>s(c)&&Math.abs(c.startMs-e)<=Hh.SAME_TIME_MS&&Math.abs(c.endMs-i)<=Hh.SAME_TIME_MS)??n.answers.find(c=>c.startMs<=e&&c.endMs>=i);return a?a.answer:{status:"failed"}}}const V1=7.5,W1=9;class ca{static cache=new Map;static load(t){let e=ca.cache.get(t);return e||(e=fetch(t).then(i=>i.arrayBuffer()).then(i=>ca.parse(i)),ca.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 ca.load(t[0].url);const n=i.map(r=>r.url).join(`
|
|
9687
|
-
`);let s=ca.cache.get(n);return s||(s=Promise.all(i.map(r=>ca.load(r.url))).then(r=>r.reduce((a,c)=>ca.concat(a,c))),ca.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 li{constructor(t){if(this.heights=t,t.length!==li.WIDTH*li.HEIGHT)throw new Error(`a lunar relief has ${li.WIDTH*li.HEIGHT} samples, not ${t.length}`)}static SAMPLES_PER_DEGREE=16;static WIDTH=360*li.SAMPLES_PER_DEGREE;static HEIGHT=180*li.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=li.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 m=(f%li.WIDTH+li.WIDTH)%li.WIDTH,g=Math.min(li.HEIGHT-1,Math.max(0,p));return this.heights[g*li.WIDTH+m]},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)*li.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>=li.BAND_FROM_DEG&&n<=li.BAND_TO_DEG}static withBump(t,e,i,n=.4){const s=new Int8Array(li.WIDTH*li.HEIGHT),r=li.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)*li.WIDTH+(c+u+li.WIDTH)%li.WIDTH]=Math.round(i/li.UNIT_KM));return new li(s)}static smooth(){return new li(new Int8Array(li.WIDTH*li.HEIGHT))}}class Sr{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=Sr.SAMPLES){const{s,u:r,w:a,distanceKm:c}=Sr.frame(t,e),l=Math.PI/180,h=new Float32Array(n),u=li.REFERENCE_RADIUS_KM;for(let d=0;d<n;d++){const f=d/n*2*Math.PI,p=Math.cos(f),m=Math.sin(f),g=p*r[0]+m*a[0],v=p*r[1]+m*a[1],M=p*r[2]+m*a[2];let w=0;for(let y=Sr.SEARCH_FROM_DEG;y<=Sr.SEARCH_TO_DEG;y+=Sr.SEARCH_STEP_DEG){const b=Math.cos(y*l),S=Math.sin(y*l),E=b*s[0]+S*g,x=b*s[1]+S*v,A=b*s[2]+S*M,T=Math.asin(Math.max(-1,Math.min(1,A)))/l,I=Math.atan2(x,E)/l,D=u+i.heightKm(T,I),O=Math.atan2(D*S,c-D*b);O>w&&(w=O)}h[d]=w/l}return{radiusDeg:h,meanRadiusDeg:Math.asin(u/c)/l}}static frame(t,e){const i=new wc(e.lat,e.lng,e.elevationM),n=xo(t),s=rv(t,i,!1),r=new Ge(s.x-n.x,s.y-n.y,s.z-n.z,n.t),a=Math.hypot(r.x,r.y,r.z)*Sr.AU_KM,c=Sr.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=j5(t,i),f=ay(d),p=wo(d,new Ge(-r.x,-r.y,-r.z,n.t)),m=Math.asin(p.z/Math.hypot(p.x,p.y,p.z)),g=Math.atan2(-p.y,p.x),v=new Ge(-Math.sin(m)*Math.cos(g),Math.sin(m)*Math.sin(g),Math.cos(m),n.t),M=new Ge(-Math.sin(g),-Math.cos(g),0,n.t);return{s:u,u:c(wo(f,v)),w:c(wo(f,M)),distanceKm:a}}static surfacePoint(t,e,i,n){const{s,u:r,w:a}=Sr.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 m=Math.max(0,u-f),g=Math.max(m,t.radiusDeg[a]);p>g&&(r+=.5*(p*p-g*g))}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=pR(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 wc(e.lat,e.lng,e.elevationM),n=xo(t),s=rv(t,i,!1),r=Sr.bodyFixed(t)(new Ge(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 Ld{static cache=new Map;static load(t){let e=Ld.cache.get(t);return e||(e=Ld.fetchRelief(t).catch(()=>{}),Ld.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 li(new Int8Array(i.buffer,i.byteOffset,i.length))}}const Ky=Nn.catalog({en:()=>st(()=>import("./PerceptionMessages_en-B2O6DR64.js"),[],import.meta.url).then(o=>o.perceptionMessages_en),fr:()=>st(()=>import("./PerceptionMessages_fr-B59TnGBC.js"),[],import.meta.url).then(o=>o.perceptionMessages_fr),es:()=>st(()=>import("./PerceptionMessages_es-BmkP6OqD.js"),[],import.meta.url).then(o=>o.perceptionMessages_es),it:()=>st(()=>import("./PerceptionMessages_it-DPlxRmxu.js"),[],import.meta.url).then(o=>o.perceptionMessages_it)});class ym{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=ym.ID;messages=Ky;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=ym.MATRICES[String(t.type)];if(!e)return Js.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)=>Js.IDENTITY[a]+(r-Js.IDENTITY[a])*n),contrastGain:1}}}class qy{static ID="fatigue";id=qy.ID;messages=Ky;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 Js.NONE}}class $c{static ID="intoxication";static MEASURED_LEVEL=.08;static MEASURED_LOSS_DB=.9;static MAX_EFFECT_LEVEL=.1;static MAX_LEVEL=.5;id=$c.ID;messages=Ky;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:$c.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($c.MAX_EFFECT_LEVEL,Number.isFinite(e)?e:0));if(i===0)return Js.NONE;const n=i/$c.MEASURED_LEVEL*$c.MEASURED_LOSS_DB;return{colorMatrix:Js.IDENTITY,contrastGain:10**(-n/20)}}}const Lk=o=>o.sources[0]??o.id,Nk=Ie.point("perception").provide(Ie.BUILT_IN,[new ym,new $c,new qy].map(o=>({id:o.id,name:o.id,credit:Lk(o),creditUrl:"https://ufoathome.org/docs/sources/",create:()=>o})));class Yc{static built=new WeakMap;static get ALL(){return Nk.map(t=>{let e=Yc.built.get(t);return e||(e=t.create(),Yc.built.set(t,e)),e})}static byId(t){return Yc.ALL.find(e=>e.id===t)}static perceptionOf(t){return Yc.ALL.reduce((e,i)=>Js.combine(e,i.perceive(t?.[i.id]??{})),Js.NONE)}static compact(t){const e={},i=Yc.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 BM{names;constructor(t){this.names=t??Nn.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 fl.point(t,this.loaded?this.names.compassPoints:void 0)}towards(t){return fl.towards(t,this.loaded?this.names:void 0)}}class ua{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??ua.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(ua.kind(s,e).toLocaleLowerCase(n)),r.push(s.tracks>1?e.tracks.replace("{count}",String(s.tracks)):e.singleTrack);const a=s.voltageV?ua.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===ua.METRE_GAUGE_MM?r.push(e.metreGauge):s.gaugeMm!==ua.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?`${ua.name(s,e)}; ${r.join(", ")}`:`${ua.name(s,e)} — ${r.join(", ")}`}}class Nd{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=Nd.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===Nd.PUBLISHED_ORIGIN&&Nd.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 kk=new URL(""+new URL("rain-BvWZrB9h.ogg",import.meta.url).href,import.meta.url).href,Fk=new URL(""+new URL("wind-BjklexY7.ogg",import.meta.url).href,import.meta.url).href,VS=new URL(""+new URL("thunder-DA48qs_v.wav",import.meta.url).href,import.meta.url).href,Uk=20,zk=1;class hl{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};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}}dr.isLive(this.context)&&dr.unlock(this.context)}setAmbient(t,e,i){if(this.requested={type:t,intensity:e,windSpeed:i},!this.context)return;this.paused&&(t="none",e=0,i=0);const n=t==="rain"||t==="hail"?t:"none";if(this.ambientVolume=n==="hail"?Math.min(1,e*1.3+.2):n==="rain"?e:0,n!==this.ambientKey){this.ambientKey=n;const r=++this.ambientToken;this.stopSource(this.ambientSource,this.ambientGain),this.ambientSource=void 0,this.ambientGain=void 0,n!=="none"&&this.startLoop(kk,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/Uk,1);const s=i>zk;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(Fk,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)}playThunder(){!this.context||this.paused||this.playOneShot(VS,.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=hl.CRACK_CUTOFF_HZ;const r=e.createGain();r.gain.value=i,n.connect(s).connect(r).connect(this.output(e)),n.start(),this.playOneShot(VS,i,hl.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*hl.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/hl.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,dr.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()}}class no{constructor(t){this.elements=t;const{eccentricity:e,perihelionAu:i}=t,[n,s]=this.perifocalAxes(),r=Math.sqrt(no.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*no.stumpffC(n),a=e-i*i*i/Math.sqrt(no.SUN_GM_AU3_PER_DAY2)*no.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(no.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*no.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<no.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 F3=[{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 Bk{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 F3.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=gi(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=wo(K5(),new Ge(t.x,t.y,t.z,e)),r=wo(WE(e),s),a=rv(e,new wc(n.lat,n.lng,n.elevationM),!0),c=new Ge(r.x-a.x,r.y-a.y,r.z-a.z,e),l=Lm(c);return ly(l.ra,l.dec,i,n)}static earthPositionAt(t){return wo(Y5(),gc(gt.Earth,t))}static julianDayOf(t){return 2451545+gi(t).tt}static orbitOf(t){const e=this.orbits.get(t.id);if(e)return e;const i=new no(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 X1=[{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 WS{static UNIX_EPOCH_JD=24405875e-1;static aroundDate(t){const e=this.julianDayOf(t);return X1.filter(i=>this.magnitudeAt(i,e)!==void 0)}static appearancesAt(t,e){const i=this.julianDayOf(t),n=[];for(const s of X1){const r=this.magnitudeAt(s,i);r!==void 0&&n.push({outburst:s,position:Br.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 X1.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 Hk=[{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}],wm=6.5;class $1{static activeAt(t){return Hk.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=wm){if(e<=0)return 0;const s=wm-n;return t*Math.sin(e*Math.PI/180)/Math.pow(i,s)}static radiantPosition(t,e,i){return Br.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 ji{static QUIET_RATE_PER_HOUR=2;static APEX_RATE_PER_HOUR=8;static POPULATION_INDEX=3;static apexPosition(t,e){const i=gi(t),n=new Dm(0,A5(t).elon-90,1),s=wo(Q5(i),cy(n,i)),r=Lm(s);return ly(r.ra,r.dec,t,e)}static observedRatePerHour(t,e=wm){const i=ji.APEX_RATE_PER_HOUR*Math.max(0,Math.sin(t*Math.PI/180)),n=wm-e;return(ji.QUIET_RATE_PER_HOUR+i)/Math.pow(ji.POPULATION_INDEX,n)}static schedule(t){const e=new Vm(t.seed^1542469173);return Er.schedule(t).map(i=>{const n=ji.toCartesian({altitudeDeg:Math.asin(e.next())*180/Math.PI,azimuthDeg:e.between(0,360)}),s=i.fromRadiantDeg*Math.PI/180,r=ji.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:ji.toHorizontal(a),bearingDeg:ji.bearingFrom(a,n)}})}static turnAround(t,e){const[i,n]=ji.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]=ji.basisAround(t),s=t.x*e.x+t.y*e.y+t.z*e.z,r=ji.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=ji.normalise(ji.cross(t,e));return[i,ji.normalise(ji.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=ji.toCartesian(t.radiant??{altitudeDeg:90,azimuthDeg:0}),i=ji.turnAround(e,t.bearingDeg),n=t.fromRadiantDeg*Math.PI/180;return ji.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 XS="https://ufoathome.org/tle/index.json";class cs{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??cs.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(XS)||t.push(XS),t}static FIRST_SNAPSHOT="2021-02-22";async covers(t){const e=Date.parse(`${cs.FIRST_SNAPSHOT}T00:00:00Z`)-cs.MAX_ELEMENT_AGE_DAYS*cs.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)-cs.MAX_ELEMENT_AGE_DAYS*cs.DAY_MS&&t.getTime()<=Date.parse(n.to)+cs.MAX_ELEMENT_AGE_DAYS*cs.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*cs.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(m=>new Date(m*r).toISOString().slice(0,10)).filter(m=>l.has(m));if(h.length===0)return[];const[u,...d]=await Promise.all([this.json(new URL(`objects-${t}.json`,n).href),...h.map(m=>this.binary(new URL(`${t}/${m}.bin`,n).href))]),f=new Map;for(const m of d)for(const g of cs.decode(m,i.recordBytes)){const v=f.get(g.norad);(!v||Math.abs(g.epochMs-s)<Math.abs(v.epochMs-s))&&f.set(g.norad,g)}const p=[];for(const m of f.values()){const g=Math.abs(m.epochMs-s)/cs.DAY_MS;if(g>cs.MAX_ELEMENT_AGE_DAYS)continue;const v=u[m.norad]??{name:String(m.norad)};v.launch&&Date.parse(`${v.launch}T00:00:00Z`)>s||p.push({norad:m.norad,name:v.name,kind:t,launch:v.launch,stdMag:v.stdMag,elements:m,ageDays:g})}return p}coverageOf(t,e,i,n){const{from:s,to:r}=i.kinds[t],a=e.getTime(),c=cs.MAX_ELEMENT_AGE_DAYS*cs.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 Gk{lowerM;upperM;add(t,e){if(!(t<=0)){if(e.behindM!==void 0){const i=mi.sizeMAt(e.behindM,t);this.lowerM=this.lowerM===void 0?i:Math.max(this.lowerM,i)}if(e.inFrontM!==void 0){const i=mi.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:mi.distanceMAt(this.lowerM,t),maxM:this.upperM===void 0?void 0:mi.distanceMAt(this.upperM,t)}}clear(){this.lowerM=void 0,this.upperM=void 0}}class pl{static DEG_PER_SECOND=360/86164.0905;static degOver(t){return Math.max(0,t)*pl.DEG_PER_SECOND}static instants(t,e){if(!(e>0))return 1;const i=pl.degOver(t)/e;return i<1?1:Math.min(pl.MAX_INSTANTS,Math.max(2,Math.ceil(i)))}static MAX_INSTANTS=64}class Zn{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 pl.DEG_PER_SECOND*3600}static graspOf(t,e={}){if(t.visualAid)return Zn.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 Zn.EYE;const s=e.focalLengthMm??t.frame?.focalLengthMm??Zn.UNKNOWN_CAMERA_FOCAL_MM,r=s/n,a=Zn.resolutionArcsec(t,s,r);return{apertureMm:r,exposureSeconds:Math.min(i,Zn.trailLimitedSeconds(a)),resolutionArcsec:a}}static visualAidGrasp(t,e){const i=t.visualAid,n=Zn.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??Zn.UNKNOWN_CAMERA_DETAIL_UM)/1e3/e*Zn.ARCSEC_PER_RADIAN,r=1.22*Zn.WAVELENGTH_M/(i/1e3)*Zn.ARCSEC_PER_RADIAN;return Math.max(s,r)}static trailLimitedSeconds(t){return t/Zn.skyDriftArcsecPerSecond}static gainOverEye(t,e={}){const i=Zn.graspOf(t,e),n=Zn.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:Ti.focalLengthMmFor(t,e.fieldOfViewDeg);return Zn.gainOverEye(t,{fNumber:e.fNumber,focalLengthMm:i,exposureSeconds:e.exposureSeconds})}}const $S=111320,cd=Math.PI/180,Vk=1.02,Wk=1;class kd{static of(t,e){const i=kd.sightings(t,e);if(i.length<2)return;const n=kd.baseline(i);if(!n)return;const{near:s,far:r,closedM:a}=n,c=Math.tan(r.widthDeg/2*cd)===0?0:Math.tan(s.widthDeg/2*cd)/Math.tan(r.widthDeg/2*cd);if(c<Vk)return;const l=a/(c-1),h=mi.sizeMAt(l,s.widthDeg),u=i.map(d=>({t:d.t,m:mi.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=Oe(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=kd.closedAlongSight(i,n),[r,a,c]=s>=0?[n,i,s]:[i,n,-s];c<Wk||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)*$S,n=(e.lng-t.lng)*$S*Math.cos(t.lat*cd),s=(t.sightAzimuthDeg??0)*cd;return i*Math.cos(s)+n*Math.sin(s)}}class _s{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:_s.atLeastNearest(t.statedM),basis:"stated"};if(t.hypothesisM!==void 0&&t.hypothesisM>0)return{distanceM:_s.atLeastNearest(t.hypothesisM),basis:"hypothesis"};if(t.derivedM!==void 0&&t.derivedM>0)return{distanceM:_s.atLeastNearest(t.derivedM),basis:"derived"};const e=_s.largest(t.range?.minM,t.crossing?.behindM),i=_s.smallest(t.range?.maxM,t.crossing?.inFrontM),n=e===void 0?void 0:e*_s.MARGIN,s=i===void 0?void 0:i/_s.MARGIN;return n!==void 0&&s!==void 0?{distanceM:_s.atLeastNearest(n<=s?Math.sqrt(n*s):n),basis:"bounded"}:n!==void 0?{distanceM:_s.atLeastNearest(n),basis:"bounded"}:s!==void 0&&s<_s.CONVENTIONAL_M?{distanceM:_s.atLeastNearest(s),basis:"bounded"}:{distanceM:_s.CONVENTIONAL_M,basis:"conventional"}}static atLeastNearest(t){return Math.max(_s.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 m=Math.min(r.trainMs*p/Pt.TRAIN_POINTS,e-r.fromT),g=Pt.pieceAt(s,r,e-m);if(!g||(f.push(Pt.seenFrom(i,g)),m>=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,m=e.magnitudeDrop*(.5-.5*Math.log(1-.999*d(3))),g=e.dropBack*(.5+d(4)),v=a*(2*d(5)-1),M=c*(.5+d(6)),w=t.lagMsAt(f),y=t.acrossKmAt(f),b=t.belowKmAt(f),S=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=>w+1e3*Pt.lagOfBraking(2*g,S(E)),acrossKmAt:E=>y+v*S(E),belowKmAt:E=>b+M*S(E),magnitudeAt:E=>t.magnitudeAt(Math.min(E,t.untilT))+m,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 Gh{static typed=new Map;static of(t){return Gh.typed.get(t)}static set(t,e){const i=e.trim();i===""?Gh.typed.delete(t):Gh.typed.set(t,i)}static forget(){Gh.typed.clear()}}class Zy{static FIRST_DAY="2022-01-01";static mayCover(t){return new Date(t).toISOString().slice(0,10)>=Zy.FIRST_DAY}}class YS{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 Xk="Aircraft positions: adsb.lol feeders and contributors, Open Database License 1.0 (https://www.adsb.lol/docs/open-data/historical/)",$k="Aircraft positions: Flightradar24 API (https://fr24api.flightradar24.com/)",KS="flightradar24",Yk=Ie.point("aircraft").provide(Ie.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 YS(Xk,o=>Zy.mayCover(o),async()=>new(await st(async()=>{const{AdsbLolArchiveProvider:o}=await import("./AdsbLolArchiveProvider-BYOz5Wdl.js");return{AdsbLolArchiveProvider:o}},[],import.meta.url)).AdsbLolArchiveProvider)},{id:KS,name:"Flightradar24",credit:"Flightradar24, on your own subscription",creditUrl:"https://fr24api.flightradar24.com/",keyUrl:"https://fr24api.flightradar24.com/key-management",create:()=>new YS($k,o=>o>=Date.UTC(2016,4,11)&&o<=Date.now(),async()=>new(await st(async()=>{const{Flightradar24Provider:o}=await import("./Flightradar24Provider-RjrQ963H.js");return{Flightradar24Provider:o}},[],import.meta.url)).Flightradar24Provider({token:()=>Gh.of(KS)}))}]);class Hn{static MAX_GAP_S=60;static FT_TO_M=.3048;static EARTH_RADIUS_KM=6371;static seenFrom(t,e,i){const n=Hn.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:Hn.angularRate(t,e,i)}}static viewsAt(t,e,i){return t.flatMap(n=>Hn.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*Hn.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>Hn.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:Hn.wrapLongitude(s.lng+h*c),heightM:l*Hn.FT_TO_M},altitudeFt:l,groundSpeedKt:s.groundSpeedKt,trackDeg:s.trackDeg}}static angularRate(t,e,i){const n=Hn.positionAt(t,i-500),s=Hn.positionAt(t,i+500);if(!n||!s)return;const r=Hn.unit(Pt.seenFrom(e,n.geo)),a=Hn.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 zn{constructor(t){this.boxes=t;for(const i of t){const n=Math.hypot(i.halfWidthM,i.halfLengthM),[s,r]=[zn.cell(i.eastM-n),zn.cell(i.eastM+n)],[a,c]=[zn.cell(i.northM-n),zn.cell(i.northM+n)];for(let l=s;l<=r;l++)for(let h=a;h<=c;h++){const u=zn.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 zn([]);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(!zn.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 zn(i);return zn.last?.signature===n.signature?zn.last.obstacles:(zn.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(zn.key(zn.cell(t),zn.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 m=Math.sign(l)||1;return{box:r,nx:r.sin*m,ny:r.cos*m,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/zn.CELL_M)}static key(t,e){return(t+32768)*65536+(e+32768)}}const qS="https://ufoathome.org/fireballs/index.json";class ba{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??ba.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(qS)||t.push(qS),t}static mayCover(t){return new Date(t).toISOString().slice(0,7)>=ba.FIRST_MONTH}async credit(){return(await this.loadIndex())?.index.credit}async between(t,e){if(!ba.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=ba.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:ba.COLOR,trainS:ba.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}}r3();const U3="satellites-change",z3="fireballs-change",B3="references-change",H3="aircraft-change",Jy="rr0-confrontation",ZS="comet:",JS="nova:",Kk=new URL(""+new URL("lunar-relief.bin-ByThqxUn.gz",import.meta.url).href,import.meta.url).href,qk=new URL(""+new URL("stars-mag7.5-B43R6Wvg.bin",import.meta.url).href,import.meta.url).href,Zk=new URL(""+new URL("stars-mag7.5-9-BLV2tFmZ.bin",import.meta.url).href,import.meta.url).href,Jk=-18,jk={sun:{altitudeDeg:-3,azimuthDeg:180,magnitude:-26.7},moon:{altitudeDeg:-90,azimuthDeg:0,phase:{phaseFraction:0,illuminatedFraction:0},magnitude:-12.7},planets:[]},s0={lat:0,lng:0,elevationM:0,headingDeg:void 0,pitchDeg:0,fovDeg:60};class Me 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",Pa,La,sl]}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 cs;satellitesFor;satelliteRequest=0;satelliteStatus="none";satellites;satellitePassesMemo;static fireballArchive=new ba;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=Yk[0];static trafficRuntimeLoading;static trafficRuntime;static loadTrafficRuntime(){return Me.trafficRuntimeLoading??=st(()=>import("./trafficRuntime-CFgDqQz4.js"),__vite__mapDeps([19,18]),import.meta.url).then(t=>Me.trafficRuntime=t),Me.trafficRuntimeLoading.catch(()=>{Me.trafficRuntimeLoading=void 0}),Me.trafficRuntimeLoading}traffic;lastSun;get sunAltitudeDeg(){return this.sceneRenderer.sunAltitudeDeg??this.lastSun?.altitudeDeg}decorMemo;seatedMemo;starCatalogDepth=0;weatherAudio=new hl;vehicleAudio=new ex;aircraftAudio;vehicleHearing=new nm;decorAircraftHearing;bodyHearing;decorModelSounds=new Map;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>Me.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 S=r.ghostTooltip,E=S.drop[this.ufoElement.sighting.lens?.glass??"lens"];return{kind:"drop",name:E,detail:()=>S.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(S=>S.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,(S,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 S=this.naming.names.afterimageTooltip;return{kind:"afterimage",name:S.name,detail:()=>S.detail.replace("{name}",S.name)}}const f=this.pickDecorAt(t,e)??this.sceneRenderer.pickPeakAt(t,e),p=f?this.ufoElement.sighting.decor.find(S=>S.id===f):void 0;if(p){const S=this.said.read(p.title)||s.decorKind(p.kind);return{kind:"decor",id:p.id,name:S,detail:()=>this.decorTooltip(p,S)}}const m=this.sceneRenderer.pickRailwayAt(t,e);if(m){const S=r.railwayTooltip;return{kind:"railway",id:m.line.id,name:ua.name(m.line,S),detail:()=>ua.detail(m,S,E=>this.distanceText(E))}}const g=this.trafficTooltipAt(t,e);if(g)return{kind:"traffic",name:g};const v=this.skyEventPickAt(t,e,(S,E)=>E.inSky===!0&&!S.pickedAfterSatellites);if(v)return v;const M=this.sceneRenderer.pickSatelliteAt(t,e);if(M)return{kind:"satellite",name:r.satelliteTooltip.replace("{name}",M.name).replace("{mag}",M.magnitude.toLocaleString(void 0,{maximumFractionDigits:1})).replace("{height}",Math.round(M.heightKm).toLocaleString())};const w=this.skyEventPickAt(t,e,(S,E)=>E.inSky===!0&&S.pickedAfterSatellites===!0);if(w)return w;const y=this.sceneRenderer.pickOpticsAt(t,e);if(y){const S=r.opticsTooltips[y.id].replace("{angle}",String(Math.round(y.angleDeg??0)));return{kind:"optics",id:y.id,name:S.split(" — ")[0],detail:()=>S}}const b=this.sceneRenderer.pickStarAt(t,e);if(b){const S=b.star.mag,E=b.altitudeDeg,x=E<0?r.starTooltipBelow:r.starTooltip,A=s.star(b.star);return{kind:"star",name:A,detail:()=>x.replace("{name}",A).replace("{mag}",S.toLocaleString(void 0,{maximumFractionDigits:Math.abs(S)<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<Me.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=(ke.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 il(n=>{if(!ke.records(t.instrument)||!ke.falling(t.lens))return 0;const s=Cu(t,n*1e3),r=Oe(t,n*1e3);return(s.precipitationAmount??1)*ke.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=Mo(Ks.preferencesFor(this),yo);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?xM.map(d=>vo.of(d)).find(d=>d.key===s.kind):void 0,a=s&&r?vo.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=dt.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=k0.kinds(),i=this.obstaclesOf(this.ufoElement.sighting.decor);this.interpretationObstacles=i;const{interpretation:n,kindOf:s}=ki.expandWithKinds(t,e,{obstacles:i});if(this.interpretationAsked=t,this.interpretationShown=n,this.computedKinds=s,this.loadComputedKindTexts(),ki.loaded(t,e))return;const r=ki.load(t,e);this.sceneRenderer.holdUntil(r),r.then(()=>{this.interpretationAsked!==t||!ki.loaded(t,e)||(this.showInterpretation(t),this.ufoElement.refreshSoundControls(),this.updateAstronomy(this.lastTimeMs),this.ufoElement.repaintChrome())})}interpretationAsked;interpretationObstacles=zn.NONE;obstaclesMadeOf;obstaclesOf(t){return this.obstaclesMadeOf?.decor!==t&&(this.obstaclesMadeOf={decor:t,obstacles:zn.of(t,e=>dt.sizeOf(e))}),this.obstaclesMadeOf.obstacles}recomputeAmongNewDecor(){const t=this.interpretationAsked;!t||!ki.computes(t,k0.kinds())||this.obstaclesOf(this.ufoElement.sighting.decor).signature!==this.interpretationObstacles.signature&&(this.showInterpretation(t),this.ufoElement.refreshSoundControls())}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(ZS)?t.slice(ZS.length):void 0,i=e?F3.find(s=>s.id===e):void 0;if(i)return this.naming.comet(i);const n=t.startsWith(JS)?WS.byId(t.slice(JS.length)):void 0;return n?this.naming.nova(n):this.naming.body(t)}get naming(){return this.sceneNaming}sceneNaming=new BM;namesLanguage;ready=Promise.resolve();async loadSceneNames(){const t=Mo(Ks.preferencesFor(this),yo);if(t===this.namesLanguage)return;this.namesLanguage=t;const e=await xE(t);t===this.namesLanguage&&(this.applySceneNaming(new BM(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>Me.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=Oe(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+vn.thunderDelayMs(t)*this.ufoElement.playbackRate;return}this.thunderTimeoutId=window.setTimeout(()=>this.weatherAudio.playThunder(),vn.thunderDelayMs(t))}handleFirstInteraction=()=>{this.weatherAudio.resume(),this.vehicleAudio.resume(),this.aircraftAudio?.resume(),!this.interacted&&(this.interacted=!0,this.setWeather(Cu(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>=Me.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>${SL}</style>${xL}`,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 ht(this.sceneCanvas),this.sceneRenderer.onReferencesSettled=()=>this.dispatchEvent(new CustomEvent(B3));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 Nd(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(pM),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(o3,()=>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=>cf.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.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 Me.GESTURES)this.addEventListener(s,this.handleFirstInteraction,!0)}get said(){return this.saidTexts??=new es(Ks.preferencesFor(this))}saidTexts;traceLabelsFor;observerHeadlightsAt(t,e){const i=t.vehicle;return!i||!Qn.isRoad(i.kind)?void 0:{setting:vl.at(i.headlights??"auto",i.headlightKeyframes,e)??"auto",headingDeg:this.travelHeadingAt(t,e)}}travelHeadingAt(t,e){const i=Oe(t,e);if(!i)return 0;for(const n of[400,-400]){const s=Oe(t,e+n);if(!s||i.lat===void 0||i.lng===void 0||s.lat===void 0||s.lng===void 0)break;const r=oe(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=Ks.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(){Ie.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 Me.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(){Ie.changes.removeEventListener("change",this.onModulesChanged),this.visibilityObserver?.disconnect(),this.resizeObserver?.disconnect(),document.removeEventListener("fullscreenchange",this.handleFullscreenChange);for(const t of Me.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===Pa||t===La||t===sl)&&i!==e&&this.forwardPlayerAttributes(),t===sl&&this.stageElement.classList.toggle("minified",i!==null)}forwardPlayerAttributes(){for(const t of[Pa,La,sl]){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=Oe(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}=oe(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(Qn.transmission(this.ufoElement.sighting.vehicle)),this.weatherAudio.setAmbient(t.precipitationType,t.precipitationIntensity*(t.precipitationAmount??1),t.windSpeed)}pickCloudAt(t,e){return this.sceneRenderer.pickCloudAt(t,e)}cloudDirectionAt(t,e){return this.sceneRenderer.cloudDirectionAt(t,e)}pickDecorAt(t,e){return this.sceneRenderer.pickDecorAt(t,e)}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=Ar.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=lr.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=st(async()=>{const{ModuleSession:n}=await import("./ModuleSession-xCJtw_IT.js");return{ModuleSession:n}},[],import.meta.url).then(({ModuleSession:n})=>n.shared.require(t,e)).then(()=>this.sceneRenderer.setDecorModelProvider(new T3));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 gm(this,()=>document.createElement(_f))}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([st(()=>import("./VideoExport-B8ZhHNnd.js").then(a=>a.a),[],import.meta.url),st(()=>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([st(()=>import("./GenerativeKit-BmhvjjzB.js"),__vite__mapDeps([20,21,22]),import.meta.url),st(()=>import("./GenerativeKitMessages-CRj85mnY.js"),[],import.meta.url),st(()=>Promise.resolve().then(()=>AT),void 0,import.meta.url)]),a=Mo(Ks.preferencesFor(this),yo),[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 hl(t),this.vehicleAudio=new ex(t);const e=Me.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=Zh.isEmpty(t)?"none":`${JSON.stringify(t)}
|
|
9687
|
+
`);let s=ca.cache.get(n);return s||(s=Promise.all(i.map(r=>ca.load(r.url))).then(r=>r.reduce((a,c)=>ca.concat(a,c))),ca.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 li{constructor(t){if(this.heights=t,t.length!==li.WIDTH*li.HEIGHT)throw new Error(`a lunar relief has ${li.WIDTH*li.HEIGHT} samples, not ${t.length}`)}static SAMPLES_PER_DEGREE=16;static WIDTH=360*li.SAMPLES_PER_DEGREE;static HEIGHT=180*li.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=li.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 m=(f%li.WIDTH+li.WIDTH)%li.WIDTH,g=Math.min(li.HEIGHT-1,Math.max(0,p));return this.heights[g*li.WIDTH+m]},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)*li.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>=li.BAND_FROM_DEG&&n<=li.BAND_TO_DEG}static withBump(t,e,i,n=.4){const s=new Int8Array(li.WIDTH*li.HEIGHT),r=li.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)*li.WIDTH+(c+u+li.WIDTH)%li.WIDTH]=Math.round(i/li.UNIT_KM));return new li(s)}static smooth(){return new li(new Int8Array(li.WIDTH*li.HEIGHT))}}class Sr{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=Sr.SAMPLES){const{s,u:r,w:a,distanceKm:c}=Sr.frame(t,e),l=Math.PI/180,h=new Float32Array(n),u=li.REFERENCE_RADIUS_KM;for(let d=0;d<n;d++){const f=d/n*2*Math.PI,p=Math.cos(f),m=Math.sin(f),g=p*r[0]+m*a[0],v=p*r[1]+m*a[1],M=p*r[2]+m*a[2];let w=0;for(let y=Sr.SEARCH_FROM_DEG;y<=Sr.SEARCH_TO_DEG;y+=Sr.SEARCH_STEP_DEG){const b=Math.cos(y*l),S=Math.sin(y*l),E=b*s[0]+S*g,x=b*s[1]+S*v,A=b*s[2]+S*M,T=Math.asin(Math.max(-1,Math.min(1,A)))/l,I=Math.atan2(x,E)/l,D=u+i.heightKm(T,I),O=Math.atan2(D*S,c-D*b);O>w&&(w=O)}h[d]=w/l}return{radiusDeg:h,meanRadiusDeg:Math.asin(u/c)/l}}static frame(t,e){const i=new wc(e.lat,e.lng,e.elevationM),n=xo(t),s=rv(t,i,!1),r=new Ge(s.x-n.x,s.y-n.y,s.z-n.z,n.t),a=Math.hypot(r.x,r.y,r.z)*Sr.AU_KM,c=Sr.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=j5(t,i),f=ay(d),p=wo(d,new Ge(-r.x,-r.y,-r.z,n.t)),m=Math.asin(p.z/Math.hypot(p.x,p.y,p.z)),g=Math.atan2(-p.y,p.x),v=new Ge(-Math.sin(m)*Math.cos(g),Math.sin(m)*Math.sin(g),Math.cos(m),n.t),M=new Ge(-Math.sin(g),-Math.cos(g),0,n.t);return{s:u,u:c(wo(f,v)),w:c(wo(f,M)),distanceKm:a}}static surfacePoint(t,e,i,n){const{s,u:r,w:a}=Sr.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 m=Math.max(0,u-f),g=Math.max(m,t.radiusDeg[a]);p>g&&(r+=.5*(p*p-g*g))}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=pR(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 wc(e.lat,e.lng,e.elevationM),n=xo(t),s=rv(t,i,!1),r=Sr.bodyFixed(t)(new Ge(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 Ld{static cache=new Map;static load(t){let e=Ld.cache.get(t);return e||(e=Ld.fetchRelief(t).catch(()=>{}),Ld.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 li(new Int8Array(i.buffer,i.byteOffset,i.length))}}const Ky=Nn.catalog({en:()=>st(()=>import("./PerceptionMessages_en-B2O6DR64.js"),[],import.meta.url).then(o=>o.perceptionMessages_en),fr:()=>st(()=>import("./PerceptionMessages_fr-B59TnGBC.js"),[],import.meta.url).then(o=>o.perceptionMessages_fr),es:()=>st(()=>import("./PerceptionMessages_es-BmkP6OqD.js"),[],import.meta.url).then(o=>o.perceptionMessages_es),it:()=>st(()=>import("./PerceptionMessages_it-DPlxRmxu.js"),[],import.meta.url).then(o=>o.perceptionMessages_it)});class ym{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=ym.ID;messages=Ky;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=ym.MATRICES[String(t.type)];if(!e)return Js.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)=>Js.IDENTITY[a]+(r-Js.IDENTITY[a])*n),contrastGain:1}}}class qy{static ID="fatigue";id=qy.ID;messages=Ky;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 Js.NONE}}class $c{static ID="intoxication";static MEASURED_LEVEL=.08;static MEASURED_LOSS_DB=.9;static MAX_EFFECT_LEVEL=.1;static MAX_LEVEL=.5;id=$c.ID;messages=Ky;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:$c.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($c.MAX_EFFECT_LEVEL,Number.isFinite(e)?e:0));if(i===0)return Js.NONE;const n=i/$c.MEASURED_LEVEL*$c.MEASURED_LOSS_DB;return{colorMatrix:Js.IDENTITY,contrastGain:10**(-n/20)}}}const Lk=o=>o.sources[0]??o.id,Nk=Ie.point("perception").provide(Ie.BUILT_IN,[new ym,new $c,new qy].map(o=>({id:o.id,name:o.id,credit:Lk(o),creditUrl:"https://ufoathome.org/docs/sources/",create:()=>o})));class Yc{static built=new WeakMap;static get ALL(){return Nk.map(t=>{let e=Yc.built.get(t);return e||(e=t.create(),Yc.built.set(t,e)),e})}static byId(t){return Yc.ALL.find(e=>e.id===t)}static perceptionOf(t){return Yc.ALL.reduce((e,i)=>Js.combine(e,i.perceive(t?.[i.id]??{})),Js.NONE)}static compact(t){const e={},i=Yc.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 BM{names;constructor(t){this.names=t??Nn.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 fl.point(t,this.loaded?this.names.compassPoints:void 0)}towards(t){return fl.towards(t,this.loaded?this.names:void 0)}}class ua{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??ua.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(ua.kind(s,e).toLocaleLowerCase(n)),r.push(s.tracks>1?e.tracks.replace("{count}",String(s.tracks)):e.singleTrack);const a=s.voltageV?ua.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===ua.METRE_GAUGE_MM?r.push(e.metreGauge):s.gaugeMm!==ua.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?`${ua.name(s,e)}; ${r.join(", ")}`:`${ua.name(s,e)} — ${r.join(", ")}`}}class Nd{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=Nd.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===Nd.PUBLISHED_ORIGIN&&Nd.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 kk=new URL(""+new URL("rain-BvWZrB9h.ogg",import.meta.url).href,import.meta.url).href,Fk=new URL(""+new URL("wind-BjklexY7.ogg",import.meta.url).href,import.meta.url).href,VS=new URL(""+new URL("thunder-DA48qs_v.wav",import.meta.url).href,import.meta.url).href,Uk=20,zk=1;class hl{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};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}}dr.isLive(this.context)&&dr.unlock(this.context)}setAmbient(t,e,i){if(this.requested={type:t,intensity:e,windSpeed:i},!this.context)return;this.paused&&(t="none",e=0,i=0);const n=t==="rain"||t==="hail"?t:"none";if(this.ambientVolume=n==="hail"?Math.min(1,e*1.3+.2):n==="rain"?e:0,n!==this.ambientKey){this.ambientKey=n;const r=++this.ambientToken;this.stopSource(this.ambientSource,this.ambientGain),this.ambientSource=void 0,this.ambientGain=void 0,n!=="none"&&this.startLoop(kk,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/Uk,1);const s=i>zk;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(Fk,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)}playThunder(){!this.context||this.paused||this.playOneShot(VS,.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=hl.CRACK_CUTOFF_HZ;const r=e.createGain();r.gain.value=i,n.connect(s).connect(r).connect(this.output(e)),n.start(),this.playOneShot(VS,i,hl.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*hl.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/hl.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,dr.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()}}class no{constructor(t){this.elements=t;const{eccentricity:e,perihelionAu:i}=t,[n,s]=this.perifocalAxes(),r=Math.sqrt(no.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*no.stumpffC(n),a=e-i*i*i/Math.sqrt(no.SUN_GM_AU3_PER_DAY2)*no.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(no.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*no.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<no.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 F3=[{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 Bk{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 F3.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=gi(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=wo(K5(),new Ge(t.x,t.y,t.z,e)),r=wo(WE(e),s),a=rv(e,new wc(n.lat,n.lng,n.elevationM),!0),c=new Ge(r.x-a.x,r.y-a.y,r.z-a.z,e),l=Lm(c);return ly(l.ra,l.dec,i,n)}static earthPositionAt(t){return wo(Y5(),gc(gt.Earth,t))}static julianDayOf(t){return 2451545+gi(t).tt}static orbitOf(t){const e=this.orbits.get(t.id);if(e)return e;const i=new no(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 X1=[{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 WS{static UNIX_EPOCH_JD=24405875e-1;static aroundDate(t){const e=this.julianDayOf(t);return X1.filter(i=>this.magnitudeAt(i,e)!==void 0)}static appearancesAt(t,e){const i=this.julianDayOf(t),n=[];for(const s of X1){const r=this.magnitudeAt(s,i);r!==void 0&&n.push({outburst:s,position:Br.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 X1.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 Hk=[{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}],wm=6.5;class $1{static activeAt(t){return Hk.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=wm){if(e<=0)return 0;const s=wm-n;return t*Math.sin(e*Math.PI/180)/Math.pow(i,s)}static radiantPosition(t,e,i){return Br.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 ji{static QUIET_RATE_PER_HOUR=2;static APEX_RATE_PER_HOUR=8;static POPULATION_INDEX=3;static apexPosition(t,e){const i=gi(t),n=new Dm(0,A5(t).elon-90,1),s=wo(Q5(i),cy(n,i)),r=Lm(s);return ly(r.ra,r.dec,t,e)}static observedRatePerHour(t,e=wm){const i=ji.APEX_RATE_PER_HOUR*Math.max(0,Math.sin(t*Math.PI/180)),n=wm-e;return(ji.QUIET_RATE_PER_HOUR+i)/Math.pow(ji.POPULATION_INDEX,n)}static schedule(t){const e=new Vm(t.seed^1542469173);return Er.schedule(t).map(i=>{const n=ji.toCartesian({altitudeDeg:Math.asin(e.next())*180/Math.PI,azimuthDeg:e.between(0,360)}),s=i.fromRadiantDeg*Math.PI/180,r=ji.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:ji.toHorizontal(a),bearingDeg:ji.bearingFrom(a,n)}})}static turnAround(t,e){const[i,n]=ji.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]=ji.basisAround(t),s=t.x*e.x+t.y*e.y+t.z*e.z,r=ji.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=ji.normalise(ji.cross(t,e));return[i,ji.normalise(ji.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=ji.toCartesian(t.radiant??{altitudeDeg:90,azimuthDeg:0}),i=ji.turnAround(e,t.bearingDeg),n=t.fromRadiantDeg*Math.PI/180;return ji.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 XS="https://ufoathome.org/tle/index.json";class cs{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??cs.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(XS)||t.push(XS),t}static FIRST_SNAPSHOT="2021-02-22";async covers(t){const e=Date.parse(`${cs.FIRST_SNAPSHOT}T00:00:00Z`)-cs.MAX_ELEMENT_AGE_DAYS*cs.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)-cs.MAX_ELEMENT_AGE_DAYS*cs.DAY_MS&&t.getTime()<=Date.parse(n.to)+cs.MAX_ELEMENT_AGE_DAYS*cs.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*cs.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(m=>new Date(m*r).toISOString().slice(0,10)).filter(m=>l.has(m));if(h.length===0)return[];const[u,...d]=await Promise.all([this.json(new URL(`objects-${t}.json`,n).href),...h.map(m=>this.binary(new URL(`${t}/${m}.bin`,n).href))]),f=new Map;for(const m of d)for(const g of cs.decode(m,i.recordBytes)){const v=f.get(g.norad);(!v||Math.abs(g.epochMs-s)<Math.abs(v.epochMs-s))&&f.set(g.norad,g)}const p=[];for(const m of f.values()){const g=Math.abs(m.epochMs-s)/cs.DAY_MS;if(g>cs.MAX_ELEMENT_AGE_DAYS)continue;const v=u[m.norad]??{name:String(m.norad)};v.launch&&Date.parse(`${v.launch}T00:00:00Z`)>s||p.push({norad:m.norad,name:v.name,kind:t,launch:v.launch,stdMag:v.stdMag,elements:m,ageDays:g})}return p}coverageOf(t,e,i,n){const{from:s,to:r}=i.kinds[t],a=e.getTime(),c=cs.MAX_ELEMENT_AGE_DAYS*cs.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 Gk{lowerM;upperM;add(t,e){if(!(t<=0)){if(e.behindM!==void 0){const i=mi.sizeMAt(e.behindM,t);this.lowerM=this.lowerM===void 0?i:Math.max(this.lowerM,i)}if(e.inFrontM!==void 0){const i=mi.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:mi.distanceMAt(this.lowerM,t),maxM:this.upperM===void 0?void 0:mi.distanceMAt(this.upperM,t)}}clear(){this.lowerM=void 0,this.upperM=void 0}}class pl{static DEG_PER_SECOND=360/86164.0905;static degOver(t){return Math.max(0,t)*pl.DEG_PER_SECOND}static instants(t,e){if(!(e>0))return 1;const i=pl.degOver(t)/e;return i<1?1:Math.min(pl.MAX_INSTANTS,Math.max(2,Math.ceil(i)))}static MAX_INSTANTS=64}class Zn{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 pl.DEG_PER_SECOND*3600}static graspOf(t,e={}){if(t.visualAid)return Zn.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 Zn.EYE;const s=e.focalLengthMm??t.frame?.focalLengthMm??Zn.UNKNOWN_CAMERA_FOCAL_MM,r=s/n,a=Zn.resolutionArcsec(t,s,r);return{apertureMm:r,exposureSeconds:Math.min(i,Zn.trailLimitedSeconds(a)),resolutionArcsec:a}}static visualAidGrasp(t,e){const i=t.visualAid,n=Zn.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??Zn.UNKNOWN_CAMERA_DETAIL_UM)/1e3/e*Zn.ARCSEC_PER_RADIAN,r=1.22*Zn.WAVELENGTH_M/(i/1e3)*Zn.ARCSEC_PER_RADIAN;return Math.max(s,r)}static trailLimitedSeconds(t){return t/Zn.skyDriftArcsecPerSecond}static gainOverEye(t,e={}){const i=Zn.graspOf(t,e),n=Zn.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:Ti.focalLengthMmFor(t,e.fieldOfViewDeg);return Zn.gainOverEye(t,{fNumber:e.fNumber,focalLengthMm:i,exposureSeconds:e.exposureSeconds})}}const $S=111320,cd=Math.PI/180,Vk=1.02,Wk=1;class kd{static of(t,e){const i=kd.sightings(t,e);if(i.length<2)return;const n=kd.baseline(i);if(!n)return;const{near:s,far:r,closedM:a}=n,c=Math.tan(r.widthDeg/2*cd)===0?0:Math.tan(s.widthDeg/2*cd)/Math.tan(r.widthDeg/2*cd);if(c<Vk)return;const l=a/(c-1),h=mi.sizeMAt(l,s.widthDeg),u=i.map(d=>({t:d.t,m:mi.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=Oe(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=kd.closedAlongSight(i,n),[r,a,c]=s>=0?[n,i,s]:[i,n,-s];c<Wk||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)*$S,n=(e.lng-t.lng)*$S*Math.cos(t.lat*cd),s=(t.sightAzimuthDeg??0)*cd;return i*Math.cos(s)+n*Math.sin(s)}}class _s{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:_s.atLeastNearest(t.statedM),basis:"stated"};if(t.hypothesisM!==void 0&&t.hypothesisM>0)return{distanceM:_s.atLeastNearest(t.hypothesisM),basis:"hypothesis"};if(t.derivedM!==void 0&&t.derivedM>0)return{distanceM:_s.atLeastNearest(t.derivedM),basis:"derived"};const e=_s.largest(t.range?.minM,t.crossing?.behindM),i=_s.smallest(t.range?.maxM,t.crossing?.inFrontM),n=e===void 0?void 0:e*_s.MARGIN,s=i===void 0?void 0:i/_s.MARGIN;return n!==void 0&&s!==void 0?{distanceM:_s.atLeastNearest(n<=s?Math.sqrt(n*s):n),basis:"bounded"}:n!==void 0?{distanceM:_s.atLeastNearest(n),basis:"bounded"}:s!==void 0&&s<_s.CONVENTIONAL_M?{distanceM:_s.atLeastNearest(s),basis:"bounded"}:{distanceM:_s.CONVENTIONAL_M,basis:"conventional"}}static atLeastNearest(t){return Math.max(_s.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 m=Math.min(r.trainMs*p/Pt.TRAIN_POINTS,e-r.fromT),g=Pt.pieceAt(s,r,e-m);if(!g||(f.push(Pt.seenFrom(i,g)),m>=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,m=e.magnitudeDrop*(.5-.5*Math.log(1-.999*d(3))),g=e.dropBack*(.5+d(4)),v=a*(2*d(5)-1),M=c*(.5+d(6)),w=t.lagMsAt(f),y=t.acrossKmAt(f),b=t.belowKmAt(f),S=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=>w+1e3*Pt.lagOfBraking(2*g,S(E)),acrossKmAt:E=>y+v*S(E),belowKmAt:E=>b+M*S(E),magnitudeAt:E=>t.magnitudeAt(Math.min(E,t.untilT))+m,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 Gh{static typed=new Map;static of(t){return Gh.typed.get(t)}static set(t,e){const i=e.trim();i===""?Gh.typed.delete(t):Gh.typed.set(t,i)}static forget(){Gh.typed.clear()}}class Zy{static FIRST_DAY="2022-01-01";static mayCover(t){return new Date(t).toISOString().slice(0,10)>=Zy.FIRST_DAY}}class YS{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 Xk="Aircraft positions: adsb.lol feeders and contributors, Open Database License 1.0 (https://www.adsb.lol/docs/open-data/historical/)",$k="Aircraft positions: Flightradar24 API (https://fr24api.flightradar24.com/)",KS="flightradar24",Yk=Ie.point("aircraft").provide(Ie.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 YS(Xk,o=>Zy.mayCover(o),async()=>new(await st(async()=>{const{AdsbLolArchiveProvider:o}=await import("./AdsbLolArchiveProvider-BYOz5Wdl.js");return{AdsbLolArchiveProvider:o}},[],import.meta.url)).AdsbLolArchiveProvider)},{id:KS,name:"Flightradar24",credit:"Flightradar24, on your own subscription",creditUrl:"https://fr24api.flightradar24.com/",keyUrl:"https://fr24api.flightradar24.com/key-management",create:()=>new YS($k,o=>o>=Date.UTC(2016,4,11)&&o<=Date.now(),async()=>new(await st(async()=>{const{Flightradar24Provider:o}=await import("./Flightradar24Provider-RjrQ963H.js");return{Flightradar24Provider:o}},[],import.meta.url)).Flightradar24Provider({token:()=>Gh.of(KS)}))}]);class Hn{static MAX_GAP_S=60;static FT_TO_M=.3048;static EARTH_RADIUS_KM=6371;static seenFrom(t,e,i){const n=Hn.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:Hn.angularRate(t,e,i)}}static viewsAt(t,e,i){return t.flatMap(n=>Hn.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*Hn.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>Hn.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:Hn.wrapLongitude(s.lng+h*c),heightM:l*Hn.FT_TO_M},altitudeFt:l,groundSpeedKt:s.groundSpeedKt,trackDeg:s.trackDeg}}static angularRate(t,e,i){const n=Hn.positionAt(t,i-500),s=Hn.positionAt(t,i+500);if(!n||!s)return;const r=Hn.unit(Pt.seenFrom(e,n.geo)),a=Hn.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 zn{constructor(t){this.boxes=t;for(const i of t){const n=Math.hypot(i.halfWidthM,i.halfLengthM),[s,r]=[zn.cell(i.eastM-n),zn.cell(i.eastM+n)],[a,c]=[zn.cell(i.northM-n),zn.cell(i.northM+n)];for(let l=s;l<=r;l++)for(let h=a;h<=c;h++){const u=zn.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 zn([]);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(!zn.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 zn(i);return zn.last?.signature===n.signature?zn.last.obstacles:(zn.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(zn.key(zn.cell(t),zn.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 m=Math.sign(l)||1;return{box:r,nx:r.sin*m,ny:r.cos*m,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/zn.CELL_M)}static key(t,e){return(t+32768)*65536+(e+32768)}}const qS="https://ufoathome.org/fireballs/index.json";class ba{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??ba.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(qS)||t.push(qS),t}static mayCover(t){return new Date(t).toISOString().slice(0,7)>=ba.FIRST_MONTH}async credit(){return(await this.loadIndex())?.index.credit}async between(t,e){if(!ba.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=ba.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:ba.COLOR,trainS:ba.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}}r3();const U3="satellites-change",z3="fireballs-change",B3="references-change",H3="aircraft-change",Jy="rr0-confrontation",ZS="comet:",JS="nova:",Kk=new URL(""+new URL("lunar-relief.bin-ByThqxUn.gz",import.meta.url).href,import.meta.url).href,qk=new URL(""+new URL("stars-mag7.5-B43R6Wvg.bin",import.meta.url).href,import.meta.url).href,Zk=new URL(""+new URL("stars-mag7.5-9-BLV2tFmZ.bin",import.meta.url).href,import.meta.url).href,Jk=-18,jk={sun:{altitudeDeg:-3,azimuthDeg:180,magnitude:-26.7},moon:{altitudeDeg:-90,azimuthDeg:0,phase:{phaseFraction:0,illuminatedFraction:0},magnitude:-12.7},planets:[]},s0={lat:0,lng:0,elevationM:0,headingDeg:void 0,pitchDeg:0,fovDeg:60};class Me 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",Pa,La,sl]}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 cs;satellitesFor;satelliteRequest=0;satelliteStatus="none";satellites;satellitePassesMemo;static fireballArchive=new ba;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=Yk[0];static trafficRuntimeLoading;static trafficRuntime;static loadTrafficRuntime(){return Me.trafficRuntimeLoading??=st(()=>import("./trafficRuntime-CFgDqQz4.js"),__vite__mapDeps([19,18]),import.meta.url).then(t=>Me.trafficRuntime=t),Me.trafficRuntimeLoading.catch(()=>{Me.trafficRuntimeLoading=void 0}),Me.trafficRuntimeLoading}traffic;lastSun;get sunAltitudeDeg(){return this.sceneRenderer.sunAltitudeDeg??this.lastSun?.altitudeDeg}decorMemo;seatedMemo;starCatalogDepth=0;weatherAudio=new hl;vehicleAudio=new ex;aircraftAudio;vehicleHearing=new nm;decorAircraftHearing;bodyHearing;decorModelSounds=new Map;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>Me.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 S=r.ghostTooltip,E=S.drop[this.ufoElement.sighting.lens?.glass??"lens"];return{kind:"drop",name:E,detail:()=>S.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(S=>S.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,(S,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 S=this.naming.names.afterimageTooltip;return{kind:"afterimage",name:S.name,detail:()=>S.detail.replace("{name}",S.name)}}const f=this.pickDecorAt(t,e)??this.sceneRenderer.pickPeakAt(t,e),p=f?this.ufoElement.sighting.decor.find(S=>S.id===f):void 0;if(p){const S=this.said.read(p.title)||s.decorKind(p.kind);return{kind:"decor",id:p.id,name:S,detail:()=>this.decorTooltip(p,S)}}const m=this.sceneRenderer.pickRailwayAt(t,e);if(m){const S=r.railwayTooltip;return{kind:"railway",id:m.line.id,name:ua.name(m.line,S),detail:()=>ua.detail(m,S,E=>this.distanceText(E))}}const g=this.trafficTooltipAt(t,e);if(g)return{kind:"traffic",name:g};const v=this.skyEventPickAt(t,e,(S,E)=>E.inSky===!0&&!S.pickedAfterSatellites);if(v)return v;const M=this.sceneRenderer.pickSatelliteAt(t,e);if(M)return{kind:"satellite",name:r.satelliteTooltip.replace("{name}",M.name).replace("{mag}",M.magnitude.toLocaleString(void 0,{maximumFractionDigits:1})).replace("{height}",Math.round(M.heightKm).toLocaleString())};const w=this.skyEventPickAt(t,e,(S,E)=>E.inSky===!0&&S.pickedAfterSatellites===!0);if(w)return w;const y=this.sceneRenderer.pickOpticsAt(t,e);if(y){const S=r.opticsTooltips[y.id].replace("{angle}",String(Math.round(y.angleDeg??0)));return{kind:"optics",id:y.id,name:S.split(" — ")[0],detail:()=>S}}const b=this.sceneRenderer.pickStarAt(t,e);if(b){const S=b.star.mag,E=b.altitudeDeg,x=E<0?r.starTooltipBelow:r.starTooltip,A=s.star(b.star);return{kind:"star",name:A,detail:()=>x.replace("{name}",A).replace("{mag}",S.toLocaleString(void 0,{maximumFractionDigits:Math.abs(S)<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<Me.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=(ke.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 il(n=>{if(!ke.records(t.instrument)||!ke.falling(t.lens))return 0;const s=Cu(t,n*1e3),r=Oe(t,n*1e3);return(s.precipitationAmount??1)*ke.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=Mo(Ks.preferencesFor(this),yo);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?xM.map(d=>vo.of(d)).find(d=>d.key===s.kind):void 0,a=s&&r?vo.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=dt.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=k0.kinds(),i=this.obstaclesOf(this.ufoElement.sighting.decor);this.interpretationObstacles=i;const{interpretation:n,kindOf:s}=ki.expandWithKinds(t,e,{obstacles:i});if(this.interpretationAsked=t,this.interpretationShown=n,this.computedKinds=s,this.loadComputedKindTexts(),ki.loaded(t,e))return;const r=ki.load(t,e);this.sceneRenderer.holdUntil(r),r.then(()=>{this.interpretationAsked!==t||!ki.loaded(t,e)||(this.showInterpretation(t),this.ufoElement.refreshSoundControls(),this.updateAstronomy(this.lastTimeMs),this.ufoElement.repaintChrome())})}interpretationAsked;interpretationObstacles=zn.NONE;obstaclesMadeOf;obstaclesOf(t){return this.obstaclesMadeOf?.decor!==t&&(this.obstaclesMadeOf={decor:t,obstacles:zn.of(t,e=>dt.sizeOf(e))}),this.obstaclesMadeOf.obstacles}recomputeAmongNewDecor(){const t=this.interpretationAsked;!t||!ki.computes(t,k0.kinds())||this.obstaclesOf(this.ufoElement.sighting.decor).signature!==this.interpretationObstacles.signature&&(this.showInterpretation(t),this.ufoElement.refreshSoundControls())}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(ZS)?t.slice(ZS.length):void 0,i=e?F3.find(s=>s.id===e):void 0;if(i)return this.naming.comet(i);const n=t.startsWith(JS)?WS.byId(t.slice(JS.length)):void 0;return n?this.naming.nova(n):this.naming.body(t)}get naming(){return this.sceneNaming}sceneNaming=new BM;namesLanguage;ready=Promise.resolve();async loadSceneNames(){const t=Mo(Ks.preferencesFor(this),yo);if(t===this.namesLanguage)return;this.namesLanguage=t;const e=await xE(t);t===this.namesLanguage&&(this.applySceneNaming(new BM(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>Me.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=Oe(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+vn.thunderDelayMs(t)*this.ufoElement.playbackRate;return}this.thunderTimeoutId=window.setTimeout(()=>this.weatherAudio.playThunder(),vn.thunderDelayMs(t))}handleFirstInteraction=()=>{this.weatherAudio.resume(),this.vehicleAudio.resume(),this.aircraftAudio?.resume(),!this.interacted&&(this.interacted=!0,this.setWeather(Cu(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>=Me.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>${SL}</style>${xL}`,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 ht(this.sceneCanvas),this.sceneRenderer.onReferencesSettled=()=>this.dispatchEvent(new CustomEvent(B3));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 Nd(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(pM),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(o3,()=>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=>cf.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.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 Me.GESTURES)this.addEventListener(s,this.handleFirstInteraction,!0)}get said(){return this.saidTexts??=new es(Ks.preferencesFor(this))}saidTexts;traceLabelsFor;observerHeadlightsAt(t,e){const i=t.vehicle;return!i||!Qn.isRoad(i.kind)?void 0:{setting:vl.at(i.headlights??"auto",i.headlightKeyframes,e)??"auto",headingDeg:this.travelHeadingAt(t,e)}}travelHeadingAt(t,e){const i=Oe(t,e);if(!i)return 0;for(const n of[400,-400]){const s=Oe(t,e+n);if(!s||i.lat===void 0||i.lng===void 0||s.lat===void 0||s.lng===void 0)break;const r=oe(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=Ks.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(){Ie.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 Me.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(){Ie.changes.removeEventListener("change",this.onModulesChanged),this.visibilityObserver?.disconnect(),this.resizeObserver?.disconnect(),document.removeEventListener("fullscreenchange",this.handleFullscreenChange);for(const t of Me.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===Pa||t===La||t===sl)&&i!==e&&this.forwardPlayerAttributes(),t===sl&&this.stageElement.classList.toggle("minified",i!==null)}forwardPlayerAttributes(){for(const t of[Pa,La,sl]){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=Oe(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}=oe(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(Qn.transmission(this.ufoElement.sighting.vehicle)),this.weatherAudio.setAmbient(t.precipitationType,t.precipitationIntensity*(t.precipitationAmount??1),t.windSpeed)}pickCloudAt(t,e){return this.sceneRenderer.pickCloudAt(t,e)}cloudDirectionAt(t,e){return this.sceneRenderer.cloudDirectionAt(t,e)}pickDecorAt(t,e){return this.sceneRenderer.pickDecorAt(t,e)}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=Ar.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=lr.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=st(async()=>{const{ModuleSession:n}=await import("./ModuleSession-CDsk4Atg.js");return{ModuleSession:n}},[],import.meta.url).then(({ModuleSession:n})=>n.shared.require(t,e)).then(()=>this.sceneRenderer.setDecorModelProvider(new T3));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 gm(this,()=>document.createElement(_f))}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([st(()=>import("./VideoExport-B8ZhHNnd.js").then(a=>a.a),[],import.meta.url),st(()=>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([st(()=>import("./GenerativeKit-BmhvjjzB.js"),__vite__mapDeps([20,21,22]),import.meta.url),st(()=>import("./GenerativeKitMessages-CRj85mnY.js"),[],import.meta.url),st(()=>Promise.resolve().then(()=>AT),void 0,import.meta.url)]),a=Mo(Ks.preferencesFor(this),yo),[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 hl(t),this.vehicleAudio=new ex(t);const e=Me.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=Zh.isEmpty(t)?"none":`${JSON.stringify(t)}
|
|
9688
9688
|
${this.documentUrl??""}
|
|
9689
9689
|
${yi.generation}`;if(e===this.snapshotKey)return;const i=this.snapshotKey!==void 0&&this.traffic?.set!==void 0;this.snapshotKey=e,this.sceneRenderer.setTerrainProviders(Mm.providers(t,this.documentUrl,this.liveTerrainProviders??i3())),this.ufoElement.observerMapSnapshot=this.snapshotMapOf(t),i&&(this.traffic=void 0,this.decorMemo=void 0)}snapshotMapOf(t){const e=Zh.held(t,"map");if(!e)return;const i=`${yi.address(e.src,this.documentUrl)}
|
|
9690
9690
|
${yi.generation}`;return this.snapshotMap?.key!==i&&(this.snapshotMap={key:i,imagery:Mm.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=mi.CANVAS_HEIGHT_PX,i=Ti.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:V1,url:this.getAttribute("star-catalog-src")??qk},{magnitudeLimit:W1,url:this.getAttribute("deep-star-catalog-src")??Zk}],e=this.instrumentReach(),i=++this.starCatalogRequest;this.starCatalogDepth=e>V1?W1:V1;const n=await ca.upTo(t,e);i===this.starCatalogRequest&&(this.starCatalog=n,this.sceneRenderer.compileNextFrameOffThread(),this.updateAstronomy(this.lastTimeMs))}ensureStarsDeepEnough(){!this.starCatalog||this.starCatalogDepth>=W1||this.instrumentReach()<=this.starCatalogDepth||this.loadStars()}instrumentReach(){const t=this.ufoElement.sighting,e=Zn.gainFor(t.instrument,{fNumber:Oe(t,0)?.fNumber,fieldOfViewDeg:bn.fovOf(t,0),exposureSeconds:t.exposure});return b0(Jk,e)}updateAstronomy(t){this.ensureStarsDeepEnough(),this.applySceneAt(t);const e=us.windowEndingAt(t,this.exposureSeconds()),i=e.seconds,n=this.degreesPerPixelAt(t),s=pl.instants(i,n),r=Math.max(s,this.ufoElement.exposureTimes(t).length,us.instants(this.decorWithTraffic(this.ufoElement.sighting),Oe(this.ufoElement.sighting,t)?.elevationM??0,e.fromMs,i,n),us.bodyInstants(this.interpretationShown?.bodies??[],Oe(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:bn.fovOf(this.ufoElement.sighting,t)/e}roadGradeAt(t,e){return t.observerTrack.allKeyframes.length<2?0:Rh.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(Cu(i,t)),this.sceneRenderer.setInstrument(i.instrument,Oe(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??Me.NO_PRESENCE),this.sceneRenderer.setDecorSunlight(this.trafficSunlight(t)),this.sceneRenderer.setContrails(this.traffic?.contrails??Me.NO_CONTRAILS),this.sceneRenderer.setContrailSunlight(this.contrailSunlight(t));const n=Oe(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=Oe(i,0),r=mh(i,0),a=so(i.event.time??{},n?.lng??s0.lng,i.event.utcOffsetHours),c=i.weatherSource!==void 0&&a?wL(a):void 0,l=Object.fromEntries(I0(mh(i,t)).map(O=>[O.id,rx(t,i.weatherTrack,r,s,n,O.id,O.instances?.length?void 0:c)]));this.sceneRenderer.setCloudOffset(rx(t,i.weatherTrack,r,s,n,void 0,c),l);const h=e?.viewAt!==void 0?Oe(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)}:s0),this.sceneRenderer.setLensOptics(this.lensOpticsAt(t)),this.sceneRenderer.setInstrumentGain(Zn.gainFor(i.instrument,{fNumber:n?.fNumber,fieldOfViewDeg:bn.fovOf(i,t),exposureSeconds:i.exposure}),i.instrument.detailUm!==void 0,Vr.byId(n?.filter).opticalDensity),this.sceneRenderer.setMedium(Af.mediumOf(i.instrument.medium,Af.byId(i.film)),i.exposure,n?.fNumber??i.instrument.fNumber,i.iso,i.metering),this.sceneRenderer.setLensGhosts(ke.optics(i.instrument,n?.fNumber??i.instrument.fNumber,i.lens,this.glassWettingOf(i).stateAt(t/1e3),t)),this.sceneRenderer.setPerception(Yc.perceptionOf(i.account?.observerPerception)),this.sceneRenderer.setGait(hi.bodyAt(i,t,this.ufoElement.steadyBody)),this.sceneRenderer.updateDecorAnchoring(Oe(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??s0.lat,f=n?.lng??s0.lng,p=so(i.event.time??{},f,i.event.utcOffsetHours),m={lat:d,lng:f,elevationM:this.altitudeOf(n)};this.pushSatellitesAt(p,t,m),this.ensureFireballs(p);const g=this.skyEventsOf(i),v=g?.reentries??[];this.hearDetonations(v,t,{lat:d,lng:f,heightM:m.elevationM},e!==void 0);const M=v.filter(O=>Pt.mayDazzle(O));if(this.sceneRenderer.setRetinaHistory(M.length===0?void 0:O=>{const N=Oe(i,O),P={lat:N?.lat??d,lng:N?.lng??f,heightM:N?this.altitudeOf(N):m.elevationM};return{views:Pt.viewsAt(M,O,P),pose:N}},i),this.skyEventsStartDate=p,this.sceneRenderer.setSkyEvents(g,!1,p),g&&this.loadSkyEventTexts(xM.map(O=>vo.of(O)).filter(O=>vo.eventsOf(g,O).length>0&&!this.skyEventTexts.has(O))),e&&!e.sky)return;if(this.sceneRenderer.setSkyUnknown(!p),!p){this.sceneRenderer.setAstronomy(jk);return}const w=new Date(p.getTime()+t),y=Math.max(1,Math.round(.25*this.degreesPerPixelAt(t)/pl.DEG_PER_SECOND*1e3)),b=Math.max(1e-8,this.degreesPerPixelAt(t)*.1),S=`${Math.floor(w.getTime()/y)}|${Math.round(d/b)}|${Math.round(f/b)}|${Math.round(m.elevationM)}|${this.starCatalog?this.starCatalogDepth:0}`;if(S===this.lastSkyKey){this.sceneRenderer.render();return}this.lastSkyKey=S;const E=Ah("Sun",w,m),x=Ah("Moon",w,m);let A=on.separationOf(E,x)<1?on.viewAt(w,m):void 0;if(A){const O=on.offsetOf(E,x,A.separationDeg);if(A.obscuration>Me.LIMB_FROM_OBSCURATION){const N=this.limbFor(w,m);N&&(A={...A,obscuration:1-Sr.uncoveredFraction(N,A.sunRadiusDeg,O),limb:N})}A={...A,horizonShare:on.horizonShare(A,O,E.altitudeDeg,E.azimuthDeg,wa.distanceKm(w,m))}}const T={...E,magnitude:hg("Sun",w)-2.5*Math.log10(on.beamFraction(A))};this.lastSun={altitudeDeg:T.altitudeDeg,azimuthDeg:T.azimuthDeg};const I={...x,phase:gR(w),magnitude:hg("Moon",w),radiusDeg:wa.apparentRadiusDeg(w,m)},D=mR.map(O=>({body:O,position:Ah(O,w,m),magnitude:hg(O,w)}));this.sceneRenderer.setAstronomy({sun:T,moon:I,planets:D,comet:this.cometAt(w,m),novae:WS.appearancesAt(w,m).map(({outburst:O,position:N,magnitude:P})=>({id:O.id,position:N,magnitude:P})),stars:this.starCatalog?{catalog:this.starCatalog,date:w,observer:m}:void 0,frame:{date:w,observer:m},localHour:((w.getUTCHours()+w.getUTCMinutes()/60+(i.event.utcOffsetHours??Math.round(f/15)))%24+24)%24,eclipse:A}),this.ufoElement.setSunAltitude(T.altitudeDeg)}static LIMB_FROM_OBSCURATION=.98;limbRelief;limbRequested=!1;limbCache;limbFor(t,e){if(!this.limbRelief){this.limbRequested||(this.limbRequested=!0,Ld.load(Kk).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=Sr.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=n===void 0?"":`${n}+${i}`;if(this.fireballs?.key===s)return;if(n===void 0||!ba.mayCover(n+i)){this.fireballs={key:s,status:"outside",reentries:[]};return}const r={key:s,status:"loading",reentries:[]};this.fireballs=r,Me.fireballArchive.between(n,n+i).then(a=>{r.status=a?"ready":"unavailable",r.records=a??[],r.reentries=r.records.map(c=>ba.asReentry(c,n)),!(this.fireballs!==r||!this.isConnected)&&(this.dispatchEvent(new CustomEvent(z3)),r.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=iw(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=iw(r,e);return{...r,observerSide:a.side,observerFacing:a.facing}});return this.seatedMemo={base:t,seats:i,seated:s},s}ensureTraffic(t){const e=Oe(t,0),i=e?.lng===void 0?void 0:so(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(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=Me.aircraftProviders.get(this.aircraftSource.id);if(a||Me.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=Hn.MAX_GAP_S*1e3,u=Me.SOUND_LOOKBACK_MS,d={lat:e.lat,lng:e.lng,elevationM:this.altitudeOf(e)},f=(p,m)=>p.TrafficDecor.from(c.tracks??[],l,s,p.TrafficDecor.MAX_OBJECTS,{models:m,sunElevationAt:g=>this.sunElevationAt(g,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 m;try{m=await Me.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(m),this.startAircraftSound(c,m),this.announceTraffic(),this.describeTraffic(a,c,m,f),c.set.shown>0&&(this.readUpperAir(c,m,s-u,s+n+h),this.readTrailTraffic(a,c,m,l,s-Me.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?Hn.positionAt(c,i.startMs+t):void 0;l&&e.set(r,{heightM:l.geo.heightM,sunElevationDeg:Ds.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 Me.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=Me.trafficRuntime;if(!n)return;const s=e.descriptions?.get(Qe.keyOf(i)),r=Oe(this.ufoElement.sighting,this.lastTimeMs),a={lat:e.observer.lat,lng:e.observer.lng,heightM:this.altitudeOf(r)},c=n.AmbientNoise.dbA(Cu(this.ufoElement.sighting,this.lastTimeMs)),l=n.TrafficInfos.at(i,s,a,e.startMs+this.lastTimeMs,{ambientDbA:c}),h=l&&this.contrailAt(t,this.lastTimeMs);return l&&h?{...l,contrail:h}:l}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){!t.set||!t.observer||(t.audible=e.TrafficSound.candidates(t.set.flights,t.descriptions??new Map,Qe.keyOf,{...t.observer,heightM:this.sceneRenderer.groundAltitudeM},{ambientDbA:e.AmbientNoise.BASE_DB_A}))}pushAircraftSound(t,e){this.startDecorAircraftSound(t),this.startBodySound(),this.startRideSound(t);const i=this.aircraftAudio;if(!i)return;const n=Me.trafficRuntime;if(!n){i.setVoices([]);return}const s=Oe(t,e),r=Cu(t,e),a={ambientDbA:n.AmbientNoise.dbA(r),referenceAmplitude:n.AmbientNoise.referenceAmplitude(r)},c=t.vehicle,l=c?n.CabinHearing.voice(c,a):void 0,h={...a,ambientDbA:Math.max(a.ambientDbA,l?.levelDbA??0),...c?{throughDb:Qn.insulationDb(c)}:{}},u=this.trafficVoices(e,s,h,n),d=t.event.place?.[0],f={lat:s?.lat??d?.lat,lng:s?.lng??d?.lng};f.lat!==void 0&&f.lng!==void 0&&(this.decorAircraftHearing??=new n.DecorAircraftHearing,u.push(...this.decorAircraftHearing.voices(t,e,{lat:f.lat,lng:f.lng,heightM:s?.elevationM??0},h,p=>this.decorModelSounds.get(p.model?.id??""))),u.push(...this.bodyVoices(t,e,h,n)),l&&u.push(l),u.sort((p,m)=>m.levelDbA-p.levelDbA),u.length=Math.min(u.length,4)),i.setVoices(u,s?.headingDeg??0)}startRideSound(t){this.aircraftAudio||Qn.aircraftOf(t.vehicle)===void 0||(Me.trafficRuntime?this.aircraftAudio=this.newAircraftAudio(Me.trafficRuntime):Me.loadTrafficRuntime().catch(()=>{}))}startBodySound(){this.aircraftAudio||!this.interpretationShown?.bodies.some(t=>t.sound)||(Me.trafficRuntime?this.aircraftAudio=this.newAircraftAudio(Me.trafficRuntime):Me.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=>Ct.eyeOf(t,f,a),l=c(e);if(!l)return[];const h=new Map,u=(f,p)=>{let m=h.get(f.id);return m||h.set(f.id,m=new Ct(f,a,c)),m.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,Qe.keyOf,a,s.startMs+t,i)}startDecorAircraftSound(t){const e=t.decor.filter(i=>i.kind==="aircraft"&&i.track?.some(n=>(n.altitudeM??0)>0));if(e.length!==0){for(const i of e){const n=i.model?.id;!n||i.model?.url!==void 0||this.decorModelSounds.has(n)||(this.decorModelSounds.set(n,void 0),this.sceneRenderer.entryOfDecorModel(n).then(s=>{this.decorModelSounds.set(n,s?.parameters?.sound),this.ufoElement.refreshSoundControls()}))}if(this.aircraftAudio||Me.trafficRuntime){!this.aircraftAudio&&Me.trafficRuntime&&(this.aircraftAudio=this.newAircraftAudio(Me.trafficRuntime));return}Me.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"&&cf.flies(t)).map(t=>{const e=this.sceneRenderer.decorSkyPoint(t.id);return{key:Qe.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=>Qe.keyOf(a))),s=t.nearestPassKm??=new Map(t.tracks.map(a=>[Qe.keyOf(a),Math.min(...a.points.map(c=>Hn.groundDistanceKm(t.observer,c)))])),r=this.ufoElement.seekableDuration;return[...t.tracks].sort((a,c)=>s.get(Qe.keyOf(a))-s.get(Qe.keyOf(c))).map(a=>{const c=Qe.keyOf(a),l=t.descriptions?.get(c),h=t.models?.get(c),u=Hn.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=Oe(this.ufoElement.sighting,e),s=Qe.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=>Qe.keyOf(c)===t);if(!i?.observer||i.startMs===void 0||!r||n?.headingDeg===void 0)return!1;const a=Hn.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=Oe(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(H3)),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=>Qe.keyOf(l))),r=e.tracks.filter(l=>s.has(Qe.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(Qe.keyOf(l),u),a.set(Qe.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(Qe.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(Qe.keyOf(u),i.AircraftModels.of(d))})),this.traffic!==e||e.startMs===void 0)return;const h=i.TrafficDecor.from(c,n,e.startMs,Me.TRAIL_MAX_AIRCRAFT,{models:l});e.trailSet=Me.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||Qe.keyOf(u)!==Qe.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=Zh.held(this.ufoElement.sighting.snapshots,"upperAir");let r;if(s){const l=yi.address(s.src,this.documentUrl);r=Me.upperAirProviders.get(l),r||Me.upperAirProviders.set(l,r=new Hh(yi.json(l)))}else{const l=this.upperAirSource??e.UPPER_AIR_SOURCES[0];r=Me.upperAirProviders.get(l.id),r||Me.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=Hn.positionAt(c,i.startMs+Math.min(a.untilMs,Math.max(a.fromMs,t)));l&&e.set(r.id,{heightM:l.geo.heightM,sunElevationDeg:Ds.sunElevationDeg(s,i.observer,l.geo)})}return e}sunElevationAt(t,e){const i=Ah("Sun",new Date(t.t),e);return Ds.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??Me.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){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(U3)))},s=Me.tleArchive;(async()=>{if(!await s.covers(t))return n("outside");const[r,a]=await Promise.all([s.at(t),st(()=>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(Qe.keyOf(e))}}satellitePositionsAt(t){const e=this.satellites,i=this.ufoElement.sighting,n=Oe(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=Oe(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=so(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=Bk.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,kd.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(m=>[m.t,m.shapes.map(g=>[g.sourceId,g.shape.angular?.widthDeg,g.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 m of n.sourceIds){const g=n.getInterpolatedShapeAt(t,m);if(!g)continue;const v={...g,bounds:{...g.bounds,x:g.bounds.x+r.x,y:g.bounds.y+r.y}};c.set(m,v);const M=g.aim?this.sceneRenderer.screenPointOf(Vs.directionOf(g.aim,this.directionScratch)):{ndcX:(v.bounds.x+v.bounds.width/2)/s.width*2-1,ndcY:-((v.bounds.y+v.bounds.height/2)/s.height*2-1)},w=M!==void 0&&Math.abs(M.ndcX)<=1&&Math.abs(M.ndcY)<=1,y=w?this.sceneRenderer.decorDistancesAt(M.ndcX,M.ndcY,m):{};h.add(m),(w||g.aim)&&h.delete(m);const b=g.angular?.widthDeg??a.pxToDeg(g.bounds.width),S=this.sizeEstimateOf(m);S.add(b,y);const E=this.approachOf(e,m);l.set(m,_s.resolve({hypothesisM:this.distanceHypotheses.get(m),derivedM:E&&b>0?mi.distanceMAt(E.widthM,b):void 0,range:S.distanceRangeAt(b),crossing:y}))}for(const[m,g]of c)for(const[v,M]of c){if(v===m||M.transparency>=1||M.bounds.width*M.bounds.height<=g.bounds.width*g.bounds.height||!(g.bounds.x>=M.bounds.x&&g.bounds.y>=M.bounds.y&&g.bounds.x+g.bounds.width<=M.bounds.x+M.bounds.width&&g.bounds.y+g.bounds.height<=M.bounds.y+M.bounds.height))continue;const y=l.get(v);y&&l.set(m,{distanceM:y.distanceM*.999,basis:y.basis});break}this.depths=l;const u=n.sourceIds,d=[];for(const[m,g]of c)d.push({sourceId:m,shape:g,distanceM:l.get(m).distanceM,renderOrder:u.indexOf(m),aim:g.aim,hidden:h.has(m)||this.interpretationShown!==void 0&&(!this.comparing||g.transparency>=1),ghost:this.interpretationShown!==void 0&&this.comparing});const f=Oe(e,t),p=(f?.rollDeg??0)+hi.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:Ti.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=Ct.eyeOf(this.ufoElement.sighting,i,n);return s?Ct.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=>Ct.eyeOf(n,d,i),r=new Ct(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=>Ct.eyeOf(n,c,i),r=new Ct(t,i,s).at(e),a=s(e);return r&&a?si.projectionOf(r,a):void 0}directionToBody(t,e){const i=this.sceneRenderer.bodyGround,n=this.ufoElement.sighting,s=p=>Ct.eyeOf(n,p,i),r=new Ct(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=>Ct.eyeOf(n,p,a);i&&(s=i.bodies.map(p=>new Ct(p,a,c).at(t)).filter(p=>p!==void 0));const l=mh(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 si(n.timeline,this.confrontationTolerance).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(Jy,{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&&mh(t,s.t).storm&&this.handleLightningFlash(s)}ensureLightningSchedule(t){const e=mh(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?so(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=vn.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])}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?so(i,e.lng,t.event.utcOffsetHours):void 0;if(!n||e?.lat===void 0||e.lng===void 0){this.sceneRenderer.setMeteorShower([],0,0);return}const s={lat:e.lat,lng:e.lng,elevationM:0},r=(t.event.durationSeconds??0)*1e3||t.timeline.duration||2e4,a=Math.round(n.getTime()/1e3)+Math.round(e.lat*1e3),c=ji.schedule({ratePerHour:ji.observedRatePerHour(ji.apexPosition(n,s).altitudeDeg),durationMs:r,velocityKmS:ji.TYPICAL_VELOCITY_KM_S,seed:a}),l=$1.activeAt(n).map(u=>{const d=$1.radiantPosition(u.shower,n,s);return{entry:u,position:d,rate:$1.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=Er.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=>Er.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=Oe(e,t),r=s?.fNumber??i.fNumber;if(!n||r===void 0)return;const a=Ti.focalLengthMmFor(i,bn.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 Aa.of(e.instrument,mi.CANVAS_HEIGHT_PX,bn.fovOf(e,t))}sizeEstimateOf(t){let e=this.sizeEstimates.get(t);return e||(e=new Gk,this.sizeEstimates.set(t,e)),e}}const _f="rr0-scene";function jy(){r3(),customElements.get(_f)||customElements.define(_f,Me)}const x7=Object.freeze(Object.defineProperty({__proto__:null,AIRCRAFT_CHANGE_EVENT:H3,CONFRONTATION_EVENT:Jy,FIREBALLS_CHANGE_EVENT:z3,REFERENCES_CHANGE_EVENT:B3,SATELLITES_CHANGE_EVENT:U3,SCENE_ELEMENT_NAME:_f,SceneElement:Me,registerScene:jy},Symbol.toStringTag,{value:"Module"}));class xa{static PACKAGE="@rr0/ufoathome";static CDN="https://cdn.jsdelivr.net/npm";static DIRECTORIES={"rr0-sighting":"dist-embed-sighting","rr0-sighting-editor":"dist-embed-sighting-editor"};static current(t,e,i){const n=new URL(`${t}.mjs`,e);return n.href.startsWith(`${xa.CDN}/`)?`${i}/lib/${t}.mjs`:(n.pathname=n.pathname.replace(/\/lib\/\d+\.\d+\.\d+[^/]*\//,"/lib/"),n.href)}static VERSION_PARAMETER="v";static pinnable(t){return t in xa.DIRECTORIES}static pinnedLink(t,e){const i=new URL(t);return i.searchParams.set(xa.VERSION_PARAMETER,e),i.href}static pinned(t,e){return`${xa.CDN}/${xa.PACKAGE}@${e}/${xa.DIRECTORIES[t]}/${t}.mjs`}}class Su{static PRODUCTION="https://ufoathome.org";static home(){try{const t=new URL(import.meta.url),e=new URL(location.href);return(e.hostname==="localhost"||e.hostname==="127.0.0.1"||e.hostname==="[::1]"||e.hostname.endsWith(".localhost"))&&t.origin===e.origin?e.origin:Su.PRODUCTION}catch{return Su.PRODUCTION}}}const Qk=`
|
|
@@ -9913,9 +9913,9 @@ ${yi.generation}`;return this.snapshotMap?.key!==i&&(this.snapshotMap={key:i,ima
|
|
|
9913
9913
|
<button id="copy" class="share-copy" type="button"></button>
|
|
9914
9914
|
</div>
|
|
9915
9915
|
</dialog>
|
|
9916
|
-
`;class ml extends HTMLElement{static TAG="rr0-share-dialog";static register(){customElements.get(ml.TAG)||customElements.define(ml.TAG,ml)}subject;messages;languageToken=0;shadow;dialog;linkField;copyButton;linkBox;embedBox;linkOption;embedOption;pin;embedMarkup;noteElement;codeEditor;codeLoading;constructor(){super(),this.shadow=this.attachShadow({mode:"open"}),this.shadow.innerHTML=Qk;const t=e=>this.shadow.getElementById(e);this.dialog=t("dialog"),this.linkField=t("link"),this.copyButton=t("copy"),this.linkBox=t("link-box"),this.embedBox=t("embed-box"),this.linkOption=t("link-option"),this.embedOption=t("embed-option"),this.pin=t("pin"),this.embedMarkup=t("embed-markup"),this.noteElement=t("note"),t("close").addEventListener("click",()=>this.close()),this.dialog.addEventListener("click",e=>{e.target===this.dialog&&this.close()}),this.linkOption.addEventListener("click",()=>this.show("link")),this.embedOption.addEventListener("click",()=>this.show("embed")),this.pin.addEventListener("change",()=>this.refresh()),this.copyButton.addEventListener("click",()=>void(this.embedBox.hidden?this.copy(this.linkField.value,this.linkField):this.copy(this.codeEditor?.text??this.embedMarkup.value,this.embedMarkup))),this.applyMessages()}async useLanguage(t){const e=++this.languageToken,i=await zT.load(t);if(e===this.languageToken)return this.messages=i,this.applyMessages(),i}set note(t){this.noteElement.textContent=t??"",this.noteElement.hidden=t===void 0}get isOpen(){return this.dialog.open||this.dialog.hasAttribute("open")}open(){this.refresh(),this.show("link"),typeof this.dialog.showModal=="function"?this.dialog.showModal():this.dialog.setAttribute("open",""),this.fitLink(),requestAnimationFrame(()=>this.fitLink()),this.linkField.select()}close(){typeof this.dialog.close=="function"?this.dialog.close():this.dialog.removeAttribute("open")}refresh(){const t=this.subject;if(!t)return;const e=this.pin.checked;this.linkField.value=e?xa.pinnedLink(t.link(),"0.188.
|
|
9917
|
-
${t.element()}`;this.embedMarkup.value=n,this.codeEditor&&(this.codeEditor.text=n)}applyMessages(){const t=this.messages;if(!t)return;const e=(i,n)=>{this.shadow.getElementById(i).textContent=n};e("title",t.share),e("link-label",t.link),e("embed-label",t.embed),e("copy",t.copy),e("pin-label",t.pin.replace("{version}","0.188.0")),this.pin.parentElement.title=t.pinHint,this.shadow.getElementById("close").setAttribute("aria-label",t.close),this.linkField.setAttribute("aria-label",t.link)}show(t){this.linkBox.hidden=t!=="link",this.embedBox.hidden=t!=="embed",this.linkOption.setAttribute("aria-pressed",String(t==="link")),this.embedOption.setAttribute("aria-pressed",String(t==="embed")),t==="embed"?this.loadCodeEditor():this.fitLink()}fitLink(){this.linkField.style.height="auto",this.linkField.style.height=`${this.linkField.scrollHeight}px`}loadCodeEditor(){this.codeLoading??=st(async()=>{const{ShareCodeEditor:t}=await import("./ShareCodeEditor-C53SBK2N.js");return{ShareCodeEditor:t}},[],import.meta.url).then(({ShareCodeEditor:t})=>{this.codeEditor=new t(this.shadow.getElementById("embed-code"),this.embedMarkup.value,e=>{this.embedMarkup.value=e},this.messages?.embed??""),this.embedMarkup.hidden=!0}).catch(()=>{this.codeLoading=void 0})}async copy(t,e){try{await navigator.clipboard.writeText(t),this.copyButton.textContent=this.messages?.copied??"",window.setTimeout(()=>this.copyButton.textContent=this.messages?.copy??"",1500)}catch{e.select()}}}class jn{static PLAIN=/^\d+(?:[.,]\d+)?$/;static COLONS=/^(?:(\d+):)?(\d{1,2}):(\d{1,2}(?:[.,]\d+)?)$/;static UNITS=/^(?:(\d+(?:[.,]\d+)?)h)?(?:(\d+(?:[.,]\d+)?)m)?(?:(\d+(?:[.,]\d+)?)s)?$/i;static CLOCK=/^(?:(\d{4})-(\d{2})-(\d{2})[T ])?T?(\d{1,2}):(\d{2})(?::(\d{2}(?:[.,]\d+)?))?$/;static num(t){return t===void 0?0:Number(t.replace(",","."))}static delta(t){const e=(t??"").trim();if(e==="")return;if(jn.PLAIN.test(e))return jn.num(e);const i=jn.COLONS.exec(e);if(i){const[,s,r,a]=i;return Number(r)>=60||jn.num(a)>=60?void 0:jn.num(s)*3600+Number(r)*60+jn.num(a)}const n=jn.UNITS.exec(e);return n&&(n[1]!==void 0||n[2]!==void 0||n[3]!==void 0)?jn.num(n[1])*3600+jn.num(n[2])*60+jn.num(n[3]):/^P/i.test(e)?Xh.seconds(e.toUpperCase()):void 0}static isClock(t){return jn.clock(t)!==void 0}static clock(t){const e=jn.CLOCK.exec((t??"").trim());if(!e)return;const[,i,n,s,r,a,c]=e,l={hour:Number(r),minute:Number(a),second:jn.num(c)};if(!(l.hour>=24||l.minute>=60||l.second>=60)){if(i!==void 0){const h={year:Number(i),month:Number(n),day:Number(s)};if(h.month<1||h.month>12||h.day<1||h.day>31)return;l.date=h}return l}}static elapsedSince(t,e){if(!t||t.hour===void 0||t.minute===void 0)return;const i=t.hour*3600+t.minute*60+(t.second??0),n=e.hour*3600+e.minute*60+e.second;if(e.date){if(t.year===void 0||t.month===void 0||t.day===void 0)return;const r=Date.UTC(e.date.year,e.date.month-1,e.date.day)/1e3+n,a=Date.UTC(t.year,t.month-1,t.day)/1e3+i;return Math.max(0,r-a)}let s=n-i;return s<=-43200&&(s+=86400),Math.max(0,s)}}jy();ml.register();const _0=Su.home(),r0="compare-account",Y1="start-time",jS="start-clock",Kc="observer",T0="case-named",Fd="show-info",R0="interpretation",Vh="hide-pickers",a0="case",ld="account",o0="variant-",K1=`${_0}/edit/`;class qc extends HTMLElement{static get observedAttributes(){return["src","show-labels",Fd,Vh,R0,T0,Y1,jS,Kc,Pa,La,r0]}shadow;sceneElement;toolbarElement;accountElement;accountPrefix;caseOfElement;observerText;observerSelect;infoButton;infoPanel;infoAppLink;editLink;readingFindingsElement;readingSensible=!1;readingCheck;bestCases;readingScene=!1;readingEntry;static VERDICT_COLOURS={incompatible:"#e04848",unsettled:"#e08a2c",compatible:"#2e9d5b"};infoObservationHeading;infoObservationList;infoCreditsToggle;infoCreditsList;infoCloseButton;shareButton;shareDialog;shareStartOn;shareStart;shareScopeRow;shareScopeLabel;shareScope;shareOpensRow;shareOpensLabel;shareOpens;shareStartLabel;shareOptions;labelsToggle;paramSummary;summaryBuilder;summarySignature="";assessmentEntries=[];assessmentToken=0;supportsPopover=typeof HTMLElement.prototype.showPopover=="function";entries=[];caseSource;interpretationChoice;interpretationLabel;interpretationSelect;confrontationElement;confrontationHeading;confrontationList;compareButton;variantChips;variantMoved;interpretationLoaders=new Map;interpretationToken=0;shownInterpretation;offeredFor;currentSrc;infoOpen=!1;creditsOpen=!1;labelsShown=!1;language="en";messages;ready=Promise.resolve();constructor(){super(),this.shadow=this.attachShadow({mode:"open"});const t=document.createElement("template");t.innerHTML=`<style>${YT}</style>${$T}`,this.shadow.appendChild(t.content.cloneNode(!0)),customElements.upgrade(this.shadow),this.sceneElement=document.createElement(_f),this.forwardPlayerAttributes(),this.sceneElement.ufoElement.creditShownExternally=!0,this.sceneElement.ownCredits=!1,this.shadow.getElementById("ufo-slot").replaceWith(this.sceneElement),this.toolbarElement=this.shadow.getElementById("toolbar"),this.accountElement=this.shadow.getElementById("account"),this.accountPrefix=this.shadow.getElementById("account-prefix"),this.caseOfElement=this.shadow.getElementById("case-of"),this.observerText=this.shadow.getElementById("observer-text"),this.observerSelect=this.shadow.getElementById("observer"),this.infoButton=this.shadow.getElementById("info-button"),this.infoPanel=this.shadow.getElementById("info-panel"),this.infoAppLink=this.shadow.getElementById("info-app-link"),this.editLink=this.shadow.getElementById("edit-link"),this.infoObservationHeading=this.shadow.getElementById("info-observation-heading"),this.infoObservationList=this.shadow.getElementById("info-observation-list"),this.infoCreditsToggle=this.shadow.getElementById("info-credits-toggle"),this.infoCreditsList=this.shadow.getElementById("info-credits-list"),this.infoCloseButton=this.shadow.getElementById("info-close"),this.labelsToggle=this.shadow.getElementById("labels-button"),this.paramSummary=this.shadow.getElementById("param-summary"),this.labelsToggle.addEventListener("click",()=>{this.showLabels=!this.showLabels}),this.shareButton=document.createElement("button"),this.shareButton.type="button",this.shareButton.id="share-button",this.shareButton.setAttribute("aria-haspopup","dialog"),this.shareButton.innerHTML=qt.SHARE,this.sceneElement.ufoElement.addControl(this.shareButton),this.shareDialog=this.shadow.getElementById("share-dialog"),this.shareDialog.subject=this.shareSubject,this.shareStartOn=this.shadow.getElementById("share-start-on"),this.shareStart=this.shadow.getElementById("share-start"),this.shareStartLabel=this.shadow.getElementById("share-start-label"),this.shareScopeRow=this.shadow.getElementById("share-scope-row"),this.shareScopeLabel=this.shadow.getElementById("share-scope-label"),this.shareScope=this.shadow.getElementById("share-scope"),this.shareOpensRow=this.shadow.getElementById("share-opens-row"),this.shareOpensLabel=this.shadow.getElementById("share-opens-label"),this.shareOpens=this.shadow.getElementById("share-opens");const e=n=>({input:this.shadow.getElementById(`share-opt-${n}`),label:this.shadow.getElementById(`share-opt-${n}-label`)});this.shareOptions={labels:e("labels"),map:e("map"),milestones:e("milestones"),compare:e("compare")},this.interpretationChoice=this.shadow.getElementById("interpretation-choice"),this.interpretationLabel=this.shadow.getElementById("interpretation-label"),this.interpretationSelect=this.shadow.getElementById("interpretation"),this.confrontationElement=this.shadow.getElementById("confrontation"),this.confrontationHeading=this.shadow.getElementById("confrontation-heading"),this.confrontationList=this.shadow.getElementById("confrontation-list"),Rs.register(),this.readingFindingsElement=this.shadow.getElementById("reading-findings");const i=this.shadow.getElementById("reading-chip");i.addEventListener("click",()=>{const n=i.getAttribute("aria-expanded")!=="true";i.setAttribute("aria-expanded",String(n)),this.shadow.getElementById("reading-findings-list").hidden=!n}),this.compareButton=this.shadow.getElementById("compare-account"),this.variantChips=this.shadow.getElementById("variant-chips"),this.variantMoved=this.shadow.getElementById("variant-moved"),this.compareButton.addEventListener("click",()=>this.setComparing(!this.sceneElement.compareAccount)),this.observerSelect.addEventListener("change",()=>this.selectObserver(this.observerSelect.value)),this.interpretationSelect.addEventListener("change",()=>void this.chooseInterpretation(this.interpretationSelect.value)),this.sceneElement.addEventListener(Jy,n=>this.showConfrontation(n.detail)),this.sceneElement.ufoElement.addEventListener("timeupdate",()=>this.refreshParamSummary()),this.supportsPopover?(this.infoPanel.setAttribute("popover","auto"),this.infoPanel.removeAttribute("hidden"),this.infoButton.setAttribute("popovertarget","info-panel"),this.infoPanel.addEventListener("beforetoggle",n=>{n.newState==="open"&&(this.populateInfoPanel(),this.bringInfoButtonIntoView())}),this.infoPanel.addEventListener("toggle",n=>this.syncInfoOpen(n.newState==="open"))):this.infoButton.addEventListener("click",()=>this.toggleInfoPanel()),this.infoCloseButton.addEventListener("click",()=>this.toggleInfoPanel()),this.infoCreditsToggle.addEventListener("click",()=>this.toggleCredits()),this.shareButton.addEventListener("click",()=>this.openShare());for(const n of[this.shareStartOn,this.shareStart,...Object.values(this.shareOptions).map(s=>s.input)])n.addEventListener("input",()=>this.refreshShareLinks());for(const n of[this.shareScope,this.shareOpens])n.addEventListener("change",()=>this.refreshShareLinks());this.isConnected&&(this.ready=this.loadLocaleMessages())}get scene(){return this.sceneElement}async loadLocaleMessages(){const t=++this.localeToken,e=Ks.preferencesFor(this);this.preferences=e;const i=Mo(e,yo),[n,s,r,a]=await Promise.all([LT.load(i),BT(i),xE(i),lL.load(i)]);if(t!==this.localeToken)return;const c=i!==this.language||this.messages===void 0;this.language=i,this.messages=n,this.readingCheck=new pn(a),this.bestCases=new ie(a),this.tags=new dM(s),this.said=new es(e),this.summaryBuilder=new Vc(this.messages,new BM(r),this.said,this.tags,{messages:this.messages,locale:i}),this.accountPrefix.textContent=this.messages?.accountBy??"",this.interpretationLabel.textContent=this.messages?.interpretation??"",this.confrontationHeading.textContent=this.messages?.confrontation??"";const l=this.entries.find(h=>h.src===this.currentSrc);l&&this.offerInterpretations(l),this.updateCompareButton(),this.infoButton.title=this.messages?.about??"",this.infoButton.setAttribute("aria-label",this.messages?.about??""),this.editLink.title=this.messages?.editThisObservation??"",this.editLink.setAttribute("aria-label",this.messages?.editThisObservation??""),this.infoCloseButton.setAttribute("aria-label",this.messages?.close??""),this.infoObservationHeading.textContent=this.messages?.observation??"",this.infoCreditsToggle.textContent=this.messages?.credits??"",this.syncLabelsToggle(),this.refreshParamSummary(),c&&this.currentSrc&&this.runAssessments(),this.shareButton.title=this.messages?.share??"",this.shareButton.setAttribute("aria-label",this.messages?.share??""),this.shareStartLabel.textContent=this.messages?.shareStartAt??"",this.shareScopeLabel.textContent=this.messages?.shareScope??"",this.shareOpensLabel.textContent=this.messages?.shareOpensOn??"",this.shareOptions.labels.label.textContent=this.messages?.shareOptionLabels??"",this.shareOptions.map.label.textContent=this.messages?.shareOptionMap??"",this.shareOptions.milestones.label.textContent=this.messages?.shareOptionMilestones??"",this.shareOptions.compare.label.textContent=this.messages?.shareOptionCompare??"",this.shareStart.setAttribute("aria-label",this.messages?.shareStartAt??""),this.shareDialog.useLanguage(i),this.infoOpen&&this.populateInfoPanel(),this.updateAccountLine()}preferences=[];localeToken=0;said=new es(["en"]);tags=new dM({});connectedCallback(){Ks.preferencesFor(this).join()!==this.preferences.join()&&(this.ready=this.loadLocaleMessages()),this.applyAskedInfo();const t=this.getAttribute("src");t&&this.loadFromSrc(t)}applyAskedInfo(){this.isConnected&&this.hasAttribute(Fd)!==this.infoOpen&&this.toggleInfoPanel()}disconnectedCallback(){document.removeEventListener("click",this.handleOutsideClick)}attributeChangedCallback(t,e,i){if(t==="src"&&i&&i!==e&&this.isConnected&&this.loadFromSrc(i),t===R0){const n=this.entries.find(s=>s.src===this.currentSrc);n&&this.offerInterpretations(n)}if(t===Vh){const n=this.entries.find(s=>s.src===this.currentSrc);this.setEntries(this.entries,this.caseSource),n&&this.offerInterpretations(n)}if(t===Fd&&this.applyAskedInfo(),t==="show-labels"&&this.applyLabels(this.hasAttribute("show-labels")),(t===Pa||t===La)&&this.forwardPlayerAttributes(),t===Kc&&this.entries.length>1){const n=this.entryAsked(this.entries);n&&n.src!==this.currentSrc&&this.selectObserver(n.src)}t===r0&&this.setComparing(this.hasAttribute(r0))}forwardPlayerAttributes(){for(const t of[Pa,La]){const e=this.getAttribute(t);e===null?this.sceneElement.removeAttribute(t):this.sceneElement.setAttribute(t,e)}}get loaded(){return this.loading??Promise.resolve()}loading;loadFromSrc(t){const e=this.readFromSrc(t);return this.loading=e.catch(()=>{}),e}async readFromSrc(t){this.startPending=!0;const e=Ar.recording(t);this.sceneElement.holdForNewScene(e);const i=await e;if(Array.isArray(i))throw new Error(`${t} is a bare list of recordings, which is no longer read: list them as the sighting events of a case.json`);if(Ui.isCase(i)){Ui.check(i);const n=Ui.sightingUrls(i,new URL(t,location.href).href);if(n.length===0)throw new Error(`${t} is a case with no sighting event: no recording to show`);await this.loadObserverUrls(n,{json:i,url:new URL(t,location.href).href})}else this.setEntries([{src:t,sighting:i}],void 0)}get sightingData(){return this.entries.find(t=>t.src===this.currentSrc)?.sighting}set sightingData(t){const e=lr.recording(t);this.startPending=!0,this.currentSrc="",this.setEntries([{src:"",sighting:e}],void 0)}seekTo(t,e){const i=this.caseSource,n=e===void 0?void 0:this.entries.find(s=>{const r=this.plain(s).id;return(i?Ui.accountIds(i.json,i.url,s.src,r):[r]).includes(e)});n&&n.src!==this.currentSrc&&this.selectObserver(n.src),this.sceneElement.ufoElement.currentTime=Math.max(0,t)*1e3}set citedMoments(t){this.sceneElement.ufoElement.citedMoments=t}get playedSeconds(){return this.sceneElement.ufoElement.currentTime/1e3}get observerUrls(){return this.entries.map(t=>t.src)}set observerUrls(t){this.loadObserverUrls(t)}async loadObserverUrls(t,e){const i=await Promise.all(t.map(async n=>({src:n,sighting:await Ar.recording(n)})));this.setEntries(i,e)}reportCaseProblems(t,e){const{duplicateIds:i,unresolved:n}=Ui.problems(t,e.map(s=>this.plain(s).id).filter(s=>s!==void 0));for(const s of i)console.warn(`The case ${t.id??""} gives the id "${s}" to more than one event: a reference to it is ambiguous.`);for(const{reading:s,reference:r}of n)console.warn(`The reading ${s} of the case ${t.id??""} is "interpretationOf" "${r}", which no event of the case has as its id, nor any recording it lists.`)}setEntries(t,e){this.entries=t.map(r=>({...r,sighting:lr.recording(r.sighting)})),this.caseSource=e,e&&this.reportCaseProblems(e.json,t),this.toolbarElement.hidden=t.length===0;const i=t.length>1&&!this.hasAttribute(Vh);this.observerSelect.hidden=!i,this.observerText.hidden=i,this.observerSelect.innerHTML="";const n=t.map((r,a)=>this.observerDisplayName(this.plain(r).observer)??this.caseTitleOf(r)??(this.messages?.unnamedObserver??"").replace("{n}",String(a+1)));for(const[r,a]of t.entries()){const c=document.createElement("option");c.value=a.src;const l=n.filter(h=>h===n[r]).length>1;c.textContent=(l?this.caseTitleOf(a):void 0)??n[r],this.observerSelect.appendChild(c)}const s=t.find(r=>r.src===this.currentSrc)??this.entryAsked(t)??t[0];s?this.selectObserver(s.src):this.updateAccountLine()}entryAsked(t){const e=this.getAttribute(Kc)?.trim();if(!e)return;const i=t.find(r=>this.plain(r).observer?.id===e);if(i)return i;const n=this.caseSource;if(n){const r=t.find(a=>Ui.accountIds(n.json,n.url,a.src,this.plain(a).id).includes(e));if(r)return r}const s=t.find(r=>r.src.split("/").pop()===e.split("/").pop());return s||(/^\d+$/.test(e)?t[Number(e)-1]:void 0)}observerKeyOf(t){return this.plain(t).observer?.id??String(this.entries.indexOf(t)+1)}sharedEntry(){const t=this.shareScope.value;if(!(!this.caseSource||t===a0))return this.entries.find(e=>e.src===t)}get sharesCase(){return this.caseSource!==void 0&&!this.shareScopeRow.hidden&&this.shareScope.value===a0}editorUrl(){if(!this.currentSrc)return K1;const t=new URL(this.currentSrc,location.href),e=this.caseSource;return e?`${K1}?file=${encodeURIComponent(e.url)}&track=${encodeURIComponent(this.shownTrackUrl()??t.href)}`:`${K1}?file=${encodeURIComponent(t.href)}`}get editorHref(){return this.editorUrl()}shownTrackUrl(){return this.readingUrlOf(this.interpretationSelect.value)}shareSubject={module:"rr0-sighting",link:()=>this.playUrl(),element:()=>this.replayElement()};replayElement(){const t=this.sharedAddress(),i=[...t.observer?[[Kc,t.observer]]:[],...this.replayAttributes()].map(([n,s])=>s===""?` ${n}`:` ${n}="${s}"`).join("");return`<rr0-sighting src="${t.src}"${i}></rr0-sighting>`}playUrl(){const t=this.sharedAddress(),e=[...t.observer?[`${Kc}=${encodeURIComponent(t.observer)}`]:[],...this.replayQuery()].join("&");return t.src?`${_0}/play/?file=${encodeURIComponent(t.src)}${e&&"&"+e}`:`${_0}/play/${e&&"?"+e}`}sharedAddress(){const t=e=>e?new URL(e,location.href).href:"";if(this.sharesCase){const e=this.entries.find(i=>i.src===this.shareOpens.value)??this.entries.find(i=>i.src===this.currentSrc);return{src:t(this.caseSource.url),observer:e?this.observerKeyOf(e):void 0}}return{src:t(this.sharedEntry()?.src??this.currentSrc??"")}}replayAttributes(){const t=this.shareOptions,e=[];return this.shareStartSeconds!==void 0&&e.push([Y1,String(this.shareStartSeconds)]),t.labels.input.checked&&e.push(["show-labels",""]),t.map.input.checked&&e.push([Pa,""]),t.milestones.input.checked||e.push([La,""]),t.compare.input.checked&&e.push([r0,""]),e}replayQuery(){const t=this.shareOptions,e=[];return this.shareStartSeconds!==void 0&&e.push(`d=${this.shareStartSeconds}`),t.labels.input.checked||e.push("labels=0"),t.map.input.checked&&e.push("map=1"),t.milestones.input.checked||e.push("moments=0"),t.compare.input.checked&&e.push("compare=1"),e}get shareStartSeconds(){const t=Math.floor(Number(this.shareStart.value));return this.shareStartOn.checked&&Number.isFinite(t)&&t>=0?t:void 0}refreshShareLinks(){this.shareOpensRow.hidden=!this.sharesCase,this.shareDialog.refresh()}openShare(){const t=this.sceneElement.ufoElement;this.shareStart.max=String(Math.floor(t.seekableDuration/1e3)),this.shareStart.value=String(Math.floor(t.currentTime/1e3)),this.shareStartOn.checked=!1,this.shareOptions.labels.input.checked=this.labelsShown,this.shareOptions.map.input.checked=t.observerMapOpen,this.shareOptions.milestones.input.checked=t.milestonesVisible,this.shareOptions.compare.input.checked=this.sceneElement.compareAccount,this.offerShareScope(),this.shareOpensRow.hidden=!this.sharesCase,this.shareDialog.open()}offerShareScope(){const t=this.caseSource!==void 0&&this.entries.length>1&&!this.hasAttribute(T0);if(this.shareScopeRow.hidden=!t,this.shareScope.innerHTML="",this.shareOpens.innerHTML="",!t)return;const e=(i,n,s)=>{const r=document.createElement("option");r.value=n,r.textContent=s,i.appendChild(r)};e(this.shareScope,a0,this.messages?.shareScopeCase??"");for(const i of this.entries){const n=this.observerDisplayName(this.plain(i).observer)??this.caseTitleOf(i)??(this.messages?.unnamedObserver??"").replace("{n}",String(this.entries.indexOf(i)+1));e(this.shareScope,i.src,n),e(this.shareOpens,i.src,n)}this.shareScope.value=a0,this.shareOpens.value=this.currentSrc??this.entries[0].src}offerInterpretations(t){const e=this.offeredFor===t.sighting,i=this.interpretationSelect.value;this.offeredFor=t.sighting,this.interpretationToken++,this.interpretationLoaders=new Map,this.interpretationSelect.innerHTML="";const n=(u,d,f)=>{const p=document.createElement("option");p.value=u,p.textContent=d,this.interpretationSelect.appendChild(p),this.interpretationLoaders.set(u,f)},s=t===this.entries.find(u=>u.src===this.currentSrc),r=s?this.sceneElement.ufoElement.sighting.interpretation:void 0;n(ld,this.messages?.account??"",()=>Promise.resolve(r));const a=this.caseSource;a&&Ui.interpretationEvents(a.json,Ui.accountIds(a.json,a.url,t.src,this.plain(t).id)).forEach((u,d)=>{const f=this.said.read(u.title)??`#${d+1}`,p=(u.by??[]).map(m=>this.agentName(m)).filter(Boolean).join(", ");n(`case-${d}`,p?(this.messages?.interpretationBy??"").replace("{title}",f).replace("{by}",p):f,()=>Ui.interpretationOf(u,a.url,m=>Ar.recording(m)))});const c=s?this.keptVariants(t):[];for(const{index:u,kept:d}of c)n(`${o0}${u}`,`${this.variantLabel(d)} (${this.messages?.verdicts[d.variant.verdict]??""})`,()=>Promise.resolve(d.bodies.length>0?d:void 0));const l=e&&[...this.interpretationSelect.options].some(u=>u.value===i),h=this.askedInterpretation()??(l?i:ld);this.interpretationSelect.value=h,h===ld?(this.sceneElement.interpretation!==r&&(this.sceneElement.interpretation=r),this.shownInterpretation=ld):(!this.sceneElement.interpretation||this.shownInterpretation!==h)&&this.chooseInterpretation(h),this.interpretationChoice.hidden=this.interpretationSelect.options.length<2||this.hasAttribute(Vh),this.showConfrontation(this.sceneElement.confrontation),this.updateCompareButton(),this.showVariants(c)}keptVariants(t){const e={consolidated:0,contested:1,incompatible:2};return(t.sighting.variants??[]).map((i,n)=>({index:n,kept:i})).filter(({kept:i})=>i.variant).sort((i,n)=>e[i.kept.variant.verdict]-e[n.kept.variant.verdict]||i.kept.variant.cost-n.kept.variant.cost)}variantLabel(t){return(this.messages?.variant??"").replace("{name}",t.variant.label??t.variant.candidate)}showVariants(t){if(!this.messages)return;if(this.variantChips.innerHTML="",this.variantChips.hidden=t.length===0,t.length===0){this.showVariantMoved();return}const e=(i,n,s)=>{const r=document.createElement("button");r.type="button",r.dataset.value=i,s&&(r.dataset.verdict=s,r.title=this.messages.verdicts[s],r.append(Object.assign(document.createElement("span"),{className:"dot"}))),r.append(n),r.addEventListener("click",()=>{this.interpretationSelect.value!==i&&(this.interpretationSelect.value=i,this.chooseInterpretation(i))}),this.variantChips.append(r)};e(ld,this.messages?.account??"");for(const{index:i,kept:n}of t)e(`${o0}${i}`,n.variant.label??n.variant.candidate,n.variant.verdict);this.showVariantMoved()}showVariantMoved(){if(!this.messages)return;const t=this.interpretationSelect.value;for(const s of this.variantChips.querySelectorAll("button"))s.setAttribute("aria-pressed",String(s.dataset.value===t));this.variantMoved.innerHTML="";const e=t.startsWith(o0)?Number(t.slice(o0.length)):-1,i=this.sceneElement.ufoElement.sighting.variants?.[e]?.variant;if(this.variantMoved.hidden=!i||i.moved.length+(i.readings?.length??0)===0,!i)return;const n=new Intl.NumberFormat(this.language,{maximumFractionDigits:1});for(const s of i.moved){const[r,a]=s.field==="time"?["0 min",`${s.variant>0?"+":""}${n.format(s.variant)} min`]:s.field==="duration"?[`${n.format(s.stated)} s`,`${n.format(s.variant)} s`]:[`${n.format(s.stated)}°`,`${n.format(s.variant)}°`],c=document.createElement("span");c.append(`${this.messages.variantFields[s.field]}${this.colon}`,Object.assign(document.createElement("s"),{textContent:r})," → ",Object.assign(document.createElement("b"),{textContent:a})),this.variantMoved.append(c)}for(const s of i.readings??[]){const r=this.messages.variantReadings[s.reading];r&&this.variantMoved.append(Object.assign(document.createElement("span"),{className:"reading",textContent:r}))}}setComparing(t){this.sceneElement.compareAccount=t,this.updateCompareButton(),this.showConfrontation(this.sceneElement.confrontation)}updateCompareButton(){const t=this.sceneElement.compareAccount;this.compareButton.hidden=!this.sceneElement.interpretation,this.compareButton.setAttribute("aria-pressed",String(t));const e=t?this.messages?.hideComparison??"":this.messages?.showComparison??"";this.compareButton.title=e,this.compareButton.setAttribute("aria-label",e)}get colon(){return this.language==="fr"?" : ":": "}askedInterpretation(){const t=this.getAttribute(R0)?.trim(),e=this.caseSource;if(!t||!e)return;const i=this.entries.find(r=>r.src===this.currentSrc);if(!i)return;const s=Ui.interpretationEvents(e.json,Ui.accountIds(e.json,e.url,i.src,this.plain(i).id)).findIndex(r=>r.id===t||typeof r.url=="string"&&new URL(r.url,e.url).href===new URL(t,location.href).href);return s>=0?`case-${s}`:void 0}async chooseInterpretation(t){const e=++this.interpretationToken,i=this.interpretationLoaders.get(t),n=i?await i().catch(d=>{console.warn(`<rr0-sighting>: could not read interpretation "${t}":`,d)}):void 0,s=this.readingUrlOf(t),r=s?await Ar.recording(s).catch(()=>{}):void 0;if(e!==this.interpretationToken)return;const a=this.entries.find(d=>d.src===this.currentSrc),c=a&&r&&"timeline"in r?this.bestCases?.bestSceneOf(a.sighting,r):void 0,l=c??r,h=c?.interpretation&&n?{...n,bodies:[...n.bodies.map(d=>{const f=c.interpretation.bodies.find(p=>p.id===d.id);return f?{...d,track:f.track}:d}),...c.interpretation.bodies.filter(d=>!n.bodies.some(f=>f.id===d.id))]}:n,u=a&&l&&"timeline"in l&&qc.changesTheScene(a.sighting,l)?{...l,timeline:l.timeline.keyframes?.length?l.timeline:a.sighting.timeline}:void 0;if(u&&s)this.showScene(u,s);else if(this.readingScene&&a)this.showScene(a.sighting,a.src,!0);else if(a){const d=!this.sceneElement.ufoElement.playRequested;s?this.sceneElement.showPoster(r?.image,s,d):a.sighting.image?this.sceneElement.showPoster(a.sighting.image,a.src?new URL(a.src,location.href).href:void 0,d):this.sceneElement.showPoster(this.caseSource?.json.image,this.caseSource?.url,d)}this.readingScene=u!==void 0,this.sceneElement.interpretation=h,this.shownInterpretation=t,this.showReadingFindings(a,l),this.editLink.href=this.editorUrl(),this.dispatchEvent(new CustomEvent("interpretationchange",{detail:{track:this.shownTrackUrl()}})),this.updateCompareButton(),this.showConfrontation(this.sceneElement.confrontation),this.showVariantMoved()}readingUrlOf(t){const e=this.caseSource,i=this.entries.find(r=>r.src===this.currentSrc),n=/^case-(\d+)$/.exec(t);if(!e||!i||!n)return;const s=Ui.interpretationEvents(e.json,Ui.accountIds(e.json,e.url,i.src,this.plain(i).id))[Number(n[1])];return s?.url?new URL(s.url,e.url).href:void 0}static SCENE_FIELDS=["time","utcOffsetHours","place","observerTrack","weatherTrack","decor","instrument","lens","film","exposureSeconds","iso","references","lighting","lightPollution","vehicle"];static changesTheScene(t,e){const i=n=>JSON.stringify(qc.SCENE_FIELDS.map(s=>n[s]));return i(t)!==i(e)}showScene(t,e,i=!1){const n=this.sceneElement.ufoElement.currentTime;this.sceneElement.documentUrl=e?new URL(e,location.href).href:void 0;const s=!this.sceneElement.ufoElement.playRequested,r=e?new URL(e,location.href).href:void 0;t.image?this.sceneElement.showPoster(t.image,r,s):i?this.sceneElement.showPoster(this.caseSource?.json.image,this.caseSource?.url,s):this.sceneElement.showPoster(void 0,void 0,s),this.sceneElement.sightingData=t,this.sceneElement.ufoElement.currentTime=n}showReadingFindings(t,e){const i=this.readingFindingsElement,n=this.messages,s=e?.interpretation?.findings??[],r=t&&e&&this.readingCheck?this.readingCheck.findingsOf(t.sighting,e):[],a=[...s,...r],c=hL.of(a);this.readingEntry=n&&c?{group:"summary",field:"reading",label:n.readingLabel,unit:"",fromSource:!1,value:(a.length===1?n.readingChipOne:n.readingChip).replace("{verdict}",n.readingVerdict[c]).replace("{n}",String(a.length)),color:qc.VERDICT_COLOURS[c],full:a.map(u=>`${{holds:"✓",fails:"✗",untested:"?"}[u.outcome]} ${this.said.read(u.text)??""}`+(u.outcome==="fails"?` (${n.findingAgainst[u.against??"established"]})`:"")).join(`
|
|
9918
|
-
`)}:void 0,this.summarySignature="\0",this.refreshParamSummary();const l=i.querySelector("#reading-sensitivity");if(this.readingSensible=t&&e?Rs.resultOf(t.sighting,e)!==void 0:!1,l.show(t?.sighting,e),this.showReadingBox(),!n||!c){i.querySelector("#reading-findings-list").hidden=!0,delete i.dataset.verdict;return}i.dataset.verdict=c,i.querySelector("#reading-verdict").textContent=(a.length===1?n.readingChipOne:n.readingChip).replace("{verdict}",n.readingVerdict[c]).replace("{n}",String(a.length));const h=i.querySelector("#reading-findings-list");i.querySelector("#reading-chip").setAttribute("aria-expanded","false"),h.hidden=!0,h.replaceChildren(...a.map(u=>{const d=document.createElement("li");d.dataset.outcome=u.outcome;const f=document.createElement("span");f.className="finding-mark",f.textContent={holds:"✓",fails:"✗",untested:"?"}[u.outcome],f.title=n.findingOutcome[u.outcome],f.setAttribute("aria-label",n.findingOutcome[u.outcome]);const p=document.createElement("span");if(p.textContent=this.said.read(u.text)??"",d.append(f,p),u.outcome==="fails"){const m=document.createElement("span");m.className="finding-against",m.textContent=`(${n.findingAgainst[u.against??"established"]})`,d.append(m)}return d}))}agentName(t){if("people"in t){const[e,...i]=t.people.replace(/([a-z])([A-Z])/g,"$1 $2").split(" ");return[...i,e].join(" ")}return"org"in t?t.org.replace(/([a-z])([A-Z])/g,"$1 $2"):this.observerDisplayName(t)??""}showConfrontation(t){this.confrontationList.innerHTML="",this.confrontationElement.hidden=!this.sceneElement.interpretation||!this.sceneElement.compareAccount;const e=new Intl.NumberFormat(this.language,{maximumFractionDigits:1,minimumFractionDigits:1}),i=new Intl.NumberFormat(this.language,{maximumFractionDigits:2,minimumFractionDigits:2});for(const n of t){const s=document.createElement("li");s.append(`${this.said.read(n.title)??n.sourceId}${this.colon}`);const r=[];n.separationDeg!==void 0&&r.push([(this.messages?.confrontationDirection??"").replace("{deg}",e.format(n.separationDeg)),n.disagreements.includes("direction")]),n.widthRatio!==void 0&&r.push([(this.messages?.confrontationWidth??"").replace("{ratio}",i.format(n.widthRatio)),n.disagreements.includes("width")]),n.heightRatio!==void 0&&r.push([(this.messages?.confrontationHeight??"").replace("{ratio}",i.format(n.heightRatio)),n.disagreements.includes("height")]),r.forEach(([a,c],l)=>{l>0&&s.append(" · ");const h=document.createElement("span");h.textContent=a,c&&(h.className="disagrees"),s.append(h)}),this.confrontationList.appendChild(s)}}startPending=!1;startSeconds(t){const e=jn.clock(this.getAttribute(jS)),i=this.plain(t).time;return(e?jn.elapsedSince(i===void 0?void 0:qs(i),e):void 0)??jn.delta(this.getAttribute(Y1))}selectObserver(t){const e=this.entries.find(n=>n.src===t);if(!e)return;this.currentSrc=t,this.observerSelect.value=t,this.sceneElement.documentUrl=e.src?new URL(e.src,location.href).href:void 0;const i=!this.sceneElement.ufoElement.playRequested;if(e.sighting.image?this.sceneElement.showPoster(e.sighting.image,e.src?new URL(e.src,location.href).href:void 0,i):this.sceneElement.showPoster(this.caseSource?.json.image,this.caseSource?.url,i),this.sceneElement.holdForNewScene(),this.sceneElement.sightingData=e.sighting,this.readingScene=!1,this.startPending){this.startPending=!1;const n=this.startSeconds(e);n!==void 0&&(this.sceneElement.ufoElement.currentTime=Math.max(0,n)*1e3)}this.offerInterpretations(e),this.updateAccountLine(),this.refreshParamSummary(),this.runAssessments(),this.infoOpen&&this.populateInfoPanel(),this.dispatchEvent(new CustomEvent(HM,{detail:{src:t}}))}async runAssessments(){if(!this.messages)return;const t=++this.assessmentToken,e=await new ky(this.messages).read(this.sceneElement.ufoElement.sighting);t===this.assessmentToken&&(this.assessmentEntries=e.entries,this.refreshParamSummary())}updateAccountLine(){const t=this.entries.find(a=>a.src===this.currentSrc),e=t?this.observerDisplayName(this.plain(t).observer):void 0,i=e!==void 0||this.entries.length>1;this.accountElement.hidden=!i,this.observerText.textContent=e??"";const s=!this.hasAttribute(T0)&&this.caseSource&&(this.said.read(this.caseSource.json.title)??this.caseSource.json.id);this.caseOfElement.hidden=!s,this.caseOfElement.textContent=s?`${this.messages?.case??""} ${s}`:"";const r=e!==void 0?`${this.messages?.accountBy??""} ${e}`.trim():void 0;this.sceneElement.filmName=[s||void 0,r].filter(Boolean).join(" - ")||void 0,this.editLink.hidden=!this.currentSrc,this.editLink.href=this.editorUrl(),this.editLink.title=this.messages?.editThisObservation??"",this.editLink.setAttribute("aria-label",this.messages?.editThisObservation??"")}caseTitleOf(t){const e=this.caseSource;if(!e)return;const i=e.json.events?.find(n=>n.url!==void 0&&!n.interpretationOf&&new URL(n.url,e.url).href===new URL(t.src,location.href).href);return i?this.said.read(i.title):void 0}observerDisplayName(t){if(!t)return;const e=[...t.firstNames??[],t.lastName].filter(Boolean).join(" ");return this.said.read(t.title)||e||t.id}plainRecordings=new WeakMap;plain(t){return this.stripped(t).recording}stripped(t){let e=this.plainRecordings.get(t.sighting);return e||(e=Je.strip(t.sighting),this.plainRecordings.set(t.sighting,e)),e}basisOf(t,e){const i=this.stripped(t).provenance,n={established:-2,measured:-1,stated:0,derived:1,assumed:2,fitted:3},s=i.paths().filter(c=>e.some(l=>c===l||c.startsWith(`${l}.`))).map(c=>i.at(c)),r=s.reduce((c,l)=>n[l.basis]>n[c]?l.basis:c,"stated"),a=s.filter(c=>c.basis===r&&c.rationale).map(c=>this.said.read(c.rationale)??"").filter(c=>c!=="");return{basis:r,rationales:a}}formatDate(t){const e=t.place?.locations?.[0],i=so((t.time?qs(t.time):void 0)??{},e?.lng??0,t.utcOffsetHours);if(!i)return;const n=i.getTime()+this.utcOffsetHoursOf(t,e?.lng??0)*36e5;if(Number.isFinite(n))return new Intl.DateTimeFormat(this.language,{dateStyle:"long",timeStyle:"short",timeZone:"UTC"}).format(new Date(n))}utcOffsetHoursOf(t,e){return t.utcOffsetHours??Math.round(e/15)}formatLocation(t){const e=t.place?.locations?.[0];if(e)return`${e.lat.toFixed(4)}, ${e.lng.toFixed(4)}`}toggleInfoPanel(){const t=!this.infoOpen;if(this.supportsPopover){const e=this.infoPanel.matches(":popover-open");t&&!e?this.infoPanel.showPopover():!t&&e&&this.infoPanel.hidePopover();return}t&&this.bringInfoButtonIntoView(),this.syncInfoOpen(t),this.infoPanel.hidden=!t,t?document.addEventListener("click",this.handleOutsideClick):document.removeEventListener("click",this.handleOutsideClick)}bringInfoButtonIntoView(){const t=this.infoButton.getBoundingClientRect(),e=window.innerHeight||document.documentElement.clientHeight;t.top>=0&&t.bottom<=e||this.infoButton.scrollIntoView({block:"center"})}syncInfoOpen(t){t!==this.infoOpen&&(this.infoOpen=t,this.infoButton.setAttribute("aria-expanded",String(t)),t?this.supportsPopover||this.populateInfoPanel():(this.creditsOpen=!1,this.infoCreditsList.hidden=!0,this.infoCreditsToggle.setAttribute("aria-expanded","false")))}handleOutsideClick=t=>{const e=t.composedPath();!e.includes(this.infoPanel)&&!e.includes(this.infoButton)&&this.toggleInfoPanel()};toggleCredits(){this.creditsOpen=!this.creditsOpen,this.infoCreditsList.hidden=!this.creditsOpen,this.infoCreditsToggle.setAttribute("aria-expanded",String(this.creditsOpen)),this.creditsOpen&&this.revealInPanel(this.infoCreditsList)}revealInPanel(t){t.scrollIntoView?.({block:"nearest"})}get showLabels(){return this.labelsShown}set showLabels(t){this.toggleAttribute("show-labels",t)}applyLabels(t){this.labelsShown=t,this.syncLabelsToggle(),this.refreshParamSummary(),this.populateInfoPanel()}syncLabelsToggle(){const t=this.labelsShown?this.messages?.hideLabels??"":this.messages?.showLabels??"";this.labelsToggle.title=t,this.labelsToggle.setAttribute("aria-label",t),this.labelsToggle.setAttribute("aria-pressed",String(this.labelsShown))}showReadingBox(){const t=this.readingFindingsElement,e=this.readingEntry!==void 0&&!this.labelsShown;t.hidden=!e&&!this.readingSensible,t.querySelector("#reading-chip").hidden=!e,e||(t.querySelector("#reading-findings-list").hidden=!0)}refreshParamSummary(){if(this.paramSummary.hidden=!this.labelsShown,this.showReadingBox(),!this.labelsShown){this.paramSummary.replaceChildren(),this.summarySignature="";return}const t=this.sceneElement.ufoElement.sighting,e=this.summaryBuilder?.entriesFor(t,this.sceneElement.ufoElement.currentTime,{roadGradeDeg:this.sceneElement.roadGradeDeg})??[],i=e.map(l=>l.group).lastIndexOf("summary"),n=this.readingEntry?[this.readingEntry]:[],s=[...e.slice(0,i+1),...n,...e.slice(i+1),...this.assessmentEntries],r=s.map(l=>`${l.field}=${l.label}=${l.value}${l.unit}${l.full??""}${l.fromSource?"*":""}`).join("|");if(r===this.summarySignature)return;this.summarySignature=r;const a=[];let c;for(const l of s){c&&c.group!==l.group&&(c=void 0);const h=l.group==="summary"?this.messages?.summaryGroup??"":l.group==="observer"?this.messages?.observerGroup??"":this.messages&&l.group in this.messages.summaryGroups?this.messages.summaryGroups[l.group]:l.group==="assessment"?this.messages?.assessmentGroup??"":void 0;if(h!==void 0&&!c){const d=document.createElement("span");d.className="param-nest";const f=document.createElement("span");f.className="param-nest-label",f.textContent=h,d.append(f),c={group:l.group,element:d},a.push(d)}const u=this.paramItem(l);c?c.element.append(u):a.push(u)}this.paramSummary.replaceChildren(...a),this.syncDescription(s)}openDescription;openDescriptionTitle;syncDescription(t){this.openDescription!==void 0&&!t.some(e=>e.full===this.openDescription)&&(this.openDescription=void 0),SE.sync(this.paramSummary,this.openDescription,this.openDescriptionTitle??this.messages?.summaryDescription??"",this.messages?.closeDescription??"",()=>{this.openDescription=void 0,this.syncDescription(t)})}paramItem(t){const e=document.createElement("span");if(e.className=t.fromSource?"param-label from-source":"param-label",t.detail&&(e.title=t.detail),t.full!==void 0){e.classList.add("describable"),e.tabIndex=0,e.setAttribute("role","button");const s=()=>{this.openDescription=t.full,this.openDescriptionTitle=t.label,this.syncDescription([t])};e.addEventListener("click",s),e.addEventListener("keydown",r=>{(r.key==="Enter"||r.key===" ")&&(r.preventDefault(),s())})}const i=document.createElement("span");if(i.className="param-label-label",i.textContent=`${t.label} `,e.append(i),t.color!==void 0){const s=document.createElement("span");s.className="param-label-swatch",s.style.background=t.color,e.append(s)}const n=document.createElement("span");return n.className="param-label-value",n.textContent=t.unit===""?t.value:`${t.value} ${t.unit}`,e.append(n),e}populateInfoPanel(){const t=this.entries.find(e=>e.src===this.currentSrc);if(this.infoObservationList.innerHTML="",t){const e=this.caseSource&&(this.caseSource.json.title??this.caseSource.json.id);if(e&&this.appendInfoRow(this.infoObservationList,this.messages?.case??"",e),!this.labelsShown){const s=this.formatDate(this.plain(t));s&&this.appendInfoRow(this.infoObservationList,this.messages?.date??"",s,this.basisOf(t,qc.DATE_PATHS));const r=this.formatLocation(this.plain(t));r&&this.appendInfoRow(this.infoObservationList,this.messages?.location??"",r,this.basisOf(t,qc.PLACE_PATHS))}const i=this.said.read(this.plain(t).description);i&&!this.labelsShown&&this.appendInfoRow(this.infoObservationList,this.messages?.description??"",i);for(const s of this.plain(t).sources??[])this.appendInfoSource(this.infoObservationList,this.messages?.source??"",s);const n=this.plain(t).tags;!this.labelsShown&&n&&n.length>0&&this.appendInfoRow(this.infoObservationList,this.messages?.tags??"",n.map(s=>this.tags.name(s)).join(", "))}this.infoAppLink.href=_0,this.infoAppLink.textContent="UFO@home v0.188.0",qn.fill(this.infoCreditsList,this.sceneElement)}appendInfoSource(t,e,i){const n=document.createElement("dt");n.textContent=e;const s=document.createElement("dd"),r=this.said.read(i.title)??i.url??"";if(i.url&&/^https?:\/\//i.test(i.url)){const c=document.createElement("a");c.href=i.url,c.target="_blank",c.rel="noopener noreferrer",c.textContent=r,s.appendChild(c)}else s.append(r);const a=[i.authors?.join(", "),i.publication?.publisher,i.publication?.time,i.index].filter(Boolean);a.length>0&&s.append(`, ${a.join(", ")}`),t.append(n,s)}static DATE_PATHS=["time","utcOffsetHours","timeZone"];static PLACE_PATHS=["place"];appendInfoRow(t,e,i,n){if(!this.messages)return;const s=document.createElement("dt");s.textContent=e;const r=document.createElement("dd");if(r.textContent=i,n){const a=document.createElement("span");a.className=`basis basis-${n.basis}`,a.textContent=this.messages.basis[n.basis],n.rationales.length>0&&(a.title=n.rationales.join(`
|
|
9916
|
+
`;class ml extends HTMLElement{static TAG="rr0-share-dialog";static register(){customElements.get(ml.TAG)||customElements.define(ml.TAG,ml)}subject;messages;languageToken=0;shadow;dialog;linkField;copyButton;linkBox;embedBox;linkOption;embedOption;pin;embedMarkup;noteElement;codeEditor;codeLoading;constructor(){super(),this.shadow=this.attachShadow({mode:"open"}),this.shadow.innerHTML=Qk;const t=e=>this.shadow.getElementById(e);this.dialog=t("dialog"),this.linkField=t("link"),this.copyButton=t("copy"),this.linkBox=t("link-box"),this.embedBox=t("embed-box"),this.linkOption=t("link-option"),this.embedOption=t("embed-option"),this.pin=t("pin"),this.embedMarkup=t("embed-markup"),this.noteElement=t("note"),t("close").addEventListener("click",()=>this.close()),this.dialog.addEventListener("click",e=>{e.target===this.dialog&&this.close()}),this.linkOption.addEventListener("click",()=>this.show("link")),this.embedOption.addEventListener("click",()=>this.show("embed")),this.pin.addEventListener("change",()=>this.refresh()),this.copyButton.addEventListener("click",()=>void(this.embedBox.hidden?this.copy(this.linkField.value,this.linkField):this.copy(this.codeEditor?.text??this.embedMarkup.value,this.embedMarkup))),this.applyMessages()}async useLanguage(t){const e=++this.languageToken,i=await zT.load(t);if(e===this.languageToken)return this.messages=i,this.applyMessages(),i}set note(t){this.noteElement.textContent=t??"",this.noteElement.hidden=t===void 0}get isOpen(){return this.dialog.open||this.dialog.hasAttribute("open")}open(){this.refresh(),this.show("link"),typeof this.dialog.showModal=="function"?this.dialog.showModal():this.dialog.setAttribute("open",""),this.fitLink(),requestAnimationFrame(()=>this.fitLink()),this.linkField.select()}close(){typeof this.dialog.close=="function"?this.dialog.close():this.dialog.removeAttribute("open")}refresh(){const t=this.subject;if(!t)return;const e=this.pin.checked;this.linkField.value=e?xa.pinnedLink(t.link(),"0.188.1"):t.link(),this.fitLink();const n=`<script type="module" src="${e?xa.pinned(t.module,"0.188.1"):xa.current(t.module,import.meta.url,Su.home())}"><\/script>
|
|
9917
|
+
${t.element()}`;this.embedMarkup.value=n,this.codeEditor&&(this.codeEditor.text=n)}applyMessages(){const t=this.messages;if(!t)return;const e=(i,n)=>{this.shadow.getElementById(i).textContent=n};e("title",t.share),e("link-label",t.link),e("embed-label",t.embed),e("copy",t.copy),e("pin-label",t.pin.replace("{version}","0.188.1")),this.pin.parentElement.title=t.pinHint,this.shadow.getElementById("close").setAttribute("aria-label",t.close),this.linkField.setAttribute("aria-label",t.link)}show(t){this.linkBox.hidden=t!=="link",this.embedBox.hidden=t!=="embed",this.linkOption.setAttribute("aria-pressed",String(t==="link")),this.embedOption.setAttribute("aria-pressed",String(t==="embed")),t==="embed"?this.loadCodeEditor():this.fitLink()}fitLink(){this.linkField.style.height="auto",this.linkField.style.height=`${this.linkField.scrollHeight}px`}loadCodeEditor(){this.codeLoading??=st(async()=>{const{ShareCodeEditor:t}=await import("./ShareCodeEditor-C53SBK2N.js");return{ShareCodeEditor:t}},[],import.meta.url).then(({ShareCodeEditor:t})=>{this.codeEditor=new t(this.shadow.getElementById("embed-code"),this.embedMarkup.value,e=>{this.embedMarkup.value=e},this.messages?.embed??""),this.embedMarkup.hidden=!0}).catch(()=>{this.codeLoading=void 0})}async copy(t,e){try{await navigator.clipboard.writeText(t),this.copyButton.textContent=this.messages?.copied??"",window.setTimeout(()=>this.copyButton.textContent=this.messages?.copy??"",1500)}catch{e.select()}}}class jn{static PLAIN=/^\d+(?:[.,]\d+)?$/;static COLONS=/^(?:(\d+):)?(\d{1,2}):(\d{1,2}(?:[.,]\d+)?)$/;static UNITS=/^(?:(\d+(?:[.,]\d+)?)h)?(?:(\d+(?:[.,]\d+)?)m)?(?:(\d+(?:[.,]\d+)?)s)?$/i;static CLOCK=/^(?:(\d{4})-(\d{2})-(\d{2})[T ])?T?(\d{1,2}):(\d{2})(?::(\d{2}(?:[.,]\d+)?))?$/;static num(t){return t===void 0?0:Number(t.replace(",","."))}static delta(t){const e=(t??"").trim();if(e==="")return;if(jn.PLAIN.test(e))return jn.num(e);const i=jn.COLONS.exec(e);if(i){const[,s,r,a]=i;return Number(r)>=60||jn.num(a)>=60?void 0:jn.num(s)*3600+Number(r)*60+jn.num(a)}const n=jn.UNITS.exec(e);return n&&(n[1]!==void 0||n[2]!==void 0||n[3]!==void 0)?jn.num(n[1])*3600+jn.num(n[2])*60+jn.num(n[3]):/^P/i.test(e)?Xh.seconds(e.toUpperCase()):void 0}static isClock(t){return jn.clock(t)!==void 0}static clock(t){const e=jn.CLOCK.exec((t??"").trim());if(!e)return;const[,i,n,s,r,a,c]=e,l={hour:Number(r),minute:Number(a),second:jn.num(c)};if(!(l.hour>=24||l.minute>=60||l.second>=60)){if(i!==void 0){const h={year:Number(i),month:Number(n),day:Number(s)};if(h.month<1||h.month>12||h.day<1||h.day>31)return;l.date=h}return l}}static elapsedSince(t,e){if(!t||t.hour===void 0||t.minute===void 0)return;const i=t.hour*3600+t.minute*60+(t.second??0),n=e.hour*3600+e.minute*60+e.second;if(e.date){if(t.year===void 0||t.month===void 0||t.day===void 0)return;const r=Date.UTC(e.date.year,e.date.month-1,e.date.day)/1e3+n,a=Date.UTC(t.year,t.month-1,t.day)/1e3+i;return Math.max(0,r-a)}let s=n-i;return s<=-43200&&(s+=86400),Math.max(0,s)}}jy();ml.register();const _0=Su.home(),r0="compare-account",Y1="start-time",jS="start-clock",Kc="observer",T0="case-named",Fd="show-info",R0="interpretation",Vh="hide-pickers",a0="case",ld="account",o0="variant-",K1=`${_0}/edit/`;class qc extends HTMLElement{static get observedAttributes(){return["src","show-labels",Fd,Vh,R0,T0,Y1,jS,Kc,Pa,La,r0]}shadow;sceneElement;toolbarElement;accountElement;accountPrefix;caseOfElement;observerText;observerSelect;infoButton;infoPanel;infoAppLink;editLink;readingFindingsElement;readingSensible=!1;readingCheck;bestCases;readingScene=!1;readingEntry;static VERDICT_COLOURS={incompatible:"#e04848",unsettled:"#e08a2c",compatible:"#2e9d5b"};infoObservationHeading;infoObservationList;infoCreditsToggle;infoCreditsList;infoCloseButton;shareButton;shareDialog;shareStartOn;shareStart;shareScopeRow;shareScopeLabel;shareScope;shareOpensRow;shareOpensLabel;shareOpens;shareStartLabel;shareOptions;labelsToggle;paramSummary;summaryBuilder;summarySignature="";assessmentEntries=[];assessmentToken=0;supportsPopover=typeof HTMLElement.prototype.showPopover=="function";entries=[];caseSource;interpretationChoice;interpretationLabel;interpretationSelect;confrontationElement;confrontationHeading;confrontationList;compareButton;variantChips;variantMoved;interpretationLoaders=new Map;interpretationToken=0;shownInterpretation;offeredFor;currentSrc;infoOpen=!1;creditsOpen=!1;labelsShown=!1;language="en";messages;ready=Promise.resolve();constructor(){super(),this.shadow=this.attachShadow({mode:"open"});const t=document.createElement("template");t.innerHTML=`<style>${YT}</style>${$T}`,this.shadow.appendChild(t.content.cloneNode(!0)),customElements.upgrade(this.shadow),this.sceneElement=document.createElement(_f),this.forwardPlayerAttributes(),this.sceneElement.ufoElement.creditShownExternally=!0,this.sceneElement.ownCredits=!1,this.shadow.getElementById("ufo-slot").replaceWith(this.sceneElement),this.toolbarElement=this.shadow.getElementById("toolbar"),this.accountElement=this.shadow.getElementById("account"),this.accountPrefix=this.shadow.getElementById("account-prefix"),this.caseOfElement=this.shadow.getElementById("case-of"),this.observerText=this.shadow.getElementById("observer-text"),this.observerSelect=this.shadow.getElementById("observer"),this.infoButton=this.shadow.getElementById("info-button"),this.infoPanel=this.shadow.getElementById("info-panel"),this.infoAppLink=this.shadow.getElementById("info-app-link"),this.editLink=this.shadow.getElementById("edit-link"),this.infoObservationHeading=this.shadow.getElementById("info-observation-heading"),this.infoObservationList=this.shadow.getElementById("info-observation-list"),this.infoCreditsToggle=this.shadow.getElementById("info-credits-toggle"),this.infoCreditsList=this.shadow.getElementById("info-credits-list"),this.infoCloseButton=this.shadow.getElementById("info-close"),this.labelsToggle=this.shadow.getElementById("labels-button"),this.paramSummary=this.shadow.getElementById("param-summary"),this.labelsToggle.addEventListener("click",()=>{this.showLabels=!this.showLabels}),this.shareButton=document.createElement("button"),this.shareButton.type="button",this.shareButton.id="share-button",this.shareButton.setAttribute("aria-haspopup","dialog"),this.shareButton.innerHTML=qt.SHARE,this.sceneElement.ufoElement.addControl(this.shareButton),this.shareDialog=this.shadow.getElementById("share-dialog"),this.shareDialog.subject=this.shareSubject,this.shareStartOn=this.shadow.getElementById("share-start-on"),this.shareStart=this.shadow.getElementById("share-start"),this.shareStartLabel=this.shadow.getElementById("share-start-label"),this.shareScopeRow=this.shadow.getElementById("share-scope-row"),this.shareScopeLabel=this.shadow.getElementById("share-scope-label"),this.shareScope=this.shadow.getElementById("share-scope"),this.shareOpensRow=this.shadow.getElementById("share-opens-row"),this.shareOpensLabel=this.shadow.getElementById("share-opens-label"),this.shareOpens=this.shadow.getElementById("share-opens");const e=n=>({input:this.shadow.getElementById(`share-opt-${n}`),label:this.shadow.getElementById(`share-opt-${n}-label`)});this.shareOptions={labels:e("labels"),map:e("map"),milestones:e("milestones"),compare:e("compare")},this.interpretationChoice=this.shadow.getElementById("interpretation-choice"),this.interpretationLabel=this.shadow.getElementById("interpretation-label"),this.interpretationSelect=this.shadow.getElementById("interpretation"),this.confrontationElement=this.shadow.getElementById("confrontation"),this.confrontationHeading=this.shadow.getElementById("confrontation-heading"),this.confrontationList=this.shadow.getElementById("confrontation-list"),Rs.register(),this.readingFindingsElement=this.shadow.getElementById("reading-findings");const i=this.shadow.getElementById("reading-chip");i.addEventListener("click",()=>{const n=i.getAttribute("aria-expanded")!=="true";i.setAttribute("aria-expanded",String(n)),this.shadow.getElementById("reading-findings-list").hidden=!n}),this.compareButton=this.shadow.getElementById("compare-account"),this.variantChips=this.shadow.getElementById("variant-chips"),this.variantMoved=this.shadow.getElementById("variant-moved"),this.compareButton.addEventListener("click",()=>this.setComparing(!this.sceneElement.compareAccount)),this.observerSelect.addEventListener("change",()=>this.selectObserver(this.observerSelect.value)),this.interpretationSelect.addEventListener("change",()=>void this.chooseInterpretation(this.interpretationSelect.value)),this.sceneElement.addEventListener(Jy,n=>this.showConfrontation(n.detail)),this.sceneElement.ufoElement.addEventListener("timeupdate",()=>this.refreshParamSummary()),this.supportsPopover?(this.infoPanel.setAttribute("popover","auto"),this.infoPanel.removeAttribute("hidden"),this.infoButton.setAttribute("popovertarget","info-panel"),this.infoPanel.addEventListener("beforetoggle",n=>{n.newState==="open"&&(this.populateInfoPanel(),this.bringInfoButtonIntoView())}),this.infoPanel.addEventListener("toggle",n=>this.syncInfoOpen(n.newState==="open"))):this.infoButton.addEventListener("click",()=>this.toggleInfoPanel()),this.infoCloseButton.addEventListener("click",()=>this.toggleInfoPanel()),this.infoCreditsToggle.addEventListener("click",()=>this.toggleCredits()),this.shareButton.addEventListener("click",()=>this.openShare());for(const n of[this.shareStartOn,this.shareStart,...Object.values(this.shareOptions).map(s=>s.input)])n.addEventListener("input",()=>this.refreshShareLinks());for(const n of[this.shareScope,this.shareOpens])n.addEventListener("change",()=>this.refreshShareLinks());this.isConnected&&(this.ready=this.loadLocaleMessages())}get scene(){return this.sceneElement}async loadLocaleMessages(){const t=++this.localeToken,e=Ks.preferencesFor(this);this.preferences=e;const i=Mo(e,yo),[n,s,r,a]=await Promise.all([LT.load(i),BT(i),xE(i),lL.load(i)]);if(t!==this.localeToken)return;const c=i!==this.language||this.messages===void 0;this.language=i,this.messages=n,this.readingCheck=new pn(a),this.bestCases=new ie(a),this.tags=new dM(s),this.said=new es(e),this.summaryBuilder=new Vc(this.messages,new BM(r),this.said,this.tags,{messages:this.messages,locale:i}),this.accountPrefix.textContent=this.messages?.accountBy??"",this.interpretationLabel.textContent=this.messages?.interpretation??"",this.confrontationHeading.textContent=this.messages?.confrontation??"";const l=this.entries.find(h=>h.src===this.currentSrc);l&&this.offerInterpretations(l),this.updateCompareButton(),this.infoButton.title=this.messages?.about??"",this.infoButton.setAttribute("aria-label",this.messages?.about??""),this.editLink.title=this.messages?.editThisObservation??"",this.editLink.setAttribute("aria-label",this.messages?.editThisObservation??""),this.infoCloseButton.setAttribute("aria-label",this.messages?.close??""),this.infoObservationHeading.textContent=this.messages?.observation??"",this.infoCreditsToggle.textContent=this.messages?.credits??"",this.syncLabelsToggle(),this.refreshParamSummary(),c&&this.currentSrc&&this.runAssessments(),this.shareButton.title=this.messages?.share??"",this.shareButton.setAttribute("aria-label",this.messages?.share??""),this.shareStartLabel.textContent=this.messages?.shareStartAt??"",this.shareScopeLabel.textContent=this.messages?.shareScope??"",this.shareOpensLabel.textContent=this.messages?.shareOpensOn??"",this.shareOptions.labels.label.textContent=this.messages?.shareOptionLabels??"",this.shareOptions.map.label.textContent=this.messages?.shareOptionMap??"",this.shareOptions.milestones.label.textContent=this.messages?.shareOptionMilestones??"",this.shareOptions.compare.label.textContent=this.messages?.shareOptionCompare??"",this.shareStart.setAttribute("aria-label",this.messages?.shareStartAt??""),this.shareDialog.useLanguage(i),this.infoOpen&&this.populateInfoPanel(),this.updateAccountLine()}preferences=[];localeToken=0;said=new es(["en"]);tags=new dM({});connectedCallback(){Ks.preferencesFor(this).join()!==this.preferences.join()&&(this.ready=this.loadLocaleMessages()),this.applyAskedInfo();const t=this.getAttribute("src");t&&this.loadFromSrc(t)}applyAskedInfo(){this.isConnected&&this.hasAttribute(Fd)!==this.infoOpen&&this.toggleInfoPanel()}disconnectedCallback(){document.removeEventListener("click",this.handleOutsideClick)}attributeChangedCallback(t,e,i){if(t==="src"&&i&&i!==e&&this.isConnected&&this.loadFromSrc(i),t===R0){const n=this.entries.find(s=>s.src===this.currentSrc);n&&this.offerInterpretations(n)}if(t===Vh){const n=this.entries.find(s=>s.src===this.currentSrc);this.setEntries(this.entries,this.caseSource),n&&this.offerInterpretations(n)}if(t===Fd&&this.applyAskedInfo(),t==="show-labels"&&this.applyLabels(this.hasAttribute("show-labels")),(t===Pa||t===La)&&this.forwardPlayerAttributes(),t===Kc&&this.entries.length>1){const n=this.entryAsked(this.entries);n&&n.src!==this.currentSrc&&this.selectObserver(n.src)}t===r0&&this.setComparing(this.hasAttribute(r0))}forwardPlayerAttributes(){for(const t of[Pa,La]){const e=this.getAttribute(t);e===null?this.sceneElement.removeAttribute(t):this.sceneElement.setAttribute(t,e)}}get loaded(){return this.loading??Promise.resolve()}loading;loadFromSrc(t){const e=this.readFromSrc(t);return this.loading=e.catch(()=>{}),e}async readFromSrc(t){this.startPending=!0;const e=Ar.recording(t);this.sceneElement.holdForNewScene(e);const i=await e;if(Array.isArray(i))throw new Error(`${t} is a bare list of recordings, which is no longer read: list them as the sighting events of a case.json`);if(Ui.isCase(i)){Ui.check(i);const n=Ui.sightingUrls(i,new URL(t,location.href).href);if(n.length===0)throw new Error(`${t} is a case with no sighting event: no recording to show`);await this.loadObserverUrls(n,{json:i,url:new URL(t,location.href).href})}else this.setEntries([{src:t,sighting:i}],void 0)}get sightingData(){return this.entries.find(t=>t.src===this.currentSrc)?.sighting}set sightingData(t){const e=lr.recording(t);this.startPending=!0,this.currentSrc="",this.setEntries([{src:"",sighting:e}],void 0)}seekTo(t,e){const i=this.caseSource,n=e===void 0?void 0:this.entries.find(s=>{const r=this.plain(s).id;return(i?Ui.accountIds(i.json,i.url,s.src,r):[r]).includes(e)});n&&n.src!==this.currentSrc&&this.selectObserver(n.src),this.sceneElement.ufoElement.currentTime=Math.max(0,t)*1e3}set citedMoments(t){this.sceneElement.ufoElement.citedMoments=t}get playedSeconds(){return this.sceneElement.ufoElement.currentTime/1e3}get observerUrls(){return this.entries.map(t=>t.src)}set observerUrls(t){this.loadObserverUrls(t)}async loadObserverUrls(t,e){const i=await Promise.all(t.map(async n=>({src:n,sighting:await Ar.recording(n)})));this.setEntries(i,e)}reportCaseProblems(t,e){const{duplicateIds:i,unresolved:n}=Ui.problems(t,e.map(s=>this.plain(s).id).filter(s=>s!==void 0));for(const s of i)console.warn(`The case ${t.id??""} gives the id "${s}" to more than one event: a reference to it is ambiguous.`);for(const{reading:s,reference:r}of n)console.warn(`The reading ${s} of the case ${t.id??""} is "interpretationOf" "${r}", which no event of the case has as its id, nor any recording it lists.`)}setEntries(t,e){this.entries=t.map(r=>({...r,sighting:lr.recording(r.sighting)})),this.caseSource=e,e&&this.reportCaseProblems(e.json,t),this.toolbarElement.hidden=t.length===0;const i=t.length>1&&!this.hasAttribute(Vh);this.observerSelect.hidden=!i,this.observerText.hidden=i,this.observerSelect.innerHTML="";const n=t.map((r,a)=>this.observerDisplayName(this.plain(r).observer)??this.caseTitleOf(r)??(this.messages?.unnamedObserver??"").replace("{n}",String(a+1)));for(const[r,a]of t.entries()){const c=document.createElement("option");c.value=a.src;const l=n.filter(h=>h===n[r]).length>1;c.textContent=(l?this.caseTitleOf(a):void 0)??n[r],this.observerSelect.appendChild(c)}const s=t.find(r=>r.src===this.currentSrc)??this.entryAsked(t)??t[0];s?this.selectObserver(s.src):this.updateAccountLine()}entryAsked(t){const e=this.getAttribute(Kc)?.trim();if(!e)return;const i=t.find(r=>this.plain(r).observer?.id===e);if(i)return i;const n=this.caseSource;if(n){const r=t.find(a=>Ui.accountIds(n.json,n.url,a.src,this.plain(a).id).includes(e));if(r)return r}const s=t.find(r=>r.src.split("/").pop()===e.split("/").pop());return s||(/^\d+$/.test(e)?t[Number(e)-1]:void 0)}observerKeyOf(t){return this.plain(t).observer?.id??String(this.entries.indexOf(t)+1)}sharedEntry(){const t=this.shareScope.value;if(!(!this.caseSource||t===a0))return this.entries.find(e=>e.src===t)}get sharesCase(){return this.caseSource!==void 0&&!this.shareScopeRow.hidden&&this.shareScope.value===a0}editorUrl(){if(!this.currentSrc)return K1;const t=new URL(this.currentSrc,location.href),e=this.caseSource;return e?`${K1}?file=${encodeURIComponent(e.url)}&track=${encodeURIComponent(this.shownTrackUrl()??t.href)}`:`${K1}?file=${encodeURIComponent(t.href)}`}get editorHref(){return this.editorUrl()}shownTrackUrl(){return this.readingUrlOf(this.interpretationSelect.value)}shareSubject={module:"rr0-sighting",link:()=>this.playUrl(),element:()=>this.replayElement()};replayElement(){const t=this.sharedAddress(),i=[...t.observer?[[Kc,t.observer]]:[],...this.replayAttributes()].map(([n,s])=>s===""?` ${n}`:` ${n}="${s}"`).join("");return`<rr0-sighting src="${t.src}"${i}></rr0-sighting>`}playUrl(){const t=this.sharedAddress(),e=[...t.observer?[`${Kc}=${encodeURIComponent(t.observer)}`]:[],...this.replayQuery()].join("&");return t.src?`${_0}/play/?file=${encodeURIComponent(t.src)}${e&&"&"+e}`:`${_0}/play/${e&&"?"+e}`}sharedAddress(){const t=e=>e?new URL(e,location.href).href:"";if(this.sharesCase){const e=this.entries.find(i=>i.src===this.shareOpens.value)??this.entries.find(i=>i.src===this.currentSrc);return{src:t(this.caseSource.url),observer:e?this.observerKeyOf(e):void 0}}return{src:t(this.sharedEntry()?.src??this.currentSrc??"")}}replayAttributes(){const t=this.shareOptions,e=[];return this.shareStartSeconds!==void 0&&e.push([Y1,String(this.shareStartSeconds)]),t.labels.input.checked&&e.push(["show-labels",""]),t.map.input.checked&&e.push([Pa,""]),t.milestones.input.checked||e.push([La,""]),t.compare.input.checked&&e.push([r0,""]),e}replayQuery(){const t=this.shareOptions,e=[];return this.shareStartSeconds!==void 0&&e.push(`d=${this.shareStartSeconds}`),t.labels.input.checked||e.push("labels=0"),t.map.input.checked&&e.push("map=1"),t.milestones.input.checked||e.push("moments=0"),t.compare.input.checked&&e.push("compare=1"),e}get shareStartSeconds(){const t=Math.floor(Number(this.shareStart.value));return this.shareStartOn.checked&&Number.isFinite(t)&&t>=0?t:void 0}refreshShareLinks(){this.shareOpensRow.hidden=!this.sharesCase,this.shareDialog.refresh()}openShare(){const t=this.sceneElement.ufoElement;this.shareStart.max=String(Math.floor(t.seekableDuration/1e3)),this.shareStart.value=String(Math.floor(t.currentTime/1e3)),this.shareStartOn.checked=!1,this.shareOptions.labels.input.checked=this.labelsShown,this.shareOptions.map.input.checked=t.observerMapOpen,this.shareOptions.milestones.input.checked=t.milestonesVisible,this.shareOptions.compare.input.checked=this.sceneElement.compareAccount,this.offerShareScope(),this.shareOpensRow.hidden=!this.sharesCase,this.shareDialog.open()}offerShareScope(){const t=this.caseSource!==void 0&&this.entries.length>1&&!this.hasAttribute(T0);if(this.shareScopeRow.hidden=!t,this.shareScope.innerHTML="",this.shareOpens.innerHTML="",!t)return;const e=(i,n,s)=>{const r=document.createElement("option");r.value=n,r.textContent=s,i.appendChild(r)};e(this.shareScope,a0,this.messages?.shareScopeCase??"");for(const i of this.entries){const n=this.observerDisplayName(this.plain(i).observer)??this.caseTitleOf(i)??(this.messages?.unnamedObserver??"").replace("{n}",String(this.entries.indexOf(i)+1));e(this.shareScope,i.src,n),e(this.shareOpens,i.src,n)}this.shareScope.value=a0,this.shareOpens.value=this.currentSrc??this.entries[0].src}offerInterpretations(t){const e=this.offeredFor===t.sighting,i=this.interpretationSelect.value;this.offeredFor=t.sighting,this.interpretationToken++,this.interpretationLoaders=new Map,this.interpretationSelect.innerHTML="";const n=(u,d,f)=>{const p=document.createElement("option");p.value=u,p.textContent=d,this.interpretationSelect.appendChild(p),this.interpretationLoaders.set(u,f)},s=t===this.entries.find(u=>u.src===this.currentSrc),r=s?this.sceneElement.ufoElement.sighting.interpretation:void 0;n(ld,this.messages?.account??"",()=>Promise.resolve(r));const a=this.caseSource;a&&Ui.interpretationEvents(a.json,Ui.accountIds(a.json,a.url,t.src,this.plain(t).id)).forEach((u,d)=>{const f=this.said.read(u.title)??`#${d+1}`,p=(u.by??[]).map(m=>this.agentName(m)).filter(Boolean).join(", ");n(`case-${d}`,p?(this.messages?.interpretationBy??"").replace("{title}",f).replace("{by}",p):f,()=>Ui.interpretationOf(u,a.url,m=>Ar.recording(m)))});const c=s?this.keptVariants(t):[];for(const{index:u,kept:d}of c)n(`${o0}${u}`,`${this.variantLabel(d)} (${this.messages?.verdicts[d.variant.verdict]??""})`,()=>Promise.resolve(d.bodies.length>0?d:void 0));const l=e&&[...this.interpretationSelect.options].some(u=>u.value===i),h=this.askedInterpretation()??(l?i:ld);this.interpretationSelect.value=h,h===ld?(this.sceneElement.interpretation!==r&&(this.sceneElement.interpretation=r),this.shownInterpretation=ld):(!this.sceneElement.interpretation||this.shownInterpretation!==h)&&this.chooseInterpretation(h),this.interpretationChoice.hidden=this.interpretationSelect.options.length<2||this.hasAttribute(Vh),this.showConfrontation(this.sceneElement.confrontation),this.updateCompareButton(),this.showVariants(c)}keptVariants(t){const e={consolidated:0,contested:1,incompatible:2};return(t.sighting.variants??[]).map((i,n)=>({index:n,kept:i})).filter(({kept:i})=>i.variant).sort((i,n)=>e[i.kept.variant.verdict]-e[n.kept.variant.verdict]||i.kept.variant.cost-n.kept.variant.cost)}variantLabel(t){return(this.messages?.variant??"").replace("{name}",t.variant.label??t.variant.candidate)}showVariants(t){if(!this.messages)return;if(this.variantChips.innerHTML="",this.variantChips.hidden=t.length===0,t.length===0){this.showVariantMoved();return}const e=(i,n,s)=>{const r=document.createElement("button");r.type="button",r.dataset.value=i,s&&(r.dataset.verdict=s,r.title=this.messages.verdicts[s],r.append(Object.assign(document.createElement("span"),{className:"dot"}))),r.append(n),r.addEventListener("click",()=>{this.interpretationSelect.value!==i&&(this.interpretationSelect.value=i,this.chooseInterpretation(i))}),this.variantChips.append(r)};e(ld,this.messages?.account??"");for(const{index:i,kept:n}of t)e(`${o0}${i}`,n.variant.label??n.variant.candidate,n.variant.verdict);this.showVariantMoved()}showVariantMoved(){if(!this.messages)return;const t=this.interpretationSelect.value;for(const s of this.variantChips.querySelectorAll("button"))s.setAttribute("aria-pressed",String(s.dataset.value===t));this.variantMoved.innerHTML="";const e=t.startsWith(o0)?Number(t.slice(o0.length)):-1,i=this.sceneElement.ufoElement.sighting.variants?.[e]?.variant;if(this.variantMoved.hidden=!i||i.moved.length+(i.readings?.length??0)===0,!i)return;const n=new Intl.NumberFormat(this.language,{maximumFractionDigits:1});for(const s of i.moved){const[r,a]=s.field==="time"?["0 min",`${s.variant>0?"+":""}${n.format(s.variant)} min`]:s.field==="duration"?[`${n.format(s.stated)} s`,`${n.format(s.variant)} s`]:[`${n.format(s.stated)}°`,`${n.format(s.variant)}°`],c=document.createElement("span");c.append(`${this.messages.variantFields[s.field]}${this.colon}`,Object.assign(document.createElement("s"),{textContent:r})," → ",Object.assign(document.createElement("b"),{textContent:a})),this.variantMoved.append(c)}for(const s of i.readings??[]){const r=this.messages.variantReadings[s.reading];r&&this.variantMoved.append(Object.assign(document.createElement("span"),{className:"reading",textContent:r}))}}setComparing(t){this.sceneElement.compareAccount=t,this.updateCompareButton(),this.showConfrontation(this.sceneElement.confrontation)}updateCompareButton(){const t=this.sceneElement.compareAccount;this.compareButton.hidden=!this.sceneElement.interpretation,this.compareButton.setAttribute("aria-pressed",String(t));const e=t?this.messages?.hideComparison??"":this.messages?.showComparison??"";this.compareButton.title=e,this.compareButton.setAttribute("aria-label",e)}get colon(){return this.language==="fr"?" : ":": "}askedInterpretation(){const t=this.getAttribute(R0)?.trim(),e=this.caseSource;if(!t||!e)return;const i=this.entries.find(r=>r.src===this.currentSrc);if(!i)return;const s=Ui.interpretationEvents(e.json,Ui.accountIds(e.json,e.url,i.src,this.plain(i).id)).findIndex(r=>r.id===t||typeof r.url=="string"&&new URL(r.url,e.url).href===new URL(t,location.href).href);return s>=0?`case-${s}`:void 0}async chooseInterpretation(t){const e=++this.interpretationToken,i=this.interpretationLoaders.get(t),n=i?await i().catch(d=>{console.warn(`<rr0-sighting>: could not read interpretation "${t}":`,d)}):void 0,s=this.readingUrlOf(t),r=s?await Ar.recording(s).catch(()=>{}):void 0;if(e!==this.interpretationToken)return;const a=this.entries.find(d=>d.src===this.currentSrc),c=a&&r&&"timeline"in r?this.bestCases?.bestSceneOf(a.sighting,r):void 0,l=c??r,h=c?.interpretation&&n?{...n,bodies:[...n.bodies.map(d=>{const f=c.interpretation.bodies.find(p=>p.id===d.id);return f?{...d,track:f.track}:d}),...c.interpretation.bodies.filter(d=>!n.bodies.some(f=>f.id===d.id))]}:n,u=a&&l&&"timeline"in l&&qc.changesTheScene(a.sighting,l)?{...l,timeline:l.timeline.keyframes?.length?l.timeline:a.sighting.timeline}:void 0;if(u&&s)this.showScene(u,s);else if(this.readingScene&&a)this.showScene(a.sighting,a.src,!0);else if(a){const d=!this.sceneElement.ufoElement.playRequested;s?this.sceneElement.showPoster(r?.image,s,d):a.sighting.image?this.sceneElement.showPoster(a.sighting.image,a.src?new URL(a.src,location.href).href:void 0,d):this.sceneElement.showPoster(this.caseSource?.json.image,this.caseSource?.url,d)}this.readingScene=u!==void 0,this.sceneElement.interpretation=h,this.shownInterpretation=t,this.showReadingFindings(a,l),this.editLink.href=this.editorUrl(),this.dispatchEvent(new CustomEvent("interpretationchange",{detail:{track:this.shownTrackUrl()}})),this.updateCompareButton(),this.showConfrontation(this.sceneElement.confrontation),this.showVariantMoved()}readingUrlOf(t){const e=this.caseSource,i=this.entries.find(r=>r.src===this.currentSrc),n=/^case-(\d+)$/.exec(t);if(!e||!i||!n)return;const s=Ui.interpretationEvents(e.json,Ui.accountIds(e.json,e.url,i.src,this.plain(i).id))[Number(n[1])];return s?.url?new URL(s.url,e.url).href:void 0}static SCENE_FIELDS=["time","utcOffsetHours","place","observerTrack","weatherTrack","decor","instrument","lens","film","exposureSeconds","iso","references","lighting","lightPollution","vehicle"];static changesTheScene(t,e){const i=n=>JSON.stringify(qc.SCENE_FIELDS.map(s=>n[s]));return i(t)!==i(e)}showScene(t,e,i=!1){const n=this.sceneElement.ufoElement.currentTime;this.sceneElement.documentUrl=e?new URL(e,location.href).href:void 0;const s=!this.sceneElement.ufoElement.playRequested,r=e?new URL(e,location.href).href:void 0;t.image?this.sceneElement.showPoster(t.image,r,s):i?this.sceneElement.showPoster(this.caseSource?.json.image,this.caseSource?.url,s):this.sceneElement.showPoster(void 0,void 0,s),this.sceneElement.sightingData=t,this.sceneElement.ufoElement.currentTime=n}showReadingFindings(t,e){const i=this.readingFindingsElement,n=this.messages,s=e?.interpretation?.findings??[],r=t&&e&&this.readingCheck?this.readingCheck.findingsOf(t.sighting,e):[],a=[...s,...r],c=hL.of(a);this.readingEntry=n&&c?{group:"summary",field:"reading",label:n.readingLabel,unit:"",fromSource:!1,value:(a.length===1?n.readingChipOne:n.readingChip).replace("{verdict}",n.readingVerdict[c]).replace("{n}",String(a.length)),color:qc.VERDICT_COLOURS[c],full:a.map(u=>`${{holds:"✓",fails:"✗",untested:"?"}[u.outcome]} ${this.said.read(u.text)??""}`+(u.outcome==="fails"?` (${n.findingAgainst[u.against??"established"]})`:"")).join(`
|
|
9918
|
+
`)}:void 0,this.summarySignature="\0",this.refreshParamSummary();const l=i.querySelector("#reading-sensitivity");if(this.readingSensible=t&&e?Rs.resultOf(t.sighting,e)!==void 0:!1,l.show(t?.sighting,e),this.showReadingBox(),!n||!c){i.querySelector("#reading-findings-list").hidden=!0,delete i.dataset.verdict;return}i.dataset.verdict=c,i.querySelector("#reading-verdict").textContent=(a.length===1?n.readingChipOne:n.readingChip).replace("{verdict}",n.readingVerdict[c]).replace("{n}",String(a.length));const h=i.querySelector("#reading-findings-list");i.querySelector("#reading-chip").setAttribute("aria-expanded","false"),h.hidden=!0,h.replaceChildren(...a.map(u=>{const d=document.createElement("li");d.dataset.outcome=u.outcome;const f=document.createElement("span");f.className="finding-mark",f.textContent={holds:"✓",fails:"✗",untested:"?"}[u.outcome],f.title=n.findingOutcome[u.outcome],f.setAttribute("aria-label",n.findingOutcome[u.outcome]);const p=document.createElement("span");if(p.textContent=this.said.read(u.text)??"",d.append(f,p),u.outcome==="fails"){const m=document.createElement("span");m.className="finding-against",m.textContent=`(${n.findingAgainst[u.against??"established"]})`,d.append(m)}return d}))}agentName(t){if("people"in t){const[e,...i]=t.people.replace(/([a-z])([A-Z])/g,"$1 $2").split(" ");return[...i,e].join(" ")}return"org"in t?t.org.replace(/([a-z])([A-Z])/g,"$1 $2"):this.observerDisplayName(t)??""}showConfrontation(t){this.confrontationList.innerHTML="",this.confrontationElement.hidden=!this.sceneElement.interpretation||!this.sceneElement.compareAccount;const e=new Intl.NumberFormat(this.language,{maximumFractionDigits:1,minimumFractionDigits:1}),i=new Intl.NumberFormat(this.language,{maximumFractionDigits:2,minimumFractionDigits:2});for(const n of t){const s=document.createElement("li");s.append(`${this.said.read(n.title)??n.sourceId}${this.colon}`);const r=[];n.separationDeg!==void 0&&r.push([(this.messages?.confrontationDirection??"").replace("{deg}",e.format(n.separationDeg)),n.disagreements.includes("direction")]),n.widthRatio!==void 0&&r.push([(this.messages?.confrontationWidth??"").replace("{ratio}",i.format(n.widthRatio)),n.disagreements.includes("width")]),n.heightRatio!==void 0&&r.push([(this.messages?.confrontationHeight??"").replace("{ratio}",i.format(n.heightRatio)),n.disagreements.includes("height")]),r.forEach(([a,c],l)=>{l>0&&s.append(" · ");const h=document.createElement("span");h.textContent=a,c&&(h.className="disagrees"),s.append(h)}),this.confrontationList.appendChild(s)}}startPending=!1;startSeconds(t){const e=jn.clock(this.getAttribute(jS)),i=this.plain(t).time;return(e?jn.elapsedSince(i===void 0?void 0:qs(i),e):void 0)??jn.delta(this.getAttribute(Y1))}selectObserver(t){const e=this.entries.find(n=>n.src===t);if(!e)return;this.currentSrc=t,this.observerSelect.value=t,this.sceneElement.documentUrl=e.src?new URL(e.src,location.href).href:void 0;const i=!this.sceneElement.ufoElement.playRequested;if(e.sighting.image?this.sceneElement.showPoster(e.sighting.image,e.src?new URL(e.src,location.href).href:void 0,i):this.sceneElement.showPoster(this.caseSource?.json.image,this.caseSource?.url,i),this.sceneElement.holdForNewScene(),this.sceneElement.sightingData=e.sighting,this.readingScene=!1,this.startPending){this.startPending=!1;const n=this.startSeconds(e);n!==void 0&&(this.sceneElement.ufoElement.currentTime=Math.max(0,n)*1e3)}this.offerInterpretations(e),this.updateAccountLine(),this.refreshParamSummary(),this.runAssessments(),this.infoOpen&&this.populateInfoPanel(),this.dispatchEvent(new CustomEvent(HM,{detail:{src:t}}))}async runAssessments(){if(!this.messages)return;const t=++this.assessmentToken,e=await new ky(this.messages).read(this.sceneElement.ufoElement.sighting);t===this.assessmentToken&&(this.assessmentEntries=e.entries,this.refreshParamSummary())}updateAccountLine(){const t=this.entries.find(a=>a.src===this.currentSrc),e=t?this.observerDisplayName(this.plain(t).observer):void 0,i=e!==void 0||this.entries.length>1;this.accountElement.hidden=!i,this.observerText.textContent=e??"";const s=!this.hasAttribute(T0)&&this.caseSource&&(this.said.read(this.caseSource.json.title)??this.caseSource.json.id);this.caseOfElement.hidden=!s,this.caseOfElement.textContent=s?`${this.messages?.case??""} ${s}`:"";const r=e!==void 0?`${this.messages?.accountBy??""} ${e}`.trim():void 0;this.sceneElement.filmName=[s||void 0,r].filter(Boolean).join(" - ")||void 0,this.editLink.hidden=!this.currentSrc,this.editLink.href=this.editorUrl(),this.editLink.title=this.messages?.editThisObservation??"",this.editLink.setAttribute("aria-label",this.messages?.editThisObservation??"")}caseTitleOf(t){const e=this.caseSource;if(!e)return;const i=e.json.events?.find(n=>n.url!==void 0&&!n.interpretationOf&&new URL(n.url,e.url).href===new URL(t.src,location.href).href);return i?this.said.read(i.title):void 0}observerDisplayName(t){if(!t)return;const e=[...t.firstNames??[],t.lastName].filter(Boolean).join(" ");return this.said.read(t.title)||e||t.id}plainRecordings=new WeakMap;plain(t){return this.stripped(t).recording}stripped(t){let e=this.plainRecordings.get(t.sighting);return e||(e=Je.strip(t.sighting),this.plainRecordings.set(t.sighting,e)),e}basisOf(t,e){const i=this.stripped(t).provenance,n={established:-2,measured:-1,stated:0,derived:1,assumed:2,fitted:3},s=i.paths().filter(c=>e.some(l=>c===l||c.startsWith(`${l}.`))).map(c=>i.at(c)),r=s.reduce((c,l)=>n[l.basis]>n[c]?l.basis:c,"stated"),a=s.filter(c=>c.basis===r&&c.rationale).map(c=>this.said.read(c.rationale)??"").filter(c=>c!=="");return{basis:r,rationales:a}}formatDate(t){const e=t.place?.locations?.[0],i=so((t.time?qs(t.time):void 0)??{},e?.lng??0,t.utcOffsetHours);if(!i)return;const n=i.getTime()+this.utcOffsetHoursOf(t,e?.lng??0)*36e5;if(Number.isFinite(n))return new Intl.DateTimeFormat(this.language,{dateStyle:"long",timeStyle:"short",timeZone:"UTC"}).format(new Date(n))}utcOffsetHoursOf(t,e){return t.utcOffsetHours??Math.round(e/15)}formatLocation(t){const e=t.place?.locations?.[0];if(e)return`${e.lat.toFixed(4)}, ${e.lng.toFixed(4)}`}toggleInfoPanel(){const t=!this.infoOpen;if(this.supportsPopover){const e=this.infoPanel.matches(":popover-open");t&&!e?this.infoPanel.showPopover():!t&&e&&this.infoPanel.hidePopover();return}t&&this.bringInfoButtonIntoView(),this.syncInfoOpen(t),this.infoPanel.hidden=!t,t?document.addEventListener("click",this.handleOutsideClick):document.removeEventListener("click",this.handleOutsideClick)}bringInfoButtonIntoView(){const t=this.infoButton.getBoundingClientRect(),e=window.innerHeight||document.documentElement.clientHeight;t.top>=0&&t.bottom<=e||this.infoButton.scrollIntoView({block:"center"})}syncInfoOpen(t){t!==this.infoOpen&&(this.infoOpen=t,this.infoButton.setAttribute("aria-expanded",String(t)),t?this.supportsPopover||this.populateInfoPanel():(this.creditsOpen=!1,this.infoCreditsList.hidden=!0,this.infoCreditsToggle.setAttribute("aria-expanded","false")))}handleOutsideClick=t=>{const e=t.composedPath();!e.includes(this.infoPanel)&&!e.includes(this.infoButton)&&this.toggleInfoPanel()};toggleCredits(){this.creditsOpen=!this.creditsOpen,this.infoCreditsList.hidden=!this.creditsOpen,this.infoCreditsToggle.setAttribute("aria-expanded",String(this.creditsOpen)),this.creditsOpen&&this.revealInPanel(this.infoCreditsList)}revealInPanel(t){t.scrollIntoView?.({block:"nearest"})}get showLabels(){return this.labelsShown}set showLabels(t){this.toggleAttribute("show-labels",t)}applyLabels(t){this.labelsShown=t,this.syncLabelsToggle(),this.refreshParamSummary(),this.populateInfoPanel()}syncLabelsToggle(){const t=this.labelsShown?this.messages?.hideLabels??"":this.messages?.showLabels??"";this.labelsToggle.title=t,this.labelsToggle.setAttribute("aria-label",t),this.labelsToggle.setAttribute("aria-pressed",String(this.labelsShown))}showReadingBox(){const t=this.readingFindingsElement,e=this.readingEntry!==void 0&&!this.labelsShown;t.hidden=!e&&!this.readingSensible,t.querySelector("#reading-chip").hidden=!e,e||(t.querySelector("#reading-findings-list").hidden=!0)}refreshParamSummary(){if(this.paramSummary.hidden=!this.labelsShown,this.showReadingBox(),!this.labelsShown){this.paramSummary.replaceChildren(),this.summarySignature="";return}const t=this.sceneElement.ufoElement.sighting,e=this.summaryBuilder?.entriesFor(t,this.sceneElement.ufoElement.currentTime,{roadGradeDeg:this.sceneElement.roadGradeDeg})??[],i=e.map(l=>l.group).lastIndexOf("summary"),n=this.readingEntry?[this.readingEntry]:[],s=[...e.slice(0,i+1),...n,...e.slice(i+1),...this.assessmentEntries],r=s.map(l=>`${l.field}=${l.label}=${l.value}${l.unit}${l.full??""}${l.fromSource?"*":""}`).join("|");if(r===this.summarySignature)return;this.summarySignature=r;const a=[];let c;for(const l of s){c&&c.group!==l.group&&(c=void 0);const h=l.group==="summary"?this.messages?.summaryGroup??"":l.group==="observer"?this.messages?.observerGroup??"":this.messages&&l.group in this.messages.summaryGroups?this.messages.summaryGroups[l.group]:l.group==="assessment"?this.messages?.assessmentGroup??"":void 0;if(h!==void 0&&!c){const d=document.createElement("span");d.className="param-nest";const f=document.createElement("span");f.className="param-nest-label",f.textContent=h,d.append(f),c={group:l.group,element:d},a.push(d)}const u=this.paramItem(l);c?c.element.append(u):a.push(u)}this.paramSummary.replaceChildren(...a),this.syncDescription(s)}openDescription;openDescriptionTitle;syncDescription(t){this.openDescription!==void 0&&!t.some(e=>e.full===this.openDescription)&&(this.openDescription=void 0),SE.sync(this.paramSummary,this.openDescription,this.openDescriptionTitle??this.messages?.summaryDescription??"",this.messages?.closeDescription??"",()=>{this.openDescription=void 0,this.syncDescription(t)})}paramItem(t){const e=document.createElement("span");if(e.className=t.fromSource?"param-label from-source":"param-label",t.detail&&(e.title=t.detail),t.full!==void 0){e.classList.add("describable"),e.tabIndex=0,e.setAttribute("role","button");const s=()=>{this.openDescription=t.full,this.openDescriptionTitle=t.label,this.syncDescription([t])};e.addEventListener("click",s),e.addEventListener("keydown",r=>{(r.key==="Enter"||r.key===" ")&&(r.preventDefault(),s())})}const i=document.createElement("span");if(i.className="param-label-label",i.textContent=`${t.label} `,e.append(i),t.color!==void 0){const s=document.createElement("span");s.className="param-label-swatch",s.style.background=t.color,e.append(s)}const n=document.createElement("span");return n.className="param-label-value",n.textContent=t.unit===""?t.value:`${t.value} ${t.unit}`,e.append(n),e}populateInfoPanel(){const t=this.entries.find(e=>e.src===this.currentSrc);if(this.infoObservationList.innerHTML="",t){const e=this.caseSource&&(this.caseSource.json.title??this.caseSource.json.id);if(e&&this.appendInfoRow(this.infoObservationList,this.messages?.case??"",e),!this.labelsShown){const s=this.formatDate(this.plain(t));s&&this.appendInfoRow(this.infoObservationList,this.messages?.date??"",s,this.basisOf(t,qc.DATE_PATHS));const r=this.formatLocation(this.plain(t));r&&this.appendInfoRow(this.infoObservationList,this.messages?.location??"",r,this.basisOf(t,qc.PLACE_PATHS))}const i=this.said.read(this.plain(t).description);i&&!this.labelsShown&&this.appendInfoRow(this.infoObservationList,this.messages?.description??"",i);for(const s of this.plain(t).sources??[])this.appendInfoSource(this.infoObservationList,this.messages?.source??"",s);const n=this.plain(t).tags;!this.labelsShown&&n&&n.length>0&&this.appendInfoRow(this.infoObservationList,this.messages?.tags??"",n.map(s=>this.tags.name(s)).join(", "))}this.infoAppLink.href=_0,this.infoAppLink.textContent="UFO@home v0.188.1",qn.fill(this.infoCreditsList,this.sceneElement)}appendInfoSource(t,e,i){const n=document.createElement("dt");n.textContent=e;const s=document.createElement("dd"),r=this.said.read(i.title)??i.url??"";if(i.url&&/^https?:\/\//i.test(i.url)){const c=document.createElement("a");c.href=i.url,c.target="_blank",c.rel="noopener noreferrer",c.textContent=r,s.appendChild(c)}else s.append(r);const a=[i.authors?.join(", "),i.publication?.publisher,i.publication?.time,i.index].filter(Boolean);a.length>0&&s.append(`, ${a.join(", ")}`),t.append(n,s)}static DATE_PATHS=["time","utcOffsetHours","timeZone"];static PLACE_PATHS=["place"];appendInfoRow(t,e,i,n){if(!this.messages)return;const s=document.createElement("dt");s.textContent=e;const r=document.createElement("dd");if(r.textContent=i,n){const a=document.createElement("span");a.className=`basis basis-${n.basis}`,a.textContent=this.messages.basis[n.basis],n.rationales.length>0&&(a.title=n.rationales.join(`
|
|
9919
9919
|
`)),r.append(" ",a)}t.appendChild(s),t.appendChild(r)}}const jo="rr0-sighting",HM="observerchange";function G3(){jy(),ml.register(),customElements.get(jo)||customElements.define(jo,qc)}class Qo extends HTMLElement{static TAG="rr0-readings-comparison";static CSS=`
|
|
9920
9920
|
:host { display: block; font-size: 13px; line-height: 1.4; }
|
|
9921
9921
|
:host([hidden]) { display: none; }
|
|
@@ -9946,7 +9946,7 @@ button.open { display: inline-flex; align-items: center; gap: 6px; cursor: point
|
|
|
9946
9946
|
.option input { margin: 2px 0 0; }
|
|
9947
9947
|
${Ia.css(".menu")}
|
|
9948
9948
|
.menu:popover-open { position-area: bottom span-left; margin: .35em 0 0; }
|
|
9949
|
-
`;source;messages;language="en";preferences=["en"];status;withPictures;static register(){customElements.get(Zc.TAG)||customElements.define(Zc.TAG,Zc)}constructor(){super(),this.attachShadow({mode:"open"})}connectedCallback(){this.messages||this.loadLocale()}async loadLocale(){this.preferences=Ks.preferencesFor(this),this.language=Mo([...this.preferences],yo),this.messages=await VT.load(this.language),this.draw()}draw(){const t=this.messages,e=document.createElement("style");e.textContent=Zc.CSS;const i=document.createElement("button");i.type="button",i.className="open",i.setAttribute("part","button"),i.title=t.hint,i.setAttribute("aria-label",t.hint),i.setAttribute("aria-haspopup","menu"),i.innerHTML=Zc.ICON,this.getAttribute("variant")==="pill"&&i.append(Object.assign(document.createElement("span"),{textContent:t.button}));const n=document.createElement("div");n.className="menu",n.setAttribute("role","menu"),Ia.attach(i,n);const s=[["html",t.html,t.htmlHint],["print",t.print,t.printHint],["json",t.json,t.jsonHint],["csv",t.csv,t.csvHint]];n.append(...s.map(([c,l,h])=>{const u=document.createElement("button");return u.type="button",u.setAttribute("role","menuitem"),u.append(Object.assign(document.createElement("strong"),{textContent:l}),Object.assign(document.createElement("small"),{textContent:h})),u.addEventListener("click",()=>void this.export(c,n)),u}));const r=document.createElement("label");r.className="option",this.withPictures=Object.assign(document.createElement("input"),{type:"checkbox"});const a=document.createElement("span");a.append(Object.assign(document.createElement("strong"),{textContent:t.pictures}),Object.assign(document.createElement("small"),{textContent:t.picturesHint})),r.append(this.withPictures,a),n.append(r),this.status=Object.assign(document.createElement("p"),{className:"status",hidden:!0}),this.status.setAttribute("role","status"),n.append(this.status),i.addEventListener("click",()=>Ia.show(n,n.hidden)),this.shadowRoot.replaceChildren(e,i,n)}async export(t,e){const i=this.messages;if(this.source){this.status.textContent=i.working,this.status.hidden=!1;try{const[{CaseReportExport:n},s]=await Promise.all([st(()=>import("./CaseReportExport-
|
|
9949
|
+
`;source;messages;language="en";preferences=["en"];status;withPictures;static register(){customElements.get(Zc.TAG)||customElements.define(Zc.TAG,Zc)}constructor(){super(),this.attachShadow({mode:"open"})}connectedCallback(){this.messages||this.loadLocale()}async loadLocale(){this.preferences=Ks.preferencesFor(this),this.language=Mo([...this.preferences],yo),this.messages=await VT.load(this.language),this.draw()}draw(){const t=this.messages,e=document.createElement("style");e.textContent=Zc.CSS;const i=document.createElement("button");i.type="button",i.className="open",i.setAttribute("part","button"),i.title=t.hint,i.setAttribute("aria-label",t.hint),i.setAttribute("aria-haspopup","menu"),i.innerHTML=Zc.ICON,this.getAttribute("variant")==="pill"&&i.append(Object.assign(document.createElement("span"),{textContent:t.button}));const n=document.createElement("div");n.className="menu",n.setAttribute("role","menu"),Ia.attach(i,n);const s=[["html",t.html,t.htmlHint],["print",t.print,t.printHint],["json",t.json,t.jsonHint],["csv",t.csv,t.csvHint]];n.append(...s.map(([c,l,h])=>{const u=document.createElement("button");return u.type="button",u.setAttribute("role","menuitem"),u.append(Object.assign(document.createElement("strong"),{textContent:l}),Object.assign(document.createElement("small"),{textContent:h})),u.addEventListener("click",()=>void this.export(c,n)),u}));const r=document.createElement("label");r.className="option",this.withPictures=Object.assign(document.createElement("input"),{type:"checkbox"});const a=document.createElement("span");a.append(Object.assign(document.createElement("strong"),{textContent:t.pictures}),Object.assign(document.createElement("small"),{textContent:t.picturesHint})),r.append(this.withPictures,a),n.append(r),this.status=Object.assign(document.createElement("p"),{className:"status",hidden:!0}),this.status.setAttribute("role","status"),n.append(this.status),i.addEventListener("click",()=>Ia.show(n,n.hidden)),this.shadowRoot.replaceChildren(e,i,n)}async export(t,e){const i=this.messages;if(this.source){this.status.textContent=i.working,this.status.hidden=!1;try{const[{CaseReportExport:n},s]=await Promise.all([st(()=>import("./CaseReportExport-DbGfu7DP.js"),[],import.meta.url),this.source()]);await n.make(t,s,this.language,this.preferences,this.withPictures?.checked??!1,(r,a)=>{this.status.textContent=i.drawing.replace("{done}",String(r)).replace("{total}",String(a))}),this.status.hidden=!0,Ia.show(e,!1)}catch{this.status.textContent=i.failed}}}}const t7="interviewseek";class Eu{constructor(t,e,i=e){this.list=t,this.choose=e,this.follow=i}static CSS=`
|
|
9950
9950
|
:host {
|
|
9951
9951
|
--tl-ink: currentColor;
|
|
9952
9952
|
--tl-ink-dim: color-mix(in srgb, currentColor 80%, transparent);
|
|
@@ -10099,4 +10099,4 @@ ${Ia.css(".menu")}
|
|
|
10099
10099
|
.open-event rr0-interview { padding: 10px 12px; border: 1px solid color-mix(in srgb, currentColor 18%, transparent); border-radius: 10px;
|
|
10100
10100
|
font-size: 14px; line-height: 1.5; max-height: 22em; overflow-y: auto; }
|
|
10101
10101
|
${Eu.CSS}
|
|
10102
|
-
`,Wh="rr0-case",c0="show-timeline",l0="open-events";class Jc extends HTMLElement{static get observedAttributes(){return["src","show-labels",Fd,c0,l0,Kc]}static PASSED_ON=["show-labels"];shadow;openEvents;timeline;shown=new Map;messages;said=new es(["en"]);json;url;entries=[];constructor(){super(),this.shadow=this.attachShadow({mode:"open"});const t=document.createElement("style");t.textContent=i7;const e=document.createElement("div");e.innerHTML=e7,this.shadow.append(t,e),G3(),this.timeline=new Eu(this.byId("case-events"),r=>void this.toggle(r),r=>void this.open(r)),Qo.register(),Zc.register(),this.byId("export").source=async()=>{const r=this.json,a=new Map;return await Promise.all(this.entries.filter(c=>c.kind!=="interview"&&c.url).map(async c=>{try{a.set(c.url,await Ar.recording(c.url))}catch{}})),{caseJson:r,caseUrl:this.url,recordings:a}},this.openEvents=this.byId("open-events"),this.openEvents.addEventListener(t7,r=>{const{at:a,sighting:c}=r.detail;this.seekObservation(a,c)}),this.openEvents.addEventListener(a3,r=>{const a=r.target?.closest?.(".open-event");this.followReplay(a??void 0)}),ml.register();const i=this.byId("share");i.innerHTML=qt.SHARE;const n=this.byId("share-dialog");n.subject=this.shareSubject,i.addEventListener("click",()=>{this.url&&n.open()}),this.byId("edit").addEventListener("click",()=>{const r=this.editorUrl();r&&window.open(r,"_blank","noopener")}),this.byId("info").addEventListener("click",()=>this.showSummary(this.byId("case-summary").hidden)),this.byId("timeline-button").addEventListener("click",()=>{this.showTimeline(this.byId("case-events").parentElement.hidden)})}shareSubject={module:"rr0-sighting",link:()=>{const t=this.openKeys();return`${Su.home()}/play/?file=${encodeURIComponent(this.url??"")}${t?`&events=${encodeURIComponent(t)}`:""}`+(this.timelineShown()?"":"&timeline=0")},element:()=>{const t=this.openKeys();return`<${Wh} src="${this.url??""}"${t?` ${l0}="${t}"`:""}${this.timelineShown()?"":` ${c0}="false"`}></${Wh}>`}};timelineShown(){return!this.byId("case-events").parentElement.hidden}openKeys(){const t=[...this.shown.keys()].sort((e,i)=>e-i);return t.length===1&&t[0]===this.firstObservation()?"":t.map(e=>Jc.keyOf(this.entries[e])).join(",")}static keyOf(t){return t.event.id??Jc.fileNameOf(t)}static fileNameOf(t){return(t.url??"").split("/").pop().replace(/[.]json$/i,"")}asked(t){if(t===null)return[];if(t.trim()==="all")return this.entries.map((i,n)=>n);const e=t.split(",").map(i=>i.trim().replace(/[.]json$/i,"")).filter(i=>i!=="");return this.entries.map((i,n)=>({entry:i,at:n})).filter(({entry:i})=>e.some(n=>n===i.event.id||n===Jc.fileNameOf(i))).map(({at:i})=>i)}firstObservation(){return this.entries.findIndex(t=>t.kind!=="interview")}byId(t){return this.shadow.getElementById(t)}showSummary(t){this.byId("case-summary").hidden=!t,this.byId("info").setAttribute("aria-expanded",String(t))}showTimeline(t){this.byId("case-events").parentElement.hidden=!t,this.byId("timeline-button").setAttribute("aria-pressed",String(t));for(const e of this.players())e.toggleAttribute(Vh,t)}connectedCallback(){this.loadMessages(),this.showTimeline(this.getAttribute(c0)!=="false"),this.showSummary(this.hasAttribute(Fd));const t=this.getAttribute("src");t&&this.load(t).catch(e=>console.warn(`<${Wh}> could not read ${t}:`,e))}attributeChangedCallback(t,e,i){if(!(!this.isConnected||i===e))if(t==="src"&&i)this.load(i);else if(t===c0)this.showTimeline(i!=="false");else if(t===l0)for(const n of this.asked(i))this.open(n);else for(const n of this.players())i===null?n.removeAttribute(t):n.setAttribute(t,i)}async loadMessages(){const t=Mo(Ks.preferencesFor(this),yo);this.said=new es([t,"en"]),this.messages=await FT(t),await this.byId("share-dialog").useLanguage(t),this.draw()}async load(t){this.url=new URL(t,location.href).href;const e=await Ar.recording(this.url);if(!Ui.isCase(e))throw new Error(`${t} is not a case: <${Wh}> reads a case.json`);this.json=e,this.entries=Jc.inTime((e.events??[]).map(s=>this.entryOf(s)).filter(s=>s!==void 0)),this.shown.clear(),this.openEvents.replaceChildren(),this.draw(),this.compareReadings();const i=this.asked(this.getAttribute(l0));if(i.length>0){for(const s of i)await this.open(s);return}const n=this.firstObservation();n>=0&&this.open(n)}static inTime(t){const e=new Map(t.filter(i=>i.event.id!==void 0).map(i=>[i.event.id,i]));return Eu.inTime(t,{when:i=>i.when,kind:i=>i.kind,read:i=>[i.event.interpretationOf].flat().map(n=>n===void 0?void 0:e.get(n)).filter(n=>n!==void 0)}).map(({item:i})=>i)}entryOf(t){if(typeof t.url!="string"||t.url==="")return;const e=t.eventType===Ui.INTERVIEW_EVENT?"interview":t.eventType===Ui.SIGHTING_EVENT?t.interpretationOf===void 0?"observation":"reading":void 0;if(e)return{event:t,kind:e,url:new URL(t.url,this.url??location.href).href,title:this.said.read(t.title)??t.id??"",when:String(t.time??"")}}compareReadings(){const t=this.byId("readings-comparison"),e=new Map,i=s=>{let r=e.get(s);return r||(r=Ar.recording(s).then(a=>a,()=>{}),e.set(s,r)),r},n=async s=>Promise.all(this.entries.flatMap((r,a)=>{if(r.kind!=="reading")return[];const c=this.accountOf(r);return[(async()=>({title:r.title,witness:c?.title??"",...s&&c?.url&&r.url?{account:await i(c.url),reading:await i(r.url)}:{},open:()=>void this.open(a).then(()=>this.shown.get(a)?.scrollIntoView({block:"start",behavior:"smooth"}))}))()]}));n(!1).then(s=>t.show(s,()=>n(!0)))}accountOf(t){const e=[t.event.interpretationOf].flat().filter(i=>i!==void 0);return this.entries.find(i=>i.kind==="observation"&&e.includes(i.event.id??""))}editorUrl(){if(!this.url)return;const t=new URL("/edit/",location.href);return t.searchParams.set("file",this.url),t.href}async toggle(t){this.shown.has(t)?this.shut(t):await this.open(t)}async open(t){const e=this.entries[t];if(!e||!e.url||this.shown.has(t))return;const i=document.createElement("section");if(i.className="open-event",i.dataset.at=String(t),e.kind==="interview"){const n=document.createElement("p");n.className="open-title",n.textContent=e.title,i.append(n)}if(e.kind==="interview"){const{register:n}=await st(async()=>{const{register:r}=await import("./InterviewElement-BduwyUn5.js");return{register:r}},[],import.meta.url);n();const s=document.createElement("rr0-interview");s.setAttribute("src",e.url),i.append(s),window.setTimeout(()=>{this.followReplay(),this.markCitedMoments()},300)}else{const n=document.createElement(jo);n.setAttribute(T0,""),n.toggleAttribute(Vh,!this.byId("case-events").parentElement.hidden),n.setAttribute("src",this.url??"");const s=e.kind==="reading"?this.accountOf(e):void 0;n.setAttribute(Kc,(s??e).url??""),e.kind==="reading"&&n.setAttribute(R0,e.url),queueMicrotask(()=>{for(const r of Jc.PASSED_ON){const a=this.getAttribute(r);a!==null&&n.setAttribute(r,a)}}),n.addEventListener(HM,r=>{this.dispatchEvent(new CustomEvent(HM,{detail:r.detail}))}),i.append(n)}this.shown.set(t,i),this.order(),this.draw(),e.kind!=="interview"&&window.setTimeout(()=>this.markCitedMoments(),300)}followReplay(t){const e=t??[...this.shown.values()].find(r=>r.querySelector(jo)),i=e?Number(e.dataset.at):NaN,n=Number.isNaN(i)?void 0:this.entries[i],s=e?.querySelector(jo);if(!(!n||!s)){for(const[r,a]of this.shown){if(this.entries[r]?.kind!=="interview")continue;a.querySelector("rr0-interview")?.revealAt?.(s.playedSeconds,n.event.id)}return e}}markCitedMoments(){for(const[t,e]of this.shown){const i=this.entries[t],n=e.querySelector(jo);if(!i||!n)continue;const s=[];for(const[r,a]of this.shown){if(this.entries[r]?.kind!=="interview")continue;const c=a.querySelector("rr0-interview");s.push(...c?.momentsCited?.(i.event.id)??[])}n.citedMoments=s.sort((r,a)=>r.at-a.at)}}shut(t){this.shown.get(t)?.remove(),this.shown.delete(t),this.markCitedMoments(),this.draw()}order(){const t=[...this.shown.entries()].sort(([e],[i])=>e-i).map(([,e])=>e);this.openEvents.replaceChildren(...t)}async seekObservation(t,e){const i=this.entries.findIndex(r=>r.kind!=="interview"&&(r.event.id===e||e!==void 0&&r.url?.endsWith(`/${e}.json`))),n=i>=0?i:this.entries.findIndex(r=>r.kind!=="interview");if(n<0)return;this.shown.has(n)||await this.open(n),this.shown.get(n)?.querySelector(jo)?.seekTo(t,e),this.shown.get(n)?.scrollIntoView({block:"nearest",behavior:"smooth"})}authors(t){const e=this.messages,i=(t??[]).map(n=>"people"in n?n.people:"org"in n?n.org:this.said.read(n.title)??"").filter(n=>n!=="");return i.length<2||!e?i.join(", "):`${i.slice(0,-1).join(", ")} ${e.linkAnd} ${i[i.length-1]}`}linkedTo(t){const e=this.messages;if(e){if(t.kind==="reading"){const i=[t.event.interpretationOf].flat().filter(s=>s!==void 0),n=this.entries.map((s,r)=>i.includes(s.event.id??"")?r:-1).filter(s=>s>=0);return n.length>0?{heading:e.interpretationOf,to:n}:void 0}if(t.kind==="observation"){const i=this.entries.map((n,s)=>n.kind==="interview"&&[n.event.interviewOf].flat().includes(t.event.id)?s:-1).filter(n=>n>=0);return i.length>0?{heading:e.passagesHeading,to:i}:void 0}}}draw(){const t=this.messages,e=this.json;if(!t||!e)return;this.byId("case-kind").textContent=t.caseHeading,this.byId("case-title").textContent=this.said.read(e.title)??e.id??"";const i=this.said.read(e.summary)??"",n=this.byId("case-summary");n.textContent=i;const s=this.byId("info");s.hidden=i==="",s.title=t.caseSummary,s.setAttribute("aria-label",t.caseSummary),i===""&&this.showSummary(!1),this.byId("events-heading").textContent=t.eventsHeading,this.byId("events-icon").innerHTML=we.CLOCK;const r=this.byId("share");r.title=t.shareCase,r.setAttribute("aria-label",t.shareCase);const a=this.byId("edit");a.title=t.editCase,a.setAttribute("aria-label",t.editCase),this.timeline.render(this.entries.map((c,l)=>this.card(c,l)),t)}card(t,e){const i=this.linkedTo(t);return{at:e,kind:t.kind,title:t.title,meta:t.when.replace("T"," "),open:this.shown.has(e),...i?{links:{heading:i.heading,to:i.to.map(n=>({at:n,title:this.entries[n].title}))}}:{},by:t.kind==="observation"?"":this.authors(t.event.by)}}async loadFromSrc(t){await this.load(t),await this.player?.loaded}get scene(){return this.players()[0]?.scene}players(){return[...this.shown.entries()].sort(([t],[e])=>t-e).map(([,t])=>t.querySelector(jo)).filter(t=>t!==null)}get sightingData(){return this.players()[0]?.sightingData}get player(){return this.players()[0]}}function n7(){customElements.get(Wh)||customElements.define(Wh,Jc)}G3();n7();export{Se as $,dr as A,Ct as B,ot as C,cf as D,Hr as E,lr as F,Xe as G,Ks as H,s7 as I,De as J,tt as K,uM as L,Ie as M,pt as N,Qn as O,qt as P,xd as Q,Pt as R,es as S,Qe as T,yo as U,Nr as V,mc as W,je as X,ye as Y,We as Z,st as _,Ar as a,g7 as a$,me as a0,co as a1,be as a2,Dr as a3,y7 as a4,b7 as a5,J0 as a6,p7 as a7,qe as a8,Ir as a9,zi as aA,un as aB,bs as aC,Bi as aD,Xk as aE,Zy as aF,$k as aG,zn as aH,v0 as aI,em as aJ,mh as aK,ki as aL,k0 as aM,we as aN,Ts as aO,Oa as aP,r7 as aQ,o7 as aR,a7 as aS,Lf as aT,M7 as aU,m7 as aV,Y0 as aW,NA as aX,tm as aY,h7 as aZ,Qw as a_,Ce as aa,fa as ab,RI as ac,xt as ad,Eo as ae,c7 as af,zL as ag,iM as ah,rr as ai,yd as aj,_c as ak,gh as al,Ps as am,Rn as an,v7 as ao,vl as ap,On as aq,Ai as ar,ri as as,en as at,is as au,um as av,ns as aw,f7 as ax,Vn as ay,Yn as az,t7 as b,w7 as b0,mA as b1,ur as b2,Xf as b3,fg as b4,HR as b5,bc as b6,Sv as b7,tn as b8,Ga as b9,gt as bA,b5 as bB,ru as bC,Wt as bD,Ph as bE,Uy as bF,Ht as bG,Iy as bH,vc as bI,Yr as bJ,Ls as bK,ws as bL,_u as bM,nn as bN,x7 as bO,Y4 as ba,pi as bb,l7 as bc,u7 as bd,MA as be,d7 as bf,pr as bg,vA as bh,yb as bi,H4 as bj,R3 as bk,W0 as bl,tM as bm,PA as bn,Dy as bo,Cy as bp,He as bq,Ba as br,Pf as bs,Ot as bt,Tn as bu,la as bv,Na as bw,Ei as bx,wc as by,uf as bz,Hn as c,QA as d,Nn as e,t3 as f,xf as g,yh as h,Je as i,yn as j,JM as k,Zs as l,oe as m,lL as n,pn as o,vE as p,so as q,Xr as r,Mo as s,Ah as t,kd as u,Ws as v,CI as w,Vt as x,ts as y,_ as z};
|
|
10102
|
+
`,Wh="rr0-case",c0="show-timeline",l0="open-events";class Jc extends HTMLElement{static get observedAttributes(){return["src","show-labels",Fd,c0,l0,Kc]}static PASSED_ON=["show-labels"];shadow;openEvents;timeline;shown=new Map;messages;said=new es(["en"]);json;url;entries=[];constructor(){super(),this.shadow=this.attachShadow({mode:"open"});const t=document.createElement("style");t.textContent=i7;const e=document.createElement("div");e.innerHTML=e7,this.shadow.append(t,e),G3(),this.timeline=new Eu(this.byId("case-events"),r=>void this.toggle(r),r=>void this.open(r)),Qo.register(),Zc.register(),this.byId("export").source=async()=>{const r=this.json,a=new Map;return await Promise.all(this.entries.filter(c=>c.kind!=="interview"&&c.url).map(async c=>{try{a.set(c.url,await Ar.recording(c.url))}catch{}})),{caseJson:r,caseUrl:this.url,recordings:a}},this.openEvents=this.byId("open-events"),this.openEvents.addEventListener(t7,r=>{const{at:a,sighting:c}=r.detail;this.seekObservation(a,c)}),this.openEvents.addEventListener(a3,r=>{const a=r.target?.closest?.(".open-event");this.followReplay(a??void 0)}),ml.register();const i=this.byId("share");i.innerHTML=qt.SHARE;const n=this.byId("share-dialog");n.subject=this.shareSubject,i.addEventListener("click",()=>{this.url&&n.open()}),this.byId("edit").addEventListener("click",()=>{const r=this.editorUrl();r&&window.open(r,"_blank","noopener")}),this.byId("info").addEventListener("click",()=>this.showSummary(this.byId("case-summary").hidden)),this.byId("timeline-button").addEventListener("click",()=>{this.showTimeline(this.byId("case-events").parentElement.hidden)})}shareSubject={module:"rr0-sighting",link:()=>{const t=this.openKeys();return`${Su.home()}/play/?file=${encodeURIComponent(this.url??"")}${t?`&events=${encodeURIComponent(t)}`:""}`+(this.timelineShown()?"":"&timeline=0")},element:()=>{const t=this.openKeys();return`<${Wh} src="${this.url??""}"${t?` ${l0}="${t}"`:""}${this.timelineShown()?"":` ${c0}="false"`}></${Wh}>`}};timelineShown(){return!this.byId("case-events").parentElement.hidden}openKeys(){const t=[...this.shown.keys()].sort((e,i)=>e-i);return t.length===1&&t[0]===this.firstObservation()?"":t.map(e=>Jc.keyOf(this.entries[e])).join(",")}static keyOf(t){return t.event.id??Jc.fileNameOf(t)}static fileNameOf(t){return(t.url??"").split("/").pop().replace(/[.]json$/i,"")}asked(t){if(t===null)return[];if(t.trim()==="all")return this.entries.map((i,n)=>n);const e=t.split(",").map(i=>i.trim().replace(/[.]json$/i,"")).filter(i=>i!=="");return this.entries.map((i,n)=>({entry:i,at:n})).filter(({entry:i})=>e.some(n=>n===i.event.id||n===Jc.fileNameOf(i))).map(({at:i})=>i)}firstObservation(){return this.entries.findIndex(t=>t.kind!=="interview")}byId(t){return this.shadow.getElementById(t)}showSummary(t){this.byId("case-summary").hidden=!t,this.byId("info").setAttribute("aria-expanded",String(t))}showTimeline(t){this.byId("case-events").parentElement.hidden=!t,this.byId("timeline-button").setAttribute("aria-pressed",String(t));for(const e of this.players())e.toggleAttribute(Vh,t)}connectedCallback(){this.loadMessages(),this.showTimeline(this.getAttribute(c0)!=="false"),this.showSummary(this.hasAttribute(Fd));const t=this.getAttribute("src");t&&this.load(t).catch(e=>console.warn(`<${Wh}> could not read ${t}:`,e))}attributeChangedCallback(t,e,i){if(!(!this.isConnected||i===e))if(t==="src"&&i)this.load(i);else if(t===c0)this.showTimeline(i!=="false");else if(t===l0)for(const n of this.asked(i))this.open(n);else for(const n of this.players())i===null?n.removeAttribute(t):n.setAttribute(t,i)}async loadMessages(){const t=Mo(Ks.preferencesFor(this),yo);this.said=new es([t,"en"]),this.messages=await FT(t),await this.byId("share-dialog").useLanguage(t),this.draw()}async load(t){this.url=new URL(t,location.href).href;const e=await Ar.recording(this.url);if(!Ui.isCase(e))throw new Error(`${t} is not a case: <${Wh}> reads a case.json`);this.json=e,this.entries=Jc.inTime((e.events??[]).map(s=>this.entryOf(s)).filter(s=>s!==void 0)),this.shown.clear(),this.openEvents.replaceChildren(),this.draw(),this.compareReadings();const i=this.asked(this.getAttribute(l0));if(i.length>0){for(const s of i)await this.open(s);return}const n=this.firstObservation();n>=0&&this.open(n)}static inTime(t){const e=new Map(t.filter(i=>i.event.id!==void 0).map(i=>[i.event.id,i]));return Eu.inTime(t,{when:i=>i.when,kind:i=>i.kind,read:i=>[i.event.interpretationOf].flat().map(n=>n===void 0?void 0:e.get(n)).filter(n=>n!==void 0)}).map(({item:i})=>i)}entryOf(t){if(typeof t.url!="string"||t.url==="")return;const e=t.eventType===Ui.INTERVIEW_EVENT?"interview":t.eventType===Ui.SIGHTING_EVENT?t.interpretationOf===void 0?"observation":"reading":void 0;if(e)return{event:t,kind:e,url:new URL(t.url,this.url??location.href).href,title:this.said.read(t.title)??t.id??"",when:String(t.time??"")}}compareReadings(){const t=this.byId("readings-comparison"),e=new Map,i=s=>{let r=e.get(s);return r||(r=Ar.recording(s).then(a=>a,()=>{}),e.set(s,r)),r},n=async s=>Promise.all(this.entries.flatMap((r,a)=>{if(r.kind!=="reading")return[];const c=this.accountOf(r);return[(async()=>({title:r.title,witness:c?.title??"",...s&&c?.url&&r.url?{account:await i(c.url),reading:await i(r.url)}:{},open:()=>void this.open(a).then(()=>this.shown.get(a)?.scrollIntoView({block:"start",behavior:"smooth"}))}))()]}));n(!1).then(s=>t.show(s,()=>n(!0)))}accountOf(t){const e=[t.event.interpretationOf].flat().filter(i=>i!==void 0);return this.entries.find(i=>i.kind==="observation"&&e.includes(i.event.id??""))}editorUrl(){if(!this.url)return;const t=new URL("/edit/",location.href);return t.searchParams.set("file",this.url),t.href}async toggle(t){this.shown.has(t)?this.shut(t):await this.open(t)}async open(t){const e=this.entries[t];if(!e||!e.url||this.shown.has(t))return;const i=document.createElement("section");if(i.className="open-event",i.dataset.at=String(t),e.kind==="interview"){const n=document.createElement("p");n.className="open-title",n.textContent=e.title,i.append(n)}if(e.kind==="interview"){const{register:n}=await st(async()=>{const{register:r}=await import("./InterviewElement-BduwyUn5.js");return{register:r}},[],import.meta.url);n();const s=document.createElement("rr0-interview");s.setAttribute("src",e.url),i.append(s),window.setTimeout(()=>{this.followReplay(),this.markCitedMoments()},300)}else{const n=document.createElement(jo);n.setAttribute(T0,""),n.toggleAttribute(Vh,!this.byId("case-events").parentElement.hidden),n.setAttribute("src",this.url??"");const s=e.kind==="reading"?this.accountOf(e):void 0;n.setAttribute(Kc,(s??e).url??""),e.kind==="reading"&&n.setAttribute(R0,e.url),queueMicrotask(()=>{for(const r of Jc.PASSED_ON){const a=this.getAttribute(r);a!==null&&n.setAttribute(r,a)}}),n.addEventListener(HM,r=>{this.dispatchEvent(new CustomEvent(HM,{detail:r.detail}))}),i.append(n)}this.shown.set(t,i),this.order(),this.draw(),e.kind!=="interview"&&window.setTimeout(()=>this.markCitedMoments(),300)}followReplay(t){const e=t??[...this.shown.values()].find(r=>r.querySelector(jo)),i=e?Number(e.dataset.at):NaN,n=Number.isNaN(i)?void 0:this.entries[i],s=e?.querySelector(jo);if(!(!n||!s)){for(const[r,a]of this.shown){if(this.entries[r]?.kind!=="interview")continue;a.querySelector("rr0-interview")?.revealAt?.(s.playedSeconds,n.event.id)}return e}}markCitedMoments(){for(const[t,e]of this.shown){const i=this.entries[t],n=e.querySelector(jo);if(!i||!n)continue;const s=[];for(const[r,a]of this.shown){if(this.entries[r]?.kind!=="interview")continue;const c=a.querySelector("rr0-interview");s.push(...c?.momentsCited?.(i.event.id)??[])}n.citedMoments=s.sort((r,a)=>r.at-a.at)}}shut(t){this.shown.get(t)?.remove(),this.shown.delete(t),this.markCitedMoments(),this.draw()}order(){const t=[...this.shown.entries()].sort(([e],[i])=>e-i).map(([,e])=>e);this.openEvents.replaceChildren(...t)}async seekObservation(t,e){const i=this.entries.findIndex(r=>r.kind!=="interview"&&(r.event.id===e||e!==void 0&&r.url?.endsWith(`/${e}.json`))),n=i>=0?i:this.entries.findIndex(r=>r.kind!=="interview");if(n<0)return;this.shown.has(n)||await this.open(n),this.shown.get(n)?.querySelector(jo)?.seekTo(t,e),this.shown.get(n)?.scrollIntoView({block:"nearest",behavior:"smooth"})}authors(t){const e=this.messages,i=(t??[]).map(n=>"people"in n?n.people:"org"in n?n.org:this.said.read(n.title)??"").filter(n=>n!=="");return i.length<2||!e?i.join(", "):`${i.slice(0,-1).join(", ")} ${e.linkAnd} ${i[i.length-1]}`}linkedTo(t){const e=this.messages;if(e){if(t.kind==="reading"){const i=[t.event.interpretationOf].flat().filter(s=>s!==void 0),n=this.entries.map((s,r)=>i.includes(s.event.id??"")?r:-1).filter(s=>s>=0);return n.length>0?{heading:e.interpretationOf,to:n}:void 0}if(t.kind==="observation"){const i=this.entries.map((n,s)=>n.kind==="interview"&&[n.event.interviewOf].flat().includes(t.event.id)?s:-1).filter(n=>n>=0);return i.length>0?{heading:e.passagesHeading,to:i}:void 0}}}draw(){const t=this.messages,e=this.json;if(!t||!e)return;this.byId("case-kind").textContent=t.caseHeading,this.byId("case-title").textContent=this.said.read(e.title)??e.id??"";const i=this.said.read(e.summary)??"",n=this.byId("case-summary");n.textContent=i;const s=this.byId("info");s.hidden=i==="",s.title=t.caseSummary,s.setAttribute("aria-label",t.caseSummary),i===""&&this.showSummary(!1),this.byId("events-heading").textContent=t.eventsHeading,this.byId("events-icon").innerHTML=we.CLOCK;const r=this.byId("share");r.title=t.shareCase,r.setAttribute("aria-label",t.shareCase);const a=this.byId("edit");a.title=t.editCase,a.setAttribute("aria-label",t.editCase),this.timeline.render(this.entries.map((c,l)=>this.card(c,l)),t)}card(t,e){const i=this.linkedTo(t);return{at:e,kind:t.kind,title:t.title,meta:t.when.replace("T"," "),open:this.shown.has(e),...i?{links:{heading:i.heading,to:i.to.map(n=>({at:n,title:this.entries[n].title}))}}:{},by:t.kind==="observation"?"":this.authors(t.event.by)}}async loadFromSrc(t){await this.load(t),await this.player?.loaded}get scene(){return this.players()[0]?.scene}players(){return[...this.shown.entries()].sort(([t],[e])=>t-e).map(([,t])=>t.querySelector(jo)).filter(t=>t!==null)}get sightingData(){return this.players()[0]?.sightingData}get player(){return this.players()[0]}}function n7(){customElements.get(Wh)||customElements.define(Wh,Jc)}G3();n7();export{Se as $,dr as A,Ct as B,ot as C,cf as D,Hr as E,lr as F,Xe as G,Ks as H,s7 as I,De as J,tt as K,uM as L,Ie as M,pt as N,Qn as O,qt as P,xd as Q,Pt as R,es as S,Qe as T,yo as U,Nr as V,mc as W,je as X,ye as Y,We as Z,st as _,Ar as a,Qw as a$,me as a0,co as a1,be as a2,Dr as a3,y7 as a4,b7 as a5,J0 as a6,p7 as a7,qe as a8,Ir as a9,zi as aA,un as aB,bs as aC,Bi as aD,Xk as aE,Zy as aF,$k as aG,zn as aH,v0 as aI,em as aJ,lE as aK,mh as aL,ki as aM,k0 as aN,we as aO,Ts as aP,Oa as aQ,r7 as aR,o7 as aS,a7 as aT,Lf as aU,M7 as aV,m7 as aW,Y0 as aX,NA as aY,tm as aZ,h7 as a_,Ce as aa,fa as ab,RI as ac,xt as ad,Eo as ae,c7 as af,zL as ag,iM as ah,rr as ai,yd as aj,_c as ak,gh as al,Ps as am,Rn as an,v7 as ao,vl as ap,On as aq,Ai as ar,ri as as,en as at,is as au,um as av,ns as aw,f7 as ax,Vn as ay,Yn as az,t7 as b,g7 as b0,w7 as b1,mA as b2,ur as b3,Xf as b4,fg as b5,HR as b6,bc as b7,Sv as b8,tn as b9,uf as bA,gt as bB,b5 as bC,ru as bD,Wt as bE,Ph as bF,Uy as bG,Ht as bH,Iy as bI,vc as bJ,Yr as bK,Ls as bL,ws as bM,_u as bN,nn as bO,x7 as bP,Ga as ba,Y4 as bb,pi as bc,l7 as bd,u7 as be,MA as bf,d7 as bg,pr as bh,vA as bi,yb as bj,H4 as bk,R3 as bl,W0 as bm,tM as bn,PA as bo,Dy as bp,Cy as bq,He as br,Ba as bs,Pf as bt,Ot as bu,Tn as bv,la as bw,Na as bx,Ei as by,wc as bz,Hn as c,QA as d,Nn as e,t3 as f,xf as g,yh as h,Je as i,yn as j,JM as k,Zs as l,oe as m,lL as n,pn as o,vE as p,so as q,Xr as r,Mo as s,Ah as t,kd as u,Ws as v,CI as w,Vt as x,ts as y,_ as z};
|