clone

an offline map explorer where each world, from a game map to a city's open data, ships as one .atlas file

refactor: take the frontend apart into modules

Dami committed 2fb0bfa
The 2,800-line app.js becomes twenty-one modules under frontend/src — dom,
constants, state, engine, events, catalog, session, navigation, overview,
grid, legend, pins, zones, search, detail, styles, theme, util, boot, and
diagnostics — with app.js reduced to the entry that wires the stylesheet,
the parity tour, and start(). The 1,500-line stylesheet becomes thirty-one
component files under frontend/css, imported in the original order; the
built assets/app.css is byte-identical before and after. Every function
body moved verbatim: the parity tour reports the decomposed build identical
to the monolith baseline across all thirty-two steps, and the Go tests and
vet stay green. This is the ground the new visual identity gets built on -
the theme and styles modules now hold every color the JavaScript paints
with, beside a stylesheet split that gives the redesign one file per
component.
commit
2fb0bfa68a89bb8de39e0c78cb8d3fb154ef4c3a
parent
67680430ac7b76123db65bf2f4fbbfb9e07e6da1
author
Dami <dami.etoile@gmail.com>
54 files changed, +4520 -4331
Massets/app.js16+-
Mfrontend/app.css1531+----------------
Mfrontend/app.js2824+------------------------------
Afrontend/css/base.css31+
Afrontend/css/brand.css46+
Afrontend/css/category-rows.css106+
Afrontend/css/fatal-error.css25+
Afrontend/css/grid-navigator.css99+
Afrontend/css/icon-button.css23+
Afrontend/css/layer-header.css101+
Afrontend/css/layer-switch.css46+
Afrontend/css/layers.css25+
Afrontend/css/legend-toolbar.css61+
Afrontend/css/map-corner.css19+
Afrontend/css/map-hint.css23+
Afrontend/css/map-loading.css46+
Afrontend/css/map-panel.css46+
Afrontend/css/map-pickers.css51+
Afrontend/css/overview.css93+
Afrontend/css/pin-detail.css148++
Afrontend/css/responsive.css79+
Afrontend/css/search.css119+
Afrontend/css/shell.css8+
Afrontend/css/sidebar-footer.css21+
Afrontend/css/sidebar-heading.css41+
Afrontend/css/sidebar.css14+
Afrontend/css/solo-chip.css31+
Afrontend/css/text-symbol.css13+
Afrontend/css/tokens.css27+
Afrontend/css/tooltip.css37+
Afrontend/css/topbar-collapse.css14+
Afrontend/css/topbar.css12+
Afrontend/css/zone-index.css59+
Afrontend/css/zoom-controls.css36+
Afrontend/src/boot.js37+
Afrontend/src/catalog.js68+
Afrontend/src/constants.js27+
Afrontend/src/detail.js98+
Afrontend/src/diagnostics.js78+
Afrontend/src/dom.js55+
Afrontend/src/engine.js274+++
Afrontend/src/events.js265+++
Afrontend/src/grid.js231++
Afrontend/src/legend.js271+++
Afrontend/src/navigation.js315+++
Afrontend/src/overview.js134+
Afrontend/src/pins.js163++
Afrontend/src/search.js43+
Afrontend/src/session.js60+
Afrontend/src/state.js43+
Afrontend/src/styles.js456+++++
Afrontend/src/theme.js98+
Afrontend/src/util.js25+
Afrontend/src/zones.js239+++
M assets/app.js +8 -8
@@ -1,9 +1,9 @@
1-(()=>{var zh=n=>new Promise(t=>setTimeout(t,n)),xt=n=>document.querySelector(n);async function Jg(){for(let n=0;n<300&&!(window.__atlasDebug&&!xt("#map-loading")?.checkVisibility?.());n+=1)await zh(100)}async function Qg(){let n="";for(let t=0;t<100;t+=1){await zh(120),window.advanceTime?.();let e=window.__atlasDebug.snapshot(),i=JSON.stringify([e.zoom,e.center,e.resolution,e.tileStats]);if(i===n)return;n=i}}function qe(n,t={}){window.dispatchEvent(new KeyboardEvent("keydown",{key:n,bubbles:!0,cancelable:!0,...t}))}function tp(n){xt("#map").dispatchEvent(new KeyboardEvent("keydown",{key:n,bubbles:!0,cancelable:!0}))}function Ki(n,t){n.value=t,n.dispatchEvent(new Event("change",{bubbles:!0}))}function Js(n,t){let e=xt(n);e.value=t,e.dispatchEvent(new Event("input",{bubbles:!0}))}function Qs(n,t=!1){let e=xt("#parity-badge");e||(e=document.createElement("div"),e.id="parity-badge",e.style.cssText="position:fixed;top:8px;right:8px;z-index:9999;padding:6px 12px;font:700 13px monospace;border-radius:6px;color:#fff;pointer-events:none;",document.body.append(e)),e.style.background=t?"#b3261e":"#1a7f37",e.textContent=n}async function ep(){let n=[],t=async f=>{await Qg(),n.push({name:f,snapshot:JSON.parse(window.render_game_to_text())})};await Jg(),localStorage.clear();let e=xt("#game-select"),i=e.options[0].value;Ki(e,i),await t("initial"),Js("#pin-search","a"),await t("search-a");let r=xt(".search-result");r&&(r.click(),await t("search-select-first"),xt("#close-detail").click(),await t("detail-closed")),Js("#pin-search",""),await t("search-cleared");let o=xt(".category-row input");o&&(o.click(),await t("category-hidden"),o.click(),await t("category-restored"));let s=xt(".only-button");if(s){s.click(),await t("solo-first");let f=xt("#solo-chip");f&&!f.hidden&&f.click(),await t("solo-cleared")}let a=xt("#legend .layer-title");a&&(a.click(),await t("section-folded"),xt("#expand-all").click(),await t("sections-unfolded")),xt("#hide-all").click(),await t("all-hidden"),xt("#show-all").click(),await t("all-shown");let l=xt(".zone-index-item");l&&(l.click(),await t("zone-jumped"),l.dispatchEvent(new MouseEvent("contextmenu",{bubbles:!0,cancelable:!0})),await t("zone-highlighted"),l.dispatchEvent(new MouseEvent("contextmenu",{bubbles:!0,cancelable:!0})),await t("zone-unhighlighted")),qe("g"),await t("grid-open"),Js("#grid-input","m"),await t("grid-descended"),qe(" "),await t("subgrid-hidden"),qe(" "),qe("Escape"),await t("grid-ascended"),qe("Escape"),await t("grid-closed"),qe("z"),await t("labels-on"),qe("z"),await t("labels-off"),qe("b",{metaKey:!0}),await t("sidebar-collapsed"),qe("b",{metaKey:!0}),await t("sidebar-restored"),xt("#zoom-in").click(),await t("zoomed-in");let h=xt("#overview-dock");h&&!xt("#overview-shelf").hidden&&(h.click(),await t("overview-docked"),h.click(),await t("overview-undocked")),xt("#zoom-out").click(),await t("zoomed-out"),tp("Escape"),await t("viewport-escape");let c=xt("#variant-select");c.options.length>1&&(Ki(c,c.options[1].value),await t("variant-second"),Ki(c,c.options[0].value),await t("variant-first"));let u=xt("#map-select");return u.options.length>1&&(Ki(u,u.options[1].value),await t("map-second"),Ki(u,u.options[0].value),await t("map-first")),e.options.length>1&&(Ki(e,e.options[1].value),await t("game-second"),Ki(e,i),await t("game-first")),localStorage.clear(),{viewport:[window.innerWidth,window.innerHeight],steps:n}}var ta=!1;async function Nh(){if(!ta){ta=!0,Qs("parity tour running\u2026");try{let n=await ep(),t=await fetch("/parity/result",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(n,null,2)}),e=(await t.text()).trim();if(!t.ok)throw new Error(`saving failed: ${t.status} ${e}`);Qs(`parity tour complete \u2713 ${n.steps.length} steps`),console.log("parity tour saved to",e)}catch(n){Qs(`parity tour failed: ${n}`,!0),console.error("parity tour failed",n)}finally{ta=!1}}}window.__atlasTour=Nh;window.addEventListener("keydown",n=>{n.key==="F9"&&Nh()});var de={PROPERTYCHANGE:"propertychange"};function Le(n){for(let t in n)delete n[t]}function fe(n){let t;for(t in n)return!1;return!t}function Z(n,t,e,i,r){if(r){let s=e;e=function(a){return n.removeEventListener(t,e),s.call(i??this,a)}}else i&&i!==n&&(e=e.bind(i));let o={target:n,type:t,listener:e};return n.addEventListener(t,e),o}function yn(n,t,e,i){return Z(n,t,e,i,!0)}function J(n){n&&n.target&&(n.target.removeEventListener(n.type,n.listener),Le(n))}var P={CHANGE:"change",ERROR:"error",BLUR:"blur",CLEAR:"clear",CONTEXTMENU:"contextmenu",CLICK:"click",DBLCLICK:"dblclick",DRAGENTER:"dragenter",DRAGOVER:"dragover",DROP:"drop",FOCUS:"focus",KEYDOWN:"keydown",KEYPRESS:"keypress",LOAD:"load",RESIZE:"resize",TOUCHMOVE:"touchmove",WHEEL:"wheel"};var ea=class{constructor(){this.disposed=!1}dispose(){this.disposed||(this.disposed=!0,this.disposeInternal())}disposeInternal(){}},_i=ea;function Gh(n,t,e){let i,r;e=e||Vt;let o=0,s=n.length,a=!1;for(;o<s;)i=o+(s-o>>1),r=+e(n[i],t),r<0?o=i+1:(s=i,a=!r);return a?o:~o}function Vt(n,t){return n>t?1:n<t?-1:0}function Xh(n,t){return n<t?1:n>t?-1:0}function wn(n,t,e){if(n[0]<=t)return 0;let i=n.length;if(t<=n[i-1])return i-1;if(typeof e=="function"){for(let r=1;r<i;++r){let o=n[r];if(o===t)return r;if(o<t)return e(t,n[r-1],o)>0?r-1:r}return i-1}if(e>0){for(let r=1;r<i;++r)if(n[r]<t)return r-1;return i-1}if(e<0){for(let r=1;r<i;++r)if(n[r]<=t)return r;return i-1}for(let r=1;r<i;++r){if(n[r]==t)return r;if(n[r]<t)return n[r-1]-t<t-n[r]?r-1:r}return i-1}function Wh(n,t,e){for(;t<e;){let i=n[t];n[t]=n[e],n[e]=i,++t,--e}}function ge(n,t){let e=Array.isArray(t)?t:[t],i=e.length;for(let r=0;r<i;r++)n[n.length]=e[r]}function Nt(n,t){let e=n.length;if(e!==t.length)return!1;for(let i=0;i<e;i++)if(n[i]!==t[i])return!1;return!0}function Yh(n,t,e){let i=t||Vt;return n.every(function(r,o){if(o===0)return!0;let s=i(n[o-1],r);return!(s>0||e&&s===0)})}function $e(){return!0}function Je(){return!1}function Qe(){}function lo(n){let t,e,i;return function(){let r=Array.prototype.slice.call(arguments);return(!e||this!==i||!Nt(r,e))&&(i=this,e=r,t=n.apply(this,arguments)),t}}function Uh(n){function t(){let e;try{e=n()}catch(i){return Promise.reject(i)}return e instanceof Promise?e:Promise.resolve(e)}return t()}var ia=class{constructor(t){this.propagationStopped,this.defaultPrevented,this.type=t,this.target=null}preventDefault(){this.defaultPrevented=!0}stopPropagation(){this.propagationStopped=!0}};var Lt=ia;var na=class extends _i{constructor(t){super(),this.eventTarget_=t,this.pendingRemovals_=null,this.dispatching_=null,this.listeners_=null}addEventListener(t,e){if(!t||!e)return;let i=this.listeners_||(this.listeners_={}),r=i[t]||(i[t]=[]);r.includes(e)||r.push(e)}dispatchEvent(t){let e=typeof t=="string",i=e?t:t.type,r=this.listeners_&&this.listeners_[i];if(!r)return;let o=e?new Lt(t):t;o.target||(o.target=this.eventTarget_||this);let s=this.dispatching_||(this.dispatching_={}),a=this.pendingRemovals_||(this.pendingRemovals_={});i in s||(s[i]=0,a[i]=0),++s[i];let l;for(let h=0,c=r.length;h<c;++h)if("handleEvent"in r[h]?l=r[h].handleEvent(o):l=r[h].call(this,o),l===!1||o.propagationStopped){l=!1;break}if(--s[i]===0){let h=a[i];for(delete a[i];h--;)this.removeEventListener(i,Qe);delete s[i]}return l}disposeInternal(){this.listeners_&&Le(this.listeners_)}getListeners(t){return this.listeners_&&this.listeners_[t]||void 0}hasListener(t){return this.listeners_?t?t in this.listeners_:Object.keys(this.listeners_).length>0:!1}removeEventListener(t,e){if(!this.listeners_)return;let i=this.listeners_[t];if(!i)return;let r=i.indexOf(e);r!==-1&&(this.pendingRemovals_&&t in this.pendingRemovals_?(i[r]=Qe,++this.pendingRemovals_[t]):(i.splice(r,1),i.length===0&&delete this.listeners_[t]))}},xi=na;var En=class extends xi{constructor(){super(),this.on=this.onInternal,this.once=this.onceInternal,this.un=this.unInternal,this.revision_=0}changed(){++this.revision_,this.dispatchEvent(P.CHANGE)}getRevision(){return this.revision_}onInternal(t,e){if(Array.isArray(t)){let i=t.length,r=new Array(i);for(let o=0;o<i;++o)r[o]=Z(this,t[o],e);return r}return Z(this,t,e)}onceInternal(t,e){let i;if(Array.isArray(t)){let r=t.length;i=new Array(r);for(let o=0;o<r;++o)i[o]=yn(this,t[o],e)}else i=yn(this,t,e);return e.ol_key=i,i}unInternal(t,e){let i=e.ol_key;if(i)ip(i);else if(Array.isArray(t))for(let r=0,o=t.length;r<o;++r)this.removeEventListener(t[r],e);else this.removeEventListener(t,e)}};En.prototype.on;En.prototype.once;En.prototype.un;function ip(n){if(Array.isArray(n))for(let t=0,e=n.length;t<e;++t)J(n[t]);else J(n)}var co=En;function H(){throw new Error("Unimplemented abstract method.")}var np=0;function U(n){return n.ol_uid||(n.ol_uid=String(++np))}var ho=class extends Lt{constructor(t,e,i){super(t),this.key=e,this.oldValue=i}},ra=class extends co{constructor(t){super(),this.on,this.once,this.un,U(this),this.values_=null,t!==void 0&&this.setProperties(t)}get(t){let e;return this.values_&&this.values_.hasOwnProperty(t)&&(e=this.values_[t]),e}getKeys(){return this.values_&&Object.keys(this.values_)||[]}getProperties(){return this.values_&&Object.assign({},this.values_)||{}}getPropertiesInternal(){return this.values_}hasProperties(){return!!this.values_}notify(t,e){let i;i=`change:${t}`,this.hasListener(i)&&this.dispatchEvent(new ho(i,t,e)),i=de.PROPERTYCHANGE,this.hasListener(i)&&this.dispatchEvent(new ho(i,t,e))}addChangeListener(t,e){this.addEventListener(`change:${t}`,e)}removeChangeListener(t,e){this.removeEventListener(`change:${t}`,e)}set(t,e,i){let r=this.values_||(this.values_={});if(i)r[t]=e;else{let o=r[t];r[t]=e,o!==e&&this.notify(t,o)}}setProperties(t,e){for(let i in t)this.set(i,t[i],e)}applyProperties(t){t.values_&&Object.assign(this.values_||(this.values_={}),t.values_)}unset(t,e){if(this.values_&&t in this.values_){let i=this.values_[t];delete this.values_[t],fe(this.values_)&&(this.values_=null),e||this.notify(t,i)}}},yt=ra;function V(n,t){if(!n)throw new Error(t)}var oa=class n extends yt{constructor(t){if(super(),this.on,this.once,this.un,this.id_=void 0,this.geometryName_="geometry",this.style_=null,this.styleFunction_=void 0,this.geometryChangeKey_=null,this.addChangeListener(this.geometryName_,this.handleGeometryChanged_),t)if(typeof t.getSimplifiedGeometry=="function"){let e=t;this.setGeometry(e)}else{let e=t;this.setProperties(e)}}clone(){let t=new n,e=this.geometryName_;t.setGeometryName(e);let i=this.getPropertiesInternal();if(i){let o=this.getGeometry();for(let s in i)s===e&&o?t.set(s,o.clone()):t.set(s,i[s],!0)}let r=this.getStyle();return r&&t.setStyle(r),t}getGeometry(){return this.get(this.geometryName_)}getId(){return this.id_}getGeometryName(){return this.geometryName_}getStyle(){return this.style_}getStyleFunction(){return this.styleFunction_}handleGeometryChange_(){this.changed()}handleGeometryChanged_(){this.geometryChangeKey_&&(J(this.geometryChangeKey_),this.geometryChangeKey_=null);let t=this.getGeometry();t&&(this.geometryChangeKey_=Z(t,P.CHANGE,this.handleGeometryChange_,this)),this.changed()}setGeometry(t){this.set(this.geometryName_,t)}setStyle(t){this.style_=t,this.styleFunction_=t?rp(t):void 0,this.changed()}setId(t){this.id_=t,this.changed()}setGeometryName(t){t!==this.geometryName_&&(this.removeChangeListener(this.geometryName_,this.handleGeometryChanged_),this.geometryName_=t,this.addChangeListener(this.geometryName_,this.handleGeometryChanged_),this.handleGeometryChanged_())}};function rp(n){if(typeof n=="function")return n;let t;return Array.isArray(n)?t=n:(V(typeof n.getZIndex=="function","Expected an `ol/style/Style` or an array of `ol/style/Style.js`"),t=[n]),function(){return t}}var vn=oa;var At={ADD:"add",REMOVE:"remove"};var Kh={LENGTH:"length"},Cn=class extends Lt{constructor(t,e,i){super(t),this.element=e,this.index=i}},sa=class extends yt{constructor(t,e){if(super(),this.on,this.once,this.un,e=e||{},this.unique_=!!e.unique,this.array_=t??[],this.unique_)for(let i=1,r=this.array_.length;i<r;++i)this.assertUnique_(this.array_[i],i);this.updateLength_()}clear(){for(;this.getLength()>0;)this.pop()}extend(t){for(let e=0,i=t.length;e<i;++e)this.push(t[e]);return this}forEach(t){let e=this.array_;for(let i=0,r=e.length;i<r;++i)t(e[i],i,e)}getArray(){return this.array_}item(t){return this.array_[t]}getLength(){return this.get(Kh.LENGTH)}insertAt(t,e){if(t<0||t>this.getLength())throw new Error("Index out of bounds: "+t);this.unique_&&this.assertUnique_(e),this.array_.splice(t,0,e),this.updateLength_(),this.dispatchEvent(new Cn(At.ADD,e,t))}pop(){return this.removeAt(this.getLength()-1)}push(t){let e=this.getLength();return this.insertAt(e,t),this.getLength()}remove(t){let e=this.array_;for(let i=0,r=e.length;i<r;++i)if(e[i]===t)return this.removeAt(i)}removeAt(t){if(t<0||t>=this.getLength())return;let e=this.array_[t];return this.array_.splice(t,1),this.updateLength_(),this.dispatchEvent(new Cn(At.REMOVE,e,t)),e}setAt(t,e){let i=this.getLength();if(t>=i){this.insertAt(t,e);return}if(t<0)throw new Error("Index out of bounds: "+t);this.unique_&&this.assertUnique_(e,t);let r=this.array_[t];this.array_[t]=e,this.dispatchEvent(new Cn(At.REMOVE,r,t)),this.dispatchEvent(new Cn(At.ADD,e,t))}updateLength_(){this.set(Kh.LENGTH,this.array_.length)}assertUnique_(t,e){let i=this.array_;for(let r=0,o=i.length;r<o;++r)if(i[r]===t&&r!==e)throw new Error("Duplicate item added to a unique collection")}},kt=sa;var aa=class extends Lt{constructor(t,e,i){super(t),this.map=e,this.frameState=i!==void 0?i:null}},yi=aa;var la=class extends yi{constructor(t,e,i,r,o,s){super(t,e,o),this.originalEvent=i,this.pixel_=null,this.coordinate_=null,this.dragging=r!==void 0?r:!1,this.activePointers=s}get pixel(){return this.pixel_||(this.pixel_=this.map.getEventPixel(this.originalEvent)),this.pixel_}set pixel(t){this.pixel_=t}get coordinate(){return this.coordinate_||(this.coordinate_=this.map.getCoordinateFromPixel(this.pixel)),this.coordinate_}set coordinate(t){this.coordinate_=t}preventDefault(){super.preventDefault(),"preventDefault"in this.originalEvent&&this.originalEvent.preventDefault()}stopPropagation(){super.stopPropagation(),"stopPropagation"in this.originalEvent&&this.originalEvent.stopPropagation()}},Ae=la;var at={SINGLECLICK:"singleclick",CLICK:P.CLICK,DBLCLICK:P.DBLCLICK,POINTERDRAG:"pointerdrag",POINTERMOVE:"pointermove",POINTERDOWN:"pointerdown",POINTERUP:"pointerup",POINTEROVER:"pointerover",POINTEROUT:"pointerout",POINTERENTER:"pointerenter",POINTERLEAVE:"pointerleave",POINTERCANCEL:"pointercancel"};var Zi=typeof navigator<"u"&&typeof navigator.userAgent<"u"?navigator.userAgent.toLowerCase():"",op=Zi.includes("safari")&&!Zi.includes("chrom"),N0=op&&(Zi.includes("version/15.4")||/cpu (os|iphone os) 15_4 like mac os x/.test(Zi)),Zh=Zi.includes("webkit")&&!Zi.includes("edge"),ca=Zi.includes("macintosh"),Vh=typeof devicePixelRatio<"u"?devicePixelRatio:1,St=typeof WorkerGlobalScope<"u"&&typeof OffscreenCanvas<"u"&&self instanceof WorkerGlobalScope,ha=typeof Image<"u"&&Image.prototype.decode;var uo=(function(){let n=!1;try{let t=Object.defineProperty({},"passive",{get:function(){n=!0}});window.addEventListener("_",null,t),window.removeEventListener("_",null,t)}catch{}return n})();var fr={POINTERMOVE:"pointermove",POINTERDOWN:"pointerdown",POINTERUP:"pointerup",POINTEROVER:"pointerover",POINTEROUT:"pointerout",POINTERENTER:"pointerenter",POINTERLEAVE:"pointerleave",POINTERCANCEL:"pointercancel"};var ua=class extends xi{constructor(t,e){super(t),this.map_=t,this.clickTimeoutId_,this.emulateClicks_=!1,this.dragging_=!1,this.dragListenerKeys_=[],this.moveTolerance_=e===void 0?1:e,this.down_=null;let i=this.map_.getViewport();this.activePointers_=[],this.trackedTouches_={},this.element_=i,this.pointerdownListenerKey_=Z(i,fr.POINTERDOWN,this.handlePointerDown_,this),this.originalPointerMoveEvent_,this.relayedListenerKey_=Z(i,fr.POINTERMOVE,this.relayMoveEvent_,this),this.boundHandleTouchMove_=this.handleTouchMove_.bind(this),this.element_.addEventListener(P.TOUCHMOVE,this.boundHandleTouchMove_,uo?{passive:!1}:!1)}emulateClick_(t){let e=new Ae(at.CLICK,this.map_,t);this.dispatchEvent(e),this.clickTimeoutId_!==void 0?(clearTimeout(this.clickTimeoutId_),this.clickTimeoutId_=void 0,e=new Ae(at.DBLCLICK,this.map_,t),this.dispatchEvent(e)):this.clickTimeoutId_=setTimeout(()=>{this.clickTimeoutId_=void 0;let i=new Ae(at.SINGLECLICK,this.map_,t);this.dispatchEvent(i)},250)}updateActivePointers_(t){let e=t,i=e.pointerId;if(e.type==at.POINTERUP||e.type==at.POINTERCANCEL){delete this.trackedTouches_[i];for(let r in this.trackedTouches_)if(this.trackedTouches_[r].target!==e.target){delete this.trackedTouches_[r];break}}else(e.type==at.POINTERDOWN||e.type==at.POINTERMOVE)&&(this.trackedTouches_[i]=e);this.activePointers_=Object.values(this.trackedTouches_)}handlePointerUp_(t){this.updateActivePointers_(t);let e=new Ae(at.POINTERUP,this.map_,t,void 0,void 0,this.activePointers_);this.dispatchEvent(e),this.emulateClicks_&&!e.defaultPrevented&&!this.dragging_&&this.isMouseActionButton_(t)&&this.emulateClick_(this.down_),this.activePointers_.length===0&&(this.dragListenerKeys_.forEach(J),this.dragListenerKeys_.length=0,this.dragging_=!1,this.down_=null)}isMouseActionButton_(t){return t.button===0}handlePointerDown_(t){this.emulateClicks_=this.activePointers_.length===0,this.updateActivePointers_(t);let e=new Ae(at.POINTERDOWN,this.map_,t,void 0,void 0,this.activePointers_);if(this.dispatchEvent(e),this.down_=new PointerEvent(t.type,t),Object.defineProperty(this.down_,"target",{writable:!1,value:t.target}),this.dragListenerKeys_.length===0){let i=this.map_.getOwnerDocument();this.dragListenerKeys_.push(Z(i,at.POINTERMOVE,this.handlePointerMove_,this),Z(i,at.POINTERUP,this.handlePointerUp_,this),Z(this.element_,at.POINTERCANCEL,this.handlePointerUp_,this)),this.element_.getRootNode&&this.element_.getRootNode()!==i&&this.dragListenerKeys_.push(Z(this.element_.getRootNode(),at.POINTERUP,this.handlePointerUp_,this))}}handlePointerMove_(t){if(this.isMoving_(t)){this.updateActivePointers_(t),this.dragging_=!0;let e=new Ae(at.POINTERDRAG,this.map_,t,this.dragging_,void 0,this.activePointers_);this.dispatchEvent(e)}}relayMoveEvent_(t){this.originalPointerMoveEvent_=t;let e=!!(this.down_&&this.isMoving_(t));this.dispatchEvent(new Ae(at.POINTERMOVE,this.map_,t,e))}handleTouchMove_(t){let e=this.originalPointerMoveEvent_;(!e||e.defaultPrevented)&&(typeof t.cancelable!="boolean"||t.cancelable===!0)&&t.preventDefault()}isMoving_(t){return this.dragging_||Math.abs(t.clientX-this.down_.clientX)>this.moveTolerance_||Math.abs(t.clientY-this.down_.clientY)>this.moveTolerance_}disposeInternal(){this.relayedListenerKey_&&(J(this.relayedListenerKey_),this.relayedListenerKey_=null),this.element_.removeEventListener(P.TOUCHMOVE,this.boundHandleTouchMove_),this.pointerdownListenerKey_&&(J(this.pointerdownListenerKey_),this.pointerdownListenerKey_=null),this.dragListenerKeys_.forEach(J),this.dragListenerKeys_.length=0,this.element_=null,super.disposeInternal()}},Bh=ua;var Me={POSTRENDER:"postrender",MOVESTART:"movestart",MOVEEND:"moveend",LOADSTART:"loadstart",LOADEND:"loadend"};var Ot={LAYERGROUP:"layergroup",SIZE:"size",TARGET:"target",VIEW:"view"};var O={IDLE:0,LOADING:1,LOADED:2,ERROR:3,EMPTY:4};var gr=1/0,da=class{constructor(t,e){this.priorityFunction_=t,this.keyFunction_=e,this.elements_=[],this.priorities_=[],this.queuedElements_={}}clear(){this.elements_.length=0,this.priorities_.length=0,Le(this.queuedElements_)}dequeue(){let t=this.elements_,e=this.priorities_,i=t[0];t.length==1?(t.length=0,e.length=0):(t[0]=t.pop(),e[0]=e.pop(),this.siftUp_(0));let r=this.keyFunction_(i);return delete this.queuedElements_[r],i}enqueue(t){V(!(this.keyFunction_(t)in this.queuedElements_),"Tried to enqueue an `element` that was already added to the queue");let e=this.priorityFunction_(t);return e!=gr?(this.elements_.push(t),this.priorities_.push(e),this.queuedElements_[this.keyFunction_(t)]=!0,this.siftDown_(0,this.elements_.length-1),!0):!1}getCount(){return this.elements_.length}getLeftChildIndex_(t){return t*2+1}getRightChildIndex_(t){return t*2+2}getParentIndex_(t){return t-1>>1}heapify_(){let t;for(t=(this.elements_.length>>1)-1;t>=0;t--)this.siftUp_(t)}isEmpty(){return this.elements_.length===0}isKeyQueued(t){return t in this.queuedElements_}isQueued(t){return this.isKeyQueued(this.keyFunction_(t))}siftUp_(t){let e=this.elements_,i=this.priorities_,r=e.length,o=e[t],s=i[t],a=t;for(;t<r>>1;){let l=this.getLeftChildIndex_(t),h=this.getRightChildIndex_(t),c=h<r&&i[h]<i[l]?h:l;e[t]=e[c],i[t]=i[c],t=c}e[t]=o,i[t]=s,this.siftDown_(a,t)}siftDown_(t,e){let i=this.elements_,r=this.priorities_,o=i[e],s=r[e];for(;e>t;){let a=this.getParentIndex_(e);if(r[a]>s)i[e]=i[a],r[e]=r[a],e=a;else break}i[e]=o,r[e]=s}reprioritize(){let t=this.priorityFunction_,e=this.elements_,i=this.priorities_,r=0,o=e.length,s,a,l;for(a=0;a<o;++a)s=e[a],l=t(s),l==gr?delete this.queuedElements_[this.keyFunction_(s)]:(i[r]=l,e[r++]=s);e.length=r,i.length=r,this.heapify_()}},jh=da;var fa=class extends jh{constructor(t,e){super(i=>t.apply(null,i),i=>i[0].getKey()),this.boundHandleTileChange_=this.handleTileChange.bind(this),this.tileChangeCallback_=e,this.tilesLoading_=0,this.tilesLoadingKeys_={}}enqueue(t){let e=super.enqueue(t);return e&&t[0].addEventListener(P.CHANGE,this.boundHandleTileChange_),e}getTilesLoading(){return this.tilesLoading_}handleTileChange(t){let e=t.target,i=e.getState();if(i===O.LOADED||i===O.ERROR||i===O.EMPTY){i!==O.ERROR&&e.removeEventListener(P.CHANGE,this.boundHandleTileChange_);let r=e.getKey();r in this.tilesLoadingKeys_&&(delete this.tilesLoadingKeys_[r],--this.tilesLoading_),this.tileChangeCallback_()}}loadMoreTiles(t,e){let i=0;for(;this.tilesLoading_<t&&i<e&&this.getCount()>0;){let r=this.dequeue()[0],o=r.getKey();r.getState()===O.IDLE&&!(o in this.tilesLoadingKeys_)&&(this.tilesLoadingKeys_[o]=!0,++this.tilesLoading_,++i,r.load())}}},Hh=fa;function qh(n,t,e,i,r){if(!n||!(e in n.wantedTiles))return gr;if(!n.wantedTiles[e][t.getKey()])return gr;let o=n.viewState.center,s=i[0]-o[0],a=i[1]-o[1];return 65536*Math.log(r)+Math.sqrt(s*s+a*a)/r}var Rt={ANIMATING:0,INTERACTING:1};var ae={CENTER:"center",RESOLUTION:"resolution",ROTATION:"rotation"};function et(n,t,e){return Math.min(Math.max(n,t),e)}function $h(n,t,e,i,r,o){let s=r-e,a=o-i;if(s!==0||a!==0){let l=((n-e)*s+(t-i)*a)/(s*s+a*a);l>1?(e=r,i=o):l>0&&(e+=s*l,i+=a*l)}return pe(n,t,e,i)}function pe(n,t,e,i){let r=e-n,o=i-t;return r*r+o*o}function Jh(n){let t=n.length;for(let i=0;i<t;i++){let r=i,o=Math.abs(n[i][i]);for(let a=i+1;a<t;a++){let l=Math.abs(n[a][i]);l>o&&(o=l,r=a)}if(o===0)return null;let s=n[r];n[r]=n[i],n[i]=s;for(let a=i+1;a<t;a++){let l=-n[a][i]/n[i][i];for(let h=i;h<t+1;h++)i==h?n[a][h]=0:n[a][h]+=l*n[i][h]}}let e=new Array(t);for(let i=t-1;i>=0;i--){e[i]=n[i][t]/n[i][i];for(let r=i-1;r>=0;r--)n[r][t]-=n[r][i]*e[i]}return e}function fo(n){return n*180/Math.PI}function me(n){return n*Math.PI/180}function Pe(n,t){let e=n%t;return e*t<0?e+t:e}function Gt(n,t,e){return n+e*(t-n)}function Vi(n,t){let e=Math.pow(10,t);return Math.round(n*e)/e}function pr(n,t){return Math.floor(Vi(n,t))}function mr(n,t){return Math.ceil(Vi(n,t))}function go(n,t,e){if(n>=t&&n<e)return n;let i=e-t;return((n-t)%i+i)%i+t}function ga(n,t,e){return(function(i,r,o,s,a){if(!i)return;if(!r&&!t)return i;let l=t?0:o[0]*r,h=t?0:o[1]*r,c=a?a[0]:0,u=a?a[1]:0,f=n[0]+l/2+c,g=n[2]-l/2+c,p=n[1]+h/2+u,_=n[3]-h/2+u;f>g&&(f=(g+f)/2,g=f),p>_&&(p=(_+p)/2,_=p);let m=et(i[0],f,g),x=et(i[1],p,_);if(s&&e&&r){let w=30*r;m+=-w*Math.log(1+Math.max(0,f-i[0])/w)+w*Math.log(1+Math.max(0,i[0]-g)/w),x+=-w*Math.log(1+Math.max(0,p-i[1])/w)+w*Math.log(1+Math.max(0,i[1]-_)/w)}return[m,x]})}function Qh(n){return n}var wt={UNKNOWN:0,INTERSECTING:1,ABOVE:2,RIGHT:4,BELOW:8,LEFT:16};function pa(n){let t=ut();for(let e=0,i=n.length;e<i;++e)Hi(t,n[e]);return t}function sp(n,t,e){let i=Math.min.apply(null,n),r=Math.min.apply(null,t),o=Math.max.apply(null,n),s=Math.max.apply(null,t);return Qt(i,r,o,s,e)}function bn(n,t,e){return e?(e[0]=n[0]-t,e[1]=n[1]-t,e[2]=n[2]+t,e[3]=n[3]+t,e):[n[0]-t,n[1]-t,n[2]+t,n[3]+t]}function mo(n,t){return t?(t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t):n.slice()}function wi(n,t,e){let i,r;return t<n[0]?i=n[0]-t:n[2]<t?i=t-n[2]:i=0,e<n[1]?r=n[1]-e:n[3]<e?r=e-n[3]:r=0,i*i+r*r}function _e(n,t){return _r(n,t[0],t[1])}function ke(n,t){return n[0]<=t[0]&&t[2]<=n[2]&&n[1]<=t[1]&&t[3]<=n[3]}function _r(n,t,e){return n[0]<=t&&t<=n[2]&&n[1]<=e&&e<=n[3]}function po(n,t){let e=n[0],i=n[1],r=n[2],o=n[3],s=t[0],a=t[1],l=wt.UNKNOWN;return s<e?l=l|wt.LEFT:s>r&&(l=l|wt.RIGHT),a<i?l=l|wt.BELOW:a>o&&(l=l|wt.ABOVE),l===wt.UNKNOWN&&(l=wt.INTERSECTING),l}function ut(){return[1/0,1/0,-1/0,-1/0]}function Qt(n,t,e,i,r){return r?(r[0]=n,r[1]=t,r[2]=e,r[3]=i,r):[n,t,e,i]}function Bi(n){return Qt(1/0,1/0,-1/0,-1/0,n)}function _o(n,t){let e=n[0],i=n[1];return Qt(e,i,e,i,t)}function Sn(n,t,e,i,r){let o=Bi(r);return ma(o,n,t,e,i)}function ji(n,t){return n[0]==t[0]&&n[2]==t[2]&&n[1]==t[1]&&n[3]==t[3]}function xo(n,t){return t[0]<n[0]&&(n[0]=t[0]),t[2]>n[2]&&(n[2]=t[2]),t[1]<n[1]&&(n[1]=t[1]),t[3]>n[3]&&(n[3]=t[3]),n}function Hi(n,t){t[0]<n[0]&&(n[0]=t[0]),t[0]>n[2]&&(n[2]=t[0]),t[1]<n[1]&&(n[1]=t[1]),t[1]>n[3]&&(n[3]=t[1])}function ma(n,t,e,i,r){for(;e<i;e+=r)ap(n,t[e],t[e+1]);return n}function ap(n,t,e){n[0]=Math.min(n[0],t),n[1]=Math.min(n[1],e),n[2]=Math.max(n[2],t),n[3]=Math.max(n[3],e)}function yo(n,t){let e;return e=t(Rn(n)),e||(e=t(Tn(n)),e)||(e=t(In(n)),e)||(e=t(le(n)),e)?e:!1}function xr(n){let t=0;return De(n)||(t=j(n)*ct(n)),t}function Rn(n){return[n[0],n[1]]}function Tn(n){return[n[2],n[1]]}function Bt(n){return[(n[0]+n[2])/2,(n[1]+n[3])/2]}function tu(n,t){let e;if(t==="bottom-left")e=Rn(n);else if(t==="bottom-right")e=Tn(n);else if(t==="top-left")e=le(n);else if(t==="top-right")e=In(n);else throw new Error("Invalid corner");return e}function yr(n,t,e,i,r){let[o,s,a,l,h,c,u,f]=_a(n,t,e,i);return Qt(Math.min(o,a,h,u),Math.min(s,l,c,f),Math.max(o,a,h,u),Math.max(s,l,c,f),r)}function _a(n,t,e,i){let r=t*i[0]/2,o=t*i[1]/2,s=Math.cos(e),a=Math.sin(e),l=r*s,h=r*a,c=o*s,u=o*a,f=n[0],g=n[1];return[f-l+u,g-h-c,f-l-u,g-h+c,f+l-u,g+h+c,f+l+u,g+h-c,f-l+u,g-h-c]}function ct(n){return n[3]-n[1]}function Oe(n,t,e){let i=e||ut();return ht(n,t)?(n[0]>t[0]?i[0]=n[0]:i[0]=t[0],n[1]>t[1]?i[1]=n[1]:i[1]=t[1],n[2]<t[2]?i[2]=n[2]:i[2]=t[2],n[3]<t[3]?i[3]=n[3]:i[3]=t[3]):Bi(i),i}function xa(n,t){if(!ht(n,t))return[n.slice()];if(ke(t,n))return[];let[e,i,r,o]=n,s=Math.max(e,t[0]),a=Math.max(i,t[1]),l=Math.min(r,t[2]),h=Math.min(o,t[3]),c=[];return s>e&&c.push([e,i,s,o]),l<r&&c.push([l,i,r,o]),a>i&&c.push([s,i,l,a]),h<o&&c.push([s,h,l,o]),c}function le(n){return[n[0],n[3]]}function In(n){return[n[2],n[3]]}function j(n){return n[2]-n[0]}function ht(n,t){return n[0]<=t[2]&&n[2]>=t[0]&&n[1]<=t[3]&&n[3]>=t[1]}function De(n){return n[2]<n[0]||n[3]<n[1]}function eu(n,t){return t?(t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t):n}function iu(n,t,e){let i=!1,r=po(n,t),o=po(n,e);if(r===wt.INTERSECTING||o===wt.INTERSECTING)i=!0;else{let s=n[0],a=n[1],l=n[2],h=n[3],c=t[0],u=t[1],f=e[0],g=e[1],p=(g-u)/(f-c),_,m;o&wt.ABOVE&&!(r&wt.ABOVE)&&(_=f-(g-h)/p,i=_>=s&&_<=l),!i&&o&wt.RIGHT&&!(r&wt.RIGHT)&&(m=g-(f-l)*p,i=m>=a&&m<=h),!i&&o&wt.BELOW&&!(r&wt.BELOW)&&(_=f-(g-a)/p,i=_>=s&&_<=l),!i&&o&wt.LEFT&&!(r&wt.LEFT)&&(m=g-(f-s)*p,i=m>=a&&m<=h)}return i}function nu(n,t,e,i){if(De(n))return Bi(e);let r=[];if(i>1){let a=n[2]-n[0],l=n[3]-n[1];for(let h=0;h<i;++h)r.push(n[0]+a*h/i,n[1],n[2],n[1]+l*h/i,n[2]-a*h/i,n[3],n[0],n[3]-l*h/i)}else r=[n[0],n[1],n[2],n[1],n[2],n[3],n[0],n[3]];t(r,r,2);let o=[],s=[];for(let a=0,l=r.length;a<l;a+=2)o.push(r[a]),s.push(r[a+1]);return sp(o,s,e)}function ya(n,t){let e=t.getExtent(),i=Bt(n);if(t.canWrapX()&&(i[0]<e[0]||i[0]>=e[2])){let r=j(e),s=Math.floor((i[0]-e[0])/r)*r;n[0]-=s,n[2]-=s}return n}function wo(n,t,e){if(t.canWrapX()){let i=t.getExtent();if(!isFinite(n[0])||!isFinite(n[2]))return[[i[0],n[1],i[2],n[3]]];ya(n,t);let r=j(i);if(j(n)>r&&!e)return[[i[0],n[1],i[2],n[3]]];if(n[0]<i[0])return[[n[0]+r,n[1],i[2],n[3]],[i[0],n[1],n[2],n[3]]];if(n[2]>i[2])return[[n[0],n[1],i[2],n[3]],[i[0],n[1],n[2]-r,n[3]]]}return[n]}function ru(n,t){let e=[n];for(let i=0,r=t.length;i<r&&e.length>0;++i){let o=[];for(let s=0,a=e.length;s<a;++s)o.push(...xa(e[s],t[i]));e=o}return e}function ou(n,t){return n[0]+=+t[0],n[1]+=+t[1],n}function qi(n,t){let e=!0;for(let i=n.length-1;i>=0;--i)if(n[i]!=t[i]){e=!1;break}return e}function Ln(n,t){let e=Math.cos(t),i=Math.sin(t),r=n[0]*e-n[1]*i,o=n[1]*e+n[0]*i;return n[0]=r,n[1]=o,n}function su(n,t){return n[0]*=t,n[1]*=t,n}function Eo(n,t){if(t.canWrapX()){let e=j(t.getExtent()),i=au(n,t,e);i&&(n[0]-=i*e)}return n}function au(n,t,e){let i=t.getExtent(),r=0;return t.canWrapX()&&(n[0]<i[0]||n[0]>i[2])&&(e=e||j(i),r=Math.floor((n[0]-i[0])/e)),r}function lu(n,t,e){let i=Math.sqrt((t[0]-n[0])*(t[0]-n[0])+(t[1]-n[1])*(t[1]-n[1])),r=[(t[0]-n[0])/i,(t[1]-n[1])/i],o=[-r[1],r[0]],s=Math.sqrt((e[0]-n[0])*(e[0]-n[0])+(e[1]-n[1])*(e[1]-n[1])),a=[(e[0]-n[0])/s,(e[1]-n[1])/s],l=i===0||s===0?0:Math.acos(et(a[0]*r[0]+a[1]*r[1],-1,1));return l=Math.max(l,1e-5),a[0]*o[0]+a[1]*o[1]>0?l:Math.PI*2-l}function wa(n){return Math.pow(n,3)}function ce(n){return 1-wa(1-n)}function cu(n){return 3*n*n-2*n*n*n}function hu(n){return n}var lp=63710088e-1;function Ea(n,t,e){e=e||lp;let i=me(n[1]),r=me(t[1]),o=(r-i)/2,s=me(t[0]-n[0])/2,a=Math.sin(o)*Math.sin(o)+Math.sin(s)*Math.sin(s)*Math.cos(i)*Math.cos(r);return 2*e*Math.atan2(Math.sqrt(a),Math.sqrt(1-a))}var uu={info:1,warn:2,error:3,none:4},cp=uu.info;function vo(...n){cp>uu.warn||console.warn(...n)}var ti={radians:6370997/(2*Math.PI),degrees:2*Math.PI*6370997/360,ft:.3048,m:1,"us-ft":1200/3937};var va=class{constructor(t){this.code_=t.code,this.units_=t.units,this.extent_=t.extent!==void 0?t.extent:null,this.worldExtent_=t.worldExtent!==void 0?t.worldExtent:null,this.axisOrientation_=t.axisOrientation!==void 0?t.axisOrientation:"enu",this.global_=t.global!==void 0?t.global:!1,this.canWrapX_=!!(this.global_&&this.extent_),this.getPointResolutionFunc_=t.getPointResolution,this.defaultTileGrid_=null,this.metersPerUnit_=t.metersPerUnit}canWrapX(){return this.canWrapX_}getCode(){return this.code_}getExtent(){return this.extent_}getUnits(){return this.units_}getMetersPerUnit(){return this.metersPerUnit_||ti[this.units_]}getWorldExtent(){return this.worldExtent_}getAxisOrientation(){return this.axisOrientation_}isGlobal(){return this.global_}setGlobal(t){this.global_=t,this.canWrapX_=!!(t&&this.extent_)}getDefaultTileGrid(){return this.defaultTileGrid_}setDefaultTileGrid(t){this.defaultTileGrid_=t}setExtent(t){this.extent_=t,this.canWrapX_=!!(this.global_&&t)}setWorldExtent(t){this.worldExtent_=t}setGetPointResolution(t){this.getPointResolutionFunc_=t}getPointResolutionFunc(){return this.getPointResolutionFunc_}},Ei=va;var wr=6378137,An=Math.PI*wr,hp=[-An,-An,An,An],up=[-180,-85,180,85],Co=wr*Math.log(Math.tan(Math.PI/2)),vi=class extends Ei{constructor(t){super({code:t,units:"m",extent:hp,global:!0,worldExtent:up,getPointResolution:function(e,i){return e/Math.cosh(i[1]/wr)}})}},Ca=[new vi("EPSG:3857"),new vi("EPSG:102100"),new vi("EPSG:102113"),new vi("EPSG:900913"),new vi("http://www.opengis.net/def/crs/EPSG/0/3857"),new vi("http://www.opengis.net/gml/srs/epsg.xml#3857")];function du(n,t,e,i){let r=n.length;e=e>1?e:2,i=i??e,t===void 0&&(e>2?t=n.slice():t=new Array(r));for(let o=0;o<r;o+=i){t[o]=An*n[o]/180;let s=wr*Math.log(Math.tan(Math.PI*(+n[o+1]+90)/360));s>Co?s=Co:s<-Co&&(s=-Co),t[o+1]=s}return t}function fu(n,t,e,i){let r=n.length;e=e>1?e:2,i=i??e,t===void 0&&(e>2?t=n.slice():t=new Array(r));for(let o=0;o<r;o+=i)t[o]=180*n[o]/An,t[o+1]=360*Math.atan(Math.exp(n[o+1]/wr))/Math.PI-90;return t}var dp=6378137,gu=[-180,-90,180,90],fp=Math.PI*dp/180,ei=class extends Ei{constructor(t,e){super({code:t,units:"degrees",extent:gu,axisOrientation:e,global:!0,metersPerUnit:fp,worldExtent:gu})}},ba=[new ei("CRS:84"),new ei("EPSG:4326","neu"),new ei("urn:ogc:def:crs:OGC:1.3:CRS84"),new ei("urn:ogc:def:crs:OGC:2:84"),new ei("http://www.opengis.net/def/crs/OGC/1.3/CRS84"),new ei("http://www.opengis.net/gml/srs/epsg.xml#4326","neu"),new ei("http://www.opengis.net/def/crs/EPSG/0/4326","neu")];var Sa={};function pu(n){return Sa[n]||Sa[n.replace(/urn:(x-)?ogc:def:crs:EPSG:(.*:)?(\w+)$/,"EPSG:$3")]||null}function mu(n,t){Sa[n]=t}var Mn={};function Pn(n,t,e){let i=n.getCode(),r=t.getCode();i in Mn||(Mn[i]={}),Mn[i][r]=e}function bo(n,t){return n in Mn&&t in Mn[n]?Mn[n][t]:null}var So=.9996,he=.00669438,To=he*he,Io=To*he,$i=he/(1-he),_u=Math.sqrt(1-he),kn=(1-_u)/(1+_u),Eu=kn*kn,Ra=Eu*kn,Ta=Ra*kn,vu=Ta*kn,Cu=1-he/4-3*To/64-5*Io/256,gp=3*he/8+3*To/32+45*Io/1024,pp=15*To/256+45*Io/1024,mp=35*Io/3072,_p=3/2*kn-27/32*Ra+269/512*vu,xp=21/16*Eu-55/32*Ta,yp=151/96*Ra-417/128*vu,wp=1097/512*Ta,Ro=6378137;function Ep(n,t,e){let i=n-5e5,s=(e.north?t:t-1e7)/So/(Ro*Cu),a=s+_p*Math.sin(2*s)+xp*Math.sin(4*s)+yp*Math.sin(6*s)+wp*Math.sin(8*s),l=Math.sin(a),h=l*l,c=Math.cos(a),u=l/c,f=u*u,g=f*f,p=1-he*h,_=Math.sqrt(1-he*h),m=Ro/_,x=(1-he)/p,w=$i*c**2,v=w*w,y=i/(m*So),E=y*y,R=E*y,A=R*y,S=A*y,T=S*y,I=a-u/x*(E/2-A/24*(5+3*f+10*w-4*v-9*$i))+T/720*(61+90*f+298*w+45*g-252*$i-3*v),z=(y-R/6*(1+2*f+w)+S/120*(5-2*w+28*f-3*v+8*$i+24*g))/c;return z=go(z+me(bu(e.number)),-Math.PI,Math.PI),[fo(z),fo(I)]}var xu=-80,yu=84,vp=-180,Cp=180;function bp(n,t,e){n=go(n,vp,Cp),t<xu?t=xu:t>yu&&(t=yu);let i=me(t),r=Math.sin(i),o=Math.cos(i),s=r/o,a=s*s,l=a*a,h=me(n),c=bu(e.number),u=me(c),f=Ro/Math.sqrt(1-he*r**2),g=$i*o**2,p=o*go(h-u,-Math.PI,Math.PI),_=p*p,m=_*p,x=m*p,w=x*p,v=w*p,y=Ro*(Cu*i-gp*Math.sin(2*i)+pp*Math.sin(4*i)-mp*Math.sin(6*i)),E=So*f*(p+m/6*(1-a+g)+w/120*(5-18*a+l+72*g-58*$i))+5e5,R=So*(y+f*s*(_/2+x/24*(5-a+9*g+4*g**2)+v/720*(61-58*a+l+600*g-330*$i)));return e.north||(R+=1e7),[E,R]}function bu(n){return(n-1)*6-180+3}var Sp=[/^EPSG:(\d+)$/,/^urn:ogc:def:crs:EPSG::(\d+)$/,/^http:\/\/www\.opengis\.net\/def\/crs\/EPSG\/0\/(\d+)$/];function Su(n){let t=0;for(let r of Sp){let o=n.match(r);if(o){t=parseInt(o[1]);break}}if(!t)return null;let e=0,i=!1;return t>32700&&t<32761?e=t-32700:t>32600&&t<32661&&(i=!0,e=t-32600),e?{number:e,north:i}:null}function wu(n,t){return function(e,i,r,o){let s=e.length;r=r>1?r:2,o=o??r,i||(r>2?i=e.slice():i=new Array(s));for(let a=0;a<s;a+=o){let l=e[a],h=e[a+1],c=n(l,h,t);i[a]=c[0],i[a+1]=c[1]}return i}}function Ru(n){return Su(n)?new Ei({code:n,units:"m"}):null}function Tu(n){let t=Su(n.getCode());return t?{forward:wu(bp,t),inverse:wu(Ep,t)}:null}var Rp=[Tu],Tp=[Ru];var La=!0;function Lu(n){La=!(n===void 0?!0:n)}function Ma(n,t){if(t!==void 0){for(let e=0,i=n.length;e<i;++e)t[e]=n[e];t=t}else t=n.slice();return t}function Aa(n){mu(n.getCode(),n),Pn(n,n,Ma)}function Ip(n){n.forEach(Aa)}function Et(n){if(typeof n!="string")return n;let t=pu(n);if(t)return t;for(let e of Tp){let i=e(n);if(i)return i}return null}function Pa(n,t,e,i){n=Et(n);let r,o=n.getPointResolutionFunc();if(o){if(r=o(t,e),i&&i!==n.getUnits()){let s=n.getMetersPerUnit();s&&(r=r*s/ti[i])}}else{let s=n.getUnits();if(s=="degrees"&&!i||i=="degrees")r=t;else{let a=Ji(n,Et("EPSG:4326"));if(!a&&s!=="degrees")r=t*n.getMetersPerUnit();else{let h=[e[0]-t/2,e[1],e[0]+t/2,e[1],e[0],e[1]-t/2,e[0],e[1]+t/2];h=a(h,h,2);let c=Ea(h.slice(0,2),h.slice(2,4)),u=Ea(h.slice(4,6),h.slice(6,8));r=(c+u)/2}let l=i?ti[i]:n.getMetersPerUnit();l!==void 0&&(r/=l)}}return r}function Iu(n){Ip(n),n.forEach(function(t){n.forEach(function(e){t!==e&&Pn(t,e,Ma)})})}function Lp(n,t,e,i){n.forEach(function(r){t.forEach(function(o){Pn(r,o,e),Pn(o,r,i)})})}function Lo(n,t){return n?typeof n=="string"?Et(n):n:Et(t)}function Au(n){return(function(t,e,i,r){let o=t.length;i=i!==void 0?i:2,r=r??i,e=e!==void 0?e:new Array(o);for(let s=0;s<o;s+=r){let a=n(t.slice(s,s+i)),l=a.length;for(let h=0,c=r;h<c;++h)e[s+h]=h>=l?t[s+h]:a[h]}return e})}function On(n,t){if(n===t)return!0;let e=n.getUnits()===t.getUnits();return(n.getCode()===t.getCode()||Ji(n,t)===Ma)&&e}function Ji(n,t){let e=n.getCode(),i=t.getCode(),r=bo(e,i);if(r)return r;let o=null,s=null;for(let l of Rp)o||(o=l(n)),s||(s=l(t));if(!o&&!s)return null;let a="EPSG:4326";if(s)if(o)r=Ia(o.inverse,s.forward);else{let l=bo(e,a);l&&(r=Ia(l,s.forward))}else{let l=bo(a,i);l&&(r=Ia(o.inverse,l))}return r&&(Aa(n),Aa(t),Pn(n,t,r)),r}function Ia(n,t){return function(e,i,r,o){return i=n(e,i,r,o),t(i,i,r,o)}}function Qi(n,t){let e=Et(n),i=Et(t);return Ji(e,i)}function Dn(n,t,e){let i=Qi(t,e);if(!i){let r=Et(t).getCode(),o=Et(e).getCode();throw new Error(`No transform available between ${r} and ${o}`)}return i(n,void 0,n.length)}function Mu(n,t,e,i){let r=Qi(t,e);return nu(n,r,void 0,i)}var xe=null;function tn(){return xe}function Er(n,t){return xe?Dn(n,t,xe):n}function ye(n,t){return xe?Dn(n,xe,t):(La&&!qi(n,[0,0])&&n[0]>=-180&&n[0]<=180&&n[1]>=-90&&n[1]<=90&&(La=!1,vo("Call useGeographic() from ol/proj once to work with [longitude, latitude] coordinates.")),n)}function Ci(n,t){return xe?Mu(n,t,xe):n}function we(n,t){return xe?Mu(n,xe,t):n}function Pu(n,t){if(!xe)return n;let e=Et(t).getMetersPerUnit(),i=xe.getMetersPerUnit();return e&&i?n*e/i:n}function Ap(){Iu(Ca),Iu(ba),Lp(ba,Ca,du,fu)}Ap();var Mp=[1,0,0,1,0,0],Vy=new Array(6);function Mt(){return Mp.slice(0)}function ku(n,t){return n[0]=t[0],n[1]=t[1],n[2]=t[2],n[3]=t[3],n[4]=t[4],n[5]=t[5],n}function dt(n,t){let e=t[0],i=t[1];return t[0]=n[0]*e+n[2]*i+n[4],t[1]=n[1]*e+n[3]*i+n[5],t}function Dt(n,t,e,i,r,o,s,a){let l=Math.sin(o),h=Math.cos(o);return n[0]=i*h,n[1]=r*l,n[2]=-i*l,n[3]=r*h,n[4]=s*i*h-a*i*l+t,n[5]=s*r*l+a*r*h+e,n}function Mo(n,t){let e=Pp(t);V(e!==0,"Transformation matrix cannot be inverted");let i=t[0],r=t[1],o=t[2],s=t[3],a=t[4],l=t[5];return n[0]=s/e,n[1]=-r/e,n[2]=-o/e,n[3]=i/e,n[4]=(o*l-s*a)/e,n[5]=-(i*l-r*a)/e,n}function Pp(n){return n[0]*n[3]-n[1]*n[2]}var kp=[1e5,1e5,1e5,1e5,2,2];function Ou(n){return"matrix("+n.join(", ")+")"}function Ao(n){return n.substring(7,n.length-1).split(",").map(parseFloat)}function Du(n,t){let e=Ao(n),i=Ao(t);for(let r=0;r<6;++r)if(Math.round((e[r]-i[r])*kp[r])!==0)return!1;return!0}function jt(n,t,e,i,r,o,s){o=o||[],s=s||2;let a=0;for(let l=t;l<e;l+=i){let h=n[l],c=n[l+1];o[a++]=r[0]*h+r[2]*c+r[4],o[a++]=r[1]*h+r[3]*c+r[5];for(let u=2;u<s;u++)o[a++]=n[l+u]}return o&&o.length!=a&&(o.length=a),o}function Po(n,t,e,i,r,o,s){s=s||[];let a=Math.cos(r),l=Math.sin(r),h=o[0],c=o[1],u=0;for(let f=t;f<e;f+=i){let g=n[f]-h,p=n[f+1]-c;s[u++]=h+g*a-p*l,s[u++]=c+g*l+p*a;for(let _=f+2;_<f+i;++_)s[u++]=n[_]}return s&&s.length!=u&&(s.length=u),s}function Fu(n,t,e,i,r,o,s,a){a=a||[];let l=s[0],h=s[1],c=0;for(let u=t;u<e;u+=i){let f=n[u]-l,g=n[u+1]-h;a[c++]=l+r*f,a[c++]=h+o*g;for(let p=u+2;p<u+i;++p)a[c++]=n[p]}return a&&a.length!=c&&(a.length=c),a}function zu(n,t,e,i,r,o,s){s=s||[];let a=0;for(let l=t;l<e;l+=i){s[a++]=n[l]+r,s[a++]=n[l+1]+o;for(let h=l+2;h<l+i;++h)s[a++]=n[h]}return s&&s.length!=a&&(s.length=a),s}var Nu=Mt(),Op=[NaN,NaN],ka=class extends yt{constructor(){super(),this.extent_=ut(),this.extentRevision_=-1,this.simplifiedGeometryMaxMinSquaredTolerance=0,this.simplifiedGeometryRevision=0,this.simplifyTransformedInternal=lo((t,e,i)=>{if(!i)return this.getSimplifiedGeometry(e);let r=this.clone();return r.applyTransform(i),r.getSimplifiedGeometry(e)})}simplifyTransformed(t,e){return this.simplifyTransformedInternal(this.getRevision(),t,e)}clone(){return H()}closestPointXY(t,e,i,r){return H()}containsXY(t,e){return this.closestPointXY(t,e,Op,Number.MIN_VALUE)===0}getClosestPoint(t,e){return e=e||[NaN,NaN],this.closestPointXY(t[0],t[1],e,1/0),e}intersectsCoordinate(t){return this.containsXY(t[0],t[1])}computeExtent(t){return H()}getExtent(t){if(this.extentRevision_!=this.getRevision()){let e=this.computeExtent(this.extent_);(isNaN(e[0])||isNaN(e[1]))&&Bi(e),this.extentRevision_=this.getRevision()}return eu(this.extent_,t)}rotate(t,e){H()}scale(t,e,i){H()}simplify(t){return this.getSimplifiedGeometry(t*t)}getSimplifiedGeometry(t){return H()}getType(){return H()}applyTransform(t){H()}intersectsExtent(t){return H()}translate(t,e){H()}transform(t,e){let i=Et(t),r=i.getUnits()=="tile-pixels"?function(o,s,a){let l=i.getExtent(),h=i.getWorldExtent(),c=ct(h)/ct(l);Dt(Nu,h[0],h[3],c,-c,0,0,0);let u=jt(o,0,o.length,a,Nu,s),f=Qi(i,e);return f?f(u,u,a):u}:Qi(i,e);return this.applyTransform(r),this}},Gu=ka;var Oa=class extends Gu{constructor(){super(),this.layout="XY",this.stride=2,this.flatCoordinates}computeExtent(t){return Sn(this.flatCoordinates,0,this.flatCoordinates.length,this.stride,t)}getCoordinates(){return H()}getFirstCoordinate(){return this.flatCoordinates.slice(0,this.stride)}getFlatCoordinates(){return this.flatCoordinates}getLastCoordinate(){return this.flatCoordinates.slice(this.flatCoordinates.length-this.stride)}getLayout(){return this.layout}getSimplifiedGeometry(t){if(this.simplifiedGeometryRevision!==this.getRevision()&&(this.simplifiedGeometryMaxMinSquaredTolerance=0,this.simplifiedGeometryRevision=this.getRevision()),t<0||this.simplifiedGeometryMaxMinSquaredTolerance!==0&&t<=this.simplifiedGeometryMaxMinSquaredTolerance)return this;let e=this.getSimplifiedGeometryInternal(t);return e.getFlatCoordinates().length<this.flatCoordinates.length?e:(this.simplifiedGeometryMaxMinSquaredTolerance=t,this)}getSimplifiedGeometryInternal(t){return this}getStride(){return this.stride}setFlatCoordinates(t,e){this.stride=Xu(t),this.layout=t,this.flatCoordinates=e}setCoordinates(t,e){H()}setLayout(t,e,i){let r;if(t)r=Xu(t);else{for(let o=0;o<i;++o){if(e.length===0){this.layout="XY",this.stride=2;return}e=e[0]}r=e.length,t=Dp(r)}this.layout=t,this.stride=r}applyTransform(t){this.flatCoordinates&&(t(this.flatCoordinates,this.flatCoordinates,this.layout.startsWith("XYZ")?3:2,this.stride),this.changed())}rotate(t,e){let i=this.getFlatCoordinates();if(i){let r=this.getStride();Po(i,0,i.length,r,t,e,i),this.changed()}}scale(t,e,i){e===void 0&&(e=t),i||(i=Bt(this.getExtent()));let r=this.getFlatCoordinates();if(r){let o=this.getStride();Fu(r,0,r.length,o,t,e,i,r),this.changed()}}translate(t,e){let i=this.getFlatCoordinates();if(i){let r=this.getStride();zu(i,0,i.length,r,t,e,i),this.changed()}}};function Dp(n){let t;return n==2?t="XY":n==3?t="XYZ":n==4&&(t="XYZM"),t}function Xu(n){let t;return n=="XY"?t=2:n=="XYZ"||n=="XYM"?t=3:n=="XYZM"&&(t=4),t}function Wu(n,t,e){let i=n.getFlatCoordinates();if(!i)return null;let r=n.getStride();return jt(i,0,i.length,r,t,e)}var Fe=Oa;function Da(n,t,e,i){let r=0,o=n[e-i],s=n[e-i+1],a=0,l=0;for(;t<e;t+=i){let h=n[t]-o,c=n[t+1]-s;r+=l*h-a*c,a=h,l=c}return r/2}function Fa(n,t,e,i){let r=0;for(let o=0,s=e.length;o<s;++o){let a=e[o];r+=Da(n,t,a,i),t=a}return r}function Yu(n,t,e,i){let r=0;for(let o=0,s=e.length;o<s;++o){let a=e[o];r+=Fa(n,t,a,i),t=a[a.length-1]}return r}function Uu(n,t,e,i,r,o,s){let a=n[t],l=n[t+1],h=n[e]-a,c=n[e+1]-l,u;if(h===0&&c===0)u=t;else{let f=((r-a)*h+(o-l)*c)/(h*h+c*c);if(f>1)u=e;else if(f>0){for(let g=0;g<i;++g)s[g]=Gt(n[t+g],n[e+g],f);s.length=i;return}else u=t}for(let f=0;f<i;++f)s[f]=n[u+f];s.length=i}function za(n,t,e,i,r){let o=n[t],s=n[t+1];for(t+=i;t<e;t+=i){let a=n[t],l=n[t+1],h=pe(o,s,a,l);h>r&&(r=h),o=a,s=l}return r}function Na(n,t,e,i,r){for(let o=0,s=e.length;o<s;++o){let a=e[o];r=za(n,t,a,i,r),t=a}return r}function Ku(n,t,e,i,r){for(let o=0,s=e.length;o<s;++o){let a=e[o];r=Na(n,t,a,i,r),t=a[a.length-1]}return r}function Ga(n,t,e,i,r,o,s,a,l,h,c){if(t==e)return h;let u,f;if(r===0){if(f=pe(s,a,n[t],n[t+1]),f<h){for(u=0;u<i;++u)l[u]=n[t+u];return l.length=i,f}return h}c=c||[NaN,NaN];let g=t+i;for(;g<e;)if(Uu(n,g-i,g,i,s,a,c),f=pe(s,a,c[0],c[1]),f<h){for(h=f,u=0;u<i;++u)l[u]=c[u];l.length=i,g+=i}else g+=i*Math.max((Math.sqrt(f)-Math.sqrt(h))/r|0,1);if(o&&(Uu(n,e-i,t,i,s,a,c),f=pe(s,a,c[0],c[1]),f<h)){for(h=f,u=0;u<i;++u)l[u]=c[u];l.length=i}return h}function Xa(n,t,e,i,r,o,s,a,l,h,c){c=c||[NaN,NaN];for(let u=0,f=e.length;u<f;++u){let g=e[u];h=Ga(n,t,g,i,r,o,s,a,l,h,c),t=g}return h}function Zu(n,t,e,i,r,o,s,a,l,h,c){c=c||[NaN,NaN];for(let u=0,f=e.length;u<f;++u){let g=e[u];h=Xa(n,t,g,i,r,o,s,a,l,h,c),t=g[g.length-1]}return h}function Vu(n,t,e,i){for(let r=0,o=e.length;r<o;++r)n[t++]=e[r];return t}function vr(n,t,e,i){for(let r=0,o=e.length;r<o;++r){let s=e[r];for(let a=0;a<i;++a)n[t++]=s[a]}return t}function Wa(n,t,e,i,r){r=r||[];let o=0;for(let s=0,a=e.length;s<a;++s){let l=vr(n,t,e[s],i);r[o++]=l,t=l}return r.length=o,r}function Bu(n,t,e,i,r){r=r||[];let o=0;for(let s=0,a=e.length;s<a;++s){let l=Wa(n,t,e[s],i,r[o]);l.length===0&&(l[0]=t),r[o++]=l,t=l[l.length-1]}return r.length=o,r}function ze(n,t,e,i,r){r=r!==void 0?r:[];let o=0;for(let s=t;s<e;s+=i)r[o++]=n.slice(s,s+i);return r.length=o,r}function Fn(n,t,e,i,r){r=r!==void 0?r:[];let o=0;for(let s=0,a=e.length;s<a;++s){let l=e[s];r[o++]=ze(n,t,l,i,r[o]),t=l}return r.length=o,r}function Cr(n,t,e,i,r){r=r!==void 0?r:[];let o=0;for(let s=0,a=e.length;s<a;++s){let l=e[s];r[o++]=l.length===1&&l[0]===t?[]:Fn(n,t,l,i,r[o]),t=l[l.length-1]}return r.length=o,r}function ju(n,t,e,i,r){return!yo(r,function(s){return!bi(n,t,e,i,s[0],s[1])})}function bi(n,t,e,i,r,o){let s=0,a=n[e-i],l=n[e-i+1];for(;t<e;t+=i){let h=n[t],c=n[t+1];l<=o?c>o&&(h-a)*(o-l)-(r-a)*(c-l)>0&&s++:c<=o&&(h-a)*(o-l)-(r-a)*(c-l)<0&&s--,a=h,l=c}return s!==0}function br(n,t,e,i,r,o){if(e.length===0||!bi(n,t,e[0],i,r,o))return!1;for(let s=1,a=e.length;s<a;++s)if(bi(n,e[s-1],e[s],i,r,o))return!1;return!0}function Hu(n,t,e,i,r,o){if(e.length===0)return!1;for(let s=0,a=e.length;s<a;++s){let l=e[s];if(br(n,t,l,i,r,o))return!0;t=l[l.length-1]}return!1}function qu(n,t,e,i,r){let o;for(t+=i;t<e;t+=i)if(o=r(n.slice(t-i,t),n.slice(t,t+i)),o)return o;return!1}function ko(n,t,e,i,r,o){return o=o??ma(ut(),n,t,e,i),ht(r,o)?o[0]>=r[0]&&o[2]<=r[2]||o[1]>=r[1]&&o[3]<=r[3]?!0:qu(n,t,e,i,function(s,a){return iu(r,s,a)}):!1}function Ya(n,t,e,i,r){return!!(ko(n,t,e,i,r)||bi(n,t,e,i,r[0],r[1])||bi(n,t,e,i,r[0],r[3])||bi(n,t,e,i,r[2],r[1])||bi(n,t,e,i,r[2],r[3]))}function Ua(n,t,e,i,r){if(!Ya(n,t,e[0],i,r))return!1;if(e.length===1)return!0;for(let o=1,s=e.length;o<s;++o)if(ju(n,e[o-1],e[o],i,r)&&!ko(n,e[o-1],e[o],i,r))return!1;return!0}function $u(n,t,e,i,r){for(let o=0,s=e.length;o<s;++o){let a=e[o];if(Ua(n,t,a,i,r))return!0;t=a[a.length-1]}return!1}function Sr(n,t,e,i,r,o,s){let a=(e-t)/i;if(a<3){for(;t<e;t+=i)o[s++]=n[t],o[s++]=n[t+1];return s}let l=new Array(a);l[0]=1,l[a-1]=1;let h=[t,e-i],c=0;for(;h.length>0;){let u=h.pop(),f=h.pop(),g=0,p=n[f],_=n[f+1],m=n[u],x=n[u+1];for(let w=f+i;w<u;w+=i){let v=n[w],y=n[w+1],E=$h(v,y,p,_,m,x);E>g&&(c=w,g=E)}g>r&&(l[(c-t)/i]=1,f+i<c&&h.push(f,c),c+i<u&&h.push(c,u))}for(let u=0;u<a;++u)l[u]&&(o[s++]=n[t+u*i],o[s++]=n[t+u*i+1]);return s}function Ju(n,t,e,i,r,o,s,a){for(let l=0,h=e.length;l<h;++l){let c=e[l];s=Sr(n,t,c,i,r,o,s),a.push(s),t=c}return s}function Si(n,t){return t*Math.round(n/t)}function Fp(n,t,e,i,r,o,s){if(t==e)return s;let a=Si(n[t],r),l=Si(n[t+1],r);t+=i,o[s++]=a,o[s++]=l;let h,c;do if(h=Si(n[t],r),c=Si(n[t+1],r),t+=i,t==e)return o[s++]=h,o[s++]=c,s;while(h==a&&c==l);for(;t<e;){let u=Si(n[t],r),f=Si(n[t+1],r);if(t+=i,u==h&&f==c)continue;let g=h-a,p=c-l,_=u-a,m=f-l;if(g*m==p*_&&(g<0&&_<g||g==_||g>0&&_>g)&&(p<0&&m<p||p==m||p>0&&m>p)){h=u,c=f;continue}o[s++]=h,o[s++]=c,a=h,l=c,h=u,c=f}return o[s++]=h,o[s++]=c,s}function Rr(n,t,e,i,r,o,s,a){for(let l=0,h=e.length;l<h;++l){let c=e[l];s=Fp(n,t,c,i,r,o,s),a.push(s),t=c}return s}function Qu(n,t,e,i,r,o,s,a){for(let l=0,h=e.length;l<h;++l){let c=e[l],u=[];s=Rr(n,t,c,i,r,o,s,u),a.push(u),t=c[c.length-1]}return s}var Ka=class n extends Fe{constructor(t,e){super(),this.maxDelta_=-1,this.maxDeltaRevision_=-1,e!==void 0&&!Array.isArray(t[0])?this.setFlatCoordinates(e,t):this.setCoordinates(t,e)}clone(){return new n(this.flatCoordinates.slice(),this.layout)}closestPointXY(t,e,i,r){return r<wi(this.getExtent(),t,e)?r:(this.maxDeltaRevision_!=this.getRevision()&&(this.maxDelta_=Math.sqrt(za(this.flatCoordinates,0,this.flatCoordinates.length,this.stride,0)),this.maxDeltaRevision_=this.getRevision()),Ga(this.flatCoordinates,0,this.flatCoordinates.length,this.stride,this.maxDelta_,!0,t,e,i,r))}getArea(){return Da(this.flatCoordinates,0,this.flatCoordinates.length,this.stride)}getCoordinates(){return ze(this.flatCoordinates,0,this.flatCoordinates.length,this.stride)}getSimplifiedGeometryInternal(t){let e=[];return e.length=Sr(this.flatCoordinates,0,this.flatCoordinates.length,this.stride,t,e,0),new n(e,"XY")}getType(){return"LinearRing"}intersectsExtent(t){return ko(this.flatCoordinates,0,this.flatCoordinates.length,this.stride,t)}setCoordinates(t,e){this.setLayout(e,t,1),this.flatCoordinates||(this.flatCoordinates=[]),this.flatCoordinates.length=vr(this.flatCoordinates,0,t,this.stride),this.changed()}},Za=Ka;var Va=class n extends Fe{constructor(t,e){super(),this.setCoordinates(t,e)}clone(){let t=new n(this.flatCoordinates.slice(),this.layout);return t.applyProperties(this),t}closestPointXY(t,e,i,r){let o=this.flatCoordinates,s=pe(t,e,o[0],o[1]);if(s<r){let a=this.stride;for(let l=0;l<a;++l)i[l]=o[l];return i.length=a,s}return r}getCoordinates(){return this.flatCoordinates.slice()}computeExtent(t){return _o(this.flatCoordinates,t)}getType(){return"Point"}intersectsExtent(t){return _r(t,this.flatCoordinates[0],this.flatCoordinates[1])}setCoordinates(t,e){this.setLayout(e,t,0),this.flatCoordinates||(this.flatCoordinates=[]),this.flatCoordinates.length=Vu(this.flatCoordinates,0,t,this.stride),this.changed()}},Ri=Va;function Tr(n,t,e,i,r,o,s){let a,l,h,c,u,f,g,p=r[o+1],_=[];for(let w=0,v=e.length;w<v;++w){let y=e[w];for(c=n[y-i],f=n[y-i+1],a=t;a<y;a+=i)u=n[a],g=n[a+1],(p<=f&&g<=p||f<=p&&p<=g)&&(h=(p-f)/(g-f)*(u-c)+c,_.push(h)),c=u,f=g}let m=NaN,x=-1/0;for(_.sort(Vt),c=_[0],a=1,l=_.length;a<l;++a){u=_[a];let w=Math.abs(u-c);w>x&&(h=(c+u)/2,br(n,t,e,i,h,p)&&(m=h,x=w)),c=u}return isNaN(m)&&(m=r[o]),s?(s.push(m,p,x),s):[m,p,x]}function Oo(n,t,e,i,r){let o=[];for(let s=0,a=e.length;s<a;++s){let l=e[s];o=Tr(n,t,l,i,r,2*s,o),t=l[l.length-1]}return o}function td(n,t,e,i){for(;t<e-i;){for(let r=0;r<i;++r){let o=n[t+r];n[t+r]=n[e-i+r],n[e-i+r]=o}t+=i,e-=i}}function Ba(n,t,e,i){let r=0,o=n[e-i],s=n[e-i+1];for(;t<e;t+=i){let a=n[t],l=n[t+1];r+=(a-o)*(l+s),o=a,s=l}return r===0?void 0:r>0}function ja(n,t,e,i,r){r=r!==void 0?r:!1;for(let o=0,s=e.length;o<s;++o){let a=e[o],l=Ba(n,t,a,i);if(o===0){if(r&&l||!r&&!l)return!1}else if(r&&!l||!r&&l)return!1;t=a}return!0}function ed(n,t,e,i,r){for(let o=0,s=e.length;o<s;++o){let a=e[o];if(!ja(n,t,a,i,r))return!1;a.length&&(t=a[a.length-1])}return!0}function Do(n,t,e,i,r){r=r!==void 0?r:!1;for(let o=0,s=e.length;o<s;++o){let a=e[o],l=Ba(n,t,a,i);(o===0?r&&l||!r&&!l:r&&!l||!r&&l)&&td(n,t,a,i),t=a}return t}function Ha(n,t,e,i,r){for(let o=0,s=e.length;o<s;++o)t=Do(n,t,e[o],i,r);return t}function id(n,t){let e=[],i=0,r=0,o;for(let s=0,a=t.length;s<a;++s){let l=t[s],h=Ba(n,i,l,2);if(o===void 0&&(o=h),h===o)e.push(t.slice(r,s+1));else{if(e.length===0)continue;e[e.length-1].push(t[r])}r=s+1,i=l}return e}var Fo=class n extends Fe{constructor(t,e,i){super(),this.ends_=[],this.flatInteriorPointRevision_=-1,this.flatInteriorPoint_=null,this.maxDelta_=-1,this.maxDeltaRevision_=-1,this.orientedRevision_=-1,this.orientedFlatCoordinates_=null,e!==void 0&&i?(this.setFlatCoordinates(e,t),this.ends_=i):this.setCoordinates(t,e)}appendLinearRing(t){this.flatCoordinates?ge(this.flatCoordinates,t.getFlatCoordinates()):this.flatCoordinates=t.getFlatCoordinates().slice(),this.ends_.push(this.flatCoordinates.length),this.changed()}clone(){let t=new n(this.flatCoordinates.slice(),this.layout,this.ends_.slice());return t.applyProperties(this),t}closestPointXY(t,e,i,r){return r<wi(this.getExtent(),t,e)?r:(this.maxDeltaRevision_!=this.getRevision()&&(this.maxDelta_=Math.sqrt(Na(this.flatCoordinates,0,this.ends_,this.stride,0)),this.maxDeltaRevision_=this.getRevision()),Xa(this.flatCoordinates,0,this.ends_,this.stride,this.maxDelta_,!0,t,e,i,r))}containsXY(t,e){return br(this.getOrientedFlatCoordinates(),0,this.ends_,this.stride,t,e)}getArea(){return Fa(this.getOrientedFlatCoordinates(),0,this.ends_,this.stride)}getCoordinates(t){let e;return t!==void 0?(e=this.getOrientedFlatCoordinates().slice(),Do(e,0,this.ends_,this.stride,t)):e=this.flatCoordinates,Fn(e,0,this.ends_,this.stride)}getEnds(){return this.ends_}getFlatInteriorPoint(){if(this.flatInteriorPointRevision_!=this.getRevision()){let t=Bt(this.getExtent());this.flatInteriorPoint_=Tr(this.getOrientedFlatCoordinates(),0,this.ends_,this.stride,t,0),this.flatInteriorPointRevision_=this.getRevision()}return this.flatInteriorPoint_}getInteriorPoint(){return new Ri(this.getFlatInteriorPoint(),"XYM")}getLinearRingCount(){return this.ends_.length}getLinearRing(t){return t<0||this.ends_.length<=t?null:new Za(this.flatCoordinates.slice(t===0?0:this.ends_[t-1],this.ends_[t]),this.layout)}getLinearRings(){let t=this.layout,e=this.flatCoordinates,i=this.ends_,r=[],o=0;for(let s=0,a=i.length;s<a;++s){let l=i[s],h=new Za(e.slice(o,l),t);r.push(h),o=l}return r}getOrientedFlatCoordinates(){if(this.orientedRevision_!=this.getRevision()){let t=this.flatCoordinates;ja(t,0,this.ends_,this.stride)?this.orientedFlatCoordinates_=t:(this.orientedFlatCoordinates_=t.slice(),this.orientedFlatCoordinates_.length=Do(this.orientedFlatCoordinates_,0,this.ends_,this.stride)),this.orientedRevision_=this.getRevision()}return this.orientedFlatCoordinates_}getSimplifiedGeometryInternal(t){let e=[],i=[];return e.length=Rr(this.flatCoordinates,0,this.ends_,this.stride,Math.sqrt(t),e,0,i),new n(e,"XY",i)}getType(){return"Polygon"}intersectsExtent(t){return Ua(this.getOrientedFlatCoordinates(),0,this.ends_,this.stride,t)}setCoordinates(t,e){this.setLayout(e,t,2),this.flatCoordinates||(this.flatCoordinates=[]);let i=Wa(this.flatCoordinates,0,t,this.stride,this.ends_);this.flatCoordinates.length=i.length===0?0:i[i.length-1],this.changed()}},ii=Fo;function qa(n){if(De(n))throw new Error("Cannot create polygon from empty extent");let t=n[0],e=n[1],i=n[2],r=n[3],o=[t,e,t,r,i,r,i,e,t,e];return new Fo(o,"XY",[o.length])}function $a(n,t,e,i){let r=j(t)/e[0],o=ct(t)/e[1];return i?Math.min(n,Math.max(r,o)):Math.min(n,Math.min(r,o))}function Ja(n,t,e){let i=Math.min(n,t),r=50;return i*=Math.log(1+r*Math.max(0,n/t-1))/r+1,e&&(i=Math.max(i,e),i/=Math.log(1+r*Math.max(0,e/n-1))/r+1),et(i,e/2,t*2)}function nd(n,t,e,i){return t=t!==void 0?t:!0,(function(r,o,s,a){if(r!==void 0){let l=n[0],h=n[n.length-1],c=e?$a(l,e,s,i):l;if(a)return t?Ja(r,c,h):et(r,h,c);let u=Math.min(c,r),f=Math.floor(wn(n,u,o));return n[f]>c&&f<n.length-1?n[f+1]:n[f]}})}function rd(n,t,e,i,r,o){return i=i!==void 0?i:!0,e=e!==void 0?e:0,(function(s,a,l,h){if(s!==void 0){let c=r?$a(t,r,l,o):t;if(h)return i?Ja(s,c,e):et(s,e,c);let u=1e-9,f=Math.ceil(Math.log(t/c)/Math.log(n)-u),g=-a*(.5-u)+.5,p=Math.min(c,s),_=Math.floor(Math.log(t/p)/Math.log(n)+g),m=Math.max(f,_),x=t/Math.pow(n,m);return et(x,e,c)}})}function Qa(n,t,e,i,r){return e=e!==void 0?e:!0,(function(o,s,a,l){if(o!==void 0){let h=i?$a(n,i,a,r):n;return!e||!l?et(o,t,h):Ja(o,h,t)}})}function zn(n){if(n!==void 0)return 0}function tl(n){if(n!==void 0)return n}function od(n){let t=2*Math.PI/n;return(function(e,i){if(i)return e;if(e!==void 0)return e=Math.floor(e/t+.5)*t,e})}function sd(n){let t=n===void 0?me(5):n;return(function(e,i){return i||e===void 0?e:Math.abs(e)<=t?0:e})}var el=0,nl=class extends yt{constructor(t){super(),this.on,this.once,this.un,t=Object.assign({},t),this.hints_=[0,0],this.animations_=[],this.updateAnimationKey_,this.projection_=Lo(t.projection,"EPSG:3857"),this.viewportSize_=[100,100],this.targetCenter_=null,this.targetResolution_,this.targetRotation_,this.nextCenter_=null,this.nextResolution_,this.nextRotation_,this.cancelAnchor_=void 0,t.projection&&Lu(),t.center&&(t.center=ye(t.center,this.projection_)),t.extent&&(t.extent=we(t.extent,this.projection_)),this.applyOptions_(t)}applyOptions_(t){let e=Object.assign({},t);for(let a in ae)delete e[a];this.setProperties(e,!0);let i=Np(t);this.maxResolution_=i.maxResolution,this.minResolution_=i.minResolution,this.zoomFactor_=i.zoomFactor,this.resolutions_=t.resolutions,this.padding_=t.padding,this.minZoom_=i.minZoom;let r=zp(t),o=i.constraint,s=Gp(t);this.constraints_={center:r,resolution:o,rotation:s},this.setRotation(t.rotation!==void 0?t.rotation:0),this.setCenterInternal(t.center!==void 0?t.center:null),t.resolution!==void 0?this.setResolution(t.resolution):t.zoom!==void 0&&this.setZoom(t.zoom)}get padding(){return this.padding_}set padding(t){let e=this.padding_;this.padding_=t;let i=this.getCenterInternal();if(i){let r=t||[0,0,0,0];e=e||[0,0,0,0];let o=this.getResolution(),s=o/2*(r[3]-e[3]+e[1]-r[1]),a=o/2*(r[0]-e[0]+e[2]-r[2]);this.setCenterInternal([i[0]+s,i[1]-a])}}getUpdatedOptions_(t){let e=this.getProperties();return e.resolution!==void 0?e.resolution=this.getResolution():e.zoom=this.getZoom(),e.center=this.getCenterInternal(),e.rotation=this.getRotation(),Object.assign({},e,t)}animate(t){this.isDef()&&!this.getAnimating()&&this.resolveConstraints(0);let e=new Array(arguments.length);for(let i=0;i<e.length;++i){let r=arguments[i];r.center&&(r=Object.assign({},r),r.center=ye(r.center,this.getProjection())),r.anchor&&(r=Object.assign({},r),r.anchor=ye(r.anchor,this.getProjection())),e[i]=r}this.animateInternal.apply(this,e)}animateInternal(t){let e=arguments.length,i;e>1&&typeof arguments[e-1]=="function"&&(i=arguments[e-1],--e);let r=0;for(;r<e&&!this.isDef();++r){let c=arguments[r];c.center&&this.setCenterInternal(c.center),c.zoom!==void 0?this.setZoom(c.zoom):c.resolution&&this.setResolution(c.resolution),c.rotation!==void 0&&this.setRotation(c.rotation)}if(r===e){i&&zo(i,!0);return}let o=Date.now(),s=this.targetCenter_.slice(),a=this.targetResolution_,l=this.targetRotation_,h=[];for(;r<e;++r){let c=arguments[r],u={start:o,complete:!1,anchor:c.anchor,duration:c.duration!==void 0?c.duration:1e3,easing:c.easing||cu,callback:i};if(c.center&&(u.sourceCenter=s,u.targetCenter=c.center.slice(),s=u.targetCenter),c.zoom!==void 0?(u.sourceResolution=a,u.targetResolution=this.getResolutionForZoom(c.zoom),a=u.targetResolution):c.resolution&&(u.sourceResolution=a,u.targetResolution=c.resolution,a=u.targetResolution),c.rotation!==void 0){u.sourceRotation=l;let f=Pe(c.rotation-l+Math.PI,2*Math.PI)-Math.PI;u.targetRotation=l+f,l=u.targetRotation}Xp(u)?u.complete=!0:o+=u.duration,h.push(u)}this.animations_.push(h),this.setHint(Rt.ANIMATING,1),this.updateAnimations_()}getAnimating(){return this.hints_[Rt.ANIMATING]>0}getInteracting(){return this.hints_[Rt.INTERACTING]>0}cancelAnimations(){this.setHint(Rt.ANIMATING,-this.hints_[Rt.ANIMATING]);let t;for(let e=0,i=this.animations_.length;e<i;++e){let r=this.animations_[e];if(r[0].callback&&zo(r[0].callback,!1),!t)for(let o=0,s=r.length;o<s;++o){let a=r[o];if(!a.complete){t=a.anchor;break}}}this.animations_.length=0,this.cancelAnchor_=t,this.nextCenter_=null,this.nextResolution_=NaN,this.nextRotation_=NaN}updateAnimations_(){if(this.updateAnimationKey_!==void 0&&(cancelAnimationFrame(this.updateAnimationKey_),this.updateAnimationKey_=void 0),!this.getAnimating())return;let t=Date.now(),e=!1;for(let i=this.animations_.length-1;i>=0;--i){let r=this.animations_[i],o=!0;for(let s=0,a=r.length;s<a;++s){let l=r[s];if(l.complete)continue;let h=t-l.start,c=l.duration>0?h/l.duration:1;c>=1?(l.complete=!0,c=1):o=!1;let u=l.easing(c);if(l.sourceCenter){let f=l.sourceCenter[0],g=l.sourceCenter[1],p=l.targetCenter[0],_=l.targetCenter[1];this.nextCenter_=l.targetCenter;let m=f+u*(p-f),x=g+u*(_-g);this.targetCenter_=[m,x]}if(l.sourceResolution&&l.targetResolution){let f=u===1?l.targetResolution:l.sourceResolution+u*(l.targetResolution-l.sourceResolution);if(l.anchor){let g=this.getViewportSize_(this.getRotation()),p=this.constraints_.resolution(f,0,g,!0);this.targetCenter_=this.calculateCenterZoom(p,l.anchor)}this.nextResolution_=l.targetResolution,this.targetResolution_=f,this.applyTargetState_(!0)}if(l.sourceRotation!==void 0&&l.targetRotation!==void 0){let f=u===1?Pe(l.targetRotation+Math.PI,2*Math.PI)-Math.PI:l.sourceRotation+u*(l.targetRotation-l.sourceRotation);if(l.anchor){let g=this.constraints_.rotation(f,!0);this.targetCenter_=this.calculateCenterRotate(g,l.anchor)}this.nextRotation_=l.targetRotation,this.targetRotation_=f}if(this.applyTargetState_(!0),e=!0,!l.complete)break}if(o){this.animations_[i]=null,this.setHint(Rt.ANIMATING,-1),this.nextCenter_=null,this.nextResolution_=NaN,this.nextRotation_=NaN;let s=r[0].callback;s&&zo(s,!0)}}this.animations_=this.animations_.filter(Boolean),e&&this.updateAnimationKey_===void 0&&(this.updateAnimationKey_=requestAnimationFrame(this.updateAnimations_.bind(this)))}calculateCenterRotate(t,e){let i,r=this.getCenterInternal();return r!==void 0&&(i=[r[0]-e[0],r[1]-e[1]],Ln(i,t-this.getRotation()),ou(i,e)),i}calculateCenterZoom(t,e){let i,r=this.getCenterInternal(),o=this.getResolution();if(r!==void 0&&o!==void 0){let s=e[0]-t*(e[0]-r[0])/o,a=e[1]-t*(e[1]-r[1])/o;i=[s,a]}return i}getViewportSize_(t){let e=this.viewportSize_;if(t){let i=e[0],r=e[1];return[Math.abs(i*Math.cos(t))+Math.abs(r*Math.sin(t)),Math.abs(i*Math.sin(t))+Math.abs(r*Math.cos(t))]}return e}setViewportSize(t){this.viewportSize_=Array.isArray(t)?t.slice():[100,100],this.getAnimating()||this.resolveConstraints(0)}getCenter(){let t=this.getCenterInternal();return t&&Er(t,this.getProjection())}getCenterInternal(){return this.get(ae.CENTER)}getConstraints(){return this.constraints_}getConstrainResolution(){return this.get("constrainResolution")}getHints(t){return t!==void 0?(t[0]=this.hints_[0],t[1]=this.hints_[1],t):this.hints_.slice()}calculateExtent(t){let e=this.calculateExtentInternal(t);return Ci(e,this.getProjection())}calculateExtentInternal(t){t=t||this.getViewportSizeMinusPadding_();let e=this.getCenterInternal();V(e,"The view center is not defined");let i=this.getResolution();V(i!==void 0,"The view resolution is not defined");let r=this.getRotation();return V(r!==void 0,"The view rotation is not defined"),yr(e,i,r,t)}getMaxResolution(){return this.maxResolution_}getMinResolution(){return this.minResolution_}getMaxZoom(){return this.getZoomForResolution(this.minResolution_)}setMaxZoom(t){this.applyOptions_(this.getUpdatedOptions_({maxZoom:t}))}getMinZoom(){return this.getZoomForResolution(this.maxResolution_)}setMinZoom(t){this.applyOptions_(this.getUpdatedOptions_({minZoom:t}))}setConstrainResolution(t){this.applyOptions_(this.getUpdatedOptions_({constrainResolution:t}))}getProjection(){return this.projection_}getResolution(){return this.get(ae.RESOLUTION)}getResolutions(){return this.resolutions_}getResolutionForExtent(t,e){return this.getResolutionForExtentInternal(we(t,this.getProjection()),e)}getResolutionForExtentInternal(t,e){e=e||this.getViewportSizeMinusPadding_();let i=j(t)/e[0],r=ct(t)/e[1];return Math.max(i,r)}getResolutionForValueFunction(t){t=t||2;let e=this.getConstrainedResolution(this.maxResolution_),i=this.minResolution_,r=Math.log(e/i)/Math.log(t);return(function(o){return e/Math.pow(t,o*r)})}getRotation(){return this.get(ae.ROTATION)}getValueForResolutionFunction(t){let e=Math.log(t||2),i=this.getConstrainedResolution(this.maxResolution_),r=this.minResolution_,o=Math.log(i/r)/e;return(function(s){return Math.log(i/s)/e/o})}getViewportSizeMinusPadding_(t){let e=this.getViewportSize_(t),i=this.padding_;return i&&(e=[e[0]-i[1]-i[3],e[1]-i[0]-i[2]]),e}getState(){let t=this.getProjection(),e=this.getResolution(),i=this.getRotation(),r=this.getCenterInternal(),o=this.padding_;if(o){let s=this.getViewportSizeMinusPadding_();r=il(r,this.getViewportSize_(),[s[0]/2+o[3],s[1]/2+o[0]],e,i)}return{center:r.slice(0),projection:t!==void 0?t:null,resolution:e,nextCenter:this.nextCenter_,nextResolution:this.nextResolution_,nextRotation:this.nextRotation_,rotation:i,zoom:this.getZoom()}}getViewStateAndExtent(){return{viewState:this.getState(),extent:this.calculateExtent()}}getZoom(){let t,e=this.getResolution();return e!==void 0&&(t=this.getZoomForResolution(e)),t}getZoomForResolution(t){let e=this.minZoom_||0,i,r;if(this.resolutions_){let o=wn(this.resolutions_,t,1);e=o,i=this.resolutions_[o],o==this.resolutions_.length-1?r=2:r=i/this.resolutions_[o+1]}else i=this.maxResolution_,r=this.zoomFactor_;return e+Math.log(i/t)/Math.log(r)}getResolutionForZoom(t){if(this.resolutions_?.length){if(this.resolutions_.length===1)return this.resolutions_[0];let e=et(Math.floor(t),0,this.resolutions_.length-2),i=this.resolutions_[e]/this.resolutions_[e+1];return this.resolutions_[e]/Math.pow(i,et(t-e,0,1))}return this.maxResolution_/Math.pow(this.zoomFactor_,t-this.minZoom_)}fit(t,e){let i;if(V(Array.isArray(t)||typeof t.getSimplifiedGeometry=="function","Invalid extent or geometry provided as `geometry`"),Array.isArray(t)){V(!De(t),"Cannot fit empty extent provided as `geometry`");let r=we(t,this.getProjection());i=qa(r)}else if(t.getType()==="Circle"){let r=we(t.getExtent(),this.getProjection());i=qa(r),i.rotate(this.getRotation(),Bt(r))}else{let r=tn();r?i=t.clone().transform(r,this.getProjection()):i=t}this.fitInternal(i,e)}rotatedExtentForGeometry(t){let e=this.getRotation(),i=Math.cos(e),r=Math.sin(-e),o=t.getFlatCoordinates(),s=t.getStride(),a=1/0,l=1/0,h=-1/0,c=-1/0;for(let u=0,f=o.length;u<f;u+=s){let g=o[u]*i-o[u+1]*r,p=o[u]*r+o[u+1]*i;a=Math.min(a,g),l=Math.min(l,p),h=Math.max(h,g),c=Math.max(c,p)}return[a,l,h,c]}fitInternal(t,e){e=e||{};let i=e.size;i||(i=this.getViewportSizeMinusPadding_());let r=e.padding!==void 0?e.padding:[0,0,0,0],o=e.nearest!==void 0?e.nearest:!1,s;e.minResolution!==void 0?s=e.minResolution:e.maxZoom!==void 0?s=this.getResolutionForZoom(e.maxZoom):s=0;let a=this.rotatedExtentForGeometry(t),l=this.getResolutionForExtentInternal(a,[i[0]-r[1]-r[3],i[1]-r[0]-r[2]]);l=isNaN(l)?s:Math.max(l,s),l=this.getConstrainedResolution(l,o?0:1);let h=this.getRotation(),c=Math.sin(h),u=Math.cos(h),f=Bt(a);f[0]+=(r[1]-r[3])/2*l,f[1]+=(r[0]-r[2])/2*l;let g=f[0]*u-f[1]*c,p=f[1]*u+f[0]*c,_=this.getConstrainedCenter([g,p],l),m=e.callback?e.callback:Qe;e.duration!==void 0?this.animateInternal({resolution:l,center:_,duration:e.duration,easing:e.easing},m):(this.targetResolution_=l,this.targetCenter_=_,this.applyTargetState_(!1,!0),zo(m,!0))}centerOn(t,e,i){this.centerOnInternal(ye(t,this.getProjection()),e,i)}centerOnInternal(t,e,i){this.setCenterInternal(il(t,e,i,this.getResolution(),this.getRotation()))}calculateCenterShift(t,e,i,r){let o,s=this.padding_;if(s&&t){let a=this.getViewportSizeMinusPadding_(-i),l=il(t,r,[a[0]/2+s[3],a[1]/2+s[0]],e,i);o=[t[0]-l[0],t[1]-l[1]]}return o}isDef(){return!!this.getCenterInternal()&&this.getResolution()!==void 0}adjustCenter(t){let e=Er(this.targetCenter_,this.getProjection());this.setCenter([e[0]+t[0],e[1]+t[1]])}adjustCenterInternal(t){let e=this.targetCenter_;this.setCenterInternal([e[0]+t[0],e[1]+t[1]])}adjustResolution(t,e){e=e&&ye(e,this.getProjection()),this.adjustResolutionInternal(t,e)}adjustResolutionInternal(t,e){let i=this.getAnimating()||this.getInteracting(),r=this.getViewportSize_(this.getRotation()),o=this.constraints_.resolution(this.targetResolution_*t,0,r,i);e&&(this.targetCenter_=this.calculateCenterZoom(o,e)),this.targetResolution_*=t,this.applyTargetState_()}adjustZoom(t,e){this.adjustResolution(Math.pow(this.zoomFactor_,-t),e)}adjustRotation(t,e){e&&(e=ye(e,this.getProjection())),this.adjustRotationInternal(t,e)}adjustRotationInternal(t,e){let i=this.getAnimating()||this.getInteracting(),r=this.constraints_.rotation(this.targetRotation_+t,i);e&&(this.targetCenter_=this.calculateCenterRotate(r,e)),this.targetRotation_+=t,this.applyTargetState_()}setCenter(t){this.setCenterInternal(t&&ye(t,this.getProjection()))}setCenterInternal(t){this.targetCenter_=t,this.applyTargetState_()}setHint(t,e){return this.hints_[t]+=e,this.changed(),this.hints_[t]}setResolution(t){this.targetResolution_=t,this.applyTargetState_()}setRotation(t){this.targetRotation_=t,this.applyTargetState_()}setZoom(t){this.setResolution(this.getResolutionForZoom(t))}applyTargetState_(t,e){let i=this.getAnimating()||this.getInteracting()||e,r=this.constraints_.rotation(this.targetRotation_,i),o=this.getViewportSize_(r),s=this.constraints_.resolution(this.targetResolution_,0,o,i),a=this.constraints_.center(this.targetCenter_,s,o,i,this.calculateCenterShift(this.targetCenter_,s,r,o));this.get(ae.ROTATION)!==r&&this.set(ae.ROTATION,r),this.get(ae.RESOLUTION)!==s&&(this.set(ae.RESOLUTION,s),this.set("zoom",this.getZoom(),!0)),(!a||!this.get(ae.CENTER)||!qi(this.get(ae.CENTER),a))&&this.set(ae.CENTER,a),this.getAnimating()&&!t&&this.cancelAnimations(),this.cancelAnchor_=void 0}resolveConstraints(t,e,i){t=t!==void 0?t:200;let r=e||0,o=this.constraints_.rotation(this.targetRotation_),s=this.getViewportSize_(o),a=this.constraints_.resolution(this.targetResolution_,r,s),l=this.constraints_.center(this.targetCenter_,a,s,!1,this.calculateCenterShift(this.targetCenter_,a,o,s));if(t===0&&!this.cancelAnchor_){this.targetResolution_=a,this.targetRotation_=o,this.targetCenter_=l,this.applyTargetState_();return}i=i||(t===0?this.cancelAnchor_:void 0),this.cancelAnchor_=void 0,(this.getResolution()!==a||this.getRotation()!==o||!this.getCenterInternal()||!qi(this.getCenterInternal(),l))&&(this.getAnimating()&&this.cancelAnimations(),this.animateInternal({rotation:o,center:l,resolution:a,duration:t,easing:ce,anchor:i}))}beginInteraction(){this.resolveConstraints(0),this.setHint(Rt.INTERACTING,1)}endInteraction(t,e,i){i=i&&ye(i,this.getProjection()),this.endInteractionInternal(t,e,i)}endInteractionInternal(t,e,i){this.getInteracting()&&(this.setHint(Rt.INTERACTING,-1),this.resolveConstraints(t,e,i))}getConstrainedCenter(t,e){let i=this.getViewportSize_(this.getRotation());return this.constraints_.center(t,e||this.getResolution(),i)}getConstrainedZoom(t,e){let i=this.getResolutionForZoom(t);return this.getZoomForResolution(this.getConstrainedResolution(i,e))}getConstrainedResolution(t,e){e=e||0;let i=this.getViewportSize_(this.getRotation());return this.constraints_.resolution(t,e,i)}};function zo(n,t){setTimeout(function(){n(t)},0)}function zp(n){if(n.extent!==void 0){let e=n.smoothExtentConstraint!==void 0?n.smoothExtentConstraint:!0;return ga(n.extent,n.constrainOnlyCenter,e)}let t=Lo(n.projection,"EPSG:3857");if(n.multiWorld!==!0&&t.isGlobal()){let e=t.getExtent().slice();return e[0]=-1/0,e[2]=1/0,ga(e,!1,!1)}return Qh}function Np(n){let t,e,i,s=n.minZoom!==void 0?n.minZoom:el,a=n.maxZoom!==void 0?n.maxZoom:28,l=n.zoomFactor!==void 0?n.zoomFactor:2,h=n.multiWorld!==void 0?n.multiWorld:!1,c=n.smoothResolutionConstraint!==void 0?n.smoothResolutionConstraint:!0,u=n.showFullExtent!==void 0?n.showFullExtent:!1,f=Lo(n.projection,"EPSG:3857"),g=f.getExtent(),p=n.constrainOnlyCenter,_=n.extent;if(!h&&!_&&f.isGlobal()&&(p=!1,_=g),n.resolutions!==void 0){let m=n.resolutions;e=m[s],i=m[a]!==void 0?m[a]:m[m.length-1],n.constrainResolution?t=nd(m,c,!p&&_,u):t=Qa(e,i,c,!p&&_,u)}else{let x=(g?Math.max(j(g),ct(g)):360*ti.degrees/f.getMetersPerUnit())/256/Math.pow(2,el),w=x/Math.pow(2,28-el);e=n.maxResolution,e!==void 0?s=0:e=x/Math.pow(l,s),i=n.minResolution,i===void 0&&(n.maxZoom!==void 0?n.maxResolution!==void 0?i=e/Math.pow(l,a):i=x/Math.pow(l,a):i=w),a=s+Math.floor(Math.log(e/i)/Math.log(l)),i=e/Math.pow(l,a-s),n.constrainResolution?t=rd(l,e,i,c,!p&&_,u):t=Qa(e,i,c,!p&&_,u)}return{constraint:t,maxResolution:e,minResolution:i,minZoom:s,zoomFactor:l}}function Gp(n){if(n.enableRotation!==void 0?n.enableRotation:!0){let e=n.constrainRotation;return e===void 0||e===!0?sd():e===!1?tl:typeof e=="number"?od(e):tl}return zn}function Xp(n){return!(n.sourceCenter&&n.targetCenter&&!qi(n.sourceCenter,n.targetCenter)||n.sourceResolution!==n.targetResolution||n.sourceRotation!==n.targetRotation)}function il(n,t,e,i,r){let o=Math.cos(-r),s=Math.sin(-r),a=n[0]*o-n[1]*s,l=n[1]*o+n[0]*s;a+=(t[0]/2-e[0])*i,l+=(e[1]-t[1]/2)*i,s=-s;let h=a*o-l*s,c=l*o+a*s;return[h,c]}var te=nl;var Ir="ol-hidden";var Ti="ol-unselectable";var Nn="ol-control",rl="ol-collapsed",Wp=new RegExp(["^\\s*(?=(?:(?:[-a-z]+\\s*){0,2}(italic|oblique))?)","(?=(?:(?:[-a-z]+\\s*){0,2}(small-caps))?)","(?=(?:(?:[-a-z]+\\s*){0,2}(bold(?:er)?|lighter|[1-9]00 ))?)","(?:(?:normal|\\1|\\2|\\3)\\s*){0,3}((?:xx?-)?","(?:small|large)|medium|smaller|larger|[\\.\\d]+(?:\\%|in|[cem]m|ex|p[ctx]))","(?:\\s*\\/\\s*(normal|[\\.\\d]+(?:\\%|in|[cem]m|ex|p[ctx])?))",`?\\s*([-,\\"\\'\\sa-z0-9]+?)\\s*$`].join(""),"i"),ld=["style","variant","weight","size","lineHeight","family"],No={normal:400,bold:700},Go=function(n){let t=n.match(Wp);if(!t)return null;let e={lineHeight:"normal",size:"1.2em",style:"normal",weight:"400",variant:"normal"};for(let i=0,r=ld.length;i<r;++i){let o=t[i+1];o!==void 0&&(e[ld[i]]=typeof o=="string"?o.trim():o)}return isNaN(Number(e.weight))&&e.weight in No&&(e.weight=No[e.weight]),e.families=e.family.split(/,\s?/).map(i=>i.trim().replace(/^['"]|['"]$/g,"")),e};function nt(n,t,e,i){let r;return e&&e.length?r=e.shift():St?r=new class extends OffscreenCanvas{style={}}(n??300,t??150):r=document.createElement("canvas"),n&&(r.width=n),t&&(r.height=t),r.getContext("2d",i)}var ol;function Lr(){return ol||(ol=nt(1,1)),ol}function en(n){let t=n.canvas;t.width=1,t.height=1,n.clearRect(0,0,1,1)}function sl(n,t){let e=t.parentNode;e&&e.replaceChild(n,t)}function cd(n){for(;n.lastChild;)n.lastChild.remove()}function hd(n,t){let e=n.childNodes;for(let i=0;;++i){let r=e[i],o=t[i];if(!r&&!o)break;if(r!==o){if(!r){n.appendChild(o);continue}if(!o){n.removeChild(r),--i;continue}n.insertBefore(o,r)}}}function Xo(){return new Proxy({childNodes:[],appendChild:function(t){return this.childNodes.push(t),t},remove:function(){},removeChild:function(t){let e=this.childNodes.indexOf(t);if(e===-1)throw new Error("Node to remove was not found");return this.childNodes.splice(e,1),t},insertBefore:function(t,e){let i=this.childNodes.indexOf(e);if(i===-1)throw new Error("Reference node not found");return this.childNodes.splice(i,0,t),t},style:{}},{get(t,e,i){return e==="firstElementChild"?t.childNodes.length>0?t.childNodes[0]:null:Reflect.get(t,e,i)}})}function ee(n){return typeof HTMLCanvasElement<"u"&&n instanceof HTMLCanvasElement||typeof OffscreenCanvas<"u"&&n instanceof OffscreenCanvas}var al=class extends yt{constructor(t){super();let e=t.element;e&&!t.target&&!e.style.pointerEvents&&(e.style.pointerEvents="auto"),this.element=e||null,this.target_=null,this.map_=null,this.listenerKeys=[],t.render&&(this.render=t.render),t.target&&this.setTarget(t.target)}disposeInternal(){this.element?.remove(),super.disposeInternal()}getMap(){return this.map_}setMap(t){this.map_&&this.element?.remove();for(let e=0,i=this.listenerKeys.length;e<i;++e)J(this.listenerKeys[e]);if(this.listenerKeys.length=0,this.map_=t,t){let e=this.target_??t.getOverlayContainerStopEvent();this.element&&e.appendChild(this.element),this.render!==Qe&&this.listenerKeys.push(Z(t,Me.POSTRENDER,this.render,this)),t.render()}}render(t){}setTarget(t){this.target_=typeof t=="string"?document.getElementById(t):t}},Gn=al;var ll=class extends Gn{constructor(t){t=t||{},super({element:document.createElement("div"),render:t.render,target:t.target}),this.ulElement_=document.createElement("ul"),this.collapsed_=t.collapsed!==void 0?t.collapsed:!0,this.userCollapsed_=this.collapsed_,this.overrideCollapsible_=t.collapsible!==void 0,this.collapsible_=t.collapsible!==void 0?t.collapsible:!0,this.collapsible_||(this.collapsed_=!1),this.attributions_=t.attributions;let e=t.className!==void 0?t.className:"ol-attribution",i=t.tipLabel!==void 0?t.tipLabel:"Attributions",r=t.expandClassName!==void 0?t.expandClassName:e+"-expand",o=t.collapseLabel!==void 0?t.collapseLabel:"\u203A",s=t.collapseClassName!==void 0?t.collapseClassName:e+"-collapse";typeof o=="string"?(this.collapseLabel_=document.createElement("span"),this.collapseLabel_.textContent=o,this.collapseLabel_.className=s):this.collapseLabel_=o;let a=t.label!==void 0?t.label:"i";typeof a=="string"?(this.label_=document.createElement("span"),this.label_.textContent=a,this.label_.className=r):this.label_=a;let l=this.collapsible_&&!this.collapsed_?this.collapseLabel_:this.label_;this.toggleButton_=document.createElement("button"),this.toggleButton_.setAttribute("type","button"),this.toggleButton_.setAttribute("aria-expanded",String(!this.collapsed_)),this.toggleButton_.title=i,this.toggleButton_.appendChild(l),this.toggleButton_.addEventListener(P.CLICK,this.handleClick_.bind(this),!1);let h=e+" "+Ti+" "+Nn+(this.collapsed_&&this.collapsible_?" "+rl:"")+(this.collapsible_?"":" ol-uncollapsible"),c=this.element;c.className=h,c.appendChild(this.toggleButton_),c.appendChild(this.ulElement_),this.renderedAttributions_=[],this.renderedVisible_=!0}collectSourceAttributions_(t){let e=this.getMap().getAllLayers(),i=new Set(e.flatMap(r=>r.getAttributions(t)));if(this.attributions_!==void 0&&(Array.isArray(this.attributions_)?this.attributions_.forEach(r=>i.add(r)):i.add(this.attributions_)),!this.overrideCollapsible_){let r=!e.some(o=>o.getSource()?.getAttributionsCollapsible()===!1);this.setCollapsible(r)}return Array.from(i)}async updateElement_(t){if(!t){this.renderedVisible_&&(this.element.style.display="none",this.renderedVisible_=!1);return}let e=await Promise.all(this.collectSourceAttributions_(t).map(r=>Uh(()=>r))),i=e.length>0;if(this.renderedVisible_!=i&&(this.element.style.display=i?"":"none",this.renderedVisible_=i),!Nt(e,this.renderedAttributions_)){cd(this.ulElement_);for(let r=0,o=e.length;r<o;++r){let s=document.createElement("li");s.innerHTML=e[r],this.ulElement_.appendChild(s)}this.renderedAttributions_=e}}handleClick_(t){t.preventDefault(),this.handleToggle_(),this.userCollapsed_=this.collapsed_}handleToggle_(){this.element.classList.toggle(rl),this.collapsed_?sl(this.collapseLabel_,this.label_):sl(this.label_,this.collapseLabel_),this.collapsed_=!this.collapsed_,this.toggleButton_.setAttribute("aria-expanded",String(!this.collapsed_))}getCollapsible(){return this.collapsible_}setCollapsible(t){this.collapsible_!==t&&(this.collapsible_=t,this.element.classList.toggle("ol-uncollapsible"),this.userCollapsed_&&this.handleToggle_())}setCollapsed(t){this.userCollapsed_=t,!(!this.collapsible_||this.collapsed_===t)&&this.handleToggle_()}getCollapsed(){return this.collapsed_}render(t){this.updateElement_(t.frameState)}},ud=ll;var cl=class extends Gn{constructor(t){t=t||{},super({element:document.createElement("div"),render:t.render,target:t.target});let e=t.className!==void 0?t.className:"ol-rotate",i=t.label!==void 0?t.label:"\u21E7",r=t.compassClassName!==void 0?t.compassClassName:"ol-compass";this.label_=null,typeof i=="string"?(this.label_=document.createElement("span"),this.label_.className=r,this.label_.textContent=i):(this.label_=i,this.label_.classList.add(r));let o=t.tipLabel?t.tipLabel:"Reset rotation",s=document.createElement("button");s.className=e+"-reset",s.setAttribute("type","button"),s.title=o,s.appendChild(this.label_),s.addEventListener(P.CLICK,this.handleClick_.bind(this),!1);let a=e+" "+Ti+" "+Nn,l=this.element;l.className=a,l.appendChild(s),this.callResetNorth_=t.resetNorth?t.resetNorth:void 0,this.duration_=t.duration!==void 0?t.duration:250,this.autoHide_=t.autoHide!==void 0?t.autoHide:!0,this.rotation_=void 0,this.autoHide_&&this.element.classList.add(Ir)}handleClick_(t){t.preventDefault(),this.callResetNorth_!==void 0?this.callResetNorth_():this.resetNorth_()}resetNorth_(){let e=this.getMap().getView();if(!e)return;let i=e.getRotation();i!==void 0&&(this.duration_>0&&i%(2*Math.PI)!==0?e.animate({rotation:0,duration:this.duration_,easing:ce}):e.setRotation(0))}render(t){let e=t.frameState;if(!e)return;let i=e.viewState.rotation;if(i!=this.rotation_){let r="rotate("+i+"rad)";if(this.autoHide_){let o=this.element.classList.contains(Ir);!o&&i===0?this.element.classList.add(Ir):o&&i!==0&&this.element.classList.remove(Ir)}this.label_.style.transform=r}this.rotation_=i}},dd=cl;var hl=class extends Gn{constructor(t){t=t||{},super({element:document.createElement("div"),target:t.target});let e=t.className!==void 0?t.className:"ol-zoom",i=t.delta!==void 0?t.delta:1,r=t.zoomInClassName!==void 0?t.zoomInClassName:e+"-in",o=t.zoomOutClassName!==void 0?t.zoomOutClassName:e+"-out",s=t.zoomInLabel!==void 0?t.zoomInLabel:"+",a=t.zoomOutLabel!==void 0?t.zoomOutLabel:"\u2013",l=t.zoomInTipLabel!==void 0?t.zoomInTipLabel:"Zoom in",h=t.zoomOutTipLabel!==void 0?t.zoomOutTipLabel:"Zoom out",c=document.createElement("button");c.className=r,c.setAttribute("type","button"),c.title=l,c.appendChild(typeof s=="string"?document.createTextNode(s):s),c.addEventListener(P.CLICK,this.handleClick_.bind(this,i),!1);let u=document.createElement("button");u.className=o,u.setAttribute("type","button"),u.title=h,u.appendChild(typeof a=="string"?document.createTextNode(a):a),u.addEventListener(P.CLICK,this.handleClick_.bind(this,-i),!1);let f=e+" "+Ti+" "+Nn,g=this.element;g.className=f,g.appendChild(c),g.appendChild(u),this.duration_=t.duration!==void 0?t.duration:250}handleClick_(t,e){e.preventDefault(),this.zoomByDelta_(t)}zoomByDelta_(t){let i=this.getMap().getView();if(!i)return;let r=i.getZoom();if(r!==void 0){let o=i.getConstrainedZoom(r+t);this.duration_>0?(i.getAnimating()&&i.cancelAnimations(),i.animate({zoom:o,duration:this.duration_,easing:ce})):i.setZoom(o)}}},fd=hl;function Wo(n){n=n||{};let t=new kt;return(n.zoom===void 0||n.zoom)&&t.push(new fd(n.zoomOptions)),(n.rotate===void 0||n.rotate)&&t.push(new dd(n.rotateOptions)),(n.attribution===void 0||n.attribution)&&t.push(new ud(n.attributionOptions)),t}var ul=class{constructor(t,e,i){this.decay_=t,this.minVelocity_=e,this.delay_=i,this.points_=[],this.angle_=0,this.initialVelocity_=0}begin(){this.points_.length=0,this.angle_=0,this.initialVelocity_=0}update(t,e){this.points_.push(t,e,Date.now())}end(){if(this.points_.length<6)return!1;let t=Date.now()-this.delay_,e=this.points_.length-3;if(this.points_[e+2]<t)return!1;let i=e-3;for(;i>0&&this.points_[i+2]>t;)i-=3;let r=this.points_[e+2]-this.points_[i+2];if(r<1e3/60)return!1;let o=this.points_[e]-this.points_[i],s=this.points_[e+1]-this.points_[i+1];return this.angle_=Math.atan2(s,o),this.initialVelocity_=Math.sqrt(o*o+s*s)/r,this.initialVelocity_>this.minVelocity_}getDistance(){return(this.minVelocity_-this.initialVelocity_)/this.decay_}getAngle(){return this.angle_}},gd=ul;var dl={ACTIVE:"active"};var fl=class extends yt{constructor(t){super(),this.on,this.once,this.un,t&&t.handleEvent&&(this.handleEvent=t.handleEvent),this.map_=null,this.setActive(!0)}getActive(){return this.get(dl.ACTIVE)}getMap(){return this.map_}handleEvent(t){return!0}setActive(t){this.set(dl.ACTIVE,t)}setMap(t){this.map_=t}};function pd(n,t,e){let i=n.getCenterInternal();if(i){let r=[i[0]+t[0],i[1]+t[1]];n.animateInternal({duration:e!==void 0?e:250,easing:hu,center:n.getConstrainedCenter(r)})}}function Xn(n,t,e,i){let r=n.getZoom();if(r===void 0)return;let o=n.getConstrainedZoom(r+t),s=n.getResolutionForZoom(o);n.getAnimating()&&n.cancelAnimations(),n.animate({resolution:s,anchor:e,duration:i!==void 0?i:250,easing:ce})}var Ne=fl;var gl=class extends Ne{constructor(t){super(),t=t||{},this.delta_=t.delta?t.delta:1,this.duration_=t.duration!==void 0?t.duration:250}handleEvent(t){let e=!1;if(t.type==at.DBLCLICK){let i=t.originalEvent,r=t.map,o=t.coordinate,s=i.shiftKey?-this.delta_:this.delta_,a=r.getView();Xn(a,s,o,this.duration_),i.preventDefault(),e=!0}return!e}},md=gl;function Ar(n){let t=arguments;return function(e){let i=!0;for(let r=0,o=t.length;r<o&&(i=i&&t[r](e),!!i);++r);return i}}var _d=function(n){let t=n.originalEvent;return t.altKey&&!(t.metaKey||t.ctrlKey)&&t.shiftKey},Yp=function(n){let t=n.map.getTargetElement(),e=t.getRootNode(),i=n.map.getOwnerDocument().activeElement;return e instanceof ShadowRoot?e.host.contains(i):t.contains(i)},Yo=function(n){let t=n.map.getTargetElement(),e=t.getRootNode();return(e instanceof ShadowRoot?e.host:t).hasAttribute("tabindex")?Yp(n):!0},xd=$e;var Uo=function(n){let t=n.originalEvent;return"pointerId"in t&&t.button==0&&!(Zh&&ca&&t.ctrlKey)};var Ko=function(n){let t=n.originalEvent;return!t.altKey&&!(t.metaKey||t.ctrlKey)&&!t.shiftKey};var yd=function(n){let t=n.originalEvent;return ca?t.metaKey:t.ctrlKey},wd=function(n){let t=n.originalEvent;return!t.altKey&&!(t.metaKey||t.ctrlKey)&&t.shiftKey},Zo=function(n){let t=n.originalEvent,e=t.target.tagName;return e!=="INPUT"&&e!=="SELECT"&&e!=="TEXTAREA"&&!t.target.isContentEditable},Vo=function(n){let t=n.originalEvent;return"pointerId"in t&&t.pointerType=="mouse"};var Ed=function(n){let t=n.originalEvent;return"pointerId"in t&&t.isPrimary&&t.button===0};var pl=class extends Ne{constructor(t){t=t||{},super(t),t.handleDownEvent&&(this.handleDownEvent=t.handleDownEvent),t.handleDragEvent&&(this.handleDragEvent=t.handleDragEvent),t.handleMoveEvent&&(this.handleMoveEvent=t.handleMoveEvent),t.handleUpEvent&&(this.handleUpEvent=t.handleUpEvent),t.stopDown&&(this.stopDown=t.stopDown),this.handlingDownUpSequence=!1,this.targetPointers=[]}getPointerCount(){return this.targetPointers.length}handleDownEvent(t){return!1}handleDragEvent(t){}handleEvent(t){if(!t.originalEvent)return!0;let e=!1;if(this.updateTrackedPointers_(t),this.handlingDownUpSequence){if(t.type==at.POINTERDRAG)this.handleDragEvent(t),t.originalEvent.preventDefault();else if(t.type==at.POINTERUP){let i=this.handleUpEvent(t);this.handlingDownUpSequence=i&&this.targetPointers.length>0}}else if(t.type==at.POINTERDOWN){let i=this.handleDownEvent(t);this.handlingDownUpSequence=i,e=this.stopDown(i)}else t.type==at.POINTERMOVE&&this.handleMoveEvent(t);return!e}handleMoveEvent(t){}handleUpEvent(t){return!1}stopDown(t){return t}updateTrackedPointers_(t){t.activePointers&&(this.targetPointers=t.activePointers)}};function Wn(n){let t=n.length,e=0,i=0;for(let r=0;r<t;r++)e+=n[r].clientX,i+=n[r].clientY;return{clientX:e/t,clientY:i/t}}var Ge=pl;var ml=class extends Ge{constructor(t){super({stopDown:Je}),t=t||{},this.kinetic_=t.kinetic,this.lastCentroid=null,this.lastPointersCount_,this.panning_=!1;let e=t.condition?t.condition:Ar(Ko,Ed);this.condition_=t.onFocusOnly?Ar(Yo,e):e,this.noKinetic_=!1}handleDragEvent(t){let e=t.map;this.panning_||(this.panning_=!0,e.getView().beginInteraction());let i=this.targetPointers,r=e.getEventPixel(Wn(i));if(i.length==this.lastPointersCount_){if(this.kinetic_&&this.kinetic_.update(r[0],r[1]),this.lastCentroid){let o=[this.lastCentroid[0]-r[0],r[1]-this.lastCentroid[1]],a=t.map.getView();su(o,a.getResolution()),Ln(o,a.getRotation()),a.adjustCenterInternal(o)}}else this.kinetic_&&this.kinetic_.begin();this.lastCentroid=r,this.lastPointersCount_=i.length,t.originalEvent.preventDefault()}handleUpEvent(t){let e=t.map,i=e.getView();if(this.targetPointers.length===0){if(!this.noKinetic_&&this.kinetic_&&this.kinetic_.end()){let r=this.kinetic_.getDistance(),o=this.kinetic_.getAngle(),s=i.getCenterInternal(),a=e.getPixelFromCoordinateInternal(s),l=e.getCoordinateFromPixelInternal([a[0]-r*Math.cos(o),a[1]-r*Math.sin(o)]);i.animateInternal({center:i.getConstrainedCenter(l),duration:500,easing:ce})}return this.panning_&&(this.panning_=!1,i.endInteraction()),!1}return this.kinetic_&&this.kinetic_.begin(),this.lastCentroid=null,!0}handleDownEvent(t){if(this.targetPointers.length>0&&this.condition_(t)){let i=t.map.getView();return this.lastCentroid=null,i.getAnimating()&&i.cancelAnimations(),this.kinetic_&&this.kinetic_.begin(),this.noKinetic_=this.targetPointers.length>1,!0}return!1}},vd=ml;var _l=class extends Ge{constructor(t){t=t||{},super({stopDown:Je}),this.condition_=t.condition?t.condition:_d,this.lastAngle_=void 0,this.duration_=t.duration!==void 0?t.duration:250}handleDragEvent(t){if(!Vo(t))return;let e=t.map,i=e.getView();if(i.getConstraints().rotation===zn)return;let r=e.getSize(),o=t.pixel,s=Math.atan2(r[1]/2-o[1],o[0]-r[0]/2);if(this.lastAngle_!==void 0){let a=s-this.lastAngle_;i.adjustRotationInternal(-a)}this.lastAngle_=s}handleUpEvent(t){return Vo(t)?(t.map.getView().endInteraction(this.duration_),!1):!0}handleDownEvent(t){return Vo(t)&&Uo(t)&&this.condition_(t)?(t.map.getView().beginInteraction(),this.lastAngle_=void 0,!0):!1}},Cd=_l;var xl=class extends _i{constructor(t){super(),this.geometry_=null,this.element_=document.createElement("div"),this.element_.style.position="absolute",this.element_.style.pointerEvents="auto",this.element_.className="ol-box "+t,this.map_=null,this.startPixel_=null,this.endPixel_=null}disposeInternal(){this.setMap(null)}render_(){let t=this.startPixel_,e=this.endPixel_,i="px",r=this.element_.style;r.left=Math.min(t[0],e[0])+i,r.top=Math.min(t[1],e[1])+i,r.width=Math.abs(e[0]-t[0])+i,r.height=Math.abs(e[1]-t[1])+i}setMap(t){if(this.map_){this.map_.getOverlayContainer().removeChild(this.element_);let e=this.element_.style;e.left="inherit",e.top="inherit",e.width="inherit",e.height="inherit"}this.map_=t,this.map_&&this.map_.getOverlayContainer().appendChild(this.element_)}setPixels(t,e){this.startPixel_=t,this.endPixel_=e,this.createOrUpdateGeometry(),this.render_()}createOrUpdateGeometry(){if(!this.map_)return;let t=this.startPixel_,e=this.endPixel_,r=[t,[t[0],e[1]],e,[e[0],t[1]]].map(this.map_.getCoordinateFromPixelInternal,this.map_);r[4]=r[0].slice(),this.geometry_?this.geometry_.setCoordinates([r]):this.geometry_=new ii([r])}getGeometry(){return this.geometry_}},bd=xl;var Yn={BOXSTART:"boxstart",BOXDRAG:"boxdrag",BOXEND:"boxend",BOXCANCEL:"boxcancel"},nn=class extends Lt{constructor(t,e,i){super(t),this.coordinate=e,this.mapBrowserEvent=i}},yl=class extends Ge{constructor(t){super(),this.on,this.once,this.un,t=t??{},this.box_=new bd(t.className||"ol-dragbox"),this.minArea_=t.minArea??64,t.onBoxEnd&&(this.onBoxEnd=t.onBoxEnd),this.startPixel_=null,this.condition_=t.condition??Uo,this.boxEndCondition_=t.boxEndCondition??this.defaultBoxEndCondition}defaultBoxEndCondition(t,e,i){let r=i[0]-e[0],o=i[1]-e[1];return r*r+o*o>=this.minArea_}getGeometry(){return this.box_.getGeometry()}handleDragEvent(t){this.startPixel_&&(this.box_.setPixels(this.startPixel_,t.pixel),this.dispatchEvent(new nn(Yn.BOXDRAG,t.coordinate,t)))}handleUpEvent(t){if(!this.startPixel_)return!1;let e=this.boxEndCondition_(t,this.startPixel_,t.pixel);return e&&this.onBoxEnd(t),this.dispatchEvent(new nn(e?Yn.BOXEND:Yn.BOXCANCEL,t.coordinate,t)),this.box_.setMap(null),this.startPixel_=null,!1}handleDownEvent(t){return this.condition_(t)?(this.startPixel_=t.pixel,this.box_.setMap(t.map),this.box_.setPixels(this.startPixel_,this.startPixel_),this.dispatchEvent(new nn(Yn.BOXSTART,t.coordinate,t)),!0):!1}onBoxEnd(t){}setActive(t){t||(this.box_.setMap(null),this.startPixel_&&(this.dispatchEvent(new nn(Yn.BOXCANCEL,this.startPixel_,null)),this.startPixel_=null)),super.setActive(t)}setMap(t){this.getMap()&&(this.box_.setMap(null),this.startPixel_&&(this.dispatchEvent(new nn(Yn.BOXCANCEL,this.startPixel_,null)),this.startPixel_=null)),super.setMap(t)}},Sd=yl;var wl=class extends Sd{constructor(t){t=t||{};let e=t.condition?t.condition:wd;super({condition:e,className:t.className||"ol-dragzoom",minArea:t.minArea}),this.duration_=t.duration!==void 0?t.duration:200,this.out_=t.out!==void 0?t.out:!1}onBoxEnd(t){let i=this.getMap().getView(),r=this.getGeometry();if(this.out_){let o=i.rotatedExtentForGeometry(r),s=i.getResolutionForExtentInternal(o),a=i.getResolution()/s;r=r.clone(),r.scale(a*a)}i.fitInternal(r,{duration:this.duration_,easing:ce})}},Rd=wl;var Ii={LEFT:"ArrowLeft",UP:"ArrowUp",RIGHT:"ArrowRight",DOWN:"ArrowDown"};var El=class extends Ne{constructor(t){super(),t=t||{},this.defaultCondition_=function(e){return Ko(e)&&Zo(e)},this.condition_=t.condition!==void 0?t.condition:this.defaultCondition_,this.duration_=t.duration!==void 0?t.duration:100,this.pixelDelta_=t.pixelDelta!==void 0?t.pixelDelta:128}handleEvent(t){let e=!1;if(t.type==P.KEYDOWN){let i=t.originalEvent,r=i.key;if(this.condition_(t)&&(r==Ii.DOWN||r==Ii.LEFT||r==Ii.RIGHT||r==Ii.UP)){let s=t.map.getView(),a=s.getResolution()*this.pixelDelta_,l=0,h=0;r==Ii.DOWN?h=-a:r==Ii.LEFT?l=-a:r==Ii.RIGHT?l=a:h=a;let c=[l,h];Ln(c,s.getRotation()),pd(s,c,this.duration_),i.preventDefault(),e=!0}}return!e}},Td=El;var vl=class extends Ne{constructor(t){super(),t=t||{},this.condition_=t.condition?t.condition:function(e){return!yd(e)&&Zo(e)},this.delta_=t.delta?t.delta:1,this.duration_=t.duration!==void 0?t.duration:100}handleEvent(t){let e=!1;if(t.type==P.KEYDOWN||t.type==P.KEYPRESS){let i=t.originalEvent,r=i.key;if(this.condition_(t)&&(r==="+"||r==="-")){let o=t.map,s=r==="+"?this.delta_:-this.delta_,a=o.getView();Xn(a,s,void 0,this.duration_),i.preventDefault(),e=!0}}return!e}},Id=vl;var Up=40,Kp=300,Zp=3,Cl=class extends Ne{constructor(t){t=t||{},super(t),this.totalDelta_=0,this.lastDelta_=0,this.maxDelta_=t.maxDelta!==void 0?t.maxDelta:1,this.duration_=t.duration!==void 0?t.duration:250,this.timeout_=t.timeout!==void 0?t.timeout:80,this.useAnchor_=t.useAnchor!==void 0?t.useAnchor:!0,this.constrainResolution_=t.constrainResolution!==void 0?t.constrainResolution:!1;let e=t.condition?t.condition:xd;this.condition_=t.onFocusOnly?Ar(Yo,e):e,this.lastAnchor_=null,this.startTime_=void 0,this.timeoutId_,this.mode_=void 0,this.trackpadEventGap_=400,this.trackpadTimeoutId_,this.deltaPerZoom_=300,this.ctrlKeyPressed_=!1,this.ctrlKeyListenerKeys_=[]}setMap(t){if(this.ctrlKeyListenerKeys_.forEach(J),this.ctrlKeyListenerKeys_.length=0,this.ctrlKeyPressed_=!1,super.setMap(t),t){let e=t.getOwnerDocument();this.ctrlKeyListenerKeys_.push(Z(e,"keydown",i=>{i.key==="Control"&&(this.ctrlKeyPressed_=!0)}),Z(e,"keyup",i=>{i.key==="Control"&&(this.ctrlKeyPressed_=!1)}))}}endInteraction_(){this.trackpadTimeoutId_=void 0;let t=this.getMap();if(!t)return;let e=t.getView(),i=this.lastDelta_?this.lastDelta_>0?1:-1:0;e.endInteraction(this.constrainResolution_||e.getConstrainResolution()?100:void 0,i,this.lastAnchor_?t.getCoordinateFromPixel(this.lastAnchor_):null)}handleEvent(t){if(!this.condition_(t)||t.type!==P.WHEEL)return!0;let i=t.map,r=t.originalEvent;r.preventDefault();let o=r.ctrlKey&&!this.ctrlKeyPressed_;r.ctrlKey||(this.ctrlKeyPressed_=!1),this.useAnchor_&&(this.lastAnchor_=t.pixel);let s=r.deltaY;switch(r.deltaMode){case WheelEvent.DOM_DELTA_LINE:s*=Up;break;case WheelEvent.DOM_DELTA_PAGE:s*=Kp;break;default:}if(s===0)return!1;this.lastDelta_=s;let a=Date.now();this.startTime_===void 0&&(this.startTime_=a),(!this.mode_||a-this.startTime_>this.trackpadEventGap_)&&(this.mode_=Math.abs(s)<4?"trackpad":"wheel");let l=i.getView();if(this.mode_==="trackpad")return this.trackpadTimeoutId_?clearTimeout(this.trackpadTimeoutId_):(l.getAnimating()&&l.cancelAnimations(),l.beginInteraction()),this.trackpadTimeoutId_=setTimeout(this.endInteraction_.bind(this),this.timeout_),o&&(s=s*Zp),l.adjustZoom(-s/this.deltaPerZoom_,this.lastAnchor_?i.getCoordinateFromPixel(this.lastAnchor_):null),this.startTime_=a,!1;this.totalDelta_+=s;let h=Math.max(this.timeout_-(a-this.startTime_),0);return clearTimeout(this.timeoutId_),this.timeoutId_=setTimeout(this.handleWheelZoom_.bind(this,i),h),!1}handleWheelZoom_(t){let e=t.getView();e.getAnimating()&&e.cancelAnimations();let i=-et(this.totalDelta_,-this.maxDelta_*this.deltaPerZoom_,this.maxDelta_*this.deltaPerZoom_)/this.deltaPerZoom_;(e.getConstrainResolution()||this.constrainResolution_)&&(i=i?i>0?1:-1:0),Xn(e,i,this.lastAnchor_?t.getCoordinateFromPixel(this.lastAnchor_):null,this.duration_),this.mode_=void 0,this.totalDelta_=0,this.lastAnchor_=null,this.startTime_=void 0,this.timeoutId_=void 0}setMouseAnchor(t){this.useAnchor_=t,t||(this.lastAnchor_=null)}},Ld=Cl;var bl=class extends Ge{constructor(t){t=t||{};let e=t;e.stopDown||(e.stopDown=Je),super(e),this.anchor_=null,this.lastAngle_=void 0,this.rotating_=!1,this.rotationDelta_=0,this.threshold_=t.threshold!==void 0?t.threshold:.3,this.duration_=t.duration!==void 0?t.duration:250}handleDragEvent(t){let e=0,i=this.targetPointers[0],r=this.targetPointers[1],o=Math.atan2(r.clientY-i.clientY,r.clientX-i.clientX);if(this.lastAngle_!==void 0){let l=o-this.lastAngle_;this.rotationDelta_+=l,!this.rotating_&&Math.abs(this.rotationDelta_)>this.threshold_&&(this.rotating_=!0),e=l}this.lastAngle_=o;let s=t.map,a=s.getView();a.getConstraints().rotation!==zn&&(this.anchor_=s.getCoordinateFromPixelInternal(s.getEventPixel(Wn(this.targetPointers))),this.rotating_&&(s.render(),a.adjustRotationInternal(e,this.anchor_)))}handleUpEvent(t){return this.targetPointers.length<2?(t.map.getView().endInteraction(this.duration_),!1):!0}handleDownEvent(t){if(this.targetPointers.length>=2){let e=t.map;return this.anchor_=null,this.lastAngle_=void 0,this.rotating_=!1,this.rotationDelta_=0,this.handlingDownUpSequence||e.getView().beginInteraction(),!0}return!1}},Ad=bl;var Sl=class extends Ge{constructor(t){t=t||{};let e=t;e.stopDown||(e.stopDown=Je),super(e),this.anchor_=null,this.duration_=t.duration!==void 0?t.duration:400,this.lastDistance_=void 0,this.lastScaleDelta_=1}handleDragEvent(t){let e=1,i=this.targetPointers[0],r=this.targetPointers[1],o=i.clientX-r.clientX,s=i.clientY-r.clientY,a=Math.sqrt(o*o+s*s);this.lastDistance_!==void 0&&(e=this.lastDistance_/a),this.lastDistance_=a;let l=t.map,h=l.getView();e!=1&&(this.lastScaleDelta_=e),this.anchor_=l.getCoordinateFromPixelInternal(l.getEventPixel(Wn(this.targetPointers))),l.render(),h.adjustResolutionInternal(e,this.anchor_)}handleUpEvent(t){if(this.targetPointers.length<2){let i=t.map.getView(),r=this.lastScaleDelta_>1?1:-1;return i.endInteraction(this.duration_,r),!1}return!0}handleDownEvent(t){if(this.targetPointers.length>=2){let e=t.map;return this.anchor_=null,this.lastDistance_=void 0,this.lastScaleDelta_=1,this.handlingDownUpSequence||e.getView().beginInteraction(),!0}return!1}},Md=Sl;function Bo(n){n=n||{};let t=new kt,e=new gd(-.005,.05,100);return(n.altShiftDragRotate===void 0||n.altShiftDragRotate)&&t.push(new Cd),(n.doubleClickZoom===void 0||n.doubleClickZoom)&&t.push(new md({delta:n.zoomDelta,duration:n.zoomDuration})),(n.dragPan===void 0||n.dragPan)&&t.push(new vd({onFocusOnly:n.onFocusOnly,kinetic:e})),(n.pinchRotate===void 0||n.pinchRotate)&&t.push(new Ad),(n.pinchZoom===void 0||n.pinchZoom)&&t.push(new Md({duration:n.zoomDuration})),(n.keyboard===void 0||n.keyboard)&&(t.push(new Td),t.push(new Id({delta:n.zoomDelta,duration:n.zoomDuration}))),(n.mouseWheelZoom===void 0||n.mouseWheelZoom)&&t.push(new Ld({onFocusOnly:n.onFocusOnly,duration:n.zoomDuration})),(n.shiftDragZoom===void 0||n.shiftDragZoom)&&t.push(new Rd({duration:n.zoomDuration})),t}var rt={OPACITY:"opacity",VISIBLE:"visible",EXTENT:"extent",Z_INDEX:"zIndex",MAX_RESOLUTION:"maxResolution",MIN_RESOLUTION:"minResolution",MAX_ZOOM:"maxZoom",MIN_ZOOM:"minZoom",SOURCE:"source",MAP:"map"};var Rl=class extends yt{constructor(t){super(),this.on,this.once,this.un,this.background_=t.background;let e=Object.assign({},t);typeof t.properties=="object"&&(delete e.properties,Object.assign(e,t.properties)),e[rt.OPACITY]=t.opacity!==void 0?t.opacity:1,V(typeof e[rt.OPACITY]=="number","Layer opacity must be a number"),e[rt.VISIBLE]=t.visible!==void 0?t.visible:!0,e[rt.Z_INDEX]=t.zIndex,e[rt.MAX_RESOLUTION]=t.maxResolution!==void 0?t.maxResolution:1/0,e[rt.MIN_RESOLUTION]=t.minResolution!==void 0?t.minResolution:0,e[rt.MIN_ZOOM]=t.minZoom!==void 0?t.minZoom:-1/0,e[rt.MAX_ZOOM]=t.maxZoom!==void 0?t.maxZoom:1/0,this.className_=e.className!==void 0?e.className:"ol-layer",delete e.className,this.setProperties(e),this.state_=null}getBackground(){return this.background_}getClassName(){return this.className_}getLayerState(t){let e=this.state_||{layer:this,managed:t===void 0?!0:t},i=this.getZIndex();return e.opacity=et(Math.round(this.getOpacity()*100)/100,0,1),e.visible=this.getVisible(),e.extent=this.getExtent(),e.zIndex=i===void 0&&!e.managed?1/0:i,e.maxResolution=this.getMaxResolution(),e.minResolution=Math.max(this.getMinResolution(),0),e.minZoom=this.getMinZoom(),e.maxZoom=this.getMaxZoom(),this.state_=e,e}getLayersArray(t){return H()}getLayerStatesArray(t){return H()}getExtent(){return this.get(rt.EXTENT)}getMaxResolution(){return this.get(rt.MAX_RESOLUTION)}getMinResolution(){return this.get(rt.MIN_RESOLUTION)}getMinZoom(){return this.get(rt.MIN_ZOOM)}getMaxZoom(){return this.get(rt.MAX_ZOOM)}getOpacity(){return this.get(rt.OPACITY)}getSourceState(){return H()}getVisible(){return this.get(rt.VISIBLE)}getZIndex(){return this.get(rt.Z_INDEX)}setBackground(t){this.background_=t,this.changed()}setExtent(t){this.set(rt.EXTENT,t)}setMaxResolution(t){this.set(rt.MAX_RESOLUTION,t)}setMinResolution(t){this.set(rt.MIN_RESOLUTION,t)}setMaxZoom(t){this.set(rt.MAX_ZOOM,t)}setMinZoom(t){this.set(rt.MIN_ZOOM,t)}setOpacity(t){V(typeof t=="number","Layer opacity must be a number"),this.set(rt.OPACITY,t)}setVisible(t){this.set(rt.VISIBLE,t)}setZIndex(t){this.set(rt.Z_INDEX,t)}disposeInternal(){this.state_&&(this.state_.layer=null,this.state_=null),super.disposeInternal()}},jo=Rl;var Li={ADDLAYER:"addlayer",REMOVELAYER:"removelayer"},Ee=class extends Lt{constructor(t,e){super(t),this.layer=e}},Tl={LAYERS:"layers"},Il=class n extends jo{constructor(t){t=t||{};let e=Object.assign({},t);delete e.layers;let i=t.layers;super(e),this.on,this.once,this.un,this.layersListenerKeys_=[],this.listenerKeys_={},this.addChangeListener(Tl.LAYERS,this.handleLayersChanged_),i?Array.isArray(i)?i=new kt(i.slice(),{unique:!0}):V(typeof i.getArray=="function","Expected `layers` to be an array or a `Collection`"):i=new kt(void 0,{unique:!0}),this.setLayers(i)}handleLayerChange_(){this.changed()}handleLayersChanged_(){this.layersListenerKeys_.forEach(J),this.layersListenerKeys_.length=0;let t=this.getLayers();this.layersListenerKeys_.push(Z(t,At.ADD,this.handleLayersAdd_,this),Z(t,At.REMOVE,this.handleLayersRemove_,this));for(let i in this.listenerKeys_)this.listenerKeys_[i].forEach(J);Le(this.listenerKeys_);let e=t.getArray();for(let i=0,r=e.length;i<r;i++){let o=e[i];this.registerLayerListeners_(o),this.dispatchEvent(new Ee(Li.ADDLAYER,o))}this.changed()}registerLayerListeners_(t){let e=[Z(t,de.PROPERTYCHANGE,this.handleLayerChange_,this),Z(t,P.CHANGE,this.handleLayerChange_,this)];t instanceof n&&e.push(Z(t,Li.ADDLAYER,this.handleLayerGroupAdd_,this),Z(t,Li.REMOVELAYER,this.handleLayerGroupRemove_,this)),this.listenerKeys_[U(t)]=e}handleLayerGroupAdd_(t){this.dispatchEvent(new Ee(Li.ADDLAYER,t.layer))}handleLayerGroupRemove_(t){this.dispatchEvent(new Ee(Li.REMOVELAYER,t.layer))}handleLayersAdd_(t){let e=t.element;this.registerLayerListeners_(e),this.dispatchEvent(new Ee(Li.ADDLAYER,e)),this.changed()}handleLayersRemove_(t){let e=t.element,i=U(e);this.listenerKeys_[i].forEach(J),delete this.listenerKeys_[i],this.dispatchEvent(new Ee(Li.REMOVELAYER,e)),this.changed()}getLayers(){return this.get(Tl.LAYERS)}setLayers(t){let e=this.getLayers();if(e){let i=e.getArray();for(let r=0,o=i.length;r<o;++r)this.dispatchEvent(new Ee(Li.REMOVELAYER,i[r]))}this.set(Tl.LAYERS,t)}getLayersArray(t){return t=t!==void 0?t:[],this.getLayers().forEach(function(e){e.getLayersArray(t)}),t}getLayerStatesArray(t){let e=t!==void 0?t:[],i=e.length;this.getLayers().forEach(function(s){s.getLayerStatesArray(e)});let r=this.getLayerState(),o=r.zIndex;!t&&r.zIndex===void 0&&(o=0);for(let s=i,a=e.length;s<a;s++){let l=e[s];l.opacity*=r.opacity,l.visible=l.visible&&r.visible,l.maxResolution=Math.min(l.maxResolution,r.maxResolution),l.minResolution=Math.max(l.minResolution,r.minResolution),l.minZoom=Math.max(l.minZoom,r.minZoom),l.maxZoom=Math.min(l.maxZoom,r.maxZoom),r.extent!==void 0&&(l.extent!==void 0?l.extent=Oe(l.extent,r.extent):l.extent=r.extent),l.zIndex===void 0&&(l.zIndex=o)}return e}getSourceState(){return"ready"}},Mr=Il;var Ft={PRERENDER:"prerender",POSTRENDER:"postrender",PRECOMPOSE:"precompose",POSTCOMPOSE:"postcompose",RENDERCOMPLETE:"rendercomplete"};var Ll=class extends jo{constructor(t){let e=Object.assign({},t);delete e.source,super(e),this.on,this.once,this.un,this.mapPrecomposeKey_=null,this.mapRenderKey_=null,this.sourceChangeKey_=null,this.renderer_=null,this.sourceReady_=!1,this.rendered=!1,t.render&&(this.render=t.render),t.map&&this.setMap(t.map),this.addChangeListener(rt.SOURCE,this.handleSourcePropertyChange_);let i=t.source?t.source:null;this.setSource(i)}getLayersArray(t){return t=t||[],t.push(this),t}getLayerStatesArray(t){return t=t||[],t.push(this.getLayerState()),t}getSource(){return this.get(rt.SOURCE)||null}getRenderSource(){return this.getSource()}getSourceState(){let t=this.getSource();return t?t.getState():"undefined"}handleSourceChange_(){this.changed(),!(this.sourceReady_||this.getSource().getState()!=="ready")&&(this.sourceReady_=!0,this.dispatchEvent("sourceready"))}handleSourcePropertyChange_(){this.sourceChangeKey_&&(J(this.sourceChangeKey_),this.sourceChangeKey_=null),this.sourceReady_=!1;let t=this.getSource();t&&(this.sourceChangeKey_=Z(t,P.CHANGE,this.handleSourceChange_,this),t.getState()==="ready"&&(this.sourceReady_=!0,setTimeout(()=>{this.dispatchEvent("sourceready")},0))),this.changed()}getFeatures(t){return this.renderer_?this.renderer_.getFeatures(t):Promise.resolve([])}getData(t){return!this.renderer_||!this.rendered?null:this.renderer_.getData(t)}isVisible(t){let e,i=this.getMapInternal();!t&&i&&(t=i.getView()),t instanceof te?e={viewState:t.getState(),extent:t.calculateExtent()}:e=t,!e.layerStatesArray&&i&&(e.layerStatesArray=i.getLayerGroup().getLayerStatesArray());let r;if(e.layerStatesArray){if(r=e.layerStatesArray.find(s=>s.layer===this),!r)return!1}else r=this.getLayerState();let o=this.getExtent();return Pr(r,e.viewState)&&(!o||ht(o,e.extent))}getAttributions(t){if(!this.isVisible(t))return[];let e=this.getSource()?.getAttributions();if(!e)return[];let i=t instanceof te?t.getViewStateAndExtent():t,r=e(i);return Array.isArray(r)||(r=[r]),r}render(t,e){let i=this.getRenderer();return i.prepareFrame(t)?(this.rendered=!0,i.renderFrame(t,e)):null}unrender(){this.rendered=!1}getDeclutter(){}renderDeclutter(t,e){}renderDeferred(t){let e=this.getRenderer();e&&e.renderDeferred(t)}setMapInternal(t){t||this.unrender(),this.set(rt.MAP,t)}getMapInternal(){return this.get(rt.MAP)}setMap(t){this.mapPrecomposeKey_&&(J(this.mapPrecomposeKey_),this.mapPrecomposeKey_=null),t||this.changed(),this.mapRenderKey_&&(J(this.mapRenderKey_),this.mapRenderKey_=null),t&&(this.mapPrecomposeKey_=Z(t,Ft.PRECOMPOSE,this.handlePrecompose_,this),this.mapRenderKey_=Z(this,P.CHANGE,t.render,t),this.changed())}handlePrecompose_(t){let e=t.frameState.layerStatesArray,i=this.getLayerState(!1);V(!e.some(r=>r.layer===i.layer),"A layer can only be added to the map once. Use either `layer.setMap()` or `map.addLayer()`, not both."),e.push(i)}setSource(t){this.set(rt.SOURCE,t)}getRenderer(){return this.renderer_||(this.renderer_=this.createRenderer()),this.renderer_}hasRenderer(){return!!this.renderer_}createRenderer(){return null}clearRenderer(){this.renderer_&&(this.renderer_.dispose(),delete this.renderer_)}disposeInternal(){this.clearRenderer(),this.setSource(null),super.disposeInternal()}};function Pr(n,t){if(!n.visible)return!1;let e=t.resolution;if(e<n.minResolution||e>=n.maxResolution)return!1;let i=t.zoom;return i>n.minZoom&&i<=n.maxZoom}var rn=Ll;function Ho(n,t,e=0,i=n.length-1,r=Vp){for(;i>e;){if(i-e>600){let l=i-e+1,h=t-e+1,c=Math.log(l),u=.5*Math.exp(2*c/3),f=.5*Math.sqrt(c*u*(l-u)/l)*(h-l/2<0?-1:1),g=Math.max(e,Math.floor(t-h*u/l+f)),p=Math.min(i,Math.floor(t+(l-h)*u/l+f));Ho(n,t,g,p,r)}let o=n[t],s=e,a=i;for(kr(n,e,t),r(n[i],o)>0&&kr(n,e,i);s<a;){for(kr(n,s,a),s++,a--;r(n[s],o)<0;)s++;for(;r(n[a],o)>0;)a--}r(n[e],o)===0?kr(n,e,a):(a++,kr(n,a,i)),a<=t&&(e=a+1),t<=a&&(i=a-1)}}function kr(n,t,e){let i=n[t];n[t]=n[e],n[e]=i}function Vp(n,t){return n<t?-1:n>t?1:0}var on=class{constructor(t=9){this._maxEntries=Math.max(4,t),this._minEntries=Math.max(2,Math.ceil(this._maxEntries*.4)),this.clear()}all(){return this._all(this.data,[])}search(t){let e=this.data,i=[];if(!$o(t,e))return i;let r=this.toBBox,o=[];for(;e;){for(let s=0;s<e.children.length;s++){let a=e.children[s],l=e.leaf?r(a):a;$o(t,l)&&(e.leaf?i.push(a):Ml(t,l)?this._all(a,i):o.push(a))}e=o.pop()}return i}collides(t){let e=this.data;if(!$o(t,e))return!1;let i=[];for(;e;){for(let r=0;r<e.children.length;r++){let o=e.children[r],s=e.leaf?this.toBBox(o):o;if($o(t,s)){if(e.leaf||Ml(t,s))return!0;i.push(o)}}e=i.pop()}return!1}load(t){if(!(t&&t.length))return this;if(t.length<this._minEntries){for(let i=0;i<t.length;i++)this.insert(t[i]);return this}let e=this._build(t.slice(),0,t.length-1,0);if(!this.data.children.length)this.data=e;else if(this.data.height===e.height)this._splitRoot(this.data,e);else{if(this.data.height<e.height){let i=this.data;this.data=e,e=i}this._insert(e,this.data.height-e.height-1,!0)}return this}insert(t){return t&&this._insert(t,this.data.height-1),this}clear(){return this.data=Kn([]),this}remove(t,e){if(!t)return this;let i=this.data,r=this.toBBox(t),o=[],s=[],a,l,h;for(;i||o.length;){if(i||(i=o.pop(),l=o[o.length-1],a=s.pop(),h=!0),i.leaf){let c=Bp(t,i.children,e);if(c!==-1)return i.children.splice(c,1),o.push(i),this._condense(o),this}!h&&!i.leaf&&Ml(i,r)?(o.push(i),s.push(a),a=0,l=i,i=i.children[0]):l?(a++,i=l.children[a],h=!1):i=null}return this}toBBox(t){return t}compareMinX(t,e){return t.minX-e.minX}compareMinY(t,e){return t.minY-e.minY}toJSON(){return this.data}fromJSON(t){return this.data=t,this}_all(t,e){let i=[];for(;t;)t.leaf?e.push(...t.children):i.push(...t.children),t=i.pop();return e}_build(t,e,i,r){let o=i-e+1,s=this._maxEntries,a;if(o<=s)return a=Kn(t.slice(e,i+1)),Un(a,this.toBBox),a;r||(r=Math.ceil(Math.log(o)/Math.log(s)),s=Math.ceil(o/Math.pow(s,r-1))),a=Kn([]),a.leaf=!1,a.height=r;let l=Math.ceil(o/s),h=l*Math.ceil(Math.sqrt(s));Pd(t,e,i,h,this.compareMinX);for(let c=e;c<=i;c+=h){let u=Math.min(c+h-1,i);Pd(t,c,u,l,this.compareMinY);for(let f=c;f<=u;f+=l){let g=Math.min(f+l-1,u);a.children.push(this._build(t,f,g,r-1))}}return Un(a,this.toBBox),a}_chooseSubtree(t,e,i,r){for(;r.push(e),!(e.leaf||r.length-1===i);){let o=1/0,s=1/0,a;for(let l=0;l<e.children.length;l++){let h=e.children[l],c=Al(h),u=qp(t,h)-c;u<s?(s=u,o=c<o?c:o,a=h):u===s&&c<o&&(o=c,a=h)}e=a||e.children[0]}return e}_insert(t,e,i){let r=i?t:this.toBBox(t),o=[],s=this._chooseSubtree(r,this.data,e,o);for(s.children.push(t),Dr(s,r);e>=0&&o[e].children.length>this._maxEntries;)this._split(o,e),e--;this._adjustParentBBoxes(r,o,e)}_split(t,e){let i=t[e],r=i.children.length,o=this._minEntries;this._chooseSplitAxis(i,o,r);let s=this._chooseSplitIndex(i,o,r),a=Kn(i.children.splice(s,i.children.length-s));a.height=i.height,a.leaf=i.leaf,Un(i,this.toBBox),Un(a,this.toBBox),e?t[e-1].children.push(a):this._splitRoot(i,a)}_splitRoot(t,e){this.data=Kn([t,e]),this.data.height=t.height+1,this.data.leaf=!1,Un(this.data,this.toBBox)}_chooseSplitIndex(t,e,i){let r,o=1/0,s=1/0;for(let a=e;a<=i-e;a++){let l=Or(t,0,a,this.toBBox),h=Or(t,a,i,this.toBBox),c=$p(l,h),u=Al(l)+Al(h);c<o?(o=c,r=a,s=u<s?u:s):c===o&&u<s&&(s=u,r=a)}return r||i-e}_chooseSplitAxis(t,e,i){let r=t.leaf?this.compareMinX:jp,o=t.leaf?this.compareMinY:Hp,s=this._allDistMargin(t,e,i,r),a=this._allDistMargin(t,e,i,o);s<a&&t.children.sort(r)}_allDistMargin(t,e,i,r){t.children.sort(r);let o=this.toBBox,s=Or(t,0,e,o),a=Or(t,i-e,i,o),l=qo(s)+qo(a);for(let h=e;h<i-e;h++){let c=t.children[h];Dr(s,t.leaf?o(c):c),l+=qo(s)}for(let h=i-e-1;h>=e;h--){let c=t.children[h];Dr(a,t.leaf?o(c):c),l+=qo(a)}return l}_adjustParentBBoxes(t,e,i){for(let r=i;r>=0;r--)Dr(e[r],t)}_condense(t){for(let e=t.length-1,i;e>=0;e--)t[e].children.length===0?e>0?(i=t[e-1].children,i.splice(i.indexOf(t[e]),1)):this.clear():Un(t[e],this.toBBox)}};function Bp(n,t,e){if(!e)return t.indexOf(n);for(let i=0;i<t.length;i++)if(e(n,t[i]))return i;return-1}function Un(n,t){Or(n,0,n.children.length,t,n)}function Or(n,t,e,i,r){r||(r=Kn(null)),r.minX=1/0,r.minY=1/0,r.maxX=-1/0,r.maxY=-1/0;for(let o=t;o<e;o++){let s=n.children[o];Dr(r,n.leaf?i(s):s)}return r}function Dr(n,t){return n.minX=Math.min(n.minX,t.minX),n.minY=Math.min(n.minY,t.minY),n.maxX=Math.max(n.maxX,t.maxX),n.maxY=Math.max(n.maxY,t.maxY),n}function jp(n,t){return n.minX-t.minX}function Hp(n,t){return n.minY-t.minY}function Al(n){return(n.maxX-n.minX)*(n.maxY-n.minY)}function qo(n){return n.maxX-n.minX+(n.maxY-n.minY)}function qp(n,t){return(Math.max(t.maxX,n.maxX)-Math.min(t.minX,n.minX))*(Math.max(t.maxY,n.maxY)-Math.min(t.minY,n.minY))}function $p(n,t){let e=Math.max(n.minX,t.minX),i=Math.max(n.minY,t.minY),r=Math.min(n.maxX,t.maxX),o=Math.min(n.maxY,t.maxY);return Math.max(0,r-e)*Math.max(0,o-i)}function Ml(n,t){return n.minX<=t.minX&&n.minY<=t.minY&&t.maxX<=n.maxX&&t.maxY<=n.maxY}function $o(n,t){return t.minX<=n.maxX&&t.minY<=n.maxY&&t.maxX>=n.minX&&t.maxY>=n.minY}function Kn(n){return{children:n,height:1,leaf:!0,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0}}function Pd(n,t,e,i,r){let o=[t,e];for(;o.length;){if(e=o.pop(),t=o.pop(),e-t<=i)continue;let s=t+Math.ceil((e-t)/i/2)*i;Ho(n,s,t,e,r),o.push(t,s,s,e)}}var Qo=[NaN,NaN,NaN,0],Pl;function Jp(){return Pl||(Pl=nt(1,1,void 0,{willReadFrequently:!0,desynchronized:!0})),Pl}var Qp=/^rgba?\(\s*(\d+%?)\s+(\d+%?)\s+(\d+%?)(?:\s*\/\s*(\d+%|\d*\.\d+|[01]))?\s*\)$/i,tm=/^rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)(?:\s*,\s*(\d+%|\d*\.\d+|[01]))?\s*\)$/i,em=/^rgba?\(\s*(\d+%)\s*,\s*(\d+%)\s*,\s*(\d+%)(?:\s*,\s*(\d+%|\d*\.\d+|[01]))?\s*\)$/i,im=/^#([\da-f]{3,4}|[\da-f]{6}|[\da-f]{8})$/i;function Jo(n,t){return n.endsWith("%")?Number(n.substring(0,n.length-1))/t:Number(n)}function zr(n){throw new Error('failed to parse "'+n+'" as color')}function kd(n){if(n.toLowerCase().startsWith("rgb")){let o=n.match(tm)||n.match(Qp)||n.match(em);if(o){let s=o[4],a=100/255;return[et(Jo(o[1],a)+.5|0,0,255),et(Jo(o[2],a)+.5|0,0,255),et(Jo(o[3],a)+.5|0,0,255),s!==void 0?et(Jo(s,100),0,1):1]}zr(n)}if(n.startsWith("#")){if(im.test(n)){let o=n.substring(1),s=o.length<=4?1:2,a=[0,0,0,255];for(let l=0,h=o.length;l<h;l+=s){let c=parseInt(o.substring(l,l+s),16);s===1&&(c+=c<<4),a[l/s]=c}return a[3]=a[3]/255,a}zr(n)}let t=Jp();t.fillStyle="#abcdef";let e=t.fillStyle;t.fillStyle=n,t.fillStyle===e&&(t.fillStyle="#fedcba",e=t.fillStyle,t.fillStyle=n,t.fillStyle===e&&zr(n));let i=t.fillStyle;if(i.startsWith("#")||i.startsWith("rgba"))return kd(i);t.clearRect(0,0,1,1),t.fillRect(0,0,1,1);let r=Array.from(t.getImageData(0,0,1,1).data);return r[3]=Vi(r[3]/255,3),r}function Od(n){return typeof n=="string"?n:Gr(n)}var nm=1024,Fr={},kl=0;function Dd(n){if(n.length===4)return n;let t=n.slice();return t[3]=1,t}function Ol(n){return n>.0031308?Math.pow(n,1/2.4)*269.025-14.025:n*3294.6}function Dl(n){return n>.2068965?Math.pow(n,3):(n-4/29)*(108/841)}function Fl(n){return n>10.314724?Math.pow((n+14.025)/269.025,2.4):n/3294.6}function zl(n){return n>.0088564?Math.pow(n,1/3):n/(108/841)+4/29}function Nl(n){let t=Fl(n[0]),e=Fl(n[1]),i=Fl(n[2]),r=zl(t*.222488403+e*.716873169+i*.06060791),o=500*(zl(t*.452247074+e*.399439023+i*.148375274)-r),s=200*(r-zl(t*.016863605+e*.117638439+i*.865350722)),a=Math.atan2(s,o)*(180/Math.PI);return[116*r-16,Math.sqrt(o*o+s*s),a<0?a+360:a,n[3]]}function Fd(n){let t=(n[0]+16)/116,e=n[1],i=n[2]*Math.PI/180,r=Dl(t),o=Dl(t+e/500*Math.cos(i)),s=Dl(t-e/200*Math.sin(i)),a=Ol(o*3.021973625-r*1.617392459-s*.404875592),l=Ol(o*-.943766287+r*1.916279586+s*.027607165),h=Ol(o*.069407491-r*.22898585+s*1.159737864);return[et(a+.5|0,0,255),et(l+.5|0,0,255),et(h+.5|0,0,255),n[3]]}function Nr(n){if(n==="none")return Qo;if(Fr.hasOwnProperty(n))return Fr[n];if(kl>=nm){let e=0;for(let i in Fr)(e++&3)===0&&(delete Fr[i],--kl)}let t=kd(n);t.length!==4&&zr(n);for(let e of t)isNaN(e)&&zr(n);return Fr[n]=t,++kl,t}function ue(n){return Array.isArray(n)?n:Nr(n)}function Gr(n){let t=n[0];t!=(t|0)&&(t=t+.5|0);let e=n[1];e!=(e|0)&&(e=e+.5|0);let i=n[2];i!=(i|0)&&(i=i+.5|0);let r=n[3]===void 0?1:Math.round(n[3]*1e3)/1e3;return"rgba("+t+","+e+","+i+","+r+")"}function Gl(n){return n[0]>0&&n[1]>0}function zd(n,t,e){return e===void 0&&(e=[0,0]),e[0]=n[0]*t+.5|0,e[1]=n[1]*t+.5|0,e}function pt(n,t){return Array.isArray(n)?n:(t===void 0?t=[n,n]:(t[0]=n,t[1]=n),t)}var an=0,es=0,Xt=1<<an++,Q=1<<an++,Wt=1<<an++,Zt=1<<an++,ri=1<<an++,sn=1<<an++,is=Math.pow(2,an)-1,Wl={[Xt]:"boolean",[Q]:"number",[Wt]:"string",[Zt]:"color",[ri]:"number[]",[sn]:"size"},rm=Object.keys(Wl).map(Number).sort(Vt);function om(n){return n in Wl}function ni(n){let t=[];for(let e of rm)Xr(n,e)&&t.push(Wl[e]);return t.length===0?"untyped":t.length<3?t.join(" or "):t.slice(0,-1).join(", ")+", or "+t[t.length-1]}function Xr(n,t){return(n&t)===t}function ts(n,t){return!!(n&t)}function Ai(n,t){return n===t}var ft=class{constructor(t,e){if(!om(t))throw new Error(`literal expressions must have a specific type, got ${ni(t)}`);this.type=t,this.value=e}},ns=class{constructor(t,e,...i){this.type=t,this.operator=e,this.args=i}};function rs(n){return{variables:new Map,properties:new Map,featureId:!1,geometryType:!1,mCoordinate:!1,mapState:!1,inputVariables:n}}function mt(n,t,e){switch(typeof n){case"boolean":{if(Ai(t,Wt))return new ft(Wt,n?"true":"false");if(!Xr(t,Xt))throw new Error(`got a boolean, but expected ${ni(t)}`);return new ft(Xt,n)}case"number":{if(Ai(t,sn))return new ft(sn,pt(n));if(Ai(t,Xt))return new ft(Xt,!!n);if(Ai(t,Wt))return new ft(Wt,n.toString());if(!Xr(t,Q))throw new Error(`got a number, but expected ${ni(t)}`);return new ft(Q,n)}case"string":{if(Ai(t,Zt))return new ft(Zt,Nr(n));if(Ai(t,Xt))return new ft(Xt,!!n);if(!Xr(t,Wt))throw new Error(`got a string, but expected ${ni(t)}`);return new ft(Wt,n)}default:}if(!Array.isArray(n))throw new Error("expression must be an array or a primitive value");if(n.length===0)throw new Error("empty expression");if(typeof n[0]=="string")return _m(n,t,e);for(let i of n)if(typeof i!="number")throw new Error("expected an array of numbers");if(Ai(t,sn)){if(n.length!==2)throw new Error(`expected an array of two values for a size, got ${n.length}`);return new ft(sn,n)}if(Ai(t,Zt)){if(n.length===3)return new ft(Zt,[...n,1]);if(n.length===4)return new ft(Zt,n);throw new Error(`expected an array of 3 or 4 values for a color, got ${n.length}`)}if(!Xr(t,ri))throw new Error(`got an array of numbers, but expected ${ni(t)}`);return new ft(ri,n)}var b={Get:"get",Var:"var",Concat:"concat",GeometryType:"geometry-type",LineMetric:"line-metric",Any:"any",All:"all",Not:"!",Resolution:"resolution",Zoom:"zoom",Time:"time",Equal:"==",NotEqual:"!=",GreaterThan:">",GreaterThanOrEqualTo:">=",LessThan:"<",LessThanOrEqualTo:"<=",Multiply:"*",Divide:"/",Add:"+",Subtract:"-",Clamp:"clamp",Mod:"%",Pow:"^",Abs:"abs",Floor:"floor",Ceil:"ceil",Round:"round",Sin:"sin",Cos:"cos",Atan:"atan",Sqrt:"sqrt",Match:"match",Between:"between",Interpolate:"interpolate",Coalesce:"coalesce",Case:"case",In:"in",Number:"number",String:"string",Array:"array",Color:"color",Id:"id",Band:"band",Palette:"palette",ToString:"to-string",Has:"has"},sm={[b.Get]:K(q(1,1/0),Nd),[b.Var]:am(),[b.Has]:K(q(1,1/0),Nd),[b.Id]:K(lm,Zn),[b.Concat]:K(q(2,1/0),ot(Wt)),[b.GeometryType]:K(cm,Zn),[b.LineMetric]:K(hm,Zn),[b.Resolution]:K(Xl,Zn),[b.Zoom]:K(Xl,Zn),[b.Time]:K(Xl,Zn),[b.Any]:K(q(2,1/0),ot(Xt)),[b.All]:K(q(2,1/0),ot(Xt)),[b.Not]:K(q(1,1),ot(Xt)),[b.Equal]:K(q(2,2),Xd()),[b.NotEqual]:K(q(2,2),Xd()),[b.GreaterThan]:K(q(2,2),ot(Q)),[b.GreaterThanOrEqualTo]:K(q(2,2),ot(Q)),[b.LessThan]:K(q(2,2),ot(Q)),[b.LessThanOrEqualTo]:K(q(2,2),ot(Q)),[b.Multiply]:K(q(2,1/0),Gd),[b.Coalesce]:K(q(2,1/0),Gd),[b.Divide]:K(q(2,2),ot(Q)),[b.Add]:K(q(2,1/0),ot(Q)),[b.Subtract]:K(q(2,2),ot(Q)),[b.Clamp]:K(q(3,3),ot(Q)),[b.Mod]:K(q(2,2),ot(Q)),[b.Pow]:K(q(2,2),ot(Q)),[b.Abs]:K(q(1,1),ot(Q)),[b.Floor]:K(q(1,1),ot(Q)),[b.Ceil]:K(q(1,1),ot(Q)),[b.Round]:K(q(1,1),ot(Q)),[b.Sin]:K(q(1,1),ot(Q)),[b.Cos]:K(q(1,1),ot(Q)),[b.Atan]:K(q(1,2),ot(Q)),[b.Sqrt]:K(q(1,1),ot(Q)),[b.Match]:K(q(4,1/0),Wd,dm),[b.Between]:K(q(3,3),ot(Q)),[b.Interpolate]:K(q(6,1/0),Wd,fm),[b.Case]:K(q(3,1/0),um,gm),[b.In]:K(q(2,2),pm),[b.Number]:K(q(1,1/0),ot(is)),[b.String]:K(q(1,1/0),ot(is)),[b.Array]:K(q(1,1/0),ot(Q)),[b.Color]:K(q(1,4),ot(Q)),[b.Band]:K(q(1,3),ot(Q)),[b.Palette]:K(q(2,2),mm),[b.ToString]:K(q(1,1),ot(Xt|Q|Wt|Zt))};function Nd(n,t,e){let i=n.length-1,r=new Array(i);for(let o=0;o<i;++o){let s=n[o+1];switch(typeof s){case"number":{r[o]=new ft(Q,s);break}case"string":{r[o]=new ft(Wt,s);break}default:throw new Error(`expected a string key or numeric array index for a get operation, got ${s}`)}o===0&&e.properties.set(String(s),t)}return r}function am(){return function(n,t,e){let i=n[1];if(typeof i!="string")throw new Error("expected a string argument for var operation");let r=t,o=e.inputVariables?.[i];if(o!==void 0){let s=mt(o,is,e);if(!(s instanceof ft))throw new Error(`style variables should only be literal values (no expressions!), variable name: ${i}`);let a=s.type;if(typeof o=="string"&&ts(r,Zt)&&!ts(r,Wt)?a=Zt:Array.isArray(o)&&o.length===2&&ts(r,sn)&&!ts(r,ri)&&(a=sn),r&=a,r===es)throw new Error(`the type expected from the var operator (${ni(t)}) did not have any overlap with the type of the corresponding style variables (${ni(a)}), variable name: ${i}`)}if(e.variables.has(i)){let s=e.variables.get(i);if(r&=s,r===es)throw new Error(`a new type expected from the var operator (${ni(t)}) did not have any overlap with the previous type expected for it (${ni(s)}), variable name: ${i}`)}return e.variables.set(i,r),new ns(r,"var",new ft(Wt,i))}}function lm(n,t,e){e.featureId=!0}function cm(n,t,e){e.geometryType=!0}function hm(n,t,e){e.mCoordinate=!0}function Xl(n,t,e){e.mapState=!0}function Zn(n,t,e){let i=n[0];if(n.length!==1)throw new Error(`expected no arguments for ${i} operation`);return[]}function q(n,t){return function(e,i,r){let o=e[0],s=e.length-1;if(n===t){if(s!==n){let a=n===1?"":"s";throw new Error(`expected ${n} argument${a} for ${o}, got ${s}`)}}else if(s<n||s>t){let a=t===1/0?`${n} or more`:`${n} to ${t}`;throw new Error(`expected ${a} arguments for ${o}, got ${s}`)}}}function Gd(n,t,e){let i=n.length-1,r=new Array(i);for(let o=0;o<i;++o){let s=mt(n[o+1],t,e);r[o]=s}return r}function ot(n){return function(t,e,i){let r=t.length-1,o=new Array(r);for(let s=0;s<r;++s){let a=mt(t[s+1],n,i);o[s]=a}return o}}function Xd(){return function(n,t,e){let i=n[0],r=n.length-1,o=new Array(r),s=is;for(let a=0;a<r;++a){let l=mt(n[a+1],s,e);s&=l.type}if(s===es)throw new Error(`no common type was found among the arguments of ${i}`);for(let a=0;a<r;++a){let l=mt(n[a+1],s,e);o[a]=l}return o}}function um(n,t,e){let i=n[0],r=n.length-1;if(r%2===0)throw new Error(`expected an odd number of arguments for ${i}, got ${r} instead`)}function Wd(n,t,e){let i=n[0],r=n.length-1;if(r%2===1)throw new Error(`expected an even number of arguments for operation ${i}, got ${r} instead`)}function dm(n,t,e){let i=n.length-1,r=mt(n[n.length-1],t,e),o=Wt|Q|Xt,s=new Array(i-2);for(let l=0;l<i-2;l+=2){try{let h=mt(n[l+2],o,e);o&=h.type}catch(h){throw new Error(`failed to parse argument ${l+1} of match expression: ${h.message}`)}if(o===es)throw new Error("no common type was found among the arguments of match expression")}for(let l=0;l<i-2;l+=2){try{let h=mt(n[l+2],o,e);s[l]=h}catch(h){throw new Error(`failed to parse argument ${l+1} of match expression: ${h.message}`)}try{let h=mt(n[l+3],r.type,e);s[l+1]=h}catch(h){throw new Error(`failed to parse argument ${l+2} of match expression: ${h.message}`)}}return[mt(n[1],o,e),...s,r]}function fm(n,t,e){let i=n[1],r;switch(i[0]){case"linear":r=1;break;case"exponential":let l=i[1];if(typeof l!="number"||l<=0)throw new Error(`expected a number base for exponential interpolation, got ${JSON.stringify(l)} instead`);r=l;break;default:throw new Error(`invalid interpolation type: ${JSON.stringify(i)}`)}let o=new ft(Q,r),s;try{s=mt(n[2],Q,e)}catch(l){throw new Error(`failed to parse argument 1 in interpolate expression: ${l.message}`)}let a=new Array(n.length-3);for(let l=0;l<a.length;l+=2){try{let h=mt(n[l+3],Q,e);a[l]=h}catch(h){throw new Error(`failed to parse argument ${l+2} for interpolate expression: ${h.message}`)}try{let h=mt(n[l+4],t,e);a[l+1]=h}catch(h){throw new Error(`failed to parse argument ${l+3} for interpolate expression: ${h.message}`)}}return[o,s,...a]}function gm(n,t,e){let i=mt(n[n.length-1],t,e),r=new Array(n.length-1);for(let o=0;o<r.length-1;o+=2){try{let s=mt(n[o+1],Xt,e);r[o]=s}catch(s){throw new Error(`failed to parse argument ${o} of case expression: ${s.message}`)}try{let s=mt(n[o+2],i.type,e);r[o+1]=s}catch(s){throw new Error(`failed to parse argument ${o+1} of case expression: ${s.message}`)}}return r[r.length-1]=i,r}function pm(n,t,e){let i=n[2];if(!Array.isArray(i))throw new Error('the second argument for the "in" operator must be an array');let r;if(i[0]==="literal"){if(i=i[1],!Array.isArray(i))throw new Error('failed to parse "in" expression: the literal operator must be followed by an array')}else if(typeof i[0]=="string")throw new Error('for the "in" operator, a string array should be wrapped in a "literal" operator to disambiguate from expressions');typeof i[0]=="string"?r=Wt:r=Q;let o=new Array(i.length);for(let a=0;a<o.length;a++)try{let l=mt(i[a],r,e);o[a]=l}catch(l){throw new Error(`failed to parse haystack item ${a} for "in" expression: ${l.message}`)}return[mt(n[1],r,e),...o]}function mm(n,t,e){let i;try{i=mt(n[1],Q,e)}catch(s){throw new Error(`failed to parse first argument in palette expression: ${s.message}`)}let r=n[2];if(!Array.isArray(r))throw new Error("the second argument of palette must be an array");let o=new Array(r.length);for(let s=0;s<o.length;s++){let a;try{a=mt(r[s],Zt,e)}catch(l){throw new Error(`failed to parse color at index ${s} in palette expression: ${l.message}`)}if(!(a instanceof ft))throw new Error(`the palette color at index ${s} must be a literal value`);o[s]=a}return[i,...o]}function K(...n){return function(t,e,i){let r=t[0],o;for(let s=0;s<n.length;s++){let a=n[s](t,e,i);if(s==n.length-1){if(!a)throw new Error("expected last argument validator to return the parsed args");o=a}}return new ns(e,r,...o)}}function _m(n,t,e){let i=n[0],r=sm[i];if(!r)throw new Error(`unknown operator: ${i}`);return r(n,t,e)}function os(n){if(!n)return"";let t=n.getType();switch(t){case"Point":case"LineString":case"Polygon":return t;case"MultiPoint":case"MultiLineString":case"MultiPolygon":return t.substring(5);case"Circle":return"Polygon";case"GeometryCollection":return os(n.getGeometries()[0]);default:return""}}function Yl(){return{variables:{},properties:{},resolution:NaN,featureId:null,geometryType:""}}function Ce(n,t,e){let i=mt(n,t,e);return ve(i,e)}function ve(n,t){if(n instanceof ft){if(n.type===Zt&&typeof n.value=="string"){let i=Nr(n.value);return function(){return i}}return function(){return n.value}}let e=n.operator;switch(e){case b.Number:case b.String:case b.Coalesce:return xm(n,t);case b.Get:case b.Var:case b.Has:return ym(n,t);case b.Id:return i=>i.featureId;case b.GeometryType:return i=>i.geometryType;case b.Concat:{let i=n.args.map(r=>ve(r,t));return r=>"".concat(...i.map(o=>o(r).toString()))}case b.Resolution:return i=>i.resolution;case b.Any:case b.All:case b.Between:case b.In:case b.Not:return Em(n,t);case b.Equal:case b.NotEqual:case b.LessThan:case b.LessThanOrEqualTo:case b.GreaterThan:case b.GreaterThanOrEqualTo:return wm(n,t);case b.Multiply:case b.Divide:case b.Add:case b.Subtract:case b.Clamp:case b.Mod:case b.Pow:case b.Abs:case b.Floor:case b.Ceil:case b.Round:case b.Sin:case b.Cos:case b.Atan:case b.Sqrt:return vm(n,t);case b.Case:return Cm(n,t);case b.Match:return bm(n,t);case b.Interpolate:return Sm(n,t);case b.ToString:return Rm(n,t);default:throw new Error(`Unsupported operator ${e}`)}}function xm(n,t){let e=n.operator,i=n.args.length,r=new Array(i);for(let o=0;o<i;++o)r[o]=ve(n.args[o],t);switch(e){case b.Coalesce:return o=>{for(let s=0;s<i;++s){let a=r[s](o);if(typeof a<"u"&&a!==null)return a}throw new Error("Expected one of the values to be non-null")};case b.Number:case b.String:return o=>{for(let s=0;s<i;++s){let a=r[s](o);if(typeof a===e)return a}throw new Error(`Expected one of the values to be a ${e}`)};default:throw new Error(`Unsupported assertion operator ${e}`)}}function ym(n,t){let i=n.args[0].value;switch(n.operator){case b.Get:return r=>{let o=n.args,s=r.properties[i];for(let a=1,l=o.length;a<l;++a){let c=o[a].value;s=s[c]}return s};case b.Var:return r=>r.variables[i];case b.Has:return r=>{let o=n.args;if(!(i in r.properties))return!1;let s=r.properties[i];for(let a=1,l=o.length;a<l;++a){let c=o[a].value;if(!s||!Object.hasOwn(s,c))return!1;s=s[c]}return!0};default:throw new Error(`Unsupported accessor operator ${n.operator}`)}}function wm(n,t){let e=n.operator,i=ve(n.args[0],t),r=ve(n.args[1],t);switch(e){case b.Equal:return o=>i(o)===r(o);case b.NotEqual:return o=>i(o)!==r(o);case b.LessThan:return o=>i(o)<r(o);case b.LessThanOrEqualTo:return o=>i(o)<=r(o);case b.GreaterThan:return o=>i(o)>r(o);case b.GreaterThanOrEqualTo:return o=>i(o)>=r(o);default:throw new Error(`Unsupported comparison operator ${e}`)}}function Em(n,t){let e=n.operator,i=n.args.length,r=new Array(i);for(let o=0;o<i;++o)r[o]=ve(n.args[o],t);switch(e){case b.Any:return o=>{for(let s=0;s<i;++s)if(r[s](o))return!0;return!1};case b.All:return o=>{for(let s=0;s<i;++s)if(!r[s](o))return!1;return!0};case b.Between:return o=>{let s=r[0](o),a=r[1](o),l=r[2](o);return s>=a&&s<=l};case b.In:return o=>{let s=r[0](o);for(let a=1;a<i;++a)if(s===r[a](o))return!0;return!1};case b.Not:return o=>!r[0](o);default:throw new Error(`Unsupported logical operator ${e}`)}}function vm(n,t){let e=n.operator,i=n.args.length,r=new Array(i);for(let o=0;o<i;++o)r[o]=ve(n.args[o],t);switch(e){case b.Multiply:return o=>{let s=1;for(let a=0;a<i;++a)s*=r[a](o);return s};case b.Divide:return o=>r[0](o)/r[1](o);case b.Add:return o=>{let s=0;for(let a=0;a<i;++a)s+=r[a](o);return s};case b.Subtract:return o=>r[0](o)-r[1](o);case b.Clamp:return o=>{let s=r[0](o),a=r[1](o);if(s<a)return a;let l=r[2](o);return s>l?l:s};case b.Mod:return o=>r[0](o)%r[1](o);case b.Pow:return o=>Math.pow(r[0](o),r[1](o));case b.Abs:return o=>Math.abs(r[0](o));case b.Floor:return o=>Math.floor(r[0](o));case b.Ceil:return o=>Math.ceil(r[0](o));case b.Round:return o=>Math.round(r[0](o));case b.Sin:return o=>Math.sin(r[0](o));case b.Cos:return o=>Math.cos(r[0](o));case b.Atan:return i===2?o=>Math.atan2(r[0](o),r[1](o)):o=>Math.atan(r[0](o));case b.Sqrt:return o=>Math.sqrt(r[0](o));default:throw new Error(`Unsupported numeric operator ${e}`)}}function Cm(n,t){let e=n.args.length,i=new Array(e);for(let r=0;r<e;++r)i[r]=ve(n.args[r],t);return r=>{for(let o=0;o<e-1;o+=2)if(i[o](r))return i[o+1](r);return i[e-1](r)}}function bm(n,t){let e=n.args.length,i=new Array(e);for(let r=0;r<e;++r)i[r]=ve(n.args[r],t);return r=>{let o=i[0](r);for(let s=1;s<e-1;s+=2)if(o===i[s](r))return i[s+1](r);return i[e-1](r)}}function Sm(n,t){let e=n.args.length,i=new Array(e);for(let r=0;r<e;++r)i[r]=ve(n.args[r],t);return r=>{let o=i[0](r),s=i[1](r),a,l;for(let h=2;h<e;h+=2){let c=i[h](r),u=i[h+1](r),f=Array.isArray(u);if(f&&(u=Dd(u)),c>=s)return h===2?u:f?Tm(o,s,a,l,c,u):Wr(o,s,a,l,c,u);a=c,l=u}return l}}function Rm(n,t){let e=n.operator,i=n.args.length,r=new Array(i);for(let o=0;o<i;++o)r[o]=ve(n.args[o],t);if(e===b.ToString)return o=>{let s=r[0](o);return n.args[0].type===Zt?Gr(s):s.toString()};throw new Error(`Unsupported convert operator ${e}`)}function Wr(n,t,e,i,r,o){let s=r-e;if(s===0)return i;let a=t-e,l=n===1?a/s:(Math.pow(n,a)-1)/(Math.pow(n,s)-1);return i+l*(o-i)}function Tm(n,t,e,i,r,o){if(r-e===0)return i;let a=Nl(i),l=Nl(o),h=l[2]-a[2];h>180?h-=360:h<-180&&(h+=360);let c=[Wr(n,t,e,a[0],r,l[0]),Wr(n,t,e,a[1],r,l[1]),a[2]+Wr(n,t,e,0,r,h),Wr(n,t,e,i[3],r,o[3])];return Fd(c)}var W={IDLE:0,LOADING:1,LOADED:2,ERROR:3,EMPTY:4};function Yd(n,t,e){let i=n,r=!0,o=!1,s=!1,a=[yn(i,P.LOAD,function(){s=!0,o||t()})];return i.src&&ha?(o=!0,i.decode().then(function(){r&&t()}).catch(function(l){r&&(s?t():e())})):a.push(yn(i,P.ERROR,e)),function(){r=!1,a.forEach(J)}}function Im(n,t){return new Promise((e,i)=>{function r(){s(),e(n)}function o(){s(),i(new Error("Image load error"))}function s(){n.removeEventListener("load",r),n.removeEventListener("error",o)}n.addEventListener("load",r),n.addEventListener("error",o),t&&(n.src=t)})}function Ud(n,t){return t&&(n.src=t),n.src&&ha?new Promise((e,i)=>n.decode().then(()=>e(n)).catch(r=>n.complete&&n.width?e(n):i(r))):Im(n)}var Kl=class{constructor(){this.cache_={},this.patternCache_={},this.cacheSize_=0,this.maxCacheSize_=1024}clear(){this.cache_={},this.patternCache_={},this.cacheSize_=0}canExpireCache(){return this.cacheSize_>this.maxCacheSize_}expire(){if(this.canExpireCache()){let t=0;for(let e in this.cache_){let i=this.cache_[e];(t++&3)===0&&!i.hasListener()&&(delete this.cache_[e],delete this.patternCache_[e],--this.cacheSize_)}}}get(t,e){let i=Ul(t,e);return i in this.cache_?this.cache_[i]:null}getPattern(t,e){let i=Ul(t,e);return i in this.patternCache_?this.patternCache_[i]:null}set(t,e,i,r){let o=Ul(t,e),s=o in this.cache_;this.cache_[o]=i,r&&(i.getImageState()===W.IDLE&&i.load(),i.getImageState()===W.LOADING?i.ready().then(()=>{this.patternCache_[o]=Lr().createPattern(i.getImage(1),"repeat")}):this.patternCache_[o]=Lr().createPattern(i.getImage(1),"repeat")),s||++this.cacheSize_}setSize(t){this.maxCacheSize_=t,this.expire()}};function Ul(n,t){let e=t?ue(t):"null";return n+":"+e}var Yt=new Kl;var Yr=null,ss=class extends xi{constructor(t,e,i,r,o){super(),this.hitDetectionImage_=null,this.image_=t,this.crossOrigin_=i?.crossOrigin,this.referrerPolicy_=i?.referrerPolicy,this.canvas_={},this.color_=o,this.imageState_=r===void 0?W.IDLE:r,this.size_=t&&t.width&&t.height?[t.width,t.height]:null,this.src_=e,this.tainted_,this.ready_=null}initializeImage_(){this.image_=new Image,this.crossOrigin_!==null&&(this.image_.crossOrigin=this.crossOrigin_),this.referrerPolicy_!==void 0&&(this.image_.referrerPolicy=this.referrerPolicy_)}isTainted_(){if(this.tainted_===void 0&&this.imageState_===W.LOADED){Yr||(Yr=nt(1,1,void 0,{willReadFrequently:!0})),Yr.drawImage(this.image_,0,0);try{Yr.getImageData(0,0,1,1),this.tainted_=!1}catch{Yr=null,this.tainted_=!0}}return this.tainted_===!0}dispatchChangeEvent_(){this.dispatchEvent(P.CHANGE)}handleImageError_(){this.imageState_=W.ERROR,this.dispatchChangeEvent_()}handleImageLoad_(){this.imageState_=W.LOADED,this.size_=[this.image_.width,this.image_.height],this.dispatchChangeEvent_()}getImage(t){return this.image_||this.initializeImage_(),this.replaceColor_(t),this.canvas_[t]?this.canvas_[t]:this.image_}setImage(t){this.image_=t}getPixelRatio(t){return this.replaceColor_(t),this.canvas_[t]?t:1}getImageState(){return this.imageState_}getHitDetectionImage(){if(this.image_||this.initializeImage_(),!this.hitDetectionImage_)if(this.isTainted_()){let t=this.size_[0],e=this.size_[1],i=nt(t,e);i.fillRect(0,0,t,e),this.hitDetectionImage_=i.canvas}else this.hitDetectionImage_=this.image_;return this.hitDetectionImage_}getSize(){return this.size_}getSrc(){return this.src_}load(){if(this.imageState_===W.IDLE){this.image_||this.initializeImage_(),this.imageState_=W.LOADING;try{this.src_!==void 0&&(this.image_.src=this.src_)}catch{this.handleImageError_()}this.image_ instanceof HTMLImageElement&&Ud(this.image_,this.src_).then(t=>{this.image_=t,this.handleImageLoad_()}).catch(this.handleImageError_.bind(this))}}replaceColor_(t){if(!this.color_||this.canvas_[t]||this.imageState_!==W.LOADED)return;let e=this.image_,i=nt(Math.ceil(e.width*t),Math.ceil(e.height*t)),r=i.canvas;i.scale(t,t),i.drawImage(e,0,0),i.globalCompositeOperation="multiply",i.fillStyle=Od(this.color_),i.fillRect(0,0,r.width/t,r.height/t),i.globalCompositeOperation="destination-in",i.drawImage(e,0,0),this.canvas_[t]=r}ready(){return this.ready_||(this.ready_=new Promise(t=>{if(this.imageState_===W.LOADED||this.imageState_===W.ERROR)t();else{let e=()=>{(this.imageState_===W.LOADED||this.imageState_===W.ERROR)&&(this.removeEventListener(P.CHANGE,e),t())};this.addEventListener(P.CHANGE,e)}})),this.ready_}};function Mi(n,t,e,i,r,o){let s=t===void 0?void 0:Yt.get(t,r);return s||(s=new ss(n,n&&"src"in n?n.src||void 0:t,e,i,r),Yt.set(t,r,s,o)),o&&s&&!Yt.getPattern(t,r)&&Yt.set(t,r,s,o),s}var Kd=ss;function Ht(n){return n?Array.isArray(n)?Gr(n):typeof n=="object"&&"src"in n?Lm(n):n:null}function Lm(n){if(!n.offset||!n.size)return Yt.getPattern(n.src,n.color);let t=n.src+":"+n.offset,e=Yt.getPattern(t,n.color);if(e)return e;let i=Yt.get(n.src,null);if(i.getImageState()!==W.LOADED)return null;let r=nt(n.size[0],n.size[1]);return r.drawImage(i.getImage(1),n.offset[0],n.offset[1],n.size[0],n.size[1],0,0,n.size[0],n.size[1]),Mi(r.canvas,t,void 0,W.LOADED,n.color,!0),Yt.getPattern(t,n.color)}var as="10px sans-serif",Tt="#000",Xe="round",qt=[],$t=0,We="round",oi=10,Vd=0,Ut="#000",Pi="center",cn="middle",si=[0,0,0,0],ai=1,ln=new yt,Ur=null,Zd,Zl={},Am=new Set(["serif","sans-serif","monospace","cursive","fantasy","system-ui","ui-serif","ui-sans-serif","ui-monospace","ui-rounded","emoji","math","fangsong"]);function Mm(n,t,e){return`${n} ${t} 16px "${e}"`}var Bd=(function(){let t,e;async function i(o){await e.ready;let s=Go(o),a=s.families[0].toLowerCase(),l=s.weight,h=[];return e.forEach(u=>{let f=u.family.replace(/^['"]|['"]$/g,"").toLowerCase(),g=No[u.weight]||u.weight;f===a&&u.style===s.style&&g==l&&h.push(u)}),h.length===0?!1:(await Promise.all(h.map(u=>u.load().then(()=>!0,()=>!1)))).some(u=>u)}async function r(){await e.ready;let o=!0,s=ln.getProperties(),a=Object.keys(s).filter(l=>s[l]<100);for(let l=a.length-1;l>=0;--l){let h=a[l],c=s[h];c<100&&(await i(h)?(Le(Zl),ln.set(h,100)):(c+=10,ln.set(h,c,!0),c<100&&(o=!1)))}t=void 0,o||(t=setTimeout(r,100))}return async function(o){e||(e=St?self.fonts:document.fonts);let s=Go(o);if(!s)return;let a=s.families,l=!1;for(let h of a){if(Am.has(h))continue;let c=Mm(s.style,s.weight,h);ln.get(c)===void 0&&(ln.set(c,0,!0),l=!0)}l&&(clearTimeout(t),t=setTimeout(r,100))}})(),Pm=(function(){let n;return function(t){let e=Zl[t];if(e==null){if(St){let i=Go(t),r=jd(t,"\u017Dg");e=(isNaN(Number(i.lineHeight))?1.2:Number(i.lineHeight))*(r.actualBoundingBoxAscent+r.actualBoundingBoxDescent)}else n||(n=document.createElement("div"),n.innerHTML="M",n.style.minHeight="0",n.style.maxHeight="none",n.style.height="auto",n.style.padding="0",n.style.border="none",n.style.position="absolute",n.style.display="block",n.style.left="-99999px"),n.style.font=t,document.body.appendChild(n),e=n.offsetHeight,document.body.removeChild(n);Zl[t]=e}return e}})();function jd(n,t){return Ur||(Ur=nt(1,1)),n!=Zd&&(Ur.font=n,Zd=Ur.font),Ur.measureText(t)}function Hd(n,t){return jd(n,t).width}function Vl(n,t,e){if(t in e)return e[t];let i=t.split(`2-`).reduce((r,o)=>Math.max(r,Hd(n,o)),0);return e[t]=i,i}function qd(n,t){let e=[],i=[],r=[],o=0,s=0,a=0,l=0;for(let h=0,c=t.length;h<=c;h+=2){let u=t[h];if(u===`3-`||h===c){o=Math.max(o,s),r.push(s),s=0,a+=l,l=0;continue}let f=t[h+1]||n.font,g=Hd(f,u);e.push(g),s+=g;let p=Pm(f);i.push(p),l=Math.max(l,p)}return{width:o,height:a,widths:e,heights:i,lineWidths:r}}function $d(n,t,e,i,r,o,s,a,l,h,c){n.save(),e!==1&&(n.globalAlpha===void 0?n.globalAlpha=u=>u.globalAlpha*=e:n.globalAlpha*=e),t&&n.transform.apply(n,t),i.contextInstructions?(n.translate(l,h),n.scale(c[0],c[1]),km(i,n)):c[0]<0||c[1]<0?(n.translate(l,h),n.scale(c[0],c[1]),n.drawImage(i,r,o,s,a,0,0,s,a)):n.drawImage(i,r,o,s,a,l,h,s*c[0],a*c[1]),n.restore()}function km(n,t){let e=n.contextInstructions;for(let i=0,r=e.length;i<r;i+=2)Array.isArray(e[i+1])?t[e[i]].apply(t,e[i+1]):t[e[i]]=e[i+1]}var Bl=class n{constructor(t){this.opacity_=t.opacity,this.rotateWithView_=t.rotateWithView,this.rotation_=t.rotation,this.scale_=t.scale,this.scaleArray_=pt(t.scale),this.displacement_=t.displacement,this.declutterMode_=t.declutterMode}clone(){let t=this.getScale();return new n({opacity:this.getOpacity(),scale:Array.isArray(t)?t.slice():t,rotation:this.getRotation(),rotateWithView:this.getRotateWithView(),displacement:this.getDisplacement().slice(),declutterMode:this.getDeclutterMode()})}getOpacity(){return this.opacity_}getRotateWithView(){return this.rotateWithView_}getRotation(){return this.rotation_}getScale(){return this.scale_}getScaleArray(){return this.scaleArray_}getDisplacement(){return this.displacement_}getDeclutterMode(){return this.declutterMode_}getAnchor(){return H()}getImage(t){return H()}getHitDetectionImage(){return H()}getPixelRatio(t){return 1}getImageState(){return H()}getImageSize(){return H()}getOrigin(){return H()}getSize(){return H()}setDisplacement(t){this.displacement_=t}setOpacity(t){this.opacity_=t}setRotateWithView(t){this.rotateWithView_=t}setRotation(t){this.rotation_=t}setScale(t){this.scale_=t,this.scaleArray_=pt(t)}listenImageChange(t){H()}load(){H()}unlistenImageChange(t){H()}ready(){return Promise.resolve()}},ls=Bl;var jl=class n extends ls{constructor(t){super({opacity:1,rotateWithView:t.rotateWithView!==void 0?t.rotateWithView:!1,rotation:t.rotation!==void 0?t.rotation:0,scale:t.scale!==void 0?t.scale:1,displacement:t.displacement!==void 0?t.displacement:[0,0],declutterMode:t.declutterMode}),this.hitDetectionCanvas_=null,this.fill_=t.fill!==void 0?t.fill:null,this.origin_=[0,0],this.points_=t.points,this.radius=t.radius,this.radius2_=t.radius2,this.angle_=t.angle!==void 0?t.angle:0,this.stroke_=t.stroke!==void 0?t.stroke:null,this.size_,this.renderOptions_,this.imageState_=this.fill_&&this.fill_.loading()?W.LOADING:W.LOADED,this.imageState_===W.LOADING&&this.ready().then(()=>this.imageState_=W.LOADED),this.render()}clone(){let t=this.getScale(),e=new n({fill:this.getFill()?this.getFill().clone():void 0,points:this.getPoints(),radius:this.getRadius(),radius2:this.getRadius2(),angle:this.getAngle(),stroke:this.getStroke()?this.getStroke().clone():void 0,rotation:this.getRotation(),rotateWithView:this.getRotateWithView(),scale:Array.isArray(t)?t.slice():t,displacement:this.getDisplacement().slice(),declutterMode:this.getDeclutterMode()});return e.setOpacity(this.getOpacity()),e}getAnchor(){let t=this.size_,e=this.getDisplacement(),i=this.getScaleArray();return[t[0]/2-e[0]/i[0],t[1]/2+e[1]/i[1]]}getAngle(){return this.angle_}getFill(){return this.fill_}setFill(t){this.fill_=t,this.render()}getHitDetectionImage(){return this.hitDetectionCanvas_||(this.hitDetectionCanvas_=this.createHitDetectionCanvas_(this.renderOptions_)),this.hitDetectionCanvas_}getImage(t){let e=this.fill_?.getKey(),i=`${t},${this.angle_},${this.radius},${this.radius2_},${this.points_},${e}`+Object.values(this.renderOptions_).join(","),r=Yt.get(i,null)?.getImage(1);if(!r){let o=this.renderOptions_,s=Math.ceil(o.size*t),a=nt(s,s);this.draw_(o,a,t),r=a.canvas;let l=new Kd(r,void 0,null,W.LOADED,null);Yt.set(i,null,l),createImageBitmap(r).then(h=>{l.setImage(h)})}return r}getPixelRatio(t){return t}getImageSize(){return this.size_}getImageState(){return this.imageState_}getOrigin(){return this.origin_}getPoints(){return this.points_}getRadius(){return this.radius}setRadius(t){this.radius!==t&&(this.radius=t,this.render())}getRadius2(){return this.radius2_}setRadius2(t){this.radius2_!==t&&(this.radius2_=t,this.render())}getSize(){return this.size_}getStroke(){return this.stroke_}setStroke(t){this.stroke_=t,this.render()}listenImageChange(t){}load(){}unlistenImageChange(t){}calculateLineJoinSize_(t,e,i){if(e===0||this.points_===1/0||t!=="bevel"&&t!=="miter")return e;let r=this.radius,o=this.radius2_===void 0?r:this.radius2_;if(r<o){let R=r;r=o,o=R}let s=this.radius2_===void 0?this.points_:this.points_*2,a=2*Math.PI/s,l=o*Math.sin(a),h=Math.sqrt(o*o-l*l),c=r-h,u=Math.sqrt(l*l+c*c),f=u/l;if(t==="miter"&&f<=i)return f*e;let g=e/2/f,p=e/2*(c/u),m=Math.sqrt((r+g)*(r+g)+p*p)-r;if(this.radius2_===void 0||t==="bevel")return m*2;let x=r*Math.sin(a),w=Math.sqrt(r*r-x*x),v=o-w,E=Math.sqrt(x*x+v*v)/x;if(E<=i){let R=E*e/2-o-r;return 2*Math.max(m,R)}return m*2}createRenderOptions(){let t=Xe,e=We,i=0,r=null,o=0,s,a=0;this.stroke_&&(s=Ht(this.stroke_.getColor()??Ut),a=this.stroke_.getWidth()??ai,r=this.stroke_.getLineDash(),o=this.stroke_.getLineDashOffset()??0,e=this.stroke_.getLineJoin()??We,t=this.stroke_.getLineCap()??Xe,i=this.stroke_.getMiterLimit()??oi);let l=this.calculateLineJoinSize_(e,a,i),h=Math.max(this.radius,this.radius2_||0),c=Math.ceil(2*h+l);return{strokeStyle:s,strokeWidth:a,size:c,lineCap:t,lineDash:r,lineDashOffset:o,lineJoin:e,miterLimit:i}}render(){this.renderOptions_=this.createRenderOptions();let t=this.renderOptions_.size;this.hitDetectionCanvas_=null,this.size_=[t,t]}draw_(t,e,i){if(e.scale(i,i),e.translate(t.size/2,t.size/2),this.createPath_(e),this.fill_){let r=this.fill_.getColor();r===null&&(r=Tt),e.fillStyle=Ht(r),e.fill()}t.strokeStyle&&(e.strokeStyle=t.strokeStyle,e.lineWidth=t.strokeWidth,t.lineDash&&(e.setLineDash(t.lineDash),e.lineDashOffset=t.lineDashOffset),e.lineCap=t.lineCap,e.lineJoin=t.lineJoin,e.miterLimit=t.miterLimit,e.stroke())}createHitDetectionCanvas_(t){let e;if(this.fill_){let i=this.fill_.getColor(),r=0;typeof i=="string"&&(i=ue(i)),i===null?r=1:Array.isArray(i)&&(r=i.length===4?i[3]:1),r===0&&(e=nt(t.size,t.size),this.drawHitDetectionCanvas_(t,e))}return e?e.canvas:this.getImage(1)}createPath_(t){let e=this.points_,i=this.radius;if(e===1/0)t.arc(0,0,i,0,2*Math.PI);else{let r=this.radius2_===void 0?i:this.radius2_;this.radius2_!==void 0&&(e*=2);let o=this.angle_-Math.PI/2,s=2*Math.PI/e;for(let a=0;a<e;a++){let l=o+a*s,h=a%2===0?i:r;t.lineTo(h*Math.cos(l),h*Math.sin(l))}t.closePath()}}drawHitDetectionCanvas_(t,e){e.translate(t.size/2,t.size/2),this.createPath_(e),e.fillStyle=Tt,e.fill(),t.strokeStyle&&(e.strokeStyle=t.strokeStyle,e.lineWidth=t.strokeWidth,t.lineDash&&(e.setLineDash(t.lineDash),e.lineDashOffset=t.lineDashOffset),e.lineJoin=t.lineJoin,e.miterLimit=t.miterLimit,e.stroke())}ready(){return this.fill_?this.fill_.ready():Promise.resolve()}},cs=jl;var Hl=class n extends cs{constructor(t){t=t||{radius:5},super({points:1/0,fill:t.fill,radius:t.radius,stroke:t.stroke,scale:t.scale!==void 0?t.scale:1,rotation:t.rotation!==void 0?t.rotation:0,rotateWithView:t.rotateWithView!==void 0?t.rotateWithView:!1,displacement:t.displacement!==void 0?t.displacement:[0,0],declutterMode:t.declutterMode})}clone(){let t=this.getScale(),e=new n({fill:this.getFill()?this.getFill().clone():void 0,stroke:this.getStroke()?this.getStroke().clone():void 0,radius:this.getRadius(),scale:Array.isArray(t)?t.slice():t,rotation:this.getRotation(),rotateWithView:this.getRotateWithView(),displacement:this.getDisplacement().slice(),declutterMode:this.getDeclutterMode()});return e.setOpacity(this.getOpacity()),e}},hs=Hl;var ql=class n{constructor(t){t=t||{},this.patternImage_=null,this.color_=null,t.color!==void 0&&this.setColor(t.color)}clone(){let t=this.getColor();return new n({color:Array.isArray(t)?t.slice():t||void 0})}getColor(){return this.color_}setColor(t){if(t!==null&&typeof t=="object"&&"src"in t){let e=Mi(null,t.src,{crossOrigin:"anonymous"},void 0,t.offset?null:t.color?t.color:null,!(t.offset&&t.size));e.ready().then(()=>{this.patternImage_=null}),e.getImageState()===W.IDLE&&e.load(),e.getImageState()===W.LOADING&&(this.patternImage_=e)}this.color_=t}getKey(){let t=this.getColor();return t?t instanceof CanvasPattern||t instanceof CanvasGradient?U(t):typeof t=="object"&&"src"in t?t.src+":"+t.offset:ue(t).toString():""}loading(){return!!this.patternImage_}ready(){return this.patternImage_?this.patternImage_.ready():Promise.resolve()}},_t=ql;function Jd(n,t,e,i){return e!==void 0&&i!==void 0?[e/n,i/t]:e!==void 0?e/n:i!==void 0?i/t:1}var $l=class n extends ls{constructor(t){t=t||{};let e=t.opacity!==void 0?t.opacity:1,i=t.rotation!==void 0?t.rotation:0,r=t.scale!==void 0?t.scale:1,o=t.rotateWithView!==void 0?t.rotateWithView:!1;super({opacity:e,rotation:i,scale:r,displacement:t.displacement!==void 0?t.displacement:[0,0],rotateWithView:o,declutterMode:t.declutterMode}),this.anchor_=t.anchor!==void 0?t.anchor:[.5,.5],this.normalizedAnchor_=null,this.anchorOrigin_=t.anchorOrigin!==void 0?t.anchorOrigin:"top-left",this.anchorXUnits_=t.anchorXUnits!==void 0?t.anchorXUnits:"fraction",this.anchorYUnits_=t.anchorYUnits!==void 0?t.anchorYUnits:"fraction",this.crossOrigin_=t.crossOrigin!==void 0?t.crossOrigin:null,this.referrerPolicy_=t.referrerPolicy;let s=t.img!==void 0?t.img:null,a=t.src;V(!(a!==void 0&&s),"`image` and `src` cannot be provided at the same time"),(a===void 0||a.length===0)&&s&&(a=s.src||U(s)),V(a!==void 0&&a.length>0,"A defined and non-empty `src` or `image` must be provided"),V(!((t.width!==void 0||t.height!==void 0)&&t.scale!==void 0),"`width` or `height` cannot be provided together with `scale`");let l;if(t.src!==void 0?l=W.IDLE:s!==void 0&&("complete"in s?s.complete?l=s.src?W.LOADED:W.IDLE:l=W.LOADING:l=W.LOADED),this.color_=t.color!==void 0?ue(t.color):null,this.iconImage_=Mi(s,a,{crossOrigin:this.crossOrigin_,referrerPolicy:this.referrerPolicy_},l,this.color_),this.offset_=t.offset!==void 0?t.offset:[0,0],this.offsetOrigin_=t.offsetOrigin!==void 0?t.offsetOrigin:"top-left",this.origin_=null,this.size_=t.size!==void 0?t.size:null,this.initialOptions_,t.width!==void 0||t.height!==void 0){let h,c;if(t.size)[h,c]=t.size;else{let u=this.getImage(1);if(u.width&&u.height)h=u.width,c=u.height;else if(u instanceof HTMLImageElement){this.initialOptions_=t;let f=()=>{if(this.unlistenImageChange(f),!this.initialOptions_)return;let g=this.iconImage_.getSize();this.setScale(Jd(g[0],g[1],t.width,t.height))};this.listenImageChange(f);return}}h!==void 0&&this.setScale(Jd(h,c,t.width,t.height))}}clone(){let t,e,i;return this.initialOptions_?(e=this.initialOptions_.width,i=this.initialOptions_.height):(t=this.getScale(),t=Array.isArray(t)?t.slice():t),new n({anchor:this.anchor_.slice(),anchorOrigin:this.anchorOrigin_,anchorXUnits:this.anchorXUnits_,anchorYUnits:this.anchorYUnits_,color:this.color_&&this.color_.slice?this.color_.slice():this.color_||void 0,crossOrigin:this.crossOrigin_,referrerPolicy:this.referrerPolicy_,offset:this.offset_.slice(),offsetOrigin:this.offsetOrigin_,opacity:this.getOpacity(),rotateWithView:this.getRotateWithView(),rotation:this.getRotation(),scale:t,width:e,height:i,size:this.size_!==null?this.size_.slice():void 0,src:this.getSrc(),displacement:this.getDisplacement().slice(),declutterMode:this.getDeclutterMode()})}getAnchor(){let t=this.normalizedAnchor_;if(!t){t=this.anchor_;let r=this.getSize();if(this.anchorXUnits_=="fraction"||this.anchorYUnits_=="fraction"){if(!r)return null;t=this.anchor_.slice(),this.anchorXUnits_=="fraction"&&(t[0]*=r[0]),this.anchorYUnits_=="fraction"&&(t[1]*=r[1])}if(this.anchorOrigin_!="top-left"){if(!r)return null;t===this.anchor_&&(t=this.anchor_.slice()),(this.anchorOrigin_=="top-right"||this.anchorOrigin_=="bottom-right")&&(t[0]=-t[0]+r[0]),(this.anchorOrigin_=="bottom-left"||this.anchorOrigin_=="bottom-right")&&(t[1]=-t[1]+r[1])}this.normalizedAnchor_=t}let e=this.getDisplacement(),i=this.getScaleArray();return[t[0]-e[0]/i[0],t[1]+e[1]/i[1]]}setAnchor(t){this.anchor_=t,this.normalizedAnchor_=null}getColor(){return this.color_}setColor(t){let e=t?ue(t):null;if(this.color_===e||this.color_&&e&&this.color_.length===e.length&&this.color_.every((s,a)=>s===e[a]))return;this.color_=e;let i=this.getSrc(),r=i!==void 0?null:this.getHitDetectionImage(),o=i!==void 0?W.IDLE:this.iconImage_.getImageState();this.iconImage_=Mi(r,i,{crossOrigin:this.crossOrigin_,referrerPolicy:this.referrerPolicy_},o,this.color_)}getImage(t){return this.iconImage_.getImage(t)}getPixelRatio(t){return this.iconImage_.getPixelRatio(t)}getImageSize(){return this.iconImage_.getSize()}getImageState(){return this.iconImage_.getImageState()}getHitDetectionImage(){return this.iconImage_.getHitDetectionImage()}getOrigin(){if(this.origin_)return this.origin_;let t=this.offset_;if(this.offsetOrigin_!="top-left"){let e=this.getSize(),i=this.iconImage_.getSize();if(!e||!i)return null;t=t.slice(),(this.offsetOrigin_=="top-right"||this.offsetOrigin_=="bottom-right")&&(t[0]=i[0]-e[0]-t[0]),(this.offsetOrigin_=="bottom-left"||this.offsetOrigin_=="bottom-right")&&(t[1]=i[1]-e[1]-t[1])}return this.origin_=t,this.origin_}getSrc(){return this.iconImage_.getSrc()}setSrc(t){this.iconImage_=Mi(null,t,{crossOrigin:this.crossOrigin_,referrerPolicy:this.referrerPolicy_},W.IDLE,this.color_)}getSize(){return this.size_?this.size_:this.iconImage_.getSize()}getWidth(){let t=this.getScaleArray();if(this.size_)return this.size_[0]*t[0];if(this.iconImage_.getImageState()==W.LOADED)return this.iconImage_.getSize()[0]*t[0]}getHeight(){let t=this.getScaleArray();if(this.size_)return this.size_[1]*t[1];if(this.iconImage_.getImageState()==W.LOADED)return this.iconImage_.getSize()[1]*t[1]}setScale(t){delete this.initialOptions_,super.setScale(t)}listenImageChange(t){this.iconImage_.addEventListener(P.CHANGE,t)}load(){this.iconImage_.load()}unlistenImageChange(t){this.iconImage_.removeEventListener(P.CHANGE,t)}ready(){return this.iconImage_.ready()}},hn=$l;var Jl=class n{constructor(t){t=t||{},this.color_=t.color!==void 0?t.color:null,this.lineCap_=t.lineCap,this.lineDash_=t.lineDash!==void 0?t.lineDash:null,this.lineDashOffset_=t.lineDashOffset,this.lineJoin_=t.lineJoin,this.miterLimit_=t.miterLimit,this.offset_=t.offset,this.width_=t.width}clone(){let t=this.getColor();return new n({color:Array.isArray(t)?t.slice():t||void 0,lineCap:this.getLineCap(),lineDash:this.getLineDash()?this.getLineDash().slice():void 0,lineDashOffset:this.getLineDashOffset(),lineJoin:this.getLineJoin(),miterLimit:this.getMiterLimit(),offset:this.getOffset(),width:this.getWidth()})}getColor(){return this.color_}getLineCap(){return this.lineCap_}getLineDash(){return this.lineDash_}getLineDashOffset(){return this.lineDashOffset_}getLineJoin(){return this.lineJoin_}getMiterLimit(){return this.miterLimit_}getOffset(){return this.offset_}getWidth(){return this.width_}setColor(t){this.color_=t}setLineCap(t){this.lineCap_=t}setLineDash(t){this.lineDash_=t}setLineDashOffset(t){this.lineDashOffset_=t}setLineJoin(t){this.lineJoin_=t}setMiterLimit(t){this.miterLimit_=t}setOffset(t){this.offset_=t}setWidth(t){this.width_=t}},Pt=Jl;var us=class n{constructor(t){t=t||{},this.geometry_=null,this.geometryFunction_=Qd,t.geometry!==void 0&&this.setGeometry(t.geometry),this.fill_=t.fill!==void 0?t.fill:null,this.image_=t.image!==void 0?t.image:null,this.renderer_=t.renderer!==void 0?t.renderer:null,this.hitDetectionRenderer_=t.hitDetectionRenderer!==void 0?t.hitDetectionRenderer:null,this.stroke_=t.stroke!==void 0?t.stroke:null,this.text_=t.text!==void 0?t.text:null,this.zIndex_=t.zIndex}clone(){let t=this.getGeometry();return t&&typeof t=="object"&&(t=t.clone()),new n({geometry:t??void 0,fill:this.getFill()?this.getFill().clone():void 0,image:this.getImage()?this.getImage().clone():void 0,renderer:this.getRenderer()??void 0,stroke:this.getStroke()?this.getStroke().clone():void 0,text:this.getText()?this.getText().clone():void 0,zIndex:this.getZIndex()})}getRenderer(){return this.renderer_}setRenderer(t){this.renderer_=t}setHitDetectionRenderer(t){this.hitDetectionRenderer_=t}getHitDetectionRenderer(){return this.hitDetectionRenderer_}getGeometry(){return this.geometry_}getGeometryFunction(){return this.geometryFunction_}getFill(){return this.fill_}setFill(t){this.fill_=t}getImage(){return this.image_}setImage(t){this.image_=t}getStroke(){return this.stroke_}setStroke(t){this.stroke_=t}getText(){return this.text_}setText(t){this.text_=t}getZIndex(){return this.zIndex_}setGeometry(t){typeof t=="function"?this.geometryFunction_=t:typeof t=="string"?this.geometryFunction_=function(e){return e.get(t)}:t?t!==void 0&&(this.geometryFunction_=function(){return t}):this.geometryFunction_=Qd,this.geometry_=t}setZIndex(t){this.zIndex_=t}};function tf(n){let t;if(typeof n=="function")t=n;else{let e;Array.isArray(n)?e=n:(V(typeof n.getZIndex=="function","Expected an `Style` or an array of `Style`"),e=[n]),t=function(){return e}}return t}var Ql=null;function tc(n,t){if(!Ql){let e=new _t({color:"rgba(255,255,255,0.4)"}),i=new Pt({color:"#3399CC",width:1.25});Ql=[new us({image:new hs({fill:e,stroke:i,radius:5}),fill:e,stroke:i})]}return Ql}function Qd(n){return n.getGeometry()}var It=us;var Om="#333",ec=class n{constructor(t){t=t||{},this.font_=t.font,this.rotation_=t.rotation,this.rotateWithView_=t.rotateWithView,this.keepUpright_=t.keepUpright,this.scale_=t.scale,this.scaleArray_=pt(t.scale!==void 0?t.scale:1),this.text_=t.text,this.textAlign_=t.textAlign,this.justify_=t.justify,this.repeat_=t.repeat,this.textBaseline_=t.textBaseline,this.fill_=t.fill!==void 0?t.fill:new _t({color:Om}),this.maxAngle_=t.maxAngle!==void 0?t.maxAngle:Math.PI/4,this.placement_=t.placement!==void 0?t.placement:"point",this.overflow_=!!t.overflow,this.stroke_=t.stroke!==void 0?t.stroke:null,this.offsetX_=t.offsetX!==void 0?t.offsetX:0,this.offsetY_=t.offsetY!==void 0?t.offsetY:0,this.backgroundFill_=t.backgroundFill?t.backgroundFill:null,this.backgroundStroke_=t.backgroundStroke?t.backgroundStroke:null,this.padding_=t.padding===void 0?null:t.padding,this.declutterMode_=t.declutterMode}clone(){let t=this.getScale();return new n({font:this.getFont(),placement:this.getPlacement(),repeat:this.getRepeat(),maxAngle:this.getMaxAngle(),overflow:this.getOverflow(),rotation:this.getRotation(),rotateWithView:this.getRotateWithView(),keepUpright:this.getKeepUpright(),scale:Array.isArray(t)?t.slice():t,text:this.getText(),textAlign:this.getTextAlign(),justify:this.getJustify(),textBaseline:this.getTextBaseline(),fill:this.getFill()instanceof _t?this.getFill().clone():this.getFill(),stroke:this.getStroke()?this.getStroke().clone():void 0,offsetX:this.getOffsetX(),offsetY:this.getOffsetY(),backgroundFill:this.getBackgroundFill()?this.getBackgroundFill().clone():void 0,backgroundStroke:this.getBackgroundStroke()?this.getBackgroundStroke().clone():void 0,padding:this.getPadding()||void 0,declutterMode:this.getDeclutterMode()})}getOverflow(){return this.overflow_}getFont(){return this.font_}getMaxAngle(){return this.maxAngle_}getPlacement(){return this.placement_}getRepeat(){return this.repeat_}getOffsetX(){return this.offsetX_}getOffsetY(){return this.offsetY_}getFill(){return this.fill_}getRotateWithView(){return this.rotateWithView_}getKeepUpright(){return this.keepUpright_}getRotation(){return this.rotation_}getScale(){return this.scale_}getScaleArray(){return this.scaleArray_}getStroke(){return this.stroke_}getText(){return this.text_}getTextAlign(){return this.textAlign_}getJustify(){return this.justify_}getTextBaseline(){return this.textBaseline_}getBackgroundFill(){return this.backgroundFill_}getBackgroundStroke(){return this.backgroundStroke_}getPadding(){return this.padding_}getDeclutterMode(){return this.declutterMode_}setOverflow(t){this.overflow_=t}setFont(t){this.font_=t}setMaxAngle(t){this.maxAngle_=t}setOffsetX(t){this.offsetX_=t}setOffsetY(t){this.offsetY_=t}setPlacement(t){this.placement_=t}setRepeat(t){this.repeat_=t}setRotateWithView(t){this.rotateWithView_=t}setKeepUpright(t){this.keepUpright_=t}setFill(t){this.fill_=t}setRotation(t){this.rotation_=t}setScale(t){this.scale_=t,this.scaleArray_=pt(t!==void 0?t:1)}setStroke(t){this.stroke_=t}setText(t){this.text_=t}setTextAlign(t){this.textAlign_=t}setJustify(t){this.justify_=t}setTextBaseline(t){this.textBaseline_=t}setBackgroundFill(t){this.backgroundFill_=t}setBackgroundStroke(t){this.backgroundStroke_=t}setPadding(t){this.padding_=t}},li=ec;function Dm(n){return!0}function Fm(n,t){t=t??rs();let e=zm(n,t),i=Yl();return function(r,o){if(i.properties=r.getPropertiesInternal(),i.resolution=o,t.featureId){let s=r.getId();s!==void 0?i.featureId=s:i.featureId=null}return t.geometryType&&(i.geometryType=os(r.getGeometry())),e(i)}}function ef(n,t){t=t??rs();let e=n.length,i=new Array(e);for(let s=0;s<e;++s)i[s]=ic(n[s],t);let r=Yl(),o=new Array(e);return function(s,a){if(r.properties=s.getPropertiesInternal(),r.resolution=a,t.featureId){let h=s.getId();h!==void 0?r.featureId=h:r.featureId=null}t.geometryType&&(r.geometryType=os(s.getGeometry()));let l=0;for(let h=0;h<e;++h){let c=i[h](r);c&&(o[l]=c,l+=1)}return o.length=l,o}}function sf(n,t){if(t=t??rs(),!Array.isArray(n))return ef([n],t);let e=n.length;if("style"in n[0]){let o=new Array(e);for(let s=0;s<e;++s){let a=n[s];if(!("style"in a))throw new Error("Expected a list of rules with a style property");o[s]=a}return Fm(o,t)}return ef(n,t)}function zm(n,t){let e=n.length,i=new Array(e);for(let r=0;r<e;++r){let o=n[r],s="filter"in o?Ce(o.filter,Xt,t):Dm,a;if(Array.isArray(o.style)){let l=o.style.length;a=new Array(l);for(let h=0;h<l;++h)a[h]=ic(o.style[h],t)}else a=[ic(o.style,t)];i[r]={filter:s,styles:a}}return function(r){let o=[],s=!1;for(let a=0;a<e;++a){let l=i[a].filter;if(l(r)&&!(n[a].else&&s)){s=!0;for(let h of i[a].styles){let c=h(r);c&&o.push(c)}}}return o}}function ic(n,t){let e=Kr(n,"",t),i=Zr(n,"",t),r=Nm(n,t),o=Gm(n,t),s=zt(n,"z-index",t);if(!e&&!i&&!r&&!o&&!fe(n))throw new Error("No fill, stroke, point, or text symbolizer properties in style: "+JSON.stringify(n));let a=new It;return function(l){let h=!0;if(e){let c=e(l);c&&(h=!1),a.setFill(c)}if(i){let c=i(l);c&&(h=!1),a.setStroke(c)}if(r){let c=r(l);c&&(h=!1),a.setText(c)}if(o){let c=o(l);c&&(h=!1),a.setImage(c)}return s&&a.setZIndex(s(l)),h?null:a}}function Kr(n,t,e){let i;if(t+"fill-pattern-src"in n)i=Um(n,t+"fill-",e);else{if(n[t+"fill-color"]==="none")return o=>null;i=fs(n,t+"fill-color",e)}if(!i)return null;let r=new _t;return function(o){let s=i(o);return s===Qo?null:(r.setColor(s),r)}}function Zr(n,t,e){let i=zt(n,t+"stroke-width",e),r=fs(n,t+"stroke-color",e);if(!i&&!r)return null;let o=ci(n,t+"stroke-line-cap",e),s=ci(n,t+"stroke-line-join",e),a=af(n,t+"stroke-line-dash",e),l=zt(n,t+"stroke-line-dash-offset",e),h=zt(n,t+"stroke-miter-limit",e),c=zt(n,t+"stroke-offset",e),u=new Pt;return function(f){if(r){let g=r(f);if(g===Qo)return null;u.setColor(g)}if(i&&u.setWidth(i(f)),o){let g=o(f);if(g!=="butt"&&g!=="round"&&g!=="square")throw new Error("Expected butt, round, or square line cap");u.setLineCap(g)}if(s){let g=s(f);if(g!=="bevel"&&g!=="round"&&g!=="miter")throw new Error("Expected bevel, round, or miter line join");u.setLineJoin(g)}return a&&u.setLineDash(a(f)),l&&u.setLineDashOffset(l(f)),h&&u.setMiterLimit(h(f)),c&&u.setOffset(c(f)),u}}function Nm(n,t){let e="text-",i=ci(n,e+"value",t);if(!i)return null;let r=Kr(n,e,t),o=Kr(n,e+"background-",t),s=Zr(n,e,t),a=Zr(n,e+"background-",t),l=ci(n,e+"font",t),h=zt(n,e+"max-angle",t),c=zt(n,e+"offset-x",t),u=zt(n,e+"offset-y",t),f=Vn(n,e+"overflow",t),g=ci(n,e+"placement",t),p=zt(n,e+"repeat",t),_=gs(n,e+"scale",t),m=Vn(n,e+"rotate-with-view",t),x=zt(n,e+"rotation",t),w=ci(n,e+"align",t),v=ci(n,e+"justify",t),y=ci(n,e+"baseline",t),E=Vn(n,e+"keep-upright",t),R=af(n,e+"padding",t),A=ps(n,e+"declutter-mode"),S=new li({declutterMode:A});return function(T){if(S.setText(i(T)),r&&S.setFill(r(T)),o&&S.setBackgroundFill(o(T)),s&&S.setStroke(s(T)),a&&S.setBackgroundStroke(a(T)),l&&S.setFont(l(T)),h&&S.setMaxAngle(h(T)),c&&S.setOffsetX(c(T)),u&&S.setOffsetY(u(T)),f&&S.setOverflow(f(T)),g){let I=g(T);if(I!=="point"&&I!=="line")throw new Error("Expected point or line for text-placement");S.setPlacement(I)}if(p&&S.setRepeat(p(T)),_&&S.setScale(_(T)),m&&S.setRotateWithView(m(T)),x&&S.setRotation(x(T)),w){let I=w(T);if(I!=="left"&&I!=="center"&&I!=="right"&&I!=="end"&&I!=="start")throw new Error("Expected left, right, center, start, or end for text-align");S.setTextAlign(I)}if(v){let I=v(T);if(I!=="left"&&I!=="right"&&I!=="center")throw new Error("Expected left, right, or center for text-justify");S.setJustify(I)}if(y){let I=y(T);if(I!=="bottom"&&I!=="top"&&I!=="middle"&&I!=="alphabetic"&&I!=="hanging")throw new Error("Expected bottom, top, middle, alphabetic, or hanging for text-baseline");S.setTextBaseline(I)}return R&&S.setPadding(R(T)),E&&S.setKeepUpright(E(T)),S}}function Gm(n,t){return"icon-src"in n?Xm(n,t):"shape-points"in n?Wm(n,t):"circle-radius"in n?Ym(n,t):null}function Xm(n,t){let e="icon-",i=e+"src",r=lf(n[i],i),o=ds(n,e+"anchor",t),s=gs(n,e+"scale",t),a=zt(n,e+"opacity",t),l=ds(n,e+"displacement",t),h=zt(n,e+"rotation",t),c=Vn(n,e+"rotate-with-view",t),u=rf(n,e+"anchor-origin"),f=of(n,e+"anchor-x-units"),g=of(n,e+"anchor-y-units"),p=hi(n,e+"color"),_,m=null;p!==void 0&&(Array.isArray(p)&&p.length>0&&typeof p[0]=="string"?m=fs(n,e+"color",t):_=cf(p,e+"color"));let x=Zm(n,e+"cross-origin"),w=Vm(n,e+"offset"),v=rf(n,e+"offset-origin"),y=nc(n,e+"width"),E=nc(n,e+"height"),R=Km(n,e+"size"),A=ps(n,e+"declutter-mode"),S={src:r,anchorOrigin:u,anchorXUnits:f,anchorYUnits:g,crossOrigin:x,offset:w,offsetOrigin:v,height:E,width:y,size:R,declutterMode:A},T=null;return function(I){if(T)m&&T.setColor(m(I));else{let z=m?m(I):_;T=new hn(z!==void 0?Object.assign({},S,{color:z}):Object.assign({},S))}return a&&T.setOpacity(a(I)),l&&T.setDisplacement(l(I)),h&&T.setRotation(h(I)),c&&T.setRotateWithView(c(I)),s&&T.setScale(s(I)),o&&T.setAnchor(o(I)),T}}function Wm(n,t){let e="shape-",i=e+"points",r=e+"radius",o=rc(n[i],i);if(!(r in n))throw new Error(`Expected a number for ${r}`);let s=zt(n,r,t),a=typeof n[r]=="number"?n[r]:5,l=e+"radius2",h=zt(n,l,t),c=typeof n[l]=="number"?n[l]:void 0,u=Kr(n,e,t),f=Zr(n,e,t),g=gs(n,e+"scale",t),p=ds(n,e+"displacement",t),_=zt(n,e+"rotation",t),m=Vn(n,e+"rotate-with-view",t),x=nc(n,e+"angle"),w=ps(n,e+"declutter-mode"),v=new cs({points:o,radius:a,radius2:c,angle:x,declutterMode:w});return function(y){return s&&v.setRadius(s(y)),h&&v.setRadius2(h(y)),u&&v.setFill(u(y)),f&&v.setStroke(f(y)),p&&v.setDisplacement(p(y)),_&&v.setRotation(_(y)),m&&v.setRotateWithView(m(y)),g&&v.setScale(g(y)),v}}function Ym(n,t){let e="circle-",i=Kr(n,e,t),r=Zr(n,e,t),o=zt(n,e+"radius",t),s=gs(n,e+"scale",t),a=ds(n,e+"displacement",t),l=zt(n,e+"rotation",t),h=Vn(n,e+"rotate-with-view",t),c=ps(n,e+"declutter-mode"),u=new hs({radius:5,declutterMode:c});return function(f){return o&&u.setRadius(o(f)),i&&u.setFill(i(f)),r&&u.setStroke(r(f)),a&&u.setDisplacement(a(f)),l&&u.setRotation(l(f)),h&&u.setRotateWithView(h(f)),s&&u.setScale(s(f)),u}}function hi(n,t){if(!(t in n))return;let e=n[t];return e===void 0?void 0:e}function zt(n,t,e){let i=hi(n,t);if(i===void 0)return;let r=Ce(i,Q,e);return function(o){return rc(r(o),t)}}function ci(n,t,e){let i=hi(n,t);if(i===void 0)return null;let r=Ce(i,Wt,e);return function(o){return lf(r(o),t)}}function Um(n,t,e){let i=ci(n,t+"pattern-src",e),r=nf(n,t+"pattern-offset",e),o=nf(n,t+"pattern-size",e),s=fs(n,t+"color",e);return function(a){return{src:i(a),offset:r&&r(a),size:o&&o(a),color:s&&s(a)}}}function Vn(n,t,e){let i=hi(n,t);if(i===void 0)return null;let r=Ce(i,Xt,e);return function(o){let s=r(o);if(typeof s!="boolean")throw new Error(`Expected a boolean for ${t}`);return s}}function fs(n,t,e){let i=hi(n,t);if(i===void 0)return null;let r=Ce(i,Zt,e);return function(o){return cf(r(o),t)}}function af(n,t,e){let i=hi(n,t);if(i===void 0)return null;if(Array.isArray(i)&&(i.length===0||typeof i[0]!="string")){let o=i.map((s,a)=>{if(typeof s=="number")return()=>s;let l=Ce(s,Q,e);return function(h){return rc(l(h),`${t}[${a}]`)}});return function(s){let a=new Array(o.length);for(let l=0;l<o.length;++l)a[l]=o[l](s);return a}}let r=Ce(i,ri,e);return function(o){return Vr(r(o),t)}}function ds(n,t,e){let i=hi(n,t);if(i===void 0)return null;let r=Ce(i,ri,e);return function(o){let s=Vr(r(o),t);if(s.length!==2)throw new Error(`Expected two numbers for ${t}`);return s}}function nf(n,t,e){let i=hi(n,t);if(i===void 0)return null;let r=Ce(i,ri,e);return function(o){return hf(r(o),t)}}function gs(n,t,e){let i=hi(n,t);if(i===void 0)return null;let r=Ce(i,ri|Q,e);return function(o){return Bm(r(o),t)}}function nc(n,t){let e=n[t];if(e!==void 0){if(typeof e!="number")throw new Error(`Expected a number for ${t}`);return e}}function Km(n,t){let e=n[t];if(e!==void 0){if(typeof e=="number")return pt(e);if(!Array.isArray(e))throw new Error(`Expected a number or size array for ${t}`);if(e.length!==2||typeof e[0]!="number"||typeof e[1]!="number")throw new Error(`Expected a number or size array for ${t}`);return e}}function Zm(n,t){let e=n[t];if(e!==void 0){if(typeof e!="string")throw new Error(`Expected a string for ${t}`);return e}}function rf(n,t){let e=n[t];if(e!==void 0){if(e!=="bottom-left"&&e!=="bottom-right"&&e!=="top-left"&&e!=="top-right")throw new Error(`Expected bottom-left, bottom-right, top-left, or top-right for ${t}`);return e}}function of(n,t){let e=n[t];if(e!==void 0){if(e!=="pixels"&&e!=="fraction")throw new Error(`Expected pixels or fraction for ${t}`);return e}}function Vm(n,t){let e=n[t];if(e!==void 0)return Vr(e,t)}function ps(n,t){let e=n[t];if(e!==void 0){if(typeof e!="string")throw new Error(`Expected a string for ${t}`);if(e!=="declutter"&&e!=="obstacle"&&e!=="none")throw new Error(`Expected declutter, obstacle, or none for ${t}`);return e}}function Vr(n,t){if(!Array.isArray(n))throw new Error(`Expected an array for ${t}`);let e=n.length;for(let i=0;i<e;++i)if(typeof n[i]!="number")throw new Error(`Expected an array of numbers for ${t}`);return n}function lf(n,t){if(typeof n!="string")throw new Error(`Expected a string for ${t}`);return n}function rc(n,t){if(typeof n!="number")throw new Error(`Expected a number for ${t}`);return n}function cf(n,t){if(typeof n=="string")return n;let e=Vr(n,t),i=e.length;if(i<3||i>4)throw new Error(`Expected a color with 3 or 4 values for ${t}`);return e}function hf(n,t){let e=Vr(n,t);if(e.length!==2)throw new Error(`Expected an array of two numbers for ${t}`);return e}function Bm(n,t){return typeof n=="number"?n:hf(n,t)}var uf={RENDER_ORDER:"renderOrder"},oc=class extends rn{constructor(t){t=t||{};let e=Object.assign({},t);delete e.style,delete e.renderBuffer,delete e.updateWhileAnimating,delete e.updateWhileInteracting,super(e),this.declutter_=t.declutter?String(t.declutter):void 0,this.renderBuffer_=t.renderBuffer!==void 0?t.renderBuffer:100,this.style_=null,this.styleFunction_=void 0,this.setStyle(t.style),this.updateWhileAnimating_=t.updateWhileAnimating!==void 0?t.updateWhileAnimating:!1,this.updateWhileInteracting_=t.updateWhileInteracting!==void 0?t.updateWhileInteracting:!1}getDeclutter(){return this.declutter_}getFeatures(t){return super.getFeatures(t)}getRenderBuffer(){return this.renderBuffer_}getRenderOrder(){return this.get(uf.RENDER_ORDER)}getStyle(){return this.style_}getStyleFunction(){return this.styleFunction_}getUpdateWhileAnimating(){return this.updateWhileAnimating_}getUpdateWhileInteracting(){return this.updateWhileInteracting_}renderDeclutter(t,e){let i=this.getDeclutter();i in t.declutter||(t.declutter[i]=new on(9)),this.getRenderer().renderDeclutter(t,e)}setRenderOrder(t){this.set(uf.RENDER_ORDER,t)}setStyle(t){this.style_=t===void 0?tc:t;let e=jm(t);this.styleFunction_=t===null?void 0:tf(e),this.changed()}setDeclutter(t){this.declutter_=t?String(t):void 0,this.changed()}};function jm(n){if(n===void 0)return tc;if(!n)return null;if(typeof n=="function"||n instanceof It)return n;if(Array.isArray(n)&&n.length===0)return[];if(Array.isArray(n)&&n[0]instanceof It){let e=n.length,i=new Array(e);for(let r=0;r<e;++r){let o=n[r];if(!(o instanceof It))throw new Error("Expected a list of style instances");i[r]=o}return i}return sf(n)}var ms=oc;var sc=class extends Lt{constructor(t,e,i,r){super(t),this.inversePixelTransform=e,this.frameState=i,this.context=r}},_s=sc;var ac=class extends _i{constructor(t){super(),this.map_=t}dispatchRenderEvent(t,e){H()}calculateMatrices2D(t){let e=t.viewState,i=t.coordinateToPixelTransform,r=t.pixelToCoordinateTransform;Dt(i,t.size[0]/2,t.size[1]/2,1/e.resolution,-1/e.resolution,-e.rotation,-e.center[0],-e.center[1]),Mo(r,i)}forEachFeatureAtCoordinate(t,e,i,r,o,s,a,l){let h,c=e.viewState;function u(y,E,R,A){return o.call(s,E,y?R:null,A)}let f=c.projection,g=Eo(t.slice(),f),p=[[0,0]];if(f.canWrapX()&&r){let y=f.getExtent(),E=j(y);p.push([-E,0],[E,0])}let _=e.layerStatesArray,m=_.length,x=[],w=[];for(let y=0;y<p.length;y++)for(let E=m-1;E>=0;--E){let R=_[E],A=R.layer;if(A.hasRenderer()&&Pr(R,c)&&a.call(l,A)){let S=A.getRenderer(),T=A.getSource();if(S&&T){let I=T.getWrapX()?g:t,z=u.bind(null,R.managed);w[0]=I[0]+p[y][0],w[1]=I[1]+p[y][1],h=S.forEachFeatureAtCoordinate(w,e,i,z,x)}if(h)return h}}if(x.length===0)return;let v=1/x.length;return x.forEach((y,E)=>y.distanceSq+=E*v),x.sort((y,E)=>y.distanceSq-E.distanceSq),x.some(y=>h=y.callback(y.feature,y.layer,y.geometry)),h}hasFeatureAtCoordinate(t,e,i,r,o,s){return this.forEachFeatureAtCoordinate(t,e,i,r,$e,this,o,s)!==void 0}getMap(){return this.map_}renderFrame(t){H()}scheduleExpireIconCache(t){Yt.canExpireCache()&&t.postRenderFunctions.push(Hm)}};function Hm(n,t){Yt.expire()}var df=ac;var lc=class extends df{constructor(t){super(t),this.fontChangeListenerKey_=Z(ln,de.PROPERTYCHANGE,t.redrawText,t),this.element_=St?Xo():document.createElement("div");let e=this.element_.style;e.position="absolute",e.width="100%",e.height="100%",e.zIndex="0",this.element_.className=Ti+" ol-layers";let i=t.getViewport();i&&i.insertBefore(this.element_,i.firstChild||null),this.children_=[],this.renderedVisible_=!0}dispatchRenderEvent(t,e){let i=this.getMap();if(i.hasListener(t)){let r=new _s(t,void 0,e);i.dispatchEvent(r)}}disposeInternal(){J(this.fontChangeListenerKey_),this.element_.remove(),super.disposeInternal()}renderFrame(t){if(!t){this.renderedVisible_&&(this.element_.style.display="none",this.renderedVisible_=!1);return}this.calculateMatrices2D(t),this.dispatchRenderEvent(Ft.PRECOMPOSE,t);let e=t.layerStatesArray.sort((c,u)=>c.zIndex-u.zIndex);e.some(c=>c.layer instanceof ms&&c.layer.getDeclutter())&&(t.declutter={});let r=t.viewState;this.children_.length=0;let s=this.getMap().getTargetElement(),a;ee(s)&&(a=s.getContext("2d"),a.setTransform(1,0,0,1,0,0),a.clearRect(0,0,s.width,s.height));let l=[],h=a?s:null;for(let c=0,u=e.length;c<u;++c){let f=e[c];t.layerIndex=c;let g=f.layer,p=g.getSourceState();if(!Pr(f,r)||p!="ready"&&p!="undefined"){g.unrender();continue}let _=g.render(t,h);_&&(_!==h&&(this.children_.push(_),h=_),l.push(f))}this.declutter(t,l),hd(this.element_,this.children_);for(let c of a?this.children_:[]){let u=c.firstElementChild||c,f=c.style.backgroundColor;if(f&&(!ee(u)||u.width>0)&&(a.fillStyle=f,a.fillRect(0,0,a.canvas.width,a.canvas.height)),!ee(u)||u.width===0)continue;a.save();let g=c.style.opacity||u.style.opacity;a.globalAlpha=g===""?1:Number(g);let p=u.style.transform;if(p)a.transform(...Ao(p));else{let _=parseFloat(u.style.width)/u.width,m=parseFloat(u.style.height)/u.height;a.transform(_,0,0,m,0,0)}a.drawImage(u,0,0),a.restore()}this.dispatchRenderEvent(Ft.POSTCOMPOSE,t),this.renderedVisible_||(this.element_.style.display="",this.renderedVisible_=!0),this.scheduleExpireIconCache(t)}declutter(t,e){if(t.declutter){for(let i=e.length-1;i>=0;--i){let r=e[i],o=r.layer;o.getDeclutter()&&o.renderDeclutter(t,r)}e.forEach(i=>i.layer.renderDeferred(t))}}},ff=lc;function gf(n){if(n instanceof rn){n.setMapInternal(null);return}n instanceof Mr&&n.getLayers().forEach(gf)}function pf(n,t){if(n instanceof rn){n.setMapInternal(t);return}if(n instanceof Mr){let e=n.getLayers().getArray();for(let i=0,r=e.length;i<r;++i)pf(e[i],t)}}var cc=class extends yt{constructor(t){super(),t=t||{},this.on,this.once,this.un;let e=qm(t);this.renderComplete_=!1,this.loaded_=!0,this.boundHandleBrowserEvent_=this.handleBrowserEvent.bind(this),this.maxTilesLoading_=t.maxTilesLoading!==void 0?t.maxTilesLoading:16,this.pixelRatio_=t.pixelRatio!==void 0?t.pixelRatio:Vh,this.postRenderTimeoutHandle_,this.animationDelayKey_,this.animationDelay_=this.animationDelay_.bind(this),this.coordinateToPixelTransform_=Mt(),this.pixelToCoordinateTransform_=Mt(),this.frameIndex_=0,this.frameState_=null,this.previousExtent_=null,this.viewPropertyListenerKey_=null,this.viewChangeListenerKey_=null,this.layerGroupPropertyListenerKeys_=null,St||(this.viewport_=document.createElement("div"),this.viewport_.className="ol-viewport"+("ontouchstart"in window?" ol-touch":""),this.viewport_.style.position="relative",this.viewport_.style.overflow="hidden",this.viewport_.style.width="100%",this.viewport_.style.height="100%",this.overlayContainer_=document.createElement("div"),this.overlayContainer_.style.position="absolute",this.overlayContainer_.style.zIndex="0",this.overlayContainer_.style.width="100%",this.overlayContainer_.style.height="100%",this.overlayContainer_.style.pointerEvents="none",this.overlayContainer_.className="ol-overlaycontainer",this.viewport_.appendChild(this.overlayContainer_),this.overlayContainerStopEvent_=document.createElement("div"),this.overlayContainerStopEvent_.style.position="absolute",this.overlayContainerStopEvent_.style.zIndex="0",this.overlayContainerStopEvent_.style.width="100%",this.overlayContainerStopEvent_.style.height="100%",this.overlayContainerStopEvent_.style.pointerEvents="none",this.overlayContainerStopEvent_.className="ol-overlaycontainer-stopevent",this.viewport_.appendChild(this.overlayContainerStopEvent_)),this.mapBrowserEventHandler_=null,this.moveTolerance_=t.moveTolerance,this.keyboardEventTarget_=e.keyboardEventTarget,this.targetChangeHandlerKeys_=null,this.targetElement_=null,St||(this.resizeObserver_=new ResizeObserver(()=>this.updateSize())),this.controls=e.controls||(St?new kt:Wo()),this.interactions=e.interactions||(St?new kt:Bo({onFocusOnly:!0})),this.overlays_=e.overlays,this.overlayIdIndex_={},this.renderer_=null,this.postRenderFunctions_=[],this.tileQueue_=new Hh(this.getTilePriority.bind(this),this.handleTileChange_.bind(this)),this.addChangeListener(Ot.LAYERGROUP,this.handleLayerGroupChanged_),this.addChangeListener(Ot.VIEW,this.handleViewChanged_),this.addChangeListener(Ot.SIZE,this.handleSizeChanged_),this.addChangeListener(Ot.TARGET,this.handleTargetChanged_),this.setProperties(e.values);let i=this;t.view&&!(t.view instanceof te)&&t.view.then(function(r){i.setView(new te(r))}),this.controls.addEventListener(At.ADD,r=>{r.element.setMap(this)}),this.controls.addEventListener(At.REMOVE,r=>{r.element.setMap(null)}),this.interactions.addEventListener(At.ADD,r=>{r.element.setMap(this)}),this.interactions.addEventListener(At.REMOVE,r=>{r.element.setMap(null)}),this.overlays_.addEventListener(At.ADD,r=>{this.addOverlayInternal_(r.element)}),this.overlays_.addEventListener(At.REMOVE,r=>{let o=r.element.getId();o!==void 0&&delete this.overlayIdIndex_[o.toString()],r.element.setMap(null)}),this.controls.forEach(r=>{r.setMap(this)}),this.interactions.forEach(r=>{r.setMap(this)}),this.overlays_.forEach(this.addOverlayInternal_.bind(this))}addControl(t){this.getControls().push(t)}addInteraction(t){this.getInteractions().push(t)}addLayer(t){this.getLayerGroup().getLayers().push(t)}handleLayerAdd_(t){pf(t.layer,this)}addOverlay(t){this.getOverlays().push(t)}addOverlayInternal_(t){let e=t.getId();e!==void 0&&(this.overlayIdIndex_[e.toString()]=t),t.setMap(this)}disposeInternal(){this.controls.clear(),this.interactions.clear(),this.overlays_.clear(),this.resizeObserver_?.disconnect(),this.setTarget(null),super.disposeInternal()}forEachFeatureAtPixel(t,e,i){if(!this.frameState_||!this.renderer_)return;let r=this.getCoordinateFromPixelInternal(t);i=i!==void 0?i:{};let o=i.hitTolerance!==void 0?i.hitTolerance:0,s=i.layerFilter!==void 0?i.layerFilter:$e,a=i.checkWrapped!==!1;return this.renderer_.forEachFeatureAtCoordinate(r,this.frameState_,o,a,e,null,s,null)}getFeaturesAtPixel(t,e){let i=[];return this.forEachFeatureAtPixel(t,function(r){i.push(r)},e),i}getAllLayers(){let t=[];function e(i){i.forEach(function(r){r instanceof Mr?e(r.getLayers()):t.push(r)})}return e(this.getLayers()),t}hasFeatureAtPixel(t,e){if(!this.frameState_||!this.renderer_)return!1;let i=this.getCoordinateFromPixelInternal(t);e=e!==void 0?e:{};let r=e.layerFilter!==void 0?e.layerFilter:$e,o=e.hitTolerance!==void 0?e.hitTolerance:0,s=e.checkWrapped!==!1;return this.renderer_.hasFeatureAtCoordinate(i,this.frameState_,o,s,r,null)}getEventCoordinate(t){return this.getCoordinateFromPixel(this.getEventPixel(t))}getEventCoordinateInternal(t){return this.getCoordinateFromPixelInternal(this.getEventPixel(t))}getEventPixel(t){let i=this.viewport_.getBoundingClientRect(),r=this.getSize(),o=i.width/r[0],s=i.height/r[1],a="changedTouches"in t?t.changedTouches[0]:t;return[(a.clientX-i.left)/o,(a.clientY-i.top)/s]}getTarget(){return this.get(Ot.TARGET)}getTargetElement(){return this.targetElement_}getCoordinateFromPixel(t){return Er(this.getCoordinateFromPixelInternal(t),this.getView().getProjection())}getCoordinateFromPixelInternal(t){let e=this.frameState_;return e?dt(e.pixelToCoordinateTransform,t.slice()):null}getControls(){return this.controls}getOverlays(){return this.overlays_}getOverlayById(t){let e=this.overlayIdIndex_[t.toString()];return e!==void 0?e:null}getInteractions(){return this.interactions}getLayerGroup(){return this.get(Ot.LAYERGROUP)}setLayers(t){let e=this.getLayerGroup();if(t instanceof kt){e.setLayers(t);return}let i=e.getLayers();i.clear(),i.extend(t)}getLayers(){return this.getLayerGroup().getLayers()}getLoadingOrNotReady(){let t=this.getLayerGroup().getLayerStatesArray();for(let e=0,i=t.length;e<i;++e){let r=t[e];if(!r.visible)continue;let o=r.layer.getRenderer();if(o&&!o.ready)return!0;let s=r.layer.getSource();if(s&&s.loading)return!0}return!1}getPixelFromCoordinate(t){let e=ye(t,this.getView().getProjection());return this.getPixelFromCoordinateInternal(e)}getPixelFromCoordinateInternal(t){let e=this.frameState_;return e?dt(e.coordinateToPixelTransform,t.slice(0,2)):null}getPixelRatio(){return this.pixelRatio_}setPixelRatio(t){this.pixelRatio_!==t&&(this.pixelRatio_=t,this.render())}getRenderer(){return this.renderer_}getSize(){return this.get(Ot.SIZE)}getView(){return this.get(Ot.VIEW)}getViewport(){return this.viewport_}getOverlayContainer(){return this.overlayContainer_}getOverlayContainerStopEvent(){return this.overlayContainerStopEvent_}getOwnerDocument(){let t=this.getTargetElement();return t?t.ownerDocument:document}getTilePriority(t,e,i,r){return qh(this.frameState_,t,e,i,r)}handleBrowserEvent(t,e){e=e||t.type;let i=new Ae(e,this,t);this.handleMapBrowserEvent(i)}handleMapBrowserEvent(t){if(!this.frameState_)return;let e=t.originalEvent,i=e.type;if(i===fr.POINTERDOWN||i===P.WHEEL||i===P.KEYDOWN){let r=this.getOwnerDocument(),o=this.viewport_.getRootNode?this.viewport_.getRootNode():r,s=e.target,a=o instanceof ShadowRoot?o.host===s?o.host.ownerDocument:o:o===r?r.documentElement:o;if(this.overlayContainerStopEvent_.contains(s)||!a.contains(s))return}if(t.frameState=this.frameState_,this.dispatchEvent(t)!==!1){let r=this.getInteractions().getArray().slice();for(let o=r.length-1;o>=0;o--){let s=r[o];if(s.getMap()!==this||!s.getActive()||!this.getTargetElement())continue;if(!s.handleEvent(t)||t.propagationStopped)break}}}handlePostRender(){let t=this.frameState_,e=this.tileQueue_;if(!e.isEmpty()){let r=this.maxTilesLoading_,o=r,s=t?t.viewHints:void 0,a=s?s[Rt.ANIMATING]||s[Rt.INTERACTING]:!1;if(a){let l=Date.now()-t.time>8;r=l?0:8,o=l?0:2}e.getTilesLoading()<r&&(a&&e.reprioritize(),e.loadMoreTiles(r,o))}t&&this.renderer_&&!t.animate&&(this.renderComplete_?(this.hasListener(Ft.RENDERCOMPLETE)&&this.renderer_.dispatchRenderEvent(Ft.RENDERCOMPLETE,t),this.loaded_===!1&&(this.loaded_=!0,this.dispatchEvent(new yi(Me.LOADEND,this,t)))):this.loaded_===!0&&(this.loaded_=!1,this.dispatchEvent(new yi(Me.LOADSTART,this,t))));let i=this.postRenderFunctions_;if(t)for(let r=0,o=i.length;r<o;++r)i[r](this,t);i.length=0}handleSizeChanged_(){this.getView()&&!this.getView().getAnimating()&&this.getView().resolveConstraints(0),this.render()}handleTargetChanged_(){if(this.mapBrowserEventHandler_){for(let i=0,r=this.targetChangeHandlerKeys_.length;i<r;++i)J(this.targetChangeHandlerKeys_[i]);this.targetChangeHandlerKeys_=null,this.viewport_.removeEventListener(P.CONTEXTMENU,this.boundHandleBrowserEvent_),this.viewport_.removeEventListener(P.WHEEL,this.boundHandleBrowserEvent_),this.mapBrowserEventHandler_.dispose(),this.mapBrowserEventHandler_=null,this.viewport_.remove()}if(this.targetElement_&&!ee(this.targetElement_)){this.resizeObserver_?.unobserve(this.targetElement_);let i=this.targetElement_.getRootNode();i instanceof ShadowRoot&&this.resizeObserver_.unobserve(i.host),this.setSize(void 0)}let t=this.getTarget(),e=typeof t=="string"?document.getElementById(t):t;if(this.targetElement_=e,!e)this.renderer_&&(clearTimeout(this.postRenderTimeoutHandle_),this.postRenderTimeoutHandle_=void 0,this.postRenderFunctions_.length=0,this.renderer_.dispose(),this.renderer_=null),this.animationDelayKey_&&(cancelAnimationFrame(this.animationDelayKey_),this.animationDelayKey_=void 0);else{if(ee(e)||e.appendChild(this.viewport_),this.renderer_||(this.renderer_=new ff(this)),!ee(e)){this.mapBrowserEventHandler_=new Bh(this,this.moveTolerance_);for(let r in at)this.mapBrowserEventHandler_.addEventListener(at[r],this.handleMapBrowserEvent.bind(this));this.viewport_.addEventListener(P.CONTEXTMENU,this.boundHandleBrowserEvent_,!1),this.viewport_.addEventListener(P.WHEEL,this.boundHandleBrowserEvent_,uo?{passive:!1}:!1);let i;if(this.keyboardEventTarget_)i=this.keyboardEventTarget_;else{let r=e.getRootNode();i=r instanceof ShadowRoot?r.host:e}if(this.targetChangeHandlerKeys_=[Z(i,P.KEYDOWN,this.handleBrowserEvent,this),Z(i,P.KEYPRESS,this.handleBrowserEvent,this)],!ee(e)){let r=e.getRootNode();r instanceof ShadowRoot&&this.resizeObserver_.observe(r.host),this.resizeObserver_?.observe(e)}}this.updateSize()}}handleTileChange_(){this.render()}handleViewPropertyChanged_(){this.render()}handleViewChanged_(){this.viewPropertyListenerKey_&&(J(this.viewPropertyListenerKey_),this.viewPropertyListenerKey_=null),this.viewChangeListenerKey_&&(J(this.viewChangeListenerKey_),this.viewChangeListenerKey_=null);let t=this.getView();t&&(this.updateViewportSize_(this.getSize()),this.viewPropertyListenerKey_=Z(t,de.PROPERTYCHANGE,this.handleViewPropertyChanged_,this),this.viewChangeListenerKey_=Z(t,P.CHANGE,this.handleViewPropertyChanged_,this),t.resolveConstraints(0)),this.render()}handleLayerGroupChanged_(){this.layerGroupPropertyListenerKeys_&&(this.layerGroupPropertyListenerKeys_.forEach(J),this.layerGroupPropertyListenerKeys_=null);let t=this.getLayerGroup();t&&(this.handleLayerAdd_(new Ee("addlayer",t)),this.layerGroupPropertyListenerKeys_=[Z(t,de.PROPERTYCHANGE,this.render,this),Z(t,P.CHANGE,this.render,this),Z(t,"addlayer",this.handleLayerAdd_,this),Z(t,"removelayer",this.handleLayerRemove_,this)]),this.render()}isRendered(){return!!this.frameState_}animationDelay_(){this.animationDelayKey_=void 0,this.renderFrame_(Date.now())}renderSync(){this.animationDelayKey_&&cancelAnimationFrame(this.animationDelayKey_),this.animationDelay_()}redrawText(){if(!this.frameState_)return;let t=this.frameState_.layerStatesArray;for(let e=0,i=t.length;e<i;++e){let r=t[e].layer;r.hasRenderer()&&r.getRenderer().handleFontsChanged()}}render(){this.renderer_&&this.animationDelayKey_===void 0&&(this.animationDelayKey_=requestAnimationFrame(this.animationDelay_))}removeControl(t){return this.getControls().remove(t)}removeInteraction(t){return this.getInteractions().remove(t)}removeLayer(t){return this.getLayerGroup().getLayers().remove(t)}handleLayerRemove_(t){gf(t.layer)}removeOverlay(t){return this.getOverlays().remove(t)}renderFrame_(t){let e=this.getSize(),i=this.getView(),r=this.frameState_,o=null;if(e!==void 0&&Gl(e)&&i&&i.isDef()){let s=i.getHints(this.frameState_?this.frameState_.viewHints:void 0),a=i.getState();if(o={animate:!1,coordinateToPixelTransform:this.coordinateToPixelTransform_,declutter:null,extent:yr(a.center,a.resolution,a.rotation,e),index:this.frameIndex_++,layerIndex:0,layerStatesArray:this.getLayerGroup().getLayerStatesArray(),pixelRatio:this.pixelRatio_,pixelToCoordinateTransform:this.pixelToCoordinateTransform_,postRenderFunctions:[],size:e,tileQueue:this.tileQueue_,time:t,usedTiles:{},viewState:a,viewHints:s,wantedTiles:{},mapId:U(this),renderTargets:{}},a.nextCenter&&a.nextResolution){let l=isNaN(a.nextRotation)?a.rotation:a.nextRotation;o.nextExtent=yr(a.nextCenter,a.nextResolution,l,e)}}this.frameState_=o,this.renderer_.renderFrame(o),o&&(o.animate&&this.render(),Array.prototype.push.apply(this.postRenderFunctions_,o.postRenderFunctions),r&&(!this.previousExtent_||!De(this.previousExtent_)&&!ji(o.extent,this.previousExtent_))&&(this.dispatchEvent(new yi(Me.MOVESTART,this,r)),this.previousExtent_=Bi(this.previousExtent_)),this.previousExtent_&&!o.viewHints[Rt.ANIMATING]&&!o.viewHints[Rt.INTERACTING]&&!ji(o.extent,this.previousExtent_)&&(this.dispatchEvent(new yi(Me.MOVEEND,this,o)),mo(o.extent,this.previousExtent_))),this.dispatchEvent(new yi(Me.POSTRENDER,this,o)),this.renderComplete_=(this.hasListener(Me.LOADSTART)||this.hasListener(Me.LOADEND)||this.hasListener(Ft.RENDERCOMPLETE))&&!this.tileQueue_.getTilesLoading()&&!this.tileQueue_.getCount()&&!this.getLoadingOrNotReady(),this.postRenderTimeoutHandle_||(this.postRenderTimeoutHandle_=setTimeout(()=>{this.postRenderTimeoutHandle_=void 0,this.handlePostRender()},0))}setLayerGroup(t){let e=this.getLayerGroup();e&&this.handleLayerRemove_(new Ee("removelayer",e)),this.set(Ot.LAYERGROUP,t)}setSize(t){this.set(Ot.SIZE,t)}setTarget(t){this.set(Ot.TARGET,t)}setView(t){if(!t||t instanceof te){this.set(Ot.VIEW,t);return}this.set(Ot.VIEW,new te);let e=this;t.then(function(i){e.setView(new te(i))})}updateSize(){let t=this.getTargetElement(),e;if(t){let r,o;if(ee(t)){let s=t.getContext("2d").getTransform();r=t.width/s.a,o=t.height/s.d}else{let s=getComputedStyle(t);r=t.offsetWidth-parseFloat(s.borderLeftWidth)-parseFloat(s.paddingLeft)-parseFloat(s.paddingRight)-parseFloat(s.borderRightWidth),o=t.offsetHeight-parseFloat(s.borderTopWidth)-parseFloat(s.paddingTop)-parseFloat(s.paddingBottom)-parseFloat(s.borderBottomWidth)}!isNaN(r)&&!isNaN(o)&&(e=[Math.max(0,r),Math.max(0,o)],!Gl(e)&&(t.offsetWidth||t.offsetHeight||t.getClientRects().length)&&vo("No map visible because the map container's width or height are 0."))}let i=this.getSize();e&&(!i||!Nt(e,i))&&(this.updateViewportSize_(e),this.setSize(e))}updateViewportSize_(t){let e=this.getView();e&&e.setViewportSize(t)}};function qm(n){let t=null;n.keyboardEventTarget!==void 0&&(t=typeof n.keyboardEventTarget=="string"?document.getElementById(n.keyboardEventTarget):n.keyboardEventTarget);let e={},i=n.layers&&typeof n.layers.getLayers=="function"?n.layers:new Mr({layers:n.layers});e[Ot.LAYERGROUP]=i,e[Ot.TARGET]=n.target,e[Ot.VIEW]=n.view instanceof te?n.view:new te;let r;n.controls!==void 0&&(Array.isArray(n.controls)?r=new kt(n.controls.slice()):(V(typeof n.controls.getArray=="function","Expected `controls` to be an array or an `ol/Collection.js`"),r=n.controls));let o;n.interactions!==void 0&&(Array.isArray(n.interactions)?o=new kt(n.interactions.slice()):(V(typeof n.interactions.getArray=="function","Expected `interactions` to be an array or an `ol/Collection.js`"),o=n.interactions));let s;return n.overlays!==void 0?Array.isArray(n.overlays)?s=new kt(n.overlays.slice()):(V(typeof n.overlays.getArray=="function","Expected `overlays` to be an array or an `ol/Collection.js`"),s=n.overlays):s=new kt,{controls:r,interactions:o,keyboardEventTarget:t,overlays:s,values:e}}var mf=cc;var hc=class n extends Fe{constructor(t,e){super(),e&&!Array.isArray(t[0])?this.setFlatCoordinates(e,t):this.setCoordinates(t,e)}appendPoint(t){ge(this.flatCoordinates,t.getFlatCoordinates()),this.changed()}clone(){let t=new n(this.flatCoordinates.slice(),this.layout);return t.applyProperties(this),t}closestPointXY(t,e,i,r){if(r<wi(this.getExtent(),t,e))return r;let o=this.flatCoordinates,s=this.stride;for(let a=0,l=o.length;a<l;a+=s){let h=pe(t,e,o[a],o[a+1]);if(h<r){r=h;for(let c=0;c<s;++c)i[c]=o[a+c];i.length=s}}return r}getCoordinates(){return ze(this.flatCoordinates,0,this.flatCoordinates.length,this.stride)}getPoint(t){let e=this.flatCoordinates.length/this.stride;return t<0||e<=t?null:new Ri(this.flatCoordinates.slice(t*this.stride,(t+1)*this.stride),this.layout)}getPoints(){let t=this.flatCoordinates,e=this.layout,i=this.stride,r=[];for(let o=0,s=t.length;o<s;o+=i){let a=new Ri(t.slice(o,o+i),e);r.push(a)}return r}getType(){return"MultiPoint"}intersectsExtent(t){let e=this.flatCoordinates,i=this.stride;for(let r=0,o=e.length;r<o;r+=i){let s=e[r],a=e[r+1];if(_r(t,s,a))return!0}return!1}setCoordinates(t,e){this.setLayout(e,t,1),this.flatCoordinates||(this.flatCoordinates=[]),this.flatCoordinates.length=vr(this.flatCoordinates,0,t,this.stride),this.changed()}},_f=hc;function xs(n,t,e,i){let r=[],o=ut();for(let s=0,a=e.length;s<a;++s){let l=e[s];o=Sn(n,t,l[0],i),r.push((o[0]+o[2])/2,(o[1]+o[3])/2),t=l[l.length-1]}return r}var uc=class n extends Fe{constructor(t,e,i){if(super(),this.endss_=[],this.flatInteriorPointsRevision_=-1,this.flatInteriorPoints_=null,this.maxDelta_=-1,this.maxDeltaRevision_=-1,this.orientedRevision_=-1,this.orientedFlatCoordinates_=null,!i&&!Array.isArray(t[0])){let r=t,o=[],s=[];for(let a=0,l=r.length;a<l;++a){let h=r[a],c=o.length,u=h.getEnds();for(let f=0,g=u.length;f<g;++f)u[f]+=c;ge(o,h.getFlatCoordinates()),s.push(u)}e=r.length===0?this.getLayout():r[0].getLayout(),t=o,i=s}e!==void 0&&i?(this.setFlatCoordinates(e,t),this.endss_=i):this.setCoordinates(t,e)}appendPolygon(t){let e;if(!this.flatCoordinates)this.flatCoordinates=t.getFlatCoordinates().slice(),e=t.getEnds().slice(),this.endss_.push();else{let i=this.flatCoordinates.length;ge(this.flatCoordinates,t.getFlatCoordinates()),e=t.getEnds().slice();for(let r=0,o=e.length;r<o;++r)e[r]+=i}this.endss_.push(e),this.changed()}clone(){let t=this.endss_.length,e=new Array(t);for(let r=0;r<t;++r)e[r]=this.endss_[r].slice();let i=new n(this.flatCoordinates.slice(),this.layout,e);return i.applyProperties(this),i}closestPointXY(t,e,i,r){return r<wi(this.getExtent(),t,e)?r:(this.maxDeltaRevision_!=this.getRevision()&&(this.maxDelta_=Math.sqrt(Ku(this.flatCoordinates,0,this.endss_,this.stride,0)),this.maxDeltaRevision_=this.getRevision()),Zu(this.getOrientedFlatCoordinates(),0,this.endss_,this.stride,this.maxDelta_,!0,t,e,i,r))}containsXY(t,e){return Hu(this.getOrientedFlatCoordinates(),0,this.endss_,this.stride,t,e)}getArea(){return Yu(this.getOrientedFlatCoordinates(),0,this.endss_,this.stride)}getCoordinates(t){let e;return t!==void 0?(e=this.getOrientedFlatCoordinates().slice(),Ha(e,0,this.endss_,this.stride,t)):e=this.flatCoordinates,Cr(e,0,this.endss_,this.stride)}getEndss(){return this.endss_}getFlatInteriorPoints(){if(this.flatInteriorPointsRevision_!=this.getRevision()){let t=xs(this.flatCoordinates,0,this.endss_,this.stride);this.flatInteriorPoints_=Oo(this.getOrientedFlatCoordinates(),0,this.endss_,this.stride,t),this.flatInteriorPointsRevision_=this.getRevision()}return this.flatInteriorPoints_}getInteriorPoints(){return new _f(this.getFlatInteriorPoints().slice(),"XYM")}getOrientedFlatCoordinates(){if(this.orientedRevision_!=this.getRevision()){let t=this.flatCoordinates;ed(t,0,this.endss_,this.stride)?this.orientedFlatCoordinates_=t:(this.orientedFlatCoordinates_=t.slice(),this.orientedFlatCoordinates_.length=Ha(this.orientedFlatCoordinates_,0,this.endss_,this.stride)),this.orientedRevision_=this.getRevision()}return this.orientedFlatCoordinates_}getSimplifiedGeometryInternal(t){let e=[],i=[];return e.length=Qu(this.flatCoordinates,0,this.endss_,this.stride,Math.sqrt(t),e,0,i),new n(e,"XY",i)}getPolygon(t){if(t<0||this.endss_.length<=t)return null;let e;if(t===0)e=0;else{let o=this.endss_[t-1];e=o[o.length-1]}let i=this.endss_[t].slice(),r=i[i.length-1];if(e!==0)for(let o=0,s=i.length;o<s;++o)i[o]-=e;return new ii(this.flatCoordinates.slice(e,r),this.layout,i)}getPolygons(){let t=this.layout,e=this.flatCoordinates,i=this.endss_,r=[],o=0;for(let s=0,a=i.length;s<a;++s){let l=i[s].slice(),h=l[l.length-1];if(o!==0)for(let u=0,f=l.length;u<f;++u)l[u]-=o;let c=new ii(e.slice(o,h),t,l);r.push(c),o=h}return r}getType(){return"MultiPolygon"}intersectsExtent(t){return $u(this.getOrientedFlatCoordinates(),0,this.endss_,this.stride,t)}setCoordinates(t,e){this.setLayout(e,t,3),this.flatCoordinates||(this.flatCoordinates=[]);let i=Bu(this.flatCoordinates,0,t,this.stride,this.endss_);if(i.length===0)this.flatCoordinates.length=0;else{let r=i[i.length-1];this.flatCoordinates.length=r.length===0?0:r[r.length-1]}this.changed()}},xf=uc;var dc=class extends xi{constructor(t,e,i){super(),i=i||{},this.tileCoord=t,this.state=e,this.key="",this.transition_=i.transition===void 0?250:i.transition,this.transitionStarts_={},this.interpolate=!!i.interpolate}changed(){this.dispatchEvent(P.CHANGE)}release(){this.setState(O.EMPTY)}getKey(){return this.key+"/"+this.tileCoord}getTileCoord(){return this.tileCoord}getState(){return this.state}setState(t){if(this.state!==O.EMPTY){if(this.state!==O.ERROR&&this.state>t)throw new Error("Tile load sequence violation");this.state=t,this.changed()}}load(){H()}getAlpha(t,e){if(!this.transition_)return 1;let i=this.transitionStarts_[t];if(!i)i=e,this.transitionStarts_[t]=i;else if(i===-1)return 1;let r=e-i+1e3/60;return r>=this.transition_?1:wa(r/this.transition_)}inTransition(t){return this.transition_?this.transitionStarts_[t]!==-1:!1}endTransition(t){this.transition_&&(this.transitionStarts_[t]=-1)}disposeInternal(){this.release(),super.disposeInternal()}},Bn=dc;function ys(n){return n instanceof Image||n instanceof HTMLCanvasElement||n instanceof HTMLVideoElement||n instanceof ImageBitmap?n:null}var $m=new Error("disposed");var Jm=[256,256],fc=class extends Bn{constructor(t){let e=O.IDLE;super(t.tileCoord,e,{transition:t.transition,interpolate:t.interpolate}),this.loader_=t.loader,this.data_=null,this.error_=null,this.size_=t.size||null,this.controller_=t.controller||null}getSize(){if(this.size_)return this.size_;let t=ys(this.data_);return t?[t.width,t.height]:Jm}getData(){return this.data_}getError(){return this.error_}load(){if(this.state!==O.IDLE&&this.state!==O.ERROR)return;this.state=O.LOADING,this.changed();let t=this;this.loader_().then(function(e){t.data_=e,t.state=O.LOADED,t.changed()}).catch(function(e){t.error_=e,t.state=O.ERROR,t.changed()})}disposeInternal(){this.controller_&&(this.controller_.abort($m),this.controller_=null),super.disposeInternal()}},gc=fc;var pc=class extends Bn{constructor(t,e,i,r,o,s){super(t,e,s),this.crossOrigin_=r?.crossOrigin,this.referrerPolicy_=r?.referrerPolicy,this.src_=i,this.key=i,this.image_,St?this.image_=new OffscreenCanvas(1,1):(this.image_=new Image,this.crossOrigin_!==null&&(this.image_.crossOrigin=this.crossOrigin_),this.referrerPolicy_!==void 0&&(this.image_.referrerPolicy=this.referrerPolicy_)),this.unlisten_=null,this.tileLoadFunction_=o}getImage(){return this.image_}setImage(t){this.image_=t,this.state=O.LOADED,this.unlistenImage_(),this.changed()}getCrossOrigin(){return this.crossOrigin_}getReferrerPolicy(){return this.referrerPolicy_}handleImageError_(){this.state=O.ERROR,this.unlistenImage_(),this.image_=Qm(),this.changed()}handleImageLoad_(){if(St)this.state=O.LOADED;else{let t=this.image_;t.naturalWidth&&t.naturalHeight?this.state=O.LOADED:this.state=O.EMPTY}this.unlistenImage_(),this.changed()}load(){this.state==O.ERROR&&(this.state=O.IDLE,this.image_=new Image,this.crossOrigin_!==null&&(this.image_.crossOrigin=this.crossOrigin_),this.referrerPolicy_!==void 0&&(this.image_.referrerPolicy=this.referrerPolicy_)),this.state==O.IDLE&&(this.state=O.LOADING,this.changed(),this.tileLoadFunction_(this,this.src_),this.unlisten_=Yd(this.image_,this.handleImageLoad_.bind(this),this.handleImageError_.bind(this)))}unlistenImage_(){this.unlisten_&&(this.unlisten_(),this.unlisten_=null)}disposeInternal(){this.unlistenImage_(),this.image_=null,super.disposeInternal()}};function Qm(){let n=nt(1,1);return n.fillStyle="rgba(0,0,0,0)",n.fillRect(0,0,1,1),n.canvas}var ws=pc;var Es=class{constructor(t,e,i,r){this.minX=t,this.maxX=e,this.minY=i,this.maxY=r}contains(t){return this.containsXY(t[1],t[2])}containsTileRange(t){return this.minX<=t.minX&&t.maxX<=this.maxX&&this.minY<=t.minY&&t.maxY<=this.maxY}containsXY(t,e){return this.minX<=t&&t<=this.maxX&&this.minY<=e&&e<=this.maxY}equals(t){return this.minX==t.minX&&this.minY==t.minY&&this.maxX==t.maxX&&this.maxY==t.maxY}extend(t){t.minX<this.minX&&(this.minX=t.minX),t.maxX>this.maxX&&(this.maxX=t.maxX),t.minY<this.minY&&(this.minY=t.minY),t.maxY>this.maxY&&(this.maxY=t.maxY)}getHeight(){return this.maxY-this.minY+1}getSize(){return[this.getWidth(),this.getHeight()]}getWidth(){return this.maxX-this.minX+1}intersects(t){return this.minX<=t.maxX&&this.maxX>=t.minX&&this.minY<=t.maxY&&this.maxY>=t.minY}};function un(n,t,e,i,r){return r!==void 0?(r.minX=n,r.maxX=t,r.minY=e,r.maxY=i,r):new Es(n,t,e,i)}var vs=Es;var mc,dn=[];function yf(n,t,e,i,r){n.beginPath(),n.moveTo(0,0),n.lineTo(t,e),n.lineTo(i,r),n.closePath(),n.save(),n.clip(),n.fillRect(0,0,Math.max(t,i)+1,Math.max(e,r)),n.restore()}function _c(n,t){return Math.abs(n[t*4]-210)>2||Math.abs(n[t*4+3]-.75*255)>2}function t_(){if(mc===void 0){let n=nt(6,6,dn);n.globalCompositeOperation="lighter",n.fillStyle="rgba(210, 0, 0, 0.75)",yf(n,4,5,4,0),yf(n,4,5,0,5);let t=n.getImageData(0,0,3,3).data;mc=_c(t,0)||_c(t,4)||_c(t,8),en(n),dn.push(n.canvas)}return mc}function wf(n,t,e,i){let r=Dn(e,t,n),o=Pa(t,i,e),s=t.getMetersPerUnit();s!==void 0&&(o*=s);let a=n.getMetersPerUnit();a!==void 0&&(o/=a);let l=n.getExtent();if(!l||_e(l,r)){let h=Pa(n,o,r)/o;isFinite(h)&&h>0&&(o/=h)}return o}function Ef(n,t,e,i){let r=Bt(e),o=wf(n,t,r,i);return(!isFinite(o)||o<=0)&&yo(e,function(s){return o=wf(n,t,s,i),isFinite(o)&&o>0}),o}function vf(n,t,e,i,r,o,s,a,l,h,c,u,f,g){let p=nt(Math.round(e*n),Math.round(e*t),dn);if(u||(p.imageSmoothingEnabled=!1),l.length===0)return p.canvas;p.scale(e,e);function _(E){return Math.round(E*e)/e}p.globalCompositeOperation="lighter";let m=ut();l.forEach(function(E,R,A){xo(m,E.extent)});let x,w=e/i,v=(u?1:1+Math.pow(2,-24))/w;if(!f||l.length!==1||h!==0){if(x=nt(Math.round(j(m)*w),Math.round(ct(m)*w),dn),u||(x.imageSmoothingEnabled=!1),r&&g){let E=(r[0]-m[0])*w,R=-(r[3]-m[3])*w,A=j(r)*w,S=ct(r)*w;x.rect(E,R,A,S),x.clip()}l.forEach(function(E,R,A){if(E.image.width>0&&E.image.height>0){if(E.clipExtent){x.save();let G=(E.clipExtent[0]-m[0])*w,F=-(E.clipExtent[3]-m[3])*w,B=j(E.clipExtent)*w,lt=ct(E.clipExtent)*w;x.rect(u?G:Math.round(G),u?F:Math.round(F),u?B:Math.round(G+B)-Math.round(G),u?lt:Math.round(F+lt)-Math.round(F)),x.clip()}let S=(E.extent[0]-m[0])*w,T=-(E.extent[3]-m[3])*w,I=j(E.extent)*w,z=ct(E.extent)*w;x.drawImage(E.image,h,h,E.image.width-2*h,E.image.height-2*h,u?S:Math.round(S),u?T:Math.round(T),u?I:Math.round(S+I)-Math.round(S),u?z:Math.round(T+z)-Math.round(T)),E.clipExtent&&x.restore()}})}let y=le(s);return a.getTriangles().forEach(function(E,R,A){let S=E.source,T=E.target,I=S[0][0],z=S[0][1],G=S[1][0],F=S[1][1],B=S[2][0],lt=S[2][1],M=_((T[0][0]-y[0])/o),X=_(-(T[0][1]-y[1])/o),k=_((T[1][0]-y[0])/o),$=_(-(T[1][1]-y[1])/o),N=_((T[2][0]-y[0])/o),tt=_(-(T[2][1]-y[1])/o),it=I,vt=z;I=0,z=0,G-=it,F-=vt,B-=it,lt-=vt;let L=[[G,F,0,0,k-M],[B,lt,0,0,N-M],[0,0,G,F,$-X],[0,0,B,lt,tt-X]],Jt=Jh(L);if(!Jt)return;if(p.save(),p.beginPath(),t_()||!u){p.moveTo(k,$);let st=4,Re=M-k,Xi=X-$;for(let re=0;re<st;re++)p.lineTo(k+_((re+1)*Re/st),$+_(re*Xi/(st-1))),re!=st-1&&p.lineTo(k+_((re+1)*Re/st),$+_((re+1)*Xi/(st-1)));p.lineTo(N,tt)}else p.moveTo(k,$),p.lineTo(M,X),p.lineTo(N,tt);p.clip(),p.transform(Jt[0],Jt[2],Jt[1],Jt[3],M,X),p.translate(m[0]-it,m[3]-vt);let Ct;if(x)Ct=x.canvas,p.scale(v,-v);else{let st=l[0],Re=st.extent;Ct=st.image,p.scale(j(Re)/Ct.width,-ct(Re)/Ct.height)}p.drawImage(Ct,0,0),p.restore()}),x&&(en(x),dn.push(x.canvas)),c&&(p.save(),p.globalCompositeOperation="source-over",p.strokeStyle="black",p.lineWidth=1,a.getTriangles().forEach(function(E,R,A){let S=E.target,T=(S[0][0]-y[0])/o,I=-(S[0][1]-y[1])/o,z=(S[1][0]-y[0])/o,G=-(S[1][1]-y[1])/o,F=(S[2][0]-y[0])/o,B=-(S[2][1]-y[1])/o;p.beginPath(),p.moveTo(z,G),p.lineTo(T,I),p.lineTo(F,B),p.closePath(),p.stroke()}),p.restore()),p.canvas}var e_=10,Cf=.25,xc=class{constructor(t,e,i,r,o,s,a){this.sourceProj_=t,this.targetProj_=e;let l={},h=a?Au(v=>dt(a,Dn(v,this.targetProj_,this.sourceProj_))):Qi(this.targetProj_,this.sourceProj_);this.transformInv_=function(v){let y=v[0]+"/"+v[1];return l[y]||(l[y]=h(v)),l[y]},this.maxSourceExtent_=r,this.errorThresholdSquared_=o*o,this.triangles_=[],this.wrapsXInSource_=!1,this.canWrapXInSource_=this.sourceProj_.canWrapX()&&!!r&&!!this.sourceProj_.getExtent()&&j(r)>=j(this.sourceProj_.getExtent()),this.sourceWorldWidth_=this.sourceProj_.getExtent()?j(this.sourceProj_.getExtent()):null,this.targetWorldWidth_=this.targetProj_.getExtent()?j(this.targetProj_.getExtent()):null;let c=le(i),u=In(i),f=Tn(i),g=Rn(i),p=this.transformInv_(c),_=this.transformInv_(u),m=this.transformInv_(f),x=this.transformInv_(g),w=e_+(s?Math.max(0,Math.ceil(Math.log2(xr(i)/(s*s*256*256)))):0);if(this.addQuad_(c,u,f,g,p,_,m,x,w),this.wrapsXInSource_){let v=1/0;this.triangles_.forEach(function(y,E,R){v=Math.min(v,y.source[0][0],y.source[1][0],y.source[2][0])}),this.triangles_.forEach(y=>{if(Math.max(y.source[0][0],y.source[1][0],y.source[2][0])-v>this.sourceWorldWidth_/2){let E=[[y.source[0][0],y.source[0][1]],[y.source[1][0],y.source[1][1]],[y.source[2][0],y.source[2][1]]];E[0][0]-v>this.sourceWorldWidth_/2&&(E[0][0]-=this.sourceWorldWidth_),E[1][0]-v>this.sourceWorldWidth_/2&&(E[1][0]-=this.sourceWorldWidth_),E[2][0]-v>this.sourceWorldWidth_/2&&(E[2][0]-=this.sourceWorldWidth_);let R=Math.min(E[0][0],E[1][0],E[2][0]);Math.max(E[0][0],E[1][0],E[2][0])-R<this.sourceWorldWidth_/2&&(y.source=E)}})}l={}}addTriangle_(t,e,i,r,o,s){this.triangles_.push({source:[r,o,s],target:[t,e,i]})}addQuad_(t,e,i,r,o,s,a,l,h){let c=pa([o,s,a,l]),u=this.sourceWorldWidth_?j(c)/this.sourceWorldWidth_:null,f=this.sourceWorldWidth_,g=this.sourceProj_.canWrapX()&&u>.5&&u<1,p=!1;if(h>0){if(this.targetProj_.isGlobal()&&this.targetWorldWidth_){let m=pa([t,e,i,r]);p=j(m)/this.targetWorldWidth_>Cf||p}!g&&this.sourceProj_.isGlobal()&&u&&(p=u>Cf||p)}if(!p&&this.maxSourceExtent_&&isFinite(c[0])&&isFinite(c[1])&&isFinite(c[2])&&isFinite(c[3])&&!ht(c,this.maxSourceExtent_))return;let _=0;if(!p&&(!isFinite(o[0])||!isFinite(o[1])||!isFinite(s[0])||!isFinite(s[1])||!isFinite(a[0])||!isFinite(a[1])||!isFinite(l[0])||!isFinite(l[1]))){if(h>0)p=!0;else if(_=(!isFinite(o[0])||!isFinite(o[1])?8:0)+(!isFinite(s[0])||!isFinite(s[1])?4:0)+(!isFinite(a[0])||!isFinite(a[1])?2:0)+(!isFinite(l[0])||!isFinite(l[1])?1:0),_!=1&&_!=2&&_!=4&&_!=8)return}if(h>0){if(!p){let m=[(t[0]+i[0])/2,(t[1]+i[1])/2],x=this.transformInv_(m),w;g?w=(Pe(o[0],f)+Pe(a[0],f))/2-Pe(x[0],f):w=(o[0]+a[0])/2-x[0];let v=(o[1]+a[1])/2-x[1];p=w*w+v*v>this.errorThresholdSquared_}if(p){if(Math.abs(t[0]-i[0])<=Math.abs(t[1]-i[1])){let m=[(e[0]+i[0])/2,(e[1]+i[1])/2],x=this.transformInv_(m),w=[(r[0]+t[0])/2,(r[1]+t[1])/2],v=this.transformInv_(w);this.addQuad_(t,e,m,w,o,s,x,v,h-1),this.addQuad_(w,m,i,r,v,x,a,l,h-1)}else{let m=[(t[0]+e[0])/2,(t[1]+e[1])/2],x=this.transformInv_(m),w=[(i[0]+r[0])/2,(i[1]+r[1])/2],v=this.transformInv_(w);this.addQuad_(t,m,w,r,o,x,v,l,h-1),this.addQuad_(m,e,i,w,x,s,a,v,h-1)}return}}if(g){if(!this.canWrapXInSource_)return;this.wrapsXInSource_=!0}(_&11)==0&&this.addTriangle_(t,i,r,o,a,l),(_&14)==0&&this.addTriangle_(t,i,e,o,a,s),_&&((_&13)==0&&this.addTriangle_(e,r,t,s,l,o),(_&7)==0&&this.addTriangle_(e,r,i,s,l,a))}calculateSourceExtent(){let t=ut();return this.triangles_.forEach(function(e,i,r){let o=e.source;Hi(t,o[0]),Hi(t,o[1]),Hi(t,o[2])}),t}getTriangles(){return this.triangles_}},bf=xc;var yc=class extends Bn{constructor(t,e,i,r,o,s,a,l,h,c,u,f){super(o,O.IDLE,f),this.renderEdges_=u!==void 0?u:!1,this.pixelRatio_=a,this.gutter_=l,this.canvas_=null,this.sourceTileGrid_=e,this.targetTileGrid_=r,this.wrappedTileCoord_=s||o,this.sourceTiles_=[],this.sourcesListenerKeys_=null,this.sourceZ_=0,this.clipExtent_=t.canWrapX()?t.getExtent():void 0;let g=r.getTileCoordExtent(this.wrappedTileCoord_),p=this.targetTileGrid_.getExtent(),_=this.sourceTileGrid_.getExtent(),m=p?Oe(g,p):g;if(xr(m)===0){this.state=O.EMPTY;return}let x=t.getExtent();x&&(_?_=Oe(_,x):_=x);let w=r.getResolution(this.wrappedTileCoord_[0]),v=Ef(t,i,m,w);if(!isFinite(v)||v<=0){this.state=O.EMPTY;return}let y=c!==void 0?c:.5;if(this.triangulation_=new bf(t,i,m,_,v*y,w),this.triangulation_.getTriangles().length===0){this.state=O.EMPTY;return}this.sourceZ_=e.getZForResolution(v);let E=this.triangulation_.calculateSourceExtent();if(_&&(t.canWrapX()?(E[1]=et(E[1],_[1],_[3]),E[3]=et(E[3],_[1],_[3])):E=Oe(E,_)),!xr(E))this.state=O.EMPTY;else{let R=0,A=0;t.canWrapX()&&(R=j(x),A=Math.floor((E[0]-x[0])/R)),wo(E.slice(),t,!0).forEach(T=>{let I=e.getTileRangeForExtentAndZ(T,this.sourceZ_);for(let z=I.minX;z<=I.maxX;z++)for(let G=I.minY;G<=I.maxY;G++){let F=A*R;this.sourceTiles_.push({getTile:()=>h(this.sourceZ_,z,G,a),offset:F})}++A}),this.sourceTiles_.length===0&&(this.state=O.EMPTY)}}getImage(){return this.canvas_}reproject_(){let t=[];if(this.sourceTiles_.forEach(e=>{let i=e.tile;if(i&&i.getState()==O.LOADED){let r=this.sourceTileGrid_.getTileCoordExtent(i.tileCoord);r[0]+=e.offset,r[2]+=e.offset;let o=this.clipExtent_?.slice();o&&(o[0]+=e.offset,o[2]+=e.offset),t.push({extent:r,clipExtent:o,image:i.getImage()})}}),this.sourceTiles_.length=0,t.length===0)this.state=O.ERROR;else{let e=this.wrappedTileCoord_[0],i=this.targetTileGrid_.getTileSize(e),r=typeof i=="number"?i:i[0],o=typeof i=="number"?i:i[1],s=this.targetTileGrid_.getResolution(e),a=this.sourceTileGrid_.getResolution(this.sourceZ_),l=this.targetTileGrid_.getTileCoordExtent(this.wrappedTileCoord_);this.canvas_=vf(r,o,this.pixelRatio_,a,this.sourceTileGrid_.getExtent(),s,l,this.triangulation_,t,this.gutter_,this.renderEdges_,this.interpolate),this.state=O.LOADED}this.changed()}load(){for(let t of this.sourceTiles_)t.tile=t.getTile();if(this.state==O.IDLE){this.state=O.LOADING,this.changed();let t=0;this.sourcesListenerKeys_=[],this.sourceTiles_.forEach(({tile:e})=>{let i=e.getState();if(i==O.IDLE||i==O.LOADING){t++;let r=Z(e,P.CHANGE,o=>{let s=e.getState();(s==O.LOADED||s==O.ERROR||s==O.EMPTY)&&(J(r),t--,t===0&&(this.unlistenSources_(),this.reproject_()))});this.sourcesListenerKeys_.push(r)}}),t===0?setTimeout(this.reproject_.bind(this),0):this.sourceTiles_.forEach(function({tile:e},i,r){e.getState()==O.IDLE&&e.load()})}}unlistenSources_(){this.sourcesListenerKeys_.forEach(J),this.sourcesListenerKeys_=null}release(){this.canvas_&&(en(this.canvas_.getContext("2d")),dn.push(this.canvas_),this.canvas_=null),this.sourceTiles_.length=0,super.release()}},Cs=yc;var wc=class{constructor(t){this.highWaterMark=t!==void 0?t:2048,this.count_=0,this.entries_={},this.oldest_=null,this.newest_=null}deleteOldest(){let t=this.pop();t instanceof _i&&t.dispose()}canExpireCache(){return this.highWaterMark>0&&this.getCount()>this.highWaterMark}expireCache(t){for(;this.canExpireCache();)this.deleteOldest()}clear(){for(;this.oldest_;)this.deleteOldest()}containsKey(t){return this.entries_.hasOwnProperty(t)}forEach(t){let e=this.oldest_;for(;e;)t(e.value_,e.key_,this),e=e.newer}get(t,e){let i=this.entries_[t];return V(i!==void 0,"Tried to get a value for a key that does not exist in the cache"),i===this.newest_||(i===this.oldest_?(this.oldest_=this.oldest_.newer,this.oldest_.older=null):(i.newer.older=i.older,i.older.newer=i.newer),i.newer=null,i.older=this.newest_,this.newest_.newer=i,this.newest_=i),i.value_}remove(t){let e=this.entries_[t];return V(e!==void 0,"Tried to get a value for a key that does not exist in the cache"),e===this.newest_?(this.newest_=e.older,this.newest_&&(this.newest_.newer=null)):e===this.oldest_?(this.oldest_=e.newer,this.oldest_&&(this.oldest_.older=null)):(e.newer.older=e.older,e.older.newer=e.newer),delete this.entries_[t],--this.count_,e.value_}getCount(){return this.count_}getKeys(){let t=new Array(this.count_),e=0,i;for(i=this.newest_;i;i=i.older)t[e++]=i.key_;return t}getValues(){let t=new Array(this.count_),e=0,i;for(i=this.newest_;i;i=i.older)t[e++]=i.value_;return t}peekLast(){return this.oldest_.value_}peekLastKey(){return this.oldest_.key_}peekFirstKey(){return this.newest_.key_}peek(t){return this.entries_[t]?.value_}pop(){let t=this.oldest_;return delete this.entries_[t.key_],t.newer&&(t.newer.older=null),this.oldest_=t.newer,this.oldest_||(this.newest_=null),--this.count_,t.value_}replace(t,e){this.get(t),this.entries_[t].value_=e}set(t,e){V(!(t in this.entries_),"Tried to set a value for a key that is used already");let i={key_:t,newer:null,older:this.newest_,value_:e};this.newest_?this.newest_.newer=i:this.oldest_=i,this.newest_=i,this.entries_[t]=i,++this.count_}setSize(t){this.highWaterMark=t}},Ec=wc;function jn(n,t,e,i){return i!==void 0?(i[0]=n,i[1]=t,i[2]=e,i):[n,t,e]}function i_(n,t,e){return n+"/"+t+"/"+e}function Hn(n,t,e,i,r){return`${U(n)},${t},${i_(e,i,r)}`}function Sf(n){return n_(n[0],n[1],n[2])}function n_(n,t,e){return(t<<n)+e}function Rf(n,t){let e=n[0],i=n[1],r=n[2];if(t.getMinZoom()>e||e>t.getMaxZoom())return!1;let o=t.getFullTileRange(e);return o?o.containsXY(i,r):!0}var vc=class{constructor(){this.instructions_=[],this.zIndex=0,this.offset_=0,this.pendingMethod_,this.context_=new Proxy(Lr(),{get:(t,e)=>{if(typeof t[e]=="function")return this.pendingMethod_=e,this.pushMethodArgs_},set:(t,e,i)=>(this.push_(e,i),!0)})}push_(...t){let e=this.instructions_,i=this.zIndex+this.offset_;e[i]||(e[i]=[]),e[i].push(...t)}pushMethodArgs_=(...t)=>{this.push_(this.pendingMethod_,t)};pushFunction(t){this.push_(t)}getContext(){return this.context_}draw(t){this.instructions_.forEach(e=>{for(let i=0,r=e.length;i<r;++i){let o=e[i];if(typeof o=="function"){o(t);continue}let s=e[++i];typeof t[o]=="function"?t[o](...s):typeof s=="function"?t[o]=s(t):t[o]=s}})}clear(){this.instructions_.length=0,this.zIndex=0,this.offset_=0}offset(){this.offset_=this.instructions_.length,this.zIndex=0}},bs=vc;var r_=5,Cc=class extends co{constructor(t){super(),this.ready=!0,this.boundHandleImageChange_=this.handleImageChange_.bind(this),this.layer_=t,this.staleKeys_=new Array,this.maxStaleKeys=r_,this.renderedSourceKey_}getStaleKeys(){return this.staleKeys_}prependStaleKey(t){this.staleKeys_.unshift(t),this.staleKeys_.length>this.maxStaleKeys&&(this.staleKeys_.length=this.maxStaleKeys)}updateStaleKeys(t){this.renderedSourceKey_?this.renderedSourceKey_!==t&&(this.prependStaleKey(this.renderedSourceKey_),this.renderedSourceKey_=t):this.renderedSourceKey_=t}getFeatures(t){return H()}getData(t){return null}prepareFrame(t){return H()}renderFrame(t,e){return H()}forEachFeatureAtCoordinate(t,e,i,r,o){}getLayer(){return this.layer_}handleFontsChanged(){}handleImageChange_(t){let e=t.target;(e.getState()===W.LOADED||e.getState()===W.ERROR)&&this.renderIfReadyAndVisible()}loadImage(t){let e=t.getState();return e!=W.LOADED&&e!=W.ERROR&&t.addEventListener(P.CHANGE,this.boundHandleImageChange_),e==W.IDLE&&(t.load(),e=t.getState()),e==W.LOADED}renderIfReadyAndVisible(){let t=this.getLayer();t&&t.getVisible()&&t.getSourceState()==="ready"&&t.changed()}renderDeferred(t){}disposeInternal(){delete this.layer_,super.disposeInternal()}},Tf=Cc;var Sc=[],qn=null;function o_(){qn=nt(1,1,void 0,{willReadFrequently:!0})}var bc=class extends Tf{constructor(t){super(t),this.container=null,this.renderedResolution,this.tempTransform=Mt(),this.pixelTransform=Mt(),this.inversePixelTransform=Mt(),this.context=null,this.deferredContext_=null,this.containerReused=!1,this.frameState=null}getImageData(t,e,i){qn||o_(),qn.clearRect(0,0,1,1);let r;try{qn.drawImage(t,e,i,1,1,0,0,1,1),r=qn.getImageData(0,0,1,1).data}catch{return qn=null,null}return r}getBackground(t){let i=this.getLayer().getBackground();return typeof i=="function"&&(i=i(t.viewState.resolution)),i||void 0}useContainer(t,e,i,r,o){if(ee(t)&&this.pixelTransform[1]===0&&this.pixelTransform[2]===0&&this.pixelTransform[4]===0&&this.pixelTransform[5]===0&&t.width===r&&t.height===o){let h=t,c=h.getContext("2d");if(c){this.container=t,this.context=c,this.containerReused=!0,i&&(c.fillStyle=i,c.fillRect(0,0,h.width,h.height));return}}let s=this.getLayer().getClassName(),a,l;if(t&&t.className===s&&(!i||t&&t.style.backgroundColor&&Nt(ue(t.style.backgroundColor),ue(i)))){let h=t.firstElementChild;ee(h)&&(l=h.getContext("2d"))}if(l&&Du(l.canvas.style.transform,e)?(this.container=t,this.context=l,this.containerReused=!0):this.containerReused?(this.container=null,this.context=null,this.containerReused=!1):this.container&&(this.container.style.backgroundColor=null),!this.container){a=St?Xo():document.createElement("div"),a.className=s;let h=a.style;h.position="absolute",h.width="100%",h.height="100%",l=nt();let c=l.canvas;a.appendChild(c),h=c.style,h.position="absolute",h.left="0",h.transformOrigin="top left",this.container=a,this.context=l}!this.containerReused&&i&&!this.container.style.backgroundColor&&(this.container.style.backgroundColor=i)}clipUnrotated(t,e,i){let r=le(i),o=In(i),s=Tn(i),a=Rn(i);dt(e.coordinateToPixelTransform,r),dt(e.coordinateToPixelTransform,o),dt(e.coordinateToPixelTransform,s),dt(e.coordinateToPixelTransform,a);let l=this.inversePixelTransform;dt(l,r),dt(l,o),dt(l,s),dt(l,a),t.save(),t.beginPath(),t.moveTo(Math.round(r[0]),Math.round(r[1])),t.lineTo(Math.round(o[0]),Math.round(o[1])),t.lineTo(Math.round(s[0]),Math.round(s[1])),t.lineTo(Math.round(a[0]),Math.round(a[1])),t.clip()}prepareContainer(t,e){let i=t.extent,r=t.viewState.resolution,o=t.viewState.rotation,s=t.pixelRatio,a=Math.round(j(i)/r*s),l=Math.round(ct(i)/r*s);Dt(this.pixelTransform,t.size[0]/2,t.size[1]/2,1/s,1/s,o,-a/2,-l/2),Mo(this.inversePixelTransform,this.pixelTransform);let h=Ou(this.pixelTransform),c=this.getBackground(t);if(this.useContainer(e,h,c,a,l),!this.containerReused){let u=this.context.canvas;u.width!=a||u.height!=l?(u.width=a,u.height=l):this.context.clearRect(0,0,a,l),h!==u.style.transform&&(u.style.transform=h)}}dispatchRenderEvent_(t,e,i){let r=this.getLayer();if(r.hasListener(t)){let o=new _s(t,this.inversePixelTransform,i,e);r.dispatchEvent(o)}}preRender(t,e){this.frameState=e,!e.declutter&&this.dispatchRenderEvent_(Ft.PRERENDER,t,e)}postRender(t,e){e.declutter||this.dispatchRenderEvent_(Ft.POSTRENDER,t,e)}renderDeferredInternal(t){}getRenderContext(t){return t.declutter&&!this.deferredContext_&&(this.deferredContext_=new bs),t.declutter?this.deferredContext_.getContext():this.context}renderDeferred(t){t.declutter&&(this.dispatchRenderEvent_(Ft.PRERENDER,this.context,t),t.declutter&&this.deferredContext_&&(this.deferredContext_.draw(this.context),this.deferredContext_.clear()),this.renderDeferredInternal(t),this.dispatchRenderEvent_(Ft.POSTRENDER,this.context,t))}getRenderTransform(t,e,i,r,o,s,a){let l=o/2,h=s/2,c=r/e,u=-c,f=-t[0]+a,g=-t[1];return Dt(this.tempTransform,l,h,c,u,-i,f,g)}disposeInternal(){delete this.frameState,super.disposeInternal()}},Ss=bc;function Rc(n,t,e){if(!(e in n))return n[e]=new Set([t]),!0;let i=n[e],r=i.has(t);return r||i.add(t),!r}function s_(n,t,e){let i=n[e];return i?i.delete(t):!1}function If(n,t){let e=n.layerStatesArray[n.layerIndex];e.extent&&(t=Oe(t,we(e.extent,n.viewState.projection)));let i=e.layer.getRenderSource();if(!i.getWrapX()){let r=i.getTileGridForProjection(n.viewState.projection).getExtent();r&&(t=Oe(t,r))}return t}var Tc=class extends Ss{constructor(t,e){super(t),e=e||{},this.extentChanged=!0,this.renderComplete=!1,this.renderedExtent_=null,this.renderedPixelRatio,this.renderedProjection=null,this.renderedTiles=[],this.renderedSourceRevision_,this.tempExtent=ut(),this.tempTileRange_=new vs(0,0,0,0),this.tempTileCoord_=jn(0,0,0);let i=e.cacheSize!==void 0?e.cacheSize:512;this.tileCache_=new Ec(i),this.sourceTileCache_=null,this.layerExtent=null,this.maxStaleKeys=i*.5}getTileCache(){return this.tileCache_}getSourceTileCache(){return this.sourceTileCache_||(this.sourceTileCache_=new Ec(512)),this.sourceTileCache_}getOrCreateTile(t,e,i,r){let o=this.tileCache_,a=this.getLayer().getSource(),l=Hn(a,a.getKey(),t,e,i),h;if(o.containsKey(l))h=o.get(l);else{let c=r.viewState.projection,u=a.getProjection();if(h=a.getTile(t,e,i,r.pixelRatio,c,!u||On(u,c)?void 0:this.getSourceTileCache()),!h)return null;o.set(l,h)}return h}getTile(t,e,i,r){let o=this.getOrCreateTile(t,e,i,r);return o||null}getData(t){let e=this.frameState;if(!e)return null;let i=this.getLayer(),r=dt(e.pixelToCoordinateTransform,t.slice()),o=i.getExtent();if(o&&!_e(o,r))return null;let s=e.viewState,a=i.getRenderSource(),l=a.getTileGridForProjection(s.projection),h=a.getTilePixelRatio(e.pixelRatio);for(let c=l.getZForResolution(s.resolution);c>=l.getMinZoom();--c){let u=l.getTileCoordForCoordAndZ(r,c),f=this.getTile(c,u[1],u[2],e);if(!f||f.getState()!==O.LOADED)continue;let g=l.getOrigin(c),p=pt(l.getTileSize(c)),_=l.getResolution(c),m;if(f instanceof ws||f instanceof Cs)m=f.getImage();else if(f instanceof gc){if(m=ys(f.getData()),!m)continue}else continue;let x=Math.floor(h*((r[0]-g[0])/_-u[1]*p[0])),w=Math.floor(h*((g[1]-r[1])/_-u[2]*p[1])),v=Math.round(h*a.getGutterForProjection(s.projection));return this.getImageData(m,x+v,w+v)}return null}prepareFrame(t){this.renderedProjection?t.viewState.projection!==this.renderedProjection&&(this.tileCache_.clear(),this.renderedProjection=t.viewState.projection):this.renderedProjection=t.viewState.projection;let e=this.getLayer().getSource();if(!e)return!1;let i=e.getRevision();return this.renderedSourceRevision_?this.renderedSourceRevision_!==i&&(this.renderedSourceRevision_=i,this.renderedSourceKey_===e.getKey()&&(this.tileCache_.clear(),this.sourceTileCache_?.clear())):this.renderedSourceRevision_=i,!0}enqueueTilesForNextExtent(){return!0}enqueueTiles(t,e,i,r,o){let s=t.viewState,a=this.getLayer(),l=a.getRenderSource(),h=l.getTileGridForProjection(s.projection),c=U(l);c in t.wantedTiles||(t.wantedTiles[c]={});let u=t.wantedTiles[c],f=a.getMapInternal(),g=Math.max(i-o,h.getMinZoom(),h.getZForResolution(Math.min(a.getMaxResolution(),f?f.getView().getResolutionForZoom(Math.max(a.getMinZoom(),0)):h.getResolution(0)),l.zDirection)),p=s.rotation,_=p?_a(s.center,s.resolution,p,t.size):void 0;for(let m=i;m>=g;--m){let x=h.getTileRangeForExtentAndZ(e,m,this.tempTileRange_),w=h.getResolution(m);for(let v=x.minX;v<=x.maxX;++v)for(let y=x.minY;y<=x.maxY;++y){if(p&&!h.tileCoordIntersectsViewport([m,v,y],_))continue;let E=this.getTile(m,v,y,t);if(!E||!Rc(r,E,m))continue;let A=E.getKey();if(u[A]=!0,E.getState()===O.IDLE&&!t.tileQueue.isKeyQueued(A)){let S=jn(m,v,y,this.tempTileCoord_);t.tileQueue.enqueue([E,c,h.getTileCoordCenter(S),w])}}}}findStaleTile_(t,e){let i=this.tileCache_,r=t[0],o=t[1],s=t[2],a=this.getStaleKeys();for(let l=0;l<a.length;++l){let h=Hn(this.getLayer().getSource(),a[l],r,o,s);if(i.containsKey(h)){let c=i.peek(h);if(c.getState()===O.LOADED)return c.endTransition(U(this)),Rc(e,c,r),!0}}return!1}findAltTiles_(t,e,i,r){let o=t.getTileRangeForTileCoordAndZ(e,i,this.tempTileRange_);if(!o)return!1;let s=!0,a=this.tileCache_,l=this.getLayer().getRenderSource(),h=l.getKey();for(let c=o.minX;c<=o.maxX;++c)for(let u=o.minY;u<=o.maxY;++u){let f=Hn(l,h,i,c,u),g=!1;if(a.containsKey(f)){let p=a.peek(f);p.getState()===O.LOADED&&(Rc(r,p,i),g=!0)}g||(s=!1)}return s}renderFrame(t,e){this.renderComplete=!0;let i=t.layerStatesArray[t.layerIndex],r=t.viewState,o=r.projection,s=r.resolution,a=r.center,l=t.pixelRatio,h=this.getLayer(),c=h.getSource(),u=c.getTileGridForProjection(o),f=u.getZForResolution(s,c.zDirection),g=u.getResolution(f);this.updateStaleKeys(c.getKey());let p=t.extent,_=c.getTilePixelRatio(l);this.prepareContainer(t,e);let m=this.context.canvas.width,x=this.context.canvas.height;this.layerExtent=i.extent?we(i.extent,o):null,this.layerExtent&&(p=Oe(p,this.layerExtent));let w=g*m/2/_,v=g*x/2/_,y=[a[0]-w,a[1]-v,a[0]+w,a[1]+v],E={};this.renderedTiles.length=0;let R=h.getPreload();if(t.nextExtent&&this.enqueueTilesForNextExtent()){let M=u.getZForResolution(r.nextResolution,c.zDirection),X=If(t,t.nextExtent);this.enqueueTiles(t,X,M,E,R)}let A=If(t,p);if(this.enqueueTiles(t,A,f,E,0),R>0&&setTimeout(()=>{this.enqueueTiles(t,A,f-1,E,R-1)},0),!(f in E))return this.container;let S=U(this),T=t.time;for(let M of E[f]){let X=M.getState();if(X===O.EMPTY)continue;let k=M.tileCoord;if(X===O.LOADED&&M.getAlpha(S,T)===1){M.endTransition(S);continue}if(X!==O.ERROR&&(this.renderComplete=!1),this.findStaleTile_(k,E)){s_(E,M,f),t.animate=!0;continue}if(this.findAltTiles_(u,k,f+1,E))continue;let tt=u.getMinZoom();for(let it=f-1;it>=tt&&!this.findAltTiles_(u,k,it,E);--it);}let I=g/s*l/_,z=this.getRenderContext(t);Dt(this.tempTransform,m/2,x/2,I,I,0,-m/2,-x/2),this.layerExtent&&this.clipUnrotated(z,t,this.layerExtent),c.getInterpolate()||(z.imageSmoothingEnabled=!1),this.preRender(z,t);let G=Object.keys(E).map(Number);G.sort(Vt);let F=[],B=[],lt=[];for(let M=G.length-1;M>=0;--M){let X=G[M],k=c.getTilePixelSize(X,l,o),N=u.getResolution(X)/g,tt=k[0]*N*I,it=k[1]*N*I,vt=u.getTileCoordForCoordAndZ(le(y),X),L=u.getTileCoordExtent(vt),Jt=dt(this.tempTransform,[_*(L[0]-y[0])/g,_*(y[3]-L[3])/g]),Ct=_*c.getGutterForProjection(o);for(let st of E[X]){if(st.getState()!==O.LOADED)continue;let Re=st.tileCoord,Xi=vt[1]-Re[1],re=Math.round(Jt[0]-(Xi-1)*tt),rr=vt[2]-Re[2],io=Math.round(Jt[1]-(rr-1)*it),Wi=Math.round(Jt[0]-Xi*tt),Yi=Math.round(Jt[1]-rr*it),_n=re-Wi,Ve=io-Yi,xn=X===f;if(xn&&st.inTransition(S)){lt.push({tile:st,x:Wi,y:Yi,w:_n,h:Ve,gutter:Ct}),this.renderedTiles.unshift(st),this.updateUsedTiles(t.usedTiles,c,st);continue}let or=[Wi,Yi,Wi+_n,Yi+Ve],sr=[];for(let mi=0,ar=F.length;mi<ar;++mi)X<B[mi]&&ht(or,F[mi])&&sr.push(F[mi]);let no;sr.length>0&&(no=ru(or,sr)),F.push(or),B.push(X),this.drawTile(st,t,Wi,Yi,_n,Ve,Ct,xn,no),this.renderedTiles.unshift(st),this.updateUsedTiles(t.usedTiles,c,st)}}for(let M=0,X=lt.length;M<X;++M){let{tile:k,x:$,y:N,w:tt,h:it,gutter:vt}=lt[M];this.drawTile(k,t,$,N,tt,it,vt,!0,void 0)}if(this.renderedResolution=g,this.extentChanged=!this.renderedExtent_||!ji(this.renderedExtent_,y),this.renderedExtent_=y,this.renderedPixelRatio=l,this.postRender(this.context,t),this.layerExtent&&z.restore(),z.imageSmoothingEnabled=!0,this.renderComplete){let M=(X,k)=>{let $=U(c),N=k.wantedTiles[$],tt=N?Object.keys(N).length:0;this.updateCacheSize(tt),this.tileCache_.expireCache(),this.sourceTileCache_?.expireCache()};t.postRenderFunctions.push(M)}return this.container}updateCacheSize(t){this.tileCache_.highWaterMark=Math.max(this.tileCache_.highWaterMark,t*2)}drawTile(t,e,i,r,o,s,a,l,h){let c;if(t instanceof gc){if(c=ys(t.getData()),!c)throw new Error("Rendering array data is not yet supported")}else c=this.getTileImage(t);if(!c)return;let u=this.getRenderContext(e),f=U(this),g=e.layerStatesArray[e.layerIndex],p=g.opacity*(l?t.getAlpha(f,e.time):1),_=p!==u.globalAlpha;_&&(u.save(),u.globalAlpha=p);let m=c.width-2*a,x=c.height-2*a;if(h){let w=m/o,v=x/s;for(let y=0,E=h.length;y<E;++y){let R=h[y],A=R[0],S=R[1],T=R[2]-R[0],I=R[3]-R[1];u.drawImage(c,a+(A-i)*w,a+(S-r)*v,T*w,I*v,A,S,T,I)}}else u.drawImage(c,a,a,m,x,i,r,o,s);_&&u.restore(),p!==g.opacity?e.animate=!0:l&&t.endTransition(f)}getImage(){let t=this.context;return t?t.canvas:null}getTileImage(t){return t.getImage()}updateUsedTiles(t,e,i){let r=U(e);r in t||(t[r]={}),t[r][i.getKey()]=!0}},Lf=Tc;var Br={PRELOAD:"preload",USE_INTERIM_TILES_ON_ERROR:"useInterimTilesOnError"};var Ic=class extends rn{constructor(t){t=t||{};let e=Object.assign({},t),i=t.cacheSize;delete t.cacheSize,delete e.preload,delete e.useInterimTilesOnError,super(e),this.on,this.once,this.un,this.cacheSize_=i,this.setPreload(t.preload!==void 0?t.preload:0),this.setUseInterimTilesOnError(t.useInterimTilesOnError!==void 0?t.useInterimTilesOnError:!0)}getCacheSize(){return this.cacheSize_}getPreload(){return this.get(Br.PRELOAD)}setPreload(t){this.set(Br.PRELOAD,t)}getUseInterimTilesOnError(){return this.get(Br.USE_INTERIM_TILES_ON_ERROR)}setUseInterimTilesOnError(t){this.set(Br.USE_INTERIM_TILES_ON_ERROR,t)}getData(t){return super.getData(t)}},Af=Ic;var Lc=class extends Af{constructor(t){super(t)}createRenderer(){return new Lf(this,{cacheSize:this.getCacheSize()})}},Ac=Lc;var Mc=class{drawCustom(t,e,i,r,o){}drawGeometry(t){}setStyle(t){}drawCircle(t,e,i){}drawFeature(t,e,i){}drawGeometryCollection(t,e,i){}drawLineString(t,e,i){}drawMultiLineString(t,e,i){}drawMultiPoint(t,e,i){}drawMultiPolygon(t,e,i){}drawPoint(t,e,i){}drawPolygon(t,e,i){}drawText(t,e,i){}setFillStrokeStyle(t,e){}setImageStyle(t,e){}setTextStyle(t,e){}},Rs=Mc;var jr={BEGIN_GEOMETRY:0,BEGIN_PATH:1,CIRCLE:2,CLOSE_PATH:3,CUSTOM:4,DRAW_CHARS:5,DRAW_IMAGE:6,END_GEOMETRY:7,FILL:8,MOVE_TO_LINE_TO:9,SET_FILL_STYLE:10,SET_STROKE_STYLE:11,STROKE:12},Hr=[jr.FILL],Ye=[jr.STROKE],ui=[jr.BEGIN_PATH],Pc=[jr.CLOSE_PATH],D=jr;var kc=class extends Rs{constructor(t,e,i,r){super(),this.tolerance=t,this.maxExtent=e,this.pixelRatio=r,this.maxLineWidth=0,this.resolution=i,this.beginGeometryInstruction1_=null,this.beginGeometryInstruction2_=null,this.bufferedMaxExtent_=null,this.instructions=[],this.coordinates=[],this.tmpCoordinate_=[],this.hitDetectionInstructions=[],this.state={}}applyPixelRatio(t){let e=this.pixelRatio;return e==1?t:t.map(function(i){return i*e})}appendFlatPointCoordinates(t,e){let i=this.getBufferedMaxExtent(),r=this.tmpCoordinate_,o=this.coordinates,s=o.length;for(let a=0,l=t.length;a<l;a+=e)r[0]=t[a],r[1]=t[a+1],_e(i,r)&&(o[s++]=r[0],o[s++]=r[1]);return s}appendFlatLineCoordinates(t,e,i,r,o,s){let a=this.coordinates,l=a.length,h=this.getBufferedMaxExtent();s&&(e+=r);let c=t[e],u=t[e+1],f=this.tmpCoordinate_,g=!0,p,_,m;for(p=e+r;p<i;p+=r)f[0]=t[p],f[1]=t[p+1],m=po(h,f),m!==_?(g&&(a[l++]=c,a[l++]=u,g=!1),a[l++]=f[0],a[l++]=f[1]):m===wt.INTERSECTING?(a[l++]=f[0],a[l++]=f[1],g=!1):g=!0,c=f[0],u=f[1],_=m;return(o&&g||p===e+r)&&(a[l++]=c,a[l++]=u),l}drawCustomCoordinates_(t,e,i,r,o){for(let s=0,a=i.length;s<a;++s){let l=i[s],h=this.appendFlatLineCoordinates(t,e,l,r,!1,!1);o.push(h),e=l}return e}drawCustom(t,e,i,r,o){this.beginGeometry(t,e,o);let s=t.getType(),a=t.getStride(),l=this.coordinates.length,h,c,u,f,g;switch(s){case"MultiPolygon":h=t.getOrientedFlatCoordinates(),f=[];let p=t.getEndss();g=0;for(let _=0,m=p.length;_<m;++_){let x=[];g=this.drawCustomCoordinates_(h,g,p[_],a,x),f.push(x)}this.instructions.push([D.CUSTOM,l,f,t,i,Cr,o]),this.hitDetectionInstructions.push([D.CUSTOM,l,f,t,r||i,Cr,o]);break;case"Polygon":case"MultiLineString":u=[],h=s=="Polygon"?t.getOrientedFlatCoordinates():t.getFlatCoordinates(),g=this.drawCustomCoordinates_(h,0,t.getEnds(),a,u),this.instructions.push([D.CUSTOM,l,u,t,i,Fn,o]),this.hitDetectionInstructions.push([D.CUSTOM,l,u,t,r||i,Fn,o]);break;case"LineString":case"Circle":h=t.getFlatCoordinates(),c=this.appendFlatLineCoordinates(h,0,h.length,a,!1,!1),this.instructions.push([D.CUSTOM,l,c,t,i,ze,o]),this.hitDetectionInstructions.push([D.CUSTOM,l,c,t,r||i,ze,o]);break;case"MultiPoint":h=t.getFlatCoordinates(),c=this.appendFlatPointCoordinates(h,a),c>l&&(this.instructions.push([D.CUSTOM,l,c,t,i,ze,o]),this.hitDetectionInstructions.push([D.CUSTOM,l,c,t,r||i,ze,o]));break;case"Point":h=t.getFlatCoordinates(),this.coordinates.push(h[0],h[1]),c=this.coordinates.length,this.instructions.push([D.CUSTOM,l,c,t,i,void 0,o]),this.hitDetectionInstructions.push([D.CUSTOM,l,c,t,r||i,void 0,o]);break;default:}this.endGeometry(e)}beginGeometry(t,e,i){this.beginGeometryInstruction1_=[D.BEGIN_GEOMETRY,e,0,t,i],this.instructions.push(this.beginGeometryInstruction1_),this.beginGeometryInstruction2_=[D.BEGIN_GEOMETRY,e,0,t,i],this.hitDetectionInstructions.push(this.beginGeometryInstruction2_)}finish(){return{instructions:this.instructions,hitDetectionInstructions:this.hitDetectionInstructions,coordinates:this.coordinates}}reverseHitDetectionInstructions(){let t=this.hitDetectionInstructions;t.reverse();let e,i=t.length,r,o,s=-1;for(e=0;e<i;++e)r=t[e],o=r[0],o==D.END_GEOMETRY?s=e:o==D.BEGIN_GEOMETRY&&(r[2]=e,Wh(this.hitDetectionInstructions,s,e),s=-1)}fillStyleToState(t,e={}){if(t){let i=t.getColor();e.fillPatternScale=i&&typeof i=="object"&&"src"in i?this.pixelRatio:1,e.fillStyle=Ht(i||Tt)??void 0}else e.fillStyle=void 0;return e}strokeStyleToState(t,e={}){if(t){let i=t.getColor();e.strokeStyle=Ht(i||Ut);let r=t.getLineCap();e.lineCap=r!==void 0?r:Xe;let o=t.getLineDash();e.lineDash=o?o.slice():qt;let s=t.getLineDashOffset();e.lineDashOffset=s||$t;let a=t.getLineJoin();e.lineJoin=a!==void 0?a:We;let l=t.getWidth();e.lineWidth=l!==void 0?l:ai;let h=t.getMiterLimit();e.miterLimit=h!==void 0?h:oi;let c=t.getOffset();e.strokeOffset=c??Vd,e.lineWidth>this.maxLineWidth&&(this.maxLineWidth=e.lineWidth,this.bufferedMaxExtent_=null)}else e.strokeStyle=void 0,e.lineCap=void 0,e.lineDash=null,e.lineDashOffset=void 0,e.lineJoin=void 0,e.lineWidth=void 0,e.miterLimit=void 0,e.strokeOffset=void 0;return e}setFillStrokeStyle(t,e){let i=this.state;this.fillStyleToState(t,i),this.strokeStyleToState(e,i)}createFill(t){let e=t.fillStyle,i=[D.SET_FILL_STYLE,e];return typeof e!="string"&&i.push(t.fillPatternScale),i}applyStroke(t){this.instructions.push(this.createStroke(t))}createStroke(t){return[D.SET_STROKE_STYLE,t.strokeStyle,t.lineWidth*this.pixelRatio,t.lineCap,t.lineJoin,t.miterLimit,t.lineDash?this.applyPixelRatio(t.lineDash):null,t.lineDashOffset*this.pixelRatio]}updateFillStyle(t,e){let i=t.fillStyle;(i!==void 0&&typeof i!="string"||t.currentFillStyle!=i)&&(this.instructions.push(e.call(this,t)),t.currentFillStyle=i)}updateStrokeStyle(t,e){let i=t.strokeStyle,r=t.lineCap,o=t.lineDash,s=t.lineDashOffset,a=t.lineJoin,l=t.lineWidth,h=t.miterLimit,c=t.strokeOffset;(t.currentStrokeStyle!=i||t.currentLineCap!=r||o!=t.currentLineDash&&!Nt(t.currentLineDash,o)||t.currentLineDashOffset!=s||t.currentLineJoin!=a||t.currentLineWidth!=l||t.currentMiterLimit!=h||t.currentStrokeOffset!=c)&&(e.call(this,t),t.currentStrokeStyle=i,t.currentLineCap=r,t.currentLineDash=o,t.currentLineDashOffset=s,t.currentLineJoin=a,t.currentLineWidth=l,t.currentMiterLimit=h,t.currentStrokeOffset=c)}endGeometry(t){this.beginGeometryInstruction1_[2]=this.instructions.length,this.beginGeometryInstruction1_=null,this.beginGeometryInstruction2_[2]=this.hitDetectionInstructions.length,this.beginGeometryInstruction2_=null;let e=[D.END_GEOMETRY,t];this.instructions.push(e),this.hitDetectionInstructions.push(e)}getBufferedMaxExtent(){if(!this.bufferedMaxExtent_&&(this.bufferedMaxExtent_=mo(this.maxExtent),this.maxLineWidth>0)){let t=this.resolution*(this.maxLineWidth+1)/2;bn(this.bufferedMaxExtent_,t,this.bufferedMaxExtent_)}return this.bufferedMaxExtent_}},Ue=kc;var Oc=class extends Ue{constructor(t,e,i,r){super(t,e,i,r),this.hitDetectionImage_=null,this.image_=null,this.imagePixelRatio_=void 0,this.anchorX_=void 0,this.anchorY_=void 0,this.height_=void 0,this.opacity_=void 0,this.originX_=void 0,this.originY_=void 0,this.rotateWithView_=void 0,this.rotation_=void 0,this.scale_=void 0,this.width_=void 0,this.declutterMode_=void 0,this.declutterImageWithText_=void 0}drawPoint(t,e,i){if(!this.image_||this.maxExtent&&!_e(this.maxExtent,t.getFlatCoordinates()))return;this.beginGeometry(t,e,i);let r=t.getFlatCoordinates(),o=t.getStride(),s=this.coordinates.length,a=this.appendFlatPointCoordinates(r,o);this.instructions.push([D.DRAW_IMAGE,s,a,this.image_,this.anchorX_*this.imagePixelRatio_,this.anchorY_*this.imagePixelRatio_,Math.ceil(this.height_*this.imagePixelRatio_),this.opacity_,this.originX_*this.imagePixelRatio_,this.originY_*this.imagePixelRatio_,this.rotateWithView_,this.rotation_,[this.scale_[0]*this.pixelRatio/this.imagePixelRatio_,this.scale_[1]*this.pixelRatio/this.imagePixelRatio_],Math.ceil(this.width_*this.imagePixelRatio_),this.declutterMode_,this.declutterImageWithText_]),this.hitDetectionInstructions.push([D.DRAW_IMAGE,s,a,this.hitDetectionImage_,this.anchorX_,this.anchorY_,this.height_,1,this.originX_,this.originY_,this.rotateWithView_,this.rotation_,this.scale_,this.width_,this.declutterMode_,this.declutterImageWithText_]),this.endGeometry(e)}drawMultiPoint(t,e,i){if(!this.image_)return;this.beginGeometry(t,e,i);let r=t.getFlatCoordinates(),o=[];for(let l=0,h=r.length;l<h;l+=t.getStride())(!this.maxExtent||_e(this.maxExtent,r.slice(l,l+2)))&&o.push(r[l],r[l+1]);let s=this.coordinates.length,a=this.appendFlatPointCoordinates(o,2);this.instructions.push([D.DRAW_IMAGE,s,a,this.image_,this.anchorX_*this.imagePixelRatio_,this.anchorY_*this.imagePixelRatio_,Math.ceil(this.height_*this.imagePixelRatio_),this.opacity_,this.originX_*this.imagePixelRatio_,this.originY_*this.imagePixelRatio_,this.rotateWithView_,this.rotation_,[this.scale_[0]*this.pixelRatio/this.imagePixelRatio_,this.scale_[1]*this.pixelRatio/this.imagePixelRatio_],Math.ceil(this.width_*this.imagePixelRatio_),this.declutterMode_,this.declutterImageWithText_]),this.hitDetectionInstructions.push([D.DRAW_IMAGE,s,a,this.hitDetectionImage_,this.anchorX_,this.anchorY_,this.height_,1,this.originX_,this.originY_,this.rotateWithView_,this.rotation_,this.scale_,this.width_,this.declutterMode_,this.declutterImageWithText_]),this.endGeometry(e)}finish(){return this.reverseHitDetectionInstructions(),this.anchorX_=void 0,this.anchorY_=void 0,this.hitDetectionImage_=null,this.image_=null,this.imagePixelRatio_=void 0,this.height_=void 0,this.scale_=void 0,this.opacity_=void 0,this.originX_=void 0,this.originY_=void 0,this.rotateWithView_=void 0,this.rotation_=void 0,this.width_=void 0,super.finish()}setImageStyle(t,e){let i=t.getAnchor(),r=t.getSize(),o=t.getOrigin();this.imagePixelRatio_=t.getPixelRatio(this.pixelRatio),this.anchorX_=i[0],this.anchorY_=i[1],this.hitDetectionImage_=t.getHitDetectionImage(),this.image_=t.getImage(this.pixelRatio),this.height_=r[1],this.opacity_=t.getOpacity(),this.originX_=o[0],this.originY_=o[1],this.rotateWithView_=t.getRotateWithView(),this.rotation_=t.getRotation(),this.scale_=t.getScaleArray(),this.width_=r[0],this.declutterMode_=t.getDeclutterMode(),this.declutterImageWithText_=e}},Mf=Oc;var Dc=class extends Ue{constructor(t,e,i,r){super(t,e,i,r)}drawFlatCoordinates_(t,e,i,r,o){let s=this.coordinates.length,a=this.appendFlatLineCoordinates(t,e,i,r,!1,!1);return this.instructions.push([D.MOVE_TO_LINE_TO,s,a,o*this.pixelRatio]),this.hitDetectionInstructions.push([D.MOVE_TO_LINE_TO,s,a,o]),i}drawLineString(t,e,i){let r=this.state,o=r.strokeStyle,s=r.lineWidth,a=r.strokeOffset;if(o===void 0||s===void 0)return;this.updateStrokeStyle(r,this.applyStroke),this.beginGeometry(t,e,i),this.hitDetectionInstructions.push([D.SET_STROKE_STYLE,Ut,r.lineWidth,r.lineCap,r.lineJoin,r.miterLimit,qt,$t],ui);let l=t.getFlatCoordinates(),h=t.getStride();this.drawFlatCoordinates_(l,0,l.length,h,a),this.hitDetectionInstructions.push(Ye),this.endGeometry(e)}drawMultiLineString(t,e,i){let r=this.state,o=r.strokeStyle,s=r.lineWidth,a=r.strokeOffset;if(o===void 0||s===void 0)return;this.updateStrokeStyle(r,this.applyStroke),this.beginGeometry(t,e,i),this.hitDetectionInstructions.push([D.SET_STROKE_STYLE,Ut,r.lineWidth,r.lineCap,r.lineJoin,r.miterLimit,qt,$t],ui);let l=t.getEnds(),h=t.getFlatCoordinates(),c=t.getStride(),u=0;for(let f=0,g=l.length;f<g;++f)u=this.drawFlatCoordinates_(h,u,l[f],c,a);this.hitDetectionInstructions.push(Ye),this.endGeometry(e)}finish(){let t=this.state;return t.lastStroke!=null&&t.lastStroke!=this.coordinates.length&&this.instructions.push(Ye),this.reverseHitDetectionInstructions(),this.state=null,super.finish()}applyStroke(t){t.lastStroke!=null&&t.lastStroke!=this.coordinates.length&&(this.instructions.push(Ye),t.lastStroke=this.coordinates.length),t.lastStroke=0,super.applyStroke(t),this.instructions.push(ui)}},Pf=Dc;var Fc=class extends Ue{constructor(t,e,i,r){super(t,e,i,r)}drawFlatCoordinatess_(t,e,i,r,o){let s=this.state,a=s.fillStyle!==void 0,l=s.strokeStyle!==void 0,h=i.length;this.instructions.push(ui),this.hitDetectionInstructions.push(ui);for(let c=0;c<h;++c){let u=i[c],f=this.coordinates.length,g=this.appendFlatLineCoordinates(t,e,u,r,!0,!l);this.instructions.push([D.MOVE_TO_LINE_TO,f,g,o*this.pixelRatio,!0]),this.hitDetectionInstructions.push([D.MOVE_TO_LINE_TO,f,g,o,!0]),l&&(this.instructions.push(Pc),this.hitDetectionInstructions.push(Pc)),e=u}return a&&(this.instructions.push(Hr),this.hitDetectionInstructions.push(Hr)),l&&(this.instructions.push(Ye),this.hitDetectionInstructions.push(Ye)),e}drawCircle(t,e,i){let r=this.state,o=r.fillStyle,s=r.strokeStyle,a=r.strokeOffset;if(o===void 0&&s===void 0||this.handleStrokeOffset_(()=>this.drawCircle(t,e,i)))return;this.setFillStrokeStyles_(),this.beginGeometry(t,e,i),r.fillStyle!==void 0&&this.hitDetectionInstructions.push([D.SET_FILL_STYLE,Tt]),r.strokeStyle!==void 0&&this.hitDetectionInstructions.push([D.SET_STROKE_STYLE,Ut,r.lineWidth,r.lineCap,r.lineJoin,r.miterLimit,qt,$t]);let l=t.getFlatCoordinates(),h=t.getStride(),c=this.coordinates.length;this.appendFlatLineCoordinates(l,0,l.length,h,!1,!1);let u=[D.CIRCLE,c,a];this.instructions.push(ui,u),this.hitDetectionInstructions.push(ui,u),r.fillStyle!==void 0&&(this.instructions.push(Hr),this.hitDetectionInstructions.push(Hr)),r.strokeStyle!==void 0&&(this.instructions.push(Ye),this.hitDetectionInstructions.push(Ye)),this.endGeometry(e)}drawPolygon(t,e,i){let r=this.state,o=r.fillStyle,s=r.strokeStyle,a=r.strokeOffset;if(o===void 0&&s===void 0||this.handleStrokeOffset_(()=>this.drawPolygon(t,e,i)))return;this.setFillStrokeStyles_(),this.beginGeometry(t,e,i),r.fillStyle!==void 0&&this.hitDetectionInstructions.push([D.SET_FILL_STYLE,Tt]),r.strokeStyle!==void 0&&this.hitDetectionInstructions.push([D.SET_STROKE_STYLE,Ut,r.lineWidth,r.lineCap,r.lineJoin,r.miterLimit,qt,$t]);let l=t.getEnds(),h=t.getOrientedFlatCoordinates(),c=t.getStride();this.drawFlatCoordinatess_(h,0,l,c,a),this.endGeometry(e)}drawMultiPolygon(t,e,i){let r=this.state,o=r.fillStyle,s=r.strokeStyle,a=r.strokeOffset;if(o===void 0&&s===void 0||this.handleStrokeOffset_(()=>this.drawMultiPolygon(t,e,i)))return;this.setFillStrokeStyles_(),this.beginGeometry(t,e,i),r.fillStyle!==void 0&&this.hitDetectionInstructions.push([D.SET_FILL_STYLE,Tt]),r.strokeStyle!==void 0&&this.hitDetectionInstructions.push([D.SET_STROKE_STYLE,Ut,r.lineWidth,r.lineCap,r.lineJoin,r.miterLimit,qt,$t]);let l=t.getEndss(),h=t.getOrientedFlatCoordinates(),c=t.getStride(),u=0;for(let f=0,g=l.length;f<g;++f)u=this.drawFlatCoordinatess_(h,u,l[f],c,a);this.endGeometry(e)}finish(){this.reverseHitDetectionInstructions(),this.state=null;let t=this.tolerance;if(t!==0){let e=this.coordinates;for(let i=0,r=e.length;i<r;++i)e[i]=Si(e[i],t)}return super.finish()}setFillStrokeStyles_(){let t=this.state;this.updateFillStyle(t,this.createFill),this.updateStrokeStyle(t,this.applyStroke)}handleStrokeOffset_(t){let e=this.state,i=e.fillStyle,r=e.strokeStyle,o=e.strokeOffset;return Math.abs(o)>0&&i!==void 0&&r!==void 0?(e.strokeStyle=void 0,e.strokeOffset=0,t(),e.fillStyle=void 0,e.strokeStyle=r,e.strokeOffset=o,t(),e.fillStyle=i,!0):!1}},zc=Fc;var Nc=0,Gc=1;function a_(n,t,e,i,r,o,s,a){let l=s-r,h=a-o,c=0,u=1;if(l===0){if(r<n||r>e)return!1}else{let f=(n-r)/l,g=(e-r)/l;if(f>g){let p=f;f=g,g=p}if(f>c&&(c=f),g<u&&(u=g),c>u)return!1}if(h===0){if(o<t||o>i)return!1}else{let f=(t-o)/h,g=(i-o)/h;if(f>g){let p=f;f=g,g=p}if(f>c&&(c=f),g<u&&(u=g),c>u)return!1}return Nc=c,Gc=u,!0}function kf(n,t,e,i){let r=i[0],o=i[1],s=i[2],a=i[3],l=[],h=[],c=!1,u,f,g=0;for(let p=0,_=t.length;p<_;++p){let m=t[p],x=n[g],w=n[g+1],v=!1;for(let y=g+e;y<m;y+=e){let E=n[y],R=n[y+1];if(a_(r,o,s,a,x,w,E,R)){let A=E-x,S=R-w,T=x+Nc*A,I=w+Nc*S,z=x+Gc*A,G=w+Gc*S;c&&v&&T===u&&I===f?l.push(z,G):(c&&h.push(l.length),l.push(T,I,z,G),c=!0),u=z,f=G,v=!0}x=E,w=R}g=m}return c&&h.push(l.length),{flatCoordinates:l,ends:h}}function Of(n,t,e,i,r){let o=[],s=e,a=0,l=t.slice(e,2);for(;a<n&&s+r<i;){let[h,c]=l.slice(-2),u=t[s+r],f=t[s+r+1],g=Math.sqrt((u-h)*(u-h)+(f-c)*(f-c));if(a+=g,a>=n){let p=(n-a+g)/g,_=Gt(h,u,p),m=Gt(c,f,p);l.push(_,m),o.push(l),l=[_,m],a==n&&(s+=r),a=0}else if(a<n)l.push(t[s+r],t[s+r+1]),s+=r;else{let p=g-a,_=Gt(h,u,p/g),m=Gt(c,f,p/g);l.push(_,m),o.push(l),l=[_,m],a=0,s+=r}}return a>0&&o.push(l),o}function Df(n,t,e,i,r){let o=e,s=e,a=0,l=0,h=e,c,u,f,g,p,_,m,x,w,v;for(u=e;u<i;u+=r){let y=t[u],E=t[u+1];p!==void 0&&(w=y-p,v=E-_,g=Math.sqrt(w*w+v*v),m!==void 0&&(l+=f,c=Math.acos((m*w+x*v)/(f*g)),c>n&&(l>a&&(a=l,o=h,s=u),l=0,h=u-r)),f=g,m=w,x=v),p=y,_=E}return l+=g,l>a?[h,u]:[o,s]}var qr={left:0,center:.5,right:1,top:0,middle:.5,hanging:.2,alphabetic:.8,ideographic:.8,bottom:1},Xc=class extends Ue{constructor(t,e,i,r){super(t,e,i,r),this.labels_=null,this.text_="",this.textOffsetX_=0,this.textOffsetY_=0,this.textRotateWithView_=void 0,this.textKeepUpright_=void 0,this.textRotation_=0,this.textFillState_=null,this.fillStates={},this.fillStates[Tt]={fillStyle:Tt},this.textStrokeState_=null,this.strokeStates={},this.textState_={},this.textStates={},this.textKey_="",this.fillKey_="",this.strokeKey_="",this.declutterMode_=void 0,this.declutterImageWithText_=void 0}finish(){let t=super.finish();return t.textStates=this.textStates,t.fillStates=this.fillStates,t.strokeStates=this.strokeStates,t}drawText(t,e,i){let r=this.textFillState_,o=this.textStrokeState_,s=this.textState_;if(this.text_===""||!s||!r&&!o)return;let a=this.coordinates,l=a.length,h=t.getType(),c=null,u=t.getStride();if(s.placement==="line"&&(h=="LineString"||h=="MultiLineString"||h=="Polygon"||h=="MultiPolygon")){let f=t.getExtent();if(!ht(this.maxExtent,f))return;let g;if(c=t.getFlatCoordinates(),h=="LineString")g=[c.length];else if(h=="MultiLineString")g=t.getEnds();else if(h=="Polygon")g=t.getEnds().slice(0,1);else if(h=="MultiPolygon"){let x=t.getEndss();g=[];for(let w=0,v=x.length;w<v;++w)g.push(x[w][0])}if((h=="LineString"||h=="MultiLineString")&&!ke(this.getBufferedMaxExtent(),f)){let x=kf(c,g,u,this.getBufferedMaxExtent());if(c=x.flatCoordinates,g=x.ends,u=2,g.length===0)return}this.beginGeometry(t,e,i);let p=s.repeat,_=p?void 0:s.textAlign,m=0;for(let x=0,w=g.length;x<w;++x){let v;p?v=Of(p*this.resolution,c,m,g[x],u):v=[c.slice(m,g[x])];for(let y=0,E=v.length;y<E;++y){let R=v[y],A=0,S=R.length;if(_==null){let I=Df(s.maxAngle,R,0,R.length,2);A=I[0],S=I[1]}for(let I=A;I<S;I+=u)a.push(R[I],R[I+1]);let T=a.length;m=g[x],this.drawChars_(l,T),l=T}}this.endGeometry(e)}else{let f=s.overflow?null:[];switch(h){case"Point":case"MultiPoint":c=t.getFlatCoordinates();break;case"LineString":c=t.getFlatMidpoint();break;case"Circle":c=t.getCenter();break;case"MultiLineString":c=t.getFlatMidpoints(),u=2;break;case"Polygon":c=t.getFlatInteriorPoint(),s.overflow||f.push(c[2]/this.resolution),u=3;break;case"MultiPolygon":let y=t.getFlatInteriorPoints();c=[];for(let E=0,R=y.length;E<R;E+=3)s.overflow||f.push(y[E+2]/this.resolution),c.push(y[E],y[E+1]);if(c.length===0)return;u=2;break;default:}let g=this.appendFlatPointCoordinates(c,u);if(g===l)return;if(f&&(g-l)/2!==c.length/u){let y=l/2;f=f.filter((E,R)=>{let A=a[(y+R)*2]===c[R*u]&&a[(y+R)*2+1]===c[R*u+1];return A||--y,A})}this.saveTextStates_();let p=s.backgroundFill?this.createFill(this.fillStyleToState(s.backgroundFill)):null,_=s.backgroundStroke?this.createStroke(this.strokeStyleToState(s.backgroundStroke)):null;this.beginGeometry(t,e,i);let m=s.padding;if(m!=si&&(s.scale[0]<0||s.scale[1]<0)){let y=s.padding[0],E=s.padding[1],R=s.padding[2],A=s.padding[3];s.scale[0]<0&&(E=-E,A=-A),s.scale[1]<0&&(y=-y,R=-R),m=[y,E,R,A]}let x=this.pixelRatio;this.instructions.push([D.DRAW_IMAGE,l,g,null,NaN,NaN,NaN,1,0,0,this.textRotateWithView_,this.textRotation_,[1,1],NaN,this.declutterMode_,this.declutterImageWithText_,m==si?si:m.map(function(y){return y*x}),p,_,this.text_,this.textKey_,this.strokeKey_,this.fillKey_,this.textOffsetX_,this.textOffsetY_,f]);let w=1/x,v=p?p.slice(0):null;v&&(v[1]=Tt),this.hitDetectionInstructions.push([D.DRAW_IMAGE,l,g,null,NaN,NaN,NaN,1,0,0,this.textRotateWithView_,this.textRotation_,[w,w],NaN,this.declutterMode_,this.declutterImageWithText_,m,v,_,this.text_,this.textKey_,this.strokeKey_,this.fillKey_?Tt:this.fillKey_,this.textOffsetX_,this.textOffsetY_,f]),this.endGeometry(e)}}saveTextStates_(){let t=this.textStrokeState_,e=this.textState_,i=this.textFillState_,r=this.strokeKey_;t&&(r in this.strokeStates||(this.strokeStates[r]={strokeStyle:t.strokeStyle,lineCap:t.lineCap,lineDashOffset:t.lineDashOffset,lineWidth:t.lineWidth,lineJoin:t.lineJoin,miterLimit:t.miterLimit,lineDash:t.lineDash}));let o=this.textKey_;o in this.textStates||(this.textStates[o]={font:e.font,textAlign:e.textAlign||Pi,justify:e.justify,textBaseline:e.textBaseline||cn,scale:e.scale});let s=this.fillKey_;i&&(s in this.fillStates||(this.fillStates[s]={fillStyle:i.fillStyle}))}drawChars_(t,e){let i=this.textStrokeState_,r=this.textState_,o=this.strokeKey_,s=this.textKey_,a=this.fillKey_;this.saveTextStates_();let l=this.pixelRatio,h=qr[r.textBaseline],c=this.textOffsetX_*l,u=this.textOffsetY_*l,f=this.text_,g=i?i.lineWidth*Math.abs(r.scale[0])/2:0;this.instructions.push([D.DRAW_CHARS,t,e,h,r.overflow,a,r.maxAngle,l,u,o,g*l,f,s,1,this.declutterMode_,this.textKeepUpright_,c]),this.hitDetectionInstructions.push([D.DRAW_CHARS,t,e,h,r.overflow,a&&Tt,r.maxAngle,l,u,o,g*l,f,s,1/l,this.declutterMode_,this.textKeepUpright_,c])}setTextStyle(t,e){let i,r,o;if(!t)this.text_="";else{let s=t.getFill();s?(r=this.textFillState_,r||(r={},this.textFillState_=r),r.fillStyle=Ht(s.getColor()||Tt)):(r=null,this.textFillState_=r);let a=t.getStroke();if(!a)o=null,this.textStrokeState_=o;else{o=this.textStrokeState_,o||(o={},this.textStrokeState_=o);let _=a.getLineDash(),m=a.getLineDashOffset(),x=a.getWidth(),w=a.getMiterLimit();o.lineCap=a.getLineCap()||Xe,o.lineDash=_?_.slice():qt,o.lineDashOffset=m===void 0?$t:m,o.lineJoin=a.getLineJoin()||We,o.lineWidth=x===void 0?ai:x,o.miterLimit=w===void 0?oi:w,o.strokeStyle=Ht(a.getColor()||Ut)}i=this.textState_;let l=t.getFont()||as;Bd(l);let h=t.getScaleArray();i.overflow=t.getOverflow(),i.font=l,i.maxAngle=t.getMaxAngle(),i.placement=t.getPlacement(),i.textAlign=t.getTextAlign(),i.repeat=t.getRepeat(),i.justify=t.getJustify(),i.textBaseline=t.getTextBaseline()||cn,i.backgroundFill=t.getBackgroundFill(),i.backgroundStroke=t.getBackgroundStroke(),i.padding=t.getPadding()||si,i.scale=h===void 0?[1,1]:h;let c=t.getOffsetX(),u=t.getOffsetY(),f=t.getRotateWithView(),g=t.getKeepUpright(),p=t.getRotation();this.text_=t.getText()||"",this.textOffsetX_=c===void 0?0:c,this.textOffsetY_=u===void 0?0:u,this.textRotateWithView_=f===void 0?!1:f,this.textKeepUpright_=g===void 0?!0:g,this.textRotation_=p===void 0?0:p,this.strokeKey_=o?(typeof o.strokeStyle=="string"?o.strokeStyle:U(o.strokeStyle))+o.lineCap+o.lineDashOffset+"|"+o.lineWidth+o.lineJoin+o.miterLimit+"["+o.lineDash.join()+"]":"",this.textKey_=i.font+i.scale+(i.textAlign||"?")+(i.repeat||"?")+(i.justify||"?")+(i.textBaseline||"?"),this.fillKey_=r&&r.fillStyle?typeof r.fillStyle=="string"?r.fillStyle:"|"+U(r.fillStyle):""}this.declutterMode_=t.getDeclutterMode(),this.declutterImageWithText_=e}},Ff=Xc;var l_={Circle:zc,Default:Ue,Image:Mf,LineString:Pf,Polygon:zc,Text:Ff},Wc=class{constructor(t,e,i,r){this.tolerance_=t,this.maxExtent_=e,this.pixelRatio_=r,this.resolution_=i,this.buildersByZIndex_={}}finish(){let t={};for(let e in this.buildersByZIndex_){t[e]=t[e]||{};let i=this.buildersByZIndex_[e];for(let r in i){let o=i[r].finish();t[e][r]=o}}return t}getBuilder(t,e){let i=t!==void 0?t.toString():"0",r=this.buildersByZIndex_[i];r===void 0&&(r={},this.buildersByZIndex_[i]=r);let o=r[e];if(o===void 0){let s=l_[e];o=new s(this.tolerance_,this.maxExtent_,this.resolution_,this.pixelRatio_),r[e]=o}return o}},zf=Wc;function Nf(n,t,e,i){let r=n[t],o=n[t+1],s=0;for(let a=t+i;a<e;a+=i){let l=n[a],h=n[a+1];s+=Math.sqrt((l-r)*(l-r)+(h-o)*(h-o)),r=l,o=h}return s}function Ts(n,t,e,i,r,o,s,a){s=s??[],a=a??i;let l=n[t+i],h=n[t+i+1],c=n[e-2*i],u=n[e-2*i+1],f,g,p,_,m,x,w,v,y=0;for(let E=t;E<e;E+=i){p=f,_=g,m=void 0,x=void 0,E+i<e&&(m=n[E+i],x=n[E+i+1]),o&&E===t&&(p=c,_=u),o&&E===e-i&&(m=l,x=h),f=n[E],g=n[E+1],[w,v]=c_(f,g,p,_,m,x,r),s[y++]=w,s[y++]=v;for(let R=2;R<a;R++)s[y++]=n[E+R]}return s.length!=y&&(s.length=y),s}function c_(n,t,e,i,r,o,s){let a,l;e!==void 0&&i!==void 0?(a=n-e,l=t-i):r!==void 0&&o!==void 0?(a=r-n,l=o-t):(a=1,l=0);let h=Math.hypot(a,l),c=a/h,u=l/h;if(a=-u,l=c,e===void 0||i===void 0)return[n+a*s,t+l*s];if(r===void 0||o===void 0)return[n+a*s,t+l*s];let f=lu([n,t],[e,i],[r,o]);if(Math.cos(f)>.998)return[n+c*s,t+u*s];let g=Math.cos(f/2),p=Math.sin(f/2),_=p*a+g*l,m=-g*a+p*l,x=_*(1/p),w=m*(1/p);return[n+x*s,t+w*s]}function Is(n,t,e=!1){for(let i=0,r=n.length-2;i<r;i+=t){let o=e&&i===0?n.length-3*t:n.length-2*t;for(let s=o;s>i+t;s-=t){let a=n[i],l=n[i+1],h=n[i+t],c=n[i+t+1],u=n[s],f=n[s+1],g=n[s+t],p=n[s+t+1],_=(p-f)*(h-a)-(g-u)*(c-l);if(_===0)continue;let m=((g-u)*(l-f)-(p-f)*(a-u))/_,x=((h-a)*(l-f)-(c-l)*(a-u))/_;if(m>0&&m<1&&x>0&&x<1){let w=a+m*(h-a),v=l+m*(c-l);n[i+t]=w,n[i+t+1]=v,n.splice(i+2*t,s-i-t);break}}}return n}var Yc;function h_(){return Yc||(Yc=new Intl.Segmenter(void 0,{granularity:"grapheme"})),Yc}function Gf(n,t,e,i,r,o,s,a,l,h,c,u,f=!0){let g=n[t],p=n[t+1],_=0,m=0,x=0,w=0;function v(){_=g,m=p,t+=i,g=n[t],p=n[t+1],w+=x,x=Math.sqrt((g-_)*(g-_)+(p-m)*(p-m))}do v();while(t<e-i&&w+x<o);let y=x===0?0:(o-w)/x,E=Gt(_,g,y),R=Gt(m,p,y),A=t-i,S=w,T=o+a*l(h,r,c);for(;t<e-i&&w+x<T;)v();y=x===0?0:(T-w)/x;let I=Gt(_,g,y),z=Gt(m,p,y),G=!1;if(f)if(u){let k=[E,R,I,z];Po(k,0,4,2,u,k,k),G=k[0]>k[2]}else G=E>I;let F=Math.PI,B=[],lt=A+i===t;t=A,x=0,w=S,g=n[t],p=n[t+1];let M;if(lt){v(),M=Math.atan2(p-m,g-_),G&&(M+=M>0?-F:F);let k=(I+E)/2,$=(z+R)/2;return B[0]=[k,$,(T-o)/2,M,r],B}r=r.replace(/\n/g," ");let X=Array.from(h_().segment(r),k=>k.segment);for(let k=0,$=X.length;k<$;){v();let N=Math.atan2(p-m,g-_);if(G&&(N+=N>0?-F:F),M!==void 0){let Ct=N-M;if(Ct+=Ct>F?-2*F:Ct<-F?2*F:0,Math.abs(Ct)>s)return null}M=N;let tt=k,it=0;for(;k<$;++k){let Ct=G?$-k-1:k,st=a*l(h,X[Ct],c);if(t+i<e&&w+x<o+it+st/2)break;it+=st}if(k===tt)continue;let vt=(G?X.slice($-k,$-tt):X.slice(tt,k)).join("");y=x===0?0:(o+it/2-w)/x;let L=Gt(_,g,y),Jt=Gt(m,p,y);B.push([L,Jt,it/2,N,vt]),o+=it}return B}var $n=ut(),ki=[],di=[],fi=[],Oi=[];function Xf(n){return n[3].declutterBox}var Wf=new RegExp("[\u0591-\u08FF\uFB1D-\uFDFF\uFE70-\uFEFC\u0800-\u0FFF\uE800-\uEFFF]");function Uc(n,t){return t==="start"?t=Wf.test(n)?"right":"left":t==="end"&&(t=Wf.test(n)?"left":"right"),qr[t]}function u_(n,t,e){return e>0&&n.push(`4-`,""),n.push(t,""),n}function d_(n,t,e){return e%2===0&&(n+=t),n}var Kc=class{constructor(t,e,i,r,o){this.overlaps=i,this.pixelRatio=e,this.resolution=t,this.alignAndScaleFill_,this.instructions=r.instructions,this.coordinates=r.coordinates,this.coordinateCache_={},this.renderedTransform_=Mt(),this.hitDetectionInstructions=r.hitDetectionInstructions,this.pixelCoordinates_=null,this.viewRotation_=0,this.fillStates=r.fillStates||{},this.strokeStates=r.strokeStates||{},this.textStates=r.textStates||{},this.widths_={},this.labels_={},this.zIndexContext_=o?new bs:null}getZIndexContext(){return this.zIndexContext_}createLabel(t,e,i,r){let o=t+e+i+r;if(this.labels_[o])return this.labels_[o];let s=r?this.strokeStates[r]:null,a=i?this.fillStates[i]:null,l=this.textStates[e],h=this.pixelRatio,c=[l.scale[0]*h,l.scale[1]*h],u=l.justify?qr[l.justify]:Uc(Array.isArray(t)?t[0]:t,l.textAlign||Pi),f=r&&s.lineWidth?s.lineWidth:0,g=Array.isArray(t)?t:String(t).split(`5-`).reduce(u_,[]),{width:p,height:_,widths:m,heights:x,lineWidths:w}=qd(l,g),v=p+f,y=[],E=(v+2)*c[0],R=(_+f)*c[1],A={width:E<0?Math.floor(E):Math.ceil(E),height:R<0?Math.floor(R):Math.ceil(R),contextInstructions:y};(c[0]!=1||c[1]!=1)&&y.push("scale",c),r&&(y.push("strokeStyle",s.strokeStyle),y.push("lineWidth",f),y.push("lineCap",s.lineCap),y.push("lineJoin",s.lineJoin),y.push("miterLimit",s.miterLimit),y.push("setLineDash",[s.lineDash]),y.push("lineDashOffset",s.lineDashOffset)),i&&y.push("fillStyle",a.fillStyle),y.push("textBaseline","middle"),y.push("textAlign","center");let S=.5-u,T=u*v+S*f,I=[],z=[],G=0,F=0,B=0,lt=0,M;for(let X=0,k=g.length;X<k;X+=2){let $=g[X];if($===`6-`){F+=G,G=0,T=u*v+S*f,++lt;continue}let N=g[X+1]||l.font;N!==M&&(r&&I.push("font",N),i&&z.push("font",N),M=N),G=Math.max(G,x[B]);let tt=[$,T+S*m[B]+u*(m[B]-w[lt]),.5*(f+G)+F];T+=m[B],r&&I.push("strokeText",tt),i&&z.push("fillText",tt),++B}return Array.prototype.push.apply(y,I),Array.prototype.push.apply(y,z),this.labels_[o]=A,A}replayTextBackground_(t,e,i,r,o,s,a){t.beginPath(),t.moveTo.apply(t,e),t.lineTo.apply(t,i),t.lineTo.apply(t,r),t.lineTo.apply(t,o),t.lineTo.apply(t,e),s&&(this.alignAndScaleFill_=s[2],t.fillStyle=s[1],this.fill_(t)),a&&(this.setStrokeStyle_(t,a),t.stroke())}calculateImageOrLabelDimensions_(t,e,i,r,o,s,a,l,h,c,u,f,g,p,_,m){a*=f[0],l*=f[1];let x=i-a,w=r-l,v=o+h>t?t-h:o,y=s+c>e?e-c:s,E=p[3]+v*f[0]+p[1],R=p[0]+y*f[1]+p[2],A=x-p[3],S=w-p[0];(_||u!==0)&&(ki[0]=A,Oi[0]=A,ki[1]=S,di[1]=S,di[0]=A+E,fi[0]=di[0],fi[1]=S+R,Oi[1]=fi[1]);let T;return u!==0?(T=Dt(Mt(),i,r,1,1,u,-i,-r),dt(T,ki),dt(T,di),dt(T,fi),dt(T,Oi),Qt(Math.min(ki[0],di[0],fi[0],Oi[0]),Math.min(ki[1],di[1],fi[1],Oi[1]),Math.max(ki[0],di[0],fi[0],Oi[0]),Math.max(ki[1],di[1],fi[1],Oi[1]),$n)):Qt(Math.min(A,A+E),Math.min(S,S+R),Math.max(A,A+E),Math.max(S,S+R),$n),g&&(x=Math.round(x),w=Math.round(w)),{drawImageX:x,drawImageY:w,drawImageW:v,drawImageH:y,originX:h,originY:c,declutterBox:{minX:$n[0],minY:$n[1],maxX:$n[2],maxY:$n[3],value:m},canvasTransform:T,scale:f}}replayImageOrLabel_(t,e,i,r,o,s,a){let l=!!(s||a),h=r.declutterBox,c=a?a[2]*r.scale[0]/2:0;return h.minX-c<=e[0]&&h.maxX+c>=0&&h.minY-c<=e[1]&&h.maxY+c>=0&&(l&&this.replayTextBackground_(t,ki,di,fi,Oi,s,a),$d(t,r.canvasTransform,o,i,r.originX,r.originY,r.drawImageW,r.drawImageH,r.drawImageX,r.drawImageY,r.scale)),!0}fill_(t){let e=this.alignAndScaleFill_;if(e){let i=dt(this.renderedTransform_,[0,0]),r=512*this.pixelRatio;t.save(),t.translate(i[0]%r,i[1]%r),e!==1&&t.scale(e,e)}t.fill(),e&&t.restore()}setStrokeStyle_(t,e){t.strokeStyle=e[1],e[1]&&(t.lineWidth=e[2],t.lineCap=e[3],t.lineJoin=e[4],t.miterLimit=e[5],t.lineDashOffset=e[7],t.setLineDash(e[6]))}drawLabelWithPointPlacement_(t,e,i,r){let o=this.textStates[e],s=this.createLabel(t,e,r,i),a=this.strokeStates[i],l=this.pixelRatio,h=Uc(Array.isArray(t)?t[0]:t,o.textAlign||Pi),c=qr[o.textBaseline||cn],u=a&&a.lineWidth?a.lineWidth:0,f=s.width/l-2*o.scale[0],g=h*f+2*(.5-h)*u,p=c*s.height/l+2*(.5-c)*u;return{label:s,anchorX:g,anchorY:p}}execute_(t,e,i,r,o,s,a,l){let h=this.zIndexContext_,c;this.pixelCoordinates_&&Nt(i,this.renderedTransform_)?c=this.pixelCoordinates_:(this.pixelCoordinates_||(this.pixelCoordinates_=[]),c=jt(this.coordinates,0,this.coordinates.length,2,i,this.pixelCoordinates_),ku(this.renderedTransform_,i));let u=0,f=r.length,g=0,p,_=[],m,x,w,v,y,E,R,A,S,T,I,z,G,F=0,B=0,lt=this.coordinateCache_,M=this.viewRotation_,X=Math.round(Math.atan2(-i[1],i[0])*1e12)/1e12,k={context:t,pixelRatio:this.pixelRatio,resolution:this.resolution,rotation:M},$=this.instructions!=r||this.overlaps?0:200,N,tt,it,vt;for(;u<f;){let L=r[u];switch(L[0]){case D.BEGIN_GEOMETRY:N=L[1],vt=L[3],N.getGeometry()?a!==void 0&&!ht(a,vt.getExtent())?u=L[2]+1:++u:u=L[2],h&&(h.zIndex=L[4]);break;case D.BEGIN_PATH:F>$&&(this.fill_(t),F=0),B>$&&(t.stroke(),B=0),!F&&!B&&(t.beginPath(),y=NaN,E=NaN),++u;break;case D.CIRCLE:g=L[1],w=L[2]??0;let Ct=c[g],st=c[g+1],Re=c[g+2]-w,Xi=c[g+3]-w,re=Re-Ct,rr=Xi-st,io=Math.sqrt(re*re+rr*rr);t.moveTo(Ct+io,st),t.arc(Ct,st,io,0,2*Math.PI,!0),++u;break;case D.CLOSE_PATH:t.closePath(),++u;break;case D.CUSTOM:g=L[1],p=L[2];let Wi=L[3],Yi=L[4],_n=L[5];k.geometry=Wi,k.feature=N,u in lt||(lt[u]=[]);let Ve=lt[u];_n?_n(c,g,p,2,Ve):(Ve[0]=c[g],Ve[1]=c[g+1],Ve.length=2),h&&(h.zIndex=L[6]),Yi(Ve,k),++u;break;case D.DRAW_IMAGE:g=L[1],p=L[2],S=L[3],m=L[4],x=L[5];let xn=L[6],or=L[7],sr=L[8],no=L[9],mi=L[10],ar=L[11],Vg=L[12],ro=L[13];v=L[14]||"declutter";let lr=L[15];if(!S&&L.length>=20){T=L[19],I=L[20],z=L[21],G=L[22];let bt=this.drawLabelWithPointPlacement_(T,I,z,G);S=bt.label,L[3]=S;let Te=L[23];m=(bt.anchorX-Te)*this.pixelRatio,L[4]=m;let oe=L[24];x=(bt.anchorY-oe)*this.pixelRatio,L[5]=x,xn=S.height,L[6]=xn,ro=S.width,L[13]=ro}let Bs;L.length>25&&(Bs=L[25]);let js,oo,so;L.length>17?(js=L[16],oo=L[17],so=L[18]):(js=si,oo=null,so=null),mi&&X?ar+=M:!mi&&!X&&(ar-=M);let Bg=0;for(;g<p;g+=2){if(Bs&&Bs[Bg++]<ro/this.pixelRatio)continue;let bt=this.calculateImageOrLabelDimensions_(S.width,S.height,c[g],c[g+1],ro,xn,m,x,sr,no,ar,Vg,o,js,!!oo||!!so,N),Te=[t,e,S,bt,or,oo,so];if(l){let oe,Ie,se;if(lr){let gt=p-g;if(!lr[gt]){lr[gt]={args:Te,declutterMode:v};continue}let Kt=lr[gt];oe=Kt.args,Ie=Kt.declutterMode,delete lr[gt],se=Xf(oe)}let Be,je;if(oe&&(Ie!=="declutter"||!l.collides(se))&&(Be=!0),(v!=="declutter"||!l.collides(bt.declutterBox))&&(je=!0),Ie==="declutter"&&v==="declutter"){let gt=Be&&je;Be=gt,je=gt}Be&&(Ie!=="none"&&l.insert(se),this.replayImageOrLabel_.apply(this,oe)),je&&(v!=="none"&&l.insert(bt.declutterBox),this.replayImageOrLabel_.apply(this,Te))}else this.replayImageOrLabel_.apply(this,Te)}++u;break;case D.DRAW_CHARS:let Lh=L[1],Ah=L[2],Hs=L[3],jg=L[4];G=L[5];let Hg=L[6],Mh=L[7],Ph=L[8];z=L[9];let qs=L[10];T=L[11],Array.isArray(T)&&(T=T.reduce(d_,"")),I=L[12];let kh=[L[13],L[13]];v=L[14]||"declutter";let qg=L[15],Oh=L[16],$s=this.textStates[I],cr=$s.font,hr=[$s.scale[0]*Mh,$s.scale[1]*Mh],ur;cr in this.widths_?ur=this.widths_[cr]:(ur={},this.widths_[cr]=ur);let Dh=Nf(c,Lh,Ah,2),Fh=Math.abs(hr[0])*Vl(cr,T,ur);if(jg||Fh<=Dh){let bt=this.textStates[I].textAlign,Te=(Dh-Fh)*Uc(T,bt),oe=Gf(c,Lh,Ah,2,T,Te,Hg,Math.abs(hr[0]),Vl,cr,ur,X?0:this.viewRotation_,qg);t:if(oe){let Ie=[],se,Be,je,gt,Kt;if(z)for(se=0,Be=oe.length;se<Be;++se){Kt=oe[se],je=Kt[4],gt=this.createLabel(je,I,"",z),m=Kt[2]+(hr[0]<0?-qs:qs)-Oh,x=Hs*gt.height+(.5-Hs)*2*qs*hr[1]/hr[0]-Ph;let He=this.calculateImageOrLabelDimensions_(gt.width,gt.height,Kt[0],Kt[1],gt.width,gt.height,m,x,0,0,Kt[3],kh,!1,si,!1,N);if(l&&v==="declutter"&&l.collides(He.declutterBox))break t;Ie.push([t,e,gt,He,1,null,null])}if(G)for(se=0,Be=oe.length;se<Be;++se){Kt=oe[se],je=Kt[4],gt=this.createLabel(je,I,G,""),m=Kt[2]-Oh,x=Hs*gt.height-Ph;let He=this.calculateImageOrLabelDimensions_(gt.width,gt.height,Kt[0],Kt[1],gt.width,gt.height,m,x,0,0,Kt[3],kh,!1,si,!1,N);if(l&&v==="declutter"&&l.collides(He.declutterBox))break t;Ie.push([t,e,gt,He,1,null,null])}l&&v!=="none"&&l.load(Ie.map(Xf));for(let He=0,$g=Ie.length;He<$g;++He)this.replayImageOrLabel_.apply(this,Ie[He])}}++u;break;case D.END_GEOMETRY:if(s!==void 0){N=L[1];let bt=s(N,vt,v);if(bt)return bt}++u;break;case D.FILL:$?F++:this.fill_(t),++u;break;case D.MOVE_TO_LINE_TO:g=L[1],p=L[2],w=L[3];let Ui,dr,ao;if(w){let Te=(L[4]??!1)||Math.abs(c[g]-c[p-2])<1e-6&&Math.abs(c[g+1]-c[p-1])<1e-6;Ts(c,g,p,2,w,Te,_),Is(_,2,Te),Ui=_,dr=0,ao=Ui.length}else Ui=c,dr=g,ao=p;tt=Ui[dr],it=Ui[dr+1],t.moveTo(tt,it),y=tt+.5|0,E=it+.5|0;for(let bt=dr+2;bt<ao;bt+=2)tt=Ui[bt],it=Ui[bt+1],R=tt+.5|0,A=it+.5|0,(bt==ao-2||R!==y||A!==E)&&(t.lineTo(tt,it),y=R,E=A);++u;break;case D.SET_FILL_STYLE:this.alignAndScaleFill_=L[2],F?(this.fill_(t),F=0,B&&(t.stroke(),B=0)):B&&L[1]&&(t.stroke(),B=0),t.fillStyle=L[1],++u;break;case D.SET_STROKE_STYLE:F&&L[1]&&(this.fill_(t),F=0),B&&(t.stroke(),B=0),this.setStrokeStyle_(t,L),++u;break;case D.STROKE:$?B++:t.stroke(),++u;break;default:++u;break}}F&&this.fill_(t),B&&t.stroke()}execute(t,e,i,r,o,s){this.viewRotation_=r,this.execute_(t,e,i,this.instructions,o,void 0,void 0,s)}executeHitDetection(t,e,i,r,o){return this.viewRotation_=i,this.execute_(t,[t.canvas.width,t.canvas.height],e,this.hitDetectionInstructions,!0,r,o)}},Yf=Kc;var Di=["Polygon","Circle","LineString","Image","Text","Default"],Bc=["Image","Text"],Uf=Di.filter(n=>!Bc.includes(n)),Kf=!1,Zf=!1;function f_(){let n=0,t=i=>{let r=nt(1,1,null,{willReadFrequently:i}),o=0,s=performance.now();for(;performance.now()-s<50;++o)r.fillStyle=`rgba(255,0,${o%256},1)`,r.fillRect(0,0,1,1),r.getImageData(0,0,1,1);return n=o>n?o:n,o};Kf={[t(!0)]:!0,[t(!1)]:!1,[t(void 0)]:void 0}[n],Zf=!0}var Vc=class{constructor(t,e,i,r,o,s,a){this.maxExtent_=t,this.overlaps_=r,this.pixelRatio_=i,this.resolution_=e,this.renderBuffer_=s,this.executorsByZIndex_={},this.hitDetectionContext_=null,this.hitDetectionTransform_=Mt(),this.renderedContext_=null,this.deferredZIndexContexts_={},this.createExecutors_(o,a)}clip(t,e){let i=this.getClipCoords(e);t.beginPath(),t.moveTo(i[0],i[1]),t.lineTo(i[2],i[3]),t.lineTo(i[4],i[5]),t.lineTo(i[6],i[7]),t.clip()}createExecutors_(t,e){for(let i in t){let r=this.executorsByZIndex_[i];r===void 0&&(r={},this.executorsByZIndex_[i]=r);let o=t[i];for(let s in o){let a=o[s];r[s]=new Yf(this.resolution_,this.pixelRatio_,this.overlaps_,a,e)}}}hasExecutors(t){for(let e in this.executorsByZIndex_){let i=this.executorsByZIndex_[e];for(let r=0,o=t.length;r<o;++r)if(t[r]in i)return!0}return!1}forEachFeatureAtCoordinate(t,e,i,r,o,s){Zf===!1&&f_(),r=Math.round(r);let a=r*2+1,l=Dt(this.hitDetectionTransform_,r+.5,r+.5,1/e,-1/e,-i,-t[0],-t[1]),h=!this.hitDetectionContext_;h&&(this.hitDetectionContext_=nt(a,a,null,{willReadFrequently:Kf}));let c=this.hitDetectionContext_;c.canvas.width!==a||c.canvas.height!==a?(c.canvas.width=a,c.canvas.height=a):h||c.clearRect(0,0,a,a);let u;this.renderBuffer_!==void 0&&(u=ut(),Hi(u,t),bn(u,e*(this.renderBuffer_+r),u));let f=g_(r),g;function p(E,R,A){let S=c.getImageData(0,0,a,a).data;for(let T=0,I=f.length;T<I;T++)if(S[f[T]]>0){if(!s||A==="none"||g!=="Image"&&g!=="Text"||s.includes(E)){let z=(f[T]-3)/4,G=r-z%a,F=r-(z/a|0),B=o(E,R,G*G+F*F);if(B)return B}c.clearRect(0,0,a,a);break}}let _=Object.keys(this.executorsByZIndex_).map(Number);_.sort(Vt);let m,x,w,v,y;for(m=_.length-1;m>=0;--m){let E=_[m].toString();for(w=this.executorsByZIndex_[E],x=Di.length-1;x>=0;--x)if(g=Di[x],v=w[g],v!==void 0&&(y=v.executeHitDetection(c,l,i,p,u),y))return y}}getClipCoords(t){let e=this.maxExtent_;if(!e)return null;let i=e[0],r=e[1],o=e[2],s=e[3],a=[i,r,i,s,o,s,o,r];return jt(a,0,8,2,t,a),a}isEmpty(){return fe(this.executorsByZIndex_)}execute(t,e,i,r,o,s,a){let l=Object.keys(this.executorsByZIndex_).map(Number);l.sort(a?Xh:Vt),s=s||Di;let h=Di.length;for(let c=0,u=l.length;c<u;++c){let f=l[c].toString(),g=this.executorsByZIndex_[f];for(let p=0,_=s.length;p<_;++p){let m=s[p],x=g[m];if(x!==void 0){let w=a===null?void 0:x.getZIndexContext(),v=w?w.getContext():t,y=this.maxExtent_&&m!=="Image"&&m!=="Text";if(y&&(v.save(),this.clip(v,i)),!w||m==="Text"||m==="Image"?x.execute(v,e,i,r,o,a):w.pushFunction(E=>x.execute(E,e,i,r,o,a)),y&&v.restore(),w){w.offset();let E=l[c]*h+Di.indexOf(m);this.deferredZIndexContexts_[E]||(this.deferredZIndexContexts_[E]=[]),this.deferredZIndexContexts_[E].push(w)}}}}this.renderedContext_=t}getDeferredZIndexContexts(){return this.deferredZIndexContexts_}getRenderedContext(){return this.renderedContext_}renderDeferred(){let t=this.deferredZIndexContexts_,e=Object.keys(t).map(Number).sort(Vt);for(let i=0,r=e.length;i<r;++i)t[e[i]].forEach(o=>{o.draw(this.renderedContext_),o.clear()}),t[e[i]].length=0}},Zc={};function g_(n){if(Zc[n]!==void 0)return Zc[n];let t=n*2+1,e=n*n,i=new Array(e+1);for(let o=0;o<=n;++o)for(let s=0;s<=n;++s){let a=o*o+s*s;if(a>e)break;let l=i[a];l||(l=[],i[a]=l),l.push(((n+o)*t+(n+s))*4+3),o>0&&l.push(((n-o)*t+(n+s))*4+3),s>0&&(l.push(((n+o)*t+(n-s))*4+3),o>0&&l.push(((n-o)*t+(n-s))*4+3))}let r=[];for(let o=0,s=i.length;o<s;++o)i[o]&&r.push(...i[o]);return Zc[n]=r,r}var Vf=Vc;var jc=class extends Rs{constructor(t,e,i,r,o,s,a){super(),this.context_=t,this.pixelRatio_=e,this.extent_=i,this.transform_=r,this.transformRotation_=r?Vi(Math.atan2(r[1],r[0]),10):0,this.viewRotation_=o,this.squaredTolerance_=s,this.userTransform_=a,this.contextFillState_=null,this.contextStrokeState_=null,this.contextTextState_=null,this.fillState_=null,this.strokeState_=null,this.image_=null,this.imageAnchorX_=0,this.imageAnchorY_=0,this.imageHeight_=0,this.imageOpacity_=0,this.imageOriginX_=0,this.imageOriginY_=0,this.imageRotateWithView_=!1,this.imageRotation_=0,this.imageScale_=[0,0],this.imageWidth_=0,this.text_="",this.textOffsetX_=0,this.textOffsetY_=0,this.textRotateWithView_=!1,this.textRotation_=0,this.textScale_=[0,0],this.textFillState_=null,this.textStrokeState_=null,this.textState_=null,this.pixelCoordinates_=[],this.tmpLocalTransform_=Mt()}drawImages_(t,e,i,r){if(!this.image_)return;let o=jt(t,e,i,r,this.transform_,this.pixelCoordinates_),s=this.context_,a=this.tmpLocalTransform_,l=s.globalAlpha;this.imageOpacity_!=1&&(s.globalAlpha=l*this.imageOpacity_);let h=this.imageRotation_;this.transformRotation_===0&&(h-=this.viewRotation_),this.imageRotateWithView_&&(h+=this.viewRotation_);for(let c=0,u=o.length;c<u;c+=2){let f=o[c]-this.imageAnchorX_,g=o[c+1]-this.imageAnchorY_;if(h!==0||this.imageScale_[0]!=1||this.imageScale_[1]!=1){let p=f+this.imageAnchorX_,_=g+this.imageAnchorY_;Dt(a,p,_,1,1,h,-p,-_),s.save(),s.transform.apply(s,a),s.translate(p,_),s.scale(this.imageScale_[0],this.imageScale_[1]),s.drawImage(this.image_,this.imageOriginX_,this.imageOriginY_,this.imageWidth_,this.imageHeight_,-this.imageAnchorX_,-this.imageAnchorY_,this.imageWidth_,this.imageHeight_),s.restore()}else s.drawImage(this.image_,this.imageOriginX_,this.imageOriginY_,this.imageWidth_,this.imageHeight_,f,g,this.imageWidth_,this.imageHeight_)}this.imageOpacity_!=1&&(s.globalAlpha=l)}drawText_(t,e,i,r){if(!this.textState_||this.text_==="")return;this.textFillState_&&this.setContextFillState_(this.textFillState_),this.textStrokeState_&&this.setContextStrokeState_(this.textStrokeState_),this.setContextTextState_(this.textState_);let o=jt(t,e,i,r,this.transform_,this.pixelCoordinates_),s=this.context_,a=this.textRotation_;for(this.transformRotation_===0&&(a-=this.viewRotation_),this.textRotateWithView_&&(a+=this.viewRotation_);e<i;e+=r){let l=o[e]+this.textOffsetX_,h=o[e+1]+this.textOffsetY_;a!==0||this.textScale_[0]!=1||this.textScale_[1]!=1?(s.save(),s.translate(l-this.textOffsetX_,h-this.textOffsetY_),s.rotate(a),s.translate(this.textOffsetX_,this.textOffsetY_),s.scale(this.textScale_[0],this.textScale_[1]),this.textStrokeState_&&s.strokeText(this.text_,0,0),this.textFillState_&&s.fillText(this.text_,0,0),s.restore()):(this.textStrokeState_&&s.strokeText(this.text_,l,h),this.textFillState_&&s.fillText(this.text_,l,h))}}moveToLineTo_(t,e,i,r,o,s){let a=this.context_,l=jt(t,e,i,r,this.transform_,this.pixelCoordinates_);if(Math.abs(s)>0){let c=l.length,u=o||Math.abs(l[0]-l[c-2])<1e-6&&Math.abs(l[1]-l[c-1])<1e-6;l=Ts(l,0,c,2,s,u,l),Is(l,2,u)}a.moveTo(l[0],l[1]);let h=l.length;o&&(h-=2);for(let c=2;c<h;c+=2)a.lineTo(l[c],l[c+1]);return o&&a.closePath(),i}drawRings_(t,e,i,r,o){for(let s=0,a=i.length;s<a;++s)e=this.moveToLineTo_(t,e,i[s],r,!0,o);return e}drawCircle(t){if(this.squaredTolerance_&&(t=t.simplifyTransformed(this.squaredTolerance_,this.userTransform_)),!!ht(this.extent_,t.getExtent())){if(this.fillState_||this.strokeState_){this.fillState_&&this.setContextFillState_(this.fillState_),this.strokeState_&&this.setContextStrokeState_(this.strokeState_);let e=Wu(t,this.transform_,this.pixelCoordinates_),i=e[2]-e[0],r=e[3]-e[1],o=Math.sqrt(i*i+r*r),s=this.context_;s.beginPath(),s.arc(e[0],e[1],o,0,2*Math.PI),this.fillState_&&s.fill(),this.strokeState_&&s.stroke()}this.text_!==""&&this.drawText_(t.getCenter(),0,2,2)}}setStyle(t){this.setFillStrokeStyle(t.getFill(),t.getStroke()),this.setImageStyle(t.getImage()),this.setTextStyle(t.getText())}setTransform(t){this.transform_=t}drawGeometry(t){switch(t.getType()){case"Point":this.drawPoint(t);break;case"LineString":this.drawLineString(t);break;case"Polygon":this.drawPolygon(t);break;case"MultiPoint":this.drawMultiPoint(t);break;case"MultiLineString":this.drawMultiLineString(t);break;case"MultiPolygon":this.drawMultiPolygon(t);break;case"GeometryCollection":this.drawGeometryCollection(t);break;case"Circle":this.drawCircle(t);break;default:}}drawFeature(t,e){let i=e.getGeometryFunction()(t);i&&(this.setStyle(e),this.drawGeometry(i))}drawGeometryCollection(t){let e=t.getGeometriesArray();for(let i=0,r=e.length;i<r;++i)this.drawGeometry(e[i])}drawPoint(t){this.squaredTolerance_&&(t=t.simplifyTransformed(this.squaredTolerance_,this.userTransform_));let e=t.getFlatCoordinates(),i=t.getStride();this.image_&&this.drawImages_(e,0,e.length,i),this.text_!==""&&this.drawText_(e,0,e.length,i)}drawMultiPoint(t){this.squaredTolerance_&&(t=t.simplifyTransformed(this.squaredTolerance_,this.userTransform_));let e=t.getFlatCoordinates(),i=t.getStride();this.image_&&this.drawImages_(e,0,e.length,i),this.text_!==""&&this.drawText_(e,0,e.length,i)}drawLineString(t){if(this.squaredTolerance_&&(t=t.simplifyTransformed(this.squaredTolerance_,this.userTransform_)),!!ht(this.extent_,t.getExtent())){if(this.strokeState_){this.setContextStrokeState_(this.strokeState_);let e=this.context_,i=t.getFlatCoordinates();e.beginPath(),this.moveToLineTo_(i,0,i.length,t.getStride(),!1,this.strokeState_.strokeOffset),e.stroke()}if(this.text_!==""){let e=t.getFlatMidpoint();this.drawText_(e,0,2,2)}}}drawMultiLineString(t){this.squaredTolerance_&&(t=t.simplifyTransformed(this.squaredTolerance_,this.userTransform_));let e=t.getExtent();if(ht(this.extent_,e)){if(this.strokeState_){this.setContextStrokeState_(this.strokeState_);let i=this.context_,r=t.getFlatCoordinates(),o=0,s=t.getEnds(),a=t.getStride();i.beginPath();for(let l=0,h=s.length;l<h;++l)o=this.moveToLineTo_(r,o,s[l],a,!1,this.strokeState_.strokeOffset);i.stroke()}if(this.text_!==""){let i=t.getFlatMidpoints();this.drawText_(i,0,i.length,2)}}}drawPolygon(t){if(this.squaredTolerance_&&(t=t.simplifyTransformed(this.squaredTolerance_,this.userTransform_)),!!ht(this.extent_,t.getExtent())){if(this.strokeState_||this.fillState_){this.fillState_&&this.setContextFillState_(this.fillState_),this.strokeState_&&this.setContextStrokeState_(this.strokeState_);let e=this.context_;e.beginPath(),this.drawRings_(t.getOrientedFlatCoordinates(),0,t.getEnds(),t.getStride(),this.strokeState_?.strokeOffset),this.fillState_&&e.fill(),this.strokeState_&&e.stroke()}if(this.text_!==""){let e=t.getFlatInteriorPoint();this.drawText_(e,0,2,2)}}}drawMultiPolygon(t){if(this.squaredTolerance_&&(t=t.simplifyTransformed(this.squaredTolerance_,this.userTransform_)),!!ht(this.extent_,t.getExtent())){if(this.strokeState_||this.fillState_){this.fillState_&&this.setContextFillState_(this.fillState_),this.strokeState_&&this.setContextStrokeState_(this.strokeState_);let e=this.context_,i=t.getOrientedFlatCoordinates(),r=0,o=t.getEndss(),s=t.getStride();e.beginPath();for(let a=0,l=o.length;a<l;++a){let h=o[a];r=this.drawRings_(i,r,h,s,this.strokeState_?.strokeOffset)}this.fillState_&&e.fill(),this.strokeState_&&e.stroke()}if(this.text_!==""){let e=t.getFlatInteriorPoints();this.drawText_(e,0,e.length,2)}}}setContextFillState_(t){let e=this.context_,i=this.contextFillState_;i?i.fillStyle!=t.fillStyle&&(i.fillStyle=t.fillStyle,e.fillStyle=t.fillStyle):(e.fillStyle=t.fillStyle,this.contextFillState_={fillStyle:t.fillStyle})}setContextStrokeState_(t){let e=this.context_,i=this.contextStrokeState_;i?(i.lineCap!=t.lineCap&&(i.lineCap=t.lineCap,e.lineCap=t.lineCap),Nt(i.lineDash,t.lineDash)||e.setLineDash(i.lineDash=t.lineDash),i.lineDashOffset!=t.lineDashOffset&&(i.lineDashOffset=t.lineDashOffset,e.lineDashOffset=t.lineDashOffset),i.lineJoin!=t.lineJoin&&(i.lineJoin=t.lineJoin,e.lineJoin=t.lineJoin),i.lineWidth!=t.lineWidth&&(i.lineWidth=t.lineWidth,e.lineWidth=t.lineWidth),i.miterLimit!=t.miterLimit&&(i.miterLimit=t.miterLimit,e.miterLimit=t.miterLimit),i.strokeStyle!=t.strokeStyle&&(i.strokeStyle=t.strokeStyle,e.strokeStyle=t.strokeStyle)):(e.lineCap=t.lineCap,e.setLineDash(t.lineDash),e.lineDashOffset=t.lineDashOffset,e.lineJoin=t.lineJoin,e.lineWidth=t.lineWidth,e.miterLimit=t.miterLimit,e.strokeStyle=t.strokeStyle,this.contextStrokeState_={lineCap:t.lineCap,lineDash:t.lineDash,lineDashOffset:t.lineDashOffset,lineJoin:t.lineJoin,lineWidth:t.lineWidth,miterLimit:t.miterLimit,strokeStyle:t.strokeStyle})}setContextTextState_(t){let e=this.context_,i=this.contextTextState_,r=t.textAlign?t.textAlign:Pi;i?(i.font!=t.font&&(i.font=t.font,e.font=t.font),i.textAlign!=r&&(i.textAlign=r,e.textAlign=r),i.textBaseline!=t.textBaseline&&(i.textBaseline=t.textBaseline,e.textBaseline=t.textBaseline)):(e.font=t.font,e.textAlign=r,e.textBaseline=t.textBaseline,this.contextTextState_={font:t.font,textAlign:r,textBaseline:t.textBaseline})}setFillStrokeStyle(t,e){if(!t)this.fillState_=null;else{let i=t.getColor();this.fillState_={fillStyle:Ht(i||Tt)}}if(!e)this.strokeState_=null;else{let i=e.getColor(),r=e.getLineCap(),o=e.getLineDash(),s=e.getLineDashOffset(),a=e.getLineJoin(),l=e.getWidth(),h=e.getMiterLimit(),c=o||qt,u=e.getOffset();this.strokeState_={lineCap:r!==void 0?r:Xe,lineDash:this.pixelRatio_===1?c:c.map(f=>f*this.pixelRatio_),lineDashOffset:(s||$t)*this.pixelRatio_,lineJoin:a!==void 0?a:We,lineWidth:(l!==void 0?l:ai)*this.pixelRatio_,miterLimit:h!==void 0?h:oi,strokeStyle:Ht(i||Ut),strokeOffset:(u??0)*this.pixelRatio_}}}setImageStyle(t){let e;if(!t||!(e=t.getSize())){this.image_=null;return}let i=t.getPixelRatio(this.pixelRatio_),r=t.getAnchor(),o=t.getOrigin();this.image_=t.getImage(this.pixelRatio_),this.imageAnchorX_=r[0]*i,this.imageAnchorY_=r[1]*i,this.imageHeight_=e[1]*i,this.imageOpacity_=t.getOpacity(),this.imageOriginX_=o[0],this.imageOriginY_=o[1],this.imageRotateWithView_=t.getRotateWithView(),this.imageRotation_=t.getRotation();let s=t.getScaleArray();this.imageScale_=[s[0]*this.pixelRatio_/i,s[1]*this.pixelRatio_/i],this.imageWidth_=e[0]*i}setTextStyle(t){if(!t)this.text_="";else{let e=t.getFill();if(!e)this.textFillState_=null;else{let g=e.getColor();this.textFillState_={fillStyle:Ht(g||Tt)}}let i=t.getStroke();if(!i)this.textStrokeState_=null;else{let g=i.getColor(),p=i.getLineCap(),_=i.getLineDash(),m=i.getLineDashOffset(),x=i.getLineJoin(),w=i.getWidth(),v=i.getMiterLimit();this.textStrokeState_={lineCap:p!==void 0?p:Xe,lineDash:_||qt,lineDashOffset:m||$t,lineJoin:x!==void 0?x:We,lineWidth:w!==void 0?w:ai,miterLimit:v!==void 0?v:oi,strokeStyle:Ht(g||Ut)}}let r=t.getFont(),o=t.getOffsetX(),s=t.getOffsetY(),a=t.getRotateWithView(),l=t.getRotation(),h=t.getScaleArray(),c=t.getText(),u=t.getTextAlign(),f=t.getTextBaseline();this.textState_={font:r!==void 0?r:as,textAlign:u!==void 0?u:Pi,textBaseline:f!==void 0?f:cn},this.text_=c!==void 0?Array.isArray(c)?c.reduce((g,p,_)=>g+=_%2?" ":p,""):c:"",this.textOffsetX_=o!==void 0?this.pixelRatio_*o:0,this.textOffsetY_=s!==void 0?this.pixelRatio_*s:0,this.textRotateWithView_=a!==void 0?a:!1,this.textRotation_=l!==void 0?l:0,this.textScale_=[this.pixelRatio_*h[0],this.pixelRatio_*h[1]]}}},Bf=jc;var be=.5;function jf(n,t,e,i,r,o,s,a,l){let h=l?Ci(r,l):r,c=n[0]*be,u=n[1]*be,f=nt(c,u);f.imageSmoothingEnabled=!1;let g=f.canvas,p=new Bf(f,be,r,null,s,a,l?Ji(tn(),l):null),_=e.length,m=Math.floor((256*256*256-1)/_),x={};for(let v=1;v<=_;++v){let y=e[v-1],E=y.getStyleFunction()||i;if(!E)continue;let R=E(y,o);if(!R)continue;Array.isArray(R)||(R=[R]);let S=(v*m).toString(16).padStart(7,"#00000");for(let T=0,I=R.length;T<I;++T){let z=R[T],G=z.getGeometryFunction()(y);if(!G||!ht(h,G.getExtent()))continue;let F=z.clone(),B=F.getFill();B&&B.setColor(S);let lt=F.getStroke();lt&&(lt.setColor(S),lt.setLineDash(null)),F.setText(void 0);let M=z.getImage();if(M){let N=M.getImageSize();if(!N)continue;let tt=nt(N[0],N[1],void 0,{alpha:!1}),it=tt.canvas;tt.fillStyle=S,tt.fillRect(0,0,it.width,it.height),F.setImage(new hn({img:it,anchor:M.getAnchor(),anchorXUnits:"pixels",anchorYUnits:"pixels",offset:M.getOrigin(),opacity:1,size:M.getSize(),scale:M.getScale(),rotation:M.getRotation(),rotateWithView:M.getRotateWithView()}))}let X=F.getZIndex()||0,k=x[X];k||(k={},x[X]=k,k.Polygon=[],k.Circle=[],k.LineString=[],k.Point=[]);let $=G.getType();if($==="GeometryCollection"){let N=G.getGeometriesArrayRecursive();for(let tt=0,it=N.length;tt<it;++tt){let vt=N[tt];k[vt.getType().replace("Multi","")].push(vt,F)}}else k[$.replace("Multi","")].push(G,F)}}let w=Object.keys(x).map(Number).sort(Vt);for(let v=0,y=w.length;v<y;++v){let E=x[w[v]];for(let R in E){let A=E[R];for(let S=0,T=A.length;S<T;S+=2){p.setStyle(A[S+1]);for(let I=0,z=t.length;I<z;++I)p.setTransform(t[I]),p.drawGeometry(A[S])}}}return f.getImageData(0,0,g.width,g.height)}function Hf(n,t,e){let i=[];if(e){let r=Math.floor(Math.round(n[0])*be),o=Math.floor(Math.round(n[1])*be),s=(et(r,0,e.width-1)+et(o,0,e.height-1)*e.width)*4,a=e.data[s],l=e.data[s+1],c=e.data[s+2]+256*(l+256*a),u=Math.floor((256*256*256-1)/t.length);c&&c%u===0&&i.push(t[c/u-1])}return i}var p_=.5,qf={Point:v_,LineString:y_,Polygon:b_,MultiPoint:C_,MultiLineString:w_,MultiPolygon:E_,GeometryCollection:x_,Circle:m_};function $f(n,t){return parseInt(U(n),10)-parseInt(U(t),10)}function Hc(n,t){let e=qc(n,t);return e*e}function qc(n,t){return p_*n/t}function m_(n,t,e,i,r){let o=e.getFill(),s=e.getStroke();if(o||s){let l=n.getBuilder(e.getZIndex(),"Circle");l.setFillStrokeStyle(o,s),l.drawCircle(t,i,r)}let a=e.getText();if(a&&a.getText()){let l=n.getBuilder(e.getZIndex(),"Text");l.setTextStyle(a),l.drawText(t,i,r)}}function $c(n,t,e,i,r,o,s,a){let l=[],h=e.getImage();if(h){let f=!0,g=h.getImageState();g==W.LOADED||g==W.ERROR?f=!1:g==W.IDLE&&h.load(),f&&l.push(h.ready())}let c=e.getFill();c&&c.loading()&&l.push(c.ready());let u=l.length>0;return u&&Promise.all(l).then(()=>r(null)),__(n,t,e,i,o,s,a),u}function __(n,t,e,i,r,o,s){let a=e.getGeometryFunction()(t);if(!a)return;let l=a.simplifyTransformed(i,r);if(e.getRenderer())Jf(n,l,e,t,s);else{let c=qf[l.getType()];c(n,l,e,t,s,o)}}function Jf(n,t,e,i,r){if(t.getType()=="GeometryCollection"){let s=t.getGeometries();for(let a=0,l=s.length;a<l;++a)Jf(n,s[a],e,i,r);return}n.getBuilder(e.getZIndex(),"Default").drawCustom(t,i,e.getRenderer(),e.getHitDetectionRenderer(),r)}function x_(n,t,e,i,r,o){let s=t.getGeometriesArray(),a,l;for(a=0,l=s.length;a<l;++a){let h=qf[s[a].getType()];h(n,s[a],e,i,r,o)}}function y_(n,t,e,i,r){let o=e.getStroke();if(o){let a=n.getBuilder(e.getZIndex(),"LineString");a.setFillStrokeStyle(null,o),a.drawLineString(t,i,r)}let s=e.getText();if(s&&s.getText()){let a=n.getBuilder(e.getZIndex(),"Text");a.setTextStyle(s),a.drawText(t,i,r)}}function w_(n,t,e,i,r){let o=e.getStroke();if(o){let a=n.getBuilder(e.getZIndex(),"LineString");a.setFillStrokeStyle(null,o),a.drawMultiLineString(t,i,r)}let s=e.getText();if(s&&s.getText()){let a=n.getBuilder(e.getZIndex(),"Text");a.setTextStyle(s),a.drawText(t,i,r)}}function E_(n,t,e,i,r){let o=e.getFill(),s=e.getStroke();if(s||o){let l=n.getBuilder(e.getZIndex(),"Polygon");l.setFillStrokeStyle(o,s),l.drawMultiPolygon(t,i,r)}let a=e.getText();if(a&&a.getText()){let l=n.getBuilder(e.getZIndex(),"Text");l.setTextStyle(a),l.drawText(t,i,r)}}function v_(n,t,e,i,r,o){let s=e.getImage(),a=e.getText(),l=a&&a.getText(),h=o&&s&&l?{}:void 0;if(s){if(s.getImageState()!=W.LOADED)return;let c=n.getBuilder(e.getZIndex(),"Image");c.setImageStyle(s,h),c.drawPoint(t,i,r)}if(l){let c=n.getBuilder(e.getZIndex(),"Text");c.setTextStyle(a,h),c.drawText(t,i,r)}}function C_(n,t,e,i,r,o){let s=e.getImage(),a=s&&s.getOpacity()!==0,l=e.getText(),h=l&&l.getText(),c=o&&a&&h?{}:void 0;if(a){if(s.getImageState()!=W.LOADED)return;let u=n.getBuilder(e.getZIndex(),"Image");u.setImageStyle(s,c),u.drawMultiPoint(t,i,r)}if(h){let u=n.getBuilder(e.getZIndex(),"Text");u.setTextStyle(l,c),u.drawText(t,i,r)}}function b_(n,t,e,i,r){let o=e.getFill(),s=e.getStroke();if(o||s){let l=n.getBuilder(e.getZIndex(),"Polygon");l.setFillStrokeStyle(o,s),l.drawPolygon(t,i,r)}let a=e.getText();if(a&&a.getText()){let l=n.getBuilder(e.getZIndex(),"Text");l.setTextStyle(a),l.drawText(t,i,r)}}var Jc=class extends Ss{constructor(t){super(t),this.boundHandleStyleImageChange_=this.handleStyleImageChange_.bind(this),this.animatingOrInteracting_,this.hitDetectionImageData_=null,this.clipExtent_=null,this.extendX_=!1,this.renderedFeatures_=null,this.renderedRevision_=-1,this.renderedResolution_=NaN,this.renderedExtent_=ut(),this.wrappedRenderedExtent_=ut(),this.renderedRotation_,this.renderedCenter_=null,this.renderedProjection_=null,this.renderedPixelRatio_=1,this.renderedRenderOrder_=null,this.renderedFrameDeclutter_,this.replayGroup_=null,this.replayGroupChanged=!0,this.clipping=!0,this.targetContext_=null,this.opacity_=1}renderWorlds(t,e,i){let r=e.extent,o=e.viewState,s=o.center,a=o.resolution,l=o.projection,h=o.rotation,c=l.getExtent(),u=this.getLayer().getSource(),f=this.getLayer().getDeclutter(),g=e.pixelRatio,p=e.viewHints,_=!(p[Rt.ANIMATING]||p[Rt.INTERACTING]),m=this.context,x=Math.round(j(r)/a*g),w=Math.round(ct(r)/a*g),v=u.getWrapX()&&l.canWrapX(),y=v?j(c):null,E=v?Math.ceil((r[2]-c[2])/y)+(this.extendX_?2:1):1,R=v?Math.floor((r[0]-c[0])/y)-(this.extendX_?1:0):0;do{let A=this.getRenderTransform(s,a,0,g,x,w,R*y);e.declutter&&(A=A.slice(0)),t.execute(m,[m.canvas.width,m.canvas.height],A,h,_,i===void 0?Di:i?Bc:Uf,i?f&&e.declutter[f]:void 0)}while(++R<E)}setDrawContext_(){this.opacity_!==1&&(this.targetContext_=this.context,this.context=nt(this.context.canvas.width,this.context.canvas.height,Sc))}resetDrawContext_(){if(this.opacity_!==1&&this.targetContext_){let t=this.targetContext_.globalAlpha;this.targetContext_.globalAlpha=this.opacity_,this.targetContext_.drawImage(this.context.canvas,0,0),this.targetContext_.globalAlpha=t,en(this.context),Sc.push(this.context.canvas),this.context=this.targetContext_,this.targetContext_=null}}renderDeclutter(t){!this.replayGroup_||!this.getLayer().getDeclutter()||this.renderWorlds(this.replayGroup_,t,!0)}renderDeferredInternal(t){this.replayGroup_&&(this.clipExtent_&&this.clipUnrotated(this.context,t,this.clipExtent_),this.replayGroup_.renderDeferred(),this.clipExtent_&&(this.context.restore(),this.clipExtent_=null),this.resetDrawContext_())}renderFrame(t,e){let i=t.layerStatesArray[t.layerIndex];this.opacity_=i.opacity;let r=t.viewState;this.prepareContainer(t,e);let o=this.context,s=this.replayGroup_,a=s&&!s.isEmpty();if(!a&&!(this.getLayer().hasListener(Ft.PRERENDER)||this.getLayer().hasListener(Ft.POSTRENDER)))return this.container;this.setDrawContext_(),this.preRender(o,t);let l=r.projection;this.clipExtent_=null;let h=!1;if(a&&i.extent&&this.clipping){let c=we(i.extent,l);a=ht(c,t.extent),a&&!ke(c,t.extent)&&(t.declutter?this.clipExtent_=c:(this.clipUnrotated(o,t,c),h=!0))}return a&&this.renderWorlds(s,t,this.getLayer().getDeclutter()?!1:void 0),h&&o.restore(),this.postRender(o,t),this.renderedRotation_!==r.rotation&&(this.renderedRotation_=r.rotation,this.hitDetectionImageData_=null),t.declutter||this.resetDrawContext_(),this.container}getFeatures(t){return new Promise(e=>{if(this.frameState&&!this.hitDetectionImageData_&&!this.animatingOrInteracting_){let i=this.frameState.size.slice(),r=this.renderedCenter_,o=this.renderedResolution_,s=this.renderedRotation_,a=this.renderedProjection_,l=this.wrappedRenderedExtent_,h=this.getLayer(),c=[],u=i[0]*be,f=i[1]*be;c.push(this.getRenderTransform(r,o,s,be,u,f,0).slice());let g=h.getSource(),p=a.getExtent();if(g.getWrapX()&&a.canWrapX()&&!ke(p,l)){let m=l[0],x=j(p),w=0,v;for(;m<p[0];)--w,v=x*w,c.push(this.getRenderTransform(r,o,s,be,u,f,v).slice()),m+=x;for(w=0,m=l[2];m>p[2];)++w,v=x*w,c.push(this.getRenderTransform(r,o,s,be,u,f,v).slice()),m-=x}let _=tn();this.hitDetectionImageData_=jf(i,c,this.renderedFeatures_,h.getStyleFunction(),l,o,s,Hc(o,this.renderedPixelRatio_),_?a:null)}e(Hf(t,this.renderedFeatures_,this.hitDetectionImageData_))})}forEachFeatureAtCoordinate(t,e,i,r,o){if(!this.replayGroup_)return;let s=e.viewState.resolution,a=e.viewState.rotation,l=this.getLayer(),h={},c=function(f,g,p){let _=U(f),m=h[_];if(m){if(m!==!0&&p<m.distanceSq){if(p===0)return h[_]=!0,o.splice(o.lastIndexOf(m),1),r(f,l,g);m.geometry=g,m.distanceSq=p}}else{if(p===0)return h[_]=!0,r(f,l,g);o.push(h[_]={feature:f,layer:l,geometry:g,distanceSq:p,callback:r})}},u=this.getLayer().getDeclutter();return this.replayGroup_.forEachFeatureAtCoordinate(t,s,a,i,c,u?e.declutter?.[u]?.all().map(f=>f.value):null)}handleFontsChanged(){let t=this.getLayer();t.getVisible()&&this.replayGroup_&&t.changed()}handleStyleImageChange_(t){this.renderIfReadyAndVisible()}prepareFrame(t){let e=this.getLayer(),i=e.getSource();if(!i)return!1;let r=t.viewHints[Rt.ANIMATING],o=t.viewHints[Rt.INTERACTING],s=e.getUpdateWhileAnimating(),a=e.getUpdateWhileInteracting();if(this.ready&&!s&&r||!a&&o)return this.animatingOrInteracting_=!0,!0;this.animatingOrInteracting_=!1;let l=t.extent,h=t.viewState,c=h.projection,u=h.resolution,f=t.pixelRatio,g=e.getRevision(),p=e.getRenderBuffer(),_=e.getRenderOrder();_===void 0&&(_=$f);let m=h.center.slice(),x=bn(l,p*u),w=x.slice(),v=[x.slice()],y=c.getExtent(),E=i.getWrapX()&&c.canWrapX();if(this.extendX_=!1,E){let M=i.getExtent();M&&!De(M)&&(this.extendX_=M[0]<y[0]||M[2]>y[2])}if(E&&(!ke(y,t.extent)||this.extendX_)){let M=j(y),X=Math.max(j(x)/2,M),k=y[0],$=y[2];this.extendX_&&(k-=M,$+=M),x[0]=k-X,x[2]=$+X,Eo(m,c);let N=ya(v[0],c);N[0]<y[0]&&N[2]<y[2]?v.push([N[0]+M,N[1],N[2]+M,N[3]]):N[0]>y[0]&&N[2]>y[2]&&v.push([N[0]-M,N[1],N[2]-M,N[3]])}if(this.ready&&this.renderedResolution_==u&&this.renderedPixelRatio_===f&&this.renderedRevision_==g&&this.renderedRenderOrder_==_&&this.renderedFrameDeclutter_===!!t.declutter&&ke(this.wrappedRenderedExtent_,x))return Nt(this.renderedExtent_,w)||(this.hitDetectionImageData_=null,this.renderedExtent_=w),this.renderedCenter_=m,this.replayGroupChanged=!1,!0;this.replayGroup_=null;let R=new zf(qc(u,f),x,u,f),A=tn(),S;if(A){for(let M=0,X=v.length;M<X;++M){let k=v[M],$=Ci(k,c);i.loadFeatures($,Pu(u,c),A)}S=Ji(A,c)}else for(let M=0,X=v.length;M<X;++M)i.loadFeatures(v[M],u,c);let T=Hc(u,f),I=!0,z=(M,X)=>{let k,$=M.getStyleFunction()||e.getStyleFunction();if($&&(k=$(M,u)),k){let N=this.renderFeature(M,T,k,R,S,this.getLayer().getDeclutter(),X);I=I&&!N}},G=Ci(x,c),F=i.getFeaturesInExtent(G);_&&F.sort(_);for(let M=0,X=F.length;M<X;++M)z(F[M],M);this.renderedFeatures_=F,this.ready=I;let B=R.finish(),lt=new Vf(x,u,f,i.getOverlaps(),B,e.getRenderBuffer(),!!t.declutter);return this.renderedResolution_=u,this.renderedRevision_=g,this.renderedRenderOrder_=_,this.renderedFrameDeclutter_=!!t.declutter,this.renderedExtent_=w,this.wrappedRenderedExtent_=x,this.renderedCenter_=m,this.renderedProjection_=c,this.renderedPixelRatio_=f,this.replayGroup_=lt,this.hitDetectionImageData_=null,this.replayGroupChanged=!0,!0}renderFeature(t,e,i,r,o,s,a){if(!i)return!1;let l=!1;if(Array.isArray(i))for(let h=0,c=i.length;h<c;++h)l=$c(r,t,i[h],e,this.boundHandleStyleImageChange_,o,s,a)||l;else l=$c(r,t,i,e,this.boundHandleStyleImageChange_,o,s,a);return l}},Qf=Jc;var Qc=class extends ms{constructor(t){super(t)}createRenderer(){return new Qf(this)}},tg=Qc;var S_=!1;function R_(n,t,e,i,r,o,s){let a=new XMLHttpRequest;a.open("GET",typeof n=="function"?n(e,i,r):n,!0),t.getType()=="arraybuffer"&&(a.responseType="arraybuffer"),a.withCredentials=S_,a.onload=function(l){if(!a.status||a.status>=200&&a.status<300){let h=t.getType();try{let c;h=="text"||h=="json"?c=a.responseText:h=="xml"?c=a.responseXML||a.responseText:h=="arraybuffer"&&(c=a.response),c?o(t.readFeatures(c,{extent:e,featureProjection:r}),t.readProjection(c)):s()}catch{s()}}else s()},a.onerror=s,a.send()}function th(n,t){return function(e,i,r,o,s){R_(n,t,e,i,r,(a,l)=>{this.addFeatures(a),o!==void 0&&o(a)},()=>{this.changed(),s!==void 0&&s()})}}function eg(n,t){return[[-1/0,-1/0,1/0,1/0]]}function eh(n,t,e,i,r,o,s){let a,l,h=(e-t)/i;if(h===1)a=t;else if(h===2)a=t,l=r;else if(h!==0){let c=n[t],u=n[t+1],f=0,g=[0];for(let m=t+i;m<e;m+=i){let x=n[m],w=n[m+1];f+=Math.sqrt((x-c)*(x-c)+(w-u)*(w-u)),g.push(f),c=x,u=w}let p=r*f,_=Gh(g,p);_<0?(l=(p-g[-_-2])/(g[-_-1]-g[-_-2]),a=t+(-_-2)*i):a=t+_*i}s=s>1?s:2,o=o||new Array(s);for(let c=0;c<s;++c)o[c]=a===void 0?NaN:l===void 0?n[a+c]:Gt(n[a+c],n[a+i+c],l);return o}var ig=Mt(),$r=class n{constructor(t,e,i,r,o,s){this.styleFunction,this.extent_,this.id_=s,this.type_=t,this.flatCoordinates_=e,this.flatInteriorPoints_=null,this.flatMidpoints_=null,this.ends_=i||null,this.properties_=o,this.squaredTolerance_,this.stride_=r,this.simplifiedGeometry_}get(t){return this.properties_[t]}getExtent(){return this.extent_||(this.extent_=this.type_==="Point"?_o(this.flatCoordinates_):Sn(this.flatCoordinates_,0,this.flatCoordinates_.length,this.stride_)),this.extent_}getFlatInteriorPoint(){if(!this.flatInteriorPoints_){let t=Bt(this.getExtent());this.flatInteriorPoints_=Tr(this.flatCoordinates_,0,this.ends_,this.stride_,t,0)}return this.flatInteriorPoints_}getFlatInteriorPoints(){if(!this.flatInteriorPoints_){let t=id(this.flatCoordinates_,this.ends_),e=xs(this.flatCoordinates_,0,t,this.stride_);this.flatInteriorPoints_=Oo(this.flatCoordinates_,0,t,this.stride_,e)}return this.flatInteriorPoints_}getFlatMidpoint(){return this.flatMidpoints_||(this.flatMidpoints_=eh(this.flatCoordinates_,0,this.flatCoordinates_.length,this.stride_,.5)),this.flatMidpoints_}getFlatMidpoints(){if(!this.flatMidpoints_){this.flatMidpoints_=[];let t=this.flatCoordinates_,e=0,i=this.ends_;for(let r=0,o=i.length;r<o;++r){let s=i[r],a=eh(t,e,s,this.stride_,.5);ge(this.flatMidpoints_,a),e=s}}return this.flatMidpoints_}getId(){return this.id_}getOrientedFlatCoordinates(){return this.flatCoordinates_}getGeometry(){return this}getSimplifiedGeometry(t){return this}simplifyTransformed(t,e){return this}getProperties(){return this.properties_}getPropertiesInternal(){return this.properties_}getStride(){return this.stride_}getStyleFunction(){return this.styleFunction}getType(){return this.type_}transform(t){t=Et(t);let e=t.getExtent(),i=t.getWorldExtent();if(e&&i){let r=ct(i)/ct(e);Dt(ig,i[0],i[3],r,-r,0,0,0),jt(this.flatCoordinates_,0,this.flatCoordinates_.length,this.stride_,ig,this.flatCoordinates_)}}applyTransform(t){t(this.flatCoordinates_,this.flatCoordinates_,this.stride_)}clone(){return new n(this.type_,this.flatCoordinates_.slice(),this.ends_?.slice(),this.stride_,Object.assign({},this.properties_),this.id_)}getEnds(){return this.ends_}enableSimplifyTransformed(){return this.simplifyTransformed=lo((t,e)=>{if(t===this.squaredTolerance_)return this.simplifiedGeometry_;this.simplifiedGeometry_=this.clone(),e&&this.simplifiedGeometry_.applyTransform(e);let i=this.simplifiedGeometry_.getFlatCoordinates(),r;switch(this.type_){case"LineString":i.length=Sr(i,0,this.simplifiedGeometry_.flatCoordinates_.length,this.simplifiedGeometry_.stride_,t,i,0),r=[i.length];break;case"MultiLineString":r=[],i.length=Ju(i,0,this.simplifiedGeometry_.ends_,this.simplifiedGeometry_.stride_,t,i,0,r);break;case"Polygon":r=[],i.length=Rr(i,0,this.simplifiedGeometry_.ends_,this.simplifiedGeometry_.stride_,Math.sqrt(t),i,0,r);break;default:}return r&&(this.simplifiedGeometry_=new n(this.type_,i,r,this.stride_,this.properties_,this.id_)),this.squaredTolerance_=t,this.simplifiedGeometry_}),this}};$r.prototype.getFlatCoordinates=$r.prototype.getOrientedFlatCoordinates;var fn=$r;var ih=class{constructor(t){this.rbush_=new on(t),this.items_={}}insert(t,e){let i={minX:t[0],minY:t[1],maxX:t[2],maxY:t[3],value:e};this.rbush_.insert(i),this.items_[U(e)]=i}load(t,e){let i=new Array(e.length);for(let r=0,o=e.length;r<o;r++){let s=t[r],a=e[r],l={minX:s[0],minY:s[1],maxX:s[2],maxY:s[3],value:a};i[r]=l,this.items_[U(a)]=l}this.rbush_.load(i)}remove(t){let e=U(t),i=this.items_[e];return delete this.items_[e],this.rbush_.remove(i)!==null}update(t,e){let i=this.items_[U(e)],r=[i.minX,i.minY,i.maxX,i.maxY];ji(r,t)||(this.remove(e),this.insert(t,e))}getAll(){return this.rbush_.all().map(function(e){return e.value})}getInExtent(t){let e={minX:t[0],minY:t[1],maxX:t[2],maxY:t[3]};return this.rbush_.search(e).map(function(r){return r.value})}forEach(t){return this.forEach_(this.getAll(),t)}forEachInExtent(t,e){return this.forEach_(this.getInExtent(t),e)}forEach_(t,e){let i;for(let r=0,o=t.length;r<o;r++)if(i=e(t[r]),i)return i;return i}isEmpty(){return fe(this.items_)}clear(){this.rbush_.clear(),this.items_={}}getExtent(t){let e=this.rbush_.toJSON();return Qt(e.minX,e.minY,e.maxX,e.maxY,t)}concat(t){this.rbush_.load(t.rbush_.all());for(let e in t.items_)this.items_[e]=t.items_[e]}},nh=ih;var rh=class extends yt{constructor(t){super(),this.projection=Et(t.projection),this.attributions_=ng(t.attributions),this.attributionsCollapsible_=t.attributionsCollapsible??!0,this.loading=!1,this.state_=t.state!==void 0?t.state:"ready",this.wrapX_=t.wrapX!==void 0?t.wrapX:!1,this.interpolate_=!!t.interpolate,this.viewResolver=null,this.viewRejector=null;let e=this;this.viewPromise_=new Promise(function(i,r){e.viewResolver=i,e.viewRejector=r})}getAttributions(){return this.attributions_}getAttributionsCollapsible(){return this.attributionsCollapsible_}getProjection(){return this.projection}getResolutions(t){return null}getView(){return this.viewPromise_}ready(){let t=this.getState();return t==="ready"?Promise.resolve():t==="error"?Promise.reject(new Error("Source failed to load")):new Promise((e,i)=>{let r=()=>{let o=this.getState();o==="ready"?(this.un("change",r),e()):o==="error"&&(this.un("change",r),i(new Error("Source failed to load")))};this.on("change",r)})}getState(){return this.state_}getWrapX(){return this.wrapX_}getInterpolate(){return this.interpolate_}refresh(){this.changed()}setAttributions(t){this.attributions_=ng(t),this.changed()}setState(t){this.state_=t,this.changed()}};function ng(n){return n?typeof n=="function"?n:(Array.isArray(n)||(n=[n]),t=>n):null}var Ls=rh;var ie={ADDFEATURE:"addfeature",CHANGEFEATURE:"changefeature",CLEAR:"clear",REMOVEFEATURE:"removefeature",FEATURESLOADSTART:"featuresloadstart",FEATURESLOADEND:"featuresloadend",FEATURESLOADERROR:"featuresloaderror"};var Ke=class extends Lt{constructor(t,e,i){super(t),this.feature=e,this.features=i}},oh=class extends Ls{constructor(t){t=t||{},super({attributions:t.attributions,interpolate:!0,projection:void 0,state:"ready",wrapX:t.wrapX!==void 0?t.wrapX:!0}),this.on,this.once,this.un,this.loader_=Qe,this.format_=t.format||null,this.overlaps_=t.overlaps===void 0?!0:t.overlaps,this.url_=t.url,t.loader!==void 0?this.loader_=t.loader:this.url_!==void 0&&(V(this.format_,"`format` must be set when `url` is set"),this.loader_=th(this.url_,this.format_)),this.strategy_=t.strategy!==void 0?t.strategy:eg;let e=t.useSpatialIndex!==void 0?t.useSpatialIndex:!0;this.featuresRtree_=e?new nh:null,this.loadedExtentsRtree_=new nh,this.nullGeometryFeatures_={},this.idIndex_={},this.uidIndex_={},this.featureChangeKeys_={},this.featuresCollection_=null;let i,r;Array.isArray(t.features)?r=t.features:t.features&&(i=t.features,r=i.getArray()),!e&&i===void 0&&(i=new kt(r)),r!==void 0&&this.addFeaturesInternal(r),i!==void 0&&this.bindFeaturesCollection_(i)}addFeature(t){this.addFeatureInternal(t),this.changed()}addFeatureInternal(t){let e=U(t);if(!this.addToIndex_(e,t)){this.featuresCollection_&&this.featuresCollection_.remove(t);return}this.setupChangeEvents_(e,t);let i=t.getGeometry();if(i){let r=i.getExtent();this.featuresRtree_&&this.featuresRtree_.insert(r,t)}else this.nullGeometryFeatures_[e]=t;this.dispatchEvent(new Ke(ie.ADDFEATURE,t))}setupChangeEvents_(t,e){e instanceof fn||(this.featureChangeKeys_[t]=[Z(e,P.CHANGE,this.handleFeatureChange_,this),Z(e,de.PROPERTYCHANGE,this.handleFeatureChange_,this)])}addToIndex_(t,e){let i=!0;if(e.getId()!==void 0){let r=String(e.getId());if(!(r in this.idIndex_))this.idIndex_[r]=e;else if(e instanceof fn){let o=this.idIndex_[r];o instanceof fn?Array.isArray(o)?o.push(e):this.idIndex_[r]=[o,e]:i=!1}else i=!1}return i&&(V(!(t in this.uidIndex_),"The passed `feature` was already added to the source"),this.uidIndex_[t]=e),i}addFeatures(t){this.addFeaturesInternal(t),this.changed()}addFeaturesInternal(t){let e=[],i=[],r=[];for(let o=0,s=t.length;o<s;o++){let a=t[o],l=U(a);this.addToIndex_(l,a)&&i.push(a)}for(let o=0,s=i.length;o<s;o++){let a=i[o],l=U(a);this.setupChangeEvents_(l,a);let h=a.getGeometry();if(h){let c=h.getExtent();e.push(c),r.push(a)}else this.nullGeometryFeatures_[l]=a}if(this.featuresRtree_&&this.featuresRtree_.load(e,r),this.hasListener(ie.ADDFEATURE))for(let o=0,s=i.length;o<s;o++)this.dispatchEvent(new Ke(ie.ADDFEATURE,i[o]))}bindFeaturesCollection_(t){let e=!1;this.addEventListener(ie.ADDFEATURE,function(i){e||(e=!0,t.push(i.feature),e=!1)}),this.addEventListener(ie.REMOVEFEATURE,function(i){e||(e=!0,t.remove(i.feature),e=!1)}),t.addEventListener(At.ADD,i=>{e||(e=!0,this.addFeature(i.element),e=!1)}),t.addEventListener(At.REMOVE,i=>{e||(e=!0,this.removeFeature(i.element),e=!1)}),this.featuresCollection_=t}clear(t){if(t){for(let i in this.featureChangeKeys_)this.featureChangeKeys_[i].forEach(J);this.featuresCollection_||(this.featureChangeKeys_={},this.idIndex_={},this.uidIndex_={})}else if(this.featuresRtree_){this.featuresRtree_.forEach(i=>{this.removeFeatureInternal(i)});for(let i in this.nullGeometryFeatures_)this.removeFeatureInternal(this.nullGeometryFeatures_[i])}this.featuresCollection_&&this.featuresCollection_.clear(),this.featuresRtree_&&this.featuresRtree_.clear(),this.nullGeometryFeatures_={};let e=new Ke(ie.CLEAR);this.dispatchEvent(e),this.changed()}forEachFeature(t){if(this.featuresRtree_)return this.featuresRtree_.forEach(t);this.featuresCollection_&&this.featuresCollection_.forEach(t)}forEachFeatureAtCoordinateDirect(t,e){let i=[t[0],t[1],t[0],t[1]];return this.forEachFeatureInExtent(i,function(r){let o=r.getGeometry();if(o instanceof fn||o.intersectsCoordinate(t))return e(r)})}forEachFeatureInExtent(t,e){if(this.featuresRtree_)return this.featuresRtree_.forEachInExtent(t,e);this.featuresCollection_&&this.featuresCollection_.forEach(e)}forEachFeatureIntersectingExtent(t,e){return this.forEachFeatureInExtent(t,function(i){let r=i.getGeometry();if(r instanceof fn||r.intersectsExtent(t)){let o=e(i);if(o)return o}})}getFeaturesCollection(){return this.featuresCollection_}getFeatures(){let t;return this.featuresCollection_?t=this.featuresCollection_.getArray().slice(0):this.featuresRtree_&&(t=this.featuresRtree_.getAll(),fe(this.nullGeometryFeatures_)||ge(t,Object.values(this.nullGeometryFeatures_))),t}getFeaturesAtCoordinate(t){let e=[];return this.forEachFeatureAtCoordinateDirect(t,function(i){e.push(i)}),e}getFeaturesInExtent(t,e){if(this.featuresRtree_){if(!(e&&e.canWrapX()&&this.getWrapX()))return this.featuresRtree_.getInExtent(t);let r=wo(t,e);return[].concat(...r.map(o=>this.featuresRtree_.getInExtent(o)))}return this.featuresCollection_?this.featuresCollection_.getArray().slice(0):[]}getClosestFeatureToCoordinate(t,e){let i=t[0],r=t[1],o=null,s=[NaN,NaN],a=1/0,l=[-1/0,-1/0,1/0,1/0];return e=e||$e,this.featuresRtree_.forEachInExtent(l,function(h){if(e(h)){let c=h.getGeometry(),u=a;if(a=c instanceof fn?0:c.closestPointXY(i,r,s,a),a<u){o=h;let f=Math.sqrt(a);l[0]=i-f,l[1]=r-f,l[2]=i+f,l[3]=r+f}}}),o}getExtent(t){return this.featuresRtree_?.getExtent(t)??null}getFeatureById(t){let e=this.idIndex_[t.toString()];return e!==void 0?e:null}getFeatureByUid(t){let e=this.uidIndex_[t];return e!==void 0?e:null}getFormat(){return this.format_}getOverlaps(){return this.overlaps_}getUrl(){return this.url_}handleFeatureChange_(t){let e=t.target,i=U(e),r=e.getGeometry();if(!r)i in this.nullGeometryFeatures_||(this.featuresRtree_&&this.featuresRtree_.remove(e),this.nullGeometryFeatures_[i]=e);else{let s=r.getExtent();i in this.nullGeometryFeatures_?(delete this.nullGeometryFeatures_[i],this.featuresRtree_&&this.featuresRtree_.insert(s,e)):this.featuresRtree_&&this.featuresRtree_.update(s,e)}let o=e.getId();if(o!==void 0){let s=o.toString();this.idIndex_[s]!==e&&(this.removeFromIdIndex_(e),this.idIndex_[s]=e)}else this.removeFromIdIndex_(e),this.uidIndex_[i]=e;this.changed(),this.dispatchEvent(new Ke(ie.CHANGEFEATURE,e))}hasFeature(t){let e=t.getId();if(e!==void 0){let i=this.idIndex_[String(e)];return Array.isArray(i)?i.includes(t):i===t}return U(t)in this.uidIndex_}isEmpty(){return this.featuresRtree_?this.featuresRtree_.isEmpty()&&fe(this.nullGeometryFeatures_):this.featuresCollection_?this.featuresCollection_.getLength()===0:!0}loadFeatures(t,e,i){let r=this.loadedExtentsRtree_,o=this.strategy_(t,e,i);for(let s=0,a=o.length;s<a;++s){let l=o[s];if(!r.forEachInExtent(l,function(c){return ke(c.extent,l)})){this.loading=Number(this.loading)+1,this.dispatchEvent(new Ke(ie.FEATURESLOADSTART));let c=p=>{this.loading=Number(this.loading)-1,this.dispatchEvent(new Ke(ie.FEATURESLOADEND,void 0,p))},u=()=>{this.changed(),this.loading=Number(this.loading)-1,this.dispatchEvent(new Ke(ie.FEATURESLOADERROR))},f=!1,g=this.loader_.call(this,l,e,i,p=>f||c(p),()=>f||u());g instanceof Promise?(f=!0,g.then(p=>{this.addFeatures(p),c(p)}).catch(u)):this.loader_.length<4&&(this.loading=!1),r.insert(l,{extent:l.slice()})}}}refresh(){this.clear(!0),this.loadedExtentsRtree_.clear(),super.refresh()}removeLoadedExtent(t){let e=this.loadedExtentsRtree_,i=[];e.forEachInExtent(t,function(r){i.push(r)}),i.forEach(r=>{e.remove(r);let o=xa(r.extent,t);for(let s of o)e.insert(s,{extent:s})})}removeFeatures(t){let e=!1;for(let i=0,r=t.length;i<r;++i)e=this.removeFeatureInternal(t[i])||e;e&&this.changed()}removeFeature(t){if(!t)return;this.removeFeatureInternal(t)&&this.changed()}removeFeatureInternal(t){let e=U(t);if(!(e in this.uidIndex_))return!1;e in this.nullGeometryFeatures_?delete this.nullGeometryFeatures_[e]:this.featuresRtree_&&this.featuresRtree_.remove(t),this.featureChangeKeys_[e]?.forEach(J),delete this.featureChangeKeys_[e];let r=t.getId();if(r!==void 0){let o=r.toString(),s=this.idIndex_[o];s===t?delete this.idIndex_[o]:Array.isArray(s)&&(s.splice(s.indexOf(t),1),s.length===1&&(this.idIndex_[o]=s[0]))}return delete this.uidIndex_[e],this.hasListener(ie.REMOVEFEATURE)&&this.dispatchEvent(new Ke(ie.REMOVEFEATURE,t)),!0}removeFromIdIndex_(t){for(let e in this.idIndex_)if(this.idIndex_[e]===t){delete this.idIndex_[e];break}}setLoader(t){this.loader_=t}setUrl(t){V(this.format_,"`format` must be set when `url` is set"),this.url_=t,this.setLoader(th(t,this.format_))}setOverlaps(t){this.overlaps_=t,this.changed()}},gi=oh;var Jn=[0,0,0],Fi=5,sh=class{constructor(t){let e=t.minZoom,i=t.resolutions;e===void 0&&i&&(e=i.findIndex(s=>s!==void 0)),this.minZoom=e!==void 0?e:0,this.resolutions_=i,V(Yh(this.resolutions_,(s,a)=>a-s,!0),"`resolutions` must be sorted in descending order");let r;if(!t.origins){for(let s=0,a=this.resolutions_.length-1;s<a;++s)if(!r)r=this.resolutions_[s]/this.resolutions_[s+1];else if(this.resolutions_[s]/this.resolutions_[s+1]!==r){r=void 0;break}}this.zoomFactor_=r,this.maxZoom=this.resolutions_.length-1,this.origin_=t.origin!==void 0?t.origin:null,this.origins_=null,t.origins!==void 0&&(this.origins_=t.origins,V(this.origins_.length==this.resolutions_.length,"Number of `origins` and `resolutions` must be equal"));let o=t.extent;o!==void 0&&!this.origin_&&!this.origins_&&(this.origin_=le(o)),V(!this.origin_&&this.origins_||this.origin_&&!this.origins_,"Either `origin` or `origins` must be configured, never both"),this.tileSizes_=null,t.tileSizes!==void 0&&(this.tileSizes_=t.tileSizes,V(this.tileSizes_.length==this.resolutions_.length,"Number of `tileSizes` and `resolutions` must be equal")),this.tileSize_=t.tileSize!==void 0?t.tileSize:this.tileSizes_?null:256,V(!this.tileSize_&&this.tileSizes_||this.tileSize_&&!this.tileSizes_,"Either `tileSize` or `tileSizes` must be configured, never both"),this.extent_=o!==void 0?o:null,this.fullTileRanges_=null,this.tmpSize_=[0,0],this.tmpExtent_=[0,0,0,0],t.tileRanges!==void 0?this.fullTileRanges_=t.tileRanges:t.sizes!==void 0?this.fullTileRanges_=t.sizes.map((s,a)=>{let l=new vs(Math.min(0,s[0]),Math.max(s[0]-1,-1),Math.min(0,s[1]),Math.max(s[1]-1,-1));if(o){let h=this.getTileRangeForExtentAndZ(o,a);l.minX=Math.max(h.minX,l.minX),l.maxX=Math.min(h.maxX,l.maxX),l.minY=Math.max(h.minY,l.minY),l.maxY=Math.min(h.maxY,l.maxY)}return l}):o&&this.calculateTileRanges_(o)}forEachTileCoord(t,e,i){let r=this.getTileRangeForExtentAndZ(t,e);for(let o=r.minX,s=r.maxX;o<=s;++o)for(let a=r.minY,l=r.maxY;a<=l;++a)i([e,o,a])}forEachTileCoordParentTileRange(t,e,i,r){let o,s,a,l=null,h=t[0]-1;for(this.zoomFactor_===2?(s=t[1],a=t[2]):l=this.getTileCoordExtent(t,r);h>=this.minZoom;){if(s!==void 0&&a!==void 0?(s=Math.floor(s/2),a=Math.floor(a/2),o=un(s,s,a,a,i)):o=this.getTileRangeForExtentAndZ(l,h,i),e(h,o))return!0;--h}return!1}getExtent(){return this.extent_}getMaxZoom(){return this.maxZoom}getMinZoom(){return this.minZoom}getOrigin(t){return this.origin_?this.origin_:this.origins_[t]}getOrigins(){return this.origins_}getResolution(t){return this.resolutions_[t]}getResolutions(){return this.resolutions_}getTileCoordChildTileRange(t,e,i){if(t[0]<this.maxZoom){if(this.zoomFactor_===2){let o=t[1]*2,s=t[2]*2;return un(o,o+1,s,s+1,e)}let r=this.getTileCoordExtent(t,i||this.tmpExtent_);return this.getTileRangeForExtentAndZ(r,t[0]+1,e)}return null}getTileRangeForTileCoordAndZ(t,e,i){if(e>this.maxZoom||e<this.minZoom)return null;let r=t[0],o=t[1],s=t[2];if(e===r)return un(o,s,o,s,i);if(this.zoomFactor_){let l=Math.pow(this.zoomFactor_,e-r),h=Math.floor(o*l),c=Math.floor(s*l);if(e<r)return un(h,h,c,c,i);let u=Math.floor(l*(o+1))-1,f=Math.floor(l*(s+1))-1;return un(h,u,c,f,i)}let a=this.getTileCoordExtent(t,this.tmpExtent_);return this.getTileRangeForExtentAndZ(a,e,i)}getTileRangeForExtentAndZ(t,e,i){this.getTileCoordForXYAndZ_(t[0],t[3],e,!1,Jn);let r=Jn[1],o=Jn[2];this.getTileCoordForXYAndZ_(t[2],t[1],e,!0,Jn);let s=Jn[1],a=Jn[2];return un(r,s,o,a,i)}getTileCoordCenter(t){let e=this.getOrigin(t[0]),i=this.getResolution(t[0]),r=pt(this.getTileSize(t[0]),this.tmpSize_);return[e[0]+(t[1]+.5)*r[0]*i,e[1]-(t[2]+.5)*r[1]*i]}getTileCoordExtent(t,e){let i=this.getOrigin(t[0]),r=this.getResolution(t[0]),o=pt(this.getTileSize(t[0]),this.tmpSize_),s=i[0]+t[1]*o[0]*r,a=i[1]-(t[2]+1)*o[1]*r,l=s+o[0]*r,h=a+o[1]*r;return Qt(s,a,l,h,e)}getTileCoordForCoordAndResolution(t,e,i){return this.getTileCoordForXYAndResolution_(t[0],t[1],e,!1,i)}getTileCoordForXYAndResolution_(t,e,i,r,o){let s=this.getZForResolution(i),a=i/this.getResolution(s),l=this.getOrigin(s),h=pt(this.getTileSize(s),this.tmpSize_),c=a*(t-l[0])/i/h[0],u=a*(l[1]-e)/i/h[1];return r?(c=mr(c,Fi)-1,u=mr(u,Fi)-1):(c=pr(c,Fi),u=pr(u,Fi)),jn(s,c,u,o)}getTileCoordForXYAndZ_(t,e,i,r,o){let s=this.getOrigin(i),a=this.getResolution(i),l=pt(this.getTileSize(i),this.tmpSize_),h=(t-s[0])/a/l[0],c=(s[1]-e)/a/l[1];return r?(h=mr(h,Fi)-1,c=mr(c,Fi)-1):(h=pr(h,Fi),c=pr(c,Fi)),jn(i,h,c,o)}getTileCoordForCoordAndZ(t,e,i){return this.getTileCoordForXYAndZ_(t[0],t[1],e,!1,i)}getTileCoordResolution(t){return this.resolutions_[t[0]]}getTileSize(t){return this.tileSize_?this.tileSize_:this.tileSizes_[t]}getFullTileRange(t){return this.fullTileRanges_?this.fullTileRanges_[t]:this.extent_?this.getTileRangeForExtentAndZ(this.extent_,t):null}getZForResolution(t,e){let i=wn(this.resolutions_,t,e||0);return et(i,this.minZoom,this.maxZoom)}tileCoordIntersectsViewport(t,e){return Ya(e,0,e.length,2,this.getTileCoordExtent(t))}calculateTileRanges_(t){let e=this.resolutions_.length,i=new Array(e);for(let r=this.minZoom;r<e;++r)i[r]=this.getTileRangeForExtentAndZ(t,r);this.fullTileRanges_=i}},Jr=sh;function As(n){let t=n.getDefaultTileGrid();return t||(t=I_(n),n.setDefaultTileGrid(t)),t}function rg(n,t,e){let i=t[0],r=n.getTileCoordCenter(t),o=Ms(e);if(!_e(o,r)){let s=j(o),a=Math.ceil((o[0]-r[0])/s);return r[0]+=s*a,n.getTileCoordForCoordAndZ(r,i)}return t}function T_(n,t,e,i){i=i!==void 0?i:"top-left";let r=sg(n,t,e);return new Jr({extent:n,origin:tu(n,i),resolutions:r,tileSize:e})}function og(n){let t=n||{},e=t.extent||Et("EPSG:3857").getExtent(),i={extent:e,minZoom:t.minZoom,tileSize:t.tileSize,resolutions:sg(e,t.maxZoom,t.tileSize,t.maxResolution)};return new Jr(i)}function sg(n,t,e,i){t=t!==void 0?t:42,e=pt(e!==void 0?e:256);let r=ct(n),o=j(n);i=i>0?i:Math.max(o/e[0],r/e[1]);let s=t+1,a=new Array(s);for(let l=0;l<s;++l)a[l]=i/Math.pow(2,l);return a}function I_(n,t,e,i){let r=Ms(n);return T_(r,t,e,i)}function Ms(n){n=Et(n);let t=n.getExtent();if(!t){let e=180*ti.degrees/n.getMetersPerUnit();t=Qt(-e,-e,e,e)}return t}var L_=/\{z\}/g,A_=/\{x\}/g,M_=/\{y\}/g,P_=/\{-y\}/g;function ag(n,t,e,i,r){return n.replace(L_,t.toString()).replace(A_,e.toString()).replace(M_,i.toString()).replace(P_,function(){if(r===void 0)throw new Error("If the URL template has a {-y} placeholder, the grid extent must be known");return(r-i).toString()})}function lg(n){let t=[],e=/\{([a-z])-([a-z])\}/.exec(n);if(e){let i=e[1].charCodeAt(0),r=e[2].charCodeAt(0),o;for(o=i;o<=r;++o)t.push(n.replace(e[0],String.fromCharCode(o)));return t}if(e=/\{(\d+)-(\d+)\}/.exec(n),e){let i=parseInt(e[2],10);for(let r=parseInt(e[1],10);r<=i;r++)t.push(n.replace(e[0],r.toString()));return t}return t.push(n),t}function k_(n,t){return(function(e,i,r){if(!e)return;let o,s=e[0];if(t){let a=t.getFullTileRange(s);a&&(o=a.getHeight()-1)}return ag(n,s,e[1],e[2],o)})}function cg(n,t){let e=n.length,i=new Array(e);for(let r=0;r<e;++r)i[r]=k_(n[r],t);return O_(i)}function O_(n){return n.length===1?n[0]:(function(t,e,i){if(!t)return;let r=Sf(t),o=Pe(r,n.length);return n[o](t,e,i)})}var ah=class extends Ls{constructor(t){super({attributions:t.attributions,attributionsCollapsible:t.attributionsCollapsible,projection:t.projection,state:t.state,wrapX:t.wrapX,interpolate:t.interpolate}),this.on,this.once,this.un,this.tilePixelRatio_=t.tilePixelRatio!==void 0?t.tilePixelRatio:1,this.tileGrid=t.tileGrid!==void 0?t.tileGrid:null;let e=[256,256];this.tileGrid&&pt(this.tileGrid.getTileSize(this.tileGrid.getMinZoom()),e),this.tmpSize=[0,0],this.key_=t.key||U(this),this.tileOptions={transition:t.transition,interpolate:t.interpolate},this.zDirection=t.zDirection?t.zDirection:0}getGutterForProjection(t){return 0}getKey(){return this.key_}setKey(t){this.key_!==t&&(this.key_=t,this.changed())}getResolutions(t){let e=t?this.getTileGridForProjection(t):this.tileGrid;return e?e.getResolutions():null}getTile(t,e,i,r,o,s){return H()}getTileGrid(){return this.tileGrid}getTileGridForProjection(t){return this.tileGrid?this.tileGrid:As(t)}getTilePixelRatio(t){return this.tilePixelRatio_}getTilePixelSize(t,e,i){let r=this.getTileGridForProjection(i),o=this.getTilePixelRatio(e),s=pt(r.getTileSize(t),this.tmpSize);return o==1?s:zd(s,o,this.tmpSize)}getTileCoordForTileUrlFunction(t,e){let i=e!==void 0?e:this.getProjection(),r=e!==void 0?this.getTileGridForProjection(i):this.tileGrid||this.getTileGridForProjection(i);return this.getWrapX()&&i.isGlobal()&&(t=rg(r,t,i)),Rf(t,r)?t:null}clear(){}refresh(){this.clear(),super.refresh()}},Ps=class extends Lt{constructor(t,e){super(t),this.tile=e}},hg=ah;var ks={TILELOADSTART:"tileloadstart",TILELOADEND:"tileloadend",TILELOADERROR:"tileloaderror"};var lh=class n extends hg{constructor(t){super({attributions:t.attributions,cacheSize:t.cacheSize,projection:t.projection,state:t.state,tileGrid:t.tileGrid,tilePixelRatio:t.tilePixelRatio,wrapX:t.wrapX,transition:t.transition,interpolate:t.interpolate,key:t.key,attributionsCollapsible:t.attributionsCollapsible,zDirection:t.zDirection}),this.generateTileUrlFunction_=this.tileUrlFunction===n.prototype.tileUrlFunction,this.tileLoadFunction=t.tileLoadFunction,t.tileUrlFunction&&(this.tileUrlFunction=t.tileUrlFunction),this.urls=null,t.urls?this.setUrls(t.urls):t.url&&this.setUrl(t.url),this.tileLoadingKeys_={}}getTileLoadFunction(){return this.tileLoadFunction}getTileUrlFunction(){return Object.getPrototypeOf(this).tileUrlFunction===this.tileUrlFunction?this.tileUrlFunction.bind(this):this.tileUrlFunction}getUrls(){return this.urls}handleTileChange(t){let e=t.target,i=U(e),r=e.getState(),o;r==O.LOADING?(this.tileLoadingKeys_[i]=!0,o=ks.TILELOADSTART):i in this.tileLoadingKeys_&&(delete this.tileLoadingKeys_[i],o=r==O.ERROR?ks.TILELOADERROR:r==O.LOADED?ks.TILELOADEND:void 0),o!=null&&this.dispatchEvent(new Ps(o,e))}setTileLoadFunction(t){this.tileLoadFunction=t,this.changed()}setTileUrlFunction(t,e){this.tileUrlFunction=t,typeof e<"u"?this.setKey(e):this.changed()}setUrl(t){let e=lg(t);this.urls=e,this.setUrls(e)}setUrls(t){this.urls=t;let e=t.join(`7-`);this.generateTileUrlFunction_?this.setTileUrlFunction(cg(t,this.tileGrid),e):this.setKey(e)}tileUrlFunction(t,e,i){}},ug=lh;var ch=class extends ug{constructor(t){super({attributions:t.attributions,cacheSize:t.cacheSize,projection:t.projection,state:t.state,tileGrid:t.tileGrid,tileLoadFunction:t.tileLoadFunction?t.tileLoadFunction:D_,tilePixelRatio:t.tilePixelRatio,tileUrlFunction:t.tileUrlFunction,url:t.url,urls:t.urls,wrapX:t.wrapX,transition:t.transition,interpolate:t.interpolate!==void 0?t.interpolate:!0,key:t.key,attributionsCollapsible:t.attributionsCollapsible,zDirection:t.zDirection}),this.crossOrigin=t.crossOrigin!==void 0?t.crossOrigin:null,this.referrerPolicy=t.referrerPolicy,this.tileClass=t.tileClass!==void 0?t.tileClass:ws,this.tileGridForProjection={},this.reprojectionErrorThreshold_=t.reprojectionErrorThreshold,this.renderReprojectionEdges_=!1}getGutterForProjection(t){return this.getProjection()&&t&&!On(this.getProjection(),t)?0:this.getGutter()}getGutter(){return 0}getKey(){let t=super.getKey();return this.getInterpolate()||(t+=":disable-interpolation"),t}getTileGridForProjection(t){let e=this.getProjection();if(this.tileGrid&&(!e||On(e,t)))return this.tileGrid;let i=U(t);return i in this.tileGridForProjection||(this.tileGridForProjection[i]=As(t)),this.tileGridForProjection[i]}createTile_(t,e,i,r,o,s){let a=[t,e,i],l=this.getTileCoordForTileUrlFunction(a,o),h=l?this.tileUrlFunction(l,r,o):void 0,c=new this.tileClass(a,h!==void 0?O.IDLE:O.EMPTY,h!==void 0?h:"",{crossOrigin:this.crossOrigin,referrerPolicy:this.referrerPolicy},this.tileLoadFunction,this.tileOptions);return c.key=s,c.addEventListener(P.CHANGE,this.handleTileChange.bind(this)),c}getTile(t,e,i,r,o,s){let a=this.getProjection();if(!a||!o||On(a,o))return this.getTileInternal(t,e,i,r,a||o);let l=[t,e,i],h=this.getKey(),c=this.getTileGridForProjection(a),u=this.getTileGridForProjection(o),f=this.getTileCoordForTileUrlFunction(l,o),g=new Cs(a,c,o,u,l,f,this.getTilePixelRatio(r),this.getGutter(),(p,_,m,x)=>this.getTileInternal(p,_,m,x,a,s),this.reprojectionErrorThreshold_,this.renderReprojectionEdges_,this.tileOptions);return g.key=h,g}getTileInternal(t,e,i,r,o,s){let a=this.getKey(),l=Hn(this,a,t,e,i);if(s&&s.containsKey(l))return s.get(l);let h=this.createTile_(t,e,i,r,o,a);return s?.set(l,h),h}setRenderReprojectionEdges(t){this.renderReprojectionEdges_!=t&&(this.renderReprojectionEdges_=t,this.changed())}setTileGridForProjection(t,e){let i=Et(t);if(i){let r=U(i);r in this.tileGridForProjection||(this.tileGridForProjection[r]=e)}}};function D_(n,t){if(St){let e=n.getCrossOrigin(),i="same-origin",r="same-origin";e==="anonymous"||e===""?(i="cors",r="omit"):e==="use-credentials"&&(i="cors",r="include");let o={mode:i,credentials:r,referrerPolicy:n.getReferrerPolicy()};fetch(t,o).then(s=>{if(!s.ok)throw new Error(`HTTP ${s.status}`);return s.blob()}).then(s=>createImageBitmap(s)).then(s=>{let a=n.getImage();a.width=s.width,a.height=s.height,a.getContext("2d").drawImage(s,0,0),s.close?.(),a.dispatchEvent(new Event("load"))}).catch(()=>{n.getImage().dispatchEvent(new Event("error"))});return}n.getImage().src=t}var dg=ch;var hh=class extends dg{constructor(t){t=t||{};let e=t.projection!==void 0?t.projection:"EPSG:3857",i=t.tileGrid!==void 0?t.tileGrid:og({extent:Ms(e),maxResolution:t.maxResolution,maxZoom:t.maxZoom,minZoom:t.minZoom,tileSize:t.tileSize});super({attributions:t.attributions,cacheSize:t.cacheSize,crossOrigin:t.crossOrigin,referrerPolicy:t.referrerPolicy,interpolate:t.interpolate,projection:e,reprojectionErrorThreshold:t.reprojectionErrorThreshold,tileGrid:i,tileLoadFunction:t.tileLoadFunction,tilePixelRatio:t.tilePixelRatio,tileUrlFunction:t.tileUrlFunction,url:t.url,urls:t.urls,wrapX:t.wrapX!==void 0?t.wrapX:!0,transition:t.transition,attributionsCollapsible:t.attributionsCollapsible,zDirection:t.zDirection}),this.gutter_=t.gutter!==void 0?t.gutter:0}getGutter(){return this.gutter_}},fg=hh;var Y=n=>document.querySelector(n),C={game:Y("#game-select"),map:Y("#map-select"),variant:Y("#variant-select"),variantField:Y("#variant-field"),gameTitle:Y("#game-title"),title:Y("#map-title"),meta:Y("#map-meta"),legend:Y("#legend"),search:Y("#pin-search"),searchResults:Y("#search-results"),visibleCount:Y("#visible-count"),viewport:Y("#map"),layers:Y("#layers"),zoneToggle:Y("#zone-toggle"),zoneCount:Y("#zone-count"),zoneIndex:Y("#zone-index"),zoneList:Y("#zone-list"),loading:Y("#map-loading"),labelsHint:Y("#labels-hint"),gridHint:Y("#grid-hint"),soloChip:Y("#solo-chip"),overview:Y("#overview"),overviewShelf:Y("#overview-shelf"),overviewDock:Y("#overview-dock"),overviewCanvas:Y("#overview-canvas"),overviewViewport:Y("#overview-viewport"),gridNavigator:Y("#grid-navigator"),gridInput:Y("#grid-input"),gridBack:Y("#grid-back"),subgridToggle:Y("#subgrid-toggle"),detail:Y("#pin-detail"),detailTitle:Y("#detail-title"),detailCategory:Y("#detail-category"),detailDescription:Y("#detail-description"),detailID:Y("#detail-id"),detailCoordinates:Y("#detail-coordinates"),detailLinks:Y("#detail-links"),detailDot:Y("#detail-dot"),sidebar:Y("#sidebar"),mobileLegend:Y("#mobile-legend"),fatal:Y("#fatal-error"),fatalMessage:Y("#fatal-message")},Gs=["#d6f36b","#72d5f4","#ff9e64","#df83ff","#62e6ae","#ff6f91","#f4d35e","#8aa9ff","#e7a56d","#83d483"],Ni="0123456789bcdefghjkmnpqrstuvwxyz",F_=3,z_=2,d={catalog:null,game:null,map:null,variant:null,engine:null,projection:null,layers:null,sources:null,hiddenCategories:new Set,collapsedSections:new Set,pins:[],pinByID:new Map,selectedPin:null,hoveredPin:null,pinLabelsVisible:!1,gridEnabled:!1,subgridVisible:!0,gridPrefix:"",zonesVisible:!0,zoneRecords:new Map,highlightedZones:new Set,focusedZoneID:null,search:"",fitZoom:0,zoneTitleCount:0,eligibleLocations:0,tileRun:0,tileStats:{requested:0,loaded:0,errors:0,peakPending:0},overviewRun:0,overviewKey:"",overviewPointer:null,overviewDocked:!1,renderedShard:0,mapRun:0,textByMap:new Map,restore:null,settling:!1,styleCache:new Map,markerIcons:new Map};async function N_(){X_();try{let n=await fetch("/static/catalog.json");if(!n.ok)throw new Error(`catalog request returned ${n.status}`);if(d.catalog=await n.json(),!d.catalog.games.length)throw new Error("the embedded catalog contains no maps");G_(),wh(C.game,d.catalog.games,"title");let t=Sg(),e=bg(),i=e&&(!t.game||t.game===e.game&&t.map===e.map);d.restore=i?e:null,await dh(t.game||e?.game||d.catalog.games[0].slug,t.map||e?.map),d.restore=null,Kx(),requestAnimationFrame(()=>C.viewport.focus({preventScroll:!0}))}catch(n){C.loading.hidden=!0,C.fatalMessage.textContent=n instanceof Error?n.message:String(n),C.fatal.hidden=!1}}function ne(n){return new tg({updateWhileAnimating:!0,...n})}function G_(){let n=d.catalog.tileGrid.size,t=[0,-n,n,0];d.projection=new Ei({code:"ATLAS:PIXELS",units:"pixels",extent:t}),d.sources={grid:new gi({wrapX:!1}),gridContext:new gi({wrapX:!1}),zoneScrim:new gi({wrapX:!1}),zones:new gi({wrapX:!1}),zoneTitles:new gi({wrapX:!1}),text:new gi({wrapX:!1}),pins:new gi({wrapX:!1}),priority:new gi({wrapX:!1})},d.layers={raster:new Ac({zIndex:0}),rasterDetail:new Ac({zIndex:1}),grid:ne({source:d.sources.grid,style:xg,renderOrder:Se,renderBuffer:40,zIndex:5}),zoneScrim:ne({source:d.sources.zoneScrim,style:kx,zIndex:6}),zones:ne({source:d.sources.zones,style:Ox,renderBuffer:32,zIndex:10}),zoneTitles:ne({source:d.sources.zoneTitles,style:Dx,renderOrder:Se,renderBuffer:160,zIndex:20}),zoneTitleDetail:ne({source:d.sources.zoneTitles,style:Fx,renderOrder:Se,renderBuffer:160,zIndex:44}),text:ne({source:d.sources.text,style:wx,renderOrder:Se,renderBuffer:220,zIndex:30}),textDetail:ne({source:d.sources.text,style:Ex,renderOrder:Se,renderBuffer:220,zIndex:45}),zoneText:ne({source:d.sources.text,style:vx,renderOrder:Se,renderBuffer:220,zIndex:41}),pins:ne({source:d.sources.pins,style:_x,renderOrder:Se,renderBuffer:48,zIndex:40}),zonePins:ne({source:d.sources.pins,style:xx,renderOrder:Se,renderBuffer:48,zIndex:42}),pinLabels:ne({source:d.sources.pins,style:yx,renderOrder:Se,renderBuffer:180,zIndex:45}),gridContext:ne({source:d.sources.gridContext,style:xg,renderOrder:Se,renderBuffer:40,zIndex:48}),priority:ne({source:d.sources.priority,style:Cx,renderOrder:Se,renderBuffer:220,zIndex:50})},d.engine=new mf({target:C.viewport,layers:Object.values(d.layers),controls:Wo({attribution:!1,rotate:!1,zoom:!1}),interactions:Bo({onFocusOnly:!1}),view:Eg(5)}),d.engine.on("movestart",()=>{d.engine.getViewport().classList.add("is-dragging")}),d.engine.on("moveend",()=>{d.engine.getViewport().classList.remove("is-dragging"),d.overviewPointer===null&&mh()}),d.engine.on("postrender",ph),C.viewport.addEventListener("wheel",()=>{document.activeElement!==C.viewport&&C.viewport.focus({preventScroll:!0})},{capture:!0,passive:!0}),d.engine.on("singleclick",e=>{if(d.gridEnabled){let r=d.engine.forEachFeatureAtPixel(e.pixel,o=>{let s=o.get("gridCell");return s&&s.role!=="leaf"&&s.role!=="scope"?s:null},{hitTolerance:1,layerFilter:o=>o===d.layers.grid||o===d.layers.gridContext});if(r){_h(r.hash);return}}let i=d.engine.forEachFeatureAtPixel(e.pixel,(r,o)=>Os(o)&&r.get("pin")||null,{hitTolerance:5,layerFilter:Os});i&&Gg(i)}),d.engine.on("pointermove",e=>{if(e.dragging){zs(null);return}let i=d.engine.forEachFeatureAtPixel(e.pixel,(s,a)=>Os(a)&&s.get("pin")||null,{hitTolerance:4,layerFilter:Os}),r=i?.category.displayType==="text"?null:i;zs(r||null);let o=d.gridEnabled&&d.engine.hasFeatureAtPixel(e.pixel,{layerFilter:s=>s===d.layers.grid||s===d.layers.gridContext});d.engine.getTargetElement().style.cursor=i||o?"pointer":""}),d.engine.getViewport().addEventListener("pointerleave",()=>zs(null))}function Os(n){return n===d.layers.pins||n===d.layers.zonePins||n===d.layers.pinLabels||n===d.layers.priority||n===d.layers.text||n===d.layers.textDetail||n===d.layers.zoneText}function Eg(n){let t=d.catalog.tileGrid.size;return new te({projection:d.projection,center:[t/2,-t/2],resolutions:Ig(n),minZoom:0,maxZoom:n,extent:[0,-t,t,0],constrainResolution:!1,smoothResolutionConstraint:!1,showFullExtent:!0,zoom:0})}function X_(){C.game.addEventListener("change",()=>{dh(C.game.value)}),C.map.addEventListener("change",()=>{Rg(Number(C.map.value))}),C.variant.addEventListener("change",()=>Tg(Number(C.variant.value))),C.legend.addEventListener("change",i=>{let r=i.target;if(r.dataset.sectionToggle){hx(r.dataset.sectionToggle);return}if(!r.dataset.category)return;let o=Number(r.dataset.category);r.checked?d.hiddenCategories.delete(o):d.hiddenCategories.add(o),Gi(),nr()});let n=null,t=()=>{for(let o of C.layers.querySelectorAll(".is-hovered"))o.classList.remove("is-hovered");if(!n)return;let r=document.elementFromPoint(n.x,n.y)?.closest(".category-row, .layer-header");r&&C.layers.contains(r)&&r.classList.add("is-hovered")};C.layers.addEventListener("pointermove",i=>{n={x:i.clientX,y:i.clientY},t()},{passive:!0}),C.layers.addEventListener("pointerleave",()=>{n=null,t()}),C.layers.addEventListener("scroll",t,{passive:!0}),C.layers.addEventListener("click",i=>{let r=i.target.closest("[data-only-category], [data-only-section]");if(r){i.preventDefault(),i.stopPropagation(),ux(r.dataset.onlyCategory?{category:Number(r.dataset.onlyCategory)}:{section:r.dataset.onlySection});return}let o=i.target.closest("[data-section]");if(!o)return;let s=o.dataset.section;d.collapsedSections.has(s)?d.collapsedSections.delete(s):d.collapsedSections.add(s),Eh()}),C.soloChip.addEventListener("click",()=>Ns(!0)),Y("#expand-all").addEventListener("click",()=>pg(!1)),Y("#collapse-all").addEventListener("click",()=>pg(!0)),Y("#show-all").addEventListener("click",()=>Ns(!0)),Y("#hide-all").addEventListener("click",()=>Ns(!1)),C.zoneToggle.addEventListener("change",()=>{vh(C.zoneToggle.checked)}),C.zoneIndex.addEventListener("click",i=>{let r=i.target.closest("[data-zone]");r&&sx(Number(r.dataset.zone))}),C.zoneIndex.addEventListener("contextmenu",i=>{let r=i.target.closest("[data-zone]");r&&(i.preventDefault(),ax(Number(r.dataset.zone)))}),C.search.addEventListener("input",()=>{d.search=C.search.value.trim().toLocaleLowerCase(),Gi(),bh()}),C.searchResults.addEventListener("click",i=>{let r=i.target.closest("[data-location]");if(!r)return;let o=d.pinByID.get(Number(r.dataset.location));o&&_g(o)}),C.detailLinks.addEventListener("click",i=>{let r=i.target.closest("[data-location]");if(!r)return;let o=d.pinByID.get(Number(r.dataset.location));o&&_g(o)}),Y("#close-detail").addEventListener("click",tr),Y("#zoom-in").addEventListener("click",()=>Ds(1)),Y("#zoom-out").addEventListener("click",()=>Ds(-1)),C.gridBack.addEventListener("click",Pg),C.gridInput.addEventListener("input",()=>{let i=Ws(),r=[...C.gridInput.value.toLocaleLowerCase()].filter(o=>Ni.includes(o)).slice(0,i).join("");C.gridInput.value=r,_h(r)}),C.subgridToggle.addEventListener("click",()=>{Xs(!d.subgridVisible),C.viewport.focus({preventScroll:!0})}),C.gridInput.addEventListener("keydown",i=>{if(i.key===" "){i.preventDefault(),Xs(!d.subgridVisible);return}i.key==="Escape"&&(i.preventDefault(),i.stopPropagation(),C.viewport.focus({preventScroll:!0}))}),C.viewport.addEventListener("keydown",i=>{if(!uh(i.target)){if(i.key==="+"||i.key==="=")Ds(1);else if(i.key==="-")Ds(-1);else if(i.key==="Escape")tr();else return;i.preventDefault()}}),window.addEventListener("contextmenu",i=>{uh(i.target)||i.preventDefault()}),window.addEventListener("keydown",i=>{if((i.metaKey||i.ctrlKey)&&i.key.toLocaleLowerCase()==="r"){i.preventDefault(),location.reload();return}if(!uh(i.target)){if((i.metaKey||i.ctrlKey)&&i.key.toLocaleLowerCase()==="k"){i.preventDefault(),C.search.focus(),C.search.select();return}if((i.metaKey||i.ctrlKey)&&i.key.toLocaleLowerCase()==="b"){i.preventDefault(),H_();return}$_(i)||i.key.toLocaleLowerCase()==="z"&&(i.preventDefault(),d.pinLabelsVisible=!d.pinLabelsVisible,C.labelsHint.textContent=`Z \xB7 labels ${d.pinLabelsVisible?"on":"off"}`,d.layers.pinLabels.changed())}}),window.addEventListener("hashchange",()=>{let i=Sg();i.game===d.game?.slug&&i.map===d.map?.slug||(d.restore=null,dh(i.game||d.catalog.games[0].slug,i.map))}),window.addEventListener("resize",()=>{d.engine?.updateSize(),ph()}),C.overview.addEventListener("pointerdown",i=>{d.overviewDocked||i.pointerType==="mouse"&&i.button!==0||(i.preventDefault(),C.overview.setPointerCapture(i.pointerId),d.overviewPointer=i.pointerId,gg(i,!0))}),C.overview.addEventListener("pointermove",i=>{d.overviewPointer===i.pointerId&&(i.preventDefault(),gg(i,!1))});let e=i=>{d.overviewPointer===i.pointerId&&(d.overviewPointer=null,mh())};C.overview.addEventListener("pointerup",e),C.overview.addEventListener("pointercancel",e),C.overviewDock.addEventListener("click",()=>{Lg(!d.overviewDocked),C.viewport.focus({preventScroll:!0})}),C.mobileLegend.addEventListener("click",()=>{let i=C.sidebar.classList.toggle("is-open");C.mobileLegend.setAttribute("aria-expanded",String(i))})}async function W_(n){let[t,e]=await Promise.all([fetch(`/static/catalog/${n.id}.json`).then(r=>r.json()),fetch(`/static/catalog/${n.id}.bin`).then(r=>r.arrayBuffer())]),i=t.groups.flatMap(r=>r.categories);return Y_(e,i),{...n,variants:t.variants,groups:t.groups,zones:t.zones||[],sections:Q_(t.groups)}}function Y_(n,t){let e=new DataView(n);if(String.fromCharCode(...new Uint8Array(n,0,8))!=="ATLASLOC")throw new Error("location payload is not in the expected form");let r=e.getUint16(8,!0);if(r!==2)throw new Error(`location payload is version ${r}, and this reads 2`);let o=e.getUint32(10,!0),s=16,a=new Int32Array(n,s,o),l=new Float32Array(n,s+=o*4,o),h=new Float32Array(n,s+=o*4,o),c=new Int32Array(n,s+=o*4,o),u=new Int32Array(n,s+=o*4,o),f=new Uint32Array(n,s+=o*4,o+1),g=new Uint16Array(n,s+=(o+1)*4,o),p=new Uint8Array(n,s+o*2),_=new TextDecoder;for(let m of t)m.locations=[];for(let m=0;m<o;m++)t[g[m]].locations.push({id:a[m],title:_.decode(p.subarray(f[m],f[m+1])),lat:l[m],lng:h[m],regionId:c[m]||void 0,shard:u[m]||void 0})}async function U_(n){return d.textByMap.has(n)||d.textByMap.set(n,fetch(`/static/catalog/${n}.text`).then(t=>t.json()).catch(()=>({}))),d.textByMap.get(n)}async function dh(n,t){d.game=d.catalog.games.find(r=>r.slug===n)||d.catalog.games[0],!t&&!d.restore&&(d.restore=bg(d.game.slug)),C.game.value=d.game.slug,wh(C.map,d.game.maps,"title","id"),C.map.disabled=d.game.maps.length===1,C.map.title=C.map.disabled?"This game has one map":"Choose a map";let e=d.restore?.game===d.game.slug?d.restore:null,i=t&&d.game.maps.find(r=>r.slug===t)||e&&d.game.maps.find(r=>r.slug===e.map);await Rg((i||d.game.maps[0]).id)}var vg="atlas.session";function er(){if(!d.map||!d.variant||d.settling)return;let n=d.engine?.getView();try{let t=Cg();t.last=d.game.slug,t.games[d.game.slug]={game:d.game.slug,map:d.map.slug,variant:d.map.variants.indexOf(d.variant),center:n?.getCenter(),zoom:n?.getZoom(),hidden:[...d.hiddenCategories],collapsed:[...d.collapsedSections],overviewDocked:d.overviewDocked},localStorage.setItem(vg,JSON.stringify(t))}catch{}}function Cg(){try{let n=JSON.parse(localStorage.getItem(vg)||"null");if(n&&n.games)return n}catch{}return{last:"",games:{}}}function bg(n){let t=Cg(),e=n||t.last,i=e&&t.games[e];return i&&i.game&&i.map?i:null}function Sg(){let[n,t]=decodeURIComponent(location.hash.replace(/^#\/?/,"")).split("/").map(e=>e.trim());return{game:n,map:t}}function K_(){if(!d.game||!d.map)return;let n=`#${d.game.slug}/${d.map.slug}`;location.hash!==n&&history.replaceState(null,"",n)}async function Rg(n){let t=d.game.maps.find(o=>o.id===n)||d.game.maps[0],e=++d.mapRun;C.loading.hidden=!1;let i=await W_(t);if(d.mapRun!==e)return;d.settling=!0,d.map=i,document.documentElement.style.setProperty("--icon-outset-color",Rh()),C.map.value=String(d.map.id),wh(C.variant,d.map.variants,"name"),C.variantField.hidden=d.map.variants.length<2,d.styleCache.clear(),zs(null),d.gridPrefix="",d.hiddenCategories.clear(),d.collapsedSections.clear(),d.collapsedSections.add("zones");for(let o of d.map.groups)for(let s of o.categories)s.visible||d.hiddenCategories.add(s.id);let r=d.restore?.map===d.map.slug?d.restore:null;r&&(d.hiddenCategories=new Set(r.hidden),d.collapsedSections=new Set(r.collapsed)),Lg(!!d.restore?.overviewDocked,!1),d.search="",C.search.value="",C.searchResults.hidden=!0,tr(),tx(),Og(),nx(),Tg(r?pi(r.variant,0,d.map.variants.length-1):0,!0),C.gameTitle.textContent=d.game.title,C.title.textContent=d.map.title,C.meta.textContent=`${pn(d.map.pinCount)} locations \xB7 ${pn(d.map.zones?.length||0)} regions`,C.sidebar.classList.remove("is-open"),C.mobileLegend.setAttribute("aria-expanded","false"),K_(),d.settling=!1,er()}function Tg(n,t=!1){let e=d.variant;d.variant=d.map.variants[n]||d.map.variants[0];let i=d.variant,r=t?null:j_(e,i),o=ir(i);C.variant.value=String(d.map.variants.indexOf(d.variant)),t?d.engine.setView(Eg(o)):(d.engine.getView().setMinZoom(i.minZoom),d.engine.getView().setMaxZoom(o));let s=++d.tileRun,a=0;d.tileStats={requested:0,loaded:0,errors:0,peakPending:0},C.loading.hidden=!1;let l=_=>{_.on("tileloadstart",()=>{d.tileRun===s&&(a++,d.tileStats.requested++,d.tileStats.peakPending=Math.max(d.tileStats.peakPending,a))});let m=x=>{d.tileRun===s&&(a=Math.max(0,a-1),x?d.tileStats.errors++:d.tileStats.loaded++,a===0&&d.tileStats.loaded>0&&(C.loading.hidden=!0))};return _.on("tileloadend",()=>m(!1)),_.on("tileloaderror",()=>m(!0)),_},h=(_,m)=>l(new fg({projection:d.projection,tileGrid:new Jr({extent:[0,-d.catalog.tileGrid.size,d.catalog.tileGrid.size,0],origin:[0,0],resolutions:Ig(_),tileSize:d.catalog.tileGrid.tileSize}),cacheSize:64,interpolate:i.interpolate,transition:0,wrapX:!1,tileUrlFunction:([x,w,v])=>{let y=i.formats[x];if(!(!y||w<0||v<0||!m(x,w,v)))return`/static/tiles/${encodeURIComponent(i.tiles)}/${x}/${w}/${v}.${y}`}})),c=i.fullZoom??i.maxZoom,u=h(c,(_,m,x)=>fh(i,_,m,x)),f=d.layers.raster.getSource();d.layers.raster.setSource(u),d.layers.raster.setExtent(gn()),d.layers.raster.setBackground(i.background||void 0),f?.clear();let g=d.layers.rasterDetail.getSource();i.maxZoom>c?(d.layers.rasterDetail.setSource(h(i.maxZoom,(_,m,x)=>_>c&&fh(i,_,m,x))),d.layers.rasterDetail.setExtent(gn()),d.layers.rasterDetail.setVisible(!0)):d.layers.rasterDetail.setVisible(!1),g?.clear(),xh(),d.gridEnabled&&(mn(),d.layers.pins.changed(),d.layers.text.changed(),d.layers.priority.changed()),d.overviewKey="",B_();let p=d.restore?.map===d.map.slug?d.restore:null;if(d.renderedShard!==(i.shard||0)&&(Og(),Gi()),p?.center&&Number.isFinite(p.zoom)){let _=d.engine.getView();_.setCenter(p.center),_.setZoom(p.zoom),d.fitZoom=p.zoom,Qn()}else t?requestAnimationFrame(mx):(r&&d.engine.getView().animate({center:r,duration:200}),Qn());er()}function fh(n,t,e,i){let r=n.coverage?.[t];if(!r)return!0;let o=e-r.x,s=i-r.y;if(o<0||s<0||o>=r.w||s>=r.h)return!1;let a=Z_(n,t,r),l=s*r.w+o;return(a[l>>3]&1<<(l&7))!==0}function Z_(n,t,e){if(!e.decoded){let i=atob(e.bits),r=new Uint8Array(i.length);for(let o=0;o<i.length;o++)r[o]=i.charCodeAt(o);e.decoded=r}return e.decoded}function Ig(n){let t=d.catalog.tileGrid.size/d.catalog.tileGrid.tileSize;return Array.from({length:n+1},(e,i)=>t/2**i)}function ir(n){return n.maxZoom+z_}var V_=168;function B_(){let n=d.variant,t=C.overviewCanvas,e=t.getContext("2d"),i=gn(),r=d.catalog.tileGrid.size,o=d.catalog.tileGrid.tileSize,s=i[2]-i[0],a=i[3]-i[1],l=0;for(;l<n.fullZoom&&Math.max(s,a)/r*o*2**l<V_;)l++;let h=o*2**l/r;t.width=Math.max(1,Math.round(s*h)),t.height=Math.max(1,Math.round(a*h)),e.clearRect(0,0,t.width,t.height),n.background&&(e.fillStyle=n.background,e.fillRect(0,0,t.width,t.height));let c=++d.overviewRun,u=n.formats[l],f=Math.floor(i[0]/r*2**l),g=Math.ceil(i[2]/r*2**l),p=Math.floor(-i[3]/r*2**l),_=Math.ceil(-i[1]/r*2**l);for(let m=p;m<_;m++)for(let x=f;x<g;x++){if(!u||!fh(n,l,x,m))continue;let w=new Image;w.onload=()=>{d.overviewRun===c&&e.drawImage(w,x*o-i[0]*h,m*o+i[3]*h,o,o)},w.src=`/static/tiles/${encodeURIComponent(n.tiles)}/${l}/${x}/${m}.${u}`}ph()}function ph(){let n=d.engine?.getView();if(!n||!d.variant)return;let t=gn(),e=n.calculateExtent(d.engine.getSize()),i=t[2]-t[0],r=t[3]-t[1],o=(n.getResolution()||0)*4,s=e[0]<=t[0]+o&&e[1]<=t[1]+o&&e[2]>=t[2]-o&&e[3]>=t[3]-o,a=s?"hidden":e.map(Math.round).join(",");if(a===d.overviewKey||(d.overviewKey=a,C.overviewShelf.hidden=s,s))return;let l=C.overviewCanvas,h=pi((e[0]-t[0])/i,0,1),c=pi((e[2]-t[0])/i,0,1),u=pi((t[3]-e[3])/r,0,1),f=pi((t[3]-e[1])/r,0,1),g=C.overviewViewport.style;g.left=`${h*l.width}px`,g.top=`${u*l.height}px`,g.width=`${Math.max(8,(c-h)*l.width)}px`,g.height=`${Math.max(8,(f-u)*l.height)}px`}function Lg(n,t=!0){d.overviewDocked=n,n&&d.overviewPointer!==null&&(d.overviewPointer=null,mh()),C.overviewShelf.classList.toggle("is-docked",n),C.overviewDock.setAttribute("aria-expanded",String(!n));let e=n?"Bring the overview back":"Put the overview away";C.overviewDock.setAttribute("aria-label",e),C.overviewDock.title=e,t&&er()}function gg(n,t){let e=d.engine?.getView();if(!e||!d.variant)return;let i=C.overviewCanvas.getBoundingClientRect(),r=gn(),o=(a,l,h)=>pi((a-l)/(h-l),0,1),s=[r[0]+o(n.clientX,i.left,i.right)*(r[2]-r[0]),r[3]-o(n.clientY,i.top,i.bottom)*(r[3]-r[1])];if(t){e.animate({center:s,duration:180});return}e.cancelAnimations(),e.setCenter(s)}function mh(){Qn(),er()}function j_(n,t){if(!n||!t||!n.shard||!t.shard||n.shard===t.shard||!n.bounds||!t.bounds)return null;let i=d.engine?.getView()?.getCenter();if(!i)return null;let r=(i[0]-n.bounds.x)/n.bounds.width,o=(-i[1]-n.bounds.y)/n.bounds.height;return[t.bounds.x+pi(r,0,1)*t.bounds.width,-(t.bounds.y+pi(o,0,1)*t.bounds.height)]}function H_(){let t=document.querySelector(".app-shell").classList.toggle("sidebar-collapsed");C.mobileLegend.setAttribute("aria-expanded",String(!t)),requestAnimationFrame(()=>d.engine?.updateSize())}function gn(){let n=d.catalog.tileGrid.size,t=d.variant?.bounds||{x:0,y:0,width:n,height:n};return[t.x,-(t.y+t.height),t.x+t.width,-t.y]}function q_(){let n=d.variant?.surface;return n?[n.x,-(n.y+n.height),n.x+n.width,-n.y]:gn()}function $_(n){return n.key.toLocaleLowerCase()==="g"?(n.preventDefault(),Ag(),d.gridEnabled?(C.gridInput.focus(),C.gridInput.select()):C.viewport.focus({preventScroll:!0}),!0):n.key===" "&&d.gridEnabled&&n.target!==C.subgridToggle?(n.preventDefault(),Xs(!d.subgridVisible),!0):n.key==="Escape"&&d.gridEnabled?(n.preventDefault(),Pg(),!0):!1}function Ag(n=!d.gridEnabled){d.gridEnabled=n,n&&Xs(!0),xh(),mn(),d.layers.pins.changed(),d.layers.text.changed(),d.layers.priority.changed()}function Xs(n){d.subgridVisible=n,d.layers.grid.changed(),d.layers.gridContext.changed(),C.subgridToggle.setAttribute("aria-pressed",String(n)),C.subgridToggle.setAttribute("aria-label",n?"Hide the subgrid":"Show the subgrid"),Mg()}function Mg(){if(!d.gridEnabled){C.gridHint.textContent="G \xB7 grid off";return}C.gridHint.textContent=`G-${d.gridPrefix||"root"}`+(d.subgridVisible?"":" no subgrid")}function _h(n){let t=Ws(),e=[...n.toLocaleLowerCase()].filter(r=>Ni.includes(r)).slice(0,t).join(""),i=e!==d.gridPrefix;d.gridPrefix=e,d.gridEnabled||(d.gridEnabled=!0),xh(),mn(),d.layers.pins.changed(),d.layers.text.changed(),d.layers.priority.changed(),i&&(tr(),d.engine.getView().fit(Qr(),{size:d.engine.getSize(),padding:[52,52,52,52],maxZoom:ir(d.variant),duration:180}))}function Pg(){if(d.gridEnabled){if(!d.gridPrefix){Ag(!1);return}_h(d.gridPrefix.slice(0,-1))}}function xh(){if(!d.sources||(d.sources.grid.clear(),d.sources.gridContext.clear(),C.gridNavigator.hidden=!d.gridEnabled,Mg(),!d.gridEnabled||!d.variant))return;let n=Ws();if(C.gridInput.maxLength=n,C.gridInput.value=d.gridPrefix,C.gridBack.title=d.gridPrefix?"Back one geohash level":"Close geohash grid",J_(),d.gridPrefix.length>=n){Fs(d.gridPrefix,Qr(),"leaf");return}d.gridPrefix&&Fs(d.gridPrefix,Qr(),"scope");for(let t of Ni){let e=d.gridPrefix+t;Fs(e,yh(e),"child")}}function J_(){for(let n=0;n<d.gridPrefix.length;n++){let t=d.gridPrefix.slice(0,n),e=d.gridPrefix.slice(0,n+1);for(let i of Ni){let r=t+i;r!==e&&Fs(r,yh(r),"neighbor",d.gridPrefix.length-n)}}}function Fs(n,t,e,i=0){let[r,o,s,a]=t,l=d.pins.filter(u=>{if(u.filteredHidden)return!1;let[f,g]=u.coordinate;return f>=r&&f<=s&&g>=o&&g<=a}).length,h=new vn({geometry:new ii([[[r,o],[r,a],[s,a],[s,o],[r,o]]]),gridCell:{hash:n,extent:t,role:e,count:l,contextDistance:i},priority:e==="neighbor"?-i*100+Ni.indexOf(n[n.length-1]):Ni.indexOf(n[n.length-1])});(e==="neighbor"?d.sources.gridContext:d.sources.grid).addFeature(h)}function Qr(){return yh(d.gridPrefix)}function yh(n){let t=[...q_()],e=!0;for(let i of n){let r=Ni.indexOf(i);if(!(r<0))for(let o of[16,8,4,2,1]){if(e){let s=(t[0]+t[2])/2;r&o?t[0]=s:t[2]=s}else{let s=(t[1]+t[3])/2;r&o?t[1]=s:t[3]=s}e=!e}}return t}function Ws(){return F_}function Ys(n){if(!d.gridEnabled||!d.gridPrefix)return!1;let t=Qr(),[e,i]=n.coordinate;return e>=t[0]&&e<=t[2]&&i>=t[1]&&i<=t[3]}function wh(n,t,e,i){n.replaceChildren(),t.forEach((r,o)=>{let s=document.createElement("option");s.value=i?String(r[i]):r.slug||String(o),s.textContent=r[e],n.append(s)})}function Q_(n){let t=[],e=[];for(let i of n){let r=[];for(let o of i.categories)(o.displayType==="text"?e:r).push(o);r.length&&t.push({key:`group-${i.id}`,title:i.title,categories:r})}return e.length&&t.unshift({key:"text",title:"Text",categories:e}),t}function tx(){let n=document.createDocumentFragment();for(let t of d.map.sections){let e=document.createElement("section");e.className="layer-section",e.dataset.layerSection=t.key;let i=t.categories.reduce((o,s)=>o+s.locations.length,0);e.append(ex(t.key,t.title,i));let r=document.createElement("div");r.className="category-toggles";for(let o of t.categories)r.append(ix(o));e.append(r),n.append(e)}C.legend.replaceChildren(n),Eh(),nr()}function ex(n,t,e){let i=document.createElement("div");i.className="layer-header";let r=document.createElement("button");r.type="button",r.className="layer-title",r.dataset.section=n;let o=document.createElement("span");o.className="layer-chevron",o.setAttribute("aria-hidden","true"),o.innerHTML='<svg viewBox="0 0 24 24"><path d="m9 6 6 6-6 6"/></svg>';let s=document.createElement("span");s.textContent=t;let a=document.createElement("span");a.className="layer-count",a.textContent=pn(e),r.append(o,s,a);let l=kg(`Show only ${t}`);l.dataset.onlySection=n;let h=document.createElement("label");h.className="layer-switch";let c=document.createElement("input");c.type="checkbox",c.dataset.sectionToggle=n,c.setAttribute("aria-label",`Show ${t}`);let u=document.createElement("span");return u.setAttribute("aria-hidden","true"),h.append(c,u),i.append(r,l,h),i}function kg(n){let t=document.createElement("button");return t.type="button",t.className="only-button",t.dataset.label=n,t.setAttribute("aria-label",n),t.innerHTML='<svg viewBox="0 0 16 16" aria-hidden="true"><circle cx="8" cy="8" r="4.6"/><circle cx="8" cy="8" r="1.3" fill="currentColor" stroke="none"/><path d="M8 1v2M8 13v2M1 8h2M13 8h2"/></svg>',t}function ix(n){let t=n.displayType==="text",e=document.createElement("label");e.className="category-row",Th(e,n);let i=document.createElement("input");i.type="checkbox",i.dataset.category=String(n.id),i.checked=!d.hiddenCategories.has(n.id);let r=document.createElement("span");t?(r.className="text-symbol",r.textContent="Tt",r.title="Drawn as a text label"):(r.className="category-icon",Ih(r,n,Vs(n.title)),r.title=n.icon||n.title);let o=document.createElement("span");o.className="category-name",o.textContent=n.title;let s=document.createElement("span");s.className="category-count",s.textContent=pn(n.locations.length);let a=kg(`Show only ${n.title}`);return a.dataset.onlyCategory=String(n.id),e.append(i,r,o,a,s),e}function pg(n){if(d.collapsedSections.clear(),n)for(let t of C.layers.querySelectorAll("[data-section]"))d.collapsedSections.add(t.dataset.section);Eh()}function Eh(){for(let n of C.layers.querySelectorAll("[data-section]")){let t=d.collapsedSections.has(n.dataset.section);n.setAttribute("aria-expanded",String(!t)),n.closest(".layer-section").classList.toggle("is-collapsed",t)}er()}function nx(){d.sources.pins.clear(),d.sources.text.clear(),d.sources.priority.clear(),d.pins=[],d.pinByID.clear();for(let n of d.map.groups)for(let t of n.categories){t.displayType!=="text"&&bx(t);for(let e of t.locations){let i={location:e,category:t,group:n,coordinate:Ch(e.lat,e.lng),filteredHidden:!1,priority:Xx(t,e),feature:null};i.feature=new vn({geometry:new Ri(i.coordinate),pin:i,priority:i.priority}),d.pins.push(i),d.pinByID.set(e.id,i),t.displayType==="text"?d.sources.text.addFeature(i.feature):d.sources.pins.addFeature(i.feature)}}Gi()}function Og(){let n=(d.map.zones||[]).filter(Kg);d.renderedShard=d.variant?.shard||0,d.sources.zones.clear(),d.sources.zoneTitles.clear(),d.zoneRecords.clear(),d.highlightedZones.clear(),d.focusedZoneID=null,d.zoneTitleCount=0,vh(!0),C.zoneIndex.hidden=n.length===0,C.zoneCount.textContent=pn(n.length);for(let t of n){let e=ut(),i=[],r=!1;for(let l of t.features||[]){let h=lx(l);h&&(r=!0,i.push(h),xo(e,h.getExtent()),d.sources.zones.addFeature(new vn({geometry:h,zone:t,color:gh(t.id),child:t.parentRegionId!=null})))}if(!r)continue;let o=gh(t.id),s=t.center?Ch(t.center.lat,t.center.lng):Bt(e),a=Math.max(e[2]-e[0],e[3]-e[1]);d.sources.zoneTitles.addFeature(new vn({geometry:new Ri(s),zone:t,color:o,child:t.parentRegionId!=null,span:a,priority:(t.parentRegionId==null?2e6:1e6)+Math.round(a)})),d.zoneRecords.set(t.id,{zone:t,extent:e.slice(),geometries:i,color:o})}d.zoneTitleCount=d.sources.zoneTitles.getFeatures().length,Dg(),rx()}function Dg(){if(d.sources.zoneScrim.clear(),!d.highlightedZones.size)return;let[n,t,e,i]=d.projection.getExtent(),r=[mg([[n,t],[e,t],[e,i],[n,i],[n,t]],!0)];for(let o of d.highlightedZones)for(let s of d.zoneRecords.get(o)?.geometries||[]){let a=s.getType()==="MultiPolygon"?s.getPolygons():[s];for(let l of a)l.getLinearRings().forEach((h,c)=>{r.push(mg(h.getCoordinates(),c>0))})}d.sources.zoneScrim.addFeature(new vn({geometry:new ii(r)}))}function mg(n,t){let e=0;for(let i=0,r=n.length-1;i<n.length;r=i++)e+=n[r][0]*n[i][1]-n[i][0]*n[r][1];return e<0===t?n:n.slice().reverse()}function rx(){let n=document.createDocumentFragment();for(let{zone:t,depth:e}of ox()){let i=d.zoneRecords.get(t.id);if(!i)continue;let r=document.createElement("button");r.type="button",r.className="zone-index-item",r.dataset.zone=String(t.id),r.style.setProperty("--zone-color",i.color),r.style.setProperty("--zone-depth",String(e)),r.setAttribute("aria-pressed","false"),r.title=`${t.title}: click to jump; right-click to toggle highlight`;let o=document.createElement("span");o.className="zone-index-marker",o.setAttribute("aria-hidden","true");let s=document.createElement("span");s.textContent=t.title,r.append(o,s),n.append(r)}C.zoneList.replaceChildren(n),C.zoneIndex.hidden=d.zoneRecords.size===0}function ox(){let n=[...d.zoneRecords.values()].map(s=>s.zone),t=new Set(n.map(s=>s.id)),e=new Map;for(let s of n){let a=t.has(s.parentRegionId)?s.parentRegionId:null;e.has(a)||e.set(a,[]),e.get(a).push(s)}for(let s of e.values())s.sort((a,l)=>a.title.localeCompare(l.title,void 0,{numeric:!0,sensitivity:"base"}));let i=[],r=new Set,o=(s,a)=>{if(!r.has(s.id)){r.add(s.id),i.push({zone:s,depth:a});for(let l of e.get(s.id)||[])o(l,a+1)}};for(let s of e.get(null)||[])o(s,0);for(let s of n)o(s,0);return i}function vh(n){d.zonesVisible=n,C.zoneToggle.checked=n,d.layers.zoneScrim.setVisible(n),d.layers.zones.setVisible(n),d.layers.zoneTitles.setVisible(n),d.layers.zoneTitleDetail.setVisible(n)}function sx(n){let t=d.zoneRecords.get(n);t&&(d.focusedZoneID=n,Fg(),tr(),d.engine.getView().fit(t.extent,{size:d.engine.getSize(),padding:[54,54,54,54],maxZoom:ir(d.variant),duration:220}),C.sidebar.classList.remove("is-open"),C.mobileLegend.setAttribute("aria-expanded","false"))}function ax(n){d.zoneRecords.has(n)&&(d.highlightedZones.has(n)?d.highlightedZones.delete(n):(d.highlightedZones.add(n),vh(!0)),d.hoveredPin=null,zg(),Ng(),Fg(),Dg(),d.layers.zones.changed(),d.layers.zoneTitles.changed(),d.layers.zoneTitleDetail.changed())}function Fg(){C.zoneIndex.classList.toggle("has-highlights",d.highlightedZones.size>0);for(let n of C.zoneList.querySelectorAll("[data-zone]")){let t=Number(n.dataset.zone),e=d.highlightedZones.has(t);n.classList.toggle("is-highlighted",e),n.classList.toggle("is-current",d.focusedZoneID===t),n.setAttribute("aria-pressed",String(e))}}function lx(n){if(!n?.coordinates)return null;let t=([e,i])=>Ch(i,e);return n.type==="Polygon"?new ii(n.coordinates.map(e=>e.map(t))):n.type==="MultiPolygon"?new xf(n.coordinates.map(e=>e.map(i=>i.map(t)))):null}function Ch(n,t){let e=d.catalog.tileGrid,i=2**e.sourceZoom,r=(t+180)/360*i,o=n*Math.PI/180,s=(1-Math.asinh(Math.tan(o))/Math.PI)/2*i;return[(r-e.firstTile)*e.tileSize,-(s-e.firstTile)*e.tileSize]}function Gi(){for(let n of d.pins){let t=d.hiddenCategories.has(n.category.id),e=d.search&&!n.location.title.toLocaleLowerCase().includes(d.search);n.filteredHidden=!!(t||e)}zg(),Ng(),d.selectedPin?.filteredHidden&&tr()}function zg(){if(!d.highlightedZones.size){for(let t of d.pins)t.insideHighlightedZone=!1;return}let n=[...d.highlightedZones].map(t=>d.zoneRecords.get(t)).filter(Boolean);for(let t of d.pins)t.insideHighlightedZone=n.some(e=>e.geometries.some(i=>cx(i,t.coordinate)))}function cx(n,t){if(n.intersectsCoordinate(t))return!0;let e=n.getClosestPoint(t),i=e[0]-t[0],r=e[1]-t[1];return i*i+r*r<=1}function Ng(){d.eligibleLocations=d.pins.filter(n=>!Ze(n)).length,mn(),d.layers.pins.changed(),d.layers.zonePins.changed(),d.layers.pinLabels.changed(),d.layers.text.changed(),d.layers.zoneText.changed(),d.layers.textDetail.changed(),d.layers.priority.changed(),Qn()}function mn(){d.sources.priority.clear();for(let n of d.pins){if(Ze(n))continue;let t=!!d.search&&n.location.title.toLocaleLowerCase().includes(d.search);(n===d.selectedPin||n===d.hoveredPin||t||Ys(n))&&d.sources.priority.addFeature(n.feature)}}function zs(n){d.hoveredPin!==n&&(d.hoveredPin=n,d.sources&&(mn(),d.layers.pins.changed(),d.layers.priority.changed()))}function bh(){if(!d.search){C.searchResults.hidden=!0,C.searchResults.replaceChildren();return}let n=d.pins.filter(e=>!d.hiddenCategories.has(e.category.id)&&e.location.title.toLocaleLowerCase().includes(d.search)).sort((e,i)=>e.location.title.localeCompare(i.location.title)).slice(0,20),t=document.createDocumentFragment();if(!n.length){let e=document.createElement("p");e.className="search-empty",e.textContent="No visible locations match.",t.append(e)}for(let e of n){let i=document.createElement("button");i.type="button",i.className="search-result",i.dataset.location=String(e.location.id),Th(i,e.category);let r=document.createElement("span");r.className="result-dot",Ih(r,e.category,Vs(e.category.title));let o=document.createElement("span"),s=document.createElement("strong");s.textContent=e.location.title;let a=document.createElement("small");a.textContent=`${e.category.title} \xB7 ${e.group.title}`,o.append(s,a),i.append(r,o),t.append(i)}C.searchResults.replaceChildren(t),C.searchResults.hidden=!1}function Ns(n){if(d.hiddenCategories.clear(),!n)for(let t of d.map.groups)for(let e of t.categories)d.hiddenCategories.add(e.id);Us(),Gi(),bh(),nr()}function Us(){for(let n of document.querySelectorAll("[data-category]"))n.checked=!d.hiddenCategories.has(Number(n.dataset.category))}function hx(n){let t=d.map.sections.find(i=>i.key===n);if(!t)return;let e=t.categories.some(i=>!d.hiddenCategories.has(i.id));for(let i of t.categories)e?d.hiddenCategories.add(i.id):d.hiddenCategories.delete(i.id);Us(),Gi(),nr()}function ux(n){if(d.map){if(dx(n)){Ns(!0);return}d.hiddenCategories.clear();for(let t of d.map.sections){let e=n.section===t.key;for(let i of t.categories)!e&&n.category!==i.id&&d.hiddenCategories.add(i.id)}Us(),Gi(),bh(),nr()}}function dx(n){for(let t of d.map.sections)for(let e of t.categories)if((n.section===t.key||n.category===e.id)===d.hiddenCategories.has(e.id))return!1;return!0}function fx(){let n=C.soloChip;if(!d.map){n.hidden=!0;return}let t=null,e=0,i=null,r=0;for(let s of d.map.sections){let a=0;for(let l of s.categories)d.hiddenCategories.has(l.id)||(a++,e++,t=l);a>0&&(r++,i=a===s.categories.length?s:null)}let o="";e===1&&t?o=t.title:r===1&&i&&(o=i.title),n.hidden=!o,n.textContent=o?`only: ${o}`:"",n.title=o?`Showing only ${o} \u2014 click to show everything`:""}function nr(){if(d.map){for(let n of d.map.sections){let t=C.legend.querySelector(`input[data-section-toggle="${n.key}"]`);t&&(t.checked=n.categories.some(e=>!d.hiddenCategories.has(e.id)))}fx(),er()}}function _g(n){d.hiddenCategories.delete(n.category.id),d.search="",C.search.value="",C.searchResults.hidden=!0,Us(),Gi(),nr(),Gg(n,!0)}function Gg(n,t=!1){if(d.selectedPin=n,mn(),d.layers.pins.changed(),d.layers.pinLabels.changed(),d.layers.text.changed(),d.layers.textDetail.changed(),d.layers.priority.changed(),C.detailTitle.textContent=n.location.title,C.detailCategory.textContent=`${n.group.title} / ${n.category.title}`,C.detailDescription.textContent="",C.detailLinks.hidden=!0,gx(n),C.detailID.textContent=String(n.location.id),C.detailCoordinates.textContent=`${n.location.lat.toFixed(6)}, ${n.location.lng.toFixed(6)}`,Th(C.detailDot,n.category),Ih(C.detailDot,n.category,Vs(n.category.title)),C.detail.hidden=!1,t){let e=d.engine.getView();e.animate({center:n.coordinate,zoom:Math.min(ir(d.variant),Math.max(e.getZoom()||0,4)),duration:220})}}async function gx(n){let t=await U_(d.map.id);if(d.selectedPin!==n)return;let e=t[String(n.location.id)]||{};n.location.description=e.d||"",n.location.links=e.l||[],C.detailDescription.textContent=Ux(e.d)||"No description is included in the archive.",px(n)}function px(n){let t=(n.location.links||[]).filter(i=>d.pinByID.has(i.locationId));if(C.detailLinks.hidden=t.length===0,!t.length){C.detailLinks.replaceChildren();return}let e=document.createDocumentFragment();for(let i of t){let r=document.createElement("button");r.type="button",r.className="detail-link",r.dataset.location=String(i.locationId),r.textContent=i.title,e.append(r)}C.detailLinks.replaceChildren(e)}function tr(){d.selectedPin=null,d.sources&&(mn(),d.layers.pins.changed(),d.layers.pinLabels.changed(),d.layers.text.changed(),d.layers.textDetail.changed(),d.layers.priority.changed()),C.detail.hidden=!0}function mx(){if(!d.engine||!d.variant)return;let n=d.engine.getView();n.fit(gn(),{size:d.engine.getSize(),padding:[36,36,36,36],maxZoom:d.variant.maxZoom,duration:0}),d.fitZoom=n.getZoom()||0,Qn()}function Ds(n){let t=d.engine.getView(),e=t.getZoom()||0;t.animate({zoom:pi(e+n,d.variant.minZoom,ir(d.variant)),duration:140})}function Qn(){let n=d.engine?.getView().getZoom();if(C.viewport.dataset.zoom=Number.isFinite(n)?n.toFixed(3):"",!d.engine||!d.pins.length){C.visibleCount.textContent="0 locations visible";return}let t=d.engine.getView().calculateExtent(d.engine.getSize()),e=0;for(let i of d.pins){if(Ze(i))continue;let[r,o]=i.coordinate;r>=t[0]&&r<=t[2]&&o>=t[1]&&o<=t[3]&&e++}C.visibleCount.textContent=`${pn(d.eligibleLocations)} enabled \xB7 ${pn(e)} in view`}function Se(n,t){return(n.get("priority")||0)-(t.get("priority")||0)}function _x(n){let t=n.get("pin");return!t||Ze(t)||t.insideHighlightedZone||to(t)?null:Sh(t,!1)}function xx(n){let t=n.get("pin");return!t||!d.highlightedZones.size||!t.insideHighlightedZone||Ze(t)||to(t)?null:Sh(t,!1)}function yx(n){let t=n.get("pin");return!t||Ze(t)||!d.pinLabelsVisible||!eo()?null:Xg(t)}function wx(n){let t=n.get("pin");if(!t||Ze(t)||t.insideHighlightedZone||to(t)||eo())return null;let e=d.fitZoom+Math.log2(Wx(t.category));return(d.engine.getView().getZoom()||0)<e?null:Ks(t,!1)}function Ex(n){let t=n.get("pin");return!t||Ze(t)||t.insideHighlightedZone||to(t)||!eo()?null:Ks(t,!1)}function vx(n){let t=n.get("pin");return!t||!d.highlightedZones.size||!t.insideHighlightedZone||Ze(t)||to(t)?null:Ks(t,!1)}function Cx(n){let t=n.get("pin");if(!t||Ze(t))return null;if(t.category.displayType==="text")return Ks(t,t===d.selectedPin);let e=Sh(t,t===d.selectedPin);return t===d.hoveredPin||t===d.selectedPin?[e,Xg(t)]:e}function Sh(n,t){let e=`marker:${n.category.id}:${t?1:0}`;if(d.styleCache.has(e))return d.styleCache.get(e);let i=Zs(n.category),r=t?2e7:n.priority,o=d.markerIcons.get(Wg(n.category)),s;return o?s=new It({image:new hn({src:o,width:t?36:31,height:t?36:31}),zIndex:r}):s=new It({text:new li({text:Vs(n.category.title),font:`900 ${t?15:13}px Inter, sans-serif`,fill:new _t({color:i}),stroke:new Pt({color:Rh(),width:t?4:3})}),zIndex:r}),d.styleCache.set(e,s),s}function Xg(n){let t=`marker-label:${n.location.id}`;if(d.styleCache.has(t))return d.styleCache.get(t);let e=new It({text:new li({text:n.location.title,offsetY:21,font:'700 10px "Arial Narrow", "Roboto Condensed", sans-serif',fill:new _t({color:"#f4f6ed"}),stroke:new Pt({color:"rgba(0,0,0,0.98)",width:3}),backgroundFill:new _t({color:"rgba(10,13,9,0.72)"}),padding:[2,4,2,4],overflow:!0}),zIndex:n.priority});return d.styleCache.set(t,e),e}function bx(n){if(!n.iconAsset)return;let t=Wg(n);if(d.markerIcons.has(t))return;d.markerIcons.set(t,null);let e=new Image;e.onload=()=>{let i=document.createElement("canvas");i.width=64,i.height=64;let r=i.getContext("2d"),o=Zs(n),s=document.createElement("canvas");s.width=64,s.height=64;let a=s.getContext("2d");a.imageSmoothingEnabled=!n.iconPicture,a.drawImage(e,6,6,52,52),n.iconPicture||(a.globalCompositeOperation="source-in",a.fillStyle=o,a.fillRect(0,0,64,64));let l=document.createElement("canvas");l.width=64,l.height=64;let h=l.getContext("2d");h.drawImage(e,6,6,52,52),h.globalCompositeOperation="source-in",h.fillStyle=Rh(),h.fillRect(0,0,64,64);for(let c=-3;c<=3;c++)for(let u=-3;u<=3;u++)u*u+c*c<=10&&r.drawImage(l,u,c);r.drawImage(s,0,0),d.markerIcons.set(t,i.toDataURL("image/png")),Sx(),d.layers.pins.changed(),d.layers.zonePins.changed(),d.layers.priority.changed()},e.onerror=()=>d.markerIcons.set(t,!1),e.src=Zg(n.iconAsset)}function Sx(){for(let n of d.styleCache.keys())n.startsWith("marker:")&&d.styleCache.delete(n)}function Wg(n){return`${n.iconAsset||""}:${Zs(n)}:${d.map?.iconOutset||"light"}`}var Rx={light:"rgba(255, 255, 255, 0.96)",dark:"rgba(7, 9, 7, 0.98)"};function Rh(){return Rx[d.map?.iconOutset==="dark"?"dark":"light"]}function Tx(n){let t=d.map?.iconOutset==="dark",e=Lx(n);return(t?e>.3:e<.88)?n:Ix(n,t?.74:.42)}function Ix(n,t){let e=String(n).replace("#","");if(e.length!==6)return n;let[i,r,o]=[0,2,4].map(v=>parseInt(e.slice(v,v+2),16)/255),s=Math.max(i,r,o),a=Math.min(i,r,o),l=(s+a)/2,h=0,c=s-a,u=c===0?0:c/(1-Math.abs(2*l-1));c!==0&&(s===i?h=(r-o)/c%6:s===r?h=(o-i)/c+2:h=(i-r)/c+4,h*=60,h<0&&(h+=360));let f=(1-Math.abs(2*t-1))*u,g=f*(1-Math.abs(h/60%2-1)),p=t-f/2,[_,m,x]=h<60?[f,g,0]:h<120?[g,f,0]:h<180?[0,f,g]:h<240?[0,g,f]:h<300?[g,0,f]:[f,0,g],w=v=>Math.round((v+p)*255).toString(16).padStart(2,"0");return`#${w(_)}${w(m)}${w(x)}`}function Lx(n){let t=String(n).replace("#","");if(t.length!==6)return .5;let e=i=>parseInt(t.slice(i,i+2),16)/255;return .2126*e(0)+.7152*e(2)+.0722*e(4)}function Ks(n,t){let e=`text:${n.location.id}:${t?1:0}`;if(d.styleCache.has(e))return d.styleCache.get(e);let r=[new It({text:new li({text:n.location.title,font:`${t?"900":"800"} 14px "Arial Narrow", "Roboto Condensed", sans-serif`,fill:new _t({color:t?"#d6f36b":"#f3f5e9"}),stroke:new Pt({color:"rgba(0,0,0,0.95)",width:4}),backgroundFill:new _t({color:t?"rgba(17,21,14,0.9)":"rgba(10,13,9,0.58)"}),backgroundStroke:t?new Pt({color:"#d6f36b",width:1}):void 0,padding:[3,6,3,6],overflow:!0}),zIndex:t?2e7:n.priority+3e6})];return d.styleCache.set(e,r),r}function xg(n,t){let e=n.get("gridCell");if(!e)return null;let i=e.role==="leaf",r=e.role==="scope",o=e.role==="neighbor",s=i||r?15:o?10:11,l=`${i||r?900:o?750:800} ${s}px ui-monospace, SFMono-Regular, Menlo, monospace`,h=o?[2,4,2,4]:[3,5,3,5],c=Ax(e,l,s,h,t);if(e.role==="child"&&(!c||!d.subgridVisible))return null;let u=r&&d.subgridVisible,f=`grid:${e.hash}:${e.role}:${e.contextDistance}:${c?1:0}:${u?1:0}`;if(d.styleCache.has(f))return d.styleCache.get(f);let g=Gs[Math.max(0,Ni.indexOf(e.hash[e.hash.length-1]))%Gs.length],p=new It({fill:r?void 0:new _t({color:o?`rgba(3, 5, 3, ${Math.min(.52,.3+e.contextDistance*.06)})`:zi(g,i?.14:.055)}),stroke:new Pt({color:i||r?"#ffffff":zi(g,o?.44:.82),width:i?2.5:r?u?1.8:2.5:o?1:1.4}),text:c&&!u?new li({text:e.hash,font:l,fill:new _t({color:i||r?"#ffffff":o?zi(g,.72):g}),stroke:new Pt({color:"rgba(0,0,0,0.96)",width:4}),backgroundFill:new _t({color:o?"rgba(4,6,4,0.88)":"rgba(9,12,8,0.76)"}),padding:h,overflow:!0}):void 0,zIndex:i||r?100:n.get("priority")});return d.styleCache.set(f,p),p}function Ax(n,t,e,i,r){if(!r)return!0;let o=Mx(n.hash,t)+i[1]+i[3],s=e+i[0]+i[2];return o<=(n.extent[2]-n.extent[0])/r&&s<=(n.extent[3]-n.extent[1])/r}var yg=document.createElement("canvas").getContext("2d"),wg=new Map;function Mx(n,t){let e=`${t}|${n}`,i=wg.get(e);return i===void 0&&(yg.font=t,i=yg.measureText(n).width,wg.set(e,i)),i}var Px=new It({fill:new _t({color:"rgba(3, 5, 3, 0.62)"})});function kx(){return d.zonesVisible?Px:null}function Ox(n){if(!d.zonesVisible)return null;let t=n.get("zone"),e=n.get("child"),i=d.highlightedZones.has(t.id),r=Ug(t.id),o=`zone:${t.id}:${e?1:0}:${i?1:r?2:0}`;if(d.styleCache.has(o))return d.styleCache.get(o);let s=n.get("color");if(r){let h=new It({stroke:new Pt({color:zi(s,e?.34:.44),width:e?1:1.3,lineDash:e?[3,4]:[7,5]}),zIndex:e?101:100});return d.styleCache.set(o,h),h}let a=new It({fill:new _t({color:zi(s,e?.035:.07)}),stroke:new Pt({color:zi(s,e?.5:.72),width:e?1.2:1.8,lineDash:e?[3,4]:[7,5]})});if(!i)return d.styleCache.set(o,a),a;let l=[new It({stroke:new Pt({color:"rgba(255,255,255,0.94)",width:5}),zIndex:9e3}),new It({fill:new _t({color:zi(s,.22)}),stroke:new Pt({color:s,width:2.6}),zIndex:9001})];return d.styleCache.set(o,l),l}function Dx(n){if(!d.zonesVisible||eo())return null;let t=n.get("child"),e=d.highlightedZones.has(n.get("zone").id),i=d.engine.getView().getZoom()||0;if(!e&&t&&i<d.fitZoom+3)return null;let r=n.get("span")/d.engine.getView().getResolution();return!e&&d.zoneTitleCount>40&&r<52?null:Yg(n)}function Fx(n){return!d.zonesVisible||!eo()?null:Yg(n)}function Yg(n){let t=n.get("child"),e=n.get("zone"),i=d.highlightedZones.has(e.id),r=Ug(e.id),o=`zone-title:${e.id}:${t?1:0}:${i?1:r?2:0}`;if(d.styleCache.has(o))return d.styleCache.get(o);let s=n.get("color"),a=new It({text:new li({text:e.title.toLocaleUpperCase(),font:`${t?"700 12px":"800 14px"} "Arial Narrow", "Roboto Condensed", sans-serif`,fill:new _t({color:i?"#11140f":r?"rgba(185,192,177,0.56)":t?"#c7ccbd":"#f1f4e7"}),stroke:new Pt({color:i?"rgba(255,255,255,0.96)":r?"rgba(0,0,0,0.82)":"rgba(0,0,0,0.95)",width:i?2:r?3:4}),backgroundFill:new _t({color:i?s:r?"rgba(4,6,4,0.84)":"rgba(11,14,10,0.72)"}),backgroundStroke:new Pt({color:i?"#ffffff":zi(s,r?.24:.55),width:i?2:1}),padding:[5,8,5,8],overflow:!0}),zIndex:i?91e5:n.get("priority")});return d.styleCache.set(o,a),a}function Ug(n){if(!d.highlightedZones.size||d.highlightedZones.has(n))return!1;for(let t of d.highlightedZones)if(zx(n,t))return!1;return!0}function zx(n,t){let e=new Set,i=d.zoneRecords.get(t)?.zone.parentRegionId;for(;i!=null&&!e.has(i);){if(i===n)return!0;e.add(i),i=d.zoneRecords.get(i)?.zone.parentRegionId}return!1}function to(n){return n===d.selectedPin||n===d.hoveredPin||Ys(n)||!!d.search&&n.location.title.toLocaleLowerCase().includes(d.search)}function Ze(n){return n.filteredHidden||Nx(n)||Gx(n)||!Kg(n.location)}function Kg(n){let t=d.variant?.shard;return!t||!n.shard||n.shard===t}function Nx(n){return!d.highlightedZones.size||n.insideHighlightedZone||n===d.selectedPin?!1:!(d.search&&n.location.title.toLocaleLowerCase().includes(d.search))}function Gx(n){return!d.gridEnabled||!d.gridPrefix||Ys(n)||n===d.selectedPin?!1:!(d.search&&n.location.title.toLocaleLowerCase().includes(d.search))}function Xx(n,t){return Math.max(0,1e6-Math.min(n.locations.length,999)*1e3)+Yx(t.id)%1e3}function Wx(n){return n.locations.length>200?4:n.locations.length>75?2.5:1}function eo(){return(d.engine?.getView().getZoom()||0)>=(d.variant?.maxZoom||0)-.05}function Yx(n){return Math.imul(Number(n)||0,2654435761)>>>0}function gh(n){let t=Math.abs(Number(n)||0);return Gs[(Math.imul(t,2654435761)>>>0)%Gs.length]}function zi(n,t){let e=String(n||"#ffffff").replace("#",""),i=e.length===3?e.split("").map(o=>o+o).join(""):e.slice(0,6).padEnd(6,"f"),r=Number.parseInt(i,16);return`rgba(${r>>16&255}, ${r>>8&255}, ${r&255}, ${t})`}function Th(n,t){n.style.setProperty("--pin-color",Zs(t))}function Zs(n){return Tx(n.color||gh(n.id))}function Ih(n,t,e){if(n.classList.remove("has-source-icon"),n.style.removeProperty("--pin-icon"),n.textContent="",!t.iconAsset){n.textContent=e;return}n.style.setProperty("--pin-icon",`url("${Zg(t.iconAsset)}")`),n.classList.add("has-source-icon")}function Zg(n){return`/static/icons/${n.split("/").map(e=>encodeURIComponent(e)).join("/")}`}function Vs(n){return n.split(/\s+/).slice(0,2).map(t=>t[0]||"").join("")}function Ux(n){return String(n||"").replace(/\[([^\]]+)\]\([^)]+\)/g,"$1").replace(/[*_`>#]/g,"").replace(/\r/g,"").replace(/\n{3,}/g,`1+(()=>{var iu=n=>new Promise(t=>setTimeout(t,n)),yt=n=>document.querySelector(n);async function Mm(){for(let n=0;n<300&&!(window.__atlasDebug&&!yt("#map-loading")?.checkVisibility?.());n+=1)await iu(100)}async function Pm(){let n="";for(let t=0;t<100;t+=1){await iu(120),window.advanceTime?.();let e=window.__atlasDebug.snapshot(),i=JSON.stringify([e.zoom,e.center,e.resolution,e.tileStats]);if(i===n)return;n=i}}function ri(n,t={}){window.dispatchEvent(new KeyboardEvent("keydown",{key:n,bubbles:!0,cancelable:!0,...t}))}function Om(n){yt("#map").dispatchEvent(new KeyboardEvent("keydown",{key:n,bubbles:!0,cancelable:!0}))}function Qi(n,t){n.value=t,n.dispatchEvent(new Event("change",{bubbles:!0}))}function _a(n,t){let e=yt(n);e.value=t,e.dispatchEvent(new Event("input",{bubbles:!0}))}function ya(n,t=!1){let e=yt("#parity-badge");e||(e=document.createElement("div"),e.id="parity-badge",e.style.cssText="position:fixed;top:8px;right:8px;z-index:9999;padding:6px 12px;font:700 13px monospace;border-radius:6px;color:#fff;pointer-events:none;",document.body.append(e)),e.style.background=t?"#b3261e":"#1a7f37",e.textContent=n}async function Dm(){let n=[],t=async f=>{await Pm(),n.push({name:f,snapshot:JSON.parse(window.render_game_to_text())})};await Mm(),localStorage.clear();let e=yt("#game-select"),i=e.options[0].value;Qi(e,i),await t("initial"),_a("#pin-search","a"),await t("search-a");let r=yt(".search-result");r&&(r.click(),await t("search-select-first"),yt("#close-detail").click(),await t("detail-closed")),_a("#pin-search",""),await t("search-cleared");let s=yt(".category-row input");s&&(s.click(),await t("category-hidden"),s.click(),await t("category-restored"));let o=yt(".only-button");if(o){o.click(),await t("solo-first");let f=yt("#solo-chip");f&&!f.hidden&&f.click(),await t("solo-cleared")}let a=yt("#legend .layer-title");a&&(a.click(),await t("section-folded"),yt("#expand-all").click(),await t("sections-unfolded")),yt("#hide-all").click(),await t("all-hidden"),yt("#show-all").click(),await t("all-shown");let l=yt(".zone-index-item");l&&(l.click(),await t("zone-jumped"),l.dispatchEvent(new MouseEvent("contextmenu",{bubbles:!0,cancelable:!0})),await t("zone-highlighted"),l.dispatchEvent(new MouseEvent("contextmenu",{bubbles:!0,cancelable:!0})),await t("zone-unhighlighted")),ri("g"),await t("grid-open"),_a("#grid-input","m"),await t("grid-descended"),ri(" "),await t("subgrid-hidden"),ri(" "),ri("Escape"),await t("grid-ascended"),ri("Escape"),await t("grid-closed"),ri("z"),await t("labels-on"),ri("z"),await t("labels-off"),ri("b",{metaKey:!0}),await t("sidebar-collapsed"),ri("b",{metaKey:!0}),await t("sidebar-restored"),yt("#zoom-in").click(),await t("zoomed-in");let h=yt("#overview-dock");h&&!yt("#overview-shelf").hidden&&(h.click(),await t("overview-docked"),h.click(),await t("overview-undocked")),yt("#zoom-out").click(),await t("zoomed-out"),Om("Escape"),await t("viewport-escape");let c=yt("#variant-select");c.options.length>1&&(Qi(c,c.options[1].value),await t("variant-second"),Qi(c,c.options[0].value),await t("variant-first"));let d=yt("#map-select");return d.options.length>1&&(Qi(d,d.options[1].value),await t("map-second"),Qi(d,d.options[0].value),await t("map-first")),e.options.length>1&&(Qi(e,e.options[1].value),await t("game-second"),Qi(e,i),await t("game-first")),localStorage.clear(),{viewport:[window.innerWidth,window.innerHeight],steps:n}}var xa=!1;async function nu(){if(!xa){xa=!0,ya("parity tour running\u2026");try{let n=await Dm(),t=await fetch("/parity/result",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(n,null,2)}),e=(await t.text()).trim();if(!t.ok)throw new Error(`saving failed: ${t.status} ${e}`);ya(`parity tour complete \u2713 ${n.steps.length} steps`),console.log("parity tour saved to",e)}catch(n){ya(`parity tour failed: ${n}`,!0),console.error("parity tour failed",n)}finally{xa=!1}}}window.__atlasTour=nu;window.addEventListener("keydown",n=>{n.key==="F9"&&nu()});var W=n=>document.querySelector(n),v={game:W("#game-select"),map:W("#map-select"),variant:W("#variant-select"),variantField:W("#variant-field"),gameTitle:W("#game-title"),title:W("#map-title"),meta:W("#map-meta"),legend:W("#legend"),search:W("#pin-search"),searchResults:W("#search-results"),visibleCount:W("#visible-count"),viewport:W("#map"),layers:W("#layers"),zoneToggle:W("#zone-toggle"),zoneCount:W("#zone-count"),zoneIndex:W("#zone-index"),zoneList:W("#zone-list"),loading:W("#map-loading"),labelsHint:W("#labels-hint"),gridHint:W("#grid-hint"),soloChip:W("#solo-chip"),overview:W("#overview"),overviewShelf:W("#overview-shelf"),overviewDock:W("#overview-dock"),overviewCanvas:W("#overview-canvas"),overviewViewport:W("#overview-viewport"),gridNavigator:W("#grid-navigator"),gridInput:W("#grid-input"),gridBack:W("#grid-back"),subgridToggle:W("#subgrid-toggle"),detail:W("#pin-detail"),detailTitle:W("#detail-title"),detailCategory:W("#detail-category"),detailDescription:W("#detail-description"),detailID:W("#detail-id"),detailCoordinates:W("#detail-coordinates"),detailLinks:W("#detail-links"),detailDot:W("#detail-dot"),sidebar:W("#sidebar"),mobileLegend:W("#mobile-legend"),fatal:W("#fatal-error"),fatalMessage:W("#fatal-message")};function Sr(n,t,e,i){n.replaceChildren(),t.forEach((r,s)=>{let o=document.createElement("option");o.value=i?String(r[i]):r.slug||String(s),o.textContent=r[e],n.append(o)})}var u={catalog:null,game:null,map:null,variant:null,engine:null,projection:null,layers:null,sources:null,hiddenCategories:new Set,collapsedSections:new Set,pins:[],pinByID:new Map,selectedPin:null,hoveredPin:null,pinLabelsVisible:!1,gridEnabled:!1,subgridVisible:!0,gridPrefix:"",zonesVisible:!0,zoneRecords:new Map,highlightedZones:new Set,focusedZoneID:null,search:"",fitZoom:0,zoneTitleCount:0,eligibleLocations:0,tileRun:0,tileStats:{requested:0,loaded:0,errors:0,peakPending:0},overviewRun:0,overviewKey:"",overviewPointer:null,overviewDocked:!1,renderedShard:0,mapRun:0,textByMap:new Map,restore:null,settling:!1,styleCache:new Map,markerIcons:new Map};var Tn=["#d6f36b","#72d5f4","#ff9e64","#df83ff","#62e6ae","#ff6f91","#f4d35e","#8aa9ff","#e7a56d","#83d483"],me="0123456789bcdefghjkmnpqrstuvwxyz";var Ea="atlas.session";var ru={light:"rgba(255, 255, 255, 0.96)",dark:"rgba(7, 9, 7, 0.98)"};var xt={UNKNOWN:0,INTERSECTING:1,ABOVE:2,RIGHT:4,BELOW:8,LEFT:16};function wa(n){let t=ut();for(let e=0,i=n.length;e<i;++e)nn(t,n[e]);return t}function km(n,t,e){let i=Math.min.apply(null,n),r=Math.min.apply(null,t),s=Math.max.apply(null,n),o=Math.max.apply(null,t);return Qt(i,r,s,o,e)}function In(n,t,e){return e?(e[0]=n[0]-t,e[1]=n[1]-t,e[2]=n[2]+t,e[3]=n[3]+t,e):[n[0]-t,n[1]-t,n[2]+t,n[3]+t]}function bs(n,t){return t?(t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t):n.slice()}function Ii(n,t,e){let i,r;return t<n[0]?i=n[0]-t:n[2]<t?i=t-n[2]:i=0,e<n[1]?r=n[1]-e:n[3]<e?r=e-n[3]:r=0,i*i+r*r}function pe(n,t){return Rr(n,t[0],t[1])}function De(n,t){return n[0]<=t[0]&&t[2]<=n[2]&&n[1]<=t[1]&&t[3]<=n[3]}function Rr(n,t,e){return n[0]<=t&&t<=n[2]&&n[1]<=e&&e<=n[3]}function Is(n,t){let e=n[0],i=n[1],r=n[2],s=n[3],o=t[0],a=t[1],l=xt.UNKNOWN;return o<e?l=l|xt.LEFT:o>r&&(l=l|xt.RIGHT),a<i?l=l|xt.BELOW:a>s&&(l=l|xt.ABOVE),l===xt.UNKNOWN&&(l=xt.INTERSECTING),l}function ut(){return[1/0,1/0,-1/0,-1/0]}function Qt(n,t,e,i,r){return r?(r[0]=n,r[1]=t,r[2]=e,r[3]=i,r):[n,t,e,i]}function tn(n){return Qt(1/0,1/0,-1/0,-1/0,n)}function Ls(n,t){let e=n[0],i=n[1];return Qt(e,i,e,i,t)}function bn(n,t,e,i,r){let s=tn(r);return Ca(s,n,t,e,i)}function en(n,t){return n[0]==t[0]&&n[2]==t[2]&&n[1]==t[1]&&n[3]==t[3]}function As(n,t){return t[0]<n[0]&&(n[0]=t[0]),t[2]>n[2]&&(n[2]=t[2]),t[1]<n[1]&&(n[1]=t[1]),t[3]>n[3]&&(n[3]=t[3]),n}function nn(n,t){t[0]<n[0]&&(n[0]=t[0]),t[0]>n[2]&&(n[2]=t[0]),t[1]<n[1]&&(n[1]=t[1]),t[1]>n[3]&&(n[3]=t[1])}function Ca(n,t,e,i,r){for(;e<i;e+=r)Fm(n,t[e],t[e+1]);return n}function Fm(n,t,e){n[0]=Math.min(n[0],t),n[1]=Math.min(n[1],e),n[2]=Math.max(n[2],t),n[3]=Math.max(n[3],e)}function Ms(n,t){let e;return e=t(Ln(n)),e||(e=t(An(n)),e)||(e=t(Mn(n)),e)||(e=t(ae(n)),e)?e:!1}function Tr(n){let t=0;return Fe(n)||(t=j(n)*ct(n)),t}function Ln(n){return[n[0],n[1]]}function An(n){return[n[2],n[1]]}function Kt(n){return[(n[0]+n[2])/2,(n[1]+n[3])/2]}function su(n,t){let e;if(t==="bottom-left")e=Ln(n);else if(t==="bottom-right")e=An(n);else if(t==="top-left")e=ae(n);else if(t==="top-right")e=Mn(n);else throw new Error("Invalid corner");return e}function Ir(n,t,e,i,r){let[s,o,a,l,h,c,d,f]=va(n,t,e,i);return Qt(Math.min(s,a,h,d),Math.min(o,l,c,f),Math.max(s,a,h,d),Math.max(o,l,c,f),r)}function va(n,t,e,i){let r=t*i[0]/2,s=t*i[1]/2,o=Math.cos(e),a=Math.sin(e),l=r*o,h=r*a,c=s*o,d=s*a,f=n[0],g=n[1];return[f-l+d,g-h-c,f-l-d,g-h+c,f+l-d,g+h+c,f+l+d,g+h-c,f-l+d,g-h-c]}function ct(n){return n[3]-n[1]}function ke(n,t,e){let i=e||ut();return ht(n,t)?(n[0]>t[0]?i[0]=n[0]:i[0]=t[0],n[1]>t[1]?i[1]=n[1]:i[1]=t[1],n[2]<t[2]?i[2]=n[2]:i[2]=t[2],n[3]<t[3]?i[3]=n[3]:i[3]=t[3]):tn(i),i}function Sa(n,t){if(!ht(n,t))return[n.slice()];if(De(t,n))return[];let[e,i,r,s]=n,o=Math.max(e,t[0]),a=Math.max(i,t[1]),l=Math.min(r,t[2]),h=Math.min(s,t[3]),c=[];return o>e&&c.push([e,i,o,s]),l<r&&c.push([l,i,r,s]),a>i&&c.push([o,i,l,a]),h<s&&c.push([o,h,l,s]),c}function ae(n){return[n[0],n[3]]}function Mn(n){return[n[2],n[3]]}function j(n){return n[2]-n[0]}function ht(n,t){return n[0]<=t[2]&&n[2]>=t[0]&&n[1]<=t[3]&&n[3]>=t[1]}function Fe(n){return n[2]<n[0]||n[3]<n[1]}function ou(n,t){return t?(t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t):n}function au(n,t,e){let i=!1,r=Is(n,t),s=Is(n,e);if(r===xt.INTERSECTING||s===xt.INTERSECTING)i=!0;else{let o=n[0],a=n[1],l=n[2],h=n[3],c=t[0],d=t[1],f=e[0],g=e[1],m=(g-d)/(f-c),_,p;s&xt.ABOVE&&!(r&xt.ABOVE)&&(_=f-(g-h)/m,i=_>=o&&_<=l),!i&&s&xt.RIGHT&&!(r&xt.RIGHT)&&(p=g-(f-l)*m,i=p>=a&&p<=h),!i&&s&xt.BELOW&&!(r&xt.BELOW)&&(_=f-(g-a)/m,i=_>=o&&_<=l),!i&&s&xt.LEFT&&!(r&xt.LEFT)&&(p=g-(f-o)*m,i=p>=a&&p<=h)}return i}function lu(n,t,e,i){if(Fe(n))return tn(e);let r=[];if(i>1){let a=n[2]-n[0],l=n[3]-n[1];for(let h=0;h<i;++h)r.push(n[0]+a*h/i,n[1],n[2],n[1]+l*h/i,n[2]-a*h/i,n[3],n[0],n[3]-l*h/i)}else r=[n[0],n[1],n[2],n[1],n[2],n[3],n[0],n[3]];t(r,r,2);let s=[],o=[];for(let a=0,l=r.length;a<l;a+=2)s.push(r[a]),o.push(r[a+1]);return km(s,o,e)}function Ra(n,t){let e=t.getExtent(),i=Kt(n);if(t.canWrapX()&&(i[0]<e[0]||i[0]>=e[2])){let r=j(e),o=Math.floor((i[0]-e[0])/r)*r;n[0]-=o,n[2]-=o}return n}function Ps(n,t,e){if(t.canWrapX()){let i=t.getExtent();if(!isFinite(n[0])||!isFinite(n[2]))return[[i[0],n[1],i[2],n[3]]];Ra(n,t);let r=j(i);if(j(n)>r&&!e)return[[i[0],n[1],i[2],n[3]]];if(n[0]<i[0])return[[n[0]+r,n[1],i[2],n[3]],[i[0],n[1],n[2],n[3]]];if(n[2]>i[2])return[[n[0],n[1],i[2],n[3]],[i[0],n[1],n[2]-r,n[3]]]}return[n]}function cu(n,t){let e=[n];for(let i=0,r=t.length;i<r&&e.length>0;++i){let s=[];for(let o=0,a=e.length;o<a;++o)s.push(...Sa(e[o],t[i]));e=s}return e}var hu={info:1,warn:2,error:3,none:4},Nm=hu.info;function Os(...n){Nm>hu.warn||console.warn(...n)}function et(n,t,e){return Math.min(Math.max(n,t),e)}function uu(n,t,e,i,r,s){let o=r-e,a=s-i;if(o!==0||a!==0){let l=((n-e)*o+(t-i)*a)/(o*o+a*a);l>1?(e=r,i=s):l>0&&(e+=o*l,i+=a*l)}return _e(n,t,e,i)}function _e(n,t,e,i){let r=e-n,s=i-t;return r*r+s*s}function du(n){let t=n.length;for(let i=0;i<t;i++){let r=i,s=Math.abs(n[i][i]);for(let a=i+1;a<t;a++){let l=Math.abs(n[a][i]);l>s&&(s=l,r=a)}if(s===0)return null;let o=n[r];n[r]=n[i],n[i]=o;for(let a=i+1;a<t;a++){let l=-n[a][i]/n[i][i];for(let h=i;h<t+1;h++)i==h?n[a][h]=0:n[a][h]+=l*n[i][h]}}let e=new Array(t);for(let i=t-1;i>=0;i--){e[i]=n[i][t]/n[i][i];for(let r=i-1;r>=0;r--)n[r][t]-=n[r][i]*e[i]}return e}function Ds(n){return n*180/Math.PI}function ye(n){return n*Math.PI/180}function Ne(n,t){let e=n%t;return e*t<0?e+t:e}function zt(n,t,e){return n+e*(t-n)}function rn(n,t){let e=Math.pow(10,t);return Math.round(n*e)/e}function br(n,t){return Math.floor(rn(n,t))}function Lr(n,t){return Math.ceil(rn(n,t))}function ks(n,t,e){if(n>=t&&n<e)return n;let i=e-t;return((n-t)%i+i)%i+t}function fu(n,t){return n[0]+=+t[0],n[1]+=+t[1],n}function sn(n,t){let e=!0;for(let i=n.length-1;i>=0;--i)if(n[i]!=t[i]){e=!1;break}return e}function Pn(n,t){let e=Math.cos(t),i=Math.sin(t),r=n[0]*e-n[1]*i,s=n[1]*e+n[0]*i;return n[0]=r,n[1]=s,n}function gu(n,t){return n[0]*=t,n[1]*=t,n}function Fs(n,t){if(t.canWrapX()){let e=j(t.getExtent()),i=mu(n,t,e);i&&(n[0]-=i*e)}return n}function mu(n,t,e){let i=t.getExtent(),r=0;return t.canWrapX()&&(n[0]<i[0]||n[0]>i[2])&&(e=e||j(i),r=Math.floor((n[0]-i[0])/e)),r}function pu(n,t,e){let i=Math.sqrt((t[0]-n[0])*(t[0]-n[0])+(t[1]-n[1])*(t[1]-n[1])),r=[(t[0]-n[0])/i,(t[1]-n[1])/i],s=[-r[1],r[0]],o=Math.sqrt((e[0]-n[0])*(e[0]-n[0])+(e[1]-n[1])*(e[1]-n[1])),a=[(e[0]-n[0])/o,(e[1]-n[1])/o],l=i===0||o===0?0:Math.acos(et(a[0]*r[0]+a[1]*r[1],-1,1));return l=Math.max(l,1e-5),a[0]*s[0]+a[1]*s[1]>0?l:Math.PI*2-l}var si={radians:6370997/(2*Math.PI),degrees:2*Math.PI*6370997/360,ft:.3048,m:1,"us-ft":1200/3937};var Ta=class{constructor(t){this.code_=t.code,this.units_=t.units,this.extent_=t.extent!==void 0?t.extent:null,this.worldExtent_=t.worldExtent!==void 0?t.worldExtent:null,this.axisOrientation_=t.axisOrientation!==void 0?t.axisOrientation:"enu",this.global_=t.global!==void 0?t.global:!1,this.canWrapX_=!!(this.global_&&this.extent_),this.getPointResolutionFunc_=t.getPointResolution,this.defaultTileGrid_=null,this.metersPerUnit_=t.metersPerUnit}canWrapX(){return this.canWrapX_}getCode(){return this.code_}getExtent(){return this.extent_}getUnits(){return this.units_}getMetersPerUnit(){return this.metersPerUnit_||si[this.units_]}getWorldExtent(){return this.worldExtent_}getAxisOrientation(){return this.axisOrientation_}isGlobal(){return this.global_}setGlobal(t){this.global_=t,this.canWrapX_=!!(t&&this.extent_)}getDefaultTileGrid(){return this.defaultTileGrid_}setDefaultTileGrid(t){this.defaultTileGrid_=t}setExtent(t){this.extent_=t,this.canWrapX_=!!(this.global_&&t)}setWorldExtent(t){this.worldExtent_=t}setGetPointResolution(t){this.getPointResolutionFunc_=t}getPointResolutionFunc(){return this.getPointResolutionFunc_}},bi=Ta;var Ar=6378137,On=Math.PI*Ar,zm=[-On,-On,On,On],Gm=[-180,-85,180,85],Ns=Ar*Math.log(Math.tan(Math.PI/2)),Li=class extends bi{constructor(t){super({code:t,units:"m",extent:zm,global:!0,worldExtent:Gm,getPointResolution:function(e,i){return e/Math.cosh(i[1]/Ar)}})}},Ia=[new Li("EPSG:3857"),new Li("EPSG:102100"),new Li("EPSG:102113"),new Li("EPSG:900913"),new Li("http://www.opengis.net/def/crs/EPSG/0/3857"),new Li("http://www.opengis.net/gml/srs/epsg.xml#3857")];function _u(n,t,e,i){let r=n.length;e=e>1?e:2,i=i??e,t===void 0&&(e>2?t=n.slice():t=new Array(r));for(let s=0;s<r;s+=i){t[s]=On*n[s]/180;let o=Ar*Math.log(Math.tan(Math.PI*(+n[s+1]+90)/360));o>Ns?o=Ns:o<-Ns&&(o=-Ns),t[s+1]=o}return t}function yu(n,t,e,i){let r=n.length;e=e>1?e:2,i=i??e,t===void 0&&(e>2?t=n.slice():t=new Array(r));for(let s=0;s<r;s+=i)t[s]=180*n[s]/On,t[s+1]=360*Math.atan(Math.exp(n[s+1]/Ar))/Math.PI-90;return t}var Xm=6378137,xu=[-180,-90,180,90],Wm=Math.PI*Xm/180,oi=class extends bi{constructor(t,e){super({code:t,units:"degrees",extent:xu,axisOrientation:e,global:!0,metersPerUnit:Wm,worldExtent:xu})}},ba=[new oi("CRS:84"),new oi("EPSG:4326","neu"),new oi("urn:ogc:def:crs:OGC:1.3:CRS84"),new oi("urn:ogc:def:crs:OGC:2:84"),new oi("http://www.opengis.net/def/crs/OGC/1.3/CRS84"),new oi("http://www.opengis.net/gml/srs/epsg.xml#4326","neu"),new oi("http://www.opengis.net/def/crs/EPSG/0/4326","neu")];var La={};function Eu(n){return La[n]||La[n.replace(/urn:(x-)?ogc:def:crs:EPSG:(.*:)?(\w+)$/,"EPSG:$3")]||null}function wu(n,t){La[n]=t}function ze(n){for(let t in n)delete n[t]}function xe(n){let t;for(t in n)return!1;return!t}var Dn={};function kn(n,t,e){let i=n.getCode(),r=t.getCode();i in Dn||(Dn[i]={}),Dn[i][r]=e}function zs(n,t){return n in Dn&&t in Dn[n]?Dn[n][t]:null}var Gs=.9996,le=.00669438,Ws=le*le,Us=Ws*le,on=le/(1-le),Cu=Math.sqrt(1-le),Fn=(1-Cu)/(1+Cu),Tu=Fn*Fn,Aa=Tu*Fn,Ma=Aa*Fn,Iu=Ma*Fn,bu=1-le/4-3*Ws/64-5*Us/256,Um=3*le/8+3*Ws/32+45*Us/1024,Ym=15*Ws/256+45*Us/1024,Vm=35*Us/3072,Zm=3/2*Fn-27/32*Aa+269/512*Iu,Km=21/16*Tu-55/32*Ma,Bm=151/96*Aa-417/128*Iu,jm=1097/512*Ma,Xs=6378137;function Hm(n,t,e){let i=n-5e5,o=(e.north?t:t-1e7)/Gs/(Xs*bu),a=o+Zm*Math.sin(2*o)+Km*Math.sin(4*o)+Bm*Math.sin(6*o)+jm*Math.sin(8*o),l=Math.sin(a),h=l*l,c=Math.cos(a),d=l/c,f=d*d,g=f*f,m=1-le*h,_=Math.sqrt(1-le*h),p=Xs/_,y=(1-le)/m,E=on*c**2,C=E*E,x=i/(p*Gs),w=x*x,T=w*x,A=T*x,R=A*x,I=R*x,b=a-d/y*(w/2-A/24*(5+3*f+10*E-4*C-9*on))+I/720*(61+90*f+298*E+45*g-252*on-3*C),N=(x-T/6*(1+2*f+E)+R/120*(5-2*E+28*f-3*C+8*on+24*g))/c;return N=ks(N+ye(Lu(e.number)),-Math.PI,Math.PI),[Ds(N),Ds(b)]}var vu=-80,Su=84,qm=-180,$m=180;function Jm(n,t,e){n=ks(n,qm,$m),t<vu?t=vu:t>Su&&(t=Su);let i=ye(t),r=Math.sin(i),s=Math.cos(i),o=r/s,a=o*o,l=a*a,h=ye(n),c=Lu(e.number),d=ye(c),f=Xs/Math.sqrt(1-le*r**2),g=on*s**2,m=s*ks(h-d,-Math.PI,Math.PI),_=m*m,p=_*m,y=p*m,E=y*m,C=E*m,x=Xs*(bu*i-Um*Math.sin(2*i)+Ym*Math.sin(4*i)-Vm*Math.sin(6*i)),w=Gs*f*(m+p/6*(1-a+g)+E/120*(5-18*a+l+72*g-58*on))+5e5,T=Gs*(x+f*o*(_/2+y/24*(5-a+9*g+4*g**2)+C/720*(61-58*a+l+600*g-330*on)));return e.north||(T+=1e7),[w,T]}function Lu(n){return(n-1)*6-180+3}var Qm=[/^EPSG:(\d+)$/,/^urn:ogc:def:crs:EPSG::(\d+)$/,/^http:\/\/www\.opengis\.net\/def\/crs\/EPSG\/0\/(\d+)$/];function Au(n){let t=0;for(let r of Qm){let s=n.match(r);if(s){t=parseInt(s[1]);break}}if(!t)return null;let e=0,i=!1;return t>32700&&t<32761?e=t-32700:t>32600&&t<32661&&(i=!0,e=t-32600),e?{number:e,north:i}:null}function Ru(n,t){return function(e,i,r,s){let o=e.length;r=r>1?r:2,s=s??r,i||(r>2?i=e.slice():i=new Array(o));for(let a=0;a<o;a+=s){let l=e[a],h=e[a+1],c=n(l,h,t);i[a]=c[0],i[a+1]=c[1]}return i}}function Mu(n){return Au(n)?new bi({code:n,units:"m"}):null}function Pu(n){let t=Au(n.getCode());return t?{forward:Ru(Jm,t),inverse:Ru(Hm,t)}:null}var tp=63710088e-1;function Pa(n,t,e){e=e||tp;let i=ye(n[1]),r=ye(t[1]),s=(r-i)/2,o=ye(t[0]-n[0])/2,a=Math.sin(s)*Math.sin(s)+Math.sin(o)*Math.sin(o)*Math.cos(i)*Math.cos(r);return 2*e*Math.atan2(Math.sqrt(a),Math.sqrt(1-a))}var ep=[Pu],ip=[Mu];var Da=!0;function Du(n){Da=!(n===void 0?!0:n)}function Fa(n,t){if(t!==void 0){for(let e=0,i=n.length;e<i;++e)t[e]=n[e];t=t}else t=n.slice();return t}function ka(n){wu(n.getCode(),n),kn(n,n,Fa)}function np(n){n.forEach(ka)}function Et(n){if(typeof n!="string")return n;let t=Eu(n);if(t)return t;for(let e of ip){let i=e(n);if(i)return i}return null}function Na(n,t,e,i){n=Et(n);let r,s=n.getPointResolutionFunc();if(s){if(r=s(t,e),i&&i!==n.getUnits()){let o=n.getMetersPerUnit();o&&(r=r*o/si[i])}}else{let o=n.getUnits();if(o=="degrees"&&!i||i=="degrees")r=t;else{let a=an(n,Et("EPSG:4326"));if(!a&&o!=="degrees")r=t*n.getMetersPerUnit();else{let h=[e[0]-t/2,e[1],e[0]+t/2,e[1],e[0],e[1]-t/2,e[0],e[1]+t/2];h=a(h,h,2);let c=Pa(h.slice(0,2),h.slice(2,4)),d=Pa(h.slice(4,6),h.slice(6,8));r=(c+d)/2}let l=i?si[i]:n.getMetersPerUnit();l!==void 0&&(r/=l)}}return r}function Ou(n){np(n),n.forEach(function(t){n.forEach(function(e){t!==e&&kn(t,e,Fa)})})}function rp(n,t,e,i){n.forEach(function(r){t.forEach(function(s){kn(r,s,e),kn(s,r,i)})})}function Ys(n,t){return n?typeof n=="string"?Et(n):n:Et(t)}function ku(n){return(function(t,e,i,r){let s=t.length;i=i!==void 0?i:2,r=r??i,e=e!==void 0?e:new Array(s);for(let o=0;o<s;o+=r){let a=n(t.slice(o,o+i)),l=a.length;for(let h=0,c=r;h<c;++h)e[o+h]=h>=l?t[o+h]:a[h]}return e})}function Nn(n,t){if(n===t)return!0;let e=n.getUnits()===t.getUnits();return(n.getCode()===t.getCode()||an(n,t)===Fa)&&e}function an(n,t){let e=n.getCode(),i=t.getCode(),r=zs(e,i);if(r)return r;let s=null,o=null;for(let l of ep)s||(s=l(n)),o||(o=l(t));if(!s&&!o)return null;let a="EPSG:4326";if(o)if(s)r=Oa(s.inverse,o.forward);else{let l=zs(e,a);l&&(r=Oa(l,o.forward))}else{let l=zs(a,i);l&&(r=Oa(s.inverse,l))}return r&&(ka(n),ka(t),kn(n,t,r)),r}function Oa(n,t){return function(e,i,r,s){return i=n(e,i,r,s),t(i,i,r,s)}}function ln(n,t){let e=Et(n),i=Et(t);return an(e,i)}function zn(n,t,e){let i=ln(t,e);if(!i){let r=Et(t).getCode(),s=Et(e).getCode();throw new Error(`No transform available between ${r} and ${s}`)}return i(n,void 0,n.length)}function Fu(n,t,e,i){let r=ln(t,e);return lu(n,r,void 0,i)}var Ee=null;function cn(){return Ee}function Mr(n,t){return Ee?zn(n,t,Ee):n}function we(n,t){return Ee?zn(n,Ee,t):(Da&&!sn(n,[0,0])&&n[0]>=-180&&n[0]<=180&&n[1]>=-90&&n[1]<=90&&(Da=!1,Os("Call useGeographic() from ol/proj once to work with [longitude, latitude] coordinates.")),n)}function Ai(n,t){return Ee?Fu(n,t,Ee):n}function Ce(n,t){return Ee?Fu(n,Ee,t):n}function Nu(n,t){if(!Ee)return n;let e=Et(t).getMetersPerUnit(),i=Ee.getMetersPerUnit();return e&&i?n*e/i:n}function sp(){Ou(Ia),Ou(ba),rp(ba,Ia,_u,yu)}sp();function za(n){return n[0]>0&&n[1]>0}function zu(n,t,e){return e===void 0&&(e=[0,0]),e[0]=n[0]*t+.5|0,e[1]=n[1]*t+.5|0,e}function mt(n,t){return Array.isArray(n)?n:(t===void 0?t=[n,n]:(t[0]=n,t[1]=n),t)}var Vs=class{constructor(t,e,i,r){this.minX=t,this.maxX=e,this.minY=i,this.maxY=r}contains(t){return this.containsXY(t[1],t[2])}containsTileRange(t){return this.minX<=t.minX&&t.maxX<=this.maxX&&this.minY<=t.minY&&t.maxY<=this.maxY}containsXY(t,e){return this.minX<=t&&t<=this.maxX&&this.minY<=e&&e<=this.maxY}equals(t){return this.minX==t.minX&&this.minY==t.minY&&this.maxX==t.maxX&&this.maxY==t.maxY}extend(t){t.minX<this.minX&&(this.minX=t.minX),t.maxX>this.maxX&&(this.maxX=t.maxX),t.minY<this.minY&&(this.minY=t.minY),t.maxY>this.maxY&&(this.maxY=t.maxY)}getHeight(){return this.maxY-this.minY+1}getSize(){return[this.getWidth(),this.getHeight()]}getWidth(){return this.maxX-this.minX+1}intersects(t){return this.minX<=t.maxX&&this.maxX>=t.minX&&this.minY<=t.maxY&&this.maxY>=t.minY}};function hn(n,t,e,i,r){return r!==void 0?(r.minX=n,r.maxX=t,r.minY=e,r.maxY=i,r):new Vs(n,t,e,i)}var Zs=Vs;function Gu(n,t,e){let i,r;e=e||Bt;let s=0,o=n.length,a=!1;for(;s<o;)i=s+(o-s>>1),r=+e(n[i],t),r<0?s=i+1:(o=i,a=!r);return a?s:~s}function Bt(n,t){return n>t?1:n<t?-1:0}function Xu(n,t){return n<t?1:n>t?-1:0}function Gn(n,t,e){if(n[0]<=t)return 0;let i=n.length;if(t<=n[i-1])return i-1;if(typeof e=="function"){for(let r=1;r<i;++r){let s=n[r];if(s===t)return r;if(s<t)return e(t,n[r-1],s)>0?r-1:r}return i-1}if(e>0){for(let r=1;r<i;++r)if(n[r]<t)return r-1;return i-1}if(e<0){for(let r=1;r<i;++r)if(n[r]<=t)return r;return i-1}for(let r=1;r<i;++r){if(n[r]==t)return r;if(n[r]<t)return n[r-1]-t<t-n[r]?r-1:r}return i-1}function Wu(n,t,e){for(;t<e;){let i=n[t];n[t]=n[e],n[e]=i,++t,--e}}function ve(n,t){let e=Array.isArray(t)?t:[t],i=e.length;for(let r=0;r<i;r++)n[n.length]=e[r]}function Gt(n,t){let e=n.length;if(e!==t.length)return!1;for(let i=0;i<e;i++)if(n[i]!==t[i])return!1;return!0}function Uu(n,t,e){let i=t||Bt;return n.every(function(r,s){if(s===0)return!0;let o=i(n[s-1],r);return!(o>0||e&&o===0)})}function K(n,t){if(!n)throw new Error(t)}function Yu(n,t,e,i,r){return!Ms(r,function(o){return!Mi(n,t,e,i,o[0],o[1])})}function Mi(n,t,e,i,r,s){let o=0,a=n[e-i],l=n[e-i+1];for(;t<e;t+=i){let h=n[t],c=n[t+1];l<=s?c>s&&(h-a)*(s-l)-(r-a)*(c-l)>0&&o++:c<=s&&(h-a)*(s-l)-(r-a)*(c-l)<0&&o--,a=h,l=c}return o!==0}function Pr(n,t,e,i,r,s){if(e.length===0||!Mi(n,t,e[0],i,r,s))return!1;for(let o=1,a=e.length;o<a;++o)if(Mi(n,e[o-1],e[o],i,r,s))return!1;return!0}function Vu(n,t,e,i,r,s){if(e.length===0)return!1;for(let o=0,a=e.length;o<a;++o){let l=e[o];if(Pr(n,t,l,i,r,s))return!0;t=l[l.length-1]}return!1}function Zu(n,t,e,i,r){let s;for(t+=i;t<e;t+=i)if(s=r(n.slice(t-i,t),n.slice(t,t+i)),s)return s;return!1}function Ks(n,t,e,i,r,s){return s=s??Ca(ut(),n,t,e,i),ht(r,s)?s[0]>=r[0]&&s[2]<=r[2]||s[1]>=r[1]&&s[3]<=r[3]?!0:Zu(n,t,e,i,function(o,a){return au(r,o,a)}):!1}function Ga(n,t,e,i,r){return!!(Ks(n,t,e,i,r)||Mi(n,t,e,i,r[0],r[1])||Mi(n,t,e,i,r[0],r[3])||Mi(n,t,e,i,r[2],r[1])||Mi(n,t,e,i,r[2],r[3]))}function Xa(n,t,e,i,r){if(!Ga(n,t,e[0],i,r))return!1;if(e.length===1)return!0;for(let s=1,o=e.length;s<o;++s)if(Yu(n,e[s-1],e[s],i,r)&&!Ks(n,e[s-1],e[s],i,r))return!1;return!0}function Ku(n,t,e,i,r){for(let s=0,o=e.length;s<o;++s){let a=e[s];if(Xa(n,t,a,i,r))return!0;t=a[a.length-1]}return!1}function H(){throw new Error("Unimplemented abstract method.")}var op=0;function Y(n){return n.ol_uid||(n.ol_uid=String(++op))}function Xn(n,t,e,i){return i!==void 0?(i[0]=n,i[1]=t,i[2]=e,i):[n,t,e]}function ap(n,t,e){return n+"/"+t+"/"+e}function Wn(n,t,e,i,r){return`${Y(n)},${t},${ap(e,i,r)}`}function Bu(n){return lp(n[0],n[1],n[2])}function lp(n,t,e){return(t<<n)+e}function ju(n,t){let e=n[0],i=n[1],r=n[2];if(t.getMinZoom()>e||e>t.getMaxZoom())return!1;let s=t.getFullTileRange(e);return s?s.containsXY(i,r):!0}var Un=[0,0,0],Pi=5,Wa=class{constructor(t){let e=t.minZoom,i=t.resolutions;e===void 0&&i&&(e=i.findIndex(o=>o!==void 0)),this.minZoom=e!==void 0?e:0,this.resolutions_=i,K(Uu(this.resolutions_,(o,a)=>a-o,!0),"`resolutions` must be sorted in descending order");let r;if(!t.origins){for(let o=0,a=this.resolutions_.length-1;o<a;++o)if(!r)r=this.resolutions_[o]/this.resolutions_[o+1];else if(this.resolutions_[o]/this.resolutions_[o+1]!==r){r=void 0;break}}this.zoomFactor_=r,this.maxZoom=this.resolutions_.length-1,this.origin_=t.origin!==void 0?t.origin:null,this.origins_=null,t.origins!==void 0&&(this.origins_=t.origins,K(this.origins_.length==this.resolutions_.length,"Number of `origins` and `resolutions` must be equal"));let s=t.extent;s!==void 0&&!this.origin_&&!this.origins_&&(this.origin_=ae(s)),K(!this.origin_&&this.origins_||this.origin_&&!this.origins_,"Either `origin` or `origins` must be configured, never both"),this.tileSizes_=null,t.tileSizes!==void 0&&(this.tileSizes_=t.tileSizes,K(this.tileSizes_.length==this.resolutions_.length,"Number of `tileSizes` and `resolutions` must be equal")),this.tileSize_=t.tileSize!==void 0?t.tileSize:this.tileSizes_?null:256,K(!this.tileSize_&&this.tileSizes_||this.tileSize_&&!this.tileSizes_,"Either `tileSize` or `tileSizes` must be configured, never both"),this.extent_=s!==void 0?s:null,this.fullTileRanges_=null,this.tmpSize_=[0,0],this.tmpExtent_=[0,0,0,0],t.tileRanges!==void 0?this.fullTileRanges_=t.tileRanges:t.sizes!==void 0?this.fullTileRanges_=t.sizes.map((o,a)=>{let l=new Zs(Math.min(0,o[0]),Math.max(o[0]-1,-1),Math.min(0,o[1]),Math.max(o[1]-1,-1));if(s){let h=this.getTileRangeForExtentAndZ(s,a);l.minX=Math.max(h.minX,l.minX),l.maxX=Math.min(h.maxX,l.maxX),l.minY=Math.max(h.minY,l.minY),l.maxY=Math.min(h.maxY,l.maxY)}return l}):s&&this.calculateTileRanges_(s)}forEachTileCoord(t,e,i){let r=this.getTileRangeForExtentAndZ(t,e);for(let s=r.minX,o=r.maxX;s<=o;++s)for(let a=r.minY,l=r.maxY;a<=l;++a)i([e,s,a])}forEachTileCoordParentTileRange(t,e,i,r){let s,o,a,l=null,h=t[0]-1;for(this.zoomFactor_===2?(o=t[1],a=t[2]):l=this.getTileCoordExtent(t,r);h>=this.minZoom;){if(o!==void 0&&a!==void 0?(o=Math.floor(o/2),a=Math.floor(a/2),s=hn(o,o,a,a,i)):s=this.getTileRangeForExtentAndZ(l,h,i),e(h,s))return!0;--h}return!1}getExtent(){return this.extent_}getMaxZoom(){return this.maxZoom}getMinZoom(){return this.minZoom}getOrigin(t){return this.origin_?this.origin_:this.origins_[t]}getOrigins(){return this.origins_}getResolution(t){return this.resolutions_[t]}getResolutions(){return this.resolutions_}getTileCoordChildTileRange(t,e,i){if(t[0]<this.maxZoom){if(this.zoomFactor_===2){let s=t[1]*2,o=t[2]*2;return hn(s,s+1,o,o+1,e)}let r=this.getTileCoordExtent(t,i||this.tmpExtent_);return this.getTileRangeForExtentAndZ(r,t[0]+1,e)}return null}getTileRangeForTileCoordAndZ(t,e,i){if(e>this.maxZoom||e<this.minZoom)return null;let r=t[0],s=t[1],o=t[2];if(e===r)return hn(s,o,s,o,i);if(this.zoomFactor_){let l=Math.pow(this.zoomFactor_,e-r),h=Math.floor(s*l),c=Math.floor(o*l);if(e<r)return hn(h,h,c,c,i);let d=Math.floor(l*(s+1))-1,f=Math.floor(l*(o+1))-1;return hn(h,d,c,f,i)}let a=this.getTileCoordExtent(t,this.tmpExtent_);return this.getTileRangeForExtentAndZ(a,e,i)}getTileRangeForExtentAndZ(t,e,i){this.getTileCoordForXYAndZ_(t[0],t[3],e,!1,Un);let r=Un[1],s=Un[2];this.getTileCoordForXYAndZ_(t[2],t[1],e,!0,Un);let o=Un[1],a=Un[2];return hn(r,o,s,a,i)}getTileCoordCenter(t){let e=this.getOrigin(t[0]),i=this.getResolution(t[0]),r=mt(this.getTileSize(t[0]),this.tmpSize_);return[e[0]+(t[1]+.5)*r[0]*i,e[1]-(t[2]+.5)*r[1]*i]}getTileCoordExtent(t,e){let i=this.getOrigin(t[0]),r=this.getResolution(t[0]),s=mt(this.getTileSize(t[0]),this.tmpSize_),o=i[0]+t[1]*s[0]*r,a=i[1]-(t[2]+1)*s[1]*r,l=o+s[0]*r,h=a+s[1]*r;return Qt(o,a,l,h,e)}getTileCoordForCoordAndResolution(t,e,i){return this.getTileCoordForXYAndResolution_(t[0],t[1],e,!1,i)}getTileCoordForXYAndResolution_(t,e,i,r,s){let o=this.getZForResolution(i),a=i/this.getResolution(o),l=this.getOrigin(o),h=mt(this.getTileSize(o),this.tmpSize_),c=a*(t-l[0])/i/h[0],d=a*(l[1]-e)/i/h[1];return r?(c=Lr(c,Pi)-1,d=Lr(d,Pi)-1):(c=br(c,Pi),d=br(d,Pi)),Xn(o,c,d,s)}getTileCoordForXYAndZ_(t,e,i,r,s){let o=this.getOrigin(i),a=this.getResolution(i),l=mt(this.getTileSize(i),this.tmpSize_),h=(t-o[0])/a/l[0],c=(o[1]-e)/a/l[1];return r?(h=Lr(h,Pi)-1,c=Lr(c,Pi)-1):(h=br(h,Pi),c=br(c,Pi)),Xn(i,h,c,s)}getTileCoordForCoordAndZ(t,e,i){return this.getTileCoordForXYAndZ_(t[0],t[1],e,!1,i)}getTileCoordResolution(t){return this.resolutions_[t[0]]}getTileSize(t){return this.tileSize_?this.tileSize_:this.tileSizes_[t]}getFullTileRange(t){return this.fullTileRanges_?this.fullTileRanges_[t]:this.extent_?this.getTileRangeForExtentAndZ(this.extent_,t):null}getZForResolution(t,e){let i=Gn(this.resolutions_,t,e||0);return et(i,this.minZoom,this.maxZoom)}tileCoordIntersectsViewport(t,e){return Ga(e,0,e.length,2,this.getTileCoordExtent(t))}calculateTileRanges_(t){let e=this.resolutions_.length,i=new Array(e);for(let r=this.minZoom;r<e;++r)i[r]=this.getTileRangeForExtentAndZ(t,r);this.fullTileRanges_=i}},Or=Wa;function Bs(n){let t=n.getDefaultTileGrid();return t||(t=hp(n),n.setDefaultTileGrid(t)),t}function qu(n,t,e){let i=t[0],r=n.getTileCoordCenter(t),s=js(e);if(!pe(s,r)){let o=j(s),a=Math.ceil((s[0]-r[0])/o);return r[0]+=o*a,n.getTileCoordForCoordAndZ(r,i)}return t}function cp(n,t,e,i){i=i!==void 0?i:"top-left";let r=Ju(n,t,e);return new Or({extent:n,origin:su(n,i),resolutions:r,tileSize:e})}function $u(n){let t=n||{},e=t.extent||Et("EPSG:3857").getExtent(),i={extent:e,minZoom:t.minZoom,tileSize:t.tileSize,resolutions:Ju(e,t.maxZoom,t.tileSize,t.maxResolution)};return new Or(i)}function Ju(n,t,e,i){t=t!==void 0?t:42,e=mt(e!==void 0?e:256);let r=ct(n),s=j(n);i=i>0?i:Math.max(s/e[0],r/e[1]);let o=t+1,a=new Array(o);for(let l=0;l<o;++l)a[l]=i/Math.pow(2,l);return a}function hp(n,t,e,i){let r=js(n);return cp(r,t,e,i)}function js(n){n=Et(n);let t=n.getExtent();if(!t){let e=180*si.degrees/n.getMetersPerUnit();t=Qt(-e,-e,e,e)}return t}var U={IDLE:0,LOADING:1,LOADED:2,ERROR:3,EMPTY:4};function Z(n,t,e,i,r){if(r){let o=e;e=function(a){return n.removeEventListener(t,e),o.call(i??this,a)}}else i&&i!==n&&(e=e.bind(i));let s={target:n,type:t,listener:e};return n.addEventListener(t,e),s}function Yn(n,t,e,i){return Z(n,t,e,i,!0)}function J(n){n&&n.target&&(n.target.removeEventListener(n.type,n.listener),ze(n))}var P={CHANGE:"change",ERROR:"error",BLUR:"blur",CLEAR:"clear",CONTEXTMENU:"contextmenu",CLICK:"click",DBLCLICK:"dblclick",DRAGENTER:"dragenter",DRAGOVER:"dragover",DROP:"drop",FOCUS:"focus",KEYDOWN:"keydown",KEYPRESS:"keypress",LOAD:"load",RESIZE:"resize",TOUCHMOVE:"touchmove",WHEEL:"wheel"};var Ua=class{constructor(){this.disposed=!1}dispose(){this.disposed||(this.disposed=!0,this.disposeInternal())}disposeInternal(){}},Oi=Ua;function ai(){return!0}function li(){return!1}function ci(){}function Hs(n){let t,e,i;return function(){let r=Array.prototype.slice.call(arguments);return(!e||this!==i||!Gt(r,e))&&(i=this,e=r,t=n.apply(this,arguments)),t}}function Qu(n){function t(){let e;try{e=n()}catch(i){return Promise.reject(i)}return e instanceof Promise?e:Promise.resolve(e)}return t()}var Ya=class{constructor(t){this.propagationStopped,this.defaultPrevented,this.type=t,this.target=null}preventDefault(){this.defaultPrevented=!0}stopPropagation(){this.propagationStopped=!0}};var Lt=Ya;var Va=class extends Oi{constructor(t){super(),this.eventTarget_=t,this.pendingRemovals_=null,this.dispatching_=null,this.listeners_=null}addEventListener(t,e){if(!t||!e)return;let i=this.listeners_||(this.listeners_={}),r=i[t]||(i[t]=[]);r.includes(e)||r.push(e)}dispatchEvent(t){let e=typeof t=="string",i=e?t:t.type,r=this.listeners_&&this.listeners_[i];if(!r)return;let s=e?new Lt(t):t;s.target||(s.target=this.eventTarget_||this);let o=this.dispatching_||(this.dispatching_={}),a=this.pendingRemovals_||(this.pendingRemovals_={});i in o||(o[i]=0,a[i]=0),++o[i];let l;for(let h=0,c=r.length;h<c;++h)if("handleEvent"in r[h]?l=r[h].handleEvent(s):l=r[h].call(this,s),l===!1||s.propagationStopped){l=!1;break}if(--o[i]===0){let h=a[i];for(delete a[i];h--;)this.removeEventListener(i,ci);delete o[i]}return l}disposeInternal(){this.listeners_&&ze(this.listeners_)}getListeners(t){return this.listeners_&&this.listeners_[t]||void 0}hasListener(t){return this.listeners_?t?t in this.listeners_:Object.keys(this.listeners_).length>0:!1}removeEventListener(t,e){if(!this.listeners_)return;let i=this.listeners_[t];if(!i)return;let r=i.indexOf(e);r!==-1&&(this.pendingRemovals_&&t in this.pendingRemovals_?(i[r]=ci,++this.pendingRemovals_[t]):(i.splice(r,1),i.length===0&&delete this.listeners_[t]))}},Di=Va;var un=typeof navigator<"u"&&typeof navigator.userAgent<"u"?navigator.userAgent.toLowerCase():"",up=un.includes("safari")&&!un.includes("chrom"),C0=up&&(un.includes("version/15.4")||/cpu (os|iphone os) 15_4 like mac os x/.test(un)),td=un.includes("webkit")&&!un.includes("edge"),Za=un.includes("macintosh"),ed=typeof devicePixelRatio<"u"?devicePixelRatio:1,Rt=typeof WorkerGlobalScope<"u"&&typeof OffscreenCanvas<"u"&&self instanceof WorkerGlobalScope,Ka=typeof Image<"u"&&Image.prototype.decode;var qs=(function(){let n=!1;try{let t=Object.defineProperty({},"passive",{get:function(){n=!0}});window.addEventListener("_",null,t),window.removeEventListener("_",null,t)}catch{}return n})();function id(n,t,e){let i=n,r=!0,s=!1,o=!1,a=[Yn(i,P.LOAD,function(){o=!0,s||t()})];return i.src&&Ka?(s=!0,i.decode().then(function(){r&&t()}).catch(function(l){r&&(o?t():e())})):a.push(Yn(i,P.ERROR,e)),function(){r=!1,a.forEach(J)}}function dp(n,t){return new Promise((e,i)=>{function r(){o(),e(n)}function s(){o(),i(new Error("Image load error"))}function o(){n.removeEventListener("load",r),n.removeEventListener("error",s)}n.addEventListener("load",r),n.addEventListener("error",s),t&&(n.src=t)})}function nd(n,t){return t&&(n.src=t),n.src&&Ka?new Promise((e,i)=>n.decode().then(()=>e(n)).catch(r=>n.complete&&n.width?e(n):i(r))):dp(n)}var D={IDLE:0,LOADING:1,LOADED:2,ERROR:3,EMPTY:4};function Ba(n){return Math.pow(n,3)}function ce(n){return 1-Ba(1-n)}function rd(n){return 3*n*n-2*n*n*n}function sd(n){return n}var ja=class extends Di{constructor(t,e,i){super(),i=i||{},this.tileCoord=t,this.state=e,this.key="",this.transition_=i.transition===void 0?250:i.transition,this.transitionStarts_={},this.interpolate=!!i.interpolate}changed(){this.dispatchEvent(P.CHANGE)}release(){this.setState(D.EMPTY)}getKey(){return this.key+"/"+this.tileCoord}getTileCoord(){return this.tileCoord}getState(){return this.state}setState(t){if(this.state!==D.EMPTY){if(this.state!==D.ERROR&&this.state>t)throw new Error("Tile load sequence violation");this.state=t,this.changed()}}load(){H()}getAlpha(t,e){if(!this.transition_)return 1;let i=this.transitionStarts_[t];if(!i)i=e,this.transitionStarts_[t]=i;else if(i===-1)return 1;let r=e-i+1e3/60;return r>=this.transition_?1:Ba(r/this.transition_)}inTransition(t){return this.transition_?this.transitionStarts_[t]!==-1:!1}endTransition(t){this.transition_&&(this.transitionStarts_[t]=-1)}disposeInternal(){this.release(),super.disposeInternal()}},Vn=ja;function nt(n,t,e,i){let r;return e&&e.length?r=e.shift():Rt?r=new class extends OffscreenCanvas{style={}}(n??300,t??150):r=document.createElement("canvas"),n&&(r.width=n),t&&(r.height=t),r.getContext("2d",i)}var Ha;function Dr(){return Ha||(Ha=nt(1,1)),Ha}function dn(n){let t=n.canvas;t.width=1,t.height=1,n.clearRect(0,0,1,1)}function qa(n,t){let e=t.parentNode;e&&e.replaceChild(n,t)}function od(n){for(;n.lastChild;)n.lastChild.remove()}function ad(n,t){let e=n.childNodes;for(let i=0;;++i){let r=e[i],s=t[i];if(!r&&!s)break;if(r!==s){if(!r){n.appendChild(s);continue}if(!s){n.removeChild(r),--i;continue}n.insertBefore(s,r)}}}function $s(){return new Proxy({childNodes:[],appendChild:function(t){return this.childNodes.push(t),t},remove:function(){},removeChild:function(t){let e=this.childNodes.indexOf(t);if(e===-1)throw new Error("Node to remove was not found");return this.childNodes.splice(e,1),t},insertBefore:function(t,e){let i=this.childNodes.indexOf(e);if(i===-1)throw new Error("Reference node not found");return this.childNodes.splice(i,0,t),t},style:{}},{get(t,e,i){return e==="firstElementChild"?t.childNodes.length>0?t.childNodes[0]:null:Reflect.get(t,e,i)}})}function te(n){return typeof HTMLCanvasElement<"u"&&n instanceof HTMLCanvasElement||typeof OffscreenCanvas<"u"&&n instanceof OffscreenCanvas}var $a=class extends Vn{constructor(t,e,i,r,s,o){super(t,e,o),this.crossOrigin_=r?.crossOrigin,this.referrerPolicy_=r?.referrerPolicy,this.src_=i,this.key=i,this.image_,Rt?this.image_=new OffscreenCanvas(1,1):(this.image_=new Image,this.crossOrigin_!==null&&(this.image_.crossOrigin=this.crossOrigin_),this.referrerPolicy_!==void 0&&(this.image_.referrerPolicy=this.referrerPolicy_)),this.unlisten_=null,this.tileLoadFunction_=s}getImage(){return this.image_}setImage(t){this.image_=t,this.state=D.LOADED,this.unlistenImage_(),this.changed()}getCrossOrigin(){return this.crossOrigin_}getReferrerPolicy(){return this.referrerPolicy_}handleImageError_(){this.state=D.ERROR,this.unlistenImage_(),this.image_=fp(),this.changed()}handleImageLoad_(){if(Rt)this.state=D.LOADED;else{let t=this.image_;t.naturalWidth&&t.naturalHeight?this.state=D.LOADED:this.state=D.EMPTY}this.unlistenImage_(),this.changed()}load(){this.state==D.ERROR&&(this.state=D.IDLE,this.image_=new Image,this.crossOrigin_!==null&&(this.image_.crossOrigin=this.crossOrigin_),this.referrerPolicy_!==void 0&&(this.image_.referrerPolicy=this.referrerPolicy_)),this.state==D.IDLE&&(this.state=D.LOADING,this.changed(),this.tileLoadFunction_(this,this.src_),this.unlisten_=id(this.image_,this.handleImageLoad_.bind(this),this.handleImageError_.bind(this)))}unlistenImage_(){this.unlisten_&&(this.unlisten_(),this.unlisten_=null)}disposeInternal(){this.unlistenImage_(),this.image_=null,super.disposeInternal()}};function fp(){let n=nt(1,1);return n.fillStyle="rgba(0,0,0,0)",n.fillRect(0,0,1,1),n.canvas}var Js=$a;var Ja,fn=[];function ld(n,t,e,i,r){n.beginPath(),n.moveTo(0,0),n.lineTo(t,e),n.lineTo(i,r),n.closePath(),n.save(),n.clip(),n.fillRect(0,0,Math.max(t,i)+1,Math.max(e,r)),n.restore()}function Qa(n,t){return Math.abs(n[t*4]-210)>2||Math.abs(n[t*4+3]-.75*255)>2}function gp(){if(Ja===void 0){let n=nt(6,6,fn);n.globalCompositeOperation="lighter",n.fillStyle="rgba(210, 0, 0, 0.75)",ld(n,4,5,4,0),ld(n,4,5,0,5);let t=n.getImageData(0,0,3,3).data;Ja=Qa(t,0)||Qa(t,4)||Qa(t,8),dn(n),fn.push(n.canvas)}return Ja}function cd(n,t,e,i){let r=zn(e,t,n),s=Na(t,i,e),o=t.getMetersPerUnit();o!==void 0&&(s*=o);let a=n.getMetersPerUnit();a!==void 0&&(s/=a);let l=n.getExtent();if(!l||pe(l,r)){let h=Na(n,s,r)/s;isFinite(h)&&h>0&&(s/=h)}return s}function hd(n,t,e,i){let r=Kt(e),s=cd(n,t,r,i);return(!isFinite(s)||s<=0)&&Ms(e,function(o){return s=cd(n,t,o,i),isFinite(s)&&s>0}),s}function ud(n,t,e,i,r,s,o,a,l,h,c,d,f,g){let m=nt(Math.round(e*n),Math.round(e*t),fn);if(d||(m.imageSmoothingEnabled=!1),l.length===0)return m.canvas;m.scale(e,e);function _(w){return Math.round(w*e)/e}m.globalCompositeOperation="lighter";let p=ut();l.forEach(function(w,T,A){As(p,w.extent)});let y,E=e/i,C=(d?1:1+Math.pow(2,-24))/E;if(!f||l.length!==1||h!==0){if(y=nt(Math.round(j(p)*E),Math.round(ct(p)*E),fn),d||(y.imageSmoothingEnabled=!1),r&&g){let w=(r[0]-p[0])*E,T=-(r[3]-p[3])*E,A=j(r)*E,R=ct(r)*E;y.rect(w,T,A,R),y.clip()}l.forEach(function(w,T,A){if(w.image.width>0&&w.image.height>0){if(w.clipExtent){y.save();let G=(w.clipExtent[0]-p[0])*E,F=-(w.clipExtent[3]-p[3])*E,B=j(w.clipExtent)*E,lt=ct(w.clipExtent)*E;y.rect(d?G:Math.round(G),d?F:Math.round(F),d?B:Math.round(G+B)-Math.round(G),d?lt:Math.round(F+lt)-Math.round(F)),y.clip()}let R=(w.extent[0]-p[0])*E,I=-(w.extent[3]-p[3])*E,b=j(w.extent)*E,N=ct(w.extent)*E;y.drawImage(w.image,h,h,w.image.width-2*h,w.image.height-2*h,d?R:Math.round(R),d?I:Math.round(I),d?b:Math.round(R+b)-Math.round(R),d?N:Math.round(I+N)-Math.round(I)),w.clipExtent&&y.restore()}})}let x=ae(o);return a.getTriangles().forEach(function(w,T,A){let R=w.source,I=w.target,b=R[0][0],N=R[0][1],G=R[1][0],F=R[1][1],B=R[2][0],lt=R[2][1],M=_((I[0][0]-x[0])/s),X=_(-(I[0][1]-x[1])/s),O=_((I[1][0]-x[0])/s),$=_(-(I[1][1]-x[1])/s),z=_((I[2][0]-x[0])/s),tt=_(-(I[2][1]-x[1])/s),it=b,Ct=N;b=0,N=0,G-=it,F-=Ct,B-=it,lt-=Ct;let L=[[G,F,0,0,O-M],[B,lt,0,0,z-M],[0,0,G,F,$-X],[0,0,B,lt,tt-X]],Jt=du(L);if(!Jt)return;if(m.save(),m.beginPath(),gp()||!d){m.moveTo(O,$);let ot=4,Me=M-O,Hi=X-$;for(let re=0;re<ot;re++)m.lineTo(O+_((re+1)*Me/ot),$+_(re*Hi/(ot-1))),re!=ot-1&&m.lineTo(O+_((re+1)*Me/ot),$+_((re+1)*Hi/(ot-1)));m.lineTo(z,tt)}else m.moveTo(O,$),m.lineTo(M,X),m.lineTo(z,tt);m.clip(),m.transform(Jt[0],Jt[2],Jt[1],Jt[3],M,X),m.translate(p[0]-it,p[3]-Ct);let vt;if(y)vt=y.canvas,m.scale(C,-C);else{let ot=l[0],Me=ot.extent;vt=ot.image,m.scale(j(Me)/vt.width,-ct(Me)/vt.height)}m.drawImage(vt,0,0),m.restore()}),y&&(dn(y),fn.push(y.canvas)),c&&(m.save(),m.globalCompositeOperation="source-over",m.strokeStyle="black",m.lineWidth=1,a.getTriangles().forEach(function(w,T,A){let R=w.target,I=(R[0][0]-x[0])/s,b=-(R[0][1]-x[1])/s,N=(R[1][0]-x[0])/s,G=-(R[1][1]-x[1])/s,F=(R[2][0]-x[0])/s,B=-(R[2][1]-x[1])/s;m.beginPath(),m.moveTo(N,G),m.lineTo(I,b),m.lineTo(F,B),m.closePath(),m.stroke()}),m.restore()),m.canvas}var mp=[1,0,0,1,0,0],J0=new Array(6);function At(){return mp.slice(0)}function dd(n,t){return n[0]=t[0],n[1]=t[1],n[2]=t[2],n[3]=t[3],n[4]=t[4],n[5]=t[5],n}function dt(n,t){let e=t[0],i=t[1];return t[0]=n[0]*e+n[2]*i+n[4],t[1]=n[1]*e+n[3]*i+n[5],t}function Ot(n,t,e,i,r,s,o,a){let l=Math.sin(s),h=Math.cos(s);return n[0]=i*h,n[1]=r*l,n[2]=-i*l,n[3]=r*h,n[4]=o*i*h-a*i*l+t,n[5]=o*r*l+a*r*h+e,n}function to(n,t){let e=pp(t);K(e!==0,"Transformation matrix cannot be inverted");let i=t[0],r=t[1],s=t[2],o=t[3],a=t[4],l=t[5];return n[0]=o/e,n[1]=-r/e,n[2]=-s/e,n[3]=i/e,n[4]=(s*l-o*a)/e,n[5]=-(i*l-r*a)/e,n}function pp(n){return n[0]*n[3]-n[1]*n[2]}var _p=[1e5,1e5,1e5,1e5,2,2];function fd(n){return"matrix("+n.join(", ")+")"}function Qs(n){return n.substring(7,n.length-1).split(",").map(parseFloat)}function gd(n,t){let e=Qs(n),i=Qs(t);for(let r=0;r<6;++r)if(Math.round((e[r]-i[r])*_p[r])!==0)return!1;return!0}var yp=10,md=.25,tl=class{constructor(t,e,i,r,s,o,a){this.sourceProj_=t,this.targetProj_=e;let l={},h=a?ku(C=>dt(a,zn(C,this.targetProj_,this.sourceProj_))):ln(this.targetProj_,this.sourceProj_);this.transformInv_=function(C){let x=C[0]+"/"+C[1];return l[x]||(l[x]=h(C)),l[x]},this.maxSourceExtent_=r,this.errorThresholdSquared_=s*s,this.triangles_=[],this.wrapsXInSource_=!1,this.canWrapXInSource_=this.sourceProj_.canWrapX()&&!!r&&!!this.sourceProj_.getExtent()&&j(r)>=j(this.sourceProj_.getExtent()),this.sourceWorldWidth_=this.sourceProj_.getExtent()?j(this.sourceProj_.getExtent()):null,this.targetWorldWidth_=this.targetProj_.getExtent()?j(this.targetProj_.getExtent()):null;let c=ae(i),d=Mn(i),f=An(i),g=Ln(i),m=this.transformInv_(c),_=this.transformInv_(d),p=this.transformInv_(f),y=this.transformInv_(g),E=yp+(o?Math.max(0,Math.ceil(Math.log2(Tr(i)/(o*o*256*256)))):0);if(this.addQuad_(c,d,f,g,m,_,p,y,E),this.wrapsXInSource_){let C=1/0;this.triangles_.forEach(function(x,w,T){C=Math.min(C,x.source[0][0],x.source[1][0],x.source[2][0])}),this.triangles_.forEach(x=>{if(Math.max(x.source[0][0],x.source[1][0],x.source[2][0])-C>this.sourceWorldWidth_/2){let w=[[x.source[0][0],x.source[0][1]],[x.source[1][0],x.source[1][1]],[x.source[2][0],x.source[2][1]]];w[0][0]-C>this.sourceWorldWidth_/2&&(w[0][0]-=this.sourceWorldWidth_),w[1][0]-C>this.sourceWorldWidth_/2&&(w[1][0]-=this.sourceWorldWidth_),w[2][0]-C>this.sourceWorldWidth_/2&&(w[2][0]-=this.sourceWorldWidth_);let T=Math.min(w[0][0],w[1][0],w[2][0]);Math.max(w[0][0],w[1][0],w[2][0])-T<this.sourceWorldWidth_/2&&(x.source=w)}})}l={}}addTriangle_(t,e,i,r,s,o){this.triangles_.push({source:[r,s,o],target:[t,e,i]})}addQuad_(t,e,i,r,s,o,a,l,h){let c=wa([s,o,a,l]),d=this.sourceWorldWidth_?j(c)/this.sourceWorldWidth_:null,f=this.sourceWorldWidth_,g=this.sourceProj_.canWrapX()&&d>.5&&d<1,m=!1;if(h>0){if(this.targetProj_.isGlobal()&&this.targetWorldWidth_){let p=wa([t,e,i,r]);m=j(p)/this.targetWorldWidth_>md||m}!g&&this.sourceProj_.isGlobal()&&d&&(m=d>md||m)}if(!m&&this.maxSourceExtent_&&isFinite(c[0])&&isFinite(c[1])&&isFinite(c[2])&&isFinite(c[3])&&!ht(c,this.maxSourceExtent_))return;let _=0;if(!m&&(!isFinite(s[0])||!isFinite(s[1])||!isFinite(o[0])||!isFinite(o[1])||!isFinite(a[0])||!isFinite(a[1])||!isFinite(l[0])||!isFinite(l[1]))){if(h>0)m=!0;else if(_=(!isFinite(s[0])||!isFinite(s[1])?8:0)+(!isFinite(o[0])||!isFinite(o[1])?4:0)+(!isFinite(a[0])||!isFinite(a[1])?2:0)+(!isFinite(l[0])||!isFinite(l[1])?1:0),_!=1&&_!=2&&_!=4&&_!=8)return}if(h>0){if(!m){let p=[(t[0]+i[0])/2,(t[1]+i[1])/2],y=this.transformInv_(p),E;g?E=(Ne(s[0],f)+Ne(a[0],f))/2-Ne(y[0],f):E=(s[0]+a[0])/2-y[0];let C=(s[1]+a[1])/2-y[1];m=E*E+C*C>this.errorThresholdSquared_}if(m){if(Math.abs(t[0]-i[0])<=Math.abs(t[1]-i[1])){let p=[(e[0]+i[0])/2,(e[1]+i[1])/2],y=this.transformInv_(p),E=[(r[0]+t[0])/2,(r[1]+t[1])/2],C=this.transformInv_(E);this.addQuad_(t,e,p,E,s,o,y,C,h-1),this.addQuad_(E,p,i,r,C,y,a,l,h-1)}else{let p=[(t[0]+e[0])/2,(t[1]+e[1])/2],y=this.transformInv_(p),E=[(i[0]+r[0])/2,(i[1]+r[1])/2],C=this.transformInv_(E);this.addQuad_(t,p,E,r,s,y,C,l,h-1),this.addQuad_(p,e,i,E,y,o,a,C,h-1)}return}}if(g){if(!this.canWrapXInSource_)return;this.wrapsXInSource_=!0}(_&11)==0&&this.addTriangle_(t,i,r,s,a,l),(_&14)==0&&this.addTriangle_(t,i,e,s,a,o),_&&((_&13)==0&&this.addTriangle_(e,r,t,o,l,s),(_&7)==0&&this.addTriangle_(e,r,i,o,l,a))}calculateSourceExtent(){let t=ut();return this.triangles_.forEach(function(e,i,r){let s=e.source;nn(t,s[0]),nn(t,s[1]),nn(t,s[2])}),t}getTriangles(){return this.triangles_}},pd=tl;var el=class extends Vn{constructor(t,e,i,r,s,o,a,l,h,c,d,f){super(s,D.IDLE,f),this.renderEdges_=d!==void 0?d:!1,this.pixelRatio_=a,this.gutter_=l,this.canvas_=null,this.sourceTileGrid_=e,this.targetTileGrid_=r,this.wrappedTileCoord_=o||s,this.sourceTiles_=[],this.sourcesListenerKeys_=null,this.sourceZ_=0,this.clipExtent_=t.canWrapX()?t.getExtent():void 0;let g=r.getTileCoordExtent(this.wrappedTileCoord_),m=this.targetTileGrid_.getExtent(),_=this.sourceTileGrid_.getExtent(),p=m?ke(g,m):g;if(Tr(p)===0){this.state=D.EMPTY;return}let y=t.getExtent();y&&(_?_=ke(_,y):_=y);let E=r.getResolution(this.wrappedTileCoord_[0]),C=hd(t,i,p,E);if(!isFinite(C)||C<=0){this.state=D.EMPTY;return}let x=c!==void 0?c:.5;if(this.triangulation_=new pd(t,i,p,_,C*x,E),this.triangulation_.getTriangles().length===0){this.state=D.EMPTY;return}this.sourceZ_=e.getZForResolution(C);let w=this.triangulation_.calculateSourceExtent();if(_&&(t.canWrapX()?(w[1]=et(w[1],_[1],_[3]),w[3]=et(w[3],_[1],_[3])):w=ke(w,_)),!Tr(w))this.state=D.EMPTY;else{let T=0,A=0;t.canWrapX()&&(T=j(y),A=Math.floor((w[0]-y[0])/T)),Ps(w.slice(),t,!0).forEach(I=>{let b=e.getTileRangeForExtentAndZ(I,this.sourceZ_);for(let N=b.minX;N<=b.maxX;N++)for(let G=b.minY;G<=b.maxY;G++){let F=A*T;this.sourceTiles_.push({getTile:()=>h(this.sourceZ_,N,G,a),offset:F})}++A}),this.sourceTiles_.length===0&&(this.state=D.EMPTY)}}getImage(){return this.canvas_}reproject_(){let t=[];if(this.sourceTiles_.forEach(e=>{let i=e.tile;if(i&&i.getState()==D.LOADED){let r=this.sourceTileGrid_.getTileCoordExtent(i.tileCoord);r[0]+=e.offset,r[2]+=e.offset;let s=this.clipExtent_?.slice();s&&(s[0]+=e.offset,s[2]+=e.offset),t.push({extent:r,clipExtent:s,image:i.getImage()})}}),this.sourceTiles_.length=0,t.length===0)this.state=D.ERROR;else{let e=this.wrappedTileCoord_[0],i=this.targetTileGrid_.getTileSize(e),r=typeof i=="number"?i:i[0],s=typeof i=="number"?i:i[1],o=this.targetTileGrid_.getResolution(e),a=this.sourceTileGrid_.getResolution(this.sourceZ_),l=this.targetTileGrid_.getTileCoordExtent(this.wrappedTileCoord_);this.canvas_=ud(r,s,this.pixelRatio_,a,this.sourceTileGrid_.getExtent(),o,l,this.triangulation_,t,this.gutter_,this.renderEdges_,this.interpolate),this.state=D.LOADED}this.changed()}load(){for(let t of this.sourceTiles_)t.tile=t.getTile();if(this.state==D.IDLE){this.state=D.LOADING,this.changed();let t=0;this.sourcesListenerKeys_=[],this.sourceTiles_.forEach(({tile:e})=>{let i=e.getState();if(i==D.IDLE||i==D.LOADING){t++;let r=Z(e,P.CHANGE,s=>{let o=e.getState();(o==D.LOADED||o==D.ERROR||o==D.EMPTY)&&(J(r),t--,t===0&&(this.unlistenSources_(),this.reproject_()))});this.sourcesListenerKeys_.push(r)}}),t===0?setTimeout(this.reproject_.bind(this),0):this.sourceTiles_.forEach(function({tile:e},i,r){e.getState()==D.IDLE&&e.load()})}}unlistenSources_(){this.sourcesListenerKeys_.forEach(J),this.sourcesListenerKeys_=null}release(){this.canvas_&&(dn(this.canvas_.getContext("2d")),fn.push(this.canvas_),this.canvas_=null),this.sourceTiles_.length=0,super.release()}},eo=el;var xp=/\{z\}/g,Ep=/\{x\}/g,wp=/\{y\}/g,Cp=/\{-y\}/g;function _d(n,t,e,i,r){return n.replace(xp,t.toString()).replace(Ep,e.toString()).replace(wp,i.toString()).replace(Cp,function(){if(r===void 0)throw new Error("If the URL template has a {-y} placeholder, the grid extent must be known");return(r-i).toString()})}function yd(n){let t=[],e=/\{([a-z])-([a-z])\}/.exec(n);if(e){let i=e[1].charCodeAt(0),r=e[2].charCodeAt(0),s;for(s=i;s<=r;++s)t.push(n.replace(e[0],String.fromCharCode(s)));return t}if(e=/\{(\d+)-(\d+)\}/.exec(n),e){let i=parseInt(e[2],10);for(let r=parseInt(e[1],10);r<=i;r++)t.push(n.replace(e[0],r.toString()));return t}return t.push(n),t}function vp(n,t){return(function(e,i,r){if(!e)return;let s,o=e[0];if(t){let a=t.getFullTileRange(o);a&&(s=a.getHeight()-1)}return _d(n,o,e[1],e[2],s)})}function xd(n,t){let e=n.length,i=new Array(e);for(let r=0;r<e;++r)i[r]=vp(n[r],t);return Sp(i)}function Sp(n){return n.length===1?n[0]:(function(t,e,i){if(!t)return;let r=Bu(t),s=Ne(r,n.length);return n[s](t,e,i)})}var Se={PROPERTYCHANGE:"propertychange"};var Zn=class extends Di{constructor(){super(),this.on=this.onInternal,this.once=this.onceInternal,this.un=this.unInternal,this.revision_=0}changed(){++this.revision_,this.dispatchEvent(P.CHANGE)}getRevision(){return this.revision_}onInternal(t,e){if(Array.isArray(t)){let i=t.length,r=new Array(i);for(let s=0;s<i;++s)r[s]=Z(this,t[s],e);return r}return Z(this,t,e)}onceInternal(t,e){let i;if(Array.isArray(t)){let r=t.length;i=new Array(r);for(let s=0;s<r;++s)i[s]=Yn(this,t[s],e)}else i=Yn(this,t,e);return e.ol_key=i,i}unInternal(t,e){let i=e.ol_key;if(i)Rp(i);else if(Array.isArray(t))for(let r=0,s=t.length;r<s;++r)this.removeEventListener(t[r],e);else this.removeEventListener(t,e)}};Zn.prototype.on;Zn.prototype.once;Zn.prototype.un;function Rp(n){if(Array.isArray(n))for(let t=0,e=n.length;t<e;++t)J(n[t]);else J(n)}var io=Zn;var no=class extends Lt{constructor(t,e,i){super(t),this.key=e,this.oldValue=i}},il=class extends io{constructor(t){super(),this.on,this.once,this.un,Y(this),this.values_=null,t!==void 0&&this.setProperties(t)}get(t){let e;return this.values_&&this.values_.hasOwnProperty(t)&&(e=this.values_[t]),e}getKeys(){return this.values_&&Object.keys(this.values_)||[]}getProperties(){return this.values_&&Object.assign({},this.values_)||{}}getPropertiesInternal(){return this.values_}hasProperties(){return!!this.values_}notify(t,e){let i;i=`change:${t}`,this.hasListener(i)&&this.dispatchEvent(new no(i,t,e)),i=Se.PROPERTYCHANGE,this.hasListener(i)&&this.dispatchEvent(new no(i,t,e))}addChangeListener(t,e){this.addEventListener(`change:${t}`,e)}removeChangeListener(t,e){this.removeEventListener(`change:${t}`,e)}set(t,e,i){let r=this.values_||(this.values_={});if(i)r[t]=e;else{let s=r[t];r[t]=e,s!==e&&this.notify(t,s)}}setProperties(t,e){for(let i in t)this.set(i,t[i],e)}applyProperties(t){t.values_&&Object.assign(this.values_||(this.values_={}),t.values_)}unset(t,e){if(this.values_&&t in this.values_){let i=this.values_[t];delete this.values_[t],xe(this.values_)&&(this.values_=null),e||this.notify(t,i)}}},wt=il;var nl=class extends wt{constructor(t){super(),this.projection=Et(t.projection),this.attributions_=Ed(t.attributions),this.attributionsCollapsible_=t.attributionsCollapsible??!0,this.loading=!1,this.state_=t.state!==void 0?t.state:"ready",this.wrapX_=t.wrapX!==void 0?t.wrapX:!1,this.interpolate_=!!t.interpolate,this.viewResolver=null,this.viewRejector=null;let e=this;this.viewPromise_=new Promise(function(i,r){e.viewResolver=i,e.viewRejector=r})}getAttributions(){return this.attributions_}getAttributionsCollapsible(){return this.attributionsCollapsible_}getProjection(){return this.projection}getResolutions(t){return null}getView(){return this.viewPromise_}ready(){let t=this.getState();return t==="ready"?Promise.resolve():t==="error"?Promise.reject(new Error("Source failed to load")):new Promise((e,i)=>{let r=()=>{let s=this.getState();s==="ready"?(this.un("change",r),e()):s==="error"&&(this.un("change",r),i(new Error("Source failed to load")))};this.on("change",r)})}getState(){return this.state_}getWrapX(){return this.wrapX_}getInterpolate(){return this.interpolate_}refresh(){this.changed()}setAttributions(t){this.attributions_=Ed(t),this.changed()}setState(t){this.state_=t,this.changed()}};function Ed(n){return n?typeof n=="function"?n:(Array.isArray(n)||(n=[n]),t=>n):null}var ro=nl;var rl=class extends ro{constructor(t){super({attributions:t.attributions,attributionsCollapsible:t.attributionsCollapsible,projection:t.projection,state:t.state,wrapX:t.wrapX,interpolate:t.interpolate}),this.on,this.once,this.un,this.tilePixelRatio_=t.tilePixelRatio!==void 0?t.tilePixelRatio:1,this.tileGrid=t.tileGrid!==void 0?t.tileGrid:null;let e=[256,256];this.tileGrid&&mt(this.tileGrid.getTileSize(this.tileGrid.getMinZoom()),e),this.tmpSize=[0,0],this.key_=t.key||Y(this),this.tileOptions={transition:t.transition,interpolate:t.interpolate},this.zDirection=t.zDirection?t.zDirection:0}getGutterForProjection(t){return 0}getKey(){return this.key_}setKey(t){this.key_!==t&&(this.key_=t,this.changed())}getResolutions(t){let e=t?this.getTileGridForProjection(t):this.tileGrid;return e?e.getResolutions():null}getTile(t,e,i,r,s,o){return H()}getTileGrid(){return this.tileGrid}getTileGridForProjection(t){return this.tileGrid?this.tileGrid:Bs(t)}getTilePixelRatio(t){return this.tilePixelRatio_}getTilePixelSize(t,e,i){let r=this.getTileGridForProjection(i),s=this.getTilePixelRatio(e),o=mt(r.getTileSize(t),this.tmpSize);return s==1?o:zu(o,s,this.tmpSize)}getTileCoordForTileUrlFunction(t,e){let i=e!==void 0?e:this.getProjection(),r=e!==void 0?this.getTileGridForProjection(i):this.tileGrid||this.getTileGridForProjection(i);return this.getWrapX()&&i.isGlobal()&&(t=qu(r,t,i)),ju(t,r)?t:null}clear(){}refresh(){this.clear(),super.refresh()}},so=class extends Lt{constructor(t,e){super(t),this.tile=e}},wd=rl;var oo={TILELOADSTART:"tileloadstart",TILELOADEND:"tileloadend",TILELOADERROR:"tileloaderror"};var sl=class n extends wd{constructor(t){super({attributions:t.attributions,cacheSize:t.cacheSize,projection:t.projection,state:t.state,tileGrid:t.tileGrid,tilePixelRatio:t.tilePixelRatio,wrapX:t.wrapX,transition:t.transition,interpolate:t.interpolate,key:t.key,attributionsCollapsible:t.attributionsCollapsible,zDirection:t.zDirection}),this.generateTileUrlFunction_=this.tileUrlFunction===n.prototype.tileUrlFunction,this.tileLoadFunction=t.tileLoadFunction,t.tileUrlFunction&&(this.tileUrlFunction=t.tileUrlFunction),this.urls=null,t.urls?this.setUrls(t.urls):t.url&&this.setUrl(t.url),this.tileLoadingKeys_={}}getTileLoadFunction(){return this.tileLoadFunction}getTileUrlFunction(){return Object.getPrototypeOf(this).tileUrlFunction===this.tileUrlFunction?this.tileUrlFunction.bind(this):this.tileUrlFunction}getUrls(){return this.urls}handleTileChange(t){let e=t.target,i=Y(e),r=e.getState(),s;r==D.LOADING?(this.tileLoadingKeys_[i]=!0,s=oo.TILELOADSTART):i in this.tileLoadingKeys_&&(delete this.tileLoadingKeys_[i],s=r==D.ERROR?oo.TILELOADERROR:r==D.LOADED?oo.TILELOADEND:void 0),s!=null&&this.dispatchEvent(new so(s,e))}setTileLoadFunction(t){this.tileLoadFunction=t,this.changed()}setTileUrlFunction(t,e){this.tileUrlFunction=t,typeof e<"u"?this.setKey(e):this.changed()}setUrl(t){let e=yd(t);this.urls=e,this.setUrls(e)}setUrls(t){this.urls=t;let e=t.join(`2+`);this.generateTileUrlFunction_?this.setTileUrlFunction(xd(t,this.tileGrid),e):this.setKey(e)}tileUrlFunction(t,e,i){}},Cd=sl;var ol=class extends Cd{constructor(t){super({attributions:t.attributions,cacheSize:t.cacheSize,projection:t.projection,state:t.state,tileGrid:t.tileGrid,tileLoadFunction:t.tileLoadFunction?t.tileLoadFunction:Tp,tilePixelRatio:t.tilePixelRatio,tileUrlFunction:t.tileUrlFunction,url:t.url,urls:t.urls,wrapX:t.wrapX,transition:t.transition,interpolate:t.interpolate!==void 0?t.interpolate:!0,key:t.key,attributionsCollapsible:t.attributionsCollapsible,zDirection:t.zDirection}),this.crossOrigin=t.crossOrigin!==void 0?t.crossOrigin:null,this.referrerPolicy=t.referrerPolicy,this.tileClass=t.tileClass!==void 0?t.tileClass:Js,this.tileGridForProjection={},this.reprojectionErrorThreshold_=t.reprojectionErrorThreshold,this.renderReprojectionEdges_=!1}getGutterForProjection(t){return this.getProjection()&&t&&!Nn(this.getProjection(),t)?0:this.getGutter()}getGutter(){return 0}getKey(){let t=super.getKey();return this.getInterpolate()||(t+=":disable-interpolation"),t}getTileGridForProjection(t){let e=this.getProjection();if(this.tileGrid&&(!e||Nn(e,t)))return this.tileGrid;let i=Y(t);return i in this.tileGridForProjection||(this.tileGridForProjection[i]=Bs(t)),this.tileGridForProjection[i]}createTile_(t,e,i,r,s,o){let a=[t,e,i],l=this.getTileCoordForTileUrlFunction(a,s),h=l?this.tileUrlFunction(l,r,s):void 0,c=new this.tileClass(a,h!==void 0?D.IDLE:D.EMPTY,h!==void 0?h:"",{crossOrigin:this.crossOrigin,referrerPolicy:this.referrerPolicy},this.tileLoadFunction,this.tileOptions);return c.key=o,c.addEventListener(P.CHANGE,this.handleTileChange.bind(this)),c}getTile(t,e,i,r,s,o){let a=this.getProjection();if(!a||!s||Nn(a,s))return this.getTileInternal(t,e,i,r,a||s);let l=[t,e,i],h=this.getKey(),c=this.getTileGridForProjection(a),d=this.getTileGridForProjection(s),f=this.getTileCoordForTileUrlFunction(l,s),g=new eo(a,c,s,d,l,f,this.getTilePixelRatio(r),this.getGutter(),(m,_,p,y)=>this.getTileInternal(m,_,p,y,a,o),this.reprojectionErrorThreshold_,this.renderReprojectionEdges_,this.tileOptions);return g.key=h,g}getTileInternal(t,e,i,r,s,o){let a=this.getKey(),l=Wn(this,a,t,e,i);if(o&&o.containsKey(l))return o.get(l);let h=this.createTile_(t,e,i,r,s,a);return o?.set(l,h),h}setRenderReprojectionEdges(t){this.renderReprojectionEdges_!=t&&(this.renderReprojectionEdges_=t,this.changed())}setTileGridForProjection(t,e){let i=Et(t);if(i){let r=Y(i);r in this.tileGridForProjection||(this.tileGridForProjection[r]=e)}}};function Tp(n,t){if(Rt){let e=n.getCrossOrigin(),i="same-origin",r="same-origin";e==="anonymous"||e===""?(i="cors",r="omit"):e==="use-credentials"&&(i="cors",r="include");let s={mode:i,credentials:r,referrerPolicy:n.getReferrerPolicy()};fetch(t,s).then(o=>{if(!o.ok)throw new Error(`HTTP ${o.status}`);return o.blob()}).then(o=>createImageBitmap(o)).then(o=>{let a=n.getImage();a.width=o.width,a.height=o.height,a.getContext("2d").drawImage(o,0,0),o.close?.(),a.dispatchEvent(new Event("load"))}).catch(()=>{n.getImage().dispatchEvent(new Event("error"))});return}n.getImage().src=t}var vd=ol;var al=class extends vd{constructor(t){t=t||{};let e=t.projection!==void 0?t.projection:"EPSG:3857",i=t.tileGrid!==void 0?t.tileGrid:$u({extent:js(e),maxResolution:t.maxResolution,maxZoom:t.maxZoom,minZoom:t.minZoom,tileSize:t.tileSize});super({attributions:t.attributions,cacheSize:t.cacheSize,crossOrigin:t.crossOrigin,referrerPolicy:t.referrerPolicy,interpolate:t.interpolate,projection:e,reprojectionErrorThreshold:t.reprojectionErrorThreshold,tileGrid:i,tileLoadFunction:t.tileLoadFunction,tilePixelRatio:t.tilePixelRatio,tileUrlFunction:t.tileUrlFunction,url:t.url,urls:t.urls,wrapX:t.wrapX!==void 0?t.wrapX:!0,transition:t.transition,attributionsCollapsible:t.attributionsCollapsible,zDirection:t.zDirection}),this.gutter_=t.gutter!==void 0?t.gutter:0}getGutter(){return this.gutter_}},Sd=al;function hi(){if(!u.map||!u.variant||u.settling)return;let n=u.engine?.getView();try{let t=Rd();t.last=u.game.slug,t.games[u.game.slug]={game:u.game.slug,map:u.map.slug,variant:u.map.variants.indexOf(u.variant),center:n?.getCenter(),zoom:n?.getZoom(),hidden:[...u.hiddenCategories],collapsed:[...u.collapsedSections],overviewDocked:u.overviewDocked},localStorage.setItem(Ea,JSON.stringify(t))}catch{}}function Rd(){try{let n=JSON.parse(localStorage.getItem(Ea)||"null");if(n&&n.games)return n}catch{}return{last:"",games:{}}}function ao(n){let t=Rd(),e=n||t.last,i=e&&t.games[e];return i&&i.game&&i.map?i:null}function lo(){let[n,t]=decodeURIComponent(location.hash.replace(/^#\/?/,"")).split("/").map(e=>e.trim());return{game:n,map:t}}function Td(){if(!u.game||!u.map)return;let n=`#${u.game.slug}/${u.map.slug}`;location.hash!==n&&history.replaceState(null,"",n)}var ll=class n extends wt{constructor(t){if(super(),this.on,this.once,this.un,this.id_=void 0,this.geometryName_="geometry",this.style_=null,this.styleFunction_=void 0,this.geometryChangeKey_=null,this.addChangeListener(this.geometryName_,this.handleGeometryChanged_),t)if(typeof t.getSimplifiedGeometry=="function"){let e=t;this.setGeometry(e)}else{let e=t;this.setProperties(e)}}clone(){let t=new n,e=this.geometryName_;t.setGeometryName(e);let i=this.getPropertiesInternal();if(i){let s=this.getGeometry();for(let o in i)o===e&&s?t.set(o,s.clone()):t.set(o,i[o],!0)}let r=this.getStyle();return r&&t.setStyle(r),t}getGeometry(){return this.get(this.geometryName_)}getId(){return this.id_}getGeometryName(){return this.geometryName_}getStyle(){return this.style_}getStyleFunction(){return this.styleFunction_}handleGeometryChange_(){this.changed()}handleGeometryChanged_(){this.geometryChangeKey_&&(J(this.geometryChangeKey_),this.geometryChangeKey_=null);let t=this.getGeometry();t&&(this.geometryChangeKey_=Z(t,P.CHANGE,this.handleGeometryChange_,this)),this.changed()}setGeometry(t){this.set(this.geometryName_,t)}setStyle(t){this.style_=t,this.styleFunction_=t?Ip(t):void 0,this.changed()}setId(t){this.id_=t,this.changed()}setGeometryName(t){t!==this.geometryName_&&(this.removeChangeListener(this.geometryName_,this.handleGeometryChanged_),this.geometryName_=t,this.addChangeListener(this.geometryName_,this.handleGeometryChanged_),this.handleGeometryChanged_())}};function Ip(n){if(typeof n=="function")return n;let t;return Array.isArray(n)?t=n:(K(typeof n.getZIndex=="function","Expected an `ol/style/Style` or an array of `ol/style/Style.js`"),t=[n]),function(){return t}}var ki=ll;function jt(n,t,e,i,r,s,o){s=s||[],o=o||2;let a=0;for(let l=t;l<e;l+=i){let h=n[l],c=n[l+1];s[a++]=r[0]*h+r[2]*c+r[4],s[a++]=r[1]*h+r[3]*c+r[5];for(let d=2;d<o;d++)s[a++]=n[l+d]}return s&&s.length!=a&&(s.length=a),s}function co(n,t,e,i,r,s,o){o=o||[];let a=Math.cos(r),l=Math.sin(r),h=s[0],c=s[1],d=0;for(let f=t;f<e;f+=i){let g=n[f]-h,m=n[f+1]-c;o[d++]=h+g*a-m*l,o[d++]=c+g*l+m*a;for(let _=f+2;_<f+i;++_)o[d++]=n[_]}return o&&o.length!=d&&(o.length=d),o}function Id(n,t,e,i,r,s,o,a){a=a||[];let l=o[0],h=o[1],c=0;for(let d=t;d<e;d+=i){let f=n[d]-l,g=n[d+1]-h;a[c++]=l+r*f,a[c++]=h+s*g;for(let m=d+2;m<d+i;++m)a[c++]=n[m]}return a&&a.length!=c&&(a.length=c),a}function bd(n,t,e,i,r,s,o){o=o||[];let a=0;for(let l=t;l<e;l+=i){o[a++]=n[l]+r,o[a++]=n[l+1]+s;for(let h=l+2;h<l+i;++h)o[a++]=n[h]}return o&&o.length!=a&&(o.length=a),o}var Ld=At(),bp=[NaN,NaN],cl=class extends wt{constructor(){super(),this.extent_=ut(),this.extentRevision_=-1,this.simplifiedGeometryMaxMinSquaredTolerance=0,this.simplifiedGeometryRevision=0,this.simplifyTransformedInternal=Hs((t,e,i)=>{if(!i)return this.getSimplifiedGeometry(e);let r=this.clone();return r.applyTransform(i),r.getSimplifiedGeometry(e)})}simplifyTransformed(t,e){return this.simplifyTransformedInternal(this.getRevision(),t,e)}clone(){return H()}closestPointXY(t,e,i,r){return H()}containsXY(t,e){return this.closestPointXY(t,e,bp,Number.MIN_VALUE)===0}getClosestPoint(t,e){return e=e||[NaN,NaN],this.closestPointXY(t[0],t[1],e,1/0),e}intersectsCoordinate(t){return this.containsXY(t[0],t[1])}computeExtent(t){return H()}getExtent(t){if(this.extentRevision_!=this.getRevision()){let e=this.computeExtent(this.extent_);(isNaN(e[0])||isNaN(e[1]))&&tn(e),this.extentRevision_=this.getRevision()}return ou(this.extent_,t)}rotate(t,e){H()}scale(t,e,i){H()}simplify(t){return this.getSimplifiedGeometry(t*t)}getSimplifiedGeometry(t){return H()}getType(){return H()}applyTransform(t){H()}intersectsExtent(t){return H()}translate(t,e){H()}transform(t,e){let i=Et(t),r=i.getUnits()=="tile-pixels"?function(s,o,a){let l=i.getExtent(),h=i.getWorldExtent(),c=ct(h)/ct(l);Ot(Ld,h[0],h[3],c,-c,0,0,0);let d=jt(s,0,s.length,a,Ld,o),f=ln(i,e);return f?f(d,d,a):d}:ln(i,e);return this.applyTransform(r),this}},Ad=cl;var hl=class extends Ad{constructor(){super(),this.layout="XY",this.stride=2,this.flatCoordinates}computeExtent(t){return bn(this.flatCoordinates,0,this.flatCoordinates.length,this.stride,t)}getCoordinates(){return H()}getFirstCoordinate(){return this.flatCoordinates.slice(0,this.stride)}getFlatCoordinates(){return this.flatCoordinates}getLastCoordinate(){return this.flatCoordinates.slice(this.flatCoordinates.length-this.stride)}getLayout(){return this.layout}getSimplifiedGeometry(t){if(this.simplifiedGeometryRevision!==this.getRevision()&&(this.simplifiedGeometryMaxMinSquaredTolerance=0,this.simplifiedGeometryRevision=this.getRevision()),t<0||this.simplifiedGeometryMaxMinSquaredTolerance!==0&&t<=this.simplifiedGeometryMaxMinSquaredTolerance)return this;let e=this.getSimplifiedGeometryInternal(t);return e.getFlatCoordinates().length<this.flatCoordinates.length?e:(this.simplifiedGeometryMaxMinSquaredTolerance=t,this)}getSimplifiedGeometryInternal(t){return this}getStride(){return this.stride}setFlatCoordinates(t,e){this.stride=Md(t),this.layout=t,this.flatCoordinates=e}setCoordinates(t,e){H()}setLayout(t,e,i){let r;if(t)r=Md(t);else{for(let s=0;s<i;++s){if(e.length===0){this.layout="XY",this.stride=2;return}e=e[0]}r=e.length,t=Lp(r)}this.layout=t,this.stride=r}applyTransform(t){this.flatCoordinates&&(t(this.flatCoordinates,this.flatCoordinates,this.layout.startsWith("XYZ")?3:2,this.stride),this.changed())}rotate(t,e){let i=this.getFlatCoordinates();if(i){let r=this.getStride();co(i,0,i.length,r,t,e,i),this.changed()}}scale(t,e,i){e===void 0&&(e=t),i||(i=Kt(this.getExtent()));let r=this.getFlatCoordinates();if(r){let s=this.getStride();Id(r,0,r.length,s,t,e,i,r),this.changed()}}translate(t,e){let i=this.getFlatCoordinates();if(i){let r=this.getStride();bd(i,0,i.length,r,t,e,i),this.changed()}}};function Lp(n){let t;return n==2?t="XY":n==3?t="XYZ":n==4&&(t="XYZM"),t}function Md(n){let t;return n=="XY"?t=2:n=="XYZ"||n=="XYM"?t=3:n=="XYZM"&&(t=4),t}function Pd(n,t,e){let i=n.getFlatCoordinates();if(!i)return null;let r=n.getStride();return jt(i,0,i.length,r,t,e)}var Ge=hl;function Od(n,t,e,i){for(let r=0,s=e.length;r<s;++r)n[t++]=e[r];return t}function kr(n,t,e,i){for(let r=0,s=e.length;r<s;++r){let o=e[r];for(let a=0;a<i;++a)n[t++]=o[a]}return t}function ul(n,t,e,i,r){r=r||[];let s=0;for(let o=0,a=e.length;o<a;++o){let l=kr(n,t,e[o],i);r[s++]=l,t=l}return r.length=s,r}function Dd(n,t,e,i,r){r=r||[];let s=0;for(let o=0,a=e.length;o<a;++o){let l=ul(n,t,e[o],i,r[s]);l.length===0&&(l[0]=t),r[s++]=l,t=l[l.length-1]}return r.length=s,r}var dl=class n extends Ge{constructor(t,e){super(),this.setCoordinates(t,e)}clone(){let t=new n(this.flatCoordinates.slice(),this.layout);return t.applyProperties(this),t}closestPointXY(t,e,i,r){let s=this.flatCoordinates,o=_e(t,e,s[0],s[1]);if(o<r){let a=this.stride;for(let l=0;l<a;++l)i[l]=s[l];return i.length=a,o}return r}getCoordinates(){return this.flatCoordinates.slice()}computeExtent(t){return Ls(this.flatCoordinates,t)}getType(){return"Point"}intersectsExtent(t){return Rr(t,this.flatCoordinates[0],this.flatCoordinates[1])}setCoordinates(t,e){this.setLayout(e,t,0),this.flatCoordinates||(this.flatCoordinates=[]),this.flatCoordinates.length=Od(this.flatCoordinates,0,t,this.stride),this.changed()}},ui=dl;function Fr(){return ru[u.map?.iconOutset==="dark"?"dark":"light"]}function Ap(n){let t=u.map?.iconOutset==="dark",e=Pp(n);return(t?e>.3:e<.88)?n:Mp(n,t?.74:.42)}function Mp(n,t){let e=String(n).replace("#","");if(e.length!==6)return n;let[i,r,s]=[0,2,4].map(C=>parseInt(e.slice(C,C+2),16)/255),o=Math.max(i,r,s),a=Math.min(i,r,s),l=(o+a)/2,h=0,c=o-a,d=c===0?0:c/(1-Math.abs(2*l-1));c!==0&&(o===i?h=(r-s)/c%6:o===r?h=(s-i)/c+2:h=(i-r)/c+4,h*=60,h<0&&(h+=360));let f=(1-Math.abs(2*t-1))*d,g=f*(1-Math.abs(h/60%2-1)),m=t-f/2,[_,p,y]=h<60?[f,g,0]:h<120?[g,f,0]:h<180?[0,f,g]:h<240?[0,g,f]:h<300?[g,0,f]:[f,0,g],E=C=>Math.round((C+m)*255).toString(16).padStart(2,"0");return`#${E(_)}${E(p)}${E(y)}`}function Pp(n){let t=String(n).replace("#","");if(t.length!==6)return .5;let e=i=>parseInt(t.slice(i,i+2),16)/255;return .2126*e(0)+.7152*e(2)+.0722*e(4)}function ho(n){let t=Math.abs(Number(n)||0);return Tn[(Math.imul(t,2654435761)>>>0)%Tn.length]}function di(n,t){let e=String(n||"#ffffff").replace("#",""),i=e.length===3?e.split("").map(s=>s+s).join(""):e.slice(0,6).padEnd(6,"f"),r=Number.parseInt(i,16);return`rgba(${r>>16&255}, ${r>>8&255}, ${r&255}, ${t})`}function Kn(n,t){n.style.setProperty("--pin-color",Nr(t))}function Nr(n){return Ap(n.color||ho(n.id))}function Bn(n,t,e){if(n.classList.remove("has-source-icon"),n.style.removeProperty("--pin-icon"),n.textContent="",!t.iconAsset){n.textContent=e;return}n.style.setProperty("--pin-icon",`url("${fl(t.iconAsset)}")`),n.classList.add("has-source-icon")}function fl(n){return`/static/icons/${n.split("/").map(e=>encodeURIComponent(e)).join("/")}`}function Fi(n){return n.split(/\s+/).slice(0,2).map(t=>t[0]||"").join("")}function kd(n){return Math.imul(Number(n)||0,2654435761)>>>0}function Fd(n){return String(n||"").replace(/\[([^\]]+)\]\([^)]+\)/g,"$1").replace(/[*_`>#]/g,"").replace(/\r/g,"").replace(/\n{3,}/g,`83 9-`).trim()}function pn(n){return new Intl.NumberFormat().format(n)}function pi(n,t,e){return Math.min(e,Math.max(t,n))}function uh(n){return n instanceof HTMLElement&&(n.matches("input, textarea, select")||n.isContentEditable)}function Kx(){let n=()=>({game:d.game?.title,map:d.map?.title,variant:d.variant?.name,zoom:d.engine?.getView().getZoom(),center:d.engine?.getView().getCenter(),resolution:d.engine?.getView().getResolution(),nativeMaxZoom:d.variant?.maxZoom,maxZoom:d.variant?ir(d.variant):null,interpolate:d.variant?.interpolate,tileStats:{...d.tileStats},pins:d.pins.length,eligibleLocations:d.eligibleLocations,domNodes:document.querySelectorAll("*").length,canvases:document.querySelectorAll("canvas").length,rasterCacheSize:64,pinLabelsVisible:d.pinLabelsVisible,hoveredPin:d.hoveredPin?.location.title||null,selectedPin:d.selectedPin?.location.title||null,fitZoom:d.fitZoom,filters:{hiddenCategories:[...d.hiddenCategories].sort(),collapsedSections:[...d.collapsedSections].sort()},ui:{sidebarCollapsed:document.querySelector(".app-shell")?.classList.contains("sidebar-collapsed")??!1,detailOpen:!C.detail.hidden,detailTitle:C.detailTitle.textContent||null,searchQuery:d.search,searchResultsVisible:!C.searchResults.hidden,soloChip:C.soloChip.hidden?null:C.soloChip.textContent,visibleCountText:C.visibleCount.textContent,overviewDocked:d.overviewDocked,subgridVisible:d.subgridVisible},zones:{visible:d.zonesVisible,count:d.zoneRecords.size,focused:d.zoneRecords.get(d.focusedZoneID)?.zone.title||null,highlighted:[...d.highlightedZones].map(t=>d.zoneRecords.get(t)?.zone.title).filter(Boolean),focusedPins:d.pins.filter(t=>!t.filteredHidden&&t.insideHighlightedZone).length},grid:{enabled:d.gridEnabled,prefix:d.gridPrefix,maximumDepth:Ws(),extent:d.gridEnabled?Qr():null,cells:[...d.sources.grid.getFeatures(),...d.sources.gridContext.getFeatures()].map(t=>t.get("gridCell")),priorityPins:d.gridPrefix?d.pins.filter(t=>!t.filteredHidden&&Ys(t)).length:0}});window.__atlasDebug={snapshot:n,setLayerVisible:(t,e)=>d.layers[t]?.setVisible(e)},window.render_game_to_text=()=>JSON.stringify({coordinateSystem:"ATLAS:PIXELS; origin top-left; x increases right; y decreases downward",...n()}),window.advanceTime=()=>d.engine?.renderSync()}N_();})();4+`).trim()}function Xe(n){return new Intl.NumberFormat().format(n)}function Re(n,t,e){return Math.min(e,Math.max(t,n))}function uo(n){return n instanceof HTMLElement&&(n.matches("input, textarea, select")||n.isContentEditable)}function gl(n){u.hiddenCategories.delete(n.category.id),u.search="",v.search.value="",v.searchResults.hidden=!0,zr(),he(),Ni(),ml(n,!0)}function ml(n,t=!1){if(u.selectedPin=n,We(),u.layers.pins.changed(),u.layers.pinLabels.changed(),u.layers.text.changed(),u.layers.textDetail.changed(),u.layers.priority.changed(),v.detailTitle.textContent=n.location.title,v.detailCategory.textContent=`${n.group.title} / ${n.category.title}`,v.detailDescription.textContent="",v.detailLinks.hidden=!0,Op(n),v.detailID.textContent=String(n.location.id),v.detailCoordinates.textContent=`${n.location.lat.toFixed(6)}, ${n.location.lng.toFixed(6)}`,Kn(v.detailDot,n.category),Bn(v.detailDot,n.category,Fi(n.category.title)),v.detail.hidden=!1,t){let e=u.engine.getView();e.animate({center:n.coordinate,zoom:Math.min(Ue(u.variant),Math.max(e.getZoom()||0,4)),duration:220})}}async function Op(n){let t=await Nd(u.map.id);if(u.selectedPin!==n)return;let e=t[String(n.location.id)]||{};n.location.description=e.d||"",n.location.links=e.l||[],v.detailDescription.textContent=Fd(e.d)||"No description is included in the archive.",Dp(n)}function Dp(n){let t=(n.location.links||[]).filter(i=>u.pinByID.has(i.locationId));if(v.detailLinks.hidden=t.length===0,!t.length){v.detailLinks.replaceChildren();return}let e=document.createDocumentFragment();for(let i of t){let r=document.createElement("button");r.type="button",r.className="detail-link",r.dataset.location=String(i.locationId),r.textContent=i.title,e.append(r)}v.detailLinks.replaceChildren(e)}function Te(){u.selectedPin=null,u.sources&&(We(),u.layers.pins.changed(),u.layers.pinLabels.changed(),u.layers.text.changed(),u.layers.textDetail.changed(),u.layers.priority.changed()),v.detail.hidden=!0}function pl(n,t,e,i){let r=0,s=n[e-i],o=n[e-i+1],a=0,l=0;for(;t<e;t+=i){let h=n[t]-s,c=n[t+1]-o;r+=l*h-a*c,a=h,l=c}return r/2}function _l(n,t,e,i){let r=0;for(let s=0,o=e.length;s<o;++s){let a=e[s];r+=pl(n,t,a,i),t=a}return r}function zd(n,t,e,i){let r=0;for(let s=0,o=e.length;s<o;++s){let a=e[s];r+=_l(n,t,a,i),t=a[a.length-1]}return r}function Gd(n,t,e,i,r,s,o){let a=n[t],l=n[t+1],h=n[e]-a,c=n[e+1]-l,d;if(h===0&&c===0)d=t;else{let f=((r-a)*h+(s-l)*c)/(h*h+c*c);if(f>1)d=e;else if(f>0){for(let g=0;g<i;++g)o[g]=zt(n[t+g],n[e+g],f);o.length=i;return}else d=t}for(let f=0;f<i;++f)o[f]=n[d+f];o.length=i}function yl(n,t,e,i,r){let s=n[t],o=n[t+1];for(t+=i;t<e;t+=i){let a=n[t],l=n[t+1],h=_e(s,o,a,l);h>r&&(r=h),s=a,o=l}return r}function xl(n,t,e,i,r){for(let s=0,o=e.length;s<o;++s){let a=e[s];r=yl(n,t,a,i,r),t=a}return r}function Xd(n,t,e,i,r){for(let s=0,o=e.length;s<o;++s){let a=e[s];r=xl(n,t,a,i,r),t=a[a.length-1]}return r}function El(n,t,e,i,r,s,o,a,l,h,c){if(t==e)return h;let d,f;if(r===0){if(f=_e(o,a,n[t],n[t+1]),f<h){for(d=0;d<i;++d)l[d]=n[t+d];return l.length=i,f}return h}c=c||[NaN,NaN];let g=t+i;for(;g<e;)if(Gd(n,g-i,g,i,o,a,c),f=_e(o,a,c[0],c[1]),f<h){for(h=f,d=0;d<i;++d)l[d]=c[d];l.length=i,g+=i}else g+=i*Math.max((Math.sqrt(f)-Math.sqrt(h))/r|0,1);if(s&&(Gd(n,e-i,t,i,o,a,c),f=_e(o,a,c[0],c[1]),f<h)){for(h=f,d=0;d<i;++d)l[d]=c[d];l.length=i}return h}function wl(n,t,e,i,r,s,o,a,l,h,c){c=c||[NaN,NaN];for(let d=0,f=e.length;d<f;++d){let g=e[d];h=El(n,t,g,i,r,s,o,a,l,h,c),t=g}return h}function Wd(n,t,e,i,r,s,o,a,l,h,c){c=c||[NaN,NaN];for(let d=0,f=e.length;d<f;++d){let g=e[d];h=wl(n,t,g,i,r,s,o,a,l,h,c),t=g[g.length-1]}return h}function Ye(n,t,e,i,r){r=r!==void 0?r:[];let s=0;for(let o=t;o<e;o+=i)r[s++]=n.slice(o,o+i);return r.length=s,r}function jn(n,t,e,i,r){r=r!==void 0?r:[];let s=0;for(let o=0,a=e.length;o<a;++o){let l=e[o];r[s++]=Ye(n,t,l,i,r[s]),t=l}return r.length=s,r}function Gr(n,t,e,i,r){r=r!==void 0?r:[];let s=0;for(let o=0,a=e.length;o<a;++o){let l=e[o];r[s++]=l.length===1&&l[0]===t?[]:jn(n,t,l,i,r[s]),t=l[l.length-1]}return r.length=s,r}function Xr(n,t,e,i,r,s,o){let a=(e-t)/i;if(a<3){for(;t<e;t+=i)s[o++]=n[t],s[o++]=n[t+1];return o}let l=new Array(a);l[0]=1,l[a-1]=1;let h=[t,e-i],c=0;for(;h.length>0;){let d=h.pop(),f=h.pop(),g=0,m=n[f],_=n[f+1],p=n[d],y=n[d+1];for(let E=f+i;E<d;E+=i){let C=n[E],x=n[E+1],w=uu(C,x,m,_,p,y);w>g&&(c=E,g=w)}g>r&&(l[(c-t)/i]=1,f+i<c&&h.push(f,c),c+i<d&&h.push(c,d))}for(let d=0;d<a;++d)l[d]&&(s[o++]=n[t+d*i],s[o++]=n[t+d*i+1]);return o}function Ud(n,t,e,i,r,s,o,a){for(let l=0,h=e.length;l<h;++l){let c=e[l];o=Xr(n,t,c,i,r,s,o),a.push(o),t=c}return o}function zi(n,t){return t*Math.round(n/t)}function kp(n,t,e,i,r,s,o){if(t==e)return o;let a=zi(n[t],r),l=zi(n[t+1],r);t+=i,s[o++]=a,s[o++]=l;let h,c;do if(h=zi(n[t],r),c=zi(n[t+1],r),t+=i,t==e)return s[o++]=h,s[o++]=c,o;while(h==a&&c==l);for(;t<e;){let d=zi(n[t],r),f=zi(n[t+1],r);if(t+=i,d==h&&f==c)continue;let g=h-a,m=c-l,_=d-a,p=f-l;if(g*p==m*_&&(g<0&&_<g||g==_||g>0&&_>g)&&(m<0&&p<m||m==p||m>0&&p>m)){h=d,c=f;continue}s[o++]=h,s[o++]=c,a=h,l=c,h=d,c=f}return s[o++]=h,s[o++]=c,o}function Wr(n,t,e,i,r,s,o,a){for(let l=0,h=e.length;l<h;++l){let c=e[l];o=kp(n,t,c,i,r,s,o),a.push(o),t=c}return o}function Yd(n,t,e,i,r,s,o,a){for(let l=0,h=e.length;l<h;++l){let c=e[l],d=[];o=Wr(n,t,c,i,r,s,o,d),a.push(d),t=c[c.length-1]}return o}var Cl=class n extends Ge{constructor(t,e){super(),this.maxDelta_=-1,this.maxDeltaRevision_=-1,e!==void 0&&!Array.isArray(t[0])?this.setFlatCoordinates(e,t):this.setCoordinates(t,e)}clone(){return new n(this.flatCoordinates.slice(),this.layout)}closestPointXY(t,e,i,r){return r<Ii(this.getExtent(),t,e)?r:(this.maxDeltaRevision_!=this.getRevision()&&(this.maxDelta_=Math.sqrt(yl(this.flatCoordinates,0,this.flatCoordinates.length,this.stride,0)),this.maxDeltaRevision_=this.getRevision()),El(this.flatCoordinates,0,this.flatCoordinates.length,this.stride,this.maxDelta_,!0,t,e,i,r))}getArea(){return pl(this.flatCoordinates,0,this.flatCoordinates.length,this.stride)}getCoordinates(){return Ye(this.flatCoordinates,0,this.flatCoordinates.length,this.stride)}getSimplifiedGeometryInternal(t){let e=[];return e.length=Xr(this.flatCoordinates,0,this.flatCoordinates.length,this.stride,t,e,0),new n(e,"XY")}getType(){return"LinearRing"}intersectsExtent(t){return Ks(this.flatCoordinates,0,this.flatCoordinates.length,this.stride,t)}setCoordinates(t,e){this.setLayout(e,t,1),this.flatCoordinates||(this.flatCoordinates=[]),this.flatCoordinates.length=kr(this.flatCoordinates,0,t,this.stride),this.changed()}},vl=Cl;function Ur(n,t,e,i,r,s,o){let a,l,h,c,d,f,g,m=r[s+1],_=[];for(let E=0,C=e.length;E<C;++E){let x=e[E];for(c=n[x-i],f=n[x-i+1],a=t;a<x;a+=i)d=n[a],g=n[a+1],(m<=f&&g<=m||f<=m&&m<=g)&&(h=(m-f)/(g-f)*(d-c)+c,_.push(h)),c=d,f=g}let p=NaN,y=-1/0;for(_.sort(Bt),c=_[0],a=1,l=_.length;a<l;++a){d=_[a];let E=Math.abs(d-c);E>y&&(h=(c+d)/2,Pr(n,t,e,i,h,m)&&(p=h,y=E)),c=d}return isNaN(p)&&(p=r[s]),o?(o.push(p,m,y),o):[p,m,y]}function fo(n,t,e,i,r){let s=[];for(let o=0,a=e.length;o<a;++o){let l=e[o];s=Ur(n,t,l,i,r,2*o,s),t=l[l.length-1]}return s}function Vd(n,t,e,i){for(;t<e-i;){for(let r=0;r<i;++r){let s=n[t+r];n[t+r]=n[e-i+r],n[e-i+r]=s}t+=i,e-=i}}function Sl(n,t,e,i){let r=0,s=n[e-i],o=n[e-i+1];for(;t<e;t+=i){let a=n[t],l=n[t+1];r+=(a-s)*(l+o),s=a,o=l}return r===0?void 0:r>0}function Rl(n,t,e,i,r){r=r!==void 0?r:!1;for(let s=0,o=e.length;s<o;++s){let a=e[s],l=Sl(n,t,a,i);if(s===0){if(r&&l||!r&&!l)return!1}else if(r&&!l||!r&&l)return!1;t=a}return!0}function Zd(n,t,e,i,r){for(let s=0,o=e.length;s<o;++s){let a=e[s];if(!Rl(n,t,a,i,r))return!1;a.length&&(t=a[a.length-1])}return!0}function go(n,t,e,i,r){r=r!==void 0?r:!1;for(let s=0,o=e.length;s<o;++s){let a=e[s],l=Sl(n,t,a,i);(s===0?r&&l||!r&&!l:r&&!l||!r&&l)&&Vd(n,t,a,i),t=a}return t}function Tl(n,t,e,i,r){for(let s=0,o=e.length;s<o;++s)t=go(n,t,e[s],i,r);return t}function Kd(n,t){let e=[],i=0,r=0,s;for(let o=0,a=t.length;o<a;++o){let l=t[o],h=Sl(n,i,l,2);if(s===void 0&&(s=h),h===s)e.push(t.slice(r,o+1));else{if(e.length===0)continue;e[e.length-1].push(t[r])}r=o+1,i=l}return e}var mo=class n extends Ge{constructor(t,e,i){super(),this.ends_=[],this.flatInteriorPointRevision_=-1,this.flatInteriorPoint_=null,this.maxDelta_=-1,this.maxDeltaRevision_=-1,this.orientedRevision_=-1,this.orientedFlatCoordinates_=null,e!==void 0&&i?(this.setFlatCoordinates(e,t),this.ends_=i):this.setCoordinates(t,e)}appendLinearRing(t){this.flatCoordinates?ve(this.flatCoordinates,t.getFlatCoordinates()):this.flatCoordinates=t.getFlatCoordinates().slice(),this.ends_.push(this.flatCoordinates.length),this.changed()}clone(){let t=new n(this.flatCoordinates.slice(),this.layout,this.ends_.slice());return t.applyProperties(this),t}closestPointXY(t,e,i,r){return r<Ii(this.getExtent(),t,e)?r:(this.maxDeltaRevision_!=this.getRevision()&&(this.maxDelta_=Math.sqrt(xl(this.flatCoordinates,0,this.ends_,this.stride,0)),this.maxDeltaRevision_=this.getRevision()),wl(this.flatCoordinates,0,this.ends_,this.stride,this.maxDelta_,!0,t,e,i,r))}containsXY(t,e){return Pr(this.getOrientedFlatCoordinates(),0,this.ends_,this.stride,t,e)}getArea(){return _l(this.getOrientedFlatCoordinates(),0,this.ends_,this.stride)}getCoordinates(t){let e;return t!==void 0?(e=this.getOrientedFlatCoordinates().slice(),go(e,0,this.ends_,this.stride,t)):e=this.flatCoordinates,jn(e,0,this.ends_,this.stride)}getEnds(){return this.ends_}getFlatInteriorPoint(){if(this.flatInteriorPointRevision_!=this.getRevision()){let t=Kt(this.getExtent());this.flatInteriorPoint_=Ur(this.getOrientedFlatCoordinates(),0,this.ends_,this.stride,t,0),this.flatInteriorPointRevision_=this.getRevision()}return this.flatInteriorPoint_}getInteriorPoint(){return new ui(this.getFlatInteriorPoint(),"XYM")}getLinearRingCount(){return this.ends_.length}getLinearRing(t){return t<0||this.ends_.length<=t?null:new vl(this.flatCoordinates.slice(t===0?0:this.ends_[t-1],this.ends_[t]),this.layout)}getLinearRings(){let t=this.layout,e=this.flatCoordinates,i=this.ends_,r=[],s=0;for(let o=0,a=i.length;o<a;++o){let l=i[o],h=new vl(e.slice(s,l),t);r.push(h),s=l}return r}getOrientedFlatCoordinates(){if(this.orientedRevision_!=this.getRevision()){let t=this.flatCoordinates;Rl(t,0,this.ends_,this.stride)?this.orientedFlatCoordinates_=t:(this.orientedFlatCoordinates_=t.slice(),this.orientedFlatCoordinates_.length=go(this.orientedFlatCoordinates_,0,this.ends_,this.stride)),this.orientedRevision_=this.getRevision()}return this.orientedFlatCoordinates_}getSimplifiedGeometryInternal(t){let e=[],i=[];return e.length=Wr(this.flatCoordinates,0,this.ends_,this.stride,Math.sqrt(t),e,0,i),new n(e,"XY",i)}getType(){return"Polygon"}intersectsExtent(t){return Xa(this.getOrientedFlatCoordinates(),0,this.ends_,this.stride,t)}setCoordinates(t,e){this.setLayout(e,t,2),this.flatCoordinates||(this.flatCoordinates=[]);let i=ul(this.flatCoordinates,0,t,this.stride,this.ends_);this.flatCoordinates.length=i.length===0?0:i[i.length-1],this.changed()}},Ve=mo;function Il(n){if(Fe(n))throw new Error("Cannot create polygon from empty extent");let t=n[0],e=n[1],i=n[2],r=n[3],s=[t,e,t,r,i,r,i,e,t,e];return new mo(s,"XY",[s.length])}function Np(){let n=u.variant?.surface;return n?[n.x,-(n.y+n.height),n.x+n.width,-n.y]:fi()}function Bd(n){return n.key.toLocaleLowerCase()==="g"?(n.preventDefault(),jd(),u.gridEnabled?(v.gridInput.focus(),v.gridInput.select()):v.viewport.focus({preventScroll:!0}),!0):n.key===" "&&u.gridEnabled&&n.target!==v.subgridToggle?(n.preventDefault(),Yr(!u.subgridVisible),!0):n.key==="Escape"&&u.gridEnabled?(n.preventDefault(),bl(),!0):!1}function jd(n=!u.gridEnabled){u.gridEnabled=n,n&&Yr(!0),_o(),We(),u.layers.pins.changed(),u.layers.text.changed(),u.layers.priority.changed()}function Yr(n){u.subgridVisible=n,u.layers.grid.changed(),u.layers.gridContext.changed(),v.subgridToggle.setAttribute("aria-pressed",String(n)),v.subgridToggle.setAttribute("aria-label",n?"Hide the subgrid":"Show the subgrid"),Hd()}function Hd(){if(!u.gridEnabled){v.gridHint.textContent="G \xB7 grid off";return}v.gridHint.textContent=`G-${u.gridPrefix||"root"}`+(u.subgridVisible?"":" no subgrid")}function Vr(n){let t=qn(),e=[...n.toLocaleLowerCase()].filter(r=>me.includes(r)).slice(0,t).join(""),i=e!==u.gridPrefix;u.gridPrefix=e,u.gridEnabled||(u.gridEnabled=!0),_o(),We(),u.layers.pins.changed(),u.layers.text.changed(),u.layers.priority.changed(),i&&(Te(),u.engine.getView().fit(Hn(),{size:u.engine.getSize(),padding:[52,52,52,52],maxZoom:Ue(u.variant),duration:180}))}function bl(){if(u.gridEnabled){if(!u.gridPrefix){jd(!1);return}Vr(u.gridPrefix.slice(0,-1))}}function _o(){if(!u.sources||(u.sources.grid.clear(),u.sources.gridContext.clear(),v.gridNavigator.hidden=!u.gridEnabled,Hd(),!u.gridEnabled||!u.variant))return;let n=qn();if(v.gridInput.maxLength=n,v.gridInput.value=u.gridPrefix,v.gridBack.title=u.gridPrefix?"Back one geohash level":"Close geohash grid",zp(),u.gridPrefix.length>=n){po(u.gridPrefix,Hn(),"leaf");return}u.gridPrefix&&po(u.gridPrefix,Hn(),"scope");for(let t of me){let e=u.gridPrefix+t;po(e,Ll(e),"child")}}function zp(){for(let n=0;n<u.gridPrefix.length;n++){let t=u.gridPrefix.slice(0,n),e=u.gridPrefix.slice(0,n+1);for(let i of me){let r=t+i;r!==e&&po(r,Ll(r),"neighbor",u.gridPrefix.length-n)}}}function po(n,t,e,i=0){let[r,s,o,a]=t,l=u.pins.filter(d=>{if(d.filteredHidden)return!1;let[f,g]=d.coordinate;return f>=r&&f<=o&&g>=s&&g<=a}).length,h=new ki({geometry:new Ve([[[r,s],[r,a],[o,a],[o,s],[r,s]]]),gridCell:{hash:n,extent:t,role:e,count:l,contextDistance:i},priority:e==="neighbor"?-i*100+me.indexOf(n[n.length-1]):me.indexOf(n[n.length-1])});(e==="neighbor"?u.sources.gridContext:u.sources.grid).addFeature(h)}function Hn(){return Ll(u.gridPrefix)}function Ll(n){let t=[...Np()],e=!0;for(let i of n){let r=me.indexOf(i);if(!(r<0))for(let s of[16,8,4,2,1]){if(e){let o=(t[0]+t[2])/2;r&s?t[0]=o:t[2]=o}else{let o=(t[1]+t[3])/2;r&s?t[1]=o:t[3]=o}e=!e}}return t}function qn(){return 3}function $n(n){if(!u.gridEnabled||!u.gridPrefix)return!1;let t=Hn(),[e,i]=n.coordinate;return e>=t[0]&&e<=t[2]&&i>=t[1]&&i<=t[3]}var xo=[NaN,NaN,NaN,0],Al;function Gp(){return Al||(Al=nt(1,1,void 0,{willReadFrequently:!0,desynchronized:!0})),Al}var Xp=/^rgba?\(\s*(\d+%?)\s+(\d+%?)\s+(\d+%?)(?:\s*\/\s*(\d+%|\d*\.\d+|[01]))?\s*\)$/i,Wp=/^rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)(?:\s*,\s*(\d+%|\d*\.\d+|[01]))?\s*\)$/i,Up=/^rgba?\(\s*(\d+%)\s*,\s*(\d+%)\s*,\s*(\d+%)(?:\s*,\s*(\d+%|\d*\.\d+|[01]))?\s*\)$/i,Yp=/^#([\da-f]{3,4}|[\da-f]{6}|[\da-f]{8})$/i;function yo(n,t){return n.endsWith("%")?Number(n.substring(0,n.length-1))/t:Number(n)}function Kr(n){throw new Error('failed to parse "'+n+'" as color')}function qd(n){if(n.toLowerCase().startsWith("rgb")){let s=n.match(Wp)||n.match(Xp)||n.match(Up);if(s){let o=s[4],a=100/255;return[et(yo(s[1],a)+.5|0,0,255),et(yo(s[2],a)+.5|0,0,255),et(yo(s[3],a)+.5|0,0,255),o!==void 0?et(yo(o,100),0,1):1]}Kr(n)}if(n.startsWith("#")){if(Yp.test(n)){let s=n.substring(1),o=s.length<=4?1:2,a=[0,0,0,255];for(let l=0,h=s.length;l<h;l+=o){let c=parseInt(s.substring(l,l+o),16);o===1&&(c+=c<<4),a[l/o]=c}return a[3]=a[3]/255,a}Kr(n)}let t=Gp();t.fillStyle="#abcdef";let e=t.fillStyle;t.fillStyle=n,t.fillStyle===e&&(t.fillStyle="#fedcba",e=t.fillStyle,t.fillStyle=n,t.fillStyle===e&&Kr(n));let i=t.fillStyle;if(i.startsWith("#")||i.startsWith("rgba"))return qd(i);t.clearRect(0,0,1,1),t.fillRect(0,0,1,1);let r=Array.from(t.getImageData(0,0,1,1).data);return r[3]=rn(r[3]/255,3),r}function $d(n){return typeof n=="string"?n:jr(n)}var Vp=1024,Zr={},Ml=0;function Jd(n){if(n.length===4)return n;let t=n.slice();return t[3]=1,t}function Pl(n){return n>.0031308?Math.pow(n,1/2.4)*269.025-14.025:n*3294.6}function Ol(n){return n>.2068965?Math.pow(n,3):(n-4/29)*(108/841)}function Dl(n){return n>10.314724?Math.pow((n+14.025)/269.025,2.4):n/3294.6}function kl(n){return n>.0088564?Math.pow(n,1/3):n/(108/841)+4/29}function Fl(n){let t=Dl(n[0]),e=Dl(n[1]),i=Dl(n[2]),r=kl(t*.222488403+e*.716873169+i*.06060791),s=500*(kl(t*.452247074+e*.399439023+i*.148375274)-r),o=200*(r-kl(t*.016863605+e*.117638439+i*.865350722)),a=Math.atan2(o,s)*(180/Math.PI);return[116*r-16,Math.sqrt(s*s+o*o),a<0?a+360:a,n[3]]}function Qd(n){let t=(n[0]+16)/116,e=n[1],i=n[2]*Math.PI/180,r=Ol(t),s=Ol(t+e/500*Math.cos(i)),o=Ol(t-e/200*Math.sin(i)),a=Pl(s*3.021973625-r*1.617392459-o*.404875592),l=Pl(s*-.943766287+r*1.916279586+o*.027607165),h=Pl(s*.069407491-r*.22898585+o*1.159737864);return[et(a+.5|0,0,255),et(l+.5|0,0,255),et(h+.5|0,0,255),n[3]]}function Br(n){if(n==="none")return xo;if(Zr.hasOwnProperty(n))return Zr[n];if(Ml>=Vp){let e=0;for(let i in Zr)(e++&3)===0&&(delete Zr[i],--Ml)}let t=qd(n);t.length!==4&&Kr(n);for(let e of t)isNaN(e)&&Kr(n);return Zr[n]=t,++Ml,t}function ue(n){return Array.isArray(n)?n:Br(n)}function jr(n){let t=n[0];t!=(t|0)&&(t=t+.5|0);let e=n[1];e!=(e|0)&&(e=e+.5|0);let i=n[2];i!=(i|0)&&(i=i+.5|0);let r=n[3]===void 0?1:Math.round(n[3]*1e3)/1e3;return"rgba("+t+","+e+","+i+","+r+")"}var zl=class{constructor(){this.cache_={},this.patternCache_={},this.cacheSize_=0,this.maxCacheSize_=1024}clear(){this.cache_={},this.patternCache_={},this.cacheSize_=0}canExpireCache(){return this.cacheSize_>this.maxCacheSize_}expire(){if(this.canExpireCache()){let t=0;for(let e in this.cache_){let i=this.cache_[e];(t++&3)===0&&!i.hasListener()&&(delete this.cache_[e],delete this.patternCache_[e],--this.cacheSize_)}}}get(t,e){let i=Nl(t,e);return i in this.cache_?this.cache_[i]:null}getPattern(t,e){let i=Nl(t,e);return i in this.patternCache_?this.patternCache_[i]:null}set(t,e,i,r){let s=Nl(t,e),o=s in this.cache_;this.cache_[s]=i,r&&(i.getImageState()===U.IDLE&&i.load(),i.getImageState()===U.LOADING?i.ready().then(()=>{this.patternCache_[s]=Dr().createPattern(i.getImage(1),"repeat")}):this.patternCache_[s]=Dr().createPattern(i.getImage(1),"repeat")),o||++this.cacheSize_}setSize(t){this.maxCacheSize_=t,this.expire()}};function Nl(n,t){let e=t?ue(t):"null";return n+":"+e}var Xt=new zl;var Hr=null,Eo=class extends Di{constructor(t,e,i,r,s){super(),this.hitDetectionImage_=null,this.image_=t,this.crossOrigin_=i?.crossOrigin,this.referrerPolicy_=i?.referrerPolicy,this.canvas_={},this.color_=s,this.imageState_=r===void 0?U.IDLE:r,this.size_=t&&t.width&&t.height?[t.width,t.height]:null,this.src_=e,this.tainted_,this.ready_=null}initializeImage_(){this.image_=new Image,this.crossOrigin_!==null&&(this.image_.crossOrigin=this.crossOrigin_),this.referrerPolicy_!==void 0&&(this.image_.referrerPolicy=this.referrerPolicy_)}isTainted_(){if(this.tainted_===void 0&&this.imageState_===U.LOADED){Hr||(Hr=nt(1,1,void 0,{willReadFrequently:!0})),Hr.drawImage(this.image_,0,0);try{Hr.getImageData(0,0,1,1),this.tainted_=!1}catch{Hr=null,this.tainted_=!0}}return this.tainted_===!0}dispatchChangeEvent_(){this.dispatchEvent(P.CHANGE)}handleImageError_(){this.imageState_=U.ERROR,this.dispatchChangeEvent_()}handleImageLoad_(){this.imageState_=U.LOADED,this.size_=[this.image_.width,this.image_.height],this.dispatchChangeEvent_()}getImage(t){return this.image_||this.initializeImage_(),this.replaceColor_(t),this.canvas_[t]?this.canvas_[t]:this.image_}setImage(t){this.image_=t}getPixelRatio(t){return this.replaceColor_(t),this.canvas_[t]?t:1}getImageState(){return this.imageState_}getHitDetectionImage(){if(this.image_||this.initializeImage_(),!this.hitDetectionImage_)if(this.isTainted_()){let t=this.size_[0],e=this.size_[1],i=nt(t,e);i.fillRect(0,0,t,e),this.hitDetectionImage_=i.canvas}else this.hitDetectionImage_=this.image_;return this.hitDetectionImage_}getSize(){return this.size_}getSrc(){return this.src_}load(){if(this.imageState_===U.IDLE){this.image_||this.initializeImage_(),this.imageState_=U.LOADING;try{this.src_!==void 0&&(this.image_.src=this.src_)}catch{this.handleImageError_()}this.image_ instanceof HTMLImageElement&&nd(this.image_,this.src_).then(t=>{this.image_=t,this.handleImageLoad_()}).catch(this.handleImageError_.bind(this))}}replaceColor_(t){if(!this.color_||this.canvas_[t]||this.imageState_!==U.LOADED)return;let e=this.image_,i=nt(Math.ceil(e.width*t),Math.ceil(e.height*t)),r=i.canvas;i.scale(t,t),i.drawImage(e,0,0),i.globalCompositeOperation="multiply",i.fillStyle=$d(this.color_),i.fillRect(0,0,r.width/t,r.height/t),i.globalCompositeOperation="destination-in",i.drawImage(e,0,0),this.canvas_[t]=r}ready(){return this.ready_||(this.ready_=new Promise(t=>{if(this.imageState_===U.LOADED||this.imageState_===U.ERROR)t();else{let e=()=>{(this.imageState_===U.LOADED||this.imageState_===U.ERROR)&&(this.removeEventListener(P.CHANGE,e),t())};this.addEventListener(P.CHANGE,e)}})),this.ready_}};function Gi(n,t,e,i,r,s){let o=t===void 0?void 0:Xt.get(t,r);return o||(o=new Eo(n,n&&"src"in n?n.src||void 0:t,e,i,r),Xt.set(t,r,o,s)),s&&o&&!Xt.getPattern(t,r)&&Xt.set(t,r,o,s),o}var tf=Eo;function Ht(n){return n?Array.isArray(n)?jr(n):typeof n=="object"&&"src"in n?Zp(n):n:null}function Zp(n){if(!n.offset||!n.size)return Xt.getPattern(n.src,n.color);let t=n.src+":"+n.offset,e=Xt.getPattern(t,n.color);if(e)return e;let i=Xt.get(n.src,null);if(i.getImageState()!==U.LOADED)return null;let r=nt(n.size[0],n.size[1]);return r.drawImage(i.getImage(1),n.offset[0],n.offset[1],n.size[0],n.size[1],0,0,n.size[0],n.size[1]),Gi(r.canvas,t,void 0,U.LOADED,n.color,!0),Xt.getPattern(t,n.color)}var qr="ol-hidden";var Xi="ol-unselectable";var Jn="ol-control",Gl="ol-collapsed",Kp=new RegExp(["^\\s*(?=(?:(?:[-a-z]+\\s*){0,2}(italic|oblique))?)","(?=(?:(?:[-a-z]+\\s*){0,2}(small-caps))?)","(?=(?:(?:[-a-z]+\\s*){0,2}(bold(?:er)?|lighter|[1-9]00 ))?)","(?:(?:normal|\\1|\\2|\\3)\\s*){0,3}((?:xx?-)?","(?:small|large)|medium|smaller|larger|[\\.\\d]+(?:\\%|in|[cem]m|ex|p[ctx]))","(?:\\s*\\/\\s*(normal|[\\.\\d]+(?:\\%|in|[cem]m|ex|p[ctx])?))",`?\\s*([-,\\"\\'\\sa-z0-9]+?)\\s*$`].join(""),"i"),ef=["style","variant","weight","size","lineHeight","family"],wo={normal:400,bold:700},Co=function(n){let t=n.match(Kp);if(!t)return null;let e={lineHeight:"normal",size:"1.2em",style:"normal",weight:"400",variant:"normal"};for(let i=0,r=ef.length;i<r;++i){let s=t[i+1];s!==void 0&&(e[ef[i]]=typeof s=="string"?s.trim():s)}return isNaN(Number(e.weight))&&e.weight in wo&&(e.weight=wo[e.weight]),e.families=e.family.split(/,\s?/).map(i=>i.trim().replace(/^['"]|['"]$/g,"")),e};var vo="10px sans-serif",Tt="#000",Ze="round",qt=[],$t=0,Ke="round",gi=10,rf=0,Wt="#000",Wi="center",mn="middle",mi=[0,0,0,0],pi=1,gn=new wt,$r=null,nf,Xl={},Bp=new Set(["serif","sans-serif","monospace","cursive","fantasy","system-ui","ui-serif","ui-sans-serif","ui-monospace","ui-rounded","emoji","math","fangsong"]);function jp(n,t,e){return`${n} ${t} 16px "${e}"`}var sf=(function(){let t,e;async function i(s){await e.ready;let o=Co(s),a=o.families[0].toLowerCase(),l=o.weight,h=[];return e.forEach(d=>{let f=d.family.replace(/^['"]|['"]$/g,"").toLowerCase(),g=wo[d.weight]||d.weight;f===a&&d.style===o.style&&g==l&&h.push(d)}),h.length===0?!1:(await Promise.all(h.map(d=>d.load().then(()=>!0,()=>!1)))).some(d=>d)}async function r(){await e.ready;let s=!0,o=gn.getProperties(),a=Object.keys(o).filter(l=>o[l]<100);for(let l=a.length-1;l>=0;--l){let h=a[l],c=o[h];c<100&&(await i(h)?(ze(Xl),gn.set(h,100)):(c+=10,gn.set(h,c,!0),c<100&&(s=!1)))}t=void 0,s||(t=setTimeout(r,100))}return async function(s){e||(e=Rt?self.fonts:document.fonts);let o=Co(s);if(!o)return;let a=o.families,l=!1;for(let h of a){if(Bp.has(h))continue;let c=jp(o.style,o.weight,h);gn.get(c)===void 0&&(gn.set(c,0,!0),l=!0)}l&&(clearTimeout(t),t=setTimeout(r,100))}})(),Hp=(function(){let n;return function(t){let e=Xl[t];if(e==null){if(Rt){let i=Co(t),r=of(t,"\u017Dg");e=(isNaN(Number(i.lineHeight))?1.2:Number(i.lineHeight))*(r.actualBoundingBoxAscent+r.actualBoundingBoxDescent)}else n||(n=document.createElement("div"),n.innerHTML="M",n.style.minHeight="0",n.style.maxHeight="none",n.style.height="auto",n.style.padding="0",n.style.border="none",n.style.position="absolute",n.style.display="block",n.style.left="-99999px"),n.style.font=t,document.body.appendChild(n),e=n.offsetHeight,document.body.removeChild(n);Xl[t]=e}return e}})();function of(n,t){return $r||($r=nt(1,1)),n!=nf&&($r.font=n,nf=$r.font),$r.measureText(t)}function af(n,t){return of(n,t).width}function Wl(n,t,e){if(t in e)return e[t];let i=t.split(`5+`).reduce((r,s)=>Math.max(r,af(n,s)),0);return e[t]=i,i}function lf(n,t){let e=[],i=[],r=[],s=0,o=0,a=0,l=0;for(let h=0,c=t.length;h<=c;h+=2){let d=t[h];if(d===`6+`||h===c){s=Math.max(s,o),r.push(o),o=0,a+=l,l=0;continue}let f=t[h+1]||n.font,g=af(f,d);e.push(g),o+=g;let m=Hp(f);i.push(m),l=Math.max(l,m)}return{width:s,height:a,widths:e,heights:i,lineWidths:r}}function cf(n,t,e,i,r,s,o,a,l,h,c){n.save(),e!==1&&(n.globalAlpha===void 0?n.globalAlpha=d=>d.globalAlpha*=e:n.globalAlpha*=e),t&&n.transform.apply(n,t),i.contextInstructions?(n.translate(l,h),n.scale(c[0],c[1]),qp(i,n)):c[0]<0||c[1]<0?(n.translate(l,h),n.scale(c[0],c[1]),n.drawImage(i,r,s,o,a,0,0,o,a)):n.drawImage(i,r,s,o,a,l,h,o*c[0],a*c[1]),n.restore()}function qp(n,t){let e=n.contextInstructions;for(let i=0,r=e.length;i<r;i+=2)Array.isArray(e[i+1])?t[e[i]].apply(t,e[i+1]):t[e[i]]=e[i+1]}var Ul=class n{constructor(t){this.opacity_=t.opacity,this.rotateWithView_=t.rotateWithView,this.rotation_=t.rotation,this.scale_=t.scale,this.scaleArray_=mt(t.scale),this.displacement_=t.displacement,this.declutterMode_=t.declutterMode}clone(){let t=this.getScale();return new n({opacity:this.getOpacity(),scale:Array.isArray(t)?t.slice():t,rotation:this.getRotation(),rotateWithView:this.getRotateWithView(),displacement:this.getDisplacement().slice(),declutterMode:this.getDeclutterMode()})}getOpacity(){return this.opacity_}getRotateWithView(){return this.rotateWithView_}getRotation(){return this.rotation_}getScale(){return this.scale_}getScaleArray(){return this.scaleArray_}getDisplacement(){return this.displacement_}getDeclutterMode(){return this.declutterMode_}getAnchor(){return H()}getImage(t){return H()}getHitDetectionImage(){return H()}getPixelRatio(t){return 1}getImageState(){return H()}getImageSize(){return H()}getOrigin(){return H()}getSize(){return H()}setDisplacement(t){this.displacement_=t}setOpacity(t){this.opacity_=t}setRotateWithView(t){this.rotateWithView_=t}setRotation(t){this.rotation_=t}setScale(t){this.scale_=t,this.scaleArray_=mt(t)}listenImageChange(t){H()}load(){H()}unlistenImageChange(t){H()}ready(){return Promise.resolve()}},So=Ul;var Yl=class n extends So{constructor(t){super({opacity:1,rotateWithView:t.rotateWithView!==void 0?t.rotateWithView:!1,rotation:t.rotation!==void 0?t.rotation:0,scale:t.scale!==void 0?t.scale:1,displacement:t.displacement!==void 0?t.displacement:[0,0],declutterMode:t.declutterMode}),this.hitDetectionCanvas_=null,this.fill_=t.fill!==void 0?t.fill:null,this.origin_=[0,0],this.points_=t.points,this.radius=t.radius,this.radius2_=t.radius2,this.angle_=t.angle!==void 0?t.angle:0,this.stroke_=t.stroke!==void 0?t.stroke:null,this.size_,this.renderOptions_,this.imageState_=this.fill_&&this.fill_.loading()?U.LOADING:U.LOADED,this.imageState_===U.LOADING&&this.ready().then(()=>this.imageState_=U.LOADED),this.render()}clone(){let t=this.getScale(),e=new n({fill:this.getFill()?this.getFill().clone():void 0,points:this.getPoints(),radius:this.getRadius(),radius2:this.getRadius2(),angle:this.getAngle(),stroke:this.getStroke()?this.getStroke().clone():void 0,rotation:this.getRotation(),rotateWithView:this.getRotateWithView(),scale:Array.isArray(t)?t.slice():t,displacement:this.getDisplacement().slice(),declutterMode:this.getDeclutterMode()});return e.setOpacity(this.getOpacity()),e}getAnchor(){let t=this.size_,e=this.getDisplacement(),i=this.getScaleArray();return[t[0]/2-e[0]/i[0],t[1]/2+e[1]/i[1]]}getAngle(){return this.angle_}getFill(){return this.fill_}setFill(t){this.fill_=t,this.render()}getHitDetectionImage(){return this.hitDetectionCanvas_||(this.hitDetectionCanvas_=this.createHitDetectionCanvas_(this.renderOptions_)),this.hitDetectionCanvas_}getImage(t){let e=this.fill_?.getKey(),i=`${t},${this.angle_},${this.radius},${this.radius2_},${this.points_},${e}`+Object.values(this.renderOptions_).join(","),r=Xt.get(i,null)?.getImage(1);if(!r){let s=this.renderOptions_,o=Math.ceil(s.size*t),a=nt(o,o);this.draw_(s,a,t),r=a.canvas;let l=new tf(r,void 0,null,U.LOADED,null);Xt.set(i,null,l),createImageBitmap(r).then(h=>{l.setImage(h)})}return r}getPixelRatio(t){return t}getImageSize(){return this.size_}getImageState(){return this.imageState_}getOrigin(){return this.origin_}getPoints(){return this.points_}getRadius(){return this.radius}setRadius(t){this.radius!==t&&(this.radius=t,this.render())}getRadius2(){return this.radius2_}setRadius2(t){this.radius2_!==t&&(this.radius2_=t,this.render())}getSize(){return this.size_}getStroke(){return this.stroke_}setStroke(t){this.stroke_=t,this.render()}listenImageChange(t){}load(){}unlistenImageChange(t){}calculateLineJoinSize_(t,e,i){if(e===0||this.points_===1/0||t!=="bevel"&&t!=="miter")return e;let r=this.radius,s=this.radius2_===void 0?r:this.radius2_;if(r<s){let T=r;r=s,s=T}let o=this.radius2_===void 0?this.points_:this.points_*2,a=2*Math.PI/o,l=s*Math.sin(a),h=Math.sqrt(s*s-l*l),c=r-h,d=Math.sqrt(l*l+c*c),f=d/l;if(t==="miter"&&f<=i)return f*e;let g=e/2/f,m=e/2*(c/d),p=Math.sqrt((r+g)*(r+g)+m*m)-r;if(this.radius2_===void 0||t==="bevel")return p*2;let y=r*Math.sin(a),E=Math.sqrt(r*r-y*y),C=s-E,w=Math.sqrt(y*y+C*C)/y;if(w<=i){let T=w*e/2-s-r;return 2*Math.max(p,T)}return p*2}createRenderOptions(){let t=Ze,e=Ke,i=0,r=null,s=0,o,a=0;this.stroke_&&(o=Ht(this.stroke_.getColor()??Wt),a=this.stroke_.getWidth()??pi,r=this.stroke_.getLineDash(),s=this.stroke_.getLineDashOffset()??0,e=this.stroke_.getLineJoin()??Ke,t=this.stroke_.getLineCap()??Ze,i=this.stroke_.getMiterLimit()??gi);let l=this.calculateLineJoinSize_(e,a,i),h=Math.max(this.radius,this.radius2_||0),c=Math.ceil(2*h+l);return{strokeStyle:o,strokeWidth:a,size:c,lineCap:t,lineDash:r,lineDashOffset:s,lineJoin:e,miterLimit:i}}render(){this.renderOptions_=this.createRenderOptions();let t=this.renderOptions_.size;this.hitDetectionCanvas_=null,this.size_=[t,t]}draw_(t,e,i){if(e.scale(i,i),e.translate(t.size/2,t.size/2),this.createPath_(e),this.fill_){let r=this.fill_.getColor();r===null&&(r=Tt),e.fillStyle=Ht(r),e.fill()}t.strokeStyle&&(e.strokeStyle=t.strokeStyle,e.lineWidth=t.strokeWidth,t.lineDash&&(e.setLineDash(t.lineDash),e.lineDashOffset=t.lineDashOffset),e.lineCap=t.lineCap,e.lineJoin=t.lineJoin,e.miterLimit=t.miterLimit,e.stroke())}createHitDetectionCanvas_(t){let e;if(this.fill_){let i=this.fill_.getColor(),r=0;typeof i=="string"&&(i=ue(i)),i===null?r=1:Array.isArray(i)&&(r=i.length===4?i[3]:1),r===0&&(e=nt(t.size,t.size),this.drawHitDetectionCanvas_(t,e))}return e?e.canvas:this.getImage(1)}createPath_(t){let e=this.points_,i=this.radius;if(e===1/0)t.arc(0,0,i,0,2*Math.PI);else{let r=this.radius2_===void 0?i:this.radius2_;this.radius2_!==void 0&&(e*=2);let s=this.angle_-Math.PI/2,o=2*Math.PI/e;for(let a=0;a<e;a++){let l=s+a*o,h=a%2===0?i:r;t.lineTo(h*Math.cos(l),h*Math.sin(l))}t.closePath()}}drawHitDetectionCanvas_(t,e){e.translate(t.size/2,t.size/2),this.createPath_(e),e.fillStyle=Tt,e.fill(),t.strokeStyle&&(e.strokeStyle=t.strokeStyle,e.lineWidth=t.strokeWidth,t.lineDash&&(e.setLineDash(t.lineDash),e.lineDashOffset=t.lineDashOffset),e.lineJoin=t.lineJoin,e.miterLimit=t.miterLimit,e.stroke())}ready(){return this.fill_?this.fill_.ready():Promise.resolve()}},Ro=Yl;var Vl=class n extends Ro{constructor(t){t=t||{radius:5},super({points:1/0,fill:t.fill,radius:t.radius,stroke:t.stroke,scale:t.scale!==void 0?t.scale:1,rotation:t.rotation!==void 0?t.rotation:0,rotateWithView:t.rotateWithView!==void 0?t.rotateWithView:!1,displacement:t.displacement!==void 0?t.displacement:[0,0],declutterMode:t.declutterMode})}clone(){let t=this.getScale(),e=new n({fill:this.getFill()?this.getFill().clone():void 0,stroke:this.getStroke()?this.getStroke().clone():void 0,radius:this.getRadius(),scale:Array.isArray(t)?t.slice():t,rotation:this.getRotation(),rotateWithView:this.getRotateWithView(),displacement:this.getDisplacement().slice(),declutterMode:this.getDeclutterMode()});return e.setOpacity(this.getOpacity()),e}},To=Vl;var Zl=class n{constructor(t){t=t||{},this.patternImage_=null,this.color_=null,t.color!==void 0&&this.setColor(t.color)}clone(){let t=this.getColor();return new n({color:Array.isArray(t)?t.slice():t||void 0})}getColor(){return this.color_}setColor(t){if(t!==null&&typeof t=="object"&&"src"in t){let e=Gi(null,t.src,{crossOrigin:"anonymous"},void 0,t.offset?null:t.color?t.color:null,!(t.offset&&t.size));e.ready().then(()=>{this.patternImage_=null}),e.getImageState()===U.IDLE&&e.load(),e.getImageState()===U.LOADING&&(this.patternImage_=e)}this.color_=t}getKey(){let t=this.getColor();return t?t instanceof CanvasPattern||t instanceof CanvasGradient?Y(t):typeof t=="object"&&"src"in t?t.src+":"+t.offset:ue(t).toString():""}loading(){return!!this.patternImage_}ready(){return this.patternImage_?this.patternImage_.ready():Promise.resolve()}},pt=Zl;function hf(n,t,e,i){return e!==void 0&&i!==void 0?[e/n,i/t]:e!==void 0?e/n:i!==void 0?i/t:1}var Kl=class n extends So{constructor(t){t=t||{};let e=t.opacity!==void 0?t.opacity:1,i=t.rotation!==void 0?t.rotation:0,r=t.scale!==void 0?t.scale:1,s=t.rotateWithView!==void 0?t.rotateWithView:!1;super({opacity:e,rotation:i,scale:r,displacement:t.displacement!==void 0?t.displacement:[0,0],rotateWithView:s,declutterMode:t.declutterMode}),this.anchor_=t.anchor!==void 0?t.anchor:[.5,.5],this.normalizedAnchor_=null,this.anchorOrigin_=t.anchorOrigin!==void 0?t.anchorOrigin:"top-left",this.anchorXUnits_=t.anchorXUnits!==void 0?t.anchorXUnits:"fraction",this.anchorYUnits_=t.anchorYUnits!==void 0?t.anchorYUnits:"fraction",this.crossOrigin_=t.crossOrigin!==void 0?t.crossOrigin:null,this.referrerPolicy_=t.referrerPolicy;let o=t.img!==void 0?t.img:null,a=t.src;K(!(a!==void 0&&o),"`image` and `src` cannot be provided at the same time"),(a===void 0||a.length===0)&&o&&(a=o.src||Y(o)),K(a!==void 0&&a.length>0,"A defined and non-empty `src` or `image` must be provided"),K(!((t.width!==void 0||t.height!==void 0)&&t.scale!==void 0),"`width` or `height` cannot be provided together with `scale`");let l;if(t.src!==void 0?l=U.IDLE:o!==void 0&&("complete"in o?o.complete?l=o.src?U.LOADED:U.IDLE:l=U.LOADING:l=U.LOADED),this.color_=t.color!==void 0?ue(t.color):null,this.iconImage_=Gi(o,a,{crossOrigin:this.crossOrigin_,referrerPolicy:this.referrerPolicy_},l,this.color_),this.offset_=t.offset!==void 0?t.offset:[0,0],this.offsetOrigin_=t.offsetOrigin!==void 0?t.offsetOrigin:"top-left",this.origin_=null,this.size_=t.size!==void 0?t.size:null,this.initialOptions_,t.width!==void 0||t.height!==void 0){let h,c;if(t.size)[h,c]=t.size;else{let d=this.getImage(1);if(d.width&&d.height)h=d.width,c=d.height;else if(d instanceof HTMLImageElement){this.initialOptions_=t;let f=()=>{if(this.unlistenImageChange(f),!this.initialOptions_)return;let g=this.iconImage_.getSize();this.setScale(hf(g[0],g[1],t.width,t.height))};this.listenImageChange(f);return}}h!==void 0&&this.setScale(hf(h,c,t.width,t.height))}}clone(){let t,e,i;return this.initialOptions_?(e=this.initialOptions_.width,i=this.initialOptions_.height):(t=this.getScale(),t=Array.isArray(t)?t.slice():t),new n({anchor:this.anchor_.slice(),anchorOrigin:this.anchorOrigin_,anchorXUnits:this.anchorXUnits_,anchorYUnits:this.anchorYUnits_,color:this.color_&&this.color_.slice?this.color_.slice():this.color_||void 0,crossOrigin:this.crossOrigin_,referrerPolicy:this.referrerPolicy_,offset:this.offset_.slice(),offsetOrigin:this.offsetOrigin_,opacity:this.getOpacity(),rotateWithView:this.getRotateWithView(),rotation:this.getRotation(),scale:t,width:e,height:i,size:this.size_!==null?this.size_.slice():void 0,src:this.getSrc(),displacement:this.getDisplacement().slice(),declutterMode:this.getDeclutterMode()})}getAnchor(){let t=this.normalizedAnchor_;if(!t){t=this.anchor_;let r=this.getSize();if(this.anchorXUnits_=="fraction"||this.anchorYUnits_=="fraction"){if(!r)return null;t=this.anchor_.slice(),this.anchorXUnits_=="fraction"&&(t[0]*=r[0]),this.anchorYUnits_=="fraction"&&(t[1]*=r[1])}if(this.anchorOrigin_!="top-left"){if(!r)return null;t===this.anchor_&&(t=this.anchor_.slice()),(this.anchorOrigin_=="top-right"||this.anchorOrigin_=="bottom-right")&&(t[0]=-t[0]+r[0]),(this.anchorOrigin_=="bottom-left"||this.anchorOrigin_=="bottom-right")&&(t[1]=-t[1]+r[1])}this.normalizedAnchor_=t}let e=this.getDisplacement(),i=this.getScaleArray();return[t[0]-e[0]/i[0],t[1]+e[1]/i[1]]}setAnchor(t){this.anchor_=t,this.normalizedAnchor_=null}getColor(){return this.color_}setColor(t){let e=t?ue(t):null;if(this.color_===e||this.color_&&e&&this.color_.length===e.length&&this.color_.every((o,a)=>o===e[a]))return;this.color_=e;let i=this.getSrc(),r=i!==void 0?null:this.getHitDetectionImage(),s=i!==void 0?U.IDLE:this.iconImage_.getImageState();this.iconImage_=Gi(r,i,{crossOrigin:this.crossOrigin_,referrerPolicy:this.referrerPolicy_},s,this.color_)}getImage(t){return this.iconImage_.getImage(t)}getPixelRatio(t){return this.iconImage_.getPixelRatio(t)}getImageSize(){return this.iconImage_.getSize()}getImageState(){return this.iconImage_.getImageState()}getHitDetectionImage(){return this.iconImage_.getHitDetectionImage()}getOrigin(){if(this.origin_)return this.origin_;let t=this.offset_;if(this.offsetOrigin_!="top-left"){let e=this.getSize(),i=this.iconImage_.getSize();if(!e||!i)return null;t=t.slice(),(this.offsetOrigin_=="top-right"||this.offsetOrigin_=="bottom-right")&&(t[0]=i[0]-e[0]-t[0]),(this.offsetOrigin_=="bottom-left"||this.offsetOrigin_=="bottom-right")&&(t[1]=i[1]-e[1]-t[1])}return this.origin_=t,this.origin_}getSrc(){return this.iconImage_.getSrc()}setSrc(t){this.iconImage_=Gi(null,t,{crossOrigin:this.crossOrigin_,referrerPolicy:this.referrerPolicy_},U.IDLE,this.color_)}getSize(){return this.size_?this.size_:this.iconImage_.getSize()}getWidth(){let t=this.getScaleArray();if(this.size_)return this.size_[0]*t[0];if(this.iconImage_.getImageState()==U.LOADED)return this.iconImage_.getSize()[0]*t[0]}getHeight(){let t=this.getScaleArray();if(this.size_)return this.size_[1]*t[1];if(this.iconImage_.getImageState()==U.LOADED)return this.iconImage_.getSize()[1]*t[1]}setScale(t){delete this.initialOptions_,super.setScale(t)}listenImageChange(t){this.iconImage_.addEventListener(P.CHANGE,t)}load(){this.iconImage_.load()}unlistenImageChange(t){this.iconImage_.removeEventListener(P.CHANGE,t)}ready(){return this.iconImage_.ready()}},pn=Kl;var Bl=class n{constructor(t){t=t||{},this.color_=t.color!==void 0?t.color:null,this.lineCap_=t.lineCap,this.lineDash_=t.lineDash!==void 0?t.lineDash:null,this.lineDashOffset_=t.lineDashOffset,this.lineJoin_=t.lineJoin,this.miterLimit_=t.miterLimit,this.offset_=t.offset,this.width_=t.width}clone(){let t=this.getColor();return new n({color:Array.isArray(t)?t.slice():t||void 0,lineCap:this.getLineCap(),lineDash:this.getLineDash()?this.getLineDash().slice():void 0,lineDashOffset:this.getLineDashOffset(),lineJoin:this.getLineJoin(),miterLimit:this.getMiterLimit(),offset:this.getOffset(),width:this.getWidth()})}getColor(){return this.color_}getLineCap(){return this.lineCap_}getLineDash(){return this.lineDash_}getLineDashOffset(){return this.lineDashOffset_}getLineJoin(){return this.lineJoin_}getMiterLimit(){return this.miterLimit_}getOffset(){return this.offset_}getWidth(){return this.width_}setColor(t){this.color_=t}setLineCap(t){this.lineCap_=t}setLineDash(t){this.lineDash_=t}setLineDashOffset(t){this.lineDashOffset_=t}setLineJoin(t){this.lineJoin_=t}setMiterLimit(t){this.miterLimit_=t}setOffset(t){this.offset_=t}setWidth(t){this.width_=t}},Mt=Bl;var Io=class n{constructor(t){t=t||{},this.geometry_=null,this.geometryFunction_=uf,t.geometry!==void 0&&this.setGeometry(t.geometry),this.fill_=t.fill!==void 0?t.fill:null,this.image_=t.image!==void 0?t.image:null,this.renderer_=t.renderer!==void 0?t.renderer:null,this.hitDetectionRenderer_=t.hitDetectionRenderer!==void 0?t.hitDetectionRenderer:null,this.stroke_=t.stroke!==void 0?t.stroke:null,this.text_=t.text!==void 0?t.text:null,this.zIndex_=t.zIndex}clone(){let t=this.getGeometry();return t&&typeof t=="object"&&(t=t.clone()),new n({geometry:t??void 0,fill:this.getFill()?this.getFill().clone():void 0,image:this.getImage()?this.getImage().clone():void 0,renderer:this.getRenderer()??void 0,stroke:this.getStroke()?this.getStroke().clone():void 0,text:this.getText()?this.getText().clone():void 0,zIndex:this.getZIndex()})}getRenderer(){return this.renderer_}setRenderer(t){this.renderer_=t}setHitDetectionRenderer(t){this.hitDetectionRenderer_=t}getHitDetectionRenderer(){return this.hitDetectionRenderer_}getGeometry(){return this.geometry_}getGeometryFunction(){return this.geometryFunction_}getFill(){return this.fill_}setFill(t){this.fill_=t}getImage(){return this.image_}setImage(t){this.image_=t}getStroke(){return this.stroke_}setStroke(t){this.stroke_=t}getText(){return this.text_}setText(t){this.text_=t}getZIndex(){return this.zIndex_}setGeometry(t){typeof t=="function"?this.geometryFunction_=t:typeof t=="string"?this.geometryFunction_=function(e){return e.get(t)}:t?t!==void 0&&(this.geometryFunction_=function(){return t}):this.geometryFunction_=uf,this.geometry_=t}setZIndex(t){this.zIndex_=t}};function df(n){let t;if(typeof n=="function")t=n;else{let e;Array.isArray(n)?e=n:(K(typeof n.getZIndex=="function","Expected an `Style` or an array of `Style`"),e=[n]),t=function(){return e}}return t}var jl=null;function Hl(n,t){if(!jl){let e=new pt({color:"rgba(255,255,255,0.4)"}),i=new Mt({color:"#3399CC",width:1.25});jl=[new Io({image:new To({fill:e,stroke:i,radius:5}),fill:e,stroke:i})]}return jl}function uf(n){return n.getGeometry()}var It=Io;var $p="#333",ql=class n{constructor(t){t=t||{},this.font_=t.font,this.rotation_=t.rotation,this.rotateWithView_=t.rotateWithView,this.keepUpright_=t.keepUpright,this.scale_=t.scale,this.scaleArray_=mt(t.scale!==void 0?t.scale:1),this.text_=t.text,this.textAlign_=t.textAlign,this.justify_=t.justify,this.repeat_=t.repeat,this.textBaseline_=t.textBaseline,this.fill_=t.fill!==void 0?t.fill:new pt({color:$p}),this.maxAngle_=t.maxAngle!==void 0?t.maxAngle:Math.PI/4,this.placement_=t.placement!==void 0?t.placement:"point",this.overflow_=!!t.overflow,this.stroke_=t.stroke!==void 0?t.stroke:null,this.offsetX_=t.offsetX!==void 0?t.offsetX:0,this.offsetY_=t.offsetY!==void 0?t.offsetY:0,this.backgroundFill_=t.backgroundFill?t.backgroundFill:null,this.backgroundStroke_=t.backgroundStroke?t.backgroundStroke:null,this.padding_=t.padding===void 0?null:t.padding,this.declutterMode_=t.declutterMode}clone(){let t=this.getScale();return new n({font:this.getFont(),placement:this.getPlacement(),repeat:this.getRepeat(),maxAngle:this.getMaxAngle(),overflow:this.getOverflow(),rotation:this.getRotation(),rotateWithView:this.getRotateWithView(),keepUpright:this.getKeepUpright(),scale:Array.isArray(t)?t.slice():t,text:this.getText(),textAlign:this.getTextAlign(),justify:this.getJustify(),textBaseline:this.getTextBaseline(),fill:this.getFill()instanceof pt?this.getFill().clone():this.getFill(),stroke:this.getStroke()?this.getStroke().clone():void 0,offsetX:this.getOffsetX(),offsetY:this.getOffsetY(),backgroundFill:this.getBackgroundFill()?this.getBackgroundFill().clone():void 0,backgroundStroke:this.getBackgroundStroke()?this.getBackgroundStroke().clone():void 0,padding:this.getPadding()||void 0,declutterMode:this.getDeclutterMode()})}getOverflow(){return this.overflow_}getFont(){return this.font_}getMaxAngle(){return this.maxAngle_}getPlacement(){return this.placement_}getRepeat(){return this.repeat_}getOffsetX(){return this.offsetX_}getOffsetY(){return this.offsetY_}getFill(){return this.fill_}getRotateWithView(){return this.rotateWithView_}getKeepUpright(){return this.keepUpright_}getRotation(){return this.rotation_}getScale(){return this.scale_}getScaleArray(){return this.scaleArray_}getStroke(){return this.stroke_}getText(){return this.text_}getTextAlign(){return this.textAlign_}getJustify(){return this.justify_}getTextBaseline(){return this.textBaseline_}getBackgroundFill(){return this.backgroundFill_}getBackgroundStroke(){return this.backgroundStroke_}getPadding(){return this.padding_}getDeclutterMode(){return this.declutterMode_}setOverflow(t){this.overflow_=t}setFont(t){this.font_=t}setMaxAngle(t){this.maxAngle_=t}setOffsetX(t){this.offsetX_=t}setOffsetY(t){this.offsetY_=t}setPlacement(t){this.placement_=t}setRepeat(t){this.repeat_=t}setRotateWithView(t){this.rotateWithView_=t}setKeepUpright(t){this.keepUpright_=t}setFill(t){this.fill_=t}setRotation(t){this.rotation_=t}setScale(t){this.scale_=t,this.scaleArray_=mt(t!==void 0?t:1)}setStroke(t){this.stroke_=t}setText(t){this.text_=t}setTextAlign(t){this.textAlign_=t}setJustify(t){this.justify_=t}setTextBaseline(t){this.textBaseline_=t}setBackgroundFill(t){this.backgroundFill_=t}setBackgroundStroke(t){this.backgroundStroke_=t}setPadding(t){this.padding_=t}},_i=ql;function de(n,t){return(n.get("priority")||0)-(t.get("priority")||0)}function mf(n){let t=n.get("pin");return!t||fe(t)||t.insideHighlightedZone||Qn(t)?null:$l(t,!1)}function pf(n){let t=n.get("pin");return!t||!u.highlightedZones.size||!t.insideHighlightedZone||fe(t)||Qn(t)?null:$l(t,!1)}function _f(n){let t=n.get("pin");return!t||fe(t)||!u.pinLabelsVisible||!tr()?null:Cf(t)}function yf(n){let t=n.get("pin");if(!t||fe(t)||t.insideHighlightedZone||Qn(t)||tr())return null;let e=u.fitZoom+Math.log2(Mf(t.category));return(u.engine.getView().getZoom()||0)<e?null:bo(t,!1)}function xf(n){let t=n.get("pin");return!t||fe(t)||t.insideHighlightedZone||Qn(t)||!tr()?null:bo(t,!1)}function Ef(n){let t=n.get("pin");return!t||!u.highlightedZones.size||!t.insideHighlightedZone||fe(t)||Qn(t)?null:bo(t,!1)}function wf(n){let t=n.get("pin");if(!t||fe(t))return null;if(t.category.displayType==="text")return bo(t,t===u.selectedPin);let e=$l(t,t===u.selectedPin);return t===u.hoveredPin||t===u.selectedPin?[e,Cf(t)]:e}function $l(n,t){let e=`marker:${n.category.id}:${t?1:0}`;if(u.styleCache.has(e))return u.styleCache.get(e);let i=Nr(n.category),r=t?2e7:n.priority,s=u.markerIcons.get(Sf(n.category)),o;return s?o=new It({image:new pn({src:s,width:t?36:31,height:t?36:31}),zIndex:r}):o=new It({text:new _i({text:Fi(n.category.title),font:`900 ${t?15:13}px Inter, sans-serif`,fill:new pt({color:i}),stroke:new Mt({color:Fr(),width:t?4:3})}),zIndex:r}),u.styleCache.set(e,o),o}function Cf(n){let t=`marker-label:${n.location.id}`;if(u.styleCache.has(t))return u.styleCache.get(t);let e=new It({text:new _i({text:n.location.title,offsetY:21,font:'700 10px "Arial Narrow", "Roboto Condensed", sans-serif',fill:new pt({color:"#f4f6ed"}),stroke:new Mt({color:"rgba(0,0,0,0.98)",width:3}),backgroundFill:new pt({color:"rgba(10,13,9,0.72)"}),padding:[2,4,2,4],overflow:!0}),zIndex:n.priority});return u.styleCache.set(t,e),e}function vf(n){if(!n.iconAsset)return;let t=Sf(n);if(u.markerIcons.has(t))return;u.markerIcons.set(t,null);let e=new Image;e.onload=()=>{let i=document.createElement("canvas");i.width=64,i.height=64;let r=i.getContext("2d"),s=Nr(n),o=document.createElement("canvas");o.width=64,o.height=64;let a=o.getContext("2d");a.imageSmoothingEnabled=!n.iconPicture,a.drawImage(e,6,6,52,52),n.iconPicture||(a.globalCompositeOperation="source-in",a.fillStyle=s,a.fillRect(0,0,64,64));let l=document.createElement("canvas");l.width=64,l.height=64;let h=l.getContext("2d");h.drawImage(e,6,6,52,52),h.globalCompositeOperation="source-in",h.fillStyle=Fr(),h.fillRect(0,0,64,64);for(let c=-3;c<=3;c++)for(let d=-3;d<=3;d++)d*d+c*c<=10&&r.drawImage(l,d,c);r.drawImage(o,0,0),u.markerIcons.set(t,i.toDataURL("image/png")),Jp(),u.layers.pins.changed(),u.layers.zonePins.changed(),u.layers.priority.changed()},e.onerror=()=>u.markerIcons.set(t,!1),e.src=fl(n.iconAsset)}function Jp(){for(let n of u.styleCache.keys())n.startsWith("marker:")&&u.styleCache.delete(n)}function Sf(n){return`${n.iconAsset||""}:${Nr(n)}:${u.map?.iconOutset||"light"}`}function bo(n,t){let e=`text:${n.location.id}:${t?1:0}`;if(u.styleCache.has(e))return u.styleCache.get(e);let r=[new It({text:new _i({text:n.location.title,font:`${t?"900":"800"} 14px "Arial Narrow", "Roboto Condensed", sans-serif`,fill:new pt({color:t?"#d6f36b":"#f3f5e9"}),stroke:new Mt({color:"rgba(0,0,0,0.95)",width:4}),backgroundFill:new pt({color:t?"rgba(17,21,14,0.9)":"rgba(10,13,9,0.58)"}),backgroundStroke:t?new Mt({color:"#d6f36b",width:1}):void 0,padding:[3,6,3,6],overflow:!0}),zIndex:t?2e7:n.priority+3e6})];return u.styleCache.set(e,r),r}function Jl(n,t){let e=n.get("gridCell");if(!e)return null;let i=e.role==="leaf",r=e.role==="scope",s=e.role==="neighbor",o=i||r?15:s?10:11,l=`${i||r?900:s?750:800} ${o}px ui-monospace, SFMono-Regular, Menlo, monospace`,h=s?[2,4,2,4]:[3,5,3,5],c=Qp(e,l,o,h,t);if(e.role==="child"&&(!c||!u.subgridVisible))return null;let d=r&&u.subgridVisible,f=`grid:${e.hash}:${e.role}:${e.contextDistance}:${c?1:0}:${d?1:0}`;if(u.styleCache.has(f))return u.styleCache.get(f);let g=Tn[Math.max(0,me.indexOf(e.hash[e.hash.length-1]))%Tn.length],m=new It({fill:r?void 0:new pt({color:s?`rgba(3, 5, 3, ${Math.min(.52,.3+e.contextDistance*.06)})`:di(g,i?.14:.055)}),stroke:new Mt({color:i||r?"#ffffff":di(g,s?.44:.82),width:i?2.5:r?d?1.8:2.5:s?1:1.4}),text:c&&!d?new _i({text:e.hash,font:l,fill:new pt({color:i||r?"#ffffff":s?di(g,.72):g}),stroke:new Mt({color:"rgba(0,0,0,0.96)",width:4}),backgroundFill:new pt({color:s?"rgba(4,6,4,0.88)":"rgba(9,12,8,0.76)"}),padding:h,overflow:!0}):void 0,zIndex:i||r?100:n.get("priority")});return u.styleCache.set(f,m),m}function Qp(n,t,e,i,r){if(!r)return!0;let s=t_(n.hash,t)+i[1]+i[3],o=e+i[0]+i[2];return s<=(n.extent[2]-n.extent[0])/r&&o<=(n.extent[3]-n.extent[1])/r}var ff=document.createElement("canvas").getContext("2d"),gf=new Map;function t_(n,t){let e=`${t}|${n}`,i=gf.get(e);return i===void 0&&(ff.font=t,i=ff.measureText(n).width,gf.set(e,i)),i}var e_=new It({fill:new pt({color:"rgba(3, 5, 3, 0.62)"})});function Rf(){return u.zonesVisible?e_:null}function Tf(n){if(!u.zonesVisible)return null;let t=n.get("zone"),e=n.get("child"),i=u.highlightedZones.has(t.id),r=Af(t.id),s=`zone:${t.id}:${e?1:0}:${i?1:r?2:0}`;if(u.styleCache.has(s))return u.styleCache.get(s);let o=n.get("color");if(r){let h=new It({stroke:new Mt({color:di(o,e?.34:.44),width:e?1:1.3,lineDash:e?[3,4]:[7,5]}),zIndex:e?101:100});return u.styleCache.set(s,h),h}let a=new It({fill:new pt({color:di(o,e?.035:.07)}),stroke:new Mt({color:di(o,e?.5:.72),width:e?1.2:1.8,lineDash:e?[3,4]:[7,5]})});if(!i)return u.styleCache.set(s,a),a;let l=[new It({stroke:new Mt({color:"rgba(255,255,255,0.94)",width:5}),zIndex:9e3}),new It({fill:new pt({color:di(o,.22)}),stroke:new Mt({color:o,width:2.6}),zIndex:9001})];return u.styleCache.set(s,l),l}function If(n){if(!u.zonesVisible||tr())return null;let t=n.get("child"),e=u.highlightedZones.has(n.get("zone").id),i=u.engine.getView().getZoom()||0;if(!e&&t&&i<u.fitZoom+3)return null;let r=n.get("span")/u.engine.getView().getResolution();return!e&&u.zoneTitleCount>40&&r<52?null:Lf(n)}function bf(n){return!u.zonesVisible||!tr()?null:Lf(n)}function Lf(n){let t=n.get("child"),e=n.get("zone"),i=u.highlightedZones.has(e.id),r=Af(e.id),s=`zone-title:${e.id}:${t?1:0}:${i?1:r?2:0}`;if(u.styleCache.has(s))return u.styleCache.get(s);let o=n.get("color"),a=new It({text:new _i({text:e.title.toLocaleUpperCase(),font:`${t?"700 12px":"800 14px"} "Arial Narrow", "Roboto Condensed", sans-serif`,fill:new pt({color:i?"#11140f":r?"rgba(185,192,177,0.56)":t?"#c7ccbd":"#f1f4e7"}),stroke:new Mt({color:i?"rgba(255,255,255,0.96)":r?"rgba(0,0,0,0.82)":"rgba(0,0,0,0.95)",width:i?2:r?3:4}),backgroundFill:new pt({color:i?o:r?"rgba(4,6,4,0.84)":"rgba(11,14,10,0.72)"}),backgroundStroke:new Mt({color:i?"#ffffff":di(o,r?.24:.55),width:i?2:1}),padding:[5,8,5,8],overflow:!0}),zIndex:i?91e5:n.get("priority")});return u.styleCache.set(s,a),a}function Af(n){if(!u.highlightedZones.size||u.highlightedZones.has(n))return!1;for(let t of u.highlightedZones)if(i_(n,t))return!1;return!0}function i_(n,t){let e=new Set,i=u.zoneRecords.get(t)?.zone.parentRegionId;for(;i!=null&&!e.has(i);){if(i===n)return!0;e.add(i),i=u.zoneRecords.get(i)?.zone.parentRegionId}return!1}var Ql=class n extends Ge{constructor(t,e){super(),e&&!Array.isArray(t[0])?this.setFlatCoordinates(e,t):this.setCoordinates(t,e)}appendPoint(t){ve(this.flatCoordinates,t.getFlatCoordinates()),this.changed()}clone(){let t=new n(this.flatCoordinates.slice(),this.layout);return t.applyProperties(this),t}closestPointXY(t,e,i,r){if(r<Ii(this.getExtent(),t,e))return r;let s=this.flatCoordinates,o=this.stride;for(let a=0,l=s.length;a<l;a+=o){let h=_e(t,e,s[a],s[a+1]);if(h<r){r=h;for(let c=0;c<o;++c)i[c]=s[a+c];i.length=o}}return r}getCoordinates(){return Ye(this.flatCoordinates,0,this.flatCoordinates.length,this.stride)}getPoint(t){let e=this.flatCoordinates.length/this.stride;return t<0||e<=t?null:new ui(this.flatCoordinates.slice(t*this.stride,(t+1)*this.stride),this.layout)}getPoints(){let t=this.flatCoordinates,e=this.layout,i=this.stride,r=[];for(let s=0,o=t.length;s<o;s+=i){let a=new ui(t.slice(s,s+i),e);r.push(a)}return r}getType(){return"MultiPoint"}intersectsExtent(t){let e=this.flatCoordinates,i=this.stride;for(let r=0,s=e.length;r<s;r+=i){let o=e[r],a=e[r+1];if(Rr(t,o,a))return!0}return!1}setCoordinates(t,e){this.setLayout(e,t,1),this.flatCoordinates||(this.flatCoordinates=[]),this.flatCoordinates.length=kr(this.flatCoordinates,0,t,this.stride),this.changed()}},Pf=Ql;function Lo(n,t,e,i){let r=[],s=ut();for(let o=0,a=e.length;o<a;++o){let l=e[o];s=bn(n,t,l[0],i),r.push((s[0]+s[2])/2,(s[1]+s[3])/2),t=l[l.length-1]}return r}var tc=class n extends Ge{constructor(t,e,i){if(super(),this.endss_=[],this.flatInteriorPointsRevision_=-1,this.flatInteriorPoints_=null,this.maxDelta_=-1,this.maxDeltaRevision_=-1,this.orientedRevision_=-1,this.orientedFlatCoordinates_=null,!i&&!Array.isArray(t[0])){let r=t,s=[],o=[];for(let a=0,l=r.length;a<l;++a){let h=r[a],c=s.length,d=h.getEnds();for(let f=0,g=d.length;f<g;++f)d[f]+=c;ve(s,h.getFlatCoordinates()),o.push(d)}e=r.length===0?this.getLayout():r[0].getLayout(),t=s,i=o}e!==void 0&&i?(this.setFlatCoordinates(e,t),this.endss_=i):this.setCoordinates(t,e)}appendPolygon(t){let e;if(!this.flatCoordinates)this.flatCoordinates=t.getFlatCoordinates().slice(),e=t.getEnds().slice(),this.endss_.push();else{let i=this.flatCoordinates.length;ve(this.flatCoordinates,t.getFlatCoordinates()),e=t.getEnds().slice();for(let r=0,s=e.length;r<s;++r)e[r]+=i}this.endss_.push(e),this.changed()}clone(){let t=this.endss_.length,e=new Array(t);for(let r=0;r<t;++r)e[r]=this.endss_[r].slice();let i=new n(this.flatCoordinates.slice(),this.layout,e);return i.applyProperties(this),i}closestPointXY(t,e,i,r){return r<Ii(this.getExtent(),t,e)?r:(this.maxDeltaRevision_!=this.getRevision()&&(this.maxDelta_=Math.sqrt(Xd(this.flatCoordinates,0,this.endss_,this.stride,0)),this.maxDeltaRevision_=this.getRevision()),Wd(this.getOrientedFlatCoordinates(),0,this.endss_,this.stride,this.maxDelta_,!0,t,e,i,r))}containsXY(t,e){return Vu(this.getOrientedFlatCoordinates(),0,this.endss_,this.stride,t,e)}getArea(){return zd(this.getOrientedFlatCoordinates(),0,this.endss_,this.stride)}getCoordinates(t){let e;return t!==void 0?(e=this.getOrientedFlatCoordinates().slice(),Tl(e,0,this.endss_,this.stride,t)):e=this.flatCoordinates,Gr(e,0,this.endss_,this.stride)}getEndss(){return this.endss_}getFlatInteriorPoints(){if(this.flatInteriorPointsRevision_!=this.getRevision()){let t=Lo(this.flatCoordinates,0,this.endss_,this.stride);this.flatInteriorPoints_=fo(this.getOrientedFlatCoordinates(),0,this.endss_,this.stride,t),this.flatInteriorPointsRevision_=this.getRevision()}return this.flatInteriorPoints_}getInteriorPoints(){return new Pf(this.getFlatInteriorPoints().slice(),"XYM")}getOrientedFlatCoordinates(){if(this.orientedRevision_!=this.getRevision()){let t=this.flatCoordinates;Zd(t,0,this.endss_,this.stride)?this.orientedFlatCoordinates_=t:(this.orientedFlatCoordinates_=t.slice(),this.orientedFlatCoordinates_.length=Tl(this.orientedFlatCoordinates_,0,this.endss_,this.stride)),this.orientedRevision_=this.getRevision()}return this.orientedFlatCoordinates_}getSimplifiedGeometryInternal(t){let e=[],i=[];return e.length=Yd(this.flatCoordinates,0,this.endss_,this.stride,Math.sqrt(t),e,0,i),new n(e,"XY",i)}getPolygon(t){if(t<0||this.endss_.length<=t)return null;let e;if(t===0)e=0;else{let s=this.endss_[t-1];e=s[s.length-1]}let i=this.endss_[t].slice(),r=i[i.length-1];if(e!==0)for(let s=0,o=i.length;s<o;++s)i[s]-=e;return new Ve(this.flatCoordinates.slice(e,r),this.layout,i)}getPolygons(){let t=this.layout,e=this.flatCoordinates,i=this.endss_,r=[],s=0;for(let o=0,a=i.length;o<a;++o){let l=i[o].slice(),h=l[l.length-1];if(s!==0)for(let d=0,f=l.length;d<f;++d)l[d]-=s;let c=new Ve(e.slice(s,h),t,l);r.push(c),s=h}return r}getType(){return"MultiPolygon"}intersectsExtent(t){return Ku(this.getOrientedFlatCoordinates(),0,this.endss_,this.stride,t)}setCoordinates(t,e){this.setLayout(e,t,3),this.flatCoordinates||(this.flatCoordinates=[]);let i=Dd(this.flatCoordinates,0,t,this.stride,this.endss_);if(i.length===0)this.flatCoordinates.length=0;else{let r=i[i.length-1];this.flatCoordinates.length=r.length===0?0:r[r.length-1]}this.changed()}},Of=tc;function ec(){let n=(u.map.zones||[]).filter(rc);u.renderedShard=u.variant?.shard||0,u.sources.zones.clear(),u.sources.zoneTitles.clear(),u.zoneRecords.clear(),u.highlightedZones.clear(),u.focusedZoneID=null,u.zoneTitleCount=0,Ao(!0),v.zoneIndex.hidden=n.length===0,v.zoneCount.textContent=Xe(n.length);for(let t of n){let e=ut(),i=[],r=!1;for(let l of t.features||[]){let h=s_(l);h&&(r=!0,i.push(h),As(e,h.getExtent()),u.sources.zones.addFeature(new ki({geometry:h,zone:t,color:ho(t.id),child:t.parentRegionId!=null})))}if(!r)continue;let s=ho(t.id),o=t.center?Mo(t.center.lat,t.center.lng):Kt(e),a=Math.max(e[2]-e[0],e[3]-e[1]);u.sources.zoneTitles.addFeature(new ki({geometry:new ui(o),zone:t,color:s,child:t.parentRegionId!=null,span:a,priority:(t.parentRegionId==null?2e6:1e6)+Math.round(a)})),u.zoneRecords.set(t.id,{zone:t,extent:e.slice(),geometries:i,color:s})}u.zoneTitleCount=u.sources.zoneTitles.getFeatures().length,kf(),n_()}function kf(){if(u.sources.zoneScrim.clear(),!u.highlightedZones.size)return;let[n,t,e,i]=u.projection.getExtent(),r=[Df([[n,t],[e,t],[e,i],[n,i],[n,t]],!0)];for(let s of u.highlightedZones)for(let o of u.zoneRecords.get(s)?.geometries||[]){let a=o.getType()==="MultiPolygon"?o.getPolygons():[o];for(let l of a)l.getLinearRings().forEach((h,c)=>{r.push(Df(h.getCoordinates(),c>0))})}u.sources.zoneScrim.addFeature(new ki({geometry:new Ve(r)}))}function Df(n,t){let e=0;for(let i=0,r=n.length-1;i<n.length;r=i++)e+=n[r][0]*n[i][1]-n[i][0]*n[r][1];return e<0===t?n:n.slice().reverse()}function n_(){let n=document.createDocumentFragment();for(let{zone:t,depth:e}of r_()){let i=u.zoneRecords.get(t.id);if(!i)continue;let r=document.createElement("button");r.type="button",r.className="zone-index-item",r.dataset.zone=String(t.id),r.style.setProperty("--zone-color",i.color),r.style.setProperty("--zone-depth",String(e)),r.setAttribute("aria-pressed","false"),r.title=`${t.title}: click to jump; right-click to toggle highlight`;let s=document.createElement("span");s.className="zone-index-marker",s.setAttribute("aria-hidden","true");let o=document.createElement("span");o.textContent=t.title,r.append(s,o),n.append(r)}v.zoneList.replaceChildren(n),v.zoneIndex.hidden=u.zoneRecords.size===0}function r_(){let n=[...u.zoneRecords.values()].map(o=>o.zone),t=new Set(n.map(o=>o.id)),e=new Map;for(let o of n){let a=t.has(o.parentRegionId)?o.parentRegionId:null;e.has(a)||e.set(a,[]),e.get(a).push(o)}for(let o of e.values())o.sort((a,l)=>a.title.localeCompare(l.title,void 0,{numeric:!0,sensitivity:"base"}));let i=[],r=new Set,s=(o,a)=>{if(!r.has(o.id)){r.add(o.id),i.push({zone:o,depth:a});for(let l of e.get(o.id)||[])s(l,a+1)}};for(let o of e.get(null)||[])s(o,0);for(let o of n)s(o,0);return i}function Ao(n){u.zonesVisible=n,v.zoneToggle.checked=n,u.layers.zoneScrim.setVisible(n),u.layers.zones.setVisible(n),u.layers.zoneTitles.setVisible(n),u.layers.zoneTitleDetail.setVisible(n)}function Ff(n){let t=u.zoneRecords.get(n);t&&(u.focusedZoneID=n,zf(),Te(),u.engine.getView().fit(t.extent,{size:u.engine.getSize(),padding:[54,54,54,54],maxZoom:Ue(u.variant),duration:220}),v.sidebar.classList.remove("is-open"),v.mobileLegend.setAttribute("aria-expanded","false"))}function Nf(n){u.zoneRecords.has(n)&&(u.highlightedZones.has(n)?u.highlightedZones.delete(n):(u.highlightedZones.add(n),Ao(!0)),u.hoveredPin=null,ic(),nc(),zf(),kf(),u.layers.zones.changed(),u.layers.zoneTitles.changed(),u.layers.zoneTitleDetail.changed())}function zf(){v.zoneIndex.classList.toggle("has-highlights",u.highlightedZones.size>0);for(let n of v.zoneList.querySelectorAll("[data-zone]")){let t=Number(n.dataset.zone),e=u.highlightedZones.has(t);n.classList.toggle("is-highlighted",e),n.classList.toggle("is-current",u.focusedZoneID===t),n.setAttribute("aria-pressed",String(e))}}function s_(n){if(!n?.coordinates)return null;let t=([e,i])=>Mo(i,e);return n.type==="Polygon"?new Ve(n.coordinates.map(e=>e.map(t))):n.type==="MultiPolygon"?new Of(n.coordinates.map(e=>e.map(i=>i.map(t)))):null}function Mo(n,t){let e=u.catalog.tileGrid,i=2**e.sourceZoom,r=(t+180)/360*i,s=n*Math.PI/180,o=(1-Math.asinh(Math.tan(s))/Math.PI)/2*i;return[(r-e.firstTile)*e.tileSize,-(o-e.firstTile)*e.tileSize]}function Gf(){u.sources.pins.clear(),u.sources.text.clear(),u.sources.priority.clear(),u.pins=[],u.pinByID.clear();for(let n of u.map.groups)for(let t of n.categories){t.displayType!=="text"&&vf(t);for(let e of t.locations){let i={location:e,category:t,group:n,coordinate:Mo(e.lat,e.lng),filteredHidden:!1,priority:c_(t,e),feature:null};i.feature=new ki({geometry:new ui(i.coordinate),pin:i,priority:i.priority}),u.pins.push(i),u.pinByID.set(e.id,i),t.displayType==="text"?u.sources.text.addFeature(i.feature):u.sources.pins.addFeature(i.feature)}}he()}function he(){for(let n of u.pins){let t=u.hiddenCategories.has(n.category.id),e=u.search&&!n.location.title.toLocaleLowerCase().includes(u.search);n.filteredHidden=!!(t||e)}ic(),nc(),u.selectedPin?.filteredHidden&&Te()}function ic(){if(!u.highlightedZones.size){for(let t of u.pins)t.insideHighlightedZone=!1;return}let n=[...u.highlightedZones].map(t=>u.zoneRecords.get(t)).filter(Boolean);for(let t of u.pins)t.insideHighlightedZone=n.some(e=>e.geometries.some(i=>o_(i,t.coordinate)))}function o_(n,t){if(n.intersectsCoordinate(t))return!0;let e=n.getClosestPoint(t),i=e[0]-t[0],r=e[1]-t[1];return i*i+r*r<=1}function nc(){u.eligibleLocations=u.pins.filter(n=>!fe(n)).length,We(),u.layers.pins.changed(),u.layers.zonePins.changed(),u.layers.pinLabels.changed(),u.layers.text.changed(),u.layers.zoneText.changed(),u.layers.textDetail.changed(),u.layers.priority.changed(),_n()}function We(){u.sources.priority.clear();for(let n of u.pins){if(fe(n))continue;let t=!!u.search&&n.location.title.toLocaleLowerCase().includes(u.search);(n===u.selectedPin||n===u.hoveredPin||t||$n(n))&&u.sources.priority.addFeature(n.feature)}}function er(n){u.hoveredPin!==n&&(u.hoveredPin=n,u.sources&&(We(),u.layers.pins.changed(),u.layers.priority.changed()))}function Qn(n){return n===u.selectedPin||n===u.hoveredPin||$n(n)||!!u.search&&n.location.title.toLocaleLowerCase().includes(u.search)}function fe(n){return n.filteredHidden||a_(n)||l_(n)||!rc(n.location)}function rc(n){let t=u.variant?.shard;return!t||!n.shard||n.shard===t}function a_(n){return!u.highlightedZones.size||n.insideHighlightedZone||n===u.selectedPin?!1:!(u.search&&n.location.title.toLocaleLowerCase().includes(u.search))}function l_(n){return!u.gridEnabled||!u.gridPrefix||$n(n)||n===u.selectedPin?!1:!(u.search&&n.location.title.toLocaleLowerCase().includes(u.search))}function c_(n,t){return Math.max(0,1e6-Math.min(n.locations.length,999)*1e3)+kd(t.id)%1e3}function Mf(n){return n.locations.length>200?4:n.locations.length>75?2.5:1}function tr(){return(u.engine?.getView().getZoom()||0)>=(u.variant?.maxZoom||0)-.05}function Jr(){if(!u.search){v.searchResults.hidden=!0,v.searchResults.replaceChildren();return}let n=u.pins.filter(e=>!u.hiddenCategories.has(e.category.id)&&e.location.title.toLocaleLowerCase().includes(u.search)).sort((e,i)=>e.location.title.localeCompare(i.location.title)).slice(0,20),t=document.createDocumentFragment();if(!n.length){let e=document.createElement("p");e.className="search-empty",e.textContent="No visible locations match.",t.append(e)}for(let e of n){let i=document.createElement("button");i.type="button",i.className="search-result",i.dataset.location=String(e.location.id),Kn(i,e.category);let r=document.createElement("span");r.className="result-dot",Bn(r,e.category,Fi(e.category.title));let s=document.createElement("span"),o=document.createElement("strong");o.textContent=e.location.title;let a=document.createElement("small");a.textContent=`${e.category.title} \xB7 ${e.group.title}`,s.append(o,a),i.append(r,s),t.append(i)}v.searchResults.replaceChildren(t),v.searchResults.hidden=!1}function Xf(n){let t=[],e=[];for(let i of n){let r=[];for(let s of i.categories)(s.displayType==="text"?e:r).push(s);r.length&&t.push({key:`group-${i.id}`,title:i.title,categories:r})}return e.length&&t.unshift({key:"text",title:"Text",categories:e}),t}function Wf(){let n=document.createDocumentFragment();for(let t of u.map.sections){let e=document.createElement("section");e.className="layer-section",e.dataset.layerSection=t.key;let i=t.categories.reduce((s,o)=>s+o.locations.length,0);e.append(h_(t.key,t.title,i));let r=document.createElement("div");r.className="category-toggles";for(let s of t.categories)r.append(u_(s));e.append(r),n.append(e)}v.legend.replaceChildren(n),Po(),Ni()}function h_(n,t,e){let i=document.createElement("div");i.className="layer-header";let r=document.createElement("button");r.type="button",r.className="layer-title",r.dataset.section=n;let s=document.createElement("span");s.className="layer-chevron",s.setAttribute("aria-hidden","true"),s.innerHTML='<svg viewBox="0 0 24 24"><path d="m9 6 6 6-6 6"/></svg>';let o=document.createElement("span");o.textContent=t;let a=document.createElement("span");a.className="layer-count",a.textContent=Xe(e),r.append(s,o,a);let l=Uf(`Show only ${t}`);l.dataset.onlySection=n;let h=document.createElement("label");h.className="layer-switch";let c=document.createElement("input");c.type="checkbox",c.dataset.sectionToggle=n,c.setAttribute("aria-label",`Show ${t}`);let d=document.createElement("span");return d.setAttribute("aria-hidden","true"),h.append(c,d),i.append(r,l,h),i}function Uf(n){let t=document.createElement("button");return t.type="button",t.className="only-button",t.dataset.label=n,t.setAttribute("aria-label",n),t.innerHTML='<svg viewBox="0 0 16 16" aria-hidden="true"><circle cx="8" cy="8" r="4.6"/><circle cx="8" cy="8" r="1.3" fill="currentColor" stroke="none"/><path d="M8 1v2M8 13v2M1 8h2M13 8h2"/></svg>',t}function u_(n){let t=n.displayType==="text",e=document.createElement("label");e.className="category-row",Kn(e,n);let i=document.createElement("input");i.type="checkbox",i.dataset.category=String(n.id),i.checked=!u.hiddenCategories.has(n.id);let r=document.createElement("span");t?(r.className="text-symbol",r.textContent="Tt",r.title="Drawn as a text label"):(r.className="category-icon",Bn(r,n,Fi(n.title)),r.title=n.icon||n.title);let s=document.createElement("span");s.className="category-name",s.textContent=n.title;let o=document.createElement("span");o.className="category-count",o.textContent=Xe(n.locations.length);let a=Uf(`Show only ${n.title}`);return a.dataset.onlyCategory=String(n.id),e.append(i,r,s,a,o),e}function sc(n){if(u.collapsedSections.clear(),n)for(let t of v.layers.querySelectorAll("[data-section]"))u.collapsedSections.add(t.dataset.section);Po()}function Po(){for(let n of v.layers.querySelectorAll("[data-section]")){let t=u.collapsedSections.has(n.dataset.section);n.setAttribute("aria-expanded",String(!t)),n.closest(".layer-section").classList.toggle("is-collapsed",t)}hi()}function Qr(n){if(u.hiddenCategories.clear(),!n)for(let t of u.map.groups)for(let e of t.categories)u.hiddenCategories.add(e.id);zr(),he(),Jr(),Ni()}function zr(){for(let n of document.querySelectorAll("[data-category]"))n.checked=!u.hiddenCategories.has(Number(n.dataset.category))}function Yf(n){let t=u.map.sections.find(i=>i.key===n);if(!t)return;let e=t.categories.some(i=>!u.hiddenCategories.has(i.id));for(let i of t.categories)e?u.hiddenCategories.add(i.id):u.hiddenCategories.delete(i.id);zr(),he(),Ni()}function Vf(n){if(u.map){if(d_(n)){Qr(!0);return}u.hiddenCategories.clear();for(let t of u.map.sections){let e=n.section===t.key;for(let i of t.categories)!e&&n.category!==i.id&&u.hiddenCategories.add(i.id)}zr(),he(),Jr(),Ni()}}function d_(n){for(let t of u.map.sections)for(let e of t.categories)if((n.section===t.key||n.category===e.id)===u.hiddenCategories.has(e.id))return!1;return!0}function f_(){let n=v.soloChip;if(!u.map){n.hidden=!0;return}let t=null,e=0,i=null,r=0;for(let o of u.map.sections){let a=0;for(let l of o.categories)u.hiddenCategories.has(l.id)||(a++,e++,t=l);a>0&&(r++,i=a===o.categories.length?o:null)}let s="";e===1&&t?s=t.title:r===1&&i&&(s=i.title),n.hidden=!s,n.textContent=s?`only: ${s}`:"",n.title=s?`Showing only ${s} \u2014 click to show everything`:""}function Ni(){if(u.map){for(let n of u.map.sections){let t=v.legend.querySelector(`input[data-section-toggle="${n.key}"]`);t&&(t.checked=n.categories.some(e=>!u.hiddenCategories.has(e.id)))}f_(),hi()}}async function Zf(n){let[t,e]=await Promise.all([fetch(`/static/catalog/${n.id}.json`).then(r=>r.json()),fetch(`/static/catalog/${n.id}.bin`).then(r=>r.arrayBuffer())]),i=t.groups.flatMap(r=>r.categories);return g_(e,i),{...n,variants:t.variants,groups:t.groups,zones:t.zones||[],sections:Xf(t.groups)}}function g_(n,t){let e=new DataView(n);if(String.fromCharCode(...new Uint8Array(n,0,8))!=="ATLASLOC")throw new Error("location payload is not in the expected form");let r=e.getUint16(8,!0);if(r!==2)throw new Error(`location payload is version ${r}, and this reads 2`);let s=e.getUint32(10,!0),o=16,a=new Int32Array(n,o,s),l=new Float32Array(n,o+=s*4,s),h=new Float32Array(n,o+=s*4,s),c=new Int32Array(n,o+=s*4,s),d=new Int32Array(n,o+=s*4,s),f=new Uint32Array(n,o+=s*4,s+1),g=new Uint16Array(n,o+=(s+1)*4,s),m=new Uint8Array(n,o+s*2),_=new TextDecoder;for(let p of t)p.locations=[];for(let p=0;p<s;p++)t[g[p]].locations.push({id:a[p],title:_.decode(m.subarray(f[p],f[p+1])),lat:l[p],lng:h[p],regionId:c[p]||void 0,shard:d[p]||void 0})}async function Nd(n){return u.textByMap.has(n)||u.textByMap.set(n,fetch(`/static/catalog/${n}.text`).then(t=>t.json()).catch(()=>({}))),u.textByMap.get(n)}var Pt={ADD:"add",REMOVE:"remove"};var Kf={LENGTH:"length"},ir=class extends Lt{constructor(t,e,i){super(t),this.element=e,this.index=i}},oc=class extends wt{constructor(t,e){if(super(),this.on,this.once,this.un,e=e||{},this.unique_=!!e.unique,this.array_=t??[],this.unique_)for(let i=1,r=this.array_.length;i<r;++i)this.assertUnique_(this.array_[i],i);this.updateLength_()}clear(){for(;this.getLength()>0;)this.pop()}extend(t){for(let e=0,i=t.length;e<i;++e)this.push(t[e]);return this}forEach(t){let e=this.array_;for(let i=0,r=e.length;i<r;++i)t(e[i],i,e)}getArray(){return this.array_}item(t){return this.array_[t]}getLength(){return this.get(Kf.LENGTH)}insertAt(t,e){if(t<0||t>this.getLength())throw new Error("Index out of bounds: "+t);this.unique_&&this.assertUnique_(e),this.array_.splice(t,0,e),this.updateLength_(),this.dispatchEvent(new ir(Pt.ADD,e,t))}pop(){return this.removeAt(this.getLength()-1)}push(t){let e=this.getLength();return this.insertAt(e,t),this.getLength()}remove(t){let e=this.array_;for(let i=0,r=e.length;i<r;++i)if(e[i]===t)return this.removeAt(i)}removeAt(t){if(t<0||t>=this.getLength())return;let e=this.array_[t];return this.array_.splice(t,1),this.updateLength_(),this.dispatchEvent(new ir(Pt.REMOVE,e,t)),e}setAt(t,e){let i=this.getLength();if(t>=i){this.insertAt(t,e);return}if(t<0)throw new Error("Index out of bounds: "+t);this.unique_&&this.assertUnique_(e,t);let r=this.array_[t];this.array_[t]=e,this.dispatchEvent(new ir(Pt.REMOVE,r,t)),this.dispatchEvent(new ir(Pt.ADD,e,t))}updateLength_(){this.set(Kf.LENGTH,this.array_.length)}assertUnique_(t,e){let i=this.array_;for(let r=0,s=i.length;r<s;++r)if(i[r]===t&&r!==e)throw new Error("Duplicate item added to a unique collection")}},Dt=oc;var ac=class extends Lt{constructor(t,e,i){super(t),this.map=e,this.frameState=i!==void 0?i:null}},Ui=ac;var lc=class extends Ui{constructor(t,e,i,r,s,o){super(t,e,s),this.originalEvent=i,this.pixel_=null,this.coordinate_=null,this.dragging=r!==void 0?r:!1,this.activePointers=o}get pixel(){return this.pixel_||(this.pixel_=this.map.getEventPixel(this.originalEvent)),this.pixel_}set pixel(t){this.pixel_=t}get coordinate(){return this.coordinate_||(this.coordinate_=this.map.getCoordinateFromPixel(this.pixel)),this.coordinate_}set coordinate(t){this.coordinate_=t}preventDefault(){super.preventDefault(),"preventDefault"in this.originalEvent&&this.originalEvent.preventDefault()}stopPropagation(){super.stopPropagation(),"stopPropagation"in this.originalEvent&&this.originalEvent.stopPropagation()}},Be=lc;var at={SINGLECLICK:"singleclick",CLICK:P.CLICK,DBLCLICK:P.DBLCLICK,POINTERDRAG:"pointerdrag",POINTERMOVE:"pointermove",POINTERDOWN:"pointerdown",POINTERUP:"pointerup",POINTEROVER:"pointerover",POINTEROUT:"pointerout",POINTERENTER:"pointerenter",POINTERLEAVE:"pointerleave",POINTERCANCEL:"pointercancel"};var ts={POINTERMOVE:"pointermove",POINTERDOWN:"pointerdown",POINTERUP:"pointerup",POINTEROVER:"pointerover",POINTEROUT:"pointerout",POINTERENTER:"pointerenter",POINTERLEAVE:"pointerleave",POINTERCANCEL:"pointercancel"};var cc=class extends Di{constructor(t,e){super(t),this.map_=t,this.clickTimeoutId_,this.emulateClicks_=!1,this.dragging_=!1,this.dragListenerKeys_=[],this.moveTolerance_=e===void 0?1:e,this.down_=null;let i=this.map_.getViewport();this.activePointers_=[],this.trackedTouches_={},this.element_=i,this.pointerdownListenerKey_=Z(i,ts.POINTERDOWN,this.handlePointerDown_,this),this.originalPointerMoveEvent_,this.relayedListenerKey_=Z(i,ts.POINTERMOVE,this.relayMoveEvent_,this),this.boundHandleTouchMove_=this.handleTouchMove_.bind(this),this.element_.addEventListener(P.TOUCHMOVE,this.boundHandleTouchMove_,qs?{passive:!1}:!1)}emulateClick_(t){let e=new Be(at.CLICK,this.map_,t);this.dispatchEvent(e),this.clickTimeoutId_!==void 0?(clearTimeout(this.clickTimeoutId_),this.clickTimeoutId_=void 0,e=new Be(at.DBLCLICK,this.map_,t),this.dispatchEvent(e)):this.clickTimeoutId_=setTimeout(()=>{this.clickTimeoutId_=void 0;let i=new Be(at.SINGLECLICK,this.map_,t);this.dispatchEvent(i)},250)}updateActivePointers_(t){let e=t,i=e.pointerId;if(e.type==at.POINTERUP||e.type==at.POINTERCANCEL){delete this.trackedTouches_[i];for(let r in this.trackedTouches_)if(this.trackedTouches_[r].target!==e.target){delete this.trackedTouches_[r];break}}else(e.type==at.POINTERDOWN||e.type==at.POINTERMOVE)&&(this.trackedTouches_[i]=e);this.activePointers_=Object.values(this.trackedTouches_)}handlePointerUp_(t){this.updateActivePointers_(t);let e=new Be(at.POINTERUP,this.map_,t,void 0,void 0,this.activePointers_);this.dispatchEvent(e),this.emulateClicks_&&!e.defaultPrevented&&!this.dragging_&&this.isMouseActionButton_(t)&&this.emulateClick_(this.down_),this.activePointers_.length===0&&(this.dragListenerKeys_.forEach(J),this.dragListenerKeys_.length=0,this.dragging_=!1,this.down_=null)}isMouseActionButton_(t){return t.button===0}handlePointerDown_(t){this.emulateClicks_=this.activePointers_.length===0,this.updateActivePointers_(t);let e=new Be(at.POINTERDOWN,this.map_,t,void 0,void 0,this.activePointers_);if(this.dispatchEvent(e),this.down_=new PointerEvent(t.type,t),Object.defineProperty(this.down_,"target",{writable:!1,value:t.target}),this.dragListenerKeys_.length===0){let i=this.map_.getOwnerDocument();this.dragListenerKeys_.push(Z(i,at.POINTERMOVE,this.handlePointerMove_,this),Z(i,at.POINTERUP,this.handlePointerUp_,this),Z(this.element_,at.POINTERCANCEL,this.handlePointerUp_,this)),this.element_.getRootNode&&this.element_.getRootNode()!==i&&this.dragListenerKeys_.push(Z(this.element_.getRootNode(),at.POINTERUP,this.handlePointerUp_,this))}}handlePointerMove_(t){if(this.isMoving_(t)){this.updateActivePointers_(t),this.dragging_=!0;let e=new Be(at.POINTERDRAG,this.map_,t,this.dragging_,void 0,this.activePointers_);this.dispatchEvent(e)}}relayMoveEvent_(t){this.originalPointerMoveEvent_=t;let e=!!(this.down_&&this.isMoving_(t));this.dispatchEvent(new Be(at.POINTERMOVE,this.map_,t,e))}handleTouchMove_(t){let e=this.originalPointerMoveEvent_;(!e||e.defaultPrevented)&&(typeof t.cancelable!="boolean"||t.cancelable===!0)&&t.preventDefault()}isMoving_(t){return this.dragging_||Math.abs(t.clientX-this.down_.clientX)>this.moveTolerance_||Math.abs(t.clientY-this.down_.clientY)>this.moveTolerance_}disposeInternal(){this.relayedListenerKey_&&(J(this.relayedListenerKey_),this.relayedListenerKey_=null),this.element_.removeEventListener(P.TOUCHMOVE,this.boundHandleTouchMove_),this.pointerdownListenerKey_&&(J(this.pointerdownListenerKey_),this.pointerdownListenerKey_=null),this.dragListenerKeys_.forEach(J),this.dragListenerKeys_.length=0,this.element_=null,super.disposeInternal()}},Bf=cc;var je={POSTRENDER:"postrender",MOVESTART:"movestart",MOVEEND:"moveend",LOADSTART:"loadstart",LOADEND:"loadend"};var kt={LAYERGROUP:"layergroup",SIZE:"size",TARGET:"target",VIEW:"view"};var es=1/0,hc=class{constructor(t,e){this.priorityFunction_=t,this.keyFunction_=e,this.elements_=[],this.priorities_=[],this.queuedElements_={}}clear(){this.elements_.length=0,this.priorities_.length=0,ze(this.queuedElements_)}dequeue(){let t=this.elements_,e=this.priorities_,i=t[0];t.length==1?(t.length=0,e.length=0):(t[0]=t.pop(),e[0]=e.pop(),this.siftUp_(0));let r=this.keyFunction_(i);return delete this.queuedElements_[r],i}enqueue(t){K(!(this.keyFunction_(t)in this.queuedElements_),"Tried to enqueue an `element` that was already added to the queue");let e=this.priorityFunction_(t);return e!=es?(this.elements_.push(t),this.priorities_.push(e),this.queuedElements_[this.keyFunction_(t)]=!0,this.siftDown_(0,this.elements_.length-1),!0):!1}getCount(){return this.elements_.length}getLeftChildIndex_(t){return t*2+1}getRightChildIndex_(t){return t*2+2}getParentIndex_(t){return t-1>>1}heapify_(){let t;for(t=(this.elements_.length>>1)-1;t>=0;t--)this.siftUp_(t)}isEmpty(){return this.elements_.length===0}isKeyQueued(t){return t in this.queuedElements_}isQueued(t){return this.isKeyQueued(this.keyFunction_(t))}siftUp_(t){let e=this.elements_,i=this.priorities_,r=e.length,s=e[t],o=i[t],a=t;for(;t<r>>1;){let l=this.getLeftChildIndex_(t),h=this.getRightChildIndex_(t),c=h<r&&i[h]<i[l]?h:l;e[t]=e[c],i[t]=i[c],t=c}e[t]=s,i[t]=o,this.siftDown_(a,t)}siftDown_(t,e){let i=this.elements_,r=this.priorities_,s=i[e],o=r[e];for(;e>t;){let a=this.getParentIndex_(e);if(r[a]>o)i[e]=i[a],r[e]=r[a],e=a;else break}i[e]=s,r[e]=o}reprioritize(){let t=this.priorityFunction_,e=this.elements_,i=this.priorities_,r=0,s=e.length,o,a,l;for(a=0;a<s;++a)o=e[a],l=t(o),l==es?delete this.queuedElements_[this.keyFunction_(o)]:(i[r]=l,e[r++]=o);e.length=r,i.length=r,this.heapify_()}},jf=hc;var uc=class extends jf{constructor(t,e){super(i=>t.apply(null,i),i=>i[0].getKey()),this.boundHandleTileChange_=this.handleTileChange.bind(this),this.tileChangeCallback_=e,this.tilesLoading_=0,this.tilesLoadingKeys_={}}enqueue(t){let e=super.enqueue(t);return e&&t[0].addEventListener(P.CHANGE,this.boundHandleTileChange_),e}getTilesLoading(){return this.tilesLoading_}handleTileChange(t){let e=t.target,i=e.getState();if(i===D.LOADED||i===D.ERROR||i===D.EMPTY){i!==D.ERROR&&e.removeEventListener(P.CHANGE,this.boundHandleTileChange_);let r=e.getKey();r in this.tilesLoadingKeys_&&(delete this.tilesLoadingKeys_[r],--this.tilesLoading_),this.tileChangeCallback_()}}loadMoreTiles(t,e){let i=0;for(;this.tilesLoading_<t&&i<e&&this.getCount()>0;){let r=this.dequeue()[0],s=r.getKey();r.getState()===D.IDLE&&!(s in this.tilesLoadingKeys_)&&(this.tilesLoadingKeys_[s]=!0,++this.tilesLoading_,++i,r.load())}}},Hf=uc;function qf(n,t,e,i,r){if(!n||!(e in n.wantedTiles))return es;if(!n.wantedTiles[e][t.getKey()])return es;let s=n.viewState.center,o=i[0]-s[0],a=i[1]-s[1];return 65536*Math.log(r)+Math.sqrt(o*o+a*a)/r}var bt={ANIMATING:0,INTERACTING:1};var ge={CENTER:"center",RESOLUTION:"resolution",ROTATION:"rotation"};function dc(n,t,e){return(function(i,r,s,o,a){if(!i)return;if(!r&&!t)return i;let l=t?0:s[0]*r,h=t?0:s[1]*r,c=a?a[0]:0,d=a?a[1]:0,f=n[0]+l/2+c,g=n[2]-l/2+c,m=n[1]+h/2+d,_=n[3]-h/2+d;f>g&&(f=(g+f)/2,g=f),m>_&&(m=(_+m)/2,_=m);let p=et(i[0],f,g),y=et(i[1],m,_);if(o&&e&&r){let E=30*r;p+=-E*Math.log(1+Math.max(0,f-i[0])/E)+E*Math.log(1+Math.max(0,i[0]-g)/E),y+=-E*Math.log(1+Math.max(0,m-i[1])/E)+E*Math.log(1+Math.max(0,i[1]-_)/E)}return[p,y]})}function $f(n){return n}function fc(n,t,e,i){let r=j(t)/e[0],s=ct(t)/e[1];return i?Math.min(n,Math.max(r,s)):Math.min(n,Math.min(r,s))}function gc(n,t,e){let i=Math.min(n,t),r=50;return i*=Math.log(1+r*Math.max(0,n/t-1))/r+1,e&&(i=Math.max(i,e),i/=Math.log(1+r*Math.max(0,e/n-1))/r+1),et(i,e/2,t*2)}function Jf(n,t,e,i){return t=t!==void 0?t:!0,(function(r,s,o,a){if(r!==void 0){let l=n[0],h=n[n.length-1],c=e?fc(l,e,o,i):l;if(a)return t?gc(r,c,h):et(r,h,c);let d=Math.min(c,r),f=Math.floor(Gn(n,d,s));return n[f]>c&&f<n.length-1?n[f+1]:n[f]}})}function Qf(n,t,e,i,r,s){return i=i!==void 0?i:!0,e=e!==void 0?e:0,(function(o,a,l,h){if(o!==void 0){let c=r?fc(t,r,l,s):t;if(h)return i?gc(o,c,e):et(o,e,c);let d=1e-9,f=Math.ceil(Math.log(t/c)/Math.log(n)-d),g=-a*(.5-d)+.5,m=Math.min(c,o),_=Math.floor(Math.log(t/m)/Math.log(n)+g),p=Math.max(f,_),y=t/Math.pow(n,p);return et(y,e,c)}})}function mc(n,t,e,i,r){return e=e!==void 0?e:!0,(function(s,o,a,l){if(s!==void 0){let h=i?fc(n,i,a,r):n;return!e||!l?et(s,t,h):gc(s,h,t)}})}function nr(n){if(n!==void 0)return 0}function pc(n){if(n!==void 0)return n}function tg(n){let t=2*Math.PI/n;return(function(e,i){if(i)return e;if(e!==void 0)return e=Math.floor(e/t+.5)*t,e})}function eg(n){let t=n===void 0?ye(5):n;return(function(e,i){return i||e===void 0?e:Math.abs(e)<=t?0:e})}var _c=0,xc=class extends wt{constructor(t){super(),this.on,this.once,this.un,t=Object.assign({},t),this.hints_=[0,0],this.animations_=[],this.updateAnimationKey_,this.projection_=Ys(t.projection,"EPSG:3857"),this.viewportSize_=[100,100],this.targetCenter_=null,this.targetResolution_,this.targetRotation_,this.nextCenter_=null,this.nextResolution_,this.nextRotation_,this.cancelAnchor_=void 0,t.projection&&Du(),t.center&&(t.center=we(t.center,this.projection_)),t.extent&&(t.extent=Ce(t.extent,this.projection_)),this.applyOptions_(t)}applyOptions_(t){let e=Object.assign({},t);for(let a in ge)delete e[a];this.setProperties(e,!0);let i=p_(t);this.maxResolution_=i.maxResolution,this.minResolution_=i.minResolution,this.zoomFactor_=i.zoomFactor,this.resolutions_=t.resolutions,this.padding_=t.padding,this.minZoom_=i.minZoom;let r=m_(t),s=i.constraint,o=__(t);this.constraints_={center:r,resolution:s,rotation:o},this.setRotation(t.rotation!==void 0?t.rotation:0),this.setCenterInternal(t.center!==void 0?t.center:null),t.resolution!==void 0?this.setResolution(t.resolution):t.zoom!==void 0&&this.setZoom(t.zoom)}get padding(){return this.padding_}set padding(t){let e=this.padding_;this.padding_=t;let i=this.getCenterInternal();if(i){let r=t||[0,0,0,0];e=e||[0,0,0,0];let s=this.getResolution(),o=s/2*(r[3]-e[3]+e[1]-r[1]),a=s/2*(r[0]-e[0]+e[2]-r[2]);this.setCenterInternal([i[0]+o,i[1]-a])}}getUpdatedOptions_(t){let e=this.getProperties();return e.resolution!==void 0?e.resolution=this.getResolution():e.zoom=this.getZoom(),e.center=this.getCenterInternal(),e.rotation=this.getRotation(),Object.assign({},e,t)}animate(t){this.isDef()&&!this.getAnimating()&&this.resolveConstraints(0);let e=new Array(arguments.length);for(let i=0;i<e.length;++i){let r=arguments[i];r.center&&(r=Object.assign({},r),r.center=we(r.center,this.getProjection())),r.anchor&&(r=Object.assign({},r),r.anchor=we(r.anchor,this.getProjection())),e[i]=r}this.animateInternal.apply(this,e)}animateInternal(t){let e=arguments.length,i;e>1&&typeof arguments[e-1]=="function"&&(i=arguments[e-1],--e);let r=0;for(;r<e&&!this.isDef();++r){let c=arguments[r];c.center&&this.setCenterInternal(c.center),c.zoom!==void 0?this.setZoom(c.zoom):c.resolution&&this.setResolution(c.resolution),c.rotation!==void 0&&this.setRotation(c.rotation)}if(r===e){i&&Oo(i,!0);return}let s=Date.now(),o=this.targetCenter_.slice(),a=this.targetResolution_,l=this.targetRotation_,h=[];for(;r<e;++r){let c=arguments[r],d={start:s,complete:!1,anchor:c.anchor,duration:c.duration!==void 0?c.duration:1e3,easing:c.easing||rd,callback:i};if(c.center&&(d.sourceCenter=o,d.targetCenter=c.center.slice(),o=d.targetCenter),c.zoom!==void 0?(d.sourceResolution=a,d.targetResolution=this.getResolutionForZoom(c.zoom),a=d.targetResolution):c.resolution&&(d.sourceResolution=a,d.targetResolution=c.resolution,a=d.targetResolution),c.rotation!==void 0){d.sourceRotation=l;let f=Ne(c.rotation-l+Math.PI,2*Math.PI)-Math.PI;d.targetRotation=l+f,l=d.targetRotation}y_(d)?d.complete=!0:s+=d.duration,h.push(d)}this.animations_.push(h),this.setHint(bt.ANIMATING,1),this.updateAnimations_()}getAnimating(){return this.hints_[bt.ANIMATING]>0}getInteracting(){return this.hints_[bt.INTERACTING]>0}cancelAnimations(){this.setHint(bt.ANIMATING,-this.hints_[bt.ANIMATING]);let t;for(let e=0,i=this.animations_.length;e<i;++e){let r=this.animations_[e];if(r[0].callback&&Oo(r[0].callback,!1),!t)for(let s=0,o=r.length;s<o;++s){let a=r[s];if(!a.complete){t=a.anchor;break}}}this.animations_.length=0,this.cancelAnchor_=t,this.nextCenter_=null,this.nextResolution_=NaN,this.nextRotation_=NaN}updateAnimations_(){if(this.updateAnimationKey_!==void 0&&(cancelAnimationFrame(this.updateAnimationKey_),this.updateAnimationKey_=void 0),!this.getAnimating())return;let t=Date.now(),e=!1;for(let i=this.animations_.length-1;i>=0;--i){let r=this.animations_[i],s=!0;for(let o=0,a=r.length;o<a;++o){let l=r[o];if(l.complete)continue;let h=t-l.start,c=l.duration>0?h/l.duration:1;c>=1?(l.complete=!0,c=1):s=!1;let d=l.easing(c);if(l.sourceCenter){let f=l.sourceCenter[0],g=l.sourceCenter[1],m=l.targetCenter[0],_=l.targetCenter[1];this.nextCenter_=l.targetCenter;let p=f+d*(m-f),y=g+d*(_-g);this.targetCenter_=[p,y]}if(l.sourceResolution&&l.targetResolution){let f=d===1?l.targetResolution:l.sourceResolution+d*(l.targetResolution-l.sourceResolution);if(l.anchor){let g=this.getViewportSize_(this.getRotation()),m=this.constraints_.resolution(f,0,g,!0);this.targetCenter_=this.calculateCenterZoom(m,l.anchor)}this.nextResolution_=l.targetResolution,this.targetResolution_=f,this.applyTargetState_(!0)}if(l.sourceRotation!==void 0&&l.targetRotation!==void 0){let f=d===1?Ne(l.targetRotation+Math.PI,2*Math.PI)-Math.PI:l.sourceRotation+d*(l.targetRotation-l.sourceRotation);if(l.anchor){let g=this.constraints_.rotation(f,!0);this.targetCenter_=this.calculateCenterRotate(g,l.anchor)}this.nextRotation_=l.targetRotation,this.targetRotation_=f}if(this.applyTargetState_(!0),e=!0,!l.complete)break}if(s){this.animations_[i]=null,this.setHint(bt.ANIMATING,-1),this.nextCenter_=null,this.nextResolution_=NaN,this.nextRotation_=NaN;let o=r[0].callback;o&&Oo(o,!0)}}this.animations_=this.animations_.filter(Boolean),e&&this.updateAnimationKey_===void 0&&(this.updateAnimationKey_=requestAnimationFrame(this.updateAnimations_.bind(this)))}calculateCenterRotate(t,e){let i,r=this.getCenterInternal();return r!==void 0&&(i=[r[0]-e[0],r[1]-e[1]],Pn(i,t-this.getRotation()),fu(i,e)),i}calculateCenterZoom(t,e){let i,r=this.getCenterInternal(),s=this.getResolution();if(r!==void 0&&s!==void 0){let o=e[0]-t*(e[0]-r[0])/s,a=e[1]-t*(e[1]-r[1])/s;i=[o,a]}return i}getViewportSize_(t){let e=this.viewportSize_;if(t){let i=e[0],r=e[1];return[Math.abs(i*Math.cos(t))+Math.abs(r*Math.sin(t)),Math.abs(i*Math.sin(t))+Math.abs(r*Math.cos(t))]}return e}setViewportSize(t){this.viewportSize_=Array.isArray(t)?t.slice():[100,100],this.getAnimating()||this.resolveConstraints(0)}getCenter(){let t=this.getCenterInternal();return t&&Mr(t,this.getProjection())}getCenterInternal(){return this.get(ge.CENTER)}getConstraints(){return this.constraints_}getConstrainResolution(){return this.get("constrainResolution")}getHints(t){return t!==void 0?(t[0]=this.hints_[0],t[1]=this.hints_[1],t):this.hints_.slice()}calculateExtent(t){let e=this.calculateExtentInternal(t);return Ai(e,this.getProjection())}calculateExtentInternal(t){t=t||this.getViewportSizeMinusPadding_();let e=this.getCenterInternal();K(e,"The view center is not defined");let i=this.getResolution();K(i!==void 0,"The view resolution is not defined");let r=this.getRotation();return K(r!==void 0,"The view rotation is not defined"),Ir(e,i,r,t)}getMaxResolution(){return this.maxResolution_}getMinResolution(){return this.minResolution_}getMaxZoom(){return this.getZoomForResolution(this.minResolution_)}setMaxZoom(t){this.applyOptions_(this.getUpdatedOptions_({maxZoom:t}))}getMinZoom(){return this.getZoomForResolution(this.maxResolution_)}setMinZoom(t){this.applyOptions_(this.getUpdatedOptions_({minZoom:t}))}setConstrainResolution(t){this.applyOptions_(this.getUpdatedOptions_({constrainResolution:t}))}getProjection(){return this.projection_}getResolution(){return this.get(ge.RESOLUTION)}getResolutions(){return this.resolutions_}getResolutionForExtent(t,e){return this.getResolutionForExtentInternal(Ce(t,this.getProjection()),e)}getResolutionForExtentInternal(t,e){e=e||this.getViewportSizeMinusPadding_();let i=j(t)/e[0],r=ct(t)/e[1];return Math.max(i,r)}getResolutionForValueFunction(t){t=t||2;let e=this.getConstrainedResolution(this.maxResolution_),i=this.minResolution_,r=Math.log(e/i)/Math.log(t);return(function(s){return e/Math.pow(t,s*r)})}getRotation(){return this.get(ge.ROTATION)}getValueForResolutionFunction(t){let e=Math.log(t||2),i=this.getConstrainedResolution(this.maxResolution_),r=this.minResolution_,s=Math.log(i/r)/e;return(function(o){return Math.log(i/o)/e/s})}getViewportSizeMinusPadding_(t){let e=this.getViewportSize_(t),i=this.padding_;return i&&(e=[e[0]-i[1]-i[3],e[1]-i[0]-i[2]]),e}getState(){let t=this.getProjection(),e=this.getResolution(),i=this.getRotation(),r=this.getCenterInternal(),s=this.padding_;if(s){let o=this.getViewportSizeMinusPadding_();r=yc(r,this.getViewportSize_(),[o[0]/2+s[3],o[1]/2+s[0]],e,i)}return{center:r.slice(0),projection:t!==void 0?t:null,resolution:e,nextCenter:this.nextCenter_,nextResolution:this.nextResolution_,nextRotation:this.nextRotation_,rotation:i,zoom:this.getZoom()}}getViewStateAndExtent(){return{viewState:this.getState(),extent:this.calculateExtent()}}getZoom(){let t,e=this.getResolution();return e!==void 0&&(t=this.getZoomForResolution(e)),t}getZoomForResolution(t){let e=this.minZoom_||0,i,r;if(this.resolutions_){let s=Gn(this.resolutions_,t,1);e=s,i=this.resolutions_[s],s==this.resolutions_.length-1?r=2:r=i/this.resolutions_[s+1]}else i=this.maxResolution_,r=this.zoomFactor_;return e+Math.log(i/t)/Math.log(r)}getResolutionForZoom(t){if(this.resolutions_?.length){if(this.resolutions_.length===1)return this.resolutions_[0];let e=et(Math.floor(t),0,this.resolutions_.length-2),i=this.resolutions_[e]/this.resolutions_[e+1];return this.resolutions_[e]/Math.pow(i,et(t-e,0,1))}return this.maxResolution_/Math.pow(this.zoomFactor_,t-this.minZoom_)}fit(t,e){let i;if(K(Array.isArray(t)||typeof t.getSimplifiedGeometry=="function","Invalid extent or geometry provided as `geometry`"),Array.isArray(t)){K(!Fe(t),"Cannot fit empty extent provided as `geometry`");let r=Ce(t,this.getProjection());i=Il(r)}else if(t.getType()==="Circle"){let r=Ce(t.getExtent(),this.getProjection());i=Il(r),i.rotate(this.getRotation(),Kt(r))}else{let r=cn();r?i=t.clone().transform(r,this.getProjection()):i=t}this.fitInternal(i,e)}rotatedExtentForGeometry(t){let e=this.getRotation(),i=Math.cos(e),r=Math.sin(-e),s=t.getFlatCoordinates(),o=t.getStride(),a=1/0,l=1/0,h=-1/0,c=-1/0;for(let d=0,f=s.length;d<f;d+=o){let g=s[d]*i-s[d+1]*r,m=s[d]*r+s[d+1]*i;a=Math.min(a,g),l=Math.min(l,m),h=Math.max(h,g),c=Math.max(c,m)}return[a,l,h,c]}fitInternal(t,e){e=e||{};let i=e.size;i||(i=this.getViewportSizeMinusPadding_());let r=e.padding!==void 0?e.padding:[0,0,0,0],s=e.nearest!==void 0?e.nearest:!1,o;e.minResolution!==void 0?o=e.minResolution:e.maxZoom!==void 0?o=this.getResolutionForZoom(e.maxZoom):o=0;let a=this.rotatedExtentForGeometry(t),l=this.getResolutionForExtentInternal(a,[i[0]-r[1]-r[3],i[1]-r[0]-r[2]]);l=isNaN(l)?o:Math.max(l,o),l=this.getConstrainedResolution(l,s?0:1);let h=this.getRotation(),c=Math.sin(h),d=Math.cos(h),f=Kt(a);f[0]+=(r[1]-r[3])/2*l,f[1]+=(r[0]-r[2])/2*l;let g=f[0]*d-f[1]*c,m=f[1]*d+f[0]*c,_=this.getConstrainedCenter([g,m],l),p=e.callback?e.callback:ci;e.duration!==void 0?this.animateInternal({resolution:l,center:_,duration:e.duration,easing:e.easing},p):(this.targetResolution_=l,this.targetCenter_=_,this.applyTargetState_(!1,!0),Oo(p,!0))}centerOn(t,e,i){this.centerOnInternal(we(t,this.getProjection()),e,i)}centerOnInternal(t,e,i){this.setCenterInternal(yc(t,e,i,this.getResolution(),this.getRotation()))}calculateCenterShift(t,e,i,r){let s,o=this.padding_;if(o&&t){let a=this.getViewportSizeMinusPadding_(-i),l=yc(t,r,[a[0]/2+o[3],a[1]/2+o[0]],e,i);s=[t[0]-l[0],t[1]-l[1]]}return s}isDef(){return!!this.getCenterInternal()&&this.getResolution()!==void 0}adjustCenter(t){let e=Mr(this.targetCenter_,this.getProjection());this.setCenter([e[0]+t[0],e[1]+t[1]])}adjustCenterInternal(t){let e=this.targetCenter_;this.setCenterInternal([e[0]+t[0],e[1]+t[1]])}adjustResolution(t,e){e=e&&we(e,this.getProjection()),this.adjustResolutionInternal(t,e)}adjustResolutionInternal(t,e){let i=this.getAnimating()||this.getInteracting(),r=this.getViewportSize_(this.getRotation()),s=this.constraints_.resolution(this.targetResolution_*t,0,r,i);e&&(this.targetCenter_=this.calculateCenterZoom(s,e)),this.targetResolution_*=t,this.applyTargetState_()}adjustZoom(t,e){this.adjustResolution(Math.pow(this.zoomFactor_,-t),e)}adjustRotation(t,e){e&&(e=we(e,this.getProjection())),this.adjustRotationInternal(t,e)}adjustRotationInternal(t,e){let i=this.getAnimating()||this.getInteracting(),r=this.constraints_.rotation(this.targetRotation_+t,i);e&&(this.targetCenter_=this.calculateCenterRotate(r,e)),this.targetRotation_+=t,this.applyTargetState_()}setCenter(t){this.setCenterInternal(t&&we(t,this.getProjection()))}setCenterInternal(t){this.targetCenter_=t,this.applyTargetState_()}setHint(t,e){return this.hints_[t]+=e,this.changed(),this.hints_[t]}setResolution(t){this.targetResolution_=t,this.applyTargetState_()}setRotation(t){this.targetRotation_=t,this.applyTargetState_()}setZoom(t){this.setResolution(this.getResolutionForZoom(t))}applyTargetState_(t,e){let i=this.getAnimating()||this.getInteracting()||e,r=this.constraints_.rotation(this.targetRotation_,i),s=this.getViewportSize_(r),o=this.constraints_.resolution(this.targetResolution_,0,s,i),a=this.constraints_.center(this.targetCenter_,o,s,i,this.calculateCenterShift(this.targetCenter_,o,r,s));this.get(ge.ROTATION)!==r&&this.set(ge.ROTATION,r),this.get(ge.RESOLUTION)!==o&&(this.set(ge.RESOLUTION,o),this.set("zoom",this.getZoom(),!0)),(!a||!this.get(ge.CENTER)||!sn(this.get(ge.CENTER),a))&&this.set(ge.CENTER,a),this.getAnimating()&&!t&&this.cancelAnimations(),this.cancelAnchor_=void 0}resolveConstraints(t,e,i){t=t!==void 0?t:200;let r=e||0,s=this.constraints_.rotation(this.targetRotation_),o=this.getViewportSize_(s),a=this.constraints_.resolution(this.targetResolution_,r,o),l=this.constraints_.center(this.targetCenter_,a,o,!1,this.calculateCenterShift(this.targetCenter_,a,s,o));if(t===0&&!this.cancelAnchor_){this.targetResolution_=a,this.targetRotation_=s,this.targetCenter_=l,this.applyTargetState_();return}i=i||(t===0?this.cancelAnchor_:void 0),this.cancelAnchor_=void 0,(this.getResolution()!==a||this.getRotation()!==s||!this.getCenterInternal()||!sn(this.getCenterInternal(),l))&&(this.getAnimating()&&this.cancelAnimations(),this.animateInternal({rotation:s,center:l,resolution:a,duration:t,easing:ce,anchor:i}))}beginInteraction(){this.resolveConstraints(0),this.setHint(bt.INTERACTING,1)}endInteraction(t,e,i){i=i&&we(i,this.getProjection()),this.endInteractionInternal(t,e,i)}endInteractionInternal(t,e,i){this.getInteracting()&&(this.setHint(bt.INTERACTING,-1),this.resolveConstraints(t,e,i))}getConstrainedCenter(t,e){let i=this.getViewportSize_(this.getRotation());return this.constraints_.center(t,e||this.getResolution(),i)}getConstrainedZoom(t,e){let i=this.getResolutionForZoom(t);return this.getZoomForResolution(this.getConstrainedResolution(i,e))}getConstrainedResolution(t,e){e=e||0;let i=this.getViewportSize_(this.getRotation());return this.constraints_.resolution(t,e,i)}};function Oo(n,t){setTimeout(function(){n(t)},0)}function m_(n){if(n.extent!==void 0){let e=n.smoothExtentConstraint!==void 0?n.smoothExtentConstraint:!0;return dc(n.extent,n.constrainOnlyCenter,e)}let t=Ys(n.projection,"EPSG:3857");if(n.multiWorld!==!0&&t.isGlobal()){let e=t.getExtent().slice();return e[0]=-1/0,e[2]=1/0,dc(e,!1,!1)}return $f}function p_(n){let t,e,i,o=n.minZoom!==void 0?n.minZoom:_c,a=n.maxZoom!==void 0?n.maxZoom:28,l=n.zoomFactor!==void 0?n.zoomFactor:2,h=n.multiWorld!==void 0?n.multiWorld:!1,c=n.smoothResolutionConstraint!==void 0?n.smoothResolutionConstraint:!0,d=n.showFullExtent!==void 0?n.showFullExtent:!1,f=Ys(n.projection,"EPSG:3857"),g=f.getExtent(),m=n.constrainOnlyCenter,_=n.extent;if(!h&&!_&&f.isGlobal()&&(m=!1,_=g),n.resolutions!==void 0){let p=n.resolutions;e=p[o],i=p[a]!==void 0?p[a]:p[p.length-1],n.constrainResolution?t=Jf(p,c,!m&&_,d):t=mc(e,i,c,!m&&_,d)}else{let y=(g?Math.max(j(g),ct(g)):360*si.degrees/f.getMetersPerUnit())/256/Math.pow(2,_c),E=y/Math.pow(2,28-_c);e=n.maxResolution,e!==void 0?o=0:e=y/Math.pow(l,o),i=n.minResolution,i===void 0&&(n.maxZoom!==void 0?n.maxResolution!==void 0?i=e/Math.pow(l,a):i=y/Math.pow(l,a):i=E),a=o+Math.floor(Math.log(e/i)/Math.log(l)),i=e/Math.pow(l,a-o),n.constrainResolution?t=Qf(l,e,i,c,!m&&_,d):t=mc(e,i,c,!m&&_,d)}return{constraint:t,maxResolution:e,minResolution:i,minZoom:o,zoomFactor:l}}function __(n){if(n.enableRotation!==void 0?n.enableRotation:!0){let e=n.constrainRotation;return e===void 0||e===!0?eg():e===!1?pc:typeof e=="number"?tg(e):pc}return nr}function y_(n){return!(n.sourceCenter&&n.targetCenter&&!sn(n.sourceCenter,n.targetCenter)||n.sourceResolution!==n.targetResolution||n.sourceRotation!==n.targetRotation)}function yc(n,t,e,i,r){let s=Math.cos(-r),o=Math.sin(-r),a=n[0]*s-n[1]*o,l=n[1]*s+n[0]*o;a+=(t[0]/2-e[0])*i,l+=(e[1]-t[1]/2)*i,o=-o;let h=a*s-l*o,c=l*s+a*o;return[h,c]}var ee=xc;var Ec=class extends wt{constructor(t){super();let e=t.element;e&&!t.target&&!e.style.pointerEvents&&(e.style.pointerEvents="auto"),this.element=e||null,this.target_=null,this.map_=null,this.listenerKeys=[],t.render&&(this.render=t.render),t.target&&this.setTarget(t.target)}disposeInternal(){this.element?.remove(),super.disposeInternal()}getMap(){return this.map_}setMap(t){this.map_&&this.element?.remove();for(let e=0,i=this.listenerKeys.length;e<i;++e)J(this.listenerKeys[e]);if(this.listenerKeys.length=0,this.map_=t,t){let e=this.target_??t.getOverlayContainerStopEvent();this.element&&e.appendChild(this.element),this.render!==ci&&this.listenerKeys.push(Z(t,je.POSTRENDER,this.render,this)),t.render()}}render(t){}setTarget(t){this.target_=typeof t=="string"?document.getElementById(t):t}},rr=Ec;var wc=class extends rr{constructor(t){t=t||{},super({element:document.createElement("div"),render:t.render,target:t.target}),this.ulElement_=document.createElement("ul"),this.collapsed_=t.collapsed!==void 0?t.collapsed:!0,this.userCollapsed_=this.collapsed_,this.overrideCollapsible_=t.collapsible!==void 0,this.collapsible_=t.collapsible!==void 0?t.collapsible:!0,this.collapsible_||(this.collapsed_=!1),this.attributions_=t.attributions;let e=t.className!==void 0?t.className:"ol-attribution",i=t.tipLabel!==void 0?t.tipLabel:"Attributions",r=t.expandClassName!==void 0?t.expandClassName:e+"-expand",s=t.collapseLabel!==void 0?t.collapseLabel:"\u203A",o=t.collapseClassName!==void 0?t.collapseClassName:e+"-collapse";typeof s=="string"?(this.collapseLabel_=document.createElement("span"),this.collapseLabel_.textContent=s,this.collapseLabel_.className=o):this.collapseLabel_=s;let a=t.label!==void 0?t.label:"i";typeof a=="string"?(this.label_=document.createElement("span"),this.label_.textContent=a,this.label_.className=r):this.label_=a;let l=this.collapsible_&&!this.collapsed_?this.collapseLabel_:this.label_;this.toggleButton_=document.createElement("button"),this.toggleButton_.setAttribute("type","button"),this.toggleButton_.setAttribute("aria-expanded",String(!this.collapsed_)),this.toggleButton_.title=i,this.toggleButton_.appendChild(l),this.toggleButton_.addEventListener(P.CLICK,this.handleClick_.bind(this),!1);let h=e+" "+Xi+" "+Jn+(this.collapsed_&&this.collapsible_?" "+Gl:"")+(this.collapsible_?"":" ol-uncollapsible"),c=this.element;c.className=h,c.appendChild(this.toggleButton_),c.appendChild(this.ulElement_),this.renderedAttributions_=[],this.renderedVisible_=!0}collectSourceAttributions_(t){let e=this.getMap().getAllLayers(),i=new Set(e.flatMap(r=>r.getAttributions(t)));if(this.attributions_!==void 0&&(Array.isArray(this.attributions_)?this.attributions_.forEach(r=>i.add(r)):i.add(this.attributions_)),!this.overrideCollapsible_){let r=!e.some(s=>s.getSource()?.getAttributionsCollapsible()===!1);this.setCollapsible(r)}return Array.from(i)}async updateElement_(t){if(!t){this.renderedVisible_&&(this.element.style.display="none",this.renderedVisible_=!1);return}let e=await Promise.all(this.collectSourceAttributions_(t).map(r=>Qu(()=>r))),i=e.length>0;if(this.renderedVisible_!=i&&(this.element.style.display=i?"":"none",this.renderedVisible_=i),!Gt(e,this.renderedAttributions_)){od(this.ulElement_);for(let r=0,s=e.length;r<s;++r){let o=document.createElement("li");o.innerHTML=e[r],this.ulElement_.appendChild(o)}this.renderedAttributions_=e}}handleClick_(t){t.preventDefault(),this.handleToggle_(),this.userCollapsed_=this.collapsed_}handleToggle_(){this.element.classList.toggle(Gl),this.collapsed_?qa(this.collapseLabel_,this.label_):qa(this.label_,this.collapseLabel_),this.collapsed_=!this.collapsed_,this.toggleButton_.setAttribute("aria-expanded",String(!this.collapsed_))}getCollapsible(){return this.collapsible_}setCollapsible(t){this.collapsible_!==t&&(this.collapsible_=t,this.element.classList.toggle("ol-uncollapsible"),this.userCollapsed_&&this.handleToggle_())}setCollapsed(t){this.userCollapsed_=t,!(!this.collapsible_||this.collapsed_===t)&&this.handleToggle_()}getCollapsed(){return this.collapsed_}render(t){this.updateElement_(t.frameState)}},ig=wc;var Cc=class extends rr{constructor(t){t=t||{},super({element:document.createElement("div"),render:t.render,target:t.target});let e=t.className!==void 0?t.className:"ol-rotate",i=t.label!==void 0?t.label:"\u21E7",r=t.compassClassName!==void 0?t.compassClassName:"ol-compass";this.label_=null,typeof i=="string"?(this.label_=document.createElement("span"),this.label_.className=r,this.label_.textContent=i):(this.label_=i,this.label_.classList.add(r));let s=t.tipLabel?t.tipLabel:"Reset rotation",o=document.createElement("button");o.className=e+"-reset",o.setAttribute("type","button"),o.title=s,o.appendChild(this.label_),o.addEventListener(P.CLICK,this.handleClick_.bind(this),!1);let a=e+" "+Xi+" "+Jn,l=this.element;l.className=a,l.appendChild(o),this.callResetNorth_=t.resetNorth?t.resetNorth:void 0,this.duration_=t.duration!==void 0?t.duration:250,this.autoHide_=t.autoHide!==void 0?t.autoHide:!0,this.rotation_=void 0,this.autoHide_&&this.element.classList.add(qr)}handleClick_(t){t.preventDefault(),this.callResetNorth_!==void 0?this.callResetNorth_():this.resetNorth_()}resetNorth_(){let e=this.getMap().getView();if(!e)return;let i=e.getRotation();i!==void 0&&(this.duration_>0&&i%(2*Math.PI)!==0?e.animate({rotation:0,duration:this.duration_,easing:ce}):e.setRotation(0))}render(t){let e=t.frameState;if(!e)return;let i=e.viewState.rotation;if(i!=this.rotation_){let r="rotate("+i+"rad)";if(this.autoHide_){let s=this.element.classList.contains(qr);!s&&i===0?this.element.classList.add(qr):s&&i!==0&&this.element.classList.remove(qr)}this.label_.style.transform=r}this.rotation_=i}},ng=Cc;var vc=class extends rr{constructor(t){t=t||{},super({element:document.createElement("div"),target:t.target});let e=t.className!==void 0?t.className:"ol-zoom",i=t.delta!==void 0?t.delta:1,r=t.zoomInClassName!==void 0?t.zoomInClassName:e+"-in",s=t.zoomOutClassName!==void 0?t.zoomOutClassName:e+"-out",o=t.zoomInLabel!==void 0?t.zoomInLabel:"+",a=t.zoomOutLabel!==void 0?t.zoomOutLabel:"\u2013",l=t.zoomInTipLabel!==void 0?t.zoomInTipLabel:"Zoom in",h=t.zoomOutTipLabel!==void 0?t.zoomOutTipLabel:"Zoom out",c=document.createElement("button");c.className=r,c.setAttribute("type","button"),c.title=l,c.appendChild(typeof o=="string"?document.createTextNode(o):o),c.addEventListener(P.CLICK,this.handleClick_.bind(this,i),!1);let d=document.createElement("button");d.className=s,d.setAttribute("type","button"),d.title=h,d.appendChild(typeof a=="string"?document.createTextNode(a):a),d.addEventListener(P.CLICK,this.handleClick_.bind(this,-i),!1);let f=e+" "+Xi+" "+Jn,g=this.element;g.className=f,g.appendChild(c),g.appendChild(d),this.duration_=t.duration!==void 0?t.duration:250}handleClick_(t,e){e.preventDefault(),this.zoomByDelta_(t)}zoomByDelta_(t){let i=this.getMap().getView();if(!i)return;let r=i.getZoom();if(r!==void 0){let s=i.getConstrainedZoom(r+t);this.duration_>0?(i.getAnimating()&&i.cancelAnimations(),i.animate({zoom:s,duration:this.duration_,easing:ce})):i.setZoom(s)}}},rg=vc;function Do(n){n=n||{};let t=new Dt;return(n.zoom===void 0||n.zoom)&&t.push(new rg(n.zoomOptions)),(n.rotate===void 0||n.rotate)&&t.push(new ng(n.rotateOptions)),(n.attribution===void 0||n.attribution)&&t.push(new ig(n.attributionOptions)),t}var Sc=class{constructor(t,e,i){this.decay_=t,this.minVelocity_=e,this.delay_=i,this.points_=[],this.angle_=0,this.initialVelocity_=0}begin(){this.points_.length=0,this.angle_=0,this.initialVelocity_=0}update(t,e){this.points_.push(t,e,Date.now())}end(){if(this.points_.length<6)return!1;let t=Date.now()-this.delay_,e=this.points_.length-3;if(this.points_[e+2]<t)return!1;let i=e-3;for(;i>0&&this.points_[i+2]>t;)i-=3;let r=this.points_[e+2]-this.points_[i+2];if(r<1e3/60)return!1;let s=this.points_[e]-this.points_[i],o=this.points_[e+1]-this.points_[i+1];return this.angle_=Math.atan2(o,s),this.initialVelocity_=Math.sqrt(s*s+o*o)/r,this.initialVelocity_>this.minVelocity_}getDistance(){return(this.minVelocity_-this.initialVelocity_)/this.decay_}getAngle(){return this.angle_}},sg=Sc;var Rc={ACTIVE:"active"};var Tc=class extends wt{constructor(t){super(),this.on,this.once,this.un,t&&t.handleEvent&&(this.handleEvent=t.handleEvent),this.map_=null,this.setActive(!0)}getActive(){return this.get(Rc.ACTIVE)}getMap(){return this.map_}handleEvent(t){return!0}setActive(t){this.set(Rc.ACTIVE,t)}setMap(t){this.map_=t}};function og(n,t,e){let i=n.getCenterInternal();if(i){let r=[i[0]+t[0],i[1]+t[1]];n.animateInternal({duration:e!==void 0?e:250,easing:sd,center:n.getConstrainedCenter(r)})}}function sr(n,t,e,i){let r=n.getZoom();if(r===void 0)return;let s=n.getConstrainedZoom(r+t),o=n.getResolutionForZoom(s);n.getAnimating()&&n.cancelAnimations(),n.animate({resolution:o,anchor:e,duration:i!==void 0?i:250,easing:ce})}var He=Tc;var Ic=class extends He{constructor(t){super(),t=t||{},this.delta_=t.delta?t.delta:1,this.duration_=t.duration!==void 0?t.duration:250}handleEvent(t){let e=!1;if(t.type==at.DBLCLICK){let i=t.originalEvent,r=t.map,s=t.coordinate,o=i.shiftKey?-this.delta_:this.delta_,a=r.getView();sr(a,o,s,this.duration_),i.preventDefault(),e=!0}return!e}},ag=Ic;function is(n){let t=arguments;return function(e){let i=!0;for(let r=0,s=t.length;r<s&&(i=i&&t[r](e),!!i);++r);return i}}var lg=function(n){let t=n.originalEvent;return t.altKey&&!(t.metaKey||t.ctrlKey)&&t.shiftKey},x_=function(n){let t=n.map.getTargetElement(),e=t.getRootNode(),i=n.map.getOwnerDocument().activeElement;return e instanceof ShadowRoot?e.host.contains(i):t.contains(i)},ko=function(n){let t=n.map.getTargetElement(),e=t.getRootNode();return(e instanceof ShadowRoot?e.host:t).hasAttribute("tabindex")?x_(n):!0},cg=ai;var Fo=function(n){let t=n.originalEvent;return"pointerId"in t&&t.button==0&&!(td&&Za&&t.ctrlKey)};var No=function(n){let t=n.originalEvent;return!t.altKey&&!(t.metaKey||t.ctrlKey)&&!t.shiftKey};var hg=function(n){let t=n.originalEvent;return Za?t.metaKey:t.ctrlKey},ug=function(n){let t=n.originalEvent;return!t.altKey&&!(t.metaKey||t.ctrlKey)&&t.shiftKey},zo=function(n){let t=n.originalEvent,e=t.target.tagName;return e!=="INPUT"&&e!=="SELECT"&&e!=="TEXTAREA"&&!t.target.isContentEditable},Go=function(n){let t=n.originalEvent;return"pointerId"in t&&t.pointerType=="mouse"};var dg=function(n){let t=n.originalEvent;return"pointerId"in t&&t.isPrimary&&t.button===0};var bc=class extends He{constructor(t){t=t||{},super(t),t.handleDownEvent&&(this.handleDownEvent=t.handleDownEvent),t.handleDragEvent&&(this.handleDragEvent=t.handleDragEvent),t.handleMoveEvent&&(this.handleMoveEvent=t.handleMoveEvent),t.handleUpEvent&&(this.handleUpEvent=t.handleUpEvent),t.stopDown&&(this.stopDown=t.stopDown),this.handlingDownUpSequence=!1,this.targetPointers=[]}getPointerCount(){return this.targetPointers.length}handleDownEvent(t){return!1}handleDragEvent(t){}handleEvent(t){if(!t.originalEvent)return!0;let e=!1;if(this.updateTrackedPointers_(t),this.handlingDownUpSequence){if(t.type==at.POINTERDRAG)this.handleDragEvent(t),t.originalEvent.preventDefault();else if(t.type==at.POINTERUP){let i=this.handleUpEvent(t);this.handlingDownUpSequence=i&&this.targetPointers.length>0}}else if(t.type==at.POINTERDOWN){let i=this.handleDownEvent(t);this.handlingDownUpSequence=i,e=this.stopDown(i)}else t.type==at.POINTERMOVE&&this.handleMoveEvent(t);return!e}handleMoveEvent(t){}handleUpEvent(t){return!1}stopDown(t){return t}updateTrackedPointers_(t){t.activePointers&&(this.targetPointers=t.activePointers)}};function or(n){let t=n.length,e=0,i=0;for(let r=0;r<t;r++)e+=n[r].clientX,i+=n[r].clientY;return{clientX:e/t,clientY:i/t}}var qe=bc;var Lc=class extends qe{constructor(t){super({stopDown:li}),t=t||{},this.kinetic_=t.kinetic,this.lastCentroid=null,this.lastPointersCount_,this.panning_=!1;let e=t.condition?t.condition:is(No,dg);this.condition_=t.onFocusOnly?is(ko,e):e,this.noKinetic_=!1}handleDragEvent(t){let e=t.map;this.panning_||(this.panning_=!0,e.getView().beginInteraction());let i=this.targetPointers,r=e.getEventPixel(or(i));if(i.length==this.lastPointersCount_){if(this.kinetic_&&this.kinetic_.update(r[0],r[1]),this.lastCentroid){let s=[this.lastCentroid[0]-r[0],r[1]-this.lastCentroid[1]],a=t.map.getView();gu(s,a.getResolution()),Pn(s,a.getRotation()),a.adjustCenterInternal(s)}}else this.kinetic_&&this.kinetic_.begin();this.lastCentroid=r,this.lastPointersCount_=i.length,t.originalEvent.preventDefault()}handleUpEvent(t){let e=t.map,i=e.getView();if(this.targetPointers.length===0){if(!this.noKinetic_&&this.kinetic_&&this.kinetic_.end()){let r=this.kinetic_.getDistance(),s=this.kinetic_.getAngle(),o=i.getCenterInternal(),a=e.getPixelFromCoordinateInternal(o),l=e.getCoordinateFromPixelInternal([a[0]-r*Math.cos(s),a[1]-r*Math.sin(s)]);i.animateInternal({center:i.getConstrainedCenter(l),duration:500,easing:ce})}return this.panning_&&(this.panning_=!1,i.endInteraction()),!1}return this.kinetic_&&this.kinetic_.begin(),this.lastCentroid=null,!0}handleDownEvent(t){if(this.targetPointers.length>0&&this.condition_(t)){let i=t.map.getView();return this.lastCentroid=null,i.getAnimating()&&i.cancelAnimations(),this.kinetic_&&this.kinetic_.begin(),this.noKinetic_=this.targetPointers.length>1,!0}return!1}},fg=Lc;var Ac=class extends qe{constructor(t){t=t||{},super({stopDown:li}),this.condition_=t.condition?t.condition:lg,this.lastAngle_=void 0,this.duration_=t.duration!==void 0?t.duration:250}handleDragEvent(t){if(!Go(t))return;let e=t.map,i=e.getView();if(i.getConstraints().rotation===nr)return;let r=e.getSize(),s=t.pixel,o=Math.atan2(r[1]/2-s[1],s[0]-r[0]/2);if(this.lastAngle_!==void 0){let a=o-this.lastAngle_;i.adjustRotationInternal(-a)}this.lastAngle_=o}handleUpEvent(t){return Go(t)?(t.map.getView().endInteraction(this.duration_),!1):!0}handleDownEvent(t){return Go(t)&&Fo(t)&&this.condition_(t)?(t.map.getView().beginInteraction(),this.lastAngle_=void 0,!0):!1}},gg=Ac;var Mc=class extends Oi{constructor(t){super(),this.geometry_=null,this.element_=document.createElement("div"),this.element_.style.position="absolute",this.element_.style.pointerEvents="auto",this.element_.className="ol-box "+t,this.map_=null,this.startPixel_=null,this.endPixel_=null}disposeInternal(){this.setMap(null)}render_(){let t=this.startPixel_,e=this.endPixel_,i="px",r=this.element_.style;r.left=Math.min(t[0],e[0])+i,r.top=Math.min(t[1],e[1])+i,r.width=Math.abs(e[0]-t[0])+i,r.height=Math.abs(e[1]-t[1])+i}setMap(t){if(this.map_){this.map_.getOverlayContainer().removeChild(this.element_);let e=this.element_.style;e.left="inherit",e.top="inherit",e.width="inherit",e.height="inherit"}this.map_=t,this.map_&&this.map_.getOverlayContainer().appendChild(this.element_)}setPixels(t,e){this.startPixel_=t,this.endPixel_=e,this.createOrUpdateGeometry(),this.render_()}createOrUpdateGeometry(){if(!this.map_)return;let t=this.startPixel_,e=this.endPixel_,r=[t,[t[0],e[1]],e,[e[0],t[1]]].map(this.map_.getCoordinateFromPixelInternal,this.map_);r[4]=r[0].slice(),this.geometry_?this.geometry_.setCoordinates([r]):this.geometry_=new Ve([r])}getGeometry(){return this.geometry_}},mg=Mc;var ar={BOXSTART:"boxstart",BOXDRAG:"boxdrag",BOXEND:"boxend",BOXCANCEL:"boxcancel"},yn=class extends Lt{constructor(t,e,i){super(t),this.coordinate=e,this.mapBrowserEvent=i}},Pc=class extends qe{constructor(t){super(),this.on,this.once,this.un,t=t??{},this.box_=new mg(t.className||"ol-dragbox"),this.minArea_=t.minArea??64,t.onBoxEnd&&(this.onBoxEnd=t.onBoxEnd),this.startPixel_=null,this.condition_=t.condition??Fo,this.boxEndCondition_=t.boxEndCondition??this.defaultBoxEndCondition}defaultBoxEndCondition(t,e,i){let r=i[0]-e[0],s=i[1]-e[1];return r*r+s*s>=this.minArea_}getGeometry(){return this.box_.getGeometry()}handleDragEvent(t){this.startPixel_&&(this.box_.setPixels(this.startPixel_,t.pixel),this.dispatchEvent(new yn(ar.BOXDRAG,t.coordinate,t)))}handleUpEvent(t){if(!this.startPixel_)return!1;let e=this.boxEndCondition_(t,this.startPixel_,t.pixel);return e&&this.onBoxEnd(t),this.dispatchEvent(new yn(e?ar.BOXEND:ar.BOXCANCEL,t.coordinate,t)),this.box_.setMap(null),this.startPixel_=null,!1}handleDownEvent(t){return this.condition_(t)?(this.startPixel_=t.pixel,this.box_.setMap(t.map),this.box_.setPixels(this.startPixel_,this.startPixel_),this.dispatchEvent(new yn(ar.BOXSTART,t.coordinate,t)),!0):!1}onBoxEnd(t){}setActive(t){t||(this.box_.setMap(null),this.startPixel_&&(this.dispatchEvent(new yn(ar.BOXCANCEL,this.startPixel_,null)),this.startPixel_=null)),super.setActive(t)}setMap(t){this.getMap()&&(this.box_.setMap(null),this.startPixel_&&(this.dispatchEvent(new yn(ar.BOXCANCEL,this.startPixel_,null)),this.startPixel_=null)),super.setMap(t)}},pg=Pc;var Oc=class extends pg{constructor(t){t=t||{};let e=t.condition?t.condition:ug;super({condition:e,className:t.className||"ol-dragzoom",minArea:t.minArea}),this.duration_=t.duration!==void 0?t.duration:200,this.out_=t.out!==void 0?t.out:!1}onBoxEnd(t){let i=this.getMap().getView(),r=this.getGeometry();if(this.out_){let s=i.rotatedExtentForGeometry(r),o=i.getResolutionForExtentInternal(s),a=i.getResolution()/o;r=r.clone(),r.scale(a*a)}i.fitInternal(r,{duration:this.duration_,easing:ce})}},_g=Oc;var Yi={LEFT:"ArrowLeft",UP:"ArrowUp",RIGHT:"ArrowRight",DOWN:"ArrowDown"};var Dc=class extends He{constructor(t){super(),t=t||{},this.defaultCondition_=function(e){return No(e)&&zo(e)},this.condition_=t.condition!==void 0?t.condition:this.defaultCondition_,this.duration_=t.duration!==void 0?t.duration:100,this.pixelDelta_=t.pixelDelta!==void 0?t.pixelDelta:128}handleEvent(t){let e=!1;if(t.type==P.KEYDOWN){let i=t.originalEvent,r=i.key;if(this.condition_(t)&&(r==Yi.DOWN||r==Yi.LEFT||r==Yi.RIGHT||r==Yi.UP)){let o=t.map.getView(),a=o.getResolution()*this.pixelDelta_,l=0,h=0;r==Yi.DOWN?h=-a:r==Yi.LEFT?l=-a:r==Yi.RIGHT?l=a:h=a;let c=[l,h];Pn(c,o.getRotation()),og(o,c,this.duration_),i.preventDefault(),e=!0}}return!e}},yg=Dc;var kc=class extends He{constructor(t){super(),t=t||{},this.condition_=t.condition?t.condition:function(e){return!hg(e)&&zo(e)},this.delta_=t.delta?t.delta:1,this.duration_=t.duration!==void 0?t.duration:100}handleEvent(t){let e=!1;if(t.type==P.KEYDOWN||t.type==P.KEYPRESS){let i=t.originalEvent,r=i.key;if(this.condition_(t)&&(r==="+"||r==="-")){let s=t.map,o=r==="+"?this.delta_:-this.delta_,a=s.getView();sr(a,o,void 0,this.duration_),i.preventDefault(),e=!0}}return!e}},xg=kc;var E_=40,w_=300,C_=3,Fc=class extends He{constructor(t){t=t||{},super(t),this.totalDelta_=0,this.lastDelta_=0,this.maxDelta_=t.maxDelta!==void 0?t.maxDelta:1,this.duration_=t.duration!==void 0?t.duration:250,this.timeout_=t.timeout!==void 0?t.timeout:80,this.useAnchor_=t.useAnchor!==void 0?t.useAnchor:!0,this.constrainResolution_=t.constrainResolution!==void 0?t.constrainResolution:!1;let e=t.condition?t.condition:cg;this.condition_=t.onFocusOnly?is(ko,e):e,this.lastAnchor_=null,this.startTime_=void 0,this.timeoutId_,this.mode_=void 0,this.trackpadEventGap_=400,this.trackpadTimeoutId_,this.deltaPerZoom_=300,this.ctrlKeyPressed_=!1,this.ctrlKeyListenerKeys_=[]}setMap(t){if(this.ctrlKeyListenerKeys_.forEach(J),this.ctrlKeyListenerKeys_.length=0,this.ctrlKeyPressed_=!1,super.setMap(t),t){let e=t.getOwnerDocument();this.ctrlKeyListenerKeys_.push(Z(e,"keydown",i=>{i.key==="Control"&&(this.ctrlKeyPressed_=!0)}),Z(e,"keyup",i=>{i.key==="Control"&&(this.ctrlKeyPressed_=!1)}))}}endInteraction_(){this.trackpadTimeoutId_=void 0;let t=this.getMap();if(!t)return;let e=t.getView(),i=this.lastDelta_?this.lastDelta_>0?1:-1:0;e.endInteraction(this.constrainResolution_||e.getConstrainResolution()?100:void 0,i,this.lastAnchor_?t.getCoordinateFromPixel(this.lastAnchor_):null)}handleEvent(t){if(!this.condition_(t)||t.type!==P.WHEEL)return!0;let i=t.map,r=t.originalEvent;r.preventDefault();let s=r.ctrlKey&&!this.ctrlKeyPressed_;r.ctrlKey||(this.ctrlKeyPressed_=!1),this.useAnchor_&&(this.lastAnchor_=t.pixel);let o=r.deltaY;switch(r.deltaMode){case WheelEvent.DOM_DELTA_LINE:o*=E_;break;case WheelEvent.DOM_DELTA_PAGE:o*=w_;break;default:}if(o===0)return!1;this.lastDelta_=o;let a=Date.now();this.startTime_===void 0&&(this.startTime_=a),(!this.mode_||a-this.startTime_>this.trackpadEventGap_)&&(this.mode_=Math.abs(o)<4?"trackpad":"wheel");let l=i.getView();if(this.mode_==="trackpad")return this.trackpadTimeoutId_?clearTimeout(this.trackpadTimeoutId_):(l.getAnimating()&&l.cancelAnimations(),l.beginInteraction()),this.trackpadTimeoutId_=setTimeout(this.endInteraction_.bind(this),this.timeout_),s&&(o=o*C_),l.adjustZoom(-o/this.deltaPerZoom_,this.lastAnchor_?i.getCoordinateFromPixel(this.lastAnchor_):null),this.startTime_=a,!1;this.totalDelta_+=o;let h=Math.max(this.timeout_-(a-this.startTime_),0);return clearTimeout(this.timeoutId_),this.timeoutId_=setTimeout(this.handleWheelZoom_.bind(this,i),h),!1}handleWheelZoom_(t){let e=t.getView();e.getAnimating()&&e.cancelAnimations();let i=-et(this.totalDelta_,-this.maxDelta_*this.deltaPerZoom_,this.maxDelta_*this.deltaPerZoom_)/this.deltaPerZoom_;(e.getConstrainResolution()||this.constrainResolution_)&&(i=i?i>0?1:-1:0),sr(e,i,this.lastAnchor_?t.getCoordinateFromPixel(this.lastAnchor_):null,this.duration_),this.mode_=void 0,this.totalDelta_=0,this.lastAnchor_=null,this.startTime_=void 0,this.timeoutId_=void 0}setMouseAnchor(t){this.useAnchor_=t,t||(this.lastAnchor_=null)}},Eg=Fc;var Nc=class extends qe{constructor(t){t=t||{};let e=t;e.stopDown||(e.stopDown=li),super(e),this.anchor_=null,this.lastAngle_=void 0,this.rotating_=!1,this.rotationDelta_=0,this.threshold_=t.threshold!==void 0?t.threshold:.3,this.duration_=t.duration!==void 0?t.duration:250}handleDragEvent(t){let e=0,i=this.targetPointers[0],r=this.targetPointers[1],s=Math.atan2(r.clientY-i.clientY,r.clientX-i.clientX);if(this.lastAngle_!==void 0){let l=s-this.lastAngle_;this.rotationDelta_+=l,!this.rotating_&&Math.abs(this.rotationDelta_)>this.threshold_&&(this.rotating_=!0),e=l}this.lastAngle_=s;let o=t.map,a=o.getView();a.getConstraints().rotation!==nr&&(this.anchor_=o.getCoordinateFromPixelInternal(o.getEventPixel(or(this.targetPointers))),this.rotating_&&(o.render(),a.adjustRotationInternal(e,this.anchor_)))}handleUpEvent(t){return this.targetPointers.length<2?(t.map.getView().endInteraction(this.duration_),!1):!0}handleDownEvent(t){if(this.targetPointers.length>=2){let e=t.map;return this.anchor_=null,this.lastAngle_=void 0,this.rotating_=!1,this.rotationDelta_=0,this.handlingDownUpSequence||e.getView().beginInteraction(),!0}return!1}},wg=Nc;var zc=class extends qe{constructor(t){t=t||{};let e=t;e.stopDown||(e.stopDown=li),super(e),this.anchor_=null,this.duration_=t.duration!==void 0?t.duration:400,this.lastDistance_=void 0,this.lastScaleDelta_=1}handleDragEvent(t){let e=1,i=this.targetPointers[0],r=this.targetPointers[1],s=i.clientX-r.clientX,o=i.clientY-r.clientY,a=Math.sqrt(s*s+o*o);this.lastDistance_!==void 0&&(e=this.lastDistance_/a),this.lastDistance_=a;let l=t.map,h=l.getView();e!=1&&(this.lastScaleDelta_=e),this.anchor_=l.getCoordinateFromPixelInternal(l.getEventPixel(or(this.targetPointers))),l.render(),h.adjustResolutionInternal(e,this.anchor_)}handleUpEvent(t){if(this.targetPointers.length<2){let i=t.map.getView(),r=this.lastScaleDelta_>1?1:-1;return i.endInteraction(this.duration_,r),!1}return!0}handleDownEvent(t){if(this.targetPointers.length>=2){let e=t.map;return this.anchor_=null,this.lastDistance_=void 0,this.lastScaleDelta_=1,this.handlingDownUpSequence||e.getView().beginInteraction(),!0}return!1}},Cg=zc;function Xo(n){n=n||{};let t=new Dt,e=new sg(-.005,.05,100);return(n.altShiftDragRotate===void 0||n.altShiftDragRotate)&&t.push(new gg),(n.doubleClickZoom===void 0||n.doubleClickZoom)&&t.push(new ag({delta:n.zoomDelta,duration:n.zoomDuration})),(n.dragPan===void 0||n.dragPan)&&t.push(new fg({onFocusOnly:n.onFocusOnly,kinetic:e})),(n.pinchRotate===void 0||n.pinchRotate)&&t.push(new wg),(n.pinchZoom===void 0||n.pinchZoom)&&t.push(new Cg({duration:n.zoomDuration})),(n.keyboard===void 0||n.keyboard)&&(t.push(new yg),t.push(new xg({delta:n.zoomDelta,duration:n.zoomDuration}))),(n.mouseWheelZoom===void 0||n.mouseWheelZoom)&&t.push(new Eg({onFocusOnly:n.onFocusOnly,duration:n.zoomDuration})),(n.shiftDragZoom===void 0||n.shiftDragZoom)&&t.push(new _g({duration:n.zoomDuration})),t}var rt={OPACITY:"opacity",VISIBLE:"visible",EXTENT:"extent",Z_INDEX:"zIndex",MAX_RESOLUTION:"maxResolution",MIN_RESOLUTION:"minResolution",MAX_ZOOM:"maxZoom",MIN_ZOOM:"minZoom",SOURCE:"source",MAP:"map"};var Gc=class extends wt{constructor(t){super(),this.on,this.once,this.un,this.background_=t.background;let e=Object.assign({},t);typeof t.properties=="object"&&(delete e.properties,Object.assign(e,t.properties)),e[rt.OPACITY]=t.opacity!==void 0?t.opacity:1,K(typeof e[rt.OPACITY]=="number","Layer opacity must be a number"),e[rt.VISIBLE]=t.visible!==void 0?t.visible:!0,e[rt.Z_INDEX]=t.zIndex,e[rt.MAX_RESOLUTION]=t.maxResolution!==void 0?t.maxResolution:1/0,e[rt.MIN_RESOLUTION]=t.minResolution!==void 0?t.minResolution:0,e[rt.MIN_ZOOM]=t.minZoom!==void 0?t.minZoom:-1/0,e[rt.MAX_ZOOM]=t.maxZoom!==void 0?t.maxZoom:1/0,this.className_=e.className!==void 0?e.className:"ol-layer",delete e.className,this.setProperties(e),this.state_=null}getBackground(){return this.background_}getClassName(){return this.className_}getLayerState(t){let e=this.state_||{layer:this,managed:t===void 0?!0:t},i=this.getZIndex();return e.opacity=et(Math.round(this.getOpacity()*100)/100,0,1),e.visible=this.getVisible(),e.extent=this.getExtent(),e.zIndex=i===void 0&&!e.managed?1/0:i,e.maxResolution=this.getMaxResolution(),e.minResolution=Math.max(this.getMinResolution(),0),e.minZoom=this.getMinZoom(),e.maxZoom=this.getMaxZoom(),this.state_=e,e}getLayersArray(t){return H()}getLayerStatesArray(t){return H()}getExtent(){return this.get(rt.EXTENT)}getMaxResolution(){return this.get(rt.MAX_RESOLUTION)}getMinResolution(){return this.get(rt.MIN_RESOLUTION)}getMinZoom(){return this.get(rt.MIN_ZOOM)}getMaxZoom(){return this.get(rt.MAX_ZOOM)}getOpacity(){return this.get(rt.OPACITY)}getSourceState(){return H()}getVisible(){return this.get(rt.VISIBLE)}getZIndex(){return this.get(rt.Z_INDEX)}setBackground(t){this.background_=t,this.changed()}setExtent(t){this.set(rt.EXTENT,t)}setMaxResolution(t){this.set(rt.MAX_RESOLUTION,t)}setMinResolution(t){this.set(rt.MIN_RESOLUTION,t)}setMaxZoom(t){this.set(rt.MAX_ZOOM,t)}setMinZoom(t){this.set(rt.MIN_ZOOM,t)}setOpacity(t){K(typeof t=="number","Layer opacity must be a number"),this.set(rt.OPACITY,t)}setVisible(t){this.set(rt.VISIBLE,t)}setZIndex(t){this.set(rt.Z_INDEX,t)}disposeInternal(){this.state_&&(this.state_.layer=null,this.state_=null),super.disposeInternal()}},Wo=Gc;var Vi={ADDLAYER:"addlayer",REMOVELAYER:"removelayer"},Ie=class extends Lt{constructor(t,e){super(t),this.layer=e}},Xc={LAYERS:"layers"},Wc=class n extends Wo{constructor(t){t=t||{};let e=Object.assign({},t);delete e.layers;let i=t.layers;super(e),this.on,this.once,this.un,this.layersListenerKeys_=[],this.listenerKeys_={},this.addChangeListener(Xc.LAYERS,this.handleLayersChanged_),i?Array.isArray(i)?i=new Dt(i.slice(),{unique:!0}):K(typeof i.getArray=="function","Expected `layers` to be an array or a `Collection`"):i=new Dt(void 0,{unique:!0}),this.setLayers(i)}handleLayerChange_(){this.changed()}handleLayersChanged_(){this.layersListenerKeys_.forEach(J),this.layersListenerKeys_.length=0;let t=this.getLayers();this.layersListenerKeys_.push(Z(t,Pt.ADD,this.handleLayersAdd_,this),Z(t,Pt.REMOVE,this.handleLayersRemove_,this));for(let i in this.listenerKeys_)this.listenerKeys_[i].forEach(J);ze(this.listenerKeys_);let e=t.getArray();for(let i=0,r=e.length;i<r;i++){let s=e[i];this.registerLayerListeners_(s),this.dispatchEvent(new Ie(Vi.ADDLAYER,s))}this.changed()}registerLayerListeners_(t){let e=[Z(t,Se.PROPERTYCHANGE,this.handleLayerChange_,this),Z(t,P.CHANGE,this.handleLayerChange_,this)];t instanceof n&&e.push(Z(t,Vi.ADDLAYER,this.handleLayerGroupAdd_,this),Z(t,Vi.REMOVELAYER,this.handleLayerGroupRemove_,this)),this.listenerKeys_[Y(t)]=e}handleLayerGroupAdd_(t){this.dispatchEvent(new Ie(Vi.ADDLAYER,t.layer))}handleLayerGroupRemove_(t){this.dispatchEvent(new Ie(Vi.REMOVELAYER,t.layer))}handleLayersAdd_(t){let e=t.element;this.registerLayerListeners_(e),this.dispatchEvent(new Ie(Vi.ADDLAYER,e)),this.changed()}handleLayersRemove_(t){let e=t.element,i=Y(e);this.listenerKeys_[i].forEach(J),delete this.listenerKeys_[i],this.dispatchEvent(new Ie(Vi.REMOVELAYER,e)),this.changed()}getLayers(){return this.get(Xc.LAYERS)}setLayers(t){let e=this.getLayers();if(e){let i=e.getArray();for(let r=0,s=i.length;r<s;++r)this.dispatchEvent(new Ie(Vi.REMOVELAYER,i[r]))}this.set(Xc.LAYERS,t)}getLayersArray(t){return t=t!==void 0?t:[],this.getLayers().forEach(function(e){e.getLayersArray(t)}),t}getLayerStatesArray(t){let e=t!==void 0?t:[],i=e.length;this.getLayers().forEach(function(o){o.getLayerStatesArray(e)});let r=this.getLayerState(),s=r.zIndex;!t&&r.zIndex===void 0&&(s=0);for(let o=i,a=e.length;o<a;o++){let l=e[o];l.opacity*=r.opacity,l.visible=l.visible&&r.visible,l.maxResolution=Math.min(l.maxResolution,r.maxResolution),l.minResolution=Math.max(l.minResolution,r.minResolution),l.minZoom=Math.max(l.minZoom,r.minZoom),l.maxZoom=Math.min(l.maxZoom,r.maxZoom),r.extent!==void 0&&(l.extent!==void 0?l.extent=ke(l.extent,r.extent):l.extent=r.extent),l.zIndex===void 0&&(l.zIndex=s)}return e}getSourceState(){return"ready"}},ns=Wc;var Ft={PRERENDER:"prerender",POSTRENDER:"postrender",PRECOMPOSE:"precompose",POSTCOMPOSE:"postcompose",RENDERCOMPLETE:"rendercomplete"};var Uc=class extends Wo{constructor(t){let e=Object.assign({},t);delete e.source,super(e),this.on,this.once,this.un,this.mapPrecomposeKey_=null,this.mapRenderKey_=null,this.sourceChangeKey_=null,this.renderer_=null,this.sourceReady_=!1,this.rendered=!1,t.render&&(this.render=t.render),t.map&&this.setMap(t.map),this.addChangeListener(rt.SOURCE,this.handleSourcePropertyChange_);let i=t.source?t.source:null;this.setSource(i)}getLayersArray(t){return t=t||[],t.push(this),t}getLayerStatesArray(t){return t=t||[],t.push(this.getLayerState()),t}getSource(){return this.get(rt.SOURCE)||null}getRenderSource(){return this.getSource()}getSourceState(){let t=this.getSource();return t?t.getState():"undefined"}handleSourceChange_(){this.changed(),!(this.sourceReady_||this.getSource().getState()!=="ready")&&(this.sourceReady_=!0,this.dispatchEvent("sourceready"))}handleSourcePropertyChange_(){this.sourceChangeKey_&&(J(this.sourceChangeKey_),this.sourceChangeKey_=null),this.sourceReady_=!1;let t=this.getSource();t&&(this.sourceChangeKey_=Z(t,P.CHANGE,this.handleSourceChange_,this),t.getState()==="ready"&&(this.sourceReady_=!0,setTimeout(()=>{this.dispatchEvent("sourceready")},0))),this.changed()}getFeatures(t){return this.renderer_?this.renderer_.getFeatures(t):Promise.resolve([])}getData(t){return!this.renderer_||!this.rendered?null:this.renderer_.getData(t)}isVisible(t){let e,i=this.getMapInternal();!t&&i&&(t=i.getView()),t instanceof ee?e={viewState:t.getState(),extent:t.calculateExtent()}:e=t,!e.layerStatesArray&&i&&(e.layerStatesArray=i.getLayerGroup().getLayerStatesArray());let r;if(e.layerStatesArray){if(r=e.layerStatesArray.find(o=>o.layer===this),!r)return!1}else r=this.getLayerState();let s=this.getExtent();return rs(r,e.viewState)&&(!s||ht(s,e.extent))}getAttributions(t){if(!this.isVisible(t))return[];let e=this.getSource()?.getAttributions();if(!e)return[];let i=t instanceof ee?t.getViewStateAndExtent():t,r=e(i);return Array.isArray(r)||(r=[r]),r}render(t,e){let i=this.getRenderer();return i.prepareFrame(t)?(this.rendered=!0,i.renderFrame(t,e)):null}unrender(){this.rendered=!1}getDeclutter(){}renderDeclutter(t,e){}renderDeferred(t){let e=this.getRenderer();e&&e.renderDeferred(t)}setMapInternal(t){t||this.unrender(),this.set(rt.MAP,t)}getMapInternal(){return this.get(rt.MAP)}setMap(t){this.mapPrecomposeKey_&&(J(this.mapPrecomposeKey_),this.mapPrecomposeKey_=null),t||this.changed(),this.mapRenderKey_&&(J(this.mapRenderKey_),this.mapRenderKey_=null),t&&(this.mapPrecomposeKey_=Z(t,Ft.PRECOMPOSE,this.handlePrecompose_,this),this.mapRenderKey_=Z(this,P.CHANGE,t.render,t),this.changed())}handlePrecompose_(t){let e=t.frameState.layerStatesArray,i=this.getLayerState(!1);K(!e.some(r=>r.layer===i.layer),"A layer can only be added to the map once. Use either `layer.setMap()` or `map.addLayer()`, not both."),e.push(i)}setSource(t){this.set(rt.SOURCE,t)}getRenderer(){return this.renderer_||(this.renderer_=this.createRenderer()),this.renderer_}hasRenderer(){return!!this.renderer_}createRenderer(){return null}clearRenderer(){this.renderer_&&(this.renderer_.dispose(),delete this.renderer_)}disposeInternal(){this.clearRenderer(),this.setSource(null),super.disposeInternal()}};function rs(n,t){if(!n.visible)return!1;let e=t.resolution;if(e<n.minResolution||e>=n.maxResolution)return!1;let i=t.zoom;return i>n.minZoom&&i<=n.maxZoom}var xn=Uc;function Uo(n,t,e=0,i=n.length-1,r=v_){for(;i>e;){if(i-e>600){let l=i-e+1,h=t-e+1,c=Math.log(l),d=.5*Math.exp(2*c/3),f=.5*Math.sqrt(c*d*(l-d)/l)*(h-l/2<0?-1:1),g=Math.max(e,Math.floor(t-h*d/l+f)),m=Math.min(i,Math.floor(t+(l-h)*d/l+f));Uo(n,t,g,m,r)}let s=n[t],o=e,a=i;for(ss(n,e,t),r(n[i],s)>0&&ss(n,e,i);o<a;){for(ss(n,o,a),o++,a--;r(n[o],s)<0;)o++;for(;r(n[a],s)>0;)a--}r(n[e],s)===0?ss(n,e,a):(a++,ss(n,a,i)),a<=t&&(e=a+1),t<=a&&(i=a-1)}}function ss(n,t,e){let i=n[t];n[t]=n[e],n[e]=i}function v_(n,t){return n<t?-1:n>t?1:0}var En=class{constructor(t=9){this._maxEntries=Math.max(4,t),this._minEntries=Math.max(2,Math.ceil(this._maxEntries*.4)),this.clear()}all(){return this._all(this.data,[])}search(t){let e=this.data,i=[];if(!Vo(t,e))return i;let r=this.toBBox,s=[];for(;e;){for(let o=0;o<e.children.length;o++){let a=e.children[o],l=e.leaf?r(a):a;Vo(t,l)&&(e.leaf?i.push(a):Vc(t,l)?this._all(a,i):s.push(a))}e=s.pop()}return i}collides(t){let e=this.data;if(!Vo(t,e))return!1;let i=[];for(;e;){for(let r=0;r<e.children.length;r++){let s=e.children[r],o=e.leaf?this.toBBox(s):s;if(Vo(t,o)){if(e.leaf||Vc(t,o))return!0;i.push(s)}}e=i.pop()}return!1}load(t){if(!(t&&t.length))return this;if(t.length<this._minEntries){for(let i=0;i<t.length;i++)this.insert(t[i]);return this}let e=this._build(t.slice(),0,t.length-1,0);if(!this.data.children.length)this.data=e;else if(this.data.height===e.height)this._splitRoot(this.data,e);else{if(this.data.height<e.height){let i=this.data;this.data=e,e=i}this._insert(e,this.data.height-e.height-1,!0)}return this}insert(t){return t&&this._insert(t,this.data.height-1),this}clear(){return this.data=cr([]),this}remove(t,e){if(!t)return this;let i=this.data,r=this.toBBox(t),s=[],o=[],a,l,h;for(;i||s.length;){if(i||(i=s.pop(),l=s[s.length-1],a=o.pop(),h=!0),i.leaf){let c=S_(t,i.children,e);if(c!==-1)return i.children.splice(c,1),s.push(i),this._condense(s),this}!h&&!i.leaf&&Vc(i,r)?(s.push(i),o.push(a),a=0,l=i,i=i.children[0]):l?(a++,i=l.children[a],h=!1):i=null}return this}toBBox(t){return t}compareMinX(t,e){return t.minX-e.minX}compareMinY(t,e){return t.minY-e.minY}toJSON(){return this.data}fromJSON(t){return this.data=t,this}_all(t,e){let i=[];for(;t;)t.leaf?e.push(...t.children):i.push(...t.children),t=i.pop();return e}_build(t,e,i,r){let s=i-e+1,o=this._maxEntries,a;if(s<=o)return a=cr(t.slice(e,i+1)),lr(a,this.toBBox),a;r||(r=Math.ceil(Math.log(s)/Math.log(o)),o=Math.ceil(s/Math.pow(o,r-1))),a=cr([]),a.leaf=!1,a.height=r;let l=Math.ceil(s/o),h=l*Math.ceil(Math.sqrt(o));vg(t,e,i,h,this.compareMinX);for(let c=e;c<=i;c+=h){let d=Math.min(c+h-1,i);vg(t,c,d,l,this.compareMinY);for(let f=c;f<=d;f+=l){let g=Math.min(f+l-1,d);a.children.push(this._build(t,f,g,r-1))}}return lr(a,this.toBBox),a}_chooseSubtree(t,e,i,r){for(;r.push(e),!(e.leaf||r.length-1===i);){let s=1/0,o=1/0,a;for(let l=0;l<e.children.length;l++){let h=e.children[l],c=Yc(h),d=I_(t,h)-c;d<o?(o=d,s=c<s?c:s,a=h):d===o&&c<s&&(s=c,a=h)}e=a||e.children[0]}return e}_insert(t,e,i){let r=i?t:this.toBBox(t),s=[],o=this._chooseSubtree(r,this.data,e,s);for(o.children.push(t),as(o,r);e>=0&&s[e].children.length>this._maxEntries;)this._split(s,e),e--;this._adjustParentBBoxes(r,s,e)}_split(t,e){let i=t[e],r=i.children.length,s=this._minEntries;this._chooseSplitAxis(i,s,r);let o=this._chooseSplitIndex(i,s,r),a=cr(i.children.splice(o,i.children.length-o));a.height=i.height,a.leaf=i.leaf,lr(i,this.toBBox),lr(a,this.toBBox),e?t[e-1].children.push(a):this._splitRoot(i,a)}_splitRoot(t,e){this.data=cr([t,e]),this.data.height=t.height+1,this.data.leaf=!1,lr(this.data,this.toBBox)}_chooseSplitIndex(t,e,i){let r,s=1/0,o=1/0;for(let a=e;a<=i-e;a++){let l=os(t,0,a,this.toBBox),h=os(t,a,i,this.toBBox),c=b_(l,h),d=Yc(l)+Yc(h);c<s?(s=c,r=a,o=d<o?d:o):c===s&&d<o&&(o=d,r=a)}return r||i-e}_chooseSplitAxis(t,e,i){let r=t.leaf?this.compareMinX:R_,s=t.leaf?this.compareMinY:T_,o=this._allDistMargin(t,e,i,r),a=this._allDistMargin(t,e,i,s);o<a&&t.children.sort(r)}_allDistMargin(t,e,i,r){t.children.sort(r);let s=this.toBBox,o=os(t,0,e,s),a=os(t,i-e,i,s),l=Yo(o)+Yo(a);for(let h=e;h<i-e;h++){let c=t.children[h];as(o,t.leaf?s(c):c),l+=Yo(o)}for(let h=i-e-1;h>=e;h--){let c=t.children[h];as(a,t.leaf?s(c):c),l+=Yo(a)}return l}_adjustParentBBoxes(t,e,i){for(let r=i;r>=0;r--)as(e[r],t)}_condense(t){for(let e=t.length-1,i;e>=0;e--)t[e].children.length===0?e>0?(i=t[e-1].children,i.splice(i.indexOf(t[e]),1)):this.clear():lr(t[e],this.toBBox)}};function S_(n,t,e){if(!e)return t.indexOf(n);for(let i=0;i<t.length;i++)if(e(n,t[i]))return i;return-1}function lr(n,t){os(n,0,n.children.length,t,n)}function os(n,t,e,i,r){r||(r=cr(null)),r.minX=1/0,r.minY=1/0,r.maxX=-1/0,r.maxY=-1/0;for(let s=t;s<e;s++){let o=n.children[s];as(r,n.leaf?i(o):o)}return r}function as(n,t){return n.minX=Math.min(n.minX,t.minX),n.minY=Math.min(n.minY,t.minY),n.maxX=Math.max(n.maxX,t.maxX),n.maxY=Math.max(n.maxY,t.maxY),n}function R_(n,t){return n.minX-t.minX}function T_(n,t){return n.minY-t.minY}function Yc(n){return(n.maxX-n.minX)*(n.maxY-n.minY)}function Yo(n){return n.maxX-n.minX+(n.maxY-n.minY)}function I_(n,t){return(Math.max(t.maxX,n.maxX)-Math.min(t.minX,n.minX))*(Math.max(t.maxY,n.maxY)-Math.min(t.minY,n.minY))}function b_(n,t){let e=Math.max(n.minX,t.minX),i=Math.max(n.minY,t.minY),r=Math.min(n.maxX,t.maxX),s=Math.min(n.maxY,t.maxY);return Math.max(0,r-e)*Math.max(0,s-i)}function Vc(n,t){return n.minX<=t.minX&&n.minY<=t.minY&&t.maxX<=n.maxX&&t.maxY<=n.maxY}function Vo(n,t){return t.minX<=n.maxX&&t.minY<=n.maxY&&t.maxX>=n.minX&&t.maxY>=n.minY}function cr(n){return{children:n,height:1,leaf:!0,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0}}function vg(n,t,e,i,r){let s=[t,e];for(;s.length;){if(e=s.pop(),t=s.pop(),e-t<=i)continue;let o=t+Math.ceil((e-t)/i/2)*i;Uo(n,o,t,e,r),s.push(t,o,o,e)}}var Cn=0,Ko=0,Ut=1<<Cn++,Q=1<<Cn++,Yt=1<<Cn++,Zt=1<<Cn++,xi=1<<Cn++,wn=1<<Cn++,Bo=Math.pow(2,Cn)-1,Kc={[Ut]:"boolean",[Q]:"number",[Yt]:"string",[Zt]:"color",[xi]:"number[]",[wn]:"size"},L_=Object.keys(Kc).map(Number).sort(Bt);function A_(n){return n in Kc}function yi(n){let t=[];for(let e of L_)ls(n,e)&&t.push(Kc[e]);return t.length===0?"untyped":t.length<3?t.join(" or "):t.slice(0,-1).join(", ")+", or "+t[t.length-1]}function ls(n,t){return(n&t)===t}function Zo(n,t){return!!(n&t)}function Zi(n,t){return n===t}var ft=class{constructor(t,e){if(!A_(t))throw new Error(`literal expressions must have a specific type, got ${yi(t)}`);this.type=t,this.value=e}},jo=class{constructor(t,e,...i){this.type=t,this.operator=e,this.args=i}};function Ho(n){return{variables:new Map,properties:new Map,featureId:!1,geometryType:!1,mCoordinate:!1,mapState:!1,inputVariables:n}}function _t(n,t,e){switch(typeof n){case"boolean":{if(Zi(t,Yt))return new ft(Yt,n?"true":"false");if(!ls(t,Ut))throw new Error(`got a boolean, but expected ${yi(t)}`);return new ft(Ut,n)}case"number":{if(Zi(t,wn))return new ft(wn,mt(n));if(Zi(t,Ut))return new ft(Ut,!!n);if(Zi(t,Yt))return new ft(Yt,n.toString());if(!ls(t,Q))throw new Error(`got a number, but expected ${yi(t)}`);return new ft(Q,n)}case"string":{if(Zi(t,Zt))return new ft(Zt,Br(n));if(Zi(t,Ut))return new ft(Ut,!!n);if(!ls(t,Yt))throw new Error(`got a string, but expected ${yi(t)}`);return new ft(Yt,n)}default:}if(!Array.isArray(n))throw new Error("expression must be an array or a primitive value");if(n.length===0)throw new Error("empty expression");if(typeof n[0]=="string")return U_(n,t,e);for(let i of n)if(typeof i!="number")throw new Error("expected an array of numbers");if(Zi(t,wn)){if(n.length!==2)throw new Error(`expected an array of two values for a size, got ${n.length}`);return new ft(wn,n)}if(Zi(t,Zt)){if(n.length===3)return new ft(Zt,[...n,1]);if(n.length===4)return new ft(Zt,n);throw new Error(`expected an array of 3 or 4 values for a color, got ${n.length}`)}if(!ls(t,xi))throw new Error(`got an array of numbers, but expected ${yi(t)}`);return new ft(xi,n)}var S={Get:"get",Var:"var",Concat:"concat",GeometryType:"geometry-type",LineMetric:"line-metric",Any:"any",All:"all",Not:"!",Resolution:"resolution",Zoom:"zoom",Time:"time",Equal:"==",NotEqual:"!=",GreaterThan:">",GreaterThanOrEqualTo:">=",LessThan:"<",LessThanOrEqualTo:"<=",Multiply:"*",Divide:"/",Add:"+",Subtract:"-",Clamp:"clamp",Mod:"%",Pow:"^",Abs:"abs",Floor:"floor",Ceil:"ceil",Round:"round",Sin:"sin",Cos:"cos",Atan:"atan",Sqrt:"sqrt",Match:"match",Between:"between",Interpolate:"interpolate",Coalesce:"coalesce",Case:"case",In:"in",Number:"number",String:"string",Array:"array",Color:"color",Id:"id",Band:"band",Palette:"palette",ToString:"to-string",Has:"has"},M_={[S.Get]:V(q(1,1/0),Sg),[S.Var]:P_(),[S.Has]:V(q(1,1/0),Sg),[S.Id]:V(O_,hr),[S.Concat]:V(q(2,1/0),st(Yt)),[S.GeometryType]:V(D_,hr),[S.LineMetric]:V(k_,hr),[S.Resolution]:V(Zc,hr),[S.Zoom]:V(Zc,hr),[S.Time]:V(Zc,hr),[S.Any]:V(q(2,1/0),st(Ut)),[S.All]:V(q(2,1/0),st(Ut)),[S.Not]:V(q(1,1),st(Ut)),[S.Equal]:V(q(2,2),Tg()),[S.NotEqual]:V(q(2,2),Tg()),[S.GreaterThan]:V(q(2,2),st(Q)),[S.GreaterThanOrEqualTo]:V(q(2,2),st(Q)),[S.LessThan]:V(q(2,2),st(Q)),[S.LessThanOrEqualTo]:V(q(2,2),st(Q)),[S.Multiply]:V(q(2,1/0),Rg),[S.Coalesce]:V(q(2,1/0),Rg),[S.Divide]:V(q(2,2),st(Q)),[S.Add]:V(q(2,1/0),st(Q)),[S.Subtract]:V(q(2,2),st(Q)),[S.Clamp]:V(q(3,3),st(Q)),[S.Mod]:V(q(2,2),st(Q)),[S.Pow]:V(q(2,2),st(Q)),[S.Abs]:V(q(1,1),st(Q)),[S.Floor]:V(q(1,1),st(Q)),[S.Ceil]:V(q(1,1),st(Q)),[S.Round]:V(q(1,1),st(Q)),[S.Sin]:V(q(1,1),st(Q)),[S.Cos]:V(q(1,1),st(Q)),[S.Atan]:V(q(1,2),st(Q)),[S.Sqrt]:V(q(1,1),st(Q)),[S.Match]:V(q(4,1/0),Ig,N_),[S.Between]:V(q(3,3),st(Q)),[S.Interpolate]:V(q(6,1/0),Ig,z_),[S.Case]:V(q(3,1/0),F_,G_),[S.In]:V(q(2,2),X_),[S.Number]:V(q(1,1/0),st(Bo)),[S.String]:V(q(1,1/0),st(Bo)),[S.Array]:V(q(1,1/0),st(Q)),[S.Color]:V(q(1,4),st(Q)),[S.Band]:V(q(1,3),st(Q)),[S.Palette]:V(q(2,2),W_),[S.ToString]:V(q(1,1),st(Ut|Q|Yt|Zt))};function Sg(n,t,e){let i=n.length-1,r=new Array(i);for(let s=0;s<i;++s){let o=n[s+1];switch(typeof o){case"number":{r[s]=new ft(Q,o);break}case"string":{r[s]=new ft(Yt,o);break}default:throw new Error(`expected a string key or numeric array index for a get operation, got ${o}`)}s===0&&e.properties.set(String(o),t)}return r}function P_(){return function(n,t,e){let i=n[1];if(typeof i!="string")throw new Error("expected a string argument for var operation");let r=t,s=e.inputVariables?.[i];if(s!==void 0){let o=_t(s,Bo,e);if(!(o instanceof ft))throw new Error(`style variables should only be literal values (no expressions!), variable name: ${i}`);let a=o.type;if(typeof s=="string"&&Zo(r,Zt)&&!Zo(r,Yt)?a=Zt:Array.isArray(s)&&s.length===2&&Zo(r,wn)&&!Zo(r,xi)&&(a=wn),r&=a,r===Ko)throw new Error(`the type expected from the var operator (${yi(t)}) did not have any overlap with the type of the corresponding style variables (${yi(a)}), variable name: ${i}`)}if(e.variables.has(i)){let o=e.variables.get(i);if(r&=o,r===Ko)throw new Error(`a new type expected from the var operator (${yi(t)}) did not have any overlap with the previous type expected for it (${yi(o)}), variable name: ${i}`)}return e.variables.set(i,r),new jo(r,"var",new ft(Yt,i))}}function O_(n,t,e){e.featureId=!0}function D_(n,t,e){e.geometryType=!0}function k_(n,t,e){e.mCoordinate=!0}function Zc(n,t,e){e.mapState=!0}function hr(n,t,e){let i=n[0];if(n.length!==1)throw new Error(`expected no arguments for ${i} operation`);return[]}function q(n,t){return function(e,i,r){let s=e[0],o=e.length-1;if(n===t){if(o!==n){let a=n===1?"":"s";throw new Error(`expected ${n} argument${a} for ${s}, got ${o}`)}}else if(o<n||o>t){let a=t===1/0?`${n} or more`:`${n} to ${t}`;throw new Error(`expected ${a} arguments for ${s}, got ${o}`)}}}function Rg(n,t,e){let i=n.length-1,r=new Array(i);for(let s=0;s<i;++s){let o=_t(n[s+1],t,e);r[s]=o}return r}function st(n){return function(t,e,i){let r=t.length-1,s=new Array(r);for(let o=0;o<r;++o){let a=_t(t[o+1],n,i);s[o]=a}return s}}function Tg(){return function(n,t,e){let i=n[0],r=n.length-1,s=new Array(r),o=Bo;for(let a=0;a<r;++a){let l=_t(n[a+1],o,e);o&=l.type}if(o===Ko)throw new Error(`no common type was found among the arguments of ${i}`);for(let a=0;a<r;++a){let l=_t(n[a+1],o,e);s[a]=l}return s}}function F_(n,t,e){let i=n[0],r=n.length-1;if(r%2===0)throw new Error(`expected an odd number of arguments for ${i}, got ${r} instead`)}function Ig(n,t,e){let i=n[0],r=n.length-1;if(r%2===1)throw new Error(`expected an even number of arguments for operation ${i}, got ${r} instead`)}function N_(n,t,e){let i=n.length-1,r=_t(n[n.length-1],t,e),s=Yt|Q|Ut,o=new Array(i-2);for(let l=0;l<i-2;l+=2){try{let h=_t(n[l+2],s,e);s&=h.type}catch(h){throw new Error(`failed to parse argument ${l+1} of match expression: ${h.message}`)}if(s===Ko)throw new Error("no common type was found among the arguments of match expression")}for(let l=0;l<i-2;l+=2){try{let h=_t(n[l+2],s,e);o[l]=h}catch(h){throw new Error(`failed to parse argument ${l+1} of match expression: ${h.message}`)}try{let h=_t(n[l+3],r.type,e);o[l+1]=h}catch(h){throw new Error(`failed to parse argument ${l+2} of match expression: ${h.message}`)}}return[_t(n[1],s,e),...o,r]}function z_(n,t,e){let i=n[1],r;switch(i[0]){case"linear":r=1;break;case"exponential":let l=i[1];if(typeof l!="number"||l<=0)throw new Error(`expected a number base for exponential interpolation, got ${JSON.stringify(l)} instead`);r=l;break;default:throw new Error(`invalid interpolation type: ${JSON.stringify(i)}`)}let s=new ft(Q,r),o;try{o=_t(n[2],Q,e)}catch(l){throw new Error(`failed to parse argument 1 in interpolate expression: ${l.message}`)}let a=new Array(n.length-3);for(let l=0;l<a.length;l+=2){try{let h=_t(n[l+3],Q,e);a[l]=h}catch(h){throw new Error(`failed to parse argument ${l+2} for interpolate expression: ${h.message}`)}try{let h=_t(n[l+4],t,e);a[l+1]=h}catch(h){throw new Error(`failed to parse argument ${l+3} for interpolate expression: ${h.message}`)}}return[s,o,...a]}function G_(n,t,e){let i=_t(n[n.length-1],t,e),r=new Array(n.length-1);for(let s=0;s<r.length-1;s+=2){try{let o=_t(n[s+1],Ut,e);r[s]=o}catch(o){throw new Error(`failed to parse argument ${s} of case expression: ${o.message}`)}try{let o=_t(n[s+2],i.type,e);r[s+1]=o}catch(o){throw new Error(`failed to parse argument ${s+1} of case expression: ${o.message}`)}}return r[r.length-1]=i,r}function X_(n,t,e){let i=n[2];if(!Array.isArray(i))throw new Error('the second argument for the "in" operator must be an array');let r;if(i[0]==="literal"){if(i=i[1],!Array.isArray(i))throw new Error('failed to parse "in" expression: the literal operator must be followed by an array')}else if(typeof i[0]=="string")throw new Error('for the "in" operator, a string array should be wrapped in a "literal" operator to disambiguate from expressions');typeof i[0]=="string"?r=Yt:r=Q;let s=new Array(i.length);for(let a=0;a<s.length;a++)try{let l=_t(i[a],r,e);s[a]=l}catch(l){throw new Error(`failed to parse haystack item ${a} for "in" expression: ${l.message}`)}return[_t(n[1],r,e),...s]}function W_(n,t,e){let i;try{i=_t(n[1],Q,e)}catch(o){throw new Error(`failed to parse first argument in palette expression: ${o.message}`)}let r=n[2];if(!Array.isArray(r))throw new Error("the second argument of palette must be an array");let s=new Array(r.length);for(let o=0;o<s.length;o++){let a;try{a=_t(r[o],Zt,e)}catch(l){throw new Error(`failed to parse color at index ${o} in palette expression: ${l.message}`)}if(!(a instanceof ft))throw new Error(`the palette color at index ${o} must be a literal value`);s[o]=a}return[i,...s]}function V(...n){return function(t,e,i){let r=t[0],s;for(let o=0;o<n.length;o++){let a=n[o](t,e,i);if(o==n.length-1){if(!a)throw new Error("expected last argument validator to return the parsed args");s=a}}return new jo(e,r,...s)}}function U_(n,t,e){let i=n[0],r=M_[i];if(!r)throw new Error(`unknown operator: ${i}`);return r(n,t,e)}function qo(n){if(!n)return"";let t=n.getType();switch(t){case"Point":case"LineString":case"Polygon":return t;case"MultiPoint":case"MultiLineString":case"MultiPolygon":return t.substring(5);case"Circle":return"Polygon";case"GeometryCollection":return qo(n.getGeometries()[0]);default:return""}}function Bc(){return{variables:{},properties:{},resolution:NaN,featureId:null,geometryType:""}}function Le(n,t,e){let i=_t(n,t,e);return be(i,e)}function be(n,t){if(n instanceof ft){if(n.type===Zt&&typeof n.value=="string"){let i=Br(n.value);return function(){return i}}return function(){return n.value}}let e=n.operator;switch(e){case S.Number:case S.String:case S.Coalesce:return Y_(n,t);case S.Get:case S.Var:case S.Has:return V_(n,t);case S.Id:return i=>i.featureId;case S.GeometryType:return i=>i.geometryType;case S.Concat:{let i=n.args.map(r=>be(r,t));return r=>"".concat(...i.map(s=>s(r).toString()))}case S.Resolution:return i=>i.resolution;case S.Any:case S.All:case S.Between:case S.In:case S.Not:return K_(n,t);case S.Equal:case S.NotEqual:case S.LessThan:case S.LessThanOrEqualTo:case S.GreaterThan:case S.GreaterThanOrEqualTo:return Z_(n,t);case S.Multiply:case S.Divide:case S.Add:case S.Subtract:case S.Clamp:case S.Mod:case S.Pow:case S.Abs:case S.Floor:case S.Ceil:case S.Round:case S.Sin:case S.Cos:case S.Atan:case S.Sqrt:return B_(n,t);case S.Case:return j_(n,t);case S.Match:return H_(n,t);case S.Interpolate:return q_(n,t);case S.ToString:return $_(n,t);default:throw new Error(`Unsupported operator ${e}`)}}function Y_(n,t){let e=n.operator,i=n.args.length,r=new Array(i);for(let s=0;s<i;++s)r[s]=be(n.args[s],t);switch(e){case S.Coalesce:return s=>{for(let o=0;o<i;++o){let a=r[o](s);if(typeof a<"u"&&a!==null)return a}throw new Error("Expected one of the values to be non-null")};case S.Number:case S.String:return s=>{for(let o=0;o<i;++o){let a=r[o](s);if(typeof a===e)return a}throw new Error(`Expected one of the values to be a ${e}`)};default:throw new Error(`Unsupported assertion operator ${e}`)}}function V_(n,t){let i=n.args[0].value;switch(n.operator){case S.Get:return r=>{let s=n.args,o=r.properties[i];for(let a=1,l=s.length;a<l;++a){let c=s[a].value;o=o[c]}return o};case S.Var:return r=>r.variables[i];case S.Has:return r=>{let s=n.args;if(!(i in r.properties))return!1;let o=r.properties[i];for(let a=1,l=s.length;a<l;++a){let c=s[a].value;if(!o||!Object.hasOwn(o,c))return!1;o=o[c]}return!0};default:throw new Error(`Unsupported accessor operator ${n.operator}`)}}function Z_(n,t){let e=n.operator,i=be(n.args[0],t),r=be(n.args[1],t);switch(e){case S.Equal:return s=>i(s)===r(s);case S.NotEqual:return s=>i(s)!==r(s);case S.LessThan:return s=>i(s)<r(s);case S.LessThanOrEqualTo:return s=>i(s)<=r(s);case S.GreaterThan:return s=>i(s)>r(s);case S.GreaterThanOrEqualTo:return s=>i(s)>=r(s);default:throw new Error(`Unsupported comparison operator ${e}`)}}function K_(n,t){let e=n.operator,i=n.args.length,r=new Array(i);for(let s=0;s<i;++s)r[s]=be(n.args[s],t);switch(e){case S.Any:return s=>{for(let o=0;o<i;++o)if(r[o](s))return!0;return!1};case S.All:return s=>{for(let o=0;o<i;++o)if(!r[o](s))return!1;return!0};case S.Between:return s=>{let o=r[0](s),a=r[1](s),l=r[2](s);return o>=a&&o<=l};case S.In:return s=>{let o=r[0](s);for(let a=1;a<i;++a)if(o===r[a](s))return!0;return!1};case S.Not:return s=>!r[0](s);default:throw new Error(`Unsupported logical operator ${e}`)}}function B_(n,t){let e=n.operator,i=n.args.length,r=new Array(i);for(let s=0;s<i;++s)r[s]=be(n.args[s],t);switch(e){case S.Multiply:return s=>{let o=1;for(let a=0;a<i;++a)o*=r[a](s);return o};case S.Divide:return s=>r[0](s)/r[1](s);case S.Add:return s=>{let o=0;for(let a=0;a<i;++a)o+=r[a](s);return o};case S.Subtract:return s=>r[0](s)-r[1](s);case S.Clamp:return s=>{let o=r[0](s),a=r[1](s);if(o<a)return a;let l=r[2](s);return o>l?l:o};case S.Mod:return s=>r[0](s)%r[1](s);case S.Pow:return s=>Math.pow(r[0](s),r[1](s));case S.Abs:return s=>Math.abs(r[0](s));case S.Floor:return s=>Math.floor(r[0](s));case S.Ceil:return s=>Math.ceil(r[0](s));case S.Round:return s=>Math.round(r[0](s));case S.Sin:return s=>Math.sin(r[0](s));case S.Cos:return s=>Math.cos(r[0](s));case S.Atan:return i===2?s=>Math.atan2(r[0](s),r[1](s)):s=>Math.atan(r[0](s));case S.Sqrt:return s=>Math.sqrt(r[0](s));default:throw new Error(`Unsupported numeric operator ${e}`)}}function j_(n,t){let e=n.args.length,i=new Array(e);for(let r=0;r<e;++r)i[r]=be(n.args[r],t);return r=>{for(let s=0;s<e-1;s+=2)if(i[s](r))return i[s+1](r);return i[e-1](r)}}function H_(n,t){let e=n.args.length,i=new Array(e);for(let r=0;r<e;++r)i[r]=be(n.args[r],t);return r=>{let s=i[0](r);for(let o=1;o<e-1;o+=2)if(s===i[o](r))return i[o+1](r);return i[e-1](r)}}function q_(n,t){let e=n.args.length,i=new Array(e);for(let r=0;r<e;++r)i[r]=be(n.args[r],t);return r=>{let s=i[0](r),o=i[1](r),a,l;for(let h=2;h<e;h+=2){let c=i[h](r),d=i[h+1](r),f=Array.isArray(d);if(f&&(d=Jd(d)),c>=o)return h===2?d:f?J_(s,o,a,l,c,d):cs(s,o,a,l,c,d);a=c,l=d}return l}}function $_(n,t){let e=n.operator,i=n.args.length,r=new Array(i);for(let s=0;s<i;++s)r[s]=be(n.args[s],t);if(e===S.ToString)return s=>{let o=r[0](s);return n.args[0].type===Zt?jr(o):o.toString()};throw new Error(`Unsupported convert operator ${e}`)}function cs(n,t,e,i,r,s){let o=r-e;if(o===0)return i;let a=t-e,l=n===1?a/o:(Math.pow(n,a)-1)/(Math.pow(n,o)-1);return i+l*(s-i)}function J_(n,t,e,i,r,s){if(r-e===0)return i;let a=Fl(i),l=Fl(s),h=l[2]-a[2];h>180?h-=360:h<-180&&(h+=360);let c=[cs(n,t,e,a[0],r,l[0]),cs(n,t,e,a[1],r,l[1]),a[2]+cs(n,t,e,0,r,h),cs(n,t,e,i[3],r,s[3])];return Qd(c)}function Q_(n){return!0}function ty(n,t){t=t??Ho();let e=ey(n,t),i=Bc();return function(r,s){if(i.properties=r.getPropertiesInternal(),i.resolution=s,t.featureId){let o=r.getId();o!==void 0?i.featureId=o:i.featureId=null}return t.geometryType&&(i.geometryType=qo(r.getGeometry())),e(i)}}function bg(n,t){t=t??Ho();let e=n.length,i=new Array(e);for(let o=0;o<e;++o)i[o]=jc(n[o],t);let r=Bc(),s=new Array(e);return function(o,a){if(r.properties=o.getPropertiesInternal(),r.resolution=a,t.featureId){let h=o.getId();h!==void 0?r.featureId=h:r.featureId=null}t.geometryType&&(r.geometryType=qo(o.getGeometry()));let l=0;for(let h=0;h<e;++h){let c=i[h](r);c&&(s[l]=c,l+=1)}return s.length=l,s}}function Pg(n,t){if(t=t??Ho(),!Array.isArray(n))return bg([n],t);let e=n.length;if("style"in n[0]){let s=new Array(e);for(let o=0;o<e;++o){let a=n[o];if(!("style"in a))throw new Error("Expected a list of rules with a style property");s[o]=a}return ty(s,t)}return bg(n,t)}function ey(n,t){let e=n.length,i=new Array(e);for(let r=0;r<e;++r){let s=n[r],o="filter"in s?Le(s.filter,Ut,t):Q_,a;if(Array.isArray(s.style)){let l=s.style.length;a=new Array(l);for(let h=0;h<l;++h)a[h]=jc(s.style[h],t)}else a=[jc(s.style,t)];i[r]={filter:o,styles:a}}return function(r){let s=[],o=!1;for(let a=0;a<e;++a){let l=i[a].filter;if(l(r)&&!(n[a].else&&o)){o=!0;for(let h of i[a].styles){let c=h(r);c&&s.push(c)}}}return s}}function jc(n,t){let e=hs(n,"",t),i=us(n,"",t),r=iy(n,t),s=ny(n,t),o=Nt(n,"z-index",t);if(!e&&!i&&!r&&!s&&!xe(n))throw new Error("No fill, stroke, point, or text symbolizer properties in style: "+JSON.stringify(n));let a=new It;return function(l){let h=!0;if(e){let c=e(l);c&&(h=!1),a.setFill(c)}if(i){let c=i(l);c&&(h=!1),a.setStroke(c)}if(r){let c=r(l);c&&(h=!1),a.setText(c)}if(s){let c=s(l);c&&(h=!1),a.setImage(c)}return o&&a.setZIndex(o(l)),h?null:a}}function hs(n,t,e){let i;if(t+"fill-pattern-src"in n)i=ay(n,t+"fill-",e);else{if(n[t+"fill-color"]==="none")return s=>null;i=Jo(n,t+"fill-color",e)}if(!i)return null;let r=new pt;return function(s){let o=i(s);return o===xo?null:(r.setColor(o),r)}}function us(n,t,e){let i=Nt(n,t+"stroke-width",e),r=Jo(n,t+"stroke-color",e);if(!i&&!r)return null;let s=Ei(n,t+"stroke-line-cap",e),o=Ei(n,t+"stroke-line-join",e),a=Og(n,t+"stroke-line-dash",e),l=Nt(n,t+"stroke-line-dash-offset",e),h=Nt(n,t+"stroke-miter-limit",e),c=Nt(n,t+"stroke-offset",e),d=new Mt;return function(f){if(r){let g=r(f);if(g===xo)return null;d.setColor(g)}if(i&&d.setWidth(i(f)),s){let g=s(f);if(g!=="butt"&&g!=="round"&&g!=="square")throw new Error("Expected butt, round, or square line cap");d.setLineCap(g)}if(o){let g=o(f);if(g!=="bevel"&&g!=="round"&&g!=="miter")throw new Error("Expected bevel, round, or miter line join");d.setLineJoin(g)}return a&&d.setLineDash(a(f)),l&&d.setLineDashOffset(l(f)),h&&d.setMiterLimit(h(f)),c&&d.setOffset(c(f)),d}}function iy(n,t){let e="text-",i=Ei(n,e+"value",t);if(!i)return null;let r=hs(n,e,t),s=hs(n,e+"background-",t),o=us(n,e,t),a=us(n,e+"background-",t),l=Ei(n,e+"font",t),h=Nt(n,e+"max-angle",t),c=Nt(n,e+"offset-x",t),d=Nt(n,e+"offset-y",t),f=ur(n,e+"overflow",t),g=Ei(n,e+"placement",t),m=Nt(n,e+"repeat",t),_=Qo(n,e+"scale",t),p=ur(n,e+"rotate-with-view",t),y=Nt(n,e+"rotation",t),E=Ei(n,e+"align",t),C=Ei(n,e+"justify",t),x=Ei(n,e+"baseline",t),w=ur(n,e+"keep-upright",t),T=Og(n,e+"padding",t),A=ta(n,e+"declutter-mode"),R=new _i({declutterMode:A});return function(I){if(R.setText(i(I)),r&&R.setFill(r(I)),s&&R.setBackgroundFill(s(I)),o&&R.setStroke(o(I)),a&&R.setBackgroundStroke(a(I)),l&&R.setFont(l(I)),h&&R.setMaxAngle(h(I)),c&&R.setOffsetX(c(I)),d&&R.setOffsetY(d(I)),f&&R.setOverflow(f(I)),g){let b=g(I);if(b!=="point"&&b!=="line")throw new Error("Expected point or line for text-placement");R.setPlacement(b)}if(m&&R.setRepeat(m(I)),_&&R.setScale(_(I)),p&&R.setRotateWithView(p(I)),y&&R.setRotation(y(I)),E){let b=E(I);if(b!=="left"&&b!=="center"&&b!=="right"&&b!=="end"&&b!=="start")throw new Error("Expected left, right, center, start, or end for text-align");R.setTextAlign(b)}if(C){let b=C(I);if(b!=="left"&&b!=="right"&&b!=="center")throw new Error("Expected left, right, or center for text-justify");R.setJustify(b)}if(x){let b=x(I);if(b!=="bottom"&&b!=="top"&&b!=="middle"&&b!=="alphabetic"&&b!=="hanging")throw new Error("Expected bottom, top, middle, alphabetic, or hanging for text-baseline");R.setTextBaseline(b)}return T&&R.setPadding(T(I)),w&&R.setKeepUpright(w(I)),R}}function ny(n,t){return"icon-src"in n?ry(n,t):"shape-points"in n?sy(n,t):"circle-radius"in n?oy(n,t):null}function ry(n,t){let e="icon-",i=e+"src",r=Dg(n[i],i),s=$o(n,e+"anchor",t),o=Qo(n,e+"scale",t),a=Nt(n,e+"opacity",t),l=$o(n,e+"displacement",t),h=Nt(n,e+"rotation",t),c=ur(n,e+"rotate-with-view",t),d=Ag(n,e+"anchor-origin"),f=Mg(n,e+"anchor-x-units"),g=Mg(n,e+"anchor-y-units"),m=wi(n,e+"color"),_,p=null;m!==void 0&&(Array.isArray(m)&&m.length>0&&typeof m[0]=="string"?p=Jo(n,e+"color",t):_=kg(m,e+"color"));let y=cy(n,e+"cross-origin"),E=hy(n,e+"offset"),C=Ag(n,e+"offset-origin"),x=Hc(n,e+"width"),w=Hc(n,e+"height"),T=ly(n,e+"size"),A=ta(n,e+"declutter-mode"),R={src:r,anchorOrigin:d,anchorXUnits:f,anchorYUnits:g,crossOrigin:y,offset:E,offsetOrigin:C,height:w,width:x,size:T,declutterMode:A},I=null;return function(b){if(I)p&&I.setColor(p(b));else{let N=p?p(b):_;I=new pn(N!==void 0?Object.assign({},R,{color:N}):Object.assign({},R))}return a&&I.setOpacity(a(b)),l&&I.setDisplacement(l(b)),h&&I.setRotation(h(b)),c&&I.setRotateWithView(c(b)),o&&I.setScale(o(b)),s&&I.setAnchor(s(b)),I}}function sy(n,t){let e="shape-",i=e+"points",r=e+"radius",s=qc(n[i],i);if(!(r in n))throw new Error(`Expected a number for ${r}`);let o=Nt(n,r,t),a=typeof n[r]=="number"?n[r]:5,l=e+"radius2",h=Nt(n,l,t),c=typeof n[l]=="number"?n[l]:void 0,d=hs(n,e,t),f=us(n,e,t),g=Qo(n,e+"scale",t),m=$o(n,e+"displacement",t),_=Nt(n,e+"rotation",t),p=ur(n,e+"rotate-with-view",t),y=Hc(n,e+"angle"),E=ta(n,e+"declutter-mode"),C=new Ro({points:s,radius:a,radius2:c,angle:y,declutterMode:E});return function(x){return o&&C.setRadius(o(x)),h&&C.setRadius2(h(x)),d&&C.setFill(d(x)),f&&C.setStroke(f(x)),m&&C.setDisplacement(m(x)),_&&C.setRotation(_(x)),p&&C.setRotateWithView(p(x)),g&&C.setScale(g(x)),C}}function oy(n,t){let e="circle-",i=hs(n,e,t),r=us(n,e,t),s=Nt(n,e+"radius",t),o=Qo(n,e+"scale",t),a=$o(n,e+"displacement",t),l=Nt(n,e+"rotation",t),h=ur(n,e+"rotate-with-view",t),c=ta(n,e+"declutter-mode"),d=new To({radius:5,declutterMode:c});return function(f){return s&&d.setRadius(s(f)),i&&d.setFill(i(f)),r&&d.setStroke(r(f)),a&&d.setDisplacement(a(f)),l&&d.setRotation(l(f)),h&&d.setRotateWithView(h(f)),o&&d.setScale(o(f)),d}}function wi(n,t){if(!(t in n))return;let e=n[t];return e===void 0?void 0:e}function Nt(n,t,e){let i=wi(n,t);if(i===void 0)return;let r=Le(i,Q,e);return function(s){return qc(r(s),t)}}function Ei(n,t,e){let i=wi(n,t);if(i===void 0)return null;let r=Le(i,Yt,e);return function(s){return Dg(r(s),t)}}function ay(n,t,e){let i=Ei(n,t+"pattern-src",e),r=Lg(n,t+"pattern-offset",e),s=Lg(n,t+"pattern-size",e),o=Jo(n,t+"color",e);return function(a){return{src:i(a),offset:r&&r(a),size:s&&s(a),color:o&&o(a)}}}function ur(n,t,e){let i=wi(n,t);if(i===void 0)return null;let r=Le(i,Ut,e);return function(s){let o=r(s);if(typeof o!="boolean")throw new Error(`Expected a boolean for ${t}`);return o}}function Jo(n,t,e){let i=wi(n,t);if(i===void 0)return null;let r=Le(i,Zt,e);return function(s){return kg(r(s),t)}}function Og(n,t,e){let i=wi(n,t);if(i===void 0)return null;if(Array.isArray(i)&&(i.length===0||typeof i[0]!="string")){let s=i.map((o,a)=>{if(typeof o=="number")return()=>o;let l=Le(o,Q,e);return function(h){return qc(l(h),`${t}[${a}]`)}});return function(o){let a=new Array(s.length);for(let l=0;l<s.length;++l)a[l]=s[l](o);return a}}let r=Le(i,xi,e);return function(s){return ds(r(s),t)}}function $o(n,t,e){let i=wi(n,t);if(i===void 0)return null;let r=Le(i,xi,e);return function(s){let o=ds(r(s),t);if(o.length!==2)throw new Error(`Expected two numbers for ${t}`);return o}}function Lg(n,t,e){let i=wi(n,t);if(i===void 0)return null;let r=Le(i,xi,e);return function(s){return Fg(r(s),t)}}function Qo(n,t,e){let i=wi(n,t);if(i===void 0)return null;let r=Le(i,xi|Q,e);return function(s){return uy(r(s),t)}}function Hc(n,t){let e=n[t];if(e!==void 0){if(typeof e!="number")throw new Error(`Expected a number for ${t}`);return e}}function ly(n,t){let e=n[t];if(e!==void 0){if(typeof e=="number")return mt(e);if(!Array.isArray(e))throw new Error(`Expected a number or size array for ${t}`);if(e.length!==2||typeof e[0]!="number"||typeof e[1]!="number")throw new Error(`Expected a number or size array for ${t}`);return e}}function cy(n,t){let e=n[t];if(e!==void 0){if(typeof e!="string")throw new Error(`Expected a string for ${t}`);return e}}function Ag(n,t){let e=n[t];if(e!==void 0){if(e!=="bottom-left"&&e!=="bottom-right"&&e!=="top-left"&&e!=="top-right")throw new Error(`Expected bottom-left, bottom-right, top-left, or top-right for ${t}`);return e}}function Mg(n,t){let e=n[t];if(e!==void 0){if(e!=="pixels"&&e!=="fraction")throw new Error(`Expected pixels or fraction for ${t}`);return e}}function hy(n,t){let e=n[t];if(e!==void 0)return ds(e,t)}function ta(n,t){let e=n[t];if(e!==void 0){if(typeof e!="string")throw new Error(`Expected a string for ${t}`);if(e!=="declutter"&&e!=="obstacle"&&e!=="none")throw new Error(`Expected declutter, obstacle, or none for ${t}`);return e}}function ds(n,t){if(!Array.isArray(n))throw new Error(`Expected an array for ${t}`);let e=n.length;for(let i=0;i<e;++i)if(typeof n[i]!="number")throw new Error(`Expected an array of numbers for ${t}`);return n}function Dg(n,t){if(typeof n!="string")throw new Error(`Expected a string for ${t}`);return n}function qc(n,t){if(typeof n!="number")throw new Error(`Expected a number for ${t}`);return n}function kg(n,t){if(typeof n=="string")return n;let e=ds(n,t),i=e.length;if(i<3||i>4)throw new Error(`Expected a color with 3 or 4 values for ${t}`);return e}function Fg(n,t){let e=ds(n,t);if(e.length!==2)throw new Error(`Expected an array of two numbers for ${t}`);return e}function uy(n,t){return typeof n=="number"?n:Fg(n,t)}var Ng={RENDER_ORDER:"renderOrder"},$c=class extends xn{constructor(t){t=t||{};let e=Object.assign({},t);delete e.style,delete e.renderBuffer,delete e.updateWhileAnimating,delete e.updateWhileInteracting,super(e),this.declutter_=t.declutter?String(t.declutter):void 0,this.renderBuffer_=t.renderBuffer!==void 0?t.renderBuffer:100,this.style_=null,this.styleFunction_=void 0,this.setStyle(t.style),this.updateWhileAnimating_=t.updateWhileAnimating!==void 0?t.updateWhileAnimating:!1,this.updateWhileInteracting_=t.updateWhileInteracting!==void 0?t.updateWhileInteracting:!1}getDeclutter(){return this.declutter_}getFeatures(t){return super.getFeatures(t)}getRenderBuffer(){return this.renderBuffer_}getRenderOrder(){return this.get(Ng.RENDER_ORDER)}getStyle(){return this.style_}getStyleFunction(){return this.styleFunction_}getUpdateWhileAnimating(){return this.updateWhileAnimating_}getUpdateWhileInteracting(){return this.updateWhileInteracting_}renderDeclutter(t,e){let i=this.getDeclutter();i in t.declutter||(t.declutter[i]=new En(9)),this.getRenderer().renderDeclutter(t,e)}setRenderOrder(t){this.set(Ng.RENDER_ORDER,t)}setStyle(t){this.style_=t===void 0?Hl:t;let e=dy(t);this.styleFunction_=t===null?void 0:df(e),this.changed()}setDeclutter(t){this.declutter_=t?String(t):void 0,this.changed()}};function dy(n){if(n===void 0)return Hl;if(!n)return null;if(typeof n=="function"||n instanceof It)return n;if(Array.isArray(n)&&n.length===0)return[];if(Array.isArray(n)&&n[0]instanceof It){let e=n.length,i=new Array(e);for(let r=0;r<e;++r){let s=n[r];if(!(s instanceof It))throw new Error("Expected a list of style instances");i[r]=s}return i}return Pg(n)}var ea=$c;var Jc=class extends Lt{constructor(t,e,i,r){super(t),this.inversePixelTransform=e,this.frameState=i,this.context=r}},ia=Jc;var Qc=class extends Oi{constructor(t){super(),this.map_=t}dispatchRenderEvent(t,e){H()}calculateMatrices2D(t){let e=t.viewState,i=t.coordinateToPixelTransform,r=t.pixelToCoordinateTransform;Ot(i,t.size[0]/2,t.size[1]/2,1/e.resolution,-1/e.resolution,-e.rotation,-e.center[0],-e.center[1]),to(r,i)}forEachFeatureAtCoordinate(t,e,i,r,s,o,a,l){let h,c=e.viewState;function d(x,w,T,A){return s.call(o,w,x?T:null,A)}let f=c.projection,g=Fs(t.slice(),f),m=[[0,0]];if(f.canWrapX()&&r){let x=f.getExtent(),w=j(x);m.push([-w,0],[w,0])}let _=e.layerStatesArray,p=_.length,y=[],E=[];for(let x=0;x<m.length;x++)for(let w=p-1;w>=0;--w){let T=_[w],A=T.layer;if(A.hasRenderer()&&rs(T,c)&&a.call(l,A)){let R=A.getRenderer(),I=A.getSource();if(R&&I){let b=I.getWrapX()?g:t,N=d.bind(null,T.managed);E[0]=b[0]+m[x][0],E[1]=b[1]+m[x][1],h=R.forEachFeatureAtCoordinate(E,e,i,N,y)}if(h)return h}}if(y.length===0)return;let C=1/y.length;return y.forEach((x,w)=>x.distanceSq+=w*C),y.sort((x,w)=>x.distanceSq-w.distanceSq),y.some(x=>h=x.callback(x.feature,x.layer,x.geometry)),h}hasFeatureAtCoordinate(t,e,i,r,s,o){return this.forEachFeatureAtCoordinate(t,e,i,r,ai,this,s,o)!==void 0}getMap(){return this.map_}renderFrame(t){H()}scheduleExpireIconCache(t){Xt.canExpireCache()&&t.postRenderFunctions.push(fy)}};function fy(n,t){Xt.expire()}var zg=Qc;var th=class extends zg{constructor(t){super(t),this.fontChangeListenerKey_=Z(gn,Se.PROPERTYCHANGE,t.redrawText,t),this.element_=Rt?$s():document.createElement("div");let e=this.element_.style;e.position="absolute",e.width="100%",e.height="100%",e.zIndex="0",this.element_.className=Xi+" ol-layers";let i=t.getViewport();i&&i.insertBefore(this.element_,i.firstChild||null),this.children_=[],this.renderedVisible_=!0}dispatchRenderEvent(t,e){let i=this.getMap();if(i.hasListener(t)){let r=new ia(t,void 0,e);i.dispatchEvent(r)}}disposeInternal(){J(this.fontChangeListenerKey_),this.element_.remove(),super.disposeInternal()}renderFrame(t){if(!t){this.renderedVisible_&&(this.element_.style.display="none",this.renderedVisible_=!1);return}this.calculateMatrices2D(t),this.dispatchRenderEvent(Ft.PRECOMPOSE,t);let e=t.layerStatesArray.sort((c,d)=>c.zIndex-d.zIndex);e.some(c=>c.layer instanceof ea&&c.layer.getDeclutter())&&(t.declutter={});let r=t.viewState;this.children_.length=0;let o=this.getMap().getTargetElement(),a;te(o)&&(a=o.getContext("2d"),a.setTransform(1,0,0,1,0,0),a.clearRect(0,0,o.width,o.height));let l=[],h=a?o:null;for(let c=0,d=e.length;c<d;++c){let f=e[c];t.layerIndex=c;let g=f.layer,m=g.getSourceState();if(!rs(f,r)||m!="ready"&&m!="undefined"){g.unrender();continue}let _=g.render(t,h);_&&(_!==h&&(this.children_.push(_),h=_),l.push(f))}this.declutter(t,l),ad(this.element_,this.children_);for(let c of a?this.children_:[]){let d=c.firstElementChild||c,f=c.style.backgroundColor;if(f&&(!te(d)||d.width>0)&&(a.fillStyle=f,a.fillRect(0,0,a.canvas.width,a.canvas.height)),!te(d)||d.width===0)continue;a.save();let g=c.style.opacity||d.style.opacity;a.globalAlpha=g===""?1:Number(g);let m=d.style.transform;if(m)a.transform(...Qs(m));else{let _=parseFloat(d.style.width)/d.width,p=parseFloat(d.style.height)/d.height;a.transform(_,0,0,p,0,0)}a.drawImage(d,0,0),a.restore()}this.dispatchRenderEvent(Ft.POSTCOMPOSE,t),this.renderedVisible_||(this.element_.style.display="",this.renderedVisible_=!0),this.scheduleExpireIconCache(t)}declutter(t,e){if(t.declutter){for(let i=e.length-1;i>=0;--i){let r=e[i],s=r.layer;s.getDeclutter()&&s.renderDeclutter(t,r)}e.forEach(i=>i.layer.renderDeferred(t))}}},Gg=th;function Xg(n){if(n instanceof xn){n.setMapInternal(null);return}n instanceof ns&&n.getLayers().forEach(Xg)}function Wg(n,t){if(n instanceof xn){n.setMapInternal(t);return}if(n instanceof ns){let e=n.getLayers().getArray();for(let i=0,r=e.length;i<r;++i)Wg(e[i],t)}}var eh=class extends wt{constructor(t){super(),t=t||{},this.on,this.once,this.un;let e=gy(t);this.renderComplete_=!1,this.loaded_=!0,this.boundHandleBrowserEvent_=this.handleBrowserEvent.bind(this),this.maxTilesLoading_=t.maxTilesLoading!==void 0?t.maxTilesLoading:16,this.pixelRatio_=t.pixelRatio!==void 0?t.pixelRatio:ed,this.postRenderTimeoutHandle_,this.animationDelayKey_,this.animationDelay_=this.animationDelay_.bind(this),this.coordinateToPixelTransform_=At(),this.pixelToCoordinateTransform_=At(),this.frameIndex_=0,this.frameState_=null,this.previousExtent_=null,this.viewPropertyListenerKey_=null,this.viewChangeListenerKey_=null,this.layerGroupPropertyListenerKeys_=null,Rt||(this.viewport_=document.createElement("div"),this.viewport_.className="ol-viewport"+("ontouchstart"in window?" ol-touch":""),this.viewport_.style.position="relative",this.viewport_.style.overflow="hidden",this.viewport_.style.width="100%",this.viewport_.style.height="100%",this.overlayContainer_=document.createElement("div"),this.overlayContainer_.style.position="absolute",this.overlayContainer_.style.zIndex="0",this.overlayContainer_.style.width="100%",this.overlayContainer_.style.height="100%",this.overlayContainer_.style.pointerEvents="none",this.overlayContainer_.className="ol-overlaycontainer",this.viewport_.appendChild(this.overlayContainer_),this.overlayContainerStopEvent_=document.createElement("div"),this.overlayContainerStopEvent_.style.position="absolute",this.overlayContainerStopEvent_.style.zIndex="0",this.overlayContainerStopEvent_.style.width="100%",this.overlayContainerStopEvent_.style.height="100%",this.overlayContainerStopEvent_.style.pointerEvents="none",this.overlayContainerStopEvent_.className="ol-overlaycontainer-stopevent",this.viewport_.appendChild(this.overlayContainerStopEvent_)),this.mapBrowserEventHandler_=null,this.moveTolerance_=t.moveTolerance,this.keyboardEventTarget_=e.keyboardEventTarget,this.targetChangeHandlerKeys_=null,this.targetElement_=null,Rt||(this.resizeObserver_=new ResizeObserver(()=>this.updateSize())),this.controls=e.controls||(Rt?new Dt:Do()),this.interactions=e.interactions||(Rt?new Dt:Xo({onFocusOnly:!0})),this.overlays_=e.overlays,this.overlayIdIndex_={},this.renderer_=null,this.postRenderFunctions_=[],this.tileQueue_=new Hf(this.getTilePriority.bind(this),this.handleTileChange_.bind(this)),this.addChangeListener(kt.LAYERGROUP,this.handleLayerGroupChanged_),this.addChangeListener(kt.VIEW,this.handleViewChanged_),this.addChangeListener(kt.SIZE,this.handleSizeChanged_),this.addChangeListener(kt.TARGET,this.handleTargetChanged_),this.setProperties(e.values);let i=this;t.view&&!(t.view instanceof ee)&&t.view.then(function(r){i.setView(new ee(r))}),this.controls.addEventListener(Pt.ADD,r=>{r.element.setMap(this)}),this.controls.addEventListener(Pt.REMOVE,r=>{r.element.setMap(null)}),this.interactions.addEventListener(Pt.ADD,r=>{r.element.setMap(this)}),this.interactions.addEventListener(Pt.REMOVE,r=>{r.element.setMap(null)}),this.overlays_.addEventListener(Pt.ADD,r=>{this.addOverlayInternal_(r.element)}),this.overlays_.addEventListener(Pt.REMOVE,r=>{let s=r.element.getId();s!==void 0&&delete this.overlayIdIndex_[s.toString()],r.element.setMap(null)}),this.controls.forEach(r=>{r.setMap(this)}),this.interactions.forEach(r=>{r.setMap(this)}),this.overlays_.forEach(this.addOverlayInternal_.bind(this))}addControl(t){this.getControls().push(t)}addInteraction(t){this.getInteractions().push(t)}addLayer(t){this.getLayerGroup().getLayers().push(t)}handleLayerAdd_(t){Wg(t.layer,this)}addOverlay(t){this.getOverlays().push(t)}addOverlayInternal_(t){let e=t.getId();e!==void 0&&(this.overlayIdIndex_[e.toString()]=t),t.setMap(this)}disposeInternal(){this.controls.clear(),this.interactions.clear(),this.overlays_.clear(),this.resizeObserver_?.disconnect(),this.setTarget(null),super.disposeInternal()}forEachFeatureAtPixel(t,e,i){if(!this.frameState_||!this.renderer_)return;let r=this.getCoordinateFromPixelInternal(t);i=i!==void 0?i:{};let s=i.hitTolerance!==void 0?i.hitTolerance:0,o=i.layerFilter!==void 0?i.layerFilter:ai,a=i.checkWrapped!==!1;return this.renderer_.forEachFeatureAtCoordinate(r,this.frameState_,s,a,e,null,o,null)}getFeaturesAtPixel(t,e){let i=[];return this.forEachFeatureAtPixel(t,function(r){i.push(r)},e),i}getAllLayers(){let t=[];function e(i){i.forEach(function(r){r instanceof ns?e(r.getLayers()):t.push(r)})}return e(this.getLayers()),t}hasFeatureAtPixel(t,e){if(!this.frameState_||!this.renderer_)return!1;let i=this.getCoordinateFromPixelInternal(t);e=e!==void 0?e:{};let r=e.layerFilter!==void 0?e.layerFilter:ai,s=e.hitTolerance!==void 0?e.hitTolerance:0,o=e.checkWrapped!==!1;return this.renderer_.hasFeatureAtCoordinate(i,this.frameState_,s,o,r,null)}getEventCoordinate(t){return this.getCoordinateFromPixel(this.getEventPixel(t))}getEventCoordinateInternal(t){return this.getCoordinateFromPixelInternal(this.getEventPixel(t))}getEventPixel(t){let i=this.viewport_.getBoundingClientRect(),r=this.getSize(),s=i.width/r[0],o=i.height/r[1],a="changedTouches"in t?t.changedTouches[0]:t;return[(a.clientX-i.left)/s,(a.clientY-i.top)/o]}getTarget(){return this.get(kt.TARGET)}getTargetElement(){return this.targetElement_}getCoordinateFromPixel(t){return Mr(this.getCoordinateFromPixelInternal(t),this.getView().getProjection())}getCoordinateFromPixelInternal(t){let e=this.frameState_;return e?dt(e.pixelToCoordinateTransform,t.slice()):null}getControls(){return this.controls}getOverlays(){return this.overlays_}getOverlayById(t){let e=this.overlayIdIndex_[t.toString()];return e!==void 0?e:null}getInteractions(){return this.interactions}getLayerGroup(){return this.get(kt.LAYERGROUP)}setLayers(t){let e=this.getLayerGroup();if(t instanceof Dt){e.setLayers(t);return}let i=e.getLayers();i.clear(),i.extend(t)}getLayers(){return this.getLayerGroup().getLayers()}getLoadingOrNotReady(){let t=this.getLayerGroup().getLayerStatesArray();for(let e=0,i=t.length;e<i;++e){let r=t[e];if(!r.visible)continue;let s=r.layer.getRenderer();if(s&&!s.ready)return!0;let o=r.layer.getSource();if(o&&o.loading)return!0}return!1}getPixelFromCoordinate(t){let e=we(t,this.getView().getProjection());return this.getPixelFromCoordinateInternal(e)}getPixelFromCoordinateInternal(t){let e=this.frameState_;return e?dt(e.coordinateToPixelTransform,t.slice(0,2)):null}getPixelRatio(){return this.pixelRatio_}setPixelRatio(t){this.pixelRatio_!==t&&(this.pixelRatio_=t,this.render())}getRenderer(){return this.renderer_}getSize(){return this.get(kt.SIZE)}getView(){return this.get(kt.VIEW)}getViewport(){return this.viewport_}getOverlayContainer(){return this.overlayContainer_}getOverlayContainerStopEvent(){return this.overlayContainerStopEvent_}getOwnerDocument(){let t=this.getTargetElement();return t?t.ownerDocument:document}getTilePriority(t,e,i,r){return qf(this.frameState_,t,e,i,r)}handleBrowserEvent(t,e){e=e||t.type;let i=new Be(e,this,t);this.handleMapBrowserEvent(i)}handleMapBrowserEvent(t){if(!this.frameState_)return;let e=t.originalEvent,i=e.type;if(i===ts.POINTERDOWN||i===P.WHEEL||i===P.KEYDOWN){let r=this.getOwnerDocument(),s=this.viewport_.getRootNode?this.viewport_.getRootNode():r,o=e.target,a=s instanceof ShadowRoot?s.host===o?s.host.ownerDocument:s:s===r?r.documentElement:s;if(this.overlayContainerStopEvent_.contains(o)||!a.contains(o))return}if(t.frameState=this.frameState_,this.dispatchEvent(t)!==!1){let r=this.getInteractions().getArray().slice();for(let s=r.length-1;s>=0;s--){let o=r[s];if(o.getMap()!==this||!o.getActive()||!this.getTargetElement())continue;if(!o.handleEvent(t)||t.propagationStopped)break}}}handlePostRender(){let t=this.frameState_,e=this.tileQueue_;if(!e.isEmpty()){let r=this.maxTilesLoading_,s=r,o=t?t.viewHints:void 0,a=o?o[bt.ANIMATING]||o[bt.INTERACTING]:!1;if(a){let l=Date.now()-t.time>8;r=l?0:8,s=l?0:2}e.getTilesLoading()<r&&(a&&e.reprioritize(),e.loadMoreTiles(r,s))}t&&this.renderer_&&!t.animate&&(this.renderComplete_?(this.hasListener(Ft.RENDERCOMPLETE)&&this.renderer_.dispatchRenderEvent(Ft.RENDERCOMPLETE,t),this.loaded_===!1&&(this.loaded_=!0,this.dispatchEvent(new Ui(je.LOADEND,this,t)))):this.loaded_===!0&&(this.loaded_=!1,this.dispatchEvent(new Ui(je.LOADSTART,this,t))));let i=this.postRenderFunctions_;if(t)for(let r=0,s=i.length;r<s;++r)i[r](this,t);i.length=0}handleSizeChanged_(){this.getView()&&!this.getView().getAnimating()&&this.getView().resolveConstraints(0),this.render()}handleTargetChanged_(){if(this.mapBrowserEventHandler_){for(let i=0,r=this.targetChangeHandlerKeys_.length;i<r;++i)J(this.targetChangeHandlerKeys_[i]);this.targetChangeHandlerKeys_=null,this.viewport_.removeEventListener(P.CONTEXTMENU,this.boundHandleBrowserEvent_),this.viewport_.removeEventListener(P.WHEEL,this.boundHandleBrowserEvent_),this.mapBrowserEventHandler_.dispose(),this.mapBrowserEventHandler_=null,this.viewport_.remove()}if(this.targetElement_&&!te(this.targetElement_)){this.resizeObserver_?.unobserve(this.targetElement_);let i=this.targetElement_.getRootNode();i instanceof ShadowRoot&&this.resizeObserver_.unobserve(i.host),this.setSize(void 0)}let t=this.getTarget(),e=typeof t=="string"?document.getElementById(t):t;if(this.targetElement_=e,!e)this.renderer_&&(clearTimeout(this.postRenderTimeoutHandle_),this.postRenderTimeoutHandle_=void 0,this.postRenderFunctions_.length=0,this.renderer_.dispose(),this.renderer_=null),this.animationDelayKey_&&(cancelAnimationFrame(this.animationDelayKey_),this.animationDelayKey_=void 0);else{if(te(e)||e.appendChild(this.viewport_),this.renderer_||(this.renderer_=new Gg(this)),!te(e)){this.mapBrowserEventHandler_=new Bf(this,this.moveTolerance_);for(let r in at)this.mapBrowserEventHandler_.addEventListener(at[r],this.handleMapBrowserEvent.bind(this));this.viewport_.addEventListener(P.CONTEXTMENU,this.boundHandleBrowserEvent_,!1),this.viewport_.addEventListener(P.WHEEL,this.boundHandleBrowserEvent_,qs?{passive:!1}:!1);let i;if(this.keyboardEventTarget_)i=this.keyboardEventTarget_;else{let r=e.getRootNode();i=r instanceof ShadowRoot?r.host:e}if(this.targetChangeHandlerKeys_=[Z(i,P.KEYDOWN,this.handleBrowserEvent,this),Z(i,P.KEYPRESS,this.handleBrowserEvent,this)],!te(e)){let r=e.getRootNode();r instanceof ShadowRoot&&this.resizeObserver_.observe(r.host),this.resizeObserver_?.observe(e)}}this.updateSize()}}handleTileChange_(){this.render()}handleViewPropertyChanged_(){this.render()}handleViewChanged_(){this.viewPropertyListenerKey_&&(J(this.viewPropertyListenerKey_),this.viewPropertyListenerKey_=null),this.viewChangeListenerKey_&&(J(this.viewChangeListenerKey_),this.viewChangeListenerKey_=null);let t=this.getView();t&&(this.updateViewportSize_(this.getSize()),this.viewPropertyListenerKey_=Z(t,Se.PROPERTYCHANGE,this.handleViewPropertyChanged_,this),this.viewChangeListenerKey_=Z(t,P.CHANGE,this.handleViewPropertyChanged_,this),t.resolveConstraints(0)),this.render()}handleLayerGroupChanged_(){this.layerGroupPropertyListenerKeys_&&(this.layerGroupPropertyListenerKeys_.forEach(J),this.layerGroupPropertyListenerKeys_=null);let t=this.getLayerGroup();t&&(this.handleLayerAdd_(new Ie("addlayer",t)),this.layerGroupPropertyListenerKeys_=[Z(t,Se.PROPERTYCHANGE,this.render,this),Z(t,P.CHANGE,this.render,this),Z(t,"addlayer",this.handleLayerAdd_,this),Z(t,"removelayer",this.handleLayerRemove_,this)]),this.render()}isRendered(){return!!this.frameState_}animationDelay_(){this.animationDelayKey_=void 0,this.renderFrame_(Date.now())}renderSync(){this.animationDelayKey_&&cancelAnimationFrame(this.animationDelayKey_),this.animationDelay_()}redrawText(){if(!this.frameState_)return;let t=this.frameState_.layerStatesArray;for(let e=0,i=t.length;e<i;++e){let r=t[e].layer;r.hasRenderer()&&r.getRenderer().handleFontsChanged()}}render(){this.renderer_&&this.animationDelayKey_===void 0&&(this.animationDelayKey_=requestAnimationFrame(this.animationDelay_))}removeControl(t){return this.getControls().remove(t)}removeInteraction(t){return this.getInteractions().remove(t)}removeLayer(t){return this.getLayerGroup().getLayers().remove(t)}handleLayerRemove_(t){Xg(t.layer)}removeOverlay(t){return this.getOverlays().remove(t)}renderFrame_(t){let e=this.getSize(),i=this.getView(),r=this.frameState_,s=null;if(e!==void 0&&za(e)&&i&&i.isDef()){let o=i.getHints(this.frameState_?this.frameState_.viewHints:void 0),a=i.getState();if(s={animate:!1,coordinateToPixelTransform:this.coordinateToPixelTransform_,declutter:null,extent:Ir(a.center,a.resolution,a.rotation,e),index:this.frameIndex_++,layerIndex:0,layerStatesArray:this.getLayerGroup().getLayerStatesArray(),pixelRatio:this.pixelRatio_,pixelToCoordinateTransform:this.pixelToCoordinateTransform_,postRenderFunctions:[],size:e,tileQueue:this.tileQueue_,time:t,usedTiles:{},viewState:a,viewHints:o,wantedTiles:{},mapId:Y(this),renderTargets:{}},a.nextCenter&&a.nextResolution){let l=isNaN(a.nextRotation)?a.rotation:a.nextRotation;s.nextExtent=Ir(a.nextCenter,a.nextResolution,l,e)}}this.frameState_=s,this.renderer_.renderFrame(s),s&&(s.animate&&this.render(),Array.prototype.push.apply(this.postRenderFunctions_,s.postRenderFunctions),r&&(!this.previousExtent_||!Fe(this.previousExtent_)&&!en(s.extent,this.previousExtent_))&&(this.dispatchEvent(new Ui(je.MOVESTART,this,r)),this.previousExtent_=tn(this.previousExtent_)),this.previousExtent_&&!s.viewHints[bt.ANIMATING]&&!s.viewHints[bt.INTERACTING]&&!en(s.extent,this.previousExtent_)&&(this.dispatchEvent(new Ui(je.MOVEEND,this,s)),bs(s.extent,this.previousExtent_))),this.dispatchEvent(new Ui(je.POSTRENDER,this,s)),this.renderComplete_=(this.hasListener(je.LOADSTART)||this.hasListener(je.LOADEND)||this.hasListener(Ft.RENDERCOMPLETE))&&!this.tileQueue_.getTilesLoading()&&!this.tileQueue_.getCount()&&!this.getLoadingOrNotReady(),this.postRenderTimeoutHandle_||(this.postRenderTimeoutHandle_=setTimeout(()=>{this.postRenderTimeoutHandle_=void 0,this.handlePostRender()},0))}setLayerGroup(t){let e=this.getLayerGroup();e&&this.handleLayerRemove_(new Ie("removelayer",e)),this.set(kt.LAYERGROUP,t)}setSize(t){this.set(kt.SIZE,t)}setTarget(t){this.set(kt.TARGET,t)}setView(t){if(!t||t instanceof ee){this.set(kt.VIEW,t);return}this.set(kt.VIEW,new ee);let e=this;t.then(function(i){e.setView(new ee(i))})}updateSize(){let t=this.getTargetElement(),e;if(t){let r,s;if(te(t)){let o=t.getContext("2d").getTransform();r=t.width/o.a,s=t.height/o.d}else{let o=getComputedStyle(t);r=t.offsetWidth-parseFloat(o.borderLeftWidth)-parseFloat(o.paddingLeft)-parseFloat(o.paddingRight)-parseFloat(o.borderRightWidth),s=t.offsetHeight-parseFloat(o.borderTopWidth)-parseFloat(o.paddingTop)-parseFloat(o.paddingBottom)-parseFloat(o.borderBottomWidth)}!isNaN(r)&&!isNaN(s)&&(e=[Math.max(0,r),Math.max(0,s)],!za(e)&&(t.offsetWidth||t.offsetHeight||t.getClientRects().length)&&Os("No map visible because the map container's width or height are 0."))}let i=this.getSize();e&&(!i||!Gt(e,i))&&(this.updateViewportSize_(e),this.setSize(e))}updateViewportSize_(t){let e=this.getView();e&&e.setViewportSize(t)}};function gy(n){let t=null;n.keyboardEventTarget!==void 0&&(t=typeof n.keyboardEventTarget=="string"?document.getElementById(n.keyboardEventTarget):n.keyboardEventTarget);let e={},i=n.layers&&typeof n.layers.getLayers=="function"?n.layers:new ns({layers:n.layers});e[kt.LAYERGROUP]=i,e[kt.TARGET]=n.target,e[kt.VIEW]=n.view instanceof ee?n.view:new ee;let r;n.controls!==void 0&&(Array.isArray(n.controls)?r=new Dt(n.controls.slice()):(K(typeof n.controls.getArray=="function","Expected `controls` to be an array or an `ol/Collection.js`"),r=n.controls));let s;n.interactions!==void 0&&(Array.isArray(n.interactions)?s=new Dt(n.interactions.slice()):(K(typeof n.interactions.getArray=="function","Expected `interactions` to be an array or an `ol/Collection.js`"),s=n.interactions));let o;return n.overlays!==void 0?Array.isArray(n.overlays)?o=new Dt(n.overlays.slice()):(K(typeof n.overlays.getArray=="function","Expected `overlays` to be an array or an `ol/Collection.js`"),o=n.overlays):o=new Dt,{controls:r,interactions:s,keyboardEventTarget:t,overlays:o,values:e}}var Ug=eh;function na(n){return n instanceof Image||n instanceof HTMLCanvasElement||n instanceof HTMLVideoElement||n instanceof ImageBitmap?n:null}var my=new Error("disposed");var py=[256,256],ih=class extends Vn{constructor(t){let e=D.IDLE;super(t.tileCoord,e,{transition:t.transition,interpolate:t.interpolate}),this.loader_=t.loader,this.data_=null,this.error_=null,this.size_=t.size||null,this.controller_=t.controller||null}getSize(){if(this.size_)return this.size_;let t=na(this.data_);return t?[t.width,t.height]:py}getData(){return this.data_}getError(){return this.error_}load(){if(this.state!==D.IDLE&&this.state!==D.ERROR)return;this.state=D.LOADING,this.changed();let t=this;this.loader_().then(function(e){t.data_=e,t.state=D.LOADED,t.changed()}).catch(function(e){t.error_=e,t.state=D.ERROR,t.changed()})}disposeInternal(){this.controller_&&(this.controller_.abort(my),this.controller_=null),super.disposeInternal()}},nh=ih;var rh=class{constructor(t){this.highWaterMark=t!==void 0?t:2048,this.count_=0,this.entries_={},this.oldest_=null,this.newest_=null}deleteOldest(){let t=this.pop();t instanceof Oi&&t.dispose()}canExpireCache(){return this.highWaterMark>0&&this.getCount()>this.highWaterMark}expireCache(t){for(;this.canExpireCache();)this.deleteOldest()}clear(){for(;this.oldest_;)this.deleteOldest()}containsKey(t){return this.entries_.hasOwnProperty(t)}forEach(t){let e=this.oldest_;for(;e;)t(e.value_,e.key_,this),e=e.newer}get(t,e){let i=this.entries_[t];return K(i!==void 0,"Tried to get a value for a key that does not exist in the cache"),i===this.newest_||(i===this.oldest_?(this.oldest_=this.oldest_.newer,this.oldest_.older=null):(i.newer.older=i.older,i.older.newer=i.newer),i.newer=null,i.older=this.newest_,this.newest_.newer=i,this.newest_=i),i.value_}remove(t){let e=this.entries_[t];return K(e!==void 0,"Tried to get a value for a key that does not exist in the cache"),e===this.newest_?(this.newest_=e.older,this.newest_&&(this.newest_.newer=null)):e===this.oldest_?(this.oldest_=e.newer,this.oldest_&&(this.oldest_.older=null)):(e.newer.older=e.older,e.older.newer=e.newer),delete this.entries_[t],--this.count_,e.value_}getCount(){return this.count_}getKeys(){let t=new Array(this.count_),e=0,i;for(i=this.newest_;i;i=i.older)t[e++]=i.key_;return t}getValues(){let t=new Array(this.count_),e=0,i;for(i=this.newest_;i;i=i.older)t[e++]=i.value_;return t}peekLast(){return this.oldest_.value_}peekLastKey(){return this.oldest_.key_}peekFirstKey(){return this.newest_.key_}peek(t){return this.entries_[t]?.value_}pop(){let t=this.oldest_;return delete this.entries_[t.key_],t.newer&&(t.newer.older=null),this.oldest_=t.newer,this.oldest_||(this.newest_=null),--this.count_,t.value_}replace(t,e){this.get(t),this.entries_[t].value_=e}set(t,e){K(!(t in this.entries_),"Tried to set a value for a key that is used already");let i={key_:t,newer:null,older:this.newest_,value_:e};this.newest_?this.newest_.newer=i:this.oldest_=i,this.newest_=i,this.entries_[t]=i,++this.count_}setSize(t){this.highWaterMark=t}},sh=rh;var oh=class{constructor(){this.instructions_=[],this.zIndex=0,this.offset_=0,this.pendingMethod_,this.context_=new Proxy(Dr(),{get:(t,e)=>{if(typeof t[e]=="function")return this.pendingMethod_=e,this.pushMethodArgs_},set:(t,e,i)=>(this.push_(e,i),!0)})}push_(...t){let e=this.instructions_,i=this.zIndex+this.offset_;e[i]||(e[i]=[]),e[i].push(...t)}pushMethodArgs_=(...t)=>{this.push_(this.pendingMethod_,t)};pushFunction(t){this.push_(t)}getContext(){return this.context_}draw(t){this.instructions_.forEach(e=>{for(let i=0,r=e.length;i<r;++i){let s=e[i];if(typeof s=="function"){s(t);continue}let o=e[++i];typeof t[s]=="function"?t[s](...o):typeof o=="function"?t[s]=o(t):t[s]=o}})}clear(){this.instructions_.length=0,this.zIndex=0,this.offset_=0}offset(){this.offset_=this.instructions_.length,this.zIndex=0}},ra=oh;var _y=5,ah=class extends io{constructor(t){super(),this.ready=!0,this.boundHandleImageChange_=this.handleImageChange_.bind(this),this.layer_=t,this.staleKeys_=new Array,this.maxStaleKeys=_y,this.renderedSourceKey_}getStaleKeys(){return this.staleKeys_}prependStaleKey(t){this.staleKeys_.unshift(t),this.staleKeys_.length>this.maxStaleKeys&&(this.staleKeys_.length=this.maxStaleKeys)}updateStaleKeys(t){this.renderedSourceKey_?this.renderedSourceKey_!==t&&(this.prependStaleKey(this.renderedSourceKey_),this.renderedSourceKey_=t):this.renderedSourceKey_=t}getFeatures(t){return H()}getData(t){return null}prepareFrame(t){return H()}renderFrame(t,e){return H()}forEachFeatureAtCoordinate(t,e,i,r,s){}getLayer(){return this.layer_}handleFontsChanged(){}handleImageChange_(t){let e=t.target;(e.getState()===U.LOADED||e.getState()===U.ERROR)&&this.renderIfReadyAndVisible()}loadImage(t){let e=t.getState();return e!=U.LOADED&&e!=U.ERROR&&t.addEventListener(P.CHANGE,this.boundHandleImageChange_),e==U.IDLE&&(t.load(),e=t.getState()),e==U.LOADED}renderIfReadyAndVisible(){let t=this.getLayer();t&&t.getVisible()&&t.getSourceState()==="ready"&&t.changed()}renderDeferred(t){}disposeInternal(){delete this.layer_,super.disposeInternal()}},Yg=ah;var ch=[],dr=null;function yy(){dr=nt(1,1,void 0,{willReadFrequently:!0})}var lh=class extends Yg{constructor(t){super(t),this.container=null,this.renderedResolution,this.tempTransform=At(),this.pixelTransform=At(),this.inversePixelTransform=At(),this.context=null,this.deferredContext_=null,this.containerReused=!1,this.frameState=null}getImageData(t,e,i){dr||yy(),dr.clearRect(0,0,1,1);let r;try{dr.drawImage(t,e,i,1,1,0,0,1,1),r=dr.getImageData(0,0,1,1).data}catch{return dr=null,null}return r}getBackground(t){let i=this.getLayer().getBackground();return typeof i=="function"&&(i=i(t.viewState.resolution)),i||void 0}useContainer(t,e,i,r,s){if(te(t)&&this.pixelTransform[1]===0&&this.pixelTransform[2]===0&&this.pixelTransform[4]===0&&this.pixelTransform[5]===0&&t.width===r&&t.height===s){let h=t,c=h.getContext("2d");if(c){this.container=t,this.context=c,this.containerReused=!0,i&&(c.fillStyle=i,c.fillRect(0,0,h.width,h.height));return}}let o=this.getLayer().getClassName(),a,l;if(t&&t.className===o&&(!i||t&&t.style.backgroundColor&&Gt(ue(t.style.backgroundColor),ue(i)))){let h=t.firstElementChild;te(h)&&(l=h.getContext("2d"))}if(l&&gd(l.canvas.style.transform,e)?(this.container=t,this.context=l,this.containerReused=!0):this.containerReused?(this.container=null,this.context=null,this.containerReused=!1):this.container&&(this.container.style.backgroundColor=null),!this.container){a=Rt?$s():document.createElement("div"),a.className=o;let h=a.style;h.position="absolute",h.width="100%",h.height="100%",l=nt();let c=l.canvas;a.appendChild(c),h=c.style,h.position="absolute",h.left="0",h.transformOrigin="top left",this.container=a,this.context=l}!this.containerReused&&i&&!this.container.style.backgroundColor&&(this.container.style.backgroundColor=i)}clipUnrotated(t,e,i){let r=ae(i),s=Mn(i),o=An(i),a=Ln(i);dt(e.coordinateToPixelTransform,r),dt(e.coordinateToPixelTransform,s),dt(e.coordinateToPixelTransform,o),dt(e.coordinateToPixelTransform,a);let l=this.inversePixelTransform;dt(l,r),dt(l,s),dt(l,o),dt(l,a),t.save(),t.beginPath(),t.moveTo(Math.round(r[0]),Math.round(r[1])),t.lineTo(Math.round(s[0]),Math.round(s[1])),t.lineTo(Math.round(o[0]),Math.round(o[1])),t.lineTo(Math.round(a[0]),Math.round(a[1])),t.clip()}prepareContainer(t,e){let i=t.extent,r=t.viewState.resolution,s=t.viewState.rotation,o=t.pixelRatio,a=Math.round(j(i)/r*o),l=Math.round(ct(i)/r*o);Ot(this.pixelTransform,t.size[0]/2,t.size[1]/2,1/o,1/o,s,-a/2,-l/2),to(this.inversePixelTransform,this.pixelTransform);let h=fd(this.pixelTransform),c=this.getBackground(t);if(this.useContainer(e,h,c,a,l),!this.containerReused){let d=this.context.canvas;d.width!=a||d.height!=l?(d.width=a,d.height=l):this.context.clearRect(0,0,a,l),h!==d.style.transform&&(d.style.transform=h)}}dispatchRenderEvent_(t,e,i){let r=this.getLayer();if(r.hasListener(t)){let s=new ia(t,this.inversePixelTransform,i,e);r.dispatchEvent(s)}}preRender(t,e){this.frameState=e,!e.declutter&&this.dispatchRenderEvent_(Ft.PRERENDER,t,e)}postRender(t,e){e.declutter||this.dispatchRenderEvent_(Ft.POSTRENDER,t,e)}renderDeferredInternal(t){}getRenderContext(t){return t.declutter&&!this.deferredContext_&&(this.deferredContext_=new ra),t.declutter?this.deferredContext_.getContext():this.context}renderDeferred(t){t.declutter&&(this.dispatchRenderEvent_(Ft.PRERENDER,this.context,t),t.declutter&&this.deferredContext_&&(this.deferredContext_.draw(this.context),this.deferredContext_.clear()),this.renderDeferredInternal(t),this.dispatchRenderEvent_(Ft.POSTRENDER,this.context,t))}getRenderTransform(t,e,i,r,s,o,a){let l=s/2,h=o/2,c=r/e,d=-c,f=-t[0]+a,g=-t[1];return Ot(this.tempTransform,l,h,c,d,-i,f,g)}disposeInternal(){delete this.frameState,super.disposeInternal()}},sa=lh;function hh(n,t,e){if(!(e in n))return n[e]=new Set([t]),!0;let i=n[e],r=i.has(t);return r||i.add(t),!r}function xy(n,t,e){let i=n[e];return i?i.delete(t):!1}function Vg(n,t){let e=n.layerStatesArray[n.layerIndex];e.extent&&(t=ke(t,Ce(e.extent,n.viewState.projection)));let i=e.layer.getRenderSource();if(!i.getWrapX()){let r=i.getTileGridForProjection(n.viewState.projection).getExtent();r&&(t=ke(t,r))}return t}var uh=class extends sa{constructor(t,e){super(t),e=e||{},this.extentChanged=!0,this.renderComplete=!1,this.renderedExtent_=null,this.renderedPixelRatio,this.renderedProjection=null,this.renderedTiles=[],this.renderedSourceRevision_,this.tempExtent=ut(),this.tempTileRange_=new Zs(0,0,0,0),this.tempTileCoord_=Xn(0,0,0);let i=e.cacheSize!==void 0?e.cacheSize:512;this.tileCache_=new sh(i),this.sourceTileCache_=null,this.layerExtent=null,this.maxStaleKeys=i*.5}getTileCache(){return this.tileCache_}getSourceTileCache(){return this.sourceTileCache_||(this.sourceTileCache_=new sh(512)),this.sourceTileCache_}getOrCreateTile(t,e,i,r){let s=this.tileCache_,a=this.getLayer().getSource(),l=Wn(a,a.getKey(),t,e,i),h;if(s.containsKey(l))h=s.get(l);else{let c=r.viewState.projection,d=a.getProjection();if(h=a.getTile(t,e,i,r.pixelRatio,c,!d||Nn(d,c)?void 0:this.getSourceTileCache()),!h)return null;s.set(l,h)}return h}getTile(t,e,i,r){let s=this.getOrCreateTile(t,e,i,r);return s||null}getData(t){let e=this.frameState;if(!e)return null;let i=this.getLayer(),r=dt(e.pixelToCoordinateTransform,t.slice()),s=i.getExtent();if(s&&!pe(s,r))return null;let o=e.viewState,a=i.getRenderSource(),l=a.getTileGridForProjection(o.projection),h=a.getTilePixelRatio(e.pixelRatio);for(let c=l.getZForResolution(o.resolution);c>=l.getMinZoom();--c){let d=l.getTileCoordForCoordAndZ(r,c),f=this.getTile(c,d[1],d[2],e);if(!f||f.getState()!==D.LOADED)continue;let g=l.getOrigin(c),m=mt(l.getTileSize(c)),_=l.getResolution(c),p;if(f instanceof Js||f instanceof eo)p=f.getImage();else if(f instanceof nh){if(p=na(f.getData()),!p)continue}else continue;let y=Math.floor(h*((r[0]-g[0])/_-d[1]*m[0])),E=Math.floor(h*((g[1]-r[1])/_-d[2]*m[1])),C=Math.round(h*a.getGutterForProjection(o.projection));return this.getImageData(p,y+C,E+C)}return null}prepareFrame(t){this.renderedProjection?t.viewState.projection!==this.renderedProjection&&(this.tileCache_.clear(),this.renderedProjection=t.viewState.projection):this.renderedProjection=t.viewState.projection;let e=this.getLayer().getSource();if(!e)return!1;let i=e.getRevision();return this.renderedSourceRevision_?this.renderedSourceRevision_!==i&&(this.renderedSourceRevision_=i,this.renderedSourceKey_===e.getKey()&&(this.tileCache_.clear(),this.sourceTileCache_?.clear())):this.renderedSourceRevision_=i,!0}enqueueTilesForNextExtent(){return!0}enqueueTiles(t,e,i,r,s){let o=t.viewState,a=this.getLayer(),l=a.getRenderSource(),h=l.getTileGridForProjection(o.projection),c=Y(l);c in t.wantedTiles||(t.wantedTiles[c]={});let d=t.wantedTiles[c],f=a.getMapInternal(),g=Math.max(i-s,h.getMinZoom(),h.getZForResolution(Math.min(a.getMaxResolution(),f?f.getView().getResolutionForZoom(Math.max(a.getMinZoom(),0)):h.getResolution(0)),l.zDirection)),m=o.rotation,_=m?va(o.center,o.resolution,m,t.size):void 0;for(let p=i;p>=g;--p){let y=h.getTileRangeForExtentAndZ(e,p,this.tempTileRange_),E=h.getResolution(p);for(let C=y.minX;C<=y.maxX;++C)for(let x=y.minY;x<=y.maxY;++x){if(m&&!h.tileCoordIntersectsViewport([p,C,x],_))continue;let w=this.getTile(p,C,x,t);if(!w||!hh(r,w,p))continue;let A=w.getKey();if(d[A]=!0,w.getState()===D.IDLE&&!t.tileQueue.isKeyQueued(A)){let R=Xn(p,C,x,this.tempTileCoord_);t.tileQueue.enqueue([w,c,h.getTileCoordCenter(R),E])}}}}findStaleTile_(t,e){let i=this.tileCache_,r=t[0],s=t[1],o=t[2],a=this.getStaleKeys();for(let l=0;l<a.length;++l){let h=Wn(this.getLayer().getSource(),a[l],r,s,o);if(i.containsKey(h)){let c=i.peek(h);if(c.getState()===D.LOADED)return c.endTransition(Y(this)),hh(e,c,r),!0}}return!1}findAltTiles_(t,e,i,r){let s=t.getTileRangeForTileCoordAndZ(e,i,this.tempTileRange_);if(!s)return!1;let o=!0,a=this.tileCache_,l=this.getLayer().getRenderSource(),h=l.getKey();for(let c=s.minX;c<=s.maxX;++c)for(let d=s.minY;d<=s.maxY;++d){let f=Wn(l,h,i,c,d),g=!1;if(a.containsKey(f)){let m=a.peek(f);m.getState()===D.LOADED&&(hh(r,m,i),g=!0)}g||(o=!1)}return o}renderFrame(t,e){this.renderComplete=!0;let i=t.layerStatesArray[t.layerIndex],r=t.viewState,s=r.projection,o=r.resolution,a=r.center,l=t.pixelRatio,h=this.getLayer(),c=h.getSource(),d=c.getTileGridForProjection(s),f=d.getZForResolution(o,c.zDirection),g=d.getResolution(f);this.updateStaleKeys(c.getKey());let m=t.extent,_=c.getTilePixelRatio(l);this.prepareContainer(t,e);let p=this.context.canvas.width,y=this.context.canvas.height;this.layerExtent=i.extent?Ce(i.extent,s):null,this.layerExtent&&(m=ke(m,this.layerExtent));let E=g*p/2/_,C=g*y/2/_,x=[a[0]-E,a[1]-C,a[0]+E,a[1]+C],w={};this.renderedTiles.length=0;let T=h.getPreload();if(t.nextExtent&&this.enqueueTilesForNextExtent()){let M=d.getZForResolution(r.nextResolution,c.zDirection),X=Vg(t,t.nextExtent);this.enqueueTiles(t,X,M,w,T)}let A=Vg(t,m);if(this.enqueueTiles(t,A,f,w,0),T>0&&setTimeout(()=>{this.enqueueTiles(t,A,f-1,w,T-1)},0),!(f in w))return this.container;let R=Y(this),I=t.time;for(let M of w[f]){let X=M.getState();if(X===D.EMPTY)continue;let O=M.tileCoord;if(X===D.LOADED&&M.getAlpha(R,I)===1){M.endTransition(R);continue}if(X!==D.ERROR&&(this.renderComplete=!1),this.findStaleTile_(O,w)){xy(w,M,f),t.animate=!0;continue}if(this.findAltTiles_(d,O,f+1,w))continue;let tt=d.getMinZoom();for(let it=f-1;it>=tt&&!this.findAltTiles_(d,O,it,w);--it);}let b=g/o*l/_,N=this.getRenderContext(t);Ot(this.tempTransform,p/2,y/2,b,b,0,-p/2,-y/2),this.layerExtent&&this.clipUnrotated(N,t,this.layerExtent),c.getInterpolate()||(N.imageSmoothingEnabled=!1),this.preRender(N,t);let G=Object.keys(w).map(Number);G.sort(Bt);let F=[],B=[],lt=[];for(let M=G.length-1;M>=0;--M){let X=G[M],O=c.getTilePixelSize(X,l,s),z=d.getResolution(X)/g,tt=O[0]*z*b,it=O[1]*z*b,Ct=d.getTileCoordForCoordAndZ(ae(x),X),L=d.getTileCoordExtent(Ct),Jt=dt(this.tempTransform,[_*(L[0]-x[0])/g,_*(x[3]-L[3])/g]),vt=_*c.getGutterForProjection(s);for(let ot of w[X]){if(ot.getState()!==D.LOADED)continue;let Me=ot.tileCoord,Hi=Ct[1]-Me[1],re=Math.round(Jt[0]-(Hi-1)*tt),mr=Ct[2]-Me[2],ws=Math.round(Jt[1]-(mr-1)*it),qi=Math.round(Jt[0]-Hi*tt),$i=Math.round(Jt[1]-mr*it),Sn=re-qi,ti=ws-$i,Rn=X===f;if(Rn&&ot.inTransition(R)){lt.push({tile:ot,x:qi,y:$i,w:Sn,h:ti,gutter:vt}),this.renderedTiles.unshift(ot),this.updateUsedTiles(t.usedTiles,c,ot);continue}let pr=[qi,$i,qi+Sn,$i+ti],_r=[];for(let Ti=0,yr=F.length;Ti<yr;++Ti)X<B[Ti]&&ht(pr,F[Ti])&&_r.push(F[Ti]);let Cs;_r.length>0&&(Cs=cu(pr,_r)),F.push(pr),B.push(X),this.drawTile(ot,t,qi,$i,Sn,ti,vt,Rn,Cs),this.renderedTiles.unshift(ot),this.updateUsedTiles(t.usedTiles,c,ot)}}for(let M=0,X=lt.length;M<X;++M){let{tile:O,x:$,y:z,w:tt,h:it,gutter:Ct}=lt[M];this.drawTile(O,t,$,z,tt,it,Ct,!0,void 0)}if(this.renderedResolution=g,this.extentChanged=!this.renderedExtent_||!en(this.renderedExtent_,x),this.renderedExtent_=x,this.renderedPixelRatio=l,this.postRender(this.context,t),this.layerExtent&&N.restore(),N.imageSmoothingEnabled=!0,this.renderComplete){let M=(X,O)=>{let $=Y(c),z=O.wantedTiles[$],tt=z?Object.keys(z).length:0;this.updateCacheSize(tt),this.tileCache_.expireCache(),this.sourceTileCache_?.expireCache()};t.postRenderFunctions.push(M)}return this.container}updateCacheSize(t){this.tileCache_.highWaterMark=Math.max(this.tileCache_.highWaterMark,t*2)}drawTile(t,e,i,r,s,o,a,l,h){let c;if(t instanceof nh){if(c=na(t.getData()),!c)throw new Error("Rendering array data is not yet supported")}else c=this.getTileImage(t);if(!c)return;let d=this.getRenderContext(e),f=Y(this),g=e.layerStatesArray[e.layerIndex],m=g.opacity*(l?t.getAlpha(f,e.time):1),_=m!==d.globalAlpha;_&&(d.save(),d.globalAlpha=m);let p=c.width-2*a,y=c.height-2*a;if(h){let E=p/s,C=y/o;for(let x=0,w=h.length;x<w;++x){let T=h[x],A=T[0],R=T[1],I=T[2]-T[0],b=T[3]-T[1];d.drawImage(c,a+(A-i)*E,a+(R-r)*C,I*E,b*C,A,R,I,b)}}else d.drawImage(c,a,a,p,y,i,r,s,o);_&&d.restore(),m!==g.opacity?e.animate=!0:l&&t.endTransition(f)}getImage(){let t=this.context;return t?t.canvas:null}getTileImage(t){return t.getImage()}updateUsedTiles(t,e,i){let r=Y(e);r in t||(t[r]={}),t[r][i.getKey()]=!0}},Zg=uh;var fs={PRELOAD:"preload",USE_INTERIM_TILES_ON_ERROR:"useInterimTilesOnError"};var dh=class extends xn{constructor(t){t=t||{};let e=Object.assign({},t),i=t.cacheSize;delete t.cacheSize,delete e.preload,delete e.useInterimTilesOnError,super(e),this.on,this.once,this.un,this.cacheSize_=i,this.setPreload(t.preload!==void 0?t.preload:0),this.setUseInterimTilesOnError(t.useInterimTilesOnError!==void 0?t.useInterimTilesOnError:!0)}getCacheSize(){return this.cacheSize_}getPreload(){return this.get(fs.PRELOAD)}setPreload(t){this.set(fs.PRELOAD,t)}getUseInterimTilesOnError(){return this.get(fs.USE_INTERIM_TILES_ON_ERROR)}setUseInterimTilesOnError(t){this.set(fs.USE_INTERIM_TILES_ON_ERROR,t)}getData(t){return super.getData(t)}},Kg=dh;var fh=class extends Kg{constructor(t){super(t)}createRenderer(){return new Zg(this,{cacheSize:this.getCacheSize()})}},gh=fh;var mh=class{drawCustom(t,e,i,r,s){}drawGeometry(t){}setStyle(t){}drawCircle(t,e,i){}drawFeature(t,e,i){}drawGeometryCollection(t,e,i){}drawLineString(t,e,i){}drawMultiLineString(t,e,i){}drawMultiPoint(t,e,i){}drawMultiPolygon(t,e,i){}drawPoint(t,e,i){}drawPolygon(t,e,i){}drawText(t,e,i){}setFillStrokeStyle(t,e){}setImageStyle(t,e){}setTextStyle(t,e){}},oa=mh;var gs={BEGIN_GEOMETRY:0,BEGIN_PATH:1,CIRCLE:2,CLOSE_PATH:3,CUSTOM:4,DRAW_CHARS:5,DRAW_IMAGE:6,END_GEOMETRY:7,FILL:8,MOVE_TO_LINE_TO:9,SET_FILL_STYLE:10,SET_STROKE_STYLE:11,STROKE:12},ms=[gs.FILL],$e=[gs.STROKE],Ci=[gs.BEGIN_PATH],ph=[gs.CLOSE_PATH],k=gs;var _h=class extends oa{constructor(t,e,i,r){super(),this.tolerance=t,this.maxExtent=e,this.pixelRatio=r,this.maxLineWidth=0,this.resolution=i,this.beginGeometryInstruction1_=null,this.beginGeometryInstruction2_=null,this.bufferedMaxExtent_=null,this.instructions=[],this.coordinates=[],this.tmpCoordinate_=[],this.hitDetectionInstructions=[],this.state={}}applyPixelRatio(t){let e=this.pixelRatio;return e==1?t:t.map(function(i){return i*e})}appendFlatPointCoordinates(t,e){let i=this.getBufferedMaxExtent(),r=this.tmpCoordinate_,s=this.coordinates,o=s.length;for(let a=0,l=t.length;a<l;a+=e)r[0]=t[a],r[1]=t[a+1],pe(i,r)&&(s[o++]=r[0],s[o++]=r[1]);return o}appendFlatLineCoordinates(t,e,i,r,s,o){let a=this.coordinates,l=a.length,h=this.getBufferedMaxExtent();o&&(e+=r);let c=t[e],d=t[e+1],f=this.tmpCoordinate_,g=!0,m,_,p;for(m=e+r;m<i;m+=r)f[0]=t[m],f[1]=t[m+1],p=Is(h,f),p!==_?(g&&(a[l++]=c,a[l++]=d,g=!1),a[l++]=f[0],a[l++]=f[1]):p===xt.INTERSECTING?(a[l++]=f[0],a[l++]=f[1],g=!1):g=!0,c=f[0],d=f[1],_=p;return(s&&g||m===e+r)&&(a[l++]=c,a[l++]=d),l}drawCustomCoordinates_(t,e,i,r,s){for(let o=0,a=i.length;o<a;++o){let l=i[o],h=this.appendFlatLineCoordinates(t,e,l,r,!1,!1);s.push(h),e=l}return e}drawCustom(t,e,i,r,s){this.beginGeometry(t,e,s);let o=t.getType(),a=t.getStride(),l=this.coordinates.length,h,c,d,f,g;switch(o){case"MultiPolygon":h=t.getOrientedFlatCoordinates(),f=[];let m=t.getEndss();g=0;for(let _=0,p=m.length;_<p;++_){let y=[];g=this.drawCustomCoordinates_(h,g,m[_],a,y),f.push(y)}this.instructions.push([k.CUSTOM,l,f,t,i,Gr,s]),this.hitDetectionInstructions.push([k.CUSTOM,l,f,t,r||i,Gr,s]);break;case"Polygon":case"MultiLineString":d=[],h=o=="Polygon"?t.getOrientedFlatCoordinates():t.getFlatCoordinates(),g=this.drawCustomCoordinates_(h,0,t.getEnds(),a,d),this.instructions.push([k.CUSTOM,l,d,t,i,jn,s]),this.hitDetectionInstructions.push([k.CUSTOM,l,d,t,r||i,jn,s]);break;case"LineString":case"Circle":h=t.getFlatCoordinates(),c=this.appendFlatLineCoordinates(h,0,h.length,a,!1,!1),this.instructions.push([k.CUSTOM,l,c,t,i,Ye,s]),this.hitDetectionInstructions.push([k.CUSTOM,l,c,t,r||i,Ye,s]);break;case"MultiPoint":h=t.getFlatCoordinates(),c=this.appendFlatPointCoordinates(h,a),c>l&&(this.instructions.push([k.CUSTOM,l,c,t,i,Ye,s]),this.hitDetectionInstructions.push([k.CUSTOM,l,c,t,r||i,Ye,s]));break;case"Point":h=t.getFlatCoordinates(),this.coordinates.push(h[0],h[1]),c=this.coordinates.length,this.instructions.push([k.CUSTOM,l,c,t,i,void 0,s]),this.hitDetectionInstructions.push([k.CUSTOM,l,c,t,r||i,void 0,s]);break;default:}this.endGeometry(e)}beginGeometry(t,e,i){this.beginGeometryInstruction1_=[k.BEGIN_GEOMETRY,e,0,t,i],this.instructions.push(this.beginGeometryInstruction1_),this.beginGeometryInstruction2_=[k.BEGIN_GEOMETRY,e,0,t,i],this.hitDetectionInstructions.push(this.beginGeometryInstruction2_)}finish(){return{instructions:this.instructions,hitDetectionInstructions:this.hitDetectionInstructions,coordinates:this.coordinates}}reverseHitDetectionInstructions(){let t=this.hitDetectionInstructions;t.reverse();let e,i=t.length,r,s,o=-1;for(e=0;e<i;++e)r=t[e],s=r[0],s==k.END_GEOMETRY?o=e:s==k.BEGIN_GEOMETRY&&(r[2]=e,Wu(this.hitDetectionInstructions,o,e),o=-1)}fillStyleToState(t,e={}){if(t){let i=t.getColor();e.fillPatternScale=i&&typeof i=="object"&&"src"in i?this.pixelRatio:1,e.fillStyle=Ht(i||Tt)??void 0}else e.fillStyle=void 0;return e}strokeStyleToState(t,e={}){if(t){let i=t.getColor();e.strokeStyle=Ht(i||Wt);let r=t.getLineCap();e.lineCap=r!==void 0?r:Ze;let s=t.getLineDash();e.lineDash=s?s.slice():qt;let o=t.getLineDashOffset();e.lineDashOffset=o||$t;let a=t.getLineJoin();e.lineJoin=a!==void 0?a:Ke;let l=t.getWidth();e.lineWidth=l!==void 0?l:pi;let h=t.getMiterLimit();e.miterLimit=h!==void 0?h:gi;let c=t.getOffset();e.strokeOffset=c??rf,e.lineWidth>this.maxLineWidth&&(this.maxLineWidth=e.lineWidth,this.bufferedMaxExtent_=null)}else e.strokeStyle=void 0,e.lineCap=void 0,e.lineDash=null,e.lineDashOffset=void 0,e.lineJoin=void 0,e.lineWidth=void 0,e.miterLimit=void 0,e.strokeOffset=void 0;return e}setFillStrokeStyle(t,e){let i=this.state;this.fillStyleToState(t,i),this.strokeStyleToState(e,i)}createFill(t){let e=t.fillStyle,i=[k.SET_FILL_STYLE,e];return typeof e!="string"&&i.push(t.fillPatternScale),i}applyStroke(t){this.instructions.push(this.createStroke(t))}createStroke(t){return[k.SET_STROKE_STYLE,t.strokeStyle,t.lineWidth*this.pixelRatio,t.lineCap,t.lineJoin,t.miterLimit,t.lineDash?this.applyPixelRatio(t.lineDash):null,t.lineDashOffset*this.pixelRatio]}updateFillStyle(t,e){let i=t.fillStyle;(i!==void 0&&typeof i!="string"||t.currentFillStyle!=i)&&(this.instructions.push(e.call(this,t)),t.currentFillStyle=i)}updateStrokeStyle(t,e){let i=t.strokeStyle,r=t.lineCap,s=t.lineDash,o=t.lineDashOffset,a=t.lineJoin,l=t.lineWidth,h=t.miterLimit,c=t.strokeOffset;(t.currentStrokeStyle!=i||t.currentLineCap!=r||s!=t.currentLineDash&&!Gt(t.currentLineDash,s)||t.currentLineDashOffset!=o||t.currentLineJoin!=a||t.currentLineWidth!=l||t.currentMiterLimit!=h||t.currentStrokeOffset!=c)&&(e.call(this,t),t.currentStrokeStyle=i,t.currentLineCap=r,t.currentLineDash=s,t.currentLineDashOffset=o,t.currentLineJoin=a,t.currentLineWidth=l,t.currentMiterLimit=h,t.currentStrokeOffset=c)}endGeometry(t){this.beginGeometryInstruction1_[2]=this.instructions.length,this.beginGeometryInstruction1_=null,this.beginGeometryInstruction2_[2]=this.hitDetectionInstructions.length,this.beginGeometryInstruction2_=null;let e=[k.END_GEOMETRY,t];this.instructions.push(e),this.hitDetectionInstructions.push(e)}getBufferedMaxExtent(){if(!this.bufferedMaxExtent_&&(this.bufferedMaxExtent_=bs(this.maxExtent),this.maxLineWidth>0)){let t=this.resolution*(this.maxLineWidth+1)/2;In(this.bufferedMaxExtent_,t,this.bufferedMaxExtent_)}return this.bufferedMaxExtent_}},Je=_h;var yh=class extends Je{constructor(t,e,i,r){super(t,e,i,r),this.hitDetectionImage_=null,this.image_=null,this.imagePixelRatio_=void 0,this.anchorX_=void 0,this.anchorY_=void 0,this.height_=void 0,this.opacity_=void 0,this.originX_=void 0,this.originY_=void 0,this.rotateWithView_=void 0,this.rotation_=void 0,this.scale_=void 0,this.width_=void 0,this.declutterMode_=void 0,this.declutterImageWithText_=void 0}drawPoint(t,e,i){if(!this.image_||this.maxExtent&&!pe(this.maxExtent,t.getFlatCoordinates()))return;this.beginGeometry(t,e,i);let r=t.getFlatCoordinates(),s=t.getStride(),o=this.coordinates.length,a=this.appendFlatPointCoordinates(r,s);this.instructions.push([k.DRAW_IMAGE,o,a,this.image_,this.anchorX_*this.imagePixelRatio_,this.anchorY_*this.imagePixelRatio_,Math.ceil(this.height_*this.imagePixelRatio_),this.opacity_,this.originX_*this.imagePixelRatio_,this.originY_*this.imagePixelRatio_,this.rotateWithView_,this.rotation_,[this.scale_[0]*this.pixelRatio/this.imagePixelRatio_,this.scale_[1]*this.pixelRatio/this.imagePixelRatio_],Math.ceil(this.width_*this.imagePixelRatio_),this.declutterMode_,this.declutterImageWithText_]),this.hitDetectionInstructions.push([k.DRAW_IMAGE,o,a,this.hitDetectionImage_,this.anchorX_,this.anchorY_,this.height_,1,this.originX_,this.originY_,this.rotateWithView_,this.rotation_,this.scale_,this.width_,this.declutterMode_,this.declutterImageWithText_]),this.endGeometry(e)}drawMultiPoint(t,e,i){if(!this.image_)return;this.beginGeometry(t,e,i);let r=t.getFlatCoordinates(),s=[];for(let l=0,h=r.length;l<h;l+=t.getStride())(!this.maxExtent||pe(this.maxExtent,r.slice(l,l+2)))&&s.push(r[l],r[l+1]);let o=this.coordinates.length,a=this.appendFlatPointCoordinates(s,2);this.instructions.push([k.DRAW_IMAGE,o,a,this.image_,this.anchorX_*this.imagePixelRatio_,this.anchorY_*this.imagePixelRatio_,Math.ceil(this.height_*this.imagePixelRatio_),this.opacity_,this.originX_*this.imagePixelRatio_,this.originY_*this.imagePixelRatio_,this.rotateWithView_,this.rotation_,[this.scale_[0]*this.pixelRatio/this.imagePixelRatio_,this.scale_[1]*this.pixelRatio/this.imagePixelRatio_],Math.ceil(this.width_*this.imagePixelRatio_),this.declutterMode_,this.declutterImageWithText_]),this.hitDetectionInstructions.push([k.DRAW_IMAGE,o,a,this.hitDetectionImage_,this.anchorX_,this.anchorY_,this.height_,1,this.originX_,this.originY_,this.rotateWithView_,this.rotation_,this.scale_,this.width_,this.declutterMode_,this.declutterImageWithText_]),this.endGeometry(e)}finish(){return this.reverseHitDetectionInstructions(),this.anchorX_=void 0,this.anchorY_=void 0,this.hitDetectionImage_=null,this.image_=null,this.imagePixelRatio_=void 0,this.height_=void 0,this.scale_=void 0,this.opacity_=void 0,this.originX_=void 0,this.originY_=void 0,this.rotateWithView_=void 0,this.rotation_=void 0,this.width_=void 0,super.finish()}setImageStyle(t,e){let i=t.getAnchor(),r=t.getSize(),s=t.getOrigin();this.imagePixelRatio_=t.getPixelRatio(this.pixelRatio),this.anchorX_=i[0],this.anchorY_=i[1],this.hitDetectionImage_=t.getHitDetectionImage(),this.image_=t.getImage(this.pixelRatio),this.height_=r[1],this.opacity_=t.getOpacity(),this.originX_=s[0],this.originY_=s[1],this.rotateWithView_=t.getRotateWithView(),this.rotation_=t.getRotation(),this.scale_=t.getScaleArray(),this.width_=r[0],this.declutterMode_=t.getDeclutterMode(),this.declutterImageWithText_=e}},Bg=yh;var xh=class extends Je{constructor(t,e,i,r){super(t,e,i,r)}drawFlatCoordinates_(t,e,i,r,s){let o=this.coordinates.length,a=this.appendFlatLineCoordinates(t,e,i,r,!1,!1);return this.instructions.push([k.MOVE_TO_LINE_TO,o,a,s*this.pixelRatio]),this.hitDetectionInstructions.push([k.MOVE_TO_LINE_TO,o,a,s]),i}drawLineString(t,e,i){let r=this.state,s=r.strokeStyle,o=r.lineWidth,a=r.strokeOffset;if(s===void 0||o===void 0)return;this.updateStrokeStyle(r,this.applyStroke),this.beginGeometry(t,e,i),this.hitDetectionInstructions.push([k.SET_STROKE_STYLE,Wt,r.lineWidth,r.lineCap,r.lineJoin,r.miterLimit,qt,$t],Ci);let l=t.getFlatCoordinates(),h=t.getStride();this.drawFlatCoordinates_(l,0,l.length,h,a),this.hitDetectionInstructions.push($e),this.endGeometry(e)}drawMultiLineString(t,e,i){let r=this.state,s=r.strokeStyle,o=r.lineWidth,a=r.strokeOffset;if(s===void 0||o===void 0)return;this.updateStrokeStyle(r,this.applyStroke),this.beginGeometry(t,e,i),this.hitDetectionInstructions.push([k.SET_STROKE_STYLE,Wt,r.lineWidth,r.lineCap,r.lineJoin,r.miterLimit,qt,$t],Ci);let l=t.getEnds(),h=t.getFlatCoordinates(),c=t.getStride(),d=0;for(let f=0,g=l.length;f<g;++f)d=this.drawFlatCoordinates_(h,d,l[f],c,a);this.hitDetectionInstructions.push($e),this.endGeometry(e)}finish(){let t=this.state;return t.lastStroke!=null&&t.lastStroke!=this.coordinates.length&&this.instructions.push($e),this.reverseHitDetectionInstructions(),this.state=null,super.finish()}applyStroke(t){t.lastStroke!=null&&t.lastStroke!=this.coordinates.length&&(this.instructions.push($e),t.lastStroke=this.coordinates.length),t.lastStroke=0,super.applyStroke(t),this.instructions.push(Ci)}},jg=xh;var Eh=class extends Je{constructor(t,e,i,r){super(t,e,i,r)}drawFlatCoordinatess_(t,e,i,r,s){let o=this.state,a=o.fillStyle!==void 0,l=o.strokeStyle!==void 0,h=i.length;this.instructions.push(Ci),this.hitDetectionInstructions.push(Ci);for(let c=0;c<h;++c){let d=i[c],f=this.coordinates.length,g=this.appendFlatLineCoordinates(t,e,d,r,!0,!l);this.instructions.push([k.MOVE_TO_LINE_TO,f,g,s*this.pixelRatio,!0]),this.hitDetectionInstructions.push([k.MOVE_TO_LINE_TO,f,g,s,!0]),l&&(this.instructions.push(ph),this.hitDetectionInstructions.push(ph)),e=d}return a&&(this.instructions.push(ms),this.hitDetectionInstructions.push(ms)),l&&(this.instructions.push($e),this.hitDetectionInstructions.push($e)),e}drawCircle(t,e,i){let r=this.state,s=r.fillStyle,o=r.strokeStyle,a=r.strokeOffset;if(s===void 0&&o===void 0||this.handleStrokeOffset_(()=>this.drawCircle(t,e,i)))return;this.setFillStrokeStyles_(),this.beginGeometry(t,e,i),r.fillStyle!==void 0&&this.hitDetectionInstructions.push([k.SET_FILL_STYLE,Tt]),r.strokeStyle!==void 0&&this.hitDetectionInstructions.push([k.SET_STROKE_STYLE,Wt,r.lineWidth,r.lineCap,r.lineJoin,r.miterLimit,qt,$t]);let l=t.getFlatCoordinates(),h=t.getStride(),c=this.coordinates.length;this.appendFlatLineCoordinates(l,0,l.length,h,!1,!1);let d=[k.CIRCLE,c,a];this.instructions.push(Ci,d),this.hitDetectionInstructions.push(Ci,d),r.fillStyle!==void 0&&(this.instructions.push(ms),this.hitDetectionInstructions.push(ms)),r.strokeStyle!==void 0&&(this.instructions.push($e),this.hitDetectionInstructions.push($e)),this.endGeometry(e)}drawPolygon(t,e,i){let r=this.state,s=r.fillStyle,o=r.strokeStyle,a=r.strokeOffset;if(s===void 0&&o===void 0||this.handleStrokeOffset_(()=>this.drawPolygon(t,e,i)))return;this.setFillStrokeStyles_(),this.beginGeometry(t,e,i),r.fillStyle!==void 0&&this.hitDetectionInstructions.push([k.SET_FILL_STYLE,Tt]),r.strokeStyle!==void 0&&this.hitDetectionInstructions.push([k.SET_STROKE_STYLE,Wt,r.lineWidth,r.lineCap,r.lineJoin,r.miterLimit,qt,$t]);let l=t.getEnds(),h=t.getOrientedFlatCoordinates(),c=t.getStride();this.drawFlatCoordinatess_(h,0,l,c,a),this.endGeometry(e)}drawMultiPolygon(t,e,i){let r=this.state,s=r.fillStyle,o=r.strokeStyle,a=r.strokeOffset;if(s===void 0&&o===void 0||this.handleStrokeOffset_(()=>this.drawMultiPolygon(t,e,i)))return;this.setFillStrokeStyles_(),this.beginGeometry(t,e,i),r.fillStyle!==void 0&&this.hitDetectionInstructions.push([k.SET_FILL_STYLE,Tt]),r.strokeStyle!==void 0&&this.hitDetectionInstructions.push([k.SET_STROKE_STYLE,Wt,r.lineWidth,r.lineCap,r.lineJoin,r.miterLimit,qt,$t]);let l=t.getEndss(),h=t.getOrientedFlatCoordinates(),c=t.getStride(),d=0;for(let f=0,g=l.length;f<g;++f)d=this.drawFlatCoordinatess_(h,d,l[f],c,a);this.endGeometry(e)}finish(){this.reverseHitDetectionInstructions(),this.state=null;let t=this.tolerance;if(t!==0){let e=this.coordinates;for(let i=0,r=e.length;i<r;++i)e[i]=zi(e[i],t)}return super.finish()}setFillStrokeStyles_(){let t=this.state;this.updateFillStyle(t,this.createFill),this.updateStrokeStyle(t,this.applyStroke)}handleStrokeOffset_(t){let e=this.state,i=e.fillStyle,r=e.strokeStyle,s=e.strokeOffset;return Math.abs(s)>0&&i!==void 0&&r!==void 0?(e.strokeStyle=void 0,e.strokeOffset=0,t(),e.fillStyle=void 0,e.strokeStyle=r,e.strokeOffset=s,t(),e.fillStyle=i,!0):!1}},wh=Eh;var Ch=0,vh=1;function Ey(n,t,e,i,r,s,o,a){let l=o-r,h=a-s,c=0,d=1;if(l===0){if(r<n||r>e)return!1}else{let f=(n-r)/l,g=(e-r)/l;if(f>g){let m=f;f=g,g=m}if(f>c&&(c=f),g<d&&(d=g),c>d)return!1}if(h===0){if(s<t||s>i)return!1}else{let f=(t-s)/h,g=(i-s)/h;if(f>g){let m=f;f=g,g=m}if(f>c&&(c=f),g<d&&(d=g),c>d)return!1}return Ch=c,vh=d,!0}function Hg(n,t,e,i){let r=i[0],s=i[1],o=i[2],a=i[3],l=[],h=[],c=!1,d,f,g=0;for(let m=0,_=t.length;m<_;++m){let p=t[m],y=n[g],E=n[g+1],C=!1;for(let x=g+e;x<p;x+=e){let w=n[x],T=n[x+1];if(Ey(r,s,o,a,y,E,w,T)){let A=w-y,R=T-E,I=y+Ch*A,b=E+Ch*R,N=y+vh*A,G=E+vh*R;c&&C&&I===d&&b===f?l.push(N,G):(c&&h.push(l.length),l.push(I,b,N,G),c=!0),d=N,f=G,C=!0}y=w,E=T}g=p}return c&&h.push(l.length),{flatCoordinates:l,ends:h}}function qg(n,t,e,i,r){let s=[],o=e,a=0,l=t.slice(e,2);for(;a<n&&o+r<i;){let[h,c]=l.slice(-2),d=t[o+r],f=t[o+r+1],g=Math.sqrt((d-h)*(d-h)+(f-c)*(f-c));if(a+=g,a>=n){let m=(n-a+g)/g,_=zt(h,d,m),p=zt(c,f,m);l.push(_,p),s.push(l),l=[_,p],a==n&&(o+=r),a=0}else if(a<n)l.push(t[o+r],t[o+r+1]),o+=r;else{let m=g-a,_=zt(h,d,m/g),p=zt(c,f,m/g);l.push(_,p),s.push(l),l=[_,p],a=0,o+=r}}return a>0&&s.push(l),s}function $g(n,t,e,i,r){let s=e,o=e,a=0,l=0,h=e,c,d,f,g,m,_,p,y,E,C;for(d=e;d<i;d+=r){let x=t[d],w=t[d+1];m!==void 0&&(E=x-m,C=w-_,g=Math.sqrt(E*E+C*C),p!==void 0&&(l+=f,c=Math.acos((p*E+y*C)/(f*g)),c>n&&(l>a&&(a=l,s=h,o=d),l=0,h=d-r)),f=g,p=E,y=C),m=x,_=w}return l+=g,l>a?[h,d]:[s,o]}var ps={left:0,center:.5,right:1,top:0,middle:.5,hanging:.2,alphabetic:.8,ideographic:.8,bottom:1},Sh=class extends Je{constructor(t,e,i,r){super(t,e,i,r),this.labels_=null,this.text_="",this.textOffsetX_=0,this.textOffsetY_=0,this.textRotateWithView_=void 0,this.textKeepUpright_=void 0,this.textRotation_=0,this.textFillState_=null,this.fillStates={},this.fillStates[Tt]={fillStyle:Tt},this.textStrokeState_=null,this.strokeStates={},this.textState_={},this.textStates={},this.textKey_="",this.fillKey_="",this.strokeKey_="",this.declutterMode_=void 0,this.declutterImageWithText_=void 0}finish(){let t=super.finish();return t.textStates=this.textStates,t.fillStates=this.fillStates,t.strokeStates=this.strokeStates,t}drawText(t,e,i){let r=this.textFillState_,s=this.textStrokeState_,o=this.textState_;if(this.text_===""||!o||!r&&!s)return;let a=this.coordinates,l=a.length,h=t.getType(),c=null,d=t.getStride();if(o.placement==="line"&&(h=="LineString"||h=="MultiLineString"||h=="Polygon"||h=="MultiPolygon")){let f=t.getExtent();if(!ht(this.maxExtent,f))return;let g;if(c=t.getFlatCoordinates(),h=="LineString")g=[c.length];else if(h=="MultiLineString")g=t.getEnds();else if(h=="Polygon")g=t.getEnds().slice(0,1);else if(h=="MultiPolygon"){let y=t.getEndss();g=[];for(let E=0,C=y.length;E<C;++E)g.push(y[E][0])}if((h=="LineString"||h=="MultiLineString")&&!De(this.getBufferedMaxExtent(),f)){let y=Hg(c,g,d,this.getBufferedMaxExtent());if(c=y.flatCoordinates,g=y.ends,d=2,g.length===0)return}this.beginGeometry(t,e,i);let m=o.repeat,_=m?void 0:o.textAlign,p=0;for(let y=0,E=g.length;y<E;++y){let C;m?C=qg(m*this.resolution,c,p,g[y],d):C=[c.slice(p,g[y])];for(let x=0,w=C.length;x<w;++x){let T=C[x],A=0,R=T.length;if(_==null){let b=$g(o.maxAngle,T,0,T.length,2);A=b[0],R=b[1]}for(let b=A;b<R;b+=d)a.push(T[b],T[b+1]);let I=a.length;p=g[y],this.drawChars_(l,I),l=I}}this.endGeometry(e)}else{let f=o.overflow?null:[];switch(h){case"Point":case"MultiPoint":c=t.getFlatCoordinates();break;case"LineString":c=t.getFlatMidpoint();break;case"Circle":c=t.getCenter();break;case"MultiLineString":c=t.getFlatMidpoints(),d=2;break;case"Polygon":c=t.getFlatInteriorPoint(),o.overflow||f.push(c[2]/this.resolution),d=3;break;case"MultiPolygon":let x=t.getFlatInteriorPoints();c=[];for(let w=0,T=x.length;w<T;w+=3)o.overflow||f.push(x[w+2]/this.resolution),c.push(x[w],x[w+1]);if(c.length===0)return;d=2;break;default:}let g=this.appendFlatPointCoordinates(c,d);if(g===l)return;if(f&&(g-l)/2!==c.length/d){let x=l/2;f=f.filter((w,T)=>{let A=a[(x+T)*2]===c[T*d]&&a[(x+T)*2+1]===c[T*d+1];return A||--x,A})}this.saveTextStates_();let m=o.backgroundFill?this.createFill(this.fillStyleToState(o.backgroundFill)):null,_=o.backgroundStroke?this.createStroke(this.strokeStyleToState(o.backgroundStroke)):null;this.beginGeometry(t,e,i);let p=o.padding;if(p!=mi&&(o.scale[0]<0||o.scale[1]<0)){let x=o.padding[0],w=o.padding[1],T=o.padding[2],A=o.padding[3];o.scale[0]<0&&(w=-w,A=-A),o.scale[1]<0&&(x=-x,T=-T),p=[x,w,T,A]}let y=this.pixelRatio;this.instructions.push([k.DRAW_IMAGE,l,g,null,NaN,NaN,NaN,1,0,0,this.textRotateWithView_,this.textRotation_,[1,1],NaN,this.declutterMode_,this.declutterImageWithText_,p==mi?mi:p.map(function(x){return x*y}),m,_,this.text_,this.textKey_,this.strokeKey_,this.fillKey_,this.textOffsetX_,this.textOffsetY_,f]);let E=1/y,C=m?m.slice(0):null;C&&(C[1]=Tt),this.hitDetectionInstructions.push([k.DRAW_IMAGE,l,g,null,NaN,NaN,NaN,1,0,0,this.textRotateWithView_,this.textRotation_,[E,E],NaN,this.declutterMode_,this.declutterImageWithText_,p,C,_,this.text_,this.textKey_,this.strokeKey_,this.fillKey_?Tt:this.fillKey_,this.textOffsetX_,this.textOffsetY_,f]),this.endGeometry(e)}}saveTextStates_(){let t=this.textStrokeState_,e=this.textState_,i=this.textFillState_,r=this.strokeKey_;t&&(r in this.strokeStates||(this.strokeStates[r]={strokeStyle:t.strokeStyle,lineCap:t.lineCap,lineDashOffset:t.lineDashOffset,lineWidth:t.lineWidth,lineJoin:t.lineJoin,miterLimit:t.miterLimit,lineDash:t.lineDash}));let s=this.textKey_;s in this.textStates||(this.textStates[s]={font:e.font,textAlign:e.textAlign||Wi,justify:e.justify,textBaseline:e.textBaseline||mn,scale:e.scale});let o=this.fillKey_;i&&(o in this.fillStates||(this.fillStates[o]={fillStyle:i.fillStyle}))}drawChars_(t,e){let i=this.textStrokeState_,r=this.textState_,s=this.strokeKey_,o=this.textKey_,a=this.fillKey_;this.saveTextStates_();let l=this.pixelRatio,h=ps[r.textBaseline],c=this.textOffsetX_*l,d=this.textOffsetY_*l,f=this.text_,g=i?i.lineWidth*Math.abs(r.scale[0])/2:0;this.instructions.push([k.DRAW_CHARS,t,e,h,r.overflow,a,r.maxAngle,l,d,s,g*l,f,o,1,this.declutterMode_,this.textKeepUpright_,c]),this.hitDetectionInstructions.push([k.DRAW_CHARS,t,e,h,r.overflow,a&&Tt,r.maxAngle,l,d,s,g*l,f,o,1/l,this.declutterMode_,this.textKeepUpright_,c])}setTextStyle(t,e){let i,r,s;if(!t)this.text_="";else{let o=t.getFill();o?(r=this.textFillState_,r||(r={},this.textFillState_=r),r.fillStyle=Ht(o.getColor()||Tt)):(r=null,this.textFillState_=r);let a=t.getStroke();if(!a)s=null,this.textStrokeState_=s;else{s=this.textStrokeState_,s||(s={},this.textStrokeState_=s);let _=a.getLineDash(),p=a.getLineDashOffset(),y=a.getWidth(),E=a.getMiterLimit();s.lineCap=a.getLineCap()||Ze,s.lineDash=_?_.slice():qt,s.lineDashOffset=p===void 0?$t:p,s.lineJoin=a.getLineJoin()||Ke,s.lineWidth=y===void 0?pi:y,s.miterLimit=E===void 0?gi:E,s.strokeStyle=Ht(a.getColor()||Wt)}i=this.textState_;let l=t.getFont()||vo;sf(l);let h=t.getScaleArray();i.overflow=t.getOverflow(),i.font=l,i.maxAngle=t.getMaxAngle(),i.placement=t.getPlacement(),i.textAlign=t.getTextAlign(),i.repeat=t.getRepeat(),i.justify=t.getJustify(),i.textBaseline=t.getTextBaseline()||mn,i.backgroundFill=t.getBackgroundFill(),i.backgroundStroke=t.getBackgroundStroke(),i.padding=t.getPadding()||mi,i.scale=h===void 0?[1,1]:h;let c=t.getOffsetX(),d=t.getOffsetY(),f=t.getRotateWithView(),g=t.getKeepUpright(),m=t.getRotation();this.text_=t.getText()||"",this.textOffsetX_=c===void 0?0:c,this.textOffsetY_=d===void 0?0:d,this.textRotateWithView_=f===void 0?!1:f,this.textKeepUpright_=g===void 0?!0:g,this.textRotation_=m===void 0?0:m,this.strokeKey_=s?(typeof s.strokeStyle=="string"?s.strokeStyle:Y(s.strokeStyle))+s.lineCap+s.lineDashOffset+"|"+s.lineWidth+s.lineJoin+s.miterLimit+"["+s.lineDash.join()+"]":"",this.textKey_=i.font+i.scale+(i.textAlign||"?")+(i.repeat||"?")+(i.justify||"?")+(i.textBaseline||"?"),this.fillKey_=r&&r.fillStyle?typeof r.fillStyle=="string"?r.fillStyle:"|"+Y(r.fillStyle):""}this.declutterMode_=t.getDeclutterMode(),this.declutterImageWithText_=e}},Jg=Sh;var wy={Circle:wh,Default:Je,Image:Bg,LineString:jg,Polygon:wh,Text:Jg},Rh=class{constructor(t,e,i,r){this.tolerance_=t,this.maxExtent_=e,this.pixelRatio_=r,this.resolution_=i,this.buildersByZIndex_={}}finish(){let t={};for(let e in this.buildersByZIndex_){t[e]=t[e]||{};let i=this.buildersByZIndex_[e];for(let r in i){let s=i[r].finish();t[e][r]=s}}return t}getBuilder(t,e){let i=t!==void 0?t.toString():"0",r=this.buildersByZIndex_[i];r===void 0&&(r={},this.buildersByZIndex_[i]=r);let s=r[e];if(s===void 0){let o=wy[e];s=new o(this.tolerance_,this.maxExtent_,this.resolution_,this.pixelRatio_),r[e]=s}return s}},Qg=Rh;function tm(n,t,e,i){let r=n[t],s=n[t+1],o=0;for(let a=t+i;a<e;a+=i){let l=n[a],h=n[a+1];o+=Math.sqrt((l-r)*(l-r)+(h-s)*(h-s)),r=l,s=h}return o}function aa(n,t,e,i,r,s,o,a){o=o??[],a=a??i;let l=n[t+i],h=n[t+i+1],c=n[e-2*i],d=n[e-2*i+1],f,g,m,_,p,y,E,C,x=0;for(let w=t;w<e;w+=i){m=f,_=g,p=void 0,y=void 0,w+i<e&&(p=n[w+i],y=n[w+i+1]),s&&w===t&&(m=c,_=d),s&&w===e-i&&(p=l,y=h),f=n[w],g=n[w+1],[E,C]=Cy(f,g,m,_,p,y,r),o[x++]=E,o[x++]=C;for(let T=2;T<a;T++)o[x++]=n[w+T]}return o.length!=x&&(o.length=x),o}function Cy(n,t,e,i,r,s,o){let a,l;e!==void 0&&i!==void 0?(a=n-e,l=t-i):r!==void 0&&s!==void 0?(a=r-n,l=s-t):(a=1,l=0);let h=Math.hypot(a,l),c=a/h,d=l/h;if(a=-d,l=c,e===void 0||i===void 0)return[n+a*o,t+l*o];if(r===void 0||s===void 0)return[n+a*o,t+l*o];let f=pu([n,t],[e,i],[r,s]);if(Math.cos(f)>.998)return[n+c*o,t+d*o];let g=Math.cos(f/2),m=Math.sin(f/2),_=m*a+g*l,p=-g*a+m*l,y=_*(1/m),E=p*(1/m);return[n+y*o,t+E*o]}function la(n,t,e=!1){for(let i=0,r=n.length-2;i<r;i+=t){let s=e&&i===0?n.length-3*t:n.length-2*t;for(let o=s;o>i+t;o-=t){let a=n[i],l=n[i+1],h=n[i+t],c=n[i+t+1],d=n[o],f=n[o+1],g=n[o+t],m=n[o+t+1],_=(m-f)*(h-a)-(g-d)*(c-l);if(_===0)continue;let p=((g-d)*(l-f)-(m-f)*(a-d))/_,y=((h-a)*(l-f)-(c-l)*(a-d))/_;if(p>0&&p<1&&y>0&&y<1){let E=a+p*(h-a),C=l+p*(c-l);n[i+t]=E,n[i+t+1]=C,n.splice(i+2*t,o-i-t);break}}}return n}var Th;function vy(){return Th||(Th=new Intl.Segmenter(void 0,{granularity:"grapheme"})),Th}function em(n,t,e,i,r,s,o,a,l,h,c,d,f=!0){let g=n[t],m=n[t+1],_=0,p=0,y=0,E=0;function C(){_=g,p=m,t+=i,g=n[t],m=n[t+1],E+=y,y=Math.sqrt((g-_)*(g-_)+(m-p)*(m-p))}do C();while(t<e-i&&E+y<s);let x=y===0?0:(s-E)/y,w=zt(_,g,x),T=zt(p,m,x),A=t-i,R=E,I=s+a*l(h,r,c);for(;t<e-i&&E+y<I;)C();x=y===0?0:(I-E)/y;let b=zt(_,g,x),N=zt(p,m,x),G=!1;if(f)if(d){let O=[w,T,b,N];co(O,0,4,2,d,O,O),G=O[0]>O[2]}else G=w>b;let F=Math.PI,B=[],lt=A+i===t;t=A,y=0,E=R,g=n[t],m=n[t+1];let M;if(lt){C(),M=Math.atan2(m-p,g-_),G&&(M+=M>0?-F:F);let O=(b+w)/2,$=(N+T)/2;return B[0]=[O,$,(I-s)/2,M,r],B}r=r.replace(/\n/g," ");let X=Array.from(vy().segment(r),O=>O.segment);for(let O=0,$=X.length;O<$;){C();let z=Math.atan2(m-p,g-_);if(G&&(z+=z>0?-F:F),M!==void 0){let vt=z-M;if(vt+=vt>F?-2*F:vt<-F?2*F:0,Math.abs(vt)>o)return null}M=z;let tt=O,it=0;for(;O<$;++O){let vt=G?$-O-1:O,ot=a*l(h,X[vt],c);if(t+i<e&&E+y<s+it+ot/2)break;it+=ot}if(O===tt)continue;let Ct=(G?X.slice($-O,$-tt):X.slice(tt,O)).join("");x=y===0?0:(s+it/2-E)/y;let L=zt(_,g,x),Jt=zt(p,m,x);B.push([L,Jt,it/2,z,Ct]),s+=it}return B}var fr=ut(),Ki=[],vi=[],Si=[],Bi=[];function im(n){return n[3].declutterBox}var nm=new RegExp("[\u0591-\u08FF\uFB1D-\uFDFF\uFE70-\uFEFC\u0800-\u0FFF\uE800-\uEFFF]");function Ih(n,t){return t==="start"?t=nm.test(n)?"right":"left":t==="end"&&(t=nm.test(n)?"left":"right"),ps[t]}function Sy(n,t,e){return e>0&&n.push(`7+`,""),n.push(t,""),n}function Ry(n,t,e){return e%2===0&&(n+=t),n}var bh=class{constructor(t,e,i,r,s){this.overlaps=i,this.pixelRatio=e,this.resolution=t,this.alignAndScaleFill_,this.instructions=r.instructions,this.coordinates=r.coordinates,this.coordinateCache_={},this.renderedTransform_=At(),this.hitDetectionInstructions=r.hitDetectionInstructions,this.pixelCoordinates_=null,this.viewRotation_=0,this.fillStates=r.fillStates||{},this.strokeStates=r.strokeStates||{},this.textStates=r.textStates||{},this.widths_={},this.labels_={},this.zIndexContext_=s?new ra:null}getZIndexContext(){return this.zIndexContext_}createLabel(t,e,i,r){let s=t+e+i+r;if(this.labels_[s])return this.labels_[s];let o=r?this.strokeStates[r]:null,a=i?this.fillStates[i]:null,l=this.textStates[e],h=this.pixelRatio,c=[l.scale[0]*h,l.scale[1]*h],d=l.justify?ps[l.justify]:Ih(Array.isArray(t)?t[0]:t,l.textAlign||Wi),f=r&&o.lineWidth?o.lineWidth:0,g=Array.isArray(t)?t:String(t).split(`8+`).reduce(Sy,[]),{width:m,height:_,widths:p,heights:y,lineWidths:E}=lf(l,g),C=m+f,x=[],w=(C+2)*c[0],T=(_+f)*c[1],A={width:w<0?Math.floor(w):Math.ceil(w),height:T<0?Math.floor(T):Math.ceil(T),contextInstructions:x};(c[0]!=1||c[1]!=1)&&x.push("scale",c),r&&(x.push("strokeStyle",o.strokeStyle),x.push("lineWidth",f),x.push("lineCap",o.lineCap),x.push("lineJoin",o.lineJoin),x.push("miterLimit",o.miterLimit),x.push("setLineDash",[o.lineDash]),x.push("lineDashOffset",o.lineDashOffset)),i&&x.push("fillStyle",a.fillStyle),x.push("textBaseline","middle"),x.push("textAlign","center");let R=.5-d,I=d*C+R*f,b=[],N=[],G=0,F=0,B=0,lt=0,M;for(let X=0,O=g.length;X<O;X+=2){let $=g[X];if($===`9+`){F+=G,G=0,I=d*C+R*f,++lt;continue}let z=g[X+1]||l.font;z!==M&&(r&&b.push("font",z),i&&N.push("font",z),M=z),G=Math.max(G,y[B]);let tt=[$,I+R*p[B]+d*(p[B]-E[lt]),.5*(f+G)+F];I+=p[B],r&&b.push("strokeText",tt),i&&N.push("fillText",tt),++B}return Array.prototype.push.apply(x,b),Array.prototype.push.apply(x,N),this.labels_[s]=A,A}replayTextBackground_(t,e,i,r,s,o,a){t.beginPath(),t.moveTo.apply(t,e),t.lineTo.apply(t,i),t.lineTo.apply(t,r),t.lineTo.apply(t,s),t.lineTo.apply(t,e),o&&(this.alignAndScaleFill_=o[2],t.fillStyle=o[1],this.fill_(t)),a&&(this.setStrokeStyle_(t,a),t.stroke())}calculateImageOrLabelDimensions_(t,e,i,r,s,o,a,l,h,c,d,f,g,m,_,p){a*=f[0],l*=f[1];let y=i-a,E=r-l,C=s+h>t?t-h:s,x=o+c>e?e-c:o,w=m[3]+C*f[0]+m[1],T=m[0]+x*f[1]+m[2],A=y-m[3],R=E-m[0];(_||d!==0)&&(Ki[0]=A,Bi[0]=A,Ki[1]=R,vi[1]=R,vi[0]=A+w,Si[0]=vi[0],Si[1]=R+T,Bi[1]=Si[1]);let I;return d!==0?(I=Ot(At(),i,r,1,1,d,-i,-r),dt(I,Ki),dt(I,vi),dt(I,Si),dt(I,Bi),Qt(Math.min(Ki[0],vi[0],Si[0],Bi[0]),Math.min(Ki[1],vi[1],Si[1],Bi[1]),Math.max(Ki[0],vi[0],Si[0],Bi[0]),Math.max(Ki[1],vi[1],Si[1],Bi[1]),fr)):Qt(Math.min(A,A+w),Math.min(R,R+T),Math.max(A,A+w),Math.max(R,R+T),fr),g&&(y=Math.round(y),E=Math.round(E)),{drawImageX:y,drawImageY:E,drawImageW:C,drawImageH:x,originX:h,originY:c,declutterBox:{minX:fr[0],minY:fr[1],maxX:fr[2],maxY:fr[3],value:p},canvasTransform:I,scale:f}}replayImageOrLabel_(t,e,i,r,s,o,a){let l=!!(o||a),h=r.declutterBox,c=a?a[2]*r.scale[0]/2:0;return h.minX-c<=e[0]&&h.maxX+c>=0&&h.minY-c<=e[1]&&h.maxY+c>=0&&(l&&this.replayTextBackground_(t,Ki,vi,Si,Bi,o,a),cf(t,r.canvasTransform,s,i,r.originX,r.originY,r.drawImageW,r.drawImageH,r.drawImageX,r.drawImageY,r.scale)),!0}fill_(t){let e=this.alignAndScaleFill_;if(e){let i=dt(this.renderedTransform_,[0,0]),r=512*this.pixelRatio;t.save(),t.translate(i[0]%r,i[1]%r),e!==1&&t.scale(e,e)}t.fill(),e&&t.restore()}setStrokeStyle_(t,e){t.strokeStyle=e[1],e[1]&&(t.lineWidth=e[2],t.lineCap=e[3],t.lineJoin=e[4],t.miterLimit=e[5],t.lineDashOffset=e[7],t.setLineDash(e[6]))}drawLabelWithPointPlacement_(t,e,i,r){let s=this.textStates[e],o=this.createLabel(t,e,r,i),a=this.strokeStates[i],l=this.pixelRatio,h=Ih(Array.isArray(t)?t[0]:t,s.textAlign||Wi),c=ps[s.textBaseline||mn],d=a&&a.lineWidth?a.lineWidth:0,f=o.width/l-2*s.scale[0],g=h*f+2*(.5-h)*d,m=c*o.height/l+2*(.5-c)*d;return{label:o,anchorX:g,anchorY:m}}execute_(t,e,i,r,s,o,a,l){let h=this.zIndexContext_,c;this.pixelCoordinates_&&Gt(i,this.renderedTransform_)?c=this.pixelCoordinates_:(this.pixelCoordinates_||(this.pixelCoordinates_=[]),c=jt(this.coordinates,0,this.coordinates.length,2,i,this.pixelCoordinates_),dd(this.renderedTransform_,i));let d=0,f=r.length,g=0,m,_=[],p,y,E,C,x,w,T,A,R,I,b,N,G,F=0,B=0,lt=this.coordinateCache_,M=this.viewRotation_,X=Math.round(Math.atan2(-i[1],i[0])*1e12)/1e12,O={context:t,pixelRatio:this.pixelRatio,resolution:this.resolution,rotation:M},$=this.instructions!=r||this.overlaps?0:200,z,tt,it,Ct;for(;d<f;){let L=r[d];switch(L[0]){case k.BEGIN_GEOMETRY:z=L[1],Ct=L[3],z.getGeometry()?a!==void 0&&!ht(a,Ct.getExtent())?d=L[2]+1:++d:d=L[2],h&&(h.zIndex=L[4]);break;case k.BEGIN_PATH:F>$&&(this.fill_(t),F=0),B>$&&(t.stroke(),B=0),!F&&!B&&(t.beginPath(),x=NaN,w=NaN),++d;break;case k.CIRCLE:g=L[1],E=L[2]??0;let vt=c[g],ot=c[g+1],Me=c[g+2]-E,Hi=c[g+3]-E,re=Me-vt,mr=Hi-ot,ws=Math.sqrt(re*re+mr*mr);t.moveTo(vt+ws,ot),t.arc(vt,ot,ws,0,2*Math.PI,!0),++d;break;case k.CLOSE_PATH:t.closePath(),++d;break;case k.CUSTOM:g=L[1],m=L[2];let qi=L[3],$i=L[4],Sn=L[5];O.geometry=qi,O.feature=z,d in lt||(lt[d]=[]);let ti=lt[d];Sn?Sn(c,g,m,2,ti):(ti[0]=c[g],ti[1]=c[g+1],ti.length=2),h&&(h.zIndex=L[6]),$i(ti,O),++d;break;case k.DRAW_IMAGE:g=L[1],m=L[2],R=L[3],p=L[4],y=L[5];let Rn=L[6],pr=L[7],_r=L[8],Cs=L[9],Ti=L[10],yr=L[11],Rm=L[12],vs=L[13];C=L[14]||"declutter";let xr=L[15];if(!R&&L.length>=20){I=L[19],b=L[20],N=L[21],G=L[22];let St=this.drawLabelWithPointPlacement_(I,b,N,G);R=St.label,L[3]=R;let Pe=L[23];p=(St.anchorX-Pe)*this.pixelRatio,L[4]=p;let se=L[24];y=(St.anchorY-se)*this.pixelRatio,L[5]=y,Rn=R.height,L[6]=Rn,vs=R.width,L[13]=vs}let da;L.length>25&&(da=L[25]);let fa,Ss,Rs;L.length>17?(fa=L[16],Ss=L[17],Rs=L[18]):(fa=mi,Ss=null,Rs=null),Ti&&X?yr+=M:!Ti&&!X&&(yr-=M);let Tm=0;for(;g<m;g+=2){if(da&&da[Tm++]<vs/this.pixelRatio)continue;let St=this.calculateImageOrLabelDimensions_(R.width,R.height,c[g],c[g+1],vs,Rn,p,y,_r,Cs,yr,Rm,s,fa,!!Ss||!!Rs,z),Pe=[t,e,R,St,pr,Ss,Rs];if(l){let se,Oe,oe;if(xr){let gt=m-g;if(!xr[gt]){xr[gt]={args:Pe,declutterMode:C};continue}let Vt=xr[gt];se=Vt.args,Oe=Vt.declutterMode,delete xr[gt],oe=im(se)}let ei,ii;if(se&&(Oe!=="declutter"||!l.collides(oe))&&(ei=!0),(C!=="declutter"||!l.collides(St.declutterBox))&&(ii=!0),Oe==="declutter"&&C==="declutter"){let gt=ei&&ii;ei=gt,ii=gt}ei&&(Oe!=="none"&&l.insert(oe),this.replayImageOrLabel_.apply(this,se)),ii&&(C!=="none"&&l.insert(St.declutterBox),this.replayImageOrLabel_.apply(this,Pe))}else this.replayImageOrLabel_.apply(this,Pe)}++d;break;case k.DRAW_CHARS:let jh=L[1],Hh=L[2],ga=L[3],Im=L[4];G=L[5];let bm=L[6],qh=L[7],$h=L[8];N=L[9];let ma=L[10];I=L[11],Array.isArray(I)&&(I=I.reduce(Ry,"")),b=L[12];let Jh=[L[13],L[13]];C=L[14]||"declutter";let Lm=L[15],Qh=L[16],pa=this.textStates[b],Er=pa.font,wr=[pa.scale[0]*qh,pa.scale[1]*qh],Cr;Er in this.widths_?Cr=this.widths_[Er]:(Cr={},this.widths_[Er]=Cr);let tu=tm(c,jh,Hh,2),eu=Math.abs(wr[0])*Wl(Er,I,Cr);if(Im||eu<=tu){let St=this.textStates[b].textAlign,Pe=(tu-eu)*Ih(I,St),se=em(c,jh,Hh,2,I,Pe,bm,Math.abs(wr[0]),Wl,Er,Cr,X?0:this.viewRotation_,Lm);t:if(se){let Oe=[],oe,ei,ii,gt,Vt;if(N)for(oe=0,ei=se.length;oe<ei;++oe){Vt=se[oe],ii=Vt[4],gt=this.createLabel(ii,b,"",N),p=Vt[2]+(wr[0]<0?-ma:ma)-Qh,y=ga*gt.height+(.5-ga)*2*ma*wr[1]/wr[0]-$h;let ni=this.calculateImageOrLabelDimensions_(gt.width,gt.height,Vt[0],Vt[1],gt.width,gt.height,p,y,0,0,Vt[3],Jh,!1,mi,!1,z);if(l&&C==="declutter"&&l.collides(ni.declutterBox))break t;Oe.push([t,e,gt,ni,1,null,null])}if(G)for(oe=0,ei=se.length;oe<ei;++oe){Vt=se[oe],ii=Vt[4],gt=this.createLabel(ii,b,G,""),p=Vt[2]-Qh,y=ga*gt.height-$h;let ni=this.calculateImageOrLabelDimensions_(gt.width,gt.height,Vt[0],Vt[1],gt.width,gt.height,p,y,0,0,Vt[3],Jh,!1,mi,!1,z);if(l&&C==="declutter"&&l.collides(ni.declutterBox))break t;Oe.push([t,e,gt,ni,1,null,null])}l&&C!=="none"&&l.load(Oe.map(im));for(let ni=0,Am=Oe.length;ni<Am;++ni)this.replayImageOrLabel_.apply(this,Oe[ni])}}++d;break;case k.END_GEOMETRY:if(o!==void 0){z=L[1];let St=o(z,Ct,C);if(St)return St}++d;break;case k.FILL:$?F++:this.fill_(t),++d;break;case k.MOVE_TO_LINE_TO:g=L[1],m=L[2],E=L[3];let Ji,vr,Ts;if(E){let Pe=(L[4]??!1)||Math.abs(c[g]-c[m-2])<1e-6&&Math.abs(c[g+1]-c[m-1])<1e-6;aa(c,g,m,2,E,Pe,_),la(_,2,Pe),Ji=_,vr=0,Ts=Ji.length}else Ji=c,vr=g,Ts=m;tt=Ji[vr],it=Ji[vr+1],t.moveTo(tt,it),x=tt+.5|0,w=it+.5|0;for(let St=vr+2;St<Ts;St+=2)tt=Ji[St],it=Ji[St+1],T=tt+.5|0,A=it+.5|0,(St==Ts-2||T!==x||A!==w)&&(t.lineTo(tt,it),x=T,w=A);++d;break;case k.SET_FILL_STYLE:this.alignAndScaleFill_=L[2],F?(this.fill_(t),F=0,B&&(t.stroke(),B=0)):B&&L[1]&&(t.stroke(),B=0),t.fillStyle=L[1],++d;break;case k.SET_STROKE_STYLE:F&&L[1]&&(this.fill_(t),F=0),B&&(t.stroke(),B=0),this.setStrokeStyle_(t,L),++d;break;case k.STROKE:$?B++:t.stroke(),++d;break;default:++d;break}}F&&this.fill_(t),B&&t.stroke()}execute(t,e,i,r,s,o){this.viewRotation_=r,this.execute_(t,e,i,this.instructions,s,void 0,void 0,o)}executeHitDetection(t,e,i,r,s){return this.viewRotation_=i,this.execute_(t,[t.canvas.width,t.canvas.height],e,this.hitDetectionInstructions,!0,r,s)}},rm=bh;var ji=["Polygon","Circle","LineString","Image","Text","Default"],Mh=["Image","Text"],sm=ji.filter(n=>!Mh.includes(n)),om=!1,am=!1;function Ty(){let n=0,t=i=>{let r=nt(1,1,null,{willReadFrequently:i}),s=0,o=performance.now();for(;performance.now()-o<50;++s)r.fillStyle=`rgba(255,0,${s%256},1)`,r.fillRect(0,0,1,1),r.getImageData(0,0,1,1);return n=s>n?s:n,s};om={[t(!0)]:!0,[t(!1)]:!1,[t(void 0)]:void 0}[n],am=!0}var Ah=class{constructor(t,e,i,r,s,o,a){this.maxExtent_=t,this.overlaps_=r,this.pixelRatio_=i,this.resolution_=e,this.renderBuffer_=o,this.executorsByZIndex_={},this.hitDetectionContext_=null,this.hitDetectionTransform_=At(),this.renderedContext_=null,this.deferredZIndexContexts_={},this.createExecutors_(s,a)}clip(t,e){let i=this.getClipCoords(e);t.beginPath(),t.moveTo(i[0],i[1]),t.lineTo(i[2],i[3]),t.lineTo(i[4],i[5]),t.lineTo(i[6],i[7]),t.clip()}createExecutors_(t,e){for(let i in t){let r=this.executorsByZIndex_[i];r===void 0&&(r={},this.executorsByZIndex_[i]=r);let s=t[i];for(let o in s){let a=s[o];r[o]=new rm(this.resolution_,this.pixelRatio_,this.overlaps_,a,e)}}}hasExecutors(t){for(let e in this.executorsByZIndex_){let i=this.executorsByZIndex_[e];for(let r=0,s=t.length;r<s;++r)if(t[r]in i)return!0}return!1}forEachFeatureAtCoordinate(t,e,i,r,s,o){am===!1&&Ty(),r=Math.round(r);let a=r*2+1,l=Ot(this.hitDetectionTransform_,r+.5,r+.5,1/e,-1/e,-i,-t[0],-t[1]),h=!this.hitDetectionContext_;h&&(this.hitDetectionContext_=nt(a,a,null,{willReadFrequently:om}));let c=this.hitDetectionContext_;c.canvas.width!==a||c.canvas.height!==a?(c.canvas.width=a,c.canvas.height=a):h||c.clearRect(0,0,a,a);let d;this.renderBuffer_!==void 0&&(d=ut(),nn(d,t),In(d,e*(this.renderBuffer_+r),d));let f=Iy(r),g;function m(w,T,A){let R=c.getImageData(0,0,a,a).data;for(let I=0,b=f.length;I<b;I++)if(R[f[I]]>0){if(!o||A==="none"||g!=="Image"&&g!=="Text"||o.includes(w)){let N=(f[I]-3)/4,G=r-N%a,F=r-(N/a|0),B=s(w,T,G*G+F*F);if(B)return B}c.clearRect(0,0,a,a);break}}let _=Object.keys(this.executorsByZIndex_).map(Number);_.sort(Bt);let p,y,E,C,x;for(p=_.length-1;p>=0;--p){let w=_[p].toString();for(E=this.executorsByZIndex_[w],y=ji.length-1;y>=0;--y)if(g=ji[y],C=E[g],C!==void 0&&(x=C.executeHitDetection(c,l,i,m,d),x))return x}}getClipCoords(t){let e=this.maxExtent_;if(!e)return null;let i=e[0],r=e[1],s=e[2],o=e[3],a=[i,r,i,o,s,o,s,r];return jt(a,0,8,2,t,a),a}isEmpty(){return xe(this.executorsByZIndex_)}execute(t,e,i,r,s,o,a){let l=Object.keys(this.executorsByZIndex_).map(Number);l.sort(a?Xu:Bt),o=o||ji;let h=ji.length;for(let c=0,d=l.length;c<d;++c){let f=l[c].toString(),g=this.executorsByZIndex_[f];for(let m=0,_=o.length;m<_;++m){let p=o[m],y=g[p];if(y!==void 0){let E=a===null?void 0:y.getZIndexContext(),C=E?E.getContext():t,x=this.maxExtent_&&p!=="Image"&&p!=="Text";if(x&&(C.save(),this.clip(C,i)),!E||p==="Text"||p==="Image"?y.execute(C,e,i,r,s,a):E.pushFunction(w=>y.execute(w,e,i,r,s,a)),x&&C.restore(),E){E.offset();let w=l[c]*h+ji.indexOf(p);this.deferredZIndexContexts_[w]||(this.deferredZIndexContexts_[w]=[]),this.deferredZIndexContexts_[w].push(E)}}}}this.renderedContext_=t}getDeferredZIndexContexts(){return this.deferredZIndexContexts_}getRenderedContext(){return this.renderedContext_}renderDeferred(){let t=this.deferredZIndexContexts_,e=Object.keys(t).map(Number).sort(Bt);for(let i=0,r=e.length;i<r;++i)t[e[i]].forEach(s=>{s.draw(this.renderedContext_),s.clear()}),t[e[i]].length=0}},Lh={};function Iy(n){if(Lh[n]!==void 0)return Lh[n];let t=n*2+1,e=n*n,i=new Array(e+1);for(let s=0;s<=n;++s)for(let o=0;o<=n;++o){let a=s*s+o*o;if(a>e)break;let l=i[a];l||(l=[],i[a]=l),l.push(((n+s)*t+(n+o))*4+3),s>0&&l.push(((n-s)*t+(n+o))*4+3),o>0&&(l.push(((n+s)*t+(n-o))*4+3),s>0&&l.push(((n-s)*t+(n-o))*4+3))}let r=[];for(let s=0,o=i.length;s<o;++s)i[s]&&r.push(...i[s]);return Lh[n]=r,r}var lm=Ah;var Ph=class extends oa{constructor(t,e,i,r,s,o,a){super(),this.context_=t,this.pixelRatio_=e,this.extent_=i,this.transform_=r,this.transformRotation_=r?rn(Math.atan2(r[1],r[0]),10):0,this.viewRotation_=s,this.squaredTolerance_=o,this.userTransform_=a,this.contextFillState_=null,this.contextStrokeState_=null,this.contextTextState_=null,this.fillState_=null,this.strokeState_=null,this.image_=null,this.imageAnchorX_=0,this.imageAnchorY_=0,this.imageHeight_=0,this.imageOpacity_=0,this.imageOriginX_=0,this.imageOriginY_=0,this.imageRotateWithView_=!1,this.imageRotation_=0,this.imageScale_=[0,0],this.imageWidth_=0,this.text_="",this.textOffsetX_=0,this.textOffsetY_=0,this.textRotateWithView_=!1,this.textRotation_=0,this.textScale_=[0,0],this.textFillState_=null,this.textStrokeState_=null,this.textState_=null,this.pixelCoordinates_=[],this.tmpLocalTransform_=At()}drawImages_(t,e,i,r){if(!this.image_)return;let s=jt(t,e,i,r,this.transform_,this.pixelCoordinates_),o=this.context_,a=this.tmpLocalTransform_,l=o.globalAlpha;this.imageOpacity_!=1&&(o.globalAlpha=l*this.imageOpacity_);let h=this.imageRotation_;this.transformRotation_===0&&(h-=this.viewRotation_),this.imageRotateWithView_&&(h+=this.viewRotation_);for(let c=0,d=s.length;c<d;c+=2){let f=s[c]-this.imageAnchorX_,g=s[c+1]-this.imageAnchorY_;if(h!==0||this.imageScale_[0]!=1||this.imageScale_[1]!=1){let m=f+this.imageAnchorX_,_=g+this.imageAnchorY_;Ot(a,m,_,1,1,h,-m,-_),o.save(),o.transform.apply(o,a),o.translate(m,_),o.scale(this.imageScale_[0],this.imageScale_[1]),o.drawImage(this.image_,this.imageOriginX_,this.imageOriginY_,this.imageWidth_,this.imageHeight_,-this.imageAnchorX_,-this.imageAnchorY_,this.imageWidth_,this.imageHeight_),o.restore()}else o.drawImage(this.image_,this.imageOriginX_,this.imageOriginY_,this.imageWidth_,this.imageHeight_,f,g,this.imageWidth_,this.imageHeight_)}this.imageOpacity_!=1&&(o.globalAlpha=l)}drawText_(t,e,i,r){if(!this.textState_||this.text_==="")return;this.textFillState_&&this.setContextFillState_(this.textFillState_),this.textStrokeState_&&this.setContextStrokeState_(this.textStrokeState_),this.setContextTextState_(this.textState_);let s=jt(t,e,i,r,this.transform_,this.pixelCoordinates_),o=this.context_,a=this.textRotation_;for(this.transformRotation_===0&&(a-=this.viewRotation_),this.textRotateWithView_&&(a+=this.viewRotation_);e<i;e+=r){let l=s[e]+this.textOffsetX_,h=s[e+1]+this.textOffsetY_;a!==0||this.textScale_[0]!=1||this.textScale_[1]!=1?(o.save(),o.translate(l-this.textOffsetX_,h-this.textOffsetY_),o.rotate(a),o.translate(this.textOffsetX_,this.textOffsetY_),o.scale(this.textScale_[0],this.textScale_[1]),this.textStrokeState_&&o.strokeText(this.text_,0,0),this.textFillState_&&o.fillText(this.text_,0,0),o.restore()):(this.textStrokeState_&&o.strokeText(this.text_,l,h),this.textFillState_&&o.fillText(this.text_,l,h))}}moveToLineTo_(t,e,i,r,s,o){let a=this.context_,l=jt(t,e,i,r,this.transform_,this.pixelCoordinates_);if(Math.abs(o)>0){let c=l.length,d=s||Math.abs(l[0]-l[c-2])<1e-6&&Math.abs(l[1]-l[c-1])<1e-6;l=aa(l,0,c,2,o,d,l),la(l,2,d)}a.moveTo(l[0],l[1]);let h=l.length;s&&(h-=2);for(let c=2;c<h;c+=2)a.lineTo(l[c],l[c+1]);return s&&a.closePath(),i}drawRings_(t,e,i,r,s){for(let o=0,a=i.length;o<a;++o)e=this.moveToLineTo_(t,e,i[o],r,!0,s);return e}drawCircle(t){if(this.squaredTolerance_&&(t=t.simplifyTransformed(this.squaredTolerance_,this.userTransform_)),!!ht(this.extent_,t.getExtent())){if(this.fillState_||this.strokeState_){this.fillState_&&this.setContextFillState_(this.fillState_),this.strokeState_&&this.setContextStrokeState_(this.strokeState_);let e=Pd(t,this.transform_,this.pixelCoordinates_),i=e[2]-e[0],r=e[3]-e[1],s=Math.sqrt(i*i+r*r),o=this.context_;o.beginPath(),o.arc(e[0],e[1],s,0,2*Math.PI),this.fillState_&&o.fill(),this.strokeState_&&o.stroke()}this.text_!==""&&this.drawText_(t.getCenter(),0,2,2)}}setStyle(t){this.setFillStrokeStyle(t.getFill(),t.getStroke()),this.setImageStyle(t.getImage()),this.setTextStyle(t.getText())}setTransform(t){this.transform_=t}drawGeometry(t){switch(t.getType()){case"Point":this.drawPoint(t);break;case"LineString":this.drawLineString(t);break;case"Polygon":this.drawPolygon(t);break;case"MultiPoint":this.drawMultiPoint(t);break;case"MultiLineString":this.drawMultiLineString(t);break;case"MultiPolygon":this.drawMultiPolygon(t);break;case"GeometryCollection":this.drawGeometryCollection(t);break;case"Circle":this.drawCircle(t);break;default:}}drawFeature(t,e){let i=e.getGeometryFunction()(t);i&&(this.setStyle(e),this.drawGeometry(i))}drawGeometryCollection(t){let e=t.getGeometriesArray();for(let i=0,r=e.length;i<r;++i)this.drawGeometry(e[i])}drawPoint(t){this.squaredTolerance_&&(t=t.simplifyTransformed(this.squaredTolerance_,this.userTransform_));let e=t.getFlatCoordinates(),i=t.getStride();this.image_&&this.drawImages_(e,0,e.length,i),this.text_!==""&&this.drawText_(e,0,e.length,i)}drawMultiPoint(t){this.squaredTolerance_&&(t=t.simplifyTransformed(this.squaredTolerance_,this.userTransform_));let e=t.getFlatCoordinates(),i=t.getStride();this.image_&&this.drawImages_(e,0,e.length,i),this.text_!==""&&this.drawText_(e,0,e.length,i)}drawLineString(t){if(this.squaredTolerance_&&(t=t.simplifyTransformed(this.squaredTolerance_,this.userTransform_)),!!ht(this.extent_,t.getExtent())){if(this.strokeState_){this.setContextStrokeState_(this.strokeState_);let e=this.context_,i=t.getFlatCoordinates();e.beginPath(),this.moveToLineTo_(i,0,i.length,t.getStride(),!1,this.strokeState_.strokeOffset),e.stroke()}if(this.text_!==""){let e=t.getFlatMidpoint();this.drawText_(e,0,2,2)}}}drawMultiLineString(t){this.squaredTolerance_&&(t=t.simplifyTransformed(this.squaredTolerance_,this.userTransform_));let e=t.getExtent();if(ht(this.extent_,e)){if(this.strokeState_){this.setContextStrokeState_(this.strokeState_);let i=this.context_,r=t.getFlatCoordinates(),s=0,o=t.getEnds(),a=t.getStride();i.beginPath();for(let l=0,h=o.length;l<h;++l)s=this.moveToLineTo_(r,s,o[l],a,!1,this.strokeState_.strokeOffset);i.stroke()}if(this.text_!==""){let i=t.getFlatMidpoints();this.drawText_(i,0,i.length,2)}}}drawPolygon(t){if(this.squaredTolerance_&&(t=t.simplifyTransformed(this.squaredTolerance_,this.userTransform_)),!!ht(this.extent_,t.getExtent())){if(this.strokeState_||this.fillState_){this.fillState_&&this.setContextFillState_(this.fillState_),this.strokeState_&&this.setContextStrokeState_(this.strokeState_);let e=this.context_;e.beginPath(),this.drawRings_(t.getOrientedFlatCoordinates(),0,t.getEnds(),t.getStride(),this.strokeState_?.strokeOffset),this.fillState_&&e.fill(),this.strokeState_&&e.stroke()}if(this.text_!==""){let e=t.getFlatInteriorPoint();this.drawText_(e,0,2,2)}}}drawMultiPolygon(t){if(this.squaredTolerance_&&(t=t.simplifyTransformed(this.squaredTolerance_,this.userTransform_)),!!ht(this.extent_,t.getExtent())){if(this.strokeState_||this.fillState_){this.fillState_&&this.setContextFillState_(this.fillState_),this.strokeState_&&this.setContextStrokeState_(this.strokeState_);let e=this.context_,i=t.getOrientedFlatCoordinates(),r=0,s=t.getEndss(),o=t.getStride();e.beginPath();for(let a=0,l=s.length;a<l;++a){let h=s[a];r=this.drawRings_(i,r,h,o,this.strokeState_?.strokeOffset)}this.fillState_&&e.fill(),this.strokeState_&&e.stroke()}if(this.text_!==""){let e=t.getFlatInteriorPoints();this.drawText_(e,0,e.length,2)}}}setContextFillState_(t){let e=this.context_,i=this.contextFillState_;i?i.fillStyle!=t.fillStyle&&(i.fillStyle=t.fillStyle,e.fillStyle=t.fillStyle):(e.fillStyle=t.fillStyle,this.contextFillState_={fillStyle:t.fillStyle})}setContextStrokeState_(t){let e=this.context_,i=this.contextStrokeState_;i?(i.lineCap!=t.lineCap&&(i.lineCap=t.lineCap,e.lineCap=t.lineCap),Gt(i.lineDash,t.lineDash)||e.setLineDash(i.lineDash=t.lineDash),i.lineDashOffset!=t.lineDashOffset&&(i.lineDashOffset=t.lineDashOffset,e.lineDashOffset=t.lineDashOffset),i.lineJoin!=t.lineJoin&&(i.lineJoin=t.lineJoin,e.lineJoin=t.lineJoin),i.lineWidth!=t.lineWidth&&(i.lineWidth=t.lineWidth,e.lineWidth=t.lineWidth),i.miterLimit!=t.miterLimit&&(i.miterLimit=t.miterLimit,e.miterLimit=t.miterLimit),i.strokeStyle!=t.strokeStyle&&(i.strokeStyle=t.strokeStyle,e.strokeStyle=t.strokeStyle)):(e.lineCap=t.lineCap,e.setLineDash(t.lineDash),e.lineDashOffset=t.lineDashOffset,e.lineJoin=t.lineJoin,e.lineWidth=t.lineWidth,e.miterLimit=t.miterLimit,e.strokeStyle=t.strokeStyle,this.contextStrokeState_={lineCap:t.lineCap,lineDash:t.lineDash,lineDashOffset:t.lineDashOffset,lineJoin:t.lineJoin,lineWidth:t.lineWidth,miterLimit:t.miterLimit,strokeStyle:t.strokeStyle})}setContextTextState_(t){let e=this.context_,i=this.contextTextState_,r=t.textAlign?t.textAlign:Wi;i?(i.font!=t.font&&(i.font=t.font,e.font=t.font),i.textAlign!=r&&(i.textAlign=r,e.textAlign=r),i.textBaseline!=t.textBaseline&&(i.textBaseline=t.textBaseline,e.textBaseline=t.textBaseline)):(e.font=t.font,e.textAlign=r,e.textBaseline=t.textBaseline,this.contextTextState_={font:t.font,textAlign:r,textBaseline:t.textBaseline})}setFillStrokeStyle(t,e){if(!t)this.fillState_=null;else{let i=t.getColor();this.fillState_={fillStyle:Ht(i||Tt)}}if(!e)this.strokeState_=null;else{let i=e.getColor(),r=e.getLineCap(),s=e.getLineDash(),o=e.getLineDashOffset(),a=e.getLineJoin(),l=e.getWidth(),h=e.getMiterLimit(),c=s||qt,d=e.getOffset();this.strokeState_={lineCap:r!==void 0?r:Ze,lineDash:this.pixelRatio_===1?c:c.map(f=>f*this.pixelRatio_),lineDashOffset:(o||$t)*this.pixelRatio_,lineJoin:a!==void 0?a:Ke,lineWidth:(l!==void 0?l:pi)*this.pixelRatio_,miterLimit:h!==void 0?h:gi,strokeStyle:Ht(i||Wt),strokeOffset:(d??0)*this.pixelRatio_}}}setImageStyle(t){let e;if(!t||!(e=t.getSize())){this.image_=null;return}let i=t.getPixelRatio(this.pixelRatio_),r=t.getAnchor(),s=t.getOrigin();this.image_=t.getImage(this.pixelRatio_),this.imageAnchorX_=r[0]*i,this.imageAnchorY_=r[1]*i,this.imageHeight_=e[1]*i,this.imageOpacity_=t.getOpacity(),this.imageOriginX_=s[0],this.imageOriginY_=s[1],this.imageRotateWithView_=t.getRotateWithView(),this.imageRotation_=t.getRotation();let o=t.getScaleArray();this.imageScale_=[o[0]*this.pixelRatio_/i,o[1]*this.pixelRatio_/i],this.imageWidth_=e[0]*i}setTextStyle(t){if(!t)this.text_="";else{let e=t.getFill();if(!e)this.textFillState_=null;else{let g=e.getColor();this.textFillState_={fillStyle:Ht(g||Tt)}}let i=t.getStroke();if(!i)this.textStrokeState_=null;else{let g=i.getColor(),m=i.getLineCap(),_=i.getLineDash(),p=i.getLineDashOffset(),y=i.getLineJoin(),E=i.getWidth(),C=i.getMiterLimit();this.textStrokeState_={lineCap:m!==void 0?m:Ze,lineDash:_||qt,lineDashOffset:p||$t,lineJoin:y!==void 0?y:Ke,lineWidth:E!==void 0?E:pi,miterLimit:C!==void 0?C:gi,strokeStyle:Ht(g||Wt)}}let r=t.getFont(),s=t.getOffsetX(),o=t.getOffsetY(),a=t.getRotateWithView(),l=t.getRotation(),h=t.getScaleArray(),c=t.getText(),d=t.getTextAlign(),f=t.getTextBaseline();this.textState_={font:r!==void 0?r:vo,textAlign:d!==void 0?d:Wi,textBaseline:f!==void 0?f:mn},this.text_=c!==void 0?Array.isArray(c)?c.reduce((g,m,_)=>g+=_%2?" ":m,""):c:"",this.textOffsetX_=s!==void 0?this.pixelRatio_*s:0,this.textOffsetY_=o!==void 0?this.pixelRatio_*o:0,this.textRotateWithView_=a!==void 0?a:!1,this.textRotation_=l!==void 0?l:0,this.textScale_=[this.pixelRatio_*h[0],this.pixelRatio_*h[1]]}}},cm=Ph;var Ae=.5;function hm(n,t,e,i,r,s,o,a,l){let h=l?Ai(r,l):r,c=n[0]*Ae,d=n[1]*Ae,f=nt(c,d);f.imageSmoothingEnabled=!1;let g=f.canvas,m=new cm(f,Ae,r,null,o,a,l?an(cn(),l):null),_=e.length,p=Math.floor((256*256*256-1)/_),y={};for(let C=1;C<=_;++C){let x=e[C-1],w=x.getStyleFunction()||i;if(!w)continue;let T=w(x,s);if(!T)continue;Array.isArray(T)||(T=[T]);let R=(C*p).toString(16).padStart(7,"#00000");for(let I=0,b=T.length;I<b;++I){let N=T[I],G=N.getGeometryFunction()(x);if(!G||!ht(h,G.getExtent()))continue;let F=N.clone(),B=F.getFill();B&&B.setColor(R);let lt=F.getStroke();lt&&(lt.setColor(R),lt.setLineDash(null)),F.setText(void 0);let M=N.getImage();if(M){let z=M.getImageSize();if(!z)continue;let tt=nt(z[0],z[1],void 0,{alpha:!1}),it=tt.canvas;tt.fillStyle=R,tt.fillRect(0,0,it.width,it.height),F.setImage(new pn({img:it,anchor:M.getAnchor(),anchorXUnits:"pixels",anchorYUnits:"pixels",offset:M.getOrigin(),opacity:1,size:M.getSize(),scale:M.getScale(),rotation:M.getRotation(),rotateWithView:M.getRotateWithView()}))}let X=F.getZIndex()||0,O=y[X];O||(O={},y[X]=O,O.Polygon=[],O.Circle=[],O.LineString=[],O.Point=[]);let $=G.getType();if($==="GeometryCollection"){let z=G.getGeometriesArrayRecursive();for(let tt=0,it=z.length;tt<it;++tt){let Ct=z[tt];O[Ct.getType().replace("Multi","")].push(Ct,F)}}else O[$.replace("Multi","")].push(G,F)}}let E=Object.keys(y).map(Number).sort(Bt);for(let C=0,x=E.length;C<x;++C){let w=y[E[C]];for(let T in w){let A=w[T];for(let R=0,I=A.length;R<I;R+=2){m.setStyle(A[R+1]);for(let b=0,N=t.length;b<N;++b)m.setTransform(t[b]),m.drawGeometry(A[R])}}}return f.getImageData(0,0,g.width,g.height)}function um(n,t,e){let i=[];if(e){let r=Math.floor(Math.round(n[0])*Ae),s=Math.floor(Math.round(n[1])*Ae),o=(et(r,0,e.width-1)+et(s,0,e.height-1)*e.width)*4,a=e.data[o],l=e.data[o+1],c=e.data[o+2]+256*(l+256*a),d=Math.floor((256*256*256-1)/t.length);c&&c%d===0&&i.push(t[c/d-1])}return i}var by=.5,dm={Point:ky,LineString:Py,Polygon:Ny,MultiPoint:Fy,MultiLineString:Oy,MultiPolygon:Dy,GeometryCollection:My,Circle:Ly};function fm(n,t){return parseInt(Y(n),10)-parseInt(Y(t),10)}function Oh(n,t){let e=Dh(n,t);return e*e}function Dh(n,t){return by*n/t}function Ly(n,t,e,i,r){let s=e.getFill(),o=e.getStroke();if(s||o){let l=n.getBuilder(e.getZIndex(),"Circle");l.setFillStrokeStyle(s,o),l.drawCircle(t,i,r)}let a=e.getText();if(a&&a.getText()){let l=n.getBuilder(e.getZIndex(),"Text");l.setTextStyle(a),l.drawText(t,i,r)}}function kh(n,t,e,i,r,s,o,a){let l=[],h=e.getImage();if(h){let f=!0,g=h.getImageState();g==U.LOADED||g==U.ERROR?f=!1:g==U.IDLE&&h.load(),f&&l.push(h.ready())}let c=e.getFill();c&&c.loading()&&l.push(c.ready());let d=l.length>0;return d&&Promise.all(l).then(()=>r(null)),Ay(n,t,e,i,s,o,a),d}function Ay(n,t,e,i,r,s,o){let a=e.getGeometryFunction()(t);if(!a)return;let l=a.simplifyTransformed(i,r);if(e.getRenderer())gm(n,l,e,t,o);else{let c=dm[l.getType()];c(n,l,e,t,o,s)}}function gm(n,t,e,i,r){if(t.getType()=="GeometryCollection"){let o=t.getGeometries();for(let a=0,l=o.length;a<l;++a)gm(n,o[a],e,i,r);return}n.getBuilder(e.getZIndex(),"Default").drawCustom(t,i,e.getRenderer(),e.getHitDetectionRenderer(),r)}function My(n,t,e,i,r,s){let o=t.getGeometriesArray(),a,l;for(a=0,l=o.length;a<l;++a){let h=dm[o[a].getType()];h(n,o[a],e,i,r,s)}}function Py(n,t,e,i,r){let s=e.getStroke();if(s){let a=n.getBuilder(e.getZIndex(),"LineString");a.setFillStrokeStyle(null,s),a.drawLineString(t,i,r)}let o=e.getText();if(o&&o.getText()){let a=n.getBuilder(e.getZIndex(),"Text");a.setTextStyle(o),a.drawText(t,i,r)}}function Oy(n,t,e,i,r){let s=e.getStroke();if(s){let a=n.getBuilder(e.getZIndex(),"LineString");a.setFillStrokeStyle(null,s),a.drawMultiLineString(t,i,r)}let o=e.getText();if(o&&o.getText()){let a=n.getBuilder(e.getZIndex(),"Text");a.setTextStyle(o),a.drawText(t,i,r)}}function Dy(n,t,e,i,r){let s=e.getFill(),o=e.getStroke();if(o||s){let l=n.getBuilder(e.getZIndex(),"Polygon");l.setFillStrokeStyle(s,o),l.drawMultiPolygon(t,i,r)}let a=e.getText();if(a&&a.getText()){let l=n.getBuilder(e.getZIndex(),"Text");l.setTextStyle(a),l.drawText(t,i,r)}}function ky(n,t,e,i,r,s){let o=e.getImage(),a=e.getText(),l=a&&a.getText(),h=s&&o&&l?{}:void 0;if(o){if(o.getImageState()!=U.LOADED)return;let c=n.getBuilder(e.getZIndex(),"Image");c.setImageStyle(o,h),c.drawPoint(t,i,r)}if(l){let c=n.getBuilder(e.getZIndex(),"Text");c.setTextStyle(a,h),c.drawText(t,i,r)}}function Fy(n,t,e,i,r,s){let o=e.getImage(),a=o&&o.getOpacity()!==0,l=e.getText(),h=l&&l.getText(),c=s&&a&&h?{}:void 0;if(a){if(o.getImageState()!=U.LOADED)return;let d=n.getBuilder(e.getZIndex(),"Image");d.setImageStyle(o,c),d.drawMultiPoint(t,i,r)}if(h){let d=n.getBuilder(e.getZIndex(),"Text");d.setTextStyle(l,c),d.drawText(t,i,r)}}function Ny(n,t,e,i,r){let s=e.getFill(),o=e.getStroke();if(s||o){let l=n.getBuilder(e.getZIndex(),"Polygon");l.setFillStrokeStyle(s,o),l.drawPolygon(t,i,r)}let a=e.getText();if(a&&a.getText()){let l=n.getBuilder(e.getZIndex(),"Text");l.setTextStyle(a),l.drawText(t,i,r)}}var Fh=class extends sa{constructor(t){super(t),this.boundHandleStyleImageChange_=this.handleStyleImageChange_.bind(this),this.animatingOrInteracting_,this.hitDetectionImageData_=null,this.clipExtent_=null,this.extendX_=!1,this.renderedFeatures_=null,this.renderedRevision_=-1,this.renderedResolution_=NaN,this.renderedExtent_=ut(),this.wrappedRenderedExtent_=ut(),this.renderedRotation_,this.renderedCenter_=null,this.renderedProjection_=null,this.renderedPixelRatio_=1,this.renderedRenderOrder_=null,this.renderedFrameDeclutter_,this.replayGroup_=null,this.replayGroupChanged=!0,this.clipping=!0,this.targetContext_=null,this.opacity_=1}renderWorlds(t,e,i){let r=e.extent,s=e.viewState,o=s.center,a=s.resolution,l=s.projection,h=s.rotation,c=l.getExtent(),d=this.getLayer().getSource(),f=this.getLayer().getDeclutter(),g=e.pixelRatio,m=e.viewHints,_=!(m[bt.ANIMATING]||m[bt.INTERACTING]),p=this.context,y=Math.round(j(r)/a*g),E=Math.round(ct(r)/a*g),C=d.getWrapX()&&l.canWrapX(),x=C?j(c):null,w=C?Math.ceil((r[2]-c[2])/x)+(this.extendX_?2:1):1,T=C?Math.floor((r[0]-c[0])/x)-(this.extendX_?1:0):0;do{let A=this.getRenderTransform(o,a,0,g,y,E,T*x);e.declutter&&(A=A.slice(0)),t.execute(p,[p.canvas.width,p.canvas.height],A,h,_,i===void 0?ji:i?Mh:sm,i?f&&e.declutter[f]:void 0)}while(++T<w)}setDrawContext_(){this.opacity_!==1&&(this.targetContext_=this.context,this.context=nt(this.context.canvas.width,this.context.canvas.height,ch))}resetDrawContext_(){if(this.opacity_!==1&&this.targetContext_){let t=this.targetContext_.globalAlpha;this.targetContext_.globalAlpha=this.opacity_,this.targetContext_.drawImage(this.context.canvas,0,0),this.targetContext_.globalAlpha=t,dn(this.context),ch.push(this.context.canvas),this.context=this.targetContext_,this.targetContext_=null}}renderDeclutter(t){!this.replayGroup_||!this.getLayer().getDeclutter()||this.renderWorlds(this.replayGroup_,t,!0)}renderDeferredInternal(t){this.replayGroup_&&(this.clipExtent_&&this.clipUnrotated(this.context,t,this.clipExtent_),this.replayGroup_.renderDeferred(),this.clipExtent_&&(this.context.restore(),this.clipExtent_=null),this.resetDrawContext_())}renderFrame(t,e){let i=t.layerStatesArray[t.layerIndex];this.opacity_=i.opacity;let r=t.viewState;this.prepareContainer(t,e);let s=this.context,o=this.replayGroup_,a=o&&!o.isEmpty();if(!a&&!(this.getLayer().hasListener(Ft.PRERENDER)||this.getLayer().hasListener(Ft.POSTRENDER)))return this.container;this.setDrawContext_(),this.preRender(s,t);let l=r.projection;this.clipExtent_=null;let h=!1;if(a&&i.extent&&this.clipping){let c=Ce(i.extent,l);a=ht(c,t.extent),a&&!De(c,t.extent)&&(t.declutter?this.clipExtent_=c:(this.clipUnrotated(s,t,c),h=!0))}return a&&this.renderWorlds(o,t,this.getLayer().getDeclutter()?!1:void 0),h&&s.restore(),this.postRender(s,t),this.renderedRotation_!==r.rotation&&(this.renderedRotation_=r.rotation,this.hitDetectionImageData_=null),t.declutter||this.resetDrawContext_(),this.container}getFeatures(t){return new Promise(e=>{if(this.frameState&&!this.hitDetectionImageData_&&!this.animatingOrInteracting_){let i=this.frameState.size.slice(),r=this.renderedCenter_,s=this.renderedResolution_,o=this.renderedRotation_,a=this.renderedProjection_,l=this.wrappedRenderedExtent_,h=this.getLayer(),c=[],d=i[0]*Ae,f=i[1]*Ae;c.push(this.getRenderTransform(r,s,o,Ae,d,f,0).slice());let g=h.getSource(),m=a.getExtent();if(g.getWrapX()&&a.canWrapX()&&!De(m,l)){let p=l[0],y=j(m),E=0,C;for(;p<m[0];)--E,C=y*E,c.push(this.getRenderTransform(r,s,o,Ae,d,f,C).slice()),p+=y;for(E=0,p=l[2];p>m[2];)++E,C=y*E,c.push(this.getRenderTransform(r,s,o,Ae,d,f,C).slice()),p-=y}let _=cn();this.hitDetectionImageData_=hm(i,c,this.renderedFeatures_,h.getStyleFunction(),l,s,o,Oh(s,this.renderedPixelRatio_),_?a:null)}e(um(t,this.renderedFeatures_,this.hitDetectionImageData_))})}forEachFeatureAtCoordinate(t,e,i,r,s){if(!this.replayGroup_)return;let o=e.viewState.resolution,a=e.viewState.rotation,l=this.getLayer(),h={},c=function(f,g,m){let _=Y(f),p=h[_];if(p){if(p!==!0&&m<p.distanceSq){if(m===0)return h[_]=!0,s.splice(s.lastIndexOf(p),1),r(f,l,g);p.geometry=g,p.distanceSq=m}}else{if(m===0)return h[_]=!0,r(f,l,g);s.push(h[_]={feature:f,layer:l,geometry:g,distanceSq:m,callback:r})}},d=this.getLayer().getDeclutter();return this.replayGroup_.forEachFeatureAtCoordinate(t,o,a,i,c,d?e.declutter?.[d]?.all().map(f=>f.value):null)}handleFontsChanged(){let t=this.getLayer();t.getVisible()&&this.replayGroup_&&t.changed()}handleStyleImageChange_(t){this.renderIfReadyAndVisible()}prepareFrame(t){let e=this.getLayer(),i=e.getSource();if(!i)return!1;let r=t.viewHints[bt.ANIMATING],s=t.viewHints[bt.INTERACTING],o=e.getUpdateWhileAnimating(),a=e.getUpdateWhileInteracting();if(this.ready&&!o&&r||!a&&s)return this.animatingOrInteracting_=!0,!0;this.animatingOrInteracting_=!1;let l=t.extent,h=t.viewState,c=h.projection,d=h.resolution,f=t.pixelRatio,g=e.getRevision(),m=e.getRenderBuffer(),_=e.getRenderOrder();_===void 0&&(_=fm);let p=h.center.slice(),y=In(l,m*d),E=y.slice(),C=[y.slice()],x=c.getExtent(),w=i.getWrapX()&&c.canWrapX();if(this.extendX_=!1,w){let M=i.getExtent();M&&!Fe(M)&&(this.extendX_=M[0]<x[0]||M[2]>x[2])}if(w&&(!De(x,t.extent)||this.extendX_)){let M=j(x),X=Math.max(j(y)/2,M),O=x[0],$=x[2];this.extendX_&&(O-=M,$+=M),y[0]=O-X,y[2]=$+X,Fs(p,c);let z=Ra(C[0],c);z[0]<x[0]&&z[2]<x[2]?C.push([z[0]+M,z[1],z[2]+M,z[3]]):z[0]>x[0]&&z[2]>x[2]&&C.push([z[0]-M,z[1],z[2]-M,z[3]])}if(this.ready&&this.renderedResolution_==d&&this.renderedPixelRatio_===f&&this.renderedRevision_==g&&this.renderedRenderOrder_==_&&this.renderedFrameDeclutter_===!!t.declutter&&De(this.wrappedRenderedExtent_,y))return Gt(this.renderedExtent_,E)||(this.hitDetectionImageData_=null,this.renderedExtent_=E),this.renderedCenter_=p,this.replayGroupChanged=!1,!0;this.replayGroup_=null;let T=new Qg(Dh(d,f),y,d,f),A=cn(),R;if(A){for(let M=0,X=C.length;M<X;++M){let O=C[M],$=Ai(O,c);i.loadFeatures($,Nu(d,c),A)}R=an(A,c)}else for(let M=0,X=C.length;M<X;++M)i.loadFeatures(C[M],d,c);let I=Oh(d,f),b=!0,N=(M,X)=>{let O,$=M.getStyleFunction()||e.getStyleFunction();if($&&(O=$(M,d)),O){let z=this.renderFeature(M,I,O,T,R,this.getLayer().getDeclutter(),X);b=b&&!z}},G=Ai(y,c),F=i.getFeaturesInExtent(G);_&&F.sort(_);for(let M=0,X=F.length;M<X;++M)N(F[M],M);this.renderedFeatures_=F,this.ready=b;let B=T.finish(),lt=new lm(y,d,f,i.getOverlaps(),B,e.getRenderBuffer(),!!t.declutter);return this.renderedResolution_=d,this.renderedRevision_=g,this.renderedRenderOrder_=_,this.renderedFrameDeclutter_=!!t.declutter,this.renderedExtent_=E,this.wrappedRenderedExtent_=y,this.renderedCenter_=p,this.renderedProjection_=c,this.renderedPixelRatio_=f,this.replayGroup_=lt,this.hitDetectionImageData_=null,this.replayGroupChanged=!0,!0}renderFeature(t,e,i,r,s,o,a){if(!i)return!1;let l=!1;if(Array.isArray(i))for(let h=0,c=i.length;h<c;++h)l=kh(r,t,i[h],e,this.boundHandleStyleImageChange_,s,o,a)||l;else l=kh(r,t,i,e,this.boundHandleStyleImageChange_,s,o,a);return l}},mm=Fh;var Nh=class extends ea{constructor(t){super(t)}createRenderer(){return new mm(this)}},pm=Nh;var zy=!1;function Gy(n,t,e,i,r,s,o){let a=new XMLHttpRequest;a.open("GET",typeof n=="function"?n(e,i,r):n,!0),t.getType()=="arraybuffer"&&(a.responseType="arraybuffer"),a.withCredentials=zy,a.onload=function(l){if(!a.status||a.status>=200&&a.status<300){let h=t.getType();try{let c;h=="text"||h=="json"?c=a.responseText:h=="xml"?c=a.responseXML||a.responseText:h=="arraybuffer"&&(c=a.response),c?s(t.readFeatures(c,{extent:e,featureProjection:r}),t.readProjection(c)):o()}catch{o()}}else o()},a.onerror=o,a.send()}function zh(n,t){return function(e,i,r,s,o){Gy(n,t,e,i,r,(a,l)=>{this.addFeatures(a),s!==void 0&&s(a)},()=>{this.changed(),o!==void 0&&o()})}}function _m(n,t){return[[-1/0,-1/0,1/0,1/0]]}function Gh(n,t,e,i,r,s,o){let a,l,h=(e-t)/i;if(h===1)a=t;else if(h===2)a=t,l=r;else if(h!==0){let c=n[t],d=n[t+1],f=0,g=[0];for(let p=t+i;p<e;p+=i){let y=n[p],E=n[p+1];f+=Math.sqrt((y-c)*(y-c)+(E-d)*(E-d)),g.push(f),c=y,d=E}let m=r*f,_=Gu(g,m);_<0?(l=(m-g[-_-2])/(g[-_-1]-g[-_-2]),a=t+(-_-2)*i):a=t+_*i}o=o>1?o:2,s=s||new Array(o);for(let c=0;c<o;++c)s[c]=a===void 0?NaN:l===void 0?n[a+c]:zt(n[a+c],n[a+i+c],l);return s}var ym=At(),_s=class n{constructor(t,e,i,r,s,o){this.styleFunction,this.extent_,this.id_=o,this.type_=t,this.flatCoordinates_=e,this.flatInteriorPoints_=null,this.flatMidpoints_=null,this.ends_=i||null,this.properties_=s,this.squaredTolerance_,this.stride_=r,this.simplifiedGeometry_}get(t){return this.properties_[t]}getExtent(){return this.extent_||(this.extent_=this.type_==="Point"?Ls(this.flatCoordinates_):bn(this.flatCoordinates_,0,this.flatCoordinates_.length,this.stride_)),this.extent_}getFlatInteriorPoint(){if(!this.flatInteriorPoints_){let t=Kt(this.getExtent());this.flatInteriorPoints_=Ur(this.flatCoordinates_,0,this.ends_,this.stride_,t,0)}return this.flatInteriorPoints_}getFlatInteriorPoints(){if(!this.flatInteriorPoints_){let t=Kd(this.flatCoordinates_,this.ends_),e=Lo(this.flatCoordinates_,0,t,this.stride_);this.flatInteriorPoints_=fo(this.flatCoordinates_,0,t,this.stride_,e)}return this.flatInteriorPoints_}getFlatMidpoint(){return this.flatMidpoints_||(this.flatMidpoints_=Gh(this.flatCoordinates_,0,this.flatCoordinates_.length,this.stride_,.5)),this.flatMidpoints_}getFlatMidpoints(){if(!this.flatMidpoints_){this.flatMidpoints_=[];let t=this.flatCoordinates_,e=0,i=this.ends_;for(let r=0,s=i.length;r<s;++r){let o=i[r],a=Gh(t,e,o,this.stride_,.5);ve(this.flatMidpoints_,a),e=o}}return this.flatMidpoints_}getId(){return this.id_}getOrientedFlatCoordinates(){return this.flatCoordinates_}getGeometry(){return this}getSimplifiedGeometry(t){return this}simplifyTransformed(t,e){return this}getProperties(){return this.properties_}getPropertiesInternal(){return this.properties_}getStride(){return this.stride_}getStyleFunction(){return this.styleFunction}getType(){return this.type_}transform(t){t=Et(t);let e=t.getExtent(),i=t.getWorldExtent();if(e&&i){let r=ct(i)/ct(e);Ot(ym,i[0],i[3],r,-r,0,0,0),jt(this.flatCoordinates_,0,this.flatCoordinates_.length,this.stride_,ym,this.flatCoordinates_)}}applyTransform(t){t(this.flatCoordinates_,this.flatCoordinates_,this.stride_)}clone(){return new n(this.type_,this.flatCoordinates_.slice(),this.ends_?.slice(),this.stride_,Object.assign({},this.properties_),this.id_)}getEnds(){return this.ends_}enableSimplifyTransformed(){return this.simplifyTransformed=Hs((t,e)=>{if(t===this.squaredTolerance_)return this.simplifiedGeometry_;this.simplifiedGeometry_=this.clone(),e&&this.simplifiedGeometry_.applyTransform(e);let i=this.simplifiedGeometry_.getFlatCoordinates(),r;switch(this.type_){case"LineString":i.length=Xr(i,0,this.simplifiedGeometry_.flatCoordinates_.length,this.simplifiedGeometry_.stride_,t,i,0),r=[i.length];break;case"MultiLineString":r=[],i.length=Ud(i,0,this.simplifiedGeometry_.ends_,this.simplifiedGeometry_.stride_,t,i,0,r);break;case"Polygon":r=[],i.length=Wr(i,0,this.simplifiedGeometry_.ends_,this.simplifiedGeometry_.stride_,Math.sqrt(t),i,0,r);break;default:}return r&&(this.simplifiedGeometry_=new n(this.type_,i,r,this.stride_,this.properties_,this.id_)),this.squaredTolerance_=t,this.simplifiedGeometry_}),this}};_s.prototype.getFlatCoordinates=_s.prototype.getOrientedFlatCoordinates;var vn=_s;var Xh=class{constructor(t){this.rbush_=new En(t),this.items_={}}insert(t,e){let i={minX:t[0],minY:t[1],maxX:t[2],maxY:t[3],value:e};this.rbush_.insert(i),this.items_[Y(e)]=i}load(t,e){let i=new Array(e.length);for(let r=0,s=e.length;r<s;r++){let o=t[r],a=e[r],l={minX:o[0],minY:o[1],maxX:o[2],maxY:o[3],value:a};i[r]=l,this.items_[Y(a)]=l}this.rbush_.load(i)}remove(t){let e=Y(t),i=this.items_[e];return delete this.items_[e],this.rbush_.remove(i)!==null}update(t,e){let i=this.items_[Y(e)],r=[i.minX,i.minY,i.maxX,i.maxY];en(r,t)||(this.remove(e),this.insert(t,e))}getAll(){return this.rbush_.all().map(function(e){return e.value})}getInExtent(t){let e={minX:t[0],minY:t[1],maxX:t[2],maxY:t[3]};return this.rbush_.search(e).map(function(r){return r.value})}forEach(t){return this.forEach_(this.getAll(),t)}forEachInExtent(t,e){return this.forEach_(this.getInExtent(t),e)}forEach_(t,e){let i;for(let r=0,s=t.length;r<s;r++)if(i=e(t[r]),i)return i;return i}isEmpty(){return xe(this.items_)}clear(){this.rbush_.clear(),this.items_={}}getExtent(t){let e=this.rbush_.toJSON();return Qt(e.minX,e.minY,e.maxX,e.maxY,t)}concat(t){this.rbush_.load(t.rbush_.all());for(let e in t.items_)this.items_[e]=t.items_[e]}},Wh=Xh;var ie={ADDFEATURE:"addfeature",CHANGEFEATURE:"changefeature",CLEAR:"clear",REMOVEFEATURE:"removefeature",FEATURESLOADSTART:"featuresloadstart",FEATURESLOADEND:"featuresloadend",FEATURESLOADERROR:"featuresloaderror"};var Qe=class extends Lt{constructor(t,e,i){super(t),this.feature=e,this.features=i}},Uh=class extends ro{constructor(t){t=t||{},super({attributions:t.attributions,interpolate:!0,projection:void 0,state:"ready",wrapX:t.wrapX!==void 0?t.wrapX:!0}),this.on,this.once,this.un,this.loader_=ci,this.format_=t.format||null,this.overlaps_=t.overlaps===void 0?!0:t.overlaps,this.url_=t.url,t.loader!==void 0?this.loader_=t.loader:this.url_!==void 0&&(K(this.format_,"`format` must be set when `url` is set"),this.loader_=zh(this.url_,this.format_)),this.strategy_=t.strategy!==void 0?t.strategy:_m;let e=t.useSpatialIndex!==void 0?t.useSpatialIndex:!0;this.featuresRtree_=e?new Wh:null,this.loadedExtentsRtree_=new Wh,this.nullGeometryFeatures_={},this.idIndex_={},this.uidIndex_={},this.featureChangeKeys_={},this.featuresCollection_=null;let i,r;Array.isArray(t.features)?r=t.features:t.features&&(i=t.features,r=i.getArray()),!e&&i===void 0&&(i=new Dt(r)),r!==void 0&&this.addFeaturesInternal(r),i!==void 0&&this.bindFeaturesCollection_(i)}addFeature(t){this.addFeatureInternal(t),this.changed()}addFeatureInternal(t){let e=Y(t);if(!this.addToIndex_(e,t)){this.featuresCollection_&&this.featuresCollection_.remove(t);return}this.setupChangeEvents_(e,t);let i=t.getGeometry();if(i){let r=i.getExtent();this.featuresRtree_&&this.featuresRtree_.insert(r,t)}else this.nullGeometryFeatures_[e]=t;this.dispatchEvent(new Qe(ie.ADDFEATURE,t))}setupChangeEvents_(t,e){e instanceof vn||(this.featureChangeKeys_[t]=[Z(e,P.CHANGE,this.handleFeatureChange_,this),Z(e,Se.PROPERTYCHANGE,this.handleFeatureChange_,this)])}addToIndex_(t,e){let i=!0;if(e.getId()!==void 0){let r=String(e.getId());if(!(r in this.idIndex_))this.idIndex_[r]=e;else if(e instanceof vn){let s=this.idIndex_[r];s instanceof vn?Array.isArray(s)?s.push(e):this.idIndex_[r]=[s,e]:i=!1}else i=!1}return i&&(K(!(t in this.uidIndex_),"The passed `feature` was already added to the source"),this.uidIndex_[t]=e),i}addFeatures(t){this.addFeaturesInternal(t),this.changed()}addFeaturesInternal(t){let e=[],i=[],r=[];for(let s=0,o=t.length;s<o;s++){let a=t[s],l=Y(a);this.addToIndex_(l,a)&&i.push(a)}for(let s=0,o=i.length;s<o;s++){let a=i[s],l=Y(a);this.setupChangeEvents_(l,a);let h=a.getGeometry();if(h){let c=h.getExtent();e.push(c),r.push(a)}else this.nullGeometryFeatures_[l]=a}if(this.featuresRtree_&&this.featuresRtree_.load(e,r),this.hasListener(ie.ADDFEATURE))for(let s=0,o=i.length;s<o;s++)this.dispatchEvent(new Qe(ie.ADDFEATURE,i[s]))}bindFeaturesCollection_(t){let e=!1;this.addEventListener(ie.ADDFEATURE,function(i){e||(e=!0,t.push(i.feature),e=!1)}),this.addEventListener(ie.REMOVEFEATURE,function(i){e||(e=!0,t.remove(i.feature),e=!1)}),t.addEventListener(Pt.ADD,i=>{e||(e=!0,this.addFeature(i.element),e=!1)}),t.addEventListener(Pt.REMOVE,i=>{e||(e=!0,this.removeFeature(i.element),e=!1)}),this.featuresCollection_=t}clear(t){if(t){for(let i in this.featureChangeKeys_)this.featureChangeKeys_[i].forEach(J);this.featuresCollection_||(this.featureChangeKeys_={},this.idIndex_={},this.uidIndex_={})}else if(this.featuresRtree_){this.featuresRtree_.forEach(i=>{this.removeFeatureInternal(i)});for(let i in this.nullGeometryFeatures_)this.removeFeatureInternal(this.nullGeometryFeatures_[i])}this.featuresCollection_&&this.featuresCollection_.clear(),this.featuresRtree_&&this.featuresRtree_.clear(),this.nullGeometryFeatures_={};let e=new Qe(ie.CLEAR);this.dispatchEvent(e),this.changed()}forEachFeature(t){if(this.featuresRtree_)return this.featuresRtree_.forEach(t);this.featuresCollection_&&this.featuresCollection_.forEach(t)}forEachFeatureAtCoordinateDirect(t,e){let i=[t[0],t[1],t[0],t[1]];return this.forEachFeatureInExtent(i,function(r){let s=r.getGeometry();if(s instanceof vn||s.intersectsCoordinate(t))return e(r)})}forEachFeatureInExtent(t,e){if(this.featuresRtree_)return this.featuresRtree_.forEachInExtent(t,e);this.featuresCollection_&&this.featuresCollection_.forEach(e)}forEachFeatureIntersectingExtent(t,e){return this.forEachFeatureInExtent(t,function(i){let r=i.getGeometry();if(r instanceof vn||r.intersectsExtent(t)){let s=e(i);if(s)return s}})}getFeaturesCollection(){return this.featuresCollection_}getFeatures(){let t;return this.featuresCollection_?t=this.featuresCollection_.getArray().slice(0):this.featuresRtree_&&(t=this.featuresRtree_.getAll(),xe(this.nullGeometryFeatures_)||ve(t,Object.values(this.nullGeometryFeatures_))),t}getFeaturesAtCoordinate(t){let e=[];return this.forEachFeatureAtCoordinateDirect(t,function(i){e.push(i)}),e}getFeaturesInExtent(t,e){if(this.featuresRtree_){if(!(e&&e.canWrapX()&&this.getWrapX()))return this.featuresRtree_.getInExtent(t);let r=Ps(t,e);return[].concat(...r.map(s=>this.featuresRtree_.getInExtent(s)))}return this.featuresCollection_?this.featuresCollection_.getArray().slice(0):[]}getClosestFeatureToCoordinate(t,e){let i=t[0],r=t[1],s=null,o=[NaN,NaN],a=1/0,l=[-1/0,-1/0,1/0,1/0];return e=e||ai,this.featuresRtree_.forEachInExtent(l,function(h){if(e(h)){let c=h.getGeometry(),d=a;if(a=c instanceof vn?0:c.closestPointXY(i,r,o,a),a<d){s=h;let f=Math.sqrt(a);l[0]=i-f,l[1]=r-f,l[2]=i+f,l[3]=r+f}}}),s}getExtent(t){return this.featuresRtree_?.getExtent(t)??null}getFeatureById(t){let e=this.idIndex_[t.toString()];return e!==void 0?e:null}getFeatureByUid(t){let e=this.uidIndex_[t];return e!==void 0?e:null}getFormat(){return this.format_}getOverlaps(){return this.overlaps_}getUrl(){return this.url_}handleFeatureChange_(t){let e=t.target,i=Y(e),r=e.getGeometry();if(!r)i in this.nullGeometryFeatures_||(this.featuresRtree_&&this.featuresRtree_.remove(e),this.nullGeometryFeatures_[i]=e);else{let o=r.getExtent();i in this.nullGeometryFeatures_?(delete this.nullGeometryFeatures_[i],this.featuresRtree_&&this.featuresRtree_.insert(o,e)):this.featuresRtree_&&this.featuresRtree_.update(o,e)}let s=e.getId();if(s!==void 0){let o=s.toString();this.idIndex_[o]!==e&&(this.removeFromIdIndex_(e),this.idIndex_[o]=e)}else this.removeFromIdIndex_(e),this.uidIndex_[i]=e;this.changed(),this.dispatchEvent(new Qe(ie.CHANGEFEATURE,e))}hasFeature(t){let e=t.getId();if(e!==void 0){let i=this.idIndex_[String(e)];return Array.isArray(i)?i.includes(t):i===t}return Y(t)in this.uidIndex_}isEmpty(){return this.featuresRtree_?this.featuresRtree_.isEmpty()&&xe(this.nullGeometryFeatures_):this.featuresCollection_?this.featuresCollection_.getLength()===0:!0}loadFeatures(t,e,i){let r=this.loadedExtentsRtree_,s=this.strategy_(t,e,i);for(let o=0,a=s.length;o<a;++o){let l=s[o];if(!r.forEachInExtent(l,function(c){return De(c.extent,l)})){this.loading=Number(this.loading)+1,this.dispatchEvent(new Qe(ie.FEATURESLOADSTART));let c=m=>{this.loading=Number(this.loading)-1,this.dispatchEvent(new Qe(ie.FEATURESLOADEND,void 0,m))},d=()=>{this.changed(),this.loading=Number(this.loading)-1,this.dispatchEvent(new Qe(ie.FEATURESLOADERROR))},f=!1,g=this.loader_.call(this,l,e,i,m=>f||c(m),()=>f||d());g instanceof Promise?(f=!0,g.then(m=>{this.addFeatures(m),c(m)}).catch(d)):this.loader_.length<4&&(this.loading=!1),r.insert(l,{extent:l.slice()})}}}refresh(){this.clear(!0),this.loadedExtentsRtree_.clear(),super.refresh()}removeLoadedExtent(t){let e=this.loadedExtentsRtree_,i=[];e.forEachInExtent(t,function(r){i.push(r)}),i.forEach(r=>{e.remove(r);let s=Sa(r.extent,t);for(let o of s)e.insert(o,{extent:o})})}removeFeatures(t){let e=!1;for(let i=0,r=t.length;i<r;++i)e=this.removeFeatureInternal(t[i])||e;e&&this.changed()}removeFeature(t){if(!t)return;this.removeFeatureInternal(t)&&this.changed()}removeFeatureInternal(t){let e=Y(t);if(!(e in this.uidIndex_))return!1;e in this.nullGeometryFeatures_?delete this.nullGeometryFeatures_[e]:this.featuresRtree_&&this.featuresRtree_.remove(t),this.featureChangeKeys_[e]?.forEach(J),delete this.featureChangeKeys_[e];let r=t.getId();if(r!==void 0){let s=r.toString(),o=this.idIndex_[s];o===t?delete this.idIndex_[s]:Array.isArray(o)&&(o.splice(o.indexOf(t),1),o.length===1&&(this.idIndex_[s]=o[0]))}return delete this.uidIndex_[e],this.hasListener(ie.REMOVEFEATURE)&&this.dispatchEvent(new Qe(ie.REMOVEFEATURE,t)),!0}removeFromIdIndex_(t){for(let e in this.idIndex_)if(this.idIndex_[e]===t){delete this.idIndex_[e];break}}setLoader(t){this.loader_=t}setUrl(t){K(this.format_,"`format` must be set when `url` is set"),this.url_=t,this.setLoader(zh(t,this.format_))}setOverlaps(t){this.overlaps_=t,this.changed()}},Ri=Uh;function xm(){let n=u.variant,t=v.overviewCanvas,e=t.getContext("2d"),i=fi(),r=u.catalog.tileGrid.size,s=u.catalog.tileGrid.tileSize,o=i[2]-i[0],a=i[3]-i[1],l=0;for(;l<n.fullZoom&&Math.max(o,a)/r*s*2**l<168;)l++;let h=s*2**l/r;t.width=Math.max(1,Math.round(o*h)),t.height=Math.max(1,Math.round(a*h)),e.clearRect(0,0,t.width,t.height),n.background&&(e.fillStyle=n.background,e.fillRect(0,0,t.width,t.height));let c=++u.overviewRun,d=n.formats[l],f=Math.floor(i[0]/r*2**l),g=Math.ceil(i[2]/r*2**l),m=Math.floor(-i[3]/r*2**l),_=Math.ceil(-i[1]/r*2**l);for(let p=m;p<_;p++)for(let y=f;y<g;y++){if(!d||!ha(n,l,y,p))continue;let E=new Image;E.onload=()=>{u.overviewRun===c&&e.drawImage(E,y*s-i[0]*h,p*s+i[3]*h,s,s)},E.src=`/static/tiles/${encodeURIComponent(n.tiles)}/${l}/${y}/${p}.${d}`}ys()}function ys(){let n=u.engine?.getView();if(!n||!u.variant)return;let t=fi(),e=n.calculateExtent(u.engine.getSize()),i=t[2]-t[0],r=t[3]-t[1],s=(n.getResolution()||0)*4,o=e[0]<=t[0]+s&&e[1]<=t[1]+s&&e[2]>=t[2]-s&&e[3]>=t[3]-s,a=o?"hidden":e.map(Math.round).join(",");if(a===u.overviewKey||(u.overviewKey=a,v.overviewShelf.hidden=o,o))return;let l=v.overviewCanvas,h=Re((e[0]-t[0])/i,0,1),c=Re((e[2]-t[0])/i,0,1),d=Re((t[3]-e[3])/r,0,1),f=Re((t[3]-e[1])/r,0,1),g=v.overviewViewport.style;g.left=`${h*l.width}px`,g.top=`${d*l.height}px`,g.width=`${Math.max(8,(c-h)*l.width)}px`,g.height=`${Math.max(8,(f-d)*l.height)}px`}function ca(n,t=!0){u.overviewDocked=n,n&&u.overviewPointer!==null&&(u.overviewPointer=null,gr()),v.overviewShelf.classList.toggle("is-docked",n),v.overviewDock.setAttribute("aria-expanded",String(!n));let e=n?"Bring the overview back":"Put the overview away";v.overviewDock.setAttribute("aria-label",e),v.overviewDock.title=e,t&&hi()}function Yh(n,t){let e=u.engine?.getView();if(!e||!u.variant)return;let i=v.overviewCanvas.getBoundingClientRect(),r=fi(),s=(a,l,h)=>Re((a-l)/(h-l),0,1),o=[r[0]+s(n.clientX,i.left,i.right)*(r[2]-r[0]),r[3]-s(n.clientY,i.top,i.bottom)*(r[3]-r[1])];if(t){e.animate({center:o,duration:180});return}e.cancelAnimations(),e.setCenter(o)}function ne(n){return new pm({updateWhileAnimating:!0,...n})}function Em(){let n=u.catalog.tileGrid.size,t=[0,-n,n,0];u.projection=new bi({code:"ATLAS:PIXELS",units:"pixels",extent:t}),u.sources={grid:new Ri({wrapX:!1}),gridContext:new Ri({wrapX:!1}),zoneScrim:new Ri({wrapX:!1}),zones:new Ri({wrapX:!1}),zoneTitles:new Ri({wrapX:!1}),text:new Ri({wrapX:!1}),pins:new Ri({wrapX:!1}),priority:new Ri({wrapX:!1})},u.layers={raster:new gh({zIndex:0}),rasterDetail:new gh({zIndex:1}),grid:ne({source:u.sources.grid,style:Jl,renderOrder:de,renderBuffer:40,zIndex:5}),zoneScrim:ne({source:u.sources.zoneScrim,style:Rf,zIndex:6}),zones:ne({source:u.sources.zones,style:Tf,renderBuffer:32,zIndex:10}),zoneTitles:ne({source:u.sources.zoneTitles,style:If,renderOrder:de,renderBuffer:160,zIndex:20}),zoneTitleDetail:ne({source:u.sources.zoneTitles,style:bf,renderOrder:de,renderBuffer:160,zIndex:44}),text:ne({source:u.sources.text,style:yf,renderOrder:de,renderBuffer:220,zIndex:30}),textDetail:ne({source:u.sources.text,style:xf,renderOrder:de,renderBuffer:220,zIndex:45}),zoneText:ne({source:u.sources.text,style:Ef,renderOrder:de,renderBuffer:220,zIndex:41}),pins:ne({source:u.sources.pins,style:mf,renderOrder:de,renderBuffer:48,zIndex:40}),zonePins:ne({source:u.sources.pins,style:pf,renderOrder:de,renderBuffer:48,zIndex:42}),pinLabels:ne({source:u.sources.pins,style:_f,renderOrder:de,renderBuffer:180,zIndex:45}),gridContext:ne({source:u.sources.gridContext,style:Jl,renderOrder:de,renderBuffer:40,zIndex:48}),priority:ne({source:u.sources.priority,style:wf,renderOrder:de,renderBuffer:220,zIndex:50})},u.engine=new Ug({target:v.viewport,layers:Object.values(u.layers),controls:Do({attribution:!1,rotate:!1,zoom:!1}),interactions:Xo({onFocusOnly:!1}),view:Vh(5)}),u.engine.on("movestart",()=>{u.engine.getViewport().classList.add("is-dragging")}),u.engine.on("moveend",()=>{u.engine.getViewport().classList.remove("is-dragging"),u.overviewPointer===null&&gr()}),u.engine.on("postrender",ys),v.viewport.addEventListener("wheel",()=>{document.activeElement!==v.viewport&&v.viewport.focus({preventScroll:!0})},{capture:!0,passive:!0}),u.engine.on("singleclick",e=>{if(u.gridEnabled){let r=u.engine.forEachFeatureAtPixel(e.pixel,s=>{let o=s.get("gridCell");return o&&o.role!=="leaf"&&o.role!=="scope"?o:null},{hitTolerance:1,layerFilter:s=>s===u.layers.grid||s===u.layers.gridContext});if(r){Vr(r.hash);return}}let i=u.engine.forEachFeatureAtPixel(e.pixel,(r,s)=>ua(s)&&r.get("pin")||null,{hitTolerance:5,layerFilter:ua});i&&ml(i)}),u.engine.on("pointermove",e=>{if(e.dragging){er(null);return}let i=u.engine.forEachFeatureAtPixel(e.pixel,(o,a)=>ua(a)&&o.get("pin")||null,{hitTolerance:4,layerFilter:ua}),r=i?.category.displayType==="text"?null:i;er(r||null);let s=u.gridEnabled&&u.engine.hasFeatureAtPixel(e.pixel,{layerFilter:o=>o===u.layers.grid||o===u.layers.gridContext});u.engine.getTargetElement().style.cursor=i||s?"pointer":""}),u.engine.getViewport().addEventListener("pointerleave",()=>er(null))}function ua(n){return n===u.layers.pins||n===u.layers.zonePins||n===u.layers.pinLabels||n===u.layers.priority||n===u.layers.text||n===u.layers.textDetail||n===u.layers.zoneText}function Vh(n){let t=u.catalog.tileGrid.size;return new ee({projection:u.projection,center:[t/2,-t/2],resolutions:Zh(n),minZoom:0,maxZoom:n,extent:[0,-t,t,0],constrainResolution:!1,smoothResolutionConstraint:!1,showFullExtent:!0,zoom:0})}function Zh(n){let t=u.catalog.tileGrid.size/u.catalog.tileGrid.tileSize;return Array.from({length:n+1},(e,i)=>t/2**i)}async function xs(n,t){u.game=u.catalog.games.find(r=>r.slug===n)||u.catalog.games[0],!t&&!u.restore&&(u.restore=ao(u.game.slug)),v.game.value=u.game.slug,Sr(v.map,u.game.maps,"title","id"),v.map.disabled=u.game.maps.length===1,v.map.title=v.map.disabled?"This game has one map":"Choose a map";let e=u.restore?.game===u.game.slug?u.restore:null,i=t&&u.game.maps.find(r=>r.slug===t)||e&&u.game.maps.find(r=>r.slug===e.map);await Kh((i||u.game.maps[0]).id)}async function Kh(n){let t=u.game.maps.find(s=>s.id===n)||u.game.maps[0],e=++u.mapRun;v.loading.hidden=!1;let i=await Zf(t);if(u.mapRun!==e)return;u.settling=!0,u.map=i,document.documentElement.style.setProperty("--icon-outset-color",Fr()),v.map.value=String(u.map.id),Sr(v.variant,u.map.variants,"name"),v.variantField.hidden=u.map.variants.length<2,u.styleCache.clear(),er(null),u.gridPrefix="",u.hiddenCategories.clear(),u.collapsedSections.clear(),u.collapsedSections.add("zones");for(let s of u.map.groups)for(let o of s.categories)o.visible||u.hiddenCategories.add(o.id);let r=u.restore?.map===u.map.slug?u.restore:null;r&&(u.hiddenCategories=new Set(r.hidden),u.collapsedSections=new Set(r.collapsed)),ca(!!u.restore?.overviewDocked,!1),u.search="",v.search.value="",v.searchResults.hidden=!0,Te(),Wf(),ec(),Gf(),Bh(r?Re(r.variant,0,u.map.variants.length-1):0,!0),v.gameTitle.textContent=u.game.title,v.title.textContent=u.map.title,v.meta.textContent=`${Xe(u.map.pinCount)} locations \xB7 ${Xe(u.map.zones?.length||0)} regions`,v.sidebar.classList.remove("is-open"),v.mobileLegend.setAttribute("aria-expanded","false"),Td(),u.settling=!1,hi()}function Bh(n,t=!1){let e=u.variant;u.variant=u.map.variants[n]||u.map.variants[0];let i=u.variant,r=t?null:Yy(e,i),s=Ue(i);v.variant.value=String(u.map.variants.indexOf(u.variant)),t?u.engine.setView(Vh(s)):(u.engine.getView().setMinZoom(i.minZoom),u.engine.getView().setMaxZoom(s));let o=++u.tileRun,a=0;u.tileStats={requested:0,loaded:0,errors:0,peakPending:0},v.loading.hidden=!1;let l=_=>{_.on("tileloadstart",()=>{u.tileRun===o&&(a++,u.tileStats.requested++,u.tileStats.peakPending=Math.max(u.tileStats.peakPending,a))});let p=y=>{u.tileRun===o&&(a=Math.max(0,a-1),y?u.tileStats.errors++:u.tileStats.loaded++,a===0&&u.tileStats.loaded>0&&(v.loading.hidden=!0))};return _.on("tileloadend",()=>p(!1)),_.on("tileloaderror",()=>p(!0)),_},h=(_,p)=>l(new Sd({projection:u.projection,tileGrid:new Or({extent:[0,-u.catalog.tileGrid.size,u.catalog.tileGrid.size,0],origin:[0,0],resolutions:Zh(_),tileSize:u.catalog.tileGrid.tileSize}),cacheSize:64,interpolate:i.interpolate,transition:0,wrapX:!1,tileUrlFunction:([y,E,C])=>{let x=i.formats[y];if(!(!x||E<0||C<0||!p(y,E,C)))return`/static/tiles/${encodeURIComponent(i.tiles)}/${y}/${E}/${C}.${x}`}})),c=i.fullZoom??i.maxZoom,d=h(c,(_,p,y)=>ha(i,_,p,y)),f=u.layers.raster.getSource();u.layers.raster.setSource(d),u.layers.raster.setExtent(fi()),u.layers.raster.setBackground(i.background||void 0),f?.clear();let g=u.layers.rasterDetail.getSource();i.maxZoom>c?(u.layers.rasterDetail.setSource(h(i.maxZoom,(_,p,y)=>_>c&&ha(i,_,p,y))),u.layers.rasterDetail.setExtent(fi()),u.layers.rasterDetail.setVisible(!0)):u.layers.rasterDetail.setVisible(!1),g?.clear(),_o(),u.gridEnabled&&(We(),u.layers.pins.changed(),u.layers.text.changed(),u.layers.priority.changed()),u.overviewKey="",xm();let m=u.restore?.map===u.map.slug?u.restore:null;if(u.renderedShard!==(i.shard||0)&&(ec(),he()),m?.center&&Number.isFinite(m.zoom)){let _=u.engine.getView();_.setCenter(m.center),_.setZoom(m.zoom),u.fitZoom=m.zoom,_n()}else t?requestAnimationFrame(Vy):(r&&u.engine.getView().animate({center:r,duration:200}),_n());hi()}function ha(n,t,e,i){let r=n.coverage?.[t];if(!r)return!0;let s=e-r.x,o=i-r.y;if(s<0||o<0||s>=r.w||o>=r.h)return!1;let a=Uy(n,t,r),l=o*r.w+s;return(a[l>>3]&1<<(l&7))!==0}function Uy(n,t,e){if(!e.decoded){let i=atob(e.bits),r=new Uint8Array(i.length);for(let s=0;s<i.length;s++)r[s]=i.charCodeAt(s);e.decoded=r}return e.decoded}function Ue(n){return n.maxZoom+2}function gr(){_n(),hi()}function Yy(n,t){if(!n||!t||!n.shard||!t.shard||n.shard===t.shard||!n.bounds||!t.bounds)return null;let i=u.engine?.getView()?.getCenter();if(!i)return null;let r=(i[0]-n.bounds.x)/n.bounds.width,s=(-i[1]-n.bounds.y)/n.bounds.height;return[t.bounds.x+Re(r,0,1)*t.bounds.width,-(t.bounds.y+Re(s,0,1)*t.bounds.height)]}function wm(){let t=document.querySelector(".app-shell").classList.toggle("sidebar-collapsed");v.mobileLegend.setAttribute("aria-expanded",String(!t)),requestAnimationFrame(()=>u.engine?.updateSize())}function fi(){let n=u.catalog.tileGrid.size,t=u.variant?.bounds||{x:0,y:0,width:n,height:n};return[t.x,-(t.y+t.height),t.x+t.width,-t.y]}function Vy(){if(!u.engine||!u.variant)return;let n=u.engine.getView();n.fit(fi(),{size:u.engine.getSize(),padding:[36,36,36,36],maxZoom:u.variant.maxZoom,duration:0}),u.fitZoom=n.getZoom()||0,_n()}function Es(n){let t=u.engine.getView(),e=t.getZoom()||0;t.animate({zoom:Re(e+n,u.variant.minZoom,Ue(u.variant)),duration:140})}function _n(){let n=u.engine?.getView().getZoom();if(v.viewport.dataset.zoom=Number.isFinite(n)?n.toFixed(3):"",!u.engine||!u.pins.length){v.visibleCount.textContent="0 locations visible";return}let t=u.engine.getView().calculateExtent(u.engine.getSize()),e=0;for(let i of u.pins){if(fe(i))continue;let[r,s]=i.coordinate;r>=t[0]&&r<=t[2]&&s>=t[1]&&s<=t[3]&&e++}v.visibleCount.textContent=`${Xe(u.eligibleLocations)} enabled \xB7 ${Xe(e)} in view`}function Cm(){v.game.addEventListener("change",()=>{xs(v.game.value)}),v.map.addEventListener("change",()=>{Kh(Number(v.map.value))}),v.variant.addEventListener("change",()=>Bh(Number(v.variant.value))),v.legend.addEventListener("change",i=>{let r=i.target;if(r.dataset.sectionToggle){Yf(r.dataset.sectionToggle);return}if(!r.dataset.category)return;let s=Number(r.dataset.category);r.checked?u.hiddenCategories.delete(s):u.hiddenCategories.add(s),he(),Ni()});let n=null,t=()=>{for(let s of v.layers.querySelectorAll(".is-hovered"))s.classList.remove("is-hovered");if(!n)return;let r=document.elementFromPoint(n.x,n.y)?.closest(".category-row, .layer-header");r&&v.layers.contains(r)&&r.classList.add("is-hovered")};v.layers.addEventListener("pointermove",i=>{n={x:i.clientX,y:i.clientY},t()},{passive:!0}),v.layers.addEventListener("pointerleave",()=>{n=null,t()}),v.layers.addEventListener("scroll",t,{passive:!0}),v.layers.addEventListener("click",i=>{let r=i.target.closest("[data-only-category], [data-only-section]");if(r){i.preventDefault(),i.stopPropagation(),Vf(r.dataset.onlyCategory?{category:Number(r.dataset.onlyCategory)}:{section:r.dataset.onlySection});return}let s=i.target.closest("[data-section]");if(!s)return;let o=s.dataset.section;u.collapsedSections.has(o)?u.collapsedSections.delete(o):u.collapsedSections.add(o),Po()}),v.soloChip.addEventListener("click",()=>Qr(!0)),W("#expand-all").addEventListener("click",()=>sc(!1)),W("#collapse-all").addEventListener("click",()=>sc(!0)),W("#show-all").addEventListener("click",()=>Qr(!0)),W("#hide-all").addEventListener("click",()=>Qr(!1)),v.zoneToggle.addEventListener("change",()=>{Ao(v.zoneToggle.checked)}),v.zoneIndex.addEventListener("click",i=>{let r=i.target.closest("[data-zone]");r&&Ff(Number(r.dataset.zone))}),v.zoneIndex.addEventListener("contextmenu",i=>{let r=i.target.closest("[data-zone]");r&&(i.preventDefault(),Nf(Number(r.dataset.zone)))}),v.search.addEventListener("input",()=>{u.search=v.search.value.trim().toLocaleLowerCase(),he(),Jr()}),v.searchResults.addEventListener("click",i=>{let r=i.target.closest("[data-location]");if(!r)return;let s=u.pinByID.get(Number(r.dataset.location));s&&gl(s)}),v.detailLinks.addEventListener("click",i=>{let r=i.target.closest("[data-location]");if(!r)return;let s=u.pinByID.get(Number(r.dataset.location));s&&gl(s)}),W("#close-detail").addEventListener("click",Te),W("#zoom-in").addEventListener("click",()=>Es(1)),W("#zoom-out").addEventListener("click",()=>Es(-1)),v.gridBack.addEventListener("click",bl),v.gridInput.addEventListener("input",()=>{let i=qn(),r=[...v.gridInput.value.toLocaleLowerCase()].filter(s=>me.includes(s)).slice(0,i).join("");v.gridInput.value=r,Vr(r)}),v.subgridToggle.addEventListener("click",()=>{Yr(!u.subgridVisible),v.viewport.focus({preventScroll:!0})}),v.gridInput.addEventListener("keydown",i=>{if(i.key===" "){i.preventDefault(),Yr(!u.subgridVisible);return}i.key==="Escape"&&(i.preventDefault(),i.stopPropagation(),v.viewport.focus({preventScroll:!0}))}),v.viewport.addEventListener("keydown",i=>{if(!uo(i.target)){if(i.key==="+"||i.key==="=")Es(1);else if(i.key==="-")Es(-1);else if(i.key==="Escape")Te();else return;i.preventDefault()}}),window.addEventListener("contextmenu",i=>{uo(i.target)||i.preventDefault()}),window.addEventListener("keydown",i=>{if((i.metaKey||i.ctrlKey)&&i.key.toLocaleLowerCase()==="r"){i.preventDefault(),location.reload();return}if(!uo(i.target)){if((i.metaKey||i.ctrlKey)&&i.key.toLocaleLowerCase()==="k"){i.preventDefault(),v.search.focus(),v.search.select();return}if((i.metaKey||i.ctrlKey)&&i.key.toLocaleLowerCase()==="b"){i.preventDefault(),wm();return}Bd(i)||i.key.toLocaleLowerCase()==="z"&&(i.preventDefault(),u.pinLabelsVisible=!u.pinLabelsVisible,v.labelsHint.textContent=`Z \xB7 labels ${u.pinLabelsVisible?"on":"off"}`,u.layers.pinLabels.changed())}}),window.addEventListener("hashchange",()=>{let i=lo();i.game===u.game?.slug&&i.map===u.map?.slug||(u.restore=null,xs(i.game||u.catalog.games[0].slug,i.map))}),window.addEventListener("resize",()=>{u.engine?.updateSize(),ys()}),v.overview.addEventListener("pointerdown",i=>{u.overviewDocked||i.pointerType==="mouse"&&i.button!==0||(i.preventDefault(),v.overview.setPointerCapture(i.pointerId),u.overviewPointer=i.pointerId,Yh(i,!0))}),v.overview.addEventListener("pointermove",i=>{u.overviewPointer===i.pointerId&&(i.preventDefault(),Yh(i,!1))});let e=i=>{u.overviewPointer===i.pointerId&&(u.overviewPointer=null,gr())};v.overview.addEventListener("pointerup",e),v.overview.addEventListener("pointercancel",e),v.overviewDock.addEventListener("click",()=>{ca(!u.overviewDocked),v.viewport.focus({preventScroll:!0})}),v.mobileLegend.addEventListener("click",()=>{let i=v.sidebar.classList.toggle("is-open");v.mobileLegend.setAttribute("aria-expanded",String(i))})}function vm(){let n=()=>({game:u.game?.title,map:u.map?.title,variant:u.variant?.name,zoom:u.engine?.getView().getZoom(),center:u.engine?.getView().getCenter(),resolution:u.engine?.getView().getResolution(),nativeMaxZoom:u.variant?.maxZoom,maxZoom:u.variant?Ue(u.variant):null,interpolate:u.variant?.interpolate,tileStats:{...u.tileStats},pins:u.pins.length,eligibleLocations:u.eligibleLocations,domNodes:document.querySelectorAll("*").length,canvases:document.querySelectorAll("canvas").length,rasterCacheSize:64,pinLabelsVisible:u.pinLabelsVisible,hoveredPin:u.hoveredPin?.location.title||null,selectedPin:u.selectedPin?.location.title||null,fitZoom:u.fitZoom,filters:{hiddenCategories:[...u.hiddenCategories].sort(),collapsedSections:[...u.collapsedSections].sort()},ui:{sidebarCollapsed:document.querySelector(".app-shell")?.classList.contains("sidebar-collapsed")??!1,detailOpen:!v.detail.hidden,detailTitle:v.detailTitle.textContent||null,searchQuery:u.search,searchResultsVisible:!v.searchResults.hidden,soloChip:v.soloChip.hidden?null:v.soloChip.textContent,visibleCountText:v.visibleCount.textContent,overviewDocked:u.overviewDocked,subgridVisible:u.subgridVisible},zones:{visible:u.zonesVisible,count:u.zoneRecords.size,focused:u.zoneRecords.get(u.focusedZoneID)?.zone.title||null,highlighted:[...u.highlightedZones].map(t=>u.zoneRecords.get(t)?.zone.title).filter(Boolean),focusedPins:u.pins.filter(t=>!t.filteredHidden&&t.insideHighlightedZone).length},grid:{enabled:u.gridEnabled,prefix:u.gridPrefix,maximumDepth:qn(),extent:u.gridEnabled?Hn():null,cells:[...u.sources.grid.getFeatures(),...u.sources.gridContext.getFeatures()].map(t=>t.get("gridCell")),priorityPins:u.gridPrefix?u.pins.filter(t=>!t.filteredHidden&&$n(t)).length:0}});window.__atlasDebug={snapshot:n,setLayerVisible:(t,e)=>u.layers[t]?.setVisible(e)},window.render_game_to_text=()=>JSON.stringify({coordinateSystem:"ATLAS:PIXELS; origin top-left; x increases right; y decreases downward",...n()}),window.advanceTime=()=>u.engine?.renderSync()}async function Sm(){Cm();try{let n=await fetch("/static/catalog.json");if(!n.ok)throw new Error(`catalog request returned ${n.status}`);if(u.catalog=await n.json(),!u.catalog.games.length)throw new Error("the embedded catalog contains no maps");Em(),Sr(v.game,u.catalog.games,"title");let t=lo(),e=ao(),i=e&&(!t.game||t.game===e.game&&t.map===e.map);u.restore=i?e:null,await xs(t.game||e?.game||u.catalog.games[0].slug,t.map||e?.map),u.restore=null,vm(),requestAnimationFrame(()=>v.viewport.focus({preventScroll:!0}))}catch(n){v.loading.hidden=!0,v.fatalMessage.textContent=n instanceof Error?n.message:String(n),v.fatal.hidden=!1}}Sm();})();
M frontend/app.css +31 -1500
@@ -1,1500 +1,31 @@
1-:root {2- color-scheme: dark;3- --bg: #111310;4- --panel: #171a16;5- --panel-raised: #1e211c;6- --line: rgba(236, 240, 218, 0.11);7- --line-strong: rgba(236, 240, 218, 0.2);8- --text: #eef0e4;9- --muted: #93988b;10- --accent: #d6f36b;11- --accent-dark: #202a0e;12- --topbar: 72px;13- --sidebar: 330px;14- --pin-overlay-size: 28px;15- --text-overlay-size: 14px;16- --zone-overlay-size: 14px;17- --icon-outset-color: rgba(255, 255, 255, 0.96);18- --icon-outset:19- drop-shadow(1px 0 0 var(--icon-outset-color))20- drop-shadow(-1px 0 0 var(--icon-outset-color))21- drop-shadow(0 1px 0 var(--icon-outset-color))22- drop-shadow(0 -1px 0 var(--icon-outset-color))23- drop-shadow(0 2px 2px rgba(0, 0, 0, 0.9));24- font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;25- font-synthesis: none;26-}27-28-* {29- box-sizing: border-box;30-}31-32-html,33-body {34- width: 100%;35- height: 100%;36- margin: 0;37- overflow: hidden;38- background: var(--bg);39- color: var(--text);40- -webkit-user-select: none;41- user-select: none;42-}43-44-button,45-input,46-select {47- font: inherit;48-}49-50-button {51- color: inherit;52-}53-54-input {55- -webkit-user-select: text;56- user-select: text;57-}58-59-.app-shell {60- display: grid;61- grid-template-columns: var(--sidebar) 1fr;62- grid-template-rows: var(--topbar) minmax(0, 1fr);63- width: 100%;64- height: 100%;65-}66-67-.topbar {68- position: relative;69- z-index: 20;70- grid-column: 1 / -1;71- display: grid;72- grid-template-columns: var(--sidebar) minmax(0, 1fr) auto;73- align-items: center;74- border-bottom: 1px solid var(--line);75- background: rgba(19, 21, 18, 0.96);76- box-shadow: 0 8px 30px rgba(0, 0, 0, 0.18);77-}78-79-.brand {80- display: flex;81- align-items: center;82- gap: 12px;83- height: 100%;84- padding: 0 24px;85- border-right: 1px solid var(--line);86-}87-88-.brand-mark {89- display: grid;90- width: 35px;91- height: 35px;92- place-items: center;93- color: var(--accent);94-}95-96-.brand-mark svg {97- width: 100%;98- fill: none;99- stroke: currentColor;100- stroke-linecap: round;101- stroke-linejoin: round;102- stroke-width: 1.7;103-}104-105-.brand strong,106-.brand small {107- display: block;108-}109-110-.brand strong {111- font-family: "Arial Narrow", "Roboto Condensed", sans-serif;112- font-size: 16px;113- letter-spacing: 0.2em;114- line-height: 1;115-}116-117-.brand small {118- margin-top: 5px;119- color: var(--muted);120- font-size: 10px;121- letter-spacing: 0.08em;122- text-transform: uppercase;123-}124-125-.map-pickers {126- display: flex;127- align-items: center;128- gap: 7px;129- min-width: 0;130- padding: 0 18px;131-}132-133-.map-pickers label {134- display: flex;135- min-width: 0;136- align-items: center;137- gap: 7px;138- color: var(--muted);139- font-size: 10px;140- font-weight: 700;141- letter-spacing: 0.1em;142- text-transform: uppercase;143-}144-145-.map-pickers select {146- max-width: 230px;147- height: 37px;148- padding: 0 32px 0 12px;149- border: 1px solid var(--line);150- border-radius: 8px;151- outline: none;152- background: var(--panel-raised);153- color: var(--text);154- font-size: 13px;155- font-weight: 600;156- letter-spacing: normal;157- text-transform: none;158-}159-160-.map-pickers select:focus {161- border-color: rgba(214, 243, 107, 0.6);162-}163-164-.map-pickers select:disabled {165- border-color: transparent;166- background: rgba(255, 255, 255, 0.025);167- color: #9ca193;168- cursor: default;169- opacity: 1;170-}171-172-#variant-field[hidden] {173- display: none;174-}175-176-.icon-button {177- display: grid;178- width: 40px;179- height: 40px;180- padding: 10px;181- place-items: center;182- border: 1px solid var(--line);183- border-radius: 8px;184- background: var(--panel-raised);185-}186-187-.icon-button svg {188- fill: none;189- stroke: currentColor;190- stroke-linecap: round;191- stroke-width: 1.8;192-}193-194-.mobile-legend {195- display: none;196- margin-right: 16px;197-}198-199-/* Collapsed by ⌘B. The brand column shrinks with it so the topbar does not200- keep a rule hanging over open map. */201-.app-shell.sidebar-collapsed {202- grid-template-columns: 0 minmax(0, 1fr);203-}204-205-.app-shell.sidebar-collapsed .sidebar {206- display: none;207-}208-209-.app-shell.sidebar-collapsed .topbar {210- grid-template-columns: auto minmax(0, 1fr) auto;211-}212-213-.sidebar {214- position: relative;215- z-index: 10;216- display: flex;217- grid-column: 1;218- grid-row: 2;219- min-height: 0;220- flex-direction: column;221- border-right: 1px solid var(--line);222- background:223- linear-gradient(180deg, rgba(214, 243, 107, 0.025), transparent 22%),224- var(--panel);225-}226-227-.sidebar-heading {228- padding: 25px 22px 18px;229-}230-231-.eyebrow {232- margin: 0 0 8px;233- color: var(--accent);234- font-size: 9px;235- font-weight: 800;236- letter-spacing: 0.2em;237-}238-239-.sidebar-heading h1 {240- display: -webkit-box;241- overflow: hidden;242- margin: 0;243- font-family: "Arial Narrow", "Roboto Condensed", sans-serif;244- font-size: 27px;245- font-weight: 700;246- letter-spacing: -0.025em;247- line-height: 1.05;248- -webkit-box-orient: vertical;249- -webkit-line-clamp: 2;250-}251-252-.sidebar-heading .map-name {253- overflow: hidden;254- margin: 8px 0 0;255- color: #cdd1c3;256- font-size: 14px;257- font-weight: 650;258- text-overflow: ellipsis;259- white-space: nowrap;260-}261-262-.sidebar-heading #map-meta {263- margin: 5px 0 0;264- color: var(--muted);265- font-size: 11px;266-}267-268-.search-wrap {269- position: relative;270- display: flex;271- align-items: center;272- margin: 0 17px 16px;273-}274-275-.search-wrap svg {276- position: absolute;277- left: 12px;278- width: 16px;279- fill: none;280- stroke: var(--muted);281- stroke-linecap: round;282- stroke-width: 1.7;283-}284-285-.search-wrap input {286- width: 100%;287- height: 42px;288- padding: 0 45px 0 37px;289- border: 1px solid var(--line);290- border-radius: 8px;291- outline: none;292- background: #11140f;293- color: var(--text);294- font-size: 13px;295-}296-297-.search-wrap input::placeholder {298- color: #757a6e;299-}300-301-.search-wrap input:focus {302- border-color: rgba(214, 243, 107, 0.5);303- box-shadow: 0 0 0 3px rgba(214, 243, 107, 0.06);304-}305-306-.search-wrap kbd {307- position: absolute;308- right: 9px;309- padding: 3px 5px;310- border: 1px solid var(--line);311- border-radius: 4px;312- background: var(--panel-raised);313- color: var(--muted);314- font-family: inherit;315- font-size: 9px;316-}317-318-.search-results {319- z-index: 5;320- overflow: auto;321- max-height: 238px;322- margin: -8px 17px 14px;323- border: 1px solid var(--line);324- border-radius: 8px;325- background: #11140f;326- box-shadow: 0 15px 35px rgba(0, 0, 0, 0.32);327-}328-329-.search-result {330- display: grid;331- width: 100%;332- grid-template-columns: 22px 1fr;333- gap: 10px;334- padding: 10px 11px;335- border: 0;336- border-bottom: 1px solid var(--line);337- background: transparent;338- text-align: left;339- cursor: pointer;340-}341-342-.search-result:last-child {343- border-bottom: 0;344-}345-346-.search-result:hover {347- background: rgba(255, 255, 255, 0.04);348-}349-350-.search-result .result-dot {351- display: grid;352- width: 20px;353- height: 20px;354- margin-top: 1px;355- place-items: center;356- border-radius: 50%;357- background: var(--pin-color);358- box-shadow: 0 0 0 3px color-mix(in srgb, var(--pin-color) 18%, transparent);359- color: #fff;360- font-size: 7px;361- font-weight: 900;362-}363-364-.search-result strong,365-.search-result small {366- display: block;367-}368-369-.search-result strong {370- overflow: hidden;371- font-size: 12px;372- text-overflow: ellipsis;373- white-space: nowrap;374-}375-376-.search-result small,377-.search-empty {378- margin-top: 3px;379- color: var(--muted);380- font-size: 10px;381-}382-383-.search-empty {384- padding: 13px;385-}386-387-.legend-toolbar {388- display: flex;389- align-items: center;390- justify-content: space-between;391- padding: 12px 20px;392- border-top: 1px solid var(--line);393- border-bottom: 1px solid var(--line);394- color: var(--muted);395- font-size: 9px;396- font-weight: 800;397- letter-spacing: 0.14em;398- text-transform: uppercase;399-}400-401-.legend-toolbar div {402- display: flex;403- gap: 5px;404- align-items: center;405-}406-407-.legend-actions {408- display: flex;409- align-items: center;410- gap: 2px;411-}412-413-.legend-actions-break {414- width: 1px;415- height: 12px;416- margin: 0 5px;417- background: var(--line);418-}419-420-.legend-action {421- display: grid;422- width: 22px;423- height: 22px;424- padding: 0;425- place-items: center;426- border: 0;427- border-radius: 3px;428- background: none;429- color: var(--muted);430- cursor: pointer;431-}432-433-.legend-action svg,434-.only-button svg {435- width: 14px;436- fill: none;437- stroke: currentColor;438- stroke-linecap: round;439- stroke-linejoin: round;440- stroke-width: 1.4;441-}442-443-.legend-action:hover {444- background: rgba(255, 255, 255, 0.06);445- color: var(--accent);446-}447-448-/* The name of a control arrives only once the pointer has settled on it, so a449- legend of icons stays learnable without the words being present all the time.450- It opens to the left because the list beside it scrolls and would clip451- anything that reached past its edge. */452-[data-label] {453- position: relative;454-}455-456-[data-label]::after {457- position: absolute;458- z-index: 12;459- top: 50%;460- right: calc(100% + 6px);461- padding: 4px 7px;462- border: 1px solid var(--line-strong);463- border-radius: 4px;464- opacity: 0;465- background: rgba(12, 14, 11, 0.97);466- box-shadow: 0 6px 18px rgba(0, 0, 0, 0.4);467- color: var(--text);468- content: attr(data-label);469- font-size: 10px;470- font-weight: 600;471- letter-spacing: 0;472- text-transform: none;473- transform: translateY(-50%);474- transition: opacity 90ms ease;475- pointer-events: none;476- white-space: nowrap;477-}478-479-[data-label]:hover::after,480-[data-label]:focus-visible::after {481- opacity: 1;482- transition-delay: 520ms;483-}484-485-.layers {486- overflow-x: hidden;487- overflow-y: auto;488- min-height: 0;489- flex: 1;490- padding-bottom: 12px;491- scrollbar-color: #44483e transparent;492- scrollbar-width: thin;493-}494-495-.layer-section {496- border-bottom: 1px solid var(--line);497-}498-499-.layer-section[hidden] {500- display: none;501-}502-503-.legend .layer-section:last-child {504- border-bottom: 0;505-}506-507-/* The trailing columns match a row's, so a group's isolate button sits directly508- above the ones belonging to its categories and its mark lines up with their509- counts. Rows are inset 14 by their container and 4 by themselves. */510-.layer-header {511- display: grid;512- align-items: center;513- grid-template-columns: minmax(0, 1fr) 22px 46px;514- gap: 8px;515- padding: 8px 18px 8px 12px;516-}517-518-.layer-title {519- display: flex;520- min-width: 0;521- flex: 1;522- align-items: center;523- gap: 7px;524- padding: 4px 0;525- border: 0;526- background: transparent;527- color: #c8ccbd;528- font-size: 10px;529- font-weight: 800;530- letter-spacing: 0.12em;531- text-align: left;532- text-transform: uppercase;533- cursor: pointer;534-}535-536-.layer-title:hover {537- color: var(--text);538-}539-540-.layer-title > span:nth-child(2) {541- overflow: hidden;542- text-overflow: ellipsis;543- white-space: nowrap;544-}545-546-.layer-chevron {547- display: grid;548- width: 13px;549- height: 13px;550- flex: none;551- place-items: center;552- color: #6b7163;553- transform: rotate(90deg);554- transition: transform 140ms ease;555-}556-557-.layer-section.is-collapsed .layer-chevron {558- transform: rotate(0deg);559-}560-561-.layer-chevron svg {562- width: 12px;563- fill: none;564- stroke: currentColor;565- stroke-linecap: round;566- stroke-linejoin: round;567- stroke-width: 2.4;568-}569-570-.layer-count {571- color: var(--muted);572- font-size: 9px;573- font-weight: 600;574- font-variant-numeric: tabular-nums;575- letter-spacing: 0;576-}577-578-/* Overlaid on the count so a hovered pill never changes size: these wrap, and579- a row that grew would push the one under the cursor out from under it. */580-/* An action in the row's own gutter, not a control laid over the count. The581- column is reserved whether or not it is showing, so a row never changes582- shape under the cursor. */583-.only-button {584- display: grid;585- justify-self: end;586- width: 20px;587- height: 20px;588- padding: 0;589- place-items: center;590- border: 0;591- border-radius: 3px;592- opacity: 0;593- background: none;594- color: var(--accent);595- cursor: pointer;596- transition: opacity 110ms ease;597-}598-599-/* Driven by the pointer's position rather than by :hover -- see markHoveredRow.600- Keyboard focus is unconditional. */601-.category-row.is-hovered .only-button,602-.layer-header.is-hovered .only-button,603-.only-button:focus-visible {604- opacity: 1;605-}606-607-.only-button:hover {608- background: rgba(214, 243, 107, 0.14);609-}610-611-.solo-chip {612- overflow: hidden;613- max-width: 160px;614- padding: 0;615- border: 0;616- background: none;617- color: var(--accent);618- font-size: 9px;619- font-weight: 700;620- letter-spacing: 0.06em;621- text-overflow: ellipsis;622- text-transform: uppercase;623- white-space: nowrap;624- cursor: pointer;625-}626-627-.solo-chip[hidden] {628- display: none;629-}630-631-.solo-chip::after {632- margin-left: 6px;633- content: "\00d7";634- opacity: 0.8;635-}636-637-.solo-chip:hover {638- text-decoration: underline;639- text-underline-offset: 2px;640-}641-642-/* The group's mark reads the same way as the marks in its rows: lit when the643- group is showing, hollow when it is not. */644-.layer-switch {645- position: relative;646- display: grid;647- justify-self: end;648- width: 15px;649- height: 15px;650- flex: none;651- place-items: center;652- cursor: pointer;653-}654-655-.layer-switch input {656- position: absolute;657- width: 1px;658- height: 1px;659- opacity: 0;660-}661-662-.layer-switch > span {663- width: 9px;664- height: 9px;665- border: 1px solid #6b7163;666- transition: background 140ms ease, border-color 140ms ease;667-}668-669-.layer-switch:hover > span {670- border-color: var(--accent);671-}672-673-.layer-switch:has(input:checked) > span {674- border-color: var(--accent);675- background: var(--accent);676-}677-678-.layer-switch:has(input:focus-visible) > span {679- outline: 1px solid var(--accent);680- outline-offset: 2px;681-}682-683-.layer-section.is-collapsed .category-toggles,684-.layer-section.is-collapsed .zone-list {685- display: none;686-}687-688-.text-symbol {689- display: grid;690- width: 22px;691- height: 22px;692- flex: none;693- place-items: center;694- color: var(--pin-color);695- font-family: "Arial Narrow", "Roboto Condensed", sans-serif;696- font-size: 11px;697- font-weight: 900;698- letter-spacing: -0.04em;699-}700-701-.zone-index-item {702- --zone-depth: 0;703- display: grid;704- width: 100%;705- align-items: center;706- grid-template-columns: 10px minmax(0, 1fr);707- gap: 8px;708- min-height: 26px;709- padding: 0 4px 0 calc(4px + var(--zone-depth) * 13px);710- border: 0;711- border-radius: 3px;712- background: transparent;713- color: #9aa093;714- font-size: 11px;715- font-weight: 600;716- text-align: left;717- cursor: pointer;718-}719-720-.zone-index-item:hover,721-.zone-index-item:focus-visible {722- outline: none;723- background: rgba(255, 255, 255, 0.04);724- color: var(--text);725-}726-727-.zone-index-item.is-current {728- background: rgba(255, 255, 255, 0.055);729- color: #f0f2e8;730-}731-732-.zone-index-item.is-highlighted {733- color: #fff;734-}735-736-#zone-index.has-highlights .zone-index-item:not(.is-highlighted):not(.is-current) {737- opacity: 0.5;738-}739-740-.zone-index-item > span:last-child {741- overflow: hidden;742- text-overflow: ellipsis;743- white-space: nowrap;744-}745-746-.zone-index-marker {747- width: 8px;748- height: 8px;749- border: 1px solid color-mix(in srgb, var(--zone-color) 78%, white);750- border-radius: 2px;751- background: color-mix(in srgb, var(--zone-color) 18%, transparent);752-}753-754-.zone-index-item.is-highlighted .zone-index-marker {755- border-color: #fff;756- background: var(--zone-color);757- box-shadow: 0 0 7px color-mix(in srgb, var(--zone-color) 65%, transparent);758-}759-760-/* A legend, not a row of buttons: symbols in a column, titles left, counts761- right in tabular figures so they read down the page. State is carried by762- the mark and the weight of the text, so nothing needs an outline to say it763- is interactive. */764-.category-toggles {765- padding: 2px 14px 10px;766-}767-768-.category-row {769- display: grid;770- width: 100%;771- align-items: center;772- grid-template-columns: 22px minmax(0, 1fr) 22px 46px;773- gap: 8px;774- min-height: 26px;775- padding: 0 4px;776- border-radius: 3px;777- color: #7d8275;778- cursor: pointer;779- user-select: none;780-}781-782-.category-row.is-hovered {783- background: rgba(255, 255, 255, 0.04);784- color: var(--text);785-}786-787-.category-row:has(input:checked) {788- color: #d8dccf;789-}790-791-.category-row input {792- position: absolute;793- width: 1px;794- height: 1px;795- opacity: 0;796-}797-798-.category-row:has(input:focus-visible) {799- outline: 1px solid var(--accent);800- outline-offset: -1px;801-}802-803-/* Unlit rather than absent: an unchecked category is still part of the key. */804-.category-row:not(:has(input:checked)) .category-icon,805-.category-row:not(:has(input:checked)) .text-symbol {806- opacity: 0.32;807-}808-809-.category-icon {810- display: grid;811- width: 22px;812- height: 22px;813- flex: none;814- place-items: center;815- border: 0;816- background: transparent;817- color: var(--pin-color);818- font-size: 9px;819- font-weight: 900;820- text-transform: uppercase;821-}822-823-.category-icon.has-source-icon::before,824-.result-dot.has-source-icon::before,825-#detail-dot.has-source-icon::before,826-.pin.has-source-icon::after {827- display: block;828- background: var(--pin-icon) center / contain no-repeat;829- content: "";830- filter: var(--icon-outset);831-}832-833-.category-icon.has-source-icon::before {834- width: 14px;835- height: 14px;836- filter: var(--icon-outset);837-}838-839-.result-dot.has-source-icon,840-#detail-dot.has-source-icon {841- border-radius: 0;842- background: transparent;843- box-shadow: none;844-}845-846-.result-dot.has-source-icon::before {847- width: 16px;848- height: 16px;849-}850-851-.category-name {852- overflow: hidden;853- font-size: 11px;854- font-weight: 600;855- text-overflow: ellipsis;856- white-space: nowrap;857-}858-859-.category-count {860- color: #6f7568;861- font-size: 10px;862- font-variant-numeric: tabular-nums;863- text-align: right;864-}865-866-.sidebar-footer {867- display: flex;868- align-items: center;869- gap: 7px;870- min-height: 44px;871- padding: 0 18px;872- border-top: 1px solid var(--line);873- color: var(--muted);874- font-size: 9px;875- letter-spacing: 0.06em;876- text-transform: uppercase;877-}878-879-.live-dot {880- width: 6px;881- height: 6px;882- border-radius: 50%;883- background: var(--accent);884- box-shadow: 0 0 7px rgba(214, 243, 107, 0.6);885-}886-887-.map-panel {888- position: relative;889- grid-column: 2;890- grid-row: 2;891- min-width: 0;892- min-height: 0;893- background: #0c0e0c;894-}895-896-.map {897- position: absolute;898- inset: 0;899- overflow: hidden;900- outline: none;901- background:902- radial-gradient(circle at 50% 50%, rgba(102, 111, 86, 0.13), transparent 56%),903- #0b0d0b;904- cursor: grab;905- touch-action: none;906- user-select: none;907-}908-909-.map .ol-viewport {910- position: absolute;911- inset: 0;912-}913-914-.map .ol-layer canvas {915- display: block;916-}917-918-.map .ol-viewport.is-dragging {919- cursor: grabbing;920-}921-922-.map::after {923- position: absolute;924- z-index: 2;925- inset: 0;926- background:927- linear-gradient(90deg, rgba(5, 7, 5, 0.36), transparent 7%, transparent 93%, rgba(5, 7, 5, 0.25)),928- linear-gradient(180deg, rgba(5, 7, 5, 0.2), transparent 10%, transparent 92%, rgba(5, 7, 5, 0.35));929- content: "";930- pointer-events: none;931-}932-933-.map-loading {934- position: absolute;935- z-index: 10;936- top: 50%;937- left: 50%;938- display: grid;939- min-width: 235px;940- padding: 24px;941- place-items: center;942- border: 1px solid var(--line);943- border-radius: 12px;944- background: rgba(20, 23, 19, 0.92);945- box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4);946- text-align: center;947- transform: translate(-50%, -50%);948- transition: opacity 180ms ease;949-}950-951-.map-loading[hidden] {952- display: none;953-}954-955-.map-loading strong {956- margin-top: 12px;957- font-size: 13px;958-}959-960-.map-loading small {961- margin-top: 5px;962- color: var(--muted);963- font-size: 10px;964-}965-966-.spinner {967- width: 25px;968- height: 25px;969- border: 2px solid rgba(214, 243, 107, 0.18);970- border-top-color: var(--accent);971- border-radius: 50%;972- animation: spin 0.75s linear infinite;973-}974-975-@keyframes spin {976- to { transform: rotate(360deg); }977-}978-979-/* The overview and the key share one corner, stacked, so neither has to guess980- how tall the other is. The column is only as wide as its widest child and981- passes clicks through, so the map stays draggable around them. */982-.map-corner {983- position: absolute;984- z-index: 7;985- right: 17px;986- bottom: 17px;987- display: flex;988- flex-direction: column;989- align-items: flex-end;990- gap: 10px;991- pointer-events: none;992-}993-994-.map-corner > * {995- pointer-events: auto;996-}997-998-/* The overview earns its corner while the reader is looking for where they are,999- and stops earning it the moment they are looking at what is underneath it. It1000- slides off to the right when put away, leaving the handle at the edge to1001- bring it back. */1002-.overview-shelf {1003- display: flex;1004- align-items: center;1005- transition: transform 220ms cubic-bezier(0.22, 0.61, 0.36, 1);1006-}1007-1008-.overview-shelf[hidden] {1009- display: none;1010-}1011-1012-.overview-shelf.is-docked {1013- transform: translateX(calc(100% - 23px));1014-}1015-1016-/* Put away is put away: what is left of the panel past the edge of the window1017- does not steer the map. */1018-.overview-shelf.is-docked .overview {1019- pointer-events: none;1020-}1021-1022-/* The handle is part of the panel it moves, not a control beside it: it shares1023- the panel's edge, and only the outer corners are rounded. */1024-.overview-dock {1025- display: grid;1026- width: 24px;1027- height: 52px;1028- padding: 0;1029- border: 1px solid var(--line-strong);1030- border-right: 0;1031- border-radius: 8px 0 0 8px;1032- margin-right: -1px;1033- place-items: center;1034- background: rgba(22, 25, 21, 0.9);1035- box-shadow: -5px 6px 20px rgba(0, 0, 0, 0.24);1036- color: var(--muted);1037- cursor: pointer;1038-}1039-1040-.overview-dock:hover {1041- color: var(--accent);1042-}1043-1044-.overview-dock svg {1045- width: 13px;1046- fill: none;1047- stroke: currentColor;1048- stroke-linecap: round;1049- stroke-linejoin: round;1050- stroke-width: 1.8;1051- transition: transform 220ms cubic-bezier(0.22, 0.61, 0.36, 1);1052-}1053-1054-.overview-shelf.is-docked .overview-dock svg {1055- transform: rotate(180deg);1056-}1057-1058-/* Only worth the space once the whole map no longer fits on screen, which is1059- why it is hidden until then rather than always present. */1060-.overview {1061- position: relative;1062- overflow: hidden;1063- border: 1px solid var(--line-strong);1064- border-radius: 8px;1065- background: rgba(22, 25, 21, 0.9);1066- box-shadow: 0 6px 25px rgba(0, 0, 0, 0.28);1067- cursor: crosshair;1068- line-height: 0;1069- /* The overview is dragged, so a touch on it steers the map rather than1070- scrolling whatever is behind it. */1071- touch-action: none;1072-}1073-1074-.overview[hidden] {1075- display: none;1076-}1077-1078-.overview canvas {1079- display: block;1080- opacity: 0.85;1081-}1082-1083-.overview-viewport {1084- position: absolute;1085- border: 1px solid var(--accent);1086- border-radius: 2px;1087- background: rgba(214, 243, 107, 0.14);1088- pointer-events: none;1089-}1090-1091-.zoom-controls {1092- position: absolute;1093- z-index: 7;1094- top: 17px;1095- right: 17px;1096- display: grid;1097- overflow: hidden;1098- width: 38px;1099- border: 1px solid var(--line-strong);1100- border-radius: 8px;1101- background: rgba(22, 25, 21, 0.9);1102- box-shadow: 0 6px 25px rgba(0, 0, 0, 0.22);1103-}1104-1105-.zoom-controls button {1106- display: grid;1107- width: 38px;1108- height: 37px;1109- padding: 0;1110- place-items: center;1111- border: 0;1112- border-bottom: 1px solid var(--line);1113- background: transparent;1114- font-size: 20px;1115- cursor: pointer;1116-}1117-1118-.zoom-controls button:last-child {1119- border-bottom: 0;1120-}1121-1122-.zoom-controls button:hover {1123- background: rgba(255, 255, 255, 0.06);1124- color: var(--accent);1125-}1126-1127-.grid-navigator {1128- position: absolute;1129- z-index: 8;1130- top: 17px;1131- right: 67px;1132- display: flex;1133- overflow: hidden;1134- align-items: stretch;1135- border: 1px solid var(--line-strong);1136- border-radius: 8px;1137- background: rgba(22, 25, 21, 0.94);1138- box-shadow: 0 6px 25px rgba(0, 0, 0, 0.22);1139-}1140-1141-.grid-navigator[hidden] {1142- display: none;1143-}1144-1145-.grid-navigator button {1146- width: 36px;1147- padding: 0;1148- border: 0;1149- border-right: 1px solid var(--line);1150- background: transparent;1151- color: var(--muted);1152- font-size: 17px;1153- cursor: pointer;1154-}1155-1156-.grid-navigator button:hover {1157- color: var(--accent);1158-}1159-1160-/* The subgrid toggle sits after the field it belongs to, so its rule divides it1161- from the field rather than trailing off the end of the control. */1162-.subgrid-toggle {1163- display: grid;1164- border-right: 0;1165- border-left: 1px solid var(--line);1166- place-items: center;1167-}1168-1169-.subgrid-toggle svg {1170- width: 15px;1171- fill: none;1172- stroke: currentColor;1173- stroke-linecap: round;1174- stroke-linejoin: round;1175- stroke-width: 1.3;1176-}1177-1178-.subgrid-toggle .subgrid-toggle-slash {1179- display: none;1180-}1181-1182-.subgrid-toggle[aria-pressed="false"] {1183- color: #6d7466;1184-}1185-1186-.subgrid-toggle[aria-pressed="false"] .subgrid-toggle-slash {1187- display: inline;1188- stroke: currentColor;1189- stroke-width: 1.6;1190-}1191-1192-.grid-navigator label {1193- display: flex;1194- height: 36px;1195- align-items: center;1196- gap: 7px;1197- padding: 0 9px;1198- color: var(--muted);1199- font-size: 8px;1200- font-weight: 800;1201- letter-spacing: 0.12em;1202- text-transform: uppercase;1203-}1204-1205-.grid-navigator input {1206- width: 74px;1207- padding: 4px 6px;1208- border: 1px solid #3c4137;1209- border-radius: 4px;1210- outline: none;1211- background: #0e110d;1212- color: var(--accent);1213- font-family: ui-monospace, SFMono-Regular, Menlo, monospace;1214- font-size: 12px;1215- font-weight: 700;1216- letter-spacing: 0.08em;1217- text-transform: lowercase;1218- -webkit-user-select: text;1219- user-select: text;1220-}1221-1222-.grid-navigator input:focus {1223- border-color: rgba(214, 243, 107, 0.68);1224-}1225-1226-.map-hint {1227- position: relative;1228- display: flex;1229- align-items: center;1230- gap: 8px;1231- padding: 7px 10px;1232- border: 1px solid var(--line);1233- border-radius: 6px;1234- background: rgba(15, 17, 14, 0.76);1235- color: rgba(238, 240, 228, 0.62);1236- font-size: 9px;1237- letter-spacing: 0.08em;1238- text-transform: uppercase;1239- backdrop-filter: blur(8px);1240-}1241-1242-.map-hint i {1243- width: 2px;1244- height: 2px;1245- border-radius: 50%;1246- background: currentColor;1247-}1248-1249-.pin-detail {1250- position: absolute;1251- z-index: 9;1252- right: 68px;1253- bottom: 17px;1254- width: min(360px, calc(100% - 100px));1255- max-height: min(500px, calc(100% - 40px));1256- overflow: auto;1257- padding: 20px;1258- border: 1px solid var(--line-strong);1259- border-radius: 11px;1260- background: rgba(21, 24, 20, 0.96);1261- box-shadow: 0 18px 55px rgba(0, 0, 0, 0.45);1262- -webkit-user-select: text;1263- user-select: text;1264- backdrop-filter: blur(14px);1265-}1266-1267-.pin-detail[hidden] {1268- display: none;1269-}1270-1271-.detail-close {1272- position: absolute;1273- top: 10px;1274- right: 11px;1275- width: 29px;1276- height: 29px;1277- padding: 0;1278- border: 0;1279- border-radius: 6px;1280- background: rgba(255, 255, 255, 0.04);1281- color: var(--muted);1282- font-size: 21px;1283- cursor: pointer;1284-}1285-1286-.detail-close:hover {1287- color: var(--text);1288-}1289-1290-.detail-category {1291- display: flex;1292- align-items: center;1293- gap: 7px;1294- padding-right: 30px;1295- color: var(--muted);1296- font-size: 9px;1297- font-weight: 800;1298- letter-spacing: 0.12em;1299- text-transform: uppercase;1300-}1301-1302-.detail-category #detail-dot {1303- display: grid;1304- width: 20px;1305- height: 20px;1306- flex: 0 0 20px;1307- place-items: center;1308- border-radius: 50%;1309- background: var(--pin-color);1310- color: #fff;1311- font-size: 7px;1312- letter-spacing: 0;1313-}1314-1315-#detail-dot.has-source-icon::before {1316- width: 16px;1317- height: 16px;1318-}1319-1320-.pin-detail h2 {1321- margin: 10px 0 11px;1322- font-family: "Arial Narrow", "Roboto Condensed", sans-serif;1323- font-size: 22px;1324- line-height: 1.12;1325-}1326-1327-.pin-detail > p {1328- margin: 0;1329- color: #b9bdb0;1330- font-size: 12px;1331- line-height: 1.55;1332- white-space: pre-line;1333-}1334-1335-.detail-links {1336- display: flex;1337- flex-wrap: wrap;1338- gap: 4px 14px;1339- margin-top: 12px;1340-}1341-1342-.detail-links[hidden] {1343- display: none;1344-}1345-1346-.detail-link {1347- overflow: hidden;1348- max-width: 100%;1349- padding: 0;1350- border: 0;1351- background: none;1352- color: var(--accent);1353- font-size: 11px;1354- font-weight: 600;1355- text-decoration: underline;1356- text-overflow: ellipsis;1357- text-underline-offset: 3px;1358- white-space: nowrap;1359- cursor: pointer;1360-}1361-1362-.detail-link:hover {1363- color: var(--text);1364-}1365-1366-.pin-detail dl {1367- display: grid;1368- grid-template-columns: 1fr 1fr;1369- gap: 8px;1370- margin: 17px 0 0;1371- padding-top: 13px;1372- border-top: 1px solid var(--line);1373-}1374-1375-.pin-detail dl div {1376- min-width: 0;1377-}1378-1379-.pin-detail dt {1380- color: #71766a;1381- font-size: 8px;1382- font-weight: 800;1383- letter-spacing: 0.1em;1384- text-transform: uppercase;1385-}1386-1387-.pin-detail dd {1388- overflow: hidden;1389- margin: 4px 0 0;1390- color: #c6cabd;1391- font-family: ui-monospace, SFMono-Regular, Menlo, monospace;1392- font-size: 9px;1393- text-overflow: ellipsis;1394- white-space: nowrap;1395-}1396-1397-.fatal-error {1398- position: fixed;1399- z-index: 100;1400- inset: 50% auto auto 50%;1401- width: min(460px, calc(100% - 40px));1402- padding: 24px;1403- border: 1px solid #7e3f3f;1404- border-radius: 12px;1405- background: #261919;1406- box-shadow: 0 25px 80px rgba(0, 0, 0, 0.5);1407- transform: translate(-50%, -50%);1408- -webkit-user-select: text;1409- user-select: text;1410-}1411-1412-.fatal-error[hidden] {1413- display: none;1414-}1415-1416-.fatal-error p {1417- margin: 8px 0 0;1418- color: #c8aaaa;1419- font-size: 13px;1420-}1421-1422-@media (max-width: 980px) {1423- :root {1424- --sidebar: 300px;1425- }1426-1427- .map-pickers label > span {1428- display: none;1429- }1430-1431- .map-pickers select {1432- max-width: 190px;1433- }1434-}1435-1436-@media (max-width: 760px) {1437- :root {1438- --topbar: 64px;1439- }1440-1441- .app-shell {1442- grid-template-columns: 1fr;1443- }1444-1445- .topbar {1446- grid-template-columns: auto minmax(0, 1fr) auto;1447- }1448-1449- .brand {1450- padding: 0 15px;1451- border-right: 0;1452- }1453-1454- .brand small {1455- display: none;1456- }1457-1458- .map-pickers {1459- justify-content: center;1460- padding: 0 7px;1461- }1462-1463- .map-pickers select {1464- max-width: 135px;1465- height: 35px;1466- padding-left: 8px;1467- font-size: 11px;1468- }1469-1470- .mobile-legend {1471- display: grid;1472- }1473-1474- .sidebar {1475- position: fixed;1476- z-index: 30;1477- top: var(--topbar);1478- bottom: 0;1479- left: 0;1480- width: min(330px, calc(100% - 42px));1481- box-shadow: 18px 0 50px rgba(0, 0, 0, 0.45);1482- transform: translateX(-102%);1483- transition: transform 180ms ease;1484- }1485-1486- .sidebar.is-open {1487- transform: translateX(0);1488- }1489-1490- .map-panel {1491- grid-column: 1;1492- }1493-1494- .pin-detail {1495- right: 14px;1496- bottom: 55px;1497- width: calc(100% - 28px);1498- }1499-1500-}1+@import "./css/tokens.css";2+@import "./css/base.css";3+@import "./css/shell.css";4+@import "./css/topbar.css";5+@import "./css/brand.css";6+@import "./css/map-pickers.css";7+@import "./css/icon-button.css";8+@import "./css/topbar-collapse.css";9+@import "./css/sidebar.css";10+@import "./css/sidebar-heading.css";11+@import "./css/search.css";12+@import "./css/legend-toolbar.css";13+@import "./css/tooltip.css";14+@import "./css/layers.css";15+@import "./css/layer-header.css";16+@import "./css/solo-chip.css";17+@import "./css/layer-switch.css";18+@import "./css/text-symbol.css";19+@import "./css/zone-index.css";20+@import "./css/category-rows.css";21+@import "./css/sidebar-footer.css";22+@import "./css/map-panel.css";23+@import "./css/map-loading.css";24+@import "./css/map-corner.css";25+@import "./css/overview.css";26+@import "./css/zoom-controls.css";27+@import "./css/grid-navigator.css";28+@import "./css/map-hint.css";29+@import "./css/pin-detail.css";30+@import "./css/fatal-error.css";31+@import "./css/responsive.css";
M frontend/app.js +1 -2823
@@ -3,2828 +3,6 @@ import "./app.css";
33 44 import "./parity/tour.js";55 6-import Feature from "ol/Feature.js";7-import OLMap from "ol/Map.js";8-import View from "ol/View.js";9-import { defaults as defaultControls } from "ol/control/defaults.js";10-import { createEmpty, extend, getCenter } from "ol/extent.js";11-import Point from "ol/geom/Point.js";12-import MultiPolygon from "ol/geom/MultiPolygon.js";13-import Polygon from "ol/geom/Polygon.js";14-import { defaults as defaultInteractions } from "ol/interaction/defaults.js";15-import TileLayer from "ol/layer/Tile.js";16-import VectorLayer from "ol/layer/Vector.js";17-import Projection from "ol/proj/Projection.js";18-import VectorSource from "ol/source/Vector.js";19-import XYZ from "ol/source/XYZ.js";20-import {21- Fill,22- Icon,23- Stroke,24- Style,25- Text,26-} from "ol/style.js";27-import TileGrid from "ol/tilegrid/TileGrid.js";28-29-const $ = (selector) => document.querySelector(selector);30-const elements = {31- game: $("#game-select"),32- map: $("#map-select"),33- variant: $("#variant-select"),34- variantField: $("#variant-field"),35- gameTitle: $("#game-title"),36- title: $("#map-title"),37- meta: $("#map-meta"),38- legend: $("#legend"),39- search: $("#pin-search"),40- searchResults: $("#search-results"),41- visibleCount: $("#visible-count"),42- viewport: $("#map"),43- layers: $("#layers"),44- zoneToggle: $("#zone-toggle"),45- zoneCount: $("#zone-count"),46- zoneIndex: $("#zone-index"),47- zoneList: $("#zone-list"),48- loading: $("#map-loading"),49- labelsHint: $("#labels-hint"),50- gridHint: $("#grid-hint"),51- soloChip: $("#solo-chip"),52- overview: $("#overview"),53- overviewShelf: $("#overview-shelf"),54- overviewDock: $("#overview-dock"),55- overviewCanvas: $("#overview-canvas"),56- overviewViewport: $("#overview-viewport"),57- gridNavigator: $("#grid-navigator"),58- gridInput: $("#grid-input"),59- gridBack: $("#grid-back"),60- subgridToggle: $("#subgrid-toggle"),61- detail: $("#pin-detail"),62- detailTitle: $("#detail-title"),63- detailCategory: $("#detail-category"),64- detailDescription: $("#detail-description"),65- detailID: $("#detail-id"),66- detailCoordinates: $("#detail-coordinates"),67- detailLinks: $("#detail-links"),68- detailDot: $("#detail-dot"),69- sidebar: $("#sidebar"),70- mobileLegend: $("#mobile-legend"),71- fatal: $("#fatal-error"),72- fatalMessage: $("#fatal-message"),73-};74-75-const palette = [76- "#d6f36b", "#72d5f4", "#ff9e64", "#df83ff", "#62e6ae",77- "#ff6f91", "#f4d35e", "#8aa9ff", "#e7a56d", "#83d483",78-];79-80-const geohashAlphabet = "0123456789bcdefghjkmnpqrstuvwxyz";81-const geohashMaxDepth = 3;82-const overzoomLevels = 2;83-84-const state = {85- catalog: null,86- game: null,87- map: null,88- variant: null,89- engine: null,90- projection: null,91- layers: null,92- sources: null,93- hiddenCategories: new Set(),94- collapsedSections: new Set(),95- pins: [],96- pinByID: new Map(),97- selectedPin: null,98- hoveredPin: null,99- pinLabelsVisible: false,100- gridEnabled: false,101- // Whether the cells are drawn, which is a separate question from whether one102- // of them is holding the map to a place.103- subgridVisible: true,104- gridPrefix: "",105- zonesVisible: true,106- zoneRecords: new Map(),107- highlightedZones: new Set(),108- focusedZoneID: null,109- search: "",110- fitZoom: 0,111- zoneTitleCount: 0,112- eligibleLocations: 0,113- tileRun: 0,114- tileStats: { requested: 0, loaded: 0, errors: 0, peakPending: 0 },115- overviewRun: 0,116- overviewKey: "",117- overviewPointer: null,118- overviewDocked: false,119- renderedShard: 0,120- mapRun: 0,121- textByMap: new Map(),122- restore: null,123- settling: false,124- styleCache: new Map(),125- markerIcons: new Map(),126-};127-128-async function start() {129- bindUIEvents();130- try {131- const response = await fetch("/static/catalog.json");132- if (!response.ok) throw new Error(`catalog request returned ${response.status}`);133- state.catalog = await response.json();134- if (!state.catalog.games.length) throw new Error("the embedded catalog contains no maps");135- initializeMap();136- populateSelect(elements.game, state.catalog.games, "title");137- const route = readRoute();138- const session = readSession();139- // An address naming somewhere else was typed on purpose, so it wins and140- // arrives clean; anything else resumes where the reader left off.141- const resuming = session &&142- (!route.game || (route.game === session.game && route.map === session.map));143- state.restore = resuming ? session : null;144- await selectGame(145- route.game || session?.game || state.catalog.games[0].slug,146- route.map || session?.map,147- );148- state.restore = null;149- exposeDiagnostics();150- requestAnimationFrame(() => elements.viewport.focus({ preventScroll: true }));151- } catch (error) {152- elements.loading.hidden = true;153- elements.fatalMessage.textContent = error instanceof Error ? error.message : String(error);154- elements.fatal.hidden = false;155- }156-}157-158-// A vector layer left to itself stretches the last frame it drew through an159-// animation, which leaves markers the wrong size mid-zoom and blank ground160-// wherever a pan lands. These are all drawn afresh each frame instead, so a161-// view that is being steered shows what it is passing over.162-function eagerVector(options) {163- return new VectorLayer({ updateWhileAnimating: true, ...options });164-}165-166-function initializeMap() {167- const size = state.catalog.tileGrid.size;168- const worldExtent = [0, -size, size, 0];169- state.projection = new Projection({170- code: "ATLAS:PIXELS",171- units: "pixels",172- extent: worldExtent,173- });174- state.sources = {175- grid: new VectorSource({ wrapX: false }),176- gridContext: new VectorSource({ wrapX: false }),177- zoneScrim: new VectorSource({ wrapX: false }),178- zones: new VectorSource({ wrapX: false }),179- zoneTitles: new VectorSource({ wrapX: false }),180- text: new VectorSource({ wrapX: false }),181- pins: new VectorSource({ wrapX: false }),182- priority: new VectorSource({ wrapX: false }),183- };184- state.layers = {185- raster: new TileLayer({ zIndex: 0 }),186- // Levels above the complete one are only captured in patches. They ride on187- // top of the base layer so the fully-covered pyramid still shows through188- // wherever the deep capture has a gap.189- rasterDetail: new TileLayer({ zIndex: 1 }),190- grid: eagerVector({191- source: state.sources.grid,192- style: gridStyle,193- renderOrder: featureOrder,194- renderBuffer: 40,195- zIndex: 5,196- }),197- // Under the zones and over the map: the dimming is something the map is198- // seen through, not something drawn on top of the zone that was asked for.199- zoneScrim: eagerVector({200- source: state.sources.zoneScrim,201- style: zoneScrimStyle,202- zIndex: 6,203- }),204- zones: eagerVector({205- source: state.sources.zones,206- style: zoneStyle,207- renderBuffer: 32,208- zIndex: 10,209- }),210- zoneTitles: eagerVector({211- source: state.sources.zoneTitles,212- style: zoneTitleStyle,213- renderOrder: featureOrder,214- renderBuffer: 160,215- zIndex: 20,216- }),217- zoneTitleDetail: eagerVector({218- source: state.sources.zoneTitles,219- style: zoneTitleDetailStyle,220- renderOrder: featureOrder,221- renderBuffer: 160,222- zIndex: 44,223- }),224- text: eagerVector({225- source: state.sources.text,226- style: textFeatureStyle,227- renderOrder: featureOrder,228- renderBuffer: 220,229- zIndex: 30,230- }),231- textDetail: eagerVector({232- source: state.sources.text,233- style: textDetailFeatureStyle,234- renderOrder: featureOrder,235- renderBuffer: 220,236- zIndex: 45,237- }),238- zoneText: eagerVector({239- source: state.sources.text,240- style: zoneTextFeatureStyle,241- renderOrder: featureOrder,242- renderBuffer: 220,243- zIndex: 41,244- }),245- // Nothing is decluttered. Dropping whatever overlaps makes a crowded area246- // quietly show less than it holds, for text labels as much as for markers;247- // zooming in to separate them is the reader's job.248- pins: eagerVector({249- source: state.sources.pins,250- style: pinFeatureStyle,251- renderOrder: featureOrder,252- renderBuffer: 48,253- zIndex: 40,254- }),255- zonePins: eagerVector({256- source: state.sources.pins,257- style: zonePinFeatureStyle,258- renderOrder: featureOrder,259- renderBuffer: 48,260- zIndex: 42,261- }),262- pinLabels: eagerVector({263- source: state.sources.pins,264- style: pinLabelFeatureStyle,265- renderOrder: featureOrder,266- renderBuffer: 180,267- zIndex: 45,268- }),269- gridContext: eagerVector({270- source: state.sources.gridContext,271- style: gridStyle,272- renderOrder: featureOrder,273- renderBuffer: 40,274- zIndex: 48,275- }),276- priority: eagerVector({277- source: state.sources.priority,278- style: priorityFeatureStyle,279- renderOrder: featureOrder,280- renderBuffer: 220,281- zIndex: 50,282- }),283- };284- state.engine = new OLMap({285- target: elements.viewport,286- layers: Object.values(state.layers),287- controls: defaultControls({288- attribution: false,289- rotate: false,290- zoom: false,291- }),292- interactions: defaultInteractions({293- onFocusOnly: false,294- }),295- view: createView(5),296- });297-298- state.engine.on("movestart", () => {299- state.engine.getViewport().classList.add("is-dragging");300- });301- state.engine.on("moveend", () => {302- state.engine.getViewport().classList.remove("is-dragging");303- // A view set straight to a new centre has arrived by the next frame, so a304- // sweep across the overview finishes its journey many times over. Counting305- // the pins in view and writing the session down are worth doing once the306- // hand steering it comes to rest, which is what settleView is for.307- if (state.overviewPointer !== null) return;308- settleView();309- });310- // The locator follows the view as it moves rather than only once it settles.311- // Repeated calls that would draw the same rectangle cost nothing.312- state.engine.on("postrender", updateOverviewViewport);313- // OpenLayers can condition wheel handling on focus when its target is314- // keyboard-focusable. Refocus during the wheel's capture phase so returning315- // from any sidebar control never costs a discarded scroll gesture.316- elements.viewport.addEventListener("wheel", () => {317- if (document.activeElement !== elements.viewport) {318- elements.viewport.focus({ preventScroll: true });319- }320- }, { capture: true, passive: true });321- state.engine.on("singleclick", (event) => {322- if (state.gridEnabled) {323- const cell = state.engine.forEachFeatureAtPixel(324- event.pixel,325- // The cell the reader is already in lies over its own children, and326- // answering for them would mean the grid could not be descended.327- (feature) => {328- const under = feature.get("gridCell");329- return under && under.role !== "leaf" && under.role !== "scope" ? under : null;330- },331- {332- hitTolerance: 1,333- layerFilter: (layer) =>334- layer === state.layers.grid || layer === state.layers.gridContext,335- },336- );337- if (cell) {338- selectGridPrefix(cell.hash);339- return;340- }341- }342- const pin = state.engine.forEachFeatureAtPixel(343- event.pixel,344- (feature, layer) => (isAnnotationLayer(layer) && feature.get("pin")) || null,345- { hitTolerance: 5, layerFilter: isAnnotationLayer },346- );347- if (pin) showPin(pin);348- });349- state.engine.on("pointermove", (event) => {350- if (event.dragging) {351- setHoveredPin(null);352- return;353- }354- const hit = state.engine.forEachFeatureAtPixel(355- event.pixel,356- (feature, layer) => (isAnnotationLayer(layer) && feature.get("pin")) || null,357- { hitTolerance: 4, layerFilter: isAnnotationLayer },358- );359- const hovered = hit?.category.displayType === "text" ? null : hit;360- setHoveredPin(hovered || null);361- const gridHit = state.gridEnabled && state.engine.hasFeatureAtPixel(event.pixel, {362- layerFilter: (layer) =>363- layer === state.layers.grid || layer === state.layers.gridContext,364- });365- state.engine.getTargetElement().style.cursor = hit || gridHit ? "pointer" : "";366- });367- state.engine.getViewport().addEventListener("pointerleave", () => setHoveredPin(null));368-}369-370-// Every layer a pin can be drawn in, including the two it moves to while a zone371-// is highlighted. Leaving those out left the pins of the highlighted zone --372-// the only ones still on screen -- answering neither the pointer nor a click.373-function isAnnotationLayer(layer) {374- return layer === state.layers.pins || layer === state.layers.zonePins ||375- layer === state.layers.pinLabels || layer === state.layers.priority ||376- layer === state.layers.text || layer === state.layers.textDetail ||377- layer === state.layers.zoneText;378-}379-380-function createView(maxZoom) {381- const size = state.catalog.tileGrid.size;382- return new View({383- projection: state.projection,384- center: [size / 2, -size / 2],385- resolutions: resolutions(maxZoom),386- minZoom: 0,387- maxZoom,388- extent: [0, -size, size, 0],389- constrainResolution: false,390- smoothResolutionConstraint: false,391- showFullExtent: true,392- zoom: 0,393- });394-}395-396-function bindUIEvents() {397- elements.game.addEventListener("change", () => { void selectGame(elements.game.value); });398- elements.map.addEventListener("change", () => { void selectMap(Number(elements.map.value)); });399- elements.variant.addEventListener("change", () => selectVariant(Number(elements.variant.value)));400-401- elements.legend.addEventListener("change", (event) => {402- const input = event.target;403- if (input.dataset.sectionToggle) {404- toggleSection(input.dataset.sectionToggle);405- return;406- }407- if (!input.dataset.category) return;408- const categoryID = Number(input.dataset.category);409- if (input.checked) state.hiddenCategories.delete(categoryID);410- else state.hiddenCategories.add(categoryID);411- applyPinFilters();412- syncSectionSwitches();413- });414-415- // Which row the pointer is over is worked out from where the pointer is,416- // rather than read from :hover. Scrolling moves the list under a still417- // cursor, and the browser does not always revise :hover when it does -- so a418- // row kept offering an action to a pointer that had long since left it.419- // Recomputing on scroll settles it, because the answer comes from the420- // pointer's actual position either way.421- let pointerAt = null;422- const markHoveredRow = () => {423- for (const marked of elements.layers.querySelectorAll(".is-hovered")) {424- marked.classList.remove("is-hovered");425- }426- if (!pointerAt) return;427- const under = document.elementFromPoint(pointerAt.x, pointerAt.y);428- const row = under?.closest(".category-row, .layer-header");429- if (row && elements.layers.contains(row)) row.classList.add("is-hovered");430- };431- elements.layers.addEventListener("pointermove", (event) => {432- pointerAt = { x: event.clientX, y: event.clientY };433- markHoveredRow();434- }, { passive: true });435- elements.layers.addEventListener("pointerleave", () => {436- pointerAt = null;437- markHoveredRow();438- });439- elements.layers.addEventListener("scroll", markHoveredRow, { passive: true });440-441- elements.layers.addEventListener("click", (event) => {442- const only = event.target.closest("[data-only-category], [data-only-section]");443- if (only) {444- // The button sits inside the row's label, whose default action would445- // otherwise toggle the very checkbox this is meant to override.446- event.preventDefault();447- event.stopPropagation();448- showOnly(only.dataset.onlyCategory449- ? { category: Number(only.dataset.onlyCategory) }450- : { section: only.dataset.onlySection });451- return;452- }453- const button = event.target.closest("[data-section]");454- if (!button) return;455- const key = button.dataset.section;456- if (state.collapsedSections.has(key)) state.collapsedSections.delete(key);457- else state.collapsedSections.add(key);458- syncSectionCollapse();459- });460-461- elements.soloChip.addEventListener("click", () => setAllCategories(true));462- $("#expand-all").addEventListener("click", () => setAllSectionsCollapsed(false));463- $("#collapse-all").addEventListener("click", () => setAllSectionsCollapsed(true));464- $("#show-all").addEventListener("click", () => setAllCategories(true));465- $("#hide-all").addEventListener("click", () => setAllCategories(false));466- elements.zoneToggle.addEventListener("change", () => {467- setZonesVisible(elements.zoneToggle.checked);468- });469- elements.zoneIndex.addEventListener("click", (event) => {470- const button = event.target.closest("[data-zone]");471- if (!button) return;472- jumpToZone(Number(button.dataset.zone));473- });474- elements.zoneIndex.addEventListener("contextmenu", (event) => {475- const button = event.target.closest("[data-zone]");476- if (!button) return;477- event.preventDefault();478- toggleZoneHighlight(Number(button.dataset.zone));479- });480- elements.search.addEventListener("input", () => {481- state.search = elements.search.value.trim().toLocaleLowerCase();482- applyPinFilters();483- renderSearchResults();484- });485- elements.searchResults.addEventListener("click", (event) => {486- const result = event.target.closest("[data-location]");487- if (!result) return;488- const pin = state.pinByID.get(Number(result.dataset.location));489- if (pin) revealPin(pin);490- });491-492- elements.detailLinks.addEventListener("click", (event) => {493- const button = event.target.closest("[data-location]");494- if (!button) return;495- const pin = state.pinByID.get(Number(button.dataset.location));496- if (pin) revealPin(pin);497- });498-499- $("#close-detail").addEventListener("click", closeDetail);500- $("#zoom-in").addEventListener("click", () => changeZoom(1));501- $("#zoom-out").addEventListener("click", () => changeZoom(-1));502- elements.gridBack.addEventListener("click", ascendGrid);503- elements.gridInput.addEventListener("input", () => {504- const maximum = gridMaxDepth();505- const value = [...elements.gridInput.value.toLocaleLowerCase()]506- .filter((character) => geohashAlphabet.includes(character))507- .slice(0, maximum)508- .join("");509- elements.gridInput.value = value;510- selectGridPrefix(value);511- });512- elements.subgridToggle.addEventListener("click", () => {513- setSubgridVisible(!state.subgridVisible);514- elements.viewport.focus({ preventScroll: true });515- });516- // Escape leaves the field before it leaves the level: the first press hands517- // the keyboard back to the map, and the next one telescopes out as ever.518- // Space reaches the subgrid from inside the field too, since a hash has no519- // spaces in it and clearing the mesh is what is most wanted while typing one.520- elements.gridInput.addEventListener("keydown", (event) => {521- if (event.key === " ") {522- event.preventDefault();523- setSubgridVisible(!state.subgridVisible);524- return;525- }526- if (event.key !== "Escape") return;527- event.preventDefault();528- event.stopPropagation();529- elements.viewport.focus({ preventScroll: true });530- });531-532- elements.viewport.addEventListener("keydown", (event) => {533- if (isEditableTarget(event.target)) return;534- if (event.key === "+" || event.key === "=") changeZoom(1);535- else if (event.key === "-") changeZoom(-1);536- else if (event.key === "Escape") closeDetail();537- else return;538- event.preventDefault();539- });540- // The webview's own menu offers Reload and Inspect Element, which belong to a541- // browser rather than to a map. Text fields keep theirs, where cut and paste542- // are worth having.543- window.addEventListener("contextmenu", (event) => {544- if (isEditableTarget(event.target)) return;545- event.preventDefault();546- });547-548- window.addEventListener("keydown", (event) => {549- // Reload keeps its usual shortcut now that the menu offering it is gone.550- // The session is restored on the way back, so the view returns as it was.551- if ((event.metaKey || event.ctrlKey) && event.key.toLocaleLowerCase() === "r") {552- event.preventDefault();553- location.reload();554- return;555- }556- if (isEditableTarget(event.target)) return;557- if ((event.metaKey || event.ctrlKey) && event.key.toLocaleLowerCase() === "k") {558- event.preventDefault();559- elements.search.focus();560- elements.search.select();561- return;562- }563- // ⌘B on a Mac, Ctrl+B elsewhere: the usual shortcut for putting a sidebar564- // away, and the map is the reason the window is open.565- if ((event.metaKey || event.ctrlKey) && event.key.toLocaleLowerCase() === "b") {566- event.preventDefault();567- toggleSidebar();568- return;569- }570- if (handleGridKey(event)) return;571- if (event.key.toLocaleLowerCase() === "z") {572- event.preventDefault();573- state.pinLabelsVisible = !state.pinLabelsVisible;574- elements.labelsHint.textContent = `Z · labels ${state.pinLabelsVisible ? "on" : "off"}`;575- state.layers.pinLabels.changed();576- }577- });578- window.addEventListener("hashchange", () => {579- const route = readRoute();580- if (route.game === state.game?.slug && route.map === state.map?.slug) return;581- // An address typed by hand names where to go, so it overrides what the582- // game remembers.583- state.restore = null;584- void selectGame(route.game || state.catalog.games[0].slug, route.map);585- });586- window.addEventListener("resize", () => {587- state.engine?.updateSize();588- updateOverviewViewport();589- });590- // Holding the pointer down steers the map: a reader crossing the world drags591- // the locator there in one sweep instead of clicking their way across it.592- // Capturing the pointer keeps the sweep alive past the edge of the overview,593- // where the destination is simply the nearest point still on the map.594- elements.overview.addEventListener("pointerdown", (event) => {595- if (state.overviewDocked) return;596- if (event.pointerType === "mouse" && event.button !== 0) return;597- event.preventDefault();598- elements.overview.setPointerCapture(event.pointerId);599- state.overviewPointer = event.pointerId;600- overviewNavigate(event, true);601- });602- elements.overview.addEventListener("pointermove", (event) => {603- if (state.overviewPointer !== event.pointerId) return;604- event.preventDefault();605- overviewNavigate(event, false);606- });607- const releaseOverview = (event) => {608- if (state.overviewPointer !== event.pointerId) return;609- state.overviewPointer = null;610- settleView();611- };612- elements.overview.addEventListener("pointerup", releaseOverview);613- elements.overview.addEventListener("pointercancel", releaseOverview);614- elements.overviewDock.addEventListener("click", () => {615- setOverviewDocked(!state.overviewDocked);616- elements.viewport.focus({ preventScroll: true });617- });618- elements.mobileLegend.addEventListener("click", () => {619- const open = elements.sidebar.classList.toggle("is-open");620- elements.mobileLegend.setAttribute("aria-expanded", String(open));621- });622-}623-624-// A map arrives in two pieces: its layers, categories and regions as JSON, and625-// its locations packed as parallel arrays. Nothing here is fetched until the626-// map is opened, so the catalog can grow without the wait growing with it.627-async function loadMap(entry) {628- const [detail, packed] = await Promise.all([629- fetch(`/static/catalog/${entry.id}.json`).then((r) => r.json()),630- fetch(`/static/catalog/${entry.id}.bin`).then((r) => r.arrayBuffer()),631- ]);632- const categories = detail.groups.flatMap((group) => group.categories);633- unpackLocations(packed, categories);634- return {635- ...entry,636- variants: detail.variants,637- groups: detail.groups,638- zones: detail.zones || [],639- sections: legendSections(detail.groups),640- };641-}642-643-// The reader of packLocations. Each field is a view straight onto the buffer,644-// laid out so no copying or realignment is needed to get at it.645-function unpackLocations(buffer, categories) {646- const view = new DataView(buffer);647- const magic = String.fromCharCode(...new Uint8Array(buffer, 0, 8));648- if (magic !== "ATLASLOC") throw new Error("location payload is not in the expected form");649- const version = view.getUint16(8, true);650- if (version !== 2) throw new Error(`location payload is version ${version}, and this reads 2`);651- const count = view.getUint32(10, true);652-653- let at = 16;654- const ids = new Int32Array(buffer, at, count);655- const latitudes = new Float32Array(buffer, (at += count * 4), count);656- const longitudes = new Float32Array(buffer, (at += count * 4), count);657- const regions = new Int32Array(buffer, (at += count * 4), count);658- const shards = new Int32Array(buffer, (at += count * 4), count);659- const offsets = new Uint32Array(buffer, (at += count * 4), count + 1);660- const owners = new Uint16Array(buffer, (at += (count + 1) * 4), count);661- const titles = new Uint8Array(buffer, at + count * 2);662-663- const decoder = new TextDecoder();664- for (const category of categories) category.locations = [];665- for (let index = 0; index < count; index++) {666- categories[owners[index]].locations.push({667- id: ids[index],668- title: decoder.decode(titles.subarray(offsets[index], offsets[index + 1])),669- lat: latitudes[index],670- lng: longitudes[index],671- regionId: regions[index] || undefined,672- shard: shards[index] || undefined,673- });674- }675-}676-677-// Descriptions and cross-references are half the catalog by weight and are read678-// one pin at a time, so a map's are fetched the first time one of its pins is679-// opened, and not at all if none ever is.680-async function mapText(mapID) {681- if (!state.textByMap.has(mapID)) {682- state.textByMap.set(683- mapID,684- fetch(`/static/catalog/${mapID}.text`).then((r) => r.json()).catch(() => ({})),685- );686- }687- return state.textByMap.get(mapID);688-}689-690-async function selectGame(slug, mapSlug) {691- state.game = state.catalog.games.find((game) => game.slug === slug) || state.catalog.games[0];692- // Only an explicitly named map overrides what this game remembers.693- if (!mapSlug && !state.restore) state.restore = readSession(state.game.slug);694- elements.game.value = state.game.slug;695- populateSelect(elements.map, state.game.maps, "title", "id");696- elements.map.disabled = state.game.maps.length === 1;697- elements.map.title = elements.map.disabled ? "This game has one map" : "Choose a map";698- // Returning to a game returns to where it was left, so wandering off to699- // another game and back does not cost the reader their place.700- const remembered = state.restore?.game === state.game.slug ? state.restore : null;701- const wanted = (mapSlug && state.game.maps.find((item) => item.slug === mapSlug)) ||702- (remembered && state.game.maps.find((item) => item.slug === remembered.map));703- await selectMap((wanted || state.game.maps[0]).id);704-}705-706-// The address carries where the reader is, and nothing about what they have707-// filtered or searched. Reloading therefore lands on the same map with a clean708-// legend, which is the quickest way to start a fresh question about it.709-//710-// A fragment rather than a path: the window has no address bar to make a path711-// worth reading, the app can be mounted under a workspace prefix that a pushed712-// path would navigate out of, and a fragment cannot 404. Slash-separated713-// because both slugs contain dashes.714-// The window is reopened far more often than it is refreshed, and reopening it715-// to a default view discards work the reader did to reach where they were. The716-// whole arrangement is kept: which map, which layer, where the view sits, what717-// is filtered out and which groups are folded.718-const sessionKey = "atlas.session";719-720-// Kept per game rather than as a single place, so wandering off to another721-// game and coming back does not cost the reader where they were in this one.722-function saveSession() {723- // Nothing is written while a map is being swapped in: the arrangement is724- // half the old one and half the new until it settles.725- if (!state.map || !state.variant || state.settling) return;726- const view = state.engine?.getView();727- try {728- const stored = allSessions();729- stored.last = state.game.slug;730- stored.games[state.game.slug] = {731- game: state.game.slug,732- map: state.map.slug,733- variant: state.map.variants.indexOf(state.variant),734- center: view?.getCenter(),735- zoom: view?.getZoom(),736- hidden: [...state.hiddenCategories],737- collapsed: [...state.collapsedSections],738- overviewDocked: state.overviewDocked,739- };740- localStorage.setItem(sessionKey, JSON.stringify(stored));741- } catch {742- // A browsing session that cannot be written is not worth failing over.743- }744-}745-746-function allSessions() {747- try {748- const stored = JSON.parse(localStorage.getItem(sessionKey) || "null");749- if (stored && stored.games) return stored;750- } catch {751- // Falls through to a fresh record.752- }753- return { last: "", games: {} };754-}755-756-function readSession(gameSlug) {757- const stored = allSessions();758- const wanted = gameSlug || stored.last;759- const entry = wanted && stored.games[wanted];760- return entry && entry.game && entry.map ? entry : null;761-}762-763-function readRoute() {764- const [game, map] = decodeURIComponent(location.hash.replace(/^#\/?/, ""))765- .split("/")766- .map((part) => part.trim());767- return { game, map };768-}769-770-function writeRoute() {771- if (!state.game || !state.map) return;772- const route = `#${state.game.slug}/${state.map.slug}`;773- if (location.hash === route) return;774- // Replaced rather than pushed: this records a location, not a trail.775- history.replaceState(null, "", route);776-}777-778-async function selectMap(id) {779- const entry = state.game.maps.find((map) => map.id === id) || state.game.maps[0];780- // A map opened while another is still arriving must not be overtaken by it.781- const run = ++state.mapRun;782- elements.loading.hidden = false;783- const loaded = await loadMap(entry);784- if (state.mapRun !== run) return;785-786- state.settling = true;787- state.map = loaded;788- document.documentElement.style.setProperty("--icon-outset-color", iconOutsetColor());789- elements.map.value = String(state.map.id);790- populateSelect(elements.variant, state.map.variants, "name");791- elements.variantField.hidden = state.map.variants.length < 2;792- state.styleCache.clear();793- setHoveredPin(null);794- state.gridPrefix = "";795- state.hiddenCategories.clear();796- // Zones are a navigation aid, not the primary filter surface: keep boundaries797- // drawn but fold the index away so pin groups stay above the fold.798- state.collapsedSections.clear();799- state.collapsedSections.add("zones");800- for (const group of state.map.groups) {801- for (const category of group.categories) {802- if (!category.visible) state.hiddenCategories.add(category.id);803- }804- }805- const restore = state.restore?.map === state.map.slug ? state.restore : null;806- if (restore) {807- state.hiddenCategories = new Set(restore.hidden);808- state.collapsedSections = new Set(restore.collapsed);809- }810- // Where the corner of the screen is wanted is a preference about the game811- // rather than about one of its maps, so it carries across them.812- setOverviewDocked(Boolean(state.restore?.overviewDocked), false);813- state.search = "";814- elements.search.value = "";815- elements.searchResults.hidden = true;816- closeDetail();817- renderLegend();818- renderZones();819- buildPins();820- selectVariant(restore ? clamp(restore.variant, 0, state.map.variants.length - 1) : 0, true);821- elements.gameTitle.textContent = state.game.title;822- elements.title.textContent = state.map.title;823- elements.meta.textContent =824- `${formatNumber(state.map.pinCount)} locations · ${formatNumber(state.map.zones?.length || 0)} regions`;825- elements.sidebar.classList.remove("is-open");826- elements.mobileLegend.setAttribute("aria-expanded", "false");827- writeRoute();828- state.settling = false;829- saveSession();830-}831-832-function selectVariant(index, resetView = false) {833- const priorVariant = state.variant;834- state.variant = state.map.variants[index] || state.map.variants[0];835- const variant = state.variant;836- const carried = resetView ? null : carryViewAcrossShards(priorVariant, variant);837- const maxViewZoom = viewMaxZoom(variant);838- elements.variant.value = String(state.map.variants.indexOf(state.variant));839- if (resetView) state.engine.setView(createView(maxViewZoom));840- else {841- state.engine.getView().setMinZoom(variant.minZoom);842- state.engine.getView().setMaxZoom(maxViewZoom);843- }844-845- const tileRun = ++state.tileRun;846- let pending = 0;847- state.tileStats = { requested: 0, loaded: 0, errors: 0, peakPending: 0 };848- elements.loading.hidden = false;849- const trackLoading = (source) => {850- source.on("tileloadstart", () => {851- if (state.tileRun !== tileRun) return;852- pending++;853- state.tileStats.requested++;854- state.tileStats.peakPending = Math.max(state.tileStats.peakPending, pending);855- });856- const tileFinished = (failed) => {857- if (state.tileRun !== tileRun) return;858- pending = Math.max(0, pending - 1);859- if (failed) state.tileStats.errors++;860- else state.tileStats.loaded++;861- if (pending === 0 && state.tileStats.loaded > 0) elements.loading.hidden = true;862- };863- source.on("tileloadend", () => tileFinished(false));864- source.on("tileloaderror", () => tileFinished(true));865- return source;866- };867-868- const buildSource = (maxLevel, wanted) => trackLoading(new XYZ({869- projection: state.projection,870- tileGrid: new TileGrid({871- extent: [0, -state.catalog.tileGrid.size, state.catalog.tileGrid.size, 0],872- origin: [0, 0],873- // Keep the source grid native. Views may overzoom this last resolution,874- // but no nonexistent tile level is requested.875- resolutions: resolutions(maxLevel),876- tileSize: state.catalog.tileGrid.tileSize,877- }),878- cacheSize: 64,879- interpolate: variant.interpolate,880- transition: 0,881- wrapX: false,882- tileUrlFunction: ([zoom, x, y]) => {883- const format = variant.formats[zoom];884- if (!format || x < 0 || y < 0 || !wanted(zoom, x, y)) return undefined;885- return `/static/tiles/${encodeURIComponent(variant.tiles)}/${zoom}/${x}/${y}.${format}`;886- },887- }));888-889- const fullZoom = variant.fullZoom ?? variant.maxZoom;890- const base = buildSource(fullZoom, (zoom, x, y) => tileExists(variant, zoom, x, y));891- const previous = state.layers.raster.getSource();892- state.layers.raster.setSource(base);893- state.layers.raster.setExtent(activeExtent());894- // Tiles matching the map's background were never written; painting that895- // colour behind the layer makes their absence invisible.896- state.layers.raster.setBackground(variant.background || undefined);897- previous?.clear();898-899- const previousDetail = state.layers.rasterDetail.getSource();900- if (variant.maxZoom > fullZoom) {901- state.layers.rasterDetail.setSource(buildSource(902- variant.maxZoom,903- (zoom, x, y) => zoom > fullZoom && tileExists(variant, zoom, x, y),904- ));905- state.layers.rasterDetail.setExtent(activeExtent());906- state.layers.rasterDetail.setVisible(true);907- } else {908- state.layers.rasterDetail.setVisible(false);909- }910- previousDetail?.clear();911- renderGrid();912- if (state.gridEnabled) {913- refreshPrioritySource();914- state.layers.pins.changed();915- state.layers.text.changed();916- state.layers.priority.changed();917- }918- state.overviewKey = "";919- renderOverview();920- const resume = state.restore?.map === state.map.slug ? state.restore : null;921- // Zones and pins are built before a variant is chosen, so on a split map the922- // first render shows every layer at once. Comparing against what was actually923- // rendered catches that as well as a later switch between layers.924- if (state.renderedShard !== (variant.shard || 0)) {925- renderZones();926- applyPinFilters();927- }928- if (resume?.center && Number.isFinite(resume.zoom)) {929- // Resuming: land exactly where the reader left the view, rather than930- // fitting the map and losing where they were.931- const view = state.engine.getView();932- view.setCenter(resume.center);933- view.setZoom(resume.zoom);934- state.fitZoom = resume.zoom;935- updateVisibleCount();936- } else if (resetView) {937- requestAnimationFrame(fitMap);938- } else if (carried) {939- state.engine.getView().animate({ center: carried, duration: 200 });940- updateVisibleCount();941- } else {942- updateVisibleCount();943- }944- saveSession();945-}946-947-// Levels are sparse: background tiles are never written, and levels above948-// fullZoom exist only where the capture reached. Asking for a tile that was949-// never emitted would be a wasted request and a 404, so consult the coverage950-// bitset first and let OpenLayers show the parent tile instead.951-function tileExists(variant, zoom, x, y) {952- const coverage = variant.coverage?.[zoom];953- if (!coverage) return true;954- const column = x - coverage.x;955- const row = y - coverage.y;956- if (column < 0 || row < 0 || column >= coverage.w || row >= coverage.h) return false;957- const bits = coverageBits(variant, zoom, coverage);958- const index = row * coverage.w + column;959- return (bits[index >> 3] & (1 << (index & 7))) !== 0;960-}961-962-function coverageBits(variant, zoom, coverage) {963- if (!coverage.decoded) {964- const binary = atob(coverage.bits);965- const bytes = new Uint8Array(binary.length);966- for (let index = 0; index < binary.length; index++) bytes[index] = binary.charCodeAt(index);967- coverage.decoded = bytes;968- }969- return coverage.decoded;970-}971-972-function resolutions(maxZoom) {973- const base = state.catalog.tileGrid.size / state.catalog.tileGrid.tileSize;974- return Array.from({ length: maxZoom + 1 }, (_, zoom) => base / (2 ** zoom));975-}976-977-function viewMaxZoom(variant) {978- return variant.maxZoom + overzoomLevels;979-}980-981-// The overview is drawn once per variant from the shallowest pyramid level big982-// enough to read, then only the viewport rectangle moves.983-const overviewTargetSize = 168;984-985-function renderOverview() {986- const variant = state.variant;987- const canvas = elements.overviewCanvas;988- const context = canvas.getContext("2d");989- const extent = activeExtent();990- const world = state.catalog.tileGrid.size;991- const tileSize = state.catalog.tileGrid.tileSize;992- const width = extent[2] - extent[0];993- const height = extent[3] - extent[1];994-995- let level = 0;996- while (level < variant.fullZoom &&997- (Math.max(width, height) / world) * tileSize * (2 ** level) < overviewTargetSize) {998- level++;999- }1000- const scale = (tileSize * (2 ** level)) / world;1001- canvas.width = Math.max(1, Math.round(width * scale));1002- canvas.height = Math.max(1, Math.round(height * scale));1003- context.clearRect(0, 0, canvas.width, canvas.height);1004- if (variant.background) {1005- context.fillStyle = variant.background;1006- context.fillRect(0, 0, canvas.width, canvas.height);1007- }1008-1009- const run = ++state.overviewRun;1010- const format = variant.formats[level];1011- const first = Math.floor((extent[0] / world) * (2 ** level));1012- const last = Math.ceil((extent[2] / world) * (2 ** level));1013- const top = Math.floor((-extent[3] / world) * (2 ** level));1014- const bottom = Math.ceil((-extent[1] / world) * (2 ** level));1015- for (let y = top; y < bottom; y++) {1016- for (let x = first; x < last; x++) {1017- if (!format || !tileExists(variant, level, x, y)) continue;1018- const image = new Image();1019- image.onload = () => {1020- if (state.overviewRun !== run) return;1021- context.drawImage(1022- image,1023- x * tileSize - extent[0] * scale,1024- y * tileSize + extent[3] * scale,1025- tileSize,1026- tileSize,1027- );1028- };1029- image.src = `/static/tiles/${encodeURIComponent(variant.tiles)}/${level}/${x}/${y}.${format}`;1030- }1031- }1032- updateOverviewViewport();1033-}1034-1035-// Hidden while the whole map is on screen: a locator that says "all of it"1036-// tells the reader nothing they cannot already see.1037-function updateOverviewViewport() {1038- const view = state.engine?.getView();1039- if (!view || !state.variant) return;1040- const extent = activeExtent();1041- const visible = view.calculateExtent(state.engine.getSize());1042- const width = extent[2] - extent[0];1043- const height = extent[3] - extent[1];1044- // Fitting the map lands on its extent to within a fraction of a pixel, so an1045- // exact comparison reports the whole map as not quite visible and leaves a1046- // locator on screen that marks the entire map.1047- const slack = (view.getResolution() || 0) * 4;1048- const covered =1049- visible[0] <= extent[0] + slack && visible[1] <= extent[1] + slack &&1050- visible[2] >= extent[2] - slack && visible[3] >= extent[3] - slack;1051- const key = covered ? "hidden" : visible.map(Math.round).join(",");1052- if (key === state.overviewKey) return;1053- state.overviewKey = key;1054- // The handle goes with it: there is nothing to send for while the whole map1055- // is already on screen.1056- elements.overviewShelf.hidden = covered;1057- if (covered) return;1058-1059- const canvas = elements.overviewCanvas;1060- const left = clamp((visible[0] - extent[0]) / width, 0, 1);1061- const right = clamp((visible[2] - extent[0]) / width, 0, 1);1062- const upper = clamp((extent[3] - visible[3]) / height, 0, 1);1063- const lower = clamp((extent[3] - visible[1]) / height, 0, 1);1064- const box = elements.overviewViewport.style;1065- box.left = `${left * canvas.width}px`;1066- box.top = `${upper * canvas.height}px`;1067- // A floor keeps the rectangle findable when the view is deep enough that a1068- // true-to-scale box would be a couple of pixels.1069- box.width = `${Math.max(8, (right - left) * canvas.width)}px`;1070- box.height = `${Math.max(8, (lower - upper) * canvas.height)}px`;1071-}1072-1073-// Put away rather than switched off: the overview keeps drawing, and the handle1074-// it leaves behind is the whole of the way back. A reader who wants the corner1075-// of their map usually wants it for that map's whole session, so the choice is1076-// remembered with the rest of what a game is left in.1077-function setOverviewDocked(docked, remember = true) {1078- state.overviewDocked = docked;1079- // A sweep in progress ends where it is rather than following the panel out.1080- if (docked && state.overviewPointer !== null) {1081- state.overviewPointer = null;1082- settleView();1083- }1084- elements.overviewShelf.classList.toggle("is-docked", docked);1085- elements.overviewDock.setAttribute("aria-expanded", String(!docked));1086- const label = docked ? "Bring the overview back" : "Put the overview away";1087- elements.overviewDock.setAttribute("aria-label", label);1088- elements.overviewDock.title = label;1089- if (remember) saveSession();1090-}1091-1092-// The press that opens a gesture eases across, so a plain click reads as a1093-// move rather than a cut. Everything after it lands at once: a view that eased1094-// its way to each new position would trail behind the hand steering it.1095-function overviewNavigate(event, ease) {1096- const view = state.engine?.getView();1097- if (!view || !state.variant) return;1098- const rect = elements.overviewCanvas.getBoundingClientRect();1099- const extent = activeExtent();1100- const fraction = (value, low, high) => clamp((value - low) / (high - low), 0, 1);1101- const center = [1102- extent[0] + fraction(event.clientX, rect.left, rect.right) * (extent[2] - extent[0]),1103- extent[3] - fraction(event.clientY, rect.top, rect.bottom) * (extent[3] - extent[1]),1104- ];1105- if (ease) {1106- view.animate({ center, duration: 180 });1107- return;1108- }1109- view.cancelAnimations();1110- view.setCenter(center);1111-}1112-1113-// What a view owes the rest of the page once it has come to rest.1114-function settleView() {1115- updateVisibleCount();1116- saveSession();1117-}1118-1119-// The layers of a split map are the same ground at different heights, stacked1120-// down one sheet. Switching between them should leave the reader over the same1121-// place, so the view is carried across by its position within each layer's box1122-// rather than by its absolute coordinates.1123-function carryViewAcrossShards(previous, next) {1124- if (!previous || !next || !previous.shard || !next.shard) return null;1125- if (previous.shard === next.shard || !previous.bounds || !next.bounds) return null;1126- const view = state.engine?.getView();1127- const centre = view?.getCenter();1128- if (!centre) return null;1129- const across = (centre[0] - previous.bounds.x) / previous.bounds.width;1130- const down = (-centre[1] - previous.bounds.y) / previous.bounds.height;1131- return [1132- next.bounds.x + clamp(across, 0, 1) * next.bounds.width,1133- -(next.bounds.y + clamp(down, 0, 1) * next.bounds.height),1134- ];1135-}1136-1137-function toggleSidebar() {1138- const shell = document.querySelector(".app-shell");1139- const collapsed = shell.classList.toggle("sidebar-collapsed");1140- elements.mobileLegend.setAttribute("aria-expanded", String(!collapsed));1141- // The map keeps its own idea of how big it is.1142- requestAnimationFrame(() => state.engine?.updateSize());1143-}1144-1145-function activeExtent() {1146- const size = state.catalog.tileGrid.size;1147- const bounds = state.variant?.bounds || { x: 0, y: 0, width: size, height: size };1148- return [bounds.x, -(bounds.y + bounds.height), bounds.x + bounds.width, -bounds.y];1149-}1150-1151-// What the grid divides is the ground the map covers, which is not the window1152-// its raster is cut from: a piece of a sheet keeps a margin so the title drawn1153-// beside it survives the crop. On a big map that margin is nothing; on a small1154-// one it is a fifth of the width, and the cells over it are cells the map never1155-// gets -- b naming blank sheet while m carries what b should have held.1156-function gridExtent() {1157- const surface = state.variant?.surface;1158- if (!surface) return activeExtent();1159- return [1160- surface.x,1161- -(surface.y + surface.height),1162- surface.x + surface.width,1163- -surface.y,1164- ];1165-}1166-1167-function handleGridKey(event) {1168- if (event.key.toLocaleLowerCase() === "g") {1169- event.preventDefault();1170- toggleGrid();1171- // The grid is opened to go somewhere, so the field that takes a hash is1172- // ready for the rest of what is being typed: "gm6" arrives at m6. Closing1173- // hands the keyboard back to the map, where the shortcuts live.1174- if (state.gridEnabled) {1175- elements.gridInput.focus();1176- elements.gridInput.select();1177- } else {1178- elements.viewport.focus({ preventScroll: true });1179- }1180- return true;1181- }1182- // Space is about what the chosen cell is divided into, not where the reader1183- // is: the cell stays chosen and the pins outside it stay put away, while the1184- // subdivision inside it gets out of the way of the map underneath.1185- // The button answers its own space bar, and would otherwise be pressed twice.1186- if (event.key === " " && state.gridEnabled && event.target !== elements.subgridToggle) {1187- event.preventDefault();1188- setSubgridVisible(!state.subgridVisible);1189- return true;1190- }1191- if (event.key === "Escape" && state.gridEnabled) {1192- event.preventDefault();1193- ascendGrid();1194- return true;1195- }1196- return false;1197-}1198-1199-function toggleGrid(enabled = !state.gridEnabled) {1200- state.gridEnabled = enabled;1201- // Opening the grid divides the cell again. A reader who put the subgrid away1202- // and then closed the grid altogether is starting over, not resuming.1203- if (enabled) setSubgridVisible(true);1204- renderGrid();1205- refreshPrioritySource();1206- state.layers.pins.changed();1207- state.layers.text.changed();1208- state.layers.priority.changed();1209-}1210-1211-// Dividing the chosen cell and being held to it are two questions. The1212-// subdivision is how a reader picks the next place; once picked, the mesh over1213-// the map is often the last thing they want to look at, and until now the only1214-// way to be rid of it was to give up the scope it was holding. Nothing is1215-// really hidden: the cell keeps its boundary and the ancestors keep theirs.1216-function setSubgridVisible(visible) {1217- state.subgridVisible = visible;1218- state.layers.grid.changed();1219- state.layers.gridContext.changed();1220- elements.subgridToggle.setAttribute("aria-pressed", String(visible));1221- elements.subgridToggle.setAttribute("aria-label",1222- visible ? "Hide the subgrid" : "Show the subgrid");1223- updateGridHint();1224-}1225-1226-function updateGridHint() {1227- if (!state.gridEnabled) {1228- elements.gridHint.textContent = "G · grid off";1229- return;1230- }1231- // Compact while it is carrying a hash: the mode, the place and the state of1232- // the subdivision are one reading, not three separate ones.1233- elements.gridHint.textContent = `G-${state.gridPrefix || "root"}` +1234- (state.subgridVisible ? "" : " no subgrid");1235-}1236-1237-function selectGridPrefix(prefix) {1238- const maximum = gridMaxDepth();1239- const normalized = [...prefix.toLocaleLowerCase()]1240- .filter((character) => geohashAlphabet.includes(character))1241- .slice(0, maximum)1242- .join("");1243- const changed = normalized !== state.gridPrefix;1244- state.gridPrefix = normalized;1245- if (!state.gridEnabled) state.gridEnabled = true;1246- renderGrid();1247- refreshPrioritySource();1248- state.layers.pins.changed();1249- state.layers.text.changed();1250- state.layers.priority.changed();1251- if (!changed) return;1252- closeDetail();1253- state.engine.getView().fit(currentGridExtent(), {1254- size: state.engine.getSize(),1255- padding: [52, 52, 52, 52],1256- maxZoom: viewMaxZoom(state.variant),1257- duration: 180,1258- });1259-}1260-1261-function ascendGrid() {1262- if (!state.gridEnabled) return;1263- if (!state.gridPrefix) {1264- toggleGrid(false);1265- return;1266- }1267- selectGridPrefix(state.gridPrefix.slice(0, -1));1268-}1269-1270-function renderGrid() {1271- if (!state.sources) return;1272- state.sources.grid.clear();1273- state.sources.gridContext.clear();1274- elements.gridNavigator.hidden = !state.gridEnabled;1275- updateGridHint();1276- if (!state.gridEnabled || !state.variant) return;1277-1278- const maximum = gridMaxDepth();1279- elements.gridInput.maxLength = maximum;1280- elements.gridInput.value = state.gridPrefix;1281- elements.gridBack.title = state.gridPrefix ? "Back one geohash level" : "Close geohash grid";1282-1283- renderGridContext();1284- if (state.gridPrefix.length >= maximum) {1285- addGridFeature(state.gridPrefix, currentGridExtent(), "leaf");1286- return;1287- }1288- // The cell the reader is inside, outlined rather than tiled. It is the one1289- // part of the grid that survives putting the grid away: what is on screen is1290- // still a chosen place, and a boundary says so where a bare map does not.1291- if (state.gridPrefix) {1292- addGridFeature(state.gridPrefix, currentGridExtent(), "scope");1293- }1294- for (const character of geohashAlphabet) {1295- const hash = state.gridPrefix + character;1296- addGridFeature(hash, geohashExtent(hash), "child");1297- }1298-}1299-1300-function renderGridContext() {1301- for (let depth = 0; depth < state.gridPrefix.length; depth++) {1302- const parent = state.gridPrefix.slice(0, depth);1303- const selected = state.gridPrefix.slice(0, depth + 1);1304- for (const character of geohashAlphabet) {1305- const hash = parent + character;1306- if (hash === selected) continue;1307- addGridFeature(hash, geohashExtent(hash), "neighbor", state.gridPrefix.length - depth);1308- }1309- }1310-}1311-1312-function addGridFeature(hash, extent, role, contextDistance = 0) {1313- const [minimumX, minimumY, maximumX, maximumY] = extent;1314- const count = state.pins.filter((pin) => {1315- if (pin.filteredHidden) return false;1316- const [x, y] = pin.coordinate;1317- return x >= minimumX && x <= maximumX && y >= minimumY && y <= maximumY;1318- }).length;1319- const feature = new Feature({1320- geometry: new Polygon([[1321- [minimumX, minimumY],1322- [minimumX, maximumY],1323- [maximumX, maximumY],1324- [maximumX, minimumY],1325- [minimumX, minimumY],1326- ]]),1327- gridCell: { hash, extent, role, count, contextDistance },1328- priority: role === "neighbor"1329- ? -contextDistance * 100 + geohashAlphabet.indexOf(hash[hash.length - 1])1330- : geohashAlphabet.indexOf(hash[hash.length - 1]),1331- });1332- const source = role === "neighbor" ? state.sources.gridContext : state.sources.grid;1333- source.addFeature(feature);1334-}1335-1336-function currentGridExtent() {1337- return geohashExtent(state.gridPrefix);1338-}1339-1340-function geohashExtent(hash) {1341- const extent = [...gridExtent()];1342- let splitX = true;1343- for (const character of hash) {1344- const value = geohashAlphabet.indexOf(character);1345- if (value < 0) continue;1346- for (const mask of [16, 8, 4, 2, 1]) {1347- if (splitX) {1348- const middle = (extent[0] + extent[2]) / 2;1349- if (value & mask) extent[0] = middle;1350- else extent[2] = middle;1351- } else {1352- const middle = (extent[1] + extent[3]) / 2;1353- if (value & mask) extent[1] = middle;1354- else extent[3] = middle;1355- }1356- splitX = !splitX;1357- }1358- }1359- return extent;1360-}1361-1362-function gridMaxDepth() {1363- return geohashMaxDepth;1364-}1365-1366-function pinInGridCell(pin) {1367- if (!state.gridEnabled || !state.gridPrefix) return false;1368- const extent = currentGridExtent();1369- const [x, y] = pin.coordinate;1370- return x >= extent[0] && x <= extent[2] && y >= extent[1] && y <= extent[3];1371-}1372-1373-function populateSelect(select, items, labelKey, valueKey) {1374- select.replaceChildren();1375- items.forEach((item, index) => {1376- const option = document.createElement("option");1377- option.value = valueKey ? String(item[valueKey]) : (item.slug || String(index));1378- option.textContent = item[labelKey];1379- select.append(option);1380- });1381-}1382-1383-// Categories drawn as text are labels for the ground itself -- Area, Region,1384-// Province -- and are read and edited as one set. Gathered here rather than1385-// left in place, where "Area" sits between Altar and Bank and reads like1386-// another kind of marker.1387-function legendSections(groups) {1388- const sections = [];1389- const text = [];1390- for (const group of groups) {1391- const drawn = [];1392- for (const category of group.categories) {1393- (category.displayType === "text" ? text : drawn).push(category);1394- }1395- if (drawn.length) {1396- sections.push({ key: `group-${group.id}`, title: group.title, categories: drawn });1397- }1398- }1399- // Above the pin groups, under the zones: labels and boundaries both say where1400- // you are, rather than what is worth going to.1401- if (text.length) sections.unshift({ key: "text", title: "Text", categories: text });1402- return sections;1403-}1404-1405-function renderLegend() {1406- const fragment = document.createDocumentFragment();1407- for (const section of state.map.sections) {1408- const element = document.createElement("section");1409- element.className = "layer-section";1410- element.dataset.layerSection = section.key;1411- const locations = section.categories.reduce((total, category) => total + category.locations.length, 0);1412- element.append(layerHeader(section.key, section.title, locations));1413- const toggles = document.createElement("div");1414- toggles.className = "category-toggles";1415- for (const category of section.categories) toggles.append(categoryToggle(category));1416- element.append(toggles);1417- fragment.append(element);1418- }1419- elements.legend.replaceChildren(fragment);1420- syncSectionCollapse();1421- syncSectionSwitches();1422-}1423-1424-// Mirrors the markup of the static zones header so every layer section reads the1425-// same: disclosure on the left, one switch on the right.1426-function layerHeader(key, title, count) {1427- const header = document.createElement("div");1428- header.className = "layer-header";1429-1430- const disclosure = document.createElement("button");1431- disclosure.type = "button";1432- disclosure.className = "layer-title";1433- disclosure.dataset.section = key;1434- const chevron = document.createElement("span");1435- chevron.className = "layer-chevron";1436- chevron.setAttribute("aria-hidden", "true");1437- chevron.innerHTML = '<svg viewBox="0 0 24 24"><path d="m9 6 6 6-6 6"/></svg>';1438- const name = document.createElement("span");1439- name.textContent = title;1440- const total = document.createElement("span");1441- total.className = "layer-count";1442- total.textContent = formatNumber(count);1443- disclosure.append(chevron, name, total);1444-1445- const only = onlyButton(`Show only ${title}`);1446- only.dataset.onlySection = key;1447-1448- const toggle = document.createElement("label");1449- toggle.className = "layer-switch";1450- const checkbox = document.createElement("input");1451- checkbox.type = "checkbox";1452- checkbox.dataset.sectionToggle = key;1453- checkbox.setAttribute("aria-label", `Show ${title}`);1454- const knob = document.createElement("span");1455- knob.setAttribute("aria-hidden", "true");1456- toggle.append(checkbox, knob);1457-1458- header.append(disclosure, only, toggle);1459- return header;1460-}1461-1462-// A target rather than the word "only": the legend's remaining words are then1463-// all things the map is actually about. The label arrives on rest, for anyone1464-// meeting the icon for the first time.1465-function onlyButton(label) {1466- const button = document.createElement("button");1467- button.type = "button";1468- button.className = "only-button";1469- button.dataset.label = label;1470- button.setAttribute("aria-label", label);1471- button.innerHTML =1472- '<svg viewBox="0 0 16 16" aria-hidden="true">' +1473- '<circle cx="8" cy="8" r="4.6"/><circle cx="8" cy="8" r="1.3" fill="currentColor" stroke="none"/>' +1474- '<path d="M8 1v2M8 13v2M1 8h2M13 8h2"/></svg>';1475- return button;1476-}1477-1478-function categoryToggle(category) {1479- const isText = category.displayType === "text";1480- const row = document.createElement("label");1481- row.className = "category-row";1482- applyCategoryVisual(row, category);1483- const checkbox = document.createElement("input");1484- checkbox.type = "checkbox";1485- checkbox.dataset.category = String(category.id);1486- checkbox.checked = !state.hiddenCategories.has(category.id);1487- const icon = document.createElement("span");1488- if (isText) {1489- icon.className = "text-symbol";1490- icon.textContent = "Tt";1491- icon.title = "Drawn as a text label";1492- } else {1493- icon.className = "category-icon";1494- applyCategoryGlyph(icon, category, initials(category.title));1495- icon.title = category.icon || category.title;1496- }1497- const name = document.createElement("span");1498- name.className = "category-name";1499- name.textContent = category.title;1500- const locations = document.createElement("span");1501- locations.className = "category-count";1502- locations.textContent = formatNumber(category.locations.length);1503- // Overlaid on the count rather than appended: these pills wrap, and a row1504- // that grows on hover would shove the one under the cursor somewhere else.1505- const only = onlyButton(`Show only ${category.title}`);1506- only.dataset.onlyCategory = String(category.id);1507- row.append(checkbox, icon, name, only, locations);1508- return row;1509-}1510-1511-// There is one level of nesting here -- sections hold rows, not more sections --1512-// so folding by a depth and folding entirely are the same move, and only the1513-// one exists.1514-function setAllSectionsCollapsed(collapsed) {1515- state.collapsedSections.clear();1516- if (collapsed) {1517- for (const button of elements.layers.querySelectorAll("[data-section]")) {1518- state.collapsedSections.add(button.dataset.section);1519- }1520- }1521- syncSectionCollapse();1522-}1523-1524-function syncSectionCollapse() {1525- for (const button of elements.layers.querySelectorAll("[data-section]")) {1526- const collapsed = state.collapsedSections.has(button.dataset.section);1527- button.setAttribute("aria-expanded", String(!collapsed));1528- button.closest(".layer-section").classList.toggle("is-collapsed", collapsed);1529- }1530- saveSession();1531-}1532-1533-function buildPins() {1534- state.sources.pins.clear();1535- state.sources.text.clear();1536- state.sources.priority.clear();1537- state.pins = [];1538- state.pinByID.clear();1539- for (const group of state.map.groups) {1540- for (const category of group.categories) {1541- if (category.displayType !== "text") prepareMarkerIcon(category);1542- for (const location of category.locations) {1543- const pin = {1544- location,1545- category,1546- group,1547- coordinate: project(location.lat, location.lng),1548- filteredHidden: false,1549- priority: pinPriority(category, location),1550- feature: null,1551- };1552- pin.feature = new Feature({1553- geometry: new Point(pin.coordinate),1554- pin,1555- priority: pin.priority,1556- });1557- state.pins.push(pin);1558- state.pinByID.set(location.id, pin);1559- if (category.displayType === "text") state.sources.text.addFeature(pin.feature);1560- else state.sources.pins.addFeature(pin.feature);1561- }1562- }1563- }1564- applyPinFilters();1565-}1566-1567-function renderZones() {1568- const zones = (state.map.zones || []).filter(onActiveShard);1569- state.renderedShard = state.variant?.shard || 0;1570- state.sources.zones.clear();1571- state.sources.zoneTitles.clear();1572- state.zoneRecords.clear();1573- state.highlightedZones.clear();1574- state.focusedZoneID = null;1575- state.zoneTitleCount = 0;1576- setZonesVisible(true);1577- elements.zoneIndex.hidden = zones.length === 0;1578- elements.zoneCount.textContent = formatNumber(zones.length);1579-1580- for (const zone of zones) {1581- const zoneExtent = createEmpty();1582- const geometries = [];1583- let hasGeometry = false;1584- for (const rawGeometry of zone.features || []) {1585- const geometry = projectZoneGeometry(rawGeometry);1586- if (!geometry) continue;1587- hasGeometry = true;1588- geometries.push(geometry);1589- extend(zoneExtent, geometry.getExtent());1590- state.sources.zones.addFeature(new Feature({1591- geometry,1592- zone,1593- color: colorFor(zone.id),1594- child: zone.parentRegionId != null,1595- }));1596- }1597- if (!hasGeometry) continue;1598- const color = colorFor(zone.id);1599- const center = zone.center ? project(zone.center.lat, zone.center.lng) : getCenter(zoneExtent);1600- const span = Math.max(zoneExtent[2] - zoneExtent[0], zoneExtent[3] - zoneExtent[1]);1601- state.sources.zoneTitles.addFeature(new Feature({1602- geometry: new Point(center),1603- zone,1604- color,1605- child: zone.parentRegionId != null,1606- span,1607- priority: (zone.parentRegionId == null ? 2_000_000 : 1_000_000) + Math.round(span),1608- }));1609- state.zoneRecords.set(zone.id, {1610- zone,1611- extent: zoneExtent.slice(),1612- geometries,1613- color,1614- });1615- }1616- state.zoneTitleCount = state.sources.zoneTitles.getFeatures().length;1617- renderZoneScrim();1618- renderZoneIndex();1619-}1620-1621-// Highlighting a zone is a request to look at one place, so everything else1622-// recedes: the whole map is covered and the zone is cut back out of it.1623-// Shading only the neighbouring zones demoted them rather than raising the1624-// zone asked for, and left the unclaimed space between them at full strength.1625-function renderZoneScrim() {1626- state.sources.zoneScrim.clear();1627- if (!state.highlightedZones.size) return;1628- const [left, bottom, right, top] = state.projection.getExtent();1629- // Rings alternate direction with their depth so the fill counts its way in1630- // and out: the map, then the zone as a hole, then any hole of the zone's own1631- // back to solid.1632- const rings = [orientRing([1633- [left, bottom], [right, bottom], [right, top], [left, top], [left, bottom],1634- ], true)];1635- for (const zoneID of state.highlightedZones) {1636- for (const geometry of state.zoneRecords.get(zoneID)?.geometries || []) {1637- const polygons = geometry.getType() === "MultiPolygon"1638- ? geometry.getPolygons()1639- : [geometry];1640- for (const polygon of polygons) {1641- polygon.getLinearRings().forEach((ring, index) => {1642- rings.push(orientRing(ring.getCoordinates(), index > 0));1643- });1644- }1645- }1646- }1647- state.sources.zoneScrim.addFeature(new Feature({ geometry: new Polygon(rings) }));1648-}1649-1650-// Twice the signed area of a ring: negative when its points run clockwise.1651-function orientRing(ring, clockwise) {1652- let area = 0;1653- for (let index = 0, prior = ring.length - 1; index < ring.length; prior = index++) {1654- area += ring[prior][0] * ring[index][1] - ring[index][0] * ring[prior][1];1655- }1656- return (area < 0) === clockwise ? ring : ring.slice().reverse();1657-}1658-1659-function renderZoneIndex() {1660- const fragment = document.createDocumentFragment();1661- for (const { zone, depth } of orderedZones()) {1662- const record = state.zoneRecords.get(zone.id);1663- if (!record) continue;1664- const button = document.createElement("button");1665- button.type = "button";1666- button.className = "zone-index-item";1667- button.dataset.zone = String(zone.id);1668- button.style.setProperty("--zone-color", record.color);1669- button.style.setProperty("--zone-depth", String(depth));1670- button.setAttribute("aria-pressed", "false");1671- button.title = `${zone.title}: click to jump; right-click to toggle highlight`;1672-1673- const marker = document.createElement("span");1674- marker.className = "zone-index-marker";1675- marker.setAttribute("aria-hidden", "true");1676- const title = document.createElement("span");1677- title.textContent = zone.title;1678- button.append(marker, title);1679- fragment.append(button);1680- }1681- elements.zoneList.replaceChildren(fragment);1682- elements.zoneIndex.hidden = state.zoneRecords.size === 0;1683-}1684-1685-function orderedZones() {1686- const zones = [...state.zoneRecords.values()].map((record) => record.zone);1687- const zoneIDs = new Set(zones.map((zone) => zone.id));1688- const children = new Map();1689- for (const zone of zones) {1690- const parentID = zoneIDs.has(zone.parentRegionId) ? zone.parentRegionId : null;1691- if (!children.has(parentID)) children.set(parentID, []);1692- children.get(parentID).push(zone);1693- }1694- for (const entries of children.values()) {1695- entries.sort((left, right) => left.title.localeCompare(right.title, undefined, {1696- numeric: true,1697- sensitivity: "base",1698- }));1699- }1700-1701- const ordered = [];1702- const visited = new Set();1703- const append = (zone, depth) => {1704- if (visited.has(zone.id)) return;1705- visited.add(zone.id);1706- ordered.push({ zone, depth });1707- for (const child of children.get(zone.id) || []) append(child, depth + 1);1708- };1709- for (const zone of children.get(null) || []) append(zone, 0);1710- for (const zone of zones) append(zone, 0);1711- return ordered;1712-}1713-1714-function setZonesVisible(visible) {1715- state.zonesVisible = visible;1716- elements.zoneToggle.checked = visible;1717- state.layers.zoneScrim.setVisible(visible);1718- state.layers.zones.setVisible(visible);1719- state.layers.zoneTitles.setVisible(visible);1720- state.layers.zoneTitleDetail.setVisible(visible);1721-}1722-1723-function jumpToZone(zoneID) {1724- const record = state.zoneRecords.get(zoneID);1725- if (!record) return;1726- state.focusedZoneID = zoneID;1727- updateZoneIndexState();1728- closeDetail();1729- state.engine.getView().fit(record.extent, {1730- size: state.engine.getSize(),1731- padding: [54, 54, 54, 54],1732- maxZoom: viewMaxZoom(state.variant),1733- duration: 220,1734- });1735- elements.sidebar.classList.remove("is-open");1736- elements.mobileLegend.setAttribute("aria-expanded", "false");1737-}1738-1739-function toggleZoneHighlight(zoneID) {1740- if (!state.zoneRecords.has(zoneID)) return;1741- if (state.highlightedZones.has(zoneID)) state.highlightedZones.delete(zoneID);1742- else {1743- state.highlightedZones.add(zoneID);1744- setZonesVisible(true);1745- }1746- state.hoveredPin = null;1747- updateZonePinFocus();1748- refreshPinRendering();1749- updateZoneIndexState();1750- renderZoneScrim();1751- state.layers.zones.changed();1752- state.layers.zoneTitles.changed();1753- state.layers.zoneTitleDetail.changed();1754-}1755-1756-function updateZoneIndexState() {1757- elements.zoneIndex.classList.toggle("has-highlights", state.highlightedZones.size > 0);1758- for (const button of elements.zoneList.querySelectorAll("[data-zone]")) {1759- const zoneID = Number(button.dataset.zone);1760- const highlighted = state.highlightedZones.has(zoneID);1761- button.classList.toggle("is-highlighted", highlighted);1762- button.classList.toggle("is-current", state.focusedZoneID === zoneID);1763- button.setAttribute("aria-pressed", String(highlighted));1764- }1765-}1766-1767-function projectZoneGeometry(rawGeometry) {1768- if (!rawGeometry?.coordinates) return null;1769- const point = ([longitude, latitude]) => project(latitude, longitude);1770- if (rawGeometry.type === "Polygon") {1771- return new Polygon(rawGeometry.coordinates.map((ring) => ring.map(point)));1772- }1773- if (rawGeometry.type === "MultiPolygon") {1774- return new MultiPolygon(1775- rawGeometry.coordinates.map((polygon) => polygon.map((ring) => ring.map(point))),1776- );1777- }1778- return null;1779-}1780-1781-function project(latitude, longitude) {1782- const grid = state.catalog.tileGrid;1783- const worldTiles = 2 ** grid.sourceZoom;1784- const xTile = ((longitude + 180) / 360) * worldTiles;1785- const latitudeRadians = latitude * Math.PI / 180;1786- const yTile = (1 - Math.asinh(Math.tan(latitudeRadians)) / Math.PI) / 2 * worldTiles;1787- return [1788- (xTile - grid.firstTile) * grid.tileSize,1789- -(yTile - grid.firstTile) * grid.tileSize,1790- ];1791-}1792-1793-function applyPinFilters() {1794- for (const pin of state.pins) {1795- const categoryHidden = state.hiddenCategories.has(pin.category.id);1796- const searchHidden = state.search &&1797- !pin.location.title.toLocaleLowerCase().includes(state.search);1798- pin.filteredHidden = Boolean(categoryHidden || searchHidden);1799- }1800- updateZonePinFocus();1801- refreshPinRendering();1802- if (state.selectedPin?.filteredHidden) closeDetail();1803-}1804-1805-function updateZonePinFocus() {1806- if (!state.highlightedZones.size) {1807- for (const pin of state.pins) pin.insideHighlightedZone = false;1808- return;1809- }1810- const records = [...state.highlightedZones]1811- .map((zoneID) => state.zoneRecords.get(zoneID))1812- .filter(Boolean);1813- for (const pin of state.pins) {1814- pin.insideHighlightedZone = records.some((record) =>1815- record.geometries.some((geometry) => geometryContainsCoordinate(geometry, pin.coordinate)));1816- }1817-}1818-1819-function geometryContainsCoordinate(geometry, coordinate) {1820- if (geometry.intersectsCoordinate(coordinate)) return true;1821- const closest = geometry.getClosestPoint(coordinate);1822- const x = closest[0] - coordinate[0];1823- const y = closest[1] - coordinate[1];1824- return x * x + y * y <= 1;1825-}1826-1827-function refreshPinRendering() {1828- state.eligibleLocations = state.pins.filter((pin) => !pinIsHidden(pin)).length;1829- refreshPrioritySource();1830- state.layers.pins.changed();1831- state.layers.zonePins.changed();1832- state.layers.pinLabels.changed();1833- state.layers.text.changed();1834- state.layers.zoneText.changed();1835- state.layers.textDetail.changed();1836- state.layers.priority.changed();1837- updateVisibleCount();1838-}1839-1840-function refreshPrioritySource() {1841- state.sources.priority.clear();1842- for (const pin of state.pins) {1843- if (pinIsHidden(pin)) continue;1844- const searched = Boolean(state.search) &&1845- pin.location.title.toLocaleLowerCase().includes(state.search);1846- if (pin === state.selectedPin || pin === state.hoveredPin || searched || pinInGridCell(pin)) {1847- state.sources.priority.addFeature(pin.feature);1848- }1849- }1850-}1851-1852-function setHoveredPin(pin) {1853- if (state.hoveredPin === pin) return;1854- state.hoveredPin = pin;1855- if (!state.sources) return;1856- refreshPrioritySource();1857- state.layers.pins.changed();1858- state.layers.priority.changed();1859-}1860-1861-function renderSearchResults() {1862- if (!state.search) {1863- elements.searchResults.hidden = true;1864- elements.searchResults.replaceChildren();1865- return;1866- }1867- const matches = state.pins1868- .filter((pin) => !state.hiddenCategories.has(pin.category.id) &&1869- pin.location.title.toLocaleLowerCase().includes(state.search))1870- .sort((a, b) => a.location.title.localeCompare(b.location.title))1871- .slice(0, 20);1872- const fragment = document.createDocumentFragment();1873- if (!matches.length) {1874- const empty = document.createElement("p");1875- empty.className = "search-empty";1876- empty.textContent = "No visible locations match.";1877- fragment.append(empty);1878- }1879- for (const pin of matches) {1880- const button = document.createElement("button");1881- button.type = "button";1882- button.className = "search-result";1883- button.dataset.location = String(pin.location.id);1884- applyCategoryVisual(button, pin.category);1885- const dot = document.createElement("span");1886- dot.className = "result-dot";1887- applyCategoryGlyph(dot, pin.category, initials(pin.category.title));1888- const copy = document.createElement("span");1889- const title = document.createElement("strong");1890- title.textContent = pin.location.title;1891- const category = document.createElement("small");1892- category.textContent = `${pin.category.title} · ${pin.group.title}`;1893- copy.append(title, category);1894- button.append(dot, copy);1895- fragment.append(button);1896- }1897- elements.searchResults.replaceChildren(fragment);1898- elements.searchResults.hidden = false;1899-}1900-1901-function setAllCategories(visible) {1902- state.hiddenCategories.clear();1903- if (!visible) {1904- for (const group of state.map.groups) {1905- for (const category of group.categories) state.hiddenCategories.add(category.id);1906- }1907- }1908- syncLegendCheckboxes();1909- applyPinFilters();1910- renderSearchResults();1911- syncSectionSwitches();1912-}1913-1914-function syncLegendCheckboxes() {1915- for (const checkbox of document.querySelectorAll("[data-category]")) {1916- checkbox.checked = !state.hiddenCategories.has(Number(checkbox.dataset.category));1917- }1918-}1919-1920-function toggleSection(key) {1921- const section = state.map.sections.find((item) => item.key === key);1922- if (!section) return;1923- const hasVisible = section.categories.some((category) => !state.hiddenCategories.has(category.id));1924- for (const category of section.categories) {1925- if (hasVisible) state.hiddenCategories.add(category.id);1926- else state.hiddenCategories.delete(category.id);1927- }1928- syncLegendCheckboxes();1929- applyPinFilters();1930- syncSectionSwitches();1931-}1932-1933-// Isolating is the common request of a long legend: "just the Korok Seeds",1934-// out of a hundred and sixty categories. Everything else is hidden rather than1935-// remembered, so Show all is the single, obvious way back.1936-function showOnly(target) {1937- if (!state.map) return;1938- // Asking to isolate what is already isolated means the reader is done with1939- // it, so the same control lets them back out.1940- if (isOnly(target)) {1941- setAllCategories(true);1942- return;1943- }1944- state.hiddenCategories.clear();1945- for (const section of state.map.sections) {1946- const wanted = target.section === section.key;1947- for (const category of section.categories) {1948- if (!wanted && target.category !== category.id) {1949- state.hiddenCategories.add(category.id);1950- }1951- }1952- }1953- syncLegendCheckboxes();1954- applyPinFilters();1955- renderSearchResults();1956- syncSectionSwitches();1957-}1958-1959-// True when what is on screen is already exactly what this target would isolate.1960-function isOnly(target) {1961- for (const section of state.map.sections) {1962- for (const category of section.categories) {1963- const wanted = target.section === section.key || target.category === category.id;1964- if (wanted === state.hiddenCategories.has(category.id)) return false;1965- }1966- }1967- return true;1968-}1969-1970-// Derived rather than remembered, so the chip is right however the state was1971-// reached -- including by switching categories off one at a time.1972-function updateSoloChip() {1973- const chip = elements.soloChip;1974- if (!state.map) {1975- chip.hidden = true;1976- return;1977- }1978- let onlyVisible = null;1979- let visibleCount = 0;1980- let soleSection = null;1981- let sectionsShowing = 0;1982- for (const section of state.map.sections) {1983- let shown = 0;1984- for (const category of section.categories) {1985- if (state.hiddenCategories.has(category.id)) continue;1986- shown++;1987- visibleCount++;1988- onlyVisible = category;1989- }1990- if (shown > 0) {1991- sectionsShowing++;1992- soleSection = shown === section.categories.length ? section : null;1993- }1994- }1995- let label = "";1996- if (visibleCount === 1 && onlyVisible) label = onlyVisible.title;1997- else if (sectionsShowing === 1 && soleSection) label = soleSection.title;1998- chip.hidden = !label;1999- chip.textContent = label ? `only: ${label}` : "";2000- chip.title = label ? `Showing only ${label} — click to show everything` : "";2001-}2002-2003-function syncSectionSwitches() {2004- if (!state.map) return;2005- for (const section of state.map.sections) {2006- const input = elements.legend.querySelector(`input[data-section-toggle="${section.key}"]`);2007- if (input) {2008- input.checked = section.categories.some((category) => !state.hiddenCategories.has(category.id));2009- }2010- }2011- updateSoloChip();2012- saveSession();2013-}2014-2015-function revealPin(pin) {2016- state.hiddenCategories.delete(pin.category.id);2017- state.search = "";2018- elements.search.value = "";2019- elements.searchResults.hidden = true;2020- syncLegendCheckboxes();2021- applyPinFilters();2022- syncSectionSwitches();2023- showPin(pin, true);2024-}2025-2026-function showPin(pin, focus = false) {2027- state.selectedPin = pin;2028- refreshPrioritySource();2029- state.layers.pins.changed();2030- state.layers.pinLabels.changed();2031- state.layers.text.changed();2032- state.layers.textDetail.changed();2033- state.layers.priority.changed();2034- elements.detailTitle.textContent = pin.location.title;2035- elements.detailCategory.textContent = `${pin.group.title} / ${pin.category.title}`;2036- elements.detailDescription.textContent = "";2037- elements.detailLinks.hidden = true;2038- fillPinText(pin);2039- elements.detailID.textContent = String(pin.location.id);2040- elements.detailCoordinates.textContent =2041- `${pin.location.lat.toFixed(6)}, ${pin.location.lng.toFixed(6)}`;2042- applyCategoryVisual(elements.detailDot, pin.category);2043- applyCategoryGlyph(elements.detailDot, pin.category, initials(pin.category.title));2044- elements.detail.hidden = false;2045- if (focus) {2046- const view = state.engine.getView();2047- view.animate({2048- center: pin.coordinate,2049- zoom: Math.min(viewMaxZoom(state.variant), Math.max(view.getZoom() || 0, 4)),2050- duration: 220,2051- });2052- }2053-}2054-2055-// The words belonging to a pin are fetched the first time one is opened, so a2056-// map that is only ever looked at never pays for them. The panel opens on what2057-// is already known and fills in when they arrive; a pin closed or changed in2058-// the meantime is left alone.2059-async function fillPinText(pin) {2060- const text = await mapText(state.map.id);2061- if (state.selectedPin !== pin) return;2062- const entry = text[String(pin.location.id)] || {};2063- pin.location.description = entry.d || "";2064- pin.location.links = entry.l || [];2065- elements.detailDescription.textContent =2066- cleanDescription(entry.d) || "No description is included in the archive.";2067- renderDetailLinks(pin);2068-}2069-2070-// The source wrote these as mapgenie URLs. They are rebuilt as in-app jumps so2071-// they still work with no network, and dropped when the target is not on this2072-// map.2073-function renderDetailLinks(pin) {2074- const links = (pin.location.links || []).filter((link) => state.pinByID.has(link.locationId));2075- elements.detailLinks.hidden = links.length === 0;2076- if (!links.length) {2077- elements.detailLinks.replaceChildren();2078- return;2079- }2080- const fragment = document.createDocumentFragment();2081- for (const link of links) {2082- const button = document.createElement("button");2083- button.type = "button";2084- button.className = "detail-link";2085- button.dataset.location = String(link.locationId);2086- button.textContent = link.title;2087- fragment.append(button);2088- }2089- elements.detailLinks.replaceChildren(fragment);2090-}2091-2092-function closeDetail() {2093- state.selectedPin = null;2094- if (state.sources) {2095- refreshPrioritySource();2096- state.layers.pins.changed();2097- state.layers.pinLabels.changed();2098- state.layers.text.changed();2099- state.layers.textDetail.changed();2100- state.layers.priority.changed();2101- }2102- elements.detail.hidden = true;2103-}2104-2105-function fitMap() {2106- if (!state.engine || !state.variant) return;2107- const view = state.engine.getView();2108- view.fit(activeExtent(), {2109- size: state.engine.getSize(),2110- padding: [36, 36, 36, 36],2111- maxZoom: state.variant.maxZoom,2112- duration: 0,2113- });2114- state.fitZoom = view.getZoom() || 0;2115- updateVisibleCount();2116-}2117-2118-function changeZoom(delta) {2119- const view = state.engine.getView();2120- const current = view.getZoom() || 0;2121- view.animate({2122- zoom: clamp(current + delta, state.variant.minZoom, viewMaxZoom(state.variant)),2123- duration: 140,2124- });2125-}2126-2127-function updateVisibleCount() {2128- const zoom = state.engine?.getView().getZoom();2129- elements.viewport.dataset.zoom = Number.isFinite(zoom) ? zoom.toFixed(3) : "";2130- if (!state.engine || !state.pins.length) {2131- elements.visibleCount.textContent = "0 locations visible";2132- return;2133- }2134- const extent = state.engine.getView().calculateExtent(state.engine.getSize());2135- let inView = 0;2136- for (const pin of state.pins) {2137- if (pinIsHidden(pin)) continue;2138- const [x, y] = pin.coordinate;2139- if (x >= extent[0] && x <= extent[2] && y >= extent[1] && y <= extent[3]) inView++;2140- }2141- elements.visibleCount.textContent =2142- `${formatNumber(state.eligibleLocations)} enabled · ${formatNumber(inView)} in view`;2143-}2144-2145-function featureOrder(left, right) {2146- return (left.get("priority") || 0) - (right.get("priority") || 0);2147-}2148-2149-function pinFeatureStyle(feature) {2150- const pin = feature.get("pin");2151- if (!pin || pinIsHidden(pin) || pin.insideHighlightedZone || isPriorityPin(pin)) return null;2152- return markerStyles(pin, false);2153-}2154-2155-function zonePinFeatureStyle(feature) {2156- const pin = feature.get("pin");2157- if (!pin || !state.highlightedZones.size || !pin.insideHighlightedZone ||2158- pinIsHidden(pin) || isPriorityPin(pin)) {2159- return null;2160- }2161- return markerStyles(pin, false);2162-}2163-2164-function pinLabelFeatureStyle(feature) {2165- const pin = feature.get("pin");2166- if (!pin || pinIsHidden(pin) || !state.pinLabelsVisible || !atMaximumNativeZoom()) return null;2167- return markerLabelStyle(pin);2168-}2169-2170-function textFeatureStyle(feature) {2171- const pin = feature.get("pin");2172- if (!pin || pinIsHidden(pin) || pin.insideHighlightedZone || isPriorityPin(pin)) return null;2173- if (atMaximumNativeZoom()) return null;2174- const minimumZoom = state.fitZoom + Math.log2(textDetailRatio(pin.category));2175- if ((state.engine.getView().getZoom() || 0) < minimumZoom) return null;2176- return textStyles(pin, false);2177-}2178-2179-function textDetailFeatureStyle(feature) {2180- const pin = feature.get("pin");2181- if (!pin || pinIsHidden(pin) || pin.insideHighlightedZone ||2182- isPriorityPin(pin) || !atMaximumNativeZoom()) {2183- return null;2184- }2185- return textStyles(pin, false);2186-}2187-2188-function zoneTextFeatureStyle(feature) {2189- const pin = feature.get("pin");2190- if (!pin || !state.highlightedZones.size || !pin.insideHighlightedZone ||2191- pinIsHidden(pin) || isPriorityPin(pin)) {2192- return null;2193- }2194- return textStyles(pin, false);2195-}2196-2197-function priorityFeatureStyle(feature) {2198- const pin = feature.get("pin");2199- if (!pin || pinIsHidden(pin)) return null;2200- if (pin.category.displayType === "text") return textStyles(pin, pin === state.selectedPin);2201- const marker = markerStyles(pin, pin === state.selectedPin);2202- if (pin === state.hoveredPin || pin === state.selectedPin) {2203- return [marker, markerLabelStyle(pin)];2204- }2205- return marker;2206-}2207-2208-function markerStyles(pin, selected) {2209- const key = `marker:${pin.category.id}:${selected ? 1 : 0}`;2210- if (state.styleCache.has(key)) return state.styleCache.get(key);2211- const color = categoryColor(pin.category);2212- const zIndex = selected ? 20_000_000 : pin.priority;2213- const renderedIcon = state.markerIcons.get(markerIconKey(pin.category));2214- let style;2215- if (renderedIcon) {2216- style = new Style({2217- image: new Icon({2218- src: renderedIcon,2219- width: selected ? 36 : 31,2220- height: selected ? 36 : 31,2221- }),2222- zIndex,2223- });2224- } else {2225- style = new Style({2226- text: new Text({2227- text: initials(pin.category.title),2228- font: `900 ${selected ? 15 : 13}px Inter, sans-serif`,2229- fill: new Fill({ color }),2230- stroke: new Stroke({ color: iconOutsetColor(), width: selected ? 4 : 3 }),2231- }),2232- zIndex,2233- });2234- }2235- state.styleCache.set(key, style);2236- return style;2237-}2238-2239-function markerLabelStyle(pin) {2240- const key = `marker-label:${pin.location.id}`;2241- if (state.styleCache.has(key)) return state.styleCache.get(key);2242- const style = new Style({2243- text: new Text({2244- text: pin.location.title,2245- offsetY: 21,2246- font: '700 10px "Arial Narrow", "Roboto Condensed", sans-serif',2247- fill: new Fill({ color: "#f4f6ed" }),2248- stroke: new Stroke({ color: "rgba(0,0,0,0.98)", width: 3 }),2249- backgroundFill: new Fill({ color: "rgba(10,13,9,0.72)" }),2250- padding: [2, 4, 2, 4],2251- overflow: true,2252- }),2253- zIndex: pin.priority,2254- });2255- state.styleCache.set(key, style);2256- return style;2257-}2258-2259-function prepareMarkerIcon(category) {2260- if (!category.iconAsset) return;2261- const key = markerIconKey(category);2262- if (state.markerIcons.has(key)) return;2263- state.markerIcons.set(key, null);2264- const source = new Image();2265- source.onload = () => {2266- const canvas = document.createElement("canvas");2267- canvas.width = 64;2268- canvas.height = 64;2269- const context = canvas.getContext("2d");2270- const color = categoryColor(category);2271-2272- // A glyph is a silhouette, so it takes the category colour. A picture2273- // already carries its own, and flattening it to one colour would leave2274- // nothing but its outline filled in.2275- const tinted = document.createElement("canvas");2276- tinted.width = 64;2277- tinted.height = 64;2278- const tintedContext = tinted.getContext("2d");2279- tintedContext.imageSmoothingEnabled = !category.iconPicture;2280- tintedContext.drawImage(source, 6, 6, 52, 52);2281- if (!category.iconPicture) {2282- tintedContext.globalCompositeOperation = "source-in";2283- tintedContext.fillStyle = color;2284- tintedContext.fillRect(0, 0, 64, 64);2285- }2286-2287- const outline = document.createElement("canvas");2288- outline.width = 64;2289- outline.height = 64;2290- const outlineContext = outline.getContext("2d");2291- outlineContext.drawImage(source, 6, 6, 52, 52);2292- outlineContext.globalCompositeOperation = "source-in";2293- outlineContext.fillStyle = iconOutsetColor();2294- outlineContext.fillRect(0, 0, 64, 64);2295-2296- for (let y = -3; y <= 3; y++) {2297- for (let x = -3; x <= 3; x++) {2298- if (x * x + y * y <= 10) context.drawImage(outline, x, y);2299- }2300- }2301- context.drawImage(tinted, 0, 0);2302- state.markerIcons.set(key, canvas.toDataURL("image/png"));2303- // A raster is keyed by asset and colour, so it stands in for every category2304- // drawn that way -- Shrine and Daedric Shrine, House and House (Ownable) --2305- // and only one of them asked for it. Every marker style is dropped rather2306- // than that category's two, because the others cached their initials while2307- // this was still loading and have nothing to tell them the icon arrived.2308- dropMarkerStyles();2309- state.layers.pins.changed();2310- state.layers.zonePins.changed();2311- state.layers.priority.changed();2312- };2313- source.onerror = () => state.markerIcons.set(key, false);2314- source.src = iconURL(category.iconAsset);2315-}2316-2317-function dropMarkerStyles() {2318- for (const key of state.styleCache.keys()) {2319- if (key.startsWith("marker:")) state.styleCache.delete(key);2320- }2321-}2322-2323-function markerIconKey(category) {2324- return `${category.iconAsset || ""}:${categoryColor(category)}:${state.map?.iconOutset || "light"}`;2325-}2326-2327-const outsetColors = {2328- light: "rgba(255, 255, 255, 0.96)",2329- dark: "rgba(7, 9, 7, 0.98)",2330-};2331-2332-function iconOutsetColor() {2333- return outsetColors[state.map?.iconOutset === "dark" ? "dark" : "light"];2334-}2335-2336-// A marker is drawn in its category's colour and edged with the map's outset,2337-// so a colour close to that outset leaves the marker with nothing to stand2338-// against. Rather than edge it the other way -- which would put a pale rim on2339-// a map that asked for dark ones -- the colour itself is taken to a lighter or2340-// darker variant of the same hue, so the legend still matches the map.2341-function legibleIconColor(color) {2342- const dark = state.map?.iconOutset === "dark";2343- const luminance = relativeLuminance(color);2344- if (dark ? luminance > 0.3 : luminance < 0.88) return color;2345- return withLightness(color, dark ? 0.74 : 0.42);2346-}2347-2348-function withLightness(color, lightness) {2349- const hex = String(color).replace("#", "");2350- if (hex.length !== 6) return color;2351- const [r, g, b] = [0, 2, 4].map((at) => parseInt(hex.slice(at, at + 2), 16) / 255);2352- const high = Math.max(r, g, b);2353- const low = Math.min(r, g, b);2354- const light = (high + low) / 2;2355- let hue = 0;2356- const chroma = high - low;2357- const saturation = chroma === 0 ? 0 : chroma / (1 - Math.abs(2 * light - 1));2358- if (chroma !== 0) {2359- if (high === r) hue = ((g - b) / chroma) % 6;2360- else if (high === g) hue = (b - r) / chroma + 2;2361- else hue = (r - g) / chroma + 4;2362- hue *= 60;2363- if (hue < 0) hue += 360;2364- }2365- const c = (1 - Math.abs(2 * lightness - 1)) * saturation;2366- const x = c * (1 - Math.abs(((hue / 60) % 2) - 1));2367- const m = lightness - c / 2;2368- const [rr, gg, bb] =2369- hue < 60 ? [c, x, 0] : hue < 120 ? [x, c, 0] : hue < 180 ? [0, c, x] :2370- hue < 240 ? [0, x, c] : hue < 300 ? [x, 0, c] : [c, 0, x];2371- const channel = (value) =>2372- Math.round((value + m) * 255).toString(16).padStart(2, "0");2373- return `#${channel(rr)}${channel(gg)}${channel(bb)}`;2374-}2375-2376-function relativeLuminance(color) {2377- const hex = String(color).replace("#", "");2378- if (hex.length !== 6) return 0.5;2379- const channel = (offset) => parseInt(hex.slice(offset, offset + 2), 16) / 255;2380- return 0.2126 * channel(0) + 0.7152 * channel(2) + 0.0722 * channel(4);2381-}2382-2383-function textStyles(pin, selected) {2384- const key = `text:${pin.location.id}:${selected ? 1 : 0}`;2385- if (state.styleCache.has(key)) return state.styleCache.get(key);2386- const style = new Style({2387- text: new Text({2388- text: pin.location.title,2389- font: `${selected ? "900" : "800"} 14px "Arial Narrow", "Roboto Condensed", sans-serif`,2390- fill: new Fill({ color: selected ? "#d6f36b" : "#f3f5e9" }),2391- stroke: new Stroke({ color: "rgba(0,0,0,0.95)", width: 4 }),2392- backgroundFill: new Fill({ color: selected ? "rgba(17,21,14,0.9)" : "rgba(10,13,9,0.58)" }),2393- backgroundStroke: selected ? new Stroke({ color: "#d6f36b", width: 1 }) : undefined,2394- padding: [3, 6, 3, 6],2395- overflow: true,2396- }),2397- zIndex: selected ? 20_000_000 : pin.priority + 3_000_000,2398- });2399- const styles = [style];2400- state.styleCache.set(key, styles);2401- return styles;2402-}2403-2404-function gridStyle(feature, resolution) {2405- const cell = feature.get("gridCell");2406- if (!cell) return null;2407- const leaf = cell.role === "leaf";2408- const scope = cell.role === "scope";2409- const neighbor = cell.role === "neighbor";2410- // Monospace, as the field these are typed into already is: a hash is a code,2411- // and in a proportional face m6w is half again the width of m6j, so a level2412- // lost its labels a few cells at a time as the map shrank. Every hash at a2413- // level is the same length, so in a fixed pitch they are the same width, and2414- // the level keeps or drops its labels as one.2415- const size = leaf || scope ? 15 : neighbor ? 10 : 11;2416- const weight = leaf || scope ? 900 : neighbor ? 750 : 800;2417- const font = `${weight} ${size}px ui-monospace, SFMono-Regular, Menlo, monospace`;2418- const padding = neighbor ? [2, 4, 2, 4] : [3, 5, 3, 5];2419- const labelled = labelFitsCell(cell, font, size, padding, resolution);2420- // A subdivision is offered so it can be named and descended into, and one too2421- // small to carry its names is a mesh laid over the map. It waits for the zoom2422- // that has room for them, so the cells and their labels arrive together --2423- // and putting the grid away by hand leaves exactly that state, the one the2424- // map arrives at on its own. What stays either way is the boundary of the2425- // chosen cell and the shaded ancestors around it, which say where the reader2426- // is and dim what is outside.2427- if (cell.role === "child" && (!labelled || !state.subgridVisible)) return null;2428- // The scope is drawn two ways: with the subgrid inside it, where a bare2429- // outline would be lost among its own children, and without, where the2430- // boundary is what is left of the cell and carries its name.2431- const bare = scope && state.subgridVisible;2432- const key = `grid:${cell.hash}:${cell.role}:${cell.contextDistance}:` +2433- `${labelled ? 1 : 0}:${bare ? 1 : 0}`;2434- if (state.styleCache.has(key)) return state.styleCache.get(key);2435- const color = palette[Math.max(0, geohashAlphabet.indexOf(cell.hash[cell.hash.length - 1])) %2436- palette.length];2437- const style = new Style({2438- fill: scope2439- ? undefined2440- : new Fill({2441- color: neighbor2442- ? `rgba(3, 5, 3, ${Math.min(0.52, 0.30 + cell.contextDistance * 0.06)})`2443- : hexToRGBA(color, leaf ? 0.14 : 0.055),2444- }),2445- stroke: new Stroke({2446- color: leaf || scope ? "#ffffff" : hexToRGBA(color, neighbor ? 0.44 : 0.82),2447- width: leaf ? 2.5 : scope ? (bare ? 1.8 : 2.5) : neighbor ? 1 : 1.4,2448- }),2449- text: labelled && !bare2450- ? new Text({2451- text: cell.hash,2452- font,2453- fill: new Fill({2454- color: leaf || scope ? "#ffffff" : neighbor ? hexToRGBA(color, 0.72) : color,2455- }),2456- stroke: new Stroke({ color: "rgba(0,0,0,0.96)", width: 4 }),2457- backgroundFill: new Fill({2458- color: neighbor ? "rgba(4,6,4,0.88)" : "rgba(9,12,8,0.76)",2459- }),2460- padding,2461- overflow: true,2462- })2463- : undefined,2464- zIndex: leaf || scope ? 100 : feature.get("priority"),2465- });2466- state.styleCache.set(key, style);2467- return style;2468-}2469-2470-// A hash names the cell it sits in, so a label wider than its cell names the2471-// neighbours instead -- and at the depth where cells are smallest, that is2472-// every label at once. The cell keeps its outline and colour; only the word2473-// waits for a zoom that has room for it.2474-function labelFitsCell(cell, font, size, padding, resolution) {2475- if (!resolution) return true;2476- const width = measureLabel(cell.hash, font) + padding[1] + padding[3];2477- const height = size + padding[0] + padding[2];2478- return width <= (cell.extent[2] - cell.extent[0]) / resolution &&2479- height <= (cell.extent[3] - cell.extent[1]) / resolution;2480-}2481-2482-const labelRuler = document.createElement("canvas").getContext("2d");2483-const labelWidths = new Map();2484-2485-function measureLabel(text, font) {2486- const key = `${font}|${text}`;2487- let width = labelWidths.get(key);2488- if (width === undefined) {2489- labelRuler.font = font;2490- width = labelRuler.measureText(text).width;2491- labelWidths.set(key, width);2492- }2493- return width;2494-}2495-2496-const zoneScrimFill = new Style({ fill: new Fill({ color: "rgba(3, 5, 3, 0.62)" }) });2497-2498-function zoneScrimStyle() {2499- return state.zonesVisible ? zoneScrimFill : null;2500-}2501-2502-function zoneStyle(feature) {2503- if (!state.zonesVisible) return null;2504- const zone = feature.get("zone");2505- const child = feature.get("child");2506- const highlighted = state.highlightedZones.has(zone.id);2507- const dimmed = zoneContextDimmed(zone.id);2508- const key = `zone:${zone.id}:${child ? 1 : 0}:${highlighted ? 1 : dimmed ? 2 : 0}`;2509- if (state.styleCache.has(key)) return state.styleCache.get(key);2510- const color = feature.get("color");2511- if (dimmed) {2512- // No fill of its own: the scrim below has already taken this zone down2513- // with the rest of the map, and a second wash would single it out again.2514- const dimmedStyle = new Style({2515- stroke: new Stroke({2516- color: hexToRGBA(color, child ? 0.34 : 0.44),2517- width: child ? 1 : 1.3,2518- lineDash: child ? [3, 4] : [7, 5],2519- }),2520- zIndex: child ? 101 : 100,2521- });2522- state.styleCache.set(key, dimmedStyle);2523- return dimmedStyle;2524- }2525- const style = new Style({2526- fill: new Fill({ color: hexToRGBA(color, child ? 0.035 : 0.07) }),2527- stroke: new Stroke({2528- color: hexToRGBA(color, child ? 0.5 : 0.72),2529- width: child ? 1.2 : 1.8,2530- lineDash: child ? [3, 4] : [7, 5],2531- }),2532- });2533- if (!highlighted) {2534- state.styleCache.set(key, style);2535- return style;2536- }2537- const highlightedStyles = [2538- new Style({2539- stroke: new Stroke({2540- color: "rgba(255,255,255,0.94)",2541- width: 5,2542- }),2543- zIndex: 9000,2544- }),2545- new Style({2546- fill: new Fill({ color: hexToRGBA(color, 0.22) }),2547- stroke: new Stroke({2548- color,2549- width: 2.6,2550- }),2551- zIndex: 9001,2552- }),2553- ];2554- state.styleCache.set(key, highlightedStyles);2555- return highlightedStyles;2556-}2557-2558-function zoneTitleStyle(feature) {2559- if (!state.zonesVisible || atMaximumNativeZoom()) return null;2560- const child = feature.get("child");2561- const highlighted = state.highlightedZones.has(feature.get("zone").id);2562- const zoom = state.engine.getView().getZoom() || 0;2563- if (!highlighted && child && zoom < state.fitZoom + 3) return null;2564- const spanPixels = feature.get("span") / state.engine.getView().getResolution();2565- if (!highlighted && state.zoneTitleCount > 40 && spanPixels < 52) return null;2566- return renderedZoneTitleStyle(feature);2567-}2568-2569-function zoneTitleDetailStyle(feature) {2570- if (!state.zonesVisible || !atMaximumNativeZoom()) return null;2571- return renderedZoneTitleStyle(feature);2572-}2573-2574-function renderedZoneTitleStyle(feature) {2575- const child = feature.get("child");2576- const zone = feature.get("zone");2577- const highlighted = state.highlightedZones.has(zone.id);2578- const dimmed = zoneContextDimmed(zone.id);2579- const key = `zone-title:${zone.id}:${child ? 1 : 0}:${highlighted ? 1 : dimmed ? 2 : 0}`;2580- if (state.styleCache.has(key)) return state.styleCache.get(key);2581- const color = feature.get("color");2582- const style = new Style({2583- text: new Text({2584- text: zone.title.toLocaleUpperCase(),2585- font: `${child ? "700 12px" : "800 14px"} "Arial Narrow", "Roboto Condensed", sans-serif`,2586- fill: new Fill({2587- color: highlighted2588- ? "#11140f"2589- : dimmed2590- ? "rgba(185,192,177,0.56)"2591- : child ? "#c7ccbd" : "#f1f4e7",2592- }),2593- stroke: new Stroke({2594- color: highlighted2595- ? "rgba(255,255,255,0.96)"2596- : dimmed ? "rgba(0,0,0,0.82)" : "rgba(0,0,0,0.95)",2597- width: highlighted ? 2 : dimmed ? 3 : 4,2598- }),2599- backgroundFill: new Fill({2600- color: highlighted ? color : dimmed ? "rgba(4,6,4,0.84)" : "rgba(11,14,10,0.72)",2601- }),2602- backgroundStroke: new Stroke({2603- color: highlighted ? "#ffffff" : hexToRGBA(color, dimmed ? 0.24 : 0.55),2604- width: highlighted ? 2 : 1,2605- }),2606- padding: [5, 8, 5, 8],2607- overflow: true,2608- }),2609- zIndex: highlighted ? 9_100_000 : feature.get("priority"),2610- });2611- state.styleCache.set(key, style);2612- return style;2613-}2614-2615-function zoneContextDimmed(zoneID) {2616- if (!state.highlightedZones.size || state.highlightedZones.has(zoneID)) return false;2617- for (const highlightedID of state.highlightedZones) {2618- if (zoneIsAncestorOf(zoneID, highlightedID)) return false;2619- }2620- return true;2621-}2622-2623-function zoneIsAncestorOf(candidateID, zoneID) {2624- const visited = new Set();2625- let parentID = state.zoneRecords.get(zoneID)?.zone.parentRegionId;2626- while (parentID != null && !visited.has(parentID)) {2627- if (parentID === candidateID) return true;2628- visited.add(parentID);2629- parentID = state.zoneRecords.get(parentID)?.zone.parentRegionId;2630- }2631- return false;2632-}2633-2634-function isPriorityPin(pin) {2635- return pin === state.selectedPin || pin === state.hoveredPin ||2636- pinInGridCell(pin) ||2637- (Boolean(state.search) && pin.location.title.toLocaleLowerCase().includes(state.search));2638-}2639-2640-function pinIsHidden(pin) {2641- return pin.filteredHidden || pinIsZoneCulled(pin) || pinIsGridCulled(pin) ||2642- !onActiveShard(pin.location);2643-}2644-2645-// A map split into layers offers one at a time. Anything belonging to another2646-// layer is elsewhere in the world, not merely filtered out.2647-function onActiveShard(item) {2648- const shard = state.variant?.shard;2649- return !shard || !item.shard || item.shard === shard;2650-}2651-2652-function pinIsZoneCulled(pin) {2653- if (!state.highlightedZones.size || pin.insideHighlightedZone) return false;2654- if (pin === state.selectedPin) return false;2655- return !(Boolean(state.search) &&2656- pin.location.title.toLocaleLowerCase().includes(state.search));2657-}2658-2659-// Descending into a cell narrows the question to what is inside it, the same2660-// way highlighting a zone does. What lies outside was still being drawn, so the2661-// answer stayed as crowded as it was before the cell was chosen.2662-function pinIsGridCulled(pin) {2663- if (!state.gridEnabled || !state.gridPrefix || pinInGridCell(pin)) return false;2664- if (pin === state.selectedPin) return false;2665- return !(Boolean(state.search) &&2666- pin.location.title.toLocaleLowerCase().includes(state.search));2667-}2668-2669-function pinPriority(category, location) {2670- const rarity = Math.max(0, 1_000_000 - Math.min(category.locations.length, 999) * 1000);2671- return rarity + (stableRank(location.id) % 1000);2672-}2673-2674-function textDetailRatio(category) {2675- if (category.locations.length > 200) return 4;2676- if (category.locations.length > 75) return 2.5;2677- return 1;2678-}2679-2680-function atMaximumNativeZoom() {2681- const zoom = state.engine?.getView().getZoom() || 0;2682- return zoom >= (state.variant?.maxZoom || 0) - 0.05;2683-}2684-2685-function stableRank(value) {2686- return Math.imul(Number(value) || 0, 2654435761) >>> 0;2687-}2688-2689-function colorFor(id) {2690- const value = Math.abs(Number(id) || 0);2691- return palette[(Math.imul(value, 2654435761) >>> 0) % palette.length];2692-}2693-2694-function hexToRGBA(value, alpha) {2695- const hex = String(value || "#ffffff").replace("#", "");2696- const expanded = hex.length === 32697- ? hex.split("").map((character) => character + character).join("")2698- : hex.slice(0, 6).padEnd(6, "f");2699- const number = Number.parseInt(expanded, 16);2700- return `rgba(${(number >> 16) & 255}, ${(number >> 8) & 255}, ${number & 255}, ${alpha})`;2701-}2702-2703-function applyCategoryVisual(element, category) {2704- element.style.setProperty("--pin-color", categoryColor(category));2705-}2706-2707-// One colour for a category wherever it is drawn, so the legend and the map2708-// agree on what it looks like.2709-function categoryColor(category) {2710- return legibleIconColor(category.color || colorFor(category.id));2711-}2712-2713-function applyCategoryGlyph(element, category, fallback) {2714- element.classList.remove("has-source-icon");2715- element.style.removeProperty("--pin-icon");2716- element.textContent = "";2717- if (!category.iconAsset) {2718- element.textContent = fallback;2719- return;2720- }2721- element.style.setProperty("--pin-icon", `url("${iconURL(category.iconAsset)}")`);2722- element.classList.add("has-source-icon");2723-}2724-2725-function iconURL(asset) {2726- const path = asset.split("/").map((segment) => encodeURIComponent(segment)).join("/");2727- return `/static/icons/${path}`;2728-}2729-2730-function initials(value) {2731- return value.split(/\s+/).slice(0, 2).map((part) => part[0] || "").join("");2732-}2733-2734-function cleanDescription(value) {2735- return String(value || "")2736- .replace(/\[([^\]]+)\]\([^)]+\)/g, "$1")2737- .replace(/[*_`>#]/g, "")2738- .replace(/\r/g, "")2739- .replace(/\n{3,}/g, "\n\n")2740- .trim();2741-}2742-2743-function formatNumber(value) {2744- return new Intl.NumberFormat().format(value);2745-}2746-2747-function clamp(value, minimum, maximum) {2748- return Math.min(maximum, Math.max(minimum, value));2749-}2750-2751-function isEditableTarget(target) {2752- return target instanceof HTMLElement &&2753- (target.matches("input, textarea, select") || target.isContentEditable);2754-}2755-2756-function exposeDiagnostics() {2757- const snapshot = () => ({2758- game: state.game?.title,2759- map: state.map?.title,2760- variant: state.variant?.name,2761- zoom: state.engine?.getView().getZoom(),2762- center: state.engine?.getView().getCenter(),2763- resolution: state.engine?.getView().getResolution(),2764- nativeMaxZoom: state.variant?.maxZoom,2765- maxZoom: state.variant ? viewMaxZoom(state.variant) : null,2766- interpolate: state.variant?.interpolate,2767- tileStats: { ...state.tileStats },2768- pins: state.pins.length,2769- eligibleLocations: state.eligibleLocations,2770- domNodes: document.querySelectorAll("*").length,2771- canvases: document.querySelectorAll("canvas").length,2772- rasterCacheSize: 64,2773- pinLabelsVisible: state.pinLabelsVisible,2774- hoveredPin: state.hoveredPin?.location.title || null,2775- selectedPin: state.selectedPin?.location.title || null,2776- fitZoom: state.fitZoom,2777- filters: {2778- hiddenCategories: [...state.hiddenCategories].sort(),2779- collapsedSections: [...state.collapsedSections].sort(),2780- },2781- ui: {2782- sidebarCollapsed: document.querySelector(".app-shell")2783- ?.classList.contains("sidebar-collapsed") ?? false,2784- detailOpen: !elements.detail.hidden,2785- detailTitle: elements.detailTitle.textContent || null,2786- searchQuery: state.search,2787- searchResultsVisible: !elements.searchResults.hidden,2788- soloChip: elements.soloChip.hidden ? null : elements.soloChip.textContent,2789- visibleCountText: elements.visibleCount.textContent,2790- overviewDocked: state.overviewDocked,2791- subgridVisible: state.subgridVisible,2792- },2793- zones: {2794- visible: state.zonesVisible,2795- count: state.zoneRecords.size,2796- focused: state.zoneRecords.get(state.focusedZoneID)?.zone.title || null,2797- highlighted: [...state.highlightedZones]2798- .map((zoneID) => state.zoneRecords.get(zoneID)?.zone.title)2799- .filter(Boolean),2800- focusedPins: state.pins.filter((pin) => !pin.filteredHidden &&2801- pin.insideHighlightedZone).length,2802- },2803- grid: {2804- enabled: state.gridEnabled,2805- prefix: state.gridPrefix,2806- maximumDepth: gridMaxDepth(),2807- extent: state.gridEnabled ? currentGridExtent() : null,2808- cells: [2809- ...state.sources.grid.getFeatures(),2810- ...state.sources.gridContext.getFeatures(),2811- ].map((feature) => feature.get("gridCell")),2812- priorityPins: state.gridPrefix2813- ? state.pins.filter((pin) => !pin.filteredHidden && pinInGridCell(pin)).length2814- : 0,2815- },2816- });2817- window.__atlasDebug = {2818- snapshot,2819- // Raster layers are reachable so a render fault can be narrowed to the2820- // complete base or the deep detail riding on top of it.2821- setLayerVisible: (name, visible) => state.layers[name]?.setVisible(visible),2822- };2823- window.render_game_to_text = () => JSON.stringify({2824- coordinateSystem: "ATLAS:PIXELS; origin top-left; x increases right; y decreases downward",2825- ...snapshot(),2826- });2827- window.advanceTime = () => state.engine?.renderSync();2828-}6+import { start } from "./src/boot.js";28297 28308 start();
A frontend/css/base.css +31 -0
A frontend/css/brand.css +46 -0
A frontend/css/category-rows.css +106 -0
@@ -0,0 +1,106 @@
1+/* A legend, not a row of buttons: symbols in a column, titles left, counts2+ right in tabular figures so they read down the page. State is carried by3+ the mark and the weight of the text, so nothing needs an outline to say it4+ is interactive. */5+.category-toggles {6+ padding: 2px 14px 10px;7+}8+9+.category-row {10+ display: grid;11+ width: 100%;12+ align-items: center;13+ grid-template-columns: 22px minmax(0, 1fr) 22px 46px;14+ gap: 8px;15+ min-height: 26px;16+ padding: 0 4px;17+ border-radius: 3px;18+ color: #7d8275;19+ cursor: pointer;20+ user-select: none;21+}22+23+.category-row.is-hovered {24+ background: rgba(255, 255, 255, 0.04);25+ color: var(--text);26+}27+28+.category-row:has(input:checked) {29+ color: #d8dccf;30+}31+32+.category-row input {33+ position: absolute;34+ width: 1px;35+ height: 1px;36+ opacity: 0;37+}38+39+.category-row:has(input:focus-visible) {40+ outline: 1px solid var(--accent);41+ outline-offset: -1px;42+}43+44+/* Unlit rather than absent: an unchecked category is still part of the key. */45+.category-row:not(:has(input:checked)) .category-icon,46+.category-row:not(:has(input:checked)) .text-symbol {47+ opacity: 0.32;48+}49+50+.category-icon {51+ display: grid;52+ width: 22px;53+ height: 22px;54+ flex: none;55+ place-items: center;56+ border: 0;57+ background: transparent;58+ color: var(--pin-color);59+ font-size: 9px;60+ font-weight: 900;61+ text-transform: uppercase;62+}63+64+.category-icon.has-source-icon::before,65+.result-dot.has-source-icon::before,66+#detail-dot.has-source-icon::before,67+.pin.has-source-icon::after {68+ display: block;69+ background: var(--pin-icon) center / contain no-repeat;70+ content: "";71+ filter: var(--icon-outset);72+}73+74+.category-icon.has-source-icon::before {75+ width: 14px;76+ height: 14px;77+ filter: var(--icon-outset);78+}79+80+.result-dot.has-source-icon,81+#detail-dot.has-source-icon {82+ border-radius: 0;83+ background: transparent;84+ box-shadow: none;85+}86+87+.result-dot.has-source-icon::before {88+ width: 16px;89+ height: 16px;90+}91+92+.category-name {93+ overflow: hidden;94+ font-size: 11px;95+ font-weight: 600;96+ text-overflow: ellipsis;97+ white-space: nowrap;98+}99+100+.category-count {101+ color: #6f7568;102+ font-size: 10px;103+ font-variant-numeric: tabular-nums;104+ text-align: right;105+}106+
A frontend/css/fatal-error.css +25 -0
A frontend/css/grid-navigator.css +99 -0
@@ -0,0 +1,99 @@
1+.grid-navigator {2+ position: absolute;3+ z-index: 8;4+ top: 17px;5+ right: 67px;6+ display: flex;7+ overflow: hidden;8+ align-items: stretch;9+ border: 1px solid var(--line-strong);10+ border-radius: 8px;11+ background: rgba(22, 25, 21, 0.94);12+ box-shadow: 0 6px 25px rgba(0, 0, 0, 0.22);13+}14+15+.grid-navigator[hidden] {16+ display: none;17+}18+19+.grid-navigator button {20+ width: 36px;21+ padding: 0;22+ border: 0;23+ border-right: 1px solid var(--line);24+ background: transparent;25+ color: var(--muted);26+ font-size: 17px;27+ cursor: pointer;28+}29+30+.grid-navigator button:hover {31+ color: var(--accent);32+}33+34+/* The subgrid toggle sits after the field it belongs to, so its rule divides it35+ from the field rather than trailing off the end of the control. */36+.subgrid-toggle {37+ display: grid;38+ border-right: 0;39+ border-left: 1px solid var(--line);40+ place-items: center;41+}42+43+.subgrid-toggle svg {44+ width: 15px;45+ fill: none;46+ stroke: currentColor;47+ stroke-linecap: round;48+ stroke-linejoin: round;49+ stroke-width: 1.3;50+}51+52+.subgrid-toggle .subgrid-toggle-slash {53+ display: none;54+}55+56+.subgrid-toggle[aria-pressed="false"] {57+ color: #6d7466;58+}59+60+.subgrid-toggle[aria-pressed="false"] .subgrid-toggle-slash {61+ display: inline;62+ stroke: currentColor;63+ stroke-width: 1.6;64+}65+66+.grid-navigator label {67+ display: flex;68+ height: 36px;69+ align-items: center;70+ gap: 7px;71+ padding: 0 9px;72+ color: var(--muted);73+ font-size: 8px;74+ font-weight: 800;75+ letter-spacing: 0.12em;76+ text-transform: uppercase;77+}78+79+.grid-navigator input {80+ width: 74px;81+ padding: 4px 6px;82+ border: 1px solid #3c4137;83+ border-radius: 4px;84+ outline: none;85+ background: #0e110d;86+ color: var(--accent);87+ font-family: ui-monospace, SFMono-Regular, Menlo, monospace;88+ font-size: 12px;89+ font-weight: 700;90+ letter-spacing: 0.08em;91+ text-transform: lowercase;92+ -webkit-user-select: text;93+ user-select: text;94+}95+96+.grid-navigator input:focus {97+ border-color: rgba(214, 243, 107, 0.68);98+}99+
A frontend/css/icon-button.css +23 -0
A frontend/css/layer-header.css +101 -0
@@ -0,0 +1,101 @@
1+.layer-header {2+ display: grid;3+ align-items: center;4+ grid-template-columns: minmax(0, 1fr) 22px 46px;5+ gap: 8px;6+ padding: 8px 18px 8px 12px;7+}8+9+.layer-title {10+ display: flex;11+ min-width: 0;12+ flex: 1;13+ align-items: center;14+ gap: 7px;15+ padding: 4px 0;16+ border: 0;17+ background: transparent;18+ color: #c8ccbd;19+ font-size: 10px;20+ font-weight: 800;21+ letter-spacing: 0.12em;22+ text-align: left;23+ text-transform: uppercase;24+ cursor: pointer;25+}26+27+.layer-title:hover {28+ color: var(--text);29+}30+31+.layer-title > span:nth-child(2) {32+ overflow: hidden;33+ text-overflow: ellipsis;34+ white-space: nowrap;35+}36+37+.layer-chevron {38+ display: grid;39+ width: 13px;40+ height: 13px;41+ flex: none;42+ place-items: center;43+ color: #6b7163;44+ transform: rotate(90deg);45+ transition: transform 140ms ease;46+}47+48+.layer-section.is-collapsed .layer-chevron {49+ transform: rotate(0deg);50+}51+52+.layer-chevron svg {53+ width: 12px;54+ fill: none;55+ stroke: currentColor;56+ stroke-linecap: round;57+ stroke-linejoin: round;58+ stroke-width: 2.4;59+}60+61+.layer-count {62+ color: var(--muted);63+ font-size: 9px;64+ font-weight: 600;65+ font-variant-numeric: tabular-nums;66+ letter-spacing: 0;67+}68+69+/* Overlaid on the count so a hovered pill never changes size: these wrap, and70+ a row that grew would push the one under the cursor out from under it. */71+/* An action in the row's own gutter, not a control laid over the count. The72+ column is reserved whether or not it is showing, so a row never changes73+ shape under the cursor. */74+.only-button {75+ display: grid;76+ justify-self: end;77+ width: 20px;78+ height: 20px;79+ padding: 0;80+ place-items: center;81+ border: 0;82+ border-radius: 3px;83+ opacity: 0;84+ background: none;85+ color: var(--accent);86+ cursor: pointer;87+ transition: opacity 110ms ease;88+}89+90+/* Driven by the pointer's position rather than by :hover -- see markHoveredRow.91+ Keyboard focus is unconditional. */92+.category-row.is-hovered .only-button,93+.layer-header.is-hovered .only-button,94+.only-button:focus-visible {95+ opacity: 1;96+}97+98+.only-button:hover {99+ background: rgba(214, 243, 107, 0.14);100+}101+
A frontend/css/layer-switch.css +46 -0
A frontend/css/layers.css +25 -0
A frontend/css/legend-toolbar.css +61 -0
A frontend/css/map-corner.css +19 -0
A frontend/css/map-hint.css +23 -0
A frontend/css/map-loading.css +46 -0
A frontend/css/map-panel.css +46 -0
A frontend/css/map-pickers.css +51 -0
A frontend/css/overview.css +93 -0
@@ -0,0 +1,93 @@
1+/* The overview earns its corner while the reader is looking for where they are,2+ and stops earning it the moment they are looking at what is underneath it. It3+ slides off to the right when put away, leaving the handle at the edge to4+ bring it back. */5+.overview-shelf {6+ display: flex;7+ align-items: center;8+ transition: transform 220ms cubic-bezier(0.22, 0.61, 0.36, 1);9+}10+11+.overview-shelf[hidden] {12+ display: none;13+}14+15+.overview-shelf.is-docked {16+ transform: translateX(calc(100% - 23px));17+}18+19+/* Put away is put away: what is left of the panel past the edge of the window20+ does not steer the map. */21+.overview-shelf.is-docked .overview {22+ pointer-events: none;23+}24+25+/* The handle is part of the panel it moves, not a control beside it: it shares26+ the panel's edge, and only the outer corners are rounded. */27+.overview-dock {28+ display: grid;29+ width: 24px;30+ height: 52px;31+ padding: 0;32+ border: 1px solid var(--line-strong);33+ border-right: 0;34+ border-radius: 8px 0 0 8px;35+ margin-right: -1px;36+ place-items: center;37+ background: rgba(22, 25, 21, 0.9);38+ box-shadow: -5px 6px 20px rgba(0, 0, 0, 0.24);39+ color: var(--muted);40+ cursor: pointer;41+}42+43+.overview-dock:hover {44+ color: var(--accent);45+}46+47+.overview-dock svg {48+ width: 13px;49+ fill: none;50+ stroke: currentColor;51+ stroke-linecap: round;52+ stroke-linejoin: round;53+ stroke-width: 1.8;54+ transition: transform 220ms cubic-bezier(0.22, 0.61, 0.36, 1);55+}56+57+.overview-shelf.is-docked .overview-dock svg {58+ transform: rotate(180deg);59+}60+61+/* Only worth the space once the whole map no longer fits on screen, which is62+ why it is hidden until then rather than always present. */63+.overview {64+ position: relative;65+ overflow: hidden;66+ border: 1px solid var(--line-strong);67+ border-radius: 8px;68+ background: rgba(22, 25, 21, 0.9);69+ box-shadow: 0 6px 25px rgba(0, 0, 0, 0.28);70+ cursor: crosshair;71+ line-height: 0;72+ /* The overview is dragged, so a touch on it steers the map rather than73+ scrolling whatever is behind it. */74+ touch-action: none;75+}76+77+.overview[hidden] {78+ display: none;79+}80+81+.overview canvas {82+ display: block;83+ opacity: 0.85;84+}85+86+.overview-viewport {87+ position: absolute;88+ border: 1px solid var(--accent);89+ border-radius: 2px;90+ background: rgba(214, 243, 107, 0.14);91+ pointer-events: none;92+}93+
A frontend/css/pin-detail.css +148 -0
@@ -0,0 +1,148 @@
1+.pin-detail {2+ position: absolute;3+ z-index: 9;4+ right: 68px;5+ bottom: 17px;6+ width: min(360px, calc(100% - 100px));7+ max-height: min(500px, calc(100% - 40px));8+ overflow: auto;9+ padding: 20px;10+ border: 1px solid var(--line-strong);11+ border-radius: 11px;12+ background: rgba(21, 24, 20, 0.96);13+ box-shadow: 0 18px 55px rgba(0, 0, 0, 0.45);14+ -webkit-user-select: text;15+ user-select: text;16+ backdrop-filter: blur(14px);17+}18+19+.pin-detail[hidden] {20+ display: none;21+}22+23+.detail-close {24+ position: absolute;25+ top: 10px;26+ right: 11px;27+ width: 29px;28+ height: 29px;29+ padding: 0;30+ border: 0;31+ border-radius: 6px;32+ background: rgba(255, 255, 255, 0.04);33+ color: var(--muted);34+ font-size: 21px;35+ cursor: pointer;36+}37+38+.detail-close:hover {39+ color: var(--text);40+}41+42+.detail-category {43+ display: flex;44+ align-items: center;45+ gap: 7px;46+ padding-right: 30px;47+ color: var(--muted);48+ font-size: 9px;49+ font-weight: 800;50+ letter-spacing: 0.12em;51+ text-transform: uppercase;52+}53+54+.detail-category #detail-dot {55+ display: grid;56+ width: 20px;57+ height: 20px;58+ flex: 0 0 20px;59+ place-items: center;60+ border-radius: 50%;61+ background: var(--pin-color);62+ color: #fff;63+ font-size: 7px;64+ letter-spacing: 0;65+}66+67+#detail-dot.has-source-icon::before {68+ width: 16px;69+ height: 16px;70+}71+72+.pin-detail h2 {73+ margin: 10px 0 11px;74+ font-family: "Arial Narrow", "Roboto Condensed", sans-serif;75+ font-size: 22px;76+ line-height: 1.12;77+}78+79+.pin-detail > p {80+ margin: 0;81+ color: #b9bdb0;82+ font-size: 12px;83+ line-height: 1.55;84+ white-space: pre-line;85+}86+87+.detail-links {88+ display: flex;89+ flex-wrap: wrap;90+ gap: 4px 14px;91+ margin-top: 12px;92+}93+94+.detail-links[hidden] {95+ display: none;96+}97+98+.detail-link {99+ overflow: hidden;100+ max-width: 100%;101+ padding: 0;102+ border: 0;103+ background: none;104+ color: var(--accent);105+ font-size: 11px;106+ font-weight: 600;107+ text-decoration: underline;108+ text-overflow: ellipsis;109+ text-underline-offset: 3px;110+ white-space: nowrap;111+ cursor: pointer;112+}113+114+.detail-link:hover {115+ color: var(--text);116+}117+118+.pin-detail dl {119+ display: grid;120+ grid-template-columns: 1fr 1fr;121+ gap: 8px;122+ margin: 17px 0 0;123+ padding-top: 13px;124+ border-top: 1px solid var(--line);125+}126+127+.pin-detail dl div {128+ min-width: 0;129+}130+131+.pin-detail dt {132+ color: #71766a;133+ font-size: 8px;134+ font-weight: 800;135+ letter-spacing: 0.1em;136+ text-transform: uppercase;137+}138+139+.pin-detail dd {140+ overflow: hidden;141+ margin: 4px 0 0;142+ color: #c6cabd;143+ font-family: ui-monospace, SFMono-Regular, Menlo, monospace;144+ font-size: 9px;145+ text-overflow: ellipsis;146+ white-space: nowrap;147+}148+
A frontend/css/responsive.css +79 -0
A frontend/css/search.css +119 -0
@@ -0,0 +1,119 @@
1+.search-wrap {2+ position: relative;3+ display: flex;4+ align-items: center;5+ margin: 0 17px 16px;6+}7+8+.search-wrap svg {9+ position: absolute;10+ left: 12px;11+ width: 16px;12+ fill: none;13+ stroke: var(--muted);14+ stroke-linecap: round;15+ stroke-width: 1.7;16+}17+18+.search-wrap input {19+ width: 100%;20+ height: 42px;21+ padding: 0 45px 0 37px;22+ border: 1px solid var(--line);23+ border-radius: 8px;24+ outline: none;25+ background: #11140f;26+ color: var(--text);27+ font-size: 13px;28+}29+30+.search-wrap input::placeholder {31+ color: #757a6e;32+}33+34+.search-wrap input:focus {35+ border-color: rgba(214, 243, 107, 0.5);36+ box-shadow: 0 0 0 3px rgba(214, 243, 107, 0.06);37+}38+39+.search-wrap kbd {40+ position: absolute;41+ right: 9px;42+ padding: 3px 5px;43+ border: 1px solid var(--line);44+ border-radius: 4px;45+ background: var(--panel-raised);46+ color: var(--muted);47+ font-family: inherit;48+ font-size: 9px;49+}50+51+.search-results {52+ z-index: 5;53+ overflow: auto;54+ max-height: 238px;55+ margin: -8px 17px 14px;56+ border: 1px solid var(--line);57+ border-radius: 8px;58+ background: #11140f;59+ box-shadow: 0 15px 35px rgba(0, 0, 0, 0.32);60+}61+62+.search-result {63+ display: grid;64+ width: 100%;65+ grid-template-columns: 22px 1fr;66+ gap: 10px;67+ padding: 10px 11px;68+ border: 0;69+ border-bottom: 1px solid var(--line);70+ background: transparent;71+ text-align: left;72+ cursor: pointer;73+}74+75+.search-result:last-child {76+ border-bottom: 0;77+}78+79+.search-result:hover {80+ background: rgba(255, 255, 255, 0.04);81+}82+83+.search-result .result-dot {84+ display: grid;85+ width: 20px;86+ height: 20px;87+ margin-top: 1px;88+ place-items: center;89+ border-radius: 50%;90+ background: var(--pin-color);91+ box-shadow: 0 0 0 3px color-mix(in srgb, var(--pin-color) 18%, transparent);92+ color: #fff;93+ font-size: 7px;94+ font-weight: 900;95+}96+97+.search-result strong,98+.search-result small {99+ display: block;100+}101+102+.search-result strong {103+ overflow: hidden;104+ font-size: 12px;105+ text-overflow: ellipsis;106+ white-space: nowrap;107+}108+109+.search-result small,110+.search-empty {111+ margin-top: 3px;112+ color: var(--muted);113+ font-size: 10px;114+}115+116+.search-empty {117+ padding: 13px;118+}119+
A frontend/css/shell.css +8 -0
A frontend/css/sidebar-footer.css +21 -0
A frontend/css/sidebar-heading.css +41 -0
A frontend/css/sidebar.css +14 -0
A frontend/css/solo-chip.css +31 -0
A frontend/css/text-symbol.css +13 -0
A frontend/css/tokens.css +27 -0
A frontend/css/tooltip.css +37 -0
A frontend/css/topbar-collapse.css +14 -0
A frontend/css/topbar.css +12 -0
A frontend/css/zone-index.css +59 -0
A frontend/css/zoom-controls.css +36 -0
A frontend/src/boot.js +37 -0
@@ -0,0 +1,37 @@
1+import { elements, populateSelect } from "./dom.js";2+import { state } from "./state.js";3+import { bindUIEvents } from "./events.js";4+import { initializeMap } from "./engine.js";5+import { readRoute, readSession } from "./session.js";6+import { selectGame } from "./navigation.js";7+import { exposeDiagnostics } from "./diagnostics.js";8+9+export async function start() {10+ bindUIEvents();11+ try {12+ const response = await fetch("/static/catalog.json");13+ if (!response.ok) throw new Error(`catalog request returned ${response.status}`);14+ state.catalog = await response.json();15+ if (!state.catalog.games.length) throw new Error("the embedded catalog contains no maps");16+ initializeMap();17+ populateSelect(elements.game, state.catalog.games, "title");18+ const route = readRoute();19+ const session = readSession();20+ // An address naming somewhere else was typed on purpose, so it wins and21+ // arrives clean; anything else resumes where the reader left off.22+ const resuming = session &&23+ (!route.game || (route.game === session.game && route.map === session.map));24+ state.restore = resuming ? session : null;25+ await selectGame(26+ route.game || session?.game || state.catalog.games[0].slug,27+ route.map || session?.map,28+ );29+ state.restore = null;30+ exposeDiagnostics();31+ requestAnimationFrame(() => elements.viewport.focus({ preventScroll: true }));32+ } catch (error) {33+ elements.loading.hidden = true;34+ elements.fatalMessage.textContent = error instanceof Error ? error.message : String(error);35+ elements.fatal.hidden = false;36+ }37+}
A frontend/src/catalog.js +68 -0
@@ -0,0 +1,68 @@
1+import { state } from "./state.js";2+import { legendSections } from "./legend.js";3+4+// A map arrives in two pieces: its layers, categories and regions as JSON, and5+// its locations packed as parallel arrays. Nothing here is fetched until the6+// map is opened, so the catalog can grow without the wait growing with it.7+export async function loadMap(entry) {8+ const [detail, packed] = await Promise.all([9+ fetch(`/static/catalog/${entry.id}.json`).then((r) => r.json()),10+ fetch(`/static/catalog/${entry.id}.bin`).then((r) => r.arrayBuffer()),11+ ]);12+ const categories = detail.groups.flatMap((group) => group.categories);13+ unpackLocations(packed, categories);14+ return {15+ ...entry,16+ variants: detail.variants,17+ groups: detail.groups,18+ zones: detail.zones || [],19+ sections: legendSections(detail.groups),20+ };21+}22+23+// The reader of packLocations. Each field is a view straight onto the buffer,24+// laid out so no copying or realignment is needed to get at it.25+export function unpackLocations(buffer, categories) {26+ const view = new DataView(buffer);27+ const magic = String.fromCharCode(...new Uint8Array(buffer, 0, 8));28+ if (magic !== "ATLASLOC") throw new Error("location payload is not in the expected form");29+ const version = view.getUint16(8, true);30+ if (version !== 2) throw new Error(`location payload is version ${version}, and this reads 2`);31+ const count = view.getUint32(10, true);32+33+ let at = 16;34+ const ids = new Int32Array(buffer, at, count);35+ const latitudes = new Float32Array(buffer, (at += count * 4), count);36+ const longitudes = new Float32Array(buffer, (at += count * 4), count);37+ const regions = new Int32Array(buffer, (at += count * 4), count);38+ const shards = new Int32Array(buffer, (at += count * 4), count);39+ const offsets = new Uint32Array(buffer, (at += count * 4), count + 1);40+ const owners = new Uint16Array(buffer, (at += (count + 1) * 4), count);41+ const titles = new Uint8Array(buffer, at + count * 2);42+43+ const decoder = new TextDecoder();44+ for (const category of categories) category.locations = [];45+ for (let index = 0; index < count; index++) {46+ categories[owners[index]].locations.push({47+ id: ids[index],48+ title: decoder.decode(titles.subarray(offsets[index], offsets[index + 1])),49+ lat: latitudes[index],50+ lng: longitudes[index],51+ regionId: regions[index] || undefined,52+ shard: shards[index] || undefined,53+ });54+ }55+}56+57+// Descriptions and cross-references are half the catalog by weight and are read58+// one pin at a time, so a map's are fetched the first time one of its pins is59+// opened, and not at all if none ever is.60+export async function mapText(mapID) {61+ if (!state.textByMap.has(mapID)) {62+ state.textByMap.set(63+ mapID,64+ fetch(`/static/catalog/${mapID}.text`).then((r) => r.json()).catch(() => ({})),65+ );66+ }67+ return state.textByMap.get(mapID);68+}
A frontend/src/constants.js +27 -0
A frontend/src/detail.js +98 -0

Not shown: this page already shows 6000 lines of diff.

A frontend/src/diagnostics.js +78 -0

Not shown: this page already shows 6000 lines of diff.

A frontend/src/dom.js +55 -0

Not shown: this page already shows 6000 lines of diff.

A frontend/src/engine.js +274 -0

Not shown: this page already shows 6000 lines of diff.

A frontend/src/events.js +265 -0

Not shown: this page already shows 6000 lines of diff.

A frontend/src/grid.js +231 -0

Not shown: this page already shows 6000 lines of diff.

A frontend/src/legend.js +271 -0

Not shown: this page already shows 6000 lines of diff.

A frontend/src/navigation.js +315 -0

Not shown: this page already shows 6000 lines of diff.

A frontend/src/overview.js +134 -0

Not shown: this page already shows 6000 lines of diff.

A frontend/src/pins.js +163 -0

Not shown: this page already shows 6000 lines of diff.

A frontend/src/search.js +43 -0

Not shown: this page already shows 6000 lines of diff.

A frontend/src/session.js +60 -0

Not shown: this page already shows 6000 lines of diff.

A frontend/src/state.js +43 -0

Not shown: this page already shows 6000 lines of diff.

A frontend/src/styles.js +456 -0

Not shown: this page already shows 6000 lines of diff.

A frontend/src/theme.js +98 -0

Not shown: this page already shows 6000 lines of diff.

A frontend/src/util.js +25 -0

Not shown: this page already shows 6000 lines of diff.

A frontend/src/zones.js +239 -0

Not shown: this page already shows 6000 lines of diff.