@rr0/ufoathome 0.50.1 → 0.51.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist-embed-scene/rr0-scene.mjs +221 -221
- package/dist-embed-sighting/SightingMessages_fr-DLjugVgn.js +1 -0
- package/dist-embed-sighting/rr0-sighting.mjs +219 -219
- package/dist-embed-sighting-editor/GLTFLoader-DtUiBNzc.js +1 -0
- package/dist-embed-sighting-editor/SightingEditorMessages_fr-BHvJ-9EO.js +1 -0
- package/dist-embed-sighting-editor/index-DQDuRMiM.js +42 -0
- package/dist-embed-sighting-editor/node.browser-CTpc2BHh.js +1 -0
- package/dist-embed-sighting-editor/node.browser-DLoyk0oM.js +1 -0
- package/dist-embed-sighting-editor/rr0-sighting-editor.mjs +437 -231
- package/dist-embed-sighting-editor/sightingSchema-DLFtWuLe.js +1 -0
- package/dist-embed-ufo/rr0-ufo.mjs +3 -3
- package/package.json +5 -4
- package/dist-embed-sighting/SightingMessages_fr-ghzJGk07.js +0 -1
- package/dist-embed-sighting-editor/GLTFLoader-Bf0lL1y-.js +0 -1
- package/dist-embed-sighting-editor/SightingEditorMessages_fr-h_TFOqJZ.js +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const e={type:"number"},t={type:"object",fields:{year:{type:"number"},month:{type:"number"},day:{type:"number"},hour:{type:"number"},minute:{type:"number"},second:{type:"number"},raw:{type:"string",doc:"The exact EDTF-ish text as typed in the editor UI (e.g."}}},o={type:"object",doc:"See SightingEvent.endTime.",fields:{year:{type:"number"},month:{type:"number"},day:{type:"number"},hour:{type:"number"},minute:{type:"number"},second:{type:"number"},raw:{type:"string",doc:"The exact EDTF-ish text as typed in the editor UI (e.g."}}},n={type:"number",doc:"See SightingEvent.durationSeconds."},i={type:"number",doc:"See SightingEvent.utcOffsetHours — the legal time zone `time`/`endTime` are expressed in."},s={type:"string",doc:"See SightingEvent.timeZone — the IANA rule `utcOffsetHours` was derived from, when it was."},r={type:"array",fields:{lat:{type:"number"},lng:{type:"number"},name:{type:"string",doc:'The place as it is named, fully qualified — "Valensole, Alpes-de-Haute-Provence, …, France".'}}},a={type:"object",doc:"See Sighting.witness.",fields:{id:{type:"string"},dirName:{type:"string"},title:{type:"string"},lastName:{type:"string"},firstNames:{type:"array"}}},d={type:"string",doc:"See Sighting.caseId — shared by every witness's own sighting.json for the same case, so a page (e.g."},c={type:"string",doc:"See SightingEvent.description — a plain string, or one per language."},l={type:"array",doc:"See SightingEvent.tags."},h={type:"object",fields:{keyframes:{type:"array",fields:{t:{type:"number"},shapes:{type:"array",fields:{sourceId:{type:"string"},shape:{type:"object",fields:{kind:{type:"enum",values:["oval","polygon"]},bounds:{type:"object",fields:{x:{type:"number"},y:{type:"number"},width:{type:"number"},height:{type:"number"}}},color:{type:"string",doc:"CSS color"},angle:{type:"number",doc:"Rotation in radians; 0 = no rotation"},transparency:{type:"number",doc:"0 = opaque, 1 = fully transparent"},haloScale:{type:"number",doc:"0 = no halo/glow, >1 = larger glow radius"},blur:{type:"number",doc:"How indistinct the witness said its edges were — 0 for a hard outline, 1 for a shape with no edge at all."},brightness:{type:"number",doc:"How dazzling the witness said it was — 0 for a light you can look at, 1 for one you cannot."},selected:{type:"boolean"},title:{type:"string",doc:"What the witness calls it, if anything."},behindCloud:{type:"boolean",doc:'Whether the witness reported this shape as being behind cloud at this instant — "it disappeared into a cloud", which is a thing they SAW, not something to be deduced.'},angular:{type:"object",doc:"How big this looked to the witness, in degrees of arc (see AngularExtent) — the recording's OWN statement of size, and the one it is allowed to make.",fields:{widthDeg:{type:"number",doc:"How wide it looked, in degrees of arc."},heightDeg:{type:"number",doc:"How tall it looked, in degrees of arc."}}},aim:{type:"object",doc:"Which way the witness was actually looking when the thing was there — degrees of azimuth from true north and of altitude above the horizon, the same conventions as ObserverPose.",fields:{azimuthDeg:{type:"number",doc:"Degrees clockwise from true north, the same convention as ObserverPose.headingDeg."},altitudeDeg:{type:"number",doc:"Degrees above (positive) or below the horizon."}}},points:{type:"array",doc:"Points relative to bounds origin (0,0 = bounds.x, bounds.y)",fields:{x:{type:"number"},y:{type:"number"}}}}}}}}},order:{type:"array",doc:"Back-to-front paint/hit-test order — see Timeline's own `order` field."},groups:{type:"array",doc:"Each inner array is one group's member sourceIds (always >= 2 members) — see Timeline's own `groups` field."}}},p={type:"object",doc:"The witness's position/elevation/orientation over time — absent for older recordings, which fall back to the legacy static place[0] (see Sighting.ts's resolveObserverPoseAt).",fields:{keyframes:{type:"array",fields:{t:{type:"number"},pose:{type:"object",fields:{lat:{type:"number",doc:"Decimal degrees."},lng:{type:"number"},elevationM:{type:"number"},headingDeg:{type:"number",doc:"Degrees clockwise from true north."},pitchDeg:{type:"number",doc:"Degrees above (positive) or below (negative) the local horizontal — how far up/down the witness was looking, e.g."},rollDeg:{type:"number",doc:"How far the instrument itself was tilted about its own line of sight, degrees, positive clockwise as the witness saw it — a camera held askew, a head leaned over."},fovDeg:{type:"number",doc:"Vertical field of view in degrees, as a Three.js PerspectiveCamera would take it."},fNumber:{type:"number",doc:"How far the lens was stopped down — undefined for anything the recording did not state, which then falls back to the instrument's own setting (see Instrument.fNumber)."},focusDistanceM:{type:"number",doc:"How far away the lens was focused, metres — undefined meaning at infinity, which is where a camera pointed at the sky sits and the only setting under which everything celestial comes out sharp."}}}}}}},u={type:"object",doc:"Weather over time — absent for older recordings, which fall back to the legacy static `weather` field below (see Sighting.ts's resolveWeatherAt).",fields:{keyframes:{type:"array",fields:{t:{type:"number"},weather:{type:"object",fields:{cloudCover:{type:"number",doc:"0 = clear sky, 1 = fully overcast."},cloudDarkness:{type:"number",doc:"0 = light/clear clouds, 1 = dark/stormy character."},cloudBaseM:{type:"number",doc:"Height of the cloud layer's BASE above the ground, in meters — 600 to 2000 m covers most real low cloud."},highCloudCover:{type:"number",doc:"How much of the sky the HIGH deck covered, 0 to 1 — cirrus and cirrostratus, above about six kilometres, where anything present is ice rather than water."},lowerCloudCover:{type:"number",doc:"How much of the sky the LOW and MIDDLE decks covered, 0 to 1 — the cloud that stands between a witness and anything higher up."},iceCrystalAlignment:{type:"number",doc:"How steadily the ice crystals were falling, 0 to 1 — the one thing about the sky that decides which halo forms stood, and the one thing no record of any sighting holds."},precipitationType:{type:"enum",values:["none","rain","snow","hail"]},precipitationIntensity:{type:"number",doc:'0-1; meaningless while precipitationType is "none".'},windDirectionDeg:{type:"number",doc:"Degrees clockwise from true north — same convention as ObserverPose.headingDeg, and the direction the wind blows *toward*, not the one it comes from: SceneRenderer drifts every precipitation particle along exactly this bearing (`sin/-cos`, north = -Z), so 0 means snow drifting northward."},windSpeed:{type:"number",doc:"Real-world wind speed in m/s (0 = calm, ~30 = violent storm/hurricane-force) — drives both visual precipitation drift and wind audio volume directly, see SceneRenderer/WeatherAudio."},storm:{type:"boolean",doc:"Whether a thunderstorm was reported — drives both a scene-fog lightning flash and a delayed thunderclap (see SceneRenderer's lightning-flash scheduling, named for the visual mechanism it implements internally, not for this field)."}}}}}}},y={type:"object",doc:`Legacy static weather condition, kept only as weatherTrack's own fallback for recordings made before it existed — absent means "unknown/not recorded", not "clear skies" (renderers default to DEFAULT_WEATHER, see Weather.ts).`,fields:{cloudCover:{type:"number",doc:"0 = clear sky, 1 = fully overcast."},cloudDarkness:{type:"number",doc:"0 = light/clear clouds, 1 = dark/stormy character."},cloudBaseM:{type:"number",doc:"Height of the cloud layer's BASE above the ground, in meters — 600 to 2000 m covers most real low cloud."},highCloudCover:{type:"number",doc:"How much of the sky the HIGH deck covered, 0 to 1 — cirrus and cirrostratus, above about six kilometres, where anything present is ice rather than water."},lowerCloudCover:{type:"number",doc:"How much of the sky the LOW and MIDDLE decks covered, 0 to 1 — the cloud that stands between a witness and anything higher up."},iceCrystalAlignment:{type:"number",doc:"How steadily the ice crystals were falling, 0 to 1 — the one thing about the sky that decides which halo forms stood, and the one thing no record of any sighting holds."},precipitationType:{type:"enum",values:["none","rain","snow","hail"]},precipitationIntensity:{type:"number",doc:'0-1; meaningless while precipitationType is "none".'},windDirectionDeg:{type:"number",doc:"Degrees clockwise from true north — same convention as ObserverPose.headingDeg, and the direction the wind blows *toward*, not the one it comes from: SceneRenderer drifts every precipitation particle along exactly this bearing (`sin/-cos`, north = -Z), so 0 means snow drifting northward."},windSpeed:{type:"number",doc:"Real-world wind speed in m/s (0 = calm, ~30 = violent storm/hurricane-force) — drives both visual precipitation drift and wind audio volume directly, see SceneRenderer/WeatherAudio."},storm:{type:"boolean",doc:"Whether a thunderstorm was reported — drives both a scene-fog lightning flash and a delayed thunderclap (see SceneRenderer's lightning-flash scheduling, named for the visual mechanism it implements internally, not for this field)."}}},m={type:"object",doc:"What the sighting sounded like over time — see SoundTrack.",fields:{keyframes:{type:"array",fields:{t:{type:"number"},sound:{type:"object",fields:{kind:{type:"enum",values:["none","hum","whistle","rumble","crackle"]},volume:{type:"number",doc:"How loud it was, 0 (inaudible) to 1 (as loud as the witness could describe) — deliberately relative rather than a dB SPL figure: nobody reports a sound level in decibels, and inventing one would claim a measurement where there is only an impression."},pitchHz:{type:"number",doc:`The sound's own frequency in Hz — the oscillator's pitch for the pitched kinds ("hum", "whistle"), and the noise filter's centre for the unpitched ones ("rumble", "crackle"), where it reads as how deep or how sharp the noise is.`},src:{type:"string",doc:"An actual audio recording of the sound, when one exists (a witness who filmed the event, a later recording of the same phenomenon) — replaces synthesis entirely while it is set, with `volume` still scaling it."}}}}}}},g={type:"array",doc:"See Sighting.decor.",fields:{id:{type:"string"},kind:{type:"enum",values:["building","tree","crop","mound","streetlight","vehicle","witness","aircraft"]},title:{type:"string",doc:'Optional display name, same role as Shape.title — falls back to a generic "{kind} {n}" label (see SightingEditorElement.decorLabel) when absent.'},eastM:{type:"number",doc:"Meters from the observer's own position — eastM positive = east, northM positive = north."},northM:{type:"number"},headingDeg:{type:"number",doc:"Degrees clockwise from true north, same convention as ObserverPose.headingDeg — which way a vehicle is facing, or a witness looking."},lit:{type:"boolean",doc:"Streetlight lamp / vehicle headlights switched on."},litKeyframes:{type:"array",doc:"Sorted by t.",fields:{t:{type:"number"},lit:{type:"boolean"}}},lights:{type:"array",doc:"The object's individual lamps, each with its own place on the body and its own rhythm — see DecorLight, and LIGHT_RIGS for the ready-made sets.",fields:{id:{type:"string"},offsetM:{type:"object",doc:"Where it sits on the object, in meters relative to the object's own centre and heading: +x is its right, +y up, +z its front.",fields:{x:{type:"number"},y:{type:"number"},z:{type:"number"}}},color:{type:"string",doc:"CSS hex colour, as emitted — the regulated red/green/white of navigation lights, the amber of a hazard flasher."},intensity:{type:"number",doc:"Relative brightness, 1 being an ordinary navigation light."},pattern:{type:"object",fields:{kind:{type:"enum",values:["steady","flash"]},perMinute:{type:"number"},dutyCycle:{type:"number"},phase:{type:"number"}}}}},track:{type:"array",doc:"Where the object is over time, when it moves — an aircraft crossing the sky, a car driving past.",fields:{t:{type:"number"},eastM:{type:"number"},northM:{type:"number"},altitudeM:{type:"number",doc:"Meters above the observer's own elevation."},headingDeg:{type:"number"}}},sightingUrl:{type:"string",doc:`For kind "witness" only: the URL of that witness's own sighting.json recording, if known — lets the 3D scene's own context menu offer "view this witness's testimony" (loading it the same way SightingEditorElement.importFromUrl already does).`},windows:{type:"string",doc:"Per-side window opacity, 0 (fully open — the pane is invisible, and DecorSystem.addRoom's own interior wall panel is skipped there too, same as no window at all) to 100 (fully closed — a solid-looking pane)."},color:{type:"string",doc:'What colour this object actually is, as a CSS colour — the same way a shape states its own (see Shape.color), because a recording is written and read by people and "#8f86a8" is a colour a person can type.'},witnessSide:{type:"enum",values:["front","behind","left","right","front-left","front-right","behind-left","behind-right"]},floors:{type:"number",doc:'Kind "building" only: number of upper stories above the ground floor, set when the building is created (default 2, see SightingEditorElement.addDecor) and editable afterward.'},occupiedFloor:{type:"number",doc:'Kind "building" only, meaningful once witnessSide is set: which floor the witness is on, 0 (ground floor) up to floors.'},occludesSourceIds:{type:"array",doc:"Shape sourceIds (see Timeline.sourceIds/Shape) this decor object sits in front of, from the witness's own reported viewpoint — occluding that shape wherever their screen positions line up (see SceneRenderer.isScreenPointOccluded)."},sizeM:{type:"object",doc:"How big it really is, in meters, along its own axes — see DecorSize.",fields:{widthM:{type:"number"},lengthM:{type:"number"},heightM:{type:"number"}}},model:{type:"object",doc:"The real 3D model that stands in for the primitive, if one does — see DecorModelRef.",fields:{id:{type:"string",doc:"Catalogue entry, resolved by the live DecorModelProvider."},url:{type:"string",doc:"Direct glTF/GLB address, taking precedence over `id`."},headingOffsetDeg:{type:"number",doc:"Degrees to turn the loaded model about its own vertical axis so its nose points the way this scene's heading convention expects (0 faces -Z — see DecorSystem's build)."},credit:{type:"object",doc:"Who made it and under what licence.",fields:{title:{type:"string"},author:{type:"string"},license:{type:"string",doc:"Licence name as its author states it, e.g."},sourceUrl:{type:"string",doc:"Where it came from, so the claim can be checked."}}}}}}},b={type:"object",doc:"Which meteorological record `weatherTrack` was looked up from, when it wasn't the witness who stated the conditions — see Sighting.weatherSource.",fields:{id:{type:"string",doc:"Stable dataset id, e.g."},name:{type:"string",doc:"Human-readable dataset name, e.g."},url:{type:"string",doc:"The exact request that produced these values, so the claim stays checkable years later."}}},w={type:"string",doc:"Which INSTRUMENTS entry this was observed through — see Sighting.instrumentId."},f={type:"number",doc:"How long the shutter stayed open, seconds — one value for the whole observation, see Sighting.exposureSeconds."},v={type:"array",doc:"The named moments of the account — see Milestone.",fields:{t:{type:"number",doc:"When, in milliseconds from the start of the recording — the same scale every track uses."},label:{type:"string",doc:'Short label, shown on the seek bar: the letter or number the account itself uses ("A", "B"), or a couple of words where it uses none.'},note:{type:"string",doc:"What happened at that moment, in the account's own words where possible."}}},k={version:e,time:t,endTime:o,durationSeconds:n,utcOffsetHours:i,timeZone:s,place:r,witness:a,caseId:d,description:c,tags:l,timeline:h,witnessTrack:p,weatherTrack:u,weather:y,soundTrack:m,decor:g,weatherSource:b,instrument:w,exposureSeconds:f,milestones:v};export{d as caseId,g as decor,k as default,c as description,n as durationSeconds,o as endTime,f as exposureSeconds,w as instrument,v as milestones,r as place,m as soundTrack,l as tags,t as time,s as timeZone,h as timeline,i as utcOffsetHours,e as version,y as weather,b as weatherSource,u as weatherTrack,a as witness,p as witnessTrack};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const
|
|
1
|
+
const Dt=`
|
|
2
2
|
<div class="stage" id="stage">
|
|
3
3
|
<div class="frame" id="frame">
|
|
4
4
|
<canvas id="canvas" width="640" height="360"></canvas>
|
|
@@ -44,7 +44,7 @@ const It=`
|
|
|
44
44
|
</div>
|
|
45
45
|
</div>
|
|
46
46
|
</div>
|
|
47
|
-
`,
|
|
47
|
+
`,Ct=`
|
|
48
48
|
:host {
|
|
49
49
|
display: block;
|
|
50
50
|
font-family: sans-serif;
|
|
@@ -401,4 +401,4 @@ input[type=range] {
|
|
|
401
401
|
pointer-events: none;
|
|
402
402
|
white-space: nowrap;
|
|
403
403
|
}
|
|
404
|
-
`;class A extends Error{constructor(t,e,s){super(`${t}: ${e}${s===void 0?"":` (HTTP ${s})`}`),this.kind=t,this.url=e,this.status=s,this.name="SightingFetchError"}}class Dt{static async json(t){const e=new URL(t,location.href);if(location.protocol==="https:"&&e.protocol==="http:")throw new A("mixed-content",t);let s;try{s=await fetch(t)}catch{throw await this.diagnose(t,e)}if(!s.ok)throw new A("status",t,s.status);try{return await s.json()}catch{throw new A("malformed",t)}}static async diagnose(t,e){if(e.origin===location.origin)return new A("unreachable",t);try{return await fetch(t,{mode:"no-cors"}),new A("cors",t)}catch{return new A("unreachable",t)}}}const N=[{id:"eye",name:{en:"Naked eye",fr:"Œil nu"},flare:0,projection:"equidistant"},{id:"rectilinear-lens",name:{en:"Camera, unknown device",fr:"Appareil, modèle inconnu"},projection:"rectilinear",fNumber:8,fNumberRange:{min:2,max:22},exposureSeconds:1/250,exposureRangeSeconds:{min:1/1e3,max:8},apertureBlades:6},{id:"instamatic-126",name:{en:"Instamatic, 126 film",fr:"Instamatic, film 126"},projection:"rectilinear",frame:{widthMm:28,heightMm:28,focalLengthMm:43},fNumber:11,exposureSeconds:1/90,years:{from:1963,to:1988},apertureBlades:5,detailUm:20},{id:"slr-35mm-50",name:{en:"35 mm SLR, 50 mm lens",fr:"Reflex 35 mm, objectif 50 mm"},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},{id:"slr-35mm-zoom",name:{en:"35 mm SLR, 70-210 mm zoom",fr:"Reflex 35 mm, zoom 70-210 mm"},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},{id:"phone-landscape",name:{en:"Phone, held sideways",fr:"Téléphone, tenu couché"},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},{id:"phone-portrait",name:{en:"Phone, held upright",fr:"Téléphone, tenu debout"},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}];class w{static get default(){return N[0]}static byId(t){return N.find(e=>e.id===t)??this.default}static UNAIDED_FIELD_DEG=60;static UNAIDED_ASPECT=16/9;static fieldOfViewDeg(t){const e=t.frame;return e?2*Math.atan(e.heightMm/(2*e.focalLengthMm))*180/Math.PI:w.UNAIDED_FIELD_DEG}static aspectOf(t){const e=t.frame;return e?e.widthMm/e.heightMm:w.UNAIDED_ASPECT}static frameWidthPx(t,e){return Math.round(e*w.aspectOf(t))}static availableAt(t){return t===void 0?N:N.filter(e=>!e.years||t>=e.years.from&&(e.years.to===void 0||t<=e.years.to))}static fieldOfViewDegAt(t,e){const s=t.frame;if(!(!s||e<=0))return 2*Math.atan(s.heightMm/(2*e))*180/Math.PI}static focalLengthMmFor(t,e){const s=t.frame;if(!(!s||e<=0||e>=180))return s.heightMm/(2*Math.tan(e*Math.PI/360))}static bladesShowing(t,e){const s=e??t.fNumber;if(s===void 0||t.apertureBlades===void 0)return 0;const i=t.fNumberRange;return!i||i.max<=i.min?1:Math.max(0,Math.min(1,(s-i.min)/(i.max-i.min)))}static LENS_FLARE_ARTIFACTS=1;static flareArtifactsOf(t){return t.flare??w.LENS_FLARE_ARTIFACTS}static starPointsOf(t){const e=t.apertureBlades;return e===void 0||e<3?0:e%2===0?e:e*2}}class x{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/x.MOON_ANGULAR_WIDTH_DEG}static lerpAngular(t,e,s){if(!(!t||!e))return{widthDeg:t.widthDeg+(e.widthDeg-t.widthDeg)*s,heightDeg:t.heightDeg+(e.heightDeg-t.heightDeg)*s}}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 Ct(n,t,e){if(!n||!t)return e<1?n:t;const s=((t.azimuthDeg-n.azimuthDeg)%360+540)%360-180;return{azimuthDeg:((n.azimuthDeg+s*e)%360+360)%360,altitudeDeg:n.altitudeDeg+(t.altitudeDeg-n.altitudeDeg)*e}}function Bt(n,t,e){const{bounds:s}=n;return t>=s.x&&t<=s.x+s.width&&e>=s.y&&e<=s.y+s.height}function y(n,t,e){return n+(t-n)*e}function it(n){const t=/^#([0-9a-f]{6})$/i.exec(n);if(!t)return;const e=parseInt(t[1],16);return[e>>16&255,e>>8&255,e&255]}function Rt(n){return`#${n.map(t=>Math.round(t).toString(16).padStart(2,"0")).join("")}`}function _t(n,t,e){const s=it(n),i=it(t);return!s||!i?e<1?n:t:Rt([y(s[0],i[0],e),y(s[1],i[1],e),y(s[2],i[2],e)])}function Lt(n,t,e){const s={x:y(n.bounds.x,t.bounds.x,e),y:y(n.bounds.y,t.bounds.y,e),width:y(n.bounds.width,t.bounds.width,e),height:y(n.bounds.height,t.bounds.height,e)},i=y(n.angle,t.angle,e),a=y(n.transparency,t.transparency,e),r=y(n.haloScale,t.haloScale,e),o=y(n.blur??0,t.blur??0,e),l=y(n.brightness??0,t.brightness??0,e),h=_t(n.color,t.color,e),d=x.lerpAngular(n.angular,t.angular,e),c=Ct(n.aim,t.aim,e);return n.kind==="polygon"&&t.kind==="polygon"&&n.points.length===t.points.length?{...n,bounds:s,angle:i,transparency:a,haloScale:r,blur:o,brightness:l,color:h,angular:d,aim:c,behindCloud:e<1?n.behindCloud:t.behindCloud,points:n.points.map((u,f)=>({x:y(u.x,t.points[f].x,e),y:y(u.y,t.points[f].y,e)}))}:{...e<1?n:t,bounds:s,angle:i,transparency:a,haloScale:r,blur:o,brightness:l,color:h,angular:d,aim:c}}class q{keyframes=[];order=[];groups=[];addKeyframe(t,e){const s=this.findInsertIndex(t);if(this.keyframes[s]?.t===t){const i=new Set(e.map(a=>a.sourceId));this.keyframes[s]={t,shapes:[...this.keyframes[s].shapes.filter(a=>!i.has(a.sourceId)),...e]}}else this.keyframes.splice(s,0,{t,shapes:[...e]});for(const i of e)this.order.includes(i.sourceId)||this.order.push(i.sourceId)}findInsertIndex(t){let e=0,s=this.keyframes.length;for(;e<s;){const i=e+s>>>1;this.keyframes[i].t<t?e=i+1:s=i}return e}getKeyframeAt(t){const e=this.findInsertIndex(t),s=this.keyframes[e];return s?.t===t?s:void 0}getShapeAt(t,e){return this.getKeyframeAt(t)?.shapes.find(s=>s.sourceId===e)?.shape}getLatestShapeAt(t,e){let s=this.findInsertIndex(t);for(this.keyframes[s]?.t!==t&&(s-=1);s>=0;s--){const i=this.keyframes[s].shapes.find(a=>a.sourceId===e);if(i)return i.shape}}getInterpolatedShapeAt(t,e){const s=this.findShapeAtOrBefore(t,e);if(s?.t===t)return s.shape;const i=this.findShapeAtOrAfter(t,e);return s?i?Lt(s.shape,i.shape,(t-s.t)/(i.t-s.t)):s.shape:i?.shape}findShapeAtOrBefore(t,e){let s=this.findInsertIndex(t);for(this.keyframes[s]?.t!==t&&(s-=1);s>=0;s--){const i=this.keyframes[s].shapes.find(a=>a.sourceId===e);if(i)return{t:this.keyframes[s].t,shape:i.shape}}}findShapeAtOrAfter(t,e){for(let s=this.findInsertIndex(t);s<this.keyframes.length;s++){const i=this.keyframes[s].shapes.find(a=>a.sourceId===e);if(i)return{t:this.keyframes[s].t,shape:i.shape}}}hitTest(t,e,s,i){const a=this.sourceIds;for(let r=a.length-1;r>=0;r--){if(i?.has(a[r]))continue;const o=this.getInterpolatedShapeAt(t,a[r]);if(o&&Bt(o,e,s))return{sourceId:a[r],shape:o}}}removeSource(t){for(let e=this.keyframes.length-1;e>=0;e--){const s=this.keyframes[e].shapes.filter(i=>i.sourceId!==t);s.length===0?this.keyframes.splice(e,1):s.length!==this.keyframes[e].shapes.length&&(this.keyframes[e]={t:this.keyframes[e].t,shapes:s})}this.order=this.order.filter(e=>e!==t),this.removeFromGroup(t)}group(t){if(!(t.length<2)){for(const e of t)this.removeFromGroup(e);this.groups.push([...t])}}ungroup(t){const e=this.groups.findIndex(s=>s.includes(t));e!==-1&&this.groups.splice(e,1)}groupMembers(t){return this.groups.find(e=>e.includes(t))}removeFromGroup(t){const e=this.groups.findIndex(i=>i.includes(t));if(e===-1)return;const s=this.groups[e].filter(i=>i!==t);s.length<2?this.groups.splice(e,1):this.groups[e]=s}bringToFront(t){const e=this.order.indexOf(t);e!==-1&&(this.order.splice(e,1),this.order.push(t))}sendToBack(t){const e=this.order.indexOf(t);e!==-1&&(this.order.splice(e,1),this.order.unshift(t))}get duration(){return this.keyframes.length===0?0:this.keyframes[this.keyframes.length-1].t}get sourceIds(){return[...this.order]}get allKeyframes(){return this.keyframes}toJSON(){return{keyframes:this.keyframes,order:this.order,groups:this.groups}}static fromJSON(t){const e=new q;for(const s of t.keyframes)e.addKeyframe(s.t,s.shapes);if(t.order){const s=e.order.filter(i=>!t.order.includes(i));e.order=[...t.order,...s]}return t.groups&&(e.groups=t.groups.map(s=>s.filter(i=>e.order.includes(i))).filter(s=>s.length>=2)),e}}function Ft(n,t,e){return Math.max(t,Math.min(e,n))}function Ot(n,t,e){const s=((t-n)%360+540)%360-180;return((n+s*e)%360+360)%360}function D(n,t,e){return n+(t-n)*e}function Nt(n,t,e){return{lat:n.lat===void 0||t.lat===void 0?void 0:D(n.lat,t.lat,e),lng:n.lng===void 0||t.lng===void 0?void 0:D(n.lng,t.lng,e),elevationM:D(n.elevationM,t.elevationM,e),headingDeg:n.headingDeg===void 0||t.headingDeg===void 0?void 0:Ot(n.headingDeg,t.headingDeg,e),pitchDeg:D(n.pitchDeg,t.pitchDeg,e),rollDeg:D(n.rollDeg??0,t.rollDeg??0,e),fovDeg:D(n.fovDeg,t.fovDeg,e),fNumber:n.fNumber,focusDistanceM:n.focusDistanceM}}class _{keyframes=[];addKeyframe(t,e){const s=this.findInsertIndex(t);this.keyframes[s]?.t===t?this.keyframes[s]={t,pose:e}:this.keyframes.splice(s,0,{t,pose:e})}clear(){this.keyframes.length=0}removeKeyframeAt(t){const e=this.findInsertIndex(t);this.keyframes[e]?.t===t&&this.keyframes.splice(e,1)}findInsertIndex(t){let e=0,s=this.keyframes.length;for(;e<s;){const i=e+s>>>1;this.keyframes[i].t<t?e=i+1:s=i}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),s=this.keyframes[e]?.t===t?this.keyframes[e]:this.keyframes[e-1];if(s?.t===t)return s.pose;const i=this.keyframes[e]?.t===t?void 0:this.keyframes[e];return s?i?Nt(s.pose,i.pose,Ft((t-s.t)/(i.t-s.t),0,1)):s.pose:i?.pose}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 _;for(const s of t.keyframes)e.addKeyframe(s.t,s.pose);return e}}function k(n,t,e){return n+(t-n)*e}function Wt(n,t,e){const s=((t-n)%360+540)%360-180;return((n+s*e)%360+360)%360}function zt(n,t,e){return Math.max(t,Math.min(e,n))}function Ht(n,t,e){return{cloudCover:k(n.cloudCover,t.cloudCover,e),cloudDarkness:k(n.cloudDarkness,t.cloudDarkness,e),highCloudCover:n.highCloudCover===void 0||t.highCloudCover===void 0?void 0:k(n.highCloudCover,t.highCloudCover,e),iceCrystalAlignment:n.iceCrystalAlignment===void 0||t.iceCrystalAlignment===void 0?void 0:k(n.iceCrystalAlignment,t.iceCrystalAlignment,e),lowerCloudCover:n.lowerCloudCover===void 0||t.lowerCloudCover===void 0?void 0:k(n.lowerCloudCover,t.lowerCloudCover,e),cloudBaseM:n.cloudBaseM===void 0||t.cloudBaseM===void 0?void 0:k(n.cloudBaseM,t.cloudBaseM,e),precipitationType:e<1?n.precipitationType:t.precipitationType,precipitationIntensity:k(n.precipitationIntensity,t.precipitationIntensity,e),windDirectionDeg:Wt(n.windDirectionDeg,t.windDirectionDeg,e),windSpeed:k(n.windSpeed,t.windSpeed,e),storm:e<1?n.storm:t.storm}}class L{keyframes=[];addKeyframe(t,e){const s=this.findInsertIndex(t);this.keyframes[s]?.t===t?this.keyframes[s]={t,weather:e}:this.keyframes.splice(s,0,{t,weather:e})}clear(){this.keyframes.length=0}removeKeyframeAt(t){const e=this.findInsertIndex(t);this.keyframes[e]?.t===t&&this.keyframes.splice(e,1)}findInsertIndex(t){let e=0,s=this.keyframes.length;for(;e<s;){const i=e+s>>>1;this.keyframes[i].t<t?e=i+1:s=i}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),s=this.keyframes[e]?.t===t?this.keyframes[e]:this.keyframes[e-1];if(s?.t===t)return s.weather;const i=this.keyframes[e]?.t===t?void 0:this.keyframes[e];return s?i?Ht(s.weather,i.weather,zt((t-s.t)/(i.t-s.t),0,1)):s.weather:i?.weather}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 L;for(const s of t.keyframes)e.addKeyframe(s.t,s.weather);return e}}class F{keyframes=[];addKeyframe(t,e){const s=this.findInsertIndex(t);this.keyframes[s]?.t===t?this.keyframes[s]={t,sound:e}:this.keyframes.splice(s,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),s=this.keyframes[e]?.t===t?this.keyframes[e]:this.keyframes[e-1];if(s?.t===t)return s.sound;const i=this.keyframes[e]?.t===t?void 0:this.keyframes[e];if(!s)return i?.sound;if(!i)return s.sound;const a=(t-s.t)/(i.t-s.t);return this.lerp(s.sound,i.sound,Math.max(0,Math.min(1,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 F;for(const s of t.keyframes)e.addKeyframe(s.t,s.sound);return e}lerp(t,e,s){return{kind:s<1?t.kind:e.kind,volume:t.volume+(e.volume-t.volume)*s,pitchHz:t.pitchHz+(e.pitchHz-t.pitchHz)*s,src:s<1?t.src:e.src}}findInsertIndex(t){let e=0,s=this.keyframes.length;for(;e<s;){const i=e+s>>>1;this.keyframes[i].t<t?e=i+1:s=i}return e}}const Gt=100,Ut={kind:"none",volume:0,pitchHz:Gt};function et(n){if(n.year!==void 0)return Date.UTC(n.year,(n.month??1)-1,n.day??1,n.hour??0,n.minute??0,n.second??0)}function nt(n){return(((n.day??0)*24+(n.hour??0))*60+(n.minute??0))*6e4+(n.second??0)*1e3}const $t=["year","month","day","hour","minute"],Xt=["day","hour","minute"];function at(n,t){return t.filter(e=>n[e]!==void 0).join(",")}function Vt(n){if(n.durationSeconds!==void 0)return n.durationSeconds*1e3;if(!n.time||!n.endTime)return;const t=n.time.year!==void 0&&n.endTime.year!==void 0,e=t?$t:Xt,s=at(n.time,e);if(!(s===""||s!==at(n.endTime,e)))return t?et(n.endTime)-et(n.time):nt(n.endTime)-nt(n.time)}class Y{constructor(t,e,s,i,a,r,o,l,h=[],d,c,u,f=[]){this.event=t,this.timeline=e,this.witnessTrack=s,this.weatherTrack=i,this.soundTrack=a,this.witness=r,this.caseId=o,this.weather=l,this.decor=h,this.weatherSource=d,this.instrumentId=c,this.exposureSeconds=u,this.milestones=f}get exposure(){return this.exposureSeconds??this.instrument.exposureSeconds}get instrument(){return w.byId(this.instrumentId)}static create(t,e,s){return new Y({eventType:"sighting",time:t,place:e},new q,new _,new L,new F,s)}}const Kt=0,qt=0;function S(n,t){const e=n.witnessTrack.getInterpolatedPoseAt(t);if(e)return e;const s=n.event.place?.[0];if(s)return{lat:s.lat,lng:s.lng,elevationM:Kt,headingDeg:void 0,pitchDeg:qt,fovDeg:w.fieldOfViewDeg(n.instrument)}}function Yt(n,t){return n.soundTrack.getInterpolatedSoundAt(t)??Ut}class Zt{constructor(t,e){this.timeline=t,this.onFrame=e}rafId=null;state="stopped";currentT=0;lastWallTime=0;playbackRate=1;loop=!1;onEnded;durationOverrideMs=0;get seekableDuration(){return Math.max(this.timeline.duration,this.durationOverrideMs)}play(){if(this.state==="playing")return;this.currentT>=this.seekableDuration&&(this.currentT=0,this.resolveFrame(0)),this.state="playing",this.lastWallTime=performance.now();const t=()=>{if(this.state!=="playing")return;const e=performance.now();if(this.currentT+=(e-this.lastWallTime)*this.playbackRate,this.lastWallTime=e,this.currentT>=this.seekableDuration){if(this.loop&&this.seekableDuration>0){this.currentT%=this.seekableDuration,this.resolveFrame(this.currentT),this.rafId=requestAnimationFrame(t);return}this.currentT=this.seekableDuration,this.stop(),this.resolveFrame(this.currentT),this.onEnded?.();return}this.resolveFrame(this.currentT),this.rafId=requestAnimationFrame(t)};this.rafId=requestAnimationFrame(t)}pause(){this.state==="playing"&&(this.state="paused",this.rafId!==null&&(cancelAnimationFrame(this.rafId),this.rafId=null))}stop(){this.state="stopped",this.rafId!==null&&(cancelAnimationFrame(this.rafId),this.rafId=null)}seek(t){this.currentT=Math.max(0,Math.min(t,this.seekableDuration)),this.resolveFrame(this.currentT)}get playbackState(){return this.state}get time(){return this.currentT}resolveFrame(t){const e=new Map;for(const s of this.timeline.sourceIds){const i=this.timeline.getInterpolatedShapeAt(t,s);i&&e.set(s,i)}this.onFrame(t,e)}}const kt=["nw","n","ne","e","se","s","sw","w"],Jt=24,W=8,jt=3,Qt=8;function z(n,t,e){const s=n.x-t.x,i=n.y-t.y,a=Math.cos(e),r=Math.sin(e);return{x:t.x+s*a-i*r,y:t.y+s*r+i*a}}function B(n){return{x:n.x+n.width/2,y:n.y+n.height/2}}const te={nw:{left:!0,top:!0},n:{top:!0},ne:{right:!0,top:!0},e:{right:!0},se:{right:!0,bottom:!0},s:{bottom:!0},sw:{left:!0,bottom:!0},w:{left:!0}};class b{static handlePointsFor(t){const{x:e,y:s,width:i,height:a}=t.bounds,r={nw:{x:e,y:s},n:{x:e+i/2,y:s},ne:{x:e+i,y:s},e:{x:e+i,y:s+a/2},se:{x:e+i,y:s+a},s:{x:e+i/2,y:s+a},sw:{x:e,y:s+a},w:{x:e,y:s+a/2},rotate:{x:e+i/2,y:s-Jt}},o=B(t.bounds),l={};for(const h of Object.keys(r))l[h]=z(r[h],o,t.angle);return l}static hitTestHandle(t,e,s=8,i=[...kt,"rotate"]){const a=b.handlePointsFor(t);for(const r of i)if(Math.hypot(e.x-a[r].x,e.y-a[r].y)<=s)return r}static HANDLE_DIRECTION_DEG={e:0,se:45,s:90,sw:135,w:180,nw:225,n:270,ne:315};static resizeAxisFor(t,e){const i=((b.HANDLE_DIRECTION_DEG[t]+e*180/Math.PI)%180+180)%180/45,a=["ew","nwse","ns","nesw"];return a[Math.round(i)%a.length]}static resizeBounds(t,e,s,i){const a=B(t),r=z(i,a,-e),{x:o,y:l,width:h,height:d}=t,c=te[s];let u=o,f=l,m=o+h,p=l+d;return c.left&&(u=Math.min(r.x,m-W)),c.right&&(m=Math.max(r.x,u+W)),c.top&&(f=Math.min(r.y,p-W)),c.bottom&&(p=Math.max(r.y,f+W)),{x:u,y:f,width:m-u,height:p-f}}static resizeShape(t,e,s){if(e==="rotate")throw new Error("resizeShape does not accept the rotate handle");const{width:i,height:a}=t.bounds,r=b.resizeBounds(t.bounds,t.angle,e,s);if(t.kind==="oval")return{...t,bounds:r};const o=i===0?1:r.width/i,l=a===0?1:r.height/a;return{...t,bounds:r,points:t.points.map(h=>({x:h.x*o,y:h.y*l}))}}static rotateShape(t,e){const s=B(t.bounds),i=Math.atan2(e.y-s.y,e.x-s.x)+Math.PI/2;return{...t,angle:i}}static groupBoundsFor(t){const e=Math.min(...t.map(r=>r.x)),s=Math.min(...t.map(r=>r.y)),i=Math.max(...t.map(r=>r.x+r.width)),a=Math.max(...t.map(r=>r.y+r.height));return{x:e,y:s,width:i-e,height:a-s}}static vertexPointsFor(t){const e=B(t.bounds);return t.points.map(s=>z({x:t.bounds.x+s.x,y:t.bounds.y+s.y},e,t.angle))}static hitTestVertex(t,e,s=Qt){const i=b.vertexPointsFor(t);let a,r=s;return i.forEach((o,l)=>{const h=Math.hypot(e.x-o.x,e.y-o.y);h<=r&&(r=h,a=l)}),a}static toLocalPoint(t,e){const s=B(t.bounds),i=z(e,s,-t.angle);return{x:i.x-t.bounds.x,y:i.y-t.bounds.y}}static moveVertex(t,e,s){const i=t.points.map((c,u)=>u===e?b.toLocalPoint(t,s):c),a=Math.min(...i.map(c=>c.x)),r=Math.min(...i.map(c=>c.y)),o=Math.max(...i.map(c=>c.x)),l=Math.max(...i.map(c=>c.y)),h={x:t.bounds.x+a,y:t.bounds.y+r,width:o-a,height:l-r},d=i.map(c=>({x:c.x-a,y:c.y-r}));return{...t,bounds:h,points:d}}static insertVertexNear(t,e){const s=b.toLocalPoint(t,e),{points:i}=t;let a=i.length-1,r=1/0;for(let l=0;l<i.length;l++){const h=i[l],d=i[(l+1)%i.length],c=b.distanceToSegment(s,h,d);c<r&&(r=c,a=l)}const o=[...i.slice(0,a+1),s,...i.slice(a+1)];return{...t,points:o}}static distanceToSegment(t,e,s){const i=s.x-e.x,a=s.y-e.y,r=i*i+a*a,o=r===0?0:Math.max(0,Math.min(1,((t.x-e.x)*i+(t.y-e.y)*a)/r)),l=e.x+o*i,h=e.y+o*a;return Math.hypot(t.x-l,t.y-h)}static deleteVertex(t,e){return t.points.length<=jt?t:{...t,points:t.points.filter((s,i)=>i!==e)}}}const st=6,H=st/2,ee=20,se=24,ie=9,rt=6,ne=7,ae=6,ot=4;class re{constructor(t){this.ctx=t}starPoints=0;roll=0;clear(t,e){this.ctx.clearRect(0,0,t,e)}paintShape(t){this.ctx.save(),this.ctx.globalAlpha=1-t.transparency;const e=t.blur??0;e>0&&(this.ctx.filter=`blur(${(se*e).toFixed(2)}px)`);const s=t.brightness??0;s>0&&this.paintDazzle(t,s),t.haloScale>0&&this.paintHalo(t),this.paintBase(t),this.ctx.restore(),t.selected&&this.paintSelectionHandles(t)}setStarPoints(t){this.starPoints=Math.max(0,Math.floor(t))}setRoll(t){this.roll=t}paintDazzle(t,e){const{x:s,y:i,width:a,height:r}=t.bounds,o=s+a/2,l=i+r/2,h=Math.max(a,r)/2,d=Math.max(h*(1+ie*e),ae*e);if(d<=0)return;this.ctx.save(),this.ctx.globalCompositeOperation="lighter";const c=this.ctx.createRadialGradient(o,l,0,o,l,d);for(let u=0;u<=rt;u++){const f=u/rt,m=1/(1+24*f*f);this.ctx.globalAlpha=1,c.addColorStop(f,this.withAlpha(t.color,m*e*.55))}if(this.ctx.fillStyle=c,this.ctx.beginPath(),this.ctx.arc(o,l,d,0,2*Math.PI),this.ctx.fill(),this.starPoints>0){const u=h*(1+ne*e);this.ctx.lineWidth=Math.max(1,h*.12),this.ctx.lineCap="round";for(let f=0;f<this.starPoints;f++){const m=f/this.starPoints*Math.PI*2+this.roll,p=o+Math.cos(m)*u,g=l+Math.sin(m)*u,M=this.ctx.createLinearGradient(o,l,p,g);M.addColorStop(0,this.withAlpha(t.color,e*.55)),M.addColorStop(.35,this.withAlpha(t.color,e*.22)),M.addColorStop(1,this.withAlpha(t.color,0)),this.ctx.strokeStyle=M,this.ctx.beginPath(),this.ctx.moveTo(o,l),this.ctx.lineTo(p,g),this.ctx.stroke()}}this.ctx.restore()}dazzledFill(t,e){if(e<=0)return t.color;const s=/^#([0-9a-f]{6})$/i.exec(t.color.trim());if(!s)return t.color;const i=Number.parseInt(s[1],16),a=r=>Math.round(r+(255-r)*e);return`rgb(${a(i>>16&255)}, ${a(i>>8&255)}, ${a(i&255)})`}withAlpha(t,e){const s=Math.max(0,Math.min(1,e)),i=/^#([0-9a-f]{6})$/i.exec(t.trim());if(!i)return t;const a=Number.parseInt(i[1],16);return`rgba(${a>>16&255}, ${a>>8&255}, ${a&255}, ${s.toFixed(3)})`}paintBase(t){if(this.ctx.fillStyle=this.dazzledFill(t,t.brightness??0),this.ctx.beginPath(),t.kind==="oval"){const{x:e,y:s,width:i,height:a}=t.bounds,r=i/2,o=a/2;this.ctx.ellipse(e+r,s+o,r,o,t.angle,0,2*Math.PI)}else{const{x:e,y:s,width:i,height:a}=t.bounds;this.ctx.save(),this.ctx.translate(e+i/2,s+a/2),this.ctx.rotate(t.angle),this.ctx.translate(-i/2,-a/2),t.points.forEach((r,o)=>{o===0?this.ctx.moveTo(r.x,r.y):this.ctx.lineTo(r.x,r.y)}),this.ctx.closePath(),this.ctx.restore()}this.ctx.fill()}paintHalo(t){this.ctx.save(),this.ctx.shadowColor=t.color,this.ctx.shadowBlur=ee*t.haloScale,this.paintBase(t),this.ctx.restore()}paintSelectionHandles(t){this.paintHandleFrame(b.handlePointsFor(t),{includeRotate:!0}),t.kind==="polygon"&&this.paintVertexHandles(t)}paintVertexHandles(t){this.ctx.fillStyle="#39f";for(const e of b.vertexPointsFor(t))this.ctx.beginPath(),this.ctx.ellipse(e.x,e.y,ot,ot,0,0,2*Math.PI),this.ctx.fill()}paintMemberOutline(t){this.paintOutline(b.handlePointsFor(t))}paintGroupHandles(t){this.paintHandleFrame(b.handlePointsFor({bounds:t,angle:0}),{includeRotate:!0})}paintOutline(t){this.ctx.strokeStyle="lightgray",this.ctx.beginPath(),this.ctx.moveTo(t.nw.x,t.nw.y),this.ctx.lineTo(t.ne.x,t.ne.y),this.ctx.lineTo(t.se.x,t.se.y),this.ctx.lineTo(t.sw.x,t.sw.y),this.ctx.closePath(),this.ctx.stroke()}paintHandleFrame(t,{includeRotate:e}){this.paintOutline(t),this.ctx.fillStyle="lightgray";for(const s of kt){const i=t[s];this.ctx.fillRect(i.x-H,i.y-H,st,st)}e&&(this.ctx.beginPath(),this.ctx.moveTo(t.n.x,t.n.y),this.ctx.lineTo(t.rotate.x,t.rotate.y),this.ctx.stroke(),this.ctx.beginPath(),this.ctx.ellipse(t.rotate.x,t.rotate.y,H+1,H+1,0,0,2*Math.PI),this.ctx.fill())}}const ht=.05,lt=.08,ct=2,dt=3,oe=14,he=.02;class le{context;voice;voiceToken=0;buffers=new Map;noiseBuffer;crackleBuffer;requested;resume(){if(!this.context){if(typeof AudioContext>"u")return;try{this.context=new AudioContext}catch(t){console.warn("SightingAudio: Web Audio unavailable, the sighting stays silent:",t);return}}this.context.state==="suspended"&&this.context.resume()}setSound(t){if(this.requested=t,!this.context)return;const e=this.keyFor(t);if(!e){this.silence();return}if(this.voice?.key!==e){this.stopVoice();const s=++this.voiceToken;e.startsWith("src:")?this.buildRecordedVoice(t.src,e,s):this.voice=this.buildSynthesizedVoice(t,e)}this.applyTo(this.voice,t)}silence(){this.voiceToken++,this.stopVoice()}dispose(){this.silence(),this.context?.close(),this.context=void 0,this.buffers.clear(),this.noiseBuffer=void 0,this.crackleBuffer=void 0}keyFor(t){if(!(t.volume<=0))return t.src?`src:${t.src}`:t.kind==="none"?void 0:t.kind}applyTo(t,e){const s=this.context;if(!t||!s)return;const i=s.currentTime;t.volumeParam.setTargetAtTime(Math.max(0,Math.min(1,e.volume))*t.gainScale,i,ht);for(const{param:a,ratio:r}of t.pitch)a.setTargetAtTime(Math.min(e.pitchHz*r,s.sampleRate/2-1),i,ht)}buildSynthesizedVoice(t,e){const s=this.context;if(s)switch(t.kind){case"hum":return this.buildHum(s,e);case"whistle":return this.buildWhistle(s,e);case"rumble":return this.buildRumble(s,e);case"crackle":return this.buildCrackle(s,e);default:return}}buildHum(t,e){const s=t.createOscillator();s.type="sawtooth";const i=t.createOscillator();i.type="sawtooth";const a=t.createBiquadFilter();a.type="lowpass",a.Q.value=1;const r=t.createGain();return r.gain.value=0,s.connect(a),i.connect(a),a.connect(r).connect(t.destination),s.start(),i.start(),{key:e,nodes:[a,r],sources:[s,i],volumeParam:r.gain,gainScale:.16,pitch:[{param:s.frequency,ratio:1},{param:i.frequency,ratio:1.006},{param:a.frequency,ratio:6}]}}buildWhistle(t,e){const s=t.createOscillator();s.type="sine";const i=t.createOscillator();i.type="sine",i.frequency.value=5;const a=t.createGain(),r=t.createGain();return r.gain.value=0,i.connect(a).connect(s.frequency),s.connect(r).connect(t.destination),s.start(),i.start(),{key:e,nodes:[a,r],sources:[s,i],volumeParam:r.gain,gainScale:.22,pitch:[{param:s.frequency,ratio:1},{param:a.gain,ratio:.012}]}}buildRumble(t,e){const s=t.createBufferSource();s.buffer=this.brownNoise(t),s.loop=!0;const i=t.createBiquadFilter();i.type="lowpass",i.Q.value=.8;const a=t.createGain();return a.gain.value=0,s.connect(i).connect(a).connect(t.destination),s.start(),{key:e,nodes:[i,a],sources:[s],volumeParam:a.gain,gainScale:1.4,pitch:[{param:i.frequency,ratio:1}]}}buildCrackle(t,e){const s=t.createBufferSource();s.buffer=this.whiteNoise(t),s.loop=!0;const i=t.createBiquadFilter();i.type="bandpass",i.Q.value=1.2;const a=t.createGain();a.gain.value=0;const r=t.createBufferSource();r.buffer=this.crackleEnvelope(t),r.loop=!0;const o=t.createGain();return o.gain.value=0,r.connect(o).connect(a.gain),s.connect(i).connect(a).connect(t.destination),s.start(),r.start(),{key:e,nodes:[i,a,o],sources:[s,r],volumeParam:o.gain,gainScale:.9,pitch:[{param:i.frequency,ratio:4}]}}async buildRecordedVoice(t,e,s){const i=this.context;if(!i)return;let a;try{a=await this.getBuffer(t)}catch(l){console.warn("SightingAudio: the recorded sound failed to load, staying silent:",l);return}if(s!==this.voiceToken||!this.context)return;const r=i.createBufferSource();r.buffer=a,r.loop=!0;const o=i.createGain();o.gain.value=0,r.connect(o).connect(i.destination),r.start(),this.voice={key:e,nodes:[o],sources:[r],volumeParam:o.gain,gainScale:1,pitch:[]},this.requested&&this.applyTo(this.voice,this.requested)}async getBuffer(t){const e=this.context;if(!e)throw new Error("SightingAudio: AudioContext not ready — resume() must be called first");let s=this.buffers.get(t);return s||(s=fetch(t).then(i=>{if(!i.ok)throw new Error(`Audio fetch failed (${i.status}): ${t}`);return i.arrayBuffer()}).then(i=>e.decodeAudioData(i)),this.buffers.set(t,s)),s}whiteNoise(t){if(!this.noiseBuffer){const e=t.createBuffer(1,Math.floor(t.sampleRate*ct),t.sampleRate),s=e.getChannelData(0);for(let i=0;i<s.length;i++)s[i]=Math.random()*2-1;this.noiseBuffer=e}return this.noiseBuffer}brownNoise(t){const e=t.createBuffer(1,Math.floor(t.sampleRate*ct),t.sampleRate),s=e.getChannelData(0);let i=0,a=0;for(let r=0;r<s.length;r++)i=(i+.02*(Math.random()*2-1))/1.02,s[r]=i,a=Math.max(a,Math.abs(i));if(a>0)for(let r=0;r<s.length;r++)s[r]/=a;return e}crackleEnvelope(t){if(!this.crackleBuffer){const e=t.createBuffer(1,Math.floor(t.sampleRate*dt),t.sampleRate),s=e.getChannelData(0),i=Math.max(1,Math.floor(he*t.sampleRate)),a=Math.round(dt*oe);for(let r=0;r<a;r++){const o=Math.floor(Math.random()*s.length),l=.4+Math.random()*.6;for(let h=0;h<i&&o+h<s.length;h++)s[o+h]=Math.max(s[o+h],l*(1-h/i))}this.crackleBuffer=e}return this.crackleBuffer}stopVoice(){const t=this.voice,e=this.context;if(this.voice=void 0,!t||!e)return;const s=e.currentTime;t.volumeParam.cancelScheduledValues(s),t.volumeParam.setTargetAtTime(0,s,lt/3);const i=s+lt;for(const a of t.sources){a.onended=()=>{a.disconnect();for(const r of t.nodes)r.disconnect()};try{a.stop(i)}catch{a.disconnect();for(const r of t.nodes)r.disconnect()}}}}function X(n){return[...n].sort((t,e)=>t.t-e.t)}function ut(n,t){let e;for(const s of X(n)){if(s.t>t)break;e=s}return e}const J=Math.PI/180,G=180/Math.PI;class E{constructor(t,e,s){this.kind=t,this.canvasHeightPx=e,this.fovDeg=s;const i=s*J/2;this.focalPx=t==="equidistant"?e/2/i:e/2/Math.tan(i)}focalPx;static of(t,e,s){return new E(t.projection,e,s)}degToPx(t){const e=t*J;return this.kind==="equidistant"?this.focalPx*e:2*this.focalPx*Math.tan(e/2)}pxToDeg(t){return this.kind==="equidistant"?t/this.focalPx*G:2*Math.atan(t/(2*this.focalPx))*G}angleDegToRadiusPx(t){const e=t*J;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*G:Math.atan(t/this.focalPx)*G}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(x.angularWidthDeg(t))}}class I{static fovOf(t,e){return S(t,e)?.fovDeg??w.fieldOfViewDeg(t.instrument)}static toAngular(t){this.eachKeyframe(t,(e,s)=>({...e,angular:s.ofBounds(e.bounds)}))}static toBounds(t){this.eachKeyframe(t,(e,s)=>{if(!e.angular)return e;const{width:i,height:a}=s.toBoundsSize(e.angular),r={x:e.bounds.x+(e.bounds.width-i)/2,y:e.bounds.y+(e.bounds.height-a)/2,width:i,height:a};if(e.kind!=="polygon")return{...e,bounds:r};const o=e.bounds.width===0?1:i/e.bounds.width,l=e.bounds.height===0?1:a/e.bounds.height;return{...e,bounds:r,points:e.points.map(h=>({x:h.x*o,y:h.y*l}))}})}static toAim(t){this.eachKeyframe(t,(e,s,i)=>{if(i?.headingDeg===void 0)return e;const a=this.frameCentre(t),r=s.radiusPxToAngleDeg(e.bounds.x+e.bounds.width/2-a.x),o=s.radiusPxToAngleDeg(a.y-(e.bounds.y+e.bounds.height/2));return{...e,aim:{azimuthDeg:((i.headingDeg+r)%360+360)%360,altitudeDeg:i.pitchDeg+o}}})}static toPosition(t){this.eachKeyframe(t,(e,s,i)=>{if(!e.aim||i?.headingDeg===void 0)return e;const a=this.frameCentre(t),r=this.shortestArc(e.aim.azimuthDeg-i.headingDeg),o=e.aim.altitudeDeg-i.pitchDeg,l=a.x+this.offAxisPx(s,r)-e.bounds.width/2,h=a.y-this.offAxisPx(s,o)-e.bounds.height/2;return{...e,bounds:{...e.bounds,x:l,y:h}}})}static frameCentre(t){return{x:w.frameWidthPx(t.instrument,x.CANVAS_HEIGHT_PX)/2,y:x.CANVAS_HEIGHT_PX/2}}static shortestArc(t){return(t%360+540)%360-180}static offAxisPx(t,e){return Math.abs(e)>=I.OFF_CANVAS_DEG?Math.sign(e)*I.OFF_CANVAS_PX:t.angleDegToRadiusPx(e)}static OFF_CANVAS_DEG=89;static OFF_CANVAS_PX=1e5;static reproject(t,e,s){const i=w.frameWidthPx(e,x.CANVAS_HEIGHT_PX)/2,a=w.frameWidthPx(t.instrument,x.CANVAS_HEIGHT_PX)/2,r=x.CANVAS_HEIGHT_PX/2;for(const o of[...t.timeline.allKeyframes]){const l=this.fovOf(t,o.t),h=s?.get(o.t)??l,d=E.of(e,x.CANVAS_HEIGHT_PX,h),c=E.of(t.instrument,x.CANVAS_HEIGHT_PX,l);t.timeline.addKeyframe(o.t,o.shapes.map(u=>{const{bounds:f}=u.shape,m=f.x+f.width/2-i,p=f.y+f.height/2-r,g=Math.hypot(m,p),M=g===0?1:c.angleDegToRadiusPx(d.radiusPxToAngleDeg(g))/g,O={...f,x:a+m*M-f.width/2,y:r+p*M-f.height/2};return{...u,shape:{...u.shape,bounds:O}}}))}this.toBounds(t)}static eachKeyframe(t,e){const{timeline:s}=t;for(const i of[...s.allKeyframes]){const a=S(t,i.t),r=this.fovOf(t,i.t),o=E.of(t.instrument,x.CANVAS_HEIGHT_PX,r);s.addKeyframe(i.t,i.shapes.map(l=>({...l,shape:e(l.shape,o,a)})))}}}function ce(n){return I.toAngular(n),I.toAim(n),{version:1,time:n.event.time,endTime:n.event.endTime,durationSeconds:n.event.durationSeconds,utcOffsetHours:n.event.utcOffsetHours,timeZone:n.event.timeZone,place:n.event.place,witness:n.witness,caseId:n.caseId,description:n.event.description,tags:n.event.tags,timeline:n.timeline.toJSON(),witnessTrack:n.witnessTrack.toJSON(),weatherTrack:n.weatherTrack.toJSON(),soundTrack:n.soundTrack.toJSON(),weather:n.weather,decor:n.decor,milestones:n.milestones.length>0?n.milestones:void 0,weatherSource:n.weatherSource,instrument:n.instrumentId,exposureSeconds:n.exposureSeconds}}function de(n){const t=new Y({eventType:"sighting",time:n.time,endTime:n.endTime,durationSeconds:n.durationSeconds,utcOffsetHours:n.utcOffsetHours,timeZone:n.timeZone,place:n.place,description:n.description,tags:n.tags},q.fromJSON(n.timeline),n.witnessTrack?_.fromJSON(n.witnessTrack):new _,n.weatherTrack?L.fromJSON(n.weatherTrack):new L,n.soundTrack?F.fromJSON(n.soundTrack):new F,n.witness,n.caseId,n.weather,n.decor??[],n.weatherSource,n.instrument,n.exposureSeconds??n.witnessTrack?.keyframes.map(e=>e.pose.exposureSeconds).find(e=>e!==void 0),X(n.milestones??[]));return I.toBounds(t),I.toPosition(t),t}function ue(n,t){for(const e of n){const s=e.toLowerCase().split("-")[0];if(t.includes(s))return s}return"en"}class ft{static preferencesFor(t){const e=navigator.languages??[],s=this.declaredFor(t);return s?[s,...e]:e}static declaredFor(t){for(let e=t;e;){const s=e.closest("[lang]")?.getAttribute("lang")?.trim();if(s)return s;const i=e.getRootNode();e=i instanceof ShadowRoot?i.host:void 0}}}class T{constructor(t){this.preferences=t}read(t){if(t===void 0||typeof t=="string")return t===""?void 0:t;for(const s of this.preferences){const i=t[s]??t[T.base(s)];if(i)return i}const e=new Set(this.preferences.map(s=>T.base(s)));for(const[s,i]of Object.entries(t))if(i&&e.has(T.base(s)))return i;return Object.values(t).find(s=>s)??void 0}write(t,e,s){const i=e?.trim()?e.trim():void 0;if(t===void 0||typeof t=="string")return i;const a={...t},r=Object.keys(a).find(o=>o===s)??Object.keys(a).find(o=>T.base(o)===T.base(s))??s;return i===void 0?delete a[r]:a[r]=i,Object.keys(a).length===0?void 0:a}static base(t){return t.toLowerCase().split("-")[0]}}const fe="modulepreload",me=function(n,t){return new URL(n,t).href},mt={},pt=function(t,e,s){let i=Promise.resolve();if(e&&e.length>0){let r=function(d){return Promise.all(d.map(c=>Promise.resolve(c).then(u=>({status:"fulfilled",value:u}),u=>({status:"rejected",reason:u}))))};const o=document.getElementsByTagName("link"),l=document.querySelector("meta[property=csp-nonce]"),h=l?.nonce||l?.getAttribute("nonce");i=r(e.map(d=>{if(d=me(d,s),d in mt)return;mt[d]=!0;const c=d.endsWith(".css"),u=c?'[rel="stylesheet"]':"";if(!!s)for(let p=o.length-1;p>=0;p--){const g=o[p];if(g.href===d&&(!c||g.rel==="stylesheet"))return}else if(document.querySelector(`link[href="${d}"]${u}`))return;const m=document.createElement("link");if(m.rel=c?"stylesheet":fe,c||(m.as="script"),m.crossOrigin="",m.href=d,h&&m.setAttribute("nonce",h),document.head.appendChild(m),c)return new Promise((p,g)=>{m.addEventListener("load",p),m.addEventListener("error",()=>g(new Error(`Unable to preload CSS for ${d}`)))})}))}function a(r){const o=new Event("vite:preloadError",{cancelable:!0});if(o.payload=r,window.dispatchEvent(o),!o.defaultPrevented)throw r}return i.then(r=>{for(const o of r||[])o.status==="rejected"&&a(o.reason);return t().catch(a)})},pe=["en","fr"],ge={en:()=>pt(()=>Promise.resolve().then(()=>we),void 0,import.meta.url).then(n=>n.ufoMessages_en),fr:()=>pt(()=>import("./UfoMessages_fr-BJPYHN17.js"),[],import.meta.url).then(n=>n.ufoMessages_fr)};function ye(n){return ge[n]()}const St={play:"Play",pause:"Pause",noDuration:"No observation duration",autoReplay:"Auto-replay",currentPosition:"Current position",duration:"Duration",switchToElapsed:"click to show elapsed time",switchToClockTime:"click to show the time of day",fullscreen:"Fullscreen",exitFullscreen:"Exit fullscreen",showWitnessMap:"Show where the witness was",hideWitnessMap:"Hide where the witness was",mapImageryUnavailable:"Aerial imagery unavailable",showMilestones:"Show the account's moments",hideMilestones:"Hide the account's moments",witnessHere:"The witness, here",decorHere:"Scenery"},we=Object.freeze(Object.defineProperty({__proto__:null,ufoMessages_en:St},Symbol.toStringTag,{value:"Module"})),Tt=Math.PI/180,V=111320;function C(n,t,e,s){const i=V*Math.cos(e*Tt),a=(n-e)*V;return{x:(t-s)*i,z:-a}}function R(n,t,e,s){const i=V*Math.cos(e*Tt),a=-t,r=n;return{lat:e+a/V,lng:s+r/i}}class K{constructor(t){this.points=t}static STATIONARY_M=5;static of(t){const e=[];for(const s of t.witnessTrack.allKeyframes){const{lat:i,lng:a,headingDeg:r}=s.pose;i===void 0||a===void 0||e.push({t:s.t,lat:i,lng:a,headingDeg:r})}if(e.length===0){const s=t.event.place?.[0];if(!s)return;e.push({t:0,lat:s.lat,lng:s.lng})}return new K(e)}get moved(){return this.spanM>K.STATIONARY_M}get spanM(){const t=this.box,e=(t.south+t.north)/2,s=(t.west+t.east)/2;return Math.max(Math.abs(C(e,t.east,e,t.west).x),Math.abs(C(t.north,s,t.south,s).z))}get center(){const t=this.box;return{lat:(t.south+t.north)/2,lng:(t.west+t.east)/2}}boundsAround(t,e){const{lat:s,lng:i}=this.center,a=Math.max(this.spanM*(1+e),t)/2;return{north:R(0,-a,s,i).lat,south:R(0,a,s,i).lat,east:R(a,0,s,i).lng,west:R(-a,0,s,i).lng}}get box(){const t=this.points.map(s=>s.lat),e=this.points.map(s=>s.lng);return{south:Math.min(...t),north:Math.max(...t),west:Math.min(...e),east:Math.max(...e)}}}function be(n,t){const e=n.track,s={eastM:n.eastM,northM:n.northM,altitudeM:0,headingDeg:n.headingDeg};if(!e||e.length===0)return s;if(e.length===1||t<=e[0].t)return gt(e[0],n);const i=e[e.length-1];if(t>=i.t)return gt(i,n);for(let a=0;a<e.length-1;a++){const r=e[a],o=e[a+1];if(t<r.t||t>o.t)continue;const l=o.t-r.t,h=l===0?0:(t-r.t)/l;return{eastM:r.eastM+(o.eastM-r.eastM)*h,northM:r.northM+(o.northM-r.northM)*h,altitudeM:(r.altitudeM??0)+((o.altitudeM??0)-(r.altitudeM??0))*h,headingDeg:r.headingDeg??n.headingDeg}}return s}function gt(n,t){return{eastM:n.eastM,northM:n.northM,altitudeM:n.altitudeM??0,headingDeg:n.headingDeg??t.headingDeg}}const Pt=Math.PI/180,ve=180/Math.PI,xe=256,Me=19;function ke(n,t){return 156543.03392*Math.cos(n*Pt)/2**t}function Se(n,t){return ke(n,t)*xe}function Te(n,t){let e=0;for(;e<Me&&Se(n,e+1)>=t;)e++;return e}function $(n){const t=n*Pt;return(1-Math.log(Math.tan(t)+1/Math.cos(t))/Math.PI)/2}function Pe(n,t,e){const s=2**e;return{x:(n+180)/360*s,y:$(t)*s}}function Ee(n,t,e){const s=$(n.north),i=$(n.south);return{x:(t-n.west)/(n.east-n.west),y:($(e)-s)/(i-s)}}function Ie(n,t,e){const{x:s,y:i}=Pe(n,t,e);return{x:Math.floor(s),y:Math.floor(i),z:e}}function Ae(n){const t=2**n.z,e=n.x/t*360-180,s=(n.x+1)/t*360-180,i=yt(n.y,t);return{south:yt(n.y+1,t),north:i,west:e,east:s}}function yt(n,t){const e=n/t;return Math.atan(Math.sinh(Math.PI*(1-2*e)))*ve}function De(n,t,e,s){const i=Ie(n,t,e),a=Math.floor(s/2),r=[];for(let h=-a;h<=a;h++)for(let d=-a;d<=a;d++)r.push({x:i.x+d,y:i.y+h,z:e});const o=r.map(Ae),l={south:Math.min(...o.map(h=>h.south)),north:Math.max(...o.map(h=>h.north)),west:Math.min(...o.map(h=>h.west)),east:Math.max(...o.map(h=>h.east))};return{tiles:r,bounds:l}}class P{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 s,i=1/0;for(const a of this.targets){const r=Math.hypot(a.x-t,a.y-e);r>a.radius||r>i||(s=a,i=r)}return s}get width(){return this.ctx.canvas.width}get height(){return this.ctx.canvas.height}paint(t){const{ctx:e}=this;e.save(),this.targets=[],e.clearRect(0,0,this.width,this.height),this.paintGround(t),this.paintNight(t.nightFraction),this.paintPath(t),t.position?(this.paintCone(t,t.position),this.paintDecor(t),this.paintMarkers(t),this.paintWitness(t,t.position)):(this.paintDecor(t),this.paintMarkers(t)),this.paintNorth(),this.paintFooter(t.bounds,t.attribution),e.restore()}toCanvas(t,e,s){const i=Ee(t,s,e);return{x:i.x*this.width,y:i.y*this.height}}paintGround(t){const{ctx:e}=this;e.fillStyle="#1d2321",e.fillRect(0,0,this.width,this.height);const s=t.imagery;if(!s)return;const i=this.toCanvas(t.bounds,s.bounds.north,s.bounds.west),a=this.toCanvas(t.bounds,s.bounds.south,s.bounds.east);e.drawImage(s.source,i.x,i.y,a.x-i.x,a.y-i.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 s of t.decor){const i=this.toCanvas(t.bounds,s.lat,s.lng);if(s.label&&this.targets.push({kind:"decor",label:s.label,lat:s.lat,lng:s.lng,x:i.x,y:i.y,radius:7}),e.beginPath(),e.rect(i.x-3.5,i.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(),s.headingDeg===void 0)continue;const a=(s.headingDeg-90)*Math.PI/180;e.beginPath(),e.moveTo(i.x,i.y),e.lineTo(i.x+Math.cos(a)*10,i.y+Math.sin(a)*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,s=t.path.points.map(i=>this.toCanvas(t.bounds,i.lat,i.lng));e.beginPath(),e.moveTo(s[0].x,s[0].y);for(const i of s.slice(1))e.lineTo(i.x,i.y);e.lineJoin="round",e.lineCap="round",e.strokeStyle="rgba(0, 0, 0, 0.65)",e.lineWidth=5,e.stroke(),e.strokeStyle="rgba(255, 255, 255, 0.9)",e.lineWidth=2,e.stroke()}paintCone(t,e){const{headingDeg:s,coneHalfAngleDeg:i}=t;if(s===void 0||i===void 0)return;const{ctx:a}=this,r=this.toCanvas(t.bounds,e.lat,e.lng),o=Math.hypot(this.width,this.height),l=(s-90)*Math.PI/180,h=i*Math.PI/180;a.save(),a.beginPath(),a.moveTo(r.x,r.y),a.arc(r.x,r.y,o,l-h,l+h),a.closePath();const d=a.createRadialGradient(r.x,r.y,0,r.x,r.y,o);d.addColorStop(0,"rgba(255, 224, 130, 0.55)"),d.addColorStop(.35,"rgba(255, 224, 130, 0.22)"),d.addColorStop(1,"rgba(255, 224, 130, 0)"),a.fillStyle=d,a.fill(),a.restore()}paintMarkers(t){const{ctx:e}=this;e.textAlign="center",e.textBaseline="middle",e.font="bold 10px sans-serif";for(const s of[...t.markers].sort((i,a)=>Number(i.current)-Number(a.current))){const i=this.toCanvas(t.bounds,s.lat,s.lng);this.targets.push({kind:"milestone",label:s.note?`${s.label} — ${s.note}`:s.label,lat:s.lat,lng:s.lng,t:s.t,x:i.x,y:i.y,radius:P.MARKER_RADIUS_PX}),e.beginPath(),e.arc(i.x,i.y,P.MARKER_RADIUS_PX,0,Math.PI*2),e.fillStyle=s.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=s.current?"#1d2321":"#fff",e.fillText(s.label,i.x,i.y)}}paintWitness(t,e){const{ctx:s}=this,i=this.toCanvas(t.bounds,e.lat,e.lng);t.witnessLabel&&this.targets.push({kind:"witness",label:t.witnessLabel,lat:e.lat,lng:e.lng,x:i.x,y:i.y,radius:8});const a=t.markers.some(r=>{if(!r.current)return!1;const o=C(r.lat,r.lng,e.lat,e.lng);return Math.hypot(o.x,o.z)<=P.ON_MARKER_M});s.beginPath(),s.arc(i.x,i.y,a?P.MARKER_RADIUS_PX+2.5:5.5,0,Math.PI*2),a||(s.fillStyle="#ff5a3c",s.fill()),s.lineWidth=4,s.strokeStyle="rgba(0, 0, 0, 0.5)",s.stroke(),s.lineWidth=a?3:2.5,s.strokeStyle=a?"#ff5a3c":"#fff",s.stroke()}paintNorth(){const{ctx:t}=this,e=this.width-14,s=16;t.beginPath(),t.moveTo(e,s-9),t.lineTo(e-4.5,s+5),t.lineTo(e,s+2),t.lineTo(e+4.5,s+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,s+6),t.fillText("N",e,s+6)}paintFooter(t,e){const{ctx:s}=this;s.font="9px sans-serif",s.textBaseline="bottom";const i=e?this.wrap(e,this.width-20):[];let a=this.height-4;s.textAlign="right";for(const f of i.slice().reverse())this.paintOutlinedText(f,this.width-6,a),a-=11;const r=(t.south+t.north)/2,l=Math.abs(C(r,t.east,r,t.west).x)/this.width,h=P.SCALE_STEPS_M.find(f=>f/l<=this.width/3);if(h===void 0)return;const d=h/l,c=8,u=a-3;s.lineWidth=3,s.strokeStyle="rgba(0, 0, 0, 0.6)",s.beginPath(),s.moveTo(c,u),s.lineTo(c+d,u),s.stroke(),s.lineWidth=1.5,s.strokeStyle="rgba(255, 255, 255, 0.95)",s.stroke(),s.textAlign="left",this.paintOutlinedText(h>=1e3?`${h/1e3} km`:`${h} m`,c,u-3)}paintOutlinedText(t,e,s){const{ctx:i}=this;i.lineWidth=3,i.strokeStyle="rgba(0, 0, 0, 0.75)",i.strokeText(t,e,s),i.fillStyle="#fff",i.fillText(t,e,s)}wrap(t,e){const s=[];let i="";for(const a of t.split(" ")){const r=i?`${i} ${a}`:a;i&&this.ctx.measureText(r).width>e?(s.push(i),i=a):i=r}return i&&s.push(i),s}}const j=256,wt=3;async function Ce(n,t,e,s){const i=(n.south+n.north)/2,a=(n.west+n.east)/2,r=Math.abs(C(i,n.east,i,n.west).x),o=Math.abs(C(n.north,a,n.south,a).z),l=Te(i,Math.max(r,o)/2),{tiles:h,bounds:d}=De(a,i,l,wt),c=wt*j,u=document.createElement("canvas");u.width=c,u.height=c;const f=u.getContext("2d");if(!f)throw new Error("2D canvas context unavailable");const m=h[0];await Promise.all(h.map(async M=>{const O=e(M),Z=await s(O);if(!Z.ok)throw new Error(`Imagery tile fetch failed (${Z.status}): ${O}`);const Et=await createImageBitmap(await Z.blob());f.drawImage(Et,(M.x-m.x)*j,(M.y-m.y)*j)}));const p=document.createElement("canvas");p.width=t.width,p.height=t.height;const g=p.getContext("2d");if(!g)throw new Error("2D canvas context unavailable");return g.drawImage(u,0,0,c,c,0,0,t.width,t.height),{source:p,width:t.width,height:t.height,bounds:d}}class Be{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 Ce(t,e,s=>this.tileUrlTemplate.replace("{z}",String(s.z)).replace("{y}",String(s.y)).replace("{x}",String(s.x)),this.fetchImpl)}}function Re(){return new Be}const bt=new Set,Q="show-witness-map",tt="hide-milestones";class v extends HTMLElement{static get observedAttributes(){return["src",Q,tt]}shadow;stageElement;canvas;canvasRenderer;tooltip;toolbar;playPauseButton;loopButton;static WITNESS_MAP_MIN_SPAN_M=400;static WITNESS_MAP_MARGIN=.6;static WITNESS_MAP_IMAGERY_PX=768;fullscreenButton;cornerButtons;witnessMapButton;milestonesButton;witnessMapPanel;witnessMapCanvas;witnessMapRenderer;seekInput;milestoneMarks;milestoneCaption;timeStartLabel;timeEndLabel;witnessPath;witnessMapBounds;witnessMapImagery;witnessMapImageryRequested=!1;witnessMapImageryCredit;witnessMapImageryFailed=!1;creditShownExternally=!1;lookYawDeg=0;lookPitchDeg=0;milestonesShown=!0;currentSighting=Y.create();sightingAudio=new le;soundPreview;player;loopEnabled=!0;playbackBeforeClick;highlightedSourceIds=new Set;occludedSourceIds=bt;enableClickToPlay=!0;fullscreenTarget;messages=St;realDurationMs;realStartMs;showClockTime=!0;handleFullscreenChange=()=>{this.updateFullscreenButton(),this.resizeWitnessMap()};witnessMapResizeObserver=typeof ResizeObserver>"u"?void 0:new ResizeObserver(()=>this.resizeWitnessMap());resizeWitnessMap(){this.witnessMapPanel.hidden||(this.sizeWitnessMapCanvas(),this.paintWitnessMap(this.currentTime))}simulatedFullscreen=!1;styleBeforeSimulatedFullscreen;bodyOverflowBeforeSimulatedFullscreen;handleSimulatedFullscreenKey=t=>{t.key==="Escape"&&this.exitSimulatedFullscreen()};handlePointerMove=t=>{const e=this.canvasPointFromEvent(t),s=e&&this.shapeAt(e.x,e.y),i=this.said.read(s?.shape.title);if(!i){this.tooltip.hidden=!0;return}this.tooltip.textContent=i,this.tooltip.hidden=!1;const a=this.stageElement.getBoundingClientRect();this.tooltip.style.left=`${t.clientX-a.left+12}px`,this.tooltip.style.top=`${t.clientY-a.top+12}px`};handleWitnessMapPointerMove=t=>{const e=this.witnessMapTargetFrom(t);if(!e){this.tooltip.hidden=!0,this.witnessMapCanvas.style.cursor="default";return}this.witnessMapCanvas.style.cursor="pointer",this.tooltip.textContent=e.label,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`};handleWitnessMapClick=t=>{const e=this.witnessMapTargetFrom(t);if(e){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}))}};witnessMapTargetFrom(t){const e=this.witnessMapCanvas.getBoundingClientRect();if(!(e.width===0||e.height===0))return this.witnessMapRenderer.hitTest((t.clientX-e.left)/e.width*this.witnessMapCanvas.width,(t.clientY-e.top)/e.height*this.witnessMapCanvas.height)}handlePointerLeave=()=>{this.tooltip.hidden=!0};constructor(){super(),this.shadow=this.attachShadow({mode:"open"});const t=document.createElement("template");t.innerHTML=`<style>${At}</style>${It}`,this.shadow.appendChild(t.content.cloneNode(!0)),this.stageElement=this.shadow.getElementById("stage"),this.canvas=this.shadow.getElementById("canvas"),this.canvasRenderer=new re(this.canvas.getContext("2d")),this.tooltip=this.shadow.getElementById("tooltip"),this.toolbar=this.shadow.getElementById("toolbar"),this.playPauseButton=this.shadow.getElementById("play-pause"),this.loopButton=this.shadow.getElementById("loop"),this.fullscreenButton=this.shadow.getElementById("fullscreen"),this.cornerButtons=this.shadow.getElementById("corner-buttons"),this.witnessMapButton=this.shadow.getElementById("witness-map"),this.milestonesButton=this.shadow.getElementById("milestones"),this.witnessMapPanel=this.shadow.getElementById("witness-map-panel"),this.witnessMapCanvas=this.shadow.getElementById("witness-map-canvas"),this.witnessMapRenderer=new P(this.witnessMapCanvas.getContext("2d")),this.seekInput=this.shadow.getElementById("seek"),this.milestoneMarks=this.shadow.getElementById("milestone-marks"),this.milestoneCaption=this.shadow.getElementById("milestone-caption"),this.timeStartLabel=this.shadow.getElementById("time-start"),this.timeEndLabel=this.shadow.getElementById("time-end");for(const e of[this.timeStartLabel,this.timeEndLabel])e.addEventListener("click",()=>this.toggleTimeDisplay()),e.addEventListener("keydown",s=>{s.key!=="Enter"&&s.key!==" "||(s.preventDefault(),this.toggleTimeDisplay())});this.fullscreenTarget=this.stageElement,this.playPauseButton.addEventListener("click",()=>this.togglePlayPause()),this.loopButton.addEventListener("click",()=>this.toggleLoop()),this.fullscreenButton.addEventListener("click",()=>this.toggleFullscreen()),this.witnessMapButton.addEventListener("click",()=>this.toggleWitnessMap()),this.milestonesButton.addEventListener("click",()=>this.toggleMilestones()),this.witnessMapCanvas.addEventListener("pointermove",this.handleWitnessMapPointerMove),this.witnessMapCanvas.addEventListener("pointerleave",this.handlePointerLeave),this.witnessMapCanvas.addEventListener("click",this.handleWitnessMapClick),this.seekInput.addEventListener("input",()=>this.player.seek(Number(this.seekInput.value))),this.canvas.addEventListener("click",e=>{this.enableClickToPlay&&(e.detail<=1&&(this.playbackBeforeClick={state:this.playbackState,time:this.currentTime}),this.togglePlayPause())}),this.canvas.addEventListener("dblclick",e=>{this.enableClickToPlay&&(e.preventDefault(),this.restorePlayback(),this.toggleFullscreen())}),this.canvas.addEventListener("pointermove",this.handlePointerMove),this.canvas.addEventListener("pointerleave",this.handlePointerLeave),document.addEventListener("fullscreenchange",this.handleFullscreenChange),this.witnessMapResizeObserver?.observe(this.witnessMapPanel),this.player=this.createPlayer(),this.updateTimeLabels(),this.updatePlayPauseButton(),this.updateFullscreenButton(),this.updateWitnessMapButton(),this.updateMilestonesButton(),this.refresh(),this.loadLocaleMessages()}connectedCallback(){this.saidTexts=void 0;const t=this.getAttribute("src");t&&this.loadFromSrc(t)}disconnectedCallback(){document.removeEventListener("fullscreenchange",this.handleFullscreenChange),this.witnessMapResizeObserver?.disconnect(),this.exitSimulatedFullscreen(),this.sightingAudio.dispose()}attributeChangedCallback(t,e,s){t==="src"&&s&&s!==e&&this.isConnected&&this.loadFromSrc(s),t===Q&&this.applyWitnessMapDefault(),t===tt&&this.setMilestonesShown(!this.hasAttribute(tt))}async loadFromSrc(t){this.sightingData=await Dt.json(t)}get sightingData(){return ce(this.currentSighting)}set sightingData(t){this.player.stop(),this.soundPreview=void 0,this.sightingAudio.silence(),this.currentSighting=de(t),this.player=this.createPlayer(),this.updateTimeLabels(),this.updatePlayPauseButton(),this.refresh(),this.applyWitnessMapDefault()}get sighting(){return this.currentSighting}previewSound(t){this.soundPreview=t,this.sightingAudio.resume(),this.sightingAudio.setSound(t)}stopSoundPreview(){this.soundPreview=void 0,this.sightingAudio.silence()}get canvasElement(){return this.canvas}get renderer(){return this.canvasRenderer}get currentTime(){return this.player.time}set currentTime(t){this.player.seek(t)}get seekableDuration(){return this.player.seekableDuration}get autoReplayEnabled(){return this.loopEnabled}set autoReplayEnabled(t){t!==this.loopEnabled&&this.toggleLoop()}play(){this.player.seekableDuration<=0||this.playbackState==="playing"||this.togglePlayPause()}pause(){this.playbackState==="playing"&&this.togglePlayPause()}get positionLabel(){return this.timeStartLabel.textContent??""}get durationLabel(){return this.timeEndLabel.textContent??""}get showingClockTime(){return this.canShowClockTime}get canSwitchTimeDisplay(){return this.realStartMs!==void 0}toggleTimeDisplay(){this.canSwitchTimeDisplay&&(this.showClockTime=!this.showClockTime,this.updateTimeLabels(),this.updateTimeLabelTitles(),this.dispatchEvent(new CustomEvent("timedisplaychange",{bubbles:!0,composed:!0})))}get canShowClockTime(){return this.realStartMs!==void 0&&this.showClockTime}set showToolbar(t){this.toolbar.classList.toggle("hidden",!t)}get playbackState(){return this.player.playbackState}get selectedSourceIds(){return this.highlightedSourceIds}get durationSeconds(){return this.currentSighting.event.durationSeconds}set durationSeconds(t){this.currentSighting.event.durationSeconds=t,this.updateTimeLabels(),this.refresh(),this.updatePlayPauseButton()}set selectedSourceIds(t){const e=new Set(t);e.size===this.highlightedSourceIds.size&&[...e].every(i=>this.highlightedSourceIds.has(i))||(this.highlightedSourceIds=e,this.refresh())}setOccludedSourceIds(t){t.size===this.occludedSourceIds.size&&[...t].every(s=>this.occludedSourceIds.has(s))||(this.occludedSourceIds=t,this.refresh())}hasVisibleShapeAt(t,e){return this.shapeAt(t,e)!==void 0}refresh(){this.applyFrameFormat(),this.updateTimeLabels(),this.seekInput.max=String(this.player.seekableDuration),this.refreshMilestoneMarks(),this.updateMilestonesButton(),this.updateWitnessMap(),this.player.seek(this.player.time)}refreshMilestoneMarks(){const t=this.player.seekableDuration,e=t>0?X(this.sighting.milestones):[];this.milestoneMarks.replaceChildren(...e.map(s=>{const i=document.createElement("button");i.type="button",i.className="milestone-mark",i.style.left=`${Math.min(Math.max(s.t/t,0),1)*100}%`;const a=this.said.read(s.label)??"",r=this.said.read(s.note),o=r?`${a} — ${r}`:a;return i.title=o,i.setAttribute("aria-label",o),i.addEventListener("click",()=>this.player.seek(s.t)),i}))}showMilestoneAt(t){const e=this.milestonesShown&&this.sighting.milestones.length>0?ut(this.sighting.milestones,t):void 0;if(this.milestoneCaption.hidden=e===void 0,!e)return;const s=document.createElement("b");s.textContent=this.said.read(e.label)??"";const i=this.said.read(e.note),a=i?` — ${i}`:"";this.milestoneCaption.replaceChildren(s,document.createTextNode(a))}exposureInstants(t){const e=this.exposureTimes(t),s=1/e.length;return e.map(i=>({shapes:this.shapesAt(i),share:s}))}exposureTimes(t=this.currentTime){const e=(this.currentSighting.exposure??0)*1e3;if(e<v.SHORTEST_VISIBLE_EXPOSURE_MS)return[t];const s=Math.min(v.MAX_EXPOSURE_STEPS,Math.max(2,Math.round(e/v.SHORTEST_VISIBLE_EXPOSURE_MS))),i=Math.ceil(this.travelPxOver(t,e)/v.EXPOSURE_STEP_PX),a=Math.min(v.MAX_TRAVEL_STEPS,Math.max(s,i)),r=[];for(let o=0;o<a;o++)r.push(t+e*o/a);return r}travelPxOver(t,e){const s=this.shapesAt(t),i=this.shapesAt(t+e);let a=0;for(const[r,o]of s){const l=i.get(r);if(!l)continue;const h=l.bounds.x+l.bounds.width/2-(o.bounds.x+o.bounds.width/2),d=l.bounds.y+l.bounds.height/2-(o.bounds.y+o.bounds.height/2);a=Math.max(a,Math.hypot(h,d))}return a}shapeAt(t,e,s=this.occludedSourceIds){for(const i of this.exposureTimes()){const a=this.currentSighting.timeline.hitTest(i,t,e,s);if(a)return a}}shapesAt(t){const e=new Map;for(const s of this.currentSighting.timeline.sourceIds){const i=this.currentSighting.timeline.getInterpolatedShapeAt(t,s);i&&e.set(s,i)}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=w.frameWidthPx(this.currentSighting.instrument,this.canvas.height);if(this.canvas.width===t)return;this.canvas.width=t,this.canvas.parentElement?.style.setProperty("--frame-aspect",`${t} / ${this.canvas.height}`)}canvasPointFromEvent(t){const e=this.canvas.getBoundingClientRect();if(!(e.width===0||e.height===0))return{x:(t.clientX-e.left)/e.width*this.canvas.width,y:(t.clientY-e.top)/e.height*this.canvas.height}}onFrame(t,e){this.canvasRenderer.clear(this.canvas.width,this.canvas.height);const s=this.playbackState!=="playing"?this.highlightedSourceIds:bt;this.canvasRenderer.setStarPoints(w.starPointsOf(this.sighting.instrument)),this.canvasRenderer.setRoll((S(this.sighting,t)?.rollDeg??0)*Math.PI/180);const i=this.exposureInstants(t),a=this.lookShift;for(const r of i)for(const[o,l]of r.shapes){if(this.occludedSourceIds.has(o))continue;const h=r.share,d=h===1?l:{...l,transparency:1-(1-l.transparency)*h};this.canvasRenderer.paintShape(this.shifted(d,a))}for(const[r,o]of i[0].shapes)this.occludedSourceIds.has(r)||!s.has(r)||(s.size===1?this.canvasRenderer.paintShape({...o,selected:!0}):this.canvasRenderer.paintMemberOutline(o));if(s.size>1){const r=b.groupBoundsFor([...e].filter(([o])=>s.has(o)).map(([,o])=>o.bounds));this.canvasRenderer.paintGroupHandles(r)}this.keepWitnessMapClear(i[0].shapes),this.seekInput.value=String(t),this.timeStartLabel.textContent=this.formatPosition(t),this.showMilestoneAt(t),this.paintWitnessMap(t),this.playbackState==="playing"?(this.soundPreview=void 0,this.sightingAudio.setSound(Yt(this.currentSighting,t))):this.soundPreview?this.sightingAudio.setSound(this.soundPreview):this.sightingAudio.silence(),this.updatePlayPauseButton(),this.dispatchEvent(new CustomEvent("timeupdate",{detail:{time:t}}))}shifted(t,e){return e.x===0&&e.y===0?t:{...t,bounds:{...t.bounds,x:t.bounds.x+e.x,y:t.bounds.y+e.y}}}createPlayer(){const t=new Zt(this.currentSighting.timeline,(e,s)=>this.onFrame(e,s));return t.loop=this.loopEnabled,t.onEnded=()=>{this.updatePlayPauseButton(),this.dispatchEvent(new CustomEvent("ended",{bubbles:!0,composed:!0}))},t}togglePlayPause(){this.player.seekableDuration<=0||(this.player.playbackState==="playing"?(this.player.pause(),this.soundPreview=void 0,this.sightingAudio.silence(),this.refresh()):(this.sightingAudio.resume(),this.player.play()),this.updatePlayPauseButton())}updatePlayPauseButton(){const t=this.player.playbackState==="playing";this.playPauseButton.textContent=t?"⏸":"▶";const e=this.player.seekableDuration>0;this.playPauseButton.disabled=!e;const s=e?t?this.messages.pause:this.messages.play:this.messages.noDuration;this.playPauseButton.title=s,this.playPauseButton.setAttribute("aria-label",s),this.toolbar.classList.toggle("auto-hide",t),this.cornerButtons.classList.toggle("auto-hide",t)}toggleLoop(){this.loopEnabled=!this.loopEnabled,this.loopButton.setAttribute("aria-pressed",String(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()}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()}toggleWitnessMap(){this.setWitnessMapOpen(this.witnessMapPanel.hidden)}applyWitnessMapDefault(){this.setWitnessMapOpen(this.hasAttribute(Q)&&this.witnessPath!==void 0)}setWitnessMapOpen(t){this.witnessMapPanel.hidden=!t,this.witnessMapPanel.removeAttribute("title"),this.witnessMapButton.setAttribute("aria-pressed",String(t)),this.updateWitnessMapButton(),t&&(this.sizeWitnessMapCanvas(),this.loadWitnessMapImagery(),this.paintWitnessMap(this.currentTime))}updateWitnessMapButton(){const e=!this.witnessMapPanel.hidden?this.messages.hideWitnessMap:this.messages.showWitnessMap;this.witnessMapButton.title=e,this.witnessMapButton.setAttribute("aria-label",e)}updateWitnessMap(){const t=this.witnessPath!==void 0;if(this.witnessPath=K.of(this.currentSighting),this.witnessMapButton.hidden=this.witnessPath===void 0,!t&&this.witnessPath&&this.applyWitnessMapDefault(),!this.witnessPath){this.setWitnessMapOpen(!1),this.witnessMapBounds=void 0;return}const e=this.witnessPath.boundsAround(v.WITNESS_MAP_MIN_SPAN_M,v.WITNESS_MAP_MARGIN);(!this.witnessMapBounds||!this.sameGround(this.witnessMapBounds,e))&&(this.witnessMapBounds=e,this.witnessMapImagery=void 0,this.witnessMapImageryCredit=void 0,this.witnessMapImageryFailed=!1,this.witnessMapImageryRequested=!1,this.witnessMapPanel.hidden||this.loadWitnessMapImagery())}sameGround(t,e){const s=Math.abs(t.east-t.west)/20;return Math.abs(t.north-e.north)<s&&Math.abs(t.south-e.south)<s&&Math.abs(t.west-e.west)<s&&Math.abs(t.east-e.east)<s}async loadWitnessMapImagery(){if(this.witnessMapImageryRequested||!this.witnessMapBounds)return;this.witnessMapImageryRequested=!0;const t=Re(),e=this.witnessMapBounds;try{const s=await t.getImageryTexture(e,{width:v.WITNESS_MAP_IMAGERY_PX,height:v.WITNESS_MAP_IMAGERY_PX});if(this.witnessMapBounds!==e)return;this.witnessMapImagery=s,this.witnessMapImageryCredit=t.attribution}catch{this.witnessMapImageryFailed=!0}this.paintWitnessMap(this.currentTime)}get witnessMapCredit(){return this.witnessMapImageryCredit}get witnessMapFooterLine(){return this.witnessMapImageryFailed?this.messages.mapImageryUnavailable:this.creditShownExternally?void 0:this.witnessMapImageryCredit}keepWitnessMapClear(t){if(this.witnessMapPanel.hidden)return;const e=this.witnessMapBoxPx;if(!e)return;const s=(o,l,h)=>{for(const[d,c]of t)if(!(this.occludedSourceIds.has(d)||c.transparency>=1)&&!(c.bounds.x+c.bounds.width<o-h||c.bounds.x>l+h)&&!(c.bounds.y>e.bottom+h||c.bounds.y+c.bounds.height<e.top-h))return!0;return!1},i=[this.canvas.width-e.width,this.canvas.width],a=[0,e.width],r=v.WITNESS_MAP_CLEARANCE_PX;if(this.witnessMapPanel.classList.contains("on-the-left")){s(i[0],i[1],r)||this.witnessMapPanel.classList.remove("on-the-left");return}s(i[0],i[1],0)&&!s(a[0],a[1],0)&&this.witnessMapPanel.classList.add("on-the-left")}witnessMapBoxPx;static WITNESS_MAP_CLEARANCE_PX=24;sizeWitnessMapCanvas(){const t=this.witnessMapPanel.clientWidth;if(t===0)return;const e=Math.round(t*(globalThis.devicePixelRatio??1));this.measureWitnessMapBox(),this.witnessMapCanvas.width!==e&&(this.witnessMapCanvas.width=e,this.witnessMapCanvas.height=e)}measureWitnessMapBox(){const t=this.witnessMapPanel.getBoundingClientRect(),e=this.canvas.getBoundingClientRect();if(e.width===0||e.height===0)return;const s=this.canvas.width/e.width,i=this.canvas.height/e.height;this.witnessMapBoxPx={width:t.width*s,top:(t.top-e.top)*i,bottom:(t.bottom-e.top)*i}}paintWitnessMap(t){if(this.witnessMapPanel.hidden||!this.witnessPath||!this.witnessMapBounds)return;const e=S(this.currentSighting,t),s=this.currentSighting.instrument,i=[],a=this.currentSighting.milestones.length>0?ut(this.currentSighting.milestones,t):void 0;for(const r of this.milestonesShown?X(this.currentSighting.milestones):[]){const o=S(this.currentSighting,r.t);o?.lat===void 0||o.lng===void 0||i.push({label:this.said.read(r.label)??"",note:this.said.read(r.note),t:r.t,lat:o.lat,lng:o.lng,current:r===a})}this.witnessMapRenderer.paint({bounds:this.witnessMapBounds,imagery:this.witnessMapImagery,path:this.witnessPath,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?E.of(s,this.canvas.height,e.fovDeg).halfWidthAngleDeg(w.aspectOf(s)):void 0,markers:i,decor:this.witnessMapDecorAt(t),witnessLabel:this.said.read(this.currentSighting.witness?.title)??this.messages.witnessHere,nightFraction:this.witnessMapNightFraction,attribution:this.witnessMapFooterLine})}toggleMilestones(){this.setMilestonesShown(!this.milestonesShown)}setMilestonesShown(t){this.milestonesShown=t,this.milestoneMarks.hidden=!t,this.milestonesButton.setAttribute("aria-pressed",String(t)),this.updateMilestonesButton(),this.showMilestoneAt(this.currentTime),this.paintWitnessMap(this.currentTime)}updateMilestonesButton(){this.milestonesButton.hidden=this.currentSighting.milestones.length===0;const t=this.milestonesShown?this.messages.hideMilestones:this.messages.showMilestones;this.milestonesButton.title=t,this.milestonesButton.setAttribute("aria-label",t)}witnessMapDecorAt(t){const e=S(this.currentSighting,0);return e?.lat===void 0||e.lng===void 0?[]:this.currentSighting.decor.map(s=>{const i=be(s,t),{lat:a,lng:r}=R(i.eastM,-i.northM,e.lat,e.lng);return{lat:a,lng:r,headingDeg:i.headingDeg,label:this.said.read(s.title)??this.messages.decorHere}})}witnessMapNightFraction;setSunAltitude(t){const e=t===void 0?void 0:Math.max(0,Math.min(1,-t/12));e!==this.witnessMapNightFraction&&(this.witnessMapNightFraction=e,this.paintWitnessMap(this.currentTime))}setLookOffset(t,e){t===this.lookYawDeg&&e===this.lookPitchDeg||(this.lookYawDeg=t,this.lookPitchDeg=e,this.refresh())}get lookShiftPx(){return this.lookShift}get lookShift(){if(this.lookYawDeg===0&&this.lookPitchDeg===0)return{x:0,y:0};const t=S(this.currentSighting,this.currentTime),e=E.of(this.currentSighting.instrument,this.canvas.height,t?.fovDeg??60);return{x:-e.angleDegToRadiusPx(this.lookYawDeg),y:e.angleDegToRadiusPx(this.lookPitchDeg)}}updateFullscreenButton(){const t=this.simulatedFullscreen||document.fullscreenElement===this.fullscreenTarget;this.fullscreenButton.title=t?this.messages.exitFullscreen:this.messages.fullscreen,this.fullscreenButton.setAttribute("aria-label",this.fullscreenButton.title)}get said(){return this.saidTexts??=new T(ft.preferencesFor(this))}saidTexts;async loadLocaleMessages(){const t=ue(ft.preferencesFor(this),pe);t!=="en"&&this.applyMessages(await ye(t))}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;for(const s of[this.timeStartLabel,this.timeEndLabel])s.classList.toggle("switchable",this.canSwitchTimeDisplay),this.canSwitchTimeDisplay?(s.setAttribute("role","button"),s.setAttribute("tabindex","0")):(s.removeAttribute("role"),s.removeAttribute("tabindex"))}applyMessages(t){this.messages=t,this.updateTimeLabelTitles(),this.loopButton.title=t.autoReplay,this.loopButton.setAttribute("aria-label",t.autoReplay),this.updatePlayPauseButton(),this.updateFullscreenButton(),this.updateWitnessMapButton(),this.updateMilestonesButton()}updateTimeLabels(){const t=this.currentSighting.event,e=Vt(t);this.realDurationMs=e!==void 0&&e>0?e:void 0,this.realStartMs=t.time?et(t.time):void 0;const s=this.currentSighting.timeline.duration;this.player.playbackRate=this.realDurationMs!==void 0&&s>0?s/this.realDurationMs:1,this.player.durationOverrideMs=s>0?0:this.realDurationMs??0,this.timeEndLabel.textContent=this.formatEndOfTimeline(),this.timeStartLabel.textContent=this.formatPosition(this.player.time),this.updateTimeLabelTitles()}formatPosition(t){if(this.realDurationMs===void 0)return U(t);const e=this.currentSighting.timeline.duration,s=e>0&&t<=e?t/e*this.realDurationMs:t;return this.canShowClockTime?xt(vt(this.realStartMs+s)):U(s)}formatEndOfTimeline(){return this.realDurationMs===void 0?U(this.currentSighting.timeline.duration):this.canShowClockTime?xt(vt(this.realStartMs+this.realDurationMs)):U(this.realDurationMs)}}function vt(n){const t=new Date(n);return{hour:t.getUTCHours(),minute:t.getUTCMinutes(),second:t.getUTCSeconds()}}function xt(n){if(n.hour===void 0)return"0:00";const t=e=>String(e).padStart(2,"0");return n.second?`${t(n.hour)}:${t(n.minute??0)}:${t(n.second)}`:`${t(n.hour)}:${t(n.minute??0)}`}function U(n){const t=Math.round(n/1e3),e=Math.floor(t/60),s=t%60;return`${e}:${String(s).padStart(2,"0")}`}const Mt="rr0-ufo";function _e(){customElements.get(Mt)||customElements.define(Mt,v)}_e();
|
|
404
|
+
`;class _ extends Error{constructor(t,e,s){super(`${t}: ${e}${s===void 0?"":` (HTTP ${s})`}`),this.kind=t,this.url=e,this.status=s,this.name="SightingFetchError"}}class _t{static async json(t){const e=new URL(t,location.href);if(location.protocol==="https:"&&e.protocol==="http:")throw new _("mixed-content",t);let s;try{s=await fetch(t)}catch{throw await this.diagnose(t,e)}if(!s.ok)throw new _("status",t,s.status);try{return await s.json()}catch{throw new _("malformed",t)}}static async diagnose(t,e){if(e.origin===location.origin)return new _("unreachable",t);try{return await fetch(t,{mode:"no-cors"}),new _("cors",t)}catch{return new _("unreachable",t)}}}const H=[{id:"eye",name:{en:"Naked eye",fr:"Œil nu"},flare:0,projection:"equidistant",stabilization:.97},{id:"rectilinear-lens",name:{en:"Camera, unknown device",fr:"Appareil, modèle inconnu"},projection:"rectilinear",fNumber:8,fNumberRange:{min:2,max:22},exposureSeconds:1/250,exposureRangeSeconds:{min:1/1e3,max:8},apertureBlades:6},{id:"instamatic-126",name:{en:"Instamatic, 126 film",fr:"Instamatic, film 126"},projection:"rectilinear",frame:{widthMm:28,heightMm:28,focalLengthMm:43},fNumber:11,exposureSeconds:1/90,years:{from:1963,to:1988},apertureBlades:5,detailUm:20},{id:"slr-35mm-50",name:{en:"35 mm SLR, 50 mm lens",fr:"Reflex 35 mm, objectif 50 mm"},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},{id:"slr-35mm-zoom",name:{en:"35 mm SLR, 70-210 mm zoom",fr:"Reflex 35 mm, zoom 70-210 mm"},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},{id:"phone-landscape",name:{en:"Phone, held sideways",fr:"Téléphone, tenu couché"},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},{id:"phone-portrait",name:{en:"Phone, held upright",fr:"Téléphone, tenu debout"},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}];class b{static get default(){return H[0]}static byId(t){return H.find(e=>e.id===t)??this.default}static UNAIDED_FIELD_DEG=60;static UNAIDED_ASPECT=16/9;static fieldOfViewDeg(t){const e=t.frame;return e?2*Math.atan(e.heightMm/(2*e.focalLengthMm))*180/Math.PI:b.UNAIDED_FIELD_DEG}static aspectOf(t){const e=t.frame;return e?e.widthMm/e.heightMm:b.UNAIDED_ASPECT}static frameWidthPx(t,e){return Math.round(e*b.aspectOf(t))}static availableAt(t){return t===void 0?H:H.filter(e=>!e.years||t>=e.years.from&&(e.years.to===void 0||t<=e.years.to))}static fieldOfViewDegAt(t,e){const s=t.frame;if(!(!s||e<=0))return 2*Math.atan(s.heightMm/(2*e))*180/Math.PI}static focalLengthMmFor(t,e){const s=t.frame;if(!(!s||e<=0||e>=180))return s.heightMm/(2*Math.tan(e*Math.PI/360))}static bladesShowing(t,e){const s=e??t.fNumber;if(s===void 0||t.apertureBlades===void 0)return 0;const i=t.fNumberRange;return!i||i.max<=i.min?1:Math.max(0,Math.min(1,(s-i.min)/(i.max-i.min)))}static LENS_FLARE_ARTIFACTS=1;static flareArtifactsOf(t){return t.flare??b.LENS_FLARE_ARTIFACTS}static starPointsOf(t){const e=t.apertureBlades;return e===void 0||e<3?0:e%2===0?e:e*2}}const Et=Math.PI/180,q=111320;function D(n,t,e,s){const i=q*Math.cos(e*Et),r=(n-e)*q;return{x:(t-s)*i,z:-r}}function L(n,t,e,s){const i=q*Math.cos(e*Et),r=-t,a=n;return{lat:e+r/q,lng:s+a/i}}class F{constructor(t){this.points=t}static STATIONARY_M=5;static of(t){const e=[];for(const s of t.witnessTrack.allKeyframes){const{lat:i,lng:r,headingDeg:a}=s.pose;i===void 0||r===void 0||e.push({t:s.t,lat:i,lng:r,headingDeg:a})}if(e.length===0){const s=t.event.place?.[0];if(!s)return;e.push({t:0,lat:s.lat,lng:s.lng})}return new F(e)}get moved(){return this.spanM>F.STATIONARY_M}get spanM(){const t=this.box,e=(t.south+t.north)/2,s=(t.west+t.east)/2;return Math.max(Math.abs(D(e,t.east,e,t.west).x),Math.abs(D(t.north,s,t.south,s).z))}get center(){const t=this.box;return{lat:(t.south+t.north)/2,lng:(t.west+t.east)/2}}boundsAround(t,e){const{lat:s,lng:i}=this.center,r=Math.max(this.spanM*(1+e),t)/2;return{north:L(0,-r,s,i).lat,south:L(0,r,s,i).lat,east:L(r,0,s,i).lng,west:L(-r,0,s,i).lng}}get box(){const t=this.points.map(s=>s.lat),e=this.points.map(s=>s.lng);return{south:Math.min(...t),north:Math.max(...t),west:Math.min(...e),east:Math.max(...e)}}}class g{constructor(t,e){this.stretches=t,this.rotationPassed=e}static REFERENCE_SPEED_M_PER_S=1.4;static REFERENCE_STEP_HZ=1.9;static CADENCE_EXPONENT=.43;static RISE_M_PER_M_PER_S=.0175;static SWAY_M=.0175;static SLOWEST_WALK_M_PER_S=.2;static FASTEST_WALK_M_PER_S=2.2;static HEAD_ROLL_DEG=1.5;static HEAD_PITCH_DEG=1.25;static HEAD_YAW_DEG=1;static STILL=Object.freeze({eastM:0,northM:0,upM:0,rollDeg:0,pitchDeg:0,yawDeg:0});static of(t){const e=F.of(t);if(!e||e.points.length<2)return;const s=[];let i=0;for(let r=1;r<e.points.length;r++){const a=e.points[r-1],o=e.points[r],h=(o.t-a.t)/1e3;if(h<=0)continue;const l=D(o.lat,o.lng,a.lat,a.lng),d=l.x,c=-l.z,u=Math.hypot(d,c),f=u/h,p=g.stepHzFor(f);s.push({startMs:a.t,endMs:o.t,speedMPerS:f,eastUnit:u>0?d/u:0,northUnit:u>0?c/u:0,stepHz:p,stepsBefore:i,rampsIn:!0,rampsOut:!0}),i+=p*h}for(let r=0;r<s.length;r++){const a=s[r-1],o=s[r+1];s[r].rampsIn=a===void 0||a.stepHz===0,s[r].rampsOut=o===void 0||o.stepHz===0}if(s.some(r=>r.stepHz>0))return new g(s,1-(t.instrument.stabilization??0))}static stepHzFor(t){return t<g.SLOWEST_WALK_M_PER_S||t>g.FASTEST_WALK_M_PER_S?0:g.REFERENCE_STEP_HZ*Math.pow(t/g.REFERENCE_SPEED_M_PER_S,g.CADENCE_EXPONENT)}offsetAt(t){const e=this.stretches.find(h=>t>=h.startMs&&t<=h.endMs);if(!e||e.stepHz===0)return g.STILL;const s=e.stepsBefore+e.stepHz*(t-e.startMs)/1e3,i=2*Math.PI*s,r=this.amplitudeAt(e,t),a=g.SWAY_M*r*Math.cos(i/2),o=r*this.rotationPassed*e.speedMPerS/g.REFERENCE_SPEED_M_PER_S;return{eastM:a*e.northUnit,northM:-a*e.eastUnit,upM:g.RISE_M_PER_M_PER_S*e.speedMPerS*r*Math.cos(i),rollDeg:g.HEAD_ROLL_DEG*o*Math.cos(i/2),pitchDeg:-1.25*o*Math.cos(i),yawDeg:g.HEAD_YAW_DEG*o*Math.cos(i/2)}}amplitudeAt(t,e){const s=1e3/t.stepHz,i=Math.min(s,(t.endMs-t.startMs)/2);if(i<=0)return 1;const r=e-t.startMs,a=t.endMs-e,o=Math.min(t.rampsIn?r/i:1,t.rampsOut?a/i:1,1);return(1-Math.cos(Math.PI*Math.max(o,0)))/2}}class M{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/M.MOON_ANGULAR_WIDTH_DEG}static lerpAngular(t,e,s){if(!(!t||!e))return{widthDeg:t.widthDeg+(e.widthDeg-t.widthDeg)*s,heightDeg:t.heightDeg+(e.heightDeg-t.heightDeg)*s}}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 Rt(n,t,e){if(!n||!t)return e<1?n:t;const s=((t.azimuthDeg-n.azimuthDeg)%360+540)%360-180;return{azimuthDeg:((n.azimuthDeg+s*e)%360+360)%360,altitudeDeg:n.altitudeDeg+(t.altitudeDeg-n.altitudeDeg)*e}}function Bt(n,t,e){const{bounds:s}=n;return t>=s.x&&t<=s.x+s.width&&e>=s.y&&e<=s.y+s.height}function w(n,t,e){return n+(t-n)*e}function rt(n){const t=/^#([0-9a-f]{6})$/i.exec(n);if(!t)return;const e=parseInt(t[1],16);return[e>>16&255,e>>8&255,e&255]}function Lt(n){return`#${n.map(t=>Math.round(t).toString(16).padStart(2,"0")).join("")}`}function Ft(n,t,e){const s=rt(n),i=rt(t);return!s||!i?e<1?n:t:Lt([w(s[0],i[0],e),w(s[1],i[1],e),w(s[2],i[2],e)])}function Ot(n,t,e){const s={x:w(n.bounds.x,t.bounds.x,e),y:w(n.bounds.y,t.bounds.y,e),width:w(n.bounds.width,t.bounds.width,e),height:w(n.bounds.height,t.bounds.height,e)},i=w(n.angle,t.angle,e),r=w(n.transparency,t.transparency,e),a=w(n.haloScale,t.haloScale,e),o=w(n.blur??0,t.blur??0,e),h=w(n.brightness??0,t.brightness??0,e),l=Ft(n.color,t.color,e),d=M.lerpAngular(n.angular,t.angular,e),c=Rt(n.aim,t.aim,e);return n.kind==="polygon"&&t.kind==="polygon"&&n.points.length===t.points.length?{...n,bounds:s,angle:i,transparency:r,haloScale:a,blur:o,brightness:h,color:l,angular:d,aim:c,behindCloud:e<1?n.behindCloud:t.behindCloud,points:n.points.map((u,f)=>({x:w(u.x,t.points[f].x,e),y:w(u.y,t.points[f].y,e)}))}:{...e<1?n:t,bounds:s,angle:i,transparency:r,haloScale:a,blur:o,brightness:h,color:l,angular:d,aim:c}}class Z{keyframes=[];order=[];groups=[];addKeyframe(t,e){const s=this.findInsertIndex(t);if(this.keyframes[s]?.t===t){const i=new Set(e.map(r=>r.sourceId));this.keyframes[s]={t,shapes:[...this.keyframes[s].shapes.filter(r=>!i.has(r.sourceId)),...e]}}else this.keyframes.splice(s,0,{t,shapes:[...e]});for(const i of e)this.order.includes(i.sourceId)||this.order.push(i.sourceId)}findInsertIndex(t){let e=0,s=this.keyframes.length;for(;e<s;){const i=e+s>>>1;this.keyframes[i].t<t?e=i+1:s=i}return e}getKeyframeAt(t){const e=this.findInsertIndex(t),s=this.keyframes[e];return s?.t===t?s:void 0}getShapeAt(t,e){return this.getKeyframeAt(t)?.shapes.find(s=>s.sourceId===e)?.shape}getLatestShapeAt(t,e){let s=this.findInsertIndex(t);for(this.keyframes[s]?.t!==t&&(s-=1);s>=0;s--){const i=this.keyframes[s].shapes.find(r=>r.sourceId===e);if(i)return i.shape}}getInterpolatedShapeAt(t,e){const s=this.findShapeAtOrBefore(t,e);if(s?.t===t)return s.shape;const i=this.findShapeAtOrAfter(t,e);return s?i?Ot(s.shape,i.shape,(t-s.t)/(i.t-s.t)):s.shape:i?.shape}findShapeAtOrBefore(t,e){let s=this.findInsertIndex(t);for(this.keyframes[s]?.t!==t&&(s-=1);s>=0;s--){const i=this.keyframes[s].shapes.find(r=>r.sourceId===e);if(i)return{t:this.keyframes[s].t,shape:i.shape}}}findShapeAtOrAfter(t,e){for(let s=this.findInsertIndex(t);s<this.keyframes.length;s++){const i=this.keyframes[s].shapes.find(r=>r.sourceId===e);if(i)return{t:this.keyframes[s].t,shape:i.shape}}}hitTest(t,e,s,i){const r=this.sourceIds;for(let a=r.length-1;a>=0;a--){if(i?.has(r[a]))continue;const o=this.getInterpolatedShapeAt(t,r[a]);if(o&&Bt(o,e,s))return{sourceId:r[a],shape:o}}}removeSource(t){for(let e=this.keyframes.length-1;e>=0;e--){const s=this.keyframes[e].shapes.filter(i=>i.sourceId!==t);s.length===0?this.keyframes.splice(e,1):s.length!==this.keyframes[e].shapes.length&&(this.keyframes[e]={t:this.keyframes[e].t,shapes:s})}this.order=this.order.filter(e=>e!==t),this.removeFromGroup(t)}group(t){if(!(t.length<2)){for(const e of t)this.removeFromGroup(e);this.groups.push([...t])}}ungroup(t){const e=this.groups.findIndex(s=>s.includes(t));e!==-1&&this.groups.splice(e,1)}groupMembers(t){return this.groups.find(e=>e.includes(t))}removeFromGroup(t){const e=this.groups.findIndex(i=>i.includes(t));if(e===-1)return;const s=this.groups[e].filter(i=>i!==t);s.length<2?this.groups.splice(e,1):this.groups[e]=s}bringToFront(t){const e=this.order.indexOf(t);e!==-1&&(this.order.splice(e,1),this.order.push(t))}sendToBack(t){const e=this.order.indexOf(t);e!==-1&&(this.order.splice(e,1),this.order.unshift(t))}get duration(){return this.keyframes.length===0?0:this.keyframes[this.keyframes.length-1].t}get sourceIds(){return[...this.order]}get allKeyframes(){return this.keyframes}toJSON(){return{keyframes:this.keyframes,order:this.order,groups:this.groups}}static fromJSON(t){const e=new Z;for(const s of t.keyframes)e.addKeyframe(s.t,s.shapes);if(t.order){const s=e.order.filter(i=>!t.order.includes(i));e.order=[...t.order,...s]}return t.groups&&(e.groups=t.groups.map(s=>s.filter(i=>e.order.includes(i))).filter(s=>s.length>=2)),e}}function Nt(n,t,e){return Math.max(t,Math.min(e,n))}function Wt(n,t,e){const s=((t-n)%360+540)%360-180;return((n+s*e)%360+360)%360}function R(n,t,e){return n+(t-n)*e}function zt(n,t,e){return{lat:n.lat===void 0||t.lat===void 0?void 0:R(n.lat,t.lat,e),lng:n.lng===void 0||t.lng===void 0?void 0:R(n.lng,t.lng,e),elevationM:R(n.elevationM,t.elevationM,e),headingDeg:n.headingDeg===void 0||t.headingDeg===void 0?void 0:Wt(n.headingDeg,t.headingDeg,e),pitchDeg:R(n.pitchDeg,t.pitchDeg,e),rollDeg:R(n.rollDeg??0,t.rollDeg??0,e),fovDeg:R(n.fovDeg,t.fovDeg,e),fNumber:n.fNumber,focusDistanceM:n.focusDistanceM}}class O{keyframes=[];addKeyframe(t,e){const s=this.findInsertIndex(t);this.keyframes[s]?.t===t?this.keyframes[s]={t,pose:e}:this.keyframes.splice(s,0,{t,pose:e})}clear(){this.keyframes.length=0}removeKeyframeAt(t){const e=this.findInsertIndex(t);this.keyframes[e]?.t===t&&this.keyframes.splice(e,1)}findInsertIndex(t){let e=0,s=this.keyframes.length;for(;e<s;){const i=e+s>>>1;this.keyframes[i].t<t?e=i+1:s=i}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),s=this.keyframes[e]?.t===t?this.keyframes[e]:this.keyframes[e-1];if(s?.t===t)return s.pose;const i=this.keyframes[e]?.t===t?void 0:this.keyframes[e];return s?i?zt(s.pose,i.pose,Nt((t-s.t)/(i.t-s.t),0,1)):s.pose:i?.pose}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 O;for(const s of t.keyframes)e.addKeyframe(s.t,s.pose);return e}}function E(n,t,e){return n+(t-n)*e}function Ht(n,t,e){const s=((t-n)%360+540)%360-180;return((n+s*e)%360+360)%360}function Ut(n,t,e){return Math.max(t,Math.min(e,n))}function $t(n,t,e){return{cloudCover:E(n.cloudCover,t.cloudCover,e),cloudDarkness:E(n.cloudDarkness,t.cloudDarkness,e),highCloudCover:n.highCloudCover===void 0||t.highCloudCover===void 0?void 0:E(n.highCloudCover,t.highCloudCover,e),iceCrystalAlignment:n.iceCrystalAlignment===void 0||t.iceCrystalAlignment===void 0?void 0:E(n.iceCrystalAlignment,t.iceCrystalAlignment,e),lowerCloudCover:n.lowerCloudCover===void 0||t.lowerCloudCover===void 0?void 0:E(n.lowerCloudCover,t.lowerCloudCover,e),cloudBaseM:n.cloudBaseM===void 0||t.cloudBaseM===void 0?void 0:E(n.cloudBaseM,t.cloudBaseM,e),precipitationType:e<1?n.precipitationType:t.precipitationType,precipitationIntensity:E(n.precipitationIntensity,t.precipitationIntensity,e),windDirectionDeg:Ht(n.windDirectionDeg,t.windDirectionDeg,e),windSpeed:E(n.windSpeed,t.windSpeed,e),storm:e<1?n.storm:t.storm}}class N{keyframes=[];addKeyframe(t,e){const s=this.findInsertIndex(t);this.keyframes[s]?.t===t?this.keyframes[s]={t,weather:e}:this.keyframes.splice(s,0,{t,weather:e})}clear(){this.keyframes.length=0}removeKeyframeAt(t){const e=this.findInsertIndex(t);this.keyframes[e]?.t===t&&this.keyframes.splice(e,1)}findInsertIndex(t){let e=0,s=this.keyframes.length;for(;e<s;){const i=e+s>>>1;this.keyframes[i].t<t?e=i+1:s=i}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),s=this.keyframes[e]?.t===t?this.keyframes[e]:this.keyframes[e-1];if(s?.t===t)return s.weather;const i=this.keyframes[e]?.t===t?void 0:this.keyframes[e];return s?i?$t(s.weather,i.weather,Ut((t-s.t)/(i.t-s.t),0,1)):s.weather:i?.weather}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 N;for(const s of t.keyframes)e.addKeyframe(s.t,s.weather);return e}}class W{keyframes=[];addKeyframe(t,e){const s=this.findInsertIndex(t);this.keyframes[s]?.t===t?this.keyframes[s]={t,sound:e}:this.keyframes.splice(s,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),s=this.keyframes[e]?.t===t?this.keyframes[e]:this.keyframes[e-1];if(s?.t===t)return s.sound;const i=this.keyframes[e]?.t===t?void 0:this.keyframes[e];if(!s)return i?.sound;if(!i)return s.sound;const r=(t-s.t)/(i.t-s.t);return this.lerp(s.sound,i.sound,Math.max(0,Math.min(1,r)))}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 W;for(const s of t.keyframes)e.addKeyframe(s.t,s.sound);return e}lerp(t,e,s){return{kind:s<1?t.kind:e.kind,volume:t.volume+(e.volume-t.volume)*s,pitchHz:t.pitchHz+(e.pitchHz-t.pitchHz)*s,src:s<1?t.src:e.src}}findInsertIndex(t){let e=0,s=this.keyframes.length;for(;e<s;){const i=e+s>>>1;this.keyframes[i].t<t?e=i+1:s=i}return e}}const Xt=100,Gt={kind:"none",volume:0,pitchHz:Xt};class S{constructor(t){this.entries=t}static empty(){return new S(new Map)}get size(){return this.entries.size}at(t){return this.entries.get(t)}paths(){return[...this.entries.keys()]}set(t,e){e.basis==="stated"&&e.rationale===void 0?this.entries.delete(t):this.entries.set(t,e)}clear(t){for(const e of this.entries.keys())(e===t||e.startsWith(`${t}.`))&&this.entries.delete(e)}static strip(t){const e=new S(new Map);return{recording:S.stripValue(t,[],e),provenance:e}}static restore(t,e){if(e.size===0)return t;const s=structuredClone(t);for(const i of e.paths()){const r=e.at(i),a=i.split("."),o=S.holderOf(s,a);if(!o)continue;const h=a[a.length-1],l=o[h];l!==void 0&&(r.of!==void 0&&JSON.stringify(r.of)!==JSON.stringify(l)||(o[h]={value:l,...r.basis==="stated"?{}:{basis:r.basis},...r.rationale===void 0?{}:{rationale:r.rationale}}))}return s}static isWrapper(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)&&"value"in t}static stripValue(t,e,s){return S.isWrapper(t)?(s.set(e.join("."),{basis:t.basis??"stated",...t.rationale===void 0?{}:{rationale:t.rationale},of:t.value}),S.stripValue(t.value,e,s)):Array.isArray(t)?t.map((i,r)=>S.stripValue(i,[...e,String(r)],s)):typeof t=="object"&&t!==null?Object.fromEntries(Object.entries(t).map(([i,r])=>[i,S.stripValue(r,[...e,i],s)])):t}static holderOf(t,e){let s=t;for(const i of e.slice(0,-1)){if(typeof s!="object"||s===null)return;s=s[i]}return typeof s=="object"&&s!==null?s:void 0}}function it(n){if(n.year!==void 0)return Date.UTC(n.year,(n.month??1)-1,n.day??1,n.hour??0,n.minute??0,n.second??0)}function at(n){return(((n.day??0)*24+(n.hour??0))*60+(n.minute??0))*6e4+(n.second??0)*1e3}const Vt=["year","month","day","hour","minute"],Kt=["day","hour","minute"];function ot(n,t){return t.filter(e=>n[e]!==void 0).join(",")}function qt(n){if(n.durationSeconds!==void 0)return n.durationSeconds*1e3;if(!n.time||!n.endTime)return;const t=n.time.year!==void 0&&n.endTime.year!==void 0,e=t?Vt:Kt,s=ot(n.time,e);if(!(s===""||s!==ot(n.endTime,e)))return t?it(n.endTime)-it(n.time):at(n.endTime)-at(n.time)}class J{constructor(t,e,s,i,r,a,o,h,l=[],d,c,u,f=[]){this.event=t,this.timeline=e,this.witnessTrack=s,this.weatherTrack=i,this.soundTrack=r,this.witness=a,this.caseId=o,this.weather=h,this.decor=l,this.weatherSource=d,this.instrumentId=c,this.exposureSeconds=u,this.milestones=f}provenance=S.empty();get exposure(){return this.exposureSeconds??this.instrument.exposureSeconds}get instrument(){return b.byId(this.instrumentId)}static create(t,e,s){return new J({eventType:"sighting",time:t,place:e},new Z,new O,new N,new W,s)}}const Yt=0,Zt=0;function T(n,t){const e=n.witnessTrack.getInterpolatedPoseAt(t);if(e)return e;const s=n.event.place?.[0];if(s)return{lat:s.lat,lng:s.lng,elevationM:Yt,headingDeg:void 0,pitchDeg:Zt,fovDeg:b.fieldOfViewDeg(n.instrument)}}function Jt(n,t){return n.soundTrack.getInterpolatedSoundAt(t)??Gt}class jt{constructor(t,e){this.timeline=t,this.onFrame=e}rafId=null;state="stopped";currentT=0;lastWallTime=0;playbackRate=1;loop=!1;onEnded;durationOverrideMs=0;get seekableDuration(){return Math.max(this.timeline.duration,this.durationOverrideMs)}play(){if(this.state==="playing")return;this.currentT>=this.seekableDuration&&(this.currentT=0,this.resolveFrame(0)),this.state="playing",this.lastWallTime=performance.now();const t=()=>{if(this.state!=="playing")return;const e=performance.now();if(this.currentT+=(e-this.lastWallTime)*this.playbackRate,this.lastWallTime=e,this.currentT>=this.seekableDuration){if(this.loop&&this.seekableDuration>0){this.currentT%=this.seekableDuration,this.resolveFrame(this.currentT),this.rafId=requestAnimationFrame(t);return}this.currentT=this.seekableDuration,this.stop(),this.resolveFrame(this.currentT),this.onEnded?.();return}this.resolveFrame(this.currentT),this.rafId=requestAnimationFrame(t)};this.rafId=requestAnimationFrame(t)}pause(){this.state==="playing"&&(this.state="paused",this.rafId!==null&&(cancelAnimationFrame(this.rafId),this.rafId=null))}stop(){this.state="stopped",this.rafId!==null&&(cancelAnimationFrame(this.rafId),this.rafId=null)}seek(t){this.currentT=Math.max(0,Math.min(t,this.seekableDuration)),this.resolveFrame(this.currentT)}get playbackState(){return this.state}get time(){return this.currentT}resolveFrame(t){const e=new Map;for(const s of this.timeline.sourceIds){const i=this.timeline.getInterpolatedShapeAt(t,s);i&&e.set(s,i)}this.onFrame(t,e)}}const Tt=["nw","n","ne","e","se","s","sw","w"],Qt=24,U=8,te=3,ee=8;function $(n,t,e){const s=n.x-t.x,i=n.y-t.y,r=Math.cos(e),a=Math.sin(e);return{x:t.x+s*r-i*a,y:t.y+s*a+i*r}}function B(n){return{x:n.x+n.width/2,y:n.y+n.height/2}}const se={nw:{left:!0,top:!0},n:{top:!0},ne:{right:!0,top:!0},e:{right:!0},se:{right:!0,bottom:!0},s:{bottom:!0},sw:{left:!0,bottom:!0},w:{left:!0}};class v{static handlePointsFor(t){const{x:e,y:s,width:i,height:r}=t.bounds,a={nw:{x:e,y:s},n:{x:e+i/2,y:s},ne:{x:e+i,y:s},e:{x:e+i,y:s+r/2},se:{x:e+i,y:s+r},s:{x:e+i/2,y:s+r},sw:{x:e,y:s+r},w:{x:e,y:s+r/2},rotate:{x:e+i/2,y:s-Qt}},o=B(t.bounds),h={};for(const l of Object.keys(a))h[l]=$(a[l],o,t.angle);return h}static hitTestHandle(t,e,s=8,i=[...Tt,"rotate"]){const r=v.handlePointsFor(t);for(const a of i)if(Math.hypot(e.x-r[a].x,e.y-r[a].y)<=s)return a}static HANDLE_DIRECTION_DEG={e:0,se:45,s:90,sw:135,w:180,nw:225,n:270,ne:315};static resizeAxisFor(t,e){const i=((v.HANDLE_DIRECTION_DEG[t]+e*180/Math.PI)%180+180)%180/45,r=["ew","nwse","ns","nesw"];return r[Math.round(i)%r.length]}static resizeBounds(t,e,s,i){const r=B(t),a=$(i,r,-e),{x:o,y:h,width:l,height:d}=t,c=se[s];let u=o,f=h,p=o+l,m=h+d;return c.left&&(u=Math.min(a.x,p-U)),c.right&&(p=Math.max(a.x,u+U)),c.top&&(f=Math.min(a.y,m-U)),c.bottom&&(m=Math.max(a.y,f+U)),{x:u,y:f,width:p-u,height:m-f}}static resizeShape(t,e,s){if(e==="rotate")throw new Error("resizeShape does not accept the rotate handle");const{width:i,height:r}=t.bounds,a=v.resizeBounds(t.bounds,t.angle,e,s);if(t.kind==="oval")return{...t,bounds:a};const o=i===0?1:a.width/i,h=r===0?1:a.height/r;return{...t,bounds:a,points:t.points.map(l=>({x:l.x*o,y:l.y*h}))}}static rotateShape(t,e){const s=B(t.bounds),i=Math.atan2(e.y-s.y,e.x-s.x)+Math.PI/2;return{...t,angle:i}}static groupBoundsFor(t){const e=Math.min(...t.map(a=>a.x)),s=Math.min(...t.map(a=>a.y)),i=Math.max(...t.map(a=>a.x+a.width)),r=Math.max(...t.map(a=>a.y+a.height));return{x:e,y:s,width:i-e,height:r-s}}static vertexPointsFor(t){const e=B(t.bounds);return t.points.map(s=>$({x:t.bounds.x+s.x,y:t.bounds.y+s.y},e,t.angle))}static hitTestVertex(t,e,s=ee){const i=v.vertexPointsFor(t);let r,a=s;return i.forEach((o,h)=>{const l=Math.hypot(e.x-o.x,e.y-o.y);l<=a&&(a=l,r=h)}),r}static toLocalPoint(t,e){const s=B(t.bounds),i=$(e,s,-t.angle);return{x:i.x-t.bounds.x,y:i.y-t.bounds.y}}static moveVertex(t,e,s){const i=t.points.map((c,u)=>u===e?v.toLocalPoint(t,s):c),r=Math.min(...i.map(c=>c.x)),a=Math.min(...i.map(c=>c.y)),o=Math.max(...i.map(c=>c.x)),h=Math.max(...i.map(c=>c.y)),l={x:t.bounds.x+r,y:t.bounds.y+a,width:o-r,height:h-a},d=i.map(c=>({x:c.x-r,y:c.y-a}));return{...t,bounds:l,points:d}}static insertVertexNear(t,e){const s=v.toLocalPoint(t,e),{points:i}=t;let r=i.length-1,a=1/0;for(let h=0;h<i.length;h++){const l=i[h],d=i[(h+1)%i.length],c=v.distanceToSegment(s,l,d);c<a&&(a=c,r=h)}const o=[...i.slice(0,r+1),s,...i.slice(r+1)];return{...t,points:o}}static distanceToSegment(t,e,s){const i=s.x-e.x,r=s.y-e.y,a=i*i+r*r,o=a===0?0:Math.max(0,Math.min(1,((t.x-e.x)*i+(t.y-e.y)*r)/a)),h=e.x+o*i,l=e.y+o*r;return Math.hypot(t.x-h,t.y-l)}static deleteVertex(t,e){return t.points.length<=te?t:{...t,points:t.points.filter((s,i)=>i!==e)}}}const nt=6,X=nt/2,ie=20,ne=24,re=9,ht=6,ae=7,oe=6,lt=4;class he{constructor(t){this.ctx=t}starPoints=0;roll=0;clear(t,e){this.ctx.clearRect(0,0,t,e)}paintShape(t){this.ctx.save(),this.ctx.globalAlpha=1-t.transparency;const e=t.blur??0;e>0&&(this.ctx.filter=`blur(${(ne*e).toFixed(2)}px)`);const s=t.brightness??0;s>0&&this.paintDazzle(t,s),t.haloScale>0&&this.paintHalo(t),this.paintBase(t),this.ctx.restore(),t.selected&&this.paintSelectionHandles(t)}setStarPoints(t){this.starPoints=Math.max(0,Math.floor(t))}setRoll(t){this.roll=t}paintDazzle(t,e){const{x:s,y:i,width:r,height:a}=t.bounds,o=s+r/2,h=i+a/2,l=Math.max(r,a)/2,d=Math.max(l*(1+re*e),oe*e);if(d<=0)return;this.ctx.save(),this.ctx.globalCompositeOperation="lighter";const c=this.ctx.createRadialGradient(o,h,0,o,h,d);for(let u=0;u<=ht;u++){const f=u/ht,p=1/(1+24*f*f);this.ctx.globalAlpha=1,c.addColorStop(f,this.withAlpha(t.color,p*e*.55))}if(this.ctx.fillStyle=c,this.ctx.beginPath(),this.ctx.arc(o,h,d,0,2*Math.PI),this.ctx.fill(),this.starPoints>0){const u=l*(1+ae*e);this.ctx.lineWidth=Math.max(1,l*.12),this.ctx.lineCap="round";for(let f=0;f<this.starPoints;f++){const p=f/this.starPoints*Math.PI*2+this.roll,m=o+Math.cos(p)*u,y=h+Math.sin(p)*u,k=this.ctx.createLinearGradient(o,h,m,y);k.addColorStop(0,this.withAlpha(t.color,e*.55)),k.addColorStop(.35,this.withAlpha(t.color,e*.22)),k.addColorStop(1,this.withAlpha(t.color,0)),this.ctx.strokeStyle=k,this.ctx.beginPath(),this.ctx.moveTo(o,h),this.ctx.lineTo(m,y),this.ctx.stroke()}}this.ctx.restore()}dazzledFill(t,e){if(e<=0)return t.color;const s=/^#([0-9a-f]{6})$/i.exec(t.color.trim());if(!s)return t.color;const i=Number.parseInt(s[1],16),r=a=>Math.round(a+(255-a)*e);return`rgb(${r(i>>16&255)}, ${r(i>>8&255)}, ${r(i&255)})`}withAlpha(t,e){const s=Math.max(0,Math.min(1,e)),i=/^#([0-9a-f]{6})$/i.exec(t.trim());if(!i)return t;const r=Number.parseInt(i[1],16);return`rgba(${r>>16&255}, ${r>>8&255}, ${r&255}, ${s.toFixed(3)})`}paintBase(t){if(this.ctx.fillStyle=this.dazzledFill(t,t.brightness??0),this.ctx.beginPath(),t.kind==="oval"){const{x:e,y:s,width:i,height:r}=t.bounds,a=i/2,o=r/2;this.ctx.ellipse(e+a,s+o,a,o,t.angle,0,2*Math.PI)}else{const{x:e,y:s,width:i,height:r}=t.bounds;this.ctx.save(),this.ctx.translate(e+i/2,s+r/2),this.ctx.rotate(t.angle),this.ctx.translate(-i/2,-r/2),t.points.forEach((a,o)=>{o===0?this.ctx.moveTo(a.x,a.y):this.ctx.lineTo(a.x,a.y)}),this.ctx.closePath(),this.ctx.restore()}this.ctx.fill()}paintHalo(t){this.ctx.save(),this.ctx.shadowColor=t.color,this.ctx.shadowBlur=ie*t.haloScale,this.paintBase(t),this.ctx.restore()}paintSelectionHandles(t){this.paintHandleFrame(v.handlePointsFor(t),{includeRotate:!0}),t.kind==="polygon"&&this.paintVertexHandles(t)}paintVertexHandles(t){this.ctx.fillStyle="#39f";for(const e of v.vertexPointsFor(t))this.ctx.beginPath(),this.ctx.ellipse(e.x,e.y,lt,lt,0,0,2*Math.PI),this.ctx.fill()}paintMemberOutline(t){this.paintOutline(v.handlePointsFor(t))}paintGroupHandles(t){this.paintHandleFrame(v.handlePointsFor({bounds:t,angle:0}),{includeRotate:!0})}paintOutline(t){this.ctx.strokeStyle="lightgray",this.ctx.beginPath(),this.ctx.moveTo(t.nw.x,t.nw.y),this.ctx.lineTo(t.ne.x,t.ne.y),this.ctx.lineTo(t.se.x,t.se.y),this.ctx.lineTo(t.sw.x,t.sw.y),this.ctx.closePath(),this.ctx.stroke()}paintHandleFrame(t,{includeRotate:e}){this.paintOutline(t),this.ctx.fillStyle="lightgray";for(const s of Tt){const i=t[s];this.ctx.fillRect(i.x-X,i.y-X,nt,nt)}e&&(this.ctx.beginPath(),this.ctx.moveTo(t.n.x,t.n.y),this.ctx.lineTo(t.rotate.x,t.rotate.y),this.ctx.stroke(),this.ctx.beginPath(),this.ctx.ellipse(t.rotate.x,t.rotate.y,X+1,X+1,0,0,2*Math.PI),this.ctx.fill())}}const ct=.05,dt=.08,ut=2,ft=3,le=14,ce=.02;class de{context;voice;voiceToken=0;buffers=new Map;noiseBuffer;crackleBuffer;requested;resume(){if(!this.context){if(typeof AudioContext>"u")return;try{this.context=new AudioContext}catch(t){console.warn("SightingAudio: Web Audio unavailable, the sighting stays silent:",t);return}}this.context.state==="suspended"&&this.context.resume()}setSound(t){if(this.requested=t,!this.context)return;const e=this.keyFor(t);if(!e){this.silence();return}if(this.voice?.key!==e){this.stopVoice();const s=++this.voiceToken;e.startsWith("src:")?this.buildRecordedVoice(t.src,e,s):this.voice=this.buildSynthesizedVoice(t,e)}this.applyTo(this.voice,t)}silence(){this.voiceToken++,this.stopVoice()}dispose(){this.silence(),this.context?.close(),this.context=void 0,this.buffers.clear(),this.noiseBuffer=void 0,this.crackleBuffer=void 0}keyFor(t){if(!(t.volume<=0))return t.src?`src:${t.src}`:t.kind==="none"?void 0:t.kind}applyTo(t,e){const s=this.context;if(!t||!s)return;const i=s.currentTime;t.volumeParam.setTargetAtTime(Math.max(0,Math.min(1,e.volume))*t.gainScale,i,ct);for(const{param:r,ratio:a}of t.pitch)r.setTargetAtTime(Math.min(e.pitchHz*a,s.sampleRate/2-1),i,ct)}buildSynthesizedVoice(t,e){const s=this.context;if(s)switch(t.kind){case"hum":return this.buildHum(s,e);case"whistle":return this.buildWhistle(s,e);case"rumble":return this.buildRumble(s,e);case"crackle":return this.buildCrackle(s,e);default:return}}buildHum(t,e){const s=t.createOscillator();s.type="sawtooth";const i=t.createOscillator();i.type="sawtooth";const r=t.createBiquadFilter();r.type="lowpass",r.Q.value=1;const a=t.createGain();return a.gain.value=0,s.connect(r),i.connect(r),r.connect(a).connect(t.destination),s.start(),i.start(),{key:e,nodes:[r,a],sources:[s,i],volumeParam:a.gain,gainScale:.16,pitch:[{param:s.frequency,ratio:1},{param:i.frequency,ratio:1.006},{param:r.frequency,ratio:6}]}}buildWhistle(t,e){const s=t.createOscillator();s.type="sine";const i=t.createOscillator();i.type="sine",i.frequency.value=5;const r=t.createGain(),a=t.createGain();return a.gain.value=0,i.connect(r).connect(s.frequency),s.connect(a).connect(t.destination),s.start(),i.start(),{key:e,nodes:[r,a],sources:[s,i],volumeParam:a.gain,gainScale:.22,pitch:[{param:s.frequency,ratio:1},{param:r.gain,ratio:.012}]}}buildRumble(t,e){const s=t.createBufferSource();s.buffer=this.brownNoise(t),s.loop=!0;const i=t.createBiquadFilter();i.type="lowpass",i.Q.value=.8;const r=t.createGain();return r.gain.value=0,s.connect(i).connect(r).connect(t.destination),s.start(),{key:e,nodes:[i,r],sources:[s],volumeParam:r.gain,gainScale:1.4,pitch:[{param:i.frequency,ratio:1}]}}buildCrackle(t,e){const s=t.createBufferSource();s.buffer=this.whiteNoise(t),s.loop=!0;const i=t.createBiquadFilter();i.type="bandpass",i.Q.value=1.2;const r=t.createGain();r.gain.value=0;const a=t.createBufferSource();a.buffer=this.crackleEnvelope(t),a.loop=!0;const o=t.createGain();return o.gain.value=0,a.connect(o).connect(r.gain),s.connect(i).connect(r).connect(t.destination),s.start(),a.start(),{key:e,nodes:[i,r,o],sources:[s,a],volumeParam:o.gain,gainScale:.9,pitch:[{param:i.frequency,ratio:4}]}}async buildRecordedVoice(t,e,s){const i=this.context;if(!i)return;let r;try{r=await this.getBuffer(t)}catch(h){console.warn("SightingAudio: the recorded sound failed to load, staying silent:",h);return}if(s!==this.voiceToken||!this.context)return;const a=i.createBufferSource();a.buffer=r,a.loop=!0;const o=i.createGain();o.gain.value=0,a.connect(o).connect(i.destination),a.start(),this.voice={key:e,nodes:[o],sources:[a],volumeParam:o.gain,gainScale:1,pitch:[]},this.requested&&this.applyTo(this.voice,this.requested)}async getBuffer(t){const e=this.context;if(!e)throw new Error("SightingAudio: AudioContext not ready — resume() must be called first");let s=this.buffers.get(t);return s||(s=fetch(t).then(i=>{if(!i.ok)throw new Error(`Audio fetch failed (${i.status}): ${t}`);return i.arrayBuffer()}).then(i=>e.decodeAudioData(i)),this.buffers.set(t,s)),s}whiteNoise(t){if(!this.noiseBuffer){const e=t.createBuffer(1,Math.floor(t.sampleRate*ut),t.sampleRate),s=e.getChannelData(0);for(let i=0;i<s.length;i++)s[i]=Math.random()*2-1;this.noiseBuffer=e}return this.noiseBuffer}brownNoise(t){const e=t.createBuffer(1,Math.floor(t.sampleRate*ut),t.sampleRate),s=e.getChannelData(0);let i=0,r=0;for(let a=0;a<s.length;a++)i=(i+.02*(Math.random()*2-1))/1.02,s[a]=i,r=Math.max(r,Math.abs(i));if(r>0)for(let a=0;a<s.length;a++)s[a]/=r;return e}crackleEnvelope(t){if(!this.crackleBuffer){const e=t.createBuffer(1,Math.floor(t.sampleRate*ft),t.sampleRate),s=e.getChannelData(0),i=Math.max(1,Math.floor(ce*t.sampleRate)),r=Math.round(ft*le);for(let a=0;a<r;a++){const o=Math.floor(Math.random()*s.length),h=.4+Math.random()*.6;for(let l=0;l<i&&o+l<s.length;l++)s[o+l]=Math.max(s[o+l],h*(1-l/i))}this.crackleBuffer=e}return this.crackleBuffer}stopVoice(){const t=this.voice,e=this.context;if(this.voice=void 0,!t||!e)return;const s=e.currentTime;t.volumeParam.cancelScheduledValues(s),t.volumeParam.setTargetAtTime(0,s,dt/3);const i=s+dt;for(const r of t.sources){r.onended=()=>{r.disconnect();for(const a of t.nodes)a.disconnect()};try{r.stop(i)}catch{r.disconnect();for(const a of t.nodes)a.disconnect()}}}}function Y(n){return[...n].sort((t,e)=>t.t-e.t)}function pt(n,t){let e;for(const s of Y(n)){if(s.t>t)break;e=s}return e}const Q=Math.PI/180,G=180/Math.PI;class I{constructor(t,e,s){this.kind=t,this.canvasHeightPx=e,this.fovDeg=s;const i=s*Q/2;this.focalPx=t==="equidistant"?e/2/i:e/2/Math.tan(i)}focalPx;static of(t,e,s){return new I(t.projection,e,s)}degToPx(t){const e=t*Q;return this.kind==="equidistant"?this.focalPx*e:2*this.focalPx*Math.tan(e/2)}pxToDeg(t){return this.kind==="equidistant"?t/this.focalPx*G:2*Math.atan(t/(2*this.focalPx))*G}angleDegToRadiusPx(t){const e=t*Q;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*G:Math.atan(t/this.focalPx)*G}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(M.angularWidthDeg(t))}}class C{static fovOf(t,e){return T(t,e)?.fovDeg??b.fieldOfViewDeg(t.instrument)}static toAngular(t){this.eachKeyframe(t,(e,s)=>({...e,angular:s.ofBounds(e.bounds)}))}static toBounds(t){this.eachKeyframe(t,(e,s)=>{if(!e.angular)return e;const{width:i,height:r}=s.toBoundsSize(e.angular),a={x:e.bounds.x+(e.bounds.width-i)/2,y:e.bounds.y+(e.bounds.height-r)/2,width:i,height:r};if(e.kind!=="polygon")return{...e,bounds:a};const o=e.bounds.width===0?1:i/e.bounds.width,h=e.bounds.height===0?1:r/e.bounds.height;return{...e,bounds:a,points:e.points.map(l=>({x:l.x*o,y:l.y*h}))}})}static toAim(t){this.eachKeyframe(t,(e,s,i)=>{if(i?.headingDeg===void 0)return e;const r=this.frameCentre(t),a=s.radiusPxToAngleDeg(e.bounds.x+e.bounds.width/2-r.x),o=s.radiusPxToAngleDeg(r.y-(e.bounds.y+e.bounds.height/2));return{...e,aim:{azimuthDeg:((i.headingDeg+a)%360+360)%360,altitudeDeg:i.pitchDeg+o}}})}static toPosition(t){this.eachKeyframe(t,(e,s,i)=>{if(!e.aim||i?.headingDeg===void 0)return e;const r=this.frameCentre(t),a=this.shortestArc(e.aim.azimuthDeg-i.headingDeg),o=e.aim.altitudeDeg-i.pitchDeg,h=r.x+this.offAxisPx(s,a)-e.bounds.width/2,l=r.y-this.offAxisPx(s,o)-e.bounds.height/2;return{...e,bounds:{...e.bounds,x:h,y:l}}})}static frameCentre(t){return{x:b.frameWidthPx(t.instrument,M.CANVAS_HEIGHT_PX)/2,y:M.CANVAS_HEIGHT_PX/2}}static shortestArc(t){return(t%360+540)%360-180}static offAxisPx(t,e){return Math.abs(e)>=C.OFF_CANVAS_DEG?Math.sign(e)*C.OFF_CANVAS_PX:t.angleDegToRadiusPx(e)}static OFF_CANVAS_DEG=89;static OFF_CANVAS_PX=1e5;static reproject(t,e,s){const i=b.frameWidthPx(e,M.CANVAS_HEIGHT_PX)/2,r=b.frameWidthPx(t.instrument,M.CANVAS_HEIGHT_PX)/2,a=M.CANVAS_HEIGHT_PX/2;for(const o of[...t.timeline.allKeyframes]){const h=this.fovOf(t,o.t),l=s?.get(o.t)??h,d=I.of(e,M.CANVAS_HEIGHT_PX,l),c=I.of(t.instrument,M.CANVAS_HEIGHT_PX,h);t.timeline.addKeyframe(o.t,o.shapes.map(u=>{const{bounds:f}=u.shape,p=f.x+f.width/2-i,m=f.y+f.height/2-a,y=Math.hypot(p,m),k=y===0?1:c.angleDegToRadiusPx(d.radiusPxToAngleDeg(y))/y,z={...f,x:r+p*k-f.width/2,y:a+m*k-f.height/2};return{...u,shape:{...u.shape,bounds:z}}}))}this.toBounds(t)}static eachKeyframe(t,e){const{timeline:s}=t;for(const i of[...s.allKeyframes]){const r=T(t,i.t),a=this.fovOf(t,i.t),o=I.of(t.instrument,M.CANVAS_HEIGHT_PX,a);s.addKeyframe(i.t,i.shapes.map(h=>({...h,shape:e(h.shape,o,r)})))}}}function ue(n){return S.restore(fe(n),n.provenance)}function fe(n){return C.toAngular(n),C.toAim(n),{version:1,time:n.event.time,endTime:n.event.endTime,durationSeconds:n.event.durationSeconds,utcOffsetHours:n.event.utcOffsetHours,timeZone:n.event.timeZone,place:n.event.place,witness:n.witness,caseId:n.caseId,description:n.event.description,tags:n.event.tags,timeline:n.timeline.toJSON(),witnessTrack:n.witnessTrack.toJSON(),weatherTrack:n.weatherTrack.toJSON(),soundTrack:n.soundTrack.toJSON(),weather:n.weather,decor:n.decor,milestones:n.milestones.length>0?n.milestones:void 0,weatherSource:n.weatherSource,instrument:n.instrumentId,exposureSeconds:n.exposureSeconds}}function pe(n){const{recording:t,provenance:e}=S.strip(n),s=me(t);return s.provenance=e,s}function me(n){const t=new J({eventType:"sighting",time:n.time,endTime:n.endTime,durationSeconds:n.durationSeconds,utcOffsetHours:n.utcOffsetHours,timeZone:n.timeZone,place:n.place,description:n.description,tags:n.tags},Z.fromJSON(n.timeline),n.witnessTrack?O.fromJSON(n.witnessTrack):new O,n.weatherTrack?N.fromJSON(n.weatherTrack):new N,n.soundTrack?W.fromJSON(n.soundTrack):new W,n.witness,n.caseId,n.weather,n.decor??[],n.weatherSource,n.instrument,n.exposureSeconds??n.witnessTrack?.keyframes.map(e=>e.pose.exposureSeconds).find(e=>e!==void 0),Y(n.milestones??[]));return C.toBounds(t),C.toPosition(t),t}function ge(n,t){for(const e of n){const s=e.toLowerCase().split("-")[0];if(t.includes(s))return s}return"en"}class mt{static preferencesFor(t){const e=navigator.languages??[],s=this.declaredFor(t);return s?[s,...e]:e}static declaredFor(t){for(let e=t;e;){const s=e.closest("[lang]")?.getAttribute("lang")?.trim();if(s)return s;const i=e.getRootNode();e=i instanceof ShadowRoot?i.host:void 0}}}class P{constructor(t){this.preferences=t}read(t){if(t===void 0||typeof t=="string")return t===""?void 0:t;for(const s of this.preferences){const i=t[s]??t[P.base(s)];if(i)return i}const e=new Set(this.preferences.map(s=>P.base(s)));for(const[s,i]of Object.entries(t))if(i&&e.has(P.base(s)))return i;return Object.values(t).find(s=>s)??void 0}write(t,e,s){const i=e?.trim()?e.trim():void 0;if(t===void 0||typeof t=="string")return i;const r={...t},a=Object.keys(r).find(o=>o===s)??Object.keys(r).find(o=>P.base(o)===P.base(s))??s;return i===void 0?delete r[a]:r[a]=i,Object.keys(r).length===0?void 0:r}static base(t){return t.toLowerCase().split("-")[0]}}const ye="modulepreload",we=function(n,t){return new URL(n,t).href},gt={},yt=function(t,e,s){let i=Promise.resolve();if(e&&e.length>0){let a=function(d){return Promise.all(d.map(c=>Promise.resolve(c).then(u=>({status:"fulfilled",value:u}),u=>({status:"rejected",reason:u}))))};const o=document.getElementsByTagName("link"),h=document.querySelector("meta[property=csp-nonce]"),l=h?.nonce||h?.getAttribute("nonce");i=a(e.map(d=>{if(d=we(d,s),d in gt)return;gt[d]=!0;const c=d.endsWith(".css"),u=c?'[rel="stylesheet"]':"";if(!!s)for(let m=o.length-1;m>=0;m--){const y=o[m];if(y.href===d&&(!c||y.rel==="stylesheet"))return}else if(document.querySelector(`link[href="${d}"]${u}`))return;const p=document.createElement("link");if(p.rel=c?"stylesheet":ye,c||(p.as="script"),p.crossOrigin="",p.href=d,l&&p.setAttribute("nonce",l),document.head.appendChild(p),c)return new Promise((m,y)=>{p.addEventListener("load",m),p.addEventListener("error",()=>y(new Error(`Unable to preload CSS for ${d}`)))})}))}function r(a){const o=new Event("vite:preloadError",{cancelable:!0});if(o.payload=a,window.dispatchEvent(o),!o.defaultPrevented)throw a}return i.then(a=>{for(const o of a||[])o.status==="rejected"&&r(o.reason);return t().catch(r)})},be=["en","fr"],ve={en:()=>yt(()=>Promise.resolve().then(()=>Me),void 0,import.meta.url).then(n=>n.ufoMessages_en),fr:()=>yt(()=>import("./UfoMessages_fr-BJPYHN17.js"),[],import.meta.url).then(n=>n.ufoMessages_fr)};function xe(n){return ve[n]()}const Pt={play:"Play",pause:"Pause",noDuration:"No observation duration",autoReplay:"Auto-replay",currentPosition:"Current position",duration:"Duration",switchToElapsed:"click to show elapsed time",switchToClockTime:"click to show the time of day",fullscreen:"Fullscreen",exitFullscreen:"Exit fullscreen",showWitnessMap:"Show where the witness was",hideWitnessMap:"Hide where the witness was",mapImageryUnavailable:"Aerial imagery unavailable",showMilestones:"Show the account's moments",hideMilestones:"Hide the account's moments",witnessHere:"The witness, here",decorHere:"Scenery"},Me=Object.freeze(Object.defineProperty({__proto__:null,ufoMessages_en:Pt},Symbol.toStringTag,{value:"Module"}));function Se(n,t){const e=n.track,s={eastM:n.eastM,northM:n.northM,altitudeM:0,headingDeg:n.headingDeg};if(!e||e.length===0)return s;if(e.length===1||t<=e[0].t)return wt(e[0],n);const i=e[e.length-1];if(t>=i.t)return wt(i,n);for(let r=0;r<e.length-1;r++){const a=e[r],o=e[r+1];if(t<a.t||t>o.t)continue;const h=o.t-a.t,l=h===0?0:(t-a.t)/h;return{eastM:a.eastM+(o.eastM-a.eastM)*l,northM:a.northM+(o.northM-a.northM)*l,altitudeM:(a.altitudeM??0)+((o.altitudeM??0)-(a.altitudeM??0))*l,headingDeg:a.headingDeg??n.headingDeg}}return s}function wt(n,t){return{eastM:n.eastM,northM:n.northM,altitudeM:n.altitudeM??0,headingDeg:n.headingDeg??t.headingDeg}}const At=Math.PI/180,ke=180/Math.PI,Ee=256,Te=19;function Pe(n,t){return 156543.03392*Math.cos(n*At)/2**t}function Ae(n,t){return Pe(n,t)*Ee}function Ie(n,t){let e=0;for(;e<Te&&Ae(n,e+1)>=t;)e++;return e}function K(n){const t=n*At;return(1-Math.log(Math.tan(t)+1/Math.cos(t))/Math.PI)/2}function De(n,t,e){const s=2**e;return{x:(n+180)/360*s,y:K(t)*s}}function Ce(n,t,e){const s=K(n.north),i=K(n.south);return{x:(t-n.west)/(n.east-n.west),y:(K(e)-s)/(i-s)}}function _e(n,t,e){const{x:s,y:i}=De(n,t,e);return{x:Math.floor(s),y:Math.floor(i),z:e}}function Re(n){const t=2**n.z,e=n.x/t*360-180,s=(n.x+1)/t*360-180,i=bt(n.y,t);return{south:bt(n.y+1,t),north:i,west:e,east:s}}function bt(n,t){const e=n/t;return Math.atan(Math.sinh(Math.PI*(1-2*e)))*ke}function Be(n,t,e,s){const i=_e(n,t,e),r=Math.floor(s/2),a=[];for(let l=-r;l<=r;l++)for(let d=-r;d<=r;d++)a.push({x:i.x+d,y:i.y+l,z:e});const o=a.map(Re),h={south:Math.min(...o.map(l=>l.south)),north:Math.max(...o.map(l=>l.north)),west:Math.min(...o.map(l=>l.west)),east:Math.max(...o.map(l=>l.east))};return{tiles:a,bounds:h}}class A{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 s,i=1/0;for(const r of this.targets){const a=Math.hypot(r.x-t,r.y-e);a>r.radius||a>i||(s=r,i=a)}return s}get width(){return this.ctx.canvas.width}get height(){return this.ctx.canvas.height}paint(t){const{ctx:e}=this;e.save(),this.targets=[],e.clearRect(0,0,this.width,this.height),this.paintGround(t),this.paintNight(t.nightFraction),this.paintPath(t),t.position?(this.paintCone(t,t.position),this.paintDecor(t),this.paintMarkers(t),this.paintWitness(t,t.position)):(this.paintDecor(t),this.paintMarkers(t)),this.paintNorth(),this.paintFooter(t.bounds,t.attribution),e.restore()}toCanvas(t,e,s){const i=Ce(t,s,e);return{x:i.x*this.width,y:i.y*this.height}}paintGround(t){const{ctx:e}=this;e.fillStyle="#1d2321",e.fillRect(0,0,this.width,this.height);const s=t.imagery;if(!s)return;const i=this.toCanvas(t.bounds,s.bounds.north,s.bounds.west),r=this.toCanvas(t.bounds,s.bounds.south,s.bounds.east);e.drawImage(s.source,i.x,i.y,r.x-i.x,r.y-i.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 s of t.decor){const i=this.toCanvas(t.bounds,s.lat,s.lng);if(s.label&&this.targets.push({kind:"decor",label:s.label,lat:s.lat,lng:s.lng,x:i.x,y:i.y,radius:7}),e.beginPath(),e.rect(i.x-3.5,i.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(),s.headingDeg===void 0)continue;const r=(s.headingDeg-90)*Math.PI/180;e.beginPath(),e.moveTo(i.x,i.y),e.lineTo(i.x+Math.cos(r)*10,i.y+Math.sin(r)*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,s=t.path.points.map(i=>this.toCanvas(t.bounds,i.lat,i.lng));e.beginPath(),e.moveTo(s[0].x,s[0].y);for(const i of s.slice(1))e.lineTo(i.x,i.y);e.lineJoin="round",e.lineCap="round",e.strokeStyle="rgba(0, 0, 0, 0.65)",e.lineWidth=5,e.stroke(),e.strokeStyle="rgba(255, 255, 255, 0.9)",e.lineWidth=2,e.stroke()}paintCone(t,e){const{headingDeg:s,coneHalfAngleDeg:i}=t;if(s===void 0||i===void 0)return;const{ctx:r}=this,a=this.toCanvas(t.bounds,e.lat,e.lng),o=Math.hypot(this.width,this.height),h=(s-90)*Math.PI/180,l=i*Math.PI/180;r.save(),r.beginPath(),r.moveTo(a.x,a.y),r.arc(a.x,a.y,o,h-l,h+l),r.closePath();const d=r.createRadialGradient(a.x,a.y,0,a.x,a.y,o);d.addColorStop(0,"rgba(255, 224, 130, 0.55)"),d.addColorStop(.35,"rgba(255, 224, 130, 0.22)"),d.addColorStop(1,"rgba(255, 224, 130, 0)"),r.fillStyle=d,r.fill(),r.restore()}paintMarkers(t){const{ctx:e}=this;e.textAlign="center",e.textBaseline="middle",e.font="bold 10px sans-serif";for(const s of[...t.markers].sort((i,r)=>Number(i.current)-Number(r.current))){const i=this.toCanvas(t.bounds,s.lat,s.lng);this.targets.push({kind:"milestone",label:s.note?`${s.label} — ${s.note}`:s.label,lat:s.lat,lng:s.lng,t:s.t,x:i.x,y:i.y,radius:A.MARKER_RADIUS_PX}),e.beginPath(),e.arc(i.x,i.y,A.MARKER_RADIUS_PX,0,Math.PI*2),e.fillStyle=s.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=s.current?"#1d2321":"#fff",e.fillText(s.label,i.x,i.y)}}paintWitness(t,e){const{ctx:s}=this,i=this.toCanvas(t.bounds,e.lat,e.lng);t.witnessLabel&&this.targets.push({kind:"witness",label:t.witnessLabel,lat:e.lat,lng:e.lng,x:i.x,y:i.y,radius:8});const r=t.markers.some(a=>{if(!a.current)return!1;const o=D(a.lat,a.lng,e.lat,e.lng);return Math.hypot(o.x,o.z)<=A.ON_MARKER_M});s.beginPath(),s.arc(i.x,i.y,r?A.MARKER_RADIUS_PX+2.5:5.5,0,Math.PI*2),r||(s.fillStyle="#ff5a3c",s.fill()),s.lineWidth=4,s.strokeStyle="rgba(0, 0, 0, 0.5)",s.stroke(),s.lineWidth=r?3:2.5,s.strokeStyle=r?"#ff5a3c":"#fff",s.stroke()}paintNorth(){const{ctx:t}=this,e=this.width-14,s=16;t.beginPath(),t.moveTo(e,s-9),t.lineTo(e-4.5,s+5),t.lineTo(e,s+2),t.lineTo(e+4.5,s+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,s+6),t.fillText("N",e,s+6)}paintFooter(t,e){const{ctx:s}=this;s.font="9px sans-serif",s.textBaseline="bottom";const i=e?this.wrap(e,this.width-20):[];let r=this.height-4;s.textAlign="right";for(const f of i.slice().reverse())this.paintOutlinedText(f,this.width-6,r),r-=11;const a=(t.south+t.north)/2,h=Math.abs(D(a,t.east,a,t.west).x)/this.width,l=A.SCALE_STEPS_M.find(f=>f/h<=this.width/3);if(l===void 0)return;const d=l/h,c=8,u=r-3;s.lineWidth=3,s.strokeStyle="rgba(0, 0, 0, 0.6)",s.beginPath(),s.moveTo(c,u),s.lineTo(c+d,u),s.stroke(),s.lineWidth=1.5,s.strokeStyle="rgba(255, 255, 255, 0.95)",s.stroke(),s.textAlign="left",this.paintOutlinedText(l>=1e3?`${l/1e3} km`:`${l} m`,c,u-3)}paintOutlinedText(t,e,s){const{ctx:i}=this;i.lineWidth=3,i.strokeStyle="rgba(0, 0, 0, 0.75)",i.strokeText(t,e,s),i.fillStyle="#fff",i.fillText(t,e,s)}wrap(t,e){const s=[];let i="";for(const r of t.split(" ")){const a=i?`${i} ${r}`:r;i&&this.ctx.measureText(a).width>e?(s.push(i),i=r):i=a}return i&&s.push(i),s}}const tt=256,vt=3;async function Le(n,t,e,s){const i=(n.south+n.north)/2,r=(n.west+n.east)/2,a=Math.abs(D(i,n.east,i,n.west).x),o=Math.abs(D(n.north,r,n.south,r).z),h=Ie(i,Math.max(a,o)/2),{tiles:l,bounds:d}=Be(r,i,h,vt),c=vt*tt,u=document.createElement("canvas");u.width=c,u.height=c;const f=u.getContext("2d");if(!f)throw new Error("2D canvas context unavailable");const p=l[0];await Promise.all(l.map(async k=>{const z=e(k),j=await s(z);if(!j.ok)throw new Error(`Imagery tile fetch failed (${j.status}): ${z}`);const It=await createImageBitmap(await j.blob());f.drawImage(It,(k.x-p.x)*tt,(k.y-p.y)*tt)}));const m=document.createElement("canvas");m.width=t.width,m.height=t.height;const y=m.getContext("2d");if(!y)throw new Error("2D canvas context unavailable");return y.drawImage(u,0,0,c,c,0,0,t.width,t.height),{source:m,width:t.width,height:t.height,bounds:d}}class Fe{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 Le(t,e,s=>this.tileUrlTemplate.replace("{z}",String(s.z)).replace("{y}",String(s.y)).replace("{x}",String(s.x)),this.fetchImpl)}}function Oe(){return new Fe}const xt=new Set,et="show-witness-map",st="hide-milestones";class x extends HTMLElement{static get observedAttributes(){return["src",et,st]}shadow;stageElement;canvas;canvasRenderer;tooltip;toolbar;playPauseButton;loopButton;static WITNESS_MAP_MIN_SPAN_M=400;static WITNESS_MAP_MARGIN=.6;static WITNESS_MAP_IMAGERY_PX=768;fullscreenButton;cornerButtons;witnessMapButton;milestonesButton;witnessMapPanel;witnessMapCanvas;witnessMapRenderer;seekInput;milestoneMarks;milestoneCaption;timeStartLabel;timeEndLabel;witnessPath;witnessMapBounds;witnessMapImagery;witnessMapImageryRequested=!1;witnessMapImageryCredit;witnessMapImageryFailed=!1;creditShownExternally=!1;lookYawDeg=0;lookPitchDeg=0;milestonesShown=!0;currentSighting=J.create();sightingAudio=new de;soundPreview;player;loopEnabled=!0;playbackBeforeClick;highlightedSourceIds=new Set;occludedSourceIds=xt;enableClickToPlay=!0;fullscreenTarget;messages=Pt;realDurationMs;realStartMs;showClockTime=!0;handleFullscreenChange=()=>{this.updateFullscreenButton(),this.resizeWitnessMap()};witnessMapResizeObserver=typeof ResizeObserver>"u"?void 0:new ResizeObserver(()=>this.resizeWitnessMap());resizeWitnessMap(){this.witnessMapPanel.hidden||(this.sizeWitnessMapCanvas(),this.paintWitnessMap(this.currentTime))}simulatedFullscreen=!1;styleBeforeSimulatedFullscreen;bodyOverflowBeforeSimulatedFullscreen;handleSimulatedFullscreenKey=t=>{t.key==="Escape"&&this.exitSimulatedFullscreen()};handlePointerMove=t=>{const e=this.canvasPointFromEvent(t),s=e&&this.shapeAt(e.x,e.y),i=this.said.read(s?.shape.title);if(!i){this.tooltip.hidden=!0;return}this.tooltip.textContent=i,this.tooltip.hidden=!1;const r=this.stageElement.getBoundingClientRect();this.tooltip.style.left=`${t.clientX-r.left+12}px`,this.tooltip.style.top=`${t.clientY-r.top+12}px`};handleWitnessMapPointerMove=t=>{const e=this.witnessMapTargetFrom(t);if(!e){this.tooltip.hidden=!0,this.witnessMapCanvas.style.cursor="default";return}this.witnessMapCanvas.style.cursor="pointer",this.tooltip.textContent=e.label,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`};handleWitnessMapClick=t=>{const e=this.witnessMapTargetFrom(t);if(e){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}))}};witnessMapTargetFrom(t){const e=this.witnessMapCanvas.getBoundingClientRect();if(!(e.width===0||e.height===0))return this.witnessMapRenderer.hitTest((t.clientX-e.left)/e.width*this.witnessMapCanvas.width,(t.clientY-e.top)/e.height*this.witnessMapCanvas.height)}handlePointerLeave=()=>{this.tooltip.hidden=!0};constructor(){super(),this.shadow=this.attachShadow({mode:"open"});const t=document.createElement("template");t.innerHTML=`<style>${Ct}</style>${Dt}`,this.shadow.appendChild(t.content.cloneNode(!0)),this.stageElement=this.shadow.getElementById("stage"),this.canvas=this.shadow.getElementById("canvas"),this.canvasRenderer=new he(this.canvas.getContext("2d")),this.tooltip=this.shadow.getElementById("tooltip"),this.toolbar=this.shadow.getElementById("toolbar"),this.playPauseButton=this.shadow.getElementById("play-pause"),this.loopButton=this.shadow.getElementById("loop"),this.fullscreenButton=this.shadow.getElementById("fullscreen"),this.cornerButtons=this.shadow.getElementById("corner-buttons"),this.witnessMapButton=this.shadow.getElementById("witness-map"),this.milestonesButton=this.shadow.getElementById("milestones"),this.witnessMapPanel=this.shadow.getElementById("witness-map-panel"),this.witnessMapCanvas=this.shadow.getElementById("witness-map-canvas"),this.witnessMapRenderer=new A(this.witnessMapCanvas.getContext("2d")),this.seekInput=this.shadow.getElementById("seek"),this.milestoneMarks=this.shadow.getElementById("milestone-marks"),this.milestoneCaption=this.shadow.getElementById("milestone-caption"),this.timeStartLabel=this.shadow.getElementById("time-start"),this.timeEndLabel=this.shadow.getElementById("time-end");for(const e of[this.timeStartLabel,this.timeEndLabel])e.addEventListener("click",()=>this.toggleTimeDisplay()),e.addEventListener("keydown",s=>{s.key!=="Enter"&&s.key!==" "||(s.preventDefault(),this.toggleTimeDisplay())});this.fullscreenTarget=this.stageElement,this.playPauseButton.addEventListener("click",()=>this.togglePlayPause()),this.loopButton.addEventListener("click",()=>this.toggleLoop()),this.fullscreenButton.addEventListener("click",()=>this.toggleFullscreen()),this.witnessMapButton.addEventListener("click",()=>this.toggleWitnessMap()),this.milestonesButton.addEventListener("click",()=>this.toggleMilestones()),this.witnessMapCanvas.addEventListener("pointermove",this.handleWitnessMapPointerMove),this.witnessMapCanvas.addEventListener("pointerleave",this.handlePointerLeave),this.witnessMapCanvas.addEventListener("click",this.handleWitnessMapClick),this.seekInput.addEventListener("input",()=>this.player.seek(Number(this.seekInput.value))),this.canvas.addEventListener("click",e=>{this.enableClickToPlay&&(e.detail<=1&&(this.playbackBeforeClick={state:this.playbackState,time:this.currentTime}),this.togglePlayPause())}),this.canvas.addEventListener("dblclick",e=>{this.enableClickToPlay&&(e.preventDefault(),this.restorePlayback(),this.toggleFullscreen())}),this.canvas.addEventListener("pointermove",this.handlePointerMove),this.canvas.addEventListener("pointerleave",this.handlePointerLeave),document.addEventListener("fullscreenchange",this.handleFullscreenChange),this.witnessMapResizeObserver?.observe(this.witnessMapPanel),this.player=this.createPlayer(),this.updateTimeLabels(),this.updatePlayPauseButton(),this.updateFullscreenButton(),this.updateWitnessMapButton(),this.updateMilestonesButton(),this.refresh(),this.loadLocaleMessages()}connectedCallback(){this.saidTexts=void 0;const t=this.getAttribute("src");t&&this.loadFromSrc(t)}disconnectedCallback(){document.removeEventListener("fullscreenchange",this.handleFullscreenChange),this.witnessMapResizeObserver?.disconnect(),this.exitSimulatedFullscreen(),this.sightingAudio.dispose()}attributeChangedCallback(t,e,s){t==="src"&&s&&s!==e&&this.isConnected&&this.loadFromSrc(s),t===et&&this.applyWitnessMapDefault(),t===st&&this.setMilestonesShown(!this.hasAttribute(st))}async loadFromSrc(t){this.sightingData=await _t.json(t)}get sightingData(){return ue(this.currentSighting)}set sightingData(t){this.player.stop(),this.soundPreview=void 0,this.sightingAudio.silence(),this.currentSighting=pe(t),this.player=this.createPlayer(),this.updateTimeLabels(),this.updatePlayPauseButton(),this.refresh(),this.applyWitnessMapDefault()}get sighting(){return this.currentSighting}previewSound(t){this.soundPreview=t,this.sightingAudio.resume(),this.sightingAudio.setSound(t)}stopSoundPreview(){this.soundPreview=void 0,this.sightingAudio.silence()}get canvasElement(){return this.canvas}get renderer(){return this.canvasRenderer}get currentTime(){return this.player.time}set currentTime(t){this.player.seek(t)}get seekableDuration(){return this.player.seekableDuration}get autoReplayEnabled(){return this.loopEnabled}set autoReplayEnabled(t){t!==this.loopEnabled&&this.toggleLoop()}play(){this.player.seekableDuration<=0||this.playbackState==="playing"||this.togglePlayPause()}pause(){this.playbackState==="playing"&&this.togglePlayPause()}get positionLabel(){return this.timeStartLabel.textContent??""}get durationLabel(){return this.timeEndLabel.textContent??""}get showingClockTime(){return this.canShowClockTime}get canSwitchTimeDisplay(){return this.realStartMs!==void 0}toggleTimeDisplay(){this.canSwitchTimeDisplay&&(this.showClockTime=!this.showClockTime,this.updateTimeLabels(),this.updateTimeLabelTitles(),this.dispatchEvent(new CustomEvent("timedisplaychange",{bubbles:!0,composed:!0})))}get canShowClockTime(){return this.realStartMs!==void 0&&this.showClockTime}set showToolbar(t){this.toolbar.classList.toggle("hidden",!t)}get playbackState(){return this.player.playbackState}get selectedSourceIds(){return this.highlightedSourceIds}get durationSeconds(){return this.currentSighting.event.durationSeconds}set durationSeconds(t){this.currentSighting.event.durationSeconds=t,this.updateTimeLabels(),this.refresh(),this.updatePlayPauseButton()}set selectedSourceIds(t){const e=new Set(t);e.size===this.highlightedSourceIds.size&&[...e].every(i=>this.highlightedSourceIds.has(i))||(this.highlightedSourceIds=e,this.refresh())}setOccludedSourceIds(t){t.size===this.occludedSourceIds.size&&[...t].every(s=>this.occludedSourceIds.has(s))||(this.occludedSourceIds=t,this.refresh())}hasVisibleShapeAt(t,e){return this.shapeAt(t,e)!==void 0}refresh(){this.applyFrameFormat(),this.updateTimeLabels(),this.seekInput.max=String(this.player.seekableDuration),this.refreshMilestoneMarks(),this.updateMilestonesButton(),this.updateWitnessMap(),this.player.seek(this.player.time)}refreshMilestoneMarks(){const t=this.player.seekableDuration,e=t>0?Y(this.sighting.milestones):[];this.milestoneMarks.replaceChildren(...e.map(s=>{const i=document.createElement("button");i.type="button",i.className="milestone-mark",i.style.left=`${Math.min(Math.max(s.t/t,0),1)*100}%`;const r=this.said.read(s.label)??"",a=this.said.read(s.note),o=a?`${r} — ${a}`:r;return i.title=o,i.setAttribute("aria-label",o),i.addEventListener("click",()=>this.player.seek(s.t)),i}))}showMilestoneAt(t){const e=this.milestonesShown&&this.sighting.milestones.length>0?pt(this.sighting.milestones,t):void 0;if(this.milestoneCaption.hidden=e===void 0,!e)return;const s=document.createElement("b");s.textContent=this.said.read(e.label)??"";const i=this.said.read(e.note),r=i?` — ${i}`:"";this.milestoneCaption.replaceChildren(s,document.createTextNode(r))}exposureInstants(t){const e=this.exposureTimes(t),s=1/e.length;return e.map(i=>({shapes:this.shapesAt(i),share:s}))}exposureTimes(t=this.currentTime){const e=(this.currentSighting.exposure??0)*1e3;if(e<x.SHORTEST_VISIBLE_EXPOSURE_MS)return[t];const s=Math.min(x.MAX_EXPOSURE_STEPS,Math.max(2,Math.round(e/x.SHORTEST_VISIBLE_EXPOSURE_MS))),i=Math.ceil(this.travelPxOver(t,e)/x.EXPOSURE_STEP_PX),r=Math.min(x.MAX_TRAVEL_STEPS,Math.max(s,i)),a=[];for(let o=0;o<r;o++)a.push(t+e*o/r);return a}travelPxOver(t,e){const s=this.shapesAt(t),i=this.shapesAt(t+e);let r=0;for(const[a,o]of s){const h=i.get(a);if(!h)continue;const l=h.bounds.x+h.bounds.width/2-(o.bounds.x+o.bounds.width/2),d=h.bounds.y+h.bounds.height/2-(o.bounds.y+o.bounds.height/2);r=Math.max(r,Math.hypot(l,d))}return r}shapeAt(t,e,s=this.occludedSourceIds){for(const i of this.exposureTimes()){const r=this.currentSighting.timeline.hitTest(i,t,e,s);if(r)return r}}shapesAt(t){const e=new Map;for(const s of this.currentSighting.timeline.sourceIds){const i=this.currentSighting.timeline.getInterpolatedShapeAt(t,s);i&&e.set(s,i)}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=b.frameWidthPx(this.currentSighting.instrument,this.canvas.height);if(this.canvas.width===t)return;this.canvas.width=t,this.canvas.parentElement?.style.setProperty("--frame-aspect",`${t} / ${this.canvas.height}`)}canvasPointFromEvent(t){const e=this.canvas.getBoundingClientRect();if(!(e.width===0||e.height===0))return{x:(t.clientX-e.left)/e.width*this.canvas.width,y:(t.clientY-e.top)/e.height*this.canvas.height}}onFrame(t,e){this.canvasRenderer.clear(this.canvas.width,this.canvas.height);const s=this.playbackState!=="playing"?this.highlightedSourceIds:xt;this.canvasRenderer.setStarPoints(b.starPointsOf(this.sighting.instrument));const i=(T(this.sighting,t)?.rollDeg??0)+this.gaitAt(t).rollDeg;this.canvasRenderer.setRoll(i*Math.PI/180);const r=this.exposureInstants(t),a=this.frameShift;for(const o of r)for(const[h,l]of o.shapes){if(this.occludedSourceIds.has(h))continue;const d=o.share,c=d===1?l:{...l,transparency:1-(1-l.transparency)*d};this.canvasRenderer.paintShape(this.shifted(c,a))}for(const[o,h]of r[0].shapes)this.occludedSourceIds.has(o)||!s.has(o)||(s.size===1?this.canvasRenderer.paintShape({...h,selected:!0}):this.canvasRenderer.paintMemberOutline(h));if(s.size>1){const o=v.groupBoundsFor([...e].filter(([h])=>s.has(h)).map(([,h])=>h.bounds));this.canvasRenderer.paintGroupHandles(o)}this.keepWitnessMapClear(r[0].shapes),this.seekInput.value=String(t),this.timeStartLabel.textContent=this.formatPosition(t),this.showMilestoneAt(t),this.paintWitnessMap(t),this.playbackState==="playing"?(this.soundPreview=void 0,this.sightingAudio.setSound(Jt(this.currentSighting,t))):this.soundPreview?this.sightingAudio.setSound(this.soundPreview):this.sightingAudio.silence(),this.updatePlayPauseButton(),this.dispatchEvent(new CustomEvent("timeupdate",{detail:{time:t}}))}shifted(t,e){return e.x===0&&e.y===0?t:{...t,bounds:{...t.bounds,x:t.bounds.x+e.x,y:t.bounds.y+e.y}}}createPlayer(){const t=new jt(this.currentSighting.timeline,(e,s)=>this.onFrame(e,s));return t.loop=this.loopEnabled,t.onEnded=()=>{this.updatePlayPauseButton(),this.dispatchEvent(new CustomEvent("ended",{bubbles:!0,composed:!0}))},t}togglePlayPause(){this.player.seekableDuration<=0||(this.player.playbackState==="playing"?(this.player.pause(),this.soundPreview=void 0,this.sightingAudio.silence(),this.refresh()):(this.sightingAudio.resume(),this.player.play()),this.updatePlayPauseButton())}updatePlayPauseButton(){const t=this.player.playbackState==="playing";this.playPauseButton.textContent=t?"⏸":"▶";const e=this.player.seekableDuration>0;this.playPauseButton.disabled=!e;const s=e?t?this.messages.pause:this.messages.play:this.messages.noDuration;this.playPauseButton.title=s,this.playPauseButton.setAttribute("aria-label",s),this.toolbar.classList.toggle("auto-hide",t),this.cornerButtons.classList.toggle("auto-hide",t)}toggleLoop(){this.loopEnabled=!this.loopEnabled,this.loopButton.setAttribute("aria-pressed",String(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()}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()}toggleWitnessMap(){this.setWitnessMapOpen(this.witnessMapPanel.hidden)}applyWitnessMapDefault(){this.setWitnessMapOpen(this.hasAttribute(et)&&this.witnessPath!==void 0)}setWitnessMapOpen(t){this.witnessMapPanel.hidden=!t,this.witnessMapPanel.removeAttribute("title"),this.witnessMapButton.setAttribute("aria-pressed",String(t)),this.updateWitnessMapButton(),t&&(this.sizeWitnessMapCanvas(),this.loadWitnessMapImagery(),this.paintWitnessMap(this.currentTime))}updateWitnessMapButton(){const e=!this.witnessMapPanel.hidden?this.messages.hideWitnessMap:this.messages.showWitnessMap;this.witnessMapButton.title=e,this.witnessMapButton.setAttribute("aria-label",e)}updateWitnessMap(){const t=this.witnessPath!==void 0;if(this.witnessPath=F.of(this.currentSighting),this.witnessMapButton.hidden=this.witnessPath===void 0,!t&&this.witnessPath&&this.applyWitnessMapDefault(),!this.witnessPath){this.setWitnessMapOpen(!1),this.witnessMapBounds=void 0;return}const e=this.witnessPath.boundsAround(x.WITNESS_MAP_MIN_SPAN_M,x.WITNESS_MAP_MARGIN);(!this.witnessMapBounds||!this.sameGround(this.witnessMapBounds,e))&&(this.witnessMapBounds=e,this.witnessMapImagery=void 0,this.witnessMapImageryCredit=void 0,this.witnessMapImageryFailed=!1,this.witnessMapImageryRequested=!1,this.witnessMapPanel.hidden||this.loadWitnessMapImagery())}sameGround(t,e){const s=Math.abs(t.east-t.west)/20;return Math.abs(t.north-e.north)<s&&Math.abs(t.south-e.south)<s&&Math.abs(t.west-e.west)<s&&Math.abs(t.east-e.east)<s}async loadWitnessMapImagery(){if(this.witnessMapImageryRequested||!this.witnessMapBounds)return;this.witnessMapImageryRequested=!0;const t=Oe(),e=this.witnessMapBounds;try{const s=await t.getImageryTexture(e,{width:x.WITNESS_MAP_IMAGERY_PX,height:x.WITNESS_MAP_IMAGERY_PX});if(this.witnessMapBounds!==e)return;this.witnessMapImagery=s,this.witnessMapImageryCredit=t.attribution}catch{this.witnessMapImageryFailed=!0}this.paintWitnessMap(this.currentTime)}get witnessMapCredit(){return this.witnessMapImageryCredit}get witnessMapFooterLine(){return this.witnessMapImageryFailed?this.messages.mapImageryUnavailable:this.creditShownExternally?void 0:this.witnessMapImageryCredit}keepWitnessMapClear(t){if(this.witnessMapPanel.hidden)return;const e=this.witnessMapBoxPx;if(!e)return;const s=(o,h,l)=>{for(const[d,c]of t)if(!(this.occludedSourceIds.has(d)||c.transparency>=1)&&!(c.bounds.x+c.bounds.width<o-l||c.bounds.x>h+l)&&!(c.bounds.y>e.bottom+l||c.bounds.y+c.bounds.height<e.top-l))return!0;return!1},i=[this.canvas.width-e.width,this.canvas.width],r=[0,e.width],a=x.WITNESS_MAP_CLEARANCE_PX;if(this.witnessMapPanel.classList.contains("on-the-left")){s(i[0],i[1],a)||this.witnessMapPanel.classList.remove("on-the-left");return}s(i[0],i[1],0)&&!s(r[0],r[1],0)&&this.witnessMapPanel.classList.add("on-the-left")}witnessMapBoxPx;static WITNESS_MAP_CLEARANCE_PX=24;sizeWitnessMapCanvas(){const t=this.witnessMapPanel.clientWidth;if(t===0)return;const e=Math.round(t*(globalThis.devicePixelRatio??1));this.measureWitnessMapBox(),this.witnessMapCanvas.width!==e&&(this.witnessMapCanvas.width=e,this.witnessMapCanvas.height=e)}measureWitnessMapBox(){const t=this.witnessMapPanel.getBoundingClientRect(),e=this.canvas.getBoundingClientRect();if(e.width===0||e.height===0)return;const s=this.canvas.width/e.width,i=this.canvas.height/e.height;this.witnessMapBoxPx={width:t.width*s,top:(t.top-e.top)*i,bottom:(t.bottom-e.top)*i}}paintWitnessMap(t){if(this.witnessMapPanel.hidden||!this.witnessPath||!this.witnessMapBounds)return;const e=T(this.currentSighting,t),s=this.currentSighting.instrument,i=[],r=this.currentSighting.milestones.length>0?pt(this.currentSighting.milestones,t):void 0;for(const a of this.milestonesShown?Y(this.currentSighting.milestones):[]){const o=T(this.currentSighting,a.t);o?.lat===void 0||o.lng===void 0||i.push({label:this.said.read(a.label)??"",note:this.said.read(a.note),t:a.t,lat:o.lat,lng:o.lng,current:a===r})}this.witnessMapRenderer.paint({bounds:this.witnessMapBounds,imagery:this.witnessMapImagery,path:this.witnessPath,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?I.of(s,this.canvas.height,e.fovDeg).halfWidthAngleDeg(b.aspectOf(s)):void 0,markers:i,decor:this.witnessMapDecorAt(t),witnessLabel:this.said.read(this.currentSighting.witness?.title)??this.messages.witnessHere,nightFraction:this.witnessMapNightFraction,attribution:this.witnessMapFooterLine})}toggleMilestones(){this.setMilestonesShown(!this.milestonesShown)}setMilestonesShown(t){this.milestonesShown=t,this.milestoneMarks.hidden=!t,this.milestonesButton.setAttribute("aria-pressed",String(t)),this.updateMilestonesButton(),this.showMilestoneAt(this.currentTime),this.paintWitnessMap(this.currentTime)}updateMilestonesButton(){this.milestonesButton.hidden=this.currentSighting.milestones.length===0;const t=this.milestonesShown?this.messages.hideMilestones:this.messages.showMilestones;this.milestonesButton.title=t,this.milestonesButton.setAttribute("aria-label",t)}witnessMapDecorAt(t){const e=T(this.currentSighting,0);return e?.lat===void 0||e.lng===void 0?[]:this.currentSighting.decor.filter(s=>s.kind!=="crop").map(s=>{const i=Se(s,t),{lat:r,lng:a}=L(i.eastM,-i.northM,e.lat,e.lng);return{lat:r,lng:a,headingDeg:i.headingDeg,label:this.said.read(s.title)??this.messages.decorHere}})}witnessMapNightFraction;setSunAltitude(t){const e=t===void 0?void 0:Math.max(0,Math.min(1,-t/12));e!==this.witnessMapNightFraction&&(this.witnessMapNightFraction=e,this.paintWitnessMap(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,s=this.lookPitchDeg+t.pitchDeg;if(e===0&&s===0)return{x:0,y:0};const i=T(this.currentSighting,this.currentTime),r=I.of(this.currentSighting.instrument,this.canvas.height,i?.fovDeg??60);return{x:-r.angleDegToRadiusPx(e),y:r.angleDegToRadiusPx(s)}}gaitAt(t){return g.of(this.currentSighting)?.offsetAt(t)??g.STILL}updateFullscreenButton(){const t=this.simulatedFullscreen||document.fullscreenElement===this.fullscreenTarget;this.fullscreenButton.title=t?this.messages.exitFullscreen:this.messages.fullscreen,this.fullscreenButton.setAttribute("aria-label",this.fullscreenButton.title)}get said(){return this.saidTexts??=new P(mt.preferencesFor(this))}saidTexts;async loadLocaleMessages(){const t=ge(mt.preferencesFor(this),be);t!=="en"&&this.applyMessages(await xe(t))}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;for(const s of[this.timeStartLabel,this.timeEndLabel])s.classList.toggle("switchable",this.canSwitchTimeDisplay),this.canSwitchTimeDisplay?(s.setAttribute("role","button"),s.setAttribute("tabindex","0")):(s.removeAttribute("role"),s.removeAttribute("tabindex"))}applyMessages(t){this.messages=t,this.updateTimeLabelTitles(),this.loopButton.title=t.autoReplay,this.loopButton.setAttribute("aria-label",t.autoReplay),this.updatePlayPauseButton(),this.updateFullscreenButton(),this.updateWitnessMapButton(),this.updateMilestonesButton()}updateTimeLabels(){const t=this.currentSighting.event,e=qt(t);this.realDurationMs=e!==void 0&&e>0?e:void 0,this.realStartMs=t.time?it(t.time):void 0;const s=this.currentSighting.timeline.duration;this.player.playbackRate=this.realDurationMs!==void 0&&s>0?s/this.realDurationMs:1,this.player.durationOverrideMs=s>0?0:this.realDurationMs??0,this.timeEndLabel.textContent=this.formatEndOfTimeline(),this.timeStartLabel.textContent=this.formatPosition(this.player.time),this.updateTimeLabelTitles()}formatPosition(t){if(this.realDurationMs===void 0)return V(t);const e=this.currentSighting.timeline.duration,s=e>0&&t<=e?t/e*this.realDurationMs:t;return this.canShowClockTime?St(Mt(this.realStartMs+s)):V(s)}formatEndOfTimeline(){return this.realDurationMs===void 0?V(this.currentSighting.timeline.duration):this.canShowClockTime?St(Mt(this.realStartMs+this.realDurationMs)):V(this.realDurationMs)}}function Mt(n){const t=new Date(n);return{hour:t.getUTCHours(),minute:t.getUTCMinutes(),second:t.getUTCSeconds()}}function St(n){if(n.hour===void 0)return"0:00";const t=e=>String(e).padStart(2,"0");return n.second?`${t(n.hour)}:${t(n.minute??0)}:${t(n.second)}`:`${t(n.hour)}:${t(n.minute??0)}`}function V(n){const t=Math.round(n/1e3),e=Math.floor(t/60),s=t%60;return`${e}:${String(s).padStart(2,"0")}`}const kt="rr0-ufo";function Ne(){customElements.get(kt)||customElements.define(kt,x)}Ne();
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rr0/ufoathome",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.51.0",
|
|
5
5
|
"description": "UFO@home — record and replay a UFO sighting's shape, movement and appearance",
|
|
6
6
|
"author": "Jérôme Beau <rr0@rr0.org> (https://rr0.org)",
|
|
7
7
|
"license": "MIT",
|
|
@@ -33,12 +33,12 @@
|
|
|
33
33
|
"build:embed-ufo": "tsc --noEmit && vite build --config vite.embed-ufo.config.ts",
|
|
34
34
|
"build:embed-scene": "tsc --noEmit && vite build --config vite.embed-scene.config.ts",
|
|
35
35
|
"build:embed-sighting": "tsc --noEmit && vite build --config vite.embed-sighting.config.ts",
|
|
36
|
-
"build:all": "npm run build && npm run build:embed-sighting-editor && npm run build:embed-ufo && npm run build:embed-scene && npm run build:embed-sighting",
|
|
36
|
+
"build:all": "npm run build:schema && npm run build && npm run build:embed-sighting-editor && npm run build:embed-ufo && npm run build:embed-scene && npm run build:embed-sighting",
|
|
37
37
|
"build:site": "npm run build:schema && npm run build:embed-sighting-editor && npm run build:embed-ufo && npm run build:embed-scene && npm run build:embed-sighting && vite build --config vite.site.config.ts && tsx site/build.ts",
|
|
38
38
|
"site": "tsx site/build.ts",
|
|
39
39
|
"site:watch": "node --watch-path=./site --watch-path=./public/demo-data --import tsx site/build.ts",
|
|
40
40
|
"site:serve": "vite preview --outDir dist-site --port 5181 --strictPort",
|
|
41
|
-
"prepublishOnly": "npm run build:embed-sighting-editor && npm run build:embed-ufo && npm run build:embed-scene && npm run build:embed-sighting && npm test",
|
|
41
|
+
"prepublishOnly": "npm run build:schema && npm run build:embed-sighting-editor && npm run build:embed-ufo && npm run build:embed-scene && npm run build:embed-sighting && npm test",
|
|
42
42
|
"preview": "vite preview",
|
|
43
43
|
"test": "vitest run",
|
|
44
44
|
"test:watch": "vitest",
|
|
@@ -48,9 +48,10 @@
|
|
|
48
48
|
"build:schema": "tsx scripts/build-sighting-schema.ts",
|
|
49
49
|
"sync:cases": "tsx scripts/sync-case-recordings.ts",
|
|
50
50
|
"pretest": "npm run build:schema",
|
|
51
|
-
"build:embed-sighting-editor": "tsc --noEmit && vite build --config vite.embed-sighting-editor.config.ts"
|
|
51
|
+
"build:embed-sighting-editor": "npm run build:schema && tsc --noEmit && vite build --config vite.embed-sighting-editor.config.ts"
|
|
52
52
|
},
|
|
53
53
|
"dependencies": {
|
|
54
|
+
"@anthropic-ai/sdk": "^0.124.0",
|
|
54
55
|
"@rr0/data": "^0.3.41",
|
|
55
56
|
"@rr0/place": "^0.5.4",
|
|
56
57
|
"@rr0/time": "^0.11.2",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
const e={color:"Couleur",transparency:"Transparence",halo:"Halo",blur:"Flou",brightness:"Éclat",shapeTitle:"Nom",utcOffset:"Fuseau horaire",cloudBase:"Base des nuages",elevation:"Altitude",heightAboveGround:"Hauteur au-dessus du sol",duration:"Durée",placeName:"Lieu",latitude:"Latitude",longitude:"Longitude",heading:"Orientation",pitch:"Inclinaison",roll:"Roulis",observationTime:"Début de l'observation",observationEndTime:"Fin de l'observation",witnessGroup:"Témoin",witnessId:"ID témoin",witnessTitle:"Titre du témoin",witnessLastName:"Nom de famille du témoin",witnessFirstNames:"Prénoms du témoin",caseId:"ID de l'affaire",tags:"Mots-clés",cloudCover:"Couverture nuageuse",highCloudCover:"Nuages de glace (cirrus)",focalLength:"Focale",fieldOfView:"Champ de vision",aperture:"Diaphragme",exposure:"Temps de pose",focusDistance:"Mise au point à",iceCrystalAlignment:"Alignement des cristaux",cloudDarkness:"Obscurité des nuages",precipitationType:"Précipitations",precipitationNone:"Aucune",precipitationRain:"Pluie",precipitationSnow:"Neige",precipitationHail:"Grêle",precipitationIntensity:"Intensité",windDirection:"Direction du vent",windSpeed:"Force du vent",storm:"Orage",soundKind:"Son",soundNone:"Aucun (silencieux)",soundHum:"Bourdonnement",soundWhistle:"Sifflement",soundRumble:"Grondement",soundCrackle:"Crépitement",soundVolume:"Intensité sonore",soundPitch:"Hauteur",soundSrc:"Enregistrement",instrument:"Observé avec",decorAircraft:"Aéronef",decorAltitude:"Altitude",decorLights:"Feux",decorLightsNone:"aucun",decor:"Environnement",decorBuilding:"Bâtiment",decorTree:"Arbre",decorStreetlight:"Lampadaire",decorVehicle:"Véhicule",decorWitness:"Autre témoin",decorEast:"Distance à l'est",decorNorth:"Distance au nord",decorHeading:"Orientation",decorLit:"Allumé",decorTitle:"Nom",milestones:"Moments",milestoneLabel:"Repère",milestoneNote:"Ce qui se passe",addMilestone:"Nommer cet instant",deleteMilestone:"Supprimer le moment",confirmAccept:"Supprimer",confirmDecline:"Annuler",decorWidth:"Largeur",decorLength:"Longueur",decorHeight:"Hauteur",decorModel:"Modèle 3D",decorModelNone:"Forme intégrée",decorModelAdvanced:"Modèle depuis une adresse",decorModelUrl:"Adresse glTF/GLB",decorModelTitle:"Nom du modèle",decorModelAuthor:"Auteur",decorModelLicense:"Licence",decorModelSource:"Provenance",decorFloors:"Étages",decorOccupiedFloor:"Étage occupé",decorWitnessSide:"Emplacement du témoin",decorWitnessSideNone:"Non présent",decorWindows:"Fenêtres",decorSideFront:"Avant",decorSideBehind:"Arrière",decorSideLeft:"Gauche",decorSideRight:"Droite",decorSideFrontLeft:"Avant-gauche",decorSideFrontRight:"Avant-droit",decorSideBehindLeft:"Arrière-gauche",decorSideBehindRight:"Arrière-droit"},i={...e,testimonyBy:"Témoignage de",unnamedWitness:"Témoin {n}",about:"À propos",close:"Fermer",observation:"Observation",date:"Date",location:"Lieu",case:"Dossier",description:"Description",credits:"Crédits",editThisObservation:"Éditer cette observation",embed:"Intégrer",embedReplay:"Relecture",embedEdit:"Édition",embedCopy:"Copier",embedCopied:"Copié",showLabels:"Afficher ce qu'elle indique",hideLabels:"Masquer ce qu'elle indique"};export{i as sightingMessages_fr};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{T as Le,a as Q,b as he,L as Se,c as v,F as de,M as w,V as pe,C as F,d as b,S as U,e as ye,P as we,D as be,f as B,I as Ne,g as C,Q as me,h as Ie,O as ge,i as Oe,j as Ce,B as V,k as Fe,l as Te,N as Pe,m as ke,n as He,o as J,p as Re,R as Z,q as De,r as Ge,s as ve,t as X,u as Ue,v as Ee,w as Be,x as G,y as Ke,z as je,A as Ve,E as Xe,G as ze,H as qe,J as We,K as Ye,U as z,W as Qe,X as Je,Y as Ze,Z as $e,_ as en,$ as nn,a0 as tn,a1 as xe,a2 as sn,a3 as ne,a4 as te,a5 as se,a6 as ie,a7 as re,a8 as rn,a9 as on,aa as an,ab as cn}from"./rr0-sighting-editor.mjs";function oe(f,n){if(n===Le)return console.warn("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Geometry already defined as triangles."),f;if(n===Q||n===he){let e=f.getIndex();if(e===null){const r=[],a=f.getAttribute("position");if(a!==void 0){for(let o=0;o<a.count;o++)r.push(o);f.setIndex(r),e=f.getIndex()}else return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Undefined position attribute. Processing not possible."),f}const s=e.count-2,t=[];if(n===Q)for(let r=1;r<=s;r++)t.push(e.getX(0)),t.push(e.getX(r)),t.push(e.getX(r+1));else for(let r=0;r<s;r++)r%2===0?(t.push(e.getX(r)),t.push(e.getX(r+1)),t.push(e.getX(r+2))):(t.push(e.getX(r+2)),t.push(e.getX(r+1)),t.push(e.getX(r)));t.length/3!==s&&console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unable to generate correct amount of triangles.");const i=f.clone();return i.setIndex(t),i.clearGroups(),i}else return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unknown draw mode:",n),f}function un(f){const n=new Map,e=new Map,s=f.clone();return Ae(f,s,function(t,i){n.set(i,t),e.set(t,i)}),s.traverse(function(t){if(!t.isSkinnedMesh)return;const i=t,r=n.get(t),a=r.skeleton.bones;i.skeleton=r.skeleton.clone(),i.bindMatrix.copy(r.bindMatrix),i.skeleton.bones=a.map(function(o){return e.get(o)}),i.bind(i.skeleton,i.bindMatrix)}),s}function Ae(f,n,e){e(f,n);for(let s=0;s<f.children.length;s++)Ae(f.children[s],n.children[s],e)}class Vn extends Se{constructor(n){super(n),this.dracoLoader=null,this.ktx2Loader=null,this.meshoptDecoder=null,this.pluginCallbacks=[],this.register(function(e){return new pn(e)}),this.register(function(e){return new mn(e)}),this.register(function(e){return new Ln(e)}),this.register(function(e){return new Sn(e)}),this.register(function(e){return new yn(e)}),this.register(function(e){return new Tn(e)}),this.register(function(e){return new Rn(e)}),this.register(function(e){return new En(e)}),this.register(function(e){return new xn(e)}),this.register(function(e){return new dn(e)}),this.register(function(e){return new An(e)}),this.register(function(e){return new gn(e)}),this.register(function(e){return new Mn(e)}),this.register(function(e){return new _n(e)}),this.register(function(e){return new fn(e)}),this.register(function(e){return new ae(e,g.EXT_MESHOPT_COMPRESSION)}),this.register(function(e){return new ae(e,g.KHR_MESHOPT_COMPRESSION)}),this.register(function(e){return new wn(e)})}load(n,e,s,t){const i=this;let r;if(this.resourcePath!=="")r=this.resourcePath;else if(this.path!==""){const c=v.extractUrlBase(n);r=v.resolveURL(c,this.path)}else r=v.extractUrlBase(n);this.manager.itemStart(n);const a=function(c){t?t(c):console.error(c),i.manager.itemError(n),i.manager.itemEnd(n)},o=new de(this.manager);o.setPath(this.path),o.setResponseType("arraybuffer"),o.setRequestHeader(this.requestHeader),o.setWithCredentials(this.withCredentials),o.load(n,function(c){try{i.parse(c,r,function(u){e(u),i.manager.itemEnd(n)},a)}catch(u){a(u)}},s,a)}setDRACOLoader(n){return this.dracoLoader=n,this}setKTX2Loader(n){return this.ktx2Loader=n,this}setMeshoptDecoder(n){return this.meshoptDecoder=n,this}register(n){return this.pluginCallbacks.indexOf(n)===-1&&this.pluginCallbacks.push(n),this}unregister(n){return this.pluginCallbacks.indexOf(n)!==-1&&this.pluginCallbacks.splice(this.pluginCallbacks.indexOf(n),1),this}parse(n,e,s,t){let i;const r={},a={},o=new TextDecoder;if(typeof n=="string")i=JSON.parse(n);else if(n instanceof ArrayBuffer)if(o.decode(new Uint8Array(n,0,4))===_e){try{r[g.KHR_BINARY_GLTF]=new bn(n)}catch(l){t&&t(l);return}i=JSON.parse(r[g.KHR_BINARY_GLTF].content)}else i=JSON.parse(o.decode(n));else i=n;if(i.asset===void 0||i.asset.version[0]<2){t&&t(new Error("THREE.GLTFLoader: Unsupported asset. glTF versions >=2.0 are supported."));return}const c=new Bn(i,{path:e||this.resourcePath||"",crossOrigin:this.crossOrigin,requestHeader:this.requestHeader,manager:this.manager,ktx2Loader:this.ktx2Loader,meshoptDecoder:this.meshoptDecoder});c.fileLoader.setRequestHeader(this.requestHeader);for(let u=0;u<this.pluginCallbacks.length;u++){const l=this.pluginCallbacks[u](c);l.name||console.error("THREE.GLTFLoader: Invalid plugin found: missing name"),a[l.name]=l,r[l.name]=!0}if(i.extensionsUsed)for(let u=0;u<i.extensionsUsed.length;++u){const l=i.extensionsUsed[u],h=i.extensionsRequired||[];switch(l){case g.KHR_MATERIALS_UNLIT:r[l]=new hn;break;case g.KHR_DRACO_MESH_COMPRESSION:r[l]=new Nn(i,this.dracoLoader);break;case g.KHR_TEXTURE_TRANSFORM:r[l]=new In;break;case g.KHR_MESH_QUANTIZATION:r[l]=new On;break;default:h.indexOf(l)>=0&&a[l]===void 0&&console.warn('THREE.GLTFLoader: Unknown extension "'+l+'".')}}c.setExtensions(r),c.setPlugins(a),c.parse(s,t)}parseAsync(n,e){const s=this;return new Promise(function(t,i){s.parse(n,e,t,i)})}}function ln(){let f={};return{get:function(n){return f[n]},add:function(n,e){f[n]=e},remove:function(n){delete f[n]},removeAll:function(){f={}}}}function _(f,n,e){const s=f.json.materials[n];return s.extensions&&s.extensions[e]?s.extensions[e]:null}const g={KHR_BINARY_GLTF:"KHR_binary_glTF",KHR_DRACO_MESH_COMPRESSION:"KHR_draco_mesh_compression",KHR_LIGHTS_PUNCTUAL:"KHR_lights_punctual",KHR_MATERIALS_CLEARCOAT:"KHR_materials_clearcoat",KHR_MATERIALS_DISPERSION:"KHR_materials_dispersion",KHR_MATERIALS_IOR:"KHR_materials_ior",KHR_MATERIALS_SHEEN:"KHR_materials_sheen",KHR_MATERIALS_SPECULAR:"KHR_materials_specular",KHR_MATERIALS_TRANSMISSION:"KHR_materials_transmission",KHR_MATERIALS_IRIDESCENCE:"KHR_materials_iridescence",KHR_MATERIALS_ANISOTROPY:"KHR_materials_anisotropy",KHR_MATERIALS_UNLIT:"KHR_materials_unlit",KHR_MATERIALS_VOLUME:"KHR_materials_volume",KHR_TEXTURE_BASISU:"KHR_texture_basisu",KHR_TEXTURE_TRANSFORM:"KHR_texture_transform",KHR_MESH_QUANTIZATION:"KHR_mesh_quantization",KHR_MATERIALS_EMISSIVE_STRENGTH:"KHR_materials_emissive_strength",EXT_MATERIALS_BUMP:"EXT_materials_bump",EXT_TEXTURE_WEBP:"EXT_texture_webp",EXT_TEXTURE_AVIF:"EXT_texture_avif",EXT_MESHOPT_COMPRESSION:"EXT_meshopt_compression",KHR_MESHOPT_COMPRESSION:"KHR_meshopt_compression",EXT_MESH_GPU_INSTANCING:"EXT_mesh_gpu_instancing"};class fn{constructor(n){this.parser=n,this.name=g.KHR_LIGHTS_PUNCTUAL,this.cache={refs:{},uses:{}}}_markDefs(){const n=this.parser,e=this.parser.json.nodes||[];for(let s=0,t=e.length;s<t;s++){const i=e[s];i.extensions&&i.extensions[this.name]&&i.extensions[this.name].light!==void 0&&n._addNodeRef(this.cache,i.extensions[this.name].light)}}_loadLight(n){const e=this.parser,s="light:"+n;let t=e.cache.get(s);if(t)return t;const i=e.json,o=((i.extensions&&i.extensions[this.name]||{}).lights||[])[n];let c;const u=new F(16777215);o.color!==void 0&&u.setRGB(o.color[0],o.color[1],o.color[2],b);const l=o.range!==void 0?o.range:0;switch(o.type){case"directional":c=new be(u),c.target.position.set(0,0,-1),c.add(c.target);break;case"point":c=new we(u),c.distance=l;break;case"spot":c=new ye(u),c.distance=l,o.spot=o.spot||{},o.spot.innerConeAngle=o.spot.innerConeAngle!==void 0?o.spot.innerConeAngle:0,o.spot.outerConeAngle=o.spot.outerConeAngle!==void 0?o.spot.outerConeAngle:Math.PI/4,c.angle=o.spot.outerConeAngle,c.penumbra=1-o.spot.innerConeAngle/o.spot.outerConeAngle,c.target.position.set(0,0,-1),c.add(c.target);break;default:throw new Error("THREE.GLTFLoader: Unexpected light type: "+o.type)}return c.position.set(0,0,0),y(c,o),o.intensity!==void 0&&(c.intensity=o.intensity),c.name=e.createUniqueName(o.name||"light_"+n),t=Promise.resolve(c),e.cache.add(s,t),t}getDependency(n,e){if(n==="light")return this._loadLight(e)}createNodeAttachment(n){const e=this,s=this.parser,i=s.json.nodes[n],a=(i.extensions&&i.extensions[this.name]||{}).light;return a===void 0?null:this._loadLight(a).then(function(o){return s._getNodeRef(e.cache,a,o)})}}class hn{constructor(){this.name=g.KHR_MATERIALS_UNLIT}getMaterialType(){return G}extendParams(n,e,s){const t=[];n.color=new F(1,1,1),n.opacity=1;const i=e.pbrMetallicRoughness;if(i){if(Array.isArray(i.baseColorFactor)){const r=i.baseColorFactor;n.color.setRGB(r[0],r[1],r[2],b),n.opacity=r[3]}i.baseColorTexture!==void 0&&t.push(s.assignTexture(n,"map",i.baseColorTexture,U))}return Promise.all(t)}}class dn{constructor(n){this.parser=n,this.name=g.KHR_MATERIALS_EMISSIVE_STRENGTH}extendMaterialParams(n,e){const s=_(this.parser,n,this.name);return s===null||s.emissiveStrength!==void 0&&(e.emissiveIntensity=s.emissiveStrength),Promise.resolve()}}class pn{constructor(n){this.parser=n,this.name=g.KHR_MATERIALS_CLEARCOAT}getMaterialType(n){return _(this.parser,n,this.name)!==null?w:null}extendMaterialParams(n,e){const s=_(this.parser,n,this.name);if(s===null)return Promise.resolve();const t=[];if(s.clearcoatFactor!==void 0&&(e.clearcoat=s.clearcoatFactor),s.clearcoatTexture!==void 0&&t.push(this.parser.assignTexture(e,"clearcoatMap",s.clearcoatTexture)),s.clearcoatRoughnessFactor!==void 0&&(e.clearcoatRoughness=s.clearcoatRoughnessFactor),s.clearcoatRoughnessTexture!==void 0&&t.push(this.parser.assignTexture(e,"clearcoatRoughnessMap",s.clearcoatRoughnessTexture)),s.clearcoatNormalTexture!==void 0&&(t.push(this.parser.assignTexture(e,"clearcoatNormalMap",s.clearcoatNormalTexture)),s.clearcoatNormalTexture.scale!==void 0)){const i=s.clearcoatNormalTexture.scale;e.clearcoatNormalScale=new pe(i,i)}return Promise.all(t)}}class mn{constructor(n){this.parser=n,this.name=g.KHR_MATERIALS_DISPERSION}getMaterialType(n){return _(this.parser,n,this.name)!==null?w:null}extendMaterialParams(n,e){const s=_(this.parser,n,this.name);return s===null||(e.dispersion=s.dispersion!==void 0?s.dispersion:0),Promise.resolve()}}class gn{constructor(n){this.parser=n,this.name=g.KHR_MATERIALS_IRIDESCENCE}getMaterialType(n){return _(this.parser,n,this.name)!==null?w:null}extendMaterialParams(n,e){const s=_(this.parser,n,this.name);if(s===null)return Promise.resolve();const t=[];return s.iridescenceFactor!==void 0&&(e.iridescence=s.iridescenceFactor),s.iridescenceTexture!==void 0&&t.push(this.parser.assignTexture(e,"iridescenceMap",s.iridescenceTexture)),s.iridescenceIor!==void 0&&(e.iridescenceIOR=s.iridescenceIor),e.iridescenceThicknessRange===void 0&&(e.iridescenceThicknessRange=[100,400]),s.iridescenceThicknessMinimum!==void 0&&(e.iridescenceThicknessRange[0]=s.iridescenceThicknessMinimum),s.iridescenceThicknessMaximum!==void 0&&(e.iridescenceThicknessRange[1]=s.iridescenceThicknessMaximum),s.iridescenceThicknessTexture!==void 0&&t.push(this.parser.assignTexture(e,"iridescenceThicknessMap",s.iridescenceThicknessTexture)),Promise.all(t)}}class Tn{constructor(n){this.parser=n,this.name=g.KHR_MATERIALS_SHEEN}getMaterialType(n){return _(this.parser,n,this.name)!==null?w:null}extendMaterialParams(n,e){const s=_(this.parser,n,this.name);if(s===null)return Promise.resolve();const t=[];if(e.sheenColor=new F(0,0,0),e.sheenRoughness=0,e.sheen=1,s.sheenColorFactor!==void 0){const i=s.sheenColorFactor;e.sheenColor.setRGB(i[0],i[1],i[2],b)}return s.sheenRoughnessFactor!==void 0&&(e.sheenRoughness=s.sheenRoughnessFactor),s.sheenColorTexture!==void 0&&t.push(this.parser.assignTexture(e,"sheenColorMap",s.sheenColorTexture,U)),s.sheenRoughnessTexture!==void 0&&t.push(this.parser.assignTexture(e,"sheenRoughnessMap",s.sheenRoughnessTexture)),Promise.all(t)}}class Rn{constructor(n){this.parser=n,this.name=g.KHR_MATERIALS_TRANSMISSION}getMaterialType(n){return _(this.parser,n,this.name)!==null?w:null}extendMaterialParams(n,e){const s=_(this.parser,n,this.name);if(s===null)return Promise.resolve();const t=[];return s.transmissionFactor!==void 0&&(e.transmission=s.transmissionFactor),s.transmissionTexture!==void 0&&t.push(this.parser.assignTexture(e,"transmissionMap",s.transmissionTexture)),Promise.all(t)}}class En{constructor(n){this.parser=n,this.name=g.KHR_MATERIALS_VOLUME}getMaterialType(n){return _(this.parser,n,this.name)!==null?w:null}extendMaterialParams(n,e){const s=_(this.parser,n,this.name);if(s===null)return Promise.resolve();const t=[];e.thickness=s.thicknessFactor!==void 0?s.thicknessFactor:0,s.thicknessTexture!==void 0&&t.push(this.parser.assignTexture(e,"thicknessMap",s.thicknessTexture)),e.attenuationDistance=s.attenuationDistance||1/0;const i=s.attenuationColor||[1,1,1];return e.attenuationColor=new F().setRGB(i[0],i[1],i[2],b),Promise.all(t)}}class xn{constructor(n){this.parser=n,this.name=g.KHR_MATERIALS_IOR}getMaterialType(n){return _(this.parser,n,this.name)!==null?w:null}extendMaterialParams(n,e){const s=_(this.parser,n,this.name);return s===null||(e.ior=s.ior!==void 0?s.ior:1.5,e.ior===0&&(e.ior=1e3)),Promise.resolve()}}class An{constructor(n){this.parser=n,this.name=g.KHR_MATERIALS_SPECULAR}getMaterialType(n){return _(this.parser,n,this.name)!==null?w:null}extendMaterialParams(n,e){const s=_(this.parser,n,this.name);if(s===null)return Promise.resolve();const t=[];e.specularIntensity=s.specularFactor!==void 0?s.specularFactor:1,s.specularTexture!==void 0&&t.push(this.parser.assignTexture(e,"specularIntensityMap",s.specularTexture));const i=s.specularColorFactor||[1,1,1];return e.specularColor=new F().setRGB(i[0],i[1],i[2],b),s.specularColorTexture!==void 0&&t.push(this.parser.assignTexture(e,"specularColorMap",s.specularColorTexture,U)),Promise.all(t)}}class _n{constructor(n){this.parser=n,this.name=g.EXT_MATERIALS_BUMP}getMaterialType(n){return _(this.parser,n,this.name)!==null?w:null}extendMaterialParams(n,e){const s=_(this.parser,n,this.name);if(s===null)return Promise.resolve();const t=[];return e.bumpScale=s.bumpFactor!==void 0?s.bumpFactor:1,s.bumpTexture!==void 0&&t.push(this.parser.assignTexture(e,"bumpMap",s.bumpTexture)),Promise.all(t)}}class Mn{constructor(n){this.parser=n,this.name=g.KHR_MATERIALS_ANISOTROPY}getMaterialType(n){return _(this.parser,n,this.name)!==null?w:null}extendMaterialParams(n,e){const s=_(this.parser,n,this.name);if(s===null)return Promise.resolve();const t=[];return s.anisotropyStrength!==void 0&&(e.anisotropy=s.anisotropyStrength),s.anisotropyRotation!==void 0&&(e.anisotropyRotation=s.anisotropyRotation),s.anisotropyTexture!==void 0&&t.push(this.parser.assignTexture(e,"anisotropyMap",s.anisotropyTexture)),Promise.all(t)}}class Ln{constructor(n){this.parser=n,this.name=g.KHR_TEXTURE_BASISU}loadTexture(n){const e=this.parser,s=e.json,t=s.textures[n];if(!t.extensions||!t.extensions[this.name])return null;const i=t.extensions[this.name],r=e.options.ktx2Loader;if(!r){if(s.extensionsRequired&&s.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures");return null}return e.loadTextureImage(n,i.source,r)}}class Sn{constructor(n){this.parser=n,this.name=g.EXT_TEXTURE_WEBP}loadTexture(n){const e=this.name,s=this.parser,t=s.json,i=t.textures[n];if(!i.extensions||!i.extensions[e])return null;const r=i.extensions[e],a=t.images[r.source];let o=s.textureLoader;if(a.uri){const c=s.options.manager.getHandler(a.uri);c!==null&&(o=c)}return s.loadTextureImage(n,r.source,o)}}class yn{constructor(n){this.parser=n,this.name=g.EXT_TEXTURE_AVIF}loadTexture(n){const e=this.name,s=this.parser,t=s.json,i=t.textures[n];if(!i.extensions||!i.extensions[e])return null;const r=i.extensions[e],a=t.images[r.source];let o=s.textureLoader;if(a.uri){const c=s.options.manager.getHandler(a.uri);c!==null&&(o=c)}return s.loadTextureImage(n,r.source,o)}}class ae{constructor(n,e){this.name=e,this.parser=n}loadBufferView(n){const e=this.parser.json,s=e.bufferViews[n];if(s.extensions&&s.extensions[this.name]){const t=s.extensions[this.name],i=this.parser.getDependency("buffer",t.buffer),r=this.parser.options.meshoptDecoder;if(!r||!r.supported){if(e.extensionsRequired&&e.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setMeshoptDecoder must be called before loading compressed files");return null}return i.then(function(a){const o=t.byteOffset||0,c=t.byteLength||0,u=t.count,l=t.byteStride,h=new Uint8Array(a,o,c);return r.decodeGltfBufferAsync?r.decodeGltfBufferAsync(u,l,h,t.mode,t.filter).then(function(d){return d.buffer}):r.ready.then(function(){const d=new ArrayBuffer(u*l);return r.decodeGltfBuffer(new Uint8Array(d),u,l,h,t.mode,t.filter),d})})}else return null}}class wn{constructor(n){this.name=g.EXT_MESH_GPU_INSTANCING,this.parser=n}createNodeMesh(n){const e=this.parser.json,s=e.nodes[n];if(!s.extensions||!s.extensions[this.name]||s.mesh===void 0)return null;const t=e.meshes[s.mesh];for(const c of t.primitives)if(c.mode!==L.TRIANGLES&&c.mode!==L.TRIANGLE_STRIP&&c.mode!==L.TRIANGLE_FAN&&c.mode!==void 0)return null;const r=s.extensions[this.name].attributes,a=[],o={};for(const c in r)a.push(this.parser.getDependency("accessor",r[c]).then(u=>(o[c]=u,o[c])));return a.length<1?null:(a.push(this.parser.createNodeMesh(n)),Promise.all(a).then(c=>{const u=c.pop(),l=u.isGroup?u.children:[u],h=c[0].count,d=[];for(const p of l){const R=new B,m=new C,T=new me,A=new C(1,1,1),x=new Ne(p.geometry,p.material,h);for(let E=0;E<h;E++)o.TRANSLATION&&m.fromBufferAttribute(o.TRANSLATION,E),o.ROTATION&&T.fromBufferAttribute(o.ROTATION,E),o.SCALE&&A.fromBufferAttribute(o.SCALE,E),x.setMatrixAt(E,R.compose(m,T,A));for(const E in o)if(E==="_COLOR_0"){const M=o[E];x.instanceColor=new Ie(M.array,M.itemSize,M.normalized)}else E!=="TRANSLATION"&&E!=="ROTATION"&&E!=="SCALE"&&p.geometry.setAttribute(E,o[E]);ge.prototype.copy.call(x,p),this.parser.assignFinalMaterial(x),d.push(x)}return u.isGroup?(u.clear(),u.add(...d),u):d[0]}))}}const _e="glTF",D=12,ce={JSON:1313821514,BIN:5130562};class bn{constructor(n){this.name=g.KHR_BINARY_GLTF,this.content=null,this.body=null;const e=new DataView(n,0,D),s=new TextDecoder;if(this.header={magic:s.decode(new Uint8Array(n.slice(0,4))),version:e.getUint32(4,!0),length:e.getUint32(8,!0)},this.header.magic!==_e)throw new Error("THREE.GLTFLoader: Unsupported glTF-Binary header.");if(this.header.version<2)throw new Error("THREE.GLTFLoader: Legacy binary file detected.");const t=this.header.length-D,i=new DataView(n,D);let r=0;for(;r<t;){const a=i.getUint32(r,!0);r+=4;const o=i.getUint32(r,!0);if(r+=4,o===ce.JSON){const c=new Uint8Array(n,D+r,a);this.content=s.decode(c)}else if(o===ce.BIN){const c=D+r;this.body=n.slice(c,c+a)}r+=a}if(this.content===null)throw new Error("THREE.GLTFLoader: JSON content not found.")}}class Nn{constructor(n,e){if(!e)throw new Error("THREE.GLTFLoader: No DRACOLoader instance provided.");this.name=g.KHR_DRACO_MESH_COMPRESSION,this.json=n,this.dracoLoader=e,this.dracoLoader.preload()}decodePrimitive(n,e){const s=this.json,t=this.dracoLoader,i=n.extensions[this.name].bufferView,r=n.extensions[this.name].attributes,a={},o={},c={};for(const u in r){const l=$[u]||u.toLowerCase();a[l]=r[u]}for(const u in n.attributes){const l=$[u]||u.toLowerCase();if(r[u]!==void 0){const h=s.accessors[n.attributes[u]],d=k[h.componentType];c[l]=d.name,o[l]=h.normalized===!0}}return e.getDependency("bufferView",i).then(function(u){return new Promise(function(l,h){t.decodeDracoFile(u,function(d){for(const p in d.attributes){const R=d.attributes[p],m=o[p];m!==void 0&&(R.normalized=m)}l(d)},a,c,b,h)})})}}class In{constructor(){this.name=g.KHR_TEXTURE_TRANSFORM}extendTexture(n,e){return(e.texCoord===void 0||e.texCoord===n.channel)&&e.offset===void 0&&e.rotation===void 0&&e.scale===void 0||(n=n.clone(),e.texCoord!==void 0&&(n.channel=e.texCoord),e.offset!==void 0&&n.offset.fromArray(e.offset),e.rotation!==void 0&&(n.rotation=e.rotation),e.scale!==void 0&&n.repeat.fromArray(e.scale),n.needsUpdate=!0),n}}class On{constructor(){this.name=g.KHR_MESH_QUANTIZATION}}class Me extends on{constructor(n,e,s,t){super(n,e,s,t)}copySampleValue_(n){const e=this.resultBuffer,s=this.sampleValues,t=this.valueSize,i=n*t*3+t;for(let r=0;r!==t;r++)e[r]=s[i+r];return e}interpolate_(n,e,s,t){const i=this.resultBuffer,r=this.sampleValues,a=this.valueSize,o=a*2,c=a*3,u=t-e,l=(s-e)/u,h=l*l,d=h*l,p=n*c,R=p-c,m=-2*d+3*h,T=d-h,A=1-m,x=T-h+l;for(let E=0;E!==a;E++){const M=r[R+E+a],N=r[R+E+o]*u,S=r[p+E+a],H=r[p+E]*u;i[E]=A*M+x*N+m*S+T*H}return i}}const Cn=new me;class Fn extends Me{interpolate_(n,e,s,t){const i=super.interpolate_(n,e,s,t);return Cn.fromArray(i).normalize().toArray(i),i}}const L={POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6},k={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},ue={9728:Re,9729:J,9984:He,9985:ke,9986:Pe,9987:Te},le={33071:Ge,33648:De,10497:Z},q={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},$={POSITION:"position",NORMAL:"normal",TANGENT:"tangent",TEXCOORD_0:"uv",TEXCOORD_1:"uv1",TEXCOORD_2:"uv2",TEXCOORD_3:"uv3",COLOR_0:"color",WEIGHTS_0:"skinWeight",JOINTS_0:"skinIndex"},I={scale:"scale",translation:"position",rotation:"quaternion",weights:"morphTargetInfluences"},Pn={CUBICSPLINE:void 0,LINEAR:xe,STEP:tn},W={OPAQUE:"OPAQUE",MASK:"MASK",BLEND:"BLEND"};function kn(f){return f.DefaultMaterial===void 0&&(f.DefaultMaterial=new Ee({color:16777215,emissive:0,metalness:1,roughness:1,transparent:!1,depthTest:!0,side:rn})),f.DefaultMaterial}function O(f,n,e){for(const s in e.extensions)f[s]===void 0&&(n.userData.gltfExtensions=n.userData.gltfExtensions||{},n.userData.gltfExtensions[s]=e.extensions[s])}function y(f,n){n.extras!==void 0&&(typeof n.extras=="object"?Object.assign(f.userData,n.extras):console.warn("THREE.GLTFLoader: Ignoring primitive type .extras, "+n.extras))}function Hn(f,n,e){let s=!1,t=!1,i=!1;for(let c=0,u=n.length;c<u;c++){const l=n[c];if(l.POSITION!==void 0&&(s=!0),l.NORMAL!==void 0&&(t=!0),l.COLOR_0!==void 0&&(i=!0),s&&t&&i)break}if(!s&&!t&&!i)return Promise.resolve(f);const r=[],a=[],o=[];for(let c=0,u=n.length;c<u;c++){const l=n[c];if(s){const h=l.POSITION!==void 0?e.getDependency("accessor",l.POSITION):f.attributes.position;r.push(h)}if(t){const h=l.NORMAL!==void 0?e.getDependency("accessor",l.NORMAL):f.attributes.normal;a.push(h)}if(i){const h=l.COLOR_0!==void 0?e.getDependency("accessor",l.COLOR_0):f.attributes.color;o.push(h)}}return Promise.all([Promise.all(r),Promise.all(a),Promise.all(o)]).then(function(c){const u=c[0],l=c[1],h=c[2];return s&&(f.morphAttributes.position=u),t&&(f.morphAttributes.normal=l),i&&(f.morphAttributes.color=h),f.morphTargetsRelative=!0,f})}function Dn(f,n){if(f.updateMorphTargets(),n.weights!==void 0)for(let e=0,s=n.weights.length;e<s;e++)f.morphTargetInfluences[e]=n.weights[e];if(n.extras&&Array.isArray(n.extras.targetNames)){const e=n.extras.targetNames;if(f.morphTargetInfluences.length===e.length){f.morphTargetDictionary={};for(let s=0,t=e.length;s<t;s++)f.morphTargetDictionary[e[s]]=s}else console.warn("THREE.GLTFLoader: Invalid extras.targetNames length. Ignoring names.")}}function Gn(f){let n;const e=f.extensions&&f.extensions[g.KHR_DRACO_MESH_COMPRESSION];if(e?n="draco:"+e.bufferView+":"+e.indices+":"+Y(e.attributes):n=f.indices+":"+Y(f.attributes)+":"+f.mode,f.targets!==void 0)for(let s=0,t=f.targets.length;s<t;s++)n+=":"+Y(f.targets[s]);return n}function Y(f){let n="";const e=Object.keys(f).sort();for(let s=0,t=e.length;s<t;s++)n+=e[s]+":"+f[e[s]]+";";return n}function ee(f){switch(f){case Int8Array:return 1/127;case Uint8Array:return 1/255;case Int16Array:return 1/32767;case Uint16Array:return 1/65535;default:throw new Error("THREE.GLTFLoader: Unsupported normalized accessor component type.")}}function vn(f){return f.search(/\.jpe?g($|\?)/i)>0||f.search(/^data\:image\/jpeg/)===0?"image/jpeg":f.search(/\.webp($|\?)/i)>0||f.search(/^data\:image\/webp/)===0?"image/webp":f.search(/\.ktx2($|\?)/i)>0||f.search(/^data\:image\/ktx2/)===0?"image/ktx2":"image/png"}const Un=new B;class Bn{constructor(n={},e={}){this.json=n,this.extensions={},this.plugins={},this.options=e,this.cache=new ln,this.associations=new Map,this.primitiveCache={},this.nodeCache={},this.meshCache={refs:{},uses:{}},this.cameraCache={refs:{},uses:{}},this.lightCache={refs:{},uses:{}},this.sourceCache={},this.textureCache={},this.nodeNamesUsed={};let s=!1,t=-1,i=!1,r=-1;if(typeof navigator<"u"&&typeof navigator.userAgent<"u"){const a=navigator.userAgent;s=/^((?!chrome|android).)*safari/i.test(a)===!0;const o=a.match(/Version\/(\d+)/);t=s&&o?parseInt(o[1],10):-1,i=a.indexOf("Firefox")>-1,r=i?a.match(/Firefox\/([0-9]+)\./)[1]:-1}typeof createImageBitmap>"u"||s&&t<17||i&&r<98?this.textureLoader=new Oe(this.options.manager):this.textureLoader=new Ce(this.options.manager),this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new de(this.options.manager),this.fileLoader.setResponseType("arraybuffer"),this.options.crossOrigin==="use-credentials"&&this.fileLoader.setWithCredentials(!0)}setExtensions(n){this.extensions=n}setPlugins(n){this.plugins=n}parse(n,e){const s=this,t=this.json,i=this.extensions;this.cache.removeAll(),this.nodeCache={},this._invokeAll(function(r){return r._markDefs&&r._markDefs()}),Promise.all(this._invokeAll(function(r){return r.beforeRoot&&r.beforeRoot()})).then(function(){return Promise.all([s.getDependencies("scene"),s.getDependencies("animation"),s.getDependencies("camera")])}).then(function(r){const a={scene:r[0][t.scene||0],scenes:r[0],animations:r[1],cameras:r[2],asset:t.asset,parser:s,userData:{}};return O(i,a,t),y(a,t),Promise.all(s._invokeAll(function(o){return o.afterRoot&&o.afterRoot(a)})).then(function(){for(const o of a.scenes)o.updateMatrixWorld();n(a)})}).catch(e)}_markDefs(){const n=this.json.nodes||[],e=this.json.skins||[],s=this.json.meshes||[];for(let t=0,i=e.length;t<i;t++){const r=e[t].joints;for(let a=0,o=r.length;a<o;a++)n[r[a]].isBone=!0}for(let t=0,i=n.length;t<i;t++){const r=n[t];r.mesh!==void 0&&(this._addNodeRef(this.meshCache,r.mesh),r.skin!==void 0&&(s[r.mesh].isSkinnedMesh=!0)),r.camera!==void 0&&this._addNodeRef(this.cameraCache,r.camera)}}_addNodeRef(n,e){e!==void 0&&(n.refs[e]===void 0&&(n.refs[e]=n.uses[e]=0),n.refs[e]++)}_getNodeRef(n,e,s){if(n.refs[e]<=1)return s;const t=s.clone(),i=(r,a)=>{const o=this.associations.get(r);o!=null&&this.associations.set(a,o);for(const[c,u]of r.children.entries())i(u,a.children[c])};return i(s,t),t.name+="_instance_"+n.uses[e]++,t}_invokeOne(n){const e=Object.values(this.plugins);e.push(this);for(let s=0;s<e.length;s++){const t=n(e[s]);if(t)return t}return null}_invokeAll(n){const e=Object.values(this.plugins);e.unshift(this);const s=[];for(let t=0;t<e.length;t++){const i=n(e[t]);i&&s.push(i)}return s}getDependency(n,e){const s=n+":"+e;let t=this.cache.get(s);if(!t){switch(n){case"scene":t=this.loadScene(e);break;case"node":t=this._invokeOne(function(i){return i.loadNode&&i.loadNode(e)});break;case"mesh":t=this._invokeOne(function(i){return i.loadMesh&&i.loadMesh(e)});break;case"accessor":t=this.loadAccessor(e);break;case"bufferView":t=this._invokeOne(function(i){return i.loadBufferView&&i.loadBufferView(e)});break;case"buffer":t=this.loadBuffer(e);break;case"material":t=this._invokeOne(function(i){return i.loadMaterial&&i.loadMaterial(e)});break;case"texture":t=this._invokeOne(function(i){return i.loadTexture&&i.loadTexture(e)});break;case"skin":t=this.loadSkin(e);break;case"animation":t=this._invokeOne(function(i){return i.loadAnimation&&i.loadAnimation(e)});break;case"camera":t=this.loadCamera(e);break;default:if(t=this._invokeOne(function(i){return i!=this&&i.getDependency&&i.getDependency(n,e)}),!t)throw new Error("Unknown type: "+n);break}this.cache.add(s,t)}return t}getDependencies(n){let e=this.cache.get(n);if(!e){const s=this,t=this.json[n+(n==="mesh"?"es":"s")]||[];e=Promise.all(t.map(function(i,r){return s.getDependency(n,r)})),this.cache.add(n,e)}return e}loadBuffer(n){const e=this.json.buffers[n],s=this.fileLoader;if(e.type&&e.type!=="arraybuffer")throw new Error("THREE.GLTFLoader: "+e.type+" buffer type is not supported.");if(e.uri===void 0&&n===0)return Promise.resolve(this.extensions[g.KHR_BINARY_GLTF].body);const t=this.options;return new Promise(function(i,r){s.load(v.resolveURL(e.uri,t.path),i,void 0,function(){r(new Error('THREE.GLTFLoader: Failed to load buffer "'+e.uri+'".'))})})}loadBufferView(n){const e=this.json.bufferViews[n];return this.getDependency("buffer",e.buffer).then(function(s){const t=e.byteLength||0,i=e.byteOffset||0;return s.slice(i,i+t)})}loadAccessor(n){const e=this,s=this.json,t=this.json.accessors[n];if(t.bufferView===void 0&&t.sparse===void 0){const r=q[t.type],a=k[t.componentType],o=t.normalized===!0,c=new a(t.count*r);return Promise.resolve(new V(c,r,o))}const i=[];return t.bufferView!==void 0?i.push(this.getDependency("bufferView",t.bufferView)):i.push(null),t.sparse!==void 0&&(i.push(this.getDependency("bufferView",t.sparse.indices.bufferView)),i.push(this.getDependency("bufferView",t.sparse.values.bufferView))),Promise.all(i).then(function(r){const a=r[0],o=q[t.type],c=k[t.componentType],u=c.BYTES_PER_ELEMENT,l=u*o,h=t.byteOffset||0,d=t.bufferView!==void 0?s.bufferViews[t.bufferView].byteStride:void 0,p=t.normalized===!0;let R,m;if(d&&d!==l){const T=Math.floor(h/d),A="InterleavedBuffer:"+t.bufferView+":"+t.componentType+":"+T+":"+t.count;let x=e.cache.get(A);x||(R=new c(a,T*d,t.count*d/u),x=new Fe(R,d/u),e.cache.add(A,x)),m=new sn(x,o,h%d/u,p)}else a===null?R=new c(t.count*o):R=new c(a,h,t.count*o),m=new V(R,o,p);if(t.sparse!==void 0){const T=q.SCALAR,A=k[t.sparse.indices.componentType],x=t.sparse.indices.byteOffset||0,E=t.sparse.values.byteOffset||0,M=new A(r[1],x,t.sparse.count*T),N=new c(r[2],E,t.sparse.count*o);a!==null&&(m=new V(m.array.slice(),m.itemSize,m.normalized)),m.normalized=!1;for(let S=0,H=M.length;S<H;S++){const P=M[S];if(m.setX(P,N[S*o]),o>=2&&m.setY(P,N[S*o+1]),o>=3&&m.setZ(P,N[S*o+2]),o>=4&&m.setW(P,N[S*o+3]),o>=5)throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}m.normalized=p}return m})}loadTexture(n){const e=this.json,s=this.options,i=e.textures[n].source,r=e.images[i];let a=this.textureLoader;if(r.uri){const o=s.manager.getHandler(r.uri);o!==null&&(a=o)}return this.loadTextureImage(n,i,a)}loadTextureImage(n,e,s){const t=this,i=this.json,r=i.textures[n],a=i.images[e],o=(a.uri||a.bufferView)+":"+r.sampler;if(this.textureCache[o])return this.textureCache[o];const c=this.loadImageSource(e,s).then(function(u){u.flipY=!1,u.name=r.name||a.name||"",u.name===""&&typeof a.uri=="string"&&a.uri.startsWith("data:image/")===!1&&(u.name=a.uri);const h=(i.samplers||{})[r.sampler]||{};return u.magFilter=ue[h.magFilter]||J,u.minFilter=ue[h.minFilter]||Te,u.wrapS=le[h.wrapS]||Z,u.wrapT=le[h.wrapT]||Z,u.generateMipmaps=!u.isCompressedTexture&&u.minFilter!==Re&&u.minFilter!==J,t.associations.set(u,{textures:n}),u}).catch(function(){return null});return this.textureCache[o]=c,c}loadImageSource(n,e){const s=this,t=this.json,i=this.options;if(this.sourceCache[n]!==void 0)return this.sourceCache[n].then(l=>l.clone());const r=t.images[n],a=self.URL||self.webkitURL;let o=r.uri||"",c=!1;if(r.bufferView!==void 0)o=s.getDependency("bufferView",r.bufferView).then(function(l){c=!0;const h=new Blob([l],{type:r.mimeType});return o=a.createObjectURL(h),o});else if(r.uri===void 0)throw new Error("THREE.GLTFLoader: Image "+n+" is missing URI and bufferView");const u=Promise.resolve(o).then(function(l){return new Promise(function(h,d){let p=h;e.isImageBitmapLoader===!0&&(p=function(R){const m=new ne(R);m.needsUpdate=!0,h(m)}),e.load(v.resolveURL(l,i.path),p,void 0,d)})}).then(function(l){return c===!0&&a.revokeObjectURL(o),y(l,r),l.userData.mimeType=r.mimeType||vn(r.uri),l}).catch(function(l){throw console.error("THREE.GLTFLoader: Couldn't load texture",o),l});return this.sourceCache[n]=u,u}assignTexture(n,e,s,t){const i=this;return this.getDependency("texture",s.index).then(function(r){if(!r)return null;if(s.texCoord!==void 0&&s.texCoord>0&&(r=r.clone(),r.channel=s.texCoord),i.extensions[g.KHR_TEXTURE_TRANSFORM]){const a=s.extensions!==void 0?s.extensions[g.KHR_TEXTURE_TRANSFORM]:void 0;if(a){const o=i.associations.get(r);r=i.extensions[g.KHR_TEXTURE_TRANSFORM].extendTexture(r,a),i.associations.set(r,o)}}return t!==void 0&&(r.colorSpace=t),n[e]=r,r})}assignFinalMaterial(n){const e=n.geometry;let s=n.material;const t=e.attributes.tangent===void 0,i=e.attributes.color!==void 0,r=e.attributes.normal===void 0;if(n.isPoints){const a="PointsMaterial:"+s.uuid;let o=this.cache.get(a);o||(o=new ve,X.prototype.copy.call(o,s),o.color.copy(s.color),o.map=s.map,o.sizeAttenuation=!1,this.cache.add(a,o)),s=o}else if(n.isLine){const a="LineBasicMaterial:"+s.uuid;let o=this.cache.get(a);o||(o=new Ue,X.prototype.copy.call(o,s),o.color.copy(s.color),o.map=s.map,this.cache.add(a,o)),s=o}if(t||i||r){let a="ClonedMaterial:"+s.uuid+":";t&&(a+="derivative-tangents:"),i&&(a+="vertex-colors:"),r&&(a+="flat-shading:");let o=this.cache.get(a);o||(o=s.clone(),i&&(o.vertexColors=!0),r&&(o.flatShading=!0),t&&(o.normalScale&&(o.normalScale.y*=-1),o.clearcoatNormalScale&&(o.clearcoatNormalScale.y*=-1)),this.cache.add(a,o),this.associations.set(o,this.associations.get(s))),s=o}n.material=s}getMaterialType(){return Ee}loadMaterial(n){const e=this,s=this.json,t=this.extensions,i=s.materials[n];let r;const a={},o=i.extensions||{},c=[];if(o[g.KHR_MATERIALS_UNLIT]){const l=t[g.KHR_MATERIALS_UNLIT];r=l.getMaterialType(),c.push(l.extendParams(a,i,e))}else{const l=i.pbrMetallicRoughness||{};if(a.color=new F(1,1,1),a.opacity=1,Array.isArray(l.baseColorFactor)){const h=l.baseColorFactor;a.color.setRGB(h[0],h[1],h[2],b),a.opacity=h[3]}l.baseColorTexture!==void 0&&c.push(e.assignTexture(a,"map",l.baseColorTexture,U)),a.metalness=l.metallicFactor!==void 0?l.metallicFactor:1,a.roughness=l.roughnessFactor!==void 0?l.roughnessFactor:1,l.metallicRoughnessTexture!==void 0&&(c.push(e.assignTexture(a,"metalnessMap",l.metallicRoughnessTexture)),c.push(e.assignTexture(a,"roughnessMap",l.metallicRoughnessTexture))),r=this._invokeOne(function(h){return h.getMaterialType&&h.getMaterialType(n)}),c.push(Promise.all(this._invokeAll(function(h){return h.extendMaterialParams&&h.extendMaterialParams(n,a)})))}i.doubleSided===!0&&(a.side=Be);const u=i.alphaMode||W.OPAQUE;if(u===W.BLEND?(a.transparent=!0,a.depthWrite=!1):(a.transparent=!1,u===W.MASK&&(a.alphaTest=i.alphaCutoff!==void 0?i.alphaCutoff:.5)),i.normalTexture!==void 0&&r!==G&&(c.push(e.assignTexture(a,"normalMap",i.normalTexture)),a.normalScale=new pe(1,1),i.normalTexture.scale!==void 0)){const l=i.normalTexture.scale;a.normalScale.set(l,l)}if(i.occlusionTexture!==void 0&&r!==G&&(c.push(e.assignTexture(a,"aoMap",i.occlusionTexture)),i.occlusionTexture.strength!==void 0&&(a.aoMapIntensity=i.occlusionTexture.strength)),i.emissiveFactor!==void 0&&r!==G){const l=i.emissiveFactor;a.emissive=new F().setRGB(l[0],l[1],l[2],b)}return i.emissiveTexture!==void 0&&r!==G&&c.push(e.assignTexture(a,"emissiveMap",i.emissiveTexture,U)),Promise.all(c).then(function(){const l=new r(a);return i.name&&(l.name=i.name),y(l,i),e.associations.set(l,{materials:n}),i.extensions&&O(t,l,i),l})}createUniqueName(n){const e=Ke.sanitizeNodeName(n||"");return e in this.nodeNamesUsed?e+"_"+ ++this.nodeNamesUsed[e]:(this.nodeNamesUsed[e]=0,e)}loadGeometries(n){const e=this,s=this.extensions,t=this.primitiveCache;function i(a){return s[g.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(a,e).then(function(o){return fe(o,a,e)})}const r=[];for(let a=0,o=n.length;a<o;a++){const c=n[a],u=Gn(c),l=t[u];if(l)r.push(l.promise);else{let h;c.extensions&&c.extensions[g.KHR_DRACO_MESH_COMPRESSION]?h=i(c):h=fe(new je,c,e),t[u]={primitive:c,promise:h},r.push(h)}}return Promise.all(r)}loadMesh(n){const e=this,s=this.json,t=this.extensions,i=s.meshes[n],r=i.primitives,a=[];for(let o=0,c=r.length;o<c;o++){const u=r[o].material===void 0?kn(this.cache):this.getDependency("material",r[o].material);a.push(u)}return a.push(e.loadGeometries(r)),Promise.all(a).then(function(o){const c=o.slice(0,o.length-1),u=o[o.length-1],l=[];for(let d=0,p=u.length;d<p;d++){const R=u[d],m=r[d];let T;const A=c[d];if(m.mode===L.TRIANGLES||m.mode===L.TRIANGLE_STRIP||m.mode===L.TRIANGLE_FAN||m.mode===void 0)T=i.isSkinnedMesh===!0?new Ve(R,A):new Xe(R,A),T.isSkinnedMesh===!0&&T.normalizeSkinWeights(),m.mode===L.TRIANGLE_STRIP?T.geometry=oe(T.geometry,he):m.mode===L.TRIANGLE_FAN&&(T.geometry=oe(T.geometry,Q));else if(m.mode===L.LINES)T=new ze(R,A);else if(m.mode===L.LINE_STRIP)T=new qe(R,A);else if(m.mode===L.LINE_LOOP)T=new We(R,A);else if(m.mode===L.POINTS)T=new Ye(R,A);else throw new Error("THREE.GLTFLoader: Primitive mode unsupported: "+m.mode);Object.keys(T.geometry.morphAttributes).length>0&&Dn(T,i),T.name=e.createUniqueName(i.name||"mesh_"+n),y(T,i),m.extensions&&O(t,T,m),e.assignFinalMaterial(T),l.push(T)}for(let d=0,p=l.length;d<p;d++)e.associations.set(l[d],{meshes:n,primitives:d});if(l.length===1)return i.extensions&&O(t,l[0],i),l[0];const h=new z;i.extensions&&O(t,h,i),e.associations.set(h,{meshes:n});for(let d=0,p=l.length;d<p;d++)h.add(l[d]);return h})}loadCamera(n){let e;const s=this.json.cameras[n],t=s[s.type];if(!t){console.warn("THREE.GLTFLoader: Missing camera parameters.");return}return s.type==="perspective"?e=new Qe(Je.radToDeg(t.yfov),t.aspectRatio||1,t.znear||1,t.zfar||2e6):s.type==="orthographic"&&(e=new Ze(-t.xmag,t.xmag,t.ymag,-t.ymag,t.znear,t.zfar)),s.name&&(e.name=this.createUniqueName(s.name)),y(e,s),Promise.resolve(e)}loadSkin(n){const e=this.json.skins[n],s=[];for(let t=0,i=e.joints.length;t<i;t++)s.push(this._loadNodeShallow(e.joints[t]));return e.inverseBindMatrices!==void 0?s.push(this.getDependency("accessor",e.inverseBindMatrices)):s.push(null),Promise.all(s).then(function(t){const i=t.pop(),r=t,a=[],o=[];for(let c=0,u=r.length;c<u;c++){const l=r[c];if(l){a.push(l);const h=new B;i!==null&&h.fromArray(i.array,c*16),o.push(h)}else console.warn('THREE.GLTFLoader: Joint "%s" could not be found.',e.joints[c])}return new $e(a,o)})}loadAnimation(n){const e=this.json,s=this,t=e.animations[n],i=t.name?t.name:"animation_"+n,r=[],a=[],o=[],c=[],u=[];for(let l=0,h=t.channels.length;l<h;l++){const d=t.channels[l],p=t.samplers[d.sampler],R=d.target,m=R.node,T=t.parameters!==void 0?t.parameters[p.input]:p.input,A=t.parameters!==void 0?t.parameters[p.output]:p.output;R.node!==void 0&&(r.push(this.getDependency("node",m)),a.push(this.getDependency("accessor",T)),o.push(this.getDependency("accessor",A)),c.push(p),u.push(R))}return Promise.all([Promise.all(r),Promise.all(a),Promise.all(o),Promise.all(c),Promise.all(u)]).then(function(l){const h=l[0],d=l[1],p=l[2],R=l[3],m=l[4],T=[];for(let x=0,E=h.length;x<E;x++){const M=h[x],N=d[x],S=p[x],H=R[x],P=m[x];if(M===void 0)continue;M.updateMatrix&&M.updateMatrix();const K=s._createAnimationTracks(M,N,S,H,P);if(K)for(let j=0;j<K.length;j++)T.push(K[j])}const A=new en(i,void 0,T);return y(A,t),A})}createNodeMesh(n){const e=this.json,s=this,t=e.nodes[n];return t.mesh===void 0?null:s.getDependency("mesh",t.mesh).then(function(i){const r=s._getNodeRef(s.meshCache,t.mesh,i);return t.weights!==void 0&&r.traverse(function(a){if(a.isMesh)for(let o=0,c=t.weights.length;o<c;o++)a.morphTargetInfluences[o]=t.weights[o]}),r})}loadNode(n){const e=this.json,s=this,t=e.nodes[n],i=s._loadNodeShallow(n),r=[],a=t.children||[];for(let c=0,u=a.length;c<u;c++)r.push(s.getDependency("node",a[c]));const o=t.skin===void 0?Promise.resolve(null):s.getDependency("skin",t.skin);return Promise.all([i,Promise.all(r),o]).then(function(c){const u=c[0],l=c[1],h=c[2];h!==null&&u.traverse(function(d){d.isSkinnedMesh&&d.bind(h,Un)});for(let d=0,p=l.length;d<p;d++)u.add(l[d]);if(u.userData.pivot!==void 0&&l.length>0){const d=u.userData.pivot,p=l[0];u.pivot=new C().fromArray(d),u.position.x-=d[0],u.position.y-=d[1],u.position.z-=d[2],p.position.set(0,0,0),delete u.userData.pivot}return u})}_loadNodeShallow(n){const e=this.json,s=this.extensions,t=this;if(this.nodeCache[n]!==void 0)return this.nodeCache[n];const i=e.nodes[n],r=i.name?t.createUniqueName(i.name):"",a=[],o=t._invokeOne(function(c){return c.createNodeMesh&&c.createNodeMesh(n)});return o&&a.push(o),i.camera!==void 0&&a.push(t.getDependency("camera",i.camera).then(function(c){return t._getNodeRef(t.cameraCache,i.camera,c)})),t._invokeAll(function(c){return c.createNodeAttachment&&c.createNodeAttachment(n)}).forEach(function(c){a.push(c)}),this.nodeCache[n]=Promise.all(a).then(function(c){let u;if(i.isBone===!0?u=new nn:c.length>1?u=new z:c.length===1?u=c[0]:u=new ge,u!==c[0])for(let l=0,h=c.length;l<h;l++)u.add(c[l]);if(i.name&&(u.userData.name=i.name,u.name=r),y(u,i),i.extensions&&O(s,u,i),i.matrix!==void 0){const l=new B;l.fromArray(i.matrix),u.applyMatrix4(l)}else i.translation!==void 0&&u.position.fromArray(i.translation),i.rotation!==void 0&&u.quaternion.fromArray(i.rotation),i.scale!==void 0&&u.scale.fromArray(i.scale);if(!t.associations.has(u))t.associations.set(u,{});else if(i.mesh!==void 0&&t.meshCache.refs[i.mesh]>1){const l=t.associations.get(u);t.associations.set(u,{...l})}return t.associations.get(u).nodes=n,u}),this.nodeCache[n]}loadScene(n){const e=this.extensions,s=this.json.scenes[n],t=this,i=new z;s.name&&(i.name=t.createUniqueName(s.name)),y(i,s),s.extensions&&O(e,i,s);const r=s.nodes||[],a=[];for(let o=0,c=r.length;o<c;o++)a.push(t.getDependency("node",r[o]));return Promise.all(a).then(function(o){for(let u=0,l=o.length;u<l;u++){const h=o[u];h.parent!==null?i.add(un(h)):i.add(h)}const c=u=>{const l=new Map;for(const[h,d]of t.associations)(h instanceof X||h instanceof ne)&&l.set(h,d);return u.traverse(h=>{const d=t.associations.get(h);d!=null&&l.set(h,d)}),l};return t.associations=c(i),i})}_createAnimationTracks(n,e,s,t,i){const r=[],a=n.name?n.name:n.uuid,o=[];function c(d){d.morphTargetInfluences&&o.push(d.name?d.name:d.uuid)}I[i.path]===I.weights?(c(n),n.isGroup&&n.children.forEach(c)):o.push(a);let u;switch(I[i.path]){case I.weights:u=se;break;case I.rotation:u=ie;break;case I.translation:case I.scale:u=te;break;default:switch(s.itemSize){case 1:u=se;break;case 2:case 3:default:u=te;break}break}const l=t.interpolation!==void 0?Pn[t.interpolation]:xe,h=this._getArrayFromAccessor(s);for(let d=0,p=o.length;d<p;d++){const R=new u(o[d]+"."+I[i.path],e.array,h,l);t.interpolation==="CUBICSPLINE"&&this._createCubicSplineTrackInterpolant(R),r.push(R)}return r}_getArrayFromAccessor(n){let e=n.array;if(n.normalized){const s=ee(e.constructor),t=new Float32Array(e.length);for(let i=0,r=e.length;i<r;i++)t[i]=e[i]*s;e=t}return e}_createCubicSplineTrackInterpolant(n){n.createInterpolant=function(s){const t=this instanceof ie?Fn:Me;return new t(this.times,this.values,this.getValueSize()/3,s)},n.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline=!0}}function Kn(f,n,e){const s=n.attributes,t=new an;if(s.POSITION!==void 0){const a=e.json.accessors[s.POSITION],o=a.min,c=a.max;if(o!==void 0&&c!==void 0){if(t.set(new C(o[0],o[1],o[2]),new C(c[0],c[1],c[2])),a.normalized){const u=ee(k[a.componentType]);t.min.multiplyScalar(u),t.max.multiplyScalar(u)}}else{console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.");return}}else return;const i=n.targets;if(i!==void 0){const a=new C,o=new C;for(let c=0,u=i.length;c<u;c++){const l=i[c];if(l.POSITION!==void 0){const h=e.json.accessors[l.POSITION],d=h.min,p=h.max;if(d!==void 0&&p!==void 0){if(o.setX(Math.max(Math.abs(d[0]),Math.abs(p[0]))),o.setY(Math.max(Math.abs(d[1]),Math.abs(p[1]))),o.setZ(Math.max(Math.abs(d[2]),Math.abs(p[2]))),h.normalized){const R=ee(k[h.componentType]);o.multiplyScalar(R)}a.max(o)}else console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.")}}t.expandByVector(a)}f.boundingBox=t;const r=new cn;t.getCenter(r.center),r.radius=t.min.distanceTo(t.max)/2,f.boundingSphere=r}function fe(f,n,e){const s=n.attributes,t=[];function i(r,a){return e.getDependency("accessor",r).then(function(o){f.setAttribute(a,o)})}for(const r in s){const a=$[r]||r.toLowerCase();a in f.attributes||t.push(i(s[r],a))}if(n.indices!==void 0&&!f.index){const r=e.getDependency("accessor",n.indices).then(function(a){f.setIndex(a)});t.push(r)}return re.workingColorSpace!==b&&"COLOR_0"in s&&console.warn(`THREE.GLTFLoader: Converting vertex colors from "srgb-linear" to "${re.workingColorSpace}" not supported.`),y(f,n),Kn(f,n,e),Promise.all(t).then(function(){return n.targets!==void 0?Hn(f,n.targets,e):f})}export{Vn as GLTFLoader};
|