@rr0/ufoathome 0.204.0 → 0.204.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist-embed-scene/rr0-scene.mjs +215 -215
- package/dist-embed-sighting/{CaseReportExport-CUy_3oyV.js → CaseReportExport-DQ4bO4eb.js} +1 -1
- package/dist-embed-sighting/SightingMessages_en-Bih7ljAQ.js +1 -0
- package/dist-embed-sighting/SightingMessages_es-CHrrXx-N.js +1 -0
- package/dist-embed-sighting/SightingMessages_fr-B2NUAkiz.js +1 -0
- package/dist-embed-sighting/SightingMessages_it-OGLqMUWg.js +1 -0
- package/dist-embed-sighting/rr0-sighting.mjs +233 -229
- package/dist-embed-sighting-editor/{CaseElement-CC4gimF1.js → CaseElement-zFqMRzIe.js} +2 -2
- package/dist-embed-sighting-editor/{CaseReportExport-DmvvH_GH.js → CaseReportExport-C7dPT0eH.js} +1 -1
- package/{dist-embed-ufoathome/SightingEditorMessages_en-V_dJYjNb.js → dist-embed-sighting-editor/SightingEditorMessages_en-CS2iXwDm.js} +1 -1
- package/{dist-embed-ufoathome/SightingEditorMessages_es-DauDuhPa.js → dist-embed-sighting-editor/SightingEditorMessages_es-C8Vw_4b_.js} +1 -1
- package/dist-embed-sighting-editor/{SightingEditorMessages_fr-zxTvQa2I.js → SightingEditorMessages_fr-AYgrnKFD.js} +1 -1
- package/dist-embed-sighting-editor/{SightingEditorMessages_it-vvaao68O.js → SightingEditorMessages_it-DZyzwScx.js} +1 -1
- package/dist-embed-sighting-editor/{SightingElement-BpYuBmJB.js → SightingElement-Bf654S_I.js} +5 -5
- package/dist-embed-sighting-editor/{SightingLabels_en-dOsFjVRL.js → SightingLabels_en-trAaLk8Q.js} +1 -1
- package/{dist-embed-ufoathome/SightingLabels_es-CKlP2BDO.js → dist-embed-sighting-editor/SightingLabels_es-Geji-Hhz.js} +1 -1
- package/dist-embed-sighting-editor/{SightingLabels_fr-Cpkcf5_9.js → SightingLabels_fr-BVnntoiD.js} +1 -1
- package/{dist-embed-ufoathome/SightingLabels_it-3127rMXm.js → dist-embed-sighting-editor/SightingLabels_it-B9FWbLXW.js} +1 -1
- package/dist-embed-sighting-editor/{SightingMessages_en-Drcr3k4V.js → SightingMessages_en-D90vDTQ7.js} +1 -1
- package/dist-embed-sighting-editor/{SightingMessages_es-BcaWM7Oy.js → SightingMessages_es-D8laK6OY.js} +1 -1
- package/dist-embed-sighting-editor/{SightingMessages_fr-7IYuW095.js → SightingMessages_fr-Gq3IMFTE.js} +1 -1
- package/dist-embed-sighting-editor/{SightingMessages_it-BhDmZn6p.js → SightingMessages_it-BXDxv-lE.js} +1 -1
- package/dist-embed-sighting-editor/rr0-sighting-editor.mjs +245 -241
- package/dist-embed-ufoathome/{AdsbLolArchiveProvider-Ck345V92.js → AdsbLolArchiveProvider-JK7ddZzC.js} +1 -1
- package/dist-embed-ufoathome/{Aurora-CMORgA2p.js → Aurora-UBzKnuxt.js} +1 -1
- package/dist-embed-ufoathome/{AuroraEditor-CDZgVOlI.js → AuroraEditor-B0Q9h5C6.js} +1 -1
- package/dist-embed-ufoathome/{AuroraSimulation-DqfSBul6.js → AuroraSimulation-Cj8dyvm4.js} +1 -1
- package/dist-embed-ufoathome/{BallesterGuaspAssessor-DUNQZ9e8.js → BallesterGuaspAssessor-DZ5guaNx.js} +1 -1
- package/dist-embed-ufoathome/{BalloonEditor-Cx3fRab8.js → BalloonEditor-BBAtMeVM.js} +1 -1
- package/dist-embed-ufoathome/{BeamEditor-gxTjO6Pr.js → BeamEditor-Dgo8WSF9.js} +1 -1
- package/dist-embed-ufoathome/{BeamSystem-C8jjTJtB.js → BeamSystem-BbSsBbZk.js} +1 -1
- package/dist-embed-ufoathome/{BodyEditor-DGaBo74A.js → BodyEditor-Cav_-OeQ.js} +1 -1
- package/dist-embed-ufoathome/{CaseEditorElement-BOp207Tr.js → CaseEditorElement-CK82yjEn.js} +6 -6
- package/dist-embed-ufoathome/{CaseElement-BGO5UZLP.js → CaseElement-Bm6xPD0e.js} +3 -3
- package/dist-embed-ufoathome/{CaseReportExport-6DFaJzfO.js → CaseReportExport-D_I2ml6F.js} +3 -3
- package/dist-embed-ufoathome/{ColumnResize-DnX89ynB.js → ColumnResize-DksRZriL.js} +4 -4
- package/dist-embed-ufoathome/{ControlPasses-CeExr5X1.js → ControlPasses-BpLNDq5G.js} +1 -1
- package/dist-embed-ufoathome/{CoverageAssessor-BbqRqh0C.js → CoverageAssessor-UyH_dVvr.js} +1 -1
- package/dist-embed-ufoathome/{Flightradar24Provider-MzQcuUHn.js → Flightradar24Provider-XASYwL-N.js} +1 -1
- package/dist-embed-ufoathome/{GLTFLoader-CPUffC65.js → GLTFLoader-s3EU9qS0.js} +1 -1
- package/dist-embed-ufoathome/{GeoJsonExport-D7QhWNRC.js → GeoJsonExport-BCtJzQ9B.js} +1 -1
- package/dist-embed-ufoathome/{GeographicFigures-BvEeCtxr.js → GeographicFigures-DINsiWL0.js} +1 -1
- package/dist-embed-ufoathome/{HynekAssessor-BwjRkQWT.js → HynekAssessor-D5zxfJ44.js} +1 -1
- package/dist-embed-ufoathome/{InterviewEditorElement-CVCOicLD.js → InterviewEditorElement-CQNMEirl.js} +1 -1
- package/dist-embed-ufoathome/{InterviewElement-ZI42DKRx.js → InterviewElement-BouR8Xii.js} +1 -1
- package/dist-embed-ufoathome/{KmlExport-BX0nxAaA.js → KmlExport-C8zEY6ew.js} +1 -1
- package/dist-embed-ufoathome/{LanternEditor-BROUv-vx.js → LanternEditor-DEeA3Kf_.js} +1 -1
- package/dist-embed-ufoathome/{LaserBeam-ChD9aV-N.js → LaserBeam-CDTsYUwS.js} +1 -1
- package/dist-embed-ufoathome/{LaunchEditor-CM2Wcjv2.js → LaunchEditor-C91_y6bJ.js} +1 -1
- package/dist-embed-ufoathome/{LaunchPlume-DeVRe05u.js → LaunchPlume-Je5cyuGE.js} +1 -1
- package/dist-embed-ufoathome/{LaunchSimulation-RROdYccW.js → LaunchSimulation-BsCQGsdb.js} +1 -1
- package/dist-embed-ufoathome/{ModelSource-nXZ6eIH5.js → ModelSource-7jnvikmB.js} +1 -1
- package/dist-embed-ufoathome/{ModelThumbnails-CRSm49vm.js → ModelThumbnails-DhEg69n0.js} +1 -1
- package/dist-embed-ufoathome/{ModelViewer-BQsl_Nfn.js → ModelViewer-BQJyyY66.js} +1 -1
- package/dist-embed-ufoathome/{ModulesPanelElement-BvzY1GUF.js → ModulesPanelElement-Ct9DMG0-.js} +1 -1
- package/dist-embed-ufoathome/{NearestApproach-DbUpe1iw.js → NearestApproach-BFKGUqFb.js} +1 -1
- package/dist-embed-ufoathome/{PoherAssessor-Dmro58tC.js → PoherAssessor-Cmw5u2Nv.js} +1 -1
- package/dist-embed-ufoathome/{PoherSelfCheck-pcYj_hQ1.js → PoherSelfCheck-BjmenygA.js} +1 -1
- package/dist-embed-ufoathome/{ReentryEditor-Di0KzYeZ.js → ReentryEditor-x_C9chQN.js} +1 -1
- package/dist-embed-ufoathome/{ReentrySimulation-HhdlSVkR.js → ReentrySimulation-D0XIfeyt.js} +1 -1
- package/dist-embed-ufoathome/{ReferenceSystem-B30-UBHY.js → ReferenceSystem-Cv556rkv.js} +1 -1
- package/dist-embed-ufoathome/{ScenarioReadings-EAUAsx9t.js → ScenarioReadings-YJ8iIjyw.js} +1 -1
- package/dist-embed-ufoathome/{ScenarioSweep-jTxLjnaW.js → ScenarioSweep-DTqJSF5a.js} +1 -1
- package/dist-embed-ufoathome/{SearchlightEditor-B6_BW8FD.js → SearchlightEditor-Dy-gMDUN.js} +1 -1
- package/dist-embed-ufoathome/{SearchlightSystem-D_DTpDNC.js → SearchlightSystem-C-qAMIFS.js} +1 -1
- package/dist-embed-ufoathome/{ShareDialogElement-C0oFh0X4.js → ShareDialogElement-DMDY7Hlo.js} +17 -13
- package/dist-embed-ufoathome/Sighting-C1yj2-s5.js +1 -0
- package/{dist-embed-sighting-editor/SightingEditorMessages_en-V_dJYjNb.js → dist-embed-ufoathome/SightingEditorMessages_en-CS2iXwDm.js} +1 -1
- package/{dist-embed-sighting-editor/SightingEditorMessages_es-DauDuhPa.js → dist-embed-ufoathome/SightingEditorMessages_es-C8Vw_4b_.js} +1 -1
- package/dist-embed-ufoathome/{SightingEditorMessages_fr-zxTvQa2I.js → SightingEditorMessages_fr-AYgrnKFD.js} +1 -1
- package/dist-embed-ufoathome/{SightingEditorMessages_it-vvaao68O.js → SightingEditorMessages_it-DZyzwScx.js} +1 -1
- package/dist-embed-ufoathome/{SightingElement-DzxTvvLN.js → SightingElement-DZlh5u4N.js} +5 -5
- package/dist-embed-ufoathome/{SightingLabels_en-dOsFjVRL.js → SightingLabels_en-trAaLk8Q.js} +1 -1
- package/{dist-embed-sighting-editor/SightingLabels_es-CKlP2BDO.js → dist-embed-ufoathome/SightingLabels_es-Geji-Hhz.js} +1 -1
- package/dist-embed-ufoathome/{SightingLabels_fr-Cpkcf5_9.js → SightingLabels_fr-BVnntoiD.js} +1 -1
- package/{dist-embed-sighting-editor/SightingLabels_it-3127rMXm.js → dist-embed-ufoathome/SightingLabels_it-B9FWbLXW.js} +1 -1
- package/dist-embed-ufoathome/{SightingMessages_en-Drcr3k4V.js → SightingMessages_en-D90vDTQ7.js} +1 -1
- package/dist-embed-ufoathome/{SightingMessages_es-BcaWM7Oy.js → SightingMessages_es-D8laK6OY.js} +1 -1
- package/dist-embed-ufoathome/{SightingMessages_fr-7IYuW095.js → SightingMessages_fr-Gq3IMFTE.js} +1 -1
- package/dist-embed-ufoathome/{SightingMessages_it-BhDmZn6p.js → SightingMessages_it-BXDxv-lE.js} +1 -1
- package/dist-embed-ufoathome/{TraceSystem-CiBRo1aU.js → TraceSystem-DYmjmB9_.js} +1 -1
- package/dist-embed-ufoathome/{VideoButton-BseBKx2r.js → VideoButton-CvAmQpx0.js} +1 -1
- package/dist-embed-ufoathome/rr0-ufoathome.mjs +3 -3
- package/dist-embed-ufoathome/{surroundingsSources-BSh42KUu.js → surroundingsSources-DtoCfflQ.js} +1 -1
- package/dist-embed-ufoathome/{trafficRuntime-BMTtwn7o.js → trafficRuntime-CyYep5Cc.js} +1 -1
- package/package.json +1 -1
- package/dist-embed-sighting/SightingMessages_en-DKFVZnDu.js +0 -1
- package/dist-embed-sighting/SightingMessages_es-DYQlWvm0.js +0 -1
- package/dist-embed-sighting/SightingMessages_fr-BygVDDY9.js +0 -1
- package/dist-embed-sighting/SightingMessages_it-BI7GnXPz.js +0 -1
- package/dist-embed-ufoathome/Sighting-BX_CmDY2.js +0 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./SkyLantern-DJT_Ibzh.js","./Obstacles-v9SkfBD7.js","./LanternEditor-
|
|
2
|
-
const hn="modulepreload",fn=function(n,t){return new URL(n,t).href},ze={},d=function(t,e,r){let s=Promise.resolve();if(e&&e.length>0){let i=function(m){return Promise.all(m.map(p=>Promise.resolve(p).then(f=>({status:"fulfilled",value:f}),f=>({status:"rejected",reason:f}))))};const a=document.getElementsByTagName("link"),l=document.querySelector("meta[property=csp-nonce]"),c=l?.nonce||l?.getAttribute("nonce");s=i(e.map(m=>{if(m=fn(m,r),m in ze)return;ze[m]=!0;const p=m.endsWith(".css"),f=p?'[rel="stylesheet"]':"";if(!!r)for(let E=a.length-1;E>=0;E--){const G=a[E];if(G.href===m&&(!p||G.rel==="stylesheet"))return}else if(document.querySelector(`link[href="${m}"]${f}`))return;const S=document.createElement("link");if(S.rel=p?"stylesheet":hn,p||(S.as="script"),S.crossOrigin="",S.href=m,c&&S.setAttribute("nonce",c),document.head.appendChild(S),p)return new Promise((E,G)=>{S.addEventListener("load",E),S.addEventListener("error",()=>G(new Error(`Unable to preload CSS for ${m}`)))})}))}function o(i){const a=new Event("vite:preloadError",{cancelable:!0});if(a.payload=i,window.dispatchEvent(a),!a.defaultPrevented)throw i}return s.then(i=>{for(const a of i||[])a.status==="rejected"&&o(a.reason);return t().catch(o)})},gn="rr0-read",wn="rr0-edit",ve="in-place",yn="rr0-mode";class Xs{static ask(t,e,r){const s=new CustomEvent(e,{detail:r,bubbles:!0,composed:!0,cancelable:!0});return t.dispatchEvent(s),s.defaultPrevented}}class j{constructor(t){this.entries=t}static same(t,e){return typeof t=="number"&&typeof e=="number"?t===e||Math.abs(t-e)<=1e-9*Math.max(1,Math.abs(t),Math.abs(e)):Array.isArray(t)&&Array.isArray(e)?t.length===e.length&&t.every((r,s)=>j.same(r,e[s])):typeof t=="object"&&t!==null&&typeof e=="object"&&e!==null&&!Array.isArray(t)&&!Array.isArray(e)?[...new Set([...Object.keys(t),...Object.keys(e)])].every(s=>j.same(t[s],e[s])):t===e}static free(t){return t?.basis==="assumed"||t?.basis==="fitted"}static empty(){return new j(new Map)}get size(){return this.entries.size}at(t){return this.entries.get(t)}paths(){return[...this.entries.keys()]}sourced(){return[...this.entries].filter(([,t])=>t.source!==void 0).map(([t,e])=>({path:t,basis:e.basis,source:e.source}))}interviewsCited(){const t=[];for(const{source:e}of this.sourced()){const r=e.said?.interview;r!==void 0&&!t.includes(r)&&t.push(r)}return t}pathsFromInterview(t){return this.sourced().filter(({source:e})=>e.said!==void 0&&e.said.interview===t).map(({path:e})=>e)}set(t,e){e.basis==="stated"&&e.rationale===void 0&&e.how===void 0&&e.range===void 0&&e.source===void 0?this.entries.delete(t):this.entries.set(t,e)}clear(t){for(const e of this.entries.keys())(e===t||e.startsWith(`${t}.`))&&this.entries.delete(e)}static strip(t){const e=new j(new Map);return{recording:j.stripValue(t,[],e),provenance:e}}static restore(t,e){if(e.size===0)return t;const r={...t},s=new Set([r]);for(const o of e.paths()){const i=e.at(o),a=o.split("."),l=j.writableHolderOf(r,a,s);if(!l)continue;const c=a[a.length-1],m=l[c];m!==void 0&&(i.of!==void 0&&!j.same(i.of,m)||(l[c]={value:m,...i.basis==="stated"?{}:{basis:i.basis},...i.rationale===void 0?{}:{rationale:i.rationale},...i.how===void 0?{}:{how:i.how},...i.range===void 0?{}:{range:i.range},...i.source===void 0?{}:{source:i.source}}))}return r}static isWrapper(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)&&"value"in t}static stripValue(t,e,r){return j.isWrapper(t)?(r.set(e.join("."),{basis:t.basis??"stated",...t.rationale===void 0?{}:{rationale:t.rationale},...t.how===void 0?{}:{how:t.how},...t.range===void 0?{}:{range:t.range},...t.source===void 0?{}:{source:t.source},of:t.value}),j.stripValue(t.value,e,r)):Array.isArray(t)?t.map((s,o)=>j.stripValue(s,[...e,String(o)],r)):typeof t=="object"&&t!==null?Object.fromEntries(Object.entries(t).map(([s,o])=>[s,j.stripValue(o,[...e,s],r)])):t}static writableHolderOf(t,e,r){let s=t;for(const o of e.slice(0,-1)){const i=s[o];if(typeof i!="object"||i===null)return;if(r.has(i)){s=i;continue}const a=Array.isArray(i)?[...i]:{...i};r.add(a),s[o]=a,s=a}return s}}class bn extends Error{constructor(t,e,r){super(typeof e=="number"&&Number.isInteger(e)&&e>=1?`This ${t} file is in version ${e} of its format; this UFO@home reads version ${r}. Read it with the UFO@home that reads its version.`:`This ${t} file states ${JSON.stringify(e)} as its format version, which is not a version.`),this.format=t,this.found=e,this.supported=r,this.name="FormatVersionError"}said(t){return t.replace("{found}",typeof this.found=="number"?String(this.found):JSON.stringify(this.found)).replace("{supported}",String(this.supported))}}class ht{static CURRENT={sighting:4,case:1,interview:1};static SCHEMA_BASE="https://ufoathome.org/schema";static schemaUrl(t,e=ht.CURRENT[t]){return`${ht.SCHEMA_BASE}/${e}/${t}.schema.json`}static of(t){if(typeof t!="object"||t===null)return 1;const e=t.version;return e===void 0?1:typeof e=="object"&&e!==null&&"value"in e?e.value:e}static recording(t){return ht.check(t,"sighting")}static check(t,e){const r=ht.of(t),s=ht.CURRENT[e];if(typeof r!="number"||!Number.isInteger(r)||r!==s)throw new bn(e,r,s);return t}}class N{static built=new WeakMap;static computers=new WeakMap;static loading=new WeakMap;static loaded(t,e){return e.every(r=>N.itemsOf(t,r.key).length===0||N.computers.has(r))}static load(t,e){return Promise.all(e.filter(r=>N.itemsOf(t,r.key).length>0&&!N.computers.has(r)).map(r=>{let s=N.loading.get(r);return s||(s=r.compute().then(o=>{N.computers.set(r,o)}),s.catch(()=>N.loading.delete(r)),N.loading.set(r,s)),s.catch(()=>{})})).then(()=>{})}static of(t){let e=N.built.get(t);return e||(e=t.create(),N.built.set(t,e)),e}static itemsOf(t,e){const r=t?.[e];return Array.isArray(r)?r:[]}static computes(t,e){return e.some(r=>N.itemsOf(t,r.key).length>0)}static expand(t,e,r){return N.expandWithKinds(t,e,r).interpretation}static expandWithKinds(t,e,r){const s=new Map,o=new Map;if(!t||!N.computes(t,e))return{interpretation:t,kindOf:s,phenomenonOf:o};const i=e.flatMap(a=>N.itemsOf(t,a.key).flatMap(l=>{const c=N.computers.get(a);if(!c)return[];const m=c(l,r),p=a.phenomenon?.(l);for(const f of m)s.set(f.id,a),p&&o.set(f.id,p);return m}));return{interpretation:{...t,bodies:[...t.bodies,...i]},kindOf:s,phenomenonOf:o}}static phenomena(t,e){const r=new Set;for(const s of e)for(const o of N.itemsOf(t,s.key)){const i=s.phenomenon?.(o);i&&r.add(i)}return r}static computedPart(t,e){const r={};for(const s of e){const o=N.itemsOf(t,s.key);o.length>0&&(r[s.key]=[...o])}return r}static saysNothing(t,e){return t.bodies.length===0&&t.title===void 0&&t.smoke===void 0&&e.every(r=>t[r.key]===void 0)}}const Js=Object.freeze(Object.defineProperty({__proto__:null,InterpretationKinds:N},Symbol.toStringTag,{value:"Module"}));class Zr extends Error{constructor(t,e,r,s){super(`Module "${t}" gives "${r}" at ${e}, which module "${s}" already gives`),this.moduleId=t,this.point=e,this.sourceId=r,this.ownerId=s,this.name="ModuleConflictError"}}class En{constructor(t){this.id=t}sources=[];owners=new Map;ownerOf(t){return this.owners.get(t)}conflict(t,e){for(const r of e){const s=this.owners.get(r.id);if(s!==void 0&&s!==t)return{sourceId:r.id,ownerId:s}}}provide(t,e){const r=this.conflict(t,e);if(r)throw new Zr(t,this.id,r.sourceId,r.ownerId);this.withdraw(t);const s=t===A.BUILT_IN?this.sources.findIndex(o=>this.owners.get(o.id)!==A.BUILT_IN):-1;s<0?this.sources.push(...e):this.sources.splice(s,0,...e);for(const o of e)this.owners.set(o.id,t);return this.sources}withdraw(t){for(let e=this.sources.length-1;e>=0;e--){const r=this.sources[e].id;this.owners.get(r)===t&&(this.sources.splice(e,1),this.owners.delete(r))}}}class A{static BUILT_IN="ufoathome";static changes=new EventTarget;static points=new Map;static modules=new Map;static point(t){let e=A.points.get(t);return e||(e=new En(t),A.points.set(t,e)),e}static install(t){if(t.id===A.BUILT_IN)throw new Error(`"${A.BUILT_IN}" is the id of the built-in module`);const e=A.contributionsOf(t);for(const[o,i]of e){const a=A.point(o).conflict(t.id,i);if(a)throw new Zr(t.id,o,a.sourceId,a.ownerId)}const r=new Set(e.map(([o])=>o)),s=A.modules.get(t.id);if(s)for(const[o]of A.contributionsOf(s))r.add(o);for(const o of r)A.point(o).withdraw(t.id);for(const[o,i]of e)A.point(o).provide(t.id,i);A.modules.set(t.id,t);for(const o of r)A.announce(o)}static uninstall(t){const e=A.modules.get(t);if(e){A.modules.delete(t);for(const[r]of A.contributionsOf(e))A.point(r).withdraw(t),A.announce(r)}}static installed(){return[...A.modules.values()]}static contributionsOf(t){return Object.entries(t.contributes).filter(e=>Array.isArray(e[1])&&e[1].length>0)}static announce(t){A.changes.dispatchEvent(new CustomEvent("change",{detail:t}))}}const Sn=["en","fr","es","it"];class _{static catalog(t){const e=new Map;return{load(r){const s=_.languageOf(r);let o=e.get(s);return o||(o=t[s](),e.set(s,o),o.catch(()=>e.delete(s))),o}}}static none(){return new Proxy({},{get:()=>""})}static blank(){const t=new Proxy(()=>t,{get:(e,r)=>r===Symbol.toPrimitive?()=>"":r===Symbol.iterator?function*(){}:r==="toString"||r==="valueOf"?()=>"":r==="then"?void 0:t,apply:()=>t,has:()=>!1,ownKeys:()=>[],getOwnPropertyDescriptor:()=>{}});return t}static languageOf(t){const e=t.toLowerCase().split("-")[0];return Sn.includes(e)?e:"en"}}const vn=_.catalog({en:()=>d(()=>import("./FlareKindMessages_en-j3CY_TxX.js"),[],import.meta.url).then(n=>n.flareKindMessages_en),fr:()=>d(()=>import("./FlareKindMessages_fr-B2MezoN2.js"),[],import.meta.url).then(n=>n.flareKindMessages_fr),es:()=>d(()=>import("./FlareKindMessages_es-CZgrFIOO.js"),[],import.meta.url).then(n=>n.flareKindMessages_es),it:()=>d(()=>import("./FlareKindMessages_it-CmZmb3RP.js"),[],import.meta.url).then(n=>n.flareKindMessages_it)});class nt{constructor(t={}){this.options=t,this.fetchImpl=t.fetchImpl??fetch.bind(globalThis),this.wait=t.wait??(e=>new Promise(r=>setTimeout(r,e)))}static URL="https://historical-forecast-api.open-meteo.com/v1/forecast";static CREDIT="Open-Meteo historical forecast";static LEVELS=[850,700,600,500,400,300];static RETRIES=6;static RETRY_MS=2e3;days=new Map;fetchImpl;wait;async profile(t,e,r){const o=new Date(Math.floor(r.getTime()/36e5)*36e5),i=(r.getTime()-o.getTime())/36e5,a=await this.hourly(t,e,o);if(i<1e-6)return a;const l=await this.hourly(t,e,new Date(o.getTime()+36e5));return a.levels.length!==l.levels.length?i<.5?a:l:{...a,hour:r.toISOString().slice(0,16),levels:a.levels.map((c,m)=>{const[p,f]=X.vector(c.wind),[y,S]=X.vector(l.levels[m].wind);return{aboveGroundM:c.aboveGroundM+i*(l.levels[m].aboveGroundM-c.aboveGroundM),wind:X.fromVector(p+i*(y-p),f+i*(S-f))}})}}async hourly(t,e,r){const s=r.toISOString().slice(0,13)+":00",o=s.slice(0,10),i=`${t.toFixed(4)},${e.toFixed(4)},${o}`;let a=this.days.get(i);return a||(a=this.day(t,e,o,i),a.catch(()=>this.days.delete(i)),this.days.set(i,a)),nt.profileOf(await a,s)}static profileOf(t,e){const r=t.hourly,s=r.time.indexOf(e);if(s<0)throw new Error(`No wind for ${e} in the archive's answer`);const o=c=>(c+180)%360,i=[],a=r.wind_speed_10m?.[s],l=r.wind_direction_10m?.[s];typeof a=="number"&&typeof l=="number"&&i.push({aboveGroundM:10,wind:{towardDeg:o(l),speedMS:a}});for(const c of nt.LEVELS){const m=r[`geopotential_height_${c}hPa`]?.[s],p=r[`wind_speed_${c}hPa`]?.[s],f=r[`wind_direction_${c}hPa`]?.[s];if(typeof m!="number"||typeof p!="number"||typeof f!="number")continue;const y=m-t.elevation;y<=(i[i.length-1]?.aboveGroundM??0)||i.push({aboveGroundM:y,wind:{towardDeg:o(f),speedMS:p}})}if(i.length===0)throw new Error(`No wind for ${e} in the archive's answer`);return{lat:t.latitude,lng:t.longitude,elevationM:t.elevation,hour:e,levels:i,credit:nt.CREDIT}}async day(t,e,r,s){const o=await this.options.cache?.get(s);if(o)return JSON.parse(o);const i=["wind_speed_10m","wind_direction_10m",...nt.LEVELS.flatMap(c=>[`wind_speed_${c}hPa`,`wind_direction_${c}hPa`,`geopotential_height_${c}hPa`])],a=new URLSearchParams({latitude:String(t),longitude:String(e),start_date:r,end_date:r,hourly:i.join(","),wind_speed_unit:"ms",timezone:"GMT"}),l=`${this.options.url??nt.URL}?${a}`;for(let c=0;;c++){const m=await this.fetchImpl(l);if(m.ok){const p=await m.text();return await this.options.cache?.set(s,p),JSON.parse(p)}if((m.status===429||m.status>=500)&&c<nt.RETRIES){await this.wait(nt.RETRY_MS*2**c);continue}throw new Error(`The wind archive answered ${m.status} for ${s}`)}}}class X{static at(t,e){const r=t.levels;if(e<=r[0].aboveGroundM)return{...r[0].wind};for(let s=1;s<r.length;s++){const o=r[s-1],i=r[s];if(e<=i.aboveGroundM){const a=(e-o.aboveGroundM)/(i.aboveGroundM-o.aboveGroundM),[l,c]=X.vector(o.wind),[m,p]=X.vector(i.wind);return X.fromVector(l+a*(m-l),c+a*(p-c))}}return{...r[r.length-1].wind}}static vector(t){const e=t.towardDeg*Math.PI/180;return[t.speedMS*Math.sin(e),t.speedMS*Math.cos(e)]}static fromVector(t,e){return{towardDeg:(Math.atan2(t,e)*180/Math.PI+360)%360,speedMS:Math.hypot(t,e)}}static rounded(t){return{towardDeg:Math.round(t.towardDeg)%360,speedMS:Math.round(t.speedMS*100)/100}}}const Zs=Object.freeze(Object.defineProperty({__proto__:null,OpenMeteoWindProfiles:nt,Winds:X},Symbol.toStringTag,{value:"Module"})),xn=X.rounded,We={key:"flares",messages:vn,phenomenon:()=>"DecoyFlare",inWind:(n,t)=>({...n,wind:xn(t.at(n.aircraft.altitudeM))}),compute:()=>d(async()=>{const{DecoyFlare:n}=await import("./DecoyFlare-DUt1_LcW.js");return{DecoyFlare:n}},[],import.meta.url).then(({DecoyFlare:n})=>t=>n.bodiesOf(t))},Mn=_.catalog({en:()=>d(()=>import("./LanternKindMessages_en-CQXdJ-k6.js"),[],import.meta.url).then(n=>n.lanternKindMessages_en),fr:()=>d(()=>import("./LanternKindMessages_fr-D7tQa_tQ.js"),[],import.meta.url).then(n=>n.lanternKindMessages_fr),es:()=>d(()=>import("./LanternKindMessages_es-BOO6kPjs.js"),[],import.meta.url).then(n=>n.lanternKindMessages_es),it:()=>d(()=>import("./LanternKindMessages_it-B8J-29Mj.js"),[],import.meta.url).then(n=>n.lanternKindMessages_it)}),Ye=X.rounded,Xe={key:"lanterns",messages:Mn,phenomenon:()=>"SkyLantern",inWind:(n,t)=>{const e=n.site.altitudeM??0,r=n.windAloft?.atM??1e3;return{...n,wind:Ye(t.at(10)),windAloft:{...Ye(t.at(e+r)),atM:r}}},compute:()=>d(async()=>{const{SkyLantern:n}=await import("./SkyLantern-DJT_Ibzh.js");return{SkyLantern:n}},__vite__mapDeps([0,1]),import.meta.url).then(({SkyLantern:n})=>(t,e)=>n.bodiesOf(t,e?.obstacles)),editor:()=>d(async()=>{const{LanternEditor:n}=await import("./LanternEditor-BROUv-vx.js");return{LanternEditor:n}},__vite__mapDeps([2,3,4,5,0,1,6,7,8]),import.meta.url).then(({LanternEditor:n})=>(t,e,r)=>new n(t,e,r))},An=_.catalog({en:()=>d(()=>import("./BirdKindMessages_en-c_-L7frF.js"),[],import.meta.url).then(n=>n.birdKindMessages_en),fr:()=>d(()=>import("./BirdKindMessages_fr-C1TuqqEj.js"),[],import.meta.url).then(n=>n.birdKindMessages_fr),es:()=>d(()=>import("./BirdKindMessages_es-8Zo2t0o4.js"),[],import.meta.url).then(n=>n.birdKindMessages_es),it:()=>d(()=>import("./BirdKindMessages_it-DQZcrCkf.js"),[],import.meta.url).then(n=>n.birdKindMessages_it)}),Je={key:"birds",messages:An,phenomenon:()=>"Birds",compute:()=>d(async()=>{const{BirdFlock:n}=await import("./BirdFlock-ByBkJV35.js").then(t=>t.b);return{BirdFlock:n}},__vite__mapDeps([9,1]),import.meta.url).then(({BirdFlock:n})=>(t,e)=>n.bodiesOf(t,e?.obstacles)),editor:()=>d(async()=>{const{BirdEditor:n}=await import("./BirdEditor-CBVGyUnK.js");return{BirdEditor:n}},__vite__mapDeps([10,3,4,5,9,1,8,11]),import.meta.url).then(({BirdEditor:n})=>(t,e,r)=>new n(t,e,r))},Tn=_.catalog({en:()=>d(()=>import("./DroneKindMessages_en-CLygXcsv.js"),[],import.meta.url).then(n=>n.droneKindMessages_en),fr:()=>d(()=>import("./DroneKindMessages_fr-CAX15_pk.js"),[],import.meta.url).then(n=>n.droneKindMessages_fr),es:()=>d(()=>import("./DroneKindMessages_es-B9XFRYnQ.js"),[],import.meta.url).then(n=>n.droneKindMessages_es),it:()=>d(()=>import("./DroneKindMessages_it-CSGsCaJQ.js"),[],import.meta.url).then(n=>n.droneKindMessages_it)}),Ze={quadcopter:"ConsumerDrone",saucer:"ConsumerDrone","fixed-wing":"MilitaryDrone"},Qe={key:"drones",messages:Tn,phenomenon:n=>Ze[n.airframe]??Ze.quadcopter,compute:()=>d(async()=>{const{DroneFlight:n}=await import("./DroneFlight-CGNIh9XS.js").then(t=>t.c);return{DroneFlight:n}},__vite__mapDeps([12,13]),import.meta.url).then(({DroneFlight:n})=>t=>n.bodiesOf(t)),editor:()=>d(async()=>{const{DroneEditor:n}=await import("./DroneEditor-7X9CM_3H.js");return{DroneEditor:n}},__vite__mapDeps([14,3,4,5,15,12,13,8,11]),import.meta.url).then(({DroneEditor:n})=>(t,e,r)=>new n(t,e,r))},In=_.catalog({en:()=>d(()=>import("./BalloonKindMessages_en-C6tZ-5gT.js"),[],import.meta.url).then(n=>n.balloonKindMessages_en),fr:()=>d(()=>import("./BalloonKindMessages_fr-C3QJIuDJ.js"),[],import.meta.url).then(n=>n.balloonKindMessages_fr),es:()=>d(()=>import("./BalloonKindMessages_es-BfoEjhe1.js"),[],import.meta.url).then(n=>n.balloonKindMessages_es),it:()=>d(()=>import("./BalloonKindMessages_it-CkO7mqHp.js"),[],import.meta.url).then(n=>n.balloonKindMessages_it)}),Qs=["round","star","heart","figure"];class he{static HELIUM_KG_MOL=.0040026;static ALL=[{id:"hot-air",modelId:"ufoathome-balloon-hot-air",envelope:"open",launchVolumeM3:2550,maxVolumeM3:2550,massKg:540,dragCoefficient:.5,aspect:1.461,widthM:16.5,color:"#c8202f",stripeColor:"#f5c400",albedo:.4,burner:{heatingKS:1.2,coolingS:400,blastS:6,maxExcessK:100,flameCdM2:2e4,envelopeCdM2:40,color:"#ffb347"},phenomenon:"WeatherBalloonsOrMongolfieres",durationS:3600},{id:"party",modelId:"ufoathome-balloon-latex",envelope:"elastic",launchVolumeM3:.0115,maxVolumeM3:.0335,massKg:.0045,dragCoefficient:.47,aspect:1.13,color:"#d8263a",albedo:.35,phenomenon:"WeatherBalloonsOrMongolfieres",durationS:3600},{id:"led",modelId:"ufoathome-balloon-led",envelope:"elastic",launchVolumeM3:.0141,maxVolumeM3:.041,massKg:.0075,dragCoefficient:.47,aspect:1.115,color:"#ffffff",albedo:.5,glow:{candela:.5,color:"#ffffff"},phenomenon:"LedBalloon",durationS:3600},{id:"foil",modelId:"ufoathome-balloon-foil",envelope:"vented",launchVolumeM3:.014,maxVolumeM3:.014,massKg:.01,dragCoefficient:.6,aspect:1.034,widthM:.45,depthRatio:.267,color:"#c9cdd2",albedo:.85,finish:"mirror",spins:!0,shapes:{round:{modelId:"ufoathome-balloon-foil",aspect:1.034,widthM:.45,depthRatio:.267,launchVolumeM3:.014,maxVolumeM3:.014,massKg:.01,color:"#c9cdd2"},star:{modelId:"ufoathome-balloon-foil-star",aspect:1.029,widthM:.5,depthRatio:.183,launchVolumeM3:.012,maxVolumeM3:.012,massKg:.009,color:"#e0b83a"},heart:{modelId:"ufoathome-balloon-foil-heart",aspect:.903,widthM:.5,depthRatio:.2,launchVolumeM3:.014,maxVolumeM3:.014,massKg:.01,color:"#d81e3c"},figure:{modelId:"ufoathome-balloon-foil-figure",aspect:1.112,widthM:.8,depthRatio:.127,launchVolumeM3:.05,maxVolumeM3:.05,massKg:.03,color:"#f0a3c8"}},phenomenon:"FoilBalloon",durationS:3600},{id:"pilot",modelId:"ufoathome-balloon-latex",envelope:"elastic",launchVolumeM3:.144,maxVolumeM3:.57,massKg:.045,dragCoefficient:.4,aspect:1.13,color:"#f0e6cf",albedo:.55,lamp:{candela:1,color:"#fff1c4"},phenomenon:"WeatherBalloonsOrMongolfieres",durationS:5400},{id:"weather",modelId:"ufoathome-balloon-latex",envelope:"elastic",launchVolumeM3:1.75,maxVolumeM3:118.9,massKg:.85,dragCoefficient:.3,aspect:1.13,color:"#f2ece0",albedo:.55,phenomenon:"WeatherBalloonsOrMongolfieres",durationS:7200},{id:"stratospheric",modelId:"ufoathome-balloon-stratospheric",envelope:"vented",launchVolumeM3:219,maxVolumeM3:14e3,massKg:210,dragCoefficient:.4,aspect:.91,color:"#e9eef2",albedo:.8,ballastKg:20,phenomenon:"StratosphericBalloons",durationS:10800},{id:"stratospheric-large",modelId:"ufoathome-balloon-stratospheric",envelope:"vented",launchVolumeM3:730,maxVolumeM3:15e4,massKg:700,dragCoefficient:.4,aspect:.91,color:"#e9eef2",albedo:.8,ballastKg:140,phenomenon:"StratosphericBalloons",durationS:14400},{id:"superpressure",modelId:"ufoathome-balloon-latex",envelope:"superpressure",launchVolumeM3:45,maxVolumeM3:523,massKg:44,dragCoefficient:.4,aspect:1.13,color:"#eef1f4",albedo:.8,phenomenon:"StratosphericBalloons",durationS:10800},{id:"infrared",modelId:"ufoathome-balloon-stratospheric",envelope:"open",launchVolumeM3:2075,maxVolumeM3:45e3,massKg:150,dragCoefficient:.4,aspect:.91,color:"#9aa0a8",albedo:.4,insideExcessK:20,phenomenon:"StratosphericBalloons",durationS:10800},{id:"prank-candles",modelId:"ufoathome-balloon-prank",envelope:"open",launchVolumeM3:.25,maxVolumeM3:.25,massKg:.02,dragCoefficient:.6,aspect:1.515,widthM:.6,color:"#f4f4f4",albedo:.6,insideExcessK:60,spins:!0,sways:!0,flames:{count:4,candela:.5,color:"#ffb347",burnS:720,coolingS:15},phenomenon:"SkyLantern",durationS:1200},{id:"prank-flares",modelId:"ufoathome-balloon-prank",envelope:"open",launchVolumeM3:2,maxVolumeM3:2,massKg:.3,dragCoefficient:.6,aspect:1.515,widthM:1.2,color:"#2b2d30",albedo:.1,insideExcessK:80,spins:!0,sways:!0,flames:{count:1,candela:150,color:"#ff3a20",burnS:900,coolingS:30},phenomenon:"SkyLantern",durationS:1500},{id:"anti-hail",modelId:"ufoathome-balloon-latex",envelope:"elastic",launchVolumeM3:.65,maxVolumeM3:8,massKg:.4,dragCoefficient:.35,aspect:1.13,color:"#f2ece0",albedo:.55,torch:{aboveM:600,candela:300,color:"#ff9a3c",burnS:90,fallMS:4},phenomenon:"ParachuteFlare",durationS:1200},{id:"solar",modelId:"ufoathome-balloon-latex",envelope:"open",launchVolumeM3:14,maxVolumeM3:14,massKg:.4,dragCoefficient:.47,aspect:1.13,color:"#151515",albedo:.05,insideExcessK:10,phenomenon:"WeatherBalloonsOrMongolfieres",durationS:3600},{id:"captive",modelId:"ufoathome-balloon-latex",envelope:"sealed",tethered:!0,launchVolumeM3:14,maxVolumeM3:14,massKg:8,dragCoefficient:.47,aspect:1.13,color:"#f4f4f4",albedo:.7,phenomenon:"WeatherBalloonsOrMongolfieres",durationS:3600}];static byId(t){return he.ALL.find(e=>e.id===t)}}const tr=X.rounded,er={key:"balloons",messages:In,phenomenon:n=>{const t=typeof n.balloon=="string"?n.balloon:n.balloon?.id;return(he.byId(t)??he.ALL[0]).phenomenon},inWind:(n,t)=>{const e=n.site.altitudeM??0;return{...n,wind:tr(t.at(10)),windsAloft:t.levels.filter(r=>r>e+10).map(r=>({...tr(t.at(r)),atM:Math.round(r-e)}))}},compute:()=>d(async()=>{const{BalloonFlight:n}=await import("./BalloonFlight-CvE7AHlm.js");return{BalloonFlight:n}},[],import.meta.url).then(({BalloonFlight:n})=>t=>n.bodiesOf(t)),editor:()=>d(async()=>{const{BalloonEditor:n}=await import("./BalloonEditor-Cx3fRab8.js");return{BalloonEditor:n}},__vite__mapDeps([16,3,4,5,15,12,13,17,6,7,8]),import.meta.url).then(({BalloonEditor:n})=>(t,e,r)=>new n(t,e,r))},_n=_.catalog({en:()=>d(()=>import("./AirshipKindMessages_en-DzGapVTV.js"),[],import.meta.url).then(n=>n.airshipKindMessages_en),fr:()=>d(()=>import("./AirshipKindMessages_fr-BTXNsW5W.js"),[],import.meta.url).then(n=>n.airshipKindMessages_fr),es:()=>d(()=>import("./AirshipKindMessages_es-TE93uMSC.js"),[],import.meta.url).then(n=>n.airshipKindMessages_es),it:()=>d(()=>import("./AirshipKindMessages_it-Cwa3MnJ-.js"),[],import.meta.url).then(n=>n.airshipKindMessages_it)}),le=(n,t,e,r=5)=>({"nav-left":{color:"#ff2a1a",candela:r,leds:[{at:n,radiusM:.06}]},"nav-right":{color:"#2aff5a",candela:r,leds:[{at:t,radiusM:.06}]},tail:{color:"#ffffff",candela:r,leds:[{at:e,radiusM:.06}]}});class fe{static ALL=[{id:"blimp",modelId:"ufoathome-airship-blimp",sizeM:{widthM:14.72,lengthM:59.46,heightM:17.59},cruiseMS:15,maxSpeedMS:22,color:"#c9ccd1",finColor:"#1d3f8a",albedo:.6,sign:{color:"#fff4d8",luminanceCdM2:150,lit:!0},lights:{...le([-1.22,-8.6,-9],[1.22,-8.6,-9],[0,0,29.7]),strobe:{color:"#ffffff",candela:400,hz:1,flashS:.06,leds:[{at:[0,-10.15,-9],radiusM:.08}]}},sound:"light-piston",phenomenon:"Airship"},{id:"zeppelin-nt",modelId:"ufoathome-airship-zeppelin-nt",sizeM:{widthM:18.2,lengthM:75.11,heightM:19.55},cruiseMS:19,maxSpeedMS:35,color:"#eef0f2",finColor:"#eef0f2",albedo:.75,sign:{color:"#fff4d8",luminanceCdM2:150,lit:!1},lights:{...le([-1.32,-8.4,-14],[1.32,-8.4,-14],[0,0,37.5]),strobe:{color:"#ffffff",candela:400,hz:1,flashS:.06,leds:[{at:[0,-9.65,-14],radiusM:.08}]}},sound:"light-piston",phenomenon:"Airship"},{id:"lightship",modelId:"ufoathome-airship-lightship",sizeM:{widthM:10.16,lengthM:39.66,heightM:11.98},cruiseMS:13,maxSpeedMS:20,color:"#f4f4f2",finColor:"#f4f4f2",albedo:.7,glowCdM2:20,lights:le([-.82,-5.9,-6],[.82,-5.9,-6],[0,0,19.8]),sound:"light-piston",phenomenon:"Airship"},{id:"aerostat",modelId:"ufoathome-airship-aerostat",sizeM:{widthM:25.14,lengthM:63.6,heightM:27.05},cruiseMS:0,maxSpeedMS:0,tethered:!0,color:"#f2f2f0",finColor:"#f2f2f0",albedo:.7,lights:{nose:{color:"#ff2a1a",candela:2e3,hz:.5,flashS:.6,leds:[{at:[0,-4.2,-30],radiusM:.12}]},stern:{color:"#ff2a1a",candela:2e3,hz:.5,flashS:.6,leds:[{at:[0,-6.3,22],radiusM:.12}]}},phenomenon:"Airship"},{id:"rigid",modelId:"ufoathome-airship-rigid",sizeM:{widthM:33.38,lengthM:236.66,heightM:35.79},cruiseMS:32,maxSpeedMS:36,color:"#b9bcbf",finColor:"#b9bcbf",albedo:.55,lights:le([-3.02,-16.5,-80],[3.02,-16.5,-80],[0,0,118.3],10),sound:"piston-heavy",phenomenon:"Airship"}];static byId(t){return fe.ALL.find(e=>e.id===t)}}const rr={key:"airships",messages:_n,phenomenon:n=>{const t=typeof n.airship=="string"?n.airship:n.airship?.id;return(fe.byId(t)??fe.ALL[0]).phenomenon},compute:()=>d(async()=>{const{AirshipFlight:n}=await import("./AirshipFlight-6yYGIRn8.js");return{AirshipFlight:n}},__vite__mapDeps([18,12,13]),import.meta.url).then(({AirshipFlight:n})=>t=>n.bodiesOf(t)),editor:()=>d(async()=>{const{AirshipEditor:n}=await import("./AirshipEditor-EBfUtSiB.js");return{AirshipEditor:n}},__vite__mapDeps([19,3,4,5,15,12,13,18,8,11]),import.meta.url).then(({AirshipEditor:n})=>(t,e,r)=>new n(t,e,r))},Qr=A.point("interpretations").provide(A.BUILT_IN,[{id:We.key,name:"Decoy flares",credit:"UFO@home",creditUrl:"https://ufoathome.org/docs/format/",create:()=>We},{id:Xe.key,name:"Sky lanterns",credit:"UFO@home",creditUrl:"https://ufoathome.org/docs/format/",create:()=>Xe},{id:Je.key,name:"Birds",credit:"UFO@home",creditUrl:"https://ufoathome.org/docs/format/",create:()=>Je},{id:Qe.key,name:"Drones",credit:"UFO@home",creditUrl:"https://ufoathome.org/docs/format/",create:()=>Qe},{id:er.key,name:"Balloons",credit:"UFO@home",creditUrl:"https://ufoathome.org/docs/format/",create:()=>er},{id:rr.key,name:"Airships",credit:"UFO@home",creditUrl:"https://ufoathome.org/docs/format/",create:()=>rr}]);class $e{static kinds(){return Qr.map(t=>N.of(t))}}const to=Object.freeze(Object.defineProperty({__proto__:null,INTERPRETATION_SOURCES:Qr,InterpretationRegistry:$e},Symbol.toStringTag,{value:"Module"}));class z{static SIGHTING_EVENT="sighting";static INTERPRETATION_EVENT="interpretation";static INTERVIEW_EVENT="interview";static check(t){return ht.check(t,"case")}static isCase(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)&&Array.isArray(t.events)&&!("timeline"in t)}static sightingUrls(t,e){return(t.events??[]).filter(r=>r.eventType===z.SIGHTING_EVENT&&!r.interpretationOf&&typeof r.url=="string"&&r.url!=="").map(r=>new URL(r.url,e).href)}static accountIds(t,e,r,s){const o=(t.events??[]).filter(i=>i.eventType===z.SIGHTING_EVENT&&i.id!==void 0&&typeof i.url=="string"&&r!==void 0&&new URL(i.url,e).href===r).map(i=>i.id);return s!==void 0&&o.push(s),o}static interpretationEvents(t,e){const r=[e].flat().filter(s=>!!s);return r.length===0?[]:(t.events??[]).filter(s=>s.eventType===z.INTERPRETATION_EVENT?s.sighting!==void 0&&r.includes(s.sighting):s.eventType!==z.SIGHTING_EVENT||s.interpretationOf===void 0?!1:[s.interpretationOf].flat().some(o=>r.includes(o))).map(s=>s)}static problems(t,e){const r=t.events??[],s=new Set,o=new Set;for(const a of r)a.id!==void 0&&(s.has(a.id)&&o.add(a.id),s.add(a.id));const i=[];for(const a of r){const l=a.eventType===z.SIGHTING_EVENT?a.interpretationOf:a.eventType===z.INTERVIEW_EVENT?a.interviewOf:void 0;if(l!==void 0)for(const c of[l].flat())!s.has(c)&&!e.includes(c)&&i.push({reading:a.url??a.id??"",reference:c})}return{duplicateIds:[...o],unresolved:i}}static async interpretationOf(t,e,r){if(t.bodies)return z.withModelsFrom(j.strip({title:t.title,bodies:t.bodies??[],smoke:t.smoke,findings:t.findings,...N.computedPart(t,$e.kinds())}).recording,e);if(!t.url)return{title:t.title,bodies:[]};const s=new URL(t.url,e).href,o=await r(s),i=j.strip("timeline"in o&&o.interpretation?o.interpretation:o).recording;return z.withModelsFrom({title:t.title??i.title,bodies:i.bodies??[],smoke:i.smoke,findings:i.findings,...N.computedPart(i,$e.kinds())},s)}static withModelsFrom(t,e){return{...t,bodies:t.bodies.map(r=>r.model?.url?{...r,model:{...r.model,url:new URL(r.model.url,e).href}}:r)}}}class F{static files=new Map;static hold(t){for(const[e,r]of t)F.files.set(F.key(e),r)}static releaseCopies(){for(const[t,e]of F.files)e.local||F.files.delete(t)}static clear(){F.files.clear()}static localBase(){return new URL(`local/${Date.now().toString(36)}${Math.random().toString(36).slice(2,6)}/`,location.href).href}static read(t){const e=F.files.get(F.key(t));return e===void 0?void 0:structuredClone(e.json)}static changed(...t){return t.some(e=>e!==void 0&&F.files.get(F.key(e))?.changed===!0)}static local(t){return t!==void 0&&F.files.get(F.key(t))?.local===!0}static key(t){const e=new URL(t,location.href);return e.hash="",e.href}}class Q{static NAMES=["weather","place","lightPollution","decor"];static KEYS={weather:["weatherTrack","weatherSource"],place:["place"],lightPollution:["lightPollution"],decor:["decor"]};static annexName(t,e){return`${t}.${e.replace(/[A-Z]/g,r=>`-${r.toLowerCase()}`)}.json`}static taken(t,e){const r={};if(t==="decor")return Array.isArray(e.decor)&&(r.decor=e.decor.filter(Q.surveyed)),r;for(const s of Q.KEYS[t])e[s]!==void 0&&(r[s]=e[s]);return r}static strip(t,e){if(t==="decor"){const r=Array.isArray(e.decor)?e.decor.filter(s=>!Q.surveyed(s)):[];r.length>0?e.decor=r:delete e.decor;return}for(const r of Q.KEYS[t])delete e[r]}static put(t,e,r){if(t==="decor"){if(!Array.isArray(r.decor))return;const s=Array.isArray(e.decor)?e.decor.filter(o=>!Q.surveyed(o)):[];e.decor=[...s,...r.decor];return}for(const s of Q.KEYS[t])r[s]!==void 0&&(e[s]=r[s])}static surveyed(t){return typeof t=="object"&&t!==null&&typeof t.origin=="string"}static fromFile(t,e){return t?.[e]!==void 0&&t[e].live!==!0}}class tn{static NAMES=["relief","imagery","roads","water","railways","upperAir","map"];static TERRAIN=["relief","imagery","roads","water","railways"];static held(t,e){if(!t||t.live)return;const r=t[e];return r&&!r.live&&!r.refresh&&r.src!==void 0?r:void 0}static isLive(t,e){return t?.live===!0||t?.[e]?.live===!0}static annexName(t,e){const r=e==="relief"||e==="imagery"||e==="map"?"zip":"json",s=e.replace(/[A-Z]/g,o=>`-${o.toLowerCase()}`);return`${t}.${s}.${r}`}static isEmpty(t){return!t||!t.live&&tn.NAMES.every(e=>!t[e])&&Q.NAMES.every(e=>!t[e])}}class xt extends Error{constructor(t,e,r){super(`${t}: ${e}${r===void 0?"":` (HTTP ${r})`}`),this.kind=t,this.url=e,this.status=r,this.name="SightingFetchError"}}class jt{static async recording(t){const e=F.read(t);if(e!==void 0)return e;const r=await jt.json(t);for(const s of Q.NAMES){const o=r?.snapshots?.[s];if(!(!o?.src||o.live))try{const i=ht.recording(await jt.json(new URL(o.src,new URL(t,location.href)).href));Q.put(s,r,i)}catch{}}return r}static async json(t){const e=new URL(t,location.href),r=F.read(e.href);if(r!==void 0)return r;if(location.protocol==="https:"&&e.protocol==="http:")throw new xt("mixed-content",t);let s;try{s=await fetch(t)}catch{throw await this.diagnose(t,e)}if(!s.ok)throw new xt("status",t,s.status);try{return await s.json()}catch{throw new xt("malformed",t)}}static async diagnose(t,e){if(e.origin===location.origin)return new xt("unreachable",t);try{return await fetch(t,{mode:"no-cors"}),new xt("cors",t)}catch{return new xt("unreachable",t)}}}const eo=Object.freeze(Object.defineProperty({__proto__:null,SightingFetch:jt,SightingFetchError:xt},Symbol.toStringTag,{value:"Module"}));class Pe{constructor(t,e,r=()=>{}){this.place=t,this.changed=r,e&&this.adopt(e)}reader;editor;handed;get reading(){return this.reader!==void 0}get editorLoaded(){return this.editor!==void 0}adopt(t){this.editor=t,t.switcher=this,t.hasAttribute(ve)||t.setAttribute(ve,""),t.addEventListener(gn,e=>{e.preventDefault();const r=e.detail;this.handed=r.src,this.read(r)})}async read({src:t,track:e}){const[{register:r,CASE_ELEMENT_NAME:s,OPEN_EVENTS_ATTRIBUTE:o},{registerSighting:i,SIGHTING_ELEMENT_NAME:a}]=await Promise.all([d(()=>import("./CaseElement-BGO5UZLP.js"),__vite__mapDeps([20,21,22,6,7,23,3,4,13,24,25,1,26]),import.meta.url),d(()=>import("./SightingElement-DzxTvvLN.js"),__vite__mapDeps([26,22,6,7,23,3,4,13,24,25,1]),import.meta.url)]);i(),r();const l=z.isCase(F.read(t)??await jt.json(t)),c=document.createElement(l?s:a);c.setAttribute(ve,""),c.setAttribute("show-labels",""),l&&e&&c.setAttribute(o,Pe.fileKey(e)),c.setAttribute("src",t),c.addEventListener(wn,m=>{m.preventDefault(),this.edit(m.detail)}),this.reader?.remove(),this.place(c),this.editor&&(this.editor.hidden=!0),this.reader=c,this.changed({mode:"read",src:t,...e?{track:e}:{}})}async edit(t){const e=this.editor;if(e){if(this.dropReader(),F.releaseCopies(),e.hidden=!1,this.changed({mode:"edit"}),t?.src!==void 0&&t.src!==this.handed){this.load(e,t.src,t.track);return}t?.track&&await e.openTrack(t.track);return}const{register:r,CASE_EDITOR_ELEMENT_NAME:s}=await d(async()=>{const{register:i,CASE_EDITOR_ELEMENT_NAME:a}=await import("./CaseEditorElement-BOp207Tr.js").then(l=>l.a);return{register:i,CASE_EDITOR_ELEMENT_NAME:a}},__vite__mapDeps([27,3,4,8,21,22,6,7,23,13,24,25,1,28,29,11,30,31,32,33]),import.meta.url);r();const o=document.createElement(s);this.adopt(o),t?.track&&o.setAttribute("track",t.track),t?.src?o.setAttribute("src",t.src):t?.start&&(o.caseStart=t.start),this.dropReader(),this.place(o),this.changed({mode:"edit"})}async open(t){const e=this.editor;if(this.reading||!e)return this.read({src:t});this.load(e,t)}load(t,e,r){this.handed=void 0,r?t.setAttribute("track",r):t.removeAttribute("track"),t.setAttribute("src",e)}async startNew(t){const e=this.editor;if(!e)return this.edit(t?{start:t}:void 0);this.reading&&await this.edit(),e.askBeforeReplacing(()=>{e.remove(),this.editor=void 0,this.edit(t?{start:t}:void 0)})}dropReader(){this.reader?.remove(),this.reader=void 0}static fileKey(t){return new URL(t,location.href).pathname.split("/").pop().replace(/\.json$/i,"")}}const Fe="rr0-input-file",en={inputFileFromFile:"from your disk",inputFileFromUrl:"from an address",inputFileModeHint:"Click to give it the other way: a file of yours, or an address",inputFileLoad:"Load"},Nn=`
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./SkyLantern-DJT_Ibzh.js","./Obstacles-v9SkfBD7.js","./LanternEditor-DEeA3Kf_.js","./SaidPosition-OJEYhVKN.js","./GeoProjection-DvqDbRIx.js","./SkyEventEditorStyle-CvY_AhbI.js","./Sighting-C1yj2-s5.js","./VisualAids-DI-hEL46.js","./ParameterForm-XbqxCLRn.js","./BirdFlock-ByBkJV35.js","./BirdEditor-CBVGyUnK.js","./TimelineTracks-Daaqw9ly.js","./DroneFlight-CGNIh9XS.js","./Decor-Dn-cvniW.js","./DroneEditor-7X9CM_3H.js","./DroneParameters-CfTAaLCT.js","./BalloonEditor-BBAtMeVM.js","./BalloonFlight-CvE7AHlm.js","./AirshipFlight-6yYGIRn8.js","./AirshipEditor-EBfUtSiB.js","./CaseElement-Bm6xPD0e.js","./ColumnResize-DksRZriL.js","./ShareDialogElement-DMDY7Hlo.js","./three.module-CbaHqYFq.js","./RecordingIssue-BlWT8Xsu.js","./xyzImageryRaster-Dhxs0B26.js","./SightingElement-DZlh5u4N.js","./CaseEditorElement-CK82yjEn.js","./PoherSelfCheck-BjmenygA.js","./PoherMatrix-C2fcLqDH.js","./ReentryArchive-CeXHrU7L.js","./ReferenceTimeline-2kBldQeG.js","./upperAirSources-BU0pD84c.js","./Account-C4jhsVtN.js","./UfoMessages_en-D5OYWJ3K.js","./SightingEditorMessages_en-CS2iXwDm.js","./SightingLabels_en-trAaLk8Q.js","./SightingEditorMessages_fr-AYgrnKFD.js","./SightingLabels_fr-BVnntoiD.js","./SightingEditorMessages_es-C8Vw_4b_.js","./SightingLabels_es-Geji-Hhz.js","./SightingEditorMessages_it-DZyzwScx.js","./SightingLabels_it-B9FWbLXW.js","./SightingMessages_en-D90vDTQ7.js","./SightingMessages_fr-Gq3IMFTE.js","./SightingMessages_es-D8laK6OY.js","./SightingMessages_it-BXDxv-lE.js","./UfoAtHomeMessages_en-ByVu39KF.js","./ConsentMessages_en-DBKCeDAn.js","./UfoAtHomeMessages_fr-nTqRf0ZK.js","./ConsentMessages_fr-FGSpqzMc.js","./UfoAtHomeMessages_es-D9bLboxq.js","./ConsentMessages_es-Dby74lUq.js","./UfoAtHomeMessages_it-4cZC5-y5.js","./ConsentMessages_it-BJWfXH6I.js","./SceneNames_en-sRbx6EJZ.js","./SceneNames_fr-BtTlti4C.js","./SceneNames_es-pnfHB-7D.js","./SceneNames_it-DQKwdCVD.js","./ModuleSession-Dac4fD0X.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
const hn="modulepreload",fn=function(n,t){return new URL(n,t).href},ze={},d=function(t,e,r){let s=Promise.resolve();if(e&&e.length>0){let i=function(m){return Promise.all(m.map(p=>Promise.resolve(p).then(f=>({status:"fulfilled",value:f}),f=>({status:"rejected",reason:f}))))};const a=document.getElementsByTagName("link"),l=document.querySelector("meta[property=csp-nonce]"),c=l?.nonce||l?.getAttribute("nonce");s=i(e.map(m=>{if(m=fn(m,r),m in ze)return;ze[m]=!0;const p=m.endsWith(".css"),f=p?'[rel="stylesheet"]':"";if(!!r)for(let E=a.length-1;E>=0;E--){const G=a[E];if(G.href===m&&(!p||G.rel==="stylesheet"))return}else if(document.querySelector(`link[href="${m}"]${f}`))return;const S=document.createElement("link");if(S.rel=p?"stylesheet":hn,p||(S.as="script"),S.crossOrigin="",S.href=m,c&&S.setAttribute("nonce",c),document.head.appendChild(S),p)return new Promise((E,G)=>{S.addEventListener("load",E),S.addEventListener("error",()=>G(new Error(`Unable to preload CSS for ${m}`)))})}))}function o(i){const a=new Event("vite:preloadError",{cancelable:!0});if(a.payload=i,window.dispatchEvent(a),!a.defaultPrevented)throw i}return s.then(i=>{for(const a of i||[])a.status==="rejected"&&o(a.reason);return t().catch(o)})},gn="rr0-read",wn="rr0-edit",ve="in-place",yn="rr0-mode";class Xs{static ask(t,e,r){const s=new CustomEvent(e,{detail:r,bubbles:!0,composed:!0,cancelable:!0});return t.dispatchEvent(s),s.defaultPrevented}}class j{constructor(t){this.entries=t}static same(t,e){return typeof t=="number"&&typeof e=="number"?t===e||Math.abs(t-e)<=1e-9*Math.max(1,Math.abs(t),Math.abs(e)):Array.isArray(t)&&Array.isArray(e)?t.length===e.length&&t.every((r,s)=>j.same(r,e[s])):typeof t=="object"&&t!==null&&typeof e=="object"&&e!==null&&!Array.isArray(t)&&!Array.isArray(e)?[...new Set([...Object.keys(t),...Object.keys(e)])].every(s=>j.same(t[s],e[s])):t===e}static free(t){return t?.basis==="assumed"||t?.basis==="fitted"}static empty(){return new j(new Map)}get size(){return this.entries.size}at(t){return this.entries.get(t)}paths(){return[...this.entries.keys()]}sourced(){return[...this.entries].filter(([,t])=>t.source!==void 0).map(([t,e])=>({path:t,basis:e.basis,source:e.source}))}interviewsCited(){const t=[];for(const{source:e}of this.sourced()){const r=e.said?.interview;r!==void 0&&!t.includes(r)&&t.push(r)}return t}pathsFromInterview(t){return this.sourced().filter(({source:e})=>e.said!==void 0&&e.said.interview===t).map(({path:e})=>e)}set(t,e){e.basis==="stated"&&e.rationale===void 0&&e.how===void 0&&e.range===void 0&&e.source===void 0?this.entries.delete(t):this.entries.set(t,e)}clear(t){for(const e of this.entries.keys())(e===t||e.startsWith(`${t}.`))&&this.entries.delete(e)}static strip(t){const e=new j(new Map);return{recording:j.stripValue(t,[],e),provenance:e}}static restore(t,e){if(e.size===0)return t;const r={...t},s=new Set([r]);for(const o of e.paths()){const i=e.at(o),a=o.split("."),l=j.writableHolderOf(r,a,s);if(!l)continue;const c=a[a.length-1],m=l[c];m!==void 0&&(i.of!==void 0&&!j.same(i.of,m)||(l[c]={value:m,...i.basis==="stated"?{}:{basis:i.basis},...i.rationale===void 0?{}:{rationale:i.rationale},...i.how===void 0?{}:{how:i.how},...i.range===void 0?{}:{range:i.range},...i.source===void 0?{}:{source:i.source}}))}return r}static isWrapper(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)&&"value"in t}static stripValue(t,e,r){return j.isWrapper(t)?(r.set(e.join("."),{basis:t.basis??"stated",...t.rationale===void 0?{}:{rationale:t.rationale},...t.how===void 0?{}:{how:t.how},...t.range===void 0?{}:{range:t.range},...t.source===void 0?{}:{source:t.source},of:t.value}),j.stripValue(t.value,e,r)):Array.isArray(t)?t.map((s,o)=>j.stripValue(s,[...e,String(o)],r)):typeof t=="object"&&t!==null?Object.fromEntries(Object.entries(t).map(([s,o])=>[s,j.stripValue(o,[...e,s],r)])):t}static writableHolderOf(t,e,r){let s=t;for(const o of e.slice(0,-1)){const i=s[o];if(typeof i!="object"||i===null)return;if(r.has(i)){s=i;continue}const a=Array.isArray(i)?[...i]:{...i};r.add(a),s[o]=a,s=a}return s}}class bn extends Error{constructor(t,e,r){super(typeof e=="number"&&Number.isInteger(e)&&e>=1?`This ${t} file is in version ${e} of its format; this UFO@home reads version ${r}. Read it with the UFO@home that reads its version.`:`This ${t} file states ${JSON.stringify(e)} as its format version, which is not a version.`),this.format=t,this.found=e,this.supported=r,this.name="FormatVersionError"}said(t){return t.replace("{found}",typeof this.found=="number"?String(this.found):JSON.stringify(this.found)).replace("{supported}",String(this.supported))}}class ht{static CURRENT={sighting:4,case:1,interview:1};static SCHEMA_BASE="https://ufoathome.org/schema";static schemaUrl(t,e=ht.CURRENT[t]){return`${ht.SCHEMA_BASE}/${e}/${t}.schema.json`}static of(t){if(typeof t!="object"||t===null)return 1;const e=t.version;return e===void 0?1:typeof e=="object"&&e!==null&&"value"in e?e.value:e}static recording(t){return ht.check(t,"sighting")}static check(t,e){const r=ht.of(t),s=ht.CURRENT[e];if(typeof r!="number"||!Number.isInteger(r)||r!==s)throw new bn(e,r,s);return t}}class N{static built=new WeakMap;static computers=new WeakMap;static loading=new WeakMap;static loaded(t,e){return e.every(r=>N.itemsOf(t,r.key).length===0||N.computers.has(r))}static load(t,e){return Promise.all(e.filter(r=>N.itemsOf(t,r.key).length>0&&!N.computers.has(r)).map(r=>{let s=N.loading.get(r);return s||(s=r.compute().then(o=>{N.computers.set(r,o)}),s.catch(()=>N.loading.delete(r)),N.loading.set(r,s)),s.catch(()=>{})})).then(()=>{})}static of(t){let e=N.built.get(t);return e||(e=t.create(),N.built.set(t,e)),e}static itemsOf(t,e){const r=t?.[e];return Array.isArray(r)?r:[]}static computes(t,e){return e.some(r=>N.itemsOf(t,r.key).length>0)}static expand(t,e,r){return N.expandWithKinds(t,e,r).interpretation}static expandWithKinds(t,e,r){const s=new Map,o=new Map;if(!t||!N.computes(t,e))return{interpretation:t,kindOf:s,phenomenonOf:o};const i=e.flatMap(a=>N.itemsOf(t,a.key).flatMap(l=>{const c=N.computers.get(a);if(!c)return[];const m=c(l,r),p=a.phenomenon?.(l);for(const f of m)s.set(f.id,a),p&&o.set(f.id,p);return m}));return{interpretation:{...t,bodies:[...t.bodies,...i]},kindOf:s,phenomenonOf:o}}static phenomena(t,e){const r=new Set;for(const s of e)for(const o of N.itemsOf(t,s.key)){const i=s.phenomenon?.(o);i&&r.add(i)}return r}static computedPart(t,e){const r={};for(const s of e){const o=N.itemsOf(t,s.key);o.length>0&&(r[s.key]=[...o])}return r}static saysNothing(t,e){return t.bodies.length===0&&t.title===void 0&&t.smoke===void 0&&e.every(r=>t[r.key]===void 0)}}const Js=Object.freeze(Object.defineProperty({__proto__:null,InterpretationKinds:N},Symbol.toStringTag,{value:"Module"}));class Zr extends Error{constructor(t,e,r,s){super(`Module "${t}" gives "${r}" at ${e}, which module "${s}" already gives`),this.moduleId=t,this.point=e,this.sourceId=r,this.ownerId=s,this.name="ModuleConflictError"}}class En{constructor(t){this.id=t}sources=[];owners=new Map;ownerOf(t){return this.owners.get(t)}conflict(t,e){for(const r of e){const s=this.owners.get(r.id);if(s!==void 0&&s!==t)return{sourceId:r.id,ownerId:s}}}provide(t,e){const r=this.conflict(t,e);if(r)throw new Zr(t,this.id,r.sourceId,r.ownerId);this.withdraw(t);const s=t===A.BUILT_IN?this.sources.findIndex(o=>this.owners.get(o.id)!==A.BUILT_IN):-1;s<0?this.sources.push(...e):this.sources.splice(s,0,...e);for(const o of e)this.owners.set(o.id,t);return this.sources}withdraw(t){for(let e=this.sources.length-1;e>=0;e--){const r=this.sources[e].id;this.owners.get(r)===t&&(this.sources.splice(e,1),this.owners.delete(r))}}}class A{static BUILT_IN="ufoathome";static changes=new EventTarget;static points=new Map;static modules=new Map;static point(t){let e=A.points.get(t);return e||(e=new En(t),A.points.set(t,e)),e}static install(t){if(t.id===A.BUILT_IN)throw new Error(`"${A.BUILT_IN}" is the id of the built-in module`);const e=A.contributionsOf(t);for(const[o,i]of e){const a=A.point(o).conflict(t.id,i);if(a)throw new Zr(t.id,o,a.sourceId,a.ownerId)}const r=new Set(e.map(([o])=>o)),s=A.modules.get(t.id);if(s)for(const[o]of A.contributionsOf(s))r.add(o);for(const o of r)A.point(o).withdraw(t.id);for(const[o,i]of e)A.point(o).provide(t.id,i);A.modules.set(t.id,t);for(const o of r)A.announce(o)}static uninstall(t){const e=A.modules.get(t);if(e){A.modules.delete(t);for(const[r]of A.contributionsOf(e))A.point(r).withdraw(t),A.announce(r)}}static installed(){return[...A.modules.values()]}static contributionsOf(t){return Object.entries(t.contributes).filter(e=>Array.isArray(e[1])&&e[1].length>0)}static announce(t){A.changes.dispatchEvent(new CustomEvent("change",{detail:t}))}}const Sn=["en","fr","es","it"];class _{static catalog(t){const e=new Map;return{load(r){const s=_.languageOf(r);let o=e.get(s);return o||(o=t[s](),e.set(s,o),o.catch(()=>e.delete(s))),o}}}static none(){return new Proxy({},{get:()=>""})}static blank(){const t=new Proxy(()=>t,{get:(e,r)=>r===Symbol.toPrimitive?()=>"":r===Symbol.iterator?function*(){}:r==="toString"||r==="valueOf"?()=>"":r==="then"?void 0:t,apply:()=>t,has:()=>!1,ownKeys:()=>[],getOwnPropertyDescriptor:()=>{}});return t}static languageOf(t){const e=t.toLowerCase().split("-")[0];return Sn.includes(e)?e:"en"}}const vn=_.catalog({en:()=>d(()=>import("./FlareKindMessages_en-j3CY_TxX.js"),[],import.meta.url).then(n=>n.flareKindMessages_en),fr:()=>d(()=>import("./FlareKindMessages_fr-B2MezoN2.js"),[],import.meta.url).then(n=>n.flareKindMessages_fr),es:()=>d(()=>import("./FlareKindMessages_es-CZgrFIOO.js"),[],import.meta.url).then(n=>n.flareKindMessages_es),it:()=>d(()=>import("./FlareKindMessages_it-CmZmb3RP.js"),[],import.meta.url).then(n=>n.flareKindMessages_it)});class nt{constructor(t={}){this.options=t,this.fetchImpl=t.fetchImpl??fetch.bind(globalThis),this.wait=t.wait??(e=>new Promise(r=>setTimeout(r,e)))}static URL="https://historical-forecast-api.open-meteo.com/v1/forecast";static CREDIT="Open-Meteo historical forecast";static LEVELS=[850,700,600,500,400,300];static RETRIES=6;static RETRY_MS=2e3;days=new Map;fetchImpl;wait;async profile(t,e,r){const o=new Date(Math.floor(r.getTime()/36e5)*36e5),i=(r.getTime()-o.getTime())/36e5,a=await this.hourly(t,e,o);if(i<1e-6)return a;const l=await this.hourly(t,e,new Date(o.getTime()+36e5));return a.levels.length!==l.levels.length?i<.5?a:l:{...a,hour:r.toISOString().slice(0,16),levels:a.levels.map((c,m)=>{const[p,f]=X.vector(c.wind),[y,S]=X.vector(l.levels[m].wind);return{aboveGroundM:c.aboveGroundM+i*(l.levels[m].aboveGroundM-c.aboveGroundM),wind:X.fromVector(p+i*(y-p),f+i*(S-f))}})}}async hourly(t,e,r){const s=r.toISOString().slice(0,13)+":00",o=s.slice(0,10),i=`${t.toFixed(4)},${e.toFixed(4)},${o}`;let a=this.days.get(i);return a||(a=this.day(t,e,o,i),a.catch(()=>this.days.delete(i)),this.days.set(i,a)),nt.profileOf(await a,s)}static profileOf(t,e){const r=t.hourly,s=r.time.indexOf(e);if(s<0)throw new Error(`No wind for ${e} in the archive's answer`);const o=c=>(c+180)%360,i=[],a=r.wind_speed_10m?.[s],l=r.wind_direction_10m?.[s];typeof a=="number"&&typeof l=="number"&&i.push({aboveGroundM:10,wind:{towardDeg:o(l),speedMS:a}});for(const c of nt.LEVELS){const m=r[`geopotential_height_${c}hPa`]?.[s],p=r[`wind_speed_${c}hPa`]?.[s],f=r[`wind_direction_${c}hPa`]?.[s];if(typeof m!="number"||typeof p!="number"||typeof f!="number")continue;const y=m-t.elevation;y<=(i[i.length-1]?.aboveGroundM??0)||i.push({aboveGroundM:y,wind:{towardDeg:o(f),speedMS:p}})}if(i.length===0)throw new Error(`No wind for ${e} in the archive's answer`);return{lat:t.latitude,lng:t.longitude,elevationM:t.elevation,hour:e,levels:i,credit:nt.CREDIT}}async day(t,e,r,s){const o=await this.options.cache?.get(s);if(o)return JSON.parse(o);const i=["wind_speed_10m","wind_direction_10m",...nt.LEVELS.flatMap(c=>[`wind_speed_${c}hPa`,`wind_direction_${c}hPa`,`geopotential_height_${c}hPa`])],a=new URLSearchParams({latitude:String(t),longitude:String(e),start_date:r,end_date:r,hourly:i.join(","),wind_speed_unit:"ms",timezone:"GMT"}),l=`${this.options.url??nt.URL}?${a}`;for(let c=0;;c++){const m=await this.fetchImpl(l);if(m.ok){const p=await m.text();return await this.options.cache?.set(s,p),JSON.parse(p)}if((m.status===429||m.status>=500)&&c<nt.RETRIES){await this.wait(nt.RETRY_MS*2**c);continue}throw new Error(`The wind archive answered ${m.status} for ${s}`)}}}class X{static at(t,e){const r=t.levels;if(e<=r[0].aboveGroundM)return{...r[0].wind};for(let s=1;s<r.length;s++){const o=r[s-1],i=r[s];if(e<=i.aboveGroundM){const a=(e-o.aboveGroundM)/(i.aboveGroundM-o.aboveGroundM),[l,c]=X.vector(o.wind),[m,p]=X.vector(i.wind);return X.fromVector(l+a*(m-l),c+a*(p-c))}}return{...r[r.length-1].wind}}static vector(t){const e=t.towardDeg*Math.PI/180;return[t.speedMS*Math.sin(e),t.speedMS*Math.cos(e)]}static fromVector(t,e){return{towardDeg:(Math.atan2(t,e)*180/Math.PI+360)%360,speedMS:Math.hypot(t,e)}}static rounded(t){return{towardDeg:Math.round(t.towardDeg)%360,speedMS:Math.round(t.speedMS*100)/100}}}const Zs=Object.freeze(Object.defineProperty({__proto__:null,OpenMeteoWindProfiles:nt,Winds:X},Symbol.toStringTag,{value:"Module"})),xn=X.rounded,We={key:"flares",messages:vn,phenomenon:()=>"DecoyFlare",inWind:(n,t)=>({...n,wind:xn(t.at(n.aircraft.altitudeM))}),compute:()=>d(async()=>{const{DecoyFlare:n}=await import("./DecoyFlare-DUt1_LcW.js");return{DecoyFlare:n}},[],import.meta.url).then(({DecoyFlare:n})=>t=>n.bodiesOf(t))},Mn=_.catalog({en:()=>d(()=>import("./LanternKindMessages_en-CQXdJ-k6.js"),[],import.meta.url).then(n=>n.lanternKindMessages_en),fr:()=>d(()=>import("./LanternKindMessages_fr-D7tQa_tQ.js"),[],import.meta.url).then(n=>n.lanternKindMessages_fr),es:()=>d(()=>import("./LanternKindMessages_es-BOO6kPjs.js"),[],import.meta.url).then(n=>n.lanternKindMessages_es),it:()=>d(()=>import("./LanternKindMessages_it-B8J-29Mj.js"),[],import.meta.url).then(n=>n.lanternKindMessages_it)}),Ye=X.rounded,Xe={key:"lanterns",messages:Mn,phenomenon:()=>"SkyLantern",inWind:(n,t)=>{const e=n.site.altitudeM??0,r=n.windAloft?.atM??1e3;return{...n,wind:Ye(t.at(10)),windAloft:{...Ye(t.at(e+r)),atM:r}}},compute:()=>d(async()=>{const{SkyLantern:n}=await import("./SkyLantern-DJT_Ibzh.js");return{SkyLantern:n}},__vite__mapDeps([0,1]),import.meta.url).then(({SkyLantern:n})=>(t,e)=>n.bodiesOf(t,e?.obstacles)),editor:()=>d(async()=>{const{LanternEditor:n}=await import("./LanternEditor-DEeA3Kf_.js");return{LanternEditor:n}},__vite__mapDeps([2,3,4,5,0,1,6,7,8]),import.meta.url).then(({LanternEditor:n})=>(t,e,r)=>new n(t,e,r))},An=_.catalog({en:()=>d(()=>import("./BirdKindMessages_en-c_-L7frF.js"),[],import.meta.url).then(n=>n.birdKindMessages_en),fr:()=>d(()=>import("./BirdKindMessages_fr-C1TuqqEj.js"),[],import.meta.url).then(n=>n.birdKindMessages_fr),es:()=>d(()=>import("./BirdKindMessages_es-8Zo2t0o4.js"),[],import.meta.url).then(n=>n.birdKindMessages_es),it:()=>d(()=>import("./BirdKindMessages_it-DQZcrCkf.js"),[],import.meta.url).then(n=>n.birdKindMessages_it)}),Je={key:"birds",messages:An,phenomenon:()=>"Birds",compute:()=>d(async()=>{const{BirdFlock:n}=await import("./BirdFlock-ByBkJV35.js").then(t=>t.b);return{BirdFlock:n}},__vite__mapDeps([9,1]),import.meta.url).then(({BirdFlock:n})=>(t,e)=>n.bodiesOf(t,e?.obstacles)),editor:()=>d(async()=>{const{BirdEditor:n}=await import("./BirdEditor-CBVGyUnK.js");return{BirdEditor:n}},__vite__mapDeps([10,3,4,5,9,1,8,11]),import.meta.url).then(({BirdEditor:n})=>(t,e,r)=>new n(t,e,r))},Tn=_.catalog({en:()=>d(()=>import("./DroneKindMessages_en-CLygXcsv.js"),[],import.meta.url).then(n=>n.droneKindMessages_en),fr:()=>d(()=>import("./DroneKindMessages_fr-CAX15_pk.js"),[],import.meta.url).then(n=>n.droneKindMessages_fr),es:()=>d(()=>import("./DroneKindMessages_es-B9XFRYnQ.js"),[],import.meta.url).then(n=>n.droneKindMessages_es),it:()=>d(()=>import("./DroneKindMessages_it-CSGsCaJQ.js"),[],import.meta.url).then(n=>n.droneKindMessages_it)}),Ze={quadcopter:"ConsumerDrone",saucer:"ConsumerDrone","fixed-wing":"MilitaryDrone"},Qe={key:"drones",messages:Tn,phenomenon:n=>Ze[n.airframe]??Ze.quadcopter,compute:()=>d(async()=>{const{DroneFlight:n}=await import("./DroneFlight-CGNIh9XS.js").then(t=>t.c);return{DroneFlight:n}},__vite__mapDeps([12,13]),import.meta.url).then(({DroneFlight:n})=>t=>n.bodiesOf(t)),editor:()=>d(async()=>{const{DroneEditor:n}=await import("./DroneEditor-7X9CM_3H.js");return{DroneEditor:n}},__vite__mapDeps([14,3,4,5,15,12,13,8,11]),import.meta.url).then(({DroneEditor:n})=>(t,e,r)=>new n(t,e,r))},In=_.catalog({en:()=>d(()=>import("./BalloonKindMessages_en-C6tZ-5gT.js"),[],import.meta.url).then(n=>n.balloonKindMessages_en),fr:()=>d(()=>import("./BalloonKindMessages_fr-C3QJIuDJ.js"),[],import.meta.url).then(n=>n.balloonKindMessages_fr),es:()=>d(()=>import("./BalloonKindMessages_es-BfoEjhe1.js"),[],import.meta.url).then(n=>n.balloonKindMessages_es),it:()=>d(()=>import("./BalloonKindMessages_it-CkO7mqHp.js"),[],import.meta.url).then(n=>n.balloonKindMessages_it)}),Qs=["round","star","heart","figure"];class he{static HELIUM_KG_MOL=.0040026;static ALL=[{id:"hot-air",modelId:"ufoathome-balloon-hot-air",envelope:"open",launchVolumeM3:2550,maxVolumeM3:2550,massKg:540,dragCoefficient:.5,aspect:1.461,widthM:16.5,color:"#c8202f",stripeColor:"#f5c400",albedo:.4,burner:{heatingKS:1.2,coolingS:400,blastS:6,maxExcessK:100,flameCdM2:2e4,envelopeCdM2:40,color:"#ffb347"},phenomenon:"WeatherBalloonsOrMongolfieres",durationS:3600},{id:"party",modelId:"ufoathome-balloon-latex",envelope:"elastic",launchVolumeM3:.0115,maxVolumeM3:.0335,massKg:.0045,dragCoefficient:.47,aspect:1.13,color:"#d8263a",albedo:.35,phenomenon:"WeatherBalloonsOrMongolfieres",durationS:3600},{id:"led",modelId:"ufoathome-balloon-led",envelope:"elastic",launchVolumeM3:.0141,maxVolumeM3:.041,massKg:.0075,dragCoefficient:.47,aspect:1.115,color:"#ffffff",albedo:.5,glow:{candela:.5,color:"#ffffff"},phenomenon:"LedBalloon",durationS:3600},{id:"foil",modelId:"ufoathome-balloon-foil",envelope:"vented",launchVolumeM3:.014,maxVolumeM3:.014,massKg:.01,dragCoefficient:.6,aspect:1.034,widthM:.45,depthRatio:.267,color:"#c9cdd2",albedo:.85,finish:"mirror",spins:!0,shapes:{round:{modelId:"ufoathome-balloon-foil",aspect:1.034,widthM:.45,depthRatio:.267,launchVolumeM3:.014,maxVolumeM3:.014,massKg:.01,color:"#c9cdd2"},star:{modelId:"ufoathome-balloon-foil-star",aspect:1.029,widthM:.5,depthRatio:.183,launchVolumeM3:.012,maxVolumeM3:.012,massKg:.009,color:"#e0b83a"},heart:{modelId:"ufoathome-balloon-foil-heart",aspect:.903,widthM:.5,depthRatio:.2,launchVolumeM3:.014,maxVolumeM3:.014,massKg:.01,color:"#d81e3c"},figure:{modelId:"ufoathome-balloon-foil-figure",aspect:1.112,widthM:.8,depthRatio:.127,launchVolumeM3:.05,maxVolumeM3:.05,massKg:.03,color:"#f0a3c8"}},phenomenon:"FoilBalloon",durationS:3600},{id:"pilot",modelId:"ufoathome-balloon-latex",envelope:"elastic",launchVolumeM3:.144,maxVolumeM3:.57,massKg:.045,dragCoefficient:.4,aspect:1.13,color:"#f0e6cf",albedo:.55,lamp:{candela:1,color:"#fff1c4"},phenomenon:"WeatherBalloonsOrMongolfieres",durationS:5400},{id:"weather",modelId:"ufoathome-balloon-latex",envelope:"elastic",launchVolumeM3:1.75,maxVolumeM3:118.9,massKg:.85,dragCoefficient:.3,aspect:1.13,color:"#f2ece0",albedo:.55,phenomenon:"WeatherBalloonsOrMongolfieres",durationS:7200},{id:"stratospheric",modelId:"ufoathome-balloon-stratospheric",envelope:"vented",launchVolumeM3:219,maxVolumeM3:14e3,massKg:210,dragCoefficient:.4,aspect:.91,color:"#e9eef2",albedo:.8,ballastKg:20,phenomenon:"StratosphericBalloons",durationS:10800},{id:"stratospheric-large",modelId:"ufoathome-balloon-stratospheric",envelope:"vented",launchVolumeM3:730,maxVolumeM3:15e4,massKg:700,dragCoefficient:.4,aspect:.91,color:"#e9eef2",albedo:.8,ballastKg:140,phenomenon:"StratosphericBalloons",durationS:14400},{id:"superpressure",modelId:"ufoathome-balloon-latex",envelope:"superpressure",launchVolumeM3:45,maxVolumeM3:523,massKg:44,dragCoefficient:.4,aspect:1.13,color:"#eef1f4",albedo:.8,phenomenon:"StratosphericBalloons",durationS:10800},{id:"infrared",modelId:"ufoathome-balloon-stratospheric",envelope:"open",launchVolumeM3:2075,maxVolumeM3:45e3,massKg:150,dragCoefficient:.4,aspect:.91,color:"#9aa0a8",albedo:.4,insideExcessK:20,phenomenon:"StratosphericBalloons",durationS:10800},{id:"prank-candles",modelId:"ufoathome-balloon-prank",envelope:"open",launchVolumeM3:.25,maxVolumeM3:.25,massKg:.02,dragCoefficient:.6,aspect:1.515,widthM:.6,color:"#f4f4f4",albedo:.6,insideExcessK:60,spins:!0,sways:!0,flames:{count:4,candela:.5,color:"#ffb347",burnS:720,coolingS:15},phenomenon:"SkyLantern",durationS:1200},{id:"prank-flares",modelId:"ufoathome-balloon-prank",envelope:"open",launchVolumeM3:2,maxVolumeM3:2,massKg:.3,dragCoefficient:.6,aspect:1.515,widthM:1.2,color:"#2b2d30",albedo:.1,insideExcessK:80,spins:!0,sways:!0,flames:{count:1,candela:150,color:"#ff3a20",burnS:900,coolingS:30},phenomenon:"SkyLantern",durationS:1500},{id:"anti-hail",modelId:"ufoathome-balloon-latex",envelope:"elastic",launchVolumeM3:.65,maxVolumeM3:8,massKg:.4,dragCoefficient:.35,aspect:1.13,color:"#f2ece0",albedo:.55,torch:{aboveM:600,candela:300,color:"#ff9a3c",burnS:90,fallMS:4},phenomenon:"ParachuteFlare",durationS:1200},{id:"solar",modelId:"ufoathome-balloon-latex",envelope:"open",launchVolumeM3:14,maxVolumeM3:14,massKg:.4,dragCoefficient:.47,aspect:1.13,color:"#151515",albedo:.05,insideExcessK:10,phenomenon:"WeatherBalloonsOrMongolfieres",durationS:3600},{id:"captive",modelId:"ufoathome-balloon-latex",envelope:"sealed",tethered:!0,launchVolumeM3:14,maxVolumeM3:14,massKg:8,dragCoefficient:.47,aspect:1.13,color:"#f4f4f4",albedo:.7,phenomenon:"WeatherBalloonsOrMongolfieres",durationS:3600}];static byId(t){return he.ALL.find(e=>e.id===t)}}const tr=X.rounded,er={key:"balloons",messages:In,phenomenon:n=>{const t=typeof n.balloon=="string"?n.balloon:n.balloon?.id;return(he.byId(t)??he.ALL[0]).phenomenon},inWind:(n,t)=>{const e=n.site.altitudeM??0;return{...n,wind:tr(t.at(10)),windsAloft:t.levels.filter(r=>r>e+10).map(r=>({...tr(t.at(r)),atM:Math.round(r-e)}))}},compute:()=>d(async()=>{const{BalloonFlight:n}=await import("./BalloonFlight-CvE7AHlm.js");return{BalloonFlight:n}},[],import.meta.url).then(({BalloonFlight:n})=>t=>n.bodiesOf(t)),editor:()=>d(async()=>{const{BalloonEditor:n}=await import("./BalloonEditor-BBAtMeVM.js");return{BalloonEditor:n}},__vite__mapDeps([16,3,4,5,15,12,13,17,6,7,8]),import.meta.url).then(({BalloonEditor:n})=>(t,e,r)=>new n(t,e,r))},_n=_.catalog({en:()=>d(()=>import("./AirshipKindMessages_en-DzGapVTV.js"),[],import.meta.url).then(n=>n.airshipKindMessages_en),fr:()=>d(()=>import("./AirshipKindMessages_fr-BTXNsW5W.js"),[],import.meta.url).then(n=>n.airshipKindMessages_fr),es:()=>d(()=>import("./AirshipKindMessages_es-TE93uMSC.js"),[],import.meta.url).then(n=>n.airshipKindMessages_es),it:()=>d(()=>import("./AirshipKindMessages_it-Cwa3MnJ-.js"),[],import.meta.url).then(n=>n.airshipKindMessages_it)}),le=(n,t,e,r=5)=>({"nav-left":{color:"#ff2a1a",candela:r,leds:[{at:n,radiusM:.06}]},"nav-right":{color:"#2aff5a",candela:r,leds:[{at:t,radiusM:.06}]},tail:{color:"#ffffff",candela:r,leds:[{at:e,radiusM:.06}]}});class fe{static ALL=[{id:"blimp",modelId:"ufoathome-airship-blimp",sizeM:{widthM:14.72,lengthM:59.46,heightM:17.59},cruiseMS:15,maxSpeedMS:22,color:"#c9ccd1",finColor:"#1d3f8a",albedo:.6,sign:{color:"#fff4d8",luminanceCdM2:150,lit:!0},lights:{...le([-1.22,-8.6,-9],[1.22,-8.6,-9],[0,0,29.7]),strobe:{color:"#ffffff",candela:400,hz:1,flashS:.06,leds:[{at:[0,-10.15,-9],radiusM:.08}]}},sound:"light-piston",phenomenon:"Airship"},{id:"zeppelin-nt",modelId:"ufoathome-airship-zeppelin-nt",sizeM:{widthM:18.2,lengthM:75.11,heightM:19.55},cruiseMS:19,maxSpeedMS:35,color:"#eef0f2",finColor:"#eef0f2",albedo:.75,sign:{color:"#fff4d8",luminanceCdM2:150,lit:!1},lights:{...le([-1.32,-8.4,-14],[1.32,-8.4,-14],[0,0,37.5]),strobe:{color:"#ffffff",candela:400,hz:1,flashS:.06,leds:[{at:[0,-9.65,-14],radiusM:.08}]}},sound:"light-piston",phenomenon:"Airship"},{id:"lightship",modelId:"ufoathome-airship-lightship",sizeM:{widthM:10.16,lengthM:39.66,heightM:11.98},cruiseMS:13,maxSpeedMS:20,color:"#f4f4f2",finColor:"#f4f4f2",albedo:.7,glowCdM2:20,lights:le([-.82,-5.9,-6],[.82,-5.9,-6],[0,0,19.8]),sound:"light-piston",phenomenon:"Airship"},{id:"aerostat",modelId:"ufoathome-airship-aerostat",sizeM:{widthM:25.14,lengthM:63.6,heightM:27.05},cruiseMS:0,maxSpeedMS:0,tethered:!0,color:"#f2f2f0",finColor:"#f2f2f0",albedo:.7,lights:{nose:{color:"#ff2a1a",candela:2e3,hz:.5,flashS:.6,leds:[{at:[0,-4.2,-30],radiusM:.12}]},stern:{color:"#ff2a1a",candela:2e3,hz:.5,flashS:.6,leds:[{at:[0,-6.3,22],radiusM:.12}]}},phenomenon:"Airship"},{id:"rigid",modelId:"ufoathome-airship-rigid",sizeM:{widthM:33.38,lengthM:236.66,heightM:35.79},cruiseMS:32,maxSpeedMS:36,color:"#b9bcbf",finColor:"#b9bcbf",albedo:.55,lights:le([-3.02,-16.5,-80],[3.02,-16.5,-80],[0,0,118.3],10),sound:"piston-heavy",phenomenon:"Airship"}];static byId(t){return fe.ALL.find(e=>e.id===t)}}const rr={key:"airships",messages:_n,phenomenon:n=>{const t=typeof n.airship=="string"?n.airship:n.airship?.id;return(fe.byId(t)??fe.ALL[0]).phenomenon},compute:()=>d(async()=>{const{AirshipFlight:n}=await import("./AirshipFlight-6yYGIRn8.js");return{AirshipFlight:n}},__vite__mapDeps([18,12,13]),import.meta.url).then(({AirshipFlight:n})=>t=>n.bodiesOf(t)),editor:()=>d(async()=>{const{AirshipEditor:n}=await import("./AirshipEditor-EBfUtSiB.js");return{AirshipEditor:n}},__vite__mapDeps([19,3,4,5,15,12,13,18,8,11]),import.meta.url).then(({AirshipEditor:n})=>(t,e,r)=>new n(t,e,r))},Qr=A.point("interpretations").provide(A.BUILT_IN,[{id:We.key,name:"Decoy flares",credit:"UFO@home",creditUrl:"https://ufoathome.org/docs/format/",create:()=>We},{id:Xe.key,name:"Sky lanterns",credit:"UFO@home",creditUrl:"https://ufoathome.org/docs/format/",create:()=>Xe},{id:Je.key,name:"Birds",credit:"UFO@home",creditUrl:"https://ufoathome.org/docs/format/",create:()=>Je},{id:Qe.key,name:"Drones",credit:"UFO@home",creditUrl:"https://ufoathome.org/docs/format/",create:()=>Qe},{id:er.key,name:"Balloons",credit:"UFO@home",creditUrl:"https://ufoathome.org/docs/format/",create:()=>er},{id:rr.key,name:"Airships",credit:"UFO@home",creditUrl:"https://ufoathome.org/docs/format/",create:()=>rr}]);class $e{static kinds(){return Qr.map(t=>N.of(t))}}const to=Object.freeze(Object.defineProperty({__proto__:null,INTERPRETATION_SOURCES:Qr,InterpretationRegistry:$e},Symbol.toStringTag,{value:"Module"}));class z{static SIGHTING_EVENT="sighting";static INTERPRETATION_EVENT="interpretation";static INTERVIEW_EVENT="interview";static check(t){return ht.check(t,"case")}static isCase(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)&&Array.isArray(t.events)&&!("timeline"in t)}static sightingUrls(t,e){return(t.events??[]).filter(r=>r.eventType===z.SIGHTING_EVENT&&!r.interpretationOf&&typeof r.url=="string"&&r.url!=="").map(r=>new URL(r.url,e).href)}static accountIds(t,e,r,s){const o=(t.events??[]).filter(i=>i.eventType===z.SIGHTING_EVENT&&i.id!==void 0&&typeof i.url=="string"&&r!==void 0&&new URL(i.url,e).href===r).map(i=>i.id);return s!==void 0&&o.push(s),o}static interpretationEvents(t,e){const r=[e].flat().filter(s=>!!s);return r.length===0?[]:(t.events??[]).filter(s=>s.eventType===z.INTERPRETATION_EVENT?s.sighting!==void 0&&r.includes(s.sighting):s.eventType!==z.SIGHTING_EVENT||s.interpretationOf===void 0?!1:[s.interpretationOf].flat().some(o=>r.includes(o))).map(s=>s)}static problems(t,e){const r=t.events??[],s=new Set,o=new Set;for(const a of r)a.id!==void 0&&(s.has(a.id)&&o.add(a.id),s.add(a.id));const i=[];for(const a of r){const l=a.eventType===z.SIGHTING_EVENT?a.interpretationOf:a.eventType===z.INTERVIEW_EVENT?a.interviewOf:void 0;if(l!==void 0)for(const c of[l].flat())!s.has(c)&&!e.includes(c)&&i.push({reading:a.url??a.id??"",reference:c})}return{duplicateIds:[...o],unresolved:i}}static async interpretationOf(t,e,r){if(t.bodies)return z.withModelsFrom(j.strip({title:t.title,bodies:t.bodies??[],smoke:t.smoke,findings:t.findings,...N.computedPart(t,$e.kinds())}).recording,e);if(!t.url)return{title:t.title,bodies:[]};const s=new URL(t.url,e).href,o=await r(s),i=j.strip("timeline"in o&&o.interpretation?o.interpretation:o).recording;return z.withModelsFrom({title:t.title??i.title,bodies:i.bodies??[],smoke:i.smoke,findings:i.findings,...N.computedPart(i,$e.kinds())},s)}static withModelsFrom(t,e){return{...t,bodies:t.bodies.map(r=>r.model?.url?{...r,model:{...r.model,url:new URL(r.model.url,e).href}}:r)}}}class F{static files=new Map;static hold(t){for(const[e,r]of t)F.files.set(F.key(e),r)}static releaseCopies(){for(const[t,e]of F.files)e.local||F.files.delete(t)}static clear(){F.files.clear()}static localBase(){return new URL(`local/${Date.now().toString(36)}${Math.random().toString(36).slice(2,6)}/`,location.href).href}static read(t){const e=F.files.get(F.key(t));return e===void 0?void 0:structuredClone(e.json)}static changed(...t){return t.some(e=>e!==void 0&&F.files.get(F.key(e))?.changed===!0)}static local(t){return t!==void 0&&F.files.get(F.key(t))?.local===!0}static key(t){const e=new URL(t,location.href);return e.hash="",e.href}}class Q{static NAMES=["weather","place","lightPollution","decor"];static KEYS={weather:["weatherTrack","weatherSource"],place:["place"],lightPollution:["lightPollution"],decor:["decor"]};static annexName(t,e){return`${t}.${e.replace(/[A-Z]/g,r=>`-${r.toLowerCase()}`)}.json`}static taken(t,e){const r={};if(t==="decor")return Array.isArray(e.decor)&&(r.decor=e.decor.filter(Q.surveyed)),r;for(const s of Q.KEYS[t])e[s]!==void 0&&(r[s]=e[s]);return r}static strip(t,e){if(t==="decor"){const r=Array.isArray(e.decor)?e.decor.filter(s=>!Q.surveyed(s)):[];r.length>0?e.decor=r:delete e.decor;return}for(const r of Q.KEYS[t])delete e[r]}static put(t,e,r){if(t==="decor"){if(!Array.isArray(r.decor))return;const s=Array.isArray(e.decor)?e.decor.filter(o=>!Q.surveyed(o)):[];e.decor=[...s,...r.decor];return}for(const s of Q.KEYS[t])r[s]!==void 0&&(e[s]=r[s])}static surveyed(t){return typeof t=="object"&&t!==null&&typeof t.origin=="string"}static fromFile(t,e){return t?.[e]!==void 0&&t[e].live!==!0}}class tn{static NAMES=["relief","imagery","roads","water","railways","upperAir","map"];static TERRAIN=["relief","imagery","roads","water","railways"];static held(t,e){if(!t||t.live)return;const r=t[e];return r&&!r.live&&!r.refresh&&r.src!==void 0?r:void 0}static isLive(t,e){return t?.live===!0||t?.[e]?.live===!0}static annexName(t,e){const r=e==="relief"||e==="imagery"||e==="map"?"zip":"json",s=e.replace(/[A-Z]/g,o=>`-${o.toLowerCase()}`);return`${t}.${s}.${r}`}static isEmpty(t){return!t||!t.live&&tn.NAMES.every(e=>!t[e])&&Q.NAMES.every(e=>!t[e])}}class xt extends Error{constructor(t,e,r){super(`${t}: ${e}${r===void 0?"":` (HTTP ${r})`}`),this.kind=t,this.url=e,this.status=r,this.name="SightingFetchError"}}class jt{static async recording(t){const e=F.read(t);if(e!==void 0)return e;const r=await jt.json(t);for(const s of Q.NAMES){const o=r?.snapshots?.[s];if(!(!o?.src||o.live))try{const i=ht.recording(await jt.json(new URL(o.src,new URL(t,location.href)).href));Q.put(s,r,i)}catch{}}return r}static async json(t){const e=new URL(t,location.href),r=F.read(e.href);if(r!==void 0)return r;if(location.protocol==="https:"&&e.protocol==="http:")throw new xt("mixed-content",t);let s;try{s=await fetch(t)}catch{throw await this.diagnose(t,e)}if(!s.ok)throw new xt("status",t,s.status);try{return await s.json()}catch{throw new xt("malformed",t)}}static async diagnose(t,e){if(e.origin===location.origin)return new xt("unreachable",t);try{return await fetch(t,{mode:"no-cors"}),new xt("cors",t)}catch{return new xt("unreachable",t)}}}const eo=Object.freeze(Object.defineProperty({__proto__:null,SightingFetch:jt,SightingFetchError:xt},Symbol.toStringTag,{value:"Module"}));class Pe{constructor(t,e,r=()=>{}){this.place=t,this.changed=r,e&&this.adopt(e)}reader;editor;handed;get reading(){return this.reader!==void 0}get editorLoaded(){return this.editor!==void 0}adopt(t){this.editor=t,t.switcher=this,t.hasAttribute(ve)||t.setAttribute(ve,""),t.addEventListener(gn,e=>{e.preventDefault();const r=e.detail;this.handed=r.src,this.read(r)})}async read({src:t,track:e}){const[{register:r,CASE_ELEMENT_NAME:s,OPEN_EVENTS_ATTRIBUTE:o},{registerSighting:i,SIGHTING_ELEMENT_NAME:a}]=await Promise.all([d(()=>import("./CaseElement-Bm6xPD0e.js"),__vite__mapDeps([20,21,22,6,7,23,3,4,13,24,25,1,26]),import.meta.url),d(()=>import("./SightingElement-DZlh5u4N.js"),__vite__mapDeps([26,22,6,7,23,3,4,13,24,25,1]),import.meta.url)]);i(),r();const l=z.isCase(F.read(t)??await jt.json(t)),c=document.createElement(l?s:a);c.setAttribute(ve,""),c.setAttribute("show-labels",""),l&&e&&c.setAttribute(o,Pe.fileKey(e)),c.setAttribute("src",t),c.addEventListener(wn,m=>{m.preventDefault(),this.edit(m.detail)}),this.reader?.remove(),this.place(c),this.editor&&(this.editor.hidden=!0),this.reader=c,this.changed({mode:"read",src:t,...e?{track:e}:{}})}async edit(t){const e=this.editor;if(e){if(this.dropReader(),F.releaseCopies(),e.hidden=!1,this.changed({mode:"edit"}),t?.src!==void 0&&t.src!==this.handed){this.load(e,t.src,t.track);return}t?.track&&await e.openTrack(t.track);return}const{register:r,CASE_EDITOR_ELEMENT_NAME:s}=await d(async()=>{const{register:i,CASE_EDITOR_ELEMENT_NAME:a}=await import("./CaseEditorElement-CK82yjEn.js").then(l=>l.a);return{register:i,CASE_EDITOR_ELEMENT_NAME:a}},__vite__mapDeps([27,3,4,8,21,22,6,7,23,13,24,25,1,28,29,11,30,31,32,33]),import.meta.url);r();const o=document.createElement(s);this.adopt(o),t?.track&&o.setAttribute("track",t.track),t?.src?o.setAttribute("src",t.src):t?.start&&(o.caseStart=t.start),this.dropReader(),this.place(o),this.changed({mode:"edit"})}async open(t){const e=this.editor;if(this.reading||!e)return this.read({src:t});this.load(e,t)}load(t,e,r){this.handed=void 0,r?t.setAttribute("track",r):t.removeAttribute("track"),t.setAttribute("src",e)}async startNew(t){const e=this.editor;if(!e)return this.edit(t?{start:t}:void 0);this.reading&&await this.edit(),e.askBeforeReplacing(()=>{e.remove(),this.editor=void 0,this.edit(t?{start:t}:void 0)})}dropReader(){this.reader?.remove(),this.reader=void 0}static fileKey(t){return new URL(t,location.href).pathname.split("/").pop().replace(/\.json$/i,"")}}const Fe="rr0-input-file",en={inputFileFromFile:"from your disk",inputFileFromUrl:"from an address",inputFileModeHint:"Click to give it the other way: a file of yours, or an address",inputFileLoad:"Load"},Nn=`
|
|
3
3
|
rr0-input-file { display: inline-flex; align-items: center; gap: .3em; }
|
|
4
4
|
/* As the date's own switch (see DateInputElement): it reads as part of the label, before the field. */
|
|
5
5
|
rr0-input-file .input-file-mode { order: -1; font: inherit; color: inherit; background: none; border: 0; padding: 0; margin: 0; cursor: pointer; text-decoration: underline; text-underline-offset: .15em; }
|
|
@@ -122,7 +122,7 @@ ${t} :is(select:not([multiple]):not([size]), .rr0-select) {
|
|
|
122
122
|
.consent-dialog p { margin: 0; }
|
|
123
123
|
.consent-dialog ul { margin: 6px 0 10px; padding-left: 1.2em; font-family: var(--mono, monospace); font-size: .85em; overflow-wrap: anywhere; }
|
|
124
124
|
.consent-dialog .actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; }
|
|
125
|
-
`;class As{static async ask(t,e,r){const s=[...new Set(r.filter(S=>!I.granted(S)).map(S=>I.originOf(S)))];if(s.length===0)return!0;const o=(t instanceof ShadowRoot?t.host:t).ownerDocument,i=o.createElement("div");i.className="consent-dialog",i.id="consent",i.setAttribute("popover","manual"),i.setAttribute("role","dialog");const a=o.createElement("style");a.textContent=Ms;const l=o.createElement("h2");l.id="consent-heading",l.textContent=e?.consentHeading??"",i.setAttribute("aria-labelledby",l.id);const c=o.createElement("p");c.id="consent-text",c.textContent=e?.consentText??"";const m=o.createElement("ul");m.id="consent-origins",m.append(...s.map(S=>Object.assign(o.createElement("li"),{textContent:S})));const p=o.createElement("div");p.className="actions";const f=Object.assign(o.createElement("button"),{type:"button",id:"consent-without",className:"pill-btn",textContent:e?.consentWithout??""}),y=Object.assign(o.createElement("button"),{type:"button",id:"consent-run",className:"pill-btn primary",textContent:e?.consentRun??""});return p.append(f,y),i.append(a,l,c,m,p),t.getElementById?.("consent")?.remove(),t.append(i),new Promise(S=>{const E=G=>{try{i.hidePopover?.()}catch{}i.remove(),G&&I.grant(r),S(G)};y.addEventListener("click",()=>E(!0)),f.addEventListener("click",()=>E(!1));try{i.showPopover?.()}catch{}f.focus()})}}function Ts(n,t){for(const e of n){const r=e.toLowerCase().split("-")[0];if(t.includes(r))return r}return"en"}class me{static preferencesFor(t){const e=navigator.languages??[],r=this.declaredFor(t);return r?[r,...e]:e}static declaredFor(t){for(let e=t;e;){const r=e.closest("[lang]")?.getAttribute("lang")?.trim();if(r)return r;const s=e.getRootNode();e=s instanceof ShadowRoot?s.host:void 0}}}const Is=["en","fr","es","it"],_s={en:()=>d(()=>import("./UfoMessages_en-D5OYWJ3K.js"),__vite__mapDeps([34,24]),import.meta.url).then(n=>n.ufoMessages_en),fr:()=>d(()=>import("./UfoMessages_fr-CGkQBn5r.js"),[],import.meta.url).then(n=>n.ufoMessages_fr),es:()=>d(()=>import("./UfoMessages_es-CO-v8Jl6.js"),[],import.meta.url).then(n=>n.ufoMessages_es),it:()=>d(()=>import("./UfoMessages_it-BScqxIaH.js"),[],import.meta.url).then(n=>n.ufoMessages_it)},so=_.catalog(_s),Ns={en:()=>d(()=>import("./SightingEditorMessages_en-
|
|
125
|
+
`;class As{static async ask(t,e,r){const s=[...new Set(r.filter(S=>!I.granted(S)).map(S=>I.originOf(S)))];if(s.length===0)return!0;const o=(t instanceof ShadowRoot?t.host:t).ownerDocument,i=o.createElement("div");i.className="consent-dialog",i.id="consent",i.setAttribute("popover","manual"),i.setAttribute("role","dialog");const a=o.createElement("style");a.textContent=Ms;const l=o.createElement("h2");l.id="consent-heading",l.textContent=e?.consentHeading??"",i.setAttribute("aria-labelledby",l.id);const c=o.createElement("p");c.id="consent-text",c.textContent=e?.consentText??"";const m=o.createElement("ul");m.id="consent-origins",m.append(...s.map(S=>Object.assign(o.createElement("li"),{textContent:S})));const p=o.createElement("div");p.className="actions";const f=Object.assign(o.createElement("button"),{type:"button",id:"consent-without",className:"pill-btn",textContent:e?.consentWithout??""}),y=Object.assign(o.createElement("button"),{type:"button",id:"consent-run",className:"pill-btn primary",textContent:e?.consentRun??""});return p.append(f,y),i.append(a,l,c,m,p),t.getElementById?.("consent")?.remove(),t.append(i),new Promise(S=>{const E=G=>{try{i.hidePopover?.()}catch{}i.remove(),G&&I.grant(r),S(G)};y.addEventListener("click",()=>E(!0)),f.addEventListener("click",()=>E(!1));try{i.showPopover?.()}catch{}f.focus()})}}function Ts(n,t){for(const e of n){const r=e.toLowerCase().split("-")[0];if(t.includes(r))return r}return"en"}class me{static preferencesFor(t){const e=navigator.languages??[],r=this.declaredFor(t);return r?[r,...e]:e}static declaredFor(t){for(let e=t;e;){const r=e.closest("[lang]")?.getAttribute("lang")?.trim();if(r)return r;const s=e.getRootNode();e=s instanceof ShadowRoot?s.host:void 0}}}const Is=["en","fr","es","it"],_s={en:()=>d(()=>import("./UfoMessages_en-D5OYWJ3K.js"),__vite__mapDeps([34,24]),import.meta.url).then(n=>n.ufoMessages_en),fr:()=>d(()=>import("./UfoMessages_fr-CGkQBn5r.js"),[],import.meta.url).then(n=>n.ufoMessages_fr),es:()=>d(()=>import("./UfoMessages_es-CO-v8Jl6.js"),[],import.meta.url).then(n=>n.ufoMessages_es),it:()=>d(()=>import("./UfoMessages_it-BScqxIaH.js"),[],import.meta.url).then(n=>n.ufoMessages_it)},so=_.catalog(_s),Ns={en:()=>d(()=>import("./SightingEditorMessages_en-CS2iXwDm.js"),__vite__mapDeps([35,36]),import.meta.url).then(n=>n.sightingEditorMessages_en),fr:()=>d(()=>import("./SightingEditorMessages_fr-AYgrnKFD.js"),__vite__mapDeps([37,38]),import.meta.url).then(n=>n.sightingEditorMessages_fr),es:()=>d(()=>import("./SightingEditorMessages_es-C8Vw_4b_.js"),__vite__mapDeps([39,40]),import.meta.url).then(n=>n.sightingEditorMessages_es),it:()=>d(()=>import("./SightingEditorMessages_it-DZyzwScx.js"),__vite__mapDeps([41,42]),import.meta.url).then(n=>n.sightingEditorMessages_it)},Gs=_.catalog(Ns);function oo(n){return Gs.load(n)}const ks={en:()=>d(()=>import("./SightingMessages_en-D90vDTQ7.js"),__vite__mapDeps([43,36]),import.meta.url).then(n=>n.sightingMessages_en),fr:()=>d(()=>import("./SightingMessages_fr-Gq3IMFTE.js"),__vite__mapDeps([44,38]),import.meta.url).then(n=>n.sightingMessages_fr),es:()=>d(()=>import("./SightingMessages_es-D8laK6OY.js"),__vite__mapDeps([45,40]),import.meta.url).then(n=>n.sightingMessages_es),it:()=>d(()=>import("./SightingMessages_it-BXDxv-lE.js"),__vite__mapDeps([46,42]),import.meta.url).then(n=>n.sightingMessages_it)},io=_.catalog(ks),Rs={en:()=>d(()=>import("./CaseMessages_en-BC0lku35.js"),[],import.meta.url).then(n=>n.caseMessages_en),fr:()=>d(()=>import("./CaseMessages_fr-D_6J6ONO.js"),[],import.meta.url).then(n=>n.caseMessages_fr),es:()=>d(()=>import("./CaseMessages_es-Cbktn5vj.js"),[],import.meta.url).then(n=>n.caseMessages_es),it:()=>d(()=>import("./CaseMessages_it-CYyww4oG.js"),[],import.meta.url).then(n=>n.caseMessages_it)},Os=_.catalog(Rs);function ao(n){return Os.load(n)}const Vs={en:()=>d(()=>import("./UfoAtHomeMessages_en-ByVu39KF.js"),__vite__mapDeps([47,48]),import.meta.url).then(n=>n.ufoAtHomeMessages_en),fr:()=>d(()=>import("./UfoAtHomeMessages_fr-nTqRf0ZK.js"),__vite__mapDeps([49,50]),import.meta.url).then(n=>n.ufoAtHomeMessages_fr),es:()=>d(()=>import("./UfoAtHomeMessages_es-D9bLboxq.js"),__vite__mapDeps([51,52]),import.meta.url).then(n=>n.ufoAtHomeMessages_es),it:()=>d(()=>import("./UfoAtHomeMessages_it-4cZC5-y5.js"),__vite__mapDeps([53,54]),import.meta.url).then(n=>n.ufoAtHomeMessages_it)},$s=_.catalog(Vs);function Fs(n){return $s.load(n)}const Ds={en:()=>d(()=>import("./ShareMessages_en-B43x8LgJ.js"),[],import.meta.url).then(n=>n.shareMessages_en),fr:()=>d(()=>import("./ShareMessages_fr-CzZyVbbX.js"),[],import.meta.url).then(n=>n.shareMessages_fr),es:()=>d(()=>import("./ShareMessages_es-DZCJojSc.js"),[],import.meta.url).then(n=>n.shareMessages_es),it:()=>d(()=>import("./ShareMessages_it-C_Z6eDQK.js"),[],import.meta.url).then(n=>n.shareMessages_it)},uo=_.catalog(Ds);function co(n){switch(n){case"fr":return d(()=>import("./TagNames_fr-Dnqq6HQ5.js"),[],import.meta.url).then(t=>t.tagNames_fr);case"es":return d(()=>import("./TagNames_es-BfnMpc3D.js"),[],import.meta.url).then(t=>t.tagNames_es);case"it":return d(()=>import("./TagNames_it-n6E4EGYO.js"),[],import.meta.url).then(t=>t.tagNames_it);default:return Promise.resolve({})}}const Ps={en:()=>d(()=>import("./BodyEditorMessages_en-CckxSS1L.js"),[],import.meta.url).then(n=>n.bodyEditorMessages_en),fr:()=>d(()=>import("./BodyEditorMessages_fr-638ypdqf.js"),[],import.meta.url).then(n=>n.bodyEditorMessages_fr),es:()=>d(()=>import("./BodyEditorMessages_es-B8GlFFBo.js"),[],import.meta.url).then(n=>n.bodyEditorMessages_es),it:()=>d(()=>import("./BodyEditorMessages_it-SKpMkHFI.js"),[],import.meta.url).then(n=>n.bodyEditorMessages_it)},Us={en:()=>d(()=>import("./CaseEditorMessages_en-pog3M_U6.js"),[],import.meta.url).then(n=>n.caseEditorMessages_en),fr:()=>d(()=>import("./CaseEditorMessages_fr-BOKVeIXM.js"),[],import.meta.url).then(n=>n.caseEditorMessages_fr),es:()=>d(()=>import("./CaseEditorMessages_es-Dz1N0VpM.js"),[],import.meta.url).then(n=>n.caseEditorMessages_es),it:()=>d(()=>import("./CaseEditorMessages_it-BKAkbKq-.js"),[],import.meta.url).then(n=>n.caseEditorMessages_it)},Bs={en:()=>d(()=>import("./ReadingSensitivityMessages_en-ChQHFyxb.js"),[],import.meta.url).then(n=>n.readingSensitivityMessages_en),fr:()=>d(()=>import("./ReadingSensitivityMessages_fr-Dl4a8udu.js"),[],import.meta.url).then(n=>n.readingSensitivityMessages_fr),es:()=>d(()=>import("./ReadingSensitivityMessages_es-BbFqHsvR.js"),[],import.meta.url).then(n=>n.readingSensitivityMessages_es),it:()=>d(()=>import("./ReadingSensitivityMessages_it-CwiJfUo_.js"),[],import.meta.url).then(n=>n.readingSensitivityMessages_it)},lo=_.catalog(Bs),Ls={en:()=>d(()=>import("./HvsMessages_en-BiLhEAxJ.js"),[],import.meta.url).then(n=>n.hvsMessages_en),fr:()=>d(()=>import("./HvsMessages_fr-DkvE2qm1.js"),[],import.meta.url).then(n=>n.hvsMessages_fr),es:()=>d(()=>import("./HvsMessages_es-Cbj_6eFs.js"),[],import.meta.url).then(n=>n.hvsMessages_es),it:()=>d(()=>import("./HvsMessages_it-BIJ87Uyb.js"),[],import.meta.url).then(n=>n.hvsMessages_it)},mo=_.catalog(Ls),js={en:()=>d(()=>import("./ScenarioSweepMessages_en-Bf4BscDU.js"),[],import.meta.url).then(n=>n.scenarioSweepMessages_en),fr:()=>d(()=>import("./ScenarioSweepMessages_fr-DlPsO6oI.js"),[],import.meta.url).then(n=>n.scenarioSweepMessages_fr),es:()=>d(()=>import("./ScenarioSweepMessages_es-CBHQfuRB.js"),[],import.meta.url).then(n=>n.scenarioSweepMessages_es),it:()=>d(()=>import("./ScenarioSweepMessages_it-DANW3_la.js"),[],import.meta.url).then(n=>n.scenarioSweepMessages_it)},po=_.catalog(js),Cs={en:()=>d(()=>import("./CaseExportMessages_en-jHlu58Y7.js"),[],import.meta.url).then(n=>n.caseExportMessages_en),fr:()=>d(()=>import("./CaseExportMessages_fr-sDfEgjWg.js"),[],import.meta.url).then(n=>n.caseExportMessages_fr),es:()=>d(()=>import("./CaseExportMessages_es-dCQQFgjq.js"),[],import.meta.url).then(n=>n.caseExportMessages_es),it:()=>d(()=>import("./CaseExportMessages_it-BJaglZtP.js"),[],import.meta.url).then(n=>n.caseExportMessages_it)},ho=_.catalog(Cs),Ks={en:()=>d(()=>import("./InterviewMessages_en-Ikx6GjEd.js"),[],import.meta.url).then(n=>n.interviewMessages_en),fr:()=>d(()=>import("./InterviewMessages_fr-DT0gXAKD.js"),[],import.meta.url).then(n=>n.interviewMessages_fr),es:()=>d(()=>import("./InterviewMessages_es-DKWWyrnb.js"),[],import.meta.url).then(n=>n.interviewMessages_es),it:()=>d(()=>import("./InterviewMessages_it-CF_9MYPt.js"),[],import.meta.url).then(n=>n.interviewMessages_it)},fo=_.catalog(Ks),go=_.catalog(Us),wo=_.catalog(Ps),Hs=_.catalog({en:()=>d(()=>import("./SceneNames_en-sRbx6EJZ.js"),__vite__mapDeps([55,7]),import.meta.url).then(n=>n.sceneNames_en),fr:()=>d(()=>import("./SceneNames_fr-BtTlti4C.js"),__vite__mapDeps([56,7]),import.meta.url).then(n=>n.sceneNames_fr),es:()=>d(()=>import("./SceneNames_es-pnfHB-7D.js"),__vite__mapDeps([57,7]),import.meta.url).then(n=>n.sceneNames_es),it:()=>d(()=>import("./SceneNames_it-DQKwdCVD.js"),__vite__mapDeps([58,7]),import.meta.url).then(n=>n.sceneNames_it)});function yo(n){return Hs.load(n)}const bo=_.catalog({en:()=>d(()=>import("./CloudEditorMessages_en-SmcRKW1O.js"),[],import.meta.url).then(n=>n.cloudEditorMessages_en),fr:()=>d(()=>import("./CloudEditorMessages_fr-SvL-CR04.js"),[],import.meta.url).then(n=>n.cloudEditorMessages_fr),es:()=>d(()=>import("./CloudEditorMessages_es-DFCuS9Qg.js"),[],import.meta.url).then(n=>n.cloudEditorMessages_es),it:()=>d(()=>import("./CloudEditorMessages_it-BvfiHWV9.js"),[],import.meta.url).then(n=>n.cloudEditorMessages_it)}),Jr="rr0-ufoathome",qs='<svg viewBox="0 0 16 16" width="16" height="16" aria-hidden="true" fill="none" stroke="currentColor" stroke-width="1.7" stroke-linecap="round"><path d="M8 3v10M3 8h10"/></svg>',zs='<svg viewBox="0 0 16 16" width="16" height="16" aria-hidden="true" fill="none" stroke="currentColor" stroke-width="1.7" stroke-linecap="round" stroke-linejoin="round"><path d="M2 4.5h4l1.5 1.5H14v6.5H2z"/></svg>',Ws=`
|
|
126
126
|
<style>
|
|
127
127
|
:host { display: block; ${xe.TOKENS} }
|
|
128
128
|
:host([hidden]) { display: none; }
|
package/dist-embed-ufoathome/{surroundingsSources-BSh42KUu.js → surroundingsSources-DtoCfflQ.js}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{g as B}from"./rr0-ufoathome.mjs";import{y as V,bs as tt,bt as q,z as j,bu as C,bv as X,bw as et}from"./ShareDialogElement-C0oFh0X4.js";import{l as ot}from"./GeoProjection-DvqDbRIx.js";import"./Sighting-BX_CmDY2.js";import"./VisualAids-DI-hEL46.js";import"./three.module-CbaHqYFq.js";import"./SaidPosition-OJEYhVKN.js";import"./Decor-Dn-cvniW.js";import"./RecordingIssue-BlWT8Xsu.js";import"./xyzImageryRaster-Dhxs0B26.js";import"./Obstacles-v9SkfBD7.js";class I{constructor(t){this.survey=t}static CACHE_NAME="rr0-surroundings";static MAX_AGE_MS=720*3600*1e3;static FORMAT=8;static MAX_STORED=400;static asked=new Map;get id(){return this.survey.id}get name(){return this.survey.name}get attribution(){return this.survey.attribution}get creditUrl(){return this.survey.creditUrl}get contemporary(){return this.survey.contemporary}covers(t,e){return this.survey.covers(t,e)}async getSurroundings(t,e){const s=I.key(this.survey.id,t,e);let o=I.asked.get(s);return o===void 0&&(o=this.recalled(s,t,e),I.asked.set(s,o),o.catch(()=>I.asked.delete(s))),structuredClone(await o)}later(t,e){const s=this.survey.later?.(t,e);if(!s)return;const o=I.key(this.survey.id,t,e);return s.then(n=>{const a=I.partial.get(o);if(a){I.partial.delete(o);const{incomplete:r,...i}=a,h=[...a.credits??[],...n.credits??[]].filter((l,f,M)=>M.findIndex(d=>d.url===l.url)===f),c={...i,...n,dates:{...a.dates,...n.dates},...h.length>0?{credits:h}:{}};I.asked.set(o,Promise.resolve(c)),I.openCache().then(l=>l&&I.store(l,I.request(o),c))}return structuredClone(n)})}static partial=new Map;static forget(){I.partial.clear(),I.asked.clear()}static key(t,e,s){return`${t}/v${I.FORMAT}/${e.lat.toFixed(5)}/${e.lng.toFixed(5)}/${Math.round(s)}`}async recalled(t,e,s){const o=await I.openCache(),n=I.request(t);if(o)try{const r=await o.match(n);if(r){const{savedAt:i,surroundings:h}=await r.json();if(Date.now()-i<I.MAX_AGE_MS)return h;await o.delete(n)}}catch{}const a=await this.survey.getSurroundings(e,s);return a.incomplete?(I.asked.delete(t),I.partial.set(t,structuredClone(a)),a):(o&&I.store(o,n,a),a)}static async store(t,e,s){try{const o={savedAt:Date.now(),surroundings:s};await t.put(e,new Response(JSON.stringify(o),{headers:{"Content-Type":"application/json"}}));const n=await t.keys();for(const a of n.slice(0,Math.max(0,n.length-I.MAX_STORED)))await t.delete(a)}catch{}}static async openCache(){try{return typeof caches>"u"?void 0:await caches.open(I.CACHE_NAME)}catch{return}}static request(t){const e=typeof location>"u"?"http://localhost":location.origin;return new Request(`${e}/__surroundings__/${encodeURIComponent(t)}`)}}class st{constructor(t){if(this.candidates=t,t.length===0)throw new Error("A survey needs at least one candidate");this.current=t[0]}current;get id(){return this.current.id}get name(){return this.current.name}get attribution(){return this.current.attribution}get creditUrl(){return this.current.creditUrl}get contemporary(){return this.current.contemporary}covers(t,e){return this.candidates.some(s=>s.covers(t,e))}async getSurroundings(t,e){let s;for(const o of this.candidates)if(o.covers(t.lat,t.lng))try{const n=await o.getSurroundings(t,e);return this.current=o,n}catch(n){if(s??=n,!(n instanceof V))throw n}throw s??new V("no-coverage","No survey reaches this place")}later(t,e){return this.current.later?.(t,e)}}class D{constructor(t,e,s,o){this.heights=t,this.building=e,this.width=s,this.height=o}static ROOF_PERCENTILE=.9;static STEP_M=.9;static RECTANGLE_FILL=.72;static MIN_DEPTH_M=2.5;static MAX_PARTS=24;static MAX_CELLS=640;buildings(t){const e=t.metresPerPixel,s=t.minAreaM2??12,o=new Uint8Array(this.width*this.height),n=[];for(let a=0;a<this.building.length;a++){if(!this.building[a]||o[a])continue;const r=this.patchFrom(a,o);if(!(r.length*e*e<s))for(const i of this.buildingsOf(r,e,s))Math.hypot(i.eastM,i.northM)<=t.radiusM&&n.push(i)}return n.sort((a,r)=>Math.hypot(a.eastM,a.northM)-Math.hypot(r.eastM,r.northM)),n.slice(0,t.maxBuildings??60)}patchFrom(t,e){const s=[],o=[t];for(e[t]=1;o.length>0;){const n=o.pop();s.push(n);const a=n%this.width,r=Math.floor(n/this.width);for(const[i,h]of[[1,0],[-1,0],[0,1],[0,-1]]){const c=a+i,l=r+h;if(c<0||l<0||c>=this.width||l>=this.height)continue;const f=l*this.width+c;this.building[f]&&!e[f]&&Math.abs(this.heights[f]-this.heights[n])<=D.STEP_M&&(e[f]=1,o.push(f))}}return s}buildingsOf(t,e,s){const o=this.width/2,n=this.height/2,a=[],r=[],i=[];for(const h of t){const c=h%this.width,l=Math.floor(h/this.width);a.push((c+.5-o)*e),r.push((n-l-.5)*e),i.push(this.heights[h])}return D.ofPoints(a,r,i,e,s)}static ofPoints(t,e,s,o,n,a=D.RECTANGLE_FILL,r=[]){const i=[];for(let m=0;m<t.length;m++)for(const[E,v]of[[-.5,-.5],[.5,-.5],[-.5,.5],[.5,.5]])i.push([t[m]+E*o,e[m]+v*o]);const h=D.hull(i),{angle:c,rectangle:l}=D.smallestRectangle(h),f=t.length*o*o,M=(l.maxU-l.minU)*(l.maxV-l.minV);if(f/M>=a||f<4*n)return[D.building(l,c,D.roof(s))];const d=h.map((m,E)=>({from:{east:m[0],north:m[1]},to:{east:h[(E+1)%h.length][0],north:h[(E+1)%h.length][1]}})),g=D.dominantAngles([...r,...d]);return D.parts(t,e,s,g.length>0?g:[c],o,n)}static dominantAngles(t,e=3){const s=new Map;for(const o of t){const n=Math.hypot(o.to.east-o.from.east,o.to.north-o.from.north);if(n<1e-6)continue;const a=(Math.atan2(o.to.north-o.from.north,o.to.east-o.from.east)%(Math.PI/2)+Math.PI/2)%(Math.PI/2),r=Math.round(a/(Math.PI/60));s.set(r,(s.get(r)??0)+n)}return[...s.entries()].sort((o,n)=>n[1]-o[1]).slice(0,e).map(([o])=>o*Math.PI/60)}static parts(t,e,s,o,n,a){let r=t.map((h,c)=>c);const i=[];for(let h=0;h<D.MAX_PARTS&&r.length>0;h++){let c;for(const M of o){const d=D.largestIn(t,e,r,M,n);d&&(c===void 0||d.area>c.area)&&(c=d)}if(c===void 0||c.area<a)break;const l=c.covered;Math.min(c.rectangle.maxU-c.rectangle.minU,c.rectangle.maxV-c.rectangle.minV)>=D.MIN_DEPTH_M&&i.push(D.building(c.rectangle,c.angle,D.roof([...l].map(M=>s[M])))),r=r.filter(M=>!l.has(M))}return i}static largestIn(t,e,s,o,n){const a=Math.cos(o),r=Math.sin(o);let i=1/0,h=-1/0,c=1/0,l=-1/0;const f=[],M=[];for(const A of s){const y=t[A]*a+e[A]*r,R=-t[A]*r+e[A]*a;f.push(y),M.push(R),i=Math.min(i,y),h=Math.max(h,y),c=Math.min(c,R),l=Math.max(l,R)}const d=Math.max(n*Math.SQRT2,Math.max(h-i,l-c)/D.MAX_CELLS),g=Math.max(1,Math.ceil((h-i)/d+1e-9)),m=Math.max(1,Math.ceil((l-c)/d+1e-9)),E=new Uint8Array(g*m),v=s.map((A,y)=>{const R=Math.min(g-1,Math.max(0,Math.floor((f[y]-i)/d))),x=Math.min(m-1,Math.max(0,Math.floor((M[y]-c)/d)));return E[x*g+R]=1,x*g+R}),w=D.largestRectangle(E,g,m);if(w===void 0)return;const p=new Set;return s.forEach((A,y)=>{const R=v[y]%g,x=Math.floor(v[y]/g);R>=w.column&&R<w.column+w.columns&&x>=w.row&&x<w.row+w.rows&&p.add(A)}),{area:w.area*d*d,angle:o,covered:p,rectangle:{minU:i+w.column*d,maxU:i+(w.column+w.columns)*d,minV:c+w.row*d,maxV:c+(w.row+w.rows)*d}}}static largestRectangle(t,e,s){const o=new Array(e).fill(0);let n;for(let a=0;a<s;a++){for(let i=0;i<e;i++)o[i]=t[a*e+i]?o[i]+1:0;const r=[];for(let i=0;i<=e;i++){const h=i===e?0:o[i];for(;r.length>0&&o[r[r.length-1]]>=h;){const c=r.pop(),l=r.length===0?i:i-r[r.length-1]-1,f=o[c]*l;(n===void 0||f>n.area)&&(n={column:i-l,row:a-o[c]+1,columns:l,rows:o[c],area:f})}r.push(i)}}return n}static roof(t){const e=[...t].sort((s,o)=>s-o);return Math.max(2,e[Math.min(e.length-1,Math.floor(e.length*D.ROOF_PERCENTILE))])}static building(t,e,s){const o=Math.cos(e),n=Math.sin(e),a=t.maxU-t.minU,r=t.maxV-t.minV,i=(t.minU+t.maxU)/2,h=(t.minV+t.maxV)/2,l=((90-(a<r?e:e+Math.PI/2)*180/Math.PI)%180+180)%180;return{eastM:D.tenth(i*o-h*n),northM:D.tenth(i*n+h*o),widthM:D.tenth(Math.max(a,r)),lengthM:D.tenth(Math.min(a,r)),heightM:D.tenth(s),headingDeg:Math.round(l*10)/10}}static smallestRectangle(t){let e={area:1/0,angle:0,rectangle:{minU:0,maxU:0,minV:0,maxV:0}};for(let s=0;s<Math.max(1,t.length);s++){const[o,n]=t[s]??[0,0],[a,r]=t[(s+1)%t.length]??[1,0],i=Math.atan2(r-n,a-o),h=Math.cos(i),c=Math.sin(i);let l=1/0,f=-1/0,M=1/0,d=-1/0;for(const[m,E]of t){const v=m*h+E*c,w=-m*c+E*h;l=Math.min(l,v),f=Math.max(f,v),M=Math.min(M,w),d=Math.max(d,w)}const g=(f-l)*(d-M);g<e.area&&(e={area:g,angle:i,rectangle:{minU:l,maxU:f,minV:M,maxV:d}})}return e}static hull(t){const e=[...t].sort((r,i)=>r[0]-i[0]||r[1]-i[1]),s=e.filter((r,i)=>i===0||r[0]!==e[i-1][0]||r[1]!==e[i-1][1]);if(s.length<3)return s;const o=(r,i,h)=>(i[0]-r[0])*(h[1]-r[1])-(i[1]-r[1])*(h[0]-r[0]),n=[];for(const r of s){for(;n.length>=2&&o(n[n.length-2],n[n.length-1],r)<=0;)n.pop();n.push(r)}const a=[];for(const r of[...s].reverse()){for(;a.length>=2&&o(a[a.length-2],a[a.length-1],r)<=0;)a.pop();a.push(r)}return[...n.slice(0,-1),...a.slice(0,-1)]}static tenth(t){return Math.round(t*10)/10}}class H{constructor(t,e,s,o){this.heights=t,this.vegetation=e,this.width=s,this.height=o}static SUMMIT_RADIUS_M=2.5;static CROWN_REACH_M=8;static MAX_WIDTH_M=16;static MIN_WIDTH_M=2;static tenth(t){return Math.round(t*10)/10}trees(t){const e=t.metresPerPixel,s=t.minHeightM??4,o=t.eyeM??1.6,n=t.minElevationDeg??2,a=Math.max(1,Math.round(H.SUMMIT_RADIUS_M/e)),r=Math.round(H.CROWN_REACH_M/e),i=this.width/2,h=this.height/2,c=[];for(let l=0;l<this.height;l++)for(let f=0;f<this.width;f++){const M=this.canopy(f,l);if(M<s)continue;const d=(f+.5-i)*e,g=(h-l-.5)*e,m=Math.hypot(d,g);if(m>t.radiusM||!this.isSummit(f,l,M,a))continue;const E=Math.atan2(M-o,Math.max(m,1))*180/Math.PI;E<n||c.push({tree:{eastM:H.tenth(d),northM:H.tenth(g),heightM:H.tenth(M),widthM:H.tenth(this.crownWidth(f,l,M,e,r))},elevation:E})}return c.sort((l,f)=>f.elevation-l.elevation),c.slice(0,t.maxTrees??150).map(l=>l.tree)}canopy(t,e){if(t<0||e<0||t>=this.width||e>=this.height)return 0;const s=e*this.width+t;return this.vegetation[s]?this.heights[s]:0}isSummit(t,e,s,o){for(let n=-o;n<=o;n++)for(let a=-o;a<=o;a++){if(a===0&&n===0)continue;const r=this.canopy(t+a,e+n);if(r>s||r===s&&(n<0||n===0&&a<0))return!1}return!0}crownWidth(t,e,s,o,n){let a=0;for(let i=-n;i<=n;i++)for(let h=-n;h<=n;h++)Math.hypot(h,i)*o<=H.CROWN_REACH_M&&this.canopy(t+h,e+i)>=s*.5&&a++;const r=2*Math.sqrt(a*o*o/Math.PI);return Math.max(H.MIN_WIDTH_M,Math.min(r,H.MAX_WIDTH_M))}}class _{static WALLS={1:"stone",2:"meuliere",3:"concrete",4:"brick",5:"block",6:"wood",9:"other"};static ROOFS={1:"tile",2:"slate",3:"zinc",4:"concrete",9:"other"};static WALL_COLOURS={stone:"#b9ae9b",meuliere:"#b8a78a",concrete:"#b4b2ac",brick:"#a65f48",block:"#d0c6b2",wood:"#7d5c3e",other:"#c9c0ae"};static PLASTER="#d3cab8";static ROOF_COLOURS={tile:"#a0583f",slate:"#4a5059",zinc:"#8d969c",concrete:"#8f8e8a",other:"#7a7872"};static VARIATION=.12;static OLD_ROOF="#7d858c";static OLD_STOREY_M=3.6;static GRAND_STOREY_M=4.5;static MIN_STOREY_M=2.4;static MAX_STOREY_M=6;static of(t,e){const s=String(t??"").trim();if(!/^\d{1,2}$/.test(s))return;const o=Number(s),n=o%10!==0?o%10:Math.floor(o/10);return(e==="wall"?_.WALLS:_.ROOFS)[String(n)]}static roofColor(t){return t?_.ROOF_COLOURS[t]:void 0}static fit(t){return t.map(e=>{const s=e.style,o={...e.facade,color:e.facade?.color??_.wallColor(e)};s==="church"?o.openings="lancet":s==="monument"||s==="works"?o.openings="plain":(s==="old"||s==="grand")&&(o.openings="tall"),e.closedAtNight&&o.openings!=="plain"&&(o.closedAtNight=!0);const n=_.storeyOf(e);n!==void 0&&s!=="church"&&s!=="monument"&&(o.storeyM=n);const a=s==="old"&&e.roof?.color===void 0?{shape:"flat",riseM:0,...e.roof,color:_.OLD_ROOF}:e.roof;return{...e,facade:o,...a?{roof:a}:{}}})}static storeyOf(t){const e=t.heightM-(t.roof?.riseM??0);if(t.floors&&t.floors>0){const s=e/t.floors;if(s>=_.MIN_STOREY_M&&s<=_.MAX_STOREY_M)return Math.round(s*100)/100}return t.style==="old"?_.OLD_STOREY_M:t.style==="grand"?_.GRAND_STOREY_M:void 0}static wallColor(t){const e=t.style==="church"||t.style==="monument"||t.style==="old",s=t.wallMaterial?_.WALL_COLOURS[t.wallMaterial]:e?_.WALL_COLOURS.stone:_.PLASTER,o=Math.sin(t.eastM*12.9898+t.northM*78.233)*43758.5453,n=1+(o-Math.floor(o)-.5)*2*_.VARIATION,a=r=>Math.max(0,Math.min(255,Math.round(parseInt(s.slice(r,r+2),16)*n))).toString(16).padStart(2,"0");return`#${a(1)}${a(3)}${a(5)}`}}class N{static MIN_RISE_M=1.2;static MIN_EAVES_M=2.5;static MIN_SEEN=.35;static NO_DATA=-9999;static BANDS=7;static INSET_M=.9;static LIFT=1.18;static PEAK=.3;static LEVEL=.45;static fit(t,e,s){return!e&&!s&&!t.some(o=>o.roofMaterial)?t:t.map(o=>{const n=e?N.shapeOf(o,e):void 0,a=(s?N.colorOf(o,s):void 0)??_.roofColor(o.roofMaterial);if(!n&&!a)return o;const r={shape:n?.shape??"flat",...n?.ridge==="depth"?{ridge:"depth"}:{},riseM:n?.riseM??0,...a?{color:a}:{}},i=n&&n.shape!=="flat"?n.topM:o.heightM;return{...o,heightM:i,roof:r}})}static world(t,e,s){const o=t.headingDeg*Math.PI/180;return{east:t.eastM+e*Math.cos(o)+s*Math.sin(o),north:t.northM-e*Math.sin(o)+s*Math.cos(o)}}static shapeOf(t,e){const s=N.BANDS,o=Math.max(e.metresPerPixel,.5),n=t.widthM/2-N.INSET_M,a=t.lengthM/2-N.INSET_M;if(n<=0||a<=0)return;const r=[],i=Array.from({length:s},()=>({sum:0,n:0})),h=Array.from({length:s},()=>({sum:0,n:0}));let c=0;for(let y=-n;y<=n;y+=o)for(let R=-a;R<=a;R+=o){c++;const{east:x,north:$}=N.world(t,y,R),z=Math.floor(x/e.metresPerPixel+e.size/2),Y=Math.floor(e.size/2-$/e.metresPerPixel);if(z<0||Y<0||z>=e.size||Y>=e.size)continue;const k=Y*e.size+z,P=e.heights[k];if(e.vegetation[k]||P===N.NO_DATA||!(P>0))continue;r.push(P);const J=i[Math.min(s-1,Math.floor((y+n)/(2*n)*s))],Q=h[Math.min(s-1,Math.floor((R+a)/(2*a)*s))];J.sum+=P,J.n++,Q.sum+=P,Q.n++}if(c===0||r.length/c<N.MIN_SEEN)return;r.sort((y,R)=>y-R);const l=N.percentile(r,.08),f=N.percentile(r,.92),M=f-l;if(l<N.MIN_EAVES_M||M>Math.min(t.widthM,t.lengthM))return;if(M<N.MIN_RISE_M)return{shape:"flat",riseM:0,topM:f};const d=N.profile(i),g=N.profile(h);if(!d||!g)return;const m=N.peak(g)/M,E=N.peak(d)/M,v=N.spread(d)/M,w=N.spread(g)/M,p=m>=N.PEAK&&v<=N.LEVEL,A=E>=N.PEAK&&w<=N.LEVEL;if(p&&(!A||m>=E))return{shape:"gable",ridge:"width",riseM:M,topM:f};if(A)return{shape:"gable",ridge:"depth",riseM:M,topM:f};if(m>=N.PEAK&&E>=N.PEAK/2)return{shape:"hip",ridge:"width",riseM:M,topM:f}}static profile(t){const e=t.map(s=>s.n>0?s.sum/s.n:NaN);return e.filter(Number.isFinite).length>=t.length-1?e.map((s,o)=>Number.isFinite(s)?s:N.neighbour(e,o)):void 0}static neighbour(t,e){return Number.isFinite(t[e-1])?t[e-1]:t[e+1]}static peak(t){const e=Math.max(1,Math.floor(t.length/3)),s=n=>n.reduce((a,r)=>a+r,0)/n.length,o=[...t.slice(0,e),...t.slice(t.length-e)];return s(t.slice(e,t.length-e))-s(o)}static spread(t){return Math.max(...t)-Math.min(...t)}static percentile(t,e){return t[Math.min(t.length-1,Math.floor(t.length*e))]}static colorOf(t,e){const s=Math.max(e.metresPerPixel,.5),o=Math.max(t.widthM/2-N.INSET_M,s),n=Math.max(t.lengthM/2-N.INSET_M,s),a=[],r=[],i=[];for(let l=-o;l<=o;l+=s)for(let f=-n;f<=n;f+=s){const{east:M,north:d}=N.world(t,l,f),g=Math.floor(M/e.metresPerPixel+e.size/2),m=Math.floor(e.size/2-d/e.metresPerPixel);if(g<0||m<0||g>=e.size||m>=e.size)continue;const E=(m*e.size+g)*e.samples,v=e.values[E],w=e.values[E+1],p=e.values[E+2];w>v&&w>p||(a.push(v),r.push(w),i.push(p))}if(a.length===0)return;const h=l=>l.sort((f,M)=>f-M)[Math.floor(l.length/2)],c=l=>Math.min(255,Math.round(l*N.LIFT)).toString(16).padStart(2,"0");return`#${c(h(a))}${c(h(r))}${c(h(i))}`}}class G{static DEFAULT_HEIGHT_M=6;static METRES_PER_DEGREE=111320;static STREET_SPACING_M=35;static KERB_OFFSET_M=1;static DEFAULT_WIDTH_M=5.5;static PATIENCE_MS=15e3;static MAX=150;static lampsFrom(t,e,s){const o=[],n=new Set;for(const r of t.elements??[]){if(r.id!==void 0){const l=`${r.type}/${r.id}`;if(n.has(l))continue;n.add(l)}if(r.type==="way"){r.tags?.lit==="yes"&&G.alongStreet(r,e,o);continue}if(r.tags?.highway!=="street_lamp"||typeof r.lat!="number"||typeof r.lon!="number")continue;const i=(r.lon-e.lng)*G.METRES_PER_DEGREE*Math.cos(e.lat*Math.PI/180),h=(r.lat-e.lat)*G.METRES_PER_DEGREE;if(Math.hypot(i,h)>s)continue;const c=Number.parseFloat(r.tags?.height??"");o.push({eastM:Math.round(i*10)/10,northM:Math.round(h*10)/10,...Number.isFinite(c)&&c>=2&&c<=20?{heightM:c}:{}})}const a=o.filter(r=>Math.hypot(r.eastM,r.northM)<=s);return o.length=0,o.push(...a),o.sort((r,i)=>Math.hypot(r.eastM,r.northM)-Math.hypot(i.eastM,i.northM)),o.slice(0,G.MAX)}static alongStreet(t,e,s){const o=t.geometry;if(!o||o.length<2)return;const n=d=>[(d.lon-e.lng)*G.METRES_PER_DEGREE*Math.cos(e.lat*Math.PI/180),(d.lat-e.lat)*G.METRES_PER_DEGREE],a=o.map(n),r=Number.parseFloat(t.tags?.width??""),i=Number.parseInt(t.tags?.lanes??"",10),c=(Number.isFinite(r)&&r>0?r:Number.isFinite(i)&&i>0?i*3.5:G.DEFAULT_WIDTH_M)/2+G.KERB_OFFSET_M;let l=1,f=G.STREET_SPACING_M/2,M=0;for(let d=1;d<a.length;d++){const[g,m]=a[d-1],[E,v]=a[d],w=Math.hypot(E-g,v-m);if(w===0)continue;const p=(E-g)/w,A=(v-m)/w;for(;f<=M+w;f+=G.STREET_SPACING_M){const y=f-M;s.push({eastM:Math.round((g+p*y+A*c*l)*10)/10,northM:Math.round((m+A*y-p*c*l)*10)/10,supposed:!0}),l=-l}M+=w}}}class u{constructor(t={},e=[],s=[]){this.lampSources=e,this.signalSources=s,this.client=new tt(t)}static METRES_PER_DEGREE=111320;static KERB_OFFSET_M=.6;static SETBACK_M=.5;static MIN_CROSSING_M=3;static MAX_CROSSING_M=30;static SAME_CROSSING_M=5;static SAME_HEAD_M=2.5;static SAME_HEAD_DEG=45;static MAX_SIGNALS=160;static MAX_CROSSINGS=150;static MAX_SIGNS=100;static ROADS=new Set([...q.DRIVABLE,"living_street","busway","road"]);static ON_ROAD="^(traffic_signals|crossing|stop|give_way)$";static CREDIT={name:"OpenStreetMap",url:"https://www.openstreetmap.org/copyright",licence:"ODbL"};client;local(t,e){const s=u.boxOf(t,e),o=(r,i)=>{if(!r)return Promise.resolve(void 0);const h=`${r.credit.url} ${s}`;let c=u.localPending.get(h);return c||(c=i().then(l=>({credit:r.credit,found:l}),()=>{u.localPending.delete(h)}),u.localPending.set(h,c)),c},n=this.lampSources.find(r=>r.covers(t.lat,t.lng)),a=this.signalSources.find(r=>r.covers(t.lat,t.lng));return Promise.all([o(n,()=>n.lampsNear(t,e)),o(a,()=>a.signalsNear(t,e))]).then(([r,i])=>({lamps:r,signals:i}))}static localPending=new Map;static withLocal(t,e){const s=e?.lamps?e.lamps.found:t.lamps,o=e?.signals?e.signals.found:t.signals,a=[...u.found({crossings:t.crossings,signs:t.signs,...e?.lamps?{}:{lamps:s},...e?.signals?{}:{signals:o}})?[u.CREDIT]:[],...e?.lamps&&e.lamps.found.length>0?[e.lamps.credit]:[],...e?.signals&&e.signals.found.length>0?[e.signals.credit]:[]],{lamps:r,signals:i,credits:h,...c}=t;return{...c,...s?.length?{lamps:s}:{},...o?.length?{signals:o}:{},...a.length>0?{credits:a}:{}}}static today(){return new Date().toISOString().slice(0,10)}static later(t,e,s){return t?.answered(e,s).then(o=>({...o,...u.found(o)?{dates:{lamps:u.today()}}:{}}))}static found(t){return!!(t?.lamps?.length||t?.signals?.length||t?.crossings?.length||t?.signs?.length)}static query(t){const e=u.ON_ROAD;return`[out:json][timeout:25];(node["highway"="street_lamp"](${t});way["highway"]["lit"="yes"](${t});node["highway"~"${e}"](${t});node["traffic_sign"](${t});way["footway"="crossing"](${t}););out geom;(node._["highway"~"${e}"];node._["traffic_sign"];)->.kerb;way(bn.kerb)["highway"];out geom;`}static pending=new Map;async near(t,e){const s=this.ask(u.boxOf(t,e)),o=this.local(t,e);let n;const a=Symbol("late"),r=new Promise(i=>{n=setTimeout(()=>i(a),G.PATIENCE_MS)});try{const[i,h]=await Promise.all([Promise.race([s,r]),Promise.race([o,r])]),c=h===a?void 0:h;return i===a||i===void 0?{...u.withLocal({},c),incomplete:!0}:u.withLocal(u.from(i,t,e),c)}finally{clearTimeout(n)}}static RETRY_DELAYS_MS=[15e3,6e4,18e4,6e5];async answered(t,e){const s=u.boxOf(t,e);for(let o=0;;o++){const n=await this.ask(s);if(n)return u.withLocal(u.from(n,t,e),await this.local(t,e));if(o>=u.RETRY_DELAYS_MS.length)throw new Error("Overpass did not answer");await new Promise(a=>setTimeout(a,u.RETRY_DELAYS_MS[o]))}}ask(t){let e=u.pending.get(t);return e||(e=this.client.query(u.query(t)).catch(()=>{u.pending.delete(t)}),u.pending.set(t,e)),e}static boxOf(t,e){const s=e/u.METRES_PER_DEGREE,o=e/(u.METRES_PER_DEGREE*Math.cos(t.lat*Math.PI/180));return[t.lat-s,t.lng-o,t.lat+s,t.lng+o].map(n=>n.toFixed(6)).join(",")}static forget(){u.pending.clear(),u.localPending.clear()}static from(t,e,s){const o=G.lampsFrom(t,e,s),n=Math.cos(e.lat*Math.PI/180),a=(p,A)=>[(A-e.lng)*u.METRES_PER_DEGREE*n,(p-e.lat)*u.METRES_PER_DEGREE],r=(p,A)=>`${p.toFixed(7)},${A.toFixed(7)}`,i=new Map,h=new Set,c=[],l=[];for(const p of t.elements??[]){if(p.type==="node"){typeof p.lat=="number"&&typeof p.lon=="number"&&l.push(p);continue}if(p.type!=="way"||!p.geometry||p.geometry.length<2)continue;if(p.id!==void 0){if(h.has(p.id))continue;h.add(p.id)}const A=p.tags??{};if(A.footway==="crossing"&&c.push(p),!u.ROADS.has(A.highway??""))continue;const y=p.geometry.map(R=>a(R.lat,R.lon));p.geometry.forEach((R,x)=>{const $=r(R.lat,R.lon);i.set($,[...i.get($)??[],{way:p,points:y,index:x}])})}const f=[],M=[],d=[],g=new Set;for(const p of l){if(p.id!==void 0){if(g.has(p.id))continue;g.add(p.id)}const A=p.tags??{},y=a(p.lat,p.lon),R=i.get(r(p.lat,p.lon))??[],x=A.highway;if(x==="traffic_signals")for(const k of u.approaches(R,u.directionOf(A),!1))f.push(u.head(y,k,"vehicles"));if(x==="crossing"||x==="traffic_signals"&&A.crossing!==void 0){const k=R[0];if(k&&u.marked(A)){const P=u.directionAt(k);P&&M.push({eastM:u.round(y[0]),northM:u.round(y[1]),headingDeg:u.heading(P),widthM:q.widthOf(k.way.tags??{})}),P&&(A.crossing==="traffic_signals"||A["crossing:signals"]==="yes")&&f.push(...u.pedestrianHeads(y,P,k))}}if(x==="traffic_signals")continue;const $=x==="stop"?{face:"stop"}:x==="give_way"?{face:"give-way"}:u.faceOf(A);if(!$)continue;const z=A.traffic_sign?{code:A.traffic_sign}:{};if(R.length>0){const k=u.approaches(R,u.directionOf(A),!0)[0];if(k){const P=u.head(y,k,"vehicles");d.push({eastM:P.eastM,northM:P.northM,headingDeg:P.headingDeg,...$,...z})}continue}const Y=u.compassOf(A.direction);Y!==void 0&&d.push({eastM:u.round(y[0]),northM:u.round(y[1]),headingDeg:(Y+180)%360,...$,...z})}for(const p of c){const A=u.crossingAlong(p,a);A&&!M.some(y=>Math.hypot(y.eastM-A.eastM,y.northM-A.northM)<u.SAME_CROSSING_M)&&M.push(A)}const m=f.filter((p,A)=>!f.slice(0,A).some(y=>y.for===p.for&&Math.hypot(y.eastM-p.eastM,y.northM-p.northM)<u.SAME_HEAD_M&&Math.abs((y.headingDeg-p.headingDeg+540)%360-180)<u.SAME_HEAD_DEG)),E=(p,A)=>p.filter(y=>Math.hypot(y.eastM,y.northM)<=s).sort((y,R)=>Math.hypot(y.eastM,y.northM)-Math.hypot(R.eastM,R.northM)).slice(0,A),v={};o.length>0&&(v.lamps=o);const w={signals:E(m,u.MAX_SIGNALS),crossings:E(M,u.MAX_CROSSINGS),signs:E(d,u.MAX_SIGNS)};return w.signals.length>0&&(v.signals=w.signals),w.crossings.length>0&&(v.crossings=w.crossings),w.signs.length>0&&(v.signs=w.signs),v}static approaches(t,e,s){const o=[];for(const a of t){const r=a.way.tags??{},i=r.oneway==="yes"||r.oneway==="true"||r.oneway==="1"||r.junction==="roundabout"||r.highway==="motorway",h=r.oneway==="-1",{points:c,index:l}=a,f=(d,g)=>{let m=0;for(let E=Math.min(d,g);E<Math.max(d,g);E++)m+=Math.hypot(c[E+1][0]-c[E][0],c[E+1][1]-c[E][1]);return m},M=d=>{const g=c[l][0]-c[d][0],m=c[l][1]-c[d][1],E=Math.hypot(g,m);return E>0?[g/E,m/E]:void 0};if(l>0&&!h){const d=M(l-1);d&&o.push({approach:{unit:d,road:a},toEndM:f(l,c.length-1),forward:!0})}if(l<c.length-1&&!i){const d=M(l+1);d&&o.push({approach:{unit:d,road:a},toEndM:f(0,l),forward:!1})}}const n=e!==void 0&&t.length===1?o.filter(a=>a.forward===(e==="forward")):o;return!s||n.length<=1?n.map(a=>a.approach):[n.reduce((a,r)=>r.toEndM<a.toEndM?r:a).approach]}static head(t,e,s){const[o,n]=e.unit,a=q.widthOf(e.road.way.tags??{})/2+u.KERB_OFFSET_M,r=u.SETBACK_M,i=u.heading(e.unit);return{eastM:u.round(t[0]-o*r+n*a),northM:u.round(t[1]-n*r-o*a),headingDeg:(i+180)%360,for:s,phase:j.phaseOf(i)}}static pedestrianHeads(t,e,s){const o=q.widthOf(s.way.tags??{})/2+u.KERB_OFFSET_M,n=u.heading(e),a=j.phaseOf(n);return[1,-1].map(r=>({eastM:u.round(t[0]+e[1]*o*r),northM:u.round(t[1]-e[0]*o*r),headingDeg:(n+(r===1?270:90))%360,for:"pedestrians",phase:a}))}static crossingAlong(t,e){if(!u.marked(t.tags??{}))return;const s=t.geometry.map(h=>e(h.lat,h.lon)),[o,n]=s[0],[a,r]=s[s.length-1],i=Math.hypot(a-o,r-n);if(!(i<u.MIN_CROSSING_M))return{eastM:u.round((o+a)/2),northM:u.round((n+r)/2),headingDeg:(u.heading([(a-o)/i,(r-n)/i])+90)%360,widthM:Math.round(Math.min(i,u.MAX_CROSSING_M)*10)/10}}static marked(t){const e=t.crossing;return e!=="unmarked"&&e!=="no"&&e!=="informal"&&t["crossing:markings"]!=="no"}static directionAt(t){const{points:e,index:s}=t,[o,n]=s<e.length-1?[e[s],e[s+1]]:[e[s-1],e[s]],a=Math.hypot(n[0]-o[0],n[1]-o[1]);return a>0?[(n[0]-o[0])/a,(n[1]-o[1])/a]:void 0}static directionOf(t){const e=t["traffic_signals:direction"]??t["traffic_sign:direction"]??t.direction;return e==="forward"||e==="backward"?e:void 0}static compassOf(t){if(t===void 0)return;const e=Number.parseFloat(t);if(Number.isFinite(e)&&/^\s*-?\d/.test(t))return(e%360+360)%360;const o=["N","NNE","NE","ENE","E","ESE","SE","SSE","S","SSW","SW","WSW","W","WNW","NW","NNW"].indexOf(t.trim().toUpperCase());return o<0?void 0:o*22.5}static faceOf(t){const e=t.traffic_sign;if(!e||e==="no"||e==="none")return;const s=e.split(/[;,]/).map(o=>o.trim());if(s.some(o=>/stop|:AB4\b|:206\b|:R1-1\b|:B2\b/i.test(o)))return{face:"stop"};if(s.some(o=>/give_way|yield|:AB3a\b|:205\b|:R1-2\b|:B1\b/i.test(o)))return{face:"give-way"};for(const o of s){const n=/maxspeed|:B14\b|:274\b|:C14\b|:R2-1\b/i.test(o)?Number.parseInt(/\[(\d+)\]/.exec(o)?.[1]??t.maxspeed??"",10):Number.NaN;if(Number.isFinite(n)&&n>0)return{face:"speed-limit",value:n}}return{face:"other"}}static heading([t,e]){return Math.round((Math.atan2(t,e)*180/Math.PI+360)%360*10)/10}static round(t){return Math.round(t*10)/10}}class nt{id="ign-lidar-hd";name="IGN LiDAR HD";attribution="Canopy and roofs © IGN, LiDAR HD (Licence Ouverte 2.0), as surveyed on a day the service does not give";creditUrl="https://geoservices.ign.fr/lidarhd";contemporary=!0;platform;furniture;constructor(t={},e){this.platform=new C(t),this.furniture=e}covers(t,e){return C.covers(t,e)}later(t,e){return u.later(this.furniture,t,e)}async getSurroundings(t,e){if(!this.covers(t.lat,t.lng))throw new V("no-coverage","The LiDAR HD survey covers France only");const s=C.lidarRadius(e),[o,n,a,r,i]=await Promise.all([this.platform.lidar(t,s),this.platform.photo(t,s).catch(()=>{}),this.furniture?.near(t,e),this.platform.laserDate(t),this.platform.photoDate(t)]);return{trees:new H(o.heights,o.vegetation,o.size,o.size).trees({metresPerPixel:o.metresPerPixel,radiusM:s}),buildings:_.fit(N.fit(new D(o.heights,o.building,o.size,o.size).buildings({metresPerPixel:o.metresPerPixel,radiusM:s,maxBuildings:300}),o,n)),bridges:[],lines:[],...a,dates:{...r?{laser:r}:{},...n&&i?{photo:i}:{},...u.found(a)?{lamps:u.today()}:{}}}}}class b{static MAP_NATURES={Eglise:"church",Chapelle:"church",Monument:"monument","Tour, donjon":"monument","Fort, blockhaus, casemate":"monument","Arc de triomphe":"monument","Arène ou théâtre antique":"monument",Château:"old","Industriel, agricole ou commercial":"works",Serre:"works",Silo:"works"};static MAP_WORKS=new Set(["Industriel","Agricole","Annexe"]);static MAP_CLOSED_AT_NIGHT=new Set(["Commercial et services","Sportif"]);static OSM_CLOSED_AT_NIGHT=new Set(["retail","commercial","office","supermarket","kiosk","sports_hall","sports_centre","stadium","school","university","college","kindergarten","public","civic","government","train_station","transportation"]);static OSM_BUILDINGS={cathedral:"church",church:"church",chapel:"church",basilica:"church",temple:"church",mosque:"church",synagogue:"church",shrine:"church",religious:"church",castle:"old",palace:"old",fortress:"monument",bunker:"monument",triumphal_arch:"monument",industrial:"works",warehouse:"works",barn:"works",farm_auxiliary:"works",shed:"works",hangar:"works",garage:"works",garages:"works",greenhouse:"works",silo:"works",storage_tank:"works",cowshed:"works",stable:"works",sty:"works",manufacture:"works"};static OSM_HISTORIC={church:"church",chapel:"church",monastery:"old",castle:"old",manor:"old",fort:"monument",tower:"monument",monument:"monument",memorial:"monument",city_gate:"monument"};static OLD_BEFORE=1900;static GRAND_FROM_M=15;static GRAND_UP_TO_M=40;static TOWER_SLENDERNESS=2;static CHURCH_PITCH=.7;static CHURCH_ROOF_OF_WALLS=.35;static CHURCH_ROOF_COLOUR="#5a6068";static ofMap(t){const e=b.year(t.date_d_apparition),o=b.MAP_NATURES[String(t.nature??"")]??(t.usage_1==="Religieux"?"church":void 0)??(b.MAP_WORKS.has(String(t.usage_1??""))?"works":void 0)??b.ofYear(e)??b.grand(t),n=b.MAP_CLOSED_AT_NIGHT.has(String(t.usage_1??""));return{...o?{style:o}:{},...e!==void 0?{builtYear:e}:{},...n?{closedAtNight:!0}:{}}}static ofOsm(t){const e=b.year(t.start_date),s=t.historic&&t.historic!=="no"?b.OSM_HISTORIC[t.historic]??"old":void 0,o=t.amenity==="place_of_worship"?"church":void 0,n=b.OSM_BUILDINGS[t.building??""]??s??o??b.ofYear(e),a=b.OSM_CLOSED_AT_NIGHT.has(t.building??"")||t.shop!==void 0&&t.shop!=="no";return{...n?{style:n}:{},...e!==void 0?{builtYear:e}:{},...a?{closedAtNight:!0}:{}}}static year(t){const e=Number(/\b(\d{4})\b/.exec(String(t??""))?.[1]);return Number.isFinite(e)&&e>=1e3&&e<=2100?e:void 0}static fit(t){return t.map(e=>e.style==="church"?b.church(e):e)}static isTower(t){return t.heightM>=b.TOWER_SLENDERNESS*Math.max(t.widthM,t.lengthM)}static church(t){const e=t.roof?.color??b.CHURCH_ROOF_COLOUR;if(b.isTower(t))return{...t,roof:{shape:"flat",riseM:0,color:e}};if(t.roof&&t.roof.shape!=="flat")return t;const s=Math.round(Math.min(b.CHURCH_PITCH*t.lengthM,b.CHURCH_ROOF_OF_WALLS*t.heightM)*10)/10,o={shape:"gable",riseM:s,color:e};return{...t,heightM:Math.round((t.heightM+s)*10)/10,roof:o}}static ofYear(t){return t!==void 0&&t<b.OLD_BEFORE?"old":void 0}static grand(t){const e=Number(t.hauteur),s=Number(t.nombre_d_etages);if(!(Number.isFinite(s)&&s>0)&&!(t.usage_1==="Résidentiel"||t.date_d_apparition))return e>=b.GRAND_FROM_M&&e<=b.GRAND_UP_TO_M?"grand":void 0}}class O{static METRES_PER_DEGREE=111320;static NAMED_NATURES={Silo:"Silo"};static DEFAULT_HEIGHT_M=6;static FLOOR_HEIGHT_M=3;static FINE_M=.5;static COARSE_M=1;static MAX_CELLS=4e4;static RECTANGLE_FILL=.9;static buildings(t,e,s,o=12,n=300,a=[]){const r=[];for(const h of O.reached(t,a,e,s)){const c=h.feature,l=Number(c.properties.nombre_d_etages),f=Number(c.properties.hauteur),M=Number.isFinite(f)&&f>0?f:Number.isFinite(l)&&l>0?l*O.FLOOR_HEIGHT_M:O.DEFAULT_HEIGHT_M,{style:d,builtYear:g,closedAtNight:m}=b.ofMap(c.properties);for(const E of O.rectanglesOf(h.rings,M,o)){const v=_.of(c.properties.materiaux_des_murs,"wall"),w=_.of(c.properties.materiaux_de_la_toiture,"roof"),p=O.NAMED_NATURES[String(c.properties.nature??"")];r.push({...E,...p?{name:p}:{},...Number.isFinite(l)&&l>0?{floors:l}:{},...v?{wallMaterial:v}:{},...w?{roofMaterial:w}:{},...d?{style:d}:{},...g!==void 0?{builtYear:g}:{},...m?{closedAtNight:m}:{}})}}const i=h=>Math.hypot(h.eastM,h.northM);if(r.length>n){const h=c=>(c.heightM+6)*Math.sqrt(c.widthM*c.lengthM)/Math.max(i(c),50);r.sort((c,l)=>h(l)-h(c)),r.length=n}return r.sort((h,c)=>i(h)-i(c)),r}static named(t,e,s){const o=e.map(n=>({name:typeof n.properties.toponyme=="string"?n.properties.toponyme:"",rings:O.rings(n,s)})).filter(n=>n.name.length>0&&n.rings.length>0);return o.length===0?t:t.map(n=>{const a=o.find(r=>O.inside(n.eastM,n.northM,r.rings));return a?{...n,name:a.name}:n})}static reached(t,e,s,o){const n=t.map(i=>({feature:i,rings:O.rings(i,s)})).filter(i=>i.rings.length>0),a=n.map(i=>O.reach(i.rings)<=o),r=e.filter(i=>typeof i.properties.toponyme=="string"&&i.properties.toponyme.length>0).map(i=>O.rings(i,s)).filter(i=>i.length>0);if(r.length>0){const i=n.map(c=>{const l=c.rings[0],f=l.reduce((d,g)=>d+g.east,0)/l.length,M=l.reduce((d,g)=>d+g.north,0)/l.length;return r.findIndex(d=>O.inside(f,M,d))}),h=new Set(i.filter((c,l)=>c>=0&&a[l]));i.forEach((c,l)=>{h.has(c)&&(a[l]=!0)})}return n.filter((i,h)=>a[h])}static reach(t){if(O.inside(0,0,t))return 0;let e=1/0;for(const s of t)for(let o=0;o+1<s.length;o++){const n=s[o],a=s[o+1],r=a.east-n.east,i=a.north-n.north,h=r*r+i*i>0?Math.max(0,Math.min(1,-(n.east*r+n.north*i)/(r*r+i*i))):0;e=Math.min(e,Math.hypot(n.east+h*r,n.north+h*i))}return e}static inside(t,e,s){let o=0;for(const n of s)for(let a=0;a+1<n.length;a++){const r=n[a],i=n[a+1];r.north<=e!=i.north<=e&&r.east+(e-r.north)/(i.north-r.north)*(i.east-r.east)>t&&o++}return o%2===1}static rings(t,e){const s=t.geometry,o=s.type==="Polygon"?[s.coordinates]:s.type==="MultiPolygon"?s.coordinates:[],n=Math.cos(e.lat*Math.PI/180),a=[];for(const r of o)for(const i of r)a.push(i.map(([h,c])=>({east:(h-e.lng)*O.METRES_PER_DEGREE*n,north:(c-e.lat)*O.METRES_PER_DEGREE})));return a}static rectanglesOf(t,e,s){let o=1/0,n=-1/0,a=1/0,r=-1/0;for(const f of t)for(const M of f)o=Math.min(o,M.east),n=Math.max(n,M.east),a=Math.min(a,M.north),r=Math.max(r,M.north);let i=O.FINE_M;(n-o)*(r-a)/(i*i)>O.MAX_CELLS&&(i=O.COARSE_M);const h=[],c=[];for(let f=a+i/2;f<r;f+=i){const M=[];for(const d of t)for(let g=0;g+1<d.length;g++){const m=d[g],E=d[g+1];m.north<=f!=E.north<=f&&M.push(m.east+(f-m.north)/(E.north-m.north)*(E.east-m.east))}M.sort((d,g)=>d-g);for(let d=0;d+1<M.length;d+=2)for(let g=Math.ceil((M[d]-i/2)/i)*i+i/2;g<M[d+1];g+=i)h.push(g),c.push(f)}if(h.length*i*i<s)return[];const l=t.flatMap(f=>f.slice(0,-1).map((M,d)=>({from:M,to:f[d+1]})));return D.ofPoints(h,c,new Array(h.length).fill(e),i,s,O.RECTANGLE_FILL,l)}}class F{id="ign-lidar-topo";name="IGN LiDAR HD + BD TOPO";attribution="Canopy © IGN, LiDAR HD; buildings, bridges and lines © IGN, BD TOPO (Licence Ouverte 2.0), as surveyed on days the services do not give";creditUrl="https://geoservices.ign.fr/lidarhd";contemporary=!0;static BRIDGE_MARGIN_M=30;static MAX_BRIDGE_WINDOWS=8;platform;furniture;constructor(t={},e){this.platform=new C(t),this.furniture=e}covers(t,e){return C.covers(t,e)}later(t,e){return u.later(this.furniture,t,e)}async getSurroundings(t,e){if(!this.covers(t.lat,t.lng))throw new V("no-coverage","The IGN's surveys cover France only");const s=C.radius(e),[o,n,a,r,i,h]=await Promise.allSettled([this.platform.lidar(t,s),this.platform.vectors(t,s,!0),this.platform.photo(t,s),this.furniture?.near(t,e)??Promise.resolve(void 0),this.platform.laserDate(t),this.platform.photoDate(t)]),c=C.lidarRadius(s);if(o.status==="rejected"&&n.status==="rejected")throw o.reason;const l=o.status==="fulfilled"?o.value:void 0,f=n.status==="fulfilled"?n.value:void 0,M=f!==void 0&&f.buildings.length===0&&f.bridges.length===0&&f.lines.length===0;if(o.status==="rejected"&&o.reason instanceof V&&o.reason.reason==="no-coverage"&&M)throw o.reason;return{trees:l?new H(l.heights,l.vegetation,l.size,l.size).trees({metresPerPixel:l.metresPerPixel,radiusM:c}):[],buildings:this.roofed(this.buildings(l,f,t,s),l,a.status==="fulfilled"?a.value:void 0),bridges:f?await this.bridges(f,t,s,l?.structures,c):[],lines:f?X.lines(f,t,s,l?.structures):[],...r.status==="fulfilled"?r.value:{},dates:{...o.status==="fulfilled"&&i.status==="fulfilled"&&i.value?{laser:i.value}:{},...a.status==="fulfilled"&&h.status==="fulfilled"&&h.value?{photo:h.value}:{},...f?.mapDate?{map:f.mapDate}:{},...r.status==="fulfilled"&&u.found(r.value)?{lamps:u.today()}:{}}}}async bridges(t,e,s,o,n){const a=X.bridges(t,e,s,o);let r=0;return Promise.all(a.map(async i=>{if(o!==void 0&&Math.hypot(i.eastM,i.northM)+i.lengthM/2<=n)return i;const h=i.lengthM/2+F.BRIDGE_MARGIN_M;if(r++>=F.MAX_BRIDGE_WINDOWS)return i;const c=ot(i.eastM,-i.northM,e.lat,e.lng);try{const l=await this.platform.lidar(c,h),f=X.bridges(t,c,h,l.structures).sort((M,d)=>Math.hypot(M.eastM,M.northM)-Math.hypot(d.eastM,d.northM))[0];return!f||Math.hypot(f.eastM,f.northM)>i.lengthM/2?i:{...f,eastM:X.tenth(f.eastM+i.eastM),northM:X.tenth(f.northM+i.northM)}}catch{return i}}))}roofed(t,e,s){return _.fit(b.fit(N.fit(t,e,s)))}buildings(t,e,s,o){const n=e?O.buildings(e.buildings,s,o,void 0,void 0,e.zones):[],a=n.length>0||t===void 0?n:new D(t.heights,t.building,t.size,t.size).buildings({metresPerPixel:t.metresPerPixel,radiusM:C.lidarRadius(o),maxBuildings:300});return e?O.named(a,e.zones,s):a}}class at{id="ign-bd-topo";name="IGN BD TOPO";attribution="Buildings, bridges and lines © IGN, BD TOPO (Licence Ouverte 2.0), as drawn on a day the service does not give";creditUrl="https://geoservices.ign.fr/bdtopo";contemporary=!0;platform;furniture;constructor(t={},e){this.platform=new C(t),this.furniture=e}covers(t,e){return C.covers(t,e)}later(t,e){return u.later(this.furniture,t,e)}async getSurroundings(t,e){if(!this.covers(t.lat,t.lng))throw new V("no-coverage","BD TOPO covers France only");const s=C.radius(e),[o,n,a,r]=await Promise.all([this.platform.vectors(t,s,!0),this.platform.photo(t,s).catch(()=>{}),this.furniture?.near(t,e),this.platform.photoDate(t)]);return{trees:[],buildings:_.fit(b.fit(N.fit(O.named(O.buildings(o.buildings,t,s,void 0,void 0,o.zones),o.zones,t),void 0,n))),bridges:X.bridges(o,t,s,void 0),lines:X.lines(o,t,s,void 0),...a,dates:{...o.mapDate?{map:o.mapDate}:{},...n&&r?{photo:r}:{},...u.found(a)?{lamps:u.today()}:{}}}}}class S{static ROOF_SHAPES={flat:"flat",gabled:"gable",gambrel:"gable",saltbox:"gable","half-hipped":"hip",hipped:"hip",pyramidal:"hip",mansard:"hip",round:"gable",dome:"dome",onion:"dome"};static WALL_MATERIALS={brick:"brick",stone:"stone",granite:"stone",sandstone:"stone",limestone:"stone",concrete:"concrete",cement_block:"block",block:"block",wood:"wood",timber_framing:"wood"};static ROOF_MATERIALS={roof_tiles:"tile",tiles:"tile",tile:"tile",slate:"slate",metal:"zinc",zinc:"zinc",tin:"zinc",copper:"zinc",concrete:"concrete",eternit:"other"};static COLOURS={white:"#e8e6e0",grey:"#8c8c8a",gray:"#8c8c8a",black:"#3a3a3a",red:"#a8483a",brown:"#6e4f38",beige:"#d6c9a8",yellow:"#d8c070",orange:"#c9773a",green:"#5f7a52",blue:"#506a8a",tan:"#c0a37a",cream:"#e6dcc0",pink:"#c99a96",silver:"#b4b6b6"};static height(t){const e=Number.parseFloat((t??"").replace(",","."));return Number.isFinite(e)&&e>=2&&e<=500?e:void 0}static levels(t){const e=Number.parseInt(t??"",10);return Number.isFinite(e)&&e>=1&&e<=150?e:void 0}static roofShape(t){return S.ROOF_SHAPES[(t??"").trim().toLowerCase()]}static wallMaterial(t){return S.WALL_MATERIALS[(t??"").trim().toLowerCase()]}static roofMaterial(t){return S.ROOF_MATERIALS[(t??"").trim().toLowerCase()]}static colour(t){const e=(t??"").trim().toLowerCase();return/^#[0-9a-f]{6}$/.test(e)?e:/^#[0-9a-f]{3}$/.test(e)?`#${e[1]}${e[1]}${e[2]}${e[2]}${e[3]}${e[3]}`:S.COLOURS[e]}}class W{id="osm-buildings";name="OpenStreetMap buildings";attribution="Buildings © OpenStreetMap contributors (ODbL), as drawn on the day of the data, which a recording is not";creditUrl="https://www.openstreetmap.org/copyright";contemporary=!0;static MAX_RADIUS_M=1500;static MIN_AREA_M2=12;static MAX_BUILDINGS=300;client;furniture;constructor(t={},e){this.client=new tt(t),this.furniture=e}covers(){return!0}later(t,e){return u.later(this.furniture,t,e)}async getSurroundings(t,e){const s=Math.min(e,W.MAX_RADIUS_M);let o;try{o=await this.client.query(`[out:json][timeout:30];(way["building"](around:${s},${t.lat},${t.lng});relation["building"]["type"="multipolygon"](around:${s},${t.lat},${t.lng}););out geom;`)}catch(r){throw new V("unreachable",r instanceof Error?r.message:String(r))}const n=await this.furniture?.near(t,e),a=(o.osm3s?.timestamp_osm_base??"").slice(0,10);return{trees:[],buildings:_.fit(b.fit(W.buildings(o,t,s))),bridges:[],lines:[],...n,dates:{.../^\d{4}-\d{2}-\d{2}$/.test(a)?{map:a}:{},...u.found(n)?{lamps:u.today()}:{}}}}static buildings(t,e,s){const o=[];for(const n of t.elements??[]){const a=W.ringsOf(n);if(a.length===0)continue;const r=n.tags??{},i=S.levels(r["building:levels"]),h=S.height(r.height),c={geometry:{type:"Polygon",coordinates:a},properties:{...h?{hauteur:h}:{},...i?{nombre_d_etages:i}:{}}};for(const l of O.buildings([c],e,s,W.MIN_AREA_M2,50))o.push(W.described(l,r,h!==void 0))}return o.sort((n,a)=>Math.hypot(n.eastM,n.northM)-Math.hypot(a.eastM,a.northM)),o.slice(0,W.MAX_BUILDINGS)}static ringsOf(t){const e=o=>{if(!o||o.length<4)return;const n=o.map(i=>[i.lon,i.lat]),a=n[0],r=n[n.length-1];return a[0]===r[0]&&a[1]===r[1]?n:void 0};if(t.type==="way"){const o=e(t.geometry);return o?[o]:[]}return(t.members??[]).filter(o=>o.role==="outer").map(o=>e(o.geometry)).filter(o=>o!==void 0).slice(0,1)}static described(t,e,s){const o=S.wallMaterial(e["building:material"]),n=S.roofMaterial(e["roof:material"]),a=S.colour(e["building:colour"]),r=S.colour(e["roof:colour"])??_.roofColor(n),i=S.roofShape(e["roof:shape"]),h=a?{color:a}:void 0;let c,l=t.heightM;if(i==="gable"||i==="hip"||i==="dome"){const g=S.height(e["roof:height"]),m=Math.round((g??Math.min(5,Math.max(1.5,.29*Math.min(t.widthM,t.lengthM))))*10)/10;s||(l=Math.round((t.heightM+m)*10)/10),c={shape:i,riseM:m,...e["roof:orientation"]==="across"?{ridge:"depth"}:{},...r?{color:r}:{}}}else(i==="flat"||r)&&(c={shape:"flat",riseM:0,...r?{color:r}:{}});const{style:f,builtYear:M,closedAtNight:d}=b.ofOsm(e);return{...t,heightM:l,...f?{style:f}:{},...M!==void 0?{builtYear:M}:{},...d?{closedAtNight:d}:{},...e.name?{name:e.name}:{},...o?{wallMaterial:o}:{},...n?{roofMaterial:n}:{},...h?{facade:h}:{},...c?{roof:c}:{}}}}class L{credit={name:"Ville de Paris, Éclairage public",url:"https://opendata.paris.fr/explore/dataset/eclairage-public/",licence:"ODbL",of:"lamps"};static BOUNDS={south:48.8156,north:48.9022,west:2.2241,east:2.4698};static ENDPOINT="https://opendata.paris.fr/api/explore/v2.1/catalog/datasets/eclairage-public/records";static PAGE=100;static MAX=150;static MAX_PAGES=4;static METRES_PER_DEGREE=111320;static SAME_COLUMN_M=.5;static MIN_HEIGHT_M=2;fetchImpl;constructor(t){this.fetchImpl=t??fetch.bind(globalThis)}covers(t,e){const s=L.BOUNDS;return t>=s.south&&t<=s.north&&e>=s.west&&e<=s.east}async lampsNear(t,e){const s=[];let o=[];for(let n=0;n<L.MAX_PAGES&&o.length<L.MAX;n++){const a=await this.fetchImpl(L.query(t,e,L.PAGE,n*L.PAGE));if(!a.ok)throw new Error(`opendata.paris.fr refused (${a.status})`);const r=(await a.json()).results??[];if(s.push(...r),o=L.lampsFrom(s,t),r.length<L.PAGE)break}return o.slice(0,L.MAX)}static query(t,e,s,o){const n=`geom'POINT(${t.lng.toFixed(6)} ${t.lat.toFixed(6)})'`,a=new URLSearchParams({select:"geo_point_2d,lib_ouvrag,lampe_temperature_couleur,lampe_flux,support_hauteur",where:`within_distance(geo_point_2d,${n},${Math.round(e)}m)`,order_by:`distance(geo_point_2d,${n})`,limit:String(s),offset:String(o)});return`${L.ENDPOINT}?${a}`}static lampsFrom(t,e){const s=Math.cos(e.lat*Math.PI/180),o=a=>{const r=typeof a=="number"?a:Number.parseFloat(a??"");return Number.isFinite(r)&&r>0?r:void 0},n=[];for(const a of t){const r=a.geo_point_2d;if(!r||a.lib_ouvrag==="Projecteur")continue;const i=Math.round((r.lon-e.lng)*L.METRES_PER_DEGREE*s*10)/10,h=Math.round((r.lat-e.lat)*L.METRES_PER_DEGREE*10)/10,c=o(a.lampe_flux),l=n.find(d=>Math.hypot(d.eastM-i,d.northM-h)<L.SAME_COLUMN_M);if(l){c!==void 0&&(l.lumens=(l.lumens??0)+c);continue}const f=o(a.lampe_temperature_couleur),M=o(a.support_hauteur);n.push({eastM:i,northM:h,...M!==void 0&&M>=L.MIN_HEIGHT_M?{heightM:M}:{},...f!==void 0?{colorTemperatureK:f}:{},...c!==void 0?{lumens:c}:{},...a.lib_ouvrag==="Console"?{mount:"wall"}:{}})}return n}}class T{constructor(t,e){this.roads=t,this.fetchImpl=e??fetch.bind(globalThis)}credit={name:"Ville de Paris, Signalisation lumineuse tricolore",url:"https://opendata.paris.fr/explore/dataset/signalisation-tricolore/",licence:"ODbL",of:"signals"};static BOUNDS={south:48.8156,north:48.9022,west:2.2241,east:2.4698};static ENDPOINT="https://opendata.paris.fr/api/explore/v2.1/catalog/datasets/signalisation-tricolore/records";static PAGE=100;static MAX_PAGES=5;static MAX=160;static METRES_PER_DEGREE=111320;static SAME_POST_M=.8;static SEARCH_M=15;static PEDESTRIAN_ALONG_M=.4;fetchImpl;covers(t,e){const s=T.BOUNDS;return t>=s.south&&t<=s.north&&e>=s.west&&e<=s.east}async signalsNear(t,e){const s=(e+T.SEARCH_M)/T.METRES_PER_DEGREE,o=s/Math.cos(t.lat*Math.PI/180),[n,a]=await Promise.all([this.lenses(t,e),this.roads.getRoads({south:t.lat-s,north:t.lat+s,west:t.lng-o,east:t.lng+o})]);return T.signalsFrom(n,a,t)}async lenses(t,e){const s=[];for(let o=0;o<T.MAX_PAGES;o++){const n=await this.fetchImpl(T.query(t,e,T.PAGE,o*T.PAGE));if(!n.ok)throw new Error(`opendata.paris.fr refused (${n.status})`);const a=(await n.json()).results??[];if(s.push(...a),a.length<T.PAGE)break}return s}static query(t,e,s,o){const n=`geom'POINT(${t.lng.toFixed(6)} ${t.lat.toFixed(6)})'`,a=new URLSearchParams({select:"geo_point_2d,lib_regime",where:`within_distance(geo_point_2d,${n},${Math.round(e)}m)`,order_by:`distance(geo_point_2d,${n})`,limit:String(s),offset:String(o)});return`${T.ENDPOINT}?${a}`}static signalsFrom(t,e,s){const o=Math.cos(s.lat*Math.PI/180),n=(h,c)=>[(c-s.lng)*T.METRES_PER_DEGREE*o,(h-s.lat)*T.METRES_PER_DEGREE],a=[];for(const h of t){if(!h.geo_point_2d)continue;const c=n(h.geo_point_2d.lat,h.geo_point_2d.lon),l=(h.lib_regime??"").toUpperCase(),f=/ROUGE|JAUNE|VERT/.test(l),M=/PASSEZ|ATTENDEZ/.test(l);if(!f&&!M)continue;let d=a.find(g=>Math.hypot(g.at[0]-c[0],g.at[1]-c[1])<T.SAME_POST_M);d||a.push(d={at:c,vehicles:0,pedestrians:0}),f&&d.vehicles++,M&&d.pedestrians++}const r=e.map(h=>({way:h,points:h.points.map(c=>n(c.lat,c.lng))})),i=[];for(const h of a){const c=T.nearestRoad(h.at,r);if(!c)continue;const[l,f]=c.unit,M=T.heading(c.unit),d=(h.at[0]-c.foot[0])*f-(h.at[1]-c.foot[1])*l>=0,g=c.way.direction,m=g==="forward"?M:g==="backward"?(M+180)%360:d?M:(M+180)%360,E=w=>Math.round(w*10)/10,v=w=>E((w%360+360)%360);if(h.vehicles>0&&i.push({eastM:E(h.at[0]),northM:E(h.at[1]),headingDeg:v(m+180),for:"vehicles",phase:j.phaseOf(m)}),h.pedestrians>0){const w=T.heading([c.foot[0]-h.at[0],c.foot[1]-h.at[1]]),p=h.vehicles>0?T.PEDESTRIAN_ALONG_M:0;i.push({eastM:E(h.at[0]+l*p),northM:E(h.at[1]+f*p),headingDeg:v(Number.isNaN(w)?M+90:w),for:"pedestrians",phase:j.phaseOf(M)})}}return i.sort((h,c)=>Math.hypot(h.eastM,h.northM)-Math.hypot(c.eastM,c.northM)).slice(0,T.MAX)}static nearestRoad(t,e){let s;for(const{way:o,points:n}of e)for(let a=1;a<n.length;a++){const[r,i]=n[a-1],[h,c]=n[a],l=Math.hypot(h-r,c-i);if(l===0)continue;const f=[(h-r)/l,(c-i)/l],M=Math.max(0,Math.min(l,(t[0]-r)*f[0]+(t[1]-i)*f[1])),d=[r+f[0]*M,i+f[1]*M],g=Math.hypot(t[0]-d[0],t[1]-d[1]);g<=T.SEARCH_M&&(!s||g<s.distance)&&(s={way:o,unit:f,foot:d,distance:g})}return s}static heading([t,e]){return t===0&&e===0?Number.NaN:Math.round((Math.atan2(t,e)*180/Math.PI+360)%360*10)/10}}const K=B.point("surroundings").provide(B.BUILT_IN,[{id:"ign-lidar-topo",name:"IGN LiDAR HD + BD TOPO",credit:"© IGN, LiDAR HD and BD TOPO, Licence Ouverte 2.0; street lamps © OpenStreetMap contributors",creditUrl:"https://geoservices.ign.fr/lidarhd",create:()=>new I(new F({},new u({},U.TOWN_LAMPS,U.TOWN_SIGNALS)))},{id:"ign-lidar-hd",name:"IGN LiDAR HD",credit:"© IGN, LiDAR HD, Licence Ouverte 2.0; street lamps © OpenStreetMap contributors",creditUrl:"https://geoservices.ign.fr/lidarhd",create:()=>new I(new nt({},new u({},U.TOWN_LAMPS,U.TOWN_SIGNALS)))},{id:"ign-bd-topo",name:"IGN BD TOPO",credit:"© IGN, BD TOPO, Licence Ouverte 2.0; street lamps © OpenStreetMap contributors",creditUrl:"https://geoservices.ign.fr/bdtopo",create:()=>new I(new at({},new u({},U.TOWN_LAMPS,U.TOWN_SIGNALS)))},{id:"osm-buildings",name:"OpenStreetMap buildings",credit:"Buildings and street lamps © OpenStreetMap contributors (ODbL)",creditUrl:"https://www.openstreetmap.org/copyright",create:()=>new I(new W({},new u({},U.TOWN_LAMPS,U.TOWN_SIGNALS)))}]);class U{static DEFAULT_ID=K[0].id;static WORLD_ID="osm-buildings";static TOWN_LAMPS=[new L];static TOWN_SIGNALS=[new T(new et)];static NONE="none";static byId(t){return t===U.NONE?void 0:K.find(e=>e.id===t)??K[0]}static providerFor(t,e,s){const o=U.byId(t)?.create();if(t!==void 0&&t!==U.DEFAULT_ID)return o?.covers(e,s)?o:void 0;const n=K.find(r=>r.id===U.WORLD_ID).create(),a=[o,n].filter(r=>r!==void 0&&r.covers(e,s));return a.length>1?new st(a):a[0]}}export{K as SURROUNDINGS_SOURCES,U as SurroundingsSources};
|
|
1
|
+
import{g as B}from"./rr0-ufoathome.mjs";import{y as V,bs as tt,bt as q,z as j,bu as C,bv as X,bw as et}from"./ShareDialogElement-DMDY7Hlo.js";import{l as ot}from"./GeoProjection-DvqDbRIx.js";import"./Sighting-C1yj2-s5.js";import"./VisualAids-DI-hEL46.js";import"./three.module-CbaHqYFq.js";import"./SaidPosition-OJEYhVKN.js";import"./Decor-Dn-cvniW.js";import"./RecordingIssue-BlWT8Xsu.js";import"./xyzImageryRaster-Dhxs0B26.js";import"./Obstacles-v9SkfBD7.js";class I{constructor(t){this.survey=t}static CACHE_NAME="rr0-surroundings";static MAX_AGE_MS=720*3600*1e3;static FORMAT=8;static MAX_STORED=400;static asked=new Map;get id(){return this.survey.id}get name(){return this.survey.name}get attribution(){return this.survey.attribution}get creditUrl(){return this.survey.creditUrl}get contemporary(){return this.survey.contemporary}covers(t,e){return this.survey.covers(t,e)}async getSurroundings(t,e){const s=I.key(this.survey.id,t,e);let o=I.asked.get(s);return o===void 0&&(o=this.recalled(s,t,e),I.asked.set(s,o),o.catch(()=>I.asked.delete(s))),structuredClone(await o)}later(t,e){const s=this.survey.later?.(t,e);if(!s)return;const o=I.key(this.survey.id,t,e);return s.then(n=>{const a=I.partial.get(o);if(a){I.partial.delete(o);const{incomplete:r,...i}=a,h=[...a.credits??[],...n.credits??[]].filter((l,f,M)=>M.findIndex(d=>d.url===l.url)===f),c={...i,...n,dates:{...a.dates,...n.dates},...h.length>0?{credits:h}:{}};I.asked.set(o,Promise.resolve(c)),I.openCache().then(l=>l&&I.store(l,I.request(o),c))}return structuredClone(n)})}static partial=new Map;static forget(){I.partial.clear(),I.asked.clear()}static key(t,e,s){return`${t}/v${I.FORMAT}/${e.lat.toFixed(5)}/${e.lng.toFixed(5)}/${Math.round(s)}`}async recalled(t,e,s){const o=await I.openCache(),n=I.request(t);if(o)try{const r=await o.match(n);if(r){const{savedAt:i,surroundings:h}=await r.json();if(Date.now()-i<I.MAX_AGE_MS)return h;await o.delete(n)}}catch{}const a=await this.survey.getSurroundings(e,s);return a.incomplete?(I.asked.delete(t),I.partial.set(t,structuredClone(a)),a):(o&&I.store(o,n,a),a)}static async store(t,e,s){try{const o={savedAt:Date.now(),surroundings:s};await t.put(e,new Response(JSON.stringify(o),{headers:{"Content-Type":"application/json"}}));const n=await t.keys();for(const a of n.slice(0,Math.max(0,n.length-I.MAX_STORED)))await t.delete(a)}catch{}}static async openCache(){try{return typeof caches>"u"?void 0:await caches.open(I.CACHE_NAME)}catch{return}}static request(t){const e=typeof location>"u"?"http://localhost":location.origin;return new Request(`${e}/__surroundings__/${encodeURIComponent(t)}`)}}class st{constructor(t){if(this.candidates=t,t.length===0)throw new Error("A survey needs at least one candidate");this.current=t[0]}current;get id(){return this.current.id}get name(){return this.current.name}get attribution(){return this.current.attribution}get creditUrl(){return this.current.creditUrl}get contemporary(){return this.current.contemporary}covers(t,e){return this.candidates.some(s=>s.covers(t,e))}async getSurroundings(t,e){let s;for(const o of this.candidates)if(o.covers(t.lat,t.lng))try{const n=await o.getSurroundings(t,e);return this.current=o,n}catch(n){if(s??=n,!(n instanceof V))throw n}throw s??new V("no-coverage","No survey reaches this place")}later(t,e){return this.current.later?.(t,e)}}class D{constructor(t,e,s,o){this.heights=t,this.building=e,this.width=s,this.height=o}static ROOF_PERCENTILE=.9;static STEP_M=.9;static RECTANGLE_FILL=.72;static MIN_DEPTH_M=2.5;static MAX_PARTS=24;static MAX_CELLS=640;buildings(t){const e=t.metresPerPixel,s=t.minAreaM2??12,o=new Uint8Array(this.width*this.height),n=[];for(let a=0;a<this.building.length;a++){if(!this.building[a]||o[a])continue;const r=this.patchFrom(a,o);if(!(r.length*e*e<s))for(const i of this.buildingsOf(r,e,s))Math.hypot(i.eastM,i.northM)<=t.radiusM&&n.push(i)}return n.sort((a,r)=>Math.hypot(a.eastM,a.northM)-Math.hypot(r.eastM,r.northM)),n.slice(0,t.maxBuildings??60)}patchFrom(t,e){const s=[],o=[t];for(e[t]=1;o.length>0;){const n=o.pop();s.push(n);const a=n%this.width,r=Math.floor(n/this.width);for(const[i,h]of[[1,0],[-1,0],[0,1],[0,-1]]){const c=a+i,l=r+h;if(c<0||l<0||c>=this.width||l>=this.height)continue;const f=l*this.width+c;this.building[f]&&!e[f]&&Math.abs(this.heights[f]-this.heights[n])<=D.STEP_M&&(e[f]=1,o.push(f))}}return s}buildingsOf(t,e,s){const o=this.width/2,n=this.height/2,a=[],r=[],i=[];for(const h of t){const c=h%this.width,l=Math.floor(h/this.width);a.push((c+.5-o)*e),r.push((n-l-.5)*e),i.push(this.heights[h])}return D.ofPoints(a,r,i,e,s)}static ofPoints(t,e,s,o,n,a=D.RECTANGLE_FILL,r=[]){const i=[];for(let m=0;m<t.length;m++)for(const[E,v]of[[-.5,-.5],[.5,-.5],[-.5,.5],[.5,.5]])i.push([t[m]+E*o,e[m]+v*o]);const h=D.hull(i),{angle:c,rectangle:l}=D.smallestRectangle(h),f=t.length*o*o,M=(l.maxU-l.minU)*(l.maxV-l.minV);if(f/M>=a||f<4*n)return[D.building(l,c,D.roof(s))];const d=h.map((m,E)=>({from:{east:m[0],north:m[1]},to:{east:h[(E+1)%h.length][0],north:h[(E+1)%h.length][1]}})),g=D.dominantAngles([...r,...d]);return D.parts(t,e,s,g.length>0?g:[c],o,n)}static dominantAngles(t,e=3){const s=new Map;for(const o of t){const n=Math.hypot(o.to.east-o.from.east,o.to.north-o.from.north);if(n<1e-6)continue;const a=(Math.atan2(o.to.north-o.from.north,o.to.east-o.from.east)%(Math.PI/2)+Math.PI/2)%(Math.PI/2),r=Math.round(a/(Math.PI/60));s.set(r,(s.get(r)??0)+n)}return[...s.entries()].sort((o,n)=>n[1]-o[1]).slice(0,e).map(([o])=>o*Math.PI/60)}static parts(t,e,s,o,n,a){let r=t.map((h,c)=>c);const i=[];for(let h=0;h<D.MAX_PARTS&&r.length>0;h++){let c;for(const M of o){const d=D.largestIn(t,e,r,M,n);d&&(c===void 0||d.area>c.area)&&(c=d)}if(c===void 0||c.area<a)break;const l=c.covered;Math.min(c.rectangle.maxU-c.rectangle.minU,c.rectangle.maxV-c.rectangle.minV)>=D.MIN_DEPTH_M&&i.push(D.building(c.rectangle,c.angle,D.roof([...l].map(M=>s[M])))),r=r.filter(M=>!l.has(M))}return i}static largestIn(t,e,s,o,n){const a=Math.cos(o),r=Math.sin(o);let i=1/0,h=-1/0,c=1/0,l=-1/0;const f=[],M=[];for(const A of s){const y=t[A]*a+e[A]*r,R=-t[A]*r+e[A]*a;f.push(y),M.push(R),i=Math.min(i,y),h=Math.max(h,y),c=Math.min(c,R),l=Math.max(l,R)}const d=Math.max(n*Math.SQRT2,Math.max(h-i,l-c)/D.MAX_CELLS),g=Math.max(1,Math.ceil((h-i)/d+1e-9)),m=Math.max(1,Math.ceil((l-c)/d+1e-9)),E=new Uint8Array(g*m),v=s.map((A,y)=>{const R=Math.min(g-1,Math.max(0,Math.floor((f[y]-i)/d))),x=Math.min(m-1,Math.max(0,Math.floor((M[y]-c)/d)));return E[x*g+R]=1,x*g+R}),w=D.largestRectangle(E,g,m);if(w===void 0)return;const p=new Set;return s.forEach((A,y)=>{const R=v[y]%g,x=Math.floor(v[y]/g);R>=w.column&&R<w.column+w.columns&&x>=w.row&&x<w.row+w.rows&&p.add(A)}),{area:w.area*d*d,angle:o,covered:p,rectangle:{minU:i+w.column*d,maxU:i+(w.column+w.columns)*d,minV:c+w.row*d,maxV:c+(w.row+w.rows)*d}}}static largestRectangle(t,e,s){const o=new Array(e).fill(0);let n;for(let a=0;a<s;a++){for(let i=0;i<e;i++)o[i]=t[a*e+i]?o[i]+1:0;const r=[];for(let i=0;i<=e;i++){const h=i===e?0:o[i];for(;r.length>0&&o[r[r.length-1]]>=h;){const c=r.pop(),l=r.length===0?i:i-r[r.length-1]-1,f=o[c]*l;(n===void 0||f>n.area)&&(n={column:i-l,row:a-o[c]+1,columns:l,rows:o[c],area:f})}r.push(i)}}return n}static roof(t){const e=[...t].sort((s,o)=>s-o);return Math.max(2,e[Math.min(e.length-1,Math.floor(e.length*D.ROOF_PERCENTILE))])}static building(t,e,s){const o=Math.cos(e),n=Math.sin(e),a=t.maxU-t.minU,r=t.maxV-t.minV,i=(t.minU+t.maxU)/2,h=(t.minV+t.maxV)/2,l=((90-(a<r?e:e+Math.PI/2)*180/Math.PI)%180+180)%180;return{eastM:D.tenth(i*o-h*n),northM:D.tenth(i*n+h*o),widthM:D.tenth(Math.max(a,r)),lengthM:D.tenth(Math.min(a,r)),heightM:D.tenth(s),headingDeg:Math.round(l*10)/10}}static smallestRectangle(t){let e={area:1/0,angle:0,rectangle:{minU:0,maxU:0,minV:0,maxV:0}};for(let s=0;s<Math.max(1,t.length);s++){const[o,n]=t[s]??[0,0],[a,r]=t[(s+1)%t.length]??[1,0],i=Math.atan2(r-n,a-o),h=Math.cos(i),c=Math.sin(i);let l=1/0,f=-1/0,M=1/0,d=-1/0;for(const[m,E]of t){const v=m*h+E*c,w=-m*c+E*h;l=Math.min(l,v),f=Math.max(f,v),M=Math.min(M,w),d=Math.max(d,w)}const g=(f-l)*(d-M);g<e.area&&(e={area:g,angle:i,rectangle:{minU:l,maxU:f,minV:M,maxV:d}})}return e}static hull(t){const e=[...t].sort((r,i)=>r[0]-i[0]||r[1]-i[1]),s=e.filter((r,i)=>i===0||r[0]!==e[i-1][0]||r[1]!==e[i-1][1]);if(s.length<3)return s;const o=(r,i,h)=>(i[0]-r[0])*(h[1]-r[1])-(i[1]-r[1])*(h[0]-r[0]),n=[];for(const r of s){for(;n.length>=2&&o(n[n.length-2],n[n.length-1],r)<=0;)n.pop();n.push(r)}const a=[];for(const r of[...s].reverse()){for(;a.length>=2&&o(a[a.length-2],a[a.length-1],r)<=0;)a.pop();a.push(r)}return[...n.slice(0,-1),...a.slice(0,-1)]}static tenth(t){return Math.round(t*10)/10}}class H{constructor(t,e,s,o){this.heights=t,this.vegetation=e,this.width=s,this.height=o}static SUMMIT_RADIUS_M=2.5;static CROWN_REACH_M=8;static MAX_WIDTH_M=16;static MIN_WIDTH_M=2;static tenth(t){return Math.round(t*10)/10}trees(t){const e=t.metresPerPixel,s=t.minHeightM??4,o=t.eyeM??1.6,n=t.minElevationDeg??2,a=Math.max(1,Math.round(H.SUMMIT_RADIUS_M/e)),r=Math.round(H.CROWN_REACH_M/e),i=this.width/2,h=this.height/2,c=[];for(let l=0;l<this.height;l++)for(let f=0;f<this.width;f++){const M=this.canopy(f,l);if(M<s)continue;const d=(f+.5-i)*e,g=(h-l-.5)*e,m=Math.hypot(d,g);if(m>t.radiusM||!this.isSummit(f,l,M,a))continue;const E=Math.atan2(M-o,Math.max(m,1))*180/Math.PI;E<n||c.push({tree:{eastM:H.tenth(d),northM:H.tenth(g),heightM:H.tenth(M),widthM:H.tenth(this.crownWidth(f,l,M,e,r))},elevation:E})}return c.sort((l,f)=>f.elevation-l.elevation),c.slice(0,t.maxTrees??150).map(l=>l.tree)}canopy(t,e){if(t<0||e<0||t>=this.width||e>=this.height)return 0;const s=e*this.width+t;return this.vegetation[s]?this.heights[s]:0}isSummit(t,e,s,o){for(let n=-o;n<=o;n++)for(let a=-o;a<=o;a++){if(a===0&&n===0)continue;const r=this.canopy(t+a,e+n);if(r>s||r===s&&(n<0||n===0&&a<0))return!1}return!0}crownWidth(t,e,s,o,n){let a=0;for(let i=-n;i<=n;i++)for(let h=-n;h<=n;h++)Math.hypot(h,i)*o<=H.CROWN_REACH_M&&this.canopy(t+h,e+i)>=s*.5&&a++;const r=2*Math.sqrt(a*o*o/Math.PI);return Math.max(H.MIN_WIDTH_M,Math.min(r,H.MAX_WIDTH_M))}}class _{static WALLS={1:"stone",2:"meuliere",3:"concrete",4:"brick",5:"block",6:"wood",9:"other"};static ROOFS={1:"tile",2:"slate",3:"zinc",4:"concrete",9:"other"};static WALL_COLOURS={stone:"#b9ae9b",meuliere:"#b8a78a",concrete:"#b4b2ac",brick:"#a65f48",block:"#d0c6b2",wood:"#7d5c3e",other:"#c9c0ae"};static PLASTER="#d3cab8";static ROOF_COLOURS={tile:"#a0583f",slate:"#4a5059",zinc:"#8d969c",concrete:"#8f8e8a",other:"#7a7872"};static VARIATION=.12;static OLD_ROOF="#7d858c";static OLD_STOREY_M=3.6;static GRAND_STOREY_M=4.5;static MIN_STOREY_M=2.4;static MAX_STOREY_M=6;static of(t,e){const s=String(t??"").trim();if(!/^\d{1,2}$/.test(s))return;const o=Number(s),n=o%10!==0?o%10:Math.floor(o/10);return(e==="wall"?_.WALLS:_.ROOFS)[String(n)]}static roofColor(t){return t?_.ROOF_COLOURS[t]:void 0}static fit(t){return t.map(e=>{const s=e.style,o={...e.facade,color:e.facade?.color??_.wallColor(e)};s==="church"?o.openings="lancet":s==="monument"||s==="works"?o.openings="plain":(s==="old"||s==="grand")&&(o.openings="tall"),e.closedAtNight&&o.openings!=="plain"&&(o.closedAtNight=!0);const n=_.storeyOf(e);n!==void 0&&s!=="church"&&s!=="monument"&&(o.storeyM=n);const a=s==="old"&&e.roof?.color===void 0?{shape:"flat",riseM:0,...e.roof,color:_.OLD_ROOF}:e.roof;return{...e,facade:o,...a?{roof:a}:{}}})}static storeyOf(t){const e=t.heightM-(t.roof?.riseM??0);if(t.floors&&t.floors>0){const s=e/t.floors;if(s>=_.MIN_STOREY_M&&s<=_.MAX_STOREY_M)return Math.round(s*100)/100}return t.style==="old"?_.OLD_STOREY_M:t.style==="grand"?_.GRAND_STOREY_M:void 0}static wallColor(t){const e=t.style==="church"||t.style==="monument"||t.style==="old",s=t.wallMaterial?_.WALL_COLOURS[t.wallMaterial]:e?_.WALL_COLOURS.stone:_.PLASTER,o=Math.sin(t.eastM*12.9898+t.northM*78.233)*43758.5453,n=1+(o-Math.floor(o)-.5)*2*_.VARIATION,a=r=>Math.max(0,Math.min(255,Math.round(parseInt(s.slice(r,r+2),16)*n))).toString(16).padStart(2,"0");return`#${a(1)}${a(3)}${a(5)}`}}class N{static MIN_RISE_M=1.2;static MIN_EAVES_M=2.5;static MIN_SEEN=.35;static NO_DATA=-9999;static BANDS=7;static INSET_M=.9;static LIFT=1.18;static PEAK=.3;static LEVEL=.45;static fit(t,e,s){return!e&&!s&&!t.some(o=>o.roofMaterial)?t:t.map(o=>{const n=e?N.shapeOf(o,e):void 0,a=(s?N.colorOf(o,s):void 0)??_.roofColor(o.roofMaterial);if(!n&&!a)return o;const r={shape:n?.shape??"flat",...n?.ridge==="depth"?{ridge:"depth"}:{},riseM:n?.riseM??0,...a?{color:a}:{}},i=n&&n.shape!=="flat"?n.topM:o.heightM;return{...o,heightM:i,roof:r}})}static world(t,e,s){const o=t.headingDeg*Math.PI/180;return{east:t.eastM+e*Math.cos(o)+s*Math.sin(o),north:t.northM-e*Math.sin(o)+s*Math.cos(o)}}static shapeOf(t,e){const s=N.BANDS,o=Math.max(e.metresPerPixel,.5),n=t.widthM/2-N.INSET_M,a=t.lengthM/2-N.INSET_M;if(n<=0||a<=0)return;const r=[],i=Array.from({length:s},()=>({sum:0,n:0})),h=Array.from({length:s},()=>({sum:0,n:0}));let c=0;for(let y=-n;y<=n;y+=o)for(let R=-a;R<=a;R+=o){c++;const{east:x,north:$}=N.world(t,y,R),z=Math.floor(x/e.metresPerPixel+e.size/2),Y=Math.floor(e.size/2-$/e.metresPerPixel);if(z<0||Y<0||z>=e.size||Y>=e.size)continue;const k=Y*e.size+z,P=e.heights[k];if(e.vegetation[k]||P===N.NO_DATA||!(P>0))continue;r.push(P);const J=i[Math.min(s-1,Math.floor((y+n)/(2*n)*s))],Q=h[Math.min(s-1,Math.floor((R+a)/(2*a)*s))];J.sum+=P,J.n++,Q.sum+=P,Q.n++}if(c===0||r.length/c<N.MIN_SEEN)return;r.sort((y,R)=>y-R);const l=N.percentile(r,.08),f=N.percentile(r,.92),M=f-l;if(l<N.MIN_EAVES_M||M>Math.min(t.widthM,t.lengthM))return;if(M<N.MIN_RISE_M)return{shape:"flat",riseM:0,topM:f};const d=N.profile(i),g=N.profile(h);if(!d||!g)return;const m=N.peak(g)/M,E=N.peak(d)/M,v=N.spread(d)/M,w=N.spread(g)/M,p=m>=N.PEAK&&v<=N.LEVEL,A=E>=N.PEAK&&w<=N.LEVEL;if(p&&(!A||m>=E))return{shape:"gable",ridge:"width",riseM:M,topM:f};if(A)return{shape:"gable",ridge:"depth",riseM:M,topM:f};if(m>=N.PEAK&&E>=N.PEAK/2)return{shape:"hip",ridge:"width",riseM:M,topM:f}}static profile(t){const e=t.map(s=>s.n>0?s.sum/s.n:NaN);return e.filter(Number.isFinite).length>=t.length-1?e.map((s,o)=>Number.isFinite(s)?s:N.neighbour(e,o)):void 0}static neighbour(t,e){return Number.isFinite(t[e-1])?t[e-1]:t[e+1]}static peak(t){const e=Math.max(1,Math.floor(t.length/3)),s=n=>n.reduce((a,r)=>a+r,0)/n.length,o=[...t.slice(0,e),...t.slice(t.length-e)];return s(t.slice(e,t.length-e))-s(o)}static spread(t){return Math.max(...t)-Math.min(...t)}static percentile(t,e){return t[Math.min(t.length-1,Math.floor(t.length*e))]}static colorOf(t,e){const s=Math.max(e.metresPerPixel,.5),o=Math.max(t.widthM/2-N.INSET_M,s),n=Math.max(t.lengthM/2-N.INSET_M,s),a=[],r=[],i=[];for(let l=-o;l<=o;l+=s)for(let f=-n;f<=n;f+=s){const{east:M,north:d}=N.world(t,l,f),g=Math.floor(M/e.metresPerPixel+e.size/2),m=Math.floor(e.size/2-d/e.metresPerPixel);if(g<0||m<0||g>=e.size||m>=e.size)continue;const E=(m*e.size+g)*e.samples,v=e.values[E],w=e.values[E+1],p=e.values[E+2];w>v&&w>p||(a.push(v),r.push(w),i.push(p))}if(a.length===0)return;const h=l=>l.sort((f,M)=>f-M)[Math.floor(l.length/2)],c=l=>Math.min(255,Math.round(l*N.LIFT)).toString(16).padStart(2,"0");return`#${c(h(a))}${c(h(r))}${c(h(i))}`}}class G{static DEFAULT_HEIGHT_M=6;static METRES_PER_DEGREE=111320;static STREET_SPACING_M=35;static KERB_OFFSET_M=1;static DEFAULT_WIDTH_M=5.5;static PATIENCE_MS=15e3;static MAX=150;static lampsFrom(t,e,s){const o=[],n=new Set;for(const r of t.elements??[]){if(r.id!==void 0){const l=`${r.type}/${r.id}`;if(n.has(l))continue;n.add(l)}if(r.type==="way"){r.tags?.lit==="yes"&&G.alongStreet(r,e,o);continue}if(r.tags?.highway!=="street_lamp"||typeof r.lat!="number"||typeof r.lon!="number")continue;const i=(r.lon-e.lng)*G.METRES_PER_DEGREE*Math.cos(e.lat*Math.PI/180),h=(r.lat-e.lat)*G.METRES_PER_DEGREE;if(Math.hypot(i,h)>s)continue;const c=Number.parseFloat(r.tags?.height??"");o.push({eastM:Math.round(i*10)/10,northM:Math.round(h*10)/10,...Number.isFinite(c)&&c>=2&&c<=20?{heightM:c}:{}})}const a=o.filter(r=>Math.hypot(r.eastM,r.northM)<=s);return o.length=0,o.push(...a),o.sort((r,i)=>Math.hypot(r.eastM,r.northM)-Math.hypot(i.eastM,i.northM)),o.slice(0,G.MAX)}static alongStreet(t,e,s){const o=t.geometry;if(!o||o.length<2)return;const n=d=>[(d.lon-e.lng)*G.METRES_PER_DEGREE*Math.cos(e.lat*Math.PI/180),(d.lat-e.lat)*G.METRES_PER_DEGREE],a=o.map(n),r=Number.parseFloat(t.tags?.width??""),i=Number.parseInt(t.tags?.lanes??"",10),c=(Number.isFinite(r)&&r>0?r:Number.isFinite(i)&&i>0?i*3.5:G.DEFAULT_WIDTH_M)/2+G.KERB_OFFSET_M;let l=1,f=G.STREET_SPACING_M/2,M=0;for(let d=1;d<a.length;d++){const[g,m]=a[d-1],[E,v]=a[d],w=Math.hypot(E-g,v-m);if(w===0)continue;const p=(E-g)/w,A=(v-m)/w;for(;f<=M+w;f+=G.STREET_SPACING_M){const y=f-M;s.push({eastM:Math.round((g+p*y+A*c*l)*10)/10,northM:Math.round((m+A*y-p*c*l)*10)/10,supposed:!0}),l=-l}M+=w}}}class u{constructor(t={},e=[],s=[]){this.lampSources=e,this.signalSources=s,this.client=new tt(t)}static METRES_PER_DEGREE=111320;static KERB_OFFSET_M=.6;static SETBACK_M=.5;static MIN_CROSSING_M=3;static MAX_CROSSING_M=30;static SAME_CROSSING_M=5;static SAME_HEAD_M=2.5;static SAME_HEAD_DEG=45;static MAX_SIGNALS=160;static MAX_CROSSINGS=150;static MAX_SIGNS=100;static ROADS=new Set([...q.DRIVABLE,"living_street","busway","road"]);static ON_ROAD="^(traffic_signals|crossing|stop|give_way)$";static CREDIT={name:"OpenStreetMap",url:"https://www.openstreetmap.org/copyright",licence:"ODbL"};client;local(t,e){const s=u.boxOf(t,e),o=(r,i)=>{if(!r)return Promise.resolve(void 0);const h=`${r.credit.url} ${s}`;let c=u.localPending.get(h);return c||(c=i().then(l=>({credit:r.credit,found:l}),()=>{u.localPending.delete(h)}),u.localPending.set(h,c)),c},n=this.lampSources.find(r=>r.covers(t.lat,t.lng)),a=this.signalSources.find(r=>r.covers(t.lat,t.lng));return Promise.all([o(n,()=>n.lampsNear(t,e)),o(a,()=>a.signalsNear(t,e))]).then(([r,i])=>({lamps:r,signals:i}))}static localPending=new Map;static withLocal(t,e){const s=e?.lamps?e.lamps.found:t.lamps,o=e?.signals?e.signals.found:t.signals,a=[...u.found({crossings:t.crossings,signs:t.signs,...e?.lamps?{}:{lamps:s},...e?.signals?{}:{signals:o}})?[u.CREDIT]:[],...e?.lamps&&e.lamps.found.length>0?[e.lamps.credit]:[],...e?.signals&&e.signals.found.length>0?[e.signals.credit]:[]],{lamps:r,signals:i,credits:h,...c}=t;return{...c,...s?.length?{lamps:s}:{},...o?.length?{signals:o}:{},...a.length>0?{credits:a}:{}}}static today(){return new Date().toISOString().slice(0,10)}static later(t,e,s){return t?.answered(e,s).then(o=>({...o,...u.found(o)?{dates:{lamps:u.today()}}:{}}))}static found(t){return!!(t?.lamps?.length||t?.signals?.length||t?.crossings?.length||t?.signs?.length)}static query(t){const e=u.ON_ROAD;return`[out:json][timeout:25];(node["highway"="street_lamp"](${t});way["highway"]["lit"="yes"](${t});node["highway"~"${e}"](${t});node["traffic_sign"](${t});way["footway"="crossing"](${t}););out geom;(node._["highway"~"${e}"];node._["traffic_sign"];)->.kerb;way(bn.kerb)["highway"];out geom;`}static pending=new Map;async near(t,e){const s=this.ask(u.boxOf(t,e)),o=this.local(t,e);let n;const a=Symbol("late"),r=new Promise(i=>{n=setTimeout(()=>i(a),G.PATIENCE_MS)});try{const[i,h]=await Promise.all([Promise.race([s,r]),Promise.race([o,r])]),c=h===a?void 0:h;return i===a||i===void 0?{...u.withLocal({},c),incomplete:!0}:u.withLocal(u.from(i,t,e),c)}finally{clearTimeout(n)}}static RETRY_DELAYS_MS=[15e3,6e4,18e4,6e5];async answered(t,e){const s=u.boxOf(t,e);for(let o=0;;o++){const n=await this.ask(s);if(n)return u.withLocal(u.from(n,t,e),await this.local(t,e));if(o>=u.RETRY_DELAYS_MS.length)throw new Error("Overpass did not answer");await new Promise(a=>setTimeout(a,u.RETRY_DELAYS_MS[o]))}}ask(t){let e=u.pending.get(t);return e||(e=this.client.query(u.query(t)).catch(()=>{u.pending.delete(t)}),u.pending.set(t,e)),e}static boxOf(t,e){const s=e/u.METRES_PER_DEGREE,o=e/(u.METRES_PER_DEGREE*Math.cos(t.lat*Math.PI/180));return[t.lat-s,t.lng-o,t.lat+s,t.lng+o].map(n=>n.toFixed(6)).join(",")}static forget(){u.pending.clear(),u.localPending.clear()}static from(t,e,s){const o=G.lampsFrom(t,e,s),n=Math.cos(e.lat*Math.PI/180),a=(p,A)=>[(A-e.lng)*u.METRES_PER_DEGREE*n,(p-e.lat)*u.METRES_PER_DEGREE],r=(p,A)=>`${p.toFixed(7)},${A.toFixed(7)}`,i=new Map,h=new Set,c=[],l=[];for(const p of t.elements??[]){if(p.type==="node"){typeof p.lat=="number"&&typeof p.lon=="number"&&l.push(p);continue}if(p.type!=="way"||!p.geometry||p.geometry.length<2)continue;if(p.id!==void 0){if(h.has(p.id))continue;h.add(p.id)}const A=p.tags??{};if(A.footway==="crossing"&&c.push(p),!u.ROADS.has(A.highway??""))continue;const y=p.geometry.map(R=>a(R.lat,R.lon));p.geometry.forEach((R,x)=>{const $=r(R.lat,R.lon);i.set($,[...i.get($)??[],{way:p,points:y,index:x}])})}const f=[],M=[],d=[],g=new Set;for(const p of l){if(p.id!==void 0){if(g.has(p.id))continue;g.add(p.id)}const A=p.tags??{},y=a(p.lat,p.lon),R=i.get(r(p.lat,p.lon))??[],x=A.highway;if(x==="traffic_signals")for(const k of u.approaches(R,u.directionOf(A),!1))f.push(u.head(y,k,"vehicles"));if(x==="crossing"||x==="traffic_signals"&&A.crossing!==void 0){const k=R[0];if(k&&u.marked(A)){const P=u.directionAt(k);P&&M.push({eastM:u.round(y[0]),northM:u.round(y[1]),headingDeg:u.heading(P),widthM:q.widthOf(k.way.tags??{})}),P&&(A.crossing==="traffic_signals"||A["crossing:signals"]==="yes")&&f.push(...u.pedestrianHeads(y,P,k))}}if(x==="traffic_signals")continue;const $=x==="stop"?{face:"stop"}:x==="give_way"?{face:"give-way"}:u.faceOf(A);if(!$)continue;const z=A.traffic_sign?{code:A.traffic_sign}:{};if(R.length>0){const k=u.approaches(R,u.directionOf(A),!0)[0];if(k){const P=u.head(y,k,"vehicles");d.push({eastM:P.eastM,northM:P.northM,headingDeg:P.headingDeg,...$,...z})}continue}const Y=u.compassOf(A.direction);Y!==void 0&&d.push({eastM:u.round(y[0]),northM:u.round(y[1]),headingDeg:(Y+180)%360,...$,...z})}for(const p of c){const A=u.crossingAlong(p,a);A&&!M.some(y=>Math.hypot(y.eastM-A.eastM,y.northM-A.northM)<u.SAME_CROSSING_M)&&M.push(A)}const m=f.filter((p,A)=>!f.slice(0,A).some(y=>y.for===p.for&&Math.hypot(y.eastM-p.eastM,y.northM-p.northM)<u.SAME_HEAD_M&&Math.abs((y.headingDeg-p.headingDeg+540)%360-180)<u.SAME_HEAD_DEG)),E=(p,A)=>p.filter(y=>Math.hypot(y.eastM,y.northM)<=s).sort((y,R)=>Math.hypot(y.eastM,y.northM)-Math.hypot(R.eastM,R.northM)).slice(0,A),v={};o.length>0&&(v.lamps=o);const w={signals:E(m,u.MAX_SIGNALS),crossings:E(M,u.MAX_CROSSINGS),signs:E(d,u.MAX_SIGNS)};return w.signals.length>0&&(v.signals=w.signals),w.crossings.length>0&&(v.crossings=w.crossings),w.signs.length>0&&(v.signs=w.signs),v}static approaches(t,e,s){const o=[];for(const a of t){const r=a.way.tags??{},i=r.oneway==="yes"||r.oneway==="true"||r.oneway==="1"||r.junction==="roundabout"||r.highway==="motorway",h=r.oneway==="-1",{points:c,index:l}=a,f=(d,g)=>{let m=0;for(let E=Math.min(d,g);E<Math.max(d,g);E++)m+=Math.hypot(c[E+1][0]-c[E][0],c[E+1][1]-c[E][1]);return m},M=d=>{const g=c[l][0]-c[d][0],m=c[l][1]-c[d][1],E=Math.hypot(g,m);return E>0?[g/E,m/E]:void 0};if(l>0&&!h){const d=M(l-1);d&&o.push({approach:{unit:d,road:a},toEndM:f(l,c.length-1),forward:!0})}if(l<c.length-1&&!i){const d=M(l+1);d&&o.push({approach:{unit:d,road:a},toEndM:f(0,l),forward:!1})}}const n=e!==void 0&&t.length===1?o.filter(a=>a.forward===(e==="forward")):o;return!s||n.length<=1?n.map(a=>a.approach):[n.reduce((a,r)=>r.toEndM<a.toEndM?r:a).approach]}static head(t,e,s){const[o,n]=e.unit,a=q.widthOf(e.road.way.tags??{})/2+u.KERB_OFFSET_M,r=u.SETBACK_M,i=u.heading(e.unit);return{eastM:u.round(t[0]-o*r+n*a),northM:u.round(t[1]-n*r-o*a),headingDeg:(i+180)%360,for:s,phase:j.phaseOf(i)}}static pedestrianHeads(t,e,s){const o=q.widthOf(s.way.tags??{})/2+u.KERB_OFFSET_M,n=u.heading(e),a=j.phaseOf(n);return[1,-1].map(r=>({eastM:u.round(t[0]+e[1]*o*r),northM:u.round(t[1]-e[0]*o*r),headingDeg:(n+(r===1?270:90))%360,for:"pedestrians",phase:a}))}static crossingAlong(t,e){if(!u.marked(t.tags??{}))return;const s=t.geometry.map(h=>e(h.lat,h.lon)),[o,n]=s[0],[a,r]=s[s.length-1],i=Math.hypot(a-o,r-n);if(!(i<u.MIN_CROSSING_M))return{eastM:u.round((o+a)/2),northM:u.round((n+r)/2),headingDeg:(u.heading([(a-o)/i,(r-n)/i])+90)%360,widthM:Math.round(Math.min(i,u.MAX_CROSSING_M)*10)/10}}static marked(t){const e=t.crossing;return e!=="unmarked"&&e!=="no"&&e!=="informal"&&t["crossing:markings"]!=="no"}static directionAt(t){const{points:e,index:s}=t,[o,n]=s<e.length-1?[e[s],e[s+1]]:[e[s-1],e[s]],a=Math.hypot(n[0]-o[0],n[1]-o[1]);return a>0?[(n[0]-o[0])/a,(n[1]-o[1])/a]:void 0}static directionOf(t){const e=t["traffic_signals:direction"]??t["traffic_sign:direction"]??t.direction;return e==="forward"||e==="backward"?e:void 0}static compassOf(t){if(t===void 0)return;const e=Number.parseFloat(t);if(Number.isFinite(e)&&/^\s*-?\d/.test(t))return(e%360+360)%360;const o=["N","NNE","NE","ENE","E","ESE","SE","SSE","S","SSW","SW","WSW","W","WNW","NW","NNW"].indexOf(t.trim().toUpperCase());return o<0?void 0:o*22.5}static faceOf(t){const e=t.traffic_sign;if(!e||e==="no"||e==="none")return;const s=e.split(/[;,]/).map(o=>o.trim());if(s.some(o=>/stop|:AB4\b|:206\b|:R1-1\b|:B2\b/i.test(o)))return{face:"stop"};if(s.some(o=>/give_way|yield|:AB3a\b|:205\b|:R1-2\b|:B1\b/i.test(o)))return{face:"give-way"};for(const o of s){const n=/maxspeed|:B14\b|:274\b|:C14\b|:R2-1\b/i.test(o)?Number.parseInt(/\[(\d+)\]/.exec(o)?.[1]??t.maxspeed??"",10):Number.NaN;if(Number.isFinite(n)&&n>0)return{face:"speed-limit",value:n}}return{face:"other"}}static heading([t,e]){return Math.round((Math.atan2(t,e)*180/Math.PI+360)%360*10)/10}static round(t){return Math.round(t*10)/10}}class nt{id="ign-lidar-hd";name="IGN LiDAR HD";attribution="Canopy and roofs © IGN, LiDAR HD (Licence Ouverte 2.0), as surveyed on a day the service does not give";creditUrl="https://geoservices.ign.fr/lidarhd";contemporary=!0;platform;furniture;constructor(t={},e){this.platform=new C(t),this.furniture=e}covers(t,e){return C.covers(t,e)}later(t,e){return u.later(this.furniture,t,e)}async getSurroundings(t,e){if(!this.covers(t.lat,t.lng))throw new V("no-coverage","The LiDAR HD survey covers France only");const s=C.lidarRadius(e),[o,n,a,r,i]=await Promise.all([this.platform.lidar(t,s),this.platform.photo(t,s).catch(()=>{}),this.furniture?.near(t,e),this.platform.laserDate(t),this.platform.photoDate(t)]);return{trees:new H(o.heights,o.vegetation,o.size,o.size).trees({metresPerPixel:o.metresPerPixel,radiusM:s}),buildings:_.fit(N.fit(new D(o.heights,o.building,o.size,o.size).buildings({metresPerPixel:o.metresPerPixel,radiusM:s,maxBuildings:300}),o,n)),bridges:[],lines:[],...a,dates:{...r?{laser:r}:{},...n&&i?{photo:i}:{},...u.found(a)?{lamps:u.today()}:{}}}}}class b{static MAP_NATURES={Eglise:"church",Chapelle:"church",Monument:"monument","Tour, donjon":"monument","Fort, blockhaus, casemate":"monument","Arc de triomphe":"monument","Arène ou théâtre antique":"monument",Château:"old","Industriel, agricole ou commercial":"works",Serre:"works",Silo:"works"};static MAP_WORKS=new Set(["Industriel","Agricole","Annexe"]);static MAP_CLOSED_AT_NIGHT=new Set(["Commercial et services","Sportif"]);static OSM_CLOSED_AT_NIGHT=new Set(["retail","commercial","office","supermarket","kiosk","sports_hall","sports_centre","stadium","school","university","college","kindergarten","public","civic","government","train_station","transportation"]);static OSM_BUILDINGS={cathedral:"church",church:"church",chapel:"church",basilica:"church",temple:"church",mosque:"church",synagogue:"church",shrine:"church",religious:"church",castle:"old",palace:"old",fortress:"monument",bunker:"monument",triumphal_arch:"monument",industrial:"works",warehouse:"works",barn:"works",farm_auxiliary:"works",shed:"works",hangar:"works",garage:"works",garages:"works",greenhouse:"works",silo:"works",storage_tank:"works",cowshed:"works",stable:"works",sty:"works",manufacture:"works"};static OSM_HISTORIC={church:"church",chapel:"church",monastery:"old",castle:"old",manor:"old",fort:"monument",tower:"monument",monument:"monument",memorial:"monument",city_gate:"monument"};static OLD_BEFORE=1900;static GRAND_FROM_M=15;static GRAND_UP_TO_M=40;static TOWER_SLENDERNESS=2;static CHURCH_PITCH=.7;static CHURCH_ROOF_OF_WALLS=.35;static CHURCH_ROOF_COLOUR="#5a6068";static ofMap(t){const e=b.year(t.date_d_apparition),o=b.MAP_NATURES[String(t.nature??"")]??(t.usage_1==="Religieux"?"church":void 0)??(b.MAP_WORKS.has(String(t.usage_1??""))?"works":void 0)??b.ofYear(e)??b.grand(t),n=b.MAP_CLOSED_AT_NIGHT.has(String(t.usage_1??""));return{...o?{style:o}:{},...e!==void 0?{builtYear:e}:{},...n?{closedAtNight:!0}:{}}}static ofOsm(t){const e=b.year(t.start_date),s=t.historic&&t.historic!=="no"?b.OSM_HISTORIC[t.historic]??"old":void 0,o=t.amenity==="place_of_worship"?"church":void 0,n=b.OSM_BUILDINGS[t.building??""]??s??o??b.ofYear(e),a=b.OSM_CLOSED_AT_NIGHT.has(t.building??"")||t.shop!==void 0&&t.shop!=="no";return{...n?{style:n}:{},...e!==void 0?{builtYear:e}:{},...a?{closedAtNight:!0}:{}}}static year(t){const e=Number(/\b(\d{4})\b/.exec(String(t??""))?.[1]);return Number.isFinite(e)&&e>=1e3&&e<=2100?e:void 0}static fit(t){return t.map(e=>e.style==="church"?b.church(e):e)}static isTower(t){return t.heightM>=b.TOWER_SLENDERNESS*Math.max(t.widthM,t.lengthM)}static church(t){const e=t.roof?.color??b.CHURCH_ROOF_COLOUR;if(b.isTower(t))return{...t,roof:{shape:"flat",riseM:0,color:e}};if(t.roof&&t.roof.shape!=="flat")return t;const s=Math.round(Math.min(b.CHURCH_PITCH*t.lengthM,b.CHURCH_ROOF_OF_WALLS*t.heightM)*10)/10,o={shape:"gable",riseM:s,color:e};return{...t,heightM:Math.round((t.heightM+s)*10)/10,roof:o}}static ofYear(t){return t!==void 0&&t<b.OLD_BEFORE?"old":void 0}static grand(t){const e=Number(t.hauteur),s=Number(t.nombre_d_etages);if(!(Number.isFinite(s)&&s>0)&&!(t.usage_1==="Résidentiel"||t.date_d_apparition))return e>=b.GRAND_FROM_M&&e<=b.GRAND_UP_TO_M?"grand":void 0}}class O{static METRES_PER_DEGREE=111320;static NAMED_NATURES={Silo:"Silo"};static DEFAULT_HEIGHT_M=6;static FLOOR_HEIGHT_M=3;static FINE_M=.5;static COARSE_M=1;static MAX_CELLS=4e4;static RECTANGLE_FILL=.9;static buildings(t,e,s,o=12,n=300,a=[]){const r=[];for(const h of O.reached(t,a,e,s)){const c=h.feature,l=Number(c.properties.nombre_d_etages),f=Number(c.properties.hauteur),M=Number.isFinite(f)&&f>0?f:Number.isFinite(l)&&l>0?l*O.FLOOR_HEIGHT_M:O.DEFAULT_HEIGHT_M,{style:d,builtYear:g,closedAtNight:m}=b.ofMap(c.properties);for(const E of O.rectanglesOf(h.rings,M,o)){const v=_.of(c.properties.materiaux_des_murs,"wall"),w=_.of(c.properties.materiaux_de_la_toiture,"roof"),p=O.NAMED_NATURES[String(c.properties.nature??"")];r.push({...E,...p?{name:p}:{},...Number.isFinite(l)&&l>0?{floors:l}:{},...v?{wallMaterial:v}:{},...w?{roofMaterial:w}:{},...d?{style:d}:{},...g!==void 0?{builtYear:g}:{},...m?{closedAtNight:m}:{}})}}const i=h=>Math.hypot(h.eastM,h.northM);if(r.length>n){const h=c=>(c.heightM+6)*Math.sqrt(c.widthM*c.lengthM)/Math.max(i(c),50);r.sort((c,l)=>h(l)-h(c)),r.length=n}return r.sort((h,c)=>i(h)-i(c)),r}static named(t,e,s){const o=e.map(n=>({name:typeof n.properties.toponyme=="string"?n.properties.toponyme:"",rings:O.rings(n,s)})).filter(n=>n.name.length>0&&n.rings.length>0);return o.length===0?t:t.map(n=>{const a=o.find(r=>O.inside(n.eastM,n.northM,r.rings));return a?{...n,name:a.name}:n})}static reached(t,e,s,o){const n=t.map(i=>({feature:i,rings:O.rings(i,s)})).filter(i=>i.rings.length>0),a=n.map(i=>O.reach(i.rings)<=o),r=e.filter(i=>typeof i.properties.toponyme=="string"&&i.properties.toponyme.length>0).map(i=>O.rings(i,s)).filter(i=>i.length>0);if(r.length>0){const i=n.map(c=>{const l=c.rings[0],f=l.reduce((d,g)=>d+g.east,0)/l.length,M=l.reduce((d,g)=>d+g.north,0)/l.length;return r.findIndex(d=>O.inside(f,M,d))}),h=new Set(i.filter((c,l)=>c>=0&&a[l]));i.forEach((c,l)=>{h.has(c)&&(a[l]=!0)})}return n.filter((i,h)=>a[h])}static reach(t){if(O.inside(0,0,t))return 0;let e=1/0;for(const s of t)for(let o=0;o+1<s.length;o++){const n=s[o],a=s[o+1],r=a.east-n.east,i=a.north-n.north,h=r*r+i*i>0?Math.max(0,Math.min(1,-(n.east*r+n.north*i)/(r*r+i*i))):0;e=Math.min(e,Math.hypot(n.east+h*r,n.north+h*i))}return e}static inside(t,e,s){let o=0;for(const n of s)for(let a=0;a+1<n.length;a++){const r=n[a],i=n[a+1];r.north<=e!=i.north<=e&&r.east+(e-r.north)/(i.north-r.north)*(i.east-r.east)>t&&o++}return o%2===1}static rings(t,e){const s=t.geometry,o=s.type==="Polygon"?[s.coordinates]:s.type==="MultiPolygon"?s.coordinates:[],n=Math.cos(e.lat*Math.PI/180),a=[];for(const r of o)for(const i of r)a.push(i.map(([h,c])=>({east:(h-e.lng)*O.METRES_PER_DEGREE*n,north:(c-e.lat)*O.METRES_PER_DEGREE})));return a}static rectanglesOf(t,e,s){let o=1/0,n=-1/0,a=1/0,r=-1/0;for(const f of t)for(const M of f)o=Math.min(o,M.east),n=Math.max(n,M.east),a=Math.min(a,M.north),r=Math.max(r,M.north);let i=O.FINE_M;(n-o)*(r-a)/(i*i)>O.MAX_CELLS&&(i=O.COARSE_M);const h=[],c=[];for(let f=a+i/2;f<r;f+=i){const M=[];for(const d of t)for(let g=0;g+1<d.length;g++){const m=d[g],E=d[g+1];m.north<=f!=E.north<=f&&M.push(m.east+(f-m.north)/(E.north-m.north)*(E.east-m.east))}M.sort((d,g)=>d-g);for(let d=0;d+1<M.length;d+=2)for(let g=Math.ceil((M[d]-i/2)/i)*i+i/2;g<M[d+1];g+=i)h.push(g),c.push(f)}if(h.length*i*i<s)return[];const l=t.flatMap(f=>f.slice(0,-1).map((M,d)=>({from:M,to:f[d+1]})));return D.ofPoints(h,c,new Array(h.length).fill(e),i,s,O.RECTANGLE_FILL,l)}}class F{id="ign-lidar-topo";name="IGN LiDAR HD + BD TOPO";attribution="Canopy © IGN, LiDAR HD; buildings, bridges and lines © IGN, BD TOPO (Licence Ouverte 2.0), as surveyed on days the services do not give";creditUrl="https://geoservices.ign.fr/lidarhd";contemporary=!0;static BRIDGE_MARGIN_M=30;static MAX_BRIDGE_WINDOWS=8;platform;furniture;constructor(t={},e){this.platform=new C(t),this.furniture=e}covers(t,e){return C.covers(t,e)}later(t,e){return u.later(this.furniture,t,e)}async getSurroundings(t,e){if(!this.covers(t.lat,t.lng))throw new V("no-coverage","The IGN's surveys cover France only");const s=C.radius(e),[o,n,a,r,i,h]=await Promise.allSettled([this.platform.lidar(t,s),this.platform.vectors(t,s,!0),this.platform.photo(t,s),this.furniture?.near(t,e)??Promise.resolve(void 0),this.platform.laserDate(t),this.platform.photoDate(t)]),c=C.lidarRadius(s);if(o.status==="rejected"&&n.status==="rejected")throw o.reason;const l=o.status==="fulfilled"?o.value:void 0,f=n.status==="fulfilled"?n.value:void 0,M=f!==void 0&&f.buildings.length===0&&f.bridges.length===0&&f.lines.length===0;if(o.status==="rejected"&&o.reason instanceof V&&o.reason.reason==="no-coverage"&&M)throw o.reason;return{trees:l?new H(l.heights,l.vegetation,l.size,l.size).trees({metresPerPixel:l.metresPerPixel,radiusM:c}):[],buildings:this.roofed(this.buildings(l,f,t,s),l,a.status==="fulfilled"?a.value:void 0),bridges:f?await this.bridges(f,t,s,l?.structures,c):[],lines:f?X.lines(f,t,s,l?.structures):[],...r.status==="fulfilled"?r.value:{},dates:{...o.status==="fulfilled"&&i.status==="fulfilled"&&i.value?{laser:i.value}:{},...a.status==="fulfilled"&&h.status==="fulfilled"&&h.value?{photo:h.value}:{},...f?.mapDate?{map:f.mapDate}:{},...r.status==="fulfilled"&&u.found(r.value)?{lamps:u.today()}:{}}}}async bridges(t,e,s,o,n){const a=X.bridges(t,e,s,o);let r=0;return Promise.all(a.map(async i=>{if(o!==void 0&&Math.hypot(i.eastM,i.northM)+i.lengthM/2<=n)return i;const h=i.lengthM/2+F.BRIDGE_MARGIN_M;if(r++>=F.MAX_BRIDGE_WINDOWS)return i;const c=ot(i.eastM,-i.northM,e.lat,e.lng);try{const l=await this.platform.lidar(c,h),f=X.bridges(t,c,h,l.structures).sort((M,d)=>Math.hypot(M.eastM,M.northM)-Math.hypot(d.eastM,d.northM))[0];return!f||Math.hypot(f.eastM,f.northM)>i.lengthM/2?i:{...f,eastM:X.tenth(f.eastM+i.eastM),northM:X.tenth(f.northM+i.northM)}}catch{return i}}))}roofed(t,e,s){return _.fit(b.fit(N.fit(t,e,s)))}buildings(t,e,s,o){const n=e?O.buildings(e.buildings,s,o,void 0,void 0,e.zones):[],a=n.length>0||t===void 0?n:new D(t.heights,t.building,t.size,t.size).buildings({metresPerPixel:t.metresPerPixel,radiusM:C.lidarRadius(o),maxBuildings:300});return e?O.named(a,e.zones,s):a}}class at{id="ign-bd-topo";name="IGN BD TOPO";attribution="Buildings, bridges and lines © IGN, BD TOPO (Licence Ouverte 2.0), as drawn on a day the service does not give";creditUrl="https://geoservices.ign.fr/bdtopo";contemporary=!0;platform;furniture;constructor(t={},e){this.platform=new C(t),this.furniture=e}covers(t,e){return C.covers(t,e)}later(t,e){return u.later(this.furniture,t,e)}async getSurroundings(t,e){if(!this.covers(t.lat,t.lng))throw new V("no-coverage","BD TOPO covers France only");const s=C.radius(e),[o,n,a,r]=await Promise.all([this.platform.vectors(t,s,!0),this.platform.photo(t,s).catch(()=>{}),this.furniture?.near(t,e),this.platform.photoDate(t)]);return{trees:[],buildings:_.fit(b.fit(N.fit(O.named(O.buildings(o.buildings,t,s,void 0,void 0,o.zones),o.zones,t),void 0,n))),bridges:X.bridges(o,t,s,void 0),lines:X.lines(o,t,s,void 0),...a,dates:{...o.mapDate?{map:o.mapDate}:{},...n&&r?{photo:r}:{},...u.found(a)?{lamps:u.today()}:{}}}}}class S{static ROOF_SHAPES={flat:"flat",gabled:"gable",gambrel:"gable",saltbox:"gable","half-hipped":"hip",hipped:"hip",pyramidal:"hip",mansard:"hip",round:"gable",dome:"dome",onion:"dome"};static WALL_MATERIALS={brick:"brick",stone:"stone",granite:"stone",sandstone:"stone",limestone:"stone",concrete:"concrete",cement_block:"block",block:"block",wood:"wood",timber_framing:"wood"};static ROOF_MATERIALS={roof_tiles:"tile",tiles:"tile",tile:"tile",slate:"slate",metal:"zinc",zinc:"zinc",tin:"zinc",copper:"zinc",concrete:"concrete",eternit:"other"};static COLOURS={white:"#e8e6e0",grey:"#8c8c8a",gray:"#8c8c8a",black:"#3a3a3a",red:"#a8483a",brown:"#6e4f38",beige:"#d6c9a8",yellow:"#d8c070",orange:"#c9773a",green:"#5f7a52",blue:"#506a8a",tan:"#c0a37a",cream:"#e6dcc0",pink:"#c99a96",silver:"#b4b6b6"};static height(t){const e=Number.parseFloat((t??"").replace(",","."));return Number.isFinite(e)&&e>=2&&e<=500?e:void 0}static levels(t){const e=Number.parseInt(t??"",10);return Number.isFinite(e)&&e>=1&&e<=150?e:void 0}static roofShape(t){return S.ROOF_SHAPES[(t??"").trim().toLowerCase()]}static wallMaterial(t){return S.WALL_MATERIALS[(t??"").trim().toLowerCase()]}static roofMaterial(t){return S.ROOF_MATERIALS[(t??"").trim().toLowerCase()]}static colour(t){const e=(t??"").trim().toLowerCase();return/^#[0-9a-f]{6}$/.test(e)?e:/^#[0-9a-f]{3}$/.test(e)?`#${e[1]}${e[1]}${e[2]}${e[2]}${e[3]}${e[3]}`:S.COLOURS[e]}}class W{id="osm-buildings";name="OpenStreetMap buildings";attribution="Buildings © OpenStreetMap contributors (ODbL), as drawn on the day of the data, which a recording is not";creditUrl="https://www.openstreetmap.org/copyright";contemporary=!0;static MAX_RADIUS_M=1500;static MIN_AREA_M2=12;static MAX_BUILDINGS=300;client;furniture;constructor(t={},e){this.client=new tt(t),this.furniture=e}covers(){return!0}later(t,e){return u.later(this.furniture,t,e)}async getSurroundings(t,e){const s=Math.min(e,W.MAX_RADIUS_M);let o;try{o=await this.client.query(`[out:json][timeout:30];(way["building"](around:${s},${t.lat},${t.lng});relation["building"]["type"="multipolygon"](around:${s},${t.lat},${t.lng}););out geom;`)}catch(r){throw new V("unreachable",r instanceof Error?r.message:String(r))}const n=await this.furniture?.near(t,e),a=(o.osm3s?.timestamp_osm_base??"").slice(0,10);return{trees:[],buildings:_.fit(b.fit(W.buildings(o,t,s))),bridges:[],lines:[],...n,dates:{.../^\d{4}-\d{2}-\d{2}$/.test(a)?{map:a}:{},...u.found(n)?{lamps:u.today()}:{}}}}static buildings(t,e,s){const o=[];for(const n of t.elements??[]){const a=W.ringsOf(n);if(a.length===0)continue;const r=n.tags??{},i=S.levels(r["building:levels"]),h=S.height(r.height),c={geometry:{type:"Polygon",coordinates:a},properties:{...h?{hauteur:h}:{},...i?{nombre_d_etages:i}:{}}};for(const l of O.buildings([c],e,s,W.MIN_AREA_M2,50))o.push(W.described(l,r,h!==void 0))}return o.sort((n,a)=>Math.hypot(n.eastM,n.northM)-Math.hypot(a.eastM,a.northM)),o.slice(0,W.MAX_BUILDINGS)}static ringsOf(t){const e=o=>{if(!o||o.length<4)return;const n=o.map(i=>[i.lon,i.lat]),a=n[0],r=n[n.length-1];return a[0]===r[0]&&a[1]===r[1]?n:void 0};if(t.type==="way"){const o=e(t.geometry);return o?[o]:[]}return(t.members??[]).filter(o=>o.role==="outer").map(o=>e(o.geometry)).filter(o=>o!==void 0).slice(0,1)}static described(t,e,s){const o=S.wallMaterial(e["building:material"]),n=S.roofMaterial(e["roof:material"]),a=S.colour(e["building:colour"]),r=S.colour(e["roof:colour"])??_.roofColor(n),i=S.roofShape(e["roof:shape"]),h=a?{color:a}:void 0;let c,l=t.heightM;if(i==="gable"||i==="hip"||i==="dome"){const g=S.height(e["roof:height"]),m=Math.round((g??Math.min(5,Math.max(1.5,.29*Math.min(t.widthM,t.lengthM))))*10)/10;s||(l=Math.round((t.heightM+m)*10)/10),c={shape:i,riseM:m,...e["roof:orientation"]==="across"?{ridge:"depth"}:{},...r?{color:r}:{}}}else(i==="flat"||r)&&(c={shape:"flat",riseM:0,...r?{color:r}:{}});const{style:f,builtYear:M,closedAtNight:d}=b.ofOsm(e);return{...t,heightM:l,...f?{style:f}:{},...M!==void 0?{builtYear:M}:{},...d?{closedAtNight:d}:{},...e.name?{name:e.name}:{},...o?{wallMaterial:o}:{},...n?{roofMaterial:n}:{},...h?{facade:h}:{},...c?{roof:c}:{}}}}class L{credit={name:"Ville de Paris, Éclairage public",url:"https://opendata.paris.fr/explore/dataset/eclairage-public/",licence:"ODbL",of:"lamps"};static BOUNDS={south:48.8156,north:48.9022,west:2.2241,east:2.4698};static ENDPOINT="https://opendata.paris.fr/api/explore/v2.1/catalog/datasets/eclairage-public/records";static PAGE=100;static MAX=150;static MAX_PAGES=4;static METRES_PER_DEGREE=111320;static SAME_COLUMN_M=.5;static MIN_HEIGHT_M=2;fetchImpl;constructor(t){this.fetchImpl=t??fetch.bind(globalThis)}covers(t,e){const s=L.BOUNDS;return t>=s.south&&t<=s.north&&e>=s.west&&e<=s.east}async lampsNear(t,e){const s=[];let o=[];for(let n=0;n<L.MAX_PAGES&&o.length<L.MAX;n++){const a=await this.fetchImpl(L.query(t,e,L.PAGE,n*L.PAGE));if(!a.ok)throw new Error(`opendata.paris.fr refused (${a.status})`);const r=(await a.json()).results??[];if(s.push(...r),o=L.lampsFrom(s,t),r.length<L.PAGE)break}return o.slice(0,L.MAX)}static query(t,e,s,o){const n=`geom'POINT(${t.lng.toFixed(6)} ${t.lat.toFixed(6)})'`,a=new URLSearchParams({select:"geo_point_2d,lib_ouvrag,lampe_temperature_couleur,lampe_flux,support_hauteur",where:`within_distance(geo_point_2d,${n},${Math.round(e)}m)`,order_by:`distance(geo_point_2d,${n})`,limit:String(s),offset:String(o)});return`${L.ENDPOINT}?${a}`}static lampsFrom(t,e){const s=Math.cos(e.lat*Math.PI/180),o=a=>{const r=typeof a=="number"?a:Number.parseFloat(a??"");return Number.isFinite(r)&&r>0?r:void 0},n=[];for(const a of t){const r=a.geo_point_2d;if(!r||a.lib_ouvrag==="Projecteur")continue;const i=Math.round((r.lon-e.lng)*L.METRES_PER_DEGREE*s*10)/10,h=Math.round((r.lat-e.lat)*L.METRES_PER_DEGREE*10)/10,c=o(a.lampe_flux),l=n.find(d=>Math.hypot(d.eastM-i,d.northM-h)<L.SAME_COLUMN_M);if(l){c!==void 0&&(l.lumens=(l.lumens??0)+c);continue}const f=o(a.lampe_temperature_couleur),M=o(a.support_hauteur);n.push({eastM:i,northM:h,...M!==void 0&&M>=L.MIN_HEIGHT_M?{heightM:M}:{},...f!==void 0?{colorTemperatureK:f}:{},...c!==void 0?{lumens:c}:{},...a.lib_ouvrag==="Console"?{mount:"wall"}:{}})}return n}}class T{constructor(t,e){this.roads=t,this.fetchImpl=e??fetch.bind(globalThis)}credit={name:"Ville de Paris, Signalisation lumineuse tricolore",url:"https://opendata.paris.fr/explore/dataset/signalisation-tricolore/",licence:"ODbL",of:"signals"};static BOUNDS={south:48.8156,north:48.9022,west:2.2241,east:2.4698};static ENDPOINT="https://opendata.paris.fr/api/explore/v2.1/catalog/datasets/signalisation-tricolore/records";static PAGE=100;static MAX_PAGES=5;static MAX=160;static METRES_PER_DEGREE=111320;static SAME_POST_M=.8;static SEARCH_M=15;static PEDESTRIAN_ALONG_M=.4;fetchImpl;covers(t,e){const s=T.BOUNDS;return t>=s.south&&t<=s.north&&e>=s.west&&e<=s.east}async signalsNear(t,e){const s=(e+T.SEARCH_M)/T.METRES_PER_DEGREE,o=s/Math.cos(t.lat*Math.PI/180),[n,a]=await Promise.all([this.lenses(t,e),this.roads.getRoads({south:t.lat-s,north:t.lat+s,west:t.lng-o,east:t.lng+o})]);return T.signalsFrom(n,a,t)}async lenses(t,e){const s=[];for(let o=0;o<T.MAX_PAGES;o++){const n=await this.fetchImpl(T.query(t,e,T.PAGE,o*T.PAGE));if(!n.ok)throw new Error(`opendata.paris.fr refused (${n.status})`);const a=(await n.json()).results??[];if(s.push(...a),a.length<T.PAGE)break}return s}static query(t,e,s,o){const n=`geom'POINT(${t.lng.toFixed(6)} ${t.lat.toFixed(6)})'`,a=new URLSearchParams({select:"geo_point_2d,lib_regime",where:`within_distance(geo_point_2d,${n},${Math.round(e)}m)`,order_by:`distance(geo_point_2d,${n})`,limit:String(s),offset:String(o)});return`${T.ENDPOINT}?${a}`}static signalsFrom(t,e,s){const o=Math.cos(s.lat*Math.PI/180),n=(h,c)=>[(c-s.lng)*T.METRES_PER_DEGREE*o,(h-s.lat)*T.METRES_PER_DEGREE],a=[];for(const h of t){if(!h.geo_point_2d)continue;const c=n(h.geo_point_2d.lat,h.geo_point_2d.lon),l=(h.lib_regime??"").toUpperCase(),f=/ROUGE|JAUNE|VERT/.test(l),M=/PASSEZ|ATTENDEZ/.test(l);if(!f&&!M)continue;let d=a.find(g=>Math.hypot(g.at[0]-c[0],g.at[1]-c[1])<T.SAME_POST_M);d||a.push(d={at:c,vehicles:0,pedestrians:0}),f&&d.vehicles++,M&&d.pedestrians++}const r=e.map(h=>({way:h,points:h.points.map(c=>n(c.lat,c.lng))})),i=[];for(const h of a){const c=T.nearestRoad(h.at,r);if(!c)continue;const[l,f]=c.unit,M=T.heading(c.unit),d=(h.at[0]-c.foot[0])*f-(h.at[1]-c.foot[1])*l>=0,g=c.way.direction,m=g==="forward"?M:g==="backward"?(M+180)%360:d?M:(M+180)%360,E=w=>Math.round(w*10)/10,v=w=>E((w%360+360)%360);if(h.vehicles>0&&i.push({eastM:E(h.at[0]),northM:E(h.at[1]),headingDeg:v(m+180),for:"vehicles",phase:j.phaseOf(m)}),h.pedestrians>0){const w=T.heading([c.foot[0]-h.at[0],c.foot[1]-h.at[1]]),p=h.vehicles>0?T.PEDESTRIAN_ALONG_M:0;i.push({eastM:E(h.at[0]+l*p),northM:E(h.at[1]+f*p),headingDeg:v(Number.isNaN(w)?M+90:w),for:"pedestrians",phase:j.phaseOf(M)})}}return i.sort((h,c)=>Math.hypot(h.eastM,h.northM)-Math.hypot(c.eastM,c.northM)).slice(0,T.MAX)}static nearestRoad(t,e){let s;for(const{way:o,points:n}of e)for(let a=1;a<n.length;a++){const[r,i]=n[a-1],[h,c]=n[a],l=Math.hypot(h-r,c-i);if(l===0)continue;const f=[(h-r)/l,(c-i)/l],M=Math.max(0,Math.min(l,(t[0]-r)*f[0]+(t[1]-i)*f[1])),d=[r+f[0]*M,i+f[1]*M],g=Math.hypot(t[0]-d[0],t[1]-d[1]);g<=T.SEARCH_M&&(!s||g<s.distance)&&(s={way:o,unit:f,foot:d,distance:g})}return s}static heading([t,e]){return t===0&&e===0?Number.NaN:Math.round((Math.atan2(t,e)*180/Math.PI+360)%360*10)/10}}const K=B.point("surroundings").provide(B.BUILT_IN,[{id:"ign-lidar-topo",name:"IGN LiDAR HD + BD TOPO",credit:"© IGN, LiDAR HD and BD TOPO, Licence Ouverte 2.0; street lamps © OpenStreetMap contributors",creditUrl:"https://geoservices.ign.fr/lidarhd",create:()=>new I(new F({},new u({},U.TOWN_LAMPS,U.TOWN_SIGNALS)))},{id:"ign-lidar-hd",name:"IGN LiDAR HD",credit:"© IGN, LiDAR HD, Licence Ouverte 2.0; street lamps © OpenStreetMap contributors",creditUrl:"https://geoservices.ign.fr/lidarhd",create:()=>new I(new nt({},new u({},U.TOWN_LAMPS,U.TOWN_SIGNALS)))},{id:"ign-bd-topo",name:"IGN BD TOPO",credit:"© IGN, BD TOPO, Licence Ouverte 2.0; street lamps © OpenStreetMap contributors",creditUrl:"https://geoservices.ign.fr/bdtopo",create:()=>new I(new at({},new u({},U.TOWN_LAMPS,U.TOWN_SIGNALS)))},{id:"osm-buildings",name:"OpenStreetMap buildings",credit:"Buildings and street lamps © OpenStreetMap contributors (ODbL)",creditUrl:"https://www.openstreetmap.org/copyright",create:()=>new I(new W({},new u({},U.TOWN_LAMPS,U.TOWN_SIGNALS)))}]);class U{static DEFAULT_ID=K[0].id;static WORLD_ID="osm-buildings";static TOWN_LAMPS=[new L];static TOWN_SIGNALS=[new T(new et)];static NONE="none";static byId(t){return t===U.NONE?void 0:K.find(e=>e.id===t)??K[0]}static providerFor(t,e,s){const o=U.byId(t)?.create();if(t!==void 0&&t!==U.DEFAULT_ID)return o?.covers(e,s)?o:void 0;const n=K.find(r=>r.id===U.WORLD_ID).create(),a=[o,n].filter(r=>r!==void 0&&r.covers(e,s));return a.length>1?new st(a):a[0]}}export{K as SURROUNDINGS_SOURCES,U as SurroundingsSources};
|