'+i+""),L.setOptions(e,{attribution:o});var a=t.querySelector("map-link[rel=legend]");a&&(e._legendUrl=a.getAttribute("href"))},_getUnprojectedMapLatLngBounds:function(t){var e=(t=t||this._map).getPixelOrigin(),i=t.getPixelBounds(),o=t.unproject(e),n=t.unproject(i.getBottomLeft()),a=t.unproject(i.getTopRight()),s=t.unproject(e.add(t.getSize()));return L.latLngBounds(n,a).extend(s).extend(o)},_projectionMatches:function(t){t=t||this._map;var e=this.getProjection();return!(!t.options.projection||"WGS84"!==e&&t.options.projection!==e)},getQueryTemplates:function(){if(this._templatedLayer&&this._templatedLayer._queries)return this._templatedLayer._queries},_attachSkipButtons:function(t){let e,i,o=t.popup,n=t.target,a=o._container.getElementsByClassName("mapml-popup-content")[0];o._container.setAttribute("role","dialog"),a.setAttribute("tabindex","-1"),a.setAttribute("role","document"),o._count=0,o._source._eventParents?(e=o._source._eventParents[Object.keys(o._source._eventParents)[0]],i=o._source.group):e=o._source._templatedLayer,o._container.querySelector('nav[class="mapml-focus-buttons"]')&&(L.DomUtil.remove(o._container.querySelector('nav[class="mapml-focus-buttons"]')),L.DomUtil.remove(o._container.querySelector("hr")));let s=L.DomUtil.create("nav","mapml-focus-buttons"),r=L.DomUtil.create("button","mapml-popup-button",s);r.type="button",r.title="Focus Map",r.innerHTML="|❮",L.DomEvent.disableClickPropagation(r),L.DomEvent.on(r,"click",L.DomEvent.stop),L.DomEvent.on(r,"click",t=>{n.closePopup(),n._container.focus()},o);let l=L.DomUtil.create("button","mapml-popup-button",s);l.type="button",l.title="Previous Feature",l.innerHTML="❮",L.DomEvent.disableClickPropagation(l),L.DomEvent.on(l,"click",L.DomEvent.stop),L.DomEvent.on(l,"click",e._previousFeature,o);let m=L.DomUtil.create("p","mapml-feature-count",s),u=this._totalFeatureCount?this._totalFeatureCount:1;m.innerText=o._count+1+"/"+u;let p=L.DomUtil.create("button","mapml-popup-button",s);p.type="button",p.title="Next Feature",p.innerHTML="❯",L.DomEvent.disableClickPropagation(p),L.DomEvent.on(p,"click",L.DomEvent.stop),L.DomEvent.on(p,"click",e._nextFeature,o);let c=L.DomUtil.create("button","mapml-popup-button",s);c.type="button",c.title="Focus Controls",c.innerHTML="❯|",L.DomEvent.disableClickPropagation(c),L.DomEvent.on(c,"click",L.DomEvent.stop),L.DomEvent.on(c,"click",t=>{n.closePopup(),n._controlContainer.querySelector("A").focus()},o);let h=L.DomUtil.create("hr");function d(t){let e=t.originalEvent.path||t.originalEvent.composedPath(),a=9===t.originalEvent.keyCode,s=t.originalEvent.shiftKey;e[0].classList.contains("leaflet-popup-close-button")&&a&&!s||27===t.originalEvent.keyCode?(L.DomEvent.stop(t),n.closePopup(o),i.focus()):("Focus Map"===e[0].title||e[0].classList.contains("mapml-popup-content"))&&a&&s&&setTimeout(()=>{L.DomEvent.stop(t),n.closePopup(o),i.focus()},0)}function _(t){let e=t.originalEvent.path||t.originalEvent.composedPath(),i=9===t.originalEvent.keyCode,a=t.originalEvent.shiftKey;13===t.originalEvent.keyCode&&e[0].classList.contains("leaflet-popup-close-button")||27===t.originalEvent.keyCode?(L.DomEvent.stopPropagation(t),n._container.focus(),n.closePopup(o),27!==t.originalEvent.keyCode&&(n._popupClosed=!0)):i&&e[0].classList.contains("leaflet-popup-close-button")?n.closePopup(o):("Focus Map"===e[0].title||e[0].classList.contains("mapml-popup-content"))&&i&&a&&setTimeout(()=>{L.DomEvent.stop(t),n.closePopup(o),n._container.focus()},0)}o._navigationBar=s,o._content.appendChild(h),o._content.appendChild(s),a.focus(),i?(i.setAttribute("aria-expanded","true"),n.on("keydown",d)):n.on("keydown",_),n.on("popupclose",function t(e){e.popup===o&&(n.off("keydown",d),n.off("keydown",_),n.off("popupclose",t),i&&i.setAttribute("aria-expanded","false"))})}}),b=function(t,e,i){return t||e?new f(t,e,i):null},x=L.Layer.extend({onAdd:function(t){let e=t.getSize();(e.x>400||e.y>300)&&(this._container=L.DomUtil.create("table","mapml-debug",t._container),this._panel=E({className:"mapml-debug-panel",pane:this._container}),t.addLayer(this._panel)),this._grid=S({className:"mapml-debug-grid",pane:t._panes.mapPane,zIndex:400,tileSize:t.options.crs.options.crs.tile.bounds.max.x}),t.addLayer(this._grid),this._vectors=z({className:"mapml-debug-vectors",pane:t._panes.mapPane,toolPane:this._container}),t.addLayer(this._vectors)},onRemove:function(t){t.removeLayer(this._grid),t.removeLayer(this._vectors),this._panel&&(t.removeLayer(this._panel),L.DomUtil.remove(this._container))}}),v=function(){return new x},A=L.Layer.extend({initialize:function(t){L.setOptions(this,t)},onAdd:function(t){this._title=L.DomUtil.create("caption","mapml-debug-banner",this.options.pane),this._title.innerHTML="Debug mode",t.debug={},t.debug._infoContainer=this._debugContainer=L.DomUtil.create("tbody","mapml-debug-panel",this.options.pane);let e=t.debug._infoContainer;t.debug._tileCoord=L.DomUtil.create("tr","mapml-debug-coordinates",e),t.debug._tileMatrixCoord=L.DomUtil.create("tr","mapml-debug-coordinates",e),t.debug._mapCoord=L.DomUtil.create("tr","mapml-debug-coordinates",e),t.debug._tcrsCoord=L.DomUtil.create("tr","mapml-debug-coordinates",e),t.debug._pcrsCoord=L.DomUtil.create("tr","mapml-debug-coordinates",e),t.debug._gcrsCoord=L.DomUtil.create("tr","mapml-debug-coordinates",e),this._map.on("mousemove",this._updateCoords)},onRemove:function(){L.DomUtil.remove(this._title),this._debugContainer&&(L.DomUtil.remove(this._debugContainer),this._map.off("mousemove",this._updateCoords))},_updateCoords:function(t){if(this.contextMenu._visible)return;let e=this.options.mapEl,i=e._map.project(t.latlng),o=e._map.options.crs.scale(+e.zoom),n=e._map.options.crs.transformation.untransform(i,o),a=e._map.options.crs.options.crs.tile.bounds.max.x,s=i.x%a,r=i.y%a;s<0&&(s+=a),r<0&&(r+=a),this.debug._tileCoord.innerHTML=`\n | tile: | \n i: ${Math.trunc(s)}, | \n j: ${Math.trunc(r)} | \n `,this.debug._mapCoord.innerHTML=`\n map: | \n i: ${Math.trunc(t.containerPoint.x)}, | \n j: ${Math.trunc(t.containerPoint.y)} | \n `,this.debug._gcrsCoord.innerHTML=`\n gcrs: | \n lon: ${t.latlng.lng.toFixed(6)}, | \n lat: ${t.latlng.lat.toFixed(6)} | \n `,this.debug._tcrsCoord.innerHTML=`\n tcrs: | \n x: ${Math.trunc(i.x)}, | \n y: ${Math.trunc(i.y)} | \n `,this.debug._tileMatrixCoord.innerHTML=`\n tilematrix: | \n column: ${Math.trunc(i.x/a)}, | \n row: ${Math.trunc(i.y/a)} | \n `,this.debug._pcrsCoord.innerHTML=`\n pcrs: | \n easting: ${n.x.toFixed(2)}, | \n northing: ${n.y.toFixed(2)} | \n `}}),E=function(t){return new A(t)},C=L.GridLayer.extend({initialize:function(t){L.setOptions(this,t),L.GridLayer.prototype.initialize.call(this,this._map)},createTile:function(t){let e=L.DomUtil.create("div","mapml-debug-tile");return e.setAttribute("col",t.x),e.setAttribute("row",t.y),e.setAttribute("zoom",t.z),e.innerHTML=[`col: ${t.x}`,`row: ${t.y}`,`zoom: ${t.z}`].join(", "),e.style.outline="1px dashed red",e}}),S=function(t){return new C(t)},T=L.LayerGroup.extend({initialize:function(t){L.setOptions(this,t),L.LayerGroup.prototype.initialize.call(this,this._map,t)},onAdd:function(t){t.on("overlayremove",this._mapLayerUpdate,this),t.on("overlayadd",this._mapLayerUpdate,this);let e=t.options.crs.transformation.transform(L.point(0,0),t.options.crs.scale(0));this._centerVector=L.circle(t.options.crs.pointToLatLng(e,0),{radius:250}),this._centerVector.bindTooltip("Projection Center"),this._addBounds(t)},onRemove:function(t){this.clearLayers()},_addBounds:function(t){let e=Object.keys(t._layers),i=t._layers,o=["#FF5733","#8DFF33","#3397FF","#E433FF","#F3FF33"],n=0;this.addLayer(this._centerVector);for(let t of e)if(i[t].layerBounds){let e=[i[t].layerBounds.min,L.point(i[t].layerBounds.max.x,i[t].layerBounds.min.y),i[t].layerBounds.max,L.point(i[t].layerBounds.min.x,i[t].layerBounds.max.y)],a=P(e,{color:o[n%o.length],weight:2,opacity:1,fillOpacity:.01,fill:!0});i[t].options._leafletLayer&&a.bindTooltip(i[t].options._leafletLayer._title,{sticky:!0}),this.addLayer(a),n++}if(t.totalLayerBounds){let e=[t.totalLayerBounds.min,L.point(t.totalLayerBounds.max.x,t.totalLayerBounds.min.y),t.totalLayerBounds.max,L.point(t.totalLayerBounds.min.x,t.totalLayerBounds.max.y)],i=P(e,{color:"#808080",weight:5,opacity:.5,fill:!1});this.addLayer(i)}},_mapLayerUpdate:function(t){this.clearLayers(),this._addBounds(t.target)}}),z=function(t){return new T(t)},k=L.Path.extend({options:{className:"mapml-debug-extent"},initialize:function(t,e){this._locations=t,L.setOptions(this,e)},_project:function(){this._rings=[];let t=this._map.options.crs.scale(this._map.getZoom()),e=this._map;for(let i=0;i=0;e--){var i=t[e]._layer;if(t[e].checked&&i.queryable)return i}},_queryTopLayerAtMapCenter:function(t){setTimeout(()=>{!this._map.isFocused||this._map._popupClosed||" "!==t.originalEvent.key&&13!=+t.originalEvent.keyCode?delete this._map._popupClosed:this._map.fire("click",{latlng:this._map.getCenter(),layerPoint:this._map.latLngToLayerPoint(this._map.getCenter()),containerPoint:this._map.latLngToContainerPoint(this._map.getCenter())})},0)},_queryTopLayer:function(t){var e=this._getTopQueryableLayer();e&&this._query(t,e)},_query(t,e){var i={},o=e.getQueryTemplates()[0],n=t.target.getZoom(),a=this._map,s=e.crs,r=a.options.crs.options.crs.tile.bounds.max.x,l=e._container,m={autoClose:!1,autoPan:!0,maxHeight:.5*a.getSize().y-50},u=function(t){return s.transformation.untransform(t,s.scale(n))},p=function(t){return s.unproject(s.transformation.untransform(t,s.scale(n)),n)},c=s.latLngToPoint(t.latlng,n),h=c.divideBy(r).floor(),d=new L.Bounds(c.divideBy(r).floor().multiplyBy(r),c.divideBy(r).ceil().multiplyBy(r));for(var _ in i[o.query.tilei]=c.x.toFixed()-h.x*r,i[o.query.tilej]=c.y.toFixed()-h.y*r,i[o.query.mapi]=a.getSize().divideBy(2).x.toFixed(),i[o.query.mapj]=a.getSize().divideBy(2).y.toFixed(),i[o.query.pixelleft]=s.pointToLatLng(c,n).lng,i[o.query.pixeltop]=s.pointToLatLng(c,n).lat,i[o.query.pixelright]=s.pointToLatLng(c.add([1,1]),n).lng,i[o.query.pixelbottom]=s.pointToLatLng(c.add([1,1]),n).lat,i[o.query.column]=h.x,i[o.query.row]=h.y,i[o.query.x]=c.x.toFixed(),i[o.query.y]=c.y.toFixed(),i[o.query.easting]=u(c).x,i[o.query.northing]=u(c).y,i[o.query.longitude]=p(c).lng,i[o.query.latitude]=p(c).lat,i[o.query.zoom]=n,i[o.query.width]=a.getSize().x,i[o.query.height]=a.getSize().y,i[o.query.mapbottom]=u(c.add(a.getSize().divideBy(2))).y,i[o.query.mapleft]=u(c.subtract(a.getSize().divideBy(2))).x,i[o.query.maptop]=u(c.subtract(a.getSize().divideBy(2))).y,i[o.query.mapright]=u(c.add(a.getSize().divideBy(2))).x,i[o.query.tilebottom]=u(d.max).y,i[o.query.tileleft]=u(d.min).x,i[o.query.tiletop]=u(d.min).y,i[o.query.tileright]=u(d.max).x,o.query)["mapi","mapj","tilei","tilej","row","col","x","y","easting","northing","longitude","latitude","width","height","zoom","mapleft","mapright",",maptop","mapbottom","tileleft","tileright","tiletop","tilebottom","pixeltop","pixelbottom","pixelleft","pixelright"].indexOf(_)<0&&(i[_]=o.query[_]);let y,g=this._map.project(t.latlng),f=this._map.options.crs.scale(this._map.getZoom()),b=this._map.options.crs.transformation.untransform(g,f);o.layerBounds.contains(b)&&fetch(L.Util.template(o.template,i),{redirect:"follow"}).then(t=>{if(y=t.headers.get("Content-Type"),t.status>=200&&t.status<300)return t.text();throw new Error(t.status)}).then(i=>y.startsWith("text/mapml")?function(t,i){let o=(new DOMParser).parseFromString(t,"application/xml");for(let t of o.querySelectorAll("map-feature"))if(!t.querySelector("map-geometry")){let e=document.createElement("map-geometry"),o=document.createElement("map-point"),n=document.createElement("map-coordinates");e.setAttribute("cs","gcrs"),n.innerHTML=`${i.lng} ${i.lat}`,o.appendChild(n),e.appendChild(o),t.appendChild(e)}let n=M.mapMlFeatures(o,{renderer:M.featureRenderer(),pane:l,projection:a.options.projection,_leafletLayer:e,query:!0,static:!0});n.addTo(a);let s=L.DomUtil.create("div","mapml-popup-content"),r=L.DomUtil.create("iframe");r.style="border: none",r.srcdoc=o.querySelector("map-feature map-properties").innerHTML,r.setAttribute("sandbox","allow-same-origin allow-forms"),s.appendChild(r),e._totalFeatureCount=o.querySelectorAll("map-feature").length,e.bindPopup(s,m).openPopup(i),e.on("popupclose",function(){a.removeLayer(n)}),n.showPaginationFeature({i:0,popup:e._popup})}(i,t.latlng):function(t,e,i){let o=L.DomUtil.create("div","mapml-popup-content"),n=L.DomUtil.create("iframe");n.style="border: none",n.srcdoc=t,n.setAttribute("sandbox","allow-same-origin allow-forms"),o.appendChild(n),e.bindPopup(o,m).openPopup(i)}(i,e,t.latlng)).catch(t=>{console.log("Looks like there was a problem. Status: "+t.message)})}}),I=L.Handler.extend({_touchstart:L.Browser.msPointer?"MSPointerDown":L.Browser.pointer?"pointerdown":"touchstart",initialize:function(t){L.Handler.prototype.initialize.call(this,t),this._items=[{text:M.options.locale.cmBack+" (B)",callback:this._goBack},{text:M.options.locale.cmForward+" (F)",callback:this._goForward},{text:M.options.locale.cmReload+" (R)",callback:this._reload},{spacer:"-"},{text:M.options.locale.cmToggleControls+" (T)",callback:this._toggleControls},{text:M.options.locale.cmCopyCoords+" (C)",callback:this._copyCoords,hideOnSelect:!1,popup:!0,submenu:[{text:"tile",callback:this._copyTile},{text:"tilematrix",callback:this._copyTileMatrix},{spacer:"-"},{text:"map",callback:this._copyMap},{spacer:"-"},{text:"tcrs",callback:this._copyTCRS},{text:"pcrs",callback:this._copyPCRS},{text:"gcrs",callback:this._copyGCRS},{spacer:"-"},{text:M.options.locale.cmCopyAll,callback:this._copyAllCoords}]},{text:M.options.locale.cmToggleDebug+" (D)",callback:this._toggleDebug},{text:M.options.locale.cmCopyMapML+" (M)",callback:this._copyMapML},{text:M.options.locale.cmViewSource+" (V)",callback:this._viewSource}],this._layerItems=[{text:M.options.locale.lmZoomToLayer+" (Z)",callback:this._zoomToLayer},{text:M.options.locale.lmCopyExtent+" (C)",callback:this._copyLayerExtent}],this._mapMenuVisible=!1,this._keyboardEvent=!1,this._container=L.DomUtil.create("div","mapml-contextmenu",t._container),this._container.setAttribute("hidden","");for(let t=0;t<6;t++)this._items[t].el=this._createItem(this._container,this._items[t]);this._coordMenu=L.DomUtil.create("div","mapml-contextmenu mapml-submenu",this._container),this._coordMenu.id="mapml-copy-submenu",this._coordMenu.setAttribute("hidden",""),this._clickEvent=null;for(let t=0;t`;e._copyData(a)},_zoomToLayer:function(t){(t instanceof KeyboardEvent?this._map.contextMenu:this.contextMenu)._layerClicked.layer._layerEl.focus()},_goForward:function(t){(t instanceof KeyboardEvent?this._map.options.mapEl:this.options.mapEl).forward()},_goBack:function(t){(t instanceof KeyboardEvent?this._map.options.mapEl:this.options.mapEl).back()},_reload:function(t){(t instanceof KeyboardEvent?this._map.options.mapEl:this.options.mapEl).reload()},_toggleControls:function(t){(t instanceof KeyboardEvent?this._map.options.mapEl:this.options.mapEl)._toggleControls()},_copyMapML:function(t){let e=t instanceof KeyboardEvent?this._map.contextMenu:this.contextMenu,i=t instanceof KeyboardEvent?this._map.options.mapEl:this.options.mapEl;e._copyData(i.outerHTML.replace(/.*?<\/div>|