@rr0/ufoathome 0.190.0 → 0.191.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (160) hide show
  1. package/dist-embed-scene/{AdsbLolArchiveProvider-DdUpO-EA.js → AdsbLolArchiveProvider-BtF4baVw.js} +1 -1
  2. package/dist-embed-scene/{BeamEditor-BLtQJ7dq.js → BeamEditor-Dj1Wt50v.js} +1 -1
  3. package/dist-embed-scene/BeamSystem-CaNus1WN.js +1 -0
  4. package/dist-embed-scene/{BirdEditor-C6dn5_wS.js → BirdEditor-CKpe681e.js} +1 -1
  5. package/dist-embed-scene/{BirdFlock-DGC3adr7.js → BirdFlock-B2SbkMme.js} +1 -1
  6. package/dist-embed-scene/ContrailSystem-ChG1viIv.js +1 -0
  7. package/dist-embed-scene/{ControlPasses-BZIhjZfW.js → ControlPasses-Cls4RMwd.js} +1 -1
  8. package/dist-embed-scene/{DroneEditor-iXr-XzB2.js → DroneEditor-BDDLiZPp.js} +1 -1
  9. package/dist-embed-scene/{DroneFlight-D0-Y_wej.js → DroneFlight-BTFHGVWd.js} +1 -1
  10. package/dist-embed-scene/{Flightradar24Provider-DnJbUJ3f.js → Flightradar24Provider-BBj_wixV.js} +1 -1
  11. package/dist-embed-scene/GLTFLoader-CKDxld-A.js +1 -0
  12. package/dist-embed-scene/{GenerativeKitMessages-7-3kT9Ef.js → GenerativeKitMessages-BhHcmiXg.js} +1 -1
  13. package/dist-embed-scene/{HeadlightSystem-DOQSyusn.js → HeadlightSystem-Di3CUtA1.js} +1 -1
  14. package/dist-embed-scene/{LanternEditor-CHkp6fvG.js → LanternEditor-iByq1q3j.js} +1 -1
  15. package/dist-embed-scene/{LaserBeam-BS0xtrAx.js → LaserBeam-BQWS_xWa.js} +1 -1
  16. package/dist-embed-scene/{LaunchEditor-C2XidkVF.js → LaunchEditor-CjpESdIe.js} +1 -1
  17. package/dist-embed-scene/{LaunchPlume-GdjoMQQa.js → LaunchPlume-DVsshxQE.js} +1 -1
  18. package/dist-embed-scene/{LaunchSimulation-C_x89oL_.js → LaunchSimulation-BU7X_C8t.js} +1 -1
  19. package/dist-embed-scene/{ModuleSession-CnHhUFre.js → ModuleSession-Hj3QwLuw.js} +3 -3
  20. package/dist-embed-scene/ModuleThree-D1uz5JiH.js +1 -0
  21. package/dist-embed-scene/{ParameterForm-liNpnZ93.js → ParameterForm-BHRESNZ4.js} +1 -1
  22. package/dist-embed-scene/{RailwaySystem-8h9OGJkr.js → RailwaySystem-DBYCLMyL.js} +1 -1
  23. package/dist-embed-scene/{ReentryEditor-DqSDU-se.js → ReentryEditor-DpNPIxOG.js} +1 -1
  24. package/dist-embed-scene/{ReentrySimulation-DCNhQGDE.js → ReentrySimulation-m-TICP2i.js} +1 -1
  25. package/dist-embed-scene/ReferenceSystem-B6FHr1Pb.js +1 -0
  26. package/dist-embed-scene/{RoadMarkings-DAs6evab.js → RoadMarkings-DzCQFpjf.js} +1 -1
  27. package/dist-embed-scene/{SceneNames_en-BLm2h3zy.js → SceneNames_en-Dn90NisJ.js} +1 -1
  28. package/dist-embed-scene/{SceneNames_es-DrJ24RvP.js → SceneNames_es-DH6GZWja.js} +1 -1
  29. package/dist-embed-scene/{SceneNames_fr-CddH0oWD.js → SceneNames_fr-rltu5c_j.js} +1 -1
  30. package/dist-embed-scene/{SceneNames_it-DL3AbXlk.js → SceneNames_it-DsNshdIp.js} +1 -1
  31. package/dist-embed-scene/{SkyLantern-dInLqzN4.js → SkyLantern-BKxwl7Po.js} +1 -1
  32. package/dist-embed-scene/{TimelineTracks-B73gWzRB.js → TimelineTracks-Cjt0OHJS.js} +1 -1
  33. package/dist-embed-scene/{TraceSystem-vEBDgerB.js → TraceSystem-CwBlzmXK.js} +2 -2
  34. package/dist-embed-scene/{UfoMessages_en-BzK4iS9N.js → UfoMessages_en-A8Ku1B0Y.js} +1 -1
  35. package/dist-embed-scene/{WaterSystem-QZGlpcQ7.js → WaterSystem-BOnTlD7m.js} +2 -2
  36. package/dist-embed-scene/rr0-scene.mjs +331 -331
  37. package/dist-embed-scene/sightingSchema-CgwoRMl-.js +1 -0
  38. package/dist-embed-scene/trafficRuntime-DRDMbo2X.js +2 -0
  39. package/dist-embed-sighting/{AdsbLolArchiveProvider-BYOz5Wdl.js → AdsbLolArchiveProvider-BfWrS1jn.js} +1 -1
  40. package/dist-embed-sighting/{BallesterGuaspAssessor-CLQvJKlm.js → BallesterGuaspAssessor-BPaiHWd9.js} +1 -1
  41. package/dist-embed-sighting/{BeamEditor-Bl_2xUBv.js → BeamEditor--mMu1zwv.js} +2 -2
  42. package/dist-embed-sighting/BeamSystem-Cqe7QaN4.js +1 -0
  43. package/dist-embed-sighting/{BirdEditor-DAw14Ex2.js → BirdEditor-DZ1Ybqeu.js} +1 -1
  44. package/dist-embed-sighting/{BirdFlock-BbObIeXW.js → BirdFlock-BZScQXfR.js} +1 -1
  45. package/dist-embed-sighting/{CaseReportExport-pqKd-0cF.js → CaseReportExport-Jt3sfR-8.js} +3 -3
  46. package/dist-embed-sighting/ContrailSystem-Di5w5IVi.js +1 -0
  47. package/dist-embed-sighting/{ControlPasses-B78JMfGN.js → ControlPasses-Dr6eP2Mq.js} +1 -1
  48. package/dist-embed-sighting/{CoverageAssessor-BSoRnjHD.js → CoverageAssessor-Cu9wP4ZB.js} +1 -1
  49. package/dist-embed-sighting/{DroneEditor-C6uGwJCK.js → DroneEditor-Bo19kUte.js} +2 -2
  50. package/dist-embed-sighting/{DroneFlight-BPuws32_.js → DroneFlight-WxqILFs6.js} +1 -1
  51. package/dist-embed-sighting/{Flightradar24Provider-RjrQ963H.js → Flightradar24Provider-DJmvd2AL.js} +1 -1
  52. package/dist-embed-sighting/GLTFLoader-FWVFviG5.js +1 -0
  53. package/dist-embed-sighting/GenerativeKitMessages-NbyGMKAR.js +1 -0
  54. package/dist-embed-sighting/HeadlightSystem-Ce7sHylX.js +34 -0
  55. package/dist-embed-sighting/{HynekAssessor-CJ9APziM.js → HynekAssessor-DWDZGeLY.js} +1 -1
  56. package/dist-embed-sighting/{LanternEditor-2qGw33iQ.js → LanternEditor-Do0kggi8.js} +1 -1
  57. package/dist-embed-sighting/{LaserBeam-DotCCB1U.js → LaserBeam-CMO6tMze.js} +1 -1
  58. package/dist-embed-sighting/{LaunchEditor-QW4_Sx3j.js → LaunchEditor-CZri7DN4.js} +1 -1
  59. package/dist-embed-sighting/{LaunchPlume-CNTwnOG6.js → LaunchPlume-DxDfUSlS.js} +1 -1
  60. package/dist-embed-sighting/LaunchSimulation-CTxbrEJw.js +1 -0
  61. package/dist-embed-sighting/{ModuleSession-CQnRKmzR.js → ModuleSession-BCtFMDJY.js} +3 -3
  62. package/dist-embed-sighting/ModuleThree-DPVHqcup.js +1 -0
  63. package/dist-embed-sighting/{NearestApproach-iBLl7o1g.js → NearestApproach-CONyx4c5.js} +1 -1
  64. package/dist-embed-sighting/{ParameterForm-DviNoiD5.js → ParameterForm-B8nX9qW-.js} +1 -1
  65. package/dist-embed-sighting/{PoherAssessor-DDRUgnRW.js → PoherAssessor-DI86qOCu.js} +1 -1
  66. package/dist-embed-sighting/RailwaySystem-DcJr9BY_.js +41 -0
  67. package/dist-embed-sighting/{ReentryEditor-MgbKtSa4.js → ReentryEditor-BbhQfIPi.js} +1 -1
  68. package/dist-embed-sighting/ReentrySimulation-BHbW9YNO.js +1 -0
  69. package/dist-embed-sighting/ReferenceSystem-DCSdp9Bq.js +1 -0
  70. package/dist-embed-sighting/{RoadMarkings-CNLt-BEg.js → RoadMarkings-DvWjbrSf.js} +1 -1
  71. package/dist-embed-sighting/{SceneNames_en-Dz2a5iRk.js → SceneNames_en-BlRTU7Hq.js} +1 -1
  72. package/dist-embed-sighting/{SceneNames_es-CKgCl71G.js → SceneNames_es-DMNd9trd.js} +1 -1
  73. package/dist-embed-sighting/{SceneNames_fr-BjpaWmul.js → SceneNames_fr-DlMcv9D0.js} +1 -1
  74. package/dist-embed-sighting/{SceneNames_it-TidFZnkk.js → SceneNames_it-DqlWMlOE.js} +1 -1
  75. package/dist-embed-sighting/{SkyLantern-BdVGIBoq.js → SkyLantern-COmog7pF.js} +1 -1
  76. package/dist-embed-sighting/{TimelineTracks-CvGxdpGb.js → TimelineTracks-CYIJdyPF.js} +1 -1
  77. package/dist-embed-sighting/{TraceSystem-ZNrHrAPL.js → TraceSystem-1K0WblAK.js} +2 -2
  78. package/dist-embed-sighting/{UfoMessages_en-cLvtpfIC.js → UfoMessages_en-CwRXodRE.js} +1 -1
  79. package/dist-embed-sighting/WaterSystem-1VlNXZnO.js +19 -0
  80. package/dist-embed-sighting/rr0-sighting.mjs +350 -350
  81. package/dist-embed-sighting/sightingSchema-CgwoRMl-.js +1 -0
  82. package/dist-embed-sighting/trafficRuntime-CuYrKvX9.js +2 -0
  83. package/dist-embed-sighting-editor/{AdsbLolArchiveProvider-DEqEth50.js → AdsbLolArchiveProvider-BrZzIuec.js} +1 -1
  84. package/dist-embed-sighting-editor/{BallesterGuaspAssessor-CapyLOHE.js → BallesterGuaspAssessor-CXvIvYxV.js} +1 -1
  85. package/dist-embed-sighting-editor/{BeamEditor-8960brcL.js → BeamEditor-5-OlhNfL.js} +1 -1
  86. package/dist-embed-sighting-editor/{BeamSystem-BoMHmOf3.js → BeamSystem-BGdR-Xez.js} +1 -1
  87. package/dist-embed-sighting-editor/{BirdEditor-CsyXenUx.js → BirdEditor-ESUliJEN.js} +1 -1
  88. package/dist-embed-sighting-editor/{BirdFlock-CSw6ge15.js → BirdFlock-DtshFXGT.js} +1 -1
  89. package/dist-embed-sighting-editor/{CaseReportExport-CYUM0gPZ.js → CaseReportExport-CKuvpQqy.js} +1 -1
  90. package/dist-embed-sighting-editor/{ContrailSystem-teTrI30G.js → ContrailSystem-BTVyJpmn.js} +1 -1
  91. package/dist-embed-sighting-editor/{ControlPasses-PiJOqNOu.js → ControlPasses-DiQAXMzD.js} +1 -1
  92. package/dist-embed-sighting-editor/{CoverageAssessor-Zh8Hw6yp.js → CoverageAssessor-CJQzNdyr.js} +1 -1
  93. package/dist-embed-sighting-editor/{DecorParameterTexts_en-C5dEeI_C.js → DecorParameterTexts_en-idbdHsFG.js} +1 -1
  94. package/dist-embed-sighting-editor/{DecorParameterTexts_es-BysMOaxT.js → DecorParameterTexts_es-CIkkLQc2.js} +1 -1
  95. package/dist-embed-sighting-editor/{DecorParameterTexts_fr-CThgxosI.js → DecorParameterTexts_fr-D9GeuW_Y.js} +1 -1
  96. package/dist-embed-sighting-editor/{DecorParameterTexts_it-D0ZsTK16.js → DecorParameterTexts_it-v7TBrnsr.js} +1 -1
  97. package/dist-embed-sighting-editor/{DroneEditor-CnlkmY64.js → DroneEditor-DDaJO8FS.js} +1 -1
  98. package/dist-embed-sighting-editor/{DroneFlight-D4RRsn4m.js → DroneFlight-tXCk1Tg1.js} +1 -1
  99. package/dist-embed-sighting-editor/{Flightradar24Provider-D3bM2ckV.js → Flightradar24Provider-DUVcPAF2.js} +1 -1
  100. package/dist-embed-sighting-editor/{GLTFLoader-DWambWcY.js → GLTFLoader-DdijxzcI.js} +1 -1
  101. package/dist-embed-sighting-editor/{HeadlightSystem-LL1DHYBg.js → HeadlightSystem-DRq40K7R.js} +1 -1
  102. package/dist-embed-sighting-editor/{HynekAssessor-wtavw_WK.js → HynekAssessor-PxE7JR1h.js} +1 -1
  103. package/dist-embed-sighting-editor/{InterviewEditorElement-46F4WJC9.js → InterviewEditorElement-D-UDHU0L.js} +2 -2
  104. package/dist-embed-sighting-editor/{LanternEditor-DIew0BrY.js → LanternEditor-DDcI5Kv1.js} +2 -2
  105. package/dist-embed-sighting-editor/{LaserBeam-BcOjgC8-.js → LaserBeam-CadJcSMd.js} +1 -1
  106. package/dist-embed-sighting-editor/{LaunchEditor-CUw-IXhX.js → LaunchEditor-Pkk0K648.js} +1 -1
  107. package/dist-embed-sighting-editor/{LaunchPlume-By8E1xvy.js → LaunchPlume-C7My5ccR.js} +1 -1
  108. package/dist-embed-sighting-editor/{LaunchSimulation-gytH8ZVf.js → LaunchSimulation-45Z9GUBF.js} +1 -1
  109. package/dist-embed-sighting-editor/{ModelSource-BQm0eN7H.js → ModelSource-CzGHu4XS.js} +1 -1
  110. package/dist-embed-sighting-editor/{ModelThumbnails-Bwh2px6A.js → ModelThumbnails-CNO_j-KM.js} +1 -1
  111. package/dist-embed-sighting-editor/{ModelViewer-Dl5ichWV.js → ModelViewer-yfIxofpG.js} +1 -1
  112. package/dist-embed-sighting-editor/{ModuleConformance-DRVG5aJw.js → ModuleConformance-C9DED8Lk.js} +2 -2
  113. package/dist-embed-sighting-editor/{ModuleSession-o0MYjWCQ.js → ModuleSession-Cxe0BJue.js} +2 -2
  114. package/dist-embed-sighting-editor/ModuleThree-DSghL4fp.js +1 -0
  115. package/dist-embed-sighting-editor/{ModulesPanelElement-Uk66Ixvl.js → ModulesPanelElement-DgbOYqaS.js} +3 -3
  116. package/dist-embed-sighting-editor/{NearestApproach-CgC-W_0w.js → NearestApproach-EbQIYGTt.js} +1 -1
  117. package/dist-embed-sighting-editor/{PoherAssessor-C0PuGZ7E.js → PoherAssessor-BisQ5ybV.js} +1 -1
  118. package/dist-embed-sighting-editor/{RailwaySystem-CzCL0bVV.js → RailwaySystem-CIAIBvLT.js} +1 -1
  119. package/dist-embed-sighting-editor/{ReentryEditor-v66u2mvZ.js → ReentryEditor-NE8z5aZT.js} +1 -1
  120. package/dist-embed-sighting-editor/{ReentrySimulation-CLu3E046.js → ReentrySimulation-Crd-CW_o.js} +1 -1
  121. package/dist-embed-sighting-editor/{ReferenceSystem-BWEFysoI.js → ReferenceSystem-DUIJceGg.js} +1 -1
  122. package/dist-embed-sighting-editor/SightingEditorMessages_en-DSPvgYFi.js +12 -0
  123. package/dist-embed-sighting-editor/SightingEditorMessages_es-Bl3DipHr.js +12 -0
  124. package/dist-embed-sighting-editor/SightingEditorMessages_fr-BTmWQX0n.js +12 -0
  125. package/dist-embed-sighting-editor/SightingEditorMessages_it-lzbDsHjx.js +12 -0
  126. package/dist-embed-sighting-editor/{SightingFileEditor-CQtQqTVl.js → SightingFileEditor-0VZmtiOX.js} +1 -1
  127. package/dist-embed-sighting-editor/{SkyLantern-CaRiiIZX.js → SkyLantern-De_MXfQz.js} +1 -1
  128. package/dist-embed-sighting-editor/{TraceSystem-DrdYmWMC.js → TraceSystem-Ba5H90GB.js} +2 -2
  129. package/dist-embed-sighting-editor/{WaterSystem-DJVs_drg.js → WaterSystem-Dpdw46hF.js} +2 -2
  130. package/dist-embed-sighting-editor/rr0-sighting-editor.mjs +431 -422
  131. package/dist-embed-sighting-editor/sightingSchema-CgwoRMl-.js +1 -0
  132. package/dist-embed-sighting-editor/trafficRuntime-Cqj3IpvH.js +2 -0
  133. package/package.json +2 -1
  134. package/dist-embed-scene/BeamSystem-Ab_wCPf_.js +0 -1
  135. package/dist-embed-scene/ContrailSystem-BYqjhyyF.js +0 -1
  136. package/dist-embed-scene/GLTFLoader-BmUyASZK.js +0 -1
  137. package/dist-embed-scene/ModuleThree-BzKlu4H2.js +0 -1
  138. package/dist-embed-scene/ReferenceSystem-BTDpVH4u.js +0 -1
  139. package/dist-embed-scene/sightingSchema-CLXF9VE3.js +0 -1
  140. package/dist-embed-scene/trafficRuntime-CJIPy2oO.js +0 -2
  141. package/dist-embed-sighting/BeamSystem-BdJfIbJy.js +0 -1
  142. package/dist-embed-sighting/ContrailSystem-C1pCwq7H.js +0 -1
  143. package/dist-embed-sighting/GLTFLoader-BPxbcVGH.js +0 -1
  144. package/dist-embed-sighting/GenerativeKitMessages-CRj85mnY.js +0 -1
  145. package/dist-embed-sighting/HeadlightSystem-LMaOhpkj.js +0 -34
  146. package/dist-embed-sighting/LaunchSimulation-CoJIQGLm.js +0 -1
  147. package/dist-embed-sighting/ModuleThree-FBgB1-pu.js +0 -1
  148. package/dist-embed-sighting/RailwaySystem-m2A18WjN.js +0 -41
  149. package/dist-embed-sighting/ReentrySimulation-BR0KO3U0.js +0 -1
  150. package/dist-embed-sighting/ReferenceSystem-C1iPC-1U.js +0 -1
  151. package/dist-embed-sighting/WaterSystem-BtEY0XLc.js +0 -19
  152. package/dist-embed-sighting/sightingSchema-CLXF9VE3.js +0 -1
  153. package/dist-embed-sighting/trafficRuntime-CFgDqQz4.js +0 -2
  154. package/dist-embed-sighting-editor/ModuleThree-D1RGQ8X2.js +0 -1
  155. package/dist-embed-sighting-editor/SightingEditorMessages_en-BgJRl09G.js +0 -12
  156. package/dist-embed-sighting-editor/SightingEditorMessages_es-CK8yosal.js +0 -12
  157. package/dist-embed-sighting-editor/SightingEditorMessages_fr-CcBrcUd-.js +0 -12
  158. package/dist-embed-sighting-editor/SightingEditorMessages_it-Dvnh7lnI.js +0 -12
  159. package/dist-embed-sighting-editor/sightingSchema-CLXF9VE3.js +0 -1
  160. package/dist-embed-sighting-editor/trafficRuntime-j8tnHTec.js +0 -2
@@ -1 +1 @@
1
- import{aE as M,aF as y,c as I}from"./rr0-sighting.mjs";class d{static RECORD_BYTES=20;static NON_ICAO_FLAG=1<<24;static UNKNOWN=65535;static MAX_DT=35999;static decode(t){if(t.length%d.RECORD_BYTES!==0)throw new Error(`An aircraft tile is a multiple of ${d.RECORD_BYTES} bytes, not ${t.length}`);const e=new DataView(t.buffer,t.byteOffset,t.byteLength),c=[];for(let n=0;n<t.length;n+=d.RECORD_BYTES){const s=e.getUint32(n,!0),a=e.getUint16(n+16,!0),r=e.getUint16(n+18,!0);c.push({icao:s&16777215,nonIcao:(s&d.NON_ICAO_FLAG)!==0,secondsInHour:e.getUint16(n+4,!0)/10,lat:e.getInt32(n+6,!0)/1e5,lng:e.getInt32(n+10,!0)/1e5,altitudeFt:e.getInt16(n+14,!0)*25,groundSpeedKt:a===d.UNKNOWN?void 0:a/10,trackDeg:r===d.UNKNOWN?void 0:r/10})}return c}}const w="https://ufoathome.org/aircraft/index.json";class f{citation=M;static DEFAULT_RADIUS_KM=150;static FLAG_MILITARY=1;static FLAG_PIA=4;static FLAG_LADD=8;static KM_PER_DEG=111.32;static HOUR_MS=36e5;fetchImpl;indexUrls;index;hours=new Map;tiles=new Map;shards=new Map;constructor(t={}){this.fetchImpl=t.fetchImpl??fetch.bind(globalThis),this.indexUrls=t.indexUrls??f.defaultIndexUrls()}static defaultIndexUrls(){const t=[];return typeof location<"u"&&/^https?:$/.test(location.protocol)&&t.push(new URL("/aircraft/index.json",location.href).href),t.includes(w)||t.push(w),t}mayCover(t){return y.mayCover(t)}async between(t,e,c,n=f.DEFAULT_RADIUS_KM){const s=await this.loadIndex();if(!s)return{status:"failed"};const a=[];for(let o=Math.floor(e/f.HOUR_MS);o<=Math.floor(c/f.HOUR_MS);o++)a.push(o);if(!a.every(o=>s.index.days.includes(f.dayOf(o))))return{status:"outside"};const r=f.tilesAround(t,n);try{const o=(await Promise.all(a.flatMap(u=>r.map(i=>this.tileOf(s.base,u,i))))).flat();return{status:"found",tracks:f.merge(o,t,e,c,n)}}catch{return{status:"failed"}}}async describe(t,e){const c=await this.loadIndex();if(!c)return;const n=t.icao.toString(16).padStart(6,"0"),s=t.nonIcao?"non-icao":n.slice(0,2),a=`${e}/${s}`;let r=this.shards.get(a);r||(r=this.fetchImpl(new URL(`${e}/aircraft/${s}.json`,c.base).href).then(g=>g.ok?g.json():{}).catch(()=>({})),this.shards.set(a,r));const o=(await r)[t.nonIcao?`~${n}`:n];if(!o)return;const[u,i,l,h=0]=o,p={registration:u||void 0,type:i||void 0,category:l||void 0,military:(h&f.FLAG_MILITARY)!==0||void 0,restricted:(h&(f.FLAG_PIA|f.FLAG_LADD))!==0||void 0};return Object.values(p).some(g=>g!==void 0)?p:void 0}static tilesAround(t,e){const c=e/f.KM_PER_DEG,n=Math.max(-90,t.lat-c),s=Math.min(90,t.lat+c),a=Math.cos(Math.max(Math.abs(n),Math.abs(s))*Math.PI/180),r=a<1e-6?180:e/(f.KM_PER_DEG*a),o=new Set;if(r>=180)for(let i=-180;i<180;i++)o.add(i);else for(let i=Math.floor(t.lng-r);i<=Math.floor(t.lng+r);i++)o.add(I.wrapLongitude(i));const u=[];for(let i=Math.floor(n);i<=Math.min(89,Math.floor(s));i++)for(const l of o)u.push(`${i}_${l}`);return u}static dayOf(t){return new Date(t*f.HOUR_MS).toISOString().slice(0,10)}static merge(t,e,c,n,s){const a=new Map;for(const o of t){const u=o.points.filter(h=>h.t>=c&&h.t<=n&&I.groundDistanceKm(e,h)<=s);if(u.length===0)continue;const i=`${o.nonIcao?"~":""}${o.icao}`,l=a.get(i);l?l.points.push(...u):a.set(i,{icao:o.icao,nonIcao:o.nonIcao,points:u})}const r=[...a.values()];for(const o of r)o.points.sort((u,i)=>u.t-i.t);return r.sort((o,u)=>o.icao-u.icao)}loadIndex(){return this.index??=(async()=>{for(const t of this.indexUrls)try{const e=await this.fetchImpl(t);if(e.ok)return{index:await e.json(),base:t}}catch{}})(),this.index}tileOf(t,e,c){const n=f.dayOf(e),s=String(e%24).padStart(2,"0"),a=`${n}/${s}/${c}`;let r=this.tiles.get(a);return r||(r=this.hourIndex(t,n,s).then(async o=>{const u=o[c];if(!u)return[];const[i,l]=u,h=await this.fetchImpl(new URL(`${n}/${s}.pack`,t).href,{headers:{Range:`bytes=${i}-${i+l-1}`}});if(!h.ok)throw new Error(`The pack of ${n} ${s} h answered ${h.status}`);const p=new Uint8Array(await h.arrayBuffer()),g=h.status===206?p:p.subarray(i,i+l);return f.tracksOf(await f.gunzip(g),e)}),r.catch(()=>this.tiles.delete(a)),this.tiles.set(a,r)),r}hourIndex(t,e,c){const n=`${e}/${c}`;let s=this.hours.get(n);return s||(s=this.fetchImpl(new URL(`${e}/${c}.json`,t).href).then(a=>{if(a.status===404)return{};if(!a.ok)throw new Error(`The index of ${e} ${c} h answered ${a.status}`);return a.json()}),s.catch(()=>this.hours.delete(n)),this.hours.set(n,s)),s}static async gunzip(t){const e=new Blob([t]).stream().pipeThrough(new DecompressionStream("gzip"));return new Uint8Array(await new Response(e).arrayBuffer())}static tracksOf(t,e){const c=new Map;for(const n of d.decode(t)){const s=`${n.nonIcao?"~":""}${n.icao}`;let a=c.get(s);a||c.set(s,a={icao:n.icao,nonIcao:n.nonIcao,points:[]}),a.points.push({t:e*f.HOUR_MS+n.secondsInHour*1e3,lat:n.lat,lng:n.lng,altitudeFt:n.altitudeFt,groundSpeedKt:n.groundSpeedKt,trackDeg:n.trackDeg})}return[...c.values()]}}export{f as AdsbLolArchiveProvider,w as UFOATHOME_AIRCRAFT_INDEX_URL};
1
+ import{aH as M,aI as y,d as I}from"./rr0-sighting.mjs";class d{static RECORD_BYTES=20;static NON_ICAO_FLAG=1<<24;static UNKNOWN=65535;static MAX_DT=35999;static decode(t){if(t.length%d.RECORD_BYTES!==0)throw new Error(`An aircraft tile is a multiple of ${d.RECORD_BYTES} bytes, not ${t.length}`);const e=new DataView(t.buffer,t.byteOffset,t.byteLength),c=[];for(let n=0;n<t.length;n+=d.RECORD_BYTES){const s=e.getUint32(n,!0),a=e.getUint16(n+16,!0),r=e.getUint16(n+18,!0);c.push({icao:s&16777215,nonIcao:(s&d.NON_ICAO_FLAG)!==0,secondsInHour:e.getUint16(n+4,!0)/10,lat:e.getInt32(n+6,!0)/1e5,lng:e.getInt32(n+10,!0)/1e5,altitudeFt:e.getInt16(n+14,!0)*25,groundSpeedKt:a===d.UNKNOWN?void 0:a/10,trackDeg:r===d.UNKNOWN?void 0:r/10})}return c}}const w="https://ufoathome.org/aircraft/index.json";class f{citation=M;static DEFAULT_RADIUS_KM=150;static FLAG_MILITARY=1;static FLAG_PIA=4;static FLAG_LADD=8;static KM_PER_DEG=111.32;static HOUR_MS=36e5;fetchImpl;indexUrls;index;hours=new Map;tiles=new Map;shards=new Map;constructor(t={}){this.fetchImpl=t.fetchImpl??fetch.bind(globalThis),this.indexUrls=t.indexUrls??f.defaultIndexUrls()}static defaultIndexUrls(){const t=[];return typeof location<"u"&&/^https?:$/.test(location.protocol)&&t.push(new URL("/aircraft/index.json",location.href).href),t.includes(w)||t.push(w),t}mayCover(t){return y.mayCover(t)}async between(t,e,c,n=f.DEFAULT_RADIUS_KM){const s=await this.loadIndex();if(!s)return{status:"failed"};const a=[];for(let o=Math.floor(e/f.HOUR_MS);o<=Math.floor(c/f.HOUR_MS);o++)a.push(o);if(!a.every(o=>s.index.days.includes(f.dayOf(o))))return{status:"outside"};const r=f.tilesAround(t,n);try{const o=(await Promise.all(a.flatMap(u=>r.map(i=>this.tileOf(s.base,u,i))))).flat();return{status:"found",tracks:f.merge(o,t,e,c,n)}}catch{return{status:"failed"}}}async describe(t,e){const c=await this.loadIndex();if(!c)return;const n=t.icao.toString(16).padStart(6,"0"),s=t.nonIcao?"non-icao":n.slice(0,2),a=`${e}/${s}`;let r=this.shards.get(a);r||(r=this.fetchImpl(new URL(`${e}/aircraft/${s}.json`,c.base).href).then(g=>g.ok?g.json():{}).catch(()=>({})),this.shards.set(a,r));const o=(await r)[t.nonIcao?`~${n}`:n];if(!o)return;const[u,i,l,h=0]=o,p={registration:u||void 0,type:i||void 0,category:l||void 0,military:(h&f.FLAG_MILITARY)!==0||void 0,restricted:(h&(f.FLAG_PIA|f.FLAG_LADD))!==0||void 0};return Object.values(p).some(g=>g!==void 0)?p:void 0}static tilesAround(t,e){const c=e/f.KM_PER_DEG,n=Math.max(-90,t.lat-c),s=Math.min(90,t.lat+c),a=Math.cos(Math.max(Math.abs(n),Math.abs(s))*Math.PI/180),r=a<1e-6?180:e/(f.KM_PER_DEG*a),o=new Set;if(r>=180)for(let i=-180;i<180;i++)o.add(i);else for(let i=Math.floor(t.lng-r);i<=Math.floor(t.lng+r);i++)o.add(I.wrapLongitude(i));const u=[];for(let i=Math.floor(n);i<=Math.min(89,Math.floor(s));i++)for(const l of o)u.push(`${i}_${l}`);return u}static dayOf(t){return new Date(t*f.HOUR_MS).toISOString().slice(0,10)}static merge(t,e,c,n,s){const a=new Map;for(const o of t){const u=o.points.filter(h=>h.t>=c&&h.t<=n&&I.groundDistanceKm(e,h)<=s);if(u.length===0)continue;const i=`${o.nonIcao?"~":""}${o.icao}`,l=a.get(i);l?l.points.push(...u):a.set(i,{icao:o.icao,nonIcao:o.nonIcao,points:u})}const r=[...a.values()];for(const o of r)o.points.sort((u,i)=>u.t-i.t);return r.sort((o,u)=>o.icao-u.icao)}loadIndex(){return this.index??=(async()=>{for(const t of this.indexUrls)try{const e=await this.fetchImpl(t);if(e.ok)return{index:await e.json(),base:t}}catch{}})(),this.index}tileOf(t,e,c){const n=f.dayOf(e),s=String(e%24).padStart(2,"0"),a=`${n}/${s}/${c}`;let r=this.tiles.get(a);return r||(r=this.hourIndex(t,n,s).then(async o=>{const u=o[c];if(!u)return[];const[i,l]=u,h=await this.fetchImpl(new URL(`${n}/${s}.pack`,t).href,{headers:{Range:`bytes=${i}-${i+l-1}`}});if(!h.ok)throw new Error(`The pack of ${n} ${s} h answered ${h.status}`);const p=new Uint8Array(await h.arrayBuffer()),g=h.status===206?p:p.subarray(i,i+l);return f.tracksOf(await f.gunzip(g),e)}),r.catch(()=>this.tiles.delete(a)),this.tiles.set(a,r)),r}hourIndex(t,e,c){const n=`${e}/${c}`;let s=this.hours.get(n);return s||(s=this.fetchImpl(new URL(`${e}/${c}.json`,t).href).then(a=>{if(a.status===404)return{};if(!a.ok)throw new Error(`The index of ${e} ${c} h answered ${a.status}`);return a.json()}),s.catch(()=>this.hours.delete(n)),this.hours.set(n,s)),s}static async gunzip(t){const e=new Blob([t]).stream().pipeThrough(new DecompressionStream("gzip"));return new Uint8Array(await new Response(e).arrayBuffer())}static tracksOf(t,e){const c=new Map;for(const n of d.decode(t)){const s=`${n.nonIcao?"~":""}${n.icao}`;let a=c.get(s);a||c.set(s,a={icao:n.icao,nonIcao:n.nonIcao,points:[]}),a.points.push({t:e*f.HOUR_MS+n.secondsInHour*1e3,lat:n.lat,lng:n.lng,altitudeFt:n.altitudeFt,groundSpeedKt:n.groundSpeedKt,trackDeg:n.trackDeg})}return[...c.values()]}}export{f as AdsbLolArchiveProvider,w as UFOATHOME_AIRCRAFT_INDEX_URL};
@@ -1 +1 @@
1
- import{S as p}from"./rr0-sighting.mjs";import{N as h}from"./NearestApproach-iBLl7o1g.js";import{CoverageAssessor as m}from"./CoverageAssessor-BSoRnjHD.js";const S=["appearance","movement","incongruity","detection","close","beings","traces"];class s{about="observer";static PAGE_WORDS=250;static ARTICLE_WORDS=500;static CLOSE_M=150;static WEIGHTS={witnesses:.25,occupation:.2,relation:.15,geography:.15,activity:.15,age:.1};static OCCUPATIONS={student:.3,worker:.5,farmer:.5,homemaker:.5,merchant:.7,business:.7,employee:.7,artist:.7,technician:.9,police:.9,pilot:.9,military:1};static RELATIONS={friends:.3,family:.6,professional:.8,none:1};static ACTIVITIES={leisure:.3,travelling:.6,cultural:.8,working:1};static FACTORS=S;static PENDING="pending";static WEAKEST_FIRST=["fitted","assumed","derived","stated","measured","established"];async assess(t){const e=t.account??{},i=this.information(t,e),n=this.strangeness(t,e),u=this.reliability(t,e),v=i.value,r=n.filter(d=>d.value>0).length/s.FACTORS.length,c=s.WEIGHTS,a=Object.keys(c).reduce((d,l)=>d+c[l]*u[l].value,0),o=[this.criterion("bg-information",i),...s.FACTORS.map((d,l)=>this.criterion(`bg-${d}`,n[l])),...Object.keys(c).map(d=>this.criterion(`bg-${d}`,u[d]))],b=Object.values(e.strangeness??{}).some(d=>d!==void 0);return e.source===void 0||!b?{verdict:s.PENDING,factors:{q:v,sigma:r,pi:a},criteria:o}:{score:v*r*a,factors:{q:v,sigma:r,pi:a},criteria:o}}criterion(t,e){return{id:t,value:e.value,basis:e.basis,paths:e.basis===void 0?[]:e.paths}}information(t,e){const i=e.source;if(i===void 0)return{value:0,paths:[]};const n=this.basis(t,"account.source"),u=e.enquiryMinutes,v=(a,o,b)=>u===void 0?{value:b,basis:this.weakest(n,"assumed"),paths:["account.source"]}:{value:u>=a?o:b,basis:this.weakest(n,this.basis(t,"account.enquiryMinutes")),paths:["account.source","account.enquiryMinutes"]},r=this.words(t),c=(a,o,b)=>({value:r>=a?o:b,basis:this.weakest(n,"derived"),paths:["account.source","event.description"]});switch(i){case"on-site":return v(120,1,.9);case"interview":return v(60,.9,.8);case"telephone":return v(30,.7,.6);case"questionnaire":return e.followedUp?c(s.PAGE_WORDS,.7,.6):{value:.6,basis:n,paths:["account.source"]};case"letter":case"social-media":return e.followedUp?c(s.PAGE_WORDS,.6,.5):c(s.PAGE_WORDS,.4,.3);case"press":return c(s.ARTICLE_WORDS,.2,.1)}}words(t){return(p.any.read(t.event.description)??"").split(/\s+/).filter(i=>i!=="").length}strangeness(t,e){const i=e.strangeness??{},n=s.FACTORS.map(r=>{const c=i[r];if(c!==void 0){const a=`account.strangeness.${r}`;return{value:c?1:0,basis:this.basis(t,a),paths:[a]}}switch(r){case"detection":{const a=t.instrument.category;return{value:a==="eye"||a==="binoculars"?0:1,basis:"derived",paths:["instrumentId"]}}case"close":{const a=h.of(t);return a===void 0?{value:0,paths:[]}:{value:a.m<=s.CLOSE_M?1:0,basis:a.basis,paths:a.paths}}case"beings":{const a=t.decor.map((o,b)=>({object:o,index:b})).filter(({object:o})=>o.kind==="entity");return a.length>0?{value:1,basis:"stated",paths:a.map(({index:o})=>`decor.${o}`)}:{value:0,basis:"derived",paths:["decor"]}}default:return{value:0,paths:[]}}}),u=s.FACTORS.indexOf("beings");return!["appearance","movement","incongruity"].some(r=>n[s.FACTORS.indexOf(r)].value>0)&&n[u].value>0&&(n[u]={...n[u],value:0}),n}reliability(t,e){const i=t.observerCount,n=i===1,u=i===1?.3:i===2?.5:i<=5?.7:i<=10?.9:1,v=e.observerGraduate?{value:1,basis:this.basis(t,"account.observerGraduate"),paths:["account.observerGraduate"]}:e.observerOccupationKind===void 0?{value:0,paths:[]}:{value:s.OCCUPATIONS[e.observerOccupationKind],basis:this.basis(t,"account.observerOccupationKind"),paths:["account.observerOccupationKind"]},r=n?{value:.6,basis:"derived",paths:["decor"]}:e.observersRelation===void 0?{value:0,paths:[]}:{value:s.RELATIONS[e.observersRelation],basis:this.basis(t,"account.observersRelation"),paths:["account.observersRelation"]},c=e.activity!==void 0?{value:s.ACTIVITIES[e.activity],basis:this.basis(t,"account.activity"),paths:["account.activity"]}:t.vehicle!==void 0?{value:s.ACTIVITIES.travelling,basis:"derived",paths:["vehicle"]}:{value:0,paths:[]},a=e.observerAgeYears,o=a===void 0?{value:0,paths:[]}:{value:a<10||a>75?.2:a<18?.4:a<35?.6:a<65?1:.8,basis:this.basis(t,"account.observerAgeYears"),paths:["account.observerAgeYears"]};return{witnesses:{value:u,basis:"derived",paths:["decor"]},occupation:v,relation:r,geography:{value:.5,basis:"derived",paths:["decor"]},activity:c,age:o}}basis(t,e){return m.basisAt(e,t)??"stated"}weakest(...t){return s.WEAKEST_FIRST.find(e=>t.includes(e))}}export{s as BallesterGuaspAssessor};
1
+ import{S as p}from"./rr0-sighting.mjs";import{N as h}from"./NearestApproach-CONyx4c5.js";import{CoverageAssessor as m}from"./CoverageAssessor-Cu9wP4ZB.js";const S=["appearance","movement","incongruity","detection","close","beings","traces"];class s{about="observer";static PAGE_WORDS=250;static ARTICLE_WORDS=500;static CLOSE_M=150;static WEIGHTS={witnesses:.25,occupation:.2,relation:.15,geography:.15,activity:.15,age:.1};static OCCUPATIONS={student:.3,worker:.5,farmer:.5,homemaker:.5,merchant:.7,business:.7,employee:.7,artist:.7,technician:.9,police:.9,pilot:.9,military:1};static RELATIONS={friends:.3,family:.6,professional:.8,none:1};static ACTIVITIES={leisure:.3,travelling:.6,cultural:.8,working:1};static FACTORS=S;static PENDING="pending";static WEAKEST_FIRST=["fitted","assumed","derived","stated","measured","established"];async assess(t){const e=t.account??{},i=this.information(t,e),n=this.strangeness(t,e),u=this.reliability(t,e),v=i.value,r=n.filter(d=>d.value>0).length/s.FACTORS.length,c=s.WEIGHTS,a=Object.keys(c).reduce((d,l)=>d+c[l]*u[l].value,0),o=[this.criterion("bg-information",i),...s.FACTORS.map((d,l)=>this.criterion(`bg-${d}`,n[l])),...Object.keys(c).map(d=>this.criterion(`bg-${d}`,u[d]))],b=Object.values(e.strangeness??{}).some(d=>d!==void 0);return e.source===void 0||!b?{verdict:s.PENDING,factors:{q:v,sigma:r,pi:a},criteria:o}:{score:v*r*a,factors:{q:v,sigma:r,pi:a},criteria:o}}criterion(t,e){return{id:t,value:e.value,basis:e.basis,paths:e.basis===void 0?[]:e.paths}}information(t,e){const i=e.source;if(i===void 0)return{value:0,paths:[]};const n=this.basis(t,"account.source"),u=e.enquiryMinutes,v=(a,o,b)=>u===void 0?{value:b,basis:this.weakest(n,"assumed"),paths:["account.source"]}:{value:u>=a?o:b,basis:this.weakest(n,this.basis(t,"account.enquiryMinutes")),paths:["account.source","account.enquiryMinutes"]},r=this.words(t),c=(a,o,b)=>({value:r>=a?o:b,basis:this.weakest(n,"derived"),paths:["account.source","event.description"]});switch(i){case"on-site":return v(120,1,.9);case"interview":return v(60,.9,.8);case"telephone":return v(30,.7,.6);case"questionnaire":return e.followedUp?c(s.PAGE_WORDS,.7,.6):{value:.6,basis:n,paths:["account.source"]};case"letter":case"social-media":return e.followedUp?c(s.PAGE_WORDS,.6,.5):c(s.PAGE_WORDS,.4,.3);case"press":return c(s.ARTICLE_WORDS,.2,.1)}}words(t){return(p.any.read(t.event.description)??"").split(/\s+/).filter(i=>i!=="").length}strangeness(t,e){const i=e.strangeness??{},n=s.FACTORS.map(r=>{const c=i[r];if(c!==void 0){const a=`account.strangeness.${r}`;return{value:c?1:0,basis:this.basis(t,a),paths:[a]}}switch(r){case"detection":{const a=t.instrument.category;return{value:a==="eye"||a==="binoculars"?0:1,basis:"derived",paths:["instrumentId"]}}case"close":{const a=h.of(t);return a===void 0?{value:0,paths:[]}:{value:a.m<=s.CLOSE_M?1:0,basis:a.basis,paths:a.paths}}case"beings":{const a=t.decor.map((o,b)=>({object:o,index:b})).filter(({object:o})=>o.kind==="entity");return a.length>0?{value:1,basis:"stated",paths:a.map(({index:o})=>`decor.${o}`)}:{value:0,basis:"derived",paths:["decor"]}}default:return{value:0,paths:[]}}}),u=s.FACTORS.indexOf("beings");return!["appearance","movement","incongruity"].some(r=>n[s.FACTORS.indexOf(r)].value>0)&&n[u].value>0&&(n[u]={...n[u],value:0}),n}reliability(t,e){const i=t.observerCount,n=i===1,u=i===1?.3:i===2?.5:i<=5?.7:i<=10?.9:1,v=e.observerGraduate?{value:1,basis:this.basis(t,"account.observerGraduate"),paths:["account.observerGraduate"]}:e.observerOccupationKind===void 0?{value:0,paths:[]}:{value:s.OCCUPATIONS[e.observerOccupationKind],basis:this.basis(t,"account.observerOccupationKind"),paths:["account.observerOccupationKind"]},r=n?{value:.6,basis:"derived",paths:["decor"]}:e.observersRelation===void 0?{value:0,paths:[]}:{value:s.RELATIONS[e.observersRelation],basis:this.basis(t,"account.observersRelation"),paths:["account.observersRelation"]},c=e.activity!==void 0?{value:s.ACTIVITIES[e.activity],basis:this.basis(t,"account.activity"),paths:["account.activity"]}:t.vehicle!==void 0?{value:s.ACTIVITIES.travelling,basis:"derived",paths:["vehicle"]}:{value:0,paths:[]},a=e.observerAgeYears,o=a===void 0?{value:0,paths:[]}:{value:a<10||a>75?.2:a<18?.4:a<35?.6:a<65?1:.8,basis:this.basis(t,"account.observerAgeYears"),paths:["account.observerAgeYears"]};return{witnesses:{value:u,basis:"derived",paths:["decor"]},occupation:v,relation:r,geography:{value:.5,basis:"derived",paths:["decor"]},activity:c,age:o}}basis(t,e){return m.basisAt(e,t)??"stated"}weakest(...t){return s.WEAKEST_FIRST.find(e=>t.includes(e))}}export{s as BallesterGuaspAssessor};
@@ -1,4 +1,4 @@
1
- import{e as T,_ as c,aI as I,aJ as E,aO as x,bx as L}from"./rr0-sighting.mjs";import{L as u}from"./LaserBeam-DotCCB1U.js";import{S as M,P as p,E as w,a as f}from"./ParameterForm-DviNoiD5.js";import{T as _}from"./TimelineTracks-CvGxdpGb.js";const O=T.catalog({en:()=>c(()=>import("./BeamParameterTexts_en-DZB75ouZ.js"),[],import.meta.url).then(l=>l.beamParameterTexts_en),fr:()=>c(()=>import("./BeamParameterTexts_fr-BHG3fW40.js"),[],import.meta.url).then(l=>l.beamParameterTexts_fr),es:()=>c(()=>import("./BeamParameterTexts_es-AeZmsufG.js"),[],import.meta.url).then(l=>l.beamParameterTexts_es),it:()=>c(()=>import("./BeamParameterTexts_it-CPwmQX-g.js"),[],import.meta.url).then(l=>l.beamParameterTexts_it)});class h{static LIGHT_TITLE="light";static BEAM="beam";static WHEN="when";static nextPlace(e){const t=e[e.length-1]??{lat:0,lng:0,altitudeM:0},i=e[e.length-2];return i?{lat:2*t.lat-i.lat,lng:2*t.lng-i.lng,altitudeM:2*t.altitudeM-i.altitudeM}:{lat:t.lat,lng:t.lng+500/(111320*Math.max(.05,Math.cos(t.lat*Math.PI/180))),altitudeM:t.altitudeM}}static instant(e,t,i,s=!1){return{type:"number",key:e,min:-3600,max:36e3,step:.1,unit:"s",scale:.001,label:t,hint:i,...s?{required:s}:{}}}static SET={kind:"beam",title:"beam",parameters:[{type:"said",key:"title",label:"name",group:h.BEAM},{type:"number",key:"divergenceMrad",min:.001,max:1e3,step:.001,unit:"mrad",group:h.BEAM,effective:()=>u.DEFAULT_DIVERGENCE_MRAD,label:"divergence",hint:"howFastItWidensFullAngle"},{type:"number",key:"apertureM",min:.001,max:10,step:.001,unit:"m",group:h.BEAM,effective:()=>u.DEFAULT_APERTURE_M,label:"widthAtTheEmitter"},{type:"number",key:"patchiness",min:0,max:100,step:1,unit:"%",scale:100,group:h.BEAM,effective:()=>u.DEFAULT_PATCHINESS,label:"unevenHaze",hint:"howUnevenlyTheHazeItCrosses"}]};static WAVELENGTH_HINT="itsColour532ForTheGreen";static POWER_HINT="theOpticalPowerItCarriesIts";static WAVELENGTH_LABEL="wavelength";static POWER_LABEL="power";static LIGHT={kind:"beam-light",title:h.LIGHT_TITLE,parameters:[{type:"number",key:"wavelengthNm",min:380,max:780,step:1,unit:"nm",required:!0,label:h.WAVELENGTH_LABEL,hint:h.WAVELENGTH_HINT},{type:"number",key:"powerW",min:.001,max:1e5,step:.001,unit:"W",required:!0,label:h.POWER_LABEL,hint:h.POWER_HINT}]};static LIGHT_KEY={kind:"beam-light-key",title:h.LIGHT_TITLE,parameters:[h.instant("t","time","secondsOfTheRecording",!0),{type:"number",key:"wavelengthNm",min:380,max:780,step:1,unit:"nm",label:h.WAVELENGTH_LABEL,hint:h.WAVELENGTH_HINT,effective:(e,t)=>t?.wavelengthNm},{type:"number",key:"powerW",min:.001,max:1e5,step:.001,unit:"W",label:h.POWER_LABEL,hint:h.POWER_HINT,effective:(e,t)=>t?.powerW}]};static ON={kind:"beam-on",title:h.WHEN,parameters:[h.instant("fromT","onFrom","secondsOfTheRecordingEmptyFrom"),h.instant("untilT","offAt","secondsOfTheRecordingEmptyUntil")]};static MOVE_KEY={kind:"beam-move-key",title:"pathAtAnInstant",parameters:[h.instant("t","time","secondsOfTheRecording",!0)]};static hexOf(e){const t=u.colourOf(e),i=Math.max(...t,1e-9),s=n=>{const o=Math.min(1,Math.max(0,n/i)),a=o<=.0031308?12.92*o:1.055*o**(1/2.4)-.055;return Math.round(a*255).toString(16).padStart(2,"0")};return`#${t.map(s).join("")}`}static wavelengthOf(e){const t=h.hueOf(e);let i=532,s=1/0;for(let n=400;n<=700;n++){const o=Math.abs((h.hueOf(h.hexOf(n))-t+540)%360-180);o<s&&(s=o,i=n)}return i}static hueOf(e){const t=Number.parseInt(e.replace("#",""),16),[i,s,n]=[t>>16&255,t>>8&255,t&255].map(b=>b/255),o=Math.max(i,s,n),a=Math.min(i,s,n);if(o===a)return 0;const r=o-a;return((o===i?(s-n)/r%6:o===s?(n-i)/r+2:(i-s)/r+4)*60+360)%360}static PLACE={kind:"beam-place",title:"pointOfThePath",parameters:[{type:"position",key:"lat",secondKey:"lng",saidKey:"saidPosition",native:"geo",step:.1,label:"position"},{type:"number",key:"altitudeM",min:-500,max:1e5,step:.1,unit:"m",required:!0,label:"altitude",hint:"aboveTheSeaNotTheGround"}]};static publish(){I.publish(h.SET)}}const A=T.catalog({en:()=>c(()=>import("./BeamEditorMessages_en-DDvPWAdd.js"),[],import.meta.url).then(l=>l.beamEditorMessages_en),fr:()=>c(()=>import("./BeamEditorMessages_fr-CtX6uP-x.js"),[],import.meta.url).then(l=>l.beamEditorMessages_fr),es:()=>c(()=>import("./BeamEditorMessages_es-BhCkhUkN.js"),[],import.meta.url).then(l=>l.beamEditorMessages_es),it:()=>c(()=>import("./BeamEditorMessages_it-DVweRQFi.js"),[],import.meta.url).then(l=>l.beamEditorMessages_it)});class g{constructor(e,t,i){this.container=e,this.host=t,this.language=i,M.attach(e,"beam-editor",g.STYLE),I.of("beam")||h.publish(),this.ready=this.setLanguage(i)}messages;ready;parameterTexts;languageToken=0;currentId;form;list;timeline;row="on";onForm;lightForm;lightKeyForm;lightIndex;moveKeyForm;moveIndex;places;placeForm;placeIndex=0;language;shown=[];static STYLE='.beam-editor { flex-basis: 100%; min-width: 0; } .beam-editor #beam-timeline { flex-basis: 100%; min-width: 0; padding: 4px 0; } .beam-editor #beam-list, .beam-editor #beam-places { flex-basis: 100%; min-width: 0; } .beam-editor .launch-editor, .beam-editor .launch-fields { display: flex; flex-wrap: wrap; gap: 8px; align-items: end; } .beam-editor .launch-fields { flex-basis: 100%; min-width: 0; } .beam-editor [hidden] { display: none !important; } .beam-editor select { min-width: 0; width: 100%; } .beam-editor .launch-intro { flex-basis: 100%; margin: 0; } .beam-editor .launch-track { flex-basis: 100%; margin: 0; } .beam-editor .launch-parameters { flex-basis: 100%; min-width: 0; display: flex; flex-wrap: wrap; gap: 8px; align-items: flex-start; } .beam-editor .parameter-group { flex: 1 1 14em; min-width: 0; box-sizing: border-box; margin: 0; display: flex; flex-wrap: wrap; gap: 6px 12px; align-items: flex-start; align-content: flex-start; } .beam-editor input, .beam-editor select { max-width: 100%; box-sizing: border-box; } .beam-editor input[type="text"] { width: 12em; } .beam-editor #launch-title { width: 18em; } .beam-editor label { min-width: 0; max-width: 100%; } .beam-editor input.parameter-derived::placeholder { opacity: .65; } .beam-editor .launch-path { flex: 1 1 100%; min-width: 0; box-sizing: border-box; margin: 0; display: flex; flex-wrap: wrap; gap: 6px 12px; align-items: flex-start; }';async setLanguage(e){const t=++this.languageToken;this.language=e;const[i,s]=await Promise.all([A.load(e),O.load(e)]);t===this.languageToken&&(this.messages=i,this.parameterTexts=s,this.render(),this.sync())}sync(){if(!this.messages)return;const e=this.beams;this.shown=[...e],e.some(s=>s.id===this.currentId)||(this.currentId=e[0]?.id),this.list?.setItems(e.map(s=>({id:s.id,label:this.labelOf(s)})),this.currentId),this.syncAddState();const t=this.current;if(this.element("beam-fields").hidden=t===void 0,!t)return;const i={said:()=>this.host.said(),writingLanguage:()=>this.host.writingLanguage()};this.form??=new p(this.element("beam-parameters"),this.language,"beam.",i),this.form.show(this.resolved(h.SET),this.targetOfBeam(),()=>this.written()),this.syncDetail(!0)}refresh(){if(!this.messages)return;this.syncAddState();const e=this.beams;if(e.length===this.shown.length&&e.every((t,i)=>t.id===this.shown[i].id)){this.syncTimeline();return}this.sync()}setTime(e){this.messages&&this.timeline?.setTime(e)}syncAddState(){const e=this.pathOfNew()!==void 0;this.list?.setAddState(e,e?void 0:this.messages.addBeamNowhere)}get current(){return this.beams.find(e=>e.id===this.currentId)}show(e){this.messages&&(this.currentId=e,this.row="on",this.lightIndex=void 0,this.moveIndex=void 0,this.placeIndex=0,this.sync())}resolved(e){return E.resolve(e,this.parameterTexts)}render(){if(!this.messages)return;const e=this.messages;this.form=void 0,this.container.innerHTML=`<div class="launch-editor">
1
+ import{i as T,_ as c,aL as I,aM as L,aR as x,bA as E}from"./rr0-sighting.mjs";import{L as u}from"./LaserBeam-CMO6tMze.js";import{S as M,P as p,E as w,a as f}from"./ParameterForm-B8nX9qW-.js";import{T as _}from"./TimelineTracks-CYIJdyPF.js";const O=T.catalog({en:()=>c(()=>import("./BeamParameterTexts_en-DZB75ouZ.js"),[],import.meta.url).then(l=>l.beamParameterTexts_en),fr:()=>c(()=>import("./BeamParameterTexts_fr-BHG3fW40.js"),[],import.meta.url).then(l=>l.beamParameterTexts_fr),es:()=>c(()=>import("./BeamParameterTexts_es-AeZmsufG.js"),[],import.meta.url).then(l=>l.beamParameterTexts_es),it:()=>c(()=>import("./BeamParameterTexts_it-CPwmQX-g.js"),[],import.meta.url).then(l=>l.beamParameterTexts_it)});class h{static LIGHT_TITLE="light";static BEAM="beam";static WHEN="when";static nextPlace(e){const t=e[e.length-1]??{lat:0,lng:0,altitudeM:0},i=e[e.length-2];return i?{lat:2*t.lat-i.lat,lng:2*t.lng-i.lng,altitudeM:2*t.altitudeM-i.altitudeM}:{lat:t.lat,lng:t.lng+500/(111320*Math.max(.05,Math.cos(t.lat*Math.PI/180))),altitudeM:t.altitudeM}}static instant(e,t,i,s=!1){return{type:"number",key:e,min:-3600,max:36e3,step:.1,unit:"s",scale:.001,label:t,hint:i,...s?{required:s}:{}}}static SET={kind:"beam",title:"beam",parameters:[{type:"said",key:"title",label:"name",group:h.BEAM},{type:"number",key:"divergenceMrad",min:.001,max:1e3,step:.001,unit:"mrad",group:h.BEAM,effective:()=>u.DEFAULT_DIVERGENCE_MRAD,label:"divergence",hint:"howFastItWidensFullAngle"},{type:"number",key:"apertureM",min:.001,max:10,step:.001,unit:"m",group:h.BEAM,effective:()=>u.DEFAULT_APERTURE_M,label:"widthAtTheEmitter"},{type:"number",key:"patchiness",min:0,max:100,step:1,unit:"%",scale:100,group:h.BEAM,effective:()=>u.DEFAULT_PATCHINESS,label:"unevenHaze",hint:"howUnevenlyTheHazeItCrosses"}]};static WAVELENGTH_HINT="itsColour532ForTheGreen";static POWER_HINT="theOpticalPowerItCarriesIts";static WAVELENGTH_LABEL="wavelength";static POWER_LABEL="power";static LIGHT={kind:"beam-light",title:h.LIGHT_TITLE,parameters:[{type:"number",key:"wavelengthNm",min:380,max:780,step:1,unit:"nm",required:!0,label:h.WAVELENGTH_LABEL,hint:h.WAVELENGTH_HINT},{type:"number",key:"powerW",min:.001,max:1e5,step:.001,unit:"W",required:!0,label:h.POWER_LABEL,hint:h.POWER_HINT}]};static LIGHT_KEY={kind:"beam-light-key",title:h.LIGHT_TITLE,parameters:[h.instant("t","time","secondsOfTheRecording",!0),{type:"number",key:"wavelengthNm",min:380,max:780,step:1,unit:"nm",label:h.WAVELENGTH_LABEL,hint:h.WAVELENGTH_HINT,effective:(e,t)=>t?.wavelengthNm},{type:"number",key:"powerW",min:.001,max:1e5,step:.001,unit:"W",label:h.POWER_LABEL,hint:h.POWER_HINT,effective:(e,t)=>t?.powerW}]};static ON={kind:"beam-on",title:h.WHEN,parameters:[h.instant("fromT","onFrom","secondsOfTheRecordingEmptyFrom"),h.instant("untilT","offAt","secondsOfTheRecordingEmptyUntil")]};static MOVE_KEY={kind:"beam-move-key",title:"pathAtAnInstant",parameters:[h.instant("t","time","secondsOfTheRecording",!0)]};static hexOf(e){const t=u.colourOf(e),i=Math.max(...t,1e-9),s=n=>{const o=Math.min(1,Math.max(0,n/i)),a=o<=.0031308?12.92*o:1.055*o**(1/2.4)-.055;return Math.round(a*255).toString(16).padStart(2,"0")};return`#${t.map(s).join("")}`}static wavelengthOf(e){const t=h.hueOf(e);let i=532,s=1/0;for(let n=400;n<=700;n++){const o=Math.abs((h.hueOf(h.hexOf(n))-t+540)%360-180);o<s&&(s=o,i=n)}return i}static hueOf(e){const t=Number.parseInt(e.replace("#",""),16),[i,s,n]=[t>>16&255,t>>8&255,t&255].map(b=>b/255),o=Math.max(i,s,n),a=Math.min(i,s,n);if(o===a)return 0;const r=o-a;return((o===i?(s-n)/r%6:o===s?(n-i)/r+2:(i-s)/r+4)*60+360)%360}static PLACE={kind:"beam-place",title:"pointOfThePath",parameters:[{type:"position",key:"lat",secondKey:"lng",saidKey:"saidPosition",native:"geo",step:.1,label:"position"},{type:"number",key:"altitudeM",min:-500,max:1e5,step:.1,unit:"m",required:!0,label:"altitude",hint:"aboveTheSeaNotTheGround"}]};static publish(){I.publish(h.SET)}}const A=T.catalog({en:()=>c(()=>import("./BeamEditorMessages_en-DDvPWAdd.js"),[],import.meta.url).then(l=>l.beamEditorMessages_en),fr:()=>c(()=>import("./BeamEditorMessages_fr-CtX6uP-x.js"),[],import.meta.url).then(l=>l.beamEditorMessages_fr),es:()=>c(()=>import("./BeamEditorMessages_es-BhCkhUkN.js"),[],import.meta.url).then(l=>l.beamEditorMessages_es),it:()=>c(()=>import("./BeamEditorMessages_it-DVweRQFi.js"),[],import.meta.url).then(l=>l.beamEditorMessages_it)});class g{constructor(e,t,i){this.container=e,this.host=t,this.language=i,M.attach(e,"beam-editor",g.STYLE),I.of("beam")||h.publish(),this.ready=this.setLanguage(i)}messages;ready;parameterTexts;languageToken=0;currentId;form;list;timeline;row="on";onForm;lightForm;lightKeyForm;lightIndex;moveKeyForm;moveIndex;places;placeForm;placeIndex=0;language;shown=[];static STYLE='.beam-editor { flex-basis: 100%; min-width: 0; } .beam-editor #beam-timeline { flex-basis: 100%; min-width: 0; padding: 4px 0; } .beam-editor #beam-list, .beam-editor #beam-places { flex-basis: 100%; min-width: 0; } .beam-editor .launch-editor, .beam-editor .launch-fields { display: flex; flex-wrap: wrap; gap: 8px; align-items: end; } .beam-editor .launch-fields { flex-basis: 100%; min-width: 0; } .beam-editor [hidden] { display: none !important; } .beam-editor select { min-width: 0; width: 100%; } .beam-editor .launch-intro { flex-basis: 100%; margin: 0; } .beam-editor .launch-track { flex-basis: 100%; margin: 0; } .beam-editor .launch-parameters { flex-basis: 100%; min-width: 0; display: flex; flex-wrap: wrap; gap: 8px; align-items: flex-start; } .beam-editor .parameter-group { flex: 1 1 14em; min-width: 0; box-sizing: border-box; margin: 0; display: flex; flex-wrap: wrap; gap: 6px 12px; align-items: flex-start; align-content: flex-start; } .beam-editor input, .beam-editor select { max-width: 100%; box-sizing: border-box; } .beam-editor input[type="text"] { width: 12em; } .beam-editor #launch-title { width: 18em; } .beam-editor label { min-width: 0; max-width: 100%; } .beam-editor input.parameter-derived::placeholder { opacity: .65; } .beam-editor .launch-path { flex: 1 1 100%; min-width: 0; box-sizing: border-box; margin: 0; display: flex; flex-wrap: wrap; gap: 6px 12px; align-items: flex-start; }';async setLanguage(e){const t=++this.languageToken;this.language=e;const[i,s]=await Promise.all([A.load(e),O.load(e)]);t===this.languageToken&&(this.messages=i,this.parameterTexts=s,this.render(),this.sync())}sync(){if(!this.messages)return;const e=this.beams;this.shown=[...e],e.some(s=>s.id===this.currentId)||(this.currentId=e[0]?.id),this.list?.setItems(e.map(s=>({id:s.id,label:this.labelOf(s)})),this.currentId),this.syncAddState();const t=this.current;if(this.element("beam-fields").hidden=t===void 0,!t)return;const i={said:()=>this.host.said(),writingLanguage:()=>this.host.writingLanguage()};this.form??=new p(this.element("beam-parameters"),this.language,"beam.",i),this.form.show(this.resolved(h.SET),this.targetOfBeam(),()=>this.written()),this.syncDetail(!0)}refresh(){if(!this.messages)return;this.syncAddState();const e=this.beams;if(e.length===this.shown.length&&e.every((t,i)=>t.id===this.shown[i].id)){this.syncTimeline();return}this.sync()}setTime(e){this.messages&&this.timeline?.setTime(e)}syncAddState(){const e=this.pathOfNew()!==void 0;this.list?.setAddState(e,e?void 0:this.messages.addBeamNowhere)}get current(){return this.beams.find(e=>e.id===this.currentId)}show(e){this.messages&&(this.currentId=e,this.row="on",this.lightIndex=void 0,this.moveIndex=void 0,this.placeIndex=0,this.sync())}resolved(e){return L.resolve(e,this.parameterTexts)}render(){if(!this.messages)return;const e=this.messages;this.form=void 0,this.container.innerHTML=`<div class="launch-editor">
2
2
  <p class="launch-intro">${e.intro}</p>
3
3
  <div id="beam-list"></div>
4
4
  <div id="beam-fields" class="launch-fields">
@@ -27,4 +27,4 @@ import{e as T,_ as c,aI as I,aJ as E,aO as x,bx as L}from"./rr0-sighting.mjs";im
27
27
  </fieldset>
28
28
  <p class="launch-intro">${e.derivedNote}</p>
29
29
  </div>
30
- </div>`,this.list=new w({header:this.element("beam-list"),body:this.element("beam-fields"),ids:{list:"beam-select",remove:"beam-delete",add:"beam-add"},onSelect:t=>this.show(t),onAdd:()=>this.addBeam(),onRemove:()=>this.deleteCurrent()}),this.list.setLabels({list:e.beam,remove:e.deleteBeam,add:e.addBeam,empty:e.none}),this.timeline=new _(this.element("beam-timeline"),t=>this.host.seekTo(t),{addKeyframeHere:e.addHere,keyframeHere:e.here,zoomHint:e.zoomHint}),this.places=new w({header:this.element("beam-places"),body:this.element("beam-place-parameters"),ids:{list:"beam-place",remove:"beam-place-delete",add:"beam-place-add"},navigation:{scope:this.element("beam-path"),onStep:t=>this.selectPlace(this.placeIndex+t)},onSelect:t=>this.selectPlace(Number(t)),onAdd:()=>this.addPlace(),onRemove:()=>this.removePlace()}),this.places.setLabels({list:e.place,remove:e.deletePlace,add:e.addPlace,previous:e.previousPlace,next:e.nextPlace}),this.element("beam-colour").addEventListener("input",t=>this.pickColour(t.target.value)),this.element("beam-light-delete").addEventListener("click",()=>this.removeLightKey()),this.element("beam-move-delete").addEventListener("click",()=>this.removeMoveKey()),this.onForm=void 0,this.lightForm=void 0,this.lightKeyForm=void 0,this.moveKeyForm=void 0,this.placeForm=void 0}written(){const e=this.current;e&&this.list?.rename(e.id,this.labelOf(e)),this.syncTimeline()}targetOfBeam(){return new f(()=>this.current,e=>this.editBeam(t=>e(t)))}static ON_COLOR="#2f9e5a";static LIGHT_COLOR="#c0581b";static PATH_COLOR="#4f8fd6";syncTimeline(){const e=this.current;if(!this.timeline||!e)return;const t=this.messages,i=this.host.duration(),s=e.fromT??0,n=e.untilT??i,o=[{t:s,until:n,label:""}],a=this.sortedLight(e),r=this.sortedMoves(e),v=[{id:"on",label:t.on,color:g.ON_COLOR,times:[s,n],spans:o,active:this.row==="on",open:()=>this.selectRow("on"),pressed:()=>this.selectRow("on"),move:(d,m)=>this.moveEnd(d===s?"fromT":"untilT",m),add:()=>this.moveEnd("fromT",Math.round(this.host.currentTime()))},{id:"light",label:t.light,color:g.LIGHT_COLOR,times:a.map(d=>d.t),spans:a.length?[]:o,active:this.row==="light",selectedTime:this.row==="light"&&this.lightIndex!==void 0?a[this.lightIndex]?.t:void 0,open:()=>this.selectLight(this.lightIndex),pressed:(d,m)=>this.selectLight(m===void 0?this.lightIndex:this.sortedLight(this.current).findIndex(y=>y.t===m)),move:(d,m)=>this.moveLightKey(d,m),add:()=>this.addLightKey(Math.round(this.host.currentTime()))},{id:"path",label:t.path,color:g.PATH_COLOR,times:r.map(d=>d.t),spans:r.length?[]:o,active:this.row==="path",selectedTime:this.row==="path"&&this.moveIndex!==void 0?r[this.moveIndex]?.t:void 0,open:()=>this.selectMove(this.moveIndex),pressed:(d,m)=>this.selectMove(m===void 0?this.moveIndex:this.sortedMoves(this.current).findIndex(y=>y.t===m)),move:(d,m)=>this.moveMoveKey(d,m),add:()=>this.addMoveKey(Math.round(this.host.currentTime()))}],b=[s,n,...a.map(d=>d.t),...r.map(d=>d.t)];this.timeline.show(v,i,this.host.currentTime(),{from:Math.min(0,...b),to:Math.max(i,...b)})}sortedLight(e){return[...e.light??[]].sort((t,i)=>t.t-i.t)}sortedMoves(e){return[...e.moves??[]].sort((t,i)=>t.t-i.t)}selectRow(e){this.row=e,this.syncDetail(!0)}syncDetail(e=!1){this.current&&(this.element("beam-on").hidden=this.row!=="on",this.element("beam-light").hidden=this.row!=="light",this.element("beam-path").hidden=this.row!=="path",this.row==="on"&&this.syncOn(e),this.row==="light"&&this.syncLight(e),this.row==="path"&&this.syncPath(e),this.syncTimeline())}syncOn(e){this.onForm?this.onForm.sync(e):(this.onForm=new p(this.element("beam-on-parameters"),this.language,"beamOn."),this.onForm.show(this.resolved(h.ON),this.targetOfBeam(),()=>this.syncTimeline()))}moveEnd(e,t){this.editBeam(i=>{i[e]=t,i.fromT!==void 0&&i.untilT!==void 0&&i.untilT<i.fromT&&(e==="fromT"?delete i.untilT:[i.fromT,i.untilT]=[i.untilT,i.fromT])}),this.selectRow("on")}selectLight(e){const t=this.current?this.sortedLight(this.current):[];this.lightIndex=e!==void 0&&e>=0&&e<t.length?e:t.length?0:void 0,this.selectRow("light")}get currentLightKey(){const e=this.current;return e&&this.lightIndex!==void 0?this.sortedLight(e)[this.lightIndex]:void 0}syncLight(e){const t=this.messages,i=this.currentLightKey;this.element("beam-light-note").textContent=i?t.lightKeyNote:t.lightNoKeyNote,this.element("beam-light-parameters").hidden=i!==void 0,this.element("beam-light-key-parameters").hidden=i===void 0,this.element("beam-light-delete").hidden=i===void 0,this.lightForm?this.lightForm.sync(e):(this.lightForm=new p(this.element("beam-light-parameters"),this.language,"beamLight."),this.lightForm.show(this.resolved(h.LIGHT),this.targetOfBeam(),()=>this.syncColour())),this.lightKeyForm?this.lightKeyForm.sync(e):(this.lightKeyForm=new p(this.element("beam-light-key-parameters"),this.language,"beamLightKey."),this.lightKeyForm.show(this.resolved(h.LIGHT_KEY),new f(()=>this.currentLightKey,s=>this.editLightKey(this.lightIndex,s),()=>this.current),()=>this.syncColour())),this.syncColour()}syncColour(){const e=this.current;e&&(this.element("beam-colour").value=h.hexOf(this.currentLightKey?.wavelengthNm??e.wavelengthNm))}pickColour(e){const t=h.wavelengthOf(e);this.lightIndex===void 0?(this.editBeam(i=>{i.wavelengthNm=t}),this.lightForm?.sync(!0)):(this.editLightKey(this.lightIndex,i=>{i.wavelengthNm=t}),this.lightKeyForm?.sync(!0))}editLightKey(e,t){const i=this.current;if(!i)return;const s=this.sortedLight(i),n={...s[e]};t(n);const o=s.map((a,r)=>r===e?n:a).sort((a,r)=>a.t-r.t);this.editBeam(a=>{a.light=o}),this.lightIndex=o.indexOf(n),this.syncTimeline()}addLightKey(e){const t=this.current;if(!t)return;const i=this.sortedLight(t),s=i.findIndex(r=>Math.abs(r.t-e)<1);if(s>=0){this.selectLight(s);return}const n=u.stateAt(t,e),o={t:e,wavelengthNm:Math.round(n.wavelengthNm),powerW:Number(n.powerW.toFixed(3))},a=[...i,o].sort((r,v)=>r.t-v.t);this.editBeam(r=>{r.light=a}),this.selectLight(a.indexOf(o))}moveLightKey(e,t){const i=this.current?this.sortedLight(this.current).findIndex(s=>s.t===e):-1;i<0||(this.editLightKey(i,s=>{s.t=t}),this.selectRow("light"))}removeLightKey(){const e=this.current,t=this.lightIndex;if(!e||t===void 0)return;const i=this.sortedLight(e).filter((s,n)=>n!==t);this.editBeam(s=>{i.length?s.light=i:delete s.light}),this.selectLight(i.length?Math.min(t,i.length-1):void 0)}selectMove(e){const t=this.current?this.sortedMoves(this.current):[],i=e!==void 0&&e>=0&&e<t.length?e:t.length?0:void 0;i!==this.moveIndex&&(this.placeIndex=0),this.moveIndex=i,this.selectRow("path")}get currentMoveKey(){const e=this.current;return e&&this.moveIndex!==void 0?this.sortedMoves(e)[this.moveIndex]:void 0}get shownPath(){return this.currentMoveKey?.path??this.current?.path??[]}syncPath(e){const t=this.messages,i=this.currentMoveKey;this.element("beam-path-note").textContent=i?t.pathKeyNote:t.pathNoKeyNote,this.element("beam-move-key-parameters").hidden=i===void 0,this.element("beam-move-delete").hidden=i===void 0,this.moveKeyForm?this.moveKeyForm.sync(e):(this.moveKeyForm=new p(this.element("beam-move-key-parameters"),this.language,"beamMoveKey."),this.moveKeyForm.show(this.resolved(h.MOVE_KEY),new f(()=>this.currentMoveKey,s=>this.editMoveKey(this.moveIndex,n=>s(n))),()=>{})),this.syncPlaces(e)}editMoveKey(e,t){const i=this.current;if(!i)return;const s=this.sortedMoves(i),n={...s[e],path:[...s[e].path]};t(n);const o=s.map((a,r)=>r===e?n:a).sort((a,r)=>a.t-r.t);this.editBeam(a=>{a.moves=o}),this.moveIndex=o.indexOf(n),this.syncTimeline()}addMoveKey(e){const t=this.current;if(!t)return;const i=this.sortedMoves(t),s=i.findIndex(a=>Math.abs(a.t-e)<1);if(s>=0){this.selectMove(s);return}const n={t:e,path:u.stateAt(t,e).path.map(a=>({...a}))},o=[...i,n].sort((a,r)=>a.t-r.t);this.editBeam(a=>{a.moves=o}),this.selectMove(o.indexOf(n))}moveMoveKey(e,t){const i=this.current?this.sortedMoves(this.current).findIndex(s=>s.t===e):-1;i<0||(this.editMoveKey(i,s=>{s.t=t}),this.selectRow("path"))}removeMoveKey(){const e=this.current,t=this.moveIndex;if(!e||t===void 0)return;const i=this.sortedMoves(e).filter((s,n)=>n!==t);this.editBeam(s=>{i.length?s.moves=i:delete s.moves}),this.selectMove(i.length?Math.min(t,i.length-1):void 0)}syncPlaces(e=!1){const t=this.shownPath;this.placeIndex=Math.max(0,Math.min(this.placeIndex,t.length-1)),this.places?.setItems(t.map((i,s)=>({id:String(s),label:`${s+1}/${t.length}`})),String(this.placeIndex)),this.places?.setStepState(this.placeIndex>0,this.placeIndex<t.length-1),this.places?.setRemoveEnabled(t.length>g.MIN_PLACES),this.placeForm?this.placeForm.sync(e):(this.placeForm=new p(this.element("beam-place-parameters"),this.language,"beamPlace."),this.placeForm.show(this.resolved(h.PLACE),new f(()=>this.shownPath[this.placeIndex],i=>this.editPath(s=>{const n={...s[this.placeIndex]};return i(n),s.map((o,a)=>a===this.placeIndex?n:o)}),void 0,this.host.positionPlace?.()),()=>{}))}editPath(e){this.moveIndex!==void 0?this.editMoveKey(this.moveIndex,t=>{t.path=e(t.path)}):this.editBeam(t=>{t.path=e(t.path)})}static MIN_PLACES=2;selectPlace(e){const t=this.shownPath;e<0||e>=t.length||(this.placeIndex=e,this.syncPlaces(!0))}addPlace(){this.editPath(e=>[...e,h.nextPlace(e)]),this.placeIndex=this.shownPath.length-1,this.syncPlaces(!0)}removePlace(){if(this.shownPath.length<=g.MIN_PLACES)return;const e=this.placeIndex;this.editPath(t=>t.filter((i,s)=>s!==e)),this.syncPlaces(!0)}editBeam(e){const t=this.current;if(!t)return;const i={...t,path:[...t.path]};e(i),this.writeBeams(this.beams.map(s=>s===t?i:s)),this.host.changed()}pathOfNew(){const e=this.host.sighting(),t=e.event?.place?.[0];if(t?.lat===void 0||t.lng===void 0)return;const i=(e.observerTrack?.getInterpolatedPoseAt(0)?.headingDeg??0)*Math.PI/180,s=111320;return[{lat:t.lat,lng:t.lng,altitudeM:0},{lat:t.lat+2e3*Math.cos(i)/s,lng:t.lng+2e3*Math.sin(i)/(s*Math.max(.05,Math.cos(t.lat*Math.PI/180))),altitudeM:100}]}addBeam(){const e=this.pathOfNew();if(!e)return;let t=this.beams.length+1;for(;this.beams.some(s=>s.id===`beam-${t}`);)t++;const i={id:`beam-${t}`,path:e,wavelengthNm:532,powerW:5};this.writeBeams([...this.beams,i]),this.host.changed(),this.show(i.id)}deleteCurrent(){const e=this.current;e&&(this.currentId=void 0,this.writeBeams(this.beams.filter(t=>t!==e)),this.host.changed(),this.sync())}writeBeams(e){const t=this.host.sighting();t.skyEvents=L.written({...t.skyEvents,beams:e})}labelOf(e){const t=this.host.said().read(e.title);return t?`${t} (${e.id})`:e.id}get beams(){return this.host.sighting().skyEvents?.beams??[]}element(e){return this.container.querySelector(`#${e}`)}}export{g as BeamEditor};
30
+ </div>`,this.list=new w({header:this.element("beam-list"),body:this.element("beam-fields"),ids:{list:"beam-select",remove:"beam-delete",add:"beam-add"},onSelect:t=>this.show(t),onAdd:()=>this.addBeam(),onRemove:()=>this.deleteCurrent()}),this.list.setLabels({list:e.beam,remove:e.deleteBeam,add:e.addBeam,empty:e.none}),this.timeline=new _(this.element("beam-timeline"),t=>this.host.seekTo(t),{addKeyframeHere:e.addHere,keyframeHere:e.here,zoomHint:e.zoomHint}),this.places=new w({header:this.element("beam-places"),body:this.element("beam-place-parameters"),ids:{list:"beam-place",remove:"beam-place-delete",add:"beam-place-add"},navigation:{scope:this.element("beam-path"),onStep:t=>this.selectPlace(this.placeIndex+t)},onSelect:t=>this.selectPlace(Number(t)),onAdd:()=>this.addPlace(),onRemove:()=>this.removePlace()}),this.places.setLabels({list:e.place,remove:e.deletePlace,add:e.addPlace,previous:e.previousPlace,next:e.nextPlace}),this.element("beam-colour").addEventListener("input",t=>this.pickColour(t.target.value)),this.element("beam-light-delete").addEventListener("click",()=>this.removeLightKey()),this.element("beam-move-delete").addEventListener("click",()=>this.removeMoveKey()),this.onForm=void 0,this.lightForm=void 0,this.lightKeyForm=void 0,this.moveKeyForm=void 0,this.placeForm=void 0}written(){const e=this.current;e&&this.list?.rename(e.id,this.labelOf(e)),this.syncTimeline()}targetOfBeam(){return new f(()=>this.current,e=>this.editBeam(t=>e(t)))}static ON_COLOR="#2f9e5a";static LIGHT_COLOR="#c0581b";static PATH_COLOR="#4f8fd6";syncTimeline(){const e=this.current;if(!this.timeline||!e)return;const t=this.messages,i=this.host.duration(),s=e.fromT??0,n=e.untilT??i,o=[{t:s,until:n,label:""}],a=this.sortedLight(e),r=this.sortedMoves(e),v=[{id:"on",label:t.on,color:g.ON_COLOR,times:[s,n],spans:o,active:this.row==="on",open:()=>this.selectRow("on"),pressed:()=>this.selectRow("on"),move:(d,m)=>this.moveEnd(d===s?"fromT":"untilT",m),add:()=>this.moveEnd("fromT",Math.round(this.host.currentTime()))},{id:"light",label:t.light,color:g.LIGHT_COLOR,times:a.map(d=>d.t),spans:a.length?[]:o,active:this.row==="light",selectedTime:this.row==="light"&&this.lightIndex!==void 0?a[this.lightIndex]?.t:void 0,open:()=>this.selectLight(this.lightIndex),pressed:(d,m)=>this.selectLight(m===void 0?this.lightIndex:this.sortedLight(this.current).findIndex(y=>y.t===m)),move:(d,m)=>this.moveLightKey(d,m),add:()=>this.addLightKey(Math.round(this.host.currentTime()))},{id:"path",label:t.path,color:g.PATH_COLOR,times:r.map(d=>d.t),spans:r.length?[]:o,active:this.row==="path",selectedTime:this.row==="path"&&this.moveIndex!==void 0?r[this.moveIndex]?.t:void 0,open:()=>this.selectMove(this.moveIndex),pressed:(d,m)=>this.selectMove(m===void 0?this.moveIndex:this.sortedMoves(this.current).findIndex(y=>y.t===m)),move:(d,m)=>this.moveMoveKey(d,m),add:()=>this.addMoveKey(Math.round(this.host.currentTime()))}],b=[s,n,...a.map(d=>d.t),...r.map(d=>d.t)];this.timeline.show(v,i,this.host.currentTime(),{from:Math.min(0,...b),to:Math.max(i,...b)})}sortedLight(e){return[...e.light??[]].sort((t,i)=>t.t-i.t)}sortedMoves(e){return[...e.moves??[]].sort((t,i)=>t.t-i.t)}selectRow(e){this.row=e,this.syncDetail(!0)}syncDetail(e=!1){this.current&&(this.element("beam-on").hidden=this.row!=="on",this.element("beam-light").hidden=this.row!=="light",this.element("beam-path").hidden=this.row!=="path",this.row==="on"&&this.syncOn(e),this.row==="light"&&this.syncLight(e),this.row==="path"&&this.syncPath(e),this.syncTimeline())}syncOn(e){this.onForm?this.onForm.sync(e):(this.onForm=new p(this.element("beam-on-parameters"),this.language,"beamOn."),this.onForm.show(this.resolved(h.ON),this.targetOfBeam(),()=>this.syncTimeline()))}moveEnd(e,t){this.editBeam(i=>{i[e]=t,i.fromT!==void 0&&i.untilT!==void 0&&i.untilT<i.fromT&&(e==="fromT"?delete i.untilT:[i.fromT,i.untilT]=[i.untilT,i.fromT])}),this.selectRow("on")}selectLight(e){const t=this.current?this.sortedLight(this.current):[];this.lightIndex=e!==void 0&&e>=0&&e<t.length?e:t.length?0:void 0,this.selectRow("light")}get currentLightKey(){const e=this.current;return e&&this.lightIndex!==void 0?this.sortedLight(e)[this.lightIndex]:void 0}syncLight(e){const t=this.messages,i=this.currentLightKey;this.element("beam-light-note").textContent=i?t.lightKeyNote:t.lightNoKeyNote,this.element("beam-light-parameters").hidden=i!==void 0,this.element("beam-light-key-parameters").hidden=i===void 0,this.element("beam-light-delete").hidden=i===void 0,this.lightForm?this.lightForm.sync(e):(this.lightForm=new p(this.element("beam-light-parameters"),this.language,"beamLight."),this.lightForm.show(this.resolved(h.LIGHT),this.targetOfBeam(),()=>this.syncColour())),this.lightKeyForm?this.lightKeyForm.sync(e):(this.lightKeyForm=new p(this.element("beam-light-key-parameters"),this.language,"beamLightKey."),this.lightKeyForm.show(this.resolved(h.LIGHT_KEY),new f(()=>this.currentLightKey,s=>this.editLightKey(this.lightIndex,s),()=>this.current),()=>this.syncColour())),this.syncColour()}syncColour(){const e=this.current;e&&(this.element("beam-colour").value=h.hexOf(this.currentLightKey?.wavelengthNm??e.wavelengthNm))}pickColour(e){const t=h.wavelengthOf(e);this.lightIndex===void 0?(this.editBeam(i=>{i.wavelengthNm=t}),this.lightForm?.sync(!0)):(this.editLightKey(this.lightIndex,i=>{i.wavelengthNm=t}),this.lightKeyForm?.sync(!0))}editLightKey(e,t){const i=this.current;if(!i)return;const s=this.sortedLight(i),n={...s[e]};t(n);const o=s.map((a,r)=>r===e?n:a).sort((a,r)=>a.t-r.t);this.editBeam(a=>{a.light=o}),this.lightIndex=o.indexOf(n),this.syncTimeline()}addLightKey(e){const t=this.current;if(!t)return;const i=this.sortedLight(t),s=i.findIndex(r=>Math.abs(r.t-e)<1);if(s>=0){this.selectLight(s);return}const n=u.stateAt(t,e),o={t:e,wavelengthNm:Math.round(n.wavelengthNm),powerW:Number(n.powerW.toFixed(3))},a=[...i,o].sort((r,v)=>r.t-v.t);this.editBeam(r=>{r.light=a}),this.selectLight(a.indexOf(o))}moveLightKey(e,t){const i=this.current?this.sortedLight(this.current).findIndex(s=>s.t===e):-1;i<0||(this.editLightKey(i,s=>{s.t=t}),this.selectRow("light"))}removeLightKey(){const e=this.current,t=this.lightIndex;if(!e||t===void 0)return;const i=this.sortedLight(e).filter((s,n)=>n!==t);this.editBeam(s=>{i.length?s.light=i:delete s.light}),this.selectLight(i.length?Math.min(t,i.length-1):void 0)}selectMove(e){const t=this.current?this.sortedMoves(this.current):[],i=e!==void 0&&e>=0&&e<t.length?e:t.length?0:void 0;i!==this.moveIndex&&(this.placeIndex=0),this.moveIndex=i,this.selectRow("path")}get currentMoveKey(){const e=this.current;return e&&this.moveIndex!==void 0?this.sortedMoves(e)[this.moveIndex]:void 0}get shownPath(){return this.currentMoveKey?.path??this.current?.path??[]}syncPath(e){const t=this.messages,i=this.currentMoveKey;this.element("beam-path-note").textContent=i?t.pathKeyNote:t.pathNoKeyNote,this.element("beam-move-key-parameters").hidden=i===void 0,this.element("beam-move-delete").hidden=i===void 0,this.moveKeyForm?this.moveKeyForm.sync(e):(this.moveKeyForm=new p(this.element("beam-move-key-parameters"),this.language,"beamMoveKey."),this.moveKeyForm.show(this.resolved(h.MOVE_KEY),new f(()=>this.currentMoveKey,s=>this.editMoveKey(this.moveIndex,n=>s(n))),()=>{})),this.syncPlaces(e)}editMoveKey(e,t){const i=this.current;if(!i)return;const s=this.sortedMoves(i),n={...s[e],path:[...s[e].path]};t(n);const o=s.map((a,r)=>r===e?n:a).sort((a,r)=>a.t-r.t);this.editBeam(a=>{a.moves=o}),this.moveIndex=o.indexOf(n),this.syncTimeline()}addMoveKey(e){const t=this.current;if(!t)return;const i=this.sortedMoves(t),s=i.findIndex(a=>Math.abs(a.t-e)<1);if(s>=0){this.selectMove(s);return}const n={t:e,path:u.stateAt(t,e).path.map(a=>({...a}))},o=[...i,n].sort((a,r)=>a.t-r.t);this.editBeam(a=>{a.moves=o}),this.selectMove(o.indexOf(n))}moveMoveKey(e,t){const i=this.current?this.sortedMoves(this.current).findIndex(s=>s.t===e):-1;i<0||(this.editMoveKey(i,s=>{s.t=t}),this.selectRow("path"))}removeMoveKey(){const e=this.current,t=this.moveIndex;if(!e||t===void 0)return;const i=this.sortedMoves(e).filter((s,n)=>n!==t);this.editBeam(s=>{i.length?s.moves=i:delete s.moves}),this.selectMove(i.length?Math.min(t,i.length-1):void 0)}syncPlaces(e=!1){const t=this.shownPath;this.placeIndex=Math.max(0,Math.min(this.placeIndex,t.length-1)),this.places?.setItems(t.map((i,s)=>({id:String(s),label:`${s+1}/${t.length}`})),String(this.placeIndex)),this.places?.setStepState(this.placeIndex>0,this.placeIndex<t.length-1),this.places?.setRemoveEnabled(t.length>g.MIN_PLACES),this.placeForm?this.placeForm.sync(e):(this.placeForm=new p(this.element("beam-place-parameters"),this.language,"beamPlace."),this.placeForm.show(this.resolved(h.PLACE),new f(()=>this.shownPath[this.placeIndex],i=>this.editPath(s=>{const n={...s[this.placeIndex]};return i(n),s.map((o,a)=>a===this.placeIndex?n:o)}),void 0,this.host.positionPlace?.()),()=>{}))}editPath(e){this.moveIndex!==void 0?this.editMoveKey(this.moveIndex,t=>{t.path=e(t.path)}):this.editBeam(t=>{t.path=e(t.path)})}static MIN_PLACES=2;selectPlace(e){const t=this.shownPath;e<0||e>=t.length||(this.placeIndex=e,this.syncPlaces(!0))}addPlace(){this.editPath(e=>[...e,h.nextPlace(e)]),this.placeIndex=this.shownPath.length-1,this.syncPlaces(!0)}removePlace(){if(this.shownPath.length<=g.MIN_PLACES)return;const e=this.placeIndex;this.editPath(t=>t.filter((i,s)=>s!==e)),this.syncPlaces(!0)}editBeam(e){const t=this.current;if(!t)return;const i={...t,path:[...t.path]};e(i),this.writeBeams(this.beams.map(s=>s===t?i:s)),this.host.changed()}pathOfNew(){const e=this.host.sighting(),t=e.event?.place?.[0];if(t?.lat===void 0||t.lng===void 0)return;const i=(e.observerTrack?.getInterpolatedPoseAt(0)?.headingDeg??0)*Math.PI/180,s=111320;return[{lat:t.lat,lng:t.lng,altitudeM:0},{lat:t.lat+2e3*Math.cos(i)/s,lng:t.lng+2e3*Math.sin(i)/(s*Math.max(.05,Math.cos(t.lat*Math.PI/180))),altitudeM:100}]}addBeam(){const e=this.pathOfNew();if(!e)return;let t=this.beams.length+1;for(;this.beams.some(s=>s.id===`beam-${t}`);)t++;const i={id:`beam-${t}`,path:e,wavelengthNm:532,powerW:5};this.writeBeams([...this.beams,i]),this.host.changed(),this.show(i.id)}deleteCurrent(){const e=this.current;e&&(this.currentId=void 0,this.writeBeams(this.beams.filter(t=>t!==e)),this.host.changed(),this.sync())}writeBeams(e){const t=this.host.sighting();t.skyEvents=E.written({...t.skyEvents,beams:e})}labelOf(e){const t=this.host.said().read(e.title);return t?`${t} (${e.id})`:e.id}get beams(){return this.host.sighting().skyEvents?.beams??[]}element(e){return this.container.querySelector(`#${e}`)}}export{g as BeamEditor};
@@ -0,0 +1 @@
1
+ import{G as W,a2 as X,a5 as H,Y as m,ap as v,aq as k,at as D}from"./rr0-sighting.mjs";import{L as S}from"./LaserBeam-CMO6tMze.js";class x{static MAX_SEGMENTS=12e3;static MIN_PIXELS=2;static VERTICES_PER_SEGMENT=24;static HALO_RAD=.002;static HALO_SHARE=.15;static BRIGHTEST_RELATIVE=6e4;group=new W;mesh;positions=new Float32Array(x.MAX_SEGMENTS*x.VERTICES_PER_SEGMENT*3);colors=new Float32Array(x.MAX_SEGMENTS*x.VERTICES_PER_SEGMENT*3);segments=0;drawn=[];cut;constructor(){const s=new X;s.setAttribute("position",new H(this.positions,3)),s.setAttribute("color",new H(this.colors,3)),s.setDrawRange(0,0),this.mesh=new m(s,new v({vertexColors:!0,transparent:!0,blending:D,depthWrite:!1,fog:!1,side:k})),this.mesh.frustumCulled=!1,this.mesh.renderOrder=8,this.mesh.name="beams",this.group.name="beams",this.group.add(this.mesh)}get segmentCount(){return this.segments}get object(){return this.group}get drawnCount(){return this.segments}pick(s,t,e){return this.pickAt(s,t,e.toleranceRad)}update(s,t,e){const l=this.viewsOf(s,t,e);let r=0;this.segments=0,this.drawn=[];for(const h of l){const c=S.colourOf(h.wavelengthNm),i=this.place(h,t,e);this.drawn.push({id:h.id,points:i});for(let y=0;y+1<i.length&&!(this.segments>=x.MAX_SEGMENTS);y++){const E=this.pushSegment(r,i[y],i[y+1],h.wavelengthNm,c,e);E>r&&this.segments++,r=E}}const o=this.mesh.geometry;o.setDrawRange(0,r);for(const h of["position","color"]){const c=o.getAttribute(h);c.clearUpdateRanges(),r>0&&c.addUpdateRange(0,r*3),c.needsUpdate=!0}}viewsOf(s,t,e){const{lat:l,lng:r}=e.reference;(!this.cut||this.cut.lat!==l||this.cut.lng!==r||this.cut.air!==e.air)&&(this.cut={lat:l,lng:r,air:e.air,views:new Map});const o=this.cut.views,h=new Set(s);return S.onAt(s,t).map(c=>{if(!h.has(c))return S.viewOf(c,e.reference,e.air);let i=o.get(c);return i||o.set(c,i=S.viewOf(c,e.reference,e.air)),i})}place(s,t,e){const l=[],r=e.wind??{eastMS:0,northMS:0};for(const o of s.samples){const h=e.origin.x+o.eastM*e.eastScale,c=e.origin.z-o.northM,i=o.upM-e.siteElevationM;if(l.length>0&&i<e.groundYAt(h,c))break;const y=r.eastMS*o.dirEast+r.northMS*o.dirNorth,E=r.eastMS*o.dirNorth-r.northMS*o.dirEast,g=S.patchAt(o.fromSourceM,t,{windAlongMS:y,windAcrossMS:E,patchiness:s.patchiness});l.push({x:h,y:i,z:c,altitudeM:o.altitudeM,widthM:o.widthM,powerW:o.powerW,haze:g})}return l}static SMOOTH_RATIO=1.08;static MAX_HALVINGS=6;pushSegment(s,t,e,l,r,o,h=0){const c={x:e.x-t.x,y:e.y-t.y,z:e.z-t.z},i=Math.hypot(c.x,c.y,c.z);if(i<1e-6)return s;const y={x:c.x/i,y:c.y/i,z:c.z/i};if(Math.hypot((t.x+e.x)/2-o.eye.x,(t.y+e.y)/2-o.eye.y,(t.z+e.z)/2-o.eye.z)<.001)return s;const E=n=>{const u={x:o.eye.x-n.x,y:o.eye.y-n.y,z:o.eye.z-n.z},z=Math.hypot(u.x,u.y,u.z)||.001,p=(y.x*u.x+y.y*u.y+y.z*u.z)/z,a=Math.sqrt(Math.max(0,1-p*p)),w=S.coefficientsAt(o.air,l,n.altitudeM),d=S.phasedScattering({...w,aerosolPerM:w.aerosolPerM*n.haze},p);return{sinTurn:a,scattered:d,through:o.transmittanceTo(n.x,n.y,n.z)}},g=n=>x.MIN_PIXELS*o.pixelRad*Math.hypot(n.x-o.eye.x,n.y-o.eye.y,n.z-o.eye.z),N=n=>Math.hypot(n.x-o.eye.x,n.y-o.eye.y,n.z-o.eye.z),R=n=>Math.max(n.widthM,x.HALO_RAD*N(n)),f=n=>{const u=R(n)/g(n),z=Math.min(1,Math.max(0,u-1));return x.HALO_SHARE*z*z*(3-2*z)},O=new Map([t,e].map(n=>[n,E(n)])),M=(n,u,z)=>{const p=Math.max(u,g(n)),{sinTurn:a,scattered:w,through:d}=O.get(n),I=2*z*S.luminanceCdM2(n.powerW,l,w,p,a),L=r.map((C,V)=>Math.min(x.BRIGHTEST_RELATIVE,I*o.relativeScale*C*d[V])),_={x:o.eye.x-n.x,y:o.eye.y-n.y,z:o.eye.z-n.z},P=this.normalise(this.cross(y,_));return{point:n,half:p/2,level:L,across:P}},A=[[M(t,t.widthM,1-f(t)),M(e,e.widthM,1-f(e))],[M(t,R(t),f(t)),M(e,R(e),f(e))]],[G,T]=A[0].map(n=>Math.max(...n.level));if(h<x.MAX_HALVINGS&&Math.max(G,T)>x.SMOOTH_RATIO*Math.max(Math.min(G,T),1e-12)){const n={x:(t.x+e.x)/2,y:(t.y+e.y)/2,z:(t.z+e.z)/2,altitudeM:(t.altitudeM+e.altitudeM)/2,widthM:(t.widthM+e.widthM)/2,powerW:Math.sqrt(t.powerW*e.powerW),haze:(t.haze+e.haze)/2};return this.pushSegment(this.pushSegment(s,t,n,l,r,o,h+1),n,e,l,r,o,h+1)}if((s+x.VERTICES_PER_SEGMENT)*3>this.positions.length)return s;for(const n of A){if(n.every(a=>Math.max(...a.level)<=0))continue;const u=(a,w)=>{const d=s*3;this.positions[d]=a.point.x+a.across.x*a.half*w,this.positions[d+1]=a.point.y+a.across.y*a.half*w,this.positions[d+2]=a.point.z+a.across.z*a.half*w;const I=w===0?1:0;this.colors[d]=a.level[0]*I,this.colors[d+1]=a.level[1]*I,this.colors[d+2]=a.level[2]*I,s++},[z,p]=n;for(const a of[-1,1])u(z,a),u(z,0),u(p,a),u(z,0),u(p,0),u(p,a)}return s}pickAt(s,t,e){let l;for(const r of this.drawn)for(let o=0;o+1<r.points.length;o++){const h=r.points[o],c=r.points[o+1],i={x:c.x-h.x,y:c.y-h.y,z:c.z-h.z},y={x:h.x-s.x,y:h.y-s.y,z:h.z-s.z},E=i.x*i.x+i.y*i.y+i.z*i.z,g=i.x*t.x+i.y*t.y+i.z*t.z,N=i.x*y.x+i.y*y.y+i.z*y.z,R=t.x*y.x+t.y*y.y+t.z*y.z,f=E-g*g,O=f>1e-9?Math.min(1,Math.max(0,(g*R-N)/f)):0,M={x:h.x+i.x*O,y:h.y+i.y*O,z:h.z+i.z*O},A=(M.x-s.x)*t.x+(M.y-s.y)*t.y+(M.z-s.z)*t.z;if(A<=0)continue;const G=Math.hypot(M.x-s.x-t.x*A,M.y-s.y-t.y*A,M.z-s.z-t.z*A),T=Math.atan2(G,A);T<=e&&(!l||T<l.angle)&&(l={id:r.id,distanceM:Math.hypot(M.x-s.x,M.y-s.y,M.z-s.z),angle:T})}return l&&{id:l.id,distanceM:l.distanceM}}cross(s,t){return{x:s.y*t.z-s.z*t.y,y:s.z*t.x-s.x*t.z,z:s.x*t.y-s.y*t.x}}normalise(s){const t=Math.hypot(s.x,s.y,s.z)||1;return{x:s.x/t,y:s.y/t,z:s.z/t}}dispose(){this.mesh.geometry.dispose(),this.mesh.material.dispose(),this.group.removeFromParent()}}export{x as BeamSystem};
@@ -1,4 +1,4 @@
1
- import{e as k,_ as c,aQ as u,aI as y,aJ as T,aO as w,aM as M,aN as I}from"./rr0-sighting.mjs";import{S as F,P as O,a as x,E as A}from"./ParameterForm-DviNoiD5.js";import{B as v,a as m,F as S}from"./BirdFlock-BbObIeXW.js";import{T as E}from"./TimelineTracks-CvGxdpGb.js";const L=k.catalog({en:()=>c(()=>import("./BirdParameterTexts_en-C6FkYUww.js"),[],import.meta.url).then(l=>l.birdParameterTexts_en),fr:()=>c(()=>import("./BirdParameterTexts_fr-BiTR-olu.js"),[],import.meta.url).then(l=>l.birdParameterTexts_fr),es:()=>c(()=>import("./BirdParameterTexts_es-T8JyeNlI.js"),[],import.meta.url).then(l=>l.birdParameterTexts_es),it:()=>c(()=>import("./BirdParameterTexts_it-oQY4DX6B.js"),[],import.meta.url).then(l=>l.birdParameterTexts_it)});class n{static FLOCK="flock";static FORMATION="formation";static FLIGHT="flight";static LOOK="look";static speciesOf(t){return v.speciesOf(t)}static speciesLabel(t){return t.replace(/-([a-z])/g,(e,i)=>i.toUpperCase())}static formationOf(t){const e=u.read(t,"formation.kind");return typeof e=="string"?e:n.formationUnstated(t)}static formationUnstated(t){return(u.read(t,"count")??1)>1?"cluster":"single"}static flightOf(t){const e=u.read(t,"flight.kind");return typeof e=="string"?e:n.speciesOf(t).flight.kind}static burstOf(t,e){const i=u.read(t,`flight.${e}`);if(typeof i=="number")return i;const s=n.speciesOf(t).flight;return s.kind==="flapping"?n.BURST[e]:s[e]}static BURST={beats:4,glideS:2};static colour(t,e,i){return{type:"colour",key:`colours.${t}`,group:n.LOOK,label:e,...i?{hint:i}:{},effective:s=>m.colourOf(n.speciesOf(s),t)}}static SET={kind:"birds",title:"birds",parameters:[{type:"said",key:"title",label:"name",group:n.FLOCK},{type:"choice",key:"species",required:!0,group:n.FLOCK,label:"species",choices:m.ALL.map(t=>({value:t.id,label:n.speciesLabel(t.id)}))},{type:"number",key:"count",min:1,max:2e3,step:1,group:n.FLOCK,effective:()=>1,label:"howMany"},{type:"set",key:"explains",group:n.FLOCK,label:"standForTheShapes",hint:"theWholeFlockTakenForOne",visibleWhen:t=>t.explainsEach===void 0,options:(t,e)=>{const i=e?.shapes??[],s=(t.explains??[]).filter(o=>!i.some(a=>a.value===o));return[...i,...s.map(o=>({value:o,label:o}))]},empty:"noShape"},{type:"number",key:"seed",min:0,max:4294967295,step:1,group:n.FLOCK,effective:()=>1,label:"draw",hint:"whatTheDrawsStartFrom"},{type:"choice",key:"formation.kind",group:n.FORMATION,label:"pattern",effective:t=>n.formationUnstated(t),choices:[{value:"single",label:"oneBird"},{value:"v",label:"inAV"},{value:"j",label:"inAJ"},{value:"echelon",label:"inEchelon"},{value:"column",label:"inAColumn"},{value:"front",label:"abreast"},{value:"cluster",label:"aLooseCrowd"},{value:"flock",label:"aFlockThatFliesItself"}]},{type:"number",key:"formation.angleDeg",min:5,max:180,step:1,unit:"°",group:n.FORMATION,effective:()=>70,label:"angleBetweenTheArms",hint:"aGooseVMeasures",visibleWhen:t=>["v","j"].includes(n.formationOf(t))},{type:"number",key:"formation.asymmetry",min:0,max:100,step:5,unit:"%",scale:100,group:n.FORMATION,effective:()=>.7,label:"onTheRightArm",visibleWhen:t=>n.formationOf(t)==="j"},{type:"number",key:"formation.spacing",min:.2,max:20,step:.1,group:n.FORMATION,effective:t=>["v","j","echelon","column"].includes(n.formationOf(t))?1:1.5,label:"spacingInWingspans",hint:"betweenNeighbours",visibleWhen:t=>n.formationOf(t)!=="single"},{type:"number",key:"formation.wander",min:0,max:5,step:.05,group:n.FORMATION,effective:t=>["v","j","echelon","column"].includes(n.formationOf(t))?.15:.4,label:"strayInWingspans",hint:"howMuchEachBirdStrays",visibleWhen:t=>!["single","flock"].includes(n.formationOf(t))},{type:"number",key:"formation.informed",min:0,max:100,step:1,unit:"%",scale:100,group:n.FORMATION,effective:()=>S.INFORMED_SHARE,label:"informed",hint:"aFewKnowWhereTheFlockIsGoing",visibleWhen:t=>n.formationOf(t)==="flock"},{type:"number",key:"wingbeatHz",min:.5,max:30,step:.01,unit:"Hz",group:n.FLIGHT,effective:t=>{const e=t,i=v.pathOf(e)[0]?.upM??0;return Math.round(m.wingbeatHz(n.speciesOf(t),m.airDensityAt((e.originElevationM??0)+i))*100)/100},label:"wingbeat",hint:"predictedFromItsSpecies"},{type:"choice",key:"flight.kind",group:n.FLIGHT,label:"howTheyFly",effective:t=>n.speciesOf(t).flight.kind,choices:[{value:"flapping",label:"flappingAllTheTime"},{value:"bursts",label:"inBurstsAndGlides"},{value:"path",label:"asTheirPathAsks"}]},{type:"number",key:"flight.beats",min:1,max:50,step:1,group:n.FLIGHT,label:"wingbeatsABurst",effective:t=>n.burstOf(t,"beats"),visibleWhen:t=>n.flightOf(t)!=="flapping"},{type:"number",key:"flight.glideS",min:0,max:60,step:.1,unit:"s",group:n.FLIGHT,label:"glideBetween",effective:t=>n.burstOf(t,"glideS"),visibleWhen:t=>n.flightOf(t)!=="flapping"},{type:"number",key:"originElevationM",min:-500,max:6e3,step:1,unit:"m",group:n.FLIGHT,effective:()=>0,label:"thePlaceSGroundAboveTheSea",hint:"whatSetsHowThinTheAir"},n.colour("upperColor","upperSide","theBackAndTheUpperSide"),n.colour("underColor","underSide","theBellyAndTheUnderSide"),n.colour("tipColor","wingTips"),n.colour("headColor","head"),n.colour("neckColor","neck"),n.colour("billColor","bill"),{type:"number",key:"lightFromBelow.lux",min:0,max:1e4,step:.1,unit:"lx",group:n.LOOK,effective:()=>0,label:"litFromBelow",hint:"theLampsOfATown"},{type:"colour",key:"lightFromBelow.color",group:n.LOOK,fallback:"#ffd7a0",label:"lightFromBelowColour",visibleWhen:t=>typeof u.read(t,"lightFromBelow.lux")=="number"}]};static angular(t){return typeof t.azimuthDeg=="number"}static WAYPOINT={kind:"birds-waypoint",title:"pointOfThePath",parameters:[{type:"number",key:"t",min:-36e3,max:36e3,step:.1,unit:"s",scale:.001,required:!0,label:"time",hint:"secondsOfTheRecording"},{type:"position",key:"eastM",secondKey:"northM",saidKey:"saidPosition",native:"local",step:1,rangeM:1e5,label:"position",visibleWhen:t=>!n.angular(t)},{type:"number",key:"altitudeM",min:-500,max:1e4,step:.1,unit:"m",required:!0,label:"height",hint:"aboveTheGroundOfThePlace",visibleWhen:t=>!n.angular(t)},{type:"number",key:"azimuthDeg",min:0,max:360,step:.1,unit:"°",required:!0,label:"azimuth",visibleWhen:t=>n.angular(t)},{type:"number",key:"altitudeDeg",min:-90,max:90,step:.1,unit:"°",required:!0,label:"elevation",visibleWhen:t=>n.angular(t)},{type:"number",key:"distanceM",min:0,max:1e5,step:1,unit:"m",required:!0,label:"distance",visibleWhen:t=>n.angular(t)},{type:"number",key:"eyeHeightM",min:0,max:1e4,step:.1,unit:"m",effective:()=>1.6,label:"eyeHeight",visibleWhen:t=>n.angular(t)}]};static waypointAt(t,e){const i=v.pathOf(t),s=g=>Math.round(g*10)/10;if(i.length===0)return{t:e,eastM:0,northM:0,altitudeM:0};const o=i.findIndex(g=>g.t>=e),[a,r]=o<=0?[i[Math.max(o,0)],i[Math.max(o,0)]]:[i[o-1],i[o]],h=o<0?i[i.length-1]:void 0,p=h||r.t===a.t?0:(e-a.t)/(r.t-a.t),d=h??a,b=h??r;return{t:Math.round(e),eastM:s(d.eastM+(b.eastM-d.eastM)*p),northM:s(d.northM+(b.northM-d.northM)*p),altitudeM:s(d.upM+(b.upM-d.upM)*p)}}static publish(){y.publish(n.SET),y.publish(n.WAYPOINT)}}const R=k.catalog({en:()=>c(()=>import("./BirdEditorMessages_en-CN1OJud9.js"),[],import.meta.url).then(l=>l.birdEditorMessages_en),fr:()=>c(()=>import("./BirdEditorMessages_fr-hL72V8wm.js"),[],import.meta.url).then(l=>l.birdEditorMessages_fr),es:()=>c(()=>import("./BirdEditorMessages_es-DDEnjRrz.js"),[],import.meta.url).then(l=>l.birdEditorMessages_es),it:()=>c(()=>import("./BirdEditorMessages_it-BmLyiPYp.js"),[],import.meta.url).then(l=>l.birdEditorMessages_it)});class f{constructor(t,e,i){this.container=t,this.host=e,F.attach(t,"bird-editor-part",f.STYLE),this.language=i,y.of("birds")||n.publish(),this.ready=this.setLanguage(i)}messages;ready;parameterTexts;languageToken=0;currentId;form;list;timeline;pointForm;pointIndex=0;language;shown=[];static STYLE='.bird-editor-part { flex-basis: 100%; min-width: 0; } .bird-editor-part #bird-list, .bird-editor-part #bird-timeline { flex-basis: 100%; min-width: 0; } .bird-editor-part #bird-timeline { padding: 4px 0; } .bird-editor-part #bird-path > .icon-btn { align-self: flex-end; } .bird-editor-part .launch-editor, .bird-editor-part .launch-fields { display: flex; flex-wrap: wrap; gap: 8px; align-items: end; } .bird-editor-part .launch-fields { flex-basis: 100%; min-width: 0; } .bird-editor-part [hidden] { display: none !important; } .bird-editor-part select { min-width: 0; width: 100%; } .bird-editor-part .launch-intro { flex-basis: 100%; margin: 0; } .bird-editor-part .launch-parameters { flex-basis: 100%; min-width: 0; display: flex; flex-wrap: wrap; gap: 8px; align-items: flex-start; } .bird-editor-part .parameter-group { flex: 1 1 14em; min-width: 0; box-sizing: border-box; margin: 0; display: flex; flex-wrap: wrap; gap: 6px 12px; align-items: flex-start; align-content: flex-start; } .bird-editor-part input, .bird-editor-part select { max-width: 100%; box-sizing: border-box; } .bird-editor-part input[type="text"] { width: 12em; } .bird-editor-part label { min-width: 0; max-width: 100%; } .bird-editor-part input.parameter-derived::placeholder { opacity: .65; } .bird-editor-part .launch-path { flex: 1 1 100%; min-width: 0; box-sizing: border-box; margin: 0; display: flex; flex-wrap: wrap; gap: 6px 12px; align-items: flex-start; }';static PATH_COLOR="#3b82c4";async setLanguage(t){const e=++this.languageToken;this.language=t;const[i,s]=await Promise.all([R.load(t),L.load(t)]);e===this.languageToken&&(this.messages=i,this.parameterTexts=s,this.render(),this.sync())}sync(){if(!this.messages)return;const t=this.flocks;this.shown=[...t],t.some(s=>s.id===this.currentId)||(this.currentId=t[0]?.id),this.list?.setItems(t.map(s=>({id:s.id,label:this.labelOf(s)})),this.currentId),this.syncAddState();const e=this.current;if(this.element("bird-fields").hidden=e===void 0,!e)return;const i=this.element("bird-each");i.hidden=e.explainsEach===void 0,i.textContent=this.messages.explainsEachNote.replace("{n}",String(e.explainsEach?.length??0)),this.form??=new O(this.element("bird-parameters"),this.language,"birds.",{said:()=>this.host.said(),writingLanguage:()=>this.host.writingLanguage()}),this.form.show(this.resolved(n.SET),new x(()=>this.current,s=>this.editFlock(o=>s(o)),()=>({shapes:this.host.shapes().map(s=>({value:s.id,label:s.label}))}),this.host.positionPlace?.()),()=>this.written()),this.syncPoint(!0)}refresh(){if(!this.messages)return;this.syncAddState();const t=this.flocks;if(t.length===this.shown.length&&t.every((e,i)=>e.id===this.shown[i].id)){this.syncTimeline();return}this.sync()}setTime(t){this.messages&&this.timeline?.setTime(t)}syncAddState(){const t=this.frontOfObserver()!==void 0;this.list?.setAddState(t,t?void 0:this.messages.addNowhere)}get current(){return this.flocks.find(t=>t.id===this.currentId)}resolved(t){return T.resolve(t,this.parameterTexts)}render(){if(!this.messages)return;const t=this.messages;this.form=void 0,this.pointForm=void 0,this.container.innerHTML=`<div class="launch-editor">
1
+ import{i as T,_ as c,aT as u,aL as y,aM as k,aR as w,aP as M,aQ as I}from"./rr0-sighting.mjs";import{S as F,P as O,a as x,E as A}from"./ParameterForm-B8nX9qW-.js";import{B as v,a as m,F as S}from"./BirdFlock-BZScQXfR.js";import{T as E}from"./TimelineTracks-CYIJdyPF.js";const L=T.catalog({en:()=>c(()=>import("./BirdParameterTexts_en-C6FkYUww.js"),[],import.meta.url).then(l=>l.birdParameterTexts_en),fr:()=>c(()=>import("./BirdParameterTexts_fr-BiTR-olu.js"),[],import.meta.url).then(l=>l.birdParameterTexts_fr),es:()=>c(()=>import("./BirdParameterTexts_es-T8JyeNlI.js"),[],import.meta.url).then(l=>l.birdParameterTexts_es),it:()=>c(()=>import("./BirdParameterTexts_it-oQY4DX6B.js"),[],import.meta.url).then(l=>l.birdParameterTexts_it)});class n{static FLOCK="flock";static FORMATION="formation";static FLIGHT="flight";static LOOK="look";static speciesOf(t){return v.speciesOf(t)}static speciesLabel(t){return t.replace(/-([a-z])/g,(e,i)=>i.toUpperCase())}static formationOf(t){const e=u.read(t,"formation.kind");return typeof e=="string"?e:n.formationUnstated(t)}static formationUnstated(t){return(u.read(t,"count")??1)>1?"cluster":"single"}static flightOf(t){const e=u.read(t,"flight.kind");return typeof e=="string"?e:n.speciesOf(t).flight.kind}static burstOf(t,e){const i=u.read(t,`flight.${e}`);if(typeof i=="number")return i;const s=n.speciesOf(t).flight;return s.kind==="flapping"?n.BURST[e]:s[e]}static BURST={beats:4,glideS:2};static colour(t,e,i){return{type:"colour",key:`colours.${t}`,group:n.LOOK,label:e,...i?{hint:i}:{},effective:s=>m.colourOf(n.speciesOf(s),t)}}static SET={kind:"birds",title:"birds",parameters:[{type:"said",key:"title",label:"name",group:n.FLOCK},{type:"choice",key:"species",required:!0,group:n.FLOCK,label:"species",choices:m.ALL.map(t=>({value:t.id,label:n.speciesLabel(t.id)}))},{type:"number",key:"count",min:1,max:2e3,step:1,group:n.FLOCK,effective:()=>1,label:"howMany"},{type:"set",key:"explains",group:n.FLOCK,label:"standForTheShapes",hint:"theWholeFlockTakenForOne",visibleWhen:t=>t.explainsEach===void 0,options:(t,e)=>{const i=e?.shapes??[],s=(t.explains??[]).filter(o=>!i.some(a=>a.value===o));return[...i,...s.map(o=>({value:o,label:o}))]},empty:"noShape"},{type:"number",key:"seed",min:0,max:4294967295,step:1,group:n.FLOCK,effective:()=>1,label:"draw",hint:"whatTheDrawsStartFrom"},{type:"choice",key:"formation.kind",group:n.FORMATION,label:"pattern",effective:t=>n.formationUnstated(t),choices:[{value:"single",label:"oneBird"},{value:"v",label:"inAV"},{value:"j",label:"inAJ"},{value:"echelon",label:"inEchelon"},{value:"column",label:"inAColumn"},{value:"front",label:"abreast"},{value:"cluster",label:"aLooseCrowd"},{value:"flock",label:"aFlockThatFliesItself"}]},{type:"number",key:"formation.angleDeg",min:5,max:180,step:1,unit:"°",group:n.FORMATION,effective:()=>70,label:"angleBetweenTheArms",hint:"aGooseVMeasures",visibleWhen:t=>["v","j"].includes(n.formationOf(t))},{type:"number",key:"formation.asymmetry",min:0,max:100,step:5,unit:"%",scale:100,group:n.FORMATION,effective:()=>.7,label:"onTheRightArm",visibleWhen:t=>n.formationOf(t)==="j"},{type:"number",key:"formation.spacing",min:.2,max:20,step:.1,group:n.FORMATION,effective:t=>["v","j","echelon","column"].includes(n.formationOf(t))?1:1.5,label:"spacingInWingspans",hint:"betweenNeighbours",visibleWhen:t=>n.formationOf(t)!=="single"},{type:"number",key:"formation.wander",min:0,max:5,step:.05,group:n.FORMATION,effective:t=>["v","j","echelon","column"].includes(n.formationOf(t))?.15:.4,label:"strayInWingspans",hint:"howMuchEachBirdStrays",visibleWhen:t=>!["single","flock"].includes(n.formationOf(t))},{type:"number",key:"formation.informed",min:0,max:100,step:1,unit:"%",scale:100,group:n.FORMATION,effective:()=>S.INFORMED_SHARE,label:"informed",hint:"aFewKnowWhereTheFlockIsGoing",visibleWhen:t=>n.formationOf(t)==="flock"},{type:"number",key:"wingbeatHz",min:.5,max:30,step:.01,unit:"Hz",group:n.FLIGHT,effective:t=>{const e=t,i=v.pathOf(e)[0]?.upM??0;return Math.round(m.wingbeatHz(n.speciesOf(t),m.airDensityAt((e.originElevationM??0)+i))*100)/100},label:"wingbeat",hint:"predictedFromItsSpecies"},{type:"choice",key:"flight.kind",group:n.FLIGHT,label:"howTheyFly",effective:t=>n.speciesOf(t).flight.kind,choices:[{value:"flapping",label:"flappingAllTheTime"},{value:"bursts",label:"inBurstsAndGlides"},{value:"path",label:"asTheirPathAsks"}]},{type:"number",key:"flight.beats",min:1,max:50,step:1,group:n.FLIGHT,label:"wingbeatsABurst",effective:t=>n.burstOf(t,"beats"),visibleWhen:t=>n.flightOf(t)!=="flapping"},{type:"number",key:"flight.glideS",min:0,max:60,step:.1,unit:"s",group:n.FLIGHT,label:"glideBetween",effective:t=>n.burstOf(t,"glideS"),visibleWhen:t=>n.flightOf(t)!=="flapping"},{type:"number",key:"originElevationM",min:-500,max:6e3,step:1,unit:"m",group:n.FLIGHT,effective:()=>0,label:"thePlaceSGroundAboveTheSea",hint:"whatSetsHowThinTheAir"},n.colour("upperColor","upperSide","theBackAndTheUpperSide"),n.colour("underColor","underSide","theBellyAndTheUnderSide"),n.colour("tipColor","wingTips"),n.colour("headColor","head"),n.colour("neckColor","neck"),n.colour("billColor","bill"),{type:"number",key:"lightFromBelow.lux",min:0,max:1e4,step:.1,unit:"lx",group:n.LOOK,effective:()=>0,label:"litFromBelow",hint:"theLampsOfATown"},{type:"colour",key:"lightFromBelow.color",group:n.LOOK,fallback:"#ffd7a0",label:"lightFromBelowColour",visibleWhen:t=>typeof u.read(t,"lightFromBelow.lux")=="number"}]};static angular(t){return typeof t.azimuthDeg=="number"}static WAYPOINT={kind:"birds-waypoint",title:"pointOfThePath",parameters:[{type:"number",key:"t",min:-36e3,max:36e3,step:.1,unit:"s",scale:.001,required:!0,label:"time",hint:"secondsOfTheRecording"},{type:"position",key:"eastM",secondKey:"northM",saidKey:"saidPosition",native:"local",step:1,rangeM:1e5,label:"position",visibleWhen:t=>!n.angular(t)},{type:"number",key:"altitudeM",min:-500,max:1e4,step:.1,unit:"m",required:!0,label:"height",hint:"aboveTheGroundOfThePlace",visibleWhen:t=>!n.angular(t)},{type:"number",key:"azimuthDeg",min:0,max:360,step:.1,unit:"°",required:!0,label:"azimuth",visibleWhen:t=>n.angular(t)},{type:"number",key:"altitudeDeg",min:-90,max:90,step:.1,unit:"°",required:!0,label:"elevation",visibleWhen:t=>n.angular(t)},{type:"number",key:"distanceM",min:0,max:1e5,step:1,unit:"m",required:!0,label:"distance",visibleWhen:t=>n.angular(t)},{type:"number",key:"eyeHeightM",min:0,max:1e4,step:.1,unit:"m",effective:()=>1.6,label:"eyeHeight",visibleWhen:t=>n.angular(t)}]};static waypointAt(t,e){const i=v.pathOf(t),s=g=>Math.round(g*10)/10;if(i.length===0)return{t:e,eastM:0,northM:0,altitudeM:0};const o=i.findIndex(g=>g.t>=e),[a,r]=o<=0?[i[Math.max(o,0)],i[Math.max(o,0)]]:[i[o-1],i[o]],h=o<0?i[i.length-1]:void 0,p=h||r.t===a.t?0:(e-a.t)/(r.t-a.t),d=h??a,b=h??r;return{t:Math.round(e),eastM:s(d.eastM+(b.eastM-d.eastM)*p),northM:s(d.northM+(b.northM-d.northM)*p),altitudeM:s(d.upM+(b.upM-d.upM)*p)}}static publish(){y.publish(n.SET),y.publish(n.WAYPOINT)}}const R=T.catalog({en:()=>c(()=>import("./BirdEditorMessages_en-CN1OJud9.js"),[],import.meta.url).then(l=>l.birdEditorMessages_en),fr:()=>c(()=>import("./BirdEditorMessages_fr-hL72V8wm.js"),[],import.meta.url).then(l=>l.birdEditorMessages_fr),es:()=>c(()=>import("./BirdEditorMessages_es-DDEnjRrz.js"),[],import.meta.url).then(l=>l.birdEditorMessages_es),it:()=>c(()=>import("./BirdEditorMessages_it-BmLyiPYp.js"),[],import.meta.url).then(l=>l.birdEditorMessages_it)});class f{constructor(t,e,i){this.container=t,this.host=e,F.attach(t,"bird-editor-part",f.STYLE),this.language=i,y.of("birds")||n.publish(),this.ready=this.setLanguage(i)}messages;ready;parameterTexts;languageToken=0;currentId;form;list;timeline;pointForm;pointIndex=0;language;shown=[];static STYLE='.bird-editor-part { flex-basis: 100%; min-width: 0; } .bird-editor-part #bird-list, .bird-editor-part #bird-timeline { flex-basis: 100%; min-width: 0; } .bird-editor-part #bird-timeline { padding: 4px 0; } .bird-editor-part #bird-path > .icon-btn { align-self: flex-end; } .bird-editor-part .launch-editor, .bird-editor-part .launch-fields { display: flex; flex-wrap: wrap; gap: 8px; align-items: end; } .bird-editor-part .launch-fields { flex-basis: 100%; min-width: 0; } .bird-editor-part [hidden] { display: none !important; } .bird-editor-part select { min-width: 0; width: 100%; } .bird-editor-part .launch-intro { flex-basis: 100%; margin: 0; } .bird-editor-part .launch-parameters { flex-basis: 100%; min-width: 0; display: flex; flex-wrap: wrap; gap: 8px; align-items: flex-start; } .bird-editor-part .parameter-group { flex: 1 1 14em; min-width: 0; box-sizing: border-box; margin: 0; display: flex; flex-wrap: wrap; gap: 6px 12px; align-items: flex-start; align-content: flex-start; } .bird-editor-part input, .bird-editor-part select { max-width: 100%; box-sizing: border-box; } .bird-editor-part input[type="text"] { width: 12em; } .bird-editor-part label { min-width: 0; max-width: 100%; } .bird-editor-part input.parameter-derived::placeholder { opacity: .65; } .bird-editor-part .launch-path { flex: 1 1 100%; min-width: 0; box-sizing: border-box; margin: 0; display: flex; flex-wrap: wrap; gap: 6px 12px; align-items: flex-start; }';static PATH_COLOR="#3b82c4";async setLanguage(t){const e=++this.languageToken;this.language=t;const[i,s]=await Promise.all([R.load(t),L.load(t)]);e===this.languageToken&&(this.messages=i,this.parameterTexts=s,this.render(),this.sync())}sync(){if(!this.messages)return;const t=this.flocks;this.shown=[...t],t.some(s=>s.id===this.currentId)||(this.currentId=t[0]?.id),this.list?.setItems(t.map(s=>({id:s.id,label:this.labelOf(s)})),this.currentId),this.syncAddState();const e=this.current;if(this.element("bird-fields").hidden=e===void 0,!e)return;const i=this.element("bird-each");i.hidden=e.explainsEach===void 0,i.textContent=this.messages.explainsEachNote.replace("{n}",String(e.explainsEach?.length??0)),this.form??=new O(this.element("bird-parameters"),this.language,"birds.",{said:()=>this.host.said(),writingLanguage:()=>this.host.writingLanguage()}),this.form.show(this.resolved(n.SET),new x(()=>this.current,s=>this.editFlock(o=>s(o)),()=>({shapes:this.host.shapes().map(s=>({value:s.id,label:s.label}))}),this.host.positionPlace?.()),()=>this.written()),this.syncPoint(!0)}refresh(){if(!this.messages)return;this.syncAddState();const t=this.flocks;if(t.length===this.shown.length&&t.every((e,i)=>e.id===this.shown[i].id)){this.syncTimeline();return}this.sync()}setTime(t){this.messages&&this.timeline?.setTime(t)}syncAddState(){const t=this.frontOfObserver()!==void 0;this.list?.setAddState(t,t?void 0:this.messages.addNowhere)}get current(){return this.flocks.find(t=>t.id===this.currentId)}resolved(t){return k.resolve(t,this.parameterTexts)}render(){if(!this.messages)return;const t=this.messages;this.form=void 0,this.pointForm=void 0,this.container.innerHTML=`<div class="launch-editor">
2
2
  <p class="launch-intro">${t.intro}</p>
3
3
  <div id="bird-list"></div>
4
4
  <div id="bird-fields" class="launch-fields">
@@ -1 +1 @@
1
- import{aH as jt}from"./rr0-sighting.mjs";class V{static G=9.81;static BUILDS={gull:{lengthM:.6,wingspanM:1.4,restM:{widthM:1.4,heightM:.14,lengthM:.653},colours:{upperColor:"#a9b1b9",underColor:"#f3f2ec",tipColor:"#1b1c1f",headColor:"#f3f2ec",neckColor:"#f3f2ec",billColor:"#e6bd35"}},pelican:{lengthM:1.2,wingspanM:2.1,restM:{widthM:2.147,heightM:.281,lengthM:1.299},colours:{upperColor:"#7d7468",underColor:"#4f4840",tipColor:"#3b3631",headColor:"#e9dfb5",neckColor:"#5a3a2a",billColor:"#8d8778"}},goose:{lengthM:.95,wingspanM:1.6,restM:{widthM:1.6,heightM:.22,lengthM:1.003},colours:{upperColor:"#6b5d4f",underColor:"#cfc6b8",tipColor:"#3a332c",headColor:"#1d1c1b",neckColor:"#1d1c1b",billColor:"#1d1c1b"}},duck:{lengthM:.58,wingspanM:.9,restM:{widthM:.9,heightM:.15,lengthM:.633},colours:{upperColor:"#6d6457",underColor:"#b9b2a6",tipColor:"#4d463d",headColor:"#1f5a35",neckColor:"#ece9e1",billColor:"#d9b23a"}},plover:{lengthM:.27,wingspanM:.68,restM:{widthM:.68,heightM:.07,lengthM:.291},colours:{upperColor:"#6f6650",underColor:"#e8e4da",tipColor:"#3b362c",headColor:"#6f6650",neckColor:"#e8e4da",billColor:"#1d1c1b"}}};static ALL=[{id:"herring-gull",name:"Herring gull",build:"gull",lengthM:.6,wingspanM:1.4,massKg:1,wingAreaM2:.2,flight:{kind:"flapping"},plumage:{color:"#e6e8ea",albedo:.6}},{id:"ring-billed-gull",name:"Ring-billed gull",build:"gull",lengthM:.48,wingspanM:1.2,massKg:.5,wingAreaM2:.14,flight:{kind:"flapping"},colours:{upperColor:"#b3bbc3"},plumage:{color:"#e6e8ea",albedo:.6}},{id:"black-headed-gull",name:"Black-headed gull",build:"gull",lengthM:.37,wingspanM:1,massKg:.28,wingAreaM2:.1,flight:{kind:"flapping"},colours:{upperColor:"#c3c9cf",headColor:"#3d2b24",billColor:"#8f1d1d"},plumage:{color:"#e8eaec",albedo:.6}},{id:"brown-pelican",name:"Brown pelican",build:"pelican",lengthM:1.2,wingspanM:2.1,massKg:3.5,wingAreaM2:.55,flight:{kind:"bursts",beats:5,glideS:3},plumage:{color:"#7d7468",albedo:.25}},{id:"american-white-pelican",name:"American white pelican",build:"pelican",lengthM:1.5,wingspanM:2.7,massKg:7,wingAreaM2:.9,flight:{kind:"bursts",beats:6,glideS:3},plumage:{color:"#f3f2ec",albedo:.8},colours:{upperColor:"#f3f2ec",underColor:"#f3f2ec",tipColor:"#1b1c1f",headColor:"#f3f2ec",neckColor:"#f3f2ec",billColor:"#e89a3c"}},{id:"canada-goose",name:"Canada goose",build:"goose",lengthM:.95,wingspanM:1.6,massKg:4,wingAreaM2:.3,flight:{kind:"flapping"},plumage:{color:"#8a7c6c",albedo:.25}},{id:"snow-goose",name:"Snow goose",build:"goose",lengthM:.75,wingspanM:1.45,massKg:2.6,wingAreaM2:.25,flight:{kind:"flapping"},plumage:{color:"#f3f2ec",albedo:.8},colours:{upperColor:"#f3f2ec",underColor:"#f3f2ec",tipColor:"#1b1c1f",headColor:"#f3f2ec",neckColor:"#f3f2ec",billColor:"#d9898a"}},{id:"mallard",name:"Mallard",build:"duck",lengthM:.58,wingspanM:.9,massKg:1.1,wingAreaM2:.095,flight:{kind:"flapping"},plumage:{color:"#8a8074",albedo:.3}},{id:"american-golden-plover",name:"American golden plover",build:"plover",lengthM:.26,wingspanM:.68,massKg:.145,wingAreaM2:.038,flight:{kind:"flapping"},plumage:{color:"#8a8070",albedo:.3}},{id:"killdeer",name:"Killdeer",build:"plover",lengthM:.25,wingspanM:.6,massKg:.09,wingAreaM2:.03,flight:{kind:"flapping"},colours:{upperColor:"#7a6249",headColor:"#7a6249"},plumage:{color:"#9a8a72",albedo:.3}}];static byId(t){return V.ALL.find(a=>a.id===t)}static wingbeatHz(t,a=1.225){return t.massKg**(3/8)*Math.sqrt(V.G)*t.wingspanM**(-23/24)*t.wingAreaM2**(-1/3)*a**(-3/8)}static airDensityAt(t){return 1.225*((288.15-.0065*t)/288.15)**4.2559}static colourOf(t,a){return t.colours?.[a]??V.BUILDS[t.build].colours[a]}static sizeOf(t){const a=V.BUILDS[t.build],e=t.wingspanM/a.wingspanM,o=t.lengthM/a.lengthM;return{widthM:a.restM.widthM*e,lengthM:a.restM.lengthM*o,heightM:a.restM.heightM*o}}}class l{static STEP_S=.05;static NEIGHBOURS=7;static MAX_BANK_DEG=60;static INFORMED_SHARE=.2;static BLIND_HALF_DEG=30;static TURN_LAG_S=.25;static SEPARATION=4;static ALIGNMENT=1;static TURN_FOLLOWING=.8;static COHESION=.6;static EDGE_COHESION=1;static VERTICAL_COHESION=.1;static LEAD=.6;static FOLLOWER_LEAD=.3;static LOOK_AHEAD_S=3;static SPEED_RATE=1.5;static SPEED_COHESION=.5;static STEERING=2;static NOISE=1.5;static OWN_SPEED=.5;static AVOIDANCE=6;static AVOID_AHEAD_S=1;static OVER_WITHIN_M=6;static MAX_RINGS=6;static run(t){const{path:a,count:e,species:o,random:n,sampleMs:r}=t,h=t.obstacles?.empty===!1?t.obstacles:void 0,f=new It(a),g=a[0].t,A=a[a.length-1].t,u=D=>{const S=f.velocityAt(D);return Math.max(Math.hypot(S.east,S.north,S.up),10)},c=t.spacing*o.wingspanM,d=p.slotsOf({kind:"cluster",spacing:t.spacing},e,o.wingspanM,n),w=f.velocityAt(g),M=Math.atan2(w.east,w.north),b=f.at(g),i=e,m=new Float64Array(i),y=new Float64Array(i),E=new Float64Array(i),O=new Float64Array(i),N=new Float64Array(i),I=new Float64Array(i),z=new Float64Array(i),T=new Float64Array(i),P=new Float64Array(i),v=new Float64Array(i),et=new Float64Array(i),at=new Float64Array(i),nt=new Float64Array(i),Ct=new Float64Array(i),Mt=new Uint8Array(i);d.forEach((D,S)=>{m[S]=b.eastM+Math.sin(M)*D.forwardM+Math.cos(M)*D.rightM,y[S]=b.northM+Math.cos(M)*D.forwardM-Math.sin(M)*D.rightM,E[S]=b.upM+D.upM,nt[S]=1+(n()-.5)*.08,O[S]=Math.sin(M)*u(g)*nt[S],N[S]=Math.cos(M)*u(g)*nt[S]});const Ut=Math.max(0,Math.min(1,t.informedShare??l.INFORMED_SHARE)),Vt=i===1?1:Math.min(i,Math.max(2,Math.round(i*Ut)));for(let D=0;D<Vt;){const S=Math.floor(n()*i);Mt[S]||(Mt[S]=1,D++)}const xt=d.map(()=>[]),Wt=d.map(()=>({x:0,y:0,z:0})),Dt=new Yt(i,Math.max(c*1.5,.1)),lt=Math.min(l.NEIGHBOURS,i-1),Nt=new Int32Array(Math.max(lt,1)),st=9.81*Math.tan(l.MAX_BANK_DEG*Math.PI/180),Xt=-Math.cos(l.BLIND_HALF_DEG*Math.PI/180),U=l.STEP_S,ct=Math.min(1,U/l.TURN_LAG_S);let gt=g;for(let D=g;D<=A+1e-6;D+=U*1e3){if(D>=gt-1e-6){for(let s=0;s<i;s++)xt[s].push({t:gt,eastM:m[s],northM:y[s],upM:E[s],headingDeg:0,pitchDeg:0,rollDeg:0});gt+=r}const S=f.at(D),dt=f.velocityAt(D),pt=u(D);Dt.fill(m,y,E);for(let s=0;s<i;s++){const W=Math.max(Math.hypot(O[s],N[s],I[s]),.001),X=O[s]/W,j=N[s]/W,Y=I[s]/W,L=lt>0?Dt.nearest(s,m,y,E,lt,l.MAX_RINGS,Nt,(C,x,K,H)=>(C*X+x*j+K*Y)/H>Xt):0;let Q=0,G=0,ut=0,St=0,Lt=0,zt=0,ft=0,At=0,wt=0,vt=0,Tt=0,Rt=0,Pt=0,Ht=0,Gt=0;for(let C=0;C<L;C++){const x=Nt[C],K=m[x]-m[s],H=y[x]-y[s],q=E[x]-E[s],R=Math.max(Math.hypot(K,H,q),.001);if(R<c){const J=(1-R/c)/R;Q-=K*J,G-=H*J,ut-=q*J}St+=m[x],Lt+=y[x],zt+=E[x],ft+=O[x],At+=N[x],wt+=I[x],vt+=z[x],Tt+=T[x],Rt+=P[x],Pt+=K/R,Ht+=H/R,Gt+=q/R}let _=0,B=0,Z=0,F=nt[s]*pt;const tt=Math.hypot(Q,G,ut);if(tt>0){const C=Math.min(1,tt*c);_+=Q/tt*l.SEPARATION*C,B+=G/tt*l.SEPARATION*C,Z+=ut/tt*l.SEPARATION*C}if(L>0){const C=St/L-m[s],x=Lt/L-y[s],K=zt/L-E[s],H=Math.max(Math.hypot(C,x,K),.001),q=Math.hypot(Pt,Ht,Gt)/L,R=(Math.min(1,H/(2*c))+l.EDGE_COHESION*q)*l.COHESION;_+=C/H*R,B+=x/H*R,Z+=K/H*R;const J=Math.max(Math.hypot(ft,At,wt)/L,.001);Z*=l.VERTICAL_COHESION,_+=ft/L/J*l.ALIGNMENT,B+=At/L/J*l.ALIGNMENT,Z+=wt/L/J*l.ALIGNMENT,F=J+(F-J)*l.OWN_SPEED,F+=(C*X+x*j+K*Y)*l.SPEED_COHESION}if(h){const C=h.inside(m[s]+O[s]*l.AVOID_AHEAD_S,y[s]+N[s]*l.AVOID_AHEAD_S,E[s]+I[s]*l.AVOID_AHEAD_S,c)??h.inside(m[s],y[s],E[s],c);C&&(_+=C.nx*l.AVOIDANCE,B+=C.ny*l.AVOIDANCE,C.belowTopM<l.OVER_WITHIN_M&&(Z+=l.AVOIDANCE))}{const C=l.LOOK_AHEAD_S,x=S.eastM+dt.east*C-m[s],K=S.northM+dt.north*C-y[s],H=S.upM+dt.up*C-E[s],q=Math.max(Math.hypot(x,K,H),.001),R=Mt[s]||L===0?l.LEAD:l.FOLLOWER_LEAD;_+=x/q*R,B+=K/q*R,Z+=H/q*R}const k=Math.hypot(_,B,Z);F=Math.max(.7*pt,Math.min(1.4*pt,F));const bt=l.STEERING*W;let ot=k>1e-6?(_/k-X)*bt:0,rt=k>1e-6?(B/k-j)*bt:0,ht=k>1e-6?(Z/k-Y)*bt:0;L>0&&(ot+=(vt/L-z[s])*l.TURN_FOLLOWING,rt+=(Tt/L-T[s])*l.TURN_FOLLOWING,ht+=(Rt/L-P[s])*l.TURN_FOLLOWING);const $=Wt[s];$.x+=((n()-.5)*2*l.NOISE-$.x)*U,$.y+=((n()-.5)*2*l.NOISE-$.y)*U,$.z+=((n()-.5)*l.NOISE-$.z)*U,ot+=$.x,rt+=$.y,ht+=$.z;const mt=ot*X+rt*j+ht*Y;let Et=ot-mt*X,yt=rt-mt*j,Ot=ht-mt*Y;const it=Math.hypot(Et,yt,Ot);it>st&&(Et*=st/it,yt*=st/it,Ot*=st/it),v[s]=Et,et[s]=yt,at[s]=Ot,Ct[s]=Math.max(-3,Math.min(3,(F-W)*l.SPEED_RATE))}for(let s=0;s<i;s++){z[s]+=(v[s]-z[s])*ct,T[s]+=(et[s]-T[s])*ct,P[s]+=(at[s]-P[s])*ct;const W=Math.max(Math.hypot(O[s],N[s],I[s]),.001),X=O[s]/W,j=N[s]/W,Y=I[s]/W,L=z[s]*X+T[s]*j+P[s]*Y;z[s]-=L*X,T[s]-=L*j,P[s]-=L*Y;const Q=Ct[s];if(O[s]+=(z[s]+X*Q)*U,N[s]+=(T[s]+j*Q)*U,I[s]+=(P[s]+Y*Q)*U,m[s]+=O[s]*U,y[s]+=N[s]*U,E[s]+=I[s]*U,h){const G=h.inside(m[s],y[s],E[s]);G&&(G.belowTopM<G.depthM?E[s]+=G.belowTopM:(m[s]+=G.nx*G.depthM,y[s]+=G.ny*G.depthM))}}}return xt.map(D=>(p.attitudes(D),{samples:D,delayS:0}))}}class Yt{constructor(t,a){this.n=t,this.cellM=a;let e=16;for(;e<t*2;)e*=2;this.size=e,this.start=new Int32Array(e+1),this.counts=new Int32Array(e),this.members=new Int32Array(t),this.slotOf=new Int32Array(t),this.seen=new Int32Array(e),this.distances=new Float64Array(t)}size;start;counts;members;slotOf;seen;search=0;distances;cell(t){return Math.floor(t/this.cellM)}slot(t,a,e){return(Math.imul(t,73856093)^Math.imul(a,19349663)^Math.imul(e,83492791))&this.size-1}fill(t,a,e){this.counts.fill(0);for(let n=0;n<this.n;n++){const r=this.slot(this.cell(t[n]),this.cell(a[n]),this.cell(e[n]));this.slotOf[n]=r,this.counts[r]++}this.start[0]=0;for(let n=0;n<this.size;n++)this.start[n+1]=this.start[n]+this.counts[n];const o=this.start.slice(0,this.size);for(let n=0;n<this.n;n++)this.members[o[this.slotOf[n]]++]=n}nearest(t,a,e,o,n,r,h,f){const g=++this.search,A=this.cell(a[t]),u=this.cell(e[t]),c=this.cell(o[t]);let d=0;const w=this.distances;for(let M=0;M<=r;M++){for(let b=A-M;b<=A+M;b++)for(let i=u-M;i<=u+M;i++)for(let m=c-M;m<=c+M;m++){if(Math.max(Math.abs(b-A),Math.abs(i-u),Math.abs(m-c))!==M)continue;const y=this.slot(b,i,m);if(this.seen[y]!==g){this.seen[y]=g;for(let E=this.start[y];E<this.start[y+1];E++){const O=this.members[E];if(O===t)continue;const N=a[O]-a[t],I=e[O]-e[t],z=o[O]-o[t],T=N*N+I*I+z*z;if(d===n&&T>=w[n-1])continue;const P=Math.sqrt(T);if(P>0&&!f(N,I,z,P))continue;let v=Math.min(d,n-1);for(;v>0&&w[v-1]>T;)w[v]=w[v-1],h[v]=h[v-1],v--;w[v]=T,h[v]=O,d<n&&d++}}}if(d===n&&w[n-1]<=(M*this.cellM)**2)break}return d}}class p{static SAMPLE_MS=100;static MAX_KEYFRAMES=6e4;static computed=new Map;static bodiesOf(t,a=jt.NONE){const e=JSON.stringify(t)+a.signature;let o=p.computed.get(e);return o||(o=p.compute(t,a),p.computed.set(e,o),p.computed.size>16&&p.computed.delete(p.computed.keys().next().value)),o}static speciesOf(t){return V.byId(t.species)??V.ALL[0]}static compute(t,a){const e=p.pathOf(t);if(e.length===0)return[];const o=p.speciesOf(t),n=Math.max(1,Math.floor(t.count??1)),r=p.randomFrom(t.seed??1),h=t.wingbeatHz??V.wingbeatHz(o,V.airDensityAt((t.originElevationM??0)+e[0].upM)),f=t.flight??o.flight,g=e[0].t,A=e[e.length-1].t,u=p.sampleMs(n,A-g),c=t.formation?.kind==="flock"?l.run({path:e,count:n,species:o,spacing:t.formation.spacing??1.5,informedShare:t.formation.informed,obstacles:a,random:r,sampleMs:u}):p.arranged(t,e,o,n,r,u),d=V.sizeOf(o),w={...o.colours,...t.colours};return c.map((M,b)=>{const i=h*(1+(r()-.5)*.06),m=r(),y=M.delayS,E=f.kind==="path"?p.flapsAlong(M.samples,i,f,m):void 0,O=M.samples.map((I,z)=>({t:Math.round(I.t),eastM:p.round(I.eastM),northM:p.round(I.northM),altitudeM:p.round(I.upM-d.heightM/2),...z===0?{sizeM:d,appearance:{color:o.plumage.color,albedo:o.plumage.albedo}}:{},attitude:{headingDeg:p.round(I.headingDeg),pitchDeg:p.round(I.pitchDeg),rollDeg:p.round(I.rollDeg)},motions:{flap:p.round(E?E[z]:p.beatsAt((I.t-g)/1e3-y,i,f,m),1e3)}}));return{id:n>1?`${t.id}-${b+1}`:t.id,...t.title?{title:t.title}:{},...t.explainsEach?t.explainsEach[b]!==void 0?{explains:[t.explainsEach[b]]}:{}:{...t.explains?{explains:t.explains}:{},...n>1?{ensemble:t.id}:{}},model:{id:`ufoathome-bird-${o.build}`},shadow:!1,...Object.keys(w).length>0?{modelParameters:w}:{},...t.lightFromBelow?{lightFromBelow:t.lightFromBelow}:{},track:O}})}static beatsAt(t,a,e,o){if(e.kind==="flapping")return Math.max(0,t*a+o);const r=e.beats/a+e.glideS,h=Math.max(0,t+o*r),f=Math.floor(h/r),g=h-f*r;return f*e.beats+Math.min(e.beats,g*a)}static CLIMB_FLAPS_MS=.3;static DESCENT_GLIDES_MS=-.8;static flapsAlong(t,a,e,o){let n=o,r=!0,h=Math.floor(n),f=0;return t.map((g,A)=>{if(A===0)return n;const u=t[A-1],c=(g.t-u.t)/1e3;if(c<=0)return n;const d=(g.upM-u.upM)/c,w=r?n-h<e.beats:(g.t-f)/1e3>=e.glideS,M=d>p.CLIMB_FLAPS_MS?!0:d<p.DESCENT_GLIDES_MS?!1:w;if(r){const b=n+a*c;!M&&Math.floor(b)>Math.floor(n)?(n=Math.floor(b),r=!1,f=g.t):n=b}else M&&(r=!0,h=n);return n})}static sampleMs(t,a){const e=t*(a/p.SAMPLE_MS+1);return e<=p.MAX_KEYFRAMES?p.SAMPLE_MS:Math.ceil(p.SAMPLE_MS*e/p.MAX_KEYFRAMES/50)*50}static pathOf(t){return[...t.path].sort((a,e)=>a.t-e.t).map(a=>{if("eastM"in a)return{t:a.t,eastM:a.eastM,northM:a.northM,upM:a.altitudeM};const e=a.azimuthDeg*Math.PI/180,o=a.altitudeDeg*Math.PI/180,n=a.distanceM*Math.cos(o);return{t:a.t,eastM:n*Math.sin(e),northM:n*Math.cos(e),upM:(a.eyeHeightM??1.6)+a.distanceM*Math.sin(o)}})}static arranged(t,a,e,o,n,r){const h=t.formation??{kind:o>1?"cluster":"single"},f=p.slotsOf(h,o,e.wingspanM,n),g=h.kind==="v"||h.kind==="j"||h.kind==="echelon"||h.kind==="column",A=(h.wander??(g?.15:.4))*e.wingspanM,u=new It(a),c=Math.max(u.meanSpeedMS(),1);return f.map(d=>{const w=g?Math.max(0,-d.forwardM)/c:0,M=p.swayFrom(n,A),b=[];for(let i=a[0].t;i<=a[a.length-1].t+1e-6;i+=r){const m=(i-a[0].t)/1e3,y=i-w*1e3,E=u.at(y),O=u.velocityAt(y),N=Math.atan2(O.east,O.north),[I,z,T]=M(m),P=g?I:d.forwardM+I,v=d.rightM+z,et=E.eastM+Math.sin(N)*P+Math.cos(N)*v,at=E.northM+Math.cos(N)*P-Math.sin(N)*v;b.push({t:i,eastM:et,northM:at,upM:E.upM+d.upM+T,headingDeg:0,pitchDeg:0,rollDeg:0})}return p.attitudes(b),{samples:b,delayS:w}})}static slotsOf(t,a,e,o){const n=[],r=t.kind;if(r==="single"||a===1)return[{forwardM:0,rightM:0,upM:0}];if(r==="v"||r==="j"||r==="echelon"||r==="column"){const c=(t.spacing??1)*e*(r==="column"?0:1),d=(t.angleDeg??70)/2*Math.PI/180,w=r==="column"?(t.spacing??1)*e:c/Math.tan(d),M=r==="v"?.5:r==="echelon"||r==="column"?1:t.asymmetry??.7;n.push({forwardM:0,rightM:0,upM:0});const b=Math.round(M*(a-1));let i=0,m=0;for(let y=1;y<a;y++){const E=m>=a-1-b||i<b&&i/Math.max(b,1)<=m/Math.max(a-1-b,1),O=E?++i:++m;n.push({forwardM:-w*O,rightM:(E?1:-1)*c*O,upM:-.05*e*O*o()})}return n}const h=(t.spacing??1.5)*e;if(r==="front"){for(let c=0;c<a;c++)n.push({forwardM:(o()-.5)*h*1.2,rightM:(c-(a-1)/2)*h,upM:(o()-.5)*h*.4});return n}const f=a*h**3,g=Math.cbrt(f/(4/3*Math.PI*1*2.8*5.6)),A={up:g,across:2.8*g,along:5.6*g};let u=0;for(;n.length<a&&u<a*200;){u++;const c=2*o()-1,d=2*o()-1,w=2*o()-1;if(c*c+d*d+w*w>1)continue;const M={forwardM:c*A.along,rightM:d*A.across,upM:w*A.up};n.some(b=>(b.forwardM-M.forwardM)**2+(b.rightM-M.rightM)**2+(b.upM-M.upM)**2<(h/2)**2)||n.push(M)}for(;n.length<a;)n.push({forwardM:(o()-.5)*A.along,rightM:(o()-.5)*A.across,upM:0});return n}static swayFrom(t,a){const e=[0,1,2].map(o=>[0,1].map(()=>({period:3+t()*7,phase:t()*2*Math.PI,share:(o===2?.4:o===1?.7:1)*(.4+.6*t())})));return o=>e.map(n=>n.reduce((r,h)=>r+a*h.share*.5*Math.sin(2*Math.PI*o/h.period+h.phase),0))}static attitudes(t){const a=t.length;if(!(a<2)){for(let e=0;e<a;e++){const o=t[Math.max(0,e-1)],n=t[Math.min(a-1,e+1)],r=(n.t-o.t)/1e3,h=(n.eastM-o.eastM)/r,f=(n.northM-o.northM)/r,g=(n.upM-o.upM)/r,A=Math.hypot(h,f),u=t[e];u.headingDeg=A>.05?(Math.atan2(h,f)*180/Math.PI+360)%360:e>0?t[e-1].headingDeg:0,u.pitchDeg=Math.atan2(g,Math.max(A,.5))*180/Math.PI}for(let e=0;e<a;e++){const o=t[Math.max(0,e-2)],n=t[Math.min(a-1,e+2)],r=(n.t-o.t)/1e3;let h=n.headingDeg-o.headingDeg;h=(h+540)%360-180;const f=t[e],g=t[Math.max(0,e-1)],A=t[Math.min(a-1,e+1)],u=Math.hypot(A.eastM-g.eastM,A.northM-g.northM)/Math.max((A.t-g.t)/1e3,.001),c=r>0?h*Math.PI/180/r:0,d=Math.atan(u*c/V.G)*180/Math.PI;f.rollDeg=Math.max(-70,Math.min(70,d))}}}static randomFrom(t){let a=t>>>0;return()=>{a=a+1831565813>>>0;let e=a;return e=Math.imul(e^e>>>15,e|1),e^=e+Math.imul(e^e>>>7,e|61),((e^e>>>14)>>>0)/4294967296}}static round(t,a=100){return Math.round(t*a)/a}}class It{constructor(t){this.points=t}at(t){const a=this.points;if(a.length===1||t<=a[0].t)return this.extrapolated(t,0);if(t>=a[a.length-1].t)return this.extrapolated(t,a.length-1);let e=0;for(;e<a.length-2&&t>a[e+1].t;)e++;const o=a[Math.max(0,e-1)],n=a[e],r=a[e+1],h=a[Math.min(a.length-1,e+2)],f=(t-n.t)/(r.t-n.t),g=(u,c,d)=>(c[d]-u[d])/Math.max(c.t-u.t,1)*(r.t-n.t),A=u=>{const c=g(o,r,u),d=g(n,h,u),w=f*f,M=w*f;return(2*M-3*w+1)*n[u]+(M-2*w+f)*c+(-2*M+3*w)*r[u]+(M-w)*d};return{t,eastM:A("eastM"),northM:A("northM"),upM:A("upM")}}extrapolated(t,a){const e=this.points,o=e[a];if(e.length<2)return{...o,t};const n=a===0?e[0]:e[e.length-2],r=a===0?e[1]:e[e.length-1],h=(t-o.t)/Math.max(r.t-n.t,1);return{t,eastM:o.eastM+(r.eastM-n.eastM)*h,northM:o.northM+(r.northM-n.northM)*h,upM:o.upM+(r.upM-n.upM)*h}}velocityAt(t){const a=this.at(t-50),e=this.at(t+50);return{east:(e.eastM-a.eastM)/.1,north:(e.northM-a.northM)/.1,up:(e.upM-a.upM)/.1}}meanSpeedMS(){const t=this.points;if(t.length<2)return 0;let a=0;for(let e=1;e<t.length;e++)a+=Math.hypot(t[e].eastM-t[e-1].eastM,t[e].northM-t[e-1].northM,t[e].upM-t[e-1].upM);return a/Math.max((t[t.length-1].t-t[0].t)/1e3,.001)}}const qt=Object.freeze(Object.defineProperty({__proto__:null,BirdFlock:p,FlightPath:It},Symbol.toStringTag,{value:"Module"}));export{p as B,l as F,V as a,qt as b};
1
+ import{aK as jt}from"./rr0-sighting.mjs";class V{static G=9.81;static BUILDS={gull:{lengthM:.6,wingspanM:1.4,restM:{widthM:1.4,heightM:.14,lengthM:.653},colours:{upperColor:"#a9b1b9",underColor:"#f3f2ec",tipColor:"#1b1c1f",headColor:"#f3f2ec",neckColor:"#f3f2ec",billColor:"#e6bd35"}},pelican:{lengthM:1.2,wingspanM:2.1,restM:{widthM:2.147,heightM:.281,lengthM:1.299},colours:{upperColor:"#7d7468",underColor:"#4f4840",tipColor:"#3b3631",headColor:"#e9dfb5",neckColor:"#5a3a2a",billColor:"#8d8778"}},goose:{lengthM:.95,wingspanM:1.6,restM:{widthM:1.6,heightM:.22,lengthM:1.003},colours:{upperColor:"#6b5d4f",underColor:"#cfc6b8",tipColor:"#3a332c",headColor:"#1d1c1b",neckColor:"#1d1c1b",billColor:"#1d1c1b"}},duck:{lengthM:.58,wingspanM:.9,restM:{widthM:.9,heightM:.15,lengthM:.633},colours:{upperColor:"#6d6457",underColor:"#b9b2a6",tipColor:"#4d463d",headColor:"#1f5a35",neckColor:"#ece9e1",billColor:"#d9b23a"}},plover:{lengthM:.27,wingspanM:.68,restM:{widthM:.68,heightM:.07,lengthM:.291},colours:{upperColor:"#6f6650",underColor:"#e8e4da",tipColor:"#3b362c",headColor:"#6f6650",neckColor:"#e8e4da",billColor:"#1d1c1b"}}};static ALL=[{id:"herring-gull",name:"Herring gull",build:"gull",lengthM:.6,wingspanM:1.4,massKg:1,wingAreaM2:.2,flight:{kind:"flapping"},plumage:{color:"#e6e8ea",albedo:.6}},{id:"ring-billed-gull",name:"Ring-billed gull",build:"gull",lengthM:.48,wingspanM:1.2,massKg:.5,wingAreaM2:.14,flight:{kind:"flapping"},colours:{upperColor:"#b3bbc3"},plumage:{color:"#e6e8ea",albedo:.6}},{id:"black-headed-gull",name:"Black-headed gull",build:"gull",lengthM:.37,wingspanM:1,massKg:.28,wingAreaM2:.1,flight:{kind:"flapping"},colours:{upperColor:"#c3c9cf",headColor:"#3d2b24",billColor:"#8f1d1d"},plumage:{color:"#e8eaec",albedo:.6}},{id:"brown-pelican",name:"Brown pelican",build:"pelican",lengthM:1.2,wingspanM:2.1,massKg:3.5,wingAreaM2:.55,flight:{kind:"bursts",beats:5,glideS:3},plumage:{color:"#7d7468",albedo:.25}},{id:"american-white-pelican",name:"American white pelican",build:"pelican",lengthM:1.5,wingspanM:2.7,massKg:7,wingAreaM2:.9,flight:{kind:"bursts",beats:6,glideS:3},plumage:{color:"#f3f2ec",albedo:.8},colours:{upperColor:"#f3f2ec",underColor:"#f3f2ec",tipColor:"#1b1c1f",headColor:"#f3f2ec",neckColor:"#f3f2ec",billColor:"#e89a3c"}},{id:"canada-goose",name:"Canada goose",build:"goose",lengthM:.95,wingspanM:1.6,massKg:4,wingAreaM2:.3,flight:{kind:"flapping"},plumage:{color:"#8a7c6c",albedo:.25}},{id:"snow-goose",name:"Snow goose",build:"goose",lengthM:.75,wingspanM:1.45,massKg:2.6,wingAreaM2:.25,flight:{kind:"flapping"},plumage:{color:"#f3f2ec",albedo:.8},colours:{upperColor:"#f3f2ec",underColor:"#f3f2ec",tipColor:"#1b1c1f",headColor:"#f3f2ec",neckColor:"#f3f2ec",billColor:"#d9898a"}},{id:"mallard",name:"Mallard",build:"duck",lengthM:.58,wingspanM:.9,massKg:1.1,wingAreaM2:.095,flight:{kind:"flapping"},plumage:{color:"#8a8074",albedo:.3}},{id:"american-golden-plover",name:"American golden plover",build:"plover",lengthM:.26,wingspanM:.68,massKg:.145,wingAreaM2:.038,flight:{kind:"flapping"},plumage:{color:"#8a8070",albedo:.3}},{id:"killdeer",name:"Killdeer",build:"plover",lengthM:.25,wingspanM:.6,massKg:.09,wingAreaM2:.03,flight:{kind:"flapping"},colours:{upperColor:"#7a6249",headColor:"#7a6249"},plumage:{color:"#9a8a72",albedo:.3}}];static byId(t){return V.ALL.find(a=>a.id===t)}static wingbeatHz(t,a=1.225){return t.massKg**(3/8)*Math.sqrt(V.G)*t.wingspanM**(-23/24)*t.wingAreaM2**(-1/3)*a**(-3/8)}static airDensityAt(t){return 1.225*((288.15-.0065*t)/288.15)**4.2559}static colourOf(t,a){return t.colours?.[a]??V.BUILDS[t.build].colours[a]}static sizeOf(t){const a=V.BUILDS[t.build],e=t.wingspanM/a.wingspanM,o=t.lengthM/a.lengthM;return{widthM:a.restM.widthM*e,lengthM:a.restM.lengthM*o,heightM:a.restM.heightM*o}}}class l{static STEP_S=.05;static NEIGHBOURS=7;static MAX_BANK_DEG=60;static INFORMED_SHARE=.2;static BLIND_HALF_DEG=30;static TURN_LAG_S=.25;static SEPARATION=4;static ALIGNMENT=1;static TURN_FOLLOWING=.8;static COHESION=.6;static EDGE_COHESION=1;static VERTICAL_COHESION=.1;static LEAD=.6;static FOLLOWER_LEAD=.3;static LOOK_AHEAD_S=3;static SPEED_RATE=1.5;static SPEED_COHESION=.5;static STEERING=2;static NOISE=1.5;static OWN_SPEED=.5;static AVOIDANCE=6;static AVOID_AHEAD_S=1;static OVER_WITHIN_M=6;static MAX_RINGS=6;static run(t){const{path:a,count:e,species:o,random:n,sampleMs:r}=t,h=t.obstacles?.empty===!1?t.obstacles:void 0,f=new It(a),g=a[0].t,A=a[a.length-1].t,u=D=>{const S=f.velocityAt(D);return Math.max(Math.hypot(S.east,S.north,S.up),10)},c=t.spacing*o.wingspanM,d=p.slotsOf({kind:"cluster",spacing:t.spacing},e,o.wingspanM,n),w=f.velocityAt(g),M=Math.atan2(w.east,w.north),b=f.at(g),i=e,m=new Float64Array(i),y=new Float64Array(i),E=new Float64Array(i),O=new Float64Array(i),N=new Float64Array(i),I=new Float64Array(i),z=new Float64Array(i),T=new Float64Array(i),P=new Float64Array(i),v=new Float64Array(i),et=new Float64Array(i),at=new Float64Array(i),nt=new Float64Array(i),Ct=new Float64Array(i),Mt=new Uint8Array(i);d.forEach((D,S)=>{m[S]=b.eastM+Math.sin(M)*D.forwardM+Math.cos(M)*D.rightM,y[S]=b.northM+Math.cos(M)*D.forwardM-Math.sin(M)*D.rightM,E[S]=b.upM+D.upM,nt[S]=1+(n()-.5)*.08,O[S]=Math.sin(M)*u(g)*nt[S],N[S]=Math.cos(M)*u(g)*nt[S]});const Ut=Math.max(0,Math.min(1,t.informedShare??l.INFORMED_SHARE)),Vt=i===1?1:Math.min(i,Math.max(2,Math.round(i*Ut)));for(let D=0;D<Vt;){const S=Math.floor(n()*i);Mt[S]||(Mt[S]=1,D++)}const xt=d.map(()=>[]),Wt=d.map(()=>({x:0,y:0,z:0})),Dt=new Yt(i,Math.max(c*1.5,.1)),lt=Math.min(l.NEIGHBOURS,i-1),Nt=new Int32Array(Math.max(lt,1)),st=9.81*Math.tan(l.MAX_BANK_DEG*Math.PI/180),Xt=-Math.cos(l.BLIND_HALF_DEG*Math.PI/180),U=l.STEP_S,ct=Math.min(1,U/l.TURN_LAG_S);let gt=g;for(let D=g;D<=A+1e-6;D+=U*1e3){if(D>=gt-1e-6){for(let s=0;s<i;s++)xt[s].push({t:gt,eastM:m[s],northM:y[s],upM:E[s],headingDeg:0,pitchDeg:0,rollDeg:0});gt+=r}const S=f.at(D),dt=f.velocityAt(D),pt=u(D);Dt.fill(m,y,E);for(let s=0;s<i;s++){const W=Math.max(Math.hypot(O[s],N[s],I[s]),.001),X=O[s]/W,j=N[s]/W,Y=I[s]/W,L=lt>0?Dt.nearest(s,m,y,E,lt,l.MAX_RINGS,Nt,(C,x,K,G)=>(C*X+x*j+K*Y)/G>Xt):0;let Q=0,H=0,ut=0,St=0,Lt=0,zt=0,ft=0,At=0,wt=0,vt=0,Tt=0,Rt=0,Pt=0,Gt=0,Ht=0;for(let C=0;C<L;C++){const x=Nt[C],K=m[x]-m[s],G=y[x]-y[s],q=E[x]-E[s],R=Math.max(Math.hypot(K,G,q),.001);if(R<c){const J=(1-R/c)/R;Q-=K*J,H-=G*J,ut-=q*J}St+=m[x],Lt+=y[x],zt+=E[x],ft+=O[x],At+=N[x],wt+=I[x],vt+=z[x],Tt+=T[x],Rt+=P[x],Pt+=K/R,Gt+=G/R,Ht+=q/R}let _=0,B=0,Z=0,F=nt[s]*pt;const tt=Math.hypot(Q,H,ut);if(tt>0){const C=Math.min(1,tt*c);_+=Q/tt*l.SEPARATION*C,B+=H/tt*l.SEPARATION*C,Z+=ut/tt*l.SEPARATION*C}if(L>0){const C=St/L-m[s],x=Lt/L-y[s],K=zt/L-E[s],G=Math.max(Math.hypot(C,x,K),.001),q=Math.hypot(Pt,Gt,Ht)/L,R=(Math.min(1,G/(2*c))+l.EDGE_COHESION*q)*l.COHESION;_+=C/G*R,B+=x/G*R,Z+=K/G*R;const J=Math.max(Math.hypot(ft,At,wt)/L,.001);Z*=l.VERTICAL_COHESION,_+=ft/L/J*l.ALIGNMENT,B+=At/L/J*l.ALIGNMENT,Z+=wt/L/J*l.ALIGNMENT,F=J+(F-J)*l.OWN_SPEED,F+=(C*X+x*j+K*Y)*l.SPEED_COHESION}if(h){const C=h.inside(m[s]+O[s]*l.AVOID_AHEAD_S,y[s]+N[s]*l.AVOID_AHEAD_S,E[s]+I[s]*l.AVOID_AHEAD_S,c)??h.inside(m[s],y[s],E[s],c);C&&(_+=C.nx*l.AVOIDANCE,B+=C.ny*l.AVOIDANCE,C.belowTopM<l.OVER_WITHIN_M&&(Z+=l.AVOIDANCE))}{const C=l.LOOK_AHEAD_S,x=S.eastM+dt.east*C-m[s],K=S.northM+dt.north*C-y[s],G=S.upM+dt.up*C-E[s],q=Math.max(Math.hypot(x,K,G),.001),R=Mt[s]||L===0?l.LEAD:l.FOLLOWER_LEAD;_+=x/q*R,B+=K/q*R,Z+=G/q*R}const k=Math.hypot(_,B,Z);F=Math.max(.7*pt,Math.min(1.4*pt,F));const bt=l.STEERING*W;let ot=k>1e-6?(_/k-X)*bt:0,rt=k>1e-6?(B/k-j)*bt:0,ht=k>1e-6?(Z/k-Y)*bt:0;L>0&&(ot+=(vt/L-z[s])*l.TURN_FOLLOWING,rt+=(Tt/L-T[s])*l.TURN_FOLLOWING,ht+=(Rt/L-P[s])*l.TURN_FOLLOWING);const $=Wt[s];$.x+=((n()-.5)*2*l.NOISE-$.x)*U,$.y+=((n()-.5)*2*l.NOISE-$.y)*U,$.z+=((n()-.5)*l.NOISE-$.z)*U,ot+=$.x,rt+=$.y,ht+=$.z;const mt=ot*X+rt*j+ht*Y;let Et=ot-mt*X,yt=rt-mt*j,Ot=ht-mt*Y;const it=Math.hypot(Et,yt,Ot);it>st&&(Et*=st/it,yt*=st/it,Ot*=st/it),v[s]=Et,et[s]=yt,at[s]=Ot,Ct[s]=Math.max(-3,Math.min(3,(F-W)*l.SPEED_RATE))}for(let s=0;s<i;s++){z[s]+=(v[s]-z[s])*ct,T[s]+=(et[s]-T[s])*ct,P[s]+=(at[s]-P[s])*ct;const W=Math.max(Math.hypot(O[s],N[s],I[s]),.001),X=O[s]/W,j=N[s]/W,Y=I[s]/W,L=z[s]*X+T[s]*j+P[s]*Y;z[s]-=L*X,T[s]-=L*j,P[s]-=L*Y;const Q=Ct[s];if(O[s]+=(z[s]+X*Q)*U,N[s]+=(T[s]+j*Q)*U,I[s]+=(P[s]+Y*Q)*U,m[s]+=O[s]*U,y[s]+=N[s]*U,E[s]+=I[s]*U,h){const H=h.inside(m[s],y[s],E[s]);H&&(H.belowTopM<H.depthM?E[s]+=H.belowTopM:(m[s]+=H.nx*H.depthM,y[s]+=H.ny*H.depthM))}}}return xt.map(D=>(p.attitudes(D),{samples:D,delayS:0}))}}class Yt{constructor(t,a){this.n=t,this.cellM=a;let e=16;for(;e<t*2;)e*=2;this.size=e,this.start=new Int32Array(e+1),this.counts=new Int32Array(e),this.members=new Int32Array(t),this.slotOf=new Int32Array(t),this.seen=new Int32Array(e),this.distances=new Float64Array(t)}size;start;counts;members;slotOf;seen;search=0;distances;cell(t){return Math.floor(t/this.cellM)}slot(t,a,e){return(Math.imul(t,73856093)^Math.imul(a,19349663)^Math.imul(e,83492791))&this.size-1}fill(t,a,e){this.counts.fill(0);for(let n=0;n<this.n;n++){const r=this.slot(this.cell(t[n]),this.cell(a[n]),this.cell(e[n]));this.slotOf[n]=r,this.counts[r]++}this.start[0]=0;for(let n=0;n<this.size;n++)this.start[n+1]=this.start[n]+this.counts[n];const o=this.start.slice(0,this.size);for(let n=0;n<this.n;n++)this.members[o[this.slotOf[n]]++]=n}nearest(t,a,e,o,n,r,h,f){const g=++this.search,A=this.cell(a[t]),u=this.cell(e[t]),c=this.cell(o[t]);let d=0;const w=this.distances;for(let M=0;M<=r;M++){for(let b=A-M;b<=A+M;b++)for(let i=u-M;i<=u+M;i++)for(let m=c-M;m<=c+M;m++){if(Math.max(Math.abs(b-A),Math.abs(i-u),Math.abs(m-c))!==M)continue;const y=this.slot(b,i,m);if(this.seen[y]!==g){this.seen[y]=g;for(let E=this.start[y];E<this.start[y+1];E++){const O=this.members[E];if(O===t)continue;const N=a[O]-a[t],I=e[O]-e[t],z=o[O]-o[t],T=N*N+I*I+z*z;if(d===n&&T>=w[n-1])continue;const P=Math.sqrt(T);if(P>0&&!f(N,I,z,P))continue;let v=Math.min(d,n-1);for(;v>0&&w[v-1]>T;)w[v]=w[v-1],h[v]=h[v-1],v--;w[v]=T,h[v]=O,d<n&&d++}}}if(d===n&&w[n-1]<=(M*this.cellM)**2)break}return d}}class p{static SAMPLE_MS=100;static MAX_KEYFRAMES=6e4;static computed=new Map;static bodiesOf(t,a=jt.NONE){const e=JSON.stringify(t)+a.signature;let o=p.computed.get(e);return o||(o=p.compute(t,a),p.computed.set(e,o),p.computed.size>16&&p.computed.delete(p.computed.keys().next().value)),o}static speciesOf(t){return V.byId(t.species)??V.ALL[0]}static compute(t,a){const e=p.pathOf(t);if(e.length===0)return[];const o=p.speciesOf(t),n=Math.max(1,Math.floor(t.count??1)),r=p.randomFrom(t.seed??1),h=t.wingbeatHz??V.wingbeatHz(o,V.airDensityAt((t.originElevationM??0)+e[0].upM)),f=t.flight??o.flight,g=e[0].t,A=e[e.length-1].t,u=p.sampleMs(n,A-g),c=t.formation?.kind==="flock"?l.run({path:e,count:n,species:o,spacing:t.formation.spacing??1.5,informedShare:t.formation.informed,obstacles:a,random:r,sampleMs:u}):p.arranged(t,e,o,n,r,u),d=V.sizeOf(o),w={...o.colours,...t.colours};return c.map((M,b)=>{const i=h*(1+(r()-.5)*.06),m=r(),y=M.delayS,E=f.kind==="path"?p.flapsAlong(M.samples,i,f,m):void 0,O=M.samples.map((I,z)=>({t:Math.round(I.t),eastM:p.round(I.eastM),northM:p.round(I.northM),altitudeM:p.round(I.upM-d.heightM/2),...z===0?{sizeM:d,appearance:{color:o.plumage.color,albedo:o.plumage.albedo}}:{},attitude:{headingDeg:p.round(I.headingDeg),pitchDeg:p.round(I.pitchDeg),rollDeg:p.round(I.rollDeg)},motions:{flap:p.round(E?E[z]:p.beatsAt((I.t-g)/1e3-y,i,f,m),1e3)}}));return{id:n>1?`${t.id}-${b+1}`:t.id,...t.title?{title:t.title}:{},...t.explainsEach?t.explainsEach[b]!==void 0?{explains:[t.explainsEach[b]]}:{}:{...t.explains?{explains:t.explains}:{},...n>1?{ensemble:t.id}:{}},model:{id:`ufoathome-bird-${o.build}`},shadow:!1,...Object.keys(w).length>0?{modelParameters:w}:{},...t.lightFromBelow?{lightFromBelow:t.lightFromBelow}:{},track:O}})}static beatsAt(t,a,e,o){if(e.kind==="flapping")return Math.max(0,t*a+o);const r=e.beats/a+e.glideS,h=Math.max(0,t+o*r),f=Math.floor(h/r),g=h-f*r;return f*e.beats+Math.min(e.beats,g*a)}static CLIMB_FLAPS_MS=.3;static DESCENT_GLIDES_MS=-.8;static flapsAlong(t,a,e,o){let n=o,r=!0,h=Math.floor(n),f=0;return t.map((g,A)=>{if(A===0)return n;const u=t[A-1],c=(g.t-u.t)/1e3;if(c<=0)return n;const d=(g.upM-u.upM)/c,w=r?n-h<e.beats:(g.t-f)/1e3>=e.glideS,M=d>p.CLIMB_FLAPS_MS?!0:d<p.DESCENT_GLIDES_MS?!1:w;if(r){const b=n+a*c;!M&&Math.floor(b)>Math.floor(n)?(n=Math.floor(b),r=!1,f=g.t):n=b}else M&&(r=!0,h=n);return n})}static sampleMs(t,a){const e=t*(a/p.SAMPLE_MS+1);return e<=p.MAX_KEYFRAMES?p.SAMPLE_MS:Math.ceil(p.SAMPLE_MS*e/p.MAX_KEYFRAMES/50)*50}static pathOf(t){return[...t.path].sort((a,e)=>a.t-e.t).map(a=>{if("eastM"in a)return{t:a.t,eastM:a.eastM,northM:a.northM,upM:a.altitudeM};const e=a.azimuthDeg*Math.PI/180,o=a.altitudeDeg*Math.PI/180,n=a.distanceM*Math.cos(o);return{t:a.t,eastM:n*Math.sin(e),northM:n*Math.cos(e),upM:(a.eyeHeightM??1.6)+a.distanceM*Math.sin(o)}})}static arranged(t,a,e,o,n,r){const h=t.formation??{kind:o>1?"cluster":"single"},f=p.slotsOf(h,o,e.wingspanM,n),g=h.kind==="v"||h.kind==="j"||h.kind==="echelon"||h.kind==="column",A=(h.wander??(g?.15:.4))*e.wingspanM,u=new It(a),c=Math.max(u.meanSpeedMS(),1);return f.map(d=>{const w=g?Math.max(0,-d.forwardM)/c:0,M=p.swayFrom(n,A),b=[];for(let i=a[0].t;i<=a[a.length-1].t+1e-6;i+=r){const m=(i-a[0].t)/1e3,y=i-w*1e3,E=u.at(y),O=u.velocityAt(y),N=Math.atan2(O.east,O.north),[I,z,T]=M(m),P=g?I:d.forwardM+I,v=d.rightM+z,et=E.eastM+Math.sin(N)*P+Math.cos(N)*v,at=E.northM+Math.cos(N)*P-Math.sin(N)*v;b.push({t:i,eastM:et,northM:at,upM:E.upM+d.upM+T,headingDeg:0,pitchDeg:0,rollDeg:0})}return p.attitudes(b),{samples:b,delayS:w}})}static slotsOf(t,a,e,o){const n=[],r=t.kind;if(r==="single"||a===1)return[{forwardM:0,rightM:0,upM:0}];if(r==="v"||r==="j"||r==="echelon"||r==="column"){const c=(t.spacing??1)*e*(r==="column"?0:1),d=(t.angleDeg??70)/2*Math.PI/180,w=r==="column"?(t.spacing??1)*e:c/Math.tan(d),M=r==="v"?.5:r==="echelon"||r==="column"?1:t.asymmetry??.7;n.push({forwardM:0,rightM:0,upM:0});const b=Math.round(M*(a-1));let i=0,m=0;for(let y=1;y<a;y++){const E=m>=a-1-b||i<b&&i/Math.max(b,1)<=m/Math.max(a-1-b,1),O=E?++i:++m;n.push({forwardM:-w*O,rightM:(E?1:-1)*c*O,upM:-.05*e*O*o()})}return n}const h=(t.spacing??1.5)*e;if(r==="front"){for(let c=0;c<a;c++)n.push({forwardM:(o()-.5)*h*1.2,rightM:(c-(a-1)/2)*h,upM:(o()-.5)*h*.4});return n}const f=a*h**3,g=Math.cbrt(f/(4/3*Math.PI*1*2.8*5.6)),A={up:g,across:2.8*g,along:5.6*g};let u=0;for(;n.length<a&&u<a*200;){u++;const c=2*o()-1,d=2*o()-1,w=2*o()-1;if(c*c+d*d+w*w>1)continue;const M={forwardM:c*A.along,rightM:d*A.across,upM:w*A.up};n.some(b=>(b.forwardM-M.forwardM)**2+(b.rightM-M.rightM)**2+(b.upM-M.upM)**2<(h/2)**2)||n.push(M)}for(;n.length<a;)n.push({forwardM:(o()-.5)*A.along,rightM:(o()-.5)*A.across,upM:0});return n}static swayFrom(t,a){const e=[0,1,2].map(o=>[0,1].map(()=>({period:3+t()*7,phase:t()*2*Math.PI,share:(o===2?.4:o===1?.7:1)*(.4+.6*t())})));return o=>e.map(n=>n.reduce((r,h)=>r+a*h.share*.5*Math.sin(2*Math.PI*o/h.period+h.phase),0))}static attitudes(t){const a=t.length;if(!(a<2)){for(let e=0;e<a;e++){const o=t[Math.max(0,e-1)],n=t[Math.min(a-1,e+1)],r=(n.t-o.t)/1e3,h=(n.eastM-o.eastM)/r,f=(n.northM-o.northM)/r,g=(n.upM-o.upM)/r,A=Math.hypot(h,f),u=t[e];u.headingDeg=A>.05?(Math.atan2(h,f)*180/Math.PI+360)%360:e>0?t[e-1].headingDeg:0,u.pitchDeg=Math.atan2(g,Math.max(A,.5))*180/Math.PI}for(let e=0;e<a;e++){const o=t[Math.max(0,e-2)],n=t[Math.min(a-1,e+2)],r=(n.t-o.t)/1e3;let h=n.headingDeg-o.headingDeg;h=(h+540)%360-180;const f=t[e],g=t[Math.max(0,e-1)],A=t[Math.min(a-1,e+1)],u=Math.hypot(A.eastM-g.eastM,A.northM-g.northM)/Math.max((A.t-g.t)/1e3,.001),c=r>0?h*Math.PI/180/r:0,d=Math.atan(u*c/V.G)*180/Math.PI;f.rollDeg=Math.max(-70,Math.min(70,d))}}}static randomFrom(t){let a=t>>>0;return()=>{a=a+1831565813>>>0;let e=a;return e=Math.imul(e^e>>>15,e|1),e^=e+Math.imul(e^e>>>7,e|61),((e^e>>>14)>>>0)/4294967296}}static round(t,a=100){return Math.round(t*a)/a}}class It{constructor(t){this.points=t}at(t){const a=this.points;if(a.length===1||t<=a[0].t)return this.extrapolated(t,0);if(t>=a[a.length-1].t)return this.extrapolated(t,a.length-1);let e=0;for(;e<a.length-2&&t>a[e+1].t;)e++;const o=a[Math.max(0,e-1)],n=a[e],r=a[e+1],h=a[Math.min(a.length-1,e+2)],f=(t-n.t)/(r.t-n.t),g=(u,c,d)=>(c[d]-u[d])/Math.max(c.t-u.t,1)*(r.t-n.t),A=u=>{const c=g(o,r,u),d=g(n,h,u),w=f*f,M=w*f;return(2*M-3*w+1)*n[u]+(M-2*w+f)*c+(-2*M+3*w)*r[u]+(M-w)*d};return{t,eastM:A("eastM"),northM:A("northM"),upM:A("upM")}}extrapolated(t,a){const e=this.points,o=e[a];if(e.length<2)return{...o,t};const n=a===0?e[0]:e[e.length-2],r=a===0?e[1]:e[e.length-1],h=(t-o.t)/Math.max(r.t-n.t,1);return{t,eastM:o.eastM+(r.eastM-n.eastM)*h,northM:o.northM+(r.northM-n.northM)*h,upM:o.upM+(r.upM-n.upM)*h}}velocityAt(t){const a=this.at(t-50),e=this.at(t+50);return{east:(e.eastM-a.eastM)/.1,north:(e.northM-a.northM)/.1,up:(e.upM-a.upM)/.1}}meanSpeedMS(){const t=this.points;if(t.length<2)return 0;let a=0;for(let e=1;e<t.length;e++)a+=Math.hypot(t[e].eastM-t[e-1].eastM,t[e].northM-t[e-1].northM,t[e].upM-t[e-1].upM);return a/Math.max((t[t.length-1].t-t[0].t)/1e3,.001)}}const qt=Object.freeze(Object.defineProperty({__proto__:null,BirdFlock:p,FlightPath:It},Symbol.toStringTag,{value:"Module"}));export{p as B,l as F,V as a,qt as b};
@@ -1,6 +1,6 @@
1
- import{i as W,j as Z,k as Y,B as H,m as K,W as Q,e as P,_ as B,n as J,S as C,o as F}from"./rr0-sighting.mjs";class j{static of(t,n,a,s,i,e=new Date){const r=t.events??[],c=f=>f.url?new URL(f.url,n).href:void 0,o=r.filter(f=>f.eventType==="sighting"&&c(f)),u=o.filter(f=>f.interpretationOf===void 0),p=u.map(f=>j.witnessOf(f,c(f),a.get(c(f)),s)),l=f=>{const w=[f.interpretationOf].flat().filter(b=>typeof b=="string");return u.find(b=>b.id!==void 0&&w.includes(b.id))??u.find(b=>w.includes(a.get(c(b))?.id??""))},m=o.filter(f=>f.interpretationOf!==void 0).map(f=>{const w=l(f),b=w?p[u.indexOf(w)]:void 0;return j.readingOf(f,c(f),a.get(c(f)),b,w?a.get(c(w)):void 0,s,i)}),d=r.filter(f=>f.eventType==="interview").map(f=>{const w=u.find(b=>b.id!==void 0&&[f.interviewOf].flat().includes(b.id));return{title:s.read(f.title)??f.id??"",...w?{witness:p[u.indexOf(w)].title}:{},...f.time?{time:f.time}:{},by:j.names(f.by,s),...f.medium?{medium:f.medium}:{}}});j.placeOnMap(p,m);const g=s.read(t.summary);return{generatedAt:e.toISOString(),case:{...t.id?{id:t.id}:{},...t.title?{title:t.title}:{},...t.time?{time:t.time}:{},url:n,...g?{summary:g}:{}},witnesses:p,readings:m,interviews:d}}static witnessOf(t,n,a,s){const i=s.read(t.title)??s.read(a?.observer?.title)??t.id??n,e={...t.id?{id:t.id}:{},title:i,url:n,...t.time?{time:t.time}:{},indications:[],values:[],sources:[],moments:[]};if(!a)return e;const{recording:r,provenance:c}=W.strip(a),o=s.read(r.description);o&&(e.description=o);const u=r.place?.name;u&&(e.place=u),!e.time&&r.time&&(e.time=r.time),typeof r.durationSeconds=="number"&&(e.durationSeconds=r.durationSeconds),r.instrument&&(e.instrument=r.instrument),e.sources=(r.sources??[]).map(b=>{const v=b,y=s.read(v.title);return{...y?{title:y}:{},...v.authors?.length?{authors:v.authors}:{},...v.publication?.publisher?{publisher:v.publication.publisher}:{},...v.publication?.time?{time:v.publication.time}:{},...v.url?{url:v.url}:{},...v.index?{index:v.index}:{}}}),e.moments=[...r.milestones??[]].sort((b,v)=>b.t-v.t).map(b=>{const v=s.read(b.note);return{t:b.t,label:s.read(b.label)??"",...v?{note:v}:{}}});const p=r.observerTrack?.keyframes?.[0]?.pose,l=r.place?.locations?.[0],m=p?.lat??l?.lat,d=p?.lng??l?.lng;typeof m=="number"&&typeof d=="number"&&Object.assign(e,{lat:m,lng:d}),e.values=j.valuesOf(c,r,()=>!0,s);const g=Q.MODELS[0],f=r.account?.conditions,w=new Map;for(const b of r.timeline?.keyframes??[])for(const v of b.shapes){const y=s.read(v.shape.title);y&&!w.has(v.sourceId)&&w.set(v.sourceId,y)}return e.phenomena=Object.fromEntries(w),(r.timeline?.keyframes??[]).forEach((b,v)=>b.shapes.forEach((y,h)=>{const M=`timeline.keyframes.${v}.shapes.${h}.shape`,E=Z.traced(c,`${M}.aim`),O=Z.traced(c,`${M}.angular`);if(!E&&!O)return;const $=y.shape,x=c.at(`${M}.aim`)??c.at(`${M}.angular`),I={t:b.t,sourceId:y.sourceId,directionSaid:E,sizeSaid:O,...w.has(y.sourceId)?{phenomenon:w.get(y.sourceId)}:{},...$.aim?{aim:{azimuthDeg:$.aim.azimuthDeg,altitudeDeg:$.aim.altitudeDeg}}:{},...$.angular?{angular:$.angular}:{},...x?{basis:x.basis}:{},...x?.rationale?{rationale:s.read(x.rationale)??""}:{},...x?.source?{source:x.source}:{}};if(E&&$.aim){const L=(G,A,R)=>{const V=c.at(`${M}.aim.${R}`)??c.at(`${M}.aim`),q=g.law({kind:G,value:A,basis:V?.basis,how:V?.how},f);return[q.low??A,q.high??A]};I.uncertainty={azimuthDeg:L("heading",$.aim.azimuthDeg,"azimuthDeg"),altitudeDeg:L("elevation",$.aim.altitudeDeg,"altitudeDeg")}}e.indications.push(I)})),e}static readingOf(t,n,a,s,i,e,r){const c={...t.id?{id:t.id}:{},title:e.read(t.title)??e.read(a?.interpretation?.title)??n,url:n,reads:s?.title??"",by:j.names(t.by,e),...t.time?{time:t.time}:{},supposed:[],findings:[],comparisons:[],paths:[]};if(!a)return c;const{recording:o,provenance:u}=W.strip(a),p=e.read(o.description)??e.read(o.summary);p&&(c.description=p),c.supposed=j.valuesOf(u,o,(d,g)=>d.startsWith("interpretation")&&(g==="assumed"||g==="fitted"),e);const l=d=>typeof d=="string"?d:e.read(d)??"";if(c.findings=(o.interpretation?.findings??[]).map(d=>({text:l(d.text),outcome:d.outcome,...d.against?{against:d.against}:{},written:!0})),!i)return c;r&&c.findings.push(...r.findingsOf(i,a).map(d=>({text:l(d.text),outcome:d.outcome,...d.against?{against:d.against}:{},written:!1})));const m=o.interpretation?.bodies??[];if(m.length>0)try{const d=Z.forAccount(i);c.sensitivity=d.of(m,u),c.comparisons=d.comparisons(m),c.paths=j.pathsOf(m,i,c.comparisons.map(g=>g.t))}catch{}return c}static pathsOf(t,n,a){const s=Y(n),i={heightAt:()=>0},e=r=>H.eyeOf(s,r,i);return t.filter(r=>(r.explains?.length??0)>0).map(r=>{const c=new H(r,i,e),u=[...new Set([...r.track.map(p=>p.t),...a])].sort((p,l)=>p-l).map(p=>({t:p,state:c.at(p)})).filter(p=>p.state!==void 0).map(({t:p,state:l})=>({t:p,eastM:l.eastM,northM:l.northM}));return{bodyId:r.id,points:u}}).filter(r=>r.points.length>0)}static placeOnMap(t,n){const a=t.find(s=>s.lat!==void 0&&s.lng!==void 0);if(a){for(const s of t){if(s.lat===void 0||s.lng===void 0)continue;const i=K(s.lat,s.lng,a.lat,a.lng);s.at={eastM:i.x,northM:-i.z}}for(const s of n){const i=t.find(e=>e.title===s.reads)?.at;if(!i){s.paths=[];continue}for(const e of s.paths)for(const r of e.points)r.eastM+=i.eastM,r.northM+=i.northM}}}static valuesOf(t,n,a,s){return t.paths().flatMap(i=>{const e=t.at(i);return a(i,e.basis)?[{path:i,value:i.split(".").reduce((r,c)=>r?.[c],n),basis:e.basis,...e.rationale?{rationale:s.read(e.rationale)??""}:{},...e.source?{source:e.source}:{}}]:[]})}static names(t,n){const a=s=>s.replace(/([a-z])([A-Z])/g,"$1 $2");return(t??[]).map(s=>{if("people"in s){const[e,...r]=a(s.people).split(" ");return[...r,e].join(" ")}if("org"in s)return a(s.org);const i=s;return n.read(i.title)??i.id??""}).filter(s=>s!=="")}}class X{constructor(t,n){this.texts=t,this.language=n,this.decimal=new Intl.NumberFormat(n,{maximumFractionDigits:1}),this.signed=new Intl.NumberFormat(n,{maximumFractionDigits:2,signDisplay:"exceptZero"})}decimal;signed;number(t){return t===void 0||!Number.isFinite(t)?"":this.decimal.format(t)}degrees(t){return t===void 0?"":`${this.number(t)}°`}azimuth(t){return t===void 0?"":this.degrees((t%360+360)%360)}instant(t){return`${this.number(t/1e3)} s`}amount(t,n){switch(t){case"azimuth":case"altitude":return`${this.signed.format(n)}°`;case"time":return`${this.signed.format(n/1e3)} s`;default:return`×${new Intl.NumberFormat(this.language,{maximumFractionDigits:2}).format(n)}`}}rests(t){const n=t.source;return[n?[n.said?`interview ${n.said.interview??""} #${n.said.segment}`.replace(" "," "):void 0,typeof n.document=="string"?n.document:void 0,n.at,n.picture,n.tool,n.url].filter(Boolean).join(", "):"",t.rationale].filter(s=>s&&s!=="").join(" : ")}value(t){const n=t.value;return typeof n=="number"?this.number(n):typeof n=="string"?n:Array.isArray(n)?`[${n.length}]`:n===void 0?"":JSON.stringify(n)}robustness(t){const n=this.texts.robustness;return!t||t.compared===0?{kind:"nothing",text:n.nothing}:Z.measurable(t)?t.sufficient===!0?{kind:"sufficient",text:n.sufficient}:t.sufficient===!1?{kind:"fine-tuned",text:n.fineTuned.replace("{knob}",this.texts.knobs[t.margins[0].knob])}:{kind:"unjudged",text:n.unjudged}:{kind:"too-few",text:n.tooFew}}reproduced(t){return t&&t.compared>0?`${Math.round(t.agreement*t.compared)} / ${t.compared}`:""}ends(t){const n=(a,s)=>`${s?"≥ ":""}${this.amount(t.knob,a)}`;return{from:n(t.lower,t.lowerReached),to:n(t.upper,t.upperReached)}}fill(t,n){return t.replace(/\{(\w+)\}/g,(a,s)=>s in n?n[s]:a)}}class T{static FORMAT="ufoathome-case-report";static VERSION=1;static json(t,n){return JSON.stringify({format:T.FORMAT,version:T.VERSION,generator:`UFO@home ${n}`,...t},null,2)}static csv(t,n,a){const s=new X(n,a),i=n.columns,e=c=>c===void 0||!Number.isFinite(c)?"":String(Math.round(c*1e3)/1e3),r={};return r["indications.csv"]=T.table([i.witness,`${i.instant} (s)`,i.phenomenon,`${i.azimuth} (°)`,`${i.altitude} (°)`,`${i.azimuth} min`,`${i.azimuth} max`,`${i.altitude} min`,`${i.altitude} max`,`${i.size} (°)`,i.basis,i.rests],t.witnesses.flatMap(c=>c.indications.map(o=>[c.title,e(o.t/1e3),o.phenomenon??o.sourceId,e(o.aim?.azimuthDeg),e(o.aim?.altitudeDeg),e(o.uncertainty?.azimuthDeg[0]),e(o.uncertainty?.azimuthDeg[1]),e(o.uncertainty?.altitudeDeg[0]),e(o.uncertainty?.altitudeDeg[1]),o.sizeSaid?e(o.angular?.widthDeg):"",o.basis?n.bases[o.basis]:"",s.rests(o)]))),r["values.csv"]=T.table([i.witness,i.reading,i.path,i.value,i.basis,i.rests],[...t.witnesses.flatMap(c=>c.values.map(o=>[c.title,"",o.path,s.value(o),n.bases[o.basis],s.rests(o)])),...t.readings.flatMap(c=>c.supposed.map(o=>[c.reads,c.title,o.path,s.value(o),n.bases[o.basis],s.rests(o)]))]),r["readings.csv"]=T.table([i.reading,i.reads,i.by,i.time,i.reproduced,i.compared,`${i.gap} (°)`,i.robustness,i.supposedCount],t.readings.map(c=>[c.title,c.reads,c.by.join(", "),c.time??"",c.sensitivity&&c.sensitivity.compared>0?String(Math.round(c.sensitivity.agreement*c.sensitivity.compared)):"",c.sensitivity&&c.sensitivity.compared>0?String(c.sensitivity.compared):"",e(c.sensitivity?.medianSeparationDeg),s.robustness(c.sensitivity).text,String(c.supposed.length)])),r["margins.csv"]=T.table([i.reading,i.reads,i.knob,i.from,i.to,`${i.reference} min`,`${i.reference} max`,i.covered],t.readings.flatMap(c=>(c.sensitivity?.margins??[]).map(o=>[c.title,c.reads,n.knobs[o.knob],e(o.lower),e(o.upper),e(o.reference?.lower),e(o.reference?.upper),o.coverage===void 0?"":e(o.coverage)]))),r["comparisons.csv"]=T.table([i.reading,i.reads,`${i.instant} (s)`,i.phenomenon,`${i.said} ${i.azimuth}`,`${i.said} ${i.altitude}`,`${i.read} ${i.azimuth}`,`${i.read} ${i.altitude}`,`${i.separation} (°)`,i.agrees],t.readings.flatMap(c=>c.comparisons.map(o=>[c.title,c.reads,e(o.t/1e3),t.witnesses.find(u=>u.title===c.reads)?.phenomena?.[o.sourceId]??o.sourceId,e(o.said?.azimuthDeg),e(o.said?.altitudeDeg),e(o.predicted.azimuthDeg),e(o.predicted.altitudeDeg),e(o.separationDeg),o.agrees?n.yes:n.no]))),r["findings.csv"]=T.table([i.reading,i.reads,i.finding,i.outcome,i.against,i.origin],t.readings.flatMap(c=>c.findings.map(o=>[c.title,c.reads,o.text,n.outcomes[o.outcome],o.outcome==="fails"?n.grounds[o.against??"established"]:"",n.origins[o.written?"written":"computed"]]))),r}static table(t,n){const a=s=>/[",\r\n]/.test(s)?`"${s.replace(/"/g,'""')}"`:s;return[t,...n].map(s=>s.map(a).join(",")).join(`\r
1
+ import{m as W,n as Z,o as Y,B as H,p as K,W as Q,i as P,_ as B,q as J,S as C,t as F}from"./rr0-sighting.mjs";class A{static of(t,n,a,s,i,e=new Date){const r=t.events??[],c=f=>f.url?new URL(f.url,n).href:void 0,o=r.filter(f=>f.eventType==="sighting"&&c(f)),u=o.filter(f=>f.interpretationOf===void 0),p=u.map(f=>A.witnessOf(f,c(f),a.get(c(f)),s)),l=f=>{const w=[f.interpretationOf].flat().filter(b=>typeof b=="string");return u.find(b=>b.id!==void 0&&w.includes(b.id))??u.find(b=>w.includes(a.get(c(b))?.id??""))},m=o.filter(f=>f.interpretationOf!==void 0).map(f=>{const w=l(f),b=w?p[u.indexOf(w)]:void 0;return A.readingOf(f,c(f),a.get(c(f)),b,w?a.get(c(w)):void 0,s,i)}),d=r.filter(f=>f.eventType==="interview").map(f=>{const w=u.find(b=>b.id!==void 0&&[f.interviewOf].flat().includes(b.id));return{title:s.read(f.title)??f.id??"",...w?{witness:p[u.indexOf(w)].title}:{},...f.time?{time:f.time}:{},by:A.names(f.by,s),...f.medium?{medium:f.medium}:{}}});A.placeOnMap(p,m);const g=s.read(t.summary);return{generatedAt:e.toISOString(),case:{...t.id?{id:t.id}:{},...t.title?{title:t.title}:{},...t.time?{time:t.time}:{},url:n,...g?{summary:g}:{}},witnesses:p,readings:m,interviews:d}}static witnessOf(t,n,a,s){const i=s.read(t.title)??s.read(a?.observer?.title)??t.id??n,e={...t.id?{id:t.id}:{},title:i,url:n,...t.time?{time:t.time}:{},indications:[],values:[],sources:[],moments:[]};if(!a)return e;const{recording:r,provenance:c}=W.strip(a),o=s.read(r.description);o&&(e.description=o);const u=r.place?.name;u&&(e.place=u),!e.time&&r.time&&(e.time=r.time),typeof r.durationSeconds=="number"&&(e.durationSeconds=r.durationSeconds),r.instrument&&(e.instrument=r.instrument),e.sources=(r.sources??[]).map(b=>{const v=b,y=s.read(v.title);return{...y?{title:y}:{},...v.authors?.length?{authors:v.authors}:{},...v.publication?.publisher?{publisher:v.publication.publisher}:{},...v.publication?.time?{time:v.publication.time}:{},...v.url?{url:v.url}:{},...v.index?{index:v.index}:{}}}),e.moments=[...r.milestones??[]].sort((b,v)=>b.t-v.t).map(b=>{const v=s.read(b.note);return{t:b.t,label:s.read(b.label)??"",...v?{note:v}:{}}});const p=r.observerTrack?.keyframes?.[0]?.pose,l=r.place?.locations?.[0],m=p?.lat??l?.lat,d=p?.lng??l?.lng;typeof m=="number"&&typeof d=="number"&&Object.assign(e,{lat:m,lng:d}),e.values=A.valuesOf(c,r,()=>!0,s);const g=Q.MODELS[0],f=r.account?.conditions,w=new Map;for(const b of r.timeline?.keyframes??[])for(const v of b.shapes){const y=s.read(v.shape.title);y&&!w.has(v.sourceId)&&w.set(v.sourceId,y)}return e.phenomena=Object.fromEntries(w),(r.timeline?.keyframes??[]).forEach((b,v)=>b.shapes.forEach((y,h)=>{const M=`timeline.keyframes.${v}.shapes.${h}.shape`,E=Z.traced(c,`${M}.aim`),O=Z.traced(c,`${M}.angular`);if(!E&&!O)return;const $=y.shape,x=c.at(`${M}.aim`)??c.at(`${M}.angular`),I={t:b.t,sourceId:y.sourceId,directionSaid:E,sizeSaid:O,...w.has(y.sourceId)?{phenomenon:w.get(y.sourceId)}:{},...$.aim?{aim:{azimuthDeg:$.aim.azimuthDeg,altitudeDeg:$.aim.altitudeDeg}}:{},...$.angular?{angular:$.angular}:{},...x?{basis:x.basis}:{},...x?.rationale?{rationale:s.read(x.rationale)??""}:{},...x?.source?{source:x.source}:{}};if(E&&$.aim){const L=(G,j,R)=>{const V=c.at(`${M}.aim.${R}`)??c.at(`${M}.aim`),q=g.law({kind:G,value:j,basis:V?.basis,how:V?.how},f);return[q.low??j,q.high??j]};I.uncertainty={azimuthDeg:L("heading",$.aim.azimuthDeg,"azimuthDeg"),altitudeDeg:L("elevation",$.aim.altitudeDeg,"altitudeDeg")}}e.indications.push(I)})),e}static readingOf(t,n,a,s,i,e,r){const c={...t.id?{id:t.id}:{},title:e.read(t.title)??e.read(a?.interpretation?.title)??n,url:n,reads:s?.title??"",by:A.names(t.by,e),...t.time?{time:t.time}:{},supposed:[],findings:[],comparisons:[],paths:[]};if(!a)return c;const{recording:o,provenance:u}=W.strip(a),p=e.read(o.description)??e.read(o.summary);p&&(c.description=p),c.supposed=A.valuesOf(u,o,(d,g)=>d.startsWith("interpretation")&&(g==="assumed"||g==="fitted"),e);const l=d=>typeof d=="string"?d:e.read(d)??"";if(c.findings=(o.interpretation?.findings??[]).map(d=>({text:l(d.text),outcome:d.outcome,...d.against?{against:d.against}:{},written:!0})),!i)return c;r&&c.findings.push(...r.findingsOf(i,a).map(d=>({text:l(d.text),outcome:d.outcome,...d.against?{against:d.against}:{},written:!1})));const m=o.interpretation?.bodies??[];if(m.length>0)try{const d=Z.forAccount(i);c.sensitivity=d.of(m,u),c.comparisons=d.comparisons(m),c.paths=A.pathsOf(m,i,c.comparisons.map(g=>g.t))}catch{}return c}static pathsOf(t,n,a){const s=Y(n),i={heightAt:()=>0},e=r=>H.eyeOf(s,r,i);return t.filter(r=>(r.explains?.length??0)>0).map(r=>{const c=new H(r,i,e),u=[...new Set([...r.track.map(p=>p.t),...a])].sort((p,l)=>p-l).map(p=>({t:p,state:c.at(p)})).filter(p=>p.state!==void 0).map(({t:p,state:l})=>({t:p,eastM:l.eastM,northM:l.northM}));return{bodyId:r.id,points:u}}).filter(r=>r.points.length>0)}static placeOnMap(t,n){const a=t.find(s=>s.lat!==void 0&&s.lng!==void 0);if(a){for(const s of t){if(s.lat===void 0||s.lng===void 0)continue;const i=K(s.lat,s.lng,a.lat,a.lng);s.at={eastM:i.x,northM:-i.z}}for(const s of n){const i=t.find(e=>e.title===s.reads)?.at;if(!i){s.paths=[];continue}for(const e of s.paths)for(const r of e.points)r.eastM+=i.eastM,r.northM+=i.northM}}}static valuesOf(t,n,a,s){return t.paths().flatMap(i=>{const e=t.at(i);return a(i,e.basis)?[{path:i,value:i.split(".").reduce((r,c)=>r?.[c],n),basis:e.basis,...e.rationale?{rationale:s.read(e.rationale)??""}:{},...e.source?{source:e.source}:{}}]:[]})}static names(t,n){const a=s=>s.replace(/([a-z])([A-Z])/g,"$1 $2");return(t??[]).map(s=>{if("people"in s){const[e,...r]=a(s.people).split(" ");return[...r,e].join(" ")}if("org"in s)return a(s.org);const i=s;return n.read(i.title)??i.id??""}).filter(s=>s!=="")}}class X{constructor(t,n){this.texts=t,this.language=n,this.decimal=new Intl.NumberFormat(n,{maximumFractionDigits:1}),this.signed=new Intl.NumberFormat(n,{maximumFractionDigits:2,signDisplay:"exceptZero"})}decimal;signed;number(t){return t===void 0||!Number.isFinite(t)?"":this.decimal.format(t)}degrees(t){return t===void 0?"":`${this.number(t)}°`}azimuth(t){return t===void 0?"":this.degrees((t%360+360)%360)}instant(t){return`${this.number(t/1e3)} s`}amount(t,n){switch(t){case"azimuth":case"altitude":return`${this.signed.format(n)}°`;case"time":return`${this.signed.format(n/1e3)} s`;default:return`×${new Intl.NumberFormat(this.language,{maximumFractionDigits:2}).format(n)}`}}rests(t){const n=t.source;return[n?[n.said?`interview ${n.said.interview??""} #${n.said.segment}`.replace(" "," "):void 0,typeof n.document=="string"?n.document:void 0,n.at,n.picture,n.tool,n.url].filter(Boolean).join(", "):"",t.rationale].filter(s=>s&&s!=="").join(" : ")}value(t){const n=t.value;return typeof n=="number"?this.number(n):typeof n=="string"?n:Array.isArray(n)?`[${n.length}]`:n===void 0?"":JSON.stringify(n)}robustness(t){const n=this.texts.robustness;return!t||t.compared===0?{kind:"nothing",text:n.nothing}:Z.measurable(t)?t.sufficient===!0?{kind:"sufficient",text:n.sufficient}:t.sufficient===!1?{kind:"fine-tuned",text:n.fineTuned.replace("{knob}",this.texts.knobs[t.margins[0].knob])}:{kind:"unjudged",text:n.unjudged}:{kind:"too-few",text:n.tooFew}}reproduced(t){return t&&t.compared>0?`${Math.round(t.agreement*t.compared)} / ${t.compared}`:""}ends(t){const n=(a,s)=>`${s?"≥ ":""}${this.amount(t.knob,a)}`;return{from:n(t.lower,t.lowerReached),to:n(t.upper,t.upperReached)}}fill(t,n){return t.replace(/\{(\w+)\}/g,(a,s)=>s in n?n[s]:a)}}class T{static FORMAT="ufoathome-case-report";static VERSION=1;static json(t,n){return JSON.stringify({format:T.FORMAT,version:T.VERSION,generator:`UFO@home ${n}`,...t},null,2)}static csv(t,n,a){const s=new X(n,a),i=n.columns,e=c=>c===void 0||!Number.isFinite(c)?"":String(Math.round(c*1e3)/1e3),r={};return r["indications.csv"]=T.table([i.witness,`${i.instant} (s)`,i.phenomenon,`${i.azimuth} (°)`,`${i.altitude} (°)`,`${i.azimuth} min`,`${i.azimuth} max`,`${i.altitude} min`,`${i.altitude} max`,`${i.size} (°)`,i.basis,i.rests],t.witnesses.flatMap(c=>c.indications.map(o=>[c.title,e(o.t/1e3),o.phenomenon??o.sourceId,e(o.aim?.azimuthDeg),e(o.aim?.altitudeDeg),e(o.uncertainty?.azimuthDeg[0]),e(o.uncertainty?.azimuthDeg[1]),e(o.uncertainty?.altitudeDeg[0]),e(o.uncertainty?.altitudeDeg[1]),o.sizeSaid?e(o.angular?.widthDeg):"",o.basis?n.bases[o.basis]:"",s.rests(o)]))),r["values.csv"]=T.table([i.witness,i.reading,i.path,i.value,i.basis,i.rests],[...t.witnesses.flatMap(c=>c.values.map(o=>[c.title,"",o.path,s.value(o),n.bases[o.basis],s.rests(o)])),...t.readings.flatMap(c=>c.supposed.map(o=>[c.reads,c.title,o.path,s.value(o),n.bases[o.basis],s.rests(o)]))]),r["readings.csv"]=T.table([i.reading,i.reads,i.by,i.time,i.reproduced,i.compared,`${i.gap} (°)`,i.robustness,i.supposedCount],t.readings.map(c=>[c.title,c.reads,c.by.join(", "),c.time??"",c.sensitivity&&c.sensitivity.compared>0?String(Math.round(c.sensitivity.agreement*c.sensitivity.compared)):"",c.sensitivity&&c.sensitivity.compared>0?String(c.sensitivity.compared):"",e(c.sensitivity?.medianSeparationDeg),s.robustness(c.sensitivity).text,String(c.supposed.length)])),r["margins.csv"]=T.table([i.reading,i.reads,i.knob,i.from,i.to,`${i.reference} min`,`${i.reference} max`,i.covered],t.readings.flatMap(c=>(c.sensitivity?.margins??[]).map(o=>[c.title,c.reads,n.knobs[o.knob],e(o.lower),e(o.upper),e(o.reference?.lower),e(o.reference?.upper),o.coverage===void 0?"":e(o.coverage)]))),r["comparisons.csv"]=T.table([i.reading,i.reads,`${i.instant} (s)`,i.phenomenon,`${i.said} ${i.azimuth}`,`${i.said} ${i.altitude}`,`${i.read} ${i.azimuth}`,`${i.read} ${i.altitude}`,`${i.separation} (°)`,i.agrees],t.readings.flatMap(c=>c.comparisons.map(o=>[c.title,c.reads,e(o.t/1e3),t.witnesses.find(u=>u.title===c.reads)?.phenomena?.[o.sourceId]??o.sourceId,e(o.said?.azimuthDeg),e(o.said?.altitudeDeg),e(o.predicted.azimuthDeg),e(o.predicted.altitudeDeg),e(o.separationDeg),o.agrees?n.yes:n.no]))),r["findings.csv"]=T.table([i.reading,i.reads,i.finding,i.outcome,i.against,i.origin],t.readings.flatMap(c=>c.findings.map(o=>[c.title,c.reads,o.text,n.outcomes[o.outcome],o.outcome==="fails"?n.grounds[o.against??"established"]:"",n.origins[o.written?"written":"computed"]]))),r}static table(t,n){const a=s=>/[",\r\n]/.test(s)?`"${s.replace(/"/g,'""')}"`:s;return[t,...n].map(s=>s.map(a).join(",")).join(`\r
2
2
  `)+`\r
3
- `}}class D{static COLOURS=["#c2410c","#1d4ed8","#15803d","#7e22ce","#b91c1c","#0f766e"];static WIDTH=640;static HEIGHT=320;static MARGIN={left:44,right:12,top:12,bottom:34};static svg(t,n,a){const s=t.indications.filter(h=>h.directionSaid&&h.aim);if(s.length===0)return;const i=D.circularMean(s.map(h=>h.aim.azimuthDeg)),e=h=>i+((h-i)%360+540)%360-180,r=[];for(const h of s){const{azimuthDeg:M,altitudeDeg:E}=h.uncertainty??{azimuthDeg:[h.aim.azimuthDeg,h.aim.azimuthDeg],altitudeDeg:[h.aim.altitudeDeg,h.aim.altitudeDeg]};r.push({x:e(h.aim.azimuthDeg),y:h.aim.altitudeDeg}),r.push({x:e(h.aim.azimuthDeg)+(M[0]-h.aim.azimuthDeg),y:E[0]}),r.push({x:e(h.aim.azimuthDeg)+(M[1]-h.aim.azimuthDeg),y:E[1]})}for(const h of n)for(const M of h.comparisons)r.push({x:e(M.predicted.azimuthDeg),y:M.predicted.altitudeDeg});const c=r.map(h=>h.x),o=r.map(h=>h.y),[u,p]=D.padded(Math.min(...c),Math.max(...c),10),[l,m]=D.padded(Math.max(-10,Math.min(...o)),Math.min(90,Math.max(...o)),5),d=D.MARGIN,g=D.WIDTH-d.left-d.right,f=D.HEIGHT-d.top-d.bottom,w=h=>d.left+(h-u)/(p-u)*g,b=h=>d.top+(1-(h-l)/(m-l))*f,v=h=>Math.round(h*10)/10,y=[];for(const h of D.ticks(u,p))y.push(`<line x1="${v(w(h))}" y1="${d.top}" x2="${v(w(h))}" y2="${d.top+f}" class="grid"/>`),y.push(`<text x="${v(w(h))}" y="${d.top+f+14}" text-anchor="middle" class="tick">${a.number((h%360+360)%360)}°</text>`);for(const h of D.ticks(l,m))y.push(`<line x1="${d.left}" y1="${v(b(h))}" x2="${d.left+g}" y2="${v(b(h))}" class="${h===0?"horizon":"grid"}"/>`),y.push(`<text x="${d.left-6}" y="${v(b(h))+4}" text-anchor="end" class="tick">${a.number(h)}°</text>`);y.push(`<text x="${d.left+g/2}" y="${D.HEIGHT-4}" text-anchor="middle" class="axis">${a.texts.azimuth}</text>`),y.push(`<text x="12" y="${d.top+f/2}" text-anchor="middle" class="axis" transform="rotate(-90 12 ${d.top+f/2})">${a.texts.altitude}</text>`);for(const h of s){const M=h.uncertainty;if(!M)continue;const E=e(h.aim.azimuthDeg),O=w(E+M.azimuthDeg[0]-h.aim.azimuthDeg),$=w(E+M.azimuthDeg[1]-h.aim.azimuthDeg);y.push(`<rect x="${v(Math.min(O,$))}" y="${v(b(M.altitudeDeg[1]))}" width="${v(Math.abs($-O))}" height="${v(Math.max(1,b(M.altitudeDeg[0])-b(M.altitudeDeg[1])))}" class="uncertainty"/>`)}n.forEach((h,M)=>{const E=D.COLOURS[M%D.COLOURS.length];for(const O of h.comparisons){const $=w(e(O.predicted.azimuthDeg)),x=b(O.predicted.altitudeDeg);O.said&&y.push(`<line x1="${v(w(e(O.said.azimuthDeg)))}" y1="${v(b(O.said.altitudeDeg))}" x2="${v($)}" y2="${v(x)}" stroke="${E}" class="gap"/>`),y.push(D.mark(M,$,x,E,O.agrees))}});for(const h of s)y.push(`<circle cx="${v(w(e(h.aim.azimuthDeg)))}" cy="${v(b(h.aim.altitudeDeg))}" r="4" class="said"><title>${a.instant(h.t)}</title></circle>`);return`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 ${D.WIDTH} ${D.HEIGHT}" role="img" class="sky">${y.join("")}</svg>`}static mark(t,n,a,s,i){const r=o=>Math.round(o*10)/10,c=i?s:"none";switch(t%3){case 0:return`<path d="M${r(n-5)} ${r(a-5)}L${r(n+5)} ${r(a+5)}M${r(n-5)} ${r(a+5)}L${r(n+5)} ${r(a-5)}" stroke="${s}" stroke-width="${i?2.4:1.2}"/>`;case 1:return`<rect x="${r(n-5)}" y="${r(a-5)}" width="10" height="10" stroke="${s}" fill="${c}" stroke-width="1.4"/>`;default:return`<path d="M${r(n)} ${r(a-5-1)}L${r(n+5+1)} ${r(a+5)}L${r(n-5-1)} ${r(a+5)}Z" stroke="${s}" fill="${c}" stroke-width="1.4"/>`}}static legendMark(t){const n=D.COLOURS[t%D.COLOURS.length];return`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 14 14" width="14" height="14" aria-hidden="true">${D.mark(t,7,7,n,!0)}</svg>`}static circularMean(t){const n=Math.PI/180,a=t.reduce((i,e)=>i+Math.cos(e*n),0),s=t.reduce((i,e)=>i+Math.sin(e*n),0);return Math.atan2(s,a)/n}static padded(t,n,a){const s=Math.max(n-t,a),i=(t+n)/2;return[i-s/2-s*.08,i+s/2+s*.08]}static ticks(t,n){const a=n-t,s=[1,2,5,10,15,20,30,45,90].find(e=>a/e<=10)??90,i=[];for(let e=Math.ceil(t/s)*s;e<=n;e+=s)i.push(e);return i}}class k{static SIZE=520;static count=0;static MARGIN=28;static svg(t,n,a){const s=t.filter($=>$.at);if(s.length===0)return;const i=n.filter($=>$.paths.length>0),e=[...s.map($=>$.at),...i.flatMap($=>$.paths.flatMap(x=>x.points))],r=e.map($=>$.eastM),c=e.map($=>$.northM),o=Math.max(200,Math.max(...r)-Math.min(...r),Math.max(...c)-Math.min(...c))*1.25,u=(Math.max(...r)+Math.min(...r))/2,p=(Math.max(...c)+Math.min(...c))/2,l=k.SIZE-2*k.MARGIN,m=$=>k.MARGIN+($-u+o/2)/o*l,d=$=>k.MARGIN+(1-($-p+o/2)/o)*l,g=$=>Math.round($*10)/10,f=o*.75,w=Math.PI/180,b=($,x)=>({eastM:$.eastM+f*Math.sin(x*w),northM:$.northM+f*Math.cos(x*w)}),v=`plan-clip-${k.count++}`,y=[`<defs><clipPath id="${v}"><rect x="${k.MARGIN}" y="${k.MARGIN}" width="${l}" height="${l}"/></clipPath></defs>`,`<rect x="${k.MARGIN}" y="${k.MARGIN}" width="${l}" height="${l}" class="frame"/>`,`<g clip-path="url(#${v})">`];for(const $ of s)for(const x of $.indications){if(!x.directionSaid||!x.aim)continue;const I=$.at,L=x.uncertainty?.azimuthDeg;if(L&&L[1]-L[0]<180){const A=b(I,L[0]),R=b(I,L[1]);y.push(`<path d="M${g(m(I.eastM))} ${g(d(I.northM))}L${g(m(A.eastM))} ${g(d(A.northM))}L${g(m(R.eastM))} ${g(d(R.northM))}Z" class="fan"/>`)}const G=b(I,x.aim.azimuthDeg);y.push(`<line x1="${g(m(I.eastM))}" y1="${g(d(I.northM))}" x2="${g(m(G.eastM))}" y2="${g(d(G.northM))}" class="sight"><title>${a.instant(x.t)}</title></line>`)}i.forEach($=>{const x=D.COLOURS[n.indexOf($)%D.COLOURS.length];for(const I of $.paths){const L=I.points.map((A,R)=>`${R===0?"M":"L"}${g(m(A.eastM))} ${g(d(A.northM))}`).join("");y.push(`<path d="${L}" stroke="${x}" class="track"/>`);const G=I.points[I.points.length-1];y.push(`<circle cx="${g(m(G.eastM))}" cy="${g(d(G.northM))}" r="2.5" fill="${x}"/>`)}}),y.push("</g>");const h=[];for(const $ of s){const x=h.find(I=>Math.hypot(I.at.eastM-$.at.eastM,I.at.northM-$.at.northM)<o/100);x?x.names.push($.title):h.push({at:$.at,names:[$.title]})}for(const $ of h)y.push(`<circle cx="${g(m($.at.eastM))}" cy="${g(d($.at.northM))}" r="4.5" class="witness"/>`),y.push(`<text x="${g(m($.at.eastM)+7)}" y="${g(d($.at.northM)-7)}" class="name">${k.escape($.names.join(", "))}</text>`);const M=k.round(o/5),E=M/o*l,O=k.SIZE-10;return y.push(`<line x1="${k.MARGIN}" y1="${O}" x2="${g(k.MARGIN+E)}" y2="${O}" class="scale"/>`),y.push(`<text x="${g(k.MARGIN+E+6)}" y="${O+4}" class="tick">${k.escape(a.fill(a.texts.scale,{metres:a.number(M)}))}</text>`),y.push(`<path d="M${k.SIZE-18} 34L${k.SIZE-12} 18L${k.SIZE-6} 34Z" class="north"/><text x="${k.SIZE-12}" y="14" text-anchor="middle" class="tick">N</text>`),`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 ${k.SIZE} ${k.SIZE}" role="img" class="plan">${y.join("")}</svg>`}static round(t){const n=10**Math.floor(Math.log10(t));return[5,2,1].map(a=>a*n).find(a=>a<=t)??n}static escape(t){return t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}}class S{static WIDTH=640;static HEIGHT=74;static LEFT=16;static RIGHT=16;static svg(t,n){const a=t.indications.map(l=>l.t),s=t.moments;if(a.length===0&&s.length===0)return;const i=Math.max(1e3,(t.durationSeconds??0)*1e3,...a,...s.map(l=>l.t)),e=S.WIDTH-S.LEFT-S.RIGHT,r=l=>S.LEFT+l/i*e,c=l=>Math.round(l*10)/10,o=40,u=[`<line x1="${S.LEFT}" y1="${o}" x2="${S.LEFT+e}" y2="${o}" class="axis-line"/>`],p=[.5,1,2,5,10,15,30,60,120,300,600].find(l=>i/1e3/l<=10)??600;for(let l=0;l*1e3<=i;l+=p)u.push(`<line x1="${c(r(l*1e3))}" y1="${o-3}" x2="${c(r(l*1e3))}" y2="${o+3}" class="axis-line"/>`),u.push(`<text x="${c(r(l*1e3))}" y="${o+16}" text-anchor="middle" class="tick">${n.instant(l*1e3)}</text>`);for(const l of s)u.push(`<line x1="${c(r(l.t))}" y1="8" x2="${c(r(l.t))}" y2="${o}" class="moment"/>`),u.push(`<text x="${c(r(l.t)+3)}" y="16" class="moment-label">${S.escape(l.label)}${l.note?`<title>${S.escape(l.note)}</title>`:""}</text>`);for(const l of a)u.push(`<circle cx="${c(r(l))}" cy="${o}" r="3.5" class="said"><title>${n.instant(l)}</title></circle>`);return`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 ${S.WIDTH} ${S.HEIGHT}" role="img" class="timeline">${u.join("")}</svg>`}static escape(t){return t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}}class z{static CSS=`
3
+ `}}class D{static COLOURS=["#c2410c","#1d4ed8","#15803d","#7e22ce","#b91c1c","#0f766e"];static WIDTH=640;static HEIGHT=320;static MARGIN={left:44,right:12,top:12,bottom:34};static svg(t,n,a){const s=t.indications.filter(h=>h.directionSaid&&h.aim);if(s.length===0)return;const i=D.circularMean(s.map(h=>h.aim.azimuthDeg)),e=h=>i+((h-i)%360+540)%360-180,r=[];for(const h of s){const{azimuthDeg:M,altitudeDeg:E}=h.uncertainty??{azimuthDeg:[h.aim.azimuthDeg,h.aim.azimuthDeg],altitudeDeg:[h.aim.altitudeDeg,h.aim.altitudeDeg]};r.push({x:e(h.aim.azimuthDeg),y:h.aim.altitudeDeg}),r.push({x:e(h.aim.azimuthDeg)+(M[0]-h.aim.azimuthDeg),y:E[0]}),r.push({x:e(h.aim.azimuthDeg)+(M[1]-h.aim.azimuthDeg),y:E[1]})}for(const h of n)for(const M of h.comparisons)r.push({x:e(M.predicted.azimuthDeg),y:M.predicted.altitudeDeg});const c=r.map(h=>h.x),o=r.map(h=>h.y),[u,p]=D.padded(Math.min(...c),Math.max(...c),10),[l,m]=D.padded(Math.max(-10,Math.min(...o)),Math.min(90,Math.max(...o)),5),d=D.MARGIN,g=D.WIDTH-d.left-d.right,f=D.HEIGHT-d.top-d.bottom,w=h=>d.left+(h-u)/(p-u)*g,b=h=>d.top+(1-(h-l)/(m-l))*f,v=h=>Math.round(h*10)/10,y=[];for(const h of D.ticks(u,p))y.push(`<line x1="${v(w(h))}" y1="${d.top}" x2="${v(w(h))}" y2="${d.top+f}" class="grid"/>`),y.push(`<text x="${v(w(h))}" y="${d.top+f+14}" text-anchor="middle" class="tick">${a.number((h%360+360)%360)}°</text>`);for(const h of D.ticks(l,m))y.push(`<line x1="${d.left}" y1="${v(b(h))}" x2="${d.left+g}" y2="${v(b(h))}" class="${h===0?"horizon":"grid"}"/>`),y.push(`<text x="${d.left-6}" y="${v(b(h))+4}" text-anchor="end" class="tick">${a.number(h)}°</text>`);y.push(`<text x="${d.left+g/2}" y="${D.HEIGHT-4}" text-anchor="middle" class="axis">${a.texts.azimuth}</text>`),y.push(`<text x="12" y="${d.top+f/2}" text-anchor="middle" class="axis" transform="rotate(-90 12 ${d.top+f/2})">${a.texts.altitude}</text>`);for(const h of s){const M=h.uncertainty;if(!M)continue;const E=e(h.aim.azimuthDeg),O=w(E+M.azimuthDeg[0]-h.aim.azimuthDeg),$=w(E+M.azimuthDeg[1]-h.aim.azimuthDeg);y.push(`<rect x="${v(Math.min(O,$))}" y="${v(b(M.altitudeDeg[1]))}" width="${v(Math.abs($-O))}" height="${v(Math.max(1,b(M.altitudeDeg[0])-b(M.altitudeDeg[1])))}" class="uncertainty"/>`)}n.forEach((h,M)=>{const E=D.COLOURS[M%D.COLOURS.length];for(const O of h.comparisons){const $=w(e(O.predicted.azimuthDeg)),x=b(O.predicted.altitudeDeg);O.said&&y.push(`<line x1="${v(w(e(O.said.azimuthDeg)))}" y1="${v(b(O.said.altitudeDeg))}" x2="${v($)}" y2="${v(x)}" stroke="${E}" class="gap"/>`),y.push(D.mark(M,$,x,E,O.agrees))}});for(const h of s)y.push(`<circle cx="${v(w(e(h.aim.azimuthDeg)))}" cy="${v(b(h.aim.altitudeDeg))}" r="4" class="said"><title>${a.instant(h.t)}</title></circle>`);return`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 ${D.WIDTH} ${D.HEIGHT}" role="img" class="sky">${y.join("")}</svg>`}static mark(t,n,a,s,i){const r=o=>Math.round(o*10)/10,c=i?s:"none";switch(t%3){case 0:return`<path d="M${r(n-5)} ${r(a-5)}L${r(n+5)} ${r(a+5)}M${r(n-5)} ${r(a+5)}L${r(n+5)} ${r(a-5)}" stroke="${s}" stroke-width="${i?2.4:1.2}"/>`;case 1:return`<rect x="${r(n-5)}" y="${r(a-5)}" width="10" height="10" stroke="${s}" fill="${c}" stroke-width="1.4"/>`;default:return`<path d="M${r(n)} ${r(a-5-1)}L${r(n+5+1)} ${r(a+5)}L${r(n-5-1)} ${r(a+5)}Z" stroke="${s}" fill="${c}" stroke-width="1.4"/>`}}static legendMark(t){const n=D.COLOURS[t%D.COLOURS.length];return`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 14 14" width="14" height="14" aria-hidden="true">${D.mark(t,7,7,n,!0)}</svg>`}static circularMean(t){const n=Math.PI/180,a=t.reduce((i,e)=>i+Math.cos(e*n),0),s=t.reduce((i,e)=>i+Math.sin(e*n),0);return Math.atan2(s,a)/n}static padded(t,n,a){const s=Math.max(n-t,a),i=(t+n)/2;return[i-s/2-s*.08,i+s/2+s*.08]}static ticks(t,n){const a=n-t,s=[1,2,5,10,15,20,30,45,90].find(e=>a/e<=10)??90,i=[];for(let e=Math.ceil(t/s)*s;e<=n;e+=s)i.push(e);return i}}class k{static SIZE=520;static count=0;static MARGIN=28;static svg(t,n,a){const s=t.filter($=>$.at);if(s.length===0)return;const i=n.filter($=>$.paths.length>0),e=[...s.map($=>$.at),...i.flatMap($=>$.paths.flatMap(x=>x.points))],r=e.map($=>$.eastM),c=e.map($=>$.northM),o=Math.max(200,Math.max(...r)-Math.min(...r),Math.max(...c)-Math.min(...c))*1.25,u=(Math.max(...r)+Math.min(...r))/2,p=(Math.max(...c)+Math.min(...c))/2,l=k.SIZE-2*k.MARGIN,m=$=>k.MARGIN+($-u+o/2)/o*l,d=$=>k.MARGIN+(1-($-p+o/2)/o)*l,g=$=>Math.round($*10)/10,f=o*.75,w=Math.PI/180,b=($,x)=>({eastM:$.eastM+f*Math.sin(x*w),northM:$.northM+f*Math.cos(x*w)}),v=`plan-clip-${k.count++}`,y=[`<defs><clipPath id="${v}"><rect x="${k.MARGIN}" y="${k.MARGIN}" width="${l}" height="${l}"/></clipPath></defs>`,`<rect x="${k.MARGIN}" y="${k.MARGIN}" width="${l}" height="${l}" class="frame"/>`,`<g clip-path="url(#${v})">`];for(const $ of s)for(const x of $.indications){if(!x.directionSaid||!x.aim)continue;const I=$.at,L=x.uncertainty?.azimuthDeg;if(L&&L[1]-L[0]<180){const j=b(I,L[0]),R=b(I,L[1]);y.push(`<path d="M${g(m(I.eastM))} ${g(d(I.northM))}L${g(m(j.eastM))} ${g(d(j.northM))}L${g(m(R.eastM))} ${g(d(R.northM))}Z" class="fan"/>`)}const G=b(I,x.aim.azimuthDeg);y.push(`<line x1="${g(m(I.eastM))}" y1="${g(d(I.northM))}" x2="${g(m(G.eastM))}" y2="${g(d(G.northM))}" class="sight"><title>${a.instant(x.t)}</title></line>`)}i.forEach($=>{const x=D.COLOURS[n.indexOf($)%D.COLOURS.length];for(const I of $.paths){const L=I.points.map((j,R)=>`${R===0?"M":"L"}${g(m(j.eastM))} ${g(d(j.northM))}`).join("");y.push(`<path d="${L}" stroke="${x}" class="track"/>`);const G=I.points[I.points.length-1];y.push(`<circle cx="${g(m(G.eastM))}" cy="${g(d(G.northM))}" r="2.5" fill="${x}"/>`)}}),y.push("</g>");const h=[];for(const $ of s){const x=h.find(I=>Math.hypot(I.at.eastM-$.at.eastM,I.at.northM-$.at.northM)<o/100);x?x.names.push($.title):h.push({at:$.at,names:[$.title]})}for(const $ of h)y.push(`<circle cx="${g(m($.at.eastM))}" cy="${g(d($.at.northM))}" r="4.5" class="witness"/>`),y.push(`<text x="${g(m($.at.eastM)+7)}" y="${g(d($.at.northM)-7)}" class="name">${k.escape($.names.join(", "))}</text>`);const M=k.round(o/5),E=M/o*l,O=k.SIZE-10;return y.push(`<line x1="${k.MARGIN}" y1="${O}" x2="${g(k.MARGIN+E)}" y2="${O}" class="scale"/>`),y.push(`<text x="${g(k.MARGIN+E+6)}" y="${O+4}" class="tick">${k.escape(a.fill(a.texts.scale,{metres:a.number(M)}))}</text>`),y.push(`<path d="M${k.SIZE-18} 34L${k.SIZE-12} 18L${k.SIZE-6} 34Z" class="north"/><text x="${k.SIZE-12}" y="14" text-anchor="middle" class="tick">N</text>`),`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 ${k.SIZE} ${k.SIZE}" role="img" class="plan">${y.join("")}</svg>`}static round(t){const n=10**Math.floor(Math.log10(t));return[5,2,1].map(a=>a*n).find(a=>a<=t)??n}static escape(t){return t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}}class S{static WIDTH=640;static HEIGHT=74;static LEFT=16;static RIGHT=16;static svg(t,n){const a=t.indications.map(l=>l.t),s=t.moments;if(a.length===0&&s.length===0)return;const i=Math.max(1e3,(t.durationSeconds??0)*1e3,...a,...s.map(l=>l.t)),e=S.WIDTH-S.LEFT-S.RIGHT,r=l=>S.LEFT+l/i*e,c=l=>Math.round(l*10)/10,o=40,u=[`<line x1="${S.LEFT}" y1="${o}" x2="${S.LEFT+e}" y2="${o}" class="axis-line"/>`],p=[.5,1,2,5,10,15,30,60,120,300,600].find(l=>i/1e3/l<=10)??600;for(let l=0;l*1e3<=i;l+=p)u.push(`<line x1="${c(r(l*1e3))}" y1="${o-3}" x2="${c(r(l*1e3))}" y2="${o+3}" class="axis-line"/>`),u.push(`<text x="${c(r(l*1e3))}" y="${o+16}" text-anchor="middle" class="tick">${n.instant(l*1e3)}</text>`);for(const l of s)u.push(`<line x1="${c(r(l.t))}" y1="8" x2="${c(r(l.t))}" y2="${o}" class="moment"/>`),u.push(`<text x="${c(r(l.t)+3)}" y="16" class="moment-label">${S.escape(l.label)}${l.note?`<title>${S.escape(l.note)}</title>`:""}</text>`);for(const l of a)u.push(`<circle cx="${c(r(l))}" cy="${o}" r="3.5" class="said"><title>${n.instant(l)}</title></circle>`);return`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 ${S.WIDTH} ${S.HEIGHT}" role="img" class="timeline">${u.join("")}</svg>`}static escape(t){return t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}}class z{static CSS=`
4
4
  :root { color-scheme: light; --ink: #1b1d22; --dim: #5b6070; --line: #d6d9e0; --ok: #15803d; --warn: #b45309; --error: #b91c1c; }
5
5
  * { box-sizing: border-box; }
6
6
  body { margin: 0 auto; max-width: 60rem; padding: 2rem 1rem 4rem; font: 15px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif; color: var(--ink); background: #fff; }
@@ -62,4 +62,4 @@ ${o.join(`
62
62
  `)}
63
63
  </body>
64
64
  </html>
65
- `}static comparedTable(t,n){const a=n.texts.columns,s=z.escape;return z.table([a.reading,a.reads,a.reproduced,a.gap,a.robustness,a.supposedCount],t.readings.map(i=>{const e=n.robustness(i.sensitivity);return[s(i.title),s(i.reads),`<span class="n">${n.reproduced(i.sensitivity)}</span>`,n.degrees(i.sensitivity?.medianSeparationDeg),`<span class="${e.kind}">${s(e.text)}</span>`,String(i.supposed.length)]}),[2,3,5])}static witness(t,n,a){const s=a.texts,i=s.columns,e=z.escape,r=[`<h3>${e(a.fill(s.witnessHeading,{witness:t.title}))}</h3>`],o=[[s.columns.time,t.time??""],[s.place,t.place??""],[s.duration,t.durationSeconds!==void 0?a.instant(t.durationSeconds*1e3):""],[s.instrument,t.instrument??""]].filter(([,m])=>m!=="");o.length&&r.push(`<dl class="facts">${o.map(([m,d])=>`<dt>${e(m)}</dt><dd>${e(d)}</dd>`).join("")}</dl>`),t.description&&r.push(`<h4>${e(s.account)}</h4>`,`<blockquote>${e(t.description)}</blockquote>`),t.sources.length&&r.push(`<h4>${e(s.sources)}</h4>`,`<ul class="sources">${t.sources.map(m=>`<li>${[m.authors?.join(", "),m.title?`<em>${e(m.title)}</em>`:"",m.publisher,m.time,m.index].filter(Boolean).map(g=>g.startsWith("<em>")?g:e(g)).join(", ")}${m.url?` <a href="${e(m.url)}">${e(m.url)}</a>`:""}</li>`).join("")}</ul>`);const u=S.svg(t,a);u&&r.push(`<figure>${u}<figcaption>${e(s.timelineCaption)}</figcaption></figure>`),n=n.filter(m=>m.comparisons.length>0);const p=D.svg(t,n,a);if(p){const m=[`<li><svg viewBox="0 0 14 14" width="14" height="14" aria-hidden="true"><circle cx="7" cy="7" r="4" fill="#111827"/></svg>${e(s.saidLegend)}</li>`,...n.map((d,g)=>`<li>${D.legendMark(g)}${e(d.title)}</li>`)];r.push(`<figure>${p}<ul class="legend">${m.join("")}</ul><figcaption>${e(s.figureCaption)}</figcaption></figure>`)}if(t.pictures?.length){const m=t.pictures[0].views.map(d=>d.label);r.push(`<h4>${e(s.pictures)}</h4>`,`<div class="scroll"><table class="pictures"><thead><tr><th scope="col">${e(s.columns.instant)}</th>${m.map(d=>`<th scope="col">${e(d)}</th>`).join("")}</tr></thead><tbody>${t.pictures.map(d=>`<tr><td class="n">${a.instant(d.t)}</td>${d.views.map(g=>`<td>${g.image?`<img src="${g.image}" alt="${e(g.label)}, ${a.instant(d.t)}">`:`<span class="nothing">${e(s.noPicture)}</span>`}</td>`).join("")}</tr>`).join("")}</tbody></table></div>`,`<p class="caption">${e(s.picturesCaption)}</p>`)}r.push(`<h4>${e(s.indications)}</h4>`),t.indications.length===0?r.push(`<p>${e(s.noIndication)}</p>`):r.push(z.table([i.instant,i.phenomenon,i.azimuth,i.altitude,i.uncertainty,i.size,i.basis,i.rests],t.indications.map(m=>{const d=m.uncertainty;return[a.instant(m.t),e(m.phenomenon??m.sourceId),m.directionSaid?a.azimuth(m.aim?.azimuthDeg):"",m.directionSaid?a.degrees(m.aim?.altitudeDeg):"",d?`${a.azimuth(d.azimuthDeg[0])} … ${a.azimuth(d.azimuthDeg[1])} ; ${a.degrees(d.altitudeDeg[0])} … ${a.degrees(d.altitudeDeg[1])}`:"",m.sizeSaid?a.degrees(m.angular?.widthDeg):"",m.basis?e(s.bases[m.basis]):"",e(a.rests(m))]}),[0,2,3,5]));const l=t.values.filter(m=>!/^timeline\.keyframes\.\d+\.shapes\.\d+\.shape\.(aim|angular)/.test(m.path));return l.length>0&&r.push(`<h4>${e(s.values)}</h4>`,z.valuesTable(l,a)),r}static reading(t,n,a){const s=a.texts,i=s.columns,e=z.escape,r=[`<h2>${e(a.fill(s.readingHeading,{title:t.title,witness:t.reads}))}</h2>`],c=[t.by.length?a.fill(s.by,{names:t.by.join(", ")}):"",t.time?a.fill(s.made,{time:t.time}):""].filter(Boolean).join(" ");c&&r.push(`<p class="meta">${e(c)}</p>`),t.description&&r.push(`<blockquote>${e(t.description)}</blockquote>`),r.push(`<h4>${e(s.supposed)}</h4>`,t.supposed.length?z.valuesTable(t.supposed,a):`<p>${e(s.noneSupposed)}</p>`),r.push(`<h4>${e(s.findings)}</h4>`),r.push(t.findings.length?z.table([i.finding,i.outcome,i.against,i.origin],t.findings.map(u=>[e(u.text),`<span class="${u.outcome}">${e(s.outcomes[u.outcome])}</span>`,u.outcome==="fails"?e(s.grounds[u.against??"established"]):"",e(s.origins[u.written?"written":"computed"])])):`<p>${e(s.noFinding)}</p>`);const o=t.sensitivity;if(o){const u=a.robustness(o);if(r.push(`<h4>${e(s.sensitivity)}</h4>`,`<p>${e(i.reproduced)} : ${a.reproduced(o)||"–"} · ${e(i.gap)} : ${a.degrees(o.medianSeparationDeg)||"–"} · <span class="${u.kind}">${e(u.text)}</span></p>`),u.kind!=="too-few"&&u.kind!=="nothing"&&o.margins.length>0&&r.push(z.table([i.knob,i.from,i.to,i.reference,i.covered],o.margins.map(p=>{const l=a.ends(p),m=p.reference?`${a.amount(p.knob,p.reference.lower)} … ${a.amount(p.knob,p.reference.upper)}`:s.noLaw;return[e(s.knobs[p.knob]),l.from,l.to,e(m),p.coverage===void 0?"":`${Math.round(p.coverage*100)} %`]}),[1,2,4])),o.better){const{knob:p,amount:l,agreement:m}=o.better;r.push(`<p class="fine-tuned">${e(a.fill(s.better,{knob:s.knobs[p],amount:a.amount(p,l),agreed:String(Math.round(m*o.compared)),compared:String(o.compared)}))}</p>`)}}return t.comparisons.length>0&&r.push(`<h4>${e(s.comparisons)}</h4>`,z.table([i.instant,i.phenomenon,`${i.said} (${i.azimuth}, ${i.altitude})`,`${i.read} (${i.azimuth}, ${i.altitude})`,i.separation,i.agrees],t.comparisons.map(u=>[a.instant(u.t),e(n?.phenomena?.[u.sourceId]??u.sourceId),u.said?`${a.azimuth(u.said.azimuthDeg)}, ${a.degrees(u.said.altitudeDeg)}`:"",`${a.azimuth(u.predicted.azimuthDeg)}, ${a.degrees(u.predicted.altitudeDeg)}`,a.degrees(u.separationDeg),`<span class="${u.agrees?"holds":"fails"}">${e(u.agrees?s.yes:s.no)}</span>`]),[0,4])),r}static valuesTable(t,n){const a=n.texts,s=a.columns,i=z.escape;return z.table([s.path,s.value,s.basis,s.rests],t.map(e=>[`<code>${i(e.path)}</code>`,i(n.value(e)),i(a.bases[e.basis]),i(n.rests(e))]))}static table(t,n,a=[]){const s=z.escape,i=`<tr>${t.map(r=>`<th scope="col">${s(r)}</th>`).join("")}</tr>`,e=n.map(r=>`<tr>${r.map((c,o)=>`<td${a.includes(o)?' class="n"':""}>${c}</td>`).join("")}</tr>`);return`<div class="scroll"><table><thead>${i}</thead><tbody>${e.join("")}</tbody></table></div>`}static escape(t){return t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}}const _=P.catalog({en:()=>B(()=>import("./CaseReportTexts_en-DlN7p1pC.js"),[],import.meta.url).then(N=>N.caseReportTexts_en),fr:()=>B(()=>import("./CaseReportTexts_fr-B5nP6RlP.js"),[],import.meta.url).then(N=>N.caseReportTexts_fr),es:()=>B(()=>import("./CaseReportTexts_es-CncAEaey.js"),[],import.meta.url).then(N=>N.caseReportTexts_es),it:()=>B(()=>import("./CaseReportTexts_it-Dc-oPmXB.js"),[],import.meta.url).then(N=>N.caseReportTexts_it)});class U{static async make(t,n,a,s,i=!1,e){const[r,c]=await Promise.all([_.load(a),J.load(a)]),o=j.of(n.caseJson,n.caseUrl,n.recordings,new C([...s]),new F(c));i&&t!=="csv"&&await U.pictures(o,n,r,e);const u=`${n.caseJson.id??"case"}-report`;switch(t){case"html":U.download(new Blob([z.of(o,r,a,"0.190.0")],{type:"text/html"}),`${u}.html`);return;case"print":U.print(z.of(o,r,a,"0.190.0"));return;case"json":U.download(new Blob([T.json(o,"0.190.0")],{type:"application/json"}),`${u}.json`);return;case"csv":{const{zipSync:p,strToU8:l}=await B(async()=>{const{zipSync:d,strToU8:g}=await import("./browser-CltifEM0.js");return{zipSync:d,strToU8:g}},[],import.meta.url),m=Object.fromEntries(Object.entries(T.csv(o,r,a)).map(([d,g])=>[d,l(`\uFEFF${g}`)]));U.download(new Blob([p(m)],{type:"application/zip"}),`${u}-tables.zip`)}}}static PICTURED_INSTANTS=3;static async pictures(t,n,a,s){const{registerScene:i,SCENE_ELEMENT_NAME:e}=await B(async()=>{const{registerScene:p,SCENE_ELEMENT_NAME:l}=await import("./rr0-sighting.mjs").then(m=>m.bV);return{registerScene:p,SCENE_ELEMENT_NAME:l}},[],import.meta.url);i();const r=t.witnesses.map(p=>{const l=p.indications.filter(f=>f.directionSaid).map(f=>f.t),m=l.length<=U.PICTURED_INSTANTS?l:[l[0],l[Math.floor(l.length/2)],l[l.length-1]],d=t.readings.filter(f=>f.reads===p.title&&f.comparisons.length>0),g=[{label:a.accountView,url:p.url,reading:void 0},...d.map(f=>({label:f.title,url:p.url,reading:f.url}))];return{witness:p,instants:[...new Set(m)],recordings:g}}).filter(p=>p.instants.length>0),c=r.reduce((p,l)=>p+l.instants.length*l.recordings.length,0);if(c===0)return;const o=document.createElement(e);o.setAttribute("max-pixel-ratio","1"),o.setAttribute("always-live",""),Object.assign(o.style,{position:"fixed",left:"-10000px",top:"0",width:"640px",height:"360px",visibility:"hidden",pointerEvents:"none"}),document.body.appendChild(o);let u=0;s?.(u,c);try{for(const p of r){const l=p.instants.map(d=>({t:d,views:[]})),m=n.recordings.get(p.witness.url);m&&(o.documentUrl=p.witness.url,o.sightingData=m);for(const d of p.recordings){const g=m,f=d.reading?n.recordings.get(d.reading):void 0;for(const w of l){let b;g&&(!d.reading||f)&&(w===l[0]&&(o.interpretation=U.bodiesOf(f??g,d.reading??p.witness.url)),b=await o.pictureAt(w.t,480).catch(()=>{})),w.views.push({label:d.label,...b?{image:b}:{}}),s?.(++u,c)}}p.witness.pictures=l}}finally{o.remove()}}static bodiesOf(t,n){const a=W.strip(t).recording.interpretation;if(a)return{...a,bodies:a.bodies.map(s=>s.model?.url?{...s,model:{...s.model,url:new URL(s.model.url,n).href}}:s)}}static print(t){const n=document.createElement("iframe");n.setAttribute("aria-hidden","true"),n.style.cssText="position: fixed; right: 0; bottom: 0; width: 0; height: 0; border: 0",n.addEventListener("load",()=>{const a=n.contentWindow;a&&(a.addEventListener("afterprint",()=>n.remove()),a.focus(),a.print(),window.setTimeout(()=>n.remove(),6e4))},{once:!0}),n.srcdoc=t,document.body.append(n)}static download(t,n){const a=URL.createObjectURL(t),s=document.createElement("a");s.href=a,s.download=n,s.click(),window.setTimeout(()=>URL.revokeObjectURL(a),1e3)}}export{U as CaseReportExport};
65
+ `}static comparedTable(t,n){const a=n.texts.columns,s=z.escape;return z.table([a.reading,a.reads,a.reproduced,a.gap,a.robustness,a.supposedCount],t.readings.map(i=>{const e=n.robustness(i.sensitivity);return[s(i.title),s(i.reads),`<span class="n">${n.reproduced(i.sensitivity)}</span>`,n.degrees(i.sensitivity?.medianSeparationDeg),`<span class="${e.kind}">${s(e.text)}</span>`,String(i.supposed.length)]}),[2,3,5])}static witness(t,n,a){const s=a.texts,i=s.columns,e=z.escape,r=[`<h3>${e(a.fill(s.witnessHeading,{witness:t.title}))}</h3>`],o=[[s.columns.time,t.time??""],[s.place,t.place??""],[s.duration,t.durationSeconds!==void 0?a.instant(t.durationSeconds*1e3):""],[s.instrument,t.instrument??""]].filter(([,m])=>m!=="");o.length&&r.push(`<dl class="facts">${o.map(([m,d])=>`<dt>${e(m)}</dt><dd>${e(d)}</dd>`).join("")}</dl>`),t.description&&r.push(`<h4>${e(s.account)}</h4>`,`<blockquote>${e(t.description)}</blockquote>`),t.sources.length&&r.push(`<h4>${e(s.sources)}</h4>`,`<ul class="sources">${t.sources.map(m=>`<li>${[m.authors?.join(", "),m.title?`<em>${e(m.title)}</em>`:"",m.publisher,m.time,m.index].filter(Boolean).map(g=>g.startsWith("<em>")?g:e(g)).join(", ")}${m.url?` <a href="${e(m.url)}">${e(m.url)}</a>`:""}</li>`).join("")}</ul>`);const u=S.svg(t,a);u&&r.push(`<figure>${u}<figcaption>${e(s.timelineCaption)}</figcaption></figure>`),n=n.filter(m=>m.comparisons.length>0);const p=D.svg(t,n,a);if(p){const m=[`<li><svg viewBox="0 0 14 14" width="14" height="14" aria-hidden="true"><circle cx="7" cy="7" r="4" fill="#111827"/></svg>${e(s.saidLegend)}</li>`,...n.map((d,g)=>`<li>${D.legendMark(g)}${e(d.title)}</li>`)];r.push(`<figure>${p}<ul class="legend">${m.join("")}</ul><figcaption>${e(s.figureCaption)}</figcaption></figure>`)}if(t.pictures?.length){const m=t.pictures[0].views.map(d=>d.label);r.push(`<h4>${e(s.pictures)}</h4>`,`<div class="scroll"><table class="pictures"><thead><tr><th scope="col">${e(s.columns.instant)}</th>${m.map(d=>`<th scope="col">${e(d)}</th>`).join("")}</tr></thead><tbody>${t.pictures.map(d=>`<tr><td class="n">${a.instant(d.t)}</td>${d.views.map(g=>`<td>${g.image?`<img src="${g.image}" alt="${e(g.label)}, ${a.instant(d.t)}">`:`<span class="nothing">${e(s.noPicture)}</span>`}</td>`).join("")}</tr>`).join("")}</tbody></table></div>`,`<p class="caption">${e(s.picturesCaption)}</p>`)}r.push(`<h4>${e(s.indications)}</h4>`),t.indications.length===0?r.push(`<p>${e(s.noIndication)}</p>`):r.push(z.table([i.instant,i.phenomenon,i.azimuth,i.altitude,i.uncertainty,i.size,i.basis,i.rests],t.indications.map(m=>{const d=m.uncertainty;return[a.instant(m.t),e(m.phenomenon??m.sourceId),m.directionSaid?a.azimuth(m.aim?.azimuthDeg):"",m.directionSaid?a.degrees(m.aim?.altitudeDeg):"",d?`${a.azimuth(d.azimuthDeg[0])} … ${a.azimuth(d.azimuthDeg[1])} ; ${a.degrees(d.altitudeDeg[0])} … ${a.degrees(d.altitudeDeg[1])}`:"",m.sizeSaid?a.degrees(m.angular?.widthDeg):"",m.basis?e(s.bases[m.basis]):"",e(a.rests(m))]}),[0,2,3,5]));const l=t.values.filter(m=>!/^timeline\.keyframes\.\d+\.shapes\.\d+\.shape\.(aim|angular)/.test(m.path));return l.length>0&&r.push(`<h4>${e(s.values)}</h4>`,z.valuesTable(l,a)),r}static reading(t,n,a){const s=a.texts,i=s.columns,e=z.escape,r=[`<h2>${e(a.fill(s.readingHeading,{title:t.title,witness:t.reads}))}</h2>`],c=[t.by.length?a.fill(s.by,{names:t.by.join(", ")}):"",t.time?a.fill(s.made,{time:t.time}):""].filter(Boolean).join(" ");c&&r.push(`<p class="meta">${e(c)}</p>`),t.description&&r.push(`<blockquote>${e(t.description)}</blockquote>`),r.push(`<h4>${e(s.supposed)}</h4>`,t.supposed.length?z.valuesTable(t.supposed,a):`<p>${e(s.noneSupposed)}</p>`),r.push(`<h4>${e(s.findings)}</h4>`),r.push(t.findings.length?z.table([i.finding,i.outcome,i.against,i.origin],t.findings.map(u=>[e(u.text),`<span class="${u.outcome}">${e(s.outcomes[u.outcome])}</span>`,u.outcome==="fails"?e(s.grounds[u.against??"established"]):"",e(s.origins[u.written?"written":"computed"])])):`<p>${e(s.noFinding)}</p>`);const o=t.sensitivity;if(o){const u=a.robustness(o);if(r.push(`<h4>${e(s.sensitivity)}</h4>`,`<p>${e(i.reproduced)} : ${a.reproduced(o)||"–"} · ${e(i.gap)} : ${a.degrees(o.medianSeparationDeg)||"–"} · <span class="${u.kind}">${e(u.text)}</span></p>`),u.kind!=="too-few"&&u.kind!=="nothing"&&o.margins.length>0&&r.push(z.table([i.knob,i.from,i.to,i.reference,i.covered],o.margins.map(p=>{const l=a.ends(p),m=p.reference?`${a.amount(p.knob,p.reference.lower)} … ${a.amount(p.knob,p.reference.upper)}`:s.noLaw;return[e(s.knobs[p.knob]),l.from,l.to,e(m),p.coverage===void 0?"":`${Math.round(p.coverage*100)} %`]}),[1,2,4])),o.better){const{knob:p,amount:l,agreement:m}=o.better;r.push(`<p class="fine-tuned">${e(a.fill(s.better,{knob:s.knobs[p],amount:a.amount(p,l),agreed:String(Math.round(m*o.compared)),compared:String(o.compared)}))}</p>`)}}return t.comparisons.length>0&&r.push(`<h4>${e(s.comparisons)}</h4>`,z.table([i.instant,i.phenomenon,`${i.said} (${i.azimuth}, ${i.altitude})`,`${i.read} (${i.azimuth}, ${i.altitude})`,i.separation,i.agrees],t.comparisons.map(u=>[a.instant(u.t),e(n?.phenomena?.[u.sourceId]??u.sourceId),u.said?`${a.azimuth(u.said.azimuthDeg)}, ${a.degrees(u.said.altitudeDeg)}`:"",`${a.azimuth(u.predicted.azimuthDeg)}, ${a.degrees(u.predicted.altitudeDeg)}`,a.degrees(u.separationDeg),`<span class="${u.agrees?"holds":"fails"}">${e(u.agrees?s.yes:s.no)}</span>`]),[0,4])),r}static valuesTable(t,n){const a=n.texts,s=a.columns,i=z.escape;return z.table([s.path,s.value,s.basis,s.rests],t.map(e=>[`<code>${i(e.path)}</code>`,i(n.value(e)),i(a.bases[e.basis]),i(n.rests(e))]))}static table(t,n,a=[]){const s=z.escape,i=`<tr>${t.map(r=>`<th scope="col">${s(r)}</th>`).join("")}</tr>`,e=n.map(r=>`<tr>${r.map((c,o)=>`<td${a.includes(o)?' class="n"':""}>${c}</td>`).join("")}</tr>`);return`<div class="scroll"><table><thead>${i}</thead><tbody>${e.join("")}</tbody></table></div>`}static escape(t){return t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}}const _=P.catalog({en:()=>B(()=>import("./CaseReportTexts_en-DlN7p1pC.js"),[],import.meta.url).then(N=>N.caseReportTexts_en),fr:()=>B(()=>import("./CaseReportTexts_fr-B5nP6RlP.js"),[],import.meta.url).then(N=>N.caseReportTexts_fr),es:()=>B(()=>import("./CaseReportTexts_es-CncAEaey.js"),[],import.meta.url).then(N=>N.caseReportTexts_es),it:()=>B(()=>import("./CaseReportTexts_it-Dc-oPmXB.js"),[],import.meta.url).then(N=>N.caseReportTexts_it)});class U{static async make(t,n,a,s,i=!1,e){const[r,c]=await Promise.all([_.load(a),J.load(a)]),o=A.of(n.caseJson,n.caseUrl,n.recordings,new C([...s]),new F(c));i&&t!=="csv"&&await U.pictures(o,n,r,e);const u=`${n.caseJson.id??"case"}-report`;switch(t){case"html":U.download(new Blob([z.of(o,r,a,"0.191.1")],{type:"text/html"}),`${u}.html`);return;case"print":U.print(z.of(o,r,a,"0.191.1"));return;case"json":U.download(new Blob([T.json(o,"0.191.1")],{type:"application/json"}),`${u}.json`);return;case"csv":{const{zipSync:p,strToU8:l}=await B(async()=>{const{zipSync:d,strToU8:g}=await import("./browser-CltifEM0.js");return{zipSync:d,strToU8:g}},[],import.meta.url),m=Object.fromEntries(Object.entries(T.csv(o,r,a)).map(([d,g])=>[d,l(`\uFEFF${g}`)]));U.download(new Blob([p(m)],{type:"application/zip"}),`${u}-tables.zip`)}}}static PICTURED_INSTANTS=3;static async pictures(t,n,a,s){const{registerScene:i,SCENE_ELEMENT_NAME:e}=await B(async()=>{const{registerScene:p,SCENE_ELEMENT_NAME:l}=await import("./rr0-sighting.mjs").then(m=>m.bY);return{registerScene:p,SCENE_ELEMENT_NAME:l}},[],import.meta.url);i();const r=t.witnesses.map(p=>{const l=p.indications.filter(f=>f.directionSaid).map(f=>f.t),m=l.length<=U.PICTURED_INSTANTS?l:[l[0],l[Math.floor(l.length/2)],l[l.length-1]],d=t.readings.filter(f=>f.reads===p.title&&f.comparisons.length>0),g=[{label:a.accountView,url:p.url,reading:void 0},...d.map(f=>({label:f.title,url:p.url,reading:f.url}))];return{witness:p,instants:[...new Set(m)],recordings:g}}).filter(p=>p.instants.length>0),c=r.reduce((p,l)=>p+l.instants.length*l.recordings.length,0);if(c===0)return;const o=document.createElement(e);o.setAttribute("max-pixel-ratio","1"),o.setAttribute("always-live",""),Object.assign(o.style,{position:"fixed",left:"-10000px",top:"0",width:"640px",height:"360px",visibility:"hidden",pointerEvents:"none"}),document.body.appendChild(o);let u=0;s?.(u,c);try{for(const p of r){const l=p.instants.map(d=>({t:d,views:[]})),m=n.recordings.get(p.witness.url);m&&(o.documentUrl=p.witness.url,o.sightingData=m);for(const d of p.recordings){const g=m,f=d.reading?n.recordings.get(d.reading):void 0;for(const w of l){let b;g&&(!d.reading||f)&&(w===l[0]&&(o.interpretation=U.bodiesOf(f??g,d.reading??p.witness.url)),b=await o.pictureAt(w.t,480).catch(()=>{})),w.views.push({label:d.label,...b?{image:b}:{}}),s?.(++u,c)}}p.witness.pictures=l}}finally{o.remove()}}static bodiesOf(t,n){const a=W.strip(t).recording.interpretation;if(a)return{...a,bodies:a.bodies.map(s=>s.model?.url?{...s,model:{...s.model,url:new URL(s.model.url,n).href}}:s)}}static print(t){const n=document.createElement("iframe");n.setAttribute("aria-hidden","true"),n.style.cssText="position: fixed; right: 0; bottom: 0; width: 0; height: 0; border: 0",n.addEventListener("load",()=>{const a=n.contentWindow;a&&(a.addEventListener("afterprint",()=>n.remove()),a.focus(),a.print(),window.setTimeout(()=>n.remove(),6e4))},{once:!0}),n.srcdoc=t,document.body.append(n)}static download(t,n){const a=URL.createObjectURL(t),s=document.createElement("a");s.href=a,s.download=n,s.click(),window.setTimeout(()=>URL.revokeObjectURL(a),1e3)}}export{U as CaseReportExport};
@@ -0,0 +1 @@
1
+ import{G as F,a2 as m,a5 as I,Y as X,ap as D,aq as L}from"./rr0-sighting.mjs";import{C as x}from"./ContrailGrowth-DwHS8If9.js";class h{static MAX_SEGMENTS=8e3;static MIN_PIXELS=2;static UNRESOLVED_CONTRAST=.5;static STATIONS=[0,.5,1,1.5,2.25];static VERTICES_PER_SEGMENT=12*(h.STATIONS.length-1);static ICE_ASYMMETRY=.75;static phase(t){const s=h.ICE_ASYMMETRY;return(1-s*s)/(1+s*s-2*s*t)**1.5}object;group=new F;trails=[];positions=new Float32Array(h.MAX_SEGMENTS*h.VERTICES_PER_SEGMENT*3);colors=new Float32Array(h.MAX_SEGMENTS*h.VERTICES_PER_SEGMENT*4);segments=0;constructor(){const t=new m;t.setAttribute("position",new I(this.positions,3)),t.setAttribute("color",new I(this.colors,4)),t.setDrawRange(0,0),this.object=new X(t,new D({vertexColors:!0,transparent:!0,depthWrite:!1,side:L})),this.object.frustumCulled=!1,this.object.name="contrails",this.group.name="contrails",this.group.add(this.object)}get segmentCount(){return this.segments}set(t){this.trails=t}update(t,s,c){let p=0;this.segments=0;for(const o of this.trails){const u=this.samplesOf(o,t,s),i=c(o.id);for(let a=0;a+1<u.length;a++){const n=u[a],M=u[a+1];if(!n.forms||!M.forms)continue;if(this.segments>=h.MAX_SEGMENTS)break;const d=this.pushSegment(p,n,M,o.spanM,i,s);d>p&&this.segments++,p=d}}const y=this.object.geometry;y.setDrawRange(0,p);for(const[o,u]of[["position",3],["color",4]]){const i=y.getAttribute(o);i.clearUpdateRanges(),p>0&&i.addUpdateRange(0,p*u),i.needsUpdate=!0}}samplesOf(t,s,c){const p=s-x.FORMATION_S*1e3,y=[],o=(n,M,d,T,l,N)=>({x:M+n.driftEastMs*l+c.origin.x,y:T,z:-(d+n.driftNorthMs*l)+c.origin.z,age:l,forms:N,point:n});let u=-1;t.points.forEach((n,M)=>{n.tMs>p||(u=M,y.push(o(n,n.eastM,n.northM,n.upM,(s-n.tMs)/1e3,n.forms)))});const i=t.points[u],a=t.points[u+1];if(i&&a){const n=(p-i.tMs)/(a.tMs-i.tMs),M=(d,T)=>d+(T-d)*n;y.push(o(i,M(i.eastM,a.eastM),M(i.northM,a.northM),M(i.upM,a.upM),x.FORMATION_S,i.forms&&a.forms))}return y}pushSegment(t,s,c,p,y,o){const u=e=>({persistent:e.point.persistent,lifetimeS:e.point.lifetimeS,spanM:p,shearPerS:e.point.shearPerS,saturatedForS:e.point.saturatedForS}),i=x.opacity(s.age,u(s)),a=x.opacity(c.age,u(c));if(i<=0&&a<=0)return t;const n={x:c.x-s.x,y:c.y-s.y,z:c.z-s.z};if(Math.hypot(n.x,n.y,n.z)<1e-6)return t;const M={x:(s.x+c.x)/2-o.eye.x,y:(s.y+c.y)/2-o.eye.y,z:(s.z+c.z)/2-o.eye.z},d=this.normalise(this.cross(n,M)),T=e=>{if(!o.sun)return y;const r={x:e.x-o.eye.x,y:e.y-o.eye.y,z:e.z-o.eye.z},E=h.phase((o.sun.x*r.x+o.sun.y*r.y+o.sun.z*r.z)/(Math.hypot(r.x,r.y,r.z)||1));return[y[0]*E,y[1]*E,y[2]*E]},l=(e,r)=>{const E=Math.hypot(e.x-o.eye.x,e.y-o.eye.y,e.z-o.eye.z),A=x.widthM(p,e.age,e.point.shearPerS),g=Math.max(A,h.MIN_PIXELS*o.pixelRad*E),z=r*(A/g)**h.UNRESOLVED_CONTRAST,S=x.profileExponent(e.age),G=h.STATIONS.map((j,P)=>P===h.STATIONS.length-1?0:z*Math.exp(-Math.LN2*j**S));return{half:g/2,profile:G,scattered:T(e)}},N=[{sample:s,...l(s,i)},{sample:c,...l(c,a)}],w=h.STATIONS.length-1,f=(e,r,E)=>{const A=h.STATIONS[r],g=e.half*A*E,z=t*3;this.positions[z]=e.sample.x+d.x*g,this.positions[z+1]=e.sample.y+d.y*g,this.positions[z+2]=e.sample.z+d.z*g;const S=t*4;this.colors[S]=e.scattered[0],this.colors[S+1]=e.scattered[1],this.colors[S+2]=e.scattered[2],this.colors[S+3]=e.profile[r],t++},[R,O]=N;for(const e of[-1,1])for(let r=0;r<w;r++)f(R,r+1,e),f(R,r,e),f(O,r+1,e),f(R,r,e),f(O,r,e),f(O,r+1,e);return t}cross(t,s){return{x:t.y*s.z-t.z*s.y,y:t.z*s.x-t.x*s.z,z:t.x*s.y-t.y*s.x}}normalise(t){const s=Math.hypot(t.x,t.y,t.z)||1;return{x:t.x/s,y:t.y/s,z:t.z/s}}dispose(){this.object.geometry.dispose(),this.object.material.dispose(),this.group.removeFromParent()}}export{h as ContrailSystem};
@@ -1,4 +1,4 @@
1
- import{y as A,K as D,ar as F,X as R,as as y,at as E,au as P,N as U,C as k,av as S,aa as b}from"./rr0-sighting.mjs";class w{target;wideCamera=new A;materials=new Map;draw(t){const{renderer:s,camera:r,equidistant:a}=t,i=s.getDrawingBufferSize(new D),n=i.x,o=i.y,e=n/o;if(a&&!F.supports(r.fov,e))throw new Error(`A field of ${r.fov}° is drawn through a cube, which the control passes do not follow yet: export through a narrower field.`);const c=this.sourceCamera(r,a?a.sourceFovDeg(r.fov,e):r.fov),d=this.usableTarget(n,o),l=this.drawDistance(t,c,d),u=this.drawPhenomenon(t,c,d),f=Math.tan(c.fov*Math.PI/360),h=new Float32Array(n*o),p=new Uint8Array(n*o);for(let v=0;v<o;v++)for(let g=0;g<n;g++){const m=this.sourcePixel(g,v,n,o,r.fov,e,f,a);if(m<0)continue;const x=v*n+g;h[x]=l[m*4];const M=u[m*4],C=u[m*4+1],T=u[m*4+2],_=u[m*4+3];p[x]=Math.max(M,C,T,_)>w.LIGHT_THRESHOLD?255:0}return{width:n,height:o,distanceM:h,phenomenon:p}}dispose(){this.target?.dispose();for(const t of this.materials.values())t.dispose();this.materials.clear()}static LIGHT_THRESHOLD=1e-6;sourcePixel(t,s,r,a,i,n,o,e){if(!e)return(a-1-s)*r+t;const c=(t+.5)/r*2-1,d=1-(s+.5)/a*2,l=e.directionFor(c,d,i);if(l.z>=0)return-1;const u=l.x/-l.z/(o*n),f=l.y/-l.z/o,h=Math.floor((u+1)/2*r),p=Math.floor((f+1)/2*a);return h<0||h>=r||p<0||p>=a?-1:p*r+h}sourceCamera(t,s){const r=this.wideCamera.copy(t);return r.fov=s,r.clearViewOffset(),r.updateProjectionMatrix(),r.updateMatrixWorld(),r}usableTarget(t,s){return this.target?(this.target.width!==t||this.target.height!==s)&&this.target.setSize(t,s):this.target=new R(t,s,{type:P,format:E,minFilter:y,magFilter:y,depthBuffer:!0}),this.target}drawDistance(t,s,r){const{renderer:a,scene:i}=t,n=[],o=[];for(const e of t.sky)e.visible&&(e.visible=!1,n.push(e));i.traverseVisible(e=>{if(e instanceof U){if(t.isSolid(e)){o.push({mesh:e,material:e.material}),e.material=Array.isArray(e.material)?e.material.map(c=>this.distanceMaterial(c)):this.distanceMaterial(e.material);return}}else if(!e.isPoints&&!e.isLine&&!e.isSprite)return;n.push(e)});for(const e of n)e.visible=!1;try{return this.drawInto(t,r,()=>a.render(i,s))}finally{for(const e of n)e.visible=!0;for(const{mesh:e,material:c}of o)e.material=c}}drawPhenomenon(t,s,r){return this.drawInto(t,r,()=>t.drawPhenomena(s))}drawInto(t,s,r){const{renderer:a,scene:i}=t,n=a.getRenderTarget(),o=a.autoClear,e=a.shadowMap.autoUpdate,c=i.fog,d=i.background,l=a.getClearAlpha(),u=a.getClearColor(new k);i.fog=null,i.background=null,a.shadowMap.autoUpdate=!1,a.setRenderTarget(s),a.setClearColor(0,0),a.clear(!0,!0,!0),a.autoClear=!1;try{r();const f=new Float32Array(s.width*s.height*4);return S.now(a,s,0,0,s.width,s.height,f),f}finally{a.autoClear=o,a.shadowMap.autoUpdate=e,a.setRenderTarget(n),a.setClearColor(u,l),i.fog=c,i.background=d}}distanceMaterial(t){const s=t.alphaTest??0,r=t.map??t.alphaMap??null,a=s>0&&r!==null,i=`${t.side}:${a?`${r.uuid}:${s}`:"-"}`;let n=this.materials.get(i);return n||(n=new b({defines:a?{CUTOUT:"",USE_UV:""}:{},uniforms:{cutoutMap:{value:r},cutoutAlpha:{value:s}},vertexShader:w.VERTEX,fragmentShader:w.FRAGMENT,side:t.side}),this.materials.set(i,n)),n}static VERTEX=`
1
+ import{J as A,X as D,au as F,$ as R,av as y,aw as E,ax as P,Y as U,C as k,ay as S,ad as b}from"./rr0-sighting.mjs";class w{target;wideCamera=new A;materials=new Map;draw(t){const{renderer:s,camera:r,equidistant:a}=t,i=s.getDrawingBufferSize(new D),n=i.x,o=i.y,e=n/o;if(a&&!F.supports(r.fov,e))throw new Error(`A field of ${r.fov}° is drawn through a cube, which the control passes do not follow yet: export through a narrower field.`);const c=this.sourceCamera(r,a?a.sourceFovDeg(r.fov,e):r.fov),d=this.usableTarget(n,o),l=this.drawDistance(t,c,d),u=this.drawPhenomenon(t,c,d),f=Math.tan(c.fov*Math.PI/360),h=new Float32Array(n*o),p=new Uint8Array(n*o);for(let v=0;v<o;v++)for(let g=0;g<n;g++){const m=this.sourcePixel(g,v,n,o,r.fov,e,f,a);if(m<0)continue;const x=v*n+g;h[x]=l[m*4];const M=u[m*4],C=u[m*4+1],T=u[m*4+2],_=u[m*4+3];p[x]=Math.max(M,C,T,_)>w.LIGHT_THRESHOLD?255:0}return{width:n,height:o,distanceM:h,phenomenon:p}}dispose(){this.target?.dispose();for(const t of this.materials.values())t.dispose();this.materials.clear()}static LIGHT_THRESHOLD=1e-6;sourcePixel(t,s,r,a,i,n,o,e){if(!e)return(a-1-s)*r+t;const c=(t+.5)/r*2-1,d=1-(s+.5)/a*2,l=e.directionFor(c,d,i);if(l.z>=0)return-1;const u=l.x/-l.z/(o*n),f=l.y/-l.z/o,h=Math.floor((u+1)/2*r),p=Math.floor((f+1)/2*a);return h<0||h>=r||p<0||p>=a?-1:p*r+h}sourceCamera(t,s){const r=this.wideCamera.copy(t);return r.fov=s,r.clearViewOffset(),r.updateProjectionMatrix(),r.updateMatrixWorld(),r}usableTarget(t,s){return this.target?(this.target.width!==t||this.target.height!==s)&&this.target.setSize(t,s):this.target=new R(t,s,{type:P,format:E,minFilter:y,magFilter:y,depthBuffer:!0}),this.target}drawDistance(t,s,r){const{renderer:a,scene:i}=t,n=[],o=[];for(const e of t.sky)e.visible&&(e.visible=!1,n.push(e));i.traverseVisible(e=>{if(e instanceof U){if(t.isSolid(e)){o.push({mesh:e,material:e.material}),e.material=Array.isArray(e.material)?e.material.map(c=>this.distanceMaterial(c)):this.distanceMaterial(e.material);return}}else if(!e.isPoints&&!e.isLine&&!e.isSprite)return;n.push(e)});for(const e of n)e.visible=!1;try{return this.drawInto(t,r,()=>a.render(i,s))}finally{for(const e of n)e.visible=!0;for(const{mesh:e,material:c}of o)e.material=c}}drawPhenomenon(t,s,r){return this.drawInto(t,r,()=>t.drawPhenomena(s))}drawInto(t,s,r){const{renderer:a,scene:i}=t,n=a.getRenderTarget(),o=a.autoClear,e=a.shadowMap.autoUpdate,c=i.fog,d=i.background,l=a.getClearAlpha(),u=a.getClearColor(new k);i.fog=null,i.background=null,a.shadowMap.autoUpdate=!1,a.setRenderTarget(s),a.setClearColor(0,0),a.clear(!0,!0,!0),a.autoClear=!1;try{r();const f=new Float32Array(s.width*s.height*4);return S.now(a,s,0,0,s.width,s.height,f),f}finally{a.autoClear=o,a.shadowMap.autoUpdate=e,a.setRenderTarget(n),a.setClearColor(u,l),i.fog=c,i.background=d}}distanceMaterial(t){const s=t.alphaTest??0,r=t.map??t.alphaMap??null,a=s>0&&r!==null,i=`${t.side}:${a?`${r.uuid}:${s}`:"-"}`;let n=this.materials.get(i);return n||(n=new b({defines:a?{CUTOUT:"",USE_UV:""}:{},uniforms:{cutoutMap:{value:r},cutoutAlpha:{value:s}},vertexShader:w.VERTEX,fragmentShader:w.FRAGMENT,side:t.side}),this.materials.set(i,n)),n}static VERTEX=`
2
2
  #include <common>
3
3
  #include <uv_pars_vertex>
4
4
  #include <batching_pars_vertex>
@@ -1 +1 @@
1
- import{p as o}from"./rr0-sighting.mjs";const l=[{id:"when",paths:["time"]},{id:"where",paths:["place.locations.*.lat","place.locations.*.lng","observerTrack.keyframes.*.pose.lat","observerTrack.keyframes.*.pose.lng"]},{id:"facing",paths:["observerTrack.keyframes.*.pose.headingDeg"]},{id:"apparent-size",paths:["timeline.keyframes.*.shapes.*.shape.angular.widthDeg","timeline.keyframes.*.shapes.*.shape.angular.heightDeg"]},{id:"sky-position",paths:["timeline.keyframes.*.shapes.*.shape.aim.azimuthDeg","timeline.keyframes.*.shapes.*.shape.aim.altitudeDeg"]},{id:"how-long",paths:["durationSeconds","endTime"]},{id:"appearance",paths:["timeline.keyframes.*.shapes.*.shape.kind","timeline.keyframes.*.shapes.*.shape.title","timeline.keyframes.*.shapes.*.shape.color","timeline.keyframes.*.shapes.*.shape.brightness"]},{id:"movement",paths:["timeline.keyframes.1.t","observerTrack.keyframes.1.t"]},{id:"sound",paths:["soundTrack.keyframes.*.sound.kind"]},{id:"conditions",paths:["weatherTrack.keyframes.*.weather.*","weather.*"]}],d=["fitted","assumed","derived","stated","measured","established"];class p{about="observer";async assess(a){const i=o(a,!0),s=l.map(e=>p.answer(e,i,a));return{score:s.filter(e=>e.basis==="stated").length/s.length,criteria:s}}static answer(a,i,s){const e=a.paths.flatMap(t=>p.resolve(t,i));if(e.length===0)return{id:a.id,paths:[]};const r=e.map(t=>p.basisAt(t,s)??"stated");return{id:a.id,basis:d.find(t=>r.includes(t)),paths:e}}static basisAt(a,i){const s=a.split(".");for(let e=s.length;e>0;e--){const r=i.provenance.at(s.slice(0,e).join("."))?.basis;if(r)return r}}static resolve(a,i){let s=[{path:[],value:i}];for(const e of a.split("."))s=s.flatMap(({path:r,value:t})=>{if(typeof t!="object"||t===null)return[];if(e!=="*"){const n=t[e];return n===void 0?[]:[{path:[...r,e],value:n}]}return Object.entries(t).filter(([,n])=>n!==void 0).map(([n,h])=>({path:[...r,n],value:h}))});return s.filter(({value:e})=>e!==null&&e!==""&&!(Array.isArray(e)&&e.length===0)).map(({path:e})=>e.join("."))}}export{p as CoverageAssessor};
1
+ import{u as o}from"./rr0-sighting.mjs";const l=[{id:"when",paths:["time"]},{id:"where",paths:["place.locations.*.lat","place.locations.*.lng","observerTrack.keyframes.*.pose.lat","observerTrack.keyframes.*.pose.lng"]},{id:"facing",paths:["observerTrack.keyframes.*.pose.headingDeg"]},{id:"apparent-size",paths:["timeline.keyframes.*.shapes.*.shape.angular.widthDeg","timeline.keyframes.*.shapes.*.shape.angular.heightDeg"]},{id:"sky-position",paths:["timeline.keyframes.*.shapes.*.shape.aim.azimuthDeg","timeline.keyframes.*.shapes.*.shape.aim.altitudeDeg"]},{id:"how-long",paths:["durationSeconds","endTime"]},{id:"appearance",paths:["timeline.keyframes.*.shapes.*.shape.kind","timeline.keyframes.*.shapes.*.shape.title","timeline.keyframes.*.shapes.*.shape.color","timeline.keyframes.*.shapes.*.shape.brightness"]},{id:"movement",paths:["timeline.keyframes.1.t","observerTrack.keyframes.1.t"]},{id:"sound",paths:["soundTrack.keyframes.*.sound.kind"]},{id:"conditions",paths:["weatherTrack.keyframes.*.weather.*","weather.*"]}],d=["fitted","assumed","derived","stated","measured","established"];class p{about="observer";async assess(a){const i=o(a,!0),s=l.map(e=>p.answer(e,i,a));return{score:s.filter(e=>e.basis==="stated").length/s.length,criteria:s}}static answer(a,i,s){const e=a.paths.flatMap(t=>p.resolve(t,i));if(e.length===0)return{id:a.id,paths:[]};const r=e.map(t=>p.basisAt(t,s)??"stated");return{id:a.id,basis:d.find(t=>r.includes(t)),paths:e}}static basisAt(a,i){const s=a.split(".");for(let e=s.length;e>0;e--){const r=i.provenance.at(s.slice(0,e).join("."))?.basis;if(r)return r}}static resolve(a,i){let s=[{path:[],value:i}];for(const e of a.split("."))s=s.flatMap(({path:r,value:t})=>{if(typeof t!="object"||t===null)return[];if(e!=="*"){const n=t[e];return n===void 0?[]:[{path:[...r,e],value:n}]}return Object.entries(t).filter(([,n])=>n!==void 0).map(([n,h])=>({path:[...r,n],value:h}))});return s.filter(({value:e})=>e!==null&&e!==""&&!(Array.isArray(e)&&e.length===0)).map(({path:e})=>e.join("."))}}export{p as CoverageAssessor};