@rr0/ufoathome 0.191.1 → 0.192.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,2 @@
1
+ import{a9 as et,aa as g,ab as It,ac as Z,ad as j,ae as N,af as Dt,ag as V,ah as st,ai as Rt,x as at,aj as it}from"./rr0-sighting-editor.mjs";import{ak as le}from"./rr0-sighting-editor.mjs";import{C as ot}from"./ContrailGrowth-DwHS8If9.js";const Tt=.25,rt=.4,ct=6,X=12,Bt=3,lt=.2,vt=.2,ht=24,Nt=3,Ct=24,ut=1,_t=.7,Ht=1.5,wt=.8,yt=1.3,dt=.02,Pt=700,kt=-30,pt=.9,mt=5,Lt=25,Ft=.5,jt=.12,Mt=[.13,.31],Gt=.16,Ut=1.6,Kt=2,zt=3.6,At=1.1,Wt=.3,Vt=1e3,gt=.7,Xt=.7;class q{context;constructor(t){this.context=t}noiseBuffer;roughBuffers=new Map;voices=new Map;bus;reverb;reverbOut;level=1;master;paused=!0;requested=[];headingDeg=0;resume(){if(!this.context){if(typeof AudioContext>"u")return;try{this.context=new AudioContext}catch(t){console.warn("AircraftAudio: Web Audio unavailable, aircraft stay silent:",t);return}}et.isLive(this.context)&&et.unlock(this.context),this.apply()}setLevel(t){this.level=t,this.master&&(this.master.gain.value=t)}setPaused(t){t!==this.paused&&(this.paused=t,this.apply())}setVoices(t,e=0){this.requested=t,this.headingDeg=e,this.apply()}dispose(){for(const t of[...this.voices.keys()])this.release(t);et.isLive(this.context)&&this.context.close(),this.context=void 0,this.master=void 0,this.bus=void 0}apply(){const t=this.context;if(!t)return;const e=this.paused?[]:this.requested,a=new Set(e.map(n=>n.id));for(const n of[...this.voices.keys()])a.has(n)||this.release(n);for(const n of e){const s=this.voices.get(n.id)??this.build(t,n);this.retarget(t,s,n)}}build(t,e){const a=t.createGain();a.gain.value=0;let n;const s=this.busOf(t);typeof t.createStereoPanner=="function"?(n=t.createStereoPanner(),a.connect(n).connect(s)):a.connect(s);const i=t.createGain(),o=e.character?.modulationDepth??0;i.gain.value=1-o/2;const r=t.createOscillator();r.type="sine";const l=t.createGain();l.gain.value=o/2,r.connect(l).connect(i.gain),i.connect(a);const c=t.createBufferSource();c.buffer=this.noise(t),c.loop=!0,c.loopStart=Math.random()*ct*.5;const u=[],d=[],h=[];for(const D of g.OCTAVES){const I=t.createBiquadFilter();I.type="bandpass",I.frequency.value=D,I.Q.value=ut;const H=t.createBiquadFilter();H.type="bandpass",H.frequency.value=D,H.Q.value=ut;const P=t.createGain();P.gain.value=0,c.connect(I).connect(H).connect(P).connect(i),u.push(I),d.push(H),h.push(P)}const p=[];for(const[D,I]of[[e.character?.toneHz,e.character?.toneShare],[e.character?.humHz,e.character?.humShare]])if(D!==void 0)for(let H=1;H<=Nt;H++){const P=t.createOscillator();P.type="sine",P.frequency.value=D*H;const tt=t.createGain();tt.gain.value=0,P.connect(tt).connect(a),p.push({oscillator:P,gain:tt,harmonic:H,baseHz:D,share:I??0})}const m=t.createGain();m.gain.value=0,m.connect(a.gain);const E=Mt.map(D=>{const I=t.createOscillator();return I.type="sine",I.frequency.value=D,I.connect(m),I}),O=t.createGain();O.gain.value=e.character?.roughness??lt;const B=t.createBufferSource();B.buffer=this.roughTable(t,Bt),B.loop=!0,B.loopStart=Math.random()*X*.5,B.connect(O).connect(i.gain);const v=t.createGain();v.gain.value=(e.character?.roughness??lt)*vt;const S=t.createBufferSource();S.buffer=this.roughTable(t,ht),S.loop=!0,S.loopStart=Math.random()*X*.5,S.connect(v).connect(i.gain);let F;const J=this.busOf(t)&&this.reverb;J&&(F=t.createGain(),F.gain.value=0,a.connect(F).connect(J));let L,_;if(!e.inside&&typeof t.createDelay=="function"){const D=t.createDelay(dt);D.delayTime.value=0;const I=t.createBiquadFilter();I.type="highshelf",I.frequency.value=Pt,I.gain.value=0;const H=t.createGain();H.gain.value=0,a.connect(D).connect(I).connect(H).connect(n??s);const P=t.createGain();P.gain.value=0,_=t.createBufferSource(),_.buffer=this.roughTable(t,ht),_.loop=!0,_.loopStart=Math.random()*X*.5,_.connect(P).connect(D.delayTime),L={delay:D,jitter:P,shelf:I,gain:H}}const k=[c,B,S,r,...p.map(D=>D.oscillator),...E,..._?[_]:[]];for(const D of k)D.start();const $={nodes:[a,i,l,O,v,m,...L?[L.delay,L.jitter,L.shelf,L.gain]:[],...p.map(D=>D.gain),...u,...d,...h,...F?[F]:[],...n?[n]:[],...k],sources:k,filters:u,seconds:d,gains:h,tones:p,lfo:r,lfoDepth:l,wander:E,wanderDepth:m,roughDepth:O,crackleDepth:v,beat:i,output:a,panner:n,send:F,echo:L};return this.voices.set(e.id,$),$}retarget(t,e,a){const n=t.currentTime,s=(p,m)=>p.setTargetAtTime(m,n,Tt),i=Math.min(Ht,Math.max(_t,a.dopplerRatio)),o=Math.min(yt,Math.max(wt,Math.sqrt(a.dopplerRatio))),r=t.sampleRate*.45,l=a.bandAmplitudes.map((p,m)=>p*q.unweighting(g.OCTAVES[m])),c=Math.sqrt(l.reduce((p,m)=>p+m*m,0)),u=Math.min(1,Math.max(0,(a.distanceKm-mt)/(Lt-mt)));g.OCTAVES.forEach((p,m)=>{s(e.filters[m].frequency,Math.min(r,p*o)),s(e.seconds[m].frequency,Math.min(r,p*o)),s(e.gains[m].gain,l[m]*Math.sqrt(Vt/p))});const d=a.character;for(const{oscillator:p,gain:m,harmonic:E,baseHz:O,share:B}of e.tones){const v=O*E;s(p.frequency,v*i);const S=v*i;s(m.gain,S<r?B*Gt*l[q.bandOf(S)]/E:0)}d?.modulationHz!==void 0&&s(e.lfo.frequency,d.modulationHz*i);const h=c>0?q.saturated(c)/c:1;if(s(e.output.gain,h*(1-Wt*u)),s(e.wanderDepth.gain,h*jt*u/Mt.length),e.send&&s(e.send.gain,q.reverbSend(a.distanceKm)),e.echo){const p=a.groundEcho;s(e.echo.gain.gain,p?.lowGain??0),p&&(s(e.echo.delay.delayTime,Math.min(dt,p.delayS)),s(e.echo.jitter.gain,p.jitterS),s(e.echo.shelf.gain,p.lowGain>0?Math.max(kt,20*Math.log10(Math.max(p.highGain,1e-6)/p.lowGain)):0))}if(e.panner){const p=(a.azimuthDeg-this.headingDeg)*Math.PI/180,m=a.inside?0:Math.max(-pt,Math.min(pt,Math.sin(p)))*(1-Ft*u);s(e.panner.pan,m)}}static saturated(t){const e=Xt*gt;if(t<=e)return t;const a=gt-e;return e+a*(1-Math.exp(-(t-e)/a))}static reverbSend(t){return Math.min(Ut,Math.sqrt(Math.max(0,t)/Kt))}static unweighting(t){return 10**(Math.min(Ct,Math.max(0,-g.aWeightingDb(t)))/20)}static bandOf(t){let e=0;return g.OCTAVES.forEach((a,n)=>{Math.abs(Math.log(t/a))<Math.abs(Math.log(t/g.OCTAVES[e]))&&(e=n)}),e}roughTable(t,e){const a=this.roughBuffers.get(e);if(a)return a;const n=Math.floor(t.sampleRate*X),s=t.createBuffer(1,n,t.sampleRate),i=s.getChannelData(0),o=Array.from({length:X*e},()=>(Math.random()*2-1)**3),r=t.sampleRate/e;for(let l=0;l<i.length;l++){const c=l/r,u=Math.floor(c),d=c-u,h=d*d*(3-2*d);i[l]=o[u%o.length]*(1-h)+o[(u+1)%o.length]*h}return this.roughBuffers.set(e,s),s}roomImpulse(t){const e=Math.floor(t.sampleRate*zt),a=t.createBuffer(2,e,t.sampleRate);for(let n=0;n<2;n++){const s=a.getChannelData(n);let i=0;for(let o=0;o<e;o++){const r=o/t.sampleRate,l=.6*Math.exp(-r/(At*2))+.04;i+=l*(Math.random()*2-1-i),s[o]=i*Math.exp(-r/At)}}return a}busOf(t){if(this.bus)return this.bus;const e=t.createGain();if(e.gain.value=this.level,e.connect(t.destination),this.master=e,typeof t.createConvolver=="function"){const a=t.createConvolver();a.buffer=this.roomImpulse(t);const n=t.createGain();n.gain.value=.9,a.connect(n),this.reverb=a,this.reverbOut=n}if(typeof t.createDynamicsCompressor=="function"){const a=t.createDynamicsCompressor();a.threshold.value=-6,a.knee.value=3,a.ratio.value=4,a.attack.value=.005,a.release.value=.25,a.connect(e),this.bus=a}else this.bus=e;return this.reverbOut?.connect(this.bus),this.bus}release(t){const e=this.voices.get(t);if(!e)return;this.voices.delete(t);const a=this.context;a&&(e.output.gain.setTargetAtTime(0,a.currentTime,rt/3),setTimeout(()=>{for(const n of e.sources)try{n.stop()}catch{}for(const n of e.nodes)n.disconnect()},rt*1e3*3))}noise(t){if(this.noiseBuffer)return this.noiseBuffer;const e=t.createBuffer(1,t.sampleRate*ct,t.sampleRate),a=e.getChannelData(0);for(let n=0;n<a.length;n++)a[n]=Math.random()*2-1;return this.noiseBuffer=e,e}}class U{static TYPES={A318:["Airbus A318","airliner-narrow",34.1,31.4],A319:["Airbus A319","airliner-narrow",34.1,33.8],A320:["Airbus A320","airliner-narrow",34.1,37.6],A321:["Airbus A321","airliner-narrow",34.1,44.5],A19N:["Airbus A319neo","airliner-narrow",35.8,33.8],A20N:["Airbus A320neo","airliner-narrow",35.8,37.6],A21N:["Airbus A321neo","airliner-narrow",35.8,44.5],B737:["Boeing 737-700","airliner-narrow",34.3,33.6],B738:["Boeing 737-800","airliner-narrow",35.8,39.5],B739:["Boeing 737-900","airliner-narrow",35.8,42.1],B38M:["Boeing 737 MAX 8","airliner-narrow",35.9,39.5],B39M:["Boeing 737 MAX 9","airliner-narrow",35.9,42.2],B752:["Boeing 757-200","airliner-narrow",38,47.3],B753:["Boeing 757-300","airliner-narrow",38,54.4],B762:["Boeing 767-200","airliner-wide",47.6,48.5],B763:["Boeing 767-300","airliner-wide",47.6,54.9],B764:["Boeing 767-400","airliner-wide",51.9,61.4],B772:["Boeing 777-200","airliner-wide",60.9,63.7],B77L:["Boeing 777-200LR","airliner-wide",64.8,63.7],B77W:["Boeing 777-300ER","airliner-wide",64.8,73.9],B788:["Boeing 787-8","airliner-wide",60.1,56.7],B789:["Boeing 787-9","airliner-wide",60.1,62.8],B78X:["Boeing 787-10","airliner-wide",60.1,68.3],B744:["Boeing 747-400","airliner-wide",64.4,70.7],B748:["Boeing 747-8","airliner-wide",68.4,76.3],A306:["Airbus A300-600","airliner-wide",44.8,54.1],A310:["Airbus A310","airliner-wide",43.9,46.7],A332:["Airbus A330-200","airliner-wide",60.3,58.8],A333:["Airbus A330-300","airliner-wide",60.3,63.7],A338:["Airbus A330-800","airliner-wide",64,58.8],A339:["Airbus A330-900","airliner-wide",64,63.7],A343:["Airbus A340-300","airliner-wide",60.3,63.7],A346:["Airbus A340-600","airliner-wide",63.5,75.4],A359:["Airbus A350-900","airliner-wide",64.8,66.8],A35K:["Airbus A350-1000","airliner-wide",64.8,73.8],A388:["Airbus A380-800","airliner-wide",79.8,72.7],CONC:["Concorde","airliner-supersonic",25.6,61.7],DC3:["Douglas DC-3","piston-heavy",29,19.7],DC4:["Douglas DC-4","piston-heavy",35.8,28.6],P51:["North American P-51 Mustang","piston-heavy",11.3,9.8],E170:["Embraer 170","regional-jet",26,29.9],E75L:["Embraer 175","regional-jet",26,31.7],E75S:["Embraer 175","regional-jet",26,31.7],E190:["Embraer 190","regional-jet",28.7,36.2],E195:["Embraer 195","regional-jet",28.7,38.7],E290:["Embraer 190-E2","regional-jet",33.7,36.2],E295:["Embraer 195-E2","regional-jet",33.7,41.5],CRJ2:["Bombardier CRJ200","regional-jet",21.2,26.8],CRJ7:["Bombardier CRJ700","regional-jet",23.2,32.3],CRJ9:["Bombardier CRJ900","regional-jet",24.9,36.2],CRJX:["Bombardier CRJ1000","regional-jet",26.2,39.1],AT72:["ATR 72","regional-turboprop",27.1,27.2],AT76:["ATR 72-600","regional-turboprop",27.1,27.2],AT45:["ATR 42","regional-turboprop",24.6,22.7],DH8D:["Dash 8 Q400","regional-turboprop",28.4,32.8],DH8C:["Dash 8-300","regional-turboprop",27.4,25.7],SF34:["Saab 340","regional-turboprop",21.4,19.7],B190:["Beechcraft 1900","regional-turboprop",17.7,17.6],C25A:["Cessna CitationJet CJ2","business-jet",14.3,14.4],C56X:["Cessna Citation Excel","business-jet",17.2,16],C68A:["Cessna Citation Latitude","business-jet",22,18.9],C550:["Cessna Citation II","business-jet",15.8,14.4],E55P:["Embraer Phenom 300","business-jet",15.9,15.6],E50P:["Embraer Phenom 100","business-jet",12.3,12.8],GLF5:["Gulfstream G550","business-jet",28.5,29.4],FA7X:["Dassault Falcon 7X","business-jet",26.2,23.4],CL60:["Bombardier Challenger 600","business-jet",19.6,20.9],LJ45:["Learjet 45","business-jet",14.6,17.7],H25B:["Hawker 800","business-jet",15.7,15.6],C172:["Cessna 172","light-piston",11,8.3],C152:["Cessna 152","light-piston",10.2,7.3],C182:["Cessna 182","light-piston",10.9,8.8],P28A:["Piper Cherokee","light-piston",10.7,7.2],PA34:["Piper Seneca","light-piston",11.8,8.7],SR20:["Cirrus SR20","light-piston",10.9,7.9],SR22:["Cirrus SR22","light-piston",11.7,7.9],S22T:["Cirrus SR22T","light-piston",11.7,7.9],DA40:["Diamond DA40","light-piston",11.6,8.1],DA42:["Diamond DA42","light-piston",13.4,8.6],BE20:["Beechcraft King Air 200","turboprop-light",16.6,13.3],BE58:["Beechcraft Baron","light-piston",11.5,9.1],C208:["Cessna Caravan","turboprop-light",15.9,11.5],PC12:["Pilatus PC-12","turboprop-light",16.3,14.4],TBM9:["Daher TBM 900","turboprop-light",12.8,10.7],EC35:["Airbus H135","helicopter-light",10.2,12.1],EC45:["Airbus H145","helicopter-medium",11,13.6],AS50:["Airbus H125","helicopter-light",10.7,12.9],EC30:["Airbus H130","helicopter-light",10.7,12.6],B407:["Bell 407","helicopter-light",10.7,12.7],B06:["Bell 206","helicopter-light",10.2,12],B429:["Bell 429","helicopter-medium",10.9,13],B505:["Bell 505","helicopter-light",10.4,11.9],R44:["Robinson R44","helicopter-light",10.1,11.7],R22:["Robinson R22","helicopter-light",7.7,8.8],A109:["Agusta A109","helicopter-medium",11,13],A139:["Leonardo AW139","helicopter-medium",13.8,16.7],S92:["Sikorsky S-92","helicopter-heavy",17.2,20.9],H60:["Sikorsky UH-60 Black Hawk","helicopter-heavy",16.4,19.8],T38:["Northrop T-38 Talon","military-jet",7.7,14.1],HAWK:["BAE Hawk","military-jet",9.4,11.9],GLID:["Glider","glider",17,7],BALL:["Balloon","balloon",15,20],ULAC:["Ultralight","ultralight",9.5,6],C42:["Ikarus C42","ultralight",9.4,6.3],DRON:["Drone","unmanned",1,.6]};static CATEGORIES={A1:["Light aircraft","light-piston",11,8.3],A2:["Small aircraft","business-jet",15,15],A3:["Large aircraft","airliner-narrow",34.1,37.6],A4:["High-vortex large aircraft","airliner-narrow",38,47.3],A5:["Heavy aircraft","airliner-wide",60.3,63.7],A6:["High-performance aircraft","military-jet",8,14],A7:["Rotorcraft","helicopter-medium",10.7,12.7],B1:["Glider","glider",17,7],B2:["Lighter-than-air","balloon",15,20],B4:["Ultralight","ultralight",9.5,6],B6:["Unmanned aircraft","unmanned",1.5,1]};static GENERIC={name:"Airliner",kind:"airliner-narrow",spanM:34.1,lengthM:37.6,basis:"nothing"};static of(t){const e=t?.type?.toUpperCase(),a=e?U.TYPES[e]:void 0;if(a)return{code:e,name:a[0],kind:a[1],spanM:a[2],lengthM:a[3],basis:"type"};const n=t?.category?U.CATEGORIES[t.category]:void 0;return n?{name:n[0],kind:n[1],spanM:n[2],lengthM:n[3],basis:"category"}:{...U.GENERIC}}static isHelicopter(t){return t.kind.startsWith("helicopter")}}class C{static DUSK_SUN_ELEVATION_DEG=-.83;static ALWAYS=new Set(["airliner-narrow","airliner-wide","airliner-supersonic","regional-turboprop","regional-jet","business-jet"]);static NONE=new Set(["glider","balloon"]);static BRIGHTNESS={"light-piston":[.5,.2,.5],"turboprop-light":[.7,.4,.8],ultralight:[.4,.2,.4],unmanned:[0,.05,0],"helicopter-light":[1,1,1],"helicopter-medium":[1,1,1],"helicopter-heavy":[1,1,1],"military-jet":[1,1,1]};static LANDING_LIGHTS_BELOW_FT=1e4;static LANDING_INTENSITY=600;static LANDING_BEAM_DEG=10;static LANDING_COLOR="#fff1dc";static LANDING_BRIGHTNESS={"airliner-narrow":1,"airliner-wide":1,"airliner-supersonic":1,"regional-jet":.6,"regional-turboprop":.6,"business-jet":.4,"turboprop-light":.2,"light-piston":.1,ultralight:.05,"helicopter-light":.1,"helicopter-medium":.2,"helicopter-heavy":.2};static lampsOn(t,e){if(C.NONE.has(t))return{navigation:!1,beacon:!1,strobes:!1};if(C.ALWAYS.has(t))return{navigation:!0,beacon:!0,strobes:!0};const a=e<C.DUSK_SUN_ELEVATION_DEG;return t==="unmanned"?{navigation:!1,beacon:!1,strobes:a}:{navigation:a,beacon:a,strobes:a}}static lights(t,e){const a=C.lampsOn(t.kind,e),n=t.kind.startsWith("helicopter"),s=It.find(h=>h.id===(n?"helicopter":"airliner")).create(),[i,o]=n?[5,7]:[17,18],r=t.spanM/2/i,l=t.lengthM/2/o,[c,u,d]=C.BRIGHTNESS[t.kind]??[1,1,1];return s.filter(h=>h.id.startsWith("nav")?a.navigation:h.id.startsWith("strobe")?a.strobes:h.id.startsWith("beacon")?a.beacon:!0).filter(h=>!(h.id.startsWith("beacon")&&!a.beacon)).map(h=>{const p=h.id.startsWith("nav")?c:h.id.startsWith("strobe")?u:d;return{...h,offsetM:{x:h.offsetM.x*r,y:h.offsetM.y,z:h.offsetM.z*l},intensity:(h.intensity??1)*p}}).filter(h=>(h.intensity??1)>0)}static landingLights(t,e,a){const n=C.LANDING_BRIGHTNESS[t.kind]??0;if(n===0||!C.lampsOn(t.kind,e).navigation)return[];const s=c=>c<C.LANDING_LIGHTS_BELOW_FT;if(!a.some(c=>s(c.altitudeFt)))return[];const i=C.LANDING_INTENSITY*n,o=a.flatMap((c,u)=>u>0&&s(c.altitudeFt)!==s(a[u-1].altitudeFt)?[{t:c.t,intensity:s(c.altitudeFt)?i:0}]:[]),r=t.spanM/34,l=t.lengthM/36;return[-1,1].map(c=>({id:c<0?"landing-left":"landing-right",offsetM:{x:c*5*r,y:-1,z:3*l},color:C.LANDING_COLOR,intensity:s(a[0].altitudeFt)?i:0,pattern:{kind:"steady"},beamDeg:C.LANDING_BEAM_DEG,keyframes:o}))}static bodyColor(t){return t.kind==="military-jet"?"#8a8e94":t.kind.startsWith("helicopter")?"#c8ccd1":t.kind==="unmanned"?"#2c2e33":"#dde0e4"}}class x{static FAMILIES={"amvlab-a320":["A318","A319","A320","A321","A19N","A20N","A21N"],"amvlab-b737":["B732","B733","B734","B735","B736","B737","B738","B739","B37M","B38M","B39M","B3XM"],"amvlab-a350":["A359","A35K"],"amvlab-a380":["A388"],"amvlab-b787":["B788","B789","B78X"]};static BY_TYPE=new Map(Object.entries(x.FAMILIES).flatMap(([t,e])=>e.map(a=>[a,t])));static idOf(t){return t?x.BY_TYPE.get(t.toUpperCase()):void 0}}class T{static ID_PREFIX=Z.ID_PREFIX;static MAX_OBJECTS=40;static FT_TO_M=.3048;static DEG=Math.PI/180;static from(t,e,a,n=T.MAX_OBJECTS,s={}){return new qt(t,e,a,n,s).build()}static idOf(t,e){return Z.idOf(t,e)}static keyOf(t){return Z.keyOf(t)}static HEIGHT_OVER_LENGTH=.29;static sizeOf(t){return{widthM:t.spanM,lengthM:t.lengthM,heightM:t.lengthM*T.HEIGHT_OVER_LENGTH}}static offsetOf(t,e){const a=j.seenFrom(t,{lat:e.lat,lng:e.lng,heightM:e.altitudeFt*T.FT_TO_M}),n=a.distanceKm*1e3,s=n*Math.cos(a.altitudeDeg*T.DEG);return{eastM:s*Math.sin(a.azimuthDeg*T.DEG),northM:s*Math.cos(a.azimuthDeg*T.DEG),upM:n*Math.sin(a.altitudeDeg*T.DEG),altitudeDeg:a.altitudeDeg,distanceKm:a.distanceKm}}static segments(t){const e=[];let a=[];for(const n of t.points){const s=a[a.length-1];s&&n.t-s.t>N.MAX_GAP_S*1e3&&(e.push(a),a=[]),a.push(n)}return e.push(a),e.filter(n=>n.length>=2)}static bearingDeg(t,e){return(Math.atan2(e.eastM-t.eastM,e.northM-t.northM)/T.DEG+360)%360}}class qt{constructor(t,e,a,n,s){this.tracks=t,this.observer=e,this.startMs=a,this.maxObjects=n,this.options=s}build(){const t=[];for(const a of this.tracks){const n=T.keyOf(a),s=this.options.models?.get(n)??U.of(void 0);T.segments(a).forEach((i,o)=>{const r=i.map(h=>({point:h,at:T.offsetOf(this.observer,h)}));if(!r.some(h=>h.at.altitudeDeg>=0))return;const l=r.map((h,p)=>({t:h.point.t-this.startMs,eastM:h.at.eastM,northM:h.at.northM,altitudeM:h.at.upM,headingDeg:h.point.trackDeg??(p+1<r.length?T.bearingDeg(h.at,r[p+1].at):T.bearingDeg(r[p-1].at,h.at))})),c=T.idOf(a,o),u=r[Math.floor(r.length/2)].point,d=this.options.sunElevationAt?.(u)??90;t.push({object:{id:c,kind:"aircraft",eastM:l[0].eastM,northM:l[0].northM,headingDeg:l[0].headingDeg,sizeM:T.sizeOf(s),model:x.idOf(s.code)?{id:x.idOf(s.code)}:void 0,color:C.bodyColor(s),lights:[...C.lights(s,d),...C.landingLights(s,d,i.map(h=>({t:h.t-this.startMs,altitudeFt:h.altitudeFt})))],track:l},presence:{fromMs:l[0].t,untilMs:l[l.length-1].t},flight:{icao:a.icao,nonIcao:a.nonIcao,points:i},closestKm:Math.min(...r.map(h=>h.at.distanceKm))})})}t.sort((a,n)=>a.closestKm-n.closestKm);const e=t.slice(0,this.maxObjects);return{objects:e.map(a=>a.object),presence:new Map(e.map(a=>[a.object.id,a.presence])),flights:new Map(e.map(a=>[a.object.id,a.flight])),total:t.length,shown:e.length}}}const Yt=[[20,0],[120,0],[130,1.5],[140,4],[150,7.5],[160,7.5]],xt=[[20,1.5],[40,1],[60,1],[80,0],[120,0],[130,1],[140,1],[150,-3],[160,-6.5],[170,-12]],bt=.16,Jt=1,$t=[[0,-2],[10,-1],[20,0],[40,0],[50,-2],[60,-4.5],[70,-7.5],[80,-11],[90,-15],[100,-19.5],[110,-25]],Zt=[[60,-15.8],[70,-11.5],[80,-8],[90,-5],[100,-2.7],[110,-1.2],[120,-.3],[130,0],[140,-2],[150,-6],[160,-10],[170,-15],[180,-20]],Qt=1.5,Et=-40,te=1.5,ee={takeoff:{jetMps:300,flightMps:80,jetShare:[1,1,.9,.6,.3,.1,0,0]},overflight:{jetMps:280,flightMps:130,jetShare:[1,1,.9,.6,.3,.1,0,0]},approach:{jetMps:180,flightMps:70,jetShare:[.6,.5,.4,.2,.1,0,0,0]}};class w{static bandsDb(t,e,a=340){const n=ee[e],s=w.fan(t)-w.fan(90),i=.62*Math.max(0,n.jetMps-n.flightMps)/a,o=-30*Math.log10(1+i/(1+i**5)**.2*Math.cos(t*Math.PI/180));return g.OCTAVES.map((r,l)=>{const c=o+w.jetRemainder(t,r*te/n.jetMps),u=n.jetShare[l];return 10*Math.log10(u*10**(c/10)+(1-u)*10**(s/10))})}static loudestDb(t){const e=w.loudest.get(t);if(e)return e;const a=g.OCTAVES.map(()=>-1/0);for(let n=0;n<=180;n+=5)w.bandsDb(n,t).forEach((s,i)=>a[i]=Math.max(a[i],s));return w.loudest.set(t,a),a}static loudest=new Map;static angleDeg(t,e){const a=t.reduce((s,i,o)=>s+i*e[o],0),n=Math.hypot(...t)*Math.hypot(...e);return n===0?90:Math.acos(Math.min(1,Math.max(-1,a/n)))*180/Math.PI}static fan(t){const e=w.read($t,t,!0),a=w.read(Zt,t,!0)+Qt;return 10*Math.log10(10**(e/10)+10**(a/10))}static jetRemainder(t,e){const a=Math.min(1,Math.max(0,Math.log(e/bt)/Math.log(Jt/bt)));return(1-a)*w.read(Yt,t)+a*w.read(xt,t)}static read(t,e,a=!1){const[n,s]=[t[0],t[1]],[i,o]=[t[t.length-2],t[t.length-1]];if(e<=n[0])return a?Math.max(Et,n[1]+(s[1]-n[1])/(s[0]-n[0])*(e-n[0])):n[1];if(e>=o[0])return a?Math.max(Et,o[1]+(o[1]-i[1])/(o[0]-i[0])*(e-o[0])):o[1];for(let r=1;r<t.length;r++){const[l,c]=[t[r-1],t[r]];if(e<=c[0])return l[1]+(c[1]-l[1])*(e-l[0])/(c[0]-l[0])}return o[1]}}class A{static GRASS={flowResistivityKPa:200,earHeightM:1.6};static COHERENCE=.4;static JITTER_S=1e-4;static ECHO_UNDER_S=5e-4;static ECHO_FROM_S=.0015;static LOW_HZ=125;static HIGH_HZ=2e3;static AIR_DENSITY=1.2;static reflection(t,e,a=A.GRASS){const[n,s]=A.impedance(t,a);return A.reflected(n,s,Math.sin(Math.max(0,e)*Math.PI/180))}static impedance(t,e=A.GRASS){const a=A.AIR_DENSITY*t/(e.flowResistivityKPa*1e3);return[1+.0571*a**-.754,-.087*a**-.732]}static reflected(t,e,a){const[n,s,i,o]=[t*a-1,e*a,t*a+1,e*a],r=i*i+o*o;return{re:(n*i+s*o)/r,im:(s*i-n*o)/r}}static delayS(t,e=A.GRASS,a=340){return 2*e.earHeightM*Math.sin(Math.max(0,t)*Math.PI/180)/a}static excessDb(t,e=A.GRASS,a=340){const n=`${e.flowResistivityKPa}|${e.earHeightM}|${a}`;let s=A.overheads.get(n);return s||A.overheads.set(n,s=A.bandsDb(90,e,a)),A.bandsDb(t,e,a).map((i,o)=>i-s[o])}static echo(t,e=A.GRASS,a=340){const n=A.delayS(t,e,a);if(n<=A.ECHO_UNDER_S)return;const s=Math.min(1,(n-A.ECHO_UNDER_S)/(A.ECHO_FROM_S-A.ECHO_UNDER_S)),i=s*s*(3-2*s),o=r=>{const l=A.reflection(r,t,e);return i*A.COHERENCE*Math.hypot(l.re,l.im)};return{delayS:n,lowGain:o(A.LOW_HZ),highGain:o(A.HIGH_HZ),jitterS:A.JITTER_S}}static overheads=new Map;static thirds=g.OCTAVES.map(t=>[-1,0,1].map(e=>{const a=t*2**(e/3);return{middle:a,from:a*2**(-1/6),to:a*2**(1/6)}}));static impedances=new Map;static bandsDb(t,e,a){const n=A.delayS(t,e,a),s=A.COHERENCE,i=Math.sin(Math.max(0,t)*Math.PI/180);let o=A.impedances.get(e.flowResistivityKPa);return o||A.impedances.set(e.flowResistivityKPa,o=A.thirds.map(r=>r.map(l=>A.impedance(l.middle,e)))),A.thirds.map((r,l)=>{let c=0;return r.forEach((u,d)=>{const h=A.reflected(o[l][d][0],o[l][d][1],i),p=2*Math.PI*n*(u.to-u.from),[m,E]=p<1e-9?[1,0]:[(Math.sin(2*Math.PI*u.to*n)-Math.sin(2*Math.PI*u.from*n))/p,(Math.cos(2*Math.PI*u.from*n)-Math.cos(2*Math.PI*u.to*n))/p];c+=1+h.re*h.re+h.im*h.im+2*s*(h.re*m+h.im*E)}),10*Math.log10(c/r.length)})}}const Y={takeoff:{shapeDb:[10,3,-3,-2,-2,-2,5,4],levelDb:0},approach:{shapeDb:[0,0,0,0,0,0,0,0],levelDb:-8}},ae={takeoff:{shapeDb:[0,0,0,0,0,0,0,0],levelDb:0},approach:{shapeDb:[0,0,0,0,0,0,0,0],levelDb:-8}},Ot=[{id:"turbofan-narrow-body",name:"Turbofan airliner, narrow-body",kinds:["airliner-narrow"],totalDbA:148,shapeDb:[-32,-17,-9,-6,-5,-7,-12,-22],character:{toneHz:1800,toneShare:.3,humHz:90,humShare:.7},regimes:Y},{id:"turbojet-supersonic",name:"Supersonic turbojet airliner",kinds:["airliner-supersonic"],totalDbA:169.5,shapeDb:[-22,-13,-9,-6,-6,-9,-15,-25],character:{humHz:100,humShare:.7},regimes:ae},{id:"turbofan-wide-body",name:"Turbofan airliner, wide-body",kinds:["airliner-wide"],totalDbA:151,shapeDb:[-28,-14,-7,-4,-3,-6,-12,-22],character:{toneHz:1200,toneShare:.3,humHz:70,humShare:.7},regimes:Y},{id:"regional-jet",name:"Regional jet",kinds:["regional-jet"],totalDbA:144,shapeDb:[-32,-17,-9,-5,-4,-6,-11,-21],character:{toneHz:1900,toneShare:.3,humHz:95,humShare:.7},regimes:Y},{id:"business-jet",name:"Business jet",kinds:["business-jet"],totalDbA:141,shapeDb:[-30,-15,-8,-4,-3,-4,-9,-19],character:{toneHz:2500,toneShare:.25,humHz:110,humShare:.7},regimes:Y},{id:"turboprop",name:"Turboprop",kinds:["regional-turboprop","turboprop-light"],totalDbA:138,shapeDb:[-14,-9,-8,-6,-8,-13,-20,-28],character:{toneHz:80,toneShare:.5}},{id:"light-piston",name:"Light piston aircraft",kinds:["light-piston"],totalDbA:130,shapeDb:[-20,-10,-3,-6,-10,-20,-27,-42],character:{toneHz:80,toneShare:.4,modulationHz:80,modulationDepth:.4}},{id:"piston-heavy",name:"Heavy piston aircraft",kinds:["piston-heavy"],totalDbA:140,shapeDb:[-31,-12,-11,-9,-7,-6,-7,-11],character:{toneHz:84,toneShare:.4,modulationHz:84,modulationDepth:.36}},{id:"ultralight",name:"Ultralight",kinds:["ultralight"],totalDbA:124,shapeDb:[-16,-8,-5,-4,-9,-15,-23,-31],character:{toneHz:140,toneShare:.4}},{id:"helicopter-light",name:"Light helicopter",kinds:["helicopter-light"],totalDbA:134,shapeDb:[-15,-8,-4,-3,-6,-10,-16,-24],character:{modulationHz:20,modulationDepth:.5}},{id:"helicopter-medium",name:"Medium helicopter",kinds:["helicopter-medium"],totalDbA:138,shapeDb:[-14,-7,-4,-3,-6,-10,-16,-24],character:{modulationHz:22,modulationDepth:.5}},{id:"helicopter-heavy",name:"Heavy helicopter",kinds:["helicopter-heavy"],totalDbA:144,shapeDb:[-12,-6,-4,-4,-7,-11,-17,-25],character:{modulationHz:17,modulationDepth:.5}},{id:"military-jet",name:"Military jet",kinds:["military-jet"],totalDbA:152,shapeDb:[-26,-12,-6,-3,-2,-3,-7,-15]},{id:"glider",name:"Glider",kinds:["glider"],totalDbA:85,shapeDb:[-30,-22,-15,-10,-8,-8,-14,-22]},{id:"balloon",name:"Hot-air balloon",kinds:["balloon"],totalDbA:100,shapeDb:[-25,-15,-9,-5,-3,-6,-12,-20]},{id:"unmanned",name:"Unmanned aircraft",kinds:["unmanned"],totalDbA:88,shapeDb:[-40,-30,-20,-12,-6,-3,-3,-8],character:{toneHz:450,toneShare:1}}],ft=(b,t)=>b.map(e=>e+t-g.sumDb(b));function ne(b,t){if(!b)return;const e=t.toneRatio??1,a=t.toneGain??1;return{...b,...b.toneHz!==void 0?{toneHz:b.toneHz*e,toneShare:Math.min(1,(b.toneShare??0)*a)}:{},...b.humHz!==void 0?{humHz:b.humHz*e,humShare:Math.min(1,(b.humShare??0)*a)}:{}}}const St=Ot.map(b=>{const t=b.regimes===Y?"turbofan":void 0,e={id:b.id,name:b.name,soundPowerA:ft(b.shapeDb,b.totalDbA),character:b.character,directivity:t};if(!b.regimes)return e;const a={overflight:e};for(const[n,s]of Object.entries(b.regimes))a[n]={id:`${b.id}-${n}`,name:`${b.name}, ${n}`,soundPowerA:ft(b.shapeDb.map((i,o)=>i+s.shapeDb[o]),b.totalDbA+s.levelDb),character:ne(b.character,s),directivity:t};return{...e,regimes:a}});class M{static DEFAULT_AMBIENT_DB_A=35;static DETECTION_MARGIN_DB=3;static AMBIENT_SHAPE_DB=Dt.OUTDOOR_SHAPE_DB;static HEARING_FLOOR_DB_A=0;static ITERATIONS=30;static CONVERGED_MS=.5;static VELOCITY_STEP_MS=500;static CLIMB_MPS=2.5;static DESCENT_MPS=1.5;static LOW_M=3e3;static CLIMB_SPAN_MS=3e4;static noiseOfKind(t){const e=Ot.find(a=>a.kinds.includes(t));return St.find(a=>a.id===(e?.id??"turbofan-narrow-body"))}static bandsAt(t,e,a=g.STANDARD){const n=20*Math.log10(Math.max(e*1e3,1))+11;return g.OCTAVES.map((s,i)=>t.soundPowerA[i]-n-g.absorptionDbPerKm(s,a)*e)}static couldBeHeard(t,e,a=M.DEFAULT_AMBIENT_DB_A,n=g.STANDARD,s){const i=M.ambientBands(a,s);return Object.entries(t.regimes??{overflight:t}).some(([r,l])=>M.bandsAt(l,e,n).map((c,u)=>c+(l.directivity==="turbofan"?w.loudestDb(r)[u]:0)).some((c,u)=>c>=Math.max(i[u]+M.DETECTION_MARGIN_DB,M.HEARING_FLOOR_DB_A)))}static ambientBands(t,e=M.AMBIENT_SHAPE_DB){const a=g.sumDb(e);return e.map(n=>t+n-a)}static heardAt(t,e,a,n={}){const s=n.air??g.STANDARD,i=g.speedOfSound(s.temperatureC),o=t.points[t.points.length-1]?.t;if(o===void 0)return;let r=Math.min(a,o),l=N.positionAt(t,r);if(!l)return;let c=j.seenFrom(e,l.geo);for(let _=0;_<M.ITERATIONS;_++){const k=a-c.distanceKm*1e3*1e3/i,$=Math.abs(k-r);if(r=k,l=N.positionAt(t,r),!l)return;if(c=j.seenFrom(e,l.geo),$<M.CONVERGED_MS)break}const u=N.positionAt(t,a),d=u?j.seenFrom(e,u.geo):c,h=M.regimeAt(t,r,e),p=M.inRegime(n.noise??St[0],h),m=n.ambientDbA??M.DEFAULT_AMBIENT_DB_A,E=M.ambientBands(m,n.ambientShapeDb),O=M.emissionAngle(t,e,r),B=p.directivity==="turbofan"?w.bandsDb(O,h,i):void 0,v=n.ground===null?g.OCTAVES.map(()=>0):A.excessDb(c.altitudeDeg,n.ground,i),S=M.bandsAt(p,c.distanceKm,s).map((_,k)=>_+(B?.[k]??0)+v[k]),F=S.map((_,k)=>_>=Math.max(E[k]+M.DETECTION_MARGIN_DB,M.HEARING_FLOOR_DB_A)),J=S.indexOf(Math.max(...S)),L=F.lastIndexOf(!0);return{track:t,audible:F.some(Boolean),levelDbA:g.sumDb(S),bandsDbA:S,ambientDbA:m,delayS:(a-r)/1e3,emittedAtMs:r,sound:c,seen:d,lagDeg:M.angleBetween(c,d),dopplerRatio:M.doppler(t,e,r,i),dominantHz:g.OCTAVES[J],cutoffHz:L<0?void 0:g.OCTAVES[L],regime:h,noise:p,emissionAngleDeg:O}}static emissionAngle(t,e,a){const n=M.VELOCITY_STEP_MS,s=N.positionAt(t,a-n),i=N.positionAt(t,a+n),o=N.positionAt(t,a);if(!s||!i||!o)return 90;const r=d=>{const h=j.seenFrom(e,d),p=h.altitudeDeg*Math.PI/180,m=h.azimuthDeg*Math.PI/180,E=h.distanceKm*1e3;return[E*Math.cos(p)*Math.sin(m),E*Math.cos(p)*Math.cos(m),E*Math.sin(p)]},[l,c,u]=[r(s.geo),r(i.geo),r(o.geo)];return w.angleDeg(c.map((d,h)=>d-l[h]),u.map(d=>-d))}static regimeAt(t,e,a){const n=M.CLIMB_SPAN_MS,s=N.positionAt(t,e-n)??N.positionAt(t,e),i=N.positionAt(t,e+n)??N.positionAt(t,e),o=N.positionAt(t,e);if(!s||!i||!o)return"overflight";const r=(Math.min(e+n,t.points[t.points.length-1].t)-Math.max(e-n,t.points[0].t))/1e3;if(r<=0)return"overflight";const l=(i.altitudeFt-s.altitudeFt)*.3048/r;return o.altitudeFt*.3048-a.heightM>M.LOW_M?"overflight":l>M.CLIMB_MPS?"takeoff":l<-1.5?"approach":"overflight"}static inRegime(t,e){return t.regimes?.[e]??t}static profile(t,e,a,n,s=2e3,i={}){const o=[];let r,l,c=a;for(let u=a;u<=n;u+=s){const d=M.heardAt(t,e,u,i);d&&(!l||d.levelDbA>l.levelDbA)&&(l=d,c=u),d?.audible?r?r.untilMs=u:o.push(r={fromMs:u,untilMs:u}):r=void 0}return{track:t,audible:o,peakDbA:l?.levelDbA??-1/0,peakAtMs:c,peakDelayS:l?.delayS??0}}static angleBetween(t,e){const a=c=>{const u=c.altitudeDeg*Math.PI/180,d=c.azimuthDeg*Math.PI/180;return[Math.cos(u)*Math.sin(d),Math.cos(u)*Math.cos(d),Math.sin(u)]},[n,s,i]=a(t),[o,r,l]=a(e);return Math.acos(Math.min(1,Math.max(-1,n*o+s*r+i*l)))*180/Math.PI}static doppler(t,e,a,n){const s=M.VELOCITY_STEP_MS,i=N.positionAt(t,a-s),o=N.positionAt(t,a+s);if(!i||!o)return 1;const r=j.seenFrom(e,i.geo).distanceKm*1e3,l=j.seenFrom(e,o.geo).distanceKm*1e3;return 1/(1-(r-l)/(2*s/1e3)/n)}}class oe{static at(t,e,a,n,s={}){const i=N.seenFrom(t,a,n);if(!i)return;const o=U.of(e),r=M.heardAt(t,a,n,{noise:M.noiseOfKind(o.kind),...s});return{hex:`${t.nonIcao?"~":""}${t.icao.toString(16).padStart(6,"0")}`,registration:e?.registration,typeCode:o.code??e?.type,name:o.basis==="nothing"?void 0:o.name,kind:o.kind,basis:o.basis,military:e?.military===!0,restricted:e?.restricted===!0,altitudeFt:i.altitudeFt,groundSpeedKt:i.groundSpeedKt,trackDeg:i.trackDeg,sky:i.sky,angularRateDegPerS:i.angularRateDegPerS,hearing:r&&{audible:r.audible,levelDbA:r.levelDbA,ambientDbA:r.ambientDbA,delayS:r.delayS,lagDeg:r.lagDeg,dopplerRatio:r.dopplerRatio,cutoffHz:r.cutoffHz,dominantHz:r.dominantHz}}}}class R{static REFERENCE_AMPLITUDE=.02;static MASKING_RANGE_DB=6;static KNEE_DB=20;static COMPRESSION_RATIO=1;static EXPANSION_RATIO=1.8;static HEADROOM_DB=Dt.HEADROOM_DB;static DEFAULT_MAX_VOICES=4;static candidates(t,e,a,n,s={}){const i=new Set;for(const[o,r]of t){const l=M.noiseOfKind(U.of(e.get(a(r))).kind);let c=1/0;for(const u of r.points)c=Math.min(c,j.seenFrom(n,{lat:u.lat,lng:u.lng,heightM:u.altitudeFt*.3048}).distanceKm);M.couldBeHeard(l,c,s.ambientDbA,s.air,s.ambientShapeDb)&&i.add(o)}return i}static voices(t,e,a,n,s,i,o={}){const r=[];for(const l of t){const c=e.get(l);if(!c||o.only?.(l)===!1)continue;const u=o.kindOf?.(l)??U.of(a.get(n(c))).kind,d=o.noiseOf?.(l)??M.noiseOfKind(u),h=M.heardAt(c,s,i,{...o,noise:d});if(!h?.audible)continue;const p=o.throughDb,m=p?h.bandsDbA.map((E,O)=>E-(p[O]??0)):h.bandsDbA;p&&!R.noticed(m,h.ambientDbA,o.ambientShapeDb)||r.push({id:l,kind:u,bandAmplitudes:R.bandAmplitudes(m,h.ambientDbA,o.referenceAmplitude,{ambientShapeDb:o.ambientShapeDb,expandUnderKnee:o.expandUnderKnee}),levelDbA:p?g.sumDb(m):h.levelDbA,distanceKm:h.sound.distanceKm,dopplerRatio:h.dopplerRatio,azimuthDeg:h.sound.azimuthDeg,elevationDeg:h.sound.altitudeDeg,character:h.noise.character,groundEcho:o.ground===null?void 0:A.echo(h.sound.altitudeDeg,o.ground,g.speedOfSound((o.air??g.STANDARD).temperatureC))})}return r.sort((l,c)=>c.levelDbA-l.levelDbA).slice(0,o.maxVoices??R.DEFAULT_MAX_VOICES)}static noticed(t,e,a){const n=M.ambientBands(e,a);return t.some((s,i)=>s>=n[i]+M.DETECTION_MARGIN_DB)}static bandAmplitudes(t,e,a=R.REFERENCE_AMPLITUDE,n={}){const s=M.ambientBands(e,n.ambientShapeDb),i=n.expandUnderKnee===!1?1:R.EXPANSION_RATIO,o=M.DETECTION_MARGIN_DB,r=g.sumDb(t),l=r-e,c=l>=R.KNEE_DB?R.KNEE_DB+(l-R.KNEE_DB)/R.COMPRESSION_RATIO:R.KNEE_DB-(R.KNEE_DB-l)*i,u=a*10**((c-R.HEADROOM_DB)/20);return t.map((d,h)=>{const p=Math.min(1,Math.max(0,(d-s[h]-o+R.MASKING_RANGE_DB)/(2*R.MASKING_RANGE_DB)));return p*p*(3-2*p)*u*10**((d-r)/20)})}static BANDS_HZ=g.OCTAVES}class Q{static RUMBLE_BELOW_HZ=500;static DULL_BELOW_HZ=2e3;static PITCH_NOTICED=.03;static text(t,e,a,n){const s=(d,h=0)=>d.toLocaleString(n,{maximumFractionDigits:h}),i=(d,h)=>d.replace(/\{(\w+)\}/g,(p,m)=>h[m]??`{${m}}`),o=[],r=[t.registration,t.name].filter(Boolean).join(" · ");o.push(r||i(e.unnamed,{hex:t.hex}));const l=[i(e.altitude,{value:s(Math.round(t.altitudeFt/100)*100)}),t.groundSpeedKt===void 0?void 0:i(e.speed,{value:s(Math.round(t.groundSpeedKt))}),t.trackDeg===void 0?void 0:i(e.heading,{value:s(Math.round(t.trackDeg))})].filter(Boolean);o.push(l.join(" · ")),o.push(i(e.position,{distance:s(t.sky.distanceKm,t.sky.distanceKm<10?1:0),elevation:s(Math.round(t.sky.altitudeDeg)),bearing:a(t.sky.azimuthDeg)}));const c=t.hearing;if(!c)o.push(e.soundUnknown);else if(!c.audible)o.push(i(e.inaudible,{level:s(Math.round(c.levelDbA)),ambient:s(Math.round(c.ambientDbA))}));else{const d=c.cutoffHz??0,h=d<=Q.RUMBLE_BELOW_HZ?e.rumble:d<=Q.DULL_BELOW_HZ?e.muffled:e.broad,p=c.dopplerRatio-1,m=Math.abs(p)<Q.PITCH_NOTICED?"":i(p>0?e.pitchHigher:e.pitchLower,{percent:s(Math.round(Math.abs(p)*100))});o.push(i(e.heard,{level:s(Math.round(c.levelDbA)),delay:s(Math.round(c.delayS)),lag:s(Math.round(c.lagDeg)),character:i(h,{cutoff:s(d)}),pitch:m}))}t.contrail&&o.push(i(t.contrail.persistent?e.contrailPersistent:e.contrailShort,{rhi:s(Math.round(t.contrail.iceRelativeHumidity*100))}));const u=[t.military?e.military:void 0,t.restricted?e.restricted:void 0].filter(Boolean);return u.length>0&&o.push(u.join(" · ")),o.push(e.candidate),o.join(`
2
+ `)}}class nt{static EFFICIENCY={"airliner-narrow":.34,"airliner-wide":.38,"regional-jet":.32,"business-jet":.3,"military-jet":.22,unknown:.34};static efficiencyOf(t){return nt.EFFICIENCY[t]}}class f{static EMISSION_INDEX_WATER=1.25;static COMBUSTION_HEAT=432e5;static AIR_HEAT_CAPACITY=1004;static MOLAR_MASS_RATIO=.622;static FT_TO_M=.3048;static TROPOPAUSE_M=11e3;static TROPOPAUSE_HPA=226.32;static ISOTHERMAL_SCALE_HEIGHT_M=6341.62;static pressureAtAltitudeFt(t){const e=t*f.FT_TO_M;return e<=f.TROPOPAUSE_M?1013.25*(1-225577e-10*e)**5.25588:f.TROPOPAUSE_HPA*Math.exp(-(e-f.TROPOPAUSE_M)/f.ISOTHERMAL_SCALE_HEIGHT_M)}static saturationOverWaterPa(t){const e=t+273.15;return Math.exp(54.842763-6763.22/e-4.21*Math.log(e)+367e-6*e+Math.tanh(.0415*(e-218.8))*(53.878-1331.22/e-9.44523*Math.log(e)+.014025*e))}static saturationOverIcePa(t){const e=t+273.15;return Math.exp(9.550426-5723.265/e+3.53068*Math.log(e)-.00728332*e)}static iceRelativeHumidity(t,e){return e*f.saturationOverWaterPa(t)/f.saturationOverIcePa(t)}static mixingSlope(t,e){return f.EMISSION_INDEX_WATER*f.AIR_HEAT_CAPACITY*t*100/(f.MOLAR_MASS_RATIO*f.COMBUSTION_HEAT*(1-e))}static criticalTemperatureC(t,e){const a=Math.log(f.mixingSlope(t,e)-.053);return-46.46+9.43*a+.72*a*a}static requiredHumidity(t,e,a){const n=f.criticalTemperatureC(t,e);return(f.mixingSlope(t,e)*(a-n)+f.saturationOverWaterPa(n))/f.saturationOverWaterPa(a)}static evaluate(t,e){const a=f.criticalTemperatureC(t.pressureHpa,e),n=f.requiredHumidity(t.pressureHpa,e,t.temperatureC),s=f.iceRelativeHumidity(t.temperatureC,t.relativeHumidity),i=t.temperatureC<a&&t.relativeHumidity>=n;return{forms:i,persistent:i&&s>=1,criticalTemperatureC:a,requiredHumidity:n,iceRelativeHumidity:s}}}class G{static HOLD_MS=36e5;static DEG=Math.PI/180;static GAS_CONSTANT_OVER_GRAVITY=287.05/9.80665;static at(t,e,a){if(t.length===0)return;const n=t[0],s=t[t.length-1];if(e<n.t-G.HOLD_MS||e>s.t+G.HOLD_MS)return;const i=t.findIndex(h=>h.t>e),o=i===0?t[0]:t[(i===-1?t.length:i)-1],r=i===-1||i===0?o:t[i],l=G.atLevel(o,a),c=G.atLevel(r,a);if(!l||!c)return;const u=r.t>o.t?Math.min(1,Math.max(0,(e-o.t)/(r.t-o.t))):0,d=(h,p)=>h+(p-h)*u;return{pressureHpa:a,temperatureC:d(l.temperatureC,c.temperatureC),relativeHumidity:d(l.relativeHumidity,c.relativeHumidity),driftEastMs:d(l.driftEastMs,c.driftEastMs),driftNorthMs:d(l.driftNorthMs,c.driftNorthMs),shearPerS:d(l.shearPerS,c.shearPerS)}}static atLevel(t,e){const a=t.levels;for(let n=0;n+1<a.length;n++){const s=a[n],i=a[n+1];if(e>s.pressureHpa||e<i.pressureHpa)continue;const o=(Math.log(s.pressureHpa)-Math.log(e))/(Math.log(s.pressureHpa)-Math.log(i.pressureHpa)),r=(h,p)=>h+(p-h)*o,l=h=>{const p=h.windFromDeg*G.DEG;return{east:-h.windSpeedMs*Math.sin(p),north:-h.windSpeedMs*Math.cos(p)}},c=l(s),u=l(i),d=G.GAS_CONSTANT_OVER_GRAVITY*((s.temperatureC+i.temperatureC)/2+273.15)*Math.log(s.pressureHpa/i.pressureHpa);return{pressureHpa:e,temperatureC:r(s.temperatureC,i.temperatureC),relativeHumidity:r(s.relativeHumidity,i.relativeHumidity),driftEastMs:r(c.east,u.east),driftNorthMs:r(c.north,u.north),shearPerS:Math.hypot(u.east-c.east,u.north-c.north)/d}}}}class K{static MIN_ALTITUDE_FT=2e4;static DENSE_MS=3e5;static SPARSE_STEP_MS=6e4;static SATURATION_HORIZON_MS=3*36e5;static SATURATION_STEP_MS=6e5;static PRESSURE_STEP_HPA=5;static plan(t,e,a,n){if(a.length===0)return[];const s=[],i=new Map,o=(r,l,c)=>{const u=Math.round(l/K.PRESSURE_STEP_HPA)*K.PRESSURE_STEP_HPA,d=K.SATURATION_STEP_MS,h=Math.floor(r/d)*d,p=`${u}|${h}`,m=i.get(p);if(m!==void 0)return m+(h-r)/1e3;let E=1/0;for(let O=d;O<=K.SATURATION_HORIZON_MS;O+=d){const B=G.at(a,h+O,u);if(!B)break;if(f.evaluate(B,c).iceRelativeHumidity<1){E=O/1e3;break}}return i.set(p,E),E+(h-r)/1e3};for(const r of t.objects){const l=t.flights.get(r.id),c=r.track;if(!l||!c||c.length!==l.points.length)continue;const u=e?.get(Z.keyOf(l))??U.of(void 0),d=nt.efficiencyOf(u.kind);if(d===void 0)continue;const h=[];let p=-1/0;c.forEach((m,E)=>{if(m.t<-K.DENSE_MS&&E+1<c.length&&m.t-p<K.SPARSE_STEP_MS)return;p=m.t;const O=l.points[E],B=f.pressureAtAltitudeFt(O.altitudeFt),v=G.at(a,n+m.t,B),S=v&&f.evaluate(v,d);h.push({tMs:m.t,eastM:m.eastM,northM:m.northM,upM:m.altitudeM??0,forms:S?.forms??!1,persistent:S?.persistent??!1,lifetimeS:S?ot.lifetimeS(S.iceRelativeHumidity):0,driftEastMs:v?.driftEastMs??0,driftNorthMs:v?.driftNorthMs??0,shearPerS:v?.shearPerS??ot.TYPICAL_SHEAR_PER_S,iceRelativeHumidity:S?.iceRelativeHumidity??0,saturatedForS:S?.persistent?o(n+m.t,B,d):0})}),h.some((m,E)=>m.forms&&h[E+1]?.forms)&&s.push({id:r.id,spanM:u.spanM,points:h})}return s}}class y{static DEFAULT_KIND=V.DEFAULT_KIND;static STEP_MS=1e3;static LEAD_MS=12e4;static FT_PER_M=1/.3048;static ID_PREFIX="decor:";tracks=new Map;static kindOf(t,e){return V.kindOf(t,e)}static flies(t){return V.flies(t)}static ridden(t,e,a,n=()=>{}){const s=st.originOf(t);if(s)for(const i of t.decor){const o=V.kindOf(i,n(i));if(!o)continue;const r=i.sizeM,l=Math.max(r?.widthM??0,r?.lengthM??0,r?.heightM??0)/2;if(l<=0)continue;const c=y.pointAt(i,e,s),{distanceKm:u}=j.seenFrom(a,{lat:c.lat,lng:c.lng,heightM:c.altitudeFt/y.FT_PER_M});if(u*1e3<=l)return{decor:i,kind:o}}}voices(t,e,a,n={},s=()=>{}){const i=st.originOf(t);if(!i)return[];const o=new Map,r=new Map,l=Math.max(t.observerTrack.duration,(t.event.durationSeconds??0)*1e3),c=y.ridden(t,e,a,s)?.decor;for(const u of t.decor){const d=u===c?void 0:V.kindOf(u,s(u));if(!d)continue;const h=`${y.ID_PREFIX}${u.id}`;o.set(h,this.trackOf(u,h,i,l)),r.set(h,d)}for(const u of this.tracks.keys())o.has(u)||this.tracks.delete(u);return o.size===0?[]:R.voices(new Set(o.keys()),o,new Map,u=>String(u.icao),a,e,{...n,kindOf:u=>r.get(u)})}trackOf(t,e,a,n){const s=JSON.stringify([t.track,t.eastM,t.northM,t.headingDeg,a.lat,a.lng,n]),i=this.tracks.get(e);if(i?.key===s)return i.track;const o=[];for(let d=0;d<=n;d+=y.STEP_MS)o.push(y.pointAt(t,d,a));(o.length===0||o[o.length-1].t<n)&&o.push(y.pointAt(t,n,a));const r=o[0],l=o[1]??r,c=d=>(l[d]-r[d])/(l.t-r.t||1);for(let d=y.STEP_MS*10;d<=y.LEAD_MS;d+=y.STEP_MS*10)o.unshift({t:-d,lat:r.lat-c("lat")*d,lng:r.lng-c("lng")*d,altitudeFt:Math.max(0,r.altitudeFt-c("altitudeFt")*d)});const u={icao:y.hash(e),nonIcao:!0,points:o};return this.tracks.set(e,{key:s,track:u}),u}static pointAt(t,e,a){const n=Rt(t,e),s=at(n.eastM,-n.northM,a.lat,a.lng);return{t:e,lat:s.lat,lng:s.lng,altitudeFt:n.altitudeM*y.FT_PER_M}}static hash(t){let e=0;for(let a=0;a<t.length;a++)e=e*31+t.charCodeAt(a)>>>0;return e}}class z{static CABIN_DB_A={"airliner-wide":76,"airliner-narrow":78,"regional-jet":78,"business-jet":82,"regional-turboprop":84,"turboprop-light":88,"light-piston":92,"piston-heavy":90,"military-jet":95,ultralight:95,"helicopter-light":95,"helicopter-medium":96,"helicopter-heavy":98,glider:70,balloon:60};static JET_CABINS=["airliner-narrow","airliner-wide","airliner-supersonic","regional-jet","business-jet"];static JET_CABIN_SHAPE_DB=[-3,-4,-13,-24,-33,-36,-42,-55];static DEFAULT_DB_A=78;static voice(t,e={}){const a=it.aircraftOf(t);if(!a)return;const n=M.noiseOfKind(a),s=it.insulationDb(t),i=z.JET_CABINS.includes(a)&&t?.windowsOpen!==!0?z.JET_CABIN_SHAPE_DB.map((c,u)=>c+g.aWeightingDb(g.OCTAVES[u])):n.soundPowerA.map((c,u)=>c-s[u]),o=g.sumDb(i),r=z.levelDbA(a,t?.noise),l=i.map(c=>c-o+r);return{id:"observer:cabin",kind:a,bandAmplitudes:R.bandAmplitudes(l,e.ambientDbA??0,e.referenceAmplitude,{ambientShapeDb:e.ambientShapeDb,expandUnderKnee:e.expandUnderKnee}),levelDbA:r,inside:!0,distanceKm:0,dopplerRatio:1,azimuthDeg:0,elevationDeg:0,character:n.character}}static levelDbA(t,e){return(z.CABIN_DB_A[t]??z.DEFAULT_DB_A)+20*Math.log10(Math.max(e??1,.01))}}class W{static STEP_MS=250;static FT_PER_M=1/.3048;static ID_PREFIX="body:";tracks=new Map;static noiseOf(t){const e=M.noiseOfKind(t.kind),a=t.quieterDb??0;return a===0?e:{...e,id:`${e.id}-${a}dB`,soundPowerA:e.soundPowerA.map(n=>n-a)}}voices(t,e,a,n,s,i,o={}){const r=new Map,l=new Map,c=new Map;for(const d of t){if(!d.sound)continue;const h=`${W.ID_PREFIX}${d.id}`,p=this.trackOf(d,h,e,n,i);p&&(r.set(h,p),l.set(h,d.sound.kind),c.set(h,W.noiseOf(d.sound)))}for(const d of this.tracks.keys())r.has(d)||this.tracks.delete(d);if(r.size===0)return[];const u=at(a.eastM,-a.northM,n.lat,n.lng);return R.voices(new Set(r.keys()),r,new Map,d=>String(d.icao),{lat:u.lat,lng:u.lng,heightM:a.upM},s,{...o,kindOf:d=>l.get(d),noiseOf:d=>c.get(d)})}trackOf(t,e,a,n,s){const i=`${n.lat},${n.lng},${s}`,o=this.tracks.get(e);if(o&&o.body===t&&o.origin===i)return o.track;const r=[];for(let c=-12e4;c<=s;c+=W.STEP_MS){const u=a(t,c);if(!u)continue;const d=at(u.eastM,-u.northM,n.lat,n.lng);r.push({t:c,lat:d.lat,lng:d.lng,altitudeFt:u.upM*W.FT_PER_M})}if(r.length<2)return;const l={icao:W.hash(e),nonIcao:!0,points:r};return this.tracks.set(e,{body:t,origin:i,track:l}),l}static hash(t){let e=0;for(let a=0;a<t.length;a++)e=e*31+t.charCodeAt(a)>>>0;return e}}export{q as AircraftAudio,K as AircraftContrails,U as AircraftModels,Dt as AmbientNoise,W as BodyHearing,z as CabinHearing,y as DecorAircraftHearing,T as TrafficDecor,oe as TrafficInfos,R as TrafficSound,Q as TrafficTooltip,le as UPPER_AIR_SOURCES};
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@rr0/ufoathome",
3
3
  "type": "module",
4
- "version": "0.191.1",
4
+ "version": "0.192.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",
@@ -1,2 +0,0 @@
1
- import{A as et,S as A,L as vt,T as x,R as j,a as N,b as Rt,M as st,D as V,c as it,r as Bt,l as at,O as ot}from"./rr0-scene.mjs";import{C as rt}from"./ContrailGrowth-DwHS8If9.js";const Nt=.25,ct=.4,lt=6,$=12,Ct=3,ht=.2,_t=.2,ut=24,wt=3,Ht=24,dt=1,yt=.7,Pt=1.5,kt=.8,Lt=1.3,pt=.02,Ft=700,jt=-30,mt=.9,Mt=5,Gt=25,Ut=.5,Kt=.12,gt=[.13,.31],zt=.16,Wt=1.6,Vt=3.6,At=1.1,$t=.3,Xt=1e3,bt=.7,Yt=.7;class Z{context;constructor(t){this.context=t}noiseBuffer;roughBuffers=new Map;voices=new Map;bus;reverb;reverbOut;level=1;master;paused=!0;requested=[];headingDeg=0;resume(){if(!this.context){if(typeof AudioContext>"u")return;try{this.context=new AudioContext}catch(t){console.warn("AircraftAudio: Web Audio unavailable, aircraft stay silent:",t);return}}et.isLive(this.context)&&et.unlock(this.context),this.apply()}setLevel(t){this.level=t,this.master&&(this.master.gain.value=t)}setPaused(t){t!==this.paused&&(this.paused=t,this.apply())}setVoices(t,e=0){this.requested=t,this.headingDeg=e,this.apply()}dispose(){for(const t of[...this.voices.keys()])this.release(t);et.isLive(this.context)&&this.context.close(),this.context=void 0,this.master=void 0,this.bus=void 0}apply(){const t=this.context;if(!t)return;const e=this.paused?[]:this.requested,a=new Set(e.map(n=>n.id));for(const n of[...this.voices.keys()])a.has(n)||this.release(n);for(const n of e){const s=this.voices.get(n.id)??this.build(t,n);this.retarget(t,s,n)}}build(t,e){const a=t.createGain();a.gain.value=0;let n;const s=this.busOf(t);typeof t.createStereoPanner=="function"?(n=t.createStereoPanner(),a.connect(n).connect(s)):a.connect(s);const r=t.createGain(),i=e.character?.modulationDepth??0;r.gain.value=1-i/2;const o=t.createOscillator();o.type="sine";const l=t.createGain();l.gain.value=i/2,o.connect(l).connect(r.gain),r.connect(a);const c=t.createBufferSource();c.buffer=this.noise(t),c.loop=!0,c.loopStart=Math.random()*lt*.5;const u=[],d=[],h=[];for(const D of A.OCTAVES){const I=t.createBiquadFilter();I.type="bandpass",I.frequency.value=D,I.Q.value=dt;const w=t.createBiquadFilter();w.type="bandpass",w.frequency.value=D,w.Q.value=dt;const P=t.createGain();P.gain.value=0,c.connect(I).connect(w).connect(P).connect(r),u.push(I),d.push(w),h.push(P)}const p=[];for(const[D,I]of[[e.character?.toneHz,e.character?.toneShare],[e.character?.humHz,e.character?.humShare]])if(D!==void 0)for(let w=1;w<=wt;w++){const P=t.createOscillator();P.type="sine",P.frequency.value=D*w;const tt=t.createGain();tt.gain.value=0,P.connect(tt).connect(a),p.push({oscillator:P,gain:tt,harmonic:w,baseHz:D,share:I??0})}const m=t.createGain();m.gain.value=0,m.connect(a.gain);const f=gt.map(D=>{const I=t.createOscillator();return I.type="sine",I.frequency.value=D,I.connect(m),I}),O=t.createGain();O.gain.value=e.character?.roughness??ht;const v=t.createBufferSource();v.buffer=this.roughTable(t,Ct),v.loop=!0,v.loopStart=Math.random()*$*.5,v.connect(O).connect(r.gain);const B=t.createGain();B.gain.value=(e.character?.roughness??ht)*_t;const S=t.createBufferSource();S.buffer=this.roughTable(t,ut),S.loop=!0,S.loopStart=Math.random()*$*.5,S.connect(B).connect(r.gain);let F;const q=this.busOf(t)&&this.reverb;q&&(F=t.createGain(),F.gain.value=0,a.connect(F).connect(q));let L,_;if(!e.inside&&typeof t.createDelay=="function"){const D=t.createDelay(pt);D.delayTime.value=0;const I=t.createBiquadFilter();I.type="highshelf",I.frequency.value=Ft,I.gain.value=0;const w=t.createGain();w.gain.value=0,a.connect(D).connect(I).connect(w).connect(n??s);const P=t.createGain();P.gain.value=0,_=t.createBufferSource(),_.buffer=this.roughTable(t,ut),_.loop=!0,_.loopStart=Math.random()*$*.5,_.connect(P).connect(D.delayTime),L={delay:D,jitter:P,shelf:I,gain:w}}const k=[c,v,S,o,...p.map(D=>D.oscillator),...f,..._?[_]:[]];for(const D of k)D.start();const J={nodes:[a,r,l,O,B,m,...L?[L.delay,L.jitter,L.shelf,L.gain]:[],...p.map(D=>D.gain),...u,...d,...h,...F?[F]:[],...n?[n]:[],...k],sources:k,filters:u,seconds:d,gains:h,tones:p,lfo:o,lfoDepth:l,wander:f,wanderDepth:m,roughDepth:O,crackleDepth:B,beat:r,output:a,panner:n,send:F,echo:L};return this.voices.set(e.id,J),J}retarget(t,e,a){const n=t.currentTime,s=(p,m)=>p.setTargetAtTime(m,n,Nt),r=Math.min(Pt,Math.max(yt,a.dopplerRatio)),i=Math.min(Lt,Math.max(kt,Math.sqrt(a.dopplerRatio))),o=t.sampleRate*.45,l=a.bandAmplitudes.map((p,m)=>p*Z.unweighting(A.OCTAVES[m])),c=Math.sqrt(l.reduce((p,m)=>p+m*m,0)),u=Math.min(1,Math.max(0,(a.distanceKm-Mt)/(Gt-Mt)));A.OCTAVES.forEach((p,m)=>{s(e.filters[m].frequency,Math.min(o,p*i)),s(e.seconds[m].frequency,Math.min(o,p*i)),s(e.gains[m].gain,l[m]*Math.sqrt(Xt/p))});const d=a.character;for(const{oscillator:p,gain:m,harmonic:f,baseHz:O,share:v}of e.tones){const B=O*f;s(p.frequency,B*r);const S=B*r;s(m.gain,S<o?v*zt*l[Z.bandOf(S)]/f:0)}d?.modulationHz!==void 0&&s(e.lfo.frequency,d.modulationHz*r);const h=c>0?Z.saturated(c)/c:1;if(s(e.output.gain,h*(1-$t*u)),s(e.wanderDepth.gain,h*Kt*u/gt.length),e.send&&s(e.send.gain,Wt*u),e.echo){const p=a.groundEcho;s(e.echo.gain.gain,p?.lowGain??0),p&&(s(e.echo.delay.delayTime,Math.min(pt,p.delayS)),s(e.echo.jitter.gain,p.jitterS),s(e.echo.shelf.gain,p.lowGain>0?Math.max(jt,20*Math.log10(Math.max(p.highGain,1e-6)/p.lowGain)):0))}if(e.panner){const p=(a.azimuthDeg-this.headingDeg)*Math.PI/180,m=a.inside?0:Math.max(-mt,Math.min(mt,Math.sin(p)))*(1-Ut*u);s(e.panner.pan,m)}}static saturated(t){const e=Yt*bt;if(t<=e)return t;const a=bt-e;return e+a*(1-Math.exp(-(t-e)/a))}static unweighting(t){return 10**(Math.min(Ht,Math.max(0,-A.aWeightingDb(t)))/20)}static bandOf(t){let e=0;return A.OCTAVES.forEach((a,n)=>{Math.abs(Math.log(t/a))<Math.abs(Math.log(t/A.OCTAVES[e]))&&(e=n)}),e}roughTable(t,e){const a=this.roughBuffers.get(e);if(a)return a;const n=Math.floor(t.sampleRate*$),s=t.createBuffer(1,n,t.sampleRate),r=s.getChannelData(0),i=Array.from({length:$*e},()=>(Math.random()*2-1)**3),o=t.sampleRate/e;for(let l=0;l<r.length;l++){const c=l/o,u=Math.floor(c),d=c-u,h=d*d*(3-2*d);r[l]=i[u%i.length]*(1-h)+i[(u+1)%i.length]*h}return this.roughBuffers.set(e,s),s}roomImpulse(t){const e=Math.floor(t.sampleRate*Vt),a=t.createBuffer(2,e,t.sampleRate);for(let n=0;n<2;n++){const s=a.getChannelData(n);let r=0;for(let i=0;i<e;i++){const o=i/t.sampleRate,l=.6*Math.exp(-o/(At*2))+.04;r+=l*(Math.random()*2-1-r),s[i]=r*Math.exp(-o/At)}}return a}busOf(t){if(this.bus)return this.bus;const e=t.createGain();if(e.gain.value=this.level,e.connect(t.destination),this.master=e,typeof t.createConvolver=="function"){const a=t.createConvolver();a.buffer=this.roomImpulse(t);const n=t.createGain();n.gain.value=.9,a.connect(n),this.reverb=a,this.reverbOut=n}if(typeof t.createDynamicsCompressor=="function"){const a=t.createDynamicsCompressor();a.threshold.value=-6,a.knee.value=3,a.ratio.value=4,a.attack.value=.005,a.release.value=.25,a.connect(e),this.bus=a}else this.bus=e;return this.reverbOut?.connect(this.bus),this.bus}release(t){const e=this.voices.get(t);if(!e)return;this.voices.delete(t);const a=this.context;a&&(e.output.gain.setTargetAtTime(0,a.currentTime,ct/3),setTimeout(()=>{for(const n of e.sources)try{n.stop()}catch{}for(const n of e.nodes)n.disconnect()},ct*1e3*3))}noise(t){if(this.noiseBuffer)return this.noiseBuffer;const e=t.createBuffer(1,t.sampleRate*lt,t.sampleRate),a=e.getChannelData(0);for(let n=0;n<a.length;n++)a[n]=Math.random()*2-1;return this.noiseBuffer=e,e}}class U{static TYPES={A318:["Airbus A318","airliner-narrow",34.1,31.4],A319:["Airbus A319","airliner-narrow",34.1,33.8],A320:["Airbus A320","airliner-narrow",34.1,37.6],A321:["Airbus A321","airliner-narrow",34.1,44.5],A19N:["Airbus A319neo","airliner-narrow",35.8,33.8],A20N:["Airbus A320neo","airliner-narrow",35.8,37.6],A21N:["Airbus A321neo","airliner-narrow",35.8,44.5],B737:["Boeing 737-700","airliner-narrow",34.3,33.6],B738:["Boeing 737-800","airliner-narrow",35.8,39.5],B739:["Boeing 737-900","airliner-narrow",35.8,42.1],B38M:["Boeing 737 MAX 8","airliner-narrow",35.9,39.5],B39M:["Boeing 737 MAX 9","airliner-narrow",35.9,42.2],B752:["Boeing 757-200","airliner-narrow",38,47.3],B753:["Boeing 757-300","airliner-narrow",38,54.4],B762:["Boeing 767-200","airliner-wide",47.6,48.5],B763:["Boeing 767-300","airliner-wide",47.6,54.9],B764:["Boeing 767-400","airliner-wide",51.9,61.4],B772:["Boeing 777-200","airliner-wide",60.9,63.7],B77L:["Boeing 777-200LR","airliner-wide",64.8,63.7],B77W:["Boeing 777-300ER","airliner-wide",64.8,73.9],B788:["Boeing 787-8","airliner-wide",60.1,56.7],B789:["Boeing 787-9","airliner-wide",60.1,62.8],B78X:["Boeing 787-10","airliner-wide",60.1,68.3],B744:["Boeing 747-400","airliner-wide",64.4,70.7],B748:["Boeing 747-8","airliner-wide",68.4,76.3],A306:["Airbus A300-600","airliner-wide",44.8,54.1],A310:["Airbus A310","airliner-wide",43.9,46.7],A332:["Airbus A330-200","airliner-wide",60.3,58.8],A333:["Airbus A330-300","airliner-wide",60.3,63.7],A338:["Airbus A330-800","airliner-wide",64,58.8],A339:["Airbus A330-900","airliner-wide",64,63.7],A343:["Airbus A340-300","airliner-wide",60.3,63.7],A346:["Airbus A340-600","airliner-wide",63.5,75.4],A359:["Airbus A350-900","airliner-wide",64.8,66.8],A35K:["Airbus A350-1000","airliner-wide",64.8,73.8],A388:["Airbus A380-800","airliner-wide",79.8,72.7],CONC:["Concorde","airliner-supersonic",25.6,61.7],DC3:["Douglas DC-3","piston-heavy",29,19.7],DC4:["Douglas DC-4","piston-heavy",35.8,28.6],P51:["North American P-51 Mustang","piston-heavy",11.3,9.8],E170:["Embraer 170","regional-jet",26,29.9],E75L:["Embraer 175","regional-jet",26,31.7],E75S:["Embraer 175","regional-jet",26,31.7],E190:["Embraer 190","regional-jet",28.7,36.2],E195:["Embraer 195","regional-jet",28.7,38.7],E290:["Embraer 190-E2","regional-jet",33.7,36.2],E295:["Embraer 195-E2","regional-jet",33.7,41.5],CRJ2:["Bombardier CRJ200","regional-jet",21.2,26.8],CRJ7:["Bombardier CRJ700","regional-jet",23.2,32.3],CRJ9:["Bombardier CRJ900","regional-jet",24.9,36.2],CRJX:["Bombardier CRJ1000","regional-jet",26.2,39.1],AT72:["ATR 72","regional-turboprop",27.1,27.2],AT76:["ATR 72-600","regional-turboprop",27.1,27.2],AT45:["ATR 42","regional-turboprop",24.6,22.7],DH8D:["Dash 8 Q400","regional-turboprop",28.4,32.8],DH8C:["Dash 8-300","regional-turboprop",27.4,25.7],SF34:["Saab 340","regional-turboprop",21.4,19.7],B190:["Beechcraft 1900","regional-turboprop",17.7,17.6],C25A:["Cessna CitationJet CJ2","business-jet",14.3,14.4],C56X:["Cessna Citation Excel","business-jet",17.2,16],C68A:["Cessna Citation Latitude","business-jet",22,18.9],C550:["Cessna Citation II","business-jet",15.8,14.4],E55P:["Embraer Phenom 300","business-jet",15.9,15.6],E50P:["Embraer Phenom 100","business-jet",12.3,12.8],GLF5:["Gulfstream G550","business-jet",28.5,29.4],FA7X:["Dassault Falcon 7X","business-jet",26.2,23.4],CL60:["Bombardier Challenger 600","business-jet",19.6,20.9],LJ45:["Learjet 45","business-jet",14.6,17.7],H25B:["Hawker 800","business-jet",15.7,15.6],C172:["Cessna 172","light-piston",11,8.3],C152:["Cessna 152","light-piston",10.2,7.3],C182:["Cessna 182","light-piston",10.9,8.8],P28A:["Piper Cherokee","light-piston",10.7,7.2],PA34:["Piper Seneca","light-piston",11.8,8.7],SR20:["Cirrus SR20","light-piston",10.9,7.9],SR22:["Cirrus SR22","light-piston",11.7,7.9],S22T:["Cirrus SR22T","light-piston",11.7,7.9],DA40:["Diamond DA40","light-piston",11.6,8.1],DA42:["Diamond DA42","light-piston",13.4,8.6],BE20:["Beechcraft King Air 200","turboprop-light",16.6,13.3],BE58:["Beechcraft Baron","light-piston",11.5,9.1],C208:["Cessna Caravan","turboprop-light",15.9,11.5],PC12:["Pilatus PC-12","turboprop-light",16.3,14.4],TBM9:["Daher TBM 900","turboprop-light",12.8,10.7],EC35:["Airbus H135","helicopter-light",10.2,12.1],EC45:["Airbus H145","helicopter-medium",11,13.6],AS50:["Airbus H125","helicopter-light",10.7,12.9],EC30:["Airbus H130","helicopter-light",10.7,12.6],B407:["Bell 407","helicopter-light",10.7,12.7],B06:["Bell 206","helicopter-light",10.2,12],B429:["Bell 429","helicopter-medium",10.9,13],B505:["Bell 505","helicopter-light",10.4,11.9],R44:["Robinson R44","helicopter-light",10.1,11.7],R22:["Robinson R22","helicopter-light",7.7,8.8],A109:["Agusta A109","helicopter-medium",11,13],A139:["Leonardo AW139","helicopter-medium",13.8,16.7],S92:["Sikorsky S-92","helicopter-heavy",17.2,20.9],H60:["Sikorsky UH-60 Black Hawk","helicopter-heavy",16.4,19.8],T38:["Northrop T-38 Talon","military-jet",7.7,14.1],HAWK:["BAE Hawk","military-jet",9.4,11.9],GLID:["Glider","glider",17,7],BALL:["Balloon","balloon",15,20],ULAC:["Ultralight","ultralight",9.5,6],C42:["Ikarus C42","ultralight",9.4,6.3],DRON:["Drone","unmanned",1,.6]};static CATEGORIES={A1:["Light aircraft","light-piston",11,8.3],A2:["Small aircraft","business-jet",15,15],A3:["Large aircraft","airliner-narrow",34.1,37.6],A4:["High-vortex large aircraft","airliner-narrow",38,47.3],A5:["Heavy aircraft","airliner-wide",60.3,63.7],A6:["High-performance aircraft","military-jet",8,14],A7:["Rotorcraft","helicopter-medium",10.7,12.7],B1:["Glider","glider",17,7],B2:["Lighter-than-air","balloon",15,20],B4:["Ultralight","ultralight",9.5,6],B6:["Unmanned aircraft","unmanned",1.5,1]};static GENERIC={name:"Airliner",kind:"airliner-narrow",spanM:34.1,lengthM:37.6,basis:"nothing"};static of(t){const e=t?.type?.toUpperCase(),a=e?U.TYPES[e]:void 0;if(a)return{code:e,name:a[0],kind:a[1],spanM:a[2],lengthM:a[3],basis:"type"};const n=t?.category?U.CATEGORIES[t.category]:void 0;return n?{name:n[0],kind:n[1],spanM:n[2],lengthM:n[3],basis:"category"}:{...U.GENERIC}}static isHelicopter(t){return t.kind.startsWith("helicopter")}}class C{static DUSK_SUN_ELEVATION_DEG=-.83;static ALWAYS=new Set(["airliner-narrow","airliner-wide","airliner-supersonic","regional-turboprop","regional-jet","business-jet"]);static NONE=new Set(["glider","balloon"]);static BRIGHTNESS={"light-piston":[.5,.2,.5],"turboprop-light":[.7,.4,.8],ultralight:[.4,.2,.4],unmanned:[0,.05,0],"helicopter-light":[1,1,1],"helicopter-medium":[1,1,1],"helicopter-heavy":[1,1,1],"military-jet":[1,1,1]};static LANDING_LIGHTS_BELOW_FT=1e4;static LANDING_INTENSITY=600;static LANDING_BEAM_DEG=10;static LANDING_COLOR="#fff1dc";static LANDING_BRIGHTNESS={"airliner-narrow":1,"airliner-wide":1,"airliner-supersonic":1,"regional-jet":.6,"regional-turboprop":.6,"business-jet":.4,"turboprop-light":.2,"light-piston":.1,ultralight:.05,"helicopter-light":.1,"helicopter-medium":.2,"helicopter-heavy":.2};static lampsOn(t,e){if(C.NONE.has(t))return{navigation:!1,beacon:!1,strobes:!1};if(C.ALWAYS.has(t))return{navigation:!0,beacon:!0,strobes:!0};const a=e<C.DUSK_SUN_ELEVATION_DEG;return t==="unmanned"?{navigation:!1,beacon:!1,strobes:a}:{navigation:a,beacon:a,strobes:a}}static lights(t,e){const a=C.lampsOn(t.kind,e),n=t.kind.startsWith("helicopter"),s=vt.find(h=>h.id===(n?"helicopter":"airliner")).create(),[r,i]=n?[5,7]:[17,18],o=t.spanM/2/r,l=t.lengthM/2/i,[c,u,d]=C.BRIGHTNESS[t.kind]??[1,1,1];return s.filter(h=>h.id.startsWith("nav")?a.navigation:h.id.startsWith("strobe")?a.strobes:h.id.startsWith("beacon")?a.beacon:!0).filter(h=>!(h.id.startsWith("beacon")&&!a.beacon)).map(h=>{const p=h.id.startsWith("nav")?c:h.id.startsWith("strobe")?u:d;return{...h,offsetM:{x:h.offsetM.x*o,y:h.offsetM.y,z:h.offsetM.z*l},intensity:(h.intensity??1)*p}}).filter(h=>(h.intensity??1)>0)}static landingLights(t,e,a){const n=C.LANDING_BRIGHTNESS[t.kind]??0;if(n===0||!C.lampsOn(t.kind,e).navigation)return[];const s=c=>c<C.LANDING_LIGHTS_BELOW_FT;if(!a.some(c=>s(c.altitudeFt)))return[];const r=C.LANDING_INTENSITY*n,i=a.flatMap((c,u)=>u>0&&s(c.altitudeFt)!==s(a[u-1].altitudeFt)?[{t:c.t,intensity:s(c.altitudeFt)?r:0}]:[]),o=t.spanM/34,l=t.lengthM/36;return[-1,1].map(c=>({id:c<0?"landing-left":"landing-right",offsetM:{x:c*5*o,y:-1,z:3*l},color:C.LANDING_COLOR,intensity:s(a[0].altitudeFt)?r:0,pattern:{kind:"steady"},beamDeg:C.LANDING_BEAM_DEG,keyframes:i}))}static bodyColor(t){return t.kind==="military-jet"?"#8a8e94":t.kind.startsWith("helicopter")?"#c8ccd1":t.kind==="unmanned"?"#2c2e33":"#dde0e4"}}class Y{static FAMILIES={"amvlab-a320":["A318","A319","A320","A321","A19N","A20N","A21N"],"amvlab-b737":["B732","B733","B734","B735","B736","B737","B738","B739","B37M","B38M","B39M","B3XM"],"amvlab-a350":["A359","A35K"],"amvlab-a380":["A388"],"amvlab-b787":["B788","B789","B78X"]};static BY_TYPE=new Map(Object.entries(Y.FAMILIES).flatMap(([t,e])=>e.map(a=>[a,t])));static idOf(t){return t?Y.BY_TYPE.get(t.toUpperCase()):void 0}}class T{static ID_PREFIX=x.ID_PREFIX;static MAX_OBJECTS=40;static FT_TO_M=.3048;static DEG=Math.PI/180;static from(t,e,a,n=T.MAX_OBJECTS,s={}){return new qt(t,e,a,n,s).build()}static idOf(t,e){return x.idOf(t,e)}static keyOf(t){return x.keyOf(t)}static HEIGHT_OVER_LENGTH=.29;static sizeOf(t){return{widthM:t.spanM,lengthM:t.lengthM,heightM:t.lengthM*T.HEIGHT_OVER_LENGTH}}static offsetOf(t,e){const a=j.seenFrom(t,{lat:e.lat,lng:e.lng,heightM:e.altitudeFt*T.FT_TO_M}),n=a.distanceKm*1e3,s=n*Math.cos(a.altitudeDeg*T.DEG);return{eastM:s*Math.sin(a.azimuthDeg*T.DEG),northM:s*Math.cos(a.azimuthDeg*T.DEG),upM:n*Math.sin(a.altitudeDeg*T.DEG),altitudeDeg:a.altitudeDeg,distanceKm:a.distanceKm}}static segments(t){const e=[];let a=[];for(const n of t.points){const s=a[a.length-1];s&&n.t-s.t>N.MAX_GAP_S*1e3&&(e.push(a),a=[]),a.push(n)}return e.push(a),e.filter(n=>n.length>=2)}static bearingDeg(t,e){return(Math.atan2(e.eastM-t.eastM,e.northM-t.northM)/T.DEG+360)%360}}class qt{constructor(t,e,a,n,s){this.tracks=t,this.observer=e,this.startMs=a,this.maxObjects=n,this.options=s}build(){const t=[];for(const a of this.tracks){const n=T.keyOf(a),s=this.options.models?.get(n)??U.of(void 0);T.segments(a).forEach((r,i)=>{const o=r.map(h=>({point:h,at:T.offsetOf(this.observer,h)}));if(!o.some(h=>h.at.altitudeDeg>=0))return;const l=o.map((h,p)=>({t:h.point.t-this.startMs,eastM:h.at.eastM,northM:h.at.northM,altitudeM:h.at.upM,headingDeg:h.point.trackDeg??(p+1<o.length?T.bearingDeg(h.at,o[p+1].at):T.bearingDeg(o[p-1].at,h.at))})),c=T.idOf(a,i),u=o[Math.floor(o.length/2)].point,d=this.options.sunElevationAt?.(u)??90;t.push({object:{id:c,kind:"aircraft",eastM:l[0].eastM,northM:l[0].northM,headingDeg:l[0].headingDeg,sizeM:T.sizeOf(s),model:Y.idOf(s.code)?{id:Y.idOf(s.code)}:void 0,color:C.bodyColor(s),lights:[...C.lights(s,d),...C.landingLights(s,d,r.map(h=>({t:h.t-this.startMs,altitudeFt:h.altitudeFt})))],track:l},presence:{fromMs:l[0].t,untilMs:l[l.length-1].t},flight:{icao:a.icao,nonIcao:a.nonIcao,points:r},closestKm:Math.min(...o.map(h=>h.at.distanceKm))})})}t.sort((a,n)=>a.closestKm-n.closestKm);const e=t.slice(0,this.maxObjects);return{objects:e.map(a=>a.object),presence:new Map(e.map(a=>[a.object.id,a.presence])),flights:new Map(e.map(a=>[a.object.id,a.flight])),total:t.length,shown:e.length}}}const Jt=[[20,0],[120,0],[130,1.5],[140,4],[150,7.5],[160,7.5]],xt=[[20,1.5],[40,1],[60,1],[80,0],[120,0],[130,1],[140,1],[150,-3],[160,-6.5],[170,-12]],ft=.16,Zt=1,Qt=[[0,-2],[10,-1],[20,0],[40,0],[50,-2],[60,-4.5],[70,-7.5],[80,-11],[90,-15],[100,-19.5],[110,-25]],te=[[60,-15.8],[70,-11.5],[80,-8],[90,-5],[100,-2.7],[110,-1.2],[120,-.3],[130,0],[140,-2],[150,-6],[160,-10],[170,-15],[180,-20]],ee=1.5,Et=-40,ae=1.5,ne={takeoff:{jetMps:300,flightMps:80,jetShare:[1,1,.9,.6,.3,.1,0,0]},overflight:{jetMps:280,flightMps:130,jetShare:[1,1,.9,.6,.3,.1,0,0]},approach:{jetMps:180,flightMps:70,jetShare:[.6,.5,.4,.2,.1,0,0,0]}};class H{static bandsDb(t,e,a=340){const n=ne[e],s=H.fan(t)-H.fan(90),r=.62*Math.max(0,n.jetMps-n.flightMps)/a,i=-30*Math.log10(1+r/(1+r**5)**.2*Math.cos(t*Math.PI/180));return A.OCTAVES.map((o,l)=>{const c=i+H.jetRemainder(t,o*ae/n.jetMps),u=n.jetShare[l];return 10*Math.log10(u*10**(c/10)+(1-u)*10**(s/10))})}static loudestDb(t){const e=H.loudest.get(t);if(e)return e;const a=A.OCTAVES.map(()=>-1/0);for(let n=0;n<=180;n+=5)H.bandsDb(n,t).forEach((s,r)=>a[r]=Math.max(a[r],s));return H.loudest.set(t,a),a}static loudest=new Map;static angleDeg(t,e){const a=t.reduce((s,r,i)=>s+r*e[i],0),n=Math.hypot(...t)*Math.hypot(...e);return n===0?90:Math.acos(Math.min(1,Math.max(-1,a/n)))*180/Math.PI}static fan(t){const e=H.read(Qt,t,!0),a=H.read(te,t,!0)+ee;return 10*Math.log10(10**(e/10)+10**(a/10))}static jetRemainder(t,e){const a=Math.min(1,Math.max(0,Math.log(e/ft)/Math.log(Zt/ft)));return(1-a)*H.read(Jt,t)+a*H.read(xt,t)}static read(t,e,a=!1){const[n,s]=[t[0],t[1]],[r,i]=[t[t.length-2],t[t.length-1]];if(e<=n[0])return a?Math.max(Et,n[1]+(s[1]-n[1])/(s[0]-n[0])*(e-n[0])):n[1];if(e>=i[0])return a?Math.max(Et,i[1]+(i[1]-r[1])/(i[0]-r[0])*(e-i[0])):i[1];for(let o=1;o<t.length;o++){const[l,c]=[t[o-1],t[o]];if(e<=c[0])return l[1]+(c[1]-l[1])*(e-l[0])/(c[0]-l[0])}return i[1]}}class g{static GRASS={flowResistivityKPa:200,earHeightM:1.6};static COHERENCE=.4;static JITTER_S=1e-4;static ECHO_UNDER_S=5e-4;static ECHO_FROM_S=.0015;static LOW_HZ=125;static HIGH_HZ=2e3;static AIR_DENSITY=1.2;static reflection(t,e,a=g.GRASS){const[n,s]=g.impedance(t,a);return g.reflected(n,s,Math.sin(Math.max(0,e)*Math.PI/180))}static impedance(t,e=g.GRASS){const a=g.AIR_DENSITY*t/(e.flowResistivityKPa*1e3);return[1+.0571*a**-.754,-.087*a**-.732]}static reflected(t,e,a){const[n,s,r,i]=[t*a-1,e*a,t*a+1,e*a],o=r*r+i*i;return{re:(n*r+s*i)/o,im:(s*r-n*i)/o}}static delayS(t,e=g.GRASS,a=340){return 2*e.earHeightM*Math.sin(Math.max(0,t)*Math.PI/180)/a}static excessDb(t,e=g.GRASS,a=340){const n=`${e.flowResistivityKPa}|${e.earHeightM}|${a}`;let s=g.overheads.get(n);return s||g.overheads.set(n,s=g.bandsDb(90,e,a)),g.bandsDb(t,e,a).map((r,i)=>r-s[i])}static echo(t,e=g.GRASS,a=340){const n=g.delayS(t,e,a);if(n<=g.ECHO_UNDER_S)return;const s=Math.min(1,(n-g.ECHO_UNDER_S)/(g.ECHO_FROM_S-g.ECHO_UNDER_S)),r=s*s*(3-2*s),i=o=>{const l=g.reflection(o,t,e);return r*g.COHERENCE*Math.hypot(l.re,l.im)};return{delayS:n,lowGain:i(g.LOW_HZ),highGain:i(g.HIGH_HZ),jitterS:g.JITTER_S}}static overheads=new Map;static thirds=A.OCTAVES.map(t=>[-1,0,1].map(e=>{const a=t*2**(e/3);return{middle:a,from:a*2**(-1/6),to:a*2**(1/6)}}));static impedances=new Map;static bandsDb(t,e,a){const n=g.delayS(t,e,a),s=g.COHERENCE,r=Math.sin(Math.max(0,t)*Math.PI/180);let i=g.impedances.get(e.flowResistivityKPa);return i||g.impedances.set(e.flowResistivityKPa,i=g.thirds.map(o=>o.map(l=>g.impedance(l.middle,e)))),g.thirds.map((o,l)=>{let c=0;return o.forEach((u,d)=>{const h=g.reflected(i[l][d][0],i[l][d][1],r),p=2*Math.PI*n*(u.to-u.from),[m,f]=p<1e-9?[1,0]:[(Math.sin(2*Math.PI*u.to*n)-Math.sin(2*Math.PI*u.from*n))/p,(Math.cos(2*Math.PI*u.from*n)-Math.cos(2*Math.PI*u.to*n))/p];c+=1+h.re*h.re+h.im*h.im+2*s*(h.re*m+h.im*f)}),10*Math.log10(c/o.length)})}}const X={takeoff:{shapeDb:[10,3,-3,-2,-2,-2,5,4],levelDb:0},approach:{shapeDb:[0,0,0,0,0,0,0,0],levelDb:-8}},se={takeoff:{shapeDb:[0,0,0,0,0,0,0,0],levelDb:0},approach:{shapeDb:[0,0,0,0,0,0,0,0],levelDb:-8}},Tt=[{id:"turbofan-narrow-body",name:"Turbofan airliner, narrow-body",kinds:["airliner-narrow"],totalDbA:148,shapeDb:[-32,-17,-9,-6,-5,-7,-12,-22],character:{toneHz:1800,toneShare:.3,humHz:90,humShare:.7},regimes:X},{id:"turbojet-supersonic",name:"Supersonic turbojet airliner",kinds:["airliner-supersonic"],totalDbA:169.5,shapeDb:[-22,-13,-9,-6,-6,-9,-15,-25],character:{humHz:100,humShare:.7},regimes:se},{id:"turbofan-wide-body",name:"Turbofan airliner, wide-body",kinds:["airliner-wide"],totalDbA:151,shapeDb:[-28,-14,-7,-4,-3,-6,-12,-22],character:{toneHz:1200,toneShare:.3,humHz:70,humShare:.7},regimes:X},{id:"regional-jet",name:"Regional jet",kinds:["regional-jet"],totalDbA:144,shapeDb:[-32,-17,-9,-5,-4,-6,-11,-21],character:{toneHz:1900,toneShare:.3,humHz:95,humShare:.7},regimes:X},{id:"business-jet",name:"Business jet",kinds:["business-jet"],totalDbA:141,shapeDb:[-30,-15,-8,-4,-3,-4,-9,-19],character:{toneHz:2500,toneShare:.25,humHz:110,humShare:.7},regimes:X},{id:"turboprop",name:"Turboprop",kinds:["regional-turboprop","turboprop-light"],totalDbA:138,shapeDb:[-14,-9,-8,-6,-8,-13,-20,-28],character:{toneHz:80,toneShare:.5}},{id:"light-piston",name:"Light piston aircraft",kinds:["light-piston"],totalDbA:130,shapeDb:[-20,-10,-3,-6,-10,-20,-27,-42],character:{toneHz:80,toneShare:.4,modulationHz:80,modulationDepth:.4}},{id:"piston-heavy",name:"Heavy piston aircraft",kinds:["piston-heavy"],totalDbA:140,shapeDb:[-31,-12,-11,-9,-7,-6,-7,-11],character:{toneHz:84,toneShare:.4,modulationHz:84,modulationDepth:.36}},{id:"ultralight",name:"Ultralight",kinds:["ultralight"],totalDbA:124,shapeDb:[-16,-8,-5,-4,-9,-15,-23,-31],character:{toneHz:140,toneShare:.4}},{id:"helicopter-light",name:"Light helicopter",kinds:["helicopter-light"],totalDbA:134,shapeDb:[-15,-8,-4,-3,-6,-10,-16,-24],character:{modulationHz:20,modulationDepth:.5}},{id:"helicopter-medium",name:"Medium helicopter",kinds:["helicopter-medium"],totalDbA:138,shapeDb:[-14,-7,-4,-3,-6,-10,-16,-24],character:{modulationHz:22,modulationDepth:.5}},{id:"helicopter-heavy",name:"Heavy helicopter",kinds:["helicopter-heavy"],totalDbA:144,shapeDb:[-12,-6,-4,-4,-7,-11,-17,-25],character:{modulationHz:17,modulationDepth:.5}},{id:"military-jet",name:"Military jet",kinds:["military-jet"],totalDbA:152,shapeDb:[-26,-12,-6,-3,-2,-3,-7,-15]},{id:"glider",name:"Glider",kinds:["glider"],totalDbA:85,shapeDb:[-30,-22,-15,-10,-8,-8,-14,-22]},{id:"balloon",name:"Hot-air balloon",kinds:["balloon"],totalDbA:100,shapeDb:[-25,-15,-9,-5,-3,-6,-12,-20]},{id:"unmanned",name:"Unmanned aircraft",kinds:["unmanned"],totalDbA:88,shapeDb:[-40,-30,-20,-12,-6,-3,-3,-8],character:{toneHz:450,toneShare:1}}],St=(b,t)=>b.map(e=>e+t-A.sumDb(b));function ie(b,t){if(!b)return;const e=t.toneRatio??1,a=t.toneGain??1;return{...b,...b.toneHz!==void 0?{toneHz:b.toneHz*e,toneShare:Math.min(1,(b.toneShare??0)*a)}:{},...b.humHz!==void 0?{humHz:b.humHz*e,humShare:Math.min(1,(b.humShare??0)*a)}:{}}}const Dt=Tt.map(b=>{const t=b.regimes===X?"turbofan":void 0,e={id:b.id,name:b.name,soundPowerA:St(b.shapeDb,b.totalDbA),character:b.character,directivity:t};if(!b.regimes)return e;const a={overflight:e};for(const[n,s]of Object.entries(b.regimes))a[n]={id:`${b.id}-${n}`,name:`${b.name}, ${n}`,soundPowerA:St(b.shapeDb.map((r,i)=>r+s.shapeDb[i]),b.totalDbA+s.levelDb),character:ie(b.character,s),directivity:t};return{...e,regimes:a}});class M{static DEFAULT_AMBIENT_DB_A=35;static DETECTION_MARGIN_DB=3;static AMBIENT_SHAPE_DB=Rt.OUTDOOR_SHAPE_DB;static HEARING_FLOOR_DB_A=0;static ITERATIONS=30;static CONVERGED_MS=.5;static VELOCITY_STEP_MS=500;static CLIMB_MPS=2.5;static DESCENT_MPS=1.5;static LOW_M=3e3;static CLIMB_SPAN_MS=3e4;static noiseOfKind(t){const e=Tt.find(a=>a.kinds.includes(t));return Dt.find(a=>a.id===(e?.id??"turbofan-narrow-body"))}static bandsAt(t,e,a=A.STANDARD){const n=20*Math.log10(Math.max(e*1e3,1))+11;return A.OCTAVES.map((s,r)=>t.soundPowerA[r]-n-A.absorptionDbPerKm(s,a)*e)}static couldBeHeard(t,e,a=M.DEFAULT_AMBIENT_DB_A,n=A.STANDARD,s){const r=M.ambientBands(a,s);return Object.entries(t.regimes??{overflight:t}).some(([o,l])=>M.bandsAt(l,e,n).map((c,u)=>c+(l.directivity==="turbofan"?H.loudestDb(o)[u]:0)).some((c,u)=>c>=Math.max(r[u]+M.DETECTION_MARGIN_DB,M.HEARING_FLOOR_DB_A)))}static ambientBands(t,e=M.AMBIENT_SHAPE_DB){const a=A.sumDb(e);return e.map(n=>t+n-a)}static heardAt(t,e,a,n={}){const s=n.air??A.STANDARD,r=A.speedOfSound(s.temperatureC),i=t.points[t.points.length-1]?.t;if(i===void 0)return;let o=Math.min(a,i),l=N.positionAt(t,o);if(!l)return;let c=j.seenFrom(e,l.geo);for(let _=0;_<M.ITERATIONS;_++){const k=a-c.distanceKm*1e3*1e3/r,J=Math.abs(k-o);if(o=k,l=N.positionAt(t,o),!l)return;if(c=j.seenFrom(e,l.geo),J<M.CONVERGED_MS)break}const u=N.positionAt(t,a),d=u?j.seenFrom(e,u.geo):c,h=M.regimeAt(t,o,e),p=M.inRegime(n.noise??Dt[0],h),m=n.ambientDbA??M.DEFAULT_AMBIENT_DB_A,f=M.ambientBands(m,n.ambientShapeDb),O=M.emissionAngle(t,e,o),v=p.directivity==="turbofan"?H.bandsDb(O,h,r):void 0,B=n.ground===null?A.OCTAVES.map(()=>0):g.excessDb(c.altitudeDeg,n.ground,r),S=M.bandsAt(p,c.distanceKm,s).map((_,k)=>_+(v?.[k]??0)+B[k]),F=S.map((_,k)=>_>=Math.max(f[k]+M.DETECTION_MARGIN_DB,M.HEARING_FLOOR_DB_A)),q=S.indexOf(Math.max(...S)),L=F.lastIndexOf(!0);return{track:t,audible:F.some(Boolean),levelDbA:A.sumDb(S),bandsDbA:S,ambientDbA:m,delayS:(a-o)/1e3,emittedAtMs:o,sound:c,seen:d,lagDeg:M.angleBetween(c,d),dopplerRatio:M.doppler(t,e,o,r),dominantHz:A.OCTAVES[q],cutoffHz:L<0?void 0:A.OCTAVES[L],regime:h,noise:p,emissionAngleDeg:O}}static emissionAngle(t,e,a){const n=M.VELOCITY_STEP_MS,s=N.positionAt(t,a-n),r=N.positionAt(t,a+n),i=N.positionAt(t,a);if(!s||!r||!i)return 90;const o=d=>{const h=j.seenFrom(e,d),p=h.altitudeDeg*Math.PI/180,m=h.azimuthDeg*Math.PI/180,f=h.distanceKm*1e3;return[f*Math.cos(p)*Math.sin(m),f*Math.cos(p)*Math.cos(m),f*Math.sin(p)]},[l,c,u]=[o(s.geo),o(r.geo),o(i.geo)];return H.angleDeg(c.map((d,h)=>d-l[h]),u.map(d=>-d))}static regimeAt(t,e,a){const n=M.CLIMB_SPAN_MS,s=N.positionAt(t,e-n)??N.positionAt(t,e),r=N.positionAt(t,e+n)??N.positionAt(t,e),i=N.positionAt(t,e);if(!s||!r||!i)return"overflight";const o=(Math.min(e+n,t.points[t.points.length-1].t)-Math.max(e-n,t.points[0].t))/1e3;if(o<=0)return"overflight";const l=(r.altitudeFt-s.altitudeFt)*.3048/o;return i.altitudeFt*.3048-a.heightM>M.LOW_M?"overflight":l>M.CLIMB_MPS?"takeoff":l<-1.5?"approach":"overflight"}static inRegime(t,e){return t.regimes?.[e]??t}static profile(t,e,a,n,s=2e3,r={}){const i=[];let o,l,c=a;for(let u=a;u<=n;u+=s){const d=M.heardAt(t,e,u,r);d&&(!l||d.levelDbA>l.levelDbA)&&(l=d,c=u),d?.audible?o?o.untilMs=u:i.push(o={fromMs:u,untilMs:u}):o=void 0}return{track:t,audible:i,peakDbA:l?.levelDbA??-1/0,peakAtMs:c,peakDelayS:l?.delayS??0}}static angleBetween(t,e){const a=c=>{const u=c.altitudeDeg*Math.PI/180,d=c.azimuthDeg*Math.PI/180;return[Math.cos(u)*Math.sin(d),Math.cos(u)*Math.cos(d),Math.sin(u)]},[n,s,r]=a(t),[i,o,l]=a(e);return Math.acos(Math.min(1,Math.max(-1,n*i+s*o+r*l)))*180/Math.PI}static doppler(t,e,a,n){const s=M.VELOCITY_STEP_MS,r=N.positionAt(t,a-s),i=N.positionAt(t,a+s);if(!r||!i)return 1;const o=j.seenFrom(e,r.geo).distanceKm*1e3,l=j.seenFrom(e,i.geo).distanceKm*1e3;return 1/(1-(o-l)/(2*s/1e3)/n)}}class ue{static at(t,e,a,n,s={}){const r=N.seenFrom(t,a,n);if(!r)return;const i=U.of(e),o=M.heardAt(t,a,n,{noise:M.noiseOfKind(i.kind),...s});return{hex:`${t.nonIcao?"~":""}${t.icao.toString(16).padStart(6,"0")}`,registration:e?.registration,typeCode:i.code??e?.type,name:i.basis==="nothing"?void 0:i.name,kind:i.kind,basis:i.basis,military:e?.military===!0,restricted:e?.restricted===!0,altitudeFt:r.altitudeFt,groundSpeedKt:r.groundSpeedKt,trackDeg:r.trackDeg,sky:r.sky,angularRateDegPerS:r.angularRateDegPerS,hearing:o&&{audible:o.audible,levelDbA:o.levelDbA,ambientDbA:o.ambientDbA,delayS:o.delayS,lagDeg:o.lagDeg,dopplerRatio:o.dopplerRatio,cutoffHz:o.cutoffHz,dominantHz:o.dominantHz}}}}class R{static REFERENCE_AMPLITUDE=.02;static MASKING_RANGE_DB=6;static KNEE_DB=20;static COMPRESSION_RATIO=1;static EXPANSION_RATIO=1.8;static HEADROOM_DB=Rt.HEADROOM_DB;static DEFAULT_MAX_VOICES=4;static candidates(t,e,a,n,s={}){const r=new Set;for(const[i,o]of t){const l=M.noiseOfKind(U.of(e.get(a(o))).kind);let c=1/0;for(const u of o.points)c=Math.min(c,j.seenFrom(n,{lat:u.lat,lng:u.lng,heightM:u.altitudeFt*.3048}).distanceKm);M.couldBeHeard(l,c,s.ambientDbA,s.air,s.ambientShapeDb)&&r.add(i)}return r}static voices(t,e,a,n,s,r,i={}){const o=[];for(const l of t){const c=e.get(l);if(!c||i.only?.(l)===!1)continue;const u=i.kindOf?.(l)??U.of(a.get(n(c))).kind,d=i.noiseOf?.(l)??M.noiseOfKind(u),h=M.heardAt(c,s,r,{...i,noise:d});if(!h?.audible)continue;const p=i.throughDb,m=p?h.bandsDbA.map((f,O)=>f-(p[O]??0)):h.bandsDbA;p&&!R.noticed(m,h.ambientDbA,i.ambientShapeDb)||o.push({id:l,kind:u,bandAmplitudes:R.bandAmplitudes(m,h.ambientDbA,i.referenceAmplitude,{ambientShapeDb:i.ambientShapeDb,expandUnderKnee:i.expandUnderKnee}),levelDbA:p?A.sumDb(m):h.levelDbA,distanceKm:h.sound.distanceKm,dopplerRatio:h.dopplerRatio,azimuthDeg:h.sound.azimuthDeg,elevationDeg:h.sound.altitudeDeg,character:h.noise.character,groundEcho:i.ground===null?void 0:g.echo(h.sound.altitudeDeg,i.ground,A.speedOfSound((i.air??A.STANDARD).temperatureC))})}return o.sort((l,c)=>c.levelDbA-l.levelDbA).slice(0,i.maxVoices??R.DEFAULT_MAX_VOICES)}static noticed(t,e,a){const n=M.ambientBands(e,a);return t.some((s,r)=>s>=n[r]+M.DETECTION_MARGIN_DB)}static bandAmplitudes(t,e,a=R.REFERENCE_AMPLITUDE,n={}){const s=M.ambientBands(e,n.ambientShapeDb),r=n.expandUnderKnee===!1?1:R.EXPANSION_RATIO,i=M.DETECTION_MARGIN_DB,o=A.sumDb(t),l=o-e,c=l>=R.KNEE_DB?R.KNEE_DB+(l-R.KNEE_DB)/R.COMPRESSION_RATIO:R.KNEE_DB-(R.KNEE_DB-l)*r,u=a*10**((c-R.HEADROOM_DB)/20);return t.map((d,h)=>{const p=Math.min(1,Math.max(0,(d-s[h]-i+R.MASKING_RANGE_DB)/(2*R.MASKING_RANGE_DB)));return p*p*(3-2*p)*u*10**((d-o)/20)})}static BANDS_HZ=A.OCTAVES}class Q{static RUMBLE_BELOW_HZ=500;static DULL_BELOW_HZ=2e3;static PITCH_NOTICED=.03;static text(t,e,a,n){const s=(d,h=0)=>d.toLocaleString(n,{maximumFractionDigits:h}),r=(d,h)=>d.replace(/\{(\w+)\}/g,(p,m)=>h[m]??`{${m}}`),i=[],o=[t.registration,t.name].filter(Boolean).join(" · ");i.push(o||r(e.unnamed,{hex:t.hex}));const l=[r(e.altitude,{value:s(Math.round(t.altitudeFt/100)*100)}),t.groundSpeedKt===void 0?void 0:r(e.speed,{value:s(Math.round(t.groundSpeedKt))}),t.trackDeg===void 0?void 0:r(e.heading,{value:s(Math.round(t.trackDeg))})].filter(Boolean);i.push(l.join(" · ")),i.push(r(e.position,{distance:s(t.sky.distanceKm,t.sky.distanceKm<10?1:0),elevation:s(Math.round(t.sky.altitudeDeg)),bearing:a(t.sky.azimuthDeg)}));const c=t.hearing;if(!c)i.push(e.soundUnknown);else if(!c.audible)i.push(r(e.inaudible,{level:s(Math.round(c.levelDbA)),ambient:s(Math.round(c.ambientDbA))}));else{const d=c.cutoffHz??0,h=d<=Q.RUMBLE_BELOW_HZ?e.rumble:d<=Q.DULL_BELOW_HZ?e.muffled:e.broad,p=c.dopplerRatio-1,m=Math.abs(p)<Q.PITCH_NOTICED?"":r(p>0?e.pitchHigher:e.pitchLower,{percent:s(Math.round(Math.abs(p)*100))});i.push(r(e.heard,{level:s(Math.round(c.levelDbA)),delay:s(Math.round(c.delayS)),lag:s(Math.round(c.lagDeg)),character:r(h,{cutoff:s(d)}),pitch:m}))}t.contrail&&i.push(r(t.contrail.persistent?e.contrailPersistent:e.contrailShort,{rhi:s(Math.round(t.contrail.iceRelativeHumidity*100))}));const u=[t.military?e.military:void 0,t.restricted?e.restricted:void 0].filter(Boolean);return u.length>0&&i.push(u.join(" · ")),i.push(e.candidate),i.join(`
2
- `)}}class nt{static EFFICIENCY={"airliner-narrow":.34,"airliner-wide":.38,"regional-jet":.32,"business-jet":.3,"military-jet":.22,unknown:.34};static efficiencyOf(t){return nt.EFFICIENCY[t]}}class E{static EMISSION_INDEX_WATER=1.25;static COMBUSTION_HEAT=432e5;static AIR_HEAT_CAPACITY=1004;static MOLAR_MASS_RATIO=.622;static FT_TO_M=.3048;static TROPOPAUSE_M=11e3;static TROPOPAUSE_HPA=226.32;static ISOTHERMAL_SCALE_HEIGHT_M=6341.62;static pressureAtAltitudeFt(t){const e=t*E.FT_TO_M;return e<=E.TROPOPAUSE_M?1013.25*(1-225577e-10*e)**5.25588:E.TROPOPAUSE_HPA*Math.exp(-(e-E.TROPOPAUSE_M)/E.ISOTHERMAL_SCALE_HEIGHT_M)}static saturationOverWaterPa(t){const e=t+273.15;return Math.exp(54.842763-6763.22/e-4.21*Math.log(e)+367e-6*e+Math.tanh(.0415*(e-218.8))*(53.878-1331.22/e-9.44523*Math.log(e)+.014025*e))}static saturationOverIcePa(t){const e=t+273.15;return Math.exp(9.550426-5723.265/e+3.53068*Math.log(e)-.00728332*e)}static iceRelativeHumidity(t,e){return e*E.saturationOverWaterPa(t)/E.saturationOverIcePa(t)}static mixingSlope(t,e){return E.EMISSION_INDEX_WATER*E.AIR_HEAT_CAPACITY*t*100/(E.MOLAR_MASS_RATIO*E.COMBUSTION_HEAT*(1-e))}static criticalTemperatureC(t,e){const a=Math.log(E.mixingSlope(t,e)-.053);return-46.46+9.43*a+.72*a*a}static requiredHumidity(t,e,a){const n=E.criticalTemperatureC(t,e);return(E.mixingSlope(t,e)*(a-n)+E.saturationOverWaterPa(n))/E.saturationOverWaterPa(a)}static evaluate(t,e){const a=E.criticalTemperatureC(t.pressureHpa,e),n=E.requiredHumidity(t.pressureHpa,e,t.temperatureC),s=E.iceRelativeHumidity(t.temperatureC,t.relativeHumidity),r=t.temperatureC<a&&t.relativeHumidity>=n;return{forms:r,persistent:r&&s>=1,criticalTemperatureC:a,requiredHumidity:n,iceRelativeHumidity:s}}}class G{static HOLD_MS=36e5;static DEG=Math.PI/180;static GAS_CONSTANT_OVER_GRAVITY=287.05/9.80665;static at(t,e,a){if(t.length===0)return;const n=t[0],s=t[t.length-1];if(e<n.t-G.HOLD_MS||e>s.t+G.HOLD_MS)return;const r=t.findIndex(h=>h.t>e),i=r===0?t[0]:t[(r===-1?t.length:r)-1],o=r===-1||r===0?i:t[r],l=G.atLevel(i,a),c=G.atLevel(o,a);if(!l||!c)return;const u=o.t>i.t?Math.min(1,Math.max(0,(e-i.t)/(o.t-i.t))):0,d=(h,p)=>h+(p-h)*u;return{pressureHpa:a,temperatureC:d(l.temperatureC,c.temperatureC),relativeHumidity:d(l.relativeHumidity,c.relativeHumidity),driftEastMs:d(l.driftEastMs,c.driftEastMs),driftNorthMs:d(l.driftNorthMs,c.driftNorthMs),shearPerS:d(l.shearPerS,c.shearPerS)}}static atLevel(t,e){const a=t.levels;for(let n=0;n+1<a.length;n++){const s=a[n],r=a[n+1];if(e>s.pressureHpa||e<r.pressureHpa)continue;const i=(Math.log(s.pressureHpa)-Math.log(e))/(Math.log(s.pressureHpa)-Math.log(r.pressureHpa)),o=(h,p)=>h+(p-h)*i,l=h=>{const p=h.windFromDeg*G.DEG;return{east:-h.windSpeedMs*Math.sin(p),north:-h.windSpeedMs*Math.cos(p)}},c=l(s),u=l(r),d=G.GAS_CONSTANT_OVER_GRAVITY*((s.temperatureC+r.temperatureC)/2+273.15)*Math.log(s.pressureHpa/r.pressureHpa);return{pressureHpa:e,temperatureC:o(s.temperatureC,r.temperatureC),relativeHumidity:o(s.relativeHumidity,r.relativeHumidity),driftEastMs:o(c.east,u.east),driftNorthMs:o(c.north,u.north),shearPerS:Math.hypot(u.east-c.east,u.north-c.north)/d}}}}class K{static MIN_ALTITUDE_FT=2e4;static DENSE_MS=3e5;static SPARSE_STEP_MS=6e4;static SATURATION_HORIZON_MS=3*36e5;static SATURATION_STEP_MS=6e5;static PRESSURE_STEP_HPA=5;static plan(t,e,a,n){if(a.length===0)return[];const s=[],r=new Map,i=(o,l,c)=>{const u=Math.round(l/K.PRESSURE_STEP_HPA)*K.PRESSURE_STEP_HPA,d=K.SATURATION_STEP_MS,h=Math.floor(o/d)*d,p=`${u}|${h}`,m=r.get(p);if(m!==void 0)return m+(h-o)/1e3;let f=1/0;for(let O=d;O<=K.SATURATION_HORIZON_MS;O+=d){const v=G.at(a,h+O,u);if(!v)break;if(E.evaluate(v,c).iceRelativeHumidity<1){f=O/1e3;break}}return r.set(p,f),f+(h-o)/1e3};for(const o of t.objects){const l=t.flights.get(o.id),c=o.track;if(!l||!c||c.length!==l.points.length)continue;const u=e?.get(x.keyOf(l))??U.of(void 0),d=nt.efficiencyOf(u.kind);if(d===void 0)continue;const h=[];let p=-1/0;c.forEach((m,f)=>{if(m.t<-K.DENSE_MS&&f+1<c.length&&m.t-p<K.SPARSE_STEP_MS)return;p=m.t;const O=l.points[f],v=E.pressureAtAltitudeFt(O.altitudeFt),B=G.at(a,n+m.t,v),S=B&&E.evaluate(B,d);h.push({tMs:m.t,eastM:m.eastM,northM:m.northM,upM:m.altitudeM??0,forms:S?.forms??!1,persistent:S?.persistent??!1,lifetimeS:S?rt.lifetimeS(S.iceRelativeHumidity):0,driftEastMs:B?.driftEastMs??0,driftNorthMs:B?.driftNorthMs??0,shearPerS:B?.shearPerS??rt.TYPICAL_SHEAR_PER_S,iceRelativeHumidity:S?.iceRelativeHumidity??0,saturatedForS:S?.persistent?i(n+m.t,v,d):0})}),h.some((m,f)=>m.forms&&h[f+1]?.forms)&&s.push({id:o.id,spanM:u.spanM,points:h})}return s}}const Ot=[500,400,300,250,200,150],oe=["temperature","relative_humidity","wind_speed","wind_direction"],re="2022-01-01",It=.25;class ce{fetchImpl;baseUrl;cache=new Map;constructor(t={}){this.fetchImpl=t.fetchImpl??fetch.bind(globalThis),this.baseUrl=t.baseUrl??"https://historical-forecast-api.open-meteo.com/v1/forecast"}between(t,e,a){const n=new Date(e).toISOString().slice(0,10);if(n<re)return Promise.resolve({status:"outside"});const s=new Date(a).toISOString().slice(0,10),i=`${`${Math.round(t.lat/It)},${Math.round(t.lng/It)}`}|${n}|${s}`;let o=this.cache.get(i);return o||(o=this.read(t,n,s),this.cache.set(i,o),o.then(l=>{l.status==="failed"&&this.cache.delete(i)})),o}async read(t,e,a){const n=Ot.flatMap(i=>oe.map(o=>`${o}_${i}hPa`)),s=new URLSearchParams({latitude:String(t.lat),longitude:String(t.lng),start_date:e,end_date:a,hourly:n.join(","),wind_speed_unit:"ms",timezone:"UTC"}),r=`${this.baseUrl}?${s}`;try{const i=await this.fetchImpl(r);if(!i.ok)return{status:"failed"};const o=await i.json();return this.decode(o,{id:"open-meteo-forecast",name:"Open-Meteo (historical forecast)",url:r})}catch{return{status:"failed"}}}decode(t,e){const a=t.hourly;if(!a?.time)return{status:"outside"};const n=[];return a.time.forEach((s,r)=>{const i=[];for(const o of Ot){const l=p=>a[`${p}_${o}hPa`]?.[r],c=l("temperature"),u=l("relative_humidity"),d=l("wind_speed"),h=l("wind_direction");if([c,u,d,h].some(p=>p==null))return;i.push({pressureHpa:o,temperatureC:c,relativeHumidity:u/100,windSpeedMs:d,windFromDeg:h})}n.push({t:Date.parse(`${s}Z`),levels:i})}),n.length>0?{status:"found",samples:n,source:e}:{status:"outside"}}}const de=st.point("upperAir").provide(st.BUILT_IN,[{id:"open-meteo-forecast",name:"Open-Meteo (historical forecast)",credit:"Weather data by Open-Meteo.com, CC BY 4.0",creditUrl:"https://open-meteo.com/en/docs/historical-forecast-api",create:()=>new ce}]);class y{static DEFAULT_KIND=V.DEFAULT_KIND;static STEP_MS=1e3;static LEAD_MS=12e4;static FT_PER_M=1/.3048;static ID_PREFIX="decor:";tracks=new Map;static kindOf(t,e){return V.kindOf(t,e)}static flies(t){return V.flies(t)}static ridden(t,e,a,n=()=>{}){const s=it.originOf(t);if(s)for(const r of t.decor){const i=V.kindOf(r,n(r));if(!i)continue;const o=r.sizeM,l=Math.max(o?.widthM??0,o?.lengthM??0,o?.heightM??0)/2;if(l<=0)continue;const c=y.pointAt(r,e,s),{distanceKm:u}=j.seenFrom(a,{lat:c.lat,lng:c.lng,heightM:c.altitudeFt/y.FT_PER_M});if(u*1e3<=l)return{decor:r,kind:i}}}voices(t,e,a,n={},s=()=>{}){const r=it.originOf(t);if(!r)return[];const i=new Map,o=new Map,l=Math.max(t.observerTrack.duration,(t.event.durationSeconds??0)*1e3),c=y.ridden(t,e,a,s)?.decor;for(const u of t.decor){const d=u===c?void 0:V.kindOf(u,s(u));if(!d)continue;const h=`${y.ID_PREFIX}${u.id}`;i.set(h,this.trackOf(u,h,r,l)),o.set(h,d)}for(const u of this.tracks.keys())i.has(u)||this.tracks.delete(u);return i.size===0?[]:R.voices(new Set(i.keys()),i,new Map,u=>String(u.icao),a,e,{...n,kindOf:u=>o.get(u)})}trackOf(t,e,a,n){const s=JSON.stringify([t.track,t.eastM,t.northM,t.headingDeg,a.lat,a.lng,n]),r=this.tracks.get(e);if(r?.key===s)return r.track;const i=[];for(let d=0;d<=n;d+=y.STEP_MS)i.push(y.pointAt(t,d,a));(i.length===0||i[i.length-1].t<n)&&i.push(y.pointAt(t,n,a));const o=i[0],l=i[1]??o,c=d=>(l[d]-o[d])/(l.t-o.t||1);for(let d=y.STEP_MS*10;d<=y.LEAD_MS;d+=y.STEP_MS*10)i.unshift({t:-d,lat:o.lat-c("lat")*d,lng:o.lng-c("lng")*d,altitudeFt:Math.max(0,o.altitudeFt-c("altitudeFt")*d)});const u={icao:y.hash(e),nonIcao:!0,points:i};return this.tracks.set(e,{key:s,track:u}),u}static pointAt(t,e,a){const n=Bt(t,e),s=at(n.eastM,-n.northM,a.lat,a.lng);return{t:e,lat:s.lat,lng:s.lng,altitudeFt:n.altitudeM*y.FT_PER_M}}static hash(t){let e=0;for(let a=0;a<t.length;a++)e=e*31+t.charCodeAt(a)>>>0;return e}}class z{static CABIN_DB_A={"airliner-wide":76,"airliner-narrow":78,"regional-jet":78,"business-jet":82,"regional-turboprop":84,"turboprop-light":88,"light-piston":92,"piston-heavy":90,"military-jet":95,ultralight:95,"helicopter-light":95,"helicopter-medium":96,"helicopter-heavy":98,glider:70,balloon:60};static JET_CABINS=["airliner-narrow","airliner-wide","airliner-supersonic","regional-jet","business-jet"];static JET_CABIN_SHAPE_DB=[-3,-4,-13,-24,-33,-36,-42,-55];static DEFAULT_DB_A=78;static voice(t,e={}){const a=ot.aircraftOf(t);if(!a)return;const n=M.noiseOfKind(a),s=ot.insulationDb(t),r=z.JET_CABINS.includes(a)&&t?.windowsOpen!==!0?z.JET_CABIN_SHAPE_DB.map((c,u)=>c+A.aWeightingDb(A.OCTAVES[u])):n.soundPowerA.map((c,u)=>c-s[u]),i=A.sumDb(r),o=z.levelDbA(a,t?.noise),l=r.map(c=>c-i+o);return{id:"observer:cabin",kind:a,bandAmplitudes:R.bandAmplitudes(l,e.ambientDbA??0,e.referenceAmplitude,{ambientShapeDb:e.ambientShapeDb,expandUnderKnee:e.expandUnderKnee}),levelDbA:o,inside:!0,distanceKm:0,dopplerRatio:1,azimuthDeg:0,elevationDeg:0,character:n.character}}static levelDbA(t,e){return(z.CABIN_DB_A[t]??z.DEFAULT_DB_A)+20*Math.log10(Math.max(e??1,.01))}}class W{static STEP_MS=250;static FT_PER_M=1/.3048;static ID_PREFIX="body:";tracks=new Map;static noiseOf(t){const e=M.noiseOfKind(t.kind),a=t.quieterDb??0;return a===0?e:{...e,id:`${e.id}-${a}dB`,soundPowerA:e.soundPowerA.map(n=>n-a)}}voices(t,e,a,n,s,r,i={}){const o=new Map,l=new Map,c=new Map;for(const d of t){if(!d.sound)continue;const h=`${W.ID_PREFIX}${d.id}`,p=this.trackOf(d,h,e,n,r);p&&(o.set(h,p),l.set(h,d.sound.kind),c.set(h,W.noiseOf(d.sound)))}for(const d of this.tracks.keys())o.has(d)||this.tracks.delete(d);if(o.size===0)return[];const u=at(a.eastM,-a.northM,n.lat,n.lng);return R.voices(new Set(o.keys()),o,new Map,d=>String(d.icao),{lat:u.lat,lng:u.lng,heightM:a.upM},s,{...i,kindOf:d=>l.get(d),noiseOf:d=>c.get(d)})}trackOf(t,e,a,n,s){const r=`${n.lat},${n.lng},${s}`,i=this.tracks.get(e);if(i&&i.body===t&&i.origin===r)return i.track;const o=[];for(let c=-12e4;c<=s;c+=W.STEP_MS){const u=a(t,c);if(!u)continue;const d=at(u.eastM,-u.northM,n.lat,n.lng);o.push({t:c,lat:d.lat,lng:d.lng,altitudeFt:u.upM*W.FT_PER_M})}if(o.length<2)return;const l={icao:W.hash(e),nonIcao:!0,points:o};return this.tracks.set(e,{body:t,origin:r,track:l}),l}static hash(t){let e=0;for(let a=0;a<t.length;a++)e=e*31+t.charCodeAt(a)>>>0;return e}}export{Z as AircraftAudio,K as AircraftContrails,U as AircraftModels,Rt as AmbientNoise,W as BodyHearing,z as CabinHearing,y as DecorAircraftHearing,T as TrafficDecor,ue as TrafficInfos,R as TrafficSound,Q as TrafficTooltip,de as UPPER_AIR_SOURCES};
@@ -1 +0,0 @@
1
- const e={caseHeading:"Case",eventsHeading:"History",kindObservation:"Observation",kindReading:"Reading",kindInterview:"Interview",openEvent:"Open this event",interpretationOf:"Reading of",passagesHeading:"Told in",byAuthor:"by",linkAnd:"and",caseSummary:"What this case says of itself",editCase:"Edit this case",shareCase:"Share this case"};export{e as caseMessages_en};
@@ -1 +0,0 @@
1
- const e={caseHeading:"Caso",eventsHeading:"Historial",kindObservation:"Observación",kindReading:"Lectura",kindInterview:"Entrevista",openEvent:"Abrir este evento",interpretationOf:"Lectura de",passagesHeading:"Relatado en",byAuthor:"por",linkAnd:"y",caseSummary:"Lo que este caso dice de sí mismo",editCase:"Editar este caso",shareCase:"Compartir este caso"};export{e as caseMessages_es};
@@ -1 +0,0 @@
1
- const e={caseHeading:"Dossier",eventsHeading:"Historique",kindObservation:"Observation",kindReading:"Lecture",kindInterview:"Interview",openEvent:"Ouvrir cet événement",interpretationOf:"Lecture de",passagesHeading:"Relaté dans",byAuthor:"par",linkAnd:"et",caseSummary:"Ce que ce dossier dit de lui-même",editCase:"Modifier ce dossier",shareCase:"Partager ce dossier"};export{e as caseMessages_fr};
@@ -1 +0,0 @@
1
- const e={caseHeading:"Caso",eventsHeading:"Cronologia",kindObservation:"Osservazione",kindReading:"Lettura",kindInterview:"Intervista",openEvent:"Aprire questo evento",interpretationOf:"Lettura di",passagesHeading:"Raccontato in",byAuthor:"di",linkAnd:"e",caseSummary:"Ciò che questo caso dice di sé",editCase:"Modificare questo caso",shareCase:"Condividi questo caso"};export{e as caseMessages_it};
@@ -1,2 +0,0 @@
1
- import{A as et,c as A,L as vt,T as x,R as j,d as N,e as Rt,M as st,D as V,f as it,r as Bt,l as at,O as ot}from"./rr0-sighting.mjs";import{C as rt}from"./ContrailGrowth-DwHS8If9.js";const Nt=.25,ct=.4,lt=6,$=12,Ct=3,ht=.2,_t=.2,ut=24,wt=3,Ht=24,dt=1,yt=.7,Pt=1.5,kt=.8,Lt=1.3,pt=.02,Ft=700,jt=-30,mt=.9,Mt=5,Gt=25,Ut=.5,Kt=.12,gt=[.13,.31],zt=.16,Wt=1.6,Vt=3.6,At=1.1,$t=.3,Xt=1e3,bt=.7,Yt=.7;class Z{context;constructor(t){this.context=t}noiseBuffer;roughBuffers=new Map;voices=new Map;bus;reverb;reverbOut;level=1;master;paused=!0;requested=[];headingDeg=0;resume(){if(!this.context){if(typeof AudioContext>"u")return;try{this.context=new AudioContext}catch(t){console.warn("AircraftAudio: Web Audio unavailable, aircraft stay silent:",t);return}}et.isLive(this.context)&&et.unlock(this.context),this.apply()}setLevel(t){this.level=t,this.master&&(this.master.gain.value=t)}setPaused(t){t!==this.paused&&(this.paused=t,this.apply())}setVoices(t,e=0){this.requested=t,this.headingDeg=e,this.apply()}dispose(){for(const t of[...this.voices.keys()])this.release(t);et.isLive(this.context)&&this.context.close(),this.context=void 0,this.master=void 0,this.bus=void 0}apply(){const t=this.context;if(!t)return;const e=this.paused?[]:this.requested,a=new Set(e.map(n=>n.id));for(const n of[...this.voices.keys()])a.has(n)||this.release(n);for(const n of e){const s=this.voices.get(n.id)??this.build(t,n);this.retarget(t,s,n)}}build(t,e){const a=t.createGain();a.gain.value=0;let n;const s=this.busOf(t);typeof t.createStereoPanner=="function"?(n=t.createStereoPanner(),a.connect(n).connect(s)):a.connect(s);const r=t.createGain(),i=e.character?.modulationDepth??0;r.gain.value=1-i/2;const o=t.createOscillator();o.type="sine";const l=t.createGain();l.gain.value=i/2,o.connect(l).connect(r.gain),r.connect(a);const c=t.createBufferSource();c.buffer=this.noise(t),c.loop=!0,c.loopStart=Math.random()*lt*.5;const u=[],d=[],h=[];for(const D of A.OCTAVES){const I=t.createBiquadFilter();I.type="bandpass",I.frequency.value=D,I.Q.value=dt;const w=t.createBiquadFilter();w.type="bandpass",w.frequency.value=D,w.Q.value=dt;const P=t.createGain();P.gain.value=0,c.connect(I).connect(w).connect(P).connect(r),u.push(I),d.push(w),h.push(P)}const p=[];for(const[D,I]of[[e.character?.toneHz,e.character?.toneShare],[e.character?.humHz,e.character?.humShare]])if(D!==void 0)for(let w=1;w<=wt;w++){const P=t.createOscillator();P.type="sine",P.frequency.value=D*w;const tt=t.createGain();tt.gain.value=0,P.connect(tt).connect(a),p.push({oscillator:P,gain:tt,harmonic:w,baseHz:D,share:I??0})}const m=t.createGain();m.gain.value=0,m.connect(a.gain);const f=gt.map(D=>{const I=t.createOscillator();return I.type="sine",I.frequency.value=D,I.connect(m),I}),O=t.createGain();O.gain.value=e.character?.roughness??ht;const v=t.createBufferSource();v.buffer=this.roughTable(t,Ct),v.loop=!0,v.loopStart=Math.random()*$*.5,v.connect(O).connect(r.gain);const B=t.createGain();B.gain.value=(e.character?.roughness??ht)*_t;const S=t.createBufferSource();S.buffer=this.roughTable(t,ut),S.loop=!0,S.loopStart=Math.random()*$*.5,S.connect(B).connect(r.gain);let F;const q=this.busOf(t)&&this.reverb;q&&(F=t.createGain(),F.gain.value=0,a.connect(F).connect(q));let L,_;if(!e.inside&&typeof t.createDelay=="function"){const D=t.createDelay(pt);D.delayTime.value=0;const I=t.createBiquadFilter();I.type="highshelf",I.frequency.value=Ft,I.gain.value=0;const w=t.createGain();w.gain.value=0,a.connect(D).connect(I).connect(w).connect(n??s);const P=t.createGain();P.gain.value=0,_=t.createBufferSource(),_.buffer=this.roughTable(t,ut),_.loop=!0,_.loopStart=Math.random()*$*.5,_.connect(P).connect(D.delayTime),L={delay:D,jitter:P,shelf:I,gain:w}}const k=[c,v,S,o,...p.map(D=>D.oscillator),...f,..._?[_]:[]];for(const D of k)D.start();const J={nodes:[a,r,l,O,B,m,...L?[L.delay,L.jitter,L.shelf,L.gain]:[],...p.map(D=>D.gain),...u,...d,...h,...F?[F]:[],...n?[n]:[],...k],sources:k,filters:u,seconds:d,gains:h,tones:p,lfo:o,lfoDepth:l,wander:f,wanderDepth:m,roughDepth:O,crackleDepth:B,beat:r,output:a,panner:n,send:F,echo:L};return this.voices.set(e.id,J),J}retarget(t,e,a){const n=t.currentTime,s=(p,m)=>p.setTargetAtTime(m,n,Nt),r=Math.min(Pt,Math.max(yt,a.dopplerRatio)),i=Math.min(Lt,Math.max(kt,Math.sqrt(a.dopplerRatio))),o=t.sampleRate*.45,l=a.bandAmplitudes.map((p,m)=>p*Z.unweighting(A.OCTAVES[m])),c=Math.sqrt(l.reduce((p,m)=>p+m*m,0)),u=Math.min(1,Math.max(0,(a.distanceKm-Mt)/(Gt-Mt)));A.OCTAVES.forEach((p,m)=>{s(e.filters[m].frequency,Math.min(o,p*i)),s(e.seconds[m].frequency,Math.min(o,p*i)),s(e.gains[m].gain,l[m]*Math.sqrt(Xt/p))});const d=a.character;for(const{oscillator:p,gain:m,harmonic:f,baseHz:O,share:v}of e.tones){const B=O*f;s(p.frequency,B*r);const S=B*r;s(m.gain,S<o?v*zt*l[Z.bandOf(S)]/f:0)}d?.modulationHz!==void 0&&s(e.lfo.frequency,d.modulationHz*r);const h=c>0?Z.saturated(c)/c:1;if(s(e.output.gain,h*(1-$t*u)),s(e.wanderDepth.gain,h*Kt*u/gt.length),e.send&&s(e.send.gain,Wt*u),e.echo){const p=a.groundEcho;s(e.echo.gain.gain,p?.lowGain??0),p&&(s(e.echo.delay.delayTime,Math.min(pt,p.delayS)),s(e.echo.jitter.gain,p.jitterS),s(e.echo.shelf.gain,p.lowGain>0?Math.max(jt,20*Math.log10(Math.max(p.highGain,1e-6)/p.lowGain)):0))}if(e.panner){const p=(a.azimuthDeg-this.headingDeg)*Math.PI/180,m=a.inside?0:Math.max(-mt,Math.min(mt,Math.sin(p)))*(1-Ut*u);s(e.panner.pan,m)}}static saturated(t){const e=Yt*bt;if(t<=e)return t;const a=bt-e;return e+a*(1-Math.exp(-(t-e)/a))}static unweighting(t){return 10**(Math.min(Ht,Math.max(0,-A.aWeightingDb(t)))/20)}static bandOf(t){let e=0;return A.OCTAVES.forEach((a,n)=>{Math.abs(Math.log(t/a))<Math.abs(Math.log(t/A.OCTAVES[e]))&&(e=n)}),e}roughTable(t,e){const a=this.roughBuffers.get(e);if(a)return a;const n=Math.floor(t.sampleRate*$),s=t.createBuffer(1,n,t.sampleRate),r=s.getChannelData(0),i=Array.from({length:$*e},()=>(Math.random()*2-1)**3),o=t.sampleRate/e;for(let l=0;l<r.length;l++){const c=l/o,u=Math.floor(c),d=c-u,h=d*d*(3-2*d);r[l]=i[u%i.length]*(1-h)+i[(u+1)%i.length]*h}return this.roughBuffers.set(e,s),s}roomImpulse(t){const e=Math.floor(t.sampleRate*Vt),a=t.createBuffer(2,e,t.sampleRate);for(let n=0;n<2;n++){const s=a.getChannelData(n);let r=0;for(let i=0;i<e;i++){const o=i/t.sampleRate,l=.6*Math.exp(-o/(At*2))+.04;r+=l*(Math.random()*2-1-r),s[i]=r*Math.exp(-o/At)}}return a}busOf(t){if(this.bus)return this.bus;const e=t.createGain();if(e.gain.value=this.level,e.connect(t.destination),this.master=e,typeof t.createConvolver=="function"){const a=t.createConvolver();a.buffer=this.roomImpulse(t);const n=t.createGain();n.gain.value=.9,a.connect(n),this.reverb=a,this.reverbOut=n}if(typeof t.createDynamicsCompressor=="function"){const a=t.createDynamicsCompressor();a.threshold.value=-6,a.knee.value=3,a.ratio.value=4,a.attack.value=.005,a.release.value=.25,a.connect(e),this.bus=a}else this.bus=e;return this.reverbOut?.connect(this.bus),this.bus}release(t){const e=this.voices.get(t);if(!e)return;this.voices.delete(t);const a=this.context;a&&(e.output.gain.setTargetAtTime(0,a.currentTime,ct/3),setTimeout(()=>{for(const n of e.sources)try{n.stop()}catch{}for(const n of e.nodes)n.disconnect()},ct*1e3*3))}noise(t){if(this.noiseBuffer)return this.noiseBuffer;const e=t.createBuffer(1,t.sampleRate*lt,t.sampleRate),a=e.getChannelData(0);for(let n=0;n<a.length;n++)a[n]=Math.random()*2-1;return this.noiseBuffer=e,e}}class U{static TYPES={A318:["Airbus A318","airliner-narrow",34.1,31.4],A319:["Airbus A319","airliner-narrow",34.1,33.8],A320:["Airbus A320","airliner-narrow",34.1,37.6],A321:["Airbus A321","airliner-narrow",34.1,44.5],A19N:["Airbus A319neo","airliner-narrow",35.8,33.8],A20N:["Airbus A320neo","airliner-narrow",35.8,37.6],A21N:["Airbus A321neo","airliner-narrow",35.8,44.5],B737:["Boeing 737-700","airliner-narrow",34.3,33.6],B738:["Boeing 737-800","airliner-narrow",35.8,39.5],B739:["Boeing 737-900","airliner-narrow",35.8,42.1],B38M:["Boeing 737 MAX 8","airliner-narrow",35.9,39.5],B39M:["Boeing 737 MAX 9","airliner-narrow",35.9,42.2],B752:["Boeing 757-200","airliner-narrow",38,47.3],B753:["Boeing 757-300","airliner-narrow",38,54.4],B762:["Boeing 767-200","airliner-wide",47.6,48.5],B763:["Boeing 767-300","airliner-wide",47.6,54.9],B764:["Boeing 767-400","airliner-wide",51.9,61.4],B772:["Boeing 777-200","airliner-wide",60.9,63.7],B77L:["Boeing 777-200LR","airliner-wide",64.8,63.7],B77W:["Boeing 777-300ER","airliner-wide",64.8,73.9],B788:["Boeing 787-8","airliner-wide",60.1,56.7],B789:["Boeing 787-9","airliner-wide",60.1,62.8],B78X:["Boeing 787-10","airliner-wide",60.1,68.3],B744:["Boeing 747-400","airliner-wide",64.4,70.7],B748:["Boeing 747-8","airliner-wide",68.4,76.3],A306:["Airbus A300-600","airliner-wide",44.8,54.1],A310:["Airbus A310","airliner-wide",43.9,46.7],A332:["Airbus A330-200","airliner-wide",60.3,58.8],A333:["Airbus A330-300","airliner-wide",60.3,63.7],A338:["Airbus A330-800","airliner-wide",64,58.8],A339:["Airbus A330-900","airliner-wide",64,63.7],A343:["Airbus A340-300","airliner-wide",60.3,63.7],A346:["Airbus A340-600","airliner-wide",63.5,75.4],A359:["Airbus A350-900","airliner-wide",64.8,66.8],A35K:["Airbus A350-1000","airliner-wide",64.8,73.8],A388:["Airbus A380-800","airliner-wide",79.8,72.7],CONC:["Concorde","airliner-supersonic",25.6,61.7],DC3:["Douglas DC-3","piston-heavy",29,19.7],DC4:["Douglas DC-4","piston-heavy",35.8,28.6],P51:["North American P-51 Mustang","piston-heavy",11.3,9.8],E170:["Embraer 170","regional-jet",26,29.9],E75L:["Embraer 175","regional-jet",26,31.7],E75S:["Embraer 175","regional-jet",26,31.7],E190:["Embraer 190","regional-jet",28.7,36.2],E195:["Embraer 195","regional-jet",28.7,38.7],E290:["Embraer 190-E2","regional-jet",33.7,36.2],E295:["Embraer 195-E2","regional-jet",33.7,41.5],CRJ2:["Bombardier CRJ200","regional-jet",21.2,26.8],CRJ7:["Bombardier CRJ700","regional-jet",23.2,32.3],CRJ9:["Bombardier CRJ900","regional-jet",24.9,36.2],CRJX:["Bombardier CRJ1000","regional-jet",26.2,39.1],AT72:["ATR 72","regional-turboprop",27.1,27.2],AT76:["ATR 72-600","regional-turboprop",27.1,27.2],AT45:["ATR 42","regional-turboprop",24.6,22.7],DH8D:["Dash 8 Q400","regional-turboprop",28.4,32.8],DH8C:["Dash 8-300","regional-turboprop",27.4,25.7],SF34:["Saab 340","regional-turboprop",21.4,19.7],B190:["Beechcraft 1900","regional-turboprop",17.7,17.6],C25A:["Cessna CitationJet CJ2","business-jet",14.3,14.4],C56X:["Cessna Citation Excel","business-jet",17.2,16],C68A:["Cessna Citation Latitude","business-jet",22,18.9],C550:["Cessna Citation II","business-jet",15.8,14.4],E55P:["Embraer Phenom 300","business-jet",15.9,15.6],E50P:["Embraer Phenom 100","business-jet",12.3,12.8],GLF5:["Gulfstream G550","business-jet",28.5,29.4],FA7X:["Dassault Falcon 7X","business-jet",26.2,23.4],CL60:["Bombardier Challenger 600","business-jet",19.6,20.9],LJ45:["Learjet 45","business-jet",14.6,17.7],H25B:["Hawker 800","business-jet",15.7,15.6],C172:["Cessna 172","light-piston",11,8.3],C152:["Cessna 152","light-piston",10.2,7.3],C182:["Cessna 182","light-piston",10.9,8.8],P28A:["Piper Cherokee","light-piston",10.7,7.2],PA34:["Piper Seneca","light-piston",11.8,8.7],SR20:["Cirrus SR20","light-piston",10.9,7.9],SR22:["Cirrus SR22","light-piston",11.7,7.9],S22T:["Cirrus SR22T","light-piston",11.7,7.9],DA40:["Diamond DA40","light-piston",11.6,8.1],DA42:["Diamond DA42","light-piston",13.4,8.6],BE20:["Beechcraft King Air 200","turboprop-light",16.6,13.3],BE58:["Beechcraft Baron","light-piston",11.5,9.1],C208:["Cessna Caravan","turboprop-light",15.9,11.5],PC12:["Pilatus PC-12","turboprop-light",16.3,14.4],TBM9:["Daher TBM 900","turboprop-light",12.8,10.7],EC35:["Airbus H135","helicopter-light",10.2,12.1],EC45:["Airbus H145","helicopter-medium",11,13.6],AS50:["Airbus H125","helicopter-light",10.7,12.9],EC30:["Airbus H130","helicopter-light",10.7,12.6],B407:["Bell 407","helicopter-light",10.7,12.7],B06:["Bell 206","helicopter-light",10.2,12],B429:["Bell 429","helicopter-medium",10.9,13],B505:["Bell 505","helicopter-light",10.4,11.9],R44:["Robinson R44","helicopter-light",10.1,11.7],R22:["Robinson R22","helicopter-light",7.7,8.8],A109:["Agusta A109","helicopter-medium",11,13],A139:["Leonardo AW139","helicopter-medium",13.8,16.7],S92:["Sikorsky S-92","helicopter-heavy",17.2,20.9],H60:["Sikorsky UH-60 Black Hawk","helicopter-heavy",16.4,19.8],T38:["Northrop T-38 Talon","military-jet",7.7,14.1],HAWK:["BAE Hawk","military-jet",9.4,11.9],GLID:["Glider","glider",17,7],BALL:["Balloon","balloon",15,20],ULAC:["Ultralight","ultralight",9.5,6],C42:["Ikarus C42","ultralight",9.4,6.3],DRON:["Drone","unmanned",1,.6]};static CATEGORIES={A1:["Light aircraft","light-piston",11,8.3],A2:["Small aircraft","business-jet",15,15],A3:["Large aircraft","airliner-narrow",34.1,37.6],A4:["High-vortex large aircraft","airliner-narrow",38,47.3],A5:["Heavy aircraft","airliner-wide",60.3,63.7],A6:["High-performance aircraft","military-jet",8,14],A7:["Rotorcraft","helicopter-medium",10.7,12.7],B1:["Glider","glider",17,7],B2:["Lighter-than-air","balloon",15,20],B4:["Ultralight","ultralight",9.5,6],B6:["Unmanned aircraft","unmanned",1.5,1]};static GENERIC={name:"Airliner",kind:"airliner-narrow",spanM:34.1,lengthM:37.6,basis:"nothing"};static of(t){const e=t?.type?.toUpperCase(),a=e?U.TYPES[e]:void 0;if(a)return{code:e,name:a[0],kind:a[1],spanM:a[2],lengthM:a[3],basis:"type"};const n=t?.category?U.CATEGORIES[t.category]:void 0;return n?{name:n[0],kind:n[1],spanM:n[2],lengthM:n[3],basis:"category"}:{...U.GENERIC}}static isHelicopter(t){return t.kind.startsWith("helicopter")}}class C{static DUSK_SUN_ELEVATION_DEG=-.83;static ALWAYS=new Set(["airliner-narrow","airliner-wide","airliner-supersonic","regional-turboprop","regional-jet","business-jet"]);static NONE=new Set(["glider","balloon"]);static BRIGHTNESS={"light-piston":[.5,.2,.5],"turboprop-light":[.7,.4,.8],ultralight:[.4,.2,.4],unmanned:[0,.05,0],"helicopter-light":[1,1,1],"helicopter-medium":[1,1,1],"helicopter-heavy":[1,1,1],"military-jet":[1,1,1]};static LANDING_LIGHTS_BELOW_FT=1e4;static LANDING_INTENSITY=600;static LANDING_BEAM_DEG=10;static LANDING_COLOR="#fff1dc";static LANDING_BRIGHTNESS={"airliner-narrow":1,"airliner-wide":1,"airliner-supersonic":1,"regional-jet":.6,"regional-turboprop":.6,"business-jet":.4,"turboprop-light":.2,"light-piston":.1,ultralight:.05,"helicopter-light":.1,"helicopter-medium":.2,"helicopter-heavy":.2};static lampsOn(t,e){if(C.NONE.has(t))return{navigation:!1,beacon:!1,strobes:!1};if(C.ALWAYS.has(t))return{navigation:!0,beacon:!0,strobes:!0};const a=e<C.DUSK_SUN_ELEVATION_DEG;return t==="unmanned"?{navigation:!1,beacon:!1,strobes:a}:{navigation:a,beacon:a,strobes:a}}static lights(t,e){const a=C.lampsOn(t.kind,e),n=t.kind.startsWith("helicopter"),s=vt.find(h=>h.id===(n?"helicopter":"airliner")).create(),[r,i]=n?[5,7]:[17,18],o=t.spanM/2/r,l=t.lengthM/2/i,[c,u,d]=C.BRIGHTNESS[t.kind]??[1,1,1];return s.filter(h=>h.id.startsWith("nav")?a.navigation:h.id.startsWith("strobe")?a.strobes:h.id.startsWith("beacon")?a.beacon:!0).filter(h=>!(h.id.startsWith("beacon")&&!a.beacon)).map(h=>{const p=h.id.startsWith("nav")?c:h.id.startsWith("strobe")?u:d;return{...h,offsetM:{x:h.offsetM.x*o,y:h.offsetM.y,z:h.offsetM.z*l},intensity:(h.intensity??1)*p}}).filter(h=>(h.intensity??1)>0)}static landingLights(t,e,a){const n=C.LANDING_BRIGHTNESS[t.kind]??0;if(n===0||!C.lampsOn(t.kind,e).navigation)return[];const s=c=>c<C.LANDING_LIGHTS_BELOW_FT;if(!a.some(c=>s(c.altitudeFt)))return[];const r=C.LANDING_INTENSITY*n,i=a.flatMap((c,u)=>u>0&&s(c.altitudeFt)!==s(a[u-1].altitudeFt)?[{t:c.t,intensity:s(c.altitudeFt)?r:0}]:[]),o=t.spanM/34,l=t.lengthM/36;return[-1,1].map(c=>({id:c<0?"landing-left":"landing-right",offsetM:{x:c*5*o,y:-1,z:3*l},color:C.LANDING_COLOR,intensity:s(a[0].altitudeFt)?r:0,pattern:{kind:"steady"},beamDeg:C.LANDING_BEAM_DEG,keyframes:i}))}static bodyColor(t){return t.kind==="military-jet"?"#8a8e94":t.kind.startsWith("helicopter")?"#c8ccd1":t.kind==="unmanned"?"#2c2e33":"#dde0e4"}}class Y{static FAMILIES={"amvlab-a320":["A318","A319","A320","A321","A19N","A20N","A21N"],"amvlab-b737":["B732","B733","B734","B735","B736","B737","B738","B739","B37M","B38M","B39M","B3XM"],"amvlab-a350":["A359","A35K"],"amvlab-a380":["A388"],"amvlab-b787":["B788","B789","B78X"]};static BY_TYPE=new Map(Object.entries(Y.FAMILIES).flatMap(([t,e])=>e.map(a=>[a,t])));static idOf(t){return t?Y.BY_TYPE.get(t.toUpperCase()):void 0}}class T{static ID_PREFIX=x.ID_PREFIX;static MAX_OBJECTS=40;static FT_TO_M=.3048;static DEG=Math.PI/180;static from(t,e,a,n=T.MAX_OBJECTS,s={}){return new qt(t,e,a,n,s).build()}static idOf(t,e){return x.idOf(t,e)}static keyOf(t){return x.keyOf(t)}static HEIGHT_OVER_LENGTH=.29;static sizeOf(t){return{widthM:t.spanM,lengthM:t.lengthM,heightM:t.lengthM*T.HEIGHT_OVER_LENGTH}}static offsetOf(t,e){const a=j.seenFrom(t,{lat:e.lat,lng:e.lng,heightM:e.altitudeFt*T.FT_TO_M}),n=a.distanceKm*1e3,s=n*Math.cos(a.altitudeDeg*T.DEG);return{eastM:s*Math.sin(a.azimuthDeg*T.DEG),northM:s*Math.cos(a.azimuthDeg*T.DEG),upM:n*Math.sin(a.altitudeDeg*T.DEG),altitudeDeg:a.altitudeDeg,distanceKm:a.distanceKm}}static segments(t){const e=[];let a=[];for(const n of t.points){const s=a[a.length-1];s&&n.t-s.t>N.MAX_GAP_S*1e3&&(e.push(a),a=[]),a.push(n)}return e.push(a),e.filter(n=>n.length>=2)}static bearingDeg(t,e){return(Math.atan2(e.eastM-t.eastM,e.northM-t.northM)/T.DEG+360)%360}}class qt{constructor(t,e,a,n,s){this.tracks=t,this.observer=e,this.startMs=a,this.maxObjects=n,this.options=s}build(){const t=[];for(const a of this.tracks){const n=T.keyOf(a),s=this.options.models?.get(n)??U.of(void 0);T.segments(a).forEach((r,i)=>{const o=r.map(h=>({point:h,at:T.offsetOf(this.observer,h)}));if(!o.some(h=>h.at.altitudeDeg>=0))return;const l=o.map((h,p)=>({t:h.point.t-this.startMs,eastM:h.at.eastM,northM:h.at.northM,altitudeM:h.at.upM,headingDeg:h.point.trackDeg??(p+1<o.length?T.bearingDeg(h.at,o[p+1].at):T.bearingDeg(o[p-1].at,h.at))})),c=T.idOf(a,i),u=o[Math.floor(o.length/2)].point,d=this.options.sunElevationAt?.(u)??90;t.push({object:{id:c,kind:"aircraft",eastM:l[0].eastM,northM:l[0].northM,headingDeg:l[0].headingDeg,sizeM:T.sizeOf(s),model:Y.idOf(s.code)?{id:Y.idOf(s.code)}:void 0,color:C.bodyColor(s),lights:[...C.lights(s,d),...C.landingLights(s,d,r.map(h=>({t:h.t-this.startMs,altitudeFt:h.altitudeFt})))],track:l},presence:{fromMs:l[0].t,untilMs:l[l.length-1].t},flight:{icao:a.icao,nonIcao:a.nonIcao,points:r},closestKm:Math.min(...o.map(h=>h.at.distanceKm))})})}t.sort((a,n)=>a.closestKm-n.closestKm);const e=t.slice(0,this.maxObjects);return{objects:e.map(a=>a.object),presence:new Map(e.map(a=>[a.object.id,a.presence])),flights:new Map(e.map(a=>[a.object.id,a.flight])),total:t.length,shown:e.length}}}const Jt=[[20,0],[120,0],[130,1.5],[140,4],[150,7.5],[160,7.5]],xt=[[20,1.5],[40,1],[60,1],[80,0],[120,0],[130,1],[140,1],[150,-3],[160,-6.5],[170,-12]],ft=.16,Zt=1,Qt=[[0,-2],[10,-1],[20,0],[40,0],[50,-2],[60,-4.5],[70,-7.5],[80,-11],[90,-15],[100,-19.5],[110,-25]],te=[[60,-15.8],[70,-11.5],[80,-8],[90,-5],[100,-2.7],[110,-1.2],[120,-.3],[130,0],[140,-2],[150,-6],[160,-10],[170,-15],[180,-20]],ee=1.5,Et=-40,ae=1.5,ne={takeoff:{jetMps:300,flightMps:80,jetShare:[1,1,.9,.6,.3,.1,0,0]},overflight:{jetMps:280,flightMps:130,jetShare:[1,1,.9,.6,.3,.1,0,0]},approach:{jetMps:180,flightMps:70,jetShare:[.6,.5,.4,.2,.1,0,0,0]}};class H{static bandsDb(t,e,a=340){const n=ne[e],s=H.fan(t)-H.fan(90),r=.62*Math.max(0,n.jetMps-n.flightMps)/a,i=-30*Math.log10(1+r/(1+r**5)**.2*Math.cos(t*Math.PI/180));return A.OCTAVES.map((o,l)=>{const c=i+H.jetRemainder(t,o*ae/n.jetMps),u=n.jetShare[l];return 10*Math.log10(u*10**(c/10)+(1-u)*10**(s/10))})}static loudestDb(t){const e=H.loudest.get(t);if(e)return e;const a=A.OCTAVES.map(()=>-1/0);for(let n=0;n<=180;n+=5)H.bandsDb(n,t).forEach((s,r)=>a[r]=Math.max(a[r],s));return H.loudest.set(t,a),a}static loudest=new Map;static angleDeg(t,e){const a=t.reduce((s,r,i)=>s+r*e[i],0),n=Math.hypot(...t)*Math.hypot(...e);return n===0?90:Math.acos(Math.min(1,Math.max(-1,a/n)))*180/Math.PI}static fan(t){const e=H.read(Qt,t,!0),a=H.read(te,t,!0)+ee;return 10*Math.log10(10**(e/10)+10**(a/10))}static jetRemainder(t,e){const a=Math.min(1,Math.max(0,Math.log(e/ft)/Math.log(Zt/ft)));return(1-a)*H.read(Jt,t)+a*H.read(xt,t)}static read(t,e,a=!1){const[n,s]=[t[0],t[1]],[r,i]=[t[t.length-2],t[t.length-1]];if(e<=n[0])return a?Math.max(Et,n[1]+(s[1]-n[1])/(s[0]-n[0])*(e-n[0])):n[1];if(e>=i[0])return a?Math.max(Et,i[1]+(i[1]-r[1])/(i[0]-r[0])*(e-i[0])):i[1];for(let o=1;o<t.length;o++){const[l,c]=[t[o-1],t[o]];if(e<=c[0])return l[1]+(c[1]-l[1])*(e-l[0])/(c[0]-l[0])}return i[1]}}class g{static GRASS={flowResistivityKPa:200,earHeightM:1.6};static COHERENCE=.4;static JITTER_S=1e-4;static ECHO_UNDER_S=5e-4;static ECHO_FROM_S=.0015;static LOW_HZ=125;static HIGH_HZ=2e3;static AIR_DENSITY=1.2;static reflection(t,e,a=g.GRASS){const[n,s]=g.impedance(t,a);return g.reflected(n,s,Math.sin(Math.max(0,e)*Math.PI/180))}static impedance(t,e=g.GRASS){const a=g.AIR_DENSITY*t/(e.flowResistivityKPa*1e3);return[1+.0571*a**-.754,-.087*a**-.732]}static reflected(t,e,a){const[n,s,r,i]=[t*a-1,e*a,t*a+1,e*a],o=r*r+i*i;return{re:(n*r+s*i)/o,im:(s*r-n*i)/o}}static delayS(t,e=g.GRASS,a=340){return 2*e.earHeightM*Math.sin(Math.max(0,t)*Math.PI/180)/a}static excessDb(t,e=g.GRASS,a=340){const n=`${e.flowResistivityKPa}|${e.earHeightM}|${a}`;let s=g.overheads.get(n);return s||g.overheads.set(n,s=g.bandsDb(90,e,a)),g.bandsDb(t,e,a).map((r,i)=>r-s[i])}static echo(t,e=g.GRASS,a=340){const n=g.delayS(t,e,a);if(n<=g.ECHO_UNDER_S)return;const s=Math.min(1,(n-g.ECHO_UNDER_S)/(g.ECHO_FROM_S-g.ECHO_UNDER_S)),r=s*s*(3-2*s),i=o=>{const l=g.reflection(o,t,e);return r*g.COHERENCE*Math.hypot(l.re,l.im)};return{delayS:n,lowGain:i(g.LOW_HZ),highGain:i(g.HIGH_HZ),jitterS:g.JITTER_S}}static overheads=new Map;static thirds=A.OCTAVES.map(t=>[-1,0,1].map(e=>{const a=t*2**(e/3);return{middle:a,from:a*2**(-1/6),to:a*2**(1/6)}}));static impedances=new Map;static bandsDb(t,e,a){const n=g.delayS(t,e,a),s=g.COHERENCE,r=Math.sin(Math.max(0,t)*Math.PI/180);let i=g.impedances.get(e.flowResistivityKPa);return i||g.impedances.set(e.flowResistivityKPa,i=g.thirds.map(o=>o.map(l=>g.impedance(l.middle,e)))),g.thirds.map((o,l)=>{let c=0;return o.forEach((u,d)=>{const h=g.reflected(i[l][d][0],i[l][d][1],r),p=2*Math.PI*n*(u.to-u.from),[m,f]=p<1e-9?[1,0]:[(Math.sin(2*Math.PI*u.to*n)-Math.sin(2*Math.PI*u.from*n))/p,(Math.cos(2*Math.PI*u.from*n)-Math.cos(2*Math.PI*u.to*n))/p];c+=1+h.re*h.re+h.im*h.im+2*s*(h.re*m+h.im*f)}),10*Math.log10(c/o.length)})}}const X={takeoff:{shapeDb:[10,3,-3,-2,-2,-2,5,4],levelDb:0},approach:{shapeDb:[0,0,0,0,0,0,0,0],levelDb:-8}},se={takeoff:{shapeDb:[0,0,0,0,0,0,0,0],levelDb:0},approach:{shapeDb:[0,0,0,0,0,0,0,0],levelDb:-8}},Tt=[{id:"turbofan-narrow-body",name:"Turbofan airliner, narrow-body",kinds:["airliner-narrow"],totalDbA:148,shapeDb:[-32,-17,-9,-6,-5,-7,-12,-22],character:{toneHz:1800,toneShare:.3,humHz:90,humShare:.7},regimes:X},{id:"turbojet-supersonic",name:"Supersonic turbojet airliner",kinds:["airliner-supersonic"],totalDbA:169.5,shapeDb:[-22,-13,-9,-6,-6,-9,-15,-25],character:{humHz:100,humShare:.7},regimes:se},{id:"turbofan-wide-body",name:"Turbofan airliner, wide-body",kinds:["airliner-wide"],totalDbA:151,shapeDb:[-28,-14,-7,-4,-3,-6,-12,-22],character:{toneHz:1200,toneShare:.3,humHz:70,humShare:.7},regimes:X},{id:"regional-jet",name:"Regional jet",kinds:["regional-jet"],totalDbA:144,shapeDb:[-32,-17,-9,-5,-4,-6,-11,-21],character:{toneHz:1900,toneShare:.3,humHz:95,humShare:.7},regimes:X},{id:"business-jet",name:"Business jet",kinds:["business-jet"],totalDbA:141,shapeDb:[-30,-15,-8,-4,-3,-4,-9,-19],character:{toneHz:2500,toneShare:.25,humHz:110,humShare:.7},regimes:X},{id:"turboprop",name:"Turboprop",kinds:["regional-turboprop","turboprop-light"],totalDbA:138,shapeDb:[-14,-9,-8,-6,-8,-13,-20,-28],character:{toneHz:80,toneShare:.5}},{id:"light-piston",name:"Light piston aircraft",kinds:["light-piston"],totalDbA:130,shapeDb:[-20,-10,-3,-6,-10,-20,-27,-42],character:{toneHz:80,toneShare:.4,modulationHz:80,modulationDepth:.4}},{id:"piston-heavy",name:"Heavy piston aircraft",kinds:["piston-heavy"],totalDbA:140,shapeDb:[-31,-12,-11,-9,-7,-6,-7,-11],character:{toneHz:84,toneShare:.4,modulationHz:84,modulationDepth:.36}},{id:"ultralight",name:"Ultralight",kinds:["ultralight"],totalDbA:124,shapeDb:[-16,-8,-5,-4,-9,-15,-23,-31],character:{toneHz:140,toneShare:.4}},{id:"helicopter-light",name:"Light helicopter",kinds:["helicopter-light"],totalDbA:134,shapeDb:[-15,-8,-4,-3,-6,-10,-16,-24],character:{modulationHz:20,modulationDepth:.5}},{id:"helicopter-medium",name:"Medium helicopter",kinds:["helicopter-medium"],totalDbA:138,shapeDb:[-14,-7,-4,-3,-6,-10,-16,-24],character:{modulationHz:22,modulationDepth:.5}},{id:"helicopter-heavy",name:"Heavy helicopter",kinds:["helicopter-heavy"],totalDbA:144,shapeDb:[-12,-6,-4,-4,-7,-11,-17,-25],character:{modulationHz:17,modulationDepth:.5}},{id:"military-jet",name:"Military jet",kinds:["military-jet"],totalDbA:152,shapeDb:[-26,-12,-6,-3,-2,-3,-7,-15]},{id:"glider",name:"Glider",kinds:["glider"],totalDbA:85,shapeDb:[-30,-22,-15,-10,-8,-8,-14,-22]},{id:"balloon",name:"Hot-air balloon",kinds:["balloon"],totalDbA:100,shapeDb:[-25,-15,-9,-5,-3,-6,-12,-20]},{id:"unmanned",name:"Unmanned aircraft",kinds:["unmanned"],totalDbA:88,shapeDb:[-40,-30,-20,-12,-6,-3,-3,-8],character:{toneHz:450,toneShare:1}}],St=(b,t)=>b.map(e=>e+t-A.sumDb(b));function ie(b,t){if(!b)return;const e=t.toneRatio??1,a=t.toneGain??1;return{...b,...b.toneHz!==void 0?{toneHz:b.toneHz*e,toneShare:Math.min(1,(b.toneShare??0)*a)}:{},...b.humHz!==void 0?{humHz:b.humHz*e,humShare:Math.min(1,(b.humShare??0)*a)}:{}}}const Dt=Tt.map(b=>{const t=b.regimes===X?"turbofan":void 0,e={id:b.id,name:b.name,soundPowerA:St(b.shapeDb,b.totalDbA),character:b.character,directivity:t};if(!b.regimes)return e;const a={overflight:e};for(const[n,s]of Object.entries(b.regimes))a[n]={id:`${b.id}-${n}`,name:`${b.name}, ${n}`,soundPowerA:St(b.shapeDb.map((r,i)=>r+s.shapeDb[i]),b.totalDbA+s.levelDb),character:ie(b.character,s),directivity:t};return{...e,regimes:a}});class M{static DEFAULT_AMBIENT_DB_A=35;static DETECTION_MARGIN_DB=3;static AMBIENT_SHAPE_DB=Rt.OUTDOOR_SHAPE_DB;static HEARING_FLOOR_DB_A=0;static ITERATIONS=30;static CONVERGED_MS=.5;static VELOCITY_STEP_MS=500;static CLIMB_MPS=2.5;static DESCENT_MPS=1.5;static LOW_M=3e3;static CLIMB_SPAN_MS=3e4;static noiseOfKind(t){const e=Tt.find(a=>a.kinds.includes(t));return Dt.find(a=>a.id===(e?.id??"turbofan-narrow-body"))}static bandsAt(t,e,a=A.STANDARD){const n=20*Math.log10(Math.max(e*1e3,1))+11;return A.OCTAVES.map((s,r)=>t.soundPowerA[r]-n-A.absorptionDbPerKm(s,a)*e)}static couldBeHeard(t,e,a=M.DEFAULT_AMBIENT_DB_A,n=A.STANDARD,s){const r=M.ambientBands(a,s);return Object.entries(t.regimes??{overflight:t}).some(([o,l])=>M.bandsAt(l,e,n).map((c,u)=>c+(l.directivity==="turbofan"?H.loudestDb(o)[u]:0)).some((c,u)=>c>=Math.max(r[u]+M.DETECTION_MARGIN_DB,M.HEARING_FLOOR_DB_A)))}static ambientBands(t,e=M.AMBIENT_SHAPE_DB){const a=A.sumDb(e);return e.map(n=>t+n-a)}static heardAt(t,e,a,n={}){const s=n.air??A.STANDARD,r=A.speedOfSound(s.temperatureC),i=t.points[t.points.length-1]?.t;if(i===void 0)return;let o=Math.min(a,i),l=N.positionAt(t,o);if(!l)return;let c=j.seenFrom(e,l.geo);for(let _=0;_<M.ITERATIONS;_++){const k=a-c.distanceKm*1e3*1e3/r,J=Math.abs(k-o);if(o=k,l=N.positionAt(t,o),!l)return;if(c=j.seenFrom(e,l.geo),J<M.CONVERGED_MS)break}const u=N.positionAt(t,a),d=u?j.seenFrom(e,u.geo):c,h=M.regimeAt(t,o,e),p=M.inRegime(n.noise??Dt[0],h),m=n.ambientDbA??M.DEFAULT_AMBIENT_DB_A,f=M.ambientBands(m,n.ambientShapeDb),O=M.emissionAngle(t,e,o),v=p.directivity==="turbofan"?H.bandsDb(O,h,r):void 0,B=n.ground===null?A.OCTAVES.map(()=>0):g.excessDb(c.altitudeDeg,n.ground,r),S=M.bandsAt(p,c.distanceKm,s).map((_,k)=>_+(v?.[k]??0)+B[k]),F=S.map((_,k)=>_>=Math.max(f[k]+M.DETECTION_MARGIN_DB,M.HEARING_FLOOR_DB_A)),q=S.indexOf(Math.max(...S)),L=F.lastIndexOf(!0);return{track:t,audible:F.some(Boolean),levelDbA:A.sumDb(S),bandsDbA:S,ambientDbA:m,delayS:(a-o)/1e3,emittedAtMs:o,sound:c,seen:d,lagDeg:M.angleBetween(c,d),dopplerRatio:M.doppler(t,e,o,r),dominantHz:A.OCTAVES[q],cutoffHz:L<0?void 0:A.OCTAVES[L],regime:h,noise:p,emissionAngleDeg:O}}static emissionAngle(t,e,a){const n=M.VELOCITY_STEP_MS,s=N.positionAt(t,a-n),r=N.positionAt(t,a+n),i=N.positionAt(t,a);if(!s||!r||!i)return 90;const o=d=>{const h=j.seenFrom(e,d),p=h.altitudeDeg*Math.PI/180,m=h.azimuthDeg*Math.PI/180,f=h.distanceKm*1e3;return[f*Math.cos(p)*Math.sin(m),f*Math.cos(p)*Math.cos(m),f*Math.sin(p)]},[l,c,u]=[o(s.geo),o(r.geo),o(i.geo)];return H.angleDeg(c.map((d,h)=>d-l[h]),u.map(d=>-d))}static regimeAt(t,e,a){const n=M.CLIMB_SPAN_MS,s=N.positionAt(t,e-n)??N.positionAt(t,e),r=N.positionAt(t,e+n)??N.positionAt(t,e),i=N.positionAt(t,e);if(!s||!r||!i)return"overflight";const o=(Math.min(e+n,t.points[t.points.length-1].t)-Math.max(e-n,t.points[0].t))/1e3;if(o<=0)return"overflight";const l=(r.altitudeFt-s.altitudeFt)*.3048/o;return i.altitudeFt*.3048-a.heightM>M.LOW_M?"overflight":l>M.CLIMB_MPS?"takeoff":l<-1.5?"approach":"overflight"}static inRegime(t,e){return t.regimes?.[e]??t}static profile(t,e,a,n,s=2e3,r={}){const i=[];let o,l,c=a;for(let u=a;u<=n;u+=s){const d=M.heardAt(t,e,u,r);d&&(!l||d.levelDbA>l.levelDbA)&&(l=d,c=u),d?.audible?o?o.untilMs=u:i.push(o={fromMs:u,untilMs:u}):o=void 0}return{track:t,audible:i,peakDbA:l?.levelDbA??-1/0,peakAtMs:c,peakDelayS:l?.delayS??0}}static angleBetween(t,e){const a=c=>{const u=c.altitudeDeg*Math.PI/180,d=c.azimuthDeg*Math.PI/180;return[Math.cos(u)*Math.sin(d),Math.cos(u)*Math.cos(d),Math.sin(u)]},[n,s,r]=a(t),[i,o,l]=a(e);return Math.acos(Math.min(1,Math.max(-1,n*i+s*o+r*l)))*180/Math.PI}static doppler(t,e,a,n){const s=M.VELOCITY_STEP_MS,r=N.positionAt(t,a-s),i=N.positionAt(t,a+s);if(!r||!i)return 1;const o=j.seenFrom(e,r.geo).distanceKm*1e3,l=j.seenFrom(e,i.geo).distanceKm*1e3;return 1/(1-(o-l)/(2*s/1e3)/n)}}class ue{static at(t,e,a,n,s={}){const r=N.seenFrom(t,a,n);if(!r)return;const i=U.of(e),o=M.heardAt(t,a,n,{noise:M.noiseOfKind(i.kind),...s});return{hex:`${t.nonIcao?"~":""}${t.icao.toString(16).padStart(6,"0")}`,registration:e?.registration,typeCode:i.code??e?.type,name:i.basis==="nothing"?void 0:i.name,kind:i.kind,basis:i.basis,military:e?.military===!0,restricted:e?.restricted===!0,altitudeFt:r.altitudeFt,groundSpeedKt:r.groundSpeedKt,trackDeg:r.trackDeg,sky:r.sky,angularRateDegPerS:r.angularRateDegPerS,hearing:o&&{audible:o.audible,levelDbA:o.levelDbA,ambientDbA:o.ambientDbA,delayS:o.delayS,lagDeg:o.lagDeg,dopplerRatio:o.dopplerRatio,cutoffHz:o.cutoffHz,dominantHz:o.dominantHz}}}}class R{static REFERENCE_AMPLITUDE=.02;static MASKING_RANGE_DB=6;static KNEE_DB=20;static COMPRESSION_RATIO=1;static EXPANSION_RATIO=1.8;static HEADROOM_DB=Rt.HEADROOM_DB;static DEFAULT_MAX_VOICES=4;static candidates(t,e,a,n,s={}){const r=new Set;for(const[i,o]of t){const l=M.noiseOfKind(U.of(e.get(a(o))).kind);let c=1/0;for(const u of o.points)c=Math.min(c,j.seenFrom(n,{lat:u.lat,lng:u.lng,heightM:u.altitudeFt*.3048}).distanceKm);M.couldBeHeard(l,c,s.ambientDbA,s.air,s.ambientShapeDb)&&r.add(i)}return r}static voices(t,e,a,n,s,r,i={}){const o=[];for(const l of t){const c=e.get(l);if(!c||i.only?.(l)===!1)continue;const u=i.kindOf?.(l)??U.of(a.get(n(c))).kind,d=i.noiseOf?.(l)??M.noiseOfKind(u),h=M.heardAt(c,s,r,{...i,noise:d});if(!h?.audible)continue;const p=i.throughDb,m=p?h.bandsDbA.map((f,O)=>f-(p[O]??0)):h.bandsDbA;p&&!R.noticed(m,h.ambientDbA,i.ambientShapeDb)||o.push({id:l,kind:u,bandAmplitudes:R.bandAmplitudes(m,h.ambientDbA,i.referenceAmplitude,{ambientShapeDb:i.ambientShapeDb,expandUnderKnee:i.expandUnderKnee}),levelDbA:p?A.sumDb(m):h.levelDbA,distanceKm:h.sound.distanceKm,dopplerRatio:h.dopplerRatio,azimuthDeg:h.sound.azimuthDeg,elevationDeg:h.sound.altitudeDeg,character:h.noise.character,groundEcho:i.ground===null?void 0:g.echo(h.sound.altitudeDeg,i.ground,A.speedOfSound((i.air??A.STANDARD).temperatureC))})}return o.sort((l,c)=>c.levelDbA-l.levelDbA).slice(0,i.maxVoices??R.DEFAULT_MAX_VOICES)}static noticed(t,e,a){const n=M.ambientBands(e,a);return t.some((s,r)=>s>=n[r]+M.DETECTION_MARGIN_DB)}static bandAmplitudes(t,e,a=R.REFERENCE_AMPLITUDE,n={}){const s=M.ambientBands(e,n.ambientShapeDb),r=n.expandUnderKnee===!1?1:R.EXPANSION_RATIO,i=M.DETECTION_MARGIN_DB,o=A.sumDb(t),l=o-e,c=l>=R.KNEE_DB?R.KNEE_DB+(l-R.KNEE_DB)/R.COMPRESSION_RATIO:R.KNEE_DB-(R.KNEE_DB-l)*r,u=a*10**((c-R.HEADROOM_DB)/20);return t.map((d,h)=>{const p=Math.min(1,Math.max(0,(d-s[h]-i+R.MASKING_RANGE_DB)/(2*R.MASKING_RANGE_DB)));return p*p*(3-2*p)*u*10**((d-o)/20)})}static BANDS_HZ=A.OCTAVES}class Q{static RUMBLE_BELOW_HZ=500;static DULL_BELOW_HZ=2e3;static PITCH_NOTICED=.03;static text(t,e,a,n){const s=(d,h=0)=>d.toLocaleString(n,{maximumFractionDigits:h}),r=(d,h)=>d.replace(/\{(\w+)\}/g,(p,m)=>h[m]??`{${m}}`),i=[],o=[t.registration,t.name].filter(Boolean).join(" · ");i.push(o||r(e.unnamed,{hex:t.hex}));const l=[r(e.altitude,{value:s(Math.round(t.altitudeFt/100)*100)}),t.groundSpeedKt===void 0?void 0:r(e.speed,{value:s(Math.round(t.groundSpeedKt))}),t.trackDeg===void 0?void 0:r(e.heading,{value:s(Math.round(t.trackDeg))})].filter(Boolean);i.push(l.join(" · ")),i.push(r(e.position,{distance:s(t.sky.distanceKm,t.sky.distanceKm<10?1:0),elevation:s(Math.round(t.sky.altitudeDeg)),bearing:a(t.sky.azimuthDeg)}));const c=t.hearing;if(!c)i.push(e.soundUnknown);else if(!c.audible)i.push(r(e.inaudible,{level:s(Math.round(c.levelDbA)),ambient:s(Math.round(c.ambientDbA))}));else{const d=c.cutoffHz??0,h=d<=Q.RUMBLE_BELOW_HZ?e.rumble:d<=Q.DULL_BELOW_HZ?e.muffled:e.broad,p=c.dopplerRatio-1,m=Math.abs(p)<Q.PITCH_NOTICED?"":r(p>0?e.pitchHigher:e.pitchLower,{percent:s(Math.round(Math.abs(p)*100))});i.push(r(e.heard,{level:s(Math.round(c.levelDbA)),delay:s(Math.round(c.delayS)),lag:s(Math.round(c.lagDeg)),character:r(h,{cutoff:s(d)}),pitch:m}))}t.contrail&&i.push(r(t.contrail.persistent?e.contrailPersistent:e.contrailShort,{rhi:s(Math.round(t.contrail.iceRelativeHumidity*100))}));const u=[t.military?e.military:void 0,t.restricted?e.restricted:void 0].filter(Boolean);return u.length>0&&i.push(u.join(" · ")),i.push(e.candidate),i.join(`
2
- `)}}class nt{static EFFICIENCY={"airliner-narrow":.34,"airliner-wide":.38,"regional-jet":.32,"business-jet":.3,"military-jet":.22,unknown:.34};static efficiencyOf(t){return nt.EFFICIENCY[t]}}class E{static EMISSION_INDEX_WATER=1.25;static COMBUSTION_HEAT=432e5;static AIR_HEAT_CAPACITY=1004;static MOLAR_MASS_RATIO=.622;static FT_TO_M=.3048;static TROPOPAUSE_M=11e3;static TROPOPAUSE_HPA=226.32;static ISOTHERMAL_SCALE_HEIGHT_M=6341.62;static pressureAtAltitudeFt(t){const e=t*E.FT_TO_M;return e<=E.TROPOPAUSE_M?1013.25*(1-225577e-10*e)**5.25588:E.TROPOPAUSE_HPA*Math.exp(-(e-E.TROPOPAUSE_M)/E.ISOTHERMAL_SCALE_HEIGHT_M)}static saturationOverWaterPa(t){const e=t+273.15;return Math.exp(54.842763-6763.22/e-4.21*Math.log(e)+367e-6*e+Math.tanh(.0415*(e-218.8))*(53.878-1331.22/e-9.44523*Math.log(e)+.014025*e))}static saturationOverIcePa(t){const e=t+273.15;return Math.exp(9.550426-5723.265/e+3.53068*Math.log(e)-.00728332*e)}static iceRelativeHumidity(t,e){return e*E.saturationOverWaterPa(t)/E.saturationOverIcePa(t)}static mixingSlope(t,e){return E.EMISSION_INDEX_WATER*E.AIR_HEAT_CAPACITY*t*100/(E.MOLAR_MASS_RATIO*E.COMBUSTION_HEAT*(1-e))}static criticalTemperatureC(t,e){const a=Math.log(E.mixingSlope(t,e)-.053);return-46.46+9.43*a+.72*a*a}static requiredHumidity(t,e,a){const n=E.criticalTemperatureC(t,e);return(E.mixingSlope(t,e)*(a-n)+E.saturationOverWaterPa(n))/E.saturationOverWaterPa(a)}static evaluate(t,e){const a=E.criticalTemperatureC(t.pressureHpa,e),n=E.requiredHumidity(t.pressureHpa,e,t.temperatureC),s=E.iceRelativeHumidity(t.temperatureC,t.relativeHumidity),r=t.temperatureC<a&&t.relativeHumidity>=n;return{forms:r,persistent:r&&s>=1,criticalTemperatureC:a,requiredHumidity:n,iceRelativeHumidity:s}}}class G{static HOLD_MS=36e5;static DEG=Math.PI/180;static GAS_CONSTANT_OVER_GRAVITY=287.05/9.80665;static at(t,e,a){if(t.length===0)return;const n=t[0],s=t[t.length-1];if(e<n.t-G.HOLD_MS||e>s.t+G.HOLD_MS)return;const r=t.findIndex(h=>h.t>e),i=r===0?t[0]:t[(r===-1?t.length:r)-1],o=r===-1||r===0?i:t[r],l=G.atLevel(i,a),c=G.atLevel(o,a);if(!l||!c)return;const u=o.t>i.t?Math.min(1,Math.max(0,(e-i.t)/(o.t-i.t))):0,d=(h,p)=>h+(p-h)*u;return{pressureHpa:a,temperatureC:d(l.temperatureC,c.temperatureC),relativeHumidity:d(l.relativeHumidity,c.relativeHumidity),driftEastMs:d(l.driftEastMs,c.driftEastMs),driftNorthMs:d(l.driftNorthMs,c.driftNorthMs),shearPerS:d(l.shearPerS,c.shearPerS)}}static atLevel(t,e){const a=t.levels;for(let n=0;n+1<a.length;n++){const s=a[n],r=a[n+1];if(e>s.pressureHpa||e<r.pressureHpa)continue;const i=(Math.log(s.pressureHpa)-Math.log(e))/(Math.log(s.pressureHpa)-Math.log(r.pressureHpa)),o=(h,p)=>h+(p-h)*i,l=h=>{const p=h.windFromDeg*G.DEG;return{east:-h.windSpeedMs*Math.sin(p),north:-h.windSpeedMs*Math.cos(p)}},c=l(s),u=l(r),d=G.GAS_CONSTANT_OVER_GRAVITY*((s.temperatureC+r.temperatureC)/2+273.15)*Math.log(s.pressureHpa/r.pressureHpa);return{pressureHpa:e,temperatureC:o(s.temperatureC,r.temperatureC),relativeHumidity:o(s.relativeHumidity,r.relativeHumidity),driftEastMs:o(c.east,u.east),driftNorthMs:o(c.north,u.north),shearPerS:Math.hypot(u.east-c.east,u.north-c.north)/d}}}}class K{static MIN_ALTITUDE_FT=2e4;static DENSE_MS=3e5;static SPARSE_STEP_MS=6e4;static SATURATION_HORIZON_MS=3*36e5;static SATURATION_STEP_MS=6e5;static PRESSURE_STEP_HPA=5;static plan(t,e,a,n){if(a.length===0)return[];const s=[],r=new Map,i=(o,l,c)=>{const u=Math.round(l/K.PRESSURE_STEP_HPA)*K.PRESSURE_STEP_HPA,d=K.SATURATION_STEP_MS,h=Math.floor(o/d)*d,p=`${u}|${h}`,m=r.get(p);if(m!==void 0)return m+(h-o)/1e3;let f=1/0;for(let O=d;O<=K.SATURATION_HORIZON_MS;O+=d){const v=G.at(a,h+O,u);if(!v)break;if(E.evaluate(v,c).iceRelativeHumidity<1){f=O/1e3;break}}return r.set(p,f),f+(h-o)/1e3};for(const o of t.objects){const l=t.flights.get(o.id),c=o.track;if(!l||!c||c.length!==l.points.length)continue;const u=e?.get(x.keyOf(l))??U.of(void 0),d=nt.efficiencyOf(u.kind);if(d===void 0)continue;const h=[];let p=-1/0;c.forEach((m,f)=>{if(m.t<-K.DENSE_MS&&f+1<c.length&&m.t-p<K.SPARSE_STEP_MS)return;p=m.t;const O=l.points[f],v=E.pressureAtAltitudeFt(O.altitudeFt),B=G.at(a,n+m.t,v),S=B&&E.evaluate(B,d);h.push({tMs:m.t,eastM:m.eastM,northM:m.northM,upM:m.altitudeM??0,forms:S?.forms??!1,persistent:S?.persistent??!1,lifetimeS:S?rt.lifetimeS(S.iceRelativeHumidity):0,driftEastMs:B?.driftEastMs??0,driftNorthMs:B?.driftNorthMs??0,shearPerS:B?.shearPerS??rt.TYPICAL_SHEAR_PER_S,iceRelativeHumidity:S?.iceRelativeHumidity??0,saturatedForS:S?.persistent?i(n+m.t,v,d):0})}),h.some((m,f)=>m.forms&&h[f+1]?.forms)&&s.push({id:o.id,spanM:u.spanM,points:h})}return s}}const Ot=[500,400,300,250,200,150],oe=["temperature","relative_humidity","wind_speed","wind_direction"],re="2022-01-01",It=.25;class ce{fetchImpl;baseUrl;cache=new Map;constructor(t={}){this.fetchImpl=t.fetchImpl??fetch.bind(globalThis),this.baseUrl=t.baseUrl??"https://historical-forecast-api.open-meteo.com/v1/forecast"}between(t,e,a){const n=new Date(e).toISOString().slice(0,10);if(n<re)return Promise.resolve({status:"outside"});const s=new Date(a).toISOString().slice(0,10),i=`${`${Math.round(t.lat/It)},${Math.round(t.lng/It)}`}|${n}|${s}`;let o=this.cache.get(i);return o||(o=this.read(t,n,s),this.cache.set(i,o),o.then(l=>{l.status==="failed"&&this.cache.delete(i)})),o}async read(t,e,a){const n=Ot.flatMap(i=>oe.map(o=>`${o}_${i}hPa`)),s=new URLSearchParams({latitude:String(t.lat),longitude:String(t.lng),start_date:e,end_date:a,hourly:n.join(","),wind_speed_unit:"ms",timezone:"UTC"}),r=`${this.baseUrl}?${s}`;try{const i=await this.fetchImpl(r);if(!i.ok)return{status:"failed"};const o=await i.json();return this.decode(o,{id:"open-meteo-forecast",name:"Open-Meteo (historical forecast)",url:r})}catch{return{status:"failed"}}}decode(t,e){const a=t.hourly;if(!a?.time)return{status:"outside"};const n=[];return a.time.forEach((s,r)=>{const i=[];for(const o of Ot){const l=p=>a[`${p}_${o}hPa`]?.[r],c=l("temperature"),u=l("relative_humidity"),d=l("wind_speed"),h=l("wind_direction");if([c,u,d,h].some(p=>p==null))return;i.push({pressureHpa:o,temperatureC:c,relativeHumidity:u/100,windSpeedMs:d,windFromDeg:h})}n.push({t:Date.parse(`${s}Z`),levels:i})}),n.length>0?{status:"found",samples:n,source:e}:{status:"outside"}}}const de=st.point("upperAir").provide(st.BUILT_IN,[{id:"open-meteo-forecast",name:"Open-Meteo (historical forecast)",credit:"Weather data by Open-Meteo.com, CC BY 4.0",creditUrl:"https://open-meteo.com/en/docs/historical-forecast-api",create:()=>new ce}]);class y{static DEFAULT_KIND=V.DEFAULT_KIND;static STEP_MS=1e3;static LEAD_MS=12e4;static FT_PER_M=1/.3048;static ID_PREFIX="decor:";tracks=new Map;static kindOf(t,e){return V.kindOf(t,e)}static flies(t){return V.flies(t)}static ridden(t,e,a,n=()=>{}){const s=it.originOf(t);if(s)for(const r of t.decor){const i=V.kindOf(r,n(r));if(!i)continue;const o=r.sizeM,l=Math.max(o?.widthM??0,o?.lengthM??0,o?.heightM??0)/2;if(l<=0)continue;const c=y.pointAt(r,e,s),{distanceKm:u}=j.seenFrom(a,{lat:c.lat,lng:c.lng,heightM:c.altitudeFt/y.FT_PER_M});if(u*1e3<=l)return{decor:r,kind:i}}}voices(t,e,a,n={},s=()=>{}){const r=it.originOf(t);if(!r)return[];const i=new Map,o=new Map,l=Math.max(t.observerTrack.duration,(t.event.durationSeconds??0)*1e3),c=y.ridden(t,e,a,s)?.decor;for(const u of t.decor){const d=u===c?void 0:V.kindOf(u,s(u));if(!d)continue;const h=`${y.ID_PREFIX}${u.id}`;i.set(h,this.trackOf(u,h,r,l)),o.set(h,d)}for(const u of this.tracks.keys())i.has(u)||this.tracks.delete(u);return i.size===0?[]:R.voices(new Set(i.keys()),i,new Map,u=>String(u.icao),a,e,{...n,kindOf:u=>o.get(u)})}trackOf(t,e,a,n){const s=JSON.stringify([t.track,t.eastM,t.northM,t.headingDeg,a.lat,a.lng,n]),r=this.tracks.get(e);if(r?.key===s)return r.track;const i=[];for(let d=0;d<=n;d+=y.STEP_MS)i.push(y.pointAt(t,d,a));(i.length===0||i[i.length-1].t<n)&&i.push(y.pointAt(t,n,a));const o=i[0],l=i[1]??o,c=d=>(l[d]-o[d])/(l.t-o.t||1);for(let d=y.STEP_MS*10;d<=y.LEAD_MS;d+=y.STEP_MS*10)i.unshift({t:-d,lat:o.lat-c("lat")*d,lng:o.lng-c("lng")*d,altitudeFt:Math.max(0,o.altitudeFt-c("altitudeFt")*d)});const u={icao:y.hash(e),nonIcao:!0,points:i};return this.tracks.set(e,{key:s,track:u}),u}static pointAt(t,e,a){const n=Bt(t,e),s=at(n.eastM,-n.northM,a.lat,a.lng);return{t:e,lat:s.lat,lng:s.lng,altitudeFt:n.altitudeM*y.FT_PER_M}}static hash(t){let e=0;for(let a=0;a<t.length;a++)e=e*31+t.charCodeAt(a)>>>0;return e}}class z{static CABIN_DB_A={"airliner-wide":76,"airliner-narrow":78,"regional-jet":78,"business-jet":82,"regional-turboprop":84,"turboprop-light":88,"light-piston":92,"piston-heavy":90,"military-jet":95,ultralight:95,"helicopter-light":95,"helicopter-medium":96,"helicopter-heavy":98,glider:70,balloon:60};static JET_CABINS=["airliner-narrow","airliner-wide","airliner-supersonic","regional-jet","business-jet"];static JET_CABIN_SHAPE_DB=[-3,-4,-13,-24,-33,-36,-42,-55];static DEFAULT_DB_A=78;static voice(t,e={}){const a=ot.aircraftOf(t);if(!a)return;const n=M.noiseOfKind(a),s=ot.insulationDb(t),r=z.JET_CABINS.includes(a)&&t?.windowsOpen!==!0?z.JET_CABIN_SHAPE_DB.map((c,u)=>c+A.aWeightingDb(A.OCTAVES[u])):n.soundPowerA.map((c,u)=>c-s[u]),i=A.sumDb(r),o=z.levelDbA(a,t?.noise),l=r.map(c=>c-i+o);return{id:"observer:cabin",kind:a,bandAmplitudes:R.bandAmplitudes(l,e.ambientDbA??0,e.referenceAmplitude,{ambientShapeDb:e.ambientShapeDb,expandUnderKnee:e.expandUnderKnee}),levelDbA:o,inside:!0,distanceKm:0,dopplerRatio:1,azimuthDeg:0,elevationDeg:0,character:n.character}}static levelDbA(t,e){return(z.CABIN_DB_A[t]??z.DEFAULT_DB_A)+20*Math.log10(Math.max(e??1,.01))}}class W{static STEP_MS=250;static FT_PER_M=1/.3048;static ID_PREFIX="body:";tracks=new Map;static noiseOf(t){const e=M.noiseOfKind(t.kind),a=t.quieterDb??0;return a===0?e:{...e,id:`${e.id}-${a}dB`,soundPowerA:e.soundPowerA.map(n=>n-a)}}voices(t,e,a,n,s,r,i={}){const o=new Map,l=new Map,c=new Map;for(const d of t){if(!d.sound)continue;const h=`${W.ID_PREFIX}${d.id}`,p=this.trackOf(d,h,e,n,r);p&&(o.set(h,p),l.set(h,d.sound.kind),c.set(h,W.noiseOf(d.sound)))}for(const d of this.tracks.keys())o.has(d)||this.tracks.delete(d);if(o.size===0)return[];const u=at(a.eastM,-a.northM,n.lat,n.lng);return R.voices(new Set(o.keys()),o,new Map,d=>String(d.icao),{lat:u.lat,lng:u.lng,heightM:a.upM},s,{...i,kindOf:d=>l.get(d),noiseOf:d=>c.get(d)})}trackOf(t,e,a,n,s){const r=`${n.lat},${n.lng},${s}`,i=this.tracks.get(e);if(i&&i.body===t&&i.origin===r)return i.track;const o=[];for(let c=-12e4;c<=s;c+=W.STEP_MS){const u=a(t,c);if(!u)continue;const d=at(u.eastM,-u.northM,n.lat,n.lng);o.push({t:c,lat:d.lat,lng:d.lng,altitudeFt:u.upM*W.FT_PER_M})}if(o.length<2)return;const l={icao:W.hash(e),nonIcao:!0,points:o};return this.tracks.set(e,{body:t,origin:r,track:l}),l}static hash(t){let e=0;for(let a=0;a<t.length;a++)e=e*31+t.charCodeAt(a)>>>0;return e}}export{Z as AircraftAudio,K as AircraftContrails,U as AircraftModels,Rt as AmbientNoise,W as BodyHearing,z as CabinHearing,y as DecorAircraftHearing,T as TrafficDecor,ue as TrafficInfos,R as TrafficSound,Q as TrafficTooltip,de as UPPER_AIR_SOURCES};
@@ -1,2 +0,0 @@
1
- import{a9 as et,aa as g,ab as It,ac as $,ad as j,ae as N,af as Dt,ag as V,ah as st,ai as Rt,x as at,aj as it}from"./rr0-sighting-editor.mjs";import{ak as ce}from"./rr0-sighting-editor.mjs";import{C as ot}from"./ContrailGrowth-DwHS8If9.js";const Tt=.25,rt=.4,ct=6,X=12,Bt=3,lt=.2,vt=.2,ht=24,Nt=3,Ct=24,ut=1,_t=.7,Ht=1.5,wt=.8,yt=1.3,dt=.02,Pt=700,kt=-30,pt=.9,mt=5,Lt=25,Ft=.5,jt=.12,Mt=[.13,.31],Gt=.16,Ut=1.6,Kt=3.6,At=1.1,zt=.3,Wt=1e3,gt=.7,Vt=.7;class Z{context;constructor(t){this.context=t}noiseBuffer;roughBuffers=new Map;voices=new Map;bus;reverb;reverbOut;level=1;master;paused=!0;requested=[];headingDeg=0;resume(){if(!this.context){if(typeof AudioContext>"u")return;try{this.context=new AudioContext}catch(t){console.warn("AircraftAudio: Web Audio unavailable, aircraft stay silent:",t);return}}et.isLive(this.context)&&et.unlock(this.context),this.apply()}setLevel(t){this.level=t,this.master&&(this.master.gain.value=t)}setPaused(t){t!==this.paused&&(this.paused=t,this.apply())}setVoices(t,e=0){this.requested=t,this.headingDeg=e,this.apply()}dispose(){for(const t of[...this.voices.keys()])this.release(t);et.isLive(this.context)&&this.context.close(),this.context=void 0,this.master=void 0,this.bus=void 0}apply(){const t=this.context;if(!t)return;const e=this.paused?[]:this.requested,a=new Set(e.map(n=>n.id));for(const n of[...this.voices.keys()])a.has(n)||this.release(n);for(const n of e){const s=this.voices.get(n.id)??this.build(t,n);this.retarget(t,s,n)}}build(t,e){const a=t.createGain();a.gain.value=0;let n;const s=this.busOf(t);typeof t.createStereoPanner=="function"?(n=t.createStereoPanner(),a.connect(n).connect(s)):a.connect(s);const i=t.createGain(),o=e.character?.modulationDepth??0;i.gain.value=1-o/2;const r=t.createOscillator();r.type="sine";const l=t.createGain();l.gain.value=o/2,r.connect(l).connect(i.gain),i.connect(a);const c=t.createBufferSource();c.buffer=this.noise(t),c.loop=!0,c.loopStart=Math.random()*ct*.5;const u=[],d=[],h=[];for(const D of g.OCTAVES){const I=t.createBiquadFilter();I.type="bandpass",I.frequency.value=D,I.Q.value=ut;const H=t.createBiquadFilter();H.type="bandpass",H.frequency.value=D,H.Q.value=ut;const P=t.createGain();P.gain.value=0,c.connect(I).connect(H).connect(P).connect(i),u.push(I),d.push(H),h.push(P)}const p=[];for(const[D,I]of[[e.character?.toneHz,e.character?.toneShare],[e.character?.humHz,e.character?.humShare]])if(D!==void 0)for(let H=1;H<=Nt;H++){const P=t.createOscillator();P.type="sine",P.frequency.value=D*H;const tt=t.createGain();tt.gain.value=0,P.connect(tt).connect(a),p.push({oscillator:P,gain:tt,harmonic:H,baseHz:D,share:I??0})}const m=t.createGain();m.gain.value=0,m.connect(a.gain);const E=Mt.map(D=>{const I=t.createOscillator();return I.type="sine",I.frequency.value=D,I.connect(m),I}),O=t.createGain();O.gain.value=e.character?.roughness??lt;const B=t.createBufferSource();B.buffer=this.roughTable(t,Bt),B.loop=!0,B.loopStart=Math.random()*X*.5,B.connect(O).connect(i.gain);const v=t.createGain();v.gain.value=(e.character?.roughness??lt)*vt;const S=t.createBufferSource();S.buffer=this.roughTable(t,ht),S.loop=!0,S.loopStart=Math.random()*X*.5,S.connect(v).connect(i.gain);let F;const J=this.busOf(t)&&this.reverb;J&&(F=t.createGain(),F.gain.value=0,a.connect(F).connect(J));let L,_;if(!e.inside&&typeof t.createDelay=="function"){const D=t.createDelay(dt);D.delayTime.value=0;const I=t.createBiquadFilter();I.type="highshelf",I.frequency.value=Pt,I.gain.value=0;const H=t.createGain();H.gain.value=0,a.connect(D).connect(I).connect(H).connect(n??s);const P=t.createGain();P.gain.value=0,_=t.createBufferSource(),_.buffer=this.roughTable(t,ht),_.loop=!0,_.loopStart=Math.random()*X*.5,_.connect(P).connect(D.delayTime),L={delay:D,jitter:P,shelf:I,gain:H}}const k=[c,B,S,r,...p.map(D=>D.oscillator),...E,..._?[_]:[]];for(const D of k)D.start();const x={nodes:[a,i,l,O,v,m,...L?[L.delay,L.jitter,L.shelf,L.gain]:[],...p.map(D=>D.gain),...u,...d,...h,...F?[F]:[],...n?[n]:[],...k],sources:k,filters:u,seconds:d,gains:h,tones:p,lfo:r,lfoDepth:l,wander:E,wanderDepth:m,roughDepth:O,crackleDepth:v,beat:i,output:a,panner:n,send:F,echo:L};return this.voices.set(e.id,x),x}retarget(t,e,a){const n=t.currentTime,s=(p,m)=>p.setTargetAtTime(m,n,Tt),i=Math.min(Ht,Math.max(_t,a.dopplerRatio)),o=Math.min(yt,Math.max(wt,Math.sqrt(a.dopplerRatio))),r=t.sampleRate*.45,l=a.bandAmplitudes.map((p,m)=>p*Z.unweighting(g.OCTAVES[m])),c=Math.sqrt(l.reduce((p,m)=>p+m*m,0)),u=Math.min(1,Math.max(0,(a.distanceKm-mt)/(Lt-mt)));g.OCTAVES.forEach((p,m)=>{s(e.filters[m].frequency,Math.min(r,p*o)),s(e.seconds[m].frequency,Math.min(r,p*o)),s(e.gains[m].gain,l[m]*Math.sqrt(Wt/p))});const d=a.character;for(const{oscillator:p,gain:m,harmonic:E,baseHz:O,share:B}of e.tones){const v=O*E;s(p.frequency,v*i);const S=v*i;s(m.gain,S<r?B*Gt*l[Z.bandOf(S)]/E:0)}d?.modulationHz!==void 0&&s(e.lfo.frequency,d.modulationHz*i);const h=c>0?Z.saturated(c)/c:1;if(s(e.output.gain,h*(1-zt*u)),s(e.wanderDepth.gain,h*jt*u/Mt.length),e.send&&s(e.send.gain,Ut*u),e.echo){const p=a.groundEcho;s(e.echo.gain.gain,p?.lowGain??0),p&&(s(e.echo.delay.delayTime,Math.min(dt,p.delayS)),s(e.echo.jitter.gain,p.jitterS),s(e.echo.shelf.gain,p.lowGain>0?Math.max(kt,20*Math.log10(Math.max(p.highGain,1e-6)/p.lowGain)):0))}if(e.panner){const p=(a.azimuthDeg-this.headingDeg)*Math.PI/180,m=a.inside?0:Math.max(-pt,Math.min(pt,Math.sin(p)))*(1-Ft*u);s(e.panner.pan,m)}}static saturated(t){const e=Vt*gt;if(t<=e)return t;const a=gt-e;return e+a*(1-Math.exp(-(t-e)/a))}static unweighting(t){return 10**(Math.min(Ct,Math.max(0,-g.aWeightingDb(t)))/20)}static bandOf(t){let e=0;return g.OCTAVES.forEach((a,n)=>{Math.abs(Math.log(t/a))<Math.abs(Math.log(t/g.OCTAVES[e]))&&(e=n)}),e}roughTable(t,e){const a=this.roughBuffers.get(e);if(a)return a;const n=Math.floor(t.sampleRate*X),s=t.createBuffer(1,n,t.sampleRate),i=s.getChannelData(0),o=Array.from({length:X*e},()=>(Math.random()*2-1)**3),r=t.sampleRate/e;for(let l=0;l<i.length;l++){const c=l/r,u=Math.floor(c),d=c-u,h=d*d*(3-2*d);i[l]=o[u%o.length]*(1-h)+o[(u+1)%o.length]*h}return this.roughBuffers.set(e,s),s}roomImpulse(t){const e=Math.floor(t.sampleRate*Kt),a=t.createBuffer(2,e,t.sampleRate);for(let n=0;n<2;n++){const s=a.getChannelData(n);let i=0;for(let o=0;o<e;o++){const r=o/t.sampleRate,l=.6*Math.exp(-r/(At*2))+.04;i+=l*(Math.random()*2-1-i),s[o]=i*Math.exp(-r/At)}}return a}busOf(t){if(this.bus)return this.bus;const e=t.createGain();if(e.gain.value=this.level,e.connect(t.destination),this.master=e,typeof t.createConvolver=="function"){const a=t.createConvolver();a.buffer=this.roomImpulse(t);const n=t.createGain();n.gain.value=.9,a.connect(n),this.reverb=a,this.reverbOut=n}if(typeof t.createDynamicsCompressor=="function"){const a=t.createDynamicsCompressor();a.threshold.value=-6,a.knee.value=3,a.ratio.value=4,a.attack.value=.005,a.release.value=.25,a.connect(e),this.bus=a}else this.bus=e;return this.reverbOut?.connect(this.bus),this.bus}release(t){const e=this.voices.get(t);if(!e)return;this.voices.delete(t);const a=this.context;a&&(e.output.gain.setTargetAtTime(0,a.currentTime,rt/3),setTimeout(()=>{for(const n of e.sources)try{n.stop()}catch{}for(const n of e.nodes)n.disconnect()},rt*1e3*3))}noise(t){if(this.noiseBuffer)return this.noiseBuffer;const e=t.createBuffer(1,t.sampleRate*ct,t.sampleRate),a=e.getChannelData(0);for(let n=0;n<a.length;n++)a[n]=Math.random()*2-1;return this.noiseBuffer=e,e}}class U{static TYPES={A318:["Airbus A318","airliner-narrow",34.1,31.4],A319:["Airbus A319","airliner-narrow",34.1,33.8],A320:["Airbus A320","airliner-narrow",34.1,37.6],A321:["Airbus A321","airliner-narrow",34.1,44.5],A19N:["Airbus A319neo","airliner-narrow",35.8,33.8],A20N:["Airbus A320neo","airliner-narrow",35.8,37.6],A21N:["Airbus A321neo","airliner-narrow",35.8,44.5],B737:["Boeing 737-700","airliner-narrow",34.3,33.6],B738:["Boeing 737-800","airliner-narrow",35.8,39.5],B739:["Boeing 737-900","airliner-narrow",35.8,42.1],B38M:["Boeing 737 MAX 8","airliner-narrow",35.9,39.5],B39M:["Boeing 737 MAX 9","airliner-narrow",35.9,42.2],B752:["Boeing 757-200","airliner-narrow",38,47.3],B753:["Boeing 757-300","airliner-narrow",38,54.4],B762:["Boeing 767-200","airliner-wide",47.6,48.5],B763:["Boeing 767-300","airliner-wide",47.6,54.9],B764:["Boeing 767-400","airliner-wide",51.9,61.4],B772:["Boeing 777-200","airliner-wide",60.9,63.7],B77L:["Boeing 777-200LR","airliner-wide",64.8,63.7],B77W:["Boeing 777-300ER","airliner-wide",64.8,73.9],B788:["Boeing 787-8","airliner-wide",60.1,56.7],B789:["Boeing 787-9","airliner-wide",60.1,62.8],B78X:["Boeing 787-10","airliner-wide",60.1,68.3],B744:["Boeing 747-400","airliner-wide",64.4,70.7],B748:["Boeing 747-8","airliner-wide",68.4,76.3],A306:["Airbus A300-600","airliner-wide",44.8,54.1],A310:["Airbus A310","airliner-wide",43.9,46.7],A332:["Airbus A330-200","airliner-wide",60.3,58.8],A333:["Airbus A330-300","airliner-wide",60.3,63.7],A338:["Airbus A330-800","airliner-wide",64,58.8],A339:["Airbus A330-900","airliner-wide",64,63.7],A343:["Airbus A340-300","airliner-wide",60.3,63.7],A346:["Airbus A340-600","airliner-wide",63.5,75.4],A359:["Airbus A350-900","airliner-wide",64.8,66.8],A35K:["Airbus A350-1000","airliner-wide",64.8,73.8],A388:["Airbus A380-800","airliner-wide",79.8,72.7],CONC:["Concorde","airliner-supersonic",25.6,61.7],DC3:["Douglas DC-3","piston-heavy",29,19.7],DC4:["Douglas DC-4","piston-heavy",35.8,28.6],P51:["North American P-51 Mustang","piston-heavy",11.3,9.8],E170:["Embraer 170","regional-jet",26,29.9],E75L:["Embraer 175","regional-jet",26,31.7],E75S:["Embraer 175","regional-jet",26,31.7],E190:["Embraer 190","regional-jet",28.7,36.2],E195:["Embraer 195","regional-jet",28.7,38.7],E290:["Embraer 190-E2","regional-jet",33.7,36.2],E295:["Embraer 195-E2","regional-jet",33.7,41.5],CRJ2:["Bombardier CRJ200","regional-jet",21.2,26.8],CRJ7:["Bombardier CRJ700","regional-jet",23.2,32.3],CRJ9:["Bombardier CRJ900","regional-jet",24.9,36.2],CRJX:["Bombardier CRJ1000","regional-jet",26.2,39.1],AT72:["ATR 72","regional-turboprop",27.1,27.2],AT76:["ATR 72-600","regional-turboprop",27.1,27.2],AT45:["ATR 42","regional-turboprop",24.6,22.7],DH8D:["Dash 8 Q400","regional-turboprop",28.4,32.8],DH8C:["Dash 8-300","regional-turboprop",27.4,25.7],SF34:["Saab 340","regional-turboprop",21.4,19.7],B190:["Beechcraft 1900","regional-turboprop",17.7,17.6],C25A:["Cessna CitationJet CJ2","business-jet",14.3,14.4],C56X:["Cessna Citation Excel","business-jet",17.2,16],C68A:["Cessna Citation Latitude","business-jet",22,18.9],C550:["Cessna Citation II","business-jet",15.8,14.4],E55P:["Embraer Phenom 300","business-jet",15.9,15.6],E50P:["Embraer Phenom 100","business-jet",12.3,12.8],GLF5:["Gulfstream G550","business-jet",28.5,29.4],FA7X:["Dassault Falcon 7X","business-jet",26.2,23.4],CL60:["Bombardier Challenger 600","business-jet",19.6,20.9],LJ45:["Learjet 45","business-jet",14.6,17.7],H25B:["Hawker 800","business-jet",15.7,15.6],C172:["Cessna 172","light-piston",11,8.3],C152:["Cessna 152","light-piston",10.2,7.3],C182:["Cessna 182","light-piston",10.9,8.8],P28A:["Piper Cherokee","light-piston",10.7,7.2],PA34:["Piper Seneca","light-piston",11.8,8.7],SR20:["Cirrus SR20","light-piston",10.9,7.9],SR22:["Cirrus SR22","light-piston",11.7,7.9],S22T:["Cirrus SR22T","light-piston",11.7,7.9],DA40:["Diamond DA40","light-piston",11.6,8.1],DA42:["Diamond DA42","light-piston",13.4,8.6],BE20:["Beechcraft King Air 200","turboprop-light",16.6,13.3],BE58:["Beechcraft Baron","light-piston",11.5,9.1],C208:["Cessna Caravan","turboprop-light",15.9,11.5],PC12:["Pilatus PC-12","turboprop-light",16.3,14.4],TBM9:["Daher TBM 900","turboprop-light",12.8,10.7],EC35:["Airbus H135","helicopter-light",10.2,12.1],EC45:["Airbus H145","helicopter-medium",11,13.6],AS50:["Airbus H125","helicopter-light",10.7,12.9],EC30:["Airbus H130","helicopter-light",10.7,12.6],B407:["Bell 407","helicopter-light",10.7,12.7],B06:["Bell 206","helicopter-light",10.2,12],B429:["Bell 429","helicopter-medium",10.9,13],B505:["Bell 505","helicopter-light",10.4,11.9],R44:["Robinson R44","helicopter-light",10.1,11.7],R22:["Robinson R22","helicopter-light",7.7,8.8],A109:["Agusta A109","helicopter-medium",11,13],A139:["Leonardo AW139","helicopter-medium",13.8,16.7],S92:["Sikorsky S-92","helicopter-heavy",17.2,20.9],H60:["Sikorsky UH-60 Black Hawk","helicopter-heavy",16.4,19.8],T38:["Northrop T-38 Talon","military-jet",7.7,14.1],HAWK:["BAE Hawk","military-jet",9.4,11.9],GLID:["Glider","glider",17,7],BALL:["Balloon","balloon",15,20],ULAC:["Ultralight","ultralight",9.5,6],C42:["Ikarus C42","ultralight",9.4,6.3],DRON:["Drone","unmanned",1,.6]};static CATEGORIES={A1:["Light aircraft","light-piston",11,8.3],A2:["Small aircraft","business-jet",15,15],A3:["Large aircraft","airliner-narrow",34.1,37.6],A4:["High-vortex large aircraft","airliner-narrow",38,47.3],A5:["Heavy aircraft","airliner-wide",60.3,63.7],A6:["High-performance aircraft","military-jet",8,14],A7:["Rotorcraft","helicopter-medium",10.7,12.7],B1:["Glider","glider",17,7],B2:["Lighter-than-air","balloon",15,20],B4:["Ultralight","ultralight",9.5,6],B6:["Unmanned aircraft","unmanned",1.5,1]};static GENERIC={name:"Airliner",kind:"airliner-narrow",spanM:34.1,lengthM:37.6,basis:"nothing"};static of(t){const e=t?.type?.toUpperCase(),a=e?U.TYPES[e]:void 0;if(a)return{code:e,name:a[0],kind:a[1],spanM:a[2],lengthM:a[3],basis:"type"};const n=t?.category?U.CATEGORIES[t.category]:void 0;return n?{name:n[0],kind:n[1],spanM:n[2],lengthM:n[3],basis:"category"}:{...U.GENERIC}}static isHelicopter(t){return t.kind.startsWith("helicopter")}}class C{static DUSK_SUN_ELEVATION_DEG=-.83;static ALWAYS=new Set(["airliner-narrow","airliner-wide","airliner-supersonic","regional-turboprop","regional-jet","business-jet"]);static NONE=new Set(["glider","balloon"]);static BRIGHTNESS={"light-piston":[.5,.2,.5],"turboprop-light":[.7,.4,.8],ultralight:[.4,.2,.4],unmanned:[0,.05,0],"helicopter-light":[1,1,1],"helicopter-medium":[1,1,1],"helicopter-heavy":[1,1,1],"military-jet":[1,1,1]};static LANDING_LIGHTS_BELOW_FT=1e4;static LANDING_INTENSITY=600;static LANDING_BEAM_DEG=10;static LANDING_COLOR="#fff1dc";static LANDING_BRIGHTNESS={"airliner-narrow":1,"airliner-wide":1,"airliner-supersonic":1,"regional-jet":.6,"regional-turboprop":.6,"business-jet":.4,"turboprop-light":.2,"light-piston":.1,ultralight:.05,"helicopter-light":.1,"helicopter-medium":.2,"helicopter-heavy":.2};static lampsOn(t,e){if(C.NONE.has(t))return{navigation:!1,beacon:!1,strobes:!1};if(C.ALWAYS.has(t))return{navigation:!0,beacon:!0,strobes:!0};const a=e<C.DUSK_SUN_ELEVATION_DEG;return t==="unmanned"?{navigation:!1,beacon:!1,strobes:a}:{navigation:a,beacon:a,strobes:a}}static lights(t,e){const a=C.lampsOn(t.kind,e),n=t.kind.startsWith("helicopter"),s=It.find(h=>h.id===(n?"helicopter":"airliner")).create(),[i,o]=n?[5,7]:[17,18],r=t.spanM/2/i,l=t.lengthM/2/o,[c,u,d]=C.BRIGHTNESS[t.kind]??[1,1,1];return s.filter(h=>h.id.startsWith("nav")?a.navigation:h.id.startsWith("strobe")?a.strobes:h.id.startsWith("beacon")?a.beacon:!0).filter(h=>!(h.id.startsWith("beacon")&&!a.beacon)).map(h=>{const p=h.id.startsWith("nav")?c:h.id.startsWith("strobe")?u:d;return{...h,offsetM:{x:h.offsetM.x*r,y:h.offsetM.y,z:h.offsetM.z*l},intensity:(h.intensity??1)*p}}).filter(h=>(h.intensity??1)>0)}static landingLights(t,e,a){const n=C.LANDING_BRIGHTNESS[t.kind]??0;if(n===0||!C.lampsOn(t.kind,e).navigation)return[];const s=c=>c<C.LANDING_LIGHTS_BELOW_FT;if(!a.some(c=>s(c.altitudeFt)))return[];const i=C.LANDING_INTENSITY*n,o=a.flatMap((c,u)=>u>0&&s(c.altitudeFt)!==s(a[u-1].altitudeFt)?[{t:c.t,intensity:s(c.altitudeFt)?i:0}]:[]),r=t.spanM/34,l=t.lengthM/36;return[-1,1].map(c=>({id:c<0?"landing-left":"landing-right",offsetM:{x:c*5*r,y:-1,z:3*l},color:C.LANDING_COLOR,intensity:s(a[0].altitudeFt)?i:0,pattern:{kind:"steady"},beamDeg:C.LANDING_BEAM_DEG,keyframes:o}))}static bodyColor(t){return t.kind==="military-jet"?"#8a8e94":t.kind.startsWith("helicopter")?"#c8ccd1":t.kind==="unmanned"?"#2c2e33":"#dde0e4"}}class q{static FAMILIES={"amvlab-a320":["A318","A319","A320","A321","A19N","A20N","A21N"],"amvlab-b737":["B732","B733","B734","B735","B736","B737","B738","B739","B37M","B38M","B39M","B3XM"],"amvlab-a350":["A359","A35K"],"amvlab-a380":["A388"],"amvlab-b787":["B788","B789","B78X"]};static BY_TYPE=new Map(Object.entries(q.FAMILIES).flatMap(([t,e])=>e.map(a=>[a,t])));static idOf(t){return t?q.BY_TYPE.get(t.toUpperCase()):void 0}}class T{static ID_PREFIX=$.ID_PREFIX;static MAX_OBJECTS=40;static FT_TO_M=.3048;static DEG=Math.PI/180;static from(t,e,a,n=T.MAX_OBJECTS,s={}){return new Xt(t,e,a,n,s).build()}static idOf(t,e){return $.idOf(t,e)}static keyOf(t){return $.keyOf(t)}static HEIGHT_OVER_LENGTH=.29;static sizeOf(t){return{widthM:t.spanM,lengthM:t.lengthM,heightM:t.lengthM*T.HEIGHT_OVER_LENGTH}}static offsetOf(t,e){const a=j.seenFrom(t,{lat:e.lat,lng:e.lng,heightM:e.altitudeFt*T.FT_TO_M}),n=a.distanceKm*1e3,s=n*Math.cos(a.altitudeDeg*T.DEG);return{eastM:s*Math.sin(a.azimuthDeg*T.DEG),northM:s*Math.cos(a.azimuthDeg*T.DEG),upM:n*Math.sin(a.altitudeDeg*T.DEG),altitudeDeg:a.altitudeDeg,distanceKm:a.distanceKm}}static segments(t){const e=[];let a=[];for(const n of t.points){const s=a[a.length-1];s&&n.t-s.t>N.MAX_GAP_S*1e3&&(e.push(a),a=[]),a.push(n)}return e.push(a),e.filter(n=>n.length>=2)}static bearingDeg(t,e){return(Math.atan2(e.eastM-t.eastM,e.northM-t.northM)/T.DEG+360)%360}}class Xt{constructor(t,e,a,n,s){this.tracks=t,this.observer=e,this.startMs=a,this.maxObjects=n,this.options=s}build(){const t=[];for(const a of this.tracks){const n=T.keyOf(a),s=this.options.models?.get(n)??U.of(void 0);T.segments(a).forEach((i,o)=>{const r=i.map(h=>({point:h,at:T.offsetOf(this.observer,h)}));if(!r.some(h=>h.at.altitudeDeg>=0))return;const l=r.map((h,p)=>({t:h.point.t-this.startMs,eastM:h.at.eastM,northM:h.at.northM,altitudeM:h.at.upM,headingDeg:h.point.trackDeg??(p+1<r.length?T.bearingDeg(h.at,r[p+1].at):T.bearingDeg(r[p-1].at,h.at))})),c=T.idOf(a,o),u=r[Math.floor(r.length/2)].point,d=this.options.sunElevationAt?.(u)??90;t.push({object:{id:c,kind:"aircraft",eastM:l[0].eastM,northM:l[0].northM,headingDeg:l[0].headingDeg,sizeM:T.sizeOf(s),model:q.idOf(s.code)?{id:q.idOf(s.code)}:void 0,color:C.bodyColor(s),lights:[...C.lights(s,d),...C.landingLights(s,d,i.map(h=>({t:h.t-this.startMs,altitudeFt:h.altitudeFt})))],track:l},presence:{fromMs:l[0].t,untilMs:l[l.length-1].t},flight:{icao:a.icao,nonIcao:a.nonIcao,points:i},closestKm:Math.min(...r.map(h=>h.at.distanceKm))})})}t.sort((a,n)=>a.closestKm-n.closestKm);const e=t.slice(0,this.maxObjects);return{objects:e.map(a=>a.object),presence:new Map(e.map(a=>[a.object.id,a.presence])),flights:new Map(e.map(a=>[a.object.id,a.flight])),total:t.length,shown:e.length}}}const Yt=[[20,0],[120,0],[130,1.5],[140,4],[150,7.5],[160,7.5]],qt=[[20,1.5],[40,1],[60,1],[80,0],[120,0],[130,1],[140,1],[150,-3],[160,-6.5],[170,-12]],bt=.16,Jt=1,xt=[[0,-2],[10,-1],[20,0],[40,0],[50,-2],[60,-4.5],[70,-7.5],[80,-11],[90,-15],[100,-19.5],[110,-25]],$t=[[60,-15.8],[70,-11.5],[80,-8],[90,-5],[100,-2.7],[110,-1.2],[120,-.3],[130,0],[140,-2],[150,-6],[160,-10],[170,-15],[180,-20]],Zt=1.5,Et=-40,Qt=1.5,te={takeoff:{jetMps:300,flightMps:80,jetShare:[1,1,.9,.6,.3,.1,0,0]},overflight:{jetMps:280,flightMps:130,jetShare:[1,1,.9,.6,.3,.1,0,0]},approach:{jetMps:180,flightMps:70,jetShare:[.6,.5,.4,.2,.1,0,0,0]}};class w{static bandsDb(t,e,a=340){const n=te[e],s=w.fan(t)-w.fan(90),i=.62*Math.max(0,n.jetMps-n.flightMps)/a,o=-30*Math.log10(1+i/(1+i**5)**.2*Math.cos(t*Math.PI/180));return g.OCTAVES.map((r,l)=>{const c=o+w.jetRemainder(t,r*Qt/n.jetMps),u=n.jetShare[l];return 10*Math.log10(u*10**(c/10)+(1-u)*10**(s/10))})}static loudestDb(t){const e=w.loudest.get(t);if(e)return e;const a=g.OCTAVES.map(()=>-1/0);for(let n=0;n<=180;n+=5)w.bandsDb(n,t).forEach((s,i)=>a[i]=Math.max(a[i],s));return w.loudest.set(t,a),a}static loudest=new Map;static angleDeg(t,e){const a=t.reduce((s,i,o)=>s+i*e[o],0),n=Math.hypot(...t)*Math.hypot(...e);return n===0?90:Math.acos(Math.min(1,Math.max(-1,a/n)))*180/Math.PI}static fan(t){const e=w.read(xt,t,!0),a=w.read($t,t,!0)+Zt;return 10*Math.log10(10**(e/10)+10**(a/10))}static jetRemainder(t,e){const a=Math.min(1,Math.max(0,Math.log(e/bt)/Math.log(Jt/bt)));return(1-a)*w.read(Yt,t)+a*w.read(qt,t)}static read(t,e,a=!1){const[n,s]=[t[0],t[1]],[i,o]=[t[t.length-2],t[t.length-1]];if(e<=n[0])return a?Math.max(Et,n[1]+(s[1]-n[1])/(s[0]-n[0])*(e-n[0])):n[1];if(e>=o[0])return a?Math.max(Et,o[1]+(o[1]-i[1])/(o[0]-i[0])*(e-o[0])):o[1];for(let r=1;r<t.length;r++){const[l,c]=[t[r-1],t[r]];if(e<=c[0])return l[1]+(c[1]-l[1])*(e-l[0])/(c[0]-l[0])}return o[1]}}class A{static GRASS={flowResistivityKPa:200,earHeightM:1.6};static COHERENCE=.4;static JITTER_S=1e-4;static ECHO_UNDER_S=5e-4;static ECHO_FROM_S=.0015;static LOW_HZ=125;static HIGH_HZ=2e3;static AIR_DENSITY=1.2;static reflection(t,e,a=A.GRASS){const[n,s]=A.impedance(t,a);return A.reflected(n,s,Math.sin(Math.max(0,e)*Math.PI/180))}static impedance(t,e=A.GRASS){const a=A.AIR_DENSITY*t/(e.flowResistivityKPa*1e3);return[1+.0571*a**-.754,-.087*a**-.732]}static reflected(t,e,a){const[n,s,i,o]=[t*a-1,e*a,t*a+1,e*a],r=i*i+o*o;return{re:(n*i+s*o)/r,im:(s*i-n*o)/r}}static delayS(t,e=A.GRASS,a=340){return 2*e.earHeightM*Math.sin(Math.max(0,t)*Math.PI/180)/a}static excessDb(t,e=A.GRASS,a=340){const n=`${e.flowResistivityKPa}|${e.earHeightM}|${a}`;let s=A.overheads.get(n);return s||A.overheads.set(n,s=A.bandsDb(90,e,a)),A.bandsDb(t,e,a).map((i,o)=>i-s[o])}static echo(t,e=A.GRASS,a=340){const n=A.delayS(t,e,a);if(n<=A.ECHO_UNDER_S)return;const s=Math.min(1,(n-A.ECHO_UNDER_S)/(A.ECHO_FROM_S-A.ECHO_UNDER_S)),i=s*s*(3-2*s),o=r=>{const l=A.reflection(r,t,e);return i*A.COHERENCE*Math.hypot(l.re,l.im)};return{delayS:n,lowGain:o(A.LOW_HZ),highGain:o(A.HIGH_HZ),jitterS:A.JITTER_S}}static overheads=new Map;static thirds=g.OCTAVES.map(t=>[-1,0,1].map(e=>{const a=t*2**(e/3);return{middle:a,from:a*2**(-1/6),to:a*2**(1/6)}}));static impedances=new Map;static bandsDb(t,e,a){const n=A.delayS(t,e,a),s=A.COHERENCE,i=Math.sin(Math.max(0,t)*Math.PI/180);let o=A.impedances.get(e.flowResistivityKPa);return o||A.impedances.set(e.flowResistivityKPa,o=A.thirds.map(r=>r.map(l=>A.impedance(l.middle,e)))),A.thirds.map((r,l)=>{let c=0;return r.forEach((u,d)=>{const h=A.reflected(o[l][d][0],o[l][d][1],i),p=2*Math.PI*n*(u.to-u.from),[m,E]=p<1e-9?[1,0]:[(Math.sin(2*Math.PI*u.to*n)-Math.sin(2*Math.PI*u.from*n))/p,(Math.cos(2*Math.PI*u.from*n)-Math.cos(2*Math.PI*u.to*n))/p];c+=1+h.re*h.re+h.im*h.im+2*s*(h.re*m+h.im*E)}),10*Math.log10(c/r.length)})}}const Y={takeoff:{shapeDb:[10,3,-3,-2,-2,-2,5,4],levelDb:0},approach:{shapeDb:[0,0,0,0,0,0,0,0],levelDb:-8}},ee={takeoff:{shapeDb:[0,0,0,0,0,0,0,0],levelDb:0},approach:{shapeDb:[0,0,0,0,0,0,0,0],levelDb:-8}},Ot=[{id:"turbofan-narrow-body",name:"Turbofan airliner, narrow-body",kinds:["airliner-narrow"],totalDbA:148,shapeDb:[-32,-17,-9,-6,-5,-7,-12,-22],character:{toneHz:1800,toneShare:.3,humHz:90,humShare:.7},regimes:Y},{id:"turbojet-supersonic",name:"Supersonic turbojet airliner",kinds:["airliner-supersonic"],totalDbA:169.5,shapeDb:[-22,-13,-9,-6,-6,-9,-15,-25],character:{humHz:100,humShare:.7},regimes:ee},{id:"turbofan-wide-body",name:"Turbofan airliner, wide-body",kinds:["airliner-wide"],totalDbA:151,shapeDb:[-28,-14,-7,-4,-3,-6,-12,-22],character:{toneHz:1200,toneShare:.3,humHz:70,humShare:.7},regimes:Y},{id:"regional-jet",name:"Regional jet",kinds:["regional-jet"],totalDbA:144,shapeDb:[-32,-17,-9,-5,-4,-6,-11,-21],character:{toneHz:1900,toneShare:.3,humHz:95,humShare:.7},regimes:Y},{id:"business-jet",name:"Business jet",kinds:["business-jet"],totalDbA:141,shapeDb:[-30,-15,-8,-4,-3,-4,-9,-19],character:{toneHz:2500,toneShare:.25,humHz:110,humShare:.7},regimes:Y},{id:"turboprop",name:"Turboprop",kinds:["regional-turboprop","turboprop-light"],totalDbA:138,shapeDb:[-14,-9,-8,-6,-8,-13,-20,-28],character:{toneHz:80,toneShare:.5}},{id:"light-piston",name:"Light piston aircraft",kinds:["light-piston"],totalDbA:130,shapeDb:[-20,-10,-3,-6,-10,-20,-27,-42],character:{toneHz:80,toneShare:.4,modulationHz:80,modulationDepth:.4}},{id:"piston-heavy",name:"Heavy piston aircraft",kinds:["piston-heavy"],totalDbA:140,shapeDb:[-31,-12,-11,-9,-7,-6,-7,-11],character:{toneHz:84,toneShare:.4,modulationHz:84,modulationDepth:.36}},{id:"ultralight",name:"Ultralight",kinds:["ultralight"],totalDbA:124,shapeDb:[-16,-8,-5,-4,-9,-15,-23,-31],character:{toneHz:140,toneShare:.4}},{id:"helicopter-light",name:"Light helicopter",kinds:["helicopter-light"],totalDbA:134,shapeDb:[-15,-8,-4,-3,-6,-10,-16,-24],character:{modulationHz:20,modulationDepth:.5}},{id:"helicopter-medium",name:"Medium helicopter",kinds:["helicopter-medium"],totalDbA:138,shapeDb:[-14,-7,-4,-3,-6,-10,-16,-24],character:{modulationHz:22,modulationDepth:.5}},{id:"helicopter-heavy",name:"Heavy helicopter",kinds:["helicopter-heavy"],totalDbA:144,shapeDb:[-12,-6,-4,-4,-7,-11,-17,-25],character:{modulationHz:17,modulationDepth:.5}},{id:"military-jet",name:"Military jet",kinds:["military-jet"],totalDbA:152,shapeDb:[-26,-12,-6,-3,-2,-3,-7,-15]},{id:"glider",name:"Glider",kinds:["glider"],totalDbA:85,shapeDb:[-30,-22,-15,-10,-8,-8,-14,-22]},{id:"balloon",name:"Hot-air balloon",kinds:["balloon"],totalDbA:100,shapeDb:[-25,-15,-9,-5,-3,-6,-12,-20]},{id:"unmanned",name:"Unmanned aircraft",kinds:["unmanned"],totalDbA:88,shapeDb:[-40,-30,-20,-12,-6,-3,-3,-8],character:{toneHz:450,toneShare:1}}],ft=(b,t)=>b.map(e=>e+t-g.sumDb(b));function ae(b,t){if(!b)return;const e=t.toneRatio??1,a=t.toneGain??1;return{...b,...b.toneHz!==void 0?{toneHz:b.toneHz*e,toneShare:Math.min(1,(b.toneShare??0)*a)}:{},...b.humHz!==void 0?{humHz:b.humHz*e,humShare:Math.min(1,(b.humShare??0)*a)}:{}}}const St=Ot.map(b=>{const t=b.regimes===Y?"turbofan":void 0,e={id:b.id,name:b.name,soundPowerA:ft(b.shapeDb,b.totalDbA),character:b.character,directivity:t};if(!b.regimes)return e;const a={overflight:e};for(const[n,s]of Object.entries(b.regimes))a[n]={id:`${b.id}-${n}`,name:`${b.name}, ${n}`,soundPowerA:ft(b.shapeDb.map((i,o)=>i+s.shapeDb[o]),b.totalDbA+s.levelDb),character:ae(b.character,s),directivity:t};return{...e,regimes:a}});class M{static DEFAULT_AMBIENT_DB_A=35;static DETECTION_MARGIN_DB=3;static AMBIENT_SHAPE_DB=Dt.OUTDOOR_SHAPE_DB;static HEARING_FLOOR_DB_A=0;static ITERATIONS=30;static CONVERGED_MS=.5;static VELOCITY_STEP_MS=500;static CLIMB_MPS=2.5;static DESCENT_MPS=1.5;static LOW_M=3e3;static CLIMB_SPAN_MS=3e4;static noiseOfKind(t){const e=Ot.find(a=>a.kinds.includes(t));return St.find(a=>a.id===(e?.id??"turbofan-narrow-body"))}static bandsAt(t,e,a=g.STANDARD){const n=20*Math.log10(Math.max(e*1e3,1))+11;return g.OCTAVES.map((s,i)=>t.soundPowerA[i]-n-g.absorptionDbPerKm(s,a)*e)}static couldBeHeard(t,e,a=M.DEFAULT_AMBIENT_DB_A,n=g.STANDARD,s){const i=M.ambientBands(a,s);return Object.entries(t.regimes??{overflight:t}).some(([r,l])=>M.bandsAt(l,e,n).map((c,u)=>c+(l.directivity==="turbofan"?w.loudestDb(r)[u]:0)).some((c,u)=>c>=Math.max(i[u]+M.DETECTION_MARGIN_DB,M.HEARING_FLOOR_DB_A)))}static ambientBands(t,e=M.AMBIENT_SHAPE_DB){const a=g.sumDb(e);return e.map(n=>t+n-a)}static heardAt(t,e,a,n={}){const s=n.air??g.STANDARD,i=g.speedOfSound(s.temperatureC),o=t.points[t.points.length-1]?.t;if(o===void 0)return;let r=Math.min(a,o),l=N.positionAt(t,r);if(!l)return;let c=j.seenFrom(e,l.geo);for(let _=0;_<M.ITERATIONS;_++){const k=a-c.distanceKm*1e3*1e3/i,x=Math.abs(k-r);if(r=k,l=N.positionAt(t,r),!l)return;if(c=j.seenFrom(e,l.geo),x<M.CONVERGED_MS)break}const u=N.positionAt(t,a),d=u?j.seenFrom(e,u.geo):c,h=M.regimeAt(t,r,e),p=M.inRegime(n.noise??St[0],h),m=n.ambientDbA??M.DEFAULT_AMBIENT_DB_A,E=M.ambientBands(m,n.ambientShapeDb),O=M.emissionAngle(t,e,r),B=p.directivity==="turbofan"?w.bandsDb(O,h,i):void 0,v=n.ground===null?g.OCTAVES.map(()=>0):A.excessDb(c.altitudeDeg,n.ground,i),S=M.bandsAt(p,c.distanceKm,s).map((_,k)=>_+(B?.[k]??0)+v[k]),F=S.map((_,k)=>_>=Math.max(E[k]+M.DETECTION_MARGIN_DB,M.HEARING_FLOOR_DB_A)),J=S.indexOf(Math.max(...S)),L=F.lastIndexOf(!0);return{track:t,audible:F.some(Boolean),levelDbA:g.sumDb(S),bandsDbA:S,ambientDbA:m,delayS:(a-r)/1e3,emittedAtMs:r,sound:c,seen:d,lagDeg:M.angleBetween(c,d),dopplerRatio:M.doppler(t,e,r,i),dominantHz:g.OCTAVES[J],cutoffHz:L<0?void 0:g.OCTAVES[L],regime:h,noise:p,emissionAngleDeg:O}}static emissionAngle(t,e,a){const n=M.VELOCITY_STEP_MS,s=N.positionAt(t,a-n),i=N.positionAt(t,a+n),o=N.positionAt(t,a);if(!s||!i||!o)return 90;const r=d=>{const h=j.seenFrom(e,d),p=h.altitudeDeg*Math.PI/180,m=h.azimuthDeg*Math.PI/180,E=h.distanceKm*1e3;return[E*Math.cos(p)*Math.sin(m),E*Math.cos(p)*Math.cos(m),E*Math.sin(p)]},[l,c,u]=[r(s.geo),r(i.geo),r(o.geo)];return w.angleDeg(c.map((d,h)=>d-l[h]),u.map(d=>-d))}static regimeAt(t,e,a){const n=M.CLIMB_SPAN_MS,s=N.positionAt(t,e-n)??N.positionAt(t,e),i=N.positionAt(t,e+n)??N.positionAt(t,e),o=N.positionAt(t,e);if(!s||!i||!o)return"overflight";const r=(Math.min(e+n,t.points[t.points.length-1].t)-Math.max(e-n,t.points[0].t))/1e3;if(r<=0)return"overflight";const l=(i.altitudeFt-s.altitudeFt)*.3048/r;return o.altitudeFt*.3048-a.heightM>M.LOW_M?"overflight":l>M.CLIMB_MPS?"takeoff":l<-1.5?"approach":"overflight"}static inRegime(t,e){return t.regimes?.[e]??t}static profile(t,e,a,n,s=2e3,i={}){const o=[];let r,l,c=a;for(let u=a;u<=n;u+=s){const d=M.heardAt(t,e,u,i);d&&(!l||d.levelDbA>l.levelDbA)&&(l=d,c=u),d?.audible?r?r.untilMs=u:o.push(r={fromMs:u,untilMs:u}):r=void 0}return{track:t,audible:o,peakDbA:l?.levelDbA??-1/0,peakAtMs:c,peakDelayS:l?.delayS??0}}static angleBetween(t,e){const a=c=>{const u=c.altitudeDeg*Math.PI/180,d=c.azimuthDeg*Math.PI/180;return[Math.cos(u)*Math.sin(d),Math.cos(u)*Math.cos(d),Math.sin(u)]},[n,s,i]=a(t),[o,r,l]=a(e);return Math.acos(Math.min(1,Math.max(-1,n*o+s*r+i*l)))*180/Math.PI}static doppler(t,e,a,n){const s=M.VELOCITY_STEP_MS,i=N.positionAt(t,a-s),o=N.positionAt(t,a+s);if(!i||!o)return 1;const r=j.seenFrom(e,i.geo).distanceKm*1e3,l=j.seenFrom(e,o.geo).distanceKm*1e3;return 1/(1-(r-l)/(2*s/1e3)/n)}}class ie{static at(t,e,a,n,s={}){const i=N.seenFrom(t,a,n);if(!i)return;const o=U.of(e),r=M.heardAt(t,a,n,{noise:M.noiseOfKind(o.kind),...s});return{hex:`${t.nonIcao?"~":""}${t.icao.toString(16).padStart(6,"0")}`,registration:e?.registration,typeCode:o.code??e?.type,name:o.basis==="nothing"?void 0:o.name,kind:o.kind,basis:o.basis,military:e?.military===!0,restricted:e?.restricted===!0,altitudeFt:i.altitudeFt,groundSpeedKt:i.groundSpeedKt,trackDeg:i.trackDeg,sky:i.sky,angularRateDegPerS:i.angularRateDegPerS,hearing:r&&{audible:r.audible,levelDbA:r.levelDbA,ambientDbA:r.ambientDbA,delayS:r.delayS,lagDeg:r.lagDeg,dopplerRatio:r.dopplerRatio,cutoffHz:r.cutoffHz,dominantHz:r.dominantHz}}}}class R{static REFERENCE_AMPLITUDE=.02;static MASKING_RANGE_DB=6;static KNEE_DB=20;static COMPRESSION_RATIO=1;static EXPANSION_RATIO=1.8;static HEADROOM_DB=Dt.HEADROOM_DB;static DEFAULT_MAX_VOICES=4;static candidates(t,e,a,n,s={}){const i=new Set;for(const[o,r]of t){const l=M.noiseOfKind(U.of(e.get(a(r))).kind);let c=1/0;for(const u of r.points)c=Math.min(c,j.seenFrom(n,{lat:u.lat,lng:u.lng,heightM:u.altitudeFt*.3048}).distanceKm);M.couldBeHeard(l,c,s.ambientDbA,s.air,s.ambientShapeDb)&&i.add(o)}return i}static voices(t,e,a,n,s,i,o={}){const r=[];for(const l of t){const c=e.get(l);if(!c||o.only?.(l)===!1)continue;const u=o.kindOf?.(l)??U.of(a.get(n(c))).kind,d=o.noiseOf?.(l)??M.noiseOfKind(u),h=M.heardAt(c,s,i,{...o,noise:d});if(!h?.audible)continue;const p=o.throughDb,m=p?h.bandsDbA.map((E,O)=>E-(p[O]??0)):h.bandsDbA;p&&!R.noticed(m,h.ambientDbA,o.ambientShapeDb)||r.push({id:l,kind:u,bandAmplitudes:R.bandAmplitudes(m,h.ambientDbA,o.referenceAmplitude,{ambientShapeDb:o.ambientShapeDb,expandUnderKnee:o.expandUnderKnee}),levelDbA:p?g.sumDb(m):h.levelDbA,distanceKm:h.sound.distanceKm,dopplerRatio:h.dopplerRatio,azimuthDeg:h.sound.azimuthDeg,elevationDeg:h.sound.altitudeDeg,character:h.noise.character,groundEcho:o.ground===null?void 0:A.echo(h.sound.altitudeDeg,o.ground,g.speedOfSound((o.air??g.STANDARD).temperatureC))})}return r.sort((l,c)=>c.levelDbA-l.levelDbA).slice(0,o.maxVoices??R.DEFAULT_MAX_VOICES)}static noticed(t,e,a){const n=M.ambientBands(e,a);return t.some((s,i)=>s>=n[i]+M.DETECTION_MARGIN_DB)}static bandAmplitudes(t,e,a=R.REFERENCE_AMPLITUDE,n={}){const s=M.ambientBands(e,n.ambientShapeDb),i=n.expandUnderKnee===!1?1:R.EXPANSION_RATIO,o=M.DETECTION_MARGIN_DB,r=g.sumDb(t),l=r-e,c=l>=R.KNEE_DB?R.KNEE_DB+(l-R.KNEE_DB)/R.COMPRESSION_RATIO:R.KNEE_DB-(R.KNEE_DB-l)*i,u=a*10**((c-R.HEADROOM_DB)/20);return t.map((d,h)=>{const p=Math.min(1,Math.max(0,(d-s[h]-o+R.MASKING_RANGE_DB)/(2*R.MASKING_RANGE_DB)));return p*p*(3-2*p)*u*10**((d-r)/20)})}static BANDS_HZ=g.OCTAVES}class Q{static RUMBLE_BELOW_HZ=500;static DULL_BELOW_HZ=2e3;static PITCH_NOTICED=.03;static text(t,e,a,n){const s=(d,h=0)=>d.toLocaleString(n,{maximumFractionDigits:h}),i=(d,h)=>d.replace(/\{(\w+)\}/g,(p,m)=>h[m]??`{${m}}`),o=[],r=[t.registration,t.name].filter(Boolean).join(" · ");o.push(r||i(e.unnamed,{hex:t.hex}));const l=[i(e.altitude,{value:s(Math.round(t.altitudeFt/100)*100)}),t.groundSpeedKt===void 0?void 0:i(e.speed,{value:s(Math.round(t.groundSpeedKt))}),t.trackDeg===void 0?void 0:i(e.heading,{value:s(Math.round(t.trackDeg))})].filter(Boolean);o.push(l.join(" · ")),o.push(i(e.position,{distance:s(t.sky.distanceKm,t.sky.distanceKm<10?1:0),elevation:s(Math.round(t.sky.altitudeDeg)),bearing:a(t.sky.azimuthDeg)}));const c=t.hearing;if(!c)o.push(e.soundUnknown);else if(!c.audible)o.push(i(e.inaudible,{level:s(Math.round(c.levelDbA)),ambient:s(Math.round(c.ambientDbA))}));else{const d=c.cutoffHz??0,h=d<=Q.RUMBLE_BELOW_HZ?e.rumble:d<=Q.DULL_BELOW_HZ?e.muffled:e.broad,p=c.dopplerRatio-1,m=Math.abs(p)<Q.PITCH_NOTICED?"":i(p>0?e.pitchHigher:e.pitchLower,{percent:s(Math.round(Math.abs(p)*100))});o.push(i(e.heard,{level:s(Math.round(c.levelDbA)),delay:s(Math.round(c.delayS)),lag:s(Math.round(c.lagDeg)),character:i(h,{cutoff:s(d)}),pitch:m}))}t.contrail&&o.push(i(t.contrail.persistent?e.contrailPersistent:e.contrailShort,{rhi:s(Math.round(t.contrail.iceRelativeHumidity*100))}));const u=[t.military?e.military:void 0,t.restricted?e.restricted:void 0].filter(Boolean);return u.length>0&&o.push(u.join(" · ")),o.push(e.candidate),o.join(`
2
- `)}}class nt{static EFFICIENCY={"airliner-narrow":.34,"airliner-wide":.38,"regional-jet":.32,"business-jet":.3,"military-jet":.22,unknown:.34};static efficiencyOf(t){return nt.EFFICIENCY[t]}}class f{static EMISSION_INDEX_WATER=1.25;static COMBUSTION_HEAT=432e5;static AIR_HEAT_CAPACITY=1004;static MOLAR_MASS_RATIO=.622;static FT_TO_M=.3048;static TROPOPAUSE_M=11e3;static TROPOPAUSE_HPA=226.32;static ISOTHERMAL_SCALE_HEIGHT_M=6341.62;static pressureAtAltitudeFt(t){const e=t*f.FT_TO_M;return e<=f.TROPOPAUSE_M?1013.25*(1-225577e-10*e)**5.25588:f.TROPOPAUSE_HPA*Math.exp(-(e-f.TROPOPAUSE_M)/f.ISOTHERMAL_SCALE_HEIGHT_M)}static saturationOverWaterPa(t){const e=t+273.15;return Math.exp(54.842763-6763.22/e-4.21*Math.log(e)+367e-6*e+Math.tanh(.0415*(e-218.8))*(53.878-1331.22/e-9.44523*Math.log(e)+.014025*e))}static saturationOverIcePa(t){const e=t+273.15;return Math.exp(9.550426-5723.265/e+3.53068*Math.log(e)-.00728332*e)}static iceRelativeHumidity(t,e){return e*f.saturationOverWaterPa(t)/f.saturationOverIcePa(t)}static mixingSlope(t,e){return f.EMISSION_INDEX_WATER*f.AIR_HEAT_CAPACITY*t*100/(f.MOLAR_MASS_RATIO*f.COMBUSTION_HEAT*(1-e))}static criticalTemperatureC(t,e){const a=Math.log(f.mixingSlope(t,e)-.053);return-46.46+9.43*a+.72*a*a}static requiredHumidity(t,e,a){const n=f.criticalTemperatureC(t,e);return(f.mixingSlope(t,e)*(a-n)+f.saturationOverWaterPa(n))/f.saturationOverWaterPa(a)}static evaluate(t,e){const a=f.criticalTemperatureC(t.pressureHpa,e),n=f.requiredHumidity(t.pressureHpa,e,t.temperatureC),s=f.iceRelativeHumidity(t.temperatureC,t.relativeHumidity),i=t.temperatureC<a&&t.relativeHumidity>=n;return{forms:i,persistent:i&&s>=1,criticalTemperatureC:a,requiredHumidity:n,iceRelativeHumidity:s}}}class G{static HOLD_MS=36e5;static DEG=Math.PI/180;static GAS_CONSTANT_OVER_GRAVITY=287.05/9.80665;static at(t,e,a){if(t.length===0)return;const n=t[0],s=t[t.length-1];if(e<n.t-G.HOLD_MS||e>s.t+G.HOLD_MS)return;const i=t.findIndex(h=>h.t>e),o=i===0?t[0]:t[(i===-1?t.length:i)-1],r=i===-1||i===0?o:t[i],l=G.atLevel(o,a),c=G.atLevel(r,a);if(!l||!c)return;const u=r.t>o.t?Math.min(1,Math.max(0,(e-o.t)/(r.t-o.t))):0,d=(h,p)=>h+(p-h)*u;return{pressureHpa:a,temperatureC:d(l.temperatureC,c.temperatureC),relativeHumidity:d(l.relativeHumidity,c.relativeHumidity),driftEastMs:d(l.driftEastMs,c.driftEastMs),driftNorthMs:d(l.driftNorthMs,c.driftNorthMs),shearPerS:d(l.shearPerS,c.shearPerS)}}static atLevel(t,e){const a=t.levels;for(let n=0;n+1<a.length;n++){const s=a[n],i=a[n+1];if(e>s.pressureHpa||e<i.pressureHpa)continue;const o=(Math.log(s.pressureHpa)-Math.log(e))/(Math.log(s.pressureHpa)-Math.log(i.pressureHpa)),r=(h,p)=>h+(p-h)*o,l=h=>{const p=h.windFromDeg*G.DEG;return{east:-h.windSpeedMs*Math.sin(p),north:-h.windSpeedMs*Math.cos(p)}},c=l(s),u=l(i),d=G.GAS_CONSTANT_OVER_GRAVITY*((s.temperatureC+i.temperatureC)/2+273.15)*Math.log(s.pressureHpa/i.pressureHpa);return{pressureHpa:e,temperatureC:r(s.temperatureC,i.temperatureC),relativeHumidity:r(s.relativeHumidity,i.relativeHumidity),driftEastMs:r(c.east,u.east),driftNorthMs:r(c.north,u.north),shearPerS:Math.hypot(u.east-c.east,u.north-c.north)/d}}}}class K{static MIN_ALTITUDE_FT=2e4;static DENSE_MS=3e5;static SPARSE_STEP_MS=6e4;static SATURATION_HORIZON_MS=3*36e5;static SATURATION_STEP_MS=6e5;static PRESSURE_STEP_HPA=5;static plan(t,e,a,n){if(a.length===0)return[];const s=[],i=new Map,o=(r,l,c)=>{const u=Math.round(l/K.PRESSURE_STEP_HPA)*K.PRESSURE_STEP_HPA,d=K.SATURATION_STEP_MS,h=Math.floor(r/d)*d,p=`${u}|${h}`,m=i.get(p);if(m!==void 0)return m+(h-r)/1e3;let E=1/0;for(let O=d;O<=K.SATURATION_HORIZON_MS;O+=d){const B=G.at(a,h+O,u);if(!B)break;if(f.evaluate(B,c).iceRelativeHumidity<1){E=O/1e3;break}}return i.set(p,E),E+(h-r)/1e3};for(const r of t.objects){const l=t.flights.get(r.id),c=r.track;if(!l||!c||c.length!==l.points.length)continue;const u=e?.get($.keyOf(l))??U.of(void 0),d=nt.efficiencyOf(u.kind);if(d===void 0)continue;const h=[];let p=-1/0;c.forEach((m,E)=>{if(m.t<-K.DENSE_MS&&E+1<c.length&&m.t-p<K.SPARSE_STEP_MS)return;p=m.t;const O=l.points[E],B=f.pressureAtAltitudeFt(O.altitudeFt),v=G.at(a,n+m.t,B),S=v&&f.evaluate(v,d);h.push({tMs:m.t,eastM:m.eastM,northM:m.northM,upM:m.altitudeM??0,forms:S?.forms??!1,persistent:S?.persistent??!1,lifetimeS:S?ot.lifetimeS(S.iceRelativeHumidity):0,driftEastMs:v?.driftEastMs??0,driftNorthMs:v?.driftNorthMs??0,shearPerS:v?.shearPerS??ot.TYPICAL_SHEAR_PER_S,iceRelativeHumidity:S?.iceRelativeHumidity??0,saturatedForS:S?.persistent?o(n+m.t,B,d):0})}),h.some((m,E)=>m.forms&&h[E+1]?.forms)&&s.push({id:r.id,spanM:u.spanM,points:h})}return s}}class y{static DEFAULT_KIND=V.DEFAULT_KIND;static STEP_MS=1e3;static LEAD_MS=12e4;static FT_PER_M=1/.3048;static ID_PREFIX="decor:";tracks=new Map;static kindOf(t,e){return V.kindOf(t,e)}static flies(t){return V.flies(t)}static ridden(t,e,a,n=()=>{}){const s=st.originOf(t);if(s)for(const i of t.decor){const o=V.kindOf(i,n(i));if(!o)continue;const r=i.sizeM,l=Math.max(r?.widthM??0,r?.lengthM??0,r?.heightM??0)/2;if(l<=0)continue;const c=y.pointAt(i,e,s),{distanceKm:u}=j.seenFrom(a,{lat:c.lat,lng:c.lng,heightM:c.altitudeFt/y.FT_PER_M});if(u*1e3<=l)return{decor:i,kind:o}}}voices(t,e,a,n={},s=()=>{}){const i=st.originOf(t);if(!i)return[];const o=new Map,r=new Map,l=Math.max(t.observerTrack.duration,(t.event.durationSeconds??0)*1e3),c=y.ridden(t,e,a,s)?.decor;for(const u of t.decor){const d=u===c?void 0:V.kindOf(u,s(u));if(!d)continue;const h=`${y.ID_PREFIX}${u.id}`;o.set(h,this.trackOf(u,h,i,l)),r.set(h,d)}for(const u of this.tracks.keys())o.has(u)||this.tracks.delete(u);return o.size===0?[]:R.voices(new Set(o.keys()),o,new Map,u=>String(u.icao),a,e,{...n,kindOf:u=>r.get(u)})}trackOf(t,e,a,n){const s=JSON.stringify([t.track,t.eastM,t.northM,t.headingDeg,a.lat,a.lng,n]),i=this.tracks.get(e);if(i?.key===s)return i.track;const o=[];for(let d=0;d<=n;d+=y.STEP_MS)o.push(y.pointAt(t,d,a));(o.length===0||o[o.length-1].t<n)&&o.push(y.pointAt(t,n,a));const r=o[0],l=o[1]??r,c=d=>(l[d]-r[d])/(l.t-r.t||1);for(let d=y.STEP_MS*10;d<=y.LEAD_MS;d+=y.STEP_MS*10)o.unshift({t:-d,lat:r.lat-c("lat")*d,lng:r.lng-c("lng")*d,altitudeFt:Math.max(0,r.altitudeFt-c("altitudeFt")*d)});const u={icao:y.hash(e),nonIcao:!0,points:o};return this.tracks.set(e,{key:s,track:u}),u}static pointAt(t,e,a){const n=Rt(t,e),s=at(n.eastM,-n.northM,a.lat,a.lng);return{t:e,lat:s.lat,lng:s.lng,altitudeFt:n.altitudeM*y.FT_PER_M}}static hash(t){let e=0;for(let a=0;a<t.length;a++)e=e*31+t.charCodeAt(a)>>>0;return e}}class z{static CABIN_DB_A={"airliner-wide":76,"airliner-narrow":78,"regional-jet":78,"business-jet":82,"regional-turboprop":84,"turboprop-light":88,"light-piston":92,"piston-heavy":90,"military-jet":95,ultralight:95,"helicopter-light":95,"helicopter-medium":96,"helicopter-heavy":98,glider:70,balloon:60};static JET_CABINS=["airliner-narrow","airliner-wide","airliner-supersonic","regional-jet","business-jet"];static JET_CABIN_SHAPE_DB=[-3,-4,-13,-24,-33,-36,-42,-55];static DEFAULT_DB_A=78;static voice(t,e={}){const a=it.aircraftOf(t);if(!a)return;const n=M.noiseOfKind(a),s=it.insulationDb(t),i=z.JET_CABINS.includes(a)&&t?.windowsOpen!==!0?z.JET_CABIN_SHAPE_DB.map((c,u)=>c+g.aWeightingDb(g.OCTAVES[u])):n.soundPowerA.map((c,u)=>c-s[u]),o=g.sumDb(i),r=z.levelDbA(a,t?.noise),l=i.map(c=>c-o+r);return{id:"observer:cabin",kind:a,bandAmplitudes:R.bandAmplitudes(l,e.ambientDbA??0,e.referenceAmplitude,{ambientShapeDb:e.ambientShapeDb,expandUnderKnee:e.expandUnderKnee}),levelDbA:r,inside:!0,distanceKm:0,dopplerRatio:1,azimuthDeg:0,elevationDeg:0,character:n.character}}static levelDbA(t,e){return(z.CABIN_DB_A[t]??z.DEFAULT_DB_A)+20*Math.log10(Math.max(e??1,.01))}}class W{static STEP_MS=250;static FT_PER_M=1/.3048;static ID_PREFIX="body:";tracks=new Map;static noiseOf(t){const e=M.noiseOfKind(t.kind),a=t.quieterDb??0;return a===0?e:{...e,id:`${e.id}-${a}dB`,soundPowerA:e.soundPowerA.map(n=>n-a)}}voices(t,e,a,n,s,i,o={}){const r=new Map,l=new Map,c=new Map;for(const d of t){if(!d.sound)continue;const h=`${W.ID_PREFIX}${d.id}`,p=this.trackOf(d,h,e,n,i);p&&(r.set(h,p),l.set(h,d.sound.kind),c.set(h,W.noiseOf(d.sound)))}for(const d of this.tracks.keys())r.has(d)||this.tracks.delete(d);if(r.size===0)return[];const u=at(a.eastM,-a.northM,n.lat,n.lng);return R.voices(new Set(r.keys()),r,new Map,d=>String(d.icao),{lat:u.lat,lng:u.lng,heightM:a.upM},s,{...o,kindOf:d=>l.get(d),noiseOf:d=>c.get(d)})}trackOf(t,e,a,n,s){const i=`${n.lat},${n.lng},${s}`,o=this.tracks.get(e);if(o&&o.body===t&&o.origin===i)return o.track;const r=[];for(let c=-12e4;c<=s;c+=W.STEP_MS){const u=a(t,c);if(!u)continue;const d=at(u.eastM,-u.northM,n.lat,n.lng);r.push({t:c,lat:d.lat,lng:d.lng,altitudeFt:u.upM*W.FT_PER_M})}if(r.length<2)return;const l={icao:W.hash(e),nonIcao:!0,points:r};return this.tracks.set(e,{body:t,origin:i,track:l}),l}static hash(t){let e=0;for(let a=0;a<t.length;a++)e=e*31+t.charCodeAt(a)>>>0;return e}}export{Z as AircraftAudio,K as AircraftContrails,U as AircraftModels,Dt as AmbientNoise,W as BodyHearing,z as CabinHearing,y as DecorAircraftHearing,T as TrafficDecor,ie as TrafficInfos,R as TrafficSound,Q as TrafficTooltip,ce as UPPER_AIR_SOURCES};