Attributes now ride every level of the pipeline: a translator declares what it knows -- how a category renders, in the registered vocabulary -- the generator speaks for captures that predate the conventions from the same rules that used to be unwritten, and the whole game is held to the registry before a bundle is written. The manifest declares the vocabulary it was written against, and validation is stricter about a bundle that declares than one that does not: attributes must be registered, the render attribute must agree with the legacy field it will one day retire, a declared standard icon must have been resolved. The viewer's one display rule -- the string compare on displayType that four files each held a copy of -- becomes one function reading the attribute first and falling back to the legacy field, so bundles from before the conventions draw exactly as they always did. Location attributes ship in the text file beside descriptions, read when a card opens; the packed payload is untouched, and every regenerated map's pins are byte-identical to the build before, which is the whole point: the same data, now saying what it means.
- commit
- 3477b5c020e255ab0fd015ce5574c217532ad379
- parent
- 63d39fd0573cdbea31ca3bd129e712b2bea04264
- author
- Dami <dami.etoile@gmail.com>
| M | assets/ | 16 | ++-- |
| M | frontend/ | 1 | + |
| M | frontend/ | 3 | +- |
| M | frontend/ | 5 | +- |
| M | frontend/ | 5 | +- |
| A | frontend/ | 19 | +++++ |
| M | frontend/ | 3 | +- |
| M | internal/ | 8 | ++ |
| M | internal/ | 69 | ++++++++++++++++- |
| M | internal/ | 2 | + |
| M | internal/ | 48 | ++++++----- |
| M | internal/ | 6 | + |
| M | internal/ | 2 | + |
| M | tools/ | 5 | +- |
| M | tools/ | 126 | ++++++++++++++++++++++++------ |
| M | tools/ | 12 | ++- |
@@ -1,9 +1,9 @@
1-(()=>{var hu=n=>new Promise(t=>setTimeout(t,n)),yt=n=>document.querySelector(n);async function Um(){for(let n=0;n<300&&!(window.__atlasDebug&&!yt("#map-loading")?.checkVisibility?.());n+=1)await hu(100)}async function Ym(){let n="";for(let t=0;t<100;t+=1){await hu(120),await new Promise(r=>requestAnimationFrame(r)),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 Ii(n,t={}){window.dispatchEvent(new KeyboardEvent("keydown",{key:n,bubbles:!0,cancelable:!0,...t}))}function Km(n,t={}){window.dispatchEvent(new KeyboardEvent("keyup",{key:n,bubbles:!0,cancelable:!0,...t}))}function Zm(n){yt("#map").dispatchEvent(new KeyboardEvent("keydown",{key:n,bubbles:!0,cancelable:!0}))}function en(n,t){n.value=t,n.dispatchEvent(new Event("change",{bubbles:!0}))}function Ca(n,t){let e=yt(n);e.value=t,e.dispatchEvent(new Event("input",{bubbles:!0}))}function va(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 Bm(){let n=[],t=async f=>{await Ym(),n.push({name:f,snapshot:JSON.parse(window.render_game_to_text())})};await Um(),localStorage.clear();let e=yt("#game-select"),i=e.options[0].value;en(e,i),await t("initial"),Ca("#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")),Ca("#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")),Ii("g"),await t("grid-open"),Ca("#grid-input","m"),await t("grid-descended"),Ii(" "),await t("subgrid-hidden"),Ii(" "),Ii("Escape"),await t("grid-ascended"),Ii("Escape"),await t("grid-closed"),Ii("z"),await t("labels-on"),Km("z"),await t("labels-off"),Ii("b",{metaKey:!0}),await t("sidebar-collapsed"),Ii("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"),Zm("Escape"),await t("viewport-escape");let c=yt("#variant-select");c.options.length>1&&(en(c,c.options[1].value),await t("variant-second"),en(c,c.options[0].value),await t("variant-first"));let d=yt("#map-select");return d.options.length>1&&(en(d,d.options[1].value),await t("map-second"),en(d,d.options[0].value),await t("map-first")),e.options.length>1&&(en(e,e.options[1].value),await t("game-second"),en(e,i),await t("game-first")),localStorage.clear(),{viewport:[window.innerWidth,window.innerHeight],steps:n}}var Sa=!1;async function uu(){if(!Sa){Sa=!0,va("parity tour running\u2026");try{let n=await Bm(),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}`);va(`parity tour complete \u2713 ${n.steps.length} steps`),console.log("parity tour saved to",e)}catch(n){va(`parity tour failed: ${n}`,!0),console.error("parity tour failed",n)}finally{Sa=!1}}}window.__atlasTour=uu;window.addEventListener("keydown",n=>{n.key==="F9"&&uu()});var k=n=>document.querySelector(n),w={game:k("#game-select"),map:k("#map-select"),variant:k("#variant-select"),variantField:k("#variant-field"),legend:k("#legend"),search:k("#pin-search"),searchResults:k("#dock-results"),dock:k("#dock"),dockCount:k("#dock-count"),dockFlag:k("#dock-flag"),dockFold:k("#dock-fold"),dockRailName:k("#dock-rail-name"),visibleCount:k("#visible-count"),viewport:k("#map"),layers:k("#layers"),zoneToggle:k("#zone-toggle"),zoneCount:k("#zone-count"),zoneIndex:k("#zone-index"),zoneList:k("#zone-list"),loading:k("#map-loading"),labelsHint:k("#labels-hint"),gridHint:k("#grid-hint"),soloChip:k("#solo-chip"),overview:k("#overview"),overviewShelf:k("#overview-shelf"),overviewDock:k("#overview-dock"),overviewCanvas:k("#overview-canvas"),overviewViewport:k("#overview-viewport"),gridNavigator:k("#grid-navigator"),gridInput:k("#grid-input"),gridBack:k("#grid-back"),subgridToggle:k("#subgrid-toggle"),detail:k("#pin-detail"),detailTitle:k("#detail-title"),detailCategory:k("#detail-category"),detailDescription:k("#detail-description"),detailID:k("#detail-id"),detailCoordinates:k("#detail-coordinates"),detailCell:k("#detail-cell"),detailCellField:k("#detail-cell-field"),detailSource:k("#detail-source"),detailSourceField:k("#detail-source-field"),detailLinks:k("#detail-links"),detailDot:k("#detail-dot"),sidebar:k("#sidebar"),mobileLegend:k("#mobile-legend"),fatal:k("#fatal-error"),fatalMessage:k("#fatal-message"),emptyState:k("#empty-state"),emptyPath:k("#empty-path"),emptyOpen:k("#empty-open"),addBundles:k("#add-bundles")};function nn(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,labelsHeld:!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,dockFolded:!0,dockDismissed:!1,renderedShard:0,mapRun:0,textByMap:new Map,restore:null,settling:!1,styleCache:new Map,markerIcons:new Map};var Mn=["#4fb3d5","#c9924b","#82b56a","#c96a6a","#9581cc","#4bc9a9","#d4b04a","#6a92c9","#b08a5a","#8fb3a2"],ae="0123456789bcdefghjkmnpqrstuvwxyz";var Ra="atlas.session";var du={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 Ta(n){let t=ut();for(let e=0,i=n.length;e<i;++e)on(t,n[e]);return t}function Vm(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 Pn(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 Ps(n,t){return t?(t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t):n.slice()}function bi(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 Lr(n,t[0],t[1])}function Fe(n,t){return n[0]<=t[0]&&t[2]<=n[2]&&n[1]<=t[1]&&t[3]<=n[3]}function Lr(n,t,e){return n[0]<=t&&t<=n[2]&&n[1]<=e&&e<=n[3]}function Ms(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 rn(n){return Qt(1/0,1/0,-1/0,-1/0,n)}function Os(n,t){let e=n[0],i=n[1];return Qt(e,i,e,i,t)}function On(n,t,e,i,r){let s=rn(r);return Ia(s,n,t,e,i)}function sn(n,t){return n[0]==t[0]&&n[2]==t[2]&&n[1]==t[1]&&n[3]==t[3]}function Ds(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 on(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 Ia(n,t,e,i,r){for(;e<i;e+=r)jm(n,t[e],t[e+1]);return n}function jm(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 ks(n,t){let e;return e=t(Dn(n)),e||(e=t(kn(n)),e)||(e=t(Fn(n)),e)||(e=t(le(n)),e)?e:!1}function Ar(n){let t=0;return ze(n)||(t=j(n)*ct(n)),t}function Dn(n){return[n[0],n[1]]}function kn(n){return[n[2],n[1]]}function Bt(n){return[(n[0]+n[2])/2,(n[1]+n[3])/2]}function fu(n,t){let e;if(t==="bottom-left")e=Dn(n);else if(t==="bottom-right")e=kn(n);else if(t==="top-left")e=le(n);else if(t==="top-right")e=Fn(n);else throw new Error("Invalid corner");return e}function Mr(n,t,e,i,r){let[s,o,a,l,h,c,d,f]=ba(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 ba(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 Ne(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]):rn(i),i}function La(n,t){if(!ht(n,t))return[n.slice()];if(Fe(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 le(n){return[n[0],n[3]]}function Fn(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 ze(n){return n[2]<n[0]||n[3]<n[1]}function gu(n,t){return t?(t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t):n}function mu(n,t,e){let i=!1,r=Ms(n,t),s=Ms(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 pu(n,t,e,i){if(ze(n))return rn(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 Vm(s,o,e)}function Aa(n,t){let e=t.getExtent(),i=Bt(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 Fs(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]]];Aa(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 _u(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(...La(e[o],t[i]));e=s}return e}var yu={info:1,warn:2,error:3,none:4},Hm=yu.info;function Ns(...n){Hm>yu.warn||console.warn(...n)}function et(n,t,e){return Math.min(Math.max(n,t),e)}function xu(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 Eu(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 zs(n){return n*180/Math.PI}function ye(n){return n*Math.PI/180}function Ge(n,t){let e=n%t;return e*t<0?e+t:e}function zt(n,t,e){return n+e*(t-n)}function an(n,t){let e=Math.pow(10,t);return Math.round(n*e)/e}function Pr(n,t){return Math.floor(an(n,t))}function Or(n,t){return Math.ceil(an(n,t))}function Gs(n,t,e){if(n>=t&&n<e)return n;let i=e-t;return((n-t)%i+i)%i+t}function wu(n,t){return n[0]+=+t[0],n[1]+=+t[1],n}function ln(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 Nn(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 Cu(n,t){return n[0]*=t,n[1]*=t,n}function Xs(n,t){if(t.canWrapX()){let e=j(t.getExtent()),i=vu(n,t,e);i&&(n[0]-=i*e)}return n}function vu(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 Su(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 Ma=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_}},Li=Ma;var Dr=6378137,zn=Math.PI*Dr,qm=[-zn,-zn,zn,zn],$m=[-180,-85,180,85],Ws=Dr*Math.log(Math.tan(Math.PI/2)),Ai=class extends Li{constructor(t){super({code:t,units:"m",extent:qm,global:!0,worldExtent:$m,getPointResolution:function(e,i){return e/Math.cosh(i[1]/Dr)}})}},Pa=[new Ai("EPSG:3857"),new Ai("EPSG:102100"),new Ai("EPSG:102113"),new Ai("EPSG:900913"),new Ai("http://www.opengis.net/def/crs/EPSG/0/3857"),new Ai("http://www.opengis.net/gml/srs/epsg.xml#3857")];function Ru(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]=zn*n[s]/180;let o=Dr*Math.log(Math.tan(Math.PI*(+n[s+1]+90)/360));o>Ws?o=Ws:o<-Ws&&(o=-Ws),t[s+1]=o}return t}function Tu(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]/zn,t[s+1]=360*Math.atan(Math.exp(n[s+1]/Dr))/Math.PI-90;return t}var Jm=6378137,Iu=[-180,-90,180,90],Qm=Math.PI*Jm/180,oi=class extends Li{constructor(t,e){super({code:t,units:"degrees",extent:Iu,axisOrientation:e,global:!0,metersPerUnit:Qm,worldExtent:Iu})}},Oa=[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 Da={};function bu(n){return Da[n]||Da[n.replace(/urn:(x-)?ogc:def:crs:EPSG:(.*:)?(\w+)$/,"EPSG:$3")]||null}function Lu(n,t){Da[n]=t}function Xe(n){for(let t in n)delete n[t]}function xe(n){let t;for(t in n)return!1;return!t}var Gn={};function Xn(n,t,e){let i=n.getCode(),r=t.getCode();i in Gn||(Gn[i]={}),Gn[i][r]=e}function Us(n,t){return n in Gn&&t in Gn[n]?Gn[n][t]:null}var Ys=.9996,ce=.00669438,Zs=ce*ce,Bs=Zs*ce,cn=ce/(1-ce),Au=Math.sqrt(1-ce),Wn=(1-Au)/(1+Au),Du=Wn*Wn,ka=Du*Wn,Fa=ka*Wn,ku=Fa*Wn,Fu=1-ce/4-3*Zs/64-5*Bs/256,tp=3*ce/8+3*Zs/32+45*Bs/1024,ep=15*Zs/256+45*Bs/1024,ip=35*Bs/3072,np=3/2*Wn-27/32*ka+269/512*ku,rp=21/16*Du-55/32*Fa,sp=151/96*ka-417/128*ku,op=1097/512*Fa,Ks=6378137;function ap(n,t,e){let i=n-5e5,o=(e.north?t:t-1e7)/Ys/(Ks*Fu),a=o+np*Math.sin(2*o)+rp*Math.sin(4*o)+sp*Math.sin(6*o)+op*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-ce*h,_=Math.sqrt(1-ce*h),p=Ks/_,y=(1-ce)/m,E=cn*c**2,v=E*E,x=i/(p*Ys),C=x*x,T=C*x,A=T*x,R=A*x,I=R*x,b=a-d/y*(C/2-A/24*(5+3*f+10*E-4*v-9*cn))+I/720*(61+90*f+298*E+45*g-252*cn-3*v),z=(x-T/6*(1+2*f+E)+R/120*(5-2*E+28*f-3*v+8*cn+24*g))/c;return z=Gs(z+ye(Nu(e.number)),-Math.PI,Math.PI),[zs(z),zs(b)]}var Mu=-80,Pu=84,lp=-180,cp=180;function hp(n,t,e){n=Gs(n,lp,cp),t<Mu?t=Mu:t>Pu&&(t=Pu);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=Nu(e.number),d=ye(c),f=Ks/Math.sqrt(1-ce*r**2),g=cn*s**2,m=s*Gs(h-d,-Math.PI,Math.PI),_=m*m,p=_*m,y=p*m,E=y*m,v=E*m,x=Ks*(Fu*i-tp*Math.sin(2*i)+ep*Math.sin(4*i)-ip*Math.sin(6*i)),C=Ys*f*(m+p/6*(1-a+g)+E/120*(5-18*a+l+72*g-58*cn))+5e5,T=Ys*(x+f*o*(_/2+y/24*(5-a+9*g+4*g**2)+v/720*(61-58*a+l+600*g-330*cn)));return e.north||(T+=1e7),[C,T]}function Nu(n){return(n-1)*6-180+3}var up=[/^EPSG:(\d+)$/,/^urn:ogc:def:crs:EPSG::(\d+)$/,/^http:\/\/www\.opengis\.net\/def\/crs\/EPSG\/0\/(\d+)$/];function zu(n){let t=0;for(let r of up){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 Ou(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 Gu(n){return zu(n)?new Li({code:n,units:"m"}):null}function Xu(n){let t=zu(n.getCode());return t?{forward:Ou(hp,t),inverse:Ou(ap,t)}:null}var dp=63710088e-1;function Na(n,t,e){e=e||dp;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 fp=[Xu],gp=[Gu];var Ga=!0;function Uu(n){Ga=!(n===void 0?!0:n)}function Wa(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 Xa(n){Lu(n.getCode(),n),Xn(n,n,Wa)}function mp(n){n.forEach(Xa)}function Et(n){if(typeof n!="string")return n;let t=bu(n);if(t)return t;for(let e of gp){let i=e(n);if(i)return i}return null}function Ua(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=hn(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=Na(h.slice(0,2),h.slice(2,4)),d=Na(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 Wu(n){mp(n),n.forEach(function(t){n.forEach(function(e){t!==e&&Xn(t,e,Wa)})})}function pp(n,t,e,i){n.forEach(function(r){t.forEach(function(s){Xn(r,s,e),Xn(s,r,i)})})}function Vs(n,t){return n?typeof n=="string"?Et(n):n:Et(t)}function Yu(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 Un(n,t){if(n===t)return!0;let e=n.getUnits()===t.getUnits();return(n.getCode()===t.getCode()||hn(n,t)===Wa)&&e}function hn(n,t){let e=n.getCode(),i=t.getCode(),r=Us(e,i);if(r)return r;let s=null,o=null;for(let l of fp)s||(s=l(n)),o||(o=l(t));if(!s&&!o)return null;let a="EPSG:4326";if(o)if(s)r=za(s.inverse,o.forward);else{let l=Us(e,a);l&&(r=za(l,o.forward))}else{let l=Us(a,i);l&&(r=za(s.inverse,l))}return r&&(Xa(n),Xa(t),Xn(n,t,r)),r}function za(n,t){return function(e,i,r,s){return i=n(e,i,r,s),t(i,i,r,s)}}function un(n,t){let e=Et(n),i=Et(t);return hn(e,i)}function Yn(n,t,e){let i=un(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 Ku(n,t,e,i){let r=un(t,e);return pu(n,r,void 0,i)}var Ee=null;function dn(){return Ee}function kr(n,t){return Ee?Yn(n,t,Ee):n}function we(n,t){return Ee?Yn(n,Ee,t):(Ga&&!ln(n,[0,0])&&n[0]>=-180&&n[0]<=180&&n[1]>=-90&&n[1]<=90&&(Ga=!1,Ns("Call useGeographic() from ol/proj once to work with [longitude, latitude] coordinates.")),n)}function Mi(n,t){return Ee?Ku(n,t,Ee):n}function Ce(n,t){return Ee?Ku(n,Ee,t):n}function Zu(n,t){if(!Ee)return n;let e=Et(t).getMetersPerUnit(),i=Ee.getMetersPerUnit();return e&&i?n*e/i:n}function _p(){Wu(Pa),Wu(Oa),pp(Oa,Pa,Ru,Tu)}_p();function Ya(n){return n[0]>0&&n[1]>0}function Bu(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 js=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 fn(n,t,e,i,r){return r!==void 0?(r.minX=n,r.maxX=t,r.minY=e,r.maxY=i,r):new js(n,t,e,i)}var Hs=js;function Vu(n,t,e){let i,r;e=e||Vt;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 Vt(n,t){return n>t?1:n<t?-1:0}function ju(n,t){return n<t?1:n>t?-1:0}function Kn(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 Hu(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 qu(n,t,e){let i=t||Vt;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 B(n,t){if(!n)throw new Error(t)}function $u(n,t,e,i,r){return!ks(r,function(o){return!Pi(n,t,e,i,o[0],o[1])})}function Pi(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 Fr(n,t,e,i,r,s){if(e.length===0||!Pi(n,t,e[0],i,r,s))return!1;for(let o=1,a=e.length;o<a;++o)if(Pi(n,e[o-1],e[o],i,r,s))return!1;return!0}function Ju(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(Fr(n,t,l,i,r,s))return!0;t=l[l.length-1]}return!1}function Qu(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 qs(n,t,e,i,r,s){return s=s??Ia(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:Qu(n,t,e,i,function(o,a){return mu(r,o,a)}):!1}function Ka(n,t,e,i,r){return!!(qs(n,t,e,i,r)||Pi(n,t,e,i,r[0],r[1])||Pi(n,t,e,i,r[0],r[3])||Pi(n,t,e,i,r[2],r[1])||Pi(n,t,e,i,r[2],r[3]))}function Za(n,t,e,i,r){if(!Ka(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($u(n,e[s-1],e[s],i,r)&&!qs(n,e[s-1],e[s],i,r))return!1;return!0}function td(n,t,e,i,r){for(let s=0,o=e.length;s<o;++s){let a=e[s];if(Za(n,t,a,i,r))return!0;t=a[a.length-1]}return!1}function H(){throw new Error("Unimplemented abstract method.")}var yp=0;function Y(n){return n.ol_uid||(n.ol_uid=String(++yp))}function Zn(n,t,e,i){return i!==void 0?(i[0]=n,i[1]=t,i[2]=e,i):[n,t,e]}function xp(n,t,e){return n+"/"+t+"/"+e}function Bn(n,t,e,i,r){return`${Y(n)},${t},${xp(e,i,r)}`}function ed(n){return Ep(n[0],n[1],n[2])}function Ep(n,t,e){return(t<<n)+e}function id(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 Vn=[0,0,0],Oi=5,Ba=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,B(qu(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,B(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_=le(s)),B(!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,B(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,B(!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 Hs(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=fn(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 fn(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 fn(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 fn(h,h,c,c,i);let d=Math.floor(l*(s+1))-1,f=Math.floor(l*(o+1))-1;return fn(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,Vn);let r=Vn[1],s=Vn[2];this.getTileCoordForXYAndZ_(t[2],t[1],e,!0,Vn);let o=Vn[1],a=Vn[2];return fn(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=Or(c,Oi)-1,d=Or(d,Oi)-1):(c=Pr(c,Oi),d=Pr(d,Oi)),Zn(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=Or(h,Oi)-1,c=Or(c,Oi)-1):(h=Pr(h,Oi),c=Pr(c,Oi)),Zn(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=Kn(this.resolutions_,t,e||0);return et(i,this.minZoom,this.maxZoom)}tileCoordIntersectsViewport(t,e){return Ka(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}},Nr=Ba;function $s(n){let t=n.getDefaultTileGrid();return t||(t=Cp(n),n.setDefaultTileGrid(t)),t}function rd(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 wp(n,t,e,i){i=i!==void 0?i:"top-left";let r=od(n,t,e);return new Nr({extent:n,origin:fu(n,i),resolutions:r,tileSize:e})}function sd(n){let t=n||{},e=t.extent||Et("EPSG:3857").getExtent(),i={extent:e,minZoom:t.minZoom,tileSize:t.tileSize,resolutions:od(e,t.maxZoom,t.tileSize,t.maxResolution)};return new Nr(i)}function od(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 Cp(n,t,e,i){let r=Js(n);return wp(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 jn(n,t,e,i){return Z(n,t,e,i,!0)}function J(n){n&&n.target&&(n.target.removeEventListener(n.type,n.listener),Xe(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 Va=class{constructor(){this.disposed=!1}dispose(){this.disposed||(this.disposed=!0,this.disposeInternal())}disposeInternal(){}},Di=Va;function ai(){return!0}function li(){return!1}function ci(){}function Qs(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 ad(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 ja=class{constructor(t){this.propagationStopped,this.defaultPrevented,this.type=t,this.target=null}preventDefault(){this.defaultPrevented=!0}stopPropagation(){this.propagationStopped=!0}};var Lt=ja;var Ha=class extends Di{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_&&Xe(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]))}},ki=Ha;var gn=typeof navigator<"u"&&typeof navigator.userAgent<"u"?navigator.userAgent.toLowerCase():"",vp=gn.includes("safari")&&!gn.includes("chrom"),G0=vp&&(gn.includes("version/15.4")||/cpu (os|iphone os) 15_4 like mac os x/.test(gn)),ld=gn.includes("webkit")&&!gn.includes("edge"),qa=gn.includes("macintosh"),cd=typeof devicePixelRatio<"u"?devicePixelRatio:1,Rt=typeof WorkerGlobalScope<"u"&&typeof OffscreenCanvas<"u"&&self instanceof WorkerGlobalScope,$a=typeof Image<"u"&&Image.prototype.decode;var to=(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 hd(n,t,e){let i=n,r=!0,s=!1,o=!1,a=[jn(i,P.LOAD,function(){o=!0,s||t()})];return i.src&&$a?(s=!0,i.decode().then(function(){r&&t()}).catch(function(l){r&&(o?t():e())})):a.push(jn(i,P.ERROR,e)),function(){r=!1,a.forEach(J)}}function Sp(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 ud(n,t){return t&&(n.src=t),n.src&&$a?new Promise((e,i)=>n.decode().then(()=>e(n)).catch(r=>n.complete&&n.width?e(n):i(r))):Sp(n)}var D={IDLE:0,LOADING:1,LOADED:2,ERROR:3,EMPTY:4};function Ja(n){return Math.pow(n,3)}function he(n){return 1-Ja(1-n)}function dd(n){return 3*n*n-2*n*n*n}function fd(n){return n}var Qa=class extends ki{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:Ja(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()}},Hn=Qa;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 tl;function zr(){return tl||(tl=nt(1,1)),tl}function mn(n){let t=n.canvas;t.width=1,t.height=1,n.clearRect(0,0,1,1)}function el(n,t){let e=t.parentNode;e&&e.replaceChild(n,t)}function gd(n){for(;n.lastChild;)n.lastChild.remove()}function md(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 eo(){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 il=class extends Hn{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_=Rp(),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_=hd(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 Rp(){let n=nt(1,1);return n.fillStyle="rgba(0,0,0,0)",n.fillRect(0,0,1,1),n.canvas}var io=il;var nl,pn=[];function pd(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 rl(n,t){return Math.abs(n[t*4]-210)>2||Math.abs(n[t*4+3]-.75*255)>2}function Tp(){if(nl===void 0){let n=nt(6,6,pn);n.globalCompositeOperation="lighter",n.fillStyle="rgba(210, 0, 0, 0.75)",pd(n,4,5,4,0),pd(n,4,5,0,5);let t=n.getImageData(0,0,3,3).data;nl=rl(t,0)||rl(t,4)||rl(t,8),mn(n),pn.push(n.canvas)}return nl}function _d(n,t,e,i){let r=Yn(e,t,n),s=Ua(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=Ua(n,s,r)/s;isFinite(h)&&h>0&&(s/=h)}return s}function yd(n,t,e,i){let r=Bt(e),s=_d(n,t,r,i);return(!isFinite(s)||s<=0)&&ks(e,function(o){return s=_d(n,t,o,i),isFinite(s)&&s>0}),s}function xd(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),pn);if(d||(m.imageSmoothingEnabled=!1),l.length===0)return m.canvas;m.scale(e,e);function _(C){return Math.round(C*e)/e}m.globalCompositeOperation="lighter";let p=ut();l.forEach(function(C,T,A){Ds(p,C.extent)});let y,E=e/i,v=(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),pn),d||(y.imageSmoothingEnabled=!1),r&&g){let C=(r[0]-p[0])*E,T=-(r[3]-p[3])*E,A=j(r)*E,R=ct(r)*E;y.rect(C,T,A,R),y.clip()}l.forEach(function(C,T,A){if(C.image.width>0&&C.image.height>0){if(C.clipExtent){y.save();let X=(C.clipExtent[0]-p[0])*E,N=-(C.clipExtent[3]-p[3])*E,V=j(C.clipExtent)*E,lt=ct(C.clipExtent)*E;y.rect(d?X:Math.round(X),d?N:Math.round(N),d?V:Math.round(X+V)-Math.round(X),d?lt:Math.round(N+lt)-Math.round(N)),y.clip()}let R=(C.extent[0]-p[0])*E,I=-(C.extent[3]-p[3])*E,b=j(C.extent)*E,z=ct(C.extent)*E;y.drawImage(C.image,h,h,C.image.width-2*h,C.image.height-2*h,d?R:Math.round(R),d?I:Math.round(I),d?b:Math.round(R+b)-Math.round(R),d?z:Math.round(I+z)-Math.round(I)),C.clipExtent&&y.restore()}})}let x=le(o);return a.getTriangles().forEach(function(C,T,A){let R=C.source,I=C.target,b=R[0][0],z=R[0][1],X=R[1][0],N=R[1][1],V=R[2][0],lt=R[2][1],M=_((I[0][0]-x[0])/s),W=_(-(I[0][1]-x[1])/s),O=_((I[1][0]-x[0])/s),$=_(-(I[1][1]-x[1])/s),G=_((I[2][0]-x[0])/s),tt=_(-(I[2][1]-x[1])/s),it=b,Ct=z;b=0,z=0,X-=it,N-=Ct,V-=it,lt-=Ct;let L=[[X,N,0,0,O-M],[V,lt,0,0,G-M],[0,0,X,N,$-W],[0,0,V,lt,tt-W]],Jt=Eu(L);if(!Jt)return;if(m.save(),m.beginPath(),Tp()||!d){m.moveTo(O,$);let ot=4,Oe=M-O,$i=W-$;for(let re=0;re<ot;re++)m.lineTo(O+_((re+1)*Oe/ot),$+_(re*$i/(ot-1))),re!=ot-1&&m.lineTo(O+_((re+1)*Oe/ot),$+_((re+1)*$i/(ot-1)));m.lineTo(G,tt)}else m.moveTo(O,$),m.lineTo(M,W),m.lineTo(G,tt);m.clip(),m.transform(Jt[0],Jt[2],Jt[1],Jt[3],M,W),m.translate(p[0]-it,p[3]-Ct);let vt;if(y)vt=y.canvas,m.scale(v,-v);else{let ot=l[0],Oe=ot.extent;vt=ot.image,m.scale(j(Oe)/vt.width,-ct(Oe)/vt.height)}m.drawImage(vt,0,0),m.restore()}),y&&(mn(y),pn.push(y.canvas)),c&&(m.save(),m.globalCompositeOperation="source-over",m.strokeStyle="black",m.lineWidth=1,a.getTriangles().forEach(function(C,T,A){let R=C.target,I=(R[0][0]-x[0])/s,b=-(R[0][1]-x[1])/s,z=(R[1][0]-x[0])/s,X=-(R[1][1]-x[1])/s,N=(R[2][0]-x[0])/s,V=-(R[2][1]-x[1])/s;m.beginPath(),m.moveTo(z,X),m.lineTo(I,b),m.lineTo(N,V),m.closePath(),m.stroke()}),m.restore()),m.canvas}var Ip=[1,0,0,1,0,0],mE=new Array(6);function At(){return Ip.slice(0)}function Ed(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 ro(n,t){let e=bp(t);B(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 bp(n){return n[0]*n[3]-n[1]*n[2]}var Lp=[1e5,1e5,1e5,1e5,2,2];function wd(n){return"matrix("+n.join(", ")+")"}function no(n){return n.substring(7,n.length-1).split(",").map(parseFloat)}function Cd(n,t){let e=no(n),i=no(t);for(let r=0;r<6;++r)if(Math.round((e[r]-i[r])*Lp[r])!==0)return!1;return!0}var Ap=10,vd=.25,sl=class{constructor(t,e,i,r,s,o,a){this.sourceProj_=t,this.targetProj_=e;let l={},h=a?Yu(v=>dt(a,Yn(v,this.targetProj_,this.sourceProj_))):un(this.targetProj_,this.sourceProj_);this.transformInv_=function(v){let x=v[0]+"/"+v[1];return l[x]||(l[x]=h(v)),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=le(i),d=Fn(i),f=kn(i),g=Dn(i),m=this.transformInv_(c),_=this.transformInv_(d),p=this.transformInv_(f),y=this.transformInv_(g),E=Ap+(o?Math.max(0,Math.ceil(Math.log2(Ar(i)/(o*o*256*256)))):0);if(this.addQuad_(c,d,f,g,m,_,p,y,E),this.wrapsXInSource_){let v=1/0;this.triangles_.forEach(function(x,C,T){v=Math.min(v,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])-v>this.sourceWorldWidth_/2){let C=[[x.source[0][0],x.source[0][1]],[x.source[1][0],x.source[1][1]],[x.source[2][0],x.source[2][1]]];C[0][0]-v>this.sourceWorldWidth_/2&&(C[0][0]-=this.sourceWorldWidth_),C[1][0]-v>this.sourceWorldWidth_/2&&(C[1][0]-=this.sourceWorldWidth_),C[2][0]-v>this.sourceWorldWidth_/2&&(C[2][0]-=this.sourceWorldWidth_);let T=Math.min(C[0][0],C[1][0],C[2][0]);Math.max(C[0][0],C[1][0],C[2][0])-T<this.sourceWorldWidth_/2&&(x.source=C)}})}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=Ta([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=Ta([t,e,i,r]);m=j(p)/this.targetWorldWidth_>vd||m}!g&&this.sourceProj_.isGlobal()&&d&&(m=d>vd||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=(Ge(s[0],f)+Ge(a[0],f))/2-Ge(y[0],f):E=(s[0]+a[0])/2-y[0];let v=(s[1]+a[1])/2-y[1];m=E*E+v*v>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],v=this.transformInv_(E);this.addQuad_(t,e,p,E,s,o,y,v,h-1),this.addQuad_(E,p,i,r,v,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],v=this.transformInv_(E);this.addQuad_(t,p,E,r,s,y,v,l,h-1),this.addQuad_(p,e,i,E,y,o,a,v,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;on(t,s[0]),on(t,s[1]),on(t,s[2])}),t}getTriangles(){return this.triangles_}},Sd=sl;var ol=class extends Hn{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?Ne(g,m):g;if(Ar(p)===0){this.state=D.EMPTY;return}let y=t.getExtent();y&&(_?_=Ne(_,y):_=y);let E=r.getResolution(this.wrappedTileCoord_[0]),v=yd(t,i,p,E);if(!isFinite(v)||v<=0){this.state=D.EMPTY;return}let x=c!==void 0?c:.5;if(this.triangulation_=new Sd(t,i,p,_,v*x,E),this.triangulation_.getTriangles().length===0){this.state=D.EMPTY;return}this.sourceZ_=e.getZForResolution(v);let C=this.triangulation_.calculateSourceExtent();if(_&&(t.canWrapX()?(C[1]=et(C[1],_[1],_[3]),C[3]=et(C[3],_[1],_[3])):C=Ne(C,_)),!Ar(C))this.state=D.EMPTY;else{let T=0,A=0;t.canWrapX()&&(T=j(y),A=Math.floor((C[0]-y[0])/T)),Fs(C.slice(),t,!0).forEach(I=>{let b=e.getTileRangeForExtentAndZ(I,this.sourceZ_);for(let z=b.minX;z<=b.maxX;z++)for(let X=b.minY;X<=b.maxY;X++){let N=A*T;this.sourceTiles_.push({getTile:()=>h(this.sourceZ_,z,X,a),offset:N})}++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_=xd(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_&&(mn(this.canvas_.getContext("2d")),pn.push(this.canvas_),this.canvas_=null),this.sourceTiles_.length=0,super.release()}},so=ol;var Mp=/\{z\}/g,Pp=/\{x\}/g,Op=/\{y\}/g,Dp=/\{-y\}/g;function Rd(n,t,e,i,r){return n.replace(Mp,t.toString()).replace(Pp,e.toString()).replace(Op,i.toString()).replace(Dp,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 Td(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 kp(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 Rd(n,o,e[1],e[2],s)})}function Id(n,t){let e=n.length,i=new Array(e);for(let r=0;r<e;++r)i[r]=kp(n[r],t);return Fp(i)}function Fp(n){return n.length===1?n[0]:(function(t,e,i){if(!t)return;let r=ed(t),s=Ge(r,n.length);return n[s](t,e,i)})}var Se={PROPERTYCHANGE:"propertychange"};var qn=class extends ki{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]=jn(this,t[s],e)}else i=jn(this,t,e);return e.ol_key=i,i}unInternal(t,e){let i=e.ol_key;if(i)Np(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)}};qn.prototype.on;qn.prototype.once;qn.prototype.un;function Np(n){if(Array.isArray(n))for(let t=0,e=n.length;t<e;++t)J(n[t]);else J(n)}var oo=qn;var ao=class extends Lt{constructor(t,e,i){super(t),this.key=e,this.oldValue=i}},al=class extends oo{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 ao(i,t,e)),i=Se.PROPERTYCHANGE,this.hasListener(i)&&this.dispatchEvent(new ao(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=al;var ll=class extends wt{constructor(t){super(),this.projection=Et(t.projection),this.attributions_=bd(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_=bd(t),this.changed()}setState(t){this.state_=t,this.changed()}};function bd(n){return n?typeof n=="function"?n:(Array.isArray(n)||(n=[n]),t=>n):null}var lo=ll;var cl=class extends lo{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:$s(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:Bu(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=rd(r,t,i)),id(t,r)?t:null}clear(){}refresh(){this.clear(),super.refresh()}},co=class extends Lt{constructor(t,e){super(t),this.tile=e}},Ld=cl;var ho={TILELOADSTART:"tileloadstart",TILELOADEND:"tileloadend",TILELOADERROR:"tileloaderror"};var hl=class n extends Ld{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=ho.TILELOADSTART):i in this.tileLoadingKeys_&&(delete this.tileLoadingKeys_[i],s=r==D.ERROR?ho.TILELOADERROR:r==D.LOADED?ho.TILELOADEND:void 0),s!=null&&this.dispatchEvent(new co(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=Td(t);this.urls=e,this.setUrls(e)}setUrls(t){this.urls=t;let e=t.join(`2-`);this.generateTileUrlFunction_?this.setTileUrlFunction(Id(t,this.tileGrid),e):this.setKey(e)}tileUrlFunction(t,e,i){}},Ad=hl;var ul=class extends Ad{constructor(t){super({attributions:t.attributions,cacheSize:t.cacheSize,projection:t.projection,state:t.state,tileGrid:t.tileGrid,tileLoadFunction:t.tileLoadFunction?t.tileLoadFunction:zp,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:io,this.tileGridForProjection={},this.reprojectionErrorThreshold_=t.reprojectionErrorThreshold,this.renderReprojectionEdges_=!1}getGutterForProjection(t){return this.getProjection()&&t&&!Un(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||Un(e,t)))return this.tileGrid;let i=Y(t);return i in this.tileGridForProjection||(this.tileGridForProjection[i]=$s(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||Un(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 so(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=Bn(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 zp(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 Md=ul;var dl=class extends Md{constructor(t){t=t||{};let e=t.projection!==void 0?t.projection:"EPSG:3857",i=t.tileGrid!==void 0?t.tileGrid:sd({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_}},Pd=dl;function Re(){if(!u.map||!u.variant||u.settling)return;let n=u.engine?.getView();try{let t=Od();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,dockFolded:u.dockFolded,dockDismissed:u.dockDismissed},localStorage.setItem(Ra,JSON.stringify(t))}catch{}}function Od(){try{let n=JSON.parse(localStorage.getItem(Ra)||"null");if(n&&n.games)return n}catch{}return{last:"",games:{}}}function $n(n){let t=Od(),e=n||t.last,i=e&&t.games[e];return i&&i.game&&i.map?i:null}function Jn(){let[n,t]=decodeURIComponent(location.hash.replace(/^#\/?/,"")).split("/").map(e=>e.trim());return{game:n,map:t}}function Dd(){if(!u.game||!u.map)return;let n=`#${u.game.slug}/${u.map.slug}`;location.hash!==n&&history.replaceState(null,"",n)}var fl=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?Gp(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 Gp(n){if(typeof n=="function")return n;let t;return Array.isArray(n)?t=n:(B(typeof n.getZIndex=="function","Expected an `ol/style/Style` or an array of `ol/style/Style.js`"),t=[n]),function(){return t}}var Fi=fl;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 uo(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 kd(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 Fd(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 Nd=At(),Xp=[NaN,NaN],gl=class extends wt{constructor(){super(),this.extent_=ut(),this.extentRevision_=-1,this.simplifiedGeometryMaxMinSquaredTolerance=0,this.simplifiedGeometryRevision=0,this.simplifyTransformedInternal=Qs((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,Xp,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]))&&rn(e),this.extentRevision_=this.getRevision()}return gu(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(Nd,h[0],h[3],c,-c,0,0,0);let d=jt(s,0,s.length,a,Nd,o),f=un(i,e);return f?f(d,d,a):d}:un(i,e);return this.applyTransform(r),this}},zd=gl;var ml=class extends zd{constructor(){super(),this.layout="XY",this.stride=2,this.flatCoordinates}computeExtent(t){return On(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=Gd(t),this.layout=t,this.flatCoordinates=e}setCoordinates(t,e){H()}setLayout(t,e,i){let r;if(t)r=Gd(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=Wp(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();uo(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 s=this.getStride();kd(r,0,r.length,s,t,e,i,r),this.changed()}}translate(t,e){let i=this.getFlatCoordinates();if(i){let r=this.getStride();Fd(i,0,i.length,r,t,e,i),this.changed()}}};function Wp(n){let t;return n==2?t="XY":n==3?t="XYZ":n==4&&(t="XYZM"),t}function Gd(n){let t;return n=="XY"?t=2:n=="XYZ"||n=="XYM"?t=3:n=="XYZM"&&(t=4),t}function Xd(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 We=ml;function Wd(n,t,e,i){for(let r=0,s=e.length;r<s;++r)n[t++]=e[r];return t}function Gr(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 pl(n,t,e,i,r){r=r||[];let s=0;for(let o=0,a=e.length;o<a;++o){let l=Gr(n,t,e[o],i);r[s++]=l,t=l}return r.length=s,r}function Ud(n,t,e,i,r){r=r||[];let s=0;for(let o=0,a=e.length;o<a;++o){let l=pl(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 _l=class n extends We{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 Os(this.flatCoordinates,t)}getType(){return"Point"}intersectsExtent(t){return Lr(t,this.flatCoordinates[0],this.flatCoordinates[1])}setCoordinates(t,e){this.setLayout(e,t,0),this.flatCoordinates||(this.flatCoordinates=[]),this.flatCoordinates.length=Wd(this.flatCoordinates,0,t,this.stride),this.changed()}},hi=_l;function yl(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 xl(n,t,e,i){let r=0;for(let s=0,o=e.length;s<o;++s){let a=e[s];r+=yl(n,t,a,i),t=a}return r}function Yd(n,t,e,i){let r=0;for(let s=0,o=e.length;s<o;++s){let a=e[s];r+=xl(n,t,a,i),t=a[a.length-1]}return r}function Kd(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 El(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 wl(n,t,e,i,r){for(let s=0,o=e.length;s<o;++s){let a=e[s];r=El(n,t,a,i,r),t=a}return r}function Zd(n,t,e,i,r){for(let s=0,o=e.length;s<o;++s){let a=e[s];r=wl(n,t,a,i,r),t=a[a.length-1]}return r}function Cl(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(Kd(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&&(Kd(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 vl(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=Cl(n,t,g,i,r,s,o,a,l,h,c),t=g}return h}function Bd(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=vl(n,t,g,i,r,s,o,a,l,h,c),t=g[g.length-1]}return h}function Ue(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 Qn(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++]=Ue(n,t,l,i,r[s]),t=l}return r.length=s,r}function Xr(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?[]:Qn(n,t,l,i,r[s]),t=l[l.length-1]}return r.length=s,r}function Wr(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 v=n[E],x=n[E+1],C=xu(v,x,m,_,p,y);C>g&&(c=E,g=C)}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 Vd(n,t,e,i,r,s,o,a){for(let l=0,h=e.length;l<h;++l){let c=e[l];o=Wr(n,t,c,i,r,s,o),a.push(o),t=c}return o}function Ni(n,t){return t*Math.round(n/t)}function Up(n,t,e,i,r,s,o){if(t==e)return o;let a=Ni(n[t],r),l=Ni(n[t+1],r);t+=i,s[o++]=a,s[o++]=l;let h,c;do if(h=Ni(n[t],r),c=Ni(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=Ni(n[t],r),f=Ni(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 Ur(n,t,e,i,r,s,o,a){for(let l=0,h=e.length;l<h;++l){let c=e[l];o=Up(n,t,c,i,r,s,o),a.push(o),t=c}return o}function jd(n,t,e,i,r,s,o,a){for(let l=0,h=e.length;l<h;++l){let c=e[l],d=[];o=Ur(n,t,c,i,r,s,o,d),a.push(d),t=c[c.length-1]}return o}var Sl=class n extends We{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<bi(this.getExtent(),t,e)?r:(this.maxDeltaRevision_!=this.getRevision()&&(this.maxDelta_=Math.sqrt(El(this.flatCoordinates,0,this.flatCoordinates.length,this.stride,0)),this.maxDeltaRevision_=this.getRevision()),Cl(this.flatCoordinates,0,this.flatCoordinates.length,this.stride,this.maxDelta_,!0,t,e,i,r))}getArea(){return yl(this.flatCoordinates,0,this.flatCoordinates.length,this.stride)}getCoordinates(){return Ue(this.flatCoordinates,0,this.flatCoordinates.length,this.stride)}getSimplifiedGeometryInternal(t){let e=[];return e.length=Wr(this.flatCoordinates,0,this.flatCoordinates.length,this.stride,t,e,0),new n(e,"XY")}getType(){return"LinearRing"}intersectsExtent(t){return qs(this.flatCoordinates,0,this.flatCoordinates.length,this.stride,t)}setCoordinates(t,e){this.setLayout(e,t,1),this.flatCoordinates||(this.flatCoordinates=[]),this.flatCoordinates.length=Gr(this.flatCoordinates,0,t,this.stride),this.changed()}},Rl=Sl;function Yr(n,t,e,i,r,s,o){let a,l,h,c,d,f,g,m=r[s+1],_=[];for(let E=0,v=e.length;E<v;++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(Vt),c=_[0],a=1,l=_.length;a<l;++a){d=_[a];let E=Math.abs(d-c);E>y&&(h=(c+d)/2,Fr(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=Yr(n,t,l,i,r,2*o,s),t=l[l.length-1]}return s}function Hd(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 Tl(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 Il(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=Tl(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 qd(n,t,e,i,r){for(let s=0,o=e.length;s<o;++s){let a=e[s];if(!Il(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=Tl(n,t,a,i);(s===0?r&&l||!r&&!l:r&&!l||!r&&l)&&Hd(n,t,a,i),t=a}return t}function bl(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 $d(n,t){let e=[],i=0,r=0,s;for(let o=0,a=t.length;o<a;++o){let l=t[o],h=Tl(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 We{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<bi(this.getExtent(),t,e)?r:(this.maxDeltaRevision_!=this.getRevision()&&(this.maxDelta_=Math.sqrt(wl(this.flatCoordinates,0,this.ends_,this.stride,0)),this.maxDeltaRevision_=this.getRevision()),vl(this.flatCoordinates,0,this.ends_,this.stride,this.maxDelta_,!0,t,e,i,r))}containsXY(t,e){return Fr(this.getOrientedFlatCoordinates(),0,this.ends_,this.stride,t,e)}getArea(){return xl(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,Qn(e,0,this.ends_,this.stride)}getEnds(){return this.ends_}getFlatInteriorPoint(){if(this.flatInteriorPointRevision_!=this.getRevision()){let t=Bt(this.getExtent());this.flatInteriorPoint_=Yr(this.getOrientedFlatCoordinates(),0,this.ends_,this.stride,t,0),this.flatInteriorPointRevision_=this.getRevision()}return this.flatInteriorPoint_}getInteriorPoint(){return new hi(this.getFlatInteriorPoint(),"XYM")}getLinearRingCount(){return this.ends_.length}getLinearRing(t){return t<0||this.ends_.length<=t?null:new Rl(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 Rl(e.slice(s,l),t);r.push(h),s=l}return r}getOrientedFlatCoordinates(){if(this.orientedRevision_!=this.getRevision()){let t=this.flatCoordinates;Il(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=Ur(this.flatCoordinates,0,this.ends_,this.stride,Math.sqrt(t),e,0,i),new n(e,"XY",i)}getType(){return"Polygon"}intersectsExtent(t){return Za(this.getOrientedFlatCoordinates(),0,this.ends_,this.stride,t)}setCoordinates(t,e){this.setLayout(e,t,2),this.flatCoordinates||(this.flatCoordinates=[]);let i=pl(this.flatCoordinates,0,t,this.stride,this.ends_);this.flatCoordinates.length=i.length===0?0:i[i.length-1],this.changed()}},Ye=mo;function Ll(n){if(ze(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 Jd(){let n=u.variant?.surface;return n?[n.x,-(n.y+n.height),n.x+n.width,-n.y]:ui()}function Qd(n){return n.key.toLocaleLowerCase()==="g"?(n.preventDefault(),tf(),u.gridEnabled?(w.gridInput.focus(),w.gridInput.select()):w.viewport.focus({preventScroll:!0}),!0):n.key===" "&&u.gridEnabled&&n.target!==w.subgridToggle?(n.preventDefault(),Kr(!u.subgridVisible),!0):n.key==="Escape"&&u.gridEnabled?(n.preventDefault(),Al(),!0):!1}function tf(n=!u.gridEnabled){u.gridEnabled=n,n&&Kr(!0),_o(),Ke(),u.layers.pins.changed(),u.layers.text.changed(),u.layers.priority.changed()}function Kr(n){u.subgridVisible=n,u.layers.grid.changed(),u.layers.gridContext.changed(),w.subgridToggle.setAttribute("aria-pressed",String(n)),w.subgridToggle.setAttribute("aria-label",n?"Hide the subgrid":"Show the subgrid"),ef()}function ef(){if(!u.gridEnabled){w.gridHint.textContent="G \xB7 grid off";return}w.gridHint.textContent=`G-${u.gridPrefix||"root"}`+(u.subgridVisible?"":" no subgrid")}function Zr(n){let t=_n(),e=[...n.toLocaleLowerCase()].filter(r=>ae.includes(r)).slice(0,t).join(""),i=e!==u.gridPrefix;u.gridPrefix=e,u.gridEnabled||(u.gridEnabled=!0),_o(),Ke(),u.layers.pins.changed(),u.layers.text.changed(),u.layers.priority.changed(),i&&(Te(),u.engine.getView().fit(tr(),{size:u.engine.getSize(),padding:[52,52,52,52],maxZoom:Ze(u.variant),duration:180}))}function Al(){if(u.gridEnabled){if(!u.gridPrefix){tf(!1);return}Zr(u.gridPrefix.slice(0,-1))}}function _o(){if(!u.sources||(u.sources.grid.clear(),u.sources.gridContext.clear(),w.gridNavigator.hidden=!u.gridEnabled,ef(),!u.gridEnabled||!u.variant))return;let n=_n();if(w.gridInput.maxLength=n,w.gridInput.value=u.gridPrefix,w.gridBack.title=u.gridPrefix?"Back one geohash level":"Close geohash grid",Kp(),u.gridPrefix.length>=n){po(u.gridPrefix,tr(),"leaf");return}u.gridPrefix&&po(u.gridPrefix,tr(),"scope");for(let t of ae){let e=u.gridPrefix+t;po(e,Ml(e),"child")}}function Kp(){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 ae){let r=t+i;r!==e&&po(r,Ml(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 Fi({geometry:new Ye([[[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+ae.indexOf(n[n.length-1]):ae.indexOf(n[n.length-1])});(e==="neighbor"?u.sources.gridContext:u.sources.grid).addFeature(h)}function tr(){return Ml(u.gridPrefix)}function Ml(n){let t=[...Jd()],e=!0;for(let i of n){let r=ae.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 _n(){return 3}function nf(n,t=_n()){let e=[...Jd()],[i,r]=n;if(i<e[0]||i>e[2]||r<e[1]||r>e[3])return"";let s=!0,o="";for(let a=0;a<t;a++){let l=0;for(let h of[16,8,4,2,1]){if(s){let c=(e[0]+e[2])/2;i>=c?(l|=h,e[0]=c):e[2]=c}else{let c=(e[1]+e[3])/2;r>=c?(l|=h,e[1]=c):e[3]=c}s=!s}o+=ae[l]}return o}function er(n){if(!u.gridEnabled||!u.gridPrefix)return!1;let t=tr(),[e,i]=n.coordinate;return e>=t[0]&&e<=t[2]&&i>=t[1]&&i<=t[3]}function Br(){return du[u.map?.iconOutset==="dark"?"dark":"light"]}function Zp(n){let t=u.map?.iconOutset==="dark",e=Vp(n);return(t?e>.3:e<.88)?n:Bp(n,t?.74:.42)}function Bp(n,t){let e=String(n).replace("#","");if(e.length!==6)return n;let[i,r,s]=[0,2,4].map(v=>parseInt(e.slice(v,v+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=v=>Math.round((v+m)*255).toString(16).padStart(2,"0");return`#${E(_)}${E(p)}${E(y)}`}function Vp(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 yo(n){let t=Math.abs(Number(n)||0);return Mn[(Math.imul(t,2654435761)>>>0)%Mn.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 ir(n,t){n.style.setProperty("--pin-color",Vr(t))}function Vr(n){return Zp(n.color||yo(n.id))}function nr(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("${Pl(t.iconAsset)}")`),n.classList.add("has-source-icon")}function Pl(n){let t=n.split("/").map(e=>encodeURIComponent(e)).join("/");return`${u.game.base}/icons/${t}`}function zi(n){return n.split(/\s+/).slice(0,2).map(t=>t[0]||"").join("")}function rf(n){return Math.imul(Number(n)||0,2654435761)>>>0}function sf(n){return String(n||"").replace(/\[([^\]]+)\]\([^)]+\)/g,"$1").replace(/[*_`>#]/g,"").replace(/\r/g,"").replace(/\n{3,}/g,`1+(()=>{var uu=n=>new Promise(t=>setTimeout(t,n)),yt=n=>document.querySelector(n);async function Ym(){for(let n=0;n<300&&!(window.__atlasDebug&&!yt("#map-loading")?.checkVisibility?.());n+=1)await uu(100)}async function Km(){let n="";for(let t=0;t<100;t+=1){await uu(120),await new Promise(r=>requestAnimationFrame(r)),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 bi(n,t={}){window.dispatchEvent(new KeyboardEvent("keydown",{key:n,bubbles:!0,cancelable:!0,...t}))}function Zm(n,t={}){window.dispatchEvent(new KeyboardEvent("keyup",{key:n,bubbles:!0,cancelable:!0,...t}))}function Bm(n){yt("#map").dispatchEvent(new KeyboardEvent("keydown",{key:n,bubbles:!0,cancelable:!0}))}function nn(n,t){n.value=t,n.dispatchEvent(new Event("change",{bubbles:!0}))}function va(n,t){let e=yt(n);e.value=t,e.dispatchEvent(new Event("input",{bubbles:!0}))}function Sa(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 Vm(){let n=[],t=async f=>{await Km(),n.push({name:f,snapshot:JSON.parse(window.render_game_to_text())})};await Ym(),localStorage.clear();let e=yt("#game-select"),i=e.options[0].value;nn(e,i),await t("initial"),va("#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")),va("#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")),bi("g"),await t("grid-open"),va("#grid-input","m"),await t("grid-descended"),bi(" "),await t("subgrid-hidden"),bi(" "),bi("Escape"),await t("grid-ascended"),bi("Escape"),await t("grid-closed"),bi("z"),await t("labels-on"),Zm("z"),await t("labels-off"),bi("b",{metaKey:!0}),await t("sidebar-collapsed"),bi("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"),Bm("Escape"),await t("viewport-escape");let c=yt("#variant-select");c.options.length>1&&(nn(c,c.options[1].value),await t("variant-second"),nn(c,c.options[0].value),await t("variant-first"));let d=yt("#map-select");return d.options.length>1&&(nn(d,d.options[1].value),await t("map-second"),nn(d,d.options[0].value),await t("map-first")),e.options.length>1&&(nn(e,e.options[1].value),await t("game-second"),nn(e,i),await t("game-first")),localStorage.clear(),{viewport:[window.innerWidth,window.innerHeight],steps:n}}var Ra=!1;async function du(){if(!Ra){Ra=!0,Sa("parity tour running\u2026");try{let n=await Vm(),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}`);Sa(`parity tour complete \u2713 ${n.steps.length} steps`),console.log("parity tour saved to",e)}catch(n){Sa(`parity tour failed: ${n}`,!0),console.error("parity tour failed",n)}finally{Ra=!1}}}window.__atlasTour=du;window.addEventListener("keydown",n=>{n.key==="F9"&&du()});var k=n=>document.querySelector(n),w={game:k("#game-select"),map:k("#map-select"),variant:k("#variant-select"),variantField:k("#variant-field"),legend:k("#legend"),search:k("#pin-search"),searchResults:k("#dock-results"),dock:k("#dock"),dockCount:k("#dock-count"),dockFlag:k("#dock-flag"),dockFold:k("#dock-fold"),dockRailName:k("#dock-rail-name"),visibleCount:k("#visible-count"),viewport:k("#map"),layers:k("#layers"),zoneToggle:k("#zone-toggle"),zoneCount:k("#zone-count"),zoneIndex:k("#zone-index"),zoneList:k("#zone-list"),loading:k("#map-loading"),labelsHint:k("#labels-hint"),gridHint:k("#grid-hint"),soloChip:k("#solo-chip"),overview:k("#overview"),overviewShelf:k("#overview-shelf"),overviewDock:k("#overview-dock"),overviewCanvas:k("#overview-canvas"),overviewViewport:k("#overview-viewport"),gridNavigator:k("#grid-navigator"),gridInput:k("#grid-input"),gridBack:k("#grid-back"),subgridToggle:k("#subgrid-toggle"),detail:k("#pin-detail"),detailTitle:k("#detail-title"),detailCategory:k("#detail-category"),detailDescription:k("#detail-description"),detailID:k("#detail-id"),detailCoordinates:k("#detail-coordinates"),detailCell:k("#detail-cell"),detailCellField:k("#detail-cell-field"),detailSource:k("#detail-source"),detailSourceField:k("#detail-source-field"),detailLinks:k("#detail-links"),detailDot:k("#detail-dot"),sidebar:k("#sidebar"),mobileLegend:k("#mobile-legend"),fatal:k("#fatal-error"),fatalMessage:k("#fatal-message"),emptyState:k("#empty-state"),emptyPath:k("#empty-path"),emptyOpen:k("#empty-open"),addBundles:k("#add-bundles")};function rn(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,labelsHeld:!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,dockFolded:!0,dockDismissed:!1,renderedShard:0,mapRun:0,textByMap:new Map,restore:null,settling:!1,styleCache:new Map,markerIcons:new Map};var Pn=["#4fb3d5","#c9924b","#82b56a","#c96a6a","#9581cc","#4bc9a9","#d4b04a","#6a92c9","#b08a5a","#8fb3a2"],ae="0123456789bcdefghjkmnpqrstuvwxyz";var Ta="atlas.session";var fu={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 Ia(n){let t=ut();for(let e=0,i=n.length;e<i;++e)an(t,n[e]);return t}function jm(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 On(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 Os(n,t){return t?(t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t):n.slice()}function Li(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 Ar(n,t[0],t[1])}function Fe(n,t){return n[0]<=t[0]&&t[2]<=n[2]&&n[1]<=t[1]&&t[3]<=n[3]}function Ar(n,t,e){return n[0]<=t&&t<=n[2]&&n[1]<=e&&e<=n[3]}function Ps(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 sn(n){return Qt(1/0,1/0,-1/0,-1/0,n)}function Ds(n,t){let e=n[0],i=n[1];return Qt(e,i,e,i,t)}function Dn(n,t,e,i,r){let s=sn(r);return ba(s,n,t,e,i)}function on(n,t){return n[0]==t[0]&&n[2]==t[2]&&n[1]==t[1]&&n[3]==t[3]}function ks(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 an(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 ba(n,t,e,i,r){for(;e<i;e+=r)Hm(n,t[e],t[e+1]);return n}function Hm(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 Fs(n,t){let e;return e=t(kn(n)),e||(e=t(Fn(n)),e)||(e=t(Nn(n)),e)||(e=t(le(n)),e)?e:!1}function Mr(n){let t=0;return ze(n)||(t=j(n)*ct(n)),t}function kn(n){return[n[0],n[1]]}function Fn(n){return[n[2],n[1]]}function Bt(n){return[(n[0]+n[2])/2,(n[1]+n[3])/2]}function gu(n,t){let e;if(t==="bottom-left")e=kn(n);else if(t==="bottom-right")e=Fn(n);else if(t==="top-left")e=le(n);else if(t==="top-right")e=Nn(n);else throw new Error("Invalid corner");return e}function Pr(n,t,e,i,r){let[s,o,a,l,h,c,d,f]=La(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 La(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 Ne(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]):sn(i),i}function Aa(n,t){if(!ht(n,t))return[n.slice()];if(Fe(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 le(n){return[n[0],n[3]]}function Nn(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 ze(n){return n[2]<n[0]||n[3]<n[1]}function mu(n,t){return t?(t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t):n}function pu(n,t,e){let i=!1,r=Ps(n,t),s=Ps(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 _u(n,t,e,i){if(ze(n))return sn(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 jm(s,o,e)}function Ma(n,t){let e=t.getExtent(),i=Bt(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 Ns(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]]];Ma(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 yu(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(...Aa(e[o],t[i]));e=s}return e}var xu={info:1,warn:2,error:3,none:4},qm=xu.info;function zs(...n){qm>xu.warn||console.warn(...n)}function et(n,t,e){return Math.min(Math.max(n,t),e)}function Eu(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 wu(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 Gs(n){return n*180/Math.PI}function ye(n){return n*Math.PI/180}function Ge(n,t){let e=n%t;return e*t<0?e+t:e}function zt(n,t,e){return n+e*(t-n)}function ln(n,t){let e=Math.pow(10,t);return Math.round(n*e)/e}function Or(n,t){return Math.floor(ln(n,t))}function Dr(n,t){return Math.ceil(ln(n,t))}function Xs(n,t,e){if(n>=t&&n<e)return n;let i=e-t;return((n-t)%i+i)%i+t}function Cu(n,t){return n[0]+=+t[0],n[1]+=+t[1],n}function cn(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 zn(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 vu(n,t){return n[0]*=t,n[1]*=t,n}function Ws(n,t){if(t.canWrapX()){let e=j(t.getExtent()),i=Su(n,t,e);i&&(n[0]-=i*e)}return n}function Su(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 Ru(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 oi={radians:6370997/(2*Math.PI),degrees:2*Math.PI*6370997/360,ft:.3048,m:1,"us-ft":1200/3937};var Pa=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_||oi[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_}},Ai=Pa;var kr=6378137,Gn=Math.PI*kr,$m=[-Gn,-Gn,Gn,Gn],Jm=[-180,-85,180,85],Us=kr*Math.log(Math.tan(Math.PI/2)),Mi=class extends Ai{constructor(t){super({code:t,units:"m",extent:$m,global:!0,worldExtent:Jm,getPointResolution:function(e,i){return e/Math.cosh(i[1]/kr)}})}},Oa=[new Mi("EPSG:3857"),new Mi("EPSG:102100"),new Mi("EPSG:102113"),new Mi("EPSG:900913"),new Mi("http://www.opengis.net/def/crs/EPSG/0/3857"),new Mi("http://www.opengis.net/gml/srs/epsg.xml#3857")];function Tu(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]=Gn*n[s]/180;let o=kr*Math.log(Math.tan(Math.PI*(+n[s+1]+90)/360));o>Us?o=Us:o<-Us&&(o=-Us),t[s+1]=o}return t}function Iu(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]/Gn,t[s+1]=360*Math.atan(Math.exp(n[s+1]/kr))/Math.PI-90;return t}var Qm=6378137,bu=[-180,-90,180,90],tp=Math.PI*Qm/180,ai=class extends Ai{constructor(t,e){super({code:t,units:"degrees",extent:bu,axisOrientation:e,global:!0,metersPerUnit:tp,worldExtent:bu})}},Da=[new ai("CRS:84"),new ai("EPSG:4326","neu"),new ai("urn:ogc:def:crs:OGC:1.3:CRS84"),new ai("urn:ogc:def:crs:OGC:2:84"),new ai("http://www.opengis.net/def/crs/OGC/1.3/CRS84"),new ai("http://www.opengis.net/gml/srs/epsg.xml#4326","neu"),new ai("http://www.opengis.net/def/crs/EPSG/0/4326","neu")];var ka={};function Lu(n){return ka[n]||ka[n.replace(/urn:(x-)?ogc:def:crs:EPSG:(.*:)?(\w+)$/,"EPSG:$3")]||null}function Au(n,t){ka[n]=t}function Xe(n){for(let t in n)delete n[t]}function xe(n){let t;for(t in n)return!1;return!t}var Xn={};function Wn(n,t,e){let i=n.getCode(),r=t.getCode();i in Xn||(Xn[i]={}),Xn[i][r]=e}function Ys(n,t){return n in Xn&&t in Xn[n]?Xn[n][t]:null}var Ks=.9996,ce=.00669438,Bs=ce*ce,Vs=Bs*ce,hn=ce/(1-ce),Mu=Math.sqrt(1-ce),Un=(1-Mu)/(1+Mu),ku=Un*Un,Fa=ku*Un,Na=Fa*Un,Fu=Na*Un,Nu=1-ce/4-3*Bs/64-5*Vs/256,ep=3*ce/8+3*Bs/32+45*Vs/1024,ip=15*Bs/256+45*Vs/1024,np=35*Vs/3072,rp=3/2*Un-27/32*Fa+269/512*Fu,sp=21/16*ku-55/32*Na,op=151/96*Fa-417/128*Fu,ap=1097/512*Na,Zs=6378137;function lp(n,t,e){let i=n-5e5,o=(e.north?t:t-1e7)/Ks/(Zs*Nu),a=o+rp*Math.sin(2*o)+sp*Math.sin(4*o)+op*Math.sin(6*o)+ap*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-ce*h,_=Math.sqrt(1-ce*h),p=Zs/_,y=(1-ce)/m,E=hn*c**2,v=E*E,x=i/(p*Ks),C=x*x,T=C*x,A=T*x,R=A*x,I=R*x,b=a-d/y*(C/2-A/24*(5+3*f+10*E-4*v-9*hn))+I/720*(61+90*f+298*E+45*g-252*hn-3*v),z=(x-T/6*(1+2*f+E)+R/120*(5-2*E+28*f-3*v+8*hn+24*g))/c;return z=Xs(z+ye(zu(e.number)),-Math.PI,Math.PI),[Gs(z),Gs(b)]}var Pu=-80,Ou=84,cp=-180,hp=180;function up(n,t,e){n=Xs(n,cp,hp),t<Pu?t=Pu:t>Ou&&(t=Ou);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=zu(e.number),d=ye(c),f=Zs/Math.sqrt(1-ce*r**2),g=hn*s**2,m=s*Xs(h-d,-Math.PI,Math.PI),_=m*m,p=_*m,y=p*m,E=y*m,v=E*m,x=Zs*(Nu*i-ep*Math.sin(2*i)+ip*Math.sin(4*i)-np*Math.sin(6*i)),C=Ks*f*(m+p/6*(1-a+g)+E/120*(5-18*a+l+72*g-58*hn))+5e5,T=Ks*(x+f*o*(_/2+y/24*(5-a+9*g+4*g**2)+v/720*(61-58*a+l+600*g-330*hn)));return e.north||(T+=1e7),[C,T]}function zu(n){return(n-1)*6-180+3}var dp=[/^EPSG:(\d+)$/,/^urn:ogc:def:crs:EPSG::(\d+)$/,/^http:\/\/www\.opengis\.net\/def\/crs\/EPSG\/0\/(\d+)$/];function Gu(n){let t=0;for(let r of dp){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 Du(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 Xu(n){return Gu(n)?new Ai({code:n,units:"m"}):null}function Wu(n){let t=Gu(n.getCode());return t?{forward:Du(up,t),inverse:Du(lp,t)}:null}var fp=63710088e-1;function za(n,t,e){e=e||fp;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 gp=[Wu],mp=[Xu];var Xa=!0;function Yu(n){Xa=!(n===void 0?!0:n)}function Ua(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 Wa(n){Au(n.getCode(),n),Wn(n,n,Ua)}function pp(n){n.forEach(Wa)}function Et(n){if(typeof n!="string")return n;let t=Lu(n);if(t)return t;for(let e of mp){let i=e(n);if(i)return i}return null}function Ya(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/oi[i])}}else{let o=n.getUnits();if(o=="degrees"&&!i||i=="degrees")r=t;else{let a=un(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=za(h.slice(0,2),h.slice(2,4)),d=za(h.slice(4,6),h.slice(6,8));r=(c+d)/2}let l=i?oi[i]:n.getMetersPerUnit();l!==void 0&&(r/=l)}}return r}function Uu(n){pp(n),n.forEach(function(t){n.forEach(function(e){t!==e&&Wn(t,e,Ua)})})}function _p(n,t,e,i){n.forEach(function(r){t.forEach(function(s){Wn(r,s,e),Wn(s,r,i)})})}function js(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 Yn(n,t){if(n===t)return!0;let e=n.getUnits()===t.getUnits();return(n.getCode()===t.getCode()||un(n,t)===Ua)&&e}function un(n,t){let e=n.getCode(),i=t.getCode(),r=Ys(e,i);if(r)return r;let s=null,o=null;for(let l of gp)s||(s=l(n)),o||(o=l(t));if(!s&&!o)return null;let a="EPSG:4326";if(o)if(s)r=Ga(s.inverse,o.forward);else{let l=Ys(e,a);l&&(r=Ga(l,o.forward))}else{let l=Ys(a,i);l&&(r=Ga(s.inverse,l))}return r&&(Wa(n),Wa(t),Wn(n,t,r)),r}function Ga(n,t){return function(e,i,r,s){return i=n(e,i,r,s),t(i,i,r,s)}}function dn(n,t){let e=Et(n),i=Et(t);return un(e,i)}function Kn(n,t,e){let i=dn(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 Zu(n,t,e,i){let r=dn(t,e);return _u(n,r,void 0,i)}var Ee=null;function fn(){return Ee}function Fr(n,t){return Ee?Kn(n,t,Ee):n}function we(n,t){return Ee?Kn(n,Ee,t):(Xa&&!cn(n,[0,0])&&n[0]>=-180&&n[0]<=180&&n[1]>=-90&&n[1]<=90&&(Xa=!1,zs("Call useGeographic() from ol/proj once to work with [longitude, latitude] coordinates.")),n)}function Pi(n,t){return Ee?Zu(n,t,Ee):n}function Ce(n,t){return Ee?Zu(n,Ee,t):n}function Bu(n,t){if(!Ee)return n;let e=Et(t).getMetersPerUnit(),i=Ee.getMetersPerUnit();return e&&i?n*e/i:n}function yp(){Uu(Oa),Uu(Da),_p(Da,Oa,Tu,Iu)}yp();function Ka(n){return n[0]>0&&n[1]>0}function Vu(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 Hs=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 gn(n,t,e,i,r){return r!==void 0?(r.minX=n,r.maxX=t,r.minY=e,r.maxY=i,r):new Hs(n,t,e,i)}var qs=Hs;function ju(n,t,e){let i,r;e=e||Vt;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 Vt(n,t){return n>t?1:n<t?-1:0}function Hu(n,t){return n<t?1:n>t?-1:0}function Zn(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 qu(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 $u(n,t,e){let i=t||Vt;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 B(n,t){if(!n)throw new Error(t)}function Ju(n,t,e,i,r){return!Fs(r,function(o){return!Oi(n,t,e,i,o[0],o[1])})}function Oi(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 Nr(n,t,e,i,r,s){if(e.length===0||!Oi(n,t,e[0],i,r,s))return!1;for(let o=1,a=e.length;o<a;++o)if(Oi(n,e[o-1],e[o],i,r,s))return!1;return!0}function Qu(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(Nr(n,t,l,i,r,s))return!0;t=l[l.length-1]}return!1}function td(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 $s(n,t,e,i,r,s){return s=s??ba(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:td(n,t,e,i,function(o,a){return pu(r,o,a)}):!1}function Za(n,t,e,i,r){return!!($s(n,t,e,i,r)||Oi(n,t,e,i,r[0],r[1])||Oi(n,t,e,i,r[0],r[3])||Oi(n,t,e,i,r[2],r[1])||Oi(n,t,e,i,r[2],r[3]))}function Ba(n,t,e,i,r){if(!Za(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(Ju(n,e[s-1],e[s],i,r)&&!$s(n,e[s-1],e[s],i,r))return!1;return!0}function ed(n,t,e,i,r){for(let s=0,o=e.length;s<o;++s){let a=e[s];if(Ba(n,t,a,i,r))return!0;t=a[a.length-1]}return!1}function H(){throw new Error("Unimplemented abstract method.")}var xp=0;function Y(n){return n.ol_uid||(n.ol_uid=String(++xp))}function Bn(n,t,e,i){return i!==void 0?(i[0]=n,i[1]=t,i[2]=e,i):[n,t,e]}function Ep(n,t,e){return n+"/"+t+"/"+e}function Vn(n,t,e,i,r){return`${Y(n)},${t},${Ep(e,i,r)}`}function id(n){return wp(n[0],n[1],n[2])}function wp(n,t,e){return(t<<n)+e}function nd(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 jn=[0,0,0],Di=5,Va=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,B($u(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,B(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_=le(s)),B(!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,B(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,B(!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 qs(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=gn(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 gn(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 gn(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 gn(h,h,c,c,i);let d=Math.floor(l*(s+1))-1,f=Math.floor(l*(o+1))-1;return gn(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,jn);let r=jn[1],s=jn[2];this.getTileCoordForXYAndZ_(t[2],t[1],e,!0,jn);let o=jn[1],a=jn[2];return gn(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=Dr(c,Di)-1,d=Dr(d,Di)-1):(c=Or(c,Di),d=Or(d,Di)),Bn(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=Dr(h,Di)-1,c=Dr(c,Di)-1):(h=Or(h,Di),c=Or(c,Di)),Bn(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=Zn(this.resolutions_,t,e||0);return et(i,this.minZoom,this.maxZoom)}tileCoordIntersectsViewport(t,e){return Za(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}},zr=Va;function Js(n){let t=n.getDefaultTileGrid();return t||(t=vp(n),n.setDefaultTileGrid(t)),t}function sd(n,t,e){let i=t[0],r=n.getTileCoordCenter(t),s=Qs(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=ad(n,t,e);return new zr({extent:n,origin:gu(n,i),resolutions:r,tileSize:e})}function od(n){let t=n||{},e=t.extent||Et("EPSG:3857").getExtent(),i={extent:e,minZoom:t.minZoom,tileSize:t.tileSize,resolutions:ad(e,t.maxZoom,t.tileSize,t.maxResolution)};return new zr(i)}function ad(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 vp(n,t,e,i){let r=Qs(n);return Cp(r,t,e,i)}function Qs(n){n=Et(n);let t=n.getExtent();if(!t){let e=180*oi.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 Hn(n,t,e,i){return Z(n,t,e,i,!0)}function J(n){n&&n.target&&(n.target.removeEventListener(n.type,n.listener),Xe(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 ja=class{constructor(){this.disposed=!1}dispose(){this.disposed||(this.disposed=!0,this.disposeInternal())}disposeInternal(){}},ki=ja;function li(){return!0}function ci(){return!1}function hi(){}function to(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 ld(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 Ha=class{constructor(t){this.propagationStopped,this.defaultPrevented,this.type=t,this.target=null}preventDefault(){this.defaultPrevented=!0}stopPropagation(){this.propagationStopped=!0}};var Lt=Ha;var qa=class extends ki{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,hi);delete o[i]}return l}disposeInternal(){this.listeners_&&Xe(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]=hi,++this.pendingRemovals_[t]):(i.splice(r,1),i.length===0&&delete this.listeners_[t]))}},Fi=qa;var mn=typeof navigator<"u"&&typeof navigator.userAgent<"u"?navigator.userAgent.toLowerCase():"",Sp=mn.includes("safari")&&!mn.includes("chrom"),X0=Sp&&(mn.includes("version/15.4")||/cpu (os|iphone os) 15_4 like mac os x/.test(mn)),cd=mn.includes("webkit")&&!mn.includes("edge"),$a=mn.includes("macintosh"),hd=typeof devicePixelRatio<"u"?devicePixelRatio:1,Rt=typeof WorkerGlobalScope<"u"&&typeof OffscreenCanvas<"u"&&self instanceof WorkerGlobalScope,Ja=typeof Image<"u"&&Image.prototype.decode;var eo=(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 ud(n,t,e){let i=n,r=!0,s=!1,o=!1,a=[Hn(i,P.LOAD,function(){o=!0,s||t()})];return i.src&&Ja?(s=!0,i.decode().then(function(){r&&t()}).catch(function(l){r&&(o?t():e())})):a.push(Hn(i,P.ERROR,e)),function(){r=!1,a.forEach(J)}}function Rp(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 dd(n,t){return t&&(n.src=t),n.src&&Ja?new Promise((e,i)=>n.decode().then(()=>e(n)).catch(r=>n.complete&&n.width?e(n):i(r))):Rp(n)}var D={IDLE:0,LOADING:1,LOADED:2,ERROR:3,EMPTY:4};function Qa(n){return Math.pow(n,3)}function he(n){return 1-Qa(1-n)}function fd(n){return 3*n*n-2*n*n*n}function gd(n){return n}var tl=class extends Fi{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:Qa(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()}},qn=tl;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 el;function Gr(){return el||(el=nt(1,1)),el}function pn(n){let t=n.canvas;t.width=1,t.height=1,n.clearRect(0,0,1,1)}function il(n,t){let e=t.parentNode;e&&e.replaceChild(n,t)}function md(n){for(;n.lastChild;)n.lastChild.remove()}function pd(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 io(){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 nl=class extends qn{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_=Tp(),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_=ud(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 Tp(){let n=nt(1,1);return n.fillStyle="rgba(0,0,0,0)",n.fillRect(0,0,1,1),n.canvas}var no=nl;var rl,_n=[];function _d(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 sl(n,t){return Math.abs(n[t*4]-210)>2||Math.abs(n[t*4+3]-.75*255)>2}function Ip(){if(rl===void 0){let n=nt(6,6,_n);n.globalCompositeOperation="lighter",n.fillStyle="rgba(210, 0, 0, 0.75)",_d(n,4,5,4,0),_d(n,4,5,0,5);let t=n.getImageData(0,0,3,3).data;rl=sl(t,0)||sl(t,4)||sl(t,8),pn(n),_n.push(n.canvas)}return rl}function yd(n,t,e,i){let r=Kn(e,t,n),s=Ya(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=Ya(n,s,r)/s;isFinite(h)&&h>0&&(s/=h)}return s}function xd(n,t,e,i){let r=Bt(e),s=yd(n,t,r,i);return(!isFinite(s)||s<=0)&&Fs(e,function(o){return s=yd(n,t,o,i),isFinite(s)&&s>0}),s}function Ed(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),_n);if(d||(m.imageSmoothingEnabled=!1),l.length===0)return m.canvas;m.scale(e,e);function _(C){return Math.round(C*e)/e}m.globalCompositeOperation="lighter";let p=ut();l.forEach(function(C,T,A){ks(p,C.extent)});let y,E=e/i,v=(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),_n),d||(y.imageSmoothingEnabled=!1),r&&g){let C=(r[0]-p[0])*E,T=-(r[3]-p[3])*E,A=j(r)*E,R=ct(r)*E;y.rect(C,T,A,R),y.clip()}l.forEach(function(C,T,A){if(C.image.width>0&&C.image.height>0){if(C.clipExtent){y.save();let X=(C.clipExtent[0]-p[0])*E,N=-(C.clipExtent[3]-p[3])*E,V=j(C.clipExtent)*E,lt=ct(C.clipExtent)*E;y.rect(d?X:Math.round(X),d?N:Math.round(N),d?V:Math.round(X+V)-Math.round(X),d?lt:Math.round(N+lt)-Math.round(N)),y.clip()}let R=(C.extent[0]-p[0])*E,I=-(C.extent[3]-p[3])*E,b=j(C.extent)*E,z=ct(C.extent)*E;y.drawImage(C.image,h,h,C.image.width-2*h,C.image.height-2*h,d?R:Math.round(R),d?I:Math.round(I),d?b:Math.round(R+b)-Math.round(R),d?z:Math.round(I+z)-Math.round(I)),C.clipExtent&&y.restore()}})}let x=le(o);return a.getTriangles().forEach(function(C,T,A){let R=C.source,I=C.target,b=R[0][0],z=R[0][1],X=R[1][0],N=R[1][1],V=R[2][0],lt=R[2][1],M=_((I[0][0]-x[0])/s),W=_(-(I[0][1]-x[1])/s),O=_((I[1][0]-x[0])/s),$=_(-(I[1][1]-x[1])/s),G=_((I[2][0]-x[0])/s),tt=_(-(I[2][1]-x[1])/s),it=b,Ct=z;b=0,z=0,X-=it,N-=Ct,V-=it,lt-=Ct;let L=[[X,N,0,0,O-M],[V,lt,0,0,G-M],[0,0,X,N,$-W],[0,0,V,lt,tt-W]],Jt=wu(L);if(!Jt)return;if(m.save(),m.beginPath(),Ip()||!d){m.moveTo(O,$);let ot=4,Oe=M-O,Ji=W-$;for(let re=0;re<ot;re++)m.lineTo(O+_((re+1)*Oe/ot),$+_(re*Ji/(ot-1))),re!=ot-1&&m.lineTo(O+_((re+1)*Oe/ot),$+_((re+1)*Ji/(ot-1)));m.lineTo(G,tt)}else m.moveTo(O,$),m.lineTo(M,W),m.lineTo(G,tt);m.clip(),m.transform(Jt[0],Jt[2],Jt[1],Jt[3],M,W),m.translate(p[0]-it,p[3]-Ct);let vt;if(y)vt=y.canvas,m.scale(v,-v);else{let ot=l[0],Oe=ot.extent;vt=ot.image,m.scale(j(Oe)/vt.width,-ct(Oe)/vt.height)}m.drawImage(vt,0,0),m.restore()}),y&&(pn(y),_n.push(y.canvas)),c&&(m.save(),m.globalCompositeOperation="source-over",m.strokeStyle="black",m.lineWidth=1,a.getTriangles().forEach(function(C,T,A){let R=C.target,I=(R[0][0]-x[0])/s,b=-(R[0][1]-x[1])/s,z=(R[1][0]-x[0])/s,X=-(R[1][1]-x[1])/s,N=(R[2][0]-x[0])/s,V=-(R[2][1]-x[1])/s;m.beginPath(),m.moveTo(z,X),m.lineTo(I,b),m.lineTo(N,V),m.closePath(),m.stroke()}),m.restore()),m.canvas}var bp=[1,0,0,1,0,0],pE=new Array(6);function At(){return bp.slice(0)}function wd(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 so(n,t){let e=Lp(t);B(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 Lp(n){return n[0]*n[3]-n[1]*n[2]}var Ap=[1e5,1e5,1e5,1e5,2,2];function Cd(n){return"matrix("+n.join(", ")+")"}function ro(n){return n.substring(7,n.length-1).split(",").map(parseFloat)}function vd(n,t){let e=ro(n),i=ro(t);for(let r=0;r<6;++r)if(Math.round((e[r]-i[r])*Ap[r])!==0)return!1;return!0}var Mp=10,Sd=.25,ol=class{constructor(t,e,i,r,s,o,a){this.sourceProj_=t,this.targetProj_=e;let l={},h=a?Ku(v=>dt(a,Kn(v,this.targetProj_,this.sourceProj_))):dn(this.targetProj_,this.sourceProj_);this.transformInv_=function(v){let x=v[0]+"/"+v[1];return l[x]||(l[x]=h(v)),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=le(i),d=Nn(i),f=Fn(i),g=kn(i),m=this.transformInv_(c),_=this.transformInv_(d),p=this.transformInv_(f),y=this.transformInv_(g),E=Mp+(o?Math.max(0,Math.ceil(Math.log2(Mr(i)/(o*o*256*256)))):0);if(this.addQuad_(c,d,f,g,m,_,p,y,E),this.wrapsXInSource_){let v=1/0;this.triangles_.forEach(function(x,C,T){v=Math.min(v,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])-v>this.sourceWorldWidth_/2){let C=[[x.source[0][0],x.source[0][1]],[x.source[1][0],x.source[1][1]],[x.source[2][0],x.source[2][1]]];C[0][0]-v>this.sourceWorldWidth_/2&&(C[0][0]-=this.sourceWorldWidth_),C[1][0]-v>this.sourceWorldWidth_/2&&(C[1][0]-=this.sourceWorldWidth_),C[2][0]-v>this.sourceWorldWidth_/2&&(C[2][0]-=this.sourceWorldWidth_);let T=Math.min(C[0][0],C[1][0],C[2][0]);Math.max(C[0][0],C[1][0],C[2][0])-T<this.sourceWorldWidth_/2&&(x.source=C)}})}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=Ia([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=Ia([t,e,i,r]);m=j(p)/this.targetWorldWidth_>Sd||m}!g&&this.sourceProj_.isGlobal()&&d&&(m=d>Sd||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=(Ge(s[0],f)+Ge(a[0],f))/2-Ge(y[0],f):E=(s[0]+a[0])/2-y[0];let v=(s[1]+a[1])/2-y[1];m=E*E+v*v>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],v=this.transformInv_(E);this.addQuad_(t,e,p,E,s,o,y,v,h-1),this.addQuad_(E,p,i,r,v,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],v=this.transformInv_(E);this.addQuad_(t,p,E,r,s,y,v,l,h-1),this.addQuad_(p,e,i,E,y,o,a,v,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;an(t,s[0]),an(t,s[1]),an(t,s[2])}),t}getTriangles(){return this.triangles_}},Rd=ol;var al=class extends qn{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?Ne(g,m):g;if(Mr(p)===0){this.state=D.EMPTY;return}let y=t.getExtent();y&&(_?_=Ne(_,y):_=y);let E=r.getResolution(this.wrappedTileCoord_[0]),v=xd(t,i,p,E);if(!isFinite(v)||v<=0){this.state=D.EMPTY;return}let x=c!==void 0?c:.5;if(this.triangulation_=new Rd(t,i,p,_,v*x,E),this.triangulation_.getTriangles().length===0){this.state=D.EMPTY;return}this.sourceZ_=e.getZForResolution(v);let C=this.triangulation_.calculateSourceExtent();if(_&&(t.canWrapX()?(C[1]=et(C[1],_[1],_[3]),C[3]=et(C[3],_[1],_[3])):C=Ne(C,_)),!Mr(C))this.state=D.EMPTY;else{let T=0,A=0;t.canWrapX()&&(T=j(y),A=Math.floor((C[0]-y[0])/T)),Ns(C.slice(),t,!0).forEach(I=>{let b=e.getTileRangeForExtentAndZ(I,this.sourceZ_);for(let z=b.minX;z<=b.maxX;z++)for(let X=b.minY;X<=b.maxY;X++){let N=A*T;this.sourceTiles_.push({getTile:()=>h(this.sourceZ_,z,X,a),offset:N})}++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_=Ed(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_&&(pn(this.canvas_.getContext("2d")),_n.push(this.canvas_),this.canvas_=null),this.sourceTiles_.length=0,super.release()}},oo=al;var Pp=/\{z\}/g,Op=/\{x\}/g,Dp=/\{y\}/g,kp=/\{-y\}/g;function Td(n,t,e,i,r){return n.replace(Pp,t.toString()).replace(Op,e.toString()).replace(Dp,i.toString()).replace(kp,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 Id(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 Fp(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 Td(n,o,e[1],e[2],s)})}function bd(n,t){let e=n.length,i=new Array(e);for(let r=0;r<e;++r)i[r]=Fp(n[r],t);return Np(i)}function Np(n){return n.length===1?n[0]:(function(t,e,i){if(!t)return;let r=id(t),s=Ge(r,n.length);return n[s](t,e,i)})}var Se={PROPERTYCHANGE:"propertychange"};var $n=class extends Fi{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]=Hn(this,t[s],e)}else i=Hn(this,t,e);return e.ol_key=i,i}unInternal(t,e){let i=e.ol_key;if(i)zp(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)}};$n.prototype.on;$n.prototype.once;$n.prototype.un;function zp(n){if(Array.isArray(n))for(let t=0,e=n.length;t<e;++t)J(n[t]);else J(n)}var ao=$n;var lo=class extends Lt{constructor(t,e,i){super(t),this.key=e,this.oldValue=i}},ll=class extends ao{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 lo(i,t,e)),i=Se.PROPERTYCHANGE,this.hasListener(i)&&this.dispatchEvent(new lo(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=ll;var cl=class extends wt{constructor(t){super(),this.projection=Et(t.projection),this.attributions_=Ld(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_=Ld(t),this.changed()}setState(t){this.state_=t,this.changed()}};function Ld(n){return n?typeof n=="function"?n:(Array.isArray(n)||(n=[n]),t=>n):null}var co=cl;var hl=class extends co{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:Js(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:Vu(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=sd(r,t,i)),nd(t,r)?t:null}clear(){}refresh(){this.clear(),super.refresh()}},ho=class extends Lt{constructor(t,e){super(t),this.tile=e}},Ad=hl;var uo={TILELOADSTART:"tileloadstart",TILELOADEND:"tileloadend",TILELOADERROR:"tileloaderror"};var ul=class n extends Ad{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=uo.TILELOADSTART):i in this.tileLoadingKeys_&&(delete this.tileLoadingKeys_[i],s=r==D.ERROR?uo.TILELOADERROR:r==D.LOADED?uo.TILELOADEND:void 0),s!=null&&this.dispatchEvent(new ho(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=Id(t);this.urls=e,this.setUrls(e)}setUrls(t){this.urls=t;let e=t.join(`2+`);this.generateTileUrlFunction_?this.setTileUrlFunction(bd(t,this.tileGrid),e):this.setKey(e)}tileUrlFunction(t,e,i){}},Md=ul;var dl=class extends Md{constructor(t){super({attributions:t.attributions,cacheSize:t.cacheSize,projection:t.projection,state:t.state,tileGrid:t.tileGrid,tileLoadFunction:t.tileLoadFunction?t.tileLoadFunction:Gp,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:no,this.tileGridForProjection={},this.reprojectionErrorThreshold_=t.reprojectionErrorThreshold,this.renderReprojectionEdges_=!1}getGutterForProjection(t){return this.getProjection()&&t&&!Yn(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||Yn(e,t)))return this.tileGrid;let i=Y(t);return i in this.tileGridForProjection||(this.tileGridForProjection[i]=Js(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||Yn(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 oo(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=Vn(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 Gp(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 Pd=dl;var fl=class extends Pd{constructor(t){t=t||{};let e=t.projection!==void 0?t.projection:"EPSG:3857",i=t.tileGrid!==void 0?t.tileGrid:od({extent:Qs(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_}},Od=fl;function Re(){if(!u.map||!u.variant||u.settling)return;let n=u.engine?.getView();try{let t=Dd();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,dockFolded:u.dockFolded,dockDismissed:u.dockDismissed},localStorage.setItem(Ta,JSON.stringify(t))}catch{}}function Dd(){try{let n=JSON.parse(localStorage.getItem(Ta)||"null");if(n&&n.games)return n}catch{}return{last:"",games:{}}}function Jn(n){let t=Dd(),e=n||t.last,i=e&&t.games[e];return i&&i.game&&i.map?i:null}function Qn(){let[n,t]=decodeURIComponent(location.hash.replace(/^#\/?/,"")).split("/").map(e=>e.trim());return{game:n,map:t}}function kd(){if(!u.game||!u.map)return;let n=`#${u.game.slug}/${u.map.slug}`;location.hash!==n&&history.replaceState(null,"",n)}var gl=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?Xp(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 Xp(n){if(typeof n=="function")return n;let t;return Array.isArray(n)?t=n:(B(typeof n.getZIndex=="function","Expected an `ol/style/Style` or an array of `ol/style/Style.js`"),t=[n]),function(){return t}}var Ni=gl;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 fo(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 Fd(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 Nd(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 zd=At(),Wp=[NaN,NaN],ml=class extends wt{constructor(){super(),this.extent_=ut(),this.extentRevision_=-1,this.simplifiedGeometryMaxMinSquaredTolerance=0,this.simplifiedGeometryRevision=0,this.simplifyTransformedInternal=to((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,Wp,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]))&&sn(e),this.extentRevision_=this.getRevision()}return mu(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(zd,h[0],h[3],c,-c,0,0,0);let d=jt(s,0,s.length,a,zd,o),f=dn(i,e);return f?f(d,d,a):d}:dn(i,e);return this.applyTransform(r),this}},Gd=ml;var pl=class extends Gd{constructor(){super(),this.layout="XY",this.stride=2,this.flatCoordinates}computeExtent(t){return Dn(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=Xd(t),this.layout=t,this.flatCoordinates=e}setCoordinates(t,e){H()}setLayout(t,e,i){let r;if(t)r=Xd(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=Up(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();fo(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 s=this.getStride();Fd(r,0,r.length,s,t,e,i,r),this.changed()}}translate(t,e){let i=this.getFlatCoordinates();if(i){let r=this.getStride();Nd(i,0,i.length,r,t,e,i),this.changed()}}};function Up(n){let t;return n==2?t="XY":n==3?t="XYZ":n==4&&(t="XYZM"),t}function Xd(n){let t;return n=="XY"?t=2:n=="XYZ"||n=="XYM"?t=3:n=="XYZM"&&(t=4),t}function Wd(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 We=pl;function Ud(n,t,e,i){for(let r=0,s=e.length;r<s;++r)n[t++]=e[r];return t}function Xr(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 _l(n,t,e,i,r){r=r||[];let s=0;for(let o=0,a=e.length;o<a;++o){let l=Xr(n,t,e[o],i);r[s++]=l,t=l}return r.length=s,r}function Yd(n,t,e,i,r){r=r||[];let s=0;for(let o=0,a=e.length;o<a;++o){let l=_l(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 yl=class n extends We{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 Ds(this.flatCoordinates,t)}getType(){return"Point"}intersectsExtent(t){return Ar(t,this.flatCoordinates[0],this.flatCoordinates[1])}setCoordinates(t,e){this.setLayout(e,t,0),this.flatCoordinates||(this.flatCoordinates=[]),this.flatCoordinates.length=Ud(this.flatCoordinates,0,t,this.stride),this.changed()}},ui=yl;function xl(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 El(n,t,e,i){let r=0;for(let s=0,o=e.length;s<o;++s){let a=e[s];r+=xl(n,t,a,i),t=a}return r}function Kd(n,t,e,i){let r=0;for(let s=0,o=e.length;s<o;++s){let a=e[s];r+=El(n,t,a,i),t=a[a.length-1]}return r}function Zd(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 wl(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 Cl(n,t,e,i,r){for(let s=0,o=e.length;s<o;++s){let a=e[s];r=wl(n,t,a,i,r),t=a}return r}function Bd(n,t,e,i,r){for(let s=0,o=e.length;s<o;++s){let a=e[s];r=Cl(n,t,a,i,r),t=a[a.length-1]}return r}function vl(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(Zd(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&&(Zd(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 Sl(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=vl(n,t,g,i,r,s,o,a,l,h,c),t=g}return h}function Vd(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=Sl(n,t,g,i,r,s,o,a,l,h,c),t=g[g.length-1]}return h}function Ue(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 tr(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++]=Ue(n,t,l,i,r[s]),t=l}return r.length=s,r}function Wr(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?[]:tr(n,t,l,i,r[s]),t=l[l.length-1]}return r.length=s,r}function Ur(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 v=n[E],x=n[E+1],C=Eu(v,x,m,_,p,y);C>g&&(c=E,g=C)}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 jd(n,t,e,i,r,s,o,a){for(let l=0,h=e.length;l<h;++l){let c=e[l];o=Ur(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 Yp(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 Yr(n,t,e,i,r,s,o,a){for(let l=0,h=e.length;l<h;++l){let c=e[l];o=Yp(n,t,c,i,r,s,o),a.push(o),t=c}return o}function Hd(n,t,e,i,r,s,o,a){for(let l=0,h=e.length;l<h;++l){let c=e[l],d=[];o=Yr(n,t,c,i,r,s,o,d),a.push(d),t=c[c.length-1]}return o}var Rl=class n extends We{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<Li(this.getExtent(),t,e)?r:(this.maxDeltaRevision_!=this.getRevision()&&(this.maxDelta_=Math.sqrt(wl(this.flatCoordinates,0,this.flatCoordinates.length,this.stride,0)),this.maxDeltaRevision_=this.getRevision()),vl(this.flatCoordinates,0,this.flatCoordinates.length,this.stride,this.maxDelta_,!0,t,e,i,r))}getArea(){return xl(this.flatCoordinates,0,this.flatCoordinates.length,this.stride)}getCoordinates(){return Ue(this.flatCoordinates,0,this.flatCoordinates.length,this.stride)}getSimplifiedGeometryInternal(t){let e=[];return e.length=Ur(this.flatCoordinates,0,this.flatCoordinates.length,this.stride,t,e,0),new n(e,"XY")}getType(){return"LinearRing"}intersectsExtent(t){return $s(this.flatCoordinates,0,this.flatCoordinates.length,this.stride,t)}setCoordinates(t,e){this.setLayout(e,t,1),this.flatCoordinates||(this.flatCoordinates=[]),this.flatCoordinates.length=Xr(this.flatCoordinates,0,t,this.stride),this.changed()}},Tl=Rl;function Kr(n,t,e,i,r,s,o){let a,l,h,c,d,f,g,m=r[s+1],_=[];for(let E=0,v=e.length;E<v;++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(Vt),c=_[0],a=1,l=_.length;a<l;++a){d=_[a];let E=Math.abs(d-c);E>y&&(h=(c+d)/2,Nr(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 go(n,t,e,i,r){let s=[];for(let o=0,a=e.length;o<a;++o){let l=e[o];s=Kr(n,t,l,i,r,2*o,s),t=l[l.length-1]}return s}function qd(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 Il(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 bl(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=Il(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 $d(n,t,e,i,r){for(let s=0,o=e.length;s<o;++s){let a=e[s];if(!bl(n,t,a,i,r))return!1;a.length&&(t=a[a.length-1])}return!0}function mo(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=Il(n,t,a,i);(s===0?r&&l||!r&&!l:r&&!l||!r&&l)&&qd(n,t,a,i),t=a}return t}function Ll(n,t,e,i,r){for(let s=0,o=e.length;s<o;++s)t=mo(n,t,e[s],i,r);return t}function Jd(n,t){let e=[],i=0,r=0,s;for(let o=0,a=t.length;o<a;++o){let l=t[o],h=Il(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 po=class n extends We{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<Li(this.getExtent(),t,e)?r:(this.maxDeltaRevision_!=this.getRevision()&&(this.maxDelta_=Math.sqrt(Cl(this.flatCoordinates,0,this.ends_,this.stride,0)),this.maxDeltaRevision_=this.getRevision()),Sl(this.flatCoordinates,0,this.ends_,this.stride,this.maxDelta_,!0,t,e,i,r))}containsXY(t,e){return Nr(this.getOrientedFlatCoordinates(),0,this.ends_,this.stride,t,e)}getArea(){return El(this.getOrientedFlatCoordinates(),0,this.ends_,this.stride)}getCoordinates(t){let e;return t!==void 0?(e=this.getOrientedFlatCoordinates().slice(),mo(e,0,this.ends_,this.stride,t)):e=this.flatCoordinates,tr(e,0,this.ends_,this.stride)}getEnds(){return this.ends_}getFlatInteriorPoint(){if(this.flatInteriorPointRevision_!=this.getRevision()){let t=Bt(this.getExtent());this.flatInteriorPoint_=Kr(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 Tl(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 Tl(e.slice(s,l),t);r.push(h),s=l}return r}getOrientedFlatCoordinates(){if(this.orientedRevision_!=this.getRevision()){let t=this.flatCoordinates;bl(t,0,this.ends_,this.stride)?this.orientedFlatCoordinates_=t:(this.orientedFlatCoordinates_=t.slice(),this.orientedFlatCoordinates_.length=mo(this.orientedFlatCoordinates_,0,this.ends_,this.stride)),this.orientedRevision_=this.getRevision()}return this.orientedFlatCoordinates_}getSimplifiedGeometryInternal(t){let e=[],i=[];return e.length=Yr(this.flatCoordinates,0,this.ends_,this.stride,Math.sqrt(t),e,0,i),new n(e,"XY",i)}getType(){return"Polygon"}intersectsExtent(t){return Ba(this.getOrientedFlatCoordinates(),0,this.ends_,this.stride,t)}setCoordinates(t,e){this.setLayout(e,t,2),this.flatCoordinates||(this.flatCoordinates=[]);let i=_l(this.flatCoordinates,0,t,this.stride,this.ends_);this.flatCoordinates.length=i.length===0?0:i[i.length-1],this.changed()}},Ye=po;function Al(n){if(ze(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 po(s,"XY",[s.length])}function Qd(){let n=u.variant?.surface;return n?[n.x,-(n.y+n.height),n.x+n.width,-n.y]:di()}function tf(n){return n.key.toLocaleLowerCase()==="g"?(n.preventDefault(),ef(),u.gridEnabled?(w.gridInput.focus(),w.gridInput.select()):w.viewport.focus({preventScroll:!0}),!0):n.key===" "&&u.gridEnabled&&n.target!==w.subgridToggle?(n.preventDefault(),Zr(!u.subgridVisible),!0):n.key==="Escape"&&u.gridEnabled?(n.preventDefault(),Ml(),!0):!1}function ef(n=!u.gridEnabled){u.gridEnabled=n,n&&Zr(!0),yo(),Ke(),u.layers.pins.changed(),u.layers.text.changed(),u.layers.priority.changed()}function Zr(n){u.subgridVisible=n,u.layers.grid.changed(),u.layers.gridContext.changed(),w.subgridToggle.setAttribute("aria-pressed",String(n)),w.subgridToggle.setAttribute("aria-label",n?"Hide the subgrid":"Show the subgrid"),nf()}function nf(){if(!u.gridEnabled){w.gridHint.textContent="G \xB7 grid off";return}w.gridHint.textContent=`G-${u.gridPrefix||"root"}`+(u.subgridVisible?"":" no subgrid")}function Br(n){let t=yn(),e=[...n.toLocaleLowerCase()].filter(r=>ae.includes(r)).slice(0,t).join(""),i=e!==u.gridPrefix;u.gridPrefix=e,u.gridEnabled||(u.gridEnabled=!0),yo(),Ke(),u.layers.pins.changed(),u.layers.text.changed(),u.layers.priority.changed(),i&&(Te(),u.engine.getView().fit(er(),{size:u.engine.getSize(),padding:[52,52,52,52],maxZoom:Ze(u.variant),duration:180}))}function Ml(){if(u.gridEnabled){if(!u.gridPrefix){ef(!1);return}Br(u.gridPrefix.slice(0,-1))}}function yo(){if(!u.sources||(u.sources.grid.clear(),u.sources.gridContext.clear(),w.gridNavigator.hidden=!u.gridEnabled,nf(),!u.gridEnabled||!u.variant))return;let n=yn();if(w.gridInput.maxLength=n,w.gridInput.value=u.gridPrefix,w.gridBack.title=u.gridPrefix?"Back one geohash level":"Close geohash grid",Zp(),u.gridPrefix.length>=n){_o(u.gridPrefix,er(),"leaf");return}u.gridPrefix&&_o(u.gridPrefix,er(),"scope");for(let t of ae){let e=u.gridPrefix+t;_o(e,Pl(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 ae){let r=t+i;r!==e&&_o(r,Pl(r),"neighbor",u.gridPrefix.length-n)}}}function _o(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 Ni({geometry:new Ye([[[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+ae.indexOf(n[n.length-1]):ae.indexOf(n[n.length-1])});(e==="neighbor"?u.sources.gridContext:u.sources.grid).addFeature(h)}function er(){return Pl(u.gridPrefix)}function Pl(n){let t=[...Qd()],e=!0;for(let i of n){let r=ae.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 yn(){return 3}function rf(n,t=yn()){let e=[...Qd()],[i,r]=n;if(i<e[0]||i>e[2]||r<e[1]||r>e[3])return"";let s=!0,o="";for(let a=0;a<t;a++){let l=0;for(let h of[16,8,4,2,1]){if(s){let c=(e[0]+e[2])/2;i>=c?(l|=h,e[0]=c):e[2]=c}else{let c=(e[1]+e[3])/2;r>=c?(l|=h,e[1]=c):e[3]=c}s=!s}o+=ae[l]}return o}function ir(n){if(!u.gridEnabled||!u.gridPrefix)return!1;let t=er(),[e,i]=n.coordinate;return e>=t[0]&&e<=t[2]&&i>=t[1]&&i<=t[3]}function Vr(){return fu[u.map?.iconOutset==="dark"?"dark":"light"]}function Bp(n){let t=u.map?.iconOutset==="dark",e=jp(n);return(t?e>.3:e<.88)?n:Vp(n,t?.74:.42)}function Vp(n,t){let e=String(n).replace("#","");if(e.length!==6)return n;let[i,r,s]=[0,2,4].map(v=>parseInt(e.slice(v,v+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=v=>Math.round((v+m)*255).toString(16).padStart(2,"0");return`#${E(_)}${E(p)}${E(y)}`}function jp(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 xo(n){let t=Math.abs(Number(n)||0);return Pn[(Math.imul(t,2654435761)>>>0)%Pn.length]}function fi(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 nr(n,t){n.style.setProperty("--pin-color",jr(t))}function jr(n){return Bp(n.color||xo(n.id))}function rr(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("${Ol(t.iconAsset)}")`),n.classList.add("has-source-icon")}function Ol(n){let t=n.split("/").map(e=>encodeURIComponent(e)).join("/");return`${u.game.base}/icons/${t}`}function Gi(n){return n.split(/\s+/).slice(0,2).map(t=>t[0]||"").join("")}function sf(n){return Math.imul(Number(n)||0,2654435761)>>>0}function of(n){return String(n||"").replace(/\[([^\]]+)\]\([^)]+\)/g,"$1").replace(/[*_`>#]/g,"").replace(/\r/g,"").replace(/\n{3,}/g,`33 4-`).trim()}function Ie(n){return new Intl.NumberFormat().format(n)}function be(n,t,e){return Math.min(e,Math.max(t,n))}function xo(n){return n instanceof HTMLElement&&(n.matches("input, textarea, select")||n.isContentEditable)}var jp=100;function Gi(){if(!w.searchResults)return;let n=u.pins.filter(i=>!i.filteredHidden).sort((i,r)=>i.location.title.localeCompare(r.location.title)),t=n.slice(0,jp),e=document.createDocumentFragment();if(!t.length){let i=document.createElement("p");i.className="search-empty",i.textContent=u.search?"No visible locations match.":"Nothing is enabled. Show a category to list its locations.",e.append(i)}for(let i of t){let r=document.createElement("button");r.type="button",r.className="search-result",u.selectedPin===i&&r.classList.add("is-selected"),r.dataset.location=String(i.location.id),ir(r,i.category);let s=document.createElement("span");s.className="result-dot",nr(s,i.category,zi(i.category.title));let o=document.createElement("span"),a=document.createElement("strong");a.textContent=i.location.title;let l=document.createElement("small");l.textContent=`${i.category.title} \xB7 ${i.group.title}`,o.append(a,l),r.append(s,o),e.append(r)}if(n.length>t.length){let i=document.createElement("p");i.className="dock-note",i.textContent=`First ${t.length} of ${Ie(n.length)} \u2014 search or filter to narrow the list.`,e.append(i)}w.searchResults.replaceChildren(e),qp(n.length),Hp()}var of=28;function Hp(){let n=u.selectedPin?.location.title||"",t=n.length>of?`${n.slice(0,of-1).trimEnd()}\u2026`:n;w.dockRailName.textContent=t?` \xB7 ${t}`:"",w.dockRailName.hidden=!t}function qp(n){w.dockCount.textContent=`${Ie(n)} ${n===1?"location":"locations"}`,u.search?(w.dockFlag.textContent=`\u201C${u.search}\u201D`,w.dockFlag.hidden=!1):u.hiddenCategories.size>0?(w.dockFlag.textContent="filtered",w.dockFlag.hidden=!1):w.dockFlag.hidden=!0}function Eo(){!u.dockFolded||u.dockDismissed||wo(!1)}function Ol(n){u.dockDismissed=n,wo(n)}function wo(n,t=!0){u.dockFolded=n,w.dock.classList.toggle("is-folded",n),w.dockFold.setAttribute("aria-expanded",String(!n));let e=n?"Bring the panel back (\u2318\u2325B)":"Put the panel away (\u2318\u2325B)";w.dockFold.setAttribute("aria-label",e),w.dockFold.setAttribute("title",e),t&&Re()}function Dl(n){u.hiddenCategories.delete(n.category.id),jr(),ue(),Xi(),kl(n,!0)}function kl(n,t=!1){u.selectedPin=n,Ke(),u.layers.pins.changed(),u.layers.pinLabels.changed(),u.layers.text.changed(),u.layers.textDetail.changed(),u.layers.priority.changed(),w.detailTitle.textContent=n.location.title,w.detailCategory.textContent=`${n.group.title} / ${n.category.title}`,w.detailDescription.textContent="",w.detailLinks.hidden=!0,Jp(n),w.detailID.textContent=String(n.location.id),w.detailCoordinates.textContent=`${n.location.lat.toFixed(6)}, ${n.location.lng.toFixed(6)}`;let e=nf(n.coordinate);w.detailCell.textContent=e,w.detailCellField.hidden=!e;let i=$p(n);if(w.detailSource.textContent=i,w.detailSourceField.hidden=!i,ir(w.detailDot,n.category),nr(w.detailDot,n.category,zi(n.category.title)),w.detail.hidden=!1,Eo(),Gi(),t){let r=u.engine.getView();r.animate({center:n.coordinate,zoom:Math.min(Ze(u.variant),Math.max(r.getZoom()||0,4)),duration:220})}}function $p(n){let t=u.map?.merged;if(!t?.length)return"";let e=t.find(i=>i.origin)?.source||"";if(u.pinSourceIndex?.map!==u.map){let i=new Map;for(let r of t){for(let s of r.adopted||[])i.set(s.d,r.source);for(let s of r.matched||[]){let o=`confirmed by ${r.source}`;i.set(s.w,e?`${e} \xB7 ${o}`:o)}}u.pinSourceIndex={map:u.map,byID:i}}for(let i of t)if(!i.origin&&n.group.title===i.source)return i.source;return u.pinSourceIndex.byID.get(n.location.id)||e}async function Jp(n){let t=await af();if(u.selectedPin!==n)return;let e=t[String(n.location.id)]||{};n.location.description=e.d||"",n.location.links=e.l||[],w.detailDescription.textContent=sf(e.d)||"No description is included in the archive.",Qp(n)}function Qp(n){let t=(n.location.links||[]).filter(i=>u.pinByID.has(i.locationId));if(w.detailLinks.hidden=t.length===0,!t.length){w.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)}w.detailLinks.replaceChildren(e)}function Te(){let n=u.selectedPin!==null;u.selectedPin=null,u.sources&&(Ke(),u.layers.pins.changed(),u.layers.pinLabels.changed(),u.layers.text.changed(),u.layers.textDetail.changed(),u.layers.priority.changed()),w.detail.hidden=!0,n&&Gi()}var vo=[NaN,NaN,NaN,0],Fl;function t_(){return Fl||(Fl=nt(1,1,void 0,{willReadFrequently:!0,desynchronized:!0})),Fl}var e_=/^rgba?\(\s*(\d+%?)\s+(\d+%?)\s+(\d+%?)(?:\s*\/\s*(\d+%|\d*\.\d+|[01]))?\s*\)$/i,i_=/^rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)(?:\s*,\s*(\d+%|\d*\.\d+|[01]))?\s*\)$/i,n_=/^rgba?\(\s*(\d+%)\s*,\s*(\d+%)\s*,\s*(\d+%)(?:\s*,\s*(\d+%|\d*\.\d+|[01]))?\s*\)$/i,r_=/^#([\da-f]{3,4}|[\da-f]{6}|[\da-f]{8})$/i;function Co(n,t){return n.endsWith("%")?Number(n.substring(0,n.length-1))/t:Number(n)}function qr(n){throw new Error('failed to parse "'+n+'" as color')}function lf(n){if(n.toLowerCase().startsWith("rgb")){let s=n.match(i_)||n.match(e_)||n.match(n_);if(s){let o=s[4],a=100/255;return[et(Co(s[1],a)+.5|0,0,255),et(Co(s[2],a)+.5|0,0,255),et(Co(s[3],a)+.5|0,0,255),o!==void 0?et(Co(o,100),0,1):1]}qr(n)}if(n.startsWith("#")){if(r_.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}qr(n)}let t=t_();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&&qr(n));let i=t.fillStyle;if(i.startsWith("#")||i.startsWith("rgba"))return lf(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]=an(r[3]/255,3),r}function cf(n){return typeof n=="string"?n:Jr(n)}var s_=1024,Hr={},Nl=0;function hf(n){if(n.length===4)return n;let t=n.slice();return t[3]=1,t}function zl(n){return n>.0031308?Math.pow(n,1/2.4)*269.025-14.025:n*3294.6}function Gl(n){return n>.2068965?Math.pow(n,3):(n-4/29)*(108/841)}function Xl(n){return n>10.314724?Math.pow((n+14.025)/269.025,2.4):n/3294.6}function Wl(n){return n>.0088564?Math.pow(n,1/3):n/(108/841)+4/29}function Ul(n){let t=Xl(n[0]),e=Xl(n[1]),i=Xl(n[2]),r=Wl(t*.222488403+e*.716873169+i*.06060791),s=500*(Wl(t*.452247074+e*.399439023+i*.148375274)-r),o=200*(r-Wl(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 uf(n){let t=(n[0]+16)/116,e=n[1],i=n[2]*Math.PI/180,r=Gl(t),s=Gl(t+e/500*Math.cos(i)),o=Gl(t-e/200*Math.sin(i)),a=zl(s*3.021973625-r*1.617392459-o*.404875592),l=zl(s*-.943766287+r*1.916279586+o*.027607165),h=zl(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 $r(n){if(n==="none")return vo;if(Hr.hasOwnProperty(n))return Hr[n];if(Nl>=s_){let e=0;for(let i in Hr)(e++&3)===0&&(delete Hr[i],--Nl)}let t=lf(n);t.length!==4&&qr(n);for(let e of t)isNaN(e)&&qr(n);return Hr[n]=t,++Nl,t}function de(n){return Array.isArray(n)?n:$r(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 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=Yl(t,e);return i in this.cache_?this.cache_[i]:null}getPattern(t,e){let i=Yl(t,e);return i in this.patternCache_?this.patternCache_[i]:null}set(t,e,i,r){let s=Yl(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]=zr().createPattern(i.getImage(1),"repeat")}):this.patternCache_[s]=zr().createPattern(i.getImage(1),"repeat")),o||++this.cacheSize_}setSize(t){this.maxCacheSize_=t,this.expire()}};function Yl(n,t){let e=t?de(t):"null";return n+":"+e}var Xt=new Kl;var Qr=null,So=class extends ki{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){Qr||(Qr=nt(1,1,void 0,{willReadFrequently:!0})),Qr.drawImage(this.image_,0,0);try{Qr.getImageData(0,0,1,1),this.tainted_=!1}catch{Qr=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&&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_!==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=cf(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 Wi(n,t,e,i,r,s){let o=t===void 0?void 0:Xt.get(t,r);return o||(o=new So(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 df=So;function Ht(n){return n?Array.isArray(n)?Jr(n):typeof n=="object"&&"src"in n?o_(n):n:null}function o_(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]),Wi(r.canvas,t,void 0,U.LOADED,n.color,!0),Xt.getPattern(t,n.color)}var ts="ol-hidden";var Ui="ol-unselectable";var rr="ol-control",Zl="ol-collapsed",a_=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"),ff=["style","variant","weight","size","lineHeight","family"],Ro={normal:400,bold:700},To=function(n){let t=n.match(a_);if(!t)return null;let e={lineHeight:"normal",size:"1.2em",style:"normal",weight:"400",variant:"normal"};for(let i=0,r=ff.length;i<r;++i){let s=t[i+1];s!==void 0&&(e[ff[i]]=typeof s=="string"?s.trim():s)}return isNaN(Number(e.weight))&&e.weight in Ro&&(e.weight=Ro[e.weight]),e.families=e.family.split(/,\s?/).map(i=>i.trim().replace(/^['"]|['"]$/g,"")),e};var Io="10px sans-serif",Tt="#000",Be="round",qt=[],$t=0,Ve="round",fi=10,mf=0,Wt="#000",Yi="center",xn="middle",gi=[0,0,0,0],mi=1,yn=new wt,es=null,gf,Bl={},l_=new Set(["serif","sans-serif","monospace","cursive","fantasy","system-ui","ui-serif","ui-sans-serif","ui-monospace","ui-rounded","emoji","math","fangsong"]);function c_(n,t,e){return`${n} ${t} 16px "${e}"`}var pf=(function(){let t,e;async function i(s){await e.ready;let o=To(s),a=o.families[0].toLowerCase(),l=o.weight,h=[];return e.forEach(d=>{let f=d.family.replace(/^['"]|['"]$/g,"").toLowerCase(),g=Ro[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=yn.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)?(Xe(Bl),yn.set(h,100)):(c+=10,yn.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=To(s);if(!o)return;let a=o.families,l=!1;for(let h of a){if(l_.has(h))continue;let c=c_(o.style,o.weight,h);yn.get(c)===void 0&&(yn.set(c,0,!0),l=!0)}l&&(clearTimeout(t),t=setTimeout(r,100))}})(),h_=(function(){let n;return function(t){let e=Bl[t];if(e==null){if(Rt){let i=To(t),r=_f(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);Bl[t]=e}return e}})();function _f(n,t){return es||(es=nt(1,1)),n!=gf&&(es.font=n,gf=es.font),es.measureText(t)}function yf(n,t){return _f(n,t).width}function Vl(n,t,e){if(t in e)return e[t];let i=t.split(`5-`).reduce((r,s)=>Math.max(r,yf(n,s)),0);return e[t]=i,i}function xf(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=yf(f,d);e.push(g),o+=g;let m=h_(f);i.push(m),l=Math.max(l,m)}return{width:s,height:a,widths:e,heights:i,lineWidths:r}}function Ef(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]),u_(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 u_(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 jl=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()}},bo=jl;var Hl=class n extends bo{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 df(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),v=s-E,C=Math.sqrt(y*y+v*v)/y;if(C<=i){let T=C*e/2-s-r;return 2*Math.max(p,T)}return p*2}createRenderOptions(){let t=Be,e=Ve,i=0,r=null,s=0,o,a=0;this.stroke_&&(o=Ht(this.stroke_.getColor()??Wt),a=this.stroke_.getWidth()??mi,r=this.stroke_.getLineDash(),s=this.stroke_.getLineDashOffset()??0,e=this.stroke_.getLineJoin()??Ve,t=this.stroke_.getLineCap()??Be,i=this.stroke_.getMiterLimit()??fi);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=de(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()}},Lo=Hl;var ql=class n extends Lo{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}},Ao=ql;var $l=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=Wi(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:de(t).toString():""}loading(){return!!this.patternImage_}ready(){return this.patternImage_?this.patternImage_.ready():Promise.resolve()}},pt=$l;function wf(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 Jl=class n extends bo{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;B(!(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)),B(a!==void 0&&a.length>0,"A defined and non-empty `src` or `image` must be provided"),B(!((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?de(t.color):null,this.iconImage_=Wi(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(wf(g[0],g[1],t.width,t.height))};this.listenImageChange(f);return}}h!==void 0&&this.setScale(wf(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?de(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_=Wi(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_=Wi(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()}},En=Jl;var Ql=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=Ql;var Mo=class n{constructor(t){t=t||{},this.geometry_=null,this.geometryFunction_=Cf,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_=Cf,this.geometry_=t}setZIndex(t){this.zIndex_=t}};function vf(n){let t;if(typeof n=="function")t=n;else{let e;Array.isArray(n)?e=n:(B(typeof n.getZIndex=="function","Expected an `Style` or an array of `Style`"),e=[n]),t=function(){return e}}return t}var tc=null;function ec(n,t){if(!tc){let e=new pt({color:"rgba(255,255,255,0.4)"}),i=new Mt({color:"#3399CC",width:1.25});tc=[new Mo({image:new Ao({fill:e,stroke:i,radius:5}),fill:e,stroke:i})]}return tc}function Cf(n){return n.getGeometry()}var It=Mo;var d_="#333",ic=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:d_}),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}},pi=ic;function fe(n,t){return(n.get("priority")||0)-(t.get("priority")||0)}function Tf(n){let t=n.get("pin");return!t||ge(t)||t.insideHighlightedZone||sr(t)?null:nc(t,!1)}function If(n){let t=n.get("pin");return!t||!u.highlightedZones.size||!t.insideHighlightedZone||ge(t)||sr(t)?null:nc(t,!1)}function bf(n){let t=n.get("pin");return!t||ge(t)||!u.labelsHeld?null:Of(t)}function Lf(n){let t=n.get("pin");if(!t||ge(t)||t.insideHighlightedZone||sr(t)||ns())return null;if(u.labelsHeld)return is(t,!1);let e=u.fitZoom+Math.log2(Uf(t.category));return(u.engine.getView().getZoom()||0)<e?null:is(t,!1)}function Af(n){let t=n.get("pin");return!t||ge(t)||t.insideHighlightedZone||sr(t)||!ns()?null:is(t,!1)}function Mf(n){let t=n.get("pin");return!t||!u.highlightedZones.size||!t.insideHighlightedZone||ge(t)||sr(t)?null:is(t,!1)}function Pf(n){let t=n.get("pin");if(!t||ge(t))return null;if(t.category.displayType==="text")return is(t,t===u.selectedPin);let e=nc(t,t===u.selectedPin);return t===u.hoveredPin||t===u.selectedPin?[e,Of(t)]:e}function nc(n,t){let e=`marker:${n.category.id}:${t?1:0}`;if(u.styleCache.has(e))return u.styleCache.get(e);let i=Vr(n.category),r=t?2e7:n.priority,s=u.markerIcons.get(kf(n.category)),o;return s?o=new It({image:new En({src:s,width:t?36:31,height:t?36:31}),zIndex:r}):o=new It({text:new pi({text:zi(n.category.title),font:`900 ${t?15:13}px Inter, sans-serif`,fill:new pt({color:i}),stroke:new Mt({color:Br(),width:t?4:3})}),zIndex:r}),u.styleCache.set(e,o),o}function Of(n){let t=`marker-label:${n.location.id}`;if(u.styleCache.has(t))return u.styleCache.get(t);let e=new It({text:new pi({text:n.location.title,offsetY:21,font:'700 10px "Arial Narrow", "Roboto Condensed", sans-serif',fill:new pt({color:"#f2ece0"}),stroke:new Mt({color:"rgba(0,0,0,0.98)",width:3}),backgroundFill:new pt({color:"rgba(10,12,17,0.72)"}),padding:[2,4,2,4],overflow:!0}),zIndex:n.priority});return u.styleCache.set(t,e),e}function Df(n){if(!n.iconAsset)return;let t=kf(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=Vr(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=Br(),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")),f_(),u.layers.pins.changed(),u.layers.zonePins.changed(),u.layers.priority.changed()},e.onerror=()=>u.markerIcons.set(t,!1),e.src=Pl(n.iconAsset)}function f_(){for(let n of u.styleCache.keys())n.startsWith("marker:")&&u.styleCache.delete(n)}function kf(n){return`${n.iconAsset||""}:${Vr(n)}:${u.map?.iconOutset||"light"}`}function is(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 pi({text:n.location.title,font:`${t?"900":"800"} 14px "Arial Narrow", "Roboto Condensed", sans-serif`,fill:new pt({color:t?"#7fd0ea":"#f2ece0"}),stroke:new Mt({color:"rgba(0,0,0,0.95)",width:4}),backgroundFill:new pt({color:t?"rgba(13,16,23,0.9)":"rgba(10,12,17,0.58)"}),backgroundStroke:t?new Mt({color:"#3aa5c9",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 rc(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=g_(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=Mn[Math.max(0,ae.indexOf(e.hash[e.hash.length-1]))%Mn.length],m=new It({fill:r?void 0:new pt({color:s?`rgba(5, 8, 16, ${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 pi({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(8,11,18,0.88)":"rgba(12,15,22,0.76)"}),padding:h,overflow:!0}):void 0,zIndex:i||r?100:n.get("priority")});return u.styleCache.set(f,m),m}function g_(n,t,e,i,r){if(!r)return!0;let s=m_(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 Sf=document.createElement("canvas").getContext("2d"),Rf=new Map;function m_(n,t){let e=`${t}|${n}`,i=Rf.get(e);return i===void 0&&(Sf.font=t,i=Sf.measureText(n).width,Rf.set(e,i)),i}var p_=new It({fill:new pt({color:"rgba(5, 8, 16, 0.62)"})});function Ff(){return u.zonesVisible?p_:null}function Nf(n){if(!u.zonesVisible)return null;let t=n.get("zone"),e=n.get("child"),i=u.highlightedZones.has(t.id),r=Wf(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 zf(n){if(!u.zonesVisible||ns())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:Xf(n)}function Gf(n){return!u.zonesVisible||!ns()?null:Xf(n)}function Xf(n){let t=n.get("child"),e=n.get("zone"),i=u.highlightedZones.has(e.id),r=Wf(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 pi({text:e.title.toLocaleUpperCase(),font:`${t?"700 12px":"800 14px"} "Arial Narrow", "Roboto Condensed", sans-serif`,fill:new pt({color:i?"#10131a":r?"rgba(196,191,177,0.56)":t?"#c8c2b4":"#f2ece0"}),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(8,11,18,0.84)":"rgba(13,16,23,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 Wf(n){if(!u.highlightedZones.size||u.highlightedZones.has(n))return!1;for(let t of u.highlightedZones)if(__(n,t))return!1;return!0}function __(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 sc=class n extends We{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<bi(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 Ue(this.flatCoordinates,0,this.flatCoordinates.length,this.stride)}getPoint(t){let e=this.flatCoordinates.length/this.stride;return t<0||e<=t?null:new hi(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 hi(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(Lr(t,o,a))return!0}return!1}setCoordinates(t,e){this.setLayout(e,t,1),this.flatCoordinates||(this.flatCoordinates=[]),this.flatCoordinates.length=Gr(this.flatCoordinates,0,t,this.stride),this.changed()}},Yf=sc;function Po(n,t,e,i){let r=[],s=ut();for(let o=0,a=e.length;o<a;++o){let l=e[o];s=On(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 oc=class n extends We{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<bi(this.getExtent(),t,e)?r:(this.maxDeltaRevision_!=this.getRevision()&&(this.maxDelta_=Math.sqrt(Zd(this.flatCoordinates,0,this.endss_,this.stride,0)),this.maxDeltaRevision_=this.getRevision()),Bd(this.getOrientedFlatCoordinates(),0,this.endss_,this.stride,this.maxDelta_,!0,t,e,i,r))}containsXY(t,e){return Ju(this.getOrientedFlatCoordinates(),0,this.endss_,this.stride,t,e)}getArea(){return Yd(this.getOrientedFlatCoordinates(),0,this.endss_,this.stride)}getCoordinates(t){let e;return t!==void 0?(e=this.getOrientedFlatCoordinates().slice(),bl(e,0,this.endss_,this.stride,t)):e=this.flatCoordinates,Xr(e,0,this.endss_,this.stride)}getEndss(){return this.endss_}getFlatInteriorPoints(){if(this.flatInteriorPointsRevision_!=this.getRevision()){let t=Po(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 Yf(this.getFlatInteriorPoints().slice(),"XYM")}getOrientedFlatCoordinates(){if(this.orientedRevision_!=this.getRevision()){let t=this.flatCoordinates;qd(t,0,this.endss_,this.stride)?this.orientedFlatCoordinates_=t:(this.orientedFlatCoordinates_=t.slice(),this.orientedFlatCoordinates_.length=bl(this.orientedFlatCoordinates_,0,this.endss_,this.stride)),this.orientedRevision_=this.getRevision()}return this.orientedFlatCoordinates_}getSimplifiedGeometryInternal(t){let e=[],i=[];return e.length=jd(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 Ye(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 Ye(e.slice(s,h),t,l);r.push(c),s=h}return r}getType(){return"MultiPolygon"}intersectsExtent(t){return td(this.getOrientedFlatCoordinates(),0,this.endss_,this.stride,t)}setCoordinates(t,e){this.setLayout(e,t,3),this.flatCoordinates||(this.flatCoordinates=[]);let i=Ud(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()}},Kf=oc;function ac(){let n=(u.map.zones||[]).filter(hc);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,Oo(!0),w.zoneIndex.hidden=n.length===0,w.zoneCount.textContent=Ie(n.length);for(let t of n){let e=ut(),i=[],r=!1;for(let l of t.features||[]){let h=E_(l);h&&(r=!0,i.push(h),Ds(e,h.getExtent()),u.sources.zones.addFeature(new Fi({geometry:h,zone:t,color:yo(t.id),child:t.parentRegionId!=null})))}if(!r)continue;let s=yo(t.id),o=t.center?Do(t.center.lat,t.center.lng):Bt(e),a=Math.max(e[2]-e[0],e[3]-e[1]);u.sources.zoneTitles.addFeature(new Fi({geometry:new hi(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,Bf(),y_()}function Bf(){if(u.sources.zoneScrim.clear(),!u.highlightedZones.size)return;let[n,t,e,i]=u.projection.getExtent(),r=[Zf([[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(Zf(h.getCoordinates(),c>0))})}u.sources.zoneScrim.addFeature(new Fi({geometry:new Ye(r)}))}function Zf(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 y_(){let n=document.createDocumentFragment();for(let{zone:t,depth:e}of x_()){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)}w.zoneList.replaceChildren(n),w.zoneIndex.hidden=u.zoneRecords.size===0}function x_(){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 Oo(n){u.zonesVisible=n,w.zoneToggle.checked=n,u.layers.zoneScrim.setVisible(n),u.layers.zones.setVisible(n),u.layers.zoneTitles.setVisible(n),u.layers.zoneTitleDetail.setVisible(n)}function Vf(n){let t=u.zoneRecords.get(n);t&&(u.focusedZoneID=n,Hf(),Te(),u.engine.getView().fit(t.extent,{size:u.engine.getSize(),padding:[54,54,54,54],maxZoom:Ze(u.variant),duration:220}),w.sidebar.classList.remove("is-open"),w.mobileLegend.setAttribute("aria-expanded","false"))}function jf(n){u.zoneRecords.has(n)&&(u.highlightedZones.has(n)?u.highlightedZones.delete(n):(u.highlightedZones.add(n),Oo(!0)),u.hoveredPin=null,lc(),cc(),Hf(),Bf(),u.layers.zones.changed(),u.layers.zoneTitles.changed(),u.layers.zoneTitleDetail.changed())}function Hf(){w.zoneIndex.classList.toggle("has-highlights",u.highlightedZones.size>0);for(let n of w.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 E_(n){if(!n?.coordinates)return null;let t=([e,i])=>Do(i,e);return n.type==="Polygon"?new Ye(n.coordinates.map(e=>e.map(t))):n.type==="MultiPolygon"?new Kf(n.coordinates.map(e=>e.map(i=>i.map(t)))):null}function Do(n,t){let e=w_(),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 w_(){let n=u.game.tileGrid,t=u.map?.grid;return t?{...n,...t}:n}function qf(){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"&&Df(t);for(let e of t.locations){let i={location:e,category:t,group:n,coordinate:Do(e.lat,e.lng),filteredHidden:!1,priority:R_(t,e),feature:null};i.feature=new Fi({geometry:new hi(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)}}ue()}function ue(){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)}lc(),cc(),u.selectedPin?.filteredHidden&&Te(),Gi()}function lc(){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=>C_(i,t.coordinate)))}function C_(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 cc(){u.eligibleLocations=u.pins.filter(n=>!ge(n)).length,Ke(),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(),wn()}function Ke(){u.sources.priority.clear();for(let n of u.pins){if(ge(n))continue;let t=!!u.search&&n.location.title.toLocaleLowerCase().includes(u.search);(n===u.selectedPin||n===u.hoveredPin||t||er(n))&&u.sources.priority.addFeature(n.feature)}}function or(n){u.hoveredPin!==n&&(u.hoveredPin=n,u.sources&&(Ke(),u.layers.pins.changed(),u.layers.priority.changed()))}function ko(n){u.labelsHeld!==n&&(u.labelsHeld=n,w.labelsHint.textContent=n?"Z \xB7 labels shown":"Z \xB7 hold for labels",u.layers.pinLabels.changed(),u.layers.text.changed())}function sr(n){return n===u.selectedPin||n===u.hoveredPin||er(n)||!!u.search&&n.location.title.toLocaleLowerCase().includes(u.search)}function ge(n){return n.filteredHidden||v_(n)||S_(n)||!hc(n.location)}function hc(n){let t=u.variant?.shard;return!t||!n.shard||n.shard===t}function v_(n){return!u.highlightedZones.size||n.insideHighlightedZone||n===u.selectedPin?!1:!(u.search&&n.location.title.toLocaleLowerCase().includes(u.search))}function S_(n){return!u.gridEnabled||!u.gridPrefix||er(n)||n===u.selectedPin?!1:!(u.search&&n.location.title.toLocaleLowerCase().includes(u.search))}function R_(n,t){return Math.max(0,1e6-Math.min(n.locations.length,999)*1e3)+rf(t.id)%1e3}function Uf(n){return n.locations.length>200?4:n.locations.length>75?2.5:1}function ns(){return(u.engine?.getView().getZoom()||0)>=(u.variant?.maxZoom||0)-.05}function $f(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 Jf(){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(T_(t.key,t.title,i));let r=document.createElement("div");r.className="category-toggles";for(let s of t.categories)r.append(I_(s));e.append(r),n.append(e)}w.legend.replaceChildren(n),Fo(),Xi()}function T_(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=Ie(e),r.append(s,o,a);let l=Qf(`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 Qf(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 I_(n){let t=n.displayType==="text",e=document.createElement("label");e.className="category-row",ir(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",nr(r,n,zi(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=Ie(n.locations.length);let a=Qf(`Show only ${n.title}`);return a.dataset.onlyCategory=String(n.id),e.append(i,r,s,a,o),e}function uc(n){if(u.collapsedSections.clear(),n)for(let t of w.layers.querySelectorAll("[data-section]"))u.collapsedSections.add(t.dataset.section);Fo()}function Fo(){for(let n of w.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)}Re()}function rs(n){if(u.hiddenCategories.clear(),!n)for(let t of u.map.groups)for(let e of t.categories)u.hiddenCategories.add(e.id);jr(),ue(),Gi(),Xi()}function jr(){for(let n of document.querySelectorAll("[data-category]"))n.checked=!u.hiddenCategories.has(Number(n.dataset.category))}function tg(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);jr(),ue(),Xi()}function eg(n){if(u.map){if(b_(n)){rs(!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)}jr(),ue(),Gi(),Xi()}}function b_(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 L_(){let n=w.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 Xi(){if(u.map){for(let n of u.map.sections){let t=w.legend.querySelector(`input[data-section-toggle="${n.key}"]`);t&&(t.checked=n.categories.some(e=>!u.hiddenCategories.has(e.id)))}L_(),Re()}}async function ig(n){let[t,e]=await Promise.all([fetch(`${u.game.base}/maps/${n.slug}.json`),fetch(`${u.game.base}/maps/${n.slug}.bin`)]);if(!t.ok||!e.ok)throw new Error(`map ${n.slug} is not served under this catalog any more`);let[i,r]=await Promise.all([t.json(),e.arrayBuffer()]),s=i.groups.flatMap(o=>o.categories);return A_(r,s),{...n,grid:i.grid,variants:i.variants,groups:i.groups,zones:i.zones||[],merged:i.merged||[],sections:$f(i.groups)}}function A_(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 af(){let n=`${u.game.base}/${u.map.slug}`;return u.textByMap.has(n)||u.textByMap.set(n,fetch(`${u.game.base}/maps/${u.map.slug}.text`).then(t=>t.json()).catch(()=>({}))),u.textByMap.get(n)}var No=null;function Cn(){return No||(No=M_().finally(()=>{No=null})),No}async function M_(){let n=await fetch("/data/catalog.json");if(!n.ok)return;let t=u.game;if(u.catalog=await n.json(),nn(w.game,u.catalog.games,"title"),dc(),!u.catalog.games.length)return;let e=t&&u.catalog.games.find(i=>i.slug===t.slug);if(!e){let i=Jn();await _i(i.game||$n()?.game||u.catalog.games[0].slug,i.game?i.map:void 0);return}if(e.stamp!==t.stamp){for(let r of u.textByMap.keys())r.startsWith(t.base+"/")&&u.textByMap.delete(r);let i=u.engine?.getView();u.restore={game:e.slug,map:u.map?.slug,variant:u.map?u.map.variants.indexOf(u.variant):0,center:i?.getCenter(),zoom:i?.getZoom(),hidden:[...u.hiddenCategories],collapsed:[...u.collapsedSections],overviewDocked:u.overviewDocked,dockFolded:u.dockFolded,dockDismissed:u.dockDismissed},await _i(e.slug,u.map?.slug);return}u.game=e,w.game.value=e.slug}function dc(){let n=!u.catalog?.games?.length;w.emptyState.hidden=!n,u.catalog?.bundlesDir&&(w.emptyPath.textContent=u.catalog.bundlesDir)}async function fc(){for(let n of[w.emptyOpen,w.addBundles])n.disabled=!0;try{let t=await(await fetch("/data/bundles/import",{method:"POST"})).json().catch(()=>({}));await Cn();let e=t.imported?.[0];e&&u.catalog.games.some(i=>i.slug===e)&&await _i(e)}finally{for(let n of[w.emptyOpen,w.addBundles])n.disabled=!1}}var Pt={ADD:"add",REMOVE:"remove"};var ng={LENGTH:"length"},ar=class extends Lt{constructor(t,e,i){super(t),this.element=e,this.index=i}},gc=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(ng.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 ar(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 ar(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 ar(Pt.REMOVE,r,t)),this.dispatchEvent(new ar(Pt.ADD,e,t))}updateLength_(){this.set(ng.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=gc;var mc=class extends Lt{constructor(t,e,i){super(t),this.map=e,this.frameState=i!==void 0?i:null}},Ki=mc;var pc=class extends Ki{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()}},je=pc;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 ss={POINTERMOVE:"pointermove",POINTERDOWN:"pointerdown",POINTERUP:"pointerup",POINTEROVER:"pointerover",POINTEROUT:"pointerout",POINTERENTER:"pointerenter",POINTERLEAVE:"pointerleave",POINTERCANCEL:"pointercancel"};var _c=class extends ki{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,ss.POINTERDOWN,this.handlePointerDown_,this),this.originalPointerMoveEvent_,this.relayedListenerKey_=Z(i,ss.POINTERMOVE,this.relayMoveEvent_,this),this.boundHandleTouchMove_=this.handleTouchMove_.bind(this),this.element_.addEventListener(P.TOUCHMOVE,this.boundHandleTouchMove_,to?{passive:!1}:!1)}emulateClick_(t){let e=new je(at.CLICK,this.map_,t);this.dispatchEvent(e),this.clickTimeoutId_!==void 0?(clearTimeout(this.clickTimeoutId_),this.clickTimeoutId_=void 0,e=new je(at.DBLCLICK,this.map_,t),this.dispatchEvent(e)):this.clickTimeoutId_=setTimeout(()=>{this.clickTimeoutId_=void 0;let i=new je(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 je(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 je(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 je(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 je(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()}},rg=_c;var He={POSTRENDER:"postrender",MOVESTART:"movestart",MOVEEND:"moveend",LOADSTART:"loadstart",LOADEND:"loadend"};var kt={LAYERGROUP:"layergroup",SIZE:"size",TARGET:"target",VIEW:"view"};var os=1/0,yc=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,Xe(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){B(!(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!=os?(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==os?delete this.queuedElements_[this.keyFunction_(o)]:(i[r]=l,e[r++]=o);e.length=r,i.length=r,this.heapify_()}},sg=yc;var xc=class extends sg{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())}}},og=xc;function ag(n,t,e,i,r){if(!n||!(e in n.wantedTiles))return os;if(!n.wantedTiles[e][t.getKey()])return os;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 me={CENTER:"center",RESOLUTION:"resolution",ROTATION:"rotation"};function Ec(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 lg(n){return n}function wc(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 Cc(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 cg(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?wc(l,e,o,i):l;if(a)return t?Cc(r,c,h):et(r,h,c);let d=Math.min(c,r),f=Math.floor(Kn(n,d,s));return n[f]>c&&f<n.length-1?n[f+1]:n[f]}})}function hg(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?wc(t,r,l,s):t;if(h)return i?Cc(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 vc(n,t,e,i,r){return e=e!==void 0?e:!0,(function(s,o,a,l){if(s!==void 0){let h=i?wc(n,i,a,r):n;return!e||!l?et(s,t,h):Cc(s,h,t)}})}function lr(n){if(n!==void 0)return 0}function Sc(n){if(n!==void 0)return n}function ug(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 dg(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 Rc=0,Ic=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_=Vs(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&&Uu(),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 me)delete e[a];this.setProperties(e,!0);let i=O_(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=P_(t),s=i.constraint,o=D_(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&&zo(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||dd,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=Ge(c.rotation-l+Math.PI,2*Math.PI)-Math.PI;d.targetRotation=l+f,l=d.targetRotation}k_(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&&zo(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?Ge(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&&zo(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]],Nn(i,t-this.getRotation()),wu(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&&kr(t,this.getProjection())}getCenterInternal(){return this.get(me.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 Mi(e,this.getProjection())}calculateExtentInternal(t){t=t||this.getViewportSizeMinusPadding_();let e=this.getCenterInternal();B(e,"The view center is not defined");let i=this.getResolution();B(i!==void 0,"The view resolution is not defined");let r=this.getRotation();return B(r!==void 0,"The view rotation is not defined"),Mr(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(me.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(me.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=Tc(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=Kn(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(B(Array.isArray(t)||typeof t.getSimplifiedGeometry=="function","Invalid extent or geometry provided as `geometry`"),Array.isArray(t)){B(!ze(t),"Cannot fit empty extent provided as `geometry`");let r=Ce(t,this.getProjection());i=Ll(r)}else if(t.getType()==="Circle"){let r=Ce(t.getExtent(),this.getProjection());i=Ll(r),i.rotate(this.getRotation(),Bt(r))}else{let r=dn();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=Bt(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),zo(p,!0))}centerOn(t,e,i){this.centerOnInternal(we(t,this.getProjection()),e,i)}centerOnInternal(t,e,i){this.setCenterInternal(Tc(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=Tc(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=kr(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(me.ROTATION)!==r&&this.set(me.ROTATION,r),this.get(me.RESOLUTION)!==o&&(this.set(me.RESOLUTION,o),this.set("zoom",this.getZoom(),!0)),(!a||!this.get(me.CENTER)||!ln(this.get(me.CENTER),a))&&this.set(me.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()||!ln(this.getCenterInternal(),l))&&(this.getAnimating()&&this.cancelAnimations(),this.animateInternal({rotation:s,center:l,resolution:a,duration:t,easing:he,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 zo(n,t){setTimeout(function(){n(t)},0)}function P_(n){if(n.extent!==void 0){let e=n.smoothExtentConstraint!==void 0?n.smoothExtentConstraint:!0;return Ec(n.extent,n.constrainOnlyCenter,e)}let t=Vs(n.projection,"EPSG:3857");if(n.multiWorld!==!0&&t.isGlobal()){let e=t.getExtent().slice();return e[0]=-1/0,e[2]=1/0,Ec(e,!1,!1)}return lg}function O_(n){let t,e,i,o=n.minZoom!==void 0?n.minZoom:Rc,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=Vs(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=cg(p,c,!m&&_,d):t=vc(e,i,c,!m&&_,d)}else{let y=(g?Math.max(j(g),ct(g)):360*si.degrees/f.getMetersPerUnit())/256/Math.pow(2,Rc),E=y/Math.pow(2,28-Rc);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=hg(l,e,i,c,!m&&_,d):t=vc(e,i,c,!m&&_,d)}return{constraint:t,maxResolution:e,minResolution:i,minZoom:o,zoomFactor:l}}function D_(n){if(n.enableRotation!==void 0?n.enableRotation:!0){let e=n.constrainRotation;return e===void 0||e===!0?dg():e===!1?Sc:typeof e=="number"?ug(e):Sc}return lr}function k_(n){return!(n.sourceCenter&&n.targetCenter&&!ln(n.sourceCenter,n.targetCenter)||n.sourceResolution!==n.targetResolution||n.sourceRotation!==n.targetRotation)}function Tc(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=Ic;var bc=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,He.POSTRENDER,this.render,this)),t.render()}}render(t){}setTarget(t){this.target_=typeof t=="string"?document.getElementById(t):t}},cr=bc;var Lc=class extends cr{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+" "+Ui+" "+rr+(this.collapsed_&&this.collapsible_?" "+Zl:"")+(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=>ad(()=>r))),i=e.length>0;if(this.renderedVisible_!=i&&(this.element.style.display=i?"":"none",this.renderedVisible_=i),!Gt(e,this.renderedAttributions_)){gd(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(Zl),this.collapsed_?el(this.collapseLabel_,this.label_):el(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)}},fg=Lc;var Ac=class extends cr{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+" "+Ui+" "+rr,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(ts)}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:he}):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(ts);!s&&i===0?this.element.classList.add(ts):s&&i!==0&&this.element.classList.remove(ts)}this.label_.style.transform=r}this.rotation_=i}},gg=Ac;var Mc=class extends cr{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+" "+Ui+" "+rr,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:he})):i.setZoom(s)}}},mg=Mc;function Go(n){n=n||{};let t=new Dt;return(n.zoom===void 0||n.zoom)&&t.push(new mg(n.zoomOptions)),(n.rotate===void 0||n.rotate)&&t.push(new gg(n.rotateOptions)),(n.attribution===void 0||n.attribution)&&t.push(new fg(n.attributionOptions)),t}var Pc=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_}},pg=Pc;var Oc={ACTIVE:"active"};var Dc=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(Oc.ACTIVE)}getMap(){return this.map_}handleEvent(t){return!0}setActive(t){this.set(Oc.ACTIVE,t)}setMap(t){this.map_=t}};function _g(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:fd,center:n.getConstrainedCenter(r)})}}function hr(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:he})}var qe=Dc;var kc=class extends qe{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();hr(a,o,s,this.duration_),i.preventDefault(),e=!0}return!e}},yg=kc;function as(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 xg=function(n){let t=n.originalEvent;return t.altKey&&!(t.metaKey||t.ctrlKey)&&t.shiftKey},F_=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)},Xo=function(n){let t=n.map.getTargetElement(),e=t.getRootNode();return(e instanceof ShadowRoot?e.host:t).hasAttribute("tabindex")?F_(n):!0},Eg=ai;var Wo=function(n){let t=n.originalEvent;return"pointerId"in t&&t.button==0&&!(ld&&qa&&t.ctrlKey)};var Uo=function(n){let t=n.originalEvent;return!t.altKey&&!(t.metaKey||t.ctrlKey)&&!t.shiftKey};var wg=function(n){let t=n.originalEvent;return qa?t.metaKey:t.ctrlKey},Cg=function(n){let t=n.originalEvent;return!t.altKey&&!(t.metaKey||t.ctrlKey)&&t.shiftKey},Yo=function(n){let t=n.originalEvent,e=t.target.tagName;return e!=="INPUT"&&e!=="SELECT"&&e!=="TEXTAREA"&&!t.target.isContentEditable},Ko=function(n){let t=n.originalEvent;return"pointerId"in t&&t.pointerType=="mouse"};var vg=function(n){let t=n.originalEvent;return"pointerId"in t&&t.isPrimary&&t.button===0};var Fc=class extends qe{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 ur(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 $e=Fc;var Nc=class extends $e{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:as(Uo,vg);this.condition_=t.onFocusOnly?as(Xo,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(ur(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();Cu(s,a.getResolution()),Nn(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:he})}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}},Sg=Nc;var zc=class extends $e{constructor(t){t=t||{},super({stopDown:li}),this.condition_=t.condition?t.condition:xg,this.lastAngle_=void 0,this.duration_=t.duration!==void 0?t.duration:250}handleDragEvent(t){if(!Ko(t))return;let e=t.map,i=e.getView();if(i.getConstraints().rotation===lr)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 Ko(t)?(t.map.getView().endInteraction(this.duration_),!1):!0}handleDownEvent(t){return Ko(t)&&Wo(t)&&this.condition_(t)?(t.map.getView().beginInteraction(),this.lastAngle_=void 0,!0):!1}},Rg=zc;var Gc=class extends Di{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 Ye([r])}getGeometry(){return this.geometry_}},Tg=Gc;var dr={BOXSTART:"boxstart",BOXDRAG:"boxdrag",BOXEND:"boxend",BOXCANCEL:"boxcancel"},vn=class extends Lt{constructor(t,e,i){super(t),this.coordinate=e,this.mapBrowserEvent=i}},Xc=class extends $e{constructor(t){super(),this.on,this.once,this.un,t=t??{},this.box_=new Tg(t.className||"ol-dragbox"),this.minArea_=t.minArea??64,t.onBoxEnd&&(this.onBoxEnd=t.onBoxEnd),this.startPixel_=null,this.condition_=t.condition??Wo,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 vn(dr.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 vn(e?dr.BOXEND:dr.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 vn(dr.BOXSTART,t.coordinate,t)),!0):!1}onBoxEnd(t){}setActive(t){t||(this.box_.setMap(null),this.startPixel_&&(this.dispatchEvent(new vn(dr.BOXCANCEL,this.startPixel_,null)),this.startPixel_=null)),super.setActive(t)}setMap(t){this.getMap()&&(this.box_.setMap(null),this.startPixel_&&(this.dispatchEvent(new vn(dr.BOXCANCEL,this.startPixel_,null)),this.startPixel_=null)),super.setMap(t)}},Ig=Xc;var Wc=class extends Ig{constructor(t){t=t||{};let e=t.condition?t.condition:Cg;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:he})}},bg=Wc;var Zi={LEFT:"ArrowLeft",UP:"ArrowUp",RIGHT:"ArrowRight",DOWN:"ArrowDown"};var Uc=class extends qe{constructor(t){super(),t=t||{},this.defaultCondition_=function(e){return Uo(e)&&Yo(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==Zi.DOWN||r==Zi.LEFT||r==Zi.RIGHT||r==Zi.UP)){let o=t.map.getView(),a=o.getResolution()*this.pixelDelta_,l=0,h=0;r==Zi.DOWN?h=-a:r==Zi.LEFT?l=-a:r==Zi.RIGHT?l=a:h=a;let c=[l,h];Nn(c,o.getRotation()),_g(o,c,this.duration_),i.preventDefault(),e=!0}}return!e}},Lg=Uc;var Yc=class extends qe{constructor(t){super(),t=t||{},this.condition_=t.condition?t.condition:function(e){return!wg(e)&&Yo(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();hr(a,o,void 0,this.duration_),i.preventDefault(),e=!0}}return!e}},Ag=Yc;var N_=40,z_=300,G_=3,Kc=class extends qe{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:Eg;this.condition_=t.onFocusOnly?as(Xo,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*=N_;break;case WheelEvent.DOM_DELTA_PAGE:o*=z_;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*G_),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),hr(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)}},Mg=Kc;var Zc=class extends $e{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!==lr&&(this.anchor_=o.getCoordinateFromPixelInternal(o.getEventPixel(ur(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}},Pg=Zc;var Bc=class extends $e{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(ur(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}},Og=Bc;function Zo(n){n=n||{};let t=new Dt,e=new pg(-.005,.05,100);return(n.altShiftDragRotate===void 0||n.altShiftDragRotate)&&t.push(new Rg),(n.doubleClickZoom===void 0||n.doubleClickZoom)&&t.push(new yg({delta:n.zoomDelta,duration:n.zoomDuration})),(n.dragPan===void 0||n.dragPan)&&t.push(new Sg({onFocusOnly:n.onFocusOnly,kinetic:e})),(n.pinchRotate===void 0||n.pinchRotate)&&t.push(new Pg),(n.pinchZoom===void 0||n.pinchZoom)&&t.push(new Og({duration:n.zoomDuration})),(n.keyboard===void 0||n.keyboard)&&(t.push(new Lg),t.push(new Ag({delta:n.zoomDelta,duration:n.zoomDuration}))),(n.mouseWheelZoom===void 0||n.mouseWheelZoom)&&t.push(new Mg({onFocusOnly:n.onFocusOnly,duration:n.zoomDuration})),(n.shiftDragZoom===void 0||n.shiftDragZoom)&&t.push(new bg({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 Vc=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,B(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){B(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()}},Bo=Vc;var Bi={ADDLAYER:"addlayer",REMOVELAYER:"removelayer"},Le=class extends Lt{constructor(t,e){super(t),this.layer=e}},jc={LAYERS:"layers"},Hc=class n extends Bo{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(jc.LAYERS,this.handleLayersChanged_),i?Array.isArray(i)?i=new Dt(i.slice(),{unique:!0}):B(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);Xe(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 Le(Bi.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,Bi.ADDLAYER,this.handleLayerGroupAdd_,this),Z(t,Bi.REMOVELAYER,this.handleLayerGroupRemove_,this)),this.listenerKeys_[Y(t)]=e}handleLayerGroupAdd_(t){this.dispatchEvent(new Le(Bi.ADDLAYER,t.layer))}handleLayerGroupRemove_(t){this.dispatchEvent(new Le(Bi.REMOVELAYER,t.layer))}handleLayersAdd_(t){let e=t.element;this.registerLayerListeners_(e),this.dispatchEvent(new Le(Bi.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 Le(Bi.REMOVELAYER,e)),this.changed()}getLayers(){return this.get(jc.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 Le(Bi.REMOVELAYER,i[r]))}this.set(jc.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=Ne(l.extent,r.extent):l.extent=r.extent),l.zIndex===void 0&&(l.zIndex=s)}return e}getSourceState(){return"ready"}},ls=Hc;var Ft={PRERENDER:"prerender",POSTRENDER:"postrender",PRECOMPOSE:"precompose",POSTCOMPOSE:"postcompose",RENDERCOMPLETE:"rendercomplete"};var qc=class extends Bo{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 cs(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);B(!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 cs(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 Sn=qc;function Vo(n,t,e=0,i=n.length-1,r=X_){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));Vo(n,t,g,m,r)}let s=n[t],o=e,a=i;for(hs(n,e,t),r(n[i],s)>0&&hs(n,e,i);o<a;){for(hs(n,o,a),o++,a--;r(n[o],s)<0;)o++;for(;r(n[a],s)>0;)a--}r(n[e],s)===0?hs(n,e,a):(a++,hs(n,a,i)),a<=t&&(e=a+1),t<=a&&(i=a-1)}}function hs(n,t,e){let i=n[t];n[t]=n[e],n[e]=i}function X_(n,t){return n<t?-1:n>t?1:0}var Rn=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(!Ho(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;Ho(t,l)&&(e.leaf?i.push(a):Jc(t,l)?this._all(a,i):s.push(a))}e=s.pop()}return i}collides(t){let e=this.data;if(!Ho(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(Ho(t,o)){if(e.leaf||Jc(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=gr([]),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=W_(t,i.children,e);if(c!==-1)return i.children.splice(c,1),s.push(i),this._condense(s),this}!h&&!i.leaf&&Jc(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=gr(t.slice(e,i+1)),fr(a,this.toBBox),a;r||(r=Math.ceil(Math.log(s)/Math.log(o)),o=Math.ceil(s/Math.pow(o,r-1))),a=gr([]),a.leaf=!1,a.height=r;let l=Math.ceil(s/o),h=l*Math.ceil(Math.sqrt(o));Dg(t,e,i,h,this.compareMinX);for(let c=e;c<=i;c+=h){let d=Math.min(c+h-1,i);Dg(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 fr(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=$c(h),d=K_(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),ds(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=gr(i.children.splice(o,i.children.length-o));a.height=i.height,a.leaf=i.leaf,fr(i,this.toBBox),fr(a,this.toBBox),e?t[e-1].children.push(a):this._splitRoot(i,a)}_splitRoot(t,e){this.data=gr([t,e]),this.data.height=t.height+1,this.data.leaf=!1,fr(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=us(t,0,a,this.toBBox),h=us(t,a,i,this.toBBox),c=Z_(l,h),d=$c(l)+$c(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:U_,s=t.leaf?this.compareMinY:Y_,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=us(t,0,e,s),a=us(t,i-e,i,s),l=jo(o)+jo(a);for(let h=e;h<i-e;h++){let c=t.children[h];ds(o,t.leaf?s(c):c),l+=jo(o)}for(let h=i-e-1;h>=e;h--){let c=t.children[h];ds(a,t.leaf?s(c):c),l+=jo(a)}return l}_adjustParentBBoxes(t,e,i){for(let r=i;r>=0;r--)ds(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():fr(t[e],this.toBBox)}};function W_(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 fr(n,t){us(n,0,n.children.length,t,n)}function us(n,t,e,i,r){r||(r=gr(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];ds(r,n.leaf?i(o):o)}return r}function ds(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 U_(n,t){return n.minX-t.minX}function Y_(n,t){return n.minY-t.minY}function $c(n){return(n.maxX-n.minX)*(n.maxY-n.minY)}function jo(n){return n.maxX-n.minX+(n.maxY-n.minY)}function K_(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 Z_(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 Jc(n,t){return n.minX<=t.minX&&n.minY<=t.minY&&t.maxX<=n.maxX&&t.maxY<=n.maxY}function Ho(n,t){return t.minX<=n.maxX&&t.minY<=n.maxY&&t.maxX>=n.minX&&t.maxY>=n.minY}function gr(n){return{children:n,height:1,leaf:!0,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0}}function Dg(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;Vo(n,o,t,e,r),s.push(t,o,o,e)}}var In=0,$o=0,Ut=1<<In++,Q=1<<In++,Yt=1<<In++,Zt=1<<In++,xi=1<<In++,Tn=1<<In++,Jo=Math.pow(2,In)-1,th={[Ut]:"boolean",[Q]:"number",[Yt]:"string",[Zt]:"color",[xi]:"number[]",[Tn]:"size"},B_=Object.keys(th).map(Number).sort(Vt);function V_(n){return n in th}function yi(n){let t=[];for(let e of B_)fs(n,e)&&t.push(th[e]);return t.length===0?"untyped":t.length<3?t.join(" or "):t.slice(0,-1).join(", ")+", or "+t[t.length-1]}function fs(n,t){return(n&t)===t}function qo(n,t){return!!(n&t)}function Vi(n,t){return n===t}var ft=class{constructor(t,e){if(!V_(t))throw new Error(`literal expressions must have a specific type, got ${yi(t)}`);this.type=t,this.value=e}},Qo=class{constructor(t,e,...i){this.type=t,this.operator=e,this.args=i}};function ta(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(Vi(t,Yt))return new ft(Yt,n?"true":"false");if(!fs(t,Ut))throw new Error(`got a boolean, but expected ${yi(t)}`);return new ft(Ut,n)}case"number":{if(Vi(t,Tn))return new ft(Tn,mt(n));if(Vi(t,Ut))return new ft(Ut,!!n);if(Vi(t,Yt))return new ft(Yt,n.toString());if(!fs(t,Q))throw new Error(`got a number, but expected ${yi(t)}`);return new ft(Q,n)}case"string":{if(Vi(t,Zt))return new ft(Zt,$r(n));if(Vi(t,Ut))return new ft(Ut,!!n);if(!fs(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 sy(n,t,e);for(let i of n)if(typeof i!="number")throw new Error("expected an array of numbers");if(Vi(t,Tn)){if(n.length!==2)throw new Error(`expected an array of two values for a size, got ${n.length}`);return new ft(Tn,n)}if(Vi(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(!fs(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"},j_={[S.Get]:K(q(1,1/0),kg),[S.Var]:H_(),[S.Has]:K(q(1,1/0),kg),[S.Id]:K(q_,mr),[S.Concat]:K(q(2,1/0),st(Yt)),[S.GeometryType]:K($_,mr),[S.LineMetric]:K(J_,mr),[S.Resolution]:K(Qc,mr),[S.Zoom]:K(Qc,mr),[S.Time]:K(Qc,mr),[S.Any]:K(q(2,1/0),st(Ut)),[S.All]:K(q(2,1/0),st(Ut)),[S.Not]:K(q(1,1),st(Ut)),[S.Equal]:K(q(2,2),Ng()),[S.NotEqual]:K(q(2,2),Ng()),[S.GreaterThan]:K(q(2,2),st(Q)),[S.GreaterThanOrEqualTo]:K(q(2,2),st(Q)),[S.LessThan]:K(q(2,2),st(Q)),[S.LessThanOrEqualTo]:K(q(2,2),st(Q)),[S.Multiply]:K(q(2,1/0),Fg),[S.Coalesce]:K(q(2,1/0),Fg),[S.Divide]:K(q(2,2),st(Q)),[S.Add]:K(q(2,1/0),st(Q)),[S.Subtract]:K(q(2,2),st(Q)),[S.Clamp]:K(q(3,3),st(Q)),[S.Mod]:K(q(2,2),st(Q)),[S.Pow]:K(q(2,2),st(Q)),[S.Abs]:K(q(1,1),st(Q)),[S.Floor]:K(q(1,1),st(Q)),[S.Ceil]:K(q(1,1),st(Q)),[S.Round]:K(q(1,1),st(Q)),[S.Sin]:K(q(1,1),st(Q)),[S.Cos]:K(q(1,1),st(Q)),[S.Atan]:K(q(1,2),st(Q)),[S.Sqrt]:K(q(1,1),st(Q)),[S.Match]:K(q(4,1/0),zg,ty),[S.Between]:K(q(3,3),st(Q)),[S.Interpolate]:K(q(6,1/0),zg,ey),[S.Case]:K(q(3,1/0),Q_,iy),[S.In]:K(q(2,2),ny),[S.Number]:K(q(1,1/0),st(Jo)),[S.String]:K(q(1,1/0),st(Jo)),[S.Array]:K(q(1,1/0),st(Q)),[S.Color]:K(q(1,4),st(Q)),[S.Band]:K(q(1,3),st(Q)),[S.Palette]:K(q(2,2),ry),[S.ToString]:K(q(1,1),st(Ut|Q|Yt|Zt))};function kg(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 H_(){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,Jo,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"&&qo(r,Zt)&&!qo(r,Yt)?a=Zt:Array.isArray(s)&&s.length===2&&qo(r,Tn)&&!qo(r,xi)&&(a=Tn),r&=a,r===$o)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===$o)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 Qo(r,"var",new ft(Yt,i))}}function q_(n,t,e){e.featureId=!0}function $_(n,t,e){e.geometryType=!0}function J_(n,t,e){e.mCoordinate=!0}function Qc(n,t,e){e.mapState=!0}function mr(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 Fg(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 Ng(){return function(n,t,e){let i=n[0],r=n.length-1,s=new Array(r),o=Jo;for(let a=0;a<r;++a){let l=_t(n[a+1],o,e);o&=l.type}if(o===$o)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 Q_(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 zg(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 ty(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===$o)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 ey(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 iy(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 ny(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 ry(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 K(...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 Qo(e,r,...s)}}function sy(n,t,e){let i=n[0],r=j_[i];if(!r)throw new Error(`unknown operator: ${i}`);return r(n,t,e)}function ea(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 ea(n.getGeometries()[0]);default:return""}}function eh(){return{variables:{},properties:{},resolution:NaN,featureId:null,geometryType:""}}function Me(n,t,e){let i=_t(n,t,e);return Ae(i,e)}function Ae(n,t){if(n instanceof ft){if(n.type===Zt&&typeof n.value=="string"){let i=$r(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 oy(n,t);case S.Get:case S.Var:case S.Has:return ay(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=>Ae(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 cy(n,t);case S.Equal:case S.NotEqual:case S.LessThan:case S.LessThanOrEqualTo:case S.GreaterThan:case S.GreaterThanOrEqualTo:return ly(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 hy(n,t);case S.Case:return uy(n,t);case S.Match:return dy(n,t);case S.Interpolate:return fy(n,t);case S.ToString:return gy(n,t);default:throw new Error(`Unsupported operator ${e}`)}}function oy(n,t){let e=n.operator,i=n.args.length,r=new Array(i);for(let s=0;s<i;++s)r[s]=Ae(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 ay(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 ly(n,t){let e=n.operator,i=Ae(n.args[0],t),r=Ae(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 cy(n,t){let e=n.operator,i=n.args.length,r=new Array(i);for(let s=0;s<i;++s)r[s]=Ae(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 hy(n,t){let e=n.operator,i=n.args.length,r=new Array(i);for(let s=0;s<i;++s)r[s]=Ae(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 uy(n,t){let e=n.args.length,i=new Array(e);for(let r=0;r<e;++r)i[r]=Ae(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 dy(n,t){let e=n.args.length,i=new Array(e);for(let r=0;r<e;++r)i[r]=Ae(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 fy(n,t){let e=n.args.length,i=new Array(e);for(let r=0;r<e;++r)i[r]=Ae(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=hf(d)),c>=o)return h===2?d:f?my(s,o,a,l,c,d):gs(s,o,a,l,c,d);a=c,l=d}return l}}function gy(n,t){let e=n.operator,i=n.args.length,r=new Array(i);for(let s=0;s<i;++s)r[s]=Ae(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 gs(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 my(n,t,e,i,r,s){if(r-e===0)return i;let a=Ul(i),l=Ul(s),h=l[2]-a[2];h>180?h-=360:h<-180&&(h+=360);let c=[gs(n,t,e,a[0],r,l[0]),gs(n,t,e,a[1],r,l[1]),a[2]+gs(n,t,e,0,r,h),gs(n,t,e,i[3],r,s[3])];return uf(c)}function py(n){return!0}function _y(n,t){t=t??ta();let e=yy(n,t),i=eh();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=ea(r.getGeometry())),e(i)}}function Gg(n,t){t=t??ta();let e=n.length,i=new Array(e);for(let o=0;o<e;++o)i[o]=ih(n[o],t);let r=eh(),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=ea(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 Yg(n,t){if(t=t??ta(),!Array.isArray(n))return Gg([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 _y(s,t)}return Gg(n,t)}function yy(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?Me(s.filter,Ut,t):py,a;if(Array.isArray(s.style)){let l=s.style.length;a=new Array(l);for(let h=0;h<l;++h)a[h]=ih(s.style[h],t)}else a=[ih(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 ih(n,t){let e=ms(n,"",t),i=ps(n,"",t),r=xy(n,t),s=Ey(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 ms(n,t,e){let i;if(t+"fill-pattern-src"in n)i=Sy(n,t+"fill-",e);else{if(n[t+"fill-color"]==="none")return s=>null;i=na(n,t+"fill-color",e)}if(!i)return null;let r=new pt;return function(s){let o=i(s);return o===vo?null:(r.setColor(o),r)}}function ps(n,t,e){let i=Nt(n,t+"stroke-width",e),r=na(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=Kg(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===vo)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 xy(n,t){let e="text-",i=Ei(n,e+"value",t);if(!i)return null;let r=ms(n,e,t),s=ms(n,e+"background-",t),o=ps(n,e,t),a=ps(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=pr(n,e+"overflow",t),g=Ei(n,e+"placement",t),m=Nt(n,e+"repeat",t),_=ra(n,e+"scale",t),p=pr(n,e+"rotate-with-view",t),y=Nt(n,e+"rotation",t),E=Ei(n,e+"align",t),v=Ei(n,e+"justify",t),x=Ei(n,e+"baseline",t),C=pr(n,e+"keep-upright",t),T=Kg(n,e+"padding",t),A=sa(n,e+"declutter-mode"),R=new pi({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(v){let b=v(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)),C&&R.setKeepUpright(C(I)),R}}function Ey(n,t){return"icon-src"in n?wy(n,t):"shape-points"in n?Cy(n,t):"circle-radius"in n?vy(n,t):null}function wy(n,t){let e="icon-",i=e+"src",r=Zg(n[i],i),s=ia(n,e+"anchor",t),o=ra(n,e+"scale",t),a=Nt(n,e+"opacity",t),l=ia(n,e+"displacement",t),h=Nt(n,e+"rotation",t),c=pr(n,e+"rotate-with-view",t),d=Wg(n,e+"anchor-origin"),f=Ug(n,e+"anchor-x-units"),g=Ug(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=na(n,e+"color",t):_=Bg(m,e+"color"));let y=Ty(n,e+"cross-origin"),E=Iy(n,e+"offset"),v=Wg(n,e+"offset-origin"),x=nh(n,e+"width"),C=nh(n,e+"height"),T=Ry(n,e+"size"),A=sa(n,e+"declutter-mode"),R={src:r,anchorOrigin:d,anchorXUnits:f,anchorYUnits:g,crossOrigin:y,offset:E,offsetOrigin:v,height:C,width:x,size:T,declutterMode:A},I=null;return function(b){if(I)p&&I.setColor(p(b));else{let z=p?p(b):_;I=new En(z!==void 0?Object.assign({},R,{color:z}):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 Cy(n,t){let e="shape-",i=e+"points",r=e+"radius",s=rh(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=ms(n,e,t),f=ps(n,e,t),g=ra(n,e+"scale",t),m=ia(n,e+"displacement",t),_=Nt(n,e+"rotation",t),p=pr(n,e+"rotate-with-view",t),y=nh(n,e+"angle"),E=sa(n,e+"declutter-mode"),v=new Lo({points:s,radius:a,radius2:c,angle:y,declutterMode:E});return function(x){return o&&v.setRadius(o(x)),h&&v.setRadius2(h(x)),d&&v.setFill(d(x)),f&&v.setStroke(f(x)),m&&v.setDisplacement(m(x)),_&&v.setRotation(_(x)),p&&v.setRotateWithView(p(x)),g&&v.setScale(g(x)),v}}function vy(n,t){let e="circle-",i=ms(n,e,t),r=ps(n,e,t),s=Nt(n,e+"radius",t),o=ra(n,e+"scale",t),a=ia(n,e+"displacement",t),l=Nt(n,e+"rotation",t),h=pr(n,e+"rotate-with-view",t),c=sa(n,e+"declutter-mode"),d=new Ao({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=Me(i,Q,e);return function(s){return rh(r(s),t)}}function Ei(n,t,e){let i=wi(n,t);if(i===void 0)return null;let r=Me(i,Yt,e);return function(s){return Zg(r(s),t)}}function Sy(n,t,e){let i=Ei(n,t+"pattern-src",e),r=Xg(n,t+"pattern-offset",e),s=Xg(n,t+"pattern-size",e),o=na(n,t+"color",e);return function(a){return{src:i(a),offset:r&&r(a),size:s&&s(a),color:o&&o(a)}}}function pr(n,t,e){let i=wi(n,t);if(i===void 0)return null;let r=Me(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 na(n,t,e){let i=wi(n,t);if(i===void 0)return null;let r=Me(i,Zt,e);return function(s){return Bg(r(s),t)}}function Kg(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=Me(o,Q,e);return function(h){return rh(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=Me(i,xi,e);return function(s){return _s(r(s),t)}}function ia(n,t,e){let i=wi(n,t);if(i===void 0)return null;let r=Me(i,xi,e);return function(s){let o=_s(r(s),t);if(o.length!==2)throw new Error(`Expected two numbers for ${t}`);return o}}function Xg(n,t,e){let i=wi(n,t);if(i===void 0)return null;let r=Me(i,xi,e);return function(s){return Vg(r(s),t)}}function ra(n,t,e){let i=wi(n,t);if(i===void 0)return null;let r=Me(i,xi|Q,e);return function(s){return by(r(s),t)}}function nh(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 Ry(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 Ty(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 Wg(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 Ug(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 Iy(n,t){let e=n[t];if(e!==void 0)return _s(e,t)}function sa(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 _s(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 Zg(n,t){if(typeof n!="string")throw new Error(`Expected a string for ${t}`);return n}function rh(n,t){if(typeof n!="number")throw new Error(`Expected a number for ${t}`);return n}function Bg(n,t){if(typeof n=="string")return n;let e=_s(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 Vg(n,t){let e=_s(n,t);if(e.length!==2)throw new Error(`Expected an array of two numbers for ${t}`);return e}function by(n,t){return typeof n=="number"?n:Vg(n,t)}var jg={RENDER_ORDER:"renderOrder"},sh=class extends Sn{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(jg.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 Rn(9)),this.getRenderer().renderDeclutter(t,e)}setRenderOrder(t){this.set(jg.RENDER_ORDER,t)}setStyle(t){this.style_=t===void 0?ec:t;let e=Ly(t);this.styleFunction_=t===null?void 0:vf(e),this.changed()}setDeclutter(t){this.declutter_=t?String(t):void 0,this.changed()}};function Ly(n){if(n===void 0)return ec;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 Yg(n)}var oa=sh;var oh=class extends Lt{constructor(t,e,i,r){super(t),this.inversePixelTransform=e,this.frameState=i,this.context=r}},aa=oh;var ah=class extends Di{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]),ro(r,i)}forEachFeatureAtCoordinate(t,e,i,r,s,o,a,l){let h,c=e.viewState;function d(x,C,T,A){return s.call(o,C,x?T:null,A)}let f=c.projection,g=Xs(t.slice(),f),m=[[0,0]];if(f.canWrapX()&&r){let x=f.getExtent(),C=j(x);m.push([-C,0],[C,0])}let _=e.layerStatesArray,p=_.length,y=[],E=[];for(let x=0;x<m.length;x++)for(let C=p-1;C>=0;--C){let T=_[C],A=T.layer;if(A.hasRenderer()&&cs(T,c)&&a.call(l,A)){let R=A.getRenderer(),I=A.getSource();if(R&&I){let b=I.getWrapX()?g:t,z=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,z,y)}if(h)return h}}if(y.length===0)return;let v=1/y.length;return y.forEach((x,C)=>x.distanceSq+=C*v),y.sort((x,C)=>x.distanceSq-C.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(Ay)}};function Ay(n,t){Xt.expire()}var Hg=ah;var lh=class extends Hg{constructor(t){super(t),this.fontChangeListenerKey_=Z(yn,Se.PROPERTYCHANGE,t.redrawText,t),this.element_=Rt?eo():document.createElement("div");let e=this.element_.style;e.position="absolute",e.width="100%",e.height="100%",e.zIndex="0",this.element_.className=Ui+" 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 aa(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 oa&&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(!cs(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),md(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(...no(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))}}},qg=lh;function $g(n){if(n instanceof Sn){n.setMapInternal(null);return}n instanceof ls&&n.getLayers().forEach($g)}function Jg(n,t){if(n instanceof Sn){n.setMapInternal(t);return}if(n instanceof ls){let e=n.getLayers().getArray();for(let i=0,r=e.length;i<r;++i)Jg(e[i],t)}}var ch=class extends wt{constructor(t){super(),t=t||{},this.on,this.once,this.un;let e=My(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:cd,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:Go()),this.interactions=e.interactions||(Rt?new Dt:Zo({onFocusOnly:!0})),this.overlays_=e.overlays,this.overlayIdIndex_={},this.renderer_=null,this.postRenderFunctions_=[],this.tileQueue_=new og(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){Jg(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 ls?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 kr(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 ag(this.frameState_,t,e,i,r)}handleBrowserEvent(t,e){e=e||t.type;let i=new je(e,this,t);this.handleMapBrowserEvent(i)}handleMapBrowserEvent(t){if(!this.frameState_)return;let e=t.originalEvent,i=e.type;if(i===ss.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 Ki(He.LOADEND,this,t)))):this.loaded_===!0&&(this.loaded_=!1,this.dispatchEvent(new Ki(He.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 qg(this)),!te(e)){this.mapBrowserEventHandler_=new rg(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_,to?{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 Le("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){$g(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&&Ya(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:Mr(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=Mr(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_||!ze(this.previousExtent_)&&!sn(s.extent,this.previousExtent_))&&(this.dispatchEvent(new Ki(He.MOVESTART,this,r)),this.previousExtent_=rn(this.previousExtent_)),this.previousExtent_&&!s.viewHints[bt.ANIMATING]&&!s.viewHints[bt.INTERACTING]&&!sn(s.extent,this.previousExtent_)&&(this.dispatchEvent(new Ki(He.MOVEEND,this,s)),Ps(s.extent,this.previousExtent_))),this.dispatchEvent(new Ki(He.POSTRENDER,this,s)),this.renderComplete_=(this.hasListener(He.LOADSTART)||this.hasListener(He.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 Le("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)],!Ya(e)&&(t.offsetWidth||t.offsetHeight||t.getClientRects().length)&&Ns("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 My(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 ls({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()):(B(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()):(B(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()):(B(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 Qg=ch;function la(n){return n instanceof Image||n instanceof HTMLCanvasElement||n instanceof HTMLVideoElement||n instanceof ImageBitmap?n:null}var Py=new Error("disposed");var Oy=[256,256],hh=class extends Hn{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=la(this.data_);return t?[t.width,t.height]:Oy}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(Py),this.controller_=null),super.disposeInternal()}},uh=hh;var dh=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 Di&&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 B(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 B(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){B(!(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}},fh=dh;var gh=class{constructor(){this.instructions_=[],this.zIndex=0,this.offset_=0,this.pendingMethod_,this.context_=new Proxy(zr(),{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}},ca=gh;var Dy=5,mh=class extends oo{constructor(t){super(),this.ready=!0,this.boundHandleImageChange_=this.handleImageChange_.bind(this),this.layer_=t,this.staleKeys_=new Array,this.maxStaleKeys=Dy,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()}},tm=mh;var _h=[],_r=null;function ky(){_r=nt(1,1,void 0,{willReadFrequently:!0})}var ph=class extends tm{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){_r||ky(),_r.clearRect(0,0,1,1);let r;try{_r.drawImage(t,e,i,1,1,0,0,1,1),r=_r.getImageData(0,0,1,1).data}catch{return _r=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(de(t.style.backgroundColor),de(i)))){let h=t.firstElementChild;te(h)&&(l=h.getContext("2d"))}if(l&&Cd(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?eo():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=le(i),s=Fn(i),o=kn(i),a=Dn(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),ro(this.inversePixelTransform,this.pixelTransform);let h=wd(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 aa(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 ca),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()}},ha=ph;function yh(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 Fy(n,t,e){let i=n[e];return i?i.delete(t):!1}function em(n,t){let e=n.layerStatesArray[n.layerIndex];e.extent&&(t=Ne(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=Ne(t,r))}return t}var xh=class extends ha{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 Hs(0,0,0,0),this.tempTileCoord_=Zn(0,0,0);let i=e.cacheSize!==void 0?e.cacheSize:512;this.tileCache_=new fh(i),this.sourceTileCache_=null,this.layerExtent=null,this.maxStaleKeys=i*.5}getTileCache(){return this.tileCache_}getSourceTileCache(){return this.sourceTileCache_||(this.sourceTileCache_=new fh(512)),this.sourceTileCache_}getOrCreateTile(t,e,i,r){let s=this.tileCache_,a=this.getLayer().getSource(),l=Bn(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||Un(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 io||f instanceof so)p=f.getImage();else if(f instanceof uh){if(p=la(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])),v=Math.round(h*a.getGutterForProjection(o.projection));return this.getImageData(p,y+v,E+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,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?ba(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 v=y.minX;v<=y.maxX;++v)for(let x=y.minY;x<=y.maxY;++x){if(m&&!h.tileCoordIntersectsViewport([p,v,x],_))continue;let C=this.getTile(p,v,x,t);if(!C||!yh(r,C,p))continue;let A=C.getKey();if(d[A]=!0,C.getState()===D.IDLE&&!t.tileQueue.isKeyQueued(A)){let R=Zn(p,v,x,this.tempTileCoord_);t.tileQueue.enqueue([C,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=Bn(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)),yh(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=Bn(l,h,i,c,d),g=!1;if(a.containsKey(f)){let m=a.peek(f);m.getState()===D.LOADED&&(yh(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=Ne(m,this.layerExtent));let E=g*p/2/_,v=g*y/2/_,x=[a[0]-E,a[1]-v,a[0]+E,a[1]+v],C={};this.renderedTiles.length=0;let T=h.getPreload();if(t.nextExtent&&this.enqueueTilesForNextExtent()){let M=d.getZForResolution(r.nextResolution,c.zDirection),W=em(t,t.nextExtent);this.enqueueTiles(t,W,M,C,T)}let A=em(t,m);if(this.enqueueTiles(t,A,f,C,0),T>0&&setTimeout(()=>{this.enqueueTiles(t,A,f-1,C,T-1)},0),!(f in C))return this.container;let R=Y(this),I=t.time;for(let M of C[f]){let W=M.getState();if(W===D.EMPTY)continue;let O=M.tileCoord;if(W===D.LOADED&&M.getAlpha(R,I)===1){M.endTransition(R);continue}if(W!==D.ERROR&&(this.renderComplete=!1),this.findStaleTile_(O,C)){Fy(C,M,f),t.animate=!0;continue}if(this.findAltTiles_(d,O,f+1,C))continue;let tt=d.getMinZoom();for(let it=f-1;it>=tt&&!this.findAltTiles_(d,O,it,C);--it);}let b=g/o*l/_,z=this.getRenderContext(t);Ot(this.tempTransform,p/2,y/2,b,b,0,-p/2,-y/2),this.layerExtent&&this.clipUnrotated(z,t,this.layerExtent),c.getInterpolate()||(z.imageSmoothingEnabled=!1),this.preRender(z,t);let X=Object.keys(C).map(Number);X.sort(Vt);let N=[],V=[],lt=[];for(let M=X.length-1;M>=0;--M){let W=X[M],O=c.getTilePixelSize(W,l,s),G=d.getResolution(W)/g,tt=O[0]*G*b,it=O[1]*G*b,Ct=d.getTileCoordForCoordAndZ(le(x),W),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 C[W]){if(ot.getState()!==D.LOADED)continue;let Oe=ot.tileCoord,$i=Ct[1]-Oe[1],re=Math.round(Jt[0]-($i-1)*tt),Er=Ct[2]-Oe[2],Rs=Math.round(Jt[1]-(Er-1)*it),Ji=Math.round(Jt[0]-$i*tt),Qi=Math.round(Jt[1]-Er*it),Ln=re-Ji,ei=Rs-Qi,An=W===f;if(An&&ot.inTransition(R)){lt.push({tile:ot,x:Ji,y:Qi,w:Ln,h:ei,gutter:vt}),this.renderedTiles.unshift(ot),this.updateUsedTiles(t.usedTiles,c,ot);continue}let wr=[Ji,Qi,Ji+Ln,Qi+ei],Cr=[];for(let Ti=0,vr=N.length;Ti<vr;++Ti)W<V[Ti]&&ht(wr,N[Ti])&&Cr.push(N[Ti]);let Ts;Cr.length>0&&(Ts=_u(wr,Cr)),N.push(wr),V.push(W),this.drawTile(ot,t,Ji,Qi,Ln,ei,vt,An,Ts),this.renderedTiles.unshift(ot),this.updateUsedTiles(t.usedTiles,c,ot)}}for(let M=0,W=lt.length;M<W;++M){let{tile:O,x:$,y:G,w:tt,h:it,gutter:Ct}=lt[M];this.drawTile(O,t,$,G,tt,it,Ct,!0,void 0)}if(this.renderedResolution=g,this.extentChanged=!this.renderedExtent_||!sn(this.renderedExtent_,x),this.renderedExtent_=x,this.renderedPixelRatio=l,this.postRender(this.context,t),this.layerExtent&&z.restore(),z.imageSmoothingEnabled=!0,this.renderComplete){let M=(W,O)=>{let $=Y(c),G=O.wantedTiles[$],tt=G?Object.keys(G).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 uh){if(c=la(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,v=y/o;for(let x=0,C=h.length;x<C;++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)*v,I*E,b*v,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}},im=xh;var ys={PRELOAD:"preload",USE_INTERIM_TILES_ON_ERROR:"useInterimTilesOnError"};var Eh=class extends Sn{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(ys.PRELOAD)}setPreload(t){this.set(ys.PRELOAD,t)}getUseInterimTilesOnError(){return this.get(ys.USE_INTERIM_TILES_ON_ERROR)}setUseInterimTilesOnError(t){this.set(ys.USE_INTERIM_TILES_ON_ERROR,t)}getData(t){return super.getData(t)}},nm=Eh;var wh=class extends nm{constructor(t){super(t)}createRenderer(){return new im(this,{cacheSize:this.getCacheSize()})}},Ch=wh;var vh=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){}},ua=vh;var xs={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},Es=[xs.FILL],Je=[xs.STROKE],Ci=[xs.BEGIN_PATH],Sh=[xs.CLOSE_PATH],F=xs;var Rh=class extends ua{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=Ms(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([F.CUSTOM,l,f,t,i,Xr,s]),this.hitDetectionInstructions.push([F.CUSTOM,l,f,t,r||i,Xr,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([F.CUSTOM,l,d,t,i,Qn,s]),this.hitDetectionInstructions.push([F.CUSTOM,l,d,t,r||i,Qn,s]);break;case"LineString":case"Circle":h=t.getFlatCoordinates(),c=this.appendFlatLineCoordinates(h,0,h.length,a,!1,!1),this.instructions.push([F.CUSTOM,l,c,t,i,Ue,s]),this.hitDetectionInstructions.push([F.CUSTOM,l,c,t,r||i,Ue,s]);break;case"MultiPoint":h=t.getFlatCoordinates(),c=this.appendFlatPointCoordinates(h,a),c>l&&(this.instructions.push([F.CUSTOM,l,c,t,i,Ue,s]),this.hitDetectionInstructions.push([F.CUSTOM,l,c,t,r||i,Ue,s]));break;case"Point":h=t.getFlatCoordinates(),this.coordinates.push(h[0],h[1]),c=this.coordinates.length,this.instructions.push([F.CUSTOM,l,c,t,i,void 0,s]),this.hitDetectionInstructions.push([F.CUSTOM,l,c,t,r||i,void 0,s]);break;default:}this.endGeometry(e)}beginGeometry(t,e,i){this.beginGeometryInstruction1_=[F.BEGIN_GEOMETRY,e,0,t,i],this.instructions.push(this.beginGeometryInstruction1_),this.beginGeometryInstruction2_=[F.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==F.END_GEOMETRY?o=e:s==F.BEGIN_GEOMETRY&&(r[2]=e,Hu(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:Be;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:Ve;let l=t.getWidth();e.lineWidth=l!==void 0?l:mi;let h=t.getMiterLimit();e.miterLimit=h!==void 0?h:fi;let c=t.getOffset();e.strokeOffset=c??mf,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=[F.SET_FILL_STYLE,e];return typeof e!="string"&&i.push(t.fillPatternScale),i}applyStroke(t){this.instructions.push(this.createStroke(t))}createStroke(t){return[F.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=[F.END_GEOMETRY,t];this.instructions.push(e),this.hitDetectionInstructions.push(e)}getBufferedMaxExtent(){if(!this.bufferedMaxExtent_&&(this.bufferedMaxExtent_=Ps(this.maxExtent),this.maxLineWidth>0)){let t=this.resolution*(this.maxLineWidth+1)/2;Pn(this.bufferedMaxExtent_,t,this.bufferedMaxExtent_)}return this.bufferedMaxExtent_}},Qe=Rh;var Th=class extends Qe{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([F.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([F.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([F.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([F.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}},rm=Th;var Ih=class extends Qe{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([F.MOVE_TO_LINE_TO,o,a,s*this.pixelRatio]),this.hitDetectionInstructions.push([F.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([F.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(Je),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([F.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(Je),this.endGeometry(e)}finish(){let t=this.state;return t.lastStroke!=null&&t.lastStroke!=this.coordinates.length&&this.instructions.push(Je),this.reverseHitDetectionInstructions(),this.state=null,super.finish()}applyStroke(t){t.lastStroke!=null&&t.lastStroke!=this.coordinates.length&&(this.instructions.push(Je),t.lastStroke=this.coordinates.length),t.lastStroke=0,super.applyStroke(t),this.instructions.push(Ci)}},sm=Ih;var bh=class extends Qe{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([F.MOVE_TO_LINE_TO,f,g,s*this.pixelRatio,!0]),this.hitDetectionInstructions.push([F.MOVE_TO_LINE_TO,f,g,s,!0]),l&&(this.instructions.push(Sh),this.hitDetectionInstructions.push(Sh)),e=d}return a&&(this.instructions.push(Es),this.hitDetectionInstructions.push(Es)),l&&(this.instructions.push(Je),this.hitDetectionInstructions.push(Je)),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([F.SET_FILL_STYLE,Tt]),r.strokeStyle!==void 0&&this.hitDetectionInstructions.push([F.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=[F.CIRCLE,c,a];this.instructions.push(Ci,d),this.hitDetectionInstructions.push(Ci,d),r.fillStyle!==void 0&&(this.instructions.push(Es),this.hitDetectionInstructions.push(Es)),r.strokeStyle!==void 0&&(this.instructions.push(Je),this.hitDetectionInstructions.push(Je)),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([F.SET_FILL_STYLE,Tt]),r.strokeStyle!==void 0&&this.hitDetectionInstructions.push([F.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([F.SET_FILL_STYLE,Tt]),r.strokeStyle!==void 0&&this.hitDetectionInstructions.push([F.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]=Ni(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}},Lh=bh;var Ah=0,Mh=1;function Ny(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 Ah=c,Mh=d,!0}function om(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],v=!1;for(let x=g+e;x<p;x+=e){let C=n[x],T=n[x+1];if(Ny(r,s,o,a,y,E,C,T)){let A=C-y,R=T-E,I=y+Ah*A,b=E+Ah*R,z=y+Mh*A,X=E+Mh*R;c&&v&&I===d&&b===f?l.push(z,X):(c&&h.push(l.length),l.push(I,b,z,X),c=!0),d=z,f=X,v=!0}y=C,E=T}g=p}return c&&h.push(l.length),{flatCoordinates:l,ends:h}}function am(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 lm(n,t,e,i,r){let s=e,o=e,a=0,l=0,h=e,c,d,f,g,m,_,p,y,E,v;for(d=e;d<i;d+=r){let x=t[d],C=t[d+1];m!==void 0&&(E=x-m,v=C-_,g=Math.sqrt(E*E+v*v),p!==void 0&&(l+=f,c=Math.acos((p*E+y*v)/(f*g)),c>n&&(l>a&&(a=l,s=h,o=d),l=0,h=d-r)),f=g,p=E,y=v),m=x,_=C}return l+=g,l>a?[h,d]:[s,o]}var ws={left:0,center:.5,right:1,top:0,middle:.5,hanging:.2,alphabetic:.8,ideographic:.8,bottom:1},Ph=class extends Qe{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,v=y.length;E<v;++E)g.push(y[E][0])}if((h=="LineString"||h=="MultiLineString")&&!Fe(this.getBufferedMaxExtent(),f)){let y=om(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 v;m?v=am(m*this.resolution,c,p,g[y],d):v=[c.slice(p,g[y])];for(let x=0,C=v.length;x<C;++x){let T=v[x],A=0,R=T.length;if(_==null){let b=lm(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 C=0,T=x.length;C<T;C+=3)o.overflow||f.push(x[C+2]/this.resolution),c.push(x[C],x[C+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((C,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!=gi&&(o.scale[0]<0||o.scale[1]<0)){let x=o.padding[0],C=o.padding[1],T=o.padding[2],A=o.padding[3];o.scale[0]<0&&(C=-C,A=-A),o.scale[1]<0&&(x=-x,T=-T),p=[x,C,T,A]}let y=this.pixelRatio;this.instructions.push([F.DRAW_IMAGE,l,g,null,NaN,NaN,NaN,1,0,0,this.textRotateWithView_,this.textRotation_,[1,1],NaN,this.declutterMode_,this.declutterImageWithText_,p==gi?gi: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,v=m?m.slice(0):null;v&&(v[1]=Tt),this.hitDetectionInstructions.push([F.DRAW_IMAGE,l,g,null,NaN,NaN,NaN,1,0,0,this.textRotateWithView_,this.textRotation_,[E,E],NaN,this.declutterMode_,this.declutterImageWithText_,p,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 s=this.textKey_;s in this.textStates||(this.textStates[s]={font:e.font,textAlign:e.textAlign||Yi,justify:e.justify,textBaseline:e.textBaseline||xn,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=ws[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([F.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([F.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()||Be,s.lineDash=_?_.slice():qt,s.lineDashOffset=p===void 0?$t:p,s.lineJoin=a.getLineJoin()||Ve,s.lineWidth=y===void 0?mi:y,s.miterLimit=E===void 0?fi:E,s.strokeStyle=Ht(a.getColor()||Wt)}i=this.textState_;let l=t.getFont()||Io;pf(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()||xn,i.backgroundFill=t.getBackgroundFill(),i.backgroundStroke=t.getBackgroundStroke(),i.padding=t.getPadding()||gi,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}},cm=Ph;var zy={Circle:Lh,Default:Qe,Image:rm,LineString:sm,Polygon:Lh,Text:cm},Oh=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=zy[e];s=new o(this.tolerance_,this.maxExtent_,this.resolution_,this.pixelRatio_),r[e]=s}return s}},hm=Oh;function um(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 da(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,v,x=0;for(let C=t;C<e;C+=i){m=f,_=g,p=void 0,y=void 0,C+i<e&&(p=n[C+i],y=n[C+i+1]),s&&C===t&&(m=c,_=d),s&&C===e-i&&(p=l,y=h),f=n[C],g=n[C+1],[E,v]=Gy(f,g,m,_,p,y,r),o[x++]=E,o[x++]=v;for(let T=2;T<a;T++)o[x++]=n[C+T]}return o.length!=x&&(o.length=x),o}function Gy(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=Su([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 fa(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),v=l+p*(c-l);n[i+t]=E,n[i+t+1]=v,n.splice(i+2*t,o-i-t);break}}}return n}var Dh;function Xy(){return Dh||(Dh=new Intl.Segmenter(void 0,{granularity:"grapheme"})),Dh}function dm(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 v(){_=g,p=m,t+=i,g=n[t],m=n[t+1],E+=y,y=Math.sqrt((g-_)*(g-_)+(m-p)*(m-p))}do v();while(t<e-i&&E+y<s);let x=y===0?0:(s-E)/y,C=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;)v();x=y===0?0:(I-E)/y;let b=zt(_,g,x),z=zt(p,m,x),X=!1;if(f)if(d){let O=[C,T,b,z];uo(O,0,4,2,d,O,O),X=O[0]>O[2]}else X=C>b;let N=Math.PI,V=[],lt=A+i===t;t=A,y=0,E=R,g=n[t],m=n[t+1];let M;if(lt){v(),M=Math.atan2(m-p,g-_),X&&(M+=M>0?-N:N);let O=(b+C)/2,$=(z+T)/2;return V[0]=[O,$,(I-s)/2,M,r],V}r=r.replace(/\n/g," ");let W=Array.from(Xy().segment(r),O=>O.segment);for(let O=0,$=W.length;O<$;){v();let G=Math.atan2(m-p,g-_);if(X&&(G+=G>0?-N:N),M!==void 0){let vt=G-M;if(vt+=vt>N?-2*N:vt<-N?2*N:0,Math.abs(vt)>o)return null}M=G;let tt=O,it=0;for(;O<$;++O){let vt=X?$-O-1:O,ot=a*l(h,W[vt],c);if(t+i<e&&E+y<s+it+ot/2)break;it+=ot}if(O===tt)continue;let Ct=(X?W.slice($-O,$-tt):W.slice(tt,O)).join("");x=y===0?0:(s+it/2-E)/y;let L=zt(_,g,x),Jt=zt(p,m,x);V.push([L,Jt,it/2,G,Ct]),s+=it}return V}var yr=ut(),ji=[],vi=[],Si=[],Hi=[];function fm(n){return n[3].declutterBox}var gm=new RegExp("[\u0591-\u08FF\uFB1D-\uFDFF\uFE70-\uFEFC\u0800-\u0FFF\uE800-\uEFFF]");function kh(n,t){return t==="start"?t=gm.test(n)?"right":"left":t==="end"&&(t=gm.test(n)?"left":"right"),ws[t]}function Wy(n,t,e){return e>0&&n.push(`7-`,""),n.push(t,""),n}function Uy(n,t,e){return e%2===0&&(n+=t),n}var Fh=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 ca: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?ws[l.justify]:kh(Array.isArray(t)?t[0]:t,l.textAlign||Yi),f=r&&o.lineWidth?o.lineWidth:0,g=Array.isArray(t)?t:String(t).split(`8-`).reduce(Wy,[]),{width:m,height:_,widths:p,heights:y,lineWidths:E}=xf(l,g),v=m+f,x=[],C=(v+2)*c[0],T=(_+f)*c[1],A={width:C<0?Math.floor(C):Math.ceil(C),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*v+R*f,b=[],z=[],X=0,N=0,V=0,lt=0,M;for(let W=0,O=g.length;W<O;W+=2){let $=g[W];if($===`9-`){N+=X,X=0,I=d*v+R*f,++lt;continue}let G=g[W+1]||l.font;G!==M&&(r&&b.push("font",G),i&&z.push("font",G),M=G),X=Math.max(X,y[V]);let tt=[$,I+R*p[V]+d*(p[V]-E[lt]),.5*(f+X)+N];I+=p[V],r&&b.push("strokeText",tt),i&&z.push("fillText",tt),++V}return Array.prototype.push.apply(x,b),Array.prototype.push.apply(x,z),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,v=s+h>t?t-h:s,x=o+c>e?e-c:o,C=m[3]+v*f[0]+m[1],T=m[0]+x*f[1]+m[2],A=y-m[3],R=E-m[0];(_||d!==0)&&(ji[0]=A,Hi[0]=A,ji[1]=R,vi[1]=R,vi[0]=A+C,Si[0]=vi[0],Si[1]=R+T,Hi[1]=Si[1]);let I;return d!==0?(I=Ot(At(),i,r,1,1,d,-i,-r),dt(I,ji),dt(I,vi),dt(I,Si),dt(I,Hi),Qt(Math.min(ji[0],vi[0],Si[0],Hi[0]),Math.min(ji[1],vi[1],Si[1],Hi[1]),Math.max(ji[0],vi[0],Si[0],Hi[0]),Math.max(ji[1],vi[1],Si[1],Hi[1]),yr)):Qt(Math.min(A,A+C),Math.min(R,R+T),Math.max(A,A+C),Math.max(R,R+T),yr),g&&(y=Math.round(y),E=Math.round(E)),{drawImageX:y,drawImageY:E,drawImageW:v,drawImageH:x,originX:h,originY:c,declutterBox:{minX:yr[0],minY:yr[1],maxX:yr[2],maxY:yr[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,ji,vi,Si,Hi,o,a),Ef(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=kh(Array.isArray(t)?t[0]:t,s.textAlign||Yi),c=ws[s.textBaseline||xn],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_),Ed(this.renderedTransform_,i));let d=0,f=r.length,g=0,m,_=[],p,y,E,v,x,C,T,A,R,I,b,z,X,N=0,V=0,lt=this.coordinateCache_,M=this.viewRotation_,W=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,G,tt,it,Ct;for(;d<f;){let L=r[d];switch(L[0]){case F.BEGIN_GEOMETRY:G=L[1],Ct=L[3],G.getGeometry()?a!==void 0&&!ht(a,Ct.getExtent())?d=L[2]+1:++d:d=L[2],h&&(h.zIndex=L[4]);break;case F.BEGIN_PATH:N>$&&(this.fill_(t),N=0),V>$&&(t.stroke(),V=0),!N&&!V&&(t.beginPath(),x=NaN,C=NaN),++d;break;case F.CIRCLE:g=L[1],E=L[2]??0;let vt=c[g],ot=c[g+1],Oe=c[g+2]-E,$i=c[g+3]-E,re=Oe-vt,Er=$i-ot,Rs=Math.sqrt(re*re+Er*Er);t.moveTo(vt+Rs,ot),t.arc(vt,ot,Rs,0,2*Math.PI,!0),++d;break;case F.CLOSE_PATH:t.closePath(),++d;break;case F.CUSTOM:g=L[1],m=L[2];let Ji=L[3],Qi=L[4],Ln=L[5];O.geometry=Ji,O.feature=G,d in lt||(lt[d]=[]);let ei=lt[d];Ln?Ln(c,g,m,2,ei):(ei[0]=c[g],ei[1]=c[g+1],ei.length=2),h&&(h.zIndex=L[6]),Qi(ei,O),++d;break;case F.DRAW_IMAGE:g=L[1],m=L[2],R=L[3],p=L[4],y=L[5];let An=L[6],wr=L[7],Cr=L[8],Ts=L[9],Ti=L[10],vr=L[11],Fm=L[12],Is=L[13];v=L[14]||"declutter";let Sr=L[15];if(!R&&L.length>=20){I=L[19],b=L[20],z=L[21],X=L[22];let St=this.drawLabelWithPointPlacement_(I,b,z,X);R=St.label,L[3]=R;let De=L[23];p=(St.anchorX-De)*this.pixelRatio,L[4]=p;let se=L[24];y=(St.anchorY-se)*this.pixelRatio,L[5]=y,An=R.height,L[6]=An,Is=R.width,L[13]=Is}let _a;L.length>25&&(_a=L[25]);let ya,bs,Ls;L.length>17?(ya=L[16],bs=L[17],Ls=L[18]):(ya=gi,bs=null,Ls=null),Ti&&W?vr+=M:!Ti&&!W&&(vr-=M);let Nm=0;for(;g<m;g+=2){if(_a&&_a[Nm++]<Is/this.pixelRatio)continue;let St=this.calculateImageOrLabelDimensions_(R.width,R.height,c[g],c[g+1],Is,An,p,y,Cr,Ts,vr,Fm,s,ya,!!bs||!!Ls,G),De=[t,e,R,St,wr,bs,Ls];if(l){let se,ke,oe;if(Sr){let gt=m-g;if(!Sr[gt]){Sr[gt]={args:De,declutterMode:v};continue}let Kt=Sr[gt];se=Kt.args,ke=Kt.declutterMode,delete Sr[gt],oe=fm(se)}let ii,ni;if(se&&(ke!=="declutter"||!l.collides(oe))&&(ii=!0),(v!=="declutter"||!l.collides(St.declutterBox))&&(ni=!0),ke==="declutter"&&v==="declutter"){let gt=ii&∋ii=gt,ni=gt}ii&&(ke!=="none"&&l.insert(oe),this.replayImageOrLabel_.apply(this,se)),ni&&(v!=="none"&&l.insert(St.declutterBox),this.replayImageOrLabel_.apply(this,De))}else this.replayImageOrLabel_.apply(this,De)}++d;break;case F.DRAW_CHARS:let iu=L[1],nu=L[2],xa=L[3],zm=L[4];X=L[5];let Gm=L[6],ru=L[7],su=L[8];z=L[9];let Ea=L[10];I=L[11],Array.isArray(I)&&(I=I.reduce(Uy,"")),b=L[12];let ou=[L[13],L[13]];v=L[14]||"declutter";let Xm=L[15],au=L[16],wa=this.textStates[b],Rr=wa.font,Tr=[wa.scale[0]*ru,wa.scale[1]*ru],Ir;Rr in this.widths_?Ir=this.widths_[Rr]:(Ir={},this.widths_[Rr]=Ir);let lu=um(c,iu,nu,2),cu=Math.abs(Tr[0])*Vl(Rr,I,Ir);if(zm||cu<=lu){let St=this.textStates[b].textAlign,De=(lu-cu)*kh(I,St),se=dm(c,iu,nu,2,I,De,Gm,Math.abs(Tr[0]),Vl,Rr,Ir,W?0:this.viewRotation_,Xm);t:if(se){let ke=[],oe,ii,ni,gt,Kt;if(z)for(oe=0,ii=se.length;oe<ii;++oe){Kt=se[oe],ni=Kt[4],gt=this.createLabel(ni,b,"",z),p=Kt[2]+(Tr[0]<0?-Ea:Ea)-au,y=xa*gt.height+(.5-xa)*2*Ea*Tr[1]/Tr[0]-su;let ri=this.calculateImageOrLabelDimensions_(gt.width,gt.height,Kt[0],Kt[1],gt.width,gt.height,p,y,0,0,Kt[3],ou,!1,gi,!1,G);if(l&&v==="declutter"&&l.collides(ri.declutterBox))break t;ke.push([t,e,gt,ri,1,null,null])}if(X)for(oe=0,ii=se.length;oe<ii;++oe){Kt=se[oe],ni=Kt[4],gt=this.createLabel(ni,b,X,""),p=Kt[2]-au,y=xa*gt.height-su;let ri=this.calculateImageOrLabelDimensions_(gt.width,gt.height,Kt[0],Kt[1],gt.width,gt.height,p,y,0,0,Kt[3],ou,!1,gi,!1,G);if(l&&v==="declutter"&&l.collides(ri.declutterBox))break t;ke.push([t,e,gt,ri,1,null,null])}l&&v!=="none"&&l.load(ke.map(fm));for(let ri=0,Wm=ke.length;ri<Wm;++ri)this.replayImageOrLabel_.apply(this,ke[ri])}}++d;break;case F.END_GEOMETRY:if(o!==void 0){G=L[1];let St=o(G,Ct,v);if(St)return St}++d;break;case F.FILL:$?N++:this.fill_(t),++d;break;case F.MOVE_TO_LINE_TO:g=L[1],m=L[2],E=L[3];let tn,br,As;if(E){let De=(L[4]??!1)||Math.abs(c[g]-c[m-2])<1e-6&&Math.abs(c[g+1]-c[m-1])<1e-6;da(c,g,m,2,E,De,_),fa(_,2,De),tn=_,br=0,As=tn.length}else tn=c,br=g,As=m;tt=tn[br],it=tn[br+1],t.moveTo(tt,it),x=tt+.5|0,C=it+.5|0;for(let St=br+2;St<As;St+=2)tt=tn[St],it=tn[St+1],T=tt+.5|0,A=it+.5|0,(St==As-2||T!==x||A!==C)&&(t.lineTo(tt,it),x=T,C=A);++d;break;case F.SET_FILL_STYLE:this.alignAndScaleFill_=L[2],N?(this.fill_(t),N=0,V&&(t.stroke(),V=0)):V&&L[1]&&(t.stroke(),V=0),t.fillStyle=L[1],++d;break;case F.SET_STROKE_STYLE:N&&L[1]&&(this.fill_(t),N=0),V&&(t.stroke(),V=0),this.setStrokeStyle_(t,L),++d;break;case F.STROKE:$?V++:t.stroke(),++d;break;default:++d;break}}N&&this.fill_(t),V&&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)}},mm=Fh;var qi=["Polygon","Circle","LineString","Image","Text","Default"],Gh=["Image","Text"],pm=qi.filter(n=>!Gh.includes(n)),_m=!1,ym=!1;function Yy(){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};_m={[t(!0)]:!0,[t(!1)]:!1,[t(void 0)]:void 0}[n],ym=!0}var zh=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 mm(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){ym===!1&&Yy(),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:_m}));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(),on(d,t),Pn(d,e*(this.renderBuffer_+r),d));let f=Ky(r),g;function m(C,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(C)){let z=(f[I]-3)/4,X=r-z%a,N=r-(z/a|0),V=s(C,T,X*X+N*N);if(V)return V}c.clearRect(0,0,a,a);break}}let _=Object.keys(this.executorsByZIndex_).map(Number);_.sort(Vt);let p,y,E,v,x;for(p=_.length-1;p>=0;--p){let C=_[p].toString();for(E=this.executorsByZIndex_[C],y=qi.length-1;y>=0;--y)if(g=qi[y],v=E[g],v!==void 0&&(x=v.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?ju:Vt),o=o||qi;let h=qi.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(),v=E?E.getContext():t,x=this.maxExtent_&&p!=="Image"&&p!=="Text";if(x&&(v.save(),this.clip(v,i)),!E||p==="Text"||p==="Image"?y.execute(v,e,i,r,s,a):E.pushFunction(C=>y.execute(C,e,i,r,s,a)),x&&v.restore(),E){E.offset();let C=l[c]*h+qi.indexOf(p);this.deferredZIndexContexts_[C]||(this.deferredZIndexContexts_[C]=[]),this.deferredZIndexContexts_[C].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(Vt);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}},Nh={};function Ky(n){if(Nh[n]!==void 0)return Nh[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 Nh[n]=r,r}var xm=zh;var Xh=class extends ua{constructor(t,e,i,r,s,o,a){super(),this.context_=t,this.pixelRatio_=e,this.extent_=i,this.transform_=r,this.transformRotation_=r?an(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=da(l,0,c,2,o,d,l),fa(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=Xd(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:Yi;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:Be,lineDash:this.pixelRatio_===1?c:c.map(f=>f*this.pixelRatio_),lineDashOffset:(o||$t)*this.pixelRatio_,lineJoin:a!==void 0?a:Ve,lineWidth:(l!==void 0?l:mi)*this.pixelRatio_,miterLimit:h!==void 0?h:fi,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(),v=i.getMiterLimit();this.textStrokeState_={lineCap:m!==void 0?m:Be,lineDash:_||qt,lineDashOffset:p||$t,lineJoin:y!==void 0?y:Ve,lineWidth:E!==void 0?E:mi,miterLimit:v!==void 0?v:fi,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:Io,textAlign:d!==void 0?d:Yi,textBaseline:f!==void 0?f:xn},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]]}}},Em=Xh;var Pe=.5;function wm(n,t,e,i,r,s,o,a,l){let h=l?Mi(r,l):r,c=n[0]*Pe,d=n[1]*Pe,f=nt(c,d);f.imageSmoothingEnabled=!1;let g=f.canvas,m=new Em(f,Pe,r,null,o,a,l?hn(dn(),l):null),_=e.length,p=Math.floor((256*256*256-1)/_),y={};for(let v=1;v<=_;++v){let x=e[v-1],C=x.getStyleFunction()||i;if(!C)continue;let T=C(x,s);if(!T)continue;Array.isArray(T)||(T=[T]);let R=(v*p).toString(16).padStart(7,"#00000");for(let I=0,b=T.length;I<b;++I){let z=T[I],X=z.getGeometryFunction()(x);if(!X||!ht(h,X.getExtent()))continue;let N=z.clone(),V=N.getFill();V&&V.setColor(R);let lt=N.getStroke();lt&&(lt.setColor(R),lt.setLineDash(null)),N.setText(void 0);let M=z.getImage();if(M){let G=M.getImageSize();if(!G)continue;let tt=nt(G[0],G[1],void 0,{alpha:!1}),it=tt.canvas;tt.fillStyle=R,tt.fillRect(0,0,it.width,it.height),N.setImage(new En({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 W=N.getZIndex()||0,O=y[W];O||(O={},y[W]=O,O.Polygon=[],O.Circle=[],O.LineString=[],O.Point=[]);let $=X.getType();if($==="GeometryCollection"){let G=X.getGeometriesArrayRecursive();for(let tt=0,it=G.length;tt<it;++tt){let Ct=G[tt];O[Ct.getType().replace("Multi","")].push(Ct,N)}}else O[$.replace("Multi","")].push(X,N)}}let E=Object.keys(y).map(Number).sort(Vt);for(let v=0,x=E.length;v<x;++v){let C=y[E[v]];for(let T in C){let A=C[T];for(let R=0,I=A.length;R<I;R+=2){m.setStyle(A[R+1]);for(let b=0,z=t.length;b<z;++b)m.setTransform(t[b]),m.drawGeometry(A[R])}}}return f.getImageData(0,0,g.width,g.height)}function Cm(n,t,e){let i=[];if(e){let r=Math.floor(Math.round(n[0])*Pe),s=Math.floor(Math.round(n[1])*Pe),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 Zy=.5,vm={Point:Jy,LineString:Hy,Polygon:tx,MultiPoint:Qy,MultiLineString:qy,MultiPolygon:$y,GeometryCollection:jy,Circle:By};function Sm(n,t){return parseInt(Y(n),10)-parseInt(Y(t),10)}function Wh(n,t){let e=Uh(n,t);return e*e}function Uh(n,t){return Zy*n/t}function By(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 Yh(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)),Vy(n,t,e,i,s,o,a),d}function Vy(n,t,e,i,r,s,o){let a=e.getGeometryFunction()(t);if(!a)return;let l=a.simplifyTransformed(i,r);if(e.getRenderer())Rm(n,l,e,t,o);else{let c=vm[l.getType()];c(n,l,e,t,o,s)}}function Rm(n,t,e,i,r){if(t.getType()=="GeometryCollection"){let o=t.getGeometries();for(let a=0,l=o.length;a<l;++a)Rm(n,o[a],e,i,r);return}n.getBuilder(e.getZIndex(),"Default").drawCustom(t,i,e.getRenderer(),e.getHitDetectionRenderer(),r)}function jy(n,t,e,i,r,s){let o=t.getGeometriesArray(),a,l;for(a=0,l=o.length;a<l;++a){let h=vm[o[a].getType()];h(n,o[a],e,i,r,s)}}function Hy(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 qy(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 $y(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 Jy(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 Qy(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 tx(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 Kh=class extends ha{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),v=d.getWrapX()&&l.canWrapX(),x=v?j(c):null,C=v?Math.ceil((r[2]-c[2])/x)+(this.extendX_?2:1):1,T=v?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?qi:i?Gh:pm,i?f&&e.declutter[f]:void 0)}while(++T<C)}setDrawContext_(){this.opacity_!==1&&(this.targetContext_=this.context,this.context=nt(this.context.canvas.width,this.context.canvas.height,_h))}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,mn(this.context),_h.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&&!Fe(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]*Pe,f=i[1]*Pe;c.push(this.getRenderTransform(r,s,o,Pe,d,f,0).slice());let g=h.getSource(),m=a.getExtent();if(g.getWrapX()&&a.canWrapX()&&!Fe(m,l)){let p=l[0],y=j(m),E=0,v;for(;p<m[0];)--E,v=y*E,c.push(this.getRenderTransform(r,s,o,Pe,d,f,v).slice()),p+=y;for(E=0,p=l[2];p>m[2];)++E,v=y*E,c.push(this.getRenderTransform(r,s,o,Pe,d,f,v).slice()),p-=y}let _=dn();this.hitDetectionImageData_=wm(i,c,this.renderedFeatures_,h.getStyleFunction(),l,s,o,Wh(s,this.renderedPixelRatio_),_?a:null)}e(Cm(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&&(_=Sm);let p=h.center.slice(),y=Pn(l,m*d),E=y.slice(),v=[y.slice()],x=c.getExtent(),C=i.getWrapX()&&c.canWrapX();if(this.extendX_=!1,C){let M=i.getExtent();M&&!ze(M)&&(this.extendX_=M[0]<x[0]||M[2]>x[2])}if(C&&(!Fe(x,t.extent)||this.extendX_)){let M=j(x),W=Math.max(j(y)/2,M),O=x[0],$=x[2];this.extendX_&&(O-=M,$+=M),y[0]=O-W,y[2]=$+W,Xs(p,c);let G=Aa(v[0],c);G[0]<x[0]&&G[2]<x[2]?v.push([G[0]+M,G[1],G[2]+M,G[3]]):G[0]>x[0]&&G[2]>x[2]&&v.push([G[0]-M,G[1],G[2]-M,G[3]])}if(this.ready&&this.renderedResolution_==d&&this.renderedPixelRatio_===f&&this.renderedRevision_==g&&this.renderedRenderOrder_==_&&this.renderedFrameDeclutter_===!!t.declutter&&Fe(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 hm(Uh(d,f),y,d,f),A=dn(),R;if(A){for(let M=0,W=v.length;M<W;++M){let O=v[M],$=Mi(O,c);i.loadFeatures($,Zu(d,c),A)}R=hn(A,c)}else for(let M=0,W=v.length;M<W;++M)i.loadFeatures(v[M],d,c);let I=Wh(d,f),b=!0,z=(M,W)=>{let O,$=M.getStyleFunction()||e.getStyleFunction();if($&&(O=$(M,d)),O){let G=this.renderFeature(M,I,O,T,R,this.getLayer().getDeclutter(),W);b=b&&!G}},X=Mi(y,c),N=i.getFeaturesInExtent(X);_&&N.sort(_);for(let M=0,W=N.length;M<W;++M)z(N[M],M);this.renderedFeatures_=N,this.ready=b;let V=T.finish(),lt=new xm(y,d,f,i.getOverlaps(),V,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=Yh(r,t,i[h],e,this.boundHandleStyleImageChange_,s,o,a)||l;else l=Yh(r,t,i,e,this.boundHandleStyleImageChange_,s,o,a);return l}},Tm=Kh;var Zh=class extends oa{constructor(t){super(t)}createRenderer(){return new Tm(this)}},Im=Zh;var ex=!1;function ix(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=ex,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 Bh(n,t){return function(e,i,r,s,o){ix(n,t,e,i,r,(a,l)=>{this.addFeatures(a),s!==void 0&&s(a)},()=>{this.changed(),o!==void 0&&o()})}}function bm(n,t){return[[-1/0,-1/0,1/0,1/0]]}function Vh(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,_=Vu(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 Lm=At(),Cs=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"?Os(this.flatCoordinates_):On(this.flatCoordinates_,0,this.flatCoordinates_.length,this.stride_)),this.extent_}getFlatInteriorPoint(){if(!this.flatInteriorPoints_){let t=Bt(this.getExtent());this.flatInteriorPoints_=Yr(this.flatCoordinates_,0,this.ends_,this.stride_,t,0)}return this.flatInteriorPoints_}getFlatInteriorPoints(){if(!this.flatInteriorPoints_){let t=$d(this.flatCoordinates_,this.ends_),e=Po(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_=Vh(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=Vh(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(Lm,i[0],i[3],r,-r,0,0,0),jt(this.flatCoordinates_,0,this.flatCoordinates_.length,this.stride_,Lm,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=Qs((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=Wr(i,0,this.simplifiedGeometry_.flatCoordinates_.length,this.simplifiedGeometry_.stride_,t,i,0),r=[i.length];break;case"MultiLineString":r=[],i.length=Vd(i,0,this.simplifiedGeometry_.ends_,this.simplifiedGeometry_.stride_,t,i,0,r);break;case"Polygon":r=[],i.length=Ur(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}};Cs.prototype.getFlatCoordinates=Cs.prototype.getOrientedFlatCoordinates;var bn=Cs;var jh=class{constructor(t){this.rbush_=new Rn(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];sn(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]}},Hh=jh;var ie={ADDFEATURE:"addfeature",CHANGEFEATURE:"changefeature",CLEAR:"clear",REMOVEFEATURE:"removefeature",FEATURESLOADSTART:"featuresloadstart",FEATURESLOADEND:"featuresloadend",FEATURESLOADERROR:"featuresloaderror"};var ti=class extends Lt{constructor(t,e,i){super(t),this.feature=e,this.features=i}},qh=class extends lo{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&&(B(this.format_,"`format` must be set when `url` is set"),this.loader_=Bh(this.url_,this.format_)),this.strategy_=t.strategy!==void 0?t.strategy:bm;let e=t.useSpatialIndex!==void 0?t.useSpatialIndex:!0;this.featuresRtree_=e?new Hh:null,this.loadedExtentsRtree_=new Hh,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 ti(ie.ADDFEATURE,t))}setupChangeEvents_(t,e){e instanceof bn||(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 bn){let s=this.idIndex_[r];s instanceof bn?Array.isArray(s)?s.push(e):this.idIndex_[r]=[s,e]:i=!1}else i=!1}return i&&(B(!(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 ti(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 ti(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 bn||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 bn||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=Fs(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 bn?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 ti(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 Fe(c.extent,l)})){this.loading=Number(this.loading)+1,this.dispatchEvent(new ti(ie.FEATURESLOADSTART));let c=m=>{this.loading=Number(this.loading)-1,this.dispatchEvent(new ti(ie.FEATURESLOADEND,void 0,m))},d=()=>{this.changed(),this.loading=Number(this.loading)-1,this.dispatchEvent(new ti(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=La(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 ti(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){B(this.format_,"`format` must be set when `url` is set"),this.url_=t,this.setLoader(Bh(t,this.format_))}setOverlaps(t){this.overlaps_=t,this.changed()}},Ri=qh;function Am(){let n=u.variant,t=w.overviewCanvas,e=t.getContext("2d"),i=ui(),r=u.game.tileGrid.size,s=u.game.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||!ma(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=`${u.game.base}/tiles/${encodeURIComponent(n.tiles)}/${l}/${y}/${p}.${d}`}vs()}function vs(){let n=u.engine?.getView();if(!n||!u.variant)return;let t=ui(),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,w.overviewShelf.hidden=o,o))return;let l=w.overviewCanvas,h=be((e[0]-t[0])/i,0,1),c=be((e[2]-t[0])/i,0,1),d=be((t[3]-e[3])/r,0,1),f=be((t[3]-e[1])/r,0,1),g=w.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 ga(n,t=!0){u.overviewDocked=n,n&&u.overviewPointer!==null&&(u.overviewPointer=null,xr()),w.overviewShelf.classList.toggle("is-docked",n),w.overviewDock.setAttribute("aria-expanded",String(!n));let e=n?"Bring the overview back":"Put the overview away";w.overviewDock.setAttribute("aria-label",e),w.overviewDock.title=e,t&&Re()}function $h(n,t){let e=u.engine?.getView();if(!e||!u.variant)return;let i=w.overviewCanvas.getBoundingClientRect(),r=ui(),s=(a,l,h)=>be((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 Im({updateWhileAnimating:!0,...n})}function Mm(){let n=u.game.tileGrid.size,t=[0,-n,n,0];u.projection=new Li({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 Ch({zIndex:0}),rasterDetail:new Ch({zIndex:1}),grid:ne({source:u.sources.grid,style:rc,renderOrder:fe,renderBuffer:40,zIndex:5}),zoneScrim:ne({source:u.sources.zoneScrim,style:Ff,zIndex:6}),zones:ne({source:u.sources.zones,style:Nf,renderBuffer:32,zIndex:10}),zoneTitles:ne({source:u.sources.zoneTitles,style:zf,renderOrder:fe,renderBuffer:160,zIndex:20}),zoneTitleDetail:ne({source:u.sources.zoneTitles,style:Gf,renderOrder:fe,renderBuffer:160,zIndex:44}),text:ne({source:u.sources.text,style:Lf,renderOrder:fe,renderBuffer:220,zIndex:30}),textDetail:ne({source:u.sources.text,style:Af,renderOrder:fe,renderBuffer:220,zIndex:45}),zoneText:ne({source:u.sources.text,style:Mf,renderOrder:fe,renderBuffer:220,zIndex:41}),pins:ne({source:u.sources.pins,style:Tf,renderOrder:fe,renderBuffer:48,zIndex:40}),zonePins:ne({source:u.sources.pins,style:If,renderOrder:fe,renderBuffer:48,zIndex:42}),pinLabels:ne({source:u.sources.pins,style:bf,renderOrder:fe,renderBuffer:180,zIndex:45}),gridContext:ne({source:u.sources.gridContext,style:rc,renderOrder:fe,renderBuffer:40,zIndex:48}),priority:ne({source:u.sources.priority,style:Pf,renderOrder:fe,renderBuffer:220,zIndex:50})},u.engine=new Qg({target:w.viewport,layers:Object.values(u.layers),controls:Go({attribution:!1,rotate:!1,zoom:!1}),interactions:Zo({onFocusOnly:!1}),view:Jh(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&&xr()}),u.engine.on("postrender",vs),w.viewport.addEventListener("wheel",()=>{document.activeElement!==w.viewport&&w.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){Zr(r.hash);return}}let i=u.engine.forEachFeatureAtPixel(e.pixel,(r,s)=>pa(s)&&r.get("pin")||null,{hitTolerance:5,layerFilter:pa});i&&kl(i)}),u.engine.on("pointermove",e=>{if(e.dragging){or(null);return}let i=u.engine.forEachFeatureAtPixel(e.pixel,(o,a)=>pa(a)&&o.get("pin")||null,{hitTolerance:4,layerFilter:pa}),r=i?.category.displayType==="text"?null:i;or(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",()=>or(null))}function pa(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 Jh(n){let t=u.game.tileGrid.size;return new ee({projection:u.projection,center:[t/2,-t/2],resolutions:Qh(n),minZoom:0,maxZoom:n,extent:[0,-t,t,0],constrainResolution:!1,smoothResolutionConstraint:!1,showFullExtent:!0,zoom:0})}function Qh(n){let t=u.game.tileGrid.size/u.game.tileGrid.tileSize;return Array.from({length:n+1},(e,i)=>t/2**i)}async function _i(n,t){u.game=u.catalog.games.find(r=>r.slug===n)||u.catalog.games[0],u.engine||Mm(),!t&&!u.restore&&(u.restore=$n(u.game.slug)),w.game.value=u.game.slug,nn(w.map,u.game.maps,"title"),w.map.disabled=u.game.maps.length===1,w.map.title=w.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 tu((i||u.game.maps[0]).slug)}async function tu(n){let t=u.game.maps.find(s=>s.slug===n)||u.game.maps[0],e=++u.mapRun;w.loading.hidden=!1;let i;try{i=await ig(t)}catch{u.mapRun===e&&(w.loading.hidden=!0,Cn());return}if(u.mapRun!==e)return;u.settling=!0,u.map=i,document.documentElement.style.setProperty("--icon-outset-color",Br()),w.map.value=u.map.slug,nn(w.variant,u.map.variants,"name"),w.variantField.hidden=u.map.variants.length<2,u.styleCache.clear(),or(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)),ga(!!u.restore?.overviewDocked,!1),wo(u.restore?!!u.restore.dockFolded:!0,!1),u.dockDismissed=!!u.restore?.dockDismissed,u.search="",w.search.value="",w.dock.hidden=!1,Te(),Jf(),ac(),qf(),eu(r?be(r.variant,0,u.map.variants.length-1):0,!0),u.restore=null,w.sidebar.classList.remove("is-open"),w.mobileLegend.setAttribute("aria-expanded","false"),Dd(),u.settling=!1,Re()}function eu(n,t=!1){let e=u.variant;u.variant=u.map.variants[n]||u.map.variants[0];let i=u.variant,r=t?null:ox(e,i),s=Ze(i);w.variant.value=String(u.map.variants.indexOf(u.variant)),t?u.engine.setView(Jh(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},w.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&&(w.loading.hidden=!0))};return _.on("tileloadend",()=>p(!1)),_.on("tileloaderror",()=>p(!0)),_},h=(_,p)=>l(new Pd({projection:u.projection,tileGrid:new Nr({extent:[0,-u.game.tileGrid.size,u.game.tileGrid.size,0],origin:[0,0],resolutions:Qh(_),tileSize:u.game.tileGrid.tileSize}),cacheSize:64,interpolate:i.interpolate,transition:0,wrapX:!1,tileUrlFunction:([y,E,v])=>{let x=i.formats[y];if(!(!x||E<0||v<0||!p(y,E,v)))return`${u.game.base}/tiles/${encodeURIComponent(i.tiles)}/${y}/${E}/${v}.${x}`}})),c=i.fullZoom??i.maxZoom,d=h(c,(_,p,y)=>ma(i,_,p,y)),f=u.layers.raster.getSource();u.layers.raster.setSource(d),u.layers.raster.setExtent(ui()),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&&ma(i,_,p,y))),u.layers.rasterDetail.setExtent(ui()),u.layers.rasterDetail.setVisible(!0)):u.layers.rasterDetail.setVisible(!1),g?.clear(),_o(),u.gridEnabled&&(Ke(),u.layers.pins.changed(),u.layers.text.changed(),u.layers.priority.changed()),u.overviewKey="",Am();let m=t&&u.restore?.map===u.map.slug?u.restore:null;if(u.renderedShard!==(i.shard||0)&&(ac(),ue()),m?.center&&Number.isFinite(m.zoom)){let _=u.engine.getView();_.setCenter(m.center),_.setZoom(m.zoom),u.fitZoom=m.zoom,wn()}else t?requestAnimationFrame(ax):(r&&u.engine.getView().animate({center:r,duration:200}),wn());Re()}function ma(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=sx(n,t,r),l=o*r.w+s;return(a[l>>3]&1<<(l&7))!==0}function sx(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 Ze(n){return n.maxZoom+2}function xr(){wn(),Re()}function ox(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+be(r,0,1)*t.bounds.width,-(t.bounds.y+be(s,0,1)*t.bounds.height)]}function Pm(){let t=document.querySelector(".app-shell").classList.toggle("sidebar-collapsed");w.mobileLegend.setAttribute("aria-expanded",String(!t)),requestAnimationFrame(()=>u.engine?.updateSize())}function ui(){let n=u.game.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 ax(){if(!u.engine||!u.variant)return;let n=u.engine.getView();n.fit(ui(),{size:u.engine.getSize(),padding:[36,36,36,36],maxZoom:u.variant.maxZoom,duration:0}),u.fitZoom=n.getZoom()||0,wn()}function Ss(n){let t=u.engine.getView(),e=t.getZoom()||0;t.animate({zoom:be(e+n,u.variant.minZoom,Ze(u.variant)),duration:140})}function wn(){let n=u.engine?.getView().getZoom();if(w.viewport.dataset.zoom=Number.isFinite(n)?n.toFixed(3):"",!u.engine||!u.pins.length){w.visibleCount.textContent="0 locations visible";return}let t=u.engine.getView().calculateExtent(u.engine.getSize()),e=0;for(let i of u.pins){if(ge(i))continue;let[r,s]=i.coordinate;r>=t[0]&&r<=t[2]&&s>=t[1]&&s<=t[3]&&e++}w.visibleCount.textContent=`${Ie(u.eligibleLocations)} enabled \xB7 ${Ie(e)} in view`}function Om(){w.game.addEventListener("change",()=>{_i(w.game.value)}),w.map.addEventListener("change",()=>{tu(w.map.value)}),w.addBundles.addEventListener("click",()=>{fc()}),w.emptyOpen.addEventListener("click",()=>{fc()}),w.variant.addEventListener("change",()=>eu(Number(w.variant.value))),w.legend.addEventListener("change",i=>{let r=i.target;if(r.dataset.sectionToggle){tg(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),ue(),Xi()});let n=null,t=()=>{for(let s of w.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&&w.layers.contains(r)&&r.classList.add("is-hovered")};w.layers.addEventListener("pointermove",i=>{n={x:i.clientX,y:i.clientY},t()},{passive:!0}),w.layers.addEventListener("pointerleave",()=>{n=null,t()}),w.layers.addEventListener("scroll",t,{passive:!0}),w.layers.addEventListener("click",i=>{let r=i.target.closest("[data-only-category], [data-only-section]");if(r){i.preventDefault(),i.stopPropagation(),eg(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),Fo()}),w.soloChip.addEventListener("click",()=>rs(!0)),k("#expand-all").addEventListener("click",()=>uc(!1)),k("#collapse-all").addEventListener("click",()=>uc(!0)),k("#show-all").addEventListener("click",()=>rs(!0)),k("#hide-all").addEventListener("click",()=>rs(!1)),w.zoneToggle.addEventListener("change",()=>{Oo(w.zoneToggle.checked)}),w.zoneIndex.addEventListener("click",i=>{let r=i.target.closest("[data-zone]");r&&Vf(Number(r.dataset.zone))}),w.zoneIndex.addEventListener("contextmenu",i=>{let r=i.target.closest("[data-zone]");r&&(i.preventDefault(),jf(Number(r.dataset.zone)))}),w.search.addEventListener("input",()=>{u.search=w.search.value.trim().toLocaleLowerCase(),ue(),u.search&&Eo()}),w.dockFold.addEventListener("click",()=>{Ol(!u.dockFolded)}),w.searchResults.addEventListener("click",i=>{let r=i.target.closest("[data-location]");if(!r)return;let s=u.pinByID.get(Number(r.dataset.location));s&&Dl(s)}),w.detailLinks.addEventListener("click",i=>{let r=i.target.closest("[data-location]");if(!r)return;let s=u.pinByID.get(Number(r.dataset.location));s&&Dl(s)}),k("#close-detail").addEventListener("click",Te),k("#zoom-in").addEventListener("click",()=>Ss(1)),k("#zoom-out").addEventListener("click",()=>Ss(-1)),w.gridBack.addEventListener("click",Al),w.gridInput.addEventListener("input",()=>{let i=_n(),r=[...w.gridInput.value.toLocaleLowerCase()].filter(s=>ae.includes(s)).slice(0,i).join("");w.gridInput.value=r,Zr(r)}),w.subgridToggle.addEventListener("click",()=>{Kr(!u.subgridVisible),w.viewport.focus({preventScroll:!0})}),w.gridInput.addEventListener("keydown",i=>{if(i.key===" "){i.preventDefault(),Kr(!u.subgridVisible);return}i.key==="Escape"&&(i.preventDefault(),i.stopPropagation(),w.viewport.focus({preventScroll:!0}))}),w.viewport.addEventListener("keydown",i=>{if(!xo(i.target)){if(i.key==="+"||i.key==="=")Ss(1);else if(i.key==="-")Ss(-1);else if(i.key==="Escape")Te();else return;i.preventDefault()}}),window.addEventListener("contextmenu",i=>{xo(i.target)||i.preventDefault()}),window.addEventListener("keydown",i=>{if((i.metaKey||i.ctrlKey)&&i.key.toLocaleLowerCase()==="r"){i.preventDefault(),location.reload();return}if(!xo(i.target)){if((i.metaKey||i.ctrlKey)&&i.key.toLocaleLowerCase()==="k"){i.preventDefault(),w.search.focus(),w.search.select();return}if((i.metaKey||i.ctrlKey)&&i.altKey&&i.code==="KeyB"){i.preventDefault(),w.dock.hidden||Ol(!u.dockFolded);return}if((i.metaKey||i.ctrlKey)&&i.key.toLocaleLowerCase()==="b"){i.preventDefault(),Pm();return}Qd(i)||i.key.toLocaleLowerCase()==="z"&&(i.preventDefault(),i.repeat||ko(!0))}}),window.addEventListener("keyup",i=>{i.key.toLocaleLowerCase()==="z"&&ko(!1)}),window.addEventListener("blur",()=>ko(!1)),window.addEventListener("hashchange",()=>{let i=Jn();i.game===u.game?.slug&&i.map===u.map?.slug||(u.restore=null,_i(i.game||u.catalog.games[0].slug,i.map))}),window.addEventListener("resize",()=>{u.engine?.updateSize(),vs()}),w.overview.addEventListener("pointerdown",i=>{u.overviewDocked||i.pointerType==="mouse"&&i.button!==0||(i.preventDefault(),w.overview.setPointerCapture(i.pointerId),u.overviewPointer=i.pointerId,$h(i,!0))}),w.overview.addEventListener("pointermove",i=>{u.overviewPointer===i.pointerId&&(i.preventDefault(),$h(i,!1))});let e=i=>{u.overviewPointer===i.pointerId&&(u.overviewPointer=null,xr())};w.overview.addEventListener("pointerup",e),w.overview.addEventListener("pointercancel",e),w.overviewDock.addEventListener("click",()=>{ga(!u.overviewDocked),w.viewport.focus({preventScroll:!0})}),w.mobileLegend.addEventListener("click",()=>{let i=w.sidebar.classList.toggle("is-open");w.mobileLegend.setAttribute("aria-expanded",String(i))})}function Dm(){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?Ze(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,labelsHeld:u.labelsHeld,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:!w.detail.hidden,detailTitle:w.detail.hidden?null:w.detailTitle.textContent||null,searchQuery:u.search,searchResultsVisible:!w.searchResults.hidden,soloChip:w.soloChip.hidden?null:w.soloChip.textContent,visibleCountText:w.visibleCount.textContent,overviewDocked:u.overviewDocked,dockFolded:u.dockFolded,dockDismissed:u.dockDismissed,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:_n(),extent:u.gridEnabled?tr():null,cells:[...u.sources.grid.getFeatures(),...u.sources.gridContext.getFeatures()].map(t=>t.get("gridCell")),priorityPins:u.gridPrefix?u.pins.filter(t=>!t.filteredHidden&&er(t)).length:0}});window.__atlasDebug={snapshot:n,setLayerVisible:(t,e)=>u.layers[t]?.setVisible(e),refreshCatalog:Cn},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 km(){Om();try{let n=await fetch("/data/catalog.json");if(!n.ok)throw new Error(`catalog request returned ${n.status}`);if(u.catalog=await n.json(),nn(w.game,u.catalog.games,"title"),dc(),window.runtime?.EventsOn?.("atlas:catalog-changed",()=>{Cn()}),u.catalog.games.length){let t=Jn(),e=$n(),i=e&&(!t.game||t.game===e.game&&t.map===e.map);u.restore=i?e:null,await _i(t.game||e?.game||u.catalog.games[0].slug,t.map||e?.map),u.restore=null}else w.loading.hidden=!0;Dm(),requestAnimationFrame(()=>w.viewport.focus({preventScroll:!0}))}catch(n){w.loading.hidden=!0,w.fatalMessage.textContent=n instanceof Error?n.message:String(n),w.fatal.hidden=!1}}km();})();4+`).trim()}function Ie(n){return new Intl.NumberFormat().format(n)}function be(n,t,e){return Math.min(e,Math.max(t,n))}function Eo(n){return n instanceof HTMLElement&&(n.matches("input, textarea, select")||n.isContentEditable)}var Hp=100;function Xi(){if(!w.searchResults)return;let n=u.pins.filter(i=>!i.filteredHidden).sort((i,r)=>i.location.title.localeCompare(r.location.title)),t=n.slice(0,Hp),e=document.createDocumentFragment();if(!t.length){let i=document.createElement("p");i.className="search-empty",i.textContent=u.search?"No visible locations match.":"Nothing is enabled. Show a category to list its locations.",e.append(i)}for(let i of t){let r=document.createElement("button");r.type="button",r.className="search-result",u.selectedPin===i&&r.classList.add("is-selected"),r.dataset.location=String(i.location.id),nr(r,i.category);let s=document.createElement("span");s.className="result-dot",rr(s,i.category,Gi(i.category.title));let o=document.createElement("span"),a=document.createElement("strong");a.textContent=i.location.title;let l=document.createElement("small");l.textContent=`${i.category.title} \xB7 ${i.group.title}`,o.append(a,l),r.append(s,o),e.append(r)}if(n.length>t.length){let i=document.createElement("p");i.className="dock-note",i.textContent=`First ${t.length} of ${Ie(n.length)} \u2014 search or filter to narrow the list.`,e.append(i)}w.searchResults.replaceChildren(e),$p(n.length),qp()}var af=28;function qp(){let n=u.selectedPin?.location.title||"",t=n.length>af?`${n.slice(0,af-1).trimEnd()}\u2026`:n;w.dockRailName.textContent=t?` \xB7 ${t}`:"",w.dockRailName.hidden=!t}function $p(n){w.dockCount.textContent=`${Ie(n)} ${n===1?"location":"locations"}`,u.search?(w.dockFlag.textContent=`\u201C${u.search}\u201D`,w.dockFlag.hidden=!1):u.hiddenCategories.size>0?(w.dockFlag.textContent="filtered",w.dockFlag.hidden=!1):w.dockFlag.hidden=!0}function wo(){!u.dockFolded||u.dockDismissed||Co(!1)}function Dl(n){u.dockDismissed=n,Co(n)}function Co(n,t=!0){u.dockFolded=n,w.dock.classList.toggle("is-folded",n),w.dockFold.setAttribute("aria-expanded",String(!n));let e=n?"Bring the panel back (\u2318\u2325B)":"Put the panel away (\u2318\u2325B)";w.dockFold.setAttribute("aria-label",e),w.dockFold.setAttribute("title",e),t&&Re()}function kl(n){u.hiddenCategories.delete(n.category.id),Hr(),ue(),Wi(),Fl(n,!0)}function Fl(n,t=!1){u.selectedPin=n,Ke(),u.layers.pins.changed(),u.layers.pinLabels.changed(),u.layers.text.changed(),u.layers.textDetail.changed(),u.layers.priority.changed(),w.detailTitle.textContent=n.location.title,w.detailCategory.textContent=`${n.group.title} / ${n.category.title}`,w.detailDescription.textContent="",w.detailLinks.hidden=!0,Qp(n),w.detailID.textContent=String(n.location.id),w.detailCoordinates.textContent=`${n.location.lat.toFixed(6)}, ${n.location.lng.toFixed(6)}`;let e=rf(n.coordinate);w.detailCell.textContent=e,w.detailCellField.hidden=!e;let i=Jp(n);if(w.detailSource.textContent=i,w.detailSourceField.hidden=!i,nr(w.detailDot,n.category),rr(w.detailDot,n.category,Gi(n.category.title)),w.detail.hidden=!1,wo(),Xi(),t){let r=u.engine.getView();r.animate({center:n.coordinate,zoom:Math.min(Ze(u.variant),Math.max(r.getZoom()||0,4)),duration:220})}}function Jp(n){let t=u.map?.merged;if(!t?.length)return"";let e=t.find(i=>i.origin)?.source||"";if(u.pinSourceIndex?.map!==u.map){let i=new Map;for(let r of t){for(let s of r.adopted||[])i.set(s.d,r.source);for(let s of r.matched||[]){let o=`confirmed by ${r.source}`;i.set(s.w,e?`${e} \xB7 ${o}`:o)}}u.pinSourceIndex={map:u.map,byID:i}}for(let i of t)if(!i.origin&&n.group.title===i.source)return i.source;return u.pinSourceIndex.byID.get(n.location.id)||e}async function Qp(n){let t=await lf();if(u.selectedPin!==n)return;let e=t[String(n.location.id)]||{};n.location.description=e.d||"",n.location.links=e.l||[],w.detailDescription.textContent=of(e.d)||"No description is included in the archive.",t_(n)}function t_(n){let t=(n.location.links||[]).filter(i=>u.pinByID.has(i.locationId));if(w.detailLinks.hidden=t.length===0,!t.length){w.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)}w.detailLinks.replaceChildren(e)}function Te(){let n=u.selectedPin!==null;u.selectedPin=null,u.sources&&(Ke(),u.layers.pins.changed(),u.layers.pinLabels.changed(),u.layers.text.changed(),u.layers.textDetail.changed(),u.layers.priority.changed()),w.detail.hidden=!0,n&&Xi()}function Be(n){let t=n.attrs?.["atlas.render.as"];return t||(n.displayType==="text"?"text":"pin")}var So=[NaN,NaN,NaN,0],Nl;function e_(){return Nl||(Nl=nt(1,1,void 0,{willReadFrequently:!0,desynchronized:!0})),Nl}var i_=/^rgba?\(\s*(\d+%?)\s+(\d+%?)\s+(\d+%?)(?:\s*\/\s*(\d+%|\d*\.\d+|[01]))?\s*\)$/i,n_=/^rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)(?:\s*,\s*(\d+%|\d*\.\d+|[01]))?\s*\)$/i,r_=/^rgba?\(\s*(\d+%)\s*,\s*(\d+%)\s*,\s*(\d+%)(?:\s*,\s*(\d+%|\d*\.\d+|[01]))?\s*\)$/i,s_=/^#([\da-f]{3,4}|[\da-f]{6}|[\da-f]{8})$/i;function vo(n,t){return n.endsWith("%")?Number(n.substring(0,n.length-1))/t:Number(n)}function $r(n){throw new Error('failed to parse "'+n+'" as color')}function cf(n){if(n.toLowerCase().startsWith("rgb")){let s=n.match(n_)||n.match(i_)||n.match(r_);if(s){let o=s[4],a=100/255;return[et(vo(s[1],a)+.5|0,0,255),et(vo(s[2],a)+.5|0,0,255),et(vo(s[3],a)+.5|0,0,255),o!==void 0?et(vo(o,100),0,1):1]}$r(n)}if(n.startsWith("#")){if(s_.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}$r(n)}let t=e_();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&&$r(n));let i=t.fillStyle;if(i.startsWith("#")||i.startsWith("rgba"))return cf(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]=ln(r[3]/255,3),r}function hf(n){return typeof n=="string"?n:Qr(n)}var o_=1024,qr={},zl=0;function uf(n){if(n.length===4)return n;let t=n.slice();return t[3]=1,t}function Gl(n){return n>.0031308?Math.pow(n,1/2.4)*269.025-14.025:n*3294.6}function Xl(n){return n>.2068965?Math.pow(n,3):(n-4/29)*(108/841)}function Wl(n){return n>10.314724?Math.pow((n+14.025)/269.025,2.4):n/3294.6}function Ul(n){return n>.0088564?Math.pow(n,1/3):n/(108/841)+4/29}function Yl(n){let t=Wl(n[0]),e=Wl(n[1]),i=Wl(n[2]),r=Ul(t*.222488403+e*.716873169+i*.06060791),s=500*(Ul(t*.452247074+e*.399439023+i*.148375274)-r),o=200*(r-Ul(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 df(n){let t=(n[0]+16)/116,e=n[1],i=n[2]*Math.PI/180,r=Xl(t),s=Xl(t+e/500*Math.cos(i)),o=Xl(t-e/200*Math.sin(i)),a=Gl(s*3.021973625-r*1.617392459-o*.404875592),l=Gl(s*-.943766287+r*1.916279586+o*.027607165),h=Gl(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 Jr(n){if(n==="none")return So;if(qr.hasOwnProperty(n))return qr[n];if(zl>=o_){let e=0;for(let i in qr)(e++&3)===0&&(delete qr[i],--zl)}let t=cf(n);t.length!==4&&$r(n);for(let e of t)isNaN(e)&&$r(n);return qr[n]=t,++zl,t}function de(n){return Array.isArray(n)?n:Jr(n)}function Qr(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=Kl(t,e);return i in this.cache_?this.cache_[i]:null}getPattern(t,e){let i=Kl(t,e);return i in this.patternCache_?this.patternCache_[i]:null}set(t,e,i,r){let s=Kl(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]=Gr().createPattern(i.getImage(1),"repeat")}):this.patternCache_[s]=Gr().createPattern(i.getImage(1),"repeat")),o||++this.cacheSize_}setSize(t){this.maxCacheSize_=t,this.expire()}};function Kl(n,t){let e=t?de(t):"null";return n+":"+e}var Xt=new Zl;var ts=null,Ro=class extends Fi{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){ts||(ts=nt(1,1,void 0,{willReadFrequently:!0})),ts.drawImage(this.image_,0,0);try{ts.getImageData(0,0,1,1),this.tainted_=!1}catch{ts=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&&dd(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=hf(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 Ui(n,t,e,i,r,s){let o=t===void 0?void 0:Xt.get(t,r);return o||(o=new Ro(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 ff=Ro;function Ht(n){return n?Array.isArray(n)?Qr(n):typeof n=="object"&&"src"in n?a_(n):n:null}function a_(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]),Ui(r.canvas,t,void 0,U.LOADED,n.color,!0),Xt.getPattern(t,n.color)}var es="ol-hidden";var Yi="ol-unselectable";var sr="ol-control",Bl="ol-collapsed",l_=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"),gf=["style","variant","weight","size","lineHeight","family"],To={normal:400,bold:700},Io=function(n){let t=n.match(l_);if(!t)return null;let e={lineHeight:"normal",size:"1.2em",style:"normal",weight:"400",variant:"normal"};for(let i=0,r=gf.length;i<r;++i){let s=t[i+1];s!==void 0&&(e[gf[i]]=typeof s=="string"?s.trim():s)}return isNaN(Number(e.weight))&&e.weight in To&&(e.weight=To[e.weight]),e.families=e.family.split(/,\s?/).map(i=>i.trim().replace(/^['"]|['"]$/g,"")),e};var bo="10px sans-serif",Tt="#000",Ve="round",qt=[],$t=0,je="round",gi=10,pf=0,Wt="#000",Ki="center",En="middle",mi=[0,0,0,0],pi=1,xn=new wt,is=null,mf,Vl={},c_=new Set(["serif","sans-serif","monospace","cursive","fantasy","system-ui","ui-serif","ui-sans-serif","ui-monospace","ui-rounded","emoji","math","fangsong"]);function h_(n,t,e){return`${n} ${t} 16px "${e}"`}var _f=(function(){let t,e;async function i(s){await e.ready;let o=Io(s),a=o.families[0].toLowerCase(),l=o.weight,h=[];return e.forEach(d=>{let f=d.family.replace(/^['"]|['"]$/g,"").toLowerCase(),g=To[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=xn.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)?(Xe(Vl),xn.set(h,100)):(c+=10,xn.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=Io(s);if(!o)return;let a=o.families,l=!1;for(let h of a){if(c_.has(h))continue;let c=h_(o.style,o.weight,h);xn.get(c)===void 0&&(xn.set(c,0,!0),l=!0)}l&&(clearTimeout(t),t=setTimeout(r,100))}})(),u_=(function(){let n;return function(t){let e=Vl[t];if(e==null){if(Rt){let i=Io(t),r=yf(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);Vl[t]=e}return e}})();function yf(n,t){return is||(is=nt(1,1)),n!=mf&&(is.font=n,mf=is.font),is.measureText(t)}function xf(n,t){return yf(n,t).width}function jl(n,t,e){if(t in e)return e[t];let i=t.split(`5+`).reduce((r,s)=>Math.max(r,xf(n,s)),0);return e[t]=i,i}function Ef(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=xf(f,d);e.push(g),o+=g;let m=u_(f);i.push(m),l=Math.max(l,m)}return{width:s,height:a,widths:e,heights:i,lineWidths:r}}function wf(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]),d_(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 d_(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 Hl=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()}},Lo=Hl;var ql=class n extends Lo{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 ff(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),v=s-E,C=Math.sqrt(y*y+v*v)/y;if(C<=i){let T=C*e/2-s-r;return 2*Math.max(p,T)}return p*2}createRenderOptions(){let t=Ve,e=je,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()??je,t=this.stroke_.getLineCap()??Ve,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=de(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()}},Ao=ql;var $l=class n extends Ao{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}},Mo=$l;var Jl=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=Ui(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:de(t).toString():""}loading(){return!!this.patternImage_}ready(){return this.patternImage_?this.patternImage_.ready():Promise.resolve()}},pt=Jl;function Cf(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 Ql=class n extends Lo{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;B(!(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)),B(a!==void 0&&a.length>0,"A defined and non-empty `src` or `image` must be provided"),B(!((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?de(t.color):null,this.iconImage_=Ui(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(Cf(g[0],g[1],t.width,t.height))};this.listenImageChange(f);return}}h!==void 0&&this.setScale(Cf(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?de(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_=Ui(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_=Ui(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()}},wn=Ql;var tc=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=tc;var Po=class n{constructor(t){t=t||{},this.geometry_=null,this.geometryFunction_=vf,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_=vf,this.geometry_=t}setZIndex(t){this.zIndex_=t}};function Sf(n){let t;if(typeof n=="function")t=n;else{let e;Array.isArray(n)?e=n:(B(typeof n.getZIndex=="function","Expected an `Style` or an array of `Style`"),e=[n]),t=function(){return e}}return t}var ec=null;function ic(n,t){if(!ec){let e=new pt({color:"rgba(255,255,255,0.4)"}),i=new Mt({color:"#3399CC",width:1.25});ec=[new Po({image:new Mo({fill:e,stroke:i,radius:5}),fill:e,stroke:i})]}return ec}function vf(n){return n.getGeometry()}var It=Po;var f_="#333",nc=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:f_}),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=nc;function fe(n,t){return(n.get("priority")||0)-(t.get("priority")||0)}function If(n){let t=n.get("pin");return!t||ge(t)||t.insideHighlightedZone||or(t)?null:rc(t,!1)}function bf(n){let t=n.get("pin");return!t||!u.highlightedZones.size||!t.insideHighlightedZone||ge(t)||or(t)?null:rc(t,!1)}function Lf(n){let t=n.get("pin");return!t||ge(t)||!u.labelsHeld?null:Df(t)}function Af(n){let t=n.get("pin");if(!t||ge(t)||t.insideHighlightedZone||or(t)||rs())return null;if(u.labelsHeld)return ns(t,!1);let e=u.fitZoom+Math.log2(Yf(t.category));return(u.engine.getView().getZoom()||0)<e?null:ns(t,!1)}function Mf(n){let t=n.get("pin");return!t||ge(t)||t.insideHighlightedZone||or(t)||!rs()?null:ns(t,!1)}function Pf(n){let t=n.get("pin");return!t||!u.highlightedZones.size||!t.insideHighlightedZone||ge(t)||or(t)?null:ns(t,!1)}function Of(n){let t=n.get("pin");if(!t||ge(t))return null;if(Be(t.category)==="text")return ns(t,t===u.selectedPin);let e=rc(t,t===u.selectedPin);return t===u.hoveredPin||t===u.selectedPin?[e,Df(t)]:e}function rc(n,t){let e=`marker:${n.category.id}:${t?1:0}`;if(u.styleCache.has(e))return u.styleCache.get(e);let i=jr(n.category),r=t?2e7:n.priority,s=u.markerIcons.get(Ff(n.category)),o;return s?o=new It({image:new wn({src:s,width:t?36:31,height:t?36:31}),zIndex:r}):o=new It({text:new _i({text:Gi(n.category.title),font:`900 ${t?15:13}px Inter, sans-serif`,fill:new pt({color:i}),stroke:new Mt({color:Vr(),width:t?4:3})}),zIndex:r}),u.styleCache.set(e,o),o}function Df(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:"#f2ece0"}),stroke:new Mt({color:"rgba(0,0,0,0.98)",width:3}),backgroundFill:new pt({color:"rgba(10,12,17,0.72)"}),padding:[2,4,2,4],overflow:!0}),zIndex:n.priority});return u.styleCache.set(t,e),e}function kf(n){if(!n.iconAsset)return;let t=Ff(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=jr(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=Vr(),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")),g_(),u.layers.pins.changed(),u.layers.zonePins.changed(),u.layers.priority.changed()},e.onerror=()=>u.markerIcons.set(t,!1),e.src=Ol(n.iconAsset)}function g_(){for(let n of u.styleCache.keys())n.startsWith("marker:")&&u.styleCache.delete(n)}function Ff(n){return`${n.iconAsset||""}:${jr(n)}:${u.map?.iconOutset||"light"}`}function ns(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?"#7fd0ea":"#f2ece0"}),stroke:new Mt({color:"rgba(0,0,0,0.95)",width:4}),backgroundFill:new pt({color:t?"rgba(13,16,23,0.9)":"rgba(10,12,17,0.58)"}),backgroundStroke:t?new Mt({color:"#3aa5c9",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 sc(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=m_(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=Pn[Math.max(0,ae.indexOf(e.hash[e.hash.length-1]))%Pn.length],m=new It({fill:r?void 0:new pt({color:s?`rgba(5, 8, 16, ${Math.min(.52,.3+e.contextDistance*.06)})`:fi(g,i?.14:.055)}),stroke:new Mt({color:i||r?"#ffffff":fi(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?fi(g,.72):g}),stroke:new Mt({color:"rgba(0,0,0,0.96)",width:4}),backgroundFill:new pt({color:s?"rgba(8,11,18,0.88)":"rgba(12,15,22,0.76)"}),padding:h,overflow:!0}):void 0,zIndex:i||r?100:n.get("priority")});return u.styleCache.set(f,m),m}function m_(n,t,e,i,r){if(!r)return!0;let s=p_(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 Rf=document.createElement("canvas").getContext("2d"),Tf=new Map;function p_(n,t){let e=`${t}|${n}`,i=Tf.get(e);return i===void 0&&(Rf.font=t,i=Rf.measureText(n).width,Tf.set(e,i)),i}var __=new It({fill:new pt({color:"rgba(5, 8, 16, 0.62)"})});function Nf(){return u.zonesVisible?__:null}function zf(n){if(!u.zonesVisible)return null;let t=n.get("zone"),e=n.get("child"),i=u.highlightedZones.has(t.id),r=Uf(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:fi(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:fi(o,e?.035:.07)}),stroke:new Mt({color:fi(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:fi(o,.22)}),stroke:new Mt({color:o,width:2.6}),zIndex:9001})];return u.styleCache.set(s,l),l}function Gf(n){if(!u.zonesVisible||rs())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:Wf(n)}function Xf(n){return!u.zonesVisible||!rs()?null:Wf(n)}function Wf(n){let t=n.get("child"),e=n.get("zone"),i=u.highlightedZones.has(e.id),r=Uf(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?"#10131a":r?"rgba(196,191,177,0.56)":t?"#c8c2b4":"#f2ece0"}),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(8,11,18,0.84)":"rgba(13,16,23,0.72)"}),backgroundStroke:new Mt({color:i?"#ffffff":fi(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 Uf(n){if(!u.highlightedZones.size||u.highlightedZones.has(n))return!1;for(let t of u.highlightedZones)if(y_(n,t))return!1;return!0}function y_(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 oc=class n extends We{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<Li(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 Ue(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(Ar(t,o,a))return!0}return!1}setCoordinates(t,e){this.setLayout(e,t,1),this.flatCoordinates||(this.flatCoordinates=[]),this.flatCoordinates.length=Xr(this.flatCoordinates,0,t,this.stride),this.changed()}},Kf=oc;function Oo(n,t,e,i){let r=[],s=ut();for(let o=0,a=e.length;o<a;++o){let l=e[o];s=Dn(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 ac=class n extends We{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<Li(this.getExtent(),t,e)?r:(this.maxDeltaRevision_!=this.getRevision()&&(this.maxDelta_=Math.sqrt(Bd(this.flatCoordinates,0,this.endss_,this.stride,0)),this.maxDeltaRevision_=this.getRevision()),Vd(this.getOrientedFlatCoordinates(),0,this.endss_,this.stride,this.maxDelta_,!0,t,e,i,r))}containsXY(t,e){return Qu(this.getOrientedFlatCoordinates(),0,this.endss_,this.stride,t,e)}getArea(){return Kd(this.getOrientedFlatCoordinates(),0,this.endss_,this.stride)}getCoordinates(t){let e;return t!==void 0?(e=this.getOrientedFlatCoordinates().slice(),Ll(e,0,this.endss_,this.stride,t)):e=this.flatCoordinates,Wr(e,0,this.endss_,this.stride)}getEndss(){return this.endss_}getFlatInteriorPoints(){if(this.flatInteriorPointsRevision_!=this.getRevision()){let t=Oo(this.flatCoordinates,0,this.endss_,this.stride);this.flatInteriorPoints_=go(this.getOrientedFlatCoordinates(),0,this.endss_,this.stride,t),this.flatInteriorPointsRevision_=this.getRevision()}return this.flatInteriorPoints_}getInteriorPoints(){return new Kf(this.getFlatInteriorPoints().slice(),"XYM")}getOrientedFlatCoordinates(){if(this.orientedRevision_!=this.getRevision()){let t=this.flatCoordinates;$d(t,0,this.endss_,this.stride)?this.orientedFlatCoordinates_=t:(this.orientedFlatCoordinates_=t.slice(),this.orientedFlatCoordinates_.length=Ll(this.orientedFlatCoordinates_,0,this.endss_,this.stride)),this.orientedRevision_=this.getRevision()}return this.orientedFlatCoordinates_}getSimplifiedGeometryInternal(t){let e=[],i=[];return e.length=Hd(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 Ye(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 Ye(e.slice(s,h),t,l);r.push(c),s=h}return r}getType(){return"MultiPolygon"}intersectsExtent(t){return ed(this.getOrientedFlatCoordinates(),0,this.endss_,this.stride,t)}setCoordinates(t,e){this.setLayout(e,t,3),this.flatCoordinates||(this.flatCoordinates=[]);let i=Yd(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()}},Zf=ac;function lc(){let n=(u.map.zones||[]).filter(uc);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,Do(!0),w.zoneIndex.hidden=n.length===0,w.zoneCount.textContent=Ie(n.length);for(let t of n){let e=ut(),i=[],r=!1;for(let l of t.features||[]){let h=w_(l);h&&(r=!0,i.push(h),ks(e,h.getExtent()),u.sources.zones.addFeature(new Ni({geometry:h,zone:t,color:xo(t.id),child:t.parentRegionId!=null})))}if(!r)continue;let s=xo(t.id),o=t.center?ko(t.center.lat,t.center.lng):Bt(e),a=Math.max(e[2]-e[0],e[3]-e[1]);u.sources.zoneTitles.addFeature(new Ni({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,Vf(),x_()}function Vf(){if(u.sources.zoneScrim.clear(),!u.highlightedZones.size)return;let[n,t,e,i]=u.projection.getExtent(),r=[Bf([[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(Bf(h.getCoordinates(),c>0))})}u.sources.zoneScrim.addFeature(new Ni({geometry:new Ye(r)}))}function Bf(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 x_(){let n=document.createDocumentFragment();for(let{zone:t,depth:e}of E_()){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)}w.zoneList.replaceChildren(n),w.zoneIndex.hidden=u.zoneRecords.size===0}function E_(){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 Do(n){u.zonesVisible=n,w.zoneToggle.checked=n,u.layers.zoneScrim.setVisible(n),u.layers.zones.setVisible(n),u.layers.zoneTitles.setVisible(n),u.layers.zoneTitleDetail.setVisible(n)}function jf(n){let t=u.zoneRecords.get(n);t&&(u.focusedZoneID=n,qf(),Te(),u.engine.getView().fit(t.extent,{size:u.engine.getSize(),padding:[54,54,54,54],maxZoom:Ze(u.variant),duration:220}),w.sidebar.classList.remove("is-open"),w.mobileLegend.setAttribute("aria-expanded","false"))}function Hf(n){u.zoneRecords.has(n)&&(u.highlightedZones.has(n)?u.highlightedZones.delete(n):(u.highlightedZones.add(n),Do(!0)),u.hoveredPin=null,cc(),hc(),qf(),Vf(),u.layers.zones.changed(),u.layers.zoneTitles.changed(),u.layers.zoneTitleDetail.changed())}function qf(){w.zoneIndex.classList.toggle("has-highlights",u.highlightedZones.size>0);for(let n of w.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 w_(n){if(!n?.coordinates)return null;let t=([e,i])=>ko(i,e);return n.type==="Polygon"?new Ye(n.coordinates.map(e=>e.map(t))):n.type==="MultiPolygon"?new Zf(n.coordinates.map(e=>e.map(i=>i.map(t)))):null}function ko(n,t){let e=C_(),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 C_(){let n=u.game.tileGrid,t=u.map?.grid;return t?{...n,...t}:n}function $f(){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){Be(t)!=="text"&&kf(t);for(let e of t.locations){let i={location:e,category:t,group:n,coordinate:ko(e.lat,e.lng),filteredHidden:!1,priority:T_(t,e),feature:null};i.feature=new Ni({geometry:new ui(i.coordinate),pin:i,priority:i.priority}),u.pins.push(i),u.pinByID.set(e.id,i),Be(t)==="text"?u.sources.text.addFeature(i.feature):u.sources.pins.addFeature(i.feature)}}ue()}function ue(){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)}cc(),hc(),u.selectedPin?.filteredHidden&&Te(),Xi()}function cc(){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=>v_(i,t.coordinate)))}function v_(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 hc(){u.eligibleLocations=u.pins.filter(n=>!ge(n)).length,Ke(),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(),Cn()}function Ke(){u.sources.priority.clear();for(let n of u.pins){if(ge(n))continue;let t=!!u.search&&n.location.title.toLocaleLowerCase().includes(u.search);(n===u.selectedPin||n===u.hoveredPin||t||ir(n))&&u.sources.priority.addFeature(n.feature)}}function ar(n){u.hoveredPin!==n&&(u.hoveredPin=n,u.sources&&(Ke(),u.layers.pins.changed(),u.layers.priority.changed()))}function Fo(n){u.labelsHeld!==n&&(u.labelsHeld=n,w.labelsHint.textContent=n?"Z \xB7 labels shown":"Z \xB7 hold for labels",u.layers.pinLabels.changed(),u.layers.text.changed())}function or(n){return n===u.selectedPin||n===u.hoveredPin||ir(n)||!!u.search&&n.location.title.toLocaleLowerCase().includes(u.search)}function ge(n){return n.filteredHidden||S_(n)||R_(n)||!uc(n.location)}function uc(n){let t=u.variant?.shard;return!t||!n.shard||n.shard===t}function S_(n){return!u.highlightedZones.size||n.insideHighlightedZone||n===u.selectedPin?!1:!(u.search&&n.location.title.toLocaleLowerCase().includes(u.search))}function R_(n){return!u.gridEnabled||!u.gridPrefix||ir(n)||n===u.selectedPin?!1:!(u.search&&n.location.title.toLocaleLowerCase().includes(u.search))}function T_(n,t){return Math.max(0,1e6-Math.min(n.locations.length,999)*1e3)+sf(t.id)%1e3}function Yf(n){return n.locations.length>200?4:n.locations.length>75?2.5:1}function rs(){return(u.engine?.getView().getZoom()||0)>=(u.variant?.maxZoom||0)-.05}function Jf(n){let t=[],e=[];for(let i of n){let r=[];for(let s of i.categories)(Be(s)==="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 Qf(){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(I_(t.key,t.title,i));let r=document.createElement("div");r.className="category-toggles";for(let s of t.categories)r.append(b_(s));e.append(r),n.append(e)}w.legend.replaceChildren(n),No(),Wi()}function I_(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=Ie(e),r.append(s,o,a);let l=tg(`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 tg(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 b_(n){let t=Be(n)==="text",e=document.createElement("label");e.className="category-row",nr(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",rr(r,n,Gi(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=Ie(n.locations.length);let a=tg(`Show only ${n.title}`);return a.dataset.onlyCategory=String(n.id),e.append(i,r,s,a,o),e}function dc(n){if(u.collapsedSections.clear(),n)for(let t of w.layers.querySelectorAll("[data-section]"))u.collapsedSections.add(t.dataset.section);No()}function No(){for(let n of w.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)}Re()}function ss(n){if(u.hiddenCategories.clear(),!n)for(let t of u.map.groups)for(let e of t.categories)u.hiddenCategories.add(e.id);Hr(),ue(),Xi(),Wi()}function Hr(){for(let n of document.querySelectorAll("[data-category]"))n.checked=!u.hiddenCategories.has(Number(n.dataset.category))}function eg(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);Hr(),ue(),Wi()}function ig(n){if(u.map){if(L_(n)){ss(!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)}Hr(),ue(),Xi(),Wi()}}function L_(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 A_(){let n=w.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 Wi(){if(u.map){for(let n of u.map.sections){let t=w.legend.querySelector(`input[data-section-toggle="${n.key}"]`);t&&(t.checked=n.categories.some(e=>!u.hiddenCategories.has(e.id)))}A_(),Re()}}async function ng(n){let[t,e]=await Promise.all([fetch(`${u.game.base}/maps/${n.slug}.json`),fetch(`${u.game.base}/maps/${n.slug}.bin`)]);if(!t.ok||!e.ok)throw new Error(`map ${n.slug} is not served under this catalog any more`);let[i,r]=await Promise.all([t.json(),e.arrayBuffer()]),s=i.groups.flatMap(o=>o.categories);return M_(r,s),{...n,grid:i.grid,variants:i.variants,groups:i.groups,zones:i.zones||[],attrs:i.attrs||{},merged:i.merged||[],sections:Jf(i.groups)}}function M_(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 lf(){let n=`${u.game.base}/${u.map.slug}`;return u.textByMap.has(n)||u.textByMap.set(n,fetch(`${u.game.base}/maps/${u.map.slug}.text`).then(t=>t.json()).catch(()=>({}))),u.textByMap.get(n)}var zo=null;function vn(){return zo||(zo=P_().finally(()=>{zo=null})),zo}async function P_(){let n=await fetch("/data/catalog.json");if(!n.ok)return;let t=u.game;if(u.catalog=await n.json(),rn(w.game,u.catalog.games,"title"),fc(),!u.catalog.games.length)return;let e=t&&u.catalog.games.find(i=>i.slug===t.slug);if(!e){let i=Qn();await yi(i.game||Jn()?.game||u.catalog.games[0].slug,i.game?i.map:void 0);return}if(e.stamp!==t.stamp){for(let r of u.textByMap.keys())r.startsWith(t.base+"/")&&u.textByMap.delete(r);let i=u.engine?.getView();u.restore={game:e.slug,map:u.map?.slug,variant:u.map?u.map.variants.indexOf(u.variant):0,center:i?.getCenter(),zoom:i?.getZoom(),hidden:[...u.hiddenCategories],collapsed:[...u.collapsedSections],overviewDocked:u.overviewDocked,dockFolded:u.dockFolded,dockDismissed:u.dockDismissed},await yi(e.slug,u.map?.slug);return}u.game=e,w.game.value=e.slug}function fc(){let n=!u.catalog?.games?.length;w.emptyState.hidden=!n,u.catalog?.bundlesDir&&(w.emptyPath.textContent=u.catalog.bundlesDir)}async function gc(){for(let n of[w.emptyOpen,w.addBundles])n.disabled=!0;try{let t=await(await fetch("/data/bundles/import",{method:"POST"})).json().catch(()=>({}));await vn();let e=t.imported?.[0];e&&u.catalog.games.some(i=>i.slug===e)&&await yi(e)}finally{for(let n of[w.emptyOpen,w.addBundles])n.disabled=!1}}var Pt={ADD:"add",REMOVE:"remove"};var rg={LENGTH:"length"},lr=class extends Lt{constructor(t,e,i){super(t),this.element=e,this.index=i}},mc=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(rg.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 lr(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 lr(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 lr(Pt.REMOVE,r,t)),this.dispatchEvent(new lr(Pt.ADD,e,t))}updateLength_(){this.set(rg.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=mc;var pc=class extends Lt{constructor(t,e,i){super(t),this.map=e,this.frameState=i!==void 0?i:null}},Zi=pc;var _c=class extends Zi{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()}},He=_c;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 os={POINTERMOVE:"pointermove",POINTERDOWN:"pointerdown",POINTERUP:"pointerup",POINTEROVER:"pointerover",POINTEROUT:"pointerout",POINTERENTER:"pointerenter",POINTERLEAVE:"pointerleave",POINTERCANCEL:"pointercancel"};var yc=class extends Fi{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,os.POINTERDOWN,this.handlePointerDown_,this),this.originalPointerMoveEvent_,this.relayedListenerKey_=Z(i,os.POINTERMOVE,this.relayMoveEvent_,this),this.boundHandleTouchMove_=this.handleTouchMove_.bind(this),this.element_.addEventListener(P.TOUCHMOVE,this.boundHandleTouchMove_,eo?{passive:!1}:!1)}emulateClick_(t){let e=new He(at.CLICK,this.map_,t);this.dispatchEvent(e),this.clickTimeoutId_!==void 0?(clearTimeout(this.clickTimeoutId_),this.clickTimeoutId_=void 0,e=new He(at.DBLCLICK,this.map_,t),this.dispatchEvent(e)):this.clickTimeoutId_=setTimeout(()=>{this.clickTimeoutId_=void 0;let i=new He(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 He(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 He(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 He(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 He(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()}},sg=yc;var qe={POSTRENDER:"postrender",MOVESTART:"movestart",MOVEEND:"moveend",LOADSTART:"loadstart",LOADEND:"loadend"};var kt={LAYERGROUP:"layergroup",SIZE:"size",TARGET:"target",VIEW:"view"};var as=1/0,xc=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,Xe(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){B(!(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!=as?(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==as?delete this.queuedElements_[this.keyFunction_(o)]:(i[r]=l,e[r++]=o);e.length=r,i.length=r,this.heapify_()}},og=xc;var Ec=class extends og{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())}}},ag=Ec;function lg(n,t,e,i,r){if(!n||!(e in n.wantedTiles))return as;if(!n.wantedTiles[e][t.getKey()])return as;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 me={CENTER:"center",RESOLUTION:"resolution",ROTATION:"rotation"};function wc(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 cg(n){return n}function Cc(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 vc(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 hg(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?Cc(l,e,o,i):l;if(a)return t?vc(r,c,h):et(r,h,c);let d=Math.min(c,r),f=Math.floor(Zn(n,d,s));return n[f]>c&&f<n.length-1?n[f+1]:n[f]}})}function ug(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?Cc(t,r,l,s):t;if(h)return i?vc(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 Sc(n,t,e,i,r){return e=e!==void 0?e:!0,(function(s,o,a,l){if(s!==void 0){let h=i?Cc(n,i,a,r):n;return!e||!l?et(s,t,h):vc(s,h,t)}})}function cr(n){if(n!==void 0)return 0}function Rc(n){if(n!==void 0)return n}function dg(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 fg(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 Tc=0,bc=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_=js(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&&Yu(),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 me)delete e[a];this.setProperties(e,!0);let i=D_(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=O_(t),s=i.constraint,o=k_(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&&Go(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||fd,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=Ge(c.rotation-l+Math.PI,2*Math.PI)-Math.PI;d.targetRotation=l+f,l=d.targetRotation}F_(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&&Go(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?Ge(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&&Go(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]],zn(i,t-this.getRotation()),Cu(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&&Fr(t,this.getProjection())}getCenterInternal(){return this.get(me.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 Pi(e,this.getProjection())}calculateExtentInternal(t){t=t||this.getViewportSizeMinusPadding_();let e=this.getCenterInternal();B(e,"The view center is not defined");let i=this.getResolution();B(i!==void 0,"The view resolution is not defined");let r=this.getRotation();return B(r!==void 0,"The view rotation is not defined"),Pr(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(me.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(me.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=Ic(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=Zn(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(B(Array.isArray(t)||typeof t.getSimplifiedGeometry=="function","Invalid extent or geometry provided as `geometry`"),Array.isArray(t)){B(!ze(t),"Cannot fit empty extent provided as `geometry`");let r=Ce(t,this.getProjection());i=Al(r)}else if(t.getType()==="Circle"){let r=Ce(t.getExtent(),this.getProjection());i=Al(r),i.rotate(this.getRotation(),Bt(r))}else{let r=fn();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=Bt(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:hi;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),Go(p,!0))}centerOn(t,e,i){this.centerOnInternal(we(t,this.getProjection()),e,i)}centerOnInternal(t,e,i){this.setCenterInternal(Ic(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=Ic(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=Fr(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(me.ROTATION)!==r&&this.set(me.ROTATION,r),this.get(me.RESOLUTION)!==o&&(this.set(me.RESOLUTION,o),this.set("zoom",this.getZoom(),!0)),(!a||!this.get(me.CENTER)||!cn(this.get(me.CENTER),a))&&this.set(me.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()||!cn(this.getCenterInternal(),l))&&(this.getAnimating()&&this.cancelAnimations(),this.animateInternal({rotation:s,center:l,resolution:a,duration:t,easing:he,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 Go(n,t){setTimeout(function(){n(t)},0)}function O_(n){if(n.extent!==void 0){let e=n.smoothExtentConstraint!==void 0?n.smoothExtentConstraint:!0;return wc(n.extent,n.constrainOnlyCenter,e)}let t=js(n.projection,"EPSG:3857");if(n.multiWorld!==!0&&t.isGlobal()){let e=t.getExtent().slice();return e[0]=-1/0,e[2]=1/0,wc(e,!1,!1)}return cg}function D_(n){let t,e,i,o=n.minZoom!==void 0?n.minZoom:Tc,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=js(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=hg(p,c,!m&&_,d):t=Sc(e,i,c,!m&&_,d)}else{let y=(g?Math.max(j(g),ct(g)):360*oi.degrees/f.getMetersPerUnit())/256/Math.pow(2,Tc),E=y/Math.pow(2,28-Tc);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=ug(l,e,i,c,!m&&_,d):t=Sc(e,i,c,!m&&_,d)}return{constraint:t,maxResolution:e,minResolution:i,minZoom:o,zoomFactor:l}}function k_(n){if(n.enableRotation!==void 0?n.enableRotation:!0){let e=n.constrainRotation;return e===void 0||e===!0?fg():e===!1?Rc:typeof e=="number"?dg(e):Rc}return cr}function F_(n){return!(n.sourceCenter&&n.targetCenter&&!cn(n.sourceCenter,n.targetCenter)||n.sourceResolution!==n.targetResolution||n.sourceRotation!==n.targetRotation)}function Ic(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=bc;var Lc=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!==hi&&this.listenerKeys.push(Z(t,qe.POSTRENDER,this.render,this)),t.render()}}render(t){}setTarget(t){this.target_=typeof t=="string"?document.getElementById(t):t}},hr=Lc;var Ac=class extends hr{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+" "+Yi+" "+sr+(this.collapsed_&&this.collapsible_?" "+Bl:"")+(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=>ld(()=>r))),i=e.length>0;if(this.renderedVisible_!=i&&(this.element.style.display=i?"":"none",this.renderedVisible_=i),!Gt(e,this.renderedAttributions_)){md(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(Bl),this.collapsed_?il(this.collapseLabel_,this.label_):il(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)}},gg=Ac;var Mc=class extends hr{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+" "+Yi+" "+sr,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(es)}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:he}):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(es);!s&&i===0?this.element.classList.add(es):s&&i!==0&&this.element.classList.remove(es)}this.label_.style.transform=r}this.rotation_=i}},mg=Mc;var Pc=class extends hr{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+" "+Yi+" "+sr,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:he})):i.setZoom(s)}}},pg=Pc;function Xo(n){n=n||{};let t=new Dt;return(n.zoom===void 0||n.zoom)&&t.push(new pg(n.zoomOptions)),(n.rotate===void 0||n.rotate)&&t.push(new mg(n.rotateOptions)),(n.attribution===void 0||n.attribution)&&t.push(new gg(n.attributionOptions)),t}var Oc=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_}},_g=Oc;var Dc={ACTIVE:"active"};var kc=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(Dc.ACTIVE)}getMap(){return this.map_}handleEvent(t){return!0}setActive(t){this.set(Dc.ACTIVE,t)}setMap(t){this.map_=t}};function yg(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:gd,center:n.getConstrainedCenter(r)})}}function ur(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:he})}var $e=kc;var Fc=class extends $e{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();ur(a,o,s,this.duration_),i.preventDefault(),e=!0}return!e}},xg=Fc;function ls(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 Eg=function(n){let t=n.originalEvent;return t.altKey&&!(t.metaKey||t.ctrlKey)&&t.shiftKey},N_=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)},Wo=function(n){let t=n.map.getTargetElement(),e=t.getRootNode();return(e instanceof ShadowRoot?e.host:t).hasAttribute("tabindex")?N_(n):!0},wg=li;var Uo=function(n){let t=n.originalEvent;return"pointerId"in t&&t.button==0&&!(cd&&$a&&t.ctrlKey)};var Yo=function(n){let t=n.originalEvent;return!t.altKey&&!(t.metaKey||t.ctrlKey)&&!t.shiftKey};var Cg=function(n){let t=n.originalEvent;return $a?t.metaKey:t.ctrlKey},vg=function(n){let t=n.originalEvent;return!t.altKey&&!(t.metaKey||t.ctrlKey)&&t.shiftKey},Ko=function(n){let t=n.originalEvent,e=t.target.tagName;return e!=="INPUT"&&e!=="SELECT"&&e!=="TEXTAREA"&&!t.target.isContentEditable},Zo=function(n){let t=n.originalEvent;return"pointerId"in t&&t.pointerType=="mouse"};var Sg=function(n){let t=n.originalEvent;return"pointerId"in t&&t.isPrimary&&t.button===0};var Nc=class extends $e{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 dr(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 Je=Nc;var zc=class extends Je{constructor(t){super({stopDown:ci}),t=t||{},this.kinetic_=t.kinetic,this.lastCentroid=null,this.lastPointersCount_,this.panning_=!1;let e=t.condition?t.condition:ls(Yo,Sg);this.condition_=t.onFocusOnly?ls(Wo,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(dr(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();vu(s,a.getResolution()),zn(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:he})}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}},Rg=zc;var Gc=class extends Je{constructor(t){t=t||{},super({stopDown:ci}),this.condition_=t.condition?t.condition:Eg,this.lastAngle_=void 0,this.duration_=t.duration!==void 0?t.duration:250}handleDragEvent(t){if(!Zo(t))return;let e=t.map,i=e.getView();if(i.getConstraints().rotation===cr)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 Zo(t)?(t.map.getView().endInteraction(this.duration_),!1):!0}handleDownEvent(t){return Zo(t)&&Uo(t)&&this.condition_(t)?(t.map.getView().beginInteraction(),this.lastAngle_=void 0,!0):!1}},Tg=Gc;var Xc=class extends ki{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 Ye([r])}getGeometry(){return this.geometry_}},Ig=Xc;var fr={BOXSTART:"boxstart",BOXDRAG:"boxdrag",BOXEND:"boxend",BOXCANCEL:"boxcancel"},Sn=class extends Lt{constructor(t,e,i){super(t),this.coordinate=e,this.mapBrowserEvent=i}},Wc=class extends Je{constructor(t){super(),this.on,this.once,this.un,t=t??{},this.box_=new Ig(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],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 Sn(fr.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 Sn(e?fr.BOXEND:fr.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 Sn(fr.BOXSTART,t.coordinate,t)),!0):!1}onBoxEnd(t){}setActive(t){t||(this.box_.setMap(null),this.startPixel_&&(this.dispatchEvent(new Sn(fr.BOXCANCEL,this.startPixel_,null)),this.startPixel_=null)),super.setActive(t)}setMap(t){this.getMap()&&(this.box_.setMap(null),this.startPixel_&&(this.dispatchEvent(new Sn(fr.BOXCANCEL,this.startPixel_,null)),this.startPixel_=null)),super.setMap(t)}},bg=Wc;var Uc=class extends bg{constructor(t){t=t||{};let e=t.condition?t.condition:vg;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:he})}},Lg=Uc;var Bi={LEFT:"ArrowLeft",UP:"ArrowUp",RIGHT:"ArrowRight",DOWN:"ArrowDown"};var Yc=class extends $e{constructor(t){super(),t=t||{},this.defaultCondition_=function(e){return Yo(e)&&Ko(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==Bi.DOWN||r==Bi.LEFT||r==Bi.RIGHT||r==Bi.UP)){let o=t.map.getView(),a=o.getResolution()*this.pixelDelta_,l=0,h=0;r==Bi.DOWN?h=-a:r==Bi.LEFT?l=-a:r==Bi.RIGHT?l=a:h=a;let c=[l,h];zn(c,o.getRotation()),yg(o,c,this.duration_),i.preventDefault(),e=!0}}return!e}},Ag=Yc;var Kc=class extends $e{constructor(t){super(),t=t||{},this.condition_=t.condition?t.condition:function(e){return!Cg(e)&&Ko(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();ur(a,o,void 0,this.duration_),i.preventDefault(),e=!0}}return!e}},Mg=Kc;var z_=40,G_=300,X_=3,Zc=class extends $e{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:wg;this.condition_=t.onFocusOnly?ls(Wo,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*=z_;break;case WheelEvent.DOM_DELTA_PAGE:o*=G_;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*X_),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),ur(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)}},Pg=Zc;var Bc=class extends Je{constructor(t){t=t||{};let e=t;e.stopDown||(e.stopDown=ci),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!==cr&&(this.anchor_=o.getCoordinateFromPixelInternal(o.getEventPixel(dr(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}},Og=Bc;var Vc=class extends Je{constructor(t){t=t||{};let e=t;e.stopDown||(e.stopDown=ci),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(dr(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}},Dg=Vc;function Bo(n){n=n||{};let t=new Dt,e=new _g(-.005,.05,100);return(n.altShiftDragRotate===void 0||n.altShiftDragRotate)&&t.push(new Tg),(n.doubleClickZoom===void 0||n.doubleClickZoom)&&t.push(new xg({delta:n.zoomDelta,duration:n.zoomDuration})),(n.dragPan===void 0||n.dragPan)&&t.push(new Rg({onFocusOnly:n.onFocusOnly,kinetic:e})),(n.pinchRotate===void 0||n.pinchRotate)&&t.push(new Og),(n.pinchZoom===void 0||n.pinchZoom)&&t.push(new Dg({duration:n.zoomDuration})),(n.keyboard===void 0||n.keyboard)&&(t.push(new Ag),t.push(new Mg({delta:n.zoomDelta,duration:n.zoomDuration}))),(n.mouseWheelZoom===void 0||n.mouseWheelZoom)&&t.push(new Pg({onFocusOnly:n.onFocusOnly,duration:n.zoomDuration})),(n.shiftDragZoom===void 0||n.shiftDragZoom)&&t.push(new Lg({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 jc=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,B(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){B(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()}},Vo=jc;var Vi={ADDLAYER:"addlayer",REMOVELAYER:"removelayer"},Le=class extends Lt{constructor(t,e){super(t),this.layer=e}},Hc={LAYERS:"layers"},qc=class n extends Vo{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(Hc.LAYERS,this.handleLayersChanged_),i?Array.isArray(i)?i=new Dt(i.slice(),{unique:!0}):B(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);Xe(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 Le(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 Le(Vi.ADDLAYER,t.layer))}handleLayerGroupRemove_(t){this.dispatchEvent(new Le(Vi.REMOVELAYER,t.layer))}handleLayersAdd_(t){let e=t.element;this.registerLayerListeners_(e),this.dispatchEvent(new Le(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 Le(Vi.REMOVELAYER,e)),this.changed()}getLayers(){return this.get(Hc.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 Le(Vi.REMOVELAYER,i[r]))}this.set(Hc.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=Ne(l.extent,r.extent):l.extent=r.extent),l.zIndex===void 0&&(l.zIndex=s)}return e}getSourceState(){return"ready"}},cs=qc;var Ft={PRERENDER:"prerender",POSTRENDER:"postrender",PRECOMPOSE:"precompose",POSTCOMPOSE:"postcompose",RENDERCOMPLETE:"rendercomplete"};var $c=class extends Vo{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 hs(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);B(!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 hs(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=$c;function jo(n,t,e=0,i=n.length-1,r=W_){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));jo(n,t,g,m,r)}let s=n[t],o=e,a=i;for(us(n,e,t),r(n[i],s)>0&&us(n,e,i);o<a;){for(us(n,o,a),o++,a--;r(n[o],s)<0;)o++;for(;r(n[a],s)>0;)a--}r(n[e],s)===0?us(n,e,a):(a++,us(n,a,i)),a<=t&&(e=a+1),t<=a&&(i=a-1)}}function us(n,t,e){let i=n[t];n[t]=n[e],n[e]=i}function W_(n,t){return n<t?-1:n>t?1:0}var Tn=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(!qo(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;qo(t,l)&&(e.leaf?i.push(a):Qc(t,l)?this._all(a,i):s.push(a))}e=s.pop()}return i}collides(t){let e=this.data;if(!qo(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(qo(t,o)){if(e.leaf||Qc(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=mr([]),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=U_(t,i.children,e);if(c!==-1)return i.children.splice(c,1),s.push(i),this._condense(s),this}!h&&!i.leaf&&Qc(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=mr(t.slice(e,i+1)),gr(a,this.toBBox),a;r||(r=Math.ceil(Math.log(s)/Math.log(o)),o=Math.ceil(s/Math.pow(o,r-1))),a=mr([]),a.leaf=!1,a.height=r;let l=Math.ceil(s/o),h=l*Math.ceil(Math.sqrt(o));kg(t,e,i,h,this.compareMinX);for(let c=e;c<=i;c+=h){let d=Math.min(c+h-1,i);kg(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 gr(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=Jc(h),d=Z_(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),fs(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=mr(i.children.splice(o,i.children.length-o));a.height=i.height,a.leaf=i.leaf,gr(i,this.toBBox),gr(a,this.toBBox),e?t[e-1].children.push(a):this._splitRoot(i,a)}_splitRoot(t,e){this.data=mr([t,e]),this.data.height=t.height+1,this.data.leaf=!1,gr(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=ds(t,0,a,this.toBBox),h=ds(t,a,i,this.toBBox),c=B_(l,h),d=Jc(l)+Jc(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:Y_,s=t.leaf?this.compareMinY:K_,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=ds(t,0,e,s),a=ds(t,i-e,i,s),l=Ho(o)+Ho(a);for(let h=e;h<i-e;h++){let c=t.children[h];fs(o,t.leaf?s(c):c),l+=Ho(o)}for(let h=i-e-1;h>=e;h--){let c=t.children[h];fs(a,t.leaf?s(c):c),l+=Ho(a)}return l}_adjustParentBBoxes(t,e,i){for(let r=i;r>=0;r--)fs(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():gr(t[e],this.toBBox)}};function U_(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 gr(n,t){ds(n,0,n.children.length,t,n)}function ds(n,t,e,i,r){r||(r=mr(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];fs(r,n.leaf?i(o):o)}return r}function fs(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 Y_(n,t){return n.minX-t.minX}function K_(n,t){return n.minY-t.minY}function Jc(n){return(n.maxX-n.minX)*(n.maxY-n.minY)}function Ho(n){return n.maxX-n.minX+(n.maxY-n.minY)}function Z_(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 Qc(n,t){return n.minX<=t.minX&&n.minY<=t.minY&&t.maxX<=n.maxX&&t.maxY<=n.maxY}function qo(n,t){return t.minX<=n.maxX&&t.minY<=n.maxY&&t.maxX>=n.minX&&t.maxY>=n.minY}function mr(n){return{children:n,height:1,leaf:!0,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0}}function kg(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;jo(n,o,t,e,r),s.push(t,o,o,e)}}var bn=0,Jo=0,Ut=1<<bn++,Q=1<<bn++,Yt=1<<bn++,Zt=1<<bn++,Ei=1<<bn++,In=1<<bn++,Qo=Math.pow(2,bn)-1,eh={[Ut]:"boolean",[Q]:"number",[Yt]:"string",[Zt]:"color",[Ei]:"number[]",[In]:"size"},V_=Object.keys(eh).map(Number).sort(Vt);function j_(n){return n in eh}function xi(n){let t=[];for(let e of V_)gs(n,e)&&t.push(eh[e]);return t.length===0?"untyped":t.length<3?t.join(" or "):t.slice(0,-1).join(", ")+", or "+t[t.length-1]}function gs(n,t){return(n&t)===t}function $o(n,t){return!!(n&t)}function ji(n,t){return n===t}var ft=class{constructor(t,e){if(!j_(t))throw new Error(`literal expressions must have a specific type, got ${xi(t)}`);this.type=t,this.value=e}},ta=class{constructor(t,e,...i){this.type=t,this.operator=e,this.args=i}};function ea(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(ji(t,Yt))return new ft(Yt,n?"true":"false");if(!gs(t,Ut))throw new Error(`got a boolean, but expected ${xi(t)}`);return new ft(Ut,n)}case"number":{if(ji(t,In))return new ft(In,mt(n));if(ji(t,Ut))return new ft(Ut,!!n);if(ji(t,Yt))return new ft(Yt,n.toString());if(!gs(t,Q))throw new Error(`got a number, but expected ${xi(t)}`);return new ft(Q,n)}case"string":{if(ji(t,Zt))return new ft(Zt,Jr(n));if(ji(t,Ut))return new ft(Ut,!!n);if(!gs(t,Yt))throw new Error(`got a string, but expected ${xi(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 oy(n,t,e);for(let i of n)if(typeof i!="number")throw new Error("expected an array of numbers");if(ji(t,In)){if(n.length!==2)throw new Error(`expected an array of two values for a size, got ${n.length}`);return new ft(In,n)}if(ji(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(!gs(t,Ei))throw new Error(`got an array of numbers, but expected ${xi(t)}`);return new ft(Ei,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"},H_={[S.Get]:K(q(1,1/0),Fg),[S.Var]:q_(),[S.Has]:K(q(1,1/0),Fg),[S.Id]:K($_,pr),[S.Concat]:K(q(2,1/0),st(Yt)),[S.GeometryType]:K(J_,pr),[S.LineMetric]:K(Q_,pr),[S.Resolution]:K(th,pr),[S.Zoom]:K(th,pr),[S.Time]:K(th,pr),[S.Any]:K(q(2,1/0),st(Ut)),[S.All]:K(q(2,1/0),st(Ut)),[S.Not]:K(q(1,1),st(Ut)),[S.Equal]:K(q(2,2),zg()),[S.NotEqual]:K(q(2,2),zg()),[S.GreaterThan]:K(q(2,2),st(Q)),[S.GreaterThanOrEqualTo]:K(q(2,2),st(Q)),[S.LessThan]:K(q(2,2),st(Q)),[S.LessThanOrEqualTo]:K(q(2,2),st(Q)),[S.Multiply]:K(q(2,1/0),Ng),[S.Coalesce]:K(q(2,1/0),Ng),[S.Divide]:K(q(2,2),st(Q)),[S.Add]:K(q(2,1/0),st(Q)),[S.Subtract]:K(q(2,2),st(Q)),[S.Clamp]:K(q(3,3),st(Q)),[S.Mod]:K(q(2,2),st(Q)),[S.Pow]:K(q(2,2),st(Q)),[S.Abs]:K(q(1,1),st(Q)),[S.Floor]:K(q(1,1),st(Q)),[S.Ceil]:K(q(1,1),st(Q)),[S.Round]:K(q(1,1),st(Q)),[S.Sin]:K(q(1,1),st(Q)),[S.Cos]:K(q(1,1),st(Q)),[S.Atan]:K(q(1,2),st(Q)),[S.Sqrt]:K(q(1,1),st(Q)),[S.Match]:K(q(4,1/0),Gg,ey),[S.Between]:K(q(3,3),st(Q)),[S.Interpolate]:K(q(6,1/0),Gg,iy),[S.Case]:K(q(3,1/0),ty,ny),[S.In]:K(q(2,2),ry),[S.Number]:K(q(1,1/0),st(Qo)),[S.String]:K(q(1,1/0),st(Qo)),[S.Array]:K(q(1,1/0),st(Q)),[S.Color]:K(q(1,4),st(Q)),[S.Band]:K(q(1,3),st(Q)),[S.Palette]:K(q(2,2),sy),[S.ToString]:K(q(1,1),st(Ut|Q|Yt|Zt))};function Fg(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 q_(){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,Qo,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"&&$o(r,Zt)&&!$o(r,Yt)?a=Zt:Array.isArray(s)&&s.length===2&&$o(r,In)&&!$o(r,Ei)&&(a=In),r&=a,r===Jo)throw new Error(`the type expected from the var operator (${xi(t)}) did not have any overlap with the type of the corresponding style variables (${xi(a)}), variable name: ${i}`)}if(e.variables.has(i)){let o=e.variables.get(i);if(r&=o,r===Jo)throw new Error(`a new type expected from the var operator (${xi(t)}) did not have any overlap with the previous type expected for it (${xi(o)}), variable name: ${i}`)}return e.variables.set(i,r),new ta(r,"var",new ft(Yt,i))}}function $_(n,t,e){e.featureId=!0}function J_(n,t,e){e.geometryType=!0}function Q_(n,t,e){e.mCoordinate=!0}function th(n,t,e){e.mapState=!0}function pr(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 Ng(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 zg(){return function(n,t,e){let i=n[0],r=n.length-1,s=new Array(r),o=Qo;for(let a=0;a<r;++a){let l=_t(n[a+1],o,e);o&=l.type}if(o===Jo)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 ty(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 Gg(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 ey(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===Jo)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 iy(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 ny(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 ry(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 sy(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 K(...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 ta(e,r,...s)}}function oy(n,t,e){let i=n[0],r=H_[i];if(!r)throw new Error(`unknown operator: ${i}`);return r(n,t,e)}function ia(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 ia(n.getGeometries()[0]);default:return""}}function ih(){return{variables:{},properties:{},resolution:NaN,featureId:null,geometryType:""}}function Me(n,t,e){let i=_t(n,t,e);return Ae(i,e)}function Ae(n,t){if(n instanceof ft){if(n.type===Zt&&typeof n.value=="string"){let i=Jr(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 ay(n,t);case S.Get:case S.Var:case S.Has:return ly(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=>Ae(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 hy(n,t);case S.Equal:case S.NotEqual:case S.LessThan:case S.LessThanOrEqualTo:case S.GreaterThan:case S.GreaterThanOrEqualTo:return cy(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 uy(n,t);case S.Case:return dy(n,t);case S.Match:return fy(n,t);case S.Interpolate:return gy(n,t);case S.ToString:return my(n,t);default:throw new Error(`Unsupported operator ${e}`)}}function ay(n,t){let e=n.operator,i=n.args.length,r=new Array(i);for(let s=0;s<i;++s)r[s]=Ae(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 ly(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 cy(n,t){let e=n.operator,i=Ae(n.args[0],t),r=Ae(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 hy(n,t){let e=n.operator,i=n.args.length,r=new Array(i);for(let s=0;s<i;++s)r[s]=Ae(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 uy(n,t){let e=n.operator,i=n.args.length,r=new Array(i);for(let s=0;s<i;++s)r[s]=Ae(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 dy(n,t){let e=n.args.length,i=new Array(e);for(let r=0;r<e;++r)i[r]=Ae(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 fy(n,t){let e=n.args.length,i=new Array(e);for(let r=0;r<e;++r)i[r]=Ae(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 gy(n,t){let e=n.args.length,i=new Array(e);for(let r=0;r<e;++r)i[r]=Ae(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=uf(d)),c>=o)return h===2?d:f?py(s,o,a,l,c,d):ms(s,o,a,l,c,d);a=c,l=d}return l}}function my(n,t){let e=n.operator,i=n.args.length,r=new Array(i);for(let s=0;s<i;++s)r[s]=Ae(n.args[s],t);if(e===S.ToString)return s=>{let o=r[0](s);return n.args[0].type===Zt?Qr(o):o.toString()};throw new Error(`Unsupported convert operator ${e}`)}function ms(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 py(n,t,e,i,r,s){if(r-e===0)return i;let a=Yl(i),l=Yl(s),h=l[2]-a[2];h>180?h-=360:h<-180&&(h+=360);let c=[ms(n,t,e,a[0],r,l[0]),ms(n,t,e,a[1],r,l[1]),a[2]+ms(n,t,e,0,r,h),ms(n,t,e,i[3],r,s[3])];return df(c)}function _y(n){return!0}function yy(n,t){t=t??ea();let e=xy(n,t),i=ih();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=ia(r.getGeometry())),e(i)}}function Xg(n,t){t=t??ea();let e=n.length,i=new Array(e);for(let o=0;o<e;++o)i[o]=nh(n[o],t);let r=ih(),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=ia(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 Kg(n,t){if(t=t??ea(),!Array.isArray(n))return Xg([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 yy(s,t)}return Xg(n,t)}function xy(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?Me(s.filter,Ut,t):_y,a;if(Array.isArray(s.style)){let l=s.style.length;a=new Array(l);for(let h=0;h<l;++h)a[h]=nh(s.style[h],t)}else a=[nh(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 nh(n,t){let e=ps(n,"",t),i=_s(n,"",t),r=Ey(n,t),s=wy(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 ps(n,t,e){let i;if(t+"fill-pattern-src"in n)i=Ry(n,t+"fill-",e);else{if(n[t+"fill-color"]==="none")return s=>null;i=ra(n,t+"fill-color",e)}if(!i)return null;let r=new pt;return function(s){let o=i(s);return o===So?null:(r.setColor(o),r)}}function _s(n,t,e){let i=Nt(n,t+"stroke-width",e),r=ra(n,t+"stroke-color",e);if(!i&&!r)return null;let s=wi(n,t+"stroke-line-cap",e),o=wi(n,t+"stroke-line-join",e),a=Zg(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===So)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 Ey(n,t){let e="text-",i=wi(n,e+"value",t);if(!i)return null;let r=ps(n,e,t),s=ps(n,e+"background-",t),o=_s(n,e,t),a=_s(n,e+"background-",t),l=wi(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=_r(n,e+"overflow",t),g=wi(n,e+"placement",t),m=Nt(n,e+"repeat",t),_=sa(n,e+"scale",t),p=_r(n,e+"rotate-with-view",t),y=Nt(n,e+"rotation",t),E=wi(n,e+"align",t),v=wi(n,e+"justify",t),x=wi(n,e+"baseline",t),C=_r(n,e+"keep-upright",t),T=Zg(n,e+"padding",t),A=oa(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(v){let b=v(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)),C&&R.setKeepUpright(C(I)),R}}function wy(n,t){return"icon-src"in n?Cy(n,t):"shape-points"in n?vy(n,t):"circle-radius"in n?Sy(n,t):null}function Cy(n,t){let e="icon-",i=e+"src",r=Bg(n[i],i),s=na(n,e+"anchor",t),o=sa(n,e+"scale",t),a=Nt(n,e+"opacity",t),l=na(n,e+"displacement",t),h=Nt(n,e+"rotation",t),c=_r(n,e+"rotate-with-view",t),d=Ug(n,e+"anchor-origin"),f=Yg(n,e+"anchor-x-units"),g=Yg(n,e+"anchor-y-units"),m=Ci(n,e+"color"),_,p=null;m!==void 0&&(Array.isArray(m)&&m.length>0&&typeof m[0]=="string"?p=ra(n,e+"color",t):_=Vg(m,e+"color"));let y=Iy(n,e+"cross-origin"),E=by(n,e+"offset"),v=Ug(n,e+"offset-origin"),x=rh(n,e+"width"),C=rh(n,e+"height"),T=Ty(n,e+"size"),A=oa(n,e+"declutter-mode"),R={src:r,anchorOrigin:d,anchorXUnits:f,anchorYUnits:g,crossOrigin:y,offset:E,offsetOrigin:v,height:C,width:x,size:T,declutterMode:A},I=null;return function(b){if(I)p&&I.setColor(p(b));else{let z=p?p(b):_;I=new wn(z!==void 0?Object.assign({},R,{color:z}):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 vy(n,t){let e="shape-",i=e+"points",r=e+"radius",s=sh(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=ps(n,e,t),f=_s(n,e,t),g=sa(n,e+"scale",t),m=na(n,e+"displacement",t),_=Nt(n,e+"rotation",t),p=_r(n,e+"rotate-with-view",t),y=rh(n,e+"angle"),E=oa(n,e+"declutter-mode"),v=new Ao({points:s,radius:a,radius2:c,angle:y,declutterMode:E});return function(x){return o&&v.setRadius(o(x)),h&&v.setRadius2(h(x)),d&&v.setFill(d(x)),f&&v.setStroke(f(x)),m&&v.setDisplacement(m(x)),_&&v.setRotation(_(x)),p&&v.setRotateWithView(p(x)),g&&v.setScale(g(x)),v}}function Sy(n,t){let e="circle-",i=ps(n,e,t),r=_s(n,e,t),s=Nt(n,e+"radius",t),o=sa(n,e+"scale",t),a=na(n,e+"displacement",t),l=Nt(n,e+"rotation",t),h=_r(n,e+"rotate-with-view",t),c=oa(n,e+"declutter-mode"),d=new Mo({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 Ci(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=Ci(n,t);if(i===void 0)return;let r=Me(i,Q,e);return function(s){return sh(r(s),t)}}function wi(n,t,e){let i=Ci(n,t);if(i===void 0)return null;let r=Me(i,Yt,e);return function(s){return Bg(r(s),t)}}function Ry(n,t,e){let i=wi(n,t+"pattern-src",e),r=Wg(n,t+"pattern-offset",e),s=Wg(n,t+"pattern-size",e),o=ra(n,t+"color",e);return function(a){return{src:i(a),offset:r&&r(a),size:s&&s(a),color:o&&o(a)}}}function _r(n,t,e){let i=Ci(n,t);if(i===void 0)return null;let r=Me(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 ra(n,t,e){let i=Ci(n,t);if(i===void 0)return null;let r=Me(i,Zt,e);return function(s){return Vg(r(s),t)}}function Zg(n,t,e){let i=Ci(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=Me(o,Q,e);return function(h){return sh(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=Me(i,Ei,e);return function(s){return ys(r(s),t)}}function na(n,t,e){let i=Ci(n,t);if(i===void 0)return null;let r=Me(i,Ei,e);return function(s){let o=ys(r(s),t);if(o.length!==2)throw new Error(`Expected two numbers for ${t}`);return o}}function Wg(n,t,e){let i=Ci(n,t);if(i===void 0)return null;let r=Me(i,Ei,e);return function(s){return jg(r(s),t)}}function sa(n,t,e){let i=Ci(n,t);if(i===void 0)return null;let r=Me(i,Ei|Q,e);return function(s){return Ly(r(s),t)}}function rh(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 Ty(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 Iy(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 Ug(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 Yg(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 by(n,t){let e=n[t];if(e!==void 0)return ys(e,t)}function oa(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 ys(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 Bg(n,t){if(typeof n!="string")throw new Error(`Expected a string for ${t}`);return n}function sh(n,t){if(typeof n!="number")throw new Error(`Expected a number for ${t}`);return n}function Vg(n,t){if(typeof n=="string")return n;let e=ys(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 jg(n,t){let e=ys(n,t);if(e.length!==2)throw new Error(`Expected an array of two numbers for ${t}`);return e}function Ly(n,t){return typeof n=="number"?n:jg(n,t)}var Hg={RENDER_ORDER:"renderOrder"},oh=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(Hg.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 Tn(9)),this.getRenderer().renderDeclutter(t,e)}setRenderOrder(t){this.set(Hg.RENDER_ORDER,t)}setStyle(t){this.style_=t===void 0?ic:t;let e=Ay(t);this.styleFunction_=t===null?void 0:Sf(e),this.changed()}setDeclutter(t){this.declutter_=t?String(t):void 0,this.changed()}};function Ay(n){if(n===void 0)return ic;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 Kg(n)}var aa=oh;var ah=class extends Lt{constructor(t,e,i,r){super(t),this.inversePixelTransform=e,this.frameState=i,this.context=r}},la=ah;var lh=class extends ki{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]),so(r,i)}forEachFeatureAtCoordinate(t,e,i,r,s,o,a,l){let h,c=e.viewState;function d(x,C,T,A){return s.call(o,C,x?T:null,A)}let f=c.projection,g=Ws(t.slice(),f),m=[[0,0]];if(f.canWrapX()&&r){let x=f.getExtent(),C=j(x);m.push([-C,0],[C,0])}let _=e.layerStatesArray,p=_.length,y=[],E=[];for(let x=0;x<m.length;x++)for(let C=p-1;C>=0;--C){let T=_[C],A=T.layer;if(A.hasRenderer()&&hs(T,c)&&a.call(l,A)){let R=A.getRenderer(),I=A.getSource();if(R&&I){let b=I.getWrapX()?g:t,z=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,z,y)}if(h)return h}}if(y.length===0)return;let v=1/y.length;return y.forEach((x,C)=>x.distanceSq+=C*v),y.sort((x,C)=>x.distanceSq-C.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,li,this,s,o)!==void 0}getMap(){return this.map_}renderFrame(t){H()}scheduleExpireIconCache(t){Xt.canExpireCache()&&t.postRenderFunctions.push(My)}};function My(n,t){Xt.expire()}var qg=lh;var ch=class extends qg{constructor(t){super(t),this.fontChangeListenerKey_=Z(xn,Se.PROPERTYCHANGE,t.redrawText,t),this.element_=Rt?io():document.createElement("div");let e=this.element_.style;e.position="absolute",e.width="100%",e.height="100%",e.zIndex="0",this.element_.className=Yi+" 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 la(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 aa&&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(!hs(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),pd(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(...ro(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))}}},$g=ch;function Jg(n){if(n instanceof Rn){n.setMapInternal(null);return}n instanceof cs&&n.getLayers().forEach(Jg)}function Qg(n,t){if(n instanceof Rn){n.setMapInternal(t);return}if(n instanceof cs){let e=n.getLayers().getArray();for(let i=0,r=e.length;i<r;++i)Qg(e[i],t)}}var hh=class extends wt{constructor(t){super(),t=t||{},this.on,this.once,this.un;let e=Py(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:hd,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:Xo()),this.interactions=e.interactions||(Rt?new Dt:Bo({onFocusOnly:!0})),this.overlays_=e.overlays,this.overlayIdIndex_={},this.renderer_=null,this.postRenderFunctions_=[],this.tileQueue_=new ag(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){Qg(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:li,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 cs?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:li,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 Fr(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 lg(this.frameState_,t,e,i,r)}handleBrowserEvent(t,e){e=e||t.type;let i=new He(e,this,t);this.handleMapBrowserEvent(i)}handleMapBrowserEvent(t){if(!this.frameState_)return;let e=t.originalEvent,i=e.type;if(i===os.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 Zi(qe.LOADEND,this,t)))):this.loaded_===!0&&(this.loaded_=!1,this.dispatchEvent(new Zi(qe.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 $g(this)),!te(e)){this.mapBrowserEventHandler_=new sg(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_,eo?{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 Le("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){Jg(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&&Ka(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:Pr(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=Pr(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_||!ze(this.previousExtent_)&&!on(s.extent,this.previousExtent_))&&(this.dispatchEvent(new Zi(qe.MOVESTART,this,r)),this.previousExtent_=sn(this.previousExtent_)),this.previousExtent_&&!s.viewHints[bt.ANIMATING]&&!s.viewHints[bt.INTERACTING]&&!on(s.extent,this.previousExtent_)&&(this.dispatchEvent(new Zi(qe.MOVEEND,this,s)),Os(s.extent,this.previousExtent_))),this.dispatchEvent(new Zi(qe.POSTRENDER,this,s)),this.renderComplete_=(this.hasListener(qe.LOADSTART)||this.hasListener(qe.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 Le("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)],!Ka(e)&&(t.offsetWidth||t.offsetHeight||t.getClientRects().length)&&zs("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 Py(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 cs({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()):(B(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()):(B(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()):(B(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 tm=hh;function ca(n){return n instanceof Image||n instanceof HTMLCanvasElement||n instanceof HTMLVideoElement||n instanceof ImageBitmap?n:null}var Oy=new Error("disposed");var Dy=[256,256],uh=class extends qn{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=ca(this.data_);return t?[t.width,t.height]:Dy}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(Oy),this.controller_=null),super.disposeInternal()}},dh=uh;var fh=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 ki&&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 B(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 B(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){B(!(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}},gh=fh;var mh=class{constructor(){this.instructions_=[],this.zIndex=0,this.offset_=0,this.pendingMethod_,this.context_=new Proxy(Gr(),{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}},ha=mh;var ky=5,ph=class extends ao{constructor(t){super(),this.ready=!0,this.boundHandleImageChange_=this.handleImageChange_.bind(this),this.layer_=t,this.staleKeys_=new Array,this.maxStaleKeys=ky,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()}},em=ph;var yh=[],yr=null;function Fy(){yr=nt(1,1,void 0,{willReadFrequently:!0})}var _h=class extends em{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){yr||Fy(),yr.clearRect(0,0,1,1);let r;try{yr.drawImage(t,e,i,1,1,0,0,1,1),r=yr.getImageData(0,0,1,1).data}catch{return yr=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(de(t.style.backgroundColor),de(i)))){let h=t.firstElementChild;te(h)&&(l=h.getContext("2d"))}if(l&&vd(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?io():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=le(i),s=Nn(i),o=Fn(i),a=kn(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),so(this.inversePixelTransform,this.pixelTransform);let h=Cd(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 la(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 ha),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()}},ua=_h;function xh(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 Ny(n,t,e){let i=n[e];return i?i.delete(t):!1}function im(n,t){let e=n.layerStatesArray[n.layerIndex];e.extent&&(t=Ne(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=Ne(t,r))}return t}var Eh=class extends ua{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 qs(0,0,0,0),this.tempTileCoord_=Bn(0,0,0);let i=e.cacheSize!==void 0?e.cacheSize:512;this.tileCache_=new gh(i),this.sourceTileCache_=null,this.layerExtent=null,this.maxStaleKeys=i*.5}getTileCache(){return this.tileCache_}getSourceTileCache(){return this.sourceTileCache_||(this.sourceTileCache_=new gh(512)),this.sourceTileCache_}getOrCreateTile(t,e,i,r){let s=this.tileCache_,a=this.getLayer().getSource(),l=Vn(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||Yn(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 no||f instanceof oo)p=f.getImage();else if(f instanceof dh){if(p=ca(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])),v=Math.round(h*a.getGutterForProjection(o.projection));return this.getImageData(p,y+v,E+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,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?La(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 v=y.minX;v<=y.maxX;++v)for(let x=y.minY;x<=y.maxY;++x){if(m&&!h.tileCoordIntersectsViewport([p,v,x],_))continue;let C=this.getTile(p,v,x,t);if(!C||!xh(r,C,p))continue;let A=C.getKey();if(d[A]=!0,C.getState()===D.IDLE&&!t.tileQueue.isKeyQueued(A)){let R=Bn(p,v,x,this.tempTileCoord_);t.tileQueue.enqueue([C,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=Vn(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)),xh(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=Vn(l,h,i,c,d),g=!1;if(a.containsKey(f)){let m=a.peek(f);m.getState()===D.LOADED&&(xh(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=Ne(m,this.layerExtent));let E=g*p/2/_,v=g*y/2/_,x=[a[0]-E,a[1]-v,a[0]+E,a[1]+v],C={};this.renderedTiles.length=0;let T=h.getPreload();if(t.nextExtent&&this.enqueueTilesForNextExtent()){let M=d.getZForResolution(r.nextResolution,c.zDirection),W=im(t,t.nextExtent);this.enqueueTiles(t,W,M,C,T)}let A=im(t,m);if(this.enqueueTiles(t,A,f,C,0),T>0&&setTimeout(()=>{this.enqueueTiles(t,A,f-1,C,T-1)},0),!(f in C))return this.container;let R=Y(this),I=t.time;for(let M of C[f]){let W=M.getState();if(W===D.EMPTY)continue;let O=M.tileCoord;if(W===D.LOADED&&M.getAlpha(R,I)===1){M.endTransition(R);continue}if(W!==D.ERROR&&(this.renderComplete=!1),this.findStaleTile_(O,C)){Ny(C,M,f),t.animate=!0;continue}if(this.findAltTiles_(d,O,f+1,C))continue;let tt=d.getMinZoom();for(let it=f-1;it>=tt&&!this.findAltTiles_(d,O,it,C);--it);}let b=g/o*l/_,z=this.getRenderContext(t);Ot(this.tempTransform,p/2,y/2,b,b,0,-p/2,-y/2),this.layerExtent&&this.clipUnrotated(z,t,this.layerExtent),c.getInterpolate()||(z.imageSmoothingEnabled=!1),this.preRender(z,t);let X=Object.keys(C).map(Number);X.sort(Vt);let N=[],V=[],lt=[];for(let M=X.length-1;M>=0;--M){let W=X[M],O=c.getTilePixelSize(W,l,s),G=d.getResolution(W)/g,tt=O[0]*G*b,it=O[1]*G*b,Ct=d.getTileCoordForCoordAndZ(le(x),W),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 C[W]){if(ot.getState()!==D.LOADED)continue;let Oe=ot.tileCoord,Ji=Ct[1]-Oe[1],re=Math.round(Jt[0]-(Ji-1)*tt),wr=Ct[2]-Oe[2],Ts=Math.round(Jt[1]-(wr-1)*it),Qi=Math.round(Jt[0]-Ji*tt),tn=Math.round(Jt[1]-wr*it),An=re-Qi,ii=Ts-tn,Mn=W===f;if(Mn&&ot.inTransition(R)){lt.push({tile:ot,x:Qi,y:tn,w:An,h:ii,gutter:vt}),this.renderedTiles.unshift(ot),this.updateUsedTiles(t.usedTiles,c,ot);continue}let Cr=[Qi,tn,Qi+An,tn+ii],vr=[];for(let Ii=0,Sr=N.length;Ii<Sr;++Ii)W<V[Ii]&&ht(Cr,N[Ii])&&vr.push(N[Ii]);let Is;vr.length>0&&(Is=yu(Cr,vr)),N.push(Cr),V.push(W),this.drawTile(ot,t,Qi,tn,An,ii,vt,Mn,Is),this.renderedTiles.unshift(ot),this.updateUsedTiles(t.usedTiles,c,ot)}}for(let M=0,W=lt.length;M<W;++M){let{tile:O,x:$,y:G,w:tt,h:it,gutter:Ct}=lt[M];this.drawTile(O,t,$,G,tt,it,Ct,!0,void 0)}if(this.renderedResolution=g,this.extentChanged=!this.renderedExtent_||!on(this.renderedExtent_,x),this.renderedExtent_=x,this.renderedPixelRatio=l,this.postRender(this.context,t),this.layerExtent&&z.restore(),z.imageSmoothingEnabled=!0,this.renderComplete){let M=(W,O)=>{let $=Y(c),G=O.wantedTiles[$],tt=G?Object.keys(G).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 dh){if(c=ca(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,v=y/o;for(let x=0,C=h.length;x<C;++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)*v,I*E,b*v,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}},nm=Eh;var xs={PRELOAD:"preload",USE_INTERIM_TILES_ON_ERROR:"useInterimTilesOnError"};var wh=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(xs.PRELOAD)}setPreload(t){this.set(xs.PRELOAD,t)}getUseInterimTilesOnError(){return this.get(xs.USE_INTERIM_TILES_ON_ERROR)}setUseInterimTilesOnError(t){this.set(xs.USE_INTERIM_TILES_ON_ERROR,t)}getData(t){return super.getData(t)}},rm=wh;var Ch=class extends rm{constructor(t){super(t)}createRenderer(){return new nm(this,{cacheSize:this.getCacheSize()})}},vh=Ch;var Sh=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){}},da=Sh;var Es={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},ws=[Es.FILL],Qe=[Es.STROKE],vi=[Es.BEGIN_PATH],Rh=[Es.CLOSE_PATH],F=Es;var Th=class extends da{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=Ps(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([F.CUSTOM,l,f,t,i,Wr,s]),this.hitDetectionInstructions.push([F.CUSTOM,l,f,t,r||i,Wr,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([F.CUSTOM,l,d,t,i,tr,s]),this.hitDetectionInstructions.push([F.CUSTOM,l,d,t,r||i,tr,s]);break;case"LineString":case"Circle":h=t.getFlatCoordinates(),c=this.appendFlatLineCoordinates(h,0,h.length,a,!1,!1),this.instructions.push([F.CUSTOM,l,c,t,i,Ue,s]),this.hitDetectionInstructions.push([F.CUSTOM,l,c,t,r||i,Ue,s]);break;case"MultiPoint":h=t.getFlatCoordinates(),c=this.appendFlatPointCoordinates(h,a),c>l&&(this.instructions.push([F.CUSTOM,l,c,t,i,Ue,s]),this.hitDetectionInstructions.push([F.CUSTOM,l,c,t,r||i,Ue,s]));break;case"Point":h=t.getFlatCoordinates(),this.coordinates.push(h[0],h[1]),c=this.coordinates.length,this.instructions.push([F.CUSTOM,l,c,t,i,void 0,s]),this.hitDetectionInstructions.push([F.CUSTOM,l,c,t,r||i,void 0,s]);break;default:}this.endGeometry(e)}beginGeometry(t,e,i){this.beginGeometryInstruction1_=[F.BEGIN_GEOMETRY,e,0,t,i],this.instructions.push(this.beginGeometryInstruction1_),this.beginGeometryInstruction2_=[F.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==F.END_GEOMETRY?o=e:s==F.BEGIN_GEOMETRY&&(r[2]=e,qu(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:Ve;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:je;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??pf,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=[F.SET_FILL_STYLE,e];return typeof e!="string"&&i.push(t.fillPatternScale),i}applyStroke(t){this.instructions.push(this.createStroke(t))}createStroke(t){return[F.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=[F.END_GEOMETRY,t];this.instructions.push(e),this.hitDetectionInstructions.push(e)}getBufferedMaxExtent(){if(!this.bufferedMaxExtent_&&(this.bufferedMaxExtent_=Os(this.maxExtent),this.maxLineWidth>0)){let t=this.resolution*(this.maxLineWidth+1)/2;On(this.bufferedMaxExtent_,t,this.bufferedMaxExtent_)}return this.bufferedMaxExtent_}},ti=Th;var Ih=class extends ti{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([F.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([F.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([F.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([F.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}},sm=Ih;var bh=class extends ti{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([F.MOVE_TO_LINE_TO,o,a,s*this.pixelRatio]),this.hitDetectionInstructions.push([F.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([F.SET_STROKE_STYLE,Wt,r.lineWidth,r.lineCap,r.lineJoin,r.miterLimit,qt,$t],vi);let l=t.getFlatCoordinates(),h=t.getStride();this.drawFlatCoordinates_(l,0,l.length,h,a),this.hitDetectionInstructions.push(Qe),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([F.SET_STROKE_STYLE,Wt,r.lineWidth,r.lineCap,r.lineJoin,r.miterLimit,qt,$t],vi);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(Qe),this.endGeometry(e)}finish(){let t=this.state;return t.lastStroke!=null&&t.lastStroke!=this.coordinates.length&&this.instructions.push(Qe),this.reverseHitDetectionInstructions(),this.state=null,super.finish()}applyStroke(t){t.lastStroke!=null&&t.lastStroke!=this.coordinates.length&&(this.instructions.push(Qe),t.lastStroke=this.coordinates.length),t.lastStroke=0,super.applyStroke(t),this.instructions.push(vi)}},om=bh;var Lh=class extends ti{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(vi),this.hitDetectionInstructions.push(vi);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([F.MOVE_TO_LINE_TO,f,g,s*this.pixelRatio,!0]),this.hitDetectionInstructions.push([F.MOVE_TO_LINE_TO,f,g,s,!0]),l&&(this.instructions.push(Rh),this.hitDetectionInstructions.push(Rh)),e=d}return a&&(this.instructions.push(ws),this.hitDetectionInstructions.push(ws)),l&&(this.instructions.push(Qe),this.hitDetectionInstructions.push(Qe)),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([F.SET_FILL_STYLE,Tt]),r.strokeStyle!==void 0&&this.hitDetectionInstructions.push([F.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=[F.CIRCLE,c,a];this.instructions.push(vi,d),this.hitDetectionInstructions.push(vi,d),r.fillStyle!==void 0&&(this.instructions.push(ws),this.hitDetectionInstructions.push(ws)),r.strokeStyle!==void 0&&(this.instructions.push(Qe),this.hitDetectionInstructions.push(Qe)),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([F.SET_FILL_STYLE,Tt]),r.strokeStyle!==void 0&&this.hitDetectionInstructions.push([F.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([F.SET_FILL_STYLE,Tt]),r.strokeStyle!==void 0&&this.hitDetectionInstructions.push([F.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}},Ah=Lh;var Mh=0,Ph=1;function zy(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 Mh=c,Ph=d,!0}function am(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],v=!1;for(let x=g+e;x<p;x+=e){let C=n[x],T=n[x+1];if(zy(r,s,o,a,y,E,C,T)){let A=C-y,R=T-E,I=y+Mh*A,b=E+Mh*R,z=y+Ph*A,X=E+Ph*R;c&&v&&I===d&&b===f?l.push(z,X):(c&&h.push(l.length),l.push(I,b,z,X),c=!0),d=z,f=X,v=!0}y=C,E=T}g=p}return c&&h.push(l.length),{flatCoordinates:l,ends:h}}function lm(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 cm(n,t,e,i,r){let s=e,o=e,a=0,l=0,h=e,c,d,f,g,m,_,p,y,E,v;for(d=e;d<i;d+=r){let x=t[d],C=t[d+1];m!==void 0&&(E=x-m,v=C-_,g=Math.sqrt(E*E+v*v),p!==void 0&&(l+=f,c=Math.acos((p*E+y*v)/(f*g)),c>n&&(l>a&&(a=l,s=h,o=d),l=0,h=d-r)),f=g,p=E,y=v),m=x,_=C}return l+=g,l>a?[h,d]:[s,o]}var Cs={left:0,center:.5,right:1,top:0,middle:.5,hanging:.2,alphabetic:.8,ideographic:.8,bottom:1},Oh=class extends ti{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,v=y.length;E<v;++E)g.push(y[E][0])}if((h=="LineString"||h=="MultiLineString")&&!Fe(this.getBufferedMaxExtent(),f)){let y=am(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 v;m?v=lm(m*this.resolution,c,p,g[y],d):v=[c.slice(p,g[y])];for(let x=0,C=v.length;x<C;++x){let T=v[x],A=0,R=T.length;if(_==null){let b=cm(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 C=0,T=x.length;C<T;C+=3)o.overflow||f.push(x[C+2]/this.resolution),c.push(x[C],x[C+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((C,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],C=o.padding[1],T=o.padding[2],A=o.padding[3];o.scale[0]<0&&(C=-C,A=-A),o.scale[1]<0&&(x=-x,T=-T),p=[x,C,T,A]}let y=this.pixelRatio;this.instructions.push([F.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,v=m?m.slice(0):null;v&&(v[1]=Tt),this.hitDetectionInstructions.push([F.DRAW_IMAGE,l,g,null,NaN,NaN,NaN,1,0,0,this.textRotateWithView_,this.textRotation_,[E,E],NaN,this.declutterMode_,this.declutterImageWithText_,p,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 s=this.textKey_;s in this.textStates||(this.textStates[s]={font:e.font,textAlign:e.textAlign||Ki,justify:e.justify,textBaseline:e.textBaseline||En,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=Cs[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([F.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([F.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()||Ve,s.lineDash=_?_.slice():qt,s.lineDashOffset=p===void 0?$t:p,s.lineJoin=a.getLineJoin()||je,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()||bo;_f(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()||En,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}},hm=Oh;var Gy={Circle:Ah,Default:ti,Image:sm,LineString:om,Polygon:Ah,Text:hm},Dh=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=Gy[e];s=new o(this.tolerance_,this.maxExtent_,this.resolution_,this.pixelRatio_),r[e]=s}return s}},um=Dh;function dm(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 fa(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,v,x=0;for(let C=t;C<e;C+=i){m=f,_=g,p=void 0,y=void 0,C+i<e&&(p=n[C+i],y=n[C+i+1]),s&&C===t&&(m=c,_=d),s&&C===e-i&&(p=l,y=h),f=n[C],g=n[C+1],[E,v]=Xy(f,g,m,_,p,y,r),o[x++]=E,o[x++]=v;for(let T=2;T<a;T++)o[x++]=n[C+T]}return o.length!=x&&(o.length=x),o}function Xy(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=Ru([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 ga(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),v=l+p*(c-l);n[i+t]=E,n[i+t+1]=v,n.splice(i+2*t,o-i-t);break}}}return n}var kh;function Wy(){return kh||(kh=new Intl.Segmenter(void 0,{granularity:"grapheme"})),kh}function fm(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 v(){_=g,p=m,t+=i,g=n[t],m=n[t+1],E+=y,y=Math.sqrt((g-_)*(g-_)+(m-p)*(m-p))}do v();while(t<e-i&&E+y<s);let x=y===0?0:(s-E)/y,C=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;)v();x=y===0?0:(I-E)/y;let b=zt(_,g,x),z=zt(p,m,x),X=!1;if(f)if(d){let O=[C,T,b,z];fo(O,0,4,2,d,O,O),X=O[0]>O[2]}else X=C>b;let N=Math.PI,V=[],lt=A+i===t;t=A,y=0,E=R,g=n[t],m=n[t+1];let M;if(lt){v(),M=Math.atan2(m-p,g-_),X&&(M+=M>0?-N:N);let O=(b+C)/2,$=(z+T)/2;return V[0]=[O,$,(I-s)/2,M,r],V}r=r.replace(/\n/g," ");let W=Array.from(Wy().segment(r),O=>O.segment);for(let O=0,$=W.length;O<$;){v();let G=Math.atan2(m-p,g-_);if(X&&(G+=G>0?-N:N),M!==void 0){let vt=G-M;if(vt+=vt>N?-2*N:vt<-N?2*N:0,Math.abs(vt)>o)return null}M=G;let tt=O,it=0;for(;O<$;++O){let vt=X?$-O-1:O,ot=a*l(h,W[vt],c);if(t+i<e&&E+y<s+it+ot/2)break;it+=ot}if(O===tt)continue;let Ct=(X?W.slice($-O,$-tt):W.slice(tt,O)).join("");x=y===0?0:(s+it/2-E)/y;let L=zt(_,g,x),Jt=zt(p,m,x);V.push([L,Jt,it/2,G,Ct]),s+=it}return V}var xr=ut(),Hi=[],Si=[],Ri=[],qi=[];function gm(n){return n[3].declutterBox}var mm=new RegExp("[\u0591-\u08FF\uFB1D-\uFDFF\uFE70-\uFEFC\u0800-\u0FFF\uE800-\uEFFF]");function Fh(n,t){return t==="start"?t=mm.test(n)?"right":"left":t==="end"&&(t=mm.test(n)?"left":"right"),Cs[t]}function Uy(n,t,e){return e>0&&n.push(`7+`,""),n.push(t,""),n}function Yy(n,t,e){return e%2===0&&(n+=t),n}var Nh=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 ha: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?Cs[l.justify]:Fh(Array.isArray(t)?t[0]:t,l.textAlign||Ki),f=r&&o.lineWidth?o.lineWidth:0,g=Array.isArray(t)?t:String(t).split(`8+`).reduce(Uy,[]),{width:m,height:_,widths:p,heights:y,lineWidths:E}=Ef(l,g),v=m+f,x=[],C=(v+2)*c[0],T=(_+f)*c[1],A={width:C<0?Math.floor(C):Math.ceil(C),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*v+R*f,b=[],z=[],X=0,N=0,V=0,lt=0,M;for(let W=0,O=g.length;W<O;W+=2){let $=g[W];if($===`9+`){N+=X,X=0,I=d*v+R*f,++lt;continue}let G=g[W+1]||l.font;G!==M&&(r&&b.push("font",G),i&&z.push("font",G),M=G),X=Math.max(X,y[V]);let tt=[$,I+R*p[V]+d*(p[V]-E[lt]),.5*(f+X)+N];I+=p[V],r&&b.push("strokeText",tt),i&&z.push("fillText",tt),++V}return Array.prototype.push.apply(x,b),Array.prototype.push.apply(x,z),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,v=s+h>t?t-h:s,x=o+c>e?e-c:o,C=m[3]+v*f[0]+m[1],T=m[0]+x*f[1]+m[2],A=y-m[3],R=E-m[0];(_||d!==0)&&(Hi[0]=A,qi[0]=A,Hi[1]=R,Si[1]=R,Si[0]=A+C,Ri[0]=Si[0],Ri[1]=R+T,qi[1]=Ri[1]);let I;return d!==0?(I=Ot(At(),i,r,1,1,d,-i,-r),dt(I,Hi),dt(I,Si),dt(I,Ri),dt(I,qi),Qt(Math.min(Hi[0],Si[0],Ri[0],qi[0]),Math.min(Hi[1],Si[1],Ri[1],qi[1]),Math.max(Hi[0],Si[0],Ri[0],qi[0]),Math.max(Hi[1],Si[1],Ri[1],qi[1]),xr)):Qt(Math.min(A,A+C),Math.min(R,R+T),Math.max(A,A+C),Math.max(R,R+T),xr),g&&(y=Math.round(y),E=Math.round(E)),{drawImageX:y,drawImageY:E,drawImageW:v,drawImageH:x,originX:h,originY:c,declutterBox:{minX:xr[0],minY:xr[1],maxX:xr[2],maxY:xr[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,Hi,Si,Ri,qi,o,a),wf(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=Fh(Array.isArray(t)?t[0]:t,s.textAlign||Ki),c=Cs[s.textBaseline||En],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_),wd(this.renderedTransform_,i));let d=0,f=r.length,g=0,m,_=[],p,y,E,v,x,C,T,A,R,I,b,z,X,N=0,V=0,lt=this.coordinateCache_,M=this.viewRotation_,W=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,G,tt,it,Ct;for(;d<f;){let L=r[d];switch(L[0]){case F.BEGIN_GEOMETRY:G=L[1],Ct=L[3],G.getGeometry()?a!==void 0&&!ht(a,Ct.getExtent())?d=L[2]+1:++d:d=L[2],h&&(h.zIndex=L[4]);break;case F.BEGIN_PATH:N>$&&(this.fill_(t),N=0),V>$&&(t.stroke(),V=0),!N&&!V&&(t.beginPath(),x=NaN,C=NaN),++d;break;case F.CIRCLE:g=L[1],E=L[2]??0;let vt=c[g],ot=c[g+1],Oe=c[g+2]-E,Ji=c[g+3]-E,re=Oe-vt,wr=Ji-ot,Ts=Math.sqrt(re*re+wr*wr);t.moveTo(vt+Ts,ot),t.arc(vt,ot,Ts,0,2*Math.PI,!0),++d;break;case F.CLOSE_PATH:t.closePath(),++d;break;case F.CUSTOM:g=L[1],m=L[2];let Qi=L[3],tn=L[4],An=L[5];O.geometry=Qi,O.feature=G,d in lt||(lt[d]=[]);let ii=lt[d];An?An(c,g,m,2,ii):(ii[0]=c[g],ii[1]=c[g+1],ii.length=2),h&&(h.zIndex=L[6]),tn(ii,O),++d;break;case F.DRAW_IMAGE:g=L[1],m=L[2],R=L[3],p=L[4],y=L[5];let Mn=L[6],Cr=L[7],vr=L[8],Is=L[9],Ii=L[10],Sr=L[11],Nm=L[12],bs=L[13];v=L[14]||"declutter";let Rr=L[15];if(!R&&L.length>=20){I=L[19],b=L[20],z=L[21],X=L[22];let St=this.drawLabelWithPointPlacement_(I,b,z,X);R=St.label,L[3]=R;let De=L[23];p=(St.anchorX-De)*this.pixelRatio,L[4]=p;let se=L[24];y=(St.anchorY-se)*this.pixelRatio,L[5]=y,Mn=R.height,L[6]=Mn,bs=R.width,L[13]=bs}let ya;L.length>25&&(ya=L[25]);let xa,Ls,As;L.length>17?(xa=L[16],Ls=L[17],As=L[18]):(xa=mi,Ls=null,As=null),Ii&&W?Sr+=M:!Ii&&!W&&(Sr-=M);let zm=0;for(;g<m;g+=2){if(ya&&ya[zm++]<bs/this.pixelRatio)continue;let St=this.calculateImageOrLabelDimensions_(R.width,R.height,c[g],c[g+1],bs,Mn,p,y,vr,Is,Sr,Nm,s,xa,!!Ls||!!As,G),De=[t,e,R,St,Cr,Ls,As];if(l){let se,ke,oe;if(Rr){let gt=m-g;if(!Rr[gt]){Rr[gt]={args:De,declutterMode:v};continue}let Kt=Rr[gt];se=Kt.args,ke=Kt.declutterMode,delete Rr[gt],oe=gm(se)}let ni,ri;if(se&&(ke!=="declutter"||!l.collides(oe))&&(ni=!0),(v!=="declutter"||!l.collides(St.declutterBox))&&(ri=!0),ke==="declutter"&&v==="declutter"){let gt=ni&&ri;ni=gt,ri=gt}ni&&(ke!=="none"&&l.insert(oe),this.replayImageOrLabel_.apply(this,se)),ri&&(v!=="none"&&l.insert(St.declutterBox),this.replayImageOrLabel_.apply(this,De))}else this.replayImageOrLabel_.apply(this,De)}++d;break;case F.DRAW_CHARS:let nu=L[1],ru=L[2],Ea=L[3],Gm=L[4];X=L[5];let Xm=L[6],su=L[7],ou=L[8];z=L[9];let wa=L[10];I=L[11],Array.isArray(I)&&(I=I.reduce(Yy,"")),b=L[12];let au=[L[13],L[13]];v=L[14]||"declutter";let Wm=L[15],lu=L[16],Ca=this.textStates[b],Tr=Ca.font,Ir=[Ca.scale[0]*su,Ca.scale[1]*su],br;Tr in this.widths_?br=this.widths_[Tr]:(br={},this.widths_[Tr]=br);let cu=dm(c,nu,ru,2),hu=Math.abs(Ir[0])*jl(Tr,I,br);if(Gm||hu<=cu){let St=this.textStates[b].textAlign,De=(cu-hu)*Fh(I,St),se=fm(c,nu,ru,2,I,De,Xm,Math.abs(Ir[0]),jl,Tr,br,W?0:this.viewRotation_,Wm);t:if(se){let ke=[],oe,ni,ri,gt,Kt;if(z)for(oe=0,ni=se.length;oe<ni;++oe){Kt=se[oe],ri=Kt[4],gt=this.createLabel(ri,b,"",z),p=Kt[2]+(Ir[0]<0?-wa:wa)-lu,y=Ea*gt.height+(.5-Ea)*2*wa*Ir[1]/Ir[0]-ou;let si=this.calculateImageOrLabelDimensions_(gt.width,gt.height,Kt[0],Kt[1],gt.width,gt.height,p,y,0,0,Kt[3],au,!1,mi,!1,G);if(l&&v==="declutter"&&l.collides(si.declutterBox))break t;ke.push([t,e,gt,si,1,null,null])}if(X)for(oe=0,ni=se.length;oe<ni;++oe){Kt=se[oe],ri=Kt[4],gt=this.createLabel(ri,b,X,""),p=Kt[2]-lu,y=Ea*gt.height-ou;let si=this.calculateImageOrLabelDimensions_(gt.width,gt.height,Kt[0],Kt[1],gt.width,gt.height,p,y,0,0,Kt[3],au,!1,mi,!1,G);if(l&&v==="declutter"&&l.collides(si.declutterBox))break t;ke.push([t,e,gt,si,1,null,null])}l&&v!=="none"&&l.load(ke.map(gm));for(let si=0,Um=ke.length;si<Um;++si)this.replayImageOrLabel_.apply(this,ke[si])}}++d;break;case F.END_GEOMETRY:if(o!==void 0){G=L[1];let St=o(G,Ct,v);if(St)return St}++d;break;case F.FILL:$?N++:this.fill_(t),++d;break;case F.MOVE_TO_LINE_TO:g=L[1],m=L[2],E=L[3];let en,Lr,Ms;if(E){let De=(L[4]??!1)||Math.abs(c[g]-c[m-2])<1e-6&&Math.abs(c[g+1]-c[m-1])<1e-6;fa(c,g,m,2,E,De,_),ga(_,2,De),en=_,Lr=0,Ms=en.length}else en=c,Lr=g,Ms=m;tt=en[Lr],it=en[Lr+1],t.moveTo(tt,it),x=tt+.5|0,C=it+.5|0;for(let St=Lr+2;St<Ms;St+=2)tt=en[St],it=en[St+1],T=tt+.5|0,A=it+.5|0,(St==Ms-2||T!==x||A!==C)&&(t.lineTo(tt,it),x=T,C=A);++d;break;case F.SET_FILL_STYLE:this.alignAndScaleFill_=L[2],N?(this.fill_(t),N=0,V&&(t.stroke(),V=0)):V&&L[1]&&(t.stroke(),V=0),t.fillStyle=L[1],++d;break;case F.SET_STROKE_STYLE:N&&L[1]&&(this.fill_(t),N=0),V&&(t.stroke(),V=0),this.setStrokeStyle_(t,L),++d;break;case F.STROKE:$?V++:t.stroke(),++d;break;default:++d;break}}N&&this.fill_(t),V&&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)}},pm=Nh;var $i=["Polygon","Circle","LineString","Image","Text","Default"],Xh=["Image","Text"],_m=$i.filter(n=>!Xh.includes(n)),ym=!1,xm=!1;function Ky(){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};ym={[t(!0)]:!0,[t(!1)]:!1,[t(void 0)]:void 0}[n],xm=!0}var Gh=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 pm(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){xm===!1&&Ky(),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:ym}));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(),an(d,t),On(d,e*(this.renderBuffer_+r),d));let f=Zy(r),g;function m(C,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(C)){let z=(f[I]-3)/4,X=r-z%a,N=r-(z/a|0),V=s(C,T,X*X+N*N);if(V)return V}c.clearRect(0,0,a,a);break}}let _=Object.keys(this.executorsByZIndex_).map(Number);_.sort(Vt);let p,y,E,v,x;for(p=_.length-1;p>=0;--p){let C=_[p].toString();for(E=this.executorsByZIndex_[C],y=$i.length-1;y>=0;--y)if(g=$i[y],v=E[g],v!==void 0&&(x=v.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?Hu:Vt),o=o||$i;let h=$i.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(),v=E?E.getContext():t,x=this.maxExtent_&&p!=="Image"&&p!=="Text";if(x&&(v.save(),this.clip(v,i)),!E||p==="Text"||p==="Image"?y.execute(v,e,i,r,s,a):E.pushFunction(C=>y.execute(C,e,i,r,s,a)),x&&v.restore(),E){E.offset();let C=l[c]*h+$i.indexOf(p);this.deferredZIndexContexts_[C]||(this.deferredZIndexContexts_[C]=[]),this.deferredZIndexContexts_[C].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(Vt);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}},zh={};function Zy(n){if(zh[n]!==void 0)return zh[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 zh[n]=r,r}var Em=Gh;var Wh=class extends da{constructor(t,e,i,r,s,o,a){super(),this.context_=t,this.pixelRatio_=e,this.extent_=i,this.transform_=r,this.transformRotation_=r?ln(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=fa(l,0,c,2,o,d,l),ga(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=Wd(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:Ki;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:Ve,lineDash:this.pixelRatio_===1?c:c.map(f=>f*this.pixelRatio_),lineDashOffset:(o||$t)*this.pixelRatio_,lineJoin:a!==void 0?a:je,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(),v=i.getMiterLimit();this.textStrokeState_={lineCap:m!==void 0?m:Ve,lineDash:_||qt,lineDashOffset:p||$t,lineJoin:y!==void 0?y:je,lineWidth:E!==void 0?E:pi,miterLimit:v!==void 0?v: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:bo,textAlign:d!==void 0?d:Ki,textBaseline:f!==void 0?f:En},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]]}}},wm=Wh;var Pe=.5;function Cm(n,t,e,i,r,s,o,a,l){let h=l?Pi(r,l):r,c=n[0]*Pe,d=n[1]*Pe,f=nt(c,d);f.imageSmoothingEnabled=!1;let g=f.canvas,m=new wm(f,Pe,r,null,o,a,l?un(fn(),l):null),_=e.length,p=Math.floor((256*256*256-1)/_),y={};for(let v=1;v<=_;++v){let x=e[v-1],C=x.getStyleFunction()||i;if(!C)continue;let T=C(x,s);if(!T)continue;Array.isArray(T)||(T=[T]);let R=(v*p).toString(16).padStart(7,"#00000");for(let I=0,b=T.length;I<b;++I){let z=T[I],X=z.getGeometryFunction()(x);if(!X||!ht(h,X.getExtent()))continue;let N=z.clone(),V=N.getFill();V&&V.setColor(R);let lt=N.getStroke();lt&&(lt.setColor(R),lt.setLineDash(null)),N.setText(void 0);let M=z.getImage();if(M){let G=M.getImageSize();if(!G)continue;let tt=nt(G[0],G[1],void 0,{alpha:!1}),it=tt.canvas;tt.fillStyle=R,tt.fillRect(0,0,it.width,it.height),N.setImage(new wn({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 W=N.getZIndex()||0,O=y[W];O||(O={},y[W]=O,O.Polygon=[],O.Circle=[],O.LineString=[],O.Point=[]);let $=X.getType();if($==="GeometryCollection"){let G=X.getGeometriesArrayRecursive();for(let tt=0,it=G.length;tt<it;++tt){let Ct=G[tt];O[Ct.getType().replace("Multi","")].push(Ct,N)}}else O[$.replace("Multi","")].push(X,N)}}let E=Object.keys(y).map(Number).sort(Vt);for(let v=0,x=E.length;v<x;++v){let C=y[E[v]];for(let T in C){let A=C[T];for(let R=0,I=A.length;R<I;R+=2){m.setStyle(A[R+1]);for(let b=0,z=t.length;b<z;++b)m.setTransform(t[b]),m.drawGeometry(A[R])}}}return f.getImageData(0,0,g.width,g.height)}function vm(n,t,e){let i=[];if(e){let r=Math.floor(Math.round(n[0])*Pe),s=Math.floor(Math.round(n[1])*Pe),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,Sm={Point:Qy,LineString:qy,Polygon:ex,MultiPoint:tx,MultiLineString:$y,MultiPolygon:Jy,GeometryCollection:Hy,Circle:Vy};function Rm(n,t){return parseInt(Y(n),10)-parseInt(Y(t),10)}function Uh(n,t){let e=Yh(n,t);return e*e}function Yh(n,t){return By*n/t}function Vy(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)),jy(n,t,e,i,s,o,a),d}function jy(n,t,e,i,r,s,o){let a=e.getGeometryFunction()(t);if(!a)return;let l=a.simplifyTransformed(i,r);if(e.getRenderer())Tm(n,l,e,t,o);else{let c=Sm[l.getType()];c(n,l,e,t,o,s)}}function Tm(n,t,e,i,r){if(t.getType()=="GeometryCollection"){let o=t.getGeometries();for(let a=0,l=o.length;a<l;++a)Tm(n,o[a],e,i,r);return}n.getBuilder(e.getZIndex(),"Default").drawCustom(t,i,e.getRenderer(),e.getHitDetectionRenderer(),r)}function Hy(n,t,e,i,r,s){let o=t.getGeometriesArray(),a,l;for(a=0,l=o.length;a<l;++a){let h=Sm[o[a].getType()];h(n,o[a],e,i,r,s)}}function qy(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 $y(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 Jy(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 Qy(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 tx(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 ex(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 Zh=class extends ua{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),v=d.getWrapX()&&l.canWrapX(),x=v?j(c):null,C=v?Math.ceil((r[2]-c[2])/x)+(this.extendX_?2:1):1,T=v?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?$i:i?Xh:_m,i?f&&e.declutter[f]:void 0)}while(++T<C)}setDrawContext_(){this.opacity_!==1&&(this.targetContext_=this.context,this.context=nt(this.context.canvas.width,this.context.canvas.height,yh))}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,pn(this.context),yh.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&&!Fe(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]*Pe,f=i[1]*Pe;c.push(this.getRenderTransform(r,s,o,Pe,d,f,0).slice());let g=h.getSource(),m=a.getExtent();if(g.getWrapX()&&a.canWrapX()&&!Fe(m,l)){let p=l[0],y=j(m),E=0,v;for(;p<m[0];)--E,v=y*E,c.push(this.getRenderTransform(r,s,o,Pe,d,f,v).slice()),p+=y;for(E=0,p=l[2];p>m[2];)++E,v=y*E,c.push(this.getRenderTransform(r,s,o,Pe,d,f,v).slice()),p-=y}let _=fn();this.hitDetectionImageData_=Cm(i,c,this.renderedFeatures_,h.getStyleFunction(),l,s,o,Uh(s,this.renderedPixelRatio_),_?a:null)}e(vm(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&&(_=Rm);let p=h.center.slice(),y=On(l,m*d),E=y.slice(),v=[y.slice()],x=c.getExtent(),C=i.getWrapX()&&c.canWrapX();if(this.extendX_=!1,C){let M=i.getExtent();M&&!ze(M)&&(this.extendX_=M[0]<x[0]||M[2]>x[2])}if(C&&(!Fe(x,t.extent)||this.extendX_)){let M=j(x),W=Math.max(j(y)/2,M),O=x[0],$=x[2];this.extendX_&&(O-=M,$+=M),y[0]=O-W,y[2]=$+W,Ws(p,c);let G=Ma(v[0],c);G[0]<x[0]&&G[2]<x[2]?v.push([G[0]+M,G[1],G[2]+M,G[3]]):G[0]>x[0]&&G[2]>x[2]&&v.push([G[0]-M,G[1],G[2]-M,G[3]])}if(this.ready&&this.renderedResolution_==d&&this.renderedPixelRatio_===f&&this.renderedRevision_==g&&this.renderedRenderOrder_==_&&this.renderedFrameDeclutter_===!!t.declutter&&Fe(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 um(Yh(d,f),y,d,f),A=fn(),R;if(A){for(let M=0,W=v.length;M<W;++M){let O=v[M],$=Pi(O,c);i.loadFeatures($,Bu(d,c),A)}R=un(A,c)}else for(let M=0,W=v.length;M<W;++M)i.loadFeatures(v[M],d,c);let I=Uh(d,f),b=!0,z=(M,W)=>{let O,$=M.getStyleFunction()||e.getStyleFunction();if($&&(O=$(M,d)),O){let G=this.renderFeature(M,I,O,T,R,this.getLayer().getDeclutter(),W);b=b&&!G}},X=Pi(y,c),N=i.getFeaturesInExtent(X);_&&N.sort(_);for(let M=0,W=N.length;M<W;++M)z(N[M],M);this.renderedFeatures_=N,this.ready=b;let V=T.finish(),lt=new Em(y,d,f,i.getOverlaps(),V,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}},Im=Zh;var Bh=class extends aa{constructor(t){super(t)}createRenderer(){return new Im(this)}},bm=Bh;var ix=!1;function nx(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=ix,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 Vh(n,t){return function(e,i,r,s,o){nx(n,t,e,i,r,(a,l)=>{this.addFeatures(a),s!==void 0&&s(a)},()=>{this.changed(),o!==void 0&&o()})}}function Lm(n,t){return[[-1/0,-1/0,1/0,1/0]]}function jh(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,_=ju(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 Am=At(),vs=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"?Ds(this.flatCoordinates_):Dn(this.flatCoordinates_,0,this.flatCoordinates_.length,this.stride_)),this.extent_}getFlatInteriorPoint(){if(!this.flatInteriorPoints_){let t=Bt(this.getExtent());this.flatInteriorPoints_=Kr(this.flatCoordinates_,0,this.ends_,this.stride_,t,0)}return this.flatInteriorPoints_}getFlatInteriorPoints(){if(!this.flatInteriorPoints_){let t=Jd(this.flatCoordinates_,this.ends_),e=Oo(this.flatCoordinates_,0,t,this.stride_);this.flatInteriorPoints_=go(this.flatCoordinates_,0,t,this.stride_,e)}return this.flatInteriorPoints_}getFlatMidpoint(){return this.flatMidpoints_||(this.flatMidpoints_=jh(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=jh(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(Am,i[0],i[3],r,-r,0,0,0),jt(this.flatCoordinates_,0,this.flatCoordinates_.length,this.stride_,Am,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=to((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=Ur(i,0,this.simplifiedGeometry_.flatCoordinates_.length,this.simplifiedGeometry_.stride_,t,i,0),r=[i.length];break;case"MultiLineString":r=[],i.length=jd(i,0,this.simplifiedGeometry_.ends_,this.simplifiedGeometry_.stride_,t,i,0,r);break;case"Polygon":r=[],i.length=Yr(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}};vs.prototype.getFlatCoordinates=vs.prototype.getOrientedFlatCoordinates;var Ln=vs;var Hh=class{constructor(t){this.rbush_=new Tn(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];on(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]}},qh=Hh;var ie={ADDFEATURE:"addfeature",CHANGEFEATURE:"changefeature",CLEAR:"clear",REMOVEFEATURE:"removefeature",FEATURESLOADSTART:"featuresloadstart",FEATURESLOADEND:"featuresloadend",FEATURESLOADERROR:"featuresloaderror"};var ei=class extends Lt{constructor(t,e,i){super(t),this.feature=e,this.features=i}},$h=class extends co{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_=hi,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&&(B(this.format_,"`format` must be set when `url` is set"),this.loader_=Vh(this.url_,this.format_)),this.strategy_=t.strategy!==void 0?t.strategy:Lm;let e=t.useSpatialIndex!==void 0?t.useSpatialIndex:!0;this.featuresRtree_=e?new qh:null,this.loadedExtentsRtree_=new qh,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 ei(ie.ADDFEATURE,t))}setupChangeEvents_(t,e){e instanceof Ln||(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 Ln){let s=this.idIndex_[r];s instanceof Ln?Array.isArray(s)?s.push(e):this.idIndex_[r]=[s,e]:i=!1}else i=!1}return i&&(B(!(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 ei(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 ei(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 Ln||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 Ln||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=Ns(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||li,this.featuresRtree_.forEachInExtent(l,function(h){if(e(h)){let c=h.getGeometry(),d=a;if(a=c instanceof Ln?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 ei(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 Fe(c.extent,l)})){this.loading=Number(this.loading)+1,this.dispatchEvent(new ei(ie.FEATURESLOADSTART));let c=m=>{this.loading=Number(this.loading)-1,this.dispatchEvent(new ei(ie.FEATURESLOADEND,void 0,m))},d=()=>{this.changed(),this.loading=Number(this.loading)-1,this.dispatchEvent(new ei(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=Aa(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 ei(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){B(this.format_,"`format` must be set when `url` is set"),this.url_=t,this.setLoader(Vh(t,this.format_))}setOverlaps(t){this.overlaps_=t,this.changed()}},Ti=$h;function Mm(){let n=u.variant,t=w.overviewCanvas,e=t.getContext("2d"),i=di(),r=u.game.tileGrid.size,s=u.game.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||!pa(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=`${u.game.base}/tiles/${encodeURIComponent(n.tiles)}/${l}/${y}/${p}.${d}`}Ss()}function Ss(){let n=u.engine?.getView();if(!n||!u.variant)return;let t=di(),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,w.overviewShelf.hidden=o,o))return;let l=w.overviewCanvas,h=be((e[0]-t[0])/i,0,1),c=be((e[2]-t[0])/i,0,1),d=be((t[3]-e[3])/r,0,1),f=be((t[3]-e[1])/r,0,1),g=w.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 ma(n,t=!0){u.overviewDocked=n,n&&u.overviewPointer!==null&&(u.overviewPointer=null,Er()),w.overviewShelf.classList.toggle("is-docked",n),w.overviewDock.setAttribute("aria-expanded",String(!n));let e=n?"Bring the overview back":"Put the overview away";w.overviewDock.setAttribute("aria-label",e),w.overviewDock.title=e,t&&Re()}function Jh(n,t){let e=u.engine?.getView();if(!e||!u.variant)return;let i=w.overviewCanvas.getBoundingClientRect(),r=di(),s=(a,l,h)=>be((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 bm({updateWhileAnimating:!0,...n})}function Pm(){let n=u.game.tileGrid.size,t=[0,-n,n,0];u.projection=new Ai({code:"ATLAS:PIXELS",units:"pixels",extent:t}),u.sources={grid:new Ti({wrapX:!1}),gridContext:new Ti({wrapX:!1}),zoneScrim:new Ti({wrapX:!1}),zones:new Ti({wrapX:!1}),zoneTitles:new Ti({wrapX:!1}),text:new Ti({wrapX:!1}),pins:new Ti({wrapX:!1}),priority:new Ti({wrapX:!1})},u.layers={raster:new vh({zIndex:0}),rasterDetail:new vh({zIndex:1}),grid:ne({source:u.sources.grid,style:sc,renderOrder:fe,renderBuffer:40,zIndex:5}),zoneScrim:ne({source:u.sources.zoneScrim,style:Nf,zIndex:6}),zones:ne({source:u.sources.zones,style:zf,renderBuffer:32,zIndex:10}),zoneTitles:ne({source:u.sources.zoneTitles,style:Gf,renderOrder:fe,renderBuffer:160,zIndex:20}),zoneTitleDetail:ne({source:u.sources.zoneTitles,style:Xf,renderOrder:fe,renderBuffer:160,zIndex:44}),text:ne({source:u.sources.text,style:Af,renderOrder:fe,renderBuffer:220,zIndex:30}),textDetail:ne({source:u.sources.text,style:Mf,renderOrder:fe,renderBuffer:220,zIndex:45}),zoneText:ne({source:u.sources.text,style:Pf,renderOrder:fe,renderBuffer:220,zIndex:41}),pins:ne({source:u.sources.pins,style:If,renderOrder:fe,renderBuffer:48,zIndex:40}),zonePins:ne({source:u.sources.pins,style:bf,renderOrder:fe,renderBuffer:48,zIndex:42}),pinLabels:ne({source:u.sources.pins,style:Lf,renderOrder:fe,renderBuffer:180,zIndex:45}),gridContext:ne({source:u.sources.gridContext,style:sc,renderOrder:fe,renderBuffer:40,zIndex:48}),priority:ne({source:u.sources.priority,style:Of,renderOrder:fe,renderBuffer:220,zIndex:50})},u.engine=new tm({target:w.viewport,layers:Object.values(u.layers),controls:Xo({attribution:!1,rotate:!1,zoom:!1}),interactions:Bo({onFocusOnly:!1}),view:Qh(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&&Er()}),u.engine.on("postrender",Ss),w.viewport.addEventListener("wheel",()=>{document.activeElement!==w.viewport&&w.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){Br(r.hash);return}}let i=u.engine.forEachFeatureAtPixel(e.pixel,(r,s)=>_a(s)&&r.get("pin")||null,{hitTolerance:5,layerFilter:_a});i&&Fl(i)}),u.engine.on("pointermove",e=>{if(e.dragging){ar(null);return}let i=u.engine.forEachFeatureAtPixel(e.pixel,(o,a)=>_a(a)&&o.get("pin")||null,{hitTolerance:4,layerFilter:_a}),r=i&&Be(i.category)==="text"?null:i;ar(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",()=>ar(null))}function _a(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 Qh(n){let t=u.game.tileGrid.size;return new ee({projection:u.projection,center:[t/2,-t/2],resolutions:tu(n),minZoom:0,maxZoom:n,extent:[0,-t,t,0],constrainResolution:!1,smoothResolutionConstraint:!1,showFullExtent:!0,zoom:0})}function tu(n){let t=u.game.tileGrid.size/u.game.tileGrid.tileSize;return Array.from({length:n+1},(e,i)=>t/2**i)}async function yi(n,t){u.game=u.catalog.games.find(r=>r.slug===n)||u.catalog.games[0],u.engine||Pm(),!t&&!u.restore&&(u.restore=Jn(u.game.slug)),w.game.value=u.game.slug,rn(w.map,u.game.maps,"title"),w.map.disabled=u.game.maps.length===1,w.map.title=w.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 eu((i||u.game.maps[0]).slug)}async function eu(n){let t=u.game.maps.find(s=>s.slug===n)||u.game.maps[0],e=++u.mapRun;w.loading.hidden=!1;let i;try{i=await ng(t)}catch{u.mapRun===e&&(w.loading.hidden=!0,vn());return}if(u.mapRun!==e)return;u.settling=!0,u.map=i,document.documentElement.style.setProperty("--icon-outset-color",Vr()),w.map.value=u.map.slug,rn(w.variant,u.map.variants,"name"),w.variantField.hidden=u.map.variants.length<2,u.styleCache.clear(),ar(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)),ma(!!u.restore?.overviewDocked,!1),Co(u.restore?!!u.restore.dockFolded:!0,!1),u.dockDismissed=!!u.restore?.dockDismissed,u.search="",w.search.value="",w.dock.hidden=!1,Te(),Qf(),lc(),$f(),iu(r?be(r.variant,0,u.map.variants.length-1):0,!0),u.restore=null,w.sidebar.classList.remove("is-open"),w.mobileLegend.setAttribute("aria-expanded","false"),kd(),u.settling=!1,Re()}function iu(n,t=!1){let e=u.variant;u.variant=u.map.variants[n]||u.map.variants[0];let i=u.variant,r=t?null:ax(e,i),s=Ze(i);w.variant.value=String(u.map.variants.indexOf(u.variant)),t?u.engine.setView(Qh(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},w.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&&(w.loading.hidden=!0))};return _.on("tileloadend",()=>p(!1)),_.on("tileloaderror",()=>p(!0)),_},h=(_,p)=>l(new Od({projection:u.projection,tileGrid:new zr({extent:[0,-u.game.tileGrid.size,u.game.tileGrid.size,0],origin:[0,0],resolutions:tu(_),tileSize:u.game.tileGrid.tileSize}),cacheSize:64,interpolate:i.interpolate,transition:0,wrapX:!1,tileUrlFunction:([y,E,v])=>{let x=i.formats[y];if(!(!x||E<0||v<0||!p(y,E,v)))return`${u.game.base}/tiles/${encodeURIComponent(i.tiles)}/${y}/${E}/${v}.${x}`}})),c=i.fullZoom??i.maxZoom,d=h(c,(_,p,y)=>pa(i,_,p,y)),f=u.layers.raster.getSource();u.layers.raster.setSource(d),u.layers.raster.setExtent(di()),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&&pa(i,_,p,y))),u.layers.rasterDetail.setExtent(di()),u.layers.rasterDetail.setVisible(!0)):u.layers.rasterDetail.setVisible(!1),g?.clear(),yo(),u.gridEnabled&&(Ke(),u.layers.pins.changed(),u.layers.text.changed(),u.layers.priority.changed()),u.overviewKey="",Mm();let m=t&&u.restore?.map===u.map.slug?u.restore:null;if(u.renderedShard!==(i.shard||0)&&(lc(),ue()),m?.center&&Number.isFinite(m.zoom)){let _=u.engine.getView();_.setCenter(m.center),_.setZoom(m.zoom),u.fitZoom=m.zoom,Cn()}else t?requestAnimationFrame(lx):(r&&u.engine.getView().animate({center:r,duration:200}),Cn());Re()}function pa(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=ox(n,t,r),l=o*r.w+s;return(a[l>>3]&1<<(l&7))!==0}function ox(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 Ze(n){return n.maxZoom+2}function Er(){Cn(),Re()}function ax(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+be(r,0,1)*t.bounds.width,-(t.bounds.y+be(s,0,1)*t.bounds.height)]}function Om(){let t=document.querySelector(".app-shell").classList.toggle("sidebar-collapsed");w.mobileLegend.setAttribute("aria-expanded",String(!t)),requestAnimationFrame(()=>u.engine?.updateSize())}function di(){let n=u.game.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 lx(){if(!u.engine||!u.variant)return;let n=u.engine.getView();n.fit(di(),{size:u.engine.getSize(),padding:[36,36,36,36],maxZoom:u.variant.maxZoom,duration:0}),u.fitZoom=n.getZoom()||0,Cn()}function Rs(n){let t=u.engine.getView(),e=t.getZoom()||0;t.animate({zoom:be(e+n,u.variant.minZoom,Ze(u.variant)),duration:140})}function Cn(){let n=u.engine?.getView().getZoom();if(w.viewport.dataset.zoom=Number.isFinite(n)?n.toFixed(3):"",!u.engine||!u.pins.length){w.visibleCount.textContent="0 locations visible";return}let t=u.engine.getView().calculateExtent(u.engine.getSize()),e=0;for(let i of u.pins){if(ge(i))continue;let[r,s]=i.coordinate;r>=t[0]&&r<=t[2]&&s>=t[1]&&s<=t[3]&&e++}w.visibleCount.textContent=`${Ie(u.eligibleLocations)} enabled \xB7 ${Ie(e)} in view`}function Dm(){w.game.addEventListener("change",()=>{yi(w.game.value)}),w.map.addEventListener("change",()=>{eu(w.map.value)}),w.addBundles.addEventListener("click",()=>{gc()}),w.emptyOpen.addEventListener("click",()=>{gc()}),w.variant.addEventListener("change",()=>iu(Number(w.variant.value))),w.legend.addEventListener("change",i=>{let r=i.target;if(r.dataset.sectionToggle){eg(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),ue(),Wi()});let n=null,t=()=>{for(let s of w.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&&w.layers.contains(r)&&r.classList.add("is-hovered")};w.layers.addEventListener("pointermove",i=>{n={x:i.clientX,y:i.clientY},t()},{passive:!0}),w.layers.addEventListener("pointerleave",()=>{n=null,t()}),w.layers.addEventListener("scroll",t,{passive:!0}),w.layers.addEventListener("click",i=>{let r=i.target.closest("[data-only-category], [data-only-section]");if(r){i.preventDefault(),i.stopPropagation(),ig(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),No()}),w.soloChip.addEventListener("click",()=>ss(!0)),k("#expand-all").addEventListener("click",()=>dc(!1)),k("#collapse-all").addEventListener("click",()=>dc(!0)),k("#show-all").addEventListener("click",()=>ss(!0)),k("#hide-all").addEventListener("click",()=>ss(!1)),w.zoneToggle.addEventListener("change",()=>{Do(w.zoneToggle.checked)}),w.zoneIndex.addEventListener("click",i=>{let r=i.target.closest("[data-zone]");r&&jf(Number(r.dataset.zone))}),w.zoneIndex.addEventListener("contextmenu",i=>{let r=i.target.closest("[data-zone]");r&&(i.preventDefault(),Hf(Number(r.dataset.zone)))}),w.search.addEventListener("input",()=>{u.search=w.search.value.trim().toLocaleLowerCase(),ue(),u.search&&wo()}),w.dockFold.addEventListener("click",()=>{Dl(!u.dockFolded)}),w.searchResults.addEventListener("click",i=>{let r=i.target.closest("[data-location]");if(!r)return;let s=u.pinByID.get(Number(r.dataset.location));s&&kl(s)}),w.detailLinks.addEventListener("click",i=>{let r=i.target.closest("[data-location]");if(!r)return;let s=u.pinByID.get(Number(r.dataset.location));s&&kl(s)}),k("#close-detail").addEventListener("click",Te),k("#zoom-in").addEventListener("click",()=>Rs(1)),k("#zoom-out").addEventListener("click",()=>Rs(-1)),w.gridBack.addEventListener("click",Ml),w.gridInput.addEventListener("input",()=>{let i=yn(),r=[...w.gridInput.value.toLocaleLowerCase()].filter(s=>ae.includes(s)).slice(0,i).join("");w.gridInput.value=r,Br(r)}),w.subgridToggle.addEventListener("click",()=>{Zr(!u.subgridVisible),w.viewport.focus({preventScroll:!0})}),w.gridInput.addEventListener("keydown",i=>{if(i.key===" "){i.preventDefault(),Zr(!u.subgridVisible);return}i.key==="Escape"&&(i.preventDefault(),i.stopPropagation(),w.viewport.focus({preventScroll:!0}))}),w.viewport.addEventListener("keydown",i=>{if(!Eo(i.target)){if(i.key==="+"||i.key==="=")Rs(1);else if(i.key==="-")Rs(-1);else if(i.key==="Escape")Te();else return;i.preventDefault()}}),window.addEventListener("contextmenu",i=>{Eo(i.target)||i.preventDefault()}),window.addEventListener("keydown",i=>{if((i.metaKey||i.ctrlKey)&&i.key.toLocaleLowerCase()==="r"){i.preventDefault(),location.reload();return}if(!Eo(i.target)){if((i.metaKey||i.ctrlKey)&&i.key.toLocaleLowerCase()==="k"){i.preventDefault(),w.search.focus(),w.search.select();return}if((i.metaKey||i.ctrlKey)&&i.altKey&&i.code==="KeyB"){i.preventDefault(),w.dock.hidden||Dl(!u.dockFolded);return}if((i.metaKey||i.ctrlKey)&&i.key.toLocaleLowerCase()==="b"){i.preventDefault(),Om();return}tf(i)||i.key.toLocaleLowerCase()==="z"&&(i.preventDefault(),i.repeat||Fo(!0))}}),window.addEventListener("keyup",i=>{i.key.toLocaleLowerCase()==="z"&&Fo(!1)}),window.addEventListener("blur",()=>Fo(!1)),window.addEventListener("hashchange",()=>{let i=Qn();i.game===u.game?.slug&&i.map===u.map?.slug||(u.restore=null,yi(i.game||u.catalog.games[0].slug,i.map))}),window.addEventListener("resize",()=>{u.engine?.updateSize(),Ss()}),w.overview.addEventListener("pointerdown",i=>{u.overviewDocked||i.pointerType==="mouse"&&i.button!==0||(i.preventDefault(),w.overview.setPointerCapture(i.pointerId),u.overviewPointer=i.pointerId,Jh(i,!0))}),w.overview.addEventListener("pointermove",i=>{u.overviewPointer===i.pointerId&&(i.preventDefault(),Jh(i,!1))});let e=i=>{u.overviewPointer===i.pointerId&&(u.overviewPointer=null,Er())};w.overview.addEventListener("pointerup",e),w.overview.addEventListener("pointercancel",e),w.overviewDock.addEventListener("click",()=>{ma(!u.overviewDocked),w.viewport.focus({preventScroll:!0})}),w.mobileLegend.addEventListener("click",()=>{let i=w.sidebar.classList.toggle("is-open");w.mobileLegend.setAttribute("aria-expanded",String(i))})}function km(){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?Ze(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,labelsHeld:u.labelsHeld,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:!w.detail.hidden,detailTitle:w.detail.hidden?null:w.detailTitle.textContent||null,searchQuery:u.search,searchResultsVisible:!w.searchResults.hidden,soloChip:w.soloChip.hidden?null:w.soloChip.textContent,visibleCountText:w.visibleCount.textContent,overviewDocked:u.overviewDocked,dockFolded:u.dockFolded,dockDismissed:u.dockDismissed,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:yn(),extent:u.gridEnabled?er():null,cells:[...u.sources.grid.getFeatures(),...u.sources.gridContext.getFeatures()].map(t=>t.get("gridCell")),priorityPins:u.gridPrefix?u.pins.filter(t=>!t.filteredHidden&&ir(t)).length:0}});window.__atlasDebug={snapshot:n,setLayerVisible:(t,e)=>u.layers[t]?.setVisible(e),refreshCatalog:vn},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 Fm(){Dm();try{let n=await fetch("/data/catalog.json");if(!n.ok)throw new Error(`catalog request returned ${n.status}`);if(u.catalog=await n.json(),rn(w.game,u.catalog.games,"title"),fc(),window.runtime?.EventsOn?.("atlas:catalog-changed",()=>{vn()}),u.catalog.games.length){let t=Qn(),e=Jn(),i=e&&(!t.game||t.game===e.game&&t.map===e.map);u.restore=i?e:null,await yi(t.game||e?.game||u.catalog.games[0].slug,t.map||e?.map),u.restore=null}else w.loading.hidden=!0;km(),requestAnimationFrame(()=>w.viewport.focus({preventScroll:!0}))}catch(n){w.loading.hidden=!0,w.fatalMessage.textContent=n instanceof Error?n.message:String(n),w.fatal.hidden=!1}}Fm();})();@@ -27,6 +27,7 @@ export async function loadMap(entry) {
2727 variants: detail.variants,2828 groups: detail.groups,2929 zones: detail.zones || [],30+ attrs: detail.attrs || {},3031 merged: detail.merged || [],3132 sections: legendSections(detail.groups),3233 };@@ -8,6 +8,7 @@ import Projection from "ol/proj/Projection.js";
88 import VectorSource from "ol/source/Vector.js";99 1010 import { elements } from "./dom.js";11+import { renderAs } from "./semconv.js";1112 import { state } from "./state.js";1213 import {1314 featureOrder,@@ -231,7 +232,7 @@ export function initializeMap() {
231232 (feature, layer) => (isAnnotationLayer(layer) && feature.get("pin")) || null,232233 { hitTolerance: 4, layerFilter: isAnnotationLayer },233234 );234- const hovered = hit?.category.displayType === "text" ? null : hit;235+ const hovered = hit && renderAs(hit.category) === "text" ? null : hit;235236 setHoveredPin(hovered || null);236237 const gridHit = state.gridEnabled && state.engine.hasFeatureAtPixel(event.pixel, {237238 layerFilter: (layer) =>@@ -3,6 +3,7 @@ import { state } from "./state.js";
33 import { saveSession } from "./session.js";44 import { applyPinFilters } from "./pins.js";55 import { renderSearchResults } from "./search.js";6+import { renderAs } from "./semconv.js";67 import { applyCategoryVisual, applyCategoryGlyph, initials } from "./theme.js";78 import { formatNumber } from "./util.js";89 @@ -16,7 +17,7 @@ export function legendSections(groups) {
1617 for (const group of groups) {1718 const drawn = [];1819 for (const category of group.categories) {19- (category.displayType === "text" ? text : drawn).push(category);20+ (renderAs(category) === "text" ? text : drawn).push(category);2021 }2122 if (drawn.length) {2223 sections.push({ key: `group-${group.id}`, title: group.title, categories: drawn });@@ -102,7 +103,7 @@ export function onlyButton(label) {
102103 }103104 104105 export function categoryToggle(category) {105- const isText = category.displayType === "text";106+ const isText = renderAs(category) === "text";106107 const row = document.createElement("label");107108 row.className = "category-row";108109 applyCategoryVisual(row, category);@@ -5,6 +5,7 @@ import { closeDetail } from "./detail.js";
55 import { elements } from "./dom.js";66 import { pinInGridCell } from "./grid.js";77 import { renderSearchResults } from "./search.js";8+import { renderAs } from "./semconv.js";89 import { updateVisibleCount } from "./navigation.js";910 import { state } from "./state.js";1011 import { prepareMarkerIcon } from "./styles.js";@@ -19,7 +20,7 @@ export function buildPins() {
1920 state.pinByID.clear();2021 for (const group of state.map.groups) {2122 for (const category of group.categories) {22- if (category.displayType !== "text") prepareMarkerIcon(category);23+ if (renderAs(category) !== "text") prepareMarkerIcon(category);2324 for (const location of category.locations) {2425 const pin = {2526 location,@@ -37,7 +38,7 @@ export function buildPins() {
3738 });3839 state.pins.push(pin);3940 state.pinByID.set(location.id, pin);40- if (category.displayType === "text") state.sources.text.addFeature(pin.feature);41+ if (renderAs(category) === "text") state.sources.text.addFeature(pin.feature);4142 else state.sources.pins.addFeature(pin.feature);4243 }4344 }@@ -0,0 +1,19 @@
1+// The viewer's side of the semantic conventions: the attribute keys a bundle2+// may speak, read leniently. An attribute the payload declares wins; a3+// payload from before the conventions falls back to the legacy field that4+// used to carry the meaning; a key this build has never heard of is simply5+// ignored, because a bundle is never refused over vocabulary.6+7+// renderAs answers how a category draws: "pin" or "text". This is the one8+// display rule the viewer holds, spelled once.9+export function renderAs(category) {10+ const declared = category.attrs?.["atlas.render.as"];11+ if (declared) return declared;12+ return category.displayType === "text" ? "text" : "pin";13+}14+15+// mapSurface answers what the map's raster pictures. A map that says16+// nothing is a plane, which every map was until the planets arrived.17+export function mapSurface(map) {18+ return map?.attrs?.["atlas.geometry.surface"] || "plane";19+}@@ -7,6 +7,7 @@ import {
77 } from "ol/style.js";88 99 import { geohashAlphabet, palette } from "./constants.js";10+import { renderAs } from "./semconv.js";1011 import { state } from "./state.js";1112 import {1213 atMaximumNativeZoom,@@ -84,7 +85,7 @@ export function zoneTextFeatureStyle(feature) {
8485 export function priorityFeatureStyle(feature) {8586 const pin = feature.get("pin");8687 if (!pin || pinIsHidden(pin)) return null;87- if (pin.category.displayType === "text") return textStyles(pin, pin === state.selectedPin);88+ if (renderAs(pin.category) === "text") return textStyles(pin, pin === state.selectedPin);8889 const marker = markerStyles(pin, pin === state.selectedPin);8990 if (pin === state.hoveredPin || pin === state.selectedPin) {9091 return [marker, markerLabelStyle(pin)];@@ -30,9 +30,17 @@ const (
3030 3131 // Manifest is what a bundle says about itself: which game it is, which build3232 // of that game's data it carries, and which maps are inside.33+//34+// Conventions names the semantic-convention vocabulary the payloads were35+// written against; zero is a bundle from before the conventions existed.36+// It is a declaration, never a gate -- a reader that knows a newer or older37+// vocabulary still opens the bundle and ignores what it cannot speak --38+// but validation is stricter about a bundle that declares than one that39+// does not.3340 type Manifest struct {3441 Format string `json:"format"`3542 FormatVersion int `json:"formatVersion"`43+ Conventions int `json:"conventions,omitempty"`3644 Game Game `json:"game"`3745 Version Version `json:"version"`3846 TileGrid TileGrid `json:"tileGrid"`@@ -9,6 +9,8 @@ import (
99 "strconv"1010 "strings"1111 "time"12+13+ "github.com/FelineStateMachine/atlas/internal/semconv"1214 )1315 1416 // maxManifestSize bounds what Open will read as a manifest. A manifest lists@@ -121,7 +123,8 @@ func (b *Bundle) Close() error {
121123 }122124 123125 // payloadPeek is the sliver of a map payload that validation reads: which124-// pyramids its layers draw from and which icons its categories name.126+// pyramids its layers draw from, which icons its categories name, and what127+// the payload says of itself in the shared conventions.125128 type payloadPeek struct {126129 Variants []struct {127130 Tiles string `json:"tiles"`@@ -131,9 +134,18 @@ type payloadPeek struct {
131134 } `json:"variants"`132135 Groups []struct {133136 Categories []struct {134- IconAsset string `json:"iconAsset"`137+ IconAsset string `json:"iconAsset"`138+ DisplayType string `json:"displayType"`139+ Attrs map[string]string `json:"attrs"`135140 } `json:"categories"`136141 } `json:"groups"`142+ Attrs map[string]string `json:"attrs"`143+}144+145+// textPeek is the sliver of a pin's text entry that validation reads: its146+// attributes, which are the only conventions that ride the text file.147+type textPeek struct {148+ Attrs map[string]string `json:"a"`137149 }138150 139151 // Validate checks the manifest's promises against the archive: every listed@@ -214,6 +226,59 @@ func (b *Bundle) Validate() error {
214226 }215227 }216228 }229+ if b.Manifest.Conventions >= 1 {230+ if err := validateConventions(entry.Slug, peek, text); err != nil {231+ return err232+ }233+ }234+ }235+ return nil236+}237+238+// validateConventions holds a declaring bundle to the vocabulary it claims:239+// every attribute registered and well-formed, the render attribute agreeing240+// with the legacy field it will one day retire, a declared standard icon241+// actually resolved, and a declared sphere carrying a mapping that parses.242+// A bundle that declares no conventions is not held to any -- the strictness243+// belongs to the claim.244+func validateConventions(slug string, peek payloadPeek, text []byte) error {245+ if err := semconv.Validate(semconv.EntityMap, peek.Attrs); err != nil {246+ return fmt.Errorf("map %s: %w", slug, err)247+ }248+ if peek.Attrs[semconv.KeyGeometrySurface] == semconv.SurfaceSphere {249+ if peek.Attrs[semconv.KeyGeometryProjection] == "" {250+ return fmt.Errorf("map %s declares a sphere with no projection", slug)251+ }252+ if _, err := semconv.ParseEquirect(253+ peek.Attrs[semconv.KeyGeometryEquirectPx],254+ peek.Attrs[semconv.KeyGeometryEquirectDeg]); err != nil {255+ return fmt.Errorf("map %s: %w", slug, err)256+ }257+ }258+ for _, group := range peek.Groups {259+ for _, category := range group.Categories {260+ if err := semconv.Validate(semconv.EntityCategory, category.Attrs); err != nil {261+ return fmt.Errorf("map %s: %w", slug, err)262+ }263+ if declared, ok := category.Attrs[semconv.KeyRenderAs]; ok {264+ if legacy := semconv.RenderAs(nil, category.DisplayType); declared != legacy {265+ return fmt.Errorf("map %s renders a category as %s while its legacy field says %s",266+ slug, declared, legacy)267+ }268+ }269+ if category.Attrs[semconv.KeyIconStd] != "" && category.IconAsset == "" {270+ return fmt.Errorf("map %s declares a standard icon that was never resolved", slug)271+ }272+ }273+ }274+ var entries map[string]textPeek275+ if err := json.Unmarshal(text, &entries); err != nil {276+ return fmt.Errorf("map %s: decode text: %w", slug, err)277+ }278+ for id, entry := range entries {279+ if err := semconv.Validate(semconv.EntityLocation, entry.Attrs); err != nil {280+ return fmt.Errorf("map %s pin %s: %w", slug, id, err)281+ }217282 }218283 return nil219284 }@@ -22,6 +22,7 @@ import (
2222 "strings"2323 2424 "github.com/FelineStateMachine/atlas/internal/mgdoc"25+ "github.com/FelineStateMachine/atlas/internal/semconv"2526 )2627 2728 // Kind names IGN captures in a map's snapshot index, alongside the "map"@@ -261,6 +262,7 @@ func buildGroups(capture *Capture, ids *mgdoc.IDSpace, scope string) ([]mgdoc.Gr
261262 DisplayType: "markers",262263 Visible: true,263264 Locations: make([]mgdoc.Location, 0, len(markers)),265+ Attrs: map[string]string{semconv.KeyRenderAs: semconv.RenderAsPin},264266 }265267 for _, marker := range markers {266268 locationID, err := ids.Claim("ign:marker:" + marker.ID)@@ -26,17 +26,21 @@ const (
2626 )2727 2828 // Only the fields tools/tiles and tools/generate actually read, spelled with29-// the snake_case tags their own decoders name.29+// the snake_case tags their own decoders name. Attrs carries the semantic30+// conventions a translator declares -- registered atlas.* keys -- under a31+// field no real MapGenie capture spells, so a snapshot passing through32+// untranslated simply says nothing and the generator speaks for it.3033 type Map struct {31- ID int64 `json:"id"`32- Title string `json:"title"`33- Slug string `json:"slug"`34- InitialLatitude float64 `json:"initial_latitude"`35- InitialLongitude float64 `json:"initial_longitude"`36- Config Config `json:"config"`37- Game Game `json:"game"`38- Groups []Group `json:"groups"`39- Regions []struct{} `json:"regions"`34+ ID int64 `json:"id"`35+ Title string `json:"title"`36+ Slug string `json:"slug"`37+ InitialLatitude float64 `json:"initial_latitude"`38+ InitialLongitude float64 `json:"initial_longitude"`39+ Config Config `json:"config"`40+ Game Game `json:"game"`41+ Groups []Group `json:"groups"`42+ Regions []struct{} `json:"regions"`43+ Attrs map[string]string `json:"atlas_attrs,omitempty"`4044 }4145 4246 type Game struct {@@ -75,20 +79,22 @@ type Group struct {
7579 }7680 7781 type Category struct {78- ID int64 `json:"id"`79- Title string `json:"title"`80- Icon string `json:"icon"`81- DisplayType string `json:"display_type"`82- Visible bool `json:"visible"`83- Locations []Location `json:"locations"`82+ ID int64 `json:"id"`83+ Title string `json:"title"`84+ Icon string `json:"icon"`85+ DisplayType string `json:"display_type"`86+ Visible bool `json:"visible"`87+ Locations []Location `json:"locations"`88+ Attrs map[string]string `json:"atlas_attrs,omitempty"`8489 }8590 8691 type Location struct {87- ID int64 `json:"id"`88- Title string `json:"title"`89- Description string `json:"description,omitempty"`90- Latitude float64 `json:"latitude"`91- Longitude float64 `json:"longitude"`92+ ID int64 `json:"id"`93+ Title string `json:"title"`94+ Description string `json:"description,omitempty"`95+ Latitude float64 `json:"latitude"`96+ Longitude float64 `json:"longitude"`97+ Attrs map[string]string `json:"atlas_attrs,omitempty"`9298 }9399 94100 // Synthetic coordinates invert the viewer's projection, so a pin's linear@@ -21,6 +21,7 @@ import (
2121 "strings"2222 2323 "github.com/FelineStateMachine/atlas/internal/mgdoc"24+ "github.com/FelineStateMachine/atlas/internal/semconv"2425 )2526 2627 // Kind names Piggyback captures in a map's snapshot index.@@ -386,6 +387,10 @@ func buildCategory(
386387 if err != nil {387388 return mgdoc.Category{}, false, err388389 }390+ renderAs := semconv.RenderAsPin391+ if displayType == "text" {392+ renderAs = semconv.RenderAsText393+ }389394 category := mgdoc.Category{390395 ID: categoryID,391396 Title: typeLabel,@@ -396,6 +401,7 @@ func buildCategory(
396401 DisplayType: displayType,397402 Visible: true,398403 Locations: make([]mgdoc.Location, 0, len(pins)),404+ Attrs: map[string]string{semconv.KeyRenderAs: renderAs},399405 }400406 for _, pin := range pins {401407 locationID, err := ids.Claim("pb:pin:" + pin.ID)@@ -30,6 +30,7 @@ import (
3030 "strconv"3131 3232 "github.com/FelineStateMachine/atlas/internal/mgdoc"33+ "github.com/FelineStateMachine/atlas/internal/semconv"3334 )3435 3536 // Kind names Trek captures in a map's snapshot index.@@ -289,6 +290,7 @@ func buildGroups(capture *Capture, ids *mgdoc.IDSpace, scope string) ([]mgdoc.Gr
289290 DisplayType: "markers",290291 Visible: true,291292 Locations: make([]mgdoc.Location, 0, len(byType[featureType])),293+ Attrs: map[string]string{semconv.KeyRenderAs: semconv.RenderAsPin},292294 }293295 for _, feature := range byType[featureType] {294296 locationID, err := ids.Claim("trek:feature:" + strconv.FormatInt(feature.ID, 10))@@ -11,6 +11,7 @@ import (
1111 "strings"1212 1313 "github.com/FelineStateMachine/atlas/internal/bundle"14+ "github.com/FelineStateMachine/atlas/internal/semconv"1415 )1516 1617 // policyRevision orders builds of the same capture. The data has not moved@@ -22,7 +23,8 @@ import (
2223 // 1 first revisioned builds2324 // 2 merge resolution: subset names, adoption, one-to-one matches2425 // 3 origin provenance on every map; overlap merges across map slugs25-const policyRevision = 326+// 4 semantic conventions: attributes ride every payload27+const policyRevision = 42628 2729 // writeBundles packs each game into its own .atlas file, named by game,2830 // capture day, and stamp. The directory is a registry, not a mirror: a new@@ -64,6 +66,7 @@ func writeGameBundle(
6466 manifest := bundle.Manifest{6567 Format: bundle.Format,6668 FormatVersion: bundle.FormatVersion,69+ Conventions: semconv.Version,6770 Game: bundle.Game{Slug: game.Slug, Title: game.Title},6871 Version: bundle.Version{Revision: policyRevision},6972 TileGrid: bundle.TileGrid{@@ -8,6 +8,7 @@ import (
88 "errors"99 "flag"1010 "fmt"11+ "maps"1112 "os"1213 "path/filepath"1314 "regexp"@@ -18,6 +19,7 @@ import (
1819 "github.com/FelineStateMachine/atlas/internal/bundle"1920 "github.com/FelineStateMachine/atlas/internal/ignmap"2021 "github.com/FelineStateMachine/atlas/internal/pbmap"22+ "github.com/FelineStateMachine/atlas/internal/semconv"2123 "github.com/FelineStateMachine/atlas/internal/trekmap"2224 )2325 @@ -41,16 +43,17 @@ type snapshotIndex struct {
4143 }4244 4345 type rawMap struct {44- ID int64 `json:"id"`45- Title string `json:"title"`46- Slug string `json:"slug"`47- InitialLatitude float64 `json:"initial_latitude"`48- InitialLongitude float64 `json:"initial_longitude"`49- InitialZoom float64 `json:"initial_zoom"`50- Config rawConfig `json:"config"`51- Game rawGame `json:"game"`52- Groups []rawGroup `json:"groups"`53- Regions []rawRegion `json:"regions"`46+ ID int64 `json:"id"`47+ Title string `json:"title"`48+ Slug string `json:"slug"`49+ InitialLatitude float64 `json:"initial_latitude"`50+ InitialLongitude float64 `json:"initial_longitude"`51+ InitialZoom float64 `json:"initial_zoom"`52+ Config rawConfig `json:"config"`53+ Game rawGame `json:"game"`54+ Groups []rawGroup `json:"groups"`55+ Regions []rawRegion `json:"regions"`56+ Attrs map[string]string `json:"atlas_attrs"`5457 }5558 5659 type rawGame struct {@@ -77,23 +80,25 @@ type rawGroup struct {
7780 }7881 7982 type rawCategory struct {80- ID int64 `json:"id"`81- Title string `json:"title"`82- Icon string `json:"icon"`83- Color string `json:"color"`84- IconColor string `json:"icon_color"`85- DisplayType string `json:"display_type"`86- Visible bool `json:"visible"`87- Locations []rawLocation `json:"locations"`83+ ID int64 `json:"id"`84+ Title string `json:"title"`85+ Icon string `json:"icon"`86+ Color string `json:"color"`87+ IconColor string `json:"icon_color"`88+ DisplayType string `json:"display_type"`89+ Visible bool `json:"visible"`90+ Locations []rawLocation `json:"locations"`91+ Attrs map[string]string `json:"atlas_attrs"`8892 }8993 9094 type rawLocation struct {91- ID int64 `json:"id"`92- Title string `json:"title"`93- Description string `json:"description"`94- Latitude json.RawMessage `json:"latitude"`95- Longitude json.RawMessage `json:"longitude"`96- RegionID *int64 `json:"region_id"`95+ ID int64 `json:"id"`96+ Title string `json:"title"`97+ Description string `json:"description"`98+ Latitude json.RawMessage `json:"latitude"`99+ Longitude json.RawMessage `json:"longitude"`100+ RegionID *int64 `json:"region_id"`101+ Attrs map[string]string `json:"atlas_attrs"`97102 }98103 99104 type rawRegion struct {@@ -155,6 +160,10 @@ type catalogMap struct {
155160 Slug string `json:"slug"`156161 IconOutset string `json:"iconOutset,omitempty"`157162 Center coordinate `json:"center"`163+ // Attrs is the map's account of itself in the shared conventions --164+ // geometry, marker outset -- validated against the registry before a165+ // bundle is written.166+ Attrs map[string]string `json:"attrs,omitempty"`158167 // Grid is carried only by a map whose window is not the shared one, so the159168 // catalog reads the same as it did for every map that is.160169 Grid *mapGrid `json:"grid,omitempty"`@@ -259,6 +268,9 @@ type catalogCategory struct {
259268 DisplayType string `json:"displayType"`260269 Visible bool `json:"visible"`261270 Locations []catalogLocation `json:"locations"`271+ // Attrs speaks the conventions for this category -- how it renders, what272+ // its icon is -- beside the legacy fields it will one day retire.273+ Attrs map[string]string `json:"attrs,omitempty"`262274 }263275 264276 type catalogLocation struct {@@ -272,6 +284,10 @@ type catalogLocation struct {
272284 // layers, and is absent on maps that are not.273285 Shard int64 `json:"shard,omitempty"`274286 Links []catalogLink `json:"links,omitempty"`287+ // Attrs never rides the detail payload -- locations there are stripped288+ // -- and ships instead in the text file beside the description, read289+ // when a pin is opened.290+ Attrs map[string]string `json:"-"`275291 }276292 277293 // catalogLink is a cross-reference the source wrote as a mapgenie URL, resolved@@ -445,9 +461,68 @@ func buildGame(
445461 if err := attachGameIcons(gamePath, &game); err != nil {446462 return catalogGame{}, err447463 }464+ if err := speakConventions(&game); err != nil {465+ return catalogGame{}, fmt.Errorf("%s: %w", game.Slug, err)466+ }448467 return game, nil449468 }450469 470+// speakConventions makes every map answer in the shared vocabulary,471+// whatever its source knew how to say. A capture that declared its472+// attributes keeps them; one that predates the conventions -- every473+// MapGenie snapshot -- has them spoken for it from the same rules that474+// used to be unwritten: the display type it carried, the icon it resolved475+// to, the outset its curation chose. Then the whole game is held to the476+// registry, so an unregistered key or a foreign value fails here, one477+// build old, rather than riding into a bundle.478+func speakConventions(game *catalogGame) error {479+ for mapIndex := range game.Maps {480+ m := &game.Maps[mapIndex]481+ if m.IconOutset != "" {482+ m.Attrs = withAttr(m.Attrs, semconv.KeyIconOutset, m.IconOutset)483+ }484+ if err := semconv.Validate(semconv.EntityMap, m.Attrs); err != nil {485+ return fmt.Errorf("map %s: %w", m.Slug, err)486+ }487+ for groupIndex := range m.Groups {488+ categories := m.Groups[groupIndex].Categories489+ for categoryIndex := range categories {490+ category := &categories[categoryIndex]491+ if _, declared := category.Attrs[semconv.KeyRenderAs]; !declared {492+ category.Attrs = withAttr(category.Attrs, semconv.KeyRenderAs,493+ semconv.RenderAs(nil, category.DisplayType))494+ }495+ if category.IconAsset != "" {496+ kind := semconv.IconKindGlyph497+ if category.IconPicture {498+ kind = semconv.IconKindPicture499+ }500+ category.Attrs = withAttr(category.Attrs, semconv.KeyIconKind, kind)501+ }502+ if err := semconv.Validate(semconv.EntityCategory, category.Attrs); err != nil {503+ return fmt.Errorf("map %s category %q: %w", m.Slug, category.Title, err)504+ }505+ for _, location := range category.Locations {506+ if err := semconv.Validate(semconv.EntityLocation, location.Attrs); err != nil {507+ return fmt.Errorf("map %s pin %q: %w", m.Slug, location.Title, err)508+ }509+ }510+ }511+ }512+ }513+ return nil514+}515+516+// withAttr sets one attribute on a copy of the map, never the map itself: a517+// split sheet's pieces share their source's attributes by reference, and518+// speaking for one piece must not put words in another's mouth.519+func withAttr(attrs map[string]string, key, value string) map[string]string {520+ out := make(map[string]string, len(attrs)+1)521+ maps.Copy(out, attrs)522+ out[key] = value523+ return out524+}525+451526 func sortGameMaps(gameSlug string, maps []catalogMap) {452527 order := make(map[string]int)453528 for index, slug := range preferredMapOrder[gameSlug] {@@ -535,6 +610,7 @@ func buildMap(
535610 IconOutset: iconOutsetFor(raw),536611 Center: coordinate{Latitude: raw.InitialLatitude, Longitude: raw.InitialLongitude},537612 UpdatedAt: latest.CapturedAt,613+ Attrs: raw.Attrs,538614 }539615 if len(raw.Config.TileSets) == 0 {540616 return nil, "", fmt.Errorf("%w: no tile sets", errMapNotReady)@@ -614,6 +690,7 @@ func buildMap(
614690 IconColor: resolvedIconColor(rawGroup, rawCategory),615691 DisplayType: rawCategory.DisplayType,616692 Visible: rawCategory.Visible,693+ Attrs: rawCategory.Attrs,617694 }618695 for _, rawLocation := range rawCategory.Locations {619696 lat, err := number(rawLocation.Latitude)@@ -631,6 +708,7 @@ func buildMap(
631708 Latitude: lat,632709 Longitude: lng,633710 RegionID: rawLocation.RegionID,711+ Attrs: rawLocation.Attrs,634712 })635713 m.PinCount++636714 }@@ -31,6 +31,9 @@ type mapDetail struct {
3131 Variants []variant `json:"variants"`3232 Groups []catalogGroup `json:"groups"`3333 Zones []zone `json:"zones,omitempty"`34+ // Attrs is the map speaking the shared conventions -- its geometry, its35+ // marker outset -- for any reader that knows the vocabulary.36+ Attrs map[string]string `json:"attrs,omitempty"`3437 // Merged is the provenance of any other sources folded into this map.3538 // The viewer ignores it; it exists so the merged payload carries its own3639 // account.@@ -41,6 +44,10 @@ type mapDetail struct {
4144 type locationText struct {4245 Description string `json:"d,omitempty"`4346 Links []catalogLink `json:"l,omitempty"`47+ // Attrs carries a pin's own conventions -- its true planetary48+ // coordinates, when a source published them -- read when its card opens,49+ // like everything else here.50+ Attrs map[string]string `json:"a,omitempty"`4451 }4552 4653 // buildPayload splits one map three ways: its layers, categories and regions@@ -49,7 +56,7 @@ type locationText struct {
4956 func buildPayload(m catalogMap) (mapDetail, []byte, map[string]locationText) {5057 // Categories keep their identity; their locations travel packed, each5158 // carrying the position of its category in this same flattened order.52- detail := mapDetail{Grid: m.Grid, Variants: m.Variants, Zones: m.Zones, Merged: m.Merged}59+ detail := mapDetail{Grid: m.Grid, Variants: m.Variants, Zones: m.Zones, Attrs: m.Attrs, Merged: m.Merged}5360 var locations []bundle.Location5461 text := make(map[string]locationText)5562 var ordinal uint16@@ -73,10 +80,11 @@ func buildPayload(m catalogMap) (mapDetail, []byte, map[string]locationText) {
7380 Shard: location.Shard,7481 Owner: ordinal,7582 })76- if location.Description != "" || len(location.Links) > 0 {83+ if location.Description != "" || len(location.Links) > 0 || len(location.Attrs) > 0 {7784 text[strconv.FormatInt(location.ID, 10)] = locationText{7885 Description: location.Description,7986 Links: location.Links,87+ Attrs: location.Attrs,8088 }8189 }8290 }