|
|
Highlight
<H1> | <H2> | <H3> | <H4> | <H5> | <H6> | <B> | <U> | <I> | <EM> | <STRONG> | Total | 1 | 6 | 9 | 0 | 0 | 0 | 0 | 0 | 60 | 0 | 7 | 83 | Excellent! The page is using HTML headings (<H1> - <H6>) and inline emphasis tags (<EM><B><I><EM><STRONG>)
|
<H1> (1) | | <H2> (6) | Poznaj nowoczesne formy finansowania stworzone dla dynamicznych przedsiębiorców i klientów indywidualnych, które pozwolą Ci pozostać w ruchu. Postaw na elastyczność inteligentnych rozwiązań. Czym jest KINTO? Poznaj naszą wizję PRODUKTY KINTO Szeroka sieć dilerska Wypełnij formularz, a my skontaktujemy się z Tobą
| <H3> (9) | Elastyczność Komfort Doświadczenie Zaufanie LEASINGNIŻSZYCH RAT LEASINGKONSUMENCKI KINTO WYNAJEMI ZARZĄDZANIE FLOTĄ LEASINGDLA PRACOWNIKÓW NAJEM
| <I> (60) | this._layersMaxZoom&&this.setZoom(this._layersMaxZoom),void 0===this.options.minZoom&&this._layersMinZoom&&this.getZoom()=2&&e[0]instanceof B&&e[0].equals(e[i-1])&&e.pop(),e},_setLatLngs:function(t){Oi.prototype._setLatLngs.call(this,t),gi(this._latlngs)&&(this._latlngs=[this._latlngs])},_defaultShape:function(){return gi(this._latlngs[0])?this._latlngs[0]:this._latlngs[0][0]},_clipPoints:function(){var t=this._renderer._bounds,e=this.options.weight,i=new P(e,e);if(t=new D(t.min.subtract(i),t.max.add(i)),this._parts=[],this._pxBounds&&this._pxBounds.intersects(t))if(this.options.noClip)this._parts=this._rings;else for(var n,r=0,o=this._rings.length;rt.y!=n.y>t.y&&t.x0&&r.push(r[0].slice()),r}function qi(t,i){return t.feature?e({},t.feature,{geometry:i}):Hi(i)}function Hi(t){return"Feature"===t.type||"FeatureCollection"===t.type?t:{type:"Feature",properties:{},geometry:t}}var Wi={toGeoJSON:function(t){return qi(this,{type:"Point",coordinates:Gi(this.getLatLng(),t)})}};function Yi(t,e){return new Fi(t,e)}ki.include(Wi),Ri.include(Wi),zi.include(Wi),Oi.include({toGeoJSON:function(t){var e=!gi(this._latlngs);return qi(this,{type:(e?"Multi":"")+"LineString",coordinates:Zi(this._latlngs,e?1:0,!1,t)})}}),Bi.include({toGeoJSON:function(t){var e=!gi(this._latlngs),i=e&&!gi(this._latlngs[0]),n=Zi(this._latlngs,i?2:e?1:0,!0,t);return e||(n=[n]),qi(this,{type:(i?"Multi":"")+"Polygon",coordinates:n})}}),Ai.include({toMultiPoint:function(t){var e=[];return this.eachLayer((function(i){e.push(i.toGeoJSON(t).geometry.coordinates)})),qi(this,{type:"MultiPoint",coordinates:e})},toGeoJSON:function(t){var e=this.feature&&this.feature.geometry&&this.feature.geometry.type;if("MultiPoint"===e)return this.toMultiPoint(t);var i="GeometryCollection"===e,n=[];return this.eachLayer((function(e){if(e.toGeoJSON){var r=e.toGeoJSON(t);if(i)n.push(r.geometry);else{var o=Hi(r);"FeatureCollection"===o.type?n.push.apply(n,o.features):n.push(o)}}})),i?qi(this,{geometries:n,type:"GeometryCollection"}):{type:"FeatureCollection",features:n}}});var Xi=Yi,Ki=Ci.extend({options:{opacity:1,alt:"",interactive:!1,crossOrigin:!1,errorOverlayUrl:"",zIndex:1,className:""},initialize:function(t,e,i){this._url=t,this._bounds=O(e),h(this,i)},onAdd:function(){this._image||(this._initImage(),this.options.opacity0?r:[e.src]}else{_(this._url)||(this._url=[this._url]),!this.options.keepAspectRatio&&Object.prototype.hasOwnProperty.call(e.style,"objectFit")&&(e.style.objectFit="fill"),e.autoplay=!!this.options.autoplay,e.loop=!!this.options.loop,e.muted=!!this.options.muted,e.playsInline=!!this.options.playsInline;for(var s=0;s×',Ae(n,"click",(function(t){Be(t),this.close()}),this)}},_updateLayout:function(){var t=this._contentNode,e=t.style;e.width="",e.whiteSpace="nowrap";var i=t.offsetWidth;i=Math.min(i,this.options.maxWidth),i=Math.max(i,this.options.minWidth),e.width=i+1+"px",e.whiteSpace="",e.height="";var n=t.offsetHeight,r=this.options.maxHeight,o="leaflet-popup-scrolled";r&&n>r?(e.height=r+"px",ue(t,o)):he(t,o),this._containerWidth=this._container.offsetWidth},_animateZoom:function(t){var e=this._map._latLngToNewLayerPoint(this._latlng,t.zoom,t.center),i=this._getAnchor();ye(this._container,e.add(i))},_adjustPan:function(){if(this.options.autoPan)if(this._map._panAnim&&this._map._panAnim.stop(),this._autopanning)this._autopanning=!1;else{var t=this._map,e=parseInt(re(this._container,"marginBottom"),10)||0,i=this._container.offsetHeight+e,n=this._containerWidth,r=new P(this._containerLeft,-i-this._containerBottom);r._add(ve(this._container));var o=t.layerPointToContainerPoint(r),s=k(this.options.autoPanPadding),a=k(this.options.autoPanPaddingTopLeft||s),l=k(this.options.autoPanPaddingBottomRight||s),c=t.getSize(),d=0,u=0;o.x+n+l.x>c.x&&(d=o.x+n-c.x+l.x),o.x-d-a.xc.y&&(u=o.y+i-c.y+l.y),o.y-u-a.ythis.options.maxZoom||in&&this._retainParent(r,o,s,n))},_retainChildren:function(t,e,i,n){for(var r=2*t;rthis.options.maxZoom||void 0!==this.options.minZoom&&r1)this._setView(t,i);else{for(var u=r.min.y;ui.max.x)||!e.wrapLat&&(t.yi.max.y))return!1}if(!this.options.bounds)return!0;var n=this._tileCoordsToBounds(t);return O(this.options.bounds).overlaps(n)},_keyToBounds:function(t){return this._tileCoordsToBounds(this._keyToTileCoords(t))},_tileCoordsToNwSe:function(t){var e=this._map,i=this.getTileSize(),n=t.scaleBy(i),r=n.add(i);return[e.unproject(n,t.z),e.unproject(r,t.z)]},_tileCoordsToBounds:function(t){var e=this._tileCoordsToNwSe(t),i=new R(e[0],e[1]);return this.options.noWrap||(i=this._map.wrapLatLngBounds(i)),i},_tileCoordsToKey:function(t){return t.x+":"+t.y+":"+t.z},_keyToTileCoords:function(t){var e=t.split(":"),i=new P(+e[0],+e[1]);return i.z=+e[2],i},_removeTile:function(t){var e=this._tiles[t];e&&(se(e.el),delete this._tiles[t],this.fire("tileunload",{tile:e.el,coords:this._keyToTileCoords(t)}))},_initTile:function(t){ue(t,"leaflet-tile");var e=this.getTileSize();t.style.width=e.x+"px",t.style.height=e.y+"px",t.onselectstart=l,t.onmousemove=l,Dt.ielt9&&this.options.opacity0?(e.tileSize=Math.floor(e.tileSize/2),e.zoomReverse?(e.zoomOffset--,e.minZoom=Math.min(e.maxZoom,e.minZoom+1)):(e.zoomOffset++,e.maxZoom=Math.max(e.minZoom,e.maxZoom-1)),e.minZoom=Math.max(0,e.minZoom)):e.zoomReverse?e.minZoom=Math.min(e.maxZoom,e.minZoom):e.maxZoom=Math.max(e.minZoom,e.maxZoom),"string"==typeof e.subdomains&&(e.subdomains=e.subdomains.split("")),this.on("tileunload",this._onTileRemove)},setUrl:function(t,e){return this._url===t&&void 0===e&&(e=!0),this._url=t,e||this.redraw(),this},createTile:function(t,e){var i=document.createElement("img");return Ae(i,"load",n(this._tileOnLoad,this,e,i)),Ae(i,"error",n(this._tileOnError,this,e,i)),(this.options.crossOrigin||""===this.options.crossOrigin)&&(i.crossOrigin=!0===this.options.crossOrigin?"":this.options.crossOrigin),"string"==typeof this.options.referrerPolicy&&(i.referrerPolicy=this.options.referrerPolicy),i.alt="",i.src=this.getTileUrl(t),i},getTileUrl:function(t){var i={r:Dt.retina?"@2x":"",s:this._getSubdomain(t),x:t.x,y:t.y,z:this._getZoomForUrl()};if(this._map&&!this._map.options.crs.infinite){var n=this._globalTileRange.max.y-t.y;this.options.tms&&(i.y=n),i["-y"]=n}return m(this._url,e(i,this.options))},_tileOnLoad:function(t,e){Dt.ielt9?setTimeout(n(t,this,null,e),0):t(null,e)},_tileOnError:function(t,e,i){var n=this.options.errorTileUrl;n&&e.getAttribute("src")!==n&&(e.src=n),t(i,e)},_onTileRemove:function(t){t.tile.onload=null},_getZoomForUrl:function(){var t=this._tileZoom,e=this.options.maxZoom;return this.options.zoomReverse&&(t=e-t),t+this.options.zoomOffset},_getSubdomain:function(t){var e=Math.abs(t.x+t.y)%this.options.subdomains.length;return this.options.subdomains[e]},_abortLoading:function(){var t,e;for(t in this._tiles)if(this._tiles[t].coords.z!==this._tileZoom&&((e=this._tiles[t].el).onload=l,e.onerror=l,!e.complete)){e.src=y;var i=this._tiles[t].coords;se(e),delete this._tiles[t],this.fire("tileabort",{tile:e,coords:i})}},_removeTile:function(t){var e=this._tiles[t];if(e)return e.el.setAttribute("src",y),on.prototype._removeTile.call(this,t)},_tileReady:function(t,e,i){if(this._map&&(!i||i.getAttribute("src")!==y))return on.prototype._tileReady.call(this,t,e,i)}});function an(t,e){return new sn(t,e)}var ln=sn.extend({defaultWmsParams:{service:"WMS",request:"GetMap",layers:"",styles:"",format:"image/jpeg",transparent:!1,version:"1.1.1"},options:{crs:null,uppercase:!1},initialize:function(t,i){this._url=t;var n=e({},this.defaultWmsParams);for(var r in i)r in this.options||(n[r]=i[r]);var o=(i=h(this,i)).detectRetina&&Dt.retina?2:1,s=this.getTileSize();n.width=s.x*o,n.height=s.y*o,this.wmsParams=n},onAdd:function(t){this._crs=this.options.crs||t.options.crs,this._wmsVersion=parseFloat(this.wmsParams.version);var e=this._wmsVersion>=1.3?"crs":"srs";this.wmsParams[e]=this._crs.code,sn.prototype.onAdd.call(this,t)},getTileUrl:function(t){var e=this._tileCoordsToNwSe(t),i=this._crs,n=z(i.project(e[0]),i.project(e[1])),r=n.min,o=n.max,s=(this._wmsVersion>=1.3&&this._crs===Ei?[r.y,r.x,o.y,o.x]:[r.x,r.y,o.x,o.y]).join(","),a=sn.prototype.getTileUrl.call(this,t);return a+p(this.wmsParams,a,this.options.uppercase)+(this.options.uppercase?"&BBOX=":"&bbox=")+s},setParams:function(t,i){return e(this.wmsParams,t),i||this.redraw(),this}});sn.WMS=ln,an.wms=function(t,e){return new ln(t,e)};var cn=Ci.extend({options:{padding:.1},initialize:function(t){h(this,t),o(this),this._layers=this._layers||{}},onAdd:function(){this._container||(this._initContainer(),ue(this._container,"leaflet-zoom-animated")),this.getPane().appendChild(this._container),this._update(),this.on("update",this._updatePaths,this)},onRemove:function(){this.off("update",this._updatePaths,this),this._destroyContainer()},getEvents:function(){var t={viewreset:this._reset,zoom:this._onZoom,moveend:this._update,zoomend:this._onZoomEnd};return this._zoomAnimated&&(t.zoomanim=this._onAnimZoom),t},_onAnimZoom:function(t){this._updateTransform(t.center,t.zoom)},_onZoom:function(){this._updateTransform(this._map.getCenter(),this._map.getZoom())},_updateTransform:function(t,e){var i=this._map.getZoomScale(e,this._zoom),n=this._map.getSize().multiplyBy(.5+this.options.padding),r=this._map.project(this._center,e),o=n.multiplyBy(-i).add(r).subtract(this._map._getNewPixelOrigin(t,e));Dt.any3d?ge(this._container,o,i):ye(this._container,o)},_reset:function(){for(var t in this._update(),this._updateTransform(this._center,this._zoom),this._layers)this._layers[t]._reset()},_onZoomEnd:function(){for(var t in this._layers)this._layers[t]._project()},_updatePaths:function(){for(var t in this._layers)this._layers[t]._update()},_update:function(){var t=this.options.padding,e=this._map.getSize(),i=this._map.containerPointToLayerPoint(e.multiplyBy(-t)).round();this._bounds=new D(i,i.add(e.multiplyBy(1+2*t)).round()),this._center=this._map.getCenter(),this._zoom=this._map.getZoom()}}),dn=cn.extend({options:{tolerance:0},getEvents:function(){var t=cn.prototype.getEvents.call(this);return t.viewprereset=this._onViewPreReset,t},_onViewPreReset:function(){this._postponeUpdatePaths=!0},onAdd:function(){cn.prototype.onAdd.call(this),this._draw()},_initContainer:function(){var t=this._container=document.createElement("canvas");Ae(t,"mousemove",this._onMouseMove,this),Ae(t,"click dblclick mousedown mouseup contextmenu",this._onClick,this),Ae(t,"mouseout",this._handleMouseOut,this),t._leaflet_disable_events=!0,this._ctx=t.getContext("2d")},_destroyContainer:function(){E(this._redrawRequest),delete this._ctx,se(this._container),Le(this._container),delete this._container},_updatePaths:function(){if(!this._postponeUpdatePaths){for(var t in this._redrawBounds=null,this._layers)this._layers[t]._update();this._redraw()}},_update:function(){if(!this._map._animatingZoom||!this._bounds){cn.prototype._update.call(this);var t=this._bounds,e=this._container,i=t.getSize(),n=Dt.retina?2:1;ye(e,t.min),e.width=n*i.x,e.height=n*i.y,e.style.width=i.x+"px",e.style.height=i.y+"px",Dt.retina&&this._ctx.scale(2,2),this._ctx.translate(-t.min.x,-t.min.y),this.fire("update")}},_reset:function(){cn.prototype._reset.call(this),this._postponeUpdatePaths&&(this._postponeUpdatePaths=!1,this._updatePaths())},_initPath:function(t){this._updateDashArray(t),this._layers[o(t)]=t;var e=t._order={layer:t,prev:this._drawLast,next:null};this._drawLast&&(this._drawLast.next=e),this._drawLast=e,this._drawFirst=this._drawFirst||this._drawLast},_addPath:function(t){this._requestRedraw(t)},_removePath:function(t){var e=t._order,i=e.next,n=e.prev;i?i.prev=n:this._drawLast=n,n?n.next=i:this._drawFirst=i,delete t._order,delete this._layers[o(t)],this._requestRedraw(t)},_updatePath:function(t){this._extendRedrawBounds(t),t._project(),t._update(),this._requestRedraw(t)},_updateStyle:function(t){this._updateDashArray(t),this._requestRedraw(t)},_updateDashArray:function(t){if("string"==typeof t.options.dashArray){var e,i,n=t.options.dashArray.split(/[, ]+/),r=[];for(i=0;i')}}catch(t){}return function(t){return document.createElement("')}}(),pn={_initContainer:function(){this._container=oe("div","leaflet-vml-container")},_update:function(){this._map._animatingZoom||(cn.prototype._update.call(this),this.fire("update"))},_initPath:function(t){var e=t._container=hn("shape");ue(e,"leaflet-vml-shape "+(this.options.className||"")),e.coordsize="1 1",t._path=hn("path"),e.appendChild(t._path),this._updateStyle(t),this._layers[o(t)]=t},_addPath:function(t){var e=t._container;this._container.appendChild(e),t.options.interactive&&t.addInteractiveTarget(e)},_removePath:function(t){var e=t._container;se(e),t.removeInteractiveTarget(e),delete this._layers[o(t)]},_updateStyle:function(t){var e=t._stroke,i=t._fill,n=t.options,r=t._container;r.stroked=!!n.stroke,r.filled=!!n.fill,n.stroke?(e||(e=t._stroke=hn("stroke")),r.appendChild(e),e.weight=n.weight+"px",e.color=n.color,e.opacity=n.opacity,n.dashArray?e.dashStyle=_(n.dashArray)?n.dashArray.join(" "):n.dashArray.replace(/( *, *)/g," "):e.dashStyle="",e.endcap=n.lineCap.replace("butt","flat"),e.joinstyle=n.lineJoin):e&&(r.removeChild(e),t._stroke=null),n.fill?(i||(i=t._fill=hn("fill")),r.appendChild(i),i.color=n.fillColor||n.color,i.opacity=n.fillOpacity):i&&(r.removeChild(i),t._fill=null)},_updateCircle:function(t){var e=t._point.round(),i=Math.round(t._radius),n=Math.round(t._radiusY||i);this._setPath(t,t._empty()?"M0 0":"AL "+e.x+","+e.y+" "+i+","+n+" 0,23592600")},_setPath:function(t,e){t._path.v=e},_bringToFront:function(t){le(t._container)},_bringToBack:function(t){ce(t._container)}},fn=Dt.vml?hn:Y,mn=cn.extend({_initContainer:function(){this._container=fn("svg"),this._container.setAttribute("pointer-events","none"),this._rootGroup=fn("g"),this._container.appendChild(this._rootGroup)},_destroyContainer:function(){se(this._container),Le(this._container),delete this._container,delete this._rootGroup,delete this._svgSize},_update:function(){if(!this._map._animatingZoom||!this._bounds){cn.prototype._update.call(this);var t=this._bounds,e=t.getSize(),i=this._container;this._svgSize&&this._svgSize.equals(e)||(this._svgSize=e,i.setAttribute("width",e.x),i.setAttribute("height",e.y)),ye(i,t.min),i.setAttribute("viewBox",[t.min.x,t.min.y,e.x,e.y].join(" ")),this.fire("update")}},_initPath:function(t){var e=t._path=fn("path");t.options.className&&ue(e,t.options.className),t.options.interactive&&ue(e,"leaflet-interactive"),this._updateStyle(t),this._layers[o(t)]=t},_addPath:function(t){this._rootGroup||this._initContainer(),this._rootGroup.appendChild(t._path),t.addInteractiveTarget(t._path)},_removePath:function(t){se(t._path),t.removeInteractiveTarget(t._path),delete this._layers[o(t)]},_updatePath:function(t){t._project(),t._update()},_updateStyle:function(t){var e=t._path,i=t.options;e&&(i.stroke?(e.setAttribute("stroke",i.color),e.setAttribute("stroke-opacity",i.opacity),e.setAttribute("stroke-width",i.weight),e.setAttribute("stroke-linecap",i.lineCap),e.setAttribute("stroke-linejoin",i.lineJoin),i.dashArray?e.setAttribute("stroke-dasharray",i.dashArray):e.removeAttribute("stroke-dasharray"),i.dashOffset?e.setAttribute("stroke-dashoffset",i.dashOffset):e.removeAttribute("stroke-dashoffset")):e.setAttribute("stroke","none"),i.fill?(e.setAttribute("fill",i.fillColor||i.color),e.setAttribute("fill-opacity",i.fillOpacity),e.setAttribute("fill-rule",i.fillRule||"evenodd")):e.setAttribute("fill","none"))},_updatePoly:function(t,e){this._setPath(t,X(t._parts,e))},_updateCircle:function(t){var e=t._point,i=Math.max(Math.round(t._radius),1),n="a"+i+","+(Math.max(Math.round(t._radiusY),1)||i)+" 0 1,0 ",r=t._empty()?"M0 0":"M"+(e.x-i)+","+e.y+n+2*i+",0 "+n+2*-i+",0 ";this._setPath(t,r)},_setPath:function(t,e){t._path.setAttribute("d",e)},_bringToFront:function(t){le(t._path)},_bringToBack:function(t){ce(t._path)}});function _n(t){return Dt.svg||Dt.vml?new mn(t):null}Dt.vml&&mn.include(pn),He.include({getRenderer:function(t){var e=t.options.renderer||this._getPaneRenderer(t.options.pane)||this.options.renderer||this._renderer;return e||(e=this._renderer=this._createRenderer()),this.hasLayer(e)||this.addLayer(e),e},_getPaneRenderer:function(t){if("overlayPane"===t||void 0===t)return!1;var e=this._paneRenderers[t];return void 0===e&&(e=this._createRenderer({pane:t}),this._paneRenderers[t]=e),e},_createRenderer:function(t){return this.options.preferCanvas&&un(t)||_n(t)}});var gn=Bi.extend({initialize:function(t,e){Bi.prototype.initialize.call(this,this._boundsToLatLngs(t),e)},setBounds:function(t){return this.setLatLngs(this._boundsToLatLngs(t))},_boundsToLatLngs:function(t){return[(t=O(t)).getSouthWest(),t.getNorthWest(),t.getNorthEast(),t.getSouthEast()]}});mn.create=fn,mn.pointsToPath=X,Fi.geometryToLayer=Ni,Fi.coordsToLatLng=ji,Fi.coordsToLatLngs=Vi,Fi.latLngToCoords=Gi,Fi.latLngsToCoords=Zi,Fi.getFeature=qi,Fi.asFeature=Hi,He.mergeOptions({boxZoom:!0});var yn=ti.extend({initialize:function(t){this._map=t,this._container=t._container,this._pane=t._panes.overlayPane,this._resetStateTimeout=0,t.on("unload",this._destroy,this)},addHooks:function(){Ae(this._container,"mousedown",this._onMouseDown,this)},removeHooks:function(){Le(this._container,"mousedown",this._onMouseDown,this)},moved:function(){return this._moved},_destroy:function(){se(this._pane),delete this._pane},_resetState:function(){this._resetStateTimeout=0,this._moved=!1},_clearDeferredResetState:function(){0!==this._resetStateTimeout&&(clearTimeout(this._resetStateTimeout),this._resetStateTimeout=0)},_onMouseDown:function(t){if(!t.shiftKey||1!==t.which&&1!==t.button)return!1;this._clearDeferredResetState(),this._resetState(),Yt(),be(),this._startPoint=this._map.mouseEventToContainerPoint(t),Ae(document,{contextmenu:Fe,mousemove:this._onMouseMove,mouseup:this._onMouseUp,keydown:this._onKeyDown},this)},_onMouseMove:function(t){this._moved||(this._moved=!0,this._box=oe("div","leaflet-zoom-box",this._container),ue(this._container,"leaflet-crosshair"),this._map.fire("boxzoomstart")),this._point=this._map.mouseEventToContainerPoint(t);var e=new D(this._point,this._startPoint),i=e.getSize();ye(this._box,e.min),this._box.style.width=i.x+"px",this._box.style.height=i.y+"px"},_finish:function(){this._moved&&(se(this._box),he(this._container,"leaflet-crosshair")),Xt(),we(),Le(document,{contextmenu:Fe,mousemove:this._onMouseMove,mouseup:this._onMouseUp,keydown:this._onKeyDown},this)},_onMouseUp:function(t){if((1===t.which||1===t.button)&&(this._finish(),this._moved)){this._clearDeferredResetState(),this._resetStateTimeout=setTimeout(n(this._resetState,this),0);var e=new R(this._map.containerPointToLatLng(this._startPoint),this._map.containerPointToLatLng(this._point));this._map.fitBounds(e).fire("boxzoomend",{boxZoomBounds:e})}},_onKeyDown:function(t){27===t.keyCode&&(this._finish(),this._clearDeferredResetState(),this._resetState())}});He.addInitHook("addHandler","boxZoom",yn),He.mergeOptions({doubleClickZoom:!0});var vn=ti.extend({addHooks:function(){this._map.on("dblclick",this._onDoubleClick,this)},removeHooks:function(){this._map.off("dblclick",this._onDoubleClick,this)},_onDoubleClick:function(t){var e=this._map,i=e.getZoom(),n=e.options.zoomDelta,r=t.originalEvent.shiftKey?i-n:i+n;"center"===e.options.doubleClickZoom?e.setZoom(r):e.setZoomAround(t.containerPoint,r)}});He.addInitHook("addHandler","doubleClickZoom",vn),He.mergeOptions({dragging:!0,inertia:!0,inertiaDeceleration:3400,inertiaMaxSpeed:1/0,easeLinearity:.2,worldCopyJump:!1,maxBoundsViscosity:0});var xn=ti.extend({addHooks:function(){if(!this._draggable){var t=this._map;this._draggable=new ni(t._mapPane,t._container),this._draggable.on({dragstart:this._onDragStart,drag:this._onDrag,dragend:this._onDragEnd},this),this._draggable.on("predrag",this._onPreDragLimit,this),t.options.worldCopyJump&&(this._draggable.on("predrag",this._onPreDragWrap,this),t.on("zoomend",this._onZoomEnd,this),t.whenReady(this._onZoomEnd,this))}ue(this._map._container,"leaflet-grab leaflet-touch-drag"),this._draggable.enable(),this._positions=[],this._times=[]},removeHooks:function(){he(this._map._container,"leaflet-grab"),he(this._map._container,"leaflet-touch-drag"),this._draggable.disable()},moved:function(){return this._draggable&&this._draggable._moved},moving:function(){return this._draggable&&this._draggable._moving},_onDragStart:function(){var t=this._map;if(t._stop(),this._map.options.maxBounds&&this._map.options.maxBoundsViscosity){var e=O(this._map.options.maxBounds);this._offsetLimit=z(this._map.latLngToContainerPoint(e.getNorthWest()).multiplyBy(-1),this._map.latLngToContainerPoint(e.getSouthEast()).multiplyBy(-1).add(this._map.getSize())),this._viscosity=Math.min(1,Math.max(0,this._map.options.maxBoundsViscosity))}else this._offsetLimit=null;t.fire("movestart").fire("dragstart"),t.options.inertia&&(this._positions=[],this._times=[])},_onDrag:function(t){if(this._map.options.inertia){var e=this._lastTime=+new Date,i=this._lastPos=this._draggable._absPos||this._draggable._newPos;this._positions.push(i),this._times.push(e),this._prunePositions(e)}this._map.fire("move",t).fire("drag",t)},_prunePositions:function(t){for(;this._positions.length>1&&t-this._times[0]>50;)this._positions.shift(),this._times.shift()},_onZoomEnd:function(){var t=this._map.getSize().divideBy(2),e=this._map.latLngToLayerPoint([0,0]);this._initialWorldOffset=e.subtract(t).x,this._worldWidth=this._map.getPixelWorldBounds().getSize().x},_viscousLimit:function(t,e){return t-(t-e)*this._viscosity},_onPreDragLimit:function(){if(this._viscosity&&this._offsetLimit){var t=this._draggable._newPos.subtract(this._draggable._startPos),e=this._offsetLimit;t.xe.max.x&&(t.x=this._viscousLimit(t.x,e.max.x)),t.y>e.max.y&&(t.y=this._viscousLimit(t.y,e.max.y)),this._draggable._newPos=this._draggable._startPos.add(t)}},_onPreDragWrap:function(){var t=this._worldWidth,e=Math.round(t/2),i=this._initialWorldOffset,n=this._draggable._newPos.x,r=(n-e+i)%t+e-i,o=(n+e+i)%t-e-i,s=Math.abs(r+i)0?o:-o))-e;this._delta=0,this._startTime=null,s&&("center"===t.options.scrollWheelZoom?t.setZoom(e+s):t.setZoomAround(this._lastMousePos,e+s))}});He.addInitHook("addHandler","scrollWheelZoom",wn);He.mergeOptions({tapHold:Dt.touchNative&&Dt.safari&&Dt.mobile,tapTolerance:15});var Tn=ti.extend({addHooks:function(){Ae(this._map._container,"touchstart",this._onDown,this)},removeHooks:function(){Le(this._map._container,"touchstart",this._onDown,this)},_onDown:function(t){if(clearTimeout(this._holdTimeout),1===t.touches.length){var e=t.touches[0];this._startPos=this._newPos=new P(e.clientX,e.clientY),this._holdTimeout=setTimeout(n((function(){this._cancel(),this._isTapValid()&&(Ae(document,"touchend",Be),Ae(document,"touchend touchcancel",this._cancelClickPrevent),this._simulateEvent("contextmenu",e))}),this),600),Ae(document,"touchend touchcancel contextmenu",this._cancel,this),Ae(document,"touchmove",this._onMove,this)}},_cancelClickPrevent:function t(){Le(document,"touchend",Be),Le(document,"touchend touchcancel",t)},_cancel:function(){clearTimeout(this._holdTimeout),Le(document,"touchend touchcancel contextmenu",this._cancel,this),Le(document,"touchmove",this._onMove,this)},_onMove:function(t){var e=t.touches[0];this._newPos=new P(e.clientX,e.clientY)},_isTapValid:function(){return this._newPos.distanceTo(this._startPos)e.getMaxZoom()&&o>1)&&(this._zoom=e._limitZoom(this._zoom)),"center"===e.options.touchZoom){if(this._center=this._startLatLng,1===o)return}else{var s=i._add(r)._divideBy(2)._subtract(this._centerPoint);if(1===o&&0===s.x&&0===s.y)return;this._center=e.unproject(e.project(this._pinchStartLatLng,this._zoom).subtract(s),this._zoom)}this._moved||(e._moveStart(!0,!1),this._moved=!0),E(this._animRequest);var a=n(e._move,e,this._center,this._zoom,{pinch:!0,round:!1},void 0);this._animRequest=S(a,this,!0),Be(t)}},_onTouchEnd:function(){this._moved&&this._zooming?(this._zooming=!1,E(this._animRequest),Le(document,"touchmove",this._onTouchMove,this),Le(document,"touchend touchcancel",this._onTouchEnd,this),this._map.options.zoomAnimation?this._map._animateZoom(this._center,this._map._limitZoom(this._zoom),!0,this._map.options.zoomSnap):this._map._resetView(this._center,this._map._limitZoom(this._zoom))):this._zooming=!1}});He.addInitHook("addHandler","touchZoom",Sn),He.BoxZoom=yn,He.DoubleClickZoom=vn,He.Drag=xn,He.Keyboard=bn,He.ScrollWheelZoom=wn,He.TapHold=Tn,He.TouchZoom=Sn,t.Bounds=D,t.Browser=Dt,t.CRS=U,t.Canvas=dn,t.Circle=Ri,t.CircleMarker=zi,t.Class=C,t.Control=We,t.DivIcon=rn,t.DivOverlay=tn,t.DomEvent=Ze,t.DomUtil=Ce,t.Draggable=ni,t.Evented=I,t.FeatureGroup=Ii,t.GeoJSON=Fi,t.GridLayer=on,t.Handler=ti,t.Icon=Li,t.ImageOverlay=Ki,t.LatLng=B,t.LatLngBounds=R,t.Layer=Ci,t.LayerGroup=Ai,t.LineUtil=xi,t.Map=He,t.Marker=ki,t.Mixin=ei,t.Path=Di,t.Point=P,t.PolyUtil=li,t.Polygon=Bi,t.Polyline=Oi,t.Popup=en,t.PosAnimation=qe,t.Projection=Ti,t.Rectangle=gn,t.Renderer=cn,t.SVG=mn,t.SVGOverlay=Qi,t.TileLayer=sn,t.Tooltip=nn,t.Transformation=Z,t.Util=M,t.VideoOverlay=Ji,t.bind=n,t.bounds=z,t.canvas=un,t.circle=function(t,e,i){return new Ri(t,e,i)},t.circleMarker=function(t,e){return new zi(t,e)},t.control=Ye,t.divIcon=function(t){return new rn(t)},t.extend=e,t.featureGroup=function(t,e){return new Ii(t,e)},t.geoJSON=Yi,t.geoJson=Xi,t.gridLayer=function(t){return new on(t)},t.icon=function(t){return new Li(t)},t.imageOverlay=function(t,e,i){return new Ki(t,e,i)},t.latLng=F,t.latLngBounds=O,t.layerGroup=function(t,e){return new Ai(t,e)},t.map=function(t,e){return new He(t,e)},t.marker=function(t,e){return new ki(t,e)},t.point=k,t.polygon=function(t,e){return new Bi(t,e)},t.polyline=function(t,e){return new Oi(t,e)},t.popup=function(t,e){return new en(t,e)},t.rectangle=function(t,e){return new gn(t,e)},t.setOptions=h,t.stamp=o,t.svg=_n,t.svgOverlay=function(t,e,i){return new Qi(t,e,i)},t.tileLayer=an,t.tooltip=function(t,e){return new nn(t,e)},t.transformation=q,t.version="1.9.4",t.videoOverlay=function(t,e,i){return new Ji(t,e,i)};var En=window.L;t.noConflict=function(){return window.L=En,this},window.L=t}(e)},3559:function(t,e,i){var n,r,o;r=[i(3481),i(842)],void 0===(o="function"==typeof(n=function(t,e){t.MapboxGL=t.Layer.extend({options:{updateInterval:32,padding:.1,interactive:!1,pane:"tilePane"},initialize:function(i){t.setOptions(this,i),i.accessToken&&(e.accessToken=i.accessToken),this._throttledUpdate=t.Util.throttle(this._update,this.options.updateInterval,this)},onAdd:function(e){this._container||this._initContainer();var i=this.getPaneName();e.getPane(i).appendChild(this._container),this._initGL(),this._offset=this._map.containerPointToLayerPoint([0,0]),e.options.zoomAnimation&&t.DomEvent.on(e._proxy,t.DomUtil.TRANSITION_END,this._transitionEnd,this),e._addZoomLimit(this)},onRemove:function(e){this._map._proxy&&this._map.options.zoomAnimation&&t.DomEvent.off(this._map._proxy,t.DomUtil.TRANSITION_END,this._transitionEnd,this);var i=this.getPaneName();e.getPane(i).removeChild(this._container)},getEvents:function(){return{move:this._throttledUpdate,zoomanim:this._animateZoom,zoom:this._pinchZoom,zoomstart:this._zoomStart,zoomend:this._zoomEnd,resize:this._resize}},getMapboxMap:function(){return this._glMap},getCanvas:function(){return this._glMap.getCanvas()},getSize:function(){return this._map.getSize().multiplyBy(1+2*this.options.padding)},getBounds:function(){var e=this.getSize().multiplyBy(.5),i=this._map.latLngToContainerPoint(this._map.getCenter());return t.latLngBounds(this._map.containerPointToLatLng(i.subtract(e)),this._map.containerPointToLatLng(i.add(e)))},getContainer:function(){return this._container},getPaneName:function(){return this._map.getPane(this.options.pane)?this.options.pane:"tilePane"},_initContainer:function(){var e=this._container=t.DomUtil.create("div","leaflet-gl-layer"),i=this.getSize(),n=this._map.getSize().multiplyBy(this.options.padding);e.style.width=i.x+"px",e.style.height=i.y+"px";var r=this._map.containerPointToLayerPoint([0,0]).subtract(n);t.DomUtil.setPosition(e,r)},_initGL:function(){var i=this._map.getCenter(),n=t.extend({},this.options,{container:this._container,center:[i.lng,i.lat],zoom:this._map.getZoom()-1,attributionControl:!1});this._glMap?(this._glMap.setCenter(n.center),this._glMap.setZoom(n.zoom)):this._glMap=new e.Map(n),this._glMap.transform.latRange=null,this._transformGL(this._glMap),this._glMap._canvas.canvas?this._glMap._actualCanvas=this._glMap._canvas.canvas:this._glMap._actualCanvas=this._glMap._canvas;var r=this._glMap._actualCanvas;t.DomUtil.addClass(r,"leaflet-image-layer"),t.DomUtil.addClass(r,"leaflet-zoom-animated"),this.options.interactive&&t.DomUtil.addClass(r,"leaflet-interactive"),this.options.className&&t.DomUtil.addClass(r,this.options.className)},_update:function(e){if(this._map&&(this._offset=this._map.containerPointToLayerPoint([0,0]),!this._zooming)){var i=this.getSize(),n=this._container,r=this._glMap,o=this._map.getSize().multiplyBy(this.options.padding),s=this._map.containerPointToLayerPoint([0,0]).subtract(o);t.DomUtil.setPosition(n,s),this._transformGL(r);var a=Math.round(i.x),l=Math.round(i.y);Math.round(r.transform.width)!==a||Math.round(r.transform.height)!==l?(n.style.width=a+"px",n.style.height=l+"px",null!==r._resize&&void 0!==r._resize?r._resize():r.resize()):null!==r._update&&void 0!==r._update?r._update():r.update()}},_transformGL:function(t){var i=this._map.getCenter(),n=t.transform;n.center=e.LngLat.convert([i.lng,i.lat]),n.zoom=this._map.getZoom()-1},_pinchZoom:function(t){this._glMap.jumpTo({zoom:this._map.getZoom()-1,center:this._map.getCenter()})},_animateZoom:function(e){var i=this._map.getZoomScale(e.zoom),n=this._map.getSize().multiplyBy(this.options.padding*i),r=this.getSize()._divideBy(2),o=this._map.project(e.center,e.zoom)._subtract(r)._add(this._map._getMapPanePos().add(n))._round(),s=this._map.project(this._map.getBounds().getNorthWest(),e.zoom)._subtract(o);t.DomUtil.setTransform(this._glMap._actualCanvas,s.subtract(this._offset),i)},_zoomStart:function(t){this._zooming=!0},_zoomEnd:function(){var e=this._map.getZoomScale(this._map.getZoom());t.DomUtil.setTransform(this._glMap._actualCanvas,null,e),this._zooming=!1,this._update()},_transitionEnd:function(e){t.Util.requestAnimFrame((function(){var e=this._map.getZoom(),i=this._map.getCenter(),n=this._map.latLngToContainerPoint(this._map.getBounds().getNorthWest());t.DomUtil.setTransform(this._glMap._actualCanvas,n,1),this._glMap.once("moveend",t.Util.bind((function(){this._zoomEnd()}),this)),this._glMap.jumpTo({center:i,zoom:e-1})}),this)},_resize:function(t){this._transitionEnd(t)}}),t.mapboxGL=function(e){return new t.MapboxGL(e)}})?n.apply(e,r):n)||(t.exports=o)},842:function(t){t.exports=function(){"use strict";var t,e,i;function n(n,r){if(t)if(e){var o="self.onerror = function() { console.error('An error occurred while parsing the WebWorker bundle. This is most likely due to improper transpilation by Babel; please see https://docs.mapbox.com/mapbox-gl-js/guides/install/#transpiling'); }; var sharedChunk = {}; ("+t+")(sharedChunk); ("+e+")(sharedChunk); self.onerror = null;",s={};t(s),i=r(s),"undefined"!=typeof window&&window&&window.URL&&window.URL.createObjectURL&&(i.workerUrl=window.URL.createObjectURL(new Blob([o],{type:"text/javascript"})))}else e=r;else t=r}return n(0,(function(t){var e="3.5.2";let i;const n={API_URL:"https://api.mapbox.com",get API_URL_REGEX(){if(null==i){const t=/^((https?:)?\/\/)?([^\/]+\.)?mapbox\.c(n|om)(\/|\?|$)/i;try{i=null!="MISSING_ENV_VAR".API_URL_REGEX?new RegExp("MISSING_ENV_VAR".API_URL_REGEX):t}catch(e){i=t}}return i},get API_TILEJSON_REGEX(){return/^((https?:)?\/\/)?([^\/]+\.)?mapbox\.c(n|om)(\/v[0-9]*\/.*\.json.*$)/i},get API_SPRITE_REGEX(){return/^((https?:)?\/\/)?([^\/]+\.)?mapbox\.c(n|om)(\/styles\/v[0-9]*\/)(.*\/sprite.*\..*$)/i},get API_FONTS_REGEX(){return/^((https?:)?\/\/)?([^\/]+\.)?mapbox\.c(n|om)(\/fonts\/v[0-9]*\/)(.*\.pbf.*$)/i},get API_STYLE_REGEX(){return/^((https?:)?\/\/)?([^\/]+\.)?mapbox\.c(n|om)(\/styles\/v[0-9]*\/)(.*$)/i},get API_CDN_URL_REGEX(){return/^((https?:)?\/\/)?api\.mapbox\.c(n|om)(\/mapbox-gl-js\/)(.*$)/i},get EVENTS_URL(){if(!n.API_URL)return null;try{const t=new URL(n.API_URL);return"api.mapbox.cn"===t.hostname?"https://events.mapbox.cn/events/v2":"api.mapbox.com"===t.hostname?"https://events.mapbox.com/events/v2":null}catch(t){return null}},SESSION_PATH:"/map-sessions/v1",FEEDBACK_URL:"https://apps.mapbox.com/feedback",TILE_URL_VERSION:"v4",RASTER_URL_PREFIX:"raster/v1",RASTERARRAYS_URL_PREFIX:"rasterarrays/v1",REQUIRE_ACCESS_TOKEN:!0,ACCESS_TOKEN:null,DEFAULT_STYLE:"mapbox://styles/mapbox/standard",MAX_PARALLEL_IMAGE_REQUESTS:16,DRACO_URL:"https://api.mapbox.com/mapbox-gl-js/draco_decoder_gltf_v1.5.6.wasm",MESHOPT_URL:"https://api.mapbox.com/mapbox-gl-js/meshopt_base_v0.20.wasm",MESHOPT_SIMD_URL:"https://api.mapbox.com/mapbox-gl-js/meshopt_simd_v0.20.wasm",GLYPHS_URL:"mapbox://fonts/mapbox/{fontstack}/{range}.pbf",TILES3D_URL_PREFIX:"3dtiles/v1"};function r(t){return n.API_URL_REGEX.test(t)}function o(t){return 0===t.indexOf("mapbox:")}function s(t){return n.API_CDN_URL_REGEX.test(t)}function a(t){return n.API_SPRITE_REGEX.test(t)}function l(t){return n.API_STYLE_REGEX.test(t)&&!a(t)}const c={create:"create",load:"load",fullLoad:"fullLoad"},d={mark(t){performance.mark(t)},measure(t,e,i){performance.measure(t,e,i)}};function u(t){const e=t.name.split("?")[0];return s(e)&&e.includes("mapbox-gl.js")?"javascript":s(e)&&e.includes("mapbox-gl.css")?"css":function(t){return n.API_FONTS_REGEX.test(t)}(e)?"fontRange":a(e)?"sprite":l(e)?"style":function(t){return n.API_TILEJSON_REGEX.test(t)}(e)?"tilejson":"other"}function h(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var p={},f={};Object.defineProperty(f,"__esModule",{value:!0}),f.setMatrixArrayType=function(t){f.ARRAY_TYPE=_=t},f.toRadian=function(t){return t*y},f.equals=function(t,e){return Math.abs(t-e)0?(i[0]=2*(a*s+d*n+l*o-c*r)/u,i[1]=2*(l*s+d*r+c*n-a*o)/u,i[2]=2*(c*s+d*o+a*r-l*n)/u):(i[0]=2*(a*s+d*n+l*o-c*r),i[1]=2*(l*s+d*r+c*n-a*o),i[2]=2*(c*s+d*o+a*r-l*n)),V(t,e,i),t},O.getTranslation=function(t,e){return t[0]=e[12],t[1]=e[13],t[2]=e[14],t},O.getScaling=G,O.getRotation=function(t,e){var i=new F.ARRAY_TYPE(3);G(i,e);var n=1/i[0],r=1/i[1],o=1/i[2],s=e[0]*n,a=e[1]*r,l=e[2]*o,c=e[4]*n,d=e[5]*r,u=e[6]*o,h=e[8]*n,p=e[9]*r,f=e[10]*o,m=s+d+f,_=0;return m>0?(_=2*Math.sqrt(m+1),t[3]=.25*_,t[0]=(u-p)/_,t[1]=(h-l)/_,t[2]=(a-c)/_):s>d&&s>f?(_=2*Math.sqrt(1+s-d-f),t[3]=(u-p)/_,t[0]=.25*_,t[1]=(a+c)/_,t[2]=(h+l)/_):d>f?(_=2*Math.sqrt(1+d-s-f),t[3]=(h-l)/_,t[0]=(a+c)/_,t[1]=.25*_,t[2]=(u+p)/_):(_=2*Math.sqrt(1+f-s-d),t[3]=(a-c)/_,t[0]=(h+l)/_,t[1]=(u+p)/_,t[2]=.25*_),t},O.fromRotationTranslationScale=function(t,e,i,n){var r=e[0],o=e[1],s=e[2],a=e[3],l=r+r,c=o+o,d=s+s,u=r*l,h=r*c,p=r*d,f=o*c,m=o*d,_=s*d,g=a*l,y=a*c,v=a*d,x=n[0],b=n[1],w=n[2];return t[0]=(1-(f+_))*x,t[1]=(h+v)*x,t[2]=(p-y)*x,t[3]=0,t[4]=(h-v)*b,t[5]=(1-(u+_))*b,t[6]=(m+g)*b,t[7]=0,t[8]=(p+y)*w,t[9]=(m-g)*w,t[10]=(1-(u+f))*w,t[11]=0,t[12]=i[0],t[13]=i[1],t[14]=i[2],t[15]=1,t},O.fromRotationTranslationScaleOrigin=function(t,e,i,n,r){var o=e[0],s=e[1],a=e[2],l=e[3],c=o+o,d=s+s,u=a+a,h=o*c,p=o*d,f=o*u,m=s*d,_=s*u,g=a*u,y=l*c,v=l*d,x=l*u,b=n[0],w=n[1],T=n[2],S=r[0],E=r[1],M=r[2],C=(1-(m+g))*b,A=(p+x)*b,I=(f-v)*b,L=(p-x)*w,P=(1-(h+g))*w,$=(_+y)*w,k=(f+v)*T,D=(_-y)*T,z=(1-(h+m))*T;return t[0]=C,t[1]=A,t[2]=I,t[3]=0,t[4]=L,t[5]=P,t[6]=$,t[7]=0,t[8]=k,t[9]=D,t[10]=z,t[11]=0,t[12]=i[0]+S-(C*S+L*E+k*M),t[13]=i[1]+E-(A*S+P*E+D*M),t[14]=i[2]+M-(I*S+$*E+z*M),t[15]=1,t},O.fromQuat=function(t,e){var i=e[0],n=e[1],r=e[2],o=e[3],s=i+i,a=n+n,l=r+r,c=i*s,d=n*s,u=n*a,h=r*s,p=r*a,f=r*l,m=o*s,_=o*a,g=o*l;return t[0]=1-u-f,t[1]=d+g,t[2]=h-_,t[3]=0,t[4]=d-g,t[5]=1-c-f,t[6]=p+m,t[7]=0,t[8]=h+_,t[9]=p-m,t[10]=1-c-u,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t},O.frustum=function(t,e,i,n,r,o,s){var a=1/(i-e),l=1/(r-n),c=1/(o-s);return t[0]=2*o*a,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=2*o*l,t[6]=0,t[7]=0,t[8]=(i+e)*a,t[9]=(r+n)*l,t[10]=(s+o)*c,t[11]=-1,t[12]=0,t[13]=0,t[14]=s*o*2*c,t[15]=0,t},O.perspectiveNO=Z,O.perspectiveZO=function(t,e,i,n,r){var o,s=1/Math.tan(e/2);return t[0]=s/i,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=s,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[11]=-1,t[12]=0,t[13]=0,t[15]=0,null!=r&&r!==1/0?(t[10]=r*(o=1/(n-r)),t[14]=r*n*o):(t[10]=-1,t[14]=-n),t},O.perspectiveFromFieldOfView=function(t,e,i,n){var r=Math.tan(e.upDegrees*Math.PI/180),o=Math.tan(e.downDegrees*Math.PI/180),s=Math.tan(e.leftDegrees*Math.PI/180),a=Math.tan(e.rightDegrees*Math.PI/180),l=2/(s+a),c=2/(r+o);return t[0]=l,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=c,t[6]=0,t[7]=0,t[8]=-(s-a)*l*.5,t[9]=(r-o)*c*.5,t[10]=n/(i-n),t[11]=-1,t[12]=0,t[13]=0,t[14]=n*i/(i-n),t[15]=0,t},O.orthoNO=q,O.orthoZO=function(t,e,i,n,r,o,s){var a=1/(e-i),l=1/(n-r),c=1/(o-s);return t[0]=-2*a,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=-2*l,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=c,t[11]=0,t[12]=(e+i)*a,t[13]=(r+n)*l,t[14]=o*c,t[15]=1,t},O.lookAt=function(t,e,i,n){var r,o,s,a,l,c,d,u,h,p,f=e[0],m=e[1],_=e[2],g=n[0],y=n[1],v=n[2],x=i[0],b=i[1],w=i[2];return Math.abs(f-x)0&&(d*=p=1/Math.sqrt(p),u*=p,h*=p);var f=l*h-c*u,m=c*d-a*h,_=a*u-l*d;return(p=f*f+m*m+_*_)>0&&(f*=p=1/Math.sqrt(p),m*=p,_*=p),t[0]=f,t[1]=m,t[2]=_,t[3]=0,t[4]=u*_-h*m,t[5]=h*f-d*_,t[6]=d*m-u*f,t[7]=0,t[8]=d,t[9]=u,t[10]=h,t[11]=0,t[12]=r,t[13]=o,t[14]=s,t[15]=1,t},O.str=function(t){return"mat4("+t[0]+", "+t[1]+", "+t[2]+", "+t[3]+", "+t[4]+", "+t[5]+", "+t[6]+", "+t[7]+", "+t[8]+", "+t[9]+", "+t[10]+", "+t[11]+", "+t[12]+", "+t[13]+", "+t[14]+", "+t[15]+")"},O.frob=function(t){return Math.hypot(t[0],t[1],t[2],t[3],t[4],t[5],t[6],t[7],t[8],t[9],t[10],t[11],t[12],t[13],t[14],t[15])},O.add=function(t,e,i){return t[0]=e[0]+i[0],t[1]=e[1]+i[1],t[2]=e[2]+i[2],t[3]=e[3]+i[3],t[4]=e[4]+i[4],t[5]=e[5]+i[5],t[6]=e[6]+i[6],t[7]=e[7]+i[7],t[8]=e[8]+i[8],t[9]=e[9]+i[9],t[10]=e[10]+i[10],t[11]=e[11]+i[11],t[12]=e[12]+i[12],t[13]=e[13]+i[13],t[14]=e[14]+i[14],t[15]=e[15]+i[15],t},O.subtract=H,O.multiplyScalar=function(t,e,i){return t[0]=e[0]*i,t[1]=e[1]*i,t[2]=e[2]*i,t[3]=e[3]*i,t[4]=e[4]*i,t[5]=e[5]*i,t[6]=e[6]*i,t[7]=e[7]*i,t[8]=e[8]*i,t[9]=e[9]*i,t[10]=e[10]*i,t[11]=e[11]*i,t[12]=e[12]*i,t[13]=e[13]*i,t[14]=e[14]*i,t[15]=e[15]*i,t},O.multiplyScalarAndAdd=function(t,e,i,n){return t[0]=e[0]+i[0]*n,t[1]=e[1]+i[1]*n,t[2]=e[2]+i[2]*n,t[3]=e[3]+i[3]*n,t[4]=e[4]+i[4]*n,t[5]=e[5]+i[5]*n,t[6]=e[6]+i[6]*n,t[7]=e[7]+i[7]*n,t[8]=e[8]+i[8]*n,t[9]=e[9]+i[9]*n,t[10]=e[10]+i[10]*n,t[11]=e[11]+i[11]*n,t[12]=e[12]+i[12]*n,t[13]=e[13]+i[13]*n,t[14]=e[14]+i[14]*n,t[15]=e[15]+i[15]*n,t},O.exactEquals=function(t,e){return t[0]===e[0]&&t[1]===e[1]&&t[2]===e[2]&&t[3]===e[3]&&t[4]===e[4]&&t[5]===e[5]&&t[6]===e[6]&&t[7]===e[7]&&t[8]===e[8]&&t[9]===e[9]&&t[10]===e[10]&&t[11]===e[11]&&t[12]===e[12]&&t[13]===e[13]&&t[14]===e[14]&&t[15]===e[15]},O.equals=function(t,e){var i=t[0],n=t[1],r=t[2],o=t[3],s=t[4],a=t[5],l=t[6],c=t[7],d=t[8],u=t[9],h=t[10],p=t[11],f=t[12],m=t[13],_=t[14],g=t[15],y=e[0],v=e[1],x=e[2],b=e[3],w=e[4],T=e[5],S=e[6],E=e[7],M=e[8],C=e[9],A=e[10],I=e[11],L=e[12],P=e[13],$=e[14],k=e[15];return Math.abs(i-y)0&&(o=1/Math.sqrt(o)),t[0]=e[0]*o,t[1]=e[1]*o,t[2]=e[2]*o,t},Y.dot=at,Y.cross=function(t,e,i){var n=e[0],r=e[1],o=e[2],s=i[0],a=i[1],l=i[2];return t[0]=r*l-o*a,t[1]=o*s-n*l,t[2]=n*a-r*s,t},Y.lerp=function(t,e,i,n){var r=e[0],o=e[1],s=e[2];return t[0]=r+n*(i[0]-r),t[1]=o+n*(i[1]-o),t[2]=s+n*(i[2]-s),t},Y.hermite=function(t,e,i,n,r,o){var s=o*o,a=s*(2*o-3)+1,l=s*(o-2)+o,c=s*(o-1),d=s*(3-2*o);return t[0]=e[0]*a+i[0]*l+n[0]*c+r[0]*d,t[1]=e[1]*a+i[1]*l+n[1]*c+r[1]*d,t[2]=e[2]*a+i[2]*l+n[2]*c+r[2]*d,t},Y.bezier=function(t,e,i,n,r,o){var s=1-o,a=s*s,l=o*o,c=a*s,d=3*o*a,u=3*l*s,h=l*o;return t[0]=e[0]*c+i[0]*d+n[0]*u+r[0]*h,t[1]=e[1]*c+i[1]*d+n[1]*u+r[1]*h,t[2]=e[2]*c+i[2]*d+n[2]*u+r[2]*h,t},Y.random=function(t,e){e=e||1;var i=2*K.RANDOM()*Math.PI,n=2*K.RANDOM()-1,r=Math.sqrt(1-n*n)*e;return t[0]=Math.cos(i)*r,t[1]=Math.sin(i)*r,t[2]=n*e,t},Y.transformMat4=function(t,e,i){var n=e[0],r=e[1],o=e[2],s=i[3]*n+i[7]*r+i[11]*o+i[15];return t[0]=(i[0]*n+i[4]*r+i[8]*o+i[12])/(s=s||1),t[1]=(i[1]*n+i[5]*r+i[9]*o+i[13])/s,t[2]=(i[2]*n+i[6]*r+i[10]*o+i[14])/s,t},Y.transformMat3=function(t,e,i){var n=e[0],r=e[1],o=e[2];return t[0]=n*i[0]+r*i[3]+o*i[6],t[1]=n*i[1]+r*i[4]+o*i[7],t[2]=n*i[2]+r*i[5]+o*i[8],t},Y.transformQuat=function(t,e,i){var n=i[0],r=i[1],o=i[2],s=e[0],a=e[1],l=e[2],c=r*l-o*a,d=o*s-n*l,u=n*a-r*s,h=r*u-o*d,p=o*c-n*u,f=n*d-r*c,m=2*i[3];return d*=m,u*=m,p*=2,f*=2,t[0]=s+(c*=m)+(h*=2),t[1]=a+d+p,t[2]=l+u+f,t},Y.rotateX=function(t,e,i,n){var r=[],o=[];return r[0]=e[0]-i[0],r[1]=e[1]-i[1],r[2]=e[2]-i[2],o[0]=r[0],o[1]=r[1]*Math.cos(n)-r[2]*Math.sin(n),o[2]=r[1]*Math.sin(n)+r[2]*Math.cos(n),t[0]=o[0]+i[0],t[1]=o[1]+i[1],t[2]=o[2]+i[2],t},Y.rotateY=function(t,e,i,n){var r=[],o=[];return r[0]=e[0]-i[0],r[1]=e[1]-i[1],r[2]=e[2]-i[2],o[0]=r[2]*Math.sin(n)+r[0]*Math.cos(n),o[1]=r[1],o[2]=r[2]*Math.cos(n)-r[0]*Math.sin(n),t[0]=o[0]+i[0],t[1]=o[1]+i[1],t[2]=o[2]+i[2],t},Y.rotateZ=function(t,e,i,n){var r=[],o=[];return r[0]=e[0]-i[0],r[1]=e[1]-i[1],r[2]=e[2]-i[2],o[0]=r[0]*Math.cos(n)-r[1]*Math.sin(n),o[1]=r[0]*Math.sin(n)+r[1]*Math.cos(n),o[2]=r[2],t[0]=o[0]+i[0],t[1]=o[1]+i[1],t[2]=o[2]+i[2],t},Y.angle=function(t,e){var i=t[0],n=t[1],r=t[2],o=e[0],s=e[1],a=e[2],l=Math.sqrt(i*i+n*n+r*r)*Math.sqrt(o*o+s*s+a*a),c=l&&at(t,e)/l;return Math.acos(Math.min(Math.max(c,-1),1))},Y.zero=function(t){return t[0]=0,t[1]=0,t[2]=0,t},Y.str=function(t){return"vec3("+t[0]+", "+t[1]+", "+t[2]+")"},Y.exactEquals=function(t,e){return t[0]===e[0]&&t[1]===e[1]&&t[2]===e[2]},Y.equals=function(t,e){var i=t[0],n=t[1],r=t[2],o=e[0],s=e[1],a=e[2];return Math.abs(i-o)0&&(s=1/Math.sqrt(s)),t[0]=i*s,t[1]=n*s,t[2]=r*s,t[3]=o*s,t},dt.dot=function(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]+t[3]*e[3]},dt.cross=function(t,e,i,n){var r=i[0]*n[1]-i[1]*n[0],o=i[0]*n[2]-i[2]*n[0],s=i[0]*n[3]-i[3]*n[0],a=i[1]*n[2]-i[2]*n[1],l=i[1]*n[3]-i[3]*n[1],c=i[2]*n[3]-i[3]*n[2],d=e[0],u=e[1],h=e[2],p=e[3];return t[0]=u*c-h*l+p*a,t[1]=-d*c+h*s-p*o,t[2]=d*l-u*s+p*r,t[3]=-d*a+u*o-h*r,t},dt.lerp=function(t,e,i,n){var r=e[0],o=e[1],s=e[2],a=e[3];return t[0]=r+n*(i[0]-r),t[1]=o+n*(i[1]-o),t[2]=s+n*(i[2]-s),t[3]=a+n*(i[3]-a),t},dt.random=function(t,e){var i,n,r,o,s,a;e=e||1;do{s=(i=2*ht.RANDOM()-1)*i+(n=2*ht.RANDOM()-1)*n}while(s>=1);do{a=(r=2*ht.RANDOM()-1)*r+(o=2*ht.RANDOM()-1)*o}while(a>=1);var l=Math.sqrt((1-s)/a);return t[0]=e*i,t[1]=e*n,t[2]=e*r*l,t[3]=e*o*l,t},dt.transformMat4=function(t,e,i){var n=e[0],r=e[1],o=e[2],s=e[3];return t[0]=i[0]*n+i[4]*r+i[8]*o+i[12]*s,t[1]=i[1]*n+i[5]*r+i[9]*o+i[13]*s,t[2]=i[2]*n+i[6]*r+i[10]*o+i[14]*s,t[3]=i[3]*n+i[7]*r+i[11]*o+i[15]*s,t},dt.transformQuat=function(t,e,i){var n=e[0],r=e[1],o=e[2],s=i[0],a=i[1],l=i[2],c=i[3],d=c*n+a*o-l*r,u=c*r+l*n-s*o,h=c*o+s*r-a*n,p=-s*n-a*r-l*o;return t[0]=d*c+p*-s+u*-l-h*-a,t[1]=u*c+p*-a+h*-s-d*-l,t[2]=h*c+p*-l+d*-a-u*-s,t[3]=e[3],t},dt.zero=function(t){return t[0]=0,t[1]=0,t[2]=0,t[3]=0,t},dt.str=function(t){return"vec4("+t[0]+", "+t[1]+", "+t[2]+", "+t[3]+")"},dt.exactEquals=function(t,e){return t[0]===e[0]&&t[1]===e[1]&&t[2]===e[2]&&t[3]===e[3]},dt.equals=function(t,e){var i=t[0],n=t[1],r=t[2],o=t[3],s=e[0],a=e[1],l=e[2],c=e[3];return Math.abs(i-s)St.EPSILON?(t[0]=e[0]/n,t[1]=e[1]/n,t[2]=e[2]/n):(t[0]=1,t[1]=0,t[2]=0),i},W.getAngle=function(t,e){var i=Bt(t,e);return Math.acos(2*i*i-1)},W.multiply=$t,W.rotateX=function(t,e,i){i*=.5;var n=e[0],r=e[1],o=e[2],s=e[3],a=Math.sin(i),l=Math.cos(i);return t[0]=n*l+s*a,t[1]=r*l+o*a,t[2]=o*l-r*a,t[3]=s*l-n*a,t},W.rotateY=function(t,e,i){i*=.5;var n=e[0],r=e[1],o=e[2],s=e[3],a=Math.sin(i),l=Math.cos(i);return t[0]=n*l-o*a,t[1]=r*l+s*a,t[2]=o*l+n*a,t[3]=s*l-r*a,t},W.rotateZ=function(t,e,i){i*=.5;var n=e[0],r=e[1],o=e[2],s=e[3],a=Math.sin(i),l=Math.cos(i);return t[0]=n*l+r*a,t[1]=r*l-n*a,t[2]=o*l+s*a,t[3]=s*l-o*a,t},W.calculateW=function(t,e){var i=e[0],n=e[1],r=e[2];return t[0]=i,t[1]=n,t[2]=r,t[3]=Math.sqrt(Math.abs(1-i*i-n*n-r*r)),t},W.exp=kt,W.ln=Dt,W.pow=function(t,e,i){return Dt(t,e),Ot(t,t,i),kt(t,t),t},W.slerp=zt,W.random=function(t){var e=St.RANDOM(),i=St.RANDOM(),n=St.RANDOM(),r=Math.sqrt(1-e),o=Math.sqrt(e);return t[0]=r*Math.sin(2*Math.PI*i),t[1]=r*Math.cos(2*Math.PI*i),t[2]=o*Math.sin(2*Math.PI*n),t[3]=o*Math.cos(2*Math.PI*n),t},W.invert=function(t,e){var i=e[0],n=e[1],r=e[2],o=e[3],s=i*i+n*n+r*r+o*o,a=s?1/s:0;return t[0]=-i*a,t[1]=-n*a,t[2]=-r*a,t[3]=o*a,t},W.conjugate=function(t,e){return t[0]=-e[0],t[1]=-e[1],t[2]=-e[2],t[3]=e[3],t},W.fromMat3=Rt,W.fromEuler=function(t,e,i,n){var r=.5*Math.PI/180;e*=r,i*=r,n*=r;var o=Math.sin(e),s=Math.cos(e),a=Math.sin(i),l=Math.cos(i),c=Math.sin(n),d=Math.cos(n);return t[0]=o*l*d-s*a*c,t[1]=s*a*d+o*l*c,t[2]=s*l*c-o*a*d,t[3]=s*l*d+o*a*c,t},W.str=function(t){return"quat("+t[0]+", "+t[1]+", "+t[2]+", "+t[3]+")"},W.setAxes=W.sqlerp=W.rotationTo=W.equals=W.exactEquals=W.normalize=W.sqrLen=W.squaredLength=W.len=W.length=W.lerp=W.dot=W.scale=W.mul=W.add=W.set=W.copy=W.fromValues=W.clone=void 0;var St=It(f),Et=It(P),Mt=It(Y),Ct=It(dt);function At(t){if("function"!=typeof WeakMap)return null;var e=new WeakMap,i=new WeakMap;return(At=function(t){return t?i:e})(t)}function It(t,e){if(t&&t.__esModule)return t;if(null===t||"object"!==Tt(t)&&"function"!=typeof t)return{default:t};var i=At(e);if(i&&i.has(t))return i.get(t);var n={},r=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var o in t)if("default"!==o&&Object.prototype.hasOwnProperty.call(t,o)){var s=r?Object.getOwnPropertyDescriptor(t,o):null;s&&(s.get||s.set)?Object.defineProperty(n,o,s):n[o]=t[o]}return n.default=t,i&&i.set(t,n),n}function Lt(){var t=new St.ARRAY_TYPE(4);return St.ARRAY_TYPE!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0),t[3]=1,t}function Pt(t,e,i){i*=.5;var n=Math.sin(i);return t[0]=n*e[0],t[1]=n*e[1],t[2]=n*e[2],t[3]=Math.cos(i),t}function $t(t,e,i){var n=e[0],r=e[1],o=e[2],s=e[3],a=i[0],l=i[1],c=i[2],d=i[3];return t[0]=n*d+s*a+r*c-o*l,t[1]=r*d+s*l+o*a-n*c,t[2]=o*d+s*c+n*l-r*a,t[3]=s*d-n*a-r*l-o*c,t}function kt(t,e){var i=e[0],n=e[1],r=e[2],o=e[3],s=Math.sqrt(i*i+n*n+r*r),a=Math.exp(o),l=s>0?a*Math.sin(s)/s:0;return t[0]=i*l,t[1]=n*l,t[2]=r*l,t[3]=a*Math.cos(s),t}function Dt(t,e){var i=e[0],n=e[1],r=e[2],o=e[3],s=Math.sqrt(i*i+n*n+r*r),a=s>0?Math.atan2(s,o)/s:0;return t[0]=i*a,t[1]=n*a,t[2]=r*a,t[3]=.5*Math.log(i*i+n*n+r*r+o*o),t}function zt(t,e,i,n){var r,o,s,a,l,c=e[0],d=e[1],u=e[2],h=e[3],p=i[0],f=i[1],m=i[2],_=i[3];return(o=c*p+d*f+u*m+h*_)St.EPSILON?(r=Math.acos(o),s=Math.sin(r),a=Math.sin((1-n)*r)/s,l=Math.sin(n*r)/s):(a=1-n,l=n),t[0]=a*c+l*p,t[1]=a*d+l*f,t[2]=a*u+l*m,t[3]=a*h+l*_,t}function Rt(t,e){var i,n=e[0]+e[4]+e[8];if(n>0)i=Math.sqrt(n+1),t[3]=.5*i,t[0]=(e[5]-e[7])*(i=.5/i),t[1]=(e[6]-e[2])*i,t[2]=(e[1]-e[3])*i;else{var r=0;e[4]>e[0]&&(r=1),e[8]>e[3*r+r]&&(r=2);var o=(r+1)%3,s=(r+2)%3;i=Math.sqrt(e[3*r+r]-e[3*o+o]-e[3*s+s]+1),t[r]=.5*i,t[3]=(e[3*o+s]-e[3*s+o])*(i=.5/i),t[o]=(e[3*o+r]+e[3*r+o])*i,t[s]=(e[3*s+r]+e[3*r+s])*i}return t}W.clone=Ct.clone,W.fromValues=Ct.fromValues,W.copy=Ct.copy,W.set=Ct.set,W.add=Ct.add,W.mul=$t;var Ot=Ct.scale;W.scale=Ot;var Bt=Ct.dot;W.dot=Bt,W.lerp=Ct.lerp;var Ft=Ct.length;W.length=Ft,W.len=Ft;var Nt=Ct.squaredLength;W.squaredLength=Nt,W.sqrLen=Nt;var Ut=Ct.normalize;W.normalize=Ut,W.exactEquals=Ct.exactEquals,W.equals=Ct.equals;var jt,Vt,Gt,Zt=(jt=Mt.create(),Vt=Mt.fromValues(1,0,0),Gt=Mt.fromValues(0,1,0),function(t,e,i){var n=Mt.dot(e,i);return n.999999?(t[0]=0,t[1]=0,t[2]=0,t[3]=1,t):(Mt.cross(jt,e,i),t[0]=jt[0],t[1]=jt[1],t[2]=jt[2],t[3]=1+n,Ut(t,t))});W.rotationTo=Zt;var qt,Ht,Wt=(qt=Lt(),Ht=Lt(),function(t,e,i,n,r,o){return zt(qt,e,r,o),zt(Ht,i,n,o),zt(t,qt,Ht,2*o*(1-o)),t});W.sqlerp=Wt;var Yt,Xt=(Yt=Et.create(),function(t,e,i,n){return Yt[0]=i[0],Yt[3]=i[1],Yt[6]=i[2],Yt[1]=n[0],Yt[4]=n[1],Yt[7]=n[2],Yt[2]=-e[0],Yt[5]=-e[1],Yt[8]=-e[2],Ut(t,Rt(t,Yt))});W.setAxes=Xt;var Kt={};function Jt(t){return Jt="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Jt(t)}Object.defineProperty(Kt,"__esModule",{value:!0}),Kt.create=function(){var t=new Qt.ARRAY_TYPE(8);return Qt.ARRAY_TYPE!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0,t[4]=0,t[5]=0,t[6]=0,t[7]=0),t[3]=1,t},Kt.clone=function(t){var e=new Qt.ARRAY_TYPE(8);return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[4]=t[4],e[5]=t[5],e[6]=t[6],e[7]=t[7],e},Kt.fromValues=function(t,e,i,n,r,o,s,a){var l=new Qt.ARRAY_TYPE(8);return l[0]=t,l[1]=e,l[2]=i,l[3]=n,l[4]=r,l[5]=o,l[6]=s,l[7]=a,l},Kt.fromRotationTranslationValues=function(t,e,i,n,r,o,s){var a=new Qt.ARRAY_TYPE(8);a[0]=t,a[1]=e,a[2]=i,a[3]=n;var l=.5*r,c=.5*o,d=.5*s;return a[4]=l*n+c*i-d*e,a[5]=c*n+d*t-l*i,a[6]=d*n+l*e-c*t,a[7]=-l*t-c*e-d*i,a},Kt.fromRotationTranslation=re,Kt.fromTranslation=function(t,e){return t[0]=0,t[1]=0,t[2]=0,t[3]=1,t[4]=.5*e[0],t[5]=.5*e[1],t[6]=.5*e[2],t[7]=0,t},Kt.fromRotation=function(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t[4]=0,t[5]=0,t[6]=0,t[7]=0,t},Kt.fromMat4=function(t,e){var i=te.create();ee.getRotation(i,e);var n=new Qt.ARRAY_TYPE(3);return ee.getTranslation(n,e),re(t,i,n),t},Kt.copy=oe,Kt.identity=function(t){return t[0]=0,t[1]=0,t[2]=0,t[3]=1,t[4]=0,t[5]=0,t[6]=0,t[7]=0,t},Kt.set=function(t,e,i,n,r,o,s,a,l){return t[0]=e,t[1]=i,t[2]=n,t[3]=r,t[4]=o,t[5]=s,t[6]=a,t[7]=l,t},Kt.getDual=function(t,e){return t[0]=e[4],t[1]=e[5],t[2]=e[6],t[3]=e[7],t},Kt.setDual=function(t,e){return t[4]=e[0],t[5]=e[1],t[6]=e[2],t[7]=e[3],t},Kt.getTranslation=function(t,e){var i=e[4],n=e[5],r=e[6],o=e[7],s=-e[0],a=-e[1],l=-e[2],c=e[3];return t[0]=2*(i*c+o*s+n*l-r*a),t[1]=2*(n*c+o*a+r*s-i*l),t[2]=2*(r*c+o*l+i*a-n*s),t},Kt.translate=function(t,e,i){var n=e[0],r=e[1],o=e[2],s=e[3],a=.5*i[0],l=.5*i[1],c=.5*i[2],d=e[4],u=e[5],h=e[6],p=e[7];return t[0]=n,t[1]=r,t[2]=o,t[3]=s,t[4]=s*a+r*c-o*l+d,t[5]=s*l+o*a-n*c+u,t[6]=s*c+n*l-r*a+h,t[7]=-n*a-r*l-o*c+p,t},Kt.rotateX=function(t,e,i){var n=-e[0],r=-e[1],o=-e[2],s=e[3],a=e[4],l=e[5],c=e[6],d=e[7],u=a*s+d*n+l*o-c*r,h=l*s+d*r+c*n-a*o,p=c*s+d*o+a*r-l*n,f=d*s-a*n-l*r-c*o;return te.rotateX(t,e,i),t[4]=u*(s=t[3])+f*(n=t[0])+h*(o=t[2])-p*(r=t[1]),t[5]=h*s+f*r+p*n-u*o,t[6]=p*s+f*o+u*r-h*n,t[7]=f*s-u*n-h*r-p*o,t},Kt.rotateY=function(t,e,i){var n=-e[0],r=-e[1],o=-e[2],s=e[3],a=e[4],l=e[5],c=e[6],d=e[7],u=a*s+d*n+l*o-c*r,h=l*s+d*r+c*n-a*o,p=c*s+d*o+a*r-l*n,f=d*s-a*n-l*r-c*o;return te.rotateY(t,e,i),t[4]=u*(s=t[3])+f*(n=t[0])+h*(o=t[2])-p*(r=t[1]),t[5]=h*s+f*r+p*n-u*o,t[6]=p*s+f*o+u*r-h*n,t[7]=f*s-u*n-h*r-p*o,t},Kt.rotateZ=function(t,e,i){var n=-e[0],r=-e[1],o=-e[2],s=e[3],a=e[4],l=e[5],c=e[6],d=e[7],u=a*s+d*n+l*o-c*r,h=l*s+d*r+c*n-a*o,p=c*s+d*o+a*r-l*n,f=d*s-a*n-l*r-c*o;return te.rotateZ(t,e,i),t[4]=u*(s=t[3])+f*(n=t[0])+h*(o=t[2])-p*(r=t[1]),t[5]=h*s+f*r+p*n-u*o,t[6]=p*s+f*o+u*r-h*n,t[7]=f*s-u*n-h*r-p*o,t},Kt.rotateByQuatAppend=function(t,e,i){var n=i[0],r=i[1],o=i[2],s=i[3],a=e[0],l=e[1],c=e[2],d=e[3];return t[0]=a*s+d*n+l*o-c*r,t[1]=l*s+d*r+c*n-a*o,t[2]=c*s+d*o+a*r-l*n,t[3]=d*s-a*n-l*r-c*o,t[4]=(a=e[4])*s+(d=e[7])*n+(l=e[5])*o-(c=e[6])*r,t[5]=l*s+d*r+c*n-a*o,t[6]=c*s+d*o+a*r-l*n,t[7]=d*s-a*n-l*r-c*o,t},Kt.rotateByQuatPrepend=function(t,e,i){var n=e[0],r=e[1],o=e[2],s=e[3],a=i[0],l=i[1],c=i[2],d=i[3];return t[0]=n*d+s*a+r*c-o*l,t[1]=r*d+s*l+o*a-n*c,t[2]=o*d+s*c+n*l-r*a,t[3]=s*d-n*a-r*l-o*c,t[4]=n*(d=i[7])+s*(a=i[4])+r*(c=i[6])-o*(l=i[5]),t[5]=r*d+s*l+o*a-n*c,t[6]=o*d+s*c+n*l-r*a,t[7]=s*d-n*a-r*l-o*c,t},Kt.rotateAroundAxis=function(t,e,i,n){if(Math.abs(n)0){i=Math.sqrt(i);var n=e[0]/i,r=e[1]/i,o=e[2]/i,s=e[3]/i,a=e[4],l=e[5],c=e[6],d=e[7],u=n*a+r*l+o*c+s*d;t[0]=n,t[1]=r,t[2]=o,t[3]=s,t[4]=(a-n*u)/i,t[5]=(l-r*u)/i,t[6]=(c-o*u)/i,t[7]=(d-s*u)/i}return t},Kt.str=function(t){return"quat2("+t[0]+", "+t[1]+", "+t[2]+", "+t[3]+", "+t[4]+", "+t[5]+", "+t[6]+", "+t[7]+")"},Kt.exactEquals=function(t,e){return t[0]===e[0]&&t[1]===e[1]&&t[2]===e[2]&&t[3]===e[3]&&t[4]===e[4]&&t[5]===e[5]&&t[6]===e[6]&&t[7]===e[7]},Kt.equals=function(t,e){var i=t[0],n=t[1],r=t[2],o=t[3],s=t[4],a=t[5],l=t[6],c=t[7],d=e[0],u=e[1],h=e[2],p=e[3],f=e[4],m=e[5],_=e[6],g=e[7];return Math.abs(i-d)0&&(r=1/Math.sqrt(r)),t[0]=e[0]*r,t[1]=e[1]*r,t},de.dot=function(t,e){return t[0]*e[0]+t[1]*e[1]},de.cross=function(t,e,i){var n=e[0]*i[1]-e[1]*i[0];return t[0]=t[1]=0,t[2]=n,t},de.lerp=function(t,e,i,n){var r=e[0],o=e[1];return t[0]=r+n*(i[0]-r),t[1]=o+n*(i[1]-o),t},de.random=function(t,e){e=e||1;var i=2*he.RANDOM()*Math.PI;return t[0]=Math.cos(i)*e,t[1]=Math.sin(i)*e,t},de.transformMat2=function(t,e,i){var n=e[0],r=e[1];return t[0]=i[0]*n+i[2]*r,t[1]=i[1]*n+i[3]*r,t},de.transformMat2d=function(t,e,i){var n=e[0],r=e[1];return t[0]=i[0]*n+i[2]*r+i[4],t[1]=i[1]*n+i[3]*r+i[5],t},de.transformMat3=function(t,e,i){var n=e[0],r=e[1];return t[0]=i[0]*n+i[3]*r+i[6],t[1]=i[1]*n+i[4]*r+i[7],t},de.transformMat4=function(t,e,i){var n=e[0],r=e[1];return t[0]=i[0]*n+i[4]*r+i[12],t[1]=i[1]*n+i[5]*r+i[13],t},de.rotate=function(t,e,i,n){var r=e[0]-i[0],o=e[1]-i[1],s=Math.sin(n),a=Math.cos(n);return t[0]=r*a-o*s+i[0],t[1]=r*s+o*a+i[1],t},de.angle=function(t,e){var i=t[0],n=t[1],r=e[0],o=e[1],s=Math.sqrt(i*i+n*n)*Math.sqrt(r*r+o*o);return Math.acos(Math.min(Math.max(s&&(i*r+n*o)/s,-1),1))},de.zero=function(t){return t[0]=0,t[1]=0,t},de.str=function(t){return"vec2("+t[0]+", "+t[1]+")"},de.exactEquals=function(t,e){return t[0]===e[0]&&t[1]===e[1]},de.equals=function(t,e){var i=t[0],n=t[1],r=e[0],o=e[1];return Math.abs(i-r)1)return 1;for(var i=t,n=0;nr?s=i:a=i,i=.5*(a-s)+s;return i},solve:function(t,e){return this.sampleCurveY(this.solveCurveX(t,e))}};var Be=h(Re),Fe=Ne;function Ne(t,e){this.x=t,this.y=e}Ne.prototype={clone:function(){return new Ne(this.x,this.y)},add:function(t){return this.clone()._add(t)},sub:function(t){return this.clone()._sub(t)},multByPoint:function(t){return this.clone()._multByPoint(t)},divByPoint:function(t){return this.clone()._divByPoint(t)},mult:function(t){return this.clone()._mult(t)},div:function(t){return this.clone()._div(t)},rotate:function(t){return this.clone()._rotate(t)},rotateAround:function(t,e){return this.clone()._rotateAround(t,e)},matMult:function(t){return this.clone()._matMult(t)},unit:function(){return this.clone()._unit()},perp:function(){return this.clone()._perp()},round:function(){return this.clone()._round()},mag:function(){return Math.sqrt(this.x*this.x+this.y*this.y)},equals:function(t){return this.x===t.x&&this.y===t.y},dist:function(t){return Math.sqrt(this.distSqr(t))},distSqr:function(t){var e=t.x-this.x,i=t.y-this.y;return e*e+i*i},angle:function(){return Math.atan2(this.y,this.x)},angleTo:function(t){return Math.atan2(this.y-t.y,this.x-t.x)},angleWith:function(t){return this.angleWithSep(t.x,t.y)},angleWithSep:function(t,e){return Math.atan2(this.x*e-this.y*t,this.x*t+this.y*e)},_matMult:function(t){var e=t[2]*this.x+t[3]*this.y;return this.x=t[0]*this.x+t[1]*this.y,this.y=e,this},_add:function(t){return this.x+=t.x,this.y+=t.y,this},_sub:function(t){return this.x-=t.x,this.y-=t.y,this},_mult:function(t){return this.x*=t,this.y*=t,this},_div:function(t){return this.x/=t,this.y/=t,this},_multByPoint:function(t){return this.x*=t.x,this.y*=t.y,this},_divByPoint:function(t){return this.x/=t.x,this.y/=t.y,this},_unit:function(){return this._div(this.mag()),this},_perp:function(){var t=this.y;return this.y=this.x,this.x=-t,this},_rotate:function(t){var e=Math.cos(t),i=Math.sin(t),n=i*this.x+e*this.y;return this.x=e*this.x-i*this.y,this.y=n,this},_rotateAround:function(t,e){var i=Math.cos(t),n=Math.sin(t),r=e.y+n*(this.x-e.x)+i*(this.y-e.y);return this.x=e.x+i*(this.x-e.x)-n*(this.y-e.y),this.y=r,this},_round:function(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}},Ne.convert=function(t){return t instanceof Ne?t:Array.isArray(t)?new Ne(t[0],t[1]):t};var Ue=h(Fe);const je=Math.PI/180,Ve=180/Math.PI;function Ge(t){return t*je}function Ze(t){return t*Ve}const qe=[[0,0],[1,0],[1,1],[0,1]];function He(t){if(t=1)return 1;const e=t*t,i=e*t;return 4*(t{e(t,((t,e)=>{t&&(o=t),r[s]=e,0==--n&&i(o,r)}))}))}function ti(t){const e=[];for(const i in t)e.push(t[i]);return e}function ei(t,...e){for(const i of e)for(const e in i)t[e]=i[e];return t}let ii=1;function ni(){return ii++}function ri(){return function t(e){return e?(e^Math.random()*(16>>e/4)).toString(16):([1e7]+-[1e3]+-4e3+-8e3+-1e11).replace(/[018]/g,t)}()}function oi(t){return t{e[t]&&(e[t]=e[t].bind(e))}))}function li(t,e){return-1!==t.indexOf(e,t.length-e.length)}function ci(t,e,i){const n={};for(const i in t)n[i]=e.call(this,t[i],i,t);return n}function di(t,e,i){const n={};for(const i in t)e.call(this,t[i],i,t)&&(n[i]=t[i]);return n}function ui(t){return Array.isArray(t)?t.map(ui):"object"==typeof t&&t?ci(t,ui):t}const hi={};function pi(t){hi[t]||("undefined"!=typeof console&&console.warn(t),hi[t]=!0)}function fi(t,e,i){return(i.y-t.y)*(e.x-t.x)>(e.y-t.y)*(i.x-t.x)}function mi(t){let e=0;for(let i,n,r=0,o=t.length,s=o-1;r@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)(?:\=(?:([^\x00-\x20\(\)@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)|(?:\"((?:[^"\\]|\\.)*)\")))?/g,((t,i,n,r)=>{const o=n||r;return e[i]=!o||o.toLowerCase(),""})),e["max-age"]){const t=parseInt(e["max-age"],10);isNaN(t)?delete e["max-age"]:e["max-age"]=t}return e}let vi,xi,bi,wi,Ti,Si,Ei=null;function Mi(t){try{const e=self[t];return e.setItem("_mapbox_test_",1),e.removeItem("_mapbox_test_"),!0}catch(t){return!1}}function Ci(t,e){return[t[4*e],t[4*e+1],t[4*e+2],t[4*e+3]]}function Ai(t,e,i,n){for(;e>1;t[r]>1;t[r]0?1/(1.001-t):1+t}function Pi(t){return t>0?1-1/(1.001-t):-t}function $i(){return null==vi&&(vi=self.OffscreenCanvas&&new OffscreenCanvas(1,1).getContext("2d")&&"function"==typeof self.createImageBitmap),vi}const ki={now:()=>void 0!==wi?wi:performance.now(),setNow(t){wi=t},restoreNow(){wi=void 0},frame(t){const e=requestAnimationFrame(t);return{cancel:()=>cancelAnimationFrame(e)}},getImageData(t,e=0){const{width:i,height:n}=t;Ti||(Ti=document.createElement("canvas"));const r=Ti.getContext("2d",{willReadFrequently:!0});if(!r)throw new Error("failed to create canvas 2d context");return(i>Ti.width||n>Ti.height)&&(Ti.width=i,Ti.height=n),r.clearRect(-e,-e,i+2*e,n+2*e),r.drawImage(t,0,0,i,n),r.getImageData(-e,-e,i+2*e,n+2*e)},resolveURL:t=>(xi||(xi=document.createElement("a")),xi.href=t,xi.href),get devicePixelRatio(){return window.devicePixelRatio},get prefersReducedMotion(){return!!window.matchMedia&&(null==bi&&(bi=window.matchMedia("(prefers-reduced-motion: reduce)")),bi.matches)},hasCanvasFingerprintNoise(){if(void 0!==Si)return Si;if(!$i())return Si=!1,!1;const t=new OffscreenCanvas(85,1),e=t.getContext("2d",{willReadFrequently:!0});let i=0;for(let n=0;n0?`?${o}`:""}`}const Ri="mapbox-tiles";let Oi,Bi,Fi=500,Ni=50;function Ui(){try{return caches}catch(t){}}function ji(){const t=Ui();t&&!Oi&&(Oi=t.open(Ri))}let Vi=1/0;const Gi={supported:!1,testSupport:function(t){!Hi&&qi&&(Wi?Xi(t):Zi=t)}};let Zi,qi,Hi=!1,Wi=!1;const Yi="undefined"!=typeof self?self:{};function Xi(t){const e=t.createTexture();t.bindTexture(t.TEXTURE_2D,e);try{if(t.texImage2D(t.TEXTURE_2D,0,t.RGBA,t.RGBA,t.UNSIGNED_BYTE,qi),t.isContextLost())return;Gi.supported=!0}catch(t){}t.deleteTexture(e),Hi=!0}Yi.document&&(qi=Yi.document.createElement("img"),qi.onload=function(){Zi&&Xi(Zi),Zi=null,Wi=!0},qi.onerror=function(){Hi=!0,Zi=null},qi.src="data:image/webp;base64,UklGRh4AAABXRUJQVlA4TBEAAAAvAQAAAAfQ//73v/+BiOh/AAA=");const Ki={Unknown:"Unknown",Style:"Style",Source:"Source",Tile:"Tile",Glyphs:"Glyphs",SpriteImage:"SpriteImage",SpriteJSON:"SpriteJSON",Image:"Image",Model:"Model"};"function"==typeof Object.freeze&&Object.freeze(Ki);class Ji extends Error{constructor(t,e,i){401===e&&r(i)&&(t+=": you may have provided an invalid Mapbox access token. See https://docs.mapbox.com/api/overview/#access-tokens-and-token-scopes"),super(t),this.status=e,this.url=i}toString(){return`${this.name}: ${this.message} (${this.status}): ${this.url}`}}const Qi=gi()?()=>self.worker&&self.worker.referrer:()=>("blob:"===location.protocol?parent:self).location.href,tn=function(t,e){if(!(/^file:/.test(i=t.url)||/^file:/.test(Qi())&&!/^\w+:/.test(i))){if(self.fetch&&self.Request&&self.AbortController&&Request.prototype.hasOwnProperty("signal"))return function(t,e){const i=new AbortController,n=new Request(t.url,{method:t.method||"GET",body:t.body,credentials:t.credentials,headers:t.headers,referrer:Qi(),referrerPolicy:t.referrerPolicy,signal:i.signal});let o=!1,s=!1;const a=(l=n.url).indexOf("sku=")>0&&r(l);var l;"json"===t.type&&n.headers.set("Accept","application/json");const c=(i,r,o)=>{if(s)return;if(i&&"SecurityError"!==i.message&&pi(i.toString()),r&&o)return d(r);const l=Date.now();fetch(n).then((i=>{if(i.ok){const t=a?i.clone():null;return d(i,t,l)}return e(new Ji(i.statusText,i.status,t.url))})).catch((i=>{"AbortError"!==i.name&&e(new Error(`${i.message} ${t.url}`))}))},d=(i,r,a)=>{("arrayBuffer"===t.type?i.arrayBuffer():"json"===t.type?i.json():i.text()).then((t=>{s||(r&&a&&function(t,e,i){if(ji(),!Oi)return;const n=yi(e.headers.get("Cache-Control")||"");if(n["no-store"])return;const r={status:e.status,statusText:e.statusText,headers:new Headers};e.headers.forEach(((t,e)=>r.headers.set(e,t))),n["max-age"]&&r.headers.set("Expires",new Date(i+1e3*n["max-age"]).toUTCString());const o=r.headers.get("Expires");if(!o)return;if(new Date(o).getTime()-i{const i=new Response(200!==(n=e.status)&&404!==n&&[101,103,204,205,304].includes(n)?null:t,r);var n;ji(),Oi&&Oi.then((t=>t.put(s,i))).catch((t=>pi(t.message)))}))}(n,r,a),o=!0,e(null,t,i.headers.get("Cache-Control"),i.headers.get("Expires")))})).catch((t=>{s||e(new Error(t.message))}))};return a?function(t,e){if(ji(),!Oi)return e(null);Oi.then((i=>{let n=zi(t.url,{persistentParams:["language","worldview"]});const r=t.headers.get("Range");r&&(n=Di(n,{range:r})),i.match(n).then((t=>{const r=function(t){if(!t)return!1;const e=new Date(t.headers.get("Expires")||0),i=yi(t.headers.get("Cache-Control")||"");return e>Date.now()&&!i["no-cache"]}(t);i.delete(n),r&&i.put(n,t.clone()),e(null,t,r)})).catch(e)})).catch(e)}(n,c):c(null,null),{cancel:()=>{s=!0,o||i.abort()}}}(t,e);if(gi()&&self.worker&&self.worker.actor)return self.worker.actor.send("getResource",t,e,void 0,!0)}var i;return function(t,e){const i=new XMLHttpRequest;i.open(t.method||"GET",t.url,!0),"arrayBuffer"===t.type&&(i.responseType="arraybuffer");for(const e in t.headers)i.setRequestHeader(e,t.headers[e]);return"json"===t.type&&(i.responseType="text",i.setRequestHeader("Accept","application/json")),i.withCredentials="include"===t.credentials,i.onerror=()=>{e(new Error(i.statusText))},i.onload=()=>{if((i.status>=200&&i.statusi.abort()}}(t,e)},en=function(t,e){return tn(ei(t,{type:"arrayBuffer"}),e)};function nn(t){const e=document.createElement("a");return e.href=t,e.protocol===location.protocol&&e.host===location.host}const rn="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAC0lEQVQYV2NgAAIAAAUAAarVyFEAAAAASUVORK5CYII=";let on,sn;on=[],sn=0;const an=function(t,e){if(Gi.supported&&(t.headers||(t.headers={}),t.headers.accept="image/webp,*/*"),sn>=n.MAX_PARALLEL_IMAGE_REQUESTS){const i={requestParameters:t,callback:e,cancelled:!1,cancel(){this.cancelled=!0}};return on.push(i),i}sn++;let i=!1;const r=()=>{if(!i)for(i=!0,sn--;on.length&&sn{r(),t?e(t):i&&(self.createImageBitmap?function(t,e){const i=new Blob([new Uint8Array(t)],{type:"image/png"});createImageBitmap(i).then((t=>{e(null,t)})).catch((t=>{e(new Error(`Could not load image because of ${t.message}. Please make sure to use a supported image type such as PNG or JPEG. Note that SVGs are not supported.`))}))}(i,((t,i)=>e(t,i,n,o))):function(t,e){const i=new Image;i.onload=()=>{e(null,i),URL.revokeObjectURL(i.src),i.onload=null,requestAnimationFrame((()=>{i.src=rn}))},i.onerror=()=>e(new Error("Could not load image. Please make sure to use a supported image type such as PNG or JPEG. Note that SVGs are not supported."));const n=new Blob([new Uint8Array(t)],{type:"image/png"});i.src=t.byteLength?URL.createObjectURL(n):rn}(i,((t,i)=>e(t,i,n,o))))}));return{cancel:()=>{o.cancel(),r()}}},ln="01",cn="NO_ACCESS_TOKEN",dn=/^(\w+):\/\/([^/?]*)(\/[^?]+)?\??(.+)?/;function un(t){const e=t.match(dn);if(!e)throw new Error("Unable to parse URL object");return{protocol:e[1],authority:e[2],path:e[3]||"/",params:e[4]?e[4].split("&"):[]}}function hn(t){const e=t.params.length?`?${t.params.join("&")}`:"";return`${t.protocol}://${t.authority}${t.path}${e}`}const pn="mapbox.eventData";function fn(t){if(!t)return null;const e=t.split(".");if(!e||3!==e.length)return null;try{return JSON.parse(decodeURIComponent(atob(e[1]).split("").map((t=>"%"+("00"+t.charCodeAt(0).toString(16)).slice(-2))).join("")))}catch(t){return null}}class mn{constructor(t){this.type=t,this.anonId=null,this.eventData={},this.queue=[],this.pendingRequest=null}getStorageKey(t){const e=fn(n.ACCESS_TOKEN);let i="";return i=e&&e.u?btoa(encodeURIComponent(e.u).replace(/%([0-9A-F]{2})/g,((t,e)=>String.fromCharCode(Number("0x"+e))))):n.ACCESS_TOKEN||"",t?`${pn}.${t}:${i}`:`${pn}:${i}`}fetchEventData(){const t=Mi("localStorage"),e=this.getStorageKey(),i=this.getStorageKey("uuid");if(t)try{const t=localStorage.getItem(e);t&&(this.eventData=JSON.parse(t));const n=localStorage.getItem(i);n&&(this.anonId=n)}catch(t){pi("Unable to read from LocalStorage")}}saveEventData(){const t=Mi("localStorage"),e=this.getStorageKey(),i=this.getStorageKey("uuid"),n=this.anonId;if(t&&n)try{localStorage.setItem(i,n),Object.keys(this.eventData).length>=1&&localStorage.setItem(e,JSON.stringify(this.eventData))}catch(t){pi("Unable to write to LocalStorage")}}processRequests(t){}postEvent(t,e,i,r){if(!n.EVENTS_URL)return;const o=un(n.EVENTS_URL);o.params.push(`access_token=${r||n.ACCESS_TOKEN||""}`);const s={event:this.type,created:new Date(t).toISOString()},a=e?ei(s,e):s,l={url:hn(o),headers:{"Content-Type":"text/plain"},body:JSON.stringify([a])};this.pendingRequest=function(t,e){return tn(ei(t,{method:"POST"}),e)}(l,(t=>{this.pendingRequest=null,i(t),this.saveEventData(),this.processRequests(r)}))}queueRequest(t,e){this.queue.push(t),this.processRequests(e)}}const _n=new class extends mn{constructor(t){super("appUserTurnstile"),this._customAccessToken=t}postTurnstileEvent(t,e){n.EVENTS_URL&&n.ACCESS_TOKEN&&Array.isArray(t)&&t.some((t=>o(t)||r(t)))&&this.queueRequest(Date.now(),e)}processRequests(t){if(this.pendingRequest||0===this.queue.length)return;this.anonId&&this.eventData.lastSuccess&&this.eventData.tokenU||this.fetchEventData();const i=fn(n.ACCESS_TOKEN),r=i?i.u:n.ACCESS_TOKEN;let o=r!==this.eventData.tokenU;si(this.anonId)||(this.anonId=ri(),o=!0);const s=this.queue.shift();if(this.eventData.lastSuccess){const t=new Date(this.eventData.lastSuccess),e=new Date(s),i=(s-this.eventData.lastSuccess)/864e5;o=o||i>=1||i{t||(this.eventData.lastSuccess=s,this.eventData.tokenU=r)}),t):this.processRequests()}},gn=_n.postTurnstileEvent.bind(_n),yn=new class extends mn{constructor(){super("map.load"),this.success={},this.skuToken=""}postMapLoadEvent(t,e,i,r){this.skuToken=e,this.errorCb=r,n.EVENTS_URL&&(i||n.ACCESS_TOKEN?this.queueRequest({id:t,timestamp:Date.now()},i):this.errorCb(new Error(cn)))}processRequests(t){if(this.pendingRequest||0===this.queue.length)return;const{id:i,timestamp:n}=this.queue.shift();i&&this.success[i]||(this.anonId||this.fetchEventData(),si(this.anonId)||(this.anonId=ri()),this.postEvent(n,{sdkIdentifier:"mapbox-gl-js",sdkVersion:e,skuId:ln,skuToken:this.skuToken,userId:this.anonId},(t=>{t?this.errorCb(t):i&&(this.success[i]=!0)}),t))}remove(){this.errorCb=null}},vn=yn.postMapLoadEvent.bind(yn),xn=new class extends mn{constructor(){super("style.load"),this.eventIdPerMapInstanceMap=new Map,this.mapInstanceIdMap=new WeakMap}getMapInstanceId(t){let e=this.mapInstanceIdMap.get(t);return e||(e=ri(),this.mapInstanceIdMap.set(t,e)),e}getEventId(t){const e=this.eventIdPerMapInstanceMap.get(t)||0;return this.eventIdPerMapInstanceMap.set(t,e+1),e}postStyleLoadEvent(t,e){const{map:i,style:r,importedStyles:o}=e;if(!n.EVENTS_URL||!t&&!n.ACCESS_TOKEN)return;const s=this.getMapInstanceId(i),a={mapInstanceId:s,eventId:this.getEventId(s),style:r};o.length&&(a.importedStyles=o),this.queueRequest({timestamp:Date.now(),payload:a},t)}processRequests(t){if(this.pendingRequest||0===this.queue.length)return;const{timestamp:e,payload:i}=this.queue.shift();this.postEvent(e,i,(()=>{}),t)}},bn=xn.postStyleLoadEvent.bind(xn),wn=new class extends mn{constructor(){super("gljs.performance")}postPerformanceEvent(t,e){n.EVENTS_URL&&(t||n.ACCESS_TOKEN)&&this.queueRequest({timestamp:Date.now(),performanceData:e},t)}processRequests(t){if(this.pendingRequest||0===this.queue.length)return;const{timestamp:i,performanceData:n}=this.queue.shift(),r=function(t){const i=performance.getEntriesByType("resource"),n=performance.getEntriesByType("mark"),r=function(t){const e={};if(t)for(const i in t)if("other"!==i)for(const n of t[i]){const t=`${i}ResolveRangeMin`,r=`${i}ResolveRangeMax`,o=`${i}RequestCount`,s=`${i}RequestCachedCount`;e[t]=Math.min(e[t]||1/0,n.startTime),e[r]=Math.max(e[r]||-1/0,n.responseEnd);const a=t=>{void 0===e[t]&&(e[t]=0),++e[t]};void 0!==n.transferSize&&0===n.transferSize&&a(s),a(o)}return e}(function(t,e){const i={};if(t)for(const n of t){const t=e(n);void 0===i[t]&&(i[t]=[]),i[t].push(n)}return i}(i,u)),o=window.devicePixelRatio,s=navigator.connection||navigator.mozConnection||navigator.webkitConnection,a=s?s.effectiveType:void 0,d={counters:[],metadata:[],attributes:[]},h=(t,e,i)=>{null!=i&&t.push({name:e,value:i.toString()})};for(const t in r)h(d.counters,t,r[t]);if(t.interactionRange[0]!==1/0&&t.interactionRange[1]!==-1/0&&(h(d.counters,"interactionRangeMin",t.interactionRange[0]),h(d.counters,"interactionRangeMax",t.interactionRange[1])),n)for(const t of Object.keys(c)){const e=c[t],i=n.find((t=>t.name===e));i&&h(d.counters,e,i.startTime)}return h(d.counters,"visibilityHidden",t.visibilityHidden),h(d.attributes,"style",function(t){if(t)for(const e of t){const t=e.name.split("?")[0];if(l(t)){const e=t.split("/").slice(-2);if(2===e.length)return`mapbox://styles/${e[0]}/${e[1]}`}}}(i)),h(d.attributes,"terrainEnabled",t.terrainEnabled?"true":"false"),h(d.attributes,"fogEnabled",t.fogEnabled?"true":"false"),h(d.attributes,"projection",t.projection),h(d.attributes,"zoom",t.zoom),h(d.metadata,"devicePixelRatio",o),h(d.metadata,"connectionEffectiveType",a),h(d.metadata,"navigatorUserAgent",navigator.userAgent),h(d.metadata,"screenWidth",window.screen.width),h(d.metadata,"screenHeight",window.screen.height),h(d.metadata,"windowWidth",window.innerWidth),h(d.metadata,"windowHeight",window.innerHeight),h(d.metadata,"mapWidth",t.width/o),h(d.metadata,"mapHeight",t.height/o),h(d.metadata,"webglRenderer",t.renderer),h(d.metadata,"webglVendor",t.vendor),h(d.metadata,"sdkVersion",e),h(d.metadata,"sdkIdentifier","mapbox-gl-js"),d}(n);for(const t of r.metadata);for(const t of r.counters);for(const t of r.attributes);this.postEvent(i,r,(()=>{}),t)}},Tn=wn.postPerformanceEvent.bind(wn),Sn=new class extends mn{constructor(){super("map.auth"),this.success={},this.skuToken=""}getSession(t,e,i,r){if(!n.API_URL||!n.SESSION_PATH)return;const o=un(n.API_URL+n.SESSION_PATH);o.params.push(`sku=${e||""}`),o.params.push(`access_token=${r||n.ACCESS_TOKEN||""}`);const s={url:hn(o),headers:{"Content-Type":"text/plain"}};this.pendingRequest=function(t,e){return tn(ei(t,{method:"GET"}),e)}(s,(t=>{this.pendingRequest=null,i(t),this.saveEventData(),this.processRequests(r)}))}getSessionAPI(t,e,i,r){this.skuToken=e,this.errorCb=r,n.SESSION_PATH&&n.API_URL&&(i||n.ACCESS_TOKEN?this.queueRequest({id:t,timestamp:Date.now()},i):this.errorCb(new Error(cn)))}processRequests(t){if(this.pendingRequest||0===this.queue.length)return;const{id:e,timestamp:i}=this.queue.shift();e&&this.success[e]||this.getSession(i,this.skuToken,(t=>{t?this.errorCb(t):e&&(this.success[e]=!0)}),t)}remove(){this.errorCb=null}},En=Sn.getSessionAPI.bind(Sn),Mn=new Set;var Cn={exports:{}},An=function(t,e){var i,n,r,o,s,a,l,c;for(n=t.length-(i=3&t.length),r=e,s=3432918353,a=461845907,c=0;c>>16)*s&65535)>>17))*a+(((l>>>16)*a&65535)>>19))+((5*(r>>>16)&65535)>>16)&65535)>>16)*s&65535)>>17))*a+(((l>>>16)*a&65535)>>16))+((2246822507*(r>>>16)&65535)>>13))+((3266489909*(r>>>16)&65535)>>16)>>>0},In=function(t,e){for(var i,n=t.length,r=e^n,o=0;n>=4;)i=1540483477*(65535&(i=255&t.charCodeAt(o)|(255&t.charCodeAt(++o))>>16)&65535)>>16)&65535)>>24))+((1540483477*(i>>>16)&65535)>>16)&65535)>>13))+((1540483477*(r>>>16)&65535)>>15)>>>0};Cn.exports=An,Cn.exports.murmur3=An,Cn.exports.murmur2=In;var Ln=h(Cn.exports);class Pn{constructor(t,...e){ei(this,e[0]||{}),this.type=t}}class $n extends Pn{constructor(t,e={}){super("error",ei({error:t},e))}}function kn(t,e,i){i[t]&&-1!==i[t].indexOf(e)||(i[t]=i[t]||[],i[t].push(e))}function Dn(t,e,i){if(i&&i[t]){const n=i[t].indexOf(e);-1!==n&&i[t].splice(n,1)}}class zn{on(t,e){return this._listeners=this._listeners||{},kn(t,e,this._listeners),this}off(t,e){return Dn(t,e,this._listeners),Dn(t,e,this._oneTimeListeners),this}once(t,e){return e?(this._oneTimeListeners=this._oneTimeListeners||{},kn(t,e,this._oneTimeListeners),this):new Promise((e=>this.once(t,e)))}fire(t,e){const i="string"==typeof t?new Pn(t,e):t,n=i.type;if(this.listens(n)){i.target=this;const t=this._listeners&&this._listeners[n]?this._listeners[n].slice():[];for(const e of t)e.call(this,i);const e=this._oneTimeListeners&&this._oneTimeListeners[n]?this._oneTimeListeners[n].slice():[];for(const t of e)Dn(n,t,this._oneTimeListeners),t.call(this,i);const r=this._eventedParent;r&&(ei(i,"function"==typeof this._eventedParentData?this._eventedParentData():this._eventedParentData),r.fire(i))}else i instanceof $n&&console.error(i.error);return this}listens(t){return!!(this._listeners&&this._listeners[t]&&this._listeners[t].length>0||this._oneTimeListeners&&this._oneTimeListeners[t]&&this._oneTimeListeners[t].length>0||this._eventedParent&&this._eventedParent.listens(t))}setEventedParent(t,e){return this._eventedParent=t,this._eventedParentData=e,this}}t.F=void 0;var Rn={transparent:[0,0,0,0],aliceblue:[240,248,255,1],antiquewhite:[250,235,215,1],aqua:[0,255,255,1],aquamarine:[127,255,212,1],azure:[240,255,255,1],beige:[245,245,220,1],bisque:[255,228,196,1],black:[0,0,0,1],blanchedalmond:[255,235,205,1],blue:[0,0,255,1],blueviolet:[138,43,226,1],brown:[165,42,42,1],burlywood:[222,184,135,1],cadetblue:[95,158,160,1],chartreuse:[127,255,0,1],chocolate:[210,105,30,1],coral:[255,127,80,1],cornflowerblue:[100,149,237,1],cornsilk:[255,248,220,1],crimson:[220,20,60,1],cyan:[0,255,255,1],darkblue:[0,0,139,1],darkcyan:[0,139,139,1],darkgoldenrod:[184,134,11,1],darkgray:[169,169,169,1],darkgreen:[0,100,0,1],darkgrey:[169,169,169,1],darkkhaki:[189,183,107,1],darkmagenta:[139,0,139,1],darkolivegreen:[85,107,47,1],darkorange:[255,140,0,1],darkorchid:[153,50,204,1],darkred:[139,0,0,1],darksalmon:[233,150,122,1],darkseagreen:[143,188,143,1],darkslateblue:[72,61,139,1],darkslategray:[47,79,79,1],darkslategrey:[47,79,79,1],darkturquoise:[0,206,209,1],darkviolet:[148,0,211,1],deeppink:[255,20,147,1],deepskyblue:[0,191,255,1],dimgray:[105,105,105,1],dimgrey:[105,105,105,1],dodgerblue:[30,144,255,1],firebrick:[178,34,34,1],floralwhite:[255,250,240,1],forestgreen:[34,139,34,1],fuchsia:[255,0,255,1],gainsboro:[220,220,220,1],ghostwhite:[248,248,255,1],gold:[255,215,0,1],goldenrod:[218,165,32,1],gray:[128,128,128,1],green:[0,128,0,1],greenyellow:[173,255,47,1],grey:[128,128,128,1],honeydew:[240,255,240,1],hotpink:[255,105,180,1],indianred:[205,92,92,1],indigo:[75,0,130,1],ivory:[255,255,240,1],khaki:[240,230,140,1],lavender:[230,230,250,1],lavenderblush:[255,240,245,1],lawngreen:[124,252,0,1],lemonchiffon:[255,250,205,1],lightblue:[173,216,230,1],lightcoral:[240,128,128,1],lightcyan:[224,255,255,1],lightgoldenrodyellow:[250,250,210,1],lightgray:[211,211,211,1],lightgreen:[144,238,144,1],lightgrey:[211,211,211,1],lightpink:[255,182,193,1],lightsalmon:[255,160,122,1],lightseagreen:[32,178,170,1],lightskyblue:[135,206,250,1],lightslategray:[119,136,153,1],lightslategrey:[119,136,153,1],lightsteelblue:[176,196,222,1],lightyellow:[255,255,224,1],lime:[0,255,0,1],limegreen:[50,205,50,1],linen:[250,240,230,1],magenta:[255,0,255,1],maroon:[128,0,0,1],mediumaquamarine:[102,205,170,1],mediumblue:[0,0,205,1],mediumorchid:[186,85,211,1],mediumpurple:[147,112,219,1],mediumseagreen:[60,179,113,1],mediumslateblue:[123,104,238,1],mediumspringgreen:[0,250,154,1],mediumturquoise:[72,209,204,1],mediumvioletred:[199,21,133,1],midnightblue:[25,25,112,1],mintcream:[245,255,250,1],mistyrose:[255,228,225,1],moccasin:[255,228,181,1],navajowhite:[255,222,173,1],navy:[0,0,128,1],oldlace:[253,245,230,1],olive:[128,128,0,1],olivedrab:[107,142,35,1],orange:[255,165,0,1],orangered:[255,69,0,1],orchid:[218,112,214,1],palegoldenrod:[238,232,170,1],palegreen:[152,251,152,1],paleturquoise:[175,238,238,1],palevioletred:[219,112,147,1],papayawhip:[255,239,213,1],peachpuff:[255,218,185,1],peru:[205,133,63,1],pink:[255,192,203,1],plum:[221,160,221,1],powderblue:[176,224,230,1],purple:[128,0,128,1],rebeccapurple:[102,51,153,1],red:[255,0,0,1],rosybrown:[188,143,143,1],royalblue:[65,105,225,1],saddlebrown:[139,69,19,1],salmon:[250,128,114,1],sandybrown:[244,164,96,1],seagreen:[46,139,87,1],seashell:[255,245,238,1],sienna:[160,82,45,1],silver:[192,192,192,1],skyblue:[135,206,235,1],slateblue:[106,90,205,1],slategray:[112,128,144,1],slategrey:[112,128,144,1],snow:[255,250,250,1],springgreen:[0,255,127,1],steelblue:[70,130,180,1],tan:[210,180,140,1],teal:[0,128,128,1],thistle:[216,191,216,1],tomato:[255,99,71,1],turquoise:[64,224,208,1],violet:[238,130,238,1],wheat:[245,222,179,1],white:[255,255,255,1],whitesmoke:[245,245,245,1],yellow:[255,255,0,1],yellowgreen:[154,205,50,1]};function On(t){return(t=Math.round(t))255?255:t}function Bn(t){return On("%"===t[t.length-1]?parseFloat(t)/100*255:parseInt(t))}function Fn(t){return(e="%"===t[t.length-1]?parseFloat(t)/100:parseFloat(t))1?1:e;var e}function Nn(t,e,i){return i1&&(i-=1),6*i=0&&e>4|(3840&e)>>8,240&e|(240&e)>>4,15&e|(15&e)=0&&e>16,(65280&e)>>8,255&e,1]:null;var n=i.indexOf("("),r=i.indexOf(")");if(-1!==n&&r+1===i.length){var o=i.substr(0,n),s=i.substr(n+1,r-(n+1)).split(","),a=1;switch(o){case"rgba":if(4!==s.length)return null;a=Fn(s.pop());case"rgb":return 3!==s.length?null:[Bn(s[0]),Bn(s[1]),Bn(s[2]),a];case"hsla":if(4!==s.length)return null;a=Fn(s.pop());case"hsl":if(3!==s.length)return null;var l=(parseFloat(s[0])%360+360)%360/360,c=Fn(s[1]),d=Fn(s[2]),u=d=_.length)throw new Error("out of range");this.r=Vn(Vn(Vn(_[g],_[y],m),Vn(_[v],_[x],m),f),Vn(Vn(_[b],_[w],m),Vn(_[T],_[S],m),f),p)/255*r,this.g=Vn(Vn(Vn(_[g+1],_[y+1],m),Vn(_[v+1],_[x+1],m),f),Vn(Vn(_[b+1],_[w+1],m),Vn(_[T+1],_[S+1],m),f),p)/255*r,this.b=Vn(Vn(Vn(_[g+2],_[y+2],m),Vn(_[v+2],_[x+2],m),f),Vn(Vn(_[b+2],_[w+2],m),Vn(_[T+2],_[S+2],m),f),p)/255*r,this.a=r}else this.r=e,this.g=i,this.b=n,this.a=r}toArray(){const{r:t,g:e,b:i,a:n}=this;return 0===n?[0,0,0,0]:[255*t/n,255*e/n,255*i/n,n]}toArray01(){const{r:t,g:e,b:i,a:n}=this;return 0===n?[0,0,0,0]:[t/n,e/n,i/n,n]}toArray01Scaled(t){const{r:e,g:i,b:n,a:r}=this;return 0===r?[0,0,0]:[e/r*t,i/r*t,n/r*t]}toArray01PremultipliedAlpha(){const{r:t,g:e,b:i,a:n}=this;return[t,e,i,n]}toArray01Linear(){const{r:t,g:e,b:i,a:n}=this;return 0===n?[0,0,0,0]:[Math.pow(t/n,2.2),Math.pow(e/n,2.2),Math.pow(i/n,2.2),n]}}function Vn(t,e,i){return t*(1-i)+e*i}function Gn(t,e,i){return t.map(((t,n)=>Vn(t,e[n],i)))}Un.black=new Un(0,0,0,1),Un.white=new Un(1,1,1,1),Un.transparent=new Un(0,0,0,0),Un.red=new Un(1,0,0,1),Un.blue=new Un(0,0,1,1);var Zn=Object.freeze({__proto__:null,array:Gn,color:function(t,e,i){return new Un(Vn(t.r,e.r,i),Vn(t.g,e.g,i),Vn(t.b,e.b,i),Vn(t.a,e.a,i))},number:Vn});function qn(t,...e){for(const i of e)for(const e in i)t[e]=i[e];return t}class Hn extends Error{constructor(t,e){super(e),this.message=e,this.key=t}}class Wn{constructor(t,e=[]){this.parent=t,this.bindings={};for(const[t,i]of e)this.bindings[t]=i}concat(t){return new Wn(this,t)}get(t){if(this.bindings[t])return this.bindings[t];if(this.parent)return this.parent.get(t);throw new Error(`${t} not found in scope.`)}has(t){return!!this.bindings[t]||!!this.parent&&this.parent.has(t)}}const Yn={kind:"null"},Xn={kind:"number"},Kn={kind:"string"},Jn={kind:"boolean"},Qn={kind:"color"},tr={kind:"object"},er={kind:"value"},ir={kind:"collator"},nr={kind:"formatted"},rr={kind:"resolvedImage"};function or(t,e){return{kind:"array",itemType:t,N:e}}function sr(t){if("array"===t.kind){const e=sr(t.itemType);return"number"==typeof t.N?`array`:"value"===t.itemType.kind?"array":`array`}return t.kind}const ar=[Yn,Xn,Kn,Jn,Qn,nr,tr,or(er),rr];function lr(t,e){if("error"===e.kind)return null;if("array"===t.kind){if("array"===e.kind&&(0===e.N&&"value"===e.itemType.kind||!lr(t.itemType,e.itemType))&&("number"!=typeof t.N||t.N===e.N))return null}else{if(t.kind===e.kind)return null;if("value"===t.kind)for(const t of ar)if(!lr(t,e))return null}return`Expected ${sr(t)} but found ${sr(e)} instead.`}function cr(t,e){return e.some((e=>e.kind===t.kind))}function dr(t,e){return e.some((e=>"null"===e?null===t:"array"===e?Array.isArray(t):"object"===e?t&&!Array.isArray(t)&&"object"==typeof t:e===typeof t))}class ur{constructor(t,e,i){this.sensitivity=t?e?"variant":"case":e?"accent":"base",this.locale=i,this.collator=new Intl.Collator(this.locale?this.locale:[],{sensitivity:this.sensitivity,usage:"search"})}compare(t,e){return this.collator.compare(t,e)}resolvedLocale(){return new Intl.Collator(this.locale?this.locale:[]).resolvedOptions().locale}}class hr{constructor(t,e,i,n,r){this.text=t.normalize?t.normalize():t,this.image=e,this.scale=i,this.fontStack=n,this.textColor=r}}class pr{constructor(t){this.sections=t}static fromString(t){return new pr([new hr(t,null,null,null,null)])}isEmpty(){return 0===this.sections.length||!this.sections.some((t=>0!==t.text.length||t.image&&0!==t.image.namePrimary.length))}static factory(t){return t instanceof pr?t:pr.fromString(t)}toString(){return 0===this.sections.length?"":this.sections.map((t=>t.text)).join("")}serialize(){const t=["format"];for(const e of this.sections){if(e.image){t.push(["image",e.image.namePrimary]);continue}t.push(e.text);const i={};e.fontStack&&(i["text-font"]=["literal",e.fontStack.split(",")]),e.scale&&(i["font-scale"]=e.scale),e.textColor&&(i["text-color"]=["rgba"].concat(e.textColor.toRenderColor(null).toArray())),t.push(i)}return t}}class fr{constructor(t){this.namePrimary=t.namePrimary,t.nameSecondary&&(this.nameSecondary=t.nameSecondary),this.available=t.available}toString(){return this.nameSecondary?`[${this.namePrimary},${this.nameSecondary}]`:this.namePrimary}static fromString(t,e){return t?new fr({namePrimary:t,nameSecondary:e,available:!1}):null}serialize(){return this.nameSecondary?["image",this.namePrimary,this.nameSecondary]:["image",this.namePrimary]}}function mr(t,e,i,n){return"number"==typeof t&&t>=0&&t=0&&e=0&&i=0&&n2){const i=t[1];if("string"!=typeof i||!(i in br)||"object"===i)return e.error('The item type argument of "array" must be one of string, number, boolean',1);r=br[i],n++}else r=er;if(t.length>3){if(null!==t[2]&&("number"!=typeof t[2]||t[2]t.outputDefined()))}serialize(){const t=this.type,e=[t.kind];if("array"===t.kind){const i=t.itemType;if("string"===i.kind||"number"===i.kind||"boolean"===i.kind){e.push(i.kind);const n=t.N;("number"==typeof n||this.args.length>1)&&e.push(n)}}return e.concat(this.args.map((t=>t.serialize())))}}class Tr{constructor(t){this.type=nr,this.sections=t}static parse(t,e){if(t.length{const i=e.content.evaluate(t);return gr(i)===rr?new hr("",i,null,null,null):new hr(yr(i),null,e.scale?e.scale.evaluate(t):null,e.font?e.font.evaluate(t).join(","):null,e.textColor?e.textColor.evaluate(t):null)})))}eachChild(t){for(const e of this.sections)t(e.content),e.scale&&t(e.scale),e.font&&t(e.font),e.textColor&&t(e.textColor)}outputDefined(){return!1}serialize(){const t=["format"];for(const e of this.sections){t.push(e.content.serialize());const i={};e.scale&&(i["font-scale"]=e.scale.serialize()),e.font&&(i["text-font"]=e.font.serialize()),e.textColor&&(i["text-color"]=e.textColor.serialize()),t.push(i)}return t}}class Sr{constructor(t,e){this.type=rr,this.inputPrimary=t,this.inputSecondary=e}static parse(t,e){if(t.length-1,e.nameSecondary&&e.available&&t.availableImages&&(e.available=t.availableImages.indexOf(e.nameSecondary)>-1)),e}eachChild(t){t(this.inputPrimary),this.inputSecondary&&t(this.inputSecondary)}outputDefined(){return!1}serialize(){return this.inputSecondary?["image",this.inputPrimary.serialize(),this.inputSecondary.serialize()]:["image",this.inputPrimary.serialize()]}}function Er(t){return t instanceof Number?"number":t instanceof String?"string":t instanceof Boolean?"boolean":Array.isArray(t)?"array":null===t?"null":typeof t}const Mr={"to-boolean":Jn,"to-color":Qn,"to-number":Xn,"to-string":Kn};class Cr{constructor(t,e){this.type=t,this.args=e}static parse(t,e){if(t.length0&&_r(t[1][0])))return null;r=or(gr(t[1][0]),i)}for(let o=0;o4?`Invalid rbga value ${JSON.stringify(e)}: expected an array containing either three or four numeric values.`:mr(e[0],e[1],e[2],e[3]),!i))return new Un(e[0]/255,e[1]/255,e[2]/255,e[3])}throw new xr(i||`Could not parse color from value '${"string"==typeof e?e:String(JSON.stringify(e))}'`)}if("number"===this.type.kind){let e=null;for(const i of this.args){if(e=i.evaluate(t),null===e)return 0;const n=Number(e);if(!isNaN(n))return n}throw new xr(`Could not convert ${JSON.stringify(e)} to number.`)}return"formatted"===this.type.kind?pr.fromString(yr(this.args[0].evaluate(t))):"resolvedImage"===this.type.kind?fr.fromString(yr(this.args[0].evaluate(t))):"array"===this.type.kind?this.args.map((e=>e.evaluate(t))):yr(this.args[0].evaluate(t))}eachChild(t){this.args.forEach(t)}outputDefined(){return this.args.every((t=>t.outputDefined()))}serialize(){if("formatted"===this.type.kind)return new Tr([{content:this.args[0],scale:null,font:null,textColor:null}]).serialize();if("resolvedImage"===this.type.kind)return new Sr(this.args[0]).serialize();const t="array"===this.type.kind?[]:[`to-${this.type.kind}`];return this.eachChild((e=>{t.push(e.serialize())})),t}}const Ar=["Unknown","Point","LineString","Polygon"];class Ir{constructor(t,e){this.globals=null,this.feature=null,this.featureState=null,this.formattedSection=null,this._parseColorCache={},this.availableImages=null,this.canonical=null,this.featureTileCoord=null,this.featureDistanceData=null,this.scope=t,this.options=e}id(){return this.feature&&void 0!==this.feature.id?this.feature.id:null}geometryType(){return this.feature?"number"==typeof this.feature.type?Ar[this.feature.type]:this.feature.type:null}geometry(){return this.feature&&"geometry"in this.feature?this.feature.geometry:null}canonicalID(){return this.canonical}properties(){return this.feature&&this.feature.properties||{}}measureLight(t){return this.globals.brightness||0}distanceFromCenter(){if(this.featureTileCoord&&this.featureDistanceData){const t=this.featureDistanceData.center,e=this.featureDistanceData.scale,{x:i,y:n}=this.featureTileCoord;return this.featureDistanceData.bearing[0]*(i*e-t[0])+this.featureDistanceData.bearing[1]*(n*e-t[1])}return 0}parseColor(t){let e=this._parseColorCache[t];return e||(e=this._parseColorCache[t]=Un.parse(t)),e}getConfig(t){return this.options?this.options.get(t):null}}class Lr{constructor(t,e,i,n,r){this.name=t,this.type=e,this._evaluate=i,this.args=n,this._overloadIndex=r}evaluate(t){if(!this._evaluate){const t=Lr.definitions[this.name];this._evaluate=Array.isArray(t)?t[2]:t.overloads[this._overloadIndex][1]}return this._evaluate(t,this.args)}eachChild(t){this.args.forEach(t)}outputDefined(){return!1}serialize(){return[this.name].concat(this.args.map((t=>t.serialize())))}static parse(t,e){const i=t[0],n=Lr.definitions[i];if(!n)return e.error(`Unknown expression "${i}". If you wanted a literal array, use ["literal", [...]].`,0);const r=Array.isArray(n)?n[0]:n.type,o=Array.isArray(n)?[[n[1],n[2]]]:n.overloads,s=[];let a=null,l=-1;for(const[n,c]of o){if(Array.isArray(n)&&n.length!==t.length-1)continue;s.push(n),l++,a=new Ko(e.registry,e.path,null,e.scope,void 0,e._scope,e.options);const o=[];let d=!1;for(let e=1;et))).map(Pr).join(" | "),n=[];for(let i=1;ii;){if(n-i>600){const o=n-i+1,s=e-i+1,a=Math.log(o),l=.5*Math.exp(2*a/3),c=.5*Math.sqrt(a*l*(o-l)/o)*(s-o/20&&Dr(t,i,n);s0;)a--}0===r(t[i],o)?Dr(t,i,a):(a++,Dr(t,a,n)),ae?1:0}function Rr(t){let e=0;for(let i,n,r=0,o=t.length,s=o-1;r=e[2]||t[1]=e[3])}function Fr(t,e,i){const n=t[0]-e[0],r=t[1]-e[1],o=t[0]-i[0],s=t[1]-i[1];return n*s-o*r==0&&n*o(r=t)[1]!=(s=d)[1]>r[1]&&r[0]0&&a0}function jr(t,e,i,n){return 0!=(r=[n[0]-i[0],n[1]-i[1]])[0]*(o=[e[0]-t[0],e[1]-t[1]])[1]-r[1]*o[0]&&!(!Ur(t,e,i,n)||!Ur(i,n,t,e));var r,o}const Vr=8192;function Gr(t,e){const i=(180+t[0])/360,n=(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+t[1]*Math.PI/360)))/360,r=Math.pow(2,e.z);return[Math.round(i*r*Vr),Math.round(n*r*Vr)]}function Zr(t,e){for(let i=0;ii[2]){const e=.5*n;let r=t[0]-i[0]>e?-n:i[0]-t[0]>e?n:0;0===r&&(r=t[0]-i[2]>e?-n:i[2]-t[0]>e?n:0),t[0]+=r}Or(e,t)}function Jr(t,e,i,n){const r=Math.pow(2,n.z)*Vr,o=[n.x*Vr,n.y*Vr],s=[];if(!t)return s;for(const n of t)for(const t of n){const n=[t.x+o[0],t.y+o[1]];Kr(n,e,i,r),s.push(n)}return s}function Qr(t,e,i,n){const r=Math.pow(2,n.z)*Vr,o=[n.x*Vr,n.y*Vr],s=[];if(!t)return s;for(const i of t){const t=[];for(const n of i){const i=[n.x+o[0],n.y+o[1]];Or(e,i),t.push(i)}s.push(t)}if(e[2]-e[0]e)return ao(r,o,(e-(i-s))/s)}return t[t.length-1]}pointToSegmentDistance(t,e,i){let[n,r]=e,o=lo(i[0]-n)*this.kx,s=(i[1]-r)*this.ky;if(0!==o||0!==s){const e=(lo(t[0]-n)*this.kx*o+(t[1]-r)*this.ky*s)/(o*o+s*s);e>1?(n=i[0],r=i[1]):e>0&&(n+=o/this.kx*e,r+=s/this.ky*e)}return o=lo(t[0]-n)*this.kx,s=(t[1]-r)*this.ky,Math.sqrt(o*o+s*s)}pointOnLine(t,e){let i=1/0,n=t[0][0],r=t[0][1],o=0,s=0;for(let a=0;a1?(l=t[a+1][0],c=t[a+1][1]):h>0&&(l+=d/this.kx*h,c+=u/this.ky*h)),d=lo(e[0]-l)*this.kx,u=(e[1]-c)*this.ky;const p=d*d+u*u;pr.index||n.index===r.index&&n.t>r.t){const t=n;n=r,r=t}const o=[n.point],s=n.index+1,a=r.index;!so(i[s],o[0])&&st&&0===r.length&&r.push(ao(s,a,(t-(n-l))/l)),n>=e)return r.push(ao(s,a,(e-(n-l))/l)),r;n>t&&r.push(a)}return r}bufferPoint(t,e){const i=e/this.ky,n=e/this.kx;return[t[0]-n,t[1]-i,t[0]+n,t[1]+i]}bufferBBox(t,e){const i=e/this.ky,n=e/this.kx;return[t[0]-n,t[1]-i,t[2]+n,t[3]+i]}insideBBox(t,e){return lo(t[0]-e[0])>=0&&lo(t[0]-e[2])=e[1]&&t[1]180;)t-=360;return t}class co{constructor(t=[],e=(t,e)=>te?1:0){if(this.data=t,this.length=this.data.length,this.compare=e,this.length>0)for(let t=(this.length>>1)-1;t>=0;t--)this._down(t)}push(t){this.data.push(t),this._up(this.length++)}pop(){if(0===this.length)return;const t=this.data[0],e=this.data.pop();return--this.length>0&&(this.data[0]=e,this._down(0)),t}peek(){return this.data[0]}_up(t){const{data:e,compare:i}=this,n=e[t];for(;t>0;){const r=t-1>>1,o=e[r];if(i(n,o)>=0)break;e[t]=o,t=r}e[t]=n}_down(t){const{data:e,compare:i}=this,n=this.length>>1,r=e[t];for(;t=0)break;e[t]=e[n],t=n}e[t]=r}}var uo=8192;function ho(t,e){return e.dist-t.dist}const po=100,fo=50;function mo(t){const e=[1/0,1/0,-1/0,-1/0];if(e.length!==t.length)return!1;for(let i=0;i=t[0]&&t[1]t[1])return[null,null];const i=_o(t);if(e){if(2===i)return[t,null];const e=Math.floor(i/2);return[[t[0],t[0]+e],[t[0]+e,t[1]]]}{if(1===i)return[t,null];const e=Math.floor(i/2)-1;return[[t[0],t[0]+e],[t[0]+e+1,t[1]]]}}function vo(t,e){const i=[1/0,1/0,-1/0,-1/0];if(!go(e,t.length))return i;for(let n=e[0];ne[2]&&(n=t[0]-e[2]),t[1]>e[3]&&(r=t[1]-e[3]),t[3]=n)return n;if(Br(r,o)){if(ko(t,e))return 0}else if(ko(e,t))return 0;let s=n;for(const n of t)for(let t=0,r=n.length,o=r-1;t=o)continue;const c=r.range1;if(_o(c)=s)continue;const d=o.range1,u=o.range2;if(_o(d)=o)&&(o=Math.min(o,Oo(t,e,r,!0,n,o)),0===o))return o;return o}function Fo(t,e,i,n,r=1/0){let o=r;const s=vo(t,[0,t.length-1]);for(const r of i){if(o!==1/0&&bo(s,xo(r),n)>=o)continue;const i=Ro(t,e,r,n,o);if(isNaN(i))return i;if(0===(o=Math.min(o,i)))return o}return o}function No(t){return"Point"===t||"MultiPoint"===t||"LineString"===t||"MultiLineString"===t||"Polygon"===t||"MultiPolygon"===t}class Uo{constructor(t,e){this.type=Xn,this.geojson=t,this.geometries=e}static parse(t,e){if(2!==t.length)return e.error(`'distance' expression requires either one argument, but found ' ${t.length-1} instead.`);if(_r(t[1])){const e=t[1];if("FeatureCollection"===e.type){for(let t=0;ti&&(t=i),t}class Go{constructor(t,e,i){this.type=t,this.key=e,this.scope=i}static parse(t,e){let i=e.expectedType;if(null==i&&(i=er),t.length3)return e.error("Invalid number of arguments for 'config' expression.");const n=e.parse(t[1],1);if(!(n instanceof vr))return e.error("Key name of 'config' expression must be a string literal.");if(t.length>=3){const r=e.parse(t[2],2);return r instanceof vr?new Go(i,yr(n.value),yr(r.value)):e.error("Scope of 'config' expression must be a string literal.")}return new Go(i,yr(n.value))}evaluate(t){const e=[this.key,this.scope,t.scope].filter(Boolean).join(""),i=t.getConfig(e);if(!i)return null;const{type:n,value:r,values:o,minValue:s,maxValue:a,stepValue:l}=i,c=i.default.evaluate(t);let d=c;if(r){const e=t.scope;t.scope=(e||"").split("").slice(1).join(""),d=r.evaluate(t),t.scope=e}return n&&(d=jo(n,d)),void 0===d||void 0===s&&void 0===a&&void 0===l||("number"==typeof d?d=Vo(d,s,a,l):Array.isArray(d)&&(d=d.map((t=>"number"==typeof t?Vo(t,s,a,l):t)))),void 0!==r&&void 0!==d&&o&&!o.includes(d)&&(d=c,n&&(d=jo(n,d))),(n&&n!==this.type||void 0!==d&&gr(d)!==this.type)&&(d=jo(this.type.kind,d)),d}eachChild(){}outputDefined(){return!1}serialize(){const t=["config",this.key];return this.scope&&t.concat(this.key),t}}function Zo(t){if(t instanceof Lr){if("get"===t.name&&1===t.args.length)return!1;if("feature-state"===t.name)return!1;if("has"===t.name&&1===t.args.length)return!1;if("properties"===t.name||"geometry-type"===t.name||"id"===t.name)return!1;if(/^filter-/.test(t.name))return!1}if(t instanceof to)return!1;if(t instanceof Uo)return!1;let e=!0;return t.eachChild((t=>{e&&!Zo(t)&&(e=!1)})),e}function qo(t){if(t instanceof Lr&&"feature-state"===t.name)return!1;let e=!0;return t.eachChild((t=>{e&&!qo(t)&&(e=!1)})),e}function Ho(t){if(t instanceof Go)return!1;let e=!0;return t.eachChild((t=>{e&&!Ho(t)&&(e=!1)})),e}function Wo(t,e){if(t instanceof Lr&&e.indexOf(t.name)>=0)return!1;let i=!0;return t.eachChild((t=>{i&&!Wo(t,e)&&(i=!1)})),i}class Yo{constructor(t,e){this.type=e.type,this.name=t,this.boundExpression=e}static parse(t,e){if(2!==t.length||"string"!=typeof t[1])return e.error("'var' expression requires exactly one string literal argument.");const i=t[1];return e.scope.has(i)?new Yo(i,e.scope.get(i)):e.error(`Unknown variable "${i}". Make sure "${i}" has been bound in an enclosing "let" expression before using it.`,1)}evaluate(t){return this.boundExpression.evaluate(t)}eachChild(){}outputDefined(){return!1}serialize(){return["var",this.name]}}class Xo{constructor(t,e=[],i,n=new Wn,r=[],o,s){this.registry=t,this.path=e,this.key=e.map((t=>`[${t}]`)).join(""),this.scope=n,this.errors=r,this.expectedType=i,this._scope=o,this.options=s}parse(t,e,i,n,r={}){return e||i?this.concat(e,i,n)._parse(t,r):this._parse(t,r)}_parse(t,e){function i(t,e,i){return"assert"===i?new wr(e,[t]):"coerce"===i?new Cr(e,[t]):t}if(null!==t&&"string"!=typeof t&&"boolean"!=typeof t&&"number"!=typeof t||(t=["literal",t]),Array.isArray(t)){if(0===t.length)return this.error('Expected an array with at least one element. If you wanted a literal array, use ["literal", []].');const n="string"==typeof t[0]?this.registry[t[0]]:void 0;if(n){let r=n.parse(t,this);if(!r)return null;if(this.expectedType){const t=this.expectedType,n=r.type;if("string"!==t.kind&&"number"!==t.kind&&"boolean"!==t.kind&&"object"!==t.kind&&"array"!==t.kind||"value"!==n.kind)if("color"!==t.kind&&"formatted"!==t.kind&&"resolvedImage"!==t.kind||"value"!==n.kind&&"string"!==n.kind){if(this.checkSubtype(t,n))return null}else r=i(r,t,e.typeAnnotation||"coerce");else r=i(r,t,e.typeAnnotation||"assert")}if(!(r instanceof vr)&&"resolvedImage"!==r.type.kind&&Jo(r)){const e=new Ir(this._scope,this.options);try{r=new vr(r.type,r.evaluate(e))}catch(t){return this.error(t.message),null}}return r}return Cr.parse(["to-array",t],this)}return this.error(void 0===t?"'undefined' value invalid. Use null instead.":"object"==typeof t?'Bare objects invalid. Use ["literal", {...}] instead.':`Expected an array, but found ${typeof t} instead.`)}concat(t,e,i){const n="number"==typeof t?this.path.concat(t):this.path,r=i?this.scope.concat(i):this.scope;return new Xo(this.registry,n,e||null,r,this.errors,this._scope,this.options)}error(t,...e){const i=`${this.key}${e.map((t=>`[${t}]`)).join("")}`;this.errors.push(new Hn(i,t))}checkSubtype(t,e){const i=lr(t,e);return i&&this.error(i),i}}var Ko=Xo;function Jo(t){if(t instanceof Yo)return Jo(t.boundExpression);if(t instanceof Lr&&"error"===t.name)return!1;if(t instanceof $r)return!1;if(t instanceof to)return!1;if(t instanceof Uo)return!1;if(t instanceof Go)return!1;const e=t instanceof Cr||t instanceof wr;let i=!0;return t.eachChild((t=>{i=e?i&&Jo(t):i&&t instanceof vr})),!!i&&Zo(t)&&Wo(t,["zoom","heatmap-density","line-progress","raster-value","sky-radial-progress","accumulated","is-supported-script","pitch","distance-from-center","measure-light","raster-particle-speed"])}function Qo(t,e){const i=t.length-1;let n,r,o=0,s=i,a=0;for(;oe))throw new xr("Input is not a number.");s=a-1}return 0}class ts{constructor(t,e,i){this.type=t,this.input=e,this.labels=[],this.outputs=[];for(const[t,e]of i)this.labels.push(t),this.outputs.push(e)}static parse(t,e){if(t.length-1=o)return e.error('Input/output pairs for "step" expressions must be arranged with input values in strictly ascending order.',a);const c=e.parse(s,l,r);if(!c)return null;r=r||c.type,n.push([o,c])}return new ts(r,i,n)}evaluate(t){const e=this.labels,i=this.outputs;if(1===e.length)return i[0].evaluate(t);const n=this.input.evaluate(t);if(n=e[r-1]?i[r-1].evaluate(t):i[Qo(e,n)].evaluate(t)}eachChild(t){t(this.input);for(const e of this.outputs)t(e)}outputDefined(){return this.outputs.every((t=>t.outputDefined()))}serialize(){const t=["step",this.input.serialize()];for(let e=0;e0&&t.push(this.labels[e]),t.push(this.outputs[e].serialize());return t}}const es=.95047,is=1.08883,ns=4/29,rs=6/29,os=3*rs*rs,ss=rs*rs*rs,as=Math.PI/180,ls=180/Math.PI;function cs(t){return t>ss?Math.pow(t,1/3):t/os+ns}function ds(t){return t>rs?t*t*t:os*(t-ns)}function us(t){return 255*(t180||n"number"!=typeof t||t1)))return e.error("Cubic bezier interpolation requires four numeric arguments with values between 0 and 1.",1);n={name:"cubic-bezier",controlPoints:t}}}if(t.length-1=i)return e.error('Input/output pairs for "interpolate" expressions must be arranged with input values in strictly ascending order.',r);const c=e.parse(n,l,a);if(!c)return null;a=a||c.type,s.push([i,c])}return"number"===a.kind||"color"===a.kind||"array"===a.kind&&"number"===a.itemType.kind&&"number"==typeof a.N?new vs(a,i,n,r,s):e.error(`Type ${sr(a)} is not interpolatable.`)}evaluate(t){const e=this.labels,i=this.outputs;if(1===e.length)return i[0].evaluate(t);const n=this.input.evaluate(t);if(n=e[r-1])return i[r-1].evaluate(t);const o=Qo(e,n),s=vs.interpolationFactor(this.interpolation,n,e[o],e[o+1]),a=i[o].evaluate(t),l=i[o+1].evaluate(t);return"interpolate"===this.operator?Zn[this.type.kind.toLowerCase()](a,l,s):"interpolate-hcl"===this.operator?gs.reverse(gs.interpolate(gs.forward(a),gs.forward(l),s)):_s.reverse(_s.interpolate(_s.forward(a),_s.forward(l),s))}eachChild(t){t(this.input);for(const e of this.outputs)t(e)}outputDefined(){return this.outputs.every((t=>t.outputDefined()))}serialize(){let t;t="linear"===this.interpolation.name?["linear"]:"exponential"===this.interpolation.name?1===this.interpolation.base?["linear"]:["exponential",this.interpolation.base]:["cubic-bezier"].concat(this.interpolation.controlPoints);const e=[this.operator,t,this.input.serialize()];for(let t=0;tlr(n,t.type)));return new bs(o?er:i,r)}evaluate(t){let e,i=null,n=0;for(const r of this.args){if(n++,i=r.evaluate(t),i&&i instanceof fr&&!i.available&&(e||(e=i),i=null,n===this.args.length))return e;if(null!==i)break}return i}eachChild(t){this.args.forEach(t)}outputDefined(){return this.args.every((t=>t.outputDefined()))}serialize(){const t=["coalesce"];return this.eachChild((e=>{t.push(e.serialize())})),t}}class ws{constructor(t,e){this.type=e.type,this.bindings=[].concat(t),this.result=e}evaluate(t){return this.result.evaluate(t)}eachChild(t){for(const e of this.bindings)t(e[1]);t(this.result)}static parse(t,e){if(t.length=i.length)throw new xr(`Array index out of bounds: ${e} > ${i.length-1}.`);if(e!==Math.floor(e))throw new xr(`Array index must be an integer, but found ${e} instead.`);return i[e]}eachChild(t){t(this.index),t(this.input)}outputDefined(){return!1}serialize(){return["at",this.index.serialize(),this.input.serialize()]}}class Ss{constructor(t,e){this.type=Jn,this.needle=t,this.haystack=e}static parse(t,e){if(3!==t.length)return e.error(`Expected 2 arguments, but found ${t.length-1} instead.`);const i=e.parse(t[1],1,er),n=e.parse(t[2],2,er);return i&&n?cr(i.type,[Jn,Kn,Xn,Yn,er])?new Ss(i,n):e.error(`Expected first argument to be of type boolean, string, number or null, but found ${sr(i.type)} instead`):null}evaluate(t){const e=this.needle.evaluate(t),i=this.haystack.evaluate(t);if(null==i)return!1;if(!dr(e,["boolean","string","number","null"]))throw new xr(`Expected first argument to be of type boolean, string, number or null, but found ${sr(gr(e))} instead.`);if(!dr(i,["string","array"]))throw new xr(`Expected second argument to be of type array or string, but found ${sr(gr(i))} instead.`);return i.indexOf(e)>=0}eachChild(t){t(this.needle),t(this.haystack)}outputDefined(){return!0}serialize(){return["in",this.needle.serialize(),this.haystack.serialize()]}}class Es{constructor(t,e,i){this.type=Xn,this.needle=t,this.haystack=e,this.fromIndex=i}static parse(t,e){if(t.length=5)return e.error(`Expected 3 or 4 arguments, but found ${t.length-1} instead.`);const i=e.parse(t[1],1,er),n=e.parse(t[2],2,er);if(!i||!n)return null;if(!cr(i.type,[Jn,Kn,Xn,Yn,er]))return e.error(`Expected first argument to be of type boolean, string, number or null, but found ${sr(i.type)} instead`);if(4===t.length){const r=e.parse(t[3],3,Xn);return r?new Es(i,n,r):null}return new Es(i,n)}evaluate(t){const e=this.needle.evaluate(t),i=this.haystack.evaluate(t);if(!dr(e,["boolean","string","number","null"]))throw new xr(`Expected first argument to be of type boolean, string, number or null, but found ${sr(gr(e))} instead.`);if(!dr(i,["string","array"]))throw new xr(`Expected second argument to be of type array or string, but found ${sr(gr(i))} instead.`);if(this.fromIndex){const n=this.fromIndex.evaluate(t);return i.indexOf(e,n)}return i.indexOf(e)}eachChild(t){t(this.needle),t(this.haystack),this.fromIndex&&t(this.fromIndex)}outputDefined(){return!1}serialize(){if(null!=this.fromIndex&&void 0!==this.fromIndex){const t=this.fromIndex.serialize();return["index-of",this.needle.serialize(),this.haystack.serialize(),t]}return["index-of",this.needle.serialize(),this.haystack.serialize()]}}class Ms{constructor(t,e,i,n,r,o){this.inputType=t,this.type=e,this.input=i,this.cases=n,this.outputs=r,this.otherwise=o}static parse(t,e){if(t.lengthNumber.MAX_SAFE_INTEGER)return c.error(`Branch labels must be integers no larger than ${Number.MAX_SAFE_INTEGER}.`);if("number"==typeof t&&Math.floor(t)!==t)return c.error("Numeric branch labels must be integer values.");if(i){if(c.checkSubtype(i,gr(t)))return null}else i=gr(t);if(void 0!==r[String(t)])return c.error("Branch labels must be unique.");r[String(t)]=o.length}const d=e.parse(l,s,n);if(!d)return null;n=n||d.type,o.push(d)}const s=e.parse(t[1],1,er);if(!s)return null;const a=e.parse(t[t.length-1],t.length-1,n);return a?"value"!==s.type.kind&&e.concat(1).checkSubtype(i,s.type)?null:new Ms(i,n,s,r,o,a):null}evaluate(t){const e=this.input.evaluate(t);return(gr(e)===this.inputType&&this.outputs[this.cases[e]]||this.otherwise).evaluate(t)}eachChild(t){t(this.input),this.outputs.forEach(t),t(this.otherwise)}outputDefined(){return this.outputs.every((t=>t.outputDefined()))&&this.otherwise.outputDefined()}serialize(){const t=["match",this.input.serialize()],e=Object.keys(this.cases).sort(),i=[],n={};for(const t of e){const e=n[this.cases[t]];void 0===e?(n[this.cases[t]]=i.length,i.push([this.cases[t],[t]])):i[e][1].push(t)}const r=t=>"number"===this.inputType.kind?Number(t):t;for(const[e,n]of i)t.push(1===n.length?r(n[0]):n.map(r)),t.push(this.outputs[e].serialize());return t.push(this.otherwise.serialize()),t}}class Cs{constructor(t,e,i){this.type=t,this.branches=e,this.otherwise=i}static parse(t,e){if(t.lengthe.outputDefined()))&&this.otherwise.outputDefined()}serialize(){const t=["case"];return this.eachChild((e=>{t.push(e.serialize())})),t}}class As{constructor(t,e,i,n){this.type=t,this.input=e,this.beginIndex=i,this.endIndex=n}static parse(t,e){if(t.length=5)return e.error(`Expected 3 or 4 arguments, but found ${t.length-1} instead.`);const i=e.parse(t[1],1,er),n=e.parse(t[2],2,Xn);if(!i||!n)return null;if(!cr(i.type,[or(er),Kn,er]))return e.error(`Expected first argument to be of type array or string, but found ${sr(i.type)} instead`);if(4===t.length){const r=e.parse(t[3],3,Xn);return r?new As(i.type,i,n,r):null}return new As(i.type,i,n)}evaluate(t){const e=this.input.evaluate(t),i=this.beginIndex.evaluate(t);if(!dr(e,["string","array"]))throw new xr(`Expected first argument to be of type array or string, but found ${sr(gr(e))} instead.`);if(this.endIndex){const n=this.endIndex.evaluate(t);return e.slice(i,n)}return e.slice(i)}eachChild(t){t(this.input),t(this.beginIndex),this.endIndex&&t(this.endIndex)}outputDefined(){return!1}serialize(){if(null!=this.endIndex&&void 0!==this.endIndex){const t=this.endIndex.serialize();return["slice",this.input.serialize(),this.beginIndex.serialize(),t]}return["slice",this.input.serialize(),this.beginIndex.serialize()]}}function Is(t,e){return"=="===t||"!="===t?"boolean"===e.kind||"string"===e.kind||"number"===e.kind||"null"===e.kind||"value"===e.kind:"string"===e.kind||"number"===e.kind||"value"===e.kind}function Ls(t,e,i,n){return 0===n.compare(e,i)}function Ps(t,e,i){const n="=="!==t&&"!="!==t;return class r{constructor(t,e,i){this.type=Jn,this.lhs=t,this.rhs=e,this.collator=i,this.hasUntypedArgument="value"===t.type.kind||"value"===e.type.kind}static parse(t,e){if(3!==t.length&&4!==t.length)return e.error("Expected two or three arguments.");const i=t[0];let o=e.parse(t[1],1,er);if(!o)return null;if(!Is(i,o.type))return e.concat(1).error(`"${i}" comparisons are not supported for type '${sr(o.type)}'.`);let s=e.parse(t[2],2,er);if(!s)return null;if(!Is(i,s.type))return e.concat(2).error(`"${i}" comparisons are not supported for type '${sr(s.type)}'.`);if(o.type.kind!==s.type.kind&&"value"!==o.type.kind&&"value"!==s.type.kind)return e.error(`Cannot compare types '${sr(o.type)}' and '${sr(s.type)}'.`);n&&("value"===o.type.kind&&"value"!==s.type.kind?o=new wr(s.type,[o]):"value"!==o.type.kind&&"value"===s.type.kind&&(s=new wr(o.type,[s])));let a=null;if(4===t.length){if("string"!==o.type.kind&&"string"!==s.type.kind&&"value"!==o.type.kind&&"value"!==s.type.kind)return e.error("Cannot use collator to compare non-string types.");if(a=e.parse(t[3],3,ir),!a)return null}return new r(o,s,a)}evaluate(r){const o=this.lhs.evaluate(r),s=this.rhs.evaluate(r);if(n&&this.hasUntypedArgument){const e=gr(o),i=gr(s);if(e.kind!==i.kind||"string"!==e.kind&&"number"!==e.kind)throw new xr(`Expected arguments for "${t}" to be (string, string) or (number, number), but found (${e.kind}, ${i.kind}) instead.`)}if(this.collator&&!n&&this.hasUntypedArgument){const t=gr(o),i=gr(s);if("string"!==t.kind||"string"!==i.kind)return e(r,o,s)}return this.collator?i(r,o,s,this.collator.evaluate(r)):e(r,o,s)}eachChild(t){t(this.lhs),t(this.rhs),this.collator&&t(this.collator)}outputDefined(){return!0}serialize(){const e=[t];return this.eachChild((t=>{e.push(t.serialize())})),e}}}const $s=Ps("==",(function(t,e,i){return e===i}),Ls),ks=Ps("!=",(function(t,e,i){return e!==i}),(function(t,e,i,n){return!Ls(0,e,i,n)})),Ds=Ps("",(function(t,e,i){return e>i}),(function(t,e,i,n){return n.compare(e,i)>0})),Rs=Ps("=",(function(t,e,i){return e>=i}),(function(t,e,i,n){return n.compare(e,i)>=0}));class Bs{constructor(t,e,i,n,r,o){this.type=Kn,this.number=t,this.locale=e,this.currency=i,this.unit=n,this.minFractionDigits=r,this.maxFractionDigits=o}static parse(t,e){if(3!==t.length)return e.error("Expected two arguments.");const i=e.parse(t[1],1,Xn);if(!i)return null;const n=t[2];if("object"!=typeof n||Array.isArray(n))return e.error("NumberFormat options argument must be an object.");let r=null;if(n.locale&&(r=e.parse(n.locale,1,Kn),!r))return null;let o=null;if(n.currency&&(o=e.parse(n.currency,1,Kn),!o))return null;let s=null;if(n.unit&&(s=e.parse(n.unit,1,Kn),!s))return null;let a=null;if(n["min-fraction-digits"]&&(a=e.parse(n["min-fraction-digits"],1,Xn),!a))return null;let l=null;return n["max-fraction-digits"]&&(l=e.parse(n["max-fraction-digits"],1,Xn),!l)?null:new Bs(i,r,o,s,a,l)}evaluate(t){return new Intl.NumberFormat(this.locale?this.locale.evaluate(t):[],{style:(this.currency?"currency":this.unit&&"unit")||"decimal",currency:this.currency?this.currency.evaluate(t):void 0,unit:this.unit?this.unit.evaluate(t):void 0,minimumFractionDigits:this.minFractionDigits?this.minFractionDigits.evaluate(t):void 0,maximumFractionDigits:this.maxFractionDigits?this.maxFractionDigits.evaluate(t):void 0}).format(this.number.evaluate(t))}eachChild(t){t(this.number),this.locale&&t(this.locale),this.currency&&t(this.currency),this.unit&&t(this.unit),this.minFractionDigits&&t(this.minFractionDigits),this.maxFractionDigits&&t(this.maxFractionDigits)}outputDefined(){return!1}serialize(){const t={};return this.locale&&(t.locale=this.locale.serialize()),this.currency&&(t.currency=this.currency.serialize()),this.unit&&(t.unit=this.unit.serialize()),this.minFractionDigits&&(t["min-fraction-digits"]=this.minFractionDigits.serialize()),this.maxFractionDigits&&(t["max-fraction-digits"]=this.maxFractionDigits.serialize()),["number-format",this.number.serialize(),t]}}class Fs{constructor(t){this.type=Xn,this.input=t}static parse(t,e){if(2!==t.length)return e.error(`Expected 1 argument, but found ${t.length-1} instead.`);const i=e.parse(t[1],1);return i?"array"!==i.type.kind&&"string"!==i.type.kind&&"value"!==i.type.kind?e.error(`Expected argument of type string or array, but found ${sr(i.type)} instead.`):new Fs(i):null}evaluate(t){const e=this.input.evaluate(t);if("string"==typeof e)return e.length;if(Array.isArray(e))return e.length;throw new xr(`Expected value to be of type string or array, but found ${sr(gr(e))} instead.`)}eachChild(t){t(this.input)}outputDefined(){return!1}serialize(){const t=["length"];return this.eachChild((e=>{t.push(e.serialize())})),t}}function Ns(t){return function(){t=1831565813+(t|=0)|0;let e=Math.imul(t^t>>>15,1|t);return e=e+Math.imul(e^e>>>7,61|e)^e,((e^e>>>14)>>>0)/4294967296}}const Us={"==":$s,"!=":ks,">":zs,"=":Os,"=0&&t=0&&e=0&&i=0&&n-1}function Xs(t){return"data-driven"===t["property-type"]}function Ks(t){return Ys(t.expression,"measure-light")}function Js(t){return Ys(t.expression,"zoom")}function Qs(t){return!!t.expression&&t.expression.interpolated}function ta(t){return"object"==typeof t&&null!==t&&!Array.isArray(t)}function ea(t){return t}function ia(t,e){const i="color"===e.type,n=t.stops&&"object"==typeof t.stops[0][0],r=n||!(n||void 0!==t.property),o=t.type||(Qs(e)?"exponential":"interval");if(i&&((t=qn({},t)).stops&&(t.stops=t.stops.map((t=>[t[0],Un.parse(t[1])]))),t.default=Un.parse(t.default?t.default:e.default)),t.colorSpace&&"rgb"!==t.colorSpace&&!ys[t.colorSpace])throw new Error(`Unknown color space: ${t.colorSpace}`);let s,a,l;if("exponential"===o)s=sa;else if("interval"===o)s=oa;else if("categorical"===o){s=ra,a=Object.create(null);for(const e of t.stops)a[e[0]]=e[1];l=typeof t.stops[0][0]}else{if("identity"!==o)throw new Error(`Unknown function type "${o}"`);s=aa}if(n){const i={},n=[];for(let e=0;et[0])),evaluate:({zoom:i},n)=>sa({stops:r,base:t.base},e,i).evaluate(i,n)}}if(r){const i="exponential"===o?{name:"exponential",base:void 0!==t.base?t.base:1}:null;return{kind:"camera",interpolationType:i,interpolationFactor:vs.interpolationFactor.bind(void 0,i),zoomStops:t.stops.map((t=>t[0])),evaluate:({zoom:i})=>s(t,e,i,a,l)}}return{kind:"source",evaluate(i,n){const r=n&&n.properties?n.properties[t.property]:void 0;return void 0===r?na(t.default,e.default):s(t,e,r,a,l)}}}function na(t,e,i){return void 0!==t?t:void 0!==e?e:void 0!==i?i:void 0}function ra(t,e,i,n,r){return na(typeof i===r?n[i]:void 0,t.default,e.default)}function oa(t,e,i){if("number"!==Er(i))return na(t.default,e.default);const n=t.stops.length;if(1===n)return t.stops[0][1];if(i=t.stops[n-1][0])return t.stops[n-1][1];const r=Qo(t.stops.map((t=>t[0])),i);return t.stops[r][1]}function sa(t,e,i){const n=void 0!==t.base?t.base:1;if("number"!==Er(i))return na(t.default,e.default);const r=t.stops.length;if(1===r)return t.stops[0][1];if(i=t.stops[r-1][0])return t.stops[r-1][1];const o=Qo(t.stops.map((t=>t[0])),i),s=function(t,e,i,n){const r=n-i,o=t-i;return 0===r?0:1===e?o/r:(Math.pow(e,o)-1)/(Math.pow(e,r)-1)}(i,n,t.stops[o][0],t.stops[o+1][0]),a=t.stops[o][1],l=t.stops[o+1][1];let c=Zn[e.type]||ea;if(t.colorSpace&&"rgb"!==t.colorSpace){const e=ys[t.colorSpace];c=(t,i)=>e.reverse(e.interpolate(e.forward(t),e.forward(i),s))}return"function"==typeof a.evaluate?{evaluate(...t){const e=a.evaluate.apply(void 0,t),i=l.evaluate.apply(void 0,t);if(void 0!==e&&void 0!==i)return c(e,i,s)}}:c(a,l,s)}function aa(t,e,i){return"color"===e.type?i=Un.parse(i):"formatted"===e.type?i=pr.fromString(i.toString()):"resolvedImage"===e.type?i=fr.fromString(i.toString()):Er(i)===e.type||"enum"===e.type&&e.values[i]||(i=void 0),na(i,t.default,e.default)}Lr.register(Us,{error:[{kind:"error"},[Kn],(t,[e])=>{throw new xr(e.evaluate(t))}],typeof:[Kn,[er],(t,[e])=>sr(gr(e.evaluate(t)))],"to-rgba":[or(Xn,4),[Qn],(t,[e])=>e.evaluate(t).toRenderColor(null).toArray()],rgb:[Qn,[Xn,Xn,Xn],js],rgba:[Qn,[Xn,Xn,Xn,Xn],js],hsl:[Qn,[Xn,Xn,Xn],Vs],hsla:[Qn,[Xn,Xn,Xn,Xn],Vs],has:{type:Jn,overloads:[[[Kn],(t,[e])=>Gs(e.evaluate(t),t.properties())],[[Kn,tr],(t,[e,i])=>Gs(e.evaluate(t),i.evaluate(t))]]},get:{type:er,overloads:[[[Kn],(t,[e])=>Zs(e.evaluate(t),t.properties())],[[Kn,tr],(t,[e,i])=>Zs(e.evaluate(t),i.evaluate(t))]]},"feature-state":[er,[Kn],(t,[e])=>Zs(e.evaluate(t),t.featureState||{})],properties:[tr,[],t=>t.properties()],"geometry-type":[Kn,[],t=>t.geometryType()],id:[er,[],t=>t.id()],zoom:[Xn,[],t=>t.globals.zoom],pitch:[Xn,[],t=>t.globals.pitch||0],"distance-from-center":[Xn,[],t=>t.distanceFromCenter()],"measure-light":[Xn,[Kn],(t,[e])=>t.measureLight(e.evaluate(t))],"heatmap-density":[Xn,[],t=>t.globals.heatmapDensity||0],"line-progress":[Xn,[],t=>t.globals.lineProgress||0],"raster-value":[Xn,[],t=>t.globals.rasterValue||0],"raster-particle-speed":[Xn,[],t=>t.globals.rasterParticleSpeed||0],"sky-radial-progress":[Xn,[],t=>t.globals.skyRadialProgress||0],accumulated:[er,[],t=>void 0===t.globals.accumulated?null:t.globals.accumulated],"+":[Xn,qs(Xn),(t,e)=>{let i=0;for(const n of e)i+=n.evaluate(t);return i}],"*":[Xn,qs(Xn),(t,e)=>{let i=1;for(const n of e)i*=n.evaluate(t);return i}],"-":{type:Xn,overloads:[[[Xn,Xn],(t,[e,i])=>e.evaluate(t)-i.evaluate(t)],[[Xn],(t,[e])=>-e.evaluate(t)]]},"/":[Xn,[Xn,Xn],(t,[e,i])=>e.evaluate(t)/i.evaluate(t)],"%":[Xn,[Xn,Xn],(t,[e,i])=>e.evaluate(t)%i.evaluate(t)],ln2:[Xn,[],()=>Math.LN2],pi:[Xn,[],()=>Math.PI],e:[Xn,[],()=>Math.E],"^":[Xn,[Xn,Xn],(t,[e,i])=>Math.pow(e.evaluate(t),i.evaluate(t))],sqrt:[Xn,[Xn],(t,[e])=>Math.sqrt(e.evaluate(t))],log10:[Xn,[Xn],(t,[e])=>Math.log(e.evaluate(t))/Math.LN10],ln:[Xn,[Xn],(t,[e])=>Math.log(e.evaluate(t))],log2:[Xn,[Xn],(t,[e])=>Math.log(e.evaluate(t))/Math.LN2],sin:[Xn,[Xn],(t,[e])=>Math.sin(e.evaluate(t))],cos:[Xn,[Xn],(t,[e])=>Math.cos(e.evaluate(t))],tan:[Xn,[Xn],(t,[e])=>Math.tan(e.evaluate(t))],asin:[Xn,[Xn],(t,[e])=>Math.asin(e.evaluate(t))],acos:[Xn,[Xn],(t,[e])=>Math.acos(e.evaluate(t))],atan:[Xn,[Xn],(t,[e])=>Math.atan(e.evaluate(t))],min:[Xn,qs(Xn),(t,e)=>Math.min(...e.map((e=>e.evaluate(t))))],max:[Xn,qs(Xn),(t,e)=>Math.max(...e.map((e=>e.evaluate(t))))],abs:[Xn,[Xn],(t,[e])=>Math.abs(e.evaluate(t))],round:[Xn,[Xn],(t,[e])=>{const i=e.evaluate(t);return iMath.floor(e.evaluate(t))],ceil:[Xn,[Xn],(t,[e])=>Math.ceil(e.evaluate(t))],"filter-==":[Jn,[Kn,er],(t,[e,i])=>t.properties()[e.value]===i.value],"filter-id-==":[Jn,[er],(t,[e])=>t.id()===e.value],"filter-type-==":[Jn,[Kn],(t,[e])=>t.geometryType()===e.value],"filter-{const n=t.properties()[e.value],r=i.value;return typeof n==typeof r&&n{const i=t.id(),n=e.value;return typeof i==typeof n&&i":[Jn,[Kn,er],(t,[e,i])=>{const n=t.properties()[e.value],r=i.value;return typeof n==typeof r&&n>r}],"filter-id->":[Jn,[er],(t,[e])=>{const i=t.id(),n=e.value;return typeof i==typeof n&&i>n}],"filter-{const n=t.properties()[e.value],r=i.value;return typeof n==typeof r&&n{const i=t.id(),n=e.value;return typeof i==typeof n&&i=":[Jn,[Kn,er],(t,[e,i])=>{const n=t.properties()[e.value],r=i.value;return typeof n==typeof r&&n>=r}],"filter-id->=":[Jn,[er],(t,[e])=>{const i=t.id(),n=e.value;return typeof i==typeof n&&i>=n}],"filter-has":[Jn,[er],(t,[e])=>e.value in t.properties()],"filter-has-id":[Jn,[],t=>null!==t.id()&&void 0!==t.id()],"filter-type-in":[Jn,[or(Kn)],(t,[e])=>e.value.indexOf(t.geometryType())>=0],"filter-id-in":[Jn,[or(er)],(t,[e])=>e.value.indexOf(t.id())>=0],"filter-in-small":[Jn,[Kn,or(er)],(t,[e,i])=>i.value.indexOf(t.properties()[e.value])>=0],"filter-in-large":[Jn,[Kn,or(er)],(t,[e,i])=>function(t,e,i,n){for(;i>1;if(e[r]===t)return!0;e[r]>t?n=r-1:i=r+1}return!1}(t.properties()[e.value],i.value,0,i.value.length-1)],all:{type:Jn,overloads:[[[Jn,Jn],(t,[e,i])=>e.evaluate(t)&&i.evaluate(t)],[qs(Jn),(t,e)=>{for(const i of e)if(!i.evaluate(t))return!1;return!0}]]},any:{type:Jn,overloads:[[[Jn,Jn],(t,[e,i])=>e.evaluate(t)||i.evaluate(t)],[qs(Jn),(t,e)=>{for(const i of e)if(i.evaluate(t))return!0;return!1}]]},"!":[Jn,[Jn],(t,[e])=>!e.evaluate(t)],"is-supported-script":[Jn,[Kn],(t,[e])=>{const i=t.globals&&t.globals.isSupportedScript;return!i||i(e.evaluate(t))}],upcase:[Kn,[Kn],(t,[e])=>e.evaluate(t).toUpperCase()],downcase:[Kn,[Kn],(t,[e])=>e.evaluate(t).toLowerCase()],concat:[Kn,qs(er),(t,e)=>e.map((e=>yr(e.evaluate(t)))).join("")],"resolved-locale":[Kn,[ir],(t,[e])=>e.evaluate(t).resolvedLocale()],random:[Xn,[Xn,Xn,er],(t,e)=>{const[i,n,r]=e.map((e=>e.evaluate(t)));if(i>n)return i;if(i===n)return i;let o;if("string"==typeof r)o=function(t){let e=0;if(0===t.length)return e;for(let i=0;iJSON.stringify(t))).join(", ")}, but found ${JSON.stringify(t)} instead.`);return t}catch(t){return this._warningHistory[t.message]||(this._warningHistory[t.message]=!0,"undefined"!=typeof console&&console.warn(t.message)),this._defaultValue}}}function ca(t){return Array.isArray(t)&&t.length>0&&"string"==typeof t[0]&&t[0]in Us}function da(t,e,i,n){const r=new Ko(Us,[],e?function(t){const e={color:Qn,string:Kn,number:Xn,enum:Kn,boolean:Jn,formatted:nr,resolvedImage:rr};return"array"===t.type?or(e[t.value]||er,t.length):e[t.type]}(e):void 0,void 0,void 0,i,n),o=r.parse(t,void 0,void 0,void 0,e&&"string"===e.type?{typeAnnotation:"coerce"}:void 0);return o?Hs(new la(o,e,i,n)):Ws(r.errors)}class ua{constructor(t,e,i){this.kind=t,this._styleExpression=e,this.isLightConstant=i,this.isStateDependent="constant"!==t&&!qo(e.expression),this.isConfigDependent=!Ho(e.expression)}evaluateWithoutErrorHandling(t,e,i,n,r,o){return this._styleExpression.evaluateWithoutErrorHandling(t,e,i,n,r,o)}evaluate(t,e,i,n,r,o){return this._styleExpression.evaluate(t,e,i,n,r,o)}}class ha{constructor(t,e,i,n,r){this.kind=t,this.zoomStops=i,this._styleExpression=e,this.isStateDependent="camera"!==t&&!qo(e.expression),this.isLightConstant=r,this.isConfigDependent=!Ho(e.expression),this.interpolationType=n}evaluateWithoutErrorHandling(t,e,i,n,r,o){return this._styleExpression.evaluateWithoutErrorHandling(t,e,i,n,r,o)}evaluate(t,e,i,n,r,o){return this._styleExpression.evaluate(t,e,i,n,r,o)}interpolationFactor(t,e,i){return this.interpolationType?vs.interpolationFactor(this.interpolationType,t,e,i):0}}function pa(t,e,i,n){if("error"===(t=da(t,e,i,n)).result)return t;const r=t.value.expression,o=Zo(r);if(!o&&!Xs(e))return Ws([new Hn("","data expressions not supported")]);const s=Wo(r,["zoom","pitch","distance-from-center"]);if(!s&&!Js(e))return Ws([new Hn("","zoom expressions not supported")]);const a=Wo(r,["measure-light"]);if(!a&&!Ks(e))return Ws([new Hn("","measure-light expression not supported")]);const l=e.expression&&e.expression.relaxZoomRestriction,c=ma(r);return c||s||l?c instanceof Hn?Ws([c]):c instanceof vs&&!Qs(e)?Ws([new Hn("",'"interpolate" expressions cannot be used with this property')]):Hs(c?new ha(o?"camera":"composite",t.value,c.labels,c instanceof vs?c.interpolation:void 0,a):new ua(o?"constant":"source",t.value,a)):Ws([new Hn("",'"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression, or in the properties of atmosphere.')])}class fa{constructor(t,e){this._parameters=t,this._specification=e,qn(this,ia(this._parameters,this._specification))}static deserialize(t){return new fa(t._parameters,t._specification)}static serialize(t){return{_parameters:t._parameters,_specification:t._specification}}}function ma(t){let e=null;if(t instanceof ws)e=ma(t.result);else if(t instanceof bs){for(const i of t.args)if(e=ma(i),e)break}else(t instanceof ts||t instanceof vs)&&t.input instanceof Lr&&"zoom"===t.input.name&&(e=t);return e instanceof Hn||t.eachChild((t=>{const i=ma(t);i instanceof Hn?e=i:e&&i&&e!==i&&(e=new Hn("",'Only one zoom-based "step" or "interpolate" subexpression may be used in an expression.'))})),e}var _a=ya,ga=3;function ya(t,e,i){var n=this.cells=[];if(t instanceof ArrayBuffer){this.arrayBuffer=t;var r=new Int32Array(this.arrayBuffer);t=r[0],this.d=(e=r[1])+2*(i=r[2]);for(var o=0;o=d[p+0]&&n>=d[p+1])?(s[h]=!0,o.push(c[h])):s[h]=!1}}},ya.prototype._forEachCell=function(t,e,i,n,r,o,s,a){for(var l=this._convertToCellCoord(t),c=this._convertToCellCoord(e),d=this._convertToCellCoord(i),u=this._convertToCellCoord(n),h=l;h=0||(r[i]=Sa(t[i],e)));t instanceof Error&&(r.message=t.message)}if(r.$name)throw new Error("$name property is reserved for worker serialization logic.");return"Object"!==n&&(r.$name=n),r}throw new Error("can't serialize object of type "+typeof t)}function Ea(t){if(null==t||"boolean"==typeof t||"number"==typeof t||"string"==typeof t||t instanceof Boolean||t instanceof Number||t instanceof String||t instanceof Date||t instanceof RegExp||wa(t)||Ta(t)||ArrayBuffer.isView(t)||t instanceof ImageData)return t;if(Array.isArray(t))return t.map(Ea);if("object"==typeof t){const e=t.$name||"Object";if("Map"===e){const e=new Map;for(const i of Object.keys(t))"$name"!==i&&e.set(i,Ea(t[i]));return e}const{klass:i}=xa[e];if(!i)throw new Error(`can't deserialize unregistered class ${e}`);if(i.deserialize)return i.deserialize(t);const n=Object.create(i.prototype);for(const e of Object.keys(t))"$name"!==e&&(n[e]=Ea(t[e]));return n}throw new Error("can't deserialize object of type "+typeof t)}const Ma={"Latin-1 Supplement":t=>t>=128&&tt>=1536&&tt>=1872&&tt>=2208&&tt>=4352&&tt>=5120&&tt>=6016&&tt>=6320&&tt>=8192&&tt>=8448&&tt>=8528&&tt>=8960&&tt>=9216&&tt>=9280&&tt>=9312&&tt>=9632&&tt>=9728&&tt>=11008&&tt>=11904&&tt>=12032&&tt>=12272&&tt>=12288&&tt>=12352&&tt>=12448&&tt>=12544&&tt>=12592&&tt>=12688&&tt>=12704&&tt>=12736&&tt>=12784&&tt>=12800&&tt>=13056&&tt>=13312&&tt>=19904&&tt>=19968&&tt>=40960&&tt>=42128&&tt>=43360&&tt>=44032&&tt>=55216&&tt>=57344&&tt>=63744&&tt>=64336&&tt>=65040&&tt>=65072&&tt>=65104&&tt>=65136&&tt>=65280&&tt>=131072&&t=65097&&t=12296&&t=12308&&t=65306&&t=65371&&t=65512&&t=65112&&t=65123&&t=8960&&t=8972&&t=8996&&t=9085&&t=9150&&t=9169&&t=9186&&t=9754&&t=11026&&t=11088&&t=11192&&t=9984&&t=10102&&t=1424&&t=2304&&t=3840&&t-1&&(Fa="error"),Ba&&Ba(t)};function ja(){Va.fire(new Pn("pluginStateChange",{pluginStatus:Fa,pluginURL:Na}))}const Va=new zn,Ga=function(){return Fa},Za=function(){if(Fa!==za||!Na)throw new Error("rtl-text-plugin cannot be downloaded unless a pluginURL is specified");Fa=Ra,ja(),Na&&en({url:Na},(t=>{t?Ua(t):(Fa=Oa,ja())}))},qa={applyArabicShaping:null,processBidirectionalText:null,processStyledBidirectionalText:null,isLoaded:()=>Fa===Oa||null!=qa.applyArabicShaping,isLoading:()=>Fa===Ra,setState(t){Fa=t.pluginStatus,Na=t.pluginURL},isParsed:()=>null!=qa.applyArabicShaping&&null!=qa.processBidirectionalText&&null!=qa.processStyledBidirectionalText,getPluginURL:()=>Na};class Ha{constructor(t,e){this.zoom=t,e?(this.now=e.now,this.fadeDuration=e.fadeDuration,this.transition=e.transition,this.pitch=e.pitch,this.brightness=e.brightness):(this.now=0,this.fadeDuration=0,this.transition={},this.pitch=0,this.brightness=0)}isSupportedScript(t){return function(t,e){for(const i of t)if(!ka(i.charCodeAt(0),e))return!1;return!0}(t,qa.isLoaded())}}class Wa{constructor(t,e,i,n){this.property=t,this.value=e,this.expression=function(t,e,i,n){if(ta(t))return new fa(t,e);if(ca(t)||Array.isArray(t)&&t.length>0){const r=pa(t,e,i,n);if("error"===r.result)throw new Error(r.value.map((t=>`${t.key}: ${t.message}`)).join(", "));return r.value}{let i=t;return"string"==typeof t&&"color"===e.type&&(i=Un.parse(t)),{kind:"constant",isConfigDependent:!1,evaluate:()=>i}}}(void 0===e?t.specification.default:e,t.specification,i,n)}isDataDriven(){return"source"===this.expression.kind||"composite"===this.expression.kind}possiblyEvaluate(t,e,i){return this.property.possiblyEvaluate(this,t,e,i)}}class Ya{constructor(t,e,i){this.property=t,this.value=new Wa(t,void 0,e,i)}transitioned(t,e){return new Ka(this.property,this.value,e,ei({},t.transition,this.transition),t.now)}untransitioned(){return new Ka(this.property,this.value,null,{},0)}}class Xa{constructor(t,e,i){this._properties=t,this._values=Object.create(t.defaultTransitionablePropertyValues),this._scope=e,this._options=i,this.isConfigDependent=!1}getValue(t){return ui(this._values[t].value.value)}setValue(t,e){this._values.hasOwnProperty(t)||(this._values[t]=new Ya(this._values[t].property,this._scope,this._options)),this._values[t].value=new Wa(this._values[t].property,null===e?void 0:ui(e),this._scope,this._options),this.isConfigDependent=this.isConfigDependent||this._values[t].value.expression.isConfigDependent}setTransitionOrValue(t,e){e&&(this._options=e);const i=this._properties.properties;if(t)for(const e in t){const n=t[e];if(li(e,"-transition")){const t=e.slice(0,-11);i[t]&&this.setTransition(t,n)}else i.hasOwnProperty(e)&&this.setValue(e,n)}}getTransition(t){return ui(this._values[t].transition)}setTransition(t,e){this._values.hasOwnProperty(t)||(this._values[t]=new Ya(this._values[t].property)),this._values[t].transition=ui(e)||void 0}serialize(){const t={};for(const e of Object.keys(this._values)){const i=this.getValue(e);void 0!==i&&(t[e]=i);const n=this.getTransition(e);void 0!==n&&(t[`${e}-transition`]=n)}return t}transitioned(t,e){const i=new Ja(this._properties);for(const n of Object.keys(this._values))i._values[n]=this._values[n].transitioned(t,e._values[n]);return i}untransitioned(){const t=new Ja(this._properties);for(const e of Object.keys(this._values))t._values[e]=this._values[e].untransitioned();return t}}class Ka{constructor(t,e,i,n,r){const o=n.delay||0,s=n.duration||0;r=r||0,this.property=t,this.value=e,this.begin=r+o,this.end=this.begin+s,t.specification.transition&&(n.delay||n.duration)&&(this.prior=i)}possiblyEvaluate(t,e,i){const n=t.now||0,r=this.value.possiblyEvaluate(t,e,i),o=this.prior;if(o){if(n>this.end)return this.prior=null,r;if(this.value.isDataDriven())return this.prior=null,r;if(n":1,">=":1,"=2&&"$id"!==t[1]&&"$type"!==t[1];case"in":return t.length>=3&&("string"!=typeof t[1]||Array.isArray(t[2]));case"!in":case"!has":case"none":return!1;case"==":case"!=":case">":case">=":case"!0,needGeometry:!1,needFeature:!1};cl(t)||(t=gl(t));const i=t;let n=!0;try{n=function(t){if(!pl(t))return t;let e=ll(t);return hl(e),e=ul(e),e}(i)}catch(t){console.warn(`Failed to extract static filter. Filter will continue working, but at higher memory usage and slower framerate.\nThis is most likely a bug, please report this via https://github.com/mapbox/mapbox-gl-js/issues/new?assignees=&labels=&template=Bug_report.md\nand paste the contents of this message in the report.\nThank you!\nFilter Expression:\n${JSON.stringify(i,null,2)}\n `)}const r=sl[`filter_${e}`],o=da(n,r);let s=null;if("error"===o.result)throw new Error(o.value.map((t=>`${t.key}: ${t.message}`)).join(", "));s=(t,e,i)=>o.value.evaluate(t,e,{},i);let a=null,l=null;if(n!==i){const t=da(i,r);if("error"===t.result)throw new Error(t.value.map((t=>`${t.key}: ${t.message}`)).join(", "));a=(e,i,n,r,o)=>t.value.evaluate(e,i,{},n,void 0,void 0,r,o),l=!Zo(t.value.expression)}return{filter:s,dynamicFilter:a||void 0,needGeometry:_l(n),needFeature:!!l}}function ul(t){if(!Array.isArray(t))return t;const e=function(t){if(fl.has(t[0]))for(let e=1;eul(t)))}function hl(t){let e=!1;const i=[];if("case"===t[0]){for(let n=1;n",">=","e?1:0}function _l(t){if(!Array.isArray(t))return!1;if("within"===t[0]||"distance"===t[0])return!0;for(let e=1;e"===e||"="===e?yl(t[1],t[2],e):"any"===e?(i=t.slice(1),["any"].concat(i.map(gl))):"all"===e?["all"].concat(t.slice(1).map(gl)):"none"===e?["all"].concat(t.slice(1).map(gl).map(bl)):"in"===e?vl(t[1],t.slice(2)):"!in"===e?bl(vl(t[1],t.slice(2))):"has"===e?xl(t[1]):"!has"!==e||bl(xl(t[1]));var i}function yl(t,e,i){switch(t){case"$type":return[`filter-type-${i}`,e];case"$id":return[`filter-id-${i}`,e];default:return[`filter-${i}`,t,e]}}function vl(t,e){if(0===e.length)return!1;switch(t){case"$type":return["filter-type-in",["literal",e]];case"$id":return["filter-id-in",["literal",e]];default:return e.length>200&&!e.some((t=>typeof t!=typeof e[0]))?["filter-in-large",t,["literal",e.sort(ml)]]:["filter-in-small",t,["literal",e]]}}function xl(t){switch(t){case"$type":return!0;case"$id":return["filter-has-id"];default:return["filter-has",t]}}function bl(t){return["!",t]}const wl="";function Tl(t,e){return e?`${t}${wl}${e}`:t}const Sl="-transition",El=new Set(["fill","line","background","hillshade","raster"]);class Ml extends zn{constructor(t,e,i,n,r){if(super(),this.id=t.id,this.fqid=Tl(this.id,i),this.type=t.type,this.scope=i,this.lut=n,this.options=r,this._featureFilter={filter:()=>!0,needGeometry:!1,needFeature:!1},this._filterCompiled=!1,this.isConfigDependent=!1,"custom"!==t.type&&(this.metadata=t.metadata,this.minzoom=t.minzoom,this.maxzoom=t.maxzoom,"background"!==t.type&&"sky"!==t.type&&"slot"!==t.type&&(this.source=t.source,this.sourceLayer=t["source-layer"],this.filter=t.filter),t.slot&&(this.slot=t.slot),e.layout&&(this._unevaluatedLayout=new Qa(e.layout,this.scope,r),this.isConfigDependent=this.isConfigDependent||this._unevaluatedLayout.isConfigDependent),e.paint)){this._transitionablePaint=new Xa(e.paint,this.scope,r);for(const e in t.paint)this.setPaintProperty(e,t.paint[e]);for(const e in t.layout)this.setLayoutProperty(e,t.layout[e]);this.isConfigDependent=this.isConfigDependent||this._transitionablePaint.isConfigDependent,this._transitioningPaint=this._transitionablePaint.untransitioned(),this.paint=new el(e.paint)}}onAdd(t){}onRemove(t){}isDraped(t){return El.has(this.type)}getLayoutProperty(t){return"visibility"===t?this.visibility:this._unevaluatedLayout.getValue(t)}setLayoutProperty(t,e){if("custom"===this.type&&"visibility"===t)return void(this.visibility=e);const i=this._unevaluatedLayout;i._properties.properties[t]&&(i.setValue(t,e),this.isConfigDependent=this.isConfigDependent||i.isConfigDependent,"visibility"===t&&this.possiblyEvaluateVisibility())}possiblyEvaluateVisibility(){this.visibility=this._unevaluatedLayout._values.visibility.possiblyEvaluate({zoom:0})}getPaintProperty(t){return li(t,Sl)?this._transitionablePaint.getTransition(t.slice(0,-11)):this._transitionablePaint.getValue(t)}setPaintProperty(t,e){const i=this._transitionablePaint,n=i._properties.properties;if(li(t,Sl)){const r=t.slice(0,-11);return n[r]&&i.setTransition(r,e||void 0),!1}if(!n[t])return!1;const r=i._values[t],o=r.value.isDataDriven(),s=r.value;i.setValue(t,e),this.isConfigDependent=this.isConfigDependent||i.isConfigDependent,this._handleSpecialPaintPropertyUpdate(t);const a=i._values[t].value,l=a.isDataDriven(),c=li(t,"pattern")||"line-dasharray"===t;return l||o||c||this._handleOverridablePaintPropertyUpdate(t,s,a)}_handleSpecialPaintPropertyUpdate(t){}getProgramIds(){return null}getDefaultProgramParams(t,e,i){return null}_handleOverridablePaintPropertyUpdate(t,e,i){return!1}isHidden(t){return!!(this.minzoom&&t=this.maxzoom)||"none"===this.visibility}updateTransitions(t){this._transitioningPaint=this._transitionablePaint.transitioned(t,this._transitioningPaint)}hasTransition(){return this._transitioningPaint.hasTransition()}recalculate(t,e){this._unevaluatedLayout&&(this.layout=this._unevaluatedLayout.possiblyEvaluate(t,void 0,e)),this.paint=this._transitioningPaint.possiblyEvaluate(t,void 0,e)}serialize(){return di({id:this.id,type:this.type,slot:this.slot,source:this.source,"source-layer":this.sourceLayer,metadata:this.metadata,minzoom:this.minzoom,maxzoom:this.maxzoom,filter:this.filter,layout:this._unevaluatedLayout&&this._unevaluatedLayout.serialize(),paint:this._transitionablePaint&&this._transitionablePaint.serialize()},((t,e)=>!(void 0===t||"layout"===e&&!Object.keys(t).length||"paint"===e&&!Object.keys(t).length)))}is3D(){return!1}isSky(){return!1}isTileClipped(){return!1}hasOffscreenPass(){return!1}hasShadowPass(){return!1}canCastShadows(){return!1}hasLightBeamPass(){return!1}cutoffRange(){return 0}tileCoverLift(){return 0}resize(){}isStateDependent(){for(const t in this.paint._values){const e=this.paint.get(t);if(e instanceof tl&&Xs(e.property.specification)&&("source"===e.value.kind||"composite"===e.value.kind)&&e.value.isStateDependent)return!0}return!1}compileFilter(){this._filterCompiled||(this._featureFilter=dl(this.filter),this._filterCompiled=!0)}invalidateCompiledFilter(){this._filterCompiled=!1}dynamicFilter(){return this._featureFilter.dynamicFilter}dynamicFilterNeedsFeature(){return this._featureFilter.needFeature}getLayerRenderingStats(){return this._stats}resetLayerRenderingStats(t){this._stats&&("shadow"===t.renderPass?this._stats.numRenderedVerticesInShadowPass=0:this._stats.numRenderedVerticesInTransparentPass=0)}queryRadius(t){}queryIntersectsFeature(t,e,i,n,r,o,s,a,l){}queryIntersectsMatchingFeature(t,e,i,n){}}const Cl={Int8:Int8Array,Uint8:Uint8Array,Int16:Int16Array,Uint16:Uint16Array,Int32:Int32Array,Uint32:Uint32Array,Float32:Float32Array};class Al{constructor(t,e){this._structArray=t,this._pos1=e*this.size,this._pos2=this._pos1/2,this._pos4=this._pos1/4,this._pos8=this._pos1/8}}class Il{constructor(){this.isTransferred=!1,this.capacity=-1,this.resize(0)}static serialize(t,e){return t._trim(),e&&(t.isTransferred=!0,e.add(t.arrayBuffer)),{length:t.length,arrayBuffer:t.arrayBuffer}}static deserialize(t){const e=Object.create(this.prototype);return e.arrayBuffer=t.arrayBuffer,e.length=t.length,e.capacity=t.arrayBuffer.byteLength/e.bytesPerElement,e._refreshViews(),e}_trim(){this.length!==this.capacity&&(this.capacity=this.length,this.arrayBuffer=this.arrayBuffer.slice(0,this.length*this.bytesPerElement),this._refreshViews())}clear(){this.length=0}resize(t){this.reserve(t),this.length=t}reserve(t){if(t>this.capacity){this.capacity=Math.max(t,Math.floor(5*this.capacity),128),this.arrayBuffer=new ArrayBuffer(this.capacity*this.bytesPerElement);const e=this.uint8;this._refreshViews(),e&&this.uint8.set(e)}}_refreshViews(){throw new Error("StructArray#_refreshViews() must be implemented by each concrete StructArray layout")}emplace(...t){throw new Error("StructArray#emplace() must be implemented by each concrete StructArray layout")}emplaceBack(...t){throw new Error("StructArray#emplaceBack() must be implemented by each concrete StructArray layout")}destroy(){this.int8=this.uint8=this.int16=this.uint16=this.int32=this.uint32=this.float32=null,this.arrayBuffer=null}}function Ll(t,e=1){let i=0,n=0;return{members:t.map((t=>{const r=Cl[t.type].BYTES_PER_ELEMENT,o=i=Pl(i,Math.max(e,r)),s=t.components||1;return n=Math.max(n,r),i+=r*s,{name:t.name,type:t.type,components:s,offset:o}})),size:Pl(i,Math.max(n,e)),alignment:e}}function Pl(t,e){return Math.ceil(t/e)*e}class $l extends Il{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,e){const i=this.length;return this.resize(i+1),this.emplace(i,t,e)}emplace(t,e,i){const n=2*t;return this.int16[n+0]=e,this.int16[n+1]=i,t}}$l.prototype.bytesPerElement=4,ba($l,"StructArrayLayout2i4");class kl extends Il{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,e,i){const n=this.length;return this.resize(n+1),this.emplace(n,t,e,i)}emplace(t,e,i,n){const r=3*t;return this.int16[r+0]=e,this.int16[r+1]=i,this.int16[r+2]=n,t}}kl.prototype.bytesPerElement=6,ba(kl,"StructArrayLayout3i6");class Dl extends Il{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,e,i,n){const r=this.length;return this.resize(r+1),this.emplace(r,t,e,i,n)}emplace(t,e,i,n,r){const o=4*t;return this.int16[o+0]=e,this.int16[o+1]=i,this.int16[o+2]=n,this.int16[o+3]=r,t}}Dl.prototype.bytesPerElement=8,ba(Dl,"StructArrayLayout4i8");class zl extends Il{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,e,i,n,r){const o=this.length;return this.resize(o+1),this.emplace(o,t,e,i,n,r)}emplace(t,e,i,n,r,o){const s=5*t;return this.int16[s+0]=e,this.int16[s+1]=i,this.int16[s+2]=n,this.int16[s+3]=r,this.int16[s+4]=o,t}}zl.prototype.bytesPerElement=10,ba(zl,"StructArrayLayout5i10");class Rl extends Il{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t,e,i,n,r,o,s){const a=this.length;return this.resize(a+1),this.emplace(a,t,e,i,n,r,o,s)}emplace(t,e,i,n,r,o,s,a){const l=6*t,c=12*t,d=3*t;return this.int16[l+0]=e,this.int16[l+1]=i,this.uint8[c+4]=n,this.uint8[c+5]=r,this.uint8[c+6]=o,this.uint8[c+7]=s,this.float32[d+2]=a,t}}Rl.prototype.bytesPerElement=12,ba(Rl,"StructArrayLayout2i4ub1f12");class Ol extends Il{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t,e,i,n){const r=this.length;return this.resize(r+1),this.emplace(r,t,e,i,n)}emplace(t,e,i,n,r){const o=4*t;return this.float32[o+0]=e,this.float32[o+1]=i,this.float32[o+2]=n,this.float32[o+3]=r,t}}Ol.prototype.bytesPerElement=16,ba(Ol,"StructArrayLayout4f16");class Bl extends Il{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t,e,i){const n=this.length;return this.resize(n+1),this.emplace(n,t,e,i)}emplace(t,e,i,n){const r=3*t;return this.float32[r+0]=e,this.float32[r+1]=i,this.float32[r+2]=n,t}}Bl.prototype.bytesPerElement=12,ba(Bl,"StructArrayLayout3f12");class Fl extends Il{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t,e,i,n,r){const o=this.length;return this.resize(o+1),this.emplace(o,t,e,i,n,r)}emplace(t,e,i,n,r,o){const s=6*t,a=3*t;return this.uint16[s+0]=e,this.uint16[s+1]=i,this.uint16[s+2]=n,this.uint16[s+3]=r,this.float32[a+2]=o,t}}Fl.prototype.bytesPerElement=12,ba(Fl,"StructArrayLayout4ui1f12");class Nl extends Il{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(t,e,i,n){const r=this.length;return this.resize(r+1),this.emplace(r,t,e,i,n)}emplace(t,e,i,n,r){const o=4*t;return this.uint16[o+0]=e,this.uint16[o+1]=i,this.uint16[o+2]=n,this.uint16[o+3]=r,t}}Nl.prototype.bytesPerElement=8,ba(Nl,"StructArrayLayout4ui8");class Ul extends Il{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,e,i,n,r,o){const s=this.length;return this.resize(s+1),this.emplace(s,t,e,i,n,r,o)}emplace(t,e,i,n,r,o,s){const a=6*t;return this.int16[a+0]=e,this.int16[a+1]=i,this.int16[a+2]=n,this.int16[a+3]=r,this.int16[a+4]=o,this.int16[a+5]=s,t}}Ul.prototype.bytesPerElement=12,ba(Ul,"StructArrayLayout6i12");class jl extends Il{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(t,e,i,n,r,o,s,a,l,c,d,u){const h=this.length;return this.resize(h+1),this.emplace(h,t,e,i,n,r,o,s,a,l,c,d,u)}emplace(t,e,i,n,r,o,s,a,l,c,d,u,h){const p=12*t;return this.int16[p+0]=e,this.int16[p+1]=i,this.int16[p+2]=n,this.int16[p+3]=r,this.uint16[p+4]=o,this.uint16[p+5]=s,this.uint16[p+6]=a,this.uint16[p+7]=l,this.int16[p+8]=c,this.int16[p+9]=d,this.int16[p+10]=u,this.int16[p+11]=h,t}}jl.prototype.bytesPerElement=24,ba(jl,"StructArrayLayout4i4ui4i24");class Vl extends Il{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t,e,i,n,r,o){const s=this.length;return this.resize(s+1),this.emplace(s,t,e,i,n,r,o)}emplace(t,e,i,n,r,o,s){const a=10*t,l=5*t;return this.int16[a+0]=e,this.int16[a+1]=i,this.int16[a+2]=n,this.float32[l+2]=r,this.float32[l+3]=o,this.float32[l+4]=s,t}}Vl.prototype.bytesPerElement=20,ba(Vl,"StructArrayLayout3i3f20");class Gl extends Il{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer)}emplaceBack(t){const e=this.length;return this.resize(e+1),this.emplace(e,t)}emplace(t,e){return this.uint32[1*t+0]=e,t}}Gl.prototype.bytesPerElement=4,ba(Gl,"StructArrayLayout1ul4");class Zl extends Il{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t){const e=this.length;return this.resize(e+1),this.emplace(e,t)}emplace(t,e){return this.float32[1*t+0]=e,t}}Zl.prototype.bytesPerElement=4,ba(Zl,"StructArrayLayout1f4");class ql extends Il{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(t,e){const i=this.length;return this.resize(i+1),this.emplace(i,t,e)}emplace(t,e,i){const n=2*t;return this.uint16[n+0]=e,this.uint16[n+1]=i,t}}ql.prototype.bytesPerElement=4,ba(ql,"StructArrayLayout2ui4");class Hl extends Il{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(t,e,i,n,r,o,s,a,l,c,d,u,h){const p=this.length;return this.resize(p+1),this.emplace(p,t,e,i,n,r,o,s,a,l,c,d,u,h)}emplace(t,e,i,n,r,o,s,a,l,c,d,u,h,p){const f=20*t,m=10*t;return this.int16[f+0]=e,this.int16[f+1]=i,this.int16[f+2]=n,this.int16[f+3]=r,this.int16[f+4]=o,this.float32[m+3]=s,this.float32[m+4]=a,this.float32[m+5]=l,this.float32[m+6]=c,this.int16[f+14]=d,this.uint32[m+8]=u,this.uint16[f+18]=h,this.uint16[f+19]=p,t}}Hl.prototype.bytesPerElement=40,ba(Hl,"StructArrayLayout5i4f1i1ul2ui40");class Wl extends Il{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,e,i,n,r,o,s){const a=this.length;return this.resize(a+1),this.emplace(a,t,e,i,n,r,o,s)}emplace(t,e,i,n,r,o,s,a){const l=8*t;return this.int16[l+0]=e,this.int16[l+1]=i,this.int16[l+2]=n,this.int16[l+4]=r,this.int16[l+5]=o,this.int16[l+6]=s,this.int16[l+7]=a,t}}Wl.prototype.bytesPerElement=16,ba(Wl,"StructArrayLayout3i2i2i16");class Yl extends Il{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,e,i,n,r){const o=this.length;return this.resize(o+1),this.emplace(o,t,e,i,n,r)}emplace(t,e,i,n,r,o){const s=4*t,a=8*t;return this.float32[s+0]=e,this.float32[s+1]=i,this.float32[s+2]=n,this.int16[a+6]=r,this.int16[a+7]=o,t}}Yl.prototype.bytesPerElement=16,ba(Yl,"StructArrayLayout2f1f2i16");class Xl extends Il{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t,e,i,n){const r=this.length;return this.resize(r+1),this.emplace(r,t,e,i,n)}emplace(t,e,i,n,r){const o=12*t,s=3*t;return this.uint8[o+0]=e,this.uint8[o+1]=i,this.float32[s+1]=n,this.float32[s+2]=r,t}}Xl.prototype.bytesPerElement=12,ba(Xl,"StructArrayLayout2ub2f12");class Kl extends Il{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(t,e,i){const n=this.length;return this.resize(n+1),this.emplace(n,t,e,i)}emplace(t,e,i,n){const r=3*t;return this.uint16[r+0]=e,this.uint16[r+1]=i,this.uint16[r+2]=n,t}}Kl.prototype.bytesPerElement=6,ba(Kl,"StructArrayLayout3ui6");class Jl extends Il{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer)}emplaceBack(t,e,i,n,r,o,s,a,l,c,d,u,h,p,f,m,_,g,y,v,x){const b=this.length;return this.resize(b+1),this.emplace(b,t,e,i,n,r,o,s,a,l,c,d,u,h,p,f,m,_,g,y,v,x)}emplace(t,e,i,n,r,o,s,a,l,c,d,u,h,p,f,m,_,g,y,v,x,b){const w=30*t,T=15*t,S=60*t;return this.int16[w+0]=e,this.int16[w+1]=i,this.int16[w+2]=n,this.float32[T+2]=r,this.float32[T+3]=o,this.uint16[w+8]=s,this.uint16[w+9]=a,this.uint32[T+5]=l,this.uint32[T+6]=c,this.uint32[T+7]=d,this.uint16[w+16]=u,this.uint16[w+17]=h,this.uint16[w+18]=p,this.float32[T+10]=f,this.float32[T+11]=m,this.uint8[S+48]=_,this.uint8[S+49]=g,this.uint8[S+50]=y,this.uint32[T+13]=v,this.int16[w+28]=x,this.uint8[S+58]=b,t}}Jl.prototype.bytesPerElement=60,ba(Jl,"StructArrayLayout3i2f2ui3ul3ui2f3ub1ul1i1ub60");class Ql extends Il{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer)}emplaceBack(t,e,i,n,r,o,s,a,l,c,d,u,h,p,f,m,_,g,y,v,x,b,w,T,S,E,M,C,A,I,L,P,$,k){const D=this.length;return this.resize(D+1),this.emplace(D,t,e,i,n,r,o,s,a,l,c,d,u,h,p,f,m,_,g,y,v,x,b,w,T,S,E,M,C,A,I,L,P,$,k)}emplace(t,e,i,n,r,o,s,a,l,c,d,u,h,p,f,m,_,g,y,v,x,b,w,T,S,E,M,C,A,I,L,P,$,k,D){const z=22*t,R=44*t,O=88*t;return this.float32[z+0]=e,this.float32[z+1]=i,this.int16[R+4]=n,this.int16[R+5]=r,this.int16[R+6]=o,this.int16[R+7]=s,this.int16[R+8]=a,this.int16[R+9]=l,this.int16[R+10]=c,this.int16[R+11]=d,this.int16[R+12]=u,this.uint16[R+13]=h,this.uint16[R+14]=p,this.uint16[R+15]=f,this.uint16[R+16]=m,this.uint16[R+17]=_,this.uint16[R+18]=g,this.uint16[R+19]=y,this.uint16[R+20]=v,this.uint16[R+21]=x,this.uint16[R+22]=b,this.uint16[R+23]=w,this.uint16[R+24]=T,this.uint16[R+25]=S,this.uint16[R+26]=E,this.uint16[R+27]=M,this.uint32[z+14]=C,this.float32[z+15]=A,this.float32[z+16]=I,this.float32[z+17]=L,this.float32[z+18]=P,this.float32[z+19]=$,this.float32[z+20]=k,this.uint8[O+84]=D,t}}Ql.prototype.bytesPerElement=88,ba(Ql,"StructArrayLayout2f9i15ui1ul6f1ub88");class tc extends Il{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t,e,i,n,r){const o=this.length;return this.resize(o+1),this.emplace(o,t,e,i,n,r)}emplace(t,e,i,n,r,o){const s=5*t;return this.float32[s+0]=e,this.float32[s+1]=i,this.float32[s+2]=n,this.float32[s+3]=r,this.float32[s+4]=o,t}}tc.prototype.bytesPerElement=20,ba(tc,"StructArrayLayout5f20");class ec extends Il{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t,e,i,n,r,o,s){const a=this.length;return this.resize(a+1),this.emplace(a,t,e,i,n,r,o,s)}emplace(t,e,i,n,r,o,s,a){const l=7*t;return this.float32[l+0]=e,this.float32[l+1]=i,this.float32[l+2]=n,this.float32[l+3]=r,this.float32[l+4]=o,this.float32[l+5]=s,this.float32[l+6]=a,t}}ec.prototype.bytesPerElement=28,ba(ec,"StructArrayLayout7f28");class ic extends Il{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t,e){const i=this.length;return this.resize(i+1),this.emplace(i,t,e)}emplace(t,e,i){const n=2*t;return this.float32[n+0]=e,this.float32[n+1]=i,t}}ic.prototype.bytesPerElement=8,ba(ic,"StructArrayLayout2f8");class nc extends Il{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(t,e,i,n){const r=this.length;return this.resize(r+1),this.emplace(r,t,e,i,n)}emplace(t,e,i,n,r){const o=6*t;return this.uint32[3*t+0]=e,this.uint16[o+2]=i,this.uint16[o+3]=n,this.uint16[o+4]=r,t}}nc.prototype.bytesPerElement=12,ba(nc,"StructArrayLayout1ul3ui12");class rc extends Il{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(t){const e=this.length;return this.resize(e+1),this.emplace(e,t)}emplace(t,e){return this.uint16[1*t+0]=e,t}}rc.prototype.bytesPerElement=2,ba(rc,"StructArrayLayout1ui2");class oc extends Il{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t,e,i,n,r,o,s,a,l,c,d,u,h,p,f,m){const _=this.length;return this.resize(_+1),this.emplace(_,t,e,i,n,r,o,s,a,l,c,d,u,h,p,f,m)}emplace(t,e,i,n,r,o,s,a,l,c,d,u,h,p,f,m,_){const g=16*t;return this.float32[g+0]=e,this.float32[g+1]=i,this.float32[g+2]=n,this.float32[g+3]=r,this.float32[g+4]=o,this.float32[g+5]=s,this.float32[g+6]=a,this.float32[g+7]=l,this.float32[g+8]=c,this.float32[g+9]=d,this.float32[g+10]=u,this.float32[g+11]=h,this.float32[g+12]=p,this.float32[g+13]=f,this.float32[g+14]=m,this.float32[g+15]=_,t}}oc.prototype.bytesPerElement=64,ba(oc,"StructArrayLayout16f64");class sc extends Il{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t,e,i,n,r,o,s){const a=this.length;return this.resize(a+1),this.emplace(a,t,e,i,n,r,o,s)}emplace(t,e,i,n,r,o,s,a){const l=10*t,c=5*t;return this.uint16[l+0]=e,this.uint16[l+1]=i,this.uint16[l+2]=n,this.uint16[l+3]=r,this.float32[c+2]=o,this.float32[c+3]=s,this.float32[c+4]=a,t}}sc.prototype.bytesPerElement=20,ba(sc,"StructArrayLayout4ui3f20");class ac extends Il{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t){const e=this.length;return this.resize(e+1),this.emplace(e,t)}emplace(t,e){return this.int16[1*t+0]=e,t}}ac.prototype.bytesPerElement=2,ba(ac,"StructArrayLayout1i2");class lc extends Il{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer)}emplaceBack(t){const e=this.length;return this.resize(e+1),this.emplace(e,t)}emplace(t,e){return this.uint8[1*t+0]=e,t}}lc.prototype.bytesPerElement=1,ba(lc,"StructArrayLayout1ub1");class cc extends Al{get projectedAnchorX(){return this._structArray.int16[this._pos2+0]}get projectedAnchorY(){return this._structArray.int16[this._pos2+1]}get projectedAnchorZ(){return this._structArray.int16[this._pos2+2]}get tileAnchorX(){return this._structArray.int16[this._pos2+3]}get tileAnchorY(){return this._structArray.int16[this._pos2+4]}get x1(){return this._structArray.float32[this._pos4+3]}get y1(){return this._structArray.float32[this._pos4+4]}get x2(){return this._structArray.float32[this._pos4+5]}get y2(){return this._structArray.float32[this._pos4+6]}get padding(){return this._structArray.int16[this._pos2+14]}get featureIndex(){return this._structArray.uint32[this._pos4+8]}get sourceLayerIndex(){return this._structArray.uint16[this._pos2+18]}get bucketIndex(){return this._structArray.uint16[this._pos2+19]}}cc.prototype.size=40;class dc extends Hl{get(t){return new cc(this,t)}}ba(dc,"CollisionBoxArray");class uc extends Al{get projectedAnchorX(){return this._structArray.int16[this._pos2+0]}get projectedAnchorY(){return this._structArray.int16[this._pos2+1]}get projectedAnchorZ(){return this._structArray.int16[this._pos2+2]}get tileAnchorX(){return this._structArray.float32[this._pos4+2]}get tileAnchorY(){return this._structArray.float32[this._pos4+3]}get glyphStartIndex(){return this._structArray.uint16[this._pos2+8]}get numGlyphs(){return this._structArray.uint16[this._pos2+9]}get vertexStartIndex(){return this._structArray.uint32[this._pos4+5]}get lineStartIndex(){return this._structArray.uint32[this._pos4+6]}get lineLength(){return this._structArray.uint32[this._pos4+7]}get segment(){return this._structArray.uint16[this._pos2+16]}get lowerSize(){return this._structArray.uint16[this._pos2+17]}get upperSize(){return this._structArray.uint16[this._pos2+18]}get lineOffsetX(){return this._structArray.float32[this._pos4+10]}get lineOffsetY(){return this._structArray.float32[this._pos4+11]}get writingMode(){return this._structArray.uint8[this._pos1+48]}get placedOrientation(){return this._structArray.uint8[this._pos1+49]}set placedOrientation(t){this._structArray.uint8[this._pos1+49]=t}get hidden(){return this._structArray.uint8[this._pos1+50]}set hidden(t){this._structArray.uint8[this._pos1+50]=t}get crossTileID(){return this._structArray.uint32[this._pos4+13]}set crossTileID(t){this._structArray.uint32[this._pos4+13]=t}get associatedIconIndex(){return this._structArray.int16[this._pos2+28]}get flipState(){return this._structArray.uint8[this._pos1+58]}set flipState(t){this._structArray.uint8[this._pos1+58]=t}}uc.prototype.size=60;class hc extends Jl{get(t){return new uc(this,t)}}ba(hc,"PlacedSymbolArray");class pc extends Al{get tileAnchorX(){return this._structArray.float32[this._pos4+0]}get tileAnchorY(){return this._structArray.float32[this._pos4+1]}get projectedAnchorX(){return this._structArray.int16[this._pos2+4]}get projectedAnchorY(){return this._structArray.int16[this._pos2+5]}get projectedAnchorZ(){return this._structArray.int16[this._pos2+6]}get rightJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+7]}get centerJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+8]}get leftJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+9]}get verticalPlacedTextSymbolIndex(){return this._structArray.int16[this._pos2+10]}get placedIconSymbolIndex(){return this._structArray.int16[this._pos2+11]}get verticalPlacedIconSymbolIndex(){return this._structArray.int16[this._pos2+12]}get key(){return this._structArray.uint16[this._pos2+13]}get textBoxStartIndex(){return this._structArray.uint16[this._pos2+14]}get textBoxEndIndex(){return this._structArray.uint16[this._pos2+15]}get verticalTextBoxStartIndex(){return this._structArray.uint16[this._pos2+16]}get verticalTextBoxEndIndex(){return this._structArray.uint16[this._pos2+17]}get iconBoxStartIndex(){return this._structArray.uint16[this._pos2+18]}get iconBoxEndIndex(){return this._structArray.uint16[this._pos2+19]}get verticalIconBoxStartIndex(){return this._structArray.uint16[this._pos2+20]}get verticalIconBoxEndIndex(){return this._structArray.uint16[this._pos2+21]}get featureIndex(){return this._structArray.uint16[this._pos2+22]}get numHorizontalGlyphVertices(){return this._structArray.uint16[this._pos2+23]}get numVerticalGlyphVertices(){return this._structArray.uint16[this._pos2+24]}get numIconVertices(){return this._structArray.uint16[this._pos2+25]}get numVerticalIconVertices(){return this._structArray.uint16[this._pos2+26]}get useRuntimeCollisionCircles(){return this._structArray.uint16[this._pos2+27]}get crossTileID(){return this._structArray.uint32[this._pos4+14]}set crossTileID(t){this._structArray.uint32[this._pos4+14]=t}get textOffset0(){return this._structArray.float32[this._pos4+15]}get textOffset1(){return this._structArray.float32[this._pos4+16]}get collisionCircleDiameter(){return this._structArray.float32[this._pos4+17]}get zOffset(){return this._structArray.float32[this._pos4+18]}set zOffset(t){this._structArray.float32[this._pos4+18]=t}get occlusionState(){return this._structArray.float32[this._pos4+19]}set occlusionState(t){this._structArray.float32[this._pos4+19]=t}get occlusionOpacity(){return this._structArray.float32[this._pos4+20]}set occlusionOpacity(t){this._structArray.float32[this._pos4+20]=t}get hasIconTextFit(){return this._structArray.uint8[this._pos1+84]}}pc.prototype.size=88;class fc extends Ql{get(t){return new pc(this,t)}}ba(fc,"SymbolInstanceArray");class mc extends Zl{getoffsetX(t){return this.float32[1*t+0]}}ba(mc,"GlyphOffsetArray");class _c extends $l{getx(t){return this.int16[2*t+0]}gety(t){return this.int16[2*t+1]}}ba(_c,"SymbolLineVertexArray");class gc extends Al{get featureIndex(){return this._structArray.uint32[this._pos4+0]}get sourceLayerIndex(){return this._structArray.uint16[this._pos2+2]}get bucketIndex(){return this._structArray.uint16[this._pos2+3]}get layoutVertexArrayOffset(){return this._structArray.uint16[this._pos2+4]}}gc.prototype.size=12;class yc extends nc{get(t){return new gc(this,t)}}ba(yc,"FeatureIndexArray");class vc extends ql{geta_centroid_pos0(t){return this.uint16[2*t+0]}geta_centroid_pos1(t){return this.uint16[2*t+1]}}ba(vc,"FillExtrusionCentroidArray");const xc=Ll([{name:"a_pos",components:2,type:"Int16"}],4),bc=Ll([{name:"a_pos_3",components:3,type:"Int16"},{name:"a_pos_normal_3",components:3,type:"Int16"}]);class wc{constructor(t=[]){this.segments=t}_prepareSegment(t,e,i,n){let r=this.segments[this.segments.length-1];return t>wc.MAX_VERTEX_ARRAY_LENGTH&&pi(`Max vertices per segment is ${wc.MAX_VERTEX_ARRAY_LENGTH}: bucket requested ${t}`),(!r||r.vertexLength+t>wc.MAX_VERTEX_ARRAY_LENGTH||r.sortKey!==n)&&(r={vertexOffset:e,primitiveOffset:i,vertexLength:0,primitiveLength:0},void 0!==n&&(r.sortKey=n),this.segments.push(r)),r}prepareSegment(t,e,i,n){return this._prepareSegment(t,e.length,i.length,n)}get(){return this.segments}destroy(){for(const t of this.segments)for(const e in t.vaos)t.vaos[e].destroy()}static simpleSegment(t,e,i,n){return new wc([{vertexOffset:t,primitiveOffset:e,vertexLength:i,primitiveLength:n,vaos:{},sortKey:0}])}}function Tc(t,e){return 256*(t=Xe(Math.floor(t),0,255))+Xe(Math.floor(e),0,255)}wc.MAX_VERTEX_ARRAY_LENGTH=Math.pow(2,16)-1,ba(wc,"SegmentVector");const Sc=Ll([{name:"a_pattern",components:4,type:"Uint16"},{name:"a_pixel_ratio",components:1,type:"Float32"}]),Ec=Ll([{name:"a_dash",components:4,type:"Uint16"}]);class Mc{constructor(){this.ids=[],this.uniqueIds=[],this.positions=[],this.indexed=!1}add(t,e,i,n){this.ids.push(Cc(t)),this.positions.push(e,i,n)}eachPosition(t,e){const i=Cc(t);let n=0,r=this.ids.length-1;for(;n>1;this.ids[t]>=i?r=t:n=t+1}for(;this.ids[n]===i;)e(this.positions[3*n],this.positions[3*n+1],this.positions[3*n+2]),n++}static serialize(t,e){const i=new Float64Array(t.ids),n=new Uint32Array(t.positions);return Ac(i,n,0,i.length-1),e&&(e.add(i.buffer),e.add(n.buffer)),{ids:i,positions:n}}static deserialize(t){const e=new Mc;let i;e.ids=t.ids,e.positions=t.positions;for(const t of e.ids)t!==i&&e.uniqueIds.push(t),i=t;return e.indexed=!0,e}}function Cc(t){const e=+t;return!isNaN(e)&&Number.MIN_SAFE_INTEGER>1];let o=i-1,s=n+1;for(;;){do{o++}while(t[o]r);if(o>=s)break;Ic(t,o,s),Ic(e,3*o,3*s),Ic(e,3*o+1,3*s+1),Ic(e,3*o+2,3*s+2)}s-i`u_${t}`)),this.type=i,this.context=n}setUniform(t,e,i,n,r){const o=n.constantOr(this.value);e.set(t,r,o instanceof Un?o.toRenderColor(this.context.lut):o)}getBinding(t,e){return"color"===this.type?new Rc(t):new $c(t)}}class Gc{constructor(t,e){this.uniformNames=e.map((t=>`u_${t}`)),this.pattern=null,this.pixelRatio=1}setConstantPatternPositions(t){this.pixelRatio=t.pixelRatio||1,this.pattern=t.tl.concat(t.br)}setUniform(t,e,i,n,r){const o="u_pattern"===r||"u_dash"===r?this.pattern:"u_pixel_ratio"===r?this.pixelRatio:null;o&&e.set(t,r,o)}getBinding(t,e){return"u_pattern"===e||"u_dash"===e?new zc(t):new $c(t)}}class Zc{constructor(t,e,i,n){this.expression=t,this.type=i,this.maxValue=0,this.paintVertexAttributes=e.map((t=>({name:`a_${t}`,type:"Float32",components:"color"===i?2:1,offset:0}))),this.paintVertexArray=new n}populatePaintArray(t,e,i,n,r,o,s){const a=this.paintVertexArray.length,l=this.expression.evaluate(new Ha(0,{brightness:o}),e,{},r,n,s);this.paintVertexArray.resize(t),this._setPaintValue(a,t,l,this.context)}updatePaintArray(t,e,i,n,r,o,s){const a=this.expression.evaluate({zoom:0,brightness:s},i,n,void 0,r);this._setPaintValue(t,e,a,this.context)}_setPaintValue(t,e,i,n){if("color"===this.type){const r=jc(i.toRenderColor(n.lut));for(let i=t;i`u_${t}_t`)),this.type=i,this.useIntegerZoom=n,this.context=r,this.maxValue=0,this.paintVertexAttributes=e.map((t=>({name:`a_${t}`,type:"Float32",components:"color"===i?4:2,offset:0}))),this.paintVertexArray=new o}populatePaintArray(t,e,i,n,r,o,s){const a=this.expression.evaluate(new Ha(this.context.zoom,{brightness:o}),e,{},r,n,s),l=this.expression.evaluate(new Ha(this.context.zoom+1,{brightness:o}),e,{},r,n,s),c=this.paintVertexArray.length;this.paintVertexArray.resize(t),this._setPaintValue(c,t,a,l,this.context)}updatePaintArray(t,e,i,n,r,o,s){const a=this.expression.evaluate({zoom:this.context.zoom,brightness:s},i,n,void 0,r),l=this.expression.evaluate({zoom:this.context.zoom+1,brightness:s},i,n,void 0,r);this._setPaintValue(t,e,a,l,this.context)}_setPaintValue(t,e,i,n,r){if("color"===this.type){const n=jc(i.toRenderColor(r.lut)),o=jc(i.toRenderColor(r.lut));for(let i=t;i!0){this.binders={},this._buffers=[],this.context=e;const n=[];for(const r in t.paint._values){const o=t.paint.get(r);if(!i(r))continue;if(!(o instanceof tl&&Xs(o.property.specification)))continue;const s=Kc(r,t.type),a=o.value,l=o.property.specification.type,c=!!o.property.useIntegerZoom,d="line-dasharray"===r||r.endsWith("pattern"),u="line-dasharray"===r&&"constant"!==t.layout.get("line-cap").value.kind;if("constant"!==a.kind||u)if("source"===a.kind||u||d){const e=td(r,l,"source");this.binders[r]=d?new Hc(a,s,l,e,t.id):new Zc(a,s,l,e),n.push(`/a_${r}`)}else{const t=td(r,l,"composite");this.binders[r]=new qc(a,s,l,c,e,t),n.push(`/z_${r}`)}else this.binders[r]=d?new Gc(a.value,s):new Vc(a.value,s,l,e),n.push(`/u_${r}`)}this.cacheKey=n.sort().join("")}getMaxValue(t){const e=this.binders[t];return e instanceof Zc||e instanceof qc?e.maxValue:0}populatePaintArrays(t,e,i,n,r,o,s){for(const a in this.binders){const l=this.binders[a];l.context=this.context,(l instanceof Zc||l instanceof qc||l instanceof Hc)&&l.populatePaintArray(t,e,i,n,r,o,s)}}setConstantPatternPositions(t){for(const e in this.binders){const i=this.binders[e];i instanceof Gc&&i.setConstantPatternPositions(t)}}updatePaintArrays(t,e,i,n,r,o,s,a){let l=!1;const c=Object.keys(t),d=0!==c.length,u=d?c:e.uniqueIds;this.context.lut=r.lut;for(const c in this.binders){const h=this.binders[c];if(h.context=this.context,(h instanceof Zc||h instanceof qc||h instanceof Hc)&&(!0===h.expression.isStateDependent||!1===h.expression.isLightConstant)){const p=r.paint.get(c);h.expression=p.value;for(const i of u){const r=t[i.toString()];e.eachPosition(i,((t,e,i)=>{const l=n.feature(t);h.updatePaintArray(e,i,l,r,o,s,a)}))}if(!d)for(const e of i.uniqueIds){const r=t[e.toString()];i.eachPosition(e,((t,e,i)=>{const l=n.feature(t);h.updatePaintArray(e,i,l,r,o,s,a)}))}l=!0}}return l}defines(){const t=[];for(const e in this.binders){const i=this.binders[e];(i instanceof Vc||i instanceof Gc)&&t.push(...i.uniformNames.map((t=>`#define HAS_UNIFORM_${t}`)))}return t}getBinderAttributes(){const t=[];for(const e in this.binders){const i=this.binders[e];if(i instanceof Zc||i instanceof qc||i instanceof Hc)for(let e=0;e!0){this.programConfigurations={};for(const n of t)this.programConfigurations[n.id]=new Wc(n,e,i);this.needsUpload=!1,this._featureMap=new Mc,this._featureMapWithoutIds=new Mc,this._bufferOffset=0,this._idlessCounter=0}populatePaintArrays(t,e,i,n,r,o,s,a){for(const i in this.programConfigurations)this.programConfigurations[i].populatePaintArrays(t,e,n,r,o,s,a);void 0!==e.id?this._featureMap.add(e.id,i,this._bufferOffset,t):(this._featureMapWithoutIds.add(this._idlessCounter,i,this._bufferOffset,t),this._idlessCounter+=1),this._bufferOffset=t,this.needsUpload=!0}updatePaintArrays(t,e,i,n,r,o){for(const s of i)this.needsUpload=this.programConfigurations[s.id].updatePaintArrays(t,this._featureMap,this._featureMapWithoutIds,e,s,n,r,o||0)||this.needsUpload}get(t){return this.programConfigurations[t]}upload(t){if(this.needsUpload){for(const e in this.programConfigurations)this.programConfigurations[e].upload(t);this.needsUpload=!1}}destroy(){for(const t in this.programConfigurations)this.programConfigurations[t].destroy()}}const Xc={"text-opacity":["opacity"],"icon-opacity":["opacity"],"text-occlusion-opacity":["occlusion_opacity"],"icon-occlusion-opacity":["occlusion_opacity"],"text-color":["fill_color"],"icon-color":["fill_color"],"text-emissive-strength":["emissive_strength"],"icon-emissive-strength":["emissive_strength"],"text-halo-color":["halo_color"],"icon-halo-color":["halo_color"],"text-halo-blur":["halo_blur"],"icon-halo-blur":["halo_blur"],"text-halo-width":["halo_width"],"icon-halo-width":["halo_width"],"line-gap-width":["gapwidth"],"line-pattern":["pattern","pixel_ratio"],"fill-pattern":["pattern","pixel_ratio"],"fill-extrusion-pattern":["pattern","pixel_ratio"],"line-dasharray":["dash"]};function Kc(t,e){return Xc[t]||[t.replace(`${e}-`,"").replace(/-/g,"_")]}const Jc={"line-pattern":{source:Fl,composite:Fl},"fill-pattern":{source:Fl,composite:Fl},"fill-extrusion-pattern":{source:Fl,composite:Fl},"line-dasharray":{source:Nl,composite:Nl}},Qc={color:{source:ic,composite:Ol},number:{source:Zl,composite:ic}};function td(t,e,i){const n=Jc[t];return n&&n[i]||Qc[e][i]}ba(Vc,"ConstantBinder"),ba(Gc,"PatternConstantBinder"),ba(Zc,"SourceExpressionBinder"),ba(Hc,"PatternCompositeBinder"),ba(qc,"CompositeExpressionBinder"),ba(Wc,"ProgramConfiguration",{omit:["_buffers"]}),ba(Yc,"ProgramConfigurationSet");const ed=uo/Math.PI/2,id=5,nd=6,rd=16383,od=64,sd=[od,32,16],ad=-ed,ld=ed;function cd(t,e,i,n=ed){return i=Ge(i),[t*Math.sin(i)*n,-e*n,t*Math.cos(i)*n]}function dd(t,e,i){return cd(Math.cos(Ge(t)),Math.sin(Ge(t)),e,i)}const ud=6371008.8,hd=2*Math.PI*ud;class pd{constructor(t,e){if(isNaN(t)||isNaN(e))throw new Error(`Invalid LngLat object: (${t}, ${e})`);if(this.lng=+t,this.lat=+e,this.lat>90||this.lat, lat: }, an object {lon: , lat: }, or an array of [, ]")}}class fd{constructor(t,e){if(t)if(e)this.setSouthWest(t).setNorthEast(e);else if(4===t.length){const e=t;this.setSouthWest([e[0],e[1]]).setNorthEast([e[2],e[3]])}else{const e=t;this.setSouthWest(e[0]).setNorthEast(e[1])}}setNorthEast(t){return this._ne=t instanceof pd?new pd(t.lng,t.lat):pd.convert(t),this}setSouthWest(t){return this._sw=t instanceof pd?new pd(t.lng,t.lat):pd.convert(t),this}extend(t){const e=this._sw,i=this._ne;let n,r;if(t instanceof pd)n=t,r=t;else{if(!(t instanceof fd))return Array.isArray(t)?4===t.length||t.every(Array.isArray)?this.extend(fd.convert(t)):this.extend(pd.convert(t)):"object"==typeof t&&null!==t&&t.hasOwnProperty("lat")&&(t.hasOwnProperty("lon")||t.hasOwnProperty("lng"))?this.extend(pd.convert(t)):this;if(n=t._sw,r=t._ne,!n||!r)return this}return e||i?(e.lng=Math.min(n.lng,e.lng),e.lat=Math.min(n.lat,e.lat),i.lng=Math.max(r.lng,i.lng),i.lat=Math.max(r.lat,i.lat)):(this._sw=new pd(n.lng,n.lat),this._ne=new pd(r.lng,r.lat)),this}getCenter(){return new pd((this._sw.lng+this._ne.lng)/2,(this._sw.lat+this._ne.lat)/2)}getSouthWest(){return this._sw}getNorthEast(){return this._ne}getNorthWest(){return new pd(this.getWest(),this.getNorth())}getSouthEast(){return new pd(this.getEast(),this.getSouth())}getWest(){return this._sw.lng}getSouth(){return this._sw.lat}getEast(){return this._ne.lng}getNorth(){return this._ne.lat}toArray(){return[this._sw.toArray(),this._ne.toArray()]}toString(){return`LngLatBounds(${this._sw.toString()}, ${this._ne.toString()})`}isEmpty(){return!(this._sw&&this._ne)}contains(t){const{lng:e,lat:i}=pd.convert(t);let n=this._sw.lngthis._ne.lng&&(n=this._sw.lng>=e&&e>=this._ne.lng),this._sw.lat0;o--)n=1this.canonical.z?new vd(t,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y):new vd(t,this.wrap,t,this.canonical.x>>e,this.canonical.y>>e)}calculateScaledKey(t,e=!0){if(this.overscaledZ===t&&e)return this.key;if(t>this.canonical.z)return xd(this.wrap*+e,t,this.canonical.z,this.canonical.x,this.canonical.y);{const i=this.canonical.z-t;return xd(this.wrap*+e,t,t,this.canonical.x>>i,this.canonical.y>>i)}}isChildOf(t){if(t.wrap!==this.wrap)return!1;const e=this.canonical.z-t.canonical.z;return 0===t.overscaledZ||t.overscaledZ>e&&t.canonical.y===this.canonical.y>>e}children(t){if(this.overscaledZ>=t)return[new vd(this.overscaledZ+1,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y)];const e=this.canonical.z+1,i=2*this.canonical.x,n=2*this.canonical.y;return[new vd(e,this.wrap,e,i,n),new vd(e,this.wrap,e,i+1,n),new vd(e,this.wrap,e,i,n+1),new vd(e,this.wrap,e,i+1,n+1)]}isLessThan(t){return this.wrapt.wrap)&&(this.overscaledZt.overscaledZ)&&(this.canonical.xt.canonical.x)&&this.canonical.y{let e=t.canonical.x-1,i=t.wrap;return e{let e=t.canonical.x+1,i=t.wrap;return e===1new vd(t.overscaledZ,t.wrap,t.canonical.z,t.canonical.x,(0===t.canonical.y?1new vd(t.overscaledZ,t.wrap,t.canonical.z,t.canonical.x,t.canonical.y===(1=l?(Od(t,e,i,c,d,o,u,a,l),Od(t,c,d,n,r,u,s,a,l)):t.push(s)}function Bd(t,e,i){let n=t[0],r=n.x,o=n.y;e(n);const s=[n];for(let a=1;at.x+1||nt.y+1)&&pi("Geometry exceeds allowed extent, reduce your vector tile buffer size"),t}function Gd(t,e,i){const n=t.loadGeometry(),r=t.extent,o=uo/r;if(e&&i&&i.projection.isReprojectedInTileSpace){const o=1{const i=Ad((e.x+t.x/r)/o),n=Id((e.y+t.y/r)/o),d=c.project(i,n);t.x=(d.x*s-a)*r,t.y=(d.y*s-l)*r};for(let e=0;e=r||i.y=r||(d(i),t.push(i));n[e]=t}}for(const t of n)for(const e of t)Vd(e,o);return n}function Zd(t,e){return{type:t.type,id:t.id,properties:t.properties,geometry:e?Gd(t):[]}}function qd(t,e,i,n,r){t.emplaceBack(2*e+(n+1)/2,2*i+(r+1)/2)}function Hd(t,e,i){const n=16384;t.emplaceBack(e.x,e.y,e.z,i[0]*n,i[1]*n,i[2]*n)}class Wd{constructor(t){this.zoom=t.zoom,this.overscaling=t.overscaling,this.layers=t.layers,this.layerIds=this.layers.map((t=>t.fqid)),this.index=t.index,this.hasPattern=!1,this.projection=t.projection,this.layoutVertexArray=new $l,this.indexArray=new Kl,this.segments=new wc,this.programConfigurations=new Yc(t.layers,{zoom:t.zoom,lut:t.lut}),this.stateDependentLayerIds=this.layers.filter((t=>t.isStateDependent())).map((t=>t.id))}updateFootprints(t,e){}populate(t,e,i,n){const r=this.layers[0],o=[];let s=null;"circle"===r.type&&(s=r.layout.get("circle-sort-key"));for(const{feature:e,id:r,index:a,sourceLayerIndex:l}of t){const t=this.layers[0]._featureFilter.needGeometry,c=Zd(e,t);if(!this.layers[0]._featureFilter.filter(new Ha(this.zoom),c,i))continue;const d=s?s.evaluate(c,{},i):void 0,u={id:r,properties:e.properties,type:e.type,sourceLayerIndex:l,index:a,geometry:t?c.geometry:Gd(e,i,n),patterns:{},sortKey:d};o.push(u)}s&&o.sort(((t,e)=>t.sortKey-e.sortKey));let a=null;"globe"===n.projection.name&&(this.globeExtVertexArray=new Ul,a=n.projection);for(const n of o){const{geometry:r,index:o,sourceLayerIndex:s}=n,l=t[o].feature;this.addFeature(n,r,o,e.availableImages,i,a,e.brightness),e.featureIndex.insert(l,r,o,s,this.index)}}update(t,e,i,n,r){const o=0!==Object.keys(t).length;o&&!this.stateDependentLayers.length||this.programConfigurations.updatePaintArrays(t,e,o?this.stateDependentLayers:this.layers,i,n,r)}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(t){this.uploaded||(this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,xc.members),this.indexBuffer=t.createIndexBuffer(this.indexArray),this.globeExtVertexArray&&(this.globeExtVertexBuffer=t.createVertexBuffer(this.globeExtVertexArray,bc.members))),this.programConfigurations.upload(t),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy(),this.globeExtVertexBuffer&&this.globeExtVertexBuffer.destroy())}addFeature(t,e,i,n,r,o,s){for(const i of e)for(const e of i){const i=e.x,n=e.y;if(i=uo||n=uo)continue;if(o){const t=o.projectTilePoint(i,n,r),e=o.upVector(r,i,n),s=this.globeExtVertexArray;Hd(s,t,e),Hd(s,t,e),Hd(s,t,e),Hd(s,t,e)}const s=this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray,t.sortKey),a=s.vertexLength;qd(this.layoutVertexArray,i,n,-1,-1),qd(this.layoutVertexArray,i,n,1,-1),qd(this.layoutVertexArray,i,n,1,1),qd(this.layoutVertexArray,i,n,-1,1),this.indexArray.emplaceBack(a,a+1,a+2),this.indexArray.emplaceBack(a,a+2,a+3),s.vertexLength+=4,s.primitiveLength+=2}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,t,i,{},n,r,s)}}function Yd(t,e){for(let i=0;i1){if(Qd(t,e))return!0;for(let n=0;n1?i:i.sub(e)._mult(r)._add(e))}function nu(t,e){let i,n,r,o=!1;for(let s=0;se.y!=r.y>e.y&&e.xe.y!=s.y>e.y&&e.x=o.x&&r>=o.y)return!0;const o=[new Ue(e,i),new Ue(e,r),new Ue(n,r),new Ue(n,i)];if(t.length>2)for(const e of o)if(ru(t,e))return!0;for(let e=0;er.x&&e.x>r.x||t.yr.y&&e.y>r.y)return!1;const o=fi(t,e,i[0]);return o!==fi(t,e,i[1])||o!==fi(t,e,i[2])||o!==fi(t,e,i[3])}function au(t,e,i,n,r,o){let s=e.y-t.y,a=t.x-e.x;if(o=o||0){const t=s*s+a*a;if(0===t)return!0;const e=Math.sqrt(t);s/=e,a/=e}return!((i.x-t.x)*s+(i.y-t.y)*a-o=0;if(0===s)return 0;s!==i.length&&(n=!1)}return n?2:1}function vu(t,e){for(const i of t.projections){const n=gu(e,t.points[0],i.axis);if(i.projection[1]n[1])return 0}return 1}function xu(e,i){let n=0;const r=[0,0,0,0];for(let o=0;o=0&&n++;return n}class bu{constructor(e,i){this.points=e||new Array(8).fill([0,0,0]),this.planes=i||new Array(6).fill([0,0,0,0]),this.bounds=wu.fromPoints(this.points),this.projections=[],this.frustumEdges=[t._.sub([],this.points[2],this.points[3]),t._.sub([],this.points[0],this.points[3]),t._.sub([],this.points[4],this.points[0]),t._.sub([],this.points[5],this.points[1]),t._.sub([],this.points[6],this.points[2]),t._.sub([],this.points[7],this.points[3])];for(const t of this.frustumEdges){const e=[0,-t[2],t[1]],i=[t[2],0,-t[0]];this.projections.push({axis:e,projection:gu(this.points,this.points[0],e)}),this.projections.push({axis:i,projection:gu(this.points,this.points[0],i)})}}static fromInvProjectionMatrix(e,i,n,r){const o=Math.pow(2,n),s=[[-1,1,-1,1],[1,1,-1,1],[1,-1,-1,1],[-1,-1,-1,1],[-1,1,1,1],[1,1,1,1],[1,-1,1,1],[-1,-1,1,1]].map((n=>{const s=t.aA.transformMat4([],n,e),a=1/s[3]/i*o;return t.aA.mul(s,s,[a,a,r?1/s[3]:a,a])})),a=[[0,1,2],[6,5,4],[0,3,7],[2,1,5],[3,2,6],[0,4,5]].map((e=>{const i=t._.sub([],s[e[0]],s[e[1]]),n=t._.sub([],s[e[2]],s[e[1]]),r=t._.normalize([],t._.cross([],i,n)),o=-t._.dot(r,s[e[1]]);return r.concat(o)})),l=[];for(let t=0;ta[1]||a[0]>s[1])return 0}return 1}}class wu{static fromPoints(e){const i=[1/0,1/0,1/0],n=[-1/0,-1/0,-1/0];for(const r of e)t._.min(i,i,r),t._.max(n,n,r);return new wu(i,n)}static fromTileIdAndHeight(t,e,i){const n=1t.max[e]||t.min[e]>this.max[e])return!1;return!0}intersectsAabbXY(t){return!(this.min[0]>t.max[0]||t.min[0]>this.max[0]||this.min[1]>t.max[1]||t.min[1]>this.max[1])}encapsulate(t){for(let e=0;e1?null:function(t,e,i,n){const r=Math.sin(i);return t*(Math.sin((1-n)*i)/r)+e*(Math.sin(n*i)/r)}(t.a[e],t.b[e],t.angle,Xe(i,0,1))+t.center[e]}function $u(t){if(t.z0){for(const e of l)t._.min(u,u,e),t._.max(d,d,e);return new wu(u,d)}const h=[s[12]*o,s[13]*o,s[14]*o],p=a.getCenter(),f=Xe(e.center.lat,-Pd,Pd),m=Xe(p.lat,-Pd,Pd),_=Ed(e.center.lng),g=Md(f);let y=_-Ed(p.lng);const v=g-Md(m);y>.5?y-=1:yMath.abs(v))x=y>=0?1:3;else{x=v>=0?0:2;const e=[s[4]*o,s[5]*o,s[6]*o],i=-Math.sin(Ge(v>=0?a.getSouth():a.getNorth()))*ed;t._.scaleAndAdd(h,h,e,i)}const b=l[x],w=l[(x+1)%4],T=new Lu(b,w,h),S=[Pu(T,0)||b[0],Pu(T,1)||b[1],Pu(T,2)||b[2]],E=Hu(e.zoom);if(E>0){const r=function({x:t,y:e,z:i},n,r,o,s){const a=1/(1.5?h=-1:pMath.PI/2*1.01}const Xu=Ge(85),Ku=Math.cos(Xu),Ju=Math.sin(Xu),Qu=t.ad.create(),th=t=>{const e=[];return"map"===t.paint.get("circle-pitch-alignment")&&e.push("PITCH_WITH_MAP"),"map"===t.paint.get("circle-pitch-scale")&&e.push("SCALE_WITH_MAP"),e};function eh(e,i,n,r,o,s,a,l,c){if(s&&e.queryGeometry.isAboveHorizon)return!1;s&&(c*=e.pixelToTileUnitsFactor);const d=e.tileID.canonical,u=n.projection.upVectorScale(d,n.center.lat,n.worldSize).metersToTile;for(const h of i)for(const i of h){const h=i.add(l),p=o&&n.elevation?n.elevation.exaggeration()*o.getElevationAt(h.x,h.y,!0):0,f=n.projection.projectTilePoint(h.x,h.y,d);if(p>0){const t=n.projection.upVector(d,h.x,h.y);f.x+=t[0]*u*p,f.y+=t[1]*u*p,f.z+=t[2]*u*p}const m=s?h:ih(f.x,f.y,f.z,r),_=s?e.tilespaceRays.map((t=>oh(t,p))):e.queryGeometry.screenGeometry,g=t.aA.transformMat4([],[f.x,f.y,f.z,1],r);if(!a&&s?c*=g[3]/n.cameraToCenterDistance:a&&!s&&(c*=n.cameraToCenterDistance/g[3]),s){const t=Id((i.y/uo+d.y)/(1t.width||r.height>t.height||i.x>t.width-r.width||i.y>t.height-r.height)throw new RangeError("out of range source coordinates for image copy");if(r.width>e.width||r.height>e.height||n.x>e.width-r.width||n.y>e.height-r.height)throw new RangeError("out of range destination coordinates for image copy");const l=t.data,c=e.data,d=4===o&&a;for(let a=0;a{e[t.evaluationKey]=o;const s=t.expression.evaluate(e);s&&(r.data[i+n+0]=Math.floor(255*s.r/s.a),r.data[i+n+1]=Math.floor(255*s.g/s.a),r.data[i+n+2]=Math.floor(255*s.b/s.a),r.data[i+n+3]=Math.floor(255*s.a))};if(t.clips)for(let e=0,r=0;e80*i){a=1/0,l=1/0;let e=-1/0,n=-1/0;for(let o=i;oe&&(e=i),r>n&&(n=r)}c=Math.max(e-a,n-l),c=0!==c?32767/c:0}return Th(o,s,i,a,l,c,0),s}function bh(t,e,i,n,r){let o;if(r===function(t,e,i,n){let r=0;for(let o=e,s=i-n;o0)for(let r=e;r=e;r-=n)o=jh(r/n|0,t[r],t[r+1],o);return o&&Rh(o,o.next)&&(Vh(o),o=o.next),o}function wh(t,e){if(!t)return t;e||(e=t);let i,n=t;do{if(i=!1,n.steiner||!Rh(n,n.next)&&0!==zh(n.prev,n,n.next))n=n.next;else{if(Vh(n),n=e=n.prev,n===n.next)break;i=!0}}while(i||n!==e);return e}function Th(t,e,i,n,r,o,s){if(!t)return;!s&&o&&function(t,e,i,n){let r=t;do{0===r.z&&(r.z=Ph(r.x,r.y,e,i,n)),r.prevZ=r.prev,r.nextZ=r.next,r=r.next}while(r!==t);r.prevZ.nextZ=null,r.prevZ=null,function(t){let e,i=1;do{let n,r=t;t=null;let o=null;for(e=0;r;){e++;let s=r,a=0;for(let t=0;t0||l>0&&s;)0!==a&&(0===l||!s||r.z1)}(r)}(t,n,r,o);let a=t;for(;t.prev!==t.next;){const l=t.prev,c=t.next;if(o?Eh(t,n,r,o):Sh(t))e.push(l.i,t.i,c.i),Vh(t),t=c.next,a=c.next;else if((t=c)===a){s?1===s?Th(t=Mh(wh(t),e),e,i,n,r,o,2):2===s&&Ch(t,e,i,n,r,o):Th(wh(t),e,i,n,r,o,1);break}}}function Sh(t){const e=t.prev,i=t,n=t.next;if(zh(e,i,n)>=0)return!1;const r=e.x,o=i.x,s=n.x,a=e.y,l=i.y,c=n.y,d=ro?r>s?r:s:o>s?o:s,p=a>l?a>c?a:c:l>c?l:c;let f=n.next;for(;f!==e;){if(f.x>=d&&f.x=u&&f.y=0)return!1;f=f.next}return!0}function Eh(t,e,i,n){const r=t.prev,o=t,s=t.next;if(zh(r,o,s)>=0)return!1;const a=r.x,l=o.x,c=s.x,d=r.y,u=o.y,h=s.y,p=al?a>c?a:c:l>c?l:c,_=d>u?d>h?d:h:u>h?u:h,g=Ph(p,f,e,i,n),y=Ph(m,_,e,i,n);let v=t.prevZ,x=t.nextZ;for(;v&&v.z>=g&&x&&x.z=p&&v.x=f&&v.y=0)return!1;if(v=v.prevZ,x.x>=p&&x.x=f&&x.y=0)return!1;x=x.nextZ}for(;v&&v.z>=g;){if(v.x>=p&&v.x=f&&v.y=0)return!1;v=v.prevZ}for(;x&&x.z=p&&x.x=f&&x.y=0)return!1;x=x.nextZ}return!0}function Mh(t,e){let i=t;do{const n=i.prev,r=i.next.next;!Rh(n,r)&&Oh(n,i,i.next,r)&&Nh(n,r)&&Nh(r,n)&&(e.push(n.i,i.i,r.i),Vh(i),Vh(i.next),i=t=r),i=i.next}while(i!==t);return wh(i)}function Ch(t,e,i,n,r,o){let s=t;do{let t=s.next.next;for(;t!==s.prev;){if(s.i!==t.i&&Dh(s,t)){let a=Uh(s,t);return s=wh(s,s.next),a=wh(a,a.next),Th(s,e,i,n,r,o,0),void Th(a,e,i,n,r,o,0)}t=t.next}s=s.next}while(s!==t)}function Ah(t,e){return t.x-e.x}function Ih(t,e){const i=function(t,e){let i=e;const n=t.x,r=t.y;let o,s=-1/0;do{if(r=i.next.y&&i.next.y!==i.y){const t=i.x+(r-i.y)*(i.next.x-i.x)/(i.next.y-i.y);if(ts&&(s=t,o=i.x=i.x&&i.x>=l&&n!==i.x&&kh(ro.x||i.x===o.x&&Lh(o,i)))&&(o=i,d=e)}i=i.next}while(i!==a);return o}(t,e);if(!i)return e;const n=Uh(i,t);return wh(n,n.next),wh(i,i.next)}function Lh(t,e){return zh(t.prev,t,e.prev)=(t-s)*(o-a)&&(t-s)*(n-a)>=(i-s)*(e-a)&&(i-s)*(o-a)>=(r-s)*(n-a)}function Dh(t,e){return t.next.i!==e.i&&t.prev.i!==e.i&&!function(t,e){let i=t;do{if(i.i!==t.i&&i.next.i!==t.i&&i.i!==e.i&&i.next.i!==e.i&&Oh(i,i.next,t,e))return!0;i=i.next}while(i!==t);return!1}(t,e)&&(Nh(t,e)&&Nh(e,t)&&function(t,e){let i=t,n=!1;const r=(t.x+e.x)/2,o=(t.y+e.y)/2;do{i.y>o!=i.next.y>o&&i.next.y!==i.y&&r0&&zh(e.prev,e,e.next)>0)}function zh(t,e,i){return(e.y-t.y)*(i.x-e.x)-(e.x-t.x)*(i.y-e.y)}function Rh(t,e){return t.x===e.x&&t.y===e.y}function Oh(t,e,i,n){const r=Fh(zh(t,e,i)),o=Fh(zh(t,e,n)),s=Fh(zh(i,n,t)),a=Fh(zh(i,n,e));return r!==o&&s!==a||!(0!==r||!Bh(t,i,e))||!(0!==o||!Bh(t,n,e))||!(0!==s||!Bh(i,t,n))||!(0!==a||!Bh(i,e,n))}function Bh(t,e,i){return e.x=Math.min(t.x,i.x)&&e.y=Math.min(t.y,i.y)}function Fh(t){return t>0?1:t=0&&zh(t,t.prev,e)>=0:zh(t,e,t.prev)1)for(let t=0;tt.fqid)),this.index=t.index,this.hasPattern=!1,this.patternFeatures=[],this.layoutVertexArray=new $l,this.indexArray=new Kl,this.indexArray2=new ql,this.programConfigurations=new Yc(t.layers,{zoom:t.zoom,lut:t.lut}),this.segments=new wc,this.segments2=new wc,this.stateDependentLayerIds=this.layers.filter((t=>t.isStateDependent())).map((t=>t.id)),this.projection=t.projection}updateFootprints(t,e){}populate(t,e,i,n){this.hasPattern=Hh("fill",this.layers,e);const r=this.layers[0].layout.get("fill-sort-key"),o=[];for(const{feature:s,id:a,index:l,sourceLayerIndex:c}of t){const t=this.layers[0]._featureFilter.needGeometry,d=Zd(s,t);if(!this.layers[0]._featureFilter.filter(new Ha(this.zoom),d,i))continue;const u=r?r.evaluate(d,{},i,e.availableImages):void 0,h={id:a,properties:s.properties,type:s.type,sourceLayerIndex:c,index:l,geometry:t?d.geometry:Gd(s,i,n),patterns:{},sortKey:u};o.push(h)}r&&o.sort(((t,e)=>t.sortKey-e.sortKey));for(const n of o){const{geometry:r,index:o,sourceLayerIndex:s}=n;if(this.hasPattern){const t=Wh("fill",this.layers,n,this.zoom,e);this.patternFeatures.push(t)}else this.addFeature(n,r,o,i,{},e.availableImages,e.brightness);e.featureIndex.insert(t[o].feature,r,o,s,this.index)}}update(t,e,i,n,r){const o=0!==Object.keys(t).length;o&&!this.stateDependentLayers.length||this.programConfigurations.updatePaintArrays(t,e,o?this.stateDependentLayers:this.layers,i,n,r)}addFeatures(t,e,i,n,r,o){for(const t of this.patternFeatures)this.addFeature(t,t.geometry,t.index,e,i,n,o)}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(t){this.uploaded||(this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,vh),this.indexBuffer=t.createIndexBuffer(this.indexArray),this.indexBuffer2=t.createIndexBuffer(this.indexArray2)),this.programConfigurations.upload(t),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.indexBuffer2.destroy(),this.programConfigurations.destroy(),this.segments.destroy(),this.segments2.destroy())}addFeature(t,e,i,n,r,o=[],s){for(const t of Zh(e,500)){let e=0;for(const i of t)e+=i.length;const i=this.segments.prepareSegment(e,this.layoutVertexArray,this.indexArray),n=i.vertexLength,r=[],o=[];for(const e of t){if(0===e.length)continue;e!==t[0]&&o.push(r.length/2);const i=this.segments2.prepareSegment(e.length,this.layoutVertexArray,this.indexArray2),n=i.vertexLength;this.layoutVertexArray.emplaceBack(e[0].x,e[0].y),this.indexArray2.emplaceBack(n+e.length-1,n),r.push(e[0].x),r.push(e[0].y);for(let t=1;tt.cellIdx-e.cellIdx||t.triIdx-e.triIdx));let c=0;for(;cthis.max.x||this.min.x>t.x||t.y>this.max.y||this.min.y>t.y)return;const i=Qh(t.x-this.min.x,this.xScale,this.cellsX),n=Qh(t.y-this.min.y,this.yScale,this.cellsY),r=this.cells[n*this.cellsX+i];if(r){this._lazyInitLookup();for(let t=0;tthis.max.x||this.min.x>e.x)return;if(t.y>this.max.y||this.min.y>e.y)return;this._lazyInitLookup();const n=Qh(t.x-this.min.x,this.xScale,this.cellsX),r=Qh(e.x-this.min.x,this.xScale,this.cellsX),o=Qh(t.y-this.min.y,this.yScale,this.cellsY),s=Qh(e.y-this.min.y,this.yScale,this.cellsY);for(let t=o;tt.fqid)),this.index=t.index,this.hasPattern=!1,this.stateDependentLayerIds=this.layers.filter((t=>t.isStateDependent())).map((t=>t.id)),this.footprints=[]}updateFootprints(t,e){for(const i of this.footprints)e.push({footprint:i,id:t})}populate(t,e,i,n){const r=[];for(const{feature:e,id:o,index:s,sourceLayerIndex:a}of t){const t=this.layers[0]._featureFilter.needGeometry,l=Zd(e,t);if(!this.layers[0]._featureFilter.filter(new Ha(this.zoom),l,i))continue;const c={id:o,properties:e.properties,type:e.type,sourceLayerIndex:a,index:s,geometry:t?l.geometry:Gd(e,i,n),patterns:{}};r.push(c)}for(const n of r){const{geometry:r,index:o,sourceLayerIndex:s}=n;this.addFeature(n,r,o,i,{},e.availableImages,e.brightness),e.featureIndex.insert(t[o].feature,r,o,s,this.index)}}isEmpty(){return 0===this.footprints.length}uploadPending(){return!1}upload(t){}update(t,e,i,n,r){}destroy(){}addFeature(t,e,i,n,r,o=[],s){for(const t of Zh(e,2)){const e=[],i=[],n=[],r=new Ue(1/0,1/0),o=new Ue(-1/0,-1/0);for(const s of t)if(0!==s.length){s!==t[0]&&n.push(i.length/2);for(let t=0;t>3}if(r--,1===n||2===n)o+=t.readSVarint(),s+=t.readSVarint(),1===n&&(e&&a.push(e),e=[]),e.push(new dp(o,s));else{if(7!==n)throw new Error("unknown command "+n);e&&e.push(e[0].clone())}}return e&&a.push(e),a},hp.prototype.bbox=function(){var t=this._pbf;t.pos=this._geometry;for(var e=t.readVarint()+t.pos,i=1,n=0,r=0,o=0,s=1/0,a=-1/0,l=1/0,c=-1/0;t.pos>3}if(n--,1===i||2===i)(r+=t.readSVarint())a&&(a=r),(o+=t.readSVarint())c&&(c=o);else if(7!==i)throw new Error("unknown command "+i)}return[s,l,a,c]},hp.prototype.toGeoJSON=function(t,e,i){var n,r,o=this.extent*Math.pow(2,i),s=this.extent*t,a=this.extent*e,l=this.loadGeometry(),c=hp.types[this.type];function d(t){for(var e=0;e>3;e=1===n?t.readString():2===n?t.readFloat():3===n?t.readDouble():4===n?t.readVarint64():5===n?t.readVarint():6===n?t.readSVarint():7===n?t.readBoolean():null}return e}(i))}gp.prototype.feature=function(t){if(t=this._features.length)throw new Error("feature index out of bounds");this._pbf.pos=this._features[t];var e=this._pbf.readVarint()+this._pbf.pos;return new mp(this._pbf,e,this.extent,this._keys,this._values)};var vp=_p;function xp(t,e,i){if(3===t){var n=new vp(i,i.readVarint()+i.pos);n.length&&(e[n.name]=n)}}var bp=cp.VectorTile=function(t,e){this.layers=t.readFields(xp,{},e)},wp=cp.VectorTileFeature=up;cp.VectorTileLayer=_p;class Tp extends Ue{constructor(t,e,i){super(t,e),this.z=i}}class Sp extends Tp{constructor(t,e,i,n){super(t,e,i),this.w=n}}function Ep(t,e,i,n){const r=[],o=0===n?(t,e,i,n,r,o)=>{t.push(new Ue(o,i+(o-e)/(n-e)*(r-i)))}:(t,e,i,n,r,o)=>{t.push(new Ue(e+(o-i)/(r-i)*(n-e),o))};for(const s of t){const t=[];for(const r of s){if(r.lengthe&&o(s,a,l,c,d,e):u>i?h=e&&o(s,a,l,c,d,e),h>i&&u=e&&l=s[i]&&(n=e,s=t),n[i]r&&Mp(n,s,i,r),n[i]o&&Mp(s,n,i,o)}}function Ap(t,e){return t.x-e.x||t.y-e.y}function Ip(t,e){return 0===Ap(t.min,e.min)&&0===Ap(t.max,e.max)}function Lp(t,e){return!(t.min.x>e.max.x||t.max.xe.max.y||t.max.ynew Ue((t.x+o.x*uo)*a-s.x*uo,(t.y+o.y*uo)*a-s.y*uo)))}return Dp(i,r,t.indices,0,t.indices.length,0,0)}function Rp(t,e,i,n){const r=Math.pow(2,n.z-i.z);return new Ue((t+i.x*uo)*r-n.x*uo,(e+i.y*uo)*r-n.y*uo)}function Op(t,e){const i=[];e.footprint.grid.queryPoint(t,i);const n=e.footprint.indices,r=e.footprint.vertices;for(let e=0;ee[s])return null}else{const a=1/n[s];let l=(t[s]-i[s])*a,c=(e[s]-i[s])*a;if(l>c){const t=l;l=c,c=t}if(l>r&&(r=l),co)return null}return r}function Np(t,e,i,n,r,o,s,a,l,c,d){const u=n-t,h=r-e,p=o-i,f=s-t,m=a-e,_=l-i,g=d[1]*_-d[2]*m,y=d[2]*f-d[0]*_,v=d[0]*m-d[1]*f,x=u*g+h*y+p*v;if(Math.abs(x)1)return null;const M=T*p-S*h,C=S*u-w*p,A=w*h-T*u,I=(d[0]*M+d[1]*C+d[2]*A)*b;return I1?null:(f*M+m*C+_*A)*b}function Up(t,e,i){return(t-e)/(i-e)}function jp(t,e,i,n,r,o,s,a,l){const c=1{const o=n?1:0,s=(t+1)*i-o,a=e*i,l=(e+1)*i-o;r[0]=t*i,r[1]=a,r[2]=s,r[3]=l};let s=new Bp(n);const a=[];for(let e=0;e=1;n/=2){const t=i[i.length-1];s=new Bp(n);for(let e=0;e0;){const{idx:l,t:f,nodex:m,nodey:_,depth:g}=p.pop();if(this.leaves[l]){jp(m,_,g,e,i,n,r,u,h);const l=1=e[2])return f}continue}let y=0;for(let t=0;t=c[d[n]]&&(d.splice(n,0,t),i=!0);i||(d[y]=t),y++}}for(let t=0;t=this.dim+1||e=this.dim+1)throw new RangeError("out of range source coordinates for DEM data");return(e+1)*this.stride+(t+1)}static pack(t,e){const i=[0,0,0,0],n=Yp.getUnpackVector(e);let r=Math.floor((t+n[3])/n[2]);return i[2]=r%256,r=Math.floor(r/256),i[1]=r%256,r=Math.floor(r/256),i[0]=r,i}getPixels(){return new hh({width:this.stride,height:this.stride},this.pixels)}backfillBorder(t,e,i){if(this.dim!==t.dim)throw new Error("dem dimension mismatch");let n=e*this.dim,r=e*this.dim+this.dim,o=i*this.dim,s=i*this.dim+this.dim;switch(e){case-1:n=r-1;break;case 1:r=n+1}switch(i){case-1:o=s-1;break;case 1:s=o+1}const a=-e*this.dim,l=-i*this.dim;for(let e=o;et.max.x&&(t.max.x=e.x,n=!0),e.yt.max.y&&(t.max.y=e.y,n=!0),((0===e.x||e.x===uo)&&e.x===i.x)!=((0===e.y||e.y===uo)&&e.y===i.y)&&this.processBorderOverlap(e,i),n&&this.checkBorderIntersection(e,i)}checkBorderIntersection(t,e){e.xuo!=t.x>uo&&this.addBorderIntersection(1,Vn(e.y,t.y,(uo-e.x)/(t.x-e.x))),e.yuo!=t.y>uo&&this.addBorderIntersection(3,Vn(e.x,t.x,(uo-e.y)/(t.y-e.y)))}addBorderIntersection(t,e){this.borders||(this.borders=[[Number.MAX_VALUE,-Number.MAX_VALUE],[Number.MAX_VALUE,-Number.MAX_VALUE],[Number.MAX_VALUE,-Number.MAX_VALUE],[Number.MAX_VALUE,-Number.MAX_VALUE]]);const i=this.borders[t];ei[1]&&(i[1]=e)}processBorderOverlap(t,e){if(t.x===e.x){if(t.y===e.y)return;const i=0===t.x?0:1;this.addBorderIntersection(i,e.y),this.addBorderIntersection(i,t.y)}else{const i=0===t.y?2:3;this.addBorderIntersection(i,e.x),this.addBorderIntersection(i,t.x)}}centroid(){return 0===this.accCount?new Ue(0,0):new Ue(Math.floor(Math.max(0,this.acc.x)/this.accCount),Math.floor(Math.max(0,this.acc.y)/this.accCount))}intersectsCount(){return this.borders?this.borders.reduce(((t,e)=>t+ +(e[0]!==Number.MAX_VALUE)),0):0}}function hf(t,e){const i=t.add(e)._unit(),n=Xe(t.x*i.x+t.y*i.y,-1,1);var r,o,s;return r=Math.acos(n),Math.min(4,Math.max(-4,Math.tan(r)))/4*nf*((o=t).x*(s=e).y-o.y*s.xt.xt.x>uo,t=>t.yt.y>uo];function ff(t,e,i,n){const r=[4];if(0===n)return r;i._mult(n);const o=t.sub(i),s=e.sub(i),a=[t,e,o,s];for(let t=0;ttf.includes(t))),this._segments=new wc,this.hiddenByLandmarkVertexArray=new lc,this._segmentToGroundQuads={},this._segmentToGroundQuads[0]=[],this._segmentToRegionTriCounts={},this._segmentToRegionTriCounts[0]=[0,0,0,0,0],this.regionSegments={},this.regionSegments[4]=new wc}getDefaultSegment(){return this.regionSegments[4]}hasData(){return 0!==this.vertexArray.length}addData(t,e,i,n=!1){const r=t.length;if(r>2){let o=Math.max(0,this._segments.get().length-1);const s=this._segments._prepareSegment(4*r,this.vertexArray.length,2*this._segmentToGroundQuads[o].length);let a;o!==this._segments.get().length-1&&(o++,this._segmentToGroundQuads[o]=[],this._segmentToRegionTriCounts[o]=[0,0,0,0,0]);{const e=t[0],i=t[1];a=hf(e.sub(t[r-1])._perp()._unit(),i.sub(e)._perp()._unit())}for(let l=0;lt.region-e.region));for(let i=0;it+e),0);let o=0;for(let t=0;t0?this.hiddenByLandmarkVertexBuffer=t.createVertexBuffer(this.hiddenByLandmarkVertexArray,sp.members,!0):this.hiddenByLandmarkVertexBuffer&&this.hiddenByLandmarkVertexBuffer.updateData(this.hiddenByLandmarkVertexArray),this._needsHiddenByLandmarkUpdate=!1)}destroy(){if(this.vertexBuffer){this.vertexBuffer.destroy(),this.indexBuffer.destroy(),this.hiddenByLandmarkVertexBuffer&&this.hiddenByLandmarkVertexBuffer.destroy(),this._segments&&this._segments.destroy(),this.programConfigurations.destroy();for(let t=0;tt.fqid)),this.index=t.index,this.hasPattern=!1,this.edgeRadius=0,this.projection=t.projection,this.activeReplacements=[],this.replacementUpdateTime=0,this.centroidData=[],this.footprintIndices=new Kl,this.footprintVertices=new $l,this.footprintSegments=[],this.layoutVertexArray=new Dl,this.centroidVertexArray=new vc,this.indexArray=new Kl,this.programConfigurations=new Yc(t.layers,{zoom:t.zoom,lut:t.lut},(t=>Qp.includes(t))),this.segments=new wc,this.stateDependentLayerIds=this.layers.filter((t=>t.isStateDependent())).map((t=>t.id)),this.groundEffect=new mf(t),this.maxHeight=0,this.partLookup={},this.triangleSubSegments=[],this.polygonSegments=[]}updateFootprints(t,e){}populate(t,e,i,n){this.features=[],this.hasPattern=Hh("fill-extrusion",this.layers,e),this.featuresOnBorder=[],this.borderFeatureIndices=[[],[],[],[]],this.borderDoneWithNeighborZ=[-1,-1,-1,-1],this.tileToMeter=zd(i),this.edgeRadius=this.layers[0].layout.get("fill-extrusion-edge-radius")/this.tileToMeter;for(const{feature:r,id:o,index:s,sourceLayerIndex:a}of t){const t=this.layers[0]._featureFilter.needGeometry,l=Zd(r,t);if(!this.layers[0]._featureFilter.filter(new Ha(this.zoom),l,i))continue;const c={id:o,sourceLayerIndex:a,index:s,geometry:t?l.geometry:Gd(r,i,n),properties:r.properties,type:r.type,patterns:{}},d=this.layoutVertexArray.length;this.hasPattern?this.features.push(Wh("fill-extrusion",this.layers,c,this.zoom,e)):this.addFeature(c,c.geometry,s,i,{},e.availableImages,n,e.brightness),e.featureIndex.insert(r,c.geometry,s,a,this.index,d)}this.sortBorders(),"mercator"===this.projection.name&&this.splitToSubtiles(),this.groundEffect.prepareBorderSegments(),this.polygonSegments.length=0}addFeatures(t,e,i,n,r,o){for(const t of this.features){const{geometry:s}=t;this.addFeature(t,s,t.index,e,i,n,r,o)}this.sortBorders(),"mercator"===this.projection.name&&this.splitToSubtiles()}update(t,e,i,n,r){const o=0!==Object.keys(t).length;if(o&&!this.stateDependentLayers.length)return;const s=o?this.stateDependentLayers:this.layers;this.programConfigurations.updatePaintArrays(t,e,s,i,n,r),this.groundEffect.update(t,e,s,i,n,r)}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload||this.groundEffect.programConfigurations.needsUpload}upload(t){this.uploaded||(this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,lp),this.indexBuffer=t.createIndexBuffer(this.indexArray),this.layoutVertexExtArray&&(this.layoutVertexExtBuffer=t.createVertexBuffer(this.layoutVertexExtArray,ap.members,!0)),this.groundEffect.upload(t)),this.groundEffect.uploadPaintProperties(t),this.programConfigurations.upload(t),this.uploaded=!0}uploadCentroid(t){this.groundEffect.uploadHiddenByLandmark(t),this.needsCentroidUpdate&&(!this.centroidVertexBuffer&&this.centroidVertexArray.length>0?this.centroidVertexBuffer=t.createVertexBuffer(this.centroidVertexArray,op.members,!0):this.centroidVertexBuffer&&this.centroidVertexBuffer.updateData(this.centroidVertexArray),this.needsCentroidUpdate=!1)}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.centroidVertexBuffer&&this.centroidVertexBuffer.destroy(),this.layoutVertexExtBuffer&&this.layoutVertexExtBuffer.destroy(),this.groundEffect.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy())}addFeature(t,e,i,n,r,o,s,a){const l=this.layers[0].paint.get("fill-extrusion-flood-light-ground-radius").evaluate(t,{})/this.tileToMeter,c=[new Ue(0,0),new Ue(uo,uo)],d=s.projection,u="globe"===d.name,h="Polygon"===Jp[t.type],p=new uf;p.centroidDataIndex=this.centroidData.length;const f=new df,m=this.layers[0].paint.get("fill-extrusion-base").evaluate(t,{},n)=0;t--){const e=g[t];(0===e.length||(y=e[0]).every((t=>t.xt.x>=uo))||y.every((t=>t.yt.y>=uo)))&&g.splice(t,1)}var y;let v;if(u)v=Ef(g,c,n);else{v=[];for(const t of g)v.push({polygon:t,bounds:c})}const x=h?this.edgeRadius:0,b=x>0&&this.zoom{if(0===t.length)return!1;const i=t[t.length-1];return e.x===i.x&&e.y===i.y};for(const{polygon:t,bounds:e}of v){let i=0,r=0;for(const e of t)h&&!e[0].equals(e[e.length-1])&&e.push(e[0]),r+=h?e.length-1:e.length;const o=this.segments.prepareSegment((h?5:4)*r,this.layoutVertexArray,this.indexArray);f.footprintSegIdx4&&wf(s[s.length-2],s[0],s[1]),c=x?yf(s[s.length-2],s[0],s[1],x):0;const _=[];let g,y,v;y=s[1].sub(s[0])._perp()._unit();let b=!0;for(let t=1,r=0;t0?1:0,C=l.dist(h);if(r+C>32768&&(r=0),x){v=T.sub(h)._perp()._unit();let t=vf(l,h,T,gf(y,v),x);isNaN(t)&&(t=0);const e=h.sub(l)._unit();l=l.add(e.mult(c))._round(),h=h.add(e.mult(-t))._round(),c=t,y=v,m&&this.zoom>=17&&(w(_,l)||_.push(l),w(_,h)||_.push(h))}const A=o.vertexLength,I=s.length>4&&wf(l,h,T);let L=Tf(r,a,b);if(sf(this.layoutVertexArray,l.x,l.y,E,M,0,0,L),sf(this.layoutVertexArray,l.x,l.y,E,M,0,1,L),r+=C,L=Tf(r,I,!b),a=I,sf(this.layoutVertexArray,h.x,h.y,E,M,0,0,L),sf(this.layoutVertexArray,h.x,h.y,E,M,0,1,L),o.vertexLength+=4,this.indexArray.emplaceBack(A+0,A+1,A+2),this.indexArray.emplaceBack(A+1,A+3,A+2),o.primitiveLength+=2,x){const n=i+(1===t?s.length-2:t-2),r=1===t?i:n+1;if(this.indexArray.emplaceBack(A+1,n,A+3),this.indexArray.emplaceBack(n,r,A+3),o.primitiveLength+=2,void 0===g&&(g=A),!xf(T,s[t],e)){const e=t===s.length-1?g:o.vertexLength;this.indexArray.emplaceBack(A+2,A+3,e),this.indexArray.emplaceBack(A+3,e+1,e),this.indexArray.emplaceBack(A+3,r,e+1),o.primitiveLength+=3}b=!b}if(u){const t=this.layoutVertexExtArray,e=d.projectTilePoint(l.x,l.y,n),i=d.projectTilePoint(h.x,h.y,n),r=d.upVector(n,l.x,l.y),o=d.upVector(n,h.x,h.y);lf(t,e,r),lf(t,e,r),lf(t,i,o),lf(t,i,o)}}h&&(i+=s.length-1),m&&x&&this.zoom>=17&&(0!==_.length&&w(_,_[0])&&_.pop(),this.groundEffect.addData(_,e,l,x>0))}this.footprintSegments.push(a),s.triangleCount=this.indexArray.length-s.triangleArrayOffset,this.polygonSegments.push(s),++f.footprintSegLen,++f.polygonSegLen}if(f.vertexCount=this.layoutVertexArray.length-f.vertexArrayOffset,f.groundVertexCount=this.groundEffect.vertexArray.length-f.groundVertexArrayOffset,0!==f.vertexCount){if(f.centroidXY=p.borders?rf:this.encodeCentroid(p,f),this.centroidData.push(f),p.borders){this.featuresOnBorder.push(p);const t=this.featuresOnBorder.length-1;for(let e=0;ethis.featuresOnBorder[e].borders[t][0]-this.featuresOnBorder[i].borders[t][0]))}splitToSubtiles(){const t=[];for(let e=0;euo),r=2*n+(+(i.min.x+i.max.x>uo)^n);for(let n=0;nt.triangleSegmentIdx===e.triangleSegmentIdx?t.subtile-e.subtile:t.triangleSegmentIdx-e.triangleSegmentIdx));let i=0,n=0,r=0;for(const e of t){if(e.triangleSegmentIdx!==i)break;r++}const o=t.length;for(;n!==t.length;){i=t[n].triangleSegmentIdx;let s=0,a=n,l=n;for(let e=a;e0&&this.triangleSubSegments.push({segment:d,min:o,max:c}),a=l;for(let e=a;e[t[0]*(1-i[0])+e[0]*i[0],t[1]*(1-i[1])+e[1]*i[1]],h=[],p=[];for(const t of this.triangleSubSegments){h[0]=t.min.x/uo,h[1]=t.min.y/uo,p[0]=t.max.x/uo,p[1]=t.max.y/uo;const e=u(l,c,h),o=u(l,c,p);if(0===new wu([e[0],e[1],n],[o[0],o[1],r]).intersectsPrecise(i)){a&&(d.segments.push(a),a=void 0);continue}const s=t.segment;a&&a.vertexOffset!==s.vertexOffset&&(d.segments.push(a),a=void 0),a?(a.vertexLength+=s.vertexLength,a.primitiveLength+=s.primitiveLength):a={vertexOffset:s.vertexOffset,primitiveLength:s.primitiveLength,vertexLength:s.vertexLength,primitiveOffset:s.primitiveOffset,sortKey:void 0,vaos:{}}}return a&&d.segments.push(a),d}encodeCentroid(t,e){const i=t.centroid(),n=e.span(),r=Math.min(7,Math.round(n.x*this.tileToMeter/10)),o=Math.min(7,Math.round(n.y*this.tileToMeter/10));return new Ue(Xe(i.x,1,uo-1)i.max.x||i.min.x>e.max.x||e.min.y>i.max.y||i.min.y>e.max.y))for(let o=0;oe!=l>e&&to.max.x||o.min.x>t||e>o.max.y||o.min.y>e||this.footprintContainsPoint(t,e,o)&&o&&o.height>i&&(i=o.height,this.partLookup[r]=o,n=!!(o.flags&of));if(i!==Number.NEGATIVE_INFINITY)return{height:i,hidden:n};this.partLookup[r]=void 0}}function gf(t,e){const i=t.add(e)._unit();return t.x*i.x+t.y*i.y}function yf(t,e,i,n){const r=e.sub(t)._perp()._unit(),o=i.sub(e)._perp()._unit();return vf(t,e,i,gf(r,o),n)}function vf(t,e,i,n,r){const o=Math.sqrt(1-n*n);return Math.min(t.dist(e)/3,e.dist(i)/3,r*o/n)}function xf(t,e,i){return t.xi[1].x&&e.x>i[1].x||t.yi[1].y&&e.y>i[1].y}function bf(t,e){return t.xe[1].x||t.ye[1].y}function wf(t,e,i){if(t.x=uo||e.x=uo||i.x=uo)return!1;const n=i.sub(e),r=n.perp(),o=t.sub(e);return(n.x*o.x+n.y*o.y)/Math.sqrt((n.x*n.x+n.y*n.y)*(o.x*o.x+o.y*o.y))>-.866&&r.x*o.x+r.y*o.y{for(const i of t)s.push({polygon:i,bounds:e})},l=Math.ceil(Math.log2(i)),c=Math.ceil(Math.log2(n)),d=l-c,u=[];for(let t=0;t0?0:1);for(let t=0;te+1?p.push({polygons:h,bounds:t,depth:e+1}):a(h,t)}if(f.length){const t=[new Ue(0===i?d:n.x,1===i?d:n.y),s];u.length>e+1?p.push({polygons:f,bounds:t,depth:e+1}):a(f,t)}}return s}(t,e,Math.ceil((o-r)/11.25),Math.ceil((s-a)/11.25),1,((t,e,r)=>{if(0===t)return.5*(e+r);{const t=Id((i.y+e/uo)/n);return(Md(.5*(Id((i.y+r/uo)/n)+t))*n-i.y)*uo}}))}function Mf(t,e,i,n,r,o){const s=Math.pow(2,n.z-r.z);for(let a=0;a1&&(s=t[++o]);const l=Math.abs(a-s.left),c=Math.abs(a-s.right),d=Math.min(l,c);let u;const h=e/i*(n+1);if(s.isDash){const t=n-Math.abs(h);u=Math.sqrt(d*d+t*t)}else u=n-Math.sqrt(d*d+h*h);this.image.data[r+a]=Math.max(0,Math.min(255,u+128))}}}addRegularDash(t,e){for(let e=t.length-1;e>=0;--e){const i=t[e],n=t[e+1];i.zeroLength?t.splice(e,1):n&&n.isDash===i.isDash&&(n.left=i.left,t.splice(e,1))}const i=t[0],n=t[t.length-1];i.isDash===n.isDash&&(i.left=n.left-this.width,n.right=i.right+this.width);const r=this.width*this.nextRow;let o=0,s=t[o];for(let i=0;i1&&(s=t[++o]);const n=Math.abs(i-s.left),a=Math.abs(i-s.right),l=Math.min(n,a);this.image.data[r+i]=Math.max(0,Math.min(255,(s.isDash?l:-l)+e+128))}}addDash(t,e){const i=this.getKey(t,e);if(this.positions[i])return this.positions[i];const n="round"===e,r=n?7:0,o=2*r+1;if(this.nextRow+o>this.height)return pi("LineAtlas out of space"),null;0===t.length&&t.push(1);let s=0;for(let e=0;et.fqid)),this.index=t.index,this.projection=t.projection,this.hasPattern=!1,this.hasZOffset=!1,this.patternFeatures=[],this.lineClipsArray=[],this.gradients={},this.layers.forEach((t=>{this.gradients[t.id]={}})),this.layoutVertexArray=new Rl,this.layoutVertexArray2=new Ol,this.patternVertexArray=new Bl,this.indexArray=new Kl,this.programConfigurations=new Yc(t.layers,{zoom:t.zoom,lut:t.lut}),this.segments=new wc,this.maxLineLength=0,this.zOffsetVertexArray=new Zl,this.stateDependentLayerIds=this.layers.filter((t=>t.isStateDependent())).map((t=>t.id)),this.tessellationStep=t.tessellationStep?t.tessellationStep:uo/64}updateFootprints(t,e){}populate(t,e,i,n){this.hasPattern=Hh("line",this.layers,e);const r=this.layers[0].layout.get("line-sort-key"),o=this.layers[0].layout.get("line-z-offset");this.hasZOffset=!o.isConstant()||!!o.constantOr(0);const s=[];for(const{feature:e,id:o,index:a,sourceLayerIndex:l}of t){const t=this.layers[0]._featureFilter.needGeometry,c=Zd(e,t);if(!this.layers[0]._featureFilter.filter(new Ha(this.zoom),c,i))continue;const d=r?r.evaluate(c,{},i):void 0,u={id:o,properties:e.properties,type:e.type,sourceLayerIndex:l,index:a,geometry:t?c.geometry:Gd(e,i,n),patterns:{},sortKey:d};s.push(u)}r&&s.sort(((t,e)=>t.sortKey-e.sortKey));const{lineAtlas:a,featureIndex:l}=e,c=this.addConstantDashes(a);for(const n of s){const{geometry:r,index:o,sourceLayerIndex:s}=n;if(c&&this.addFeatureDashes(n,a),this.hasPattern){const t=Wh("line",this.layers,n,this.zoom,e);this.patternFeatures.push(t)}else this.addFeature(n,r,o,i,a.positions,e.availableImages,e.brightness);l.insert(t[o].feature,r,o,s,this.index)}}addConstantDashes(t){let e=!1;for(const i of this.layers){const n=i.paint.get("line-dasharray").value,r=i.layout.get("line-cap").value;if("constant"!==n.kind||"constant"!==r.kind)e=!0;else{const e=r.value,i=n.value;if(!i)continue;t.addDash(i,e)}}return e}addFeatureDashes(t,e){const i=this.zoom;for(const n of this.layers){const r=n.paint.get("line-dasharray").value,o=n.layout.get("line-cap").value;if("constant"===r.kind&&"constant"===o.kind)continue;let s,a;if("constant"===r.kind){if(s=r.value,!s)continue}else s=r.evaluate({zoom:i},t);a="constant"===o.kind?o.value:o.evaluate({zoom:i},t),e.addDash(s,a),t.patterns[n.id]=e.getKey(s,a)}}update(t,e,i,n,r){const o=0!==Object.keys(t).length;o&&!this.stateDependentLayers.length||this.programConfigurations.updatePaintArrays(t,e,o?this.stateDependentLayers:this.layers,i,n,r)}addFeatures(t,e,i,n,r,o){for(const t of this.patternFeatures)this.addFeature(t,t.geometry,t.index,e,i,n,o)}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(t){this.uploaded||(0!==this.layoutVertexArray2.length&&(this.layoutVertexBuffer2=t.createVertexBuffer(this.layoutVertexArray2,zf)),0!==this.patternVertexArray.length&&(this.patternVertexBuffer=t.createVertexBuffer(this.patternVertexArray,Of)),!this.zOffsetVertexBuffer&&this.zOffsetVertexArray.length>0&&(this.zOffsetVertexBuffer=t.createVertexBuffer(this.zOffsetVertexArray,jf.members,!0)),this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,kf),this.indexBuffer=t.createIndexBuffer(this.indexArray)),this.programConfigurations.upload(t),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.zOffsetVertexBuffer&&this.zOffsetVertexBuffer.destroy(),this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy())}lineFeatureClips(t){if(t.properties&&t.properties.hasOwnProperty("mapbox_clip_start")&&t.properties.hasOwnProperty("mapbox_clip_end"))return{start:+t.properties.mapbox_clip_start,end:+t.properties.mapbox_clip_end}}addFeature(t,e,i,n,r,o,s){const a=this.layers[0].layout,l=a.get("line-join").evaluate(t,{}),c=a.get("line-cap").evaluate(t,{}),d=a.get("line-miter-limit"),u=a.get("line-round-limit");this.lineClips=this.lineFeatureClips(t);for(const i of e)this.addLine(i,t,n,l,c,d,u);this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,t,i,r,o,n,s)}addLine(t,e,i,n,r,o,s){this.distance=0,this.scaledDistance=0,this.totalDistance=0,this.lineSoFar=0,this.currentVertex=void 0;const a={zoom:this.zoom,lineProgress:void 0},l=this.layers[0].layout,c="none"===n;if(this.patternJoinNone=this.hasPattern&&c,this.segmentStart=0,this.segmentStartf32=0,this.segmentPoints=[],this.lineClips){this.lineClipsArray.push(this.lineClips);for(let e=0;e=2&&t[u-1].equals(t[u-2]);)u--;let h=0;for(;h0;if(A&&i>h){const t=m.dist(_);if(t>2*p){const e=m.sub(m.sub(_)._mult(p/t)._round());this.updateDistance(_,e),this.addCurrentVertex(e,y,0,0,f,x),_=e}}if(b&&"round"===w&&(Mo&&(w="bevel"),"bevel"===w&&(M>2&&(w="flipbevel"),M100)S=v.mult(-1);else{const t=M*y.add(v).mag()/y.sub(v).mag();S._perp()._mult(t*(I?-1:1))}this.addCurrentVertex(m,S,0,0,f,x),this.addCurrentVertex(m,S.mult(-1),0,0,f,x)}else if("bevel"===w||"fakeround"===w){const t=-Math.sqrt(M*M-1),e=I?t:0,i=I?0:t;if(_&&this.addCurrentVertex(m,y,e,i,f,x),"fakeround"===w){const t=Math.round(180*C/Math.PI/20);for(let e=1;e2*p){const e=m.add(g.sub(m)._mult(p/t)._round());this.updateDistance(m,e),this.addCurrentVertex(e,v,0,0,f,x),m=e}}}}addVerticesTo(t,e,i,n,r,o,s,a,l,c){const d=(e.w-t.w)/this.tessellationStep|0;if(d>1){this.lineSoFar=t.w;const u=(e.x-t.x)/d,h=(e.y-t.y)/d,p=(e.z-t.z)/d,f=(e.w-t.w)/d;for(let e=1;e=0&&this.e2>=0&&(this.indexArray.emplaceBack(this.e1,this.e2,c),a.primitiveLength++),o?this.e2=c:this.e1=c,null!=l&&this.zOffsetVertexArray.emplaceBack(l)}updateScaledDistance(){if(this.lineClips){const t=this.totalDistance/(this.lineClips.end-this.lineClips.start);this.scaledDistance=this.distance/this.totalDistance,this.lineSoFar=t*this.lineClips.start+this.distance}else this.lineSoFar=this.distance}updateDistance(t,e){this.distance+=t.dist(e),this.updateScaledDistance()}}function Qf(t,e,i){return t.xi||t.yi}ba(Jf,"LineBucket",{omit:["layers","patternFeatures","currentVertex","currentVertexIsOutside"]});const tm=new ol({"line-cap":new nl(sl.layout_line["line-cap"]),"line-join":new nl(sl.layout_line["line-join"]),"line-miter-limit":new il(sl.layout_line["line-miter-limit"]),"line-round-limit":new il(sl.layout_line["line-round-limit"]),"line-sort-key":new nl(sl.layout_line["line-sort-key"]),"line-z-offset":new nl(sl.layout_line["line-z-offset"]),visibility:new il(sl.layout_line.visibility)});var em={paint:new ol({"line-opacity":new nl(sl.paint_line["line-opacity"]),"line-color":new nl(sl.paint_line["line-color"]),"line-translate":new il(sl.paint_line["line-translate"]),"line-translate-anchor":new il(sl.paint_line["line-translate-anchor"]),"line-width":new nl(sl.paint_line["line-width"]),"line-gap-width":new nl(sl.paint_line["line-gap-width"]),"line-offset":new nl(sl.paint_line["line-offset"]),"line-blur":new nl(sl.paint_line["line-blur"]),"line-dasharray":new nl(sl.paint_line["line-dasharray"]),"line-pattern":new nl(sl.paint_line["line-pattern"]),"line-gradient":new rl(sl.paint_line["line-gradient"]),"line-trim-offset":new il(sl.paint_line["line-trim-offset"]),"line-trim-fade-range":new il(sl.paint_line["line-trim-fade-range"]),"line-trim-color":new il(sl.paint_line["line-trim-color"]),"line-emissive-strength":new il(sl.paint_line["line-emissive-strength"]),"line-border-width":new nl(sl.paint_line["line-border-width"]),"line-border-color":new nl(sl.paint_line["line-border-color"]),"line-occlusion-opacity":new il(sl.paint_line["line-occlusion-opacity"])}),layout:tm};function im(t,e,i){return e*(uo/(t.tileSize*Math.pow(2,i-t.tileID.overscaledZ)))}function nm(t,e){return 1/im(t,1,e.tileZoom)}function rm(t,e,i,n){return t.translatePosMatrix(n||e.tileID.projMatrix,e,i.paint.get("line-translate"),i.paint.get("line-translate-anchor"))}const om=t=>{const e=[];sm(t)&&e.push("RENDER_LINE_DASH"),t.paint.get("line-gradient")&&e.push("RENDER_LINE_GRADIENT");const i=t.paint.get("line-trim-offset");0===i[0]&&0===i[1]||e.push("RENDER_LINE_TRIM_OFFSET"),0!==t.paint.get("line-border-width").constantOr(1)&&e.push("RENDER_LINE_BORDER");const n="none"===t.layout.get("line-join").constantOr("miter"),r=!!t.paint.get("line-pattern").constantOr(1);return n&&r&&e.push("LINE_JOIN_NONE"),e};function sm(t){const e=t.paint.get("line-dasharray").value;return e.value||"constant"!==e.kind}class am{constructor(t){this._stringToNumber={},this._numberToString=[];for(let e=0;e>1,d=-7,u=i?r-1:0,h=i?-1:1,p=t[e+u];for(u+=h,o=p&(1>=-d,d+=a;d>0;o=256*o+t[e+u],u+=h,d-=8);for(s=o&(1>=-d,d+=n;d>0;s=256*s+t[e+u],u+=h,d-=8);if(0===o)o=1-c;else{if(o===l)return s?NaN:1/0*(p?-1:1);s+=Math.pow(2,n),o-=c}return(p?-1:1)*s*Math.pow(2,o-n)},write:function(t,e,i,n,r,o){var s,a,l,c=8*o-r-1,d=(1>1,h=23===r?Math.pow(2,-24)-Math.pow(2,-77):0,p=n?0:o-1,f=n?1:-1,m=e=1?h/l:h*Math.pow(2,1-u))*l>=2&&(s++,l/=2),s+u>=d?(a=0,s=d):s+u>=1?(a=(e*l-1)*Math.pow(2,r),s+=u):(a=e*Math.pow(2,u-1)*Math.pow(2,r),s=0));r>=8;t[i+p]=255&a,p+=f,a/=256,r-=8);for(s=s0;t[i+p]=255&s,p+=f,s/=256,c-=8);t[i+p-f]|=128*m}},cm=um,dm=lm;function um(t){this.buf=ArrayBuffer.isView&&ArrayBuffer.isView(t)?t:new Uint8Array(t||0),this.pos=0,this.type=0,this.length=this.buf.length}um.Varint=0,um.Fixed64=1,um.Bytes=2,um.Fixed32=5;var hm=4294967296,pm=1/hm,fm="undefined"==typeof TextDecoder?null:new TextDecoder("utf8");function mm(t){return t.type===um.Bytes?t.readVarint()+t.pos:t.pos+1}function _m(t,e,i){return i?4294967296*e+(t>>>0):4294967296*(e>>>0)+(t>>>0)}function gm(t,e,i){var n=e=t;r--)i.buf[r+n]=i.buf[r]}function ym(t,e){for(var i=0;i>>8,t[i+2]=e>>>16,t[i+3]=e>>>24}function Im(t,e){return(t[e]|t[e+1]>3,o=this.pos;this.type=7&n,t(r,e,this),this.pos===o&&this.skip(n)}return e},readMessage:function(t,e){return this.readFields(t,e,this.readVarint()+this.pos)},readFixed32:function(){var t=Cm(this.buf,this.pos);return this.pos+=4,t},readSFixed32:function(){var t=Im(this.buf,this.pos);return this.pos+=4,t},readFixed64:function(){var t=Cm(this.buf,this.pos)+Cm(this.buf,this.pos+4)*hm;return this.pos+=8,t},readSFixed64:function(){var t=Cm(this.buf,this.pos)+Im(this.buf,this.pos+4)*hm;return this.pos+=8,t},readFloat:function(){var t=dm.read(this.buf,this.pos,!0,23,4);return this.pos+=4,t},readDouble:function(){var t=dm.read(this.buf,this.pos,!0,52,8);return this.pos+=8,t},readVarint:function(t){var e,i,n=this.buf;return e=127&(i=n[this.pos++]),i>4,r=12&&fm?function(t,e,i){return fm.decode(t.subarray(e,i))}(this.buf,e,t):function(t,e,i){for(var n="",r=e;r239?4:l>223?3:l>191?2:1;if(r+d>i)break;1===d?l=55296&&c=1114112)&&(c=null)),null===c?(c=65533,d=1):c>65535&&(c-=65536,n+=String.fromCharCode(c>>>10&1023|55296),c=56320|1023&c),n+=String.fromCharCode(c),r+=d}return n}(this.buf,e,t)},readBytes:function(){var t=this.readVarint()+this.pos,e=this.buf.subarray(this.pos,t);return this.pos=t,e},readPackedVarint:function(t,e){if(this.type!==um.Bytes)return t.push(this.readVarint(e));var i=mm(this);for(t=t||[];this.pos127;);else if(e===um.Bytes)this.pos=this.readVarint()+this.pos;else if(e===um.Fixed32)this.pos+=4;else{if(e!==um.Fixed64)throw new Error("Unimplemented type: "+e);this.pos+=8}},writeTag:function(t,e){this.writeVarint(t268435455||t=0?(i=t%4294967296|0,n=t/4294967296|0):(n=~(-t/4294967296),4294967295^(i=~(-t%4294967296))?i=i+1|0:(i=0,n=n+1|0)),t>=0x10000000000000000||t>>=7,i.buf[i.pos++]=127&t|128,t>>>=7,i.buf[i.pos++]=127&t|128,t>>>=7,i.buf[i.pos++]=127&t|128,i.buf[i.pos]=127&(t>>>=7)}(i,0,e),function(t,e){var i=(7&t)>>=3)?128:0),t&&(e.buf[e.pos++]=127&t|((t>>>=7)?128:0),t&&(e.buf[e.pos++]=127&t|((t>>>=7)?128:0),t&&(e.buf[e.pos++]=127&t|((t>>>=7)?128:0),t&&(e.buf[e.pos++]=127&t|((t>>>=7)?128:0),t&&(e.buf[e.pos++]=127&t)))))}(n,e)}(t,this):(this.realloc(4),this.buf[this.pos++]=127&t|(t>127?128:0),t>>=7)|(t>127?128:0),t>>=7)|(t>127?128:0),t>>7&127))))},writeSVarint:function(t){this.writeVarint(t55295&&n56319||o+1===e.length?(t[i++]=239,t[i++]=191,t[i++]=189):r=n;continue}if(n>6|192:(n>12|224:(t[i++]=n>>18|240,t[i++]=n>>12&63|128),t[i++]=n>>6&63|128),t[i++]=63&n|128)}return i}(this.buf,t,this.pos);var i=this.pos-e;i>=128&&gm(e,i,this),this.pos=e-1,this.writeVarint(i),this.pos+=i},writeFloat:function(t){this.realloc(4),dm.write(this.buf,t,this.pos,!0,23,4),this.pos+=4},writeDouble:function(t){this.realloc(8),dm.write(this.buf,t,this.pos,!0,52,8),this.pos+=8},writeBytes:function(t){var e=t.length;this.writeVarint(e),this.realloc(e);for(var i=0;i=128&&gm(i,n,this),this.pos=i-1,this.writeVarint(n),this.pos+=n},writeMessage:function(t,e,i){this.writeTag(t,um.Bytes),this.writeRawMessage(e,i)},writePackedVarint:function(t,e){e.length&&this.writeMessage(t,ym,e)},writePackedSVarint:function(t,e){e.length&&this.writeMessage(t,vm,e)},writePackedBoolean:function(t,e){e.length&&this.writeMessage(t,wm,e)},writePackedFloat:function(t,e){e.length&&this.writeMessage(t,xm,e)},writePackedDouble:function(t,e){e.length&&this.writeMessage(t,bm,e)},writePackedFixed32:function(t,e){e.length&&this.writeMessage(t,Tm,e)},writePackedSFixed32:function(t,e){e.length&&this.writeMessage(t,Sm,e)},writePackedFixed64:function(t,e){e.length&&this.writeMessage(t,Em,e)},writePackedSFixed64:function(t,e){e.length&&this.writeMessage(t,Mm,e)},writeBytesField:function(t,e){this.writeTag(t,um.Bytes),this.writeBytes(e)},writeFixed32Field:function(t,e){this.writeTag(t,um.Fixed32),this.writeFixed32(e)},writeSFixed32Field:function(t,e){this.writeTag(t,um.Fixed32),this.writeSFixed32(e)},writeFixed64Field:function(t,e){this.writeTag(t,um.Fixed64),this.writeFixed64(e)},writeSFixed64Field:function(t,e){this.writeTag(t,um.Fixed64),this.writeSFixed64(e)},writeVarintField:function(t,e){this.writeTag(t,um.Varint),this.writeVarint(e)},writeSVarintField:function(t,e){this.writeTag(t,um.Varint),this.writeSVarint(e)},writeStringField:function(t,e){this.writeTag(t,um.Bytes),this.writeString(e)},writeFloatField:function(t,e){this.writeTag(t,um.Fixed32),this.writeFloat(e)},writeDoubleField:function(t,e){this.writeTag(t,um.Fixed64),this.writeDouble(e)},writeBooleanField:function(t,e){this.writeVarintField(t,Boolean(e))}};var Lm=h(cm);const Pm=["id","tile","layer","source","sourceLayer","state"];class $m{constructor(t,e,i,n,r){this.type="Feature",this._vectorTileFeature=t,this._z=e,this._x=i,this._y=n,this.properties=t.properties,this.id=r}get geometry(){return void 0===this._geometry&&(this._geometry=this._vectorTileFeature.toGeoJSON(this._x,this._y,this._z).geometry),this._geometry}set geometry(t){this._geometry=t}toJSON(){const t={type:"Feature",state:void 0,geometry:this.geometry,properties:this.properties};for(const e of Pm)void 0!==this[e]&&(t[e]=this[e]);return t}}class km{constructor(){this.state={},this.stateChanges={},this.deletedStates={}}updateState(t,e,i){const n=String(e);if(this.stateChanges[t]=this.stateChanges[t]||{},this.stateChanges[t][n]=this.stateChanges[t][n]||{},ei(this.stateChanges[t][n],i),null===this.deletedStates[t]){this.deletedStates[t]={};for(const e in this.state[t])e!==n&&(this.deletedStates[t][e]=null)}else if(this.deletedStates[t]&&null===this.deletedStates[t][n]){this.deletedStates[t][n]={};for(const e in this.state[t][n])i[e]||(this.deletedStates[t][n][e]=null)}else for(const e in i)this.deletedStates[t]&&this.deletedStates[t][n]&&null===this.deletedStates[t][n][e]&&delete this.deletedStates[t][n][e]}removeFeatureState(t,e,i){if(null===this.deletedStates[t])return;const n=String(e);if(this.deletedStates[t]=this.deletedStates[t]||{},i&&void 0!==e)null!==this.deletedStates[t][n]&&(this.deletedStates[t][n]=this.deletedStates[t][n]||{},this.deletedStates[t][n][i]=null);else if(void 0!==e)if(this.stateChanges[t]&&this.stateChanges[t][n])for(i in this.deletedStates[t][n]={},this.stateChanges[t][n])this.deletedStates[t][n][i]=null;else this.deletedStates[t][n]=null;else this.deletedStates[t]=null}getState(t,e){const i=String(e),n=ei({},(this.state[t]||{})[i],(this.stateChanges[t]||{})[i]);if(null===this.deletedStates[t])return{};if(this.deletedStates[t]){const i=this.deletedStates[t][e];if(null===i)return{};for(const t in i)delete n[t]}return n}initializeTileState(t,e){t.setFeatureState(this.state,e)}coalesceChanges(t,e){const i={};for(const t in this.stateChanges){this.state[t]=this.state[t]||{};const e={};for(const i in this.stateChanges[t])this.state[t][i]||(this.state[t][i]={}),ei(this.state[t][i],this.stateChanges[t][i]),e[i]=this.state[t][i];i[t]=e}for(const t in this.deletedStates){this.state[t]=this.state[t]||{};const e={};if(null===this.deletedStates[t])for(const i in this.state[t])e[i]={},this.state[t][i]={};else for(const i in this.deletedStates[t]){if(null===this.deletedStates[t][i])this.state[t][i]={};else if(this.state[t][i])for(const e of Object.keys(this.deletedStates[t][i]))delete this.state[t][i][e];e[i]=this.state[t][i]}i[t]=i[t]||{},ei(i[t],e)}if(this.stateChanges={},this.deletedStates={},0!==Object.keys(i).length)for(const n in t)t[n].setFeatureState(i,e)}}class Dm{constructor(t,e){this.tileID=t,this.x=t.canonical.x,this.y=t.canonical.y,this.z=t.canonical.z,this.grid=new va(uo,16,0),this.featureIndexArray=new yc,this.promoteId=e,this.is3DTile=!1}insert(t,e,i,n,r,o=0,s=0){const a=this.featureIndexArray.length;this.featureIndexArray.emplaceBack(i,n,r,o);const l=this.grid;for(let t=0;t=0&&n[3]>=0&&l.insert(a,n[0],n[1],n[2],n[3])}}loadVTLayers(){if(!this.vtLayers){this.vtLayers=new bp(new Lm(this.rawTileData)).layers,this.sourceLayerCoder=new am(this.vtLayers?Object.keys(this.vtLayers).sort():["_geojsonTileLayer"]),this.vtFeatures={};for(const t in this.vtLayers)this.vtFeatures[t]=[]}return this.vtLayers}query(t,e,i,n){this.loadVTLayers();const r=t.params||{},o=dl(r.filter),s=t.tileResult,a=t.transform,l=s.bufferedTilespaceBounds,c=this.grid.query(l.min.x,l.min.y,l.max.x,l.max.y,((t,e,i,n)=>ou(s.bufferedTilespaceGeometry,t,e,i,n)));c.sort(Rm);let d=null;a.elevation&&c.length>0&&(d=Xp.create(a.elevation,this.tileID));const u={};let h;for(let l=0;l(m||(m=Gd(e,this.tileID.canonical,t.tileTransform)),i.queryIntersectsFeature(s,e,n,m,this.z,t.transform,t.pixelPosMatrix,d,r))))}return u}loadMatchingFeature(t,e,i,n,r,o,s,a,l){const{featureIndex:c,bucketIndex:d,sourceLayerIndex:u,layoutVertexArrayOffset:h}=e,p=this.bucketLayerIDs[d];if(n&&!function(t,e){for(let i=0;i=0)return!0;return!1}(n,p))return;const f=this.sourceLayerCoder.decode(u),m=this.vtLayers[f].feature(c);if(i.needGeometry){const t=Zd(m,!0);if(!i.filter(new Ha(this.tileID.overscaledZ),t,this.tileID.canonical))return}else if(!i.filter(new Ha(this.tileID.overscaledZ),m))return;const _=this.getId(m,f);for(let e=0;e{const s=e instanceof el?e.get(o):null;return s&&s.evaluate?s.evaluate(i,n,r):s}))}function Rm(t,e){return e-t}ba(Dm,"FeatureIndex",{omit:["rawTileData","sourceLayerCoder"]});var Om=24;const Bm=128;function Fm(t,e){const{expression:i}=e;if("constant"===i.kind)return{kind:"constant",layoutSize:i.evaluate(new Ha(t+1))};if("source"===i.kind)return{kind:"source"};{const{zoomStops:e,interpolationType:n}=i;let r=0;for(;r{t.text=function(t,e,i){const n=e.layout.get("text-transform").evaluate(i,{});return"uppercase"===n?t=t.toLocaleUpperCase():"lowercase"===n&&(t=t.toLocaleLowerCase()),qa.applyArabicShaping&&(t=qa.applyArabicShaping(t)),t}(t.text,e,i)})),t}const Gm={"!":"︕","#":"#",$:"$","%":"%","&":"&","(":"︵",")":"︶","*":"*","+":"+",",":"︐","-":"︲",".":"・","/":"/",":":"︓",";":"︔","":"﹀","?":"︖","@":"@","[":"﹇","\\":"\","]":"﹈","^":"^",_:"︳","`":"`","{":"︷","|":"―","}":"︸","~":"~","¢":"¢","£":"£","¥":"¥","¦":"¦","¬":"¬","¯":" ̄","–":"︲","—":"︱","‘":"﹃","’":"﹄","“":"﹁","”":"﹂","…":"︙","‧":"・","₩":"₩","、":"︑","。":"︒","〈":"︿","〉":"﹀","《":"︽","》":"︾","「":"﹁","」":"﹂","『":"﹃","』":"﹄","【":"︻","】":"︼","〔":"︹","〕":"︺","〖":"︗","〗":"︘","!":"︕","(":"︵",")":"︶",",":"︐","-":"︲",".":"・",":":"︓",";":"︔","<":"︿",">":"﹀","?":"︖","[":"﹇","]":"﹈","_":"︳","{":"︷","|":"―","}":"︸","⦅":"︵","⦆":"︶","。":"︒","「":"﹁","」":"﹂","←":"↑","→":"↓"};function Zm(t){return"︶"===t||"﹈"===t||"︸"===t||"﹄"===t||"﹂"===t||"︾"===t||"︼"===t||"︺"===t||"︘"===t||"﹀"===t||"︐"===t||"︓"===t||"︔"===t||"`"===t||" ̄"===t||"︑"===t||"︒"===t}function qm(t){return"︵"===t||"﹇"===t||"︷"===t||"﹃"===t||"﹁"===t||"︽"===t||"︻"===t||"︹"===t||"︗"===t||"︿"===t}const Hm=3;function Wm(t,e,i){e.glyphs=[],1===t&&i.readMessage(Ym,e)}function Ym(t,e,i){if(3===t){const{id:t,bitmap:n,width:r,height:o,left:s,top:a,advance:l}=i.readMessage(Xm,{});e.glyphs.push({id:t,bitmap:new dh({width:r+2*Hm,height:o+2*Hm},n),metrics:{width:r,height:o,left:s,top:a,advance:l}})}else 4===t?e.ascender=i.readSVarint():5===t&&(e.descender=i.readSVarint())}function Xm(t,e,i){1===t?e.id=i.readVarint():2===t?e.bitmap=i.readBytes():3===t?e.width=i.readVarint():4===t?e.height=i.readVarint():5===t?e.left=i.readSVarint():6===t?e.top=i.readSVarint():7===t&&(e.advance=i.readVarint())}const Km=Hm,Jm={horizontal:1,vertical:2,horizontalOnly:3};class Qm{constructor(){this.scale=1,this.fontStack="",this.imageName=null}static forText(t,e){const i=new Qm;return i.scale=t||1,i.fontStack=e,i}static forImage(t){const e=new Qm;return e.imageName=t,e}}class t_{constructor(){this.text="",this.sectionIndex=[],this.sections=[],this.imageSectionID=null}static fromFeature(t,e){const i=new t_;for(let n=0;n=0&&i>=t&&i_[this.text.charCodeAt(i)];i--)e--;this.text=this.text.substring(t,e),this.sectionIndex=this.sectionIndex.slice(t,e)}substring(t,e){const i=new t_;return i.text=this.text.substring(t,e),i.sectionIndex=this.sectionIndex.slice(t,e),i.sections=this.sections,i}toString(){return this.text}getMaxScale(){return this.sectionIndex.reduce(((t,e)=>Math.max(t,this.sections[e].scale)),0)}addTextSection(t,e){this.text+=t.text,this.sections.push(Qm.forText(t.scale,t.fontStack||e));const i=this.sections.length-1;for(let e=0;e=63743?null:++this.imageSectionID:(this.imageSectionID=57344,this.imageSectionID)}}function e_(t,e,i,n,r,o,s,a,l,c,d,u,h,p,f){const m=t_.fromFeature(t,r);u===Jm.vertical&&m.verticalizePunctuation(h);let _=[];const g=function(t,e,i,n,r,o){if(!t)return[];const s=[],a=function(t,e,i,n,r,o){let s=0;for(let i=0;i=0;let c=0;for(let i=0;i0&&o>b&&(b=o)}else{const t=i[a.fontStack];if(!t)continue;t[m]&&(S=t[m]);const n=e[a.fontStack];if(!n)continue;const o=n.glyphs[m];if(!o)continue;if(v=o.metrics,M=8203!==m?Om:0,_){const t=void 0!==n.ascender?Math.abs(n.ascender):0,e=void 0!==n.descender?Math.abs(n.descender):0,i=(t+e)*g;w-i/2;){if(s--,sn;)c-=l.shift().angleDelta;if(c>r)return!1;s++,a+=e.dist(i)}return!0}function m_(t){let e=0;for(let i=0;ic){const d=(c-l)/o,u=Vn(n.x,r.x,d),h=Vn(n.y,r.y,d),p=new p_(u,h,0,r.angleTo(n),i);return!s||f_(t,p,a,s,e)?p:void 0}l+=o}}function v_(t,e,i,n,r,o,s,a,l){const c=__(n,o,s),d=g_(n,r),u=d*s,h=0===t[0].x||t[0].x===l||0===t[0].y||t[0].y===l;return e-u=0&&g=0&&y=0&&h+c=n&&c.x>=n||(s.x>=n?s=new Ue(n,s.y+(n-s.x)/(c.x-s.x)*(c.y-s.y))._round():c.x>=n&&(c=new Ue(n,s.y+(n-s.x)/(c.x-s.x)*(c.y-s.y))._round()),s.y>=r&&c.y>=r||(s.y>=r?s=new Ue(s.x+(r-s.y)/(c.y-s.y)*(c.x-s.x),r)._round():c.y>=r&&(c=new Ue(s.x+(r-s.y)/(c.y-s.y)*(c.x-s.x),r)._round()),l&&s.equals(l[l.length-1])||(l=[s],o.push(l)),l.push(c)))))}}return o}function w_(t){let e=0,i=0;for(const n of t)e+=n.w*n.h,i=Math.max(i,n.w);t.sort(((t,e)=>e.h-t.h));const n=[{x:0,y:0,w:Math.max(Math.ceil(Math.sqrt(e/.95)),i),h:1/0}];let r=0,o=0;for(const e of t)for(let t=n.length-1;t>=0;t--){const i=n[t];if(!(e.w>i.w||e.h>i.h)){if(e.x=i.x,e.y=i.y,o=Math.max(o,e.y+e.h),r=Math.max(r,e.x+e.w),e.w===i.w&&e.h===i.h){const e=n.pop();tt.hasImage(e,i))),t.dispatchRenderCallbacks(this.haveRenderCallbacks,i);for(const n in t.getUpdatedImages(i))this.patchUpdatedImage(this.iconPositions[n],t.getImage(n,i),e),this.patchUpdatedImage(this.patternPositions[n],t.getImage(n,i),e)}patchUpdatedImage(t,e,i){if(!t||!e)return;if(t.version===e.version)return;t.version=e.version;const[n,r]=t.tl,o=!!Object.keys(this.patternPositions).length;i.update(e.data,{useMipmap:o},{x:n,y:r})}}ba(S_,"ImagePosition"),ba(E_,"ImageAtlas");const M_=1e20;function C_(t,e,i,n,r,o,s,a,l){for(let c=e;c-1);l++,o[l]=a,s[l]=c,s[l+1]=M_}for(let a=0,l=0;a{let n=this.entries[t];n||(n=this.entries[t]={glyphs:{},requests:{},ranges:{},ascender:void 0,descender:void 0});let r=n.glyphs[e];if(void 0!==r)return void i(null,{stack:t,id:e,glyph:r});if(r=this._tinySDF(n,t,e),r)return n.glyphs[e]=r,void i(null,{stack:t,id:e,glyph:r});const s=Math.floor(e/256);if(256*s>65535)return void i(new Error("glyphs > 65535 not supported"));if(n.ranges[s])return void i(null,{stack:t,id:e,glyph:r});let a=n.requests[s];a||(a=n.requests[s]=[],P_.loadGlyphRange(t,s,o,this.requestManager,((t,e)=>{if(e){n.ascender=e.ascender,n.descender=e.descender;for(const t in e.glyphs)this._doesCharSupportLocalGlyph(+t)||(n.glyphs[+t]=e.glyphs[+t]);n.ranges[s]=!0}for(const i of a)i(t,e);delete n.requests[s]}))),a.push(((n,r)=>{n?i(n):r&&i(null,{stack:t,id:e,glyph:r.glyphs[e]||null})}))}),((t,e)=>{if(t)i(t);else if(e){const t={};for(const{stack:i,id:n,glyph:r}of e)void 0===t[i]&&(t[i]={}),void 0===t[i].glyphs&&(t[i].glyphs={}),t[i].glyphs[n]=r&&{id:r.id,bitmap:r.bitmap.clone(),metrics:r.metrics},t[i].ascender=this.entries[i].ascender,t[i].descender=this.entries[i].descender;i(null,t)}}))}_doesCharSupportLocalGlyph(t){return this.localGlyphMode!==L_.none&&(this.localGlyphMode===L_.all?!!this.localFontFamily:!!this.localFontFamily&&(Ma["CJK Unified Ideographs"](t)||Ma["Hangul Syllables"](t)||Ma.Hiragana(t)||Ma.Katakana(t)||Ma["CJK Symbols and Punctuation"](t)||Ma["CJK Unified Ideographs Extension A"](t)||Ma["CJK Unified Ideographs Extension B"](t)))}_tinySDF(t,e,i){const n=this.localFontFamily;if(!n||!this._doesCharSupportLocalGlyph(i))return;let r=t.tinySDF;if(!r){let i="400";/bold/i.test(e)?i="900":/medium/i.test(e)?i="500":/light/i.test(e)&&(i="200"),r=t.tinySDF=new P_.TinySDF({fontFamily:n,fontWeight:i,fontSize:24*I_,buffer:3*I_,radius:8*I_}),r.fontWeight=i}if(this.localGlyphs[r.fontWeight][i])return this.localGlyphs[r.fontWeight][i];const o=String.fromCodePoint(i),{data:s,width:a,height:l,glyphWidth:c,glyphHeight:d,glyphLeft:u,glyphTop:h,glyphAdvance:p}=r.draw(o);return this.localGlyphs[r.fontWeight][i]={id:i,bitmap:new dh({width:a,height:l},s),metrics:{width:c/I_,height:d/I_,left:u/I_,top:h/I_-27,advance:p/I_,localGlyph:!0}}}}P_.loadGlyphRange=function(t,e,i,n,r){const o=256*e,s=o+255,a=n.transformRequest(n.normalizeGlyphsURL(i).replace("{fontstack}",t).replace("{range}",`${o}-${s}`),Ki.Glyphs);en(a,((t,e)=>{if(t)r(t);else if(e){const t={},i=function(t){return new Lm(t).readFields(Wm,{})}(e);for(const e of i.glyphs)t[e.id]=e;r(null,{glyphs:t,ascender:i.ascender,descender:i.descender})}}))},P_.TinySDF=class{constructor({fontSize:t=24,buffer:e=3,radius:i=8,cutoff:n=.25,fontFamily:r="sans-serif",fontWeight:o="normal",fontStyle:s="normal"}={}){this.buffer=e,this.cutoff=n,this.radius=i;const a=this.size=t+4*e,l=this._createCanvas(a),c=this.ctx=l.getContext("2d",{willReadFrequently:!0});c.font=`${s} ${o} ${t}px ${r}`,c.textBaseline="alphabetic",c.textAlign="left",c.fillStyle="black",this.gridOuter=new Float64Array(a*a),this.gridInner=new Float64Array(a*a),this.f=new Float64Array(a),this.z=new Float64Array(a+1),this.v=new Uint16Array(a)}_createCanvas(t){const e=document.createElement("canvas");return e.width=e.height=t,e}draw(t){const{width:e,actualBoundingBoxAscent:i,actualBoundingBoxDescent:n,actualBoundingBoxLeft:r,actualBoundingBoxRight:o}=this.ctx.measureText(t),s=Math.ceil(i),a=Math.max(0,Math.min(this.size-this.buffer,Math.ceil(o-r))),l=Math.min(this.size-this.buffer,s+Math.ceil(n)),c=a+2*this.buffer,d=l+2*this.buffer,u=Math.max(c*d,0),h=new Uint8ClampedArray(u),p={data:h,width:c,height:d,glyphWidth:a,glyphHeight:l,glyphTop:s,glyphLeft:0,glyphAdvance:e};if(0===a||0===l)return p;const{ctx:f,buffer:m,gridInner:_,gridOuter:g}=this;f.clearRect(m,m,a,l),f.fillText(t,m,m+s);const y=f.getImageData(m,m,a,l);g.fill(M_,0,u),_.fill(0,0,u);for(let t=0;t0?t*t:0,_[n]=tt+e[1]-e[0],f=u.reduce(p,0),m=h.reduce(p,0),_=a-f,g=l-m;let y=0,v=f,x=0,b=m,w=0,T=_,S=0,E=g;if(o.content&&n){const t=o.content;y=D_(u,0,t[0]),x=D_(h,0,t[1]),v=D_(u,t[0],t[2]),b=D_(h,t[1],t[3]),w=t[0]-y,S=t[1]-x,T=t[2]-t[0]-v,E=t[3]-t[1]-b}const M=(n,r,a,l)=>{const u=R_(n.stretch-y,v,c,t.left),h=O_(n.fixed-w,T,n.stretch,f),p=R_(r.stretch-x,b,d,t.top),_=O_(r.fixed-S,E,r.stretch,m),g=R_(a.stretch-y,v,c,t.left),M=O_(a.fixed-w,T,a.stretch,f),C=R_(l.stretch-x,b,d,t.top),A=O_(l.fixed-S,E,l.stretch,m),I=new Ue(u,p),L=new Ue(g,p),P=new Ue(g,C),$=new Ue(u,C),k=new Ue(h/s,_/s),D=new Ue(M/s,A/s),z=e*Math.PI/180;if(z){const t=Math.sin(z),e=Math.cos(z),i=[e,-t,t,e];I._matMult(i),L._matMult(i),$._matMult(i),P._matMult(i)}const R=n.stretch+n.fixed,O=a.stretch+a.fixed,B=r.stretch+r.fixed,F=l.stretch+l.fixed,N=t.imageSecondary;return{tl:I,tr:L,bl:$,br:P,texPrimary:{x:o.paddedRect.x+$_+R,y:o.paddedRect.y+$_+B,w:O-R,h:F-B},texSecondary:N?{x:N.paddedRect.x+$_+R,y:N.paddedRect.y+$_+B,w:O-R,h:F-B}:void 0,writingMode:void 0,glyphOffset:[0,0],sectionIndex:0,pixelOffsetTL:k,pixelOffsetBR:D,minFontScaleX:T/s/c,minFontScaleY:E/s/d,isSDF:i}};if(n&&(o.stretchX||o.stretchY)){const t=z_(u,_,f),e=z_(h,g,m);for(let i=0;io)&&(o=e.x),(!t||e.y>s)&&(s=e.y)}const l=Math.min(o-n,s-r);let c=l/2;const d=new co([],N_);if(0===l)return new Ue(n,r);for(let e=n;eu.d||!u.d)&&(u=n,i&&console.log("found best %d after %d probes",Math.round(1e4*n.d)/1e4,h)),n.max-u.dt.y!=a.y>t.y&&t.x18&&P>2&&(P>>=1),Math.max(uo/(512*P),1)*_.get("symbol-spacing")),S=_.get("text-padding")*t.tilePixelRatio,E=_.get("icon-padding")*t.tilePixelRatio,M=Ge(_.get("text-max-angle")),C="map"===_.get("text-rotation-alignment")&&"point"!==_.get("symbol-placement"),A="map"===_.get("icon-rotation-alignment")&&"point"!==_.get("symbol-placement"),I=_.get("symbol-placement"),L=T/2;var P;const $=_.get("icon-text-fit").evaluate(e,{},u),k=_.get("icon-text-fit-padding").evaluate(e,{},u),D="none"!==$;let z;!1===t.hasAnyIconTextFit&&D&&(t.hasAnyIconTextFit=!0),n&&D&&(t.allowVerticalPlacement&&i.vertical&&(z=h_(n,i.vertical,$,k,g,b)),y&&(n=h_(n,y,$,k,g,b)));const R=(s,a,m)=>{if(a.x=uo||a.y=uo)return;let _=null;if(v){const{x:t,y:e,z:i}=h.projectTilePoint(a.x,a.y,m);_={anchor:new p_(t,e,i,0,void 0),up:h.upVector(m,a.x,a.y)}}!function(t,e,i,n,r,o,s,a,l,c,d,u,h,p,f,m,_,g,y,v,x,b,w,T,S,E,M){const C=t.addToLineVertexArray(e,n);let A,I,L,P,$,k,D,z=0,R=0,O=0,B=0,F=-1,N=-1;const U={};let j=Ln("");const V=i?i.anchor:e,G="none"!==l.layout.get("icon-text-fit").evaluate(x,{},S);let Z=0,q=0;if(void 0===l._unevaluatedLayout.getValue("text-radial-offset")?[Z,q]=l.layout.get("text-offset").evaluate(x,{},S).map((t=>t*Om)):(Z=l.layout.get("text-radial-offset").evaluate(x,{},S)*Om,q=j_),t.allowVerticalPlacement&&r.vertical){const t=r.vertical;if(f)k=J_(t),a&&(D=J_(a));else{const i=l.layout.get("text-rotate").evaluate(x,{},S)+90;L=K_(c,V,e,d,u,h,t,p,i,m),a&&(P=K_(c,V,e,d,u,h,a,g,i))}}if(o){const n=l.layout.get("icon-rotate").evaluate(x,{},S),r=k_(o,n,w,G),s=a?k_(a,n,w,G):void 0;I=K_(c,V,e,d,u,h,o,g,n),z=4*r.length;const p=t.iconSizeData;let f=null;"source"===p.kind?(f=[Bm*l.layout.get("icon-size").evaluate(x,{},S)],f[0]>W_&&pi(`${t.layerIds[0]}: Value for "icon-size" is >= ${H_}. Reduce your "icon-size".`)):"composite"===p.kind&&(f=[Bm*b.compositeIconSizes[0].evaluate(x,{},S),Bm*b.compositeIconSizes[1].evaluate(x,{},S)],(f[0]>W_||f[1]>W_)&&pi(`${t.layerIds[0]}: Value for "icon-size" is >= ${H_}. Reduce your "icon-size".`)),t.addSymbols(t.icon,r,f,v,y,x,!1,i,e,C.lineStartIndex,C.lineLength,-1,T,S,E,M),F=t.icon.placedSymbolArray.length-1,s&&(R=4*s.length,t.addSymbols(t.icon,s,f,v,y,x,Jm.vertical,i,e,C.lineStartIndex,C.lineLength,-1,T,S,E,M),N=t.icon.placedSymbolArray.length-1)}for(const n in r.horizontal){const o=r.horizontal[n];A||(j=Ln(o.text),f?$=J_(o):A=K_(c,V,e,d,u,h,o,p,l.layout.get("text-rotate").evaluate(x,{},S),m));const a=1===o.positionedLines.length;if(O+=Y_(t,i,e,o,s,l,f,x,m,C,r.vertical?Jm.horizontal:Jm.horizontalOnly,a?Object.keys(r.horizontal):[n],U,F,b,T,S,E),a)break}r.vertical&&(B+=Y_(t,i,e,r.vertical,s,l,f,x,m,C,Jm.vertical,["vertical"],U,N,b,T,S,E));let H=-1;const W=(t,e)=>t?Math.max(t,e):e;H=W($,H),H=W(k,H),H=W(D,H);const Y=H>-1?1:0;t.glyphOffsetArray.length>=65535&&pi("Too many glyphs being rendered in a tile. See https://github.com/mapbox/mapbox-gl-js/issues/2907"),void 0!==x.sortKey&&t.addToSortKeyRanges(t.symbolInstances.length,x.sortKey),t.symbolInstances.emplaceBack(e.x,e.y,V.x,V.y,V.z,U.right>=0?U.right:-1,U.center>=0?U.center:-1,U.left>=0?U.left:-1,U.vertical>=0?U.vertical:-1,F,N,j,void 0!==A?A:t.collisionBoxArray.length,void 0!==A?A+1:t.collisionBoxArray.length,void 0!==L?L:t.collisionBoxArray.length,void 0!==L?L+1:t.collisionBoxArray.length,void 0!==I?I:t.collisionBoxArray.length,void 0!==I?I+1:t.collisionBoxArray.length,P||t.collisionBoxArray.length,P?P+1:t.collisionBoxArray.length,d,O,B,z,R,Y,0,Z,q,H,0,1,1,G?1:0)}(t,a,_,s,i,n,r,z,t.layers[0],t.collisionBoxArray,e.index,e.sourceLayerIndex,t.index,S,C,l,0,E,A,g,e,o,c,d,u,p,f)};if("line"===I)for(const r of b_(e.geometry,0,0,uo,uo)){const e=v_(r,T,M,i.vertical||y,n,x,w,t.overscaling,uo);for(const i of e)y&&Q_(t,y.text,L,i)||R(r,i,u)}else if("line-center"===I){for(const t of e.geometry)if(t.length>1){const e=y_(t,M,i.vertical||y,n,x,w);e&&R(t,e,u)}}else if("Polygon"===e.type)for(const t of Zh(e.geometry,0)){const e=F_(t,16);R(t[0],new p_(e.x,e.y,0,0,void 0),u)}else if("LineString"===e.type)for(const t of e.geometry)R(t,new p_(t[0].x,t[0].y,0,0,void 0),u);else if("Point"===e.type)for(const t of e.geometry)for(const e of t)R([e],new p_(e.x,e.y,0,0,void 0),u)}const H_=255,W_=H_*Bm;function Y_(t,e,i,n,r,o,s,a,l,c,d,u,h,p,f,m,_,g){const y=function(t,e,i,n,r,o,s,a){const l=[];if(0===e.positionedLines.length)return l;const c=n.layout.get("text-rotate").evaluate(o,{})*Math.PI/180,d=function(t){const e=t[0],i=t[1],n=e*i;return n>0?[e,-i]:nW_&&pi(`${t.layerIds[0]}: Value for "text-size" is >= ${H_}. Reduce your "text-size".`)):"composite"===v.kind&&(x=[Bm*f.compositeTextSizes[0].evaluate(a,{},_),Bm*f.compositeTextSizes[1].evaluate(a,{},_)],(x[0]>W_||x[1]>W_)&&pi(`${t.layerIds[0]}: Value for "text-size" is >= ${H_}. Reduce your "text-size".`)),t.addSymbols(t.text,y,x,l,s,a,d,e,i,c.lineStartIndex,c.lineLength,p,m,_,g,!1);for(const e of u)h[e]=t.text.placedSymbolArray.length-1;return 4*y.length}function X_(t){for(const e in t)return t[e];return null}function K_(t,e,i,n,r,o,s,a,l,c){let d=s.top,u=s.bottom,h=s.left,p=s.right;const f=s.collisionPadding;if(f&&(h-=f[0],d-=f[1],p+=f[2],u+=f[3]),l){const t=new Ue(h,d),e=new Ue(p,d),i=new Ue(h,u),n=new Ue(p,u),r=Ge(l);let o=new Ue(0,0);c&&(o=new Ue(c[0],c[1])),t._rotateAround(r,o),e._rotateAround(r,o),i._rotateAround(r,o),n._rotateAround(r,o),h=Math.min(t.x,e.x,i.x,n.x),p=Math.max(t.x,e.x,i.x,n.x),d=Math.min(t.y,e.y,i.y,n.y),u=Math.max(t.y,e.y,i.y,n.y)}return t.emplaceBack(e.x,e.y,e.z,i.x,i.y,h,d,p,u,a,n,r,o),t.length-1}function J_(t){t.collisionPadding&&(t.top-=t.collisionPadding[1],t.bottom+=t.collisionPadding[3]);const e=t.bottom-t.top;return e>0?Math.max(10,e):null}function Q_(t,e,i,n){const r=t.compareText;if(e in r){const t=r[e];for(let e=t.length-1;e>=0;e--)if(n.dist(t[e])v&&(x(t,c,n,r,a,l),x(c,i,a,l,o,s))}x(u,h,n,o,r,o),x(h,p,r,o,r,s),x(p,f,r,s,n,s),x(f,u,n,s,n,o),m-=v,_-=v,g+=v,y+=v;const b=1/Math.max(g-m,y-_);return{scale:b,x:m*b,y:_*b,x2:g*b,y2:y*b,projection:e}}function ig(t,{x:e,y:i},n=0){return new Ue(((e-n)*t.scale-t.x)*uo,(i*t.scale-t.y)*uo)}const ng=t.ad.identity(new Float32Array(16));class rg{constructor(t){this.spec=t,this.name=t.name,this.wrap=!1,this.requiresDraping=!1,this.supportsWorldCopies=!1,this.supportsTerrain=!1,this.supportsFog=!1,this.supportsFreeCamera=!1,this.zAxisUnit="meters",this.isReprojectedInTileSpace=!0,this.unsupportedLayers=["custom"],this.center=[0,0],this.range=[3.5,7]}project(t,e){return{x:0,y:0,z:0}}unproject(t,e){return new pd(0,0)}projectTilePoint(t,e,i){return{x:t,y:e,z:0}}locationPoint(t,e,i=!0){return t._coordinatePoint(t.locationCoordinate(e),i)}pixelsPerMeter(t,e){return Cd(1,t)*e}pixelSpaceConversion(t,e,i){return 1}farthestPixelDistance(t){return tg(t,t.pixelsPerMeter)}pointCoordinate(t,e,i,n){const r=t.horizonLineFromTop(!1),o=new Ue(e,Math.max(r,i));return t.rayIntersectionCoordinate(t.pointRayIntersection(o,n))}pointCoordinate3D(t,e,i){const n=new Ue(e,i);if(t.elevation)return t.elevation.pointCoordinate(n);{const e=this.pointCoordinate(t,n.x,n.y,0);return[e.x,e.y,e.z]}}isPointAboveHorizon(t,e){if(t.elevation&&t.elevation.visibleDemTiles.length)return!this.pointCoordinate3D(t,e.x,e.y);const i=t.horizonLineFromTop();return e.y0?epg-i&&(e=pg-i);const o=r/Math.pow(fg(e),n);let s=o*Math.sin(n*t),a=r-o*Math.cos(n*t);return s=.5*(s/Math.PI+.5),a=.5*(a/Math.PI+.5),{x:s,y:this.southernCenter?a:1-a,z:0}}unproject(t,e){t=(2*t-.5)*Math.PI,this.southernCenter&&(e=1-e),e=(2*(1-e)-.5)*Math.PI;const{n:i,f:n}=this,r=n-e,o=Math.sign(r),s=Math.sign(i)*Math.sqrt(t*t+r*r);let a=Math.atan2(t,Math.abs(r))*o;r*i1e-6&&--n>0);o=i*i;const s=Xe(Ze(t/(.8707+o*(o*(o*o*o*(.003971-.001529*o)-.013791)-.131979))),-180,180),a=Ze(i);return new pd(s,a)}}const vg=Ge(Pd);class xg extends rg{project(t,e){e=Ge(e),t=Ge(t);const i=Math.cos(e),n=2/Math.PI,r=Math.acos(i*Math.cos(t/2)),o=Math.sin(r)/r,s=.5*(t*n+2*i*Math.sin(t/2)/o)||0,a=.5*(e+Math.sin(e)/o)||0;return{x:.5*(s/Math.PI+.5),y:1-.5*(a/Math.PI+1),z:0}}unproject(t,e){let i=t=(2*t-.5)*Math.PI,n=e=(2*(1-e)-1)*Math.PI,r=25;const o=1e-6;let s=0,a=0;do{const r=Math.cos(n),o=Math.sin(n),l=2*o*r,c=o*o,d=r*r,u=Math.cos(i/2),h=Math.sin(i/2),p=2*u*h,f=h*h,m=1-d*u*u,_=m?1/m:0,g=m?Math.acos(r*u)*Math.sqrt(1/m):0,y=.5*(2*g*r*h+2*i/Math.PI)-t,v=.5*(g*o+n)-e,x=.5*_*(d*f+g*r*u*c)+1/Math.PI,b=_*(p*l/4-g*o*h),w=.125*_*(l*h-g*o*d*p),T=.5*_*(c*u+g*f*r)+.5,S=b*w-T*x;s=(v*b-y*T)/S,a=(y*w-v*x)/S,i=Xe(i-s,-Math.PI,Math.PI),n=Xe(n-a,-vg,vg)}while((Math.abs(s)>o||Math.abs(a)>o)&&--r>0);return new pd(Ze(i),Ze(n))}}class bg extends rg{constructor(t){super(t),this.center=t.center||[0,0],this.parallels=t.parallels||[0,0],this.cosPhi=Math.max(.01,Math.cos(Ge(this.parallels[0]))),this.scale=1/(2*Math.max(Math.PI*this.cosPhi,1/this.cosPhi)),this.wrap=!0,this.supportsWorldCopies=!0}project(t,e){const{scale:i,cosPhi:n}=this;return{x:Ge(t)*n*i+.5,y:-Math.sin(Ge(e))/n*i+.5,z:0}}unproject(t,e){const{scale:i,cosPhi:n}=this,r=-(e-.5)/i,o=Xe(Ze((t-.5)/i)/n,-180,180),s=Math.asin(Xe(r*n,-1,1)),a=Xe(Ze(s),-Pd,Pd);return new pd(o,a)}}class wg extends _g{constructor(t){super(t),this.requiresDraping=!0,this.supportsWorldCopies=!1,this.supportsFog=!0,this.zAxisUnit="pixels",this.unsupportedLayers=["debug"],this.range=[3,5]}projectTilePoint(e,i,n){const r=Fu(e,i,n),o=ju($u(n));return t._.transformMat4(r,r,o),{x:r[0],y:r[1],z:r[2]}}locationPoint(e,i){const n=dd(i.lat,i.lng),r=t._.normalize([],n),o=e.elevation?e.elevation.getAtPointOrZero(e.locationCoordinate(i),e._centerAltitude):e._centerAltitude,s=Cd(1,0)*uo*o;t._.scaleAndAdd(n,n,r,s);const a=t.ad.identity(new Float64Array(16));return t.ad.multiply(a,e.pixelMatrix,e.globeMatrix),t._.transformMat4(n,n,a),new Ue(n[0],n[1])}pixelsPerMeter(t,e){return Cd(1,0)*e}pixelSpaceConversion(t,e,i){const n=Cd(1,t)*e,r=Vn(Cd(1,45)*e,n,i);return this.pixelsPerMeter(t,e)/r}createTileMatrix(e,i,n){const r=Vu($u(n.canonical));return t.ad.multiply(new Float64Array(16),e.globeMatrix,r)}createInversionMatrix(e,i){const{center:n}=e,r=ju($u(i));return t.ad.rotateY(r,r,Ge(n.lng)),t.ad.rotateX(r,r,Ge(n.lat)),t.ad.scale(r,r,[e._pixelsPerMercatorPixel,e._pixelsPerMercatorPixel,1]),Float32Array.from(r)}pointCoordinate(t,e,i,n){return Iu(t,e,i,!0)||new Rd(0,0)}pointCoordinate3D(t,e,i){const n=this.pointCoordinate(t,e,i,0);return[n.x,n.y,n.z]}isPointAboveHorizon(t,e){return!Iu(t,e.x,e.y,!1)}farthestPixelDistance(e){const i=function(e,i){const n=e.cameraToCenterDistance,r=e._centerAltitude*i,o=e._camera,s=e._camera.forward(),a=t._.add([],t._.scale([],s,-n),[0,0,r]),l=e.worldSize/(2*Math.PI),c=[0,0,-l],d=e.width/e.height,u=Math.tan(e.fovAboveCenter),h=t._.scale([],o.up(),u),p=t._.scale([],o.right(),u*d),f=t._.normalize([],t._.add([],t._.add([],s,h),p)),m=[];let _;if(new mu(a,f).closestPointOnSphere(c,l,m)){const i=t._.add([],m,c),n=t._.sub([],i,a);_=Math.cos(e.fovAboveCenter)*t._.length(n)}else{const e=t._.sub([],a,c),i=t._.sub([],c,a);t._.normalize(i,i);const n=t._.length(e)-l;_=Math.sqrt(n*(n+2*l));const r=Math.acos(_/(l+n))-Math.acos(t._.dot(s,i));_*=Math.cos(r)}return 1.01*_}(e,this.pixelsPerMeter(e.center.lat,e.worldSize)),n=Hu(e.zoom);if(n>0){const t=tg(e,Cd(1,e.center.lat)*e.worldSize),r=e.worldSize/(2*Math.PI),o=Math.max(e.width,e.height)/e.worldSize*Math.PI;return Vn(i,t+r*(1-Math.cos(o)),Math.pow(n,10))}return i}upVector(t,e,i){return Fu(e,i,t,1)}upVectorScale(t){return{metersToTile:Cu(Nu($u(t)))}}}function Tg(t){const e=t.parallels,i=!!e&&Math.abs(e[0]+e[1])0&&(this.iconTransitioningVertexBuffer=t.createVertexBuffer(this.iconTransitioningVertexArray,Vf.members,!0)),this.globeExtVertexArray.length>0&&(this.globeExtVertexBuffer=t.createVertexBuffer(this.globeExtVertexArray,Ff.members,!0)),!this.zOffsetVertexBuffer&&(this.zOffsetVertexArray.length>0||r)&&(this.zOffsetVertexBuffer=t.createVertexBuffer(this.zOffsetVertexArray,jf.members,!0)),this.opacityVertexBuffer.itemSize=1),(i||n)&&this.programConfigurations.upload(t))}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy(),this.dynamicLayoutVertexBuffer.destroy(),this.opacityVertexBuffer.destroy(),this.occlusionQueryOpacityVertexBuffer.destroy(),this.iconTransitioningVertexBuffer&&this.iconTransitioningVertexBuffer.destroy(),this.globeExtVertexBuffer&&this.globeExtVertexBuffer.destroy(),this.zOffsetVertexBuffer&&this.zOffsetVertexBuffer.destroy())}}ba(Ng,"SymbolBuffers");class Ug{constructor(t,e,i){this.layoutVertexArray=new t,this.layoutAttributes=e,this.indexArray=new i,this.segments=new wc,this.collisionVertexArray=new Xl,this.collisionVertexArrayExt=new Ol}upload(t){this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,this.layoutAttributes),this.indexBuffer=t.createIndexBuffer(this.indexArray),this.collisionVertexBuffer=t.createVertexBuffer(this.collisionVertexArray,Gf.members,!0),this.collisionVertexBufferExt=t.createVertexBuffer(this.collisionVertexArrayExt,Zf.members,!0)}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.segments.destroy(),this.collisionVertexBuffer.destroy(),this.collisionVertexBufferExt.destroy())}}ba(Ug,"CollisionBuffers");class jg{constructor(e){this.queries=new Map,this.collisionBoxArray=e.collisionBoxArray,this.zoom=e.zoom,this.lut=e.lut,this.overscaling=e.overscaling,this.layers=e.layers,this.layerIds=this.layers.map((t=>t.fqid)),this.index=e.index,this.pixelRatio=e.pixelRatio,this.sourceLayerIndex=e.sourceLayerIndex,this.hasPattern=!1,this.hasRTLText=!1,this.fullyClipped=!1,this.hasAnyIconTextFit=!1,this.sortKeyRanges=[],this.collisionCircleArray=[],this.placementInvProjMatrix=t.ad.identity([]),this.placementViewportMatrix=t.ad.identity([]);const i=this.layers[0]._unevaluatedLayout._values;this.textSizeData=Fm(this.zoom,i["text-size"]),this.iconSizeData=Fm(this.zoom,i["icon-size"]);const n=this.layers[0].layout,r=n.get("symbol-sort-key"),o=n.get("symbol-z-order");this.canOverlap=n.get("text-allow-overlap")||n.get("icon-allow-overlap")||n.get("text-ignore-placement")||n.get("icon-ignore-placement"),this.sortFeaturesByKey="viewport-y"!==o&&void 0!==r.constantOr(1),this.sortFeaturesByY=("viewport-y"===o||"auto"===o&&!this.sortFeaturesByKey)&&this.canOverlap,this.writingModes=n.get("text-writing-mode").map((t=>Jm[t])),this.stateDependentLayerIds=this.layers.filter((t=>t.isStateDependent())).map((t=>t.id)),this.sourceID=e.sourceID,this.projection=e.projection,this.hasAnyZOffset=!1,this.zOffsetSortDirty=!1,this.zOffsetBuffersNeedUpload=n.get("symbol-z-elevate"),this.activeReplacements=[],this.replacementUpdateTime=0}createArrays(){this.text=new Ng(new Yc(this.layers,{zoom:this.zoom,lut:this.lut},(t=>/^text/.test(t)))),this.icon=new Ng(new Yc(this.layers,{zoom:this.zoom,lut:this.lut},(t=>/^icon/.test(t)))),this.glyphOffsetArray=new mc,this.lineVertexArray=new _c,this.symbolInstances=new fc}calculateGlyphDependencies(t,e,i,n,r){for(let i=0;i0)&&("constant"!==l.value.kind||l.value.value.length>0),h="constant"!==d.value.kind||!!d.value.value||Object.keys(d.parameters).length>0,p=s.get("symbol-sort-key");if(this.features=[],!u&&!h)return;const f=i.iconDependencies,m=i.glyphDependencies,_=i.availableImages,g=new Ha(this.zoom);for(const{feature:i,id:c,index:d,sourceLayerIndex:y}of e){const e=o._featureFilter.needGeometry,v=Zd(i,e);if(!o._featureFilter.filter(g,v,n))continue;if(e||(v.geometry=Gd(i,n,r)),a&&1!==i.type&&n.z{const o=Fu(e.x,e.y,n,1),s=Fu(r.x,r.y,n,1);return t._.dot(o,s)=0;for(const i of x.sections)if(i.image)f[i.image.namePrimary]=!0;else{const n=Ca(x.toString()),r=i.fontStack||t,o=m[r]=m[r]||{};this.calculateGlyphDependencies(i.text,o,e,this.allowVerticalPlacement,n)}}}"line"===s.get("symbol-placement")&&(this.features=function(t){const e={},i={},n=[];let r=0;function o(e){n.push(t[e]),r++}function s(t,e,r){const o=i[t];return delete i[t],i[e]=o,n[o].geometry[0].pop(),n[o].geometry[0]=n[o].geometry[0].concat(r[0]),o}function a(t,i,r){const o=e[i];return delete e[i],e[t]=o,n[o].geometry[0].shift(),n[o].geometry[0]=r[0].concat(n[o].geometry[0]),o}function l(t,e,i){const n=i?e[0][e[0].length-1]:e[0][0];return`${t}:${n.x}:${n.y}`}for(let c=0;ct.geometry))}(this.features)),this.sortFeaturesByKey&&this.features.sort(((t,e)=>t.sortKey-e.sortKey))}update(t,e,i,n,r){const o=0!==Object.keys(t).length;if(o&&!this.stateDependentLayers.length)return;const s=o?this.stateDependentLayers:this.layers;this.text.programConfigurations.updatePaintArrays(t,e,s,i,n,r),this.icon.programConfigurations.updatePaintArrays(t,e,s,i,n,r)}updateOcclusionOpacities(t,e,i){if(!e.useOcclusionQueries)return!1;const n=this;if("globe"===n.projection.name)return!1;let r=!1;n.hasTextData()&&(r=r||0!==n.text.occlusionQueryOpacityVertexArray.length),n.hasIconData()&&(r=r||0!==n.icon.occlusionQueryOpacityVertexArray.length);const o=n.layers[0].paint,s=o.get("icon-occlusion-opacity").constantOr(0),a=o.get("text-occlusion-opacity").constantOr(0);if(!n.layers[0].hasInitialOcclusionOpacityProperties||1===s&&1===a)return!1;let l=!r;for(let t=0;t.5?1:-1)*e.fadeSpeed*i*.001,r.occlusionOpacity=Xe(r.occlusionOpacity,0,1),l=l||r.occlusionOpacity!==o}if(!l)return!1;let c=0,d=0;const u=(t,e,i,n)=>{let r=0,o=0;i?(r=d,d+=n,o=d):(r=c,c+=n,o=c),o>e.occlusionQueryOpacityVertexArray.length&&e.occlusionQueryOpacityVertexArray.resize(o);const s=t.occlusionOpacity;for(let t=0;t0;if((i>0||r>0)&&(u(e,n.text,!1,i),u(e,n.text,!1,r)),s){const{placedIconSymbolIndex:t,verticalPlacedIconSymbolIndex:i}=e;t>=0&&u(e,n.icon,!0,o),i>=0&&u(e,n.icon,!0,e.numVerticalIconVertices)}}return n.hasTextData()&&n.text.occlusionQueryOpacityVertexBuffer&&(n.text.occlusionQueryOpacityVertexBuffer.length{i+=e,i>t.length&&t.resize(i);for(let r=-e;r{n+=e,n>t.length&&t.resize(n);for(let r=-e;r0;if((r>0||o>0)&&(t(this.text.zOffsetVertexArray,r,a),t(this.text.zOffsetVertexArray,o,a)),l){const{placedIconSymbolIndex:t,verticalPlacedIconSymbolIndex:i}=n;t>=0&&e(this.icon.zOffsetVertexArray,s,a),i>=0&&e(this.icon.zOffsetVertexArray,n.numVerticalIconVertices,a)}}this.text.zOffsetVertexBuffer&&this.text.zOffsetVertexBuffer.updateData(this.text.zOffsetVertexArray),this.icon.zOffsetVertexBuffer&&this.icon.zOffsetVertexBuffer.updateData(this.icon.zOffsetVertexArray)}isEmpty(){return 0===this.symbolInstances.length&&!this.hasRTLText}uploadPending(){return!this.uploaded||this.text.programConfigurations.needsUpload||this.icon.programConfigurations.needsUpload}upload(t){!this.uploaded&&this.hasDebugData()&&(this.textCollisionBox.upload(t),this.iconCollisionBox.upload(t)),this.text.upload(t,this.sortFeaturesByY,!this.uploaded,this.text.programConfigurations.needsUpload,this.zOffsetBuffersNeedUpload),this.icon.upload(t,this.sortFeaturesByY,!this.uploaded,this.icon.programConfigurations.needsUpload,this.zOffsetBuffersNeedUpload),this.uploaded=!0}destroyDebugData(){this.textCollisionBox.destroy(),this.iconCollisionBox.destroy()}getProjection(){return this.projectionInstance||(this.projectionInstance=Tg(this.projection)),this.projectionInstance}destroy(){this.text.destroy(),this.icon.destroy(),this.hasDebugData()&&this.destroyDebugData();for(const t of this.queries.values())t.destroy()}addToLineVertexArray(t,e){const i=this.lineVertexArray.length;if(void 0!==t.segment)for(const{x:t,y:i}of e)this.lineVertexArray.emplaceBack(t,i);return{lineStartIndex:i,lineLength:this.lineVertexArray.length-i}}addSymbols(t,e,i,n,r,o,s,a,l,c,d,u,h,p,f,m){const _=t.indexArray,g=t.layoutVertexArray,y=t.globeExtVertexArray,v=t.segments.prepareSegment(4*e.length,g,_,this.canOverlap?o.sortKey:void 0),x=this.glyphOffsetArray.length,b=v.vertexLength,w=this.allowVerticalPlacement&&s===Jm.vertical?Math.PI/2:0,T=o.text&&o.text.sections;for(let n=0;n=0?e.rightJustifiedTextSymbolIndex:e.centerJustifiedTextSymbolIndex>=0?e.centerJustifiedTextSymbolIndex:e.leftJustifiedTextSymbolIndex>=0?e.leftJustifiedTextSymbolIndex:e.verticalPlacedTextSymbolIndex>=0?e.verticalPlacedTextSymbolIndex:n),o=Nm(this.textSizeData,t,r)/Om;return this.tilePixelRatio*o}getSymbolInstanceIconSize(t,e,i){const n=this.icon.placedSymbolArray.get(i),r=Nm(this.iconSizeData,t,n);return this.tilePixelRatio*r}_commitDebugCollisionVertexUpdate(t,e,i,n){t.emplaceBack(e,-i,-i,n),t.emplaceBack(e,i,-i,n),t.emplaceBack(e,i,i,n),t.emplaceBack(e,-i,i,n)}_updateTextDebugCollisionBoxes(t,e,i,n,r,o){for(let s=n;s0}hasIconData(){return this.icon.segments.get().length>0}hasDebugData(){return this.textCollisionBox&&this.iconCollisionBox}hasTextCollisionBoxData(){return this.hasDebugData()&&this.textCollisionBox.segments.get().length>0}hasIconCollisionBoxData(){return this.hasDebugData()&&this.iconCollisionBox.segments.get().length>0}hasIconTextFit(){return this.hasAnyIconTextFit}addIndicesForPlacedSymbol(t,e){const i=t.placedSymbolArray.get(e),n=i.vertexStartIndex+4*i.numGlyphs;for(let e=i.vertexStartIndex;en[t]-n[e]||r[e]-r[t])),o}getSortedIndexesByZOffset(){if(!this.zOffsetSortDirty)return this.symbolInstanceIndexesSortedZOffset;if(!this.symbolInstanceIndexesSortedZOffset){this.symbolInstanceIndexesSortedZOffset=[];for(let t=0;tthis.symbolInstances.get(e).zOffset-this.symbolInstances.get(t).zOffset))}addToSortKeyRanges(t,e){const i=this.sortKeyRanges[this.sortKeyRanges.length-1];i&&i.sortKey===e?i.symbolInstanceEnd=t+1:this.sortKeyRanges.push({sortKey:e,symbolInstanceStart:t,symbolInstanceEnd:t+1})}sortFeatures(t){if(this.sortFeaturesByY&&this.sortedAngle!==t&&!(this.text.segments.get().length>1||this.icon.segments.get().length>1)){this.symbolInstanceIndexes=this.getSortedSymbolIndexes(t),this.sortedAngle=t,this.text.indexArray.clear(),this.icon.indexArray.clear(),this.featureSortOrder=[];for(const t of this.symbolInstanceIndexes){const e=this.symbolInstances.get(t);this.featureSortOrder.push(e.featureIndex);const{rightJustifiedTextSymbolIndex:i,centerJustifiedTextSymbolIndex:n,leftJustifiedTextSymbolIndex:r,verticalPlacedTextSymbolIndex:o,placedIconSymbolIndex:s,verticalPlacedIconSymbolIndex:a}=e;i>=0&&this.addIndicesForPlacedSymbol(this.text,i),n>=0&&n!==i&&this.addIndicesForPlacedSymbol(this.text,n),r>=0&&r!==n&&r!==i&&this.addIndicesForPlacedSymbol(this.text,r),o>=0&&this.addIndicesForPlacedSymbol(this.text,o),s>=0&&this.addIndicesForPlacedSymbol(this.icon,s),a>=0&&this.addIndicesForPlacedSymbol(this.icon,a)}this.text.indexBuffer&&this.text.indexBuffer.updateData(this.text.indexArray),this.icon.indexBuffer&&this.icon.indexBuffer.updateData(this.icon.indexArray)}}}ba(jg,"SymbolBucket",{omit:["layers","collisionBoxArray","features","compareText"]}),jg.addDynamicAttributes=Bg;class Vg{constructor(t,e,i,n){this.context=t,this.format=i,this.texture=t.gl.createTexture(),this.update(e,n)}update(t,e,i){const{width:n,height:r}=t,{context:o}=this,{gl:s}=o;if(s.bindTexture(s.TEXTURE_2D,this.texture),o.pixelStoreUnpackFlipY.set(!1),o.pixelStoreUnpack.set(1),o.pixelStoreUnpackPremultiplyAlpha.set(this.format===s.RGBA&&(!e||!1!==e.premultiply)),this.useMipmap=Boolean(e&&e.useMipmap),i||this.size&&this.size[0]===n&&this.size[1]===r){const{x:e,y:o}=i||{x:0,y:0};if(t instanceof HTMLImageElement||t instanceof HTMLCanvasElement||t instanceof HTMLVideoElement||t instanceof ImageData||ImageBitmap&&t instanceof ImageBitmap)s.texSubImage2D(s.TEXTURE_2D,0,e,o,s.RGBA,s.UNSIGNED_BYTE,t);else{let i=this.format,a=s.UNSIGNED_BYTE;this.format===s.R32F&&(i=s.RED,a=s.FLOAT),s.texSubImage2D(s.TEXTURE_2D,0,e,o,n,r,i,a,t.data)}}else if(this.size=[n,r],t instanceof HTMLImageElement||t instanceof HTMLCanvasElement||t instanceof HTMLVideoElement||t instanceof ImageData||ImageBitmap&&t instanceof ImageBitmap){let e=this.format;this.format===s.R8&&(e=s.RED),s.texImage2D(s.TEXTURE_2D,0,this.format,e,s.UNSIGNED_BYTE,t)}else{let e=this.format,i=this.format,o=s.UNSIGNED_BYTE,a=!1;this.format===s.DEPTH_COMPONENT&&(e=s.DEPTH_COMPONENT16,o=s.UNSIGNED_SHORT),this.format===s.DEPTH_STENCIL&&(e=s.DEPTH24_STENCIL8,o=s.UNSIGNED_INT_24_8,a=!0),this.format===s.R8&&(i=s.RED),this.format===s.R32F&&(o=s.FLOAT,i=s.RED),!this.useMipmap&&a?s.texStorage2D(s.TEXTURE_2D,1,e,n,r):s.texImage2D(s.TEXTURE_2D,0,e,n,r,0,i,o,t.data)}this.useMipmap&&s.generateMipmap(s.TEXTURE_2D)}bind(t,e,i=!1){const{context:n}=this,{gl:r}=n;r.bindTexture(r.TEXTURE_2D,this.texture),t!==this.minFilter&&(r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MAG_FILTER,t),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MIN_FILTER,this.useMipmap&&!i?t===r.NEAREST?r.NEAREST_MIPMAP_NEAREST:r.LINEAR_MIPMAP_LINEAR:t),this.minFilter=t),e!==this.wrapS&&(r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_S,e),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_T,e),this.wrapS=e)}bindExtraParam(t,e,i,n){const{context:r}=this,{gl:o}=r;o.bindTexture(o.TEXTURE_2D,this.texture),e!==this.magFilter&&(o.texParameteri(o.TEXTURE_2D,o.TEXTURE_MAG_FILTER,e),this.magFilter=e),t!==this.minFilter&&(o.texParameteri(o.TEXTURE_2D,o.TEXTURE_MIN_FILTER,this.useMipmap?t===o.NEAREST?o.NEAREST_MIPMAP_NEAREST:o.LINEAR_MIPMAP_LINEAR:t),this.minFilter=t),i!==this.wrapS&&(o.texParameteri(o.TEXTURE_2D,o.TEXTURE_WRAP_S,i),this.wrapS=i),n!==this.wrapT&&(o.texParameteri(o.TEXTURE_2D,o.TEXTURE_WRAP_T,n),this.wrapT=n)}destroy(){const{gl:t}=this.context;t.deleteTexture(this.texture),this.texture=null}}class Gg{constructor(t,e){this.context=t,this.texture=e}bind(t,e){const{context:i}=this,{gl:n}=i;n.bindTexture(n.TEXTURE_2D,this.texture),t!==this.minFilter&&(n.texParameteri(n.TEXTURE_2D,n.TEXTURE_MAG_FILTER,t),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_MIN_FILTER,t),this.minFilter=t),e!==this.wrapS&&(n.texParameteri(n.TEXTURE_2D,n.TEXTURE_WRAP_S,e),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_WRAP_T,e),this.wrapS=e)}}const Zg=32,qg=33,Hg=new Uint16Array(8184);for(let t=0;t>=1)>1;){const t=i+r>>1,l=n+o>>1;1&e?(r=i,o=n,i=s,n=a):(i=r,n=o,r=s,o=a),s=t,a=l}const l=4*t;Hg[l+0]=i,Hg[l+1]=n,Hg[l+2]=r,Hg[l+3]=o}const Wg=new Uint16Array(2178),Yg=new Uint8Array(1089),Xg=new Uint16Array(1089);function Kg(t){return 0===t?-.03125:32===t?.03125:0}var Jg=Ll([{name:"a_pos",type:"Int16",components:2},{name:"a_texture_pos",type:"Int16",components:2}]),Qg=Ll([{name:"a_index",type:"Int16",components:1}]);const ty={type:2,extent:uo,loadGeometry:()=>[[new Ue(0,0),new Ue(uo+1,0),new Ue(uo+1,uo+1),new Ue(0,uo+1),new Ue(0,0)]]};class ey{constructor(t,e,i,n,r){this.tileID=t,this.uid=ni(),this.uses=0,this.tileSize=e,this.tileZoom=i,this.buckets={},this.expirationTime=null,this.queryPadding=0,this.hasSymbolBuckets=!1,this.hasRTLText=!1,this.dependencies={},this.isRaster=r,n&&n.style&&(this._lastUpdatedBrightness=n.style.getBrightness()),this.expiredRequestCount=0,this.state="loading",n&&n.transform&&(this.projection=n.transform.projection)}registerFadeDuration(t){const e=t+this.timeAdded;ee.getLayer(t))).filter(Boolean);if(0!==t.length){n.layers=t,n.stateDependentLayerIds&&(n.stateDependentLayers=n.stateDependentLayerIds.map((e=>t.filter((t=>t.id===e))[0])));for(const e of t)i[e.fqid]=n}}return i}(t.buckets,e.style),this.hasSymbolBuckets=!1;for(const t in this.buckets){const e=this.buckets[t];if(e instanceof jg){if(this.hasSymbolBuckets=!0,!i)break;e.justReloaded=!0}}if(this.hasRTLText=!1,this.hasSymbolBuckets)for(const t in this.buckets){const e=this.buckets[t];if(e instanceof jg&&e.hasRTLText){this.hasRTLText=!0,qa.isLoading()||qa.isLoaded()||"deferred"!==Ga()||Za();break}}this.queryPadding=0;for(const t in this.buckets){const i=this.buckets[t],n=e.style.getOwnLayer(t);if(!n)continue;const r=n.queryRadius(i);this.queryPadding=Math.max(this.queryPadding,r)}t.imageAtlas&&(this.imageAtlas=t.imageAtlas),t.glyphAtlasImage&&(this.glyphAtlasImage=t.glyphAtlasImage),t.lineAtlas&&(this.lineAtlas=t.lineAtlas),this._lastUpdatedBrightness=t.brightness}else this.collisionBoxArray=new dc}unloadVectorData(){if(this.hasData()){for(const t in this.buckets)this.buckets[t].destroy();this.buckets={},this.imageAtlas&&(this.imageAtlas=null),this.lineAtlas&&(this.lineAtlas=null),this.imageAtlasTexture&&this.imageAtlasTexture.destroy(),this.glyphAtlasTexture&&this.glyphAtlasTexture.destroy(),this.lineAtlasTexture&&this.lineAtlasTexture.destroy(),this._tileBoundsBuffer&&(this._tileBoundsBuffer.destroy(),this._tileBoundsIndexBuffer.destroy(),this._tileBoundsSegments.destroy(),this._tileBoundsBuffer=null),this._tileDebugBuffer&&(this._tileDebugBuffer.destroy(),this._tileDebugSegments.destroy(),this._tileDebugBuffer=null),this._tileDebugIndexBuffer&&(this._tileDebugIndexBuffer.destroy(),this._tileDebugIndexBuffer=null),this._globeTileDebugBorderBuffer&&(this._globeTileDebugBorderBuffer.destroy(),this._globeTileDebugBorderBuffer=null),this._tileDebugTextBuffer&&(this._tileDebugTextBuffer.destroy(),this._tileDebugTextSegments.destroy(),this._tileDebugTextIndexBuffer.destroy(),this._tileDebugTextBuffer=null),this._globeTileDebugTextBuffer&&(this._globeTileDebugTextBuffer.destroy(),this._globeTileDebugTextBuffer=null),this.latestFeatureIndex=null,this.state="unloaded"}}getBucket(t){return this.buckets[t.fqid]}upload(t){for(const e in this.buckets){const i=this.buckets[e];i.uploadPending()&&i.upload(t)}const e=t.gl,i=this.imageAtlas;if(i&&!i.uploaded){const n=!!Object.keys(i.patternPositions).length;this.imageAtlasTexture=new Vg(t,i.image,e.RGBA,{useMipmap:n}),this.imageAtlas.uploaded=!0}this.glyphAtlasImage&&(this.glyphAtlasTexture=new Vg(t,this.glyphAtlasImage,e.R8),this.glyphAtlasImage=null),this.lineAtlas&&!this.lineAtlas.uploaded&&(this.lineAtlasTexture=new Vg(t,this.lineAtlas.image,e.R8),this.lineAtlas.uploaded=!0)}prepare(t,e,i){if(this.imageAtlas&&this.imageAtlasTexture&&this.imageAtlas.patchUpdatedImages(t,this.imageAtlasTexture,i),!e||!this.latestFeatureIndex||!this.latestFeatureIndex.rawTileData)return;const n=e.style.getBrightness();(this._lastUpdatedBrightness||n)&&(this._lastUpdatedBrightness&&n&&Math.abs(this._lastUpdatedBrightness-n)t)i=!1;else if(e)if(this.expirationTime=0;t--){const e=4*t,i=Hg[e+0],n=Hg[e+1],r=Hg[e+2],o=Hg[e+3],s=i+r>>1,a=n+o>>1,l=s+a-n,c=a+i-s,d=n*qg+i,u=o*qg+r,h=a*qg+s,p=Math.hypot((Wg[2*d+0]+Wg[2*u+0])/2-Wg[2*h+0],(Wg[2*d+1]+Wg[2*u+1])/2-Wg[2*h+1])>=16;Yg[h]=Yg[h]||(p?1:0),t>1)*qg+(i+l>>1)]||Yg[(o+c>>1)*qg+(r+l>>1)])}const r=new Dl,o=new Kl;let s=0;function a(t,e){const i=e*qg+t;return 0===Xg[i]&&(r.emplaceBack(Wg[2*i+0],Wg[2*i+1],t*uo/Zg,e*uo/Zg),Xg[i]=++s),Xg[i]-1}function l(t,e,i,n,r,s){const c=t+i>>1,d=e+n>>1;if(Math.abs(t-r)+Math.abs(e-s)>1&&Yg[d*qg+c])l(r,s,t,e,c,d),l(i,n,r,s,c,d);else{const l=a(t,e),c=a(i,n),d=a(r,s);o.emplaceBack(l,c,d)}}return l(0,0,Zg,Zg,Zg,0),l(Zg,Zg,0,0,0,Zg),{vertices:r,indices:o}}(this.tileID.canonical,e);n=t.vertices,r=t.indices}else{n=new Dl,r=new Kl;for(const{x:t,y:e}of i)n.emplaceBack(t,e,0,0);const t=xh(n.int16,void 0,4);for(let e=0;e0&&(a=t.ad.invert(new Float64Array(16),i.globeMatrix)),this._makeGlobeTileDebugBorderBuffer(e,r,i,o,a,s),this._makeGlobeTileDebugTextBuffer(e,r,i,o,a,s)}_globePoint(e,i,n,r,o,s,a){let l=Fu(e,i,n);if(s){const o=1.5?h=-1:u{const p=(d-t)/(h-1),f=(u-c)/(h-1),m=s.length;for(let d=0;dd*t+e;for(let t=0;t[t,this.get(t)]))}evict(t=!1){if(t||this.size>0){const t=this.first;delete this.items[t.key],0==--this.size?(this.first=null,this.last=null):(this.first=t.next,this.first.prev=null)}return this}expiresAt(t){let e;return this.has(t)&&(e=this.items[t].expiry),e}get(t){let e;if(this.has(t)){const i=this.items[t];this.ttl>0&&i.expiry0?Date.now()+this.ttl:this.ttl),this.last!==r){const t=this.last,e=r.next,i=r.prev;this.first===r&&(this.first=r.next),r.next=null,r.prev=this.last,t.next=r,null!==i&&(i.next=e),null!==e&&(e.prev=i)}}else this.max>0&&this.size===this.max&&this.evict(!0),r=this.items[t]={expiry:this.ttl>0?Date.now()+this.ttl:this.ttl,key:t,prev:this.last,next:null,value:e},1==++this.size?this.first=r:this.last.next=r;return this.last=r,this}values(t=this.keys()){return t.map((t=>this.get(t)))}}function uy(t,e){if(4!==e.length)throw new Error(`Expected data of dimension 4 but got ${e.length}.`);let i=e[3];for(let n=2;n>=1;n--){const r=1===n?1:0,o=2===n?1:0;for(let n=0;n>>1^-(1&t[e]);return t}function py(t,e){switch(e){case"uint32":return t;case"uint16":for(let e=0;e>4|(61440&i)>>8|(240&n)>4|(15&n)>6|(192&n)>>4|(192&r)>>2|192&o,t[e+1]=(48&i)>>4|(48&n)>>2|48&r|(48&o)>2|12&n|(12&r)>1|(21845&Cy)>2|(13107&Ay)>4|(3855&Ay)>8|(255&Ay)>1}var Iy=function(t,e,i){for(var n=t.length,r=0,o=new _y(e);r>l]=c}else for(s=new _y(n),r=0;r>15-t[r]);return s},Ly=new my(288);for(Cy=0;Cye&&(e=t[i]);return e},zy=function(t,e,i){var n=e/8|0;return(t[n]|t[n+1]>(7&e)&i},Ry=function(t,e){var i=e/8|0;return(t[i]|t[i+1]>(7&e)},Oy=["unexpected EOF","invalid block type","invalid length/literal","invalid distance","stream finished","no stream handler",,"no callback","invalid UTF-8 data","extra field too long","date not in range 1980-2099","filename too long","stream finishing","invalid zip data"],By=function(t,e,i){var n=new Error(e||Oy[t]);if(n.code=t,Error.captureStackTrace&&Error.captureStackTrace(n,By),!i)throw n;return n},Fy=new my(0),Ny="undefined"!=typeof TextDecoder&&new TextDecoder;try{Ny.decode(Fy,{stream:!0})}catch(t){}const Uy={gzip_data:"gzip"},jy={0:"uint32",1:"uint32",2:"uint16",3:"uint8"},Vy={uint32:1,uint16:2,uint8:4},Gy={uint32:Uint32Array,uint16:Uint16Array,uint8:Uint8Array};class Zy{constructor(t=1){this.x=NaN,this.y=NaN,this.z=NaN,this.layers={},this._cacheSize=t}getLayer(t){return this.layers[t]}getHeaderLength(t){const e=new Uint8Array(t),i=new DataView(t);if(13!==e[0])throw new fy("File is not a valid MRT.");return i.getUint32(1,!0)}parseHeader(t){const e=new Uint8Array(t),i=this.getHeaderLength(t);if(e.length= ${i} but got buffer of length ${e.length}`);const n=function(t){return t.readFields(iy,{header_length:0,x:0,y:0,z:0,layers:[]},void 0)}(new Lm(e.subarray(0,i)));if(!isNaN(this.x)&&(this.x!==n.x||this.y!==n.y||this.z!==n.z))throw new fy(`Invalid attempt to parse header ${n.z}/${n.x}/${n.y} for tile ${this.z}/${this.x}/${this.y}`);this.x=n.x,this.y=n.y,this.z=n.z;for(const t of n.layers)this.layers[t.name]=new qy(t,{cacheSize:this._cacheSize});return this}createDecodingTask(t){const e=[],i=this.getLayer(t.layerName);for(let n=0;nt.lastBlock)continue;if(i._blocksInProgress.has(n))continue;const a={layerName:i.name,firstByte:o,lastByte:s,pixelFormat:i.pixelFormat,blockIndex:n,blockShape:[r.bands.length].concat(i.bandShape),buffer:i.buffer,codec:r.codec.codec,filters:r.filters.map((t=>t.filter))};i._blocksInProgress.add(n),e.push(a)}return new Hy(e,(()=>{e.forEach((t=>i._blocksInProgress.delete(t.blockIndex)))}),((t,n)=>{if(e.forEach((t=>i._blocksInProgress.delete(t.blockIndex))),t)throw t;n.forEach((t=>{this.getLayer(t.layerName).processDecodedData(t)}))}))}}class qy{constructor({version:t,name:e,units:i,tilesize:n,pixel_format:r,buffer:o,data_index:s},a){if(this.version=t,1!==this.version)throw new fy(`Cannot parse raster layer encoded with MRT version ${t}`);this.name=e,this.units=i,this.tileSize=n,this.buffer=o,this.pixelFormat=jy[r],this.dataIndex=s,this.bandShape=[n+2*o,n+2*o,Vy[this.pixelFormat]],this._decodedBlocks=function(t=1e3,e=0,i=!1){if(isNaN(t)||t=e&&t=0}hasDataForBand(t){const{blockIndex:e}=this.getBlockForBand(t);return e>=0&&!!this._decodedBlocks.get(e.toString())}getBandView(t){const{blockIndex:e,blockBandIndex:i}=this.getBlockForBand(t),n=this._decodedBlocks.get(e.toString());if(!n)throw new fy(`Data for band ${JSON.stringify(t)} of layer "${this.name}" not decoded.`);const r=this.dataIndex[e],o=this.bandShape.reduce(((t,e)=>t*e),1),s=i*o,a=n.subarray(s,s+o);return{data:a,bytes:new Uint8Array(a.buffer).subarray(a.byteOffset,a.byteOffset+a.byteLength),tileSize:this.tileSize,buffer:this.buffer,offset:r.offset,scale:r.scale}}}class Hy{constructor(t,e,i){this.tasks=t,this._onCancel=e,this._onComplete=i,this._finalized=!1}cancel(){this._finalized||(this._onCancel(),this._finalized=!0)}complete(t,e){this._finalized||(this._onComplete(t,e),this._finalized=!0)}}Zy.performDecoding=function(t,e){return Promise.all(e.tasks.map((e=>{const{layerName:i,firstByte:n,lastByte:r,pixelFormat:o,blockShape:s,blockIndex:a,filters:l,codec:c}=e,d=new Uint8Array(t).subarray(n,r+1),u=new Uint32Array(s[0]*s[1]*s[2]);let h;if("gzip_data"!==c)throw new Error(`Unhandled codec: ${c}`);return h=function(t,e){if(!globalThis.DecompressionStream&&"gzip_data"===e)return Promise.resolve(((o=function(t){31==t[0]&&139==t[1]&&8==t[2]||By(6,"invalid gzip data");var e=t[3],i=10;4&e&&(i+=2+(t[10]|t[11]>3&1)+(e>>4&1);n>0;n-=!t[i++]);return i+(2&e)}(r=t))+8>r.length&&By(6,"invalid gzip data"),function(t,e,i){var n=t.length;if(!n||e.f&&!e.l)return i||new my(0);var r=!i,o=r||2!=e.i,s=e.i;r&&(i=new my(3*n));var a,l,c=function(t){var e=i.length;if(t>e){var n=new my(Math.max(2*e,t));n.set(i),i=n}},d=e.f||0,u=e.p||0,h=e.b||0,p=e.l,f=e.d,m=e.m,_=e.n,g=8*n;do{if(!p){d=zy(t,u,1);var y=zy(t,u+1,3);if(u+=3,!y){var v=t[(L=4+((u+7)/8|0))-4]|t[L-3]n){s&&By(0);break}o&&c(h+v),i.set(t.subarray(L,x),h),e.b=h+=v,e.p=u=8*x,e.f=d;continue}if(1==y)p=$y,f=ky,m=9,_=5;else if(2==y){var b=zy(t,u,31)+257,w=zy(t,u+10,15)+4,T=b+zy(t,u+5,31)+1;u+=14;for(var S=new my(T),E=new my(19),M=0;M>4)g){s&&By(0);break}}o&&c(h+131072);for(var R=(1>4;if((u+=15&$)>g){s&&By(0);break}if($||By(2),F264&&(N=zy(t,u,(1>4;if(U||By(3),u+=15&U,z=Ey[j],j>3){var V=vy[j];z+=Ry(t,u)&(1g){s&&By(0);break}o&&c(h+131072);var G=h+N;if(ha.length)&&(l=a.length),new my(a.subarray(0,l))):i.subarray(0,h)}(r.subarray(o,-8),{i:2},new my(((i=r)[(n=i.length)-4]|i[n-3]>>0))));var i,n,r,o;const s=Uy[e];if(!s)throw new Error(`Unhandled codec: ${e}`);const a=new globalThis.DecompressionStream(s);return new Response(new Blob([t]).stream().pipeThrough(a)).arrayBuffer().then((t=>new Uint8Array(t)))}(d,c).then((t=>(function(t,e){t.readFields(ly,e)}(new Lm(t),u),new(0,Gy[o])(u.buffer)))),h.then((t=>{for(let e=l.length-1;e>=0;e--)switch(l[e]){case"delta_filter":uy(t,s);break;case"zigzag_filter":hy(t);break;case"bitshuffle_filter":py(t,o);break;default:throw new Error(`Unhandled filter "${l[e]}"`)}return{layerName:i,blockIndex:a,data:t}})).catch((t=>{throw t}))})))};class Wy extends ey{constructor(t,e,i,n,r){super(t,e,i,n,r),this._workQueue=[],this._fetchQueue=[],this._isHeaderLoaded=!1}setTexture(t,e){const i=e.context,n=i.gl;this.texture=this.texture||e.getTileTexture(t.width),this.texture&&this.texture instanceof Vg?this.texture.update(t,{useMipmap:!1,premultiply:!1}):this.texture=new Vg(i,t,n.RGBA,{useMipmap:!1,premultiply:!1})}flushQueues(){for(;this._workQueue.length;)this._workQueue.pop()();for(;this._fetchQueue.length;)this._fetchQueue.pop()()}fetchHeader(t=16384,e){const i=this._mrt=new Zy(30),n=Object.assign({},this.requestParams,{headers:{Range:"bytes=0-"+(t-1)}});return this.entireBuffer=null,this.request=en(n,((n,r,o,s)=>{if(n)e(n);else try{const n=i.getHeaderLength(r);if(n>t)return void(this.request=this.fetchHeader(n,e));i.parseHeader(r),this._isHeaderLoaded=!0;let a=0;for(const t of Object.values(i.layers))a=Math.max(a,t.dataIndex[t.dataIndex.length-1].last_byte);r.byteLength>=a&&(this.entireBuffer=r),e(null,this.entireBuffer||r,o,s)}catch(t){e(t)}})),this.request}fetchBand(t,e,i){const n=this._mrt;if(!this._isHeaderLoaded||!n)return void i(new Error("Tile header is not ready"));const r=this.actor;if(!r)return void i(new Error("Can't fetch tile band without an actor"));let o;const s=(n,r)=>{o.complete(n,r),n?i(n):(this.updateTextureDescriptor(t,e),i(null,this.textureDescriptor&&this.textureDescriptor.img))},a=(t,e)=>{if(t)return i(t);const n=r.send("decodeRasterArray",{buffer:e,task:o},s,void 0,!0);this._workQueue.push((()=>{n&&n.cancel(),o.cancel()}))},l=n.getLayer(t);if(!l)return void i(new Error(`Unknown sourceLayer "${t}"`));if(l.hasDataForBand(e))return this.updateTextureDescriptor(t,e),void i(null,this.textureDescriptor?this.textureDescriptor.img:null);const c=l.getDataRange([e]);if(o=n.createDecodingTask(c),!o||o.tasks.length)if(this.flushQueues(),this.entireBuffer)a(null,this.entireBuffer.slice(c.firstByte,c.lastByte+1));else{const t=Object.assign({},this.requestParams,{headers:{Range:`bytes=${c.firstByte}-${c.lastByte}`}}),e=en(t,a);this._fetchQueue.push((()=>{e.cancel(),o.cancel()}))}else i(null)}updateNeeded(t,e){return(!this.textureDescriptor||this.textureDescriptor.band!==e||this.textureDescriptor.layer!==t)&&"errored"!==this.state}updateTextureDescriptor(t,e){if(!this._mrt)return;const i=this._mrt.getLayer(t);if(!i||!i.hasBand(e)||!i.hasDataForBand(e))return;const{bytes:n,tileSize:r,buffer:o,offset:s,scale:a}=i.getBandView(e),l=r+2*o,c={data:n,width:l,height:l},d=this.texture;d&&d instanceof Vg&&d.update(c,{useMipmap:!1,premultiply:!1}),this.textureDescriptor={layer:t,band:e,img:c,buffer:o,offset:s,tileSize:r,format:i.pixelFormat,mix:[a,256*a,65536*a,16777216*a]}}}class Yy{constructor(t,e){this.max=t,this.onRemove=e,this.reset()}reset(){for(const t in this.data)for(const e of this.data[t])e.timeout&&clearTimeout(e.timeout),this.onRemove(e.value);return this.data={},this.order=[],this}add(t,e,i){const n=t.wrapped().key;void 0===this.data[n]&&(this.data[n]=[]);const r={value:e,timeout:void 0};if(void 0!==i&&(r.timeout=setTimeout((()=>{this.remove(t,r)}),i)),this.data[n].push(r),this.order.push(n),this.order.length>this.max){const t=this._getAndRemoveByKey(this.order[0]);t&&this.onRemove(t)}return this}has(t){return t.wrapped().key in this.data}getAndRemove(t){return this.has(t)?this._getAndRemoveByKey(t.wrapped().key):null}_getAndRemoveByKey(t){const e=this.data[t].shift();return e.timeout&&clearTimeout(e.timeout),0===this.data[t].length&&delete this.data[t],this.order.splice(this.order.indexOf(t),1),e.value}getByKey(t){const e=this.data[t];return e?e[0].value:null}get(t){return this.has(t)?this.data[t.wrapped().key][0].value:null}remove(t,e){if(!this.has(t))return this;const i=t.wrapped().key,n=void 0===e?0:this.data[i].indexOf(e),r=this.data[i][n];return this.data[i].splice(n,1),r.timeout&&clearTimeout(r.timeout),0===this.data[i].length&&delete this.data[i],this.onRemove(r.value),this.order.splice(this.order.indexOf(i),1),this}setMaxSize(t){for(this.max=t;this.order.length>this.max;){const t=this._getAndRemoveByKey(this.order[0]);t&&this.onRemove(t)}return this}filter(t){const e=[];for(const i in this.data)for(const n of this.data[i])t(n.value)||e.push(n);for(const t of e)this.remove(t.value.tileID,t)}}class Xy extends zn{constructor(t,e,i){super(),this.id=t,this._onlySymbols=i,e.on("data",(t=>{"source"===t.dataType&&"metadata"===t.sourceDataType&&(this._sourceLoaded=!0),this._sourceLoaded&&!this._paused&&"source"===t.dataType&&"content"===t.sourceDataType&&(this.reload(),this.transform&&this.update(this.transform))})),e.on("error",(()=>{this._sourceErrored=!0})),this._source=e,this._tiles={},this._cache=new Yy(0,this._unloadTile.bind(this)),this._timers={},this._cacheTimers={},this._minTileCacheSize=e.minTileCacheSize,this._maxTileCacheSize=e.maxTileCacheSize,this._loadedParentTiles={},this.castsShadows=!1,this.tileCoverLift=0,this._coveredTiles={},this._shadowCasterTiles={},this._state=new km,this._isRaster="raster"===this._source.type||"raster-dem"===this._source.type||"raster-array"===this._source.type||"custom"===this._source.type&&"raster"===this._source._dataType}onAdd(t){this.map=t,this._minTileCacheSize=void 0===this._minTileCacheSize&&t?t._minTileCacheSize:this._minTileCacheSize,this._maxTileCacheSize=void 0===this._maxTileCacheSize&&t?t._maxTileCacheSize:this._maxTileCacheSize}loaded(){if(this._sourceErrored)return!0;if(!this._sourceLoaded)return!1;if(!this._source.loaded())return!1;for(const t in this._tiles){const e=this._tiles[t];if("errored"!==e.state&&("loaded"!==e.state||!e.bucketsLoaded()))return!1}return!0}getSource(){return this._source}pause(){this._paused=!0}resume(){if(!this._paused)return;const t=this._shouldReloadOnResume;this._paused=!1,this._shouldReloadOnResume=!1,t&&this.reload(),this.transform&&this.update(this.transform)}_loadTile(t,e){return t.isSymbolTile=this._onlySymbols,t.isExtraShadowCaster=this._shadowCasterTiles[t.tileID.key],this._source.loadTile(t,e)}_unloadTile(t){if(this._source.unloadTile)return this._source.unloadTile(t)}_abortTile(t){if(this._source.abortTile)return this._source.abortTile(t)}serialize(){return this._source.serialize()}prepare(t){this._source.prepare&&this._source.prepare(),this._state.coalesceChanges(this._tiles,this.map?this.map.painter:null);for(const e in this._tiles){const i=this._tiles[e];i.upload(t),i.prepare(this.map.style.imageManager,this.map?this.map.painter:null,this._source.scope)}}getIds(){return ti(this._tiles).map((t=>t.tileID)).sort(Ky).map((t=>t.key))}getRenderableIds(t,e){const i=[];for(const n in this._tiles)this._isIdRenderable(+n,t,e)&&i.push(this._tiles[n]);return t?i.sort(((t,e)=>{const i=t.tileID,n=e.tileID,r=new Ue(i.canonical.x,i.canonical.y)._rotate(this.transform.angle),o=new Ue(n.canonical.x,n.canonical.y)._rotate(this.transform.angle);return i.overscaledZ-n.overscaledZ||o.y-r.y||o.x-r.x})).map((t=>t.tileID.key)):i.map((t=>t.tileID)).sort(Ky).map((t=>t.key))}hasRenderableParent(t){const e=this.findLoadedParent(t,0);return!!e&&this._isIdRenderable(e.tileID.key)}_isIdRenderable(t,e,i){return this._tiles[t]&&this._tiles[t].hasData()&&!this._coveredTiles[t]&&(e||!this._tiles[t].holdingForFade())&&(i||!this._shadowCasterTiles[t])}reload(){if(this._paused)this._shouldReloadOnResume=!0;else{this._cache.reset();for(const t in this._tiles)"errored"!==this._tiles[t].state&&this._reloadTile(+t,"reloading")}}_reloadTile(t,e){const i=this._tiles[t];i&&("loading"!==i.state&&(i.state=e),this._loadTile(i,this._tileLoaded.bind(this,i,t,e)))}_tileLoaded(t,e,i,n){if(n)if(t.state="errored",404!==n.status)this._source.fire(new $n(n,{tile:t}));else{if(!(t.tileID.key in this._loadedParentTiles))return void this._source.fire(new Pn("data",{dataType:"source",sourceDataType:"error",sourceId:this._source.id}));if("raster-dem"===this._source.type&&this.usedForTerrain&&this.map.painter.terrain){const t=this.map.painter.terrain;this.update(this.transform,t.getScaledDemTileSize(),!0),t.resetTileLookupCache(this.id)}else this.update(this.transform)}else t.timeAdded=ki.now(),"expired"===i&&(t.refreshedUponExpiration=!0),this._setTileReloadTimer(e,t),"raster-dem"===this._source.type&&t.dem&&this._backfillDEM(t),this._state.initializeTileState(t,this.map?this.map.painter:null),this._source.fire(new Pn("data",{dataType:"source",tile:t,coord:t.tileID,sourceCacheId:this.id}))}_backfillDEM(t){const e=this.getRenderableIds();for(let n=0;n1||(Math.abs(i)>1&&(1===Math.abs(i+r)?i+=r:1===Math.abs(i-r)&&(i-=r)),e.dem&&t.dem&&(t.dem.backfillBorder(e.dem,i,n),t.neighboringTiles&&t.neighboringTiles[o]&&(t.neighboringTiles[o].backfilled=!0)))}}getTile(t){return this.getTileByID(t.key)}getTileByID(t){return this._tiles[t]}_retainLoadedChildren(t,e,i,n){for(const r in this._tiles){let o=this._tiles[r];if(n[r]||!o.hasData()||o.tileID.overscaledZi)continue;let s=o.tileID;for(;o&&o.tileID.overscaledZ>e+1;){const t=o.tileID.scaledTo(o.tileID.overscaledZ-1);o=this._tiles[t.key],o&&o.hasData()&&(s=t)}let a=s;for(;a.overscaledZ>e;)if(a=a.scaledTo(a.overscaledZ-1),t[a.key]){n[s.key]=s;break}}}findLoadedParent(t,e){if(t.key in this._loadedParentTiles){const i=this._loadedParentTiles[t.key];return i&&i.tileID.overscaledZ>=e?i:null}for(let i=t.overscaledZ-1;i>=e;i--){const e=t.scaledTo(i),n=this._getLoadedTile(e);if(n)return n}}_getLoadedTile(t){const e=this._tiles[t.key];return e&&e.hasData()?e:this._cache.getByKey(this._source.reparseOverscaled?t.wrapped().key:t.canonical.key)}updateCacheSize(t,e){e=e||this._source.tileSize;const i=Math.ceil(t.width/e)+1,n=Math.ceil(t.height/e)+1,r=Math.floor(i*n*5),o="number"==typeof this._minTileCacheSize?Math.max(this._minTileCacheSize,r):r,s="number"==typeof this._maxTileCacheSize?Math.min(this._maxTileCacheSize,o):o;this._cache.setMaxSize(s)}handleWrapJump(t){const e=Math.round((t-(void 0===this._prevLng?t:this._prevLng))/360);if(this._prevLng=t,e){const t={};for(const i in this._tiles){const n=this._tiles[i];n.tileID=n.tileID.unwrapTo(n.tileID.wrap+e),t[n.tileID.key]=n}this._tiles=t;for(const t in this._timers)clearTimeout(this._timers[t]),delete this._timers[t];for(const t in this._tiles)this._setTileReloadTimer(+t,this._tiles[t])}}update(t,e,i,n){if(this.transform=t,!this._sourceLoaded||this._paused||this.transform.freezeTileCoverage)return;if(this.usedForTerrain&&!i)return;let r;if(this.updateCacheSize(t,e),"globe"!==this.transform.projection.name&&this.handleWrapJump(this.transform.center.lng),this._shadowCasterTiles={},this._coveredTiles={},this.used||this.usedForTerrain){if(this._source.tileID)r=t.getVisibleUnwrappedCoordinates(this._source.tileID).map((t=>new vd(t.canonical.z,t.wrap,t.canonical.z,t.canonical.x,t.canonical.y)));else if(0!==this.tileCoverLift){const n=t.clone();n.tileCoverLift=this.tileCoverLift,r=n.coveringTiles({tileSize:e||this._source.tileSize,minzoom:this._source.minzoom,maxzoom:this._source.maxzoom,roundZoom:this._source.roundZoom&&!i,reparseOverscaled:this._source.reparseOverscaled,isTerrainDEM:this.usedForTerrain}),this._source.minzoomt(e)))}}else r=[];if(r.length>0&&this.castsShadows&&n&&"globe"!==this.transform.projection.name&&!this.usedForTerrain&&!Jy(this._source.type)){const o=t.coveringZoomLevel({tileSize:e||this._source.tileSize,roundZoom:this._source.roundZoom&&!i}),s=Math.min(o,this._source.maxzoom),a=t.extendTileCoverForShadows(r,n,s);for(const t of a)this._shadowCasterTiles[t.key]=!0,r.push(t)}const o=this._updateRetainedTiles(r);if(Jy(this._source.type)&&0!==r.length){const t={},e={},i=Object.keys(o);for(const n of i){const i=o[n],r=this._tiles[n];if(!r||r.fadeEndTime&&r.fadeEndTimen;){r=r.scaledTo(r.overscaledZ-1);const n=this._tiles[r.key];if(n&&n.hasData()&&e[r.key]){o[t]=i.tileID;break}}}for(const e in t)o[e]||(this._coveredTiles[e]=!0,o[e]=t[e])}for(const t in o)this._tiles[t].clearFadeHold();const s=function(t,e){const i=[];for(const n in t)n in e||i.push(n);return i}(this._tiles,o);for(const t of s){const e=this._tiles[t];e.hasSymbolBuckets&&!e.holdingForFade()?e.setHoldDuration(this.map._fadeDuration):e.hasSymbolBuckets&&!e.symbolFadeFinished()||this._removeTile(+t)}this._updateLoadedParentTileCache(),this._onlySymbols&&this._source.afterUpdate&&this._source.afterUpdate()}releaseSymbolFadeTiles(){for(const t in this._tiles)this._tiles[t].holdingForFade()&&this._removeTile(+t)}_updateRetainedTiles(t){const e={};if(0===t.length)return e;const i={},n=t.reduce(((t,e)=>Math.min(t,e.overscaledZ)),1/0),r=t[0].overscaledZ,o=Math.max(r-Xy.maxOverzooming,this._source.minzoom),s=Math.max(r+Xy.maxUnderzooming,this._source.minzoom),a={};for(const i of t){const t=this._addTile(i);e[i.key]=i,t.hasData()||n=this._source.maxzoom){const t=n.children(this._source.maxzoom)[0],i=this.getTile(t);if(i&&i.hasData()){e[t.key]=t;continue}}else{const t=n.children(this._source.maxzoom);if(e[t[0].key]&&e[t[1].key]&&e[t[2].key]&&e[t[3].key])continue}let r=t.wasRequested();for(let s=n.overscaledZ-1;s>=o;--s){const o=n.scaledTo(s);if(i[o.key])break;if(i[o.key]=!0,t=this.getTile(o),!t&&r&&(t=this._addTile(o)),t&&(e[o.key]=o,r=t.wasRequested(),t.hasData()))break}}return e}_updateLoadedParentTileCache(){this._loadedParentTiles={};for(const t in this._tiles){const e=[];let i,n=this._tiles[t].tileID;for(;n.overscaledZ>0;){if(n.key in this._loadedParentTiles){i=this._loadedParentTiles[n.key];break}e.push(n.key);const t=n.scaledTo(n.overscaledZ-1);if(i=this._getLoadedTile(t),i)break;n=t}for(const t of e)this._loadedParentTiles[t]=i}}_addTile(t){let e=this._tiles[t.key];if(e)return!0!==e.isExtraShadowCaster||!!this._shadowCasterTiles[t.key]||this._reloadTile(t.key,"reloading"),e;e=this._cache.getAndRemove(t),e&&(this._setTileReloadTimer(t.key,e),e.tileID=t,this._state.initializeTileState(e,this.map?this.map.painter:null),this._cacheTimers[t.key]&&(clearTimeout(this._cacheTimers[t.key]),delete this._cacheTimers[t.key],this._setTileReloadTimer(t.key,e)));const i=Boolean(e);if(!i){const i=this.map?this.map.painter:null,n=this._source.tileSize*t.overscaleFactor();e="raster-array"===this._source.type?new Wy(t,n,this.transform.tileZoom,i,this._isRaster):new ey(t,n,this.transform.tileZoom,i,this._isRaster),this._loadTile(e,this._tileLoaded.bind(this,e,t.key,e.state))}return e?(e.uses++,this._tiles[t.key]=e,i||this._source.fire(new Pn("dataloading",{tile:e,coord:e.tileID,dataType:"source"})),e):null}_setTileReloadTimer(t,e){t in this._timers&&(clearTimeout(this._timers[t]),delete this._timers[t]);const i=e.getExpiryTimeout();i&&(this._timers[t]=setTimeout((()=>{this._reloadTile(t,"expired"),delete this._timers[t]}),i))}_removeTile(t){const e=this._tiles[t];e&&(e.uses--,delete this._tiles[t],this._timers[t]&&(clearTimeout(this._timers[t]),delete this._timers[t]),e.uses>0||(e.hasData()&&"reloading"!==e.state||"empty"===e.state?this._cache.add(e.tileID,e,e.getExpiryTimeout()):(e.aborted=!0,this._abortTile(e),this._unloadTile(e))))}clearTiles(){this._shouldReloadOnResume=!1,this._paused=!1;for(const t in this._tiles)this._removeTile(+t);this._source._clear&&this._source._clear(),this._cache.reset(),this.map&&this.usedForTerrain&&this.map.painter.terrain&&this.map.painter.terrain.resetTileLookupCache(this.id)}tilesIn(t,e,i){const n=[],r=this.transform;if(!r)return n;const o="globe"===r.projection.name,s=Ed(r.center.lng);for(const a in this._tiles){const l=this._tiles[a];if(i&&l.clearQueryDebugViz(),l.holdingForFade())continue;let c;if(o){const t=l.tileID.canonical;if(0===t.z){const e=[Math.abs(Xe(s,...Qy(t,-1))-s),Math.abs(Xe(s,...Qy(t,1))-s)];c=[0,2*e.indexOf(Math.min(...e))-1]}else{const e=[Math.abs(Xe(s,...Qy(t,-1))-s),Math.abs(Xe(s,...Qy(t,0))-s),Math.abs(Xe(s,...Qy(t,1))-s)];c=[e.indexOf(Math.min(...e))-1]}}else c=[0];for(const i of c){const o=t.containsTile(l,r,e,i);o&&n.push(o)}}return n}getShadowCasterCoordinates(){return this._getRenderableCoordinates(!1,!0)}getVisibleCoordinates(t){return this._getRenderableCoordinates(t)}_getRenderableCoordinates(t,e){const i=this.getRenderableIds(t,e).map((t=>this._tiles[t].tileID)),n="globe"===this.transform.projection.name;for(const t of i)t.projMatrix=this.transform.calculateProjMatrix(t.toUnwrapped()),t.expandedProjMatrix=n?this.transform.calculateProjMatrix(t.toUnwrapped(),!1,!0):t.projMatrix;return i}sortCoordinatesByDistance(t){const e=t.slice(),i=this.transform._camera.position,n=this.transform._camera.forward(),r={};for(const t of e){const e=1/(1r[t.key]-r[e.key])),e}hasTransition(){if(this._source.hasTransition())return!0;if(Jy(this._source.type))for(const t in this._tiles){const e=this._tiles[t];if(void 0!==e.fadeEndTime&&e.fadeEndTime>=ki.now())return!0}return!1}setFeatureState(t,e,i){this._state.updateState(t=t||"_geojsonTileLayer",e,i)}removeFeatureState(t,e,i){this._state.removeFeatureState(t=t||"_geojsonTileLayer",e,i)}getFeatureState(t,e){return this._state.getState(t=t||"_geojsonTileLayer",e)}setDependencies(t,e,i){const n=this._tiles[t];n&&n.setDependencies(e,i)}reloadTilesForDependencies(t,e){for(const i in this._tiles)this._tiles[i].hasDependency(t,e)&&this._reloadTile(+i,"reloading");this._cache.filter((i=>!i.hasDependency(t,e)))}_preloadTiles(t,e){if(!this._sourceLoaded){const i=()=>{this._sourceLoaded&&(this._source.off("data",i),this._preloadTiles(t,e))};return void this._source.on("data",i)}const i=new Map,n=Array.isArray(t)?t:[t],r=this.map.painter.terrain,o=this.usedForTerrain&&r?r.getScaledDemTileSize():this._source.tileSize;for(const t of n){const e=t.coveringTiles({tileSize:o,minzoom:this._source.minzoom,maxzoom:this._source.maxzoom,roundZoom:this._source.roundZoom&&!this.usedForTerrain,reparseOverscaled:this._source.reparseOverscaled,isTerrainDEM:this.usedForTerrain});for(const t of e)i.set(t.key,t);this.usedForTerrain&&t.updateElevation(!1)}Qe(Array.from(i.values()),((t,e)=>{const i=new ey(t,this._source.tileSize*t.overscaleFactor(),this.transform.tileZoom,this.map.painter,this._isRaster);this._loadTile(i,(t=>{"raster-dem"===this._source.type&&i.dem&&this._backfillDEM(i),e(t,i)}))}),e)}}function Ky(t,e){const i=Math.abs(2*t.wrap)-+(t.wrap0?e+2*t:t}tv.useIntegerZoom=!0;const iv=new ol({"symbol-placement":new il(sl.layout_symbol["symbol-placement"]),"symbol-spacing":new il(sl.layout_symbol["symbol-spacing"]),"symbol-avoid-edges":new il(sl.layout_symbol["symbol-avoid-edges"]),"symbol-sort-key":new nl(sl.layout_symbol["symbol-sort-key"]),"symbol-z-order":new il(sl.layout_symbol["symbol-z-order"]),"symbol-z-elevate":new il(sl.layout_symbol["symbol-z-elevate"]),"icon-allow-overlap":new il(sl.layout_symbol["icon-allow-overlap"]),"icon-ignore-placement":new il(sl.layout_symbol["icon-ignore-placement"]),"icon-optional":new il(sl.layout_symbol["icon-optional"]),"icon-rotation-alignment":new il(sl.layout_symbol["icon-rotation-alignment"]),"icon-size":new nl(sl.layout_symbol["icon-size"]),"icon-text-fit":new nl(sl.layout_symbol["icon-text-fit"]),"icon-text-fit-padding":new nl(sl.layout_symbol["icon-text-fit-padding"]),"icon-image":new nl(sl.layout_symbol["icon-image"]),"icon-rotate":new nl(sl.layout_symbol["icon-rotate"]),"icon-padding":new il(sl.layout_symbol["icon-padding"]),"icon-keep-upright":new il(sl.layout_symbol["icon-keep-upright"]),"icon-offset":new nl(sl.layout_symbol["icon-offset"]),"icon-anchor":new nl(sl.layout_symbol["icon-anchor"]),"icon-pitch-alignment":new il(sl.layout_symbol["icon-pitch-alignment"]),"text-pitch-alignment":new il(sl.layout_symbol["text-pitch-alignment"]),"text-rotation-alignment":new il(sl.layout_symbol["text-rotation-alignment"]),"text-field":new nl(sl.layout_symbol["text-field"]),"text-font":new nl(sl.layout_symbol["text-font"]),"text-size":new nl(sl.layout_symbol["text-size"]),"text-max-width":new nl(sl.layout_symbol["text-max-width"]),"text-line-height":new nl(sl.layout_symbol["text-line-height"]),"text-letter-spacing":new nl(sl.layout_symbol["text-letter-spacing"]),"text-justify":new nl(sl.layout_symbol["text-justify"]),"text-radial-offset":new nl(sl.layout_symbol["text-radial-offset"]),"text-variable-anchor":new il(sl.layout_symbol["text-variable-anchor"]),"text-anchor":new nl(sl.layout_symbol["text-anchor"]),"text-max-angle":new il(sl.layout_symbol["text-max-angle"]),"text-writing-mode":new il(sl.layout_symbol["text-writing-mode"]),"text-rotate":new nl(sl.layout_symbol["text-rotate"]),"text-padding":new il(sl.layout_symbol["text-padding"]),"text-keep-upright":new il(sl.layout_symbol["text-keep-upright"]),"text-transform":new nl(sl.layout_symbol["text-transform"]),"text-offset":new nl(sl.layout_symbol["text-offset"]),"text-allow-overlap":new il(sl.layout_symbol["text-allow-overlap"]),"text-ignore-placement":new il(sl.layout_symbol["text-ignore-placement"]),"text-optional":new il(sl.layout_symbol["text-optional"]),visibility:new il(sl.layout_symbol.visibility)});var nv={paint:new ol({"icon-opacity":new nl(sl.paint_symbol["icon-opacity"]),"icon-occlusion-opacity":new nl(sl.paint_symbol["icon-occlusion-opacity"]),"icon-emissive-strength":new nl(sl.paint_symbol["icon-emissive-strength"]),"text-emissive-strength":new nl(sl.paint_symbol["text-emissive-strength"]),"icon-color":new nl(sl.paint_symbol["icon-color"]),"icon-halo-color":new nl(sl.paint_symbol["icon-halo-color"]),"icon-halo-width":new nl(sl.paint_symbol["icon-halo-width"]),"icon-halo-blur":new nl(sl.paint_symbol["icon-halo-blur"]),"icon-translate":new il(sl.paint_symbol["icon-translate"]),"icon-translate-anchor":new il(sl.paint_symbol["icon-translate-anchor"]),"icon-image-cross-fade":new nl(sl.paint_symbol["icon-image-cross-fade"]),"text-opacity":new nl(sl.paint_symbol["text-opacity"]),"text-occlusion-opacity":new nl(sl.paint_symbol["text-occlusion-opacity"]),"text-color":new nl(sl.paint_symbol["text-color"],{runtimeType:Qn,getOverride:t=>t.textColor,hasOverride:t=>!!t.textColor}),"text-halo-color":new nl(sl.paint_symbol["text-halo-color"]),"text-halo-width":new nl(sl.paint_symbol["text-halo-width"]),"text-halo-blur":new nl(sl.paint_symbol["text-halo-blur"]),"text-translate":new il(sl.paint_symbol["text-translate"]),"text-translate-anchor":new il(sl.paint_symbol["text-translate-anchor"]),"icon-color-saturation":new il(sl.paint_symbol["icon-color-saturation"]),"icon-color-contrast":new il(sl.paint_symbol["icon-color-contrast"]),"icon-color-brightness-min":new il(sl.paint_symbol["icon-color-brightness-min"]),"icon-color-brightness-max":new il(sl.paint_symbol["icon-color-brightness-max"])}),layout:iv};class rv{constructor(t){this.type=t.property.overrides?t.property.overrides.runtimeType:Yn,this.defaultValue=t}evaluate(t){if(t.formattedSection){const e=this.defaultValue.property.overrides;if(e&&e.hasOverride(t.formattedSection))return e.getOverride(t.formattedSection)}return t.feature&&t.featureState?this.defaultValue.evaluate(t.feature,t.featureState):this.defaultValue.property.specification.default}eachChild(t){this.defaultValue.isConstant()||t(this.defaultValue.value._styleExpression.expression)}outputDefined(){return!1}serialize(){return null}}ba(rv,"FormatSectionOverride",{omit:["defaultValue"]});class ov extends Ml{constructor(e,i,n,r){super(e,nv,i,n,r),this._colorAdjustmentMatrix=t.ad.identity([]),this.hasInitialOcclusionOpacityProperties=void 0!==e.paint&&("icon-occlusion-opacity"in e.paint||"text-occlusion-opacity"in e.paint)}recalculate(t,e){super.recalculate(t,e),"auto"===this.layout.get("icon-rotation-alignment")&&(this.layout._values["icon-rotation-alignment"]="point"!==this.layout.get("symbol-placement")?"map":"viewport"),"auto"===this.layout.get("text-rotation-alignment")&&(this.layout._values["text-rotation-alignment"]="point"!==this.layout.get("symbol-placement")?"map":"viewport"),"auto"===this.layout.get("text-pitch-alignment")&&(this.layout._values["text-pitch-alignment"]=this.layout.get("text-rotation-alignment")),"auto"===this.layout.get("icon-pitch-alignment")&&(this.layout._values["icon-pitch-alignment"]=this.layout.get("icon-rotation-alignment"));const i=this.layout.get("text-writing-mode");if(i){const t=[];for(const e of i)t.indexOf(e)i in t?String(t[i]):""))}(e.properties,r)}createBucket(t){return new jg(t)}queryRadius(){return 0}queryIntersectsFeature(){return!1}_setPaintOverrides(){for(const t of nv.paint.overridableProperties){if(!ov.hasPaintOverride(this.layout,t))continue;const e=this.paint.get(t),i=new rv(e),n=new la(i,e.property.specification,this.scope,this.options);let r=null;r="constant"===e.value.kind||"source"===e.value.kind?new ua("source",n):new ha("composite",n,e.value.zoomStops,e.value._interpolationType),this.paint._values[t]=new tl(e.property,r,e.parameters)}}_handleOverridablePaintPropertyUpdate(t,e,i){return!(!this.layout||e.isDataDriven()||i.isDataDriven())&&ov.hasPaintOverride(this.layout,t)}static hasPaintOverride(t,e){const i=t.get("text-field"),n=nv.paint.properties[e];let r=!1;const o=t=>{for(const e of t)if(n.overrides&&n.overrides.hasOverride(e))return void(r=!0)};if("constant"===i.value.kind&&i.value.value instanceof pr)o(i.value.value.sections);else if("source"===i.value.kind){const t=e=>{r||(e instanceof vr&&gr(e.value)===nr?o(e.value.sections):e instanceof Tr?o(e.sections):e.eachChild(t))},e=i.value;e._styleExpression&&t(e._styleExpression.expression)}return r}getProgramIds(){const t=0!==this.paint.get("icon-opacity").constantOr(1),e=0!==this.paint.get("text-opacity").constantOr(1),i=[];return t&&i.push("symbolIcon"),e&&i.push("symbolSDF"),i}getDefaultProgramParams(t,e,i){return{config:new Wc(this,{zoom:e,lut:i}),overrideFog:!1}}}const sv=new ol({visibility:new il(sl.layout_background.visibility)});var av={paint:new ol({"background-color":new il(sl.paint_background["background-color"]),"background-pattern":new il(sl.paint_background["background-pattern"]),"background-opacity":new il(sl.paint_background["background-opacity"]),"background-emissive-strength":new il(sl.paint_background["background-emissive-strength"])}),layout:sv};const lv=new ol({visibility:new il(sl.layout_raster.visibility)});var cv={paint:new ol({"raster-opacity":new il(sl.paint_raster["raster-opacity"]),"raster-color":new rl(sl.paint_raster["raster-color"]),"raster-color-mix":new il(sl.paint_raster["raster-color-mix"]),"raster-color-range":new il(sl.paint_raster["raster-color-range"]),"raster-hue-rotate":new il(sl.paint_raster["raster-hue-rotate"]),"raster-brightness-min":new il(sl.paint_raster["raster-brightness-min"]),"raster-brightness-max":new il(sl.paint_raster["raster-brightness-max"]),"raster-saturation":new il(sl.paint_raster["raster-saturation"]),"raster-contrast":new il(sl.paint_raster["raster-contrast"]),"raster-resampling":new il(sl.paint_raster["raster-resampling"]),"raster-fade-duration":new il(sl.paint_raster["raster-fade-duration"]),"raster-emissive-strength":new il(sl.paint_raster["raster-emissive-strength"]),"raster-array-band":new il(sl.paint_raster["raster-array-band"]),"raster-elevation":new il(sl.paint_raster["raster-elevation"])}),layout:lv};function dv(e,i,n,r,o,s,a,l){const c=[e,i,1,n,r,1,o,s,1],d=[a,l,1],u=t.bC.adjoint([],c),[h,p,f]=t._.transformMat3(d,d,u);return t.bC.multiply(c,c,[h,0,0,0,p,0,0,0,f])}function uv(e,i,n,r,o,s,a,l){const c=function(e,i,n,r,o,s,a,l){const c=dv(0,0,1,0,1,1,0,1),d=dv(e,i,n,r,o,s,a,l),u=t.bC.adjoint([],c);return t.bC.multiply(d,d,u)}(e,i,n,r,o,s,a,l);return[c[2]/c[8]/uo,c[5]/c[8]/uo]}function hv(t){return[t[0],Math.min(Math.max(t[1],-Pd),Pd)]}class pv extends zn{constructor(t,e,i,n){super(),this.id=t,this.dispatcher=i,this.coordinates=e.coordinates,this.type="image",this.minzoom=0,this.maxzoom=22,this.tileSize=512,this.tiles={},this._loaded=!1,this.onNorthPole=!1,this.onSouthPole=!1,this.setEventedParent(n),this.options=e,this._dirty=!1}load(t,e){if(this._loaded=e||!1,this.fire(new Pn("dataloading",{dataType:"source"})),this.url=this.options.url,!this.url)return t&&(this.coordinates=t),this._loaded=!0,void this._finishLoading();this._imageRequest=an(this.map._requestManager.transformRequest(this.url,Ki.Image),((e,i)=>{this._imageRequest=null,this._loaded=!0,e?this.fire(new $n(e)):i&&(this.image=i instanceof HTMLImageElement?ki.getImageData(i):i,this._dirty=!0,this.width=this.image.width,this.height=this.image.height,t&&(this.coordinates=t),this._finishLoading())}))}loaded(){return this._loaded}updateImage(t){return t.url?(this._imageRequest&&t.url!==this.options.url&&(this._imageRequest.cancel(),this._imageRequest=null),this.options.url=t.url,this.load(t.coordinates,this._loaded),this):this}setTexture(t){if(!(t.handle instanceof WebGLTexture))throw new Error("The provided handle is not a WebGLTexture instance");return this.texture=new Gg(this.map.painter.context,t.handle),this.width=t.dimensions[0],this.height=t.dimensions[1],this._dirty=!1,this._loaded=!0,this._finishLoading(),this}_finishLoading(){this.map&&(this.setCoordinates(this.coordinates),this.fire(new Pn("data",{dataType:"source",sourceDataType:"metadata"})))}onAdd(t){this.map=t,this.load()}onRemove(t){this._imageRequest&&(this._imageRequest.cancel(),this._imageRequest=null),!this.texture||this.texture instanceof Gg||this.texture.destroy(),this.boundsBuffer&&(this.boundsBuffer.destroy(),this.elevatedGlobeVertexBuffer&&this.elevatedGlobeVertexBuffer.destroy(),this.elevatedGlobeIndexBuffer&&this.elevatedGlobeIndexBuffer.destroy())}setCoordinates(t){if(this.coordinates=t,this._boundsArray=void 0,this._unsupportedCoords=!1,!t.length)return this;this.onNorthPole=!1,this.onSouthPole=!1;let e=t[0][1],i=t[0][1];for(const n of t)n[1]>i&&(i=n[1]),n[1]Pd?this.onNorthPole=!0:n1&&(l-=1),new gd(s,l,Math.floor((i+r)/2*a))}(e),this.minzoom=this.maxzoom=this.tileID.z}return this.fire(new Pn("data",{dataType:"source",sourceDataType:"content"})),this}_clear(){this._boundsArray=void 0,this._unsupportedCoords=!1}_prepareData(e){for(const t in this.tiles){const e=this.tiles[t];"loaded"!==e.state&&(e.state="loaded",e.texture=this.texture)}if(this._boundsArray||this.onNorthPole||this.onSouthPole||this._unsupportedCoords)return;const i=eg(new gd(0,0,0),this.map.transform.projection),n=[i.projection.project(this.coordinates[0][0],this.coordinates[0][1]),i.projection.project(this.coordinates[1][0],this.coordinates[1][1]),i.projection.project(this.coordinates[2][0],this.coordinates[2][1]),i.projection.project(this.coordinates[3][0],this.coordinates[3][1])];if(!function(t){const e=t[1].x-t[0].x,i=t[1].y-t[0].y,n=t[2].x-t[1].x,r=t[2].y-t[1].y,o=t[3].x-t[2].x,s=t[3].y-t[2].y,a=t[0].x-t[3].x,l=t[0].y-t[3].y,c=e*r-n*i,d=n*s-o*r,u=o*l-a*s,h=a*i-e*l;return c>0&&d>0&&u>0&&h>0||c{const e=r.projection.project(t[0],t[1]);return ig(r,e)._round()}));this.perspectiveTransform=uv(o.x,o.y,s.x,s.y,a.x,a.y,l.x,l.y);const c=this._boundsArray=new Dl;c.emplaceBack(o.x,o.y,0,0),c.emplaceBack(s.x,s.y,uo,0),c.emplaceBack(l.x,l.y,0,uo),c.emplaceBack(a.x,a.y,uo,uo),this.boundsBuffer&&(this.boundsBuffer.destroy(),this.elevatedGlobeVertexBuffer&&this.elevatedGlobeVertexBuffer.destroy(),this.elevatedGlobeIndexBuffer&&this.elevatedGlobeIndexBuffer.destroy()),this.boundsBuffer=e.createVertexBuffer(c,Jg.members),this.boundsSegments=wc.simpleSegment(0,0,4,2);const d=[],u=function(t){return[hv(t[0]),hv(t[1]),hv(t[2]),hv(t[3])]}(this.coordinates),[h,p,f,m]=function(t){let e=t[0][0],i=e,n=t[0][1],r=n;for(let o=1;oi&&(i=t[o][0]),t[o][1]r&&(r=t[o][1]);return[e,n,i-e,r-n]}(u);{const r=new Dl,[o,s,a,l]=function(t){let e=t[0].x,i=e,n=t[0].y,r=n;for(let o=1;oi&&(i=t[o].x),t[o].yr&&(r=t[o].y);return[e,n,i-e,r-n]}(n),c=t=>[(t.x-o)/a,(t.y-s)/l],[u,_,g,y]=n.map(c),v=function(e,i,n,r,o,s,a,l){const c=dv(0,0,1,0,1,1,0,1),d=dv(e,i,n,r,o,s,a,l),u=t.bC.adjoint([],d);return t.bC.multiply(c,c,u)}(u[0],u[1],_[0],_[1],g[0],g[1],y[0],y[1]);this.elevatedGlobePerspectiveTransform=uv(u[0],u[1],_[0],_[1],g[0],g[1],y[0],y[1]);const x=(e,i)=>{d.push(e.lng);const n=Math.round((e.lng-h)/f*uo),o=Math.round((e.lat-p)/m*uo),s=c(i),a=t._.transformMat3([],[s[0],s[1],1],v),l=Math.round(a[0]/a[2]*uo),u=Math.round(a[1]/a[2]*uo);r.emplaceBack(n,o,l,u)},b=n[3].x-n[0].x,w=n[3].y-n[0].y,T=n[2].x-n[1].x,S=n[2].y-n[1].y;for(let t=0;t{i.emplaceBack(e,n,r);const o=d[e],s=d[n],a=d[r],l=Math.min(Math.min(o,s),a),c=Math.max(Math.max(o,s),a)-l;c>this.maxLongitudeTriangleSize&&(this.maxLongitudeTriangleSize=c),t.push(l+c/2)};for(let t=0;te));i.sort(((e,i)=>t[e]-t[i]));const n=[],r=new Kl;for(let o=0;o{o.segments.push({vertexOffset:0,primitiveOffset:t,vertexLength:e.segments[0].vertexLength,primitiveLength:i,sortKey:void 0,vaos:{}})},a=.51*this.maxLongitudeTriangleSize;if(Math.abs(i[0]-n)0){const n=function(e,i){const n=i.worldSize,r=Cd(1,0)*n*kd(i.center.lat,i.zoom)/Gu(n),o=Cd(1,i.center.lat)*n,s=t.ad.identity([]);return t.ad.rotateY(s,s,Ge(i.center.lng)),t.ad.rotateX(s,s,Ge(i.center.lat)),t.ad.translate(s,s,[0,0,ed]),t.ad.scale(s,s,[r,r,r*o]),t.ad.translate(s,s,[i.point.x-.5*n,i.point.y-.5*n,0]),t.ad.multiply(s,s,e),t.ad.multiply(s,i.globeMatrix,s)}(e,i);return function(e,i,n){const r=(e,i,n)=>{const r=t._.length(e),o=t._.length(i),s=ku(e,i,n);return t._.scale(s,s,1/t._.length(s)*Vn(r,o,n))},o=r([e[0],e[1],e[2]],[i[0],i[1],i[2]],n),s=r([e[4],e[5],e[6]],[i[4],i[5],i[6]],n),a=r([e[8],e[9],e[10]],[i[8],i[9],i[10]],n),l=ku([e[12],e[13],e[14]],[i[12],i[13],i[14]],n);return[o[0],o[1],o[2],0,s[0],s[1],s[2],0,a[0],a[1],a[2],0,l[0],l[1],l[2],1]}(o,n,r)}return o}function kv(t,e,i,n){const r=wu.projectAabbCorners(n,i);let o=Number.MAX_VALUE,s=-1;for(let t=0;tnew Ue(r[t][0],r[t][1]);let l;switch(s){case 0:case 6:l=[a(1),a(5),a(4),a(7),a(3),a(2),a(1)];break;case 1:case 7:l=[a(0),a(4),a(5),a(6),a(2),a(3),a(0)];break;case 3:case 5:l=[a(1),a(0),a(4),a(7),a(6),a(2),a(1)];break;default:l=[a(1),a(5),a(6),a(7),a(3),a(0),a(1)]}if(Yd(t,l))return o}const Dv=Ll([{name:"a_pos_3f",components:3,type:"Float32"}]),zv=Ll([{name:"a_color_3f",components:3,type:"Float32"}]),Rv=Ll([{name:"a_color_4f",components:4,type:"Float32"}]),Ov=Ll([{name:"a_uv_2f",components:2,type:"Float32"}]),Bv=Ll([{name:"a_normal_3f",components:3,type:"Float32"}]),Fv=Ll([{name:"a_normal_matrix0",components:4,type:"Float32"},{name:"a_normal_matrix1",components:4,type:"Float32"},{name:"a_normal_matrix2",components:4,type:"Float32"},{name:"a_normal_matrix3",components:4,type:"Float32"}]),Nv=Ll([{name:"a_pbr",components:4,type:"Uint16"},{name:"a_heightBasedEmissiveStrength",components:3,type:"Float32"}]);class Uv{constructor(t,e,i,n){this.message=(t?`${t}: `:"")+i,n&&(this.identifier=n),null!=e&&e.__line__&&(this.line=e.__line__)}}function jv(t,e){const i=-1===t.indexOf("://");try{return new URL(t,i&&e?"http://example.com":void 0),!0}catch(t){return!1}}class Vv{constructor(t,e){this.feature=t,this.instancedDataOffset=e,this.instancedDataCount=0,this.rotation=[0,0,0],this.scale=[1,1,1],this.translation=[0,0,0]}}class Gv{constructor(){this.instancedDataArray=new oc,this.instancesEvaluatedElevation=[],this.features=[],this.idToFeaturesIndex={}}}class Zv{constructor(t){this.zoom=t.zoom,this.canonical=t.canonical,this.layers=t.layers,this.layerIds=this.layers.map((t=>t.fqid)),this.projection=t.projection,this.index=t.index,this.hasZoomDependentProperties=this.layers[0].isZoomDependent(),this.stateDependentLayerIds=this.layers.filter((t=>t.isStateDependent())).map((t=>t.id)),this.hasPattern=!1,this.instancesPerModel={},this.validForExaggeration=0,this.maxVerticalOffset=0,this.maxScale=0,this.maxHeight=0,this.lookupDim=this.zoom>this.canonical.z?256:this.zoom>15?75:100,this.instanceCount=0,this.terrainElevationMin=0,this.terrainElevationMax=0,this.validForDEMTile={id:null,timestamp:0},this.modelUris=[],this.modelsRequested=!1,this.activeReplacements=[],this.replacementUpdateTime=0}updateFootprints(t,e){}populate(t,e,i,n){this.tileToMeter=zd(i);const r=this.layers[0]._featureFilter.needGeometry;this.lookup=new Uint8Array(this.lookupDim*this.lookupDim);for(const{feature:o,id:s,index:a,sourceLayerIndex:l}of t){const t=null!=s?s:o.properties&&o.properties.hasOwnProperty("id")?o.properties.id:void 0,c=Zd(o,r);if(!this.layers[0]._featureFilter.filter(new Ha(this.zoom),c,i))continue;const d={id:t,sourceLayerIndex:l,index:a,geometry:r?c.geometry:Gd(o,i,n),properties:o.properties,type:o.type,patterns:{}},u=this.addFeature(d,d.geometry,c);u&&e.featureIndex.insert(o,d.geometry,a,l,this.index,this.instancesPerModel[u].instancedDataArray.length,uo/32)}this.lookup=null}update(t,e,i,n){for(const e in this.instancesPerModel){const i=this.instancesPerModel[e];for(const e in t)i.idToFeaturesIndex.hasOwnProperty(e)&&(this.evaluate(i.features[i.idToFeaturesIndex[e]],t[e],i,!0),this.uploaded=!1)}this.maxHeight=0}updateZoomBasedPaintProperties(){if(!this.hasZoomDependentProperties)return!1;let e=!1;for(const i in this.instancesPerModel){const n=this.instancesPerModel[i];for(const i of n.features){const r=this.layers[0],o=i.feature,s=this.canonical,a=r.paint.get("model-rotation").evaluate(o,{},s),l=r.paint.get("model-scale").evaluate(o,{},s),c=r.paint.get("model-translation").evaluate(o,{},s);t._.exactEquals(i.rotation,a)&&t._.exactEquals(i.scale,l)&&t._.exactEquals(i.translation,c)||(this.evaluate(i,i.featureStates,n,!0),e=!0)}}return e}updateReplacement(t,e,i){if(e.updateTime===this.replacementUpdateTime)return!1;this.replacementUpdateTime=e.updateTime;const n=e.getReplacementRegionsForTile(t.toUnwrapped(),!0);if(Pp(this.activeReplacements,n))return!1;this.activeReplacements=n;let r=!1;for(const e in this.instancesPerModel){const n=this.instancesPerModel[e],o=n.instancedDataArray;for(const e of n.features){const n=e.instancedDataOffset,s=e.instancedDataCount;for(let e=0;euo?a-uo:a;const l=Math.floor(a),c=o.float32[s+1];let d=!1;for(const e of this.activeReplacements)if(!(e.orderl||l>e.max.x||e.min.y>c||c>e.max.y)&&(d=Op(Rp(l,c,t.canonical,e.footprintTileId.canonical),e),d))break;o.float32[s]=d?a+uo:a,r=r||d}}}return r}isEmpty(){for(const t in this.instancesPerModel)if(0!==this.instancesPerModel[t].instancedDataArray.length)return!1;return!0}uploadPending(){return!this.uploaded}upload(t){if(!this.uploaded)for(const e in this.instancesPerModel){const i=this.instancesPerModel[e];i.instancedDataArray.length=uo||e.y=uo)continue;const t=(this.lookupDim-1)/uo,i=this.lookupDim*(e.y*t|0)+e.x*t|0;if(this.lookup){if(0!==this.lookup[i])continue;this.lookup[i]=1}this.instanceCount++;const n=s.length;s.resize(n+1),o.instancesEvaluatedElevation.push(0),s.float32[16*n]=e.x,s.float32[16*n+1]=e.y}return a.instancedDataCount=o.instancedDataArray.length-a.instancedDataOffset,a.instancedDataCount>0&&(t.id&&(o.idToFeaturesIndex[t.id]=o.features.length),o.features.push(a),this.evaluate(a,{},o,!1)),r}getModelUris(){return this.modelUris}evaluate(t,e,i,n){const r=this.layers[0],o=t.feature,s=this.canonical,a=t.rotation=r.paint.get("model-rotation").evaluate(o,e,s),l=t.scale=r.paint.get("model-scale").evaluate(o,e,s),c=t.translation=r.paint.get("model-translation").evaluate(o,e,s),d=r.paint.get("model-color").evaluate(o,e,s);d.a=r.paint.get("model-color-mix-intensity").evaluate(o,e,s);const u=[];this.maxVerticalOffset10?this.tileToMeter:zd(s,p)),a[o+4]=c[0],a[o+5]=c[1],a[o+6]=c[2]+l,a[o+7]=u[0],a[o+8]=u[1],a[o+9]=u[2],a[o+10]=u[4],a[o+11]=u[5],a[o+12]=u[6],a[o+13]=u[8],a[o+14]=u[9],a[o+15]=u[10],i.instancesEvaluatedElevation[r]=c[2]}}}ba(Zv,"ModelBucket",{omit:["layers"]}),ba(Gv,"PerModelAttributes"),ba(Vv,"ModelFeature");const qv=new ol({visibility:new il(sl.layout_model.visibility),"model-id":new nl(sl.layout_model["model-id"])});var Hv={paint:new ol({"model-opacity":new il(sl.paint_model["model-opacity"]),"model-rotation":new nl(sl.paint_model["model-rotation"]),"model-scale":new nl(sl.paint_model["model-scale"]),"model-translation":new nl(sl.paint_model["model-translation"]),"model-color":new nl(sl.paint_model["model-color"]),"model-color-mix-intensity":new nl(sl.paint_model["model-color-mix-intensity"]),"model-type":new il(sl.paint_model["model-type"]),"model-cast-shadows":new il(sl.paint_model["model-cast-shadows"]),"model-receive-shadows":new il(sl.paint_model["model-receive-shadows"]),"model-ambient-occlusion-intensity":new il(sl.paint_model["model-ambient-occlusion-intensity"]),"model-emissive-strength":new nl(sl.paint_model["model-emissive-strength"]),"model-roughness":new nl(sl.paint_model["model-roughness"]),"model-height-based-emissive-strength-multiplier":new nl(sl.paint_model["model-height-based-emissive-strength-multiplier"]),"model-cutoff-fade-range":new il(sl.paint_model["model-cutoff-fade-range"]),"model-front-cutoff":new il(sl.paint_model["model-front-cutoff"])}),layout:qv};const Wv=64,Yv={CoordinateSpaceTile:1,CoordinateSpaceYUp:2,HasMapboxMeshFeatures:4,HasMeshoptCompression:8};function Xv(e,i,n,r,o,s,a,l,c,d=!1){const u=n.zoom,h=n.project(r),p=kd(r.lat,u),f=1/p;t.ad.identity(e),t.ad.translate(e,e,[h.x+a[0]*f,h.y+a[1]*f,a[2]]);let m=1,_=1;const g=n.worldSize;if(d){if("mercator"===n.projection.name){let e=0;n.elevation&&(e=n.elevation.getAtPointOrZero(new Rd(h.x/g,h.y/g),0));const i=t.aA.transformMat4([],[h.x,h.y,e,1],n.projMatrix)[3]/n.cameraToCenterDistance;m=i,_=i*kd(n.center.lat,u)}else if("globe"===n.projection.name){const i=$v(e,n),o=t.ad.multiply([],n.projMatrix,i),s=[0,0,0,1];t.aA.transformMat4(s,s,o);const a=s[3]/n.cameraToCenterDistance,l=Hu(u),c=n.projection.pixelsPerMeter(r.lat,g)*kd(r.lat,u),d=n.projection.pixelsPerMeter(n.center.lat,g)*kd(n.center.lat,u);m=a/Vn(c,$d(n.center.lat),l),_=a*p/c,m*=d,_*=d}}else m=f;t.ad.scale(e,e,[m,m,_]);const y=[...e],v=i.orientation,x=[];if(Lv(x,[v[0]+o[0],v[1]+o[1],v[2]+o[2]],s),t.ad.multiply(e,y,x),l&&n.elevation){let o=0;const s=[];if(c&&n.elevation){o=function(e,i,n,r,o){const s=i.elevation;if(!s)return 0;const a=wu.projectAabbCorners(n,r),l=Cd(1,o.lat)*i.worldSize,c=function(e,i){const n=[0,0,1],r=[{corners:[0,1,3,2],dotProductWithUp:0},{corners:[1,5,2,6],dotProductWithUp:0},{corners:[0,4,1,5],dotProductWithUp:0},{corners:[2,6,3,7],dotProductWithUp:0},{corners:[4,7,5,6],dotProductWithUp:0},{corners:[0,3,4,7],dotProductWithUp:0}];for(const o of r){const r=e[o.corners[0]],s=e[o.corners[1]],a=e[o.corners[2]],l=[s[0]-r[0],s[1]-r[1],i*(s[2]-r[2])],c=t._.cross(l,l,[a[0]-r[0],a[1]-r[1],i*(a[2]-r[2])]);t._.normalize(c,c),o.dotProductWithUp=t._.dot(c,n)}return r.sort(((t,e)=>t.dotProductWithUp-e.dotProductWithUp)),r[0].corners}(a,l),d=a[c[0]],u=a[c[1]],h=a[c[2]],p=a[c[3]],f=s.getAtPointOrZero(new Rd(d[0]/i.worldSize,d[1]/i.worldSize),0),m=s.getAtPointOrZero(new Rd(u[0]/i.worldSize,u[1]/i.worldSize),0),_=s.getAtPointOrZero(new Rd(h[0]/i.worldSize,h[1]/i.worldSize),0),g=s.getAtPointOrZero(new Rd(p[0]/i.worldSize,p[1]/i.worldSize),0),y=(f+g)/2,v=(m+_)/2;return y>v?m=e.gl.NEAREST_MIPMAP_NEAREST}),t.uploaded=!0,t.image=null)}function Jv(t,e,i){t.indexBuffer=e.createIndexBuffer(t.indexArray,!1,!0),t.vertexBuffer=e.createVertexBuffer(t.vertexArray,Dv.members,!1,!0),t.normalArray&&(t.normalBuffer=e.createVertexBuffer(t.normalArray,Bv.members,!1,!0)),t.texcoordArray&&(t.texcoordBuffer=e.createVertexBuffer(t.texcoordArray,Ov.members,!1,!0)),t.colorArray&&(t.colorBuffer=e.createVertexBuffer(t.colorArray,(12===t.colorArray.bytesPerElement?zv:Rv).members,!1,!0)),t.featureArray&&(t.pbrBuffer=e.createVertexBuffer(t.featureArray,Nv.members,!0)),t.segments=wc.simpleSegment(0,0,t.vertexArray.length,t.indexArray.length);const n=t.material;n.pbrMetallicRoughness.baseColorTexture&&Kv(n.pbrMetallicRoughness.baseColorTexture,e),n.pbrMetallicRoughness.metallicRoughnessTexture&&Kv(n.pbrMetallicRoughness.metallicRoughnessTexture,e),n.normalTexture&&Kv(n.normalTexture,e),n.occlusionTexture&&Kv(n.occlusionTexture,e,i),n.emissionTexture&&Kv(n.emissionTexture,e)}function Qv(t,e,i){if(t.meshes)for(const n of t.meshes)Jv(n,e,i);if(t.children)for(const n of t.children)Qv(n,e,i)}function tx(t){if(t.meshes)for(const e of t.meshes)e.indexArray.destroy(),e.vertexArray.destroy(),e.colorArray&&e.colorArray.destroy(),e.normalArray&&e.normalArray.destroy(),e.texcoordArray&&e.texcoordArray.destroy(),e.featureArray&&e.featureArray.destroy();if(t.children)for(const e of t.children)tx(e)}function ex(t){if(t.meshes)for(const i of t.meshes)i.vertexBuffer&&(i.vertexBuffer.destroy(),i.indexBuffer.destroy(),i.normalBuffer&&i.normalBuffer.destroy(),i.texcoordBuffer&&i.texcoordBuffer.destroy(),i.colorBuffer&&i.colorBuffer.destroy(),i.pbrBuffer&&i.pbrBuffer.destroy(),i.segments.destroy(),i.material&&((e=i.material).pbrMetallicRoughness.baseColorTexture&&e.pbrMetallicRoughness.baseColorTexture.gfxTexture&&e.pbrMetallicRoughness.baseColorTexture.gfxTexture.destroy(),e.pbrMetallicRoughness.metallicRoughnessTexture&&e.pbrMetallicRoughness.metallicRoughnessTexture.gfxTexture&&e.pbrMetallicRoughness.metallicRoughnessTexture.gfxTexture.destroy(),e.normalTexture&&e.normalTexture.gfxTexture&&e.normalTexture.gfxTexture.destroy(),e.emissionTexture&&e.emissionTexture.gfxTexture&&e.emissionTexture.gfxTexture.destroy(),e.occlusionTexture&&e.occlusionTexture.gfxTexture&&e.occlusionTexture.gfxTexture.destroy()));var e;if(t.children)for(const e of t.children)ex(e)}class ix{constructor(t){this._callback=t,this._triggered=!1,"undefined"!=typeof MessageChannel&&(this._channel=new MessageChannel,this._channel.port2.onmessage=()=>{this._triggered=!1,this._callback()})}trigger(){this._triggered||(this._triggered=!0,this._channel?this._channel.port1.postMessage(!0):setTimeout((()=>{this._triggered=!1,this._callback()}),0))}remove(){this._channel=void 0,this._callback=()=>{}}}class nx{constructor(){this.tasks={},this.taskQueue=[],ai(["process"],this),this.invoker=new ix(this.process),this.nextId=0}add(t,e){const i=this.nextId++,n=function({type:t,isSymbolTile:e,zoom:i}){return i=i||0,"message"===t?0:"maybePrepare"!==t||e?"parseTile"!==t||e?"parseTile"===t&&e?300-i:"maybePrepare"===t&&e?400-i:500:200-i:100-i}(e);if(0===n){try{t()}finally{}return null}return this.tasks[i]={fn:t,metadata:e,priority:n,id:i},this.taskQueue.push(i),this.invoker.trigger(),{cancel:()=>{delete this.tasks[i]}}}process(){try{if(this.taskQueue=this.taskQueue.filter((t=>!!this.tasks[t])),!this.taskQueue.length)return;const t=this.pick();if(null===t)return;const e=this.tasks[t];if(delete this.tasks[t],this.taskQueue.length&&this.invoker.trigger(),!e)return;e.fn()}finally{}}pick(){let t=null,e=1/0;for(let i=0;i{i&&delete this.callbacks[s],this.target.postMessage({id:s,type:"",targetMapId:n,sourceMapId:this.mapId})}}}receive(t){const e=t.data,i=e.id;if(i&&(!e.targetMapId||this.mapId===e.targetMapId))if(""===e.type){const t=this.cancelCallbacks[i];delete this.cancelCallbacks[i],t&&t.cancel()}else if(e.mustQueue||gi()){const t=this.callbacks[i],n=this.scheduler.add((()=>this.processTask(i,e)),t&&t.metadata||{type:"message"});n&&(this.cancelCallbacks[i]=n)}else this.processTask(i,e)}processTask(t,e){if(delete this.cancelCallbacks[t],""===e.type){const i=this.callbacks[t];delete this.callbacks[t],i&&(e.error?i(Ea(e.error)):i(null,Ea(e.data)))}else{const i=new Set,n=e.hasCallback?(e,n)=>{this.target.postMessage({id:t,type:"",sourceMapId:this.mapId,error:e?Sa(e):null,data:Sa(n,i)},i)}:t=>{},r=Ea(e.data);if(this.parent[e.type])this.parent[e.type](e.sourceMapId,r,n);else if(this.parent.getWorkerSource){const t=e.type.split(".");this.parent.getWorkerSource(e.sourceMapId,t[0],r.source,r.scope)[t[1]](r,n)}else n(new Error(`Could not find function ${e.type}`))}}remove(){this.scheduler.remove(),this.target.removeEventListener("message",this.receive,!1)}}class ox{constructor(t,e){this.workerPool=t,this.actors=[],this.currentActor=0,this.id=ni();const i=this.workerPool.acquire(this.id);for(let t=0;t{this.ready=!0}))}broadcast(t,e,i){Qe(this.actors,((i,n)=>{i.send(t,e,n)}),i=i||function(){})}getActor(){return this.currentActor=(this.currentActor+1)%this.actors.length,this.actors[this.currentActor]}remove(){this.actors.forEach((t=>{t.remove()})),this.actors=[],this.workerPool.release(this.id)}}ox.Actor=rx;var sx={workerUrl:"",workerClass:null,workerParams:void 0};function ax(){return null!=sx.workerClass?new sx.workerClass:new self.Worker(sx.workerUrl,sx.workerParams)}const lx="mapboxgl_preloaded_worker_pool";class cx{constructor(){this.active={}}acquire(t){if(!this.workers)for(this.workers=[];this.workers.length{t.terminate()})),this.workers=null)}isPreloaded(){return!!this.active[lx]}numActive(){return Object.keys(this.active).length}}let dx;function ux(){return dx||(dx=new cx),dx}cx.workerCount=2;let hx,px,fx,mx,_x,gx=null;function yx(){return gi()&&self.worker&&self.worker.dracoUrl?self.worker.dracoUrl:px||n.DRACO_URL}function vx(){if(gi()&&self.worker&&self.worker.meshoptUrl)return self.worker.meshoptUrl;if(mx)return mx;const t=new Uint8Array([0,97,115,109,1,0,0,0,1,4,1,96,0,0,3,3,2,0,0,5,3,1,0,1,12,1,0,10,22,2,12,0,65,0,65,0,65,0,252,10,0,0,11,7,0,65,0,253,15,26,11]);if("object"!=typeof WebAssembly)throw new Error("WebAssembly not supported, cannot instantiate meshoptimizer");return mx=WebAssembly.validate(t)?n.MESHOPT_SIMD_URL:n.MESHOPT_URL,mx}const xx={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},bx={5120:"DT_INT8",5121:"DT_UINT8",5122:"DT_INT16",5123:"DT_UINT16",5125:"DT_UINT32",5126:"DT_FLOAT32"},wx={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16};function Tx(t,e,i){const n=i.json.bufferViews.length,r=i.buffers.length;e.bufferView=n,i.json.bufferViews[n]={buffer:r,byteLength:t.byteLength},i.buffers[r]=t}const Sx="KHR_draco_mesh_compression";function Ex(t,e){const i=t.extensions&&t.extensions[Sx];if(!i)return;const n=new fx.Decoder,r=$x(e,i.bufferView),o=new fx.Mesh;if(!n.DecodeArrayToMesh(r,r.byteLength,o))throw new Error("Failed to decode Draco mesh");const s=e.json.accessors[t.indices],a=xx[s.componentType],l=s.count*a.BYTES_PER_ELEMENT,c=fx._malloc(l);a===Uint16Array?n.GetTrianglesUInt16Array(o,l,c):n.GetTrianglesUInt32Array(o,l,c),Tx(fx.memory.buffer.slice(c,c+l),s,e),fx._free(c);for(const r of Object.keys(i.attributes)){const s=n.GetAttributeByUniqueId(o,i.attributes[r]),a=e.json.accessors[t.attributes[r]],l=bx[a.componentType],c=a.count*wx[a.type]*xx[a.componentType].BYTES_PER_ELEMENT,d=fx._malloc(c);n.GetAttributeDataArrayForAllPoints(o,s,fx[l],c,d),Tx(fx.memory.buffer.slice(d,d+c),a,e),fx._free(d)}n.destroy(),o.destroy(),delete t.extensions[Sx]}const Mx="EXT_meshopt_compression";function Cx(t,e){if(!t.extensions||!t.extensions[Mx])return;const i=t.extensions[Mx],n=new Uint8Array(e.buffers[i.buffer],i.byteOffset||0,i.byteLength||0),r=new Uint8Array(i.count*i.byteStride);_x.decodeGltfBuffer(r,i.count,i.byteStride,n,i.mode,i.filter),t.buffer=e.buffers.length,t.byteOffset=0,e.buffers[t.buffer]=r.buffer,delete t.extensions[Mx]}const Ax=1179937895,Ix=new TextDecoder("utf8");function Lx(t,e){return new URL(t,e).href}function Px(t,e,i,n){return fetch(Lx(t.uri,n)).then((t=>t.arrayBuffer())).then((t=>{e.buffers[i]=t}))}function $x(t,e){const i=t.json.bufferViews[e];return new Uint8Array(t.buffers[i.buffer],i.byteOffset||0,i.byteLength)}function kx(t,e,i,n){if(t.uri){const r=Lx(t.uri,n);return fetch(r).then((t=>t.blob())).then((t=>createImageBitmap(t))).then((t=>{e.images[i]=t}))}if(void 0!==t.bufferView){const n=$x(e,t.bufferView),r=new Blob([n],{type:t.mimeType});return createImageBitmap(r).then((t=>{e.images[i]=t}))}}function Dx(t,e=0,i){const n={json:null,images:[],buffers:[]};if(new Uint32Array(t,e,1)[0]===Ax){const i=new Uint32Array(t,e);let r=2;const o=(i[r++]>>2)-3,s=i[r++]>>2;if(r++,n.json=JSON.parse(Ix.decode(i.subarray(r,r+s))),r+=s,r{const t=[],e=a&&a.includes(Sx),r=a&&a.includes(Mx);if(e&&t.push(function(){if(!fx)return hx||(hx=function(t){let e,i=null;function n(){e=new Uint8Array(i.buffer)}function r(){throw new Error("Unexpected Draco error.")}const o={a:{a:r,d:function(t,i,n){return e.copyWithin(t,i,i+n)},c:function(t){const r=e.length,o=Math.max(t>>>0,Math.ceil(1.2*r)),s=Math.ceil((o-r)/65536);try{return i.grow(s),n(),!0}catch(t){return!1}},b:r}};return(WebAssembly.instantiateStreaming?WebAssembly.instantiateStreaming(t,o):t.then((t=>t.arrayBuffer())).then((t=>WebAssembly.instantiate(t,o)))).then((t=>{const{Rb:r,Qb:o,P:s,T:a,X:l,Ja:c,La:d,Qa:u,Va:h,Wa:p,eb:f,jb:m,f:_,e:g,yb:y,zb:v,Ab:x,Bb:b,Db:w,Gb:T}=t.instance.exports;i=g;const S=(()=>{let t=0,i=0,n=0,s=0;return a=>{n&&(r(s),r(t),i+=n,n=t=0),t||(i+=128,t=o(i));const l=a.length+7&-8;let c=t;l>=i&&(n=l,c=s=o(l));for(let t=0;t{fx=t,hx=void 0})))}()),r&&t.push(function(){if(_x)return;const t=function(t){let e;const i=WebAssembly.instantiateStreaming(t,{}).then((t=>{e=t.instance,e.exports.__wasm_call_ctors()})),n={NONE:"",OCTAHEDRAL:"meshopt_decodeFilterOct",QUATERNION:"meshopt_decodeFilterQuat",EXPONENTIAL:"meshopt_decodeFilterExp"},r={ATTRIBUTES:"meshopt_decodeVertexBuffer",TRIANGLES:"meshopt_decodeIndexBuffer",INDICES:"meshopt_decodeIndexSequence"};return{ready:i,supported:!0,decodeGltfBuffer(t,i,o,s,a,l){!function(t,e,i,n,r,o,s){const a=t.exports.sbrk,l=n+3&-4,c=a(l*r),d=a(o.length),u=new Uint8Array(t.exports.memory.buffer);u.set(o,d);const h=e(c,n,r,d,o.length);if(0===h&&s&&s(c,l,r),i.set(u.subarray(c,c+n*r)),a(c-a(0)),0!==h)throw new Error(`Malformed buffer data: ${h}`)}(e,e.exports[r[a]],t,i,o,s,e.exports[n[l]])}}}(fetch(vx()));return t.ready.then((()=>{_x=t}))}()),o)for(let e=0;e{if(e&&s)for(const{primitives:t}of s)for(const e of t)Ex(e,n);if(r&&s&&l)for(const t of l)Cx(t,n);return n}))}))}function zx(t,e){const i=t.json.bufferViews[e.bufferView],n=xx[e.componentType];return new n(t.buffers[i.buffer],(e.byteOffset||0)+(i.byteOffset||0),e.count*(i.byteStride&&i.byteStride!==wx[e.type]*n.BYTES_PER_ELEMENT?i.byteStride/n.BYTES_PER_ELEMENT:wx[e.type]))}function Rx(t,e,i,n){const r=xx[e.componentType],o=function(t){switch(t){case Int8Array:return 1/127;case Uint8Array:return 1/255;case Int16Array:return 1/32767;case Uint16Array:return 1/65535;default:return 1}}(r),s=t.json.bufferViews[e.bufferView],a=s.byteStride?s.byteStride/r.BYTES_PER_ELEMENT:wx[e.type],l=i.float32,c=l.length/i.capacity;for(let t=0,i=0;t0){for(let r=0;r0){o.texcoordArray=new ic;const t=e.json.accessors[r.TEXCOORD_0];o.texcoordArray.resize(t.count);const i=zx(e,t);Rx(e,t,o.texcoordArray,i)}if(void 0!==r._FEATURE_ID_RGBA4444){const t=e.json.accessors[r._FEATURE_ID_RGBA4444];e.json.extensionsUsed&&e.json.extensionsUsed.includes("EXT_meshopt_compression")&&(o.featureData=zx(e,t))}void 0!==r._FEATURE_RGBA4444&&(o.featureData=new Uint32Array(zx(e,e.json.accessors[r._FEATURE_RGBA4444]).buffer));const u=t.material;return o.material=function(t,e){const{emissiveFactor:i=[0,0,0],alphaMode:n="OPAQUE",alphaCutoff:r=.5,normalTexture:o,occlusionTexture:s,emissiveTexture:a,doubleSided:l}=t,{baseColorFactor:c=[1,1,1,1],metallicFactor:d=1,roughnessFactor:u=1,baseColorTexture:h,metallicRoughnessTexture:p}=t.pbrMetallicRoughness||{},f=s?e[s.index]:void 0;if(s&&s.extensions&&s.extensions.KHR_texture_transform&&f){const t=s.extensions.KHR_texture_transform;f.offsetScale=[t.offset[0],t.offset[1],t.scale[0],t.scale[1]]}return{pbrMetallicRoughness:{baseColorFactor:new Un(...c),metallicFactor:d,roughnessFactor:u,baseColorTexture:h?e[h.index]:void 0,metallicRoughnessTexture:p?e[p.index]:void 0},doubleSided:l,emissiveFactor:i,alphaMode:n,alphaCutoff:r,normalTexture:o?e[o.index]:void 0,occlusionTexture:f,emissionTexture:a?e[a.index]:void 0,defined:void 0===t.defined}}(void 0!==u?e.json.materials[u]:{defined:!1},i),o}function Bx(e,i,n){const{matrix:r,rotation:o,translation:s,scale:a,mesh:l,extras:c,children:d}=e,u={};if(u.matrix=r||t.ad.fromRotationTranslationScale([],o||[0,0,0,1],s||[0,0,0],a||[1,1,1]),void 0!==l){u.meshes=n[l];const t=u.anchor=[0,0];for(const e of u.meshes){const{min:i,max:n}=e.aabb;t[0]+=i[0]+n[0],t[1]+=i[1]+n[1]}t[0]=Math.floor(t[0]/u.meshes.length/2),t[1]=Math.floor(t[1]/u.meshes.length/2)}if(c&&(c.id&&(u.id=c.id),c.lights&&(u.lights=function(t){if(!t.length)return[];const e=function(t){const e=atob(t),i=new Uint8Array(e.length);for(let t=0;t1&&n[n.length-1].equals(n[0])&&n.pop();let r=0;for(let t=0;t0&&n.reverse();const o=xh(n.flatMap((t=>[t.x,t.y])),[]);return 0===o.length?null:{vertices:n,indices:o}}function Ux(e,i){const n=[],r=[];let o=0;const s=[];for(const a of e){o=n.length;const e=a.vertexArray.float32,l=a.indexArray.uint16;for(let r=0;r0&&([r[t+1],r[t+2]]=[r[t+2],r[t+1]])}return{vertices:n,indices:r}}function jx(t){const e=function(t,e){const i=[],n=WebGL2RenderingContext;if(t.json.textures)for(const r of t.json.textures){const o={magFilter:n.LINEAR,minFilter:n.NEAREST,wrapS:n.REPEAT,wrapT:n.REPEAT};void 0!==r.sampler&&Object.assign(o,t.json.samplers[r.sampler]),i.push({image:e[r.source],sampler:o,uploaded:!1})}return i}(t,t.images),i=function(t,e){const i=[];for(const n of t.json.meshes){const r=[];for(const i of n.primitives)r.push(Ox(i,t,e));i.push(r)}return i}(t,e),{scenes:n,scene:r,nodes:o}=t.json,s=n?n[r||0].nodes:o,a=[];for(const e of s)a.push(Bx(o[e],t,i));return function(t,e,i){const n={},r=new Set;for(let o=0;o0){const e=Array.from(r.values()).sort(((t,e)=>t-e));for(let i=e.length-1;i>=0;i--)t.splice(e[i],1)}}(a,s,t.json.nodes),a}function Vx(t){t.heightmap=new Float32Array(4096),t.heightmap.fill(-1);const e=t.vertexArray.float32,i=t.aabb.min[0]-1,n=t.aabb.min[1]-1,r=Wv/(t.aabb.max[0]-i+2),o=Wv/(t.aabb.max[1]-n+2);for(let s=0;st.heightmap[c*Wv+l]&&(t.heightmap[c*Wv+l]=a)}}function Gx(e,i){const n={};n.indexArray=new Kl,n.indexArray.reserve(4*e.length),n.vertexArray=new Bl,n.vertexArray.reserve(10*e.length),n.colorArray=new Ol,n.vertexArray.reserve(10*e.length);let r=0;for(const o of e){const e=Math.min(10,Math.max(4,1.3*o.height))*i,s=[-o.normal[1],o.normal[0],0],a=Math.min(.29,.1*o.width/o.depth),l=o.width-2*o.depth*i*(a+.01),c=t._.scaleAndAdd([],o.pos,s,l/2),d=t._.scaleAndAdd([],o.pos,s,-l/2),u=[c[0],c[1],c[2]+o.height],h=[d[0],d[1],d[2]+o.height],p=t._.scaleAndAdd([],o.normal,s,a);t._.scale(p,p,e);const f=t._.scaleAndAdd([],o.normal,s,-a);t._.scale(f,f,e),t._.add(p,c,p),t._.add(f,d,f),c[2]+=.1,d[2]+=.1,n.vertexArray.emplaceBack(p[0],p[1],p[2]),n.vertexArray.emplaceBack(f[0],f[1],f[2]),n.vertexArray.emplaceBack(c[0],c[1],c[2]),n.vertexArray.emplaceBack(d[0],d[1],d[2]),n.vertexArray.emplaceBack(u[0],u[1],u[2]),n.vertexArray.emplaceBack(h[0],h[1],h[2]),n.vertexArray.emplaceBack(c[0],c[1],c[2]),n.vertexArray.emplaceBack(d[0],d[1],d[2]),n.vertexArray.emplaceBack(p[0],p[1],p[2]),n.vertexArray.emplaceBack(f[0],f[1],f[2]);const m=l/e/2;n.colorArray.emplaceBack(-m-a,-1,m,.8),n.colorArray.emplaceBack(m+a,-1,m,.8),n.colorArray.emplaceBack(-m,0,m,1.3),n.colorArray.emplaceBack(m,0,m,1.3),n.colorArray.emplaceBack(m+a,-.8,m,.7),n.colorArray.emplaceBack(m+a,-.8,m,.7),n.colorArray.emplaceBack(0,0,m,1.3),n.colorArray.emplaceBack(0,0,m,1.3),n.colorArray.emplaceBack(m+a,-1.2,m,.8),n.colorArray.emplaceBack(m+a,-1.2,m,.8),n.indexArray.emplaceBack(6+r,4+r,8+r),n.indexArray.emplaceBack(7+r,9+r,5+r),n.indexArray.emplaceBack(0+r,1+r,2+r),n.indexArray.emplaceBack(1+r,3+r,2+r),r+=10}const o={defined:!0,emissiveFactor:[0,0,0]},s={};return s.baseColorFactor=Un.white,o.pbrMetallicRoughness=s,n.material=o,n.aabb=new wu([1/0,1/0,1/0],[-1/0,-1/0,-1/0]),n}const Zx=new Float32Array(262144),qx=new Uint8Array(262144);function Hx(t){let e=0;if(t.meshes)for(const i of t.meshes)e=Math.max(e,i.aabb.max[2]);if(t.children)for(const i of t.children)e=Math.max(e,Hx(i));return e}function Wx(t,e,i){if(t.meshes)for(const n of t.meshes)n.aabb.min[0]!==1/0&&i.insert(e,n.aabb.min[0],n.aabb.min[1],n.aabb.max[0],n.aabb.max[1]);if(t.children)for(const n of t.children)Wx(n,e,i)}const Yx=["","wall","door","roof","window","lamp","logo"];class Xx{constructor(t){this.node=t,this.evaluatedRMEA=[[1,0,0,1],[1,0,0,1],[1,0,0,1],[1,0,0,1],[.4,1,0,1],[1,0,0,1],[1,0,0,1]],this.hiddenByReplacement=!1,this.evaluatedScale=[1,1,1],this.evaluatedColor=[],this.emissionHeightBasedParams=[],this.feature={type:"Point",id:t.id,geometry:[],properties:{height:Hx(t)}},this.aabb=this._getLocalBounds()}_getLocalBounds(){if(!this.node.meshes)return new wu([1/0,1/0,1/0],[-1/0,-1/0,-1/0]);if(!this.aabb){let t=0;const e=new wu([1/0,1/0,1/0],[-1/0,-1/0,-1/0]);for(const i of this.node.meshes)this.node.lightMeshIndex!==t&&(i.transformedAabb=wu.applyTransformFast(i.aabb,this.node.matrix),e.encapsulate(i.transformedAabb)),t++;this.aabb=e}return this.aabb}}class Kx{constructor(t,e,i,n,r,o){this.id=e,this.modelTraits|=Yv.CoordinateSpaceTile,this.uploaded=!1,this.hasPattern=!1,i&&(this.modelTraits|=Yv.HasMapboxMeshFeatures),n&&(this.modelTraits|=Yv.HasMeshoptCompression),this.zoom=-1,this.terrainExaggeration=1,this.projection={name:"mercator"},this.replacementUpdateTime=0,this.elevationReadFromZ=255,this.brightness=r,this.dirty=!0,this.needsUpload=!1,this.nodesInfo=[];for(const e of t)this.nodesInfo.push(new Xx(e)),Wx(e,o.featureIndexArray.length,o.grid),o.featureIndexArray.emplaceBack(this.nodesInfo.length-1,0,o.bucketLayerIDs.length-1,0)}updateFootprints(t,e){for(const i of this.getNodesInfo()){const n=i.node;n.footprint&&e.push({footprint:n.footprint,id:t})}}update(){console.log("Update 3D model bucket")}populate(){console.log("populate 3D model bucket")}uploadPending(){return!this.uploaded||this.needsUpload}upload(t){if(!this.needsUpload)return;const e=this.getNodesInfo();for(const i of e){const e=i.node;this.uploaded?this.updatePbrBuffer(e):Qv(e,t,!0)}for(const t of e)tx(t.node);this.uploaded=!0,this.needsUpload=!1}updatePbrBuffer(t){let e=!1;if(!t.meshes)return e;for(const i of t.meshes)i.pbrBuffer&&(i.pbrBuffer.updateData(i.featureArray),e=!0);return e}needsReEvaluation(t,e,i){const n=t.transform.projectionOptions,r=t.style.getBrightness(),o=this.brightness!==r;return!!(!this.uploaded||this.dirty||n.name!==this.projection.name||Jx(i.paint.get("model-color").value,o)||Jx(i.paint.get("model-color-mix-intensity").value,o)||Jx(i.paint.get("model-roughness").value,o)||Jx(i.paint.get("model-emissive-strength").value,o)||Jx(i.paint.get("model-height-based-emissive-strength-multiplier").value,o))&&(this.projection=n,this.brightness=r,!0)}evaluateScale(t,e){if(t.transform.zoom===this.zoom)return;this.zoom=t.transform.zoom;const i=this.getNodesInfo(),n=this.id.canonical;for(const t of i){const i=t.feature;t.evaluatedScale=e.paint.get("model-scale").evaluate(i,{},n)}}evaluate(t){const e=this.getNodesInfo();for(const i of e){if(!i.node.meshes)continue;const e=i.feature,n=i.node.meshes&&i.node.meshes[0].featureData,r=i.evaluatedColor[2],o=i.evaluatedRMEA[2],s=this.id.canonical;if(i.hasTranslucentParts=!1,n){for(let n=0;n=t)continue;const u=Zx[c],h=Math.abs(u);h>a&&(s=u,a=h,l=r,d=e)}if(a>.1){const o=1-(t+.5*Math.abs(l*d))/c;let a=e._dem.get(n,i)+s*o;const u=e._dem.get(n+l,i+d),h=e._dem.get(n-l,i-d,!0);(a-u)*(a-h)>0&&(a=(u+h)/2),Zx[r]=e._dem.set(n,i,a),qx[r]=t}}}}}s&&(e._demTile.needsDEMTextureUpload=!0,e._dem._timestamp=ki.now())}getNodesInfo(){return this.nodesInfo}destroy(){const t=this.getNodesInfo();for(const e of t)tx(e.node),ex(e.node)}isEmpty(){return!this.nodesInfo.length}updateReplacement(t,e){if(e.updateTime===this.replacementUpdateTime)return;this.replacementUpdateTime=e.updateTime;const i=e.getReplacementRegionsForTile(t.toUnwrapped()),n=this.getNodesInfo();for(let t=0;tt.footprint===e.footprint))}}getHeightAtTileCoord(e,i){const n=this.getNodesInfo(),r=[],o=[0,0,0],s=t.ad.identity([]);for(let a=0;ad.max[0]||i>d.max[1])continue;if(!0===l.node.hidden)return{height:0,maxHeight:l.feature.properties.height,hidden:!1,verticalScale:l.evaluatedScale[2]};t.ad.invert(s,l.node.matrix),o[0]=e,o[1]=i,t._.transformMat4(o,o,s);const u=(o[0]-c.aabb.min[0])/(c.aabb.max[0]-c.aabb.min[0])*Wv|0,h=Math.min(63,(o[1]-c.aabb.min[1])/(c.aabb.max[1]-c.aabb.min[1])*Wv|0)*Wv+Math.min(63,u),p=c.heightmap[h];if(!(p0)return{height:void 0,maxHeight:l.feature.properties.height,hidden:l.hiddenByReplacement,verticalScale:l.evaluatedScale[2]}}}}function Jx(t,e){return!t.isLightConstant&&e}function Qx(t,e,i,n,r,o,s,a){let l=(61440&e|(61440&e)>>4)>>8,c=(3840&e|(3840&e)>>4)>>4,d=240&e|(240&e)>>4;i[3]>0&&(l=Vn(l,255*i[0],i[3]),c=Vn(c,255*i[1],i[3]),d=Vn(d,255*i[2],i[3]));const u=l>16&65535,a=o?e>>16&65535:65535&e,l=(15&a)t.polygon)).flat());const g=f?l:null,[y,v]=function(e,i,n,r,o,s,a,l,c,d,u){return"globe"===e.projection.name?function(e,i,n,r,o,s,a,l,c,d,u){const h=[],p=[],f=e.projection.upVectorScale(u,e.center.lat,e.worldSize).metersToTile,m=[0,0,0,1],_=[0,0,0,1],g=(t,e,i,n)=>{t[0]=e,t[1]=i,t[2]=n,t[3]=1},y=Sf();n>0&&(n+=y),r+=y;for(const y of i){const i=[],v=[];for(const h of y){const p=h.x+o.x,y=h.y+o.y,x=e.projection.projectTilePoint(p,y,u),b=e.projection.upVector(u,h.x,h.y);let w=n,T=r;if(a){const t=Pf(p,y,n,r,a,l,c,d);w+=t.base,T+=t.top}0!==n?g(m,x.x+b[0]*f*w,x.y+b[1]*f*w,x.z+b[2]*f*w):g(m,x.x,x.y,x.z),g(_,x.x+b[0]*f*T,x.y+b[1]*f*T,x.z+b[2]*f*T),t._.transformMat4(m,m,s),t._.transformMat4(_,_,s),i.push(new Tp(m[0],m[1],m[2])),v.push(new Tp(_[0],_[1],_[2]))}h.push(i),p.push(v)}return[h,p]}(e,i,n,r,o,s,a,l,c,d,u):a?function(e,i,n,r,o,s,a,l,c){const d=[],u=[],h=[0,0,0,1];for(const p of e){const e=[],f=[];for(const d of p){const u=d.x+r.x,p=d.y+r.y,m=Pf(u,p,i,n,s,a,l,c);h[0]=u,h[1]=p,h[2]=m.base,h[3]=1,t.aA.transformMat4(h,h,o),h[3]=Math.max(h[3],1e-5);const _=new Tp(h[0]/h[3],h[1]/h[3],h[2]/h[3]);h[0]=u,h[1]=p,h[2]=m.top,h[3]=1,t.aA.transformMat4(h,h,o),h[3]=Math.max(h[3],1e-5);const g=new Tp(h[0]/h[3],h[1]/h[3],h[2]/h[3]);e.push(_),f.push(g)}d.push(e),u.push(f)}return[d,u]}(i,n,r,o,s,a,l,c,d):function(t,e,i,n,r){const o=[],s=[],a=r[8]*e,l=r[9]*e,c=r[10]*e,d=r[11]*e,u=r[8]*i,h=r[9]*i,p=r[10]*i,f=r[11]*i;for(const e of t){const t=[],i=[];for(const o of e){const e=o.x+n.x,s=o.y+n.y,m=r[0]*e+r[4]*s+r[12],_=r[1]*e+r[5]*s+r[13],g=r[2]*e+r[6]*s+r[14],y=r[3]*e+r[7]*s+r[15],v=m+a,x=_+l,b=g+c,w=Math.max(y+d,1e-5),T=m+u,S=_+h,E=g+p,M=Math.max(y+f,1e-5);t.push(new Tp(v/w,x/w,b/w)),i.push(new Tp(T/M,S/M,E/M))}o.push(t),s.push(i)}return[o,s]}(i,n,r,o,s)}(s,r,h,u,d,a,g,p,m,s.center.lat,e.tileID.canonical),x=e.queryGeometry;return function(t,e,i){let n=1/0;Kd(i,e)&&(n=Lf(i,e[0]));for(let r=0;r=3)for(let e=0;e>4;if(1!==n)throw new Error(`Got v${n} data when expected v1.`);const r=nb[15&i];if(!r)throw new Error("Unrecognized array type.");const[o]=new Uint16Array(t,2,1),[s]=new Uint32Array(t,4,1);return new rb(s,o,r,t)}constructor(t,e=64,i=Float64Array,n){if(isNaN(t)||t>1;return this.ids[i]=i,this.coords[this._pos++]=t,this.coords[this._pos++]=e,i}finish(){const t=this._pos>>1;if(t!==this.numItems)throw new Error(`Added ${t} items when expected ${this.numItems}.`);return ob(this.ids,this.coords,this.nodeSize,0,this.numItems-1,0),this._finished=!0,this}range(t,e,i,n){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");const{ids:r,coords:o,nodeSize:s}=this,a=[0,r.length-1,0],l=[];for(;a.length;){const c=a.pop()||0,d=a.pop()||0,u=a.pop()||0;if(d-u=t&&a=e&&c>1,p=o[2*h],f=o[2*h+1];p>=t&&p=e&&f=p:n>=f)&&(a.push(h+1),a.push(d),a.push(1-c))}return l}within(t,e,i){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");const{ids:n,coords:r,nodeSize:o}=this,s=[0,n.length-1,0],a=[],l=i*i;for(;s.length;){const c=s.pop()||0,d=s.pop()||0,u=s.pop()||0;if(d-u>1,p=r[2*h],f=r[2*h+1];cb(p,f,t,e)=p:e+i>=f)&&(s.push(h+1),s.push(d),s.push(1-c))}return a}}function ob(t,e,i,n,r,o){if(r-n>1;sb(t,e,s,n,r,o),ob(t,e,i,n,s-1,1-o),ob(t,e,i,s+1,r,1-o)}function sb(t,e,i,n,r,o){for(;r>n;){if(r-n>600){const s=r-n+1,a=i-n+1,l=Math.log(s),c=.5*Math.exp(2*l/3),d=.5*Math.sqrt(l*c*(s-c)/s)*(a-s/2s&&ab(t,e,n,r);as;)l--}e[2*n+o]===s?ab(t,e,n,l):(l++,ab(t,e,l,r)),lr&&(n+=(t[i]-r)*(t[i]-r)),e[i]0&&n[0]0&&n[1]0&&r[0]0&&r[1]0?Math.acos(i/n)*Ve:0;let o=0!==t||0!==e?Math.atan2(-e,-t)*Ve+90:0;return oNi&&(t.getActor().send("enforceCacheSizeLimit",Fi),Vi=0)},t.an=gn,t.ao=class{constructor(t){this.entries={},this.scheduler=t}request(t,e,i,n){const r=this.entries[t]=this.entries[t]||{callbacks:[]};if(r.result){const[t,i]=r.result;return this.scheduler?this.scheduler.add((()=>{n(t,i)}),e):n(t,i),()=>{}}return r.callbacks.push(n),r.cancel||(r.cancel=i(((i,n)=>{r.result=[i,n];for(const t of r.callbacks)this.scheduler?this.scheduler.add((()=>{t(i,n)}),e):t(i,n);setTimeout((()=>delete this.entries[t]),3e3)}))),()=>{r.result||(r.callbacks=r.callbacks.filter((t=>t!==n)),r.callbacks.length||(r.cancel(),delete this.entries[t]))}}},t.ap=function(t,e,i){const n=JSON.stringify(t.request);return t.data&&(this.deduped.entries[n]={result:[null,t.data]}),this.deduped.request(n,{type:"parseTile",isSymbolTile:t.isSymbolTile,zoom:t.tileZoom},(e=>{const n=en(t.request,((t,n,r,o)=>{t?e(t):n&&e(null,{vectorTile:i?void 0:new bp(new Lm(n)),rawData:n,cacheControl:r,expires:o})}));return()=>{n.cancel(),e()}}),e)},t.aq=Dc,t.ar=class extends Lc{constructor(t){super(t),this.current=Fc}set(t,e,i){if(this.fetchUniformLocation(t,e))for(let t=0;t({u_camera_to_center_distance:new $c(t),u_extrude_scale:new Uc(t),u_device_pixel_ratio:new $c(t),u_matrix:new Bc(t),u_inv_rot_matrix:new Bc(t),u_merc_center:new kc(t),u_tile_id:new Dc(t),u_zoom_transition:new $c(t),u_up_dir:new Dc(t),u_emissive_strength:new $c(t)}),t.bJ=t=>({u_matrix:new Bc(t),u_pixels_to_tile_units:new Uc(t),u_device_pixel_ratio:new $c(t),u_units_to_pixels:new kc(t),u_dash_image:new Pc(t),u_gradient_image:new Pc(t),u_image_height:new $c(t),u_texsize:new kc(t),u_tile_units_to_pixels:new $c(t),u_alpha_discard_threshold:new $c(t),u_trim_offset:new kc(t),u_trim_fade_range:new kc(t),u_trim_color:new zc(t),u_emissive_strength:new $c(t)}),t.bK=t=>({u_matrix:new Bc(t),u_texsize:new kc(t),u_pixels_to_tile_units:new Uc(t),u_device_pixel_ratio:new $c(t),u_image:new Pc(t),u_units_to_pixels:new kc(t),u_tile_units_to_pixels:new $c(t),u_alpha_discard_threshold:new $c(t),u_trim_offset:new kc(t)}),t.bL=Yl,t.bM=Hf,t.bN=Om,t.bO=jm,t.bP=G_,t.bQ=c_,t.bR=th,t.bS=(t,e,i,n,r,o)=>{const s=t.transform,a="globe"===s.projection.name;let l;if("map"===o.paint.get("circle-pitch-alignment"))if(a){const t=Zu(s.zoom,e.canonical)*s._pixelsPerMercatorPixel;l=Float32Array.from([t,0,0,t])}else l=s.calculatePixelsToTileUnitsMatrix(i);else l=new Float32Array([s.pixelsToGLUnits[0],0,0,s.pixelsToGLUnits[1]]);const c={u_camera_to_center_distance:t.transform.getCameraToCenterDistance(s.projection),u_matrix:t.translatePosMatrix(e.projMatrix,i,o.paint.get("circle-translate"),o.paint.get("circle-translate-anchor")),u_device_pixel_ratio:ki.devicePixelRatio,u_extrude_scale:l,u_inv_rot_matrix:Qu,u_merc_center:[0,0],u_tile_id:[0,0,0],u_zoom_transition:0,u_up_dir:[0,0,0],u_emissive_strength:o.paint.get("circle-emissive-strength")};if(a){c.u_inv_rot_matrix=n,c.u_merc_center=r,c.u_tile_id=[e.canonical.x,e.canonical.y,1{const s=t.transform;return{u_matrix:rm(t,e,i,n),u_texsize:e.imageAtlasTexture?e.imageAtlasTexture.size:[0,0],u_pixels_to_tile_units:s.calculatePixelsToTileUnitsMatrix(e),u_device_pixel_ratio:r,u_image:0,u_tile_units_to_pixels:nm(e,s),u_units_to_pixels:[1/s.pixelsToGLUnits[0],1/s.pixelsToGLUnits[1]],u_alpha_discard_threshold:0,u_trim_offset:o}},t.bV=(t,e,i,n,r,o,s)=>{const a=t.transform,l=a.calculatePixelsToTileUnitsMatrix(e);return{u_matrix:rm(t,e,i,n),u_pixels_to_tile_units:l,u_device_pixel_ratio:o,u_units_to_pixels:[1/a.pixelsToGLUnits[0],1/a.pixelsToGLUnits[1]],u_dash_image:0,u_gradient_image:1,u_image_height:r,u_texsize:sm(i)&&e.lineAtlasTexture?e.lineAtlasTexture.size:[0,0],u_tile_units_to_pixels:nm(e,t.transform),u_alpha_discard_threshold:0,u_trim_offset:s,u_trim_fade_range:i.paint.get("line-trim-fade-range"),u_trim_color:i.paint.get("line-trim-color").toRenderColor(i.lut).toArray01(),u_emissive_strength:i.paint.get("line-emissive-strength")}},t.bW=oi,t.bX=mh,t.bY=Sf,t.bZ=bd,t.b_=_f,t.ba=function(t,e,i){const n=Hu(i.zoom),r=t.style.map._antialias,o=e.options.extStandardDerivativesForceOff||t.terrain&&t.terrain.exaggeration()>0;return 0===n&&!r&&!o},t.bb=function(e){const i=e.pixelsPerMeter,n=i/Cd(1,e.center.lat),r=t.ad.identity(new Float64Array(16));return t.ad.translate(r,r,[e.point.x,e.point.y,0]),t.ad.scale(r,r,[n,n,i]),Float32Array.from(r)},t.bc=Ou,t.bd=function(t){const e=Pd-5;t=Xe(t,-e,e)/e*90;const i=Math.pow(Math.abs(Math.sin(Ge(t))),3);return Math.round(i*(sd.length-1))},t.be=function(e,i,n,r){const o=i.getNorth(),s=i.getSouth(),a=i.getWest(),l=i.getEast(),c=10){const e=180/r;t.bC.multiply(f,f,[e/d+1,0,0,0,e/u+1,0,-.5*e/h,.5*e/p,1])}return f[2]=c,f[5]=e.x,f[8]=e.y,f},t.bf=ju,t.bg=$u,t.bh=function(e,i,n){const r=t.ad.identity(new Float64Array(16)),o=(i/(1{}}},t.bo=Gg,t.bp=ai,t.bq=class{isDataAvailableAtPoint(t){const e=this._source();if(this.isUsingMockSource()||!e||t.y1)return!1;const i=e.getSource().maxzoom,n=11)return e;const r=n.getSource().maxzoom,o=1{const s=this.getAtTileOffset(e,o.x,o.y),a=r.upVector(e.canonical,o.x,o.y),l=r.upVectorScale(e.canonical,i,n).metersToTile;return t._.scale(a,a,s*l),a}}getForTilePoints(t,e,i,n){if(this.isUsingMockSource())return!1;const r=Xp.create(this,t,n);return!!r&&(e.forEach((t=>{t[2]=this.exaggeration()*r.getElevationAt(t[0],t[1],i)})),!0)}getMinMaxForTile(t){if(this.isUsingMockSource())return null;const e=this.findDEMTileFor(t);if(!e||!e.dem)return null;const i=e.dem.tree,n=e.tileID,r=1=0?t.slice(0,e):t},t.cV=function(t){return t.indexOf(wl)>=0},t.cW=function(t){const e=t.indexOf(wl);return e>=0?t.slice(e+1):""},t.cX=function(t){const e=[],i=t.id;return void 0===i&&e.push({message:`layers.${i}: missing required property "id"`}),void 0===t.render&&e.push({message:`layers.${i}: missing required method "render"`}),t.renderingMode&&"2d"!==t.renderingMode&&"3d"!==t.renderingMode&&e.push({message:`layers.${i}: property "renderingMode" must be either "2d" or "3d"`}),e},t.cY=function(t,e,i,n){return"custom"===t.type?new vv(t,e):new ib[t.type](t,e,i,n)},t.cZ=di,t.c_=Va,t.ca=1,t.cb=Ag,t.cc=0,t.cd=ec,t.ce=function(t,e,i,n,r){return Xe((t-e)/(i-e)*(r-n)+n,n,r)},t.cf=Ns,t.cg=kd,t.ch=class{constructor(t,e,i,n){this.context=t,this.format=n,this.size=i,this.texture=t.gl.createTexture();const[r,o,s]=this.size,{gl:a}=t;a.bindTexture(a.TEXTURE_3D,this.texture),t.pixelStoreUnpackFlipY.set(!1),t.pixelStoreUnpack.set(1),t.pixelStoreUnpackPremultiplyAlpha.set(!1);let l=this.format,c=a.UNSIGNED_BYTE;this.format===a.DEPTH_COMPONENT&&(l=a.DEPTH_COMPONENT16,c=a.UNSIGNED_SHORT),this.format===a.R8&&(n=a.RED),this.format===a.R32F&&(c=a.FLOAT,n=a.RED),a.texImage3D(a.TEXTURE_3D,0,l,r,o,s,0,n,c,e.data)}bind(t,e){const{context:i}=this,{gl:n}=i;n.bindTexture(n.TEXTURE_3D,this.texture),t!==this.minFilter&&(n.texParameteri(n.TEXTURE_3D,n.TEXTURE_MAG_FILTER,t),n.texParameteri(n.TEXTURE_3D,n.TEXTURE_MIN_FILTER,t),this.minFilter=t),e!==this.wrapS&&(n.texParameteri(n.TEXTURE_3D,n.TEXTURE_WRAP_S,e),n.texParameteri(n.TEXTURE_3D,n.TEXTURE_WRAP_T,e),this.wrapS=e)}destroy(){const{gl:t}=this.context;t.deleteTexture(this.texture),this.texture=null}},t.ci=$v,t.cj=[1,1,1],t.ck=Xp,t.cl=Yv,t.cm=ql,t.cn=ic,t.co=class{constructor(){this._updateTime=0,this._sourceIds=[],this._activeRegions=[],this._prevRegions=[],this._globalClipBounds={min:new Ue(1/0,1/0),max:new Ue(-1/0,-1/0)}}clear(){this._activeRegions.length>0&&++this._updateTime,this._activeRegions=[],this._prevRegions=[]}get updateTime(){return this._updateTime}getReplacementRegionsForTile(t,e=!1){const i=$p(new Ue(0,0),new Ue(uo,uo),t),n=[];if(e&&!Lp(i,this._globalClipBounds))return n;for(const e of this._activeRegions){if(e.hiddenByOverlap)continue;if(!Lp(i,e))continue;const r=kp(e.min,e.max,t);n.push({min:r.min,max:r.max,sourceId:this._sourceIds[e.priority],footprint:e.footprint,footprintTileId:e.tileId,order:e.order,clipMask:e.clipMask})}return n}setSources(t){this._setSources(t.map((t=>({getSourceId:()=>t.cache.id,getFootprints:()=>{const e=[];for(const i of t.cache.getVisibleCoordinates()){const n=t.cache.getTile(i).buckets[t.layer];n&&n.updateFootprints(i.toUnwrapped(),e)}return e},getOrder:()=>t.order,getClipMask:()=>t.clipMask}))))}_addSource(t){const e=t.getFootprints();if(0===e.length)return;const i=t.getOrder(),n=t.getClipMask();for(const t of e){if(!t.footprint)continue;const e=$p(t.footprint.min,t.footprint.max,t.id);this._activeRegions.push({min:e.min,max:e.max,hiddenByOverlap:!1,priority:this._sourceIds.length,tileId:t.id,footprint:t.footprint,order:i,clipMask:n})}this._sourceIds.push(t.getSourceId())}_computeReplacement(){this._activeRegions.sort(((t,e)=>t.priority-e.priority||Ap(t.min,e.min)||Ap(t.max,e.max)));let t=this._activeRegions.length!==this._prevRegions.length;if(!t){let e=0;for(;!t&&e!==this._activeRegions.length;){const i=this._activeRegions[e],n=this._prevRegions[e];t=i.priority!==n.priority||!Ip(i,n)||i.order!==n.order||i.clipMask!==n.clipMask,++e}}if(t){++this._updateTime;for(const t of this._activeRegions)t.order!==1/0&&(this._globalClipBounds.min.x=Math.min(this._globalClipBounds.min.x,t.min.x),this._globalClipBounds.min.y=Math.min(this._globalClipBounds.min.y,t.min.y),this._globalClipBounds.max.x=Math.max(this._globalClipBounds.max.x,t.max.x),this._globalClipBounds.max.y=Math.max(this._globalClipBounds.max.y,t.max.y));const t=t=>{const e=this._activeRegions;if(t>=e.length)return t;const i=e[t].priority;for(;t1){let e=0,i=t(e);for(;e!==i;){let n=e;const r=e;for(;n!==i;){const t=this._activeRegions[n];t.hiddenByOverlap=!1;for(let e=0;e=0;e--)this._addSource(t[e]);this._computeReplacement()}},t.cp=Dl,t.cq=Jg,t.cr=rc,t.cs=class{constructor(t){this._createGrid(t),this._createPoles(t)}destroy(){this._poleIndexBuffer.destroy(),this._gridBuffer.destroy(),this._gridIndexBuffer.destroy(),this._poleNorthVertexBuffer.destroy(),this._poleSouthVertexBuffer.destroy();for(const t of this._poleSegments)t.destroy();for(const t of this._gridSegments)t.withSkirts.destroy(),t.withoutSkirts.destroy()}_fillGridMeshWithLods(t,e){const i=new $l,n=new Kl,r=[],o=t+1+2,s=e[0]+1,a=e[0]+1+(1+e.length),l=(t,e,i)=>{let n=t===o-1?t-2:0===t?t:t-1;return n+=i?24575:0,[n,e]};for(let t=0;tt()))},t.dB=sx,t.dC=yx,t.dD=function(t){px=ki.resolveURL(t),gx||(gx=new ox(ux(),new zn)),gx.broadcast("setDracoUrl",px)},t.dE=vx,t.dF=function(t){mx=ki.resolveURL(t),gx||(gx=new ox(ux(),new zn)),gx.broadcast("setMeshoptUrl",mx)},t.dG=ti,t.dH=ba,t.dI=dh,t.dJ=I_,t.dK=eg,t.dL=dc,t.dM=am,t.dN=Dm,t.dO=Wf,t.dP=ci,t.dQ=E_,t.dR=jg,t.dS=function(t,e,i,n,r,o,s,a,l,c,d){t.createArrays(),t.tilePixelRatio=uo/(512*t.overscaling),t.compareText={},t.iconsNeedLinear=!1;const u=t.layers[0].layout,h=t.layers[0]._unevaluatedLayout._values,p={};if("composite"===t.textSizeData.kind){const{minZoom:e,maxZoom:i}=t.textSizeData;p.compositeTextSizes=[h["text-size"].possiblyEvaluate(new Ha(e),a),h["text-size"].possiblyEvaluate(new Ha(i),a)]}if("composite"===t.iconSizeData.kind){const{minZoom:e,maxZoom:i}=t.iconSizeData;p.compositeIconSizes=[h["icon-size"].possiblyEvaluate(new Ha(e),a),h["icon-size"].possiblyEvaluate(new Ha(i),a)]}p.layoutTextSize=h["text-size"].possiblyEvaluate(new Ha(l+1),a),p.layoutIconSize=h["icon-size"].possiblyEvaluate(new Ha(l+1),a),p.textMaxSize=h["text-size"].possiblyEvaluate(new Ha(18),a);const f="map"===u.get("text-rotation-alignment")&&"point"!==u.get("symbol-placement"),m=u.get("text-size");let _=!1;for(const e of t.features)if(e.icon&&e.icon.nameSecondary){_=!0;break}for(const o of t.features){const l=u.get("text-font").evaluate(o,{},a).join(","),h=m.evaluate(o,{},a),g=p.layoutTextSize.evaluate(o,{},a),y=(p.layoutIconSize.evaluate(o,{},a),{horizontal:{},vertical:void 0}),v=o.text;let x,b=[0,0];if(v){const n=v.toString(),s=u.get("text-letter-spacing").evaluate(o,{},a)*Om,c=u.get("text-line-height").evaluate(o,{},a)*Om,d=Aa(n)?s:0,p=u.get("text-anchor").evaluate(o,{},a),m=u.get("text-variable-anchor");if(!m){const t=u.get("text-radial-offset").evaluate(o,{},a);b=t?G_(p,[t*Om,j_]):u.get("text-offset").evaluate(o,{},a).map((t=>t*Om))}let _=f?"center":u.get("text-justify").evaluate(o,{},a);const x="point"===u.get("symbol-placement"),w=x?u.get("text-max-width").evaluate(o,{},a)*Om:1/0,T=o=>{t.allowVerticalPlacement&&Ca(n)&&(y.vertical=e_(v,e,i,r,l,w,c,p,o,d,b,Jm.vertical,!0,g,h))};if(!f&&m){const t="auto"===_?m.map((t=>Z_(t))):[_];let n=!1;for(let o=0;o=0||!Ca(n)){const t=e_(v,e,i,r,l,w,c,p,_,d,b,Jm.horizontal,!1,g,h);t&&(y.horizontal[_]=t)}T(x?"left":_)}}let w=!1;if(o.icon&&o.icon.namePrimary){const e=n[o.icon.namePrimary];e&&(x=u_(r[o.icon.namePrimary],o.icon.nameSecondary?r[o.icon.nameSecondary]:void 0,u.get("icon-offset").evaluate(o,{},a),u.get("icon-anchor").evaluate(o,{},a)),w=e.sdf,void 0===t.sdfIcons?t.sdfIcons=e.sdf:t.sdfIcons!==e.sdf&&pi("Style sheet warning: Cannot mix SDF and non-SDF icons in one buffer"),(e.pixelRatio!==t.pixelRatio||0!==u.get("icon-rotate").constantOr(1))&&(t.iconsNeedLinear=!0))}const T=X_(y.horizontal)||y.vertical;t.iconsInText||(t.iconsInText=!!T&&T.iconsInText),(T||x)&&q_(t,o,y,x,n,p,g,0,b,w,s,a,c,d,_)}o&&t.generateCollisionDebugBuffers(l,t.collisionBoxArray)},t.dT=Jf,t.dU=Yh,t.dV=bp,t.dW=Lm,t.dX=Yp,t.dY=Zy,t.dZ=wp,t.d_=cp,t.da=Wu,t.db=function(e){const i=[0,0,0],n=t.ad.identity(new Float64Array(16));return t.ad.multiply(n,e.pixelMatrix,e.globeMatrix),t._.transformMat4(i,i,n),new Ue(i[0],i[1])},t.dc=d,t.dd=c,t.de=function(t){const e=t.navigator?t.navigator.userAgent:null;return!!function(t){if(null==Ei){const e=t.navigator?t.navigator.userAgent:null;Ei=!!t.safari||!(!e||!(/\b(iPad|iPhone|iPod)\b/.test(e)||e.match("Safari")&&!e.match("Chrome")))}return Ei}(t)&&e&&(e.match("Version/15.4")||e.match("Version/15.5")||e.match(/CPU (OS|iPhone OS) (15_4|15_5) like Mac OS X/))},t.df=ni,t.dg=class{constructor(t,e,i){this._transformRequestFn=t,this._customAccessToken=e,this._silenceAuthErrors=!!i,this._createSkuToken()}_createSkuToken(){const t=function(){let t="";for(let e=0;ethis._skuTokenExpiresAt}transformRequest(t,e){return this._transformRequestFn&&this._transformRequestFn(t,e)||{url:t}}normalizeStyleURL(t,i){if(!o(t))return t;const n=un(t);return n.params.push(`sdk=js-${e}`),n.path=`/styles/v1${n.path}`,this._makeAPIURL(n,this._customAccessToken||i)}normalizeGlyphsURL(t,e){if(!o(t))return t;const i=un(t);return i.path=`/fonts/v1${i.path}`,this._makeAPIURL(i,this._customAccessToken||e)}normalizeModelURL(t,e){if(!o(t))return t;const i=un(t);return i.path=`/models/v1${i.path}`,this._makeAPIURL(i,this._customAccessToken||e)}normalizeSourceURL(t,e,i,n){if(!o(t))return t;const r=un(t);return r.path=`/v4/${r.authority}.json`,r.params.push("secure"),i&&r.params.push(`language=${i}`),n&&r.params.push(`worldview=${n}`),this._makeAPIURL(r,this._customAccessToken||e)}normalizeSpriteURL(t,e,i,n){const r=un(t);return o(t)?(r.path=`/styles/v1${r.path}/sprite${e}${i}`,this._makeAPIURL(r,this._customAccessToken||n)):(r.path+=`${e}${i}`,hn(r))}normalizeTileURL(t,e,i){if(this._isSkuTokenExpired()&&this._createSkuToken(),t&&!o(t))return t;const r=un(t);r.path=r.path.replace(/(\.(png|jpg)\d*)(?=$)/,`${e||i&&"raster"!==r.authority&&512===i?"@2x":""}${Gi.supported?".webp":"$1"}`),"raster"===r.authority?r.path=`/${n.RASTER_URL_PREFIX}${r.path}`:"rasterarrays"===r.authority?r.path=`/${n.RASTERARRAYS_URL_PREFIX}${r.path}`:"3dtiles"===r.authority?r.path=`/${n.TILES3D_URL_PREFIX}${r.path}`:(r.path=r.path.replace(/^.+\/v4\//,"/"),r.path=`/${n.TILE_URL_VERSION}${r.path}`);const s=this._customAccessToken||function(t){for(const e of t){const t=e.match(/^access_token=(.*)$/);if(t)return t[1]}return null}(r.params)||n.ACCESS_TOKEN;return n.REQUIRE_ACCESS_TOKEN&&s&&this._skuToken&&r.params.push(`sku=${this._skuToken}`),this._makeAPIURL(r,s)}canonicalizeTileURL(t,e){const i=un(t);if(!i.path.match(/^(\/v4\/|\/(raster|rasterarrays)\/v1\/)/)||!i.path.match(/\.[\w]+$/))return t;let r="mapbox://";i.path.match(/^\/raster\/v1\//)?r+=`raster/${i.path.replace(`/${n.RASTER_URL_PREFIX}/`,"")}`:i.path.match(/^\/rasterarrays\/v1\//)?r+=`rasterarrays/${i.path.replace(`/${n.RASTERARRAYS_URL_PREFIX}/`,"")}`:r+=`tiles/${i.path.replace(`/${n.TILE_URL_VERSION}/`,"")}`;let o=i.params;return e&&(o=o.filter((t=>!t.match(/^access_token=/)))),o.length&&(r+=`?${o.join("&")}`),r}canonicalizeTileset(t,e){const i=!!e&&o(e),n=[];for(const e of t.tiles||[])r(e)?n.push(this.canonicalizeTileURL(e,i)):n.push(e);return n}_makeAPIURL(t,e){const i="See https://docs.mapbox.com/api/overview/#access-tokens-and-token-scopes",r=un(n.API_URL);if(t.protocol=r.protocol,t.authority=r.authority,"http"===t.protocol){const e=t.params.indexOf("secure");e>=0&&t.params.splice(e,1)}if("/"!==r.path&&(t.path=`${r.path}${t.path}`),!n.REQUIRE_ACCESS_TOKEN)return hn(t);if(e=e||n.ACCESS_TOKEN,!this._silenceAuthErrors){if(!e)throw new Error(`An API access token is required to use Mapbox GL. ${i}`);if("s"===e[0])throw new Error(`Use a public access token (pk.*) with Mapbox GL, not a secret access token (sk.*). ${i}`)}return t.params=t.params.filter((t=>-1===t.indexOf("access_token"))),t.params.push(`access_token=${e||""}`),hn(t)}},t.dh=function(t,e){e?Mn.add(t):Mn.delete(t)},t.di=Gi,t.dj=Tn,t.dk=En,t.dl=cn,t.dm=vn,t.dn=bn,t.dp=function(t){Mn.delete(t)},t.dq=Sn,t.dr=yn,t.ds=Qe,t.dt=e,t.du=function(t,e){Fi=t,Ni=e},t.dv=function(t,e,i=!1){if(Fa===za||Fa===Ra||Fa===Oa)throw new Error("setRTLTextPlugin cannot be called multiple times.");Na=ki.resolveURL(t),Fa=za,Ba=e,ja(),i||Za()},t.dw=Ga,t.dx=function(){ux().acquire(lx)},t.dy=function(){const t=dx;t&&(t.isPreloaded()&&1===t.numActive()?(t.release(lx),dx=null):console.warn("Could not clear WebWorkers since there are active Map instances that still reference it. The pre-warmed WebWorker pool can only be cleared when all map instances have been removed with map.remove()"))},t.dz=cx,t.e=ki,t.e0=cm,t.e1=h,t.e2=en,t.e3=function(t){let e=0;if(new Uint32Array(t,0,1)[0]!==Ax){const i=new Uint32Array(t,0,7),[,,n,r,o,s]=i;e=i.byteLength+r+o+s+o,(n!==t.byteLength||e>=t.byteLength)&&pi("Invalid b3dm header information.")}return Dx(t,e)},t.e4=function(t,e){const i=jx(t);for(const t of i){for(const e of t.meshes)Vx(e);t.lights&&(t.lightMeshIndex=t.meshes.length,t.meshes.push(Gx(t.lights,e)))}return i},t.e5=Kx,t.e6=rx,t.e7=qa,t.e8=function(t){ji(),Oi&&Oi.then((e=>{e.keys().then((i=>{for(let n=0;nt.arrayBuffer())).then((e=>Dx(e,0,t)))},t.m=class extends Uv{},t.n=Er,t.o=qn,t.p=Qg,t.q=Xs,t.r=Js,t.s=Qs,t.t=ca,t.u=al,t.v=ll,t.w=pi,t.x=pa,t.y=da,t.z=qo})),n(0,(function(t){function e(t){const e=t?t.url.toString():void 0;return e?performance.getEntriesByName(e):[]}function i(t){if("number"==typeof t||"boolean"==typeof t||"string"==typeof t||null==t)return JSON.stringify(t);if(Array.isArray(t)){let e="[";for(const n of t)e+=`${i(n)},`;return`${e}]`}let e="{";for(const n of Object.keys(t).sort())e+=`${n}:${i(t[n])},`;return`${e}}`}function n(e){let n="";for(const r of t.cE)n+=`/${i(e[r])}`;return n}class r{constructor(t){this.keyCache={},this._layers={},this._layerConfigs={},t&&this.replace(t)}replace(t,e){this._layerConfigs={},this._layers={},this.update(t,[],e)}update(e,i,r){this._options=r;for(const i of e)this._layerConfigs[i.id]=i,(this._layers[i.id]=t.cY(i,this.scope,null,this._options)).compileFilter(),this.keyCache[i.id]&&delete this.keyCache[i.id];for(const t of i)delete this.keyCache[t],delete this._layerConfigs[t],delete this._layers[t];this.familiesBySource={};const o=function(t,e){const i={};for(let r=0;rthis._layers[t.id])),i=e[0];if("none"===i.visibility)continue;const n=i.source||"";let r=this.familiesBySource[n];r||(r=this.familiesBySource[n]={});const o=i.sourceLayer||"_geojsonTileLayer";let s=r[o];s||(s=r[o]=[]),s.push(e)}}}const o=1*t.dJ;class s{constructor(e){const i={},n=[];for(const t in e){const r=e[t],s=i[t]={};for(const t in r.glyphs){const e=r.glyphs[+t];if(!e||0===e.bitmap.width||0===e.bitmap.height)continue;const i=e.metrics.localGlyph?o:1,a={x:0,y:0,w:e.bitmap.width+2*i,h:e.bitmap.height+2*i};n.push(a),s[t]=a}}const{w:r,h:s}=t.j(n),a=new t.dI({width:r||1,height:s||1});for(const n in e){const r=e[n];for(const e in r.glyphs){const s=r.glyphs[+e];if(!s||0===s.bitmap.width||0===s.bitmap.height)continue;const l=i[n][e],c=s.metrics.localGlyph?o:1;t.dI.copy(s.bitmap,a,{x:0,y:0},{x:l.x+c,y:l.y+c},s.bitmap)}}this.image=a,this.positions=i}}t.dH(s,"GlyphAtlas");class a{constructor(e){this.tileID=new t.aL(e.tileID.overscaledZ,e.tileID.wrap,e.tileID.canonical.z,e.tileID.canonical.x,e.tileID.canonical.y),this.tileZoom=e.tileZoom,this.uid=e.uid,this.zoom=e.zoom,this.lut=e.lut,this.canonical=e.tileID.canonical,this.pixelRatio=e.pixelRatio,this.tileSize=e.tileSize,this.source=e.source,this.scope=e.scope,this.overscaling=this.tileID.overscaleFactor(),this.showCollisionBoxes=e.showCollisionBoxes,this.collectResourceTiming=!!e.collectResourceTiming,this.promoteId=e.promoteId,this.isSymbolTile=e.isSymbolTile,this.tileTransform=t.dK(e.tileID.canonical,e.projection),this.projection=e.projection,this.brightness=e.brightness,this.extraShadowCaster=!!e.extraShadowCaster,this.tessellationStep=e.tessellationStep}parse(e,i,n,r,o){this.status="parsing",this.data=e,this.collisionBoxArray=new t.dL;const a=new t.dM(Object.keys(e.layers).sort()),c=new t.dN(this.tileID,this.promoteId);c.bucketLayerIDs=[];const d={},u=new t.dO(256,256),h={featureIndex:c,iconDependencies:{},patternDependencies:{},glyphDependencies:{},lineAtlas:u,availableImages:n,brightness:this.brightness},p=i.familiesBySource[this.source];for(const i in p){const r=e.layers[i];if(!r)continue;let o=!1,s=!1,u=!1;for(const t of p[i])"symbol"===t[0].type?o=!0:s=!0,t[0].is3D()&&"model"!==t[0].type&&(u=!0);if(this.extraShadowCaster&&!u)continue;if(!0===this.isSymbolTile&&!o)continue;if(!1===this.isSymbolTile&&!s)continue;1===r.version&&t.w(`Vector tile source "${this.source}" layer "${i}" does not use vector tile spec v2 and therefore may have some rendering errors.`);const f=a.encode(i),m=[];for(let t=0;t=e.maxzoom||"none"!==e.visibility&&(l(t,this.zoom,h.brightness,n),(d[e.id]=e.createBucket({index:c.bucketLayerIDs.length,layers:t,zoom:this.zoom,lut:this.lut,canonical:this.canonical,pixelRatio:this.pixelRatio,overscaling:this.overscaling,collisionBoxArray:this.collisionBoxArray,sourceLayerIndex:f,sourceID:this.source,projection:this.projection.spec,tessellationStep:this.tessellationStep})).populate(m,h,this.tileID.canonical,this.tileTransform),c.bucketLayerIDs.push(t.map((t=>t.id)))))}}let f,m,_,g;u.trim();const y={type:"maybePrepare",isSymbolTile:this.isSymbolTile,zoom:this.zoom},v=()=>{if(f)return this.status="done",o(f);if(this.extraShadowCaster)this.status="done",o(null,{buckets:t.dG(d).filter((t=>!t.isEmpty())),featureIndex:c,collisionBoxArray:null,glyphAtlasImage:null,lineAtlas:null,imageAtlas:null,brightness:h.brightness,glyphMap:null,iconMap:null,glyphPositions:null});else if(m&&_&&g){const e=new s(m),i=new t.dQ(_,g,this.lut);for(const r in d){const o=d[r];o instanceof t.dR?(l(o.layers,this.zoom,h.brightness,n),t.dS(o,m,e.positions,_,i.iconPositions,this.showCollisionBoxes,n,this.tileID.canonical,this.tileZoom,this.projection,this.brightness)):o.hasPattern&&(o instanceof t.dT||o instanceof t.dU||o instanceof t.b_)&&(l(o.layers,this.zoom,h.brightness,n),o.addFeatures(h,this.tileID.canonical,i.patternPositions,n,this.tileTransform,this.brightness))}this.status="done",o(null,{buckets:t.dG(d).filter((t=>!t.isEmpty())),featureIndex:c,collisionBoxArray:this.collisionBoxArray,glyphAtlasImage:e.image,lineAtlas:u,imageAtlas:i,brightness:h.brightness})}};if(!this.extraShadowCaster){const e=t.dP(h.glyphDependencies,(t=>Object.keys(t).map(Number)));Object.keys(e).length?r.send("getGlyphs",{uid:this.uid,stacks:e,scope:this.scope},((t,e)=>{f||(f=t,m=e,v())}),void 0,!1,y):m={};const i=Object.keys(h.iconDependencies);i.length?r.send("getImages",{icons:i,source:this.source,scope:this.scope,tileID:this.tileID,type:"icons"},((t,e)=>{f||(f=t,_=e,v())}),void 0,!1,y):_={};const n=Object.keys(h.patternDependencies);n.length?r.send("getImages",{icons:n,source:this.source,scope:this.scope,tileID:this.tileID,type:"patterns"},((t,e)=>{f||(f=t,g=e,v())}),void 0,!1,y):g={}}v()}}function l(e,i,n,r){const o=new t.X(i,{brightness:n});for(const t of e)t.recalculate(o,r)}class c extends t.E{constructor(e,i,n,r,o,s){super(),this.actor=e,this.layerIndex=i,this.availableImages=n,this.loadVectorData=o||t.ap,this.loading={},this.loaded={},this.deduped=new t.ao(e.scheduler),this.isSpriteLoaded=r,this.scheduler=e.scheduler,this.brightness=s}loadTile(i,n){const r=i.uid,o=i&&i.request,s=o&&o.collectResourceTiming,l=this.loading[r]=new a(i);l.abort=this.loadVectorData(i,((a,c)=>{const d=!this.loading[r];if(delete this.loading[r],d||a||!c)return l.status="done",d||(this.loaded[r]=l),n(a);const u=c.rawData,h={};c.expires&&(h.expires=c.expires),c.cacheControl&&(h.cacheControl=c.cacheControl),l.vectorTile=c.vectorTile||new t.dV(new t.dW(u));const p=()=>{l.parse(l.vectorTile,this.layerIndex,this.availableImages,this.actor,((i,r)=>{if(i||!r)return n(i);const a={};if(s){const t=e(o);t.length>0&&(a.resourceTiming=JSON.parse(JSON.stringify(t)))}n(null,t.W({rawTileData:u.slice(0)},r,h,a))}))};this.isSpriteLoaded?p():this.once("isSpriteLoaded",(()=>{this.scheduler?this.scheduler.add(p,{type:"parseTile",isSymbolTile:i.isSymbolTile,zoom:i.tileZoom}):p()})),this.loaded=this.loaded||{},this.loaded[r]=l}))}reloadTile(e,i){const n=this.loaded,r=e.uid;if(n&&n[r]){const o=n[r];o.showCollisionBoxes=e.showCollisionBoxes,o.projection=e.projection,o.brightness=e.brightness,o.tileTransform=t.dK(e.tileID.canonical,e.projection),o.extraShadowCaster=e.extraShadowCaster,o.lut=e.lut;const s=(t,e)=>{const n=o.reloadCallback;n&&(delete o.reloadCallback,o.parse(o.vectorTile,this.layerIndex,this.availableImages,this.actor,n)),i(t,e)};"parsing"===o.status?o.reloadCallback=s:"done"===o.status&&(o.vectorTile?o.parse(o.vectorTile,this.layerIndex,this.availableImages,this.actor,s):s())}else i(null,void 0)}abortTile(t,e){const i=t.uid,n=this.loading[i];n&&(n.abort&&n.abort(),delete this.loading[i]),e()}removeTile(t,e){const i=this.loaded,n=t.uid;i&&i[n]&&delete i[n],e()}}class d{loadTile(e,i){const{uid:n,encoding:r,rawImageData:o,padding:s}=e,a=ImageBitmap&&o instanceof ImageBitmap?this.getImageData(o,s):o;i(null,new t.dX(n,a,r,s{n(null,t)}),(t=>{n(t)}))}}const h=t.dZ.prototype.toGeoJSON;let p=class{constructor(e){this._feature=e,this.extent=t.a3,this.type=e.type,this.properties=e.tags,"id"in e&&!isNaN(e.id)&&(this.id=parseInt(e.id,10))}loadGeometry(){if(1===this._feature.type){const e=[];for(const i of this._feature.geometry)e.push([new t.P(i[0],i[1])]);return e}{const e=[];for(const i of this._feature.geometry){const n=[];for(const e of i)n.push(new t.P(e[0],e[1]));e.push(n)}return e}}toGeoJSON(t,e,i){return h.call(this,t,e,i)}},f=class{constructor(e){this.layers={_geojsonTileLayer:this},this.name="_geojsonTileLayer",this.extent=t.a3,this.length=e.length,this._features=e}feature(t){return new p(this._features[t])}};const m=64/4096;class _{constructor(){this.features=new Map}clear(){this.features.clear()}load(t=[],e){for(const i of t){const t=i.id;if(null==t)continue;let n=this.features.get(t);n&&this.updateCache(n,e),i.geometry?(n=y(i),this.updateCache(n,e),this.features.set(t,n)):this.features.delete(t),this.updateCache(n,e)}}updateCache(t,e){for(const{canonical:i,uid:n}of Object.values(e)){const{z:r,x:o,y:s}=i;g(t,Math.pow(2,r),o,s)&&delete e[n]}}getTile(t,e,i){const n=Math.pow(2,t),r=[];for(const t of this.features.values())g(t,n,e,i)&&r.push(w(t,n,e,i));return{features:r}}getFeatures(){return[...this.features.values()]}}function g({minX:t,minY:e,maxX:i,maxY:n},r,o,s){return t(o-m)/r&&n>(s-m)/r}function y(t){const{id:e,geometry:i,properties:n}=t;if(!i)return;if("GeometryCollection"===i.type)throw new Error("GeometryCollection not supported in dynamic mode.");const{type:r,coordinates:o}=i,s={id:e,type:1,geometry:[],tags:n,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0},a=s.geometry;if("Point"===r)v(o,a,s);else if("MultiPoint"===r)for(const t of o)v(t,a,s);else if("LineString"===r)s.type=2,x(o,a,s);else if("MultiLineString"===r)s.type=2,b(o,a,s);else if("Polygon"===r)s.type=3,b(o,a,s,!0);else{if("MultiPolygon"!==r)throw new Error("Input data is not a valid GeoJSON object.");s.type=3;for(const t of o)b(t,a,s,!0)}return s}function v([e,i],n,r){const o=t.aj(e);let s=t.ak(i);s=s1?1:s,n.push(o,s),r.minX=Math.min(r.minX,o),r.minY=Math.min(r.minY,s),r.maxX=Math.max(r.maxX,o),r.maxY=Math.max(r.maxY,s)}function x(t,e,i,n=!1,r=!1){const o=[];for(const e of t)v(e,o,i);e.push(o),n&&function(t,e){let i=0;for(let e=0,n=t.length,r=n-2;e0===e)for(let e=0,i=t.length;e>31}function F(t,e){for(var i=t.loadGeometry(),n=t.type,r=0,o=0,s=i.length,a=0;at},V=Math.fround||(G=new Float32Array(1),t=>(G[0]=+t,G[0]));var G;const Z=3,q=5,H=6;class W{constructor(t){this.options=Object.assign(Object.create(j),t),this.trees=new Array(this.options.maxZoom+1),this.stride=this.options.reduce?7:6,this.clusterProps=[]}load(t){const{log:e,minZoom:i,maxZoom:n}=this.options;e&&console.time("total time");const r=`prepare ${t.length} points`;e&&console.time(r),this.points=t;const o=[];for(let e=0;e=i;t--){const i=+Date.now();s=this.trees[t]=this._createTree(this._cluster(s,t)),e&&console.log("z%d: %d clusters in %dms",t,s.numItems,+Date.now()-i)}return e&&console.timeEnd("total time"),this}getClusters(t,e){let i=((t[0]+180)%360+360)%360-180;const n=Math.max(-90,Math.min(90,t[1]));let r=180===t[2]?180:((t[2]+180)%360+360)%360-180;const o=Math.max(-90,Math.min(90,t[3]));if(t[2]-t[0]>=360)i=-180,r=180;else if(i>r){const t=this.getClusters([i,n,180,o],e),s=this.getClusters([-180,n,r,o],e);return t.concat(s)}const s=this.trees[this._limitZoom(e)],a=s.range(K(i),J(o),K(r),J(n)),l=s.data,c=[];for(const t of a){const e=this.stride*t;c.push(l[e+q]>1?Y(l,e,this.clusterProps):this.points[l[e+Z]])}return c}getChildren(t){const e=this._getOriginId(t),i=this._getOriginZoom(t),n="No cluster with the specified id.",r=this.trees[i];if(!r)throw new Error(n);const o=r.data;if(e*this.stride>=o.length)throw new Error(n);const s=this.options.radius/(this.options.extent*Math.pow(2,i-1)),a=r.within(o[e*this.stride],o[e*this.stride+1],s),l=[];for(const e of a){const i=e*this.stride;o[i+4]===t&&l.push(o[i+q]>1?Y(o,i,this.clusterProps):this.points[o[i+Z]])}if(0===l.length)throw new Error(n);return l}getLeaves(t,e,i){const n=[];return this._appendLeaves(n,t,e=e||10,i=i||0,0),n}getTile(t,e,i){const n=this.trees[this._limitZoom(t)],r=Math.pow(2,t),{extent:o,radius:s}=this.options,a=s/o,l=(i-a)/r,c=(i+1+a)/r,d={features:[]};return this._addTileFeatures(n.range((e-a)/r,l,(e+1+a)/r,c),n.data,e,i,r,d),0===e&&this._addTileFeatures(n.range(1-a/r,l,1,c),n.data,r,i,r,d),e===r-1&&this._addTileFeatures(n.range(0,l,a/r,c),n.data,-1,i,r,d),d.features.length?d:null}getClusterExpansionZoom(t){let e=this._getOriginZoom(t)-1;for(;e1;let l,c,d;if(a)l=X(e,t,this.clusterProps),c=e[t],d=e[t+1];else{const i=this.points[e[t+Z]];l=i.properties;const[n,r]=i.geometry.coordinates;c=K(n),d=J(r)}const u={type:1,geometry:[[Math.round(this.options.extent*(c*r-i)),Math.round(this.options.extent*(d*r-n))]],tags:l};let h;h=a||this.options.generateId?e[t+Z]:this.points[e[t+Z]].id,void 0!==h&&(u.id=h),o.features.push(u)}}_limitZoom(t){return Math.max(this.options.minZoom,Math.min(Math.floor(+t),this.options.maxZoom+1))}_cluster(t,e){const{radius:i,extent:n,reduce:r,minPoints:o}=this.options,s=i/(n*Math.pow(2,e)),a=t.data,l=[],c=this.stride;for(let i=0;ie&&(p+=a[i+q])}if(p>h&&p>=o){let t,o=n*h,s=d*h,f=-1;const m=(i/c1)for(const t of u){const i=t*c;if(!(a[i+2]>5}_getOriginZoom(t){return(t-this.points.length)%32}_map(t,e,i){if(t[e+q]>1){const n=this.clusterProps[t[e+H]];return i?Object.assign({},n):n}const n=this.points[t[e+Z]].properties,r=this.options.map(n);return i&&r===n?Object.assign({},r):r}}function Y(t,e,i){return{type:"Feature",id:t[e+Z],properties:X(t,e,i),geometry:{type:"Point",coordinates:[(n=t[e],360*(n-.5)),Q(t[e+1])]}};var n}function X(t,e,i){const n=t[e+q],r=n>=1e4?`${Math.round(n/1e3)}k`:n>=1e3?Math.round(n/100)/10+"k":n,o=t[e+H],s=-1===o?{}:Object.assign({},i[o]);return Object.assign(s,{cluster:!0,cluster_id:t[e+Z],point_count:n,point_count_abbreviated:r})}function K(t){return t/360+.5}function J(t){const e=Math.sin(t*Math.PI/180),i=.5-.25*Math.log((1+e)/(1-e))/Math.PI;return i1?1:i}function Q(t){const e=(180-360*t)*Math.PI/180;return 360*Math.atan(Math.exp(e))/Math.PI-90}function tt(t,e,i,n){let r=n;const o=e+(i-e>>1);let s,a=i-e;const l=t[e],c=t[e+1],d=t[i],u=t[i+1];for(let n=e+3;n >1;t[r]>1;t[r]0?1/(1.001-t):1+t}function Pi(t){return t>0?1-1/(1.001-t):-t}function $i(){return null==vi&&(vi=self.OffscreenCanvas&&new OffscreenCanvas(1,1).getContext("2d")&&"function"==typeof self.createImageBitmap),vi}const ki={now:()=>void 0!==wi?wi:performance.now(),setNow(t){wi=t},restoreNow(){wi=void 0},frame(t){const e=requestAnimationFrame(t);return{cancel:()=>cancelAnimationFrame(e)}},getImageData(t,e=0){const{width:i,height:n}=t;Ti||(Ti=document.createElement("canvas"));const r=Ti.getContext("2d",{willReadFrequently:!0});if(!r)throw new Error("failed to create canvas 2d context");return(i>Ti.width||n>Ti.height)&&(Ti.width=i,Ti.height=n),r.clearRect(-e,-e,i+2*e,n+2*e),r.drawImage(t,0,0,i,n),r.getImageData(-e,-e,i+2*e,n+2*e)},resolveURL:t=>(xi||(xi=document.createElement("a")),xi.href=t,xi.href),get devicePixelRatio(){return window.devicePixelRatio},get prefersReducedMotion(){return!!window.matchMedia&&(null==bi&&(bi=window.matchMedia("(prefers-reduced-motion: reduce)")),bi.matches)},hasCanvasFingerprintNoise(){if(void 0!==Si)return Si;if(!$i())return Si=!1,!1;const t=new OffscreenCanvas(85,1),e=t.getContext("2d",{willReadFrequently:!0});let i=0;for(let n=0;n0?`?${o}`:""}`}const Ri="mapbox-tiles";let Oi,Bi,Fi=500,Ni=50;function Ui(){try{return caches}catch(t){}}function ji(){const t=Ui();t&&!Oi&&(Oi=t.open(Ri))}let Vi=1/0;const Gi={supported:!1,testSupport:function(t){!Hi&&qi&&(Wi?Xi(t):Zi=t)}};let Zi,qi,Hi=!1,Wi=!1;const Yi="undefined"!=typeof self?self:{};function Xi(t){const e=t.createTexture();t.bindTexture(t.TEXTURE_2D,e);try{if(t.texImage2D(t.TEXTURE_2D,0,t.RGBA,t.RGBA,t.UNSIGNED_BYTE,qi),t.isContextLost())return;Gi.supported=!0}catch(t){}t.deleteTexture(e),Hi=!0}Yi.document&&(qi=Yi.document.createElement("img"),qi.onload=function(){Zi&&Xi(Zi),Zi=null,Wi=!0},qi.onerror=function(){Hi=!0,Zi=null},qi.src="data:image/webp;base64,UklGRh4AAABXRUJQVlA4TBEAAAAvAQAAAAfQ//73v/+BiOh/AAA=");const Ki={Unknown:"Unknown",Style:"Style",Source:"Source",Tile:"Tile",Glyphs:"Glyphs",SpriteImage:"SpriteImage",SpriteJSON:"SpriteJSON",Image:"Image",Model:"Model"};"function"==typeof Object.freeze&&Object.freeze(Ki);class Ji extends Error{constructor(t,e,i){401===e&&r(i)&&(t+=": you may have provided an invalid Mapbox access token. See https://docs.mapbox.com/api/overview/#access-tokens-and-token-scopes"),super(t),this.status=e,this.url=i}toString(){return`${this.name}: ${this.message} (${this.status}): ${this.url}`}}const Qi=gi()?()=>self.worker&&self.worker.referrer:()=>("blob:"===location.protocol?parent:self).location.href,tn=function(t,e){if(!(/^file:/.test(i=t.url)||/^file:/.test(Qi())&&!/^\w+:/.test(i))){if(self.fetch&&self.Request&&self.AbortController&&Request.prototype.hasOwnProperty("signal"))return function(t,e){const i=new AbortController,n=new Request(t.url,{method:t.method||"GET",body:t.body,credentials:t.credentials,headers:t.headers,referrer:Qi(),referrerPolicy:t.referrerPolicy,signal:i.signal});let o=!1,s=!1;const a=(l=n.url).indexOf("sku=")>0&&r(l);var l;"json"===t.type&&n.headers.set("Accept","application/json");const c=(i,r,o)=>{if(s)return;if(i&&"SecurityError"!==i.message&&pi(i.toString()),r&&o)return d(r);const l=Date.now();fetch(n).then((i=>{if(i.ok){const t=a?i.clone():null;return d(i,t,l)}return e(new Ji(i.statusText,i.status,t.url))})).catch((i=>{"AbortError"!==i.name&&e(new Error(`${i.message} ${t.url}`))}))},d=(i,r,a)=>{("arrayBuffer"===t.type?i.arrayBuffer():"json"===t.type?i.json():i.text()).then((t=>{s||(r&&a&&function(t,e,i){if(ji(),!Oi)return;const n=yi(e.headers.get("Cache-Control")||"");if(n["no-store"])return;const r={status:e.status,statusText:e.statusText,headers:new Headers};e.headers.forEach(((t,e)=>r.headers.set(e,t))),n["max-age"]&&r.headers.set("Expires",new Date(i+1e3*n["max-age"]).toUTCString());const o=r.headers.get("Expires");if(!o)return;if(new Date(o).getTime()-i{const i=new Response(200!==(n=e.status)&&404!==n&&[101,103,204,205,304].includes(n)?null:t,r);var n;ji(),Oi&&Oi.then((t=>t.put(s,i))).catch((t=>pi(t.message)))}))}(n,r,a),o=!0,e(null,t,i.headers.get("Cache-Control"),i.headers.get("Expires")))})).catch((t=>{s||e(new Error(t.message))}))};return a?function(t,e){if(ji(),!Oi)return e(null);Oi.then((i=>{let n=zi(t.url,{persistentParams:["language","worldview"]});const r=t.headers.get("Range");r&&(n=Di(n,{range:r})),i.match(n).then((t=>{const r=function(t){if(!t)return!1;const e=new Date(t.headers.get("Expires")||0),i=yi(t.headers.get("Cache-Control")||"");return e>Date.now()&&!i["no-cache"]}(t);i.delete(n),r&&i.put(n,t.clone()),e(null,t,r)})).catch(e)})).catch(e)}(n,c):c(null,null),{cancel:()=>{s=!0,o||i.abort()}}}(t,e);if(gi()&&self.worker&&self.worker.actor)return self.worker.actor.send("getResource",t,e,void 0,!0)}var i;return function(t,e){const i=new XMLHttpRequest;i.open(t.method||"GET",t.url,!0),"arrayBuffer"===t.type&&(i.responseType="arraybuffer");for(const e in t.headers)i.setRequestHeader(e,t.headers[e]);return"json"===t.type&&(i.responseType="text",i.setRequestHeader("Accept","application/json")),i.withCredentials="include"===t.credentials,i.onerror=()=>{e(new Error(i.statusText))},i.onload=()=>{if((i.status>=200&&i.statusi.abort()}}(t,e)},en=function(t,e){return tn(ei(t,{type:"arrayBuffer"}),e)};function nn(t){const e=document.createElement("a");return e.href=t,e.protocol===location.protocol&&e.host===location.host}const rn="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAC0lEQVQYV2NgAAIAAAUAAarVyFEAAAAASUVORK5CYII=";let on,sn;on=[],sn=0;const an=function(t,e){if(Gi.supported&&(t.headers||(t.headers={}),t.headers.accept="image/webp,*/*"),sn>=n.MAX_PARALLEL_IMAGE_REQUESTS){const i={requestParameters:t,callback:e,cancelled:!1,cancel(){this.cancelled=!0}};return on.push(i),i}sn++;let i=!1;const r=()=>{if(!i)for(i=!0,sn--;on.length&&sn{r(),t?e(t):i&&(self.createImageBitmap?function(t,e){const i=new Blob([new Uint8Array(t)],{type:"image/png"});createImageBitmap(i).then((t=>{e(null,t)})).catch((t=>{e(new Error(`Could not load image because of ${t.message}. Please make sure to use a supported image type such as PNG or JPEG. Note that SVGs are not supported.`))}))}(i,((t,i)=>e(t,i,n,o))):function(t,e){const i=new Image;i.onload=()=>{e(null,i),URL.revokeObjectURL(i.src),i.onload=null,requestAnimationFrame((()=>{i.src=rn}))},i.onerror=()=>e(new Error("Could not load image. Please make sure to use a supported image type such as PNG or JPEG. Note that SVGs are not supported."));const n=new Blob([new Uint8Array(t)],{type:"image/png"});i.src=t.byteLength?URL.createObjectURL(n):rn}(i,((t,i)=>e(t,i,n,o))))}));return{cancel:()=>{o.cancel(),r()}}},ln="01",cn="NO_ACCESS_TOKEN",dn=/^(\w+):\/\/([^/?]*)(\/[^?]+)?\??(.+)?/;function un(t){const e=t.match(dn);if(!e)throw new Error("Unable to parse URL object");return{protocol:e[1],authority:e[2],path:e[3]||"/",params:e[4]?e[4].split("&"):[]}}function hn(t){const e=t.params.length?`?${t.params.join("&")}`:"";return`${t.protocol}://${t.authority}${t.path}${e}`}const pn="mapbox.eventData";function fn(t){if(!t)return null;const e=t.split(".");if(!e||3!==e.length)return null;try{return JSON.parse(decodeURIComponent(atob(e[1]).split("").map((t=>"%"+("00"+t.charCodeAt(0).toString(16)).slice(-2))).join("")))}catch(t){return null}}class mn{constructor(t){this.type=t,this.anonId=null,this.eventData={},this.queue=[],this.pendingRequest=null}getStorageKey(t){const e=fn(n.ACCESS_TOKEN);let i="";return i=e&&e.u?btoa(encodeURIComponent(e.u).replace(/%([0-9A-F]{2})/g,((t,e)=>String.fromCharCode(Number("0x"+e))))):n.ACCESS_TOKEN||"",t?`${pn}.${t}:${i}`:`${pn}:${i}`}fetchEventData(){const t=Mi("localStorage"),e=this.getStorageKey(),i=this.getStorageKey("uuid");if(t)try{const t=localStorage.getItem(e);t&&(this.eventData=JSON.parse(t));const n=localStorage.getItem(i);n&&(this.anonId=n)}catch(t){pi("Unable to read from LocalStorage")}}saveEventData(){const t=Mi("localStorage"),e=this.getStorageKey(),i=this.getStorageKey("uuid"),n=this.anonId;if(t&&n)try{localStorage.setItem(i,n),Object.keys(this.eventData).length>=1&&localStorage.setItem(e,JSON.stringify(this.eventData))}catch(t){pi("Unable to write to LocalStorage")}}processRequests(t){}postEvent(t,e,i,r){if(!n.EVENTS_URL)return;const o=un(n.EVENTS_URL);o.params.push(`access_token=${r||n.ACCESS_TOKEN||""}`);const s={event:this.type,created:new Date(t).toISOString()},a=e?ei(s,e):s,l={url:hn(o),headers:{"Content-Type":"text/plain"},body:JSON.stringify([a])};this.pendingRequest=function(t,e){return tn(ei(t,{method:"POST"}),e)}(l,(t=>{this.pendingRequest=null,i(t),this.saveEventData(),this.processRequests(r)}))}queueRequest(t,e){this.queue.push(t),this.processRequests(e)}}const _n=new class extends mn{constructor(t){super("appUserTurnstile"),this._customAccessToken=t}postTurnstileEvent(t,e){n.EVENTS_URL&&n.ACCESS_TOKEN&&Array.isArray(t)&&t.some((t=>o(t)||r(t)))&&this.queueRequest(Date.now(),e)}processRequests(t){if(this.pendingRequest||0===this.queue.length)return;this.anonId&&this.eventData.lastSuccess&&this.eventData.tokenU||this.fetchEventData();const i=fn(n.ACCESS_TOKEN),r=i?i.u:n.ACCESS_TOKEN;let o=r!==this.eventData.tokenU;si(this.anonId)||(this.anonId=ri(),o=!0);const s=this.queue.shift();if(this.eventData.lastSuccess){const t=new Date(this.eventData.lastSuccess),e=new Date(s),i=(s-this.eventData.lastSuccess)/864e5;o=o||i>=1||i{t||(this.eventData.lastSuccess=s,this.eventData.tokenU=r)}),t):this.processRequests()}},gn=_n.postTurnstileEvent.bind(_n),yn=new class extends mn{constructor(){super("map.load"),this.success={},this.skuToken=""}postMapLoadEvent(t,e,i,r){this.skuToken=e,this.errorCb=r,n.EVENTS_URL&&(i||n.ACCESS_TOKEN?this.queueRequest({id:t,timestamp:Date.now()},i):this.errorCb(new Error(cn)))}processRequests(t){if(this.pendingRequest||0===this.queue.length)return;const{id:i,timestamp:n}=this.queue.shift();i&&this.success[i]||(this.anonId||this.fetchEventData(),si(this.anonId)||(this.anonId=ri()),this.postEvent(n,{sdkIdentifier:"mapbox-gl-js",sdkVersion:e,skuId:ln,skuToken:this.skuToken,userId:this.anonId},(t=>{t?this.errorCb(t):i&&(this.success[i]=!0)}),t))}remove(){this.errorCb=null}},vn=yn.postMapLoadEvent.bind(yn),xn=new class extends mn{constructor(){super("style.load"),this.eventIdPerMapInstanceMap=new Map,this.mapInstanceIdMap=new WeakMap}getMapInstanceId(t){let e=this.mapInstanceIdMap.get(t);return e||(e=ri(),this.mapInstanceIdMap.set(t,e)),e}getEventId(t){const e=this.eventIdPerMapInstanceMap.get(t)||0;return this.eventIdPerMapInstanceMap.set(t,e+1),e}postStyleLoadEvent(t,e){const{map:i,style:r,importedStyles:o}=e;if(!n.EVENTS_URL||!t&&!n.ACCESS_TOKEN)return;const s=this.getMapInstanceId(i),a={mapInstanceId:s,eventId:this.getEventId(s),style:r};o.length&&(a.importedStyles=o),this.queueRequest({timestamp:Date.now(),payload:a},t)}processRequests(t){if(this.pendingRequest||0===this.queue.length)return;const{timestamp:e,payload:i}=this.queue.shift();this.postEvent(e,i,(()=>{}),t)}},bn=xn.postStyleLoadEvent.bind(xn),wn=new class extends mn{constructor(){super("gljs.performance")}postPerformanceEvent(t,e){n.EVENTS_URL&&(t||n.ACCESS_TOKEN)&&this.queueRequest({timestamp:Date.now(),performanceData:e},t)}processRequests(t){if(this.pendingRequest||0===this.queue.length)return;const{timestamp:i,performanceData:n}=this.queue.shift(),r=function(t){const i=performance.getEntriesByType("resource"),n=performance.getEntriesByType("mark"),r=function(t){const e={};if(t)for(const i in t)if("other"!==i)for(const n of t[i]){const t=`${i}ResolveRangeMin`,r=`${i}ResolveRangeMax`,o=`${i}RequestCount`,s=`${i}RequestCachedCount`;e[t]=Math.min(e[t]||1/0,n.startTime),e[r]=Math.max(e[r]||-1/0,n.responseEnd);const a=t=>{void 0===e[t]&&(e[t]=0),++e[t]};void 0!==n.transferSize&&0===n.transferSize&&a(s),a(o)}return e}(function(t,e){const i={};if(t)for(const n of t){const t=e(n);void 0===i[t]&&(i[t]=[]),i[t].push(n)}return i}(i,u)),o=window.devicePixelRatio,s=navigator.connection||navigator.mozConnection||navigator.webkitConnection,a=s?s.effectiveType:void 0,d={counters:[],metadata:[],attributes:[]},h=(t,e,i)=>{null!=i&&t.push({name:e,value:i.toString()})};for(const t in r)h(d.counters,t,r[t]);if(t.interactionRange[0]!==1/0&&t.interactionRange[1]!==-1/0&&(h(d.counters,"interactionRangeMin",t.interactionRange[0]),h(d.counters,"interactionRangeMax",t.interactionRange[1])),n)for(const t of Object.keys(c)){const e=c[t],i=n.find((t=>t.name===e));i&&h(d.counters,e,i.startTime)}return h(d.counters,"visibilityHidden",t.visibilityHidden),h(d.attributes,"style",function(t){if(t)for(const e of t){const t=e.name.split("?")[0];if(l(t)){const e=t.split("/").slice(-2);if(2===e.length)return`mapbox://styles/${e[0]}/${e[1]}`}}}(i)),h(d.attributes,"terrainEnabled",t.terrainEnabled?"true":"false"),h(d.attributes,"fogEnabled",t.fogEnabled?"true":"false"),h(d.attributes,"projection",t.projection),h(d.attributes,"zoom",t.zoom),h(d.metadata,"devicePixelRatio",o),h(d.metadata,"connectionEffectiveType",a),h(d.metadata,"navigatorUserAgent",navigator.userAgent),h(d.metadata,"screenWidth",window.screen.width),h(d.metadata,"screenHeight",window.screen.height),h(d.metadata,"windowWidth",window.innerWidth),h(d.metadata,"windowHeight",window.innerHeight),h(d.metadata,"mapWidth",t.width/o),h(d.metadata,"mapHeight",t.height/o),h(d.metadata,"webglRenderer",t.renderer),h(d.metadata,"webglVendor",t.vendor),h(d.metadata,"sdkVersion",e),h(d.metadata,"sdkIdentifier","mapbox-gl-js"),d}(n);for(const t of r.metadata);for(const t of r.counters);for(const t of r.attributes);this.postEvent(i,r,(()=>{}),t)}},Tn=wn.postPerformanceEvent.bind(wn),Sn=new class extends mn{constructor(){super("map.auth"),this.success={},this.skuToken=""}getSession(t,e,i,r){if(!n.API_URL||!n.SESSION_PATH)return;const o=un(n.API_URL+n.SESSION_PATH);o.params.push(`sku=${e||""}`),o.params.push(`access_token=${r||n.ACCESS_TOKEN||""}`);const s={url:hn(o),headers:{"Content-Type":"text/plain"}};this.pendingRequest=function(t,e){return tn(ei(t,{method:"GET"}),e)}(s,(t=>{this.pendingRequest=null,i(t),this.saveEventData(),this.processRequests(r)}))}getSessionAPI(t,e,i,r){this.skuToken=e,this.errorCb=r,n.SESSION_PATH&&n.API_URL&&(i||n.ACCESS_TOKEN?this.queueRequest({id:t,timestamp:Date.now()},i):this.errorCb(new Error(cn)))}processRequests(t){if(this.pendingRequest||0===this.queue.length)return;const{id:e,timestamp:i}=this.queue.shift();e&&this.success[e]||this.getSession(i,this.skuToken,(t=>{t?this.errorCb(t):e&&(this.success[e]=!0)}),t)}remove(){this.errorCb=null}},En=Sn.getSessionAPI.bind(Sn),Mn=new Set;var Cn={exports:{}},An=function(t,e){var i,n,r,o,s,a,l,c;for(n=t.length-(i=3&t.length),r=e,s=3432918353,a=461845907,c=0;c>>16)*s&65535)>>17))*a+(((l>>>16)*a&65535)>>19))+((5*(r>>>16)&65535)>>16)&65535)>>16)*s&65535)>>17))*a+(((l>>>16)*a&65535)>>16))+((2246822507*(r>>>16)&65535)>>13))+((3266489909*(r>>>16)&65535)>>16)>>>0},In=function(t,e){for(var i,n=t.length,r=e^n,o=0;n>=4;)i=1540483477*(65535&(i=255&t.charCodeAt(o)|(255&t.charCodeAt(++o))>>16)&65535)>>16)&65535)>>24))+((1540483477*(i>>>16)&65535)>>16)&65535)>>13))+((1540483477*(r>>>16)&65535)>>15)>>>0};Cn.exports=An,Cn.exports.murmur3=An,Cn.exports.murmur2=In;var Ln=h(Cn.exports);class Pn{constructor(t,...e){ei(this,e[0]||{}),this.type=t}}class $n extends Pn{constructor(t,e={}){super("error",ei({error:t},e))}}function kn(t,e,i){i[t]&&-1!==i[t].indexOf(e)||(i[t]=i[t]||[],i[t].push(e))}function Dn(t,e,i){if(i&&i[t]){const n=i[t].indexOf(e);-1!==n&&i[t].splice(n,1)}}class zn{on(t,e){return this._listeners=this._listeners||{},kn(t,e,this._listeners),this}off(t,e){return Dn(t,e,this._listeners),Dn(t,e,this._oneTimeListeners),this}once(t,e){return e?(this._oneTimeListeners=this._oneTimeListeners||{},kn(t,e,this._oneTimeListeners),this):new Promise((e=>this.once(t,e)))}fire(t,e){const i="string"==typeof t?new Pn(t,e):t,n=i.type;if(this.listens(n)){i.target=this;const t=this._listeners&&this._listeners[n]?this._listeners[n].slice():[];for(const e of t)e.call(this,i);const e=this._oneTimeListeners&&this._oneTimeListeners[n]?this._oneTimeListeners[n].slice():[];for(const t of e)Dn(n,t,this._oneTimeListeners),t.call(this,i);const r=this._eventedParent;r&&(ei(i,"function"==typeof this._eventedParentData?this._eventedParentData():this._eventedParentData),r.fire(i))}else i instanceof $n&&console.error(i.error);return this}listens(t){return!!(this._listeners&&this._listeners[t]&&this._listeners[t].length>0||this._oneTimeListeners&&this._oneTimeListeners[t]&&this._oneTimeListeners[t].length>0||this._eventedParent&&this._eventedParent.listens(t))}setEventedParent(t,e){return this._eventedParent=t,this._eventedParentData=e,this}}t.F=void 0;var Rn={transparent:[0,0,0,0],aliceblue:[240,248,255,1],antiquewhite:[250,235,215,1],aqua:[0,255,255,1],aquamarine:[127,255,212,1],azure:[240,255,255,1],beige:[245,245,220,1],bisque:[255,228,196,1],black:[0,0,0,1],blanchedalmond:[255,235,205,1],blue:[0,0,255,1],blueviolet:[138,43,226,1],brown:[165,42,42,1],burlywood:[222,184,135,1],cadetblue:[95,158,160,1],chartreuse:[127,255,0,1],chocolate:[210,105,30,1],coral:[255,127,80,1],cornflowerblue:[100,149,237,1],cornsilk:[255,248,220,1],crimson:[220,20,60,1],cyan:[0,255,255,1],darkblue:[0,0,139,1],darkcyan:[0,139,139,1],darkgoldenrod:[184,134,11,1],darkgray:[169,169,169,1],darkgreen:[0,100,0,1],darkgrey:[169,169,169,1],darkkhaki:[189,183,107,1],darkmagenta:[139,0,139,1],darkolivegreen:[85,107,47,1],darkorange:[255,140,0,1],darkorchid:[153,50,204,1],darkred:[139,0,0,1],darksalmon:[233,150,122,1],darkseagreen:[143,188,143,1],darkslateblue:[72,61,139,1],darkslategray:[47,79,79,1],darkslategrey:[47,79,79,1],darkturquoise:[0,206,209,1],darkviolet:[148,0,211,1],deeppink:[255,20,147,1],deepskyblue:[0,191,255,1],dimgray:[105,105,105,1],dimgrey:[105,105,105,1],dodgerblue:[30,144,255,1],firebrick:[178,34,34,1],floralwhite:[255,250,240,1],forestgreen:[34,139,34,1],fuchsia:[255,0,255,1],gainsboro:[220,220,220,1],ghostwhite:[248,248,255,1],gold:[255,215,0,1],goldenrod:[218,165,32,1],gray:[128,128,128,1],green:[0,128,0,1],greenyellow:[173,255,47,1],grey:[128,128,128,1],honeydew:[240,255,240,1],hotpink:[255,105,180,1],indianred:[205,92,92,1],indigo:[75,0,130,1],ivory:[255,255,240,1],khaki:[240,230,140,1],lavender:[230,230,250,1],lavenderblush:[255,240,245,1],lawngreen:[124,252,0,1],lemonchiffon:[255,250,205,1],lightblue:[173,216,230,1],lightcoral:[240,128,128,1],lightcyan:[224,255,255,1],lightgoldenrodyellow:[250,250,210,1],lightgray:[211,211,211,1],lightgreen:[144,238,144,1],lightgrey:[211,211,211,1],lightpink:[255,182,193,1],lightsalmon:[255,160,122,1],lightseagreen:[32,178,170,1],lightskyblue:[135,206,250,1],lightslategray:[119,136,153,1],lightslategrey:[119,136,153,1],lightsteelblue:[176,196,222,1],lightyellow:[255,255,224,1],lime:[0,255,0,1],limegreen:[50,205,50,1],linen:[250,240,230,1],magenta:[255,0,255,1],maroon:[128,0,0,1],mediumaquamarine:[102,205,170,1],mediumblue:[0,0,205,1],mediumorchid:[186,85,211,1],mediumpurple:[147,112,219,1],mediumseagreen:[60,179,113,1],mediumslateblue:[123,104,238,1],mediumspringgreen:[0,250,154,1],mediumturquoise:[72,209,204,1],mediumvioletred:[199,21,133,1],midnightblue:[25,25,112,1],mintcream:[245,255,250,1],mistyrose:[255,228,225,1],moccasin:[255,228,181,1],navajowhite:[255,222,173,1],navy:[0,0,128,1],oldlace:[253,245,230,1],olive:[128,128,0,1],olivedrab:[107,142,35,1],orange:[255,165,0,1],orangered:[255,69,0,1],orchid:[218,112,214,1],palegoldenrod:[238,232,170,1],palegreen:[152,251,152,1],paleturquoise:[175,238,238,1],palevioletred:[219,112,147,1],papayawhip:[255,239,213,1],peachpuff:[255,218,185,1],peru:[205,133,63,1],pink:[255,192,203,1],plum:[221,160,221,1],powderblue:[176,224,230,1],purple:[128,0,128,1],rebeccapurple:[102,51,153,1],red:[255,0,0,1],rosybrown:[188,143,143,1],royalblue:[65,105,225,1],saddlebrown:[139,69,19,1],salmon:[250,128,114,1],sandybrown:[244,164,96,1],seagreen:[46,139,87,1],seashell:[255,245,238,1],sienna:[160,82,45,1],silver:[192,192,192,1],skyblue:[135,206,235,1],slateblue:[106,90,205,1],slategray:[112,128,144,1],slategrey:[112,128,144,1],snow:[255,250,250,1],springgreen:[0,255,127,1],steelblue:[70,130,180,1],tan:[210,180,140,1],teal:[0,128,128,1],thistle:[216,191,216,1],tomato:[255,99,71,1],turquoise:[64,224,208,1],violet:[238,130,238,1],wheat:[245,222,179,1],white:[255,255,255,1],whitesmoke:[245,245,245,1],yellow:[255,255,0,1],yellowgreen:[154,205,50,1]};function On(t){return(t=Math.round(t))255?255:t}function Bn(t){return On("%"===t[t.length-1]?parseFloat(t)/100*255:parseInt(t))}function Fn(t){return(e="%"===t[t.length-1]?parseFloat(t)/100:parseFloat(t))1?1:e;var e}function Nn(t,e,i){return i1&&(i-=1),6*i=0&&e>4|(3840&e)>>8,240&e|(240&e)>>4,15&e|(15&e)=0&&e>16,(65280&e)>>8,255&e,1]:null;var n=i.indexOf("("),r=i.indexOf(")");if(-1!==n&&r+1===i.length){var o=i.substr(0,n),s=i.substr(n+1,r-(n+1)).split(","),a=1;switch(o){case"rgba":if(4!==s.length)return null;a=Fn(s.pop());case"rgb":return 3!==s.length?null:[Bn(s[0]),Bn(s[1]),Bn(s[2]),a];case"hsla":if(4!==s.length)return null;a=Fn(s.pop());case"hsl":if(3!==s.length)return null;var l=(parseFloat(s[0])%360+360)%360/360,c=Fn(s[1]),d=Fn(s[2]),u=d=_.length)throw new Error("out of range");this.r=Vn(Vn(Vn(_[g],_[y],m),Vn(_[v],_[x],m),f),Vn(Vn(_[b],_[w],m),Vn(_[T],_[S],m),f),p)/255*r,this.g=Vn(Vn(Vn(_[g+1],_[y+1],m),Vn(_[v+1],_[x+1],m),f),Vn(Vn(_[b+1],_[w+1],m),Vn(_[T+1],_[S+1],m),f),p)/255*r,this.b=Vn(Vn(Vn(_[g+2],_[y+2],m),Vn(_[v+2],_[x+2],m),f),Vn(Vn(_[b+2],_[w+2],m),Vn(_[T+2],_[S+2],m),f),p)/255*r,this.a=r}else this.r=e,this.g=i,this.b=n,this.a=r}toArray(){const{r:t,g:e,b:i,a:n}=this;return 0===n?[0,0,0,0]:[255*t/n,255*e/n,255*i/n,n]}toArray01(){const{r:t,g:e,b:i,a:n}=this;return 0===n?[0,0,0,0]:[t/n,e/n,i/n,n]}toArray01Scaled(t){const{r:e,g:i,b:n,a:r}=this;return 0===r?[0,0,0]:[e/r*t,i/r*t,n/r*t]}toArray01PremultipliedAlpha(){const{r:t,g:e,b:i,a:n}=this;return[t,e,i,n]}toArray01Linear(){const{r:t,g:e,b:i,a:n}=this;return 0===n?[0,0,0,0]:[Math.pow(t/n,2.2),Math.pow(e/n,2.2),Math.pow(i/n,2.2),n]}}function Vn(t,e,i){return t*(1-i)+e*i}function Gn(t,e,i){return t.map(((t,n)=>Vn(t,e[n],i)))}Un.black=new Un(0,0,0,1),Un.white=new Un(1,1,1,1),Un.transparent=new Un(0,0,0,0),Un.red=new Un(1,0,0,1),Un.blue=new Un(0,0,1,1);var Zn=Object.freeze({__proto__:null,array:Gn,color:function(t,e,i){return new Un(Vn(t.r,e.r,i),Vn(t.g,e.g,i),Vn(t.b,e.b,i),Vn(t.a,e.a,i))},number:Vn});function qn(t,...e){for(const i of e)for(const e in i)t[e]=i[e];return t}class Hn extends Error{constructor(t,e){super(e),this.message=e,this.key=t}}class Wn{constructor(t,e=[]){this.parent=t,this.bindings={};for(const[t,i]of e)this.bindings[t]=i}concat(t){return new Wn(this,t)}get(t){if(this.bindings[t])return this.bindings[t];if(this.parent)return this.parent.get(t);throw new Error(`${t} not found in scope.`)}has(t){return!!this.bindings[t]||!!this.parent&&this.parent.has(t)}}const Yn={kind:"null"},Xn={kind:"number"},Kn={kind:"string"},Jn={kind:"boolean"},Qn={kind:"color"},tr={kind:"object"},er={kind:"value"},ir={kind:"collator"},nr={kind:"formatted"},rr={kind:"resolvedImage"};function or(t,e){return{kind:"array",itemType:t,N:e}}function sr(t){if("array"===t.kind){const e=sr(t.itemType);return"number"==typeof t.N?`array`:"value"===t.itemType.kind?"array":`array`}return t.kind}const ar=[Yn,Xn,Kn,Jn,Qn,nr,tr,or(er),rr];function lr(t,e){if("error"===e.kind)return null;if("array"===t.kind){if("array"===e.kind&&(0===e.N&&"value"===e.itemType.kind||!lr(t.itemType,e.itemType))&&("number"!=typeof t.N||t.N===e.N))return null}else{if(t.kind===e.kind)return null;if("value"===t.kind)for(const t of ar)if(!lr(t,e))return null}return`Expected ${sr(t)} but found ${sr(e)} instead.`}function cr(t,e){return e.some((e=>e.kind===t.kind))}function dr(t,e){return e.some((e=>"null"===e?null===t:"array"===e?Array.isArray(t):"object"===e?t&&!Array.isArray(t)&&"object"==typeof t:e===typeof t))}class ur{constructor(t,e,i){this.sensitivity=t?e?"variant":"case":e?"accent":"base",this.locale=i,this.collator=new Intl.Collator(this.locale?this.locale:[],{sensitivity:this.sensitivity,usage:"search"})}compare(t,e){return this.collator.compare(t,e)}resolvedLocale(){return new Intl.Collator(this.locale?this.locale:[]).resolvedOptions().locale}}class hr{constructor(t,e,i,n,r){this.text=t.normalize?t.normalize():t,this.image=e,this.scale=i,this.fontStack=n,this.textColor=r}}class pr{constructor(t){this.sections=t}static fromString(t){return new pr([new hr(t,null,null,null,null)])}isEmpty(){return 0===this.sections.length||!this.sections.some((t=>0!==t.text.length||t.image&&0!==t.image.namePrimary.length))}static factory(t){return t instanceof pr?t:pr.fromString(t)}toString(){return 0===this.sections.length?"":this.sections.map((t=>t.text)).join("")}serialize(){const t=["format"];for(const e of this.sections){if(e.image){t.push(["image",e.image.namePrimary]);continue}t.push(e.text);const i={};e.fontStack&&(i["text-font"]=["literal",e.fontStack.split(",")]),e.scale&&(i["font-scale"]=e.scale),e.textColor&&(i["text-color"]=["rgba"].concat(e.textColor.toRenderColor(null).toArray())),t.push(i)}return t}}class fr{constructor(t){this.namePrimary=t.namePrimary,t.nameSecondary&&(this.nameSecondary=t.nameSecondary),this.available=t.available}toString(){return this.nameSecondary?`[${this.namePrimary},${this.nameSecondary}]`:this.namePrimary}static fromString(t,e){return t?new fr({namePrimary:t,nameSecondary:e,available:!1}):null}serialize(){return this.nameSecondary?["image",this.namePrimary,this.nameSecondary]:["image",this.namePrimary]}}function mr(t,e,i,n){return"number"==typeof t&&t>=0&&t=0&&e=0&&i=0&&n2){const i=t[1];if("string"!=typeof i||!(i in br)||"object"===i)return e.error('The item type argument of "array" must be one of string, number, boolean',1);r=br[i],n++}else r=er;if(t.length>3){if(null!==t[2]&&("number"!=typeof t[2]||t[2]t.outputDefined()))}serialize(){const t=this.type,e=[t.kind];if("array"===t.kind){const i=t.itemType;if("string"===i.kind||"number"===i.kind||"boolean"===i.kind){e.push(i.kind);const n=t.N;("number"==typeof n||this.args.length>1)&&e.push(n)}}return e.concat(this.args.map((t=>t.serialize())))}}class Tr{constructor(t){this.type=nr,this.sections=t}static parse(t,e){if(t.length{const i=e.content.evaluate(t);return gr(i)===rr?new hr("",i,null,null,null):new hr(yr(i),null,e.scale?e.scale.evaluate(t):null,e.font?e.font.evaluate(t).join(","):null,e.textColor?e.textColor.evaluate(t):null)})))}eachChild(t){for(const e of this.sections)t(e.content),e.scale&&t(e.scale),e.font&&t(e.font),e.textColor&&t(e.textColor)}outputDefined(){return!1}serialize(){const t=["format"];for(const e of this.sections){t.push(e.content.serialize());const i={};e.scale&&(i["font-scale"]=e.scale.serialize()),e.font&&(i["text-font"]=e.font.serialize()),e.textColor&&(i["text-color"]=e.textColor.serialize()),t.push(i)}return t}}class Sr{constructor(t,e){this.type=rr,this.inputPrimary=t,this.inputSecondary=e}static parse(t,e){if(t.length-1,e.nameSecondary&&e.available&&t.availableImages&&(e.available=t.availableImages.indexOf(e.nameSecondary)>-1)),e}eachChild(t){t(this.inputPrimary),this.inputSecondary&&t(this.inputSecondary)}outputDefined(){return!1}serialize(){return this.inputSecondary?["image",this.inputPrimary.serialize(),this.inputSecondary.serialize()]:["image",this.inputPrimary.serialize()]}}function Er(t){return t instanceof Number?"number":t instanceof String?"string":t instanceof Boolean?"boolean":Array.isArray(t)?"array":null===t?"null":typeof t}const Mr={"to-boolean":Jn,"to-color":Qn,"to-number":Xn,"to-string":Kn};class Cr{constructor(t,e){this.type=t,this.args=e}static parse(t,e){if(t.length0&&_r(t[1][0])))return null;r=or(gr(t[1][0]),i)}for(let o=0;o4?`Invalid rbga value ${JSON.stringify(e)}: expected an array containing either three or four numeric values.`:mr(e[0],e[1],e[2],e[3]),!i))return new Un(e[0]/255,e[1]/255,e[2]/255,e[3])}throw new xr(i||`Could not parse color from value '${"string"==typeof e?e:String(JSON.stringify(e))}'`)}if("number"===this.type.kind){let e=null;for(const i of this.args){if(e=i.evaluate(t),null===e)return 0;const n=Number(e);if(!isNaN(n))return n}throw new xr(`Could not convert ${JSON.stringify(e)} to number.`)}return"formatted"===this.type.kind?pr.fromString(yr(this.args[0].evaluate(t))):"resolvedImage"===this.type.kind?fr.fromString(yr(this.args[0].evaluate(t))):"array"===this.type.kind?this.args.map((e=>e.evaluate(t))):yr(this.args[0].evaluate(t))}eachChild(t){this.args.forEach(t)}outputDefined(){return this.args.every((t=>t.outputDefined()))}serialize(){if("formatted"===this.type.kind)return new Tr([{content:this.args[0],scale:null,font:null,textColor:null}]).serialize();if("resolvedImage"===this.type.kind)return new Sr(this.args[0]).serialize();const t="array"===this.type.kind?[]:[`to-${this.type.kind}`];return this.eachChild((e=>{t.push(e.serialize())})),t}}const Ar=["Unknown","Point","LineString","Polygon"];class Ir{constructor(t,e){this.globals=null,this.feature=null,this.featureState=null,this.formattedSection=null,this._parseColorCache={},this.availableImages=null,this.canonical=null,this.featureTileCoord=null,this.featureDistanceData=null,this.scope=t,this.options=e}id(){return this.feature&&void 0!==this.feature.id?this.feature.id:null}geometryType(){return this.feature?"number"==typeof this.feature.type?Ar[this.feature.type]:this.feature.type:null}geometry(){return this.feature&&"geometry"in this.feature?this.feature.geometry:null}canonicalID(){return this.canonical}properties(){return this.feature&&this.feature.properties||{}}measureLight(t){return this.globals.brightness||0}distanceFromCenter(){if(this.featureTileCoord&&this.featureDistanceData){const t=this.featureDistanceData.center,e=this.featureDistanceData.scale,{x:i,y:n}=this.featureTileCoord;return this.featureDistanceData.bearing[0]*(i*e-t[0])+this.featureDistanceData.bearing[1]*(n*e-t[1])}return 0}parseColor(t){let e=this._parseColorCache[t];return e||(e=this._parseColorCache[t]=Un.parse(t)),e}getConfig(t){return this.options?this.options.get(t):null}}class Lr{constructor(t,e,i,n,r){this.name=t,this.type=e,this._evaluate=i,this.args=n,this._overloadIndex=r}evaluate(t){if(!this._evaluate){const t=Lr.definitions[this.name];this._evaluate=Array.isArray(t)?t[2]:t.overloads[this._overloadIndex][1]}return this._evaluate(t,this.args)}eachChild(t){this.args.forEach(t)}outputDefined(){return!1}serialize(){return[this.name].concat(this.args.map((t=>t.serialize())))}static parse(t,e){const i=t[0],n=Lr.definitions[i];if(!n)return e.error(`Unknown expression "${i}". If you wanted a literal array, use ["literal", [...]].`,0);const r=Array.isArray(n)?n[0]:n.type,o=Array.isArray(n)?[[n[1],n[2]]]:n.overloads,s=[];let a=null,l=-1;for(const[n,c]of o){if(Array.isArray(n)&&n.length!==t.length-1)continue;s.push(n),l++,a=new Ko(e.registry,e.path,null,e.scope,void 0,e._scope,e.options);const o=[];let d=!1;for(let e=1;et))).map(Pr).join(" | "),n=[];for(let i=1;ii;){if(n-i>600){const o=n-i+1,s=e-i+1,a=Math.log(o),l=.5*Math.exp(2*a/3),c=.5*Math.sqrt(a*l*(o-l)/o)*(s-o/20&&Dr(t,i,n);s0;)a--}0===r(t[i],o)?Dr(t,i,a):(a++,Dr(t,a,n)),ae?1:0}function Rr(t){let e=0;for(let i,n,r=0,o=t.length,s=o-1;r=e[2]||t[1]=e[3])}function Fr(t,e,i){const n=t[0]-e[0],r=t[1]-e[1],o=t[0]-i[0],s=t[1]-i[1];return n*s-o*r==0&&n*o(r=t)[1]!=(s=d)[1]>r[1]&&r[0]0&&a0}function jr(t,e,i,n){return 0!=(r=[n[0]-i[0],n[1]-i[1]])[0]*(o=[e[0]-t[0],e[1]-t[1]])[1]-r[1]*o[0]&&!(!Ur(t,e,i,n)||!Ur(i,n,t,e));var r,o}const Vr=8192;function Gr(t,e){const i=(180+t[0])/360,n=(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+t[1]*Math.PI/360)))/360,r=Math.pow(2,e.z);return[Math.round(i*r*Vr),Math.round(n*r*Vr)]}function Zr(t,e){for(let i=0;ii[2]){const e=.5*n;let r=t[0]-i[0]>e?-n:i[0]-t[0]>e?n:0;0===r&&(r=t[0]-i[2]>e?-n:i[2]-t[0]>e?n:0),t[0]+=r}Or(e,t)}function Jr(t,e,i,n){const r=Math.pow(2,n.z)*Vr,o=[n.x*Vr,n.y*Vr],s=[];if(!t)return s;for(const n of t)for(const t of n){const n=[t.x+o[0],t.y+o[1]];Kr(n,e,i,r),s.push(n)}return s}function Qr(t,e,i,n){const r=Math.pow(2,n.z)*Vr,o=[n.x*Vr,n.y*Vr],s=[];if(!t)return s;for(const i of t){const t=[];for(const n of i){const i=[n.x+o[0],n.y+o[1]];Or(e,i),t.push(i)}s.push(t)}if(e[2]-e[0]e)return ao(r,o,(e-(i-s))/s)}return t[t.length-1]}pointToSegmentDistance(t,e,i){let[n,r]=e,o=lo(i[0]-n)*this.kx,s=(i[1]-r)*this.ky;if(0!==o||0!==s){const e=(lo(t[0]-n)*this.kx*o+(t[1]-r)*this.ky*s)/(o*o+s*s);e>1?(n=i[0],r=i[1]):e>0&&(n+=o/this.kx*e,r+=s/this.ky*e)}return o=lo(t[0]-n)*this.kx,s=(t[1]-r)*this.ky,Math.sqrt(o*o+s*s)}pointOnLine(t,e){let i=1/0,n=t[0][0],r=t[0][1],o=0,s=0;for(let a=0;a1?(l=t[a+1][0],c=t[a+1][1]):h>0&&(l+=d/this.kx*h,c+=u/this.ky*h)),d=lo(e[0]-l)*this.kx,u=(e[1]-c)*this.ky;const p=d*d+u*u;pr.index||n.index===r.index&&n.t>r.t){const t=n;n=r,r=t}const o=[n.point],s=n.index+1,a=r.index;!so(i[s],o[0])&&st&&0===r.length&&r.push(ao(s,a,(t-(n-l))/l)),n>=e)return r.push(ao(s,a,(e-(n-l))/l)),r;n>t&&r.push(a)}return r}bufferPoint(t,e){const i=e/this.ky,n=e/this.kx;return[t[0]-n,t[1]-i,t[0]+n,t[1]+i]}bufferBBox(t,e){const i=e/this.ky,n=e/this.kx;return[t[0]-n,t[1]-i,t[2]+n,t[3]+i]}insideBBox(t,e){return lo(t[0]-e[0])>=0&&lo(t[0]-e[2])=e[1]&&t[1]180;)t-=360;return t}class co{constructor(t=[],e=(t,e)=>te?1:0){if(this.data=t,this.length=this.data.length,this.compare=e,this.length>0)for(let t=(this.length>>1)-1;t>=0;t--)this._down(t)}push(t){this.data.push(t),this._up(this.length++)}pop(){if(0===this.length)return;const t=this.data[0],e=this.data.pop();return--this.length>0&&(this.data[0]=e,this._down(0)),t}peek(){return this.data[0]}_up(t){const{data:e,compare:i}=this,n=e[t];for(;t>0;){const r=t-1>>1,o=e[r];if(i(n,o)>=0)break;e[t]=o,t=r}e[t]=n}_down(t){const{data:e,compare:i}=this,n=this.length>>1,r=e[t];for(;t=0)break;e[t]=e[n],t=n}e[t]=r}}var uo=8192;function ho(t,e){return e.dist-t.dist}const po=100,fo=50;function mo(t){const e=[1/0,1/0,-1/0,-1/0];if(e.length!==t.length)return!1;for(let i=0;i=t[0]&&t[1]t[1])return[null,null];const i=_o(t);if(e){if(2===i)return[t,null];const e=Math.floor(i/2);return[[t[0],t[0]+e],[t[0]+e,t[1]]]}{if(1===i)return[t,null];const e=Math.floor(i/2)-1;return[[t[0],t[0]+e],[t[0]+e+1,t[1]]]}}function vo(t,e){const i=[1/0,1/0,-1/0,-1/0];if(!go(e,t.length))return i;for(let n=e[0];ne[2]&&(n=t[0]-e[2]),t[1]>e[3]&&(r=t[1]-e[3]),t[3]=n)return n;if(Br(r,o)){if(ko(t,e))return 0}else if(ko(e,t))return 0;let s=n;for(const n of t)for(let t=0,r=n.length,o=r-1;t=o)continue;const c=r.range1;if(_o(c)=s)continue;const d=o.range1,u=o.range2;if(_o(d)=o)&&(o=Math.min(o,Oo(t,e,r,!0,n,o)),0===o))return o;return o}function Fo(t,e,i,n,r=1/0){let o=r;const s=vo(t,[0,t.length-1]);for(const r of i){if(o!==1/0&&bo(s,xo(r),n)>=o)continue;const i=Ro(t,e,r,n,o);if(isNaN(i))return i;if(0===(o=Math.min(o,i)))return o}return o}function No(t){return"Point"===t||"MultiPoint"===t||"LineString"===t||"MultiLineString"===t||"Polygon"===t||"MultiPolygon"===t}class Uo{constructor(t,e){this.type=Xn,this.geojson=t,this.geometries=e}static parse(t,e){if(2!==t.length)return e.error(`'distance' expression requires either one argument, but found ' ${t.length-1} instead.`);if(_r(t[1])){const e=t[1];if("FeatureCollection"===e.type){for(let t=0;ti&&(t=i),t}class Go{constructor(t,e,i){this.type=t,this.key=e,this.scope=i}static parse(t,e){let i=e.expectedType;if(null==i&&(i=er),t.length3)return e.error("Invalid number of arguments for 'config' expression.");const n=e.parse(t[1],1);if(!(n instanceof vr))return e.error("Key name of 'config' expression must be a string literal.");if(t.length>=3){const r=e.parse(t[2],2);return r instanceof vr?new Go(i,yr(n.value),yr(r.value)):e.error("Scope of 'config' expression must be a string literal.")}return new Go(i,yr(n.value))}evaluate(t){const e=[this.key,this.scope,t.scope].filter(Boolean).join(""),i=t.getConfig(e);if(!i)return null;const{type:n,value:r,values:o,minValue:s,maxValue:a,stepValue:l}=i,c=i.default.evaluate(t);let d=c;if(r){const e=t.scope;t.scope=(e||"").split("").slice(1).join(""),d=r.evaluate(t),t.scope=e}return n&&(d=jo(n,d)),void 0===d||void 0===s&&void 0===a&&void 0===l||("number"==typeof d?d=Vo(d,s,a,l):Array.isArray(d)&&(d=d.map((t=>"number"==typeof t?Vo(t,s,a,l):t)))),void 0!==r&&void 0!==d&&o&&!o.includes(d)&&(d=c,n&&(d=jo(n,d))),(n&&n!==this.type||void 0!==d&&gr(d)!==this.type)&&(d=jo(this.type.kind,d)),d}eachChild(){}outputDefined(){return!1}serialize(){const t=["config",this.key];return this.scope&&t.concat(this.key),t}}function Zo(t){if(t instanceof Lr){if("get"===t.name&&1===t.args.length)return!1;if("feature-state"===t.name)return!1;if("has"===t.name&&1===t.args.length)return!1;if("properties"===t.name||"geometry-type"===t.name||"id"===t.name)return!1;if(/^filter-/.test(t.name))return!1}if(t instanceof to)return!1;if(t instanceof Uo)return!1;let e=!0;return t.eachChild((t=>{e&&!Zo(t)&&(e=!1)})),e}function qo(t){if(t instanceof Lr&&"feature-state"===t.name)return!1;let e=!0;return t.eachChild((t=>{e&&!qo(t)&&(e=!1)})),e}function Ho(t){if(t instanceof Go)return!1;let e=!0;return t.eachChild((t=>{e&&!Ho(t)&&(e=!1)})),e}function Wo(t,e){if(t instanceof Lr&&e.indexOf(t.name)>=0)return!1;let i=!0;return t.eachChild((t=>{i&&!Wo(t,e)&&(i=!1)})),i}class Yo{constructor(t,e){this.type=e.type,this.name=t,this.boundExpression=e}static parse(t,e){if(2!==t.length||"string"!=typeof t[1])return e.error("'var' expression requires exactly one string literal argument.");const i=t[1];return e.scope.has(i)?new Yo(i,e.scope.get(i)):e.error(`Unknown variable "${i}". Make sure "${i}" has been bound in an enclosing "let" expression before using it.`,1)}evaluate(t){return this.boundExpression.evaluate(t)}eachChild(){}outputDefined(){return!1}serialize(){return["var",this.name]}}class Xo{constructor(t,e=[],i,n=new Wn,r=[],o,s){this.registry=t,this.path=e,this.key=e.map((t=>`[${t}]`)).join(""),this.scope=n,this.errors=r,this.expectedType=i,this._scope=o,this.options=s}parse(t,e,i,n,r={}){return e||i?this.concat(e,i,n)._parse(t,r):this._parse(t,r)}_parse(t,e){function i(t,e,i){return"assert"===i?new wr(e,[t]):"coerce"===i?new Cr(e,[t]):t}if(null!==t&&"string"!=typeof t&&"boolean"!=typeof t&&"number"!=typeof t||(t=["literal",t]),Array.isArray(t)){if(0===t.length)return this.error('Expected an array with at least one element. If you wanted a literal array, use ["literal", []].');const n="string"==typeof t[0]?this.registry[t[0]]:void 0;if(n){let r=n.parse(t,this);if(!r)return null;if(this.expectedType){const t=this.expectedType,n=r.type;if("string"!==t.kind&&"number"!==t.kind&&"boolean"!==t.kind&&"object"!==t.kind&&"array"!==t.kind||"value"!==n.kind)if("color"!==t.kind&&"formatted"!==t.kind&&"resolvedImage"!==t.kind||"value"!==n.kind&&"string"!==n.kind){if(this.checkSubtype(t,n))return null}else r=i(r,t,e.typeAnnotation||"coerce");else r=i(r,t,e.typeAnnotation||"assert")}if(!(r instanceof vr)&&"resolvedImage"!==r.type.kind&&Jo(r)){const e=new Ir(this._scope,this.options);try{r=new vr(r.type,r.evaluate(e))}catch(t){return this.error(t.message),null}}return r}return Cr.parse(["to-array",t],this)}return this.error(void 0===t?"'undefined' value invalid. Use null instead.":"object"==typeof t?'Bare objects invalid. Use ["literal", {...}] instead.':`Expected an array, but found ${typeof t} instead.`)}concat(t,e,i){const n="number"==typeof t?this.path.concat(t):this.path,r=i?this.scope.concat(i):this.scope;return new Xo(this.registry,n,e||null,r,this.errors,this._scope,this.options)}error(t,...e){const i=`${this.key}${e.map((t=>`[${t}]`)).join("")}`;this.errors.push(new Hn(i,t))}checkSubtype(t,e){const i=lr(t,e);return i&&this.error(i),i}}var Ko=Xo;function Jo(t){if(t instanceof Yo)return Jo(t.boundExpression);if(t instanceof Lr&&"error"===t.name)return!1;if(t instanceof $r)return!1;if(t instanceof to)return!1;if(t instanceof Uo)return!1;if(t instanceof Go)return!1;const e=t instanceof Cr||t instanceof wr;let i=!0;return t.eachChild((t=>{i=e?i&&Jo(t):i&&t instanceof vr})),!!i&&Zo(t)&&Wo(t,["zoom","heatmap-density","line-progress","raster-value","sky-radial-progress","accumulated","is-supported-script","pitch","distance-from-center","measure-light","raster-particle-speed"])}function Qo(t,e){const i=t.length-1;let n,r,o=0,s=i,a=0;for(;oe))throw new xr("Input is not a number.");s=a-1}return 0}class ts{constructor(t,e,i){this.type=t,this.input=e,this.labels=[],this.outputs=[];for(const[t,e]of i)this.labels.push(t),this.outputs.push(e)}static parse(t,e){if(t.length-1=o)return e.error('Input/output pairs for "step" expressions must be arranged with input values in strictly ascending order.',a);const c=e.parse(s,l,r);if(!c)return null;r=r||c.type,n.push([o,c])}return new ts(r,i,n)}evaluate(t){const e=this.labels,i=this.outputs;if(1===e.length)return i[0].evaluate(t);const n=this.input.evaluate(t);if(n=e[r-1]?i[r-1].evaluate(t):i[Qo(e,n)].evaluate(t)}eachChild(t){t(this.input);for(const e of this.outputs)t(e)}outputDefined(){return this.outputs.every((t=>t.outputDefined()))}serialize(){const t=["step",this.input.serialize()];for(let e=0;e0&&t.push(this.labels[e]),t.push(this.outputs[e].serialize());return t}}const es=.95047,is=1.08883,ns=4/29,rs=6/29,os=3*rs*rs,ss=rs*rs*rs,as=Math.PI/180,ls=180/Math.PI;function cs(t){return t>ss?Math.pow(t,1/3):t/os+ns}function ds(t){return t>rs?t*t*t:os*(t-ns)}function us(t){return 255*(t180||n"number"!=typeof t||t1)))return e.error("Cubic bezier interpolation requires four numeric arguments with values between 0 and 1.",1);n={name:"cubic-bezier",controlPoints:t}}}if(t.length-1=i)return e.error('Input/output pairs for "interpolate" expressions must be arranged with input values in strictly ascending order.',r);const c=e.parse(n,l,a);if(!c)return null;a=a||c.type,s.push([i,c])}return"number"===a.kind||"color"===a.kind||"array"===a.kind&&"number"===a.itemType.kind&&"number"==typeof a.N?new vs(a,i,n,r,s):e.error(`Type ${sr(a)} is not interpolatable.`)}evaluate(t){const e=this.labels,i=this.outputs;if(1===e.length)return i[0].evaluate(t);const n=this.input.evaluate(t);if(n=e[r-1])return i[r-1].evaluate(t);const o=Qo(e,n),s=vs.interpolationFactor(this.interpolation,n,e[o],e[o+1]),a=i[o].evaluate(t),l=i[o+1].evaluate(t);return"interpolate"===this.operator?Zn[this.type.kind.toLowerCase()](a,l,s):"interpolate-hcl"===this.operator?gs.reverse(gs.interpolate(gs.forward(a),gs.forward(l),s)):_s.reverse(_s.interpolate(_s.forward(a),_s.forward(l),s))}eachChild(t){t(this.input);for(const e of this.outputs)t(e)}outputDefined(){return this.outputs.every((t=>t.outputDefined()))}serialize(){let t;t="linear"===this.interpolation.name?["linear"]:"exponential"===this.interpolation.name?1===this.interpolation.base?["linear"]:["exponential",this.interpolation.base]:["cubic-bezier"].concat(this.interpolation.controlPoints);const e=[this.operator,t,this.input.serialize()];for(let t=0;tlr(n,t.type)));return new bs(o?er:i,r)}evaluate(t){let e,i=null,n=0;for(const r of this.args){if(n++,i=r.evaluate(t),i&&i instanceof fr&&!i.available&&(e||(e=i),i=null,n===this.args.length))return e;if(null!==i)break}return i}eachChild(t){this.args.forEach(t)}outputDefined(){return this.args.every((t=>t.outputDefined()))}serialize(){const t=["coalesce"];return this.eachChild((e=>{t.push(e.serialize())})),t}}class ws{constructor(t,e){this.type=e.type,this.bindings=[].concat(t),this.result=e}evaluate(t){return this.result.evaluate(t)}eachChild(t){for(const e of this.bindings)t(e[1]);t(this.result)}static parse(t,e){if(t.length=i.length)throw new xr(`Array index out of bounds: ${e} > ${i.length-1}.`);if(e!==Math.floor(e))throw new xr(`Array index must be an integer, but found ${e} instead.`);return i[e]}eachChild(t){t(this.index),t(this.input)}outputDefined(){return!1}serialize(){return["at",this.index.serialize(),this.input.serialize()]}}class Ss{constructor(t,e){this.type=Jn,this.needle=t,this.haystack=e}static parse(t,e){if(3!==t.length)return e.error(`Expected 2 arguments, but found ${t.length-1} instead.`);const i=e.parse(t[1],1,er),n=e.parse(t[2],2,er);return i&&n?cr(i.type,[Jn,Kn,Xn,Yn,er])?new Ss(i,n):e.error(`Expected first argument to be of type boolean, string, number or null, but found ${sr(i.type)} instead`):null}evaluate(t){const e=this.needle.evaluate(t),i=this.haystack.evaluate(t);if(null==i)return!1;if(!dr(e,["boolean","string","number","null"]))throw new xr(`Expected first argument to be of type boolean, string, number or null, but found ${sr(gr(e))} instead.`);if(!dr(i,["string","array"]))throw new xr(`Expected second argument to be of type array or string, but found ${sr(gr(i))} instead.`);return i.indexOf(e)>=0}eachChild(t){t(this.needle),t(this.haystack)}outputDefined(){return!0}serialize(){return["in",this.needle.serialize(),this.haystack.serialize()]}}class Es{constructor(t,e,i){this.type=Xn,this.needle=t,this.haystack=e,this.fromIndex=i}static parse(t,e){if(t.length=5)return e.error(`Expected 3 or 4 arguments, but found ${t.length-1} instead.`);const i=e.parse(t[1],1,er),n=e.parse(t[2],2,er);if(!i||!n)return null;if(!cr(i.type,[Jn,Kn,Xn,Yn,er]))return e.error(`Expected first argument to be of type boolean, string, number or null, but found ${sr(i.type)} instead`);if(4===t.length){const r=e.parse(t[3],3,Xn);return r?new Es(i,n,r):null}return new Es(i,n)}evaluate(t){const e=this.needle.evaluate(t),i=this.haystack.evaluate(t);if(!dr(e,["boolean","string","number","null"]))throw new xr(`Expected first argument to be of type boolean, string, number or null, but found ${sr(gr(e))} instead.`);if(!dr(i,["string","array"]))throw new xr(`Expected second argument to be of type array or string, but found ${sr(gr(i))} instead.`);if(this.fromIndex){const n=this.fromIndex.evaluate(t);return i.indexOf(e,n)}return i.indexOf(e)}eachChild(t){t(this.needle),t(this.haystack),this.fromIndex&&t(this.fromIndex)}outputDefined(){return!1}serialize(){if(null!=this.fromIndex&&void 0!==this.fromIndex){const t=this.fromIndex.serialize();return["index-of",this.needle.serialize(),this.haystack.serialize(),t]}return["index-of",this.needle.serialize(),this.haystack.serialize()]}}class Ms{constructor(t,e,i,n,r,o){this.inputType=t,this.type=e,this.input=i,this.cases=n,this.outputs=r,this.otherwise=o}static parse(t,e){if(t.lengthNumber.MAX_SAFE_INTEGER)return c.error(`Branch labels must be integers no larger than ${Number.MAX_SAFE_INTEGER}.`);if("number"==typeof t&&Math.floor(t)!==t)return c.error("Numeric branch labels must be integer values.");if(i){if(c.checkSubtype(i,gr(t)))return null}else i=gr(t);if(void 0!==r[String(t)])return c.error("Branch labels must be unique.");r[String(t)]=o.length}const d=e.parse(l,s,n);if(!d)return null;n=n||d.type,o.push(d)}const s=e.parse(t[1],1,er);if(!s)return null;const a=e.parse(t[t.length-1],t.length-1,n);return a?"value"!==s.type.kind&&e.concat(1).checkSubtype(i,s.type)?null:new Ms(i,n,s,r,o,a):null}evaluate(t){const e=this.input.evaluate(t);return(gr(e)===this.inputType&&this.outputs[this.cases[e]]||this.otherwise).evaluate(t)}eachChild(t){t(this.input),this.outputs.forEach(t),t(this.otherwise)}outputDefined(){return this.outputs.every((t=>t.outputDefined()))&&this.otherwise.outputDefined()}serialize(){const t=["match",this.input.serialize()],e=Object.keys(this.cases).sort(),i=[],n={};for(const t of e){const e=n[this.cases[t]];void 0===e?(n[this.cases[t]]=i.length,i.push([this.cases[t],[t]])):i[e][1].push(t)}const r=t=>"number"===this.inputType.kind?Number(t):t;for(const[e,n]of i)t.push(1===n.length?r(n[0]):n.map(r)),t.push(this.outputs[e].serialize());return t.push(this.otherwise.serialize()),t}}class Cs{constructor(t,e,i){this.type=t,this.branches=e,this.otherwise=i}static parse(t,e){if(t.lengthe.outputDefined()))&&this.otherwise.outputDefined()}serialize(){const t=["case"];return this.eachChild((e=>{t.push(e.serialize())})),t}}class As{constructor(t,e,i,n){this.type=t,this.input=e,this.beginIndex=i,this.endIndex=n}static parse(t,e){if(t.length=5)return e.error(`Expected 3 or 4 arguments, but found ${t.length-1} instead.`);const i=e.parse(t[1],1,er),n=e.parse(t[2],2,Xn);if(!i||!n)return null;if(!cr(i.type,[or(er),Kn,er]))return e.error(`Expected first argument to be of type array or string, but found ${sr(i.type)} instead`);if(4===t.length){const r=e.parse(t[3],3,Xn);return r?new As(i.type,i,n,r):null}return new As(i.type,i,n)}evaluate(t){const e=this.input.evaluate(t),i=this.beginIndex.evaluate(t);if(!dr(e,["string","array"]))throw new xr(`Expected first argument to be of type array or string, but found ${sr(gr(e))} instead.`);if(this.endIndex){const n=this.endIndex.evaluate(t);return e.slice(i,n)}return e.slice(i)}eachChild(t){t(this.input),t(this.beginIndex),this.endIndex&&t(this.endIndex)}outputDefined(){return!1}serialize(){if(null!=this.endIndex&&void 0!==this.endIndex){const t=this.endIndex.serialize();return["slice",this.input.serialize(),this.beginIndex.serialize(),t]}return["slice",this.input.serialize(),this.beginIndex.serialize()]}}function Is(t,e){return"=="===t||"!="===t?"boolean"===e.kind||"string"===e.kind||"number"===e.kind||"null"===e.kind||"value"===e.kind:"string"===e.kind||"number"===e.kind||"value"===e.kind}function Ls(t,e,i,n){return 0===n.compare(e,i)}function Ps(t,e,i){const n="=="!==t&&"!="!==t;return class r{constructor(t,e,i){this.type=Jn,this.lhs=t,this.rhs=e,this.collator=i,this.hasUntypedArgument="value"===t.type.kind||"value"===e.type.kind}static parse(t,e){if(3!==t.length&&4!==t.length)return e.error("Expected two or three arguments.");const i=t[0];let o=e.parse(t[1],1,er);if(!o)return null;if(!Is(i,o.type))return e.concat(1).error(`"${i}" comparisons are not supported for type '${sr(o.type)}'.`);let s=e.parse(t[2],2,er);if(!s)return null;if(!Is(i,s.type))return e.concat(2).error(`"${i}" comparisons are not supported for type '${sr(s.type)}'.`);if(o.type.kind!==s.type.kind&&"value"!==o.type.kind&&"value"!==s.type.kind)return e.error(`Cannot compare types '${sr(o.type)}' and '${sr(s.type)}'.`);n&&("value"===o.type.kind&&"value"!==s.type.kind?o=new wr(s.type,[o]):"value"!==o.type.kind&&"value"===s.type.kind&&(s=new wr(o.type,[s])));let a=null;if(4===t.length){if("string"!==o.type.kind&&"string"!==s.type.kind&&"value"!==o.type.kind&&"value"!==s.type.kind)return e.error("Cannot use collator to compare non-string types.");if(a=e.parse(t[3],3,ir),!a)return null}return new r(o,s,a)}evaluate(r){const o=this.lhs.evaluate(r),s=this.rhs.evaluate(r);if(n&&this.hasUntypedArgument){const e=gr(o),i=gr(s);if(e.kind!==i.kind||"string"!==e.kind&&"number"!==e.kind)throw new xr(`Expected arguments for "${t}" to be (string, string) or (number, number), but found (${e.kind}, ${i.kind}) instead.`)}if(this.collator&&!n&&this.hasUntypedArgument){const t=gr(o),i=gr(s);if("string"!==t.kind||"string"!==i.kind)return e(r,o,s)}return this.collator?i(r,o,s,this.collator.evaluate(r)):e(r,o,s)}eachChild(t){t(this.lhs),t(this.rhs),this.collator&&t(this.collator)}outputDefined(){return!0}serialize(){const e=[t];return this.eachChild((t=>{e.push(t.serialize())})),e}}}const $s=Ps("==",(function(t,e,i){return e===i}),Ls),ks=Ps("!=",(function(t,e,i){return e!==i}),(function(t,e,i,n){return!Ls(0,e,i,n)})),Ds=Ps("",(function(t,e,i){return e>i}),(function(t,e,i,n){return n.compare(e,i)>0})),Rs=Ps("=",(function(t,e,i){return e>=i}),(function(t,e,i,n){return n.compare(e,i)>=0}));class Bs{constructor(t,e,i,n,r,o){this.type=Kn,this.number=t,this.locale=e,this.currency=i,this.unit=n,this.minFractionDigits=r,this.maxFractionDigits=o}static parse(t,e){if(3!==t.length)return e.error("Expected two arguments.");const i=e.parse(t[1],1,Xn);if(!i)return null;const n=t[2];if("object"!=typeof n||Array.isArray(n))return e.error("NumberFormat options argument must be an object.");let r=null;if(n.locale&&(r=e.parse(n.locale,1,Kn),!r))return null;let o=null;if(n.currency&&(o=e.parse(n.currency,1,Kn),!o))return null;let s=null;if(n.unit&&(s=e.parse(n.unit,1,Kn),!s))return null;let a=null;if(n["min-fraction-digits"]&&(a=e.parse(n["min-fraction-digits"],1,Xn),!a))return null;let l=null;return n["max-fraction-digits"]&&(l=e.parse(n["max-fraction-digits"],1,Xn),!l)?null:new Bs(i,r,o,s,a,l)}evaluate(t){return new Intl.NumberFormat(this.locale?this.locale.evaluate(t):[],{style:(this.currency?"currency":this.unit&&"unit")||"decimal",currency:this.currency?this.currency.evaluate(t):void 0,unit:this.unit?this.unit.evaluate(t):void 0,minimumFractionDigits:this.minFractionDigits?this.minFractionDigits.evaluate(t):void 0,maximumFractionDigits:this.maxFractionDigits?this.maxFractionDigits.evaluate(t):void 0}).format(this.number.evaluate(t))}eachChild(t){t(this.number),this.locale&&t(this.locale),this.currency&&t(this.currency),this.unit&&t(this.unit),this.minFractionDigits&&t(this.minFractionDigits),this.maxFractionDigits&&t(this.maxFractionDigits)}outputDefined(){return!1}serialize(){const t={};return this.locale&&(t.locale=this.locale.serialize()),this.currency&&(t.currency=this.currency.serialize()),this.unit&&(t.unit=this.unit.serialize()),this.minFractionDigits&&(t["min-fraction-digits"]=this.minFractionDigits.serialize()),this.maxFractionDigits&&(t["max-fraction-digits"]=this.maxFractionDigits.serialize()),["number-format",this.number.serialize(),t]}}class Fs{constructor(t){this.type=Xn,this.input=t}static parse(t,e){if(2!==t.length)return e.error(`Expected 1 argument, but found ${t.length-1} instead.`);const i=e.parse(t[1],1);return i?"array"!==i.type.kind&&"string"!==i.type.kind&&"value"!==i.type.kind?e.error(`Expected argument of type string or array, but found ${sr(i.type)} instead.`):new Fs(i):null}evaluate(t){const e=this.input.evaluate(t);if("string"==typeof e)return e.length;if(Array.isArray(e))return e.length;throw new xr(`Expected value to be of type string or array, but found ${sr(gr(e))} instead.`)}eachChild(t){t(this.input)}outputDefined(){return!1}serialize(){const t=["length"];return this.eachChild((e=>{t.push(e.serialize())})),t}}function Ns(t){return function(){t=1831565813+(t|=0)|0;let e=Math.imul(t^t>>>15,1|t);return e=e+Math.imul(e^e>>>7,61|e)^e,((e^e>>>14)>>>0)/4294967296}}const Us={"==":$s,"!=":ks,">":zs,"=":Os,"=0&&t=0&&e=0&&i=0&&n-1}function Xs(t){return"data-driven"===t["property-type"]}function Ks(t){return Ys(t.expression,"measure-light")}function Js(t){return Ys(t.expression,"zoom")}function Qs(t){return!!t.expression&&t.expression.interpolated}function ta(t){return"object"==typeof t&&null!==t&&!Array.isArray(t)}function ea(t){return t}function ia(t,e){const i="color"===e.type,n=t.stops&&"object"==typeof t.stops[0][0],r=n||!(n||void 0!==t.property),o=t.type||(Qs(e)?"exponential":"interval");if(i&&((t=qn({},t)).stops&&(t.stops=t.stops.map((t=>[t[0],Un.parse(t[1])]))),t.default=Un.parse(t.default?t.default:e.default)),t.colorSpace&&"rgb"!==t.colorSpace&&!ys[t.colorSpace])throw new Error(`Unknown color space: ${t.colorSpace}`);let s,a,l;if("exponential"===o)s=sa;else if("interval"===o)s=oa;else if("categorical"===o){s=ra,a=Object.create(null);for(const e of t.stops)a[e[0]]=e[1];l=typeof t.stops[0][0]}else{if("identity"!==o)throw new Error(`Unknown function type "${o}"`);s=aa}if(n){const i={},n=[];for(let e=0;et[0])),evaluate:({zoom:i},n)=>sa({stops:r,base:t.base},e,i).evaluate(i,n)}}if(r){const i="exponential"===o?{name:"exponential",base:void 0!==t.base?t.base:1}:null;return{kind:"camera",interpolationType:i,interpolationFactor:vs.interpolationFactor.bind(void 0,i),zoomStops:t.stops.map((t=>t[0])),evaluate:({zoom:i})=>s(t,e,i,a,l)}}return{kind:"source",evaluate(i,n){const r=n&&n.properties?n.properties[t.property]:void 0;return void 0===r?na(t.default,e.default):s(t,e,r,a,l)}}}function na(t,e,i){return void 0!==t?t:void 0!==e?e:void 0!==i?i:void 0}function ra(t,e,i,n,r){return na(typeof i===r?n[i]:void 0,t.default,e.default)}function oa(t,e,i){if("number"!==Er(i))return na(t.default,e.default);const n=t.stops.length;if(1===n)return t.stops[0][1];if(i=t.stops[n-1][0])return t.stops[n-1][1];const r=Qo(t.stops.map((t=>t[0])),i);return t.stops[r][1]}function sa(t,e,i){const n=void 0!==t.base?t.base:1;if("number"!==Er(i))return na(t.default,e.default);const r=t.stops.length;if(1===r)return t.stops[0][1];if(i=t.stops[r-1][0])return t.stops[r-1][1];const o=Qo(t.stops.map((t=>t[0])),i),s=function(t,e,i,n){const r=n-i,o=t-i;return 0===r?0:1===e?o/r:(Math.pow(e,o)-1)/(Math.pow(e,r)-1)}(i,n,t.stops[o][0],t.stops[o+1][0]),a=t.stops[o][1],l=t.stops[o+1][1];let c=Zn[e.type]||ea;if(t.colorSpace&&"rgb"!==t.colorSpace){const e=ys[t.colorSpace];c=(t,i)=>e.reverse(e.interpolate(e.forward(t),e.forward(i),s))}return"function"==typeof a.evaluate?{evaluate(...t){const e=a.evaluate.apply(void 0,t),i=l.evaluate.apply(void 0,t);if(void 0!==e&&void 0!==i)return c(e,i,s)}}:c(a,l,s)}function aa(t,e,i){return"color"===e.type?i=Un.parse(i):"formatted"===e.type?i=pr.fromString(i.toString()):"resolvedImage"===e.type?i=fr.fromString(i.toString()):Er(i)===e.type||"enum"===e.type&&e.values[i]||(i=void 0),na(i,t.default,e.default)}Lr.register(Us,{error:[{kind:"error"},[Kn],(t,[e])=>{throw new xr(e.evaluate(t))}],typeof:[Kn,[er],(t,[e])=>sr(gr(e.evaluate(t)))],"to-rgba":[or(Xn,4),[Qn],(t,[e])=>e.evaluate(t).toRenderColor(null).toArray()],rgb:[Qn,[Xn,Xn,Xn],js],rgba:[Qn,[Xn,Xn,Xn,Xn],js],hsl:[Qn,[Xn,Xn,Xn],Vs],hsla:[Qn,[Xn,Xn,Xn,Xn],Vs],has:{type:Jn,overloads:[[[Kn],(t,[e])=>Gs(e.evaluate(t),t.properties())],[[Kn,tr],(t,[e,i])=>Gs(e.evaluate(t),i.evaluate(t))]]},get:{type:er,overloads:[[[Kn],(t,[e])=>Zs(e.evaluate(t),t.properties())],[[Kn,tr],(t,[e,i])=>Zs(e.evaluate(t),i.evaluate(t))]]},"feature-state":[er,[Kn],(t,[e])=>Zs(e.evaluate(t),t.featureState||{})],properties:[tr,[],t=>t.properties()],"geometry-type":[Kn,[],t=>t.geometryType()],id:[er,[],t=>t.id()],zoom:[Xn,[],t=>t.globals.zoom],pitch:[Xn,[],t=>t.globals.pitch||0],"distance-from-center":[Xn,[],t=>t.distanceFromCenter()],"measure-light":[Xn,[Kn],(t,[e])=>t.measureLight(e.evaluate(t))],"heatmap-density":[Xn,[],t=>t.globals.heatmapDensity||0],"line-progress":[Xn,[],t=>t.globals.lineProgress||0],"raster-value":[Xn,[],t=>t.globals.rasterValue||0],"raster-particle-speed":[Xn,[],t=>t.globals.rasterParticleSpeed||0],"sky-radial-progress":[Xn,[],t=>t.globals.skyRadialProgress||0],accumulated:[er,[],t=>void 0===t.globals.accumulated?null:t.globals.accumulated],"+":[Xn,qs(Xn),(t,e)=>{let i=0;for(const n of e)i+=n.evaluate(t);return i}],"*":[Xn,qs(Xn),(t,e)=>{let i=1;for(const n of e)i*=n.evaluate(t);return i}],"-":{type:Xn,overloads:[[[Xn,Xn],(t,[e,i])=>e.evaluate(t)-i.evaluate(t)],[[Xn],(t,[e])=>-e.evaluate(t)]]},"/":[Xn,[Xn,Xn],(t,[e,i])=>e.evaluate(t)/i.evaluate(t)],"%":[Xn,[Xn,Xn],(t,[e,i])=>e.evaluate(t)%i.evaluate(t)],ln2:[Xn,[],()=>Math.LN2],pi:[Xn,[],()=>Math.PI],e:[Xn,[],()=>Math.E],"^":[Xn,[Xn,Xn],(t,[e,i])=>Math.pow(e.evaluate(t),i.evaluate(t))],sqrt:[Xn,[Xn],(t,[e])=>Math.sqrt(e.evaluate(t))],log10:[Xn,[Xn],(t,[e])=>Math.log(e.evaluate(t))/Math.LN10],ln:[Xn,[Xn],(t,[e])=>Math.log(e.evaluate(t))],log2:[Xn,[Xn],(t,[e])=>Math.log(e.evaluate(t))/Math.LN2],sin:[Xn,[Xn],(t,[e])=>Math.sin(e.evaluate(t))],cos:[Xn,[Xn],(t,[e])=>Math.cos(e.evaluate(t))],tan:[Xn,[Xn],(t,[e])=>Math.tan(e.evaluate(t))],asin:[Xn,[Xn],(t,[e])=>Math.asin(e.evaluate(t))],acos:[Xn,[Xn],(t,[e])=>Math.acos(e.evaluate(t))],atan:[Xn,[Xn],(t,[e])=>Math.atan(e.evaluate(t))],min:[Xn,qs(Xn),(t,e)=>Math.min(...e.map((e=>e.evaluate(t))))],max:[Xn,qs(Xn),(t,e)=>Math.max(...e.map((e=>e.evaluate(t))))],abs:[Xn,[Xn],(t,[e])=>Math.abs(e.evaluate(t))],round:[Xn,[Xn],(t,[e])=>{const i=e.evaluate(t);return iMath.floor(e.evaluate(t))],ceil:[Xn,[Xn],(t,[e])=>Math.ceil(e.evaluate(t))],"filter-==":[Jn,[Kn,er],(t,[e,i])=>t.properties()[e.value]===i.value],"filter-id-==":[Jn,[er],(t,[e])=>t.id()===e.value],"filter-type-==":[Jn,[Kn],(t,[e])=>t.geometryType()===e.value],"filter-{const n=t.properties()[e.value],r=i.value;return typeof n==typeof r&&n{const i=t.id(),n=e.value;return typeof i==typeof n&&i":[Jn,[Kn,er],(t,[e,i])=>{const n=t.properties()[e.value],r=i.value;return typeof n==typeof r&&n>r}],"filter-id->":[Jn,[er],(t,[e])=>{const i=t.id(),n=e.value;return typeof i==typeof n&&i>n}],"filter-{const n=t.properties()[e.value],r=i.value;return typeof n==typeof r&&n{const i=t.id(),n=e.value;return typeof i==typeof n&&i=":[Jn,[Kn,er],(t,[e,i])=>{const n=t.properties()[e.value],r=i.value;return typeof n==typeof r&&n>=r}],"filter-id->=":[Jn,[er],(t,[e])=>{const i=t.id(),n=e.value;return typeof i==typeof n&&i>=n}],"filter-has":[Jn,[er],(t,[e])=>e.value in t.properties()],"filter-has-id":[Jn,[],t=>null!==t.id()&&void 0!==t.id()],"filter-type-in":[Jn,[or(Kn)],(t,[e])=>e.value.indexOf(t.geometryType())>=0],"filter-id-in":[Jn,[or(er)],(t,[e])=>e.value.indexOf(t.id())>=0],"filter-in-small":[Jn,[Kn,or(er)],(t,[e,i])=>i.value.indexOf(t.properties()[e.value])>=0],"filter-in-large":[Jn,[Kn,or(er)],(t,[e,i])=>function(t,e,i,n){for(;i>1;if(e[r]===t)return!0;e[r]>t?n=r-1:i=r+1}return!1}(t.properties()[e.value],i.value,0,i.value.length-1)],all:{type:Jn,overloads:[[[Jn,Jn],(t,[e,i])=>e.evaluate(t)&&i.evaluate(t)],[qs(Jn),(t,e)=>{for(const i of e)if(!i.evaluate(t))return!1;return!0}]]},any:{type:Jn,overloads:[[[Jn,Jn],(t,[e,i])=>e.evaluate(t)||i.evaluate(t)],[qs(Jn),(t,e)=>{for(const i of e)if(i.evaluate(t))return!0;return!1}]]},"!":[Jn,[Jn],(t,[e])=>!e.evaluate(t)],"is-supported-script":[Jn,[Kn],(t,[e])=>{const i=t.globals&&t.globals.isSupportedScript;return!i||i(e.evaluate(t))}],upcase:[Kn,[Kn],(t,[e])=>e.evaluate(t).toUpperCase()],downcase:[Kn,[Kn],(t,[e])=>e.evaluate(t).toLowerCase()],concat:[Kn,qs(er),(t,e)=>e.map((e=>yr(e.evaluate(t)))).join("")],"resolved-locale":[Kn,[ir],(t,[e])=>e.evaluate(t).resolvedLocale()],random:[Xn,[Xn,Xn,er],(t,e)=>{const[i,n,r]=e.map((e=>e.evaluate(t)));if(i>n)return i;if(i===n)return i;let o;if("string"==typeof r)o=function(t){let e=0;if(0===t.length)return e;for(let i=0;iJSON.stringify(t))).join(", ")}, but found ${JSON.stringify(t)} instead.`);return t}catch(t){return this._warningHistory[t.message]||(this._warningHistory[t.message]=!0,"undefined"!=typeof console&&console.warn(t.message)),this._defaultValue}}}function ca(t){return Array.isArray(t)&&t.length>0&&"string"==typeof t[0]&&t[0]in Us}function da(t,e,i,n){const r=new Ko(Us,[],e?function(t){const e={color:Qn,string:Kn,number:Xn,enum:Kn,boolean:Jn,formatted:nr,resolvedImage:rr};return"array"===t.type?or(e[t.value]||er,t.length):e[t.type]}(e):void 0,void 0,void 0,i,n),o=r.parse(t,void 0,void 0,void 0,e&&"string"===e.type?{typeAnnotation:"coerce"}:void 0);return o?Hs(new la(o,e,i,n)):Ws(r.errors)}class ua{constructor(t,e,i){this.kind=t,this._styleExpression=e,this.isLightConstant=i,this.isStateDependent="constant"!==t&&!qo(e.expression),this.isConfigDependent=!Ho(e.expression)}evaluateWithoutErrorHandling(t,e,i,n,r,o){return this._styleExpression.evaluateWithoutErrorHandling(t,e,i,n,r,o)}evaluate(t,e,i,n,r,o){return this._styleExpression.evaluate(t,e,i,n,r,o)}}class ha{constructor(t,e,i,n,r){this.kind=t,this.zoomStops=i,this._styleExpression=e,this.isStateDependent="camera"!==t&&!qo(e.expression),this.isLightConstant=r,this.isConfigDependent=!Ho(e.expression),this.interpolationType=n}evaluateWithoutErrorHandling(t,e,i,n,r,o){return this._styleExpression.evaluateWithoutErrorHandling(t,e,i,n,r,o)}evaluate(t,e,i,n,r,o){return this._styleExpression.evaluate(t,e,i,n,r,o)}interpolationFactor(t,e,i){return this.interpolationType?vs.interpolationFactor(this.interpolationType,t,e,i):0}}function pa(t,e,i,n){if("error"===(t=da(t,e,i,n)).result)return t;const r=t.value.expression,o=Zo(r);if(!o&&!Xs(e))return Ws([new Hn("","data expressions not supported")]);const s=Wo(r,["zoom","pitch","distance-from-center"]);if(!s&&!Js(e))return Ws([new Hn("","zoom expressions not supported")]);const a=Wo(r,["measure-light"]);if(!a&&!Ks(e))return Ws([new Hn("","measure-light expression not supported")]);const l=e.expression&&e.expression.relaxZoomRestriction,c=ma(r);return c||s||l?c instanceof Hn?Ws([c]):c instanceof vs&&!Qs(e)?Ws([new Hn("",'"interpolate" expressions cannot be used with this property')]):Hs(c?new ha(o?"camera":"composite",t.value,c.labels,c instanceof vs?c.interpolation:void 0,a):new ua(o?"constant":"source",t.value,a)):Ws([new Hn("",'"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression, or in the properties of atmosphere.')])}class fa{constructor(t,e){this._parameters=t,this._specification=e,qn(this,ia(this._parameters,this._specification))}static deserialize(t){return new fa(t._parameters,t._specification)}static serialize(t){return{_parameters:t._parameters,_specification:t._specification}}}function ma(t){let e=null;if(t instanceof ws)e=ma(t.result);else if(t instanceof bs){for(const i of t.args)if(e=ma(i),e)break}else(t instanceof ts||t instanceof vs)&&t.input instanceof Lr&&"zoom"===t.input.name&&(e=t);return e instanceof Hn||t.eachChild((t=>{const i=ma(t);i instanceof Hn?e=i:e&&i&&e!==i&&(e=new Hn("",'Only one zoom-based "step" or "interpolate" subexpression may be used in an expression.'))})),e}var _a=ya,ga=3;function ya(t,e,i){var n=this.cells=[];if(t instanceof ArrayBuffer){this.arrayBuffer=t;var r=new Int32Array(this.arrayBuffer);t=r[0],this.d=(e=r[1])+2*(i=r[2]);for(var o=0;o=d[p+0]&&n>=d[p+1])?(s[h]=!0,o.push(c[h])):s[h]=!1}}},ya.prototype._forEachCell=function(t,e,i,n,r,o,s,a){for(var l=this._convertToCellCoord(t),c=this._convertToCellCoord(e),d=this._convertToCellCoord(i),u=this._convertToCellCoord(n),h=l;h=0||(r[i]=Sa(t[i],e)));t instanceof Error&&(r.message=t.message)}if(r.$name)throw new Error("$name property is reserved for worker serialization logic.");return"Object"!==n&&(r.$name=n),r}throw new Error("can't serialize object of type "+typeof t)}function Ea(t){if(null==t||"boolean"==typeof t||"number"==typeof t||"string"==typeof t||t instanceof Boolean||t instanceof Number||t instanceof String||t instanceof Date||t instanceof RegExp||wa(t)||Ta(t)||ArrayBuffer.isView(t)||t instanceof ImageData)return t;if(Array.isArray(t))return t.map(Ea);if("object"==typeof t){const e=t.$name||"Object";if("Map"===e){const e=new Map;for(const i of Object.keys(t))"$name"!==i&&e.set(i,Ea(t[i]));return e}const{klass:i}=xa[e];if(!i)throw new Error(`can't deserialize unregistered class ${e}`);if(i.deserialize)return i.deserialize(t);const n=Object.create(i.prototype);for(const e of Object.keys(t))"$name"!==e&&(n[e]=Ea(t[e]));return n}throw new Error("can't deserialize object of type "+typeof t)}const Ma={"Latin-1 Supplement":t=>t>=128&&tt>=1536&&tt>=1872&&tt>=2208&&tt>=4352&&tt>=5120&&tt>=6016&&tt>=6320&&tt>=8192&&tt>=8448&&tt>=8528&&tt>=8960&&tt>=9216&&tt>=9280&&tt>=9312&&tt>=9632&&tt>=9728&&tt>=11008&&tt>=11904&&tt>=12032&&tt>=12272&&tt>=12288&&tt>=12352&&tt>=12448&&tt>=12544&&tt>=12592&&tt>=12688&&tt>=12704&&tt>=12736&&tt>=12784&&tt>=12800&&tt>=13056&&tt>=13312&&tt>=19904&&tt>=19968&&tt>=40960&&tt>=42128&&tt>=43360&&tt>=44032&&tt>=55216&&tt>=57344&&tt>=63744&&tt>=64336&&tt>=65040&&tt>=65072&&tt>=65104&&tt>=65136&&tt>=65280&&tt>=131072&&t=65097&&t=12296&&t=12308&&t=65306&&t=65371&&t=65512&&t=65112&&t=65123&&t=8960&&t=8972&&t=8996&&t=9085&&t=9150&&t=9169&&t=9186&&t=9754&&t=11026&&t=11088&&t=11192&&t=9984&&t=10102&&t=1424&&t=2304&&t=3840&&t-1&&(Fa="error"),Ba&&Ba(t)};function ja(){Va.fire(new Pn("pluginStateChange",{pluginStatus:Fa,pluginURL:Na}))}const Va=new zn,Ga=function(){return Fa},Za=function(){if(Fa!==za||!Na)throw new Error("rtl-text-plugin cannot be downloaded unless a pluginURL is specified");Fa=Ra,ja(),Na&&en({url:Na},(t=>{t?Ua(t):(Fa=Oa,ja())}))},qa={applyArabicShaping:null,processBidirectionalText:null,processStyledBidirectionalText:null,isLoaded:()=>Fa===Oa||null!=qa.applyArabicShaping,isLoading:()=>Fa===Ra,setState(t){Fa=t.pluginStatus,Na=t.pluginURL},isParsed:()=>null!=qa.applyArabicShaping&&null!=qa.processBidirectionalText&&null!=qa.processStyledBidirectionalText,getPluginURL:()=>Na};class Ha{constructor(t,e){this.zoom=t,e?(this.now=e.now,this.fadeDuration=e.fadeDuration,this.transition=e.transition,this.pitch=e.pitch,this.brightness=e.brightness):(this.now=0,this.fadeDuration=0,this.transition={},this.pitch=0,this.brightness=0)}isSupportedScript(t){return function(t,e){for(const i of t)if(!ka(i.charCodeAt(0),e))return!1;return!0}(t,qa.isLoaded())}}class Wa{constructor(t,e,i,n){this.property=t,this.value=e,this.expression=function(t,e,i,n){if(ta(t))return new fa(t,e);if(ca(t)||Array.isArray(t)&&t.length>0){const r=pa(t,e,i,n);if("error"===r.result)throw new Error(r.value.map((t=>`${t.key}: ${t.message}`)).join(", "));return r.value}{let i=t;return"string"==typeof t&&"color"===e.type&&(i=Un.parse(t)),{kind:"constant",isConfigDependent:!1,evaluate:()=>i}}}(void 0===e?t.specification.default:e,t.specification,i,n)}isDataDriven(){return"source"===this.expression.kind||"composite"===this.expression.kind}possiblyEvaluate(t,e,i){return this.property.possiblyEvaluate(this,t,e,i)}}class Ya{constructor(t,e,i){this.property=t,this.value=new Wa(t,void 0,e,i)}transitioned(t,e){return new Ka(this.property,this.value,e,ei({},t.transition,this.transition),t.now)}untransitioned(){return new Ka(this.property,this.value,null,{},0)}}class Xa{constructor(t,e,i){this._properties=t,this._values=Object.create(t.defaultTransitionablePropertyValues),this._scope=e,this._options=i,this.isConfigDependent=!1}getValue(t){return ui(this._values[t].value.value)}setValue(t,e){this._values.hasOwnProperty(t)||(this._values[t]=new Ya(this._values[t].property,this._scope,this._options)),this._values[t].value=new Wa(this._values[t].property,null===e?void 0:ui(e),this._scope,this._options),this.isConfigDependent=this.isConfigDependent||this._values[t].value.expression.isConfigDependent}setTransitionOrValue(t,e){e&&(this._options=e);const i=this._properties.properties;if(t)for(const e in t){const n=t[e];if(li(e,"-transition")){const t=e.slice(0,-11);i[t]&&this.setTransition(t,n)}else i.hasOwnProperty(e)&&this.setValue(e,n)}}getTransition(t){return ui(this._values[t].transition)}setTransition(t,e){this._values.hasOwnProperty(t)||(this._values[t]=new Ya(this._values[t].property)),this._values[t].transition=ui(e)||void 0}serialize(){const t={};for(const e of Object.keys(this._values)){const i=this.getValue(e);void 0!==i&&(t[e]=i);const n=this.getTransition(e);void 0!==n&&(t[`${e}-transition`]=n)}return t}transitioned(t,e){const i=new Ja(this._properties);for(const n of Object.keys(this._values))i._values[n]=this._values[n].transitioned(t,e._values[n]);return i}untransitioned(){const t=new Ja(this._properties);for(const e of Object.keys(this._values))t._values[e]=this._values[e].untransitioned();return t}}class Ka{constructor(t,e,i,n,r){const o=n.delay||0,s=n.duration||0;r=r||0,this.property=t,this.value=e,this.begin=r+o,this.end=this.begin+s,t.specification.transition&&(n.delay||n.duration)&&(this.prior=i)}possiblyEvaluate(t,e,i){const n=t.now||0,r=this.value.possiblyEvaluate(t,e,i),o=this.prior;if(o){if(n>this.end)return this.prior=null,r;if(this.value.isDataDriven())return this.prior=null,r;if(n":1,">=":1,"=2&&"$id"!==t[1]&&"$type"!==t[1];case"in":return t.length>=3&&("string"!=typeof t[1]||Array.isArray(t[2]));case"!in":case"!has":case"none":return!1;case"==":case"!=":case">":case">=":case"!0,needGeometry:!1,needFeature:!1};cl(t)||(t=gl(t));const i=t;let n=!0;try{n=function(t){if(!pl(t))return t;let e=ll(t);return hl(e),e=ul(e),e}(i)}catch(t){console.warn(`Failed to extract static filter. Filter will continue working, but at higher memory usage and slower framerate.\nThis is most likely a bug, please report this via https://github.com/mapbox/mapbox-gl-js/issues/new?assignees=&labels=&template=Bug_report.md\nand paste the contents of this message in the report.\nThank you!\nFilter Expression:\n${JSON.stringify(i,null,2)}\n `)}const r=sl[`filter_${e}`],o=da(n,r);let s=null;if("error"===o.result)throw new Error(o.value.map((t=>`${t.key}: ${t.message}`)).join(", "));s=(t,e,i)=>o.value.evaluate(t,e,{},i);let a=null,l=null;if(n!==i){const t=da(i,r);if("error"===t.result)throw new Error(t.value.map((t=>`${t.key}: ${t.message}`)).join(", "));a=(e,i,n,r,o)=>t.value.evaluate(e,i,{},n,void 0,void 0,r,o),l=!Zo(t.value.expression)}return{filter:s,dynamicFilter:a||void 0,needGeometry:_l(n),needFeature:!!l}}function ul(t){if(!Array.isArray(t))return t;const e=function(t){if(fl.has(t[0]))for(let e=1;eul(t)))}function hl(t){let e=!1;const i=[];if("case"===t[0]){for(let n=1;n",">=","e?1:0}function _l(t){if(!Array.isArray(t))return!1;if("within"===t[0]||"distance"===t[0])return!0;for(let e=1;e"===e||"="===e?yl(t[1],t[2],e):"any"===e?(i=t.slice(1),["any"].concat(i.map(gl))):"all"===e?["all"].concat(t.slice(1).map(gl)):"none"===e?["all"].concat(t.slice(1).map(gl).map(bl)):"in"===e?vl(t[1],t.slice(2)):"!in"===e?bl(vl(t[1],t.slice(2))):"has"===e?xl(t[1]):"!has"!==e||bl(xl(t[1]));var i}function yl(t,e,i){switch(t){case"$type":return[`filter-type-${i}`,e];case"$id":return[`filter-id-${i}`,e];default:return[`filter-${i}`,t,e]}}function vl(t,e){if(0===e.length)return!1;switch(t){case"$type":return["filter-type-in",["literal",e]];case"$id":return["filter-id-in",["literal",e]];default:return e.length>200&&!e.some((t=>typeof t!=typeof e[0]))?["filter-in-large",t,["literal",e.sort(ml)]]:["filter-in-small",t,["literal",e]]}}function xl(t){switch(t){case"$type":return!0;case"$id":return["filter-has-id"];default:return["filter-has",t]}}function bl(t){return["!",t]}const wl="";function Tl(t,e){return e?`${t}${wl}${e}`:t}const Sl="-transition",El=new Set(["fill","line","background","hillshade","raster"]);class Ml extends zn{constructor(t,e,i,n,r){if(super(),this.id=t.id,this.fqid=Tl(this.id,i),this.type=t.type,this.scope=i,this.lut=n,this.options=r,this._featureFilter={filter:()=>!0,needGeometry:!1,needFeature:!1},this._filterCompiled=!1,this.isConfigDependent=!1,"custom"!==t.type&&(this.metadata=t.metadata,this.minzoom=t.minzoom,this.maxzoom=t.maxzoom,"background"!==t.type&&"sky"!==t.type&&"slot"!==t.type&&(this.source=t.source,this.sourceLayer=t["source-layer"],this.filter=t.filter),t.slot&&(this.slot=t.slot),e.layout&&(this._unevaluatedLayout=new Qa(e.layout,this.scope,r),this.isConfigDependent=this.isConfigDependent||this._unevaluatedLayout.isConfigDependent),e.paint)){this._transitionablePaint=new Xa(e.paint,this.scope,r);for(const e in t.paint)this.setPaintProperty(e,t.paint[e]);for(const e in t.layout)this.setLayoutProperty(e,t.layout[e]);this.isConfigDependent=this.isConfigDependent||this._transitionablePaint.isConfigDependent,this._transitioningPaint=this._transitionablePaint.untransitioned(),this.paint=new el(e.paint)}}onAdd(t){}onRemove(t){}isDraped(t){return El.has(this.type)}getLayoutProperty(t){return"visibility"===t?this.visibility:this._unevaluatedLayout.getValue(t)}setLayoutProperty(t,e){if("custom"===this.type&&"visibility"===t)return void(this.visibility=e);const i=this._unevaluatedLayout;i._properties.properties[t]&&(i.setValue(t,e),this.isConfigDependent=this.isConfigDependent||i.isConfigDependent,"visibility"===t&&this.possiblyEvaluateVisibility())}possiblyEvaluateVisibility(){this.visibility=this._unevaluatedLayout._values.visibility.possiblyEvaluate({zoom:0})}getPaintProperty(t){return li(t,Sl)?this._transitionablePaint.getTransition(t.slice(0,-11)):this._transitionablePaint.getValue(t)}setPaintProperty(t,e){const i=this._transitionablePaint,n=i._properties.properties;if(li(t,Sl)){const r=t.slice(0,-11);return n[r]&&i.setTransition(r,e||void 0),!1}if(!n[t])return!1;const r=i._values[t],o=r.value.isDataDriven(),s=r.value;i.setValue(t,e),this.isConfigDependent=this.isConfigDependent||i.isConfigDependent,this._handleSpecialPaintPropertyUpdate(t);const a=i._values[t].value,l=a.isDataDriven(),c=li(t,"pattern")||"line-dasharray"===t;return l||o||c||this._handleOverridablePaintPropertyUpdate(t,s,a)}_handleSpecialPaintPropertyUpdate(t){}getProgramIds(){return null}getDefaultProgramParams(t,e,i){return null}_handleOverridablePaintPropertyUpdate(t,e,i){return!1}isHidden(t){return!!(this.minzoom&&t=this.maxzoom)||"none"===this.visibility}updateTransitions(t){this._transitioningPaint=this._transitionablePaint.transitioned(t,this._transitioningPaint)}hasTransition(){return this._transitioningPaint.hasTransition()}recalculate(t,e){this._unevaluatedLayout&&(this.layout=this._unevaluatedLayout.possiblyEvaluate(t,void 0,e)),this.paint=this._transitioningPaint.possiblyEvaluate(t,void 0,e)}serialize(){return di({id:this.id,type:this.type,slot:this.slot,source:this.source,"source-layer":this.sourceLayer,metadata:this.metadata,minzoom:this.minzoom,maxzoom:this.maxzoom,filter:this.filter,layout:this._unevaluatedLayout&&this._unevaluatedLayout.serialize(),paint:this._transitionablePaint&&this._transitionablePaint.serialize()},((t,e)=>!(void 0===t||"layout"===e&&!Object.keys(t).length||"paint"===e&&!Object.keys(t).length)))}is3D(){return!1}isSky(){return!1}isTileClipped(){return!1}hasOffscreenPass(){return!1}hasShadowPass(){return!1}canCastShadows(){return!1}hasLightBeamPass(){return!1}cutoffRange(){return 0}tileCoverLift(){return 0}resize(){}isStateDependent(){for(const t in this.paint._values){const e=this.paint.get(t);if(e instanceof tl&&Xs(e.property.specification)&&("source"===e.value.kind||"composite"===e.value.kind)&&e.value.isStateDependent)return!0}return!1}compileFilter(){this._filterCompiled||(this._featureFilter=dl(this.filter),this._filterCompiled=!0)}invalidateCompiledFilter(){this._filterCompiled=!1}dynamicFilter(){return this._featureFilter.dynamicFilter}dynamicFilterNeedsFeature(){return this._featureFilter.needFeature}getLayerRenderingStats(){return this._stats}resetLayerRenderingStats(t){this._stats&&("shadow"===t.renderPass?this._stats.numRenderedVerticesInShadowPass=0:this._stats.numRenderedVerticesInTransparentPass=0)}queryRadius(t){}queryIntersectsFeature(t,e,i,n,r,o,s,a,l){}queryIntersectsMatchingFeature(t,e,i,n){}}const Cl={Int8:Int8Array,Uint8:Uint8Array,Int16:Int16Array,Uint16:Uint16Array,Int32:Int32Array,Uint32:Uint32Array,Float32:Float32Array};class Al{constructor(t,e){this._structArray=t,this._pos1=e*this.size,this._pos2=this._pos1/2,this._pos4=this._pos1/4,this._pos8=this._pos1/8}}class Il{constructor(){this.isTransferred=!1,this.capacity=-1,this.resize(0)}static serialize(t,e){return t._trim(),e&&(t.isTransferred=!0,e.add(t.arrayBuffer)),{length:t.length,arrayBuffer:t.arrayBuffer}}static deserialize(t){const e=Object.create(this.prototype);return e.arrayBuffer=t.arrayBuffer,e.length=t.length,e.capacity=t.arrayBuffer.byteLength/e.bytesPerElement,e._refreshViews(),e}_trim(){this.length!==this.capacity&&(this.capacity=this.length,this.arrayBuffer=this.arrayBuffer.slice(0,this.length*this.bytesPerElement),this._refreshViews())}clear(){this.length=0}resize(t){this.reserve(t),this.length=t}reserve(t){if(t>this.capacity){this.capacity=Math.max(t,Math.floor(5*this.capacity),128),this.arrayBuffer=new ArrayBuffer(this.capacity*this.bytesPerElement);const e=this.uint8;this._refreshViews(),e&&this.uint8.set(e)}}_refreshViews(){throw new Error("StructArray#_refreshViews() must be implemented by each concrete StructArray layout")}emplace(...t){throw new Error("StructArray#emplace() must be implemented by each concrete StructArray layout")}emplaceBack(...t){throw new Error("StructArray#emplaceBack() must be implemented by each concrete StructArray layout")}destroy(){this.int8=this.uint8=this.int16=this.uint16=this.int32=this.uint32=this.float32=null,this.arrayBuffer=null}}function Ll(t,e=1){let i=0,n=0;return{members:t.map((t=>{const r=Cl[t.type].BYTES_PER_ELEMENT,o=i=Pl(i,Math.max(e,r)),s=t.components||1;return n=Math.max(n,r),i+=r*s,{name:t.name,type:t.type,components:s,offset:o}})),size:Pl(i,Math.max(n,e)),alignment:e}}function Pl(t,e){return Math.ceil(t/e)*e}class $l extends Il{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,e){const i=this.length;return this.resize(i+1),this.emplace(i,t,e)}emplace(t,e,i){const n=2*t;return this.int16[n+0]=e,this.int16[n+1]=i,t}}$l.prototype.bytesPerElement=4,ba($l,"StructArrayLayout2i4");class kl extends Il{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,e,i){const n=this.length;return this.resize(n+1),this.emplace(n,t,e,i)}emplace(t,e,i,n){const r=3*t;return this.int16[r+0]=e,this.int16[r+1]=i,this.int16[r+2]=n,t}}kl.prototype.bytesPerElement=6,ba(kl,"StructArrayLayout3i6");class Dl extends Il{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,e,i,n){const r=this.length;return this.resize(r+1),this.emplace(r,t,e,i,n)}emplace(t,e,i,n,r){const o=4*t;return this.int16[o+0]=e,this.int16[o+1]=i,this.int16[o+2]=n,this.int16[o+3]=r,t}}Dl.prototype.bytesPerElement=8,ba(Dl,"StructArrayLayout4i8");class zl extends Il{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,e,i,n,r){const o=this.length;return this.resize(o+1),this.emplace(o,t,e,i,n,r)}emplace(t,e,i,n,r,o){const s=5*t;return this.int16[s+0]=e,this.int16[s+1]=i,this.int16[s+2]=n,this.int16[s+3]=r,this.int16[s+4]=o,t}}zl.prototype.bytesPerElement=10,ba(zl,"StructArrayLayout5i10");class Rl extends Il{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t,e,i,n,r,o,s){const a=this.length;return this.resize(a+1),this.emplace(a,t,e,i,n,r,o,s)}emplace(t,e,i,n,r,o,s,a){const l=6*t,c=12*t,d=3*t;return this.int16[l+0]=e,this.int16[l+1]=i,this.uint8[c+4]=n,this.uint8[c+5]=r,this.uint8[c+6]=o,this.uint8[c+7]=s,this.float32[d+2]=a,t}}Rl.prototype.bytesPerElement=12,ba(Rl,"StructArrayLayout2i4ub1f12");class Ol extends Il{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t,e,i,n){const r=this.length;return this.resize(r+1),this.emplace(r,t,e,i,n)}emplace(t,e,i,n,r){const o=4*t;return this.float32[o+0]=e,this.float32[o+1]=i,this.float32[o+2]=n,this.float32[o+3]=r,t}}Ol.prototype.bytesPerElement=16,ba(Ol,"StructArrayLayout4f16");class Bl extends Il{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t,e,i){const n=this.length;return this.resize(n+1),this.emplace(n,t,e,i)}emplace(t,e,i,n){const r=3*t;return this.float32[r+0]=e,this.float32[r+1]=i,this.float32[r+2]=n,t}}Bl.prototype.bytesPerElement=12,ba(Bl,"StructArrayLayout3f12");class Fl extends Il{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t,e,i,n,r){const o=this.length;return this.resize(o+1),this.emplace(o,t,e,i,n,r)}emplace(t,e,i,n,r,o){const s=6*t,a=3*t;return this.uint16[s+0]=e,this.uint16[s+1]=i,this.uint16[s+2]=n,this.uint16[s+3]=r,this.float32[a+2]=o,t}}Fl.prototype.bytesPerElement=12,ba(Fl,"StructArrayLayout4ui1f12");class Nl extends Il{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(t,e,i,n){const r=this.length;return this.resize(r+1),this.emplace(r,t,e,i,n)}emplace(t,e,i,n,r){const o=4*t;return this.uint16[o+0]=e,this.uint16[o+1]=i,this.uint16[o+2]=n,this.uint16[o+3]=r,t}}Nl.prototype.bytesPerElement=8,ba(Nl,"StructArrayLayout4ui8");class Ul extends Il{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,e,i,n,r,o){const s=this.length;return this.resize(s+1),this.emplace(s,t,e,i,n,r,o)}emplace(t,e,i,n,r,o,s){const a=6*t;return this.int16[a+0]=e,this.int16[a+1]=i,this.int16[a+2]=n,this.int16[a+3]=r,this.int16[a+4]=o,this.int16[a+5]=s,t}}Ul.prototype.bytesPerElement=12,ba(Ul,"StructArrayLayout6i12");class jl extends Il{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(t,e,i,n,r,o,s,a,l,c,d,u){const h=this.length;return this.resize(h+1),this.emplace(h,t,e,i,n,r,o,s,a,l,c,d,u)}emplace(t,e,i,n,r,o,s,a,l,c,d,u,h){const p=12*t;return this.int16[p+0]=e,this.int16[p+1]=i,this.int16[p+2]=n,this.int16[p+3]=r,this.uint16[p+4]=o,this.uint16[p+5]=s,this.uint16[p+6]=a,this.uint16[p+7]=l,this.int16[p+8]=c,this.int16[p+9]=d,this.int16[p+10]=u,this.int16[p+11]=h,t}}jl.prototype.bytesPerElement=24,ba(jl,"StructArrayLayout4i4ui4i24");class Vl extends Il{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t,e,i,n,r,o){const s=this.length;return this.resize(s+1),this.emplace(s,t,e,i,n,r,o)}emplace(t,e,i,n,r,o,s){const a=10*t,l=5*t;return this.int16[a+0]=e,this.int16[a+1]=i,this.int16[a+2]=n,this.float32[l+2]=r,this.float32[l+3]=o,this.float32[l+4]=s,t}}Vl.prototype.bytesPerElement=20,ba(Vl,"StructArrayLayout3i3f20");class Gl extends Il{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer)}emplaceBack(t){const e=this.length;return this.resize(e+1),this.emplace(e,t)}emplace(t,e){return this.uint32[1*t+0]=e,t}}Gl.prototype.bytesPerElement=4,ba(Gl,"StructArrayLayout1ul4");class Zl extends Il{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t){const e=this.length;return this.resize(e+1),this.emplace(e,t)}emplace(t,e){return this.float32[1*t+0]=e,t}}Zl.prototype.bytesPerElement=4,ba(Zl,"StructArrayLayout1f4");class ql extends Il{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(t,e){const i=this.length;return this.resize(i+1),this.emplace(i,t,e)}emplace(t,e,i){const n=2*t;return this.uint16[n+0]=e,this.uint16[n+1]=i,t}}ql.prototype.bytesPerElement=4,ba(ql,"StructArrayLayout2ui4");class Hl extends Il{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(t,e,i,n,r,o,s,a,l,c,d,u,h){const p=this.length;return this.resize(p+1),this.emplace(p,t,e,i,n,r,o,s,a,l,c,d,u,h)}emplace(t,e,i,n,r,o,s,a,l,c,d,u,h,p){const f=20*t,m=10*t;return this.int16[f+0]=e,this.int16[f+1]=i,this.int16[f+2]=n,this.int16[f+3]=r,this.int16[f+4]=o,this.float32[m+3]=s,this.float32[m+4]=a,this.float32[m+5]=l,this.float32[m+6]=c,this.int16[f+14]=d,this.uint32[m+8]=u,this.uint16[f+18]=h,this.uint16[f+19]=p,t}}Hl.prototype.bytesPerElement=40,ba(Hl,"StructArrayLayout5i4f1i1ul2ui40");class Wl extends Il{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,e,i,n,r,o,s){const a=this.length;return this.resize(a+1),this.emplace(a,t,e,i,n,r,o,s)}emplace(t,e,i,n,r,o,s,a){const l=8*t;return this.int16[l+0]=e,this.int16[l+1]=i,this.int16[l+2]=n,this.int16[l+4]=r,this.int16[l+5]=o,this.int16[l+6]=s,this.int16[l+7]=a,t}}Wl.prototype.bytesPerElement=16,ba(Wl,"StructArrayLayout3i2i2i16");class Yl extends Il{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,e,i,n,r){const o=this.length;return this.resize(o+1),this.emplace(o,t,e,i,n,r)}emplace(t,e,i,n,r,o){const s=4*t,a=8*t;return this.float32[s+0]=e,this.float32[s+1]=i,this.float32[s+2]=n,this.int16[a+6]=r,this.int16[a+7]=o,t}}Yl.prototype.bytesPerElement=16,ba(Yl,"StructArrayLayout2f1f2i16");class Xl extends Il{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t,e,i,n){const r=this.length;return this.resize(r+1),this.emplace(r,t,e,i,n)}emplace(t,e,i,n,r){const o=12*t,s=3*t;return this.uint8[o+0]=e,this.uint8[o+1]=i,this.float32[s+1]=n,this.float32[s+2]=r,t}}Xl.prototype.bytesPerElement=12,ba(Xl,"StructArrayLayout2ub2f12");class Kl extends Il{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(t,e,i){const n=this.length;return this.resize(n+1),this.emplace(n,t,e,i)}emplace(t,e,i,n){const r=3*t;return this.uint16[r+0]=e,this.uint16[r+1]=i,this.uint16[r+2]=n,t}}Kl.prototype.bytesPerElement=6,ba(Kl,"StructArrayLayout3ui6");class Jl extends Il{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer)}emplaceBack(t,e,i,n,r,o,s,a,l,c,d,u,h,p,f,m,_,g,y,v,x){const b=this.length;return this.resize(b+1),this.emplace(b,t,e,i,n,r,o,s,a,l,c,d,u,h,p,f,m,_,g,y,v,x)}emplace(t,e,i,n,r,o,s,a,l,c,d,u,h,p,f,m,_,g,y,v,x,b){const w=30*t,T=15*t,S=60*t;return this.int16[w+0]=e,this.int16[w+1]=i,this.int16[w+2]=n,this.float32[T+2]=r,this.float32[T+3]=o,this.uint16[w+8]=s,this.uint16[w+9]=a,this.uint32[T+5]=l,this.uint32[T+6]=c,this.uint32[T+7]=d,this.uint16[w+16]=u,this.uint16[w+17]=h,this.uint16[w+18]=p,this.float32[T+10]=f,this.float32[T+11]=m,this.uint8[S+48]=_,this.uint8[S+49]=g,this.uint8[S+50]=y,this.uint32[T+13]=v,this.int16[w+28]=x,this.uint8[S+58]=b,t}}Jl.prototype.bytesPerElement=60,ba(Jl,"StructArrayLayout3i2f2ui3ul3ui2f3ub1ul1i1ub60");class Ql extends Il{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer)}emplaceBack(t,e,i,n,r,o,s,a,l,c,d,u,h,p,f,m,_,g,y,v,x,b,w,T,S,E,M,C,A,I,L,P,$,k){const D=this.length;return this.resize(D+1),this.emplace(D,t,e,i,n,r,o,s,a,l,c,d,u,h,p,f,m,_,g,y,v,x,b,w,T,S,E,M,C,A,I,L,P,$,k)}emplace(t,e,i,n,r,o,s,a,l,c,d,u,h,p,f,m,_,g,y,v,x,b,w,T,S,E,M,C,A,I,L,P,$,k,D){const z=22*t,R=44*t,O=88*t;return this.float32[z+0]=e,this.float32[z+1]=i,this.int16[R+4]=n,this.int16[R+5]=r,this.int16[R+6]=o,this.int16[R+7]=s,this.int16[R+8]=a,this.int16[R+9]=l,this.int16[R+10]=c,this.int16[R+11]=d,this.int16[R+12]=u,this.uint16[R+13]=h,this.uint16[R+14]=p,this.uint16[R+15]=f,this.uint16[R+16]=m,this.uint16[R+17]=_,this.uint16[R+18]=g,this.uint16[R+19]=y,this.uint16[R+20]=v,this.uint16[R+21]=x,this.uint16[R+22]=b,this.uint16[R+23]=w,this.uint16[R+24]=T,this.uint16[R+25]=S,this.uint16[R+26]=E,this.uint16[R+27]=M,this.uint32[z+14]=C,this.float32[z+15]=A,this.float32[z+16]=I,this.float32[z+17]=L,this.float32[z+18]=P,this.float32[z+19]=$,this.float32[z+20]=k,this.uint8[O+84]=D,t}}Ql.prototype.bytesPerElement=88,ba(Ql,"StructArrayLayout2f9i15ui1ul6f1ub88");class tc extends Il{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t,e,i,n,r){const o=this.length;return this.resize(o+1),this.emplace(o,t,e,i,n,r)}emplace(t,e,i,n,r,o){const s=5*t;return this.float32[s+0]=e,this.float32[s+1]=i,this.float32[s+2]=n,this.float32[s+3]=r,this.float32[s+4]=o,t}}tc.prototype.bytesPerElement=20,ba(tc,"StructArrayLayout5f20");class ec extends Il{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t,e,i,n,r,o,s){const a=this.length;return this.resize(a+1),this.emplace(a,t,e,i,n,r,o,s)}emplace(t,e,i,n,r,o,s,a){const l=7*t;return this.float32[l+0]=e,this.float32[l+1]=i,this.float32[l+2]=n,this.float32[l+3]=r,this.float32[l+4]=o,this.float32[l+5]=s,this.float32[l+6]=a,t}}ec.prototype.bytesPerElement=28,ba(ec,"StructArrayLayout7f28");class ic extends Il{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t,e){const i=this.length;return this.resize(i+1),this.emplace(i,t,e)}emplace(t,e,i){const n=2*t;return this.float32[n+0]=e,this.float32[n+1]=i,t}}ic.prototype.bytesPerElement=8,ba(ic,"StructArrayLayout2f8");class nc extends Il{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(t,e,i,n){const r=this.length;return this.resize(r+1),this.emplace(r,t,e,i,n)}emplace(t,e,i,n,r){const o=6*t;return this.uint32[3*t+0]=e,this.uint16[o+2]=i,this.uint16[o+3]=n,this.uint16[o+4]=r,t}}nc.prototype.bytesPerElement=12,ba(nc,"StructArrayLayout1ul3ui12");class rc extends Il{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(t){const e=this.length;return this.resize(e+1),this.emplace(e,t)}emplace(t,e){return this.uint16[1*t+0]=e,t}}rc.prototype.bytesPerElement=2,ba(rc,"StructArrayLayout1ui2");class oc extends Il{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t,e,i,n,r,o,s,a,l,c,d,u,h,p,f,m){const _=this.length;return this.resize(_+1),this.emplace(_,t,e,i,n,r,o,s,a,l,c,d,u,h,p,f,m)}emplace(t,e,i,n,r,o,s,a,l,c,d,u,h,p,f,m,_){const g=16*t;return this.float32[g+0]=e,this.float32[g+1]=i,this.float32[g+2]=n,this.float32[g+3]=r,this.float32[g+4]=o,this.float32[g+5]=s,this.float32[g+6]=a,this.float32[g+7]=l,this.float32[g+8]=c,this.float32[g+9]=d,this.float32[g+10]=u,this.float32[g+11]=h,this.float32[g+12]=p,this.float32[g+13]=f,this.float32[g+14]=m,this.float32[g+15]=_,t}}oc.prototype.bytesPerElement=64,ba(oc,"StructArrayLayout16f64");class sc extends Il{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t,e,i,n,r,o,s){const a=this.length;return this.resize(a+1),this.emplace(a,t,e,i,n,r,o,s)}emplace(t,e,i,n,r,o,s,a){const l=10*t,c=5*t;return this.uint16[l+0]=e,this.uint16[l+1]=i,this.uint16[l+2]=n,this.uint16[l+3]=r,this.float32[c+2]=o,this.float32[c+3]=s,this.float32[c+4]=a,t}}sc.prototype.bytesPerElement=20,ba(sc,"StructArrayLayout4ui3f20");class ac extends Il{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t){const e=this.length;return this.resize(e+1),this.emplace(e,t)}emplace(t,e){return this.int16[1*t+0]=e,t}}ac.prototype.bytesPerElement=2,ba(ac,"StructArrayLayout1i2");class lc extends Il{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer)}emplaceBack(t){const e=this.length;return this.resize(e+1),this.emplace(e,t)}emplace(t,e){return this.uint8[1*t+0]=e,t}}lc.prototype.bytesPerElement=1,ba(lc,"StructArrayLayout1ub1");class cc extends Al{get projectedAnchorX(){return this._structArray.int16[this._pos2+0]}get projectedAnchorY(){return this._structArray.int16[this._pos2+1]}get projectedAnchorZ(){return this._structArray.int16[this._pos2+2]}get tileAnchorX(){return this._structArray.int16[this._pos2+3]}get tileAnchorY(){return this._structArray.int16[this._pos2+4]}get x1(){return this._structArray.float32[this._pos4+3]}get y1(){return this._structArray.float32[this._pos4+4]}get x2(){return this._structArray.float32[this._pos4+5]}get y2(){return this._structArray.float32[this._pos4+6]}get padding(){return this._structArray.int16[this._pos2+14]}get featureIndex(){return this._structArray.uint32[this._pos4+8]}get sourceLayerIndex(){return this._structArray.uint16[this._pos2+18]}get bucketIndex(){return this._structArray.uint16[this._pos2+19]}}cc.prototype.size=40;class dc extends Hl{get(t){return new cc(this,t)}}ba(dc,"CollisionBoxArray");class uc extends Al{get projectedAnchorX(){return this._structArray.int16[this._pos2+0]}get projectedAnchorY(){return this._structArray.int16[this._pos2+1]}get projectedAnchorZ(){return this._structArray.int16[this._pos2+2]}get tileAnchorX(){return this._structArray.float32[this._pos4+2]}get tileAnchorY(){return this._structArray.float32[this._pos4+3]}get glyphStartIndex(){return this._structArray.uint16[this._pos2+8]}get numGlyphs(){return this._structArray.uint16[this._pos2+9]}get vertexStartIndex(){return this._structArray.uint32[this._pos4+5]}get lineStartIndex(){return this._structArray.uint32[this._pos4+6]}get lineLength(){return this._structArray.uint32[this._pos4+7]}get segment(){return this._structArray.uint16[this._pos2+16]}get lowerSize(){return this._structArray.uint16[this._pos2+17]}get upperSize(){return this._structArray.uint16[this._pos2+18]}get lineOffsetX(){return this._structArray.float32[this._pos4+10]}get lineOffsetY(){return this._structArray.float32[this._pos4+11]}get writingMode(){return this._structArray.uint8[this._pos1+48]}get placedOrientation(){return this._structArray.uint8[this._pos1+49]}set placedOrientation(t){this._structArray.uint8[this._pos1+49]=t}get hidden(){return this._structArray.uint8[this._pos1+50]}set hidden(t){this._structArray.uint8[this._pos1+50]=t}get crossTileID(){return this._structArray.uint32[this._pos4+13]}set crossTileID(t){this._structArray.uint32[this._pos4+13]=t}get associatedIconIndex(){return this._structArray.int16[this._pos2+28]}get flipState(){return this._structArray.uint8[this._pos1+58]}set flipState(t){this._structArray.uint8[this._pos1+58]=t}}uc.prototype.size=60;class hc extends Jl{get(t){return new uc(this,t)}}ba(hc,"PlacedSymbolArray");class pc extends Al{get tileAnchorX(){return this._structArray.float32[this._pos4+0]}get tileAnchorY(){return this._structArray.float32[this._pos4+1]}get projectedAnchorX(){return this._structArray.int16[this._pos2+4]}get projectedAnchorY(){return this._structArray.int16[this._pos2+5]}get projectedAnchorZ(){return this._structArray.int16[this._pos2+6]}get rightJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+7]}get centerJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+8]}get leftJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+9]}get verticalPlacedTextSymbolIndex(){return this._structArray.int16[this._pos2+10]}get placedIconSymbolIndex(){return this._structArray.int16[this._pos2+11]}get verticalPlacedIconSymbolIndex(){return this._structArray.int16[this._pos2+12]}get key(){return this._structArray.uint16[this._pos2+13]}get textBoxStartIndex(){return this._structArray.uint16[this._pos2+14]}get textBoxEndIndex(){return this._structArray.uint16[this._pos2+15]}get verticalTextBoxStartIndex(){return this._structArray.uint16[this._pos2+16]}get verticalTextBoxEndIndex(){return this._structArray.uint16[this._pos2+17]}get iconBoxStartIndex(){return this._structArray.uint16[this._pos2+18]}get iconBoxEndIndex(){return this._structArray.uint16[this._pos2+19]}get verticalIconBoxStartIndex(){return this._structArray.uint16[this._pos2+20]}get verticalIconBoxEndIndex(){return this._structArray.uint16[this._pos2+21]}get featureIndex(){return this._structArray.uint16[this._pos2+22]}get numHorizontalGlyphVertices(){return this._structArray.uint16[this._pos2+23]}get numVerticalGlyphVertices(){return this._structArray.uint16[this._pos2+24]}get numIconVertices(){return this._structArray.uint16[this._pos2+25]}get numVerticalIconVertices(){return this._structArray.uint16[this._pos2+26]}get useRuntimeCollisionCircles(){return this._structArray.uint16[this._pos2+27]}get crossTileID(){return this._structArray.uint32[this._pos4+14]}set crossTileID(t){this._structArray.uint32[this._pos4+14]=t}get textOffset0(){return this._structArray.float32[this._pos4+15]}get textOffset1(){return this._structArray.float32[this._pos4+16]}get collisionCircleDiameter(){return this._structArray.float32[this._pos4+17]}get zOffset(){return this._structArray.float32[this._pos4+18]}set zOffset(t){this._structArray.float32[this._pos4+18]=t}get occlusionState(){return this._structArray.float32[this._pos4+19]}set occlusionState(t){this._structArray.float32[this._pos4+19]=t}get occlusionOpacity(){return this._structArray.float32[this._pos4+20]}set occlusionOpacity(t){this._structArray.float32[this._pos4+20]=t}get hasIconTextFit(){return this._structArray.uint8[this._pos1+84]}}pc.prototype.size=88;class fc extends Ql{get(t){return new pc(this,t)}}ba(fc,"SymbolInstanceArray");class mc extends Zl{getoffsetX(t){return this.float32[1*t+0]}}ba(mc,"GlyphOffsetArray");class _c extends $l{getx(t){return this.int16[2*t+0]}gety(t){return this.int16[2*t+1]}}ba(_c,"SymbolLineVertexArray");class gc extends Al{get featureIndex(){return this._structArray.uint32[this._pos4+0]}get sourceLayerIndex(){return this._structArray.uint16[this._pos2+2]}get bucketIndex(){return this._structArray.uint16[this._pos2+3]}get layoutVertexArrayOffset(){return this._structArray.uint16[this._pos2+4]}}gc.prototype.size=12;class yc extends nc{get(t){return new gc(this,t)}}ba(yc,"FeatureIndexArray");class vc extends ql{geta_centroid_pos0(t){return this.uint16[2*t+0]}geta_centroid_pos1(t){return this.uint16[2*t+1]}}ba(vc,"FillExtrusionCentroidArray");const xc=Ll([{name:"a_pos",components:2,type:"Int16"}],4),bc=Ll([{name:"a_pos_3",components:3,type:"Int16"},{name:"a_pos_normal_3",components:3,type:"Int16"}]);class wc{constructor(t=[]){this.segments=t}_prepareSegment(t,e,i,n){let r=this.segments[this.segments.length-1];return t>wc.MAX_VERTEX_ARRAY_LENGTH&&pi(`Max vertices per segment is ${wc.MAX_VERTEX_ARRAY_LENGTH}: bucket requested ${t}`),(!r||r.vertexLength+t>wc.MAX_VERTEX_ARRAY_LENGTH||r.sortKey!==n)&&(r={vertexOffset:e,primitiveOffset:i,vertexLength:0,primitiveLength:0},void 0!==n&&(r.sortKey=n),this.segments.push(r)),r}prepareSegment(t,e,i,n){return this._prepareSegment(t,e.length,i.length,n)}get(){return this.segments}destroy(){for(const t of this.segments)for(const e in t.vaos)t.vaos[e].destroy()}static simpleSegment(t,e,i,n){return new wc([{vertexOffset:t,primitiveOffset:e,vertexLength:i,primitiveLength:n,vaos:{},sortKey:0}])}}function Tc(t,e){return 256*(t=Xe(Math.floor(t),0,255))+Xe(Math.floor(e),0,255)}wc.MAX_VERTEX_ARRAY_LENGTH=Math.pow(2,16)-1,ba(wc,"SegmentVector");const Sc=Ll([{name:"a_pattern",components:4,type:"Uint16"},{name:"a_pixel_ratio",components:1,type:"Float32"}]),Ec=Ll([{name:"a_dash",components:4,type:"Uint16"}]);class Mc{constructor(){this.ids=[],this.uniqueIds=[],this.positions=[],this.indexed=!1}add(t,e,i,n){this.ids.push(Cc(t)),this.positions.push(e,i,n)}eachPosition(t,e){const i=Cc(t);let n=0,r=this.ids.length-1;for(;n>1;this.ids[t]>=i?r=t:n=t+1}for(;this.ids[n]===i;)e(this.positions[3*n],this.positions[3*n+1],this.positions[3*n+2]),n++}static serialize(t,e){const i=new Float64Array(t.ids),n=new Uint32Array(t.positions);return Ac(i,n,0,i.length-1),e&&(e.add(i.buffer),e.add(n.buffer)),{ids:i,positions:n}}static deserialize(t){const e=new Mc;let i;e.ids=t.ids,e.positions=t.positions;for(const t of e.ids)t!==i&&e.uniqueIds.push(t),i=t;return e.indexed=!0,e}}function Cc(t){const e=+t;return!isNaN(e)&&Number.MIN_SAFE_INTEGER>1];let o=i-1,s=n+1;for(;;){do{o++}while(t[o]r);if(o>=s)break;Ic(t,o,s),Ic(e,3*o,3*s),Ic(e,3*o+1,3*s+1),Ic(e,3*o+2,3*s+2)}s-i`u_${t}`)),this.type=i,this.context=n}setUniform(t,e,i,n,r){const o=n.constantOr(this.value);e.set(t,r,o instanceof Un?o.toRenderColor(this.context.lut):o)}getBinding(t,e){return"color"===this.type?new Rc(t):new $c(t)}}class Gc{constructor(t,e){this.uniformNames=e.map((t=>`u_${t}`)),this.pattern=null,this.pixelRatio=1}setConstantPatternPositions(t){this.pixelRatio=t.pixelRatio||1,this.pattern=t.tl.concat(t.br)}setUniform(t,e,i,n,r){const o="u_pattern"===r||"u_dash"===r?this.pattern:"u_pixel_ratio"===r?this.pixelRatio:null;o&&e.set(t,r,o)}getBinding(t,e){return"u_pattern"===e||"u_dash"===e?new zc(t):new $c(t)}}class Zc{constructor(t,e,i,n){this.expression=t,this.type=i,this.maxValue=0,this.paintVertexAttributes=e.map((t=>({name:`a_${t}`,type:"Float32",components:"color"===i?2:1,offset:0}))),this.paintVertexArray=new n}populatePaintArray(t,e,i,n,r,o,s){const a=this.paintVertexArray.length,l=this.expression.evaluate(new Ha(0,{brightness:o}),e,{},r,n,s);this.paintVertexArray.resize(t),this._setPaintValue(a,t,l,this.context)}updatePaintArray(t,e,i,n,r,o,s){const a=this.expression.evaluate({zoom:0,brightness:s},i,n,void 0,r);this._setPaintValue(t,e,a,this.context)}_setPaintValue(t,e,i,n){if("color"===this.type){const r=jc(i.toRenderColor(n.lut));for(let i=t;i`u_${t}_t`)),this.type=i,this.useIntegerZoom=n,this.context=r,this.maxValue=0,this.paintVertexAttributes=e.map((t=>({name:`a_${t}`,type:"Float32",components:"color"===i?4:2,offset:0}))),this.paintVertexArray=new o}populatePaintArray(t,e,i,n,r,o,s){const a=this.expression.evaluate(new Ha(this.context.zoom,{brightness:o}),e,{},r,n,s),l=this.expression.evaluate(new Ha(this.context.zoom+1,{brightness:o}),e,{},r,n,s),c=this.paintVertexArray.length;this.paintVertexArray.resize(t),this._setPaintValue(c,t,a,l,this.context)}updatePaintArray(t,e,i,n,r,o,s){const a=this.expression.evaluate({zoom:this.context.zoom,brightness:s},i,n,void 0,r),l=this.expression.evaluate({zoom:this.context.zoom+1,brightness:s},i,n,void 0,r);this._setPaintValue(t,e,a,l,this.context)}_setPaintValue(t,e,i,n,r){if("color"===this.type){const n=jc(i.toRenderColor(r.lut)),o=jc(i.toRenderColor(r.lut));for(let i=t;i!0){this.binders={},this._buffers=[],this.context=e;const n=[];for(const r in t.paint._values){const o=t.paint.get(r);if(!i(r))continue;if(!(o instanceof tl&&Xs(o.property.specification)))continue;const s=Kc(r,t.type),a=o.value,l=o.property.specification.type,c=!!o.property.useIntegerZoom,d="line-dasharray"===r||r.endsWith("pattern"),u="line-dasharray"===r&&"constant"!==t.layout.get("line-cap").value.kind;if("constant"!==a.kind||u)if("source"===a.kind||u||d){const e=td(r,l,"source");this.binders[r]=d?new Hc(a,s,l,e,t.id):new Zc(a,s,l,e),n.push(`/a_${r}`)}else{const t=td(r,l,"composite");this.binders[r]=new qc(a,s,l,c,e,t),n.push(`/z_${r}`)}else this.binders[r]=d?new Gc(a.value,s):new Vc(a.value,s,l,e),n.push(`/u_${r}`)}this.cacheKey=n.sort().join("")}getMaxValue(t){const e=this.binders[t];return e instanceof Zc||e instanceof qc?e.maxValue:0}populatePaintArrays(t,e,i,n,r,o,s){for(const a in this.binders){const l=this.binders[a];l.context=this.context,(l instanceof Zc||l instanceof qc||l instanceof Hc)&&l.populatePaintArray(t,e,i,n,r,o,s)}}setConstantPatternPositions(t){for(const e in this.binders){const i=this.binders[e];i instanceof Gc&&i.setConstantPatternPositions(t)}}updatePaintArrays(t,e,i,n,r,o,s,a){let l=!1;const c=Object.keys(t),d=0!==c.length,u=d?c:e.uniqueIds;this.context.lut=r.lut;for(const c in this.binders){const h=this.binders[c];if(h.context=this.context,(h instanceof Zc||h instanceof qc||h instanceof Hc)&&(!0===h.expression.isStateDependent||!1===h.expression.isLightConstant)){const p=r.paint.get(c);h.expression=p.value;for(const i of u){const r=t[i.toString()];e.eachPosition(i,((t,e,i)=>{const l=n.feature(t);h.updatePaintArray(e,i,l,r,o,s,a)}))}if(!d)for(const e of i.uniqueIds){const r=t[e.toString()];i.eachPosition(e,((t,e,i)=>{const l=n.feature(t);h.updatePaintArray(e,i,l,r,o,s,a)}))}l=!0}}return l}defines(){const t=[];for(const e in this.binders){const i=this.binders[e];(i instanceof Vc||i instanceof Gc)&&t.push(...i.uniformNames.map((t=>`#define HAS_UNIFORM_${t}`)))}return t}getBinderAttributes(){const t=[];for(const e in this.binders){const i=this.binders[e];if(i instanceof Zc||i instanceof qc||i instanceof Hc)for(let e=0;e!0){this.programConfigurations={};for(const n of t)this.programConfigurations[n.id]=new Wc(n,e,i);this.needsUpload=!1,this._featureMap=new Mc,this._featureMapWithoutIds=new Mc,this._bufferOffset=0,this._idlessCounter=0}populatePaintArrays(t,e,i,n,r,o,s,a){for(const i in this.programConfigurations)this.programConfigurations[i].populatePaintArrays(t,e,n,r,o,s,a);void 0!==e.id?this._featureMap.add(e.id,i,this._bufferOffset,t):(this._featureMapWithoutIds.add(this._idlessCounter,i,this._bufferOffset,t),this._idlessCounter+=1),this._bufferOffset=t,this.needsUpload=!0}updatePaintArrays(t,e,i,n,r,o){for(const s of i)this.needsUpload=this.programConfigurations[s.id].updatePaintArrays(t,this._featureMap,this._featureMapWithoutIds,e,s,n,r,o||0)||this.needsUpload}get(t){return this.programConfigurations[t]}upload(t){if(this.needsUpload){for(const e in this.programConfigurations)this.programConfigurations[e].upload(t);this.needsUpload=!1}}destroy(){for(const t in this.programConfigurations)this.programConfigurations[t].destroy()}}const Xc={"text-opacity":["opacity"],"icon-opacity":["opacity"],"text-occlusion-opacity":["occlusion_opacity"],"icon-occlusion-opacity":["occlusion_opacity"],"text-color":["fill_color"],"icon-color":["fill_color"],"text-emissive-strength":["emissive_strength"],"icon-emissive-strength":["emissive_strength"],"text-halo-color":["halo_color"],"icon-halo-color":["halo_color"],"text-halo-blur":["halo_blur"],"icon-halo-blur":["halo_blur"],"text-halo-width":["halo_width"],"icon-halo-width":["halo_width"],"line-gap-width":["gapwidth"],"line-pattern":["pattern","pixel_ratio"],"fill-pattern":["pattern","pixel_ratio"],"fill-extrusion-pattern":["pattern","pixel_ratio"],"line-dasharray":["dash"]};function Kc(t,e){return Xc[t]||[t.replace(`${e}-`,"").replace(/-/g,"_")]}const Jc={"line-pattern":{source:Fl,composite:Fl},"fill-pattern":{source:Fl,composite:Fl},"fill-extrusion-pattern":{source:Fl,composite:Fl},"line-dasharray":{source:Nl,composite:Nl}},Qc={color:{source:ic,composite:Ol},number:{source:Zl,composite:ic}};function td(t,e,i){const n=Jc[t];return n&&n[i]||Qc[e][i]}ba(Vc,"ConstantBinder"),ba(Gc,"PatternConstantBinder"),ba(Zc,"SourceExpressionBinder"),ba(Hc,"PatternCompositeBinder"),ba(qc,"CompositeExpressionBinder"),ba(Wc,"ProgramConfiguration",{omit:["_buffers"]}),ba(Yc,"ProgramConfigurationSet");const ed=uo/Math.PI/2,id=5,nd=6,rd=16383,od=64,sd=[od,32,16],ad=-ed,ld=ed;function cd(t,e,i,n=ed){return i=Ge(i),[t*Math.sin(i)*n,-e*n,t*Math.cos(i)*n]}function dd(t,e,i){return cd(Math.cos(Ge(t)),Math.sin(Ge(t)),e,i)}const ud=6371008.8,hd=2*Math.PI*ud;class pd{constructor(t,e){if(isNaN(t)||isNaN(e))throw new Error(`Invalid LngLat object: (${t}, ${e})`);if(this.lng=+t,this.lat=+e,this.lat>90||this.lat, lat: }, an object {lon: , lat: }, or an array of [, ]")}}class fd{constructor(t,e){if(t)if(e)this.setSouthWest(t).setNorthEast(e);else if(4===t.length){const e=t;this.setSouthWest([e[0],e[1]]).setNorthEast([e[2],e[3]])}else{const e=t;this.setSouthWest(e[0]).setNorthEast(e[1])}}setNorthEast(t){return this._ne=t instanceof pd?new pd(t.lng,t.lat):pd.convert(t),this}setSouthWest(t){return this._sw=t instanceof pd?new pd(t.lng,t.lat):pd.convert(t),this}extend(t){const e=this._sw,i=this._ne;let n,r;if(t instanceof pd)n=t,r=t;else{if(!(t instanceof fd))return Array.isArray(t)?4===t.length||t.every(Array.isArray)?this.extend(fd.convert(t)):this.extend(pd.convert(t)):"object"==typeof t&&null!==t&&t.hasOwnProperty("lat")&&(t.hasOwnProperty("lon")||t.hasOwnProperty("lng"))?this.extend(pd.convert(t)):this;if(n=t._sw,r=t._ne,!n||!r)return this}return e||i?(e.lng=Math.min(n.lng,e.lng),e.lat=Math.min(n.lat,e.lat),i.lng=Math.max(r.lng,i.lng),i.lat=Math.max(r.lat,i.lat)):(this._sw=new pd(n.lng,n.lat),this._ne=new pd(r.lng,r.lat)),this}getCenter(){return new pd((this._sw.lng+this._ne.lng)/2,(this._sw.lat+this._ne.lat)/2)}getSouthWest(){return this._sw}getNorthEast(){return this._ne}getNorthWest(){return new pd(this.getWest(),this.getNorth())}getSouthEast(){return new pd(this.getEast(),this.getSouth())}getWest(){return this._sw.lng}getSouth(){return this._sw.lat}getEast(){return this._ne.lng}getNorth(){return this._ne.lat}toArray(){return[this._sw.toArray(),this._ne.toArray()]}toString(){return`LngLatBounds(${this._sw.toString()}, ${this._ne.toString()})`}isEmpty(){return!(this._sw&&this._ne)}contains(t){const{lng:e,lat:i}=pd.convert(t);let n=this._sw.lngthis._ne.lng&&(n=this._sw.lng>=e&&e>=this._ne.lng),this._sw.lat0;o--)n=1this.canonical.z?new vd(t,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y):new vd(t,this.wrap,t,this.canonical.x>>e,this.canonical.y>>e)}calculateScaledKey(t,e=!0){if(this.overscaledZ===t&&e)return this.key;if(t>this.canonical.z)return xd(this.wrap*+e,t,this.canonical.z,this.canonical.x,this.canonical.y);{const i=this.canonical.z-t;return xd(this.wrap*+e,t,t,this.canonical.x>>i,this.canonical.y>>i)}}isChildOf(t){if(t.wrap!==this.wrap)return!1;const e=this.canonical.z-t.canonical.z;return 0===t.overscaledZ||t.overscaledZ>e&&t.canonical.y===this.canonical.y>>e}children(t){if(this.overscaledZ>=t)return[new vd(this.overscaledZ+1,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y)];const e=this.canonical.z+1,i=2*this.canonical.x,n=2*this.canonical.y;return[new vd(e,this.wrap,e,i,n),new vd(e,this.wrap,e,i+1,n),new vd(e,this.wrap,e,i,n+1),new vd(e,this.wrap,e,i+1,n+1)]}isLessThan(t){return this.wrapt.wrap)&&(this.overscaledZt.overscaledZ)&&(this.canonical.xt.canonical.x)&&this.canonical.y{let e=t.canonical.x-1,i=t.wrap;return e{let e=t.canonical.x+1,i=t.wrap;return e===1new vd(t.overscaledZ,t.wrap,t.canonical.z,t.canonical.x,(0===t.canonical.y?1new vd(t.overscaledZ,t.wrap,t.canonical.z,t.canonical.x,t.canonical.y===(1=l?(Od(t,e,i,c,d,o,u,a,l),Od(t,c,d,n,r,u,s,a,l)):t.push(s)}function Bd(t,e,i){let n=t[0],r=n.x,o=n.y;e(n);const s=[n];for(let a=1;at.x+1||nt.y+1)&&pi("Geometry exceeds allowed extent, reduce your vector tile buffer size"),t}function Gd(t,e,i){const n=t.loadGeometry(),r=t.extent,o=uo/r;if(e&&i&&i.projection.isReprojectedInTileSpace){const o=1{const i=Ad((e.x+t.x/r)/o),n=Id((e.y+t.y/r)/o),d=c.project(i,n);t.x=(d.x*s-a)*r,t.y=(d.y*s-l)*r};for(let e=0;e=r||i.y=r||(d(i),t.push(i));n[e]=t}}for(const t of n)for(const e of t)Vd(e,o);return n}function Zd(t,e){return{type:t.type,id:t.id,properties:t.properties,geometry:e?Gd(t):[]}}function qd(t,e,i,n,r){t.emplaceBack(2*e+(n+1)/2,2*i+(r+1)/2)}function Hd(t,e,i){const n=16384;t.emplaceBack(e.x,e.y,e.z,i[0]*n,i[1]*n,i[2]*n)}class Wd{constructor(t){this.zoom=t.zoom,this.overscaling=t.overscaling,this.layers=t.layers,this.layerIds=this.layers.map((t=>t.fqid)),this.index=t.index,this.hasPattern=!1,this.projection=t.projection,this.layoutVertexArray=new $l,this.indexArray=new Kl,this.segments=new wc,this.programConfigurations=new Yc(t.layers,{zoom:t.zoom,lut:t.lut}),this.stateDependentLayerIds=this.layers.filter((t=>t.isStateDependent())).map((t=>t.id))}updateFootprints(t,e){}populate(t,e,i,n){const r=this.layers[0],o=[];let s=null;"circle"===r.type&&(s=r.layout.get("circle-sort-key"));for(const{feature:e,id:r,index:a,sourceLayerIndex:l}of t){const t=this.layers[0]._featureFilter.needGeometry,c=Zd(e,t);if(!this.layers[0]._featureFilter.filter(new Ha(this.zoom),c,i))continue;const d=s?s.evaluate(c,{},i):void 0,u={id:r,properties:e.properties,type:e.type,sourceLayerIndex:l,index:a,geometry:t?c.geometry:Gd(e,i,n),patterns:{},sortKey:d};o.push(u)}s&&o.sort(((t,e)=>t.sortKey-e.sortKey));let a=null;"globe"===n.projection.name&&(this.globeExtVertexArray=new Ul,a=n.projection);for(const n of o){const{geometry:r,index:o,sourceLayerIndex:s}=n,l=t[o].feature;this.addFeature(n,r,o,e.availableImages,i,a,e.brightness),e.featureIndex.insert(l,r,o,s,this.index)}}update(t,e,i,n,r){const o=0!==Object.keys(t).length;o&&!this.stateDependentLayers.length||this.programConfigurations.updatePaintArrays(t,e,o?this.stateDependentLayers:this.layers,i,n,r)}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(t){this.uploaded||(this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,xc.members),this.indexBuffer=t.createIndexBuffer(this.indexArray),this.globeExtVertexArray&&(this.globeExtVertexBuffer=t.createVertexBuffer(this.globeExtVertexArray,bc.members))),this.programConfigurations.upload(t),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy(),this.globeExtVertexBuffer&&this.globeExtVertexBuffer.destroy())}addFeature(t,e,i,n,r,o,s){for(const i of e)for(const e of i){const i=e.x,n=e.y;if(i=uo||n=uo)continue;if(o){const t=o.projectTilePoint(i,n,r),e=o.upVector(r,i,n),s=this.globeExtVertexArray;Hd(s,t,e),Hd(s,t,e),Hd(s,t,e),Hd(s,t,e)}const s=this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray,t.sortKey),a=s.vertexLength;qd(this.layoutVertexArray,i,n,-1,-1),qd(this.layoutVertexArray,i,n,1,-1),qd(this.layoutVertexArray,i,n,1,1),qd(this.layoutVertexArray,i,n,-1,1),this.indexArray.emplaceBack(a,a+1,a+2),this.indexArray.emplaceBack(a,a+2,a+3),s.vertexLength+=4,s.primitiveLength+=2}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,t,i,{},n,r,s)}}function Yd(t,e){for(let i=0;i1){if(Qd(t,e))return!0;for(let n=0;n1?i:i.sub(e)._mult(r)._add(e))}function nu(t,e){let i,n,r,o=!1;for(let s=0;se.y!=r.y>e.y&&e.xe.y!=s.y>e.y&&e.x=o.x&&r>=o.y)return!0;const o=[new Ue(e,i),new Ue(e,r),new Ue(n,r),new Ue(n,i)];if(t.length>2)for(const e of o)if(ru(t,e))return!0;for(let e=0;er.x&&e.x>r.x||t.yr.y&&e.y>r.y)return!1;const o=fi(t,e,i[0]);return o!==fi(t,e,i[1])||o!==fi(t,e,i[2])||o!==fi(t,e,i[3])}function au(t,e,i,n,r,o){let s=e.y-t.y,a=t.x-e.x;if(o=o||0){const t=s*s+a*a;if(0===t)return!0;const e=Math.sqrt(t);s/=e,a/=e}return!((i.x-t.x)*s+(i.y-t.y)*a-o=0;if(0===s)return 0;s!==i.length&&(n=!1)}return n?2:1}function vu(t,e){for(const i of t.projections){const n=gu(e,t.points[0],i.axis);if(i.projection[1]n[1])return 0}return 1}function xu(e,i){let n=0;const r=[0,0,0,0];for(let o=0;o=0&&n++;return n}class bu{constructor(e,i){this.points=e||new Array(8).fill([0,0,0]),this.planes=i||new Array(6).fill([0,0,0,0]),this.bounds=wu.fromPoints(this.points),this.projections=[],this.frustumEdges=[t._.sub([],this.points[2],this.points[3]),t._.sub([],this.points[0],this.points[3]),t._.sub([],this.points[4],this.points[0]),t._.sub([],this.points[5],this.points[1]),t._.sub([],this.points[6],this.points[2]),t._.sub([],this.points[7],this.points[3])];for(const t of this.frustumEdges){const e=[0,-t[2],t[1]],i=[t[2],0,-t[0]];this.projections.push({axis:e,projection:gu(this.points,this.points[0],e)}),this.projections.push({axis:i,projection:gu(this.points,this.points[0],i)})}}static fromInvProjectionMatrix(e,i,n,r){const o=Math.pow(2,n),s=[[-1,1,-1,1],[1,1,-1,1],[1,-1,-1,1],[-1,-1,-1,1],[-1,1,1,1],[1,1,1,1],[1,-1,1,1],[-1,-1,1,1]].map((n=>{const s=t.aA.transformMat4([],n,e),a=1/s[3]/i*o;return t.aA.mul(s,s,[a,a,r?1/s[3]:a,a])})),a=[[0,1,2],[6,5,4],[0,3,7],[2,1,5],[3,2,6],[0,4,5]].map((e=>{const i=t._.sub([],s[e[0]],s[e[1]]),n=t._.sub([],s[e[2]],s[e[1]]),r=t._.normalize([],t._.cross([],i,n)),o=-t._.dot(r,s[e[1]]);return r.concat(o)})),l=[];for(let t=0;ta[1]||a[0]>s[1])return 0}return 1}}class wu{static fromPoints(e){const i=[1/0,1/0,1/0],n=[-1/0,-1/0,-1/0];for(const r of e)t._.min(i,i,r),t._.max(n,n,r);return new wu(i,n)}static fromTileIdAndHeight(t,e,i){const n=1t.max[e]||t.min[e]>this.max[e])return!1;return!0}intersectsAabbXY(t){return!(this.min[0]>t.max[0]||t.min[0]>this.max[0]||this.min[1]>t.max[1]||t.min[1]>this.max[1])}encapsulate(t){for(let e=0;e1?null:function(t,e,i,n){const r=Math.sin(i);return t*(Math.sin((1-n)*i)/r)+e*(Math.sin(n*i)/r)}(t.a[e],t.b[e],t.angle,Xe(i,0,1))+t.center[e]}function $u(t){if(t.z0){for(const e of l)t._.min(u,u,e),t._.max(d,d,e);return new wu(u,d)}const h=[s[12]*o,s[13]*o,s[14]*o],p=a.getCenter(),f=Xe(e.center.lat,-Pd,Pd),m=Xe(p.lat,-Pd,Pd),_=Ed(e.center.lng),g=Md(f);let y=_-Ed(p.lng);const v=g-Md(m);y>.5?y-=1:yMath.abs(v))x=y>=0?1:3;else{x=v>=0?0:2;const e=[s[4]*o,s[5]*o,s[6]*o],i=-Math.sin(Ge(v>=0?a.getSouth():a.getNorth()))*ed;t._.scaleAndAdd(h,h,e,i)}const b=l[x],w=l[(x+1)%4],T=new Lu(b,w,h),S=[Pu(T,0)||b[0],Pu(T,1)||b[1],Pu(T,2)||b[2]],E=Hu(e.zoom);if(E>0){const r=function({x:t,y:e,z:i},n,r,o,s){const a=1/(1.5?h=-1:pMath.PI/2*1.01}const Xu=Ge(85),Ku=Math.cos(Xu),Ju=Math.sin(Xu),Qu=t.ad.create(),th=t=>{const e=[];return"map"===t.paint.get("circle-pitch-alignment")&&e.push("PITCH_WITH_MAP"),"map"===t.paint.get("circle-pitch-scale")&&e.push("SCALE_WITH_MAP"),e};function eh(e,i,n,r,o,s,a,l,c){if(s&&e.queryGeometry.isAboveHorizon)return!1;s&&(c*=e.pixelToTileUnitsFactor);const d=e.tileID.canonical,u=n.projection.upVectorScale(d,n.center.lat,n.worldSize).metersToTile;for(const h of i)for(const i of h){const h=i.add(l),p=o&&n.elevation?n.elevation.exaggeration()*o.getElevationAt(h.x,h.y,!0):0,f=n.projection.projectTilePoint(h.x,h.y,d);if(p>0){const t=n.projection.upVector(d,h.x,h.y);f.x+=t[0]*u*p,f.y+=t[1]*u*p,f.z+=t[2]*u*p}const m=s?h:ih(f.x,f.y,f.z,r),_=s?e.tilespaceRays.map((t=>oh(t,p))):e.queryGeometry.screenGeometry,g=t.aA.transformMat4([],[f.x,f.y,f.z,1],r);if(!a&&s?c*=g[3]/n.cameraToCenterDistance:a&&!s&&(c*=n.cameraToCenterDistance/g[3]),s){const t=Id((i.y/uo+d.y)/(1t.width||r.height>t.height||i.x>t.width-r.width||i.y>t.height-r.height)throw new RangeError("out of range source coordinates for image copy");if(r.width>e.width||r.height>e.height||n.x>e.width-r.width||n.y>e.height-r.height)throw new RangeError("out of range destination coordinates for image copy");const l=t.data,c=e.data,d=4===o&&a;for(let a=0;a{e[t.evaluationKey]=o;const s=t.expression.evaluate(e);s&&(r.data[i+n+0]=Math.floor(255*s.r/s.a),r.data[i+n+1]=Math.floor(255*s.g/s.a),r.data[i+n+2]=Math.floor(255*s.b/s.a),r.data[i+n+3]=Math.floor(255*s.a))};if(t.clips)for(let e=0,r=0;e80*i){a=1/0,l=1/0;let e=-1/0,n=-1/0;for(let o=i;oe&&(e=i),r>n&&(n=r)}c=Math.max(e-a,n-l),c=0!==c?32767/c:0}return Th(o,s,i,a,l,c,0),s}function bh(t,e,i,n,r){let o;if(r===function(t,e,i,n){let r=0;for(let o=e,s=i-n;o0)for(let r=e;r=e;r-=n)o=jh(r/n|0,t[r],t[r+1],o);return o&&Rh(o,o.next)&&(Vh(o),o=o.next),o}function wh(t,e){if(!t)return t;e||(e=t);let i,n=t;do{if(i=!1,n.steiner||!Rh(n,n.next)&&0!==zh(n.prev,n,n.next))n=n.next;else{if(Vh(n),n=e=n.prev,n===n.next)break;i=!0}}while(i||n!==e);return e}function Th(t,e,i,n,r,o,s){if(!t)return;!s&&o&&function(t,e,i,n){let r=t;do{0===r.z&&(r.z=Ph(r.x,r.y,e,i,n)),r.prevZ=r.prev,r.nextZ=r.next,r=r.next}while(r!==t);r.prevZ.nextZ=null,r.prevZ=null,function(t){let e,i=1;do{let n,r=t;t=null;let o=null;for(e=0;r;){e++;let s=r,a=0;for(let t=0;t0||l>0&&s;)0!==a&&(0===l||!s||r.z1)}(r)}(t,n,r,o);let a=t;for(;t.prev!==t.next;){const l=t.prev,c=t.next;if(o?Eh(t,n,r,o):Sh(t))e.push(l.i,t.i,c.i),Vh(t),t=c.next,a=c.next;else if((t=c)===a){s?1===s?Th(t=Mh(wh(t),e),e,i,n,r,o,2):2===s&&Ch(t,e,i,n,r,o):Th(wh(t),e,i,n,r,o,1);break}}}function Sh(t){const e=t.prev,i=t,n=t.next;if(zh(e,i,n)>=0)return!1;const r=e.x,o=i.x,s=n.x,a=e.y,l=i.y,c=n.y,d=ro?r>s?r:s:o>s?o:s,p=a>l?a>c?a:c:l>c?l:c;let f=n.next;for(;f!==e;){if(f.x>=d&&f.x=u&&f.y=0)return!1;f=f.next}return!0}function Eh(t,e,i,n){const r=t.prev,o=t,s=t.next;if(zh(r,o,s)>=0)return!1;const a=r.x,l=o.x,c=s.x,d=r.y,u=o.y,h=s.y,p=al?a>c?a:c:l>c?l:c,_=d>u?d>h?d:h:u>h?u:h,g=Ph(p,f,e,i,n),y=Ph(m,_,e,i,n);let v=t.prevZ,x=t.nextZ;for(;v&&v.z>=g&&x&&x.z=p&&v.x=f&&v.y=0)return!1;if(v=v.prevZ,x.x>=p&&x.x=f&&x.y=0)return!1;x=x.nextZ}for(;v&&v.z>=g;){if(v.x>=p&&v.x=f&&v.y=0)return!1;v=v.prevZ}for(;x&&x.z=p&&x.x=f&&x.y=0)return!1;x=x.nextZ}return!0}function Mh(t,e){let i=t;do{const n=i.prev,r=i.next.next;!Rh(n,r)&&Oh(n,i,i.next,r)&&Nh(n,r)&&Nh(r,n)&&(e.push(n.i,i.i,r.i),Vh(i),Vh(i.next),i=t=r),i=i.next}while(i!==t);return wh(i)}function Ch(t,e,i,n,r,o){let s=t;do{let t=s.next.next;for(;t!==s.prev;){if(s.i!==t.i&&Dh(s,t)){let a=Uh(s,t);return s=wh(s,s.next),a=wh(a,a.next),Th(s,e,i,n,r,o,0),void Th(a,e,i,n,r,o,0)}t=t.next}s=s.next}while(s!==t)}function Ah(t,e){return t.x-e.x}function Ih(t,e){const i=function(t,e){let i=e;const n=t.x,r=t.y;let o,s=-1/0;do{if(r=i.next.y&&i.next.y!==i.y){const t=i.x+(r-i.y)*(i.next.x-i.x)/(i.next.y-i.y);if(ts&&(s=t,o=i.x=i.x&&i.x>=l&&n!==i.x&&kh(ro.x||i.x===o.x&&Lh(o,i)))&&(o=i,d=e)}i=i.next}while(i!==a);return o}(t,e);if(!i)return e;const n=Uh(i,t);return wh(n,n.next),wh(i,i.next)}function Lh(t,e){return zh(t.prev,t,e.prev)=(t-s)*(o-a)&&(t-s)*(n-a)>=(i-s)*(e-a)&&(i-s)*(o-a)>=(r-s)*(n-a)}function Dh(t,e){return t.next.i!==e.i&&t.prev.i!==e.i&&!function(t,e){let i=t;do{if(i.i!==t.i&&i.next.i!==t.i&&i.i!==e.i&&i.next.i!==e.i&&Oh(i,i.next,t,e))return!0;i=i.next}while(i!==t);return!1}(t,e)&&(Nh(t,e)&&Nh(e,t)&&function(t,e){let i=t,n=!1;const r=(t.x+e.x)/2,o=(t.y+e.y)/2;do{i.y>o!=i.next.y>o&&i.next.y!==i.y&&r0&&zh(e.prev,e,e.next)>0)}function zh(t,e,i){return(e.y-t.y)*(i.x-e.x)-(e.x-t.x)*(i.y-e.y)}function Rh(t,e){return t.x===e.x&&t.y===e.y}function Oh(t,e,i,n){const r=Fh(zh(t,e,i)),o=Fh(zh(t,e,n)),s=Fh(zh(i,n,t)),a=Fh(zh(i,n,e));return r!==o&&s!==a||!(0!==r||!Bh(t,i,e))||!(0!==o||!Bh(t,n,e))||!(0!==s||!Bh(i,t,n))||!(0!==a||!Bh(i,e,n))}function Bh(t,e,i){return e.x=Math.min(t.x,i.x)&&e.y=Math.min(t.y,i.y)}function Fh(t){return t>0?1:t=0&&zh(t,t.prev,e)>=0:zh(t,e,t.prev)1)for(let t=0;tt.fqid)),this.index=t.index,this.hasPattern=!1,this.patternFeatures=[],this.layoutVertexArray=new $l,this.indexArray=new Kl,this.indexArray2=new ql,this.programConfigurations=new Yc(t.layers,{zoom:t.zoom,lut:t.lut}),this.segments=new wc,this.segments2=new wc,this.stateDependentLayerIds=this.layers.filter((t=>t.isStateDependent())).map((t=>t.id)),this.projection=t.projection}updateFootprints(t,e){}populate(t,e,i,n){this.hasPattern=Hh("fill",this.layers,e);const r=this.layers[0].layout.get("fill-sort-key"),o=[];for(const{feature:s,id:a,index:l,sourceLayerIndex:c}of t){const t=this.layers[0]._featureFilter.needGeometry,d=Zd(s,t);if(!this.layers[0]._featureFilter.filter(new Ha(this.zoom),d,i))continue;const u=r?r.evaluate(d,{},i,e.availableImages):void 0,h={id:a,properties:s.properties,type:s.type,sourceLayerIndex:c,index:l,geometry:t?d.geometry:Gd(s,i,n),patterns:{},sortKey:u};o.push(h)}r&&o.sort(((t,e)=>t.sortKey-e.sortKey));for(const n of o){const{geometry:r,index:o,sourceLayerIndex:s}=n;if(this.hasPattern){const t=Wh("fill",this.layers,n,this.zoom,e);this.patternFeatures.push(t)}else this.addFeature(n,r,o,i,{},e.availableImages,e.brightness);e.featureIndex.insert(t[o].feature,r,o,s,this.index)}}update(t,e,i,n,r){const o=0!==Object.keys(t).length;o&&!this.stateDependentLayers.length||this.programConfigurations.updatePaintArrays(t,e,o?this.stateDependentLayers:this.layers,i,n,r)}addFeatures(t,e,i,n,r,o){for(const t of this.patternFeatures)this.addFeature(t,t.geometry,t.index,e,i,n,o)}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(t){this.uploaded||(this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,vh),this.indexBuffer=t.createIndexBuffer(this.indexArray),this.indexBuffer2=t.createIndexBuffer(this.indexArray2)),this.programConfigurations.upload(t),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.indexBuffer2.destroy(),this.programConfigurations.destroy(),this.segments.destroy(),this.segments2.destroy())}addFeature(t,e,i,n,r,o=[],s){for(const t of Zh(e,500)){let e=0;for(const i of t)e+=i.length;const i=this.segments.prepareSegment(e,this.layoutVertexArray,this.indexArray),n=i.vertexLength,r=[],o=[];for(const e of t){if(0===e.length)continue;e!==t[0]&&o.push(r.length/2);const i=this.segments2.prepareSegment(e.length,this.layoutVertexArray,this.indexArray2),n=i.vertexLength;this.layoutVertexArray.emplaceBack(e[0].x,e[0].y),this.indexArray2.emplaceBack(n+e.length-1,n),r.push(e[0].x),r.push(e[0].y);for(let t=1;tt.cellIdx-e.cellIdx||t.triIdx-e.triIdx));let c=0;for(;cthis.max.x||this.min.x>t.x||t.y>this.max.y||this.min.y>t.y)return;const i=Qh(t.x-this.min.x,this.xScale,this.cellsX),n=Qh(t.y-this.min.y,this.yScale,this.cellsY),r=this.cells[n*this.cellsX+i];if(r){this._lazyInitLookup();for(let t=0;tthis.max.x||this.min.x>e.x)return;if(t.y>this.max.y||this.min.y>e.y)return;this._lazyInitLookup();const n=Qh(t.x-this.min.x,this.xScale,this.cellsX),r=Qh(e.x-this.min.x,this.xScale,this.cellsX),o=Qh(t.y-this.min.y,this.yScale,this.cellsY),s=Qh(e.y-this.min.y,this.yScale,this.cellsY);for(let t=o;tt.fqid)),this.index=t.index,this.hasPattern=!1,this.stateDependentLayerIds=this.layers.filter((t=>t.isStateDependent())).map((t=>t.id)),this.footprints=[]}updateFootprints(t,e){for(const i of this.footprints)e.push({footprint:i,id:t})}populate(t,e,i,n){const r=[];for(const{feature:e,id:o,index:s,sourceLayerIndex:a}of t){const t=this.layers[0]._featureFilter.needGeometry,l=Zd(e,t);if(!this.layers[0]._featureFilter.filter(new Ha(this.zoom),l,i))continue;const c={id:o,properties:e.properties,type:e.type,sourceLayerIndex:a,index:s,geometry:t?l.geometry:Gd(e,i,n),patterns:{}};r.push(c)}for(const n of r){const{geometry:r,index:o,sourceLayerIndex:s}=n;this.addFeature(n,r,o,i,{},e.availableImages,e.brightness),e.featureIndex.insert(t[o].feature,r,o,s,this.index)}}isEmpty(){return 0===this.footprints.length}uploadPending(){return!1}upload(t){}update(t,e,i,n,r){}destroy(){}addFeature(t,e,i,n,r,o=[],s){for(const t of Zh(e,2)){const e=[],i=[],n=[],r=new Ue(1/0,1/0),o=new Ue(-1/0,-1/0);for(const s of t)if(0!==s.length){s!==t[0]&&n.push(i.length/2);for(let t=0;t>3}if(r--,1===n||2===n)o+=t.readSVarint(),s+=t.readSVarint(),1===n&&(e&&a.push(e),e=[]),e.push(new dp(o,s));else{if(7!==n)throw new Error("unknown command "+n);e&&e.push(e[0].clone())}}return e&&a.push(e),a},hp.prototype.bbox=function(){var t=this._pbf;t.pos=this._geometry;for(var e=t.readVarint()+t.pos,i=1,n=0,r=0,o=0,s=1/0,a=-1/0,l=1/0,c=-1/0;t.pos>3}if(n--,1===i||2===i)(r+=t.readSVarint())a&&(a=r),(o+=t.readSVarint())c&&(c=o);else if(7!==i)throw new Error("unknown command "+i)}return[s,l,a,c]},hp.prototype.toGeoJSON=function(t,e,i){var n,r,o=this.extent*Math.pow(2,i),s=this.extent*t,a=this.extent*e,l=this.loadGeometry(),c=hp.types[this.type];function d(t){for(var e=0;e>3;e=1===n?t.readString():2===n?t.readFloat():3===n?t.readDouble():4===n?t.readVarint64():5===n?t.readVarint():6===n?t.readSVarint():7===n?t.readBoolean():null}return e}(i))}gp.prototype.feature=function(t){if(t=this._features.length)throw new Error("feature index out of bounds");this._pbf.pos=this._features[t];var e=this._pbf.readVarint()+this._pbf.pos;return new mp(this._pbf,e,this.extent,this._keys,this._values)};var vp=_p;function xp(t,e,i){if(3===t){var n=new vp(i,i.readVarint()+i.pos);n.length&&(e[n.name]=n)}}var bp=cp.VectorTile=function(t,e){this.layers=t.readFields(xp,{},e)},wp=cp.VectorTileFeature=up;cp.VectorTileLayer=_p;class Tp extends Ue{constructor(t,e,i){super(t,e),this.z=i}}class Sp extends Tp{constructor(t,e,i,n){super(t,e,i),this.w=n}}function Ep(t,e,i,n){const r=[],o=0===n?(t,e,i,n,r,o)=>{t.push(new Ue(o,i+(o-e)/(n-e)*(r-i)))}:(t,e,i,n,r,o)=>{t.push(new Ue(e+(o-i)/(r-i)*(n-e),o))};for(const s of t){const t=[];for(const r of s){if(r.lengthe&&o(s,a,l,c,d,e):u>i?h=e&&o(s,a,l,c,d,e),h>i&&u=e&&l=s[i]&&(n=e,s=t),n[i]r&&Mp(n,s,i,r),n[i]o&&Mp(s,n,i,o)}}function Ap(t,e){return t.x-e.x||t.y-e.y}function Ip(t,e){return 0===Ap(t.min,e.min)&&0===Ap(t.max,e.max)}function Lp(t,e){return!(t.min.x>e.max.x||t.max.xe.max.y||t.max.ynew Ue((t.x+o.x*uo)*a-s.x*uo,(t.y+o.y*uo)*a-s.y*uo)))}return Dp(i,r,t.indices,0,t.indices.length,0,0)}function Rp(t,e,i,n){const r=Math.pow(2,n.z-i.z);return new Ue((t+i.x*uo)*r-n.x*uo,(e+i.y*uo)*r-n.y*uo)}function Op(t,e){const i=[];e.footprint.grid.queryPoint(t,i);const n=e.footprint.indices,r=e.footprint.vertices;for(let e=0;ee[s])return null}else{const a=1/n[s];let l=(t[s]-i[s])*a,c=(e[s]-i[s])*a;if(l>c){const t=l;l=c,c=t}if(l>r&&(r=l),co)return null}return r}function Np(t,e,i,n,r,o,s,a,l,c,d){const u=n-t,h=r-e,p=o-i,f=s-t,m=a-e,_=l-i,g=d[1]*_-d[2]*m,y=d[2]*f-d[0]*_,v=d[0]*m-d[1]*f,x=u*g+h*y+p*v;if(Math.abs(x)1)return null;const M=T*p-S*h,C=S*u-w*p,A=w*h-T*u,I=(d[0]*M+d[1]*C+d[2]*A)*b;return I1?null:(f*M+m*C+_*A)*b}function Up(t,e,i){return(t-e)/(i-e)}function jp(t,e,i,n,r,o,s,a,l){const c=1{const o=n?1:0,s=(t+1)*i-o,a=e*i,l=(e+1)*i-o;r[0]=t*i,r[1]=a,r[2]=s,r[3]=l};let s=new Bp(n);const a=[];for(let e=0;e=1;n/=2){const t=i[i.length-1];s=new Bp(n);for(let e=0;e0;){const{idx:l,t:f,nodex:m,nodey:_,depth:g}=p.pop();if(this.leaves[l]){jp(m,_,g,e,i,n,r,u,h);const l=1=e[2])return f}continue}let y=0;for(let t=0;t=c[d[n]]&&(d.splice(n,0,t),i=!0);i||(d[y]=t),y++}}for(let t=0;t=this.dim+1||e=this.dim+1)throw new RangeError("out of range source coordinates for DEM data");return(e+1)*this.stride+(t+1)}static pack(t,e){const i=[0,0,0,0],n=Yp.getUnpackVector(e);let r=Math.floor((t+n[3])/n[2]);return i[2]=r%256,r=Math.floor(r/256),i[1]=r%256,r=Math.floor(r/256),i[0]=r,i}getPixels(){return new hh({width:this.stride,height:this.stride},this.pixels)}backfillBorder(t,e,i){if(this.dim!==t.dim)throw new Error("dem dimension mismatch");let n=e*this.dim,r=e*this.dim+this.dim,o=i*this.dim,s=i*this.dim+this.dim;switch(e){case-1:n=r-1;break;case 1:r=n+1}switch(i){case-1:o=s-1;break;case 1:s=o+1}const a=-e*this.dim,l=-i*this.dim;for(let e=o;et.max.x&&(t.max.x=e.x,n=!0),e.yt.max.y&&(t.max.y=e.y,n=!0),((0===e.x||e.x===uo)&&e.x===i.x)!=((0===e.y||e.y===uo)&&e.y===i.y)&&this.processBorderOverlap(e,i),n&&this.checkBorderIntersection(e,i)}checkBorderIntersection(t,e){e.xuo!=t.x>uo&&this.addBorderIntersection(1,Vn(e.y,t.y,(uo-e.x)/(t.x-e.x))),e.yuo!=t.y>uo&&this.addBorderIntersection(3,Vn(e.x,t.x,(uo-e.y)/(t.y-e.y)))}addBorderIntersection(t,e){this.borders||(this.borders=[[Number.MAX_VALUE,-Number.MAX_VALUE],[Number.MAX_VALUE,-Number.MAX_VALUE],[Number.MAX_VALUE,-Number.MAX_VALUE],[Number.MAX_VALUE,-Number.MAX_VALUE]]);const i=this.borders[t];ei[1]&&(i[1]=e)}processBorderOverlap(t,e){if(t.x===e.x){if(t.y===e.y)return;const i=0===t.x?0:1;this.addBorderIntersection(i,e.y),this.addBorderIntersection(i,t.y)}else{const i=0===t.y?2:3;this.addBorderIntersection(i,e.x),this.addBorderIntersection(i,t.x)}}centroid(){return 0===this.accCount?new Ue(0,0):new Ue(Math.floor(Math.max(0,this.acc.x)/this.accCount),Math.floor(Math.max(0,this.acc.y)/this.accCount))}intersectsCount(){return this.borders?this.borders.reduce(((t,e)=>t+ +(e[0]!==Number.MAX_VALUE)),0):0}}function hf(t,e){const i=t.add(e)._unit(),n=Xe(t.x*i.x+t.y*i.y,-1,1);var r,o,s;return r=Math.acos(n),Math.min(4,Math.max(-4,Math.tan(r)))/4*nf*((o=t).x*(s=e).y-o.y*s.xt.xt.x>uo,t=>t.yt.y>uo];function ff(t,e,i,n){const r=[4];if(0===n)return r;i._mult(n);const o=t.sub(i),s=e.sub(i),a=[t,e,o,s];for(let t=0;ttf.includes(t))),this._segments=new wc,this.hiddenByLandmarkVertexArray=new lc,this._segmentToGroundQuads={},this._segmentToGroundQuads[0]=[],this._segmentToRegionTriCounts={},this._segmentToRegionTriCounts[0]=[0,0,0,0,0],this.regionSegments={},this.regionSegments[4]=new wc}getDefaultSegment(){return this.regionSegments[4]}hasData(){return 0!==this.vertexArray.length}addData(t,e,i,n=!1){const r=t.length;if(r>2){let o=Math.max(0,this._segments.get().length-1);const s=this._segments._prepareSegment(4*r,this.vertexArray.length,2*this._segmentToGroundQuads[o].length);let a;o!==this._segments.get().length-1&&(o++,this._segmentToGroundQuads[o]=[],this._segmentToRegionTriCounts[o]=[0,0,0,0,0]);{const e=t[0],i=t[1];a=hf(e.sub(t[r-1])._perp()._unit(),i.sub(e)._perp()._unit())}for(let l=0;lt.region-e.region));for(let i=0;it+e),0);let o=0;for(let t=0;t0?this.hiddenByLandmarkVertexBuffer=t.createVertexBuffer(this.hiddenByLandmarkVertexArray,sp.members,!0):this.hiddenByLandmarkVertexBuffer&&this.hiddenByLandmarkVertexBuffer.updateData(this.hiddenByLandmarkVertexArray),this._needsHiddenByLandmarkUpdate=!1)}destroy(){if(this.vertexBuffer){this.vertexBuffer.destroy(),this.indexBuffer.destroy(),this.hiddenByLandmarkVertexBuffer&&this.hiddenByLandmarkVertexBuffer.destroy(),this._segments&&this._segments.destroy(),this.programConfigurations.destroy();for(let t=0;tt.fqid)),this.index=t.index,this.hasPattern=!1,this.edgeRadius=0,this.projection=t.projection,this.activeReplacements=[],this.replacementUpdateTime=0,this.centroidData=[],this.footprintIndices=new Kl,this.footprintVertices=new $l,this.footprintSegments=[],this.layoutVertexArray=new Dl,this.centroidVertexArray=new vc,this.indexArray=new Kl,this.programConfigurations=new Yc(t.layers,{zoom:t.zoom,lut:t.lut},(t=>Qp.includes(t))),this.segments=new wc,this.stateDependentLayerIds=this.layers.filter((t=>t.isStateDependent())).map((t=>t.id)),this.groundEffect=new mf(t),this.maxHeight=0,this.partLookup={},this.triangleSubSegments=[],this.polygonSegments=[]}updateFootprints(t,e){}populate(t,e,i,n){this.features=[],this.hasPattern=Hh("fill-extrusion",this.layers,e),this.featuresOnBorder=[],this.borderFeatureIndices=[[],[],[],[]],this.borderDoneWithNeighborZ=[-1,-1,-1,-1],this.tileToMeter=zd(i),this.edgeRadius=this.layers[0].layout.get("fill-extrusion-edge-radius")/this.tileToMeter;for(const{feature:r,id:o,index:s,sourceLayerIndex:a}of t){const t=this.layers[0]._featureFilter.needGeometry,l=Zd(r,t);if(!this.layers[0]._featureFilter.filter(new Ha(this.zoom),l,i))continue;const c={id:o,sourceLayerIndex:a,index:s,geometry:t?l.geometry:Gd(r,i,n),properties:r.properties,type:r.type,patterns:{}},d=this.layoutVertexArray.length;this.hasPattern?this.features.push(Wh("fill-extrusion",this.layers,c,this.zoom,e)):this.addFeature(c,c.geometry,s,i,{},e.availableImages,n,e.brightness),e.featureIndex.insert(r,c.geometry,s,a,this.index,d)}this.sortBorders(),"mercator"===this.projection.name&&this.splitToSubtiles(),this.groundEffect.prepareBorderSegments(),this.polygonSegments.length=0}addFeatures(t,e,i,n,r,o){for(const t of this.features){const{geometry:s}=t;this.addFeature(t,s,t.index,e,i,n,r,o)}this.sortBorders(),"mercator"===this.projection.name&&this.splitToSubtiles()}update(t,e,i,n,r){const o=0!==Object.keys(t).length;if(o&&!this.stateDependentLayers.length)return;const s=o?this.stateDependentLayers:this.layers;this.programConfigurations.updatePaintArrays(t,e,s,i,n,r),this.groundEffect.update(t,e,s,i,n,r)}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload||this.groundEffect.programConfigurations.needsUpload}upload(t){this.uploaded||(this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,lp),this.indexBuffer=t.createIndexBuffer(this.indexArray),this.layoutVertexExtArray&&(this.layoutVertexExtBuffer=t.createVertexBuffer(this.layoutVertexExtArray,ap.members,!0)),this.groundEffect.upload(t)),this.groundEffect.uploadPaintProperties(t),this.programConfigurations.upload(t),this.uploaded=!0}uploadCentroid(t){this.groundEffect.uploadHiddenByLandmark(t),this.needsCentroidUpdate&&(!this.centroidVertexBuffer&&this.centroidVertexArray.length>0?this.centroidVertexBuffer=t.createVertexBuffer(this.centroidVertexArray,op.members,!0):this.centroidVertexBuffer&&this.centroidVertexBuffer.updateData(this.centroidVertexArray),this.needsCentroidUpdate=!1)}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.centroidVertexBuffer&&this.centroidVertexBuffer.destroy(),this.layoutVertexExtBuffer&&this.layoutVertexExtBuffer.destroy(),this.groundEffect.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy())}addFeature(t,e,i,n,r,o,s,a){const l=this.layers[0].paint.get("fill-extrusion-flood-light-ground-radius").evaluate(t,{})/this.tileToMeter,c=[new Ue(0,0),new Ue(uo,uo)],d=s.projection,u="globe"===d.name,h="Polygon"===Jp[t.type],p=new uf;p.centroidDataIndex=this.centroidData.length;const f=new df,m=this.layers[0].paint.get("fill-extrusion-base").evaluate(t,{},n)=0;t--){const e=g[t];(0===e.length||(y=e[0]).every((t=>t.xt.x>=uo))||y.every((t=>t.yt.y>=uo)))&&g.splice(t,1)}var y;let v;if(u)v=Ef(g,c,n);else{v=[];for(const t of g)v.push({polygon:t,bounds:c})}const x=h?this.edgeRadius:0,b=x>0&&this.zoom{if(0===t.length)return!1;const i=t[t.length-1];return e.x===i.x&&e.y===i.y};for(const{polygon:t,bounds:e}of v){let i=0,r=0;for(const e of t)h&&!e[0].equals(e[e.length-1])&&e.push(e[0]),r+=h?e.length-1:e.length;const o=this.segments.prepareSegment((h?5:4)*r,this.layoutVertexArray,this.indexArray);f.footprintSegIdx4&&wf(s[s.length-2],s[0],s[1]),c=x?yf(s[s.length-2],s[0],s[1],x):0;const _=[];let g,y,v;y=s[1].sub(s[0])._perp()._unit();let b=!0;for(let t=1,r=0;t0?1:0,C=l.dist(h);if(r+C>32768&&(r=0),x){v=T.sub(h)._perp()._unit();let t=vf(l,h,T,gf(y,v),x);isNaN(t)&&(t=0);const e=h.sub(l)._unit();l=l.add(e.mult(c))._round(),h=h.add(e.mult(-t))._round(),c=t,y=v,m&&this.zoom>=17&&(w(_,l)||_.push(l),w(_,h)||_.push(h))}const A=o.vertexLength,I=s.length>4&&wf(l,h,T);let L=Tf(r,a,b);if(sf(this.layoutVertexArray,l.x,l.y,E,M,0,0,L),sf(this.layoutVertexArray,l.x,l.y,E,M,0,1,L),r+=C,L=Tf(r,I,!b),a=I,sf(this.layoutVertexArray,h.x,h.y,E,M,0,0,L),sf(this.layoutVertexArray,h.x,h.y,E,M,0,1,L),o.vertexLength+=4,this.indexArray.emplaceBack(A+0,A+1,A+2),this.indexArray.emplaceBack(A+1,A+3,A+2),o.primitiveLength+=2,x){const n=i+(1===t?s.length-2:t-2),r=1===t?i:n+1;if(this.indexArray.emplaceBack(A+1,n,A+3),this.indexArray.emplaceBack(n,r,A+3),o.primitiveLength+=2,void 0===g&&(g=A),!xf(T,s[t],e)){const e=t===s.length-1?g:o.vertexLength;this.indexArray.emplaceBack(A+2,A+3,e),this.indexArray.emplaceBack(A+3,e+1,e),this.indexArray.emplaceBack(A+3,r,e+1),o.primitiveLength+=3}b=!b}if(u){const t=this.layoutVertexExtArray,e=d.projectTilePoint(l.x,l.y,n),i=d.projectTilePoint(h.x,h.y,n),r=d.upVector(n,l.x,l.y),o=d.upVector(n,h.x,h.y);lf(t,e,r),lf(t,e,r),lf(t,i,o),lf(t,i,o)}}h&&(i+=s.length-1),m&&x&&this.zoom>=17&&(0!==_.length&&w(_,_[0])&&_.pop(),this.groundEffect.addData(_,e,l,x>0))}this.footprintSegments.push(a),s.triangleCount=this.indexArray.length-s.triangleArrayOffset,this.polygonSegments.push(s),++f.footprintSegLen,++f.polygonSegLen}if(f.vertexCount=this.layoutVertexArray.length-f.vertexArrayOffset,f.groundVertexCount=this.groundEffect.vertexArray.length-f.groundVertexArrayOffset,0!==f.vertexCount){if(f.centroidXY=p.borders?rf:this.encodeCentroid(p,f),this.centroidData.push(f),p.borders){this.featuresOnBorder.push(p);const t=this.featuresOnBorder.length-1;for(let e=0;ethis.featuresOnBorder[e].borders[t][0]-this.featuresOnBorder[i].borders[t][0]))}splitToSubtiles(){const t=[];for(let e=0;euo),r=2*n+(+(i.min.x+i.max.x>uo)^n);for(let n=0;nt.triangleSegmentIdx===e.triangleSegmentIdx?t.subtile-e.subtile:t.triangleSegmentIdx-e.triangleSegmentIdx));let i=0,n=0,r=0;for(const e of t){if(e.triangleSegmentIdx!==i)break;r++}const o=t.length;for(;n!==t.length;){i=t[n].triangleSegmentIdx;let s=0,a=n,l=n;for(let e=a;e0&&this.triangleSubSegments.push({segment:d,min:o,max:c}),a=l;for(let e=a;e[t[0]*(1-i[0])+e[0]*i[0],t[1]*(1-i[1])+e[1]*i[1]],h=[],p=[];for(const t of this.triangleSubSegments){h[0]=t.min.x/uo,h[1]=t.min.y/uo,p[0]=t.max.x/uo,p[1]=t.max.y/uo;const e=u(l,c,h),o=u(l,c,p);if(0===new wu([e[0],e[1],n],[o[0],o[1],r]).intersectsPrecise(i)){a&&(d.segments.push(a),a=void 0);continue}const s=t.segment;a&&a.vertexOffset!==s.vertexOffset&&(d.segments.push(a),a=void 0),a?(a.vertexLength+=s.vertexLength,a.primitiveLength+=s.primitiveLength):a={vertexOffset:s.vertexOffset,primitiveLength:s.primitiveLength,vertexLength:s.vertexLength,primitiveOffset:s.primitiveOffset,sortKey:void 0,vaos:{}}}return a&&d.segments.push(a),d}encodeCentroid(t,e){const i=t.centroid(),n=e.span(),r=Math.min(7,Math.round(n.x*this.tileToMeter/10)),o=Math.min(7,Math.round(n.y*this.tileToMeter/10));return new Ue(Xe(i.x,1,uo-1)i.max.x||i.min.x>e.max.x||e.min.y>i.max.y||i.min.y>e.max.y))for(let o=0;oe!=l>e&&to.max.x||o.min.x>t||e>o.max.y||o.min.y>e||this.footprintContainsPoint(t,e,o)&&o&&o.height>i&&(i=o.height,this.partLookup[r]=o,n=!!(o.flags&of));if(i!==Number.NEGATIVE_INFINITY)return{height:i,hidden:n};this.partLookup[r]=void 0}}function gf(t,e){const i=t.add(e)._unit();return t.x*i.x+t.y*i.y}function yf(t,e,i,n){const r=e.sub(t)._perp()._unit(),o=i.sub(e)._perp()._unit();return vf(t,e,i,gf(r,o),n)}function vf(t,e,i,n,r){const o=Math.sqrt(1-n*n);return Math.min(t.dist(e)/3,e.dist(i)/3,r*o/n)}function xf(t,e,i){return t.xi[1].x&&e.x>i[1].x||t.yi[1].y&&e.y>i[1].y}function bf(t,e){return t.xe[1].x||t.ye[1].y}function wf(t,e,i){if(t.x=uo||e.x=uo||i.x=uo)return!1;const n=i.sub(e),r=n.perp(),o=t.sub(e);return(n.x*o.x+n.y*o.y)/Math.sqrt((n.x*n.x+n.y*n.y)*(o.x*o.x+o.y*o.y))>-.866&&r.x*o.x+r.y*o.y{for(const i of t)s.push({polygon:i,bounds:e})},l=Math.ceil(Math.log2(i)),c=Math.ceil(Math.log2(n)),d=l-c,u=[];for(let t=0;t0?0:1);for(let t=0;te+1?p.push({polygons:h,bounds:t,depth:e+1}):a(h,t)}if(f.length){const t=[new Ue(0===i?d:n.x,1===i?d:n.y),s];u.length>e+1?p.push({polygons:f,bounds:t,depth:e+1}):a(f,t)}}return s}(t,e,Math.ceil((o-r)/11.25),Math.ceil((s-a)/11.25),1,((t,e,r)=>{if(0===t)return.5*(e+r);{const t=Id((i.y+e/uo)/n);return(Md(.5*(Id((i.y+r/uo)/n)+t))*n-i.y)*uo}}))}function Mf(t,e,i,n,r,o){const s=Math.pow(2,n.z-r.z);for(let a=0;a1&&(s=t[++o]);const l=Math.abs(a-s.left),c=Math.abs(a-s.right),d=Math.min(l,c);let u;const h=e/i*(n+1);if(s.isDash){const t=n-Math.abs(h);u=Math.sqrt(d*d+t*t)}else u=n-Math.sqrt(d*d+h*h);this.image.data[r+a]=Math.max(0,Math.min(255,u+128))}}}addRegularDash(t,e){for(let e=t.length-1;e>=0;--e){const i=t[e],n=t[e+1];i.zeroLength?t.splice(e,1):n&&n.isDash===i.isDash&&(n.left=i.left,t.splice(e,1))}const i=t[0],n=t[t.length-1];i.isDash===n.isDash&&(i.left=n.left-this.width,n.right=i.right+this.width);const r=this.width*this.nextRow;let o=0,s=t[o];for(let i=0;i1&&(s=t[++o]);const n=Math.abs(i-s.left),a=Math.abs(i-s.right),l=Math.min(n,a);this.image.data[r+i]=Math.max(0,Math.min(255,(s.isDash?l:-l)+e+128))}}addDash(t,e){const i=this.getKey(t,e);if(this.positions[i])return this.positions[i];const n="round"===e,r=n?7:0,o=2*r+1;if(this.nextRow+o>this.height)return pi("LineAtlas out of space"),null;0===t.length&&t.push(1);let s=0;for(let e=0;et.fqid)),this.index=t.index,this.projection=t.projection,this.hasPattern=!1,this.hasZOffset=!1,this.patternFeatures=[],this.lineClipsArray=[],this.gradients={},this.layers.forEach((t=>{this.gradients[t.id]={}})),this.layoutVertexArray=new Rl,this.layoutVertexArray2=new Ol,this.patternVertexArray=new Bl,this.indexArray=new Kl,this.programConfigurations=new Yc(t.layers,{zoom:t.zoom,lut:t.lut}),this.segments=new wc,this.maxLineLength=0,this.zOffsetVertexArray=new Zl,this.stateDependentLayerIds=this.layers.filter((t=>t.isStateDependent())).map((t=>t.id)),this.tessellationStep=t.tessellationStep?t.tessellationStep:uo/64}updateFootprints(t,e){}populate(t,e,i,n){this.hasPattern=Hh("line",this.layers,e);const r=this.layers[0].layout.get("line-sort-key"),o=this.layers[0].layout.get("line-z-offset");this.hasZOffset=!o.isConstant()||!!o.constantOr(0);const s=[];for(const{feature:e,id:o,index:a,sourceLayerIndex:l}of t){const t=this.layers[0]._featureFilter.needGeometry,c=Zd(e,t);if(!this.layers[0]._featureFilter.filter(new Ha(this.zoom),c,i))continue;const d=r?r.evaluate(c,{},i):void 0,u={id:o,properties:e.properties,type:e.type,sourceLayerIndex:l,index:a,geometry:t?c.geometry:Gd(e,i,n),patterns:{},sortKey:d};s.push(u)}r&&s.sort(((t,e)=>t.sortKey-e.sortKey));const{lineAtlas:a,featureIndex:l}=e,c=this.addConstantDashes(a);for(const n of s){const{geometry:r,index:o,sourceLayerIndex:s}=n;if(c&&this.addFeatureDashes(n,a),this.hasPattern){const t=Wh("line",this.layers,n,this.zoom,e);this.patternFeatures.push(t)}else this.addFeature(n,r,o,i,a.positions,e.availableImages,e.brightness);l.insert(t[o].feature,r,o,s,this.index)}}addConstantDashes(t){let e=!1;for(const i of this.layers){const n=i.paint.get("line-dasharray").value,r=i.layout.get("line-cap").value;if("constant"!==n.kind||"constant"!==r.kind)e=!0;else{const e=r.value,i=n.value;if(!i)continue;t.addDash(i,e)}}return e}addFeatureDashes(t,e){const i=this.zoom;for(const n of this.layers){const r=n.paint.get("line-dasharray").value,o=n.layout.get("line-cap").value;if("constant"===r.kind&&"constant"===o.kind)continue;let s,a;if("constant"===r.kind){if(s=r.value,!s)continue}else s=r.evaluate({zoom:i},t);a="constant"===o.kind?o.value:o.evaluate({zoom:i},t),e.addDash(s,a),t.patterns[n.id]=e.getKey(s,a)}}update(t,e,i,n,r){const o=0!==Object.keys(t).length;o&&!this.stateDependentLayers.length||this.programConfigurations.updatePaintArrays(t,e,o?this.stateDependentLayers:this.layers,i,n,r)}addFeatures(t,e,i,n,r,o){for(const t of this.patternFeatures)this.addFeature(t,t.geometry,t.index,e,i,n,o)}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(t){this.uploaded||(0!==this.layoutVertexArray2.length&&(this.layoutVertexBuffer2=t.createVertexBuffer(this.layoutVertexArray2,zf)),0!==this.patternVertexArray.length&&(this.patternVertexBuffer=t.createVertexBuffer(this.patternVertexArray,Of)),!this.zOffsetVertexBuffer&&this.zOffsetVertexArray.length>0&&(this.zOffsetVertexBuffer=t.createVertexBuffer(this.zOffsetVertexArray,jf.members,!0)),this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,kf),this.indexBuffer=t.createIndexBuffer(this.indexArray)),this.programConfigurations.upload(t),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.zOffsetVertexBuffer&&this.zOffsetVertexBuffer.destroy(),this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy())}lineFeatureClips(t){if(t.properties&&t.properties.hasOwnProperty("mapbox_clip_start")&&t.properties.hasOwnProperty("mapbox_clip_end"))return{start:+t.properties.mapbox_clip_start,end:+t.properties.mapbox_clip_end}}addFeature(t,e,i,n,r,o,s){const a=this.layers[0].layout,l=a.get("line-join").evaluate(t,{}),c=a.get("line-cap").evaluate(t,{}),d=a.get("line-miter-limit"),u=a.get("line-round-limit");this.lineClips=this.lineFeatureClips(t);for(const i of e)this.addLine(i,t,n,l,c,d,u);this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,t,i,r,o,n,s)}addLine(t,e,i,n,r,o,s){this.distance=0,this.scaledDistance=0,this.totalDistance=0,this.lineSoFar=0,this.currentVertex=void 0;const a={zoom:this.zoom,lineProgress:void 0},l=this.layers[0].layout,c="none"===n;if(this.patternJoinNone=this.hasPattern&&c,this.segmentStart=0,this.segmentStartf32=0,this.segmentPoints=[],this.lineClips){this.lineClipsArray.push(this.lineClips);for(let e=0;e=2&&t[u-1].equals(t[u-2]);)u--;let h=0;for(;h0;if(A&&i>h){const t=m.dist(_);if(t>2*p){const e=m.sub(m.sub(_)._mult(p/t)._round());this.updateDistance(_,e),this.addCurrentVertex(e,y,0,0,f,x),_=e}}if(b&&"round"===w&&(Mo&&(w="bevel"),"bevel"===w&&(M>2&&(w="flipbevel"),M100)S=v.mult(-1);else{const t=M*y.add(v).mag()/y.sub(v).mag();S._perp()._mult(t*(I?-1:1))}this.addCurrentVertex(m,S,0,0,f,x),this.addCurrentVertex(m,S.mult(-1),0,0,f,x)}else if("bevel"===w||"fakeround"===w){const t=-Math.sqrt(M*M-1),e=I?t:0,i=I?0:t;if(_&&this.addCurrentVertex(m,y,e,i,f,x),"fakeround"===w){const t=Math.round(180*C/Math.PI/20);for(let e=1;e2*p){const e=m.add(g.sub(m)._mult(p/t)._round());this.updateDistance(m,e),this.addCurrentVertex(e,v,0,0,f,x),m=e}}}}addVerticesTo(t,e,i,n,r,o,s,a,l,c){const d=(e.w-t.w)/this.tessellationStep|0;if(d>1){this.lineSoFar=t.w;const u=(e.x-t.x)/d,h=(e.y-t.y)/d,p=(e.z-t.z)/d,f=(e.w-t.w)/d;for(let e=1;e=0&&this.e2>=0&&(this.indexArray.emplaceBack(this.e1,this.e2,c),a.primitiveLength++),o?this.e2=c:this.e1=c,null!=l&&this.zOffsetVertexArray.emplaceBack(l)}updateScaledDistance(){if(this.lineClips){const t=this.totalDistance/(this.lineClips.end-this.lineClips.start);this.scaledDistance=this.distance/this.totalDistance,this.lineSoFar=t*this.lineClips.start+this.distance}else this.lineSoFar=this.distance}updateDistance(t,e){this.distance+=t.dist(e),this.updateScaledDistance()}}function Qf(t,e,i){return t.xi||t.yi}ba(Jf,"LineBucket",{omit:["layers","patternFeatures","currentVertex","currentVertexIsOutside"]});const tm=new ol({"line-cap":new nl(sl.layout_line["line-cap"]),"line-join":new nl(sl.layout_line["line-join"]),"line-miter-limit":new il(sl.layout_line["line-miter-limit"]),"line-round-limit":new il(sl.layout_line["line-round-limit"]),"line-sort-key":new nl(sl.layout_line["line-sort-key"]),"line-z-offset":new nl(sl.layout_line["line-z-offset"]),visibility:new il(sl.layout_line.visibility)});var em={paint:new ol({"line-opacity":new nl(sl.paint_line["line-opacity"]),"line-color":new nl(sl.paint_line["line-color"]),"line-translate":new il(sl.paint_line["line-translate"]),"line-translate-anchor":new il(sl.paint_line["line-translate-anchor"]),"line-width":new nl(sl.paint_line["line-width"]),"line-gap-width":new nl(sl.paint_line["line-gap-width"]),"line-offset":new nl(sl.paint_line["line-offset"]),"line-blur":new nl(sl.paint_line["line-blur"]),"line-dasharray":new nl(sl.paint_line["line-dasharray"]),"line-pattern":new nl(sl.paint_line["line-pattern"]),"line-gradient":new rl(sl.paint_line["line-gradient"]),"line-trim-offset":new il(sl.paint_line["line-trim-offset"]),"line-trim-fade-range":new il(sl.paint_line["line-trim-fade-range"]),"line-trim-color":new il(sl.paint_line["line-trim-color"]),"line-emissive-strength":new il(sl.paint_line["line-emissive-strength"]),"line-border-width":new nl(sl.paint_line["line-border-width"]),"line-border-color":new nl(sl.paint_line["line-border-color"]),"line-occlusion-opacity":new il(sl.paint_line["line-occlusion-opacity"])}),layout:tm};function im(t,e,i){return e*(uo/(t.tileSize*Math.pow(2,i-t.tileID.overscaledZ)))}function nm(t,e){return 1/im(t,1,e.tileZoom)}function rm(t,e,i,n){return t.translatePosMatrix(n||e.tileID.projMatrix,e,i.paint.get("line-translate"),i.paint.get("line-translate-anchor"))}const om=t=>{const e=[];sm(t)&&e.push("RENDER_LINE_DASH"),t.paint.get("line-gradient")&&e.push("RENDER_LINE_GRADIENT");const i=t.paint.get("line-trim-offset");0===i[0]&&0===i[1]||e.push("RENDER_LINE_TRIM_OFFSET"),0!==t.paint.get("line-border-width").constantOr(1)&&e.push("RENDER_LINE_BORDER");const n="none"===t.layout.get("line-join").constantOr("miter"),r=!!t.paint.get("line-pattern").constantOr(1);return n&&r&&e.push("LINE_JOIN_NONE"),e};function sm(t){const e=t.paint.get("line-dasharray").value;return e.value||"constant"!==e.kind}class am{constructor(t){this._stringToNumber={},this._numberToString=[];for(let e=0;e>1,d=-7,u=i?r-1:0,h=i?-1:1,p=t[e+u];for(u+=h,o=p&(1>=-d,d+=a;d>0;o=256*o+t[e+u],u+=h,d-=8);for(s=o&(1>=-d,d+=n;d>0;s=256*s+t[e+u],u+=h,d-=8);if(0===o)o=1-c;else{if(o===l)return s?NaN:1/0*(p?-1:1);s+=Math.pow(2,n),o-=c}return(p?-1:1)*s*Math.pow(2,o-n)},write:function(t,e,i,n,r,o){var s,a,l,c=8*o-r-1,d=(1>1,h=23===r?Math.pow(2,-24)-Math.pow(2,-77):0,p=n?0:o-1,f=n?1:-1,m=e=1?h/l:h*Math.pow(2,1-u))*l>=2&&(s++,l/=2),s+u>=d?(a=0,s=d):s+u>=1?(a=(e*l-1)*Math.pow(2,r),s+=u):(a=e*Math.pow(2,u-1)*Math.pow(2,r),s=0));r>=8;t[i+p]=255&a,p+=f,a/=256,r-=8);for(s=s0;t[i+p]=255&s,p+=f,s/=256,c-=8);t[i+p-f]|=128*m}},cm=um,dm=lm;function um(t){this.buf=ArrayBuffer.isView&&ArrayBuffer.isView(t)?t:new Uint8Array(t||0),this.pos=0,this.type=0,this.length=this.buf.length}um.Varint=0,um.Fixed64=1,um.Bytes=2,um.Fixed32=5;var hm=4294967296,pm=1/hm,fm="undefined"==typeof TextDecoder?null:new TextDecoder("utf8");function mm(t){return t.type===um.Bytes?t.readVarint()+t.pos:t.pos+1}function _m(t,e,i){return i?4294967296*e+(t>>>0):4294967296*(e>>>0)+(t>>>0)}function gm(t,e,i){var n=e=t;r--)i.buf[r+n]=i.buf[r]}function ym(t,e){for(var i=0;i>>8,t[i+2]=e>>>16,t[i+3]=e>>>24}function Im(t,e){return(t[e]|t[e+1]>3,o=this.pos;this.type=7&n,t(r,e,this),this.pos===o&&this.skip(n)}return e},readMessage:function(t,e){return this.readFields(t,e,this.readVarint()+this.pos)},readFixed32:function(){var t=Cm(this.buf,this.pos);return this.pos+=4,t},readSFixed32:function(){var t=Im(this.buf,this.pos);return this.pos+=4,t},readFixed64:function(){var t=Cm(this.buf,this.pos)+Cm(this.buf,this.pos+4)*hm;return this.pos+=8,t},readSFixed64:function(){var t=Cm(this.buf,this.pos)+Im(this.buf,this.pos+4)*hm;return this.pos+=8,t},readFloat:function(){var t=dm.read(this.buf,this.pos,!0,23,4);return this.pos+=4,t},readDouble:function(){var t=dm.read(this.buf,this.pos,!0,52,8);return this.pos+=8,t},readVarint:function(t){var e,i,n=this.buf;return e=127&(i=n[this.pos++]),i>4,r=12&&fm?function(t,e,i){return fm.decode(t.subarray(e,i))}(this.buf,e,t):function(t,e,i){for(var n="",r=e;r239?4:l>223?3:l>191?2:1;if(r+d>i)break;1===d?l=55296&&c=1114112)&&(c=null)),null===c?(c=65533,d=1):c>65535&&(c-=65536,n+=String.fromCharCode(c>>>10&1023|55296),c=56320|1023&c),n+=String.fromCharCode(c),r+=d}return n}(this.buf,e,t)},readBytes:function(){var t=this.readVarint()+this.pos,e=this.buf.subarray(this.pos,t);return this.pos=t,e},readPackedVarint:function(t,e){if(this.type!==um.Bytes)return t.push(this.readVarint(e));var i=mm(this);for(t=t||[];this.pos127;);else if(e===um.Bytes)this.pos=this.readVarint()+this.pos;else if(e===um.Fixed32)this.pos+=4;else{if(e!==um.Fixed64)throw new Error("Unimplemented type: "+e);this.pos+=8}},writeTag:function(t,e){this.writeVarint(t268435455||t=0?(i=t%4294967296|0,n=t/4294967296|0):(n=~(-t/4294967296),4294967295^(i=~(-t%4294967296))?i=i+1|0:(i=0,n=n+1|0)),t>=0x10000000000000000||t>>=7,i.buf[i.pos++]=127&t|128,t>>>=7,i.buf[i.pos++]=127&t|128,t>>>=7,i.buf[i.pos++]=127&t|128,i.buf[i.pos]=127&(t>>>=7)}(i,0,e),function(t,e){var i=(7&t)>>=3)?128:0),t&&(e.buf[e.pos++]=127&t|((t>>>=7)?128:0),t&&(e.buf[e.pos++]=127&t|((t>>>=7)?128:0),t&&(e.buf[e.pos++]=127&t|((t>>>=7)?128:0),t&&(e.buf[e.pos++]=127&t|((t>>>=7)?128:0),t&&(e.buf[e.pos++]=127&t)))))}(n,e)}(t,this):(this.realloc(4),this.buf[this.pos++]=127&t|(t>127?128:0),t>>=7)|(t>127?128:0),t>>=7)|(t>127?128:0),t>>7&127))))},writeSVarint:function(t){this.writeVarint(t55295&&n56319||o+1===e.length?(t[i++]=239,t[i++]=191,t[i++]=189):r=n;continue}if(n>6|192:(n>12|224:(t[i++]=n>>18|240,t[i++]=n>>12&63|128),t[i++]=n>>6&63|128),t[i++]=63&n|128)}return i}(this.buf,t,this.pos);var i=this.pos-e;i>=128&&gm(e,i,this),this.pos=e-1,this.writeVarint(i),this.pos+=i},writeFloat:function(t){this.realloc(4),dm.write(this.buf,t,this.pos,!0,23,4),this.pos+=4},writeDouble:function(t){this.realloc(8),dm.write(this.buf,t,this.pos,!0,52,8),this.pos+=8},writeBytes:function(t){var e=t.length;this.writeVarint(e),this.realloc(e);for(var i=0;i=128&&gm(i,n,this),this.pos=i-1,this.writeVarint(n),this.pos+=n},writeMessage:function(t,e,i){this.writeTag(t,um.Bytes),this.writeRawMessage(e,i)},writePackedVarint:function(t,e){e.length&&this.writeMessage(t,ym,e)},writePackedSVarint:function(t,e){e.length&&this.writeMessage(t,vm,e)},writePackedBoolean:function(t,e){e.length&&this.writeMessage(t,wm,e)},writePackedFloat:function(t,e){e.length&&this.writeMessage(t,xm,e)},writePackedDouble:function(t,e){e.length&&this.writeMessage(t,bm,e)},writePackedFixed32:function(t,e){e.length&&this.writeMessage(t,Tm,e)},writePackedSFixed32:function(t,e){e.length&&this.writeMessage(t,Sm,e)},writePackedFixed64:function(t,e){e.length&&this.writeMessage(t,Em,e)},writePackedSFixed64:function(t,e){e.length&&this.writeMessage(t,Mm,e)},writeBytesField:function(t,e){this.writeTag(t,um.Bytes),this.writeBytes(e)},writeFixed32Field:function(t,e){this.writeTag(t,um.Fixed32),this.writeFixed32(e)},writeSFixed32Field:function(t,e){this.writeTag(t,um.Fixed32),this.writeSFixed32(e)},writeFixed64Field:function(t,e){this.writeTag(t,um.Fixed64),this.writeFixed64(e)},writeSFixed64Field:function(t,e){this.writeTag(t,um.Fixed64),this.writeSFixed64(e)},writeVarintField:function(t,e){this.writeTag(t,um.Varint),this.writeVarint(e)},writeSVarintField:function(t,e){this.writeTag(t,um.Varint),this.writeSVarint(e)},writeStringField:function(t,e){this.writeTag(t,um.Bytes),this.writeString(e)},writeFloatField:function(t,e){this.writeTag(t,um.Fixed32),this.writeFloat(e)},writeDoubleField:function(t,e){this.writeTag(t,um.Fixed64),this.writeDouble(e)},writeBooleanField:function(t,e){this.writeVarintField(t,Boolean(e))}};var Lm=h(cm);const Pm=["id","tile","layer","source","sourceLayer","state"];class $m{constructor(t,e,i,n,r){this.type="Feature",this._vectorTileFeature=t,this._z=e,this._x=i,this._y=n,this.properties=t.properties,this.id=r}get geometry(){return void 0===this._geometry&&(this._geometry=this._vectorTileFeature.toGeoJSON(this._x,this._y,this._z).geometry),this._geometry}set geometry(t){this._geometry=t}toJSON(){const t={type:"Feature",state:void 0,geometry:this.geometry,properties:this.properties};for(const e of Pm)void 0!==this[e]&&(t[e]=this[e]);return t}}class km{constructor(){this.state={},this.stateChanges={},this.deletedStates={}}updateState(t,e,i){const n=String(e);if(this.stateChanges[t]=this.stateChanges[t]||{},this.stateChanges[t][n]=this.stateChanges[t][n]||{},ei(this.stateChanges[t][n],i),null===this.deletedStates[t]){this.deletedStates[t]={};for(const e in this.state[t])e!==n&&(this.deletedStates[t][e]=null)}else if(this.deletedStates[t]&&null===this.deletedStates[t][n]){this.deletedStates[t][n]={};for(const e in this.state[t][n])i[e]||(this.deletedStates[t][n][e]=null)}else for(const e in i)this.deletedStates[t]&&this.deletedStates[t][n]&&null===this.deletedStates[t][n][e]&&delete this.deletedStates[t][n][e]}removeFeatureState(t,e,i){if(null===this.deletedStates[t])return;const n=String(e);if(this.deletedStates[t]=this.deletedStates[t]||{},i&&void 0!==e)null!==this.deletedStates[t][n]&&(this.deletedStates[t][n]=this.deletedStates[t][n]||{},this.deletedStates[t][n][i]=null);else if(void 0!==e)if(this.stateChanges[t]&&this.stateChanges[t][n])for(i in this.deletedStates[t][n]={},this.stateChanges[t][n])this.deletedStates[t][n][i]=null;else this.deletedStates[t][n]=null;else this.deletedStates[t]=null}getState(t,e){const i=String(e),n=ei({},(this.state[t]||{})[i],(this.stateChanges[t]||{})[i]);if(null===this.deletedStates[t])return{};if(this.deletedStates[t]){const i=this.deletedStates[t][e];if(null===i)return{};for(const t in i)delete n[t]}return n}initializeTileState(t,e){t.setFeatureState(this.state,e)}coalesceChanges(t,e){const i={};for(const t in this.stateChanges){this.state[t]=this.state[t]||{};const e={};for(const i in this.stateChanges[t])this.state[t][i]||(this.state[t][i]={}),ei(this.state[t][i],this.stateChanges[t][i]),e[i]=this.state[t][i];i[t]=e}for(const t in this.deletedStates){this.state[t]=this.state[t]||{};const e={};if(null===this.deletedStates[t])for(const i in this.state[t])e[i]={},this.state[t][i]={};else for(const i in this.deletedStates[t]){if(null===this.deletedStates[t][i])this.state[t][i]={};else if(this.state[t][i])for(const e of Object.keys(this.deletedStates[t][i]))delete this.state[t][i][e];e[i]=this.state[t][i]}i[t]=i[t]||{},ei(i[t],e)}if(this.stateChanges={},this.deletedStates={},0!==Object.keys(i).length)for(const n in t)t[n].setFeatureState(i,e)}}class Dm{constructor(t,e){this.tileID=t,this.x=t.canonical.x,this.y=t.canonical.y,this.z=t.canonical.z,this.grid=new va(uo,16,0),this.featureIndexArray=new yc,this.promoteId=e,this.is3DTile=!1}insert(t,e,i,n,r,o=0,s=0){const a=this.featureIndexArray.length;this.featureIndexArray.emplaceBack(i,n,r,o);const l=this.grid;for(let t=0;t=0&&n[3]>=0&&l.insert(a,n[0],n[1],n[2],n[3])}}loadVTLayers(){if(!this.vtLayers){this.vtLayers=new bp(new Lm(this.rawTileData)).layers,this.sourceLayerCoder=new am(this.vtLayers?Object.keys(this.vtLayers).sort():["_geojsonTileLayer"]),this.vtFeatures={};for(const t in this.vtLayers)this.vtFeatures[t]=[]}return this.vtLayers}query(t,e,i,n){this.loadVTLayers();const r=t.params||{},o=dl(r.filter),s=t.tileResult,a=t.transform,l=s.bufferedTilespaceBounds,c=this.grid.query(l.min.x,l.min.y,l.max.x,l.max.y,((t,e,i,n)=>ou(s.bufferedTilespaceGeometry,t,e,i,n)));c.sort(Rm);let d=null;a.elevation&&c.length>0&&(d=Xp.create(a.elevation,this.tileID));const u={};let h;for(let l=0;l(m||(m=Gd(e,this.tileID.canonical,t.tileTransform)),i.queryIntersectsFeature(s,e,n,m,this.z,t.transform,t.pixelPosMatrix,d,r))))}return u}loadMatchingFeature(t,e,i,n,r,o,s,a,l){const{featureIndex:c,bucketIndex:d,sourceLayerIndex:u,layoutVertexArrayOffset:h}=e,p=this.bucketLayerIDs[d];if(n&&!function(t,e){for(let i=0;i=0)return!0;return!1}(n,p))return;const f=this.sourceLayerCoder.decode(u),m=this.vtLayers[f].feature(c);if(i.needGeometry){const t=Zd(m,!0);if(!i.filter(new Ha(this.tileID.overscaledZ),t,this.tileID.canonical))return}else if(!i.filter(new Ha(this.tileID.overscaledZ),m))return;const _=this.getId(m,f);for(let e=0;e{const s=e instanceof el?e.get(o):null;return s&&s.evaluate?s.evaluate(i,n,r):s}))}function Rm(t,e){return e-t}ba(Dm,"FeatureIndex",{omit:["rawTileData","sourceLayerCoder"]});var Om=24;const Bm=128;function Fm(t,e){const{expression:i}=e;if("constant"===i.kind)return{kind:"constant",layoutSize:i.evaluate(new Ha(t+1))};if("source"===i.kind)return{kind:"source"};{const{zoomStops:e,interpolationType:n}=i;let r=0;for(;r{t.text=function(t,e,i){const n=e.layout.get("text-transform").evaluate(i,{});return"uppercase"===n?t=t.toLocaleUpperCase():"lowercase"===n&&(t=t.toLocaleLowerCase()),qa.applyArabicShaping&&(t=qa.applyArabicShaping(t)),t}(t.text,e,i)})),t}const Gm={"!":"︕","#":"#",$:"$","%":"%","&":"&","(":"︵",")":"︶","*":"*","+":"+",",":"︐","-":"︲",".":"・","/":"/",":":"︓",";":"︔","":"﹀","?":"︖","@":"@","[":"﹇","\\":"\","]":"﹈","^":"^",_:"︳","`":"`","{":"︷","|":"―","}":"︸","~":"~","¢":"¢","£":"£","¥":"¥","¦":"¦","¬":"¬","¯":" ̄","–":"︲","—":"︱","‘":"﹃","’":"﹄","“":"﹁","”":"﹂","…":"︙","‧":"・","₩":"₩","、":"︑","。":"︒","〈":"︿","〉":"﹀","《":"︽","》":"︾","「":"﹁","」":"﹂","『":"﹃","』":"﹄","【":"︻","】":"︼","〔":"︹","〕":"︺","〖":"︗","〗":"︘","!":"︕","(":"︵",")":"︶",",":"︐","-":"︲",".":"・",":":"︓",";":"︔","<":"︿",">":"﹀","?":"︖","[":"﹇","]":"﹈","_":"︳","{":"︷","|":"―","}":"︸","⦅":"︵","⦆":"︶","。":"︒","「":"﹁","」":"﹂","←":"↑","→":"↓"};function Zm(t){return"︶"===t||"﹈"===t||"︸"===t||"﹄"===t||"﹂"===t||"︾"===t||"︼"===t||"︺"===t||"︘"===t||"﹀"===t||"︐"===t||"︓"===t||"︔"===t||"`"===t||" ̄"===t||"︑"===t||"︒"===t}function qm(t){return"︵"===t||"﹇"===t||"︷"===t||"﹃"===t||"﹁"===t||"︽"===t||"︻"===t||"︹"===t||"︗"===t||"︿"===t}const Hm=3;function Wm(t,e,i){e.glyphs=[],1===t&&i.readMessage(Ym,e)}function Ym(t,e,i){if(3===t){const{id:t,bitmap:n,width:r,height:o,left:s,top:a,advance:l}=i.readMessage(Xm,{});e.glyphs.push({id:t,bitmap:new dh({width:r+2*Hm,height:o+2*Hm},n),metrics:{width:r,height:o,left:s,top:a,advance:l}})}else 4===t?e.ascender=i.readSVarint():5===t&&(e.descender=i.readSVarint())}function Xm(t,e,i){1===t?e.id=i.readVarint():2===t?e.bitmap=i.readBytes():3===t?e.width=i.readVarint():4===t?e.height=i.readVarint():5===t?e.left=i.readSVarint():6===t?e.top=i.readSVarint():7===t&&(e.advance=i.readVarint())}const Km=Hm,Jm={horizontal:1,vertical:2,horizontalOnly:3};class Qm{constructor(){this.scale=1,this.fontStack="",this.imageName=null}static forText(t,e){const i=new Qm;return i.scale=t||1,i.fontStack=e,i}static forImage(t){const e=new Qm;return e.imageName=t,e}}class t_{constructor(){this.text="",this.sectionIndex=[],this.sections=[],this.imageSectionID=null}static fromFeature(t,e){const i=new t_;for(let n=0;n=0&&i>=t&&i_[this.text.charCodeAt(i)];i--)e--;this.text=this.text.substring(t,e),this.sectionIndex=this.sectionIndex.slice(t,e)}substring(t,e){const i=new t_;return i.text=this.text.substring(t,e),i.sectionIndex=this.sectionIndex.slice(t,e),i.sections=this.sections,i}toString(){return this.text}getMaxScale(){return this.sectionIndex.reduce(((t,e)=>Math.max(t,this.sections[e].scale)),0)}addTextSection(t,e){this.text+=t.text,this.sections.push(Qm.forText(t.scale,t.fontStack||e));const i=this.sections.length-1;for(let e=0;e=63743?null:++this.imageSectionID:(this.imageSectionID=57344,this.imageSectionID)}}function e_(t,e,i,n,r,o,s,a,l,c,d,u,h,p,f){const m=t_.fromFeature(t,r);u===Jm.vertical&&m.verticalizePunctuation(h);let _=[];const g=function(t,e,i,n,r,o){if(!t)return[];const s=[],a=function(t,e,i,n,r,o){let s=0;for(let i=0;i=0;let c=0;for(let i=0;i0&&o>b&&(b=o)}else{const t=i[a.fontStack];if(!t)continue;t[m]&&(S=t[m]);const n=e[a.fontStack];if(!n)continue;const o=n.glyphs[m];if(!o)continue;if(v=o.metrics,M=8203!==m?Om:0,_){const t=void 0!==n.ascender?Math.abs(n.ascender):0,e=void 0!==n.descender?Math.abs(n.descender):0,i=(t+e)*g;w-i/2;){if(s--,sn;)c-=l.shift().angleDelta;if(c>r)return!1;s++,a+=e.dist(i)}return!0}function m_(t){let e=0;for(let i=0;ic){const d=(c-l)/o,u=Vn(n.x,r.x,d),h=Vn(n.y,r.y,d),p=new p_(u,h,0,r.angleTo(n),i);return!s||f_(t,p,a,s,e)?p:void 0}l+=o}}function v_(t,e,i,n,r,o,s,a,l){const c=__(n,o,s),d=g_(n,r),u=d*s,h=0===t[0].x||t[0].x===l||0===t[0].y||t[0].y===l;return e-u=0&&g=0&&y=0&&h+c=n&&c.x>=n||(s.x>=n?s=new Ue(n,s.y+(n-s.x)/(c.x-s.x)*(c.y-s.y))._round():c.x>=n&&(c=new Ue(n,s.y+(n-s.x)/(c.x-s.x)*(c.y-s.y))._round()),s.y>=r&&c.y>=r||(s.y>=r?s=new Ue(s.x+(r-s.y)/(c.y-s.y)*(c.x-s.x),r)._round():c.y>=r&&(c=new Ue(s.x+(r-s.y)/(c.y-s.y)*(c.x-s.x),r)._round()),l&&s.equals(l[l.length-1])||(l=[s],o.push(l)),l.push(c)))))}}return o}function w_(t){let e=0,i=0;for(const n of t)e+=n.w*n.h,i=Math.max(i,n.w);t.sort(((t,e)=>e.h-t.h));const n=[{x:0,y:0,w:Math.max(Math.ceil(Math.sqrt(e/.95)),i),h:1/0}];let r=0,o=0;for(const e of t)for(let t=n.length-1;t>=0;t--){const i=n[t];if(!(e.w>i.w||e.h>i.h)){if(e.x=i.x,e.y=i.y,o=Math.max(o,e.y+e.h),r=Math.max(r,e.x+e.w),e.w===i.w&&e.h===i.h){const e=n.pop();tt.hasImage(e,i))),t.dispatchRenderCallbacks(this.haveRenderCallbacks,i);for(const n in t.getUpdatedImages(i))this.patchUpdatedImage(this.iconPositions[n],t.getImage(n,i),e),this.patchUpdatedImage(this.patternPositions[n],t.getImage(n,i),e)}patchUpdatedImage(t,e,i){if(!t||!e)return;if(t.version===e.version)return;t.version=e.version;const[n,r]=t.tl,o=!!Object.keys(this.patternPositions).length;i.update(e.data,{useMipmap:o},{x:n,y:r})}}ba(S_,"ImagePosition"),ba(E_,"ImageAtlas");const M_=1e20;function C_(t,e,i,n,r,o,s,a,l){for(let c=e;c-1);l++,o[l]=a,s[l]=c,s[l+1]=M_}for(let a=0,l=0;a{let n=this.entries[t];n||(n=this.entries[t]={glyphs:{},requests:{},ranges:{},ascender:void 0,descender:void 0});let r=n.glyphs[e];if(void 0!==r)return void i(null,{stack:t,id:e,glyph:r});if(r=this._tinySDF(n,t,e),r)return n.glyphs[e]=r,void i(null,{stack:t,id:e,glyph:r});const s=Math.floor(e/256);if(256*s>65535)return void i(new Error("glyphs > 65535 not supported"));if(n.ranges[s])return void i(null,{stack:t,id:e,glyph:r});let a=n.requests[s];a||(a=n.requests[s]=[],P_.loadGlyphRange(t,s,o,this.requestManager,((t,e)=>{if(e){n.ascender=e.ascender,n.descender=e.descender;for(const t in e.glyphs)this._doesCharSupportLocalGlyph(+t)||(n.glyphs[+t]=e.glyphs[+t]);n.ranges[s]=!0}for(const i of a)i(t,e);delete n.requests[s]}))),a.push(((n,r)=>{n?i(n):r&&i(null,{stack:t,id:e,glyph:r.glyphs[e]||null})}))}),((t,e)=>{if(t)i(t);else if(e){const t={};for(const{stack:i,id:n,glyph:r}of e)void 0===t[i]&&(t[i]={}),void 0===t[i].glyphs&&(t[i].glyphs={}),t[i].glyphs[n]=r&&{id:r.id,bitmap:r.bitmap.clone(),metrics:r.metrics},t[i].ascender=this.entries[i].ascender,t[i].descender=this.entries[i].descender;i(null,t)}}))}_doesCharSupportLocalGlyph(t){return this.localGlyphMode!==L_.none&&(this.localGlyphMode===L_.all?!!this.localFontFamily:!!this.localFontFamily&&(Ma["CJK Unified Ideographs"](t)||Ma["Hangul Syllables"](t)||Ma.Hiragana(t)||Ma.Katakana(t)||Ma["CJK Symbols and Punctuation"](t)||Ma["CJK Unified Ideographs Extension A"](t)||Ma["CJK Unified Ideographs Extension B"](t)))}_tinySDF(t,e,i){const n=this.localFontFamily;if(!n||!this._doesCharSupportLocalGlyph(i))return;let r=t.tinySDF;if(!r){let i="400";/bold/i.test(e)?i="900":/medium/i.test(e)?i="500":/light/i.test(e)&&(i="200"),r=t.tinySDF=new P_.TinySDF({fontFamily:n,fontWeight:i,fontSize:24*I_,buffer:3*I_,radius:8*I_}),r.fontWeight=i}if(this.localGlyphs[r.fontWeight][i])return this.localGlyphs[r.fontWeight][i];const o=String.fromCodePoint(i),{data:s,width:a,height:l,glyphWidth:c,glyphHeight:d,glyphLeft:u,glyphTop:h,glyphAdvance:p}=r.draw(o);return this.localGlyphs[r.fontWeight][i]={id:i,bitmap:new dh({width:a,height:l},s),metrics:{width:c/I_,height:d/I_,left:u/I_,top:h/I_-27,advance:p/I_,localGlyph:!0}}}}P_.loadGlyphRange=function(t,e,i,n,r){const o=256*e,s=o+255,a=n.transformRequest(n.normalizeGlyphsURL(i).replace("{fontstack}",t).replace("{range}",`${o}-${s}`),Ki.Glyphs);en(a,((t,e)=>{if(t)r(t);else if(e){const t={},i=function(t){return new Lm(t).readFields(Wm,{})}(e);for(const e of i.glyphs)t[e.id]=e;r(null,{glyphs:t,ascender:i.ascender,descender:i.descender})}}))},P_.TinySDF=class{constructor({fontSize:t=24,buffer:e=3,radius:i=8,cutoff:n=.25,fontFamily:r="sans-serif",fontWeight:o="normal",fontStyle:s="normal"}={}){this.buffer=e,this.cutoff=n,this.radius=i;const a=this.size=t+4*e,l=this._createCanvas(a),c=this.ctx=l.getContext("2d",{willReadFrequently:!0});c.font=`${s} ${o} ${t}px ${r}`,c.textBaseline="alphabetic",c.textAlign="left",c.fillStyle="black",this.gridOuter=new Float64Array(a*a),this.gridInner=new Float64Array(a*a),this.f=new Float64Array(a),this.z=new Float64Array(a+1),this.v=new Uint16Array(a)}_createCanvas(t){const e=document.createElement("canvas");return e.width=e.height=t,e}draw(t){const{width:e,actualBoundingBoxAscent:i,actualBoundingBoxDescent:n,actualBoundingBoxLeft:r,actualBoundingBoxRight:o}=this.ctx.measureText(t),s=Math.ceil(i),a=Math.max(0,Math.min(this.size-this.buffer,Math.ceil(o-r))),l=Math.min(this.size-this.buffer,s+Math.ceil(n)),c=a+2*this.buffer,d=l+2*this.buffer,u=Math.max(c*d,0),h=new Uint8ClampedArray(u),p={data:h,width:c,height:d,glyphWidth:a,glyphHeight:l,glyphTop:s,glyphLeft:0,glyphAdvance:e};if(0===a||0===l)return p;const{ctx:f,buffer:m,gridInner:_,gridOuter:g}=this;f.clearRect(m,m,a,l),f.fillText(t,m,m+s);const y=f.getImageData(m,m,a,l);g.fill(M_,0,u),_.fill(0,0,u);for(let t=0;t0?t*t:0,_[n]=tt+e[1]-e[0],f=u.reduce(p,0),m=h.reduce(p,0),_=a-f,g=l-m;let y=0,v=f,x=0,b=m,w=0,T=_,S=0,E=g;if(o.content&&n){const t=o.content;y=D_(u,0,t[0]),x=D_(h,0,t[1]),v=D_(u,t[0],t[2]),b=D_(h,t[1],t[3]),w=t[0]-y,S=t[1]-x,T=t[2]-t[0]-v,E=t[3]-t[1]-b}const M=(n,r,a,l)=>{const u=R_(n.stretch-y,v,c,t.left),h=O_(n.fixed-w,T,n.stretch,f),p=R_(r.stretch-x,b,d,t.top),_=O_(r.fixed-S,E,r.stretch,m),g=R_(a.stretch-y,v,c,t.left),M=O_(a.fixed-w,T,a.stretch,f),C=R_(l.stretch-x,b,d,t.top),A=O_(l.fixed-S,E,l.stretch,m),I=new Ue(u,p),L=new Ue(g,p),P=new Ue(g,C),$=new Ue(u,C),k=new Ue(h/s,_/s),D=new Ue(M/s,A/s),z=e*Math.PI/180;if(z){const t=Math.sin(z),e=Math.cos(z),i=[e,-t,t,e];I._matMult(i),L._matMult(i),$._matMult(i),P._matMult(i)}const R=n.stretch+n.fixed,O=a.stretch+a.fixed,B=r.stretch+r.fixed,F=l.stretch+l.fixed,N=t.imageSecondary;return{tl:I,tr:L,bl:$,br:P,texPrimary:{x:o.paddedRect.x+$_+R,y:o.paddedRect.y+$_+B,w:O-R,h:F-B},texSecondary:N?{x:N.paddedRect.x+$_+R,y:N.paddedRect.y+$_+B,w:O-R,h:F-B}:void 0,writingMode:void 0,glyphOffset:[0,0],sectionIndex:0,pixelOffsetTL:k,pixelOffsetBR:D,minFontScaleX:T/s/c,minFontScaleY:E/s/d,isSDF:i}};if(n&&(o.stretchX||o.stretchY)){const t=z_(u,_,f),e=z_(h,g,m);for(let i=0;io)&&(o=e.x),(!t||e.y>s)&&(s=e.y)}const l=Math.min(o-n,s-r);let c=l/2;const d=new co([],N_);if(0===l)return new Ue(n,r);for(let e=n;eu.d||!u.d)&&(u=n,i&&console.log("found best %d after %d probes",Math.round(1e4*n.d)/1e4,h)),n.max-u.dt.y!=a.y>t.y&&t.x18&&P>2&&(P>>=1),Math.max(uo/(512*P),1)*_.get("symbol-spacing")),S=_.get("text-padding")*t.tilePixelRatio,E=_.get("icon-padding")*t.tilePixelRatio,M=Ge(_.get("text-max-angle")),C="map"===_.get("text-rotation-alignment")&&"point"!==_.get("symbol-placement"),A="map"===_.get("icon-rotation-alignment")&&"point"!==_.get("symbol-placement"),I=_.get("symbol-placement"),L=T/2;var P;const $=_.get("icon-text-fit").evaluate(e,{},u),k=_.get("icon-text-fit-padding").evaluate(e,{},u),D="none"!==$;let z;!1===t.hasAnyIconTextFit&&D&&(t.hasAnyIconTextFit=!0),n&&D&&(t.allowVerticalPlacement&&i.vertical&&(z=h_(n,i.vertical,$,k,g,b)),y&&(n=h_(n,y,$,k,g,b)));const R=(s,a,m)=>{if(a.x=uo||a.y=uo)return;let _=null;if(v){const{x:t,y:e,z:i}=h.projectTilePoint(a.x,a.y,m);_={anchor:new p_(t,e,i,0,void 0),up:h.upVector(m,a.x,a.y)}}!function(t,e,i,n,r,o,s,a,l,c,d,u,h,p,f,m,_,g,y,v,x,b,w,T,S,E,M){const C=t.addToLineVertexArray(e,n);let A,I,L,P,$,k,D,z=0,R=0,O=0,B=0,F=-1,N=-1;const U={};let j=Ln("");const V=i?i.anchor:e,G="none"!==l.layout.get("icon-text-fit").evaluate(x,{},S);let Z=0,q=0;if(void 0===l._unevaluatedLayout.getValue("text-radial-offset")?[Z,q]=l.layout.get("text-offset").evaluate(x,{},S).map((t=>t*Om)):(Z=l.layout.get("text-radial-offset").evaluate(x,{},S)*Om,q=j_),t.allowVerticalPlacement&&r.vertical){const t=r.vertical;if(f)k=J_(t),a&&(D=J_(a));else{const i=l.layout.get("text-rotate").evaluate(x,{},S)+90;L=K_(c,V,e,d,u,h,t,p,i,m),a&&(P=K_(c,V,e,d,u,h,a,g,i))}}if(o){const n=l.layout.get("icon-rotate").evaluate(x,{},S),r=k_(o,n,w,G),s=a?k_(a,n,w,G):void 0;I=K_(c,V,e,d,u,h,o,g,n),z=4*r.length;const p=t.iconSizeData;let f=null;"source"===p.kind?(f=[Bm*l.layout.get("icon-size").evaluate(x,{},S)],f[0]>W_&&pi(`${t.layerIds[0]}: Value for "icon-size" is >= ${H_}. Reduce your "icon-size".`)):"composite"===p.kind&&(f=[Bm*b.compositeIconSizes[0].evaluate(x,{},S),Bm*b.compositeIconSizes[1].evaluate(x,{},S)],(f[0]>W_||f[1]>W_)&&pi(`${t.layerIds[0]}: Value for "icon-size" is >= ${H_}. Reduce your "icon-size".`)),t.addSymbols(t.icon,r,f,v,y,x,!1,i,e,C.lineStartIndex,C.lineLength,-1,T,S,E,M),F=t.icon.placedSymbolArray.length-1,s&&(R=4*s.length,t.addSymbols(t.icon,s,f,v,y,x,Jm.vertical,i,e,C.lineStartIndex,C.lineLength,-1,T,S,E,M),N=t.icon.placedSymbolArray.length-1)}for(const n in r.horizontal){const o=r.horizontal[n];A||(j=Ln(o.text),f?$=J_(o):A=K_(c,V,e,d,u,h,o,p,l.layout.get("text-rotate").evaluate(x,{},S),m));const a=1===o.positionedLines.length;if(O+=Y_(t,i,e,o,s,l,f,x,m,C,r.vertical?Jm.horizontal:Jm.horizontalOnly,a?Object.keys(r.horizontal):[n],U,F,b,T,S,E),a)break}r.vertical&&(B+=Y_(t,i,e,r.vertical,s,l,f,x,m,C,Jm.vertical,["vertical"],U,N,b,T,S,E));let H=-1;const W=(t,e)=>t?Math.max(t,e):e;H=W($,H),H=W(k,H),H=W(D,H);const Y=H>-1?1:0;t.glyphOffsetArray.length>=65535&&pi("Too many glyphs being rendered in a tile. See https://github.com/mapbox/mapbox-gl-js/issues/2907"),void 0!==x.sortKey&&t.addToSortKeyRanges(t.symbolInstances.length,x.sortKey),t.symbolInstances.emplaceBack(e.x,e.y,V.x,V.y,V.z,U.right>=0?U.right:-1,U.center>=0?U.center:-1,U.left>=0?U.left:-1,U.vertical>=0?U.vertical:-1,F,N,j,void 0!==A?A:t.collisionBoxArray.length,void 0!==A?A+1:t.collisionBoxArray.length,void 0!==L?L:t.collisionBoxArray.length,void 0!==L?L+1:t.collisionBoxArray.length,void 0!==I?I:t.collisionBoxArray.length,void 0!==I?I+1:t.collisionBoxArray.length,P||t.collisionBoxArray.length,P?P+1:t.collisionBoxArray.length,d,O,B,z,R,Y,0,Z,q,H,0,1,1,G?1:0)}(t,a,_,s,i,n,r,z,t.layers[0],t.collisionBoxArray,e.index,e.sourceLayerIndex,t.index,S,C,l,0,E,A,g,e,o,c,d,u,p,f)};if("line"===I)for(const r of b_(e.geometry,0,0,uo,uo)){const e=v_(r,T,M,i.vertical||y,n,x,w,t.overscaling,uo);for(const i of e)y&&Q_(t,y.text,L,i)||R(r,i,u)}else if("line-center"===I){for(const t of e.geometry)if(t.length>1){const e=y_(t,M,i.vertical||y,n,x,w);e&&R(t,e,u)}}else if("Polygon"===e.type)for(const t of Zh(e.geometry,0)){const e=F_(t,16);R(t[0],new p_(e.x,e.y,0,0,void 0),u)}else if("LineString"===e.type)for(const t of e.geometry)R(t,new p_(t[0].x,t[0].y,0,0,void 0),u);else if("Point"===e.type)for(const t of e.geometry)for(const e of t)R([e],new p_(e.x,e.y,0,0,void 0),u)}const H_=255,W_=H_*Bm;function Y_(t,e,i,n,r,o,s,a,l,c,d,u,h,p,f,m,_,g){const y=function(t,e,i,n,r,o,s,a){const l=[];if(0===e.positionedLines.length)return l;const c=n.layout.get("text-rotate").evaluate(o,{})*Math.PI/180,d=function(t){const e=t[0],i=t[1],n=e*i;return n>0?[e,-i]:nW_&&pi(`${t.layerIds[0]}: Value for "text-size" is >= ${H_}. Reduce your "text-size".`)):"composite"===v.kind&&(x=[Bm*f.compositeTextSizes[0].evaluate(a,{},_),Bm*f.compositeTextSizes[1].evaluate(a,{},_)],(x[0]>W_||x[1]>W_)&&pi(`${t.layerIds[0]}: Value for "text-size" is >= ${H_}. Reduce your "text-size".`)),t.addSymbols(t.text,y,x,l,s,a,d,e,i,c.lineStartIndex,c.lineLength,p,m,_,g,!1);for(const e of u)h[e]=t.text.placedSymbolArray.length-1;return 4*y.length}function X_(t){for(const e in t)return t[e];return null}function K_(t,e,i,n,r,o,s,a,l,c){let d=s.top,u=s.bottom,h=s.left,p=s.right;const f=s.collisionPadding;if(f&&(h-=f[0],d-=f[1],p+=f[2],u+=f[3]),l){const t=new Ue(h,d),e=new Ue(p,d),i=new Ue(h,u),n=new Ue(p,u),r=Ge(l);let o=new Ue(0,0);c&&(o=new Ue(c[0],c[1])),t._rotateAround(r,o),e._rotateAround(r,o),i._rotateAround(r,o),n._rotateAround(r,o),h=Math.min(t.x,e.x,i.x,n.x),p=Math.max(t.x,e.x,i.x,n.x),d=Math.min(t.y,e.y,i.y,n.y),u=Math.max(t.y,e.y,i.y,n.y)}return t.emplaceBack(e.x,e.y,e.z,i.x,i.y,h,d,p,u,a,n,r,o),t.length-1}function J_(t){t.collisionPadding&&(t.top-=t.collisionPadding[1],t.bottom+=t.collisionPadding[3]);const e=t.bottom-t.top;return e>0?Math.max(10,e):null}function Q_(t,e,i,n){const r=t.compareText;if(e in r){const t=r[e];for(let e=t.length-1;e>=0;e--)if(n.dist(t[e])v&&(x(t,c,n,r,a,l),x(c,i,a,l,o,s))}x(u,h,n,o,r,o),x(h,p,r,o,r,s),x(p,f,r,s,n,s),x(f,u,n,s,n,o),m-=v,_-=v,g+=v,y+=v;const b=1/Math.max(g-m,y-_);return{scale:b,x:m*b,y:_*b,x2:g*b,y2:y*b,projection:e}}function ig(t,{x:e,y:i},n=0){return new Ue(((e-n)*t.scale-t.x)*uo,(i*t.scale-t.y)*uo)}const ng=t.ad.identity(new Float32Array(16));class rg{constructor(t){this.spec=t,this.name=t.name,this.wrap=!1,this.requiresDraping=!1,this.supportsWorldCopies=!1,this.supportsTerrain=!1,this.supportsFog=!1,this.supportsFreeCamera=!1,this.zAxisUnit="meters",this.isReprojectedInTileSpace=!0,this.unsupportedLayers=["custom"],this.center=[0,0],this.range=[3.5,7]}project(t,e){return{x:0,y:0,z:0}}unproject(t,e){return new pd(0,0)}projectTilePoint(t,e,i){return{x:t,y:e,z:0}}locationPoint(t,e,i=!0){return t._coordinatePoint(t.locationCoordinate(e),i)}pixelsPerMeter(t,e){return Cd(1,t)*e}pixelSpaceConversion(t,e,i){return 1}farthestPixelDistance(t){return tg(t,t.pixelsPerMeter)}pointCoordinate(t,e,i,n){const r=t.horizonLineFromTop(!1),o=new Ue(e,Math.max(r,i));return t.rayIntersectionCoordinate(t.pointRayIntersection(o,n))}pointCoordinate3D(t,e,i){const n=new Ue(e,i);if(t.elevation)return t.elevation.pointCoordinate(n);{const e=this.pointCoordinate(t,n.x,n.y,0);return[e.x,e.y,e.z]}}isPointAboveHorizon(t,e){if(t.elevation&&t.elevation.visibleDemTiles.length)return!this.pointCoordinate3D(t,e.x,e.y);const i=t.horizonLineFromTop();return e.y0?epg-i&&(e=pg-i);const o=r/Math.pow(fg(e),n);let s=o*Math.sin(n*t),a=r-o*Math.cos(n*t);return s=.5*(s/Math.PI+.5),a=.5*(a/Math.PI+.5),{x:s,y:this.southernCenter?a:1-a,z:0}}unproject(t,e){t=(2*t-.5)*Math.PI,this.southernCenter&&(e=1-e),e=(2*(1-e)-.5)*Math.PI;const{n:i,f:n}=this,r=n-e,o=Math.sign(r),s=Math.sign(i)*Math.sqrt(t*t+r*r);let a=Math.atan2(t,Math.abs(r))*o;r*i1e-6&&--n>0);o=i*i;const s=Xe(Ze(t/(.8707+o*(o*(o*o*o*(.003971-.001529*o)-.013791)-.131979))),-180,180),a=Ze(i);return new pd(s,a)}}const vg=Ge(Pd);class xg extends rg{project(t,e){e=Ge(e),t=Ge(t);const i=Math.cos(e),n=2/Math.PI,r=Math.acos(i*Math.cos(t/2)),o=Math.sin(r)/r,s=.5*(t*n+2*i*Math.sin(t/2)/o)||0,a=.5*(e+Math.sin(e)/o)||0;return{x:.5*(s/Math.PI+.5),y:1-.5*(a/Math.PI+1),z:0}}unproject(t,e){let i=t=(2*t-.5)*Math.PI,n=e=(2*(1-e)-1)*Math.PI,r=25;const o=1e-6;let s=0,a=0;do{const r=Math.cos(n),o=Math.sin(n),l=2*o*r,c=o*o,d=r*r,u=Math.cos(i/2),h=Math.sin(i/2),p=2*u*h,f=h*h,m=1-d*u*u,_=m?1/m:0,g=m?Math.acos(r*u)*Math.sqrt(1/m):0,y=.5*(2*g*r*h+2*i/Math.PI)-t,v=.5*(g*o+n)-e,x=.5*_*(d*f+g*r*u*c)+1/Math.PI,b=_*(p*l/4-g*o*h),w=.125*_*(l*h-g*o*d*p),T=.5*_*(c*u+g*f*r)+.5,S=b*w-T*x;s=(v*b-y*T)/S,a=(y*w-v*x)/S,i=Xe(i-s,-Math.PI,Math.PI),n=Xe(n-a,-vg,vg)}while((Math.abs(s)>o||Math.abs(a)>o)&&--r>0);return new pd(Ze(i),Ze(n))}}class bg extends rg{constructor(t){super(t),this.center=t.center||[0,0],this.parallels=t.parallels||[0,0],this.cosPhi=Math.max(.01,Math.cos(Ge(this.parallels[0]))),this.scale=1/(2*Math.max(Math.PI*this.cosPhi,1/this.cosPhi)),this.wrap=!0,this.supportsWorldCopies=!0}project(t,e){const{scale:i,cosPhi:n}=this;return{x:Ge(t)*n*i+.5,y:-Math.sin(Ge(e))/n*i+.5,z:0}}unproject(t,e){const{scale:i,cosPhi:n}=this,r=-(e-.5)/i,o=Xe(Ze((t-.5)/i)/n,-180,180),s=Math.asin(Xe(r*n,-1,1)),a=Xe(Ze(s),-Pd,Pd);return new pd(o,a)}}class wg extends _g{constructor(t){super(t),this.requiresDraping=!0,this.supportsWorldCopies=!1,this.supportsFog=!0,this.zAxisUnit="pixels",this.unsupportedLayers=["debug"],this.range=[3,5]}projectTilePoint(e,i,n){const r=Fu(e,i,n),o=ju($u(n));return t._.transformMat4(r,r,o),{x:r[0],y:r[1],z:r[2]}}locationPoint(e,i){const n=dd(i.lat,i.lng),r=t._.normalize([],n),o=e.elevation?e.elevation.getAtPointOrZero(e.locationCoordinate(i),e._centerAltitude):e._centerAltitude,s=Cd(1,0)*uo*o;t._.scaleAndAdd(n,n,r,s);const a=t.ad.identity(new Float64Array(16));return t.ad.multiply(a,e.pixelMatrix,e.globeMatrix),t._.transformMat4(n,n,a),new Ue(n[0],n[1])}pixelsPerMeter(t,e){return Cd(1,0)*e}pixelSpaceConversion(t,e,i){const n=Cd(1,t)*e,r=Vn(Cd(1,45)*e,n,i);return this.pixelsPerMeter(t,e)/r}createTileMatrix(e,i,n){const r=Vu($u(n.canonical));return t.ad.multiply(new Float64Array(16),e.globeMatrix,r)}createInversionMatrix(e,i){const{center:n}=e,r=ju($u(i));return t.ad.rotateY(r,r,Ge(n.lng)),t.ad.rotateX(r,r,Ge(n.lat)),t.ad.scale(r,r,[e._pixelsPerMercatorPixel,e._pixelsPerMercatorPixel,1]),Float32Array.from(r)}pointCoordinate(t,e,i,n){return Iu(t,e,i,!0)||new Rd(0,0)}pointCoordinate3D(t,e,i){const n=this.pointCoordinate(t,e,i,0);return[n.x,n.y,n.z]}isPointAboveHorizon(t,e){return!Iu(t,e.x,e.y,!1)}farthestPixelDistance(e){const i=function(e,i){const n=e.cameraToCenterDistance,r=e._centerAltitude*i,o=e._camera,s=e._camera.forward(),a=t._.add([],t._.scale([],s,-n),[0,0,r]),l=e.worldSize/(2*Math.PI),c=[0,0,-l],d=e.width/e.height,u=Math.tan(e.fovAboveCenter),h=t._.scale([],o.up(),u),p=t._.scale([],o.right(),u*d),f=t._.normalize([],t._.add([],t._.add([],s,h),p)),m=[];let _;if(new mu(a,f).closestPointOnSphere(c,l,m)){const i=t._.add([],m,c),n=t._.sub([],i,a);_=Math.cos(e.fovAboveCenter)*t._.length(n)}else{const e=t._.sub([],a,c),i=t._.sub([],c,a);t._.normalize(i,i);const n=t._.length(e)-l;_=Math.sqrt(n*(n+2*l));const r=Math.acos(_/(l+n))-Math.acos(t._.dot(s,i));_*=Math.cos(r)}return 1.01*_}(e,this.pixelsPerMeter(e.center.lat,e.worldSize)),n=Hu(e.zoom);if(n>0){const t=tg(e,Cd(1,e.center.lat)*e.worldSize),r=e.worldSize/(2*Math.PI),o=Math.max(e.width,e.height)/e.worldSize*Math.PI;return Vn(i,t+r*(1-Math.cos(o)),Math.pow(n,10))}return i}upVector(t,e,i){return Fu(e,i,t,1)}upVectorScale(t){return{metersToTile:Cu(Nu($u(t)))}}}function Tg(t){const e=t.parallels,i=!!e&&Math.abs(e[0]+e[1])0&&(this.iconTransitioningVertexBuffer=t.createVertexBuffer(this.iconTransitioningVertexArray,Vf.members,!0)),this.globeExtVertexArray.length>0&&(this.globeExtVertexBuffer=t.createVertexBuffer(this.globeExtVertexArray,Ff.members,!0)),!this.zOffsetVertexBuffer&&(this.zOffsetVertexArray.length>0||r)&&(this.zOffsetVertexBuffer=t.createVertexBuffer(this.zOffsetVertexArray,jf.members,!0)),this.opacityVertexBuffer.itemSize=1),(i||n)&&this.programConfigurations.upload(t))}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy(),this.dynamicLayoutVertexBuffer.destroy(),this.opacityVertexBuffer.destroy(),this.occlusionQueryOpacityVertexBuffer.destroy(),this.iconTransitioningVertexBuffer&&this.iconTransitioningVertexBuffer.destroy(),this.globeExtVertexBuffer&&this.globeExtVertexBuffer.destroy(),this.zOffsetVertexBuffer&&this.zOffsetVertexBuffer.destroy())}}ba(Ng,"SymbolBuffers");class Ug{constructor(t,e,i){this.layoutVertexArray=new t,this.layoutAttributes=e,this.indexArray=new i,this.segments=new wc,this.collisionVertexArray=new Xl,this.collisionVertexArrayExt=new Ol}upload(t){this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,this.layoutAttributes),this.indexBuffer=t.createIndexBuffer(this.indexArray),this.collisionVertexBuffer=t.createVertexBuffer(this.collisionVertexArray,Gf.members,!0),this.collisionVertexBufferExt=t.createVertexBuffer(this.collisionVertexArrayExt,Zf.members,!0)}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.segments.destroy(),this.collisionVertexBuffer.destroy(),this.collisionVertexBufferExt.destroy())}}ba(Ug,"CollisionBuffers");class jg{constructor(e){this.queries=new Map,this.collisionBoxArray=e.collisionBoxArray,this.zoom=e.zoom,this.lut=e.lut,this.overscaling=e.overscaling,this.layers=e.layers,this.layerIds=this.layers.map((t=>t.fqid)),this.index=e.index,this.pixelRatio=e.pixelRatio,this.sourceLayerIndex=e.sourceLayerIndex,this.hasPattern=!1,this.hasRTLText=!1,this.fullyClipped=!1,this.hasAnyIconTextFit=!1,this.sortKeyRanges=[],this.collisionCircleArray=[],this.placementInvProjMatrix=t.ad.identity([]),this.placementViewportMatrix=t.ad.identity([]);const i=this.layers[0]._unevaluatedLayout._values;this.textSizeData=Fm(this.zoom,i["text-size"]),this.iconSizeData=Fm(this.zoom,i["icon-size"]);const n=this.layers[0].layout,r=n.get("symbol-sort-key"),o=n.get("symbol-z-order");this.canOverlap=n.get("text-allow-overlap")||n.get("icon-allow-overlap")||n.get("text-ignore-placement")||n.get("icon-ignore-placement"),this.sortFeaturesByKey="viewport-y"!==o&&void 0!==r.constantOr(1),this.sortFeaturesByY=("viewport-y"===o||"auto"===o&&!this.sortFeaturesByKey)&&this.canOverlap,this.writingModes=n.get("text-writing-mode").map((t=>Jm[t])),this.stateDependentLayerIds=this.layers.filter((t=>t.isStateDependent())).map((t=>t.id)),this.sourceID=e.sourceID,this.projection=e.projection,this.hasAnyZOffset=!1,this.zOffsetSortDirty=!1,this.zOffsetBuffersNeedUpload=n.get("symbol-z-elevate"),this.activeReplacements=[],this.replacementUpdateTime=0}createArrays(){this.text=new Ng(new Yc(this.layers,{zoom:this.zoom,lut:this.lut},(t=>/^text/.test(t)))),this.icon=new Ng(new Yc(this.layers,{zoom:this.zoom,lut:this.lut},(t=>/^icon/.test(t)))),this.glyphOffsetArray=new mc,this.lineVertexArray=new _c,this.symbolInstances=new fc}calculateGlyphDependencies(t,e,i,n,r){for(let i=0;i0)&&("constant"!==l.value.kind||l.value.value.length>0),h="constant"!==d.value.kind||!!d.value.value||Object.keys(d.parameters).length>0,p=s.get("symbol-sort-key");if(this.features=[],!u&&!h)return;const f=i.iconDependencies,m=i.glyphDependencies,_=i.availableImages,g=new Ha(this.zoom);for(const{feature:i,id:c,index:d,sourceLayerIndex:y}of e){const e=o._featureFilter.needGeometry,v=Zd(i,e);if(!o._featureFilter.filter(g,v,n))continue;if(e||(v.geometry=Gd(i,n,r)),a&&1!==i.type&&n.z{const o=Fu(e.x,e.y,n,1),s=Fu(r.x,r.y,n,1);return t._.dot(o,s)=0;for(const i of x.sections)if(i.image)f[i.image.namePrimary]=!0;else{const n=Ca(x.toString()),r=i.fontStack||t,o=m[r]=m[r]||{};this.calculateGlyphDependencies(i.text,o,e,this.allowVerticalPlacement,n)}}}"line"===s.get("symbol-placement")&&(this.features=function(t){const e={},i={},n=[];let r=0;function o(e){n.push(t[e]),r++}function s(t,e,r){const o=i[t];return delete i[t],i[e]=o,n[o].geometry[0].pop(),n[o].geometry[0]=n[o].geometry[0].concat(r[0]),o}function a(t,i,r){const o=e[i];return delete e[i],e[t]=o,n[o].geometry[0].shift(),n[o].geometry[0]=r[0].concat(n[o].geometry[0]),o}function l(t,e,i){const n=i?e[0][e[0].length-1]:e[0][0];return`${t}:${n.x}:${n.y}`}for(let c=0;ct.geometry))}(this.features)),this.sortFeaturesByKey&&this.features.sort(((t,e)=>t.sortKey-e.sortKey))}update(t,e,i,n,r){const o=0!==Object.keys(t).length;if(o&&!this.stateDependentLayers.length)return;const s=o?this.stateDependentLayers:this.layers;this.text.programConfigurations.updatePaintArrays(t,e,s,i,n,r),this.icon.programConfigurations.updatePaintArrays(t,e,s,i,n,r)}updateOcclusionOpacities(t,e,i){if(!e.useOcclusionQueries)return!1;const n=this;if("globe"===n.projection.name)return!1;let r=!1;n.hasTextData()&&(r=r||0!==n.text.occlusionQueryOpacityVertexArray.length),n.hasIconData()&&(r=r||0!==n.icon.occlusionQueryOpacityVertexArray.length);const o=n.layers[0].paint,s=o.get("icon-occlusion-opacity").constantOr(0),a=o.get("text-occlusion-opacity").constantOr(0);if(!n.layers[0].hasInitialOcclusionOpacityProperties||1===s&&1===a)return!1;let l=!r;for(let t=0;t.5?1:-1)*e.fadeSpeed*i*.001,r.occlusionOpacity=Xe(r.occlusionOpacity,0,1),l=l||r.occlusionOpacity!==o}if(!l)return!1;let c=0,d=0;const u=(t,e,i,n)=>{let r=0,o=0;i?(r=d,d+=n,o=d):(r=c,c+=n,o=c),o>e.occlusionQueryOpacityVertexArray.length&&e.occlusionQueryOpacityVertexArray.resize(o);const s=t.occlusionOpacity;for(let t=0;t0;if((i>0||r>0)&&(u(e,n.text,!1,i),u(e,n.text,!1,r)),s){const{placedIconSymbolIndex:t,verticalPlacedIconSymbolIndex:i}=e;t>=0&&u(e,n.icon,!0,o),i>=0&&u(e,n.icon,!0,e.numVerticalIconVertices)}}return n.hasTextData()&&n.text.occlusionQueryOpacityVertexBuffer&&(n.text.occlusionQueryOpacityVertexBuffer.length{i+=e,i>t.length&&t.resize(i);for(let r=-e;r{n+=e,n>t.length&&t.resize(n);for(let r=-e;r0;if((r>0||o>0)&&(t(this.text.zOffsetVertexArray,r,a),t(this.text.zOffsetVertexArray,o,a)),l){const{placedIconSymbolIndex:t,verticalPlacedIconSymbolIndex:i}=n;t>=0&&e(this.icon.zOffsetVertexArray,s,a),i>=0&&e(this.icon.zOffsetVertexArray,n.numVerticalIconVertices,a)}}this.text.zOffsetVertexBuffer&&this.text.zOffsetVertexBuffer.updateData(this.text.zOffsetVertexArray),this.icon.zOffsetVertexBuffer&&this.icon.zOffsetVertexBuffer.updateData(this.icon.zOffsetVertexArray)}isEmpty(){return 0===this.symbolInstances.length&&!this.hasRTLText}uploadPending(){return!this.uploaded||this.text.programConfigurations.needsUpload||this.icon.programConfigurations.needsUpload}upload(t){!this.uploaded&&this.hasDebugData()&&(this.textCollisionBox.upload(t),this.iconCollisionBox.upload(t)),this.text.upload(t,this.sortFeaturesByY,!this.uploaded,this.text.programConfigurations.needsUpload,this.zOffsetBuffersNeedUpload),this.icon.upload(t,this.sortFeaturesByY,!this.uploaded,this.icon.programConfigurations.needsUpload,this.zOffsetBuffersNeedUpload),this.uploaded=!0}destroyDebugData(){this.textCollisionBox.destroy(),this.iconCollisionBox.destroy()}getProjection(){return this.projectionInstance||(this.projectionInstance=Tg(this.projection)),this.projectionInstance}destroy(){this.text.destroy(),this.icon.destroy(),this.hasDebugData()&&this.destroyDebugData();for(const t of this.queries.values())t.destroy()}addToLineVertexArray(t,e){const i=this.lineVertexArray.length;if(void 0!==t.segment)for(const{x:t,y:i}of e)this.lineVertexArray.emplaceBack(t,i);return{lineStartIndex:i,lineLength:this.lineVertexArray.length-i}}addSymbols(t,e,i,n,r,o,s,a,l,c,d,u,h,p,f,m){const _=t.indexArray,g=t.layoutVertexArray,y=t.globeExtVertexArray,v=t.segments.prepareSegment(4*e.length,g,_,this.canOverlap?o.sortKey:void 0),x=this.glyphOffsetArray.length,b=v.vertexLength,w=this.allowVerticalPlacement&&s===Jm.vertical?Math.PI/2:0,T=o.text&&o.text.sections;for(let n=0;n=0?e.rightJustifiedTextSymbolIndex:e.centerJustifiedTextSymbolIndex>=0?e.centerJustifiedTextSymbolIndex:e.leftJustifiedTextSymbolIndex>=0?e.leftJustifiedTextSymbolIndex:e.verticalPlacedTextSymbolIndex>=0?e.verticalPlacedTextSymbolIndex:n),o=Nm(this.textSizeData,t,r)/Om;return this.tilePixelRatio*o}getSymbolInstanceIconSize(t,e,i){const n=this.icon.placedSymbolArray.get(i),r=Nm(this.iconSizeData,t,n);return this.tilePixelRatio*r}_commitDebugCollisionVertexUpdate(t,e,i,n){t.emplaceBack(e,-i,-i,n),t.emplaceBack(e,i,-i,n),t.emplaceBack(e,i,i,n),t.emplaceBack(e,-i,i,n)}_updateTextDebugCollisionBoxes(t,e,i,n,r,o){for(let s=n;s0}hasIconData(){return this.icon.segments.get().length>0}hasDebugData(){return this.textCollisionBox&&this.iconCollisionBox}hasTextCollisionBoxData(){return this.hasDebugData()&&this.textCollisionBox.segments.get().length>0}hasIconCollisionBoxData(){return this.hasDebugData()&&this.iconCollisionBox.segments.get().length>0}hasIconTextFit(){return this.hasAnyIconTextFit}addIndicesForPlacedSymbol(t,e){const i=t.placedSymbolArray.get(e),n=i.vertexStartIndex+4*i.numGlyphs;for(let e=i.vertexStartIndex;en[t]-n[e]||r[e]-r[t])),o}getSortedIndexesByZOffset(){if(!this.zOffsetSortDirty)return this.symbolInstanceIndexesSortedZOffset;if(!this.symbolInstanceIndexesSortedZOffset){this.symbolInstanceIndexesSortedZOffset=[];for(let t=0;tthis.symbolInstances.get(e).zOffset-this.symbolInstances.get(t).zOffset))}addToSortKeyRanges(t,e){const i=this.sortKeyRanges[this.sortKeyRanges.length-1];i&&i.sortKey===e?i.symbolInstanceEnd=t+1:this.sortKeyRanges.push({sortKey:e,symbolInstanceStart:t,symbolInstanceEnd:t+1})}sortFeatures(t){if(this.sortFeaturesByY&&this.sortedAngle!==t&&!(this.text.segments.get().length>1||this.icon.segments.get().length>1)){this.symbolInstanceIndexes=this.getSortedSymbolIndexes(t),this.sortedAngle=t,this.text.indexArray.clear(),this.icon.indexArray.clear(),this.featureSortOrder=[];for(const t of this.symbolInstanceIndexes){const e=this.symbolInstances.get(t);this.featureSortOrder.push(e.featureIndex);const{rightJustifiedTextSymbolIndex:i,centerJustifiedTextSymbolIndex:n,leftJustifiedTextSymbolIndex:r,verticalPlacedTextSymbolIndex:o,placedIconSymbolIndex:s,verticalPlacedIconSymbolIndex:a}=e;i>=0&&this.addIndicesForPlacedSymbol(this.text,i),n>=0&&n!==i&&this.addIndicesForPlacedSymbol(this.text,n),r>=0&&r!==n&&r!==i&&this.addIndicesForPlacedSymbol(this.text,r),o>=0&&this.addIndicesForPlacedSymbol(this.text,o),s>=0&&this.addIndicesForPlacedSymbol(this.icon,s),a>=0&&this.addIndicesForPlacedSymbol(this.icon,a)}this.text.indexBuffer&&this.text.indexBuffer.updateData(this.text.indexArray),this.icon.indexBuffer&&this.icon.indexBuffer.updateData(this.icon.indexArray)}}}ba(jg,"SymbolBucket",{omit:["layers","collisionBoxArray","features","compareText"]}),jg.addDynamicAttributes=Bg;class Vg{constructor(t,e,i,n){this.context=t,this.format=i,this.texture=t.gl.createTexture(),this.update(e,n)}update(t,e,i){const{width:n,height:r}=t,{context:o}=this,{gl:s}=o;if(s.bindTexture(s.TEXTURE_2D,this.texture),o.pixelStoreUnpackFlipY.set(!1),o.pixelStoreUnpack.set(1),o.pixelStoreUnpackPremultiplyAlpha.set(this.format===s.RGBA&&(!e||!1!==e.premultiply)),this.useMipmap=Boolean(e&&e.useMipmap),i||this.size&&this.size[0]===n&&this.size[1]===r){const{x:e,y:o}=i||{x:0,y:0};if(t instanceof HTMLImageElement||t instanceof HTMLCanvasElement||t instanceof HTMLVideoElement||t instanceof ImageData||ImageBitmap&&t instanceof ImageBitmap)s.texSubImage2D(s.TEXTURE_2D,0,e,o,s.RGBA,s.UNSIGNED_BYTE,t);else{let i=this.format,a=s.UNSIGNED_BYTE;this.format===s.R32F&&(i=s.RED,a=s.FLOAT),s.texSubImage2D(s.TEXTURE_2D,0,e,o,n,r,i,a,t.data)}}else if(this.size=[n,r],t instanceof HTMLImageElement||t instanceof HTMLCanvasElement||t instanceof HTMLVideoElement||t instanceof ImageData||ImageBitmap&&t instanceof ImageBitmap){let e=this.format;this.format===s.R8&&(e=s.RED),s.texImage2D(s.TEXTURE_2D,0,this.format,e,s.UNSIGNED_BYTE,t)}else{let e=this.format,i=this.format,o=s.UNSIGNED_BYTE,a=!1;this.format===s.DEPTH_COMPONENT&&(e=s.DEPTH_COMPONENT16,o=s.UNSIGNED_SHORT),this.format===s.DEPTH_STENCIL&&(e=s.DEPTH24_STENCIL8,o=s.UNSIGNED_INT_24_8,a=!0),this.format===s.R8&&(i=s.RED),this.format===s.R32F&&(o=s.FLOAT,i=s.RED),!this.useMipmap&&a?s.texStorage2D(s.TEXTURE_2D,1,e,n,r):s.texImage2D(s.TEXTURE_2D,0,e,n,r,0,i,o,t.data)}this.useMipmap&&s.generateMipmap(s.TEXTURE_2D)}bind(t,e,i=!1){const{context:n}=this,{gl:r}=n;r.bindTexture(r.TEXTURE_2D,this.texture),t!==this.minFilter&&(r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MAG_FILTER,t),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MIN_FILTER,this.useMipmap&&!i?t===r.NEAREST?r.NEAREST_MIPMAP_NEAREST:r.LINEAR_MIPMAP_LINEAR:t),this.minFilter=t),e!==this.wrapS&&(r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_S,e),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_T,e),this.wrapS=e)}bindExtraParam(t,e,i,n){const{context:r}=this,{gl:o}=r;o.bindTexture(o.TEXTURE_2D,this.texture),e!==this.magFilter&&(o.texParameteri(o.TEXTURE_2D,o.TEXTURE_MAG_FILTER,e),this.magFilter=e),t!==this.minFilter&&(o.texParameteri(o.TEXTURE_2D,o.TEXTURE_MIN_FILTER,this.useMipmap?t===o.NEAREST?o.NEAREST_MIPMAP_NEAREST:o.LINEAR_MIPMAP_LINEAR:t),this.minFilter=t),i!==this.wrapS&&(o.texParameteri(o.TEXTURE_2D,o.TEXTURE_WRAP_S,i),this.wrapS=i),n!==this.wrapT&&(o.texParameteri(o.TEXTURE_2D,o.TEXTURE_WRAP_T,n),this.wrapT=n)}destroy(){const{gl:t}=this.context;t.deleteTexture(this.texture),this.texture=null}}class Gg{constructor(t,e){this.context=t,this.texture=e}bind(t,e){const{context:i}=this,{gl:n}=i;n.bindTexture(n.TEXTURE_2D,this.texture),t!==this.minFilter&&(n.texParameteri(n.TEXTURE_2D,n.TEXTURE_MAG_FILTER,t),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_MIN_FILTER,t),this.minFilter=t),e!==this.wrapS&&(n.texParameteri(n.TEXTURE_2D,n.TEXTURE_WRAP_S,e),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_WRAP_T,e),this.wrapS=e)}}const Zg=32,qg=33,Hg=new Uint16Array(8184);for(let t=0;t>=1)>1;){const t=i+r>>1,l=n+o>>1;1&e?(r=i,o=n,i=s,n=a):(i=r,n=o,r=s,o=a),s=t,a=l}const l=4*t;Hg[l+0]=i,Hg[l+1]=n,Hg[l+2]=r,Hg[l+3]=o}const Wg=new Uint16Array(2178),Yg=new Uint8Array(1089),Xg=new Uint16Array(1089);function Kg(t){return 0===t?-.03125:32===t?.03125:0}var Jg=Ll([{name:"a_pos",type:"Int16",components:2},{name:"a_texture_pos",type:"Int16",components:2}]),Qg=Ll([{name:"a_index",type:"Int16",components:1}]);const ty={type:2,extent:uo,loadGeometry:()=>[[new Ue(0,0),new Ue(uo+1,0),new Ue(uo+1,uo+1),new Ue(0,uo+1),new Ue(0,0)]]};class ey{constructor(t,e,i,n,r){this.tileID=t,this.uid=ni(),this.uses=0,this.tileSize=e,this.tileZoom=i,this.buckets={},this.expirationTime=null,this.queryPadding=0,this.hasSymbolBuckets=!1,this.hasRTLText=!1,this.dependencies={},this.isRaster=r,n&&n.style&&(this._lastUpdatedBrightness=n.style.getBrightness()),this.expiredRequestCount=0,this.state="loading",n&&n.transform&&(this.projection=n.transform.projection)}registerFadeDuration(t){const e=t+this.timeAdded;ee.getLayer(t))).filter(Boolean);if(0!==t.length){n.layers=t,n.stateDependentLayerIds&&(n.stateDependentLayers=n.stateDependentLayerIds.map((e=>t.filter((t=>t.id===e))[0])));for(const e of t)i[e.fqid]=n}}return i}(t.buckets,e.style),this.hasSymbolBuckets=!1;for(const t in this.buckets){const e=this.buckets[t];if(e instanceof jg){if(this.hasSymbolBuckets=!0,!i)break;e.justReloaded=!0}}if(this.hasRTLText=!1,this.hasSymbolBuckets)for(const t in this.buckets){const e=this.buckets[t];if(e instanceof jg&&e.hasRTLText){this.hasRTLText=!0,qa.isLoading()||qa.isLoaded()||"deferred"!==Ga()||Za();break}}this.queryPadding=0;for(const t in this.buckets){const i=this.buckets[t],n=e.style.getOwnLayer(t);if(!n)continue;const r=n.queryRadius(i);this.queryPadding=Math.max(this.queryPadding,r)}t.imageAtlas&&(this.imageAtlas=t.imageAtlas),t.glyphAtlasImage&&(this.glyphAtlasImage=t.glyphAtlasImage),t.lineAtlas&&(this.lineAtlas=t.lineAtlas),this._lastUpdatedBrightness=t.brightness}else this.collisionBoxArray=new dc}unloadVectorData(){if(this.hasData()){for(const t in this.buckets)this.buckets[t].destroy();this.buckets={},this.imageAtlas&&(this.imageAtlas=null),this.lineAtlas&&(this.lineAtlas=null),this.imageAtlasTexture&&this.imageAtlasTexture.destroy(),this.glyphAtlasTexture&&this.glyphAtlasTexture.destroy(),this.lineAtlasTexture&&this.lineAtlasTexture.destroy(),this._tileBoundsBuffer&&(this._tileBoundsBuffer.destroy(),this._tileBoundsIndexBuffer.destroy(),this._tileBoundsSegments.destroy(),this._tileBoundsBuffer=null),this._tileDebugBuffer&&(this._tileDebugBuffer.destroy(),this._tileDebugSegments.destroy(),this._tileDebugBuffer=null),this._tileDebugIndexBuffer&&(this._tileDebugIndexBuffer.destroy(),this._tileDebugIndexBuffer=null),this._globeTileDebugBorderBuffer&&(this._globeTileDebugBorderBuffer.destroy(),this._globeTileDebugBorderBuffer=null),this._tileDebugTextBuffer&&(this._tileDebugTextBuffer.destroy(),this._tileDebugTextSegments.destroy(),this._tileDebugTextIndexBuffer.destroy(),this._tileDebugTextBuffer=null),this._globeTileDebugTextBuffer&&(this._globeTileDebugTextBuffer.destroy(),this._globeTileDebugTextBuffer=null),this.latestFeatureIndex=null,this.state="unloaded"}}getBucket(t){return this.buckets[t.fqid]}upload(t){for(const e in this.buckets){const i=this.buckets[e];i.uploadPending()&&i.upload(t)}const e=t.gl,i=this.imageAtlas;if(i&&!i.uploaded){const n=!!Object.keys(i.patternPositions).length;this.imageAtlasTexture=new Vg(t,i.image,e.RGBA,{useMipmap:n}),this.imageAtlas.uploaded=!0}this.glyphAtlasImage&&(this.glyphAtlasTexture=new Vg(t,this.glyphAtlasImage,e.R8),this.glyphAtlasImage=null),this.lineAtlas&&!this.lineAtlas.uploaded&&(this.lineAtlasTexture=new Vg(t,this.lineAtlas.image,e.R8),this.lineAtlas.uploaded=!0)}prepare(t,e,i){if(this.imageAtlas&&this.imageAtlasTexture&&this.imageAtlas.patchUpdatedImages(t,this.imageAtlasTexture,i),!e||!this.latestFeatureIndex||!this.latestFeatureIndex.rawTileData)return;const n=e.style.getBrightness();(this._lastUpdatedBrightness||n)&&(this._lastUpdatedBrightness&&n&&Math.abs(this._lastUpdatedBrightness-n)t)i=!1;else if(e)if(this.expirationTime=0;t--){const e=4*t,i=Hg[e+0],n=Hg[e+1],r=Hg[e+2],o=Hg[e+3],s=i+r>>1,a=n+o>>1,l=s+a-n,c=a+i-s,d=n*qg+i,u=o*qg+r,h=a*qg+s,p=Math.hypot((Wg[2*d+0]+Wg[2*u+0])/2-Wg[2*h+0],(Wg[2*d+1]+Wg[2*u+1])/2-Wg[2*h+1])>=16;Yg[h]=Yg[h]||(p?1:0),t>1)*qg+(i+l>>1)]||Yg[(o+c>>1)*qg+(r+l>>1)])}const r=new Dl,o=new Kl;let s=0;function a(t,e){const i=e*qg+t;return 0===Xg[i]&&(r.emplaceBack(Wg[2*i+0],Wg[2*i+1],t*uo/Zg,e*uo/Zg),Xg[i]=++s),Xg[i]-1}function l(t,e,i,n,r,s){const c=t+i>>1,d=e+n>>1;if(Math.abs(t-r)+Math.abs(e-s)>1&&Yg[d*qg+c])l(r,s,t,e,c,d),l(i,n,r,s,c,d);else{const l=a(t,e),c=a(i,n),d=a(r,s);o.emplaceBack(l,c,d)}}return l(0,0,Zg,Zg,Zg,0),l(Zg,Zg,0,0,0,Zg),{vertices:r,indices:o}}(this.tileID.canonical,e);n=t.vertices,r=t.indices}else{n=new Dl,r=new Kl;for(const{x:t,y:e}of i)n.emplaceBack(t,e,0,0);const t=xh(n.int16,void 0,4);for(let e=0;e0&&(a=t.ad.invert(new Float64Array(16),i.globeMatrix)),this._makeGlobeTileDebugBorderBuffer(e,r,i,o,a,s),this._makeGlobeTileDebugTextBuffer(e,r,i,o,a,s)}_globePoint(e,i,n,r,o,s,a){let l=Fu(e,i,n);if(s){const o=1.5?h=-1:u{const p=(d-t)/(h-1),f=(u-c)/(h-1),m=s.length;for(let d=0;dd*t+e;for(let t=0;t[t,this.get(t)]))}evict(t=!1){if(t||this.size>0){const t=this.first;delete this.items[t.key],0==--this.size?(this.first=null,this.last=null):(this.first=t.next,this.first.prev=null)}return this}expiresAt(t){let e;return this.has(t)&&(e=this.items[t].expiry),e}get(t){let e;if(this.has(t)){const i=this.items[t];this.ttl>0&&i.expiry0?Date.now()+this.ttl:this.ttl),this.last!==r){const t=this.last,e=r.next,i=r.prev;this.first===r&&(this.first=r.next),r.next=null,r.prev=this.last,t.next=r,null!==i&&(i.next=e),null!==e&&(e.prev=i)}}else this.max>0&&this.size===this.max&&this.evict(!0),r=this.items[t]={expiry:this.ttl>0?Date.now()+this.ttl:this.ttl,key:t,prev:this.last,next:null,value:e},1==++this.size?this.first=r:this.last.next=r;return this.last=r,this}values(t=this.keys()){return t.map((t=>this.get(t)))}}function uy(t,e){if(4!==e.length)throw new Error(`Expected data of dimension 4 but got ${e.length}.`);let i=e[3];for(let n=2;n>=1;n--){const r=1===n?1:0,o=2===n?1:0;for(let n=0;n>>1^-(1&t[e]);return t}function py(t,e){switch(e){case"uint32":return t;case"uint16":for(let e=0;e>4|(61440&i)>>8|(240&n)>4|(15&n)>6|(192&n)>>4|(192&r)>>2|192&o,t[e+1]=(48&i)>>4|(48&n)>>2|48&r|(48&o)>2|12&n|(12&r)>1|(21845&Cy)>2|(13107&Ay)>4|(3855&Ay)>8|(255&Ay)>1}var Iy=function(t,e,i){for(var n=t.length,r=0,o=new _y(e);r>l]=c}else for(s=new _y(n),r=0;r>15-t[r]);return s},Ly=new my(288);for(Cy=0;Cye&&(e=t[i]);return e},zy=function(t,e,i){var n=e/8|0;return(t[n]|t[n+1]>(7&e)&i},Ry=function(t,e){var i=e/8|0;return(t[i]|t[i+1]>(7&e)},Oy=["unexpected EOF","invalid block type","invalid length/literal","invalid distance","stream finished","no stream handler",,"no callback","invalid UTF-8 data","extra field too long","date not in range 1980-2099","filename too long","stream finishing","invalid zip data"],By=function(t,e,i){var n=new Error(e||Oy[t]);if(n.code=t,Error.captureStackTrace&&Error.captureStackTrace(n,By),!i)throw n;return n},Fy=new my(0),Ny="undefined"!=typeof TextDecoder&&new TextDecoder;try{Ny.decode(Fy,{stream:!0})}catch(t){}const Uy={gzip_data:"gzip"},jy={0:"uint32",1:"uint32",2:"uint16",3:"uint8"},Vy={uint32:1,uint16:2,uint8:4},Gy={uint32:Uint32Array,uint16:Uint16Array,uint8:Uint8Array};class Zy{constructor(t=1){this.x=NaN,this.y=NaN,this.z=NaN,this.layers={},this._cacheSize=t}getLayer(t){return this.layers[t]}getHeaderLength(t){const e=new Uint8Array(t),i=new DataView(t);if(13!==e[0])throw new fy("File is not a valid MRT.");return i.getUint32(1,!0)}parseHeader(t){const e=new Uint8Array(t),i=this.getHeaderLength(t);if(e.length= ${i} but got buffer of length ${e.length}`);const n=function(t){return t.readFields(iy,{header_length:0,x:0,y:0,z:0,layers:[]},void 0)}(new Lm(e.subarray(0,i)));if(!isNaN(this.x)&&(this.x!==n.x||this.y!==n.y||this.z!==n.z))throw new fy(`Invalid attempt to parse header ${n.z}/${n.x}/${n.y} for tile ${this.z}/${this.x}/${this.y}`);this.x=n.x,this.y=n.y,this.z=n.z;for(const t of n.layers)this.layers[t.name]=new qy(t,{cacheSize:this._cacheSize});return this}createDecodingTask(t){const e=[],i=this.getLayer(t.layerName);for(let n=0;nt.lastBlock)continue;if(i._blocksInProgress.has(n))continue;const a={layerName:i.name,firstByte:o,lastByte:s,pixelFormat:i.pixelFormat,blockIndex:n,blockShape:[r.bands.length].concat(i.bandShape),buffer:i.buffer,codec:r.codec.codec,filters:r.filters.map((t=>t.filter))};i._blocksInProgress.add(n),e.push(a)}return new Hy(e,(()=>{e.forEach((t=>i._blocksInProgress.delete(t.blockIndex)))}),((t,n)=>{if(e.forEach((t=>i._blocksInProgress.delete(t.blockIndex))),t)throw t;n.forEach((t=>{this.getLayer(t.layerName).processDecodedData(t)}))}))}}class qy{constructor({version:t,name:e,units:i,tilesize:n,pixel_format:r,buffer:o,data_index:s},a){if(this.version=t,1!==this.version)throw new fy(`Cannot parse raster layer encoded with MRT version ${t}`);this.name=e,this.units=i,this.tileSize=n,this.buffer=o,this.pixelFormat=jy[r],this.dataIndex=s,this.bandShape=[n+2*o,n+2*o,Vy[this.pixelFormat]],this._decodedBlocks=function(t=1e3,e=0,i=!1){if(isNaN(t)||t=e&&t=0}hasDataForBand(t){const{blockIndex:e}=this.getBlockForBand(t);return e>=0&&!!this._decodedBlocks.get(e.toString())}getBandView(t){const{blockIndex:e,blockBandIndex:i}=this.getBlockForBand(t),n=this._decodedBlocks.get(e.toString());if(!n)throw new fy(`Data for band ${JSON.stringify(t)} of layer "${this.name}" not decoded.`);const r=this.dataIndex[e],o=this.bandShape.reduce(((t,e)=>t*e),1),s=i*o,a=n.subarray(s,s+o);return{data:a,bytes:new Uint8Array(a.buffer).subarray(a.byteOffset,a.byteOffset+a.byteLength),tileSize:this.tileSize,buffer:this.buffer,offset:r.offset,scale:r.scale}}}class Hy{constructor(t,e,i){this.tasks=t,this._onCancel=e,this._onComplete=i,this._finalized=!1}cancel(){this._finalized||(this._onCancel(),this._finalized=!0)}complete(t,e){this._finalized||(this._onComplete(t,e),this._finalized=!0)}}Zy.performDecoding=function(t,e){return Promise.all(e.tasks.map((e=>{const{layerName:i,firstByte:n,lastByte:r,pixelFormat:o,blockShape:s,blockIndex:a,filters:l,codec:c}=e,d=new Uint8Array(t).subarray(n,r+1),u=new Uint32Array(s[0]*s[1]*s[2]);let h;if("gzip_data"!==c)throw new Error(`Unhandled codec: ${c}`);return h=function(t,e){if(!globalThis.DecompressionStream&&"gzip_data"===e)return Promise.resolve(((o=function(t){31==t[0]&&139==t[1]&&8==t[2]||By(6,"invalid gzip data");var e=t[3],i=10;4&e&&(i+=2+(t[10]|t[11]>3&1)+(e>>4&1);n>0;n-=!t[i++]);return i+(2&e)}(r=t))+8>r.length&&By(6,"invalid gzip data"),function(t,e,i){var n=t.length;if(!n||e.f&&!e.l)return i||new my(0);var r=!i,o=r||2!=e.i,s=e.i;r&&(i=new my(3*n));var a,l,c=function(t){var e=i.length;if(t>e){var n=new my(Math.max(2*e,t));n.set(i),i=n}},d=e.f||0,u=e.p||0,h=e.b||0,p=e.l,f=e.d,m=e.m,_=e.n,g=8*n;do{if(!p){d=zy(t,u,1);var y=zy(t,u+1,3);if(u+=3,!y){var v=t[(L=4+((u+7)/8|0))-4]|t[L-3]n){s&&By(0);break}o&&c(h+v),i.set(t.subarray(L,x),h),e.b=h+=v,e.p=u=8*x,e.f=d;continue}if(1==y)p=$y,f=ky,m=9,_=5;else if(2==y){var b=zy(t,u,31)+257,w=zy(t,u+10,15)+4,T=b+zy(t,u+5,31)+1;u+=14;for(var S=new my(T),E=new my(19),M=0;M>4)g){s&&By(0);break}}o&&c(h+131072);for(var R=(1>4;if((u+=15&$)>g){s&&By(0);break}if($||By(2),F264&&(N=zy(t,u,(1>4;if(U||By(3),u+=15&U,z=Ey[j],j>3){var V=vy[j];z+=Ry(t,u)&(1g){s&&By(0);break}o&&c(h+131072);var G=h+N;if(ha.length)&&(l=a.length),new my(a.subarray(0,l))):i.subarray(0,h)}(r.subarray(o,-8),{i:2},new my(((i=r)[(n=i.length)-4]|i[n-3]>>0))));var i,n,r,o;const s=Uy[e];if(!s)throw new Error(`Unhandled codec: ${e}`);const a=new globalThis.DecompressionStream(s);return new Response(new Blob([t]).stream().pipeThrough(a)).arrayBuffer().then((t=>new Uint8Array(t)))}(d,c).then((t=>(function(t,e){t.readFields(ly,e)}(new Lm(t),u),new(0,Gy[o])(u.buffer)))),h.then((t=>{for(let e=l.length-1;e>=0;e--)switch(l[e]){case"delta_filter":uy(t,s);break;case"zigzag_filter":hy(t);break;case"bitshuffle_filter":py(t,o);break;default:throw new Error(`Unhandled filter "${l[e]}"`)}return{layerName:i,blockIndex:a,data:t}})).catch((t=>{throw t}))})))};class Wy extends ey{constructor(t,e,i,n,r){super(t,e,i,n,r),this._workQueue=[],this._fetchQueue=[],this._isHeaderLoaded=!1}setTexture(t,e){const i=e.context,n=i.gl;this.texture=this.texture||e.getTileTexture(t.width),this.texture&&this.texture instanceof Vg?this.texture.update(t,{useMipmap:!1,premultiply:!1}):this.texture=new Vg(i,t,n.RGBA,{useMipmap:!1,premultiply:!1})}flushQueues(){for(;this._workQueue.length;)this._workQueue.pop()();for(;this._fetchQueue.length;)this._fetchQueue.pop()()}fetchHeader(t=16384,e){const i=this._mrt=new Zy(30),n=Object.assign({},this.requestParams,{headers:{Range:"bytes=0-"+(t-1)}});return this.entireBuffer=null,this.request=en(n,((n,r,o,s)=>{if(n)e(n);else try{const n=i.getHeaderLength(r);if(n>t)return void(this.request=this.fetchHeader(n,e));i.parseHeader(r),this._isHeaderLoaded=!0;let a=0;for(const t of Object.values(i.layers))a=Math.max(a,t.dataIndex[t.dataIndex.length-1].last_byte);r.byteLength>=a&&(this.entireBuffer=r),e(null,this.entireBuffer||r,o,s)}catch(t){e(t)}})),this.request}fetchBand(t,e,i){const n=this._mrt;if(!this._isHeaderLoaded||!n)return void i(new Error("Tile header is not ready"));const r=this.actor;if(!r)return void i(new Error("Can't fetch tile band without an actor"));let o;const s=(n,r)=>{o.complete(n,r),n?i(n):(this.updateTextureDescriptor(t,e),i(null,this.textureDescriptor&&this.textureDescriptor.img))},a=(t,e)=>{if(t)return i(t);const n=r.send("decodeRasterArray",{buffer:e,task:o},s,void 0,!0);this._workQueue.push((()=>{n&&n.cancel(),o.cancel()}))},l=n.getLayer(t);if(!l)return void i(new Error(`Unknown sourceLayer "${t}"`));if(l.hasDataForBand(e))return this.updateTextureDescriptor(t,e),void i(null,this.textureDescriptor?this.textureDescriptor.img:null);const c=l.getDataRange([e]);if(o=n.createDecodingTask(c),!o||o.tasks.length)if(this.flushQueues(),this.entireBuffer)a(null,this.entireBuffer.slice(c.firstByte,c.lastByte+1));else{const t=Object.assign({},this.requestParams,{headers:{Range:`bytes=${c.firstByte}-${c.lastByte}`}}),e=en(t,a);this._fetchQueue.push((()=>{e.cancel(),o.cancel()}))}else i(null)}updateNeeded(t,e){return(!this.textureDescriptor||this.textureDescriptor.band!==e||this.textureDescriptor.layer!==t)&&"errored"!==this.state}updateTextureDescriptor(t,e){if(!this._mrt)return;const i=this._mrt.getLayer(t);if(!i||!i.hasBand(e)||!i.hasDataForBand(e))return;const{bytes:n,tileSize:r,buffer:o,offset:s,scale:a}=i.getBandView(e),l=r+2*o,c={data:n,width:l,height:l},d=this.texture;d&&d instanceof Vg&&d.update(c,{useMipmap:!1,premultiply:!1}),this.textureDescriptor={layer:t,band:e,img:c,buffer:o,offset:s,tileSize:r,format:i.pixelFormat,mix:[a,256*a,65536*a,16777216*a]}}}class Yy{constructor(t,e){this.max=t,this.onRemove=e,this.reset()}reset(){for(const t in this.data)for(const e of this.data[t])e.timeout&&clearTimeout(e.timeout),this.onRemove(e.value);return this.data={},this.order=[],this}add(t,e,i){const n=t.wrapped().key;void 0===this.data[n]&&(this.data[n]=[]);const r={value:e,timeout:void 0};if(void 0!==i&&(r.timeout=setTimeout((()=>{this.remove(t,r)}),i)),this.data[n].push(r),this.order.push(n),this.order.length>this.max){const t=this._getAndRemoveByKey(this.order[0]);t&&this.onRemove(t)}return this}has(t){return t.wrapped().key in this.data}getAndRemove(t){return this.has(t)?this._getAndRemoveByKey(t.wrapped().key):null}_getAndRemoveByKey(t){const e=this.data[t].shift();return e.timeout&&clearTimeout(e.timeout),0===this.data[t].length&&delete this.data[t],this.order.splice(this.order.indexOf(t),1),e.value}getByKey(t){const e=this.data[t];return e?e[0].value:null}get(t){return this.has(t)?this.data[t.wrapped().key][0].value:null}remove(t,e){if(!this.has(t))return this;const i=t.wrapped().key,n=void 0===e?0:this.data[i].indexOf(e),r=this.data[i][n];return this.data[i].splice(n,1),r.timeout&&clearTimeout(r.timeout),0===this.data[i].length&&delete this.data[i],this.onRemove(r.value),this.order.splice(this.order.indexOf(i),1),this}setMaxSize(t){for(this.max=t;this.order.length>this.max;){const t=this._getAndRemoveByKey(this.order[0]);t&&this.onRemove(t)}return this}filter(t){const e=[];for(const i in this.data)for(const n of this.data[i])t(n.value)||e.push(n);for(const t of e)this.remove(t.value.tileID,t)}}class Xy extends zn{constructor(t,e,i){super(),this.id=t,this._onlySymbols=i,e.on("data",(t=>{"source"===t.dataType&&"metadata"===t.sourceDataType&&(this._sourceLoaded=!0),this._sourceLoaded&&!this._paused&&"source"===t.dataType&&"content"===t.sourceDataType&&(this.reload(),this.transform&&this.update(this.transform))})),e.on("error",(()=>{this._sourceErrored=!0})),this._source=e,this._tiles={},this._cache=new Yy(0,this._unloadTile.bind(this)),this._timers={},this._cacheTimers={},this._minTileCacheSize=e.minTileCacheSize,this._maxTileCacheSize=e.maxTileCacheSize,this._loadedParentTiles={},this.castsShadows=!1,this.tileCoverLift=0,this._coveredTiles={},this._shadowCasterTiles={},this._state=new km,this._isRaster="raster"===this._source.type||"raster-dem"===this._source.type||"raster-array"===this._source.type||"custom"===this._source.type&&"raster"===this._source._dataType}onAdd(t){this.map=t,this._minTileCacheSize=void 0===this._minTileCacheSize&&t?t._minTileCacheSize:this._minTileCacheSize,this._maxTileCacheSize=void 0===this._maxTileCacheSize&&t?t._maxTileCacheSize:this._maxTileCacheSize}loaded(){if(this._sourceErrored)return!0;if(!this._sourceLoaded)return!1;if(!this._source.loaded())return!1;for(const t in this._tiles){const e=this._tiles[t];if("errored"!==e.state&&("loaded"!==e.state||!e.bucketsLoaded()))return!1}return!0}getSource(){return this._source}pause(){this._paused=!0}resume(){if(!this._paused)return;const t=this._shouldReloadOnResume;this._paused=!1,this._shouldReloadOnResume=!1,t&&this.reload(),this.transform&&this.update(this.transform)}_loadTile(t,e){return t.isSymbolTile=this._onlySymbols,t.isExtraShadowCaster=this._shadowCasterTiles[t.tileID.key],this._source.loadTile(t,e)}_unloadTile(t){if(this._source.unloadTile)return this._source.unloadTile(t)}_abortTile(t){if(this._source.abortTile)return this._source.abortTile(t)}serialize(){return this._source.serialize()}prepare(t){this._source.prepare&&this._source.prepare(),this._state.coalesceChanges(this._tiles,this.map?this.map.painter:null);for(const e in this._tiles){const i=this._tiles[e];i.upload(t),i.prepare(this.map.style.imageManager,this.map?this.map.painter:null,this._source.scope)}}getIds(){return ti(this._tiles).map((t=>t.tileID)).sort(Ky).map((t=>t.key))}getRenderableIds(t,e){const i=[];for(const n in this._tiles)this._isIdRenderable(+n,t,e)&&i.push(this._tiles[n]);return t?i.sort(((t,e)=>{const i=t.tileID,n=e.tileID,r=new Ue(i.canonical.x,i.canonical.y)._rotate(this.transform.angle),o=new Ue(n.canonical.x,n.canonical.y)._rotate(this.transform.angle);return i.overscaledZ-n.overscaledZ||o.y-r.y||o.x-r.x})).map((t=>t.tileID.key)):i.map((t=>t.tileID)).sort(Ky).map((t=>t.key))}hasRenderableParent(t){const e=this.findLoadedParent(t,0);return!!e&&this._isIdRenderable(e.tileID.key)}_isIdRenderable(t,e,i){return this._tiles[t]&&this._tiles[t].hasData()&&!this._coveredTiles[t]&&(e||!this._tiles[t].holdingForFade())&&(i||!this._shadowCasterTiles[t])}reload(){if(this._paused)this._shouldReloadOnResume=!0;else{this._cache.reset();for(const t in this._tiles)"errored"!==this._tiles[t].state&&this._reloadTile(+t,"reloading")}}_reloadTile(t,e){const i=this._tiles[t];i&&("loading"!==i.state&&(i.state=e),this._loadTile(i,this._tileLoaded.bind(this,i,t,e)))}_tileLoaded(t,e,i,n){if(n)if(t.state="errored",404!==n.status)this._source.fire(new $n(n,{tile:t}));else{if(!(t.tileID.key in this._loadedParentTiles))return void this._source.fire(new Pn("data",{dataType:"source",sourceDataType:"error",sourceId:this._source.id}));if("raster-dem"===this._source.type&&this.usedForTerrain&&this.map.painter.terrain){const t=this.map.painter.terrain;this.update(this.transform,t.getScaledDemTileSize(),!0),t.resetTileLookupCache(this.id)}else this.update(this.transform)}else t.timeAdded=ki.now(),"expired"===i&&(t.refreshedUponExpiration=!0),this._setTileReloadTimer(e,t),"raster-dem"===this._source.type&&t.dem&&this._backfillDEM(t),this._state.initializeTileState(t,this.map?this.map.painter:null),this._source.fire(new Pn("data",{dataType:"source",tile:t,coord:t.tileID,sourceCacheId:this.id}))}_backfillDEM(t){const e=this.getRenderableIds();for(let n=0;n1||(Math.abs(i)>1&&(1===Math.abs(i+r)?i+=r:1===Math.abs(i-r)&&(i-=r)),e.dem&&t.dem&&(t.dem.backfillBorder(e.dem,i,n),t.neighboringTiles&&t.neighboringTiles[o]&&(t.neighboringTiles[o].backfilled=!0)))}}getTile(t){return this.getTileByID(t.key)}getTileByID(t){return this._tiles[t]}_retainLoadedChildren(t,e,i,n){for(const r in this._tiles){let o=this._tiles[r];if(n[r]||!o.hasData()||o.tileID.overscaledZi)continue;let s=o.tileID;for(;o&&o.tileID.overscaledZ>e+1;){const t=o.tileID.scaledTo(o.tileID.overscaledZ-1);o=this._tiles[t.key],o&&o.hasData()&&(s=t)}let a=s;for(;a.overscaledZ>e;)if(a=a.scaledTo(a.overscaledZ-1),t[a.key]){n[s.key]=s;break}}}findLoadedParent(t,e){if(t.key in this._loadedParentTiles){const i=this._loadedParentTiles[t.key];return i&&i.tileID.overscaledZ>=e?i:null}for(let i=t.overscaledZ-1;i>=e;i--){const e=t.scaledTo(i),n=this._getLoadedTile(e);if(n)return n}}_getLoadedTile(t){const e=this._tiles[t.key];return e&&e.hasData()?e:this._cache.getByKey(this._source.reparseOverscaled?t.wrapped().key:t.canonical.key)}updateCacheSize(t,e){e=e||this._source.tileSize;const i=Math.ceil(t.width/e)+1,n=Math.ceil(t.height/e)+1,r=Math.floor(i*n*5),o="number"==typeof this._minTileCacheSize?Math.max(this._minTileCacheSize,r):r,s="number"==typeof this._maxTileCacheSize?Math.min(this._maxTileCacheSize,o):o;this._cache.setMaxSize(s)}handleWrapJump(t){const e=Math.round((t-(void 0===this._prevLng?t:this._prevLng))/360);if(this._prevLng=t,e){const t={};for(const i in this._tiles){const n=this._tiles[i];n.tileID=n.tileID.unwrapTo(n.tileID.wrap+e),t[n.tileID.key]=n}this._tiles=t;for(const t in this._timers)clearTimeout(this._timers[t]),delete this._timers[t];for(const t in this._tiles)this._setTileReloadTimer(+t,this._tiles[t])}}update(t,e,i,n){if(this.transform=t,!this._sourceLoaded||this._paused||this.transform.freezeTileCoverage)return;if(this.usedForTerrain&&!i)return;let r;if(this.updateCacheSize(t,e),"globe"!==this.transform.projection.name&&this.handleWrapJump(this.transform.center.lng),this._shadowCasterTiles={},this._coveredTiles={},this.used||this.usedForTerrain){if(this._source.tileID)r=t.getVisibleUnwrappedCoordinates(this._source.tileID).map((t=>new vd(t.canonical.z,t.wrap,t.canonical.z,t.canonical.x,t.canonical.y)));else if(0!==this.tileCoverLift){const n=t.clone();n.tileCoverLift=this.tileCoverLift,r=n.coveringTiles({tileSize:e||this._source.tileSize,minzoom:this._source.minzoom,maxzoom:this._source.maxzoom,roundZoom:this._source.roundZoom&&!i,reparseOverscaled:this._source.reparseOverscaled,isTerrainDEM:this.usedForTerrain}),this._source.minzoomt(e)))}}else r=[];if(r.length>0&&this.castsShadows&&n&&"globe"!==this.transform.projection.name&&!this.usedForTerrain&&!Jy(this._source.type)){const o=t.coveringZoomLevel({tileSize:e||this._source.tileSize,roundZoom:this._source.roundZoom&&!i}),s=Math.min(o,this._source.maxzoom),a=t.extendTileCoverForShadows(r,n,s);for(const t of a)this._shadowCasterTiles[t.key]=!0,r.push(t)}const o=this._updateRetainedTiles(r);if(Jy(this._source.type)&&0!==r.length){const t={},e={},i=Object.keys(o);for(const n of i){const i=o[n],r=this._tiles[n];if(!r||r.fadeEndTime&&r.fadeEndTimen;){r=r.scaledTo(r.overscaledZ-1);const n=this._tiles[r.key];if(n&&n.hasData()&&e[r.key]){o[t]=i.tileID;break}}}for(const e in t)o[e]||(this._coveredTiles[e]=!0,o[e]=t[e])}for(const t in o)this._tiles[t].clearFadeHold();const s=function(t,e){const i=[];for(const n in t)n in e||i.push(n);return i}(this._tiles,o);for(const t of s){const e=this._tiles[t];e.hasSymbolBuckets&&!e.holdingForFade()?e.setHoldDuration(this.map._fadeDuration):e.hasSymbolBuckets&&!e.symbolFadeFinished()||this._removeTile(+t)}this._updateLoadedParentTileCache(),this._onlySymbols&&this._source.afterUpdate&&this._source.afterUpdate()}releaseSymbolFadeTiles(){for(const t in this._tiles)this._tiles[t].holdingForFade()&&this._removeTile(+t)}_updateRetainedTiles(t){const e={};if(0===t.length)return e;const i={},n=t.reduce(((t,e)=>Math.min(t,e.overscaledZ)),1/0),r=t[0].overscaledZ,o=Math.max(r-Xy.maxOverzooming,this._source.minzoom),s=Math.max(r+Xy.maxUnderzooming,this._source.minzoom),a={};for(const i of t){const t=this._addTile(i);e[i.key]=i,t.hasData()||n=this._source.maxzoom){const t=n.children(this._source.maxzoom)[0],i=this.getTile(t);if(i&&i.hasData()){e[t.key]=t;continue}}else{const t=n.children(this._source.maxzoom);if(e[t[0].key]&&e[t[1].key]&&e[t[2].key]&&e[t[3].key])continue}let r=t.wasRequested();for(let s=n.overscaledZ-1;s>=o;--s){const o=n.scaledTo(s);if(i[o.key])break;if(i[o.key]=!0,t=this.getTile(o),!t&&r&&(t=this._addTile(o)),t&&(e[o.key]=o,r=t.wasRequested(),t.hasData()))break}}return e}_updateLoadedParentTileCache(){this._loadedParentTiles={};for(const t in this._tiles){const e=[];let i,n=this._tiles[t].tileID;for(;n.overscaledZ>0;){if(n.key in this._loadedParentTiles){i=this._loadedParentTiles[n.key];break}e.push(n.key);const t=n.scaledTo(n.overscaledZ-1);if(i=this._getLoadedTile(t),i)break;n=t}for(const t of e)this._loadedParentTiles[t]=i}}_addTile(t){let e=this._tiles[t.key];if(e)return!0!==e.isExtraShadowCaster||!!this._shadowCasterTiles[t.key]||this._reloadTile(t.key,"reloading"),e;e=this._cache.getAndRemove(t),e&&(this._setTileReloadTimer(t.key,e),e.tileID=t,this._state.initializeTileState(e,this.map?this.map.painter:null),this._cacheTimers[t.key]&&(clearTimeout(this._cacheTimers[t.key]),delete this._cacheTimers[t.key],this._setTileReloadTimer(t.key,e)));const i=Boolean(e);if(!i){const i=this.map?this.map.painter:null,n=this._source.tileSize*t.overscaleFactor();e="raster-array"===this._source.type?new Wy(t,n,this.transform.tileZoom,i,this._isRaster):new ey(t,n,this.transform.tileZoom,i,this._isRaster),this._loadTile(e,this._tileLoaded.bind(this,e,t.key,e.state))}return e?(e.uses++,this._tiles[t.key]=e,i||this._source.fire(new Pn("dataloading",{tile:e,coord:e.tileID,dataType:"source"})),e):null}_setTileReloadTimer(t,e){t in this._timers&&(clearTimeout(this._timers[t]),delete this._timers[t]);const i=e.getExpiryTimeout();i&&(this._timers[t]=setTimeout((()=>{this._reloadTile(t,"expired"),delete this._timers[t]}),i))}_removeTile(t){const e=this._tiles[t];e&&(e.uses--,delete this._tiles[t],this._timers[t]&&(clearTimeout(this._timers[t]),delete this._timers[t]),e.uses>0||(e.hasData()&&"reloading"!==e.state||"empty"===e.state?this._cache.add(e.tileID,e,e.getExpiryTimeout()):(e.aborted=!0,this._abortTile(e),this._unloadTile(e))))}clearTiles(){this._shouldReloadOnResume=!1,this._paused=!1;for(const t in this._tiles)this._removeTile(+t);this._source._clear&&this._source._clear(),this._cache.reset(),this.map&&this.usedForTerrain&&this.map.painter.terrain&&this.map.painter.terrain.resetTileLookupCache(this.id)}tilesIn(t,e,i){const n=[],r=this.transform;if(!r)return n;const o="globe"===r.projection.name,s=Ed(r.center.lng);for(const a in this._tiles){const l=this._tiles[a];if(i&&l.clearQueryDebugViz(),l.holdingForFade())continue;let c;if(o){const t=l.tileID.canonical;if(0===t.z){const e=[Math.abs(Xe(s,...Qy(t,-1))-s),Math.abs(Xe(s,...Qy(t,1))-s)];c=[0,2*e.indexOf(Math.min(...e))-1]}else{const e=[Math.abs(Xe(s,...Qy(t,-1))-s),Math.abs(Xe(s,...Qy(t,0))-s),Math.abs(Xe(s,...Qy(t,1))-s)];c=[e.indexOf(Math.min(...e))-1]}}else c=[0];for(const i of c){const o=t.containsTile(l,r,e,i);o&&n.push(o)}}return n}getShadowCasterCoordinates(){return this._getRenderableCoordinates(!1,!0)}getVisibleCoordinates(t){return this._getRenderableCoordinates(t)}_getRenderableCoordinates(t,e){const i=this.getRenderableIds(t,e).map((t=>this._tiles[t].tileID)),n="globe"===this.transform.projection.name;for(const t of i)t.projMatrix=this.transform.calculateProjMatrix(t.toUnwrapped()),t.expandedProjMatrix=n?this.transform.calculateProjMatrix(t.toUnwrapped(),!1,!0):t.projMatrix;return i}sortCoordinatesByDistance(t){const e=t.slice(),i=this.transform._camera.position,n=this.transform._camera.forward(),r={};for(const t of e){const e=1/(1r[t.key]-r[e.key])),e}hasTransition(){if(this._source.hasTransition())return!0;if(Jy(this._source.type))for(const t in this._tiles){const e=this._tiles[t];if(void 0!==e.fadeEndTime&&e.fadeEndTime>=ki.now())return!0}return!1}setFeatureState(t,e,i){this._state.updateState(t=t||"_geojsonTileLayer",e,i)}removeFeatureState(t,e,i){this._state.removeFeatureState(t=t||"_geojsonTileLayer",e,i)}getFeatureState(t,e){return this._state.getState(t=t||"_geojsonTileLayer",e)}setDependencies(t,e,i){const n=this._tiles[t];n&&n.setDependencies(e,i)}reloadTilesForDependencies(t,e){for(const i in this._tiles)this._tiles[i].hasDependency(t,e)&&this._reloadTile(+i,"reloading");this._cache.filter((i=>!i.hasDependency(t,e)))}_preloadTiles(t,e){if(!this._sourceLoaded){const i=()=>{this._sourceLoaded&&(this._source.off("data",i),this._preloadTiles(t,e))};return void this._source.on("data",i)}const i=new Map,n=Array.isArray(t)?t:[t],r=this.map.painter.terrain,o=this.usedForTerrain&&r?r.getScaledDemTileSize():this._source.tileSize;for(const t of n){const e=t.coveringTiles({tileSize:o,minzoom:this._source.minzoom,maxzoom:this._source.maxzoom,roundZoom:this._source.roundZoom&&!this.usedForTerrain,reparseOverscaled:this._source.reparseOverscaled,isTerrainDEM:this.usedForTerrain});for(const t of e)i.set(t.key,t);this.usedForTerrain&&t.updateElevation(!1)}Qe(Array.from(i.values()),((t,e)=>{const i=new ey(t,this._source.tileSize*t.overscaleFactor(),this.transform.tileZoom,this.map.painter,this._isRaster);this._loadTile(i,(t=>{"raster-dem"===this._source.type&&i.dem&&this._backfillDEM(i),e(t,i)}))}),e)}}function Ky(t,e){const i=Math.abs(2*t.wrap)-+(t.wrap0?e+2*t:t}tv.useIntegerZoom=!0;const iv=new ol({"symbol-placement":new il(sl.layout_symbol["symbol-placement"]),"symbol-spacing":new il(sl.layout_symbol["symbol-spacing"]),"symbol-avoid-edges":new il(sl.layout_symbol["symbol-avoid-edges"]),"symbol-sort-key":new nl(sl.layout_symbol["symbol-sort-key"]),"symbol-z-order":new il(sl.layout_symbol["symbol-z-order"]),"symbol-z-elevate":new il(sl.layout_symbol["symbol-z-elevate"]),"icon-allow-overlap":new il(sl.layout_symbol["icon-allow-overlap"]),"icon-ignore-placement":new il(sl.layout_symbol["icon-ignore-placement"]),"icon-optional":new il(sl.layout_symbol["icon-optional"]),"icon-rotation-alignment":new il(sl.layout_symbol["icon-rotation-alignment"]),"icon-size":new nl(sl.layout_symbol["icon-size"]),"icon-text-fit":new nl(sl.layout_symbol["icon-text-fit"]),"icon-text-fit-padding":new nl(sl.layout_symbol["icon-text-fit-padding"]),"icon-image":new nl(sl.layout_symbol["icon-image"]),"icon-rotate":new nl(sl.layout_symbol["icon-rotate"]),"icon-padding":new il(sl.layout_symbol["icon-padding"]),"icon-keep-upright":new il(sl.layout_symbol["icon-keep-upright"]),"icon-offset":new nl(sl.layout_symbol["icon-offset"]),"icon-anchor":new nl(sl.layout_symbol["icon-anchor"]),"icon-pitch-alignment":new il(sl.layout_symbol["icon-pitch-alignment"]),"text-pitch-alignment":new il(sl.layout_symbol["text-pitch-alignment"]),"text-rotation-alignment":new il(sl.layout_symbol["text-rotation-alignment"]),"text-field":new nl(sl.layout_symbol["text-field"]),"text-font":new nl(sl.layout_symbol["text-font"]),"text-size":new nl(sl.layout_symbol["text-size"]),"text-max-width":new nl(sl.layout_symbol["text-max-width"]),"text-line-height":new nl(sl.layout_symbol["text-line-height"]),"text-letter-spacing":new nl(sl.layout_symbol["text-letter-spacing"]),"text-justify":new nl(sl.layout_symbol["text-justify"]),"text-radial-offset":new nl(sl.layout_symbol["text-radial-offset"]),"text-variable-anchor":new il(sl.layout_symbol["text-variable-anchor"]),"text-anchor":new nl(sl.layout_symbol["text-anchor"]),"text-max-angle":new il(sl.layout_symbol["text-max-angle"]),"text-writing-mode":new il(sl.layout_symbol["text-writing-mode"]),"text-rotate":new nl(sl.layout_symbol["text-rotate"]),"text-padding":new il(sl.layout_symbol["text-padding"]),"text-keep-upright":new il(sl.layout_symbol["text-keep-upright"]),"text-transform":new nl(sl.layout_symbol["text-transform"]),"text-offset":new nl(sl.layout_symbol["text-offset"]),"text-allow-overlap":new il(sl.layout_symbol["text-allow-overlap"]),"text-ignore-placement":new il(sl.layout_symbol["text-ignore-placement"]),"text-optional":new il(sl.layout_symbol["text-optional"]),visibility:new il(sl.layout_symbol.visibility)});var nv={paint:new ol({"icon-opacity":new nl(sl.paint_symbol["icon-opacity"]),"icon-occlusion-opacity":new nl(sl.paint_symbol["icon-occlusion-opacity"]),"icon-emissive-strength":new nl(sl.paint_symbol["icon-emissive-strength"]),"text-emissive-strength":new nl(sl.paint_symbol["text-emissive-strength"]),"icon-color":new nl(sl.paint_symbol["icon-color"]),"icon-halo-color":new nl(sl.paint_symbol["icon-halo-color"]),"icon-halo-width":new nl(sl.paint_symbol["icon-halo-width"]),"icon-halo-blur":new nl(sl.paint_symbol["icon-halo-blur"]),"icon-translate":new il(sl.paint_symbol["icon-translate"]),"icon-translate-anchor":new il(sl.paint_symbol["icon-translate-anchor"]),"icon-image-cross-fade":new nl(sl.paint_symbol["icon-image-cross-fade"]),"text-opacity":new nl(sl.paint_symbol["text-opacity"]),"text-occlusion-opacity":new nl(sl.paint_symbol["text-occlusion-opacity"]),"text-color":new nl(sl.paint_symbol["text-color"],{runtimeType:Qn,getOverride:t=>t.textColor,hasOverride:t=>!!t.textColor}),"text-halo-color":new nl(sl.paint_symbol["text-halo-color"]),"text-halo-width":new nl(sl.paint_symbol["text-halo-width"]),"text-halo-blur":new nl(sl.paint_symbol["text-halo-blur"]),"text-translate":new il(sl.paint_symbol["text-translate"]),"text-translate-anchor":new il(sl.paint_symbol["text-translate-anchor"]),"icon-color-saturation":new il(sl.paint_symbol["icon-color-saturation"]),"icon-color-contrast":new il(sl.paint_symbol["icon-color-contrast"]),"icon-color-brightness-min":new il(sl.paint_symbol["icon-color-brightness-min"]),"icon-color-brightness-max":new il(sl.paint_symbol["icon-color-brightness-max"])}),layout:iv};class rv{constructor(t){this.type=t.property.overrides?t.property.overrides.runtimeType:Yn,this.defaultValue=t}evaluate(t){if(t.formattedSection){const e=this.defaultValue.property.overrides;if(e&&e.hasOverride(t.formattedSection))return e.getOverride(t.formattedSection)}return t.feature&&t.featureState?this.defaultValue.evaluate(t.feature,t.featureState):this.defaultValue.property.specification.default}eachChild(t){this.defaultValue.isConstant()||t(this.defaultValue.value._styleExpression.expression)}outputDefined(){return!1}serialize(){return null}}ba(rv,"FormatSectionOverride",{omit:["defaultValue"]});class ov extends Ml{constructor(e,i,n,r){super(e,nv,i,n,r),this._colorAdjustmentMatrix=t.ad.identity([]),this.hasInitialOcclusionOpacityProperties=void 0!==e.paint&&("icon-occlusion-opacity"in e.paint||"text-occlusion-opacity"in e.paint)}recalculate(t,e){super.recalculate(t,e),"auto"===this.layout.get("icon-rotation-alignment")&&(this.layout._values["icon-rotation-alignment"]="point"!==this.layout.get("symbol-placement")?"map":"viewport"),"auto"===this.layout.get("text-rotation-alignment")&&(this.layout._values["text-rotation-alignment"]="point"!==this.layout.get("symbol-placement")?"map":"viewport"),"auto"===this.layout.get("text-pitch-alignment")&&(this.layout._values["text-pitch-alignment"]=this.layout.get("text-rotation-alignment")),"auto"===this.layout.get("icon-pitch-alignment")&&(this.layout._values["icon-pitch-alignment"]=this.layout.get("icon-rotation-alignment"));const i=this.layout.get("text-writing-mode");if(i){const t=[];for(const e of i)t.indexOf(e)i in t?String(t[i]):""))}(e.properties,r)}createBucket(t){return new jg(t)}queryRadius(){return 0}queryIntersectsFeature(){return!1}_setPaintOverrides(){for(const t of nv.paint.overridableProperties){if(!ov.hasPaintOverride(this.layout,t))continue;const e=this.paint.get(t),i=new rv(e),n=new la(i,e.property.specification,this.scope,this.options);let r=null;r="constant"===e.value.kind||"source"===e.value.kind?new ua("source",n):new ha("composite",n,e.value.zoomStops,e.value._interpolationType),this.paint._values[t]=new tl(e.property,r,e.parameters)}}_handleOverridablePaintPropertyUpdate(t,e,i){return!(!this.layout||e.isDataDriven()||i.isDataDriven())&&ov.hasPaintOverride(this.layout,t)}static hasPaintOverride(t,e){const i=t.get("text-field"),n=nv.paint.properties[e];let r=!1;const o=t=>{for(const e of t)if(n.overrides&&n.overrides.hasOverride(e))return void(r=!0)};if("constant"===i.value.kind&&i.value.value instanceof pr)o(i.value.value.sections);else if("source"===i.value.kind){const t=e=>{r||(e instanceof vr&&gr(e.value)===nr?o(e.value.sections):e instanceof Tr?o(e.sections):e.eachChild(t))},e=i.value;e._styleExpression&&t(e._styleExpression.expression)}return r}getProgramIds(){const t=0!==this.paint.get("icon-opacity").constantOr(1),e=0!==this.paint.get("text-opacity").constantOr(1),i=[];return t&&i.push("symbolIcon"),e&&i.push("symbolSDF"),i}getDefaultProgramParams(t,e,i){return{config:new Wc(this,{zoom:e,lut:i}),overrideFog:!1}}}const sv=new ol({visibility:new il(sl.layout_background.visibility)});var av={paint:new ol({"background-color":new il(sl.paint_background["background-color"]),"background-pattern":new il(sl.paint_background["background-pattern"]),"background-opacity":new il(sl.paint_background["background-opacity"]),"background-emissive-strength":new il(sl.paint_background["background-emissive-strength"])}),layout:sv};const lv=new ol({visibility:new il(sl.layout_raster.visibility)});var cv={paint:new ol({"raster-opacity":new il(sl.paint_raster["raster-opacity"]),"raster-color":new rl(sl.paint_raster["raster-color"]),"raster-color-mix":new il(sl.paint_raster["raster-color-mix"]),"raster-color-range":new il(sl.paint_raster["raster-color-range"]),"raster-hue-rotate":new il(sl.paint_raster["raster-hue-rotate"]),"raster-brightness-min":new il(sl.paint_raster["raster-brightness-min"]),"raster-brightness-max":new il(sl.paint_raster["raster-brightness-max"]),"raster-saturation":new il(sl.paint_raster["raster-saturation"]),"raster-contrast":new il(sl.paint_raster["raster-contrast"]),"raster-resampling":new il(sl.paint_raster["raster-resampling"]),"raster-fade-duration":new il(sl.paint_raster["raster-fade-duration"]),"raster-emissive-strength":new il(sl.paint_raster["raster-emissive-strength"]),"raster-array-band":new il(sl.paint_raster["raster-array-band"]),"raster-elevation":new il(sl.paint_raster["raster-elevation"])}),layout:lv};function dv(e,i,n,r,o,s,a,l){const c=[e,i,1,n,r,1,o,s,1],d=[a,l,1],u=t.bC.adjoint([],c),[h,p,f]=t._.transformMat3(d,d,u);return t.bC.multiply(c,c,[h,0,0,0,p,0,0,0,f])}function uv(e,i,n,r,o,s,a,l){const c=function(e,i,n,r,o,s,a,l){const c=dv(0,0,1,0,1,1,0,1),d=dv(e,i,n,r,o,s,a,l),u=t.bC.adjoint([],c);return t.bC.multiply(d,d,u)}(e,i,n,r,o,s,a,l);return[c[2]/c[8]/uo,c[5]/c[8]/uo]}function hv(t){return[t[0],Math.min(Math.max(t[1],-Pd),Pd)]}class pv extends zn{constructor(t,e,i,n){super(),this.id=t,this.dispatcher=i,this.coordinates=e.coordinates,this.type="image",this.minzoom=0,this.maxzoom=22,this.tileSize=512,this.tiles={},this._loaded=!1,this.onNorthPole=!1,this.onSouthPole=!1,this.setEventedParent(n),this.options=e,this._dirty=!1}load(t,e){if(this._loaded=e||!1,this.fire(new Pn("dataloading",{dataType:"source"})),this.url=this.options.url,!this.url)return t&&(this.coordinates=t),this._loaded=!0,void this._finishLoading();this._imageRequest=an(this.map._requestManager.transformRequest(this.url,Ki.Image),((e,i)=>{this._imageRequest=null,this._loaded=!0,e?this.fire(new $n(e)):i&&(this.image=i instanceof HTMLImageElement?ki.getImageData(i):i,this._dirty=!0,this.width=this.image.width,this.height=this.image.height,t&&(this.coordinates=t),this._finishLoading())}))}loaded(){return this._loaded}updateImage(t){return t.url?(this._imageRequest&&t.url!==this.options.url&&(this._imageRequest.cancel(),this._imageRequest=null),this.options.url=t.url,this.load(t.coordinates,this._loaded),this):this}setTexture(t){if(!(t.handle instanceof WebGLTexture))throw new Error("The provided handle is not a WebGLTexture instance");return this.texture=new Gg(this.map.painter.context,t.handle),this.width=t.dimensions[0],this.height=t.dimensions[1],this._dirty=!1,this._loaded=!0,this._finishLoading(),this}_finishLoading(){this.map&&(this.setCoordinates(this.coordinates),this.fire(new Pn("data",{dataType:"source",sourceDataType:"metadata"})))}onAdd(t){this.map=t,this.load()}onRemove(t){this._imageRequest&&(this._imageRequest.cancel(),this._imageRequest=null),!this.texture||this.texture instanceof Gg||this.texture.destroy(),this.boundsBuffer&&(this.boundsBuffer.destroy(),this.elevatedGlobeVertexBuffer&&this.elevatedGlobeVertexBuffer.destroy(),this.elevatedGlobeIndexBuffer&&this.elevatedGlobeIndexBuffer.destroy())}setCoordinates(t){if(this.coordinates=t,this._boundsArray=void 0,this._unsupportedCoords=!1,!t.length)return this;this.onNorthPole=!1,this.onSouthPole=!1;let e=t[0][1],i=t[0][1];for(const n of t)n[1]>i&&(i=n[1]),n[1]Pd?this.onNorthPole=!0:n1&&(l-=1),new gd(s,l,Math.floor((i+r)/2*a))}(e),this.minzoom=this.maxzoom=this.tileID.z}return this.fire(new Pn("data",{dataType:"source",sourceDataType:"content"})),this}_clear(){this._boundsArray=void 0,this._unsupportedCoords=!1}_prepareData(e){for(const t in this.tiles){const e=this.tiles[t];"loaded"!==e.state&&(e.state="loaded",e.texture=this.texture)}if(this._boundsArray||this.onNorthPole||this.onSouthPole||this._unsupportedCoords)return;const i=eg(new gd(0,0,0),this.map.transform.projection),n=[i.projection.project(this.coordinates[0][0],this.coordinates[0][1]),i.projection.project(this.coordinates[1][0],this.coordinates[1][1]),i.projection.project(this.coordinates[2][0],this.coordinates[2][1]),i.projection.project(this.coordinates[3][0],this.coordinates[3][1])];if(!function(t){const e=t[1].x-t[0].x,i=t[1].y-t[0].y,n=t[2].x-t[1].x,r=t[2].y-t[1].y,o=t[3].x-t[2].x,s=t[3].y-t[2].y,a=t[0].x-t[3].x,l=t[0].y-t[3].y,c=e*r-n*i,d=n*s-o*r,u=o*l-a*s,h=a*i-e*l;return c>0&&d>0&&u>0&&h>0||c{const e=r.projection.project(t[0],t[1]);return ig(r,e)._round()}));this.perspectiveTransform=uv(o.x,o.y,s.x,s.y,a.x,a.y,l.x,l.y);const c=this._boundsArray=new Dl;c.emplaceBack(o.x,o.y,0,0),c.emplaceBack(s.x,s.y,uo,0),c.emplaceBack(l.x,l.y,0,uo),c.emplaceBack(a.x,a.y,uo,uo),this.boundsBuffer&&(this.boundsBuffer.destroy(),this.elevatedGlobeVertexBuffer&&this.elevatedGlobeVertexBuffer.destroy(),this.elevatedGlobeIndexBuffer&&this.elevatedGlobeIndexBuffer.destroy()),this.boundsBuffer=e.createVertexBuffer(c,Jg.members),this.boundsSegments=wc.simpleSegment(0,0,4,2);const d=[],u=function(t){return[hv(t[0]),hv(t[1]),hv(t[2]),hv(t[3])]}(this.coordinates),[h,p,f,m]=function(t){let e=t[0][0],i=e,n=t[0][1],r=n;for(let o=1;oi&&(i=t[o][0]),t[o][1]r&&(r=t[o][1]);return[e,n,i-e,r-n]}(u);{const r=new Dl,[o,s,a,l]=function(t){let e=t[0].x,i=e,n=t[0].y,r=n;for(let o=1;oi&&(i=t[o].x),t[o].yr&&(r=t[o].y);return[e,n,i-e,r-n]}(n),c=t=>[(t.x-o)/a,(t.y-s)/l],[u,_,g,y]=n.map(c),v=function(e,i,n,r,o,s,a,l){const c=dv(0,0,1,0,1,1,0,1),d=dv(e,i,n,r,o,s,a,l),u=t.bC.adjoint([],d);return t.bC.multiply(c,c,u)}(u[0],u[1],_[0],_[1],g[0],g[1],y[0],y[1]);this.elevatedGlobePerspectiveTransform=uv(u[0],u[1],_[0],_[1],g[0],g[1],y[0],y[1]);const x=(e,i)=>{d.push(e.lng);const n=Math.round((e.lng-h)/f*uo),o=Math.round((e.lat-p)/m*uo),s=c(i),a=t._.transformMat3([],[s[0],s[1],1],v),l=Math.round(a[0]/a[2]*uo),u=Math.round(a[1]/a[2]*uo);r.emplaceBack(n,o,l,u)},b=n[3].x-n[0].x,w=n[3].y-n[0].y,T=n[2].x-n[1].x,S=n[2].y-n[1].y;for(let t=0;t{i.emplaceBack(e,n,r);const o=d[e],s=d[n],a=d[r],l=Math.min(Math.min(o,s),a),c=Math.max(Math.max(o,s),a)-l;c>this.maxLongitudeTriangleSize&&(this.maxLongitudeTriangleSize=c),t.push(l+c/2)};for(let t=0;te));i.sort(((e,i)=>t[e]-t[i]));const n=[],r=new Kl;for(let o=0;o{o.segments.push({vertexOffset:0,primitiveOffset:t,vertexLength:e.segments[0].vertexLength,primitiveLength:i,sortKey:void 0,vaos:{}})},a=.51*this.maxLongitudeTriangleSize;if(Math.abs(i[0]-n)0){const n=function(e,i){const n=i.worldSize,r=Cd(1,0)*n*kd(i.center.lat,i.zoom)/Gu(n),o=Cd(1,i.center.lat)*n,s=t.ad.identity([]);return t.ad.rotateY(s,s,Ge(i.center.lng)),t.ad.rotateX(s,s,Ge(i.center.lat)),t.ad.translate(s,s,[0,0,ed]),t.ad.scale(s,s,[r,r,r*o]),t.ad.translate(s,s,[i.point.x-.5*n,i.point.y-.5*n,0]),t.ad.multiply(s,s,e),t.ad.multiply(s,i.globeMatrix,s)}(e,i);return function(e,i,n){const r=(e,i,n)=>{const r=t._.length(e),o=t._.length(i),s=ku(e,i,n);return t._.scale(s,s,1/t._.length(s)*Vn(r,o,n))},o=r([e[0],e[1],e[2]],[i[0],i[1],i[2]],n),s=r([e[4],e[5],e[6]],[i[4],i[5],i[6]],n),a=r([e[8],e[9],e[10]],[i[8],i[9],i[10]],n),l=ku([e[12],e[13],e[14]],[i[12],i[13],i[14]],n);return[o[0],o[1],o[2],0,s[0],s[1],s[2],0,a[0],a[1],a[2],0,l[0],l[1],l[2],1]}(o,n,r)}return o}function kv(t,e,i,n){const r=wu.projectAabbCorners(n,i);let o=Number.MAX_VALUE,s=-1;for(let t=0;tnew Ue(r[t][0],r[t][1]);let l;switch(s){case 0:case 6:l=[a(1),a(5),a(4),a(7),a(3),a(2),a(1)];break;case 1:case 7:l=[a(0),a(4),a(5),a(6),a(2),a(3),a(0)];break;case 3:case 5:l=[a(1),a(0),a(4),a(7),a(6),a(2),a(1)];break;default:l=[a(1),a(5),a(6),a(7),a(3),a(0),a(1)]}if(Yd(t,l))return o}const Dv=Ll([{name:"a_pos_3f",components:3,type:"Float32"}]),zv=Ll([{name:"a_color_3f",components:3,type:"Float32"}]),Rv=Ll([{name:"a_color_4f",components:4,type:"Float32"}]),Ov=Ll([{name:"a_uv_2f",components:2,type:"Float32"}]),Bv=Ll([{name:"a_normal_3f",components:3,type:"Float32"}]),Fv=Ll([{name:"a_normal_matrix0",components:4,type:"Float32"},{name:"a_normal_matrix1",components:4,type:"Float32"},{name:"a_normal_matrix2",components:4,type:"Float32"},{name:"a_normal_matrix3",components:4,type:"Float32"}]),Nv=Ll([{name:"a_pbr",components:4,type:"Uint16"},{name:"a_heightBasedEmissiveStrength",components:3,type:"Float32"}]);class Uv{constructor(t,e,i,n){this.message=(t?`${t}: `:"")+i,n&&(this.identifier=n),null!=e&&e.__line__&&(this.line=e.__line__)}}function jv(t,e){const i=-1===t.indexOf("://");try{return new URL(t,i&&e?"http://example.com":void 0),!0}catch(t){return!1}}class Vv{constructor(t,e){this.feature=t,this.instancedDataOffset=e,this.instancedDataCount=0,this.rotation=[0,0,0],this.scale=[1,1,1],this.translation=[0,0,0]}}class Gv{constructor(){this.instancedDataArray=new oc,this.instancesEvaluatedElevation=[],this.features=[],this.idToFeaturesIndex={}}}class Zv{constructor(t){this.zoom=t.zoom,this.canonical=t.canonical,this.layers=t.layers,this.layerIds=this.layers.map((t=>t.fqid)),this.projection=t.projection,this.index=t.index,this.hasZoomDependentProperties=this.layers[0].isZoomDependent(),this.stateDependentLayerIds=this.layers.filter((t=>t.isStateDependent())).map((t=>t.id)),this.hasPattern=!1,this.instancesPerModel={},this.validForExaggeration=0,this.maxVerticalOffset=0,this.maxScale=0,this.maxHeight=0,this.lookupDim=this.zoom>this.canonical.z?256:this.zoom>15?75:100,this.instanceCount=0,this.terrainElevationMin=0,this.terrainElevationMax=0,this.validForDEMTile={id:null,timestamp:0},this.modelUris=[],this.modelsRequested=!1,this.activeReplacements=[],this.replacementUpdateTime=0}updateFootprints(t,e){}populate(t,e,i,n){this.tileToMeter=zd(i);const r=this.layers[0]._featureFilter.needGeometry;this.lookup=new Uint8Array(this.lookupDim*this.lookupDim);for(const{feature:o,id:s,index:a,sourceLayerIndex:l}of t){const t=null!=s?s:o.properties&&o.properties.hasOwnProperty("id")?o.properties.id:void 0,c=Zd(o,r);if(!this.layers[0]._featureFilter.filter(new Ha(this.zoom),c,i))continue;const d={id:t,sourceLayerIndex:l,index:a,geometry:r?c.geometry:Gd(o,i,n),properties:o.properties,type:o.type,patterns:{}},u=this.addFeature(d,d.geometry,c);u&&e.featureIndex.insert(o,d.geometry,a,l,this.index,this.instancesPerModel[u].instancedDataArray.length,uo/32)}this.lookup=null}update(t,e,i,n){for(const e in this.instancesPerModel){const i=this.instancesPerModel[e];for(const e in t)i.idToFeaturesIndex.hasOwnProperty(e)&&(this.evaluate(i.features[i.idToFeaturesIndex[e]],t[e],i,!0),this.uploaded=!1)}this.maxHeight=0}updateZoomBasedPaintProperties(){if(!this.hasZoomDependentProperties)return!1;let e=!1;for(const i in this.instancesPerModel){const n=this.instancesPerModel[i];for(const i of n.features){const r=this.layers[0],o=i.feature,s=this.canonical,a=r.paint.get("model-rotation").evaluate(o,{},s),l=r.paint.get("model-scale").evaluate(o,{},s),c=r.paint.get("model-translation").evaluate(o,{},s);t._.exactEquals(i.rotation,a)&&t._.exactEquals(i.scale,l)&&t._.exactEquals(i.translation,c)||(this.evaluate(i,i.featureStates,n,!0),e=!0)}}return e}updateReplacement(t,e,i){if(e.updateTime===this.replacementUpdateTime)return!1;this.replacementUpdateTime=e.updateTime;const n=e.getReplacementRegionsForTile(t.toUnwrapped(),!0);if(Pp(this.activeReplacements,n))return!1;this.activeReplacements=n;let r=!1;for(const e in this.instancesPerModel){const n=this.instancesPerModel[e],o=n.instancedDataArray;for(const e of n.features){const n=e.instancedDataOffset,s=e.instancedDataCount;for(let e=0;euo?a-uo:a;const l=Math.floor(a),c=o.float32[s+1];let d=!1;for(const e of this.activeReplacements)if(!(e.orderl||l>e.max.x||e.min.y>c||c>e.max.y)&&(d=Op(Rp(l,c,t.canonical,e.footprintTileId.canonical),e),d))break;o.float32[s]=d?a+uo:a,r=r||d}}}return r}isEmpty(){for(const t in this.instancesPerModel)if(0!==this.instancesPerModel[t].instancedDataArray.length)return!1;return!0}uploadPending(){return!this.uploaded}upload(t){if(!this.uploaded)for(const e in this.instancesPerModel){const i=this.instancesPerModel[e];i.instancedDataArray.length=uo||e.y=uo)continue;const t=(this.lookupDim-1)/uo,i=this.lookupDim*(e.y*t|0)+e.x*t|0;if(this.lookup){if(0!==this.lookup[i])continue;this.lookup[i]=1}this.instanceCount++;const n=s.length;s.resize(n+1),o.instancesEvaluatedElevation.push(0),s.float32[16*n]=e.x,s.float32[16*n+1]=e.y}return a.instancedDataCount=o.instancedDataArray.length-a.instancedDataOffset,a.instancedDataCount>0&&(t.id&&(o.idToFeaturesIndex[t.id]=o.features.length),o.features.push(a),this.evaluate(a,{},o,!1)),r}getModelUris(){return this.modelUris}evaluate(t,e,i,n){const r=this.layers[0],o=t.feature,s=this.canonical,a=t.rotation=r.paint.get("model-rotation").evaluate(o,e,s),l=t.scale=r.paint.get("model-scale").evaluate(o,e,s),c=t.translation=r.paint.get("model-translation").evaluate(o,e,s),d=r.paint.get("model-color").evaluate(o,e,s);d.a=r.paint.get("model-color-mix-intensity").evaluate(o,e,s);const u=[];this.maxVerticalOffset10?this.tileToMeter:zd(s,p)),a[o+4]=c[0],a[o+5]=c[1],a[o+6]=c[2]+l,a[o+7]=u[0],a[o+8]=u[1],a[o+9]=u[2],a[o+10]=u[4],a[o+11]=u[5],a[o+12]=u[6],a[o+13]=u[8],a[o+14]=u[9],a[o+15]=u[10],i.instancesEvaluatedElevation[r]=c[2]}}}ba(Zv,"ModelBucket",{omit:["layers"]}),ba(Gv,"PerModelAttributes"),ba(Vv,"ModelFeature");const qv=new ol({visibility:new il(sl.layout_model.visibility),"model-id":new nl(sl.layout_model["model-id"])});var Hv={paint:new ol({"model-opacity":new il(sl.paint_model["model-opacity"]),"model-rotation":new nl(sl.paint_model["model-rotation"]),"model-scale":new nl(sl.paint_model["model-scale"]),"model-translation":new nl(sl.paint_model["model-translation"]),"model-color":new nl(sl.paint_model["model-color"]),"model-color-mix-intensity":new nl(sl.paint_model["model-color-mix-intensity"]),"model-type":new il(sl.paint_model["model-type"]),"model-cast-shadows":new il(sl.paint_model["model-cast-shadows"]),"model-receive-shadows":new il(sl.paint_model["model-receive-shadows"]),"model-ambient-occlusion-intensity":new il(sl.paint_model["model-ambient-occlusion-intensity"]),"model-emissive-strength":new nl(sl.paint_model["model-emissive-strength"]),"model-roughness":new nl(sl.paint_model["model-roughness"]),"model-height-based-emissive-strength-multiplier":new nl(sl.paint_model["model-height-based-emissive-strength-multiplier"]),"model-cutoff-fade-range":new il(sl.paint_model["model-cutoff-fade-range"]),"model-front-cutoff":new il(sl.paint_model["model-front-cutoff"])}),layout:qv};const Wv=64,Yv={CoordinateSpaceTile:1,CoordinateSpaceYUp:2,HasMapboxMeshFeatures:4,HasMeshoptCompression:8};function Xv(e,i,n,r,o,s,a,l,c,d=!1){const u=n.zoom,h=n.project(r),p=kd(r.lat,u),f=1/p;t.ad.identity(e),t.ad.translate(e,e,[h.x+a[0]*f,h.y+a[1]*f,a[2]]);let m=1,_=1;const g=n.worldSize;if(d){if("mercator"===n.projection.name){let e=0;n.elevation&&(e=n.elevation.getAtPointOrZero(new Rd(h.x/g,h.y/g),0));const i=t.aA.transformMat4([],[h.x,h.y,e,1],n.projMatrix)[3]/n.cameraToCenterDistance;m=i,_=i*kd(n.center.lat,u)}else if("globe"===n.projection.name){const i=$v(e,n),o=t.ad.multiply([],n.projMatrix,i),s=[0,0,0,1];t.aA.transformMat4(s,s,o);const a=s[3]/n.cameraToCenterDistance,l=Hu(u),c=n.projection.pixelsPerMeter(r.lat,g)*kd(r.lat,u),d=n.projection.pixelsPerMeter(n.center.lat,g)*kd(n.center.lat,u);m=a/Vn(c,$d(n.center.lat),l),_=a*p/c,m*=d,_*=d}}else m=f;t.ad.scale(e,e,[m,m,_]);const y=[...e],v=i.orientation,x=[];if(Lv(x,[v[0]+o[0],v[1]+o[1],v[2]+o[2]],s),t.ad.multiply(e,y,x),l&&n.elevation){let o=0;const s=[];if(c&&n.elevation){o=function(e,i,n,r,o){const s=i.elevation;if(!s)return 0;const a=wu.projectAabbCorners(n,r),l=Cd(1,o.lat)*i.worldSize,c=function(e,i){const n=[0,0,1],r=[{corners:[0,1,3,2],dotProductWithUp:0},{corners:[1,5,2,6],dotProductWithUp:0},{corners:[0,4,1,5],dotProductWithUp:0},{corners:[2,6,3,7],dotProductWithUp:0},{corners:[4,7,5,6],dotProductWithUp:0},{corners:[0,3,4,7],dotProductWithUp:0}];for(const o of r){const r=e[o.corners[0]],s=e[o.corners[1]],a=e[o.corners[2]],l=[s[0]-r[0],s[1]-r[1],i*(s[2]-r[2])],c=t._.cross(l,l,[a[0]-r[0],a[1]-r[1],i*(a[2]-r[2])]);t._.normalize(c,c),o.dotProductWithUp=t._.dot(c,n)}return r.sort(((t,e)=>t.dotProductWithUp-e.dotProductWithUp)),r[0].corners}(a,l),d=a[c[0]],u=a[c[1]],h=a[c[2]],p=a[c[3]],f=s.getAtPointOrZero(new Rd(d[0]/i.worldSize,d[1]/i.worldSize),0),m=s.getAtPointOrZero(new Rd(u[0]/i.worldSize,u[1]/i.worldSize),0),_=s.getAtPointOrZero(new Rd(h[0]/i.worldSize,h[1]/i.worldSize),0),g=s.getAtPointOrZero(new Rd(p[0]/i.worldSize,p[1]/i.worldSize),0),y=(f+g)/2,v=(m+_)/2;return y>v?m=e.gl.NEAREST_MIPMAP_NEAREST}),t.uploaded=!0,t.image=null)}function Jv(t,e,i){t.indexBuffer=e.createIndexBuffer(t.indexArray,!1,!0),t.vertexBuffer=e.createVertexBuffer(t.vertexArray,Dv.members,!1,!0),t.normalArray&&(t.normalBuffer=e.createVertexBuffer(t.normalArray,Bv.members,!1,!0)),t.texcoordArray&&(t.texcoordBuffer=e.createVertexBuffer(t.texcoordArray,Ov.members,!1,!0)),t.colorArray&&(t.colorBuffer=e.createVertexBuffer(t.colorArray,(12===t.colorArray.bytesPerElement?zv:Rv).members,!1,!0)),t.featureArray&&(t.pbrBuffer=e.createVertexBuffer(t.featureArray,Nv.members,!0)),t.segments=wc.simpleSegment(0,0,t.vertexArray.length,t.indexArray.length);const n=t.material;n.pbrMetallicRoughness.baseColorTexture&&Kv(n.pbrMetallicRoughness.baseColorTexture,e),n.pbrMetallicRoughness.metallicRoughnessTexture&&Kv(n.pbrMetallicRoughness.metallicRoughnessTexture,e),n.normalTexture&&Kv(n.normalTexture,e),n.occlusionTexture&&Kv(n.occlusionTexture,e,i),n.emissionTexture&&Kv(n.emissionTexture,e)}function Qv(t,e,i){if(t.meshes)for(const n of t.meshes)Jv(n,e,i);if(t.children)for(const n of t.children)Qv(n,e,i)}function tx(t){if(t.meshes)for(const e of t.meshes)e.indexArray.destroy(),e.vertexArray.destroy(),e.colorArray&&e.colorArray.destroy(),e.normalArray&&e.normalArray.destroy(),e.texcoordArray&&e.texcoordArray.destroy(),e.featureArray&&e.featureArray.destroy();if(t.children)for(const e of t.children)tx(e)}function ex(t){if(t.meshes)for(const i of t.meshes)i.vertexBuffer&&(i.vertexBuffer.destroy(),i.indexBuffer.destroy(),i.normalBuffer&&i.normalBuffer.destroy(),i.texcoordBuffer&&i.texcoordBuffer.destroy(),i.colorBuffer&&i.colorBuffer.destroy(),i.pbrBuffer&&i.pbrBuffer.destroy(),i.segments.destroy(),i.material&&((e=i.material).pbrMetallicRoughness.baseColorTexture&&e.pbrMetallicRoughness.baseColorTexture.gfxTexture&&e.pbrMetallicRoughness.baseColorTexture.gfxTexture.destroy(),e.pbrMetallicRoughness.metallicRoughnessTexture&&e.pbrMetallicRoughness.metallicRoughnessTexture.gfxTexture&&e.pbrMetallicRoughness.metallicRoughnessTexture.gfxTexture.destroy(),e.normalTexture&&e.normalTexture.gfxTexture&&e.normalTexture.gfxTexture.destroy(),e.emissionTexture&&e.emissionTexture.gfxTexture&&e.emissionTexture.gfxTexture.destroy(),e.occlusionTexture&&e.occlusionTexture.gfxTexture&&e.occlusionTexture.gfxTexture.destroy()));var e;if(t.children)for(const e of t.children)ex(e)}class ix{constructor(t){this._callback=t,this._triggered=!1,"undefined"!=typeof MessageChannel&&(this._channel=new MessageChannel,this._channel.port2.onmessage=()=>{this._triggered=!1,this._callback()})}trigger(){this._triggered||(this._triggered=!0,this._channel?this._channel.port1.postMessage(!0):setTimeout((()=>{this._triggered=!1,this._callback()}),0))}remove(){this._channel=void 0,this._callback=()=>{}}}class nx{constructor(){this.tasks={},this.taskQueue=[],ai(["process"],this),this.invoker=new ix(this.process),this.nextId=0}add(t,e){const i=this.nextId++,n=function({type:t,isSymbolTile:e,zoom:i}){return i=i||0,"message"===t?0:"maybePrepare"!==t||e?"parseTile"!==t||e?"parseTile"===t&&e?300-i:"maybePrepare"===t&&e?400-i:500:200-i:100-i}(e);if(0===n){try{t()}finally{}return null}return this.tasks[i]={fn:t,metadata:e,priority:n,id:i},this.taskQueue.push(i),this.invoker.trigger(),{cancel:()=>{delete this.tasks[i]}}}process(){try{if(this.taskQueue=this.taskQueue.filter((t=>!!this.tasks[t])),!this.taskQueue.length)return;const t=this.pick();if(null===t)return;const e=this.tasks[t];if(delete this.tasks[t],this.taskQueue.length&&this.invoker.trigger(),!e)return;e.fn()}finally{}}pick(){let t=null,e=1/0;for(let i=0;i{i&&delete this.callbacks[s],this.target.postMessage({id:s,type:"",targetMapId:n,sourceMapId:this.mapId})}}}receive(t){const e=t.data,i=e.id;if(i&&(!e.targetMapId||this.mapId===e.targetMapId))if(""===e.type){const t=this.cancelCallbacks[i];delete this.cancelCallbacks[i],t&&t.cancel()}else if(e.mustQueue||gi()){const t=this.callbacks[i],n=this.scheduler.add((()=>this.processTask(i,e)),t&&t.metadata||{type:"message"});n&&(this.cancelCallbacks[i]=n)}else this.processTask(i,e)}processTask(t,e){if(delete this.cancelCallbacks[t],""===e.type){const i=this.callbacks[t];delete this.callbacks[t],i&&(e.error?i(Ea(e.error)):i(null,Ea(e.data)))}else{const i=new Set,n=e.hasCallback?(e,n)=>{this.target.postMessage({id:t,type:"",sourceMapId:this.mapId,error:e?Sa(e):null,data:Sa(n,i)},i)}:t=>{},r=Ea(e.data);if(this.parent[e.type])this.parent[e.type](e.sourceMapId,r,n);else if(this.parent.getWorkerSource){const t=e.type.split(".");this.parent.getWorkerSource(e.sourceMapId,t[0],r.source,r.scope)[t[1]](r,n)}else n(new Error(`Could not find function ${e.type}`))}}remove(){this.scheduler.remove(),this.target.removeEventListener("message",this.receive,!1)}}class ox{constructor(t,e){this.workerPool=t,this.actors=[],this.currentActor=0,this.id=ni();const i=this.workerPool.acquire(this.id);for(let t=0;t{this.ready=!0}))}broadcast(t,e,i){Qe(this.actors,((i,n)=>{i.send(t,e,n)}),i=i||function(){})}getActor(){return this.currentActor=(this.currentActor+1)%this.actors.length,this.actors[this.currentActor]}remove(){this.actors.forEach((t=>{t.remove()})),this.actors=[],this.workerPool.release(this.id)}}ox.Actor=rx;var sx={workerUrl:"",workerClass:null,workerParams:void 0};function ax(){return null!=sx.workerClass?new sx.workerClass:new self.Worker(sx.workerUrl,sx.workerParams)}const lx="mapboxgl_preloaded_worker_pool";class cx{constructor(){this.active={}}acquire(t){if(!this.workers)for(this.workers=[];this.workers.length{t.terminate()})),this.workers=null)}isPreloaded(){return!!this.active[lx]}numActive(){return Object.keys(this.active).length}}let dx;function ux(){return dx||(dx=new cx),dx}cx.workerCount=2;let hx,px,fx,mx,_x,gx=null;function yx(){return gi()&&self.worker&&self.worker.dracoUrl?self.worker.dracoUrl:px||n.DRACO_URL}function vx(){if(gi()&&self.worker&&self.worker.meshoptUrl)return self.worker.meshoptUrl;if(mx)return mx;const t=new Uint8Array([0,97,115,109,1,0,0,0,1,4,1,96,0,0,3,3,2,0,0,5,3,1,0,1,12,1,0,10,22,2,12,0,65,0,65,0,65,0,252,10,0,0,11,7,0,65,0,253,15,26,11]);if("object"!=typeof WebAssembly)throw new Error("WebAssembly not supported, cannot instantiate meshoptimizer");return mx=WebAssembly.validate(t)?n.MESHOPT_SIMD_URL:n.MESHOPT_URL,mx}const xx={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},bx={5120:"DT_INT8",5121:"DT_UINT8",5122:"DT_INT16",5123:"DT_UINT16",5125:"DT_UINT32",5126:"DT_FLOAT32"},wx={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16};function Tx(t,e,i){const n=i.json.bufferViews.length,r=i.buffers.length;e.bufferView=n,i.json.bufferViews[n]={buffer:r,byteLength:t.byteLength},i.buffers[r]=t}const Sx="KHR_draco_mesh_compression";function Ex(t,e){const i=t.extensions&&t.extensions[Sx];if(!i)return;const n=new fx.Decoder,r=$x(e,i.bufferView),o=new fx.Mesh;if(!n.DecodeArrayToMesh(r,r.byteLength,o))throw new Error("Failed to decode Draco mesh");const s=e.json.accessors[t.indices],a=xx[s.componentType],l=s.count*a.BYTES_PER_ELEMENT,c=fx._malloc(l);a===Uint16Array?n.GetTrianglesUInt16Array(o,l,c):n.GetTrianglesUInt32Array(o,l,c),Tx(fx.memory.buffer.slice(c,c+l),s,e),fx._free(c);for(const r of Object.keys(i.attributes)){const s=n.GetAttributeByUniqueId(o,i.attributes[r]),a=e.json.accessors[t.attributes[r]],l=bx[a.componentType],c=a.count*wx[a.type]*xx[a.componentType].BYTES_PER_ELEMENT,d=fx._malloc(c);n.GetAttributeDataArrayForAllPoints(o,s,fx[l],c,d),Tx(fx.memory.buffer.slice(d,d+c),a,e),fx._free(d)}n.destroy(),o.destroy(),delete t.extensions[Sx]}const Mx="EXT_meshopt_compression";function Cx(t,e){if(!t.extensions||!t.extensions[Mx])return;const i=t.extensions[Mx],n=new Uint8Array(e.buffers[i.buffer],i.byteOffset||0,i.byteLength||0),r=new Uint8Array(i.count*i.byteStride);_x.decodeGltfBuffer(r,i.count,i.byteStride,n,i.mode,i.filter),t.buffer=e.buffers.length,t.byteOffset=0,e.buffers[t.buffer]=r.buffer,delete t.extensions[Mx]}const Ax=1179937895,Ix=new TextDecoder("utf8");function Lx(t,e){return new URL(t,e).href}function Px(t,e,i,n){return fetch(Lx(t.uri,n)).then((t=>t.arrayBuffer())).then((t=>{e.buffers[i]=t}))}function $x(t,e){const i=t.json.bufferViews[e];return new Uint8Array(t.buffers[i.buffer],i.byteOffset||0,i.byteLength)}function kx(t,e,i,n){if(t.uri){const r=Lx(t.uri,n);return fetch(r).then((t=>t.blob())).then((t=>createImageBitmap(t))).then((t=>{e.images[i]=t}))}if(void 0!==t.bufferView){const n=$x(e,t.bufferView),r=new Blob([n],{type:t.mimeType});return createImageBitmap(r).then((t=>{e.images[i]=t}))}}function Dx(t,e=0,i){const n={json:null,images:[],buffers:[]};if(new Uint32Array(t,e,1)[0]===Ax){const i=new Uint32Array(t,e);let r=2;const o=(i[r++]>>2)-3,s=i[r++]>>2;if(r++,n.json=JSON.parse(Ix.decode(i.subarray(r,r+s))),r+=s,r{const t=[],e=a&&a.includes(Sx),r=a&&a.includes(Mx);if(e&&t.push(function(){if(!fx)return hx||(hx=function(t){let e,i=null;function n(){e=new Uint8Array(i.buffer)}function r(){throw new Error("Unexpected Draco error.")}const o={a:{a:r,d:function(t,i,n){return e.copyWithin(t,i,i+n)},c:function(t){const r=e.length,o=Math.max(t>>>0,Math.ceil(1.2*r)),s=Math.ceil((o-r)/65536);try{return i.grow(s),n(),!0}catch(t){return!1}},b:r}};return(WebAssembly.instantiateStreaming?WebAssembly.instantiateStreaming(t,o):t.then((t=>t.arrayBuffer())).then((t=>WebAssembly.instantiate(t,o)))).then((t=>{const{Rb:r,Qb:o,P:s,T:a,X:l,Ja:c,La:d,Qa:u,Va:h,Wa:p,eb:f,jb:m,f:_,e:g,yb:y,zb:v,Ab:x,Bb:b,Db:w,Gb:T}=t.instance.exports;i=g;const S=(()=>{let t=0,i=0,n=0,s=0;return a=>{n&&(r(s),r(t),i+=n,n=t=0),t||(i+=128,t=o(i));const l=a.length+7&-8;let c=t;l>=i&&(n=l,c=s=o(l));for(let t=0;t{fx=t,hx=void 0})))}()),r&&t.push(function(){if(_x)return;const t=function(t){let e;const i=WebAssembly.instantiateStreaming(t,{}).then((t=>{e=t.instance,e.exports.__wasm_call_ctors()})),n={NONE:"",OCTAHEDRAL:"meshopt_decodeFilterOct",QUATERNION:"meshopt_decodeFilterQuat",EXPONENTIAL:"meshopt_decodeFilterExp"},r={ATTRIBUTES:"meshopt_decodeVertexBuffer",TRIANGLES:"meshopt_decodeIndexBuffer",INDICES:"meshopt_decodeIndexSequence"};return{ready:i,supported:!0,decodeGltfBuffer(t,i,o,s,a,l){!function(t,e,i,n,r,o,s){const a=t.exports.sbrk,l=n+3&-4,c=a(l*r),d=a(o.length),u=new Uint8Array(t.exports.memory.buffer);u.set(o,d);const h=e(c,n,r,d,o.length);if(0===h&&s&&s(c,l,r),i.set(u.subarray(c,c+n*r)),a(c-a(0)),0!==h)throw new Error(`Malformed buffer data: ${h}`)}(e,e.exports[r[a]],t,i,o,s,e.exports[n[l]])}}}(fetch(vx()));return t.ready.then((()=>{_x=t}))}()),o)for(let e=0;e{if(e&&s)for(const{primitives:t}of s)for(const e of t)Ex(e,n);if(r&&s&&l)for(const t of l)Cx(t,n);return n}))}))}function zx(t,e){const i=t.json.bufferViews[e.bufferView],n=xx[e.componentType];return new n(t.buffers[i.buffer],(e.byteOffset||0)+(i.byteOffset||0),e.count*(i.byteStride&&i.byteStride!==wx[e.type]*n.BYTES_PER_ELEMENT?i.byteStride/n.BYTES_PER_ELEMENT:wx[e.type]))}function Rx(t,e,i,n){const r=xx[e.componentType],o=function(t){switch(t){case Int8Array:return 1/127;case Uint8Array:return 1/255;case Int16Array:return 1/32767;case Uint16Array:return 1/65535;default:return 1}}(r),s=t.json.bufferViews[e.bufferView],a=s.byteStride?s.byteStride/r.BYTES_PER_ELEMENT:wx[e.type],l=i.float32,c=l.length/i.capacity;for(let t=0,i=0;t0){for(let r=0;r0){o.texcoordArray=new ic;const t=e.json.accessors[r.TEXCOORD_0];o.texcoordArray.resize(t.count);const i=zx(e,t);Rx(e,t,o.texcoordArray,i)}if(void 0!==r._FEATURE_ID_RGBA4444){const t=e.json.accessors[r._FEATURE_ID_RGBA4444];e.json.extensionsUsed&&e.json.extensionsUsed.includes("EXT_meshopt_compression")&&(o.featureData=zx(e,t))}void 0!==r._FEATURE_RGBA4444&&(o.featureData=new Uint32Array(zx(e,e.json.accessors[r._FEATURE_RGBA4444]).buffer));const u=t.material;return o.material=function(t,e){const{emissiveFactor:i=[0,0,0],alphaMode:n="OPAQUE",alphaCutoff:r=.5,normalTexture:o,occlusionTexture:s,emissiveTexture:a,doubleSided:l}=t,{baseColorFactor:c=[1,1,1,1],metallicFactor:d=1,roughnessFactor:u=1,baseColorTexture:h,metallicRoughnessTexture:p}=t.pbrMetallicRoughness||{},f=s?e[s.index]:void 0;if(s&&s.extensions&&s.extensions.KHR_texture_transform&&f){const t=s.extensions.KHR_texture_transform;f.offsetScale=[t.offset[0],t.offset[1],t.scale[0],t.scale[1]]}return{pbrMetallicRoughness:{baseColorFactor:new Un(...c),metallicFactor:d,roughnessFactor:u,baseColorTexture:h?e[h.index]:void 0,metallicRoughnessTexture:p?e[p.index]:void 0},doubleSided:l,emissiveFactor:i,alphaMode:n,alphaCutoff:r,normalTexture:o?e[o.index]:void 0,occlusionTexture:f,emissionTexture:a?e[a.index]:void 0,defined:void 0===t.defined}}(void 0!==u?e.json.materials[u]:{defined:!1},i),o}function Bx(e,i,n){const{matrix:r,rotation:o,translation:s,scale:a,mesh:l,extras:c,children:d}=e,u={};if(u.matrix=r||t.ad.fromRotationTranslationScale([],o||[0,0,0,1],s||[0,0,0],a||[1,1,1]),void 0!==l){u.meshes=n[l];const t=u.anchor=[0,0];for(const e of u.meshes){const{min:i,max:n}=e.aabb;t[0]+=i[0]+n[0],t[1]+=i[1]+n[1]}t[0]=Math.floor(t[0]/u.meshes.length/2),t[1]=Math.floor(t[1]/u.meshes.length/2)}if(c&&(c.id&&(u.id=c.id),c.lights&&(u.lights=function(t){if(!t.length)return[];const e=function(t){const e=atob(t),i=new Uint8Array(e.length);for(let t=0;t1&&n[n.length-1].equals(n[0])&&n.pop();let r=0;for(let t=0;t0&&n.reverse();const o=xh(n.flatMap((t=>[t.x,t.y])),[]);return 0===o.length?null:{vertices:n,indices:o}}function Ux(e,i){const n=[],r=[];let o=0;const s=[];for(const a of e){o=n.length;const e=a.vertexArray.float32,l=a.indexArray.uint16;for(let r=0;r0&&([r[t+1],r[t+2]]=[r[t+2],r[t+1]])}return{vertices:n,indices:r}}function jx(t){const e=function(t,e){const i=[],n=WebGL2RenderingContext;if(t.json.textures)for(const r of t.json.textures){const o={magFilter:n.LINEAR,minFilter:n.NEAREST,wrapS:n.REPEAT,wrapT:n.REPEAT};void 0!==r.sampler&&Object.assign(o,t.json.samplers[r.sampler]),i.push({image:e[r.source],sampler:o,uploaded:!1})}return i}(t,t.images),i=function(t,e){const i=[];for(const n of t.json.meshes){const r=[];for(const i of n.primitives)r.push(Ox(i,t,e));i.push(r)}return i}(t,e),{scenes:n,scene:r,nodes:o}=t.json,s=n?n[r||0].nodes:o,a=[];for(const e of s)a.push(Bx(o[e],t,i));return function(t,e,i){const n={},r=new Set;for(let o=0;o0){const e=Array.from(r.values()).sort(((t,e)=>t-e));for(let i=e.length-1;i>=0;i--)t.splice(e[i],1)}}(a,s,t.json.nodes),a}function Vx(t){t.heightmap=new Float32Array(4096),t.heightmap.fill(-1);const e=t.vertexArray.float32,i=t.aabb.min[0]-1,n=t.aabb.min[1]-1,r=Wv/(t.aabb.max[0]-i+2),o=Wv/(t.aabb.max[1]-n+2);for(let s=0;st.heightmap[c*Wv+l]&&(t.heightmap[c*Wv+l]=a)}}function Gx(e,i){const n={};n.indexArray=new Kl,n.indexArray.reserve(4*e.length),n.vertexArray=new Bl,n.vertexArray.reserve(10*e.length),n.colorArray=new Ol,n.vertexArray.reserve(10*e.length);let r=0;for(const o of e){const e=Math.min(10,Math.max(4,1.3*o.height))*i,s=[-o.normal[1],o.normal[0],0],a=Math.min(.29,.1*o.width/o.depth),l=o.width-2*o.depth*i*(a+.01),c=t._.scaleAndAdd([],o.pos,s,l/2),d=t._.scaleAndAdd([],o.pos,s,-l/2),u=[c[0],c[1],c[2]+o.height],h=[d[0],d[1],d[2]+o.height],p=t._.scaleAndAdd([],o.normal,s,a);t._.scale(p,p,e);const f=t._.scaleAndAdd([],o.normal,s,-a);t._.scale(f,f,e),t._.add(p,c,p),t._.add(f,d,f),c[2]+=.1,d[2]+=.1,n.vertexArray.emplaceBack(p[0],p[1],p[2]),n.vertexArray.emplaceBack(f[0],f[1],f[2]),n.vertexArray.emplaceBack(c[0],c[1],c[2]),n.vertexArray.emplaceBack(d[0],d[1],d[2]),n.vertexArray.emplaceBack(u[0],u[1],u[2]),n.vertexArray.emplaceBack(h[0],h[1],h[2]),n.vertexArray.emplaceBack(c[0],c[1],c[2]),n.vertexArray.emplaceBack(d[0],d[1],d[2]),n.vertexArray.emplaceBack(p[0],p[1],p[2]),n.vertexArray.emplaceBack(f[0],f[1],f[2]);const m=l/e/2;n.colorArray.emplaceBack(-m-a,-1,m,.8),n.colorArray.emplaceBack(m+a,-1,m,.8),n.colorArray.emplaceBack(-m,0,m,1.3),n.colorArray.emplaceBack(m,0,m,1.3),n.colorArray.emplaceBack(m+a,-.8,m,.7),n.colorArray.emplaceBack(m+a,-.8,m,.7),n.colorArray.emplaceBack(0,0,m,1.3),n.colorArray.emplaceBack(0,0,m,1.3),n.colorArray.emplaceBack(m+a,-1.2,m,.8),n.colorArray.emplaceBack(m+a,-1.2,m,.8),n.indexArray.emplaceBack(6+r,4+r,8+r),n.indexArray.emplaceBack(7+r,9+r,5+r),n.indexArray.emplaceBack(0+r,1+r,2+r),n.indexArray.emplaceBack(1+r,3+r,2+r),r+=10}const o={defined:!0,emissiveFactor:[0,0,0]},s={};return s.baseColorFactor=Un.white,o.pbrMetallicRoughness=s,n.material=o,n.aabb=new wu([1/0,1/0,1/0],[-1/0,-1/0,-1/0]),n}const Zx=new Float32Array(262144),qx=new Uint8Array(262144);function Hx(t){let e=0;if(t.meshes)for(const i of t.meshes)e=Math.max(e,i.aabb.max[2]);if(t.children)for(const i of t.children)e=Math.max(e,Hx(i));return e}function Wx(t,e,i){if(t.meshes)for(const n of t.meshes)n.aabb.min[0]!==1/0&&i.insert(e,n.aabb.min[0],n.aabb.min[1],n.aabb.max[0],n.aabb.max[1]);if(t.children)for(const n of t.children)Wx(n,e,i)}const Yx=["","wall","door","roof","window","lamp","logo"];class Xx{constructor(t){this.node=t,this.evaluatedRMEA=[[1,0,0,1],[1,0,0,1],[1,0,0,1],[1,0,0,1],[.4,1,0,1],[1,0,0,1],[1,0,0,1]],this.hiddenByReplacement=!1,this.evaluatedScale=[1,1,1],this.evaluatedColor=[],this.emissionHeightBasedParams=[],this.feature={type:"Point",id:t.id,geometry:[],properties:{height:Hx(t)}},this.aabb=this._getLocalBounds()}_getLocalBounds(){if(!this.node.meshes)return new wu([1/0,1/0,1/0],[-1/0,-1/0,-1/0]);if(!this.aabb){let t=0;const e=new wu([1/0,1/0,1/0],[-1/0,-1/0,-1/0]);for(const i of this.node.meshes)this.node.lightMeshIndex!==t&&(i.transformedAabb=wu.applyTransformFast(i.aabb,this.node.matrix),e.encapsulate(i.transformedAabb)),t++;this.aabb=e}return this.aabb}}class Kx{constructor(t,e,i,n,r,o){this.id=e,this.modelTraits|=Yv.CoordinateSpaceTile,this.uploaded=!1,this.hasPattern=!1,i&&(this.modelTraits|=Yv.HasMapboxMeshFeatures),n&&(this.modelTraits|=Yv.HasMeshoptCompression),this.zoom=-1,this.terrainExaggeration=1,this.projection={name:"mercator"},this.replacementUpdateTime=0,this.elevationReadFromZ=255,this.brightness=r,this.dirty=!0,this.needsUpload=!1,this.nodesInfo=[];for(const e of t)this.nodesInfo.push(new Xx(e)),Wx(e,o.featureIndexArray.length,o.grid),o.featureIndexArray.emplaceBack(this.nodesInfo.length-1,0,o.bucketLayerIDs.length-1,0)}updateFootprints(t,e){for(const i of this.getNodesInfo()){const n=i.node;n.footprint&&e.push({footprint:n.footprint,id:t})}}update(){console.log("Update 3D model bucket")}populate(){console.log("populate 3D model bucket")}uploadPending(){return!this.uploaded||this.needsUpload}upload(t){if(!this.needsUpload)return;const e=this.getNodesInfo();for(const i of e){const e=i.node;this.uploaded?this.updatePbrBuffer(e):Qv(e,t,!0)}for(const t of e)tx(t.node);this.uploaded=!0,this.needsUpload=!1}updatePbrBuffer(t){let e=!1;if(!t.meshes)return e;for(const i of t.meshes)i.pbrBuffer&&(i.pbrBuffer.updateData(i.featureArray),e=!0);return e}needsReEvaluation(t,e,i){const n=t.transform.projectionOptions,r=t.style.getBrightness(),o=this.brightness!==r;return!!(!this.uploaded||this.dirty||n.name!==this.projection.name||Jx(i.paint.get("model-color").value,o)||Jx(i.paint.get("model-color-mix-intensity").value,o)||Jx(i.paint.get("model-roughness").value,o)||Jx(i.paint.get("model-emissive-strength").value,o)||Jx(i.paint.get("model-height-based-emissive-strength-multiplier").value,o))&&(this.projection=n,this.brightness=r,!0)}evaluateScale(t,e){if(t.transform.zoom===this.zoom)return;this.zoom=t.transform.zoom;const i=this.getNodesInfo(),n=this.id.canonical;for(const t of i){const i=t.feature;t.evaluatedScale=e.paint.get("model-scale").evaluate(i,{},n)}}evaluate(t){const e=this.getNodesInfo();for(const i of e){if(!i.node.meshes)continue;const e=i.feature,n=i.node.meshes&&i.node.meshes[0].featureData,r=i.evaluatedColor[2],o=i.evaluatedRMEA[2],s=this.id.canonical;if(i.hasTranslucentParts=!1,n){for(let n=0;n=t)continue;const u=Zx[c],h=Math.abs(u);h>a&&(s=u,a=h,l=r,d=e)}if(a>.1){const o=1-(t+.5*Math.abs(l*d))/c;let a=e._dem.get(n,i)+s*o;const u=e._dem.get(n+l,i+d),h=e._dem.get(n-l,i-d,!0);(a-u)*(a-h)>0&&(a=(u+h)/2),Zx[r]=e._dem.set(n,i,a),qx[r]=t}}}}}s&&(e._demTile.needsDEMTextureUpload=!0,e._dem._timestamp=ki.now())}getNodesInfo(){return this.nodesInfo}destroy(){const t=this.getNodesInfo();for(const e of t)tx(e.node),ex(e.node)}isEmpty(){return!this.nodesInfo.length}updateReplacement(t,e){if(e.updateTime===this.replacementUpdateTime)return;this.replacementUpdateTime=e.updateTime;const i=e.getReplacementRegionsForTile(t.toUnwrapped()),n=this.getNodesInfo();for(let t=0;tt.footprint===e.footprint))}}getHeightAtTileCoord(e,i){const n=this.getNodesInfo(),r=[],o=[0,0,0],s=t.ad.identity([]);for(let a=0;ad.max[0]||i>d.max[1])continue;if(!0===l.node.hidden)return{height:0,maxHeight:l.feature.properties.height,hidden:!1,verticalScale:l.evaluatedScale[2]};t.ad.invert(s,l.node.matrix),o[0]=e,o[1]=i,t._.transformMat4(o,o,s);const u=(o[0]-c.aabb.min[0])/(c.aabb.max[0]-c.aabb.min[0])*Wv|0,h=Math.min(63,(o[1]-c.aabb.min[1])/(c.aabb.max[1]-c.aabb.min[1])*Wv|0)*Wv+Math.min(63,u),p=c.heightmap[h];if(!(p0)return{height:void 0,maxHeight:l.feature.properties.height,hidden:l.hiddenByReplacement,verticalScale:l.evaluatedScale[2]}}}}function Jx(t,e){return!t.isLightConstant&&e}function Qx(t,e,i,n,r,o,s,a){let l=(61440&e|(61440&e)>>4)>>8,c=(3840&e|(3840&e)>>4)>>4,d=240&e|(240&e)>>4;i[3]>0&&(l=Vn(l,255*i[0],i[3]),c=Vn(c,255*i[1],i[3]),d=Vn(d,255*i[2],i[3]));const u=l>16&65535,a=o?e>>16&65535:65535&e,l=(15&a)t.polygon)).flat());const g=f?l:null,[y,v]=function(e,i,n,r,o,s,a,l,c,d,u){return"globe"===e.projection.name?function(e,i,n,r,o,s,a,l,c,d,u){const h=[],p=[],f=e.projection.upVectorScale(u,e.center.lat,e.worldSize).metersToTile,m=[0,0,0,1],_=[0,0,0,1],g=(t,e,i,n)=>{t[0]=e,t[1]=i,t[2]=n,t[3]=1},y=Sf();n>0&&(n+=y),r+=y;for(const y of i){const i=[],v=[];for(const h of y){const p=h.x+o.x,y=h.y+o.y,x=e.projection.projectTilePoint(p,y,u),b=e.projection.upVector(u,h.x,h.y);let w=n,T=r;if(a){const t=Pf(p,y,n,r,a,l,c,d);w+=t.base,T+=t.top}0!==n?g(m,x.x+b[0]*f*w,x.y+b[1]*f*w,x.z+b[2]*f*w):g(m,x.x,x.y,x.z),g(_,x.x+b[0]*f*T,x.y+b[1]*f*T,x.z+b[2]*f*T),t._.transformMat4(m,m,s),t._.transformMat4(_,_,s),i.push(new Tp(m[0],m[1],m[2])),v.push(new Tp(_[0],_[1],_[2]))}h.push(i),p.push(v)}return[h,p]}(e,i,n,r,o,s,a,l,c,d,u):a?function(e,i,n,r,o,s,a,l,c){const d=[],u=[],h=[0,0,0,1];for(const p of e){const e=[],f=[];for(const d of p){const u=d.x+r.x,p=d.y+r.y,m=Pf(u,p,i,n,s,a,l,c);h[0]=u,h[1]=p,h[2]=m.base,h[3]=1,t.aA.transformMat4(h,h,o),h[3]=Math.max(h[3],1e-5);const _=new Tp(h[0]/h[3],h[1]/h[3],h[2]/h[3]);h[0]=u,h[1]=p,h[2]=m.top,h[3]=1,t.aA.transformMat4(h,h,o),h[3]=Math.max(h[3],1e-5);const g=new Tp(h[0]/h[3],h[1]/h[3],h[2]/h[3]);e.push(_),f.push(g)}d.push(e),u.push(f)}return[d,u]}(i,n,r,o,s,a,l,c,d):function(t,e,i,n,r){const o=[],s=[],a=r[8]*e,l=r[9]*e,c=r[10]*e,d=r[11]*e,u=r[8]*i,h=r[9]*i,p=r[10]*i,f=r[11]*i;for(const e of t){const t=[],i=[];for(const o of e){const e=o.x+n.x,s=o.y+n.y,m=r[0]*e+r[4]*s+r[12],_=r[1]*e+r[5]*s+r[13],g=r[2]*e+r[6]*s+r[14],y=r[3]*e+r[7]*s+r[15],v=m+a,x=_+l,b=g+c,w=Math.max(y+d,1e-5),T=m+u,S=_+h,E=g+p,M=Math.max(y+f,1e-5);t.push(new Tp(v/w,x/w,b/w)),i.push(new Tp(T/M,S/M,E/M))}o.push(t),s.push(i)}return[o,s]}(i,n,r,o,s)}(s,r,h,u,d,a,g,p,m,s.center.lat,e.tileID.canonical),x=e.queryGeometry;return function(t,e,i){let n=1/0;Kd(i,e)&&(n=Lf(i,e[0]));for(let r=0;r=3)for(let e=0;e>4;if(1!==n)throw new Error(`Got v${n} data when expected v1.`);const r=nb[15&i];if(!r)throw new Error("Unrecognized array type.");const[o]=new Uint16Array(t,2,1),[s]=new Uint32Array(t,4,1);return new rb(s,o,r,t)}constructor(t,e=64,i=Float64Array,n){if(isNaN(t)||t>1;return this.ids[i]=i,this.coords[this._pos++]=t,this.coords[this._pos++]=e,i}finish(){const t=this._pos>>1;if(t!==this.numItems)throw new Error(`Added ${t} items when expected ${this.numItems}.`);return ob(this.ids,this.coords,this.nodeSize,0,this.numItems-1,0),this._finished=!0,this}range(t,e,i,n){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");const{ids:r,coords:o,nodeSize:s}=this,a=[0,r.length-1,0],l=[];for(;a.length;){const c=a.pop()||0,d=a.pop()||0,u=a.pop()||0;if(d-u=t&&a=e&&c>1,p=o[2*h],f=o[2*h+1];p>=t&&p=e&&f=p:n>=f)&&(a.push(h+1),a.push(d),a.push(1-c))}return l}within(t,e,i){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");const{ids:n,coords:r,nodeSize:o}=this,s=[0,n.length-1,0],a=[],l=i*i;for(;s.length;){const c=s.pop()||0,d=s.pop()||0,u=s.pop()||0;if(d-u>1,p=r[2*h],f=r[2*h+1];cb(p,f,t,e)=p:e+i>=f)&&(s.push(h+1),s.push(d),s.push(1-c))}return a}}function ob(t,e,i,n,r,o){if(r-n>1;sb(t,e,s,n,r,o),ob(t,e,i,n,s-1,1-o),ob(t,e,i,s+1,r,1-o)}function sb(t,e,i,n,r,o){for(;r>n;){if(r-n>600){const s=r-n+1,a=i-n+1,l=Math.log(s),c=.5*Math.exp(2*l/3),d=.5*Math.sqrt(l*c*(s-c)/s)*(a-s/2s&&ab(t,e,n,r);as;)l--}e[2*n+o]===s?ab(t,e,n,l):(l++,ab(t,e,l,r)),lr&&(n+=(t[i]-r)*(t[i]-r)),e[i]0&&n[0]0&&n[1]0&&r[0]0&&r[1]0?Math.acos(i/n)*Ve:0;let o=0!==t||0!==e?Math.atan2(-e,-t)*Ve+90:0;return oNi&&(t.getActor().send("enforceCacheSizeLimit",Fi),Vi=0)},t.an=gn,t.ao=class{constructor(t){this.entries={},this.scheduler=t}request(t,e,i,n){const r=this.entries[t]=this.entries[t]||{callbacks:[]};if(r.result){const[t,i]=r.result;return this.scheduler?this.scheduler.add((()=>{n(t,i)}),e):n(t,i),()=>{}}return r.callbacks.push(n),r.cancel||(r.cancel=i(((i,n)=>{r.result=[i,n];for(const t of r.callbacks)this.scheduler?this.scheduler.add((()=>{t(i,n)}),e):t(i,n);setTimeout((()=>delete this.entries[t]),3e3)}))),()=>{r.result||(r.callbacks=r.callbacks.filter((t=>t!==n)),r.callbacks.length||(r.cancel(),delete this.entries[t]))}}},t.ap=function(t,e,i){const n=JSON.stringify(t.request);return t.data&&(this.deduped.entries[n]={result:[null,t.data]}),this.deduped.request(n,{type:"parseTile",isSymbolTile:t.isSymbolTile,zoom:t.tileZoom},(e=>{const n=en(t.request,((t,n,r,o)=>{t?e(t):n&&e(null,{vectorTile:i?void 0:new bp(new Lm(n)),rawData:n,cacheControl:r,expires:o})}));return()=>{n.cancel(),e()}}),e)},t.aq=Dc,t.ar=class extends Lc{constructor(t){super(t),this.current=Fc}set(t,e,i){if(this.fetchUniformLocation(t,e))for(let t=0;t({u_camera_to_center_distance:new $c(t),u_extrude_scale:new Uc(t),u_device_pixel_ratio:new $c(t),u_matrix:new Bc(t),u_inv_rot_matrix:new Bc(t),u_merc_center:new kc(t),u_tile_id:new Dc(t),u_zoom_transition:new $c(t),u_up_dir:new Dc(t),u_emissive_strength:new $c(t)}),t.bJ=t=>({u_matrix:new Bc(t),u_pixels_to_tile_units:new Uc(t),u_device_pixel_ratio:new $c(t),u_units_to_pixels:new kc(t),u_dash_image:new Pc(t),u_gradient_image:new Pc(t),u_image_height:new $c(t),u_texsize:new kc(t),u_tile_units_to_pixels:new $c(t),u_alpha_discard_threshold:new $c(t),u_trim_offset:new kc(t),u_trim_fade_range:new kc(t),u_trim_color:new zc(t),u_emissive_strength:new $c(t)}),t.bK=t=>({u_matrix:new Bc(t),u_texsize:new kc(t),u_pixels_to_tile_units:new Uc(t),u_device_pixel_ratio:new $c(t),u_image:new Pc(t),u_units_to_pixels:new kc(t),u_tile_units_to_pixels:new $c(t),u_alpha_discard_threshold:new $c(t),u_trim_offset:new kc(t)}),t.bL=Yl,t.bM=Hf,t.bN=Om,t.bO=jm,t.bP=G_,t.bQ=c_,t.bR=th,t.bS=(t,e,i,n,r,o)=>{const s=t.transform,a="globe"===s.projection.name;let l;if("map"===o.paint.get("circle-pitch-alignment"))if(a){const t=Zu(s.zoom,e.canonical)*s._pixelsPerMercatorPixel;l=Float32Array.from([t,0,0,t])}else l=s.calculatePixelsToTileUnitsMatrix(i);else l=new Float32Array([s.pixelsToGLUnits[0],0,0,s.pixelsToGLUnits[1]]);const c={u_camera_to_center_distance:t.transform.getCameraToCenterDistance(s.projection),u_matrix:t.translatePosMatrix(e.projMatrix,i,o.paint.get("circle-translate"),o.paint.get("circle-translate-anchor")),u_device_pixel_ratio:ki.devicePixelRatio,u_extrude_scale:l,u_inv_rot_matrix:Qu,u_merc_center:[0,0],u_tile_id:[0,0,0],u_zoom_transition:0,u_up_dir:[0,0,0],u_emissive_strength:o.paint.get("circle-emissive-strength")};if(a){c.u_inv_rot_matrix=n,c.u_merc_center=r,c.u_tile_id=[e.canonical.x,e.canonical.y,1{const s=t.transform;return{u_matrix:rm(t,e,i,n),u_texsize:e.imageAtlasTexture?e.imageAtlasTexture.size:[0,0],u_pixels_to_tile_units:s.calculatePixelsToTileUnitsMatrix(e),u_device_pixel_ratio:r,u_image:0,u_tile_units_to_pixels:nm(e,s),u_units_to_pixels:[1/s.pixelsToGLUnits[0],1/s.pixelsToGLUnits[1]],u_alpha_discard_threshold:0,u_trim_offset:o}},t.bV=(t,e,i,n,r,o,s)=>{const a=t.transform,l=a.calculatePixelsToTileUnitsMatrix(e);return{u_matrix:rm(t,e,i,n),u_pixels_to_tile_units:l,u_device_pixel_ratio:o,u_units_to_pixels:[1/a.pixelsToGLUnits[0],1/a.pixelsToGLUnits[1]],u_dash_image:0,u_gradient_image:1,u_image_height:r,u_texsize:sm(i)&&e.lineAtlasTexture?e.lineAtlasTexture.size:[0,0],u_tile_units_to_pixels:nm(e,t.transform),u_alpha_discard_threshold:0,u_trim_offset:s,u_trim_fade_range:i.paint.get("line-trim-fade-range"),u_trim_color:i.paint.get("line-trim-color").toRenderColor(i.lut).toArray01(),u_emissive_strength:i.paint.get("line-emissive-strength")}},t.bW=oi,t.bX=mh,t.bY=Sf,t.bZ=bd,t.b_=_f,t.ba=function(t,e,i){const n=Hu(i.zoom),r=t.style.map._antialias,o=e.options.extStandardDerivativesForceOff||t.terrain&&t.terrain.exaggeration()>0;return 0===n&&!r&&!o},t.bb=function(e){const i=e.pixelsPerMeter,n=i/Cd(1,e.center.lat),r=t.ad.identity(new Float64Array(16));return t.ad.translate(r,r,[e.point.x,e.point.y,0]),t.ad.scale(r,r,[n,n,i]),Float32Array.from(r)},t.bc=Ou,t.bd=function(t){const e=Pd-5;t=Xe(t,-e,e)/e*90;const i=Math.pow(Math.abs(Math.sin(Ge(t))),3);return Math.round(i*(sd.length-1))},t.be=function(e,i,n,r){const o=i.getNorth(),s=i.getSouth(),a=i.getWest(),l=i.getEast(),c=10){const e=180/r;t.bC.multiply(f,f,[e/d+1,0,0,0,e/u+1,0,-.5*e/h,.5*e/p,1])}return f[2]=c,f[5]=e.x,f[8]=e.y,f},t.bf=ju,t.bg=$u,t.bh=function(e,i,n){const r=t.ad.identity(new Float64Array(16)),o=(i/(1{}}},t.bo=Gg,t.bp=ai,t.bq=class{isDataAvailableAtPoint(t){const e=this._source();if(this.isUsingMockSource()||!e||t.y1)return!1;const i=e.getSource().maxzoom,n=11)return e;const r=n.getSource().maxzoom,o=1{const s=this.getAtTileOffset(e,o.x,o.y),a=r.upVector(e.canonical,o.x,o.y),l=r.upVectorScale(e.canonical,i,n).metersToTile;return t._.scale(a,a,s*l),a}}getForTilePoints(t,e,i,n){if(this.isUsingMockSource())return!1;const r=Xp.create(this,t,n);return!!r&&(e.forEach((t=>{t[2]=this.exaggeration()*r.getElevationAt(t[0],t[1],i)})),!0)}getMinMaxForTile(t){if(this.isUsingMockSource())return null;const e=this.findDEMTileFor(t);if(!e||!e.dem)return null;const i=e.dem.tree,n=e.tileID,r=1=0?t.slice(0,e):t},t.cV=function(t){return t.indexOf(wl)>=0},t.cW=function(t){const e=t.indexOf(wl);return e>=0?t.slice(e+1):""},t.cX=function(t){const e=[],i=t.id;return void 0===i&&e.push({message:`layers.${i}: missing required property "id"`}),void 0===t.render&&e.push({message:`layers.${i}: missing required method "render"`}),t.renderingMode&&"2d"!==t.renderingMode&&"3d"!==t.renderingMode&&e.push({message:`layers.${i}: property "renderingMode" must be either "2d" or "3d"`}),e},t.cY=function(t,e,i,n){return"custom"===t.type?new vv(t,e):new ib[t.type](t,e,i,n)},t.cZ=di,t.c_=Va,t.ca=1,t.cb=Ag,t.cc=0,t.cd=ec,t.ce=function(t,e,i,n,r){return Xe((t-e)/(i-e)*(r-n)+n,n,r)},t.cf=Ns,t.cg=kd,t.ch=class{constructor(t,e,i,n){this.context=t,this.format=n,this.size=i,this.texture=t.gl.createTexture();const[r,o,s]=this.size,{gl:a}=t;a.bindTexture(a.TEXTURE_3D,this.texture),t.pixelStoreUnpackFlipY.set(!1),t.pixelStoreUnpack.set(1),t.pixelStoreUnpackPremultiplyAlpha.set(!1);let l=this.format,c=a.UNSIGNED_BYTE;this.format===a.DEPTH_COMPONENT&&(l=a.DEPTH_COMPONENT16,c=a.UNSIGNED_SHORT),this.format===a.R8&&(n=a.RED),this.format===a.R32F&&(c=a.FLOAT,n=a.RED),a.texImage3D(a.TEXTURE_3D,0,l,r,o,s,0,n,c,e.data)}bind(t,e){const{context:i}=this,{gl:n}=i;n.bindTexture(n.TEXTURE_3D,this.texture),t!==this.minFilter&&(n.texParameteri(n.TEXTURE_3D,n.TEXTURE_MAG_FILTER,t),n.texParameteri(n.TEXTURE_3D,n.TEXTURE_MIN_FILTER,t),this.minFilter=t),e!==this.wrapS&&(n.texParameteri(n.TEXTURE_3D,n.TEXTURE_WRAP_S,e),n.texParameteri(n.TEXTURE_3D,n.TEXTURE_WRAP_T,e),this.wrapS=e)}destroy(){const{gl:t}=this.context;t.deleteTexture(this.texture),this.texture=null}},t.ci=$v,t.cj=[1,1,1],t.ck=Xp,t.cl=Yv,t.cm=ql,t.cn=ic,t.co=class{constructor(){this._updateTime=0,this._sourceIds=[],this._activeRegions=[],this._prevRegions=[],this._globalClipBounds={min:new Ue(1/0,1/0),max:new Ue(-1/0,-1/0)}}clear(){this._activeRegions.length>0&&++this._updateTime,this._activeRegions=[],this._prevRegions=[]}get updateTime(){return this._updateTime}getReplacementRegionsForTile(t,e=!1){const i=$p(new Ue(0,0),new Ue(uo,uo),t),n=[];if(e&&!Lp(i,this._globalClipBounds))return n;for(const e of this._activeRegions){if(e.hiddenByOverlap)continue;if(!Lp(i,e))continue;const r=kp(e.min,e.max,t);n.push({min:r.min,max:r.max,sourceId:this._sourceIds[e.priority],footprint:e.footprint,footprintTileId:e.tileId,order:e.order,clipMask:e.clipMask})}return n}setSources(t){this._setSources(t.map((t=>({getSourceId:()=>t.cache.id,getFootprints:()=>{const e=[];for(const i of t.cache.getVisibleCoordinates()){const n=t.cache.getTile(i).buckets[t.layer];n&&n.updateFootprints(i.toUnwrapped(),e)}return e},getOrder:()=>t.order,getClipMask:()=>t.clipMask}))))}_addSource(t){const e=t.getFootprints();if(0===e.length)return;const i=t.getOrder(),n=t.getClipMask();for(const t of e){if(!t.footprint)continue;const e=$p(t.footprint.min,t.footprint.max,t.id);this._activeRegions.push({min:e.min,max:e.max,hiddenByOverlap:!1,priority:this._sourceIds.length,tileId:t.id,footprint:t.footprint,order:i,clipMask:n})}this._sourceIds.push(t.getSourceId())}_computeReplacement(){this._activeRegions.sort(((t,e)=>t.priority-e.priority||Ap(t.min,e.min)||Ap(t.max,e.max)));let t=this._activeRegions.length!==this._prevRegions.length;if(!t){let e=0;for(;!t&&e!==this._activeRegions.length;){const i=this._activeRegions[e],n=this._prevRegions[e];t=i.priority!==n.priority||!Ip(i,n)||i.order!==n.order||i.clipMask!==n.clipMask,++e}}if(t){++this._updateTime;for(const t of this._activeRegions)t.order!==1/0&&(this._globalClipBounds.min.x=Math.min(this._globalClipBounds.min.x,t.min.x),this._globalClipBounds.min.y=Math.min(this._globalClipBounds.min.y,t.min.y),this._globalClipBounds.max.x=Math.max(this._globalClipBounds.max.x,t.max.x),this._globalClipBounds.max.y=Math.max(this._globalClipBounds.max.y,t.max.y));const t=t=>{const e=this._activeRegions;if(t>=e.length)return t;const i=e[t].priority;for(;t1){let e=0,i=t(e);for(;e!==i;){let n=e;const r=e;for(;n!==i;){const t=this._activeRegions[n];t.hiddenByOverlap=!1;for(let e=0;e=0;e--)this._addSource(t[e]);this._computeReplacement()}},t.cp=Dl,t.cq=Jg,t.cr=rc,t.cs=class{constructor(t){this._createGrid(t),this._createPoles(t)}destroy(){this._poleIndexBuffer.destroy(),this._gridBuffer.destroy(),this._gridIndexBuffer.destroy(),this._poleNorthVertexBuffer.destroy(),this._poleSouthVertexBuffer.destroy();for(const t of this._poleSegments)t.destroy();for(const t of this._gridSegments)t.withSkirts.destroy(),t.withoutSkirts.destroy()}_fillGridMeshWithLods(t,e){const i=new $l,n=new Kl,r=[],o=t+1+2,s=e[0]+1,a=e[0]+1+(1+e.length),l=(t,e,i)=>{let n=t===o-1?t-2:0===t?t:t-1;return n+=i?24575:0,[n,e]};for(let t=0;tt()))},t.dB=sx,t.dC=yx,t.dD=function(t){px=ki.resolveURL(t),gx||(gx=new ox(ux(),new zn)),gx.broadcast("setDracoUrl",px)},t.dE=vx,t.dF=function(t){mx=ki.resolveURL(t),gx||(gx=new ox(ux(),new zn)),gx.broadcast("setMeshoptUrl",mx)},t.dG=ti,t.dH=ba,t.dI=dh,t.dJ=I_,t.dK=eg,t.dL=dc,t.dM=am,t.dN=Dm,t.dO=Wf,t.dP=ci,t.dQ=E_,t.dR=jg,t.dS=function(t,e,i,n,r,o,s,a,l,c,d){t.createArrays(),t.tilePixelRatio=uo/(512*t.overscaling),t.compareText={},t.iconsNeedLinear=!1;const u=t.layers[0].layout,h=t.layers[0]._unevaluatedLayout._values,p={};if("composite"===t.textSizeData.kind){const{minZoom:e,maxZoom:i}=t.textSizeData;p.compositeTextSizes=[h["text-size"].possiblyEvaluate(new Ha(e),a),h["text-size"].possiblyEvaluate(new Ha(i),a)]}if("composite"===t.iconSizeData.kind){const{minZoom:e,maxZoom:i}=t.iconSizeData;p.compositeIconSizes=[h["icon-size"].possiblyEvaluate(new Ha(e),a),h["icon-size"].possiblyEvaluate(new Ha(i),a)]}p.layoutTextSize=h["text-size"].possiblyEvaluate(new Ha(l+1),a),p.layoutIconSize=h["icon-size"].possiblyEvaluate(new Ha(l+1),a),p.textMaxSize=h["text-size"].possiblyEvaluate(new Ha(18),a);const f="map"===u.get("text-rotation-alignment")&&"point"!==u.get("symbol-placement"),m=u.get("text-size");let _=!1;for(const e of t.features)if(e.icon&&e.icon.nameSecondary){_=!0;break}for(const o of t.features){const l=u.get("text-font").evaluate(o,{},a).join(","),h=m.evaluate(o,{},a),g=p.layoutTextSize.evaluate(o,{},a),y=(p.layoutIconSize.evaluate(o,{},a),{horizontal:{},vertical:void 0}),v=o.text;let x,b=[0,0];if(v){const n=v.toString(),s=u.get("text-letter-spacing").evaluate(o,{},a)*Om,c=u.get("text-line-height").evaluate(o,{},a)*Om,d=Aa(n)?s:0,p=u.get("text-anchor").evaluate(o,{},a),m=u.get("text-variable-anchor");if(!m){const t=u.get("text-radial-offset").evaluate(o,{},a);b=t?G_(p,[t*Om,j_]):u.get("text-offset").evaluate(o,{},a).map((t=>t*Om))}let _=f?"center":u.get("text-justify").evaluate(o,{},a);const x="point"===u.get("symbol-placement"),w=x?u.get("text-max-width").evaluate(o,{},a)*Om:1/0,T=o=>{t.allowVerticalPlacement&&Ca(n)&&(y.vertical=e_(v,e,i,r,l,w,c,p,o,d,b,Jm.vertical,!0,g,h))};if(!f&&m){const t="auto"===_?m.map((t=>Z_(t))):[_];let n=!1;for(let o=0;o=0||!Ca(n)){const t=e_(v,e,i,r,l,w,c,p,_,d,b,Jm.horizontal,!1,g,h);t&&(y.horizontal[_]=t)}T(x?"left":_)}}let w=!1;if(o.icon&&o.icon.namePrimary){const e=n[o.icon.namePrimary];e&&(x=u_(r[o.icon.namePrimary],o.icon.nameSecondary?r[o.icon.nameSecondary]:void 0,u.get("icon-offset").evaluate(o,{},a),u.get("icon-anchor").evaluate(o,{},a)),w=e.sdf,void 0===t.sdfIcons?t.sdfIcons=e.sdf:t.sdfIcons!==e.sdf&&pi("Style sheet warning: Cannot mix SDF and non-SDF icons in one buffer"),(e.pixelRatio!==t.pixelRatio||0!==u.get("icon-rotate").constantOr(1))&&(t.iconsNeedLinear=!0))}const T=X_(y.horizontal)||y.vertical;t.iconsInText||(t.iconsInText=!!T&&T.iconsInText),(T||x)&&q_(t,o,y,x,n,p,g,0,b,w,s,a,c,d,_)}o&&t.generateCollisionDebugBuffers(l,t.collisionBoxArray)},t.dT=Jf,t.dU=Yh,t.dV=bp,t.dW=Lm,t.dX=Yp,t.dY=Zy,t.dZ=wp,t.d_=cp,t.da=Wu,t.db=function(e){const i=[0,0,0],n=t.ad.identity(new Float64Array(16));return t.ad.multiply(n,e.pixelMatrix,e.globeMatrix),t._.transformMat4(i,i,n),new Ue(i[0],i[1])},t.dc=d,t.dd=c,t.de=function(t){const e=t.navigator?t.navigator.userAgent:null;return!!function(t){if(null==Ei){const e=t.navigator?t.navigator.userAgent:null;Ei=!!t.safari||!(!e||!(/\b(iPad|iPhone|iPod)\b/.test(e)||e.match("Safari")&&!e.match("Chrome")))}return Ei}(t)&&e&&(e.match("Version/15.4")||e.match("Version/15.5")||e.match(/CPU (OS|iPhone OS) (15_4|15_5) like Mac OS X/))},t.df=ni,t.dg=class{constructor(t,e,i){this._transformRequestFn=t,this._customAccessToken=e,this._silenceAuthErrors=!!i,this._createSkuToken()}_createSkuToken(){const t=function(){let t="";for(let e=0;ethis._skuTokenExpiresAt}transformRequest(t,e){return this._transformRequestFn&&this._transformRequestFn(t,e)||{url:t}}normalizeStyleURL(t,i){if(!o(t))return t;const n=un(t);return n.params.push(`sdk=js-${e}`),n.path=`/styles/v1${n.path}`,this._makeAPIURL(n,this._customAccessToken||i)}normalizeGlyphsURL(t,e){if(!o(t))return t;const i=un(t);return i.path=`/fonts/v1${i.path}`,this._makeAPIURL(i,this._customAccessToken||e)}normalizeModelURL(t,e){if(!o(t))return t;const i=un(t);return i.path=`/models/v1${i.path}`,this._makeAPIURL(i,this._customAccessToken||e)}normalizeSourceURL(t,e,i,n){if(!o(t))return t;const r=un(t);return r.path=`/v4/${r.authority}.json`,r.params.push("secure"),i&&r.params.push(`language=${i}`),n&&r.params.push(`worldview=${n}`),this._makeAPIURL(r,this._customAccessToken||e)}normalizeSpriteURL(t,e,i,n){const r=un(t);return o(t)?(r.path=`/styles/v1${r.path}/sprite${e}${i}`,this._makeAPIURL(r,this._customAccessToken||n)):(r.path+=`${e}${i}`,hn(r))}normalizeTileURL(t,e,i){if(this._isSkuTokenExpired()&&this._createSkuToken(),t&&!o(t))return t;const r=un(t);r.path=r.path.replace(/(\.(png|jpg)\d*)(?=$)/,`${e||i&&"raster"!==r.authority&&512===i?"@2x":""}${Gi.supported?".webp":"$1"}`),"raster"===r.authority?r.path=`/${n.RASTER_URL_PREFIX}${r.path}`:"rasterarrays"===r.authority?r.path=`/${n.RASTERARRAYS_URL_PREFIX}${r.path}`:"3dtiles"===r.authority?r.path=`/${n.TILES3D_URL_PREFIX}${r.path}`:(r.path=r.path.replace(/^.+\/v4\//,"/"),r.path=`/${n.TILE_URL_VERSION}${r.path}`);const s=this._customAccessToken||function(t){for(const e of t){const t=e.match(/^access_token=(.*)$/);if(t)return t[1]}return null}(r.params)||n.ACCESS_TOKEN;return n.REQUIRE_ACCESS_TOKEN&&s&&this._skuToken&&r.params.push(`sku=${this._skuToken}`),this._makeAPIURL(r,s)}canonicalizeTileURL(t,e){const i=un(t);if(!i.path.match(/^(\/v4\/|\/(raster|rasterarrays)\/v1\/)/)||!i.path.match(/\.[\w]+$/))return t;let r="mapbox://";i.path.match(/^\/raster\/v1\//)?r+=`raster/${i.path.replace(`/${n.RASTER_URL_PREFIX}/`,"")}`:i.path.match(/^\/rasterarrays\/v1\//)?r+=`rasterarrays/${i.path.replace(`/${n.RASTERARRAYS_URL_PREFIX}/`,"")}`:r+=`tiles/${i.path.replace(`/${n.TILE_URL_VERSION}/`,"")}`;let o=i.params;return e&&(o=o.filter((t=>!t.match(/^access_token=/)))),o.length&&(r+=`?${o.join("&")}`),r}canonicalizeTileset(t,e){const i=!!e&&o(e),n=[];for(const e of t.tiles||[])r(e)?n.push(this.canonicalizeTileURL(e,i)):n.push(e);return n}_makeAPIURL(t,e){const i="See https://docs.mapbox.com/api/overview/#access-tokens-and-token-scopes",r=un(n.API_URL);if(t.protocol=r.protocol,t.authority=r.authority,"http"===t.protocol){const e=t.params.indexOf("secure");e>=0&&t.params.splice(e,1)}if("/"!==r.path&&(t.path=`${r.path}${t.path}`),!n.REQUIRE_ACCESS_TOKEN)return hn(t);if(e=e||n.ACCESS_TOKEN,!this._silenceAuthErrors){if(!e)throw new Error(`An API access token is required to use Mapbox GL. ${i}`);if("s"===e[0])throw new Error(`Use a public access token (pk.*) with Mapbox GL, not a secret access token (sk.*). ${i}`)}return t.params=t.params.filter((t=>-1===t.indexOf("access_token"))),t.params.push(`access_token=${e||""}`),hn(t)}},t.dh=function(t,e){e?Mn.add(t):Mn.delete(t)},t.di=Gi,t.dj=Tn,t.dk=En,t.dl=cn,t.dm=vn,t.dn=bn,t.dp=function(t){Mn.delete(t)},t.dq=Sn,t.dr=yn,t.ds=Qe,t.dt=e,t.du=function(t,e){Fi=t,Ni=e},t.dv=function(t,e,i=!1){if(Fa===za||Fa===Ra||Fa===Oa)throw new Error("setRTLTextPlugin cannot be called multiple times.");Na=ki.resolveURL(t),Fa=za,Ba=e,ja(),i||Za()},t.dw=Ga,t.dx=function(){ux().acquire(lx)},t.dy=function(){const t=dx;t&&(t.isPreloaded()&&1===t.numActive()?(t.release(lx),dx=null):console.warn("Could not clear WebWorkers since there are active Map instances that still reference it. The pre-warmed WebWorker pool can only be cleared when all map instances have been removed with map.remove()"))},t.dz=cx,t.e=ki,t.e0=cm,t.e1=h,t.e2=en,t.e3=function(t){let e=0;if(new Uint32Array(t,0,1)[0]!==Ax){const i=new Uint32Array(t,0,7),[,,n,r,o,s]=i;e=i.byteLength+r+o+s+o,(n!==t.byteLength||e>=t.byteLength)&&pi("Invalid b3dm header information.")}return Dx(t,e)},t.e4=function(t,e){const i=jx(t);for(const t of i){for(const e of t.meshes)Vx(e);t.lights&&(t.lightMeshIndex=t.meshes.length,t.meshes.push(Gx(t.lights,e)))}return i},t.e5=Kx,t.e6=rx,t.e7=qa,t.e8=function(t){ji(),Oi&&Oi.then((e=>{e.keys().then((i=>{for(let n=0;nt.arrayBuffer())).then((e=>Dx(e,0,t)))},t.m=class extends Uv{},t.n=Er,t.o=qn,t.p=Qg,t.q=Xs,t.r=Js,t.s=Qs,t.t=ca,t.u=al,t.v=ll,t.w=pi,t.x=pa,t.y=da,t.z=qo})),n(0,(function(t){function e(t){const e=t?t.url.toString():void 0;return e?performance.getEntriesByName(e):[]}function i(t){if("number"==typeof t||"boolean"==typeof t||"string"==typeof t||null==t)return JSON.stringify(t);if(Array.isArray(t)){let e="[";for(const n of t)e+=`${i(n)},`;return`${e}]`}let e="{";for(const n of Object.keys(t).sort())e+=`${n}:${i(t[n])},`;return`${e}}`}function n(e){let n="";for(const r of t.cE)n+=`/${i(e[r])}`;return n}class r{constructor(t){this.keyCache={},this._layers={},this._layerConfigs={},t&&this.replace(t)}replace(t,e){this._layerConfigs={},this._layers={},this.update(t,[],e)}update(e,i,r){this._options=r;for(const i of e)this._layerConfigs[i.id]=i,(this._layers[i.id]=t.cY(i,this.scope,null,this._options)).compileFilter(),this.keyCache[i.id]&&delete this.keyCache[i.id];for(const t of i)delete this.keyCache[t],delete this._layerConfigs[t],delete this._layers[t];this.familiesBySource={};const o=function(t,e){const i={};for(let r=0;rthis._layers[t.id])),i=e[0];if("none"===i.visibility)continue;const n=i.source||"";let r=this.familiesBySource[n];r||(r=this.familiesBySource[n]={});const o=i.sourceLayer||"_geojsonTileLayer";let s=r[o];s||(s=r[o]=[]),s.push(e)}}}const o=1*t.dJ;class s{constructor(e){const i={},n=[];for(const t in e){const r=e[t],s=i[t]={};for(const t in r.glyphs){const e=r.glyphs[+t];if(!e||0===e.bitmap.width||0===e.bitmap.height)continue;const i=e.metrics.localGlyph?o:1,a={x:0,y:0,w:e.bitmap.width+2*i,h:e.bitmap.height+2*i};n.push(a),s[t]=a}}const{w:r,h:s}=t.j(n),a=new t.dI({width:r||1,height:s||1});for(const n in e){const r=e[n];for(const e in r.glyphs){const s=r.glyphs[+e];if(!s||0===s.bitmap.width||0===s.bitmap.height)continue;const l=i[n][e],c=s.metrics.localGlyph?o:1;t.dI.copy(s.bitmap,a,{x:0,y:0},{x:l.x+c,y:l.y+c},s.bitmap)}}this.image=a,this.positions=i}}t.dH(s,"GlyphAtlas");class a{constructor(e){this.tileID=new t.aL(e.tileID.overscaledZ,e.tileID.wrap,e.tileID.canonical.z,e.tileID.canonical.x,e.tileID.canonical.y),this.tileZoom=e.tileZoom,this.uid=e.uid,this.zoom=e.zoom,this.lut=e.lut,this.canonical=e.tileID.canonical,this.pixelRatio=e.pixelRatio,this.tileSize=e.tileSize,this.source=e.source,this.scope=e.scope,this.overscaling=this.tileID.overscaleFactor(),this.showCollisionBoxes=e.showCollisionBoxes,this.collectResourceTiming=!!e.collectResourceTiming,this.promoteId=e.promoteId,this.isSymbolTile=e.isSymbolTile,this.tileTransform=t.dK(e.tileID.canonical,e.projection),this.projection=e.projection,this.brightness=e.brightness,this.extraShadowCaster=!!e.extraShadowCaster,this.tessellationStep=e.tessellationStep}parse(e,i,n,r,o){this.status="parsing",this.data=e,this.collisionBoxArray=new t.dL;const a=new t.dM(Object.keys(e.layers).sort()),c=new t.dN(this.tileID,this.promoteId);c.bucketLayerIDs=[];const d={},u=new t.dO(256,256),h={featureIndex:c,iconDependencies:{},patternDependencies:{},glyphDependencies:{},lineAtlas:u,availableImages:n,brightness:this.brightness},p=i.familiesBySource[this.source];for(const i in p){const r=e.layers[i];if(!r)continue;let o=!1,s=!1,u=!1;for(const t of p[i])"symbol"===t[0].type?o=!0:s=!0,t[0].is3D()&&"model"!==t[0].type&&(u=!0);if(this.extraShadowCaster&&!u)continue;if(!0===this.isSymbolTile&&!o)continue;if(!1===this.isSymbolTile&&!s)continue;1===r.version&&t.w(`Vector tile source "${this.source}" layer "${i}" does not use vector tile spec v2 and therefore may have some rendering errors.`);const f=a.encode(i),m=[];for(let t=0;t=e.maxzoom||"none"!==e.visibility&&(l(t,this.zoom,h.brightness,n),(d[e.id]=e.createBucket({index:c.bucketLayerIDs.length,layers:t,zoom:this.zoom,lut:this.lut,canonical:this.canonical,pixelRatio:this.pixelRatio,overscaling:this.overscaling,collisionBoxArray:this.collisionBoxArray,sourceLayerIndex:f,sourceID:this.source,projection:this.projection.spec,tessellationStep:this.tessellationStep})).populate(m,h,this.tileID.canonical,this.tileTransform),c.bucketLayerIDs.push(t.map((t=>t.id)))))}}let f,m,_,g;u.trim();const y={type:"maybePrepare",isSymbolTile:this.isSymbolTile,zoom:this.zoom},v=()=>{if(f)return this.status="done",o(f);if(this.extraShadowCaster)this.status="done",o(null,{buckets:t.dG(d).filter((t=>!t.isEmpty())),featureIndex:c,collisionBoxArray:null,glyphAtlasImage:null,lineAtlas:null,imageAtlas:null,brightness:h.brightness,glyphMap:null,iconMap:null,glyphPositions:null});else if(m&&_&&g){const e=new s(m),i=new t.dQ(_,g,this.lut);for(const r in d){const o=d[r];o instanceof t.dR?(l(o.layers,this.zoom,h.brightness,n),t.dS(o,m,e.positions,_,i.iconPositions,this.showCollisionBoxes,n,this.tileID.canonical,this.tileZoom,this.projection,this.brightness)):o.hasPattern&&(o instanceof t.dT||o instanceof t.dU||o instanceof t.b_)&&(l(o.layers,this.zoom,h.brightness,n),o.addFeatures(h,this.tileID.canonical,i.patternPositions,n,this.tileTransform,this.brightness))}this.status="done",o(null,{buckets:t.dG(d).filter((t=>!t.isEmpty())),featureIndex:c,collisionBoxArray:this.collisionBoxArray,glyphAtlasImage:e.image,lineAtlas:u,imageAtlas:i,brightness:h.brightness})}};if(!this.extraShadowCaster){const e=t.dP(h.glyphDependencies,(t=>Object.keys(t).map(Number)));Object.keys(e).length?r.send("getGlyphs",{uid:this.uid,stacks:e,scope:this.scope},((t,e)=>{f||(f=t,m=e,v())}),void 0,!1,y):m={};const i=Object.keys(h.iconDependencies);i.length?r.send("getImages",{icons:i,source:this.source,scope:this.scope,tileID:this.tileID,type:"icons"},((t,e)=>{f||(f=t,_=e,v())}),void 0,!1,y):_={};const n=Object.keys(h.patternDependencies);n.length?r.send("getImages",{icons:n,source:this.source,scope:this.scope,tileID:this.tileID,type:"patterns"},((t,e)=>{f||(f=t,g=e,v())}),void 0,!1,y):g={}}v()}}function l(e,i,n,r){const o=new t.X(i,{brightness:n});for(const t of e)t.recalculate(o,r)}class c extends t.E{constructor(e,i,n,r,o,s){super(),this.actor=e,this.layerIndex=i,this.availableImages=n,this.loadVectorData=o||t.ap,this.loading={},this.loaded={},this.deduped=new t.ao(e.scheduler),this.isSpriteLoaded=r,this.scheduler=e.scheduler,this.brightness=s}loadTile(i,n){const r=i.uid,o=i&&i.request,s=o&&o.collectResourceTiming,l=this.loading[r]=new a(i);l.abort=this.loadVectorData(i,((a,c)=>{const d=!this.loading[r];if(delete this.loading[r],d||a||!c)return l.status="done",d||(this.loaded[r]=l),n(a);const u=c.rawData,h={};c.expires&&(h.expires=c.expires),c.cacheControl&&(h.cacheControl=c.cacheControl),l.vectorTile=c.vectorTile||new t.dV(new t.dW(u));const p=()=>{l.parse(l.vectorTile,this.layerIndex,this.availableImages,this.actor,((i,r)=>{if(i||!r)return n(i);const a={};if(s){const t=e(o);t.length>0&&(a.resourceTiming=JSON.parse(JSON.stringify(t)))}n(null,t.W({rawTileData:u.slice(0)},r,h,a))}))};this.isSpriteLoaded?p():this.once("isSpriteLoaded",(()=>{this.scheduler?this.scheduler.add(p,{type:"parseTile",isSymbolTile:i.isSymbolTile,zoom:i.tileZoom}):p()})),this.loaded=this.loaded||{},this.loaded[r]=l}))}reloadTile(e,i){const n=this.loaded,r=e.uid;if(n&&n[r]){const o=n[r];o.showCollisionBoxes=e.showCollisionBoxes,o.projection=e.projection,o.brightness=e.brightness,o.tileTransform=t.dK(e.tileID.canonical,e.projection),o.extraShadowCaster=e.extraShadowCaster,o.lut=e.lut;const s=(t,e)=>{const n=o.reloadCallback;n&&(delete o.reloadCallback,o.parse(o.vectorTile,this.layerIndex,this.availableImages,this.actor,n)),i(t,e)};"parsing"===o.status?o.reloadCallback=s:"done"===o.status&&(o.vectorTile?o.parse(o.vectorTile,this.layerIndex,this.availableImages,this.actor,s):s())}else i(null,void 0)}abortTile(t,e){const i=t.uid,n=this.loading[i];n&&(n.abort&&n.abort(),delete this.loading[i]),e()}removeTile(t,e){const i=this.loaded,n=t.uid;i&&i[n]&&delete i[n],e()}}class d{loadTile(e,i){const{uid:n,encoding:r,rawImageData:o,padding:s}=e,a=ImageBitmap&&o instanceof ImageBitmap?this.getImageData(o,s):o;i(null,new t.dX(n,a,r,s{n(null,t)}),(t=>{n(t)}))}}const h=t.dZ.prototype.toGeoJSON;let p=class{constructor(e){this._feature=e,this.extent=t.a3,this.type=e.type,this.properties=e.tags,"id"in e&&!isNaN(e.id)&&(this.id=parseInt(e.id,10))}loadGeometry(){if(1===this._feature.type){const e=[];for(const i of this._feature.geometry)e.push([new t.P(i[0],i[1])]);return e}{const e=[];for(const i of this._feature.geometry){const n=[];for(const e of i)n.push(new t.P(e[0],e[1]));e.push(n)}return e}}toGeoJSON(t,e,i){return h.call(this,t,e,i)}},f=class{constructor(e){this.layers={_geojsonTileLayer:this},this.name="_geojsonTileLayer",this.extent=t.a3,this.length=e.length,this._features=e}feature(t){return new p(this._features[t])}};const m=64/4096;class _{constructor(){this.features=new Map}clear(){this.features.clear()}load(t=[],e){for(const i of t){const t=i.id;if(null==t)continue;let n=this.features.get(t);n&&this.updateCache(n,e),i.geometry?(n=y(i),this.updateCache(n,e),this.features.set(t,n)):this.features.delete(t),this.updateCache(n,e)}}updateCache(t,e){for(const{canonical:i,uid:n}of Object.values(e)){const{z:r,x:o,y:s}=i;g(t,Math.pow(2,r),o,s)&&delete e[n]}}getTile(t,e,i){const n=Math.pow(2,t),r=[];for(const t of this.features.values())g(t,n,e,i)&&r.push(w(t,n,e,i));return{features:r}}getFeatures(){return[...this.features.values()]}}function g({minX:t,minY:e,maxX:i,maxY:n},r,o,s){return t(o-m)/r&&n>(s-m)/r}function y(t){const{id:e,geometry:i,properties:n}=t;if(!i)return;if("GeometryCollection"===i.type)throw new Error("GeometryCollection not supported in dynamic mode.");const{type:r,coordinates:o}=i,s={id:e,type:1,geometry:[],tags:n,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0},a=s.geometry;if("Point"===r)v(o,a,s);else if("MultiPoint"===r)for(const t of o)v(t,a,s);else if("LineString"===r)s.type=2,x(o,a,s);else if("MultiLineString"===r)s.type=2,b(o,a,s);else if("Polygon"===r)s.type=3,b(o,a,s,!0);else{if("MultiPolygon"!==r)throw new Error("Input data is not a valid GeoJSON object.");s.type=3;for(const t of o)b(t,a,s,!0)}return s}function v([e,i],n,r){const o=t.aj(e);let s=t.ak(i);s=s1?1:s,n.push(o,s),r.minX=Math.min(r.minX,o),r.minY=Math.min(r.minY,s),r.maxX=Math.max(r.maxX,o),r.maxY=Math.max(r.maxY,s)}function x(t,e,i,n=!1,r=!1){const o=[];for(const e of t)v(e,o,i);e.push(o),n&&function(t,e){let i=0;for(let e=0,n=t.length,r=n-2;e0===e)for(let e=0,i=t.length;e>31}function F(t,e){for(var i=t.loadGeometry(),n=t.type,r=0,o=0,s=i.length,a=0;at},V=Math.fround||(G=new Float32Array(1),t=>(G[0]=+t,G[0]));var G;const Z=3,q=5,H=6;class W{constructor(t){this.options=Object.assign(Object.create(j),t),this.trees=new Array(this.options.maxZoom+1),this.stride=this.options.reduce?7:6,this.clusterProps=[]}load(t){const{log:e,minZoom:i,maxZoom:n}=this.options;e&&console.time("total time");const r=`prepare ${t.length} points`;e&&console.time(r),this.points=t;const o=[];for(let e=0;e=i;t--){const i=+Date.now();s=this.trees[t]=this._createTree(this._cluster(s,t)),e&&console.log("z%d: %d clusters in %dms",t,s.numItems,+Date.now()-i)}return e&&console.timeEnd("total time"),this}getClusters(t,e){let i=((t[0]+180)%360+360)%360-180;const n=Math.max(-90,Math.min(90,t[1]));let r=180===t[2]?180:((t[2]+180)%360+360)%360-180;const o=Math.max(-90,Math.min(90,t[3]));if(t[2]-t[0]>=360)i=-180,r=180;else if(i>r){const t=this.getClusters([i,n,180,o],e),s=this.getClusters([-180,n,r,o],e);return t.concat(s)}const s=this.trees[this._limitZoom(e)],a=s.range(K(i),J(o),K(r),J(n)),l=s.data,c=[];for(const t of a){const e=this.stride*t;c.push(l[e+q]>1?Y(l,e,this.clusterProps):this.points[l[e+Z]])}return c}getChildren(t){const e=this._getOriginId(t),i=this._getOriginZoom(t),n="No cluster with the specified id.",r=this.trees[i];if(!r)throw new Error(n);const o=r.data;if(e*this.stride>=o.length)throw new Error(n);const s=this.options.radius/(this.options.extent*Math.pow(2,i-1)),a=r.within(o[e*this.stride],o[e*this.stride+1],s),l=[];for(const e of a){const i=e*this.stride;o[i+4]===t&&l.push(o[i+q]>1?Y(o,i,this.clusterProps):this.points[o[i+Z]])}if(0===l.length)throw new Error(n);return l}getLeaves(t,e,i){const n=[];return this._appendLeaves(n,t,e=e||10,i=i||0,0),n}getTile(t,e,i){const n=this.trees[this._limitZoom(t)],r=Math.pow(2,t),{extent:o,radius:s}=this.options,a=s/o,l=(i-a)/r,c=(i+1+a)/r,d={features:[]};return this._addTileFeatures(n.range((e-a)/r,l,(e+1+a)/r,c),n.data,e,i,r,d),0===e&&this._addTileFeatures(n.range(1-a/r,l,1,c),n.data,r,i,r,d),e===r-1&&this._addTileFeatures(n.range(0,l,a/r,c),n.data,-1,i,r,d),d.features.length?d:null}getClusterExpansionZoom(t){let e=this._getOriginZoom(t)-1;for(;e1;let l,c,d;if(a)l=X(e,t,this.clusterProps),c=e[t],d=e[t+1];else{const i=this.points[e[t+Z]];l=i.properties;const[n,r]=i.geometry.coordinates;c=K(n),d=J(r)}const u={type:1,geometry:[[Math.round(this.options.extent*(c*r-i)),Math.round(this.options.extent*(d*r-n))]],tags:l};let h;h=a||this.options.generateId?e[t+Z]:this.points[e[t+Z]].id,void 0!==h&&(u.id=h),o.features.push(u)}}_limitZoom(t){return Math.max(this.options.minZoom,Math.min(Math.floor(+t),this.options.maxZoom+1))}_cluster(t,e){const{radius:i,extent:n,reduce:r,minPoints:o}=this.options,s=i/(n*Math.pow(2,e)),a=t.data,l=[],c=this.stride;for(let i=0;ie&&(p+=a[i+q])}if(p>h&&p>=o){let t,o=n*h,s=d*h,f=-1;const m=(i/c1)for(const t of u){const i=t*c;if(!(a[i+2]>5}_getOriginZoom(t){return(t-this.points.length)%32}_map(t,e,i){if(t[e+q]>1){const n=this.clusterProps[t[e+H]];return i?Object.assign({},n):n}const n=this.points[t[e+Z]].properties,r=this.options.map(n);return i&&r===n?Object.assign({},r):r}}function Y(t,e,i){return{type:"Feature",id:t[e+Z],properties:X(t,e,i),geometry:{type:"Point",coordinates:[(n=t[e],360*(n-.5)),Q(t[e+1])]}};var n}function X(t,e,i){const n=t[e+q],r=n>=1e4?`${Math.round(n/1e3)}k`:n>=1e3?Math.round(n/100)/10+"k":n,o=t[e+H],s=-1===o?{}:Object.assign({},i[o]);return Object.assign(s,{cluster:!0,cluster_id:t[e+Z],point_count:n,point_count_abbreviated:r})}function K(t){return t/360+.5}function J(t){const e=Math.sin(t*Math.PI/180),i=.5-.25*Math.log((1+e)/(1-e))/Math.PI;return i1?1:i}function Q(t){const e=(180-360*t)*Math.PI/180;return 360*Math.atan(Math.exp(e))/Math.PI-90}function tt(t,e,i,n){let r=n;const o=e+(i-e>>1);let s,a=i-e;const l=t[e],c=t[e+1],d=t[i],u=t[i+1];for(let n=e+3;n 4?`Invalid rbga value ${JSON.stringify(e)}: expected an array containing either three or four numeric values.`:mr(e[0],e[1],e[2],e[3]),!i))return new Un(e[0]/255,e[1]/255,e[2]/255,e[3])}throw new xr(i||`Could not parse color from value '${"string"==typeof e?e:String(JSON.stringify(e))}'`)}if("number"===this.type.kind){let e=null;for(const i of this.args){if(e=i.evaluate(t),null===e)return 0;const n=Number(e);if(!isNaN(n))return n}throw new xr(`Could not convert ${JSON.stringify(e)} to number.`)}return"formatted"===this.type.kind?pr.fromString(yr(this.args[0].evaluate(t))):"resolvedImage"===this.type.kind?fr.fromString(yr(this.args[0].evaluate(t))):"array"===this.type.kind?this.args.map((e=>e.evaluate(t))):yr(this.args[0].evaluate(t))}eachChild(t){this.args.forEach(t)}outputDefined(){return this.args.every((t=>t.outputDefined()))}serialize(){if("formatted"===this.type.kind)return new Tr([{content:this.args[0],scale:null,font:null,textColor:null}]).serialize();if("resolvedImage"===this.type.kind)return new Sr(this.args[0]).serialize();const t="array"===this.type.kind?[]:[`to-${this.type.kind}`];return this.eachChild((e=>{t.push(e.serialize())})),t}}const Ar=["Unknown","Point","LineString","Polygon"];class Ir{constructor(t,e){this.globals=null,this.feature=null,this.featureState=null,this.formattedSection=null,this._parseColorCache={},this.availableImages=null,this.canonical=null,this.featureTileCoord=null,this.featureDistanceData=null,this.scope=t,this.options=e}id(){return this.feature&&void 0!==this.feature.id?this.feature.id:null}geometryType(){return this.feature?"number"==typeof this.feature.type?Ar[this.feature.type]:this.feature.type:null}geometry(){return this.feature&&"geometry"in this.feature?this.feature.geometry:null}canonicalID(){return this.canonical}properties(){return this.feature&&this.feature.properties||{}}measureLight(t){return this.globals.brightness||0}distanceFromCenter(){if(this.featureTileCoord&&this.featureDistanceData){const t=this.featureDistanceData.center,e=this.featureDistanceData.scale,{x:i,y:n}=this.featureTileCoord;return this.featureDistanceData.bearing[0]*(i*e-t[0])+this.featureDistanceData.bearing[1]*(n*e-t[1])}return 0}parseColor(t){let e=this._parseColorCache[t];return e||(e=this._parseColorCache[t]=Un.parse(t)),e}getConfig(t){return this.options?this.options.get(t):null}}class Lr{constructor(t,e,i,n,r){this.name=t,this.type=e,this._evaluate=i,this.args=n,this._overloadIndex=r}evaluate(t){if(!this._evaluate){const t=Lr.definitions[this.name];this._evaluate=Array.isArray(t)?t[2]:t.overloads[this._overloadIndex][1]}return this._evaluate(t,this.args)}eachChild(t){this.args.forEach(t)}outputDefined(){return!1}serialize(){return[this.name].concat(this.args.map((t=>t.serialize())))}static parse(t,e){const i=t[0],n=Lr.definitions[i];if(!n)return e.error(`Unknown expression "${i}". If you wanted a literal array, use ["literal", [...]].`,0);const r=Array.isArray(n)?n[0]:n.type,o=Array.isArray(n)?[[n[1],n[2]]]:n.overloads,s=[];let a=null,l=-1;for(const[n,c]of o){if(Array.isArray(n)&&n.length!==t.length-1)continue;s.push(n),l++,a=new Ko(e.registry,e.path,null,e.scope,void 0,e._scope,e.options);const o=[];let d=!1;for(let e=1;et))).map(Pr).join(" | "),n=[];for(let i=1;ii;){if(n-i>600){const o=n-i+1,s=e-i+1,a=Math.log(o),l=.5*Math.exp(2*a/3),c=.5*Math.sqrt(a*l*(o-l)/o)*(s-o/20&&Dr(t,i,n);s0;)a--}0===r(t[i],o)?Dr(t,i,a):(a++,Dr(t,a,n)),ae?1:0}function Rr(t){let e=0;for(let i,n,r=0,o=t.length,s=o-1;r=e[2]||t[1]=e[3])}function Fr(t,e,i){const n=t[0]-e[0],r=t[1]-e[1],o=t[0]-i[0],s=t[1]-i[1];return n*s-o*r==0&&n*o(r=t)[1]!=(s=d)[1]>r[1]&&r[0]0&&a0}function jr(t,e,i,n){return 0!=(r=[n[0]-i[0],n[1]-i[1]])[0]*(o=[e[0]-t[0],e[1]-t[1]])[1]-r[1]*o[0]&&!(!Ur(t,e,i,n)||!Ur(i,n,t,e));var r,o}const Vr=8192;function Gr(t,e){const i=(180+t[0])/360,n=(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+t[1]*Math.PI/360)))/360,r=Math.pow(2,e.z);return[Math.round(i*r*Vr),Math.round(n*r*Vr)]}function Zr(t,e){for(let i=0;ii[2]){const e=.5*n;let r=t[0]-i[0]>e?-n:i[0]-t[0]>e?n:0;0===r&&(r=t[0]-i[2]>e?-n:i[2]-t[0]>e?n:0),t[0]+=r}Or(e,t)}function Jr(t,e,i,n){const r=Math.pow(2,n.z)*Vr,o=[n.x*Vr,n.y*Vr],s=[];if(!t)return s;for(const n of t)for(const t of n){const n=[t.x+o[0],t.y+o[1]];Kr(n,e,i,r),s.push(n)}return s}function Qr(t,e,i,n){const r=Math.pow(2,n.z)*Vr,o=[n.x*Vr,n.y*Vr],s=[];if(!t)return s;for(const i of t){const t=[];for(const n of i){const i=[n.x+o[0],n.y+o[1]];Or(e,i),t.push(i)}s.push(t)}if(e[2]-e[0]e)return ao(r,o,(e-(i-s))/s)}return t[t.length-1]}pointToSegmentDistance(t,e,i){let[n,r]=e,o=lo(i[0]-n)*this.kx,s=(i[1]-r)*this.ky;if(0!==o||0!==s){const e=(lo(t[0]-n)*this.kx*o+(t[1]-r)*this.ky*s)/(o*o+s*s);e>1?(n=i[0],r=i[1]):e>0&&(n+=o/this.kx*e,r+=s/this.ky*e)}return o=lo(t[0]-n)*this.kx,s=(t[1]-r)*this.ky,Math.sqrt(o*o+s*s)}pointOnLine(t,e){let i=1/0,n=t[0][0],r=t[0][1],o=0,s=0;for(let a=0;a1?(l=t[a+1][0],c=t[a+1][1]):h>0&&(l+=d/this.kx*h,c+=u/this.ky*h)),d=lo(e[0]-l)*this.kx,u=(e[1]-c)*this.ky;const p=d*d+u*u;pr.index||n.index===r.index&&n.t>r.t){const t=n;n=r,r=t}const o=[n.point],s=n.index+1,a=r.index;!so(i[s],o[0])&&st&&0===r.length&&r.push(ao(s,a,(t-(n-l))/l)),n>=e)return r.push(ao(s,a,(e-(n-l))/l)),r;n>t&&r.push(a)}return r}bufferPoint(t,e){const i=e/this.ky,n=e/this.kx;return[t[0]-n,t[1]-i,t[0]+n,t[1]+i]}bufferBBox(t,e){const i=e/this.ky,n=e/this.kx;return[t[0]-n,t[1]-i,t[2]+n,t[3]+i]}insideBBox(t,e){return lo(t[0]-e[0])>=0&&lo(t[0]-e[2])=e[1]&&t[1]180;)t-=360;return t}class co{constructor(t=[],e=(t,e)=>te?1:0){if(this.data=t,this.length=this.data.length,this.compare=e,this.length>0)for(let t=(this.length>>1)-1;t>=0;t--)this._down(t)}push(t){this.data.push(t),this._up(this.length++)}pop(){if(0===this.length)return;const t=this.data[0],e=this.data.pop();return--this.length>0&&(this.data[0]=e,this._down(0)),t}peek(){return this.data[0]}_up(t){const{data:e,compare:i}=this,n=e[t];for(;t>0;){const r=t-1>>1,o=e[r];if(i(n,o)>=0)break;e[t]=o,t=r}e[t]=n}_down(t){const{data:e,compare:i}=this,n=this.length>>1,r=e[t];for(;t=0)break;e[t]=e[n],t=n}e[t]=r}}var uo=8192;function ho(t,e){return e.dist-t.dist}const po=100,fo=50;function mo(t){const e=[1/0,1/0,-1/0,-1/0];if(e.length!==t.length)return!1;for(let i=0;i=t[0]&&t[1]t[1])return[null,null];const i=_o(t);if(e){if(2===i)return[t,null];const e=Math.floor(i/2);return[[t[0],t[0]+e],[t[0]+e,t[1]]]}{if(1===i)return[t,null];const e=Math.floor(i/2)-1;return[[t[0],t[0]+e],[t[0]+e+1,t[1]]]}}function vo(t,e){const i=[1/0,1/0,-1/0,-1/0];if(!go(e,t.length))return i;for(let n=e[0];ne[2]&&(n=t[0]-e[2]),t[1]>e[3]&&(r=t[1]-e[3]),t[3]=n)return n;if(Br(r,o)){if(ko(t,e))return 0}else if(ko(e,t))return 0;let s=n;for(const n of t)for(let t=0,r=n.length,o=r-1;t=o)continue;const c=r.range1;if(_o(c)=s)continue;const d=o.range1,u=o.range2;if(_o(d)=o)&&(o=Math.min(o,Oo(t,e,r,!0,n,o)),0===o))return o;return o}function Fo(t,e,i,n,r=1/0){let o=r;const s=vo(t,[0,t.length-1]);for(const r of i){if(o!==1/0&&bo(s,xo(r),n)>=o)continue;const i=Ro(t,e,r,n,o);if(isNaN(i))return i;if(0===(o=Math.min(o,i)))return o}return o}function No(t){return"Point"===t||"MultiPoint"===t||"LineString"===t||"MultiLineString"===t||"Polygon"===t||"MultiPolygon"===t}class Uo{constructor(t,e){this.type=Xn,this.geojson=t,this.geometries=e}static parse(t,e){if(2!==t.length)return e.error(`'distance' expression requires either one argument, but found ' ${t.length-1} instead.`);if(_r(t[1])){const e=t[1];if("FeatureCollection"===e.type){for(let t=0;ti&&(t=i),t}class Go{constructor(t,e,i){this.type=t,this.key=e,this.scope=i}static parse(t,e){let i=e.expectedType;if(null==i&&(i=er),t.length3)return e.error("Invalid number of arguments for 'config' expression.");const n=e.parse(t[1],1);if(!(n instanceof vr))return e.error("Key name of 'config' expression must be a string literal.");if(t.length>=3){const r=e.parse(t[2],2);return r instanceof vr?new Go(i,yr(n.value),yr(r.value)):e.error("Scope of 'config' expression must be a string literal.")}return new Go(i,yr(n.value))}evaluate(t){const e=[this.key,this.scope,t.scope].filter(Boolean).join(""),i=t.getConfig(e);if(!i)return null;const{type:n,value:r,values:o,minValue:s,maxValue:a,stepValue:l}=i,c=i.default.evaluate(t);let d=c;if(r){const e=t.scope;t.scope=(e||"").split("").slice(1).join(""),d=r.evaluate(t),t.scope=e}return n&&(d=jo(n,d)),void 0===d||void 0===s&&void 0===a&&void 0===l||("number"==typeof d?d=Vo(d,s,a,l):Array.isArray(d)&&(d=d.map((t=>"number"==typeof t?Vo(t,s,a,l):t)))),void 0!==r&&void 0!==d&&o&&!o.includes(d)&&(d=c,n&&(d=jo(n,d))),(n&&n!==this.type||void 0!==d&&gr(d)!==this.type)&&(d=jo(this.type.kind,d)),d}eachChild(){}outputDefined(){return!1}serialize(){const t=["config",this.key];return this.scope&&t.concat(this.key),t}}function Zo(t){if(t instanceof Lr){if("get"===t.name&&1===t.args.length)return!1;if("feature-state"===t.name)return!1;if("has"===t.name&&1===t.args.length)return!1;if("properties"===t.name||"geometry-type"===t.name||"id"===t.name)return!1;if(/^filter-/.test(t.name))return!1}if(t instanceof to)return!1;if(t instanceof Uo)return!1;let e=!0;return t.eachChild((t=>{e&&!Zo(t)&&(e=!1)})),e}function qo(t){if(t instanceof Lr&&"feature-state"===t.name)return!1;let e=!0;return t.eachChild((t=>{e&&!qo(t)&&(e=!1)})),e}function Ho(t){if(t instanceof Go)return!1;let e=!0;return t.eachChild((t=>{e&&!Ho(t)&&(e=!1)})),e}function Wo(t,e){if(t instanceof Lr&&e.indexOf(t.name)>=0)return!1;let i=!0;return t.eachChild((t=>{i&&!Wo(t,e)&&(i=!1)})),i}class Yo{constructor(t,e){this.type=e.type,this.name=t,this.boundExpression=e}static parse(t,e){if(2!==t.length||"string"!=typeof t[1])return e.error("'var' expression requires exactly one string literal argument.");const i=t[1];return e.scope.has(i)?new Yo(i,e.scope.get(i)):e.error(`Unknown variable "${i}". Make sure "${i}" has been bound in an enclosing "let" expression before using it.`,1)}evaluate(t){return this.boundExpression.evaluate(t)}eachChild(){}outputDefined(){return!1}serialize(){return["var",this.name]}}class Xo{constructor(t,e=[],i,n=new Wn,r=[],o,s){this.registry=t,this.path=e,this.key=e.map((t=>`[${t}]`)).join(""),this.scope=n,this.errors=r,this.expectedType=i,this._scope=o,this.options=s}parse(t,e,i,n,r={}){return e||i?this.concat(e,i,n)._parse(t,r):this._parse(t,r)}_parse(t,e){function i(t,e,i){return"assert"===i?new wr(e,[t]):"coerce"===i?new Cr(e,[t]):t}if(null!==t&&"string"!=typeof t&&"boolean"!=typeof t&&"number"!=typeof t||(t=["literal",t]),Array.isArray(t)){if(0===t.length)return this.error('Expected an array with at least one element. If you wanted a literal array, use ["literal", []].');const n="string"==typeof t[0]?this.registry[t[0]]:void 0;if(n){let r=n.parse(t,this);if(!r)return null;if(this.expectedType){const t=this.expectedType,n=r.type;if("string"!==t.kind&&"number"!==t.kind&&"boolean"!==t.kind&&"object"!==t.kind&&"array"!==t.kind||"value"!==n.kind)if("color"!==t.kind&&"formatted"!==t.kind&&"resolvedImage"!==t.kind||"value"!==n.kind&&"string"!==n.kind){if(this.checkSubtype(t,n))return null}else r=i(r,t,e.typeAnnotation||"coerce");else r=i(r,t,e.typeAnnotation||"assert")}if(!(r instanceof vr)&&"resolvedImage"!==r.type.kind&&Jo(r)){const e=new Ir(this._scope,this.options);try{r=new vr(r.type,r.evaluate(e))}catch(t){return this.error(t.message),null}}return r}return Cr.parse(["to-array",t],this)}return this.error(void 0===t?"'undefined' value invalid. Use null instead.":"object"==typeof t?'Bare objects invalid. Use ["literal", {...}] instead.':`Expected an array, but found ${typeof t} instead.`)}concat(t,e,i){const n="number"==typeof t?this.path.concat(t):this.path,r=i?this.scope.concat(i):this.scope;return new Xo(this.registry,n,e||null,r,this.errors,this._scope,this.options)}error(t,...e){const i=`${this.key}${e.map((t=>`[${t}]`)).join("")}`;this.errors.push(new Hn(i,t))}checkSubtype(t,e){const i=lr(t,e);return i&&this.error(i),i}}var Ko=Xo;function Jo(t){if(t instanceof Yo)return Jo(t.boundExpression);if(t instanceof Lr&&"error"===t.name)return!1;if(t instanceof $r)return!1;if(t instanceof to)return!1;if(t instanceof Uo)return!1;if(t instanceof Go)return!1;const e=t instanceof Cr||t instanceof wr;let i=!0;return t.eachChild((t=>{i=e?i&&Jo(t):i&&t instanceof vr})),!!i&&Zo(t)&&Wo(t,["zoom","heatmap-density","line-progress","raster-value","sky-radial-progress","accumulated","is-supported-script","pitch","distance-from-center","measure-light","raster-particle-speed"])}function Qo(t,e){const i=t.length-1;let n,r,o=0,s=i,a=0;for(;oe))throw new xr("Input is not a number.");s=a-1}return 0}class ts{constructor(t,e,i){this.type=t,this.input=e,this.labels=[],this.outputs=[];for(const[t,e]of i)this.labels.push(t),this.outputs.push(e)}static parse(t,e){if(t.length-1=o)return e.error('Input/output pairs for "step" expressions must be arranged with input values in strictly ascending order.',a);const c=e.parse(s,l,r);if(!c)return null;r=r||c.type,n.push([o,c])}return new ts(r,i,n)}evaluate(t){const e=this.labels,i=this.outputs;if(1===e.length)return i[0].evaluate(t);const n=this.input.evaluate(t);if(n=e[r-1]?i[r-1].evaluate(t):i[Qo(e,n)].evaluate(t)}eachChild(t){t(this.input);for(const e of this.outputs)t(e)}outputDefined(){return this.outputs.every((t=>t.outputDefined()))}serialize(){const t=["step",this.input.serialize()];for(let e=0;e0&&t.push(this.labels[e]),t.push(this.outputs[e].serialize());return t}}const es=.95047,is=1.08883,ns=4/29,rs=6/29,os=3*rs*rs,ss=rs*rs*rs,as=Math.PI/180,ls=180/Math.PI;function cs(t){return t>ss?Math.pow(t,1/3):t/os+ns}function ds(t){return t>rs?t*t*t:os*(t-ns)}function us(t){return 255*(t180||n"number"!=typeof t||t1)))return e.error("Cubic bezier interpolation requires four numeric arguments with values between 0 and 1.",1);n={name:"cubic-bezier",controlPoints:t}}}if(t.length-1=i)return e.error('Input/output pairs for "interpolate" expressions must be arranged with input values in strictly ascending order.',r);const c=e.parse(n,l,a);if(!c)return null;a=a||c.type,s.push([i,c])}return"number"===a.kind||"color"===a.kind||"array"===a.kind&&"number"===a.itemType.kind&&"number"==typeof a.N?new vs(a,i,n,r,s):e.error(`Type ${sr(a)} is not interpolatable.`)}evaluate(t){const e=this.labels,i=this.outputs;if(1===e.length)return i[0].evaluate(t);const n=this.input.evaluate(t);if(n=e[r-1])return i[r-1].evaluate(t);const o=Qo(e,n),s=vs.interpolationFactor(this.interpolation,n,e[o],e[o+1]),a=i[o].evaluate(t),l=i[o+1].evaluate(t);return"interpolate"===this.operator?Zn[this.type.kind.toLowerCase()](a,l,s):"interpolate-hcl"===this.operator?gs.reverse(gs.interpolate(gs.forward(a),gs.forward(l),s)):_s.reverse(_s.interpolate(_s.forward(a),_s.forward(l),s))}eachChild(t){t(this.input);for(const e of this.outputs)t(e)}outputDefined(){return this.outputs.every((t=>t.outputDefined()))}serialize(){let t;t="linear"===this.interpolation.name?["linear"]:"exponential"===this.interpolation.name?1===this.interpolation.base?["linear"]:["exponential",this.interpolation.base]:["cubic-bezier"].concat(this.interpolation.controlPoints);const e=[this.operator,t,this.input.serialize()];for(let t=0;tlr(n,t.type)));return new bs(o?er:i,r)}evaluate(t){let e,i=null,n=0;for(const r of this.args){if(n++,i=r.evaluate(t),i&&i instanceof fr&&!i.available&&(e||(e=i),i=null,n===this.args.length))return e;if(null!==i)break}return i}eachChild(t){this.args.forEach(t)}outputDefined(){return this.args.every((t=>t.outputDefined()))}serialize(){const t=["coalesce"];return this.eachChild((e=>{t.push(e.serialize())})),t}}class ws{constructor(t,e){this.type=e.type,this.bindings=[].concat(t),this.result=e}evaluate(t){return this.result.evaluate(t)}eachChild(t){for(const e of this.bindings)t(e[1]);t(this.result)}static parse(t,e){if(t.length=i.length)throw new xr(`Array index out of bounds: ${e} > ${i.length-1}.`);if(e!==Math.floor(e))throw new xr(`Array index must be an integer, but found ${e} instead.`);return i[e]}eachChild(t){t(this.index),t(this.input)}outputDefined(){return!1}serialize(){return["at",this.index.serialize(),this.input.serialize()]}}class Ss{constructor(t,e){this.type=Jn,this.needle=t,this.haystack=e}static parse(t,e){if(3!==t.length)return e.error(`Expected 2 arguments, but found ${t.length-1} instead.`);const i=e.parse(t[1],1,er),n=e.parse(t[2],2,er);return i&&n?cr(i.type,[Jn,Kn,Xn,Yn,er])?new Ss(i,n):e.error(`Expected first argument to be of type boolean, string, number or null, but found ${sr(i.type)} instead`):null}evaluate(t){const e=this.needle.evaluate(t),i=this.haystack.evaluate(t);if(null==i)return!1;if(!dr(e,["boolean","string","number","null"]))throw new xr(`Expected first argument to be of type boolean, string, number or null, but found ${sr(gr(e))} instead.`);if(!dr(i,["string","array"]))throw new xr(`Expected second argument to be of type array or string, but found ${sr(gr(i))} instead.`);return i.indexOf(e)>=0}eachChild(t){t(this.needle),t(this.haystack)}outputDefined(){return!0}serialize(){return["in",this.needle.serialize(),this.haystack.serialize()]}}class Es{constructor(t,e,i){this.type=Xn,this.needle=t,this.haystack=e,this.fromIndex=i}static parse(t,e){if(t.length=5)return e.error(`Expected 3 or 4 arguments, but found ${t.length-1} instead.`);const i=e.parse(t[1],1,er),n=e.parse(t[2],2,er);if(!i||!n)return null;if(!cr(i.type,[Jn,Kn,Xn,Yn,er]))return e.error(`Expected first argument to be of type boolean, string, number or null, but found ${sr(i.type)} instead`);if(4===t.length){const r=e.parse(t[3],3,Xn);return r?new Es(i,n,r):null}return new Es(i,n)}evaluate(t){const e=this.needle.evaluate(t),i=this.haystack.evaluate(t);if(!dr(e,["boolean","string","number","null"]))throw new xr(`Expected first argument to be of type boolean, string, number or null, but found ${sr(gr(e))} instead.`);if(!dr(i,["string","array"]))throw new xr(`Expected second argument to be of type array or string, but found ${sr(gr(i))} instead.`);if(this.fromIndex){const n=this.fromIndex.evaluate(t);return i.indexOf(e,n)}return i.indexOf(e)}eachChild(t){t(this.needle),t(this.haystack),this.fromIndex&&t(this.fromIndex)}outputDefined(){return!1}serialize(){if(null!=this.fromIndex&&void 0!==this.fromIndex){const t=this.fromIndex.serialize();return["index-of",this.needle.serialize(),this.haystack.serialize(),t]}return["index-of",this.needle.serialize(),this.haystack.serialize()]}}class Ms{constructor(t,e,i,n,r,o){this.inputType=t,this.type=e,this.input=i,this.cases=n,this.outputs=r,this.otherwise=o}static parse(t,e){if(t.lengthNumber.MAX_SAFE_INTEGER)return c.error(`Branch labels must be integers no larger than ${Number.MAX_SAFE_INTEGER}.`);if("number"==typeof t&&Math.floor(t)!==t)return c.error("Numeric branch labels must be integer values.");if(i){if(c.checkSubtype(i,gr(t)))return null}else i=gr(t);if(void 0!==r[String(t)])return c.error("Branch labels must be unique.");r[String(t)]=o.length}const d=e.parse(l,s,n);if(!d)return null;n=n||d.type,o.push(d)}const s=e.parse(t[1],1,er);if(!s)return null;const a=e.parse(t[t.length-1],t.length-1,n);return a?"value"!==s.type.kind&&e.concat(1).checkSubtype(i,s.type)?null:new Ms(i,n,s,r,o,a):null}evaluate(t){const e=this.input.evaluate(t);return(gr(e)===this.inputType&&this.outputs[this.cases[e]]||this.otherwise).evaluate(t)}eachChild(t){t(this.input),this.outputs.forEach(t),t(this.otherwise)}outputDefined(){return this.outputs.every((t=>t.outputDefined()))&&this.otherwise.outputDefined()}serialize(){const t=["match",this.input.serialize()],e=Object.keys(this.cases).sort(),i=[],n={};for(const t of e){const e=n[this.cases[t]];void 0===e?(n[this.cases[t]]=i.length,i.push([this.cases[t],[t]])):i[e][1].push(t)}const r=t=>"number"===this.inputType.kind?Number(t):t;for(const[e,n]of i)t.push(1===n.length?r(n[0]):n.map(r)),t.push(this.outputs[e].serialize());return t.push(this.otherwise.serialize()),t}}class Cs{constructor(t,e,i){this.type=t,this.branches=e,this.otherwise=i}static parse(t,e){if(t.lengthe.outputDefined()))&&this.otherwise.outputDefined()}serialize(){const t=["case"];return this.eachChild((e=>{t.push(e.serialize())})),t}}class As{constructor(t,e,i,n){this.type=t,this.input=e,this.beginIndex=i,this.endIndex=n}static parse(t,e){if(t.length=5)return e.error(`Expected 3 or 4 arguments, but found ${t.length-1} instead.`);const i=e.parse(t[1],1,er),n=e.parse(t[2],2,Xn);if(!i||!n)return null;if(!cr(i.type,[or(er),Kn,er]))return e.error(`Expected first argument to be of type array or string, but found ${sr(i.type)} instead`);if(4===t.length){const r=e.parse(t[3],3,Xn);return r?new As(i.type,i,n,r):null}return new As(i.type,i,n)}evaluate(t){const e=this.input.evaluate(t),i=this.beginIndex.evaluate(t);if(!dr(e,["string","array"]))throw new xr(`Expected first argument to be of type array or string, but found ${sr(gr(e))} instead.`);if(this.endIndex){const n=this.endIndex.evaluate(t);return e.slice(i,n)}return e.slice(i)}eachChild(t){t(this.input),t(this.beginIndex),this.endIndex&&t(this.endIndex)}outputDefined(){return!1}serialize(){if(null!=this.endIndex&&void 0!==this.endIndex){const t=this.endIndex.serialize();return["slice",this.input.serialize(),this.beginIndex.serialize(),t]}return["slice",this.input.serialize(),this.beginIndex.serialize()]}}function Is(t,e){return"=="===t||"!="===t?"boolean"===e.kind||"string"===e.kind||"number"===e.kind||"null"===e.kind||"value"===e.kind:"string"===e.kind||"number"===e.kind||"value"===e.kind}function Ls(t,e,i,n){return 0===n.compare(e,i)}function Ps(t,e,i){const n="=="!==t&&"!="!==t;return class r{constructor(t,e,i){this.type=Jn,this.lhs=t,this.rhs=e,this.collator=i,this.hasUntypedArgument="value"===t.type.kind||"value"===e.type.kind}static parse(t,e){if(3!==t.length&&4!==t.length)return e.error("Expected two or three arguments.");const i=t[0];let o=e.parse(t[1],1,er);if(!o)return null;if(!Is(i,o.type))return e.concat(1).error(`"${i}" comparisons are not supported for type '${sr(o.type)}'.`);let s=e.parse(t[2],2,er);if(!s)return null;if(!Is(i,s.type))return e.concat(2).error(`"${i}" comparisons are not supported for type '${sr(s.type)}'.`);if(o.type.kind!==s.type.kind&&"value"!==o.type.kind&&"value"!==s.type.kind)return e.error(`Cannot compare types '${sr(o.type)}' and '${sr(s.type)}'.`);n&&("value"===o.type.kind&&"value"!==s.type.kind?o=new wr(s.type,[o]):"value"!==o.type.kind&&"value"===s.type.kind&&(s=new wr(o.type,[s])));let a=null;if(4===t.length){if("string"!==o.type.kind&&"string"!==s.type.kind&&"value"!==o.type.kind&&"value"!==s.type.kind)return e.error("Cannot use collator to compare non-string types.");if(a=e.parse(t[3],3,ir),!a)return null}return new r(o,s,a)}evaluate(r){const o=this.lhs.evaluate(r),s=this.rhs.evaluate(r);if(n&&this.hasUntypedArgument){const e=gr(o),i=gr(s);if(e.kind!==i.kind||"string"!==e.kind&&"number"!==e.kind)throw new xr(`Expected arguments for "${t}" to be (string, string) or (number, number), but found (${e.kind}, ${i.kind}) instead.`)}if(this.collator&&!n&&this.hasUntypedArgument){const t=gr(o),i=gr(s);if("string"!==t.kind||"string"!==i.kind)return e(r,o,s)}return this.collator?i(r,o,s,this.collator.evaluate(r)):e(r,o,s)}eachChild(t){t(this.lhs),t(this.rhs),this.collator&&t(this.collator)}outputDefined(){return!0}serialize(){const e=[t];return this.eachChild((t=>{e.push(t.serialize())})),e}}}const $s=Ps("==",(function(t,e,i){return e===i}),Ls),ks=Ps("!=",(function(t,e,i){return e!==i}),(function(t,e,i,n){return!Ls(0,e,i,n)})),Ds=Ps("",(function(t,e,i){return e>i}),(function(t,e,i,n){return n.compare(e,i)>0})),Rs=Ps("=",(function(t,e,i){return e>=i}),(function(t,e,i,n){return n.compare(e,i)>=0}));class Bs{constructor(t,e,i,n,r,o){this.type=Kn,this.number=t,this.locale=e,this.currency=i,this.unit=n,this.minFractionDigits=r,this.maxFractionDigits=o}static parse(t,e){if(3!==t.length)return e.error("Expected two arguments.");const i=e.parse(t[1],1,Xn);if(!i)return null;const n=t[2];if("object"!=typeof n||Array.isArray(n))return e.error("NumberFormat options argument must be an object.");let r=null;if(n.locale&&(r=e.parse(n.locale,1,Kn),!r))return null;let o=null;if(n.currency&&(o=e.parse(n.currency,1,Kn),!o))return null;let s=null;if(n.unit&&(s=e.parse(n.unit,1,Kn),!s))return null;let a=null;if(n["min-fraction-digits"]&&(a=e.parse(n["min-fraction-digits"],1,Xn),!a))return null;let l=null;return n["max-fraction-digits"]&&(l=e.parse(n["max-fraction-digits"],1,Xn),!l)?null:new Bs(i,r,o,s,a,l)}evaluate(t){return new Intl.NumberFormat(this.locale?this.locale.evaluate(t):[],{style:(this.currency?"currency":this.unit&&"unit")||"decimal",currency:this.currency?this.currency.evaluate(t):void 0,unit:this.unit?this.unit.evaluate(t):void 0,minimumFractionDigits:this.minFractionDigits?this.minFractionDigits.evaluate(t):void 0,maximumFractionDigits:this.maxFractionDigits?this.maxFractionDigits.evaluate(t):void 0}).format(this.number.evaluate(t))}eachChild(t){t(this.number),this.locale&&t(this.locale),this.currency&&t(this.currency),this.unit&&t(this.unit),this.minFractionDigits&&t(this.minFractionDigits),this.maxFractionDigits&&t(this.maxFractionDigits)}outputDefined(){return!1}serialize(){const t={};return this.locale&&(t.locale=this.locale.serialize()),this.currency&&(t.currency=this.currency.serialize()),this.unit&&(t.unit=this.unit.serialize()),this.minFractionDigits&&(t["min-fraction-digits"]=this.minFractionDigits.serialize()),this.maxFractionDigits&&(t["max-fraction-digits"]=this.maxFractionDigits.serialize()),["number-format",this.number.serialize(),t]}}class Fs{constructor(t){this.type=Xn,this.input=t}static parse(t,e){if(2!==t.length)return e.error(`Expected 1 argument, but found ${t.length-1} instead.`);const i=e.parse(t[1],1);return i?"array"!==i.type.kind&&"string"!==i.type.kind&&"value"!==i.type.kind?e.error(`Expected argument of type string or array, but found ${sr(i.type)} instead.`):new Fs(i):null}evaluate(t){const e=this.input.evaluate(t);if("string"==typeof e)return e.length;if(Array.isArray(e))return e.length;throw new xr(`Expected value to be of type string or array, but found ${sr(gr(e))} instead.`)}eachChild(t){t(this.input)}outputDefined(){return!1}serialize(){const t=["length"];return this.eachChild((e=>{t.push(e.serialize())})),t}}function Ns(t){return function(){t=1831565813+(t|=0)|0;let e=Math.imul(t^t>>>15,1|t);return e=e+Math.imul(e^e>>>7,61|e)^e,((e^e>>>14)>>>0)/4294967296}}const Us={"==":$s,"!=":ks,">":zs,"=":Os,"=0&&t=0&&e=0&&i=0&&n-1}function Xs(t){return"data-driven"===t["property-type"]}function Ks(t){return Ys(t.expression,"measure-light")}function Js(t){return Ys(t.expression,"zoom")}function Qs(t){return!!t.expression&&t.expression.interpolated}function ta(t){return"object"==typeof t&&null!==t&&!Array.isArray(t)}function ea(t){return t}function ia(t,e){const i="color"===e.type,n=t.stops&&"object"==typeof t.stops[0][0],r=n||!(n||void 0!==t.property),o=t.type||(Qs(e)?"exponential":"interval");if(i&&((t=qn({},t)).stops&&(t.stops=t.stops.map((t=>[t[0],Un.parse(t[1])]))),t.default=Un.parse(t.default?t.default:e.default)),t.colorSpace&&"rgb"!==t.colorSpace&&!ys[t.colorSpace])throw new Error(`Unknown color space: ${t.colorSpace}`);let s,a,l;if("exponential"===o)s=sa;else if("interval"===o)s=oa;else if("categorical"===o){s=ra,a=Object.create(null);for(const e of t.stops)a[e[0]]=e[1];l=typeof t.stops[0][0]}else{if("identity"!==o)throw new Error(`Unknown function type "${o}"`);s=aa}if(n){const i={},n=[];for(let e=0;et[0])),evaluate:({zoom:i},n)=>sa({stops:r,base:t.base},e,i).evaluate(i,n)}}if(r){const i="exponential"===o?{name:"exponential",base:void 0!==t.base?t.base:1}:null;return{kind:"camera",interpolationType:i,interpolationFactor:vs.interpolationFactor.bind(void 0,i),zoomStops:t.stops.map((t=>t[0])),evaluate:({zoom:i})=>s(t,e,i,a,l)}}return{kind:"source",evaluate(i,n){const r=n&&n.properties?n.properties[t.property]:void 0;return void 0===r?na(t.default,e.default):s(t,e,r,a,l)}}}function na(t,e,i){return void 0!==t?t:void 0!==e?e:void 0!==i?i:void 0}function ra(t,e,i,n,r){return na(typeof i===r?n[i]:void 0,t.default,e.default)}function oa(t,e,i){if("number"!==Er(i))return na(t.default,e.default);const n=t.stops.length;if(1===n)return t.stops[0][1];if(i=t.stops[n-1][0])return t.stops[n-1][1];const r=Qo(t.stops.map((t=>t[0])),i);return t.stops[r][1]}function sa(t,e,i){const n=void 0!==t.base?t.base:1;if("number"!==Er(i))return na(t.default,e.default);const r=t.stops.length;if(1===r)return t.stops[0][1];if(i=t.stops[r-1][0])return t.stops[r-1][1];const o=Qo(t.stops.map((t=>t[0])),i),s=function(t,e,i,n){const r=n-i,o=t-i;return 0===r?0:1===e?o/r:(Math.pow(e,o)-1)/(Math.pow(e,r)-1)}(i,n,t.stops[o][0],t.stops[o+1][0]),a=t.stops[o][1],l=t.stops[o+1][1];let c=Zn[e.type]||ea;if(t.colorSpace&&"rgb"!==t.colorSpace){const e=ys[t.colorSpace];c=(t,i)=>e.reverse(e.interpolate(e.forward(t),e.forward(i),s))}return"function"==typeof a.evaluate?{evaluate(...t){const e=a.evaluate.apply(void 0,t),i=l.evaluate.apply(void 0,t);if(void 0!==e&&void 0!==i)return c(e,i,s)}}:c(a,l,s)}function aa(t,e,i){return"color"===e.type?i=Un.parse(i):"formatted"===e.type?i=pr.fromString(i.toString()):"resolvedImage"===e.type?i=fr.fromString(i.toString()):Er(i)===e.type||"enum"===e.type&&e.values[i]||(i=void 0),na(i,t.default,e.default)}Lr.register(Us,{error:[{kind:"error"},[Kn],(t,[e])=>{throw new xr(e.evaluate(t))}],typeof:[Kn,[er],(t,[e])=>sr(gr(e.evaluate(t)))],"to-rgba":[or(Xn,4),[Qn],(t,[e])=>e.evaluate(t).toRenderColor(null).toArray()],rgb:[Qn,[Xn,Xn,Xn],js],rgba:[Qn,[Xn,Xn,Xn,Xn],js],hsl:[Qn,[Xn,Xn,Xn],Vs],hsla:[Qn,[Xn,Xn,Xn,Xn],Vs],has:{type:Jn,overloads:[[[Kn],(t,[e])=>Gs(e.evaluate(t),t.properties())],[[Kn,tr],(t,[e,i])=>Gs(e.evaluate(t),i.evaluate(t))]]},get:{type:er,overloads:[[[Kn],(t,[e])=>Zs(e.evaluate(t),t.properties())],[[Kn,tr],(t,[e,i])=>Zs(e.evaluate(t),i.evaluate(t))]]},"feature-state":[er,[Kn],(t,[e])=>Zs(e.evaluate(t),t.featureState||{})],properties:[tr,[],t=>t.properties()],"geometry-type":[Kn,[],t=>t.geometryType()],id:[er,[],t=>t.id()],zoom:[Xn,[],t=>t.globals.zoom],pitch:[Xn,[],t=>t.globals.pitch||0],"distance-from-center":[Xn,[],t=>t.distanceFromCenter()],"measure-light":[Xn,[Kn],(t,[e])=>t.measureLight(e.evaluate(t))],"heatmap-density":[Xn,[],t=>t.globals.heatmapDensity||0],"line-progress":[Xn,[],t=>t.globals.lineProgress||0],"raster-value":[Xn,[],t=>t.globals.rasterValue||0],"raster-particle-speed":[Xn,[],t=>t.globals.rasterParticleSpeed||0],"sky-radial-progress":[Xn,[],t=>t.globals.skyRadialProgress||0],accumulated:[er,[],t=>void 0===t.globals.accumulated?null:t.globals.accumulated],"+":[Xn,qs(Xn),(t,e)=>{let i=0;for(const n of e)i+=n.evaluate(t);return i}],"*":[Xn,qs(Xn),(t,e)=>{let i=1;for(const n of e)i*=n.evaluate(t);return i}],"-":{type:Xn,overloads:[[[Xn,Xn],(t,[e,i])=>e.evaluate(t)-i.evaluate(t)],[[Xn],(t,[e])=>-e.evaluate(t)]]},"/":[Xn,[Xn,Xn],(t,[e,i])=>e.evaluate(t)/i.evaluate(t)],"%":[Xn,[Xn,Xn],(t,[e,i])=>e.evaluate(t)%i.evaluate(t)],ln2:[Xn,[],()=>Math.LN2],pi:[Xn,[],()=>Math.PI],e:[Xn,[],()=>Math.E],"^":[Xn,[Xn,Xn],(t,[e,i])=>Math.pow(e.evaluate(t),i.evaluate(t))],sqrt:[Xn,[Xn],(t,[e])=>Math.sqrt(e.evaluate(t))],log10:[Xn,[Xn],(t,[e])=>Math.log(e.evaluate(t))/Math.LN10],ln:[Xn,[Xn],(t,[e])=>Math.log(e.evaluate(t))],log2:[Xn,[Xn],(t,[e])=>Math.log(e.evaluate(t))/Math.LN2],sin:[Xn,[Xn],(t,[e])=>Math.sin(e.evaluate(t))],cos:[Xn,[Xn],(t,[e])=>Math.cos(e.evaluate(t))],tan:[Xn,[Xn],(t,[e])=>Math.tan(e.evaluate(t))],asin:[Xn,[Xn],(t,[e])=>Math.asin(e.evaluate(t))],acos:[Xn,[Xn],(t,[e])=>Math.acos(e.evaluate(t))],atan:[Xn,[Xn],(t,[e])=>Math.atan(e.evaluate(t))],min:[Xn,qs(Xn),(t,e)=>Math.min(...e.map((e=>e.evaluate(t))))],max:[Xn,qs(Xn),(t,e)=>Math.max(...e.map((e=>e.evaluate(t))))],abs:[Xn,[Xn],(t,[e])=>Math.abs(e.evaluate(t))],round:[Xn,[Xn],(t,[e])=>{const i=e.evaluate(t);return iMath.floor(e.evaluate(t))],ceil:[Xn,[Xn],(t,[e])=>Math.ceil(e.evaluate(t))],"filter-==":[Jn,[Kn,er],(t,[e,i])=>t.properties()[e.value]===i.value],"filter-id-==":[Jn,[er],(t,[e])=>t.id()===e.value],"filter-type-==":[Jn,[Kn],(t,[e])=>t.geometryType()===e.value],"filter-{const n=t.properties()[e.value],r=i.value;return typeof n==typeof r&&n{const i=t.id(),n=e.value;return typeof i==typeof n&&i":[Jn,[Kn,er],(t,[e,i])=>{const n=t.properties()[e.value],r=i.value;return typeof n==typeof r&&n>r}],"filter-id->":[Jn,[er],(t,[e])=>{const i=t.id(),n=e.value;return typeof i==typeof n&&i>n}],"filter-{const n=t.properties()[e.value],r=i.value;return typeof n==typeof r&&n{const i=t.id(),n=e.value;return typeof i==typeof n&&i=":[Jn,[Kn,er],(t,[e,i])=>{const n=t.properties()[e.value],r=i.value;return typeof n==typeof r&&n>=r}],"filter-id->=":[Jn,[er],(t,[e])=>{const i=t.id(),n=e.value;return typeof i==typeof n&&i>=n}],"filter-has":[Jn,[er],(t,[e])=>e.value in t.properties()],"filter-has-id":[Jn,[],t=>null!==t.id()&&void 0!==t.id()],"filter-type-in":[Jn,[or(Kn)],(t,[e])=>e.value.indexOf(t.geometryType())>=0],"filter-id-in":[Jn,[or(er)],(t,[e])=>e.value.indexOf(t.id())>=0],"filter-in-small":[Jn,[Kn,or(er)],(t,[e,i])=>i.value.indexOf(t.properties()[e.value])>=0],"filter-in-large":[Jn,[Kn,or(er)],(t,[e,i])=>function(t,e,i,n){for(;i>1;if(e[r]===t)return!0;e[r]>t?n=r-1:i=r+1}return!1}(t.properties()[e.value],i.value,0,i.value.length-1)],all:{type:Jn,overloads:[[[Jn,Jn],(t,[e,i])=>e.evaluate(t)&&i.evaluate(t)],[qs(Jn),(t,e)=>{for(const i of e)if(!i.evaluate(t))return!1;return!0}]]},any:{type:Jn,overloads:[[[Jn,Jn],(t,[e,i])=>e.evaluate(t)||i.evaluate(t)],[qs(Jn),(t,e)=>{for(const i of e)if(i.evaluate(t))return!0;return!1}]]},"!":[Jn,[Jn],(t,[e])=>!e.evaluate(t)],"is-supported-script":[Jn,[Kn],(t,[e])=>{const i=t.globals&&t.globals.isSupportedScript;return!i||i(e.evaluate(t))}],upcase:[Kn,[Kn],(t,[e])=>e.evaluate(t).toUpperCase()],downcase:[Kn,[Kn],(t,[e])=>e.evaluate(t).toLowerCase()],concat:[Kn,qs(er),(t,e)=>e.map((e=>yr(e.evaluate(t)))).join("")],"resolved-locale":[Kn,[ir],(t,[e])=>e.evaluate(t).resolvedLocale()],random:[Xn,[Xn,Xn,er],(t,e)=>{const[i,n,r]=e.map((e=>e.evaluate(t)));if(i>n)return i;if(i===n)return i;let o;if("string"==typeof r)o=function(t){let e=0;if(0===t.length)return e;for(let i=0;iJSON.stringify(t))).join(", ")}, but found ${JSON.stringify(t)} instead.`);return t}catch(t){return this._warningHistory[t.message]||(this._warningHistory[t.message]=!0,"undefined"!=typeof console&&console.warn(t.message)),this._defaultValue}}}function ca(t){return Array.isArray(t)&&t.length>0&&"string"==typeof t[0]&&t[0]in Us}function da(t,e,i,n){const r=new Ko(Us,[],e?function(t){const e={color:Qn,string:Kn,number:Xn,enum:Kn,boolean:Jn,formatted:nr,resolvedImage:rr};return"array"===t.type?or(e[t.value]||er,t.length):e[t.type]}(e):void 0,void 0,void 0,i,n),o=r.parse(t,void 0,void 0,void 0,e&&"string"===e.type?{typeAnnotation:"coerce"}:void 0);return o?Hs(new la(o,e,i,n)):Ws(r.errors)}class ua{constructor(t,e,i){this.kind=t,this._styleExpression=e,this.isLightConstant=i,this.isStateDependent="constant"!==t&&!qo(e.expression),this.isConfigDependent=!Ho(e.expression)}evaluateWithoutErrorHandling(t,e,i,n,r,o){return this._styleExpression.evaluateWithoutErrorHandling(t,e,i,n,r,o)}evaluate(t,e,i,n,r,o){return this._styleExpression.evaluate(t,e,i,n,r,o)}}class ha{constructor(t,e,i,n,r){this.kind=t,this.zoomStops=i,this._styleExpression=e,this.isStateDependent="camera"!==t&&!qo(e.expression),this.isLightConstant=r,this.isConfigDependent=!Ho(e.expression),this.interpolationType=n}evaluateWithoutErrorHandling(t,e,i,n,r,o){return this._styleExpression.evaluateWithoutErrorHandling(t,e,i,n,r,o)}evaluate(t,e,i,n,r,o){return this._styleExpression.evaluate(t,e,i,n,r,o)}interpolationFactor(t,e,i){return this.interpolationType?vs.interpolationFactor(this.interpolationType,t,e,i):0}}function pa(t,e,i,n){if("error"===(t=da(t,e,i,n)).result)return t;const r=t.value.expression,o=Zo(r);if(!o&&!Xs(e))return Ws([new Hn("","data expressions not supported")]);const s=Wo(r,["zoom","pitch","distance-from-center"]);if(!s&&!Js(e))return Ws([new Hn("","zoom expressions not supported")]);const a=Wo(r,["measure-light"]);if(!a&&!Ks(e))return Ws([new Hn("","measure-light expression not supported")]);const l=e.expression&&e.expression.relaxZoomRestriction,c=ma(r);return c||s||l?c instanceof Hn?Ws([c]):c instanceof vs&&!Qs(e)?Ws([new Hn("",'"interpolate" expressions cannot be used with this property')]):Hs(c?new ha(o?"camera":"composite",t.value,c.labels,c instanceof vs?c.interpolation:void 0,a):new ua(o?"constant":"source",t.value,a)):Ws([new Hn("",'"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression, or in the properties of atmosphere.')])}class fa{constructor(t,e){this._parameters=t,this._specification=e,qn(this,ia(this._parameters,this._specification))}static deserialize(t){return new fa(t._parameters,t._specification)}static serialize(t){return{_parameters:t._parameters,_specification:t._specification}}}function ma(t){let e=null;if(t instanceof ws)e=ma(t.result);else if(t instanceof bs){for(const i of t.args)if(e=ma(i),e)break}else(t instanceof ts||t instanceof vs)&&t.input instanceof Lr&&"zoom"===t.input.name&&(e=t);return e instanceof Hn||t.eachChild((t=>{const i=ma(t);i instanceof Hn?e=i:e&&i&&e!==i&&(e=new Hn("",'Only one zoom-based "step" or "interpolate" subexpression may be used in an expression.'))})),e}var _a=ya,ga=3;function ya(t,e,i){var n=this.cells=[];if(t instanceof ArrayBuffer){this.arrayBuffer=t;var r=new Int32Array(this.arrayBuffer);t=r[0],this.d=(e=r[1])+2*(i=r[2]);for(var o=0;o=d[p+0]&&n>=d[p+1])?(s[h]=!0,o.push(c[h])):s[h]=!1}}},ya.prototype._forEachCell=function(t,e,i,n,r,o,s,a){for(var l=this._convertToCellCoord(t),c=this._convertToCellCoord(e),d=this._convertToCellCoord(i),u=this._convertToCellCoord(n),h=l;h=0||(r[i]=Sa(t[i],e)));t instanceof Error&&(r.message=t.message)}if(r.$name)throw new Error("$name property is reserved for worker serialization logic.");return"Object"!==n&&(r.$name=n),r}throw new Error("can't serialize object of type "+typeof t)}function Ea(t){if(null==t||"boolean"==typeof t||"number"==typeof t||"string"==typeof t||t instanceof Boolean||t instanceof Number||t instanceof String||t instanceof Date||t instanceof RegExp||wa(t)||Ta(t)||ArrayBuffer.isView(t)||t instanceof ImageData)return t;if(Array.isArray(t))return t.map(Ea);if("object"==typeof t){const e=t.$name||"Object";if("Map"===e){const e=new Map;for(const i of Object.keys(t))"$name"!==i&&e.set(i,Ea(t[i]));return e}const{klass:i}=xa[e];if(!i)throw new Error(`can't deserialize unregistered class ${e}`);if(i.deserialize)return i.deserialize(t);const n=Object.create(i.prototype);for(const e of Object.keys(t))"$name"!==e&&(n[e]=Ea(t[e]));return n}throw new Error("can't deserialize object of type "+typeof t)}const Ma={"Latin-1 Supplement":t=>t>=128&&tt>=1536&&tt>=1872&&tt>=2208&&tt>=4352&&tt>=5120&&tt>=6016&&tt>=6320&&tt>=8192&&tt>=8448&&tt>=8528&&tt>=8960&&tt>=9216&&tt>=9280&&tt>=9312&&tt>=9632&&tt>=9728&&tt>=11008&&tt>=11904&&tt>=12032&&tt>=12272&&tt>=12288&&tt>=12352&&tt>=12448&&tt>=12544&&tt>=12592&&tt>=12688&&tt>=12704&&tt>=12736&&tt>=12784&&tt>=12800&&tt>=13056&&tt>=13312&&tt>=19904&&tt>=19968&&tt>=40960&&tt>=42128&&tt>=43360&&tt>=44032&&tt>=55216&&tt>=57344&&tt>=63744&&tt>=64336&&tt>=65040&&tt>=65072&&tt>=65104&&tt>=65136&&tt>=65280&&tt>=131072&&t=65097&&t=12296&&t=12308&&t=65306&&t=65371&&t=65512&&t=65112&&t=65123&&t=8960&&t=8972&&t=8996&&t=9085&&t=9150&&t=9169&&t=9186&&t=9754&&t=11026&&t=11088&&t=11192&&t=9984&&t=10102&&t=1424&&t=2304&&t=3840&&t-1&&(Fa="error"),Ba&&Ba(t)};function ja(){Va.fire(new Pn("pluginStateChange",{pluginStatus:Fa,pluginURL:Na}))}const Va=new zn,Ga=function(){return Fa},Za=function(){if(Fa!==za||!Na)throw new Error("rtl-text-plugin cannot be downloaded unless a pluginURL is specified");Fa=Ra,ja(),Na&&en({url:Na},(t=>{t?Ua(t):(Fa=Oa,ja())}))},qa={applyArabicShaping:null,processBidirectionalText:null,processStyledBidirectionalText:null,isLoaded:()=>Fa===Oa||null!=qa.applyArabicShaping,isLoading:()=>Fa===Ra,setState(t){Fa=t.pluginStatus,Na=t.pluginURL},isParsed:()=>null!=qa.applyArabicShaping&&null!=qa.processBidirectionalText&&null!=qa.processStyledBidirectionalText,getPluginURL:()=>Na};class Ha{constructor(t,e){this.zoom=t,e?(this.now=e.now,this.fadeDuration=e.fadeDuration,this.transition=e.transition,this.pitch=e.pitch,this.brightness=e.brightness):(this.now=0,this.fadeDuration=0,this.transition={},this.pitch=0,this.brightness=0)}isSupportedScript(t){return function(t,e){for(const i of t)if(!ka(i.charCodeAt(0),e))return!1;return!0}(t,qa.isLoaded())}}class Wa{constructor(t,e,i,n){this.property=t,this.value=e,this.expression=function(t,e,i,n){if(ta(t))return new fa(t,e);if(ca(t)||Array.isArray(t)&&t.length>0){const r=pa(t,e,i,n);if("error"===r.result)throw new Error(r.value.map((t=>`${t.key}: ${t.message}`)).join(", "));return r.value}{let i=t;return"string"==typeof t&&"color"===e.type&&(i=Un.parse(t)),{kind:"constant",isConfigDependent:!1,evaluate:()=>i}}}(void 0===e?t.specification.default:e,t.specification,i,n)}isDataDriven(){return"source"===this.expression.kind||"composite"===this.expression.kind}possiblyEvaluate(t,e,i){return this.property.possiblyEvaluate(this,t,e,i)}}class Ya{constructor(t,e,i){this.property=t,this.value=new Wa(t,void 0,e,i)}transitioned(t,e){return new Ka(this.property,this.value,e,ei({},t.transition,this.transition),t.now)}untransitioned(){return new Ka(this.property,this.value,null,{},0)}}class Xa{constructor(t,e,i){this._properties=t,this._values=Object.create(t.defaultTransitionablePropertyValues),this._scope=e,this._options=i,this.isConfigDependent=!1}getValue(t){return ui(this._values[t].value.value)}setValue(t,e){this._values.hasOwnProperty(t)||(this._values[t]=new Ya(this._values[t].property,this._scope,this._options)),this._values[t].value=new Wa(this._values[t].property,null===e?void 0:ui(e),this._scope,this._options),this.isConfigDependent=this.isConfigDependent||this._values[t].value.expression.isConfigDependent}setTransitionOrValue(t,e){e&&(this._options=e);const i=this._properties.properties;if(t)for(const e in t){const n=t[e];if(li(e,"-transition")){const t=e.slice(0,-11);i[t]&&this.setTransition(t,n)}else i.hasOwnProperty(e)&&this.setValue(e,n)}}getTransition(t){return ui(this._values[t].transition)}setTransition(t,e){this._values.hasOwnProperty(t)||(this._values[t]=new Ya(this._values[t].property)),this._values[t].transition=ui(e)||void 0}serialize(){const t={};for(const e of Object.keys(this._values)){const i=this.getValue(e);void 0!==i&&(t[e]=i);const n=this.getTransition(e);void 0!==n&&(t[`${e}-transition`]=n)}return t}transitioned(t,e){const i=new Ja(this._properties);for(const n of Object.keys(this._values))i._values[n]=this._values[n].transitioned(t,e._values[n]);return i}untransitioned(){const t=new Ja(this._properties);for(const e of Object.keys(this._values))t._values[e]=this._values[e].untransitioned();return t}}class Ka{constructor(t,e,i,n,r){const o=n.delay||0,s=n.duration||0;r=r||0,this.property=t,this.value=e,this.begin=r+o,this.end=this.begin+s,t.specification.transition&&(n.delay||n.duration)&&(this.prior=i)}possiblyEvaluate(t,e,i){const n=t.now||0,r=this.value.possiblyEvaluate(t,e,i),o=this.prior;if(o){if(n>this.end)return this.prior=null,r;if(this.value.isDataDriven())return this.prior=null,r;if(n":1,">=":1,"=2&&"$id"!==t[1]&&"$type"!==t[1];case"in":return t.length>=3&&("string"!=typeof t[1]||Array.isArray(t[2]));case"!in":case"!has":case"none":return!1;case"==":case"!=":case">":case">=":case"!0,needGeometry:!1,needFeature:!1};cl(t)||(t=gl(t));const i=t;let n=!0;try{n=function(t){if(!pl(t))return t;let e=ll(t);return hl(e),e=ul(e),e}(i)}catch(t){console.warn(`Failed to extract static filter. Filter will continue working, but at higher memory usage and slower framerate.\nThis is most likely a bug, please report this via https://github.com/mapbox/mapbox-gl-js/issues/new?assignees=&labels=&template=Bug_report.md\nand paste the contents of this message in the report.\nThank you!\nFilter Expression:\n${JSON.stringify(i,null,2)}\n `)}const r=sl[`filter_${e}`],o=da(n,r);let s=null;if("error"===o.result)throw new Error(o.value.map((t=>`${t.key}: ${t.message}`)).join(", "));s=(t,e,i)=>o.value.evaluate(t,e,{},i);let a=null,l=null;if(n!==i){const t=da(i,r);if("error"===t.result)throw new Error(t.value.map((t=>`${t.key}: ${t.message}`)).join(", "));a=(e,i,n,r,o)=>t.value.evaluate(e,i,{},n,void 0,void 0,r,o),l=!Zo(t.value.expression)}return{filter:s,dynamicFilter:a||void 0,needGeometry:_l(n),needFeature:!!l}}function ul(t){if(!Array.isArray(t))return t;const e=function(t){if(fl.has(t[0]))for(let e=1;eul(t)))}function hl(t){let e=!1;const i=[];if("case"===t[0]){for(let n=1;n",">=","e?1:0}function _l(t){if(!Array.isArray(t))return!1;if("within"===t[0]||"distance"===t[0])return!0;for(let e=1;e"===e||"="===e?yl(t[1],t[2],e):"any"===e?(i=t.slice(1),["any"].concat(i.map(gl))):"all"===e?["all"].concat(t.slice(1).map(gl)):"none"===e?["all"].concat(t.slice(1).map(gl).map(bl)):"in"===e?vl(t[1],t.slice(2)):"!in"===e?bl(vl(t[1],t.slice(2))):"has"===e?xl(t[1]):"!has"!==e||bl(xl(t[1]));var i}function yl(t,e,i){switch(t){case"$type":return[`filter-type-${i}`,e];case"$id":return[`filter-id-${i}`,e];default:return[`filter-${i}`,t,e]}}function vl(t,e){if(0===e.length)return!1;switch(t){case"$type":return["filter-type-in",["literal",e]];case"$id":return["filter-id-in",["literal",e]];default:return e.length>200&&!e.some((t=>typeof t!=typeof e[0]))?["filter-in-large",t,["literal",e.sort(ml)]]:["filter-in-small",t,["literal",e]]}}function xl(t){switch(t){case"$type":return!0;case"$id":return["filter-has-id"];default:return["filter-has",t]}}function bl(t){return["!",t]}const wl="";function Tl(t,e){return e?`${t}${wl}${e}`:t}const Sl="-transition",El=new Set(["fill","line","background","hillshade","raster"]);class Ml extends zn{constructor(t,e,i,n,r){if(super(),this.id=t.id,this.fqid=Tl(this.id,i),this.type=t.type,this.scope=i,this.lut=n,this.options=r,this._featureFilter={filter:()=>!0,needGeometry:!1,needFeature:!1},this._filterCompiled=!1,this.isConfigDependent=!1,"custom"!==t.type&&(this.metadata=t.metadata,this.minzoom=t.minzoom,this.maxzoom=t.maxzoom,"background"!==t.type&&"sky"!==t.type&&"slot"!==t.type&&(this.source=t.source,this.sourceLayer=t["source-layer"],this.filter=t.filter),t.slot&&(this.slot=t.slot),e.layout&&(this._unevaluatedLayout=new Qa(e.layout,this.scope,r),this.isConfigDependent=this.isConfigDependent||this._unevaluatedLayout.isConfigDependent),e.paint)){this._transitionablePaint=new Xa(e.paint,this.scope,r);for(const e in t.paint)this.setPaintProperty(e,t.paint[e]);for(const e in t.layout)this.setLayoutProperty(e,t.layout[e]);this.isConfigDependent=this.isConfigDependent||this._transitionablePaint.isConfigDependent,this._transitioningPaint=this._transitionablePaint.untransitioned(),this.paint=new el(e.paint)}}onAdd(t){}onRemove(t){}isDraped(t){return El.has(this.type)}getLayoutProperty(t){return"visibility"===t?this.visibility:this._unevaluatedLayout.getValue(t)}setLayoutProperty(t,e){if("custom"===this.type&&"visibility"===t)return void(this.visibility=e);const i=this._unevaluatedLayout;i._properties.properties[t]&&(i.setValue(t,e),this.isConfigDependent=this.isConfigDependent||i.isConfigDependent,"visibility"===t&&this.possiblyEvaluateVisibility())}possiblyEvaluateVisibility(){this.visibility=this._unevaluatedLayout._values.visibility.possiblyEvaluate({zoom:0})}getPaintProperty(t){return li(t,Sl)?this._transitionablePaint.getTransition(t.slice(0,-11)):this._transitionablePaint.getValue(t)}setPaintProperty(t,e){const i=this._transitionablePaint,n=i._properties.properties;if(li(t,Sl)){const r=t.slice(0,-11);return n[r]&&i.setTransition(r,e||void 0),!1}if(!n[t])return!1;const r=i._values[t],o=r.value.isDataDriven(),s=r.value;i.setValue(t,e),this.isConfigDependent=this.isConfigDependent||i.isConfigDependent,this._handleSpecialPaintPropertyUpdate(t);const a=i._values[t].value,l=a.isDataDriven(),c=li(t,"pattern")||"line-dasharray"===t;return l||o||c||this._handleOverridablePaintPropertyUpdate(t,s,a)}_handleSpecialPaintPropertyUpdate(t){}getProgramIds(){return null}getDefaultProgramParams(t,e,i){return null}_handleOverridablePaintPropertyUpdate(t,e,i){return!1}isHidden(t){return!!(this.minzoom&&t=this.maxzoom)||"none"===this.visibility}updateTransitions(t){this._transitioningPaint=this._transitionablePaint.transitioned(t,this._transitioningPaint)}hasTransition(){return this._transitioningPaint.hasTransition()}recalculate(t,e){this._unevaluatedLayout&&(this.layout=this._unevaluatedLayout.possiblyEvaluate(t,void 0,e)),this.paint=this._transitioningPaint.possiblyEvaluate(t,void 0,e)}serialize(){return di({id:this.id,type:this.type,slot:this.slot,source:this.source,"source-layer":this.sourceLayer,metadata:this.metadata,minzoom:this.minzoom,maxzoom:this.maxzoom,filter:this.filter,layout:this._unevaluatedLayout&&this._unevaluatedLayout.serialize(),paint:this._transitionablePaint&&this._transitionablePaint.serialize()},((t,e)=>!(void 0===t||"layout"===e&&!Object.keys(t).length||"paint"===e&&!Object.keys(t).length)))}is3D(){return!1}isSky(){return!1}isTileClipped(){return!1}hasOffscreenPass(){return!1}hasShadowPass(){return!1}canCastShadows(){return!1}hasLightBeamPass(){return!1}cutoffRange(){return 0}tileCoverLift(){return 0}resize(){}isStateDependent(){for(const t in this.paint._values){const e=this.paint.get(t);if(e instanceof tl&&Xs(e.property.specification)&&("source"===e.value.kind||"composite"===e.value.kind)&&e.value.isStateDependent)return!0}return!1}compileFilter(){this._filterCompiled||(this._featureFilter=dl(this.filter),this._filterCompiled=!0)}invalidateCompiledFilter(){this._filterCompiled=!1}dynamicFilter(){return this._featureFilter.dynamicFilter}dynamicFilterNeedsFeature(){return this._featureFilter.needFeature}getLayerRenderingStats(){return this._stats}resetLayerRenderingStats(t){this._stats&&("shadow"===t.renderPass?this._stats.numRenderedVerticesInShadowPass=0:this._stats.numRenderedVerticesInTransparentPass=0)}queryRadius(t){}queryIntersectsFeature(t,e,i,n,r,o,s,a,l){}queryIntersectsMatchingFeature(t,e,i,n){}}const Cl={Int8:Int8Array,Uint8:Uint8Array,Int16:Int16Array,Uint16:Uint16Array,Int32:Int32Array,Uint32:Uint32Array,Float32:Float32Array};class Al{constructor(t,e){this._structArray=t,this._pos1=e*this.size,this._pos2=this._pos1/2,this._pos4=this._pos1/4,this._pos8=this._pos1/8}}class Il{constructor(){this.isTransferred=!1,this.capacity=-1,this.resize(0)}static serialize(t,e){return t._trim(),e&&(t.isTransferred=!0,e.add(t.arrayBuffer)),{length:t.length,arrayBuffer:t.arrayBuffer}}static deserialize(t){const e=Object.create(this.prototype);return e.arrayBuffer=t.arrayBuffer,e.length=t.length,e.capacity=t.arrayBuffer.byteLength/e.bytesPerElement,e._refreshViews(),e}_trim(){this.length!==this.capacity&&(this.capacity=this.length,this.arrayBuffer=this.arrayBuffer.slice(0,this.length*this.bytesPerElement),this._refreshViews())}clear(){this.length=0}resize(t){this.reserve(t),this.length=t}reserve(t){if(t>this.capacity){this.capacity=Math.max(t,Math.floor(5*this.capacity),128),this.arrayBuffer=new ArrayBuffer(this.capacity*this.bytesPerElement);const e=this.uint8;this._refreshViews(),e&&this.uint8.set(e)}}_refreshViews(){throw new Error("StructArray#_refreshViews() must be implemented by each concrete StructArray layout")}emplace(...t){throw new Error("StructArray#emplace() must be implemented by each concrete StructArray layout")}emplaceBack(...t){throw new Error("StructArray#emplaceBack() must be implemented by each concrete StructArray layout")}destroy(){this.int8=this.uint8=this.int16=this.uint16=this.int32=this.uint32=this.float32=null,this.arrayBuffer=null}}function Ll(t,e=1){let i=0,n=0;return{members:t.map((t=>{const r=Cl[t.type].BYTES_PER_ELEMENT,o=i=Pl(i,Math.max(e,r)),s=t.components||1;return n=Math.max(n,r),i+=r*s,{name:t.name,type:t.type,components:s,offset:o}})),size:Pl(i,Math.max(n,e)),alignment:e}}function Pl(t,e){return Math.ceil(t/e)*e}class $l extends Il{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,e){const i=this.length;return this.resize(i+1),this.emplace(i,t,e)}emplace(t,e,i){const n=2*t;return this.int16[n+0]=e,this.int16[n+1]=i,t}}$l.prototype.bytesPerElement=4,ba($l,"StructArrayLayout2i4");class kl extends Il{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,e,i){const n=this.length;return this.resize(n+1),this.emplace(n,t,e,i)}emplace(t,e,i,n){const r=3*t;return this.int16[r+0]=e,this.int16[r+1]=i,this.int16[r+2]=n,t}}kl.prototype.bytesPerElement=6,ba(kl,"StructArrayLayout3i6");class Dl extends Il{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,e,i,n){const r=this.length;return this.resize(r+1),this.emplace(r,t,e,i,n)}emplace(t,e,i,n,r){const o=4*t;return this.int16[o+0]=e,this.int16[o+1]=i,this.int16[o+2]=n,this.int16[o+3]=r,t}}Dl.prototype.bytesPerElement=8,ba(Dl,"StructArrayLayout4i8");class zl extends Il{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,e,i,n,r){const o=this.length;return this.resize(o+1),this.emplace(o,t,e,i,n,r)}emplace(t,e,i,n,r,o){const s=5*t;return this.int16[s+0]=e,this.int16[s+1]=i,this.int16[s+2]=n,this.int16[s+3]=r,this.int16[s+4]=o,t}}zl.prototype.bytesPerElement=10,ba(zl,"StructArrayLayout5i10");class Rl extends Il{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t,e,i,n,r,o,s){const a=this.length;return this.resize(a+1),this.emplace(a,t,e,i,n,r,o,s)}emplace(t,e,i,n,r,o,s,a){const l=6*t,c=12*t,d=3*t;return this.int16[l+0]=e,this.int16[l+1]=i,this.uint8[c+4]=n,this.uint8[c+5]=r,this.uint8[c+6]=o,this.uint8[c+7]=s,this.float32[d+2]=a,t}}Rl.prototype.bytesPerElement=12,ba(Rl,"StructArrayLayout2i4ub1f12");class Ol extends Il{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t,e,i,n){const r=this.length;return this.resize(r+1),this.emplace(r,t,e,i,n)}emplace(t,e,i,n,r){const o=4*t;return this.float32[o+0]=e,this.float32[o+1]=i,this.float32[o+2]=n,this.float32[o+3]=r,t}}Ol.prototype.bytesPerElement=16,ba(Ol,"StructArrayLayout4f16");class Bl extends Il{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t,e,i){const n=this.length;return this.resize(n+1),this.emplace(n,t,e,i)}emplace(t,e,i,n){const r=3*t;return this.float32[r+0]=e,this.float32[r+1]=i,this.float32[r+2]=n,t}}Bl.prototype.bytesPerElement=12,ba(Bl,"StructArrayLayout3f12");class Fl extends Il{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t,e,i,n,r){const o=this.length;return this.resize(o+1),this.emplace(o,t,e,i,n,r)}emplace(t,e,i,n,r,o){const s=6*t,a=3*t;return this.uint16[s+0]=e,this.uint16[s+1]=i,this.uint16[s+2]=n,this.uint16[s+3]=r,this.float32[a+2]=o,t}}Fl.prototype.bytesPerElement=12,ba(Fl,"StructArrayLayout4ui1f12");class Nl extends Il{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(t,e,i,n){const r=this.length;return this.resize(r+1),this.emplace(r,t,e,i,n)}emplace(t,e,i,n,r){const o=4*t;return this.uint16[o+0]=e,this.uint16[o+1]=i,this.uint16[o+2]=n,this.uint16[o+3]=r,t}}Nl.prototype.bytesPerElement=8,ba(Nl,"StructArrayLayout4ui8");class Ul extends Il{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,e,i,n,r,o){const s=this.length;return this.resize(s+1),this.emplace(s,t,e,i,n,r,o)}emplace(t,e,i,n,r,o,s){const a=6*t;return this.int16[a+0]=e,this.int16[a+1]=i,this.int16[a+2]=n,this.int16[a+3]=r,this.int16[a+4]=o,this.int16[a+5]=s,t}}Ul.prototype.bytesPerElement=12,ba(Ul,"StructArrayLayout6i12");class jl extends Il{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(t,e,i,n,r,o,s,a,l,c,d,u){const h=this.length;return this.resize(h+1),this.emplace(h,t,e,i,n,r,o,s,a,l,c,d,u)}emplace(t,e,i,n,r,o,s,a,l,c,d,u,h){const p=12*t;return this.int16[p+0]=e,this.int16[p+1]=i,this.int16[p+2]=n,this.int16[p+3]=r,this.uint16[p+4]=o,this.uint16[p+5]=s,this.uint16[p+6]=a,this.uint16[p+7]=l,this.int16[p+8]=c,this.int16[p+9]=d,this.int16[p+10]=u,this.int16[p+11]=h,t}}jl.prototype.bytesPerElement=24,ba(jl,"StructArrayLayout4i4ui4i24");class Vl extends Il{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t,e,i,n,r,o){const s=this.length;return this.resize(s+1),this.emplace(s,t,e,i,n,r,o)}emplace(t,e,i,n,r,o,s){const a=10*t,l=5*t;return this.int16[a+0]=e,this.int16[a+1]=i,this.int16[a+2]=n,this.float32[l+2]=r,this.float32[l+3]=o,this.float32[l+4]=s,t}}Vl.prototype.bytesPerElement=20,ba(Vl,"StructArrayLayout3i3f20");class Gl extends Il{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer)}emplaceBack(t){const e=this.length;return this.resize(e+1),this.emplace(e,t)}emplace(t,e){return this.uint32[1*t+0]=e,t}}Gl.prototype.bytesPerElement=4,ba(Gl,"StructArrayLayout1ul4");class Zl extends Il{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t){const e=this.length;return this.resize(e+1),this.emplace(e,t)}emplace(t,e){return this.float32[1*t+0]=e,t}}Zl.prototype.bytesPerElement=4,ba(Zl,"StructArrayLayout1f4");class ql extends Il{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(t,e){const i=this.length;return this.resize(i+1),this.emplace(i,t,e)}emplace(t,e,i){const n=2*t;return this.uint16[n+0]=e,this.uint16[n+1]=i,t}}ql.prototype.bytesPerElement=4,ba(ql,"StructArrayLayout2ui4");class Hl extends Il{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(t,e,i,n,r,o,s,a,l,c,d,u,h){const p=this.length;return this.resize(p+1),this.emplace(p,t,e,i,n,r,o,s,a,l,c,d,u,h)}emplace(t,e,i,n,r,o,s,a,l,c,d,u,h,p){const f=20*t,m=10*t;return this.int16[f+0]=e,this.int16[f+1]=i,this.int16[f+2]=n,this.int16[f+3]=r,this.int16[f+4]=o,this.float32[m+3]=s,this.float32[m+4]=a,this.float32[m+5]=l,this.float32[m+6]=c,this.int16[f+14]=d,this.uint32[m+8]=u,this.uint16[f+18]=h,this.uint16[f+19]=p,t}}Hl.prototype.bytesPerElement=40,ba(Hl,"StructArrayLayout5i4f1i1ul2ui40");class Wl extends Il{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,e,i,n,r,o,s){const a=this.length;return this.resize(a+1),this.emplace(a,t,e,i,n,r,o,s)}emplace(t,e,i,n,r,o,s,a){const l=8*t;return this.int16[l+0]=e,this.int16[l+1]=i,this.int16[l+2]=n,this.int16[l+4]=r,this.int16[l+5]=o,this.int16[l+6]=s,this.int16[l+7]=a,t}}Wl.prototype.bytesPerElement=16,ba(Wl,"StructArrayLayout3i2i2i16");class Yl extends Il{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,e,i,n,r){const o=this.length;return this.resize(o+1),this.emplace(o,t,e,i,n,r)}emplace(t,e,i,n,r,o){const s=4*t,a=8*t;return this.float32[s+0]=e,this.float32[s+1]=i,this.float32[s+2]=n,this.int16[a+6]=r,this.int16[a+7]=o,t}}Yl.prototype.bytesPerElement=16,ba(Yl,"StructArrayLayout2f1f2i16");class Xl extends Il{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t,e,i,n){const r=this.length;return this.resize(r+1),this.emplace(r,t,e,i,n)}emplace(t,e,i,n,r){const o=12*t,s=3*t;return this.uint8[o+0]=e,this.uint8[o+1]=i,this.float32[s+1]=n,this.float32[s+2]=r,t}}Xl.prototype.bytesPerElement=12,ba(Xl,"StructArrayLayout2ub2f12");class Kl extends Il{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(t,e,i){const n=this.length;return this.resize(n+1),this.emplace(n,t,e,i)}emplace(t,e,i,n){const r=3*t;return this.uint16[r+0]=e,this.uint16[r+1]=i,this.uint16[r+2]=n,t}}Kl.prototype.bytesPerElement=6,ba(Kl,"StructArrayLayout3ui6");class Jl extends Il{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer)}emplaceBack(t,e,i,n,r,o,s,a,l,c,d,u,h,p,f,m,_,g,y,v,x){const b=this.length;return this.resize(b+1),this.emplace(b,t,e,i,n,r,o,s,a,l,c,d,u,h,p,f,m,_,g,y,v,x)}emplace(t,e,i,n,r,o,s,a,l,c,d,u,h,p,f,m,_,g,y,v,x,b){const w=30*t,T=15*t,S=60*t;return this.int16[w+0]=e,this.int16[w+1]=i,this.int16[w+2]=n,this.float32[T+2]=r,this.float32[T+3]=o,this.uint16[w+8]=s,this.uint16[w+9]=a,this.uint32[T+5]=l,this.uint32[T+6]=c,this.uint32[T+7]=d,this.uint16[w+16]=u,this.uint16[w+17]=h,this.uint16[w+18]=p,this.float32[T+10]=f,this.float32[T+11]=m,this.uint8[S+48]=_,this.uint8[S+49]=g,this.uint8[S+50]=y,this.uint32[T+13]=v,this.int16[w+28]=x,this.uint8[S+58]=b,t}}Jl.prototype.bytesPerElement=60,ba(Jl,"StructArrayLayout3i2f2ui3ul3ui2f3ub1ul1i1ub60");class Ql extends Il{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer)}emplaceBack(t,e,i,n,r,o,s,a,l,c,d,u,h,p,f,m,_,g,y,v,x,b,w,T,S,E,M,C,A,I,L,P,$,k){const D=this.length;return this.resize(D+1),this.emplace(D,t,e,i,n,r,o,s,a,l,c,d,u,h,p,f,m,_,g,y,v,x,b,w,T,S,E,M,C,A,I,L,P,$,k)}emplace(t,e,i,n,r,o,s,a,l,c,d,u,h,p,f,m,_,g,y,v,x,b,w,T,S,E,M,C,A,I,L,P,$,k,D){const z=22*t,R=44*t,O=88*t;return this.float32[z+0]=e,this.float32[z+1]=i,this.int16[R+4]=n,this.int16[R+5]=r,this.int16[R+6]=o,this.int16[R+7]=s,this.int16[R+8]=a,this.int16[R+9]=l,this.int16[R+10]=c,this.int16[R+11]=d,this.int16[R+12]=u,this.uint16[R+13]=h,this.uint16[R+14]=p,this.uint16[R+15]=f,this.uint16[R+16]=m,this.uint16[R+17]=_,this.uint16[R+18]=g,this.uint16[R+19]=y,this.uint16[R+20]=v,this.uint16[R+21]=x,this.uint16[R+22]=b,this.uint16[R+23]=w,this.uint16[R+24]=T,this.uint16[R+25]=S,this.uint16[R+26]=E,this.uint16[R+27]=M,this.uint32[z+14]=C,this.float32[z+15]=A,this.float32[z+16]=I,this.float32[z+17]=L,this.float32[z+18]=P,this.float32[z+19]=$,this.float32[z+20]=k,this.uint8[O+84]=D,t}}Ql.prototype.bytesPerElement=88,ba(Ql,"StructArrayLayout2f9i15ui1ul6f1ub88");class tc extends Il{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t,e,i,n,r){const o=this.length;return this.resize(o+1),this.emplace(o,t,e,i,n,r)}emplace(t,e,i,n,r,o){const s=5*t;return this.float32[s+0]=e,this.float32[s+1]=i,this.float32[s+2]=n,this.float32[s+3]=r,this.float32[s+4]=o,t}}tc.prototype.bytesPerElement=20,ba(tc,"StructArrayLayout5f20");class ec extends Il{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t,e,i,n,r,o,s){const a=this.length;return this.resize(a+1),this.emplace(a,t,e,i,n,r,o,s)}emplace(t,e,i,n,r,o,s,a){const l=7*t;return this.float32[l+0]=e,this.float32[l+1]=i,this.float32[l+2]=n,this.float32[l+3]=r,this.float32[l+4]=o,this.float32[l+5]=s,this.float32[l+6]=a,t}}ec.prototype.bytesPerElement=28,ba(ec,"StructArrayLayout7f28");class ic extends Il{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t,e){const i=this.length;return this.resize(i+1),this.emplace(i,t,e)}emplace(t,e,i){const n=2*t;return this.float32[n+0]=e,this.float32[n+1]=i,t}}ic.prototype.bytesPerElement=8,ba(ic,"StructArrayLayout2f8");class nc extends Il{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(t,e,i,n){const r=this.length;return this.resize(r+1),this.emplace(r,t,e,i,n)}emplace(t,e,i,n,r){const o=6*t;return this.uint32[3*t+0]=e,this.uint16[o+2]=i,this.uint16[o+3]=n,this.uint16[o+4]=r,t}}nc.prototype.bytesPerElement=12,ba(nc,"StructArrayLayout1ul3ui12");class rc extends Il{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(t){const e=this.length;return this.resize(e+1),this.emplace(e,t)}emplace(t,e){return this.uint16[1*t+0]=e,t}}rc.prototype.bytesPerElement=2,ba(rc,"StructArrayLayout1ui2");class oc extends Il{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t,e,i,n,r,o,s,a,l,c,d,u,h,p,f,m){const _=this.length;return this.resize(_+1),this.emplace(_,t,e,i,n,r,o,s,a,l,c,d,u,h,p,f,m)}emplace(t,e,i,n,r,o,s,a,l,c,d,u,h,p,f,m,_){const g=16*t;return this.float32[g+0]=e,this.float32[g+1]=i,this.float32[g+2]=n,this.float32[g+3]=r,this.float32[g+4]=o,this.float32[g+5]=s,this.float32[g+6]=a,this.float32[g+7]=l,this.float32[g+8]=c,this.float32[g+9]=d,this.float32[g+10]=u,this.float32[g+11]=h,this.float32[g+12]=p,this.float32[g+13]=f,this.float32[g+14]=m,this.float32[g+15]=_,t}}oc.prototype.bytesPerElement=64,ba(oc,"StructArrayLayout16f64");class sc extends Il{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t,e,i,n,r,o,s){const a=this.length;return this.resize(a+1),this.emplace(a,t,e,i,n,r,o,s)}emplace(t,e,i,n,r,o,s,a){const l=10*t,c=5*t;return this.uint16[l+0]=e,this.uint16[l+1]=i,this.uint16[l+2]=n,this.uint16[l+3]=r,this.float32[c+2]=o,this.float32[c+3]=s,this.float32[c+4]=a,t}}sc.prototype.bytesPerElement=20,ba(sc,"StructArrayLayout4ui3f20");class ac extends Il{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t){const e=this.length;return this.resize(e+1),this.emplace(e,t)}emplace(t,e){return this.int16[1*t+0]=e,t}}ac.prototype.bytesPerElement=2,ba(ac,"StructArrayLayout1i2");class lc extends Il{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer)}emplaceBack(t){const e=this.length;return this.resize(e+1),this.emplace(e,t)}emplace(t,e){return this.uint8[1*t+0]=e,t}}lc.prototype.bytesPerElement=1,ba(lc,"StructArrayLayout1ub1");class cc extends Al{get projectedAnchorX(){return this._structArray.int16[this._pos2+0]}get projectedAnchorY(){return this._structArray.int16[this._pos2+1]}get projectedAnchorZ(){return this._structArray.int16[this._pos2+2]}get tileAnchorX(){return this._structArray.int16[this._pos2+3]}get tileAnchorY(){return this._structArray.int16[this._pos2+4]}get x1(){return this._structArray.float32[this._pos4+3]}get y1(){return this._structArray.float32[this._pos4+4]}get x2(){return this._structArray.float32[this._pos4+5]}get y2(){return this._structArray.float32[this._pos4+6]}get padding(){return this._structArray.int16[this._pos2+14]}get featureIndex(){return this._structArray.uint32[this._pos4+8]}get sourceLayerIndex(){return this._structArray.uint16[this._pos2+18]}get bucketIndex(){return this._structArray.uint16[this._pos2+19]}}cc.prototype.size=40;class dc extends Hl{get(t){return new cc(this,t)}}ba(dc,"CollisionBoxArray");class uc extends Al{get projectedAnchorX(){return this._structArray.int16[this._pos2+0]}get projectedAnchorY(){return this._structArray.int16[this._pos2+1]}get projectedAnchorZ(){return this._structArray.int16[this._pos2+2]}get tileAnchorX(){return this._structArray.float32[this._pos4+2]}get tileAnchorY(){return this._structArray.float32[this._pos4+3]}get glyphStartIndex(){return this._structArray.uint16[this._pos2+8]}get numGlyphs(){return this._structArray.uint16[this._pos2+9]}get vertexStartIndex(){return this._structArray.uint32[this._pos4+5]}get lineStartIndex(){return this._structArray.uint32[this._pos4+6]}get lineLength(){return this._structArray.uint32[this._pos4+7]}get segment(){return this._structArray.uint16[this._pos2+16]}get lowerSize(){return this._structArray.uint16[this._pos2+17]}get upperSize(){return this._structArray.uint16[this._pos2+18]}get lineOffsetX(){return this._structArray.float32[this._pos4+10]}get lineOffsetY(){return this._structArray.float32[this._pos4+11]}get writingMode(){return this._structArray.uint8[this._pos1+48]}get placedOrientation(){return this._structArray.uint8[this._pos1+49]}set placedOrientation(t){this._structArray.uint8[this._pos1+49]=t}get hidden(){return this._structArray.uint8[this._pos1+50]}set hidden(t){this._structArray.uint8[this._pos1+50]=t}get crossTileID(){return this._structArray.uint32[this._pos4+13]}set crossTileID(t){this._structArray.uint32[this._pos4+13]=t}get associatedIconIndex(){return this._structArray.int16[this._pos2+28]}get flipState(){return this._structArray.uint8[this._pos1+58]}set flipState(t){this._structArray.uint8[this._pos1+58]=t}}uc.prototype.size=60;class hc extends Jl{get(t){return new uc(this,t)}}ba(hc,"PlacedSymbolArray");class pc extends Al{get tileAnchorX(){return this._structArray.float32[this._pos4+0]}get tileAnchorY(){return this._structArray.float32[this._pos4+1]}get projectedAnchorX(){return this._structArray.int16[this._pos2+4]}get projectedAnchorY(){return this._structArray.int16[this._pos2+5]}get projectedAnchorZ(){return this._structArray.int16[this._pos2+6]}get rightJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+7]}get centerJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+8]}get leftJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+9]}get verticalPlacedTextSymbolIndex(){return this._structArray.int16[this._pos2+10]}get placedIconSymbolIndex(){return this._structArray.int16[this._pos2+11]}get verticalPlacedIconSymbolIndex(){return this._structArray.int16[this._pos2+12]}get key(){return this._structArray.uint16[this._pos2+13]}get textBoxStartIndex(){return this._structArray.uint16[this._pos2+14]}get textBoxEndIndex(){return this._structArray.uint16[this._pos2+15]}get verticalTextBoxStartIndex(){return this._structArray.uint16[this._pos2+16]}get verticalTextBoxEndIndex(){return this._structArray.uint16[this._pos2+17]}get iconBoxStartIndex(){return this._structArray.uint16[this._pos2+18]}get iconBoxEndIndex(){return this._structArray.uint16[this._pos2+19]}get verticalIconBoxStartIndex(){return this._structArray.uint16[this._pos2+20]}get verticalIconBoxEndIndex(){return this._structArray.uint16[this._pos2+21]}get featureIndex(){return this._structArray.uint16[this._pos2+22]}get numHorizontalGlyphVertices(){return this._structArray.uint16[this._pos2+23]}get numVerticalGlyphVertices(){return this._structArray.uint16[this._pos2+24]}get numIconVertices(){return this._structArray.uint16[this._pos2+25]}get numVerticalIconVertices(){return this._structArray.uint16[this._pos2+26]}get useRuntimeCollisionCircles(){return this._structArray.uint16[this._pos2+27]}get crossTileID(){return this._structArray.uint32[this._pos4+14]}set crossTileID(t){this._structArray.uint32[this._pos4+14]=t}get textOffset0(){return this._structArray.float32[this._pos4+15]}get textOffset1(){return this._structArray.float32[this._pos4+16]}get collisionCircleDiameter(){return this._structArray.float32[this._pos4+17]}get zOffset(){return this._structArray.float32[this._pos4+18]}set zOffset(t){this._structArray.float32[this._pos4+18]=t}get occlusionState(){return this._structArray.float32[this._pos4+19]}set occlusionState(t){this._structArray.float32[this._pos4+19]=t}get occlusionOpacity(){return this._structArray.float32[this._pos4+20]}set occlusionOpacity(t){this._structArray.float32[this._pos4+20]=t}get hasIconTextFit(){return this._structArray.uint8[this._pos1+84]}}pc.prototype.size=88;class fc extends Ql{get(t){return new pc(this,t)}}ba(fc,"SymbolInstanceArray");class mc extends Zl{getoffsetX(t){return this.float32[1*t+0]}}ba(mc,"GlyphOffsetArray");class _c extends $l{getx(t){return this.int16[2*t+0]}gety(t){return this.int16[2*t+1]}}ba(_c,"SymbolLineVertexArray");class gc extends Al{get featureIndex(){return this._structArray.uint32[this._pos4+0]}get sourceLayerIndex(){return this._structArray.uint16[this._pos2+2]}get bucketIndex(){return this._structArray.uint16[this._pos2+3]}get layoutVertexArrayOffset(){return this._structArray.uint16[this._pos2+4]}}gc.prototype.size=12;class yc extends nc{get(t){return new gc(this,t)}}ba(yc,"FeatureIndexArray");class vc extends ql{geta_centroid_pos0(t){return this.uint16[2*t+0]}geta_centroid_pos1(t){return this.uint16[2*t+1]}}ba(vc,"FillExtrusionCentroidArray");const xc=Ll([{name:"a_pos",components:2,type:"Int16"}],4),bc=Ll([{name:"a_pos_3",components:3,type:"Int16"},{name:"a_pos_normal_3",components:3,type:"Int16"}]);class wc{constructor(t=[]){this.segments=t}_prepareSegment(t,e,i,n){let r=this.segments[this.segments.length-1];return t>wc.MAX_VERTEX_ARRAY_LENGTH&&pi(`Max vertices per segment is ${wc.MAX_VERTEX_ARRAY_LENGTH}: bucket requested ${t}`),(!r||r.vertexLength+t>wc.MAX_VERTEX_ARRAY_LENGTH||r.sortKey!==n)&&(r={vertexOffset:e,primitiveOffset:i,vertexLength:0,primitiveLength:0},void 0!==n&&(r.sortKey=n),this.segments.push(r)),r}prepareSegment(t,e,i,n){return this._prepareSegment(t,e.length,i.length,n)}get(){return this.segments}destroy(){for(const t of this.segments)for(const e in t.vaos)t.vaos[e].destroy()}static simpleSegment(t,e,i,n){return new wc([{vertexOffset:t,primitiveOffset:e,vertexLength:i,primitiveLength:n,vaos:{},sortKey:0}])}}function Tc(t,e){return 256*(t=Xe(Math.floor(t),0,255))+Xe(Math.floor(e),0,255)}wc.MAX_VERTEX_ARRAY_LENGTH=Math.pow(2,16)-1,ba(wc,"SegmentVector");const Sc=Ll([{name:"a_pattern",components:4,type:"Uint16"},{name:"a_pixel_ratio",components:1,type:"Float32"}]),Ec=Ll([{name:"a_dash",components:4,type:"Uint16"}]);class Mc{constructor(){this.ids=[],this.uniqueIds=[],this.positions=[],this.indexed=!1}add(t,e,i,n){this.ids.push(Cc(t)),this.positions.push(e,i,n)}eachPosition(t,e){const i=Cc(t);let n=0,r=this.ids.length-1;for(;n>1;this.ids[t]>=i?r=t:n=t+1}for(;this.ids[n]===i;)e(this.positions[3*n],this.positions[3*n+1],this.positions[3*n+2]),n++}static serialize(t,e){const i=new Float64Array(t.ids),n=new Uint32Array(t.positions);return Ac(i,n,0,i.length-1),e&&(e.add(i.buffer),e.add(n.buffer)),{ids:i,positions:n}}static deserialize(t){const e=new Mc;let i;e.ids=t.ids,e.positions=t.positions;for(const t of e.ids)t!==i&&e.uniqueIds.push(t),i=t;return e.indexed=!0,e}}function Cc(t){const e=+t;return!isNaN(e)&&Number.MIN_SAFE_INTEGER>1];let o=i-1,s=n+1;for(;;){do{o++}while(t[o]r);if(o>=s)break;Ic(t,o,s),Ic(e,3*o,3*s),Ic(e,3*o+1,3*s+1),Ic(e,3*o+2,3*s+2)}s-i`u_${t}`)),this.type=i,this.context=n}setUniform(t,e,i,n,r){const o=n.constantOr(this.value);e.set(t,r,o instanceof Un?o.toRenderColor(this.context.lut):o)}getBinding(t,e){return"color"===this.type?new Rc(t):new $c(t)}}class Gc{constructor(t,e){this.uniformNames=e.map((t=>`u_${t}`)),this.pattern=null,this.pixelRatio=1}setConstantPatternPositions(t){this.pixelRatio=t.pixelRatio||1,this.pattern=t.tl.concat(t.br)}setUniform(t,e,i,n,r){const o="u_pattern"===r||"u_dash"===r?this.pattern:"u_pixel_ratio"===r?this.pixelRatio:null;o&&e.set(t,r,o)}getBinding(t,e){return"u_pattern"===e||"u_dash"===e?new zc(t):new $c(t)}}class Zc{constructor(t,e,i,n){this.expression=t,this.type=i,this.maxValue=0,this.paintVertexAttributes=e.map((t=>({name:`a_${t}`,type:"Float32",components:"color"===i?2:1,offset:0}))),this.paintVertexArray=new n}populatePaintArray(t,e,i,n,r,o,s){const a=this.paintVertexArray.length,l=this.expression.evaluate(new Ha(0,{brightness:o}),e,{},r,n,s);this.paintVertexArray.resize(t),this._setPaintValue(a,t,l,this.context)}updatePaintArray(t,e,i,n,r,o,s){const a=this.expression.evaluate({zoom:0,brightness:s},i,n,void 0,r);this._setPaintValue(t,e,a,this.context)}_setPaintValue(t,e,i,n){if("color"===this.type){const r=jc(i.toRenderColor(n.lut));for(let i=t;i`u_${t}_t`)),this.type=i,this.useIntegerZoom=n,this.context=r,this.maxValue=0,this.paintVertexAttributes=e.map((t=>({name:`a_${t}`,type:"Float32",components:"color"===i?4:2,offset:0}))),this.paintVertexArray=new o}populatePaintArray(t,e,i,n,r,o,s){const a=this.expression.evaluate(new Ha(this.context.zoom,{brightness:o}),e,{},r,n,s),l=this.expression.evaluate(new Ha(this.context.zoom+1,{brightness:o}),e,{},r,n,s),c=this.paintVertexArray.length;this.paintVertexArray.resize(t),this._setPaintValue(c,t,a,l,this.context)}updatePaintArray(t,e,i,n,r,o,s){const a=this.expression.evaluate({zoom:this.context.zoom,brightness:s},i,n,void 0,r),l=this.expression.evaluate({zoom:this.context.zoom+1,brightness:s},i,n,void 0,r);this._setPaintValue(t,e,a,l,this.context)}_setPaintValue(t,e,i,n,r){if("color"===this.type){const n=jc(i.toRenderColor(r.lut)),o=jc(i.toRenderColor(r.lut));for(let i=t;i!0){this.binders={},this._buffers=[],this.context=e;const n=[];for(const r in t.paint._values){const o=t.paint.get(r);if(!i(r))continue;if(!(o instanceof tl&&Xs(o.property.specification)))continue;const s=Kc(r,t.type),a=o.value,l=o.property.specification.type,c=!!o.property.useIntegerZoom,d="line-dasharray"===r||r.endsWith("pattern"),u="line-dasharray"===r&&"constant"!==t.layout.get("line-cap").value.kind;if("constant"!==a.kind||u)if("source"===a.kind||u||d){const e=td(r,l,"source");this.binders[r]=d?new Hc(a,s,l,e,t.id):new Zc(a,s,l,e),n.push(`/a_${r}`)}else{const t=td(r,l,"composite");this.binders[r]=new qc(a,s,l,c,e,t),n.push(`/z_${r}`)}else this.binders[r]=d?new Gc(a.value,s):new Vc(a.value,s,l,e),n.push(`/u_${r}`)}this.cacheKey=n.sort().join("")}getMaxValue(t){const e=this.binders[t];return e instanceof Zc||e instanceof qc?e.maxValue:0}populatePaintArrays(t,e,i,n,r,o,s){for(const a in this.binders){const l=this.binders[a];l.context=this.context,(l instanceof Zc||l instanceof qc||l instanceof Hc)&&l.populatePaintArray(t,e,i,n,r,o,s)}}setConstantPatternPositions(t){for(const e in this.binders){const i=this.binders[e];i instanceof Gc&&i.setConstantPatternPositions(t)}}updatePaintArrays(t,e,i,n,r,o,s,a){let l=!1;const c=Object.keys(t),d=0!==c.length,u=d?c:e.uniqueIds;this.context.lut=r.lut;for(const c in this.binders){const h=this.binders[c];if(h.context=this.context,(h instanceof Zc||h instanceof qc||h instanceof Hc)&&(!0===h.expression.isStateDependent||!1===h.expression.isLightConstant)){const p=r.paint.get(c);h.expression=p.value;for(const i of u){const r=t[i.toString()];e.eachPosition(i,((t,e,i)=>{const l=n.feature(t);h.updatePaintArray(e,i,l,r,o,s,a)}))}if(!d)for(const e of i.uniqueIds){const r=t[e.toString()];i.eachPosition(e,((t,e,i)=>{const l=n.feature(t);h.updatePaintArray(e,i,l,r,o,s,a)}))}l=!0}}return l}defines(){const t=[];for(const e in this.binders){const i=this.binders[e];(i instanceof Vc||i instanceof Gc)&&t.push(...i.uniformNames.map((t=>`#define HAS_UNIFORM_${t}`)))}return t}getBinderAttributes(){const t=[];for(const e in this.binders){const i=this.binders[e];if(i instanceof Zc||i instanceof qc||i instanceof Hc)for(let e=0;e!0){this.programConfigurations={};for(const n of t)this.programConfigurations[n.id]=new Wc(n,e,i);this.needsUpload=!1,this._featureMap=new Mc,this._featureMapWithoutIds=new Mc,this._bufferOffset=0,this._idlessCounter=0}populatePaintArrays(t,e,i,n,r,o,s,a){for(const i in this.programConfigurations)this.programConfigurations[i].populatePaintArrays(t,e,n,r,o,s,a);void 0!==e.id?this._featureMap.add(e.id,i,this._bufferOffset,t):(this._featureMapWithoutIds.add(this._idlessCounter,i,this._bufferOffset,t),this._idlessCounter+=1),this._bufferOffset=t,this.needsUpload=!0}updatePaintArrays(t,e,i,n,r,o){for(const s of i)this.needsUpload=this.programConfigurations[s.id].updatePaintArrays(t,this._featureMap,this._featureMapWithoutIds,e,s,n,r,o||0)||this.needsUpload}get(t){return this.programConfigurations[t]}upload(t){if(this.needsUpload){for(const e in this.programConfigurations)this.programConfigurations[e].upload(t);this.needsUpload=!1}}destroy(){for(const t in this.programConfigurations)this.programConfigurations[t].destroy()}}const Xc={"text-opacity":["opacity"],"icon-opacity":["opacity"],"text-occlusion-opacity":["occlusion_opacity"],"icon-occlusion-opacity":["occlusion_opacity"],"text-color":["fill_color"],"icon-color":["fill_color"],"text-emissive-strength":["emissive_strength"],"icon-emissive-strength":["emissive_strength"],"text-halo-color":["halo_color"],"icon-halo-color":["halo_color"],"text-halo-blur":["halo_blur"],"icon-halo-blur":["halo_blur"],"text-halo-width":["halo_width"],"icon-halo-width":["halo_width"],"line-gap-width":["gapwidth"],"line-pattern":["pattern","pixel_ratio"],"fill-pattern":["pattern","pixel_ratio"],"fill-extrusion-pattern":["pattern","pixel_ratio"],"line-dasharray":["dash"]};function Kc(t,e){return Xc[t]||[t.replace(`${e}-`,"").replace(/-/g,"_")]}const Jc={"line-pattern":{source:Fl,composite:Fl},"fill-pattern":{source:Fl,composite:Fl},"fill-extrusion-pattern":{source:Fl,composite:Fl},"line-dasharray":{source:Nl,composite:Nl}},Qc={color:{source:ic,composite:Ol},number:{source:Zl,composite:ic}};function td(t,e,i){const n=Jc[t];return n&&n[i]||Qc[e][i]}ba(Vc,"ConstantBinder"),ba(Gc,"PatternConstantBinder"),ba(Zc,"SourceExpressionBinder"),ba(Hc,"PatternCompositeBinder"),ba(qc,"CompositeExpressionBinder"),ba(Wc,"ProgramConfiguration",{omit:["_buffers"]}),ba(Yc,"ProgramConfigurationSet");const ed=uo/Math.PI/2,id=5,nd=6,rd=16383,od=64,sd=[od,32,16],ad=-ed,ld=ed;function cd(t,e,i,n=ed){return i=Ge(i),[t*Math.sin(i)*n,-e*n,t*Math.cos(i)*n]}function dd(t,e,i){return cd(Math.cos(Ge(t)),Math.sin(Ge(t)),e,i)}const ud=6371008.8,hd=2*Math.PI*ud;class pd{constructor(t,e){if(isNaN(t)||isNaN(e))throw new Error(`Invalid LngLat object: (${t}, ${e})`);if(this.lng=+t,this.lat=+e,this.lat>90||this.lat, lat: }, an object {lon: , lat: }, or an array of [, ]")}}class fd{constructor(t,e){if(t)if(e)this.setSouthWest(t).setNorthEast(e);else if(4===t.length){const e=t;this.setSouthWest([e[0],e[1]]).setNorthEast([e[2],e[3]])}else{const e=t;this.setSouthWest(e[0]).setNorthEast(e[1])}}setNorthEast(t){return this._ne=t instanceof pd?new pd(t.lng,t.lat):pd.convert(t),this}setSouthWest(t){return this._sw=t instanceof pd?new pd(t.lng,t.lat):pd.convert(t),this}extend(t){const e=this._sw,i=this._ne;let n,r;if(t instanceof pd)n=t,r=t;else{if(!(t instanceof fd))return Array.isArray(t)?4===t.length||t.every(Array.isArray)?this.extend(fd.convert(t)):this.extend(pd.convert(t)):"object"==typeof t&&null!==t&&t.hasOwnProperty("lat")&&(t.hasOwnProperty("lon")||t.hasOwnProperty("lng"))?this.extend(pd.convert(t)):this;if(n=t._sw,r=t._ne,!n||!r)return this}return e||i?(e.lng=Math.min(n.lng,e.lng),e.lat=Math.min(n.lat,e.lat),i.lng=Math.max(r.lng,i.lng),i.lat=Math.max(r.lat,i.lat)):(this._sw=new pd(n.lng,n.lat),this._ne=new pd(r.lng,r.lat)),this}getCenter(){return new pd((this._sw.lng+this._ne.lng)/2,(this._sw.lat+this._ne.lat)/2)}getSouthWest(){return this._sw}getNorthEast(){return this._ne}getNorthWest(){return new pd(this.getWest(),this.getNorth())}getSouthEast(){return new pd(this.getEast(),this.getSouth())}getWest(){return this._sw.lng}getSouth(){return this._sw.lat}getEast(){return this._ne.lng}getNorth(){return this._ne.lat}toArray(){return[this._sw.toArray(),this._ne.toArray()]}toString(){return`LngLatBounds(${this._sw.toString()}, ${this._ne.toString()})`}isEmpty(){return!(this._sw&&this._ne)}contains(t){const{lng:e,lat:i}=pd.convert(t);let n=this._sw.lngthis._ne.lng&&(n=this._sw.lng>=e&&e>=this._ne.lng),this._sw.lat0;o--)n=1this.canonical.z?new vd(t,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y):new vd(t,this.wrap,t,this.canonical.x>>e,this.canonical.y>>e)}calculateScaledKey(t,e=!0){if(this.overscaledZ===t&&e)return this.key;if(t>this.canonical.z)return xd(this.wrap*+e,t,this.canonical.z,this.canonical.x,this.canonical.y);{const i=this.canonical.z-t;return xd(this.wrap*+e,t,t,this.canonical.x>>i,this.canonical.y>>i)}}isChildOf(t){if(t.wrap!==this.wrap)return!1;const e=this.canonical.z-t.canonical.z;return 0===t.overscaledZ||t.overscaledZ>e&&t.canonical.y===this.canonical.y>>e}children(t){if(this.overscaledZ>=t)return[new vd(this.overscaledZ+1,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y)];const e=this.canonical.z+1,i=2*this.canonical.x,n=2*this.canonical.y;return[new vd(e,this.wrap,e,i,n),new vd(e,this.wrap,e,i+1,n),new vd(e,this.wrap,e,i,n+1),new vd(e,this.wrap,e,i+1,n+1)]}isLessThan(t){return this.wrapt.wrap)&&(this.overscaledZt.overscaledZ)&&(this.canonical.xt.canonical.x)&&this.canonical.y{let e=t.canonical.x-1,i=t.wrap;return e{let e=t.canonical.x+1,i=t.wrap;return e===1new vd(t.overscaledZ,t.wrap,t.canonical.z,t.canonical.x,(0===t.canonical.y?1new vd(t.overscaledZ,t.wrap,t.canonical.z,t.canonical.x,t.canonical.y===(1=l?(Od(t,e,i,c,d,o,u,a,l),Od(t,c,d,n,r,u,s,a,l)):t.push(s)}function Bd(t,e,i){let n=t[0],r=n.x,o=n.y;e(n);const s=[n];for(let a=1;at.x+1||nt.y+1)&&pi("Geometry exceeds allowed extent, reduce your vector tile buffer size"),t}function Gd(t,e,i){const n=t.loadGeometry(),r=t.extent,o=uo/r;if(e&&i&&i.projection.isReprojectedInTileSpace){const o=1{const i=Ad((e.x+t.x/r)/o),n=Id((e.y+t.y/r)/o),d=c.project(i,n);t.x=(d.x*s-a)*r,t.y=(d.y*s-l)*r};for(let e=0;e=r||i.y=r||(d(i),t.push(i));n[e]=t}}for(const t of n)for(const e of t)Vd(e,o);return n}function Zd(t,e){return{type:t.type,id:t.id,properties:t.properties,geometry:e?Gd(t):[]}}function qd(t,e,i,n,r){t.emplaceBack(2*e+(n+1)/2,2*i+(r+1)/2)}function Hd(t,e,i){const n=16384;t.emplaceBack(e.x,e.y,e.z,i[0]*n,i[1]*n,i[2]*n)}class Wd{constructor(t){this.zoom=t.zoom,this.overscaling=t.overscaling,this.layers=t.layers,this.layerIds=this.layers.map((t=>t.fqid)),this.index=t.index,this.hasPattern=!1,this.projection=t.projection,this.layoutVertexArray=new $l,this.indexArray=new Kl,this.segments=new wc,this.programConfigurations=new Yc(t.layers,{zoom:t.zoom,lut:t.lut}),this.stateDependentLayerIds=this.layers.filter((t=>t.isStateDependent())).map((t=>t.id))}updateFootprints(t,e){}populate(t,e,i,n){const r=this.layers[0],o=[];let s=null;"circle"===r.type&&(s=r.layout.get("circle-sort-key"));for(const{feature:e,id:r,index:a,sourceLayerIndex:l}of t){const t=this.layers[0]._featureFilter.needGeometry,c=Zd(e,t);if(!this.layers[0]._featureFilter.filter(new Ha(this.zoom),c,i))continue;const d=s?s.evaluate(c,{},i):void 0,u={id:r,properties:e.properties,type:e.type,sourceLayerIndex:l,index:a,geometry:t?c.geometry:Gd(e,i,n),patterns:{},sortKey:d};o.push(u)}s&&o.sort(((t,e)=>t.sortKey-e.sortKey));let a=null;"globe"===n.projection.name&&(this.globeExtVertexArray=new Ul,a=n.projection);for(const n of o){const{geometry:r,index:o,sourceLayerIndex:s}=n,l=t[o].feature;this.addFeature(n,r,o,e.availableImages,i,a,e.brightness),e.featureIndex.insert(l,r,o,s,this.index)}}update(t,e,i,n,r){const o=0!==Object.keys(t).length;o&&!this.stateDependentLayers.length||this.programConfigurations.updatePaintArrays(t,e,o?this.stateDependentLayers:this.layers,i,n,r)}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(t){this.uploaded||(this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,xc.members),this.indexBuffer=t.createIndexBuffer(this.indexArray),this.globeExtVertexArray&&(this.globeExtVertexBuffer=t.createVertexBuffer(this.globeExtVertexArray,bc.members))),this.programConfigurations.upload(t),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy(),this.globeExtVertexBuffer&&this.globeExtVertexBuffer.destroy())}addFeature(t,e,i,n,r,o,s){for(const i of e)for(const e of i){const i=e.x,n=e.y;if(i=uo||n=uo)continue;if(o){const t=o.projectTilePoint(i,n,r),e=o.upVector(r,i,n),s=this.globeExtVertexArray;Hd(s,t,e),Hd(s,t,e),Hd(s,t,e),Hd(s,t,e)}const s=this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray,t.sortKey),a=s.vertexLength;qd(this.layoutVertexArray,i,n,-1,-1),qd(this.layoutVertexArray,i,n,1,-1),qd(this.layoutVertexArray,i,n,1,1),qd(this.layoutVertexArray,i,n,-1,1),this.indexArray.emplaceBack(a,a+1,a+2),this.indexArray.emplaceBack(a,a+2,a+3),s.vertexLength+=4,s.primitiveLength+=2}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,t,i,{},n,r,s)}}function Yd(t,e){for(let i=0;i1){if(Qd(t,e))return!0;for(let n=0;n1?i:i.sub(e)._mult(r)._add(e))}function nu(t,e){let i,n,r,o=!1;for(let s=0;se.y!=r.y>e.y&&e.xe.y!=s.y>e.y&&e.x=o.x&&r>=o.y)return!0;const o=[new Ue(e,i),new Ue(e,r),new Ue(n,r),new Ue(n,i)];if(t.length>2)for(const e of o)if(ru(t,e))return!0;for(let e=0;er.x&&e.x>r.x||t.yr.y&&e.y>r.y)return!1;const o=fi(t,e,i[0]);return o!==fi(t,e,i[1])||o!==fi(t,e,i[2])||o!==fi(t,e,i[3])}function au(t,e,i,n,r,o){let s=e.y-t.y,a=t.x-e.x;if(o=o||0){const t=s*s+a*a;if(0===t)return!0;const e=Math.sqrt(t);s/=e,a/=e}return!((i.x-t.x)*s+(i.y-t.y)*a-o=0;if(0===s)return 0;s!==i.length&&(n=!1)}return n?2:1}function vu(t,e){for(const i of t.projections){const n=gu(e,t.points[0],i.axis);if(i.projection[1]n[1])return 0}return 1}function xu(e,i){let n=0;const r=[0,0,0,0];for(let o=0;o=0&&n++;return n}class bu{constructor(e,i){this.points=e||new Array(8).fill([0,0,0]),this.planes=i||new Array(6).fill([0,0,0,0]),this.bounds=wu.fromPoints(this.points),this.projections=[],this.frustumEdges=[t._.sub([],this.points[2],this.points[3]),t._.sub([],this.points[0],this.points[3]),t._.sub([],this.points[4],this.points[0]),t._.sub([],this.points[5],this.points[1]),t._.sub([],this.points[6],this.points[2]),t._.sub([],this.points[7],this.points[3])];for(const t of this.frustumEdges){const e=[0,-t[2],t[1]],i=[t[2],0,-t[0]];this.projections.push({axis:e,projection:gu(this.points,this.points[0],e)}),this.projections.push({axis:i,projection:gu(this.points,this.points[0],i)})}}static fromInvProjectionMatrix(e,i,n,r){const o=Math.pow(2,n),s=[[-1,1,-1,1],[1,1,-1,1],[1,-1,-1,1],[-1,-1,-1,1],[-1,1,1,1],[1,1,1,1],[1,-1,1,1],[-1,-1,1,1]].map((n=>{const s=t.aA.transformMat4([],n,e),a=1/s[3]/i*o;return t.aA.mul(s,s,[a,a,r?1/s[3]:a,a])})),a=[[0,1,2],[6,5,4],[0,3,7],[2,1,5],[3,2,6],[0,4,5]].map((e=>{const i=t._.sub([],s[e[0]],s[e[1]]),n=t._.sub([],s[e[2]],s[e[1]]),r=t._.normalize([],t._.cross([],i,n)),o=-t._.dot(r,s[e[1]]);return r.concat(o)})),l=[];for(let t=0;ta[1]||a[0]>s[1])return 0}return 1}}class wu{static fromPoints(e){const i=[1/0,1/0,1/0],n=[-1/0,-1/0,-1/0];for(const r of e)t._.min(i,i,r),t._.max(n,n,r);return new wu(i,n)}static fromTileIdAndHeight(t,e,i){const n=1t.max[e]||t.min[e]>this.max[e])return!1;return!0}intersectsAabbXY(t){return!(this.min[0]>t.max[0]||t.min[0]>this.max[0]||this.min[1]>t.max[1]||t.min[1]>this.max[1])}encapsulate(t){for(let e=0;e1?null:function(t,e,i,n){const r=Math.sin(i);return t*(Math.sin((1-n)*i)/r)+e*(Math.sin(n*i)/r)}(t.a[e],t.b[e],t.angle,Xe(i,0,1))+t.center[e]}function $u(t){if(t.z0){for(const e of l)t._.min(u,u,e),t._.max(d,d,e);return new wu(u,d)}const h=[s[12]*o,s[13]*o,s[14]*o],p=a.getCenter(),f=Xe(e.center.lat,-Pd,Pd),m=Xe(p.lat,-Pd,Pd),_=Ed(e.center.lng),g=Md(f);let y=_-Ed(p.lng);const v=g-Md(m);y>.5?y-=1:yMath.abs(v))x=y>=0?1:3;else{x=v>=0?0:2;const e=[s[4]*o,s[5]*o,s[6]*o],i=-Math.sin(Ge(v>=0?a.getSouth():a.getNorth()))*ed;t._.scaleAndAdd(h,h,e,i)}const b=l[x],w=l[(x+1)%4],T=new Lu(b,w,h),S=[Pu(T,0)||b[0],Pu(T,1)||b[1],Pu(T,2)||b[2]],E=Hu(e.zoom);if(E>0){const r=function({x:t,y:e,z:i},n,r,o,s){const a=1/(1.5?h=-1:pMath.PI/2*1.01}const Xu=Ge(85),Ku=Math.cos(Xu),Ju=Math.sin(Xu),Qu=t.ad.create(),th=t=>{const e=[];return"map"===t.paint.get("circle-pitch-alignment")&&e.push("PITCH_WITH_MAP"),"map"===t.paint.get("circle-pitch-scale")&&e.push("SCALE_WITH_MAP"),e};function eh(e,i,n,r,o,s,a,l,c){if(s&&e.queryGeometry.isAboveHorizon)return!1;s&&(c*=e.pixelToTileUnitsFactor);const d=e.tileID.canonical,u=n.projection.upVectorScale(d,n.center.lat,n.worldSize).metersToTile;for(const h of i)for(const i of h){const h=i.add(l),p=o&&n.elevation?n.elevation.exaggeration()*o.getElevationAt(h.x,h.y,!0):0,f=n.projection.projectTilePoint(h.x,h.y,d);if(p>0){const t=n.projection.upVector(d,h.x,h.y);f.x+=t[0]*u*p,f.y+=t[1]*u*p,f.z+=t[2]*u*p}const m=s?h:ih(f.x,f.y,f.z,r),_=s?e.tilespaceRays.map((t=>oh(t,p))):e.queryGeometry.screenGeometry,g=t.aA.transformMat4([],[f.x,f.y,f.z,1],r);if(!a&&s?c*=g[3]/n.cameraToCenterDistance:a&&!s&&(c*=n.cameraToCenterDistance/g[3]),s){const t=Id((i.y/uo+d.y)/(1t.width||r.height>t.height||i.x>t.width-r.width||i.y>t.height-r.height)throw new RangeError("out of range source coordinates for image copy");if(r.width>e.width||r.height>e.height||n.x>e.width-r.width||n.y>e.height-r.height)throw new RangeError("out of range destination coordinates for image copy");const l=t.data,c=e.data,d=4===o&&a;for(let a=0;a{e[t.evaluationKey]=o;const s=t.expression.evaluate(e);s&&(r.data[i+n+0]=Math.floor(255*s.r/s.a),r.data[i+n+1]=Math.floor(255*s.g/s.a),r.data[i+n+2]=Math.floor(255*s.b/s.a),r.data[i+n+3]=Math.floor(255*s.a))};if(t.clips)for(let e=0,r=0;e80*i){a=1/0,l=1/0;let e=-1/0,n=-1/0;for(let o=i;oe&&(e=i),r>n&&(n=r)}c=Math.max(e-a,n-l),c=0!==c?32767/c:0}return Th(o,s,i,a,l,c,0),s}function bh(t,e,i,n,r){let o;if(r===function(t,e,i,n){let r=0;for(let o=e,s=i-n;o0)for(let r=e;r=e;r-=n)o=jh(r/n|0,t[r],t[r+1],o);return o&&Rh(o,o.next)&&(Vh(o),o=o.next),o}function wh(t,e){if(!t)return t;e||(e=t);let i,n=t;do{if(i=!1,n.steiner||!Rh(n,n.next)&&0!==zh(n.prev,n,n.next))n=n.next;else{if(Vh(n),n=e=n.prev,n===n.next)break;i=!0}}while(i||n!==e);return e}function Th(t,e,i,n,r,o,s){if(!t)return;!s&&o&&function(t,e,i,n){let r=t;do{0===r.z&&(r.z=Ph(r.x,r.y,e,i,n)),r.prevZ=r.prev,r.nextZ=r.next,r=r.next}while(r!==t);r.prevZ.nextZ=null,r.prevZ=null,function(t){let e,i=1;do{let n,r=t;t=null;let o=null;for(e=0;r;){e++;let s=r,a=0;for(let t=0;t0||l>0&&s;)0!==a&&(0===l||!s||r.z1)}(r)}(t,n,r,o);let a=t;for(;t.prev!==t.next;){const l=t.prev,c=t.next;if(o?Eh(t,n,r,o):Sh(t))e.push(l.i,t.i,c.i),Vh(t),t=c.next,a=c.next;else if((t=c)===a){s?1===s?Th(t=Mh(wh(t),e),e,i,n,r,o,2):2===s&&Ch(t,e,i,n,r,o):Th(wh(t),e,i,n,r,o,1);break}}}function Sh(t){const e=t.prev,i=t,n=t.next;if(zh(e,i,n)>=0)return!1;const r=e.x,o=i.x,s=n.x,a=e.y,l=i.y,c=n.y,d=ro?r>s?r:s:o>s?o:s,p=a>l?a>c?a:c:l>c?l:c;let f=n.next;for(;f!==e;){if(f.x>=d&&f.x=u&&f.y=0)return!1;f=f.next}return!0}function Eh(t,e,i,n){const r=t.prev,o=t,s=t.next;if(zh(r,o,s)>=0)return!1;const a=r.x,l=o.x,c=s.x,d=r.y,u=o.y,h=s.y,p=al?a>c?a:c:l>c?l:c,_=d>u?d>h?d:h:u>h?u:h,g=Ph(p,f,e,i,n),y=Ph(m,_,e,i,n);let v=t.prevZ,x=t.nextZ;for(;v&&v.z>=g&&x&&x.z=p&&v.x=f&&v.y=0)return!1;if(v=v.prevZ,x.x>=p&&x.x=f&&x.y=0)return!1;x=x.nextZ}for(;v&&v.z>=g;){if(v.x>=p&&v.x=f&&v.y=0)return!1;v=v.prevZ}for(;x&&x.z=p&&x.x=f&&x.y=0)return!1;x=x.nextZ}return!0}function Mh(t,e){let i=t;do{const n=i.prev,r=i.next.next;!Rh(n,r)&&Oh(n,i,i.next,r)&&Nh(n,r)&&Nh(r,n)&&(e.push(n.i,i.i,r.i),Vh(i),Vh(i.next),i=t=r),i=i.next}while(i!==t);return wh(i)}function Ch(t,e,i,n,r,o){let s=t;do{let t=s.next.next;for(;t!==s.prev;){if(s.i!==t.i&&Dh(s,t)){let a=Uh(s,t);return s=wh(s,s.next),a=wh(a,a.next),Th(s,e,i,n,r,o,0),void Th(a,e,i,n,r,o,0)}t=t.next}s=s.next}while(s!==t)}function Ah(t,e){return t.x-e.x}function Ih(t,e){const i=function(t,e){let i=e;const n=t.x,r=t.y;let o,s=-1/0;do{if(r=i.next.y&&i.next.y!==i.y){const t=i.x+(r-i.y)*(i.next.x-i.x)/(i.next.y-i.y);if(ts&&(s=t,o=i.x=i.x&&i.x>=l&&n!==i.x&&kh(ro.x||i.x===o.x&&Lh(o,i)))&&(o=i,d=e)}i=i.next}while(i!==a);return o}(t,e);if(!i)return e;const n=Uh(i,t);return wh(n,n.next),wh(i,i.next)}function Lh(t,e){return zh(t.prev,t,e.prev)=(t-s)*(o-a)&&(t-s)*(n-a)>=(i-s)*(e-a)&&(i-s)*(o-a)>=(r-s)*(n-a)}function Dh(t,e){return t.next.i!==e.i&&t.prev.i!==e.i&&!function(t,e){let i=t;do{if(i.i!==t.i&&i.next.i!==t.i&&i.i!==e.i&&i.next.i!==e.i&&Oh(i,i.next,t,e))return!0;i=i.next}while(i!==t);return!1}(t,e)&&(Nh(t,e)&&Nh(e,t)&&function(t,e){let i=t,n=!1;const r=(t.x+e.x)/2,o=(t.y+e.y)/2;do{i.y>o!=i.next.y>o&&i.next.y!==i.y&&r0&&zh(e.prev,e,e.next)>0)}function zh(t,e,i){return(e.y-t.y)*(i.x-e.x)-(e.x-t.x)*(i.y-e.y)}function Rh(t,e){return t.x===e.x&&t.y===e.y}function Oh(t,e,i,n){const r=Fh(zh(t,e,i)),o=Fh(zh(t,e,n)),s=Fh(zh(i,n,t)),a=Fh(zh(i,n,e));return r!==o&&s!==a||!(0!==r||!Bh(t,i,e))||!(0!==o||!Bh(t,n,e))||!(0!==s||!Bh(i,t,n))||!(0!==a||!Bh(i,e,n))}function Bh(t,e,i){return e.x=Math.min(t.x,i.x)&&e.y=Math.min(t.y,i.y)}function Fh(t){return t>0?1:t=0&&zh(t,t.prev,e)>=0:zh(t,e,t.prev)1)for(let t=0;tt.fqid)),this.index=t.index,this.hasPattern=!1,this.patternFeatures=[],this.layoutVertexArray=new $l,this.indexArray=new Kl,this.indexArray2=new ql,this.programConfigurations=new Yc(t.layers,{zoom:t.zoom,lut:t.lut}),this.segments=new wc,this.segments2=new wc,this.stateDependentLayerIds=this.layers.filter((t=>t.isStateDependent())).map((t=>t.id)),this.projection=t.projection}updateFootprints(t,e){}populate(t,e,i,n){this.hasPattern=Hh("fill",this.layers,e);const r=this.layers[0].layout.get("fill-sort-key"),o=[];for(const{feature:s,id:a,index:l,sourceLayerIndex:c}of t){const t=this.layers[0]._featureFilter.needGeometry,d=Zd(s,t);if(!this.layers[0]._featureFilter.filter(new Ha(this.zoom),d,i))continue;const u=r?r.evaluate(d,{},i,e.availableImages):void 0,h={id:a,properties:s.properties,type:s.type,sourceLayerIndex:c,index:l,geometry:t?d.geometry:Gd(s,i,n),patterns:{},sortKey:u};o.push(h)}r&&o.sort(((t,e)=>t.sortKey-e.sortKey));for(const n of o){const{geometry:r,index:o,sourceLayerIndex:s}=n;if(this.hasPattern){const t=Wh("fill",this.layers,n,this.zoom,e);this.patternFeatures.push(t)}else this.addFeature(n,r,o,i,{},e.availableImages,e.brightness);e.featureIndex.insert(t[o].feature,r,o,s,this.index)}}update(t,e,i,n,r){const o=0!==Object.keys(t).length;o&&!this.stateDependentLayers.length||this.programConfigurations.updatePaintArrays(t,e,o?this.stateDependentLayers:this.layers,i,n,r)}addFeatures(t,e,i,n,r,o){for(const t of this.patternFeatures)this.addFeature(t,t.geometry,t.index,e,i,n,o)}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(t){this.uploaded||(this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,vh),this.indexBuffer=t.createIndexBuffer(this.indexArray),this.indexBuffer2=t.createIndexBuffer(this.indexArray2)),this.programConfigurations.upload(t),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.indexBuffer2.destroy(),this.programConfigurations.destroy(),this.segments.destroy(),this.segments2.destroy())}addFeature(t,e,i,n,r,o=[],s){for(const t of Zh(e,500)){let e=0;for(const i of t)e+=i.length;const i=this.segments.prepareSegment(e,this.layoutVertexArray,this.indexArray),n=i.vertexLength,r=[],o=[];for(const e of t){if(0===e.length)continue;e!==t[0]&&o.push(r.length/2);const i=this.segments2.prepareSegment(e.length,this.layoutVertexArray,this.indexArray2),n=i.vertexLength;this.layoutVertexArray.emplaceBack(e[0].x,e[0].y),this.indexArray2.emplaceBack(n+e.length-1,n),r.push(e[0].x),r.push(e[0].y);for(let t=1;tt.cellIdx-e.cellIdx||t.triIdx-e.triIdx));let c=0;for(;cthis.max.x||this.min.x>t.x||t.y>this.max.y||this.min.y>t.y)return;const i=Qh(t.x-this.min.x,this.xScale,this.cellsX),n=Qh(t.y-this.min.y,this.yScale,this.cellsY),r=this.cells[n*this.cellsX+i];if(r){this._lazyInitLookup();for(let t=0;tthis.max.x||this.min.x>e.x)return;if(t.y>this.max.y||this.min.y>e.y)return;this._lazyInitLookup();const n=Qh(t.x-this.min.x,this.xScale,this.cellsX),r=Qh(e.x-this.min.x,this.xScale,this.cellsX),o=Qh(t.y-this.min.y,this.yScale,this.cellsY),s=Qh(e.y-this.min.y,this.yScale,this.cellsY);for(let t=o;tt.fqid)),this.index=t.index,this.hasPattern=!1,this.stateDependentLayerIds=this.layers.filter((t=>t.isStateDependent())).map((t=>t.id)),this.footprints=[]}updateFootprints(t,e){for(const i of this.footprints)e.push({footprint:i,id:t})}populate(t,e,i,n){const r=[];for(const{feature:e,id:o,index:s,sourceLayerIndex:a}of t){const t=this.layers[0]._featureFilter.needGeometry,l=Zd(e,t);if(!this.layers[0]._featureFilter.filter(new Ha(this.zoom),l,i))continue;const c={id:o,properties:e.properties,type:e.type,sourceLayerIndex:a,index:s,geometry:t?l.geometry:Gd(e,i,n),patterns:{}};r.push(c)}for(const n of r){const{geometry:r,index:o,sourceLayerIndex:s}=n;this.addFeature(n,r,o,i,{},e.availableImages,e.brightness),e.featureIndex.insert(t[o].feature,r,o,s,this.index)}}isEmpty(){return 0===this.footprints.length}uploadPending(){return!1}upload(t){}update(t,e,i,n,r){}destroy(){}addFeature(t,e,i,n,r,o=[],s){for(const t of Zh(e,2)){const e=[],i=[],n=[],r=new Ue(1/0,1/0),o=new Ue(-1/0,-1/0);for(const s of t)if(0!==s.length){s!==t[0]&&n.push(i.length/2);for(let t=0;t>3}if(r--,1===n||2===n)o+=t.readSVarint(),s+=t.readSVarint(),1===n&&(e&&a.push(e),e=[]),e.push(new dp(o,s));else{if(7!==n)throw new Error("unknown command "+n);e&&e.push(e[0].clone())}}return e&&a.push(e),a},hp.prototype.bbox=function(){var t=this._pbf;t.pos=this._geometry;for(var e=t.readVarint()+t.pos,i=1,n=0,r=0,o=0,s=1/0,a=-1/0,l=1/0,c=-1/0;t.pos>3}if(n--,1===i||2===i)(r+=t.readSVarint())a&&(a=r),(o+=t.readSVarint())c&&(c=o);else if(7!==i)throw new Error("unknown command "+i)}return[s,l,a,c]},hp.prototype.toGeoJSON=function(t,e,i){var n,r,o=this.extent*Math.pow(2,i),s=this.extent*t,a=this.extent*e,l=this.loadGeometry(),c=hp.types[this.type];function d(t){for(var e=0;e>3;e=1===n?t.readString():2===n?t.readFloat():3===n?t.readDouble():4===n?t.readVarint64():5===n?t.readVarint():6===n?t.readSVarint():7===n?t.readBoolean():null}return e}(i))}gp.prototype.feature=function(t){if(t=this._features.length)throw new Error("feature index out of bounds");this._pbf.pos=this._features[t];var e=this._pbf.readVarint()+this._pbf.pos;return new mp(this._pbf,e,this.extent,this._keys,this._values)};var vp=_p;function xp(t,e,i){if(3===t){var n=new vp(i,i.readVarint()+i.pos);n.length&&(e[n.name]=n)}}var bp=cp.VectorTile=function(t,e){this.layers=t.readFields(xp,{},e)},wp=cp.VectorTileFeature=up;cp.VectorTileLayer=_p;class Tp extends Ue{constructor(t,e,i){super(t,e),this.z=i}}class Sp extends Tp{constructor(t,e,i,n){super(t,e,i),this.w=n}}function Ep(t,e,i,n){const r=[],o=0===n?(t,e,i,n,r,o)=>{t.push(new Ue(o,i+(o-e)/(n-e)*(r-i)))}:(t,e,i,n,r,o)=>{t.push(new Ue(e+(o-i)/(r-i)*(n-e),o))};for(const s of t){const t=[];for(const r of s){if(r.lengthe&&o(s,a,l,c,d,e):u>i?h=e&&o(s,a,l,c,d,e),h>i&&u=e&&l=s[i]&&(n=e,s=t),n[i]r&&Mp(n,s,i,r),n[i]o&&Mp(s,n,i,o)}}function Ap(t,e){return t.x-e.x||t.y-e.y}function Ip(t,e){return 0===Ap(t.min,e.min)&&0===Ap(t.max,e.max)}function Lp(t,e){return!(t.min.x>e.max.x||t.max.xe.max.y||t.max.ynew Ue((t.x+o.x*uo)*a-s.x*uo,(t.y+o.y*uo)*a-s.y*uo)))}return Dp(i,r,t.indices,0,t.indices.length,0,0)}function Rp(t,e,i,n){const r=Math.pow(2,n.z-i.z);return new Ue((t+i.x*uo)*r-n.x*uo,(e+i.y*uo)*r-n.y*uo)}function Op(t,e){const i=[];e.footprint.grid.queryPoint(t,i);const n=e.footprint.indices,r=e.footprint.vertices;for(let e=0;ee[s])return null}else{const a=1/n[s];let l=(t[s]-i[s])*a,c=(e[s]-i[s])*a;if(l>c){const t=l;l=c,c=t}if(l>r&&(r=l),co)return null}return r}function Np(t,e,i,n,r,o,s,a,l,c,d){const u=n-t,h=r-e,p=o-i,f=s-t,m=a-e,_=l-i,g=d[1]*_-d[2]*m,y=d[2]*f-d[0]*_,v=d[0]*m-d[1]*f,x=u*g+h*y+p*v;if(Math.abs(x)1)return null;const M=T*p-S*h,C=S*u-w*p,A=w*h-T*u,I=(d[0]*M+d[1]*C+d[2]*A)*b;return I1?null:(f*M+m*C+_*A)*b}function Up(t,e,i){return(t-e)/(i-e)}function jp(t,e,i,n,r,o,s,a,l){const c=1{const o=n?1:0,s=(t+1)*i-o,a=e*i,l=(e+1)*i-o;r[0]=t*i,r[1]=a,r[2]=s,r[3]=l};let s=new Bp(n);const a=[];for(let e=0;e=1;n/=2){const t=i[i.length-1];s=new Bp(n);for(let e=0;e0;){const{idx:l,t:f,nodex:m,nodey:_,depth:g}=p.pop();if(this.leaves[l]){jp(m,_,g,e,i,n,r,u,h);const l=1=e[2])return f}continue}let y=0;for(let t=0;t=c[d[n]]&&(d.splice(n,0,t),i=!0);i||(d[y]=t),y++}}for(let t=0;t=this.dim+1||e=this.dim+1)throw new RangeError("out of range source coordinates for DEM data");return(e+1)*this.stride+(t+1)}static pack(t,e){const i=[0,0,0,0],n=Yp.getUnpackVector(e);let r=Math.floor((t+n[3])/n[2]);return i[2]=r%256,r=Math.floor(r/256),i[1]=r%256,r=Math.floor(r/256),i[0]=r,i}getPixels(){return new hh({width:this.stride,height:this.stride},this.pixels)}backfillBorder(t,e,i){if(this.dim!==t.dim)throw new Error("dem dimension mismatch");let n=e*this.dim,r=e*this.dim+this.dim,o=i*this.dim,s=i*this.dim+this.dim;switch(e){case-1:n=r-1;break;case 1:r=n+1}switch(i){case-1:o=s-1;break;case 1:s=o+1}const a=-e*this.dim,l=-i*this.dim;for(let e=o;et.max.x&&(t.max.x=e.x,n=!0),e.yt.max.y&&(t.max.y=e.y,n=!0),((0===e.x||e.x===uo)&&e.x===i.x)!=((0===e.y||e.y===uo)&&e.y===i.y)&&this.processBorderOverlap(e,i),n&&this.checkBorderIntersection(e,i)}checkBorderIntersection(t,e){e.xuo!=t.x>uo&&this.addBorderIntersection(1,Vn(e.y,t.y,(uo-e.x)/(t.x-e.x))),e.yuo!=t.y>uo&&this.addBorderIntersection(3,Vn(e.x,t.x,(uo-e.y)/(t.y-e.y)))}addBorderIntersection(t,e){this.borders||(this.borders=[[Number.MAX_VALUE,-Number.MAX_VALUE],[Number.MAX_VALUE,-Number.MAX_VALUE],[Number.MAX_VALUE,-Number.MAX_VALUE],[Number.MAX_VALUE,-Number.MAX_VALUE]]);const i=this.borders[t];ei[1]&&(i[1]=e)}processBorderOverlap(t,e){if(t.x===e.x){if(t.y===e.y)return;const i=0===t.x?0:1;this.addBorderIntersection(i,e.y),this.addBorderIntersection(i,t.y)}else{const i=0===t.y?2:3;this.addBorderIntersection(i,e.x),this.addBorderIntersection(i,t.x)}}centroid(){return 0===this.accCount?new Ue(0,0):new Ue(Math.floor(Math.max(0,this.acc.x)/this.accCount),Math.floor(Math.max(0,this.acc.y)/this.accCount))}intersectsCount(){return this.borders?this.borders.reduce(((t,e)=>t+ +(e[0]!==Number.MAX_VALUE)),0):0}}function hf(t,e){const i=t.add(e)._unit(),n=Xe(t.x*i.x+t.y*i.y,-1,1);var r,o,s;return r=Math.acos(n),Math.min(4,Math.max(-4,Math.tan(r)))/4*nf*((o=t).x*(s=e).y-o.y*s.xt.xt.x>uo,t=>t.yt.y>uo];function ff(t,e,i,n){const r=[4];if(0===n)return r;i._mult(n);const o=t.sub(i),s=e.sub(i),a=[t,e,o,s];for(let t=0;ttf.includes(t))),this._segments=new wc,this.hiddenByLandmarkVertexArray=new lc,this._segmentToGroundQuads={},this._segmentToGroundQuads[0]=[],this._segmentToRegionTriCounts={},this._segmentToRegionTriCounts[0]=[0,0,0,0,0],this.regionSegments={},this.regionSegments[4]=new wc}getDefaultSegment(){return this.regionSegments[4]}hasData(){return 0!==this.vertexArray.length}addData(t,e,i,n=!1){const r=t.length;if(r>2){let o=Math.max(0,this._segments.get().length-1);const s=this._segments._prepareSegment(4*r,this.vertexArray.length,2*this._segmentToGroundQuads[o].length);let a;o!==this._segments.get().length-1&&(o++,this._segmentToGroundQuads[o]=[],this._segmentToRegionTriCounts[o]=[0,0,0,0,0]);{const e=t[0],i=t[1];a=hf(e.sub(t[r-1])._perp()._unit(),i.sub(e)._perp()._unit())}for(let l=0;lt.region-e.region));for(let i=0;it+e),0);let o=0;for(let t=0;t0?this.hiddenByLandmarkVertexBuffer=t.createVertexBuffer(this.hiddenByLandmarkVertexArray,sp.members,!0):this.hiddenByLandmarkVertexBuffer&&this.hiddenByLandmarkVertexBuffer.updateData(this.hiddenByLandmarkVertexArray),this._needsHiddenByLandmarkUpdate=!1)}destroy(){if(this.vertexBuffer){this.vertexBuffer.destroy(),this.indexBuffer.destroy(),this.hiddenByLandmarkVertexBuffer&&this.hiddenByLandmarkVertexBuffer.destroy(),this._segments&&this._segments.destroy(),this.programConfigurations.destroy();for(let t=0;tt.fqid)),this.index=t.index,this.hasPattern=!1,this.edgeRadius=0,this.projection=t.projection,this.activeReplacements=[],this.replacementUpdateTime=0,this.centroidData=[],this.footprintIndices=new Kl,this.footprintVertices=new $l,this.footprintSegments=[],this.layoutVertexArray=new Dl,this.centroidVertexArray=new vc,this.indexArray=new Kl,this.programConfigurations=new Yc(t.layers,{zoom:t.zoom,lut:t.lut},(t=>Qp.includes(t))),this.segments=new wc,this.stateDependentLayerIds=this.layers.filter((t=>t.isStateDependent())).map((t=>t.id)),this.groundEffect=new mf(t),this.maxHeight=0,this.partLookup={},this.triangleSubSegments=[],this.polygonSegments=[]}updateFootprints(t,e){}populate(t,e,i,n){this.features=[],this.hasPattern=Hh("fill-extrusion",this.layers,e),this.featuresOnBorder=[],this.borderFeatureIndices=[[],[],[],[]],this.borderDoneWithNeighborZ=[-1,-1,-1,-1],this.tileToMeter=zd(i),this.edgeRadius=this.layers[0].layout.get("fill-extrusion-edge-radius")/this.tileToMeter;for(const{feature:r,id:o,index:s,sourceLayerIndex:a}of t){const t=this.layers[0]._featureFilter.needGeometry,l=Zd(r,t);if(!this.layers[0]._featureFilter.filter(new Ha(this.zoom),l,i))continue;const c={id:o,sourceLayerIndex:a,index:s,geometry:t?l.geometry:Gd(r,i,n),properties:r.properties,type:r.type,patterns:{}},d=this.layoutVertexArray.length;this.hasPattern?this.features.push(Wh("fill-extrusion",this.layers,c,this.zoom,e)):this.addFeature(c,c.geometry,s,i,{},e.availableImages,n,e.brightness),e.featureIndex.insert(r,c.geometry,s,a,this.index,d)}this.sortBorders(),"mercator"===this.projection.name&&this.splitToSubtiles(),this.groundEffect.prepareBorderSegments(),this.polygonSegments.length=0}addFeatures(t,e,i,n,r,o){for(const t of this.features){const{geometry:s}=t;this.addFeature(t,s,t.index,e,i,n,r,o)}this.sortBorders(),"mercator"===this.projection.name&&this.splitToSubtiles()}update(t,e,i,n,r){const o=0!==Object.keys(t).length;if(o&&!this.stateDependentLayers.length)return;const s=o?this.stateDependentLayers:this.layers;this.programConfigurations.updatePaintArrays(t,e,s,i,n,r),this.groundEffect.update(t,e,s,i,n,r)}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload||this.groundEffect.programConfigurations.needsUpload}upload(t){this.uploaded||(this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,lp),this.indexBuffer=t.createIndexBuffer(this.indexArray),this.layoutVertexExtArray&&(this.layoutVertexExtBuffer=t.createVertexBuffer(this.layoutVertexExtArray,ap.members,!0)),this.groundEffect.upload(t)),this.groundEffect.uploadPaintProperties(t),this.programConfigurations.upload(t),this.uploaded=!0}uploadCentroid(t){this.groundEffect.uploadHiddenByLandmark(t),this.needsCentroidUpdate&&(!this.centroidVertexBuffer&&this.centroidVertexArray.length>0?this.centroidVertexBuffer=t.createVertexBuffer(this.centroidVertexArray,op.members,!0):this.centroidVertexBuffer&&this.centroidVertexBuffer.updateData(this.centroidVertexArray),this.needsCentroidUpdate=!1)}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.centroidVertexBuffer&&this.centroidVertexBuffer.destroy(),this.layoutVertexExtBuffer&&this.layoutVertexExtBuffer.destroy(),this.groundEffect.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy())}addFeature(t,e,i,n,r,o,s,a){const l=this.layers[0].paint.get("fill-extrusion-flood-light-ground-radius").evaluate(t,{})/this.tileToMeter,c=[new Ue(0,0),new Ue(uo,uo)],d=s.projection,u="globe"===d.name,h="Polygon"===Jp[t.type],p=new uf;p.centroidDataIndex=this.centroidData.length;const f=new df,m=this.layers[0].paint.get("fill-extrusion-base").evaluate(t,{},n)=0;t--){const e=g[t];(0===e.length||(y=e[0]).every((t=>t.xt.x>=uo))||y.every((t=>t.yt.y>=uo)))&&g.splice(t,1)}var y;let v;if(u)v=Ef(g,c,n);else{v=[];for(const t of g)v.push({polygon:t,bounds:c})}const x=h?this.edgeRadius:0,b=x>0&&this.zoom{if(0===t.length)return!1;const i=t[t.length-1];return e.x===i.x&&e.y===i.y};for(const{polygon:t,bounds:e}of v){let i=0,r=0;for(const e of t)h&&!e[0].equals(e[e.length-1])&&e.push(e[0]),r+=h?e.length-1:e.length;const o=this.segments.prepareSegment((h?5:4)*r,this.layoutVertexArray,this.indexArray);f.footprintSegIdx4&&wf(s[s.length-2],s[0],s[1]),c=x?yf(s[s.length-2],s[0],s[1],x):0;const _=[];let g,y,v;y=s[1].sub(s[0])._perp()._unit();let b=!0;for(let t=1,r=0;t0?1:0,C=l.dist(h);if(r+C>32768&&(r=0),x){v=T.sub(h)._perp()._unit();let t=vf(l,h,T,gf(y,v),x);isNaN(t)&&(t=0);const e=h.sub(l)._unit();l=l.add(e.mult(c))._round(),h=h.add(e.mult(-t))._round(),c=t,y=v,m&&this.zoom>=17&&(w(_,l)||_.push(l),w(_,h)||_.push(h))}const A=o.vertexLength,I=s.length>4&&wf(l,h,T);let L=Tf(r,a,b);if(sf(this.layoutVertexArray,l.x,l.y,E,M,0,0,L),sf(this.layoutVertexArray,l.x,l.y,E,M,0,1,L),r+=C,L=Tf(r,I,!b),a=I,sf(this.layoutVertexArray,h.x,h.y,E,M,0,0,L),sf(this.layoutVertexArray,h.x,h.y,E,M,0,1,L),o.vertexLength+=4,this.indexArray.emplaceBack(A+0,A+1,A+2),this.indexArray.emplaceBack(A+1,A+3,A+2),o.primitiveLength+=2,x){const n=i+(1===t?s.length-2:t-2),r=1===t?i:n+1;if(this.indexArray.emplaceBack(A+1,n,A+3),this.indexArray.emplaceBack(n,r,A+3),o.primitiveLength+=2,void 0===g&&(g=A),!xf(T,s[t],e)){const e=t===s.length-1?g:o.vertexLength;this.indexArray.emplaceBack(A+2,A+3,e),this.indexArray.emplaceBack(A+3,e+1,e),this.indexArray.emplaceBack(A+3,r,e+1),o.primitiveLength+=3}b=!b}if(u){const t=this.layoutVertexExtArray,e=d.projectTilePoint(l.x,l.y,n),i=d.projectTilePoint(h.x,h.y,n),r=d.upVector(n,l.x,l.y),o=d.upVector(n,h.x,h.y);lf(t,e,r),lf(t,e,r),lf(t,i,o),lf(t,i,o)}}h&&(i+=s.length-1),m&&x&&this.zoom>=17&&(0!==_.length&&w(_,_[0])&&_.pop(),this.groundEffect.addData(_,e,l,x>0))}this.footprintSegments.push(a),s.triangleCount=this.indexArray.length-s.triangleArrayOffset,this.polygonSegments.push(s),++f.footprintSegLen,++f.polygonSegLen}if(f.vertexCount=this.layoutVertexArray.length-f.vertexArrayOffset,f.groundVertexCount=this.groundEffect.vertexArray.length-f.groundVertexArrayOffset,0!==f.vertexCount){if(f.centroidXY=p.borders?rf:this.encodeCentroid(p,f),this.centroidData.push(f),p.borders){this.featuresOnBorder.push(p);const t=this.featuresOnBorder.length-1;for(let e=0;ethis.featuresOnBorder[e].borders[t][0]-this.featuresOnBorder[i].borders[t][0]))}splitToSubtiles(){const t=[];for(let e=0;euo),r=2*n+(+(i.min.x+i.max.x>uo)^n);for(let n=0;nt.triangleSegmentIdx===e.triangleSegmentIdx?t.subtile-e.subtile:t.triangleSegmentIdx-e.triangleSegmentIdx));let i=0,n=0,r=0;for(const e of t){if(e.triangleSegmentIdx!==i)break;r++}const o=t.length;for(;n!==t.length;){i=t[n].triangleSegmentIdx;let s=0,a=n,l=n;for(let e=a;e0&&this.triangleSubSegments.push({segment:d,min:o,max:c}),a=l;for(let e=a;e[t[0]*(1-i[0])+e[0]*i[0],t[1]*(1-i[1])+e[1]*i[1]],h=[],p=[];for(const t of this.triangleSubSegments){h[0]=t.min.x/uo,h[1]=t.min.y/uo,p[0]=t.max.x/uo,p[1]=t.max.y/uo;const e=u(l,c,h),o=u(l,c,p);if(0===new wu([e[0],e[1],n],[o[0],o[1],r]).intersectsPrecise(i)){a&&(d.segments.push(a),a=void 0);continue}const s=t.segment;a&&a.vertexOffset!==s.vertexOffset&&(d.segments.push(a),a=void 0),a?(a.vertexLength+=s.vertexLength,a.primitiveLength+=s.primitiveLength):a={vertexOffset:s.vertexOffset,primitiveLength:s.primitiveLength,vertexLength:s.vertexLength,primitiveOffset:s.primitiveOffset,sortKey:void 0,vaos:{}}}return a&&d.segments.push(a),d}encodeCentroid(t,e){const i=t.centroid(),n=e.span(),r=Math.min(7,Math.round(n.x*this.tileToMeter/10)),o=Math.min(7,Math.round(n.y*this.tileToMeter/10));return new Ue(Xe(i.x,1,uo-1)i.max.x||i.min.x>e.max.x||e.min.y>i.max.y||i.min.y>e.max.y))for(let o=0;oe!=l>e&&to.max.x||o.min.x>t||e>o.max.y||o.min.y>e||this.footprintContainsPoint(t,e,o)&&o&&o.height>i&&(i=o.height,this.partLookup[r]=o,n=!!(o.flags&of));if(i!==Number.NEGATIVE_INFINITY)return{height:i,hidden:n};this.partLookup[r]=void 0}}function gf(t,e){const i=t.add(e)._unit();return t.x*i.x+t.y*i.y}function yf(t,e,i,n){const r=e.sub(t)._perp()._unit(),o=i.sub(e)._perp()._unit();return vf(t,e,i,gf(r,o),n)}function vf(t,e,i,n,r){const o=Math.sqrt(1-n*n);return Math.min(t.dist(e)/3,e.dist(i)/3,r*o/n)}function xf(t,e,i){return t.xi[1].x&&e.x>i[1].x||t.yi[1].y&&e.y>i[1].y}function bf(t,e){return t.xe[1].x||t.ye[1].y}function wf(t,e,i){if(t.x=uo||e.x=uo||i.x=uo)return!1;const n=i.sub(e),r=n.perp(),o=t.sub(e);return(n.x*o.x+n.y*o.y)/Math.sqrt((n.x*n.x+n.y*n.y)*(o.x*o.x+o.y*o.y))>-.866&&r.x*o.x+r.y*o.y{for(const i of t)s.push({polygon:i,bounds:e})},l=Math.ceil(Math.log2(i)),c=Math.ceil(Math.log2(n)),d=l-c,u=[];for(let t=0;t0?0:1);for(let t=0;te+1?p.push({polygons:h,bounds:t,depth:e+1}):a(h,t)}if(f.length){const t=[new Ue(0===i?d:n.x,1===i?d:n.y),s];u.length>e+1?p.push({polygons:f,bounds:t,depth:e+1}):a(f,t)}}return s}(t,e,Math.ceil((o-r)/11.25),Math.ceil((s-a)/11.25),1,((t,e,r)=>{if(0===t)return.5*(e+r);{const t=Id((i.y+e/uo)/n);return(Md(.5*(Id((i.y+r/uo)/n)+t))*n-i.y)*uo}}))}function Mf(t,e,i,n,r,o){const s=Math.pow(2,n.z-r.z);for(let a=0;a1&&(s=t[++o]);const l=Math.abs(a-s.left),c=Math.abs(a-s.right),d=Math.min(l,c);let u;const h=e/i*(n+1);if(s.isDash){const t=n-Math.abs(h);u=Math.sqrt(d*d+t*t)}else u=n-Math.sqrt(d*d+h*h);this.image.data[r+a]=Math.max(0,Math.min(255,u+128))}}}addRegularDash(t,e){for(let e=t.length-1;e>=0;--e){const i=t[e],n=t[e+1];i.zeroLength?t.splice(e,1):n&&n.isDash===i.isDash&&(n.left=i.left,t.splice(e,1))}const i=t[0],n=t[t.length-1];i.isDash===n.isDash&&(i.left=n.left-this.width,n.right=i.right+this.width);const r=this.width*this.nextRow;let o=0,s=t[o];for(let i=0;i1&&(s=t[++o]);const n=Math.abs(i-s.left),a=Math.abs(i-s.right),l=Math.min(n,a);this.image.data[r+i]=Math.max(0,Math.min(255,(s.isDash?l:-l)+e+128))}}addDash(t,e){const i=this.getKey(t,e);if(this.positions[i])return this.positions[i];const n="round"===e,r=n?7:0,o=2*r+1;if(this.nextRow+o>this.height)return pi("LineAtlas out of space"),null;0===t.length&&t.push(1);let s=0;for(let e=0;et.fqid)),this.index=t.index,this.projection=t.projection,this.hasPattern=!1,this.hasZOffset=!1,this.patternFeatures=[],this.lineClipsArray=[],this.gradients={},this.layers.forEach((t=>{this.gradients[t.id]={}})),this.layoutVertexArray=new Rl,this.layoutVertexArray2=new Ol,this.patternVertexArray=new Bl,this.indexArray=new Kl,this.programConfigurations=new Yc(t.layers,{zoom:t.zoom,lut:t.lut}),this.segments=new wc,this.maxLineLength=0,this.zOffsetVertexArray=new Zl,this.stateDependentLayerIds=this.layers.filter((t=>t.isStateDependent())).map((t=>t.id)),this.tessellationStep=t.tessellationStep?t.tessellationStep:uo/64}updateFootprints(t,e){}populate(t,e,i,n){this.hasPattern=Hh("line",this.layers,e);const r=this.layers[0].layout.get("line-sort-key"),o=this.layers[0].layout.get("line-z-offset");this.hasZOffset=!o.isConstant()||!!o.constantOr(0);const s=[];for(const{feature:e,id:o,index:a,sourceLayerIndex:l}of t){const t=this.layers[0]._featureFilter.needGeometry,c=Zd(e,t);if(!this.layers[0]._featureFilter.filter(new Ha(this.zoom),c,i))continue;const d=r?r.evaluate(c,{},i):void 0,u={id:o,properties:e.properties,type:e.type,sourceLayerIndex:l,index:a,geometry:t?c.geometry:Gd(e,i,n),patterns:{},sortKey:d};s.push(u)}r&&s.sort(((t,e)=>t.sortKey-e.sortKey));const{lineAtlas:a,featureIndex:l}=e,c=this.addConstantDashes(a);for(const n of s){const{geometry:r,index:o,sourceLayerIndex:s}=n;if(c&&this.addFeatureDashes(n,a),this.hasPattern){const t=Wh("line",this.layers,n,this.zoom,e);this.patternFeatures.push(t)}else this.addFeature(n,r,o,i,a.positions,e.availableImages,e.brightness);l.insert(t[o].feature,r,o,s,this.index)}}addConstantDashes(t){let e=!1;for(const i of this.layers){const n=i.paint.get("line-dasharray").value,r=i.layout.get("line-cap").value;if("constant"!==n.kind||"constant"!==r.kind)e=!0;else{const e=r.value,i=n.value;if(!i)continue;t.addDash(i,e)}}return e}addFeatureDashes(t,e){const i=this.zoom;for(const n of this.layers){const r=n.paint.get("line-dasharray").value,o=n.layout.get("line-cap").value;if("constant"===r.kind&&"constant"===o.kind)continue;let s,a;if("constant"===r.kind){if(s=r.value,!s)continue}else s=r.evaluate({zoom:i},t);a="constant"===o.kind?o.value:o.evaluate({zoom:i},t),e.addDash(s,a),t.patterns[n.id]=e.getKey(s,a)}}update(t,e,i,n,r){const o=0!==Object.keys(t).length;o&&!this.stateDependentLayers.length||this.programConfigurations.updatePaintArrays(t,e,o?this.stateDependentLayers:this.layers,i,n,r)}addFeatures(t,e,i,n,r,o){for(const t of this.patternFeatures)this.addFeature(t,t.geometry,t.index,e,i,n,o)}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(t){this.uploaded||(0!==this.layoutVertexArray2.length&&(this.layoutVertexBuffer2=t.createVertexBuffer(this.layoutVertexArray2,zf)),0!==this.patternVertexArray.length&&(this.patternVertexBuffer=t.createVertexBuffer(this.patternVertexArray,Of)),!this.zOffsetVertexBuffer&&this.zOffsetVertexArray.length>0&&(this.zOffsetVertexBuffer=t.createVertexBuffer(this.zOffsetVertexArray,jf.members,!0)),this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,kf),this.indexBuffer=t.createIndexBuffer(this.indexArray)),this.programConfigurations.upload(t),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.zOffsetVertexBuffer&&this.zOffsetVertexBuffer.destroy(),this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy())}lineFeatureClips(t){if(t.properties&&t.properties.hasOwnProperty("mapbox_clip_start")&&t.properties.hasOwnProperty("mapbox_clip_end"))return{start:+t.properties.mapbox_clip_start,end:+t.properties.mapbox_clip_end}}addFeature(t,e,i,n,r,o,s){const a=this.layers[0].layout,l=a.get("line-join").evaluate(t,{}),c=a.get("line-cap").evaluate(t,{}),d=a.get("line-miter-limit"),u=a.get("line-round-limit");this.lineClips=this.lineFeatureClips(t);for(const i of e)this.addLine(i,t,n,l,c,d,u);this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,t,i,r,o,n,s)}addLine(t,e,i,n,r,o,s){this.distance=0,this.scaledDistance=0,this.totalDistance=0,this.lineSoFar=0,this.currentVertex=void 0;const a={zoom:this.zoom,lineProgress:void 0},l=this.layers[0].layout,c="none"===n;if(this.patternJoinNone=this.hasPattern&&c,this.segmentStart=0,this.segmentStartf32=0,this.segmentPoints=[],this.lineClips){this.lineClipsArray.push(this.lineClips);for(let e=0;e=2&&t[u-1].equals(t[u-2]);)u--;let h=0;for(;h0;if(A&&i>h){const t=m.dist(_);if(t>2*p){const e=m.sub(m.sub(_)._mult(p/t)._round());this.updateDistance(_,e),this.addCurrentVertex(e,y,0,0,f,x),_=e}}if(b&&"round"===w&&(Mo&&(w="bevel"),"bevel"===w&&(M>2&&(w="flipbevel"),M100)S=v.mult(-1);else{const t=M*y.add(v).mag()/y.sub(v).mag();S._perp()._mult(t*(I?-1:1))}this.addCurrentVertex(m,S,0,0,f,x),this.addCurrentVertex(m,S.mult(-1),0,0,f,x)}else if("bevel"===w||"fakeround"===w){const t=-Math.sqrt(M*M-1),e=I?t:0,i=I?0:t;if(_&&this.addCurrentVertex(m,y,e,i,f,x),"fakeround"===w){const t=Math.round(180*C/Math.PI/20);for(let e=1;e2*p){const e=m.add(g.sub(m)._mult(p/t)._round());this.updateDistance(m,e),this.addCurrentVertex(e,v,0,0,f,x),m=e}}}}addVerticesTo(t,e,i,n,r,o,s,a,l,c){const d=(e.w-t.w)/this.tessellationStep|0;if(d>1){this.lineSoFar=t.w;const u=(e.x-t.x)/d,h=(e.y-t.y)/d,p=(e.z-t.z)/d,f=(e.w-t.w)/d;for(let e=1;e=0&&this.e2>=0&&(this.indexArray.emplaceBack(this.e1,this.e2,c),a.primitiveLength++),o?this.e2=c:this.e1=c,null!=l&&this.zOffsetVertexArray.emplaceBack(l)}updateScaledDistance(){if(this.lineClips){const t=this.totalDistance/(this.lineClips.end-this.lineClips.start);this.scaledDistance=this.distance/this.totalDistance,this.lineSoFar=t*this.lineClips.start+this.distance}else this.lineSoFar=this.distance}updateDistance(t,e){this.distance+=t.dist(e),this.updateScaledDistance()}}function Qf(t,e,i){return t.xi||t.yi}ba(Jf,"LineBucket",{omit:["layers","patternFeatures","currentVertex","currentVertexIsOutside"]});const tm=new ol({"line-cap":new nl(sl.layout_line["line-cap"]),"line-join":new nl(sl.layout_line["line-join"]),"line-miter-limit":new il(sl.layout_line["line-miter-limit"]),"line-round-limit":new il(sl.layout_line["line-round-limit"]),"line-sort-key":new nl(sl.layout_line["line-sort-key"]),"line-z-offset":new nl(sl.layout_line["line-z-offset"]),visibility:new il(sl.layout_line.visibility)});var em={paint:new ol({"line-opacity":new nl(sl.paint_line["line-opacity"]),"line-color":new nl(sl.paint_line["line-color"]),"line-translate":new il(sl.paint_line["line-translate"]),"line-translate-anchor":new il(sl.paint_line["line-translate-anchor"]),"line-width":new nl(sl.paint_line["line-width"]),"line-gap-width":new nl(sl.paint_line["line-gap-width"]),"line-offset":new nl(sl.paint_line["line-offset"]),"line-blur":new nl(sl.paint_line["line-blur"]),"line-dasharray":new nl(sl.paint_line["line-dasharray"]),"line-pattern":new nl(sl.paint_line["line-pattern"]),"line-gradient":new rl(sl.paint_line["line-gradient"]),"line-trim-offset":new il(sl.paint_line["line-trim-offset"]),"line-trim-fade-range":new il(sl.paint_line["line-trim-fade-range"]),"line-trim-color":new il(sl.paint_line["line-trim-color"]),"line-emissive-strength":new il(sl.paint_line["line-emissive-strength"]),"line-border-width":new nl(sl.paint_line["line-border-width"]),"line-border-color":new nl(sl.paint_line["line-border-color"]),"line-occlusion-opacity":new il(sl.paint_line["line-occlusion-opacity"])}),layout:tm};function im(t,e,i){return e*(uo/(t.tileSize*Math.pow(2,i-t.tileID.overscaledZ)))}function nm(t,e){return 1/im(t,1,e.tileZoom)}function rm(t,e,i,n){return t.translatePosMatrix(n||e.tileID.projMatrix,e,i.paint.get("line-translate"),i.paint.get("line-translate-anchor"))}const om=t=>{const e=[];sm(t)&&e.push("RENDER_LINE_DASH"),t.paint.get("line-gradient")&&e.push("RENDER_LINE_GRADIENT");const i=t.paint.get("line-trim-offset");0===i[0]&&0===i[1]||e.push("RENDER_LINE_TRIM_OFFSET"),0!==t.paint.get("line-border-width").constantOr(1)&&e.push("RENDER_LINE_BORDER");const n="none"===t.layout.get("line-join").constantOr("miter"),r=!!t.paint.get("line-pattern").constantOr(1);return n&&r&&e.push("LINE_JOIN_NONE"),e};function sm(t){const e=t.paint.get("line-dasharray").value;return e.value||"constant"!==e.kind}class am{constructor(t){this._stringToNumber={},this._numberToString=[];for(let e=0;e>1,d=-7,u=i?r-1:0,h=i?-1:1,p=t[e+u];for(u+=h,o=p&(1>=-d,d+=a;d>0;o=256*o+t[e+u],u+=h,d-=8);for(s=o&(1>=-d,d+=n;d>0;s=256*s+t[e+u],u+=h,d-=8);if(0===o)o=1-c;else{if(o===l)return s?NaN:1/0*(p?-1:1);s+=Math.pow(2,n),o-=c}return(p?-1:1)*s*Math.pow(2,o-n)},write:function(t,e,i,n,r,o){var s,a,l,c=8*o-r-1,d=(1>1,h=23===r?Math.pow(2,-24)-Math.pow(2,-77):0,p=n?0:o-1,f=n?1:-1,m=e=1?h/l:h*Math.pow(2,1-u))*l>=2&&(s++,l/=2),s+u>=d?(a=0,s=d):s+u>=1?(a=(e*l-1)*Math.pow(2,r),s+=u):(a=e*Math.pow(2,u-1)*Math.pow(2,r),s=0));r>=8;t[i+p]=255&a,p+=f,a/=256,r-=8);for(s=s0;t[i+p]=255&s,p+=f,s/=256,c-=8);t[i+p-f]|=128*m}},cm=um,dm=lm;function um(t){this.buf=ArrayBuffer.isView&&ArrayBuffer.isView(t)?t:new Uint8Array(t||0),this.pos=0,this.type=0,this.length=this.buf.length}um.Varint=0,um.Fixed64=1,um.Bytes=2,um.Fixed32=5;var hm=4294967296,pm=1/hm,fm="undefined"==typeof TextDecoder?null:new TextDecoder("utf8");function mm(t){return t.type===um.Bytes?t.readVarint()+t.pos:t.pos+1}function _m(t,e,i){return i?4294967296*e+(t>>>0):4294967296*(e>>>0)+(t>>>0)}function gm(t,e,i){var n=e=t;r--)i.buf[r+n]=i.buf[r]}function ym(t,e){for(var i=0;i>>8,t[i+2]=e>>>16,t[i+3]=e>>>24}function Im(t,e){return(t[e]|t[e+1]>3,o=this.pos;this.type=7&n,t(r,e,this),this.pos===o&&this.skip(n)}return e},readMessage:function(t,e){return this.readFields(t,e,this.readVarint()+this.pos)},readFixed32:function(){var t=Cm(this.buf,this.pos);return this.pos+=4,t},readSFixed32:function(){var t=Im(this.buf,this.pos);return this.pos+=4,t},readFixed64:function(){var t=Cm(this.buf,this.pos)+Cm(this.buf,this.pos+4)*hm;return this.pos+=8,t},readSFixed64:function(){var t=Cm(this.buf,this.pos)+Im(this.buf,this.pos+4)*hm;return this.pos+=8,t},readFloat:function(){var t=dm.read(this.buf,this.pos,!0,23,4);return this.pos+=4,t},readDouble:function(){var t=dm.read(this.buf,this.pos,!0,52,8);return this.pos+=8,t},readVarint:function(t){var e,i,n=this.buf;return e=127&(i=n[this.pos++]),i>4,r=12&&fm?function(t,e,i){return fm.decode(t.subarray(e,i))}(this.buf,e,t):function(t,e,i){for(var n="",r=e;r239?4:l>223?3:l>191?2:1;if(r+d>i)break;1===d?l=55296&&c=1114112)&&(c=null)),null===c?(c=65533,d=1):c>65535&&(c-=65536,n+=String.fromCharCode(c>>>10&1023|55296),c=56320|1023&c),n+=String.fromCharCode(c),r+=d}return n}(this.buf,e,t)},readBytes:function(){var t=this.readVarint()+this.pos,e=this.buf.subarray(this.pos,t);return this.pos=t,e},readPackedVarint:function(t,e){if(this.type!==um.Bytes)return t.push(this.readVarint(e));var i=mm(this);for(t=t||[];this.pos127;);else if(e===um.Bytes)this.pos=this.readVarint()+this.pos;else if(e===um.Fixed32)this.pos+=4;else{if(e!==um.Fixed64)throw new Error("Unimplemented type: "+e);this.pos+=8}},writeTag:function(t,e){this.writeVarint(t268435455||t=0?(i=t%4294967296|0,n=t/4294967296|0):(n=~(-t/4294967296),4294967295^(i=~(-t%4294967296))?i=i+1|0:(i=0,n=n+1|0)),t>=0x10000000000000000||t>>=7,i.buf[i.pos++]=127&t|128,t>>>=7,i.buf[i.pos++]=127&t|128,t>>>=7,i.buf[i.pos++]=127&t|128,i.buf[i.pos]=127&(t>>>=7)}(i,0,e),function(t,e){var i=(7&t)>>=3)?128:0),t&&(e.buf[e.pos++]=127&t|((t>>>=7)?128:0),t&&(e.buf[e.pos++]=127&t|((t>>>=7)?128:0),t&&(e.buf[e.pos++]=127&t|((t>>>=7)?128:0),t&&(e.buf[e.pos++]=127&t|((t>>>=7)?128:0),t&&(e.buf[e.pos++]=127&t)))))}(n,e)}(t,this):(this.realloc(4),this.buf[this.pos++]=127&t|(t>127?128:0),t>>=7)|(t>127?128:0),t>>=7)|(t>127?128:0),t>>7&127))))},writeSVarint:function(t){this.writeVarint(t55295&&n56319||o+1===e.length?(t[i++]=239,t[i++]=191,t[i++]=189):r=n;continue}if(n>6|192:(n>12|224:(t[i++]=n>>18|240,t[i++]=n>>12&63|128),t[i++]=n>>6&63|128),t[i++]=63&n|128)}return i}(this.buf,t,this.pos);var i=this.pos-e;i>=128&&gm(e,i,this),this.pos=e-1,this.writeVarint(i),this.pos+=i},writeFloat:function(t){this.realloc(4),dm.write(this.buf,t,this.pos,!0,23,4),this.pos+=4},writeDouble:function(t){this.realloc(8),dm.write(this.buf,t,this.pos,!0,52,8),this.pos+=8},writeBytes:function(t){var e=t.length;this.writeVarint(e),this.realloc(e);for(var i=0;i=128&&gm(i,n,this),this.pos=i-1,this.writeVarint(n),this.pos+=n},writeMessage:function(t,e,i){this.writeTag(t,um.Bytes),this.writeRawMessage(e,i)},writePackedVarint:function(t,e){e.length&&this.writeMessage(t,ym,e)},writePackedSVarint:function(t,e){e.length&&this.writeMessage(t,vm,e)},writePackedBoolean:function(t,e){e.length&&this.writeMessage(t,wm,e)},writePackedFloat:function(t,e){e.length&&this.writeMessage(t,xm,e)},writePackedDouble:function(t,e){e.length&&this.writeMessage(t,bm,e)},writePackedFixed32:function(t,e){e.length&&this.writeMessage(t,Tm,e)},writePackedSFixed32:function(t,e){e.length&&this.writeMessage(t,Sm,e)},writePackedFixed64:function(t,e){e.length&&this.writeMessage(t,Em,e)},writePackedSFixed64:function(t,e){e.length&&this.writeMessage(t,Mm,e)},writeBytesField:function(t,e){this.writeTag(t,um.Bytes),this.writeBytes(e)},writeFixed32Field:function(t,e){this.writeTag(t,um.Fixed32),this.writeFixed32(e)},writeSFixed32Field:function(t,e){this.writeTag(t,um.Fixed32),this.writeSFixed32(e)},writeFixed64Field:function(t,e){this.writeTag(t,um.Fixed64),this.writeFixed64(e)},writeSFixed64Field:function(t,e){this.writeTag(t,um.Fixed64),this.writeSFixed64(e)},writeVarintField:function(t,e){this.writeTag(t,um.Varint),this.writeVarint(e)},writeSVarintField:function(t,e){this.writeTag(t,um.Varint),this.writeSVarint(e)},writeStringField:function(t,e){this.writeTag(t,um.Bytes),this.writeString(e)},writeFloatField:function(t,e){this.writeTag(t,um.Fixed32),this.writeFloat(e)},writeDoubleField:function(t,e){this.writeTag(t,um.Fixed64),this.writeDouble(e)},writeBooleanField:function(t,e){this.writeVarintField(t,Boolean(e))}};var Lm=h(cm);const Pm=["id","tile","layer","source","sourceLayer","state"];class $m{constructor(t,e,i,n,r){this.type="Feature",this._vectorTileFeature=t,this._z=e,this._x=i,this._y=n,this.properties=t.properties,this.id=r}get geometry(){return void 0===this._geometry&&(this._geometry=this._vectorTileFeature.toGeoJSON(this._x,this._y,this._z).geometry),this._geometry}set geometry(t){this._geometry=t}toJSON(){const t={type:"Feature",state:void 0,geometry:this.geometry,properties:this.properties};for(const e of Pm)void 0!==this[e]&&(t[e]=this[e]);return t}}class km{constructor(){this.state={},this.stateChanges={},this.deletedStates={}}updateState(t,e,i){const n=String(e);if(this.stateChanges[t]=this.stateChanges[t]||{},this.stateChanges[t][n]=this.stateChanges[t][n]||{},ei(this.stateChanges[t][n],i),null===this.deletedStates[t]){this.deletedStates[t]={};for(const e in this.state[t])e!==n&&(this.deletedStates[t][e]=null)}else if(this.deletedStates[t]&&null===this.deletedStates[t][n]){this.deletedStates[t][n]={};for(const e in this.state[t][n])i[e]||(this.deletedStates[t][n][e]=null)}else for(const e in i)this.deletedStates[t]&&this.deletedStates[t][n]&&null===this.deletedStates[t][n][e]&&delete this.deletedStates[t][n][e]}removeFeatureState(t,e,i){if(null===this.deletedStates[t])return;const n=String(e);if(this.deletedStates[t]=this.deletedStates[t]||{},i&&void 0!==e)null!==this.deletedStates[t][n]&&(this.deletedStates[t][n]=this.deletedStates[t][n]||{},this.deletedStates[t][n][i]=null);else if(void 0!==e)if(this.stateChanges[t]&&this.stateChanges[t][n])for(i in this.deletedStates[t][n]={},this.stateChanges[t][n])this.deletedStates[t][n][i]=null;else this.deletedStates[t][n]=null;else this.deletedStates[t]=null}getState(t,e){const i=String(e),n=ei({},(this.state[t]||{})[i],(this.stateChanges[t]||{})[i]);if(null===this.deletedStates[t])return{};if(this.deletedStates[t]){const i=this.deletedStates[t][e];if(null===i)return{};for(const t in i)delete n[t]}return n}initializeTileState(t,e){t.setFeatureState(this.state,e)}coalesceChanges(t,e){const i={};for(const t in this.stateChanges){this.state[t]=this.state[t]||{};const e={};for(const i in this.stateChanges[t])this.state[t][i]||(this.state[t][i]={}),ei(this.state[t][i],this.stateChanges[t][i]),e[i]=this.state[t][i];i[t]=e}for(const t in this.deletedStates){this.state[t]=this.state[t]||{};const e={};if(null===this.deletedStates[t])for(const i in this.state[t])e[i]={},this.state[t][i]={};else for(const i in this.deletedStates[t]){if(null===this.deletedStates[t][i])this.state[t][i]={};else if(this.state[t][i])for(const e of Object.keys(this.deletedStates[t][i]))delete this.state[t][i][e];e[i]=this.state[t][i]}i[t]=i[t]||{},ei(i[t],e)}if(this.stateChanges={},this.deletedStates={},0!==Object.keys(i).length)for(const n in t)t[n].setFeatureState(i,e)}}class Dm{constructor(t,e){this.tileID=t,this.x=t.canonical.x,this.y=t.canonical.y,this.z=t.canonical.z,this.grid=new va(uo,16,0),this.featureIndexArray=new yc,this.promoteId=e,this.is3DTile=!1}insert(t,e,i,n,r,o=0,s=0){const a=this.featureIndexArray.length;this.featureIndexArray.emplaceBack(i,n,r,o);const l=this.grid;for(let t=0;t=0&&n[3]>=0&&l.insert(a,n[0],n[1],n[2],n[3])}}loadVTLayers(){if(!this.vtLayers){this.vtLayers=new bp(new Lm(this.rawTileData)).layers,this.sourceLayerCoder=new am(this.vtLayers?Object.keys(this.vtLayers).sort():["_geojsonTileLayer"]),this.vtFeatures={};for(const t in this.vtLayers)this.vtFeatures[t]=[]}return this.vtLayers}query(t,e,i,n){this.loadVTLayers();const r=t.params||{},o=dl(r.filter),s=t.tileResult,a=t.transform,l=s.bufferedTilespaceBounds,c=this.grid.query(l.min.x,l.min.y,l.max.x,l.max.y,((t,e,i,n)=>ou(s.bufferedTilespaceGeometry,t,e,i,n)));c.sort(Rm);let d=null;a.elevation&&c.length>0&&(d=Xp.create(a.elevation,this.tileID));const u={};let h;for(let l=0;l(m||(m=Gd(e,this.tileID.canonical,t.tileTransform)),i.queryIntersectsFeature(s,e,n,m,this.z,t.transform,t.pixelPosMatrix,d,r))))}return u}loadMatchingFeature(t,e,i,n,r,o,s,a,l){const{featureIndex:c,bucketIndex:d,sourceLayerIndex:u,layoutVertexArrayOffset:h}=e,p=this.bucketLayerIDs[d];if(n&&!function(t,e){for(let i=0;i=0)return!0;return!1}(n,p))return;const f=this.sourceLayerCoder.decode(u),m=this.vtLayers[f].feature(c);if(i.needGeometry){const t=Zd(m,!0);if(!i.filter(new Ha(this.tileID.overscaledZ),t,this.tileID.canonical))return}else if(!i.filter(new Ha(this.tileID.overscaledZ),m))return;const _=this.getId(m,f);for(let e=0;e{const s=e instanceof el?e.get(o):null;return s&&s.evaluate?s.evaluate(i,n,r):s}))}function Rm(t,e){return e-t}ba(Dm,"FeatureIndex",{omit:["rawTileData","sourceLayerCoder"]});var Om=24;const Bm=128;function Fm(t,e){const{expression:i}=e;if("constant"===i.kind)return{kind:"constant",layoutSize:i.evaluate(new Ha(t+1))};if("source"===i.kind)return{kind:"source"};{const{zoomStops:e,interpolationType:n}=i;let r=0;for(;r{t.text=function(t,e,i){const n=e.layout.get("text-transform").evaluate(i,{});return"uppercase"===n?t=t.toLocaleUpperCase():"lowercase"===n&&(t=t.toLocaleLowerCase()),qa.applyArabicShaping&&(t=qa.applyArabicShaping(t)),t}(t.text,e,i)})),t}const Gm={"!":"︕","#":"#",$:"$","%":"%","&":"&","(":"︵",")":"︶","*":"*","+":"+",",":"︐","-":"︲",".":"・","/":"/",":":"︓",";":"︔","":"﹀","?":"︖","@":"@","[":"﹇","\\":"\","]":"﹈","^":"^",_:"︳","`":"`","{":"︷","|":"―","}":"︸","~":"~","¢":"¢","£":"£","¥":"¥","¦":"¦","¬":"¬","¯":" ̄","–":"︲","—":"︱","‘":"﹃","’":"﹄","“":"﹁","”":"﹂","…":"︙","‧":"・","₩":"₩","、":"︑","。":"︒","〈":"︿","〉":"﹀","《":"︽","》":"︾","「":"﹁","」":"﹂","『":"﹃","』":"﹄","【":"︻","】":"︼","〔":"︹","〕":"︺","〖":"︗","〗":"︘","!":"︕","(":"︵",")":"︶",",":"︐","-":"︲",".":"・",":":"︓",";":"︔","<":"︿",">":"﹀","?":"︖","[":"﹇","]":"﹈","_":"︳","{":"︷","|":"―","}":"︸","⦅":"︵","⦆":"︶","。":"︒","「":"﹁","」":"﹂","←":"↑","→":"↓"};function Zm(t){return"︶"===t||"﹈"===t||"︸"===t||"﹄"===t||"﹂"===t||"︾"===t||"︼"===t||"︺"===t||"︘"===t||"﹀"===t||"︐"===t||"︓"===t||"︔"===t||"`"===t||" ̄"===t||"︑"===t||"︒"===t}function qm(t){return"︵"===t||"﹇"===t||"︷"===t||"﹃"===t||"﹁"===t||"︽"===t||"︻"===t||"︹"===t||"︗"===t||"︿"===t}const Hm=3;function Wm(t,e,i){e.glyphs=[],1===t&&i.readMessage(Ym,e)}function Ym(t,e,i){if(3===t){const{id:t,bitmap:n,width:r,height:o,left:s,top:a,advance:l}=i.readMessage(Xm,{});e.glyphs.push({id:t,bitmap:new dh({width:r+2*Hm,height:o+2*Hm},n),metrics:{width:r,height:o,left:s,top:a,advance:l}})}else 4===t?e.ascender=i.readSVarint():5===t&&(e.descender=i.readSVarint())}function Xm(t,e,i){1===t?e.id=i.readVarint():2===t?e.bitmap=i.readBytes():3===t?e.width=i.readVarint():4===t?e.height=i.readVarint():5===t?e.left=i.readSVarint():6===t?e.top=i.readSVarint():7===t&&(e.advance=i.readVarint())}const Km=Hm,Jm={horizontal:1,vertical:2,horizontalOnly:3};class Qm{constructor(){this.scale=1,this.fontStack="",this.imageName=null}static forText(t,e){const i=new Qm;return i.scale=t||1,i.fontStack=e,i}static forImage(t){const e=new Qm;return e.imageName=t,e}}class t_{constructor(){this.text="",this.sectionIndex=[],this.sections=[],this.imageSectionID=null}static fromFeature(t,e){const i=new t_;for(let n=0;n=0&&i>=t&&i_[this.text.charCodeAt(i)];i--)e--;this.text=this.text.substring(t,e),this.sectionIndex=this.sectionIndex.slice(t,e)}substring(t,e){const i=new t_;return i.text=this.text.substring(t,e),i.sectionIndex=this.sectionIndex.slice(t,e),i.sections=this.sections,i}toString(){return this.text}getMaxScale(){return this.sectionIndex.reduce(((t,e)=>Math.max(t,this.sections[e].scale)),0)}addTextSection(t,e){this.text+=t.text,this.sections.push(Qm.forText(t.scale,t.fontStack||e));const i=this.sections.length-1;for(let e=0;e=63743?null:++this.imageSectionID:(this.imageSectionID=57344,this.imageSectionID)}}function e_(t,e,i,n,r,o,s,a,l,c,d,u,h,p,f){const m=t_.fromFeature(t,r);u===Jm.vertical&&m.verticalizePunctuation(h);let _=[];const g=function(t,e,i,n,r,o){if(!t)return[];const s=[],a=function(t,e,i,n,r,o){let s=0;for(let i=0;i=0;let c=0;for(let i=0;i0&&o>b&&(b=o)}else{const t=i[a.fontStack];if(!t)continue;t[m]&&(S=t[m]);const n=e[a.fontStack];if(!n)continue;const o=n.glyphs[m];if(!o)continue;if(v=o.metrics,M=8203!==m?Om:0,_){const t=void 0!==n.ascender?Math.abs(n.ascender):0,e=void 0!==n.descender?Math.abs(n.descender):0,i=(t+e)*g;w-i/2;){if(s--,sn;)c-=l.shift().angleDelta;if(c>r)return!1;s++,a+=e.dist(i)}return!0}function m_(t){let e=0;for(let i=0;ic){const d=(c-l)/o,u=Vn(n.x,r.x,d),h=Vn(n.y,r.y,d),p=new p_(u,h,0,r.angleTo(n),i);return!s||f_(t,p,a,s,e)?p:void 0}l+=o}}function v_(t,e,i,n,r,o,s,a,l){const c=__(n,o,s),d=g_(n,r),u=d*s,h=0===t[0].x||t[0].x===l||0===t[0].y||t[0].y===l;return e-u=0&&g=0&&y=0&&h+c=n&&c.x>=n||(s.x>=n?s=new Ue(n,s.y+(n-s.x)/(c.x-s.x)*(c.y-s.y))._round():c.x>=n&&(c=new Ue(n,s.y+(n-s.x)/(c.x-s.x)*(c.y-s.y))._round()),s.y>=r&&c.y>=r||(s.y>=r?s=new Ue(s.x+(r-s.y)/(c.y-s.y)*(c.x-s.x),r)._round():c.y>=r&&(c=new Ue(s.x+(r-s.y)/(c.y-s.y)*(c.x-s.x),r)._round()),l&&s.equals(l[l.length-1])||(l=[s],o.push(l)),l.push(c)))))}}return o}function w_(t){let e=0,i=0;for(const n of t)e+=n.w*n.h,i=Math.max(i,n.w);t.sort(((t,e)=>e.h-t.h));const n=[{x:0,y:0,w:Math.max(Math.ceil(Math.sqrt(e/.95)),i),h:1/0}];let r=0,o=0;for(const e of t)for(let t=n.length-1;t>=0;t--){const i=n[t];if(!(e.w>i.w||e.h>i.h)){if(e.x=i.x,e.y=i.y,o=Math.max(o,e.y+e.h),r=Math.max(r,e.x+e.w),e.w===i.w&&e.h===i.h){const e=n.pop();tt.hasImage(e,i))),t.dispatchRenderCallbacks(this.haveRenderCallbacks,i);for(const n in t.getUpdatedImages(i))this.patchUpdatedImage(this.iconPositions[n],t.getImage(n,i),e),this.patchUpdatedImage(this.patternPositions[n],t.getImage(n,i),e)}patchUpdatedImage(t,e,i){if(!t||!e)return;if(t.version===e.version)return;t.version=e.version;const[n,r]=t.tl,o=!!Object.keys(this.patternPositions).length;i.update(e.data,{useMipmap:o},{x:n,y:r})}}ba(S_,"ImagePosition"),ba(E_,"ImageAtlas");const M_=1e20;function C_(t,e,i,n,r,o,s,a,l){for(let c=e;c-1);l++,o[l]=a,s[l]=c,s[l+1]=M_}for(let a=0,l=0;a{let n=this.entries[t];n||(n=this.entries[t]={glyphs:{},requests:{},ranges:{},ascender:void 0,descender:void 0});let r=n.glyphs[e];if(void 0!==r)return void i(null,{stack:t,id:e,glyph:r});if(r=this._tinySDF(n,t,e),r)return n.glyphs[e]=r,void i(null,{stack:t,id:e,glyph:r});const s=Math.floor(e/256);if(256*s>65535)return void i(new Error("glyphs > 65535 not supported"));if(n.ranges[s])return void i(null,{stack:t,id:e,glyph:r});let a=n.requests[s];a||(a=n.requests[s]=[],P_.loadGlyphRange(t,s,o,this.requestManager,((t,e)=>{if(e){n.ascender=e.ascender,n.descender=e.descender;for(const t in e.glyphs)this._doesCharSupportLocalGlyph(+t)||(n.glyphs[+t]=e.glyphs[+t]);n.ranges[s]=!0}for(const i of a)i(t,e);delete n.requests[s]}))),a.push(((n,r)=>{n?i(n):r&&i(null,{stack:t,id:e,glyph:r.glyphs[e]||null})}))}),((t,e)=>{if(t)i(t);else if(e){const t={};for(const{stack:i,id:n,glyph:r}of e)void 0===t[i]&&(t[i]={}),void 0===t[i].glyphs&&(t[i].glyphs={}),t[i].glyphs[n]=r&&{id:r.id,bitmap:r.bitmap.clone(),metrics:r.metrics},t[i].ascender=this.entries[i].ascender,t[i].descender=this.entries[i].descender;i(null,t)}}))}_doesCharSupportLocalGlyph(t){return this.localGlyphMode!==L_.none&&(this.localGlyphMode===L_.all?!!this.localFontFamily:!!this.localFontFamily&&(Ma["CJK Unified Ideographs"](t)||Ma["Hangul Syllables"](t)||Ma.Hiragana(t)||Ma.Katakana(t)||Ma["CJK Symbols and Punctuation"](t)||Ma["CJK Unified Ideographs Extension A"](t)||Ma["CJK Unified Ideographs Extension B"](t)))}_tinySDF(t,e,i){const n=this.localFontFamily;if(!n||!this._doesCharSupportLocalGlyph(i))return;let r=t.tinySDF;if(!r){let i="400";/bold/i.test(e)?i="900":/medium/i.test(e)?i="500":/light/i.test(e)&&(i="200"),r=t.tinySDF=new P_.TinySDF({fontFamily:n,fontWeight:i,fontSize:24*I_,buffer:3*I_,radius:8*I_}),r.fontWeight=i}if(this.localGlyphs[r.fontWeight][i])return this.localGlyphs[r.fontWeight][i];const o=String.fromCodePoint(i),{data:s,width:a,height:l,glyphWidth:c,glyphHeight:d,glyphLeft:u,glyphTop:h,glyphAdvance:p}=r.draw(o);return this.localGlyphs[r.fontWeight][i]={id:i,bitmap:new dh({width:a,height:l},s),metrics:{width:c/I_,height:d/I_,left:u/I_,top:h/I_-27,advance:p/I_,localGlyph:!0}}}}P_.loadGlyphRange=function(t,e,i,n,r){const o=256*e,s=o+255,a=n.transformRequest(n.normalizeGlyphsURL(i).replace("{fontstack}",t).replace("{range}",`${o}-${s}`),Ki.Glyphs);en(a,((t,e)=>{if(t)r(t);else if(e){const t={},i=function(t){return new Lm(t).readFields(Wm,{})}(e);for(const e of i.glyphs)t[e.id]=e;r(null,{glyphs:t,ascender:i.ascender,descender:i.descender})}}))},P_.TinySDF=class{constructor({fontSize:t=24,buffer:e=3,radius:i=8,cutoff:n=.25,fontFamily:r="sans-serif",fontWeight:o="normal",fontStyle:s="normal"}={}){this.buffer=e,this.cutoff=n,this.radius=i;const a=this.size=t+4*e,l=this._createCanvas(a),c=this.ctx=l.getContext("2d",{willReadFrequently:!0});c.font=`${s} ${o} ${t}px ${r}`,c.textBaseline="alphabetic",c.textAlign="left",c.fillStyle="black",this.gridOuter=new Float64Array(a*a),this.gridInner=new Float64Array(a*a),this.f=new Float64Array(a),this.z=new Float64Array(a+1),this.v=new Uint16Array(a)}_createCanvas(t){const e=document.createElement("canvas");return e.width=e.height=t,e}draw(t){const{width:e,actualBoundingBoxAscent:i,actualBoundingBoxDescent:n,actualBoundingBoxLeft:r,actualBoundingBoxRight:o}=this.ctx.measureText(t),s=Math.ceil(i),a=Math.max(0,Math.min(this.size-this.buffer,Math.ceil(o-r))),l=Math.min(this.size-this.buffer,s+Math.ceil(n)),c=a+2*this.buffer,d=l+2*this.buffer,u=Math.max(c*d,0),h=new Uint8ClampedArray(u),p={data:h,width:c,height:d,glyphWidth:a,glyphHeight:l,glyphTop:s,glyphLeft:0,glyphAdvance:e};if(0===a||0===l)return p;const{ctx:f,buffer:m,gridInner:_,gridOuter:g}=this;f.clearRect(m,m,a,l),f.fillText(t,m,m+s);const y=f.getImageData(m,m,a,l);g.fill(M_,0,u),_.fill(0,0,u);for(let t=0;t0?t*t:0,_[n]=tt+e[1]-e[0],f=u.reduce(p,0),m=h.reduce(p,0),_=a-f,g=l-m;let y=0,v=f,x=0,b=m,w=0,T=_,S=0,E=g;if(o.content&&n){const t=o.content;y=D_(u,0,t[0]),x=D_(h,0,t[1]),v=D_(u,t[0],t[2]),b=D_(h,t[1],t[3]),w=t[0]-y,S=t[1]-x,T=t[2]-t[0]-v,E=t[3]-t[1]-b}const M=(n,r,a,l)=>{const u=R_(n.stretch-y,v,c,t.left),h=O_(n.fixed-w,T,n.stretch,f),p=R_(r.stretch-x,b,d,t.top),_=O_(r.fixed-S,E,r.stretch,m),g=R_(a.stretch-y,v,c,t.left),M=O_(a.fixed-w,T,a.stretch,f),C=R_(l.stretch-x,b,d,t.top),A=O_(l.fixed-S,E,l.stretch,m),I=new Ue(u,p),L=new Ue(g,p),P=new Ue(g,C),$=new Ue(u,C),k=new Ue(h/s,_/s),D=new Ue(M/s,A/s),z=e*Math.PI/180;if(z){const t=Math.sin(z),e=Math.cos(z),i=[e,-t,t,e];I._matMult(i),L._matMult(i),$._matMult(i),P._matMult(i)}const R=n.stretch+n.fixed,O=a.stretch+a.fixed,B=r.stretch+r.fixed,F=l.stretch+l.fixed,N=t.imageSecondary;return{tl:I,tr:L,bl:$,br:P,texPrimary:{x:o.paddedRect.x+$_+R,y:o.paddedRect.y+$_+B,w:O-R,h:F-B},texSecondary:N?{x:N.paddedRect.x+$_+R,y:N.paddedRect.y+$_+B,w:O-R,h:F-B}:void 0,writingMode:void 0,glyphOffset:[0,0],sectionIndex:0,pixelOffsetTL:k,pixelOffsetBR:D,minFontScaleX:T/s/c,minFontScaleY:E/s/d,isSDF:i}};if(n&&(o.stretchX||o.stretchY)){const t=z_(u,_,f),e=z_(h,g,m);for(let i=0;io)&&(o=e.x),(!t||e.y>s)&&(s=e.y)}const l=Math.min(o-n,s-r);let c=l/2;const d=new co([],N_);if(0===l)return new Ue(n,r);for(let e=n;eu.d||!u.d)&&(u=n,i&&console.log("found best %d after %d probes",Math.round(1e4*n.d)/1e4,h)),n.max-u.dt.y!=a.y>t.y&&t.x18&&P>2&&(P>>=1),Math.max(uo/(512*P),1)*_.get("symbol-spacing")),S=_.get("text-padding")*t.tilePixelRatio,E=_.get("icon-padding")*t.tilePixelRatio,M=Ge(_.get("text-max-angle")),C="map"===_.get("text-rotation-alignment")&&"point"!==_.get("symbol-placement"),A="map"===_.get("icon-rotation-alignment")&&"point"!==_.get("symbol-placement"),I=_.get("symbol-placement"),L=T/2;var P;const $=_.get("icon-text-fit").evaluate(e,{},u),k=_.get("icon-text-fit-padding").evaluate(e,{},u),D="none"!==$;let z;!1===t.hasAnyIconTextFit&&D&&(t.hasAnyIconTextFit=!0),n&&D&&(t.allowVerticalPlacement&&i.vertical&&(z=h_(n,i.vertical,$,k,g,b)),y&&(n=h_(n,y,$,k,g,b)));const R=(s,a,m)=>{if(a.x=uo||a.y=uo)return;let _=null;if(v){const{x:t,y:e,z:i}=h.projectTilePoint(a.x,a.y,m);_={anchor:new p_(t,e,i,0,void 0),up:h.upVector(m,a.x,a.y)}}!function(t,e,i,n,r,o,s,a,l,c,d,u,h,p,f,m,_,g,y,v,x,b,w,T,S,E,M){const C=t.addToLineVertexArray(e,n);let A,I,L,P,$,k,D,z=0,R=0,O=0,B=0,F=-1,N=-1;const U={};let j=Ln("");const V=i?i.anchor:e,G="none"!==l.layout.get("icon-text-fit").evaluate(x,{},S);let Z=0,q=0;if(void 0===l._unevaluatedLayout.getValue("text-radial-offset")?[Z,q]=l.layout.get("text-offset").evaluate(x,{},S).map((t=>t*Om)):(Z=l.layout.get("text-radial-offset").evaluate(x,{},S)*Om,q=j_),t.allowVerticalPlacement&&r.vertical){const t=r.vertical;if(f)k=J_(t),a&&(D=J_(a));else{const i=l.layout.get("text-rotate").evaluate(x,{},S)+90;L=K_(c,V,e,d,u,h,t,p,i,m),a&&(P=K_(c,V,e,d,u,h,a,g,i))}}if(o){const n=l.layout.get("icon-rotate").evaluate(x,{},S),r=k_(o,n,w,G),s=a?k_(a,n,w,G):void 0;I=K_(c,V,e,d,u,h,o,g,n),z=4*r.length;const p=t.iconSizeData;let f=null;"source"===p.kind?(f=[Bm*l.layout.get("icon-size").evaluate(x,{},S)],f[0]>W_&&pi(`${t.layerIds[0]}: Value for "icon-size" is >= ${H_}. Reduce your "icon-size".`)):"composite"===p.kind&&(f=[Bm*b.compositeIconSizes[0].evaluate(x,{},S),Bm*b.compositeIconSizes[1].evaluate(x,{},S)],(f[0]>W_||f[1]>W_)&&pi(`${t.layerIds[0]}: Value for "icon-size" is >= ${H_}. Reduce your "icon-size".`)),t.addSymbols(t.icon,r,f,v,y,x,!1,i,e,C.lineStartIndex,C.lineLength,-1,T,S,E,M),F=t.icon.placedSymbolArray.length-1,s&&(R=4*s.length,t.addSymbols(t.icon,s,f,v,y,x,Jm.vertical,i,e,C.lineStartIndex,C.lineLength,-1,T,S,E,M),N=t.icon.placedSymbolArray.length-1)}for(const n in r.horizontal){const o=r.horizontal[n];A||(j=Ln(o.text),f?$=J_(o):A=K_(c,V,e,d,u,h,o,p,l.layout.get("text-rotate").evaluate(x,{},S),m));const a=1===o.positionedLines.length;if(O+=Y_(t,i,e,o,s,l,f,x,m,C,r.vertical?Jm.horizontal:Jm.horizontalOnly,a?Object.keys(r.horizontal):[n],U,F,b,T,S,E),a)break}r.vertical&&(B+=Y_(t,i,e,r.vertical,s,l,f,x,m,C,Jm.vertical,["vertical"],U,N,b,T,S,E));let H=-1;const W=(t,e)=>t?Math.max(t,e):e;H=W($,H),H=W(k,H),H=W(D,H);const Y=H>-1?1:0;t.glyphOffsetArray.length>=65535&&pi("Too many glyphs being rendered in a tile. See https://github.com/mapbox/mapbox-gl-js/issues/2907"),void 0!==x.sortKey&&t.addToSortKeyRanges(t.symbolInstances.length,x.sortKey),t.symbolInstances.emplaceBack(e.x,e.y,V.x,V.y,V.z,U.right>=0?U.right:-1,U.center>=0?U.center:-1,U.left>=0?U.left:-1,U.vertical>=0?U.vertical:-1,F,N,j,void 0!==A?A:t.collisionBoxArray.length,void 0!==A?A+1:t.collisionBoxArray.length,void 0!==L?L:t.collisionBoxArray.length,void 0!==L?L+1:t.collisionBoxArray.length,void 0!==I?I:t.collisionBoxArray.length,void 0!==I?I+1:t.collisionBoxArray.length,P||t.collisionBoxArray.length,P?P+1:t.collisionBoxArray.length,d,O,B,z,R,Y,0,Z,q,H,0,1,1,G?1:0)}(t,a,_,s,i,n,r,z,t.layers[0],t.collisionBoxArray,e.index,e.sourceLayerIndex,t.index,S,C,l,0,E,A,g,e,o,c,d,u,p,f)};if("line"===I)for(const r of b_(e.geometry,0,0,uo,uo)){const e=v_(r,T,M,i.vertical||y,n,x,w,t.overscaling,uo);for(const i of e)y&&Q_(t,y.text,L,i)||R(r,i,u)}else if("line-center"===I){for(const t of e.geometry)if(t.length>1){const e=y_(t,M,i.vertical||y,n,x,w);e&&R(t,e,u)}}else if("Polygon"===e.type)for(const t of Zh(e.geometry,0)){const e=F_(t,16);R(t[0],new p_(e.x,e.y,0,0,void 0),u)}else if("LineString"===e.type)for(const t of e.geometry)R(t,new p_(t[0].x,t[0].y,0,0,void 0),u);else if("Point"===e.type)for(const t of e.geometry)for(const e of t)R([e],new p_(e.x,e.y,0,0,void 0),u)}const H_=255,W_=H_*Bm;function Y_(t,e,i,n,r,o,s,a,l,c,d,u,h,p,f,m,_,g){const y=function(t,e,i,n,r,o,s,a){const l=[];if(0===e.positionedLines.length)return l;const c=n.layout.get("text-rotate").evaluate(o,{})*Math.PI/180,d=function(t){const e=t[0],i=t[1],n=e*i;return n>0?[e,-i]:nW_&&pi(`${t.layerIds[0]}: Value for "text-size" is >= ${H_}. Reduce your "text-size".`)):"composite"===v.kind&&(x=[Bm*f.compositeTextSizes[0].evaluate(a,{},_),Bm*f.compositeTextSizes[1].evaluate(a,{},_)],(x[0]>W_||x[1]>W_)&&pi(`${t.layerIds[0]}: Value for "text-size" is >= ${H_}. Reduce your "text-size".`)),t.addSymbols(t.text,y,x,l,s,a,d,e,i,c.lineStartIndex,c.lineLength,p,m,_,g,!1);for(const e of u)h[e]=t.text.placedSymbolArray.length-1;return 4*y.length}function X_(t){for(const e in t)return t[e];return null}function K_(t,e,i,n,r,o,s,a,l,c){let d=s.top,u=s.bottom,h=s.left,p=s.right;const f=s.collisionPadding;if(f&&(h-=f[0],d-=f[1],p+=f[2],u+=f[3]),l){const t=new Ue(h,d),e=new Ue(p,d),i=new Ue(h,u),n=new Ue(p,u),r=Ge(l);let o=new Ue(0,0);c&&(o=new Ue(c[0],c[1])),t._rotateAround(r,o),e._rotateAround(r,o),i._rotateAround(r,o),n._rotateAround(r,o),h=Math.min(t.x,e.x,i.x,n.x),p=Math.max(t.x,e.x,i.x,n.x),d=Math.min(t.y,e.y,i.y,n.y),u=Math.max(t.y,e.y,i.y,n.y)}return t.emplaceBack(e.x,e.y,e.z,i.x,i.y,h,d,p,u,a,n,r,o),t.length-1}function J_(t){t.collisionPadding&&(t.top-=t.collisionPadding[1],t.bottom+=t.collisionPadding[3]);const e=t.bottom-t.top;return e>0?Math.max(10,e):null}function Q_(t,e,i,n){const r=t.compareText;if(e in r){const t=r[e];for(let e=t.length-1;e>=0;e--)if(n.dist(t[e])v&&(x(t,c,n,r,a,l),x(c,i,a,l,o,s))}x(u,h,n,o,r,o),x(h,p,r,o,r,s),x(p,f,r,s,n,s),x(f,u,n,s,n,o),m-=v,_-=v,g+=v,y+=v;const b=1/Math.max(g-m,y-_);return{scale:b,x:m*b,y:_*b,x2:g*b,y2:y*b,projection:e}}function ig(t,{x:e,y:i},n=0){return new Ue(((e-n)*t.scale-t.x)*uo,(i*t.scale-t.y)*uo)}const ng=t.ad.identity(new Float32Array(16));class rg{constructor(t){this.spec=t,this.name=t.name,this.wrap=!1,this.requiresDraping=!1,this.supportsWorldCopies=!1,this.supportsTerrain=!1,this.supportsFog=!1,this.supportsFreeCamera=!1,this.zAxisUnit="meters",this.isReprojectedInTileSpace=!0,this.unsupportedLayers=["custom"],this.center=[0,0],this.range=[3.5,7]}project(t,e){return{x:0,y:0,z:0}}unproject(t,e){return new pd(0,0)}projectTilePoint(t,e,i){return{x:t,y:e,z:0}}locationPoint(t,e,i=!0){return t._coordinatePoint(t.locationCoordinate(e),i)}pixelsPerMeter(t,e){return Cd(1,t)*e}pixelSpaceConversion(t,e,i){return 1}farthestPixelDistance(t){return tg(t,t.pixelsPerMeter)}pointCoordinate(t,e,i,n){const r=t.horizonLineFromTop(!1),o=new Ue(e,Math.max(r,i));return t.rayIntersectionCoordinate(t.pointRayIntersection(o,n))}pointCoordinate3D(t,e,i){const n=new Ue(e,i);if(t.elevation)return t.elevation.pointCoordinate(n);{const e=this.pointCoordinate(t,n.x,n.y,0);return[e.x,e.y,e.z]}}isPointAboveHorizon(t,e){if(t.elevation&&t.elevation.visibleDemTiles.length)return!this.pointCoordinate3D(t,e.x,e.y);const i=t.horizonLineFromTop();return e.y0?epg-i&&(e=pg-i);const o=r/Math.pow(fg(e),n);let s=o*Math.sin(n*t),a=r-o*Math.cos(n*t);return s=.5*(s/Math.PI+.5),a=.5*(a/Math.PI+.5),{x:s,y:this.southernCenter?a:1-a,z:0}}unproject(t,e){t=(2*t-.5)*Math.PI,this.southernCenter&&(e=1-e),e=(2*(1-e)-.5)*Math.PI;const{n:i,f:n}=this,r=n-e,o=Math.sign(r),s=Math.sign(i)*Math.sqrt(t*t+r*r);let a=Math.atan2(t,Math.abs(r))*o;r*i1e-6&&--n>0);o=i*i;const s=Xe(Ze(t/(.8707+o*(o*(o*o*o*(.003971-.001529*o)-.013791)-.131979))),-180,180),a=Ze(i);return new pd(s,a)}}const vg=Ge(Pd);class xg extends rg{project(t,e){e=Ge(e),t=Ge(t);const i=Math.cos(e),n=2/Math.PI,r=Math.acos(i*Math.cos(t/2)),o=Math.sin(r)/r,s=.5*(t*n+2*i*Math.sin(t/2)/o)||0,a=.5*(e+Math.sin(e)/o)||0;return{x:.5*(s/Math.PI+.5),y:1-.5*(a/Math.PI+1),z:0}}unproject(t,e){let i=t=(2*t-.5)*Math.PI,n=e=(2*(1-e)-1)*Math.PI,r=25;const o=1e-6;let s=0,a=0;do{const r=Math.cos(n),o=Math.sin(n),l=2*o*r,c=o*o,d=r*r,u=Math.cos(i/2),h=Math.sin(i/2),p=2*u*h,f=h*h,m=1-d*u*u,_=m?1/m:0,g=m?Math.acos(r*u)*Math.sqrt(1/m):0,y=.5*(2*g*r*h+2*i/Math.PI)-t,v=.5*(g*o+n)-e,x=.5*_*(d*f+g*r*u*c)+1/Math.PI,b=_*(p*l/4-g*o*h),w=.125*_*(l*h-g*o*d*p),T=.5*_*(c*u+g*f*r)+.5,S=b*w-T*x;s=(v*b-y*T)/S,a=(y*w-v*x)/S,i=Xe(i-s,-Math.PI,Math.PI),n=Xe(n-a,-vg,vg)}while((Math.abs(s)>o||Math.abs(a)>o)&&--r>0);return new pd(Ze(i),Ze(n))}}class bg extends rg{constructor(t){super(t),this.center=t.center||[0,0],this.parallels=t.parallels||[0,0],this.cosPhi=Math.max(.01,Math.cos(Ge(this.parallels[0]))),this.scale=1/(2*Math.max(Math.PI*this.cosPhi,1/this.cosPhi)),this.wrap=!0,this.supportsWorldCopies=!0}project(t,e){const{scale:i,cosPhi:n}=this;return{x:Ge(t)*n*i+.5,y:-Math.sin(Ge(e))/n*i+.5,z:0}}unproject(t,e){const{scale:i,cosPhi:n}=this,r=-(e-.5)/i,o=Xe(Ze((t-.5)/i)/n,-180,180),s=Math.asin(Xe(r*n,-1,1)),a=Xe(Ze(s),-Pd,Pd);return new pd(o,a)}}class wg extends _g{constructor(t){super(t),this.requiresDraping=!0,this.supportsWorldCopies=!1,this.supportsFog=!0,this.zAxisUnit="pixels",this.unsupportedLayers=["debug"],this.range=[3,5]}projectTilePoint(e,i,n){const r=Fu(e,i,n),o=ju($u(n));return t._.transformMat4(r,r,o),{x:r[0],y:r[1],z:r[2]}}locationPoint(e,i){const n=dd(i.lat,i.lng),r=t._.normalize([],n),o=e.elevation?e.elevation.getAtPointOrZero(e.locationCoordinate(i),e._centerAltitude):e._centerAltitude,s=Cd(1,0)*uo*o;t._.scaleAndAdd(n,n,r,s);const a=t.ad.identity(new Float64Array(16));return t.ad.multiply(a,e.pixelMatrix,e.globeMatrix),t._.transformMat4(n,n,a),new Ue(n[0],n[1])}pixelsPerMeter(t,e){return Cd(1,0)*e}pixelSpaceConversion(t,e,i){const n=Cd(1,t)*e,r=Vn(Cd(1,45)*e,n,i);return this.pixelsPerMeter(t,e)/r}createTileMatrix(e,i,n){const r=Vu($u(n.canonical));return t.ad.multiply(new Float64Array(16),e.globeMatrix,r)}createInversionMatrix(e,i){const{center:n}=e,r=ju($u(i));return t.ad.rotateY(r,r,Ge(n.lng)),t.ad.rotateX(r,r,Ge(n.lat)),t.ad.scale(r,r,[e._pixelsPerMercatorPixel,e._pixelsPerMercatorPixel,1]),Float32Array.from(r)}pointCoordinate(t,e,i,n){return Iu(t,e,i,!0)||new Rd(0,0)}pointCoordinate3D(t,e,i){const n=this.pointCoordinate(t,e,i,0);return[n.x,n.y,n.z]}isPointAboveHorizon(t,e){return!Iu(t,e.x,e.y,!1)}farthestPixelDistance(e){const i=function(e,i){const n=e.cameraToCenterDistance,r=e._centerAltitude*i,o=e._camera,s=e._camera.forward(),a=t._.add([],t._.scale([],s,-n),[0,0,r]),l=e.worldSize/(2*Math.PI),c=[0,0,-l],d=e.width/e.height,u=Math.tan(e.fovAboveCenter),h=t._.scale([],o.up(),u),p=t._.scale([],o.right(),u*d),f=t._.normalize([],t._.add([],t._.add([],s,h),p)),m=[];let _;if(new mu(a,f).closestPointOnSphere(c,l,m)){const i=t._.add([],m,c),n=t._.sub([],i,a);_=Math.cos(e.fovAboveCenter)*t._.length(n)}else{const e=t._.sub([],a,c),i=t._.sub([],c,a);t._.normalize(i,i);const n=t._.length(e)-l;_=Math.sqrt(n*(n+2*l));const r=Math.acos(_/(l+n))-Math.acos(t._.dot(s,i));_*=Math.cos(r)}return 1.01*_}(e,this.pixelsPerMeter(e.center.lat,e.worldSize)),n=Hu(e.zoom);if(n>0){const t=tg(e,Cd(1,e.center.lat)*e.worldSize),r=e.worldSize/(2*Math.PI),o=Math.max(e.width,e.height)/e.worldSize*Math.PI;return Vn(i,t+r*(1-Math.cos(o)),Math.pow(n,10))}return i}upVector(t,e,i){return Fu(e,i,t,1)}upVectorScale(t){return{metersToTile:Cu(Nu($u(t)))}}}function Tg(t){const e=t.parallels,i=!!e&&Math.abs(e[0]+e[1])0&&(this.iconTransitioningVertexBuffer=t.createVertexBuffer(this.iconTransitioningVertexArray,Vf.members,!0)),this.globeExtVertexArray.length>0&&(this.globeExtVertexBuffer=t.createVertexBuffer(this.globeExtVertexArray,Ff.members,!0)),!this.zOffsetVertexBuffer&&(this.zOffsetVertexArray.length>0||r)&&(this.zOffsetVertexBuffer=t.createVertexBuffer(this.zOffsetVertexArray,jf.members,!0)),this.opacityVertexBuffer.itemSize=1),(i||n)&&this.programConfigurations.upload(t))}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy(),this.dynamicLayoutVertexBuffer.destroy(),this.opacityVertexBuffer.destroy(),this.occlusionQueryOpacityVertexBuffer.destroy(),this.iconTransitioningVertexBuffer&&this.iconTransitioningVertexBuffer.destroy(),this.globeExtVertexBuffer&&this.globeExtVertexBuffer.destroy(),this.zOffsetVertexBuffer&&this.zOffsetVertexBuffer.destroy())}}ba(Ng,"SymbolBuffers");class Ug{constructor(t,e,i){this.layoutVertexArray=new t,this.layoutAttributes=e,this.indexArray=new i,this.segments=new wc,this.collisionVertexArray=new Xl,this.collisionVertexArrayExt=new Ol}upload(t){this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,this.layoutAttributes),this.indexBuffer=t.createIndexBuffer(this.indexArray),this.collisionVertexBuffer=t.createVertexBuffer(this.collisionVertexArray,Gf.members,!0),this.collisionVertexBufferExt=t.createVertexBuffer(this.collisionVertexArrayExt,Zf.members,!0)}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.segments.destroy(),this.collisionVertexBuffer.destroy(),this.collisionVertexBufferExt.destroy())}}ba(Ug,"CollisionBuffers");class jg{constructor(e){this.queries=new Map,this.collisionBoxArray=e.collisionBoxArray,this.zoom=e.zoom,this.lut=e.lut,this.overscaling=e.overscaling,this.layers=e.layers,this.layerIds=this.layers.map((t=>t.fqid)),this.index=e.index,this.pixelRatio=e.pixelRatio,this.sourceLayerIndex=e.sourceLayerIndex,this.hasPattern=!1,this.hasRTLText=!1,this.fullyClipped=!1,this.hasAnyIconTextFit=!1,this.sortKeyRanges=[],this.collisionCircleArray=[],this.placementInvProjMatrix=t.ad.identity([]),this.placementViewportMatrix=t.ad.identity([]);const i=this.layers[0]._unevaluatedLayout._values;this.textSizeData=Fm(this.zoom,i["text-size"]),this.iconSizeData=Fm(this.zoom,i["icon-size"]);const n=this.layers[0].layout,r=n.get("symbol-sort-key"),o=n.get("symbol-z-order");this.canOverlap=n.get("text-allow-overlap")||n.get("icon-allow-overlap")||n.get("text-ignore-placement")||n.get("icon-ignore-placement"),this.sortFeaturesByKey="viewport-y"!==o&&void 0!==r.constantOr(1),this.sortFeaturesByY=("viewport-y"===o||"auto"===o&&!this.sortFeaturesByKey)&&this.canOverlap,this.writingModes=n.get("text-writing-mode").map((t=>Jm[t])),this.stateDependentLayerIds=this.layers.filter((t=>t.isStateDependent())).map((t=>t.id)),this.sourceID=e.sourceID,this.projection=e.projection,this.hasAnyZOffset=!1,this.zOffsetSortDirty=!1,this.zOffsetBuffersNeedUpload=n.get("symbol-z-elevate"),this.activeReplacements=[],this.replacementUpdateTime=0}createArrays(){this.text=new Ng(new Yc(this.layers,{zoom:this.zoom,lut:this.lut},(t=>/^text/.test(t)))),this.icon=new Ng(new Yc(this.layers,{zoom:this.zoom,lut:this.lut},(t=>/^icon/.test(t)))),this.glyphOffsetArray=new mc,this.lineVertexArray=new _c,this.symbolInstances=new fc}calculateGlyphDependencies(t,e,i,n,r){for(let i=0;i0)&&("constant"!==l.value.kind||l.value.value.length>0),h="constant"!==d.value.kind||!!d.value.value||Object.keys(d.parameters).length>0,p=s.get("symbol-sort-key");if(this.features=[],!u&&!h)return;const f=i.iconDependencies,m=i.glyphDependencies,_=i.availableImages,g=new Ha(this.zoom);for(const{feature:i,id:c,index:d,sourceLayerIndex:y}of e){const e=o._featureFilter.needGeometry,v=Zd(i,e);if(!o._featureFilter.filter(g,v,n))continue;if(e||(v.geometry=Gd(i,n,r)),a&&1!==i.type&&n.z{const o=Fu(e.x,e.y,n,1),s=Fu(r.x,r.y,n,1);return t._.dot(o,s)=0;for(const i of x.sections)if(i.image)f[i.image.namePrimary]=!0;else{const n=Ca(x.toString()),r=i.fontStack||t,o=m[r]=m[r]||{};this.calculateGlyphDependencies(i.text,o,e,this.allowVerticalPlacement,n)}}}"line"===s.get("symbol-placement")&&(this.features=function(t){const e={},i={},n=[];let r=0;function o(e){n.push(t[e]),r++}function s(t,e,r){const o=i[t];return delete i[t],i[e]=o,n[o].geometry[0].pop(),n[o].geometry[0]=n[o].geometry[0].concat(r[0]),o}function a(t,i,r){const o=e[i];return delete e[i],e[t]=o,n[o].geometry[0].shift(),n[o].geometry[0]=r[0].concat(n[o].geometry[0]),o}function l(t,e,i){const n=i?e[0][e[0].length-1]:e[0][0];return`${t}:${n.x}:${n.y}`}for(let c=0;ct.geometry))}(this.features)),this.sortFeaturesByKey&&this.features.sort(((t,e)=>t.sortKey-e.sortKey))}update(t,e,i,n,r){const o=0!==Object.keys(t).length;if(o&&!this.stateDependentLayers.length)return;const s=o?this.stateDependentLayers:this.layers;this.text.programConfigurations.updatePaintArrays(t,e,s,i,n,r),this.icon.programConfigurations.updatePaintArrays(t,e,s,i,n,r)}updateOcclusionOpacities(t,e,i){if(!e.useOcclusionQueries)return!1;const n=this;if("globe"===n.projection.name)return!1;let r=!1;n.hasTextData()&&(r=r||0!==n.text.occlusionQueryOpacityVertexArray.length),n.hasIconData()&&(r=r||0!==n.icon.occlusionQueryOpacityVertexArray.length);const o=n.layers[0].paint,s=o.get("icon-occlusion-opacity").constantOr(0),a=o.get("text-occlusion-opacity").constantOr(0);if(!n.layers[0].hasInitialOcclusionOpacityProperties||1===s&&1===a)return!1;let l=!r;for(let t=0;t.5?1:-1)*e.fadeSpeed*i*.001,r.occlusionOpacity=Xe(r.occlusionOpacity,0,1),l=l||r.occlusionOpacity!==o}if(!l)return!1;let c=0,d=0;const u=(t,e,i,n)=>{let r=0,o=0;i?(r=d,d+=n,o=d):(r=c,c+=n,o=c),o>e.occlusionQueryOpacityVertexArray.length&&e.occlusionQueryOpacityVertexArray.resize(o);const s=t.occlusionOpacity;for(let t=0;t0;if((i>0||r>0)&&(u(e,n.text,!1,i),u(e,n.text,!1,r)),s){const{placedIconSymbolIndex:t,verticalPlacedIconSymbolIndex:i}=e;t>=0&&u(e,n.icon,!0,o),i>=0&&u(e,n.icon,!0,e.numVerticalIconVertices)}}return n.hasTextData()&&n.text.occlusionQueryOpacityVertexBuffer&&(n.text.occlusionQueryOpacityVertexBuffer.length{i+=e,i>t.length&&t.resize(i);for(let r=-e;r{n+=e,n>t.length&&t.resize(n);for(let r=-e;r0;if((r>0||o>0)&&(t(this.text.zOffsetVertexArray,r,a),t(this.text.zOffsetVertexArray,o,a)),l){const{placedIconSymbolIndex:t,verticalPlacedIconSymbolIndex:i}=n;t>=0&&e(this.icon.zOffsetVertexArray,s,a),i>=0&&e(this.icon.zOffsetVertexArray,n.numVerticalIconVertices,a)}}this.text.zOffsetVertexBuffer&&this.text.zOffsetVertexBuffer.updateData(this.text.zOffsetVertexArray),this.icon.zOffsetVertexBuffer&&this.icon.zOffsetVertexBuffer.updateData(this.icon.zOffsetVertexArray)}isEmpty(){return 0===this.symbolInstances.length&&!this.hasRTLText}uploadPending(){return!this.uploaded||this.text.programConfigurations.needsUpload||this.icon.programConfigurations.needsUpload}upload(t){!this.uploaded&&this.hasDebugData()&&(this.textCollisionBox.upload(t),this.iconCollisionBox.upload(t)),this.text.upload(t,this.sortFeaturesByY,!this.uploaded,this.text.programConfigurations.needsUpload,this.zOffsetBuffersNeedUpload),this.icon.upload(t,this.sortFeaturesByY,!this.uploaded,this.icon.programConfigurations.needsUpload,this.zOffsetBuffersNeedUpload),this.uploaded=!0}destroyDebugData(){this.textCollisionBox.destroy(),this.iconCollisionBox.destroy()}getProjection(){return this.projectionInstance||(this.projectionInstance=Tg(this.projection)),this.projectionInstance}destroy(){this.text.destroy(),this.icon.destroy(),this.hasDebugData()&&this.destroyDebugData();for(const t of this.queries.values())t.destroy()}addToLineVertexArray(t,e){const i=this.lineVertexArray.length;if(void 0!==t.segment)for(const{x:t,y:i}of e)this.lineVertexArray.emplaceBack(t,i);return{lineStartIndex:i,lineLength:this.lineVertexArray.length-i}}addSymbols(t,e,i,n,r,o,s,a,l,c,d,u,h,p,f,m){const _=t.indexArray,g=t.layoutVertexArray,y=t.globeExtVertexArray,v=t.segments.prepareSegment(4*e.length,g,_,this.canOverlap?o.sortKey:void 0),x=this.glyphOffsetArray.length,b=v.vertexLength,w=this.allowVerticalPlacement&&s===Jm.vertical?Math.PI/2:0,T=o.text&&o.text.sections;for(let n=0;n=0?e.rightJustifiedTextSymbolIndex:e.centerJustifiedTextSymbolIndex>=0?e.centerJustifiedTextSymbolIndex:e.leftJustifiedTextSymbolIndex>=0?e.leftJustifiedTextSymbolIndex:e.verticalPlacedTextSymbolIndex>=0?e.verticalPlacedTextSymbolIndex:n),o=Nm(this.textSizeData,t,r)/Om;return this.tilePixelRatio*o}getSymbolInstanceIconSize(t,e,i){const n=this.icon.placedSymbolArray.get(i),r=Nm(this.iconSizeData,t,n);return this.tilePixelRatio*r}_commitDebugCollisionVertexUpdate(t,e,i,n){t.emplaceBack(e,-i,-i,n),t.emplaceBack(e,i,-i,n),t.emplaceBack(e,i,i,n),t.emplaceBack(e,-i,i,n)}_updateTextDebugCollisionBoxes(t,e,i,n,r,o){for(let s=n;s0}hasIconData(){return this.icon.segments.get().length>0}hasDebugData(){return this.textCollisionBox&&this.iconCollisionBox}hasTextCollisionBoxData(){return this.hasDebugData()&&this.textCollisionBox.segments.get().length>0}hasIconCollisionBoxData(){return this.hasDebugData()&&this.iconCollisionBox.segments.get().length>0}hasIconTextFit(){return this.hasAnyIconTextFit}addIndicesForPlacedSymbol(t,e){const i=t.placedSymbolArray.get(e),n=i.vertexStartIndex+4*i.numGlyphs;for(let e=i.vertexStartIndex;en[t]-n[e]||r[e]-r[t])),o}getSortedIndexesByZOffset(){if(!this.zOffsetSortDirty)return this.symbolInstanceIndexesSortedZOffset;if(!this.symbolInstanceIndexesSortedZOffset){this.symbolInstanceIndexesSortedZOffset=[];for(let t=0;tthis.symbolInstances.get(e).zOffset-this.symbolInstances.get(t).zOffset))}addToSortKeyRanges(t,e){const i=this.sortKeyRanges[this.sortKeyRanges.length-1];i&&i.sortKey===e?i.symbolInstanceEnd=t+1:this.sortKeyRanges.push({sortKey:e,symbolInstanceStart:t,symbolInstanceEnd:t+1})}sortFeatures(t){if(this.sortFeaturesByY&&this.sortedAngle!==t&&!(this.text.segments.get().length>1||this.icon.segments.get().length>1)){this.symbolInstanceIndexes=this.getSortedSymbolIndexes(t),this.sortedAngle=t,this.text.indexArray.clear(),this.icon.indexArray.clear(),this.featureSortOrder=[];for(const t of this.symbolInstanceIndexes){const e=this.symbolInstances.get(t);this.featureSortOrder.push(e.featureIndex);const{rightJustifiedTextSymbolIndex:i,centerJustifiedTextSymbolIndex:n,leftJustifiedTextSymbolIndex:r,verticalPlacedTextSymbolIndex:o,placedIconSymbolIndex:s,verticalPlacedIconSymbolIndex:a}=e;i>=0&&this.addIndicesForPlacedSymbol(this.text,i),n>=0&&n!==i&&this.addIndicesForPlacedSymbol(this.text,n),r>=0&&r!==n&&r!==i&&this.addIndicesForPlacedSymbol(this.text,r),o>=0&&this.addIndicesForPlacedSymbol(this.text,o),s>=0&&this.addIndicesForPlacedSymbol(this.icon,s),a>=0&&this.addIndicesForPlacedSymbol(this.icon,a)}this.text.indexBuffer&&this.text.indexBuffer.updateData(this.text.indexArray),this.icon.indexBuffer&&this.icon.indexBuffer.updateData(this.icon.indexArray)}}}ba(jg,"SymbolBucket",{omit:["layers","collisionBoxArray","features","compareText"]}),jg.addDynamicAttributes=Bg;class Vg{constructor(t,e,i,n){this.context=t,this.format=i,this.texture=t.gl.createTexture(),this.update(e,n)}update(t,e,i){const{width:n,height:r}=t,{context:o}=this,{gl:s}=o;if(s.bindTexture(s.TEXTURE_2D,this.texture),o.pixelStoreUnpackFlipY.set(!1),o.pixelStoreUnpack.set(1),o.pixelStoreUnpackPremultiplyAlpha.set(this.format===s.RGBA&&(!e||!1!==e.premultiply)),this.useMipmap=Boolean(e&&e.useMipmap),i||this.size&&this.size[0]===n&&this.size[1]===r){const{x:e,y:o}=i||{x:0,y:0};if(t instanceof HTMLImageElement||t instanceof HTMLCanvasElement||t instanceof HTMLVideoElement||t instanceof ImageData||ImageBitmap&&t instanceof ImageBitmap)s.texSubImage2D(s.TEXTURE_2D,0,e,o,s.RGBA,s.UNSIGNED_BYTE,t);else{let i=this.format,a=s.UNSIGNED_BYTE;this.format===s.R32F&&(i=s.RED,a=s.FLOAT),s.texSubImage2D(s.TEXTURE_2D,0,e,o,n,r,i,a,t.data)}}else if(this.size=[n,r],t instanceof HTMLImageElement||t instanceof HTMLCanvasElement||t instanceof HTMLVideoElement||t instanceof ImageData||ImageBitmap&&t instanceof ImageBitmap){let e=this.format;this.format===s.R8&&(e=s.RED),s.texImage2D(s.TEXTURE_2D,0,this.format,e,s.UNSIGNED_BYTE,t)}else{let e=this.format,i=this.format,o=s.UNSIGNED_BYTE,a=!1;this.format===s.DEPTH_COMPONENT&&(e=s.DEPTH_COMPONENT16,o=s.UNSIGNED_SHORT),this.format===s.DEPTH_STENCIL&&(e=s.DEPTH24_STENCIL8,o=s.UNSIGNED_INT_24_8,a=!0),this.format===s.R8&&(i=s.RED),this.format===s.R32F&&(o=s.FLOAT,i=s.RED),!this.useMipmap&&a?s.texStorage2D(s.TEXTURE_2D,1,e,n,r):s.texImage2D(s.TEXTURE_2D,0,e,n,r,0,i,o,t.data)}this.useMipmap&&s.generateMipmap(s.TEXTURE_2D)}bind(t,e,i=!1){const{context:n}=this,{gl:r}=n;r.bindTexture(r.TEXTURE_2D,this.texture),t!==this.minFilter&&(r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MAG_FILTER,t),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MIN_FILTER,this.useMipmap&&!i?t===r.NEAREST?r.NEAREST_MIPMAP_NEAREST:r.LINEAR_MIPMAP_LINEAR:t),this.minFilter=t),e!==this.wrapS&&(r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_S,e),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_T,e),this.wrapS=e)}bindExtraParam(t,e,i,n){const{context:r}=this,{gl:o}=r;o.bindTexture(o.TEXTURE_2D,this.texture),e!==this.magFilter&&(o.texParameteri(o.TEXTURE_2D,o.TEXTURE_MAG_FILTER,e),this.magFilter=e),t!==this.minFilter&&(o.texParameteri(o.TEXTURE_2D,o.TEXTURE_MIN_FILTER,this.useMipmap?t===o.NEAREST?o.NEAREST_MIPMAP_NEAREST:o.LINEAR_MIPMAP_LINEAR:t),this.minFilter=t),i!==this.wrapS&&(o.texParameteri(o.TEXTURE_2D,o.TEXTURE_WRAP_S,i),this.wrapS=i),n!==this.wrapT&&(o.texParameteri(o.TEXTURE_2D,o.TEXTURE_WRAP_T,n),this.wrapT=n)}destroy(){const{gl:t}=this.context;t.deleteTexture(this.texture),this.texture=null}}class Gg{constructor(t,e){this.context=t,this.texture=e}bind(t,e){const{context:i}=this,{gl:n}=i;n.bindTexture(n.TEXTURE_2D,this.texture),t!==this.minFilter&&(n.texParameteri(n.TEXTURE_2D,n.TEXTURE_MAG_FILTER,t),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_MIN_FILTER,t),this.minFilter=t),e!==this.wrapS&&(n.texParameteri(n.TEXTURE_2D,n.TEXTURE_WRAP_S,e),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_WRAP_T,e),this.wrapS=e)}}const Zg=32,qg=33,Hg=new Uint16Array(8184);for(let t=0;t>=1)>1;){const t=i+r>>1,l=n+o>>1;1&e?(r=i,o=n,i=s,n=a):(i=r,n=o,r=s,o=a),s=t,a=l}const l=4*t;Hg[l+0]=i,Hg[l+1]=n,Hg[l+2]=r,Hg[l+3]=o}const Wg=new Uint16Array(2178),Yg=new Uint8Array(1089),Xg=new Uint16Array(1089);function Kg(t){return 0===t?-.03125:32===t?.03125:0}var Jg=Ll([{name:"a_pos",type:"Int16",components:2},{name:"a_texture_pos",type:"Int16",components:2}]),Qg=Ll([{name:"a_index",type:"Int16",components:1}]);const ty={type:2,extent:uo,loadGeometry:()=>[[new Ue(0,0),new Ue(uo+1,0),new Ue(uo+1,uo+1),new Ue(0,uo+1),new Ue(0,0)]]};class ey{constructor(t,e,i,n,r){this.tileID=t,this.uid=ni(),this.uses=0,this.tileSize=e,this.tileZoom=i,this.buckets={},this.expirationTime=null,this.queryPadding=0,this.hasSymbolBuckets=!1,this.hasRTLText=!1,this.dependencies={},this.isRaster=r,n&&n.style&&(this._lastUpdatedBrightness=n.style.getBrightness()),this.expiredRequestCount=0,this.state="loading",n&&n.transform&&(this.projection=n.transform.projection)}registerFadeDuration(t){const e=t+this.timeAdded;ee.getLayer(t))).filter(Boolean);if(0!==t.length){n.layers=t,n.stateDependentLayerIds&&(n.stateDependentLayers=n.stateDependentLayerIds.map((e=>t.filter((t=>t.id===e))[0])));for(const e of t)i[e.fqid]=n}}return i}(t.buckets,e.style),this.hasSymbolBuckets=!1;for(const t in this.buckets){const e=this.buckets[t];if(e instanceof jg){if(this.hasSymbolBuckets=!0,!i)break;e.justReloaded=!0}}if(this.hasRTLText=!1,this.hasSymbolBuckets)for(const t in this.buckets){const e=this.buckets[t];if(e instanceof jg&&e.hasRTLText){this.hasRTLText=!0,qa.isLoading()||qa.isLoaded()||"deferred"!==Ga()||Za();break}}this.queryPadding=0;for(const t in this.buckets){const i=this.buckets[t],n=e.style.getOwnLayer(t);if(!n)continue;const r=n.queryRadius(i);this.queryPadding=Math.max(this.queryPadding,r)}t.imageAtlas&&(this.imageAtlas=t.imageAtlas),t.glyphAtlasImage&&(this.glyphAtlasImage=t.glyphAtlasImage),t.lineAtlas&&(this.lineAtlas=t.lineAtlas),this._lastUpdatedBrightness=t.brightness}else this.collisionBoxArray=new dc}unloadVectorData(){if(this.hasData()){for(const t in this.buckets)this.buckets[t].destroy();this.buckets={},this.imageAtlas&&(this.imageAtlas=null),this.lineAtlas&&(this.lineAtlas=null),this.imageAtlasTexture&&this.imageAtlasTexture.destroy(),this.glyphAtlasTexture&&this.glyphAtlasTexture.destroy(),this.lineAtlasTexture&&this.lineAtlasTexture.destroy(),this._tileBoundsBuffer&&(this._tileBoundsBuffer.destroy(),this._tileBoundsIndexBuffer.destroy(),this._tileBoundsSegments.destroy(),this._tileBoundsBuffer=null),this._tileDebugBuffer&&(this._tileDebugBuffer.destroy(),this._tileDebugSegments.destroy(),this._tileDebugBuffer=null),this._tileDebugIndexBuffer&&(this._tileDebugIndexBuffer.destroy(),this._tileDebugIndexBuffer=null),this._globeTileDebugBorderBuffer&&(this._globeTileDebugBorderBuffer.destroy(),this._globeTileDebugBorderBuffer=null),this._tileDebugTextBuffer&&(this._tileDebugTextBuffer.destroy(),this._tileDebugTextSegments.destroy(),this._tileDebugTextIndexBuffer.destroy(),this._tileDebugTextBuffer=null),this._globeTileDebugTextBuffer&&(this._globeTileDebugTextBuffer.destroy(),this._globeTileDebugTextBuffer=null),this.latestFeatureIndex=null,this.state="unloaded"}}getBucket(t){return this.buckets[t.fqid]}upload(t){for(const e in this.buckets){const i=this.buckets[e];i.uploadPending()&&i.upload(t)}const e=t.gl,i=this.imageAtlas;if(i&&!i.uploaded){const n=!!Object.keys(i.patternPositions).length;this.imageAtlasTexture=new Vg(t,i.image,e.RGBA,{useMipmap:n}),this.imageAtlas.uploaded=!0}this.glyphAtlasImage&&(this.glyphAtlasTexture=new Vg(t,this.glyphAtlasImage,e.R8),this.glyphAtlasImage=null),this.lineAtlas&&!this.lineAtlas.uploaded&&(this.lineAtlasTexture=new Vg(t,this.lineAtlas.image,e.R8),this.lineAtlas.uploaded=!0)}prepare(t,e,i){if(this.imageAtlas&&this.imageAtlasTexture&&this.imageAtlas.patchUpdatedImages(t,this.imageAtlasTexture,i),!e||!this.latestFeatureIndex||!this.latestFeatureIndex.rawTileData)return;const n=e.style.getBrightness();(this._lastUpdatedBrightness||n)&&(this._lastUpdatedBrightness&&n&&Math.abs(this._lastUpdatedBrightness-n)t)i=!1;else if(e)if(this.expirationTime=0;t--){const e=4*t,i=Hg[e+0],n=Hg[e+1],r=Hg[e+2],o=Hg[e+3],s=i+r>>1,a=n+o>>1,l=s+a-n,c=a+i-s,d=n*qg+i,u=o*qg+r,h=a*qg+s,p=Math.hypot((Wg[2*d+0]+Wg[2*u+0])/2-Wg[2*h+0],(Wg[2*d+1]+Wg[2*u+1])/2-Wg[2*h+1])>=16;Yg[h]=Yg[h]||(p?1:0),t>1)*qg+(i+l>>1)]||Yg[(o+c>>1)*qg+(r+l>>1)])}const r=new Dl,o=new Kl;let s=0;function a(t,e){const i=e*qg+t;return 0===Xg[i]&&(r.emplaceBack(Wg[2*i+0],Wg[2*i+1],t*uo/Zg,e*uo/Zg),Xg[i]=++s),Xg[i]-1}function l(t,e,i,n,r,s){const c=t+i>>1,d=e+n>>1;if(Math.abs(t-r)+Math.abs(e-s)>1&&Yg[d*qg+c])l(r,s,t,e,c,d),l(i,n,r,s,c,d);else{const l=a(t,e),c=a(i,n),d=a(r,s);o.emplaceBack(l,c,d)}}return l(0,0,Zg,Zg,Zg,0),l(Zg,Zg,0,0,0,Zg),{vertices:r,indices:o}}(this.tileID.canonical,e);n=t.vertices,r=t.indices}else{n=new Dl,r=new Kl;for(const{x:t,y:e}of i)n.emplaceBack(t,e,0,0);const t=xh(n.int16,void 0,4);for(let e=0;e0&&(a=t.ad.invert(new Float64Array(16),i.globeMatrix)),this._makeGlobeTileDebugBorderBuffer(e,r,i,o,a,s),this._makeGlobeTileDebugTextBuffer(e,r,i,o,a,s)}_globePoint(e,i,n,r,o,s,a){let l=Fu(e,i,n);if(s){const o=1.5?h=-1:u{const p=(d-t)/(h-1),f=(u-c)/(h-1),m=s.length;for(let d=0;dd*t+e;for(let t=0;t[t,this.get(t)]))}evict(t=!1){if(t||this.size>0){const t=this.first;delete this.items[t.key],0==--this.size?(this.first=null,this.last=null):(this.first=t.next,this.first.prev=null)}return this}expiresAt(t){let e;return this.has(t)&&(e=this.items[t].expiry),e}get(t){let e;if(this.has(t)){const i=this.items[t];this.ttl>0&&i.expiry0?Date.now()+this.ttl:this.ttl),this.last!==r){const t=this.last,e=r.next,i=r.prev;this.first===r&&(this.first=r.next),r.next=null,r.prev=this.last,t.next=r,null!==i&&(i.next=e),null!==e&&(e.prev=i)}}else this.max>0&&this.size===this.max&&this.evict(!0),r=this.items[t]={expiry:this.ttl>0?Date.now()+this.ttl:this.ttl,key:t,prev:this.last,next:null,value:e},1==++this.size?this.first=r:this.last.next=r;return this.last=r,this}values(t=this.keys()){return t.map((t=>this.get(t)))}}function uy(t,e){if(4!==e.length)throw new Error(`Expected data of dimension 4 but got ${e.length}.`);let i=e[3];for(let n=2;n>=1;n--){const r=1===n?1:0,o=2===n?1:0;for(let n=0;n>>1^-(1&t[e]);return t}function py(t,e){switch(e){case"uint32":return t;case"uint16":for(let e=0;e>4|(61440&i)>>8|(240&n)>4|(15&n)>6|(192&n)>>4|(192&r)>>2|192&o,t[e+1]=(48&i)>>4|(48&n)>>2|48&r|(48&o)>2|12&n|(12&r)>1|(21845&Cy)>2|(13107&Ay)>4|(3855&Ay)>8|(255&Ay)>1}var Iy=function(t,e,i){for(var n=t.length,r=0,o=new _y(e);r>l]=c}else for(s=new _y(n),r=0;r>15-t[r]);return s},Ly=new my(288);for(Cy=0;Cye&&(e=t[i]);return e},zy=function(t,e,i){var n=e/8|0;return(t[n]|t[n+1]>(7&e)&i},Ry=function(t,e){var i=e/8|0;return(t[i]|t[i+1]>(7&e)},Oy=["unexpected EOF","invalid block type","invalid length/literal","invalid distance","stream finished","no stream handler",,"no callback","invalid UTF-8 data","extra field too long","date not in range 1980-2099","filename too long","stream finishing","invalid zip data"],By=function(t,e,i){var n=new Error(e||Oy[t]);if(n.code=t,Error.captureStackTrace&&Error.captureStackTrace(n,By),!i)throw n;return n},Fy=new my(0),Ny="undefined"!=typeof TextDecoder&&new TextDecoder;try{Ny.decode(Fy,{stream:!0})}catch(t){}const Uy={gzip_data:"gzip"},jy={0:"uint32",1:"uint32",2:"uint16",3:"uint8"},Vy={uint32:1,uint16:2,uint8:4},Gy={uint32:Uint32Array,uint16:Uint16Array,uint8:Uint8Array};class Zy{constructor(t=1){this.x=NaN,this.y=NaN,this.z=NaN,this.layers={},this._cacheSize=t}getLayer(t){return this.layers[t]}getHeaderLength(t){const e=new Uint8Array(t),i=new DataView(t);if(13!==e[0])throw new fy("File is not a valid MRT.");return i.getUint32(1,!0)}parseHeader(t){const e=new Uint8Array(t),i=this.getHeaderLength(t);if(e.length= ${i} but got buffer of length ${e.length}`);const n=function(t){return t.readFields(iy,{header_length:0,x:0,y:0,z:0,layers:[]},void 0)}(new Lm(e.subarray(0,i)));if(!isNaN(this.x)&&(this.x!==n.x||this.y!==n.y||this.z!==n.z))throw new fy(`Invalid attempt to parse header ${n.z}/${n.x}/${n.y} for tile ${this.z}/${this.x}/${this.y}`);this.x=n.x,this.y=n.y,this.z=n.z;for(const t of n.layers)this.layers[t.name]=new qy(t,{cacheSize:this._cacheSize});return this}createDecodingTask(t){const e=[],i=this.getLayer(t.layerName);for(let n=0;nt.lastBlock)continue;if(i._blocksInProgress.has(n))continue;const a={layerName:i.name,firstByte:o,lastByte:s,pixelFormat:i.pixelFormat,blockIndex:n,blockShape:[r.bands.length].concat(i.bandShape),buffer:i.buffer,codec:r.codec.codec,filters:r.filters.map((t=>t.filter))};i._blocksInProgress.add(n),e.push(a)}return new Hy(e,(()=>{e.forEach((t=>i._blocksInProgress.delete(t.blockIndex)))}),((t,n)=>{if(e.forEach((t=>i._blocksInProgress.delete(t.blockIndex))),t)throw t;n.forEach((t=>{this.getLayer(t.layerName).processDecodedData(t)}))}))}}class qy{constructor({version:t,name:e,units:i,tilesize:n,pixel_format:r,buffer:o,data_index:s},a){if(this.version=t,1!==this.version)throw new fy(`Cannot parse raster layer encoded with MRT version ${t}`);this.name=e,this.units=i,this.tileSize=n,this.buffer=o,this.pixelFormat=jy[r],this.dataIndex=s,this.bandShape=[n+2*o,n+2*o,Vy[this.pixelFormat]],this._decodedBlocks=function(t=1e3,e=0,i=!1){if(isNaN(t)||t=e&&t=0}hasDataForBand(t){const{blockIndex:e}=this.getBlockForBand(t);return e>=0&&!!this._decodedBlocks.get(e.toString())}getBandView(t){const{blockIndex:e,blockBandIndex:i}=this.getBlockForBand(t),n=this._decodedBlocks.get(e.toString());if(!n)throw new fy(`Data for band ${JSON.stringify(t)} of layer "${this.name}" not decoded.`);const r=this.dataIndex[e],o=this.bandShape.reduce(((t,e)=>t*e),1),s=i*o,a=n.subarray(s,s+o);return{data:a,bytes:new Uint8Array(a.buffer).subarray(a.byteOffset,a.byteOffset+a.byteLength),tileSize:this.tileSize,buffer:this.buffer,offset:r.offset,scale:r.scale}}}class Hy{constructor(t,e,i){this.tasks=t,this._onCancel=e,this._onComplete=i,this._finalized=!1}cancel(){this._finalized||(this._onCancel(),this._finalized=!0)}complete(t,e){this._finalized||(this._onComplete(t,e),this._finalized=!0)}}Zy.performDecoding=function(t,e){return Promise.all(e.tasks.map((e=>{const{layerName:i,firstByte:n,lastByte:r,pixelFormat:o,blockShape:s,blockIndex:a,filters:l,codec:c}=e,d=new Uint8Array(t).subarray(n,r+1),u=new Uint32Array(s[0]*s[1]*s[2]);let h;if("gzip_data"!==c)throw new Error(`Unhandled codec: ${c}`);return h=function(t,e){if(!globalThis.DecompressionStream&&"gzip_data"===e)return Promise.resolve(((o=function(t){31==t[0]&&139==t[1]&&8==t[2]||By(6,"invalid gzip data");var e=t[3],i=10;4&e&&(i+=2+(t[10]|t[11]>3&1)+(e>>4&1);n>0;n-=!t[i++]);return i+(2&e)}(r=t))+8>r.length&&By(6,"invalid gzip data"),function(t,e,i){var n=t.length;if(!n||e.f&&!e.l)return i||new my(0);var r=!i,o=r||2!=e.i,s=e.i;r&&(i=new my(3*n));var a,l,c=function(t){var e=i.length;if(t>e){var n=new my(Math.max(2*e,t));n.set(i),i=n}},d=e.f||0,u=e.p||0,h=e.b||0,p=e.l,f=e.d,m=e.m,_=e.n,g=8*n;do{if(!p){d=zy(t,u,1);var y=zy(t,u+1,3);if(u+=3,!y){var v=t[(L=4+((u+7)/8|0))-4]|t[L-3]n){s&&By(0);break}o&&c(h+v),i.set(t.subarray(L,x),h),e.b=h+=v,e.p=u=8*x,e.f=d;continue}if(1==y)p=$y,f=ky,m=9,_=5;else if(2==y){var b=zy(t,u,31)+257,w=zy(t,u+10,15)+4,T=b+zy(t,u+5,31)+1;u+=14;for(var S=new my(T),E=new my(19),M=0;M>4)g){s&&By(0);break}}o&&c(h+131072);for(var R=(1>4;if((u+=15&$)>g){s&&By(0);break}if($||By(2),F264&&(N=zy(t,u,(1>4;if(U||By(3),u+=15&U,z=Ey[j],j>3){var V=vy[j];z+=Ry(t,u)&(1g){s&&By(0);break}o&&c(h+131072);var G=h+N;if(ha.length)&&(l=a.length),new my(a.subarray(0,l))):i.subarray(0,h)}(r.subarray(o,-8),{i:2},new my(((i=r)[(n=i.length)-4]|i[n-3]>>0))));var i,n,r,o;const s=Uy[e];if(!s)throw new Error(`Unhandled codec: ${e}`);const a=new globalThis.DecompressionStream(s);return new Response(new Blob([t]).stream().pipeThrough(a)).arrayBuffer().then((t=>new Uint8Array(t)))}(d,c).then((t=>(function(t,e){t.readFields(ly,e)}(new Lm(t),u),new(0,Gy[o])(u.buffer)))),h.then((t=>{for(let e=l.length-1;e>=0;e--)switch(l[e]){case"delta_filter":uy(t,s);break;case"zigzag_filter":hy(t);break;case"bitshuffle_filter":py(t,o);break;default:throw new Error(`Unhandled filter "${l[e]}"`)}return{layerName:i,blockIndex:a,data:t}})).catch((t=>{throw t}))})))};class Wy extends ey{constructor(t,e,i,n,r){super(t,e,i,n,r),this._workQueue=[],this._fetchQueue=[],this._isHeaderLoaded=!1}setTexture(t,e){const i=e.context,n=i.gl;this.texture=this.texture||e.getTileTexture(t.width),this.texture&&this.texture instanceof Vg?this.texture.update(t,{useMipmap:!1,premultiply:!1}):this.texture=new Vg(i,t,n.RGBA,{useMipmap:!1,premultiply:!1})}flushQueues(){for(;this._workQueue.length;)this._workQueue.pop()();for(;this._fetchQueue.length;)this._fetchQueue.pop()()}fetchHeader(t=16384,e){const i=this._mrt=new Zy(30),n=Object.assign({},this.requestParams,{headers:{Range:"bytes=0-"+(t-1)}});return this.entireBuffer=null,this.request=en(n,((n,r,o,s)=>{if(n)e(n);else try{const n=i.getHeaderLength(r);if(n>t)return void(this.request=this.fetchHeader(n,e));i.parseHeader(r),this._isHeaderLoaded=!0;let a=0;for(const t of Object.values(i.layers))a=Math.max(a,t.dataIndex[t.dataIndex.length-1].last_byte);r.byteLength>=a&&(this.entireBuffer=r),e(null,this.entireBuffer||r,o,s)}catch(t){e(t)}})),this.request}fetchBand(t,e,i){const n=this._mrt;if(!this._isHeaderLoaded||!n)return void i(new Error("Tile header is not ready"));const r=this.actor;if(!r)return void i(new Error("Can't fetch tile band without an actor"));let o;const s=(n,r)=>{o.complete(n,r),n?i(n):(this.updateTextureDescriptor(t,e),i(null,this.textureDescriptor&&this.textureDescriptor.img))},a=(t,e)=>{if(t)return i(t);const n=r.send("decodeRasterArray",{buffer:e,task:o},s,void 0,!0);this._workQueue.push((()=>{n&&n.cancel(),o.cancel()}))},l=n.getLayer(t);if(!l)return void i(new Error(`Unknown sourceLayer "${t}"`));if(l.hasDataForBand(e))return this.updateTextureDescriptor(t,e),void i(null,this.textureDescriptor?this.textureDescriptor.img:null);const c=l.getDataRange([e]);if(o=n.createDecodingTask(c),!o||o.tasks.length)if(this.flushQueues(),this.entireBuffer)a(null,this.entireBuffer.slice(c.firstByte,c.lastByte+1));else{const t=Object.assign({},this.requestParams,{headers:{Range:`bytes=${c.firstByte}-${c.lastByte}`}}),e=en(t,a);this._fetchQueue.push((()=>{e.cancel(),o.cancel()}))}else i(null)}updateNeeded(t,e){return(!this.textureDescriptor||this.textureDescriptor.band!==e||this.textureDescriptor.layer!==t)&&"errored"!==this.state}updateTextureDescriptor(t,e){if(!this._mrt)return;const i=this._mrt.getLayer(t);if(!i||!i.hasBand(e)||!i.hasDataForBand(e))return;const{bytes:n,tileSize:r,buffer:o,offset:s,scale:a}=i.getBandView(e),l=r+2*o,c={data:n,width:l,height:l},d=this.texture;d&&d instanceof Vg&&d.update(c,{useMipmap:!1,premultiply:!1}),this.textureDescriptor={layer:t,band:e,img:c,buffer:o,offset:s,tileSize:r,format:i.pixelFormat,mix:[a,256*a,65536*a,16777216*a]}}}class Yy{constructor(t,e){this.max=t,this.onRemove=e,this.reset()}reset(){for(const t in this.data)for(const e of this.data[t])e.timeout&&clearTimeout(e.timeout),this.onRemove(e.value);return this.data={},this.order=[],this}add(t,e,i){const n=t.wrapped().key;void 0===this.data[n]&&(this.data[n]=[]);const r={value:e,timeout:void 0};if(void 0!==i&&(r.timeout=setTimeout((()=>{this.remove(t,r)}),i)),this.data[n].push(r),this.order.push(n),this.order.length>this.max){const t=this._getAndRemoveByKey(this.order[0]);t&&this.onRemove(t)}return this}has(t){return t.wrapped().key in this.data}getAndRemove(t){return this.has(t)?this._getAndRemoveByKey(t.wrapped().key):null}_getAndRemoveByKey(t){const e=this.data[t].shift();return e.timeout&&clearTimeout(e.timeout),0===this.data[t].length&&delete this.data[t],this.order.splice(this.order.indexOf(t),1),e.value}getByKey(t){const e=this.data[t];return e?e[0].value:null}get(t){return this.has(t)?this.data[t.wrapped().key][0].value:null}remove(t,e){if(!this.has(t))return this;const i=t.wrapped().key,n=void 0===e?0:this.data[i].indexOf(e),r=this.data[i][n];return this.data[i].splice(n,1),r.timeout&&clearTimeout(r.timeout),0===this.data[i].length&&delete this.data[i],this.onRemove(r.value),this.order.splice(this.order.indexOf(i),1),this}setMaxSize(t){for(this.max=t;this.order.length>this.max;){const t=this._getAndRemoveByKey(this.order[0]);t&&this.onRemove(t)}return this}filter(t){const e=[];for(const i in this.data)for(const n of this.data[i])t(n.value)||e.push(n);for(const t of e)this.remove(t.value.tileID,t)}}class Xy extends zn{constructor(t,e,i){super(),this.id=t,this._onlySymbols=i,e.on("data",(t=>{"source"===t.dataType&&"metadata"===t.sourceDataType&&(this._sourceLoaded=!0),this._sourceLoaded&&!this._paused&&"source"===t.dataType&&"content"===t.sourceDataType&&(this.reload(),this.transform&&this.update(this.transform))})),e.on("error",(()=>{this._sourceErrored=!0})),this._source=e,this._tiles={},this._cache=new Yy(0,this._unloadTile.bind(this)),this._timers={},this._cacheTimers={},this._minTileCacheSize=e.minTileCacheSize,this._maxTileCacheSize=e.maxTileCacheSize,this._loadedParentTiles={},this.castsShadows=!1,this.tileCoverLift=0,this._coveredTiles={},this._shadowCasterTiles={},this._state=new km,this._isRaster="raster"===this._source.type||"raster-dem"===this._source.type||"raster-array"===this._source.type||"custom"===this._source.type&&"raster"===this._source._dataType}onAdd(t){this.map=t,this._minTileCacheSize=void 0===this._minTileCacheSize&&t?t._minTileCacheSize:this._minTileCacheSize,this._maxTileCacheSize=void 0===this._maxTileCacheSize&&t?t._maxTileCacheSize:this._maxTileCacheSize}loaded(){if(this._sourceErrored)return!0;if(!this._sourceLoaded)return!1;if(!this._source.loaded())return!1;for(const t in this._tiles){const e=this._tiles[t];if("errored"!==e.state&&("loaded"!==e.state||!e.bucketsLoaded()))return!1}return!0}getSource(){return this._source}pause(){this._paused=!0}resume(){if(!this._paused)return;const t=this._shouldReloadOnResume;this._paused=!1,this._shouldReloadOnResume=!1,t&&this.reload(),this.transform&&this.update(this.transform)}_loadTile(t,e){return t.isSymbolTile=this._onlySymbols,t.isExtraShadowCaster=this._shadowCasterTiles[t.tileID.key],this._source.loadTile(t,e)}_unloadTile(t){if(this._source.unloadTile)return this._source.unloadTile(t)}_abortTile(t){if(this._source.abortTile)return this._source.abortTile(t)}serialize(){return this._source.serialize()}prepare(t){this._source.prepare&&this._source.prepare(),this._state.coalesceChanges(this._tiles,this.map?this.map.painter:null);for(const e in this._tiles){const i=this._tiles[e];i.upload(t),i.prepare(this.map.style.imageManager,this.map?this.map.painter:null,this._source.scope)}}getIds(){return ti(this._tiles).map((t=>t.tileID)).sort(Ky).map((t=>t.key))}getRenderableIds(t,e){const i=[];for(const n in this._tiles)this._isIdRenderable(+n,t,e)&&i.push(this._tiles[n]);return t?i.sort(((t,e)=>{const i=t.tileID,n=e.tileID,r=new Ue(i.canonical.x,i.canonical.y)._rotate(this.transform.angle),o=new Ue(n.canonical.x,n.canonical.y)._rotate(this.transform.angle);return i.overscaledZ-n.overscaledZ||o.y-r.y||o.x-r.x})).map((t=>t.tileID.key)):i.map((t=>t.tileID)).sort(Ky).map((t=>t.key))}hasRenderableParent(t){const e=this.findLoadedParent(t,0);return!!e&&this._isIdRenderable(e.tileID.key)}_isIdRenderable(t,e,i){return this._tiles[t]&&this._tiles[t].hasData()&&!this._coveredTiles[t]&&(e||!this._tiles[t].holdingForFade())&&(i||!this._shadowCasterTiles[t])}reload(){if(this._paused)this._shouldReloadOnResume=!0;else{this._cache.reset();for(const t in this._tiles)"errored"!==this._tiles[t].state&&this._reloadTile(+t,"reloading")}}_reloadTile(t,e){const i=this._tiles[t];i&&("loading"!==i.state&&(i.state=e),this._loadTile(i,this._tileLoaded.bind(this,i,t,e)))}_tileLoaded(t,e,i,n){if(n)if(t.state="errored",404!==n.status)this._source.fire(new $n(n,{tile:t}));else{if(!(t.tileID.key in this._loadedParentTiles))return void this._source.fire(new Pn("data",{dataType:"source",sourceDataType:"error",sourceId:this._source.id}));if("raster-dem"===this._source.type&&this.usedForTerrain&&this.map.painter.terrain){const t=this.map.painter.terrain;this.update(this.transform,t.getScaledDemTileSize(),!0),t.resetTileLookupCache(this.id)}else this.update(this.transform)}else t.timeAdded=ki.now(),"expired"===i&&(t.refreshedUponExpiration=!0),this._setTileReloadTimer(e,t),"raster-dem"===this._source.type&&t.dem&&this._backfillDEM(t),this._state.initializeTileState(t,this.map?this.map.painter:null),this._source.fire(new Pn("data",{dataType:"source",tile:t,coord:t.tileID,sourceCacheId:this.id}))}_backfillDEM(t){const e=this.getRenderableIds();for(let n=0;n1||(Math.abs(i)>1&&(1===Math.abs(i+r)?i+=r:1===Math.abs(i-r)&&(i-=r)),e.dem&&t.dem&&(t.dem.backfillBorder(e.dem,i,n),t.neighboringTiles&&t.neighboringTiles[o]&&(t.neighboringTiles[o].backfilled=!0)))}}getTile(t){return this.getTileByID(t.key)}getTileByID(t){return this._tiles[t]}_retainLoadedChildren(t,e,i,n){for(const r in this._tiles){let o=this._tiles[r];if(n[r]||!o.hasData()||o.tileID.overscaledZi)continue;let s=o.tileID;for(;o&&o.tileID.overscaledZ>e+1;){const t=o.tileID.scaledTo(o.tileID.overscaledZ-1);o=this._tiles[t.key],o&&o.hasData()&&(s=t)}let a=s;for(;a.overscaledZ>e;)if(a=a.scaledTo(a.overscaledZ-1),t[a.key]){n[s.key]=s;break}}}findLoadedParent(t,e){if(t.key in this._loadedParentTiles){const i=this._loadedParentTiles[t.key];return i&&i.tileID.overscaledZ>=e?i:null}for(let i=t.overscaledZ-1;i>=e;i--){const e=t.scaledTo(i),n=this._getLoadedTile(e);if(n)return n}}_getLoadedTile(t){const e=this._tiles[t.key];return e&&e.hasData()?e:this._cache.getByKey(this._source.reparseOverscaled?t.wrapped().key:t.canonical.key)}updateCacheSize(t,e){e=e||this._source.tileSize;const i=Math.ceil(t.width/e)+1,n=Math.ceil(t.height/e)+1,r=Math.floor(i*n*5),o="number"==typeof this._minTileCacheSize?Math.max(this._minTileCacheSize,r):r,s="number"==typeof this._maxTileCacheSize?Math.min(this._maxTileCacheSize,o):o;this._cache.setMaxSize(s)}handleWrapJump(t){const e=Math.round((t-(void 0===this._prevLng?t:this._prevLng))/360);if(this._prevLng=t,e){const t={};for(const i in this._tiles){const n=this._tiles[i];n.tileID=n.tileID.unwrapTo(n.tileID.wrap+e),t[n.tileID.key]=n}this._tiles=t;for(const t in this._timers)clearTimeout(this._timers[t]),delete this._timers[t];for(const t in this._tiles)this._setTileReloadTimer(+t,this._tiles[t])}}update(t,e,i,n){if(this.transform=t,!this._sourceLoaded||this._paused||this.transform.freezeTileCoverage)return;if(this.usedForTerrain&&!i)return;let r;if(this.updateCacheSize(t,e),"globe"!==this.transform.projection.name&&this.handleWrapJump(this.transform.center.lng),this._shadowCasterTiles={},this._coveredTiles={},this.used||this.usedForTerrain){if(this._source.tileID)r=t.getVisibleUnwrappedCoordinates(this._source.tileID).map((t=>new vd(t.canonical.z,t.wrap,t.canonical.z,t.canonical.x,t.canonical.y)));else if(0!==this.tileCoverLift){const n=t.clone();n.tileCoverLift=this.tileCoverLift,r=n.coveringTiles({tileSize:e||this._source.tileSize,minzoom:this._source.minzoom,maxzoom:this._source.maxzoom,roundZoom:this._source.roundZoom&&!i,reparseOverscaled:this._source.reparseOverscaled,isTerrainDEM:this.usedForTerrain}),this._source.minzoomt(e)))}}else r=[];if(r.length>0&&this.castsShadows&&n&&"globe"!==this.transform.projection.name&&!this.usedForTerrain&&!Jy(this._source.type)){const o=t.coveringZoomLevel({tileSize:e||this._source.tileSize,roundZoom:this._source.roundZoom&&!i}),s=Math.min(o,this._source.maxzoom),a=t.extendTileCoverForShadows(r,n,s);for(const t of a)this._shadowCasterTiles[t.key]=!0,r.push(t)}const o=this._updateRetainedTiles(r);if(Jy(this._source.type)&&0!==r.length){const t={},e={},i=Object.keys(o);for(const n of i){const i=o[n],r=this._tiles[n];if(!r||r.fadeEndTime&&r.fadeEndTimen;){r=r.scaledTo(r.overscaledZ-1);const n=this._tiles[r.key];if(n&&n.hasData()&&e[r.key]){o[t]=i.tileID;break}}}for(const e in t)o[e]||(this._coveredTiles[e]=!0,o[e]=t[e])}for(const t in o)this._tiles[t].clearFadeHold();const s=function(t,e){const i=[];for(const n in t)n in e||i.push(n);return i}(this._tiles,o);for(const t of s){const e=this._tiles[t];e.hasSymbolBuckets&&!e.holdingForFade()?e.setHoldDuration(this.map._fadeDuration):e.hasSymbolBuckets&&!e.symbolFadeFinished()||this._removeTile(+t)}this._updateLoadedParentTileCache(),this._onlySymbols&&this._source.afterUpdate&&this._source.afterUpdate()}releaseSymbolFadeTiles(){for(const t in this._tiles)this._tiles[t].holdingForFade()&&this._removeTile(+t)}_updateRetainedTiles(t){const e={};if(0===t.length)return e;const i={},n=t.reduce(((t,e)=>Math.min(t,e.overscaledZ)),1/0),r=t[0].overscaledZ,o=Math.max(r-Xy.maxOverzooming,this._source.minzoom),s=Math.max(r+Xy.maxUnderzooming,this._source.minzoom),a={};for(const i of t){const t=this._addTile(i);e[i.key]=i,t.hasData()||n=this._source.maxzoom){const t=n.children(this._source.maxzoom)[0],i=this.getTile(t);if(i&&i.hasData()){e[t.key]=t;continue}}else{const t=n.children(this._source.maxzoom);if(e[t[0].key]&&e[t[1].key]&&e[t[2].key]&&e[t[3].key])continue}let r=t.wasRequested();for(let s=n.overscaledZ-1;s>=o;--s){const o=n.scaledTo(s);if(i[o.key])break;if(i[o.key]=!0,t=this.getTile(o),!t&&r&&(t=this._addTile(o)),t&&(e[o.key]=o,r=t.wasRequested(),t.hasData()))break}}return e}_updateLoadedParentTileCache(){this._loadedParentTiles={};for(const t in this._tiles){const e=[];let i,n=this._tiles[t].tileID;for(;n.overscaledZ>0;){if(n.key in this._loadedParentTiles){i=this._loadedParentTiles[n.key];break}e.push(n.key);const t=n.scaledTo(n.overscaledZ-1);if(i=this._getLoadedTile(t),i)break;n=t}for(const t of e)this._loadedParentTiles[t]=i}}_addTile(t){let e=this._tiles[t.key];if(e)return!0!==e.isExtraShadowCaster||!!this._shadowCasterTiles[t.key]||this._reloadTile(t.key,"reloading"),e;e=this._cache.getAndRemove(t),e&&(this._setTileReloadTimer(t.key,e),e.tileID=t,this._state.initializeTileState(e,this.map?this.map.painter:null),this._cacheTimers[t.key]&&(clearTimeout(this._cacheTimers[t.key]),delete this._cacheTimers[t.key],this._setTileReloadTimer(t.key,e)));const i=Boolean(e);if(!i){const i=this.map?this.map.painter:null,n=this._source.tileSize*t.overscaleFactor();e="raster-array"===this._source.type?new Wy(t,n,this.transform.tileZoom,i,this._isRaster):new ey(t,n,this.transform.tileZoom,i,this._isRaster),this._loadTile(e,this._tileLoaded.bind(this,e,t.key,e.state))}return e?(e.uses++,this._tiles[t.key]=e,i||this._source.fire(new Pn("dataloading",{tile:e,coord:e.tileID,dataType:"source"})),e):null}_setTileReloadTimer(t,e){t in this._timers&&(clearTimeout(this._timers[t]),delete this._timers[t]);const i=e.getExpiryTimeout();i&&(this._timers[t]=setTimeout((()=>{this._reloadTile(t,"expired"),delete this._timers[t]}),i))}_removeTile(t){const e=this._tiles[t];e&&(e.uses--,delete this._tiles[t],this._timers[t]&&(clearTimeout(this._timers[t]),delete this._timers[t]),e.uses>0||(e.hasData()&&"reloading"!==e.state||"empty"===e.state?this._cache.add(e.tileID,e,e.getExpiryTimeout()):(e.aborted=!0,this._abortTile(e),this._unloadTile(e))))}clearTiles(){this._shouldReloadOnResume=!1,this._paused=!1;for(const t in this._tiles)this._removeTile(+t);this._source._clear&&this._source._clear(),this._cache.reset(),this.map&&this.usedForTerrain&&this.map.painter.terrain&&this.map.painter.terrain.resetTileLookupCache(this.id)}tilesIn(t,e,i){const n=[],r=this.transform;if(!r)return n;const o="globe"===r.projection.name,s=Ed(r.center.lng);for(const a in this._tiles){const l=this._tiles[a];if(i&&l.clearQueryDebugViz(),l.holdingForFade())continue;let c;if(o){const t=l.tileID.canonical;if(0===t.z){const e=[Math.abs(Xe(s,...Qy(t,-1))-s),Math.abs(Xe(s,...Qy(t,1))-s)];c=[0,2*e.indexOf(Math.min(...e))-1]}else{const e=[Math.abs(Xe(s,...Qy(t,-1))-s),Math.abs(Xe(s,...Qy(t,0))-s),Math.abs(Xe(s,...Qy(t,1))-s)];c=[e.indexOf(Math.min(...e))-1]}}else c=[0];for(const i of c){const o=t.containsTile(l,r,e,i);o&&n.push(o)}}return n}getShadowCasterCoordinates(){return this._getRenderableCoordinates(!1,!0)}getVisibleCoordinates(t){return this._getRenderableCoordinates(t)}_getRenderableCoordinates(t,e){const i=this.getRenderableIds(t,e).map((t=>this._tiles[t].tileID)),n="globe"===this.transform.projection.name;for(const t of i)t.projMatrix=this.transform.calculateProjMatrix(t.toUnwrapped()),t.expandedProjMatrix=n?this.transform.calculateProjMatrix(t.toUnwrapped(),!1,!0):t.projMatrix;return i}sortCoordinatesByDistance(t){const e=t.slice(),i=this.transform._camera.position,n=this.transform._camera.forward(),r={};for(const t of e){const e=1/(1r[t.key]-r[e.key])),e}hasTransition(){if(this._source.hasTransition())return!0;if(Jy(this._source.type))for(const t in this._tiles){const e=this._tiles[t];if(void 0!==e.fadeEndTime&&e.fadeEndTime>=ki.now())return!0}return!1}setFeatureState(t,e,i){this._state.updateState(t=t||"_geojsonTileLayer",e,i)}removeFeatureState(t,e,i){this._state.removeFeatureState(t=t||"_geojsonTileLayer",e,i)}getFeatureState(t,e){return this._state.getState(t=t||"_geojsonTileLayer",e)}setDependencies(t,e,i){const n=this._tiles[t];n&&n.setDependencies(e,i)}reloadTilesForDependencies(t,e){for(const i in this._tiles)this._tiles[i].hasDependency(t,e)&&this._reloadTile(+i,"reloading");this._cache.filter((i=>!i.hasDependency(t,e)))}_preloadTiles(t,e){if(!this._sourceLoaded){const i=()=>{this._sourceLoaded&&(this._source.off("data",i),this._preloadTiles(t,e))};return void this._source.on("data",i)}const i=new Map,n=Array.isArray(t)?t:[t],r=this.map.painter.terrain,o=this.usedForTerrain&&r?r.getScaledDemTileSize():this._source.tileSize;for(const t of n){const e=t.coveringTiles({tileSize:o,minzoom:this._source.minzoom,maxzoom:this._source.maxzoom,roundZoom:this._source.roundZoom&&!this.usedForTerrain,reparseOverscaled:this._source.reparseOverscaled,isTerrainDEM:this.usedForTerrain});for(const t of e)i.set(t.key,t);this.usedForTerrain&&t.updateElevation(!1)}Qe(Array.from(i.values()),((t,e)=>{const i=new ey(t,this._source.tileSize*t.overscaleFactor(),this.transform.tileZoom,this.map.painter,this._isRaster);this._loadTile(i,(t=>{"raster-dem"===this._source.type&&i.dem&&this._backfillDEM(i),e(t,i)}))}),e)}}function Ky(t,e){const i=Math.abs(2*t.wrap)-+(t.wrap0?e+2*t:t}tv.useIntegerZoom=!0;const iv=new ol({"symbol-placement":new il(sl.layout_symbol["symbol-placement"]),"symbol-spacing":new il(sl.layout_symbol["symbol-spacing"]),"symbol-avoid-edges":new il(sl.layout_symbol["symbol-avoid-edges"]),"symbol-sort-key":new nl(sl.layout_symbol["symbol-sort-key"]),"symbol-z-order":new il(sl.layout_symbol["symbol-z-order"]),"symbol-z-elevate":new il(sl.layout_symbol["symbol-z-elevate"]),"icon-allow-overlap":new il(sl.layout_symbol["icon-allow-overlap"]),"icon-ignore-placement":new il(sl.layout_symbol["icon-ignore-placement"]),"icon-optional":new il(sl.layout_symbol["icon-optional"]),"icon-rotation-alignment":new il(sl.layout_symbol["icon-rotation-alignment"]),"icon-size":new nl(sl.layout_symbol["icon-size"]),"icon-text-fit":new nl(sl.layout_symbol["icon-text-fit"]),"icon-text-fit-padding":new nl(sl.layout_symbol["icon-text-fit-padding"]),"icon-image":new nl(sl.layout_symbol["icon-image"]),"icon-rotate":new nl(sl.layout_symbol["icon-rotate"]),"icon-padding":new il(sl.layout_symbol["icon-padding"]),"icon-keep-upright":new il(sl.layout_symbol["icon-keep-upright"]),"icon-offset":new nl(sl.layout_symbol["icon-offset"]),"icon-anchor":new nl(sl.layout_symbol["icon-anchor"]),"icon-pitch-alignment":new il(sl.layout_symbol["icon-pitch-alignment"]),"text-pitch-alignment":new il(sl.layout_symbol["text-pitch-alignment"]),"text-rotation-alignment":new il(sl.layout_symbol["text-rotation-alignment"]),"text-field":new nl(sl.layout_symbol["text-field"]),"text-font":new nl(sl.layout_symbol["text-font"]),"text-size":new nl(sl.layout_symbol["text-size"]),"text-max-width":new nl(sl.layout_symbol["text-max-width"]),"text-line-height":new nl(sl.layout_symbol["text-line-height"]),"text-letter-spacing":new nl(sl.layout_symbol["text-letter-spacing"]),"text-justify":new nl(sl.layout_symbol["text-justify"]),"text-radial-offset":new nl(sl.layout_symbol["text-radial-offset"]),"text-variable-anchor":new il(sl.layout_symbol["text-variable-anchor"]),"text-anchor":new nl(sl.layout_symbol["text-anchor"]),"text-max-angle":new il(sl.layout_symbol["text-max-angle"]),"text-writing-mode":new il(sl.layout_symbol["text-writing-mode"]),"text-rotate":new nl(sl.layout_symbol["text-rotate"]),"text-padding":new il(sl.layout_symbol["text-padding"]),"text-keep-upright":new il(sl.layout_symbol["text-keep-upright"]),"text-transform":new nl(sl.layout_symbol["text-transform"]),"text-offset":new nl(sl.layout_symbol["text-offset"]),"text-allow-overlap":new il(sl.layout_symbol["text-allow-overlap"]),"text-ignore-placement":new il(sl.layout_symbol["text-ignore-placement"]),"text-optional":new il(sl.layout_symbol["text-optional"]),visibility:new il(sl.layout_symbol.visibility)});var nv={paint:new ol({"icon-opacity":new nl(sl.paint_symbol["icon-opacity"]),"icon-occlusion-opacity":new nl(sl.paint_symbol["icon-occlusion-opacity"]),"icon-emissive-strength":new nl(sl.paint_symbol["icon-emissive-strength"]),"text-emissive-strength":new nl(sl.paint_symbol["text-emissive-strength"]),"icon-color":new nl(sl.paint_symbol["icon-color"]),"icon-halo-color":new nl(sl.paint_symbol["icon-halo-color"]),"icon-halo-width":new nl(sl.paint_symbol["icon-halo-width"]),"icon-halo-blur":new nl(sl.paint_symbol["icon-halo-blur"]),"icon-translate":new il(sl.paint_symbol["icon-translate"]),"icon-translate-anchor":new il(sl.paint_symbol["icon-translate-anchor"]),"icon-image-cross-fade":new nl(sl.paint_symbol["icon-image-cross-fade"]),"text-opacity":new nl(sl.paint_symbol["text-opacity"]),"text-occlusion-opacity":new nl(sl.paint_symbol["text-occlusion-opacity"]),"text-color":new nl(sl.paint_symbol["text-color"],{runtimeType:Qn,getOverride:t=>t.textColor,hasOverride:t=>!!t.textColor}),"text-halo-color":new nl(sl.paint_symbol["text-halo-color"]),"text-halo-width":new nl(sl.paint_symbol["text-halo-width"]),"text-halo-blur":new nl(sl.paint_symbol["text-halo-blur"]),"text-translate":new il(sl.paint_symbol["text-translate"]),"text-translate-anchor":new il(sl.paint_symbol["text-translate-anchor"]),"icon-color-saturation":new il(sl.paint_symbol["icon-color-saturation"]),"icon-color-contrast":new il(sl.paint_symbol["icon-color-contrast"]),"icon-color-brightness-min":new il(sl.paint_symbol["icon-color-brightness-min"]),"icon-color-brightness-max":new il(sl.paint_symbol["icon-color-brightness-max"])}),layout:iv};class rv{constructor(t){this.type=t.property.overrides?t.property.overrides.runtimeType:Yn,this.defaultValue=t}evaluate(t){if(t.formattedSection){const e=this.defaultValue.property.overrides;if(e&&e.hasOverride(t.formattedSection))return e.getOverride(t.formattedSection)}return t.feature&&t.featureState?this.defaultValue.evaluate(t.feature,t.featureState):this.defaultValue.property.specification.default}eachChild(t){this.defaultValue.isConstant()||t(this.defaultValue.value._styleExpression.expression)}outputDefined(){return!1}serialize(){return null}}ba(rv,"FormatSectionOverride",{omit:["defaultValue"]});class ov extends Ml{constructor(e,i,n,r){super(e,nv,i,n,r),this._colorAdjustmentMatrix=t.ad.identity([]),this.hasInitialOcclusionOpacityProperties=void 0!==e.paint&&("icon-occlusion-opacity"in e.paint||"text-occlusion-opacity"in e.paint)}recalculate(t,e){super.recalculate(t,e),"auto"===this.layout.get("icon-rotation-alignment")&&(this.layout._values["icon-rotation-alignment"]="point"!==this.layout.get("symbol-placement")?"map":"viewport"),"auto"===this.layout.get("text-rotation-alignment")&&(this.layout._values["text-rotation-alignment"]="point"!==this.layout.get("symbol-placement")?"map":"viewport"),"auto"===this.layout.get("text-pitch-alignment")&&(this.layout._values["text-pitch-alignment"]=this.layout.get("text-rotation-alignment")),"auto"===this.layout.get("icon-pitch-alignment")&&(this.layout._values["icon-pitch-alignment"]=this.layout.get("icon-rotation-alignment"));const i=this.layout.get("text-writing-mode");if(i){const t=[];for(const e of i)t.indexOf(e)i in t?String(t[i]):""))}(e.properties,r)}createBucket(t){return new jg(t)}queryRadius(){return 0}queryIntersectsFeature(){return!1}_setPaintOverrides(){for(const t of nv.paint.overridableProperties){if(!ov.hasPaintOverride(this.layout,t))continue;const e=this.paint.get(t),i=new rv(e),n=new la(i,e.property.specification,this.scope,this.options);let r=null;r="constant"===e.value.kind||"source"===e.value.kind?new ua("source",n):new ha("composite",n,e.value.zoomStops,e.value._interpolationType),this.paint._values[t]=new tl(e.property,r,e.parameters)}}_handleOverridablePaintPropertyUpdate(t,e,i){return!(!this.layout||e.isDataDriven()||i.isDataDriven())&&ov.hasPaintOverride(this.layout,t)}static hasPaintOverride(t,e){const i=t.get("text-field"),n=nv.paint.properties[e];let r=!1;const o=t=>{for(const e of t)if(n.overrides&&n.overrides.hasOverride(e))return void(r=!0)};if("constant"===i.value.kind&&i.value.value instanceof pr)o(i.value.value.sections);else if("source"===i.value.kind){const t=e=>{r||(e instanceof vr&&gr(e.value)===nr?o(e.value.sections):e instanceof Tr?o(e.sections):e.eachChild(t))},e=i.value;e._styleExpression&&t(e._styleExpression.expression)}return r}getProgramIds(){const t=0!==this.paint.get("icon-opacity").constantOr(1),e=0!==this.paint.get("text-opacity").constantOr(1),i=[];return t&&i.push("symbolIcon"),e&&i.push("symbolSDF"),i}getDefaultProgramParams(t,e,i){return{config:new Wc(this,{zoom:e,lut:i}),overrideFog:!1}}}const sv=new ol({visibility:new il(sl.layout_background.visibility)});var av={paint:new ol({"background-color":new il(sl.paint_background["background-color"]),"background-pattern":new il(sl.paint_background["background-pattern"]),"background-opacity":new il(sl.paint_background["background-opacity"]),"background-emissive-strength":new il(sl.paint_background["background-emissive-strength"])}),layout:sv};const lv=new ol({visibility:new il(sl.layout_raster.visibility)});var cv={paint:new ol({"raster-opacity":new il(sl.paint_raster["raster-opacity"]),"raster-color":new rl(sl.paint_raster["raster-color"]),"raster-color-mix":new il(sl.paint_raster["raster-color-mix"]),"raster-color-range":new il(sl.paint_raster["raster-color-range"]),"raster-hue-rotate":new il(sl.paint_raster["raster-hue-rotate"]),"raster-brightness-min":new il(sl.paint_raster["raster-brightness-min"]),"raster-brightness-max":new il(sl.paint_raster["raster-brightness-max"]),"raster-saturation":new il(sl.paint_raster["raster-saturation"]),"raster-contrast":new il(sl.paint_raster["raster-contrast"]),"raster-resampling":new il(sl.paint_raster["raster-resampling"]),"raster-fade-duration":new il(sl.paint_raster["raster-fade-duration"]),"raster-emissive-strength":new il(sl.paint_raster["raster-emissive-strength"]),"raster-array-band":new il(sl.paint_raster["raster-array-band"]),"raster-elevation":new il(sl.paint_raster["raster-elevation"])}),layout:lv};function dv(e,i,n,r,o,s,a,l){const c=[e,i,1,n,r,1,o,s,1],d=[a,l,1],u=t.bC.adjoint([],c),[h,p,f]=t._.transformMat3(d,d,u);return t.bC.multiply(c,c,[h,0,0,0,p,0,0,0,f])}function uv(e,i,n,r,o,s,a,l){const c=function(e,i,n,r,o,s,a,l){const c=dv(0,0,1,0,1,1,0,1),d=dv(e,i,n,r,o,s,a,l),u=t.bC.adjoint([],c);return t.bC.multiply(d,d,u)}(e,i,n,r,o,s,a,l);return[c[2]/c[8]/uo,c[5]/c[8]/uo]}function hv(t){return[t[0],Math.min(Math.max(t[1],-Pd),Pd)]}class pv extends zn{constructor(t,e,i,n){super(),this.id=t,this.dispatcher=i,this.coordinates=e.coordinates,this.type="image",this.minzoom=0,this.maxzoom=22,this.tileSize=512,this.tiles={},this._loaded=!1,this.onNorthPole=!1,this.onSouthPole=!1,this.setEventedParent(n),this.options=e,this._dirty=!1}load(t,e){if(this._loaded=e||!1,this.fire(new Pn("dataloading",{dataType:"source"})),this.url=this.options.url,!this.url)return t&&(this.coordinates=t),this._loaded=!0,void this._finishLoading();this._imageRequest=an(this.map._requestManager.transformRequest(this.url,Ki.Image),((e,i)=>{this._imageRequest=null,this._loaded=!0,e?this.fire(new $n(e)):i&&(this.image=i instanceof HTMLImageElement?ki.getImageData(i):i,this._dirty=!0,this.width=this.image.width,this.height=this.image.height,t&&(this.coordinates=t),this._finishLoading())}))}loaded(){return this._loaded}updateImage(t){return t.url?(this._imageRequest&&t.url!==this.options.url&&(this._imageRequest.cancel(),this._imageRequest=null),this.options.url=t.url,this.load(t.coordinates,this._loaded),this):this}setTexture(t){if(!(t.handle instanceof WebGLTexture))throw new Error("The provided handle is not a WebGLTexture instance");return this.texture=new Gg(this.map.painter.context,t.handle),this.width=t.dimensions[0],this.height=t.dimensions[1],this._dirty=!1,this._loaded=!0,this._finishLoading(),this}_finishLoading(){this.map&&(this.setCoordinates(this.coordinates),this.fire(new Pn("data",{dataType:"source",sourceDataType:"metadata"})))}onAdd(t){this.map=t,this.load()}onRemove(t){this._imageRequest&&(this._imageRequest.cancel(),this._imageRequest=null),!this.texture||this.texture instanceof Gg||this.texture.destroy(),this.boundsBuffer&&(this.boundsBuffer.destroy(),this.elevatedGlobeVertexBuffer&&this.elevatedGlobeVertexBuffer.destroy(),this.elevatedGlobeIndexBuffer&&this.elevatedGlobeIndexBuffer.destroy())}setCoordinates(t){if(this.coordinates=t,this._boundsArray=void 0,this._unsupportedCoords=!1,!t.length)return this;this.onNorthPole=!1,this.onSouthPole=!1;let e=t[0][1],i=t[0][1];for(const n of t)n[1]>i&&(i=n[1]),n[1]Pd?this.onNorthPole=!0:n1&&(l-=1),new gd(s,l,Math.floor((i+r)/2*a))}(e),this.minzoom=this.maxzoom=this.tileID.z}return this.fire(new Pn("data",{dataType:"source",sourceDataType:"content"})),this}_clear(){this._boundsArray=void 0,this._unsupportedCoords=!1}_prepareData(e){for(const t in this.tiles){const e=this.tiles[t];"loaded"!==e.state&&(e.state="loaded",e.texture=this.texture)}if(this._boundsArray||this.onNorthPole||this.onSouthPole||this._unsupportedCoords)return;const i=eg(new gd(0,0,0),this.map.transform.projection),n=[i.projection.project(this.coordinates[0][0],this.coordinates[0][1]),i.projection.project(this.coordinates[1][0],this.coordinates[1][1]),i.projection.project(this.coordinates[2][0],this.coordinates[2][1]),i.projection.project(this.coordinates[3][0],this.coordinates[3][1])];if(!function(t){const e=t[1].x-t[0].x,i=t[1].y-t[0].y,n=t[2].x-t[1].x,r=t[2].y-t[1].y,o=t[3].x-t[2].x,s=t[3].y-t[2].y,a=t[0].x-t[3].x,l=t[0].y-t[3].y,c=e*r-n*i,d=n*s-o*r,u=o*l-a*s,h=a*i-e*l;return c>0&&d>0&&u>0&&h>0||c{const e=r.projection.project(t[0],t[1]);return ig(r,e)._round()}));this.perspectiveTransform=uv(o.x,o.y,s.x,s.y,a.x,a.y,l.x,l.y);const c=this._boundsArray=new Dl;c.emplaceBack(o.x,o.y,0,0),c.emplaceBack(s.x,s.y,uo,0),c.emplaceBack(l.x,l.y,0,uo),c.emplaceBack(a.x,a.y,uo,uo),this.boundsBuffer&&(this.boundsBuffer.destroy(),this.elevatedGlobeVertexBuffer&&this.elevatedGlobeVertexBuffer.destroy(),this.elevatedGlobeIndexBuffer&&this.elevatedGlobeIndexBuffer.destroy()),this.boundsBuffer=e.createVertexBuffer(c,Jg.members),this.boundsSegments=wc.simpleSegment(0,0,4,2);const d=[],u=function(t){return[hv(t[0]),hv(t[1]),hv(t[2]),hv(t[3])]}(this.coordinates),[h,p,f,m]=function(t){let e=t[0][0],i=e,n=t[0][1],r=n;for(let o=1;oi&&(i=t[o][0]),t[o][1]r&&(r=t[o][1]);return[e,n,i-e,r-n]}(u);{const r=new Dl,[o,s,a,l]=function(t){let e=t[0].x,i=e,n=t[0].y,r=n;for(let o=1;oi&&(i=t[o].x),t[o].yr&&(r=t[o].y);return[e,n,i-e,r-n]}(n),c=t=>[(t.x-o)/a,(t.y-s)/l],[u,_,g,y]=n.map(c),v=function(e,i,n,r,o,s,a,l){const c=dv(0,0,1,0,1,1,0,1),d=dv(e,i,n,r,o,s,a,l),u=t.bC.adjoint([],d);return t.bC.multiply(c,c,u)}(u[0],u[1],_[0],_[1],g[0],g[1],y[0],y[1]);this.elevatedGlobePerspectiveTransform=uv(u[0],u[1],_[0],_[1],g[0],g[1],y[0],y[1]);const x=(e,i)=>{d.push(e.lng);const n=Math.round((e.lng-h)/f*uo),o=Math.round((e.lat-p)/m*uo),s=c(i),a=t._.transformMat3([],[s[0],s[1],1],v),l=Math.round(a[0]/a[2]*uo),u=Math.round(a[1]/a[2]*uo);r.emplaceBack(n,o,l,u)},b=n[3].x-n[0].x,w=n[3].y-n[0].y,T=n[2].x-n[1].x,S=n[2].y-n[1].y;for(let t=0;t{i.emplaceBack(e,n,r);const o=d[e],s=d[n],a=d[r],l=Math.min(Math.min(o,s),a),c=Math.max(Math.max(o,s),a)-l;c>this.maxLongitudeTriangleSize&&(this.maxLongitudeTriangleSize=c),t.push(l+c/2)};for(let t=0;te));i.sort(((e,i)=>t[e]-t[i]));const n=[],r=new Kl;for(let o=0;o{o.segments.push({vertexOffset:0,primitiveOffset:t,vertexLength:e.segments[0].vertexLength,primitiveLength:i,sortKey:void 0,vaos:{}})},a=.51*this.maxLongitudeTriangleSize;if(Math.abs(i[0]-n)0){const n=function(e,i){const n=i.worldSize,r=Cd(1,0)*n*kd(i.center.lat,i.zoom)/Gu(n),o=Cd(1,i.center.lat)*n,s=t.ad.identity([]);return t.ad.rotateY(s,s,Ge(i.center.lng)),t.ad.rotateX(s,s,Ge(i.center.lat)),t.ad.translate(s,s,[0,0,ed]),t.ad.scale(s,s,[r,r,r*o]),t.ad.translate(s,s,[i.point.x-.5*n,i.point.y-.5*n,0]),t.ad.multiply(s,s,e),t.ad.multiply(s,i.globeMatrix,s)}(e,i);return function(e,i,n){const r=(e,i,n)=>{const r=t._.length(e),o=t._.length(i),s=ku(e,i,n);return t._.scale(s,s,1/t._.length(s)*Vn(r,o,n))},o=r([e[0],e[1],e[2]],[i[0],i[1],i[2]],n),s=r([e[4],e[5],e[6]],[i[4],i[5],i[6]],n),a=r([e[8],e[9],e[10]],[i[8],i[9],i[10]],n),l=ku([e[12],e[13],e[14]],[i[12],i[13],i[14]],n);return[o[0],o[1],o[2],0,s[0],s[1],s[2],0,a[0],a[1],a[2],0,l[0],l[1],l[2],1]}(o,n,r)}return o}function kv(t,e,i,n){const r=wu.projectAabbCorners(n,i);let o=Number.MAX_VALUE,s=-1;for(let t=0;tnew Ue(r[t][0],r[t][1]);let l;switch(s){case 0:case 6:l=[a(1),a(5),a(4),a(7),a(3),a(2),a(1)];break;case 1:case 7:l=[a(0),a(4),a(5),a(6),a(2),a(3),a(0)];break;case 3:case 5:l=[a(1),a(0),a(4),a(7),a(6),a(2),a(1)];break;default:l=[a(1),a(5),a(6),a(7),a(3),a(0),a(1)]}if(Yd(t,l))return o}const Dv=Ll([{name:"a_pos_3f",components:3,type:"Float32"}]),zv=Ll([{name:"a_color_3f",components:3,type:"Float32"}]),Rv=Ll([{name:"a_color_4f",components:4,type:"Float32"}]),Ov=Ll([{name:"a_uv_2f",components:2,type:"Float32"}]),Bv=Ll([{name:"a_normal_3f",components:3,type:"Float32"}]),Fv=Ll([{name:"a_normal_matrix0",components:4,type:"Float32"},{name:"a_normal_matrix1",components:4,type:"Float32"},{name:"a_normal_matrix2",components:4,type:"Float32"},{name:"a_normal_matrix3",components:4,type:"Float32"}]),Nv=Ll([{name:"a_pbr",components:4,type:"Uint16"},{name:"a_heightBasedEmissiveStrength",components:3,type:"Float32"}]);class Uv{constructor(t,e,i,n){this.message=(t?`${t}: `:"")+i,n&&(this.identifier=n),null!=e&&e.__line__&&(this.line=e.__line__)}}function jv(t,e){const i=-1===t.indexOf("://");try{return new URL(t,i&&e?"http://example.com":void 0),!0}catch(t){return!1}}class Vv{constructor(t,e){this.feature=t,this.instancedDataOffset=e,this.instancedDataCount=0,this.rotation=[0,0,0],this.scale=[1,1,1],this.translation=[0,0,0]}}class Gv{constructor(){this.instancedDataArray=new oc,this.instancesEvaluatedElevation=[],this.features=[],this.idToFeaturesIndex={}}}class Zv{constructor(t){this.zoom=t.zoom,this.canonical=t.canonical,this.layers=t.layers,this.layerIds=this.layers.map((t=>t.fqid)),this.projection=t.projection,this.index=t.index,this.hasZoomDependentProperties=this.layers[0].isZoomDependent(),this.stateDependentLayerIds=this.layers.filter((t=>t.isStateDependent())).map((t=>t.id)),this.hasPattern=!1,this.instancesPerModel={},this.validForExaggeration=0,this.maxVerticalOffset=0,this.maxScale=0,this.maxHeight=0,this.lookupDim=this.zoom>this.canonical.z?256:this.zoom>15?75:100,this.instanceCount=0,this.terrainElevationMin=0,this.terrainElevationMax=0,this.validForDEMTile={id:null,timestamp:0},this.modelUris=[],this.modelsRequested=!1,this.activeReplacements=[],this.replacementUpdateTime=0}updateFootprints(t,e){}populate(t,e,i,n){this.tileToMeter=zd(i);const r=this.layers[0]._featureFilter.needGeometry;this.lookup=new Uint8Array(this.lookupDim*this.lookupDim);for(const{feature:o,id:s,index:a,sourceLayerIndex:l}of t){const t=null!=s?s:o.properties&&o.properties.hasOwnProperty("id")?o.properties.id:void 0,c=Zd(o,r);if(!this.layers[0]._featureFilter.filter(new Ha(this.zoom),c,i))continue;const d={id:t,sourceLayerIndex:l,index:a,geometry:r?c.geometry:Gd(o,i,n),properties:o.properties,type:o.type,patterns:{}},u=this.addFeature(d,d.geometry,c);u&&e.featureIndex.insert(o,d.geometry,a,l,this.index,this.instancesPerModel[u].instancedDataArray.length,uo/32)}this.lookup=null}update(t,e,i,n){for(const e in this.instancesPerModel){const i=this.instancesPerModel[e];for(const e in t)i.idToFeaturesIndex.hasOwnProperty(e)&&(this.evaluate(i.features[i.idToFeaturesIndex[e]],t[e],i,!0),this.uploaded=!1)}this.maxHeight=0}updateZoomBasedPaintProperties(){if(!this.hasZoomDependentProperties)return!1;let e=!1;for(const i in this.instancesPerModel){const n=this.instancesPerModel[i];for(const i of n.features){const r=this.layers[0],o=i.feature,s=this.canonical,a=r.paint.get("model-rotation").evaluate(o,{},s),l=r.paint.get("model-scale").evaluate(o,{},s),c=r.paint.get("model-translation").evaluate(o,{},s);t._.exactEquals(i.rotation,a)&&t._.exactEquals(i.scale,l)&&t._.exactEquals(i.translation,c)||(this.evaluate(i,i.featureStates,n,!0),e=!0)}}return e}updateReplacement(t,e,i){if(e.updateTime===this.replacementUpdateTime)return!1;this.replacementUpdateTime=e.updateTime;const n=e.getReplacementRegionsForTile(t.toUnwrapped(),!0);if(Pp(this.activeReplacements,n))return!1;this.activeReplacements=n;let r=!1;for(const e in this.instancesPerModel){const n=this.instancesPerModel[e],o=n.instancedDataArray;for(const e of n.features){const n=e.instancedDataOffset,s=e.instancedDataCount;for(let e=0;euo?a-uo:a;const l=Math.floor(a),c=o.float32[s+1];let d=!1;for(const e of this.activeReplacements)if(!(e.orderl||l>e.max.x||e.min.y>c||c>e.max.y)&&(d=Op(Rp(l,c,t.canonical,e.footprintTileId.canonical),e),d))break;o.float32[s]=d?a+uo:a,r=r||d}}}return r}isEmpty(){for(const t in this.instancesPerModel)if(0!==this.instancesPerModel[t].instancedDataArray.length)return!1;return!0}uploadPending(){return!this.uploaded}upload(t){if(!this.uploaded)for(const e in this.instancesPerModel){const i=this.instancesPerModel[e];i.instancedDataArray.length=uo||e.y=uo)continue;const t=(this.lookupDim-1)/uo,i=this.lookupDim*(e.y*t|0)+e.x*t|0;if(this.lookup){if(0!==this.lookup[i])continue;this.lookup[i]=1}this.instanceCount++;const n=s.length;s.resize(n+1),o.instancesEvaluatedElevation.push(0),s.float32[16*n]=e.x,s.float32[16*n+1]=e.y}return a.instancedDataCount=o.instancedDataArray.length-a.instancedDataOffset,a.instancedDataCount>0&&(t.id&&(o.idToFeaturesIndex[t.id]=o.features.length),o.features.push(a),this.evaluate(a,{},o,!1)),r}getModelUris(){return this.modelUris}evaluate(t,e,i,n){const r=this.layers[0],o=t.feature,s=this.canonical,a=t.rotation=r.paint.get("model-rotation").evaluate(o,e,s),l=t.scale=r.paint.get("model-scale").evaluate(o,e,s),c=t.translation=r.paint.get("model-translation").evaluate(o,e,s),d=r.paint.get("model-color").evaluate(o,e,s);d.a=r.paint.get("model-color-mix-intensity").evaluate(o,e,s);const u=[];this.maxVerticalOffset10?this.tileToMeter:zd(s,p)),a[o+4]=c[0],a[o+5]=c[1],a[o+6]=c[2]+l,a[o+7]=u[0],a[o+8]=u[1],a[o+9]=u[2],a[o+10]=u[4],a[o+11]=u[5],a[o+12]=u[6],a[o+13]=u[8],a[o+14]=u[9],a[o+15]=u[10],i.instancesEvaluatedElevation[r]=c[2]}}}ba(Zv,"ModelBucket",{omit:["layers"]}),ba(Gv,"PerModelAttributes"),ba(Vv,"ModelFeature");const qv=new ol({visibility:new il(sl.layout_model.visibility),"model-id":new nl(sl.layout_model["model-id"])});var Hv={paint:new ol({"model-opacity":new il(sl.paint_model["model-opacity"]),"model-rotation":new nl(sl.paint_model["model-rotation"]),"model-scale":new nl(sl.paint_model["model-scale"]),"model-translation":new nl(sl.paint_model["model-translation"]),"model-color":new nl(sl.paint_model["model-color"]),"model-color-mix-intensity":new nl(sl.paint_model["model-color-mix-intensity"]),"model-type":new il(sl.paint_model["model-type"]),"model-cast-shadows":new il(sl.paint_model["model-cast-shadows"]),"model-receive-shadows":new il(sl.paint_model["model-receive-shadows"]),"model-ambient-occlusion-intensity":new il(sl.paint_model["model-ambient-occlusion-intensity"]),"model-emissive-strength":new nl(sl.paint_model["model-emissive-strength"]),"model-roughness":new nl(sl.paint_model["model-roughness"]),"model-height-based-emissive-strength-multiplier":new nl(sl.paint_model["model-height-based-emissive-strength-multiplier"]),"model-cutoff-fade-range":new il(sl.paint_model["model-cutoff-fade-range"]),"model-front-cutoff":new il(sl.paint_model["model-front-cutoff"])}),layout:qv};const Wv=64,Yv={CoordinateSpaceTile:1,CoordinateSpaceYUp:2,HasMapboxMeshFeatures:4,HasMeshoptCompression:8};function Xv(e,i,n,r,o,s,a,l,c,d=!1){const u=n.zoom,h=n.project(r),p=kd(r.lat,u),f=1/p;t.ad.identity(e),t.ad.translate(e,e,[h.x+a[0]*f,h.y+a[1]*f,a[2]]);let m=1,_=1;const g=n.worldSize;if(d){if("mercator"===n.projection.name){let e=0;n.elevation&&(e=n.elevation.getAtPointOrZero(new Rd(h.x/g,h.y/g),0));const i=t.aA.transformMat4([],[h.x,h.y,e,1],n.projMatrix)[3]/n.cameraToCenterDistance;m=i,_=i*kd(n.center.lat,u)}else if("globe"===n.projection.name){const i=$v(e,n),o=t.ad.multiply([],n.projMatrix,i),s=[0,0,0,1];t.aA.transformMat4(s,s,o);const a=s[3]/n.cameraToCenterDistance,l=Hu(u),c=n.projection.pixelsPerMeter(r.lat,g)*kd(r.lat,u),d=n.projection.pixelsPerMeter(n.center.lat,g)*kd(n.center.lat,u);m=a/Vn(c,$d(n.center.lat),l),_=a*p/c,m*=d,_*=d}}else m=f;t.ad.scale(e,e,[m,m,_]);const y=[...e],v=i.orientation,x=[];if(Lv(x,[v[0]+o[0],v[1]+o[1],v[2]+o[2]],s),t.ad.multiply(e,y,x),l&&n.elevation){let o=0;const s=[];if(c&&n.elevation){o=function(e,i,n,r,o){const s=i.elevation;if(!s)return 0;const a=wu.projectAabbCorners(n,r),l=Cd(1,o.lat)*i.worldSize,c=function(e,i){const n=[0,0,1],r=[{corners:[0,1,3,2],dotProductWithUp:0},{corners:[1,5,2,6],dotProductWithUp:0},{corners:[0,4,1,5],dotProductWithUp:0},{corners:[2,6,3,7],dotProductWithUp:0},{corners:[4,7,5,6],dotProductWithUp:0},{corners:[0,3,4,7],dotProductWithUp:0}];for(const o of r){const r=e[o.corners[0]],s=e[o.corners[1]],a=e[o.corners[2]],l=[s[0]-r[0],s[1]-r[1],i*(s[2]-r[2])],c=t._.cross(l,l,[a[0]-r[0],a[1]-r[1],i*(a[2]-r[2])]);t._.normalize(c,c),o.dotProductWithUp=t._.dot(c,n)}return r.sort(((t,e)=>t.dotProductWithUp-e.dotProductWithUp)),r[0].corners}(a,l),d=a[c[0]],u=a[c[1]],h=a[c[2]],p=a[c[3]],f=s.getAtPointOrZero(new Rd(d[0]/i.worldSize,d[1]/i.worldSize),0),m=s.getAtPointOrZero(new Rd(u[0]/i.worldSize,u[1]/i.worldSize),0),_=s.getAtPointOrZero(new Rd(h[0]/i.worldSize,h[1]/i.worldSize),0),g=s.getAtPointOrZero(new Rd(p[0]/i.worldSize,p[1]/i.worldSize),0),y=(f+g)/2,v=(m+_)/2;return y>v?m=e.gl.NEAREST_MIPMAP_NEAREST}),t.uploaded=!0,t.image=null)}function Jv(t,e,i){t.indexBuffer=e.createIndexBuffer(t.indexArray,!1,!0),t.vertexBuffer=e.createVertexBuffer(t.vertexArray,Dv.members,!1,!0),t.normalArray&&(t.normalBuffer=e.createVertexBuffer(t.normalArray,Bv.members,!1,!0)),t.texcoordArray&&(t.texcoordBuffer=e.createVertexBuffer(t.texcoordArray,Ov.members,!1,!0)),t.colorArray&&(t.colorBuffer=e.createVertexBuffer(t.colorArray,(12===t.colorArray.bytesPerElement?zv:Rv).members,!1,!0)),t.featureArray&&(t.pbrBuffer=e.createVertexBuffer(t.featureArray,Nv.members,!0)),t.segments=wc.simpleSegment(0,0,t.vertexArray.length,t.indexArray.length);const n=t.material;n.pbrMetallicRoughness.baseColorTexture&&Kv(n.pbrMetallicRoughness.baseColorTexture,e),n.pbrMetallicRoughness.metallicRoughnessTexture&&Kv(n.pbrMetallicRoughness.metallicRoughnessTexture,e),n.normalTexture&&Kv(n.normalTexture,e),n.occlusionTexture&&Kv(n.occlusionTexture,e,i),n.emissionTexture&&Kv(n.emissionTexture,e)}function Qv(t,e,i){if(t.meshes)for(const n of t.meshes)Jv(n,e,i);if(t.children)for(const n of t.children)Qv(n,e,i)}function tx(t){if(t.meshes)for(const e of t.meshes)e.indexArray.destroy(),e.vertexArray.destroy(),e.colorArray&&e.colorArray.destroy(),e.normalArray&&e.normalArray.destroy(),e.texcoordArray&&e.texcoordArray.destroy(),e.featureArray&&e.featureArray.destroy();if(t.children)for(const e of t.children)tx(e)}function ex(t){if(t.meshes)for(const i of t.meshes)i.vertexBuffer&&(i.vertexBuffer.destroy(),i.indexBuffer.destroy(),i.normalBuffer&&i.normalBuffer.destroy(),i.texcoordBuffer&&i.texcoordBuffer.destroy(),i.colorBuffer&&i.colorBuffer.destroy(),i.pbrBuffer&&i.pbrBuffer.destroy(),i.segments.destroy(),i.material&&((e=i.material).pbrMetallicRoughness.baseColorTexture&&e.pbrMetallicRoughness.baseColorTexture.gfxTexture&&e.pbrMetallicRoughness.baseColorTexture.gfxTexture.destroy(),e.pbrMetallicRoughness.metallicRoughnessTexture&&e.pbrMetallicRoughness.metallicRoughnessTexture.gfxTexture&&e.pbrMetallicRoughness.metallicRoughnessTexture.gfxTexture.destroy(),e.normalTexture&&e.normalTexture.gfxTexture&&e.normalTexture.gfxTexture.destroy(),e.emissionTexture&&e.emissionTexture.gfxTexture&&e.emissionTexture.gfxTexture.destroy(),e.occlusionTexture&&e.occlusionTexture.gfxTexture&&e.occlusionTexture.gfxTexture.destroy()));var e;if(t.children)for(const e of t.children)ex(e)}class ix{constructor(t){this._callback=t,this._triggered=!1,"undefined"!=typeof MessageChannel&&(this._channel=new MessageChannel,this._channel.port2.onmessage=()=>{this._triggered=!1,this._callback()})}trigger(){this._triggered||(this._triggered=!0,this._channel?this._channel.port1.postMessage(!0):setTimeout((()=>{this._triggered=!1,this._callback()}),0))}remove(){this._channel=void 0,this._callback=()=>{}}}class nx{constructor(){this.tasks={},this.taskQueue=[],ai(["process"],this),this.invoker=new ix(this.process),this.nextId=0}add(t,e){const i=this.nextId++,n=function({type:t,isSymbolTile:e,zoom:i}){return i=i||0,"message"===t?0:"maybePrepare"!==t||e?"parseTile"!==t||e?"parseTile"===t&&e?300-i:"maybePrepare"===t&&e?400-i:500:200-i:100-i}(e);if(0===n){try{t()}finally{}return null}return this.tasks[i]={fn:t,metadata:e,priority:n,id:i},this.taskQueue.push(i),this.invoker.trigger(),{cancel:()=>{delete this.tasks[i]}}}process(){try{if(this.taskQueue=this.taskQueue.filter((t=>!!this.tasks[t])),!this.taskQueue.length)return;const t=this.pick();if(null===t)return;const e=this.tasks[t];if(delete this.tasks[t],this.taskQueue.length&&this.invoker.trigger(),!e)return;e.fn()}finally{}}pick(){let t=null,e=1/0;for(let i=0;i{i&&delete this.callbacks[s],this.target.postMessage({id:s,type:"",targetMapId:n,sourceMapId:this.mapId})}}}receive(t){const e=t.data,i=e.id;if(i&&(!e.targetMapId||this.mapId===e.targetMapId))if(""===e.type){const t=this.cancelCallbacks[i];delete this.cancelCallbacks[i],t&&t.cancel()}else if(e.mustQueue||gi()){const t=this.callbacks[i],n=this.scheduler.add((()=>this.processTask(i,e)),t&&t.metadata||{type:"message"});n&&(this.cancelCallbacks[i]=n)}else this.processTask(i,e)}processTask(t,e){if(delete this.cancelCallbacks[t],""===e.type){const i=this.callbacks[t];delete this.callbacks[t],i&&(e.error?i(Ea(e.error)):i(null,Ea(e.data)))}else{const i=new Set,n=e.hasCallback?(e,n)=>{this.target.postMessage({id:t,type:"",sourceMapId:this.mapId,error:e?Sa(e):null,data:Sa(n,i)},i)}:t=>{},r=Ea(e.data);if(this.parent[e.type])this.parent[e.type](e.sourceMapId,r,n);else if(this.parent.getWorkerSource){const t=e.type.split(".");this.parent.getWorkerSource(e.sourceMapId,t[0],r.source,r.scope)[t[1]](r,n)}else n(new Error(`Could not find function ${e.type}`))}}remove(){this.scheduler.remove(),this.target.removeEventListener("message",this.receive,!1)}}class ox{constructor(t,e){this.workerPool=t,this.actors=[],this.currentActor=0,this.id=ni();const i=this.workerPool.acquire(this.id);for(let t=0;t{this.ready=!0}))}broadcast(t,e,i){Qe(this.actors,((i,n)=>{i.send(t,e,n)}),i=i||function(){})}getActor(){return this.currentActor=(this.currentActor+1)%this.actors.length,this.actors[this.currentActor]}remove(){this.actors.forEach((t=>{t.remove()})),this.actors=[],this.workerPool.release(this.id)}}ox.Actor=rx;var sx={workerUrl:"",workerClass:null,workerParams:void 0};function ax(){return null!=sx.workerClass?new sx.workerClass:new self.Worker(sx.workerUrl,sx.workerParams)}const lx="mapboxgl_preloaded_worker_pool";class cx{constructor(){this.active={}}acquire(t){if(!this.workers)for(this.workers=[];this.workers.length{t.terminate()})),this.workers=null)}isPreloaded(){return!!this.active[lx]}numActive(){return Object.keys(this.active).length}}let dx;function ux(){return dx||(dx=new cx),dx}cx.workerCount=2;let hx,px,fx,mx,_x,gx=null;function yx(){return gi()&&self.worker&&self.worker.dracoUrl?self.worker.dracoUrl:px||n.DRACO_URL}function vx(){if(gi()&&self.worker&&self.worker.meshoptUrl)return self.worker.meshoptUrl;if(mx)return mx;const t=new Uint8Array([0,97,115,109,1,0,0,0,1,4,1,96,0,0,3,3,2,0,0,5,3,1,0,1,12,1,0,10,22,2,12,0,65,0,65,0,65,0,252,10,0,0,11,7,0,65,0,253,15,26,11]);if("object"!=typeof WebAssembly)throw new Error("WebAssembly not supported, cannot instantiate meshoptimizer");return mx=WebAssembly.validate(t)?n.MESHOPT_SIMD_URL:n.MESHOPT_URL,mx}const xx={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},bx={5120:"DT_INT8",5121:"DT_UINT8",5122:"DT_INT16",5123:"DT_UINT16",5125:"DT_UINT32",5126:"DT_FLOAT32"},wx={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16};function Tx(t,e,i){const n=i.json.bufferViews.length,r=i.buffers.length;e.bufferView=n,i.json.bufferViews[n]={buffer:r,byteLength:t.byteLength},i.buffers[r]=t}const Sx="KHR_draco_mesh_compression";function Ex(t,e){const i=t.extensions&&t.extensions[Sx];if(!i)return;const n=new fx.Decoder,r=$x(e,i.bufferView),o=new fx.Mesh;if(!n.DecodeArrayToMesh(r,r.byteLength,o))throw new Error("Failed to decode Draco mesh");const s=e.json.accessors[t.indices],a=xx[s.componentType],l=s.count*a.BYTES_PER_ELEMENT,c=fx._malloc(l);a===Uint16Array?n.GetTrianglesUInt16Array(o,l,c):n.GetTrianglesUInt32Array(o,l,c),Tx(fx.memory.buffer.slice(c,c+l),s,e),fx._free(c);for(const r of Object.keys(i.attributes)){const s=n.GetAttributeByUniqueId(o,i.attributes[r]),a=e.json.accessors[t.attributes[r]],l=bx[a.componentType],c=a.count*wx[a.type]*xx[a.componentType].BYTES_PER_ELEMENT,d=fx._malloc(c);n.GetAttributeDataArrayForAllPoints(o,s,fx[l],c,d),Tx(fx.memory.buffer.slice(d,d+c),a,e),fx._free(d)}n.destroy(),o.destroy(),delete t.extensions[Sx]}const Mx="EXT_meshopt_compression";function Cx(t,e){if(!t.extensions||!t.extensions[Mx])return;const i=t.extensions[Mx],n=new Uint8Array(e.buffers[i.buffer],i.byteOffset||0,i.byteLength||0),r=new Uint8Array(i.count*i.byteStride);_x.decodeGltfBuffer(r,i.count,i.byteStride,n,i.mode,i.filter),t.buffer=e.buffers.length,t.byteOffset=0,e.buffers[t.buffer]=r.buffer,delete t.extensions[Mx]}const Ax=1179937895,Ix=new TextDecoder("utf8");function Lx(t,e){return new URL(t,e).href}function Px(t,e,i,n){return fetch(Lx(t.uri,n)).then((t=>t.arrayBuffer())).then((t=>{e.buffers[i]=t}))}function $x(t,e){const i=t.json.bufferViews[e];return new Uint8Array(t.buffers[i.buffer],i.byteOffset||0,i.byteLength)}function kx(t,e,i,n){if(t.uri){const r=Lx(t.uri,n);return fetch(r).then((t=>t.blob())).then((t=>createImageBitmap(t))).then((t=>{e.images[i]=t}))}if(void 0!==t.bufferView){const n=$x(e,t.bufferView),r=new Blob([n],{type:t.mimeType});return createImageBitmap(r).then((t=>{e.images[i]=t}))}}function Dx(t,e=0,i){const n={json:null,images:[],buffers:[]};if(new Uint32Array(t,e,1)[0]===Ax){const i=new Uint32Array(t,e);let r=2;const o=(i[r++]>>2)-3,s=i[r++]>>2;if(r++,n.json=JSON.parse(Ix.decode(i.subarray(r,r+s))),r+=s,r{const t=[],e=a&&a.includes(Sx),r=a&&a.includes(Mx);if(e&&t.push(function(){if(!fx)return hx||(hx=function(t){let e,i=null;function n(){e=new Uint8Array(i.buffer)}function r(){throw new Error("Unexpected Draco error.")}const o={a:{a:r,d:function(t,i,n){return e.copyWithin(t,i,i+n)},c:function(t){const r=e.length,o=Math.max(t>>>0,Math.ceil(1.2*r)),s=Math.ceil((o-r)/65536);try{return i.grow(s),n(),!0}catch(t){return!1}},b:r}};return(WebAssembly.instantiateStreaming?WebAssembly.instantiateStreaming(t,o):t.then((t=>t.arrayBuffer())).then((t=>WebAssembly.instantiate(t,o)))).then((t=>{const{Rb:r,Qb:o,P:s,T:a,X:l,Ja:c,La:d,Qa:u,Va:h,Wa:p,eb:f,jb:m,f:_,e:g,yb:y,zb:v,Ab:x,Bb:b,Db:w,Gb:T}=t.instance.exports;i=g;const S=(()=>{let t=0,i=0,n=0,s=0;return a=>{n&&(r(s),r(t),i+=n,n=t=0),t||(i+=128,t=o(i));const l=a.length+7&-8;let c=t;l>=i&&(n=l,c=s=o(l));for(let t=0;t{fx=t,hx=void 0})))}()),r&&t.push(function(){if(_x)return;const t=function(t){let e;const i=WebAssembly.instantiateStreaming(t,{}).then((t=>{e=t.instance,e.exports.__wasm_call_ctors()})),n={NONE:"",OCTAHEDRAL:"meshopt_decodeFilterOct",QUATERNION:"meshopt_decodeFilterQuat",EXPONENTIAL:"meshopt_decodeFilterExp"},r={ATTRIBUTES:"meshopt_decodeVertexBuffer",TRIANGLES:"meshopt_decodeIndexBuffer",INDICES:"meshopt_decodeIndexSequence"};return{ready:i,supported:!0,decodeGltfBuffer(t,i,o,s,a,l){!function(t,e,i,n,r,o,s){const a=t.exports.sbrk,l=n+3&-4,c=a(l*r),d=a(o.length),u=new Uint8Array(t.exports.memory.buffer);u.set(o,d);const h=e(c,n,r,d,o.length);if(0===h&&s&&s(c,l,r),i.set(u.subarray(c,c+n*r)),a(c-a(0)),0!==h)throw new Error(`Malformed buffer data: ${h}`)}(e,e.exports[r[a]],t,i,o,s,e.exports[n[l]])}}}(fetch(vx()));return t.ready.then((()=>{_x=t}))}()),o)for(let e=0;e{if(e&&s)for(const{primitives:t}of s)for(const e of t)Ex(e,n);if(r&&s&&l)for(const t of l)Cx(t,n);return n}))}))}function zx(t,e){const i=t.json.bufferViews[e.bufferView],n=xx[e.componentType];return new n(t.buffers[i.buffer],(e.byteOffset||0)+(i.byteOffset||0),e.count*(i.byteStride&&i.byteStride!==wx[e.type]*n.BYTES_PER_ELEMENT?i.byteStride/n.BYTES_PER_ELEMENT:wx[e.type]))}function Rx(t,e,i,n){const r=xx[e.componentType],o=function(t){switch(t){case Int8Array:return 1/127;case Uint8Array:return 1/255;case Int16Array:return 1/32767;case Uint16Array:return 1/65535;default:return 1}}(r),s=t.json.bufferViews[e.bufferView],a=s.byteStride?s.byteStride/r.BYTES_PER_ELEMENT:wx[e.type],l=i.float32,c=l.length/i.capacity;for(let t=0,i=0;t0){for(let r=0;r0){o.texcoordArray=new ic;const t=e.json.accessors[r.TEXCOORD_0];o.texcoordArray.resize(t.count);const i=zx(e,t);Rx(e,t,o.texcoordArray,i)}if(void 0!==r._FEATURE_ID_RGBA4444){const t=e.json.accessors[r._FEATURE_ID_RGBA4444];e.json.extensionsUsed&&e.json.extensionsUsed.includes("EXT_meshopt_compression")&&(o.featureData=zx(e,t))}void 0!==r._FEATURE_RGBA4444&&(o.featureData=new Uint32Array(zx(e,e.json.accessors[r._FEATURE_RGBA4444]).buffer));const u=t.material;return o.material=function(t,e){const{emissiveFactor:i=[0,0,0],alphaMode:n="OPAQUE",alphaCutoff:r=.5,normalTexture:o,occlusionTexture:s,emissiveTexture:a,doubleSided:l}=t,{baseColorFactor:c=[1,1,1,1],metallicFactor:d=1,roughnessFactor:u=1,baseColorTexture:h,metallicRoughnessTexture:p}=t.pbrMetallicRoughness||{},f=s?e[s.index]:void 0;if(s&&s.extensions&&s.extensions.KHR_texture_transform&&f){const t=s.extensions.KHR_texture_transform;f.offsetScale=[t.offset[0],t.offset[1],t.scale[0],t.scale[1]]}return{pbrMetallicRoughness:{baseColorFactor:new Un(...c),metallicFactor:d,roughnessFactor:u,baseColorTexture:h?e[h.index]:void 0,metallicRoughnessTexture:p?e[p.index]:void 0},doubleSided:l,emissiveFactor:i,alphaMode:n,alphaCutoff:r,normalTexture:o?e[o.index]:void 0,occlusionTexture:f,emissionTexture:a?e[a.index]:void 0,defined:void 0===t.defined}}(void 0!==u?e.json.materials[u]:{defined:!1},i),o}function Bx(e,i,n){const{matrix:r,rotation:o,translation:s,scale:a,mesh:l,extras:c,children:d}=e,u={};if(u.matrix=r||t.ad.fromRotationTranslationScale([],o||[0,0,0,1],s||[0,0,0],a||[1,1,1]),void 0!==l){u.meshes=n[l];const t=u.anchor=[0,0];for(const e of u.meshes){const{min:i,max:n}=e.aabb;t[0]+=i[0]+n[0],t[1]+=i[1]+n[1]}t[0]=Math.floor(t[0]/u.meshes.length/2),t[1]=Math.floor(t[1]/u.meshes.length/2)}if(c&&(c.id&&(u.id=c.id),c.lights&&(u.lights=function(t){if(!t.length)return[];const e=function(t){const e=atob(t),i=new Uint8Array(e.length);for(let t=0;t1&&n[n.length-1].equals(n[0])&&n.pop();let r=0;for(let t=0;t0&&n.reverse();const o=xh(n.flatMap((t=>[t.x,t.y])),[]);return 0===o.length?null:{vertices:n,indices:o}}function Ux(e,i){const n=[],r=[];let o=0;const s=[];for(const a of e){o=n.length;const e=a.vertexArray.float32,l=a.indexArray.uint16;for(let r=0;r0&&([r[t+1],r[t+2]]=[r[t+2],r[t+1]])}return{vertices:n,indices:r}}function jx(t){const e=function(t,e){const i=[],n=WebGL2RenderingContext;if(t.json.textures)for(const r of t.json.textures){const o={magFilter:n.LINEAR,minFilter:n.NEAREST,wrapS:n.REPEAT,wrapT:n.REPEAT};void 0!==r.sampler&&Object.assign(o,t.json.samplers[r.sampler]),i.push({image:e[r.source],sampler:o,uploaded:!1})}return i}(t,t.images),i=function(t,e){const i=[];for(const n of t.json.meshes){const r=[];for(const i of n.primitives)r.push(Ox(i,t,e));i.push(r)}return i}(t,e),{scenes:n,scene:r,nodes:o}=t.json,s=n?n[r||0].nodes:o,a=[];for(const e of s)a.push(Bx(o[e],t,i));return function(t,e,i){const n={},r=new Set;for(let o=0;o0){const e=Array.from(r.values()).sort(((t,e)=>t-e));for(let i=e.length-1;i>=0;i--)t.splice(e[i],1)}}(a,s,t.json.nodes),a}function Vx(t){t.heightmap=new Float32Array(4096),t.heightmap.fill(-1);const e=t.vertexArray.float32,i=t.aabb.min[0]-1,n=t.aabb.min[1]-1,r=Wv/(t.aabb.max[0]-i+2),o=Wv/(t.aabb.max[1]-n+2);for(let s=0;st.heightmap[c*Wv+l]&&(t.heightmap[c*Wv+l]=a)}}function Gx(e,i){const n={};n.indexArray=new Kl,n.indexArray.reserve(4*e.length),n.vertexArray=new Bl,n.vertexArray.reserve(10*e.length),n.colorArray=new Ol,n.vertexArray.reserve(10*e.length);let r=0;for(const o of e){const e=Math.min(10,Math.max(4,1.3*o.height))*i,s=[-o.normal[1],o.normal[0],0],a=Math.min(.29,.1*o.width/o.depth),l=o.width-2*o.depth*i*(a+.01),c=t._.scaleAndAdd([],o.pos,s,l/2),d=t._.scaleAndAdd([],o.pos,s,-l/2),u=[c[0],c[1],c[2]+o.height],h=[d[0],d[1],d[2]+o.height],p=t._.scaleAndAdd([],o.normal,s,a);t._.scale(p,p,e);const f=t._.scaleAndAdd([],o.normal,s,-a);t._.scale(f,f,e),t._.add(p,c,p),t._.add(f,d,f),c[2]+=.1,d[2]+=.1,n.vertexArray.emplaceBack(p[0],p[1],p[2]),n.vertexArray.emplaceBack(f[0],f[1],f[2]),n.vertexArray.emplaceBack(c[0],c[1],c[2]),n.vertexArray.emplaceBack(d[0],d[1],d[2]),n.vertexArray.emplaceBack(u[0],u[1],u[2]),n.vertexArray.emplaceBack(h[0],h[1],h[2]),n.vertexArray.emplaceBack(c[0],c[1],c[2]),n.vertexArray.emplaceBack(d[0],d[1],d[2]),n.vertexArray.emplaceBack(p[0],p[1],p[2]),n.vertexArray.emplaceBack(f[0],f[1],f[2]);const m=l/e/2;n.colorArray.emplaceBack(-m-a,-1,m,.8),n.colorArray.emplaceBack(m+a,-1,m,.8),n.colorArray.emplaceBack(-m,0,m,1.3),n.colorArray.emplaceBack(m,0,m,1.3),n.colorArray.emplaceBack(m+a,-.8,m,.7),n.colorArray.emplaceBack(m+a,-.8,m,.7),n.colorArray.emplaceBack(0,0,m,1.3),n.colorArray.emplaceBack(0,0,m,1.3),n.colorArray.emplaceBack(m+a,-1.2,m,.8),n.colorArray.emplaceBack(m+a,-1.2,m,.8),n.indexArray.emplaceBack(6+r,4+r,8+r),n.indexArray.emplaceBack(7+r,9+r,5+r),n.indexArray.emplaceBack(0+r,1+r,2+r),n.indexArray.emplaceBack(1+r,3+r,2+r),r+=10}const o={defined:!0,emissiveFactor:[0,0,0]},s={};return s.baseColorFactor=Un.white,o.pbrMetallicRoughness=s,n.material=o,n.aabb=new wu([1/0,1/0,1/0],[-1/0,-1/0,-1/0]),n}const Zx=new Float32Array(262144),qx=new Uint8Array(262144);function Hx(t){let e=0;if(t.meshes)for(const i of t.meshes)e=Math.max(e,i.aabb.max[2]);if(t.children)for(const i of t.children)e=Math.max(e,Hx(i));return e}function Wx(t,e,i){if(t.meshes)for(const n of t.meshes)n.aabb.min[0]!==1/0&&i.insert(e,n.aabb.min[0],n.aabb.min[1],n.aabb.max[0],n.aabb.max[1]);if(t.children)for(const n of t.children)Wx(n,e,i)}const Yx=["","wall","door","roof","window","lamp","logo"];class Xx{constructor(t){this.node=t,this.evaluatedRMEA=[[1,0,0,1],[1,0,0,1],[1,0,0,1],[1,0,0,1],[.4,1,0,1],[1,0,0,1],[1,0,0,1]],this.hiddenByReplacement=!1,this.evaluatedScale=[1,1,1],this.evaluatedColor=[],this.emissionHeightBasedParams=[],this.feature={type:"Point",id:t.id,geometry:[],properties:{height:Hx(t)}},this.aabb=this._getLocalBounds()}_getLocalBounds(){if(!this.node.meshes)return new wu([1/0,1/0,1/0],[-1/0,-1/0,-1/0]);if(!this.aabb){let t=0;const e=new wu([1/0,1/0,1/0],[-1/0,-1/0,-1/0]);for(const i of this.node.meshes)this.node.lightMeshIndex!==t&&(i.transformedAabb=wu.applyTransformFast(i.aabb,this.node.matrix),e.encapsulate(i.transformedAabb)),t++;this.aabb=e}return this.aabb}}class Kx{constructor(t,e,i,n,r,o){this.id=e,this.modelTraits|=Yv.CoordinateSpaceTile,this.uploaded=!1,this.hasPattern=!1,i&&(this.modelTraits|=Yv.HasMapboxMeshFeatures),n&&(this.modelTraits|=Yv.HasMeshoptCompression),this.zoom=-1,this.terrainExaggeration=1,this.projection={name:"mercator"},this.replacementUpdateTime=0,this.elevationReadFromZ=255,this.brightness=r,this.dirty=!0,this.needsUpload=!1,this.nodesInfo=[];for(const e of t)this.nodesInfo.push(new Xx(e)),Wx(e,o.featureIndexArray.length,o.grid),o.featureIndexArray.emplaceBack(this.nodesInfo.length-1,0,o.bucketLayerIDs.length-1,0)}updateFootprints(t,e){for(const i of this.getNodesInfo()){const n=i.node;n.footprint&&e.push({footprint:n.footprint,id:t})}}update(){console.log("Update 3D model bucket")}populate(){console.log("populate 3D model bucket")}uploadPending(){return!this.uploaded||this.needsUpload}upload(t){if(!this.needsUpload)return;const e=this.getNodesInfo();for(const i of e){const e=i.node;this.uploaded?this.updatePbrBuffer(e):Qv(e,t,!0)}for(const t of e)tx(t.node);this.uploaded=!0,this.needsUpload=!1}updatePbrBuffer(t){let e=!1;if(!t.meshes)return e;for(const i of t.meshes)i.pbrBuffer&&(i.pbrBuffer.updateData(i.featureArray),e=!0);return e}needsReEvaluation(t,e,i){const n=t.transform.projectionOptions,r=t.style.getBrightness(),o=this.brightness!==r;return!!(!this.uploaded||this.dirty||n.name!==this.projection.name||Jx(i.paint.get("model-color").value,o)||Jx(i.paint.get("model-color-mix-intensity").value,o)||Jx(i.paint.get("model-roughness").value,o)||Jx(i.paint.get("model-emissive-strength").value,o)||Jx(i.paint.get("model-height-based-emissive-strength-multiplier").value,o))&&(this.projection=n,this.brightness=r,!0)}evaluateScale(t,e){if(t.transform.zoom===this.zoom)return;this.zoom=t.transform.zoom;const i=this.getNodesInfo(),n=this.id.canonical;for(const t of i){const i=t.feature;t.evaluatedScale=e.paint.get("model-scale").evaluate(i,{},n)}}evaluate(t){const e=this.getNodesInfo();for(const i of e){if(!i.node.meshes)continue;const e=i.feature,n=i.node.meshes&&i.node.meshes[0].featureData,r=i.evaluatedColor[2],o=i.evaluatedRMEA[2],s=this.id.canonical;if(i.hasTranslucentParts=!1,n){for(let n=0;n=t)continue;const u=Zx[c],h=Math.abs(u);h>a&&(s=u,a=h,l=r,d=e)}if(a>.1){const o=1-(t+.5*Math.abs(l*d))/c;let a=e._dem.get(n,i)+s*o;const u=e._dem.get(n+l,i+d),h=e._dem.get(n-l,i-d,!0);(a-u)*(a-h)>0&&(a=(u+h)/2),Zx[r]=e._dem.set(n,i,a),qx[r]=t}}}}}s&&(e._demTile.needsDEMTextureUpload=!0,e._dem._timestamp=ki.now())}getNodesInfo(){return this.nodesInfo}destroy(){const t=this.getNodesInfo();for(const e of t)tx(e.node),ex(e.node)}isEmpty(){return!this.nodesInfo.length}updateReplacement(t,e){if(e.updateTime===this.replacementUpdateTime)return;this.replacementUpdateTime=e.updateTime;const i=e.getReplacementRegionsForTile(t.toUnwrapped()),n=this.getNodesInfo();for(let t=0;tt.footprint===e.footprint))}}getHeightAtTileCoord(e,i){const n=this.getNodesInfo(),r=[],o=[0,0,0],s=t.ad.identity([]);for(let a=0;ad.max[0]||i>d.max[1])continue;if(!0===l.node.hidden)return{height:0,maxHeight:l.feature.properties.height,hidden:!1,verticalScale:l.evaluatedScale[2]};t.ad.invert(s,l.node.matrix),o[0]=e,o[1]=i,t._.transformMat4(o,o,s);const u=(o[0]-c.aabb.min[0])/(c.aabb.max[0]-c.aabb.min[0])*Wv|0,h=Math.min(63,(o[1]-c.aabb.min[1])/(c.aabb.max[1]-c.aabb.min[1])*Wv|0)*Wv+Math.min(63,u),p=c.heightmap[h];if(!(p0)return{height:void 0,maxHeight:l.feature.properties.height,hidden:l.hiddenByReplacement,verticalScale:l.evaluatedScale[2]}}}}function Jx(t,e){return!t.isLightConstant&&e}function Qx(t,e,i,n,r,o,s,a){let l=(61440&e|(61440&e)>>4)>>8,c=(3840&e|(3840&e)>>4)>>4,d=240&e|(240&e)>>4;i[3]>0&&(l=Vn(l,255*i[0],i[3]),c=Vn(c,255*i[1],i[3]),d=Vn(d,255*i[2],i[3]));const u=l>16&65535,a=o?e>>16&65535:65535&e,l=(15&a)t.polygon)).flat());const g=f?l:null,[y,v]=function(e,i,n,r,o,s,a,l,c,d,u){return"globe"===e.projection.name?function(e,i,n,r,o,s,a,l,c,d,u){const h=[],p=[],f=e.projection.upVectorScale(u,e.center.lat,e.worldSize).metersToTile,m=[0,0,0,1],_=[0,0,0,1],g=(t,e,i,n)=>{t[0]=e,t[1]=i,t[2]=n,t[3]=1},y=Sf();n>0&&(n+=y),r+=y;for(const y of i){const i=[],v=[];for(const h of y){const p=h.x+o.x,y=h.y+o.y,x=e.projection.projectTilePoint(p,y,u),b=e.projection.upVector(u,h.x,h.y);let w=n,T=r;if(a){const t=Pf(p,y,n,r,a,l,c,d);w+=t.base,T+=t.top}0!==n?g(m,x.x+b[0]*f*w,x.y+b[1]*f*w,x.z+b[2]*f*w):g(m,x.x,x.y,x.z),g(_,x.x+b[0]*f*T,x.y+b[1]*f*T,x.z+b[2]*f*T),t._.transformMat4(m,m,s),t._.transformMat4(_,_,s),i.push(new Tp(m[0],m[1],m[2])),v.push(new Tp(_[0],_[1],_[2]))}h.push(i),p.push(v)}return[h,p]}(e,i,n,r,o,s,a,l,c,d,u):a?function(e,i,n,r,o,s,a,l,c){const d=[],u=[],h=[0,0,0,1];for(const p of e){const e=[],f=[];for(const d of p){const u=d.x+r.x,p=d.y+r.y,m=Pf(u,p,i,n,s,a,l,c);h[0]=u,h[1]=p,h[2]=m.base,h[3]=1,t.aA.transformMat4(h,h,o),h[3]=Math.max(h[3],1e-5);const _=new Tp(h[0]/h[3],h[1]/h[3],h[2]/h[3]);h[0]=u,h[1]=p,h[2]=m.top,h[3]=1,t.aA.transformMat4(h,h,o),h[3]=Math.max(h[3],1e-5);const g=new Tp(h[0]/h[3],h[1]/h[3],h[2]/h[3]);e.push(_),f.push(g)}d.push(e),u.push(f)}return[d,u]}(i,n,r,o,s,a,l,c,d):function(t,e,i,n,r){const o=[],s=[],a=r[8]*e,l=r[9]*e,c=r[10]*e,d=r[11]*e,u=r[8]*i,h=r[9]*i,p=r[10]*i,f=r[11]*i;for(const e of t){const t=[],i=[];for(const o of e){const e=o.x+n.x,s=o.y+n.y,m=r[0]*e+r[4]*s+r[12],_=r[1]*e+r[5]*s+r[13],g=r[2]*e+r[6]*s+r[14],y=r[3]*e+r[7]*s+r[15],v=m+a,x=_+l,b=g+c,w=Math.max(y+d,1e-5),T=m+u,S=_+h,E=g+p,M=Math.max(y+f,1e-5);t.push(new Tp(v/w,x/w,b/w)),i.push(new Tp(T/M,S/M,E/M))}o.push(t),s.push(i)}return[o,s]}(i,n,r,o,s)}(s,r,h,u,d,a,g,p,m,s.center.lat,e.tileID.canonical),x=e.queryGeometry;return function(t,e,i){let n=1/0;Kd(i,e)&&(n=Lf(i,e[0]));for(let r=0;r=3)for(let e=0;e>4;if(1!==n)throw new Error(`Got v${n} data when expected v1.`);const r=nb[15&i];if(!r)throw new Error("Unrecognized array type.");const[o]=new Uint16Array(t,2,1),[s]=new Uint32Array(t,4,1);return new rb(s,o,r,t)}constructor(t,e=64,i=Float64Array,n){if(isNaN(t)||t>1;return this.ids[i]=i,this.coords[this._pos++]=t,this.coords[this._pos++]=e,i}finish(){const t=this._pos>>1;if(t!==this.numItems)throw new Error(`Added ${t} items when expected ${this.numItems}.`);return ob(this.ids,this.coords,this.nodeSize,0,this.numItems-1,0),this._finished=!0,this}range(t,e,i,n){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");const{ids:r,coords:o,nodeSize:s}=this,a=[0,r.length-1,0],l=[];for(;a.length;){const c=a.pop()||0,d=a.pop()||0,u=a.pop()||0;if(d-u=t&&a=e&&c>1,p=o[2*h],f=o[2*h+1];p>=t&&p=e&&f=p:n>=f)&&(a.push(h+1),a.push(d),a.push(1-c))}return l}within(t,e,i){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");const{ids:n,coords:r,nodeSize:o}=this,s=[0,n.length-1,0],a=[],l=i*i;for(;s.length;){const c=s.pop()||0,d=s.pop()||0,u=s.pop()||0;if(d-u>1,p=r[2*h],f=r[2*h+1];cb(p,f,t,e)=p:e+i>=f)&&(s.push(h+1),s.push(d),s.push(1-c))}return a}}function ob(t,e,i,n,r,o){if(r-n>1;sb(t,e,s,n,r,o),ob(t,e,i,n,s-1,1-o),ob(t,e,i,s+1,r,1-o)}function sb(t,e,i,n,r,o){for(;r>n;){if(r-n>600){const s=r-n+1,a=i-n+1,l=Math.log(s),c=.5*Math.exp(2*l/3),d=.5*Math.sqrt(l*c*(s-c)/s)*(a-s/2s&&ab(t,e,n,r);as;)l--}e[2*n+o]===s?ab(t,e,n,l):(l++,ab(t,e,l,r)),lr&&(n+=(t[i]-r)*(t[i]-r)),e[i]0&&n[0]0&&n[1]0&&r[0]0&&r[1]0?Math.acos(i/n)*Ve:0;let o=0!==t||0!==e?Math.atan2(-e,-t)*Ve+90:0;return oNi&&(t.getActor().send("enforceCacheSizeLimit",Fi),Vi=0)},t.an=gn,t.ao=class{constructor(t){this.entries={},this.scheduler=t}request(t,e,i,n){const r=this.entries[t]=this.entries[t]||{callbacks:[]};if(r.result){const[t,i]=r.result;return this.scheduler?this.scheduler.add((()=>{n(t,i)}),e):n(t,i),()=>{}}return r.callbacks.push(n),r.cancel||(r.cancel=i(((i,n)=>{r.result=[i,n];for(const t of r.callbacks)this.scheduler?this.scheduler.add((()=>{t(i,n)}),e):t(i,n);setTimeout((()=>delete this.entries[t]),3e3)}))),()=>{r.result||(r.callbacks=r.callbacks.filter((t=>t!==n)),r.callbacks.length||(r.cancel(),delete this.entries[t]))}}},t.ap=function(t,e,i){const n=JSON.stringify(t.request);return t.data&&(this.deduped.entries[n]={result:[null,t.data]}),this.deduped.request(n,{type:"parseTile",isSymbolTile:t.isSymbolTile,zoom:t.tileZoom},(e=>{const n=en(t.request,((t,n,r,o)=>{t?e(t):n&&e(null,{vectorTile:i?void 0:new bp(new Lm(n)),rawData:n,cacheControl:r,expires:o})}));return()=>{n.cancel(),e()}}),e)},t.aq=Dc,t.ar=class extends Lc{constructor(t){super(t),this.current=Fc}set(t,e,i){if(this.fetchUniformLocation(t,e))for(let t=0;t({u_camera_to_center_distance:new $c(t),u_extrude_scale:new Uc(t),u_device_pixel_ratio:new $c(t),u_matrix:new Bc(t),u_inv_rot_matrix:new Bc(t),u_merc_center:new kc(t),u_tile_id:new Dc(t),u_zoom_transition:new $c(t),u_up_dir:new Dc(t),u_emissive_strength:new $c(t)}),t.bJ=t=>({u_matrix:new Bc(t),u_pixels_to_tile_units:new Uc(t),u_device_pixel_ratio:new $c(t),u_units_to_pixels:new kc(t),u_dash_image:new Pc(t),u_gradient_image:new Pc(t),u_image_height:new $c(t),u_texsize:new kc(t),u_tile_units_to_pixels:new $c(t),u_alpha_discard_threshold:new $c(t),u_trim_offset:new kc(t),u_trim_fade_range:new kc(t),u_trim_color:new zc(t),u_emissive_strength:new $c(t)}),t.bK=t=>({u_matrix:new Bc(t),u_texsize:new kc(t),u_pixels_to_tile_units:new Uc(t),u_device_pixel_ratio:new $c(t),u_image:new Pc(t),u_units_to_pixels:new kc(t),u_tile_units_to_pixels:new $c(t),u_alpha_discard_threshold:new $c(t),u_trim_offset:new kc(t)}),t.bL=Yl,t.bM=Hf,t.bN=Om,t.bO=jm,t.bP=G_,t.bQ=c_,t.bR=th,t.bS=(t,e,i,n,r,o)=>{const s=t.transform,a="globe"===s.projection.name;let l;if("map"===o.paint.get("circle-pitch-alignment"))if(a){const t=Zu(s.zoom,e.canonical)*s._pixelsPerMercatorPixel;l=Float32Array.from([t,0,0,t])}else l=s.calculatePixelsToTileUnitsMatrix(i);else l=new Float32Array([s.pixelsToGLUnits[0],0,0,s.pixelsToGLUnits[1]]);const c={u_camera_to_center_distance:t.transform.getCameraToCenterDistance(s.projection),u_matrix:t.translatePosMatrix(e.projMatrix,i,o.paint.get("circle-translate"),o.paint.get("circle-translate-anchor")),u_device_pixel_ratio:ki.devicePixelRatio,u_extrude_scale:l,u_inv_rot_matrix:Qu,u_merc_center:[0,0],u_tile_id:[0,0,0],u_zoom_transition:0,u_up_dir:[0,0,0],u_emissive_strength:o.paint.get("circle-emissive-strength")};if(a){c.u_inv_rot_matrix=n,c.u_merc_center=r,c.u_tile_id=[e.canonical.x,e.canonical.y,1{const s=t.transform;return{u_matrix:rm(t,e,i,n),u_texsize:e.imageAtlasTexture?e.imageAtlasTexture.size:[0,0],u_pixels_to_tile_units:s.calculatePixelsToTileUnitsMatrix(e),u_device_pixel_ratio:r,u_image:0,u_tile_units_to_pixels:nm(e,s),u_units_to_pixels:[1/s.pixelsToGLUnits[0],1/s.pixelsToGLUnits[1]],u_alpha_discard_threshold:0,u_trim_offset:o}},t.bV=(t,e,i,n,r,o,s)=>{const a=t.transform,l=a.calculatePixelsToTileUnitsMatrix(e);return{u_matrix:rm(t,e,i,n),u_pixels_to_tile_units:l,u_device_pixel_ratio:o,u_units_to_pixels:[1/a.pixelsToGLUnits[0],1/a.pixelsToGLUnits[1]],u_dash_image:0,u_gradient_image:1,u_image_height:r,u_texsize:sm(i)&&e.lineAtlasTexture?e.lineAtlasTexture.size:[0,0],u_tile_units_to_pixels:nm(e,t.transform),u_alpha_discard_threshold:0,u_trim_offset:s,u_trim_fade_range:i.paint.get("line-trim-fade-range"),u_trim_color:i.paint.get("line-trim-color").toRenderColor(i.lut).toArray01(),u_emissive_strength:i.paint.get("line-emissive-strength")}},t.bW=oi,t.bX=mh,t.bY=Sf,t.bZ=bd,t.b_=_f,t.ba=function(t,e,i){const n=Hu(i.zoom),r=t.style.map._antialias,o=e.options.extStandardDerivativesForceOff||t.terrain&&t.terrain.exaggeration()>0;return 0===n&&!r&&!o},t.bb=function(e){const i=e.pixelsPerMeter,n=i/Cd(1,e.center.lat),r=t.ad.identity(new Float64Array(16));return t.ad.translate(r,r,[e.point.x,e.point.y,0]),t.ad.scale(r,r,[n,n,i]),Float32Array.from(r)},t.bc=Ou,t.bd=function(t){const e=Pd-5;t=Xe(t,-e,e)/e*90;const i=Math.pow(Math.abs(Math.sin(Ge(t))),3);return Math.round(i*(sd.length-1))},t.be=function(e,i,n,r){const o=i.getNorth(),s=i.getSouth(),a=i.getWest(),l=i.getEast(),c=10){const e=180/r;t.bC.multiply(f,f,[e/d+1,0,0,0,e/u+1,0,-.5*e/h,.5*e/p,1])}return f[2]=c,f[5]=e.x,f[8]=e.y,f},t.bf=ju,t.bg=$u,t.bh=function(e,i,n){const r=t.ad.identity(new Float64Array(16)),o=(i/(1{}}},t.bo=Gg,t.bp=ai,t.bq=class{isDataAvailableAtPoint(t){const e=this._source();if(this.isUsingMockSource()||!e||t.y1)return!1;const i=e.getSource().maxzoom,n=11)return e;const r=n.getSource().maxzoom,o=1{const s=this.getAtTileOffset(e,o.x,o.y),a=r.upVector(e.canonical,o.x,o.y),l=r.upVectorScale(e.canonical,i,n).metersToTile;return t._.scale(a,a,s*l),a}}getForTilePoints(t,e,i,n){if(this.isUsingMockSource())return!1;const r=Xp.create(this,t,n);return!!r&&(e.forEach((t=>{t[2]=this.exaggeration()*r.getElevationAt(t[0],t[1],i)})),!0)}getMinMaxForTile(t){if(this.isUsingMockSource())return null;const e=this.findDEMTileFor(t);if(!e||!e.dem)return null;const i=e.dem.tree,n=e.tileID,r=1=0?t.slice(0,e):t},t.cV=function(t){return t.indexOf(wl)>=0},t.cW=function(t){const e=t.indexOf(wl);return e>=0?t.slice(e+1):""},t.cX=function(t){const e=[],i=t.id;return void 0===i&&e.push({message:`layers.${i}: missing required property "id"`}),void 0===t.render&&e.push({message:`layers.${i}: missing required method "render"`}),t.renderingMode&&"2d"!==t.renderingMode&&"3d"!==t.renderingMode&&e.push({message:`layers.${i}: property "renderingMode" must be either "2d" or "3d"`}),e},t.cY=function(t,e,i,n){return"custom"===t.type?new vv(t,e):new ib[t.type](t,e,i,n)},t.cZ=di,t.c_=Va,t.ca=1,t.cb=Ag,t.cc=0,t.cd=ec,t.ce=function(t,e,i,n,r){return Xe((t-e)/(i-e)*(r-n)+n,n,r)},t.cf=Ns,t.cg=kd,t.ch=class{constructor(t,e,i,n){this.context=t,this.format=n,this.size=i,this.texture=t.gl.createTexture();const[r,o,s]=this.size,{gl:a}=t;a.bindTexture(a.TEXTURE_3D,this.texture),t.pixelStoreUnpackFlipY.set(!1),t.pixelStoreUnpack.set(1),t.pixelStoreUnpackPremultiplyAlpha.set(!1);let l=this.format,c=a.UNSIGNED_BYTE;this.format===a.DEPTH_COMPONENT&&(l=a.DEPTH_COMPONENT16,c=a.UNSIGNED_SHORT),this.format===a.R8&&(n=a.RED),this.format===a.R32F&&(c=a.FLOAT,n=a.RED),a.texImage3D(a.TEXTURE_3D,0,l,r,o,s,0,n,c,e.data)}bind(t,e){const{context:i}=this,{gl:n}=i;n.bindTexture(n.TEXTURE_3D,this.texture),t!==this.minFilter&&(n.texParameteri(n.TEXTURE_3D,n.TEXTURE_MAG_FILTER,t),n.texParameteri(n.TEXTURE_3D,n.TEXTURE_MIN_FILTER,t),this.minFilter=t),e!==this.wrapS&&(n.texParameteri(n.TEXTURE_3D,n.TEXTURE_WRAP_S,e),n.texParameteri(n.TEXTURE_3D,n.TEXTURE_WRAP_T,e),this.wrapS=e)}destroy(){const{gl:t}=this.context;t.deleteTexture(this.texture),this.texture=null}},t.ci=$v,t.cj=[1,1,1],t.ck=Xp,t.cl=Yv,t.cm=ql,t.cn=ic,t.co=class{constructor(){this._updateTime=0,this._sourceIds=[],this._activeRegions=[],this._prevRegions=[],this._globalClipBounds={min:new Ue(1/0,1/0),max:new Ue(-1/0,-1/0)}}clear(){this._activeRegions.length>0&&++this._updateTime,this._activeRegions=[],this._prevRegions=[]}get updateTime(){return this._updateTime}getReplacementRegionsForTile(t,e=!1){const i=$p(new Ue(0,0),new Ue(uo,uo),t),n=[];if(e&&!Lp(i,this._globalClipBounds))return n;for(const e of this._activeRegions){if(e.hiddenByOverlap)continue;if(!Lp(i,e))continue;const r=kp(e.min,e.max,t);n.push({min:r.min,max:r.max,sourceId:this._sourceIds[e.priority],footprint:e.footprint,footprintTileId:e.tileId,order:e.order,clipMask:e.clipMask})}return n}setSources(t){this._setSources(t.map((t=>({getSourceId:()=>t.cache.id,getFootprints:()=>{const e=[];for(const i of t.cache.getVisibleCoordinates()){const n=t.cache.getTile(i).buckets[t.layer];n&&n.updateFootprints(i.toUnwrapped(),e)}return e},getOrder:()=>t.order,getClipMask:()=>t.clipMask}))))}_addSource(t){const e=t.getFootprints();if(0===e.length)return;const i=t.getOrder(),n=t.getClipMask();for(const t of e){if(!t.footprint)continue;const e=$p(t.footprint.min,t.footprint.max,t.id);this._activeRegions.push({min:e.min,max:e.max,hiddenByOverlap:!1,priority:this._sourceIds.length,tileId:t.id,footprint:t.footprint,order:i,clipMask:n})}this._sourceIds.push(t.getSourceId())}_computeReplacement(){this._activeRegions.sort(((t,e)=>t.priority-e.priority||Ap(t.min,e.min)||Ap(t.max,e.max)));let t=this._activeRegions.length!==this._prevRegions.length;if(!t){let e=0;for(;!t&&e!==this._activeRegions.length;){const i=this._activeRegions[e],n=this._prevRegions[e];t=i.priority!==n.priority||!Ip(i,n)||i.order!==n.order||i.clipMask!==n.clipMask,++e}}if(t){++this._updateTime;for(const t of this._activeRegions)t.order!==1/0&&(this._globalClipBounds.min.x=Math.min(this._globalClipBounds.min.x,t.min.x),this._globalClipBounds.min.y=Math.min(this._globalClipBounds.min.y,t.min.y),this._globalClipBounds.max.x=Math.max(this._globalClipBounds.max.x,t.max.x),this._globalClipBounds.max.y=Math.max(this._globalClipBounds.max.y,t.max.y));const t=t=>{const e=this._activeRegions;if(t>=e.length)return t;const i=e[t].priority;for(;t1){let e=0,i=t(e);for(;e!==i;){let n=e;const r=e;for(;n!==i;){const t=this._activeRegions[n];t.hiddenByOverlap=!1;for(let e=0;e=0;e--)this._addSource(t[e]);this._computeReplacement()}},t.cp=Dl,t.cq=Jg,t.cr=rc,t.cs=class{constructor(t){this._createGrid(t),this._createPoles(t)}destroy(){this._poleIndexBuffer.destroy(),this._gridBuffer.destroy(),this._gridIndexBuffer.destroy(),this._poleNorthVertexBuffer.destroy(),this._poleSouthVertexBuffer.destroy();for(const t of this._poleSegments)t.destroy();for(const t of this._gridSegments)t.withSkirts.destroy(),t.withoutSkirts.destroy()}_fillGridMeshWithLods(t,e){const i=new $l,n=new Kl,r=[],o=t+1+2,s=e[0]+1,a=e[0]+1+(1+e.length),l=(t,e,i)=>{let n=t===o-1?t-2:0===t?t:t-1;return n+=i?24575:0,[n,e]};for(let t=0;tt()))},t.dB=sx,t.dC=yx,t.dD=function(t){px=ki.resolveURL(t),gx||(gx=new ox(ux(),new zn)),gx.broadcast("setDracoUrl",px)},t.dE=vx,t.dF=function(t){mx=ki.resolveURL(t),gx||(gx=new ox(ux(),new zn)),gx.broadcast("setMeshoptUrl",mx)},t.dG=ti,t.dH=ba,t.dI=dh,t.dJ=I_,t.dK=eg,t.dL=dc,t.dM=am,t.dN=Dm,t.dO=Wf,t.dP=ci,t.dQ=E_,t.dR=jg,t.dS=function(t,e,i,n,r,o,s,a,l,c,d){t.createArrays(),t.tilePixelRatio=uo/(512*t.overscaling),t.compareText={},t.iconsNeedLinear=!1;const u=t.layers[0].layout,h=t.layers[0]._unevaluatedLayout._values,p={};if("composite"===t.textSizeData.kind){const{minZoom:e,maxZoom:i}=t.textSizeData;p.compositeTextSizes=[h["text-size"].possiblyEvaluate(new Ha(e),a),h["text-size"].possiblyEvaluate(new Ha(i),a)]}if("composite"===t.iconSizeData.kind){const{minZoom:e,maxZoom:i}=t.iconSizeData;p.compositeIconSizes=[h["icon-size"].possiblyEvaluate(new Ha(e),a),h["icon-size"].possiblyEvaluate(new Ha(i),a)]}p.layoutTextSize=h["text-size"].possiblyEvaluate(new Ha(l+1),a),p.layoutIconSize=h["icon-size"].possiblyEvaluate(new Ha(l+1),a),p.textMaxSize=h["text-size"].possiblyEvaluate(new Ha(18),a);const f="map"===u.get("text-rotation-alignment")&&"point"!==u.get("symbol-placement"),m=u.get("text-size");let _=!1;for(const e of t.features)if(e.icon&&e.icon.nameSecondary){_=!0;break}for(const o of t.features){const l=u.get("text-font").evaluate(o,{},a).join(","),h=m.evaluate(o,{},a),g=p.layoutTextSize.evaluate(o,{},a),y=(p.layoutIconSize.evaluate(o,{},a),{horizontal:{},vertical:void 0}),v=o.text;let x,b=[0,0];if(v){const n=v.toString(),s=u.get("text-letter-spacing").evaluate(o,{},a)*Om,c=u.get("text-line-height").evaluate(o,{},a)*Om,d=Aa(n)?s:0,p=u.get("text-anchor").evaluate(o,{},a),m=u.get("text-variable-anchor");if(!m){const t=u.get("text-radial-offset").evaluate(o,{},a);b=t?G_(p,[t*Om,j_]):u.get("text-offset").evaluate(o,{},a).map((t=>t*Om))}let _=f?"center":u.get("text-justify").evaluate(o,{},a);const x="point"===u.get("symbol-placement"),w=x?u.get("text-max-width").evaluate(o,{},a)*Om:1/0,T=o=>{t.allowVerticalPlacement&&Ca(n)&&(y.vertical=e_(v,e,i,r,l,w,c,p,o,d,b,Jm.vertical,!0,g,h))};if(!f&&m){const t="auto"===_?m.map((t=>Z_(t))):[_];let n=!1;for(let o=0;o=0||!Ca(n)){const t=e_(v,e,i,r,l,w,c,p,_,d,b,Jm.horizontal,!1,g,h);t&&(y.horizontal[_]=t)}T(x?"left":_)}}let w=!1;if(o.icon&&o.icon.namePrimary){const e=n[o.icon.namePrimary];e&&(x=u_(r[o.icon.namePrimary],o.icon.nameSecondary?r[o.icon.nameSecondary]:void 0,u.get("icon-offset").evaluate(o,{},a),u.get("icon-anchor").evaluate(o,{},a)),w=e.sdf,void 0===t.sdfIcons?t.sdfIcons=e.sdf:t.sdfIcons!==e.sdf&&pi("Style sheet warning: Cannot mix SDF and non-SDF icons in one buffer"),(e.pixelRatio!==t.pixelRatio||0!==u.get("icon-rotate").constantOr(1))&&(t.iconsNeedLinear=!0))}const T=X_(y.horizontal)||y.vertical;t.iconsInText||(t.iconsInText=!!T&&T.iconsInText),(T||x)&&q_(t,o,y,x,n,p,g,0,b,w,s,a,c,d,_)}o&&t.generateCollisionDebugBuffers(l,t.collisionBoxArray)},t.dT=Jf,t.dU=Yh,t.dV=bp,t.dW=Lm,t.dX=Yp,t.dY=Zy,t.dZ=wp,t.d_=cp,t.da=Wu,t.db=function(e){const i=[0,0,0],n=t.ad.identity(new Float64Array(16));return t.ad.multiply(n,e.pixelMatrix,e.globeMatrix),t._.transformMat4(i,i,n),new Ue(i[0],i[1])},t.dc=d,t.dd=c,t.de=function(t){const e=t.navigator?t.navigator.userAgent:null;return!!function(t){if(null==Ei){const e=t.navigator?t.navigator.userAgent:null;Ei=!!t.safari||!(!e||!(/\b(iPad|iPhone|iPod)\b/.test(e)||e.match("Safari")&&!e.match("Chrome")))}return Ei}(t)&&e&&(e.match("Version/15.4")||e.match("Version/15.5")||e.match(/CPU (OS|iPhone OS) (15_4|15_5) like Mac OS X/))},t.df=ni,t.dg=class{constructor(t,e,i){this._transformRequestFn=t,this._customAccessToken=e,this._silenceAuthErrors=!!i,this._createSkuToken()}_createSkuToken(){const t=function(){let t="";for(let e=0;ethis._skuTokenExpiresAt}transformRequest(t,e){return this._transformRequestFn&&this._transformRequestFn(t,e)||{url:t}}normalizeStyleURL(t,i){if(!o(t))return t;const n=un(t);return n.params.push(`sdk=js-${e}`),n.path=`/styles/v1${n.path}`,this._makeAPIURL(n,this._customAccessToken||i)}normalizeGlyphsURL(t,e){if(!o(t))return t;const i=un(t);return i.path=`/fonts/v1${i.path}`,this._makeAPIURL(i,this._customAccessToken||e)}normalizeModelURL(t,e){if(!o(t))return t;const i=un(t);return i.path=`/models/v1${i.path}`,this._makeAPIURL(i,this._customAccessToken||e)}normalizeSourceURL(t,e,i,n){if(!o(t))return t;const r=un(t);return r.path=`/v4/${r.authority}.json`,r.params.push("secure"),i&&r.params.push(`language=${i}`),n&&r.params.push(`worldview=${n}`),this._makeAPIURL(r,this._customAccessToken||e)}normalizeSpriteURL(t,e,i,n){const r=un(t);return o(t)?(r.path=`/styles/v1${r.path}/sprite${e}${i}`,this._makeAPIURL(r,this._customAccessToken||n)):(r.path+=`${e}${i}`,hn(r))}normalizeTileURL(t,e,i){if(this._isSkuTokenExpired()&&this._createSkuToken(),t&&!o(t))return t;const r=un(t);r.path=r.path.replace(/(\.(png|jpg)\d*)(?=$)/,`${e||i&&"raster"!==r.authority&&512===i?"@2x":""}${Gi.supported?".webp":"$1"}`),"raster"===r.authority?r.path=`/${n.RASTER_URL_PREFIX}${r.path}`:"rasterarrays"===r.authority?r.path=`/${n.RASTERARRAYS_URL_PREFIX}${r.path}`:"3dtiles"===r.authority?r.path=`/${n.TILES3D_URL_PREFIX}${r.path}`:(r.path=r.path.replace(/^.+\/v4\//,"/"),r.path=`/${n.TILE_URL_VERSION}${r.path}`);const s=this._customAccessToken||function(t){for(const e of t){const t=e.match(/^access_token=(.*)$/);if(t)return t[1]}return null}(r.params)||n.ACCESS_TOKEN;return n.REQUIRE_ACCESS_TOKEN&&s&&this._skuToken&&r.params.push(`sku=${this._skuToken}`),this._makeAPIURL(r,s)}canonicalizeTileURL(t,e){const i=un(t);if(!i.path.match(/^(\/v4\/|\/(raster|rasterarrays)\/v1\/)/)||!i.path.match(/\.[\w]+$/))return t;let r="mapbox://";i.path.match(/^\/raster\/v1\//)?r+=`raster/${i.path.replace(`/${n.RASTER_URL_PREFIX}/`,"")}`:i.path.match(/^\/rasterarrays\/v1\//)?r+=`rasterarrays/${i.path.replace(`/${n.RASTERARRAYS_URL_PREFIX}/`,"")}`:r+=`tiles/${i.path.replace(`/${n.TILE_URL_VERSION}/`,"")}`;let o=i.params;return e&&(o=o.filter((t=>!t.match(/^access_token=/)))),o.length&&(r+=`?${o.join("&")}`),r}canonicalizeTileset(t,e){const i=!!e&&o(e),n=[];for(const e of t.tiles||[])r(e)?n.push(this.canonicalizeTileURL(e,i)):n.push(e);return n}_makeAPIURL(t,e){const i="See https://docs.mapbox.com/api/overview/#access-tokens-and-token-scopes",r=un(n.API_URL);if(t.protocol=r.protocol,t.authority=r.authority,"http"===t.protocol){const e=t.params.indexOf("secure");e>=0&&t.params.splice(e,1)}if("/"!==r.path&&(t.path=`${r.path}${t.path}`),!n.REQUIRE_ACCESS_TOKEN)return hn(t);if(e=e||n.ACCESS_TOKEN,!this._silenceAuthErrors){if(!e)throw new Error(`An API access token is required to use Mapbox GL. ${i}`);if("s"===e[0])throw new Error(`Use a public access token (pk.*) with Mapbox GL, not a secret access token (sk.*). ${i}`)}return t.params=t.params.filter((t=>-1===t.indexOf("access_token"))),t.params.push(`access_token=${e||""}`),hn(t)}},t.dh=function(t,e){e?Mn.add(t):Mn.delete(t)},t.di=Gi,t.dj=Tn,t.dk=En,t.dl=cn,t.dm=vn,t.dn=bn,t.dp=function(t){Mn.delete(t)},t.dq=Sn,t.dr=yn,t.ds=Qe,t.dt=e,t.du=function(t,e){Fi=t,Ni=e},t.dv=function(t,e,i=!1){if(Fa===za||Fa===Ra||Fa===Oa)throw new Error("setRTLTextPlugin cannot be called multiple times.");Na=ki.resolveURL(t),Fa=za,Ba=e,ja(),i||Za()},t.dw=Ga,t.dx=function(){ux().acquire(lx)},t.dy=function(){const t=dx;t&&(t.isPreloaded()&&1===t.numActive()?(t.release(lx),dx=null):console.warn("Could not clear WebWorkers since there are active Map instances that still reference it. The pre-warmed WebWorker pool can only be cleared when all map instances have been removed with map.remove()"))},t.dz=cx,t.e=ki,t.e0=cm,t.e1=h,t.e2=en,t.e3=function(t){let e=0;if(new Uint32Array(t,0,1)[0]!==Ax){const i=new Uint32Array(t,0,7),[,,n,r,o,s]=i;e=i.byteLength+r+o+s+o,(n!==t.byteLength||e>=t.byteLength)&&pi("Invalid b3dm header information.")}return Dx(t,e)},t.e4=function(t,e){const i=jx(t);for(const t of i){for(const e of t.meshes)Vx(e);t.lights&&(t.lightMeshIndex=t.meshes.length,t.meshes.push(Gx(t.lights,e)))}return i},t.e5=Kx,t.e6=rx,t.e7=qa,t.e8=function(t){ji(),Oi&&Oi.then((e=>{e.keys().then((i=>{for(let n=0;nt.arrayBuffer())).then((e=>Dx(e,0,t)))},t.m=class extends Uv{},t.n=Er,t.o=qn,t.p=Qg,t.q=Xs,t.r=Js,t.s=Qs,t.t=ca,t.u=al,t.v=ll,t.w=pi,t.x=pa,t.y=da,t.z=qo})),n(0,(function(t){function e(t){const e=t?t.url.toString():void 0;return e?performance.getEntriesByName(e):[]}function i(t){if("number"==typeof t||"boolean"==typeof t||"string"==typeof t||null==t)return JSON.stringify(t);if(Array.isArray(t)){let e="[";for(const n of t)e+=`${i(n)},`;return`${e}]`}let e="{";for(const n of Object.keys(t).sort())e+=`${n}:${i(t[n])},`;return`${e}}`}function n(e){let n="";for(const r of t.cE)n+=`/${i(e[r])}`;return n}class r{constructor(t){this.keyCache={},this._layers={},this._layerConfigs={},t&&this.replace(t)}replace(t,e){this._layerConfigs={},this._layers={},this.update(t,[],e)}update(e,i,r){this._options=r;for(const i of e)this._layerConfigs[i.id]=i,(this._layers[i.id]=t.cY(i,this.scope,null,this._options)).compileFilter(),this.keyCache[i.id]&&delete this.keyCache[i.id];for(const t of i)delete this.keyCache[t],delete this._layerConfigs[t],delete this._layers[t];this.familiesBySource={};const o=function(t,e){const i={};for(let r=0;rthis._layers[t.id])),i=e[0];if("none"===i.visibility)continue;const n=i.source||"";let r=this.familiesBySource[n];r||(r=this.familiesBySource[n]={});const o=i.sourceLayer||"_geojsonTileLayer";let s=r[o];s||(s=r[o]=[]),s.push(e)}}}const o=1*t.dJ;class s{constructor(e){const i={},n=[];for(const t in e){const r=e[t],s=i[t]={};for(const t in r.glyphs){const e=r.glyphs[+t];if(!e||0===e.bitmap.width||0===e.bitmap.height)continue;const i=e.metrics.localGlyph?o:1,a={x:0,y:0,w:e.bitmap.width+2*i,h:e.bitmap.height+2*i};n.push(a),s[t]=a}}const{w:r,h:s}=t.j(n),a=new t.dI({width:r||1,height:s||1});for(const n in e){const r=e[n];for(const e in r.glyphs){const s=r.glyphs[+e];if(!s||0===s.bitmap.width||0===s.bitmap.height)continue;const l=i[n][e],c=s.metrics.localGlyph?o:1;t.dI.copy(s.bitmap,a,{x:0,y:0},{x:l.x+c,y:l.y+c},s.bitmap)}}this.image=a,this.positions=i}}t.dH(s,"GlyphAtlas");class a{constructor(e){this.tileID=new t.aL(e.tileID.overscaledZ,e.tileID.wrap,e.tileID.canonical.z,e.tileID.canonical.x,e.tileID.canonical.y),this.tileZoom=e.tileZoom,this.uid=e.uid,this.zoom=e.zoom,this.lut=e.lut,this.canonical=e.tileID.canonical,this.pixelRatio=e.pixelRatio,this.tileSize=e.tileSize,this.source=e.source,this.scope=e.scope,this.overscaling=this.tileID.overscaleFactor(),this.showCollisionBoxes=e.showCollisionBoxes,this.collectResourceTiming=!!e.collectResourceTiming,this.promoteId=e.promoteId,this.isSymbolTile=e.isSymbolTile,this.tileTransform=t.dK(e.tileID.canonical,e.projection),this.projection=e.projection,this.brightness=e.brightness,this.extraShadowCaster=!!e.extraShadowCaster,this.tessellationStep=e.tessellationStep}parse(e,i,n,r,o){this.status="parsing",this.data=e,this.collisionBoxArray=new t.dL;const a=new t.dM(Object.keys(e.layers).sort()),c=new t.dN(this.tileID,this.promoteId);c.bucketLayerIDs=[];const d={},u=new t.dO(256,256),h={featureIndex:c,iconDependencies:{},patternDependencies:{},glyphDependencies:{},lineAtlas:u,availableImages:n,brightness:this.brightness},p=i.familiesBySource[this.source];for(const i in p){const r=e.layers[i];if(!r)continue;let o=!1,s=!1,u=!1;for(const t of p[i])"symbol"===t[0].type?o=!0:s=!0,t[0].is3D()&&"model"!==t[0].type&&(u=!0);if(this.extraShadowCaster&&!u)continue;if(!0===this.isSymbolTile&&!o)continue;if(!1===this.isSymbolTile&&!s)continue;1===r.version&&t.w(`Vector tile source "${this.source}" layer "${i}" does not use vector tile spec v2 and therefore may have some rendering errors.`);const f=a.encode(i),m=[];for(let t=0;t=e.maxzoom||"none"!==e.visibility&&(l(t,this.zoom,h.brightness,n),(d[e.id]=e.createBucket({index:c.bucketLayerIDs.length,layers:t,zoom:this.zoom,lut:this.lut,canonical:this.canonical,pixelRatio:this.pixelRatio,overscaling:this.overscaling,collisionBoxArray:this.collisionBoxArray,sourceLayerIndex:f,sourceID:this.source,projection:this.projection.spec,tessellationStep:this.tessellationStep})).populate(m,h,this.tileID.canonical,this.tileTransform),c.bucketLayerIDs.push(t.map((t=>t.id)))))}}let f,m,_,g;u.trim();const y={type:"maybePrepare",isSymbolTile:this.isSymbolTile,zoom:this.zoom},v=()=>{if(f)return this.status="done",o(f);if(this.extraShadowCaster)this.status="done",o(null,{buckets:t.dG(d).filter((t=>!t.isEmpty())),featureIndex:c,collisionBoxArray:null,glyphAtlasImage:null,lineAtlas:null,imageAtlas:null,brightness:h.brightness,glyphMap:null,iconMap:null,glyphPositions:null});else if(m&&_&&g){const e=new s(m),i=new t.dQ(_,g,this.lut);for(const r in d){const o=d[r];o instanceof t.dR?(l(o.layers,this.zoom,h.brightness,n),t.dS(o,m,e.positions,_,i.iconPositions,this.showCollisionBoxes,n,this.tileID.canonical,this.tileZoom,this.projection,this.brightness)):o.hasPattern&&(o instanceof t.dT||o instanceof t.dU||o instanceof t.b_)&&(l(o.layers,this.zoom,h.brightness,n),o.addFeatures(h,this.tileID.canonical,i.patternPositions,n,this.tileTransform,this.brightness))}this.status="done",o(null,{buckets:t.dG(d).filter((t=>!t.isEmpty())),featureIndex:c,collisionBoxArray:this.collisionBoxArray,glyphAtlasImage:e.image,lineAtlas:u,imageAtlas:i,brightness:h.brightness})}};if(!this.extraShadowCaster){const e=t.dP(h.glyphDependencies,(t=>Object.keys(t).map(Number)));Object.keys(e).length?r.send("getGlyphs",{uid:this.uid,stacks:e,scope:this.scope},((t,e)=>{f||(f=t,m=e,v())}),void 0,!1,y):m={};const i=Object.keys(h.iconDependencies);i.length?r.send("getImages",{icons:i,source:this.source,scope:this.scope,tileID:this.tileID,type:"icons"},((t,e)=>{f||(f=t,_=e,v())}),void 0,!1,y):_={};const n=Object.keys(h.patternDependencies);n.length?r.send("getImages",{icons:n,source:this.source,scope:this.scope,tileID:this.tileID,type:"patterns"},((t,e)=>{f||(f=t,g=e,v())}),void 0,!1,y):g={}}v()}}function l(e,i,n,r){const o=new t.X(i,{brightness:n});for(const t of e)t.recalculate(o,r)}class c extends t.E{constructor(e,i,n,r,o,s){super(),this.actor=e,this.layerIndex=i,this.availableImages=n,this.loadVectorData=o||t.ap,this.loading={},this.loaded={},this.deduped=new t.ao(e.scheduler),this.isSpriteLoaded=r,this.scheduler=e.scheduler,this.brightness=s}loadTile(i,n){const r=i.uid,o=i&&i.request,s=o&&o.collectResourceTiming,l=this.loading[r]=new a(i);l.abort=this.loadVectorData(i,((a,c)=>{const d=!this.loading[r];if(delete this.loading[r],d||a||!c)return l.status="done",d||(this.loaded[r]=l),n(a);const u=c.rawData,h={};c.expires&&(h.expires=c.expires),c.cacheControl&&(h.cacheControl=c.cacheControl),l.vectorTile=c.vectorTile||new t.dV(new t.dW(u));const p=()=>{l.parse(l.vectorTile,this.layerIndex,this.availableImages,this.actor,((i,r)=>{if(i||!r)return n(i);const a={};if(s){const t=e(o);t.length>0&&(a.resourceTiming=JSON.parse(JSON.stringify(t)))}n(null,t.W({rawTileData:u.slice(0)},r,h,a))}))};this.isSpriteLoaded?p():this.once("isSpriteLoaded",(()=>{this.scheduler?this.scheduler.add(p,{type:"parseTile",isSymbolTile:i.isSymbolTile,zoom:i.tileZoom}):p()})),this.loaded=this.loaded||{},this.loaded[r]=l}))}reloadTile(e,i){const n=this.loaded,r=e.uid;if(n&&n[r]){const o=n[r];o.showCollisionBoxes=e.showCollisionBoxes,o.projection=e.projection,o.brightness=e.brightness,o.tileTransform=t.dK(e.tileID.canonical,e.projection),o.extraShadowCaster=e.extraShadowCaster,o.lut=e.lut;const s=(t,e)=>{const n=o.reloadCallback;n&&(delete o.reloadCallback,o.parse(o.vectorTile,this.layerIndex,this.availableImages,this.actor,n)),i(t,e)};"parsing"===o.status?o.reloadCallback=s:"done"===o.status&&(o.vectorTile?o.parse(o.vectorTile,this.layerIndex,this.availableImages,this.actor,s):s())}else i(null,void 0)}abortTile(t,e){const i=t.uid,n=this.loading[i];n&&(n.abort&&n.abort(),delete this.loading[i]),e()}removeTile(t,e){const i=this.loaded,n=t.uid;i&&i[n]&&delete i[n],e()}}class d{loadTile(e,i){const{uid:n,encoding:r,rawImageData:o,padding:s}=e,a=ImageBitmap&&o instanceof ImageBitmap?this.getImageData(o,s):o;i(null,new t.dX(n,a,r,s{n(null,t)}),(t=>{n(t)}))}}const h=t.dZ.prototype.toGeoJSON;let p=class{constructor(e){this._feature=e,this.extent=t.a3,this.type=e.type,this.properties=e.tags,"id"in e&&!isNaN(e.id)&&(this.id=parseInt(e.id,10))}loadGeometry(){if(1===this._feature.type){const e=[];for(const i of this._feature.geometry)e.push([new t.P(i[0],i[1])]);return e}{const e=[];for(const i of this._feature.geometry){const n=[];for(const e of i)n.push(new t.P(e[0],e[1]));e.push(n)}return e}}toGeoJSON(t,e,i){return h.call(this,t,e,i)}},f=class{constructor(e){this.layers={_geojsonTileLayer:this},this.name="_geojsonTileLayer",this.extent=t.a3,this.length=e.length,this._features=e}feature(t){return new p(this._features[t])}};const m=64/4096;class _{constructor(){this.features=new Map}clear(){this.features.clear()}load(t=[],e){for(const i of t){const t=i.id;if(null==t)continue;let n=this.features.get(t);n&&this.updateCache(n,e),i.geometry?(n=y(i),this.updateCache(n,e),this.features.set(t,n)):this.features.delete(t),this.updateCache(n,e)}}updateCache(t,e){for(const{canonical:i,uid:n}of Object.values(e)){const{z:r,x:o,y:s}=i;g(t,Math.pow(2,r),o,s)&&delete e[n]}}getTile(t,e,i){const n=Math.pow(2,t),r=[];for(const t of this.features.values())g(t,n,e,i)&&r.push(w(t,n,e,i));return{features:r}}getFeatures(){return[...this.features.values()]}}function g({minX:t,minY:e,maxX:i,maxY:n},r,o,s){return t(o-m)/r&&n>(s-m)/r}function y(t){const{id:e,geometry:i,properties:n}=t;if(!i)return;if("GeometryCollection"===i.type)throw new Error("GeometryCollection not supported in dynamic mode.");const{type:r,coordinates:o}=i,s={id:e,type:1,geometry:[],tags:n,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0},a=s.geometry;if("Point"===r)v(o,a,s);else if("MultiPoint"===r)for(const t of o)v(t,a,s);else if("LineString"===r)s.type=2,x(o,a,s);else if("MultiLineString"===r)s.type=2,b(o,a,s);else if("Polygon"===r)s.type=3,b(o,a,s,!0);else{if("MultiPolygon"!==r)throw new Error("Input data is not a valid GeoJSON object.");s.type=3;for(const t of o)b(t,a,s,!0)}return s}function v([e,i],n,r){const o=t.aj(e);let s=t.ak(i);s=s1?1:s,n.push(o,s),r.minX=Math.min(r.minX,o),r.minY=Math.min(r.minY,s),r.maxX=Math.max(r.maxX,o),r.maxY=Math.max(r.maxY,s)}function x(t,e,i,n=!1,r=!1){const o=[];for(const e of t)v(e,o,i);e.push(o),n&&function(t,e){let i=0;for(let e=0,n=t.length,r=n-2;e0===e)for(let e=0,i=t.length;e>31}function F(t,e){for(var i=t.loadGeometry(),n=t.type,r=0,o=0,s=i.length,a=0;at},V=Math.fround||(G=new Float32Array(1),t=>(G[0]=+t,G[0]));var G;const Z=3,q=5,H=6;class W{constructor(t){this.options=Object.assign(Object.create(j),t),this.trees=new Array(this.options.maxZoom+1),this.stride=this.options.reduce?7:6,this.clusterProps=[]}load(t){const{log:e,minZoom:i,maxZoom:n}=this.options;e&&console.time("total time");const r=`prepare ${t.length} points`;e&&console.time(r),this.points=t;const o=[];for(let e=0;e=i;t--){const i=+Date.now();s=this.trees[t]=this._createTree(this._cluster(s,t)),e&&console.log("z%d: %d clusters in %dms",t,s.numItems,+Date.now()-i)}return e&&console.timeEnd("total time"),this}getClusters(t,e){let i=((t[0]+180)%360+360)%360-180;const n=Math.max(-90,Math.min(90,t[1]));let r=180===t[2]?180:((t[2]+180)%360+360)%360-180;const o=Math.max(-90,Math.min(90,t[3]));if(t[2]-t[0]>=360)i=-180,r=180;else if(i>r){const t=this.getClusters([i,n,180,o],e),s=this.getClusters([-180,n,r,o],e);return t.concat(s)}const s=this.trees[this._limitZoom(e)],a=s.range(K(i),J(o),K(r),J(n)),l=s.data,c=[];for(const t of a){const e=this.stride*t;c.push(l[e+q]>1?Y(l,e,this.clusterProps):this.points[l[e+Z]])}return c}getChildren(t){const e=this._getOriginId(t),i=this._getOriginZoom(t),n="No cluster with the specified id.",r=this.trees[i];if(!r)throw new Error(n);const o=r.data;if(e*this.stride>=o.length)throw new Error(n);const s=this.options.radius/(this.options.extent*Math.pow(2,i-1)),a=r.within(o[e*this.stride],o[e*this.stride+1],s),l=[];for(const e of a){const i=e*this.stride;o[i+4]===t&&l.push(o[i+q]>1?Y(o,i,this.clusterProps):this.points[o[i+Z]])}if(0===l.length)throw new Error(n);return l}getLeaves(t,e,i){const n=[];return this._appendLeaves(n,t,e=e||10,i=i||0,0),n}getTile(t,e,i){const n=this.trees[this._limitZoom(t)],r=Math.pow(2,t),{extent:o,radius:s}=this.options,a=s/o,l=(i-a)/r,c=(i+1+a)/r,d={features:[]};return this._addTileFeatures(n.range((e-a)/r,l,(e+1+a)/r,c),n.data,e,i,r,d),0===e&&this._addTileFeatures(n.range(1-a/r,l,1,c),n.data,r,i,r,d),e===r-1&&this._addTileFeatures(n.range(0,l,a/r,c),n.data,-1,i,r,d),d.features.length?d:null}getClusterExpansionZoom(t){let e=this._getOriginZoom(t)-1;for(;e1;let l,c,d;if(a)l=X(e,t,this.clusterProps),c=e[t],d=e[t+1];else{const i=this.points[e[t+Z]];l=i.properties;const[n,r]=i.geometry.coordinates;c=K(n),d=J(r)}const u={type:1,geometry:[[Math.round(this.options.extent*(c*r-i)),Math.round(this.options.extent*(d*r-n))]],tags:l};let h;h=a||this.options.generateId?e[t+Z]:this.points[e[t+Z]].id,void 0!==h&&(u.id=h),o.features.push(u)}}_limitZoom(t){return Math.max(this.options.minZoom,Math.min(Math.floor(+t),this.options.maxZoom+1))}_cluster(t,e){const{radius:i,extent:n,reduce:r,minPoints:o}=this.options,s=i/(n*Math.pow(2,e)),a=t.data,l=[],c=this.stride;for(let i=0;ie&&(p+=a[i+q])}if(p>h&&p>=o){let t,o=n*h,s=d*h,f=-1;const m=(i/c1)for(const t of u){const i=t*c;if(!(a[i+2]>5}_getOriginZoom(t){return(t-this.points.length)%32}_map(t,e,i){if(t[e+q]>1){const n=this.clusterProps[t[e+H]];return i?Object.assign({},n):n}const n=this.points[t[e+Z]].properties,r=this.options.map(n);return i&&r===n?Object.assign({},r):r}}function Y(t,e,i){return{type:"Feature",id:t[e+Z],properties:X(t,e,i),geometry:{type:"Point",coordinates:[(n=t[e],360*(n-.5)),Q(t[e+1])]}};var n}function X(t,e,i){const n=t[e+q],r=n>=1e4?`${Math.round(n/1e3)}k`:n>=1e3?Math.round(n/100)/10+"k":n,o=t[e+H],s=-1===o?{}:Object.assign({},i[o]);return Object.assign(s,{cluster:!0,cluster_id:t[e+Z],point_count:n,point_count_abbreviated:r})}function K(t){return t/360+.5}function J(t){const e=Math.sin(t*Math.PI/180),i=.5-.25*Math.log((1+e)/(1-e))/Math.PI;return i1?1:i}function Q(t){const e=(180-360*t)*Math.PI/180;return 360*Math.atan(Math.exp(e))/Math.PI-90}function tt(t,e,i,n){let r=n;const o=e+(i-e>>1);let s,a=i-e;const l=t[e],c=t[e+1],d=t[i],u=t[i+1];for(let n=e+3;n r.index||n.index===r.index&&n.t>r.t){const t=n;n=r,r=t}const o=[n.point],s=n.index+1,a=r.index;!so(i[s],o[0])&&st&&0===r.length&&r.push(ao(s,a,(t-(n-l))/l)),n>=e)return r.push(ao(s,a,(e-(n-l))/l)),r;n>t&&r.push(a)}return r}bufferPoint(t,e){const i=e/this.ky,n=e/this.kx;return[t[0]-n,t[1]-i,t[0]+n,t[1]+i]}bufferBBox(t,e){const i=e/this.ky,n=e/this.kx;return[t[0]-n,t[1]-i,t[2]+n,t[3]+i]}insideBBox(t,e){return lo(t[0]-e[0])>=0&&lo(t[0]-e[2])=e[1]&&t[1]180;)t-=360;return t}class co{constructor(t=[],e=(t,e)=>te?1:0){if(this.data=t,this.length=this.data.length,this.compare=e,this.length>0)for(let t=(this.length>>1)-1;t>=0;t--)this._down(t)}push(t){this.data.push(t),this._up(this.length++)}pop(){if(0===this.length)return;const t=this.data[0],e=this.data.pop();return--this.length>0&&(this.data[0]=e,this._down(0)),t}peek(){return this.data[0]}_up(t){const{data:e,compare:i}=this,n=e[t];for(;t>0;){const r=t-1>>1,o=e[r];if(i(n,o)>=0)break;e[t]=o,t=r}e[t]=n}_down(t){const{data:e,compare:i}=this,n=this.length>>1,r=e[t];for(;t=0)break;e[t]=e[n],t=n}e[t]=r}}var uo=8192;function ho(t,e){return e.dist-t.dist}const po=100,fo=50;function mo(t){const e=[1/0,1/0,-1/0,-1/0];if(e.length!==t.length)return!1;for(let i=0;i=t[0]&&t[1]t[1])return[null,null];const i=_o(t);if(e){if(2===i)return[t,null];const e=Math.floor(i/2);return[[t[0],t[0]+e],[t[0]+e,t[1]]]}{if(1===i)return[t,null];const e=Math.floor(i/2)-1;return[[t[0],t[0]+e],[t[0]+e+1,t[1]]]}}function vo(t,e){const i=[1/0,1/0,-1/0,-1/0];if(!go(e,t.length))return i;for(let n=e[0];ne[2]&&(n=t[0]-e[2]),t[1]>e[3]&&(r=t[1]-e[3]),t[3]=n)return n;if(Br(r,o)){if(ko(t,e))return 0}else if(ko(e,t))return 0;let s=n;for(const n of t)for(let t=0,r=n.length,o=r-1;t=o)continue;const c=r.range1;if(_o(c)=s)continue;const d=o.range1,u=o.range2;if(_o(d)=o)&&(o=Math.min(o,Oo(t,e,r,!0,n,o)),0===o))return o;return o}function Fo(t,e,i,n,r=1/0){let o=r;const s=vo(t,[0,t.length-1]);for(const r of i){if(o!==1/0&&bo(s,xo(r),n)>=o)continue;const i=Ro(t,e,r,n,o);if(isNaN(i))return i;if(0===(o=Math.min(o,i)))return o}return o}function No(t){return"Point"===t||"MultiPoint"===t||"LineString"===t||"MultiLineString"===t||"Polygon"===t||"MultiPolygon"===t}class Uo{constructor(t,e){this.type=Xn,this.geojson=t,this.geometries=e}static parse(t,e){if(2!==t.length)return e.error(`'distance' expression requires either one argument, but found ' ${t.length-1} instead.`);if(_r(t[1])){const e=t[1];if("FeatureCollection"===e.type){for(let t=0;ti&&(t=i),t}class Go{constructor(t,e,i){this.type=t,this.key=e,this.scope=i}static parse(t,e){let i=e.expectedType;if(null==i&&(i=er),t.length3)return e.error("Invalid number of arguments for 'config' expression.");const n=e.parse(t[1],1);if(!(n instanceof vr))return e.error("Key name of 'config' expression must be a string literal.");if(t.length>=3){const r=e.parse(t[2],2);return r instanceof vr?new Go(i,yr(n.value),yr(r.value)):e.error("Scope of 'config' expression must be a string literal.")}return new Go(i,yr(n.value))}evaluate(t){const e=[this.key,this.scope,t.scope].filter(Boolean).join(""),i=t.getConfig(e);if(!i)return null;const{type:n,value:r,values:o,minValue:s,maxValue:a,stepValue:l}=i,c=i.default.evaluate(t);let d=c;if(r){const e=t.scope;t.scope=(e||"").split("").slice(1).join(""),d=r.evaluate(t),t.scope=e}return n&&(d=jo(n,d)),void 0===d||void 0===s&&void 0===a&&void 0===l||("number"==typeof d?d=Vo(d,s,a,l):Array.isArray(d)&&(d=d.map((t=>"number"==typeof t?Vo(t,s,a,l):t)))),void 0!==r&&void 0!==d&&o&&!o.includes(d)&&(d=c,n&&(d=jo(n,d))),(n&&n!==this.type||void 0!==d&&gr(d)!==this.type)&&(d=jo(this.type.kind,d)),d}eachChild(){}outputDefined(){return!1}serialize(){const t=["config",this.key];return this.scope&&t.concat(this.key),t}}function Zo(t){if(t instanceof Lr){if("get"===t.name&&1===t.args.length)return!1;if("feature-state"===t.name)return!1;if("has"===t.name&&1===t.args.length)return!1;if("properties"===t.name||"geometry-type"===t.name||"id"===t.name)return!1;if(/^filter-/.test(t.name))return!1}if(t instanceof to)return!1;if(t instanceof Uo)return!1;let e=!0;return t.eachChild((t=>{e&&!Zo(t)&&(e=!1)})),e}function qo(t){if(t instanceof Lr&&"feature-state"===t.name)return!1;let e=!0;return t.eachChild((t=>{e&&!qo(t)&&(e=!1)})),e}function Ho(t){if(t instanceof Go)return!1;let e=!0;return t.eachChild((t=>{e&&!Ho(t)&&(e=!1)})),e}function Wo(t,e){if(t instanceof Lr&&e.indexOf(t.name)>=0)return!1;let i=!0;return t.eachChild((t=>{i&&!Wo(t,e)&&(i=!1)})),i}class Yo{constructor(t,e){this.type=e.type,this.name=t,this.boundExpression=e}static parse(t,e){if(2!==t.length||"string"!=typeof t[1])return e.error("'var' expression requires exactly one string literal argument.");const i=t[1];return e.scope.has(i)?new Yo(i,e.scope.get(i)):e.error(`Unknown variable "${i}". Make sure "${i}" has been bound in an enclosing "let" expression before using it.`,1)}evaluate(t){return this.boundExpression.evaluate(t)}eachChild(){}outputDefined(){return!1}serialize(){return["var",this.name]}}class Xo{constructor(t,e=[],i,n=new Wn,r=[],o,s){this.registry=t,this.path=e,this.key=e.map((t=>`[${t}]`)).join(""),this.scope=n,this.errors=r,this.expectedType=i,this._scope=o,this.options=s}parse(t,e,i,n,r={}){return e||i?this.concat(e,i,n)._parse(t,r):this._parse(t,r)}_parse(t,e){function i(t,e,i){return"assert"===i?new wr(e,[t]):"coerce"===i?new Cr(e,[t]):t}if(null!==t&&"string"!=typeof t&&"boolean"!=typeof t&&"number"!=typeof t||(t=["literal",t]),Array.isArray(t)){if(0===t.length)return this.error('Expected an array with at least one element. If you wanted a literal array, use ["literal", []].');const n="string"==typeof t[0]?this.registry[t[0]]:void 0;if(n){let r=n.parse(t,this);if(!r)return null;if(this.expectedType){const t=this.expectedType,n=r.type;if("string"!==t.kind&&"number"!==t.kind&&"boolean"!==t.kind&&"object"!==t.kind&&"array"!==t.kind||"value"!==n.kind)if("color"!==t.kind&&"formatted"!==t.kind&&"resolvedImage"!==t.kind||"value"!==n.kind&&"string"!==n.kind){if(this.checkSubtype(t,n))return null}else r=i(r,t,e.typeAnnotation||"coerce");else r=i(r,t,e.typeAnnotation||"assert")}if(!(r instanceof vr)&&"resolvedImage"!==r.type.kind&&Jo(r)){const e=new Ir(this._scope,this.options);try{r=new vr(r.type,r.evaluate(e))}catch(t){return this.error(t.message),null}}return r}return Cr.parse(["to-array",t],this)}return this.error(void 0===t?"'undefined' value invalid. Use null instead.":"object"==typeof t?'Bare objects invalid. Use ["literal", {...}] instead.':`Expected an array, but found ${typeof t} instead.`)}concat(t,e,i){const n="number"==typeof t?this.path.concat(t):this.path,r=i?this.scope.concat(i):this.scope;return new Xo(this.registry,n,e||null,r,this.errors,this._scope,this.options)}error(t,...e){const i=`${this.key}${e.map((t=>`[${t}]`)).join("")}`;this.errors.push(new Hn(i,t))}checkSubtype(t,e){const i=lr(t,e);return i&&this.error(i),i}}var Ko=Xo;function Jo(t){if(t instanceof Yo)return Jo(t.boundExpression);if(t instanceof Lr&&"error"===t.name)return!1;if(t instanceof $r)return!1;if(t instanceof to)return!1;if(t instanceof Uo)return!1;if(t instanceof Go)return!1;const e=t instanceof Cr||t instanceof wr;let i=!0;return t.eachChild((t=>{i=e?i&&Jo(t):i&&t instanceof vr})),!!i&&Zo(t)&&Wo(t,["zoom","heatmap-density","line-progress","raster-value","sky-radial-progress","accumulated","is-supported-script","pitch","distance-from-center","measure-light","raster-particle-speed"])}function Qo(t,e){const i=t.length-1;let n,r,o=0,s=i,a=0;for(;oe))throw new xr("Input is not a number.");s=a-1}return 0}class ts{constructor(t,e,i){this.type=t,this.input=e,this.labels=[],this.outputs=[];for(const[t,e]of i)this.labels.push(t),this.outputs.push(e)}static parse(t,e){if(t.length-1=o)return e.error('Input/output pairs for "step" expressions must be arranged with input values in strictly ascending order.',a);const c=e.parse(s,l,r);if(!c)return null;r=r||c.type,n.push([o,c])}return new ts(r,i,n)}evaluate(t){const e=this.labels,i=this.outputs;if(1===e.length)return i[0].evaluate(t);const n=this.input.evaluate(t);if(n=e[r-1]?i[r-1].evaluate(t):i[Qo(e,n)].evaluate(t)}eachChild(t){t(this.input);for(const e of this.outputs)t(e)}outputDefined(){return this.outputs.every((t=>t.outputDefined()))}serialize(){const t=["step",this.input.serialize()];for(let e=0;e0&&t.push(this.labels[e]),t.push(this.outputs[e].serialize());return t}}const es=.95047,is=1.08883,ns=4/29,rs=6/29,os=3*rs*rs,ss=rs*rs*rs,as=Math.PI/180,ls=180/Math.PI;function cs(t){return t>ss?Math.pow(t,1/3):t/os+ns}function ds(t){return t>rs?t*t*t:os*(t-ns)}function us(t){return 255*(t180||n"number"!=typeof t||t1)))return e.error("Cubic bezier interpolation requires four numeric arguments with values between 0 and 1.",1);n={name:"cubic-bezier",controlPoints:t}}}if(t.length-1=i)return e.error('Input/output pairs for "interpolate" expressions must be arranged with input values in strictly ascending order.',r);const c=e.parse(n,l,a);if(!c)return null;a=a||c.type,s.push([i,c])}return"number"===a.kind||"color"===a.kind||"array"===a.kind&&"number"===a.itemType.kind&&"number"==typeof a.N?new vs(a,i,n,r,s):e.error(`Type ${sr(a)} is not interpolatable.`)}evaluate(t){const e=this.labels,i=this.outputs;if(1===e.length)return i[0].evaluate(t);const n=this.input.evaluate(t);if(n=e[r-1])return i[r-1].evaluate(t);const o=Qo(e,n),s=vs.interpolationFactor(this.interpolation,n,e[o],e[o+1]),a=i[o].evaluate(t),l=i[o+1].evaluate(t);return"interpolate"===this.operator?Zn[this.type.kind.toLowerCase()](a,l,s):"interpolate-hcl"===this.operator?gs.reverse(gs.interpolate(gs.forward(a),gs.forward(l),s)):_s.reverse(_s.interpolate(_s.forward(a),_s.forward(l),s))}eachChild(t){t(this.input);for(const e of this.outputs)t(e)}outputDefined(){return this.outputs.every((t=>t.outputDefined()))}serialize(){let t;t="linear"===this.interpolation.name?["linear"]:"exponential"===this.interpolation.name?1===this.interpolation.base?["linear"]:["exponential",this.interpolation.base]:["cubic-bezier"].concat(this.interpolation.controlPoints);const e=[this.operator,t,this.input.serialize()];for(let t=0;tlr(n,t.type)));return new bs(o?er:i,r)}evaluate(t){let e,i=null,n=0;for(const r of this.args){if(n++,i=r.evaluate(t),i&&i instanceof fr&&!i.available&&(e||(e=i),i=null,n===this.args.length))return e;if(null!==i)break}return i}eachChild(t){this.args.forEach(t)}outputDefined(){return this.args.every((t=>t.outputDefined()))}serialize(){const t=["coalesce"];return this.eachChild((e=>{t.push(e.serialize())})),t}}class ws{constructor(t,e){this.type=e.type,this.bindings=[].concat(t),this.result=e}evaluate(t){return this.result.evaluate(t)}eachChild(t){for(const e of this.bindings)t(e[1]);t(this.result)}static parse(t,e){if(t.length=i.length)throw new xr(`Array index out of bounds: ${e} > ${i.length-1}.`);if(e!==Math.floor(e))throw new xr(`Array index must be an integer, but found ${e} instead.`);return i[e]}eachChild(t){t(this.index),t(this.input)}outputDefined(){return!1}serialize(){return["at",this.index.serialize(),this.input.serialize()]}}class Ss{constructor(t,e){this.type=Jn,this.needle=t,this.haystack=e}static parse(t,e){if(3!==t.length)return e.error(`Expected 2 arguments, but found ${t.length-1} instead.`);const i=e.parse(t[1],1,er),n=e.parse(t[2],2,er);return i&&n?cr(i.type,[Jn,Kn,Xn,Yn,er])?new Ss(i,n):e.error(`Expected first argument to be of type boolean, string, number or null, but found ${sr(i.type)} instead`):null}evaluate(t){const e=this.needle.evaluate(t),i=this.haystack.evaluate(t);if(null==i)return!1;if(!dr(e,["boolean","string","number","null"]))throw new xr(`Expected first argument to be of type boolean, string, number or null, but found ${sr(gr(e))} instead.`);if(!dr(i,["string","array"]))throw new xr(`Expected second argument to be of type array or string, but found ${sr(gr(i))} instead.`);return i.indexOf(e)>=0}eachChild(t){t(this.needle),t(this.haystack)}outputDefined(){return!0}serialize(){return["in",this.needle.serialize(),this.haystack.serialize()]}}class Es{constructor(t,e,i){this.type=Xn,this.needle=t,this.haystack=e,this.fromIndex=i}static parse(t,e){if(t.length=5)return e.error(`Expected 3 or 4 arguments, but found ${t.length-1} instead.`);const i=e.parse(t[1],1,er),n=e.parse(t[2],2,er);if(!i||!n)return null;if(!cr(i.type,[Jn,Kn,Xn,Yn,er]))return e.error(`Expected first argument to be of type boolean, string, number or null, but found ${sr(i.type)} instead`);if(4===t.length){const r=e.parse(t[3],3,Xn);return r?new Es(i,n,r):null}return new Es(i,n)}evaluate(t){const e=this.needle.evaluate(t),i=this.haystack.evaluate(t);if(!dr(e,["boolean","string","number","null"]))throw new xr(`Expected first argument to be of type boolean, string, number or null, but found ${sr(gr(e))} instead.`);if(!dr(i,["string","array"]))throw new xr(`Expected second argument to be of type array or string, but found ${sr(gr(i))} instead.`);if(this.fromIndex){const n=this.fromIndex.evaluate(t);return i.indexOf(e,n)}return i.indexOf(e)}eachChild(t){t(this.needle),t(this.haystack),this.fromIndex&&t(this.fromIndex)}outputDefined(){return!1}serialize(){if(null!=this.fromIndex&&void 0!==this.fromIndex){const t=this.fromIndex.serialize();return["index-of",this.needle.serialize(),this.haystack.serialize(),t]}return["index-of",this.needle.serialize(),this.haystack.serialize()]}}class Ms{constructor(t,e,i,n,r,o){this.inputType=t,this.type=e,this.input=i,this.cases=n,this.outputs=r,this.otherwise=o}static parse(t,e){if(t.lengthNumber.MAX_SAFE_INTEGER)return c.error(`Branch labels must be integers no larger than ${Number.MAX_SAFE_INTEGER}.`);if("number"==typeof t&&Math.floor(t)!==t)return c.error("Numeric branch labels must be integer values.");if(i){if(c.checkSubtype(i,gr(t)))return null}else i=gr(t);if(void 0!==r[String(t)])return c.error("Branch labels must be unique.");r[String(t)]=o.length}const d=e.parse(l,s,n);if(!d)return null;n=n||d.type,o.push(d)}const s=e.parse(t[1],1,er);if(!s)return null;const a=e.parse(t[t.length-1],t.length-1,n);return a?"value"!==s.type.kind&&e.concat(1).checkSubtype(i,s.type)?null:new Ms(i,n,s,r,o,a):null}evaluate(t){const e=this.input.evaluate(t);return(gr(e)===this.inputType&&this.outputs[this.cases[e]]||this.otherwise).evaluate(t)}eachChild(t){t(this.input),this.outputs.forEach(t),t(this.otherwise)}outputDefined(){return this.outputs.every((t=>t.outputDefined()))&&this.otherwise.outputDefined()}serialize(){const t=["match",this.input.serialize()],e=Object.keys(this.cases).sort(),i=[],n={};for(const t of e){const e=n[this.cases[t]];void 0===e?(n[this.cases[t]]=i.length,i.push([this.cases[t],[t]])):i[e][1].push(t)}const r=t=>"number"===this.inputType.kind?Number(t):t;for(const[e,n]of i)t.push(1===n.length?r(n[0]):n.map(r)),t.push(this.outputs[e].serialize());return t.push(this.otherwise.serialize()),t}}class Cs{constructor(t,e,i){this.type=t,this.branches=e,this.otherwise=i}static parse(t,e){if(t.lengthe.outputDefined()))&&this.otherwise.outputDefined()}serialize(){const t=["case"];return this.eachChild((e=>{t.push(e.serialize())})),t}}class As{constructor(t,e,i,n){this.type=t,this.input=e,this.beginIndex=i,this.endIndex=n}static parse(t,e){if(t.length=5)return e.error(`Expected 3 or 4 arguments, but found ${t.length-1} instead.`);const i=e.parse(t[1],1,er),n=e.parse(t[2],2,Xn);if(!i||!n)return null;if(!cr(i.type,[or(er),Kn,er]))return e.error(`Expected first argument to be of type array or string, but found ${sr(i.type)} instead`);if(4===t.length){const r=e.parse(t[3],3,Xn);return r?new As(i.type,i,n,r):null}return new As(i.type,i,n)}evaluate(t){const e=this.input.evaluate(t),i=this.beginIndex.evaluate(t);if(!dr(e,["string","array"]))throw new xr(`Expected first argument to be of type array or string, but found ${sr(gr(e))} instead.`);if(this.endIndex){const n=this.endIndex.evaluate(t);return e.slice(i,n)}return e.slice(i)}eachChild(t){t(this.input),t(this.beginIndex),this.endIndex&&t(this.endIndex)}outputDefined(){return!1}serialize(){if(null!=this.endIndex&&void 0!==this.endIndex){const t=this.endIndex.serialize();return["slice",this.input.serialize(),this.beginIndex.serialize(),t]}return["slice",this.input.serialize(),this.beginIndex.serialize()]}}function Is(t,e){return"=="===t||"!="===t?"boolean"===e.kind||"string"===e.kind||"number"===e.kind||"null"===e.kind||"value"===e.kind:"string"===e.kind||"number"===e.kind||"value"===e.kind}function Ls(t,e,i,n){return 0===n.compare(e,i)}function Ps(t,e,i){const n="=="!==t&&"!="!==t;return class r{constructor(t,e,i){this.type=Jn,this.lhs=t,this.rhs=e,this.collator=i,this.hasUntypedArgument="value"===t.type.kind||"value"===e.type.kind}static parse(t,e){if(3!==t.length&&4!==t.length)return e.error("Expected two or three arguments.");const i=t[0];let o=e.parse(t[1],1,er);if(!o)return null;if(!Is(i,o.type))return e.concat(1).error(`"${i}" comparisons are not supported for type '${sr(o.type)}'.`);let s=e.parse(t[2],2,er);if(!s)return null;if(!Is(i,s.type))return e.concat(2).error(`"${i}" comparisons are not supported for type '${sr(s.type)}'.`);if(o.type.kind!==s.type.kind&&"value"!==o.type.kind&&"value"!==s.type.kind)return e.error(`Cannot compare types '${sr(o.type)}' and '${sr(s.type)}'.`);n&&("value"===o.type.kind&&"value"!==s.type.kind?o=new wr(s.type,[o]):"value"!==o.type.kind&&"value"===s.type.kind&&(s=new wr(o.type,[s])));let a=null;if(4===t.length){if("string"!==o.type.kind&&"string"!==s.type.kind&&"value"!==o.type.kind&&"value"!==s.type.kind)return e.error("Cannot use collator to compare non-string types.");if(a=e.parse(t[3],3,ir),!a)return null}return new r(o,s,a)}evaluate(r){const o=this.lhs.evaluate(r),s=this.rhs.evaluate(r);if(n&&this.hasUntypedArgument){const e=gr(o),i=gr(s);if(e.kind!==i.kind||"string"!==e.kind&&"number"!==e.kind)throw new xr(`Expected arguments for "${t}" to be (string, string) or (number, number), but found (${e.kind}, ${i.kind}) instead.`)}if(this.collator&&!n&&this.hasUntypedArgument){const t=gr(o),i=gr(s);if("string"!==t.kind||"string"!==i.kind)return e(r,o,s)}return this.collator?i(r,o,s,this.collator.evaluate(r)):e(r,o,s)}eachChild(t){t(this.lhs),t(this.rhs),this.collator&&t(this.collator)}outputDefined(){return!0}serialize(){const e=[t];return this.eachChild((t=>{e.push(t.serialize())})),e}}}const $s=Ps("==",(function(t,e,i){return e===i}),Ls),ks=Ps("!=",(function(t,e,i){return e!==i}),(function(t,e,i,n){return!Ls(0,e,i,n)})),Ds=Ps("",(function(t,e,i){return e>i}),(function(t,e,i,n){return n.compare(e,i)>0})),Rs=Ps("=",(function(t,e,i){return e>=i}),(function(t,e,i,n){return n.compare(e,i)>=0}));class Bs{constructor(t,e,i,n,r,o){this.type=Kn,this.number=t,this.locale=e,this.currency=i,this.unit=n,this.minFractionDigits=r,this.maxFractionDigits=o}static parse(t,e){if(3!==t.length)return e.error("Expected two arguments.");const i=e.parse(t[1],1,Xn);if(!i)return null;const n=t[2];if("object"!=typeof n||Array.isArray(n))return e.error("NumberFormat options argument must be an object.");let r=null;if(n.locale&&(r=e.parse(n.locale,1,Kn),!r))return null;let o=null;if(n.currency&&(o=e.parse(n.currency,1,Kn),!o))return null;let s=null;if(n.unit&&(s=e.parse(n.unit,1,Kn),!s))return null;let a=null;if(n["min-fraction-digits"]&&(a=e.parse(n["min-fraction-digits"],1,Xn),!a))return null;let l=null;return n["max-fraction-digits"]&&(l=e.parse(n["max-fraction-digits"],1,Xn),!l)?null:new Bs(i,r,o,s,a,l)}evaluate(t){return new Intl.NumberFormat(this.locale?this.locale.evaluate(t):[],{style:(this.currency?"currency":this.unit&&"unit")||"decimal",currency:this.currency?this.currency.evaluate(t):void 0,unit:this.unit?this.unit.evaluate(t):void 0,minimumFractionDigits:this.minFractionDigits?this.minFractionDigits.evaluate(t):void 0,maximumFractionDigits:this.maxFractionDigits?this.maxFractionDigits.evaluate(t):void 0}).format(this.number.evaluate(t))}eachChild(t){t(this.number),this.locale&&t(this.locale),this.currency&&t(this.currency),this.unit&&t(this.unit),this.minFractionDigits&&t(this.minFractionDigits),this.maxFractionDigits&&t(this.maxFractionDigits)}outputDefined(){return!1}serialize(){const t={};return this.locale&&(t.locale=this.locale.serialize()),this.currency&&(t.currency=this.currency.serialize()),this.unit&&(t.unit=this.unit.serialize()),this.minFractionDigits&&(t["min-fraction-digits"]=this.minFractionDigits.serialize()),this.maxFractionDigits&&(t["max-fraction-digits"]=this.maxFractionDigits.serialize()),["number-format",this.number.serialize(),t]}}class Fs{constructor(t){this.type=Xn,this.input=t}static parse(t,e){if(2!==t.length)return e.error(`Expected 1 argument, but found ${t.length-1} instead.`);const i=e.parse(t[1],1);return i?"array"!==i.type.kind&&"string"!==i.type.kind&&"value"!==i.type.kind?e.error(`Expected argument of type string or array, but found ${sr(i.type)} instead.`):new Fs(i):null}evaluate(t){const e=this.input.evaluate(t);if("string"==typeof e)return e.length;if(Array.isArray(e))return e.length;throw new xr(`Expected value to be of type string or array, but found ${sr(gr(e))} instead.`)}eachChild(t){t(this.input)}outputDefined(){return!1}serialize(){const t=["length"];return this.eachChild((e=>{t.push(e.serialize())})),t}}function Ns(t){return function(){t=1831565813+(t|=0)|0;let e=Math.imul(t^t>>>15,1|t);return e=e+Math.imul(e^e>>>7,61|e)^e,((e^e>>>14)>>>0)/4294967296}}const Us={"==":$s,"!=":ks,">":zs,"=":Os,"=0&&t=0&&e=0&&i=0&&n-1}function Xs(t){return"data-driven"===t["property-type"]}function Ks(t){return Ys(t.expression,"measure-light")}function Js(t){return Ys(t.expression,"zoom")}function Qs(t){return!!t.expression&&t.expression.interpolated}function ta(t){return"object"==typeof t&&null!==t&&!Array.isArray(t)}function ea(t){return t}function ia(t,e){const i="color"===e.type,n=t.stops&&"object"==typeof t.stops[0][0],r=n||!(n||void 0!==t.property),o=t.type||(Qs(e)?"exponential":"interval");if(i&&((t=qn({},t)).stops&&(t.stops=t.stops.map((t=>[t[0],Un.parse(t[1])]))),t.default=Un.parse(t.default?t.default:e.default)),t.colorSpace&&"rgb"!==t.colorSpace&&!ys[t.colorSpace])throw new Error(`Unknown color space: ${t.colorSpace}`);let s,a,l;if("exponential"===o)s=sa;else if("interval"===o)s=oa;else if("categorical"===o){s=ra,a=Object.create(null);for(const e of t.stops)a[e[0]]=e[1];l=typeof t.stops[0][0]}else{if("identity"!==o)throw new Error(`Unknown function type "${o}"`);s=aa}if(n){const i={},n=[];for(let e=0;et[0])),evaluate:({zoom:i},n)=>sa({stops:r,base:t.base},e,i).evaluate(i,n)}}if(r){const i="exponential"===o?{name:"exponential",base:void 0!==t.base?t.base:1}:null;return{kind:"camera",interpolationType:i,interpolationFactor:vs.interpolationFactor.bind(void 0,i),zoomStops:t.stops.map((t=>t[0])),evaluate:({zoom:i})=>s(t,e,i,a,l)}}return{kind:"source",evaluate(i,n){const r=n&&n.properties?n.properties[t.property]:void 0;return void 0===r?na(t.default,e.default):s(t,e,r,a,l)}}}function na(t,e,i){return void 0!==t?t:void 0!==e?e:void 0!==i?i:void 0}function ra(t,e,i,n,r){return na(typeof i===r?n[i]:void 0,t.default,e.default)}function oa(t,e,i){if("number"!==Er(i))return na(t.default,e.default);const n=t.stops.length;if(1===n)return t.stops[0][1];if(i=t.stops[n-1][0])return t.stops[n-1][1];const r=Qo(t.stops.map((t=>t[0])),i);return t.stops[r][1]}function sa(t,e,i){const n=void 0!==t.base?t.base:1;if("number"!==Er(i))return na(t.default,e.default);const r=t.stops.length;if(1===r)return t.stops[0][1];if(i=t.stops[r-1][0])return t.stops[r-1][1];const o=Qo(t.stops.map((t=>t[0])),i),s=function(t,e,i,n){const r=n-i,o=t-i;return 0===r?0:1===e?o/r:(Math.pow(e,o)-1)/(Math.pow(e,r)-1)}(i,n,t.stops[o][0],t.stops[o+1][0]),a=t.stops[o][1],l=t.stops[o+1][1];let c=Zn[e.type]||ea;if(t.colorSpace&&"rgb"!==t.colorSpace){const e=ys[t.colorSpace];c=(t,i)=>e.reverse(e.interpolate(e.forward(t),e.forward(i),s))}return"function"==typeof a.evaluate?{evaluate(...t){const e=a.evaluate.apply(void 0,t),i=l.evaluate.apply(void 0,t);if(void 0!==e&&void 0!==i)return c(e,i,s)}}:c(a,l,s)}function aa(t,e,i){return"color"===e.type?i=Un.parse(i):"formatted"===e.type?i=pr.fromString(i.toString()):"resolvedImage"===e.type?i=fr.fromString(i.toString()):Er(i)===e.type||"enum"===e.type&&e.values[i]||(i=void 0),na(i,t.default,e.default)}Lr.register(Us,{error:[{kind:"error"},[Kn],(t,[e])=>{throw new xr(e.evaluate(t))}],typeof:[Kn,[er],(t,[e])=>sr(gr(e.evaluate(t)))],"to-rgba":[or(Xn,4),[Qn],(t,[e])=>e.evaluate(t).toRenderColor(null).toArray()],rgb:[Qn,[Xn,Xn,Xn],js],rgba:[Qn,[Xn,Xn,Xn,Xn],js],hsl:[Qn,[Xn,Xn,Xn],Vs],hsla:[Qn,[Xn,Xn,Xn,Xn],Vs],has:{type:Jn,overloads:[[[Kn],(t,[e])=>Gs(e.evaluate(t),t.properties())],[[Kn,tr],(t,[e,i])=>Gs(e.evaluate(t),i.evaluate(t))]]},get:{type:er,overloads:[[[Kn],(t,[e])=>Zs(e.evaluate(t),t.properties())],[[Kn,tr],(t,[e,i])=>Zs(e.evaluate(t),i.evaluate(t))]]},"feature-state":[er,[Kn],(t,[e])=>Zs(e.evaluate(t),t.featureState||{})],properties:[tr,[],t=>t.properties()],"geometry-type":[Kn,[],t=>t.geometryType()],id:[er,[],t=>t.id()],zoom:[Xn,[],t=>t.globals.zoom],pitch:[Xn,[],t=>t.globals.pitch||0],"distance-from-center":[Xn,[],t=>t.distanceFromCenter()],"measure-light":[Xn,[Kn],(t,[e])=>t.measureLight(e.evaluate(t))],"heatmap-density":[Xn,[],t=>t.globals.heatmapDensity||0],"line-progress":[Xn,[],t=>t.globals.lineProgress||0],"raster-value":[Xn,[],t=>t.globals.rasterValue||0],"raster-particle-speed":[Xn,[],t=>t.globals.rasterParticleSpeed||0],"sky-radial-progress":[Xn,[],t=>t.globals.skyRadialProgress||0],accumulated:[er,[],t=>void 0===t.globals.accumulated?null:t.globals.accumulated],"+":[Xn,qs(Xn),(t,e)=>{let i=0;for(const n of e)i+=n.evaluate(t);return i}],"*":[Xn,qs(Xn),(t,e)=>{let i=1;for(const n of e)i*=n.evaluate(t);return i}],"-":{type:Xn,overloads:[[[Xn,Xn],(t,[e,i])=>e.evaluate(t)-i.evaluate(t)],[[Xn],(t,[e])=>-e.evaluate(t)]]},"/":[Xn,[Xn,Xn],(t,[e,i])=>e.evaluate(t)/i.evaluate(t)],"%":[Xn,[Xn,Xn],(t,[e,i])=>e.evaluate(t)%i.evaluate(t)],ln2:[Xn,[],()=>Math.LN2],pi:[Xn,[],()=>Math.PI],e:[Xn,[],()=>Math.E],"^":[Xn,[Xn,Xn],(t,[e,i])=>Math.pow(e.evaluate(t),i.evaluate(t))],sqrt:[Xn,[Xn],(t,[e])=>Math.sqrt(e.evaluate(t))],log10:[Xn,[Xn],(t,[e])=>Math.log(e.evaluate(t))/Math.LN10],ln:[Xn,[Xn],(t,[e])=>Math.log(e.evaluate(t))],log2:[Xn,[Xn],(t,[e])=>Math.log(e.evaluate(t))/Math.LN2],sin:[Xn,[Xn],(t,[e])=>Math.sin(e.evaluate(t))],cos:[Xn,[Xn],(t,[e])=>Math.cos(e.evaluate(t))],tan:[Xn,[Xn],(t,[e])=>Math.tan(e.evaluate(t))],asin:[Xn,[Xn],(t,[e])=>Math.asin(e.evaluate(t))],acos:[Xn,[Xn],(t,[e])=>Math.acos(e.evaluate(t))],atan:[Xn,[Xn],(t,[e])=>Math.atan(e.evaluate(t))],min:[Xn,qs(Xn),(t,e)=>Math.min(...e.map((e=>e.evaluate(t))))],max:[Xn,qs(Xn),(t,e)=>Math.max(...e.map((e=>e.evaluate(t))))],abs:[Xn,[Xn],(t,[e])=>Math.abs(e.evaluate(t))],round:[Xn,[Xn],(t,[e])=>{const i=e.evaluate(t);return iMath.floor(e.evaluate(t))],ceil:[Xn,[Xn],(t,[e])=>Math.ceil(e.evaluate(t))],"filter-==":[Jn,[Kn,er],(t,[e,i])=>t.properties()[e.value]===i.value],"filter-id-==":[Jn,[er],(t,[e])=>t.id()===e.value],"filter-type-==":[Jn,[Kn],(t,[e])=>t.geometryType()===e.value],"filter-{const n=t.properties()[e.value],r=i.value;return typeof n==typeof r&&n{const i=t.id(),n=e.value;return typeof i==typeof n&&i":[Jn,[Kn,er],(t,[e,i])=>{const n=t.properties()[e.value],r=i.value;return typeof n==typeof r&&n>r}],"filter-id->":[Jn,[er],(t,[e])=>{const i=t.id(),n=e.value;return typeof i==typeof n&&i>n}],"filter-{const n=t.properties()[e.value],r=i.value;return typeof n==typeof r&&n{const i=t.id(),n=e.value;return typeof i==typeof n&&i=":[Jn,[Kn,er],(t,[e,i])=>{const n=t.properties()[e.value],r=i.value;return typeof n==typeof r&&n>=r}],"filter-id->=":[Jn,[er],(t,[e])=>{const i=t.id(),n=e.value;return typeof i==typeof n&&i>=n}],"filter-has":[Jn,[er],(t,[e])=>e.value in t.properties()],"filter-has-id":[Jn,[],t=>null!==t.id()&&void 0!==t.id()],"filter-type-in":[Jn,[or(Kn)],(t,[e])=>e.value.indexOf(t.geometryType())>=0],"filter-id-in":[Jn,[or(er)],(t,[e])=>e.value.indexOf(t.id())>=0],"filter-in-small":[Jn,[Kn,or(er)],(t,[e,i])=>i.value.indexOf(t.properties()[e.value])>=0],"filter-in-large":[Jn,[Kn,or(er)],(t,[e,i])=>function(t,e,i,n){for(;i>1;if(e[r]===t)return!0;e[r]>t?n=r-1:i=r+1}return!1}(t.properties()[e.value],i.value,0,i.value.length-1)],all:{type:Jn,overloads:[[[Jn,Jn],(t,[e,i])=>e.evaluate(t)&&i.evaluate(t)],[qs(Jn),(t,e)=>{for(const i of e)if(!i.evaluate(t))return!1;return!0}]]},any:{type:Jn,overloads:[[[Jn,Jn],(t,[e,i])=>e.evaluate(t)||i.evaluate(t)],[qs(Jn),(t,e)=>{for(const i of e)if(i.evaluate(t))return!0;return!1}]]},"!":[Jn,[Jn],(t,[e])=>!e.evaluate(t)],"is-supported-script":[Jn,[Kn],(t,[e])=>{const i=t.globals&&t.globals.isSupportedScript;return!i||i(e.evaluate(t))}],upcase:[Kn,[Kn],(t,[e])=>e.evaluate(t).toUpperCase()],downcase:[Kn,[Kn],(t,[e])=>e.evaluate(t).toLowerCase()],concat:[Kn,qs(er),(t,e)=>e.map((e=>yr(e.evaluate(t)))).join("")],"resolved-locale":[Kn,[ir],(t,[e])=>e.evaluate(t).resolvedLocale()],random:[Xn,[Xn,Xn,er],(t,e)=>{const[i,n,r]=e.map((e=>e.evaluate(t)));if(i>n)return i;if(i===n)return i;let o;if("string"==typeof r)o=function(t){let e=0;if(0===t.length)return e;for(let i=0;iJSON.stringify(t))).join(", ")}, but found ${JSON.stringify(t)} instead.`);return t}catch(t){return this._warningHistory[t.message]||(this._warningHistory[t.message]=!0,"undefined"!=typeof console&&console.warn(t.message)),this._defaultValue}}}function ca(t){return Array.isArray(t)&&t.length>0&&"string"==typeof t[0]&&t[0]in Us}function da(t,e,i,n){const r=new Ko(Us,[],e?function(t){const e={color:Qn,string:Kn,number:Xn,enum:Kn,boolean:Jn,formatted:nr,resolvedImage:rr};return"array"===t.type?or(e[t.value]||er,t.length):e[t.type]}(e):void 0,void 0,void 0,i,n),o=r.parse(t,void 0,void 0,void 0,e&&"string"===e.type?{typeAnnotation:"coerce"}:void 0);return o?Hs(new la(o,e,i,n)):Ws(r.errors)}class ua{constructor(t,e,i){this.kind=t,this._styleExpression=e,this.isLightConstant=i,this.isStateDependent="constant"!==t&&!qo(e.expression),this.isConfigDependent=!Ho(e.expression)}evaluateWithoutErrorHandling(t,e,i,n,r,o){return this._styleExpression.evaluateWithoutErrorHandling(t,e,i,n,r,o)}evaluate(t,e,i,n,r,o){return this._styleExpression.evaluate(t,e,i,n,r,o)}}class ha{constructor(t,e,i,n,r){this.kind=t,this.zoomStops=i,this._styleExpression=e,this.isStateDependent="camera"!==t&&!qo(e.expression),this.isLightConstant=r,this.isConfigDependent=!Ho(e.expression),this.interpolationType=n}evaluateWithoutErrorHandling(t,e,i,n,r,o){return this._styleExpression.evaluateWithoutErrorHandling(t,e,i,n,r,o)}evaluate(t,e,i,n,r,o){return this._styleExpression.evaluate(t,e,i,n,r,o)}interpolationFactor(t,e,i){return this.interpolationType?vs.interpolationFactor(this.interpolationType,t,e,i):0}}function pa(t,e,i,n){if("error"===(t=da(t,e,i,n)).result)return t;const r=t.value.expression,o=Zo(r);if(!o&&!Xs(e))return Ws([new Hn("","data expressions not supported")]);const s=Wo(r,["zoom","pitch","distance-from-center"]);if(!s&&!Js(e))return Ws([new Hn("","zoom expressions not supported")]);const a=Wo(r,["measure-light"]);if(!a&&!Ks(e))return Ws([new Hn("","measure-light expression not supported")]);const l=e.expression&&e.expression.relaxZoomRestriction,c=ma(r);return c||s||l?c instanceof Hn?Ws([c]):c instanceof vs&&!Qs(e)?Ws([new Hn("",'"interpolate" expressions cannot be used with this property')]):Hs(c?new ha(o?"camera":"composite",t.value,c.labels,c instanceof vs?c.interpolation:void 0,a):new ua(o?"constant":"source",t.value,a)):Ws([new Hn("",'"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression, or in the properties of atmosphere.')])}class fa{constructor(t,e){this._parameters=t,this._specification=e,qn(this,ia(this._parameters,this._specification))}static deserialize(t){return new fa(t._parameters,t._specification)}static serialize(t){return{_parameters:t._parameters,_specification:t._specification}}}function ma(t){let e=null;if(t instanceof ws)e=ma(t.result);else if(t instanceof bs){for(const i of t.args)if(e=ma(i),e)break}else(t instanceof ts||t instanceof vs)&&t.input instanceof Lr&&"zoom"===t.input.name&&(e=t);return e instanceof Hn||t.eachChild((t=>{const i=ma(t);i instanceof Hn?e=i:e&&i&&e!==i&&(e=new Hn("",'Only one zoom-based "step" or "interpolate" subexpression may be used in an expression.'))})),e}var _a=ya,ga=3;function ya(t,e,i){var n=this.cells=[];if(t instanceof ArrayBuffer){this.arrayBuffer=t;var r=new Int32Array(this.arrayBuffer);t=r[0],this.d=(e=r[1])+2*(i=r[2]);for(var o=0;o=d[p+0]&&n>=d[p+1])?(s[h]=!0,o.push(c[h])):s[h]=!1}}},ya.prototype._forEachCell=function(t,e,i,n,r,o,s,a){for(var l=this._convertToCellCoord(t),c=this._convertToCellCoord(e),d=this._convertToCellCoord(i),u=this._convertToCellCoord(n),h=l;h=0||(r[i]=Sa(t[i],e)));t instanceof Error&&(r.message=t.message)}if(r.$name)throw new Error("$name property is reserved for worker serialization logic.");return"Object"!==n&&(r.$name=n),r}throw new Error("can't serialize object of type "+typeof t)}function Ea(t){if(null==t||"boolean"==typeof t||"number"==typeof t||"string"==typeof t||t instanceof Boolean||t instanceof Number||t instanceof String||t instanceof Date||t instanceof RegExp||wa(t)||Ta(t)||ArrayBuffer.isView(t)||t instanceof ImageData)return t;if(Array.isArray(t))return t.map(Ea);if("object"==typeof t){const e=t.$name||"Object";if("Map"===e){const e=new Map;for(const i of Object.keys(t))"$name"!==i&&e.set(i,Ea(t[i]));return e}const{klass:i}=xa[e];if(!i)throw new Error(`can't deserialize unregistered class ${e}`);if(i.deserialize)return i.deserialize(t);const n=Object.create(i.prototype);for(const e of Object.keys(t))"$name"!==e&&(n[e]=Ea(t[e]));return n}throw new Error("can't deserialize object of type "+typeof t)}const Ma={"Latin-1 Supplement":t=>t>=128&&tt>=1536&&tt>=1872&&tt>=2208&&tt>=4352&&tt>=5120&&tt>=6016&&tt>=6320&&tt>=8192&&tt>=8448&&tt>=8528&&tt>=8960&&tt>=9216&&tt>=9280&&tt>=9312&&tt>=9632&&tt>=9728&&tt>=11008&&tt>=11904&&tt>=12032&&tt>=12272&&tt>=12288&&tt>=12352&&tt>=12448&&tt>=12544&&tt>=12592&&tt>=12688&&tt>=12704&&tt>=12736&&tt>=12784&&tt>=12800&&tt>=13056&&tt>=13312&&tt>=19904&&tt>=19968&&tt>=40960&&tt>=42128&&tt>=43360&&tt>=44032&&tt>=55216&&tt>=57344&&tt>=63744&&tt>=64336&&tt>=65040&&tt>=65072&&tt>=65104&&tt>=65136&&tt>=65280&&tt>=131072&&t=65097&&t=12296&&t=12308&&t=65306&&t=65371&&t=65512&&t=65112&&t=65123&&t=8960&&t=8972&&t=8996&&t=9085&&t=9150&&t=9169&&t=9186&&t=9754&&t=11026&&t=11088&&t=11192&&t=9984&&t=10102&&t=1424&&t=2304&&t=3840&&t-1&&(Fa="error"),Ba&&Ba(t)};function ja(){Va.fire(new Pn("pluginStateChange",{pluginStatus:Fa,pluginURL:Na}))}const Va=new zn,Ga=function(){return Fa},Za=function(){if(Fa!==za||!Na)throw new Error("rtl-text-plugin cannot be downloaded unless a pluginURL is specified");Fa=Ra,ja(),Na&&en({url:Na},(t=>{t?Ua(t):(Fa=Oa,ja())}))},qa={applyArabicShaping:null,processBidirectionalText:null,processStyledBidirectionalText:null,isLoaded:()=>Fa===Oa||null!=qa.applyArabicShaping,isLoading:()=>Fa===Ra,setState(t){Fa=t.pluginStatus,Na=t.pluginURL},isParsed:()=>null!=qa.applyArabicShaping&&null!=qa.processBidirectionalText&&null!=qa.processStyledBidirectionalText,getPluginURL:()=>Na};class Ha{constructor(t,e){this.zoom=t,e?(this.now=e.now,this.fadeDuration=e.fadeDuration,this.transition=e.transition,this.pitch=e.pitch,this.brightness=e.brightness):(this.now=0,this.fadeDuration=0,this.transition={},this.pitch=0,this.brightness=0)}isSupportedScript(t){return function(t,e){for(const i of t)if(!ka(i.charCodeAt(0),e))return!1;return!0}(t,qa.isLoaded())}}class Wa{constructor(t,e,i,n){this.property=t,this.value=e,this.expression=function(t,e,i,n){if(ta(t))return new fa(t,e);if(ca(t)||Array.isArray(t)&&t.length>0){const r=pa(t,e,i,n);if("error"===r.result)throw new Error(r.value.map((t=>`${t.key}: ${t.message}`)).join(", "));return r.value}{let i=t;return"string"==typeof t&&"color"===e.type&&(i=Un.parse(t)),{kind:"constant",isConfigDependent:!1,evaluate:()=>i}}}(void 0===e?t.specification.default:e,t.specification,i,n)}isDataDriven(){return"source"===this.expression.kind||"composite"===this.expression.kind}possiblyEvaluate(t,e,i){return this.property.possiblyEvaluate(this,t,e,i)}}class Ya{constructor(t,e,i){this.property=t,this.value=new Wa(t,void 0,e,i)}transitioned(t,e){return new Ka(this.property,this.value,e,ei({},t.transition,this.transition),t.now)}untransitioned(){return new Ka(this.property,this.value,null,{},0)}}class Xa{constructor(t,e,i){this._properties=t,this._values=Object.create(t.defaultTransitionablePropertyValues),this._scope=e,this._options=i,this.isConfigDependent=!1}getValue(t){return ui(this._values[t].value.value)}setValue(t,e){this._values.hasOwnProperty(t)||(this._values[t]=new Ya(this._values[t].property,this._scope,this._options)),this._values[t].value=new Wa(this._values[t].property,null===e?void 0:ui(e),this._scope,this._options),this.isConfigDependent=this.isConfigDependent||this._values[t].value.expression.isConfigDependent}setTransitionOrValue(t,e){e&&(this._options=e);const i=this._properties.properties;if(t)for(const e in t){const n=t[e];if(li(e,"-transition")){const t=e.slice(0,-11);i[t]&&this.setTransition(t,n)}else i.hasOwnProperty(e)&&this.setValue(e,n)}}getTransition(t){return ui(this._values[t].transition)}setTransition(t,e){this._values.hasOwnProperty(t)||(this._values[t]=new Ya(this._values[t].property)),this._values[t].transition=ui(e)||void 0}serialize(){const t={};for(const e of Object.keys(this._values)){const i=this.getValue(e);void 0!==i&&(t[e]=i);const n=this.getTransition(e);void 0!==n&&(t[`${e}-transition`]=n)}return t}transitioned(t,e){const i=new Ja(this._properties);for(const n of Object.keys(this._values))i._values[n]=this._values[n].transitioned(t,e._values[n]);return i}untransitioned(){const t=new Ja(this._properties);for(const e of Object.keys(this._values))t._values[e]=this._values[e].untransitioned();return t}}class Ka{constructor(t,e,i,n,r){const o=n.delay||0,s=n.duration||0;r=r||0,this.property=t,this.value=e,this.begin=r+o,this.end=this.begin+s,t.specification.transition&&(n.delay||n.duration)&&(this.prior=i)}possiblyEvaluate(t,e,i){const n=t.now||0,r=this.value.possiblyEvaluate(t,e,i),o=this.prior;if(o){if(n>this.end)return this.prior=null,r;if(this.value.isDataDriven())return this.prior=null,r;if(n":1,">=":1,"=2&&"$id"!==t[1]&&"$type"!==t[1];case"in":return t.length>=3&&("string"!=typeof t[1]||Array.isArray(t[2]));case"!in":case"!has":case"none":return!1;case"==":case"!=":case">":case">=":case"!0,needGeometry:!1,needFeature:!1};cl(t)||(t=gl(t));const i=t;let n=!0;try{n=function(t){if(!pl(t))return t;let e=ll(t);return hl(e),e=ul(e),e}(i)}catch(t){console.warn(`Failed to extract static filter. Filter will continue working, but at higher memory usage and slower framerate.\nThis is most likely a bug, please report this via https://github.com/mapbox/mapbox-gl-js/issues/new?assignees=&labels=&template=Bug_report.md\nand paste the contents of this message in the report.\nThank you!\nFilter Expression:\n${JSON.stringify(i,null,2)}\n `)}const r=sl[`filter_${e}`],o=da(n,r);let s=null;if("error"===o.result)throw new Error(o.value.map((t=>`${t.key}: ${t.message}`)).join(", "));s=(t,e,i)=>o.value.evaluate(t,e,{},i);let a=null,l=null;if(n!==i){const t=da(i,r);if("error"===t.result)throw new Error(t.value.map((t=>`${t.key}: ${t.message}`)).join(", "));a=(e,i,n,r,o)=>t.value.evaluate(e,i,{},n,void 0,void 0,r,o),l=!Zo(t.value.expression)}return{filter:s,dynamicFilter:a||void 0,needGeometry:_l(n),needFeature:!!l}}function ul(t){if(!Array.isArray(t))return t;const e=function(t){if(fl.has(t[0]))for(let e=1;eul(t)))}function hl(t){let e=!1;const i=[];if("case"===t[0]){for(let n=1;n",">=","e?1:0}function _l(t){if(!Array.isArray(t))return!1;if("within"===t[0]||"distance"===t[0])return!0;for(let e=1;e"===e||"="===e?yl(t[1],t[2],e):"any"===e?(i=t.slice(1),["any"].concat(i.map(gl))):"all"===e?["all"].concat(t.slice(1).map(gl)):"none"===e?["all"].concat(t.slice(1).map(gl).map(bl)):"in"===e?vl(t[1],t.slice(2)):"!in"===e?bl(vl(t[1],t.slice(2))):"has"===e?xl(t[1]):"!has"!==e||bl(xl(t[1]));var i}function yl(t,e,i){switch(t){case"$type":return[`filter-type-${i}`,e];case"$id":return[`filter-id-${i}`,e];default:return[`filter-${i}`,t,e]}}function vl(t,e){if(0===e.length)return!1;switch(t){case"$type":return["filter-type-in",["literal",e]];case"$id":return["filter-id-in",["literal",e]];default:return e.length>200&&!e.some((t=>typeof t!=typeof e[0]))?["filter-in-large",t,["literal",e.sort(ml)]]:["filter-in-small",t,["literal",e]]}}function xl(t){switch(t){case"$type":return!0;case"$id":return["filter-has-id"];default:return["filter-has",t]}}function bl(t){return["!",t]}const wl="";function Tl(t,e){return e?`${t}${wl}${e}`:t}const Sl="-transition",El=new Set(["fill","line","background","hillshade","raster"]);class Ml extends zn{constructor(t,e,i,n,r){if(super(),this.id=t.id,this.fqid=Tl(this.id,i),this.type=t.type,this.scope=i,this.lut=n,this.options=r,this._featureFilter={filter:()=>!0,needGeometry:!1,needFeature:!1},this._filterCompiled=!1,this.isConfigDependent=!1,"custom"!==t.type&&(this.metadata=t.metadata,this.minzoom=t.minzoom,this.maxzoom=t.maxzoom,"background"!==t.type&&"sky"!==t.type&&"slot"!==t.type&&(this.source=t.source,this.sourceLayer=t["source-layer"],this.filter=t.filter),t.slot&&(this.slot=t.slot),e.layout&&(this._unevaluatedLayout=new Qa(e.layout,this.scope,r),this.isConfigDependent=this.isConfigDependent||this._unevaluatedLayout.isConfigDependent),e.paint)){this._transitionablePaint=new Xa(e.paint,this.scope,r);for(const e in t.paint)this.setPaintProperty(e,t.paint[e]);for(const e in t.layout)this.setLayoutProperty(e,t.layout[e]);this.isConfigDependent=this.isConfigDependent||this._transitionablePaint.isConfigDependent,this._transitioningPaint=this._transitionablePaint.untransitioned(),this.paint=new el(e.paint)}}onAdd(t){}onRemove(t){}isDraped(t){return El.has(this.type)}getLayoutProperty(t){return"visibility"===t?this.visibility:this._unevaluatedLayout.getValue(t)}setLayoutProperty(t,e){if("custom"===this.type&&"visibility"===t)return void(this.visibility=e);const i=this._unevaluatedLayout;i._properties.properties[t]&&(i.setValue(t,e),this.isConfigDependent=this.isConfigDependent||i.isConfigDependent,"visibility"===t&&this.possiblyEvaluateVisibility())}possiblyEvaluateVisibility(){this.visibility=this._unevaluatedLayout._values.visibility.possiblyEvaluate({zoom:0})}getPaintProperty(t){return li(t,Sl)?this._transitionablePaint.getTransition(t.slice(0,-11)):this._transitionablePaint.getValue(t)}setPaintProperty(t,e){const i=this._transitionablePaint,n=i._properties.properties;if(li(t,Sl)){const r=t.slice(0,-11);return n[r]&&i.setTransition(r,e||void 0),!1}if(!n[t])return!1;const r=i._values[t],o=r.value.isDataDriven(),s=r.value;i.setValue(t,e),this.isConfigDependent=this.isConfigDependent||i.isConfigDependent,this._handleSpecialPaintPropertyUpdate(t);const a=i._values[t].value,l=a.isDataDriven(),c=li(t,"pattern")||"line-dasharray"===t;return l||o||c||this._handleOverridablePaintPropertyUpdate(t,s,a)}_handleSpecialPaintPropertyUpdate(t){}getProgramIds(){return null}getDefaultProgramParams(t,e,i){return null}_handleOverridablePaintPropertyUpdate(t,e,i){return!1}isHidden(t){return!!(this.minzoom&&t=this.maxzoom)||"none"===this.visibility}updateTransitions(t){this._transitioningPaint=this._transitionablePaint.transitioned(t,this._transitioningPaint)}hasTransition(){return this._transitioningPaint.hasTransition()}recalculate(t,e){this._unevaluatedLayout&&(this.layout=this._unevaluatedLayout.possiblyEvaluate(t,void 0,e)),this.paint=this._transitioningPaint.possiblyEvaluate(t,void 0,e)}serialize(){return di({id:this.id,type:this.type,slot:this.slot,source:this.source,"source-layer":this.sourceLayer,metadata:this.metadata,minzoom:this.minzoom,maxzoom:this.maxzoom,filter:this.filter,layout:this._unevaluatedLayout&&this._unevaluatedLayout.serialize(),paint:this._transitionablePaint&&this._transitionablePaint.serialize()},((t,e)=>!(void 0===t||"layout"===e&&!Object.keys(t).length||"paint"===e&&!Object.keys(t).length)))}is3D(){return!1}isSky(){return!1}isTileClipped(){return!1}hasOffscreenPass(){return!1}hasShadowPass(){return!1}canCastShadows(){return!1}hasLightBeamPass(){return!1}cutoffRange(){return 0}tileCoverLift(){return 0}resize(){}isStateDependent(){for(const t in this.paint._values){const e=this.paint.get(t);if(e instanceof tl&&Xs(e.property.specification)&&("source"===e.value.kind||"composite"===e.value.kind)&&e.value.isStateDependent)return!0}return!1}compileFilter(){this._filterCompiled||(this._featureFilter=dl(this.filter),this._filterCompiled=!0)}invalidateCompiledFilter(){this._filterCompiled=!1}dynamicFilter(){return this._featureFilter.dynamicFilter}dynamicFilterNeedsFeature(){return this._featureFilter.needFeature}getLayerRenderingStats(){return this._stats}resetLayerRenderingStats(t){this._stats&&("shadow"===t.renderPass?this._stats.numRenderedVerticesInShadowPass=0:this._stats.numRenderedVerticesInTransparentPass=0)}queryRadius(t){}queryIntersectsFeature(t,e,i,n,r,o,s,a,l){}queryIntersectsMatchingFeature(t,e,i,n){}}const Cl={Int8:Int8Array,Uint8:Uint8Array,Int16:Int16Array,Uint16:Uint16Array,Int32:Int32Array,Uint32:Uint32Array,Float32:Float32Array};class Al{constructor(t,e){this._structArray=t,this._pos1=e*this.size,this._pos2=this._pos1/2,this._pos4=this._pos1/4,this._pos8=this._pos1/8}}class Il{constructor(){this.isTransferred=!1,this.capacity=-1,this.resize(0)}static serialize(t,e){return t._trim(),e&&(t.isTransferred=!0,e.add(t.arrayBuffer)),{length:t.length,arrayBuffer:t.arrayBuffer}}static deserialize(t){const e=Object.create(this.prototype);return e.arrayBuffer=t.arrayBuffer,e.length=t.length,e.capacity=t.arrayBuffer.byteLength/e.bytesPerElement,e._refreshViews(),e}_trim(){this.length!==this.capacity&&(this.capacity=this.length,this.arrayBuffer=this.arrayBuffer.slice(0,this.length*this.bytesPerElement),this._refreshViews())}clear(){this.length=0}resize(t){this.reserve(t),this.length=t}reserve(t){if(t>this.capacity){this.capacity=Math.max(t,Math.floor(5*this.capacity),128),this.arrayBuffer=new ArrayBuffer(this.capacity*this.bytesPerElement);const e=this.uint8;this._refreshViews(),e&&this.uint8.set(e)}}_refreshViews(){throw new Error("StructArray#_refreshViews() must be implemented by each concrete StructArray layout")}emplace(...t){throw new Error("StructArray#emplace() must be implemented by each concrete StructArray layout")}emplaceBack(...t){throw new Error("StructArray#emplaceBack() must be implemented by each concrete StructArray layout")}destroy(){this.int8=this.uint8=this.int16=this.uint16=this.int32=this.uint32=this.float32=null,this.arrayBuffer=null}}function Ll(t,e=1){let i=0,n=0;return{members:t.map((t=>{const r=Cl[t.type].BYTES_PER_ELEMENT,o=i=Pl(i,Math.max(e,r)),s=t.components||1;return n=Math.max(n,r),i+=r*s,{name:t.name,type:t.type,components:s,offset:o}})),size:Pl(i,Math.max(n,e)),alignment:e}}function Pl(t,e){return Math.ceil(t/e)*e}class $l extends Il{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,e){const i=this.length;return this.resize(i+1),this.emplace(i,t,e)}emplace(t,e,i){const n=2*t;return this.int16[n+0]=e,this.int16[n+1]=i,t}}$l.prototype.bytesPerElement=4,ba($l,"StructArrayLayout2i4");class kl extends Il{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,e,i){const n=this.length;return this.resize(n+1),this.emplace(n,t,e,i)}emplace(t,e,i,n){const r=3*t;return this.int16[r+0]=e,this.int16[r+1]=i,this.int16[r+2]=n,t}}kl.prototype.bytesPerElement=6,ba(kl,"StructArrayLayout3i6");class Dl extends Il{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,e,i,n){const r=this.length;return this.resize(r+1),this.emplace(r,t,e,i,n)}emplace(t,e,i,n,r){const o=4*t;return this.int16[o+0]=e,this.int16[o+1]=i,this.int16[o+2]=n,this.int16[o+3]=r,t}}Dl.prototype.bytesPerElement=8,ba(Dl,"StructArrayLayout4i8");class zl extends Il{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,e,i,n,r){const o=this.length;return this.resize(o+1),this.emplace(o,t,e,i,n,r)}emplace(t,e,i,n,r,o){const s=5*t;return this.int16[s+0]=e,this.int16[s+1]=i,this.int16[s+2]=n,this.int16[s+3]=r,this.int16[s+4]=o,t}}zl.prototype.bytesPerElement=10,ba(zl,"StructArrayLayout5i10");class Rl extends Il{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t,e,i,n,r,o,s){const a=this.length;return this.resize(a+1),this.emplace(a,t,e,i,n,r,o,s)}emplace(t,e,i,n,r,o,s,a){const l=6*t,c=12*t,d=3*t;return this.int16[l+0]=e,this.int16[l+1]=i,this.uint8[c+4]=n,this.uint8[c+5]=r,this.uint8[c+6]=o,this.uint8[c+7]=s,this.float32[d+2]=a,t}}Rl.prototype.bytesPerElement=12,ba(Rl,"StructArrayLayout2i4ub1f12");class Ol extends Il{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t,e,i,n){const r=this.length;return this.resize(r+1),this.emplace(r,t,e,i,n)}emplace(t,e,i,n,r){const o=4*t;return this.float32[o+0]=e,this.float32[o+1]=i,this.float32[o+2]=n,this.float32[o+3]=r,t}}Ol.prototype.bytesPerElement=16,ba(Ol,"StructArrayLayout4f16");class Bl extends Il{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t,e,i){const n=this.length;return this.resize(n+1),this.emplace(n,t,e,i)}emplace(t,e,i,n){const r=3*t;return this.float32[r+0]=e,this.float32[r+1]=i,this.float32[r+2]=n,t}}Bl.prototype.bytesPerElement=12,ba(Bl,"StructArrayLayout3f12");class Fl extends Il{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t,e,i,n,r){const o=this.length;return this.resize(o+1),this.emplace(o,t,e,i,n,r)}emplace(t,e,i,n,r,o){const s=6*t,a=3*t;return this.uint16[s+0]=e,this.uint16[s+1]=i,this.uint16[s+2]=n,this.uint16[s+3]=r,this.float32[a+2]=o,t}}Fl.prototype.bytesPerElement=12,ba(Fl,"StructArrayLayout4ui1f12");class Nl extends Il{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(t,e,i,n){const r=this.length;return this.resize(r+1),this.emplace(r,t,e,i,n)}emplace(t,e,i,n,r){const o=4*t;return this.uint16[o+0]=e,this.uint16[o+1]=i,this.uint16[o+2]=n,this.uint16[o+3]=r,t}}Nl.prototype.bytesPerElement=8,ba(Nl,"StructArrayLayout4ui8");class Ul extends Il{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,e,i,n,r,o){const s=this.length;return this.resize(s+1),this.emplace(s,t,e,i,n,r,o)}emplace(t,e,i,n,r,o,s){const a=6*t;return this.int16[a+0]=e,this.int16[a+1]=i,this.int16[a+2]=n,this.int16[a+3]=r,this.int16[a+4]=o,this.int16[a+5]=s,t}}Ul.prototype.bytesPerElement=12,ba(Ul,"StructArrayLayout6i12");class jl extends Il{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(t,e,i,n,r,o,s,a,l,c,d,u){const h=this.length;return this.resize(h+1),this.emplace(h,t,e,i,n,r,o,s,a,l,c,d,u)}emplace(t,e,i,n,r,o,s,a,l,c,d,u,h){const p=12*t;return this.int16[p+0]=e,this.int16[p+1]=i,this.int16[p+2]=n,this.int16[p+3]=r,this.uint16[p+4]=o,this.uint16[p+5]=s,this.uint16[p+6]=a,this.uint16[p+7]=l,this.int16[p+8]=c,this.int16[p+9]=d,this.int16[p+10]=u,this.int16[p+11]=h,t}}jl.prototype.bytesPerElement=24,ba(jl,"StructArrayLayout4i4ui4i24");class Vl extends Il{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t,e,i,n,r,o){const s=this.length;return this.resize(s+1),this.emplace(s,t,e,i,n,r,o)}emplace(t,e,i,n,r,o,s){const a=10*t,l=5*t;return this.int16[a+0]=e,this.int16[a+1]=i,this.int16[a+2]=n,this.float32[l+2]=r,this.float32[l+3]=o,this.float32[l+4]=s,t}}Vl.prototype.bytesPerElement=20,ba(Vl,"StructArrayLayout3i3f20");class Gl extends Il{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer)}emplaceBack(t){const e=this.length;return this.resize(e+1),this.emplace(e,t)}emplace(t,e){return this.uint32[1*t+0]=e,t}}Gl.prototype.bytesPerElement=4,ba(Gl,"StructArrayLayout1ul4");class Zl extends Il{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t){const e=this.length;return this.resize(e+1),this.emplace(e,t)}emplace(t,e){return this.float32[1*t+0]=e,t}}Zl.prototype.bytesPerElement=4,ba(Zl,"StructArrayLayout1f4");class ql extends Il{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(t,e){const i=this.length;return this.resize(i+1),this.emplace(i,t,e)}emplace(t,e,i){const n=2*t;return this.uint16[n+0]=e,this.uint16[n+1]=i,t}}ql.prototype.bytesPerElement=4,ba(ql,"StructArrayLayout2ui4");class Hl extends Il{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(t,e,i,n,r,o,s,a,l,c,d,u,h){const p=this.length;return this.resize(p+1),this.emplace(p,t,e,i,n,r,o,s,a,l,c,d,u,h)}emplace(t,e,i,n,r,o,s,a,l,c,d,u,h,p){const f=20*t,m=10*t;return this.int16[f+0]=e,this.int16[f+1]=i,this.int16[f+2]=n,this.int16[f+3]=r,this.int16[f+4]=o,this.float32[m+3]=s,this.float32[m+4]=a,this.float32[m+5]=l,this.float32[m+6]=c,this.int16[f+14]=d,this.uint32[m+8]=u,this.uint16[f+18]=h,this.uint16[f+19]=p,t}}Hl.prototype.bytesPerElement=40,ba(Hl,"StructArrayLayout5i4f1i1ul2ui40");class Wl extends Il{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,e,i,n,r,o,s){const a=this.length;return this.resize(a+1),this.emplace(a,t,e,i,n,r,o,s)}emplace(t,e,i,n,r,o,s,a){const l=8*t;return this.int16[l+0]=e,this.int16[l+1]=i,this.int16[l+2]=n,this.int16[l+4]=r,this.int16[l+5]=o,this.int16[l+6]=s,this.int16[l+7]=a,t}}Wl.prototype.bytesPerElement=16,ba(Wl,"StructArrayLayout3i2i2i16");class Yl extends Il{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,e,i,n,r){const o=this.length;return this.resize(o+1),this.emplace(o,t,e,i,n,r)}emplace(t,e,i,n,r,o){const s=4*t,a=8*t;return this.float32[s+0]=e,this.float32[s+1]=i,this.float32[s+2]=n,this.int16[a+6]=r,this.int16[a+7]=o,t}}Yl.prototype.bytesPerElement=16,ba(Yl,"StructArrayLayout2f1f2i16");class Xl extends Il{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t,e,i,n){const r=this.length;return this.resize(r+1),this.emplace(r,t,e,i,n)}emplace(t,e,i,n,r){const o=12*t,s=3*t;return this.uint8[o+0]=e,this.uint8[o+1]=i,this.float32[s+1]=n,this.float32[s+2]=r,t}}Xl.prototype.bytesPerElement=12,ba(Xl,"StructArrayLayout2ub2f12");class Kl extends Il{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(t,e,i){const n=this.length;return this.resize(n+1),this.emplace(n,t,e,i)}emplace(t,e,i,n){const r=3*t;return this.uint16[r+0]=e,this.uint16[r+1]=i,this.uint16[r+2]=n,t}}Kl.prototype.bytesPerElement=6,ba(Kl,"StructArrayLayout3ui6");class Jl extends Il{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer)}emplaceBack(t,e,i,n,r,o,s,a,l,c,d,u,h,p,f,m,_,g,y,v,x){const b=this.length;return this.resize(b+1),this.emplace(b,t,e,i,n,r,o,s,a,l,c,d,u,h,p,f,m,_,g,y,v,x)}emplace(t,e,i,n,r,o,s,a,l,c,d,u,h,p,f,m,_,g,y,v,x,b){const w=30*t,T=15*t,S=60*t;return this.int16[w+0]=e,this.int16[w+1]=i,this.int16[w+2]=n,this.float32[T+2]=r,this.float32[T+3]=o,this.uint16[w+8]=s,this.uint16[w+9]=a,this.uint32[T+5]=l,this.uint32[T+6]=c,this.uint32[T+7]=d,this.uint16[w+16]=u,this.uint16[w+17]=h,this.uint16[w+18]=p,this.float32[T+10]=f,this.float32[T+11]=m,this.uint8[S+48]=_,this.uint8[S+49]=g,this.uint8[S+50]=y,this.uint32[T+13]=v,this.int16[w+28]=x,this.uint8[S+58]=b,t}}Jl.prototype.bytesPerElement=60,ba(Jl,"StructArrayLayout3i2f2ui3ul3ui2f3ub1ul1i1ub60");class Ql extends Il{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer)}emplaceBack(t,e,i,n,r,o,s,a,l,c,d,u,h,p,f,m,_,g,y,v,x,b,w,T,S,E,M,C,A,I,L,P,$,k){const D=this.length;return this.resize(D+1),this.emplace(D,t,e,i,n,r,o,s,a,l,c,d,u,h,p,f,m,_,g,y,v,x,b,w,T,S,E,M,C,A,I,L,P,$,k)}emplace(t,e,i,n,r,o,s,a,l,c,d,u,h,p,f,m,_,g,y,v,x,b,w,T,S,E,M,C,A,I,L,P,$,k,D){const z=22*t,R=44*t,O=88*t;return this.float32[z+0]=e,this.float32[z+1]=i,this.int16[R+4]=n,this.int16[R+5]=r,this.int16[R+6]=o,this.int16[R+7]=s,this.int16[R+8]=a,this.int16[R+9]=l,this.int16[R+10]=c,this.int16[R+11]=d,this.int16[R+12]=u,this.uint16[R+13]=h,this.uint16[R+14]=p,this.uint16[R+15]=f,this.uint16[R+16]=m,this.uint16[R+17]=_,this.uint16[R+18]=g,this.uint16[R+19]=y,this.uint16[R+20]=v,this.uint16[R+21]=x,this.uint16[R+22]=b,this.uint16[R+23]=w,this.uint16[R+24]=T,this.uint16[R+25]=S,this.uint16[R+26]=E,this.uint16[R+27]=M,this.uint32[z+14]=C,this.float32[z+15]=A,this.float32[z+16]=I,this.float32[z+17]=L,this.float32[z+18]=P,this.float32[z+19]=$,this.float32[z+20]=k,this.uint8[O+84]=D,t}}Ql.prototype.bytesPerElement=88,ba(Ql,"StructArrayLayout2f9i15ui1ul6f1ub88");class tc extends Il{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t,e,i,n,r){const o=this.length;return this.resize(o+1),this.emplace(o,t,e,i,n,r)}emplace(t,e,i,n,r,o){const s=5*t;return this.float32[s+0]=e,this.float32[s+1]=i,this.float32[s+2]=n,this.float32[s+3]=r,this.float32[s+4]=o,t}}tc.prototype.bytesPerElement=20,ba(tc,"StructArrayLayout5f20");class ec extends Il{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t,e,i,n,r,o,s){const a=this.length;return this.resize(a+1),this.emplace(a,t,e,i,n,r,o,s)}emplace(t,e,i,n,r,o,s,a){const l=7*t;return this.float32[l+0]=e,this.float32[l+1]=i,this.float32[l+2]=n,this.float32[l+3]=r,this.float32[l+4]=o,this.float32[l+5]=s,this.float32[l+6]=a,t}}ec.prototype.bytesPerElement=28,ba(ec,"StructArrayLayout7f28");class ic extends Il{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t,e){const i=this.length;return this.resize(i+1),this.emplace(i,t,e)}emplace(t,e,i){const n=2*t;return this.float32[n+0]=e,this.float32[n+1]=i,t}}ic.prototype.bytesPerElement=8,ba(ic,"StructArrayLayout2f8");class nc extends Il{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(t,e,i,n){const r=this.length;return this.resize(r+1),this.emplace(r,t,e,i,n)}emplace(t,e,i,n,r){const o=6*t;return this.uint32[3*t+0]=e,this.uint16[o+2]=i,this.uint16[o+3]=n,this.uint16[o+4]=r,t}}nc.prototype.bytesPerElement=12,ba(nc,"StructArrayLayout1ul3ui12");class rc extends Il{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(t){const e=this.length;return this.resize(e+1),this.emplace(e,t)}emplace(t,e){return this.uint16[1*t+0]=e,t}}rc.prototype.bytesPerElement=2,ba(rc,"StructArrayLayout1ui2");class oc extends Il{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t,e,i,n,r,o,s,a,l,c,d,u,h,p,f,m){const _=this.length;return this.resize(_+1),this.emplace(_,t,e,i,n,r,o,s,a,l,c,d,u,h,p,f,m)}emplace(t,e,i,n,r,o,s,a,l,c,d,u,h,p,f,m,_){const g=16*t;return this.float32[g+0]=e,this.float32[g+1]=i,this.float32[g+2]=n,this.float32[g+3]=r,this.float32[g+4]=o,this.float32[g+5]=s,this.float32[g+6]=a,this.float32[g+7]=l,this.float32[g+8]=c,this.float32[g+9]=d,this.float32[g+10]=u,this.float32[g+11]=h,this.float32[g+12]=p,this.float32[g+13]=f,this.float32[g+14]=m,this.float32[g+15]=_,t}}oc.prototype.bytesPerElement=64,ba(oc,"StructArrayLayout16f64");class sc extends Il{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t,e,i,n,r,o,s){const a=this.length;return this.resize(a+1),this.emplace(a,t,e,i,n,r,o,s)}emplace(t,e,i,n,r,o,s,a){const l=10*t,c=5*t;return this.uint16[l+0]=e,this.uint16[l+1]=i,this.uint16[l+2]=n,this.uint16[l+3]=r,this.float32[c+2]=o,this.float32[c+3]=s,this.float32[c+4]=a,t}}sc.prototype.bytesPerElement=20,ba(sc,"StructArrayLayout4ui3f20");class ac extends Il{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t){const e=this.length;return this.resize(e+1),this.emplace(e,t)}emplace(t,e){return this.int16[1*t+0]=e,t}}ac.prototype.bytesPerElement=2,ba(ac,"StructArrayLayout1i2");class lc extends Il{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer)}emplaceBack(t){const e=this.length;return this.resize(e+1),this.emplace(e,t)}emplace(t,e){return this.uint8[1*t+0]=e,t}}lc.prototype.bytesPerElement=1,ba(lc,"StructArrayLayout1ub1");class cc extends Al{get projectedAnchorX(){return this._structArray.int16[this._pos2+0]}get projectedAnchorY(){return this._structArray.int16[this._pos2+1]}get projectedAnchorZ(){return this._structArray.int16[this._pos2+2]}get tileAnchorX(){return this._structArray.int16[this._pos2+3]}get tileAnchorY(){return this._structArray.int16[this._pos2+4]}get x1(){return this._structArray.float32[this._pos4+3]}get y1(){return this._structArray.float32[this._pos4+4]}get x2(){return this._structArray.float32[this._pos4+5]}get y2(){return this._structArray.float32[this._pos4+6]}get padding(){return this._structArray.int16[this._pos2+14]}get featureIndex(){return this._structArray.uint32[this._pos4+8]}get sourceLayerIndex(){return this._structArray.uint16[this._pos2+18]}get bucketIndex(){return this._structArray.uint16[this._pos2+19]}}cc.prototype.size=40;class dc extends Hl{get(t){return new cc(this,t)}}ba(dc,"CollisionBoxArray");class uc extends Al{get projectedAnchorX(){return this._structArray.int16[this._pos2+0]}get projectedAnchorY(){return this._structArray.int16[this._pos2+1]}get projectedAnchorZ(){return this._structArray.int16[this._pos2+2]}get tileAnchorX(){return this._structArray.float32[this._pos4+2]}get tileAnchorY(){return this._structArray.float32[this._pos4+3]}get glyphStartIndex(){return this._structArray.uint16[this._pos2+8]}get numGlyphs(){return this._structArray.uint16[this._pos2+9]}get vertexStartIndex(){return this._structArray.uint32[this._pos4+5]}get lineStartIndex(){return this._structArray.uint32[this._pos4+6]}get lineLength(){return this._structArray.uint32[this._pos4+7]}get segment(){return this._structArray.uint16[this._pos2+16]}get lowerSize(){return this._structArray.uint16[this._pos2+17]}get upperSize(){return this._structArray.uint16[this._pos2+18]}get lineOffsetX(){return this._structArray.float32[this._pos4+10]}get lineOffsetY(){return this._structArray.float32[this._pos4+11]}get writingMode(){return this._structArray.uint8[this._pos1+48]}get placedOrientation(){return this._structArray.uint8[this._pos1+49]}set placedOrientation(t){this._structArray.uint8[this._pos1+49]=t}get hidden(){return this._structArray.uint8[this._pos1+50]}set hidden(t){this._structArray.uint8[this._pos1+50]=t}get crossTileID(){return this._structArray.uint32[this._pos4+13]}set crossTileID(t){this._structArray.uint32[this._pos4+13]=t}get associatedIconIndex(){return this._structArray.int16[this._pos2+28]}get flipState(){return this._structArray.uint8[this._pos1+58]}set flipState(t){this._structArray.uint8[this._pos1+58]=t}}uc.prototype.size=60;class hc extends Jl{get(t){return new uc(this,t)}}ba(hc,"PlacedSymbolArray");class pc extends Al{get tileAnchorX(){return this._structArray.float32[this._pos4+0]}get tileAnchorY(){return this._structArray.float32[this._pos4+1]}get projectedAnchorX(){return this._structArray.int16[this._pos2+4]}get projectedAnchorY(){return this._structArray.int16[this._pos2+5]}get projectedAnchorZ(){return this._structArray.int16[this._pos2+6]}get rightJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+7]}get centerJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+8]}get leftJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+9]}get verticalPlacedTextSymbolIndex(){return this._structArray.int16[this._pos2+10]}get placedIconSymbolIndex(){return this._structArray.int16[this._pos2+11]}get verticalPlacedIconSymbolIndex(){return this._structArray.int16[this._pos2+12]}get key(){return this._structArray.uint16[this._pos2+13]}get textBoxStartIndex(){return this._structArray.uint16[this._pos2+14]}get textBoxEndIndex(){return this._structArray.uint16[this._pos2+15]}get verticalTextBoxStartIndex(){return this._structArray.uint16[this._pos2+16]}get verticalTextBoxEndIndex(){return this._structArray.uint16[this._pos2+17]}get iconBoxStartIndex(){return this._structArray.uint16[this._pos2+18]}get iconBoxEndIndex(){return this._structArray.uint16[this._pos2+19]}get verticalIconBoxStartIndex(){return this._structArray.uint16[this._pos2+20]}get verticalIconBoxEndIndex(){return this._structArray.uint16[this._pos2+21]}get featureIndex(){return this._structArray.uint16[this._pos2+22]}get numHorizontalGlyphVertices(){return this._structArray.uint16[this._pos2+23]}get numVerticalGlyphVertices(){return this._structArray.uint16[this._pos2+24]}get numIconVertices(){return this._structArray.uint16[this._pos2+25]}get numVerticalIconVertices(){return this._structArray.uint16[this._pos2+26]}get useRuntimeCollisionCircles(){return this._structArray.uint16[this._pos2+27]}get crossTileID(){return this._structArray.uint32[this._pos4+14]}set crossTileID(t){this._structArray.uint32[this._pos4+14]=t}get textOffset0(){return this._structArray.float32[this._pos4+15]}get textOffset1(){return this._structArray.float32[this._pos4+16]}get collisionCircleDiameter(){return this._structArray.float32[this._pos4+17]}get zOffset(){return this._structArray.float32[this._pos4+18]}set zOffset(t){this._structArray.float32[this._pos4+18]=t}get occlusionState(){return this._structArray.float32[this._pos4+19]}set occlusionState(t){this._structArray.float32[this._pos4+19]=t}get occlusionOpacity(){return this._structArray.float32[this._pos4+20]}set occlusionOpacity(t){this._structArray.float32[this._pos4+20]=t}get hasIconTextFit(){return this._structArray.uint8[this._pos1+84]}}pc.prototype.size=88;class fc extends Ql{get(t){return new pc(this,t)}}ba(fc,"SymbolInstanceArray");class mc extends Zl{getoffsetX(t){return this.float32[1*t+0]}}ba(mc,"GlyphOffsetArray");class _c extends $l{getx(t){return this.int16[2*t+0]}gety(t){return this.int16[2*t+1]}}ba(_c,"SymbolLineVertexArray");class gc extends Al{get featureIndex(){return this._structArray.uint32[this._pos4+0]}get sourceLayerIndex(){return this._structArray.uint16[this._pos2+2]}get bucketIndex(){return this._structArray.uint16[this._pos2+3]}get layoutVertexArrayOffset(){return this._structArray.uint16[this._pos2+4]}}gc.prototype.size=12;class yc extends nc{get(t){return new gc(this,t)}}ba(yc,"FeatureIndexArray");class vc extends ql{geta_centroid_pos0(t){return this.uint16[2*t+0]}geta_centroid_pos1(t){return this.uint16[2*t+1]}}ba(vc,"FillExtrusionCentroidArray");const xc=Ll([{name:"a_pos",components:2,type:"Int16"}],4),bc=Ll([{name:"a_pos_3",components:3,type:"Int16"},{name:"a_pos_normal_3",components:3,type:"Int16"}]);class wc{constructor(t=[]){this.segments=t}_prepareSegment(t,e,i,n){let r=this.segments[this.segments.length-1];return t>wc.MAX_VERTEX_ARRAY_LENGTH&&pi(`Max vertices per segment is ${wc.MAX_VERTEX_ARRAY_LENGTH}: bucket requested ${t}`),(!r||r.vertexLength+t>wc.MAX_VERTEX_ARRAY_LENGTH||r.sortKey!==n)&&(r={vertexOffset:e,primitiveOffset:i,vertexLength:0,primitiveLength:0},void 0!==n&&(r.sortKey=n),this.segments.push(r)),r}prepareSegment(t,e,i,n){return this._prepareSegment(t,e.length,i.length,n)}get(){return this.segments}destroy(){for(const t of this.segments)for(const e in t.vaos)t.vaos[e].destroy()}static simpleSegment(t,e,i,n){return new wc([{vertexOffset:t,primitiveOffset:e,vertexLength:i,primitiveLength:n,vaos:{},sortKey:0}])}}function Tc(t,e){return 256*(t=Xe(Math.floor(t),0,255))+Xe(Math.floor(e),0,255)}wc.MAX_VERTEX_ARRAY_LENGTH=Math.pow(2,16)-1,ba(wc,"SegmentVector");const Sc=Ll([{name:"a_pattern",components:4,type:"Uint16"},{name:"a_pixel_ratio",components:1,type:"Float32"}]),Ec=Ll([{name:"a_dash",components:4,type:"Uint16"}]);class Mc{constructor(){this.ids=[],this.uniqueIds=[],this.positions=[],this.indexed=!1}add(t,e,i,n){this.ids.push(Cc(t)),this.positions.push(e,i,n)}eachPosition(t,e){const i=Cc(t);let n=0,r=this.ids.length-1;for(;n>1;this.ids[t]>=i?r=t:n=t+1}for(;this.ids[n]===i;)e(this.positions[3*n],this.positions[3*n+1],this.positions[3*n+2]),n++}static serialize(t,e){const i=new Float64Array(t.ids),n=new Uint32Array(t.positions);return Ac(i,n,0,i.length-1),e&&(e.add(i.buffer),e.add(n.buffer)),{ids:i,positions:n}}static deserialize(t){const e=new Mc;let i;e.ids=t.ids,e.positions=t.positions;for(const t of e.ids)t!==i&&e.uniqueIds.push(t),i=t;return e.indexed=!0,e}}function Cc(t){const e=+t;return!isNaN(e)&&Number.MIN_SAFE_INTEGER>1];let o=i-1,s=n+1;for(;;){do{o++}while(t[o]r);if(o>=s)break;Ic(t,o,s),Ic(e,3*o,3*s),Ic(e,3*o+1,3*s+1),Ic(e,3*o+2,3*s+2)}s-i`u_${t}`)),this.type=i,this.context=n}setUniform(t,e,i,n,r){const o=n.constantOr(this.value);e.set(t,r,o instanceof Un?o.toRenderColor(this.context.lut):o)}getBinding(t,e){return"color"===this.type?new Rc(t):new $c(t)}}class Gc{constructor(t,e){this.uniformNames=e.map((t=>`u_${t}`)),this.pattern=null,this.pixelRatio=1}setConstantPatternPositions(t){this.pixelRatio=t.pixelRatio||1,this.pattern=t.tl.concat(t.br)}setUniform(t,e,i,n,r){const o="u_pattern"===r||"u_dash"===r?this.pattern:"u_pixel_ratio"===r?this.pixelRatio:null;o&&e.set(t,r,o)}getBinding(t,e){return"u_pattern"===e||"u_dash"===e?new zc(t):new $c(t)}}class Zc{constructor(t,e,i,n){this.expression=t,this.type=i,this.maxValue=0,this.paintVertexAttributes=e.map((t=>({name:`a_${t}`,type:"Float32",components:"color"===i?2:1,offset:0}))),this.paintVertexArray=new n}populatePaintArray(t,e,i,n,r,o,s){const a=this.paintVertexArray.length,l=this.expression.evaluate(new Ha(0,{brightness:o}),e,{},r,n,s);this.paintVertexArray.resize(t),this._setPaintValue(a,t,l,this.context)}updatePaintArray(t,e,i,n,r,o,s){const a=this.expression.evaluate({zoom:0,brightness:s},i,n,void 0,r);this._setPaintValue(t,e,a,this.context)}_setPaintValue(t,e,i,n){if("color"===this.type){const r=jc(i.toRenderColor(n.lut));for(let i=t;i`u_${t}_t`)),this.type=i,this.useIntegerZoom=n,this.context=r,this.maxValue=0,this.paintVertexAttributes=e.map((t=>({name:`a_${t}`,type:"Float32",components:"color"===i?4:2,offset:0}))),this.paintVertexArray=new o}populatePaintArray(t,e,i,n,r,o,s){const a=this.expression.evaluate(new Ha(this.context.zoom,{brightness:o}),e,{},r,n,s),l=this.expression.evaluate(new Ha(this.context.zoom+1,{brightness:o}),e,{},r,n,s),c=this.paintVertexArray.length;this.paintVertexArray.resize(t),this._setPaintValue(c,t,a,l,this.context)}updatePaintArray(t,e,i,n,r,o,s){const a=this.expression.evaluate({zoom:this.context.zoom,brightness:s},i,n,void 0,r),l=this.expression.evaluate({zoom:this.context.zoom+1,brightness:s},i,n,void 0,r);this._setPaintValue(t,e,a,l,this.context)}_setPaintValue(t,e,i,n,r){if("color"===this.type){const n=jc(i.toRenderColor(r.lut)),o=jc(i.toRenderColor(r.lut));for(let i=t;i!0){this.binders={},this._buffers=[],this.context=e;const n=[];for(const r in t.paint._values){const o=t.paint.get(r);if(!i(r))continue;if(!(o instanceof tl&&Xs(o.property.specification)))continue;const s=Kc(r,t.type),a=o.value,l=o.property.specification.type,c=!!o.property.useIntegerZoom,d="line-dasharray"===r||r.endsWith("pattern"),u="line-dasharray"===r&&"constant"!==t.layout.get("line-cap").value.kind;if("constant"!==a.kind||u)if("source"===a.kind||u||d){const e=td(r,l,"source");this.binders[r]=d?new Hc(a,s,l,e,t.id):new Zc(a,s,l,e),n.push(`/a_${r}`)}else{const t=td(r,l,"composite");this.binders[r]=new qc(a,s,l,c,e,t),n.push(`/z_${r}`)}else this.binders[r]=d?new Gc(a.value,s):new Vc(a.value,s,l,e),n.push(`/u_${r}`)}this.cacheKey=n.sort().join("")}getMaxValue(t){const e=this.binders[t];return e instanceof Zc||e instanceof qc?e.maxValue:0}populatePaintArrays(t,e,i,n,r,o,s){for(const a in this.binders){const l=this.binders[a];l.context=this.context,(l instanceof Zc||l instanceof qc||l instanceof Hc)&&l.populatePaintArray(t,e,i,n,r,o,s)}}setConstantPatternPositions(t){for(const e in this.binders){const i=this.binders[e];i instanceof Gc&&i.setConstantPatternPositions(t)}}updatePaintArrays(t,e,i,n,r,o,s,a){let l=!1;const c=Object.keys(t),d=0!==c.length,u=d?c:e.uniqueIds;this.context.lut=r.lut;for(const c in this.binders){const h=this.binders[c];if(h.context=this.context,(h instanceof Zc||h instanceof qc||h instanceof Hc)&&(!0===h.expression.isStateDependent||!1===h.expression.isLightConstant)){const p=r.paint.get(c);h.expression=p.value;for(const i of u){const r=t[i.toString()];e.eachPosition(i,((t,e,i)=>{const l=n.feature(t);h.updatePaintArray(e,i,l,r,o,s,a)}))}if(!d)for(const e of i.uniqueIds){const r=t[e.toString()];i.eachPosition(e,((t,e,i)=>{const l=n.feature(t);h.updatePaintArray(e,i,l,r,o,s,a)}))}l=!0}}return l}defines(){const t=[];for(const e in this.binders){const i=this.binders[e];(i instanceof Vc||i instanceof Gc)&&t.push(...i.uniformNames.map((t=>`#define HAS_UNIFORM_${t}`)))}return t}getBinderAttributes(){const t=[];for(const e in this.binders){const i=this.binders[e];if(i instanceof Zc||i instanceof qc||i instanceof Hc)for(let e=0;e!0){this.programConfigurations={};for(const n of t)this.programConfigurations[n.id]=new Wc(n,e,i);this.needsUpload=!1,this._featureMap=new Mc,this._featureMapWithoutIds=new Mc,this._bufferOffset=0,this._idlessCounter=0}populatePaintArrays(t,e,i,n,r,o,s,a){for(const i in this.programConfigurations)this.programConfigurations[i].populatePaintArrays(t,e,n,r,o,s,a);void 0!==e.id?this._featureMap.add(e.id,i,this._bufferOffset,t):(this._featureMapWithoutIds.add(this._idlessCounter,i,this._bufferOffset,t),this._idlessCounter+=1),this._bufferOffset=t,this.needsUpload=!0}updatePaintArrays(t,e,i,n,r,o){for(const s of i)this.needsUpload=this.programConfigurations[s.id].updatePaintArrays(t,this._featureMap,this._featureMapWithoutIds,e,s,n,r,o||0)||this.needsUpload}get(t){return this.programConfigurations[t]}upload(t){if(this.needsUpload){for(const e in this.programConfigurations)this.programConfigurations[e].upload(t);this.needsUpload=!1}}destroy(){for(const t in this.programConfigurations)this.programConfigurations[t].destroy()}}const Xc={"text-opacity":["opacity"],"icon-opacity":["opacity"],"text-occlusion-opacity":["occlusion_opacity"],"icon-occlusion-opacity":["occlusion_opacity"],"text-color":["fill_color"],"icon-color":["fill_color"],"text-emissive-strength":["emissive_strength"],"icon-emissive-strength":["emissive_strength"],"text-halo-color":["halo_color"],"icon-halo-color":["halo_color"],"text-halo-blur":["halo_blur"],"icon-halo-blur":["halo_blur"],"text-halo-width":["halo_width"],"icon-halo-width":["halo_width"],"line-gap-width":["gapwidth"],"line-pattern":["pattern","pixel_ratio"],"fill-pattern":["pattern","pixel_ratio"],"fill-extrusion-pattern":["pattern","pixel_ratio"],"line-dasharray":["dash"]};function Kc(t,e){return Xc[t]||[t.replace(`${e}-`,"").replace(/-/g,"_")]}const Jc={"line-pattern":{source:Fl,composite:Fl},"fill-pattern":{source:Fl,composite:Fl},"fill-extrusion-pattern":{source:Fl,composite:Fl},"line-dasharray":{source:Nl,composite:Nl}},Qc={color:{source:ic,composite:Ol},number:{source:Zl,composite:ic}};function td(t,e,i){const n=Jc[t];return n&&n[i]||Qc[e][i]}ba(Vc,"ConstantBinder"),ba(Gc,"PatternConstantBinder"),ba(Zc,"SourceExpressionBinder"),ba(Hc,"PatternCompositeBinder"),ba(qc,"CompositeExpressionBinder"),ba(Wc,"ProgramConfiguration",{omit:["_buffers"]}),ba(Yc,"ProgramConfigurationSet");const ed=uo/Math.PI/2,id=5,nd=6,rd=16383,od=64,sd=[od,32,16],ad=-ed,ld=ed;function cd(t,e,i,n=ed){return i=Ge(i),[t*Math.sin(i)*n,-e*n,t*Math.cos(i)*n]}function dd(t,e,i){return cd(Math.cos(Ge(t)),Math.sin(Ge(t)),e,i)}const ud=6371008.8,hd=2*Math.PI*ud;class pd{constructor(t,e){if(isNaN(t)||isNaN(e))throw new Error(`Invalid LngLat object: (${t}, ${e})`);if(this.lng=+t,this.lat=+e,this.lat>90||this.lat, lat: }, an object {lon: , lat: }, or an array of [, ]")}}class fd{constructor(t,e){if(t)if(e)this.setSouthWest(t).setNorthEast(e);else if(4===t.length){const e=t;this.setSouthWest([e[0],e[1]]).setNorthEast([e[2],e[3]])}else{const e=t;this.setSouthWest(e[0]).setNorthEast(e[1])}}setNorthEast(t){return this._ne=t instanceof pd?new pd(t.lng,t.lat):pd.convert(t),this}setSouthWest(t){return this._sw=t instanceof pd?new pd(t.lng,t.lat):pd.convert(t),this}extend(t){const e=this._sw,i=this._ne;let n,r;if(t instanceof pd)n=t,r=t;else{if(!(t instanceof fd))return Array.isArray(t)?4===t.length||t.every(Array.isArray)?this.extend(fd.convert(t)):this.extend(pd.convert(t)):"object"==typeof t&&null!==t&&t.hasOwnProperty("lat")&&(t.hasOwnProperty("lon")||t.hasOwnProperty("lng"))?this.extend(pd.convert(t)):this;if(n=t._sw,r=t._ne,!n||!r)return this}return e||i?(e.lng=Math.min(n.lng,e.lng),e.lat=Math.min(n.lat,e.lat),i.lng=Math.max(r.lng,i.lng),i.lat=Math.max(r.lat,i.lat)):(this._sw=new pd(n.lng,n.lat),this._ne=new pd(r.lng,r.lat)),this}getCenter(){return new pd((this._sw.lng+this._ne.lng)/2,(this._sw.lat+this._ne.lat)/2)}getSouthWest(){return this._sw}getNorthEast(){return this._ne}getNorthWest(){return new pd(this.getWest(),this.getNorth())}getSouthEast(){return new pd(this.getEast(),this.getSouth())}getWest(){return this._sw.lng}getSouth(){return this._sw.lat}getEast(){return this._ne.lng}getNorth(){return this._ne.lat}toArray(){return[this._sw.toArray(),this._ne.toArray()]}toString(){return`LngLatBounds(${this._sw.toString()}, ${this._ne.toString()})`}isEmpty(){return!(this._sw&&this._ne)}contains(t){const{lng:e,lat:i}=pd.convert(t);let n=this._sw.lngthis._ne.lng&&(n=this._sw.lng>=e&&e>=this._ne.lng),this._sw.lat0;o--)n=1this.canonical.z?new vd(t,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y):new vd(t,this.wrap,t,this.canonical.x>>e,this.canonical.y>>e)}calculateScaledKey(t,e=!0){if(this.overscaledZ===t&&e)return this.key;if(t>this.canonical.z)return xd(this.wrap*+e,t,this.canonical.z,this.canonical.x,this.canonical.y);{const i=this.canonical.z-t;return xd(this.wrap*+e,t,t,this.canonical.x>>i,this.canonical.y>>i)}}isChildOf(t){if(t.wrap!==this.wrap)return!1;const e=this.canonical.z-t.canonical.z;return 0===t.overscaledZ||t.overscaledZ>e&&t.canonical.y===this.canonical.y>>e}children(t){if(this.overscaledZ>=t)return[new vd(this.overscaledZ+1,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y)];const e=this.canonical.z+1,i=2*this.canonical.x,n=2*this.canonical.y;return[new vd(e,this.wrap,e,i,n),new vd(e,this.wrap,e,i+1,n),new vd(e,this.wrap,e,i,n+1),new vd(e,this.wrap,e,i+1,n+1)]}isLessThan(t){return this.wrapt.wrap)&&(this.overscaledZt.overscaledZ)&&(this.canonical.xt.canonical.x)&&this.canonical.y{let e=t.canonical.x-1,i=t.wrap;return e{let e=t.canonical.x+1,i=t.wrap;return e===1new vd(t.overscaledZ,t.wrap,t.canonical.z,t.canonical.x,(0===t.canonical.y?1new vd(t.overscaledZ,t.wrap,t.canonical.z,t.canonical.x,t.canonical.y===(1=l?(Od(t,e,i,c,d,o,u,a,l),Od(t,c,d,n,r,u,s,a,l)):t.push(s)}function Bd(t,e,i){let n=t[0],r=n.x,o=n.y;e(n);const s=[n];for(let a=1;at.x+1||nt.y+1)&&pi("Geometry exceeds allowed extent, reduce your vector tile buffer size"),t}function Gd(t,e,i){const n=t.loadGeometry(),r=t.extent,o=uo/r;if(e&&i&&i.projection.isReprojectedInTileSpace){const o=1{const i=Ad((e.x+t.x/r)/o),n=Id((e.y+t.y/r)/o),d=c.project(i,n);t.x=(d.x*s-a)*r,t.y=(d.y*s-l)*r};for(let e=0;e=r||i.y=r||(d(i),t.push(i));n[e]=t}}for(const t of n)for(const e of t)Vd(e,o);return n}function Zd(t,e){return{type:t.type,id:t.id,properties:t.properties,geometry:e?Gd(t):[]}}function qd(t,e,i,n,r){t.emplaceBack(2*e+(n+1)/2,2*i+(r+1)/2)}function Hd(t,e,i){const n=16384;t.emplaceBack(e.x,e.y,e.z,i[0]*n,i[1]*n,i[2]*n)}class Wd{constructor(t){this.zoom=t.zoom,this.overscaling=t.overscaling,this.layers=t.layers,this.layerIds=this.layers.map((t=>t.fqid)),this.index=t.index,this.hasPattern=!1,this.projection=t.projection,this.layoutVertexArray=new $l,this.indexArray=new Kl,this.segments=new wc,this.programConfigurations=new Yc(t.layers,{zoom:t.zoom,lut:t.lut}),this.stateDependentLayerIds=this.layers.filter((t=>t.isStateDependent())).map((t=>t.id))}updateFootprints(t,e){}populate(t,e,i,n){const r=this.layers[0],o=[];let s=null;"circle"===r.type&&(s=r.layout.get("circle-sort-key"));for(const{feature:e,id:r,index:a,sourceLayerIndex:l}of t){const t=this.layers[0]._featureFilter.needGeometry,c=Zd(e,t);if(!this.layers[0]._featureFilter.filter(new Ha(this.zoom),c,i))continue;const d=s?s.evaluate(c,{},i):void 0,u={id:r,properties:e.properties,type:e.type,sourceLayerIndex:l,index:a,geometry:t?c.geometry:Gd(e,i,n),patterns:{},sortKey:d};o.push(u)}s&&o.sort(((t,e)=>t.sortKey-e.sortKey));let a=null;"globe"===n.projection.name&&(this.globeExtVertexArray=new Ul,a=n.projection);for(const n of o){const{geometry:r,index:o,sourceLayerIndex:s}=n,l=t[o].feature;this.addFeature(n,r,o,e.availableImages,i,a,e.brightness),e.featureIndex.insert(l,r,o,s,this.index)}}update(t,e,i,n,r){const o=0!==Object.keys(t).length;o&&!this.stateDependentLayers.length||this.programConfigurations.updatePaintArrays(t,e,o?this.stateDependentLayers:this.layers,i,n,r)}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(t){this.uploaded||(this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,xc.members),this.indexBuffer=t.createIndexBuffer(this.indexArray),this.globeExtVertexArray&&(this.globeExtVertexBuffer=t.createVertexBuffer(this.globeExtVertexArray,bc.members))),this.programConfigurations.upload(t),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy(),this.globeExtVertexBuffer&&this.globeExtVertexBuffer.destroy())}addFeature(t,e,i,n,r,o,s){for(const i of e)for(const e of i){const i=e.x,n=e.y;if(i=uo||n=uo)continue;if(o){const t=o.projectTilePoint(i,n,r),e=o.upVector(r,i,n),s=this.globeExtVertexArray;Hd(s,t,e),Hd(s,t,e),Hd(s,t,e),Hd(s,t,e)}const s=this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray,t.sortKey),a=s.vertexLength;qd(this.layoutVertexArray,i,n,-1,-1),qd(this.layoutVertexArray,i,n,1,-1),qd(this.layoutVertexArray,i,n,1,1),qd(this.layoutVertexArray,i,n,-1,1),this.indexArray.emplaceBack(a,a+1,a+2),this.indexArray.emplaceBack(a,a+2,a+3),s.vertexLength+=4,s.primitiveLength+=2}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,t,i,{},n,r,s)}}function Yd(t,e){for(let i=0;i1){if(Qd(t,e))return!0;for(let n=0;n1?i:i.sub(e)._mult(r)._add(e))}function nu(t,e){let i,n,r,o=!1;for(let s=0;se.y!=r.y>e.y&&e.xe.y!=s.y>e.y&&e.x=o.x&&r>=o.y)return!0;const o=[new Ue(e,i),new Ue(e,r),new Ue(n,r),new Ue(n,i)];if(t.length>2)for(const e of o)if(ru(t,e))return!0;for(let e=0;er.x&&e.x>r.x||t.yr.y&&e.y>r.y)return!1;const o=fi(t,e,i[0]);return o!==fi(t,e,i[1])||o!==fi(t,e,i[2])||o!==fi(t,e,i[3])}function au(t,e,i,n,r,o){let s=e.y-t.y,a=t.x-e.x;if(o=o||0){const t=s*s+a*a;if(0===t)return!0;const e=Math.sqrt(t);s/=e,a/=e}return!((i.x-t.x)*s+(i.y-t.y)*a-o=0;if(0===s)return 0;s!==i.length&&(n=!1)}return n?2:1}function vu(t,e){for(const i of t.projections){const n=gu(e,t.points[0],i.axis);if(i.projection[1]n[1])return 0}return 1}function xu(e,i){let n=0;const r=[0,0,0,0];for(let o=0;o=0&&n++;return n}class bu{constructor(e,i){this.points=e||new Array(8).fill([0,0,0]),this.planes=i||new Array(6).fill([0,0,0,0]),this.bounds=wu.fromPoints(this.points),this.projections=[],this.frustumEdges=[t._.sub([],this.points[2],this.points[3]),t._.sub([],this.points[0],this.points[3]),t._.sub([],this.points[4],this.points[0]),t._.sub([],this.points[5],this.points[1]),t._.sub([],this.points[6],this.points[2]),t._.sub([],this.points[7],this.points[3])];for(const t of this.frustumEdges){const e=[0,-t[2],t[1]],i=[t[2],0,-t[0]];this.projections.push({axis:e,projection:gu(this.points,this.points[0],e)}),this.projections.push({axis:i,projection:gu(this.points,this.points[0],i)})}}static fromInvProjectionMatrix(e,i,n,r){const o=Math.pow(2,n),s=[[-1,1,-1,1],[1,1,-1,1],[1,-1,-1,1],[-1,-1,-1,1],[-1,1,1,1],[1,1,1,1],[1,-1,1,1],[-1,-1,1,1]].map((n=>{const s=t.aA.transformMat4([],n,e),a=1/s[3]/i*o;return t.aA.mul(s,s,[a,a,r?1/s[3]:a,a])})),a=[[0,1,2],[6,5,4],[0,3,7],[2,1,5],[3,2,6],[0,4,5]].map((e=>{const i=t._.sub([],s[e[0]],s[e[1]]),n=t._.sub([],s[e[2]],s[e[1]]),r=t._.normalize([],t._.cross([],i,n)),o=-t._.dot(r,s[e[1]]);return r.concat(o)})),l=[];for(let t=0;ta[1]||a[0]>s[1])return 0}return 1}}class wu{static fromPoints(e){const i=[1/0,1/0,1/0],n=[-1/0,-1/0,-1/0];for(const r of e)t._.min(i,i,r),t._.max(n,n,r);return new wu(i,n)}static fromTileIdAndHeight(t,e,i){const n=1t.max[e]||t.min[e]>this.max[e])return!1;return!0}intersectsAabbXY(t){return!(this.min[0]>t.max[0]||t.min[0]>this.max[0]||this.min[1]>t.max[1]||t.min[1]>this.max[1])}encapsulate(t){for(let e=0;e1?null:function(t,e,i,n){const r=Math.sin(i);return t*(Math.sin((1-n)*i)/r)+e*(Math.sin(n*i)/r)}(t.a[e],t.b[e],t.angle,Xe(i,0,1))+t.center[e]}function $u(t){if(t.z0){for(const e of l)t._.min(u,u,e),t._.max(d,d,e);return new wu(u,d)}const h=[s[12]*o,s[13]*o,s[14]*o],p=a.getCenter(),f=Xe(e.center.lat,-Pd,Pd),m=Xe(p.lat,-Pd,Pd),_=Ed(e.center.lng),g=Md(f);let y=_-Ed(p.lng);const v=g-Md(m);y>.5?y-=1:yMath.abs(v))x=y>=0?1:3;else{x=v>=0?0:2;const e=[s[4]*o,s[5]*o,s[6]*o],i=-Math.sin(Ge(v>=0?a.getSouth():a.getNorth()))*ed;t._.scaleAndAdd(h,h,e,i)}const b=l[x],w=l[(x+1)%4],T=new Lu(b,w,h),S=[Pu(T,0)||b[0],Pu(T,1)||b[1],Pu(T,2)||b[2]],E=Hu(e.zoom);if(E>0){const r=function({x:t,y:e,z:i},n,r,o,s){const a=1/(1.5?h=-1:pMath.PI/2*1.01}const Xu=Ge(85),Ku=Math.cos(Xu),Ju=Math.sin(Xu),Qu=t.ad.create(),th=t=>{const e=[];return"map"===t.paint.get("circle-pitch-alignment")&&e.push("PITCH_WITH_MAP"),"map"===t.paint.get("circle-pitch-scale")&&e.push("SCALE_WITH_MAP"),e};function eh(e,i,n,r,o,s,a,l,c){if(s&&e.queryGeometry.isAboveHorizon)return!1;s&&(c*=e.pixelToTileUnitsFactor);const d=e.tileID.canonical,u=n.projection.upVectorScale(d,n.center.lat,n.worldSize).metersToTile;for(const h of i)for(const i of h){const h=i.add(l),p=o&&n.elevation?n.elevation.exaggeration()*o.getElevationAt(h.x,h.y,!0):0,f=n.projection.projectTilePoint(h.x,h.y,d);if(p>0){const t=n.projection.upVector(d,h.x,h.y);f.x+=t[0]*u*p,f.y+=t[1]*u*p,f.z+=t[2]*u*p}const m=s?h:ih(f.x,f.y,f.z,r),_=s?e.tilespaceRays.map((t=>oh(t,p))):e.queryGeometry.screenGeometry,g=t.aA.transformMat4([],[f.x,f.y,f.z,1],r);if(!a&&s?c*=g[3]/n.cameraToCenterDistance:a&&!s&&(c*=n.cameraToCenterDistance/g[3]),s){const t=Id((i.y/uo+d.y)/(1t.width||r.height>t.height||i.x>t.width-r.width||i.y>t.height-r.height)throw new RangeError("out of range source coordinates for image copy");if(r.width>e.width||r.height>e.height||n.x>e.width-r.width||n.y>e.height-r.height)throw new RangeError("out of range destination coordinates for image copy");const l=t.data,c=e.data,d=4===o&&a;for(let a=0;a{e[t.evaluationKey]=o;const s=t.expression.evaluate(e);s&&(r.data[i+n+0]=Math.floor(255*s.r/s.a),r.data[i+n+1]=Math.floor(255*s.g/s.a),r.data[i+n+2]=Math.floor(255*s.b/s.a),r.data[i+n+3]=Math.floor(255*s.a))};if(t.clips)for(let e=0,r=0;e80*i){a=1/0,l=1/0;let e=-1/0,n=-1/0;for(let o=i;oe&&(e=i),r>n&&(n=r)}c=Math.max(e-a,n-l),c=0!==c?32767/c:0}return Th(o,s,i,a,l,c,0),s}function bh(t,e,i,n,r){let o;if(r===function(t,e,i,n){let r=0;for(let o=e,s=i-n;o0)for(let r=e;r=e;r-=n)o=jh(r/n|0,t[r],t[r+1],o);return o&&Rh(o,o.next)&&(Vh(o),o=o.next),o}function wh(t,e){if(!t)return t;e||(e=t);let i,n=t;do{if(i=!1,n.steiner||!Rh(n,n.next)&&0!==zh(n.prev,n,n.next))n=n.next;else{if(Vh(n),n=e=n.prev,n===n.next)break;i=!0}}while(i||n!==e);return e}function Th(t,e,i,n,r,o,s){if(!t)return;!s&&o&&function(t,e,i,n){let r=t;do{0===r.z&&(r.z=Ph(r.x,r.y,e,i,n)),r.prevZ=r.prev,r.nextZ=r.next,r=r.next}while(r!==t);r.prevZ.nextZ=null,r.prevZ=null,function(t){let e,i=1;do{let n,r=t;t=null;let o=null;for(e=0;r;){e++;let s=r,a=0;for(let t=0;t0||l>0&&s;)0!==a&&(0===l||!s||r.z1)}(r)}(t,n,r,o);let a=t;for(;t.prev!==t.next;){const l=t.prev,c=t.next;if(o?Eh(t,n,r,o):Sh(t))e.push(l.i,t.i,c.i),Vh(t),t=c.next,a=c.next;else if((t=c)===a){s?1===s?Th(t=Mh(wh(t),e),e,i,n,r,o,2):2===s&&Ch(t,e,i,n,r,o):Th(wh(t),e,i,n,r,o,1);break}}}function Sh(t){const e=t.prev,i=t,n=t.next;if(zh(e,i,n)>=0)return!1;const r=e.x,o=i.x,s=n.x,a=e.y,l=i.y,c=n.y,d=ro?r>s?r:s:o>s?o:s,p=a>l?a>c?a:c:l>c?l:c;let f=n.next;for(;f!==e;){if(f.x>=d&&f.x=u&&f.y=0)return!1;f=f.next}return!0}function Eh(t,e,i,n){const r=t.prev,o=t,s=t.next;if(zh(r,o,s)>=0)return!1;const a=r.x,l=o.x,c=s.x,d=r.y,u=o.y,h=s.y,p=al?a>c?a:c:l>c?l:c,_=d>u?d>h?d:h:u>h?u:h,g=Ph(p,f,e,i,n),y=Ph(m,_,e,i,n);let v=t.prevZ,x=t.nextZ;for(;v&&v.z>=g&&x&&x.z=p&&v.x=f&&v.y=0)return!1;if(v=v.prevZ,x.x>=p&&x.x=f&&x.y=0)return!1;x=x.nextZ}for(;v&&v.z>=g;){if(v.x>=p&&v.x=f&&v.y=0)return!1;v=v.prevZ}for(;x&&x.z=p&&x.x=f&&x.y=0)return!1;x=x.nextZ}return!0}function Mh(t,e){let i=t;do{const n=i.prev,r=i.next.next;!Rh(n,r)&&Oh(n,i,i.next,r)&&Nh(n,r)&&Nh(r,n)&&(e.push(n.i,i.i,r.i),Vh(i),Vh(i.next),i=t=r),i=i.next}while(i!==t);return wh(i)}function Ch(t,e,i,n,r,o){let s=t;do{let t=s.next.next;for(;t!==s.prev;){if(s.i!==t.i&&Dh(s,t)){let a=Uh(s,t);return s=wh(s,s.next),a=wh(a,a.next),Th(s,e,i,n,r,o,0),void Th(a,e,i,n,r,o,0)}t=t.next}s=s.next}while(s!==t)}function Ah(t,e){return t.x-e.x}function Ih(t,e){const i=function(t,e){let i=e;const n=t.x,r=t.y;let o,s=-1/0;do{if(r=i.next.y&&i.next.y!==i.y){const t=i.x+(r-i.y)*(i.next.x-i.x)/(i.next.y-i.y);if(ts&&(s=t,o=i.x=i.x&&i.x>=l&&n!==i.x&&kh(ro.x||i.x===o.x&&Lh(o,i)))&&(o=i,d=e)}i=i.next}while(i!==a);return o}(t,e);if(!i)return e;const n=Uh(i,t);return wh(n,n.next),wh(i,i.next)}function Lh(t,e){return zh(t.prev,t,e.prev)=(t-s)*(o-a)&&(t-s)*(n-a)>=(i-s)*(e-a)&&(i-s)*(o-a)>=(r-s)*(n-a)}function Dh(t,e){return t.next.i!==e.i&&t.prev.i!==e.i&&!function(t,e){let i=t;do{if(i.i!==t.i&&i.next.i!==t.i&&i.i!==e.i&&i.next.i!==e.i&&Oh(i,i.next,t,e))return!0;i=i.next}while(i!==t);return!1}(t,e)&&(Nh(t,e)&&Nh(e,t)&&function(t,e){let i=t,n=!1;const r=(t.x+e.x)/2,o=(t.y+e.y)/2;do{i.y>o!=i.next.y>o&&i.next.y!==i.y&&r0&&zh(e.prev,e,e.next)>0)}function zh(t,e,i){return(e.y-t.y)*(i.x-e.x)-(e.x-t.x)*(i.y-e.y)}function Rh(t,e){return t.x===e.x&&t.y===e.y}function Oh(t,e,i,n){const r=Fh(zh(t,e,i)),o=Fh(zh(t,e,n)),s=Fh(zh(i,n,t)),a=Fh(zh(i,n,e));return r!==o&&s!==a||!(0!==r||!Bh(t,i,e))||!(0!==o||!Bh(t,n,e))||!(0!==s||!Bh(i,t,n))||!(0!==a||!Bh(i,e,n))}function Bh(t,e,i){return e.x=Math.min(t.x,i.x)&&e.y=Math.min(t.y,i.y)}function Fh(t){return t>0?1:t=0&&zh(t,t.prev,e)>=0:zh(t,e,t.prev)1)for(let t=0;tt.fqid)),this.index=t.index,this.hasPattern=!1,this.patternFeatures=[],this.layoutVertexArray=new $l,this.indexArray=new Kl,this.indexArray2=new ql,this.programConfigurations=new Yc(t.layers,{zoom:t.zoom,lut:t.lut}),this.segments=new wc,this.segments2=new wc,this.stateDependentLayerIds=this.layers.filter((t=>t.isStateDependent())).map((t=>t.id)),this.projection=t.projection}updateFootprints(t,e){}populate(t,e,i,n){this.hasPattern=Hh("fill",this.layers,e);const r=this.layers[0].layout.get("fill-sort-key"),o=[];for(const{feature:s,id:a,index:l,sourceLayerIndex:c}of t){const t=this.layers[0]._featureFilter.needGeometry,d=Zd(s,t);if(!this.layers[0]._featureFilter.filter(new Ha(this.zoom),d,i))continue;const u=r?r.evaluate(d,{},i,e.availableImages):void 0,h={id:a,properties:s.properties,type:s.type,sourceLayerIndex:c,index:l,geometry:t?d.geometry:Gd(s,i,n),patterns:{},sortKey:u};o.push(h)}r&&o.sort(((t,e)=>t.sortKey-e.sortKey));for(const n of o){const{geometry:r,index:o,sourceLayerIndex:s}=n;if(this.hasPattern){const t=Wh("fill",this.layers,n,this.zoom,e);this.patternFeatures.push(t)}else this.addFeature(n,r,o,i,{},e.availableImages,e.brightness);e.featureIndex.insert(t[o].feature,r,o,s,this.index)}}update(t,e,i,n,r){const o=0!==Object.keys(t).length;o&&!this.stateDependentLayers.length||this.programConfigurations.updatePaintArrays(t,e,o?this.stateDependentLayers:this.layers,i,n,r)}addFeatures(t,e,i,n,r,o){for(const t of this.patternFeatures)this.addFeature(t,t.geometry,t.index,e,i,n,o)}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(t){this.uploaded||(this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,vh),this.indexBuffer=t.createIndexBuffer(this.indexArray),this.indexBuffer2=t.createIndexBuffer(this.indexArray2)),this.programConfigurations.upload(t),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.indexBuffer2.destroy(),this.programConfigurations.destroy(),this.segments.destroy(),this.segments2.destroy())}addFeature(t,e,i,n,r,o=[],s){for(const t of Zh(e,500)){let e=0;for(const i of t)e+=i.length;const i=this.segments.prepareSegment(e,this.layoutVertexArray,this.indexArray),n=i.vertexLength,r=[],o=[];for(const e of t){if(0===e.length)continue;e!==t[0]&&o.push(r.length/2);const i=this.segments2.prepareSegment(e.length,this.layoutVertexArray,this.indexArray2),n=i.vertexLength;this.layoutVertexArray.emplaceBack(e[0].x,e[0].y),this.indexArray2.emplaceBack(n+e.length-1,n),r.push(e[0].x),r.push(e[0].y);for(let t=1;tt.cellIdx-e.cellIdx||t.triIdx-e.triIdx));let c=0;for(;cthis.max.x||this.min.x>t.x||t.y>this.max.y||this.min.y>t.y)return;const i=Qh(t.x-this.min.x,this.xScale,this.cellsX),n=Qh(t.y-this.min.y,this.yScale,this.cellsY),r=this.cells[n*this.cellsX+i];if(r){this._lazyInitLookup();for(let t=0;tthis.max.x||this.min.x>e.x)return;if(t.y>this.max.y||this.min.y>e.y)return;this._lazyInitLookup();const n=Qh(t.x-this.min.x,this.xScale,this.cellsX),r=Qh(e.x-this.min.x,this.xScale,this.cellsX),o=Qh(t.y-this.min.y,this.yScale,this.cellsY),s=Qh(e.y-this.min.y,this.yScale,this.cellsY);for(let t=o;tt.fqid)),this.index=t.index,this.hasPattern=!1,this.stateDependentLayerIds=this.layers.filter((t=>t.isStateDependent())).map((t=>t.id)),this.footprints=[]}updateFootprints(t,e){for(const i of this.footprints)e.push({footprint:i,id:t})}populate(t,e,i,n){const r=[];for(const{feature:e,id:o,index:s,sourceLayerIndex:a}of t){const t=this.layers[0]._featureFilter.needGeometry,l=Zd(e,t);if(!this.layers[0]._featureFilter.filter(new Ha(this.zoom),l,i))continue;const c={id:o,properties:e.properties,type:e.type,sourceLayerIndex:a,index:s,geometry:t?l.geometry:Gd(e,i,n),patterns:{}};r.push(c)}for(const n of r){const{geometry:r,index:o,sourceLayerIndex:s}=n;this.addFeature(n,r,o,i,{},e.availableImages,e.brightness),e.featureIndex.insert(t[o].feature,r,o,s,this.index)}}isEmpty(){return 0===this.footprints.length}uploadPending(){return!1}upload(t){}update(t,e,i,n,r){}destroy(){}addFeature(t,e,i,n,r,o=[],s){for(const t of Zh(e,2)){const e=[],i=[],n=[],r=new Ue(1/0,1/0),o=new Ue(-1/0,-1/0);for(const s of t)if(0!==s.length){s!==t[0]&&n.push(i.length/2);for(let t=0;t>3}if(r--,1===n||2===n)o+=t.readSVarint(),s+=t.readSVarint(),1===n&&(e&&a.push(e),e=[]),e.push(new dp(o,s));else{if(7!==n)throw new Error("unknown command "+n);e&&e.push(e[0].clone())}}return e&&a.push(e),a},hp.prototype.bbox=function(){var t=this._pbf;t.pos=this._geometry;for(var e=t.readVarint()+t.pos,i=1,n=0,r=0,o=0,s=1/0,a=-1/0,l=1/0,c=-1/0;t.pos>3}if(n--,1===i||2===i)(r+=t.readSVarint())a&&(a=r),(o+=t.readSVarint())c&&(c=o);else if(7!==i)throw new Error("unknown command "+i)}return[s,l,a,c]},hp.prototype.toGeoJSON=function(t,e,i){var n,r,o=this.extent*Math.pow(2,i),s=this.extent*t,a=this.extent*e,l=this.loadGeometry(),c=hp.types[this.type];function d(t){for(var e=0;e>3;e=1===n?t.readString():2===n?t.readFloat():3===n?t.readDouble():4===n?t.readVarint64():5===n?t.readVarint():6===n?t.readSVarint():7===n?t.readBoolean():null}return e}(i))}gp.prototype.feature=function(t){if(t=this._features.length)throw new Error("feature index out of bounds");this._pbf.pos=this._features[t];var e=this._pbf.readVarint()+this._pbf.pos;return new mp(this._pbf,e,this.extent,this._keys,this._values)};var vp=_p;function xp(t,e,i){if(3===t){var n=new vp(i,i.readVarint()+i.pos);n.length&&(e[n.name]=n)}}var bp=cp.VectorTile=function(t,e){this.layers=t.readFields(xp,{},e)},wp=cp.VectorTileFeature=up;cp.VectorTileLayer=_p;class Tp extends Ue{constructor(t,e,i){super(t,e),this.z=i}}class Sp extends Tp{constructor(t,e,i,n){super(t,e,i),this.w=n}}function Ep(t,e,i,n){const r=[],o=0===n?(t,e,i,n,r,o)=>{t.push(new Ue(o,i+(o-e)/(n-e)*(r-i)))}:(t,e,i,n,r,o)=>{t.push(new Ue(e+(o-i)/(r-i)*(n-e),o))};for(const s of t){const t=[];for(const r of s){if(r.lengthe&&o(s,a,l,c,d,e):u>i?h=e&&o(s,a,l,c,d,e),h>i&&u=e&&l=s[i]&&(n=e,s=t),n[i]r&&Mp(n,s,i,r),n[i]o&&Mp(s,n,i,o)}}function Ap(t,e){return t.x-e.x||t.y-e.y}function Ip(t,e){return 0===Ap(t.min,e.min)&&0===Ap(t.max,e.max)}function Lp(t,e){return!(t.min.x>e.max.x||t.max.xe.max.y||t.max.ynew Ue((t.x+o.x*uo)*a-s.x*uo,(t.y+o.y*uo)*a-s.y*uo)))}return Dp(i,r,t.indices,0,t.indices.length,0,0)}function Rp(t,e,i,n){const r=Math.pow(2,n.z-i.z);return new Ue((t+i.x*uo)*r-n.x*uo,(e+i.y*uo)*r-n.y*uo)}function Op(t,e){const i=[];e.footprint.grid.queryPoint(t,i);const n=e.footprint.indices,r=e.footprint.vertices;for(let e=0;ee[s])return null}else{const a=1/n[s];let l=(t[s]-i[s])*a,c=(e[s]-i[s])*a;if(l>c){const t=l;l=c,c=t}if(l>r&&(r=l),co)return null}return r}function Np(t,e,i,n,r,o,s,a,l,c,d){const u=n-t,h=r-e,p=o-i,f=s-t,m=a-e,_=l-i,g=d[1]*_-d[2]*m,y=d[2]*f-d[0]*_,v=d[0]*m-d[1]*f,x=u*g+h*y+p*v;if(Math.abs(x)1)return null;const M=T*p-S*h,C=S*u-w*p,A=w*h-T*u,I=(d[0]*M+d[1]*C+d[2]*A)*b;return I1?null:(f*M+m*C+_*A)*b}function Up(t,e,i){return(t-e)/(i-e)}function jp(t,e,i,n,r,o,s,a,l){const c=1{const o=n?1:0,s=(t+1)*i-o,a=e*i,l=(e+1)*i-o;r[0]=t*i,r[1]=a,r[2]=s,r[3]=l};let s=new Bp(n);const a=[];for(let e=0;e=1;n/=2){const t=i[i.length-1];s=new Bp(n);for(let e=0;e0;){const{idx:l,t:f,nodex:m,nodey:_,depth:g}=p.pop();if(this.leaves[l]){jp(m,_,g,e,i,n,r,u,h);const l=1=e[2])return f}continue}let y=0;for(let t=0;t=c[d[n]]&&(d.splice(n,0,t),i=!0);i||(d[y]=t),y++}}for(let t=0;t=this.dim+1||e=this.dim+1)throw new RangeError("out of range source coordinates for DEM data");return(e+1)*this.stride+(t+1)}static pack(t,e){const i=[0,0,0,0],n=Yp.getUnpackVector(e);let r=Math.floor((t+n[3])/n[2]);return i[2]=r%256,r=Math.floor(r/256),i[1]=r%256,r=Math.floor(r/256),i[0]=r,i}getPixels(){return new hh({width:this.stride,height:this.stride},this.pixels)}backfillBorder(t,e,i){if(this.dim!==t.dim)throw new Error("dem dimension mismatch");let n=e*this.dim,r=e*this.dim+this.dim,o=i*this.dim,s=i*this.dim+this.dim;switch(e){case-1:n=r-1;break;case 1:r=n+1}switch(i){case-1:o=s-1;break;case 1:s=o+1}const a=-e*this.dim,l=-i*this.dim;for(let e=o;et.max.x&&(t.max.x=e.x,n=!0),e.yt.max.y&&(t.max.y=e.y,n=!0),((0===e.x||e.x===uo)&&e.x===i.x)!=((0===e.y||e.y===uo)&&e.y===i.y)&&this.processBorderOverlap(e,i),n&&this.checkBorderIntersection(e,i)}checkBorderIntersection(t,e){e.xuo!=t.x>uo&&this.addBorderIntersection(1,Vn(e.y,t.y,(uo-e.x)/(t.x-e.x))),e.yuo!=t.y>uo&&this.addBorderIntersection(3,Vn(e.x,t.x,(uo-e.y)/(t.y-e.y)))}addBorderIntersection(t,e){this.borders||(this.borders=[[Number.MAX_VALUE,-Number.MAX_VALUE],[Number.MAX_VALUE,-Number.MAX_VALUE],[Number.MAX_VALUE,-Number.MAX_VALUE],[Number.MAX_VALUE,-Number.MAX_VALUE]]);const i=this.borders[t];ei[1]&&(i[1]=e)}processBorderOverlap(t,e){if(t.x===e.x){if(t.y===e.y)return;const i=0===t.x?0:1;this.addBorderIntersection(i,e.y),this.addBorderIntersection(i,t.y)}else{const i=0===t.y?2:3;this.addBorderIntersection(i,e.x),this.addBorderIntersection(i,t.x)}}centroid(){return 0===this.accCount?new Ue(0,0):new Ue(Math.floor(Math.max(0,this.acc.x)/this.accCount),Math.floor(Math.max(0,this.acc.y)/this.accCount))}intersectsCount(){return this.borders?this.borders.reduce(((t,e)=>t+ +(e[0]!==Number.MAX_VALUE)),0):0}}function hf(t,e){const i=t.add(e)._unit(),n=Xe(t.x*i.x+t.y*i.y,-1,1);var r,o,s;return r=Math.acos(n),Math.min(4,Math.max(-4,Math.tan(r)))/4*nf*((o=t).x*(s=e).y-o.y*s.xt.xt.x>uo,t=>t.yt.y>uo];function ff(t,e,i,n){const r=[4];if(0===n)return r;i._mult(n);const o=t.sub(i),s=e.sub(i),a=[t,e,o,s];for(let t=0;ttf.includes(t))),this._segments=new wc,this.hiddenByLandmarkVertexArray=new lc,this._segmentToGroundQuads={},this._segmentToGroundQuads[0]=[],this._segmentToRegionTriCounts={},this._segmentToRegionTriCounts[0]=[0,0,0,0,0],this.regionSegments={},this.regionSegments[4]=new wc}getDefaultSegment(){return this.regionSegments[4]}hasData(){return 0!==this.vertexArray.length}addData(t,e,i,n=!1){const r=t.length;if(r>2){let o=Math.max(0,this._segments.get().length-1);const s=this._segments._prepareSegment(4*r,this.vertexArray.length,2*this._segmentToGroundQuads[o].length);let a;o!==this._segments.get().length-1&&(o++,this._segmentToGroundQuads[o]=[],this._segmentToRegionTriCounts[o]=[0,0,0,0,0]);{const e=t[0],i=t[1];a=hf(e.sub(t[r-1])._perp()._unit(),i.sub(e)._perp()._unit())}for(let l=0;lt.region-e.region));for(let i=0;it+e),0);let o=0;for(let t=0;t0?this.hiddenByLandmarkVertexBuffer=t.createVertexBuffer(this.hiddenByLandmarkVertexArray,sp.members,!0):this.hiddenByLandmarkVertexBuffer&&this.hiddenByLandmarkVertexBuffer.updateData(this.hiddenByLandmarkVertexArray),this._needsHiddenByLandmarkUpdate=!1)}destroy(){if(this.vertexBuffer){this.vertexBuffer.destroy(),this.indexBuffer.destroy(),this.hiddenByLandmarkVertexBuffer&&this.hiddenByLandmarkVertexBuffer.destroy(),this._segments&&this._segments.destroy(),this.programConfigurations.destroy();for(let t=0;tt.fqid)),this.index=t.index,this.hasPattern=!1,this.edgeRadius=0,this.projection=t.projection,this.activeReplacements=[],this.replacementUpdateTime=0,this.centroidData=[],this.footprintIndices=new Kl,this.footprintVertices=new $l,this.footprintSegments=[],this.layoutVertexArray=new Dl,this.centroidVertexArray=new vc,this.indexArray=new Kl,this.programConfigurations=new Yc(t.layers,{zoom:t.zoom,lut:t.lut},(t=>Qp.includes(t))),this.segments=new wc,this.stateDependentLayerIds=this.layers.filter((t=>t.isStateDependent())).map((t=>t.id)),this.groundEffect=new mf(t),this.maxHeight=0,this.partLookup={},this.triangleSubSegments=[],this.polygonSegments=[]}updateFootprints(t,e){}populate(t,e,i,n){this.features=[],this.hasPattern=Hh("fill-extrusion",this.layers,e),this.featuresOnBorder=[],this.borderFeatureIndices=[[],[],[],[]],this.borderDoneWithNeighborZ=[-1,-1,-1,-1],this.tileToMeter=zd(i),this.edgeRadius=this.layers[0].layout.get("fill-extrusion-edge-radius")/this.tileToMeter;for(const{feature:r,id:o,index:s,sourceLayerIndex:a}of t){const t=this.layers[0]._featureFilter.needGeometry,l=Zd(r,t);if(!this.layers[0]._featureFilter.filter(new Ha(this.zoom),l,i))continue;const c={id:o,sourceLayerIndex:a,index:s,geometry:t?l.geometry:Gd(r,i,n),properties:r.properties,type:r.type,patterns:{}},d=this.layoutVertexArray.length;this.hasPattern?this.features.push(Wh("fill-extrusion",this.layers,c,this.zoom,e)):this.addFeature(c,c.geometry,s,i,{},e.availableImages,n,e.brightness),e.featureIndex.insert(r,c.geometry,s,a,this.index,d)}this.sortBorders(),"mercator"===this.projection.name&&this.splitToSubtiles(),this.groundEffect.prepareBorderSegments(),this.polygonSegments.length=0}addFeatures(t,e,i,n,r,o){for(const t of this.features){const{geometry:s}=t;this.addFeature(t,s,t.index,e,i,n,r,o)}this.sortBorders(),"mercator"===this.projection.name&&this.splitToSubtiles()}update(t,e,i,n,r){const o=0!==Object.keys(t).length;if(o&&!this.stateDependentLayers.length)return;const s=o?this.stateDependentLayers:this.layers;this.programConfigurations.updatePaintArrays(t,e,s,i,n,r),this.groundEffect.update(t,e,s,i,n,r)}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload||this.groundEffect.programConfigurations.needsUpload}upload(t){this.uploaded||(this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,lp),this.indexBuffer=t.createIndexBuffer(this.indexArray),this.layoutVertexExtArray&&(this.layoutVertexExtBuffer=t.createVertexBuffer(this.layoutVertexExtArray,ap.members,!0)),this.groundEffect.upload(t)),this.groundEffect.uploadPaintProperties(t),this.programConfigurations.upload(t),this.uploaded=!0}uploadCentroid(t){this.groundEffect.uploadHiddenByLandmark(t),this.needsCentroidUpdate&&(!this.centroidVertexBuffer&&this.centroidVertexArray.length>0?this.centroidVertexBuffer=t.createVertexBuffer(this.centroidVertexArray,op.members,!0):this.centroidVertexBuffer&&this.centroidVertexBuffer.updateData(this.centroidVertexArray),this.needsCentroidUpdate=!1)}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.centroidVertexBuffer&&this.centroidVertexBuffer.destroy(),this.layoutVertexExtBuffer&&this.layoutVertexExtBuffer.destroy(),this.groundEffect.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy())}addFeature(t,e,i,n,r,o,s,a){const l=this.layers[0].paint.get("fill-extrusion-flood-light-ground-radius").evaluate(t,{})/this.tileToMeter,c=[new Ue(0,0),new Ue(uo,uo)],d=s.projection,u="globe"===d.name,h="Polygon"===Jp[t.type],p=new uf;p.centroidDataIndex=this.centroidData.length;const f=new df,m=this.layers[0].paint.get("fill-extrusion-base").evaluate(t,{},n)=0;t--){const e=g[t];(0===e.length||(y=e[0]).every((t=>t.xt.x>=uo))||y.every((t=>t.yt.y>=uo)))&&g.splice(t,1)}var y;let v;if(u)v=Ef(g,c,n);else{v=[];for(const t of g)v.push({polygon:t,bounds:c})}const x=h?this.edgeRadius:0,b=x>0&&this.zoom{if(0===t.length)return!1;const i=t[t.length-1];return e.x===i.x&&e.y===i.y};for(const{polygon:t,bounds:e}of v){let i=0,r=0;for(const e of t)h&&!e[0].equals(e[e.length-1])&&e.push(e[0]),r+=h?e.length-1:e.length;const o=this.segments.prepareSegment((h?5:4)*r,this.layoutVertexArray,this.indexArray);f.footprintSegIdx4&&wf(s[s.length-2],s[0],s[1]),c=x?yf(s[s.length-2],s[0],s[1],x):0;const _=[];let g,y,v;y=s[1].sub(s[0])._perp()._unit();let b=!0;for(let t=1,r=0;t0?1:0,C=l.dist(h);if(r+C>32768&&(r=0),x){v=T.sub(h)._perp()._unit();let t=vf(l,h,T,gf(y,v),x);isNaN(t)&&(t=0);const e=h.sub(l)._unit();l=l.add(e.mult(c))._round(),h=h.add(e.mult(-t))._round(),c=t,y=v,m&&this.zoom>=17&&(w(_,l)||_.push(l),w(_,h)||_.push(h))}const A=o.vertexLength,I=s.length>4&&wf(l,h,T);let L=Tf(r,a,b);if(sf(this.layoutVertexArray,l.x,l.y,E,M,0,0,L),sf(this.layoutVertexArray,l.x,l.y,E,M,0,1,L),r+=C,L=Tf(r,I,!b),a=I,sf(this.layoutVertexArray,h.x,h.y,E,M,0,0,L),sf(this.layoutVertexArray,h.x,h.y,E,M,0,1,L),o.vertexLength+=4,this.indexArray.emplaceBack(A+0,A+1,A+2),this.indexArray.emplaceBack(A+1,A+3,A+2),o.primitiveLength+=2,x){const n=i+(1===t?s.length-2:t-2),r=1===t?i:n+1;if(this.indexArray.emplaceBack(A+1,n,A+3),this.indexArray.emplaceBack(n,r,A+3),o.primitiveLength+=2,void 0===g&&(g=A),!xf(T,s[t],e)){const e=t===s.length-1?g:o.vertexLength;this.indexArray.emplaceBack(A+2,A+3,e),this.indexArray.emplaceBack(A+3,e+1,e),this.indexArray.emplaceBack(A+3,r,e+1),o.primitiveLength+=3}b=!b}if(u){const t=this.layoutVertexExtArray,e=d.projectTilePoint(l.x,l.y,n),i=d.projectTilePoint(h.x,h.y,n),r=d.upVector(n,l.x,l.y),o=d.upVector(n,h.x,h.y);lf(t,e,r),lf(t,e,r),lf(t,i,o),lf(t,i,o)}}h&&(i+=s.length-1),m&&x&&this.zoom>=17&&(0!==_.length&&w(_,_[0])&&_.pop(),this.groundEffect.addData(_,e,l,x>0))}this.footprintSegments.push(a),s.triangleCount=this.indexArray.length-s.triangleArrayOffset,this.polygonSegments.push(s),++f.footprintSegLen,++f.polygonSegLen}if(f.vertexCount=this.layoutVertexArray.length-f.vertexArrayOffset,f.groundVertexCount=this.groundEffect.vertexArray.length-f.groundVertexArrayOffset,0!==f.vertexCount){if(f.centroidXY=p.borders?rf:this.encodeCentroid(p,f),this.centroidData.push(f),p.borders){this.featuresOnBorder.push(p);const t=this.featuresOnBorder.length-1;for(let e=0;ethis.featuresOnBorder[e].borders[t][0]-this.featuresOnBorder[i].borders[t][0]))}splitToSubtiles(){const t=[];for(let e=0;euo),r=2*n+(+(i.min.x+i.max.x>uo)^n);for(let n=0;nt.triangleSegmentIdx===e.triangleSegmentIdx?t.subtile-e.subtile:t.triangleSegmentIdx-e.triangleSegmentIdx));let i=0,n=0,r=0;for(const e of t){if(e.triangleSegmentIdx!==i)break;r++}const o=t.length;for(;n!==t.length;){i=t[n].triangleSegmentIdx;let s=0,a=n,l=n;for(let e=a;e0&&this.triangleSubSegments.push({segment:d,min:o,max:c}),a=l;for(let e=a;e[t[0]*(1-i[0])+e[0]*i[0],t[1]*(1-i[1])+e[1]*i[1]],h=[],p=[];for(const t of this.triangleSubSegments){h[0]=t.min.x/uo,h[1]=t.min.y/uo,p[0]=t.max.x/uo,p[1]=t.max.y/uo;const e=u(l,c,h),o=u(l,c,p);if(0===new wu([e[0],e[1],n],[o[0],o[1],r]).intersectsPrecise(i)){a&&(d.segments.push(a),a=void 0);continue}const s=t.segment;a&&a.vertexOffset!==s.vertexOffset&&(d.segments.push(a),a=void 0),a?(a.vertexLength+=s.vertexLength,a.primitiveLength+=s.primitiveLength):a={vertexOffset:s.vertexOffset,primitiveLength:s.primitiveLength,vertexLength:s.vertexLength,primitiveOffset:s.primitiveOffset,sortKey:void 0,vaos:{}}}return a&&d.segments.push(a),d}encodeCentroid(t,e){const i=t.centroid(),n=e.span(),r=Math.min(7,Math.round(n.x*this.tileToMeter/10)),o=Math.min(7,Math.round(n.y*this.tileToMeter/10));return new Ue(Xe(i.x,1,uo-1)i.max.x||i.min.x>e.max.x||e.min.y>i.max.y||i.min.y>e.max.y))for(let o=0;oe!=l>e&&to.max.x||o.min.x>t||e>o.max.y||o.min.y>e||this.footprintContainsPoint(t,e,o)&&o&&o.height>i&&(i=o.height,this.partLookup[r]=o,n=!!(o.flags&of));if(i!==Number.NEGATIVE_INFINITY)return{height:i,hidden:n};this.partLookup[r]=void 0}}function gf(t,e){const i=t.add(e)._unit();return t.x*i.x+t.y*i.y}function yf(t,e,i,n){const r=e.sub(t)._perp()._unit(),o=i.sub(e)._perp()._unit();return vf(t,e,i,gf(r,o),n)}function vf(t,e,i,n,r){const o=Math.sqrt(1-n*n);return Math.min(t.dist(e)/3,e.dist(i)/3,r*o/n)}function xf(t,e,i){return t.xi[1].x&&e.x>i[1].x||t.yi[1].y&&e.y>i[1].y}function bf(t,e){return t.xe[1].x||t.ye[1].y}function wf(t,e,i){if(t.x=uo||e.x=uo||i.x=uo)return!1;const n=i.sub(e),r=n.perp(),o=t.sub(e);return(n.x*o.x+n.y*o.y)/Math.sqrt((n.x*n.x+n.y*n.y)*(o.x*o.x+o.y*o.y))>-.866&&r.x*o.x+r.y*o.y{for(const i of t)s.push({polygon:i,bounds:e})},l=Math.ceil(Math.log2(i)),c=Math.ceil(Math.log2(n)),d=l-c,u=[];for(let t=0;t0?0:1);for(let t=0;te+1?p.push({polygons:h,bounds:t,depth:e+1}):a(h,t)}if(f.length){const t=[new Ue(0===i?d:n.x,1===i?d:n.y),s];u.length>e+1?p.push({polygons:f,bounds:t,depth:e+1}):a(f,t)}}return s}(t,e,Math.ceil((o-r)/11.25),Math.ceil((s-a)/11.25),1,((t,e,r)=>{if(0===t)return.5*(e+r);{const t=Id((i.y+e/uo)/n);return(Md(.5*(Id((i.y+r/uo)/n)+t))*n-i.y)*uo}}))}function Mf(t,e,i,n,r,o){const s=Math.pow(2,n.z-r.z);for(let a=0;a1&&(s=t[++o]);const l=Math.abs(a-s.left),c=Math.abs(a-s.right),d=Math.min(l,c);let u;const h=e/i*(n+1);if(s.isDash){const t=n-Math.abs(h);u=Math.sqrt(d*d+t*t)}else u=n-Math.sqrt(d*d+h*h);this.image.data[r+a]=Math.max(0,Math.min(255,u+128))}}}addRegularDash(t,e){for(let e=t.length-1;e>=0;--e){const i=t[e],n=t[e+1];i.zeroLength?t.splice(e,1):n&&n.isDash===i.isDash&&(n.left=i.left,t.splice(e,1))}const i=t[0],n=t[t.length-1];i.isDash===n.isDash&&(i.left=n.left-this.width,n.right=i.right+this.width);const r=this.width*this.nextRow;let o=0,s=t[o];for(let i=0;i1&&(s=t[++o]);const n=Math.abs(i-s.left),a=Math.abs(i-s.right),l=Math.min(n,a);this.image.data[r+i]=Math.max(0,Math.min(255,(s.isDash?l:-l)+e+128))}}addDash(t,e){const i=this.getKey(t,e);if(this.positions[i])return this.positions[i];const n="round"===e,r=n?7:0,o=2*r+1;if(this.nextRow+o>this.height)return pi("LineAtlas out of space"),null;0===t.length&&t.push(1);let s=0;for(let e=0;et.fqid)),this.index=t.index,this.projection=t.projection,this.hasPattern=!1,this.hasZOffset=!1,this.patternFeatures=[],this.lineClipsArray=[],this.gradients={},this.layers.forEach((t=>{this.gradients[t.id]={}})),this.layoutVertexArray=new Rl,this.layoutVertexArray2=new Ol,this.patternVertexArray=new Bl,this.indexArray=new Kl,this.programConfigurations=new Yc(t.layers,{zoom:t.zoom,lut:t.lut}),this.segments=new wc,this.maxLineLength=0,this.zOffsetVertexArray=new Zl,this.stateDependentLayerIds=this.layers.filter((t=>t.isStateDependent())).map((t=>t.id)),this.tessellationStep=t.tessellationStep?t.tessellationStep:uo/64}updateFootprints(t,e){}populate(t,e,i,n){this.hasPattern=Hh("line",this.layers,e);const r=this.layers[0].layout.get("line-sort-key"),o=this.layers[0].layout.get("line-z-offset");this.hasZOffset=!o.isConstant()||!!o.constantOr(0);const s=[];for(const{feature:e,id:o,index:a,sourceLayerIndex:l}of t){const t=this.layers[0]._featureFilter.needGeometry,c=Zd(e,t);if(!this.layers[0]._featureFilter.filter(new Ha(this.zoom),c,i))continue;const d=r?r.evaluate(c,{},i):void 0,u={id:o,properties:e.properties,type:e.type,sourceLayerIndex:l,index:a,geometry:t?c.geometry:Gd(e,i,n),patterns:{},sortKey:d};s.push(u)}r&&s.sort(((t,e)=>t.sortKey-e.sortKey));const{lineAtlas:a,featureIndex:l}=e,c=this.addConstantDashes(a);for(const n of s){const{geometry:r,index:o,sourceLayerIndex:s}=n;if(c&&this.addFeatureDashes(n,a),this.hasPattern){const t=Wh("line",this.layers,n,this.zoom,e);this.patternFeatures.push(t)}else this.addFeature(n,r,o,i,a.positions,e.availableImages,e.brightness);l.insert(t[o].feature,r,o,s,this.index)}}addConstantDashes(t){let e=!1;for(const i of this.layers){const n=i.paint.get("line-dasharray").value,r=i.layout.get("line-cap").value;if("constant"!==n.kind||"constant"!==r.kind)e=!0;else{const e=r.value,i=n.value;if(!i)continue;t.addDash(i,e)}}return e}addFeatureDashes(t,e){const i=this.zoom;for(const n of this.layers){const r=n.paint.get("line-dasharray").value,o=n.layout.get("line-cap").value;if("constant"===r.kind&&"constant"===o.kind)continue;let s,a;if("constant"===r.kind){if(s=r.value,!s)continue}else s=r.evaluate({zoom:i},t);a="constant"===o.kind?o.value:o.evaluate({zoom:i},t),e.addDash(s,a),t.patterns[n.id]=e.getKey(s,a)}}update(t,e,i,n,r){const o=0!==Object.keys(t).length;o&&!this.stateDependentLayers.length||this.programConfigurations.updatePaintArrays(t,e,o?this.stateDependentLayers:this.layers,i,n,r)}addFeatures(t,e,i,n,r,o){for(const t of this.patternFeatures)this.addFeature(t,t.geometry,t.index,e,i,n,o)}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(t){this.uploaded||(0!==this.layoutVertexArray2.length&&(this.layoutVertexBuffer2=t.createVertexBuffer(this.layoutVertexArray2,zf)),0!==this.patternVertexArray.length&&(this.patternVertexBuffer=t.createVertexBuffer(this.patternVertexArray,Of)),!this.zOffsetVertexBuffer&&this.zOffsetVertexArray.length>0&&(this.zOffsetVertexBuffer=t.createVertexBuffer(this.zOffsetVertexArray,jf.members,!0)),this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,kf),this.indexBuffer=t.createIndexBuffer(this.indexArray)),this.programConfigurations.upload(t),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.zOffsetVertexBuffer&&this.zOffsetVertexBuffer.destroy(),this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy())}lineFeatureClips(t){if(t.properties&&t.properties.hasOwnProperty("mapbox_clip_start")&&t.properties.hasOwnProperty("mapbox_clip_end"))return{start:+t.properties.mapbox_clip_start,end:+t.properties.mapbox_clip_end}}addFeature(t,e,i,n,r,o,s){const a=this.layers[0].layout,l=a.get("line-join").evaluate(t,{}),c=a.get("line-cap").evaluate(t,{}),d=a.get("line-miter-limit"),u=a.get("line-round-limit");this.lineClips=this.lineFeatureClips(t);for(const i of e)this.addLine(i,t,n,l,c,d,u);this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,t,i,r,o,n,s)}addLine(t,e,i,n,r,o,s){this.distance=0,this.scaledDistance=0,this.totalDistance=0,this.lineSoFar=0,this.currentVertex=void 0;const a={zoom:this.zoom,lineProgress:void 0},l=this.layers[0].layout,c="none"===n;if(this.patternJoinNone=this.hasPattern&&c,this.segmentStart=0,this.segmentStartf32=0,this.segmentPoints=[],this.lineClips){this.lineClipsArray.push(this.lineClips);for(let e=0;e=2&&t[u-1].equals(t[u-2]);)u--;let h=0;for(;h0;if(A&&i>h){const t=m.dist(_);if(t>2*p){const e=m.sub(m.sub(_)._mult(p/t)._round());this.updateDistance(_,e),this.addCurrentVertex(e,y,0,0,f,x),_=e}}if(b&&"round"===w&&(Mo&&(w="bevel"),"bevel"===w&&(M>2&&(w="flipbevel"),M100)S=v.mult(-1);else{const t=M*y.add(v).mag()/y.sub(v).mag();S._perp()._mult(t*(I?-1:1))}this.addCurrentVertex(m,S,0,0,f,x),this.addCurrentVertex(m,S.mult(-1),0,0,f,x)}else if("bevel"===w||"fakeround"===w){const t=-Math.sqrt(M*M-1),e=I?t:0,i=I?0:t;if(_&&this.addCurrentVertex(m,y,e,i,f,x),"fakeround"===w){const t=Math.round(180*C/Math.PI/20);for(let e=1;e2*p){const e=m.add(g.sub(m)._mult(p/t)._round());this.updateDistance(m,e),this.addCurrentVertex(e,v,0,0,f,x),m=e}}}}addVerticesTo(t,e,i,n,r,o,s,a,l,c){const d=(e.w-t.w)/this.tessellationStep|0;if(d>1){this.lineSoFar=t.w;const u=(e.x-t.x)/d,h=(e.y-t.y)/d,p=(e.z-t.z)/d,f=(e.w-t.w)/d;for(let e=1;e=0&&this.e2>=0&&(this.indexArray.emplaceBack(this.e1,this.e2,c),a.primitiveLength++),o?this.e2=c:this.e1=c,null!=l&&this.zOffsetVertexArray.emplaceBack(l)}updateScaledDistance(){if(this.lineClips){const t=this.totalDistance/(this.lineClips.end-this.lineClips.start);this.scaledDistance=this.distance/this.totalDistance,this.lineSoFar=t*this.lineClips.start+this.distance}else this.lineSoFar=this.distance}updateDistance(t,e){this.distance+=t.dist(e),this.updateScaledDistance()}}function Qf(t,e,i){return t.xi||t.yi}ba(Jf,"LineBucket",{omit:["layers","patternFeatures","currentVertex","currentVertexIsOutside"]});const tm=new ol({"line-cap":new nl(sl.layout_line["line-cap"]),"line-join":new nl(sl.layout_line["line-join"]),"line-miter-limit":new il(sl.layout_line["line-miter-limit"]),"line-round-limit":new il(sl.layout_line["line-round-limit"]),"line-sort-key":new nl(sl.layout_line["line-sort-key"]),"line-z-offset":new nl(sl.layout_line["line-z-offset"]),visibility:new il(sl.layout_line.visibility)});var em={paint:new ol({"line-opacity":new nl(sl.paint_line["line-opacity"]),"line-color":new nl(sl.paint_line["line-color"]),"line-translate":new il(sl.paint_line["line-translate"]),"line-translate-anchor":new il(sl.paint_line["line-translate-anchor"]),"line-width":new nl(sl.paint_line["line-width"]),"line-gap-width":new nl(sl.paint_line["line-gap-width"]),"line-offset":new nl(sl.paint_line["line-offset"]),"line-blur":new nl(sl.paint_line["line-blur"]),"line-dasharray":new nl(sl.paint_line["line-dasharray"]),"line-pattern":new nl(sl.paint_line["line-pattern"]),"line-gradient":new rl(sl.paint_line["line-gradient"]),"line-trim-offset":new il(sl.paint_line["line-trim-offset"]),"line-trim-fade-range":new il(sl.paint_line["line-trim-fade-range"]),"line-trim-color":new il(sl.paint_line["line-trim-color"]),"line-emissive-strength":new il(sl.paint_line["line-emissive-strength"]),"line-border-width":new nl(sl.paint_line["line-border-width"]),"line-border-color":new nl(sl.paint_line["line-border-color"]),"line-occlusion-opacity":new il(sl.paint_line["line-occlusion-opacity"])}),layout:tm};function im(t,e,i){return e*(uo/(t.tileSize*Math.pow(2,i-t.tileID.overscaledZ)))}function nm(t,e){return 1/im(t,1,e.tileZoom)}function rm(t,e,i,n){return t.translatePosMatrix(n||e.tileID.projMatrix,e,i.paint.get("line-translate"),i.paint.get("line-translate-anchor"))}const om=t=>{const e=[];sm(t)&&e.push("RENDER_LINE_DASH"),t.paint.get("line-gradient")&&e.push("RENDER_LINE_GRADIENT");const i=t.paint.get("line-trim-offset");0===i[0]&&0===i[1]||e.push("RENDER_LINE_TRIM_OFFSET"),0!==t.paint.get("line-border-width").constantOr(1)&&e.push("RENDER_LINE_BORDER");const n="none"===t.layout.get("line-join").constantOr("miter"),r=!!t.paint.get("line-pattern").constantOr(1);return n&&r&&e.push("LINE_JOIN_NONE"),e};function sm(t){const e=t.paint.get("line-dasharray").value;return e.value||"constant"!==e.kind}class am{constructor(t){this._stringToNumber={},this._numberToString=[];for(let e=0;e>1,d=-7,u=i?r-1:0,h=i?-1:1,p=t[e+u];for(u+=h,o=p&(1>=-d,d+=a;d>0;o=256*o+t[e+u],u+=h,d-=8);for(s=o&(1>=-d,d+=n;d>0;s=256*s+t[e+u],u+=h,d-=8);if(0===o)o=1-c;else{if(o===l)return s?NaN:1/0*(p?-1:1);s+=Math.pow(2,n),o-=c}return(p?-1:1)*s*Math.pow(2,o-n)},write:function(t,e,i,n,r,o){var s,a,l,c=8*o-r-1,d=(1>1,h=23===r?Math.pow(2,-24)-Math.pow(2,-77):0,p=n?0:o-1,f=n?1:-1,m=e=1?h/l:h*Math.pow(2,1-u))*l>=2&&(s++,l/=2),s+u>=d?(a=0,s=d):s+u>=1?(a=(e*l-1)*Math.pow(2,r),s+=u):(a=e*Math.pow(2,u-1)*Math.pow(2,r),s=0));r>=8;t[i+p]=255&a,p+=f,a/=256,r-=8);for(s=s0;t[i+p]=255&s,p+=f,s/=256,c-=8);t[i+p-f]|=128*m}},cm=um,dm=lm;function um(t){this.buf=ArrayBuffer.isView&&ArrayBuffer.isView(t)?t:new Uint8Array(t||0),this.pos=0,this.type=0,this.length=this.buf.length}um.Varint=0,um.Fixed64=1,um.Bytes=2,um.Fixed32=5;var hm=4294967296,pm=1/hm,fm="undefined"==typeof TextDecoder?null:new TextDecoder("utf8");function mm(t){return t.type===um.Bytes?t.readVarint()+t.pos:t.pos+1}function _m(t,e,i){return i?4294967296*e+(t>>>0):4294967296*(e>>>0)+(t>>>0)}function gm(t,e,i){var n=e=t;r--)i.buf[r+n]=i.buf[r]}function ym(t,e){for(var i=0;i>>8,t[i+2]=e>>>16,t[i+3]=e>>>24}function Im(t,e){return(t[e]|t[e+1]>3,o=this.pos;this.type=7&n,t(r,e,this),this.pos===o&&this.skip(n)}return e},readMessage:function(t,e){return this.readFields(t,e,this.readVarint()+this.pos)},readFixed32:function(){var t=Cm(this.buf,this.pos);return this.pos+=4,t},readSFixed32:function(){var t=Im(this.buf,this.pos);return this.pos+=4,t},readFixed64:function(){var t=Cm(this.buf,this.pos)+Cm(this.buf,this.pos+4)*hm;return this.pos+=8,t},readSFixed64:function(){var t=Cm(this.buf,this.pos)+Im(this.buf,this.pos+4)*hm;return this.pos+=8,t},readFloat:function(){var t=dm.read(this.buf,this.pos,!0,23,4);return this.pos+=4,t},readDouble:function(){var t=dm.read(this.buf,this.pos,!0,52,8);return this.pos+=8,t},readVarint:function(t){var e,i,n=this.buf;return e=127&(i=n[this.pos++]),i>4,r=12&&fm?function(t,e,i){return fm.decode(t.subarray(e,i))}(this.buf,e,t):function(t,e,i){for(var n="",r=e;r239?4:l>223?3:l>191?2:1;if(r+d>i)break;1===d?l=55296&&c=1114112)&&(c=null)),null===c?(c=65533,d=1):c>65535&&(c-=65536,n+=String.fromCharCode(c>>>10&1023|55296),c=56320|1023&c),n+=String.fromCharCode(c),r+=d}return n}(this.buf,e,t)},readBytes:function(){var t=this.readVarint()+this.pos,e=this.buf.subarray(this.pos,t);return this.pos=t,e},readPackedVarint:function(t,e){if(this.type!==um.Bytes)return t.push(this.readVarint(e));var i=mm(this);for(t=t||[];this.pos127;);else if(e===um.Bytes)this.pos=this.readVarint()+this.pos;else if(e===um.Fixed32)this.pos+=4;else{if(e!==um.Fixed64)throw new Error("Unimplemented type: "+e);this.pos+=8}},writeTag:function(t,e){this.writeVarint(t268435455||t=0?(i=t%4294967296|0,n=t/4294967296|0):(n=~(-t/4294967296),4294967295^(i=~(-t%4294967296))?i=i+1|0:(i=0,n=n+1|0)),t>=0x10000000000000000||t>>=7,i.buf[i.pos++]=127&t|128,t>>>=7,i.buf[i.pos++]=127&t|128,t>>>=7,i.buf[i.pos++]=127&t|128,i.buf[i.pos]=127&(t>>>=7)}(i,0,e),function(t,e){var i=(7&t)>>=3)?128:0),t&&(e.buf[e.pos++]=127&t|((t>>>=7)?128:0),t&&(e.buf[e.pos++]=127&t|((t>>>=7)?128:0),t&&(e.buf[e.pos++]=127&t|((t>>>=7)?128:0),t&&(e.buf[e.pos++]=127&t|((t>>>=7)?128:0),t&&(e.buf[e.pos++]=127&t)))))}(n,e)}(t,this):(this.realloc(4),this.buf[this.pos++]=127&t|(t>127?128:0),t>>=7)|(t>127?128:0),t>>=7)|(t>127?128:0),t>>7&127))))},writeSVarint:function(t){this.writeVarint(t55295&&n56319||o+1===e.length?(t[i++]=239,t[i++]=191,t[i++]=189):r=n;continue}if(n>6|192:(n>12|224:(t[i++]=n>>18|240,t[i++]=n>>12&63|128),t[i++]=n>>6&63|128),t[i++]=63&n|128)}return i}(this.buf,t,this.pos);var i=this.pos-e;i>=128&&gm(e,i,this),this.pos=e-1,this.writeVarint(i),this.pos+=i},writeFloat:function(t){this.realloc(4),dm.write(this.buf,t,this.pos,!0,23,4),this.pos+=4},writeDouble:function(t){this.realloc(8),dm.write(this.buf,t,this.pos,!0,52,8),this.pos+=8},writeBytes:function(t){var e=t.length;this.writeVarint(e),this.realloc(e);for(var i=0;i=128&&gm(i,n,this),this.pos=i-1,this.writeVarint(n),this.pos+=n},writeMessage:function(t,e,i){this.writeTag(t,um.Bytes),this.writeRawMessage(e,i)},writePackedVarint:function(t,e){e.length&&this.writeMessage(t,ym,e)},writePackedSVarint:function(t,e){e.length&&this.writeMessage(t,vm,e)},writePackedBoolean:function(t,e){e.length&&this.writeMessage(t,wm,e)},writePackedFloat:function(t,e){e.length&&this.writeMessage(t,xm,e)},writePackedDouble:function(t,e){e.length&&this.writeMessage(t,bm,e)},writePackedFixed32:function(t,e){e.length&&this.writeMessage(t,Tm,e)},writePackedSFixed32:function(t,e){e.length&&this.writeMessage(t,Sm,e)},writePackedFixed64:function(t,e){e.length&&this.writeMessage(t,Em,e)},writePackedSFixed64:function(t,e){e.length&&this.writeMessage(t,Mm,e)},writeBytesField:function(t,e){this.writeTag(t,um.Bytes),this.writeBytes(e)},writeFixed32Field:function(t,e){this.writeTag(t,um.Fixed32),this.writeFixed32(e)},writeSFixed32Field:function(t,e){this.writeTag(t,um.Fixed32),this.writeSFixed32(e)},writeFixed64Field:function(t,e){this.writeTag(t,um.Fixed64),this.writeFixed64(e)},writeSFixed64Field:function(t,e){this.writeTag(t,um.Fixed64),this.writeSFixed64(e)},writeVarintField:function(t,e){this.writeTag(t,um.Varint),this.writeVarint(e)},writeSVarintField:function(t,e){this.writeTag(t,um.Varint),this.writeSVarint(e)},writeStringField:function(t,e){this.writeTag(t,um.Bytes),this.writeString(e)},writeFloatField:function(t,e){this.writeTag(t,um.Fixed32),this.writeFloat(e)},writeDoubleField:function(t,e){this.writeTag(t,um.Fixed64),this.writeDouble(e)},writeBooleanField:function(t,e){this.writeVarintField(t,Boolean(e))}};var Lm=h(cm);const Pm=["id","tile","layer","source","sourceLayer","state"];class $m{constructor(t,e,i,n,r){this.type="Feature",this._vectorTileFeature=t,this._z=e,this._x=i,this._y=n,this.properties=t.properties,this.id=r}get geometry(){return void 0===this._geometry&&(this._geometry=this._vectorTileFeature.toGeoJSON(this._x,this._y,this._z).geometry),this._geometry}set geometry(t){this._geometry=t}toJSON(){const t={type:"Feature",state:void 0,geometry:this.geometry,properties:this.properties};for(const e of Pm)void 0!==this[e]&&(t[e]=this[e]);return t}}class km{constructor(){this.state={},this.stateChanges={},this.deletedStates={}}updateState(t,e,i){const n=String(e);if(this.stateChanges[t]=this.stateChanges[t]||{},this.stateChanges[t][n]=this.stateChanges[t][n]||{},ei(this.stateChanges[t][n],i),null===this.deletedStates[t]){this.deletedStates[t]={};for(const e in this.state[t])e!==n&&(this.deletedStates[t][e]=null)}else if(this.deletedStates[t]&&null===this.deletedStates[t][n]){this.deletedStates[t][n]={};for(const e in this.state[t][n])i[e]||(this.deletedStates[t][n][e]=null)}else for(const e in i)this.deletedStates[t]&&this.deletedStates[t][n]&&null===this.deletedStates[t][n][e]&&delete this.deletedStates[t][n][e]}removeFeatureState(t,e,i){if(null===this.deletedStates[t])return;const n=String(e);if(this.deletedStates[t]=this.deletedStates[t]||{},i&&void 0!==e)null!==this.deletedStates[t][n]&&(this.deletedStates[t][n]=this.deletedStates[t][n]||{},this.deletedStates[t][n][i]=null);else if(void 0!==e)if(this.stateChanges[t]&&this.stateChanges[t][n])for(i in this.deletedStates[t][n]={},this.stateChanges[t][n])this.deletedStates[t][n][i]=null;else this.deletedStates[t][n]=null;else this.deletedStates[t]=null}getState(t,e){const i=String(e),n=ei({},(this.state[t]||{})[i],(this.stateChanges[t]||{})[i]);if(null===this.deletedStates[t])return{};if(this.deletedStates[t]){const i=this.deletedStates[t][e];if(null===i)return{};for(const t in i)delete n[t]}return n}initializeTileState(t,e){t.setFeatureState(this.state,e)}coalesceChanges(t,e){const i={};for(const t in this.stateChanges){this.state[t]=this.state[t]||{};const e={};for(const i in this.stateChanges[t])this.state[t][i]||(this.state[t][i]={}),ei(this.state[t][i],this.stateChanges[t][i]),e[i]=this.state[t][i];i[t]=e}for(const t in this.deletedStates){this.state[t]=this.state[t]||{};const e={};if(null===this.deletedStates[t])for(const i in this.state[t])e[i]={},this.state[t][i]={};else for(const i in this.deletedStates[t]){if(null===this.deletedStates[t][i])this.state[t][i]={};else if(this.state[t][i])for(const e of Object.keys(this.deletedStates[t][i]))delete this.state[t][i][e];e[i]=this.state[t][i]}i[t]=i[t]||{},ei(i[t],e)}if(this.stateChanges={},this.deletedStates={},0!==Object.keys(i).length)for(const n in t)t[n].setFeatureState(i,e)}}class Dm{constructor(t,e){this.tileID=t,this.x=t.canonical.x,this.y=t.canonical.y,this.z=t.canonical.z,this.grid=new va(uo,16,0),this.featureIndexArray=new yc,this.promoteId=e,this.is3DTile=!1}insert(t,e,i,n,r,o=0,s=0){const a=this.featureIndexArray.length;this.featureIndexArray.emplaceBack(i,n,r,o);const l=this.grid;for(let t=0;t=0&&n[3]>=0&&l.insert(a,n[0],n[1],n[2],n[3])}}loadVTLayers(){if(!this.vtLayers){this.vtLayers=new bp(new Lm(this.rawTileData)).layers,this.sourceLayerCoder=new am(this.vtLayers?Object.keys(this.vtLayers).sort():["_geojsonTileLayer"]),this.vtFeatures={};for(const t in this.vtLayers)this.vtFeatures[t]=[]}return this.vtLayers}query(t,e,i,n){this.loadVTLayers();const r=t.params||{},o=dl(r.filter),s=t.tileResult,a=t.transform,l=s.bufferedTilespaceBounds,c=this.grid.query(l.min.x,l.min.y,l.max.x,l.max.y,((t,e,i,n)=>ou(s.bufferedTilespaceGeometry,t,e,i,n)));c.sort(Rm);let d=null;a.elevation&&c.length>0&&(d=Xp.create(a.elevation,this.tileID));const u={};let h;for(let l=0;l(m||(m=Gd(e,this.tileID.canonical,t.tileTransform)),i.queryIntersectsFeature(s,e,n,m,this.z,t.transform,t.pixelPosMatrix,d,r))))}return u}loadMatchingFeature(t,e,i,n,r,o,s,a,l){const{featureIndex:c,bucketIndex:d,sourceLayerIndex:u,layoutVertexArrayOffset:h}=e,p=this.bucketLayerIDs[d];if(n&&!function(t,e){for(let i=0;i=0)return!0;return!1}(n,p))return;const f=this.sourceLayerCoder.decode(u),m=this.vtLayers[f].feature(c);if(i.needGeometry){const t=Zd(m,!0);if(!i.filter(new Ha(this.tileID.overscaledZ),t,this.tileID.canonical))return}else if(!i.filter(new Ha(this.tileID.overscaledZ),m))return;const _=this.getId(m,f);for(let e=0;e{const s=e instanceof el?e.get(o):null;return s&&s.evaluate?s.evaluate(i,n,r):s}))}function Rm(t,e){return e-t}ba(Dm,"FeatureIndex",{omit:["rawTileData","sourceLayerCoder"]});var Om=24;const Bm=128;function Fm(t,e){const{expression:i}=e;if("constant"===i.kind)return{kind:"constant",layoutSize:i.evaluate(new Ha(t+1))};if("source"===i.kind)return{kind:"source"};{const{zoomStops:e,interpolationType:n}=i;let r=0;for(;r{t.text=function(t,e,i){const n=e.layout.get("text-transform").evaluate(i,{});return"uppercase"===n?t=t.toLocaleUpperCase():"lowercase"===n&&(t=t.toLocaleLowerCase()),qa.applyArabicShaping&&(t=qa.applyArabicShaping(t)),t}(t.text,e,i)})),t}const Gm={"!":"︕","#":"#",$:"$","%":"%","&":"&","(":"︵",")":"︶","*":"*","+":"+",",":"︐","-":"︲",".":"・","/":"/",":":"︓",";":"︔","":"﹀","?":"︖","@":"@","[":"﹇","\\":"\","]":"﹈","^":"^",_:"︳","`":"`","{":"︷","|":"―","}":"︸","~":"~","¢":"¢","£":"£","¥":"¥","¦":"¦","¬":"¬","¯":" ̄","–":"︲","—":"︱","‘":"﹃","’":"﹄","“":"﹁","”":"﹂","…":"︙","‧":"・","₩":"₩","、":"︑","。":"︒","〈":"︿","〉":"﹀","《":"︽","》":"︾","「":"﹁","」":"﹂","『":"﹃","』":"﹄","【":"︻","】":"︼","〔":"︹","〕":"︺","〖":"︗","〗":"︘","!":"︕","(":"︵",")":"︶",",":"︐","-":"︲",".":"・",":":"︓",";":"︔","<":"︿",">":"﹀","?":"︖","[":"﹇","]":"﹈","_":"︳","{":"︷","|":"―","}":"︸","⦅":"︵","⦆":"︶","。":"︒","「":"﹁","」":"﹂","←":"↑","→":"↓"};function Zm(t){return"︶"===t||"﹈"===t||"︸"===t||"﹄"===t||"﹂"===t||"︾"===t||"︼"===t||"︺"===t||"︘"===t||"﹀"===t||"︐"===t||"︓"===t||"︔"===t||"`"===t||" ̄"===t||"︑"===t||"︒"===t}function qm(t){return"︵"===t||"﹇"===t||"︷"===t||"﹃"===t||"﹁"===t||"︽"===t||"︻"===t||"︹"===t||"︗"===t||"︿"===t}const Hm=3;function Wm(t,e,i){e.glyphs=[],1===t&&i.readMessage(Ym,e)}function Ym(t,e,i){if(3===t){const{id:t,bitmap:n,width:r,height:o,left:s,top:a,advance:l}=i.readMessage(Xm,{});e.glyphs.push({id:t,bitmap:new dh({width:r+2*Hm,height:o+2*Hm},n),metrics:{width:r,height:o,left:s,top:a,advance:l}})}else 4===t?e.ascender=i.readSVarint():5===t&&(e.descender=i.readSVarint())}function Xm(t,e,i){1===t?e.id=i.readVarint():2===t?e.bitmap=i.readBytes():3===t?e.width=i.readVarint():4===t?e.height=i.readVarint():5===t?e.left=i.readSVarint():6===t?e.top=i.readSVarint():7===t&&(e.advance=i.readVarint())}const Km=Hm,Jm={horizontal:1,vertical:2,horizontalOnly:3};class Qm{constructor(){this.scale=1,this.fontStack="",this.imageName=null}static forText(t,e){const i=new Qm;return i.scale=t||1,i.fontStack=e,i}static forImage(t){const e=new Qm;return e.imageName=t,e}}class t_{constructor(){this.text="",this.sectionIndex=[],this.sections=[],this.imageSectionID=null}static fromFeature(t,e){const i=new t_;for(let n=0;n=0&&i>=t&&i_[this.text.charCodeAt(i)];i--)e--;this.text=this.text.substring(t,e),this.sectionIndex=this.sectionIndex.slice(t,e)}substring(t,e){const i=new t_;return i.text=this.text.substring(t,e),i.sectionIndex=this.sectionIndex.slice(t,e),i.sections=this.sections,i}toString(){return this.text}getMaxScale(){return this.sectionIndex.reduce(((t,e)=>Math.max(t,this.sections[e].scale)),0)}addTextSection(t,e){this.text+=t.text,this.sections.push(Qm.forText(t.scale,t.fontStack||e));const i=this.sections.length-1;for(let e=0;e=63743?null:++this.imageSectionID:(this.imageSectionID=57344,this.imageSectionID)}}function e_(t,e,i,n,r,o,s,a,l,c,d,u,h,p,f){const m=t_.fromFeature(t,r);u===Jm.vertical&&m.verticalizePunctuation(h);let _=[];const g=function(t,e,i,n,r,o){if(!t)return[];const s=[],a=function(t,e,i,n,r,o){let s=0;for(let i=0;i=0;let c=0;for(let i=0;i0&&o>b&&(b=o)}else{const t=i[a.fontStack];if(!t)continue;t[m]&&(S=t[m]);const n=e[a.fontStack];if(!n)continue;const o=n.glyphs[m];if(!o)continue;if(v=o.metrics,M=8203!==m?Om:0,_){const t=void 0!==n.ascender?Math.abs(n.ascender):0,e=void 0!==n.descender?Math.abs(n.descender):0,i=(t+e)*g;w-i/2;){if(s--,sn;)c-=l.shift().angleDelta;if(c>r)return!1;s++,a+=e.dist(i)}return!0}function m_(t){let e=0;for(let i=0;ic){const d=(c-l)/o,u=Vn(n.x,r.x,d),h=Vn(n.y,r.y,d),p=new p_(u,h,0,r.angleTo(n),i);return!s||f_(t,p,a,s,e)?p:void 0}l+=o}}function v_(t,e,i,n,r,o,s,a,l){const c=__(n,o,s),d=g_(n,r),u=d*s,h=0===t[0].x||t[0].x===l||0===t[0].y||t[0].y===l;return e-u=0&&g=0&&y=0&&h+c=n&&c.x>=n||(s.x>=n?s=new Ue(n,s.y+(n-s.x)/(c.x-s.x)*(c.y-s.y))._round():c.x>=n&&(c=new Ue(n,s.y+(n-s.x)/(c.x-s.x)*(c.y-s.y))._round()),s.y>=r&&c.y>=r||(s.y>=r?s=new Ue(s.x+(r-s.y)/(c.y-s.y)*(c.x-s.x),r)._round():c.y>=r&&(c=new Ue(s.x+(r-s.y)/(c.y-s.y)*(c.x-s.x),r)._round()),l&&s.equals(l[l.length-1])||(l=[s],o.push(l)),l.push(c)))))}}return o}function w_(t){let e=0,i=0;for(const n of t)e+=n.w*n.h,i=Math.max(i,n.w);t.sort(((t,e)=>e.h-t.h));const n=[{x:0,y:0,w:Math.max(Math.ceil(Math.sqrt(e/.95)),i),h:1/0}];let r=0,o=0;for(const e of t)for(let t=n.length-1;t>=0;t--){const i=n[t];if(!(e.w>i.w||e.h>i.h)){if(e.x=i.x,e.y=i.y,o=Math.max(o,e.y+e.h),r=Math.max(r,e.x+e.w),e.w===i.w&&e.h===i.h){const e=n.pop();tt.hasImage(e,i))),t.dispatchRenderCallbacks(this.haveRenderCallbacks,i);for(const n in t.getUpdatedImages(i))this.patchUpdatedImage(this.iconPositions[n],t.getImage(n,i),e),this.patchUpdatedImage(this.patternPositions[n],t.getImage(n,i),e)}patchUpdatedImage(t,e,i){if(!t||!e)return;if(t.version===e.version)return;t.version=e.version;const[n,r]=t.tl,o=!!Object.keys(this.patternPositions).length;i.update(e.data,{useMipmap:o},{x:n,y:r})}}ba(S_,"ImagePosition"),ba(E_,"ImageAtlas");const M_=1e20;function C_(t,e,i,n,r,o,s,a,l){for(let c=e;c-1);l++,o[l]=a,s[l]=c,s[l+1]=M_}for(let a=0,l=0;a{let n=this.entries[t];n||(n=this.entries[t]={glyphs:{},requests:{},ranges:{},ascender:void 0,descender:void 0});let r=n.glyphs[e];if(void 0!==r)return void i(null,{stack:t,id:e,glyph:r});if(r=this._tinySDF(n,t,e),r)return n.glyphs[e]=r,void i(null,{stack:t,id:e,glyph:r});const s=Math.floor(e/256);if(256*s>65535)return void i(new Error("glyphs > 65535 not supported"));if(n.ranges[s])return void i(null,{stack:t,id:e,glyph:r});let a=n.requests[s];a||(a=n.requests[s]=[],P_.loadGlyphRange(t,s,o,this.requestManager,((t,e)=>{if(e){n.ascender=e.ascender,n.descender=e.descender;for(const t in e.glyphs)this._doesCharSupportLocalGlyph(+t)||(n.glyphs[+t]=e.glyphs[+t]);n.ranges[s]=!0}for(const i of a)i(t,e);delete n.requests[s]}))),a.push(((n,r)=>{n?i(n):r&&i(null,{stack:t,id:e,glyph:r.glyphs[e]||null})}))}),((t,e)=>{if(t)i(t);else if(e){const t={};for(const{stack:i,id:n,glyph:r}of e)void 0===t[i]&&(t[i]={}),void 0===t[i].glyphs&&(t[i].glyphs={}),t[i].glyphs[n]=r&&{id:r.id,bitmap:r.bitmap.clone(),metrics:r.metrics},t[i].ascender=this.entries[i].ascender,t[i].descender=this.entries[i].descender;i(null,t)}}))}_doesCharSupportLocalGlyph(t){return this.localGlyphMode!==L_.none&&(this.localGlyphMode===L_.all?!!this.localFontFamily:!!this.localFontFamily&&(Ma["CJK Unified Ideographs"](t)||Ma["Hangul Syllables"](t)||Ma.Hiragana(t)||Ma.Katakana(t)||Ma["CJK Symbols and Punctuation"](t)||Ma["CJK Unified Ideographs Extension A"](t)||Ma["CJK Unified Ideographs Extension B"](t)))}_tinySDF(t,e,i){const n=this.localFontFamily;if(!n||!this._doesCharSupportLocalGlyph(i))return;let r=t.tinySDF;if(!r){let i="400";/bold/i.test(e)?i="900":/medium/i.test(e)?i="500":/light/i.test(e)&&(i="200"),r=t.tinySDF=new P_.TinySDF({fontFamily:n,fontWeight:i,fontSize:24*I_,buffer:3*I_,radius:8*I_}),r.fontWeight=i}if(this.localGlyphs[r.fontWeight][i])return this.localGlyphs[r.fontWeight][i];const o=String.fromCodePoint(i),{data:s,width:a,height:l,glyphWidth:c,glyphHeight:d,glyphLeft:u,glyphTop:h,glyphAdvance:p}=r.draw(o);return this.localGlyphs[r.fontWeight][i]={id:i,bitmap:new dh({width:a,height:l},s),metrics:{width:c/I_,height:d/I_,left:u/I_,top:h/I_-27,advance:p/I_,localGlyph:!0}}}}P_.loadGlyphRange=function(t,e,i,n,r){const o=256*e,s=o+255,a=n.transformRequest(n.normalizeGlyphsURL(i).replace("{fontstack}",t).replace("{range}",`${o}-${s}`),Ki.Glyphs);en(a,((t,e)=>{if(t)r(t);else if(e){const t={},i=function(t){return new Lm(t).readFields(Wm,{})}(e);for(const e of i.glyphs)t[e.id]=e;r(null,{glyphs:t,ascender:i.ascender,descender:i.descender})}}))},P_.TinySDF=class{constructor({fontSize:t=24,buffer:e=3,radius:i=8,cutoff:n=.25,fontFamily:r="sans-serif",fontWeight:o="normal",fontStyle:s="normal"}={}){this.buffer=e,this.cutoff=n,this.radius=i;const a=this.size=t+4*e,l=this._createCanvas(a),c=this.ctx=l.getContext("2d",{willReadFrequently:!0});c.font=`${s} ${o} ${t}px ${r}`,c.textBaseline="alphabetic",c.textAlign="left",c.fillStyle="black",this.gridOuter=new Float64Array(a*a),this.gridInner=new Float64Array(a*a),this.f=new Float64Array(a),this.z=new Float64Array(a+1),this.v=new Uint16Array(a)}_createCanvas(t){const e=document.createElement("canvas");return e.width=e.height=t,e}draw(t){const{width:e,actualBoundingBoxAscent:i,actualBoundingBoxDescent:n,actualBoundingBoxLeft:r,actualBoundingBoxRight:o}=this.ctx.measureText(t),s=Math.ceil(i),a=Math.max(0,Math.min(this.size-this.buffer,Math.ceil(o-r))),l=Math.min(this.size-this.buffer,s+Math.ceil(n)),c=a+2*this.buffer,d=l+2*this.buffer,u=Math.max(c*d,0),h=new Uint8ClampedArray(u),p={data:h,width:c,height:d,glyphWidth:a,glyphHeight:l,glyphTop:s,glyphLeft:0,glyphAdvance:e};if(0===a||0===l)return p;const{ctx:f,buffer:m,gridInner:_,gridOuter:g}=this;f.clearRect(m,m,a,l),f.fillText(t,m,m+s);const y=f.getImageData(m,m,a,l);g.fill(M_,0,u),_.fill(0,0,u);for(let t=0;t0?t*t:0,_[n]=tt+e[1]-e[0],f=u.reduce(p,0),m=h.reduce(p,0),_=a-f,g=l-m;let y=0,v=f,x=0,b=m,w=0,T=_,S=0,E=g;if(o.content&&n){const t=o.content;y=D_(u,0,t[0]),x=D_(h,0,t[1]),v=D_(u,t[0],t[2]),b=D_(h,t[1],t[3]),w=t[0]-y,S=t[1]-x,T=t[2]-t[0]-v,E=t[3]-t[1]-b}const M=(n,r,a,l)=>{const u=R_(n.stretch-y,v,c,t.left),h=O_(n.fixed-w,T,n.stretch,f),p=R_(r.stretch-x,b,d,t.top),_=O_(r.fixed-S,E,r.stretch,m),g=R_(a.stretch-y,v,c,t.left),M=O_(a.fixed-w,T,a.stretch,f),C=R_(l.stretch-x,b,d,t.top),A=O_(l.fixed-S,E,l.stretch,m),I=new Ue(u,p),L=new Ue(g,p),P=new Ue(g,C),$=new Ue(u,C),k=new Ue(h/s,_/s),D=new Ue(M/s,A/s),z=e*Math.PI/180;if(z){const t=Math.sin(z),e=Math.cos(z),i=[e,-t,t,e];I._matMult(i),L._matMult(i),$._matMult(i),P._matMult(i)}const R=n.stretch+n.fixed,O=a.stretch+a.fixed,B=r.stretch+r.fixed,F=l.stretch+l.fixed,N=t.imageSecondary;return{tl:I,tr:L,bl:$,br:P,texPrimary:{x:o.paddedRect.x+$_+R,y:o.paddedRect.y+$_+B,w:O-R,h:F-B},texSecondary:N?{x:N.paddedRect.x+$_+R,y:N.paddedRect.y+$_+B,w:O-R,h:F-B}:void 0,writingMode:void 0,glyphOffset:[0,0],sectionIndex:0,pixelOffsetTL:k,pixelOffsetBR:D,minFontScaleX:T/s/c,minFontScaleY:E/s/d,isSDF:i}};if(n&&(o.stretchX||o.stretchY)){const t=z_(u,_,f),e=z_(h,g,m);for(let i=0;io)&&(o=e.x),(!t||e.y>s)&&(s=e.y)}const l=Math.min(o-n,s-r);let c=l/2;const d=new co([],N_);if(0===l)return new Ue(n,r);for(let e=n;eu.d||!u.d)&&(u=n,i&&console.log("found best %d after %d probes",Math.round(1e4*n.d)/1e4,h)),n.max-u.dt.y!=a.y>t.y&&t.x18&&P>2&&(P>>=1),Math.max(uo/(512*P),1)*_.get("symbol-spacing")),S=_.get("text-padding")*t.tilePixelRatio,E=_.get("icon-padding")*t.tilePixelRatio,M=Ge(_.get("text-max-angle")),C="map"===_.get("text-rotation-alignment")&&"point"!==_.get("symbol-placement"),A="map"===_.get("icon-rotation-alignment")&&"point"!==_.get("symbol-placement"),I=_.get("symbol-placement"),L=T/2;var P;const $=_.get("icon-text-fit").evaluate(e,{},u),k=_.get("icon-text-fit-padding").evaluate(e,{},u),D="none"!==$;let z;!1===t.hasAnyIconTextFit&&D&&(t.hasAnyIconTextFit=!0),n&&D&&(t.allowVerticalPlacement&&i.vertical&&(z=h_(n,i.vertical,$,k,g,b)),y&&(n=h_(n,y,$,k,g,b)));const R=(s,a,m)=>{if(a.x=uo||a.y=uo)return;let _=null;if(v){const{x:t,y:e,z:i}=h.projectTilePoint(a.x,a.y,m);_={anchor:new p_(t,e,i,0,void 0),up:h.upVector(m,a.x,a.y)}}!function(t,e,i,n,r,o,s,a,l,c,d,u,h,p,f,m,_,g,y,v,x,b,w,T,S,E,M){const C=t.addToLineVertexArray(e,n);let A,I,L,P,$,k,D,z=0,R=0,O=0,B=0,F=-1,N=-1;const U={};let j=Ln("");const V=i?i.anchor:e,G="none"!==l.layout.get("icon-text-fit").evaluate(x,{},S);let Z=0,q=0;if(void 0===l._unevaluatedLayout.getValue("text-radial-offset")?[Z,q]=l.layout.get("text-offset").evaluate(x,{},S).map((t=>t*Om)):(Z=l.layout.get("text-radial-offset").evaluate(x,{},S)*Om,q=j_),t.allowVerticalPlacement&&r.vertical){const t=r.vertical;if(f)k=J_(t),a&&(D=J_(a));else{const i=l.layout.get("text-rotate").evaluate(x,{},S)+90;L=K_(c,V,e,d,u,h,t,p,i,m),a&&(P=K_(c,V,e,d,u,h,a,g,i))}}if(o){const n=l.layout.get("icon-rotate").evaluate(x,{},S),r=k_(o,n,w,G),s=a?k_(a,n,w,G):void 0;I=K_(c,V,e,d,u,h,o,g,n),z=4*r.length;const p=t.iconSizeData;let f=null;"source"===p.kind?(f=[Bm*l.layout.get("icon-size").evaluate(x,{},S)],f[0]>W_&&pi(`${t.layerIds[0]}: Value for "icon-size" is >= ${H_}. Reduce your "icon-size".`)):"composite"===p.kind&&(f=[Bm*b.compositeIconSizes[0].evaluate(x,{},S),Bm*b.compositeIconSizes[1].evaluate(x,{},S)],(f[0]>W_||f[1]>W_)&&pi(`${t.layerIds[0]}: Value for "icon-size" is >= ${H_}. Reduce your "icon-size".`)),t.addSymbols(t.icon,r,f,v,y,x,!1,i,e,C.lineStartIndex,C.lineLength,-1,T,S,E,M),F=t.icon.placedSymbolArray.length-1,s&&(R=4*s.length,t.addSymbols(t.icon,s,f,v,y,x,Jm.vertical,i,e,C.lineStartIndex,C.lineLength,-1,T,S,E,M),N=t.icon.placedSymbolArray.length-1)}for(const n in r.horizontal){const o=r.horizontal[n];A||(j=Ln(o.text),f?$=J_(o):A=K_(c,V,e,d,u,h,o,p,l.layout.get("text-rotate").evaluate(x,{},S),m));const a=1===o.positionedLines.length;if(O+=Y_(t,i,e,o,s,l,f,x,m,C,r.vertical?Jm.horizontal:Jm.horizontalOnly,a?Object.keys(r.horizontal):[n],U,F,b,T,S,E),a)break}r.vertical&&(B+=Y_(t,i,e,r.vertical,s,l,f,x,m,C,Jm.vertical,["vertical"],U,N,b,T,S,E));let H=-1;const W=(t,e)=>t?Math.max(t,e):e;H=W($,H),H=W(k,H),H=W(D,H);const Y=H>-1?1:0;t.glyphOffsetArray.length>=65535&&pi("Too many glyphs being rendered in a tile. See https://github.com/mapbox/mapbox-gl-js/issues/2907"),void 0!==x.sortKey&&t.addToSortKeyRanges(t.symbolInstances.length,x.sortKey),t.symbolInstances.emplaceBack(e.x,e.y,V.x,V.y,V.z,U.right>=0?U.right:-1,U.center>=0?U.center:-1,U.left>=0?U.left:-1,U.vertical>=0?U.vertical:-1,F,N,j,void 0!==A?A:t.collisionBoxArray.length,void 0!==A?A+1:t.collisionBoxArray.length,void 0!==L?L:t.collisionBoxArray.length,void 0!==L?L+1:t.collisionBoxArray.length,void 0!==I?I:t.collisionBoxArray.length,void 0!==I?I+1:t.collisionBoxArray.length,P||t.collisionBoxArray.length,P?P+1:t.collisionBoxArray.length,d,O,B,z,R,Y,0,Z,q,H,0,1,1,G?1:0)}(t,a,_,s,i,n,r,z,t.layers[0],t.collisionBoxArray,e.index,e.sourceLayerIndex,t.index,S,C,l,0,E,A,g,e,o,c,d,u,p,f)};if("line"===I)for(const r of b_(e.geometry,0,0,uo,uo)){const e=v_(r,T,M,i.vertical||y,n,x,w,t.overscaling,uo);for(const i of e)y&&Q_(t,y.text,L,i)||R(r,i,u)}else if("line-center"===I){for(const t of e.geometry)if(t.length>1){const e=y_(t,M,i.vertical||y,n,x,w);e&&R(t,e,u)}}else if("Polygon"===e.type)for(const t of Zh(e.geometry,0)){const e=F_(t,16);R(t[0],new p_(e.x,e.y,0,0,void 0),u)}else if("LineString"===e.type)for(const t of e.geometry)R(t,new p_(t[0].x,t[0].y,0,0,void 0),u);else if("Point"===e.type)for(const t of e.geometry)for(const e of t)R([e],new p_(e.x,e.y,0,0,void 0),u)}const H_=255,W_=H_*Bm;function Y_(t,e,i,n,r,o,s,a,l,c,d,u,h,p,f,m,_,g){const y=function(t,e,i,n,r,o,s,a){const l=[];if(0===e.positionedLines.length)return l;const c=n.layout.get("text-rotate").evaluate(o,{})*Math.PI/180,d=function(t){const e=t[0],i=t[1],n=e*i;return n>0?[e,-i]:nW_&&pi(`${t.layerIds[0]}: Value for "text-size" is >= ${H_}. Reduce your "text-size".`)):"composite"===v.kind&&(x=[Bm*f.compositeTextSizes[0].evaluate(a,{},_),Bm*f.compositeTextSizes[1].evaluate(a,{},_)],(x[0]>W_||x[1]>W_)&&pi(`${t.layerIds[0]}: Value for "text-size" is >= ${H_}. Reduce your "text-size".`)),t.addSymbols(t.text,y,x,l,s,a,d,e,i,c.lineStartIndex,c.lineLength,p,m,_,g,!1);for(const e of u)h[e]=t.text.placedSymbolArray.length-1;return 4*y.length}function X_(t){for(const e in t)return t[e];return null}function K_(t,e,i,n,r,o,s,a,l,c){let d=s.top,u=s.bottom,h=s.left,p=s.right;const f=s.collisionPadding;if(f&&(h-=f[0],d-=f[1],p+=f[2],u+=f[3]),l){const t=new Ue(h,d),e=new Ue(p,d),i=new Ue(h,u),n=new Ue(p,u),r=Ge(l);let o=new Ue(0,0);c&&(o=new Ue(c[0],c[1])),t._rotateAround(r,o),e._rotateAround(r,o),i._rotateAround(r,o),n._rotateAround(r,o),h=Math.min(t.x,e.x,i.x,n.x),p=Math.max(t.x,e.x,i.x,n.x),d=Math.min(t.y,e.y,i.y,n.y),u=Math.max(t.y,e.y,i.y,n.y)}return t.emplaceBack(e.x,e.y,e.z,i.x,i.y,h,d,p,u,a,n,r,o),t.length-1}function J_(t){t.collisionPadding&&(t.top-=t.collisionPadding[1],t.bottom+=t.collisionPadding[3]);const e=t.bottom-t.top;return e>0?Math.max(10,e):null}function Q_(t,e,i,n){const r=t.compareText;if(e in r){const t=r[e];for(let e=t.length-1;e>=0;e--)if(n.dist(t[e])v&&(x(t,c,n,r,a,l),x(c,i,a,l,o,s))}x(u,h,n,o,r,o),x(h,p,r,o,r,s),x(p,f,r,s,n,s),x(f,u,n,s,n,o),m-=v,_-=v,g+=v,y+=v;const b=1/Math.max(g-m,y-_);return{scale:b,x:m*b,y:_*b,x2:g*b,y2:y*b,projection:e}}function ig(t,{x:e,y:i},n=0){return new Ue(((e-n)*t.scale-t.x)*uo,(i*t.scale-t.y)*uo)}const ng=t.ad.identity(new Float32Array(16));class rg{constructor(t){this.spec=t,this.name=t.name,this.wrap=!1,this.requiresDraping=!1,this.supportsWorldCopies=!1,this.supportsTerrain=!1,this.supportsFog=!1,this.supportsFreeCamera=!1,this.zAxisUnit="meters",this.isReprojectedInTileSpace=!0,this.unsupportedLayers=["custom"],this.center=[0,0],this.range=[3.5,7]}project(t,e){return{x:0,y:0,z:0}}unproject(t,e){return new pd(0,0)}projectTilePoint(t,e,i){return{x:t,y:e,z:0}}locationPoint(t,e,i=!0){return t._coordinatePoint(t.locationCoordinate(e),i)}pixelsPerMeter(t,e){return Cd(1,t)*e}pixelSpaceConversion(t,e,i){return 1}farthestPixelDistance(t){return tg(t,t.pixelsPerMeter)}pointCoordinate(t,e,i,n){const r=t.horizonLineFromTop(!1),o=new Ue(e,Math.max(r,i));return t.rayIntersectionCoordinate(t.pointRayIntersection(o,n))}pointCoordinate3D(t,e,i){const n=new Ue(e,i);if(t.elevation)return t.elevation.pointCoordinate(n);{const e=this.pointCoordinate(t,n.x,n.y,0);return[e.x,e.y,e.z]}}isPointAboveHorizon(t,e){if(t.elevation&&t.elevation.visibleDemTiles.length)return!this.pointCoordinate3D(t,e.x,e.y);const i=t.horizonLineFromTop();return e.y0?epg-i&&(e=pg-i);const o=r/Math.pow(fg(e),n);let s=o*Math.sin(n*t),a=r-o*Math.cos(n*t);return s=.5*(s/Math.PI+.5),a=.5*(a/Math.PI+.5),{x:s,y:this.southernCenter?a:1-a,z:0}}unproject(t,e){t=(2*t-.5)*Math.PI,this.southernCenter&&(e=1-e),e=(2*(1-e)-.5)*Math.PI;const{n:i,f:n}=this,r=n-e,o=Math.sign(r),s=Math.sign(i)*Math.sqrt(t*t+r*r);let a=Math.atan2(t,Math.abs(r))*o;r*i1e-6&&--n>0);o=i*i;const s=Xe(Ze(t/(.8707+o*(o*(o*o*o*(.003971-.001529*o)-.013791)-.131979))),-180,180),a=Ze(i);return new pd(s,a)}}const vg=Ge(Pd);class xg extends rg{project(t,e){e=Ge(e),t=Ge(t);const i=Math.cos(e),n=2/Math.PI,r=Math.acos(i*Math.cos(t/2)),o=Math.sin(r)/r,s=.5*(t*n+2*i*Math.sin(t/2)/o)||0,a=.5*(e+Math.sin(e)/o)||0;return{x:.5*(s/Math.PI+.5),y:1-.5*(a/Math.PI+1),z:0}}unproject(t,e){let i=t=(2*t-.5)*Math.PI,n=e=(2*(1-e)-1)*Math.PI,r=25;const o=1e-6;let s=0,a=0;do{const r=Math.cos(n),o=Math.sin(n),l=2*o*r,c=o*o,d=r*r,u=Math.cos(i/2),h=Math.sin(i/2),p=2*u*h,f=h*h,m=1-d*u*u,_=m?1/m:0,g=m?Math.acos(r*u)*Math.sqrt(1/m):0,y=.5*(2*g*r*h+2*i/Math.PI)-t,v=.5*(g*o+n)-e,x=.5*_*(d*f+g*r*u*c)+1/Math.PI,b=_*(p*l/4-g*o*h),w=.125*_*(l*h-g*o*d*p),T=.5*_*(c*u+g*f*r)+.5,S=b*w-T*x;s=(v*b-y*T)/S,a=(y*w-v*x)/S,i=Xe(i-s,-Math.PI,Math.PI),n=Xe(n-a,-vg,vg)}while((Math.abs(s)>o||Math.abs(a)>o)&&--r>0);return new pd(Ze(i),Ze(n))}}class bg extends rg{constructor(t){super(t),this.center=t.center||[0,0],this.parallels=t.parallels||[0,0],this.cosPhi=Math.max(.01,Math.cos(Ge(this.parallels[0]))),this.scale=1/(2*Math.max(Math.PI*this.cosPhi,1/this.cosPhi)),this.wrap=!0,this.supportsWorldCopies=!0}project(t,e){const{scale:i,cosPhi:n}=this;return{x:Ge(t)*n*i+.5,y:-Math.sin(Ge(e))/n*i+.5,z:0}}unproject(t,e){const{scale:i,cosPhi:n}=this,r=-(e-.5)/i,o=Xe(Ze((t-.5)/i)/n,-180,180),s=Math.asin(Xe(r*n,-1,1)),a=Xe(Ze(s),-Pd,Pd);return new pd(o,a)}}class wg extends _g{constructor(t){super(t),this.requiresDraping=!0,this.supportsWorldCopies=!1,this.supportsFog=!0,this.zAxisUnit="pixels",this.unsupportedLayers=["debug"],this.range=[3,5]}projectTilePoint(e,i,n){const r=Fu(e,i,n),o=ju($u(n));return t._.transformMat4(r,r,o),{x:r[0],y:r[1],z:r[2]}}locationPoint(e,i){const n=dd(i.lat,i.lng),r=t._.normalize([],n),o=e.elevation?e.elevation.getAtPointOrZero(e.locationCoordinate(i),e._centerAltitude):e._centerAltitude,s=Cd(1,0)*uo*o;t._.scaleAndAdd(n,n,r,s);const a=t.ad.identity(new Float64Array(16));return t.ad.multiply(a,e.pixelMatrix,e.globeMatrix),t._.transformMat4(n,n,a),new Ue(n[0],n[1])}pixelsPerMeter(t,e){return Cd(1,0)*e}pixelSpaceConversion(t,e,i){const n=Cd(1,t)*e,r=Vn(Cd(1,45)*e,n,i);return this.pixelsPerMeter(t,e)/r}createTileMatrix(e,i,n){const r=Vu($u(n.canonical));return t.ad.multiply(new Float64Array(16),e.globeMatrix,r)}createInversionMatrix(e,i){const{center:n}=e,r=ju($u(i));return t.ad.rotateY(r,r,Ge(n.lng)),t.ad.rotateX(r,r,Ge(n.lat)),t.ad.scale(r,r,[e._pixelsPerMercatorPixel,e._pixelsPerMercatorPixel,1]),Float32Array.from(r)}pointCoordinate(t,e,i,n){return Iu(t,e,i,!0)||new Rd(0,0)}pointCoordinate3D(t,e,i){const n=this.pointCoordinate(t,e,i,0);return[n.x,n.y,n.z]}isPointAboveHorizon(t,e){return!Iu(t,e.x,e.y,!1)}farthestPixelDistance(e){const i=function(e,i){const n=e.cameraToCenterDistance,r=e._centerAltitude*i,o=e._camera,s=e._camera.forward(),a=t._.add([],t._.scale([],s,-n),[0,0,r]),l=e.worldSize/(2*Math.PI),c=[0,0,-l],d=e.width/e.height,u=Math.tan(e.fovAboveCenter),h=t._.scale([],o.up(),u),p=t._.scale([],o.right(),u*d),f=t._.normalize([],t._.add([],t._.add([],s,h),p)),m=[];let _;if(new mu(a,f).closestPointOnSphere(c,l,m)){const i=t._.add([],m,c),n=t._.sub([],i,a);_=Math.cos(e.fovAboveCenter)*t._.length(n)}else{const e=t._.sub([],a,c),i=t._.sub([],c,a);t._.normalize(i,i);const n=t._.length(e)-l;_=Math.sqrt(n*(n+2*l));const r=Math.acos(_/(l+n))-Math.acos(t._.dot(s,i));_*=Math.cos(r)}return 1.01*_}(e,this.pixelsPerMeter(e.center.lat,e.worldSize)),n=Hu(e.zoom);if(n>0){const t=tg(e,Cd(1,e.center.lat)*e.worldSize),r=e.worldSize/(2*Math.PI),o=Math.max(e.width,e.height)/e.worldSize*Math.PI;return Vn(i,t+r*(1-Math.cos(o)),Math.pow(n,10))}return i}upVector(t,e,i){return Fu(e,i,t,1)}upVectorScale(t){return{metersToTile:Cu(Nu($u(t)))}}}function Tg(t){const e=t.parallels,i=!!e&&Math.abs(e[0]+e[1])0&&(this.iconTransitioningVertexBuffer=t.createVertexBuffer(this.iconTransitioningVertexArray,Vf.members,!0)),this.globeExtVertexArray.length>0&&(this.globeExtVertexBuffer=t.createVertexBuffer(this.globeExtVertexArray,Ff.members,!0)),!this.zOffsetVertexBuffer&&(this.zOffsetVertexArray.length>0||r)&&(this.zOffsetVertexBuffer=t.createVertexBuffer(this.zOffsetVertexArray,jf.members,!0)),this.opacityVertexBuffer.itemSize=1),(i||n)&&this.programConfigurations.upload(t))}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy(),this.dynamicLayoutVertexBuffer.destroy(),this.opacityVertexBuffer.destroy(),this.occlusionQueryOpacityVertexBuffer.destroy(),this.iconTransitioningVertexBuffer&&this.iconTransitioningVertexBuffer.destroy(),this.globeExtVertexBuffer&&this.globeExtVertexBuffer.destroy(),this.zOffsetVertexBuffer&&this.zOffsetVertexBuffer.destroy())}}ba(Ng,"SymbolBuffers");class Ug{constructor(t,e,i){this.layoutVertexArray=new t,this.layoutAttributes=e,this.indexArray=new i,this.segments=new wc,this.collisionVertexArray=new Xl,this.collisionVertexArrayExt=new Ol}upload(t){this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,this.layoutAttributes),this.indexBuffer=t.createIndexBuffer(this.indexArray),this.collisionVertexBuffer=t.createVertexBuffer(this.collisionVertexArray,Gf.members,!0),this.collisionVertexBufferExt=t.createVertexBuffer(this.collisionVertexArrayExt,Zf.members,!0)}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.segments.destroy(),this.collisionVertexBuffer.destroy(),this.collisionVertexBufferExt.destroy())}}ba(Ug,"CollisionBuffers");class jg{constructor(e){this.queries=new Map,this.collisionBoxArray=e.collisionBoxArray,this.zoom=e.zoom,this.lut=e.lut,this.overscaling=e.overscaling,this.layers=e.layers,this.layerIds=this.layers.map((t=>t.fqid)),this.index=e.index,this.pixelRatio=e.pixelRatio,this.sourceLayerIndex=e.sourceLayerIndex,this.hasPattern=!1,this.hasRTLText=!1,this.fullyClipped=!1,this.hasAnyIconTextFit=!1,this.sortKeyRanges=[],this.collisionCircleArray=[],this.placementInvProjMatrix=t.ad.identity([]),this.placementViewportMatrix=t.ad.identity([]);const i=this.layers[0]._unevaluatedLayout._values;this.textSizeData=Fm(this.zoom,i["text-size"]),this.iconSizeData=Fm(this.zoom,i["icon-size"]);const n=this.layers[0].layout,r=n.get("symbol-sort-key"),o=n.get("symbol-z-order");this.canOverlap=n.get("text-allow-overlap")||n.get("icon-allow-overlap")||n.get("text-ignore-placement")||n.get("icon-ignore-placement"),this.sortFeaturesByKey="viewport-y"!==o&&void 0!==r.constantOr(1),this.sortFeaturesByY=("viewport-y"===o||"auto"===o&&!this.sortFeaturesByKey)&&this.canOverlap,this.writingModes=n.get("text-writing-mode").map((t=>Jm[t])),this.stateDependentLayerIds=this.layers.filter((t=>t.isStateDependent())).map((t=>t.id)),this.sourceID=e.sourceID,this.projection=e.projection,this.hasAnyZOffset=!1,this.zOffsetSortDirty=!1,this.zOffsetBuffersNeedUpload=n.get("symbol-z-elevate"),this.activeReplacements=[],this.replacementUpdateTime=0}createArrays(){this.text=new Ng(new Yc(this.layers,{zoom:this.zoom,lut:this.lut},(t=>/^text/.test(t)))),this.icon=new Ng(new Yc(this.layers,{zoom:this.zoom,lut:this.lut},(t=>/^icon/.test(t)))),this.glyphOffsetArray=new mc,this.lineVertexArray=new _c,this.symbolInstances=new fc}calculateGlyphDependencies(t,e,i,n,r){for(let i=0;i0)&&("constant"!==l.value.kind||l.value.value.length>0),h="constant"!==d.value.kind||!!d.value.value||Object.keys(d.parameters).length>0,p=s.get("symbol-sort-key");if(this.features=[],!u&&!h)return;const f=i.iconDependencies,m=i.glyphDependencies,_=i.availableImages,g=new Ha(this.zoom);for(const{feature:i,id:c,index:d,sourceLayerIndex:y}of e){const e=o._featureFilter.needGeometry,v=Zd(i,e);if(!o._featureFilter.filter(g,v,n))continue;if(e||(v.geometry=Gd(i,n,r)),a&&1!==i.type&&n.z{const o=Fu(e.x,e.y,n,1),s=Fu(r.x,r.y,n,1);return t._.dot(o,s)=0;for(const i of x.sections)if(i.image)f[i.image.namePrimary]=!0;else{const n=Ca(x.toString()),r=i.fontStack||t,o=m[r]=m[r]||{};this.calculateGlyphDependencies(i.text,o,e,this.allowVerticalPlacement,n)}}}"line"===s.get("symbol-placement")&&(this.features=function(t){const e={},i={},n=[];let r=0;function o(e){n.push(t[e]),r++}function s(t,e,r){const o=i[t];return delete i[t],i[e]=o,n[o].geometry[0].pop(),n[o].geometry[0]=n[o].geometry[0].concat(r[0]),o}function a(t,i,r){const o=e[i];return delete e[i],e[t]=o,n[o].geometry[0].shift(),n[o].geometry[0]=r[0].concat(n[o].geometry[0]),o}function l(t,e,i){const n=i?e[0][e[0].length-1]:e[0][0];return`${t}:${n.x}:${n.y}`}for(let c=0;ct.geometry))}(this.features)),this.sortFeaturesByKey&&this.features.sort(((t,e)=>t.sortKey-e.sortKey))}update(t,e,i,n,r){const o=0!==Object.keys(t).length;if(o&&!this.stateDependentLayers.length)return;const s=o?this.stateDependentLayers:this.layers;this.text.programConfigurations.updatePaintArrays(t,e,s,i,n,r),this.icon.programConfigurations.updatePaintArrays(t,e,s,i,n,r)}updateOcclusionOpacities(t,e,i){if(!e.useOcclusionQueries)return!1;const n=this;if("globe"===n.projection.name)return!1;let r=!1;n.hasTextData()&&(r=r||0!==n.text.occlusionQueryOpacityVertexArray.length),n.hasIconData()&&(r=r||0!==n.icon.occlusionQueryOpacityVertexArray.length);const o=n.layers[0].paint,s=o.get("icon-occlusion-opacity").constantOr(0),a=o.get("text-occlusion-opacity").constantOr(0);if(!n.layers[0].hasInitialOcclusionOpacityProperties||1===s&&1===a)return!1;let l=!r;for(let t=0;t.5?1:-1)*e.fadeSpeed*i*.001,r.occlusionOpacity=Xe(r.occlusionOpacity,0,1),l=l||r.occlusionOpacity!==o}if(!l)return!1;let c=0,d=0;const u=(t,e,i,n)=>{let r=0,o=0;i?(r=d,d+=n,o=d):(r=c,c+=n,o=c),o>e.occlusionQueryOpacityVertexArray.length&&e.occlusionQueryOpacityVertexArray.resize(o);const s=t.occlusionOpacity;for(let t=0;t0;if((i>0||r>0)&&(u(e,n.text,!1,i),u(e,n.text,!1,r)),s){const{placedIconSymbolIndex:t,verticalPlacedIconSymbolIndex:i}=e;t>=0&&u(e,n.icon,!0,o),i>=0&&u(e,n.icon,!0,e.numVerticalIconVertices)}}return n.hasTextData()&&n.text.occlusionQueryOpacityVertexBuffer&&(n.text.occlusionQueryOpacityVertexBuffer.length{i+=e,i>t.length&&t.resize(i);for(let r=-e;r{n+=e,n>t.length&&t.resize(n);for(let r=-e;r0;if((r>0||o>0)&&(t(this.text.zOffsetVertexArray,r,a),t(this.text.zOffsetVertexArray,o,a)),l){const{placedIconSymbolIndex:t,verticalPlacedIconSymbolIndex:i}=n;t>=0&&e(this.icon.zOffsetVertexArray,s,a),i>=0&&e(this.icon.zOffsetVertexArray,n.numVerticalIconVertices,a)}}this.text.zOffsetVertexBuffer&&this.text.zOffsetVertexBuffer.updateData(this.text.zOffsetVertexArray),this.icon.zOffsetVertexBuffer&&this.icon.zOffsetVertexBuffer.updateData(this.icon.zOffsetVertexArray)}isEmpty(){return 0===this.symbolInstances.length&&!this.hasRTLText}uploadPending(){return!this.uploaded||this.text.programConfigurations.needsUpload||this.icon.programConfigurations.needsUpload}upload(t){!this.uploaded&&this.hasDebugData()&&(this.textCollisionBox.upload(t),this.iconCollisionBox.upload(t)),this.text.upload(t,this.sortFeaturesByY,!this.uploaded,this.text.programConfigurations.needsUpload,this.zOffsetBuffersNeedUpload),this.icon.upload(t,this.sortFeaturesByY,!this.uploaded,this.icon.programConfigurations.needsUpload,this.zOffsetBuffersNeedUpload),this.uploaded=!0}destroyDebugData(){this.textCollisionBox.destroy(),this.iconCollisionBox.destroy()}getProjection(){return this.projectionInstance||(this.projectionInstance=Tg(this.projection)),this.projectionInstance}destroy(){this.text.destroy(),this.icon.destroy(),this.hasDebugData()&&this.destroyDebugData();for(const t of this.queries.values())t.destroy()}addToLineVertexArray(t,e){const i=this.lineVertexArray.length;if(void 0!==t.segment)for(const{x:t,y:i}of e)this.lineVertexArray.emplaceBack(t,i);return{lineStartIndex:i,lineLength:this.lineVertexArray.length-i}}addSymbols(t,e,i,n,r,o,s,a,l,c,d,u,h,p,f,m){const _=t.indexArray,g=t.layoutVertexArray,y=t.globeExtVertexArray,v=t.segments.prepareSegment(4*e.length,g,_,this.canOverlap?o.sortKey:void 0),x=this.glyphOffsetArray.length,b=v.vertexLength,w=this.allowVerticalPlacement&&s===Jm.vertical?Math.PI/2:0,T=o.text&&o.text.sections;for(let n=0;n=0?e.rightJustifiedTextSymbolIndex:e.centerJustifiedTextSymbolIndex>=0?e.centerJustifiedTextSymbolIndex:e.leftJustifiedTextSymbolIndex>=0?e.leftJustifiedTextSymbolIndex:e.verticalPlacedTextSymbolIndex>=0?e.verticalPlacedTextSymbolIndex:n),o=Nm(this.textSizeData,t,r)/Om;return this.tilePixelRatio*o}getSymbolInstanceIconSize(t,e,i){const n=this.icon.placedSymbolArray.get(i),r=Nm(this.iconSizeData,t,n);return this.tilePixelRatio*r}_commitDebugCollisionVertexUpdate(t,e,i,n){t.emplaceBack(e,-i,-i,n),t.emplaceBack(e,i,-i,n),t.emplaceBack(e,i,i,n),t.emplaceBack(e,-i,i,n)}_updateTextDebugCollisionBoxes(t,e,i,n,r,o){for(let s=n;s0}hasIconData(){return this.icon.segments.get().length>0}hasDebugData(){return this.textCollisionBox&&this.iconCollisionBox}hasTextCollisionBoxData(){return this.hasDebugData()&&this.textCollisionBox.segments.get().length>0}hasIconCollisionBoxData(){return this.hasDebugData()&&this.iconCollisionBox.segments.get().length>0}hasIconTextFit(){return this.hasAnyIconTextFit}addIndicesForPlacedSymbol(t,e){const i=t.placedSymbolArray.get(e),n=i.vertexStartIndex+4*i.numGlyphs;for(let e=i.vertexStartIndex;en[t]-n[e]||r[e]-r[t])),o}getSortedIndexesByZOffset(){if(!this.zOffsetSortDirty)return this.symbolInstanceIndexesSortedZOffset;if(!this.symbolInstanceIndexesSortedZOffset){this.symbolInstanceIndexesSortedZOffset=[];for(let t=0;tthis.symbolInstances.get(e).zOffset-this.symbolInstances.get(t).zOffset))}addToSortKeyRanges(t,e){const i=this.sortKeyRanges[this.sortKeyRanges.length-1];i&&i.sortKey===e?i.symbolInstanceEnd=t+1:this.sortKeyRanges.push({sortKey:e,symbolInstanceStart:t,symbolInstanceEnd:t+1})}sortFeatures(t){if(this.sortFeaturesByY&&this.sortedAngle!==t&&!(this.text.segments.get().length>1||this.icon.segments.get().length>1)){this.symbolInstanceIndexes=this.getSortedSymbolIndexes(t),this.sortedAngle=t,this.text.indexArray.clear(),this.icon.indexArray.clear(),this.featureSortOrder=[];for(const t of this.symbolInstanceIndexes){const e=this.symbolInstances.get(t);this.featureSortOrder.push(e.featureIndex);const{rightJustifiedTextSymbolIndex:i,centerJustifiedTextSymbolIndex:n,leftJustifiedTextSymbolIndex:r,verticalPlacedTextSymbolIndex:o,placedIconSymbolIndex:s,verticalPlacedIconSymbolIndex:a}=e;i>=0&&this.addIndicesForPlacedSymbol(this.text,i),n>=0&&n!==i&&this.addIndicesForPlacedSymbol(this.text,n),r>=0&&r!==n&&r!==i&&this.addIndicesForPlacedSymbol(this.text,r),o>=0&&this.addIndicesForPlacedSymbol(this.text,o),s>=0&&this.addIndicesForPlacedSymbol(this.icon,s),a>=0&&this.addIndicesForPlacedSymbol(this.icon,a)}this.text.indexBuffer&&this.text.indexBuffer.updateData(this.text.indexArray),this.icon.indexBuffer&&this.icon.indexBuffer.updateData(this.icon.indexArray)}}}ba(jg,"SymbolBucket",{omit:["layers","collisionBoxArray","features","compareText"]}),jg.addDynamicAttributes=Bg;class Vg{constructor(t,e,i,n){this.context=t,this.format=i,this.texture=t.gl.createTexture(),this.update(e,n)}update(t,e,i){const{width:n,height:r}=t,{context:o}=this,{gl:s}=o;if(s.bindTexture(s.TEXTURE_2D,this.texture),o.pixelStoreUnpackFlipY.set(!1),o.pixelStoreUnpack.set(1),o.pixelStoreUnpackPremultiplyAlpha.set(this.format===s.RGBA&&(!e||!1!==e.premultiply)),this.useMipmap=Boolean(e&&e.useMipmap),i||this.size&&this.size[0]===n&&this.size[1]===r){const{x:e,y:o}=i||{x:0,y:0};if(t instanceof HTMLImageElement||t instanceof HTMLCanvasElement||t instanceof HTMLVideoElement||t instanceof ImageData||ImageBitmap&&t instanceof ImageBitmap)s.texSubImage2D(s.TEXTURE_2D,0,e,o,s.RGBA,s.UNSIGNED_BYTE,t);else{let i=this.format,a=s.UNSIGNED_BYTE;this.format===s.R32F&&(i=s.RED,a=s.FLOAT),s.texSubImage2D(s.TEXTURE_2D,0,e,o,n,r,i,a,t.data)}}else if(this.size=[n,r],t instanceof HTMLImageElement||t instanceof HTMLCanvasElement||t instanceof HTMLVideoElement||t instanceof ImageData||ImageBitmap&&t instanceof ImageBitmap){let e=this.format;this.format===s.R8&&(e=s.RED),s.texImage2D(s.TEXTURE_2D,0,this.format,e,s.UNSIGNED_BYTE,t)}else{let e=this.format,i=this.format,o=s.UNSIGNED_BYTE,a=!1;this.format===s.DEPTH_COMPONENT&&(e=s.DEPTH_COMPONENT16,o=s.UNSIGNED_SHORT),this.format===s.DEPTH_STENCIL&&(e=s.DEPTH24_STENCIL8,o=s.UNSIGNED_INT_24_8,a=!0),this.format===s.R8&&(i=s.RED),this.format===s.R32F&&(o=s.FLOAT,i=s.RED),!this.useMipmap&&a?s.texStorage2D(s.TEXTURE_2D,1,e,n,r):s.texImage2D(s.TEXTURE_2D,0,e,n,r,0,i,o,t.data)}this.useMipmap&&s.generateMipmap(s.TEXTURE_2D)}bind(t,e,i=!1){const{context:n}=this,{gl:r}=n;r.bindTexture(r.TEXTURE_2D,this.texture),t!==this.minFilter&&(r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MAG_FILTER,t),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MIN_FILTER,this.useMipmap&&!i?t===r.NEAREST?r.NEAREST_MIPMAP_NEAREST:r.LINEAR_MIPMAP_LINEAR:t),this.minFilter=t),e!==this.wrapS&&(r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_S,e),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_T,e),this.wrapS=e)}bindExtraParam(t,e,i,n){const{context:r}=this,{gl:o}=r;o.bindTexture(o.TEXTURE_2D,this.texture),e!==this.magFilter&&(o.texParameteri(o.TEXTURE_2D,o.TEXTURE_MAG_FILTER,e),this.magFilter=e),t!==this.minFilter&&(o.texParameteri(o.TEXTURE_2D,o.TEXTURE_MIN_FILTER,this.useMipmap?t===o.NEAREST?o.NEAREST_MIPMAP_NEAREST:o.LINEAR_MIPMAP_LINEAR:t),this.minFilter=t),i!==this.wrapS&&(o.texParameteri(o.TEXTURE_2D,o.TEXTURE_WRAP_S,i),this.wrapS=i),n!==this.wrapT&&(o.texParameteri(o.TEXTURE_2D,o.TEXTURE_WRAP_T,n),this.wrapT=n)}destroy(){const{gl:t}=this.context;t.deleteTexture(this.texture),this.texture=null}}class Gg{constructor(t,e){this.context=t,this.texture=e}bind(t,e){const{context:i}=this,{gl:n}=i;n.bindTexture(n.TEXTURE_2D,this.texture),t!==this.minFilter&&(n.texParameteri(n.TEXTURE_2D,n.TEXTURE_MAG_FILTER,t),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_MIN_FILTER,t),this.minFilter=t),e!==this.wrapS&&(n.texParameteri(n.TEXTURE_2D,n.TEXTURE_WRAP_S,e),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_WRAP_T,e),this.wrapS=e)}}const Zg=32,qg=33,Hg=new Uint16Array(8184);for(let t=0;t>=1)>1;){const t=i+r>>1,l=n+o>>1;1&e?(r=i,o=n,i=s,n=a):(i=r,n=o,r=s,o=a),s=t,a=l}const l=4*t;Hg[l+0]=i,Hg[l+1]=n,Hg[l+2]=r,Hg[l+3]=o}const Wg=new Uint16Array(2178),Yg=new Uint8Array(1089),Xg=new Uint16Array(1089);function Kg(t){return 0===t?-.03125:32===t?.03125:0}var Jg=Ll([{name:"a_pos",type:"Int16",components:2},{name:"a_texture_pos",type:"Int16",components:2}]),Qg=Ll([{name:"a_index",type:"Int16",components:1}]);const ty={type:2,extent:uo,loadGeometry:()=>[[new Ue(0,0),new Ue(uo+1,0),new Ue(uo+1,uo+1),new Ue(0,uo+1),new Ue(0,0)]]};class ey{constructor(t,e,i,n,r){this.tileID=t,this.uid=ni(),this.uses=0,this.tileSize=e,this.tileZoom=i,this.buckets={},this.expirationTime=null,this.queryPadding=0,this.hasSymbolBuckets=!1,this.hasRTLText=!1,this.dependencies={},this.isRaster=r,n&&n.style&&(this._lastUpdatedBrightness=n.style.getBrightness()),this.expiredRequestCount=0,this.state="loading",n&&n.transform&&(this.projection=n.transform.projection)}registerFadeDuration(t){const e=t+this.timeAdded;ee.getLayer(t))).filter(Boolean);if(0!==t.length){n.layers=t,n.stateDependentLayerIds&&(n.stateDependentLayers=n.stateDependentLayerIds.map((e=>t.filter((t=>t.id===e))[0])));for(const e of t)i[e.fqid]=n}}return i}(t.buckets,e.style),this.hasSymbolBuckets=!1;for(const t in this.buckets){const e=this.buckets[t];if(e instanceof jg){if(this.hasSymbolBuckets=!0,!i)break;e.justReloaded=!0}}if(this.hasRTLText=!1,this.hasSymbolBuckets)for(const t in this.buckets){const e=this.buckets[t];if(e instanceof jg&&e.hasRTLText){this.hasRTLText=!0,qa.isLoading()||qa.isLoaded()||"deferred"!==Ga()||Za();break}}this.queryPadding=0;for(const t in this.buckets){const i=this.buckets[t],n=e.style.getOwnLayer(t);if(!n)continue;const r=n.queryRadius(i);this.queryPadding=Math.max(this.queryPadding,r)}t.imageAtlas&&(this.imageAtlas=t.imageAtlas),t.glyphAtlasImage&&(this.glyphAtlasImage=t.glyphAtlasImage),t.lineAtlas&&(this.lineAtlas=t.lineAtlas),this._lastUpdatedBrightness=t.brightness}else this.collisionBoxArray=new dc}unloadVectorData(){if(this.hasData()){for(const t in this.buckets)this.buckets[t].destroy();this.buckets={},this.imageAtlas&&(this.imageAtlas=null),this.lineAtlas&&(this.lineAtlas=null),this.imageAtlasTexture&&this.imageAtlasTexture.destroy(),this.glyphAtlasTexture&&this.glyphAtlasTexture.destroy(),this.lineAtlasTexture&&this.lineAtlasTexture.destroy(),this._tileBoundsBuffer&&(this._tileBoundsBuffer.destroy(),this._tileBoundsIndexBuffer.destroy(),this._tileBoundsSegments.destroy(),this._tileBoundsBuffer=null),this._tileDebugBuffer&&(this._tileDebugBuffer.destroy(),this._tileDebugSegments.destroy(),this._tileDebugBuffer=null),this._tileDebugIndexBuffer&&(this._tileDebugIndexBuffer.destroy(),this._tileDebugIndexBuffer=null),this._globeTileDebugBorderBuffer&&(this._globeTileDebugBorderBuffer.destroy(),this._globeTileDebugBorderBuffer=null),this._tileDebugTextBuffer&&(this._tileDebugTextBuffer.destroy(),this._tileDebugTextSegments.destroy(),this._tileDebugTextIndexBuffer.destroy(),this._tileDebugTextBuffer=null),this._globeTileDebugTextBuffer&&(this._globeTileDebugTextBuffer.destroy(),this._globeTileDebugTextBuffer=null),this.latestFeatureIndex=null,this.state="unloaded"}}getBucket(t){return this.buckets[t.fqid]}upload(t){for(const e in this.buckets){const i=this.buckets[e];i.uploadPending()&&i.upload(t)}const e=t.gl,i=this.imageAtlas;if(i&&!i.uploaded){const n=!!Object.keys(i.patternPositions).length;this.imageAtlasTexture=new Vg(t,i.image,e.RGBA,{useMipmap:n}),this.imageAtlas.uploaded=!0}this.glyphAtlasImage&&(this.glyphAtlasTexture=new Vg(t,this.glyphAtlasImage,e.R8),this.glyphAtlasImage=null),this.lineAtlas&&!this.lineAtlas.uploaded&&(this.lineAtlasTexture=new Vg(t,this.lineAtlas.image,e.R8),this.lineAtlas.uploaded=!0)}prepare(t,e,i){if(this.imageAtlas&&this.imageAtlasTexture&&this.imageAtlas.patchUpdatedImages(t,this.imageAtlasTexture,i),!e||!this.latestFeatureIndex||!this.latestFeatureIndex.rawTileData)return;const n=e.style.getBrightness();(this._lastUpdatedBrightness||n)&&(this._lastUpdatedBrightness&&n&&Math.abs(this._lastUpdatedBrightness-n)t)i=!1;else if(e)if(this.expirationTime=0;t--){const e=4*t,i=Hg[e+0],n=Hg[e+1],r=Hg[e+2],o=Hg[e+3],s=i+r>>1,a=n+o>>1,l=s+a-n,c=a+i-s,d=n*qg+i,u=o*qg+r,h=a*qg+s,p=Math.hypot((Wg[2*d+0]+Wg[2*u+0])/2-Wg[2*h+0],(Wg[2*d+1]+Wg[2*u+1])/2-Wg[2*h+1])>=16;Yg[h]=Yg[h]||(p?1:0),t>1)*qg+(i+l>>1)]||Yg[(o+c>>1)*qg+(r+l>>1)])}const r=new Dl,o=new Kl;let s=0;function a(t,e){const i=e*qg+t;return 0===Xg[i]&&(r.emplaceBack(Wg[2*i+0],Wg[2*i+1],t*uo/Zg,e*uo/Zg),Xg[i]=++s),Xg[i]-1}function l(t,e,i,n,r,s){const c=t+i>>1,d=e+n>>1;if(Math.abs(t-r)+Math.abs(e-s)>1&&Yg[d*qg+c])l(r,s,t,e,c,d),l(i,n,r,s,c,d);else{const l=a(t,e),c=a(i,n),d=a(r,s);o.emplaceBack(l,c,d)}}return l(0,0,Zg,Zg,Zg,0),l(Zg,Zg,0,0,0,Zg),{vertices:r,indices:o}}(this.tileID.canonical,e);n=t.vertices,r=t.indices}else{n=new Dl,r=new Kl;for(const{x:t,y:e}of i)n.emplaceBack(t,e,0,0);const t=xh(n.int16,void 0,4);for(let e=0;e0&&(a=t.ad.invert(new Float64Array(16),i.globeMatrix)),this._makeGlobeTileDebugBorderBuffer(e,r,i,o,a,s),this._makeGlobeTileDebugTextBuffer(e,r,i,o,a,s)}_globePoint(e,i,n,r,o,s,a){let l=Fu(e,i,n);if(s){const o=1.5?h=-1:u{const p=(d-t)/(h-1),f=(u-c)/(h-1),m=s.length;for(let d=0;dd*t+e;for(let t=0;t[t,this.get(t)]))}evict(t=!1){if(t||this.size>0){const t=this.first;delete this.items[t.key],0==--this.size?(this.first=null,this.last=null):(this.first=t.next,this.first.prev=null)}return this}expiresAt(t){let e;return this.has(t)&&(e=this.items[t].expiry),e}get(t){let e;if(this.has(t)){const i=this.items[t];this.ttl>0&&i.expiry0?Date.now()+this.ttl:this.ttl),this.last!==r){const t=this.last,e=r.next,i=r.prev;this.first===r&&(this.first=r.next),r.next=null,r.prev=this.last,t.next=r,null!==i&&(i.next=e),null!==e&&(e.prev=i)}}else this.max>0&&this.size===this.max&&this.evict(!0),r=this.items[t]={expiry:this.ttl>0?Date.now()+this.ttl:this.ttl,key:t,prev:this.last,next:null,value:e},1==++this.size?this.first=r:this.last.next=r;return this.last=r,this}values(t=this.keys()){return t.map((t=>this.get(t)))}}function uy(t,e){if(4!==e.length)throw new Error(`Expected data of dimension 4 but got ${e.length}.`);let i=e[3];for(let n=2;n>=1;n--){const r=1===n?1:0,o=2===n?1:0;for(let n=0;n>>1^-(1&t[e]);return t}function py(t,e){switch(e){case"uint32":return t;case"uint16":for(let e=0;e>4|(61440&i)>>8|(240&n)>4|(15&n)>6|(192&n)>>4|(192&r)>>2|192&o,t[e+1]=(48&i)>>4|(48&n)>>2|48&r|(48&o)>2|12&n|(12&r)>1|(21845&Cy)>2|(13107&Ay)>4|(3855&Ay)>8|(255&Ay)>1}var Iy=function(t,e,i){for(var n=t.length,r=0,o=new _y(e);r>l]=c}else for(s=new _y(n),r=0;r>15-t[r]);return s},Ly=new my(288);for(Cy=0;Cye&&(e=t[i]);return e},zy=function(t,e,i){var n=e/8|0;return(t[n]|t[n+1]>(7&e)&i},Ry=function(t,e){var i=e/8|0;return(t[i]|t[i+1]>(7&e)},Oy=["unexpected EOF","invalid block type","invalid length/literal","invalid distance","stream finished","no stream handler",,"no callback","invalid UTF-8 data","extra field too long","date not in range 1980-2099","filename too long","stream finishing","invalid zip data"],By=function(t,e,i){var n=new Error(e||Oy[t]);if(n.code=t,Error.captureStackTrace&&Error.captureStackTrace(n,By),!i)throw n;return n},Fy=new my(0),Ny="undefined"!=typeof TextDecoder&&new TextDecoder;try{Ny.decode(Fy,{stream:!0})}catch(t){}const Uy={gzip_data:"gzip"},jy={0:"uint32",1:"uint32",2:"uint16",3:"uint8"},Vy={uint32:1,uint16:2,uint8:4},Gy={uint32:Uint32Array,uint16:Uint16Array,uint8:Uint8Array};class Zy{constructor(t=1){this.x=NaN,this.y=NaN,this.z=NaN,this.layers={},this._cacheSize=t}getLayer(t){return this.layers[t]}getHeaderLength(t){const e=new Uint8Array(t),i=new DataView(t);if(13!==e[0])throw new fy("File is not a valid MRT.");return i.getUint32(1,!0)}parseHeader(t){const e=new Uint8Array(t),i=this.getHeaderLength(t);if(e.length= ${i} but got buffer of length ${e.length}`);const n=function(t){return t.readFields(iy,{header_length:0,x:0,y:0,z:0,layers:[]},void 0)}(new Lm(e.subarray(0,i)));if(!isNaN(this.x)&&(this.x!==n.x||this.y!==n.y||this.z!==n.z))throw new fy(`Invalid attempt to parse header ${n.z}/${n.x}/${n.y} for tile ${this.z}/${this.x}/${this.y}`);this.x=n.x,this.y=n.y,this.z=n.z;for(const t of n.layers)this.layers[t.name]=new qy(t,{cacheSize:this._cacheSize});return this}createDecodingTask(t){const e=[],i=this.getLayer(t.layerName);for(let n=0;nt.lastBlock)continue;if(i._blocksInProgress.has(n))continue;const a={layerName:i.name,firstByte:o,lastByte:s,pixelFormat:i.pixelFormat,blockIndex:n,blockShape:[r.bands.length].concat(i.bandShape),buffer:i.buffer,codec:r.codec.codec,filters:r.filters.map((t=>t.filter))};i._blocksInProgress.add(n),e.push(a)}return new Hy(e,(()=>{e.forEach((t=>i._blocksInProgress.delete(t.blockIndex)))}),((t,n)=>{if(e.forEach((t=>i._blocksInProgress.delete(t.blockIndex))),t)throw t;n.forEach((t=>{this.getLayer(t.layerName).processDecodedData(t)}))}))}}class qy{constructor({version:t,name:e,units:i,tilesize:n,pixel_format:r,buffer:o,data_index:s},a){if(this.version=t,1!==this.version)throw new fy(`Cannot parse raster layer encoded with MRT version ${t}`);this.name=e,this.units=i,this.tileSize=n,this.buffer=o,this.pixelFormat=jy[r],this.dataIndex=s,this.bandShape=[n+2*o,n+2*o,Vy[this.pixelFormat]],this._decodedBlocks=function(t=1e3,e=0,i=!1){if(isNaN(t)||t=e&&t=0}hasDataForBand(t){const{blockIndex:e}=this.getBlockForBand(t);return e>=0&&!!this._decodedBlocks.get(e.toString())}getBandView(t){const{blockIndex:e,blockBandIndex:i}=this.getBlockForBand(t),n=this._decodedBlocks.get(e.toString());if(!n)throw new fy(`Data for band ${JSON.stringify(t)} of layer "${this.name}" not decoded.`);const r=this.dataIndex[e],o=this.bandShape.reduce(((t,e)=>t*e),1),s=i*o,a=n.subarray(s,s+o);return{data:a,bytes:new Uint8Array(a.buffer).subarray(a.byteOffset,a.byteOffset+a.byteLength),tileSize:this.tileSize,buffer:this.buffer,offset:r.offset,scale:r.scale}}}class Hy{constructor(t,e,i){this.tasks=t,this._onCancel=e,this._onComplete=i,this._finalized=!1}cancel(){this._finalized||(this._onCancel(),this._finalized=!0)}complete(t,e){this._finalized||(this._onComplete(t,e),this._finalized=!0)}}Zy.performDecoding=function(t,e){return Promise.all(e.tasks.map((e=>{const{layerName:i,firstByte:n,lastByte:r,pixelFormat:o,blockShape:s,blockIndex:a,filters:l,codec:c}=e,d=new Uint8Array(t).subarray(n,r+1),u=new Uint32Array(s[0]*s[1]*s[2]);let h;if("gzip_data"!==c)throw new Error(`Unhandled codec: ${c}`);return h=function(t,e){if(!globalThis.DecompressionStream&&"gzip_data"===e)return Promise.resolve(((o=function(t){31==t[0]&&139==t[1]&&8==t[2]||By(6,"invalid gzip data");var e=t[3],i=10;4&e&&(i+=2+(t[10]|t[11]>3&1)+(e>>4&1);n>0;n-=!t[i++]);return i+(2&e)}(r=t))+8>r.length&&By(6,"invalid gzip data"),function(t,e,i){var n=t.length;if(!n||e.f&&!e.l)return i||new my(0);var r=!i,o=r||2!=e.i,s=e.i;r&&(i=new my(3*n));var a,l,c=function(t){var e=i.length;if(t>e){var n=new my(Math.max(2*e,t));n.set(i),i=n}},d=e.f||0,u=e.p||0,h=e.b||0,p=e.l,f=e.d,m=e.m,_=e.n,g=8*n;do{if(!p){d=zy(t,u,1);var y=zy(t,u+1,3);if(u+=3,!y){var v=t[(L=4+((u+7)/8|0))-4]|t[L-3]n){s&&By(0);break}o&&c(h+v),i.set(t.subarray(L,x),h),e.b=h+=v,e.p=u=8*x,e.f=d;continue}if(1==y)p=$y,f=ky,m=9,_=5;else if(2==y){var b=zy(t,u,31)+257,w=zy(t,u+10,15)+4,T=b+zy(t,u+5,31)+1;u+=14;for(var S=new my(T),E=new my(19),M=0;M>4)g){s&&By(0);break}}o&&c(h+131072);for(var R=(1>4;if((u+=15&$)>g){s&&By(0);break}if($||By(2),F264&&(N=zy(t,u,(1>4;if(U||By(3),u+=15&U,z=Ey[j],j>3){var V=vy[j];z+=Ry(t,u)&(1g){s&&By(0);break}o&&c(h+131072);var G=h+N;if(ha.length)&&(l=a.length),new my(a.subarray(0,l))):i.subarray(0,h)}(r.subarray(o,-8),{i:2},new my(((i=r)[(n=i.length)-4]|i[n-3]>>0))));var i,n,r,o;const s=Uy[e];if(!s)throw new Error(`Unhandled codec: ${e}`);const a=new globalThis.DecompressionStream(s);return new Response(new Blob([t]).stream().pipeThrough(a)).arrayBuffer().then((t=>new Uint8Array(t)))}(d,c).then((t=>(function(t,e){t.readFields(ly,e)}(new Lm(t),u),new(0,Gy[o])(u.buffer)))),h.then((t=>{for(let e=l.length-1;e>=0;e--)switch(l[e]){case"delta_filter":uy(t,s);break;case"zigzag_filter":hy(t);break;case"bitshuffle_filter":py(t,o);break;default:throw new Error(`Unhandled filter "${l[e]}"`)}return{layerName:i,blockIndex:a,data:t}})).catch((t=>{throw t}))})))};class Wy extends ey{constructor(t,e,i,n,r){super(t,e,i,n,r),this._workQueue=[],this._fetchQueue=[],this._isHeaderLoaded=!1}setTexture(t,e){const i=e.context,n=i.gl;this.texture=this.texture||e.getTileTexture(t.width),this.texture&&this.texture instanceof Vg?this.texture.update(t,{useMipmap:!1,premultiply:!1}):this.texture=new Vg(i,t,n.RGBA,{useMipmap:!1,premultiply:!1})}flushQueues(){for(;this._workQueue.length;)this._workQueue.pop()();for(;this._fetchQueue.length;)this._fetchQueue.pop()()}fetchHeader(t=16384,e){const i=this._mrt=new Zy(30),n=Object.assign({},this.requestParams,{headers:{Range:"bytes=0-"+(t-1)}});return this.entireBuffer=null,this.request=en(n,((n,r,o,s)=>{if(n)e(n);else try{const n=i.getHeaderLength(r);if(n>t)return void(this.request=this.fetchHeader(n,e));i.parseHeader(r),this._isHeaderLoaded=!0;let a=0;for(const t of Object.values(i.layers))a=Math.max(a,t.dataIndex[t.dataIndex.length-1].last_byte);r.byteLength>=a&&(this.entireBuffer=r),e(null,this.entireBuffer||r,o,s)}catch(t){e(t)}})),this.request}fetchBand(t,e,i){const n=this._mrt;if(!this._isHeaderLoaded||!n)return void i(new Error("Tile header is not ready"));const r=this.actor;if(!r)return void i(new Error("Can't fetch tile band without an actor"));let o;const s=(n,r)=>{o.complete(n,r),n?i(n):(this.updateTextureDescriptor(t,e),i(null,this.textureDescriptor&&this.textureDescriptor.img))},a=(t,e)=>{if(t)return i(t);const n=r.send("decodeRasterArray",{buffer:e,task:o},s,void 0,!0);this._workQueue.push((()=>{n&&n.cancel(),o.cancel()}))},l=n.getLayer(t);if(!l)return void i(new Error(`Unknown sourceLayer "${t}"`));if(l.hasDataForBand(e))return this.updateTextureDescriptor(t,e),void i(null,this.textureDescriptor?this.textureDescriptor.img:null);const c=l.getDataRange([e]);if(o=n.createDecodingTask(c),!o||o.tasks.length)if(this.flushQueues(),this.entireBuffer)a(null,this.entireBuffer.slice(c.firstByte,c.lastByte+1));else{const t=Object.assign({},this.requestParams,{headers:{Range:`bytes=${c.firstByte}-${c.lastByte}`}}),e=en(t,a);this._fetchQueue.push((()=>{e.cancel(),o.cancel()}))}else i(null)}updateNeeded(t,e){return(!this.textureDescriptor||this.textureDescriptor.band!==e||this.textureDescriptor.layer!==t)&&"errored"!==this.state}updateTextureDescriptor(t,e){if(!this._mrt)return;const i=this._mrt.getLayer(t);if(!i||!i.hasBand(e)||!i.hasDataForBand(e))return;const{bytes:n,tileSize:r,buffer:o,offset:s,scale:a}=i.getBandView(e),l=r+2*o,c={data:n,width:l,height:l},d=this.texture;d&&d instanceof Vg&&d.update(c,{useMipmap:!1,premultiply:!1}),this.textureDescriptor={layer:t,band:e,img:c,buffer:o,offset:s,tileSize:r,format:i.pixelFormat,mix:[a,256*a,65536*a,16777216*a]}}}class Yy{constructor(t,e){this.max=t,this.onRemove=e,this.reset()}reset(){for(const t in this.data)for(const e of this.data[t])e.timeout&&clearTimeout(e.timeout),this.onRemove(e.value);return this.data={},this.order=[],this}add(t,e,i){const n=t.wrapped().key;void 0===this.data[n]&&(this.data[n]=[]);const r={value:e,timeout:void 0};if(void 0!==i&&(r.timeout=setTimeout((()=>{this.remove(t,r)}),i)),this.data[n].push(r),this.order.push(n),this.order.length>this.max){const t=this._getAndRemoveByKey(this.order[0]);t&&this.onRemove(t)}return this}has(t){return t.wrapped().key in this.data}getAndRemove(t){return this.has(t)?this._getAndRemoveByKey(t.wrapped().key):null}_getAndRemoveByKey(t){const e=this.data[t].shift();return e.timeout&&clearTimeout(e.timeout),0===this.data[t].length&&delete this.data[t],this.order.splice(this.order.indexOf(t),1),e.value}getByKey(t){const e=this.data[t];return e?e[0].value:null}get(t){return this.has(t)?this.data[t.wrapped().key][0].value:null}remove(t,e){if(!this.has(t))return this;const i=t.wrapped().key,n=void 0===e?0:this.data[i].indexOf(e),r=this.data[i][n];return this.data[i].splice(n,1),r.timeout&&clearTimeout(r.timeout),0===this.data[i].length&&delete this.data[i],this.onRemove(r.value),this.order.splice(this.order.indexOf(i),1),this}setMaxSize(t){for(this.max=t;this.order.length>this.max;){const t=this._getAndRemoveByKey(this.order[0]);t&&this.onRemove(t)}return this}filter(t){const e=[];for(const i in this.data)for(const n of this.data[i])t(n.value)||e.push(n);for(const t of e)this.remove(t.value.tileID,t)}}class Xy extends zn{constructor(t,e,i){super(),this.id=t,this._onlySymbols=i,e.on("data",(t=>{"source"===t.dataType&&"metadata"===t.sourceDataType&&(this._sourceLoaded=!0),this._sourceLoaded&&!this._paused&&"source"===t.dataType&&"content"===t.sourceDataType&&(this.reload(),this.transform&&this.update(this.transform))})),e.on("error",(()=>{this._sourceErrored=!0})),this._source=e,this._tiles={},this._cache=new Yy(0,this._unloadTile.bind(this)),this._timers={},this._cacheTimers={},this._minTileCacheSize=e.minTileCacheSize,this._maxTileCacheSize=e.maxTileCacheSize,this._loadedParentTiles={},this.castsShadows=!1,this.tileCoverLift=0,this._coveredTiles={},this._shadowCasterTiles={},this._state=new km,this._isRaster="raster"===this._source.type||"raster-dem"===this._source.type||"raster-array"===this._source.type||"custom"===this._source.type&&"raster"===this._source._dataType}onAdd(t){this.map=t,this._minTileCacheSize=void 0===this._minTileCacheSize&&t?t._minTileCacheSize:this._minTileCacheSize,this._maxTileCacheSize=void 0===this._maxTileCacheSize&&t?t._maxTileCacheSize:this._maxTileCacheSize}loaded(){if(this._sourceErrored)return!0;if(!this._sourceLoaded)return!1;if(!this._source.loaded())return!1;for(const t in this._tiles){const e=this._tiles[t];if("errored"!==e.state&&("loaded"!==e.state||!e.bucketsLoaded()))return!1}return!0}getSource(){return this._source}pause(){this._paused=!0}resume(){if(!this._paused)return;const t=this._shouldReloadOnResume;this._paused=!1,this._shouldReloadOnResume=!1,t&&this.reload(),this.transform&&this.update(this.transform)}_loadTile(t,e){return t.isSymbolTile=this._onlySymbols,t.isExtraShadowCaster=this._shadowCasterTiles[t.tileID.key],this._source.loadTile(t,e)}_unloadTile(t){if(this._source.unloadTile)return this._source.unloadTile(t)}_abortTile(t){if(this._source.abortTile)return this._source.abortTile(t)}serialize(){return this._source.serialize()}prepare(t){this._source.prepare&&this._source.prepare(),this._state.coalesceChanges(this._tiles,this.map?this.map.painter:null);for(const e in this._tiles){const i=this._tiles[e];i.upload(t),i.prepare(this.map.style.imageManager,this.map?this.map.painter:null,this._source.scope)}}getIds(){return ti(this._tiles).map((t=>t.tileID)).sort(Ky).map((t=>t.key))}getRenderableIds(t,e){const i=[];for(const n in this._tiles)this._isIdRenderable(+n,t,e)&&i.push(this._tiles[n]);return t?i.sort(((t,e)=>{const i=t.tileID,n=e.tileID,r=new Ue(i.canonical.x,i.canonical.y)._rotate(this.transform.angle),o=new Ue(n.canonical.x,n.canonical.y)._rotate(this.transform.angle);return i.overscaledZ-n.overscaledZ||o.y-r.y||o.x-r.x})).map((t=>t.tileID.key)):i.map((t=>t.tileID)).sort(Ky).map((t=>t.key))}hasRenderableParent(t){const e=this.findLoadedParent(t,0);return!!e&&this._isIdRenderable(e.tileID.key)}_isIdRenderable(t,e,i){return this._tiles[t]&&this._tiles[t].hasData()&&!this._coveredTiles[t]&&(e||!this._tiles[t].holdingForFade())&&(i||!this._shadowCasterTiles[t])}reload(){if(this._paused)this._shouldReloadOnResume=!0;else{this._cache.reset();for(const t in this._tiles)"errored"!==this._tiles[t].state&&this._reloadTile(+t,"reloading")}}_reloadTile(t,e){const i=this._tiles[t];i&&("loading"!==i.state&&(i.state=e),this._loadTile(i,this._tileLoaded.bind(this,i,t,e)))}_tileLoaded(t,e,i,n){if(n)if(t.state="errored",404!==n.status)this._source.fire(new $n(n,{tile:t}));else{if(!(t.tileID.key in this._loadedParentTiles))return void this._source.fire(new Pn("data",{dataType:"source",sourceDataType:"error",sourceId:this._source.id}));if("raster-dem"===this._source.type&&this.usedForTerrain&&this.map.painter.terrain){const t=this.map.painter.terrain;this.update(this.transform,t.getScaledDemTileSize(),!0),t.resetTileLookupCache(this.id)}else this.update(this.transform)}else t.timeAdded=ki.now(),"expired"===i&&(t.refreshedUponExpiration=!0),this._setTileReloadTimer(e,t),"raster-dem"===this._source.type&&t.dem&&this._backfillDEM(t),this._state.initializeTileState(t,this.map?this.map.painter:null),this._source.fire(new Pn("data",{dataType:"source",tile:t,coord:t.tileID,sourceCacheId:this.id}))}_backfillDEM(t){const e=this.getRenderableIds();for(let n=0;n1||(Math.abs(i)>1&&(1===Math.abs(i+r)?i+=r:1===Math.abs(i-r)&&(i-=r)),e.dem&&t.dem&&(t.dem.backfillBorder(e.dem,i,n),t.neighboringTiles&&t.neighboringTiles[o]&&(t.neighboringTiles[o].backfilled=!0)))}}getTile(t){return this.getTileByID(t.key)}getTileByID(t){return this._tiles[t]}_retainLoadedChildren(t,e,i,n){for(const r in this._tiles){let o=this._tiles[r];if(n[r]||!o.hasData()||o.tileID.overscaledZi)continue;let s=o.tileID;for(;o&&o.tileID.overscaledZ>e+1;){const t=o.tileID.scaledTo(o.tileID.overscaledZ-1);o=this._tiles[t.key],o&&o.hasData()&&(s=t)}let a=s;for(;a.overscaledZ>e;)if(a=a.scaledTo(a.overscaledZ-1),t[a.key]){n[s.key]=s;break}}}findLoadedParent(t,e){if(t.key in this._loadedParentTiles){const i=this._loadedParentTiles[t.key];return i&&i.tileID.overscaledZ>=e?i:null}for(let i=t.overscaledZ-1;i>=e;i--){const e=t.scaledTo(i),n=this._getLoadedTile(e);if(n)return n}}_getLoadedTile(t){const e=this._tiles[t.key];return e&&e.hasData()?e:this._cache.getByKey(this._source.reparseOverscaled?t.wrapped().key:t.canonical.key)}updateCacheSize(t,e){e=e||this._source.tileSize;const i=Math.ceil(t.width/e)+1,n=Math.ceil(t.height/e)+1,r=Math.floor(i*n*5),o="number"==typeof this._minTileCacheSize?Math.max(this._minTileCacheSize,r):r,s="number"==typeof this._maxTileCacheSize?Math.min(this._maxTileCacheSize,o):o;this._cache.setMaxSize(s)}handleWrapJump(t){const e=Math.round((t-(void 0===this._prevLng?t:this._prevLng))/360);if(this._prevLng=t,e){const t={};for(const i in this._tiles){const n=this._tiles[i];n.tileID=n.tileID.unwrapTo(n.tileID.wrap+e),t[n.tileID.key]=n}this._tiles=t;for(const t in this._timers)clearTimeout(this._timers[t]),delete this._timers[t];for(const t in this._tiles)this._setTileReloadTimer(+t,this._tiles[t])}}update(t,e,i,n){if(this.transform=t,!this._sourceLoaded||this._paused||this.transform.freezeTileCoverage)return;if(this.usedForTerrain&&!i)return;let r;if(this.updateCacheSize(t,e),"globe"!==this.transform.projection.name&&this.handleWrapJump(this.transform.center.lng),this._shadowCasterTiles={},this._coveredTiles={},this.used||this.usedForTerrain){if(this._source.tileID)r=t.getVisibleUnwrappedCoordinates(this._source.tileID).map((t=>new vd(t.canonical.z,t.wrap,t.canonical.z,t.canonical.x,t.canonical.y)));else if(0!==this.tileCoverLift){const n=t.clone();n.tileCoverLift=this.tileCoverLift,r=n.coveringTiles({tileSize:e||this._source.tileSize,minzoom:this._source.minzoom,maxzoom:this._source.maxzoom,roundZoom:this._source.roundZoom&&!i,reparseOverscaled:this._source.reparseOverscaled,isTerrainDEM:this.usedForTerrain}),this._source.minzoomt(e)))}}else r=[];if(r.length>0&&this.castsShadows&&n&&"globe"!==this.transform.projection.name&&!this.usedForTerrain&&!Jy(this._source.type)){const o=t.coveringZoomLevel({tileSize:e||this._source.tileSize,roundZoom:this._source.roundZoom&&!i}),s=Math.min(o,this._source.maxzoom),a=t.extendTileCoverForShadows(r,n,s);for(const t of a)this._shadowCasterTiles[t.key]=!0,r.push(t)}const o=this._updateRetainedTiles(r);if(Jy(this._source.type)&&0!==r.length){const t={},e={},i=Object.keys(o);for(const n of i){const i=o[n],r=this._tiles[n];if(!r||r.fadeEndTime&&r.fadeEndTimen;){r=r.scaledTo(r.overscaledZ-1);const n=this._tiles[r.key];if(n&&n.hasData()&&e[r.key]){o[t]=i.tileID;break}}}for(const e in t)o[e]||(this._coveredTiles[e]=!0,o[e]=t[e])}for(const t in o)this._tiles[t].clearFadeHold();const s=function(t,e){const i=[];for(const n in t)n in e||i.push(n);return i}(this._tiles,o);for(const t of s){const e=this._tiles[t];e.hasSymbolBuckets&&!e.holdingForFade()?e.setHoldDuration(this.map._fadeDuration):e.hasSymbolBuckets&&!e.symbolFadeFinished()||this._removeTile(+t)}this._updateLoadedParentTileCache(),this._onlySymbols&&this._source.afterUpdate&&this._source.afterUpdate()}releaseSymbolFadeTiles(){for(const t in this._tiles)this._tiles[t].holdingForFade()&&this._removeTile(+t)}_updateRetainedTiles(t){const e={};if(0===t.length)return e;const i={},n=t.reduce(((t,e)=>Math.min(t,e.overscaledZ)),1/0),r=t[0].overscaledZ,o=Math.max(r-Xy.maxOverzooming,this._source.minzoom),s=Math.max(r+Xy.maxUnderzooming,this._source.minzoom),a={};for(const i of t){const t=this._addTile(i);e[i.key]=i,t.hasData()||n=this._source.maxzoom){const t=n.children(this._source.maxzoom)[0],i=this.getTile(t);if(i&&i.hasData()){e[t.key]=t;continue}}else{const t=n.children(this._source.maxzoom);if(e[t[0].key]&&e[t[1].key]&&e[t[2].key]&&e[t[3].key])continue}let r=t.wasRequested();for(let s=n.overscaledZ-1;s>=o;--s){const o=n.scaledTo(s);if(i[o.key])break;if(i[o.key]=!0,t=this.getTile(o),!t&&r&&(t=this._addTile(o)),t&&(e[o.key]=o,r=t.wasRequested(),t.hasData()))break}}return e}_updateLoadedParentTileCache(){this._loadedParentTiles={};for(const t in this._tiles){const e=[];let i,n=this._tiles[t].tileID;for(;n.overscaledZ>0;){if(n.key in this._loadedParentTiles){i=this._loadedParentTiles[n.key];break}e.push(n.key);const t=n.scaledTo(n.overscaledZ-1);if(i=this._getLoadedTile(t),i)break;n=t}for(const t of e)this._loadedParentTiles[t]=i}}_addTile(t){let e=this._tiles[t.key];if(e)return!0!==e.isExtraShadowCaster||!!this._shadowCasterTiles[t.key]||this._reloadTile(t.key,"reloading"),e;e=this._cache.getAndRemove(t),e&&(this._setTileReloadTimer(t.key,e),e.tileID=t,this._state.initializeTileState(e,this.map?this.map.painter:null),this._cacheTimers[t.key]&&(clearTimeout(this._cacheTimers[t.key]),delete this._cacheTimers[t.key],this._setTileReloadTimer(t.key,e)));const i=Boolean(e);if(!i){const i=this.map?this.map.painter:null,n=this._source.tileSize*t.overscaleFactor();e="raster-array"===this._source.type?new Wy(t,n,this.transform.tileZoom,i,this._isRaster):new ey(t,n,this.transform.tileZoom,i,this._isRaster),this._loadTile(e,this._tileLoaded.bind(this,e,t.key,e.state))}return e?(e.uses++,this._tiles[t.key]=e,i||this._source.fire(new Pn("dataloading",{tile:e,coord:e.tileID,dataType:"source"})),e):null}_setTileReloadTimer(t,e){t in this._timers&&(clearTimeout(this._timers[t]),delete this._timers[t]);const i=e.getExpiryTimeout();i&&(this._timers[t]=setTimeout((()=>{this._reloadTile(t,"expired"),delete this._timers[t]}),i))}_removeTile(t){const e=this._tiles[t];e&&(e.uses--,delete this._tiles[t],this._timers[t]&&(clearTimeout(this._timers[t]),delete this._timers[t]),e.uses>0||(e.hasData()&&"reloading"!==e.state||"empty"===e.state?this._cache.add(e.tileID,e,e.getExpiryTimeout()):(e.aborted=!0,this._abortTile(e),this._unloadTile(e))))}clearTiles(){this._shouldReloadOnResume=!1,this._paused=!1;for(const t in this._tiles)this._removeTile(+t);this._source._clear&&this._source._clear(),this._cache.reset(),this.map&&this.usedForTerrain&&this.map.painter.terrain&&this.map.painter.terrain.resetTileLookupCache(this.id)}tilesIn(t,e,i){const n=[],r=this.transform;if(!r)return n;const o="globe"===r.projection.name,s=Ed(r.center.lng);for(const a in this._tiles){const l=this._tiles[a];if(i&&l.clearQueryDebugViz(),l.holdingForFade())continue;let c;if(o){const t=l.tileID.canonical;if(0===t.z){const e=[Math.abs(Xe(s,...Qy(t,-1))-s),Math.abs(Xe(s,...Qy(t,1))-s)];c=[0,2*e.indexOf(Math.min(...e))-1]}else{const e=[Math.abs(Xe(s,...Qy(t,-1))-s),Math.abs(Xe(s,...Qy(t,0))-s),Math.abs(Xe(s,...Qy(t,1))-s)];c=[e.indexOf(Math.min(...e))-1]}}else c=[0];for(const i of c){const o=t.containsTile(l,r,e,i);o&&n.push(o)}}return n}getShadowCasterCoordinates(){return this._getRenderableCoordinates(!1,!0)}getVisibleCoordinates(t){return this._getRenderableCoordinates(t)}_getRenderableCoordinates(t,e){const i=this.getRenderableIds(t,e).map((t=>this._tiles[t].tileID)),n="globe"===this.transform.projection.name;for(const t of i)t.projMatrix=this.transform.calculateProjMatrix(t.toUnwrapped()),t.expandedProjMatrix=n?this.transform.calculateProjMatrix(t.toUnwrapped(),!1,!0):t.projMatrix;return i}sortCoordinatesByDistance(t){const e=t.slice(),i=this.transform._camera.position,n=this.transform._camera.forward(),r={};for(const t of e){const e=1/(1r[t.key]-r[e.key])),e}hasTransition(){if(this._source.hasTransition())return!0;if(Jy(this._source.type))for(const t in this._tiles){const e=this._tiles[t];if(void 0!==e.fadeEndTime&&e.fadeEndTime>=ki.now())return!0}return!1}setFeatureState(t,e,i){this._state.updateState(t=t||"_geojsonTileLayer",e,i)}removeFeatureState(t,e,i){this._state.removeFeatureState(t=t||"_geojsonTileLayer",e,i)}getFeatureState(t,e){return this._state.getState(t=t||"_geojsonTileLayer",e)}setDependencies(t,e,i){const n=this._tiles[t];n&&n.setDependencies(e,i)}reloadTilesForDependencies(t,e){for(const i in this._tiles)this._tiles[i].hasDependency(t,e)&&this._reloadTile(+i,"reloading");this._cache.filter((i=>!i.hasDependency(t,e)))}_preloadTiles(t,e){if(!this._sourceLoaded){const i=()=>{this._sourceLoaded&&(this._source.off("data",i),this._preloadTiles(t,e))};return void this._source.on("data",i)}const i=new Map,n=Array.isArray(t)?t:[t],r=this.map.painter.terrain,o=this.usedForTerrain&&r?r.getScaledDemTileSize():this._source.tileSize;for(const t of n){const e=t.coveringTiles({tileSize:o,minzoom:this._source.minzoom,maxzoom:this._source.maxzoom,roundZoom:this._source.roundZoom&&!this.usedForTerrain,reparseOverscaled:this._source.reparseOverscaled,isTerrainDEM:this.usedForTerrain});for(const t of e)i.set(t.key,t);this.usedForTerrain&&t.updateElevation(!1)}Qe(Array.from(i.values()),((t,e)=>{const i=new ey(t,this._source.tileSize*t.overscaleFactor(),this.transform.tileZoom,this.map.painter,this._isRaster);this._loadTile(i,(t=>{"raster-dem"===this._source.type&&i.dem&&this._backfillDEM(i),e(t,i)}))}),e)}}function Ky(t,e){const i=Math.abs(2*t.wrap)-+(t.wrap0?e+2*t:t}tv.useIntegerZoom=!0;const iv=new ol({"symbol-placement":new il(sl.layout_symbol["symbol-placement"]),"symbol-spacing":new il(sl.layout_symbol["symbol-spacing"]),"symbol-avoid-edges":new il(sl.layout_symbol["symbol-avoid-edges"]),"symbol-sort-key":new nl(sl.layout_symbol["symbol-sort-key"]),"symbol-z-order":new il(sl.layout_symbol["symbol-z-order"]),"symbol-z-elevate":new il(sl.layout_symbol["symbol-z-elevate"]),"icon-allow-overlap":new il(sl.layout_symbol["icon-allow-overlap"]),"icon-ignore-placement":new il(sl.layout_symbol["icon-ignore-placement"]),"icon-optional":new il(sl.layout_symbol["icon-optional"]),"icon-rotation-alignment":new il(sl.layout_symbol["icon-rotation-alignment"]),"icon-size":new nl(sl.layout_symbol["icon-size"]),"icon-text-fit":new nl(sl.layout_symbol["icon-text-fit"]),"icon-text-fit-padding":new nl(sl.layout_symbol["icon-text-fit-padding"]),"icon-image":new nl(sl.layout_symbol["icon-image"]),"icon-rotate":new nl(sl.layout_symbol["icon-rotate"]),"icon-padding":new il(sl.layout_symbol["icon-padding"]),"icon-keep-upright":new il(sl.layout_symbol["icon-keep-upright"]),"icon-offset":new nl(sl.layout_symbol["icon-offset"]),"icon-anchor":new nl(sl.layout_symbol["icon-anchor"]),"icon-pitch-alignment":new il(sl.layout_symbol["icon-pitch-alignment"]),"text-pitch-alignment":new il(sl.layout_symbol["text-pitch-alignment"]),"text-rotation-alignment":new il(sl.layout_symbol["text-rotation-alignment"]),"text-field":new nl(sl.layout_symbol["text-field"]),"text-font":new nl(sl.layout_symbol["text-font"]),"text-size":new nl(sl.layout_symbol["text-size"]),"text-max-width":new nl(sl.layout_symbol["text-max-width"]),"text-line-height":new nl(sl.layout_symbol["text-line-height"]),"text-letter-spacing":new nl(sl.layout_symbol["text-letter-spacing"]),"text-justify":new nl(sl.layout_symbol["text-justify"]),"text-radial-offset":new nl(sl.layout_symbol["text-radial-offset"]),"text-variable-anchor":new il(sl.layout_symbol["text-variable-anchor"]),"text-anchor":new nl(sl.layout_symbol["text-anchor"]),"text-max-angle":new il(sl.layout_symbol["text-max-angle"]),"text-writing-mode":new il(sl.layout_symbol["text-writing-mode"]),"text-rotate":new nl(sl.layout_symbol["text-rotate"]),"text-padding":new il(sl.layout_symbol["text-padding"]),"text-keep-upright":new il(sl.layout_symbol["text-keep-upright"]),"text-transform":new nl(sl.layout_symbol["text-transform"]),"text-offset":new nl(sl.layout_symbol["text-offset"]),"text-allow-overlap":new il(sl.layout_symbol["text-allow-overlap"]),"text-ignore-placement":new il(sl.layout_symbol["text-ignore-placement"]),"text-optional":new il(sl.layout_symbol["text-optional"]),visibility:new il(sl.layout_symbol.visibility)});var nv={paint:new ol({"icon-opacity":new nl(sl.paint_symbol["icon-opacity"]),"icon-occlusion-opacity":new nl(sl.paint_symbol["icon-occlusion-opacity"]),"icon-emissive-strength":new nl(sl.paint_symbol["icon-emissive-strength"]),"text-emissive-strength":new nl(sl.paint_symbol["text-emissive-strength"]),"icon-color":new nl(sl.paint_symbol["icon-color"]),"icon-halo-color":new nl(sl.paint_symbol["icon-halo-color"]),"icon-halo-width":new nl(sl.paint_symbol["icon-halo-width"]),"icon-halo-blur":new nl(sl.paint_symbol["icon-halo-blur"]),"icon-translate":new il(sl.paint_symbol["icon-translate"]),"icon-translate-anchor":new il(sl.paint_symbol["icon-translate-anchor"]),"icon-image-cross-fade":new nl(sl.paint_symbol["icon-image-cross-fade"]),"text-opacity":new nl(sl.paint_symbol["text-opacity"]),"text-occlusion-opacity":new nl(sl.paint_symbol["text-occlusion-opacity"]),"text-color":new nl(sl.paint_symbol["text-color"],{runtimeType:Qn,getOverride:t=>t.textColor,hasOverride:t=>!!t.textColor}),"text-halo-color":new nl(sl.paint_symbol["text-halo-color"]),"text-halo-width":new nl(sl.paint_symbol["text-halo-width"]),"text-halo-blur":new nl(sl.paint_symbol["text-halo-blur"]),"text-translate":new il(sl.paint_symbol["text-translate"]),"text-translate-anchor":new il(sl.paint_symbol["text-translate-anchor"]),"icon-color-saturation":new il(sl.paint_symbol["icon-color-saturation"]),"icon-color-contrast":new il(sl.paint_symbol["icon-color-contrast"]),"icon-color-brightness-min":new il(sl.paint_symbol["icon-color-brightness-min"]),"icon-color-brightness-max":new il(sl.paint_symbol["icon-color-brightness-max"])}),layout:iv};class rv{constructor(t){this.type=t.property.overrides?t.property.overrides.runtimeType:Yn,this.defaultValue=t}evaluate(t){if(t.formattedSection){const e=this.defaultValue.property.overrides;if(e&&e.hasOverride(t.formattedSection))return e.getOverride(t.formattedSection)}return t.feature&&t.featureState?this.defaultValue.evaluate(t.feature,t.featureState):this.defaultValue.property.specification.default}eachChild(t){this.defaultValue.isConstant()||t(this.defaultValue.value._styleExpression.expression)}outputDefined(){return!1}serialize(){return null}}ba(rv,"FormatSectionOverride",{omit:["defaultValue"]});class ov extends Ml{constructor(e,i,n,r){super(e,nv,i,n,r),this._colorAdjustmentMatrix=t.ad.identity([]),this.hasInitialOcclusionOpacityProperties=void 0!==e.paint&&("icon-occlusion-opacity"in e.paint||"text-occlusion-opacity"in e.paint)}recalculate(t,e){super.recalculate(t,e),"auto"===this.layout.get("icon-rotation-alignment")&&(this.layout._values["icon-rotation-alignment"]="point"!==this.layout.get("symbol-placement")?"map":"viewport"),"auto"===this.layout.get("text-rotation-alignment")&&(this.layout._values["text-rotation-alignment"]="point"!==this.layout.get("symbol-placement")?"map":"viewport"),"auto"===this.layout.get("text-pitch-alignment")&&(this.layout._values["text-pitch-alignment"]=this.layout.get("text-rotation-alignment")),"auto"===this.layout.get("icon-pitch-alignment")&&(this.layout._values["icon-pitch-alignment"]=this.layout.get("icon-rotation-alignment"));const i=this.layout.get("text-writing-mode");if(i){const t=[];for(const e of i)t.indexOf(e)i in t?String(t[i]):""))}(e.properties,r)}createBucket(t){return new jg(t)}queryRadius(){return 0}queryIntersectsFeature(){return!1}_setPaintOverrides(){for(const t of nv.paint.overridableProperties){if(!ov.hasPaintOverride(this.layout,t))continue;const e=this.paint.get(t),i=new rv(e),n=new la(i,e.property.specification,this.scope,this.options);let r=null;r="constant"===e.value.kind||"source"===e.value.kind?new ua("source",n):new ha("composite",n,e.value.zoomStops,e.value._interpolationType),this.paint._values[t]=new tl(e.property,r,e.parameters)}}_handleOverridablePaintPropertyUpdate(t,e,i){return!(!this.layout||e.isDataDriven()||i.isDataDriven())&&ov.hasPaintOverride(this.layout,t)}static hasPaintOverride(t,e){const i=t.get("text-field"),n=nv.paint.properties[e];let r=!1;const o=t=>{for(const e of t)if(n.overrides&&n.overrides.hasOverride(e))return void(r=!0)};if("constant"===i.value.kind&&i.value.value instanceof pr)o(i.value.value.sections);else if("source"===i.value.kind){const t=e=>{r||(e instanceof vr&&gr(e.value)===nr?o(e.value.sections):e instanceof Tr?o(e.sections):e.eachChild(t))},e=i.value;e._styleExpression&&t(e._styleExpression.expression)}return r}getProgramIds(){const t=0!==this.paint.get("icon-opacity").constantOr(1),e=0!==this.paint.get("text-opacity").constantOr(1),i=[];return t&&i.push("symbolIcon"),e&&i.push("symbolSDF"),i}getDefaultProgramParams(t,e,i){return{config:new Wc(this,{zoom:e,lut:i}),overrideFog:!1}}}const sv=new ol({visibility:new il(sl.layout_background.visibility)});var av={paint:new ol({"background-color":new il(sl.paint_background["background-color"]),"background-pattern":new il(sl.paint_background["background-pattern"]),"background-opacity":new il(sl.paint_background["background-opacity"]),"background-emissive-strength":new il(sl.paint_background["background-emissive-strength"])}),layout:sv};const lv=new ol({visibility:new il(sl.layout_raster.visibility)});var cv={paint:new ol({"raster-opacity":new il(sl.paint_raster["raster-opacity"]),"raster-color":new rl(sl.paint_raster["raster-color"]),"raster-color-mix":new il(sl.paint_raster["raster-color-mix"]),"raster-color-range":new il(sl.paint_raster["raster-color-range"]),"raster-hue-rotate":new il(sl.paint_raster["raster-hue-rotate"]),"raster-brightness-min":new il(sl.paint_raster["raster-brightness-min"]),"raster-brightness-max":new il(sl.paint_raster["raster-brightness-max"]),"raster-saturation":new il(sl.paint_raster["raster-saturation"]),"raster-contrast":new il(sl.paint_raster["raster-contrast"]),"raster-resampling":new il(sl.paint_raster["raster-resampling"]),"raster-fade-duration":new il(sl.paint_raster["raster-fade-duration"]),"raster-emissive-strength":new il(sl.paint_raster["raster-emissive-strength"]),"raster-array-band":new il(sl.paint_raster["raster-array-band"]),"raster-elevation":new il(sl.paint_raster["raster-elevation"])}),layout:lv};function dv(e,i,n,r,o,s,a,l){const c=[e,i,1,n,r,1,o,s,1],d=[a,l,1],u=t.bC.adjoint([],c),[h,p,f]=t._.transformMat3(d,d,u);return t.bC.multiply(c,c,[h,0,0,0,p,0,0,0,f])}function uv(e,i,n,r,o,s,a,l){const c=function(e,i,n,r,o,s,a,l){const c=dv(0,0,1,0,1,1,0,1),d=dv(e,i,n,r,o,s,a,l),u=t.bC.adjoint([],c);return t.bC.multiply(d,d,u)}(e,i,n,r,o,s,a,l);return[c[2]/c[8]/uo,c[5]/c[8]/uo]}function hv(t){return[t[0],Math.min(Math.max(t[1],-Pd),Pd)]}class pv extends zn{constructor(t,e,i,n){super(),this.id=t,this.dispatcher=i,this.coordinates=e.coordinates,this.type="image",this.minzoom=0,this.maxzoom=22,this.tileSize=512,this.tiles={},this._loaded=!1,this.onNorthPole=!1,this.onSouthPole=!1,this.setEventedParent(n),this.options=e,this._dirty=!1}load(t,e){if(this._loaded=e||!1,this.fire(new Pn("dataloading",{dataType:"source"})),this.url=this.options.url,!this.url)return t&&(this.coordinates=t),this._loaded=!0,void this._finishLoading();this._imageRequest=an(this.map._requestManager.transformRequest(this.url,Ki.Image),((e,i)=>{this._imageRequest=null,this._loaded=!0,e?this.fire(new $n(e)):i&&(this.image=i instanceof HTMLImageElement?ki.getImageData(i):i,this._dirty=!0,this.width=this.image.width,this.height=this.image.height,t&&(this.coordinates=t),this._finishLoading())}))}loaded(){return this._loaded}updateImage(t){return t.url?(this._imageRequest&&t.url!==this.options.url&&(this._imageRequest.cancel(),this._imageRequest=null),this.options.url=t.url,this.load(t.coordinates,this._loaded),this):this}setTexture(t){if(!(t.handle instanceof WebGLTexture))throw new Error("The provided handle is not a WebGLTexture instance");return this.texture=new Gg(this.map.painter.context,t.handle),this.width=t.dimensions[0],this.height=t.dimensions[1],this._dirty=!1,this._loaded=!0,this._finishLoading(),this}_finishLoading(){this.map&&(this.setCoordinates(this.coordinates),this.fire(new Pn("data",{dataType:"source",sourceDataType:"metadata"})))}onAdd(t){this.map=t,this.load()}onRemove(t){this._imageRequest&&(this._imageRequest.cancel(),this._imageRequest=null),!this.texture||this.texture instanceof Gg||this.texture.destroy(),this.boundsBuffer&&(this.boundsBuffer.destroy(),this.elevatedGlobeVertexBuffer&&this.elevatedGlobeVertexBuffer.destroy(),this.elevatedGlobeIndexBuffer&&this.elevatedGlobeIndexBuffer.destroy())}setCoordinates(t){if(this.coordinates=t,this._boundsArray=void 0,this._unsupportedCoords=!1,!t.length)return this;this.onNorthPole=!1,this.onSouthPole=!1;let e=t[0][1],i=t[0][1];for(const n of t)n[1]>i&&(i=n[1]),n[1]Pd?this.onNorthPole=!0:n1&&(l-=1),new gd(s,l,Math.floor((i+r)/2*a))}(e),this.minzoom=this.maxzoom=this.tileID.z}return this.fire(new Pn("data",{dataType:"source",sourceDataType:"content"})),this}_clear(){this._boundsArray=void 0,this._unsupportedCoords=!1}_prepareData(e){for(const t in this.tiles){const e=this.tiles[t];"loaded"!==e.state&&(e.state="loaded",e.texture=this.texture)}if(this._boundsArray||this.onNorthPole||this.onSouthPole||this._unsupportedCoords)return;const i=eg(new gd(0,0,0),this.map.transform.projection),n=[i.projection.project(this.coordinates[0][0],this.coordinates[0][1]),i.projection.project(this.coordinates[1][0],this.coordinates[1][1]),i.projection.project(this.coordinates[2][0],this.coordinates[2][1]),i.projection.project(this.coordinates[3][0],this.coordinates[3][1])];if(!function(t){const e=t[1].x-t[0].x,i=t[1].y-t[0].y,n=t[2].x-t[1].x,r=t[2].y-t[1].y,o=t[3].x-t[2].x,s=t[3].y-t[2].y,a=t[0].x-t[3].x,l=t[0].y-t[3].y,c=e*r-n*i,d=n*s-o*r,u=o*l-a*s,h=a*i-e*l;return c>0&&d>0&&u>0&&h>0||c{const e=r.projection.project(t[0],t[1]);return ig(r,e)._round()}));this.perspectiveTransform=uv(o.x,o.y,s.x,s.y,a.x,a.y,l.x,l.y);const c=this._boundsArray=new Dl;c.emplaceBack(o.x,o.y,0,0),c.emplaceBack(s.x,s.y,uo,0),c.emplaceBack(l.x,l.y,0,uo),c.emplaceBack(a.x,a.y,uo,uo),this.boundsBuffer&&(this.boundsBuffer.destroy(),this.elevatedGlobeVertexBuffer&&this.elevatedGlobeVertexBuffer.destroy(),this.elevatedGlobeIndexBuffer&&this.elevatedGlobeIndexBuffer.destroy()),this.boundsBuffer=e.createVertexBuffer(c,Jg.members),this.boundsSegments=wc.simpleSegment(0,0,4,2);const d=[],u=function(t){return[hv(t[0]),hv(t[1]),hv(t[2]),hv(t[3])]}(this.coordinates),[h,p,f,m]=function(t){let e=t[0][0],i=e,n=t[0][1],r=n;for(let o=1;oi&&(i=t[o][0]),t[o][1]r&&(r=t[o][1]);return[e,n,i-e,r-n]}(u);{const r=new Dl,[o,s,a,l]=function(t){let e=t[0].x,i=e,n=t[0].y,r=n;for(let o=1;oi&&(i=t[o].x),t[o].yr&&(r=t[o].y);return[e,n,i-e,r-n]}(n),c=t=>[(t.x-o)/a,(t.y-s)/l],[u,_,g,y]=n.map(c),v=function(e,i,n,r,o,s,a,l){const c=dv(0,0,1,0,1,1,0,1),d=dv(e,i,n,r,o,s,a,l),u=t.bC.adjoint([],d);return t.bC.multiply(c,c,u)}(u[0],u[1],_[0],_[1],g[0],g[1],y[0],y[1]);this.elevatedGlobePerspectiveTransform=uv(u[0],u[1],_[0],_[1],g[0],g[1],y[0],y[1]);const x=(e,i)=>{d.push(e.lng);const n=Math.round((e.lng-h)/f*uo),o=Math.round((e.lat-p)/m*uo),s=c(i),a=t._.transformMat3([],[s[0],s[1],1],v),l=Math.round(a[0]/a[2]*uo),u=Math.round(a[1]/a[2]*uo);r.emplaceBack(n,o,l,u)},b=n[3].x-n[0].x,w=n[3].y-n[0].y,T=n[2].x-n[1].x,S=n[2].y-n[1].y;for(let t=0;t{i.emplaceBack(e,n,r);const o=d[e],s=d[n],a=d[r],l=Math.min(Math.min(o,s),a),c=Math.max(Math.max(o,s),a)-l;c>this.maxLongitudeTriangleSize&&(this.maxLongitudeTriangleSize=c),t.push(l+c/2)};for(let t=0;te));i.sort(((e,i)=>t[e]-t[i]));const n=[],r=new Kl;for(let o=0;o{o.segments.push({vertexOffset:0,primitiveOffset:t,vertexLength:e.segments[0].vertexLength,primitiveLength:i,sortKey:void 0,vaos:{}})},a=.51*this.maxLongitudeTriangleSize;if(Math.abs(i[0]-n)0){const n=function(e,i){const n=i.worldSize,r=Cd(1,0)*n*kd(i.center.lat,i.zoom)/Gu(n),o=Cd(1,i.center.lat)*n,s=t.ad.identity([]);return t.ad.rotateY(s,s,Ge(i.center.lng)),t.ad.rotateX(s,s,Ge(i.center.lat)),t.ad.translate(s,s,[0,0,ed]),t.ad.scale(s,s,[r,r,r*o]),t.ad.translate(s,s,[i.point.x-.5*n,i.point.y-.5*n,0]),t.ad.multiply(s,s,e),t.ad.multiply(s,i.globeMatrix,s)}(e,i);return function(e,i,n){const r=(e,i,n)=>{const r=t._.length(e),o=t._.length(i),s=ku(e,i,n);return t._.scale(s,s,1/t._.length(s)*Vn(r,o,n))},o=r([e[0],e[1],e[2]],[i[0],i[1],i[2]],n),s=r([e[4],e[5],e[6]],[i[4],i[5],i[6]],n),a=r([e[8],e[9],e[10]],[i[8],i[9],i[10]],n),l=ku([e[12],e[13],e[14]],[i[12],i[13],i[14]],n);return[o[0],o[1],o[2],0,s[0],s[1],s[2],0,a[0],a[1],a[2],0,l[0],l[1],l[2],1]}(o,n,r)}return o}function kv(t,e,i,n){const r=wu.projectAabbCorners(n,i);let o=Number.MAX_VALUE,s=-1;for(let t=0;tnew Ue(r[t][0],r[t][1]);let l;switch(s){case 0:case 6:l=[a(1),a(5),a(4),a(7),a(3),a(2),a(1)];break;case 1:case 7:l=[a(0),a(4),a(5),a(6),a(2),a(3),a(0)];break;case 3:case 5:l=[a(1),a(0),a(4),a(7),a(6),a(2),a(1)];break;default:l=[a(1),a(5),a(6),a(7),a(3),a(0),a(1)]}if(Yd(t,l))return o}const Dv=Ll([{name:"a_pos_3f",components:3,type:"Float32"}]),zv=Ll([{name:"a_color_3f",components:3,type:"Float32"}]),Rv=Ll([{name:"a_color_4f",components:4,type:"Float32"}]),Ov=Ll([{name:"a_uv_2f",components:2,type:"Float32"}]),Bv=Ll([{name:"a_normal_3f",components:3,type:"Float32"}]),Fv=Ll([{name:"a_normal_matrix0",components:4,type:"Float32"},{name:"a_normal_matrix1",components:4,type:"Float32"},{name:"a_normal_matrix2",components:4,type:"Float32"},{name:"a_normal_matrix3",components:4,type:"Float32"}]),Nv=Ll([{name:"a_pbr",components:4,type:"Uint16"},{name:"a_heightBasedEmissiveStrength",components:3,type:"Float32"}]);class Uv{constructor(t,e,i,n){this.message=(t?`${t}: `:"")+i,n&&(this.identifier=n),null!=e&&e.__line__&&(this.line=e.__line__)}}function jv(t,e){const i=-1===t.indexOf("://");try{return new URL(t,i&&e?"http://example.com":void 0),!0}catch(t){return!1}}class Vv{constructor(t,e){this.feature=t,this.instancedDataOffset=e,this.instancedDataCount=0,this.rotation=[0,0,0],this.scale=[1,1,1],this.translation=[0,0,0]}}class Gv{constructor(){this.instancedDataArray=new oc,this.instancesEvaluatedElevation=[],this.features=[],this.idToFeaturesIndex={}}}class Zv{constructor(t){this.zoom=t.zoom,this.canonical=t.canonical,this.layers=t.layers,this.layerIds=this.layers.map((t=>t.fqid)),this.projection=t.projection,this.index=t.index,this.hasZoomDependentProperties=this.layers[0].isZoomDependent(),this.stateDependentLayerIds=this.layers.filter((t=>t.isStateDependent())).map((t=>t.id)),this.hasPattern=!1,this.instancesPerModel={},this.validForExaggeration=0,this.maxVerticalOffset=0,this.maxScale=0,this.maxHeight=0,this.lookupDim=this.zoom>this.canonical.z?256:this.zoom>15?75:100,this.instanceCount=0,this.terrainElevationMin=0,this.terrainElevationMax=0,this.validForDEMTile={id:null,timestamp:0},this.modelUris=[],this.modelsRequested=!1,this.activeReplacements=[],this.replacementUpdateTime=0}updateFootprints(t,e){}populate(t,e,i,n){this.tileToMeter=zd(i);const r=this.layers[0]._featureFilter.needGeometry;this.lookup=new Uint8Array(this.lookupDim*this.lookupDim);for(const{feature:o,id:s,index:a,sourceLayerIndex:l}of t){const t=null!=s?s:o.properties&&o.properties.hasOwnProperty("id")?o.properties.id:void 0,c=Zd(o,r);if(!this.layers[0]._featureFilter.filter(new Ha(this.zoom),c,i))continue;const d={id:t,sourceLayerIndex:l,index:a,geometry:r?c.geometry:Gd(o,i,n),properties:o.properties,type:o.type,patterns:{}},u=this.addFeature(d,d.geometry,c);u&&e.featureIndex.insert(o,d.geometry,a,l,this.index,this.instancesPerModel[u].instancedDataArray.length,uo/32)}this.lookup=null}update(t,e,i,n){for(const e in this.instancesPerModel){const i=this.instancesPerModel[e];for(const e in t)i.idToFeaturesIndex.hasOwnProperty(e)&&(this.evaluate(i.features[i.idToFeaturesIndex[e]],t[e],i,!0),this.uploaded=!1)}this.maxHeight=0}updateZoomBasedPaintProperties(){if(!this.hasZoomDependentProperties)return!1;let e=!1;for(const i in this.instancesPerModel){const n=this.instancesPerModel[i];for(const i of n.features){const r=this.layers[0],o=i.feature,s=this.canonical,a=r.paint.get("model-rotation").evaluate(o,{},s),l=r.paint.get("model-scale").evaluate(o,{},s),c=r.paint.get("model-translation").evaluate(o,{},s);t._.exactEquals(i.rotation,a)&&t._.exactEquals(i.scale,l)&&t._.exactEquals(i.translation,c)||(this.evaluate(i,i.featureStates,n,!0),e=!0)}}return e}updateReplacement(t,e,i){if(e.updateTime===this.replacementUpdateTime)return!1;this.replacementUpdateTime=e.updateTime;const n=e.getReplacementRegionsForTile(t.toUnwrapped(),!0);if(Pp(this.activeReplacements,n))return!1;this.activeReplacements=n;let r=!1;for(const e in this.instancesPerModel){const n=this.instancesPerModel[e],o=n.instancedDataArray;for(const e of n.features){const n=e.instancedDataOffset,s=e.instancedDataCount;for(let e=0;euo?a-uo:a;const l=Math.floor(a),c=o.float32[s+1];let d=!1;for(const e of this.activeReplacements)if(!(e.orderl||l>e.max.x||e.min.y>c||c>e.max.y)&&(d=Op(Rp(l,c,t.canonical,e.footprintTileId.canonical),e),d))break;o.float32[s]=d?a+uo:a,r=r||d}}}return r}isEmpty(){for(const t in this.instancesPerModel)if(0!==this.instancesPerModel[t].instancedDataArray.length)return!1;return!0}uploadPending(){return!this.uploaded}upload(t){if(!this.uploaded)for(const e in this.instancesPerModel){const i=this.instancesPerModel[e];i.instancedDataArray.length=uo||e.y=uo)continue;const t=(this.lookupDim-1)/uo,i=this.lookupDim*(e.y*t|0)+e.x*t|0;if(this.lookup){if(0!==this.lookup[i])continue;this.lookup[i]=1}this.instanceCount++;const n=s.length;s.resize(n+1),o.instancesEvaluatedElevation.push(0),s.float32[16*n]=e.x,s.float32[16*n+1]=e.y}return a.instancedDataCount=o.instancedDataArray.length-a.instancedDataOffset,a.instancedDataCount>0&&(t.id&&(o.idToFeaturesIndex[t.id]=o.features.length),o.features.push(a),this.evaluate(a,{},o,!1)),r}getModelUris(){return this.modelUris}evaluate(t,e,i,n){const r=this.layers[0],o=t.feature,s=this.canonical,a=t.rotation=r.paint.get("model-rotation").evaluate(o,e,s),l=t.scale=r.paint.get("model-scale").evaluate(o,e,s),c=t.translation=r.paint.get("model-translation").evaluate(o,e,s),d=r.paint.get("model-color").evaluate(o,e,s);d.a=r.paint.get("model-color-mix-intensity").evaluate(o,e,s);const u=[];this.maxVerticalOffset10?this.tileToMeter:zd(s,p)),a[o+4]=c[0],a[o+5]=c[1],a[o+6]=c[2]+l,a[o+7]=u[0],a[o+8]=u[1],a[o+9]=u[2],a[o+10]=u[4],a[o+11]=u[5],a[o+12]=u[6],a[o+13]=u[8],a[o+14]=u[9],a[o+15]=u[10],i.instancesEvaluatedElevation[r]=c[2]}}}ba(Zv,"ModelBucket",{omit:["layers"]}),ba(Gv,"PerModelAttributes"),ba(Vv,"ModelFeature");const qv=new ol({visibility:new il(sl.layout_model.visibility),"model-id":new nl(sl.layout_model["model-id"])});var Hv={paint:new ol({"model-opacity":new il(sl.paint_model["model-opacity"]),"model-rotation":new nl(sl.paint_model["model-rotation"]),"model-scale":new nl(sl.paint_model["model-scale"]),"model-translation":new nl(sl.paint_model["model-translation"]),"model-color":new nl(sl.paint_model["model-color"]),"model-color-mix-intensity":new nl(sl.paint_model["model-color-mix-intensity"]),"model-type":new il(sl.paint_model["model-type"]),"model-cast-shadows":new il(sl.paint_model["model-cast-shadows"]),"model-receive-shadows":new il(sl.paint_model["model-receive-shadows"]),"model-ambient-occlusion-intensity":new il(sl.paint_model["model-ambient-occlusion-intensity"]),"model-emissive-strength":new nl(sl.paint_model["model-emissive-strength"]),"model-roughness":new nl(sl.paint_model["model-roughness"]),"model-height-based-emissive-strength-multiplier":new nl(sl.paint_model["model-height-based-emissive-strength-multiplier"]),"model-cutoff-fade-range":new il(sl.paint_model["model-cutoff-fade-range"]),"model-front-cutoff":new il(sl.paint_model["model-front-cutoff"])}),layout:qv};const Wv=64,Yv={CoordinateSpaceTile:1,CoordinateSpaceYUp:2,HasMapboxMeshFeatures:4,HasMeshoptCompression:8};function Xv(e,i,n,r,o,s,a,l,c,d=!1){const u=n.zoom,h=n.project(r),p=kd(r.lat,u),f=1/p;t.ad.identity(e),t.ad.translate(e,e,[h.x+a[0]*f,h.y+a[1]*f,a[2]]);let m=1,_=1;const g=n.worldSize;if(d){if("mercator"===n.projection.name){let e=0;n.elevation&&(e=n.elevation.getAtPointOrZero(new Rd(h.x/g,h.y/g),0));const i=t.aA.transformMat4([],[h.x,h.y,e,1],n.projMatrix)[3]/n.cameraToCenterDistance;m=i,_=i*kd(n.center.lat,u)}else if("globe"===n.projection.name){const i=$v(e,n),o=t.ad.multiply([],n.projMatrix,i),s=[0,0,0,1];t.aA.transformMat4(s,s,o);const a=s[3]/n.cameraToCenterDistance,l=Hu(u),c=n.projection.pixelsPerMeter(r.lat,g)*kd(r.lat,u),d=n.projection.pixelsPerMeter(n.center.lat,g)*kd(n.center.lat,u);m=a/Vn(c,$d(n.center.lat),l),_=a*p/c,m*=d,_*=d}}else m=f;t.ad.scale(e,e,[m,m,_]);const y=[...e],v=i.orientation,x=[];if(Lv(x,[v[0]+o[0],v[1]+o[1],v[2]+o[2]],s),t.ad.multiply(e,y,x),l&&n.elevation){let o=0;const s=[];if(c&&n.elevation){o=function(e,i,n,r,o){const s=i.elevation;if(!s)return 0;const a=wu.projectAabbCorners(n,r),l=Cd(1,o.lat)*i.worldSize,c=function(e,i){const n=[0,0,1],r=[{corners:[0,1,3,2],dotProductWithUp:0},{corners:[1,5,2,6],dotProductWithUp:0},{corners:[0,4,1,5],dotProductWithUp:0},{corners:[2,6,3,7],dotProductWithUp:0},{corners:[4,7,5,6],dotProductWithUp:0},{corners:[0,3,4,7],dotProductWithUp:0}];for(const o of r){const r=e[o.corners[0]],s=e[o.corners[1]],a=e[o.corners[2]],l=[s[0]-r[0],s[1]-r[1],i*(s[2]-r[2])],c=t._.cross(l,l,[a[0]-r[0],a[1]-r[1],i*(a[2]-r[2])]);t._.normalize(c,c),o.dotProductWithUp=t._.dot(c,n)}return r.sort(((t,e)=>t.dotProductWithUp-e.dotProductWithUp)),r[0].corners}(a,l),d=a[c[0]],u=a[c[1]],h=a[c[2]],p=a[c[3]],f=s.getAtPointOrZero(new Rd(d[0]/i.worldSize,d[1]/i.worldSize),0),m=s.getAtPointOrZero(new Rd(u[0]/i.worldSize,u[1]/i.worldSize),0),_=s.getAtPointOrZero(new Rd(h[0]/i.worldSize,h[1]/i.worldSize),0),g=s.getAtPointOrZero(new Rd(p[0]/i.worldSize,p[1]/i.worldSize),0),y=(f+g)/2,v=(m+_)/2;return y>v?m=e.gl.NEAREST_MIPMAP_NEAREST}),t.uploaded=!0,t.image=null)}function Jv(t,e,i){t.indexBuffer=e.createIndexBuffer(t.indexArray,!1,!0),t.vertexBuffer=e.createVertexBuffer(t.vertexArray,Dv.members,!1,!0),t.normalArray&&(t.normalBuffer=e.createVertexBuffer(t.normalArray,Bv.members,!1,!0)),t.texcoordArray&&(t.texcoordBuffer=e.createVertexBuffer(t.texcoordArray,Ov.members,!1,!0)),t.colorArray&&(t.colorBuffer=e.createVertexBuffer(t.colorArray,(12===t.colorArray.bytesPerElement?zv:Rv).members,!1,!0)),t.featureArray&&(t.pbrBuffer=e.createVertexBuffer(t.featureArray,Nv.members,!0)),t.segments=wc.simpleSegment(0,0,t.vertexArray.length,t.indexArray.length);const n=t.material;n.pbrMetallicRoughness.baseColorTexture&&Kv(n.pbrMetallicRoughness.baseColorTexture,e),n.pbrMetallicRoughness.metallicRoughnessTexture&&Kv(n.pbrMetallicRoughness.metallicRoughnessTexture,e),n.normalTexture&&Kv(n.normalTexture,e),n.occlusionTexture&&Kv(n.occlusionTexture,e,i),n.emissionTexture&&Kv(n.emissionTexture,e)}function Qv(t,e,i){if(t.meshes)for(const n of t.meshes)Jv(n,e,i);if(t.children)for(const n of t.children)Qv(n,e,i)}function tx(t){if(t.meshes)for(const e of t.meshes)e.indexArray.destroy(),e.vertexArray.destroy(),e.colorArray&&e.colorArray.destroy(),e.normalArray&&e.normalArray.destroy(),e.texcoordArray&&e.texcoordArray.destroy(),e.featureArray&&e.featureArray.destroy();if(t.children)for(const e of t.children)tx(e)}function ex(t){if(t.meshes)for(const i of t.meshes)i.vertexBuffer&&(i.vertexBuffer.destroy(),i.indexBuffer.destroy(),i.normalBuffer&&i.normalBuffer.destroy(),i.texcoordBuffer&&i.texcoordBuffer.destroy(),i.colorBuffer&&i.colorBuffer.destroy(),i.pbrBuffer&&i.pbrBuffer.destroy(),i.segments.destroy(),i.material&&((e=i.material).pbrMetallicRoughness.baseColorTexture&&e.pbrMetallicRoughness.baseColorTexture.gfxTexture&&e.pbrMetallicRoughness.baseColorTexture.gfxTexture.destroy(),e.pbrMetallicRoughness.metallicRoughnessTexture&&e.pbrMetallicRoughness.metallicRoughnessTexture.gfxTexture&&e.pbrMetallicRoughness.metallicRoughnessTexture.gfxTexture.destroy(),e.normalTexture&&e.normalTexture.gfxTexture&&e.normalTexture.gfxTexture.destroy(),e.emissionTexture&&e.emissionTexture.gfxTexture&&e.emissionTexture.gfxTexture.destroy(),e.occlusionTexture&&e.occlusionTexture.gfxTexture&&e.occlusionTexture.gfxTexture.destroy()));var e;if(t.children)for(const e of t.children)ex(e)}class ix{constructor(t){this._callback=t,this._triggered=!1,"undefined"!=typeof MessageChannel&&(this._channel=new MessageChannel,this._channel.port2.onmessage=()=>{this._triggered=!1,this._callback()})}trigger(){this._triggered||(this._triggered=!0,this._channel?this._channel.port1.postMessage(!0):setTimeout((()=>{this._triggered=!1,this._callback()}),0))}remove(){this._channel=void 0,this._callback=()=>{}}}class nx{constructor(){this.tasks={},this.taskQueue=[],ai(["process"],this),this.invoker=new ix(this.process),this.nextId=0}add(t,e){const i=this.nextId++,n=function({type:t,isSymbolTile:e,zoom:i}){return i=i||0,"message"===t?0:"maybePrepare"!==t||e?"parseTile"!==t||e?"parseTile"===t&&e?300-i:"maybePrepare"===t&&e?400-i:500:200-i:100-i}(e);if(0===n){try{t()}finally{}return null}return this.tasks[i]={fn:t,metadata:e,priority:n,id:i},this.taskQueue.push(i),this.invoker.trigger(),{cancel:()=>{delete this.tasks[i]}}}process(){try{if(this.taskQueue=this.taskQueue.filter((t=>!!this.tasks[t])),!this.taskQueue.length)return;const t=this.pick();if(null===t)return;const e=this.tasks[t];if(delete this.tasks[t],this.taskQueue.length&&this.invoker.trigger(),!e)return;e.fn()}finally{}}pick(){let t=null,e=1/0;for(let i=0;i{i&&delete this.callbacks[s],this.target.postMessage({id:s,type:"",targetMapId:n,sourceMapId:this.mapId})}}}receive(t){const e=t.data,i=e.id;if(i&&(!e.targetMapId||this.mapId===e.targetMapId))if(""===e.type){const t=this.cancelCallbacks[i];delete this.cancelCallbacks[i],t&&t.cancel()}else if(e.mustQueue||gi()){const t=this.callbacks[i],n=this.scheduler.add((()=>this.processTask(i,e)),t&&t.metadata||{type:"message"});n&&(this.cancelCallbacks[i]=n)}else this.processTask(i,e)}processTask(t,e){if(delete this.cancelCallbacks[t],""===e.type){const i=this.callbacks[t];delete this.callbacks[t],i&&(e.error?i(Ea(e.error)):i(null,Ea(e.data)))}else{const i=new Set,n=e.hasCallback?(e,n)=>{this.target.postMessage({id:t,type:"",sourceMapId:this.mapId,error:e?Sa(e):null,data:Sa(n,i)},i)}:t=>{},r=Ea(e.data);if(this.parent[e.type])this.parent[e.type](e.sourceMapId,r,n);else if(this.parent.getWorkerSource){const t=e.type.split(".");this.parent.getWorkerSource(e.sourceMapId,t[0],r.source,r.scope)[t[1]](r,n)}else n(new Error(`Could not find function ${e.type}`))}}remove(){this.scheduler.remove(),this.target.removeEventListener("message",this.receive,!1)}}class ox{constructor(t,e){this.workerPool=t,this.actors=[],this.currentActor=0,this.id=ni();const i=this.workerPool.acquire(this.id);for(let t=0;t{this.ready=!0}))}broadcast(t,e,i){Qe(this.actors,((i,n)=>{i.send(t,e,n)}),i=i||function(){})}getActor(){return this.currentActor=(this.currentActor+1)%this.actors.length,this.actors[this.currentActor]}remove(){this.actors.forEach((t=>{t.remove()})),this.actors=[],this.workerPool.release(this.id)}}ox.Actor=rx;var sx={workerUrl:"",workerClass:null,workerParams:void 0};function ax(){return null!=sx.workerClass?new sx.workerClass:new self.Worker(sx.workerUrl,sx.workerParams)}const lx="mapboxgl_preloaded_worker_pool";class cx{constructor(){this.active={}}acquire(t){if(!this.workers)for(this.workers=[];this.workers.length{t.terminate()})),this.workers=null)}isPreloaded(){return!!this.active[lx]}numActive(){return Object.keys(this.active).length}}let dx;function ux(){return dx||(dx=new cx),dx}cx.workerCount=2;let hx,px,fx,mx,_x,gx=null;function yx(){return gi()&&self.worker&&self.worker.dracoUrl?self.worker.dracoUrl:px||n.DRACO_URL}function vx(){if(gi()&&self.worker&&self.worker.meshoptUrl)return self.worker.meshoptUrl;if(mx)return mx;const t=new Uint8Array([0,97,115,109,1,0,0,0,1,4,1,96,0,0,3,3,2,0,0,5,3,1,0,1,12,1,0,10,22,2,12,0,65,0,65,0,65,0,252,10,0,0,11,7,0,65,0,253,15,26,11]);if("object"!=typeof WebAssembly)throw new Error("WebAssembly not supported, cannot instantiate meshoptimizer");return mx=WebAssembly.validate(t)?n.MESHOPT_SIMD_URL:n.MESHOPT_URL,mx}const xx={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},bx={5120:"DT_INT8",5121:"DT_UINT8",5122:"DT_INT16",5123:"DT_UINT16",5125:"DT_UINT32",5126:"DT_FLOAT32"},wx={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16};function Tx(t,e,i){const n=i.json.bufferViews.length,r=i.buffers.length;e.bufferView=n,i.json.bufferViews[n]={buffer:r,byteLength:t.byteLength},i.buffers[r]=t}const Sx="KHR_draco_mesh_compression";function Ex(t,e){const i=t.extensions&&t.extensions[Sx];if(!i)return;const n=new fx.Decoder,r=$x(e,i.bufferView),o=new fx.Mesh;if(!n.DecodeArrayToMesh(r,r.byteLength,o))throw new Error("Failed to decode Draco mesh");const s=e.json.accessors[t.indices],a=xx[s.componentType],l=s.count*a.BYTES_PER_ELEMENT,c=fx._malloc(l);a===Uint16Array?n.GetTrianglesUInt16Array(o,l,c):n.GetTrianglesUInt32Array(o,l,c),Tx(fx.memory.buffer.slice(c,c+l),s,e),fx._free(c);for(const r of Object.keys(i.attributes)){const s=n.GetAttributeByUniqueId(o,i.attributes[r]),a=e.json.accessors[t.attributes[r]],l=bx[a.componentType],c=a.count*wx[a.type]*xx[a.componentType].BYTES_PER_ELEMENT,d=fx._malloc(c);n.GetAttributeDataArrayForAllPoints(o,s,fx[l],c,d),Tx(fx.memory.buffer.slice(d,d+c),a,e),fx._free(d)}n.destroy(),o.destroy(),delete t.extensions[Sx]}const Mx="EXT_meshopt_compression";function Cx(t,e){if(!t.extensions||!t.extensions[Mx])return;const i=t.extensions[Mx],n=new Uint8Array(e.buffers[i.buffer],i.byteOffset||0,i.byteLength||0),r=new Uint8Array(i.count*i.byteStride);_x.decodeGltfBuffer(r,i.count,i.byteStride,n,i.mode,i.filter),t.buffer=e.buffers.length,t.byteOffset=0,e.buffers[t.buffer]=r.buffer,delete t.extensions[Mx]}const Ax=1179937895,Ix=new TextDecoder("utf8");function Lx(t,e){return new URL(t,e).href}function Px(t,e,i,n){return fetch(Lx(t.uri,n)).then((t=>t.arrayBuffer())).then((t=>{e.buffers[i]=t}))}function $x(t,e){const i=t.json.bufferViews[e];return new Uint8Array(t.buffers[i.buffer],i.byteOffset||0,i.byteLength)}function kx(t,e,i,n){if(t.uri){const r=Lx(t.uri,n);return fetch(r).then((t=>t.blob())).then((t=>createImageBitmap(t))).then((t=>{e.images[i]=t}))}if(void 0!==t.bufferView){const n=$x(e,t.bufferView),r=new Blob([n],{type:t.mimeType});return createImageBitmap(r).then((t=>{e.images[i]=t}))}}function Dx(t,e=0,i){const n={json:null,images:[],buffers:[]};if(new Uint32Array(t,e,1)[0]===Ax){const i=new Uint32Array(t,e);let r=2;const o=(i[r++]>>2)-3,s=i[r++]>>2;if(r++,n.json=JSON.parse(Ix.decode(i.subarray(r,r+s))),r+=s,r{const t=[],e=a&&a.includes(Sx),r=a&&a.includes(Mx);if(e&&t.push(function(){if(!fx)return hx||(hx=function(t){let e,i=null;function n(){e=new Uint8Array(i.buffer)}function r(){throw new Error("Unexpected Draco error.")}const o={a:{a:r,d:function(t,i,n){return e.copyWithin(t,i,i+n)},c:function(t){const r=e.length,o=Math.max(t>>>0,Math.ceil(1.2*r)),s=Math.ceil((o-r)/65536);try{return i.grow(s),n(),!0}catch(t){return!1}},b:r}};return(WebAssembly.instantiateStreaming?WebAssembly.instantiateStreaming(t,o):t.then((t=>t.arrayBuffer())).then((t=>WebAssembly.instantiate(t,o)))).then((t=>{const{Rb:r,Qb:o,P:s,T:a,X:l,Ja:c,La:d,Qa:u,Va:h,Wa:p,eb:f,jb:m,f:_,e:g,yb:y,zb:v,Ab:x,Bb:b,Db:w,Gb:T}=t.instance.exports;i=g;const S=(()=>{let t=0,i=0,n=0,s=0;return a=>{n&&(r(s),r(t),i+=n,n=t=0),t||(i+=128,t=o(i));const l=a.length+7&-8;let c=t;l>=i&&(n=l,c=s=o(l));for(let t=0;t{fx=t,hx=void 0})))}()),r&&t.push(function(){if(_x)return;const t=function(t){let e;const i=WebAssembly.instantiateStreaming(t,{}).then((t=>{e=t.instance,e.exports.__wasm_call_ctors()})),n={NONE:"",OCTAHEDRAL:"meshopt_decodeFilterOct",QUATERNION:"meshopt_decodeFilterQuat",EXPONENTIAL:"meshopt_decodeFilterExp"},r={ATTRIBUTES:"meshopt_decodeVertexBuffer",TRIANGLES:"meshopt_decodeIndexBuffer",INDICES:"meshopt_decodeIndexSequence"};return{ready:i,supported:!0,decodeGltfBuffer(t,i,o,s,a,l){!function(t,e,i,n,r,o,s){const a=t.exports.sbrk,l=n+3&-4,c=a(l*r),d=a(o.length),u=new Uint8Array(t.exports.memory.buffer);u.set(o,d);const h=e(c,n,r,d,o.length);if(0===h&&s&&s(c,l,r),i.set(u.subarray(c,c+n*r)),a(c-a(0)),0!==h)throw new Error(`Malformed buffer data: ${h}`)}(e,e.exports[r[a]],t,i,o,s,e.exports[n[l]])}}}(fetch(vx()));return t.ready.then((()=>{_x=t}))}()),o)for(let e=0;e{if(e&&s)for(const{primitives:t}of s)for(const e of t)Ex(e,n);if(r&&s&&l)for(const t of l)Cx(t,n);return n}))}))}function zx(t,e){const i=t.json.bufferViews[e.bufferView],n=xx[e.componentType];return new n(t.buffers[i.buffer],(e.byteOffset||0)+(i.byteOffset||0),e.count*(i.byteStride&&i.byteStride!==wx[e.type]*n.BYTES_PER_ELEMENT?i.byteStride/n.BYTES_PER_ELEMENT:wx[e.type]))}function Rx(t,e,i,n){const r=xx[e.componentType],o=function(t){switch(t){case Int8Array:return 1/127;case Uint8Array:return 1/255;case Int16Array:return 1/32767;case Uint16Array:return 1/65535;default:return 1}}(r),s=t.json.bufferViews[e.bufferView],a=s.byteStride?s.byteStride/r.BYTES_PER_ELEMENT:wx[e.type],l=i.float32,c=l.length/i.capacity;for(let t=0,i=0;t0){for(let r=0;r0){o.texcoordArray=new ic;const t=e.json.accessors[r.TEXCOORD_0];o.texcoordArray.resize(t.count);const i=zx(e,t);Rx(e,t,o.texcoordArray,i)}if(void 0!==r._FEATURE_ID_RGBA4444){const t=e.json.accessors[r._FEATURE_ID_RGBA4444];e.json.extensionsUsed&&e.json.extensionsUsed.includes("EXT_meshopt_compression")&&(o.featureData=zx(e,t))}void 0!==r._FEATURE_RGBA4444&&(o.featureData=new Uint32Array(zx(e,e.json.accessors[r._FEATURE_RGBA4444]).buffer));const u=t.material;return o.material=function(t,e){const{emissiveFactor:i=[0,0,0],alphaMode:n="OPAQUE",alphaCutoff:r=.5,normalTexture:o,occlusionTexture:s,emissiveTexture:a,doubleSided:l}=t,{baseColorFactor:c=[1,1,1,1],metallicFactor:d=1,roughnessFactor:u=1,baseColorTexture:h,metallicRoughnessTexture:p}=t.pbrMetallicRoughness||{},f=s?e[s.index]:void 0;if(s&&s.extensions&&s.extensions.KHR_texture_transform&&f){const t=s.extensions.KHR_texture_transform;f.offsetScale=[t.offset[0],t.offset[1],t.scale[0],t.scale[1]]}return{pbrMetallicRoughness:{baseColorFactor:new Un(...c),metallicFactor:d,roughnessFactor:u,baseColorTexture:h?e[h.index]:void 0,metallicRoughnessTexture:p?e[p.index]:void 0},doubleSided:l,emissiveFactor:i,alphaMode:n,alphaCutoff:r,normalTexture:o?e[o.index]:void 0,occlusionTexture:f,emissionTexture:a?e[a.index]:void 0,defined:void 0===t.defined}}(void 0!==u?e.json.materials[u]:{defined:!1},i),o}function Bx(e,i,n){const{matrix:r,rotation:o,translation:s,scale:a,mesh:l,extras:c,children:d}=e,u={};if(u.matrix=r||t.ad.fromRotationTranslationScale([],o||[0,0,0,1],s||[0,0,0],a||[1,1,1]),void 0!==l){u.meshes=n[l];const t=u.anchor=[0,0];for(const e of u.meshes){const{min:i,max:n}=e.aabb;t[0]+=i[0]+n[0],t[1]+=i[1]+n[1]}t[0]=Math.floor(t[0]/u.meshes.length/2),t[1]=Math.floor(t[1]/u.meshes.length/2)}if(c&&(c.id&&(u.id=c.id),c.lights&&(u.lights=function(t){if(!t.length)return[];const e=function(t){const e=atob(t),i=new Uint8Array(e.length);for(let t=0;t1&&n[n.length-1].equals(n[0])&&n.pop();let r=0;for(let t=0;t0&&n.reverse();const o=xh(n.flatMap((t=>[t.x,t.y])),[]);return 0===o.length?null:{vertices:n,indices:o}}function Ux(e,i){const n=[],r=[];let o=0;const s=[];for(const a of e){o=n.length;const e=a.vertexArray.float32,l=a.indexArray.uint16;for(let r=0;r0&&([r[t+1],r[t+2]]=[r[t+2],r[t+1]])}return{vertices:n,indices:r}}function jx(t){const e=function(t,e){const i=[],n=WebGL2RenderingContext;if(t.json.textures)for(const r of t.json.textures){const o={magFilter:n.LINEAR,minFilter:n.NEAREST,wrapS:n.REPEAT,wrapT:n.REPEAT};void 0!==r.sampler&&Object.assign(o,t.json.samplers[r.sampler]),i.push({image:e[r.source],sampler:o,uploaded:!1})}return i}(t,t.images),i=function(t,e){const i=[];for(const n of t.json.meshes){const r=[];for(const i of n.primitives)r.push(Ox(i,t,e));i.push(r)}return i}(t,e),{scenes:n,scene:r,nodes:o}=t.json,s=n?n[r||0].nodes:o,a=[];for(const e of s)a.push(Bx(o[e],t,i));return function(t,e,i){const n={},r=new Set;for(let o=0;o0){const e=Array.from(r.values()).sort(((t,e)=>t-e));for(let i=e.length-1;i>=0;i--)t.splice(e[i],1)}}(a,s,t.json.nodes),a}function Vx(t){t.heightmap=new Float32Array(4096),t.heightmap.fill(-1);const e=t.vertexArray.float32,i=t.aabb.min[0]-1,n=t.aabb.min[1]-1,r=Wv/(t.aabb.max[0]-i+2),o=Wv/(t.aabb.max[1]-n+2);for(let s=0;st.heightmap[c*Wv+l]&&(t.heightmap[c*Wv+l]=a)}}function Gx(e,i){const n={};n.indexArray=new Kl,n.indexArray.reserve(4*e.length),n.vertexArray=new Bl,n.vertexArray.reserve(10*e.length),n.colorArray=new Ol,n.vertexArray.reserve(10*e.length);let r=0;for(const o of e){const e=Math.min(10,Math.max(4,1.3*o.height))*i,s=[-o.normal[1],o.normal[0],0],a=Math.min(.29,.1*o.width/o.depth),l=o.width-2*o.depth*i*(a+.01),c=t._.scaleAndAdd([],o.pos,s,l/2),d=t._.scaleAndAdd([],o.pos,s,-l/2),u=[c[0],c[1],c[2]+o.height],h=[d[0],d[1],d[2]+o.height],p=t._.scaleAndAdd([],o.normal,s,a);t._.scale(p,p,e);const f=t._.scaleAndAdd([],o.normal,s,-a);t._.scale(f,f,e),t._.add(p,c,p),t._.add(f,d,f),c[2]+=.1,d[2]+=.1,n.vertexArray.emplaceBack(p[0],p[1],p[2]),n.vertexArray.emplaceBack(f[0],f[1],f[2]),n.vertexArray.emplaceBack(c[0],c[1],c[2]),n.vertexArray.emplaceBack(d[0],d[1],d[2]),n.vertexArray.emplaceBack(u[0],u[1],u[2]),n.vertexArray.emplaceBack(h[0],h[1],h[2]),n.vertexArray.emplaceBack(c[0],c[1],c[2]),n.vertexArray.emplaceBack(d[0],d[1],d[2]),n.vertexArray.emplaceBack(p[0],p[1],p[2]),n.vertexArray.emplaceBack(f[0],f[1],f[2]);const m=l/e/2;n.colorArray.emplaceBack(-m-a,-1,m,.8),n.colorArray.emplaceBack(m+a,-1,m,.8),n.colorArray.emplaceBack(-m,0,m,1.3),n.colorArray.emplaceBack(m,0,m,1.3),n.colorArray.emplaceBack(m+a,-.8,m,.7),n.colorArray.emplaceBack(m+a,-.8,m,.7),n.colorArray.emplaceBack(0,0,m,1.3),n.colorArray.emplaceBack(0,0,m,1.3),n.colorArray.emplaceBack(m+a,-1.2,m,.8),n.colorArray.emplaceBack(m+a,-1.2,m,.8),n.indexArray.emplaceBack(6+r,4+r,8+r),n.indexArray.emplaceBack(7+r,9+r,5+r),n.indexArray.emplaceBack(0+r,1+r,2+r),n.indexArray.emplaceBack(1+r,3+r,2+r),r+=10}const o={defined:!0,emissiveFactor:[0,0,0]},s={};return s.baseColorFactor=Un.white,o.pbrMetallicRoughness=s,n.material=o,n.aabb=new wu([1/0,1/0,1/0],[-1/0,-1/0,-1/0]),n}const Zx=new Float32Array(262144),qx=new Uint8Array(262144);function Hx(t){let e=0;if(t.meshes)for(const i of t.meshes)e=Math.max(e,i.aabb.max[2]);if(t.children)for(const i of t.children)e=Math.max(e,Hx(i));return e}function Wx(t,e,i){if(t.meshes)for(const n of t.meshes)n.aabb.min[0]!==1/0&&i.insert(e,n.aabb.min[0],n.aabb.min[1],n.aabb.max[0],n.aabb.max[1]);if(t.children)for(const n of t.children)Wx(n,e,i)}const Yx=["","wall","door","roof","window","lamp","logo"];class Xx{constructor(t){this.node=t,this.evaluatedRMEA=[[1,0,0,1],[1,0,0,1],[1,0,0,1],[1,0,0,1],[.4,1,0,1],[1,0,0,1],[1,0,0,1]],this.hiddenByReplacement=!1,this.evaluatedScale=[1,1,1],this.evaluatedColor=[],this.emissionHeightBasedParams=[],this.feature={type:"Point",id:t.id,geometry:[],properties:{height:Hx(t)}},this.aabb=this._getLocalBounds()}_getLocalBounds(){if(!this.node.meshes)return new wu([1/0,1/0,1/0],[-1/0,-1/0,-1/0]);if(!this.aabb){let t=0;const e=new wu([1/0,1/0,1/0],[-1/0,-1/0,-1/0]);for(const i of this.node.meshes)this.node.lightMeshIndex!==t&&(i.transformedAabb=wu.applyTransformFast(i.aabb,this.node.matrix),e.encapsulate(i.transformedAabb)),t++;this.aabb=e}return this.aabb}}class Kx{constructor(t,e,i,n,r,o){this.id=e,this.modelTraits|=Yv.CoordinateSpaceTile,this.uploaded=!1,this.hasPattern=!1,i&&(this.modelTraits|=Yv.HasMapboxMeshFeatures),n&&(this.modelTraits|=Yv.HasMeshoptCompression),this.zoom=-1,this.terrainExaggeration=1,this.projection={name:"mercator"},this.replacementUpdateTime=0,this.elevationReadFromZ=255,this.brightness=r,this.dirty=!0,this.needsUpload=!1,this.nodesInfo=[];for(const e of t)this.nodesInfo.push(new Xx(e)),Wx(e,o.featureIndexArray.length,o.grid),o.featureIndexArray.emplaceBack(this.nodesInfo.length-1,0,o.bucketLayerIDs.length-1,0)}updateFootprints(t,e){for(const i of this.getNodesInfo()){const n=i.node;n.footprint&&e.push({footprint:n.footprint,id:t})}}update(){console.log("Update 3D model bucket")}populate(){console.log("populate 3D model bucket")}uploadPending(){return!this.uploaded||this.needsUpload}upload(t){if(!this.needsUpload)return;const e=this.getNodesInfo();for(const i of e){const e=i.node;this.uploaded?this.updatePbrBuffer(e):Qv(e,t,!0)}for(const t of e)tx(t.node);this.uploaded=!0,this.needsUpload=!1}updatePbrBuffer(t){let e=!1;if(!t.meshes)return e;for(const i of t.meshes)i.pbrBuffer&&(i.pbrBuffer.updateData(i.featureArray),e=!0);return e}needsReEvaluation(t,e,i){const n=t.transform.projectionOptions,r=t.style.getBrightness(),o=this.brightness!==r;return!!(!this.uploaded||this.dirty||n.name!==this.projection.name||Jx(i.paint.get("model-color").value,o)||Jx(i.paint.get("model-color-mix-intensity").value,o)||Jx(i.paint.get("model-roughness").value,o)||Jx(i.paint.get("model-emissive-strength").value,o)||Jx(i.paint.get("model-height-based-emissive-strength-multiplier").value,o))&&(this.projection=n,this.brightness=r,!0)}evaluateScale(t,e){if(t.transform.zoom===this.zoom)return;this.zoom=t.transform.zoom;const i=this.getNodesInfo(),n=this.id.canonical;for(const t of i){const i=t.feature;t.evaluatedScale=e.paint.get("model-scale").evaluate(i,{},n)}}evaluate(t){const e=this.getNodesInfo();for(const i of e){if(!i.node.meshes)continue;const e=i.feature,n=i.node.meshes&&i.node.meshes[0].featureData,r=i.evaluatedColor[2],o=i.evaluatedRMEA[2],s=this.id.canonical;if(i.hasTranslucentParts=!1,n){for(let n=0;n=t)continue;const u=Zx[c],h=Math.abs(u);h>a&&(s=u,a=h,l=r,d=e)}if(a>.1){const o=1-(t+.5*Math.abs(l*d))/c;let a=e._dem.get(n,i)+s*o;const u=e._dem.get(n+l,i+d),h=e._dem.get(n-l,i-d,!0);(a-u)*(a-h)>0&&(a=(u+h)/2),Zx[r]=e._dem.set(n,i,a),qx[r]=t}}}}}s&&(e._demTile.needsDEMTextureUpload=!0,e._dem._timestamp=ki.now())}getNodesInfo(){return this.nodesInfo}destroy(){const t=this.getNodesInfo();for(const e of t)tx(e.node),ex(e.node)}isEmpty(){return!this.nodesInfo.length}updateReplacement(t,e){if(e.updateTime===this.replacementUpdateTime)return;this.replacementUpdateTime=e.updateTime;const i=e.getReplacementRegionsForTile(t.toUnwrapped()),n=this.getNodesInfo();for(let t=0;tt.footprint===e.footprint))}}getHeightAtTileCoord(e,i){const n=this.getNodesInfo(),r=[],o=[0,0,0],s=t.ad.identity([]);for(let a=0;ad.max[0]||i>d.max[1])continue;if(!0===l.node.hidden)return{height:0,maxHeight:l.feature.properties.height,hidden:!1,verticalScale:l.evaluatedScale[2]};t.ad.invert(s,l.node.matrix),o[0]=e,o[1]=i,t._.transformMat4(o,o,s);const u=(o[0]-c.aabb.min[0])/(c.aabb.max[0]-c.aabb.min[0])*Wv|0,h=Math.min(63,(o[1]-c.aabb.min[1])/(c.aabb.max[1]-c.aabb.min[1])*Wv|0)*Wv+Math.min(63,u),p=c.heightmap[h];if(!(p0)return{height:void 0,maxHeight:l.feature.properties.height,hidden:l.hiddenByReplacement,verticalScale:l.evaluatedScale[2]}}}}function Jx(t,e){return!t.isLightConstant&&e}function Qx(t,e,i,n,r,o,s,a){let l=(61440&e|(61440&e)>>4)>>8,c=(3840&e|(3840&e)>>4)>>4,d=240&e|(240&e)>>4;i[3]>0&&(l=Vn(l,255*i[0],i[3]),c=Vn(c,255*i[1],i[3]),d=Vn(d,255*i[2],i[3]));const u=l>16&65535,a=o?e>>16&65535:65535&e,l=(15&a)t.polygon)).flat());const g=f?l:null,[y,v]=function(e,i,n,r,o,s,a,l,c,d,u){return"globe"===e.projection.name?function(e,i,n,r,o,s,a,l,c,d,u){const h=[],p=[],f=e.projection.upVectorScale(u,e.center.lat,e.worldSize).metersToTile,m=[0,0,0,1],_=[0,0,0,1],g=(t,e,i,n)=>{t[0]=e,t[1]=i,t[2]=n,t[3]=1},y=Sf();n>0&&(n+=y),r+=y;for(const y of i){const i=[],v=[];for(const h of y){const p=h.x+o.x,y=h.y+o.y,x=e.projection.projectTilePoint(p,y,u),b=e.projection.upVector(u,h.x,h.y);let w=n,T=r;if(a){const t=Pf(p,y,n,r,a,l,c,d);w+=t.base,T+=t.top}0!==n?g(m,x.x+b[0]*f*w,x.y+b[1]*f*w,x.z+b[2]*f*w):g(m,x.x,x.y,x.z),g(_,x.x+b[0]*f*T,x.y+b[1]*f*T,x.z+b[2]*f*T),t._.transformMat4(m,m,s),t._.transformMat4(_,_,s),i.push(new Tp(m[0],m[1],m[2])),v.push(new Tp(_[0],_[1],_[2]))}h.push(i),p.push(v)}return[h,p]}(e,i,n,r,o,s,a,l,c,d,u):a?function(e,i,n,r,o,s,a,l,c){const d=[],u=[],h=[0,0,0,1];for(const p of e){const e=[],f=[];for(const d of p){const u=d.x+r.x,p=d.y+r.y,m=Pf(u,p,i,n,s,a,l,c);h[0]=u,h[1]=p,h[2]=m.base,h[3]=1,t.aA.transformMat4(h,h,o),h[3]=Math.max(h[3],1e-5);const _=new Tp(h[0]/h[3],h[1]/h[3],h[2]/h[3]);h[0]=u,h[1]=p,h[2]=m.top,h[3]=1,t.aA.transformMat4(h,h,o),h[3]=Math.max(h[3],1e-5);const g=new Tp(h[0]/h[3],h[1]/h[3],h[2]/h[3]);e.push(_),f.push(g)}d.push(e),u.push(f)}return[d,u]}(i,n,r,o,s,a,l,c,d):function(t,e,i,n,r){const o=[],s=[],a=r[8]*e,l=r[9]*e,c=r[10]*e,d=r[11]*e,u=r[8]*i,h=r[9]*i,p=r[10]*i,f=r[11]*i;for(const e of t){const t=[],i=[];for(const o of e){const e=o.x+n.x,s=o.y+n.y,m=r[0]*e+r[4]*s+r[12],_=r[1]*e+r[5]*s+r[13],g=r[2]*e+r[6]*s+r[14],y=r[3]*e+r[7]*s+r[15],v=m+a,x=_+l,b=g+c,w=Math.max(y+d,1e-5),T=m+u,S=_+h,E=g+p,M=Math.max(y+f,1e-5);t.push(new Tp(v/w,x/w,b/w)),i.push(new Tp(T/M,S/M,E/M))}o.push(t),s.push(i)}return[o,s]}(i,n,r,o,s)}(s,r,h,u,d,a,g,p,m,s.center.lat,e.tileID.canonical),x=e.queryGeometry;return function(t,e,i){let n=1/0;Kd(i,e)&&(n=Lf(i,e[0]));for(let r=0;r=3)for(let e=0;e>4;if(1!==n)throw new Error(`Got v${n} data when expected v1.`);const r=nb[15&i];if(!r)throw new Error("Unrecognized array type.");const[o]=new Uint16Array(t,2,1),[s]=new Uint32Array(t,4,1);return new rb(s,o,r,t)}constructor(t,e=64,i=Float64Array,n){if(isNaN(t)||t>1;return this.ids[i]=i,this.coords[this._pos++]=t,this.coords[this._pos++]=e,i}finish(){const t=this._pos>>1;if(t!==this.numItems)throw new Error(`Added ${t} items when expected ${this.numItems}.`);return ob(this.ids,this.coords,this.nodeSize,0,this.numItems-1,0),this._finished=!0,this}range(t,e,i,n){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");const{ids:r,coords:o,nodeSize:s}=this,a=[0,r.length-1,0],l=[];for(;a.length;){const c=a.pop()||0,d=a.pop()||0,u=a.pop()||0;if(d-u=t&&a=e&&c>1,p=o[2*h],f=o[2*h+1];p>=t&&p=e&&f=p:n>=f)&&(a.push(h+1),a.push(d),a.push(1-c))}return l}within(t,e,i){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");const{ids:n,coords:r,nodeSize:o}=this,s=[0,n.length-1,0],a=[],l=i*i;for(;s.length;){const c=s.pop()||0,d=s.pop()||0,u=s.pop()||0;if(d-u>1,p=r[2*h],f=r[2*h+1];cb(p,f,t,e)=p:e+i>=f)&&(s.push(h+1),s.push(d),s.push(1-c))}return a}}function ob(t,e,i,n,r,o){if(r-n>1;sb(t,e,s,n,r,o),ob(t,e,i,n,s-1,1-o),ob(t,e,i,s+1,r,1-o)}function sb(t,e,i,n,r,o){for(;r>n;){if(r-n>600){const s=r-n+1,a=i-n+1,l=Math.log(s),c=.5*Math.exp(2*l/3),d=.5*Math.sqrt(l*c*(s-c)/s)*(a-s/2s&&ab(t,e,n,r);as;)l--}e[2*n+o]===s?ab(t,e,n,l):(l++,ab(t,e,l,r)),lr&&(n+=(t[i]-r)*(t[i]-r)),e[i]0&&n[0]0&&n[1]0&&r[0]0&&r[1]0?Math.acos(i/n)*Ve:0;let o=0!==t||0!==e?Math.atan2(-e,-t)*Ve+90:0;return oNi&&(t.getActor().send("enforceCacheSizeLimit",Fi),Vi=0)},t.an=gn,t.ao=class{constructor(t){this.entries={},this.scheduler=t}request(t,e,i,n){const r=this.entries[t]=this.entries[t]||{callbacks:[]};if(r.result){const[t,i]=r.result;return this.scheduler?this.scheduler.add((()=>{n(t,i)}),e):n(t,i),()=>{}}return r.callbacks.push(n),r.cancel||(r.cancel=i(((i,n)=>{r.result=[i,n];for(const t of r.callbacks)this.scheduler?this.scheduler.add((()=>{t(i,n)}),e):t(i,n);setTimeout((()=>delete this.entries[t]),3e3)}))),()=>{r.result||(r.callbacks=r.callbacks.filter((t=>t!==n)),r.callbacks.length||(r.cancel(),delete this.entries[t]))}}},t.ap=function(t,e,i){const n=JSON.stringify(t.request);return t.data&&(this.deduped.entries[n]={result:[null,t.data]}),this.deduped.request(n,{type:"parseTile",isSymbolTile:t.isSymbolTile,zoom:t.tileZoom},(e=>{const n=en(t.request,((t,n,r,o)=>{t?e(t):n&&e(null,{vectorTile:i?void 0:new bp(new Lm(n)),rawData:n,cacheControl:r,expires:o})}));return()=>{n.cancel(),e()}}),e)},t.aq=Dc,t.ar=class extends Lc{constructor(t){super(t),this.current=Fc}set(t,e,i){if(this.fetchUniformLocation(t,e))for(let t=0;t({u_camera_to_center_distance:new $c(t),u_extrude_scale:new Uc(t),u_device_pixel_ratio:new $c(t),u_matrix:new Bc(t),u_inv_rot_matrix:new Bc(t),u_merc_center:new kc(t),u_tile_id:new Dc(t),u_zoom_transition:new $c(t),u_up_dir:new Dc(t),u_emissive_strength:new $c(t)}),t.bJ=t=>({u_matrix:new Bc(t),u_pixels_to_tile_units:new Uc(t),u_device_pixel_ratio:new $c(t),u_units_to_pixels:new kc(t),u_dash_image:new Pc(t),u_gradient_image:new Pc(t),u_image_height:new $c(t),u_texsize:new kc(t),u_tile_units_to_pixels:new $c(t),u_alpha_discard_threshold:new $c(t),u_trim_offset:new kc(t),u_trim_fade_range:new kc(t),u_trim_color:new zc(t),u_emissive_strength:new $c(t)}),t.bK=t=>({u_matrix:new Bc(t),u_texsize:new kc(t),u_pixels_to_tile_units:new Uc(t),u_device_pixel_ratio:new $c(t),u_image:new Pc(t),u_units_to_pixels:new kc(t),u_tile_units_to_pixels:new $c(t),u_alpha_discard_threshold:new $c(t),u_trim_offset:new kc(t)}),t.bL=Yl,t.bM=Hf,t.bN=Om,t.bO=jm,t.bP=G_,t.bQ=c_,t.bR=th,t.bS=(t,e,i,n,r,o)=>{const s=t.transform,a="globe"===s.projection.name;let l;if("map"===o.paint.get("circle-pitch-alignment"))if(a){const t=Zu(s.zoom,e.canonical)*s._pixelsPerMercatorPixel;l=Float32Array.from([t,0,0,t])}else l=s.calculatePixelsToTileUnitsMatrix(i);else l=new Float32Array([s.pixelsToGLUnits[0],0,0,s.pixelsToGLUnits[1]]);const c={u_camera_to_center_distance:t.transform.getCameraToCenterDistance(s.projection),u_matrix:t.translatePosMatrix(e.projMatrix,i,o.paint.get("circle-translate"),o.paint.get("circle-translate-anchor")),u_device_pixel_ratio:ki.devicePixelRatio,u_extrude_scale:l,u_inv_rot_matrix:Qu,u_merc_center:[0,0],u_tile_id:[0,0,0],u_zoom_transition:0,u_up_dir:[0,0,0],u_emissive_strength:o.paint.get("circle-emissive-strength")};if(a){c.u_inv_rot_matrix=n,c.u_merc_center=r,c.u_tile_id=[e.canonical.x,e.canonical.y,1{const s=t.transform;return{u_matrix:rm(t,e,i,n),u_texsize:e.imageAtlasTexture?e.imageAtlasTexture.size:[0,0],u_pixels_to_tile_units:s.calculatePixelsToTileUnitsMatrix(e),u_device_pixel_ratio:r,u_image:0,u_tile_units_to_pixels:nm(e,s),u_units_to_pixels:[1/s.pixelsToGLUnits[0],1/s.pixelsToGLUnits[1]],u_alpha_discard_threshold:0,u_trim_offset:o}},t.bV=(t,e,i,n,r,o,s)=>{const a=t.transform,l=a.calculatePixelsToTileUnitsMatrix(e);return{u_matrix:rm(t,e,i,n),u_pixels_to_tile_units:l,u_device_pixel_ratio:o,u_units_to_pixels:[1/a.pixelsToGLUnits[0],1/a.pixelsToGLUnits[1]],u_dash_image:0,u_gradient_image:1,u_image_height:r,u_texsize:sm(i)&&e.lineAtlasTexture?e.lineAtlasTexture.size:[0,0],u_tile_units_to_pixels:nm(e,t.transform),u_alpha_discard_threshold:0,u_trim_offset:s,u_trim_fade_range:i.paint.get("line-trim-fade-range"),u_trim_color:i.paint.get("line-trim-color").toRenderColor(i.lut).toArray01(),u_emissive_strength:i.paint.get("line-emissive-strength")}},t.bW=oi,t.bX=mh,t.bY=Sf,t.bZ=bd,t.b_=_f,t.ba=function(t,e,i){const n=Hu(i.zoom),r=t.style.map._antialias,o=e.options.extStandardDerivativesForceOff||t.terrain&&t.terrain.exaggeration()>0;return 0===n&&!r&&!o},t.bb=function(e){const i=e.pixelsPerMeter,n=i/Cd(1,e.center.lat),r=t.ad.identity(new Float64Array(16));return t.ad.translate(r,r,[e.point.x,e.point.y,0]),t.ad.scale(r,r,[n,n,i]),Float32Array.from(r)},t.bc=Ou,t.bd=function(t){const e=Pd-5;t=Xe(t,-e,e)/e*90;const i=Math.pow(Math.abs(Math.sin(Ge(t))),3);return Math.round(i*(sd.length-1))},t.be=function(e,i,n,r){const o=i.getNorth(),s=i.getSouth(),a=i.getWest(),l=i.getEast(),c=10){const e=180/r;t.bC.multiply(f,f,[e/d+1,0,0,0,e/u+1,0,-.5*e/h,.5*e/p,1])}return f[2]=c,f[5]=e.x,f[8]=e.y,f},t.bf=ju,t.bg=$u,t.bh=function(e,i,n){const r=t.ad.identity(new Float64Array(16)),o=(i/(1{}}},t.bo=Gg,t.bp=ai,t.bq=class{isDataAvailableAtPoint(t){const e=this._source();if(this.isUsingMockSource()||!e||t.y1)return!1;const i=e.getSource().maxzoom,n=11)return e;const r=n.getSource().maxzoom,o=1{const s=this.getAtTileOffset(e,o.x,o.y),a=r.upVector(e.canonical,o.x,o.y),l=r.upVectorScale(e.canonical,i,n).metersToTile;return t._.scale(a,a,s*l),a}}getForTilePoints(t,e,i,n){if(this.isUsingMockSource())return!1;const r=Xp.create(this,t,n);return!!r&&(e.forEach((t=>{t[2]=this.exaggeration()*r.getElevationAt(t[0],t[1],i)})),!0)}getMinMaxForTile(t){if(this.isUsingMockSource())return null;const e=this.findDEMTileFor(t);if(!e||!e.dem)return null;const i=e.dem.tree,n=e.tileID,r=1=0?t.slice(0,e):t},t.cV=function(t){return t.indexOf(wl)>=0},t.cW=function(t){const e=t.indexOf(wl);return e>=0?t.slice(e+1):""},t.cX=function(t){const e=[],i=t.id;return void 0===i&&e.push({message:`layers.${i}: missing required property "id"`}),void 0===t.render&&e.push({message:`layers.${i}: missing required method "render"`}),t.renderingMode&&"2d"!==t.renderingMode&&"3d"!==t.renderingMode&&e.push({message:`layers.${i}: property "renderingMode" must be either "2d" or "3d"`}),e},t.cY=function(t,e,i,n){return"custom"===t.type?new vv(t,e):new ib[t.type](t,e,i,n)},t.cZ=di,t.c_=Va,t.ca=1,t.cb=Ag,t.cc=0,t.cd=ec,t.ce=function(t,e,i,n,r){return Xe((t-e)/(i-e)*(r-n)+n,n,r)},t.cf=Ns,t.cg=kd,t.ch=class{constructor(t,e,i,n){this.context=t,this.format=n,this.size=i,this.texture=t.gl.createTexture();const[r,o,s]=this.size,{gl:a}=t;a.bindTexture(a.TEXTURE_3D,this.texture),t.pixelStoreUnpackFlipY.set(!1),t.pixelStoreUnpack.set(1),t.pixelStoreUnpackPremultiplyAlpha.set(!1);let l=this.format,c=a.UNSIGNED_BYTE;this.format===a.DEPTH_COMPONENT&&(l=a.DEPTH_COMPONENT16,c=a.UNSIGNED_SHORT),this.format===a.R8&&(n=a.RED),this.format===a.R32F&&(c=a.FLOAT,n=a.RED),a.texImage3D(a.TEXTURE_3D,0,l,r,o,s,0,n,c,e.data)}bind(t,e){const{context:i}=this,{gl:n}=i;n.bindTexture(n.TEXTURE_3D,this.texture),t!==this.minFilter&&(n.texParameteri(n.TEXTURE_3D,n.TEXTURE_MAG_FILTER,t),n.texParameteri(n.TEXTURE_3D,n.TEXTURE_MIN_FILTER,t),this.minFilter=t),e!==this.wrapS&&(n.texParameteri(n.TEXTURE_3D,n.TEXTURE_WRAP_S,e),n.texParameteri(n.TEXTURE_3D,n.TEXTURE_WRAP_T,e),this.wrapS=e)}destroy(){const{gl:t}=this.context;t.deleteTexture(this.texture),this.texture=null}},t.ci=$v,t.cj=[1,1,1],t.ck=Xp,t.cl=Yv,t.cm=ql,t.cn=ic,t.co=class{constructor(){this._updateTime=0,this._sourceIds=[],this._activeRegions=[],this._prevRegions=[],this._globalClipBounds={min:new Ue(1/0,1/0),max:new Ue(-1/0,-1/0)}}clear(){this._activeRegions.length>0&&++this._updateTime,this._activeRegions=[],this._prevRegions=[]}get updateTime(){return this._updateTime}getReplacementRegionsForTile(t,e=!1){const i=$p(new Ue(0,0),new Ue(uo,uo),t),n=[];if(e&&!Lp(i,this._globalClipBounds))return n;for(const e of this._activeRegions){if(e.hiddenByOverlap)continue;if(!Lp(i,e))continue;const r=kp(e.min,e.max,t);n.push({min:r.min,max:r.max,sourceId:this._sourceIds[e.priority],footprint:e.footprint,footprintTileId:e.tileId,order:e.order,clipMask:e.clipMask})}return n}setSources(t){this._setSources(t.map((t=>({getSourceId:()=>t.cache.id,getFootprints:()=>{const e=[];for(const i of t.cache.getVisibleCoordinates()){const n=t.cache.getTile(i).buckets[t.layer];n&&n.updateFootprints(i.toUnwrapped(),e)}return e},getOrder:()=>t.order,getClipMask:()=>t.clipMask}))))}_addSource(t){const e=t.getFootprints();if(0===e.length)return;const i=t.getOrder(),n=t.getClipMask();for(const t of e){if(!t.footprint)continue;const e=$p(t.footprint.min,t.footprint.max,t.id);this._activeRegions.push({min:e.min,max:e.max,hiddenByOverlap:!1,priority:this._sourceIds.length,tileId:t.id,footprint:t.footprint,order:i,clipMask:n})}this._sourceIds.push(t.getSourceId())}_computeReplacement(){this._activeRegions.sort(((t,e)=>t.priority-e.priority||Ap(t.min,e.min)||Ap(t.max,e.max)));let t=this._activeRegions.length!==this._prevRegions.length;if(!t){let e=0;for(;!t&&e!==this._activeRegions.length;){const i=this._activeRegions[e],n=this._prevRegions[e];t=i.priority!==n.priority||!Ip(i,n)||i.order!==n.order||i.clipMask!==n.clipMask,++e}}if(t){++this._updateTime;for(const t of this._activeRegions)t.order!==1/0&&(this._globalClipBounds.min.x=Math.min(this._globalClipBounds.min.x,t.min.x),this._globalClipBounds.min.y=Math.min(this._globalClipBounds.min.y,t.min.y),this._globalClipBounds.max.x=Math.max(this._globalClipBounds.max.x,t.max.x),this._globalClipBounds.max.y=Math.max(this._globalClipBounds.max.y,t.max.y));const t=t=>{const e=this._activeRegions;if(t>=e.length)return t;const i=e[t].priority;for(;t1){let e=0,i=t(e);for(;e!==i;){let n=e;const r=e;for(;n!==i;){const t=this._activeRegions[n];t.hiddenByOverlap=!1;for(let e=0;e=0;e--)this._addSource(t[e]);this._computeReplacement()}},t.cp=Dl,t.cq=Jg,t.cr=rc,t.cs=class{constructor(t){this._createGrid(t),this._createPoles(t)}destroy(){this._poleIndexBuffer.destroy(),this._gridBuffer.destroy(),this._gridIndexBuffer.destroy(),this._poleNorthVertexBuffer.destroy(),this._poleSouthVertexBuffer.destroy();for(const t of this._poleSegments)t.destroy();for(const t of this._gridSegments)t.withSkirts.destroy(),t.withoutSkirts.destroy()}_fillGridMeshWithLods(t,e){const i=new $l,n=new Kl,r=[],o=t+1+2,s=e[0]+1,a=e[0]+1+(1+e.length),l=(t,e,i)=>{let n=t===o-1?t-2:0===t?t:t-1;return n+=i?24575:0,[n,e]};for(let t=0;tt()))},t.dB=sx,t.dC=yx,t.dD=function(t){px=ki.resolveURL(t),gx||(gx=new ox(ux(),new zn)),gx.broadcast("setDracoUrl",px)},t.dE=vx,t.dF=function(t){mx=ki.resolveURL(t),gx||(gx=new ox(ux(),new zn)),gx.broadcast("setMeshoptUrl",mx)},t.dG=ti,t.dH=ba,t.dI=dh,t.dJ=I_,t.dK=eg,t.dL=dc,t.dM=am,t.dN=Dm,t.dO=Wf,t.dP=ci,t.dQ=E_,t.dR=jg,t.dS=function(t,e,i,n,r,o,s,a,l,c,d){t.createArrays(),t.tilePixelRatio=uo/(512*t.overscaling),t.compareText={},t.iconsNeedLinear=!1;const u=t.layers[0].layout,h=t.layers[0]._unevaluatedLayout._values,p={};if("composite"===t.textSizeData.kind){const{minZoom:e,maxZoom:i}=t.textSizeData;p.compositeTextSizes=[h["text-size"].possiblyEvaluate(new Ha(e),a),h["text-size"].possiblyEvaluate(new Ha(i),a)]}if("composite"===t.iconSizeData.kind){const{minZoom:e,maxZoom:i}=t.iconSizeData;p.compositeIconSizes=[h["icon-size"].possiblyEvaluate(new Ha(e),a),h["icon-size"].possiblyEvaluate(new Ha(i),a)]}p.layoutTextSize=h["text-size"].possiblyEvaluate(new Ha(l+1),a),p.layoutIconSize=h["icon-size"].possiblyEvaluate(new Ha(l+1),a),p.textMaxSize=h["text-size"].possiblyEvaluate(new Ha(18),a);const f="map"===u.get("text-rotation-alignment")&&"point"!==u.get("symbol-placement"),m=u.get("text-size");let _=!1;for(const e of t.features)if(e.icon&&e.icon.nameSecondary){_=!0;break}for(const o of t.features){const l=u.get("text-font").evaluate(o,{},a).join(","),h=m.evaluate(o,{},a),g=p.layoutTextSize.evaluate(o,{},a),y=(p.layoutIconSize.evaluate(o,{},a),{horizontal:{},vertical:void 0}),v=o.text;let x,b=[0,0];if(v){const n=v.toString(),s=u.get("text-letter-spacing").evaluate(o,{},a)*Om,c=u.get("text-line-height").evaluate(o,{},a)*Om,d=Aa(n)?s:0,p=u.get("text-anchor").evaluate(o,{},a),m=u.get("text-variable-anchor");if(!m){const t=u.get("text-radial-offset").evaluate(o,{},a);b=t?G_(p,[t*Om,j_]):u.get("text-offset").evaluate(o,{},a).map((t=>t*Om))}let _=f?"center":u.get("text-justify").evaluate(o,{},a);const x="point"===u.get("symbol-placement"),w=x?u.get("text-max-width").evaluate(o,{},a)*Om:1/0,T=o=>{t.allowVerticalPlacement&&Ca(n)&&(y.vertical=e_(v,e,i,r,l,w,c,p,o,d,b,Jm.vertical,!0,g,h))};if(!f&&m){const t="auto"===_?m.map((t=>Z_(t))):[_];let n=!1;for(let o=0;o=0||!Ca(n)){const t=e_(v,e,i,r,l,w,c,p,_,d,b,Jm.horizontal,!1,g,h);t&&(y.horizontal[_]=t)}T(x?"left":_)}}let w=!1;if(o.icon&&o.icon.namePrimary){const e=n[o.icon.namePrimary];e&&(x=u_(r[o.icon.namePrimary],o.icon.nameSecondary?r[o.icon.nameSecondary]:void 0,u.get("icon-offset").evaluate(o,{},a),u.get("icon-anchor").evaluate(o,{},a)),w=e.sdf,void 0===t.sdfIcons?t.sdfIcons=e.sdf:t.sdfIcons!==e.sdf&&pi("Style sheet warning: Cannot mix SDF and non-SDF icons in one buffer"),(e.pixelRatio!==t.pixelRatio||0!==u.get("icon-rotate").constantOr(1))&&(t.iconsNeedLinear=!0))}const T=X_(y.horizontal)||y.vertical;t.iconsInText||(t.iconsInText=!!T&&T.iconsInText),(T||x)&&q_(t,o,y,x,n,p,g,0,b,w,s,a,c,d,_)}o&&t.generateCollisionDebugBuffers(l,t.collisionBoxArray)},t.dT=Jf,t.dU=Yh,t.dV=bp,t.dW=Lm,t.dX=Yp,t.dY=Zy,t.dZ=wp,t.d_=cp,t.da=Wu,t.db=function(e){const i=[0,0,0],n=t.ad.identity(new Float64Array(16));return t.ad.multiply(n,e.pixelMatrix,e.globeMatrix),t._.transformMat4(i,i,n),new Ue(i[0],i[1])},t.dc=d,t.dd=c,t.de=function(t){const e=t.navigator?t.navigator.userAgent:null;return!!function(t){if(null==Ei){const e=t.navigator?t.navigator.userAgent:null;Ei=!!t.safari||!(!e||!(/\b(iPad|iPhone|iPod)\b/.test(e)||e.match("Safari")&&!e.match("Chrome")))}return Ei}(t)&&e&&(e.match("Version/15.4")||e.match("Version/15.5")||e.match(/CPU (OS|iPhone OS) (15_4|15_5) like Mac OS X/))},t.df=ni,t.dg=class{constructor(t,e,i){this._transformRequestFn=t,this._customAccessToken=e,this._silenceAuthErrors=!!i,this._createSkuToken()}_createSkuToken(){const t=function(){let t="";for(let e=0;ethis._skuTokenExpiresAt}transformRequest(t,e){return this._transformRequestFn&&this._transformRequestFn(t,e)||{url:t}}normalizeStyleURL(t,i){if(!o(t))return t;const n=un(t);return n.params.push(`sdk=js-${e}`),n.path=`/styles/v1${n.path}`,this._makeAPIURL(n,this._customAccessToken||i)}normalizeGlyphsURL(t,e){if(!o(t))return t;const i=un(t);return i.path=`/fonts/v1${i.path}`,this._makeAPIURL(i,this._customAccessToken||e)}normalizeModelURL(t,e){if(!o(t))return t;const i=un(t);return i.path=`/models/v1${i.path}`,this._makeAPIURL(i,this._customAccessToken||e)}normalizeSourceURL(t,e,i,n){if(!o(t))return t;const r=un(t);return r.path=`/v4/${r.authority}.json`,r.params.push("secure"),i&&r.params.push(`language=${i}`),n&&r.params.push(`worldview=${n}`),this._makeAPIURL(r,this._customAccessToken||e)}normalizeSpriteURL(t,e,i,n){const r=un(t);return o(t)?(r.path=`/styles/v1${r.path}/sprite${e}${i}`,this._makeAPIURL(r,this._customAccessToken||n)):(r.path+=`${e}${i}`,hn(r))}normalizeTileURL(t,e,i){if(this._isSkuTokenExpired()&&this._createSkuToken(),t&&!o(t))return t;const r=un(t);r.path=r.path.replace(/(\.(png|jpg)\d*)(?=$)/,`${e||i&&"raster"!==r.authority&&512===i?"@2x":""}${Gi.supported?".webp":"$1"}`),"raster"===r.authority?r.path=`/${n.RASTER_URL_PREFIX}${r.path}`:"rasterarrays"===r.authority?r.path=`/${n.RASTERARRAYS_URL_PREFIX}${r.path}`:"3dtiles"===r.authority?r.path=`/${n.TILES3D_URL_PREFIX}${r.path}`:(r.path=r.path.replace(/^.+\/v4\//,"/"),r.path=`/${n.TILE_URL_VERSION}${r.path}`);const s=this._customAccessToken||function(t){for(const e of t){const t=e.match(/^access_token=(.*)$/);if(t)return t[1]}return null}(r.params)||n.ACCESS_TOKEN;return n.REQUIRE_ACCESS_TOKEN&&s&&this._skuToken&&r.params.push(`sku=${this._skuToken}`),this._makeAPIURL(r,s)}canonicalizeTileURL(t,e){const i=un(t);if(!i.path.match(/^(\/v4\/|\/(raster|rasterarrays)\/v1\/)/)||!i.path.match(/\.[\w]+$/))return t;let r="mapbox://";i.path.match(/^\/raster\/v1\//)?r+=`raster/${i.path.replace(`/${n.RASTER_URL_PREFIX}/`,"")}`:i.path.match(/^\/rasterarrays\/v1\//)?r+=`rasterarrays/${i.path.replace(`/${n.RASTERARRAYS_URL_PREFIX}/`,"")}`:r+=`tiles/${i.path.replace(`/${n.TILE_URL_VERSION}/`,"")}`;let o=i.params;return e&&(o=o.filter((t=>!t.match(/^access_token=/)))),o.length&&(r+=`?${o.join("&")}`),r}canonicalizeTileset(t,e){const i=!!e&&o(e),n=[];for(const e of t.tiles||[])r(e)?n.push(this.canonicalizeTileURL(e,i)):n.push(e);return n}_makeAPIURL(t,e){const i="See https://docs.mapbox.com/api/overview/#access-tokens-and-token-scopes",r=un(n.API_URL);if(t.protocol=r.protocol,t.authority=r.authority,"http"===t.protocol){const e=t.params.indexOf("secure");e>=0&&t.params.splice(e,1)}if("/"!==r.path&&(t.path=`${r.path}${t.path}`),!n.REQUIRE_ACCESS_TOKEN)return hn(t);if(e=e||n.ACCESS_TOKEN,!this._silenceAuthErrors){if(!e)throw new Error(`An API access token is required to use Mapbox GL. ${i}`);if("s"===e[0])throw new Error(`Use a public access token (pk.*) with Mapbox GL, not a secret access token (sk.*). ${i}`)}return t.params=t.params.filter((t=>-1===t.indexOf("access_token"))),t.params.push(`access_token=${e||""}`),hn(t)}},t.dh=function(t,e){e?Mn.add(t):Mn.delete(t)},t.di=Gi,t.dj=Tn,t.dk=En,t.dl=cn,t.dm=vn,t.dn=bn,t.dp=function(t){Mn.delete(t)},t.dq=Sn,t.dr=yn,t.ds=Qe,t.dt=e,t.du=function(t,e){Fi=t,Ni=e},t.dv=function(t,e,i=!1){if(Fa===za||Fa===Ra||Fa===Oa)throw new Error("setRTLTextPlugin cannot be called multiple times.");Na=ki.resolveURL(t),Fa=za,Ba=e,ja(),i||Za()},t.dw=Ga,t.dx=function(){ux().acquire(lx)},t.dy=function(){const t=dx;t&&(t.isPreloaded()&&1===t.numActive()?(t.release(lx),dx=null):console.warn("Could not clear WebWorkers since there are active Map instances that still reference it. The pre-warmed WebWorker pool can only be cleared when all map instances have been removed with map.remove()"))},t.dz=cx,t.e=ki,t.e0=cm,t.e1=h,t.e2=en,t.e3=function(t){let e=0;if(new Uint32Array(t,0,1)[0]!==Ax){const i=new Uint32Array(t,0,7),[,,n,r,o,s]=i;e=i.byteLength+r+o+s+o,(n!==t.byteLength||e>=t.byteLength)&&pi("Invalid b3dm header information.")}return Dx(t,e)},t.e4=function(t,e){const i=jx(t);for(const t of i){for(const e of t.meshes)Vx(e);t.lights&&(t.lightMeshIndex=t.meshes.length,t.meshes.push(Gx(t.lights,e)))}return i},t.e5=Kx,t.e6=rx,t.e7=qa,t.e8=function(t){ji(),Oi&&Oi.then((e=>{e.keys().then((i=>{for(let n=0;nt.arrayBuffer())).then((e=>Dx(e,0,t)))},t.m=class extends Uv{},t.n=Er,t.o=qn,t.p=Qg,t.q=Xs,t.r=Js,t.s=Qs,t.t=ca,t.u=al,t.v=ll,t.w=pi,t.x=pa,t.y=da,t.z=qo})),n(0,(function(t){function e(t){const e=t?t.url.toString():void 0;return e?performance.getEntriesByName(e):[]}function i(t){if("number"==typeof t||"boolean"==typeof t||"string"==typeof t||null==t)return JSON.stringify(t);if(Array.isArray(t)){let e="[";for(const n of t)e+=`${i(n)},`;return`${e}]`}let e="{";for(const n of Object.keys(t).sort())e+=`${n}:${i(t[n])},`;return`${e}}`}function n(e){let n="";for(const r of t.cE)n+=`/${i(e[r])}`;return n}class r{constructor(t){this.keyCache={},this._layers={},this._layerConfigs={},t&&this.replace(t)}replace(t,e){this._layerConfigs={},this._layers={},this.update(t,[],e)}update(e,i,r){this._options=r;for(const i of e)this._layerConfigs[i.id]=i,(this._layers[i.id]=t.cY(i,this.scope,null,this._options)).compileFilter(),this.keyCache[i.id]&&delete this.keyCache[i.id];for(const t of i)delete this.keyCache[t],delete this._layerConfigs[t],delete this._layers[t];this.familiesBySource={};const o=function(t,e){const i={};for(let r=0;rthis._layers[t.id])),i=e[0];if("none"===i.visibility)continue;const n=i.source||"";let r=this.familiesBySource[n];r||(r=this.familiesBySource[n]={});const o=i.sourceLayer||"_geojsonTileLayer";let s=r[o];s||(s=r[o]=[]),s.push(e)}}}const o=1*t.dJ;class s{constructor(e){const i={},n=[];for(const t in e){const r=e[t],s=i[t]={};for(const t in r.glyphs){const e=r.glyphs[+t];if(!e||0===e.bitmap.width||0===e.bitmap.height)continue;const i=e.metrics.localGlyph?o:1,a={x:0,y:0,w:e.bitmap.width+2*i,h:e.bitmap.height+2*i};n.push(a),s[t]=a}}const{w:r,h:s}=t.j(n),a=new t.dI({width:r||1,height:s||1});for(const n in e){const r=e[n];for(const e in r.glyphs){const s=r.glyphs[+e];if(!s||0===s.bitmap.width||0===s.bitmap.height)continue;const l=i[n][e],c=s.metrics.localGlyph?o:1;t.dI.copy(s.bitmap,a,{x:0,y:0},{x:l.x+c,y:l.y+c},s.bitmap)}}this.image=a,this.positions=i}}t.dH(s,"GlyphAtlas");class a{constructor(e){this.tileID=new t.aL(e.tileID.overscaledZ,e.tileID.wrap,e.tileID.canonical.z,e.tileID.canonical.x,e.tileID.canonical.y),this.tileZoom=e.tileZoom,this.uid=e.uid,this.zoom=e.zoom,this.lut=e.lut,this.canonical=e.tileID.canonical,this.pixelRatio=e.pixelRatio,this.tileSize=e.tileSize,this.source=e.source,this.scope=e.scope,this.overscaling=this.tileID.overscaleFactor(),this.showCollisionBoxes=e.showCollisionBoxes,this.collectResourceTiming=!!e.collectResourceTiming,this.promoteId=e.promoteId,this.isSymbolTile=e.isSymbolTile,this.tileTransform=t.dK(e.tileID.canonical,e.projection),this.projection=e.projection,this.brightness=e.brightness,this.extraShadowCaster=!!e.extraShadowCaster,this.tessellationStep=e.tessellationStep}parse(e,i,n,r,o){this.status="parsing",this.data=e,this.collisionBoxArray=new t.dL;const a=new t.dM(Object.keys(e.layers).sort()),c=new t.dN(this.tileID,this.promoteId);c.bucketLayerIDs=[];const d={},u=new t.dO(256,256),h={featureIndex:c,iconDependencies:{},patternDependencies:{},glyphDependencies:{},lineAtlas:u,availableImages:n,brightness:this.brightness},p=i.familiesBySource[this.source];for(const i in p){const r=e.layers[i];if(!r)continue;let o=!1,s=!1,u=!1;for(const t of p[i])"symbol"===t[0].type?o=!0:s=!0,t[0].is3D()&&"model"!==t[0].type&&(u=!0);if(this.extraShadowCaster&&!u)continue;if(!0===this.isSymbolTile&&!o)continue;if(!1===this.isSymbolTile&&!s)continue;1===r.version&&t.w(`Vector tile source "${this.source}" layer "${i}" does not use vector tile spec v2 and therefore may have some rendering errors.`);const f=a.encode(i),m=[];for(let t=0;t=e.maxzoom||"none"!==e.visibility&&(l(t,this.zoom,h.brightness,n),(d[e.id]=e.createBucket({index:c.bucketLayerIDs.length,layers:t,zoom:this.zoom,lut:this.lut,canonical:this.canonical,pixelRatio:this.pixelRatio,overscaling:this.overscaling,collisionBoxArray:this.collisionBoxArray,sourceLayerIndex:f,sourceID:this.source,projection:this.projection.spec,tessellationStep:this.tessellationStep})).populate(m,h,this.tileID.canonical,this.tileTransform),c.bucketLayerIDs.push(t.map((t=>t.id)))))}}let f,m,_,g;u.trim();const y={type:"maybePrepare",isSymbolTile:this.isSymbolTile,zoom:this.zoom},v=()=>{if(f)return this.status="done",o(f);if(this.extraShadowCaster)this.status="done",o(null,{buckets:t.dG(d).filter((t=>!t.isEmpty())),featureIndex:c,collisionBoxArray:null,glyphAtlasImage:null,lineAtlas:null,imageAtlas:null,brightness:h.brightness,glyphMap:null,iconMap:null,glyphPositions:null});else if(m&&_&&g){const e=new s(m),i=new t.dQ(_,g,this.lut);for(const r in d){const o=d[r];o instanceof t.dR?(l(o.layers,this.zoom,h.brightness,n),t.dS(o,m,e.positions,_,i.iconPositions,this.showCollisionBoxes,n,this.tileID.canonical,this.tileZoom,this.projection,this.brightness)):o.hasPattern&&(o instanceof t.dT||o instanceof t.dU||o instanceof t.b_)&&(l(o.layers,this.zoom,h.brightness,n),o.addFeatures(h,this.tileID.canonical,i.patternPositions,n,this.tileTransform,this.brightness))}this.status="done",o(null,{buckets:t.dG(d).filter((t=>!t.isEmpty())),featureIndex:c,collisionBoxArray:this.collisionBoxArray,glyphAtlasImage:e.image,lineAtlas:u,imageAtlas:i,brightness:h.brightness})}};if(!this.extraShadowCaster){const e=t.dP(h.glyphDependencies,(t=>Object.keys(t).map(Number)));Object.keys(e).length?r.send("getGlyphs",{uid:this.uid,stacks:e,scope:this.scope},((t,e)=>{f||(f=t,m=e,v())}),void 0,!1,y):m={};const i=Object.keys(h.iconDependencies);i.length?r.send("getImages",{icons:i,source:this.source,scope:this.scope,tileID:this.tileID,type:"icons"},((t,e)=>{f||(f=t,_=e,v())}),void 0,!1,y):_={};const n=Object.keys(h.patternDependencies);n.length?r.send("getImages",{icons:n,source:this.source,scope:this.scope,tileID:this.tileID,type:"patterns"},((t,e)=>{f||(f=t,g=e,v())}),void 0,!1,y):g={}}v()}}function l(e,i,n,r){const o=new t.X(i,{brightness:n});for(const t of e)t.recalculate(o,r)}class c extends t.E{constructor(e,i,n,r,o,s){super(),this.actor=e,this.layerIndex=i,this.availableImages=n,this.loadVectorData=o||t.ap,this.loading={},this.loaded={},this.deduped=new t.ao(e.scheduler),this.isSpriteLoaded=r,this.scheduler=e.scheduler,this.brightness=s}loadTile(i,n){const r=i.uid,o=i&&i.request,s=o&&o.collectResourceTiming,l=this.loading[r]=new a(i);l.abort=this.loadVectorData(i,((a,c)=>{const d=!this.loading[r];if(delete this.loading[r],d||a||!c)return l.status="done",d||(this.loaded[r]=l),n(a);const u=c.rawData,h={};c.expires&&(h.expires=c.expires),c.cacheControl&&(h.cacheControl=c.cacheControl),l.vectorTile=c.vectorTile||new t.dV(new t.dW(u));const p=()=>{l.parse(l.vectorTile,this.layerIndex,this.availableImages,this.actor,((i,r)=>{if(i||!r)return n(i);const a={};if(s){const t=e(o);t.length>0&&(a.resourceTiming=JSON.parse(JSON.stringify(t)))}n(null,t.W({rawTileData:u.slice(0)},r,h,a))}))};this.isSpriteLoaded?p():this.once("isSpriteLoaded",(()=>{this.scheduler?this.scheduler.add(p,{type:"parseTile",isSymbolTile:i.isSymbolTile,zoom:i.tileZoom}):p()})),this.loaded=this.loaded||{},this.loaded[r]=l}))}reloadTile(e,i){const n=this.loaded,r=e.uid;if(n&&n[r]){const o=n[r];o.showCollisionBoxes=e.showCollisionBoxes,o.projection=e.projection,o.brightness=e.brightness,o.tileTransform=t.dK(e.tileID.canonical,e.projection),o.extraShadowCaster=e.extraShadowCaster,o.lut=e.lut;const s=(t,e)=>{const n=o.reloadCallback;n&&(delete o.reloadCallback,o.parse(o.vectorTile,this.layerIndex,this.availableImages,this.actor,n)),i(t,e)};"parsing"===o.status?o.reloadCallback=s:"done"===o.status&&(o.vectorTile?o.parse(o.vectorTile,this.layerIndex,this.availableImages,this.actor,s):s())}else i(null,void 0)}abortTile(t,e){const i=t.uid,n=this.loading[i];n&&(n.abort&&n.abort(),delete this.loading[i]),e()}removeTile(t,e){const i=this.loaded,n=t.uid;i&&i[n]&&delete i[n],e()}}class d{loadTile(e,i){const{uid:n,encoding:r,rawImageData:o,padding:s}=e,a=ImageBitmap&&o instanceof ImageBitmap?this.getImageData(o,s):o;i(null,new t.dX(n,a,r,s{n(null,t)}),(t=>{n(t)}))}}const h=t.dZ.prototype.toGeoJSON;let p=class{constructor(e){this._feature=e,this.extent=t.a3,this.type=e.type,this.properties=e.tags,"id"in e&&!isNaN(e.id)&&(this.id=parseInt(e.id,10))}loadGeometry(){if(1===this._feature.type){const e=[];for(const i of this._feature.geometry)e.push([new t.P(i[0],i[1])]);return e}{const e=[];for(const i of this._feature.geometry){const n=[];for(const e of i)n.push(new t.P(e[0],e[1]));e.push(n)}return e}}toGeoJSON(t,e,i){return h.call(this,t,e,i)}},f=class{constructor(e){this.layers={_geojsonTileLayer:this},this.name="_geojsonTileLayer",this.extent=t.a3,this.length=e.length,this._features=e}feature(t){return new p(this._features[t])}};const m=64/4096;class _{constructor(){this.features=new Map}clear(){this.features.clear()}load(t=[],e){for(const i of t){const t=i.id;if(null==t)continue;let n=this.features.get(t);n&&this.updateCache(n,e),i.geometry?(n=y(i),this.updateCache(n,e),this.features.set(t,n)):this.features.delete(t),this.updateCache(n,e)}}updateCache(t,e){for(const{canonical:i,uid:n}of Object.values(e)){const{z:r,x:o,y:s}=i;g(t,Math.pow(2,r),o,s)&&delete e[n]}}getTile(t,e,i){const n=Math.pow(2,t),r=[];for(const t of this.features.values())g(t,n,e,i)&&r.push(w(t,n,e,i));return{features:r}}getFeatures(){return[...this.features.values()]}}function g({minX:t,minY:e,maxX:i,maxY:n},r,o,s){return t(o-m)/r&&n>(s-m)/r}function y(t){const{id:e,geometry:i,properties:n}=t;if(!i)return;if("GeometryCollection"===i.type)throw new Error("GeometryCollection not supported in dynamic mode.");const{type:r,coordinates:o}=i,s={id:e,type:1,geometry:[],tags:n,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0},a=s.geometry;if("Point"===r)v(o,a,s);else if("MultiPoint"===r)for(const t of o)v(t,a,s);else if("LineString"===r)s.type=2,x(o,a,s);else if("MultiLineString"===r)s.type=2,b(o,a,s);else if("Polygon"===r)s.type=3,b(o,a,s,!0);else{if("MultiPolygon"!==r)throw new Error("Input data is not a valid GeoJSON object.");s.type=3;for(const t of o)b(t,a,s,!0)}return s}function v([e,i],n,r){const o=t.aj(e);let s=t.ak(i);s=s1?1:s,n.push(o,s),r.minX=Math.min(r.minX,o),r.minY=Math.min(r.minY,s),r.maxX=Math.max(r.maxX,o),r.maxY=Math.max(r.maxY,s)}function x(t,e,i,n=!1,r=!1){const o=[];for(const e of t)v(e,o,i);e.push(o),n&&function(t,e){let i=0;for(let e=0,n=t.length,r=n-2;e0===e)for(let e=0,i=t.length;e>31}function F(t,e){for(var i=t.loadGeometry(),n=t.type,r=0,o=0,s=i.length,a=0;at},V=Math.fround||(G=new Float32Array(1),t=>(G[0]=+t,G[0]));var G;const Z=3,q=5,H=6;class W{constructor(t){this.options=Object.assign(Object.create(j),t),this.trees=new Array(this.options.maxZoom+1),this.stride=this.options.reduce?7:6,this.clusterProps=[]}load(t){const{log:e,minZoom:i,maxZoom:n}=this.options;e&&console.time("total time");const r=`prepare ${t.length} points`;e&&console.time(r),this.points=t;const o=[];for(let e=0;e=i;t--){const i=+Date.now();s=this.trees[t]=this._createTree(this._cluster(s,t)),e&&console.log("z%d: %d clusters in %dms",t,s.numItems,+Date.now()-i)}return e&&console.timeEnd("total time"),this}getClusters(t,e){let i=((t[0]+180)%360+360)%360-180;const n=Math.max(-90,Math.min(90,t[1]));let r=180===t[2]?180:((t[2]+180)%360+360)%360-180;const o=Math.max(-90,Math.min(90,t[3]));if(t[2]-t[0]>=360)i=-180,r=180;else if(i>r){const t=this.getClusters([i,n,180,o],e),s=this.getClusters([-180,n,r,o],e);return t.concat(s)}const s=this.trees[this._limitZoom(e)],a=s.range(K(i),J(o),K(r),J(n)),l=s.data,c=[];for(const t of a){const e=this.stride*t;c.push(l[e+q]>1?Y(l,e,this.clusterProps):this.points[l[e+Z]])}return c}getChildren(t){const e=this._getOriginId(t),i=this._getOriginZoom(t),n="No cluster with the specified id.",r=this.trees[i];if(!r)throw new Error(n);const o=r.data;if(e*this.stride>=o.length)throw new Error(n);const s=this.options.radius/(this.options.extent*Math.pow(2,i-1)),a=r.within(o[e*this.stride],o[e*this.stride+1],s),l=[];for(const e of a){const i=e*this.stride;o[i+4]===t&&l.push(o[i+q]>1?Y(o,i,this.clusterProps):this.points[o[i+Z]])}if(0===l.length)throw new Error(n);return l}getLeaves(t,e,i){const n=[];return this._appendLeaves(n,t,e=e||10,i=i||0,0),n}getTile(t,e,i){const n=this.trees[this._limitZoom(t)],r=Math.pow(2,t),{extent:o,radius:s}=this.options,a=s/o,l=(i-a)/r,c=(i+1+a)/r,d={features:[]};return this._addTileFeatures(n.range((e-a)/r,l,(e+1+a)/r,c),n.data,e,i,r,d),0===e&&this._addTileFeatures(n.range(1-a/r,l,1,c),n.data,r,i,r,d),e===r-1&&this._addTileFeatures(n.range(0,l,a/r,c),n.data,-1,i,r,d),d.features.length?d:null}getClusterExpansionZoom(t){let e=this._getOriginZoom(t)-1;for(;e1;let l,c,d;if(a)l=X(e,t,this.clusterProps),c=e[t],d=e[t+1];else{const i=this.points[e[t+Z]];l=i.properties;const[n,r]=i.geometry.coordinates;c=K(n),d=J(r)}const u={type:1,geometry:[[Math.round(this.options.extent*(c*r-i)),Math.round(this.options.extent*(d*r-n))]],tags:l};let h;h=a||this.options.generateId?e[t+Z]:this.points[e[t+Z]].id,void 0!==h&&(u.id=h),o.features.push(u)}}_limitZoom(t){return Math.max(this.options.minZoom,Math.min(Math.floor(+t),this.options.maxZoom+1))}_cluster(t,e){const{radius:i,extent:n,reduce:r,minPoints:o}=this.options,s=i/(n*Math.pow(2,e)),a=t.data,l=[],c=this.stride;for(let i=0;ie&&(p+=a[i+q])}if(p>h&&p>=o){let t,o=n*h,s=d*h,f=-1;const m=(i/c1)for(const t of u){const i=t*c;if(!(a[i+2]>5}_getOriginZoom(t){return(t-this.points.length)%32}_map(t,e,i){if(t[e+q]>1){const n=this.clusterProps[t[e+H]];return i?Object.assign({},n):n}const n=this.points[t[e+Z]].properties,r=this.options.map(n);return i&&r===n?Object.assign({},r):r}}function Y(t,e,i){return{type:"Feature",id:t[e+Z],properties:X(t,e,i),geometry:{type:"Point",coordinates:[(n=t[e],360*(n-.5)),Q(t[e+1])]}};var n}function X(t,e,i){const n=t[e+q],r=n>=1e4?`${Math.round(n/1e3)}k`:n>=1e3?Math.round(n/100)/10+"k":n,o=t[e+H],s=-1===o?{}:Object.assign({},i[o]);return Object.assign(s,{cluster:!0,cluster_id:t[e+Z],point_count:n,point_count_abbreviated:r})}function K(t){return t/360+.5}function J(t){const e=Math.sin(t*Math.PI/180),i=.5-.25*Math.log((1+e)/(1-e))/Math.PI;return i1?1:i}function Q(t){const e=(180-360*t)*Math.PI/180;return 360*Math.atan(Math.exp(e))/Math.PI-90}function tt(t,e,i,n){let r=n;const o=e+(i-e>>1);let s,a=i-e;const l=t[e],c=t[e+1],d=t[i],u=t[i+1];for(let n=e+3;n 0)for(let r=e;r=e;r-=n)o=jh(r/n|0,t[r],t[r+1],o);return o&&Rh(o,o.next)&&(Vh(o),o=o.next),o}function wh(t,e){if(!t)return t;e||(e=t);let i,n=t;do{if(i=!1,n.steiner||!Rh(n,n.next)&&0!==zh(n.prev,n,n.next))n=n.next;else{if(Vh(n),n=e=n.prev,n===n.next)break;i=!0}}while(i||n!==e);return e}function Th(t,e,i,n,r,o,s){if(!t)return;!s&&o&&function(t,e,i,n){let r=t;do{0===r.z&&(r.z=Ph(r.x,r.y,e,i,n)),r.prevZ=r.prev,r.nextZ=r.next,r=r.next}while(r!==t);r.prevZ.nextZ=null,r.prevZ=null,function(t){let e,i=1;do{let n,r=t;t=null;let o=null;for(e=0;r;){e++;let s=r,a=0;for(let t=0;t0||l>0&&s;)0!==a&&(0===l||!s||r.z1)}(r)}(t,n,r,o);let a=t;for(;t.prev!==t.next;){const l=t.prev,c=t.next;if(o?Eh(t,n,r,o):Sh(t))e.push(l.i,t.i,c.i),Vh(t),t=c.next,a=c.next;else if((t=c)===a){s?1===s?Th(t=Mh(wh(t),e),e,i,n,r,o,2):2===s&&Ch(t,e,i,n,r,o):Th(wh(t),e,i,n,r,o,1);break}}}function Sh(t){const e=t.prev,i=t,n=t.next;if(zh(e,i,n)>=0)return!1;const r=e.x,o=i.x,s=n.x,a=e.y,l=i.y,c=n.y,d=ro?r>s?r:s:o>s?o:s,p=a>l?a>c?a:c:l>c?l:c;let f=n.next;for(;f!==e;){if(f.x>=d&&f.x=u&&f.y=0)return!1;f=f.next}return!0}function Eh(t,e,i,n){const r=t.prev,o=t,s=t.next;if(zh(r,o,s)>=0)return!1;const a=r.x,l=o.x,c=s.x,d=r.y,u=o.y,h=s.y,p=al?a>c?a:c:l>c?l:c,_=d>u?d>h?d:h:u>h?u:h,g=Ph(p,f,e,i,n),y=Ph(m,_,e,i,n);let v=t.prevZ,x=t.nextZ;for(;v&&v.z>=g&&x&&x.z=p&&v.x=f&&v.y=0)return!1;if(v=v.prevZ,x.x>=p&&x.x=f&&x.y=0)return!1;x=x.nextZ}for(;v&&v.z>=g;){if(v.x>=p&&v.x=f&&v.y=0)return!1;v=v.prevZ}for(;x&&x.z=p&&x.x=f&&x.y=0)return!1;x=x.nextZ}return!0}function Mh(t,e){let i=t;do{const n=i.prev,r=i.next.next;!Rh(n,r)&&Oh(n,i,i.next,r)&&Nh(n,r)&&Nh(r,n)&&(e.push(n.i,i.i,r.i),Vh(i),Vh(i.next),i=t=r),i=i.next}while(i!==t);return wh(i)}function Ch(t,e,i,n,r,o){let s=t;do{let t=s.next.next;for(;t!==s.prev;){if(s.i!==t.i&&Dh(s,t)){let a=Uh(s,t);return s=wh(s,s.next),a=wh(a,a.next),Th(s,e,i,n,r,o,0),void Th(a,e,i,n,r,o,0)}t=t.next}s=s.next}while(s!==t)}function Ah(t,e){return t.x-e.x}function Ih(t,e){const i=function(t,e){let i=e;const n=t.x,r=t.y;let o,s=-1/0;do{if(r=i.next.y&&i.next.y!==i.y){const t=i.x+(r-i.y)*(i.next.x-i.x)/(i.next.y-i.y);if(ts&&(s=t,o=i.x=i.x&&i.x>=l&&n!==i.x&&kh(ro.x||i.x===o.x&&Lh(o,i)))&&(o=i,d=e)}i=i.next}while(i!==a);return o}(t,e);if(!i)return e;const n=Uh(i,t);return wh(n,n.next),wh(i,i.next)}function Lh(t,e){return zh(t.prev,t,e.prev)=(t-s)*(o-a)&&(t-s)*(n-a)>=(i-s)*(e-a)&&(i-s)*(o-a)>=(r-s)*(n-a)}function Dh(t,e){return t.next.i!==e.i&&t.prev.i!==e.i&&!function(t,e){let i=t;do{if(i.i!==t.i&&i.next.i!==t.i&&i.i!==e.i&&i.next.i!==e.i&&Oh(i,i.next,t,e))return!0;i=i.next}while(i!==t);return!1}(t,e)&&(Nh(t,e)&&Nh(e,t)&&function(t,e){let i=t,n=!1;const r=(t.x+e.x)/2,o=(t.y+e.y)/2;do{i.y>o!=i.next.y>o&&i.next.y!==i.y&&r0&&zh(e.prev,e,e.next)>0)}function zh(t,e,i){return(e.y-t.y)*(i.x-e.x)-(e.x-t.x)*(i.y-e.y)}function Rh(t,e){return t.x===e.x&&t.y===e.y}function Oh(t,e,i,n){const r=Fh(zh(t,e,i)),o=Fh(zh(t,e,n)),s=Fh(zh(i,n,t)),a=Fh(zh(i,n,e));return r!==o&&s!==a||!(0!==r||!Bh(t,i,e))||!(0!==o||!Bh(t,n,e))||!(0!==s||!Bh(i,t,n))||!(0!==a||!Bh(i,e,n))}function Bh(t,e,i){return e.x=Math.min(t.x,i.x)&&e.y=Math.min(t.y,i.y)}function Fh(t){return t>0?1:t=0&&zh(t,t.prev,e)>=0:zh(t,e,t.prev)1)for(let t=0;tt.fqid)),this.index=t.index,this.hasPattern=!1,this.patternFeatures=[],this.layoutVertexArray=new $l,this.indexArray=new Kl,this.indexArray2=new ql,this.programConfigurations=new Yc(t.layers,{zoom:t.zoom,lut:t.lut}),this.segments=new wc,this.segments2=new wc,this.stateDependentLayerIds=this.layers.filter((t=>t.isStateDependent())).map((t=>t.id)),this.projection=t.projection}updateFootprints(t,e){}populate(t,e,i,n){this.hasPattern=Hh("fill",this.layers,e);const r=this.layers[0].layout.get("fill-sort-key"),o=[];for(const{feature:s,id:a,index:l,sourceLayerIndex:c}of t){const t=this.layers[0]._featureFilter.needGeometry,d=Zd(s,t);if(!this.layers[0]._featureFilter.filter(new Ha(this.zoom),d,i))continue;const u=r?r.evaluate(d,{},i,e.availableImages):void 0,h={id:a,properties:s.properties,type:s.type,sourceLayerIndex:c,index:l,geometry:t?d.geometry:Gd(s,i,n),patterns:{},sortKey:u};o.push(h)}r&&o.sort(((t,e)=>t.sortKey-e.sortKey));for(const n of o){const{geometry:r,index:o,sourceLayerIndex:s}=n;if(this.hasPattern){const t=Wh("fill",this.layers,n,this.zoom,e);this.patternFeatures.push(t)}else this.addFeature(n,r,o,i,{},e.availableImages,e.brightness);e.featureIndex.insert(t[o].feature,r,o,s,this.index)}}update(t,e,i,n,r){const o=0!==Object.keys(t).length;o&&!this.stateDependentLayers.length||this.programConfigurations.updatePaintArrays(t,e,o?this.stateDependentLayers:this.layers,i,n,r)}addFeatures(t,e,i,n,r,o){for(const t of this.patternFeatures)this.addFeature(t,t.geometry,t.index,e,i,n,o)}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(t){this.uploaded||(this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,vh),this.indexBuffer=t.createIndexBuffer(this.indexArray),this.indexBuffer2=t.createIndexBuffer(this.indexArray2)),this.programConfigurations.upload(t),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.indexBuffer2.destroy(),this.programConfigurations.destroy(),this.segments.destroy(),this.segments2.destroy())}addFeature(t,e,i,n,r,o=[],s){for(const t of Zh(e,500)){let e=0;for(const i of t)e+=i.length;const i=this.segments.prepareSegment(e,this.layoutVertexArray,this.indexArray),n=i.vertexLength,r=[],o=[];for(const e of t){if(0===e.length)continue;e!==t[0]&&o.push(r.length/2);const i=this.segments2.prepareSegment(e.length,this.layoutVertexArray,this.indexArray2),n=i.vertexLength;this.layoutVertexArray.emplaceBack(e[0].x,e[0].y),this.indexArray2.emplaceBack(n+e.length-1,n),r.push(e[0].x),r.push(e[0].y);for(let t=1;tt.cellIdx-e.cellIdx||t.triIdx-e.triIdx));let c=0;for(;cthis.max.x||this.min.x>t.x||t.y>this.max.y||this.min.y>t.y)return;const i=Qh(t.x-this.min.x,this.xScale,this.cellsX),n=Qh(t.y-this.min.y,this.yScale,this.cellsY),r=this.cells[n*this.cellsX+i];if(r){this._lazyInitLookup();for(let t=0;tthis.max.x||this.min.x>e.x)return;if(t.y>this.max.y||this.min.y>e.y)return;this._lazyInitLookup();const n=Qh(t.x-this.min.x,this.xScale,this.cellsX),r=Qh(e.x-this.min.x,this.xScale,this.cellsX),o=Qh(t.y-this.min.y,this.yScale,this.cellsY),s=Qh(e.y-this.min.y,this.yScale,this.cellsY);for(let t=o;tt.fqid)),this.index=t.index,this.hasPattern=!1,this.stateDependentLayerIds=this.layers.filter((t=>t.isStateDependent())).map((t=>t.id)),this.footprints=[]}updateFootprints(t,e){for(const i of this.footprints)e.push({footprint:i,id:t})}populate(t,e,i,n){const r=[];for(const{feature:e,id:o,index:s,sourceLayerIndex:a}of t){const t=this.layers[0]._featureFilter.needGeometry,l=Zd(e,t);if(!this.layers[0]._featureFilter.filter(new Ha(this.zoom),l,i))continue;const c={id:o,properties:e.properties,type:e.type,sourceLayerIndex:a,index:s,geometry:t?l.geometry:Gd(e,i,n),patterns:{}};r.push(c)}for(const n of r){const{geometry:r,index:o,sourceLayerIndex:s}=n;this.addFeature(n,r,o,i,{},e.availableImages,e.brightness),e.featureIndex.insert(t[o].feature,r,o,s,this.index)}}isEmpty(){return 0===this.footprints.length}uploadPending(){return!1}upload(t){}update(t,e,i,n,r){}destroy(){}addFeature(t,e,i,n,r,o=[],s){for(const t of Zh(e,2)){const e=[],i=[],n=[],r=new Ue(1/0,1/0),o=new Ue(-1/0,-1/0);for(const s of t)if(0!==s.length){s!==t[0]&&n.push(i.length/2);for(let t=0;t>3}if(r--,1===n||2===n)o+=t.readSVarint(),s+=t.readSVarint(),1===n&&(e&&a.push(e),e=[]),e.push(new dp(o,s));else{if(7!==n)throw new Error("unknown command "+n);e&&e.push(e[0].clone())}}return e&&a.push(e),a},hp.prototype.bbox=function(){var t=this._pbf;t.pos=this._geometry;for(var e=t.readVarint()+t.pos,i=1,n=0,r=0,o=0,s=1/0,a=-1/0,l=1/0,c=-1/0;t.pos>3}if(n--,1===i||2===i)(r+=t.readSVarint())a&&(a=r),(o+=t.readSVarint())c&&(c=o);else if(7!==i)throw new Error("unknown command "+i)}return[s,l,a,c]},hp.prototype.toGeoJSON=function(t,e,i){var n,r,o=this.extent*Math.pow(2,i),s=this.extent*t,a=this.extent*e,l=this.loadGeometry(),c=hp.types[this.type];function d(t){for(var e=0;e>3;e=1===n?t.readString():2===n?t.readFloat():3===n?t.readDouble():4===n?t.readVarint64():5===n?t.readVarint():6===n?t.readSVarint():7===n?t.readBoolean():null}return e}(i))}gp.prototype.feature=function(t){if(t=this._features.length)throw new Error("feature index out of bounds");this._pbf.pos=this._features[t];var e=this._pbf.readVarint()+this._pbf.pos;return new mp(this._pbf,e,this.extent,this._keys,this._values)};var vp=_p;function xp(t,e,i){if(3===t){var n=new vp(i,i.readVarint()+i.pos);n.length&&(e[n.name]=n)}}var bp=cp.VectorTile=function(t,e){this.layers=t.readFields(xp,{},e)},wp=cp.VectorTileFeature=up;cp.VectorTileLayer=_p;class Tp extends Ue{constructor(t,e,i){super(t,e),this.z=i}}class Sp extends Tp{constructor(t,e,i,n){super(t,e,i),this.w=n}}function Ep(t,e,i,n){const r=[],o=0===n?(t,e,i,n,r,o)=>{t.push(new Ue(o,i+(o-e)/(n-e)*(r-i)))}:(t,e,i,n,r,o)=>{t.push(new Ue(e+(o-i)/(r-i)*(n-e),o))};for(const s of t){const t=[];for(const r of s){if(r.lengthe&&o(s,a,l,c,d,e):u>i?h=e&&o(s,a,l,c,d,e),h>i&&u=e&&l=s[i]&&(n=e,s=t),n[i]r&&Mp(n,s,i,r),n[i]o&&Mp(s,n,i,o)}}function Ap(t,e){return t.x-e.x||t.y-e.y}function Ip(t,e){return 0===Ap(t.min,e.min)&&0===Ap(t.max,e.max)}function Lp(t,e){return!(t.min.x>e.max.x||t.max.xe.max.y||t.max.ynew Ue((t.x+o.x*uo)*a-s.x*uo,(t.y+o.y*uo)*a-s.y*uo)))}return Dp(i,r,t.indices,0,t.indices.length,0,0)}function Rp(t,e,i,n){const r=Math.pow(2,n.z-i.z);return new Ue((t+i.x*uo)*r-n.x*uo,(e+i.y*uo)*r-n.y*uo)}function Op(t,e){const i=[];e.footprint.grid.queryPoint(t,i);const n=e.footprint.indices,r=e.footprint.vertices;for(let e=0;ee[s])return null}else{const a=1/n[s];let l=(t[s]-i[s])*a,c=(e[s]-i[s])*a;if(l>c){const t=l;l=c,c=t}if(l>r&&(r=l),co)return null}return r}function Np(t,e,i,n,r,o,s,a,l,c,d){const u=n-t,h=r-e,p=o-i,f=s-t,m=a-e,_=l-i,g=d[1]*_-d[2]*m,y=d[2]*f-d[0]*_,v=d[0]*m-d[1]*f,x=u*g+h*y+p*v;if(Math.abs(x)1)return null;const M=T*p-S*h,C=S*u-w*p,A=w*h-T*u,I=(d[0]*M+d[1]*C+d[2]*A)*b;return I1?null:(f*M+m*C+_*A)*b}function Up(t,e,i){return(t-e)/(i-e)}function jp(t,e,i,n,r,o,s,a,l){const c=1{const o=n?1:0,s=(t+1)*i-o,a=e*i,l=(e+1)*i-o;r[0]=t*i,r[1]=a,r[2]=s,r[3]=l};let s=new Bp(n);const a=[];for(let e=0;e=1;n/=2){const t=i[i.length-1];s=new Bp(n);for(let e=0;e0;){const{idx:l,t:f,nodex:m,nodey:_,depth:g}=p.pop();if(this.leaves[l]){jp(m,_,g,e,i,n,r,u,h);const l=1=e[2])return f}continue}let y=0;for(let t=0;t=c[d[n]]&&(d.splice(n,0,t),i=!0);i||(d[y]=t),y++}}for(let t=0;t=this.dim+1||e=this.dim+1)throw new RangeError("out of range source coordinates for DEM data");return(e+1)*this.stride+(t+1)}static pack(t,e){const i=[0,0,0,0],n=Yp.getUnpackVector(e);let r=Math.floor((t+n[3])/n[2]);return i[2]=r%256,r=Math.floor(r/256),i[1]=r%256,r=Math.floor(r/256),i[0]=r,i}getPixels(){return new hh({width:this.stride,height:this.stride},this.pixels)}backfillBorder(t,e,i){if(this.dim!==t.dim)throw new Error("dem dimension mismatch");let n=e*this.dim,r=e*this.dim+this.dim,o=i*this.dim,s=i*this.dim+this.dim;switch(e){case-1:n=r-1;break;case 1:r=n+1}switch(i){case-1:o=s-1;break;case 1:s=o+1}const a=-e*this.dim,l=-i*this.dim;for(let e=o;et.max.x&&(t.max.x=e.x,n=!0),e.yt.max.y&&(t.max.y=e.y,n=!0),((0===e.x||e.x===uo)&&e.x===i.x)!=((0===e.y||e.y===uo)&&e.y===i.y)&&this.processBorderOverlap(e,i),n&&this.checkBorderIntersection(e,i)}checkBorderIntersection(t,e){e.xuo!=t.x>uo&&this.addBorderIntersection(1,Vn(e.y,t.y,(uo-e.x)/(t.x-e.x))),e.yuo!=t.y>uo&&this.addBorderIntersection(3,Vn(e.x,t.x,(uo-e.y)/(t.y-e.y)))}addBorderIntersection(t,e){this.borders||(this.borders=[[Number.MAX_VALUE,-Number.MAX_VALUE],[Number.MAX_VALUE,-Number.MAX_VALUE],[Number.MAX_VALUE,-Number.MAX_VALUE],[Number.MAX_VALUE,-Number.MAX_VALUE]]);const i=this.borders[t];ei[1]&&(i[1]=e)}processBorderOverlap(t,e){if(t.x===e.x){if(t.y===e.y)return;const i=0===t.x?0:1;this.addBorderIntersection(i,e.y),this.addBorderIntersection(i,t.y)}else{const i=0===t.y?2:3;this.addBorderIntersection(i,e.x),this.addBorderIntersection(i,t.x)}}centroid(){return 0===this.accCount?new Ue(0,0):new Ue(Math.floor(Math.max(0,this.acc.x)/this.accCount),Math.floor(Math.max(0,this.acc.y)/this.accCount))}intersectsCount(){return this.borders?this.borders.reduce(((t,e)=>t+ +(e[0]!==Number.MAX_VALUE)),0):0}}function hf(t,e){const i=t.add(e)._unit(),n=Xe(t.x*i.x+t.y*i.y,-1,1);var r,o,s;return r=Math.acos(n),Math.min(4,Math.max(-4,Math.tan(r)))/4*nf*((o=t).x*(s=e).y-o.y*s.xt.xt.x>uo,t=>t.yt.y>uo];function ff(t,e,i,n){const r=[4];if(0===n)return r;i._mult(n);const o=t.sub(i),s=e.sub(i),a=[t,e,o,s];for(let t=0;ttf.includes(t))),this._segments=new wc,this.hiddenByLandmarkVertexArray=new lc,this._segmentToGroundQuads={},this._segmentToGroundQuads[0]=[],this._segmentToRegionTriCounts={},this._segmentToRegionTriCounts[0]=[0,0,0,0,0],this.regionSegments={},this.regionSegments[4]=new wc}getDefaultSegment(){return this.regionSegments[4]}hasData(){return 0!==this.vertexArray.length}addData(t,e,i,n=!1){const r=t.length;if(r>2){let o=Math.max(0,this._segments.get().length-1);const s=this._segments._prepareSegment(4*r,this.vertexArray.length,2*this._segmentToGroundQuads[o].length);let a;o!==this._segments.get().length-1&&(o++,this._segmentToGroundQuads[o]=[],this._segmentToRegionTriCounts[o]=[0,0,0,0,0]);{const e=t[0],i=t[1];a=hf(e.sub(t[r-1])._perp()._unit(),i.sub(e)._perp()._unit())}for(let l=0;lt.region-e.region));for(let i=0;it+e),0);let o=0;for(let t=0;t0?this.hiddenByLandmarkVertexBuffer=t.createVertexBuffer(this.hiddenByLandmarkVertexArray,sp.members,!0):this.hiddenByLandmarkVertexBuffer&&this.hiddenByLandmarkVertexBuffer.updateData(this.hiddenByLandmarkVertexArray),this._needsHiddenByLandmarkUpdate=!1)}destroy(){if(this.vertexBuffer){this.vertexBuffer.destroy(),this.indexBuffer.destroy(),this.hiddenByLandmarkVertexBuffer&&this.hiddenByLandmarkVertexBuffer.destroy(),this._segments&&this._segments.destroy(),this.programConfigurations.destroy();for(let t=0;tt.fqid)),this.index=t.index,this.hasPattern=!1,this.edgeRadius=0,this.projection=t.projection,this.activeReplacements=[],this.replacementUpdateTime=0,this.centroidData=[],this.footprintIndices=new Kl,this.footprintVertices=new $l,this.footprintSegments=[],this.layoutVertexArray=new Dl,this.centroidVertexArray=new vc,this.indexArray=new Kl,this.programConfigurations=new Yc(t.layers,{zoom:t.zoom,lut:t.lut},(t=>Qp.includes(t))),this.segments=new wc,this.stateDependentLayerIds=this.layers.filter((t=>t.isStateDependent())).map((t=>t.id)),this.groundEffect=new mf(t),this.maxHeight=0,this.partLookup={},this.triangleSubSegments=[],this.polygonSegments=[]}updateFootprints(t,e){}populate(t,e,i,n){this.features=[],this.hasPattern=Hh("fill-extrusion",this.layers,e),this.featuresOnBorder=[],this.borderFeatureIndices=[[],[],[],[]],this.borderDoneWithNeighborZ=[-1,-1,-1,-1],this.tileToMeter=zd(i),this.edgeRadius=this.layers[0].layout.get("fill-extrusion-edge-radius")/this.tileToMeter;for(const{feature:r,id:o,index:s,sourceLayerIndex:a}of t){const t=this.layers[0]._featureFilter.needGeometry,l=Zd(r,t);if(!this.layers[0]._featureFilter.filter(new Ha(this.zoom),l,i))continue;const c={id:o,sourceLayerIndex:a,index:s,geometry:t?l.geometry:Gd(r,i,n),properties:r.properties,type:r.type,patterns:{}},d=this.layoutVertexArray.length;this.hasPattern?this.features.push(Wh("fill-extrusion",this.layers,c,this.zoom,e)):this.addFeature(c,c.geometry,s,i,{},e.availableImages,n,e.brightness),e.featureIndex.insert(r,c.geometry,s,a,this.index,d)}this.sortBorders(),"mercator"===this.projection.name&&this.splitToSubtiles(),this.groundEffect.prepareBorderSegments(),this.polygonSegments.length=0}addFeatures(t,e,i,n,r,o){for(const t of this.features){const{geometry:s}=t;this.addFeature(t,s,t.index,e,i,n,r,o)}this.sortBorders(),"mercator"===this.projection.name&&this.splitToSubtiles()}update(t,e,i,n,r){const o=0!==Object.keys(t).length;if(o&&!this.stateDependentLayers.length)return;const s=o?this.stateDependentLayers:this.layers;this.programConfigurations.updatePaintArrays(t,e,s,i,n,r),this.groundEffect.update(t,e,s,i,n,r)}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload||this.groundEffect.programConfigurations.needsUpload}upload(t){this.uploaded||(this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,lp),this.indexBuffer=t.createIndexBuffer(this.indexArray),this.layoutVertexExtArray&&(this.layoutVertexExtBuffer=t.createVertexBuffer(this.layoutVertexExtArray,ap.members,!0)),this.groundEffect.upload(t)),this.groundEffect.uploadPaintProperties(t),this.programConfigurations.upload(t),this.uploaded=!0}uploadCentroid(t){this.groundEffect.uploadHiddenByLandmark(t),this.needsCentroidUpdate&&(!this.centroidVertexBuffer&&this.centroidVertexArray.length>0?this.centroidVertexBuffer=t.createVertexBuffer(this.centroidVertexArray,op.members,!0):this.centroidVertexBuffer&&this.centroidVertexBuffer.updateData(this.centroidVertexArray),this.needsCentroidUpdate=!1)}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.centroidVertexBuffer&&this.centroidVertexBuffer.destroy(),this.layoutVertexExtBuffer&&this.layoutVertexExtBuffer.destroy(),this.groundEffect.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy())}addFeature(t,e,i,n,r,o,s,a){const l=this.layers[0].paint.get("fill-extrusion-flood-light-ground-radius").evaluate(t,{})/this.tileToMeter,c=[new Ue(0,0),new Ue(uo,uo)],d=s.projection,u="globe"===d.name,h="Polygon"===Jp[t.type],p=new uf;p.centroidDataIndex=this.centroidData.length;const f=new df,m=this.layers[0].paint.get("fill-extrusion-base").evaluate(t,{},n)=0;t--){const e=g[t];(0===e.length||(y=e[0]).every((t=>t.xt.x>=uo))||y.every((t=>t.yt.y>=uo)))&&g.splice(t,1)}var y;let v;if(u)v=Ef(g,c,n);else{v=[];for(const t of g)v.push({polygon:t,bounds:c})}const x=h?this.edgeRadius:0,b=x>0&&this.zoom{if(0===t.length)return!1;const i=t[t.length-1];return e.x===i.x&&e.y===i.y};for(const{polygon:t,bounds:e}of v){let i=0,r=0;for(const e of t)h&&!e[0].equals(e[e.length-1])&&e.push(e[0]),r+=h?e.length-1:e.length;const o=this.segments.prepareSegment((h?5:4)*r,this.layoutVertexArray,this.indexArray);f.footprintSegIdx4&&wf(s[s.length-2],s[0],s[1]),c=x?yf(s[s.length-2],s[0],s[1],x):0;const _=[];let g,y,v;y=s[1].sub(s[0])._perp()._unit();let b=!0;for(let t=1,r=0;t0?1:0,C=l.dist(h);if(r+C>32768&&(r=0),x){v=T.sub(h)._perp()._unit();let t=vf(l,h,T,gf(y,v),x);isNaN(t)&&(t=0);const e=h.sub(l)._unit();l=l.add(e.mult(c))._round(),h=h.add(e.mult(-t))._round(),c=t,y=v,m&&this.zoom>=17&&(w(_,l)||_.push(l),w(_,h)||_.push(h))}const A=o.vertexLength,I=s.length>4&&wf(l,h,T);let L=Tf(r,a,b);if(sf(this.layoutVertexArray,l.x,l.y,E,M,0,0,L),sf(this.layoutVertexArray,l.x,l.y,E,M,0,1,L),r+=C,L=Tf(r,I,!b),a=I,sf(this.layoutVertexArray,h.x,h.y,E,M,0,0,L),sf(this.layoutVertexArray,h.x,h.y,E,M,0,1,L),o.vertexLength+=4,this.indexArray.emplaceBack(A+0,A+1,A+2),this.indexArray.emplaceBack(A+1,A+3,A+2),o.primitiveLength+=2,x){const n=i+(1===t?s.length-2:t-2),r=1===t?i:n+1;if(this.indexArray.emplaceBack(A+1,n,A+3),this.indexArray.emplaceBack(n,r,A+3),o.primitiveLength+=2,void 0===g&&(g=A),!xf(T,s[t],e)){const e=t===s.length-1?g:o.vertexLength;this.indexArray.emplaceBack(A+2,A+3,e),this.indexArray.emplaceBack(A+3,e+1,e),this.indexArray.emplaceBack(A+3,r,e+1),o.primitiveLength+=3}b=!b}if(u){const t=this.layoutVertexExtArray,e=d.projectTilePoint(l.x,l.y,n),i=d.projectTilePoint(h.x,h.y,n),r=d.upVector(n,l.x,l.y),o=d.upVector(n,h.x,h.y);lf(t,e,r),lf(t,e,r),lf(t,i,o),lf(t,i,o)}}h&&(i+=s.length-1),m&&x&&this.zoom>=17&&(0!==_.length&&w(_,_[0])&&_.pop(),this.groundEffect.addData(_,e,l,x>0))}this.footprintSegments.push(a),s.triangleCount=this.indexArray.length-s.triangleArrayOffset,this.polygonSegments.push(s),++f.footprintSegLen,++f.polygonSegLen}if(f.vertexCount=this.layoutVertexArray.length-f.vertexArrayOffset,f.groundVertexCount=this.groundEffect.vertexArray.length-f.groundVertexArrayOffset,0!==f.vertexCount){if(f.centroidXY=p.borders?rf:this.encodeCentroid(p,f),this.centroidData.push(f),p.borders){this.featuresOnBorder.push(p);const t=this.featuresOnBorder.length-1;for(let e=0;ethis.featuresOnBorder[e].borders[t][0]-this.featuresOnBorder[i].borders[t][0]))}splitToSubtiles(){const t=[];for(let e=0;euo),r=2*n+(+(i.min.x+i.max.x>uo)^n);for(let n=0;nt.triangleSegmentIdx===e.triangleSegmentIdx?t.subtile-e.subtile:t.triangleSegmentIdx-e.triangleSegmentIdx));let i=0,n=0,r=0;for(const e of t){if(e.triangleSegmentIdx!==i)break;r++}const o=t.length;for(;n!==t.length;){i=t[n].triangleSegmentIdx;let s=0,a=n,l=n;for(let e=a;e0&&this.triangleSubSegments.push({segment:d,min:o,max:c}),a=l;for(let e=a;e[t[0]*(1-i[0])+e[0]*i[0],t[1]*(1-i[1])+e[1]*i[1]],h=[],p=[];for(const t of this.triangleSubSegments){h[0]=t.min.x/uo,h[1]=t.min.y/uo,p[0]=t.max.x/uo,p[1]=t.max.y/uo;const e=u(l,c,h),o=u(l,c,p);if(0===new wu([e[0],e[1],n],[o[0],o[1],r]).intersectsPrecise(i)){a&&(d.segments.push(a),a=void 0);continue}const s=t.segment;a&&a.vertexOffset!==s.vertexOffset&&(d.segments.push(a),a=void 0),a?(a.vertexLength+=s.vertexLength,a.primitiveLength+=s.primitiveLength):a={vertexOffset:s.vertexOffset,primitiveLength:s.primitiveLength,vertexLength:s.vertexLength,primitiveOffset:s.primitiveOffset,sortKey:void 0,vaos:{}}}return a&&d.segments.push(a),d}encodeCentroid(t,e){const i=t.centroid(),n=e.span(),r=Math.min(7,Math.round(n.x*this.tileToMeter/10)),o=Math.min(7,Math.round(n.y*this.tileToMeter/10));return new Ue(Xe(i.x,1,uo-1)i.max.x||i.min.x>e.max.x||e.min.y>i.max.y||i.min.y>e.max.y))for(let o=0;oe!=l>e&&to.max.x||o.min.x>t||e>o.max.y||o.min.y>e||this.footprintContainsPoint(t,e,o)&&o&&o.height>i&&(i=o.height,this.partLookup[r]=o,n=!!(o.flags&of));if(i!==Number.NEGATIVE_INFINITY)return{height:i,hidden:n};this.partLookup[r]=void 0}}function gf(t,e){const i=t.add(e)._unit();return t.x*i.x+t.y*i.y}function yf(t,e,i,n){const r=e.sub(t)._perp()._unit(),o=i.sub(e)._perp()._unit();return vf(t,e,i,gf(r,o),n)}function vf(t,e,i,n,r){const o=Math.sqrt(1-n*n);return Math.min(t.dist(e)/3,e.dist(i)/3,r*o/n)}function xf(t,e,i){return t.xi[1].x&&e.x>i[1].x||t.yi[1].y&&e.y>i[1].y}function bf(t,e){return t.xe[1].x||t.ye[1].y}function wf(t,e,i){if(t.x=uo||e.x=uo||i.x=uo)return!1;const n=i.sub(e),r=n.perp(),o=t.sub(e);return(n.x*o.x+n.y*o.y)/Math.sqrt((n.x*n.x+n.y*n.y)*(o.x*o.x+o.y*o.y))>-.866&&r.x*o.x+r.y*o.y{for(const i of t)s.push({polygon:i,bounds:e})},l=Math.ceil(Math.log2(i)),c=Math.ceil(Math.log2(n)),d=l-c,u=[];for(let t=0;t0?0:1);for(let t=0;te+1?p.push({polygons:h,bounds:t,depth:e+1}):a(h,t)}if(f.length){const t=[new Ue(0===i?d:n.x,1===i?d:n.y),s];u.length>e+1?p.push({polygons:f,bounds:t,depth:e+1}):a(f,t)}}return s}(t,e,Math.ceil((o-r)/11.25),Math.ceil((s-a)/11.25),1,((t,e,r)=>{if(0===t)return.5*(e+r);{const t=Id((i.y+e/uo)/n);return(Md(.5*(Id((i.y+r/uo)/n)+t))*n-i.y)*uo}}))}function Mf(t,e,i,n,r,o){const s=Math.pow(2,n.z-r.z);for(let a=0;a1&&(s=t[++o]);const l=Math.abs(a-s.left),c=Math.abs(a-s.right),d=Math.min(l,c);let u;const h=e/i*(n+1);if(s.isDash){const t=n-Math.abs(h);u=Math.sqrt(d*d+t*t)}else u=n-Math.sqrt(d*d+h*h);this.image.data[r+a]=Math.max(0,Math.min(255,u+128))}}}addRegularDash(t,e){for(let e=t.length-1;e>=0;--e){const i=t[e],n=t[e+1];i.zeroLength?t.splice(e,1):n&&n.isDash===i.isDash&&(n.left=i.left,t.splice(e,1))}const i=t[0],n=t[t.length-1];i.isDash===n.isDash&&(i.left=n.left-this.width,n.right=i.right+this.width);const r=this.width*this.nextRow;let o=0,s=t[o];for(let i=0;i1&&(s=t[++o]);const n=Math.abs(i-s.left),a=Math.abs(i-s.right),l=Math.min(n,a);this.image.data[r+i]=Math.max(0,Math.min(255,(s.isDash?l:-l)+e+128))}}addDash(t,e){const i=this.getKey(t,e);if(this.positions[i])return this.positions[i];const n="round"===e,r=n?7:0,o=2*r+1;if(this.nextRow+o>this.height)return pi("LineAtlas out of space"),null;0===t.length&&t.push(1);let s=0;for(let e=0;et.fqid)),this.index=t.index,this.projection=t.projection,this.hasPattern=!1,this.hasZOffset=!1,this.patternFeatures=[],this.lineClipsArray=[],this.gradients={},this.layers.forEach((t=>{this.gradients[t.id]={}})),this.layoutVertexArray=new Rl,this.layoutVertexArray2=new Ol,this.patternVertexArray=new Bl,this.indexArray=new Kl,this.programConfigurations=new Yc(t.layers,{zoom:t.zoom,lut:t.lut}),this.segments=new wc,this.maxLineLength=0,this.zOffsetVertexArray=new Zl,this.stateDependentLayerIds=this.layers.filter((t=>t.isStateDependent())).map((t=>t.id)),this.tessellationStep=t.tessellationStep?t.tessellationStep:uo/64}updateFootprints(t,e){}populate(t,e,i,n){this.hasPattern=Hh("line",this.layers,e);const r=this.layers[0].layout.get("line-sort-key"),o=this.layers[0].layout.get("line-z-offset");this.hasZOffset=!o.isConstant()||!!o.constantOr(0);const s=[];for(const{feature:e,id:o,index:a,sourceLayerIndex:l}of t){const t=this.layers[0]._featureFilter.needGeometry,c=Zd(e,t);if(!this.layers[0]._featureFilter.filter(new Ha(this.zoom),c,i))continue;const d=r?r.evaluate(c,{},i):void 0,u={id:o,properties:e.properties,type:e.type,sourceLayerIndex:l,index:a,geometry:t?c.geometry:Gd(e,i,n),patterns:{},sortKey:d};s.push(u)}r&&s.sort(((t,e)=>t.sortKey-e.sortKey));const{lineAtlas:a,featureIndex:l}=e,c=this.addConstantDashes(a);for(const n of s){const{geometry:r,index:o,sourceLayerIndex:s}=n;if(c&&this.addFeatureDashes(n,a),this.hasPattern){const t=Wh("line",this.layers,n,this.zoom,e);this.patternFeatures.push(t)}else this.addFeature(n,r,o,i,a.positions,e.availableImages,e.brightness);l.insert(t[o].feature,r,o,s,this.index)}}addConstantDashes(t){let e=!1;for(const i of this.layers){const n=i.paint.get("line-dasharray").value,r=i.layout.get("line-cap").value;if("constant"!==n.kind||"constant"!==r.kind)e=!0;else{const e=r.value,i=n.value;if(!i)continue;t.addDash(i,e)}}return e}addFeatureDashes(t,e){const i=this.zoom;for(const n of this.layers){const r=n.paint.get("line-dasharray").value,o=n.layout.get("line-cap").value;if("constant"===r.kind&&"constant"===o.kind)continue;let s,a;if("constant"===r.kind){if(s=r.value,!s)continue}else s=r.evaluate({zoom:i},t);a="constant"===o.kind?o.value:o.evaluate({zoom:i},t),e.addDash(s,a),t.patterns[n.id]=e.getKey(s,a)}}update(t,e,i,n,r){const o=0!==Object.keys(t).length;o&&!this.stateDependentLayers.length||this.programConfigurations.updatePaintArrays(t,e,o?this.stateDependentLayers:this.layers,i,n,r)}addFeatures(t,e,i,n,r,o){for(const t of this.patternFeatures)this.addFeature(t,t.geometry,t.index,e,i,n,o)}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(t){this.uploaded||(0!==this.layoutVertexArray2.length&&(this.layoutVertexBuffer2=t.createVertexBuffer(this.layoutVertexArray2,zf)),0!==this.patternVertexArray.length&&(this.patternVertexBuffer=t.createVertexBuffer(this.patternVertexArray,Of)),!this.zOffsetVertexBuffer&&this.zOffsetVertexArray.length>0&&(this.zOffsetVertexBuffer=t.createVertexBuffer(this.zOffsetVertexArray,jf.members,!0)),this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,kf),this.indexBuffer=t.createIndexBuffer(this.indexArray)),this.programConfigurations.upload(t),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.zOffsetVertexBuffer&&this.zOffsetVertexBuffer.destroy(),this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy())}lineFeatureClips(t){if(t.properties&&t.properties.hasOwnProperty("mapbox_clip_start")&&t.properties.hasOwnProperty("mapbox_clip_end"))return{start:+t.properties.mapbox_clip_start,end:+t.properties.mapbox_clip_end}}addFeature(t,e,i,n,r,o,s){const a=this.layers[0].layout,l=a.get("line-join").evaluate(t,{}),c=a.get("line-cap").evaluate(t,{}),d=a.get("line-miter-limit"),u=a.get("line-round-limit");this.lineClips=this.lineFeatureClips(t);for(const i of e)this.addLine(i,t,n,l,c,d,u);this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,t,i,r,o,n,s)}addLine(t,e,i,n,r,o,s){this.distance=0,this.scaledDistance=0,this.totalDistance=0,this.lineSoFar=0,this.currentVertex=void 0;const a={zoom:this.zoom,lineProgress:void 0},l=this.layers[0].layout,c="none"===n;if(this.patternJoinNone=this.hasPattern&&c,this.segmentStart=0,this.segmentStartf32=0,this.segmentPoints=[],this.lineClips){this.lineClipsArray.push(this.lineClips);for(let e=0;e=2&&t[u-1].equals(t[u-2]);)u--;let h=0;for(;h0;if(A&&i>h){const t=m.dist(_);if(t>2*p){const e=m.sub(m.sub(_)._mult(p/t)._round());this.updateDistance(_,e),this.addCurrentVertex(e,y,0,0,f,x),_=e}}if(b&&"round"===w&&(Mo&&(w="bevel"),"bevel"===w&&(M>2&&(w="flipbevel"),M100)S=v.mult(-1);else{const t=M*y.add(v).mag()/y.sub(v).mag();S._perp()._mult(t*(I?-1:1))}this.addCurrentVertex(m,S,0,0,f,x),this.addCurrentVertex(m,S.mult(-1),0,0,f,x)}else if("bevel"===w||"fakeround"===w){const t=-Math.sqrt(M*M-1),e=I?t:0,i=I?0:t;if(_&&this.addCurrentVertex(m,y,e,i,f,x),"fakeround"===w){const t=Math.round(180*C/Math.PI/20);for(let e=1;e2*p){const e=m.add(g.sub(m)._mult(p/t)._round());this.updateDistance(m,e),this.addCurrentVertex(e,v,0,0,f,x),m=e}}}}addVerticesTo(t,e,i,n,r,o,s,a,l,c){const d=(e.w-t.w)/this.tessellationStep|0;if(d>1){this.lineSoFar=t.w;const u=(e.x-t.x)/d,h=(e.y-t.y)/d,p=(e.z-t.z)/d,f=(e.w-t.w)/d;for(let e=1;e=0&&this.e2>=0&&(this.indexArray.emplaceBack(this.e1,this.e2,c),a.primitiveLength++),o?this.e2=c:this.e1=c,null!=l&&this.zOffsetVertexArray.emplaceBack(l)}updateScaledDistance(){if(this.lineClips){const t=this.totalDistance/(this.lineClips.end-this.lineClips.start);this.scaledDistance=this.distance/this.totalDistance,this.lineSoFar=t*this.lineClips.start+this.distance}else this.lineSoFar=this.distance}updateDistance(t,e){this.distance+=t.dist(e),this.updateScaledDistance()}}function Qf(t,e,i){return t.xi||t.yi}ba(Jf,"LineBucket",{omit:["layers","patternFeatures","currentVertex","currentVertexIsOutside"]});const tm=new ol({"line-cap":new nl(sl.layout_line["line-cap"]),"line-join":new nl(sl.layout_line["line-join"]),"line-miter-limit":new il(sl.layout_line["line-miter-limit"]),"line-round-limit":new il(sl.layout_line["line-round-limit"]),"line-sort-key":new nl(sl.layout_line["line-sort-key"]),"line-z-offset":new nl(sl.layout_line["line-z-offset"]),visibility:new il(sl.layout_line.visibility)});var em={paint:new ol({"line-opacity":new nl(sl.paint_line["line-opacity"]),"line-color":new nl(sl.paint_line["line-color"]),"line-translate":new il(sl.paint_line["line-translate"]),"line-translate-anchor":new il(sl.paint_line["line-translate-anchor"]),"line-width":new nl(sl.paint_line["line-width"]),"line-gap-width":new nl(sl.paint_line["line-gap-width"]),"line-offset":new nl(sl.paint_line["line-offset"]),"line-blur":new nl(sl.paint_line["line-blur"]),"line-dasharray":new nl(sl.paint_line["line-dasharray"]),"line-pattern":new nl(sl.paint_line["line-pattern"]),"line-gradient":new rl(sl.paint_line["line-gradient"]),"line-trim-offset":new il(sl.paint_line["line-trim-offset"]),"line-trim-fade-range":new il(sl.paint_line["line-trim-fade-range"]),"line-trim-color":new il(sl.paint_line["line-trim-color"]),"line-emissive-strength":new il(sl.paint_line["line-emissive-strength"]),"line-border-width":new nl(sl.paint_line["line-border-width"]),"line-border-color":new nl(sl.paint_line["line-border-color"]),"line-occlusion-opacity":new il(sl.paint_line["line-occlusion-opacity"])}),layout:tm};function im(t,e,i){return e*(uo/(t.tileSize*Math.pow(2,i-t.tileID.overscaledZ)))}function nm(t,e){return 1/im(t,1,e.tileZoom)}function rm(t,e,i,n){return t.translatePosMatrix(n||e.tileID.projMatrix,e,i.paint.get("line-translate"),i.paint.get("line-translate-anchor"))}const om=t=>{const e=[];sm(t)&&e.push("RENDER_LINE_DASH"),t.paint.get("line-gradient")&&e.push("RENDER_LINE_GRADIENT");const i=t.paint.get("line-trim-offset");0===i[0]&&0===i[1]||e.push("RENDER_LINE_TRIM_OFFSET"),0!==t.paint.get("line-border-width").constantOr(1)&&e.push("RENDER_LINE_BORDER");const n="none"===t.layout.get("line-join").constantOr("miter"),r=!!t.paint.get("line-pattern").constantOr(1);return n&&r&&e.push("LINE_JOIN_NONE"),e};function sm(t){const e=t.paint.get("line-dasharray").value;return e.value||"constant"!==e.kind}class am{constructor(t){this._stringToNumber={},this._numberToString=[];for(let e=0;e>1,d=-7,u=i?r-1:0,h=i?-1:1,p=t[e+u];for(u+=h,o=p&(1>=-d,d+=a;d>0;o=256*o+t[e+u],u+=h,d-=8);for(s=o&(1>=-d,d+=n;d>0;s=256*s+t[e+u],u+=h,d-=8);if(0===o)o=1-c;else{if(o===l)return s?NaN:1/0*(p?-1:1);s+=Math.pow(2,n),o-=c}return(p?-1:1)*s*Math.pow(2,o-n)},write:function(t,e,i,n,r,o){var s,a,l,c=8*o-r-1,d=(1>1,h=23===r?Math.pow(2,-24)-Math.pow(2,-77):0,p=n?0:o-1,f=n?1:-1,m=e=1?h/l:h*Math.pow(2,1-u))*l>=2&&(s++,l/=2),s+u>=d?(a=0,s=d):s+u>=1?(a=(e*l-1)*Math.pow(2,r),s+=u):(a=e*Math.pow(2,u-1)*Math.pow(2,r),s=0));r>=8;t[i+p]=255&a,p+=f,a/=256,r-=8);for(s=s0;t[i+p]=255&s,p+=f,s/=256,c-=8);t[i+p-f]|=128*m}},cm=um,dm=lm;function um(t){this.buf=ArrayBuffer.isView&&ArrayBuffer.isView(t)?t:new Uint8Array(t||0),this.pos=0,this.type=0,this.length=this.buf.length}um.Varint=0,um.Fixed64=1,um.Bytes=2,um.Fixed32=5;var hm=4294967296,pm=1/hm,fm="undefined"==typeof TextDecoder?null:new TextDecoder("utf8");function mm(t){return t.type===um.Bytes?t.readVarint()+t.pos:t.pos+1}function _m(t,e,i){return i?4294967296*e+(t>>>0):4294967296*(e>>>0)+(t>>>0)}function gm(t,e,i){var n=e=t;r--)i.buf[r+n]=i.buf[r]}function ym(t,e){for(var i=0;i>>8,t[i+2]=e>>>16,t[i+3]=e>>>24}function Im(t,e){return(t[e]|t[e+1]>3,o=this.pos;this.type=7&n,t(r,e,this),this.pos===o&&this.skip(n)}return e},readMessage:function(t,e){return this.readFields(t,e,this.readVarint()+this.pos)},readFixed32:function(){var t=Cm(this.buf,this.pos);return this.pos+=4,t},readSFixed32:function(){var t=Im(this.buf,this.pos);return this.pos+=4,t},readFixed64:function(){var t=Cm(this.buf,this.pos)+Cm(this.buf,this.pos+4)*hm;return this.pos+=8,t},readSFixed64:function(){var t=Cm(this.buf,this.pos)+Im(this.buf,this.pos+4)*hm;return this.pos+=8,t},readFloat:function(){var t=dm.read(this.buf,this.pos,!0,23,4);return this.pos+=4,t},readDouble:function(){var t=dm.read(this.buf,this.pos,!0,52,8);return this.pos+=8,t},readVarint:function(t){var e,i,n=this.buf;return e=127&(i=n[this.pos++]),i>4,r=12&&fm?function(t,e,i){return fm.decode(t.subarray(e,i))}(this.buf,e,t):function(t,e,i){for(var n="",r=e;r239?4:l>223?3:l>191?2:1;if(r+d>i)break;1===d?l=55296&&c=1114112)&&(c=null)),null===c?(c=65533,d=1):c>65535&&(c-=65536,n+=String.fromCharCode(c>>>10&1023|55296),c=56320|1023&c),n+=String.fromCharCode(c),r+=d}return n}(this.buf,e,t)},readBytes:function(){var t=this.readVarint()+this.pos,e=this.buf.subarray(this.pos,t);return this.pos=t,e},readPackedVarint:function(t,e){if(this.type!==um.Bytes)return t.push(this.readVarint(e));var i=mm(this);for(t=t||[];this.pos127;);else if(e===um.Bytes)this.pos=this.readVarint()+this.pos;else if(e===um.Fixed32)this.pos+=4;else{if(e!==um.Fixed64)throw new Error("Unimplemented type: "+e);this.pos+=8}},writeTag:function(t,e){this.writeVarint(t268435455||t=0?(i=t%4294967296|0,n=t/4294967296|0):(n=~(-t/4294967296),4294967295^(i=~(-t%4294967296))?i=i+1|0:(i=0,n=n+1|0)),t>=0x10000000000000000||t>>=7,i.buf[i.pos++]=127&t|128,t>>>=7,i.buf[i.pos++]=127&t|128,t>>>=7,i.buf[i.pos++]=127&t|128,i.buf[i.pos]=127&(t>>>=7)}(i,0,e),function(t,e){var i=(7&t)>>=3)?128:0),t&&(e.buf[e.pos++]=127&t|((t>>>=7)?128:0),t&&(e.buf[e.pos++]=127&t|((t>>>=7)?128:0),t&&(e.buf[e.pos++]=127&t|((t>>>=7)?128:0),t&&(e.buf[e.pos++]=127&t|((t>>>=7)?128:0),t&&(e.buf[e.pos++]=127&t)))))}(n,e)}(t,this):(this.realloc(4),this.buf[this.pos++]=127&t|(t>127?128:0),t>>=7)|(t>127?128:0),t>>=7)|(t>127?128:0),t>>7&127))))},writeSVarint:function(t){this.writeVarint(t55295&&n56319||o+1===e.length?(t[i++]=239,t[i++]=191,t[i++]=189):r=n;continue}if(n>6|192:(n>12|224:(t[i++]=n>>18|240,t[i++]=n>>12&63|128),t[i++]=n>>6&63|128),t[i++]=63&n|128)}return i}(this.buf,t,this.pos);var i=this.pos-e;i>=128&&gm(e,i,this),this.pos=e-1,this.writeVarint(i),this.pos+=i},writeFloat:function(t){this.realloc(4),dm.write(this.buf,t,this.pos,!0,23,4),this.pos+=4},writeDouble:function(t){this.realloc(8),dm.write(this.buf,t,this.pos,!0,52,8),this.pos+=8},writeBytes:function(t){var e=t.length;this.writeVarint(e),this.realloc(e);for(var i=0;i=128&&gm(i,n,this),this.pos=i-1,this.writeVarint(n),this.pos+=n},writeMessage:function(t,e,i){this.writeTag(t,um.Bytes),this.writeRawMessage(e,i)},writePackedVarint:function(t,e){e.length&&this.writeMessage(t,ym,e)},writePackedSVarint:function(t,e){e.length&&this.writeMessage(t,vm,e)},writePackedBoolean:function(t,e){e.length&&this.writeMessage(t,wm,e)},writePackedFloat:function(t,e){e.length&&this.writeMessage(t,xm,e)},writePackedDouble:function(t,e){e.length&&this.writeMessage(t,bm,e)},writePackedFixed32:function(t,e){e.length&&this.writeMessage(t,Tm,e)},writePackedSFixed32:function(t,e){e.length&&this.writeMessage(t,Sm,e)},writePackedFixed64:function(t,e){e.length&&this.writeMessage(t,Em,e)},writePackedSFixed64:function(t,e){e.length&&this.writeMessage(t,Mm,e)},writeBytesField:function(t,e){this.writeTag(t,um.Bytes),this.writeBytes(e)},writeFixed32Field:function(t,e){this.writeTag(t,um.Fixed32),this.writeFixed32(e)},writeSFixed32Field:function(t,e){this.writeTag(t,um.Fixed32),this.writeSFixed32(e)},writeFixed64Field:function(t,e){this.writeTag(t,um.Fixed64),this.writeFixed64(e)},writeSFixed64Field:function(t,e){this.writeTag(t,um.Fixed64),this.writeSFixed64(e)},writeVarintField:function(t,e){this.writeTag(t,um.Varint),this.writeVarint(e)},writeSVarintField:function(t,e){this.writeTag(t,um.Varint),this.writeSVarint(e)},writeStringField:function(t,e){this.writeTag(t,um.Bytes),this.writeString(e)},writeFloatField:function(t,e){this.writeTag(t,um.Fixed32),this.writeFloat(e)},writeDoubleField:function(t,e){this.writeTag(t,um.Fixed64),this.writeDouble(e)},writeBooleanField:function(t,e){this.writeVarintField(t,Boolean(e))}};var Lm=h(cm);const Pm=["id","tile","layer","source","sourceLayer","state"];class $m{constructor(t,e,i,n,r){this.type="Feature",this._vectorTileFeature=t,this._z=e,this._x=i,this._y=n,this.properties=t.properties,this.id=r}get geometry(){return void 0===this._geometry&&(this._geometry=this._vectorTileFeature.toGeoJSON(this._x,this._y,this._z).geometry),this._geometry}set geometry(t){this._geometry=t}toJSON(){const t={type:"Feature",state:void 0,geometry:this.geometry,properties:this.properties};for(const e of Pm)void 0!==this[e]&&(t[e]=this[e]);return t}}class km{constructor(){this.state={},this.stateChanges={},this.deletedStates={}}updateState(t,e,i){const n=String(e);if(this.stateChanges[t]=this.stateChanges[t]||{},this.stateChanges[t][n]=this.stateChanges[t][n]||{},ei(this.stateChanges[t][n],i),null===this.deletedStates[t]){this.deletedStates[t]={};for(const e in this.state[t])e!==n&&(this.deletedStates[t][e]=null)}else if(this.deletedStates[t]&&null===this.deletedStates[t][n]){this.deletedStates[t][n]={};for(const e in this.state[t][n])i[e]||(this.deletedStates[t][n][e]=null)}else for(const e in i)this.deletedStates[t]&&this.deletedStates[t][n]&&null===this.deletedStates[t][n][e]&&delete this.deletedStates[t][n][e]}removeFeatureState(t,e,i){if(null===this.deletedStates[t])return;const n=String(e);if(this.deletedStates[t]=this.deletedStates[t]||{},i&&void 0!==e)null!==this.deletedStates[t][n]&&(this.deletedStates[t][n]=this.deletedStates[t][n]||{},this.deletedStates[t][n][i]=null);else if(void 0!==e)if(this.stateChanges[t]&&this.stateChanges[t][n])for(i in this.deletedStates[t][n]={},this.stateChanges[t][n])this.deletedStates[t][n][i]=null;else this.deletedStates[t][n]=null;else this.deletedStates[t]=null}getState(t,e){const i=String(e),n=ei({},(this.state[t]||{})[i],(this.stateChanges[t]||{})[i]);if(null===this.deletedStates[t])return{};if(this.deletedStates[t]){const i=this.deletedStates[t][e];if(null===i)return{};for(const t in i)delete n[t]}return n}initializeTileState(t,e){t.setFeatureState(this.state,e)}coalesceChanges(t,e){const i={};for(const t in this.stateChanges){this.state[t]=this.state[t]||{};const e={};for(const i in this.stateChanges[t])this.state[t][i]||(this.state[t][i]={}),ei(this.state[t][i],this.stateChanges[t][i]),e[i]=this.state[t][i];i[t]=e}for(const t in this.deletedStates){this.state[t]=this.state[t]||{};const e={};if(null===this.deletedStates[t])for(const i in this.state[t])e[i]={},this.state[t][i]={};else for(const i in this.deletedStates[t]){if(null===this.deletedStates[t][i])this.state[t][i]={};else if(this.state[t][i])for(const e of Object.keys(this.deletedStates[t][i]))delete this.state[t][i][e];e[i]=this.state[t][i]}i[t]=i[t]||{},ei(i[t],e)}if(this.stateChanges={},this.deletedStates={},0!==Object.keys(i).length)for(const n in t)t[n].setFeatureState(i,e)}}class Dm{constructor(t,e){this.tileID=t,this.x=t.canonical.x,this.y=t.canonical.y,this.z=t.canonical.z,this.grid=new va(uo,16,0),this.featureIndexArray=new yc,this.promoteId=e,this.is3DTile=!1}insert(t,e,i,n,r,o=0,s=0){const a=this.featureIndexArray.length;this.featureIndexArray.emplaceBack(i,n,r,o);const l=this.grid;for(let t=0;t=0&&n[3]>=0&&l.insert(a,n[0],n[1],n[2],n[3])}}loadVTLayers(){if(!this.vtLayers){this.vtLayers=new bp(new Lm(this.rawTileData)).layers,this.sourceLayerCoder=new am(this.vtLayers?Object.keys(this.vtLayers).sort():["_geojsonTileLayer"]),this.vtFeatures={};for(const t in this.vtLayers)this.vtFeatures[t]=[]}return this.vtLayers}query(t,e,i,n){this.loadVTLayers();const r=t.params||{},o=dl(r.filter),s=t.tileResult,a=t.transform,l=s.bufferedTilespaceBounds,c=this.grid.query(l.min.x,l.min.y,l.max.x,l.max.y,((t,e,i,n)=>ou(s.bufferedTilespaceGeometry,t,e,i,n)));c.sort(Rm);let d=null;a.elevation&&c.length>0&&(d=Xp.create(a.elevation,this.tileID));const u={};let h;for(let l=0;l(m||(m=Gd(e,this.tileID.canonical,t.tileTransform)),i.queryIntersectsFeature(s,e,n,m,this.z,t.transform,t.pixelPosMatrix,d,r))))}return u}loadMatchingFeature(t,e,i,n,r,o,s,a,l){const{featureIndex:c,bucketIndex:d,sourceLayerIndex:u,layoutVertexArrayOffset:h}=e,p=this.bucketLayerIDs[d];if(n&&!function(t,e){for(let i=0;i=0)return!0;return!1}(n,p))return;const f=this.sourceLayerCoder.decode(u),m=this.vtLayers[f].feature(c);if(i.needGeometry){const t=Zd(m,!0);if(!i.filter(new Ha(this.tileID.overscaledZ),t,this.tileID.canonical))return}else if(!i.filter(new Ha(this.tileID.overscaledZ),m))return;const _=this.getId(m,f);for(let e=0;e{const s=e instanceof el?e.get(o):null;return s&&s.evaluate?s.evaluate(i,n,r):s}))}function Rm(t,e){return e-t}ba(Dm,"FeatureIndex",{omit:["rawTileData","sourceLayerCoder"]});var Om=24;const Bm=128;function Fm(t,e){const{expression:i}=e;if("constant"===i.kind)return{kind:"constant",layoutSize:i.evaluate(new Ha(t+1))};if("source"===i.kind)return{kind:"source"};{const{zoomStops:e,interpolationType:n}=i;let r=0;for(;r{t.text=function(t,e,i){const n=e.layout.get("text-transform").evaluate(i,{});return"uppercase"===n?t=t.toLocaleUpperCase():"lowercase"===n&&(t=t.toLocaleLowerCase()),qa.applyArabicShaping&&(t=qa.applyArabicShaping(t)),t}(t.text,e,i)})),t}const Gm={"!":"︕","#":"#",$:"$","%":"%","&":"&","(":"︵",")":"︶","*":"*","+":"+",",":"︐","-":"︲",".":"・","/":"/",":":"︓",";":"︔","":"﹀","?":"︖","@":"@","[":"﹇","\\":"\","]":"﹈","^":"^",_:"︳","`":"`","{":"︷","|":"―","}":"︸","~":"~","¢":"¢","£":"£","¥":"¥","¦":"¦","¬":"¬","¯":" ̄","–":"︲","—":"︱","‘":"﹃","’":"﹄","“":"﹁","”":"﹂","…":"︙","‧":"・","₩":"₩","、":"︑","。":"︒","〈":"︿","〉":"﹀","《":"︽","》":"︾","「":"﹁","」":"﹂","『":"﹃","』":"﹄","【":"︻","】":"︼","〔":"︹","〕":"︺","〖":"︗","〗":"︘","!":"︕","(":"︵",")":"︶",",":"︐","-":"︲",".":"・",":":"︓",";":"︔","<":"︿",">":"﹀","?":"︖","[":"﹇","]":"﹈","_":"︳","{":"︷","|":"―","}":"︸","⦅":"︵","⦆":"︶","。":"︒","「":"﹁","」":"﹂","←":"↑","→":"↓"};function Zm(t){return"︶"===t||"﹈"===t||"︸"===t||"﹄"===t||"﹂"===t||"︾"===t||"︼"===t||"︺"===t||"︘"===t||"﹀"===t||"︐"===t||"︓"===t||"︔"===t||"`"===t||" ̄"===t||"︑"===t||"︒"===t}function qm(t){return"︵"===t||"﹇"===t||"︷"===t||"﹃"===t||"﹁"===t||"︽"===t||"︻"===t||"︹"===t||"︗"===t||"︿"===t}const Hm=3;function Wm(t,e,i){e.glyphs=[],1===t&&i.readMessage(Ym,e)}function Ym(t,e,i){if(3===t){const{id:t,bitmap:n,width:r,height:o,left:s,top:a,advance:l}=i.readMessage(Xm,{});e.glyphs.push({id:t,bitmap:new dh({width:r+2*Hm,height:o+2*Hm},n),metrics:{width:r,height:o,left:s,top:a,advance:l}})}else 4===t?e.ascender=i.readSVarint():5===t&&(e.descender=i.readSVarint())}function Xm(t,e,i){1===t?e.id=i.readVarint():2===t?e.bitmap=i.readBytes():3===t?e.width=i.readVarint():4===t?e.height=i.readVarint():5===t?e.left=i.readSVarint():6===t?e.top=i.readSVarint():7===t&&(e.advance=i.readVarint())}const Km=Hm,Jm={horizontal:1,vertical:2,horizontalOnly:3};class Qm{constructor(){this.scale=1,this.fontStack="",this.imageName=null}static forText(t,e){const i=new Qm;return i.scale=t||1,i.fontStack=e,i}static forImage(t){const e=new Qm;return e.imageName=t,e}}class t_{constructor(){this.text="",this.sectionIndex=[],this.sections=[],this.imageSectionID=null}static fromFeature(t,e){const i=new t_;for(let n=0;n=0&&i>=t&&i_[this.text.charCodeAt(i)];i--)e--;this.text=this.text.substring(t,e),this.sectionIndex=this.sectionIndex.slice(t,e)}substring(t,e){const i=new t_;return i.text=this.text.substring(t,e),i.sectionIndex=this.sectionIndex.slice(t,e),i.sections=this.sections,i}toString(){return this.text}getMaxScale(){return this.sectionIndex.reduce(((t,e)=>Math.max(t,this.sections[e].scale)),0)}addTextSection(t,e){this.text+=t.text,this.sections.push(Qm.forText(t.scale,t.fontStack||e));const i=this.sections.length-1;for(let e=0;e=63743?null:++this.imageSectionID:(this.imageSectionID=57344,this.imageSectionID)}}function e_(t,e,i,n,r,o,s,a,l,c,d,u,h,p,f){const m=t_.fromFeature(t,r);u===Jm.vertical&&m.verticalizePunctuation(h);let _=[];const g=function(t,e,i,n,r,o){if(!t)return[];const s=[],a=function(t,e,i,n,r,o){let s=0;for(let i=0;i=0;let c=0;for(let i=0;i0&&o>b&&(b=o)}else{const t=i[a.fontStack];if(!t)continue;t[m]&&(S=t[m]);const n=e[a.fontStack];if(!n)continue;const o=n.glyphs[m];if(!o)continue;if(v=o.metrics,M=8203!==m?Om:0,_){const t=void 0!==n.ascender?Math.abs(n.ascender):0,e=void 0!==n.descender?Math.abs(n.descender):0,i=(t+e)*g;w-i/2;){if(s--,sn;)c-=l.shift().angleDelta;if(c>r)return!1;s++,a+=e.dist(i)}return!0}function m_(t){let e=0;for(let i=0;ic){const d=(c-l)/o,u=Vn(n.x,r.x,d),h=Vn(n.y,r.y,d),p=new p_(u,h,0,r.angleTo(n),i);return!s||f_(t,p,a,s,e)?p:void 0}l+=o}}function v_(t,e,i,n,r,o,s,a,l){const c=__(n,o,s),d=g_(n,r),u=d*s,h=0===t[0].x||t[0].x===l||0===t[0].y||t[0].y===l;return e-u=0&&g=0&&y=0&&h+c=n&&c.x>=n||(s.x>=n?s=new Ue(n,s.y+(n-s.x)/(c.x-s.x)*(c.y-s.y))._round():c.x>=n&&(c=new Ue(n,s.y+(n-s.x)/(c.x-s.x)*(c.y-s.y))._round()),s.y>=r&&c.y>=r||(s.y>=r?s=new Ue(s.x+(r-s.y)/(c.y-s.y)*(c.x-s.x),r)._round():c.y>=r&&(c=new Ue(s.x+(r-s.y)/(c.y-s.y)*(c.x-s.x),r)._round()),l&&s.equals(l[l.length-1])||(l=[s],o.push(l)),l.push(c)))))}}return o}function w_(t){let e=0,i=0;for(const n of t)e+=n.w*n.h,i=Math.max(i,n.w);t.sort(((t,e)=>e.h-t.h));const n=[{x:0,y:0,w:Math.max(Math.ceil(Math.sqrt(e/.95)),i),h:1/0}];let r=0,o=0;for(const e of t)for(let t=n.length-1;t>=0;t--){const i=n[t];if(!(e.w>i.w||e.h>i.h)){if(e.x=i.x,e.y=i.y,o=Math.max(o,e.y+e.h),r=Math.max(r,e.x+e.w),e.w===i.w&&e.h===i.h){const e=n.pop();tt.hasImage(e,i))),t.dispatchRenderCallbacks(this.haveRenderCallbacks,i);for(const n in t.getUpdatedImages(i))this.patchUpdatedImage(this.iconPositions[n],t.getImage(n,i),e),this.patchUpdatedImage(this.patternPositions[n],t.getImage(n,i),e)}patchUpdatedImage(t,e,i){if(!t||!e)return;if(t.version===e.version)return;t.version=e.version;const[n,r]=t.tl,o=!!Object.keys(this.patternPositions).length;i.update(e.data,{useMipmap:o},{x:n,y:r})}}ba(S_,"ImagePosition"),ba(E_,"ImageAtlas");const M_=1e20;function C_(t,e,i,n,r,o,s,a,l){for(let c=e;c-1);l++,o[l]=a,s[l]=c,s[l+1]=M_}for(let a=0,l=0;a{let n=this.entries[t];n||(n=this.entries[t]={glyphs:{},requests:{},ranges:{},ascender:void 0,descender:void 0});let r=n.glyphs[e];if(void 0!==r)return void i(null,{stack:t,id:e,glyph:r});if(r=this._tinySDF(n,t,e),r)return n.glyphs[e]=r,void i(null,{stack:t,id:e,glyph:r});const s=Math.floor(e/256);if(256*s>65535)return void i(new Error("glyphs > 65535 not supported"));if(n.ranges[s])return void i(null,{stack:t,id:e,glyph:r});let a=n.requests[s];a||(a=n.requests[s]=[],P_.loadGlyphRange(t,s,o,this.requestManager,((t,e)=>{if(e){n.ascender=e.ascender,n.descender=e.descender;for(const t in e.glyphs)this._doesCharSupportLocalGlyph(+t)||(n.glyphs[+t]=e.glyphs[+t]);n.ranges[s]=!0}for(const i of a)i(t,e);delete n.requests[s]}))),a.push(((n,r)=>{n?i(n):r&&i(null,{stack:t,id:e,glyph:r.glyphs[e]||null})}))}),((t,e)=>{if(t)i(t);else if(e){const t={};for(const{stack:i,id:n,glyph:r}of e)void 0===t[i]&&(t[i]={}),void 0===t[i].glyphs&&(t[i].glyphs={}),t[i].glyphs[n]=r&&{id:r.id,bitmap:r.bitmap.clone(),metrics:r.metrics},t[i].ascender=this.entries[i].ascender,t[i].descender=this.entries[i].descender;i(null,t)}}))}_doesCharSupportLocalGlyph(t){return this.localGlyphMode!==L_.none&&(this.localGlyphMode===L_.all?!!this.localFontFamily:!!this.localFontFamily&&(Ma["CJK Unified Ideographs"](t)||Ma["Hangul Syllables"](t)||Ma.Hiragana(t)||Ma.Katakana(t)||Ma["CJK Symbols and Punctuation"](t)||Ma["CJK Unified Ideographs Extension A"](t)||Ma["CJK Unified Ideographs Extension B"](t)))}_tinySDF(t,e,i){const n=this.localFontFamily;if(!n||!this._doesCharSupportLocalGlyph(i))return;let r=t.tinySDF;if(!r){let i="400";/bold/i.test(e)?i="900":/medium/i.test(e)?i="500":/light/i.test(e)&&(i="200"),r=t.tinySDF=new P_.TinySDF({fontFamily:n,fontWeight:i,fontSize:24*I_,buffer:3*I_,radius:8*I_}),r.fontWeight=i}if(this.localGlyphs[r.fontWeight][i])return this.localGlyphs[r.fontWeight][i];const o=String.fromCodePoint(i),{data:s,width:a,height:l,glyphWidth:c,glyphHeight:d,glyphLeft:u,glyphTop:h,glyphAdvance:p}=r.draw(o);return this.localGlyphs[r.fontWeight][i]={id:i,bitmap:new dh({width:a,height:l},s),metrics:{width:c/I_,height:d/I_,left:u/I_,top:h/I_-27,advance:p/I_,localGlyph:!0}}}}P_.loadGlyphRange=function(t,e,i,n,r){const o=256*e,s=o+255,a=n.transformRequest(n.normalizeGlyphsURL(i).replace("{fontstack}",t).replace("{range}",`${o}-${s}`),Ki.Glyphs);en(a,((t,e)=>{if(t)r(t);else if(e){const t={},i=function(t){return new Lm(t).readFields(Wm,{})}(e);for(const e of i.glyphs)t[e.id]=e;r(null,{glyphs:t,ascender:i.ascender,descender:i.descender})}}))},P_.TinySDF=class{constructor({fontSize:t=24,buffer:e=3,radius:i=8,cutoff:n=.25,fontFamily:r="sans-serif",fontWeight:o="normal",fontStyle:s="normal"}={}){this.buffer=e,this.cutoff=n,this.radius=i;const a=this.size=t+4*e,l=this._createCanvas(a),c=this.ctx=l.getContext("2d",{willReadFrequently:!0});c.font=`${s} ${o} ${t}px ${r}`,c.textBaseline="alphabetic",c.textAlign="left",c.fillStyle="black",this.gridOuter=new Float64Array(a*a),this.gridInner=new Float64Array(a*a),this.f=new Float64Array(a),this.z=new Float64Array(a+1),this.v=new Uint16Array(a)}_createCanvas(t){const e=document.createElement("canvas");return e.width=e.height=t,e}draw(t){const{width:e,actualBoundingBoxAscent:i,actualBoundingBoxDescent:n,actualBoundingBoxLeft:r,actualBoundingBoxRight:o}=this.ctx.measureText(t),s=Math.ceil(i),a=Math.max(0,Math.min(this.size-this.buffer,Math.ceil(o-r))),l=Math.min(this.size-this.buffer,s+Math.ceil(n)),c=a+2*this.buffer,d=l+2*this.buffer,u=Math.max(c*d,0),h=new Uint8ClampedArray(u),p={data:h,width:c,height:d,glyphWidth:a,glyphHeight:l,glyphTop:s,glyphLeft:0,glyphAdvance:e};if(0===a||0===l)return p;const{ctx:f,buffer:m,gridInner:_,gridOuter:g}=this;f.clearRect(m,m,a,l),f.fillText(t,m,m+s);const y=f.getImageData(m,m,a,l);g.fill(M_,0,u),_.fill(0,0,u);for(let t=0;t0?t*t:0,_[n]=tt+e[1]-e[0],f=u.reduce(p,0),m=h.reduce(p,0),_=a-f,g=l-m;let y=0,v=f,x=0,b=m,w=0,T=_,S=0,E=g;if(o.content&&n){const t=o.content;y=D_(u,0,t[0]),x=D_(h,0,t[1]),v=D_(u,t[0],t[2]),b=D_(h,t[1],t[3]),w=t[0]-y,S=t[1]-x,T=t[2]-t[0]-v,E=t[3]-t[1]-b}const M=(n,r,a,l)=>{const u=R_(n.stretch-y,v,c,t.left),h=O_(n.fixed-w,T,n.stretch,f),p=R_(r.stretch-x,b,d,t.top),_=O_(r.fixed-S,E,r.stretch,m),g=R_(a.stretch-y,v,c,t.left),M=O_(a.fixed-w,T,a.stretch,f),C=R_(l.stretch-x,b,d,t.top),A=O_(l.fixed-S,E,l.stretch,m),I=new Ue(u,p),L=new Ue(g,p),P=new Ue(g,C),$=new Ue(u,C),k=new Ue(h/s,_/s),D=new Ue(M/s,A/s),z=e*Math.PI/180;if(z){const t=Math.sin(z),e=Math.cos(z),i=[e,-t,t,e];I._matMult(i),L._matMult(i),$._matMult(i),P._matMult(i)}const R=n.stretch+n.fixed,O=a.stretch+a.fixed,B=r.stretch+r.fixed,F=l.stretch+l.fixed,N=t.imageSecondary;return{tl:I,tr:L,bl:$,br:P,texPrimary:{x:o.paddedRect.x+$_+R,y:o.paddedRect.y+$_+B,w:O-R,h:F-B},texSecondary:N?{x:N.paddedRect.x+$_+R,y:N.paddedRect.y+$_+B,w:O-R,h:F-B}:void 0,writingMode:void 0,glyphOffset:[0,0],sectionIndex:0,pixelOffsetTL:k,pixelOffsetBR:D,minFontScaleX:T/s/c,minFontScaleY:E/s/d,isSDF:i}};if(n&&(o.stretchX||o.stretchY)){const t=z_(u,_,f),e=z_(h,g,m);for(let i=0;io)&&(o=e.x),(!t||e.y>s)&&(s=e.y)}const l=Math.min(o-n,s-r);let c=l/2;const d=new co([],N_);if(0===l)return new Ue(n,r);for(let e=n;eu.d||!u.d)&&(u=n,i&&console.log("found best %d after %d probes",Math.round(1e4*n.d)/1e4,h)),n.max-u.dt.y!=a.y>t.y&&t.x18&&P>2&&(P>>=1),Math.max(uo/(512*P),1)*_.get("symbol-spacing")),S=_.get("text-padding")*t.tilePixelRatio,E=_.get("icon-padding")*t.tilePixelRatio,M=Ge(_.get("text-max-angle")),C="map"===_.get("text-rotation-alignment")&&"point"!==_.get("symbol-placement"),A="map"===_.get("icon-rotation-alignment")&&"point"!==_.get("symbol-placement"),I=_.get("symbol-placement"),L=T/2;var P;const $=_.get("icon-text-fit").evaluate(e,{},u),k=_.get("icon-text-fit-padding").evaluate(e,{},u),D="none"!==$;let z;!1===t.hasAnyIconTextFit&&D&&(t.hasAnyIconTextFit=!0),n&&D&&(t.allowVerticalPlacement&&i.vertical&&(z=h_(n,i.vertical,$,k,g,b)),y&&(n=h_(n,y,$,k,g,b)));const R=(s,a,m)=>{if(a.x=uo||a.y=uo)return;let _=null;if(v){const{x:t,y:e,z:i}=h.projectTilePoint(a.x,a.y,m);_={anchor:new p_(t,e,i,0,void 0),up:h.upVector(m,a.x,a.y)}}!function(t,e,i,n,r,o,s,a,l,c,d,u,h,p,f,m,_,g,y,v,x,b,w,T,S,E,M){const C=t.addToLineVertexArray(e,n);let A,I,L,P,$,k,D,z=0,R=0,O=0,B=0,F=-1,N=-1;const U={};let j=Ln("");const V=i?i.anchor:e,G="none"!==l.layout.get("icon-text-fit").evaluate(x,{},S);let Z=0,q=0;if(void 0===l._unevaluatedLayout.getValue("text-radial-offset")?[Z,q]=l.layout.get("text-offset").evaluate(x,{},S).map((t=>t*Om)):(Z=l.layout.get("text-radial-offset").evaluate(x,{},S)*Om,q=j_),t.allowVerticalPlacement&&r.vertical){const t=r.vertical;if(f)k=J_(t),a&&(D=J_(a));else{const i=l.layout.get("text-rotate").evaluate(x,{},S)+90;L=K_(c,V,e,d,u,h,t,p,i,m),a&&(P=K_(c,V,e,d,u,h,a,g,i))}}if(o){const n=l.layout.get("icon-rotate").evaluate(x,{},S),r=k_(o,n,w,G),s=a?k_(a,n,w,G):void 0;I=K_(c,V,e,d,u,h,o,g,n),z=4*r.length;const p=t.iconSizeData;let f=null;"source"===p.kind?(f=[Bm*l.layout.get("icon-size").evaluate(x,{},S)],f[0]>W_&&pi(`${t.layerIds[0]}: Value for "icon-size" is >= ${H_}. Reduce your "icon-size".`)):"composite"===p.kind&&(f=[Bm*b.compositeIconSizes[0].evaluate(x,{},S),Bm*b.compositeIconSizes[1].evaluate(x,{},S)],(f[0]>W_||f[1]>W_)&&pi(`${t.layerIds[0]}: Value for "icon-size" is >= ${H_}. Reduce your "icon-size".`)),t.addSymbols(t.icon,r,f,v,y,x,!1,i,e,C.lineStartIndex,C.lineLength,-1,T,S,E,M),F=t.icon.placedSymbolArray.length-1,s&&(R=4*s.length,t.addSymbols(t.icon,s,f,v,y,x,Jm.vertical,i,e,C.lineStartIndex,C.lineLength,-1,T,S,E,M),N=t.icon.placedSymbolArray.length-1)}for(const n in r.horizontal){const o=r.horizontal[n];A||(j=Ln(o.text),f?$=J_(o):A=K_(c,V,e,d,u,h,o,p,l.layout.get("text-rotate").evaluate(x,{},S),m));const a=1===o.positionedLines.length;if(O+=Y_(t,i,e,o,s,l,f,x,m,C,r.vertical?Jm.horizontal:Jm.horizontalOnly,a?Object.keys(r.horizontal):[n],U,F,b,T,S,E),a)break}r.vertical&&(B+=Y_(t,i,e,r.vertical,s,l,f,x,m,C,Jm.vertical,["vertical"],U,N,b,T,S,E));let H=-1;const W=(t,e)=>t?Math.max(t,e):e;H=W($,H),H=W(k,H),H=W(D,H);const Y=H>-1?1:0;t.glyphOffsetArray.length>=65535&&pi("Too many glyphs being rendered in a tile. See https://github.com/mapbox/mapbox-gl-js/issues/2907"),void 0!==x.sortKey&&t.addToSortKeyRanges(t.symbolInstances.length,x.sortKey),t.symbolInstances.emplaceBack(e.x,e.y,V.x,V.y,V.z,U.right>=0?U.right:-1,U.center>=0?U.center:-1,U.left>=0?U.left:-1,U.vertical>=0?U.vertical:-1,F,N,j,void 0!==A?A:t.collisionBoxArray.length,void 0!==A?A+1:t.collisionBoxArray.length,void 0!==L?L:t.collisionBoxArray.length,void 0!==L?L+1:t.collisionBoxArray.length,void 0!==I?I:t.collisionBoxArray.length,void 0!==I?I+1:t.collisionBoxArray.length,P||t.collisionBoxArray.length,P?P+1:t.collisionBoxArray.length,d,O,B,z,R,Y,0,Z,q,H,0,1,1,G?1:0)}(t,a,_,s,i,n,r,z,t.layers[0],t.collisionBoxArray,e.index,e.sourceLayerIndex,t.index,S,C,l,0,E,A,g,e,o,c,d,u,p,f)};if("line"===I)for(const r of b_(e.geometry,0,0,uo,uo)){const e=v_(r,T,M,i.vertical||y,n,x,w,t.overscaling,uo);for(const i of e)y&&Q_(t,y.text,L,i)||R(r,i,u)}else if("line-center"===I){for(const t of e.geometry)if(t.length>1){const e=y_(t,M,i.vertical||y,n,x,w);e&&R(t,e,u)}}else if("Polygon"===e.type)for(const t of Zh(e.geometry,0)){const e=F_(t,16);R(t[0],new p_(e.x,e.y,0,0,void 0),u)}else if("LineString"===e.type)for(const t of e.geometry)R(t,new p_(t[0].x,t[0].y,0,0,void 0),u);else if("Point"===e.type)for(const t of e.geometry)for(const e of t)R([e],new p_(e.x,e.y,0,0,void 0),u)}const H_=255,W_=H_*Bm;function Y_(t,e,i,n,r,o,s,a,l,c,d,u,h,p,f,m,_,g){const y=function(t,e,i,n,r,o,s,a){const l=[];if(0===e.positionedLines.length)return l;const c=n.layout.get("text-rotate").evaluate(o,{})*Math.PI/180,d=function(t){const e=t[0],i=t[1],n=e*i;return n>0?[e,-i]:nW_&&pi(`${t.layerIds[0]}: Value for "text-size" is >= ${H_}. Reduce your "text-size".`)):"composite"===v.kind&&(x=[Bm*f.compositeTextSizes[0].evaluate(a,{},_),Bm*f.compositeTextSizes[1].evaluate(a,{},_)],(x[0]>W_||x[1]>W_)&&pi(`${t.layerIds[0]}: Value for "text-size" is >= ${H_}. Reduce your "text-size".`)),t.addSymbols(t.text,y,x,l,s,a,d,e,i,c.lineStartIndex,c.lineLength,p,m,_,g,!1);for(const e of u)h[e]=t.text.placedSymbolArray.length-1;return 4*y.length}function X_(t){for(const e in t)return t[e];return null}function K_(t,e,i,n,r,o,s,a,l,c){let d=s.top,u=s.bottom,h=s.left,p=s.right;const f=s.collisionPadding;if(f&&(h-=f[0],d-=f[1],p+=f[2],u+=f[3]),l){const t=new Ue(h,d),e=new Ue(p,d),i=new Ue(h,u),n=new Ue(p,u),r=Ge(l);let o=new Ue(0,0);c&&(o=new Ue(c[0],c[1])),t._rotateAround(r,o),e._rotateAround(r,o),i._rotateAround(r,o),n._rotateAround(r,o),h=Math.min(t.x,e.x,i.x,n.x),p=Math.max(t.x,e.x,i.x,n.x),d=Math.min(t.y,e.y,i.y,n.y),u=Math.max(t.y,e.y,i.y,n.y)}return t.emplaceBack(e.x,e.y,e.z,i.x,i.y,h,d,p,u,a,n,r,o),t.length-1}function J_(t){t.collisionPadding&&(t.top-=t.collisionPadding[1],t.bottom+=t.collisionPadding[3]);const e=t.bottom-t.top;return e>0?Math.max(10,e):null}function Q_(t,e,i,n){const r=t.compareText;if(e in r){const t=r[e];for(let e=t.length-1;e>=0;e--)if(n.dist(t[e])v&&(x(t,c,n,r,a,l),x(c,i,a,l,o,s))}x(u,h,n,o,r,o),x(h,p,r,o,r,s),x(p,f,r,s,n,s),x(f,u,n,s,n,o),m-=v,_-=v,g+=v,y+=v;const b=1/Math.max(g-m,y-_);return{scale:b,x:m*b,y:_*b,x2:g*b,y2:y*b,projection:e}}function ig(t,{x:e,y:i},n=0){return new Ue(((e-n)*t.scale-t.x)*uo,(i*t.scale-t.y)*uo)}const ng=t.ad.identity(new Float32Array(16));class rg{constructor(t){this.spec=t,this.name=t.name,this.wrap=!1,this.requiresDraping=!1,this.supportsWorldCopies=!1,this.supportsTerrain=!1,this.supportsFog=!1,this.supportsFreeCamera=!1,this.zAxisUnit="meters",this.isReprojectedInTileSpace=!0,this.unsupportedLayers=["custom"],this.center=[0,0],this.range=[3.5,7]}project(t,e){return{x:0,y:0,z:0}}unproject(t,e){return new pd(0,0)}projectTilePoint(t,e,i){return{x:t,y:e,z:0}}locationPoint(t,e,i=!0){return t._coordinatePoint(t.locationCoordinate(e),i)}pixelsPerMeter(t,e){return Cd(1,t)*e}pixelSpaceConversion(t,e,i){return 1}farthestPixelDistance(t){return tg(t,t.pixelsPerMeter)}pointCoordinate(t,e,i,n){const r=t.horizonLineFromTop(!1),o=new Ue(e,Math.max(r,i));return t.rayIntersectionCoordinate(t.pointRayIntersection(o,n))}pointCoordinate3D(t,e,i){const n=new Ue(e,i);if(t.elevation)return t.elevation.pointCoordinate(n);{const e=this.pointCoordinate(t,n.x,n.y,0);return[e.x,e.y,e.z]}}isPointAboveHorizon(t,e){if(t.elevation&&t.elevation.visibleDemTiles.length)return!this.pointCoordinate3D(t,e.x,e.y);const i=t.horizonLineFromTop();return e.y0?epg-i&&(e=pg-i);const o=r/Math.pow(fg(e),n);let s=o*Math.sin(n*t),a=r-o*Math.cos(n*t);return s=.5*(s/Math.PI+.5),a=.5*(a/Math.PI+.5),{x:s,y:this.southernCenter?a:1-a,z:0}}unproject(t,e){t=(2*t-.5)*Math.PI,this.southernCenter&&(e=1-e),e=(2*(1-e)-.5)*Math.PI;const{n:i,f:n}=this,r=n-e,o=Math.sign(r),s=Math.sign(i)*Math.sqrt(t*t+r*r);let a=Math.atan2(t,Math.abs(r))*o;r*i1e-6&&--n>0);o=i*i;const s=Xe(Ze(t/(.8707+o*(o*(o*o*o*(.003971-.001529*o)-.013791)-.131979))),-180,180),a=Ze(i);return new pd(s,a)}}const vg=Ge(Pd);class xg extends rg{project(t,e){e=Ge(e),t=Ge(t);const i=Math.cos(e),n=2/Math.PI,r=Math.acos(i*Math.cos(t/2)),o=Math.sin(r)/r,s=.5*(t*n+2*i*Math.sin(t/2)/o)||0,a=.5*(e+Math.sin(e)/o)||0;return{x:.5*(s/Math.PI+.5),y:1-.5*(a/Math.PI+1),z:0}}unproject(t,e){let i=t=(2*t-.5)*Math.PI,n=e=(2*(1-e)-1)*Math.PI,r=25;const o=1e-6;let s=0,a=0;do{const r=Math.cos(n),o=Math.sin(n),l=2*o*r,c=o*o,d=r*r,u=Math.cos(i/2),h=Math.sin(i/2),p=2*u*h,f=h*h,m=1-d*u*u,_=m?1/m:0,g=m?Math.acos(r*u)*Math.sqrt(1/m):0,y=.5*(2*g*r*h+2*i/Math.PI)-t,v=.5*(g*o+n)-e,x=.5*_*(d*f+g*r*u*c)+1/Math.PI,b=_*(p*l/4-g*o*h),w=.125*_*(l*h-g*o*d*p),T=.5*_*(c*u+g*f*r)+.5,S=b*w-T*x;s=(v*b-y*T)/S,a=(y*w-v*x)/S,i=Xe(i-s,-Math.PI,Math.PI),n=Xe(n-a,-vg,vg)}while((Math.abs(s)>o||Math.abs(a)>o)&&--r>0);return new pd(Ze(i),Ze(n))}}class bg extends rg{constructor(t){super(t),this.center=t.center||[0,0],this.parallels=t.parallels||[0,0],this.cosPhi=Math.max(.01,Math.cos(Ge(this.parallels[0]))),this.scale=1/(2*Math.max(Math.PI*this.cosPhi,1/this.cosPhi)),this.wrap=!0,this.supportsWorldCopies=!0}project(t,e){const{scale:i,cosPhi:n}=this;return{x:Ge(t)*n*i+.5,y:-Math.sin(Ge(e))/n*i+.5,z:0}}unproject(t,e){const{scale:i,cosPhi:n}=this,r=-(e-.5)/i,o=Xe(Ze((t-.5)/i)/n,-180,180),s=Math.asin(Xe(r*n,-1,1)),a=Xe(Ze(s),-Pd,Pd);return new pd(o,a)}}class wg extends _g{constructor(t){super(t),this.requiresDraping=!0,this.supportsWorldCopies=!1,this.supportsFog=!0,this.zAxisUnit="pixels",this.unsupportedLayers=["debug"],this.range=[3,5]}projectTilePoint(e,i,n){const r=Fu(e,i,n),o=ju($u(n));return t._.transformMat4(r,r,o),{x:r[0],y:r[1],z:r[2]}}locationPoint(e,i){const n=dd(i.lat,i.lng),r=t._.normalize([],n),o=e.elevation?e.elevation.getAtPointOrZero(e.locationCoordinate(i),e._centerAltitude):e._centerAltitude,s=Cd(1,0)*uo*o;t._.scaleAndAdd(n,n,r,s);const a=t.ad.identity(new Float64Array(16));return t.ad.multiply(a,e.pixelMatrix,e.globeMatrix),t._.transformMat4(n,n,a),new Ue(n[0],n[1])}pixelsPerMeter(t,e){return Cd(1,0)*e}pixelSpaceConversion(t,e,i){const n=Cd(1,t)*e,r=Vn(Cd(1,45)*e,n,i);return this.pixelsPerMeter(t,e)/r}createTileMatrix(e,i,n){const r=Vu($u(n.canonical));return t.ad.multiply(new Float64Array(16),e.globeMatrix,r)}createInversionMatrix(e,i){const{center:n}=e,r=ju($u(i));return t.ad.rotateY(r,r,Ge(n.lng)),t.ad.rotateX(r,r,Ge(n.lat)),t.ad.scale(r,r,[e._pixelsPerMercatorPixel,e._pixelsPerMercatorPixel,1]),Float32Array.from(r)}pointCoordinate(t,e,i,n){return Iu(t,e,i,!0)||new Rd(0,0)}pointCoordinate3D(t,e,i){const n=this.pointCoordinate(t,e,i,0);return[n.x,n.y,n.z]}isPointAboveHorizon(t,e){return!Iu(t,e.x,e.y,!1)}farthestPixelDistance(e){const i=function(e,i){const n=e.cameraToCenterDistance,r=e._centerAltitude*i,o=e._camera,s=e._camera.forward(),a=t._.add([],t._.scale([],s,-n),[0,0,r]),l=e.worldSize/(2*Math.PI),c=[0,0,-l],d=e.width/e.height,u=Math.tan(e.fovAboveCenter),h=t._.scale([],o.up(),u),p=t._.scale([],o.right(),u*d),f=t._.normalize([],t._.add([],t._.add([],s,h),p)),m=[];let _;if(new mu(a,f).closestPointOnSphere(c,l,m)){const i=t._.add([],m,c),n=t._.sub([],i,a);_=Math.cos(e.fovAboveCenter)*t._.length(n)}else{const e=t._.sub([],a,c),i=t._.sub([],c,a);t._.normalize(i,i);const n=t._.length(e)-l;_=Math.sqrt(n*(n+2*l));const r=Math.acos(_/(l+n))-Math.acos(t._.dot(s,i));_*=Math.cos(r)}return 1.01*_}(e,this.pixelsPerMeter(e.center.lat,e.worldSize)),n=Hu(e.zoom);if(n>0){const t=tg(e,Cd(1,e.center.lat)*e.worldSize),r=e.worldSize/(2*Math.PI),o=Math.max(e.width,e.height)/e.worldSize*Math.PI;return Vn(i,t+r*(1-Math.cos(o)),Math.pow(n,10))}return i}upVector(t,e,i){return Fu(e,i,t,1)}upVectorScale(t){return{metersToTile:Cu(Nu($u(t)))}}}function Tg(t){const e=t.parallels,i=!!e&&Math.abs(e[0]+e[1])0&&(this.iconTransitioningVertexBuffer=t.createVertexBuffer(this.iconTransitioningVertexArray,Vf.members,!0)),this.globeExtVertexArray.length>0&&(this.globeExtVertexBuffer=t.createVertexBuffer(this.globeExtVertexArray,Ff.members,!0)),!this.zOffsetVertexBuffer&&(this.zOffsetVertexArray.length>0||r)&&(this.zOffsetVertexBuffer=t.createVertexBuffer(this.zOffsetVertexArray,jf.members,!0)),this.opacityVertexBuffer.itemSize=1),(i||n)&&this.programConfigurations.upload(t))}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy(),this.dynamicLayoutVertexBuffer.destroy(),this.opacityVertexBuffer.destroy(),this.occlusionQueryOpacityVertexBuffer.destroy(),this.iconTransitioningVertexBuffer&&this.iconTransitioningVertexBuffer.destroy(),this.globeExtVertexBuffer&&this.globeExtVertexBuffer.destroy(),this.zOffsetVertexBuffer&&this.zOffsetVertexBuffer.destroy())}}ba(Ng,"SymbolBuffers");class Ug{constructor(t,e,i){this.layoutVertexArray=new t,this.layoutAttributes=e,this.indexArray=new i,this.segments=new wc,this.collisionVertexArray=new Xl,this.collisionVertexArrayExt=new Ol}upload(t){this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,this.layoutAttributes),this.indexBuffer=t.createIndexBuffer(this.indexArray),this.collisionVertexBuffer=t.createVertexBuffer(this.collisionVertexArray,Gf.members,!0),this.collisionVertexBufferExt=t.createVertexBuffer(this.collisionVertexArrayExt,Zf.members,!0)}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.segments.destroy(),this.collisionVertexBuffer.destroy(),this.collisionVertexBufferExt.destroy())}}ba(Ug,"CollisionBuffers");class jg{constructor(e){this.queries=new Map,this.collisionBoxArray=e.collisionBoxArray,this.zoom=e.zoom,this.lut=e.lut,this.overscaling=e.overscaling,this.layers=e.layers,this.layerIds=this.layers.map((t=>t.fqid)),this.index=e.index,this.pixelRatio=e.pixelRatio,this.sourceLayerIndex=e.sourceLayerIndex,this.hasPattern=!1,this.hasRTLText=!1,this.fullyClipped=!1,this.hasAnyIconTextFit=!1,this.sortKeyRanges=[],this.collisionCircleArray=[],this.placementInvProjMatrix=t.ad.identity([]),this.placementViewportMatrix=t.ad.identity([]);const i=this.layers[0]._unevaluatedLayout._values;this.textSizeData=Fm(this.zoom,i["text-size"]),this.iconSizeData=Fm(this.zoom,i["icon-size"]);const n=this.layers[0].layout,r=n.get("symbol-sort-key"),o=n.get("symbol-z-order");this.canOverlap=n.get("text-allow-overlap")||n.get("icon-allow-overlap")||n.get("text-ignore-placement")||n.get("icon-ignore-placement"),this.sortFeaturesByKey="viewport-y"!==o&&void 0!==r.constantOr(1),this.sortFeaturesByY=("viewport-y"===o||"auto"===o&&!this.sortFeaturesByKey)&&this.canOverlap,this.writingModes=n.get("text-writing-mode").map((t=>Jm[t])),this.stateDependentLayerIds=this.layers.filter((t=>t.isStateDependent())).map((t=>t.id)),this.sourceID=e.sourceID,this.projection=e.projection,this.hasAnyZOffset=!1,this.zOffsetSortDirty=!1,this.zOffsetBuffersNeedUpload=n.get("symbol-z-elevate"),this.activeReplacements=[],this.replacementUpdateTime=0}createArrays(){this.text=new Ng(new Yc(this.layers,{zoom:this.zoom,lut:this.lut},(t=>/^text/.test(t)))),this.icon=new Ng(new Yc(this.layers,{zoom:this.zoom,lut:this.lut},(t=>/^icon/.test(t)))),this.glyphOffsetArray=new mc,this.lineVertexArray=new _c,this.symbolInstances=new fc}calculateGlyphDependencies(t,e,i,n,r){for(let i=0;i0)&&("constant"!==l.value.kind||l.value.value.length>0),h="constant"!==d.value.kind||!!d.value.value||Object.keys(d.parameters).length>0,p=s.get("symbol-sort-key");if(this.features=[],!u&&!h)return;const f=i.iconDependencies,m=i.glyphDependencies,_=i.availableImages,g=new Ha(this.zoom);for(const{feature:i,id:c,index:d,sourceLayerIndex:y}of e){const e=o._featureFilter.needGeometry,v=Zd(i,e);if(!o._featureFilter.filter(g,v,n))continue;if(e||(v.geometry=Gd(i,n,r)),a&&1!==i.type&&n.z{const o=Fu(e.x,e.y,n,1),s=Fu(r.x,r.y,n,1);return t._.dot(o,s)=0;for(const i of x.sections)if(i.image)f[i.image.namePrimary]=!0;else{const n=Ca(x.toString()),r=i.fontStack||t,o=m[r]=m[r]||{};this.calculateGlyphDependencies(i.text,o,e,this.allowVerticalPlacement,n)}}}"line"===s.get("symbol-placement")&&(this.features=function(t){const e={},i={},n=[];let r=0;function o(e){n.push(t[e]),r++}function s(t,e,r){const o=i[t];return delete i[t],i[e]=o,n[o].geometry[0].pop(),n[o].geometry[0]=n[o].geometry[0].concat(r[0]),o}function a(t,i,r){const o=e[i];return delete e[i],e[t]=o,n[o].geometry[0].shift(),n[o].geometry[0]=r[0].concat(n[o].geometry[0]),o}function l(t,e,i){const n=i?e[0][e[0].length-1]:e[0][0];return`${t}:${n.x}:${n.y}`}for(let c=0;ct.geometry))}(this.features)),this.sortFeaturesByKey&&this.features.sort(((t,e)=>t.sortKey-e.sortKey))}update(t,e,i,n,r){const o=0!==Object.keys(t).length;if(o&&!this.stateDependentLayers.length)return;const s=o?this.stateDependentLayers:this.layers;this.text.programConfigurations.updatePaintArrays(t,e,s,i,n,r),this.icon.programConfigurations.updatePaintArrays(t,e,s,i,n,r)}updateOcclusionOpacities(t,e,i){if(!e.useOcclusionQueries)return!1;const n=this;if("globe"===n.projection.name)return!1;let r=!1;n.hasTextData()&&(r=r||0!==n.text.occlusionQueryOpacityVertexArray.length),n.hasIconData()&&(r=r||0!==n.icon.occlusionQueryOpacityVertexArray.length);const o=n.layers[0].paint,s=o.get("icon-occlusion-opacity").constantOr(0),a=o.get("text-occlusion-opacity").constantOr(0);if(!n.layers[0].hasInitialOcclusionOpacityProperties||1===s&&1===a)return!1;let l=!r;for(let t=0;t.5?1:-1)*e.fadeSpeed*i*.001,r.occlusionOpacity=Xe(r.occlusionOpacity,0,1),l=l||r.occlusionOpacity!==o}if(!l)return!1;let c=0,d=0;const u=(t,e,i,n)=>{let r=0,o=0;i?(r=d,d+=n,o=d):(r=c,c+=n,o=c),o>e.occlusionQueryOpacityVertexArray.length&&e.occlusionQueryOpacityVertexArray.resize(o);const s=t.occlusionOpacity;for(let t=0;t0;if((i>0||r>0)&&(u(e,n.text,!1,i),u(e,n.text,!1,r)),s){const{placedIconSymbolIndex:t,verticalPlacedIconSymbolIndex:i}=e;t>=0&&u(e,n.icon,!0,o),i>=0&&u(e,n.icon,!0,e.numVerticalIconVertices)}}return n.hasTextData()&&n.text.occlusionQueryOpacityVertexBuffer&&(n.text.occlusionQueryOpacityVertexBuffer.length{i+=e,i>t.length&&t.resize(i);for(let r=-e;r{n+=e,n>t.length&&t.resize(n);for(let r=-e;r0;if((r>0||o>0)&&(t(this.text.zOffsetVertexArray,r,a),t(this.text.zOffsetVertexArray,o,a)),l){const{placedIconSymbolIndex:t,verticalPlacedIconSymbolIndex:i}=n;t>=0&&e(this.icon.zOffsetVertexArray,s,a),i>=0&&e(this.icon.zOffsetVertexArray,n.numVerticalIconVertices,a)}}this.text.zOffsetVertexBuffer&&this.text.zOffsetVertexBuffer.updateData(this.text.zOffsetVertexArray),this.icon.zOffsetVertexBuffer&&this.icon.zOffsetVertexBuffer.updateData(this.icon.zOffsetVertexArray)}isEmpty(){return 0===this.symbolInstances.length&&!this.hasRTLText}uploadPending(){return!this.uploaded||this.text.programConfigurations.needsUpload||this.icon.programConfigurations.needsUpload}upload(t){!this.uploaded&&this.hasDebugData()&&(this.textCollisionBox.upload(t),this.iconCollisionBox.upload(t)),this.text.upload(t,this.sortFeaturesByY,!this.uploaded,this.text.programConfigurations.needsUpload,this.zOffsetBuffersNeedUpload),this.icon.upload(t,this.sortFeaturesByY,!this.uploaded,this.icon.programConfigurations.needsUpload,this.zOffsetBuffersNeedUpload),this.uploaded=!0}destroyDebugData(){this.textCollisionBox.destroy(),this.iconCollisionBox.destroy()}getProjection(){return this.projectionInstance||(this.projectionInstance=Tg(this.projection)),this.projectionInstance}destroy(){this.text.destroy(),this.icon.destroy(),this.hasDebugData()&&this.destroyDebugData();for(const t of this.queries.values())t.destroy()}addToLineVertexArray(t,e){const i=this.lineVertexArray.length;if(void 0!==t.segment)for(const{x:t,y:i}of e)this.lineVertexArray.emplaceBack(t,i);return{lineStartIndex:i,lineLength:this.lineVertexArray.length-i}}addSymbols(t,e,i,n,r,o,s,a,l,c,d,u,h,p,f,m){const _=t.indexArray,g=t.layoutVertexArray,y=t.globeExtVertexArray,v=t.segments.prepareSegment(4*e.length,g,_,this.canOverlap?o.sortKey:void 0),x=this.glyphOffsetArray.length,b=v.vertexLength,w=this.allowVerticalPlacement&&s===Jm.vertical?Math.PI/2:0,T=o.text&&o.text.sections;for(let n=0;n=0?e.rightJustifiedTextSymbolIndex:e.centerJustifiedTextSymbolIndex>=0?e.centerJustifiedTextSymbolIndex:e.leftJustifiedTextSymbolIndex>=0?e.leftJustifiedTextSymbolIndex:e.verticalPlacedTextSymbolIndex>=0?e.verticalPlacedTextSymbolIndex:n),o=Nm(this.textSizeData,t,r)/Om;return this.tilePixelRatio*o}getSymbolInstanceIconSize(t,e,i){const n=this.icon.placedSymbolArray.get(i),r=Nm(this.iconSizeData,t,n);return this.tilePixelRatio*r}_commitDebugCollisionVertexUpdate(t,e,i,n){t.emplaceBack(e,-i,-i,n),t.emplaceBack(e,i,-i,n),t.emplaceBack(e,i,i,n),t.emplaceBack(e,-i,i,n)}_updateTextDebugCollisionBoxes(t,e,i,n,r,o){for(let s=n;s0}hasIconData(){return this.icon.segments.get().length>0}hasDebugData(){return this.textCollisionBox&&this.iconCollisionBox}hasTextCollisionBoxData(){return this.hasDebugData()&&this.textCollisionBox.segments.get().length>0}hasIconCollisionBoxData(){return this.hasDebugData()&&this.iconCollisionBox.segments.get().length>0}hasIconTextFit(){return this.hasAnyIconTextFit}addIndicesForPlacedSymbol(t,e){const i=t.placedSymbolArray.get(e),n=i.vertexStartIndex+4*i.numGlyphs;for(let e=i.vertexStartIndex;en[t]-n[e]||r[e]-r[t])),o}getSortedIndexesByZOffset(){if(!this.zOffsetSortDirty)return this.symbolInstanceIndexesSortedZOffset;if(!this.symbolInstanceIndexesSortedZOffset){this.symbolInstanceIndexesSortedZOffset=[];for(let t=0;tthis.symbolInstances.get(e).zOffset-this.symbolInstances.get(t).zOffset))}addToSortKeyRanges(t,e){const i=this.sortKeyRanges[this.sortKeyRanges.length-1];i&&i.sortKey===e?i.symbolInstanceEnd=t+1:this.sortKeyRanges.push({sortKey:e,symbolInstanceStart:t,symbolInstanceEnd:t+1})}sortFeatures(t){if(this.sortFeaturesByY&&this.sortedAngle!==t&&!(this.text.segments.get().length>1||this.icon.segments.get().length>1)){this.symbolInstanceIndexes=this.getSortedSymbolIndexes(t),this.sortedAngle=t,this.text.indexArray.clear(),this.icon.indexArray.clear(),this.featureSortOrder=[];for(const t of this.symbolInstanceIndexes){const e=this.symbolInstances.get(t);this.featureSortOrder.push(e.featureIndex);const{rightJustifiedTextSymbolIndex:i,centerJustifiedTextSymbolIndex:n,leftJustifiedTextSymbolIndex:r,verticalPlacedTextSymbolIndex:o,placedIconSymbolIndex:s,verticalPlacedIconSymbolIndex:a}=e;i>=0&&this.addIndicesForPlacedSymbol(this.text,i),n>=0&&n!==i&&this.addIndicesForPlacedSymbol(this.text,n),r>=0&&r!==n&&r!==i&&this.addIndicesForPlacedSymbol(this.text,r),o>=0&&this.addIndicesForPlacedSymbol(this.text,o),s>=0&&this.addIndicesForPlacedSymbol(this.icon,s),a>=0&&this.addIndicesForPlacedSymbol(this.icon,a)}this.text.indexBuffer&&this.text.indexBuffer.updateData(this.text.indexArray),this.icon.indexBuffer&&this.icon.indexBuffer.updateData(this.icon.indexArray)}}}ba(jg,"SymbolBucket",{omit:["layers","collisionBoxArray","features","compareText"]}),jg.addDynamicAttributes=Bg;class Vg{constructor(t,e,i,n){this.context=t,this.format=i,this.texture=t.gl.createTexture(),this.update(e,n)}update(t,e,i){const{width:n,height:r}=t,{context:o}=this,{gl:s}=o;if(s.bindTexture(s.TEXTURE_2D,this.texture),o.pixelStoreUnpackFlipY.set(!1),o.pixelStoreUnpack.set(1),o.pixelStoreUnpackPremultiplyAlpha.set(this.format===s.RGBA&&(!e||!1!==e.premultiply)),this.useMipmap=Boolean(e&&e.useMipmap),i||this.size&&this.size[0]===n&&this.size[1]===r){const{x:e,y:o}=i||{x:0,y:0};if(t instanceof HTMLImageElement||t instanceof HTMLCanvasElement||t instanceof HTMLVideoElement||t instanceof ImageData||ImageBitmap&&t instanceof ImageBitmap)s.texSubImage2D(s.TEXTURE_2D,0,e,o,s.RGBA,s.UNSIGNED_BYTE,t);else{let i=this.format,a=s.UNSIGNED_BYTE;this.format===s.R32F&&(i=s.RED,a=s.FLOAT),s.texSubImage2D(s.TEXTURE_2D,0,e,o,n,r,i,a,t.data)}}else if(this.size=[n,r],t instanceof HTMLImageElement||t instanceof HTMLCanvasElement||t instanceof HTMLVideoElement||t instanceof ImageData||ImageBitmap&&t instanceof ImageBitmap){let e=this.format;this.format===s.R8&&(e=s.RED),s.texImage2D(s.TEXTURE_2D,0,this.format,e,s.UNSIGNED_BYTE,t)}else{let e=this.format,i=this.format,o=s.UNSIGNED_BYTE,a=!1;this.format===s.DEPTH_COMPONENT&&(e=s.DEPTH_COMPONENT16,o=s.UNSIGNED_SHORT),this.format===s.DEPTH_STENCIL&&(e=s.DEPTH24_STENCIL8,o=s.UNSIGNED_INT_24_8,a=!0),this.format===s.R8&&(i=s.RED),this.format===s.R32F&&(o=s.FLOAT,i=s.RED),!this.useMipmap&&a?s.texStorage2D(s.TEXTURE_2D,1,e,n,r):s.texImage2D(s.TEXTURE_2D,0,e,n,r,0,i,o,t.data)}this.useMipmap&&s.generateMipmap(s.TEXTURE_2D)}bind(t,e,i=!1){const{context:n}=this,{gl:r}=n;r.bindTexture(r.TEXTURE_2D,this.texture),t!==this.minFilter&&(r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MAG_FILTER,t),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MIN_FILTER,this.useMipmap&&!i?t===r.NEAREST?r.NEAREST_MIPMAP_NEAREST:r.LINEAR_MIPMAP_LINEAR:t),this.minFilter=t),e!==this.wrapS&&(r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_S,e),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_T,e),this.wrapS=e)}bindExtraParam(t,e,i,n){const{context:r}=this,{gl:o}=r;o.bindTexture(o.TEXTURE_2D,this.texture),e!==this.magFilter&&(o.texParameteri(o.TEXTURE_2D,o.TEXTURE_MAG_FILTER,e),this.magFilter=e),t!==this.minFilter&&(o.texParameteri(o.TEXTURE_2D,o.TEXTURE_MIN_FILTER,this.useMipmap?t===o.NEAREST?o.NEAREST_MIPMAP_NEAREST:o.LINEAR_MIPMAP_LINEAR:t),this.minFilter=t),i!==this.wrapS&&(o.texParameteri(o.TEXTURE_2D,o.TEXTURE_WRAP_S,i),this.wrapS=i),n!==this.wrapT&&(o.texParameteri(o.TEXTURE_2D,o.TEXTURE_WRAP_T,n),this.wrapT=n)}destroy(){const{gl:t}=this.context;t.deleteTexture(this.texture),this.texture=null}}class Gg{constructor(t,e){this.context=t,this.texture=e}bind(t,e){const{context:i}=this,{gl:n}=i;n.bindTexture(n.TEXTURE_2D,this.texture),t!==this.minFilter&&(n.texParameteri(n.TEXTURE_2D,n.TEXTURE_MAG_FILTER,t),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_MIN_FILTER,t),this.minFilter=t),e!==this.wrapS&&(n.texParameteri(n.TEXTURE_2D,n.TEXTURE_WRAP_S,e),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_WRAP_T,e),this.wrapS=e)}}const Zg=32,qg=33,Hg=new Uint16Array(8184);for(let t=0;t>=1)>1;){const t=i+r>>1,l=n+o>>1;1&e?(r=i,o=n,i=s,n=a):(i=r,n=o,r=s,o=a),s=t,a=l}const l=4*t;Hg[l+0]=i,Hg[l+1]=n,Hg[l+2]=r,Hg[l+3]=o}const Wg=new Uint16Array(2178),Yg=new Uint8Array(1089),Xg=new Uint16Array(1089);function Kg(t){return 0===t?-.03125:32===t?.03125:0}var Jg=Ll([{name:"a_pos",type:"Int16",components:2},{name:"a_texture_pos",type:"Int16",components:2}]),Qg=Ll([{name:"a_index",type:"Int16",components:1}]);const ty={type:2,extent:uo,loadGeometry:()=>[[new Ue(0,0),new Ue(uo+1,0),new Ue(uo+1,uo+1),new Ue(0,uo+1),new Ue(0,0)]]};class ey{constructor(t,e,i,n,r){this.tileID=t,this.uid=ni(),this.uses=0,this.tileSize=e,this.tileZoom=i,this.buckets={},this.expirationTime=null,this.queryPadding=0,this.hasSymbolBuckets=!1,this.hasRTLText=!1,this.dependencies={},this.isRaster=r,n&&n.style&&(this._lastUpdatedBrightness=n.style.getBrightness()),this.expiredRequestCount=0,this.state="loading",n&&n.transform&&(this.projection=n.transform.projection)}registerFadeDuration(t){const e=t+this.timeAdded;ee.getLayer(t))).filter(Boolean);if(0!==t.length){n.layers=t,n.stateDependentLayerIds&&(n.stateDependentLayers=n.stateDependentLayerIds.map((e=>t.filter((t=>t.id===e))[0])));for(const e of t)i[e.fqid]=n}}return i}(t.buckets,e.style),this.hasSymbolBuckets=!1;for(const t in this.buckets){const e=this.buckets[t];if(e instanceof jg){if(this.hasSymbolBuckets=!0,!i)break;e.justReloaded=!0}}if(this.hasRTLText=!1,this.hasSymbolBuckets)for(const t in this.buckets){const e=this.buckets[t];if(e instanceof jg&&e.hasRTLText){this.hasRTLText=!0,qa.isLoading()||qa.isLoaded()||"deferred"!==Ga()||Za();break}}this.queryPadding=0;for(const t in this.buckets){const i=this.buckets[t],n=e.style.getOwnLayer(t);if(!n)continue;const r=n.queryRadius(i);this.queryPadding=Math.max(this.queryPadding,r)}t.imageAtlas&&(this.imageAtlas=t.imageAtlas),t.glyphAtlasImage&&(this.glyphAtlasImage=t.glyphAtlasImage),t.lineAtlas&&(this.lineAtlas=t.lineAtlas),this._lastUpdatedBrightness=t.brightness}else this.collisionBoxArray=new dc}unloadVectorData(){if(this.hasData()){for(const t in this.buckets)this.buckets[t].destroy();this.buckets={},this.imageAtlas&&(this.imageAtlas=null),this.lineAtlas&&(this.lineAtlas=null),this.imageAtlasTexture&&this.imageAtlasTexture.destroy(),this.glyphAtlasTexture&&this.glyphAtlasTexture.destroy(),this.lineAtlasTexture&&this.lineAtlasTexture.destroy(),this._tileBoundsBuffer&&(this._tileBoundsBuffer.destroy(),this._tileBoundsIndexBuffer.destroy(),this._tileBoundsSegments.destroy(),this._tileBoundsBuffer=null),this._tileDebugBuffer&&(this._tileDebugBuffer.destroy(),this._tileDebugSegments.destroy(),this._tileDebugBuffer=null),this._tileDebugIndexBuffer&&(this._tileDebugIndexBuffer.destroy(),this._tileDebugIndexBuffer=null),this._globeTileDebugBorderBuffer&&(this._globeTileDebugBorderBuffer.destroy(),this._globeTileDebugBorderBuffer=null),this._tileDebugTextBuffer&&(this._tileDebugTextBuffer.destroy(),this._tileDebugTextSegments.destroy(),this._tileDebugTextIndexBuffer.destroy(),this._tileDebugTextBuffer=null),this._globeTileDebugTextBuffer&&(this._globeTileDebugTextBuffer.destroy(),this._globeTileDebugTextBuffer=null),this.latestFeatureIndex=null,this.state="unloaded"}}getBucket(t){return this.buckets[t.fqid]}upload(t){for(const e in this.buckets){const i=this.buckets[e];i.uploadPending()&&i.upload(t)}const e=t.gl,i=this.imageAtlas;if(i&&!i.uploaded){const n=!!Object.keys(i.patternPositions).length;this.imageAtlasTexture=new Vg(t,i.image,e.RGBA,{useMipmap:n}),this.imageAtlas.uploaded=!0}this.glyphAtlasImage&&(this.glyphAtlasTexture=new Vg(t,this.glyphAtlasImage,e.R8),this.glyphAtlasImage=null),this.lineAtlas&&!this.lineAtlas.uploaded&&(this.lineAtlasTexture=new Vg(t,this.lineAtlas.image,e.R8),this.lineAtlas.uploaded=!0)}prepare(t,e,i){if(this.imageAtlas&&this.imageAtlasTexture&&this.imageAtlas.patchUpdatedImages(t,this.imageAtlasTexture,i),!e||!this.latestFeatureIndex||!this.latestFeatureIndex.rawTileData)return;const n=e.style.getBrightness();(this._lastUpdatedBrightness||n)&&(this._lastUpdatedBrightness&&n&&Math.abs(this._lastUpdatedBrightness-n)t)i=!1;else if(e)if(this.expirationTime=0;t--){const e=4*t,i=Hg[e+0],n=Hg[e+1],r=Hg[e+2],o=Hg[e+3],s=i+r>>1,a=n+o>>1,l=s+a-n,c=a+i-s,d=n*qg+i,u=o*qg+r,h=a*qg+s,p=Math.hypot((Wg[2*d+0]+Wg[2*u+0])/2-Wg[2*h+0],(Wg[2*d+1]+Wg[2*u+1])/2-Wg[2*h+1])>=16;Yg[h]=Yg[h]||(p?1:0),t>1)*qg+(i+l>>1)]||Yg[(o+c>>1)*qg+(r+l>>1)])}const r=new Dl,o=new Kl;let s=0;function a(t,e){const i=e*qg+t;return 0===Xg[i]&&(r.emplaceBack(Wg[2*i+0],Wg[2*i+1],t*uo/Zg,e*uo/Zg),Xg[i]=++s),Xg[i]-1}function l(t,e,i,n,r,s){const c=t+i>>1,d=e+n>>1;if(Math.abs(t-r)+Math.abs(e-s)>1&&Yg[d*qg+c])l(r,s,t,e,c,d),l(i,n,r,s,c,d);else{const l=a(t,e),c=a(i,n),d=a(r,s);o.emplaceBack(l,c,d)}}return l(0,0,Zg,Zg,Zg,0),l(Zg,Zg,0,0,0,Zg),{vertices:r,indices:o}}(this.tileID.canonical,e);n=t.vertices,r=t.indices}else{n=new Dl,r=new Kl;for(const{x:t,y:e}of i)n.emplaceBack(t,e,0,0);const t=xh(n.int16,void 0,4);for(let e=0;e0&&(a=t.ad.invert(new Float64Array(16),i.globeMatrix)),this._makeGlobeTileDebugBorderBuffer(e,r,i,o,a,s),this._makeGlobeTileDebugTextBuffer(e,r,i,o,a,s)}_globePoint(e,i,n,r,o,s,a){let l=Fu(e,i,n);if(s){const o=1.5?h=-1:u{const p=(d-t)/(h-1),f=(u-c)/(h-1),m=s.length;for(let d=0;dd*t+e;for(let t=0;t[t,this.get(t)]))}evict(t=!1){if(t||this.size>0){const t=this.first;delete this.items[t.key],0==--this.size?(this.first=null,this.last=null):(this.first=t.next,this.first.prev=null)}return this}expiresAt(t){let e;return this.has(t)&&(e=this.items[t].expiry),e}get(t){let e;if(this.has(t)){const i=this.items[t];this.ttl>0&&i.expiry0?Date.now()+this.ttl:this.ttl),this.last!==r){const t=this.last,e=r.next,i=r.prev;this.first===r&&(this.first=r.next),r.next=null,r.prev=this.last,t.next=r,null!==i&&(i.next=e),null!==e&&(e.prev=i)}}else this.max>0&&this.size===this.max&&this.evict(!0),r=this.items[t]={expiry:this.ttl>0?Date.now()+this.ttl:this.ttl,key:t,prev:this.last,next:null,value:e},1==++this.size?this.first=r:this.last.next=r;return this.last=r,this}values(t=this.keys()){return t.map((t=>this.get(t)))}}function uy(t,e){if(4!==e.length)throw new Error(`Expected data of dimension 4 but got ${e.length}.`);let i=e[3];for(let n=2;n>=1;n--){const r=1===n?1:0,o=2===n?1:0;for(let n=0;n>>1^-(1&t[e]);return t}function py(t,e){switch(e){case"uint32":return t;case"uint16":for(let e=0;e>4|(61440&i)>>8|(240&n)>4|(15&n)>6|(192&n)>>4|(192&r)>>2|192&o,t[e+1]=(48&i)>>4|(48&n)>>2|48&r|(48&o)>2|12&n|(12&r)>1|(21845&Cy)>2|(13107&Ay)>4|(3855&Ay)>8|(255&Ay)>1}var Iy=function(t,e,i){for(var n=t.length,r=0,o=new _y(e);r>l]=c}else for(s=new _y(n),r=0;r>15-t[r]);return s},Ly=new my(288);for(Cy=0;Cye&&(e=t[i]);return e},zy=function(t,e,i){var n=e/8|0;return(t[n]|t[n+1]>(7&e)&i},Ry=function(t,e){var i=e/8|0;return(t[i]|t[i+1]>(7&e)},Oy=["unexpected EOF","invalid block type","invalid length/literal","invalid distance","stream finished","no stream handler",,"no callback","invalid UTF-8 data","extra field too long","date not in range 1980-2099","filename too long","stream finishing","invalid zip data"],By=function(t,e,i){var n=new Error(e||Oy[t]);if(n.code=t,Error.captureStackTrace&&Error.captureStackTrace(n,By),!i)throw n;return n},Fy=new my(0),Ny="undefined"!=typeof TextDecoder&&new TextDecoder;try{Ny.decode(Fy,{stream:!0})}catch(t){}const Uy={gzip_data:"gzip"},jy={0:"uint32",1:"uint32",2:"uint16",3:"uint8"},Vy={uint32:1,uint16:2,uint8:4},Gy={uint32:Uint32Array,uint16:Uint16Array,uint8:Uint8Array};class Zy{constructor(t=1){this.x=NaN,this.y=NaN,this.z=NaN,this.layers={},this._cacheSize=t}getLayer(t){return this.layers[t]}getHeaderLength(t){const e=new Uint8Array(t),i=new DataView(t);if(13!==e[0])throw new fy("File is not a valid MRT.");return i.getUint32(1,!0)}parseHeader(t){const e=new Uint8Array(t),i=this.getHeaderLength(t);if(e.length= ${i} but got buffer of length ${e.length}`);const n=function(t){return t.readFields(iy,{header_length:0,x:0,y:0,z:0,layers:[]},void 0)}(new Lm(e.subarray(0,i)));if(!isNaN(this.x)&&(this.x!==n.x||this.y!==n.y||this.z!==n.z))throw new fy(`Invalid attempt to parse header ${n.z}/${n.x}/${n.y} for tile ${this.z}/${this.x}/${this.y}`);this.x=n.x,this.y=n.y,this.z=n.z;for(const t of n.layers)this.layers[t.name]=new qy(t,{cacheSize:this._cacheSize});return this}createDecodingTask(t){const e=[],i=this.getLayer(t.layerName);for(let n=0;nt.lastBlock)continue;if(i._blocksInProgress.has(n))continue;const a={layerName:i.name,firstByte:o,lastByte:s,pixelFormat:i.pixelFormat,blockIndex:n,blockShape:[r.bands.length].concat(i.bandShape),buffer:i.buffer,codec:r.codec.codec,filters:r.filters.map((t=>t.filter))};i._blocksInProgress.add(n),e.push(a)}return new Hy(e,(()=>{e.forEach((t=>i._blocksInProgress.delete(t.blockIndex)))}),((t,n)=>{if(e.forEach((t=>i._blocksInProgress.delete(t.blockIndex))),t)throw t;n.forEach((t=>{this.getLayer(t.layerName).processDecodedData(t)}))}))}}class qy{constructor({version:t,name:e,units:i,tilesize:n,pixel_format:r,buffer:o,data_index:s},a){if(this.version=t,1!==this.version)throw new fy(`Cannot parse raster layer encoded with MRT version ${t}`);this.name=e,this.units=i,this.tileSize=n,this.buffer=o,this.pixelFormat=jy[r],this.dataIndex=s,this.bandShape=[n+2*o,n+2*o,Vy[this.pixelFormat]],this._decodedBlocks=function(t=1e3,e=0,i=!1){if(isNaN(t)||t=e&&t=0}hasDataForBand(t){const{blockIndex:e}=this.getBlockForBand(t);return e>=0&&!!this._decodedBlocks.get(e.toString())}getBandView(t){const{blockIndex:e,blockBandIndex:i}=this.getBlockForBand(t),n=this._decodedBlocks.get(e.toString());if(!n)throw new fy(`Data for band ${JSON.stringify(t)} of layer "${this.name}" not decoded.`);const r=this.dataIndex[e],o=this.bandShape.reduce(((t,e)=>t*e),1),s=i*o,a=n.subarray(s,s+o);return{data:a,bytes:new Uint8Array(a.buffer).subarray(a.byteOffset,a.byteOffset+a.byteLength),tileSize:this.tileSize,buffer:this.buffer,offset:r.offset,scale:r.scale}}}class Hy{constructor(t,e,i){this.tasks=t,this._onCancel=e,this._onComplete=i,this._finalized=!1}cancel(){this._finalized||(this._onCancel(),this._finalized=!0)}complete(t,e){this._finalized||(this._onComplete(t,e),this._finalized=!0)}}Zy.performDecoding=function(t,e){return Promise.all(e.tasks.map((e=>{const{layerName:i,firstByte:n,lastByte:r,pixelFormat:o,blockShape:s,blockIndex:a,filters:l,codec:c}=e,d=new Uint8Array(t).subarray(n,r+1),u=new Uint32Array(s[0]*s[1]*s[2]);let h;if("gzip_data"!==c)throw new Error(`Unhandled codec: ${c}`);return h=function(t,e){if(!globalThis.DecompressionStream&&"gzip_data"===e)return Promise.resolve(((o=function(t){31==t[0]&&139==t[1]&&8==t[2]||By(6,"invalid gzip data");var e=t[3],i=10;4&e&&(i+=2+(t[10]|t[11]>3&1)+(e>>4&1);n>0;n-=!t[i++]);return i+(2&e)}(r=t))+8>r.length&&By(6,"invalid gzip data"),function(t,e,i){var n=t.length;if(!n||e.f&&!e.l)return i||new my(0);var r=!i,o=r||2!=e.i,s=e.i;r&&(i=new my(3*n));var a,l,c=function(t){var e=i.length;if(t>e){var n=new my(Math.max(2*e,t));n.set(i),i=n}},d=e.f||0,u=e.p||0,h=e.b||0,p=e.l,f=e.d,m=e.m,_=e.n,g=8*n;do{if(!p){d=zy(t,u,1);var y=zy(t,u+1,3);if(u+=3,!y){var v=t[(L=4+((u+7)/8|0))-4]|t[L-3]n){s&&By(0);break}o&&c(h+v),i.set(t.subarray(L,x),h),e.b=h+=v,e.p=u=8*x,e.f=d;continue}if(1==y)p=$y,f=ky,m=9,_=5;else if(2==y){var b=zy(t,u,31)+257,w=zy(t,u+10,15)+4,T=b+zy(t,u+5,31)+1;u+=14;for(var S=new my(T),E=new my(19),M=0;M>4)g){s&&By(0);break}}o&&c(h+131072);for(var R=(1>4;if((u+=15&$)>g){s&&By(0);break}if($||By(2),F264&&(N=zy(t,u,(1>4;if(U||By(3),u+=15&U,z=Ey[j],j>3){var V=vy[j];z+=Ry(t,u)&(1g){s&&By(0);break}o&&c(h+131072);var G=h+N;if(ha.length)&&(l=a.length),new my(a.subarray(0,l))):i.subarray(0,h)}(r.subarray(o,-8),{i:2},new my(((i=r)[(n=i.length)-4]|i[n-3]>>0))));var i,n,r,o;const s=Uy[e];if(!s)throw new Error(`Unhandled codec: ${e}`);const a=new globalThis.DecompressionStream(s);return new Response(new Blob([t]).stream().pipeThrough(a)).arrayBuffer().then((t=>new Uint8Array(t)))}(d,c).then((t=>(function(t,e){t.readFields(ly,e)}(new Lm(t),u),new(0,Gy[o])(u.buffer)))),h.then((t=>{for(let e=l.length-1;e>=0;e--)switch(l[e]){case"delta_filter":uy(t,s);break;case"zigzag_filter":hy(t);break;case"bitshuffle_filter":py(t,o);break;default:throw new Error(`Unhandled filter "${l[e]}"`)}return{layerName:i,blockIndex:a,data:t}})).catch((t=>{throw t}))})))};class Wy extends ey{constructor(t,e,i,n,r){super(t,e,i,n,r),this._workQueue=[],this._fetchQueue=[],this._isHeaderLoaded=!1}setTexture(t,e){const i=e.context,n=i.gl;this.texture=this.texture||e.getTileTexture(t.width),this.texture&&this.texture instanceof Vg?this.texture.update(t,{useMipmap:!1,premultiply:!1}):this.texture=new Vg(i,t,n.RGBA,{useMipmap:!1,premultiply:!1})}flushQueues(){for(;this._workQueue.length;)this._workQueue.pop()();for(;this._fetchQueue.length;)this._fetchQueue.pop()()}fetchHeader(t=16384,e){const i=this._mrt=new Zy(30),n=Object.assign({},this.requestParams,{headers:{Range:"bytes=0-"+(t-1)}});return this.entireBuffer=null,this.request=en(n,((n,r,o,s)=>{if(n)e(n);else try{const n=i.getHeaderLength(r);if(n>t)return void(this.request=this.fetchHeader(n,e));i.parseHeader(r),this._isHeaderLoaded=!0;let a=0;for(const t of Object.values(i.layers))a=Math.max(a,t.dataIndex[t.dataIndex.length-1].last_byte);r.byteLength>=a&&(this.entireBuffer=r),e(null,this.entireBuffer||r,o,s)}catch(t){e(t)}})),this.request}fetchBand(t,e,i){const n=this._mrt;if(!this._isHeaderLoaded||!n)return void i(new Error("Tile header is not ready"));const r=this.actor;if(!r)return void i(new Error("Can't fetch tile band without an actor"));let o;const s=(n,r)=>{o.complete(n,r),n?i(n):(this.updateTextureDescriptor(t,e),i(null,this.textureDescriptor&&this.textureDescriptor.img))},a=(t,e)=>{if(t)return i(t);const n=r.send("decodeRasterArray",{buffer:e,task:o},s,void 0,!0);this._workQueue.push((()=>{n&&n.cancel(),o.cancel()}))},l=n.getLayer(t);if(!l)return void i(new Error(`Unknown sourceLayer "${t}"`));if(l.hasDataForBand(e))return this.updateTextureDescriptor(t,e),void i(null,this.textureDescriptor?this.textureDescriptor.img:null);const c=l.getDataRange([e]);if(o=n.createDecodingTask(c),!o||o.tasks.length)if(this.flushQueues(),this.entireBuffer)a(null,this.entireBuffer.slice(c.firstByte,c.lastByte+1));else{const t=Object.assign({},this.requestParams,{headers:{Range:`bytes=${c.firstByte}-${c.lastByte}`}}),e=en(t,a);this._fetchQueue.push((()=>{e.cancel(),o.cancel()}))}else i(null)}updateNeeded(t,e){return(!this.textureDescriptor||this.textureDescriptor.band!==e||this.textureDescriptor.layer!==t)&&"errored"!==this.state}updateTextureDescriptor(t,e){if(!this._mrt)return;const i=this._mrt.getLayer(t);if(!i||!i.hasBand(e)||!i.hasDataForBand(e))return;const{bytes:n,tileSize:r,buffer:o,offset:s,scale:a}=i.getBandView(e),l=r+2*o,c={data:n,width:l,height:l},d=this.texture;d&&d instanceof Vg&&d.update(c,{useMipmap:!1,premultiply:!1}),this.textureDescriptor={layer:t,band:e,img:c,buffer:o,offset:s,tileSize:r,format:i.pixelFormat,mix:[a,256*a,65536*a,16777216*a]}}}class Yy{constructor(t,e){this.max=t,this.onRemove=e,this.reset()}reset(){for(const t in this.data)for(const e of this.data[t])e.timeout&&clearTimeout(e.timeout),this.onRemove(e.value);return this.data={},this.order=[],this}add(t,e,i){const n=t.wrapped().key;void 0===this.data[n]&&(this.data[n]=[]);const r={value:e,timeout:void 0};if(void 0!==i&&(r.timeout=setTimeout((()=>{this.remove(t,r)}),i)),this.data[n].push(r),this.order.push(n),this.order.length>this.max){const t=this._getAndRemoveByKey(this.order[0]);t&&this.onRemove(t)}return this}has(t){return t.wrapped().key in this.data}getAndRemove(t){return this.has(t)?this._getAndRemoveByKey(t.wrapped().key):null}_getAndRemoveByKey(t){const e=this.data[t].shift();return e.timeout&&clearTimeout(e.timeout),0===this.data[t].length&&delete this.data[t],this.order.splice(this.order.indexOf(t),1),e.value}getByKey(t){const e=this.data[t];return e?e[0].value:null}get(t){return this.has(t)?this.data[t.wrapped().key][0].value:null}remove(t,e){if(!this.has(t))return this;const i=t.wrapped().key,n=void 0===e?0:this.data[i].indexOf(e),r=this.data[i][n];return this.data[i].splice(n,1),r.timeout&&clearTimeout(r.timeout),0===this.data[i].length&&delete this.data[i],this.onRemove(r.value),this.order.splice(this.order.indexOf(i),1),this}setMaxSize(t){for(this.max=t;this.order.length>this.max;){const t=this._getAndRemoveByKey(this.order[0]);t&&this.onRemove(t)}return this}filter(t){const e=[];for(const i in this.data)for(const n of this.data[i])t(n.value)||e.push(n);for(const t of e)this.remove(t.value.tileID,t)}}class Xy extends zn{constructor(t,e,i){super(),this.id=t,this._onlySymbols=i,e.on("data",(t=>{"source"===t.dataType&&"metadata"===t.sourceDataType&&(this._sourceLoaded=!0),this._sourceLoaded&&!this._paused&&"source"===t.dataType&&"content"===t.sourceDataType&&(this.reload(),this.transform&&this.update(this.transform))})),e.on("error",(()=>{this._sourceErrored=!0})),this._source=e,this._tiles={},this._cache=new Yy(0,this._unloadTile.bind(this)),this._timers={},this._cacheTimers={},this._minTileCacheSize=e.minTileCacheSize,this._maxTileCacheSize=e.maxTileCacheSize,this._loadedParentTiles={},this.castsShadows=!1,this.tileCoverLift=0,this._coveredTiles={},this._shadowCasterTiles={},this._state=new km,this._isRaster="raster"===this._source.type||"raster-dem"===this._source.type||"raster-array"===this._source.type||"custom"===this._source.type&&"raster"===this._source._dataType}onAdd(t){this.map=t,this._minTileCacheSize=void 0===this._minTileCacheSize&&t?t._minTileCacheSize:this._minTileCacheSize,this._maxTileCacheSize=void 0===this._maxTileCacheSize&&t?t._maxTileCacheSize:this._maxTileCacheSize}loaded(){if(this._sourceErrored)return!0;if(!this._sourceLoaded)return!1;if(!this._source.loaded())return!1;for(const t in this._tiles){const e=this._tiles[t];if("errored"!==e.state&&("loaded"!==e.state||!e.bucketsLoaded()))return!1}return!0}getSource(){return this._source}pause(){this._paused=!0}resume(){if(!this._paused)return;const t=this._shouldReloadOnResume;this._paused=!1,this._shouldReloadOnResume=!1,t&&this.reload(),this.transform&&this.update(this.transform)}_loadTile(t,e){return t.isSymbolTile=this._onlySymbols,t.isExtraShadowCaster=this._shadowCasterTiles[t.tileID.key],this._source.loadTile(t,e)}_unloadTile(t){if(this._source.unloadTile)return this._source.unloadTile(t)}_abortTile(t){if(this._source.abortTile)return this._source.abortTile(t)}serialize(){return this._source.serialize()}prepare(t){this._source.prepare&&this._source.prepare(),this._state.coalesceChanges(this._tiles,this.map?this.map.painter:null);for(const e in this._tiles){const i=this._tiles[e];i.upload(t),i.prepare(this.map.style.imageManager,this.map?this.map.painter:null,this._source.scope)}}getIds(){return ti(this._tiles).map((t=>t.tileID)).sort(Ky).map((t=>t.key))}getRenderableIds(t,e){const i=[];for(const n in this._tiles)this._isIdRenderable(+n,t,e)&&i.push(this._tiles[n]);return t?i.sort(((t,e)=>{const i=t.tileID,n=e.tileID,r=new Ue(i.canonical.x,i.canonical.y)._rotate(this.transform.angle),o=new Ue(n.canonical.x,n.canonical.y)._rotate(this.transform.angle);return i.overscaledZ-n.overscaledZ||o.y-r.y||o.x-r.x})).map((t=>t.tileID.key)):i.map((t=>t.tileID)).sort(Ky).map((t=>t.key))}hasRenderableParent(t){const e=this.findLoadedParent(t,0);return!!e&&this._isIdRenderable(e.tileID.key)}_isIdRenderable(t,e,i){return this._tiles[t]&&this._tiles[t].hasData()&&!this._coveredTiles[t]&&(e||!this._tiles[t].holdingForFade())&&(i||!this._shadowCasterTiles[t])}reload(){if(this._paused)this._shouldReloadOnResume=!0;else{this._cache.reset();for(const t in this._tiles)"errored"!==this._tiles[t].state&&this._reloadTile(+t,"reloading")}}_reloadTile(t,e){const i=this._tiles[t];i&&("loading"!==i.state&&(i.state=e),this._loadTile(i,this._tileLoaded.bind(this,i,t,e)))}_tileLoaded(t,e,i,n){if(n)if(t.state="errored",404!==n.status)this._source.fire(new $n(n,{tile:t}));else{if(!(t.tileID.key in this._loadedParentTiles))return void this._source.fire(new Pn("data",{dataType:"source",sourceDataType:"error",sourceId:this._source.id}));if("raster-dem"===this._source.type&&this.usedForTerrain&&this.map.painter.terrain){const t=this.map.painter.terrain;this.update(this.transform,t.getScaledDemTileSize(),!0),t.resetTileLookupCache(this.id)}else this.update(this.transform)}else t.timeAdded=ki.now(),"expired"===i&&(t.refreshedUponExpiration=!0),this._setTileReloadTimer(e,t),"raster-dem"===this._source.type&&t.dem&&this._backfillDEM(t),this._state.initializeTileState(t,this.map?this.map.painter:null),this._source.fire(new Pn("data",{dataType:"source",tile:t,coord:t.tileID,sourceCacheId:this.id}))}_backfillDEM(t){const e=this.getRenderableIds();for(let n=0;n1||(Math.abs(i)>1&&(1===Math.abs(i+r)?i+=r:1===Math.abs(i-r)&&(i-=r)),e.dem&&t.dem&&(t.dem.backfillBorder(e.dem,i,n),t.neighboringTiles&&t.neighboringTiles[o]&&(t.neighboringTiles[o].backfilled=!0)))}}getTile(t){return this.getTileByID(t.key)}getTileByID(t){return this._tiles[t]}_retainLoadedChildren(t,e,i,n){for(const r in this._tiles){let o=this._tiles[r];if(n[r]||!o.hasData()||o.tileID.overscaledZi)continue;let s=o.tileID;for(;o&&o.tileID.overscaledZ>e+1;){const t=o.tileID.scaledTo(o.tileID.overscaledZ-1);o=this._tiles[t.key],o&&o.hasData()&&(s=t)}let a=s;for(;a.overscaledZ>e;)if(a=a.scaledTo(a.overscaledZ-1),t[a.key]){n[s.key]=s;break}}}findLoadedParent(t,e){if(t.key in this._loadedParentTiles){const i=this._loadedParentTiles[t.key];return i&&i.tileID.overscaledZ>=e?i:null}for(let i=t.overscaledZ-1;i>=e;i--){const e=t.scaledTo(i),n=this._getLoadedTile(e);if(n)return n}}_getLoadedTile(t){const e=this._tiles[t.key];return e&&e.hasData()?e:this._cache.getByKey(this._source.reparseOverscaled?t.wrapped().key:t.canonical.key)}updateCacheSize(t,e){e=e||this._source.tileSize;const i=Math.ceil(t.width/e)+1,n=Math.ceil(t.height/e)+1,r=Math.floor(i*n*5),o="number"==typeof this._minTileCacheSize?Math.max(this._minTileCacheSize,r):r,s="number"==typeof this._maxTileCacheSize?Math.min(this._maxTileCacheSize,o):o;this._cache.setMaxSize(s)}handleWrapJump(t){const e=Math.round((t-(void 0===this._prevLng?t:this._prevLng))/360);if(this._prevLng=t,e){const t={};for(const i in this._tiles){const n=this._tiles[i];n.tileID=n.tileID.unwrapTo(n.tileID.wrap+e),t[n.tileID.key]=n}this._tiles=t;for(const t in this._timers)clearTimeout(this._timers[t]),delete this._timers[t];for(const t in this._tiles)this._setTileReloadTimer(+t,this._tiles[t])}}update(t,e,i,n){if(this.transform=t,!this._sourceLoaded||this._paused||this.transform.freezeTileCoverage)return;if(this.usedForTerrain&&!i)return;let r;if(this.updateCacheSize(t,e),"globe"!==this.transform.projection.name&&this.handleWrapJump(this.transform.center.lng),this._shadowCasterTiles={},this._coveredTiles={},this.used||this.usedForTerrain){if(this._source.tileID)r=t.getVisibleUnwrappedCoordinates(this._source.tileID).map((t=>new vd(t.canonical.z,t.wrap,t.canonical.z,t.canonical.x,t.canonical.y)));else if(0!==this.tileCoverLift){const n=t.clone();n.tileCoverLift=this.tileCoverLift,r=n.coveringTiles({tileSize:e||this._source.tileSize,minzoom:this._source.minzoom,maxzoom:this._source.maxzoom,roundZoom:this._source.roundZoom&&!i,reparseOverscaled:this._source.reparseOverscaled,isTerrainDEM:this.usedForTerrain}),this._source.minzoomt(e)))}}else r=[];if(r.length>0&&this.castsShadows&&n&&"globe"!==this.transform.projection.name&&!this.usedForTerrain&&!Jy(this._source.type)){const o=t.coveringZoomLevel({tileSize:e||this._source.tileSize,roundZoom:this._source.roundZoom&&!i}),s=Math.min(o,this._source.maxzoom),a=t.extendTileCoverForShadows(r,n,s);for(const t of a)this._shadowCasterTiles[t.key]=!0,r.push(t)}const o=this._updateRetainedTiles(r);if(Jy(this._source.type)&&0!==r.length){const t={},e={},i=Object.keys(o);for(const n of i){const i=o[n],r=this._tiles[n];if(!r||r.fadeEndTime&&r.fadeEndTimen;){r=r.scaledTo(r.overscaledZ-1);const n=this._tiles[r.key];if(n&&n.hasData()&&e[r.key]){o[t]=i.tileID;break}}}for(const e in t)o[e]||(this._coveredTiles[e]=!0,o[e]=t[e])}for(const t in o)this._tiles[t].clearFadeHold();const s=function(t,e){const i=[];for(const n in t)n in e||i.push(n);return i}(this._tiles,o);for(const t of s){const e=this._tiles[t];e.hasSymbolBuckets&&!e.holdingForFade()?e.setHoldDuration(this.map._fadeDuration):e.hasSymbolBuckets&&!e.symbolFadeFinished()||this._removeTile(+t)}this._updateLoadedParentTileCache(),this._onlySymbols&&this._source.afterUpdate&&this._source.afterUpdate()}releaseSymbolFadeTiles(){for(const t in this._tiles)this._tiles[t].holdingForFade()&&this._removeTile(+t)}_updateRetainedTiles(t){const e={};if(0===t.length)return e;const i={},n=t.reduce(((t,e)=>Math.min(t,e.overscaledZ)),1/0),r=t[0].overscaledZ,o=Math.max(r-Xy.maxOverzooming,this._source.minzoom),s=Math.max(r+Xy.maxUnderzooming,this._source.minzoom),a={};for(const i of t){const t=this._addTile(i);e[i.key]=i,t.hasData()||n=this._source.maxzoom){const t=n.children(this._source.maxzoom)[0],i=this.getTile(t);if(i&&i.hasData()){e[t.key]=t;continue}}else{const t=n.children(this._source.maxzoom);if(e[t[0].key]&&e[t[1].key]&&e[t[2].key]&&e[t[3].key])continue}let r=t.wasRequested();for(let s=n.overscaledZ-1;s>=o;--s){const o=n.scaledTo(s);if(i[o.key])break;if(i[o.key]=!0,t=this.getTile(o),!t&&r&&(t=this._addTile(o)),t&&(e[o.key]=o,r=t.wasRequested(),t.hasData()))break}}return e}_updateLoadedParentTileCache(){this._loadedParentTiles={};for(const t in this._tiles){const e=[];let i,n=this._tiles[t].tileID;for(;n.overscaledZ>0;){if(n.key in this._loadedParentTiles){i=this._loadedParentTiles[n.key];break}e.push(n.key);const t=n.scaledTo(n.overscaledZ-1);if(i=this._getLoadedTile(t),i)break;n=t}for(const t of e)this._loadedParentTiles[t]=i}}_addTile(t){let e=this._tiles[t.key];if(e)return!0!==e.isExtraShadowCaster||!!this._shadowCasterTiles[t.key]||this._reloadTile(t.key,"reloading"),e;e=this._cache.getAndRemove(t),e&&(this._setTileReloadTimer(t.key,e),e.tileID=t,this._state.initializeTileState(e,this.map?this.map.painter:null),this._cacheTimers[t.key]&&(clearTimeout(this._cacheTimers[t.key]),delete this._cacheTimers[t.key],this._setTileReloadTimer(t.key,e)));const i=Boolean(e);if(!i){const i=this.map?this.map.painter:null,n=this._source.tileSize*t.overscaleFactor();e="raster-array"===this._source.type?new Wy(t,n,this.transform.tileZoom,i,this._isRaster):new ey(t,n,this.transform.tileZoom,i,this._isRaster),this._loadTile(e,this._tileLoaded.bind(this,e,t.key,e.state))}return e?(e.uses++,this._tiles[t.key]=e,i||this._source.fire(new Pn("dataloading",{tile:e,coord:e.tileID,dataType:"source"})),e):null}_setTileReloadTimer(t,e){t in this._timers&&(clearTimeout(this._timers[t]),delete this._timers[t]);const i=e.getExpiryTimeout();i&&(this._timers[t]=setTimeout((()=>{this._reloadTile(t,"expired"),delete this._timers[t]}),i))}_removeTile(t){const e=this._tiles[t];e&&(e.uses--,delete this._tiles[t],this._timers[t]&&(clearTimeout(this._timers[t]),delete this._timers[t]),e.uses>0||(e.hasData()&&"reloading"!==e.state||"empty"===e.state?this._cache.add(e.tileID,e,e.getExpiryTimeout()):(e.aborted=!0,this._abortTile(e),this._unloadTile(e))))}clearTiles(){this._shouldReloadOnResume=!1,this._paused=!1;for(const t in this._tiles)this._removeTile(+t);this._source._clear&&this._source._clear(),this._cache.reset(),this.map&&this.usedForTerrain&&this.map.painter.terrain&&this.map.painter.terrain.resetTileLookupCache(this.id)}tilesIn(t,e,i){const n=[],r=this.transform;if(!r)return n;const o="globe"===r.projection.name,s=Ed(r.center.lng);for(const a in this._tiles){const l=this._tiles[a];if(i&&l.clearQueryDebugViz(),l.holdingForFade())continue;let c;if(o){const t=l.tileID.canonical;if(0===t.z){const e=[Math.abs(Xe(s,...Qy(t,-1))-s),Math.abs(Xe(s,...Qy(t,1))-s)];c=[0,2*e.indexOf(Math.min(...e))-1]}else{const e=[Math.abs(Xe(s,...Qy(t,-1))-s),Math.abs(Xe(s,...Qy(t,0))-s),Math.abs(Xe(s,...Qy(t,1))-s)];c=[e.indexOf(Math.min(...e))-1]}}else c=[0];for(const i of c){const o=t.containsTile(l,r,e,i);o&&n.push(o)}}return n}getShadowCasterCoordinates(){return this._getRenderableCoordinates(!1,!0)}getVisibleCoordinates(t){return this._getRenderableCoordinates(t)}_getRenderableCoordinates(t,e){const i=this.getRenderableIds(t,e).map((t=>this._tiles[t].tileID)),n="globe"===this.transform.projection.name;for(const t of i)t.projMatrix=this.transform.calculateProjMatrix(t.toUnwrapped()),t.expandedProjMatrix=n?this.transform.calculateProjMatrix(t.toUnwrapped(),!1,!0):t.projMatrix;return i}sortCoordinatesByDistance(t){const e=t.slice(),i=this.transform._camera.position,n=this.transform._camera.forward(),r={};for(const t of e){const e=1/(1r[t.key]-r[e.key])),e}hasTransition(){if(this._source.hasTransition())return!0;if(Jy(this._source.type))for(const t in this._tiles){const e=this._tiles[t];if(void 0!==e.fadeEndTime&&e.fadeEndTime>=ki.now())return!0}return!1}setFeatureState(t,e,i){this._state.updateState(t=t||"_geojsonTileLayer",e,i)}removeFeatureState(t,e,i){this._state.removeFeatureState(t=t||"_geojsonTileLayer",e,i)}getFeatureState(t,e){return this._state.getState(t=t||"_geojsonTileLayer",e)}setDependencies(t,e,i){const n=this._tiles[t];n&&n.setDependencies(e,i)}reloadTilesForDependencies(t,e){for(const i in this._tiles)this._tiles[i].hasDependency(t,e)&&this._reloadTile(+i,"reloading");this._cache.filter((i=>!i.hasDependency(t,e)))}_preloadTiles(t,e){if(!this._sourceLoaded){const i=()=>{this._sourceLoaded&&(this._source.off("data",i),this._preloadTiles(t,e))};return void this._source.on("data",i)}const i=new Map,n=Array.isArray(t)?t:[t],r=this.map.painter.terrain,o=this.usedForTerrain&&r?r.getScaledDemTileSize():this._source.tileSize;for(const t of n){const e=t.coveringTiles({tileSize:o,minzoom:this._source.minzoom,maxzoom:this._source.maxzoom,roundZoom:this._source.roundZoom&&!this.usedForTerrain,reparseOverscaled:this._source.reparseOverscaled,isTerrainDEM:this.usedForTerrain});for(const t of e)i.set(t.key,t);this.usedForTerrain&&t.updateElevation(!1)}Qe(Array.from(i.values()),((t,e)=>{const i=new ey(t,this._source.tileSize*t.overscaleFactor(),this.transform.tileZoom,this.map.painter,this._isRaster);this._loadTile(i,(t=>{"raster-dem"===this._source.type&&i.dem&&this._backfillDEM(i),e(t,i)}))}),e)}}function Ky(t,e){const i=Math.abs(2*t.wrap)-+(t.wrap0?e+2*t:t}tv.useIntegerZoom=!0;const iv=new ol({"symbol-placement":new il(sl.layout_symbol["symbol-placement"]),"symbol-spacing":new il(sl.layout_symbol["symbol-spacing"]),"symbol-avoid-edges":new il(sl.layout_symbol["symbol-avoid-edges"]),"symbol-sort-key":new nl(sl.layout_symbol["symbol-sort-key"]),"symbol-z-order":new il(sl.layout_symbol["symbol-z-order"]),"symbol-z-elevate":new il(sl.layout_symbol["symbol-z-elevate"]),"icon-allow-overlap":new il(sl.layout_symbol["icon-allow-overlap"]),"icon-ignore-placement":new il(sl.layout_symbol["icon-ignore-placement"]),"icon-optional":new il(sl.layout_symbol["icon-optional"]),"icon-rotation-alignment":new il(sl.layout_symbol["icon-rotation-alignment"]),"icon-size":new nl(sl.layout_symbol["icon-size"]),"icon-text-fit":new nl(sl.layout_symbol["icon-text-fit"]),"icon-text-fit-padding":new nl(sl.layout_symbol["icon-text-fit-padding"]),"icon-image":new nl(sl.layout_symbol["icon-image"]),"icon-rotate":new nl(sl.layout_symbol["icon-rotate"]),"icon-padding":new il(sl.layout_symbol["icon-padding"]),"icon-keep-upright":new il(sl.layout_symbol["icon-keep-upright"]),"icon-offset":new nl(sl.layout_symbol["icon-offset"]),"icon-anchor":new nl(sl.layout_symbol["icon-anchor"]),"icon-pitch-alignment":new il(sl.layout_symbol["icon-pitch-alignment"]),"text-pitch-alignment":new il(sl.layout_symbol["text-pitch-alignment"]),"text-rotation-alignment":new il(sl.layout_symbol["text-rotation-alignment"]),"text-field":new nl(sl.layout_symbol["text-field"]),"text-font":new nl(sl.layout_symbol["text-font"]),"text-size":new nl(sl.layout_symbol["text-size"]),"text-max-width":new nl(sl.layout_symbol["text-max-width"]),"text-line-height":new nl(sl.layout_symbol["text-line-height"]),"text-letter-spacing":new nl(sl.layout_symbol["text-letter-spacing"]),"text-justify":new nl(sl.layout_symbol["text-justify"]),"text-radial-offset":new nl(sl.layout_symbol["text-radial-offset"]),"text-variable-anchor":new il(sl.layout_symbol["text-variable-anchor"]),"text-anchor":new nl(sl.layout_symbol["text-anchor"]),"text-max-angle":new il(sl.layout_symbol["text-max-angle"]),"text-writing-mode":new il(sl.layout_symbol["text-writing-mode"]),"text-rotate":new nl(sl.layout_symbol["text-rotate"]),"text-padding":new il(sl.layout_symbol["text-padding"]),"text-keep-upright":new il(sl.layout_symbol["text-keep-upright"]),"text-transform":new nl(sl.layout_symbol["text-transform"]),"text-offset":new nl(sl.layout_symbol["text-offset"]),"text-allow-overlap":new il(sl.layout_symbol["text-allow-overlap"]),"text-ignore-placement":new il(sl.layout_symbol["text-ignore-placement"]),"text-optional":new il(sl.layout_symbol["text-optional"]),visibility:new il(sl.layout_symbol.visibility)});var nv={paint:new ol({"icon-opacity":new nl(sl.paint_symbol["icon-opacity"]),"icon-occlusion-opacity":new nl(sl.paint_symbol["icon-occlusion-opacity"]),"icon-emissive-strength":new nl(sl.paint_symbol["icon-emissive-strength"]),"text-emissive-strength":new nl(sl.paint_symbol["text-emissive-strength"]),"icon-color":new nl(sl.paint_symbol["icon-color"]),"icon-halo-color":new nl(sl.paint_symbol["icon-halo-color"]),"icon-halo-width":new nl(sl.paint_symbol["icon-halo-width"]),"icon-halo-blur":new nl(sl.paint_symbol["icon-halo-blur"]),"icon-translate":new il(sl.paint_symbol["icon-translate"]),"icon-translate-anchor":new il(sl.paint_symbol["icon-translate-anchor"]),"icon-image-cross-fade":new nl(sl.paint_symbol["icon-image-cross-fade"]),"text-opacity":new nl(sl.paint_symbol["text-opacity"]),"text-occlusion-opacity":new nl(sl.paint_symbol["text-occlusion-opacity"]),"text-color":new nl(sl.paint_symbol["text-color"],{runtimeType:Qn,getOverride:t=>t.textColor,hasOverride:t=>!!t.textColor}),"text-halo-color":new nl(sl.paint_symbol["text-halo-color"]),"text-halo-width":new nl(sl.paint_symbol["text-halo-width"]),"text-halo-blur":new nl(sl.paint_symbol["text-halo-blur"]),"text-translate":new il(sl.paint_symbol["text-translate"]),"text-translate-anchor":new il(sl.paint_symbol["text-translate-anchor"]),"icon-color-saturation":new il(sl.paint_symbol["icon-color-saturation"]),"icon-color-contrast":new il(sl.paint_symbol["icon-color-contrast"]),"icon-color-brightness-min":new il(sl.paint_symbol["icon-color-brightness-min"]),"icon-color-brightness-max":new il(sl.paint_symbol["icon-color-brightness-max"])}),layout:iv};class rv{constructor(t){this.type=t.property.overrides?t.property.overrides.runtimeType:Yn,this.defaultValue=t}evaluate(t){if(t.formattedSection){const e=this.defaultValue.property.overrides;if(e&&e.hasOverride(t.formattedSection))return e.getOverride(t.formattedSection)}return t.feature&&t.featureState?this.defaultValue.evaluate(t.feature,t.featureState):this.defaultValue.property.specification.default}eachChild(t){this.defaultValue.isConstant()||t(this.defaultValue.value._styleExpression.expression)}outputDefined(){return!1}serialize(){return null}}ba(rv,"FormatSectionOverride",{omit:["defaultValue"]});class ov extends Ml{constructor(e,i,n,r){super(e,nv,i,n,r),this._colorAdjustmentMatrix=t.ad.identity([]),this.hasInitialOcclusionOpacityProperties=void 0!==e.paint&&("icon-occlusion-opacity"in e.paint||"text-occlusion-opacity"in e.paint)}recalculate(t,e){super.recalculate(t,e),"auto"===this.layout.get("icon-rotation-alignment")&&(this.layout._values["icon-rotation-alignment"]="point"!==this.layout.get("symbol-placement")?"map":"viewport"),"auto"===this.layout.get("text-rotation-alignment")&&(this.layout._values["text-rotation-alignment"]="point"!==this.layout.get("symbol-placement")?"map":"viewport"),"auto"===this.layout.get("text-pitch-alignment")&&(this.layout._values["text-pitch-alignment"]=this.layout.get("text-rotation-alignment")),"auto"===this.layout.get("icon-pitch-alignment")&&(this.layout._values["icon-pitch-alignment"]=this.layout.get("icon-rotation-alignment"));const i=this.layout.get("text-writing-mode");if(i){const t=[];for(const e of i)t.indexOf(e)i in t?String(t[i]):""))}(e.properties,r)}createBucket(t){return new jg(t)}queryRadius(){return 0}queryIntersectsFeature(){return!1}_setPaintOverrides(){for(const t of nv.paint.overridableProperties){if(!ov.hasPaintOverride(this.layout,t))continue;const e=this.paint.get(t),i=new rv(e),n=new la(i,e.property.specification,this.scope,this.options);let r=null;r="constant"===e.value.kind||"source"===e.value.kind?new ua("source",n):new ha("composite",n,e.value.zoomStops,e.value._interpolationType),this.paint._values[t]=new tl(e.property,r,e.parameters)}}_handleOverridablePaintPropertyUpdate(t,e,i){return!(!this.layout||e.isDataDriven()||i.isDataDriven())&&ov.hasPaintOverride(this.layout,t)}static hasPaintOverride(t,e){const i=t.get("text-field"),n=nv.paint.properties[e];let r=!1;const o=t=>{for(const e of t)if(n.overrides&&n.overrides.hasOverride(e))return void(r=!0)};if("constant"===i.value.kind&&i.value.value instanceof pr)o(i.value.value.sections);else if("source"===i.value.kind){const t=e=>{r||(e instanceof vr&&gr(e.value)===nr?o(e.value.sections):e instanceof Tr?o(e.sections):e.eachChild(t))},e=i.value;e._styleExpression&&t(e._styleExpression.expression)}return r}getProgramIds(){const t=0!==this.paint.get("icon-opacity").constantOr(1),e=0!==this.paint.get("text-opacity").constantOr(1),i=[];return t&&i.push("symbolIcon"),e&&i.push("symbolSDF"),i}getDefaultProgramParams(t,e,i){return{config:new Wc(this,{zoom:e,lut:i}),overrideFog:!1}}}const sv=new ol({visibility:new il(sl.layout_background.visibility)});var av={paint:new ol({"background-color":new il(sl.paint_background["background-color"]),"background-pattern":new il(sl.paint_background["background-pattern"]),"background-opacity":new il(sl.paint_background["background-opacity"]),"background-emissive-strength":new il(sl.paint_background["background-emissive-strength"])}),layout:sv};const lv=new ol({visibility:new il(sl.layout_raster.visibility)});var cv={paint:new ol({"raster-opacity":new il(sl.paint_raster["raster-opacity"]),"raster-color":new rl(sl.paint_raster["raster-color"]),"raster-color-mix":new il(sl.paint_raster["raster-color-mix"]),"raster-color-range":new il(sl.paint_raster["raster-color-range"]),"raster-hue-rotate":new il(sl.paint_raster["raster-hue-rotate"]),"raster-brightness-min":new il(sl.paint_raster["raster-brightness-min"]),"raster-brightness-max":new il(sl.paint_raster["raster-brightness-max"]),"raster-saturation":new il(sl.paint_raster["raster-saturation"]),"raster-contrast":new il(sl.paint_raster["raster-contrast"]),"raster-resampling":new il(sl.paint_raster["raster-resampling"]),"raster-fade-duration":new il(sl.paint_raster["raster-fade-duration"]),"raster-emissive-strength":new il(sl.paint_raster["raster-emissive-strength"]),"raster-array-band":new il(sl.paint_raster["raster-array-band"]),"raster-elevation":new il(sl.paint_raster["raster-elevation"])}),layout:lv};function dv(e,i,n,r,o,s,a,l){const c=[e,i,1,n,r,1,o,s,1],d=[a,l,1],u=t.bC.adjoint([],c),[h,p,f]=t._.transformMat3(d,d,u);return t.bC.multiply(c,c,[h,0,0,0,p,0,0,0,f])}function uv(e,i,n,r,o,s,a,l){const c=function(e,i,n,r,o,s,a,l){const c=dv(0,0,1,0,1,1,0,1),d=dv(e,i,n,r,o,s,a,l),u=t.bC.adjoint([],c);return t.bC.multiply(d,d,u)}(e,i,n,r,o,s,a,l);return[c[2]/c[8]/uo,c[5]/c[8]/uo]}function hv(t){return[t[0],Math.min(Math.max(t[1],-Pd),Pd)]}class pv extends zn{constructor(t,e,i,n){super(),this.id=t,this.dispatcher=i,this.coordinates=e.coordinates,this.type="image",this.minzoom=0,this.maxzoom=22,this.tileSize=512,this.tiles={},this._loaded=!1,this.onNorthPole=!1,this.onSouthPole=!1,this.setEventedParent(n),this.options=e,this._dirty=!1}load(t,e){if(this._loaded=e||!1,this.fire(new Pn("dataloading",{dataType:"source"})),this.url=this.options.url,!this.url)return t&&(this.coordinates=t),this._loaded=!0,void this._finishLoading();this._imageRequest=an(this.map._requestManager.transformRequest(this.url,Ki.Image),((e,i)=>{this._imageRequest=null,this._loaded=!0,e?this.fire(new $n(e)):i&&(this.image=i instanceof HTMLImageElement?ki.getImageData(i):i,this._dirty=!0,this.width=this.image.width,this.height=this.image.height,t&&(this.coordinates=t),this._finishLoading())}))}loaded(){return this._loaded}updateImage(t){return t.url?(this._imageRequest&&t.url!==this.options.url&&(this._imageRequest.cancel(),this._imageRequest=null),this.options.url=t.url,this.load(t.coordinates,this._loaded),this):this}setTexture(t){if(!(t.handle instanceof WebGLTexture))throw new Error("The provided handle is not a WebGLTexture instance");return this.texture=new Gg(this.map.painter.context,t.handle),this.width=t.dimensions[0],this.height=t.dimensions[1],this._dirty=!1,this._loaded=!0,this._finishLoading(),this}_finishLoading(){this.map&&(this.setCoordinates(this.coordinates),this.fire(new Pn("data",{dataType:"source",sourceDataType:"metadata"})))}onAdd(t){this.map=t,this.load()}onRemove(t){this._imageRequest&&(this._imageRequest.cancel(),this._imageRequest=null),!this.texture||this.texture instanceof Gg||this.texture.destroy(),this.boundsBuffer&&(this.boundsBuffer.destroy(),this.elevatedGlobeVertexBuffer&&this.elevatedGlobeVertexBuffer.destroy(),this.elevatedGlobeIndexBuffer&&this.elevatedGlobeIndexBuffer.destroy())}setCoordinates(t){if(this.coordinates=t,this._boundsArray=void 0,this._unsupportedCoords=!1,!t.length)return this;this.onNorthPole=!1,this.onSouthPole=!1;let e=t[0][1],i=t[0][1];for(const n of t)n[1]>i&&(i=n[1]),n[1]Pd?this.onNorthPole=!0:n1&&(l-=1),new gd(s,l,Math.floor((i+r)/2*a))}(e),this.minzoom=this.maxzoom=this.tileID.z}return this.fire(new Pn("data",{dataType:"source",sourceDataType:"content"})),this}_clear(){this._boundsArray=void 0,this._unsupportedCoords=!1}_prepareData(e){for(const t in this.tiles){const e=this.tiles[t];"loaded"!==e.state&&(e.state="loaded",e.texture=this.texture)}if(this._boundsArray||this.onNorthPole||this.onSouthPole||this._unsupportedCoords)return;const i=eg(new gd(0,0,0),this.map.transform.projection),n=[i.projection.project(this.coordinates[0][0],this.coordinates[0][1]),i.projection.project(this.coordinates[1][0],this.coordinates[1][1]),i.projection.project(this.coordinates[2][0],this.coordinates[2][1]),i.projection.project(this.coordinates[3][0],this.coordinates[3][1])];if(!function(t){const e=t[1].x-t[0].x,i=t[1].y-t[0].y,n=t[2].x-t[1].x,r=t[2].y-t[1].y,o=t[3].x-t[2].x,s=t[3].y-t[2].y,a=t[0].x-t[3].x,l=t[0].y-t[3].y,c=e*r-n*i,d=n*s-o*r,u=o*l-a*s,h=a*i-e*l;return c>0&&d>0&&u>0&&h>0||c{const e=r.projection.project(t[0],t[1]);return ig(r,e)._round()}));this.perspectiveTransform=uv(o.x,o.y,s.x,s.y,a.x,a.y,l.x,l.y);const c=this._boundsArray=new Dl;c.emplaceBack(o.x,o.y,0,0),c.emplaceBack(s.x,s.y,uo,0),c.emplaceBack(l.x,l.y,0,uo),c.emplaceBack(a.x,a.y,uo,uo),this.boundsBuffer&&(this.boundsBuffer.destroy(),this.elevatedGlobeVertexBuffer&&this.elevatedGlobeVertexBuffer.destroy(),this.elevatedGlobeIndexBuffer&&this.elevatedGlobeIndexBuffer.destroy()),this.boundsBuffer=e.createVertexBuffer(c,Jg.members),this.boundsSegments=wc.simpleSegment(0,0,4,2);const d=[],u=function(t){return[hv(t[0]),hv(t[1]),hv(t[2]),hv(t[3])]}(this.coordinates),[h,p,f,m]=function(t){let e=t[0][0],i=e,n=t[0][1],r=n;for(let o=1;oi&&(i=t[o][0]),t[o][1]r&&(r=t[o][1]);return[e,n,i-e,r-n]}(u);{const r=new Dl,[o,s,a,l]=function(t){let e=t[0].x,i=e,n=t[0].y,r=n;for(let o=1;oi&&(i=t[o].x),t[o].yr&&(r=t[o].y);return[e,n,i-e,r-n]}(n),c=t=>[(t.x-o)/a,(t.y-s)/l],[u,_,g,y]=n.map(c),v=function(e,i,n,r,o,s,a,l){const c=dv(0,0,1,0,1,1,0,1),d=dv(e,i,n,r,o,s,a,l),u=t.bC.adjoint([],d);return t.bC.multiply(c,c,u)}(u[0],u[1],_[0],_[1],g[0],g[1],y[0],y[1]);this.elevatedGlobePerspectiveTransform=uv(u[0],u[1],_[0],_[1],g[0],g[1],y[0],y[1]);const x=(e,i)=>{d.push(e.lng);const n=Math.round((e.lng-h)/f*uo),o=Math.round((e.lat-p)/m*uo),s=c(i),a=t._.transformMat3([],[s[0],s[1],1],v),l=Math.round(a[0]/a[2]*uo),u=Math.round(a[1]/a[2]*uo);r.emplaceBack(n,o,l,u)},b=n[3].x-n[0].x,w=n[3].y-n[0].y,T=n[2].x-n[1].x,S=n[2].y-n[1].y;for(let t=0;t{i.emplaceBack(e,n,r);const o=d[e],s=d[n],a=d[r],l=Math.min(Math.min(o,s),a),c=Math.max(Math.max(o,s),a)-l;c>this.maxLongitudeTriangleSize&&(this.maxLongitudeTriangleSize=c),t.push(l+c/2)};for(let t=0;te));i.sort(((e,i)=>t[e]-t[i]));const n=[],r=new Kl;for(let o=0;o{o.segments.push({vertexOffset:0,primitiveOffset:t,vertexLength:e.segments[0].vertexLength,primitiveLength:i,sortKey:void 0,vaos:{}})},a=.51*this.maxLongitudeTriangleSize;if(Math.abs(i[0]-n)0){const n=function(e,i){const n=i.worldSize,r=Cd(1,0)*n*kd(i.center.lat,i.zoom)/Gu(n),o=Cd(1,i.center.lat)*n,s=t.ad.identity([]);return t.ad.rotateY(s,s,Ge(i.center.lng)),t.ad.rotateX(s,s,Ge(i.center.lat)),t.ad.translate(s,s,[0,0,ed]),t.ad.scale(s,s,[r,r,r*o]),t.ad.translate(s,s,[i.point.x-.5*n,i.point.y-.5*n,0]),t.ad.multiply(s,s,e),t.ad.multiply(s,i.globeMatrix,s)}(e,i);return function(e,i,n){const r=(e,i,n)=>{const r=t._.length(e),o=t._.length(i),s=ku(e,i,n);return t._.scale(s,s,1/t._.length(s)*Vn(r,o,n))},o=r([e[0],e[1],e[2]],[i[0],i[1],i[2]],n),s=r([e[4],e[5],e[6]],[i[4],i[5],i[6]],n),a=r([e[8],e[9],e[10]],[i[8],i[9],i[10]],n),l=ku([e[12],e[13],e[14]],[i[12],i[13],i[14]],n);return[o[0],o[1],o[2],0,s[0],s[1],s[2],0,a[0],a[1],a[2],0,l[0],l[1],l[2],1]}(o,n,r)}return o}function kv(t,e,i,n){const r=wu.projectAabbCorners(n,i);let o=Number.MAX_VALUE,s=-1;for(let t=0;tnew Ue(r[t][0],r[t][1]);let l;switch(s){case 0:case 6:l=[a(1),a(5),a(4),a(7),a(3),a(2),a(1)];break;case 1:case 7:l=[a(0),a(4),a(5),a(6),a(2),a(3),a(0)];break;case 3:case 5:l=[a(1),a(0),a(4),a(7),a(6),a(2),a(1)];break;default:l=[a(1),a(5),a(6),a(7),a(3),a(0),a(1)]}if(Yd(t,l))return o}const Dv=Ll([{name:"a_pos_3f",components:3,type:"Float32"}]),zv=Ll([{name:"a_color_3f",components:3,type:"Float32"}]),Rv=Ll([{name:"a_color_4f",components:4,type:"Float32"}]),Ov=Ll([{name:"a_uv_2f",components:2,type:"Float32"}]),Bv=Ll([{name:"a_normal_3f",components:3,type:"Float32"}]),Fv=Ll([{name:"a_normal_matrix0",components:4,type:"Float32"},{name:"a_normal_matrix1",components:4,type:"Float32"},{name:"a_normal_matrix2",components:4,type:"Float32"},{name:"a_normal_matrix3",components:4,type:"Float32"}]),Nv=Ll([{name:"a_pbr",components:4,type:"Uint16"},{name:"a_heightBasedEmissiveStrength",components:3,type:"Float32"}]);class Uv{constructor(t,e,i,n){this.message=(t?`${t}: `:"")+i,n&&(this.identifier=n),null!=e&&e.__line__&&(this.line=e.__line__)}}function jv(t,e){const i=-1===t.indexOf("://");try{return new URL(t,i&&e?"http://example.com":void 0),!0}catch(t){return!1}}class Vv{constructor(t,e){this.feature=t,this.instancedDataOffset=e,this.instancedDataCount=0,this.rotation=[0,0,0],this.scale=[1,1,1],this.translation=[0,0,0]}}class Gv{constructor(){this.instancedDataArray=new oc,this.instancesEvaluatedElevation=[],this.features=[],this.idToFeaturesIndex={}}}class Zv{constructor(t){this.zoom=t.zoom,this.canonical=t.canonical,this.layers=t.layers,this.layerIds=this.layers.map((t=>t.fqid)),this.projection=t.projection,this.index=t.index,this.hasZoomDependentProperties=this.layers[0].isZoomDependent(),this.stateDependentLayerIds=this.layers.filter((t=>t.isStateDependent())).map((t=>t.id)),this.hasPattern=!1,this.instancesPerModel={},this.validForExaggeration=0,this.maxVerticalOffset=0,this.maxScale=0,this.maxHeight=0,this.lookupDim=this.zoom>this.canonical.z?256:this.zoom>15?75:100,this.instanceCount=0,this.terrainElevationMin=0,this.terrainElevationMax=0,this.validForDEMTile={id:null,timestamp:0},this.modelUris=[],this.modelsRequested=!1,this.activeReplacements=[],this.replacementUpdateTime=0}updateFootprints(t,e){}populate(t,e,i,n){this.tileToMeter=zd(i);const r=this.layers[0]._featureFilter.needGeometry;this.lookup=new Uint8Array(this.lookupDim*this.lookupDim);for(const{feature:o,id:s,index:a,sourceLayerIndex:l}of t){const t=null!=s?s:o.properties&&o.properties.hasOwnProperty("id")?o.properties.id:void 0,c=Zd(o,r);if(!this.layers[0]._featureFilter.filter(new Ha(this.zoom),c,i))continue;const d={id:t,sourceLayerIndex:l,index:a,geometry:r?c.geometry:Gd(o,i,n),properties:o.properties,type:o.type,patterns:{}},u=this.addFeature(d,d.geometry,c);u&&e.featureIndex.insert(o,d.geometry,a,l,this.index,this.instancesPerModel[u].instancedDataArray.length,uo/32)}this.lookup=null}update(t,e,i,n){for(const e in this.instancesPerModel){const i=this.instancesPerModel[e];for(const e in t)i.idToFeaturesIndex.hasOwnProperty(e)&&(this.evaluate(i.features[i.idToFeaturesIndex[e]],t[e],i,!0),this.uploaded=!1)}this.maxHeight=0}updateZoomBasedPaintProperties(){if(!this.hasZoomDependentProperties)return!1;let e=!1;for(const i in this.instancesPerModel){const n=this.instancesPerModel[i];for(const i of n.features){const r=this.layers[0],o=i.feature,s=this.canonical,a=r.paint.get("model-rotation").evaluate(o,{},s),l=r.paint.get("model-scale").evaluate(o,{},s),c=r.paint.get("model-translation").evaluate(o,{},s);t._.exactEquals(i.rotation,a)&&t._.exactEquals(i.scale,l)&&t._.exactEquals(i.translation,c)||(this.evaluate(i,i.featureStates,n,!0),e=!0)}}return e}updateReplacement(t,e,i){if(e.updateTime===this.replacementUpdateTime)return!1;this.replacementUpdateTime=e.updateTime;const n=e.getReplacementRegionsForTile(t.toUnwrapped(),!0);if(Pp(this.activeReplacements,n))return!1;this.activeReplacements=n;let r=!1;for(const e in this.instancesPerModel){const n=this.instancesPerModel[e],o=n.instancedDataArray;for(const e of n.features){const n=e.instancedDataOffset,s=e.instancedDataCount;for(let e=0;euo?a-uo:a;const l=Math.floor(a),c=o.float32[s+1];let d=!1;for(const e of this.activeReplacements)if(!(e.orderl||l>e.max.x||e.min.y>c||c>e.max.y)&&(d=Op(Rp(l,c,t.canonical,e.footprintTileId.canonical),e),d))break;o.float32[s]=d?a+uo:a,r=r||d}}}return r}isEmpty(){for(const t in this.instancesPerModel)if(0!==this.instancesPerModel[t].instancedDataArray.length)return!1;return!0}uploadPending(){return!this.uploaded}upload(t){if(!this.uploaded)for(const e in this.instancesPerModel){const i=this.instancesPerModel[e];i.instancedDataArray.length=uo||e.y=uo)continue;const t=(this.lookupDim-1)/uo,i=this.lookupDim*(e.y*t|0)+e.x*t|0;if(this.lookup){if(0!==this.lookup[i])continue;this.lookup[i]=1}this.instanceCount++;const n=s.length;s.resize(n+1),o.instancesEvaluatedElevation.push(0),s.float32[16*n]=e.x,s.float32[16*n+1]=e.y}return a.instancedDataCount=o.instancedDataArray.length-a.instancedDataOffset,a.instancedDataCount>0&&(t.id&&(o.idToFeaturesIndex[t.id]=o.features.length),o.features.push(a),this.evaluate(a,{},o,!1)),r}getModelUris(){return this.modelUris}evaluate(t,e,i,n){const r=this.layers[0],o=t.feature,s=this.canonical,a=t.rotation=r.paint.get("model-rotation").evaluate(o,e,s),l=t.scale=r.paint.get("model-scale").evaluate(o,e,s),c=t.translation=r.paint.get("model-translation").evaluate(o,e,s),d=r.paint.get("model-color").evaluate(o,e,s);d.a=r.paint.get("model-color-mix-intensity").evaluate(o,e,s);const u=[];this.maxVerticalOffset10?this.tileToMeter:zd(s,p)),a[o+4]=c[0],a[o+5]=c[1],a[o+6]=c[2]+l,a[o+7]=u[0],a[o+8]=u[1],a[o+9]=u[2],a[o+10]=u[4],a[o+11]=u[5],a[o+12]=u[6],a[o+13]=u[8],a[o+14]=u[9],a[o+15]=u[10],i.instancesEvaluatedElevation[r]=c[2]}}}ba(Zv,"ModelBucket",{omit:["layers"]}),ba(Gv,"PerModelAttributes"),ba(Vv,"ModelFeature");const qv=new ol({visibility:new il(sl.layout_model.visibility),"model-id":new nl(sl.layout_model["model-id"])});var Hv={paint:new ol({"model-opacity":new il(sl.paint_model["model-opacity"]),"model-rotation":new nl(sl.paint_model["model-rotation"]),"model-scale":new nl(sl.paint_model["model-scale"]),"model-translation":new nl(sl.paint_model["model-translation"]),"model-color":new nl(sl.paint_model["model-color"]),"model-color-mix-intensity":new nl(sl.paint_model["model-color-mix-intensity"]),"model-type":new il(sl.paint_model["model-type"]),"model-cast-shadows":new il(sl.paint_model["model-cast-shadows"]),"model-receive-shadows":new il(sl.paint_model["model-receive-shadows"]),"model-ambient-occlusion-intensity":new il(sl.paint_model["model-ambient-occlusion-intensity"]),"model-emissive-strength":new nl(sl.paint_model["model-emissive-strength"]),"model-roughness":new nl(sl.paint_model["model-roughness"]),"model-height-based-emissive-strength-multiplier":new nl(sl.paint_model["model-height-based-emissive-strength-multiplier"]),"model-cutoff-fade-range":new il(sl.paint_model["model-cutoff-fade-range"]),"model-front-cutoff":new il(sl.paint_model["model-front-cutoff"])}),layout:qv};const Wv=64,Yv={CoordinateSpaceTile:1,CoordinateSpaceYUp:2,HasMapboxMeshFeatures:4,HasMeshoptCompression:8};function Xv(e,i,n,r,o,s,a,l,c,d=!1){const u=n.zoom,h=n.project(r),p=kd(r.lat,u),f=1/p;t.ad.identity(e),t.ad.translate(e,e,[h.x+a[0]*f,h.y+a[1]*f,a[2]]);let m=1,_=1;const g=n.worldSize;if(d){if("mercator"===n.projection.name){let e=0;n.elevation&&(e=n.elevation.getAtPointOrZero(new Rd(h.x/g,h.y/g),0));const i=t.aA.transformMat4([],[h.x,h.y,e,1],n.projMatrix)[3]/n.cameraToCenterDistance;m=i,_=i*kd(n.center.lat,u)}else if("globe"===n.projection.name){const i=$v(e,n),o=t.ad.multiply([],n.projMatrix,i),s=[0,0,0,1];t.aA.transformMat4(s,s,o);const a=s[3]/n.cameraToCenterDistance,l=Hu(u),c=n.projection.pixelsPerMeter(r.lat,g)*kd(r.lat,u),d=n.projection.pixelsPerMeter(n.center.lat,g)*kd(n.center.lat,u);m=a/Vn(c,$d(n.center.lat),l),_=a*p/c,m*=d,_*=d}}else m=f;t.ad.scale(e,e,[m,m,_]);const y=[...e],v=i.orientation,x=[];if(Lv(x,[v[0]+o[0],v[1]+o[1],v[2]+o[2]],s),t.ad.multiply(e,y,x),l&&n.elevation){let o=0;const s=[];if(c&&n.elevation){o=function(e,i,n,r,o){const s=i.elevation;if(!s)return 0;const a=wu.projectAabbCorners(n,r),l=Cd(1,o.lat)*i.worldSize,c=function(e,i){const n=[0,0,1],r=[{corners:[0,1,3,2],dotProductWithUp:0},{corners:[1,5,2,6],dotProductWithUp:0},{corners:[0,4,1,5],dotProductWithUp:0},{corners:[2,6,3,7],dotProductWithUp:0},{corners:[4,7,5,6],dotProductWithUp:0},{corners:[0,3,4,7],dotProductWithUp:0}];for(const o of r){const r=e[o.corners[0]],s=e[o.corners[1]],a=e[o.corners[2]],l=[s[0]-r[0],s[1]-r[1],i*(s[2]-r[2])],c=t._.cross(l,l,[a[0]-r[0],a[1]-r[1],i*(a[2]-r[2])]);t._.normalize(c,c),o.dotProductWithUp=t._.dot(c,n)}return r.sort(((t,e)=>t.dotProductWithUp-e.dotProductWithUp)),r[0].corners}(a,l),d=a[c[0]],u=a[c[1]],h=a[c[2]],p=a[c[3]],f=s.getAtPointOrZero(new Rd(d[0]/i.worldSize,d[1]/i.worldSize),0),m=s.getAtPointOrZero(new Rd(u[0]/i.worldSize,u[1]/i.worldSize),0),_=s.getAtPointOrZero(new Rd(h[0]/i.worldSize,h[1]/i.worldSize),0),g=s.getAtPointOrZero(new Rd(p[0]/i.worldSize,p[1]/i.worldSize),0),y=(f+g)/2,v=(m+_)/2;return y>v?m=e.gl.NEAREST_MIPMAP_NEAREST}),t.uploaded=!0,t.image=null)}function Jv(t,e,i){t.indexBuffer=e.createIndexBuffer(t.indexArray,!1,!0),t.vertexBuffer=e.createVertexBuffer(t.vertexArray,Dv.members,!1,!0),t.normalArray&&(t.normalBuffer=e.createVertexBuffer(t.normalArray,Bv.members,!1,!0)),t.texcoordArray&&(t.texcoordBuffer=e.createVertexBuffer(t.texcoordArray,Ov.members,!1,!0)),t.colorArray&&(t.colorBuffer=e.createVertexBuffer(t.colorArray,(12===t.colorArray.bytesPerElement?zv:Rv).members,!1,!0)),t.featureArray&&(t.pbrBuffer=e.createVertexBuffer(t.featureArray,Nv.members,!0)),t.segments=wc.simpleSegment(0,0,t.vertexArray.length,t.indexArray.length);const n=t.material;n.pbrMetallicRoughness.baseColorTexture&&Kv(n.pbrMetallicRoughness.baseColorTexture,e),n.pbrMetallicRoughness.metallicRoughnessTexture&&Kv(n.pbrMetallicRoughness.metallicRoughnessTexture,e),n.normalTexture&&Kv(n.normalTexture,e),n.occlusionTexture&&Kv(n.occlusionTexture,e,i),n.emissionTexture&&Kv(n.emissionTexture,e)}function Qv(t,e,i){if(t.meshes)for(const n of t.meshes)Jv(n,e,i);if(t.children)for(const n of t.children)Qv(n,e,i)}function tx(t){if(t.meshes)for(const e of t.meshes)e.indexArray.destroy(),e.vertexArray.destroy(),e.colorArray&&e.colorArray.destroy(),e.normalArray&&e.normalArray.destroy(),e.texcoordArray&&e.texcoordArray.destroy(),e.featureArray&&e.featureArray.destroy();if(t.children)for(const e of t.children)tx(e)}function ex(t){if(t.meshes)for(const i of t.meshes)i.vertexBuffer&&(i.vertexBuffer.destroy(),i.indexBuffer.destroy(),i.normalBuffer&&i.normalBuffer.destroy(),i.texcoordBuffer&&i.texcoordBuffer.destroy(),i.colorBuffer&&i.colorBuffer.destroy(),i.pbrBuffer&&i.pbrBuffer.destroy(),i.segments.destroy(),i.material&&((e=i.material).pbrMetallicRoughness.baseColorTexture&&e.pbrMetallicRoughness.baseColorTexture.gfxTexture&&e.pbrMetallicRoughness.baseColorTexture.gfxTexture.destroy(),e.pbrMetallicRoughness.metallicRoughnessTexture&&e.pbrMetallicRoughness.metallicRoughnessTexture.gfxTexture&&e.pbrMetallicRoughness.metallicRoughnessTexture.gfxTexture.destroy(),e.normalTexture&&e.normalTexture.gfxTexture&&e.normalTexture.gfxTexture.destroy(),e.emissionTexture&&e.emissionTexture.gfxTexture&&e.emissionTexture.gfxTexture.destroy(),e.occlusionTexture&&e.occlusionTexture.gfxTexture&&e.occlusionTexture.gfxTexture.destroy()));var e;if(t.children)for(const e of t.children)ex(e)}class ix{constructor(t){this._callback=t,this._triggered=!1,"undefined"!=typeof MessageChannel&&(this._channel=new MessageChannel,this._channel.port2.onmessage=()=>{this._triggered=!1,this._callback()})}trigger(){this._triggered||(this._triggered=!0,this._channel?this._channel.port1.postMessage(!0):setTimeout((()=>{this._triggered=!1,this._callback()}),0))}remove(){this._channel=void 0,this._callback=()=>{}}}class nx{constructor(){this.tasks={},this.taskQueue=[],ai(["process"],this),this.invoker=new ix(this.process),this.nextId=0}add(t,e){const i=this.nextId++,n=function({type:t,isSymbolTile:e,zoom:i}){return i=i||0,"message"===t?0:"maybePrepare"!==t||e?"parseTile"!==t||e?"parseTile"===t&&e?300-i:"maybePrepare"===t&&e?400-i:500:200-i:100-i}(e);if(0===n){try{t()}finally{}return null}return this.tasks[i]={fn:t,metadata:e,priority:n,id:i},this.taskQueue.push(i),this.invoker.trigger(),{cancel:()=>{delete this.tasks[i]}}}process(){try{if(this.taskQueue=this.taskQueue.filter((t=>!!this.tasks[t])),!this.taskQueue.length)return;const t=this.pick();if(null===t)return;const e=this.tasks[t];if(delete this.tasks[t],this.taskQueue.length&&this.invoker.trigger(),!e)return;e.fn()}finally{}}pick(){let t=null,e=1/0;for(let i=0;i{i&&delete this.callbacks[s],this.target.postMessage({id:s,type:"",targetMapId:n,sourceMapId:this.mapId})}}}receive(t){const e=t.data,i=e.id;if(i&&(!e.targetMapId||this.mapId===e.targetMapId))if(""===e.type){const t=this.cancelCallbacks[i];delete this.cancelCallbacks[i],t&&t.cancel()}else if(e.mustQueue||gi()){const t=this.callbacks[i],n=this.scheduler.add((()=>this.processTask(i,e)),t&&t.metadata||{type:"message"});n&&(this.cancelCallbacks[i]=n)}else this.processTask(i,e)}processTask(t,e){if(delete this.cancelCallbacks[t],""===e.type){const i=this.callbacks[t];delete this.callbacks[t],i&&(e.error?i(Ea(e.error)):i(null,Ea(e.data)))}else{const i=new Set,n=e.hasCallback?(e,n)=>{this.target.postMessage({id:t,type:"",sourceMapId:this.mapId,error:e?Sa(e):null,data:Sa(n,i)},i)}:t=>{},r=Ea(e.data);if(this.parent[e.type])this.parent[e.type](e.sourceMapId,r,n);else if(this.parent.getWorkerSource){const t=e.type.split(".");this.parent.getWorkerSource(e.sourceMapId,t[0],r.source,r.scope)[t[1]](r,n)}else n(new Error(`Could not find function ${e.type}`))}}remove(){this.scheduler.remove(),this.target.removeEventListener("message",this.receive,!1)}}class ox{constructor(t,e){this.workerPool=t,this.actors=[],this.currentActor=0,this.id=ni();const i=this.workerPool.acquire(this.id);for(let t=0;t{this.ready=!0}))}broadcast(t,e,i){Qe(this.actors,((i,n)=>{i.send(t,e,n)}),i=i||function(){})}getActor(){return this.currentActor=(this.currentActor+1)%this.actors.length,this.actors[this.currentActor]}remove(){this.actors.forEach((t=>{t.remove()})),this.actors=[],this.workerPool.release(this.id)}}ox.Actor=rx;var sx={workerUrl:"",workerClass:null,workerParams:void 0};function ax(){return null!=sx.workerClass?new sx.workerClass:new self.Worker(sx.workerUrl,sx.workerParams)}const lx="mapboxgl_preloaded_worker_pool";class cx{constructor(){this.active={}}acquire(t){if(!this.workers)for(this.workers=[];this.workers.length{t.terminate()})),this.workers=null)}isPreloaded(){return!!this.active[lx]}numActive(){return Object.keys(this.active).length}}let dx;function ux(){return dx||(dx=new cx),dx}cx.workerCount=2;let hx,px,fx,mx,_x,gx=null;function yx(){return gi()&&self.worker&&self.worker.dracoUrl?self.worker.dracoUrl:px||n.DRACO_URL}function vx(){if(gi()&&self.worker&&self.worker.meshoptUrl)return self.worker.meshoptUrl;if(mx)return mx;const t=new Uint8Array([0,97,115,109,1,0,0,0,1,4,1,96,0,0,3,3,2,0,0,5,3,1,0,1,12,1,0,10,22,2,12,0,65,0,65,0,65,0,252,10,0,0,11,7,0,65,0,253,15,26,11]);if("object"!=typeof WebAssembly)throw new Error("WebAssembly not supported, cannot instantiate meshoptimizer");return mx=WebAssembly.validate(t)?n.MESHOPT_SIMD_URL:n.MESHOPT_URL,mx}const xx={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},bx={5120:"DT_INT8",5121:"DT_UINT8",5122:"DT_INT16",5123:"DT_UINT16",5125:"DT_UINT32",5126:"DT_FLOAT32"},wx={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16};function Tx(t,e,i){const n=i.json.bufferViews.length,r=i.buffers.length;e.bufferView=n,i.json.bufferViews[n]={buffer:r,byteLength:t.byteLength},i.buffers[r]=t}const Sx="KHR_draco_mesh_compression";function Ex(t,e){const i=t.extensions&&t.extensions[Sx];if(!i)return;const n=new fx.Decoder,r=$x(e,i.bufferView),o=new fx.Mesh;if(!n.DecodeArrayToMesh(r,r.byteLength,o))throw new Error("Failed to decode Draco mesh");const s=e.json.accessors[t.indices],a=xx[s.componentType],l=s.count*a.BYTES_PER_ELEMENT,c=fx._malloc(l);a===Uint16Array?n.GetTrianglesUInt16Array(o,l,c):n.GetTrianglesUInt32Array(o,l,c),Tx(fx.memory.buffer.slice(c,c+l),s,e),fx._free(c);for(const r of Object.keys(i.attributes)){const s=n.GetAttributeByUniqueId(o,i.attributes[r]),a=e.json.accessors[t.attributes[r]],l=bx[a.componentType],c=a.count*wx[a.type]*xx[a.componentType].BYTES_PER_ELEMENT,d=fx._malloc(c);n.GetAttributeDataArrayForAllPoints(o,s,fx[l],c,d),Tx(fx.memory.buffer.slice(d,d+c),a,e),fx._free(d)}n.destroy(),o.destroy(),delete t.extensions[Sx]}const Mx="EXT_meshopt_compression";function Cx(t,e){if(!t.extensions||!t.extensions[Mx])return;const i=t.extensions[Mx],n=new Uint8Array(e.buffers[i.buffer],i.byteOffset||0,i.byteLength||0),r=new Uint8Array(i.count*i.byteStride);_x.decodeGltfBuffer(r,i.count,i.byteStride,n,i.mode,i.filter),t.buffer=e.buffers.length,t.byteOffset=0,e.buffers[t.buffer]=r.buffer,delete t.extensions[Mx]}const Ax=1179937895,Ix=new TextDecoder("utf8");function Lx(t,e){return new URL(t,e).href}function Px(t,e,i,n){return fetch(Lx(t.uri,n)).then((t=>t.arrayBuffer())).then((t=>{e.buffers[i]=t}))}function $x(t,e){const i=t.json.bufferViews[e];return new Uint8Array(t.buffers[i.buffer],i.byteOffset||0,i.byteLength)}function kx(t,e,i,n){if(t.uri){const r=Lx(t.uri,n);return fetch(r).then((t=>t.blob())).then((t=>createImageBitmap(t))).then((t=>{e.images[i]=t}))}if(void 0!==t.bufferView){const n=$x(e,t.bufferView),r=new Blob([n],{type:t.mimeType});return createImageBitmap(r).then((t=>{e.images[i]=t}))}}function Dx(t,e=0,i){const n={json:null,images:[],buffers:[]};if(new Uint32Array(t,e,1)[0]===Ax){const i=new Uint32Array(t,e);let r=2;const o=(i[r++]>>2)-3,s=i[r++]>>2;if(r++,n.json=JSON.parse(Ix.decode(i.subarray(r,r+s))),r+=s,r{const t=[],e=a&&a.includes(Sx),r=a&&a.includes(Mx);if(e&&t.push(function(){if(!fx)return hx||(hx=function(t){let e,i=null;function n(){e=new Uint8Array(i.buffer)}function r(){throw new Error("Unexpected Draco error.")}const o={a:{a:r,d:function(t,i,n){return e.copyWithin(t,i,i+n)},c:function(t){const r=e.length,o=Math.max(t>>>0,Math.ceil(1.2*r)),s=Math.ceil((o-r)/65536);try{return i.grow(s),n(),!0}catch(t){return!1}},b:r}};return(WebAssembly.instantiateStreaming?WebAssembly.instantiateStreaming(t,o):t.then((t=>t.arrayBuffer())).then((t=>WebAssembly.instantiate(t,o)))).then((t=>{const{Rb:r,Qb:o,P:s,T:a,X:l,Ja:c,La:d,Qa:u,Va:h,Wa:p,eb:f,jb:m,f:_,e:g,yb:y,zb:v,Ab:x,Bb:b,Db:w,Gb:T}=t.instance.exports;i=g;const S=(()=>{let t=0,i=0,n=0,s=0;return a=>{n&&(r(s),r(t),i+=n,n=t=0),t||(i+=128,t=o(i));const l=a.length+7&-8;let c=t;l>=i&&(n=l,c=s=o(l));for(let t=0;t{fx=t,hx=void 0})))}()),r&&t.push(function(){if(_x)return;const t=function(t){let e;const i=WebAssembly.instantiateStreaming(t,{}).then((t=>{e=t.instance,e.exports.__wasm_call_ctors()})),n={NONE:"",OCTAHEDRAL:"meshopt_decodeFilterOct",QUATERNION:"meshopt_decodeFilterQuat",EXPONENTIAL:"meshopt_decodeFilterExp"},r={ATTRIBUTES:"meshopt_decodeVertexBuffer",TRIANGLES:"meshopt_decodeIndexBuffer",INDICES:"meshopt_decodeIndexSequence"};return{ready:i,supported:!0,decodeGltfBuffer(t,i,o,s,a,l){!function(t,e,i,n,r,o,s){const a=t.exports.sbrk,l=n+3&-4,c=a(l*r),d=a(o.length),u=new Uint8Array(t.exports.memory.buffer);u.set(o,d);const h=e(c,n,r,d,o.length);if(0===h&&s&&s(c,l,r),i.set(u.subarray(c,c+n*r)),a(c-a(0)),0!==h)throw new Error(`Malformed buffer data: ${h}`)}(e,e.exports[r[a]],t,i,o,s,e.exports[n[l]])}}}(fetch(vx()));return t.ready.then((()=>{_x=t}))}()),o)for(let e=0;e{if(e&&s)for(const{primitives:t}of s)for(const e of t)Ex(e,n);if(r&&s&&l)for(const t of l)Cx(t,n);return n}))}))}function zx(t,e){const i=t.json.bufferViews[e.bufferView],n=xx[e.componentType];return new n(t.buffers[i.buffer],(e.byteOffset||0)+(i.byteOffset||0),e.count*(i.byteStride&&i.byteStride!==wx[e.type]*n.BYTES_PER_ELEMENT?i.byteStride/n.BYTES_PER_ELEMENT:wx[e.type]))}function Rx(t,e,i,n){const r=xx[e.componentType],o=function(t){switch(t){case Int8Array:return 1/127;case Uint8Array:return 1/255;case Int16Array:return 1/32767;case Uint16Array:return 1/65535;default:return 1}}(r),s=t.json.bufferViews[e.bufferView],a=s.byteStride?s.byteStride/r.BYTES_PER_ELEMENT:wx[e.type],l=i.float32,c=l.length/i.capacity;for(let t=0,i=0;t0){for(let r=0;r0){o.texcoordArray=new ic;const t=e.json.accessors[r.TEXCOORD_0];o.texcoordArray.resize(t.count);const i=zx(e,t);Rx(e,t,o.texcoordArray,i)}if(void 0!==r._FEATURE_ID_RGBA4444){const t=e.json.accessors[r._FEATURE_ID_RGBA4444];e.json.extensionsUsed&&e.json.extensionsUsed.includes("EXT_meshopt_compression")&&(o.featureData=zx(e,t))}void 0!==r._FEATURE_RGBA4444&&(o.featureData=new Uint32Array(zx(e,e.json.accessors[r._FEATURE_RGBA4444]).buffer));const u=t.material;return o.material=function(t,e){const{emissiveFactor:i=[0,0,0],alphaMode:n="OPAQUE",alphaCutoff:r=.5,normalTexture:o,occlusionTexture:s,emissiveTexture:a,doubleSided:l}=t,{baseColorFactor:c=[1,1,1,1],metallicFactor:d=1,roughnessFactor:u=1,baseColorTexture:h,metallicRoughnessTexture:p}=t.pbrMetallicRoughness||{},f=s?e[s.index]:void 0;if(s&&s.extensions&&s.extensions.KHR_texture_transform&&f){const t=s.extensions.KHR_texture_transform;f.offsetScale=[t.offset[0],t.offset[1],t.scale[0],t.scale[1]]}return{pbrMetallicRoughness:{baseColorFactor:new Un(...c),metallicFactor:d,roughnessFactor:u,baseColorTexture:h?e[h.index]:void 0,metallicRoughnessTexture:p?e[p.index]:void 0},doubleSided:l,emissiveFactor:i,alphaMode:n,alphaCutoff:r,normalTexture:o?e[o.index]:void 0,occlusionTexture:f,emissionTexture:a?e[a.index]:void 0,defined:void 0===t.defined}}(void 0!==u?e.json.materials[u]:{defined:!1},i),o}function Bx(e,i,n){const{matrix:r,rotation:o,translation:s,scale:a,mesh:l,extras:c,children:d}=e,u={};if(u.matrix=r||t.ad.fromRotationTranslationScale([],o||[0,0,0,1],s||[0,0,0],a||[1,1,1]),void 0!==l){u.meshes=n[l];const t=u.anchor=[0,0];for(const e of u.meshes){const{min:i,max:n}=e.aabb;t[0]+=i[0]+n[0],t[1]+=i[1]+n[1]}t[0]=Math.floor(t[0]/u.meshes.length/2),t[1]=Math.floor(t[1]/u.meshes.length/2)}if(c&&(c.id&&(u.id=c.id),c.lights&&(u.lights=function(t){if(!t.length)return[];const e=function(t){const e=atob(t),i=new Uint8Array(e.length);for(let t=0;t1&&n[n.length-1].equals(n[0])&&n.pop();let r=0;for(let t=0;t0&&n.reverse();const o=xh(n.flatMap((t=>[t.x,t.y])),[]);return 0===o.length?null:{vertices:n,indices:o}}function Ux(e,i){const n=[],r=[];let o=0;const s=[];for(const a of e){o=n.length;const e=a.vertexArray.float32,l=a.indexArray.uint16;for(let r=0;r0&&([r[t+1],r[t+2]]=[r[t+2],r[t+1]])}return{vertices:n,indices:r}}function jx(t){const e=function(t,e){const i=[],n=WebGL2RenderingContext;if(t.json.textures)for(const r of t.json.textures){const o={magFilter:n.LINEAR,minFilter:n.NEAREST,wrapS:n.REPEAT,wrapT:n.REPEAT};void 0!==r.sampler&&Object.assign(o,t.json.samplers[r.sampler]),i.push({image:e[r.source],sampler:o,uploaded:!1})}return i}(t,t.images),i=function(t,e){const i=[];for(const n of t.json.meshes){const r=[];for(const i of n.primitives)r.push(Ox(i,t,e));i.push(r)}return i}(t,e),{scenes:n,scene:r,nodes:o}=t.json,s=n?n[r||0].nodes:o,a=[];for(const e of s)a.push(Bx(o[e],t,i));return function(t,e,i){const n={},r=new Set;for(let o=0;o0){const e=Array.from(r.values()).sort(((t,e)=>t-e));for(let i=e.length-1;i>=0;i--)t.splice(e[i],1)}}(a,s,t.json.nodes),a}function Vx(t){t.heightmap=new Float32Array(4096),t.heightmap.fill(-1);const e=t.vertexArray.float32,i=t.aabb.min[0]-1,n=t.aabb.min[1]-1,r=Wv/(t.aabb.max[0]-i+2),o=Wv/(t.aabb.max[1]-n+2);for(let s=0;st.heightmap[c*Wv+l]&&(t.heightmap[c*Wv+l]=a)}}function Gx(e,i){const n={};n.indexArray=new Kl,n.indexArray.reserve(4*e.length),n.vertexArray=new Bl,n.vertexArray.reserve(10*e.length),n.colorArray=new Ol,n.vertexArray.reserve(10*e.length);let r=0;for(const o of e){const e=Math.min(10,Math.max(4,1.3*o.height))*i,s=[-o.normal[1],o.normal[0],0],a=Math.min(.29,.1*o.width/o.depth),l=o.width-2*o.depth*i*(a+.01),c=t._.scaleAndAdd([],o.pos,s,l/2),d=t._.scaleAndAdd([],o.pos,s,-l/2),u=[c[0],c[1],c[2]+o.height],h=[d[0],d[1],d[2]+o.height],p=t._.scaleAndAdd([],o.normal,s,a);t._.scale(p,p,e);const f=t._.scaleAndAdd([],o.normal,s,-a);t._.scale(f,f,e),t._.add(p,c,p),t._.add(f,d,f),c[2]+=.1,d[2]+=.1,n.vertexArray.emplaceBack(p[0],p[1],p[2]),n.vertexArray.emplaceBack(f[0],f[1],f[2]),n.vertexArray.emplaceBack(c[0],c[1],c[2]),n.vertexArray.emplaceBack(d[0],d[1],d[2]),n.vertexArray.emplaceBack(u[0],u[1],u[2]),n.vertexArray.emplaceBack(h[0],h[1],h[2]),n.vertexArray.emplaceBack(c[0],c[1],c[2]),n.vertexArray.emplaceBack(d[0],d[1],d[2]),n.vertexArray.emplaceBack(p[0],p[1],p[2]),n.vertexArray.emplaceBack(f[0],f[1],f[2]);const m=l/e/2;n.colorArray.emplaceBack(-m-a,-1,m,.8),n.colorArray.emplaceBack(m+a,-1,m,.8),n.colorArray.emplaceBack(-m,0,m,1.3),n.colorArray.emplaceBack(m,0,m,1.3),n.colorArray.emplaceBack(m+a,-.8,m,.7),n.colorArray.emplaceBack(m+a,-.8,m,.7),n.colorArray.emplaceBack(0,0,m,1.3),n.colorArray.emplaceBack(0,0,m,1.3),n.colorArray.emplaceBack(m+a,-1.2,m,.8),n.colorArray.emplaceBack(m+a,-1.2,m,.8),n.indexArray.emplaceBack(6+r,4+r,8+r),n.indexArray.emplaceBack(7+r,9+r,5+r),n.indexArray.emplaceBack(0+r,1+r,2+r),n.indexArray.emplaceBack(1+r,3+r,2+r),r+=10}const o={defined:!0,emissiveFactor:[0,0,0]},s={};return s.baseColorFactor=Un.white,o.pbrMetallicRoughness=s,n.material=o,n.aabb=new wu([1/0,1/0,1/0],[-1/0,-1/0,-1/0]),n}const Zx=new Float32Array(262144),qx=new Uint8Array(262144);function Hx(t){let e=0;if(t.meshes)for(const i of t.meshes)e=Math.max(e,i.aabb.max[2]);if(t.children)for(const i of t.children)e=Math.max(e,Hx(i));return e}function Wx(t,e,i){if(t.meshes)for(const n of t.meshes)n.aabb.min[0]!==1/0&&i.insert(e,n.aabb.min[0],n.aabb.min[1],n.aabb.max[0],n.aabb.max[1]);if(t.children)for(const n of t.children)Wx(n,e,i)}const Yx=["","wall","door","roof","window","lamp","logo"];class Xx{constructor(t){this.node=t,this.evaluatedRMEA=[[1,0,0,1],[1,0,0,1],[1,0,0,1],[1,0,0,1],[.4,1,0,1],[1,0,0,1],[1,0,0,1]],this.hiddenByReplacement=!1,this.evaluatedScale=[1,1,1],this.evaluatedColor=[],this.emissionHeightBasedParams=[],this.feature={type:"Point",id:t.id,geometry:[],properties:{height:Hx(t)}},this.aabb=this._getLocalBounds()}_getLocalBounds(){if(!this.node.meshes)return new wu([1/0,1/0,1/0],[-1/0,-1/0,-1/0]);if(!this.aabb){let t=0;const e=new wu([1/0,1/0,1/0],[-1/0,-1/0,-1/0]);for(const i of this.node.meshes)this.node.lightMeshIndex!==t&&(i.transformedAabb=wu.applyTransformFast(i.aabb,this.node.matrix),e.encapsulate(i.transformedAabb)),t++;this.aabb=e}return this.aabb}}class Kx{constructor(t,e,i,n,r,o){this.id=e,this.modelTraits|=Yv.CoordinateSpaceTile,this.uploaded=!1,this.hasPattern=!1,i&&(this.modelTraits|=Yv.HasMapboxMeshFeatures),n&&(this.modelTraits|=Yv.HasMeshoptCompression),this.zoom=-1,this.terrainExaggeration=1,this.projection={name:"mercator"},this.replacementUpdateTime=0,this.elevationReadFromZ=255,this.brightness=r,this.dirty=!0,this.needsUpload=!1,this.nodesInfo=[];for(const e of t)this.nodesInfo.push(new Xx(e)),Wx(e,o.featureIndexArray.length,o.grid),o.featureIndexArray.emplaceBack(this.nodesInfo.length-1,0,o.bucketLayerIDs.length-1,0)}updateFootprints(t,e){for(const i of this.getNodesInfo()){const n=i.node;n.footprint&&e.push({footprint:n.footprint,id:t})}}update(){console.log("Update 3D model bucket")}populate(){console.log("populate 3D model bucket")}uploadPending(){return!this.uploaded||this.needsUpload}upload(t){if(!this.needsUpload)return;const e=this.getNodesInfo();for(const i of e){const e=i.node;this.uploaded?this.updatePbrBuffer(e):Qv(e,t,!0)}for(const t of e)tx(t.node);this.uploaded=!0,this.needsUpload=!1}updatePbrBuffer(t){let e=!1;if(!t.meshes)return e;for(const i of t.meshes)i.pbrBuffer&&(i.pbrBuffer.updateData(i.featureArray),e=!0);return e}needsReEvaluation(t,e,i){const n=t.transform.projectionOptions,r=t.style.getBrightness(),o=this.brightness!==r;return!!(!this.uploaded||this.dirty||n.name!==this.projection.name||Jx(i.paint.get("model-color").value,o)||Jx(i.paint.get("model-color-mix-intensity").value,o)||Jx(i.paint.get("model-roughness").value,o)||Jx(i.paint.get("model-emissive-strength").value,o)||Jx(i.paint.get("model-height-based-emissive-strength-multiplier").value,o))&&(this.projection=n,this.brightness=r,!0)}evaluateScale(t,e){if(t.transform.zoom===this.zoom)return;this.zoom=t.transform.zoom;const i=this.getNodesInfo(),n=this.id.canonical;for(const t of i){const i=t.feature;t.evaluatedScale=e.paint.get("model-scale").evaluate(i,{},n)}}evaluate(t){const e=this.getNodesInfo();for(const i of e){if(!i.node.meshes)continue;const e=i.feature,n=i.node.meshes&&i.node.meshes[0].featureData,r=i.evaluatedColor[2],o=i.evaluatedRMEA[2],s=this.id.canonical;if(i.hasTranslucentParts=!1,n){for(let n=0;n=t)continue;const u=Zx[c],h=Math.abs(u);h>a&&(s=u,a=h,l=r,d=e)}if(a>.1){const o=1-(t+.5*Math.abs(l*d))/c;let a=e._dem.get(n,i)+s*o;const u=e._dem.get(n+l,i+d),h=e._dem.get(n-l,i-d,!0);(a-u)*(a-h)>0&&(a=(u+h)/2),Zx[r]=e._dem.set(n,i,a),qx[r]=t}}}}}s&&(e._demTile.needsDEMTextureUpload=!0,e._dem._timestamp=ki.now())}getNodesInfo(){return this.nodesInfo}destroy(){const t=this.getNodesInfo();for(const e of t)tx(e.node),ex(e.node)}isEmpty(){return!this.nodesInfo.length}updateReplacement(t,e){if(e.updateTime===this.replacementUpdateTime)return;this.replacementUpdateTime=e.updateTime;const i=e.getReplacementRegionsForTile(t.toUnwrapped()),n=this.getNodesInfo();for(let t=0;tt.footprint===e.footprint))}}getHeightAtTileCoord(e,i){const n=this.getNodesInfo(),r=[],o=[0,0,0],s=t.ad.identity([]);for(let a=0;ad.max[0]||i>d.max[1])continue;if(!0===l.node.hidden)return{height:0,maxHeight:l.feature.properties.height,hidden:!1,verticalScale:l.evaluatedScale[2]};t.ad.invert(s,l.node.matrix),o[0]=e,o[1]=i,t._.transformMat4(o,o,s);const u=(o[0]-c.aabb.min[0])/(c.aabb.max[0]-c.aabb.min[0])*Wv|0,h=Math.min(63,(o[1]-c.aabb.min[1])/(c.aabb.max[1]-c.aabb.min[1])*Wv|0)*Wv+Math.min(63,u),p=c.heightmap[h];if(!(p0)return{height:void 0,maxHeight:l.feature.properties.height,hidden:l.hiddenByReplacement,verticalScale:l.evaluatedScale[2]}}}}function Jx(t,e){return!t.isLightConstant&&e}function Qx(t,e,i,n,r,o,s,a){let l=(61440&e|(61440&e)>>4)>>8,c=(3840&e|(3840&e)>>4)>>4,d=240&e|(240&e)>>4;i[3]>0&&(l=Vn(l,255*i[0],i[3]),c=Vn(c,255*i[1],i[3]),d=Vn(d,255*i[2],i[3]));const u=l>16&65535,a=o?e>>16&65535:65535&e,l=(15&a)t.polygon)).flat());const g=f?l:null,[y,v]=function(e,i,n,r,o,s,a,l,c,d,u){return"globe"===e.projection.name?function(e,i,n,r,o,s,a,l,c,d,u){const h=[],p=[],f=e.projection.upVectorScale(u,e.center.lat,e.worldSize).metersToTile,m=[0,0,0,1],_=[0,0,0,1],g=(t,e,i,n)=>{t[0]=e,t[1]=i,t[2]=n,t[3]=1},y=Sf();n>0&&(n+=y),r+=y;for(const y of i){const i=[],v=[];for(const h of y){const p=h.x+o.x,y=h.y+o.y,x=e.projection.projectTilePoint(p,y,u),b=e.projection.upVector(u,h.x,h.y);let w=n,T=r;if(a){const t=Pf(p,y,n,r,a,l,c,d);w+=t.base,T+=t.top}0!==n?g(m,x.x+b[0]*f*w,x.y+b[1]*f*w,x.z+b[2]*f*w):g(m,x.x,x.y,x.z),g(_,x.x+b[0]*f*T,x.y+b[1]*f*T,x.z+b[2]*f*T),t._.transformMat4(m,m,s),t._.transformMat4(_,_,s),i.push(new Tp(m[0],m[1],m[2])),v.push(new Tp(_[0],_[1],_[2]))}h.push(i),p.push(v)}return[h,p]}(e,i,n,r,o,s,a,l,c,d,u):a?function(e,i,n,r,o,s,a,l,c){const d=[],u=[],h=[0,0,0,1];for(const p of e){const e=[],f=[];for(const d of p){const u=d.x+r.x,p=d.y+r.y,m=Pf(u,p,i,n,s,a,l,c);h[0]=u,h[1]=p,h[2]=m.base,h[3]=1,t.aA.transformMat4(h,h,o),h[3]=Math.max(h[3],1e-5);const _=new Tp(h[0]/h[3],h[1]/h[3],h[2]/h[3]);h[0]=u,h[1]=p,h[2]=m.top,h[3]=1,t.aA.transformMat4(h,h,o),h[3]=Math.max(h[3],1e-5);const g=new Tp(h[0]/h[3],h[1]/h[3],h[2]/h[3]);e.push(_),f.push(g)}d.push(e),u.push(f)}return[d,u]}(i,n,r,o,s,a,l,c,d):function(t,e,i,n,r){const o=[],s=[],a=r[8]*e,l=r[9]*e,c=r[10]*e,d=r[11]*e,u=r[8]*i,h=r[9]*i,p=r[10]*i,f=r[11]*i;for(const e of t){const t=[],i=[];for(const o of e){const e=o.x+n.x,s=o.y+n.y,m=r[0]*e+r[4]*s+r[12],_=r[1]*e+r[5]*s+r[13],g=r[2]*e+r[6]*s+r[14],y=r[3]*e+r[7]*s+r[15],v=m+a,x=_+l,b=g+c,w=Math.max(y+d,1e-5),T=m+u,S=_+h,E=g+p,M=Math.max(y+f,1e-5);t.push(new Tp(v/w,x/w,b/w)),i.push(new Tp(T/M,S/M,E/M))}o.push(t),s.push(i)}return[o,s]}(i,n,r,o,s)}(s,r,h,u,d,a,g,p,m,s.center.lat,e.tileID.canonical),x=e.queryGeometry;return function(t,e,i){let n=1/0;Kd(i,e)&&(n=Lf(i,e[0]));for(let r=0;r=3)for(let e=0;e>4;if(1!==n)throw new Error(`Got v${n} data when expected v1.`);const r=nb[15&i];if(!r)throw new Error("Unrecognized array type.");const[o]=new Uint16Array(t,2,1),[s]=new Uint32Array(t,4,1);return new rb(s,o,r,t)}constructor(t,e=64,i=Float64Array,n){if(isNaN(t)||t>1;return this.ids[i]=i,this.coords[this._pos++]=t,this.coords[this._pos++]=e,i}finish(){const t=this._pos>>1;if(t!==this.numItems)throw new Error(`Added ${t} items when expected ${this.numItems}.`);return ob(this.ids,this.coords,this.nodeSize,0,this.numItems-1,0),this._finished=!0,this}range(t,e,i,n){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");const{ids:r,coords:o,nodeSize:s}=this,a=[0,r.length-1,0],l=[];for(;a.length;){const c=a.pop()||0,d=a.pop()||0,u=a.pop()||0;if(d-u=t&&a=e&&c>1,p=o[2*h],f=o[2*h+1];p>=t&&p=e&&f=p:n>=f)&&(a.push(h+1),a.push(d),a.push(1-c))}return l}within(t,e,i){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");const{ids:n,coords:r,nodeSize:o}=this,s=[0,n.length-1,0],a=[],l=i*i;for(;s.length;){const c=s.pop()||0,d=s.pop()||0,u=s.pop()||0;if(d-u>1,p=r[2*h],f=r[2*h+1];cb(p,f,t,e)=p:e+i>=f)&&(s.push(h+1),s.push(d),s.push(1-c))}return a}}function ob(t,e,i,n,r,o){if(r-n>1;sb(t,e,s,n,r,o),ob(t,e,i,n,s-1,1-o),ob(t,e,i,s+1,r,1-o)}function sb(t,e,i,n,r,o){for(;r>n;){if(r-n>600){const s=r-n+1,a=i-n+1,l=Math.log(s),c=.5*Math.exp(2*l/3),d=.5*Math.sqrt(l*c*(s-c)/s)*(a-s/2s&&ab(t,e,n,r);as;)l--}e[2*n+o]===s?ab(t,e,n,l):(l++,ab(t,e,l,r)),lr&&(n+=(t[i]-r)*(t[i]-r)),e[i]0&&n[0]0&&n[1]0&&r[0]0&&r[1]0?Math.acos(i/n)*Ve:0;let o=0!==t||0!==e?Math.atan2(-e,-t)*Ve+90:0;return oNi&&(t.getActor().send("enforceCacheSizeLimit",Fi),Vi=0)},t.an=gn,t.ao=class{constructor(t){this.entries={},this.scheduler=t}request(t,e,i,n){const r=this.entries[t]=this.entries[t]||{callbacks:[]};if(r.result){const[t,i]=r.result;return this.scheduler?this.scheduler.add((()=>{n(t,i)}),e):n(t,i),()=>{}}return r.callbacks.push(n),r.cancel||(r.cancel=i(((i,n)=>{r.result=[i,n];for(const t of r.callbacks)this.scheduler?this.scheduler.add((()=>{t(i,n)}),e):t(i,n);setTimeout((()=>delete this.entries[t]),3e3)}))),()=>{r.result||(r.callbacks=r.callbacks.filter((t=>t!==n)),r.callbacks.length||(r.cancel(),delete this.entries[t]))}}},t.ap=function(t,e,i){const n=JSON.stringify(t.request);return t.data&&(this.deduped.entries[n]={result:[null,t.data]}),this.deduped.request(n,{type:"parseTile",isSymbolTile:t.isSymbolTile,zoom:t.tileZoom},(e=>{const n=en(t.request,((t,n,r,o)=>{t?e(t):n&&e(null,{vectorTile:i?void 0:new bp(new Lm(n)),rawData:n,cacheControl:r,expires:o})}));return()=>{n.cancel(),e()}}),e)},t.aq=Dc,t.ar=class extends Lc{constructor(t){super(t),this.current=Fc}set(t,e,i){if(this.fetchUniformLocation(t,e))for(let t=0;t({u_camera_to_center_distance:new $c(t),u_extrude_scale:new Uc(t),u_device_pixel_ratio:new $c(t),u_matrix:new Bc(t),u_inv_rot_matrix:new Bc(t),u_merc_center:new kc(t),u_tile_id:new Dc(t),u_zoom_transition:new $c(t),u_up_dir:new Dc(t),u_emissive_strength:new $c(t)}),t.bJ=t=>({u_matrix:new Bc(t),u_pixels_to_tile_units:new Uc(t),u_device_pixel_ratio:new $c(t),u_units_to_pixels:new kc(t),u_dash_image:new Pc(t),u_gradient_image:new Pc(t),u_image_height:new $c(t),u_texsize:new kc(t),u_tile_units_to_pixels:new $c(t),u_alpha_discard_threshold:new $c(t),u_trim_offset:new kc(t),u_trim_fade_range:new kc(t),u_trim_color:new zc(t),u_emissive_strength:new $c(t)}),t.bK=t=>({u_matrix:new Bc(t),u_texsize:new kc(t),u_pixels_to_tile_units:new Uc(t),u_device_pixel_ratio:new $c(t),u_image:new Pc(t),u_units_to_pixels:new kc(t),u_tile_units_to_pixels:new $c(t),u_alpha_discard_threshold:new $c(t),u_trim_offset:new kc(t)}),t.bL=Yl,t.bM=Hf,t.bN=Om,t.bO=jm,t.bP=G_,t.bQ=c_,t.bR=th,t.bS=(t,e,i,n,r,o)=>{const s=t.transform,a="globe"===s.projection.name;let l;if("map"===o.paint.get("circle-pitch-alignment"))if(a){const t=Zu(s.zoom,e.canonical)*s._pixelsPerMercatorPixel;l=Float32Array.from([t,0,0,t])}else l=s.calculatePixelsToTileUnitsMatrix(i);else l=new Float32Array([s.pixelsToGLUnits[0],0,0,s.pixelsToGLUnits[1]]);const c={u_camera_to_center_distance:t.transform.getCameraToCenterDistance(s.projection),u_matrix:t.translatePosMatrix(e.projMatrix,i,o.paint.get("circle-translate"),o.paint.get("circle-translate-anchor")),u_device_pixel_ratio:ki.devicePixelRatio,u_extrude_scale:l,u_inv_rot_matrix:Qu,u_merc_center:[0,0],u_tile_id:[0,0,0],u_zoom_transition:0,u_up_dir:[0,0,0],u_emissive_strength:o.paint.get("circle-emissive-strength")};if(a){c.u_inv_rot_matrix=n,c.u_merc_center=r,c.u_tile_id=[e.canonical.x,e.canonical.y,1{const s=t.transform;return{u_matrix:rm(t,e,i,n),u_texsize:e.imageAtlasTexture?e.imageAtlasTexture.size:[0,0],u_pixels_to_tile_units:s.calculatePixelsToTileUnitsMatrix(e),u_device_pixel_ratio:r,u_image:0,u_tile_units_to_pixels:nm(e,s),u_units_to_pixels:[1/s.pixelsToGLUnits[0],1/s.pixelsToGLUnits[1]],u_alpha_discard_threshold:0,u_trim_offset:o}},t.bV=(t,e,i,n,r,o,s)=>{const a=t.transform,l=a.calculatePixelsToTileUnitsMatrix(e);return{u_matrix:rm(t,e,i,n),u_pixels_to_tile_units:l,u_device_pixel_ratio:o,u_units_to_pixels:[1/a.pixelsToGLUnits[0],1/a.pixelsToGLUnits[1]],u_dash_image:0,u_gradient_image:1,u_image_height:r,u_texsize:sm(i)&&e.lineAtlasTexture?e.lineAtlasTexture.size:[0,0],u_tile_units_to_pixels:nm(e,t.transform),u_alpha_discard_threshold:0,u_trim_offset:s,u_trim_fade_range:i.paint.get("line-trim-fade-range"),u_trim_color:i.paint.get("line-trim-color").toRenderColor(i.lut).toArray01(),u_emissive_strength:i.paint.get("line-emissive-strength")}},t.bW=oi,t.bX=mh,t.bY=Sf,t.bZ=bd,t.b_=_f,t.ba=function(t,e,i){const n=Hu(i.zoom),r=t.style.map._antialias,o=e.options.extStandardDerivativesForceOff||t.terrain&&t.terrain.exaggeration()>0;return 0===n&&!r&&!o},t.bb=function(e){const i=e.pixelsPerMeter,n=i/Cd(1,e.center.lat),r=t.ad.identity(new Float64Array(16));return t.ad.translate(r,r,[e.point.x,e.point.y,0]),t.ad.scale(r,r,[n,n,i]),Float32Array.from(r)},t.bc=Ou,t.bd=function(t){const e=Pd-5;t=Xe(t,-e,e)/e*90;const i=Math.pow(Math.abs(Math.sin(Ge(t))),3);return Math.round(i*(sd.length-1))},t.be=function(e,i,n,r){const o=i.getNorth(),s=i.getSouth(),a=i.getWest(),l=i.getEast(),c=10){const e=180/r;t.bC.multiply(f,f,[e/d+1,0,0,0,e/u+1,0,-.5*e/h,.5*e/p,1])}return f[2]=c,f[5]=e.x,f[8]=e.y,f},t.bf=ju,t.bg=$u,t.bh=function(e,i,n){const r=t.ad.identity(new Float64Array(16)),o=(i/(1{}}},t.bo=Gg,t.bp=ai,t.bq=class{isDataAvailableAtPoint(t){const e=this._source();if(this.isUsingMockSource()||!e||t.y1)return!1;const i=e.getSource().maxzoom,n=11)return e;const r=n.getSource().maxzoom,o=1{const s=this.getAtTileOffset(e,o.x,o.y),a=r.upVector(e.canonical,o.x,o.y),l=r.upVectorScale(e.canonical,i,n).metersToTile;return t._.scale(a,a,s*l),a}}getForTilePoints(t,e,i,n){if(this.isUsingMockSource())return!1;const r=Xp.create(this,t,n);return!!r&&(e.forEach((t=>{t[2]=this.exaggeration()*r.getElevationAt(t[0],t[1],i)})),!0)}getMinMaxForTile(t){if(this.isUsingMockSource())return null;const e=this.findDEMTileFor(t);if(!e||!e.dem)return null;const i=e.dem.tree,n=e.tileID,r=1=0?t.slice(0,e):t},t.cV=function(t){return t.indexOf(wl)>=0},t.cW=function(t){const e=t.indexOf(wl);return e>=0?t.slice(e+1):""},t.cX=function(t){const e=[],i=t.id;return void 0===i&&e.push({message:`layers.${i}: missing required property "id"`}),void 0===t.render&&e.push({message:`layers.${i}: missing required method "render"`}),t.renderingMode&&"2d"!==t.renderingMode&&"3d"!==t.renderingMode&&e.push({message:`layers.${i}: property "renderingMode" must be either "2d" or "3d"`}),e},t.cY=function(t,e,i,n){return"custom"===t.type?new vv(t,e):new ib[t.type](t,e,i,n)},t.cZ=di,t.c_=Va,t.ca=1,t.cb=Ag,t.cc=0,t.cd=ec,t.ce=function(t,e,i,n,r){return Xe((t-e)/(i-e)*(r-n)+n,n,r)},t.cf=Ns,t.cg=kd,t.ch=class{constructor(t,e,i,n){this.context=t,this.format=n,this.size=i,this.texture=t.gl.createTexture();const[r,o,s]=this.size,{gl:a}=t;a.bindTexture(a.TEXTURE_3D,this.texture),t.pixelStoreUnpackFlipY.set(!1),t.pixelStoreUnpack.set(1),t.pixelStoreUnpackPremultiplyAlpha.set(!1);let l=this.format,c=a.UNSIGNED_BYTE;this.format===a.DEPTH_COMPONENT&&(l=a.DEPTH_COMPONENT16,c=a.UNSIGNED_SHORT),this.format===a.R8&&(n=a.RED),this.format===a.R32F&&(c=a.FLOAT,n=a.RED),a.texImage3D(a.TEXTURE_3D,0,l,r,o,s,0,n,c,e.data)}bind(t,e){const{context:i}=this,{gl:n}=i;n.bindTexture(n.TEXTURE_3D,this.texture),t!==this.minFilter&&(n.texParameteri(n.TEXTURE_3D,n.TEXTURE_MAG_FILTER,t),n.texParameteri(n.TEXTURE_3D,n.TEXTURE_MIN_FILTER,t),this.minFilter=t),e!==this.wrapS&&(n.texParameteri(n.TEXTURE_3D,n.TEXTURE_WRAP_S,e),n.texParameteri(n.TEXTURE_3D,n.TEXTURE_WRAP_T,e),this.wrapS=e)}destroy(){const{gl:t}=this.context;t.deleteTexture(this.texture),this.texture=null}},t.ci=$v,t.cj=[1,1,1],t.ck=Xp,t.cl=Yv,t.cm=ql,t.cn=ic,t.co=class{constructor(){this._updateTime=0,this._sourceIds=[],this._activeRegions=[],this._prevRegions=[],this._globalClipBounds={min:new Ue(1/0,1/0),max:new Ue(-1/0,-1/0)}}clear(){this._activeRegions.length>0&&++this._updateTime,this._activeRegions=[],this._prevRegions=[]}get updateTime(){return this._updateTime}getReplacementRegionsForTile(t,e=!1){const i=$p(new Ue(0,0),new Ue(uo,uo),t),n=[];if(e&&!Lp(i,this._globalClipBounds))return n;for(const e of this._activeRegions){if(e.hiddenByOverlap)continue;if(!Lp(i,e))continue;const r=kp(e.min,e.max,t);n.push({min:r.min,max:r.max,sourceId:this._sourceIds[e.priority],footprint:e.footprint,footprintTileId:e.tileId,order:e.order,clipMask:e.clipMask})}return n}setSources(t){this._setSources(t.map((t=>({getSourceId:()=>t.cache.id,getFootprints:()=>{const e=[];for(const i of t.cache.getVisibleCoordinates()){const n=t.cache.getTile(i).buckets[t.layer];n&&n.updateFootprints(i.toUnwrapped(),e)}return e},getOrder:()=>t.order,getClipMask:()=>t.clipMask}))))}_addSource(t){const e=t.getFootprints();if(0===e.length)return;const i=t.getOrder(),n=t.getClipMask();for(const t of e){if(!t.footprint)continue;const e=$p(t.footprint.min,t.footprint.max,t.id);this._activeRegions.push({min:e.min,max:e.max,hiddenByOverlap:!1,priority:this._sourceIds.length,tileId:t.id,footprint:t.footprint,order:i,clipMask:n})}this._sourceIds.push(t.getSourceId())}_computeReplacement(){this._activeRegions.sort(((t,e)=>t.priority-e.priority||Ap(t.min,e.min)||Ap(t.max,e.max)));let t=this._activeRegions.length!==this._prevRegions.length;if(!t){let e=0;for(;!t&&e!==this._activeRegions.length;){const i=this._activeRegions[e],n=this._prevRegions[e];t=i.priority!==n.priority||!Ip(i,n)||i.order!==n.order||i.clipMask!==n.clipMask,++e}}if(t){++this._updateTime;for(const t of this._activeRegions)t.order!==1/0&&(this._globalClipBounds.min.x=Math.min(this._globalClipBounds.min.x,t.min.x),this._globalClipBounds.min.y=Math.min(this._globalClipBounds.min.y,t.min.y),this._globalClipBounds.max.x=Math.max(this._globalClipBounds.max.x,t.max.x),this._globalClipBounds.max.y=Math.max(this._globalClipBounds.max.y,t.max.y));const t=t=>{const e=this._activeRegions;if(t>=e.length)return t;const i=e[t].priority;for(;t1){let e=0,i=t(e);for(;e!==i;){let n=e;const r=e;for(;n!==i;){const t=this._activeRegions[n];t.hiddenByOverlap=!1;for(let e=0;e=0;e--)this._addSource(t[e]);this._computeReplacement()}},t.cp=Dl,t.cq=Jg,t.cr=rc,t.cs=class{constructor(t){this._createGrid(t),this._createPoles(t)}destroy(){this._poleIndexBuffer.destroy(),this._gridBuffer.destroy(),this._gridIndexBuffer.destroy(),this._poleNorthVertexBuffer.destroy(),this._poleSouthVertexBuffer.destroy();for(const t of this._poleSegments)t.destroy();for(const t of this._gridSegments)t.withSkirts.destroy(),t.withoutSkirts.destroy()}_fillGridMeshWithLods(t,e){const i=new $l,n=new Kl,r=[],o=t+1+2,s=e[0]+1,a=e[0]+1+(1+e.length),l=(t,e,i)=>{let n=t===o-1?t-2:0===t?t:t-1;return n+=i?24575:0,[n,e]};for(let t=0;tt()))},t.dB=sx,t.dC=yx,t.dD=function(t){px=ki.resolveURL(t),gx||(gx=new ox(ux(),new zn)),gx.broadcast("setDracoUrl",px)},t.dE=vx,t.dF=function(t){mx=ki.resolveURL(t),gx||(gx=new ox(ux(),new zn)),gx.broadcast("setMeshoptUrl",mx)},t.dG=ti,t.dH=ba,t.dI=dh,t.dJ=I_,t.dK=eg,t.dL=dc,t.dM=am,t.dN=Dm,t.dO=Wf,t.dP=ci,t.dQ=E_,t.dR=jg,t.dS=function(t,e,i,n,r,o,s,a,l,c,d){t.createArrays(),t.tilePixelRatio=uo/(512*t.overscaling),t.compareText={},t.iconsNeedLinear=!1;const u=t.layers[0].layout,h=t.layers[0]._unevaluatedLayout._values,p={};if("composite"===t.textSizeData.kind){const{minZoom:e,maxZoom:i}=t.textSizeData;p.compositeTextSizes=[h["text-size"].possiblyEvaluate(new Ha(e),a),h["text-size"].possiblyEvaluate(new Ha(i),a)]}if("composite"===t.iconSizeData.kind){const{minZoom:e,maxZoom:i}=t.iconSizeData;p.compositeIconSizes=[h["icon-size"].possiblyEvaluate(new Ha(e),a),h["icon-size"].possiblyEvaluate(new Ha(i),a)]}p.layoutTextSize=h["text-size"].possiblyEvaluate(new Ha(l+1),a),p.layoutIconSize=h["icon-size"].possiblyEvaluate(new Ha(l+1),a),p.textMaxSize=h["text-size"].possiblyEvaluate(new Ha(18),a);const f="map"===u.get("text-rotation-alignment")&&"point"!==u.get("symbol-placement"),m=u.get("text-size");let _=!1;for(const e of t.features)if(e.icon&&e.icon.nameSecondary){_=!0;break}for(const o of t.features){const l=u.get("text-font").evaluate(o,{},a).join(","),h=m.evaluate(o,{},a),g=p.layoutTextSize.evaluate(o,{},a),y=(p.layoutIconSize.evaluate(o,{},a),{horizontal:{},vertical:void 0}),v=o.text;let x,b=[0,0];if(v){const n=v.toString(),s=u.get("text-letter-spacing").evaluate(o,{},a)*Om,c=u.get("text-line-height").evaluate(o,{},a)*Om,d=Aa(n)?s:0,p=u.get("text-anchor").evaluate(o,{},a),m=u.get("text-variable-anchor");if(!m){const t=u.get("text-radial-offset").evaluate(o,{},a);b=t?G_(p,[t*Om,j_]):u.get("text-offset").evaluate(o,{},a).map((t=>t*Om))}let _=f?"center":u.get("text-justify").evaluate(o,{},a);const x="point"===u.get("symbol-placement"),w=x?u.get("text-max-width").evaluate(o,{},a)*Om:1/0,T=o=>{t.allowVerticalPlacement&&Ca(n)&&(y.vertical=e_(v,e,i,r,l,w,c,p,o,d,b,Jm.vertical,!0,g,h))};if(!f&&m){const t="auto"===_?m.map((t=>Z_(t))):[_];let n=!1;for(let o=0;o=0||!Ca(n)){const t=e_(v,e,i,r,l,w,c,p,_,d,b,Jm.horizontal,!1,g,h);t&&(y.horizontal[_]=t)}T(x?"left":_)}}let w=!1;if(o.icon&&o.icon.namePrimary){const e=n[o.icon.namePrimary];e&&(x=u_(r[o.icon.namePrimary],o.icon.nameSecondary?r[o.icon.nameSecondary]:void 0,u.get("icon-offset").evaluate(o,{},a),u.get("icon-anchor").evaluate(o,{},a)),w=e.sdf,void 0===t.sdfIcons?t.sdfIcons=e.sdf:t.sdfIcons!==e.sdf&&pi("Style sheet warning: Cannot mix SDF and non-SDF icons in one buffer"),(e.pixelRatio!==t.pixelRatio||0!==u.get("icon-rotate").constantOr(1))&&(t.iconsNeedLinear=!0))}const T=X_(y.horizontal)||y.vertical;t.iconsInText||(t.iconsInText=!!T&&T.iconsInText),(T||x)&&q_(t,o,y,x,n,p,g,0,b,w,s,a,c,d,_)}o&&t.generateCollisionDebugBuffers(l,t.collisionBoxArray)},t.dT=Jf,t.dU=Yh,t.dV=bp,t.dW=Lm,t.dX=Yp,t.dY=Zy,t.dZ=wp,t.d_=cp,t.da=Wu,t.db=function(e){const i=[0,0,0],n=t.ad.identity(new Float64Array(16));return t.ad.multiply(n,e.pixelMatrix,e.globeMatrix),t._.transformMat4(i,i,n),new Ue(i[0],i[1])},t.dc=d,t.dd=c,t.de=function(t){const e=t.navigator?t.navigator.userAgent:null;return!!function(t){if(null==Ei){const e=t.navigator?t.navigator.userAgent:null;Ei=!!t.safari||!(!e||!(/\b(iPad|iPhone|iPod)\b/.test(e)||e.match("Safari")&&!e.match("Chrome")))}return Ei}(t)&&e&&(e.match("Version/15.4")||e.match("Version/15.5")||e.match(/CPU (OS|iPhone OS) (15_4|15_5) like Mac OS X/))},t.df=ni,t.dg=class{constructor(t,e,i){this._transformRequestFn=t,this._customAccessToken=e,this._silenceAuthErrors=!!i,this._createSkuToken()}_createSkuToken(){const t=function(){let t="";for(let e=0;ethis._skuTokenExpiresAt}transformRequest(t,e){return this._transformRequestFn&&this._transformRequestFn(t,e)||{url:t}}normalizeStyleURL(t,i){if(!o(t))return t;const n=un(t);return n.params.push(`sdk=js-${e}`),n.path=`/styles/v1${n.path}`,this._makeAPIURL(n,this._customAccessToken||i)}normalizeGlyphsURL(t,e){if(!o(t))return t;const i=un(t);return i.path=`/fonts/v1${i.path}`,this._makeAPIURL(i,this._customAccessToken||e)}normalizeModelURL(t,e){if(!o(t))return t;const i=un(t);return i.path=`/models/v1${i.path}`,this._makeAPIURL(i,this._customAccessToken||e)}normalizeSourceURL(t,e,i,n){if(!o(t))return t;const r=un(t);return r.path=`/v4/${r.authority}.json`,r.params.push("secure"),i&&r.params.push(`language=${i}`),n&&r.params.push(`worldview=${n}`),this._makeAPIURL(r,this._customAccessToken||e)}normalizeSpriteURL(t,e,i,n){const r=un(t);return o(t)?(r.path=`/styles/v1${r.path}/sprite${e}${i}`,this._makeAPIURL(r,this._customAccessToken||n)):(r.path+=`${e}${i}`,hn(r))}normalizeTileURL(t,e,i){if(this._isSkuTokenExpired()&&this._createSkuToken(),t&&!o(t))return t;const r=un(t);r.path=r.path.replace(/(\.(png|jpg)\d*)(?=$)/,`${e||i&&"raster"!==r.authority&&512===i?"@2x":""}${Gi.supported?".webp":"$1"}`),"raster"===r.authority?r.path=`/${n.RASTER_URL_PREFIX}${r.path}`:"rasterarrays"===r.authority?r.path=`/${n.RASTERARRAYS_URL_PREFIX}${r.path}`:"3dtiles"===r.authority?r.path=`/${n.TILES3D_URL_PREFIX}${r.path}`:(r.path=r.path.replace(/^.+\/v4\//,"/"),r.path=`/${n.TILE_URL_VERSION}${r.path}`);const s=this._customAccessToken||function(t){for(const e of t){const t=e.match(/^access_token=(.*)$/);if(t)return t[1]}return null}(r.params)||n.ACCESS_TOKEN;return n.REQUIRE_ACCESS_TOKEN&&s&&this._skuToken&&r.params.push(`sku=${this._skuToken}`),this._makeAPIURL(r,s)}canonicalizeTileURL(t,e){const i=un(t);if(!i.path.match(/^(\/v4\/|\/(raster|rasterarrays)\/v1\/)/)||!i.path.match(/\.[\w]+$/))return t;let r="mapbox://";i.path.match(/^\/raster\/v1\//)?r+=`raster/${i.path.replace(`/${n.RASTER_URL_PREFIX}/`,"")}`:i.path.match(/^\/rasterarrays\/v1\//)?r+=`rasterarrays/${i.path.replace(`/${n.RASTERARRAYS_URL_PREFIX}/`,"")}`:r+=`tiles/${i.path.replace(`/${n.TILE_URL_VERSION}/`,"")}`;let o=i.params;return e&&(o=o.filter((t=>!t.match(/^access_token=/)))),o.length&&(r+=`?${o.join("&")}`),r}canonicalizeTileset(t,e){const i=!!e&&o(e),n=[];for(const e of t.tiles||[])r(e)?n.push(this.canonicalizeTileURL(e,i)):n.push(e);return n}_makeAPIURL(t,e){const i="See https://docs.mapbox.com/api/overview/#access-tokens-and-token-scopes",r=un(n.API_URL);if(t.protocol=r.protocol,t.authority=r.authority,"http"===t.protocol){const e=t.params.indexOf("secure");e>=0&&t.params.splice(e,1)}if("/"!==r.path&&(t.path=`${r.path}${t.path}`),!n.REQUIRE_ACCESS_TOKEN)return hn(t);if(e=e||n.ACCESS_TOKEN,!this._silenceAuthErrors){if(!e)throw new Error(`An API access token is required to use Mapbox GL. ${i}`);if("s"===e[0])throw new Error(`Use a public access token (pk.*) with Mapbox GL, not a secret access token (sk.*). ${i}`)}return t.params=t.params.filter((t=>-1===t.indexOf("access_token"))),t.params.push(`access_token=${e||""}`),hn(t)}},t.dh=function(t,e){e?Mn.add(t):Mn.delete(t)},t.di=Gi,t.dj=Tn,t.dk=En,t.dl=cn,t.dm=vn,t.dn=bn,t.dp=function(t){Mn.delete(t)},t.dq=Sn,t.dr=yn,t.ds=Qe,t.dt=e,t.du=function(t,e){Fi=t,Ni=e},t.dv=function(t,e,i=!1){if(Fa===za||Fa===Ra||Fa===Oa)throw new Error("setRTLTextPlugin cannot be called multiple times.");Na=ki.resolveURL(t),Fa=za,Ba=e,ja(),i||Za()},t.dw=Ga,t.dx=function(){ux().acquire(lx)},t.dy=function(){const t=dx;t&&(t.isPreloaded()&&1===t.numActive()?(t.release(lx),dx=null):console.warn("Could not clear WebWorkers since there are active Map instances that still reference it. The pre-warmed WebWorker pool can only be cleared when all map instances have been removed with map.remove()"))},t.dz=cx,t.e=ki,t.e0=cm,t.e1=h,t.e2=en,t.e3=function(t){let e=0;if(new Uint32Array(t,0,1)[0]!==Ax){const i=new Uint32Array(t,0,7),[,,n,r,o,s]=i;e=i.byteLength+r+o+s+o,(n!==t.byteLength||e>=t.byteLength)&&pi("Invalid b3dm header information.")}return Dx(t,e)},t.e4=function(t,e){const i=jx(t);for(const t of i){for(const e of t.meshes)Vx(e);t.lights&&(t.lightMeshIndex=t.meshes.length,t.meshes.push(Gx(t.lights,e)))}return i},t.e5=Kx,t.e6=rx,t.e7=qa,t.e8=function(t){ji(),Oi&&Oi.then((e=>{e.keys().then((i=>{for(let n=0;nt.arrayBuffer())).then((e=>Dx(e,0,t)))},t.m=class extends Uv{},t.n=Er,t.o=qn,t.p=Qg,t.q=Xs,t.r=Js,t.s=Qs,t.t=ca,t.u=al,t.v=ll,t.w=pi,t.x=pa,t.y=da,t.z=qo})),n(0,(function(t){function e(t){const e=t?t.url.toString():void 0;return e?performance.getEntriesByName(e):[]}function i(t){if("number"==typeof t||"boolean"==typeof t||"string"==typeof t||null==t)return JSON.stringify(t);if(Array.isArray(t)){let e="[";for(const n of t)e+=`${i(n)},`;return`${e}]`}let e="{";for(const n of Object.keys(t).sort())e+=`${n}:${i(t[n])},`;return`${e}}`}function n(e){let n="";for(const r of t.cE)n+=`/${i(e[r])}`;return n}class r{constructor(t){this.keyCache={},this._layers={},this._layerConfigs={},t&&this.replace(t)}replace(t,e){this._layerConfigs={},this._layers={},this.update(t,[],e)}update(e,i,r){this._options=r;for(const i of e)this._layerConfigs[i.id]=i,(this._layers[i.id]=t.cY(i,this.scope,null,this._options)).compileFilter(),this.keyCache[i.id]&&delete this.keyCache[i.id];for(const t of i)delete this.keyCache[t],delete this._layerConfigs[t],delete this._layers[t];this.familiesBySource={};const o=function(t,e){const i={};for(let r=0;rthis._layers[t.id])),i=e[0];if("none"===i.visibility)continue;const n=i.source||"";let r=this.familiesBySource[n];r||(r=this.familiesBySource[n]={});const o=i.sourceLayer||"_geojsonTileLayer";let s=r[o];s||(s=r[o]=[]),s.push(e)}}}const o=1*t.dJ;class s{constructor(e){const i={},n=[];for(const t in e){const r=e[t],s=i[t]={};for(const t in r.glyphs){const e=r.glyphs[+t];if(!e||0===e.bitmap.width||0===e.bitmap.height)continue;const i=e.metrics.localGlyph?o:1,a={x:0,y:0,w:e.bitmap.width+2*i,h:e.bitmap.height+2*i};n.push(a),s[t]=a}}const{w:r,h:s}=t.j(n),a=new t.dI({width:r||1,height:s||1});for(const n in e){const r=e[n];for(const e in r.glyphs){const s=r.glyphs[+e];if(!s||0===s.bitmap.width||0===s.bitmap.height)continue;const l=i[n][e],c=s.metrics.localGlyph?o:1;t.dI.copy(s.bitmap,a,{x:0,y:0},{x:l.x+c,y:l.y+c},s.bitmap)}}this.image=a,this.positions=i}}t.dH(s,"GlyphAtlas");class a{constructor(e){this.tileID=new t.aL(e.tileID.overscaledZ,e.tileID.wrap,e.tileID.canonical.z,e.tileID.canonical.x,e.tileID.canonical.y),this.tileZoom=e.tileZoom,this.uid=e.uid,this.zoom=e.zoom,this.lut=e.lut,this.canonical=e.tileID.canonical,this.pixelRatio=e.pixelRatio,this.tileSize=e.tileSize,this.source=e.source,this.scope=e.scope,this.overscaling=this.tileID.overscaleFactor(),this.showCollisionBoxes=e.showCollisionBoxes,this.collectResourceTiming=!!e.collectResourceTiming,this.promoteId=e.promoteId,this.isSymbolTile=e.isSymbolTile,this.tileTransform=t.dK(e.tileID.canonical,e.projection),this.projection=e.projection,this.brightness=e.brightness,this.extraShadowCaster=!!e.extraShadowCaster,this.tessellationStep=e.tessellationStep}parse(e,i,n,r,o){this.status="parsing",this.data=e,this.collisionBoxArray=new t.dL;const a=new t.dM(Object.keys(e.layers).sort()),c=new t.dN(this.tileID,this.promoteId);c.bucketLayerIDs=[];const d={},u=new t.dO(256,256),h={featureIndex:c,iconDependencies:{},patternDependencies:{},glyphDependencies:{},lineAtlas:u,availableImages:n,brightness:this.brightness},p=i.familiesBySource[this.source];for(const i in p){const r=e.layers[i];if(!r)continue;let o=!1,s=!1,u=!1;for(const t of p[i])"symbol"===t[0].type?o=!0:s=!0,t[0].is3D()&&"model"!==t[0].type&&(u=!0);if(this.extraShadowCaster&&!u)continue;if(!0===this.isSymbolTile&&!o)continue;if(!1===this.isSymbolTile&&!s)continue;1===r.version&&t.w(`Vector tile source "${this.source}" layer "${i}" does not use vector tile spec v2 and therefore may have some rendering errors.`);const f=a.encode(i),m=[];for(let t=0;t=e.maxzoom||"none"!==e.visibility&&(l(t,this.zoom,h.brightness,n),(d[e.id]=e.createBucket({index:c.bucketLayerIDs.length,layers:t,zoom:this.zoom,lut:this.lut,canonical:this.canonical,pixelRatio:this.pixelRatio,overscaling:this.overscaling,collisionBoxArray:this.collisionBoxArray,sourceLayerIndex:f,sourceID:this.source,projection:this.projection.spec,tessellationStep:this.tessellationStep})).populate(m,h,this.tileID.canonical,this.tileTransform),c.bucketLayerIDs.push(t.map((t=>t.id)))))}}let f,m,_,g;u.trim();const y={type:"maybePrepare",isSymbolTile:this.isSymbolTile,zoom:this.zoom},v=()=>{if(f)return this.status="done",o(f);if(this.extraShadowCaster)this.status="done",o(null,{buckets:t.dG(d).filter((t=>!t.isEmpty())),featureIndex:c,collisionBoxArray:null,glyphAtlasImage:null,lineAtlas:null,imageAtlas:null,brightness:h.brightness,glyphMap:null,iconMap:null,glyphPositions:null});else if(m&&_&&g){const e=new s(m),i=new t.dQ(_,g,this.lut);for(const r in d){const o=d[r];o instanceof t.dR?(l(o.layers,this.zoom,h.brightness,n),t.dS(o,m,e.positions,_,i.iconPositions,this.showCollisionBoxes,n,this.tileID.canonical,this.tileZoom,this.projection,this.brightness)):o.hasPattern&&(o instanceof t.dT||o instanceof t.dU||o instanceof t.b_)&&(l(o.layers,this.zoom,h.brightness,n),o.addFeatures(h,this.tileID.canonical,i.patternPositions,n,this.tileTransform,this.brightness))}this.status="done",o(null,{buckets:t.dG(d).filter((t=>!t.isEmpty())),featureIndex:c,collisionBoxArray:this.collisionBoxArray,glyphAtlasImage:e.image,lineAtlas:u,imageAtlas:i,brightness:h.brightness})}};if(!this.extraShadowCaster){const e=t.dP(h.glyphDependencies,(t=>Object.keys(t).map(Number)));Object.keys(e).length?r.send("getGlyphs",{uid:this.uid,stacks:e,scope:this.scope},((t,e)=>{f||(f=t,m=e,v())}),void 0,!1,y):m={};const i=Object.keys(h.iconDependencies);i.length?r.send("getImages",{icons:i,source:this.source,scope:this.scope,tileID:this.tileID,type:"icons"},((t,e)=>{f||(f=t,_=e,v())}),void 0,!1,y):_={};const n=Object.keys(h.patternDependencies);n.length?r.send("getImages",{icons:n,source:this.source,scope:this.scope,tileID:this.tileID,type:"patterns"},((t,e)=>{f||(f=t,g=e,v())}),void 0,!1,y):g={}}v()}}function l(e,i,n,r){const o=new t.X(i,{brightness:n});for(const t of e)t.recalculate(o,r)}class c extends t.E{constructor(e,i,n,r,o,s){super(),this.actor=e,this.layerIndex=i,this.availableImages=n,this.loadVectorData=o||t.ap,this.loading={},this.loaded={},this.deduped=new t.ao(e.scheduler),this.isSpriteLoaded=r,this.scheduler=e.scheduler,this.brightness=s}loadTile(i,n){const r=i.uid,o=i&&i.request,s=o&&o.collectResourceTiming,l=this.loading[r]=new a(i);l.abort=this.loadVectorData(i,((a,c)=>{const d=!this.loading[r];if(delete this.loading[r],d||a||!c)return l.status="done",d||(this.loaded[r]=l),n(a);const u=c.rawData,h={};c.expires&&(h.expires=c.expires),c.cacheControl&&(h.cacheControl=c.cacheControl),l.vectorTile=c.vectorTile||new t.dV(new t.dW(u));const p=()=>{l.parse(l.vectorTile,this.layerIndex,this.availableImages,this.actor,((i,r)=>{if(i||!r)return n(i);const a={};if(s){const t=e(o);t.length>0&&(a.resourceTiming=JSON.parse(JSON.stringify(t)))}n(null,t.W({rawTileData:u.slice(0)},r,h,a))}))};this.isSpriteLoaded?p():this.once("isSpriteLoaded",(()=>{this.scheduler?this.scheduler.add(p,{type:"parseTile",isSymbolTile:i.isSymbolTile,zoom:i.tileZoom}):p()})),this.loaded=this.loaded||{},this.loaded[r]=l}))}reloadTile(e,i){const n=this.loaded,r=e.uid;if(n&&n[r]){const o=n[r];o.showCollisionBoxes=e.showCollisionBoxes,o.projection=e.projection,o.brightness=e.brightness,o.tileTransform=t.dK(e.tileID.canonical,e.projection),o.extraShadowCaster=e.extraShadowCaster,o.lut=e.lut;const s=(t,e)=>{const n=o.reloadCallback;n&&(delete o.reloadCallback,o.parse(o.vectorTile,this.layerIndex,this.availableImages,this.actor,n)),i(t,e)};"parsing"===o.status?o.reloadCallback=s:"done"===o.status&&(o.vectorTile?o.parse(o.vectorTile,this.layerIndex,this.availableImages,this.actor,s):s())}else i(null,void 0)}abortTile(t,e){const i=t.uid,n=this.loading[i];n&&(n.abort&&n.abort(),delete this.loading[i]),e()}removeTile(t,e){const i=this.loaded,n=t.uid;i&&i[n]&&delete i[n],e()}}class d{loadTile(e,i){const{uid:n,encoding:r,rawImageData:o,padding:s}=e,a=ImageBitmap&&o instanceof ImageBitmap?this.getImageData(o,s):o;i(null,new t.dX(n,a,r,s{n(null,t)}),(t=>{n(t)}))}}const h=t.dZ.prototype.toGeoJSON;let p=class{constructor(e){this._feature=e,this.extent=t.a3,this.type=e.type,this.properties=e.tags,"id"in e&&!isNaN(e.id)&&(this.id=parseInt(e.id,10))}loadGeometry(){if(1===this._feature.type){const e=[];for(const i of this._feature.geometry)e.push([new t.P(i[0],i[1])]);return e}{const e=[];for(const i of this._feature.geometry){const n=[];for(const e of i)n.push(new t.P(e[0],e[1]));e.push(n)}return e}}toGeoJSON(t,e,i){return h.call(this,t,e,i)}},f=class{constructor(e){this.layers={_geojsonTileLayer:this},this.name="_geojsonTileLayer",this.extent=t.a3,this.length=e.length,this._features=e}feature(t){return new p(this._features[t])}};const m=64/4096;class _{constructor(){this.features=new Map}clear(){this.features.clear()}load(t=[],e){for(const i of t){const t=i.id;if(null==t)continue;let n=this.features.get(t);n&&this.updateCache(n,e),i.geometry?(n=y(i),this.updateCache(n,e),this.features.set(t,n)):this.features.delete(t),this.updateCache(n,e)}}updateCache(t,e){for(const{canonical:i,uid:n}of Object.values(e)){const{z:r,x:o,y:s}=i;g(t,Math.pow(2,r),o,s)&&delete e[n]}}getTile(t,e,i){const n=Math.pow(2,t),r=[];for(const t of this.features.values())g(t,n,e,i)&&r.push(w(t,n,e,i));return{features:r}}getFeatures(){return[...this.features.values()]}}function g({minX:t,minY:e,maxX:i,maxY:n},r,o,s){return t(o-m)/r&&n>(s-m)/r}function y(t){const{id:e,geometry:i,properties:n}=t;if(!i)return;if("GeometryCollection"===i.type)throw new Error("GeometryCollection not supported in dynamic mode.");const{type:r,coordinates:o}=i,s={id:e,type:1,geometry:[],tags:n,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0},a=s.geometry;if("Point"===r)v(o,a,s);else if("MultiPoint"===r)for(const t of o)v(t,a,s);else if("LineString"===r)s.type=2,x(o,a,s);else if("MultiLineString"===r)s.type=2,b(o,a,s);else if("Polygon"===r)s.type=3,b(o,a,s,!0);else{if("MultiPolygon"!==r)throw new Error("Input data is not a valid GeoJSON object.");s.type=3;for(const t of o)b(t,a,s,!0)}return s}function v([e,i],n,r){const o=t.aj(e);let s=t.ak(i);s=s1?1:s,n.push(o,s),r.minX=Math.min(r.minX,o),r.minY=Math.min(r.minY,s),r.maxX=Math.max(r.maxX,o),r.maxY=Math.max(r.maxY,s)}function x(t,e,i,n=!1,r=!1){const o=[];for(const e of t)v(e,o,i);e.push(o),n&&function(t,e){let i=0;for(let e=0,n=t.length,r=n-2;e0===e)for(let e=0,i=t.length;e>31}function F(t,e){for(var i=t.loadGeometry(),n=t.type,r=0,o=0,s=i.length,a=0;at},V=Math.fround||(G=new Float32Array(1),t=>(G[0]=+t,G[0]));var G;const Z=3,q=5,H=6;class W{constructor(t){this.options=Object.assign(Object.create(j),t),this.trees=new Array(this.options.maxZoom+1),this.stride=this.options.reduce?7:6,this.clusterProps=[]}load(t){const{log:e,minZoom:i,maxZoom:n}=this.options;e&&console.time("total time");const r=`prepare ${t.length} points`;e&&console.time(r),this.points=t;const o=[];for(let e=0;e=i;t--){const i=+Date.now();s=this.trees[t]=this._createTree(this._cluster(s,t)),e&&console.log("z%d: %d clusters in %dms",t,s.numItems,+Date.now()-i)}return e&&console.timeEnd("total time"),this}getClusters(t,e){let i=((t[0]+180)%360+360)%360-180;const n=Math.max(-90,Math.min(90,t[1]));let r=180===t[2]?180:((t[2]+180)%360+360)%360-180;const o=Math.max(-90,Math.min(90,t[3]));if(t[2]-t[0]>=360)i=-180,r=180;else if(i>r){const t=this.getClusters([i,n,180,o],e),s=this.getClusters([-180,n,r,o],e);return t.concat(s)}const s=this.trees[this._limitZoom(e)],a=s.range(K(i),J(o),K(r),J(n)),l=s.data,c=[];for(const t of a){const e=this.stride*t;c.push(l[e+q]>1?Y(l,e,this.clusterProps):this.points[l[e+Z]])}return c}getChildren(t){const e=this._getOriginId(t),i=this._getOriginZoom(t),n="No cluster with the specified id.",r=this.trees[i];if(!r)throw new Error(n);const o=r.data;if(e*this.stride>=o.length)throw new Error(n);const s=this.options.radius/(this.options.extent*Math.pow(2,i-1)),a=r.within(o[e*this.stride],o[e*this.stride+1],s),l=[];for(const e of a){const i=e*this.stride;o[i+4]===t&&l.push(o[i+q]>1?Y(o,i,this.clusterProps):this.points[o[i+Z]])}if(0===l.length)throw new Error(n);return l}getLeaves(t,e,i){const n=[];return this._appendLeaves(n,t,e=e||10,i=i||0,0),n}getTile(t,e,i){const n=this.trees[this._limitZoom(t)],r=Math.pow(2,t),{extent:o,radius:s}=this.options,a=s/o,l=(i-a)/r,c=(i+1+a)/r,d={features:[]};return this._addTileFeatures(n.range((e-a)/r,l,(e+1+a)/r,c),n.data,e,i,r,d),0===e&&this._addTileFeatures(n.range(1-a/r,l,1,c),n.data,r,i,r,d),e===r-1&&this._addTileFeatures(n.range(0,l,a/r,c),n.data,-1,i,r,d),d.features.length?d:null}getClusterExpansionZoom(t){let e=this._getOriginZoom(t)-1;for(;e1;let l,c,d;if(a)l=X(e,t,this.clusterProps),c=e[t],d=e[t+1];else{const i=this.points[e[t+Z]];l=i.properties;const[n,r]=i.geometry.coordinates;c=K(n),d=J(r)}const u={type:1,geometry:[[Math.round(this.options.extent*(c*r-i)),Math.round(this.options.extent*(d*r-n))]],tags:l};let h;h=a||this.options.generateId?e[t+Z]:this.points[e[t+Z]].id,void 0!==h&&(u.id=h),o.features.push(u)}}_limitZoom(t){return Math.max(this.options.minZoom,Math.min(Math.floor(+t),this.options.maxZoom+1))}_cluster(t,e){const{radius:i,extent:n,reduce:r,minPoints:o}=this.options,s=i/(n*Math.pow(2,e)),a=t.data,l=[],c=this.stride;for(let i=0;ie&&(p+=a[i+q])}if(p>h&&p>=o){let t,o=n*h,s=d*h,f=-1;const m=(i/c1)for(const t of u){const i=t*c;if(!(a[i+2]>5}_getOriginZoom(t){return(t-this.points.length)%32}_map(t,e,i){if(t[e+q]>1){const n=this.clusterProps[t[e+H]];return i?Object.assign({},n):n}const n=this.points[t[e+Z]].properties,r=this.options.map(n);return i&&r===n?Object.assign({},r):r}}function Y(t,e,i){return{type:"Feature",id:t[e+Z],properties:X(t,e,i),geometry:{type:"Point",coordinates:[(n=t[e],360*(n-.5)),Q(t[e+1])]}};var n}function X(t,e,i){const n=t[e+q],r=n>=1e4?`${Math.round(n/1e3)}k`:n>=1e3?Math.round(n/100)/10+"k":n,o=t[e+H],s=-1===o?{}:Object.assign({},i[o]);return Object.assign(s,{cluster:!0,cluster_id:t[e+Z],point_count:n,point_count_abbreviated:r})}function K(t){return t/360+.5}function J(t){const e=Math.sin(t*Math.PI/180),i=.5-.25*Math.log((1+e)/(1-e))/Math.PI;return i1?1:i}function Q(t){const e=(180-360*t)*Math.PI/180;return 360*Math.atan(Math.exp(e))/Math.PI-90}function tt(t,e,i,n){let r=n;const o=e+(i-e>>1);let s,a=i-e;const l=t[e],c=t[e+1],d=t[i],u=t[i+1];for(let n=e+3;n =e;r-=n)o=jh(r/n|0,t[r],t[r+1],o);return o&&Rh(o,o.next)&&(Vh(o),o=o.next),o}function wh(t,e){if(!t)return t;e||(e=t);let i,n=t;do{if(i=!1,n.steiner||!Rh(n,n.next)&&0!==zh(n.prev,n,n.next))n=n.next;else{if(Vh(n),n=e=n.prev,n===n.next)break;i=!0}}while(i||n!==e);return e}function Th(t,e,i,n,r,o,s){if(!t)return;!s&&o&&function(t,e,i,n){let r=t;do{0===r.z&&(r.z=Ph(r.x,r.y,e,i,n)),r.prevZ=r.prev,r.nextZ=r.next,r=r.next}while(r!==t);r.prevZ.nextZ=null,r.prevZ=null,function(t){let e,i=1;do{let n,r=t;t=null;let o=null;for(e=0;r;){e++;let s=r,a=0;for(let t=0;t0||l>0&&s;)0!==a&&(0===l||!s||r.z1)}(r)}(t,n,r,o);let a=t;for(;t.prev!==t.next;){const l=t.prev,c=t.next;if(o?Eh(t,n,r,o):Sh(t))e.push(l.i,t.i,c.i),Vh(t),t=c.next,a=c.next;else if((t=c)===a){s?1===s?Th(t=Mh(wh(t),e),e,i,n,r,o,2):2===s&&Ch(t,e,i,n,r,o):Th(wh(t),e,i,n,r,o,1);break}}}function Sh(t){const e=t.prev,i=t,n=t.next;if(zh(e,i,n)>=0)return!1;const r=e.x,o=i.x,s=n.x,a=e.y,l=i.y,c=n.y,d=ro?r>s?r:s:o>s?o:s,p=a>l?a>c?a:c:l>c?l:c;let f=n.next;for(;f!==e;){if(f.x>=d&&f.x=u&&f.y=0)return!1;f=f.next}return!0}function Eh(t,e,i,n){const r=t.prev,o=t,s=t.next;if(zh(r,o,s)>=0)return!1;const a=r.x,l=o.x,c=s.x,d=r.y,u=o.y,h=s.y,p=al?a>c?a:c:l>c?l:c,_=d>u?d>h?d:h:u>h?u:h,g=Ph(p,f,e,i,n),y=Ph(m,_,e,i,n);let v=t.prevZ,x=t.nextZ;for(;v&&v.z>=g&&x&&x.z=p&&v.x=f&&v.y=0)return!1;if(v=v.prevZ,x.x>=p&&x.x=f&&x.y=0)return!1;x=x.nextZ}for(;v&&v.z>=g;){if(v.x>=p&&v.x=f&&v.y=0)return!1;v=v.prevZ}for(;x&&x.z=p&&x.x=f&&x.y=0)return!1;x=x.nextZ}return!0}function Mh(t,e){let i=t;do{const n=i.prev,r=i.next.next;!Rh(n,r)&&Oh(n,i,i.next,r)&&Nh(n,r)&&Nh(r,n)&&(e.push(n.i,i.i,r.i),Vh(i),Vh(i.next),i=t=r),i=i.next}while(i!==t);return wh(i)}function Ch(t,e,i,n,r,o){let s=t;do{let t=s.next.next;for(;t!==s.prev;){if(s.i!==t.i&&Dh(s,t)){let a=Uh(s,t);return s=wh(s,s.next),a=wh(a,a.next),Th(s,e,i,n,r,o,0),void Th(a,e,i,n,r,o,0)}t=t.next}s=s.next}while(s!==t)}function Ah(t,e){return t.x-e.x}function Ih(t,e){const i=function(t,e){let i=e;const n=t.x,r=t.y;let o,s=-1/0;do{if(r=i.next.y&&i.next.y!==i.y){const t=i.x+(r-i.y)*(i.next.x-i.x)/(i.next.y-i.y);if(ts&&(s=t,o=i.x=i.x&&i.x>=l&&n!==i.x&&kh(ro.x||i.x===o.x&&Lh(o,i)))&&(o=i,d=e)}i=i.next}while(i!==a);return o}(t,e);if(!i)return e;const n=Uh(i,t);return wh(n,n.next),wh(i,i.next)}function Lh(t,e){return zh(t.prev,t,e.prev)=(t-s)*(o-a)&&(t-s)*(n-a)>=(i-s)*(e-a)&&(i-s)*(o-a)>=(r-s)*(n-a)}function Dh(t,e){return t.next.i!==e.i&&t.prev.i!==e.i&&!function(t,e){let i=t;do{if(i.i!==t.i&&i.next.i!==t.i&&i.i!==e.i&&i.next.i!==e.i&&Oh(i,i.next,t,e))return!0;i=i.next}while(i!==t);return!1}(t,e)&&(Nh(t,e)&&Nh(e,t)&&function(t,e){let i=t,n=!1;const r=(t.x+e.x)/2,o=(t.y+e.y)/2;do{i.y>o!=i.next.y>o&&i.next.y!==i.y&&r0&&zh(e.prev,e,e.next)>0)}function zh(t,e,i){return(e.y-t.y)*(i.x-e.x)-(e.x-t.x)*(i.y-e.y)}function Rh(t,e){return t.x===e.x&&t.y===e.y}function Oh(t,e,i,n){const r=Fh(zh(t,e,i)),o=Fh(zh(t,e,n)),s=Fh(zh(i,n,t)),a=Fh(zh(i,n,e));return r!==o&&s!==a||!(0!==r||!Bh(t,i,e))||!(0!==o||!Bh(t,n,e))||!(0!==s||!Bh(i,t,n))||!(0!==a||!Bh(i,e,n))}function Bh(t,e,i){return e.x=Math.min(t.x,i.x)&&e.y=Math.min(t.y,i.y)}function Fh(t){return t>0?1:t=0&&zh(t,t.prev,e)>=0:zh(t,e,t.prev)1)for(let t=0;tt.fqid)),this.index=t.index,this.hasPattern=!1,this.patternFeatures=[],this.layoutVertexArray=new $l,this.indexArray=new Kl,this.indexArray2=new ql,this.programConfigurations=new Yc(t.layers,{zoom:t.zoom,lut:t.lut}),this.segments=new wc,this.segments2=new wc,this.stateDependentLayerIds=this.layers.filter((t=>t.isStateDependent())).map((t=>t.id)),this.projection=t.projection}updateFootprints(t,e){}populate(t,e,i,n){this.hasPattern=Hh("fill",this.layers,e);const r=this.layers[0].layout.get("fill-sort-key"),o=[];for(const{feature:s,id:a,index:l,sourceLayerIndex:c}of t){const t=this.layers[0]._featureFilter.needGeometry,d=Zd(s,t);if(!this.layers[0]._featureFilter.filter(new Ha(this.zoom),d,i))continue;const u=r?r.evaluate(d,{},i,e.availableImages):void 0,h={id:a,properties:s.properties,type:s.type,sourceLayerIndex:c,index:l,geometry:t?d.geometry:Gd(s,i,n),patterns:{},sortKey:u};o.push(h)}r&&o.sort(((t,e)=>t.sortKey-e.sortKey));for(const n of o){const{geometry:r,index:o,sourceLayerIndex:s}=n;if(this.hasPattern){const t=Wh("fill",this.layers,n,this.zoom,e);this.patternFeatures.push(t)}else this.addFeature(n,r,o,i,{},e.availableImages,e.brightness);e.featureIndex.insert(t[o].feature,r,o,s,this.index)}}update(t,e,i,n,r){const o=0!==Object.keys(t).length;o&&!this.stateDependentLayers.length||this.programConfigurations.updatePaintArrays(t,e,o?this.stateDependentLayers:this.layers,i,n,r)}addFeatures(t,e,i,n,r,o){for(const t of this.patternFeatures)this.addFeature(t,t.geometry,t.index,e,i,n,o)}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(t){this.uploaded||(this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,vh),this.indexBuffer=t.createIndexBuffer(this.indexArray),this.indexBuffer2=t.createIndexBuffer(this.indexArray2)),this.programConfigurations.upload(t),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.indexBuffer2.destroy(),this.programConfigurations.destroy(),this.segments.destroy(),this.segments2.destroy())}addFeature(t,e,i,n,r,o=[],s){for(const t of Zh(e,500)){let e=0;for(const i of t)e+=i.length;const i=this.segments.prepareSegment(e,this.layoutVertexArray,this.indexArray),n=i.vertexLength,r=[],o=[];for(const e of t){if(0===e.length)continue;e!==t[0]&&o.push(r.length/2);const i=this.segments2.prepareSegment(e.length,this.layoutVertexArray,this.indexArray2),n=i.vertexLength;this.layoutVertexArray.emplaceBack(e[0].x,e[0].y),this.indexArray2.emplaceBack(n+e.length-1,n),r.push(e[0].x),r.push(e[0].y);for(let t=1;tt.cellIdx-e.cellIdx||t.triIdx-e.triIdx));let c=0;for(;cthis.max.x||this.min.x>t.x||t.y>this.max.y||this.min.y>t.y)return;const i=Qh(t.x-this.min.x,this.xScale,this.cellsX),n=Qh(t.y-this.min.y,this.yScale,this.cellsY),r=this.cells[n*this.cellsX+i];if(r){this._lazyInitLookup();for(let t=0;tthis.max.x||this.min.x>e.x)return;if(t.y>this.max.y||this.min.y>e.y)return;this._lazyInitLookup();const n=Qh(t.x-this.min.x,this.xScale,this.cellsX),r=Qh(e.x-this.min.x,this.xScale,this.cellsX),o=Qh(t.y-this.min.y,this.yScale,this.cellsY),s=Qh(e.y-this.min.y,this.yScale,this.cellsY);for(let t=o;tt.fqid)),this.index=t.index,this.hasPattern=!1,this.stateDependentLayerIds=this.layers.filter((t=>t.isStateDependent())).map((t=>t.id)),this.footprints=[]}updateFootprints(t,e){for(const i of this.footprints)e.push({footprint:i,id:t})}populate(t,e,i,n){const r=[];for(const{feature:e,id:o,index:s,sourceLayerIndex:a}of t){const t=this.layers[0]._featureFilter.needGeometry,l=Zd(e,t);if(!this.layers[0]._featureFilter.filter(new Ha(this.zoom),l,i))continue;const c={id:o,properties:e.properties,type:e.type,sourceLayerIndex:a,index:s,geometry:t?l.geometry:Gd(e,i,n),patterns:{}};r.push(c)}for(const n of r){const{geometry:r,index:o,sourceLayerIndex:s}=n;this.addFeature(n,r,o,i,{},e.availableImages,e.brightness),e.featureIndex.insert(t[o].feature,r,o,s,this.index)}}isEmpty(){return 0===this.footprints.length}uploadPending(){return!1}upload(t){}update(t,e,i,n,r){}destroy(){}addFeature(t,e,i,n,r,o=[],s){for(const t of Zh(e,2)){const e=[],i=[],n=[],r=new Ue(1/0,1/0),o=new Ue(-1/0,-1/0);for(const s of t)if(0!==s.length){s!==t[0]&&n.push(i.length/2);for(let t=0;t>3}if(r--,1===n||2===n)o+=t.readSVarint(),s+=t.readSVarint(),1===n&&(e&&a.push(e),e=[]),e.push(new dp(o,s));else{if(7!==n)throw new Error("unknown command "+n);e&&e.push(e[0].clone())}}return e&&a.push(e),a},hp.prototype.bbox=function(){var t=this._pbf;t.pos=this._geometry;for(var e=t.readVarint()+t.pos,i=1,n=0,r=0,o=0,s=1/0,a=-1/0,l=1/0,c=-1/0;t.pos>3}if(n--,1===i||2===i)(r+=t.readSVarint())a&&(a=r),(o+=t.readSVarint())c&&(c=o);else if(7!==i)throw new Error("unknown command "+i)}return[s,l,a,c]},hp.prototype.toGeoJSON=function(t,e,i){var n,r,o=this.extent*Math.pow(2,i),s=this.extent*t,a=this.extent*e,l=this.loadGeometry(),c=hp.types[this.type];function d(t){for(var e=0;e>3;e=1===n?t.readString():2===n?t.readFloat():3===n?t.readDouble():4===n?t.readVarint64():5===n?t.readVarint():6===n?t.readSVarint():7===n?t.readBoolean():null}return e}(i))}gp.prototype.feature=function(t){if(t=this._features.length)throw new Error("feature index out of bounds");this._pbf.pos=this._features[t];var e=this._pbf.readVarint()+this._pbf.pos;return new mp(this._pbf,e,this.extent,this._keys,this._values)};var vp=_p;function xp(t,e,i){if(3===t){var n=new vp(i,i.readVarint()+i.pos);n.length&&(e[n.name]=n)}}var bp=cp.VectorTile=function(t,e){this.layers=t.readFields(xp,{},e)},wp=cp.VectorTileFeature=up;cp.VectorTileLayer=_p;class Tp extends Ue{constructor(t,e,i){super(t,e),this.z=i}}class Sp extends Tp{constructor(t,e,i,n){super(t,e,i),this.w=n}}function Ep(t,e,i,n){const r=[],o=0===n?(t,e,i,n,r,o)=>{t.push(new Ue(o,i+(o-e)/(n-e)*(r-i)))}:(t,e,i,n,r,o)=>{t.push(new Ue(e+(o-i)/(r-i)*(n-e),o))};for(const s of t){const t=[];for(const r of s){if(r.lengthe&&o(s,a,l,c,d,e):u>i?h=e&&o(s,a,l,c,d,e),h>i&&u=e&&l=s[i]&&(n=e,s=t),n[i]r&&Mp(n,s,i,r),n[i]o&&Mp(s,n,i,o)}}function Ap(t,e){return t.x-e.x||t.y-e.y}function Ip(t,e){return 0===Ap(t.min,e.min)&&0===Ap(t.max,e.max)}function Lp(t,e){return!(t.min.x>e.max.x||t.max.xe.max.y||t.max.ynew Ue((t.x+o.x*uo)*a-s.x*uo,(t.y+o.y*uo)*a-s.y*uo)))}return Dp(i,r,t.indices,0,t.indices.length,0,0)}function Rp(t,e,i,n){const r=Math.pow(2,n.z-i.z);return new Ue((t+i.x*uo)*r-n.x*uo,(e+i.y*uo)*r-n.y*uo)}function Op(t,e){const i=[];e.footprint.grid.queryPoint(t,i);const n=e.footprint.indices,r=e.footprint.vertices;for(let e=0;ee[s])return null}else{const a=1/n[s];let l=(t[s]-i[s])*a,c=(e[s]-i[s])*a;if(l>c){const t=l;l=c,c=t}if(l>r&&(r=l),co)return null}return r}function Np(t,e,i,n,r,o,s,a,l,c,d){const u=n-t,h=r-e,p=o-i,f=s-t,m=a-e,_=l-i,g=d[1]*_-d[2]*m,y=d[2]*f-d[0]*_,v=d[0]*m-d[1]*f,x=u*g+h*y+p*v;if(Math.abs(x)1)return null;const M=T*p-S*h,C=S*u-w*p,A=w*h-T*u,I=(d[0]*M+d[1]*C+d[2]*A)*b;return I1?null:(f*M+m*C+_*A)*b}function Up(t,e,i){return(t-e)/(i-e)}function jp(t,e,i,n,r,o,s,a,l){const c=1{const o=n?1:0,s=(t+1)*i-o,a=e*i,l=(e+1)*i-o;r[0]=t*i,r[1]=a,r[2]=s,r[3]=l};let s=new Bp(n);const a=[];for(let e=0;e=1;n/=2){const t=i[i.length-1];s=new Bp(n);for(let e=0;e0;){const{idx:l,t:f,nodex:m,nodey:_,depth:g}=p.pop();if(this.leaves[l]){jp(m,_,g,e,i,n,r,u,h);const l=1=e[2])return f}continue}let y=0;for(let t=0;t=c[d[n]]&&(d.splice(n,0,t),i=!0);i||(d[y]=t),y++}}for(let t=0;t=this.dim+1||e=this.dim+1)throw new RangeError("out of range source coordinates for DEM data");return(e+1)*this.stride+(t+1)}static pack(t,e){const i=[0,0,0,0],n=Yp.getUnpackVector(e);let r=Math.floor((t+n[3])/n[2]);return i[2]=r%256,r=Math.floor(r/256),i[1]=r%256,r=Math.floor(r/256),i[0]=r,i}getPixels(){return new hh({width:this.stride,height:this.stride},this.pixels)}backfillBorder(t,e,i){if(this.dim!==t.dim)throw new Error("dem dimension mismatch");let n=e*this.dim,r=e*this.dim+this.dim,o=i*this.dim,s=i*this.dim+this.dim;switch(e){case-1:n=r-1;break;case 1:r=n+1}switch(i){case-1:o=s-1;break;case 1:s=o+1}const a=-e*this.dim,l=-i*this.dim;for(let e=o;et.max.x&&(t.max.x=e.x,n=!0),e.yt.max.y&&(t.max.y=e.y,n=!0),((0===e.x||e.x===uo)&&e.x===i.x)!=((0===e.y||e.y===uo)&&e.y===i.y)&&this.processBorderOverlap(e,i),n&&this.checkBorderIntersection(e,i)}checkBorderIntersection(t,e){e.xuo!=t.x>uo&&this.addBorderIntersection(1,Vn(e.y,t.y,(uo-e.x)/(t.x-e.x))),e.yuo!=t.y>uo&&this.addBorderIntersection(3,Vn(e.x,t.x,(uo-e.y)/(t.y-e.y)))}addBorderIntersection(t,e){this.borders||(this.borders=[[Number.MAX_VALUE,-Number.MAX_VALUE],[Number.MAX_VALUE,-Number.MAX_VALUE],[Number.MAX_VALUE,-Number.MAX_VALUE],[Number.MAX_VALUE,-Number.MAX_VALUE]]);const i=this.borders[t];ei[1]&&(i[1]=e)}processBorderOverlap(t,e){if(t.x===e.x){if(t.y===e.y)return;const i=0===t.x?0:1;this.addBorderIntersection(i,e.y),this.addBorderIntersection(i,t.y)}else{const i=0===t.y?2:3;this.addBorderIntersection(i,e.x),this.addBorderIntersection(i,t.x)}}centroid(){return 0===this.accCount?new Ue(0,0):new Ue(Math.floor(Math.max(0,this.acc.x)/this.accCount),Math.floor(Math.max(0,this.acc.y)/this.accCount))}intersectsCount(){return this.borders?this.borders.reduce(((t,e)=>t+ +(e[0]!==Number.MAX_VALUE)),0):0}}function hf(t,e){const i=t.add(e)._unit(),n=Xe(t.x*i.x+t.y*i.y,-1,1);var r,o,s;return r=Math.acos(n),Math.min(4,Math.max(-4,Math.tan(r)))/4*nf*((o=t).x*(s=e).y-o.y*s.xt.xt.x>uo,t=>t.yt.y>uo];function ff(t,e,i,n){const r=[4];if(0===n)return r;i._mult(n);const o=t.sub(i),s=e.sub(i),a=[t,e,o,s];for(let t=0;ttf.includes(t))),this._segments=new wc,this.hiddenByLandmarkVertexArray=new lc,this._segmentToGroundQuads={},this._segmentToGroundQuads[0]=[],this._segmentToRegionTriCounts={},this._segmentToRegionTriCounts[0]=[0,0,0,0,0],this.regionSegments={},this.regionSegments[4]=new wc}getDefaultSegment(){return this.regionSegments[4]}hasData(){return 0!==this.vertexArray.length}addData(t,e,i,n=!1){const r=t.length;if(r>2){let o=Math.max(0,this._segments.get().length-1);const s=this._segments._prepareSegment(4*r,this.vertexArray.length,2*this._segmentToGroundQuads[o].length);let a;o!==this._segments.get().length-1&&(o++,this._segmentToGroundQuads[o]=[],this._segmentToRegionTriCounts[o]=[0,0,0,0,0]);{const e=t[0],i=t[1];a=hf(e.sub(t[r-1])._perp()._unit(),i.sub(e)._perp()._unit())}for(let l=0;lt.region-e.region));for(let i=0;it+e),0);let o=0;for(let t=0;t0?this.hiddenByLandmarkVertexBuffer=t.createVertexBuffer(this.hiddenByLandmarkVertexArray,sp.members,!0):this.hiddenByLandmarkVertexBuffer&&this.hiddenByLandmarkVertexBuffer.updateData(this.hiddenByLandmarkVertexArray),this._needsHiddenByLandmarkUpdate=!1)}destroy(){if(this.vertexBuffer){this.vertexBuffer.destroy(),this.indexBuffer.destroy(),this.hiddenByLandmarkVertexBuffer&&this.hiddenByLandmarkVertexBuffer.destroy(),this._segments&&this._segments.destroy(),this.programConfigurations.destroy();for(let t=0;tt.fqid)),this.index=t.index,this.hasPattern=!1,this.edgeRadius=0,this.projection=t.projection,this.activeReplacements=[],this.replacementUpdateTime=0,this.centroidData=[],this.footprintIndices=new Kl,this.footprintVertices=new $l,this.footprintSegments=[],this.layoutVertexArray=new Dl,this.centroidVertexArray=new vc,this.indexArray=new Kl,this.programConfigurations=new Yc(t.layers,{zoom:t.zoom,lut:t.lut},(t=>Qp.includes(t))),this.segments=new wc,this.stateDependentLayerIds=this.layers.filter((t=>t.isStateDependent())).map((t=>t.id)),this.groundEffect=new mf(t),this.maxHeight=0,this.partLookup={},this.triangleSubSegments=[],this.polygonSegments=[]}updateFootprints(t,e){}populate(t,e,i,n){this.features=[],this.hasPattern=Hh("fill-extrusion",this.layers,e),this.featuresOnBorder=[],this.borderFeatureIndices=[[],[],[],[]],this.borderDoneWithNeighborZ=[-1,-1,-1,-1],this.tileToMeter=zd(i),this.edgeRadius=this.layers[0].layout.get("fill-extrusion-edge-radius")/this.tileToMeter;for(const{feature:r,id:o,index:s,sourceLayerIndex:a}of t){const t=this.layers[0]._featureFilter.needGeometry,l=Zd(r,t);if(!this.layers[0]._featureFilter.filter(new Ha(this.zoom),l,i))continue;const c={id:o,sourceLayerIndex:a,index:s,geometry:t?l.geometry:Gd(r,i,n),properties:r.properties,type:r.type,patterns:{}},d=this.layoutVertexArray.length;this.hasPattern?this.features.push(Wh("fill-extrusion",this.layers,c,this.zoom,e)):this.addFeature(c,c.geometry,s,i,{},e.availableImages,n,e.brightness),e.featureIndex.insert(r,c.geometry,s,a,this.index,d)}this.sortBorders(),"mercator"===this.projection.name&&this.splitToSubtiles(),this.groundEffect.prepareBorderSegments(),this.polygonSegments.length=0}addFeatures(t,e,i,n,r,o){for(const t of this.features){const{geometry:s}=t;this.addFeature(t,s,t.index,e,i,n,r,o)}this.sortBorders(),"mercator"===this.projection.name&&this.splitToSubtiles()}update(t,e,i,n,r){const o=0!==Object.keys(t).length;if(o&&!this.stateDependentLayers.length)return;const s=o?this.stateDependentLayers:this.layers;this.programConfigurations.updatePaintArrays(t,e,s,i,n,r),this.groundEffect.update(t,e,s,i,n,r)}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload||this.groundEffect.programConfigurations.needsUpload}upload(t){this.uploaded||(this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,lp),this.indexBuffer=t.createIndexBuffer(this.indexArray),this.layoutVertexExtArray&&(this.layoutVertexExtBuffer=t.createVertexBuffer(this.layoutVertexExtArray,ap.members,!0)),this.groundEffect.upload(t)),this.groundEffect.uploadPaintProperties(t),this.programConfigurations.upload(t),this.uploaded=!0}uploadCentroid(t){this.groundEffect.uploadHiddenByLandmark(t),this.needsCentroidUpdate&&(!this.centroidVertexBuffer&&this.centroidVertexArray.length>0?this.centroidVertexBuffer=t.createVertexBuffer(this.centroidVertexArray,op.members,!0):this.centroidVertexBuffer&&this.centroidVertexBuffer.updateData(this.centroidVertexArray),this.needsCentroidUpdate=!1)}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.centroidVertexBuffer&&this.centroidVertexBuffer.destroy(),this.layoutVertexExtBuffer&&this.layoutVertexExtBuffer.destroy(),this.groundEffect.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy())}addFeature(t,e,i,n,r,o,s,a){const l=this.layers[0].paint.get("fill-extrusion-flood-light-ground-radius").evaluate(t,{})/this.tileToMeter,c=[new Ue(0,0),new Ue(uo,uo)],d=s.projection,u="globe"===d.name,h="Polygon"===Jp[t.type],p=new uf;p.centroidDataIndex=this.centroidData.length;const f=new df,m=this.layers[0].paint.get("fill-extrusion-base").evaluate(t,{},n)=0;t--){const e=g[t];(0===e.length||(y=e[0]).every((t=>t.xt.x>=uo))||y.every((t=>t.yt.y>=uo)))&&g.splice(t,1)}var y;let v;if(u)v=Ef(g,c,n);else{v=[];for(const t of g)v.push({polygon:t,bounds:c})}const x=h?this.edgeRadius:0,b=x>0&&this.zoom{if(0===t.length)return!1;const i=t[t.length-1];return e.x===i.x&&e.y===i.y};for(const{polygon:t,bounds:e}of v){let i=0,r=0;for(const e of t)h&&!e[0].equals(e[e.length-1])&&e.push(e[0]),r+=h?e.length-1:e.length;const o=this.segments.prepareSegment((h?5:4)*r,this.layoutVertexArray,this.indexArray);f.footprintSegIdx4&&wf(s[s.length-2],s[0],s[1]),c=x?yf(s[s.length-2],s[0],s[1],x):0;const _=[];let g,y,v;y=s[1].sub(s[0])._perp()._unit();let b=!0;for(let t=1,r=0;t0?1:0,C=l.dist(h);if(r+C>32768&&(r=0),x){v=T.sub(h)._perp()._unit();let t=vf(l,h,T,gf(y,v),x);isNaN(t)&&(t=0);const e=h.sub(l)._unit();l=l.add(e.mult(c))._round(),h=h.add(e.mult(-t))._round(),c=t,y=v,m&&this.zoom>=17&&(w(_,l)||_.push(l),w(_,h)||_.push(h))}const A=o.vertexLength,I=s.length>4&&wf(l,h,T);let L=Tf(r,a,b);if(sf(this.layoutVertexArray,l.x,l.y,E,M,0,0,L),sf(this.layoutVertexArray,l.x,l.y,E,M,0,1,L),r+=C,L=Tf(r,I,!b),a=I,sf(this.layoutVertexArray,h.x,h.y,E,M,0,0,L),sf(this.layoutVertexArray,h.x,h.y,E,M,0,1,L),o.vertexLength+=4,this.indexArray.emplaceBack(A+0,A+1,A+2),this.indexArray.emplaceBack(A+1,A+3,A+2),o.primitiveLength+=2,x){const n=i+(1===t?s.length-2:t-2),r=1===t?i:n+1;if(this.indexArray.emplaceBack(A+1,n,A+3),this.indexArray.emplaceBack(n,r,A+3),o.primitiveLength+=2,void 0===g&&(g=A),!xf(T,s[t],e)){const e=t===s.length-1?g:o.vertexLength;this.indexArray.emplaceBack(A+2,A+3,e),this.indexArray.emplaceBack(A+3,e+1,e),this.indexArray.emplaceBack(A+3,r,e+1),o.primitiveLength+=3}b=!b}if(u){const t=this.layoutVertexExtArray,e=d.projectTilePoint(l.x,l.y,n),i=d.projectTilePoint(h.x,h.y,n),r=d.upVector(n,l.x,l.y),o=d.upVector(n,h.x,h.y);lf(t,e,r),lf(t,e,r),lf(t,i,o),lf(t,i,o)}}h&&(i+=s.length-1),m&&x&&this.zoom>=17&&(0!==_.length&&w(_,_[0])&&_.pop(),this.groundEffect.addData(_,e,l,x>0))}this.footprintSegments.push(a),s.triangleCount=this.indexArray.length-s.triangleArrayOffset,this.polygonSegments.push(s),++f.footprintSegLen,++f.polygonSegLen}if(f.vertexCount=this.layoutVertexArray.length-f.vertexArrayOffset,f.groundVertexCount=this.groundEffect.vertexArray.length-f.groundVertexArrayOffset,0!==f.vertexCount){if(f.centroidXY=p.borders?rf:this.encodeCentroid(p,f),this.centroidData.push(f),p.borders){this.featuresOnBorder.push(p);const t=this.featuresOnBorder.length-1;for(let e=0;ethis.featuresOnBorder[e].borders[t][0]-this.featuresOnBorder[i].borders[t][0]))}splitToSubtiles(){const t=[];for(let e=0;euo),r=2*n+(+(i.min.x+i.max.x>uo)^n);for(let n=0;nt.triangleSegmentIdx===e.triangleSegmentIdx?t.subtile-e.subtile:t.triangleSegmentIdx-e.triangleSegmentIdx));let i=0,n=0,r=0;for(const e of t){if(e.triangleSegmentIdx!==i)break;r++}const o=t.length;for(;n!==t.length;){i=t[n].triangleSegmentIdx;let s=0,a=n,l=n;for(let e=a;e0&&this.triangleSubSegments.push({segment:d,min:o,max:c}),a=l;for(let e=a;e[t[0]*(1-i[0])+e[0]*i[0],t[1]*(1-i[1])+e[1]*i[1]],h=[],p=[];for(const t of this.triangleSubSegments){h[0]=t.min.x/uo,h[1]=t.min.y/uo,p[0]=t.max.x/uo,p[1]=t.max.y/uo;const e=u(l,c,h),o=u(l,c,p);if(0===new wu([e[0],e[1],n],[o[0],o[1],r]).intersectsPrecise(i)){a&&(d.segments.push(a),a=void 0);continue}const s=t.segment;a&&a.vertexOffset!==s.vertexOffset&&(d.segments.push(a),a=void 0),a?(a.vertexLength+=s.vertexLength,a.primitiveLength+=s.primitiveLength):a={vertexOffset:s.vertexOffset,primitiveLength:s.primitiveLength,vertexLength:s.vertexLength,primitiveOffset:s.primitiveOffset,sortKey:void 0,vaos:{}}}return a&&d.segments.push(a),d}encodeCentroid(t,e){const i=t.centroid(),n=e.span(),r=Math.min(7,Math.round(n.x*this.tileToMeter/10)),o=Math.min(7,Math.round(n.y*this.tileToMeter/10));return new Ue(Xe(i.x,1,uo-1)i.max.x||i.min.x>e.max.x||e.min.y>i.max.y||i.min.y>e.max.y))for(let o=0;oe!=l>e&&to.max.x||o.min.x>t||e>o.max.y||o.min.y>e||this.footprintContainsPoint(t,e,o)&&o&&o.height>i&&(i=o.height,this.partLookup[r]=o,n=!!(o.flags&of));if(i!==Number.NEGATIVE_INFINITY)return{height:i,hidden:n};this.partLookup[r]=void 0}}function gf(t,e){const i=t.add(e)._unit();return t.x*i.x+t.y*i.y}function yf(t,e,i,n){const r=e.sub(t)._perp()._unit(),o=i.sub(e)._perp()._unit();return vf(t,e,i,gf(r,o),n)}function vf(t,e,i,n,r){const o=Math.sqrt(1-n*n);return Math.min(t.dist(e)/3,e.dist(i)/3,r*o/n)}function xf(t,e,i){return t.xi[1].x&&e.x>i[1].x||t.yi[1].y&&e.y>i[1].y}function bf(t,e){return t.xe[1].x||t.ye[1].y}function wf(t,e,i){if(t.x=uo||e.x=uo||i.x=uo)return!1;const n=i.sub(e),r=n.perp(),o=t.sub(e);return(n.x*o.x+n.y*o.y)/Math.sqrt((n.x*n.x+n.y*n.y)*(o.x*o.x+o.y*o.y))>-.866&&r.x*o.x+r.y*o.y{for(const i of t)s.push({polygon:i,bounds:e})},l=Math.ceil(Math.log2(i)),c=Math.ceil(Math.log2(n)),d=l-c,u=[];for(let t=0;t0?0:1);for(let t=0;te+1?p.push({polygons:h,bounds:t,depth:e+1}):a(h,t)}if(f.length){const t=[new Ue(0===i?d:n.x,1===i?d:n.y),s];u.length>e+1?p.push({polygons:f,bounds:t,depth:e+1}):a(f,t)}}return s}(t,e,Math.ceil((o-r)/11.25),Math.ceil((s-a)/11.25),1,((t,e,r)=>{if(0===t)return.5*(e+r);{const t=Id((i.y+e/uo)/n);return(Md(.5*(Id((i.y+r/uo)/n)+t))*n-i.y)*uo}}))}function Mf(t,e,i,n,r,o){const s=Math.pow(2,n.z-r.z);for(let a=0;a1&&(s=t[++o]);const l=Math.abs(a-s.left),c=Math.abs(a-s.right),d=Math.min(l,c);let u;const h=e/i*(n+1);if(s.isDash){const t=n-Math.abs(h);u=Math.sqrt(d*d+t*t)}else u=n-Math.sqrt(d*d+h*h);this.image.data[r+a]=Math.max(0,Math.min(255,u+128))}}}addRegularDash(t,e){for(let e=t.length-1;e>=0;--e){const i=t[e],n=t[e+1];i.zeroLength?t.splice(e,1):n&&n.isDash===i.isDash&&(n.left=i.left,t.splice(e,1))}const i=t[0],n=t[t.length-1];i.isDash===n.isDash&&(i.left=n.left-this.width,n.right=i.right+this.width);const r=this.width*this.nextRow;let o=0,s=t[o];for(let i=0;i1&&(s=t[++o]);const n=Math.abs(i-s.left),a=Math.abs(i-s.right),l=Math.min(n,a);this.image.data[r+i]=Math.max(0,Math.min(255,(s.isDash?l:-l)+e+128))}}addDash(t,e){const i=this.getKey(t,e);if(this.positions[i])return this.positions[i];const n="round"===e,r=n?7:0,o=2*r+1;if(this.nextRow+o>this.height)return pi("LineAtlas out of space"),null;0===t.length&&t.push(1);let s=0;for(let e=0;et.fqid)),this.index=t.index,this.projection=t.projection,this.hasPattern=!1,this.hasZOffset=!1,this.patternFeatures=[],this.lineClipsArray=[],this.gradients={},this.layers.forEach((t=>{this.gradients[t.id]={}})),this.layoutVertexArray=new Rl,this.layoutVertexArray2=new Ol,this.patternVertexArray=new Bl,this.indexArray=new Kl,this.programConfigurations=new Yc(t.layers,{zoom:t.zoom,lut:t.lut}),this.segments=new wc,this.maxLineLength=0,this.zOffsetVertexArray=new Zl,this.stateDependentLayerIds=this.layers.filter((t=>t.isStateDependent())).map((t=>t.id)),this.tessellationStep=t.tessellationStep?t.tessellationStep:uo/64}updateFootprints(t,e){}populate(t,e,i,n){this.hasPattern=Hh("line",this.layers,e);const r=this.layers[0].layout.get("line-sort-key"),o=this.layers[0].layout.get("line-z-offset");this.hasZOffset=!o.isConstant()||!!o.constantOr(0);const s=[];for(const{feature:e,id:o,index:a,sourceLayerIndex:l}of t){const t=this.layers[0]._featureFilter.needGeometry,c=Zd(e,t);if(!this.layers[0]._featureFilter.filter(new Ha(this.zoom),c,i))continue;const d=r?r.evaluate(c,{},i):void 0,u={id:o,properties:e.properties,type:e.type,sourceLayerIndex:l,index:a,geometry:t?c.geometry:Gd(e,i,n),patterns:{},sortKey:d};s.push(u)}r&&s.sort(((t,e)=>t.sortKey-e.sortKey));const{lineAtlas:a,featureIndex:l}=e,c=this.addConstantDashes(a);for(const n of s){const{geometry:r,index:o,sourceLayerIndex:s}=n;if(c&&this.addFeatureDashes(n,a),this.hasPattern){const t=Wh("line",this.layers,n,this.zoom,e);this.patternFeatures.push(t)}else this.addFeature(n,r,o,i,a.positions,e.availableImages,e.brightness);l.insert(t[o].feature,r,o,s,this.index)}}addConstantDashes(t){let e=!1;for(const i of this.layers){const n=i.paint.get("line-dasharray").value,r=i.layout.get("line-cap").value;if("constant"!==n.kind||"constant"!==r.kind)e=!0;else{const e=r.value,i=n.value;if(!i)continue;t.addDash(i,e)}}return e}addFeatureDashes(t,e){const i=this.zoom;for(const n of this.layers){const r=n.paint.get("line-dasharray").value,o=n.layout.get("line-cap").value;if("constant"===r.kind&&"constant"===o.kind)continue;let s,a;if("constant"===r.kind){if(s=r.value,!s)continue}else s=r.evaluate({zoom:i},t);a="constant"===o.kind?o.value:o.evaluate({zoom:i},t),e.addDash(s,a),t.patterns[n.id]=e.getKey(s,a)}}update(t,e,i,n,r){const o=0!==Object.keys(t).length;o&&!this.stateDependentLayers.length||this.programConfigurations.updatePaintArrays(t,e,o?this.stateDependentLayers:this.layers,i,n,r)}addFeatures(t,e,i,n,r,o){for(const t of this.patternFeatures)this.addFeature(t,t.geometry,t.index,e,i,n,o)}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(t){this.uploaded||(0!==this.layoutVertexArray2.length&&(this.layoutVertexBuffer2=t.createVertexBuffer(this.layoutVertexArray2,zf)),0!==this.patternVertexArray.length&&(this.patternVertexBuffer=t.createVertexBuffer(this.patternVertexArray,Of)),!this.zOffsetVertexBuffer&&this.zOffsetVertexArray.length>0&&(this.zOffsetVertexBuffer=t.createVertexBuffer(this.zOffsetVertexArray,jf.members,!0)),this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,kf),this.indexBuffer=t.createIndexBuffer(this.indexArray)),this.programConfigurations.upload(t),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.zOffsetVertexBuffer&&this.zOffsetVertexBuffer.destroy(),this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy())}lineFeatureClips(t){if(t.properties&&t.properties.hasOwnProperty("mapbox_clip_start")&&t.properties.hasOwnProperty("mapbox_clip_end"))return{start:+t.properties.mapbox_clip_start,end:+t.properties.mapbox_clip_end}}addFeature(t,e,i,n,r,o,s){const a=this.layers[0].layout,l=a.get("line-join").evaluate(t,{}),c=a.get("line-cap").evaluate(t,{}),d=a.get("line-miter-limit"),u=a.get("line-round-limit");this.lineClips=this.lineFeatureClips(t);for(const i of e)this.addLine(i,t,n,l,c,d,u);this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,t,i,r,o,n,s)}addLine(t,e,i,n,r,o,s){this.distance=0,this.scaledDistance=0,this.totalDistance=0,this.lineSoFar=0,this.currentVertex=void 0;const a={zoom:this.zoom,lineProgress:void 0},l=this.layers[0].layout,c="none"===n;if(this.patternJoinNone=this.hasPattern&&c,this.segmentStart=0,this.segmentStartf32=0,this.segmentPoints=[],this.lineClips){this.lineClipsArray.push(this.lineClips);for(let e=0;e=2&&t[u-1].equals(t[u-2]);)u--;let h=0;for(;h0;if(A&&i>h){const t=m.dist(_);if(t>2*p){const e=m.sub(m.sub(_)._mult(p/t)._round());this.updateDistance(_,e),this.addCurrentVertex(e,y,0,0,f,x),_=e}}if(b&&"round"===w&&(Mo&&(w="bevel"),"bevel"===w&&(M>2&&(w="flipbevel"),M100)S=v.mult(-1);else{const t=M*y.add(v).mag()/y.sub(v).mag();S._perp()._mult(t*(I?-1:1))}this.addCurrentVertex(m,S,0,0,f,x),this.addCurrentVertex(m,S.mult(-1),0,0,f,x)}else if("bevel"===w||"fakeround"===w){const t=-Math.sqrt(M*M-1),e=I?t:0,i=I?0:t;if(_&&this.addCurrentVertex(m,y,e,i,f,x),"fakeround"===w){const t=Math.round(180*C/Math.PI/20);for(let e=1;e2*p){const e=m.add(g.sub(m)._mult(p/t)._round());this.updateDistance(m,e),this.addCurrentVertex(e,v,0,0,f,x),m=e}}}}addVerticesTo(t,e,i,n,r,o,s,a,l,c){const d=(e.w-t.w)/this.tessellationStep|0;if(d>1){this.lineSoFar=t.w;const u=(e.x-t.x)/d,h=(e.y-t.y)/d,p=(e.z-t.z)/d,f=(e.w-t.w)/d;for(let e=1;e=0&&this.e2>=0&&(this.indexArray.emplaceBack(this.e1,this.e2,c),a.primitiveLength++),o?this.e2=c:this.e1=c,null!=l&&this.zOffsetVertexArray.emplaceBack(l)}updateScaledDistance(){if(this.lineClips){const t=this.totalDistance/(this.lineClips.end-this.lineClips.start);this.scaledDistance=this.distance/this.totalDistance,this.lineSoFar=t*this.lineClips.start+this.distance}else this.lineSoFar=this.distance}updateDistance(t,e){this.distance+=t.dist(e),this.updateScaledDistance()}}function Qf(t,e,i){return t.xi||t.yi}ba(Jf,"LineBucket",{omit:["layers","patternFeatures","currentVertex","currentVertexIsOutside"]});const tm=new ol({"line-cap":new nl(sl.layout_line["line-cap"]),"line-join":new nl(sl.layout_line["line-join"]),"line-miter-limit":new il(sl.layout_line["line-miter-limit"]),"line-round-limit":new il(sl.layout_line["line-round-limit"]),"line-sort-key":new nl(sl.layout_line["line-sort-key"]),"line-z-offset":new nl(sl.layout_line["line-z-offset"]),visibility:new il(sl.layout_line.visibility)});var em={paint:new ol({"line-opacity":new nl(sl.paint_line["line-opacity"]),"line-color":new nl(sl.paint_line["line-color"]),"line-translate":new il(sl.paint_line["line-translate"]),"line-translate-anchor":new il(sl.paint_line["line-translate-anchor"]),"line-width":new nl(sl.paint_line["line-width"]),"line-gap-width":new nl(sl.paint_line["line-gap-width"]),"line-offset":new nl(sl.paint_line["line-offset"]),"line-blur":new nl(sl.paint_line["line-blur"]),"line-dasharray":new nl(sl.paint_line["line-dasharray"]),"line-pattern":new nl(sl.paint_line["line-pattern"]),"line-gradient":new rl(sl.paint_line["line-gradient"]),"line-trim-offset":new il(sl.paint_line["line-trim-offset"]),"line-trim-fade-range":new il(sl.paint_line["line-trim-fade-range"]),"line-trim-color":new il(sl.paint_line["line-trim-color"]),"line-emissive-strength":new il(sl.paint_line["line-emissive-strength"]),"line-border-width":new nl(sl.paint_line["line-border-width"]),"line-border-color":new nl(sl.paint_line["line-border-color"]),"line-occlusion-opacity":new il(sl.paint_line["line-occlusion-opacity"])}),layout:tm};function im(t,e,i){return e*(uo/(t.tileSize*Math.pow(2,i-t.tileID.overscaledZ)))}function nm(t,e){return 1/im(t,1,e.tileZoom)}function rm(t,e,i,n){return t.translatePosMatrix(n||e.tileID.projMatrix,e,i.paint.get("line-translate"),i.paint.get("line-translate-anchor"))}const om=t=>{const e=[];sm(t)&&e.push("RENDER_LINE_DASH"),t.paint.get("line-gradient")&&e.push("RENDER_LINE_GRADIENT");const i=t.paint.get("line-trim-offset");0===i[0]&&0===i[1]||e.push("RENDER_LINE_TRIM_OFFSET"),0!==t.paint.get("line-border-width").constantOr(1)&&e.push("RENDER_LINE_BORDER");const n="none"===t.layout.get("line-join").constantOr("miter"),r=!!t.paint.get("line-pattern").constantOr(1);return n&&r&&e.push("LINE_JOIN_NONE"),e};function sm(t){const e=t.paint.get("line-dasharray").value;return e.value||"constant"!==e.kind}class am{constructor(t){this._stringToNumber={},this._numberToString=[];for(let e=0;e>1,d=-7,u=i?r-1:0,h=i?-1:1,p=t[e+u];for(u+=h,o=p&(1>=-d,d+=a;d>0;o=256*o+t[e+u],u+=h,d-=8);for(s=o&(1>=-d,d+=n;d>0;s=256*s+t[e+u],u+=h,d-=8);if(0===o)o=1-c;else{if(o===l)return s?NaN:1/0*(p?-1:1);s+=Math.pow(2,n),o-=c}return(p?-1:1)*s*Math.pow(2,o-n)},write:function(t,e,i,n,r,o){var s,a,l,c=8*o-r-1,d=(1>1,h=23===r?Math.pow(2,-24)-Math.pow(2,-77):0,p=n?0:o-1,f=n?1:-1,m=e=1?h/l:h*Math.pow(2,1-u))*l>=2&&(s++,l/=2),s+u>=d?(a=0,s=d):s+u>=1?(a=(e*l-1)*Math.pow(2,r),s+=u):(a=e*Math.pow(2,u-1)*Math.pow(2,r),s=0));r>=8;t[i+p]=255&a,p+=f,a/=256,r-=8);for(s=s0;t[i+p]=255&s,p+=f,s/=256,c-=8);t[i+p-f]|=128*m}},cm=um,dm=lm;function um(t){this.buf=ArrayBuffer.isView&&ArrayBuffer.isView(t)?t:new Uint8Array(t||0),this.pos=0,this.type=0,this.length=this.buf.length}um.Varint=0,um.Fixed64=1,um.Bytes=2,um.Fixed32=5;var hm=4294967296,pm=1/hm,fm="undefined"==typeof TextDecoder?null:new TextDecoder("utf8");function mm(t){return t.type===um.Bytes?t.readVarint()+t.pos:t.pos+1}function _m(t,e,i){return i?4294967296*e+(t>>>0):4294967296*(e>>>0)+(t>>>0)}function gm(t,e,i){var n=e=t;r--)i.buf[r+n]=i.buf[r]}function ym(t,e){for(var i=0;i>>8,t[i+2]=e>>>16,t[i+3]=e>>>24}function Im(t,e){return(t[e]|t[e+1]>3,o=this.pos;this.type=7&n,t(r,e,this),this.pos===o&&this.skip(n)}return e},readMessage:function(t,e){return this.readFields(t,e,this.readVarint()+this.pos)},readFixed32:function(){var t=Cm(this.buf,this.pos);return this.pos+=4,t},readSFixed32:function(){var t=Im(this.buf,this.pos);return this.pos+=4,t},readFixed64:function(){var t=Cm(this.buf,this.pos)+Cm(this.buf,this.pos+4)*hm;return this.pos+=8,t},readSFixed64:function(){var t=Cm(this.buf,this.pos)+Im(this.buf,this.pos+4)*hm;return this.pos+=8,t},readFloat:function(){var t=dm.read(this.buf,this.pos,!0,23,4);return this.pos+=4,t},readDouble:function(){var t=dm.read(this.buf,this.pos,!0,52,8);return this.pos+=8,t},readVarint:function(t){var e,i,n=this.buf;return e=127&(i=n[this.pos++]),i>4,r=12&&fm?function(t,e,i){return fm.decode(t.subarray(e,i))}(this.buf,e,t):function(t,e,i){for(var n="",r=e;r239?4:l>223?3:l>191?2:1;if(r+d>i)break;1===d?l=55296&&c=1114112)&&(c=null)),null===c?(c=65533,d=1):c>65535&&(c-=65536,n+=String.fromCharCode(c>>>10&1023|55296),c=56320|1023&c),n+=String.fromCharCode(c),r+=d}return n}(this.buf,e,t)},readBytes:function(){var t=this.readVarint()+this.pos,e=this.buf.subarray(this.pos,t);return this.pos=t,e},readPackedVarint:function(t,e){if(this.type!==um.Bytes)return t.push(this.readVarint(e));var i=mm(this);for(t=t||[];this.pos127;);else if(e===um.Bytes)this.pos=this.readVarint()+this.pos;else if(e===um.Fixed32)this.pos+=4;else{if(e!==um.Fixed64)throw new Error("Unimplemented type: "+e);this.pos+=8}},writeTag:function(t,e){this.writeVarint(t268435455||t=0?(i=t%4294967296|0,n=t/4294967296|0):(n=~(-t/4294967296),4294967295^(i=~(-t%4294967296))?i=i+1|0:(i=0,n=n+1|0)),t>=0x10000000000000000||t>>=7,i.buf[i.pos++]=127&t|128,t>>>=7,i.buf[i.pos++]=127&t|128,t>>>=7,i.buf[i.pos++]=127&t|128,i.buf[i.pos]=127&(t>>>=7)}(i,0,e),function(t,e){var i=(7&t)>>=3)?128:0),t&&(e.buf[e.pos++]=127&t|((t>>>=7)?128:0),t&&(e.buf[e.pos++]=127&t|((t>>>=7)?128:0),t&&(e.buf[e.pos++]=127&t|((t>>>=7)?128:0),t&&(e.buf[e.pos++]=127&t|((t>>>=7)?128:0),t&&(e.buf[e.pos++]=127&t)))))}(n,e)}(t,this):(this.realloc(4),this.buf[this.pos++]=127&t|(t>127?128:0),t>>=7)|(t>127?128:0),t>>=7)|(t>127?128:0),t>>7&127))))},writeSVarint:function(t){this.writeVarint(t55295&&n56319||o+1===e.length?(t[i++]=239,t[i++]=191,t[i++]=189):r=n;continue}if(n>6|192:(n>12|224:(t[i++]=n>>18|240,t[i++]=n>>12&63|128),t[i++]=n>>6&63|128),t[i++]=63&n|128)}return i}(this.buf,t,this.pos);var i=this.pos-e;i>=128&&gm(e,i,this),this.pos=e-1,this.writeVarint(i),this.pos+=i},writeFloat:function(t){this.realloc(4),dm.write(this.buf,t,this.pos,!0,23,4),this.pos+=4},writeDouble:function(t){this.realloc(8),dm.write(this.buf,t,this.pos,!0,52,8),this.pos+=8},writeBytes:function(t){var e=t.length;this.writeVarint(e),this.realloc(e);for(var i=0;i=128&&gm(i,n,this),this.pos=i-1,this.writeVarint(n),this.pos+=n},writeMessage:function(t,e,i){this.writeTag(t,um.Bytes),this.writeRawMessage(e,i)},writePackedVarint:function(t,e){e.length&&this.writeMessage(t,ym,e)},writePackedSVarint:function(t,e){e.length&&this.writeMessage(t,vm,e)},writePackedBoolean:function(t,e){e.length&&this.writeMessage(t,wm,e)},writePackedFloat:function(t,e){e.length&&this.writeMessage(t,xm,e)},writePackedDouble:function(t,e){e.length&&this.writeMessage(t,bm,e)},writePackedFixed32:function(t,e){e.length&&this.writeMessage(t,Tm,e)},writePackedSFixed32:function(t,e){e.length&&this.writeMessage(t,Sm,e)},writePackedFixed64:function(t,e){e.length&&this.writeMessage(t,Em,e)},writePackedSFixed64:function(t,e){e.length&&this.writeMessage(t,Mm,e)},writeBytesField:function(t,e){this.writeTag(t,um.Bytes),this.writeBytes(e)},writeFixed32Field:function(t,e){this.writeTag(t,um.Fixed32),this.writeFixed32(e)},writeSFixed32Field:function(t,e){this.writeTag(t,um.Fixed32),this.writeSFixed32(e)},writeFixed64Field:function(t,e){this.writeTag(t,um.Fixed64),this.writeFixed64(e)},writeSFixed64Field:function(t,e){this.writeTag(t,um.Fixed64),this.writeSFixed64(e)},writeVarintField:function(t,e){this.writeTag(t,um.Varint),this.writeVarint(e)},writeSVarintField:function(t,e){this.writeTag(t,um.Varint),this.writeSVarint(e)},writeStringField:function(t,e){this.writeTag(t,um.Bytes),this.writeString(e)},writeFloatField:function(t,e){this.writeTag(t,um.Fixed32),this.writeFloat(e)},writeDoubleField:function(t,e){this.writeTag(t,um.Fixed64),this.writeDouble(e)},writeBooleanField:function(t,e){this.writeVarintField(t,Boolean(e))}};var Lm=h(cm);const Pm=["id","tile","layer","source","sourceLayer","state"];class $m{constructor(t,e,i,n,r){this.type="Feature",this._vectorTileFeature=t,this._z=e,this._x=i,this._y=n,this.properties=t.properties,this.id=r}get geometry(){return void 0===this._geometry&&(this._geometry=this._vectorTileFeature.toGeoJSON(this._x,this._y,this._z).geometry),this._geometry}set geometry(t){this._geometry=t}toJSON(){const t={type:"Feature",state:void 0,geometry:this.geometry,properties:this.properties};for(const e of Pm)void 0!==this[e]&&(t[e]=this[e]);return t}}class km{constructor(){this.state={},this.stateChanges={},this.deletedStates={}}updateState(t,e,i){const n=String(e);if(this.stateChanges[t]=this.stateChanges[t]||{},this.stateChanges[t][n]=this.stateChanges[t][n]||{},ei(this.stateChanges[t][n],i),null===this.deletedStates[t]){this.deletedStates[t]={};for(const e in this.state[t])e!==n&&(this.deletedStates[t][e]=null)}else if(this.deletedStates[t]&&null===this.deletedStates[t][n]){this.deletedStates[t][n]={};for(const e in this.state[t][n])i[e]||(this.deletedStates[t][n][e]=null)}else for(const e in i)this.deletedStates[t]&&this.deletedStates[t][n]&&null===this.deletedStates[t][n][e]&&delete this.deletedStates[t][n][e]}removeFeatureState(t,e,i){if(null===this.deletedStates[t])return;const n=String(e);if(this.deletedStates[t]=this.deletedStates[t]||{},i&&void 0!==e)null!==this.deletedStates[t][n]&&(this.deletedStates[t][n]=this.deletedStates[t][n]||{},this.deletedStates[t][n][i]=null);else if(void 0!==e)if(this.stateChanges[t]&&this.stateChanges[t][n])for(i in this.deletedStates[t][n]={},this.stateChanges[t][n])this.deletedStates[t][n][i]=null;else this.deletedStates[t][n]=null;else this.deletedStates[t]=null}getState(t,e){const i=String(e),n=ei({},(this.state[t]||{})[i],(this.stateChanges[t]||{})[i]);if(null===this.deletedStates[t])return{};if(this.deletedStates[t]){const i=this.deletedStates[t][e];if(null===i)return{};for(const t in i)delete n[t]}return n}initializeTileState(t,e){t.setFeatureState(this.state,e)}coalesceChanges(t,e){const i={};for(const t in this.stateChanges){this.state[t]=this.state[t]||{};const e={};for(const i in this.stateChanges[t])this.state[t][i]||(this.state[t][i]={}),ei(this.state[t][i],this.stateChanges[t][i]),e[i]=this.state[t][i];i[t]=e}for(const t in this.deletedStates){this.state[t]=this.state[t]||{};const e={};if(null===this.deletedStates[t])for(const i in this.state[t])e[i]={},this.state[t][i]={};else for(const i in this.deletedStates[t]){if(null===this.deletedStates[t][i])this.state[t][i]={};else if(this.state[t][i])for(const e of Object.keys(this.deletedStates[t][i]))delete this.state[t][i][e];e[i]=this.state[t][i]}i[t]=i[t]||{},ei(i[t],e)}if(this.stateChanges={},this.deletedStates={},0!==Object.keys(i).length)for(const n in t)t[n].setFeatureState(i,e)}}class Dm{constructor(t,e){this.tileID=t,this.x=t.canonical.x,this.y=t.canonical.y,this.z=t.canonical.z,this.grid=new va(uo,16,0),this.featureIndexArray=new yc,this.promoteId=e,this.is3DTile=!1}insert(t,e,i,n,r,o=0,s=0){const a=this.featureIndexArray.length;this.featureIndexArray.emplaceBack(i,n,r,o);const l=this.grid;for(let t=0;t=0&&n[3]>=0&&l.insert(a,n[0],n[1],n[2],n[3])}}loadVTLayers(){if(!this.vtLayers){this.vtLayers=new bp(new Lm(this.rawTileData)).layers,this.sourceLayerCoder=new am(this.vtLayers?Object.keys(this.vtLayers).sort():["_geojsonTileLayer"]),this.vtFeatures={};for(const t in this.vtLayers)this.vtFeatures[t]=[]}return this.vtLayers}query(t,e,i,n){this.loadVTLayers();const r=t.params||{},o=dl(r.filter),s=t.tileResult,a=t.transform,l=s.bufferedTilespaceBounds,c=this.grid.query(l.min.x,l.min.y,l.max.x,l.max.y,((t,e,i,n)=>ou(s.bufferedTilespaceGeometry,t,e,i,n)));c.sort(Rm);let d=null;a.elevation&&c.length>0&&(d=Xp.create(a.elevation,this.tileID));const u={};let h;for(let l=0;l(m||(m=Gd(e,this.tileID.canonical,t.tileTransform)),i.queryIntersectsFeature(s,e,n,m,this.z,t.transform,t.pixelPosMatrix,d,r))))}return u}loadMatchingFeature(t,e,i,n,r,o,s,a,l){const{featureIndex:c,bucketIndex:d,sourceLayerIndex:u,layoutVertexArrayOffset:h}=e,p=this.bucketLayerIDs[d];if(n&&!function(t,e){for(let i=0;i=0)return!0;return!1}(n,p))return;const f=this.sourceLayerCoder.decode(u),m=this.vtLayers[f].feature(c);if(i.needGeometry){const t=Zd(m,!0);if(!i.filter(new Ha(this.tileID.overscaledZ),t,this.tileID.canonical))return}else if(!i.filter(new Ha(this.tileID.overscaledZ),m))return;const _=this.getId(m,f);for(let e=0;e{const s=e instanceof el?e.get(o):null;return s&&s.evaluate?s.evaluate(i,n,r):s}))}function Rm(t,e){return e-t}ba(Dm,"FeatureIndex",{omit:["rawTileData","sourceLayerCoder"]});var Om=24;const Bm=128;function Fm(t,e){const{expression:i}=e;if("constant"===i.kind)return{kind:"constant",layoutSize:i.evaluate(new Ha(t+1))};if("source"===i.kind)return{kind:"source"};{const{zoomStops:e,interpolationType:n}=i;let r=0;for(;r{t.text=function(t,e,i){const n=e.layout.get("text-transform").evaluate(i,{});return"uppercase"===n?t=t.toLocaleUpperCase():"lowercase"===n&&(t=t.toLocaleLowerCase()),qa.applyArabicShaping&&(t=qa.applyArabicShaping(t)),t}(t.text,e,i)})),t}const Gm={"!":"︕","#":"#",$:"$","%":"%","&":"&","(":"︵",")":"︶","*":"*","+":"+",",":"︐","-":"︲",".":"・","/":"/",":":"︓",";":"︔","":"﹀","?":"︖","@":"@","[":"﹇","\\":"\","]":"﹈","^":"^",_:"︳","`":"`","{":"︷","|":"―","}":"︸","~":"~","¢":"¢","£":"£","¥":"¥","¦":"¦","¬":"¬","¯":" ̄","–":"︲","—":"︱","‘":"﹃","’":"﹄","“":"﹁","”":"﹂","…":"︙","‧":"・","₩":"₩","、":"︑","。":"︒","〈":"︿","〉":"﹀","《":"︽","》":"︾","「":"﹁","」":"﹂","『":"﹃","』":"﹄","【":"︻","】":"︼","〔":"︹","〕":"︺","〖":"︗","〗":"︘","!":"︕","(":"︵",")":"︶",",":"︐","-":"︲",".":"・",":":"︓",";":"︔","<":"︿",">":"﹀","?":"︖","[":"﹇","]":"﹈","_":"︳","{":"︷","|":"―","}":"︸","⦅":"︵","⦆":"︶","。":"︒","「":"﹁","」":"﹂","←":"↑","→":"↓"};function Zm(t){return"︶"===t||"﹈"===t||"︸"===t||"﹄"===t||"﹂"===t||"︾"===t||"︼"===t||"︺"===t||"︘"===t||"﹀"===t||"︐"===t||"︓"===t||"︔"===t||"`"===t||" ̄"===t||"︑"===t||"︒"===t}function qm(t){return"︵"===t||"﹇"===t||"︷"===t||"﹃"===t||"﹁"===t||"︽"===t||"︻"===t||"︹"===t||"︗"===t||"︿"===t}const Hm=3;function Wm(t,e,i){e.glyphs=[],1===t&&i.readMessage(Ym,e)}function Ym(t,e,i){if(3===t){const{id:t,bitmap:n,width:r,height:o,left:s,top:a,advance:l}=i.readMessage(Xm,{});e.glyphs.push({id:t,bitmap:new dh({width:r+2*Hm,height:o+2*Hm},n),metrics:{width:r,height:o,left:s,top:a,advance:l}})}else 4===t?e.ascender=i.readSVarint():5===t&&(e.descender=i.readSVarint())}function Xm(t,e,i){1===t?e.id=i.readVarint():2===t?e.bitmap=i.readBytes():3===t?e.width=i.readVarint():4===t?e.height=i.readVarint():5===t?e.left=i.readSVarint():6===t?e.top=i.readSVarint():7===t&&(e.advance=i.readVarint())}const Km=Hm,Jm={horizontal:1,vertical:2,horizontalOnly:3};class Qm{constructor(){this.scale=1,this.fontStack="",this.imageName=null}static forText(t,e){const i=new Qm;return i.scale=t||1,i.fontStack=e,i}static forImage(t){const e=new Qm;return e.imageName=t,e}}class t_{constructor(){this.text="",this.sectionIndex=[],this.sections=[],this.imageSectionID=null}static fromFeature(t,e){const i=new t_;for(let n=0;n=0&&i>=t&&i_[this.text.charCodeAt(i)];i--)e--;this.text=this.text.substring(t,e),this.sectionIndex=this.sectionIndex.slice(t,e)}substring(t,e){const i=new t_;return i.text=this.text.substring(t,e),i.sectionIndex=this.sectionIndex.slice(t,e),i.sections=this.sections,i}toString(){return this.text}getMaxScale(){return this.sectionIndex.reduce(((t,e)=>Math.max(t,this.sections[e].scale)),0)}addTextSection(t,e){this.text+=t.text,this.sections.push(Qm.forText(t.scale,t.fontStack||e));const i=this.sections.length-1;for(let e=0;e=63743?null:++this.imageSectionID:(this.imageSectionID=57344,this.imageSectionID)}}function e_(t,e,i,n,r,o,s,a,l,c,d,u,h,p,f){const m=t_.fromFeature(t,r);u===Jm.vertical&&m.verticalizePunctuation(h);let _=[];const g=function(t,e,i,n,r,o){if(!t)return[];const s=[],a=function(t,e,i,n,r,o){let s=0;for(let i=0;i=0;let c=0;for(let i=0;i0&&o>b&&(b=o)}else{const t=i[a.fontStack];if(!t)continue;t[m]&&(S=t[m]);const n=e[a.fontStack];if(!n)continue;const o=n.glyphs[m];if(!o)continue;if(v=o.metrics,M=8203!==m?Om:0,_){const t=void 0!==n.ascender?Math.abs(n.ascender):0,e=void 0!==n.descender?Math.abs(n.descender):0,i=(t+e)*g;w-i/2;){if(s--,sn;)c-=l.shift().angleDelta;if(c>r)return!1;s++,a+=e.dist(i)}return!0}function m_(t){let e=0;for(let i=0;ic){const d=(c-l)/o,u=Vn(n.x,r.x,d),h=Vn(n.y,r.y,d),p=new p_(u,h,0,r.angleTo(n),i);return!s||f_(t,p,a,s,e)?p:void 0}l+=o}}function v_(t,e,i,n,r,o,s,a,l){const c=__(n,o,s),d=g_(n,r),u=d*s,h=0===t[0].x||t[0].x===l||0===t[0].y||t[0].y===l;return e-u=0&&g=0&&y=0&&h+c=n&&c.x>=n||(s.x>=n?s=new Ue(n,s.y+(n-s.x)/(c.x-s.x)*(c.y-s.y))._round():c.x>=n&&(c=new Ue(n,s.y+(n-s.x)/(c.x-s.x)*(c.y-s.y))._round()),s.y>=r&&c.y>=r||(s.y>=r?s=new Ue(s.x+(r-s.y)/(c.y-s.y)*(c.x-s.x),r)._round():c.y>=r&&(c=new Ue(s.x+(r-s.y)/(c.y-s.y)*(c.x-s.x),r)._round()),l&&s.equals(l[l.length-1])||(l=[s],o.push(l)),l.push(c)))))}}return o}function w_(t){let e=0,i=0;for(const n of t)e+=n.w*n.h,i=Math.max(i,n.w);t.sort(((t,e)=>e.h-t.h));const n=[{x:0,y:0,w:Math.max(Math.ceil(Math.sqrt(e/.95)),i),h:1/0}];let r=0,o=0;for(const e of t)for(let t=n.length-1;t>=0;t--){const i=n[t];if(!(e.w>i.w||e.h>i.h)){if(e.x=i.x,e.y=i.y,o=Math.max(o,e.y+e.h),r=Math.max(r,e.x+e.w),e.w===i.w&&e.h===i.h){const e=n.pop();tt.hasImage(e,i))),t.dispatchRenderCallbacks(this.haveRenderCallbacks,i);for(const n in t.getUpdatedImages(i))this.patchUpdatedImage(this.iconPositions[n],t.getImage(n,i),e),this.patchUpdatedImage(this.patternPositions[n],t.getImage(n,i),e)}patchUpdatedImage(t,e,i){if(!t||!e)return;if(t.version===e.version)return;t.version=e.version;const[n,r]=t.tl,o=!!Object.keys(this.patternPositions).length;i.update(e.data,{useMipmap:o},{x:n,y:r})}}ba(S_,"ImagePosition"),ba(E_,"ImageAtlas");const M_=1e20;function C_(t,e,i,n,r,o,s,a,l){for(let c=e;c-1);l++,o[l]=a,s[l]=c,s[l+1]=M_}for(let a=0,l=0;a{let n=this.entries[t];n||(n=this.entries[t]={glyphs:{},requests:{},ranges:{},ascender:void 0,descender:void 0});let r=n.glyphs[e];if(void 0!==r)return void i(null,{stack:t,id:e,glyph:r});if(r=this._tinySDF(n,t,e),r)return n.glyphs[e]=r,void i(null,{stack:t,id:e,glyph:r});const s=Math.floor(e/256);if(256*s>65535)return void i(new Error("glyphs > 65535 not supported"));if(n.ranges[s])return void i(null,{stack:t,id:e,glyph:r});let a=n.requests[s];a||(a=n.requests[s]=[],P_.loadGlyphRange(t,s,o,this.requestManager,((t,e)=>{if(e){n.ascender=e.ascender,n.descender=e.descender;for(const t in e.glyphs)this._doesCharSupportLocalGlyph(+t)||(n.glyphs[+t]=e.glyphs[+t]);n.ranges[s]=!0}for(const i of a)i(t,e);delete n.requests[s]}))),a.push(((n,r)=>{n?i(n):r&&i(null,{stack:t,id:e,glyph:r.glyphs[e]||null})}))}),((t,e)=>{if(t)i(t);else if(e){const t={};for(const{stack:i,id:n,glyph:r}of e)void 0===t[i]&&(t[i]={}),void 0===t[i].glyphs&&(t[i].glyphs={}),t[i].glyphs[n]=r&&{id:r.id,bitmap:r.bitmap.clone(),metrics:r.metrics},t[i].ascender=this.entries[i].ascender,t[i].descender=this.entries[i].descender;i(null,t)}}))}_doesCharSupportLocalGlyph(t){return this.localGlyphMode!==L_.none&&(this.localGlyphMode===L_.all?!!this.localFontFamily:!!this.localFontFamily&&(Ma["CJK Unified Ideographs"](t)||Ma["Hangul Syllables"](t)||Ma.Hiragana(t)||Ma.Katakana(t)||Ma["CJK Symbols and Punctuation"](t)||Ma["CJK Unified Ideographs Extension A"](t)||Ma["CJK Unified Ideographs Extension B"](t)))}_tinySDF(t,e,i){const n=this.localFontFamily;if(!n||!this._doesCharSupportLocalGlyph(i))return;let r=t.tinySDF;if(!r){let i="400";/bold/i.test(e)?i="900":/medium/i.test(e)?i="500":/light/i.test(e)&&(i="200"),r=t.tinySDF=new P_.TinySDF({fontFamily:n,fontWeight:i,fontSize:24*I_,buffer:3*I_,radius:8*I_}),r.fontWeight=i}if(this.localGlyphs[r.fontWeight][i])return this.localGlyphs[r.fontWeight][i];const o=String.fromCodePoint(i),{data:s,width:a,height:l,glyphWidth:c,glyphHeight:d,glyphLeft:u,glyphTop:h,glyphAdvance:p}=r.draw(o);return this.localGlyphs[r.fontWeight][i]={id:i,bitmap:new dh({width:a,height:l},s),metrics:{width:c/I_,height:d/I_,left:u/I_,top:h/I_-27,advance:p/I_,localGlyph:!0}}}}P_.loadGlyphRange=function(t,e,i,n,r){const o=256*e,s=o+255,a=n.transformRequest(n.normalizeGlyphsURL(i).replace("{fontstack}",t).replace("{range}",`${o}-${s}`),Ki.Glyphs);en(a,((t,e)=>{if(t)r(t);else if(e){const t={},i=function(t){return new Lm(t).readFields(Wm,{})}(e);for(const e of i.glyphs)t[e.id]=e;r(null,{glyphs:t,ascender:i.ascender,descender:i.descender})}}))},P_.TinySDF=class{constructor({fontSize:t=24,buffer:e=3,radius:i=8,cutoff:n=.25,fontFamily:r="sans-serif",fontWeight:o="normal",fontStyle:s="normal"}={}){this.buffer=e,this.cutoff=n,this.radius=i;const a=this.size=t+4*e,l=this._createCanvas(a),c=this.ctx=l.getContext("2d",{willReadFrequently:!0});c.font=`${s} ${o} ${t}px ${r}`,c.textBaseline="alphabetic",c.textAlign="left",c.fillStyle="black",this.gridOuter=new Float64Array(a*a),this.gridInner=new Float64Array(a*a),this.f=new Float64Array(a),this.z=new Float64Array(a+1),this.v=new Uint16Array(a)}_createCanvas(t){const e=document.createElement("canvas");return e.width=e.height=t,e}draw(t){const{width:e,actualBoundingBoxAscent:i,actualBoundingBoxDescent:n,actualBoundingBoxLeft:r,actualBoundingBoxRight:o}=this.ctx.measureText(t),s=Math.ceil(i),a=Math.max(0,Math.min(this.size-this.buffer,Math.ceil(o-r))),l=Math.min(this.size-this.buffer,s+Math.ceil(n)),c=a+2*this.buffer,d=l+2*this.buffer,u=Math.max(c*d,0),h=new Uint8ClampedArray(u),p={data:h,width:c,height:d,glyphWidth:a,glyphHeight:l,glyphTop:s,glyphLeft:0,glyphAdvance:e};if(0===a||0===l)return p;const{ctx:f,buffer:m,gridInner:_,gridOuter:g}=this;f.clearRect(m,m,a,l),f.fillText(t,m,m+s);const y=f.getImageData(m,m,a,l);g.fill(M_,0,u),_.fill(0,0,u);for(let t=0;t0?t*t:0,_[n]=tt+e[1]-e[0],f=u.reduce(p,0),m=h.reduce(p,0),_=a-f,g=l-m;let y=0,v=f,x=0,b=m,w=0,T=_,S=0,E=g;if(o.content&&n){const t=o.content;y=D_(u,0,t[0]),x=D_(h,0,t[1]),v=D_(u,t[0],t[2]),b=D_(h,t[1],t[3]),w=t[0]-y,S=t[1]-x,T=t[2]-t[0]-v,E=t[3]-t[1]-b}const M=(n,r,a,l)=>{const u=R_(n.stretch-y,v,c,t.left),h=O_(n.fixed-w,T,n.stretch,f),p=R_(r.stretch-x,b,d,t.top),_=O_(r.fixed-S,E,r.stretch,m),g=R_(a.stretch-y,v,c,t.left),M=O_(a.fixed-w,T,a.stretch,f),C=R_(l.stretch-x,b,d,t.top),A=O_(l.fixed-S,E,l.stretch,m),I=new Ue(u,p),L=new Ue(g,p),P=new Ue(g,C),$=new Ue(u,C),k=new Ue(h/s,_/s),D=new Ue(M/s,A/s),z=e*Math.PI/180;if(z){const t=Math.sin(z),e=Math.cos(z),i=[e,-t,t,e];I._matMult(i),L._matMult(i),$._matMult(i),P._matMult(i)}const R=n.stretch+n.fixed,O=a.stretch+a.fixed,B=r.stretch+r.fixed,F=l.stretch+l.fixed,N=t.imageSecondary;return{tl:I,tr:L,bl:$,br:P,texPrimary:{x:o.paddedRect.x+$_+R,y:o.paddedRect.y+$_+B,w:O-R,h:F-B},texSecondary:N?{x:N.paddedRect.x+$_+R,y:N.paddedRect.y+$_+B,w:O-R,h:F-B}:void 0,writingMode:void 0,glyphOffset:[0,0],sectionIndex:0,pixelOffsetTL:k,pixelOffsetBR:D,minFontScaleX:T/s/c,minFontScaleY:E/s/d,isSDF:i}};if(n&&(o.stretchX||o.stretchY)){const t=z_(u,_,f),e=z_(h,g,m);for(let i=0;io)&&(o=e.x),(!t||e.y>s)&&(s=e.y)}const l=Math.min(o-n,s-r);let c=l/2;const d=new co([],N_);if(0===l)return new Ue(n,r);for(let e=n;eu.d||!u.d)&&(u=n,i&&console.log("found best %d after %d probes",Math.round(1e4*n.d)/1e4,h)),n.max-u.dt.y!=a.y>t.y&&t.x18&&P>2&&(P>>=1),Math.max(uo/(512*P),1)*_.get("symbol-spacing")),S=_.get("text-padding")*t.tilePixelRatio,E=_.get("icon-padding")*t.tilePixelRatio,M=Ge(_.get("text-max-angle")),C="map"===_.get("text-rotation-alignment")&&"point"!==_.get("symbol-placement"),A="map"===_.get("icon-rotation-alignment")&&"point"!==_.get("symbol-placement"),I=_.get("symbol-placement"),L=T/2;var P;const $=_.get("icon-text-fit").evaluate(e,{},u),k=_.get("icon-text-fit-padding").evaluate(e,{},u),D="none"!==$;let z;!1===t.hasAnyIconTextFit&&D&&(t.hasAnyIconTextFit=!0),n&&D&&(t.allowVerticalPlacement&&i.vertical&&(z=h_(n,i.vertical,$,k,g,b)),y&&(n=h_(n,y,$,k,g,b)));const R=(s,a,m)=>{if(a.x=uo||a.y=uo)return;let _=null;if(v){const{x:t,y:e,z:i}=h.projectTilePoint(a.x,a.y,m);_={anchor:new p_(t,e,i,0,void 0),up:h.upVector(m,a.x,a.y)}}!function(t,e,i,n,r,o,s,a,l,c,d,u,h,p,f,m,_,g,y,v,x,b,w,T,S,E,M){const C=t.addToLineVertexArray(e,n);let A,I,L,P,$,k,D,z=0,R=0,O=0,B=0,F=-1,N=-1;const U={};let j=Ln("");const V=i?i.anchor:e,G="none"!==l.layout.get("icon-text-fit").evaluate(x,{},S);let Z=0,q=0;if(void 0===l._unevaluatedLayout.getValue("text-radial-offset")?[Z,q]=l.layout.get("text-offset").evaluate(x,{},S).map((t=>t*Om)):(Z=l.layout.get("text-radial-offset").evaluate(x,{},S)*Om,q=j_),t.allowVerticalPlacement&&r.vertical){const t=r.vertical;if(f)k=J_(t),a&&(D=J_(a));else{const i=l.layout.get("text-rotate").evaluate(x,{},S)+90;L=K_(c,V,e,d,u,h,t,p,i,m),a&&(P=K_(c,V,e,d,u,h,a,g,i))}}if(o){const n=l.layout.get("icon-rotate").evaluate(x,{},S),r=k_(o,n,w,G),s=a?k_(a,n,w,G):void 0;I=K_(c,V,e,d,u,h,o,g,n),z=4*r.length;const p=t.iconSizeData;let f=null;"source"===p.kind?(f=[Bm*l.layout.get("icon-size").evaluate(x,{},S)],f[0]>W_&&pi(`${t.layerIds[0]}: Value for "icon-size" is >= ${H_}. Reduce your "icon-size".`)):"composite"===p.kind&&(f=[Bm*b.compositeIconSizes[0].evaluate(x,{},S),Bm*b.compositeIconSizes[1].evaluate(x,{},S)],(f[0]>W_||f[1]>W_)&&pi(`${t.layerIds[0]}: Value for "icon-size" is >= ${H_}. Reduce your "icon-size".`)),t.addSymbols(t.icon,r,f,v,y,x,!1,i,e,C.lineStartIndex,C.lineLength,-1,T,S,E,M),F=t.icon.placedSymbolArray.length-1,s&&(R=4*s.length,t.addSymbols(t.icon,s,f,v,y,x,Jm.vertical,i,e,C.lineStartIndex,C.lineLength,-1,T,S,E,M),N=t.icon.placedSymbolArray.length-1)}for(const n in r.horizontal){const o=r.horizontal[n];A||(j=Ln(o.text),f?$=J_(o):A=K_(c,V,e,d,u,h,o,p,l.layout.get("text-rotate").evaluate(x,{},S),m));const a=1===o.positionedLines.length;if(O+=Y_(t,i,e,o,s,l,f,x,m,C,r.vertical?Jm.horizontal:Jm.horizontalOnly,a?Object.keys(r.horizontal):[n],U,F,b,T,S,E),a)break}r.vertical&&(B+=Y_(t,i,e,r.vertical,s,l,f,x,m,C,Jm.vertical,["vertical"],U,N,b,T,S,E));let H=-1;const W=(t,e)=>t?Math.max(t,e):e;H=W($,H),H=W(k,H),H=W(D,H);const Y=H>-1?1:0;t.glyphOffsetArray.length>=65535&&pi("Too many glyphs being rendered in a tile. See https://github.com/mapbox/mapbox-gl-js/issues/2907"),void 0!==x.sortKey&&t.addToSortKeyRanges(t.symbolInstances.length,x.sortKey),t.symbolInstances.emplaceBack(e.x,e.y,V.x,V.y,V.z,U.right>=0?U.right:-1,U.center>=0?U.center:-1,U.left>=0?U.left:-1,U.vertical>=0?U.vertical:-1,F,N,j,void 0!==A?A:t.collisionBoxArray.length,void 0!==A?A+1:t.collisionBoxArray.length,void 0!==L?L:t.collisionBoxArray.length,void 0!==L?L+1:t.collisionBoxArray.length,void 0!==I?I:t.collisionBoxArray.length,void 0!==I?I+1:t.collisionBoxArray.length,P||t.collisionBoxArray.length,P?P+1:t.collisionBoxArray.length,d,O,B,z,R,Y,0,Z,q,H,0,1,1,G?1:0)}(t,a,_,s,i,n,r,z,t.layers[0],t.collisionBoxArray,e.index,e.sourceLayerIndex,t.index,S,C,l,0,E,A,g,e,o,c,d,u,p,f)};if("line"===I)for(const r of b_(e.geometry,0,0,uo,uo)){const e=v_(r,T,M,i.vertical||y,n,x,w,t.overscaling,uo);for(const i of e)y&&Q_(t,y.text,L,i)||R(r,i,u)}else if("line-center"===I){for(const t of e.geometry)if(t.length>1){const e=y_(t,M,i.vertical||y,n,x,w);e&&R(t,e,u)}}else if("Polygon"===e.type)for(const t of Zh(e.geometry,0)){const e=F_(t,16);R(t[0],new p_(e.x,e.y,0,0,void 0),u)}else if("LineString"===e.type)for(const t of e.geometry)R(t,new p_(t[0].x,t[0].y,0,0,void 0),u);else if("Point"===e.type)for(const t of e.geometry)for(const e of t)R([e],new p_(e.x,e.y,0,0,void 0),u)}const H_=255,W_=H_*Bm;function Y_(t,e,i,n,r,o,s,a,l,c,d,u,h,p,f,m,_,g){const y=function(t,e,i,n,r,o,s,a){const l=[];if(0===e.positionedLines.length)return l;const c=n.layout.get("text-rotate").evaluate(o,{})*Math.PI/180,d=function(t){const e=t[0],i=t[1],n=e*i;return n>0?[e,-i]:nW_&&pi(`${t.layerIds[0]}: Value for "text-size" is >= ${H_}. Reduce your "text-size".`)):"composite"===v.kind&&(x=[Bm*f.compositeTextSizes[0].evaluate(a,{},_),Bm*f.compositeTextSizes[1].evaluate(a,{},_)],(x[0]>W_||x[1]>W_)&&pi(`${t.layerIds[0]}: Value for "text-size" is >= ${H_}. Reduce your "text-size".`)),t.addSymbols(t.text,y,x,l,s,a,d,e,i,c.lineStartIndex,c.lineLength,p,m,_,g,!1);for(const e of u)h[e]=t.text.placedSymbolArray.length-1;return 4*y.length}function X_(t){for(const e in t)return t[e];return null}function K_(t,e,i,n,r,o,s,a,l,c){let d=s.top,u=s.bottom,h=s.left,p=s.right;const f=s.collisionPadding;if(f&&(h-=f[0],d-=f[1],p+=f[2],u+=f[3]),l){const t=new Ue(h,d),e=new Ue(p,d),i=new Ue(h,u),n=new Ue(p,u),r=Ge(l);let o=new Ue(0,0);c&&(o=new Ue(c[0],c[1])),t._rotateAround(r,o),e._rotateAround(r,o),i._rotateAround(r,o),n._rotateAround(r,o),h=Math.min(t.x,e.x,i.x,n.x),p=Math.max(t.x,e.x,i.x,n.x),d=Math.min(t.y,e.y,i.y,n.y),u=Math.max(t.y,e.y,i.y,n.y)}return t.emplaceBack(e.x,e.y,e.z,i.x,i.y,h,d,p,u,a,n,r,o),t.length-1}function J_(t){t.collisionPadding&&(t.top-=t.collisionPadding[1],t.bottom+=t.collisionPadding[3]);const e=t.bottom-t.top;return e>0?Math.max(10,e):null}function Q_(t,e,i,n){const r=t.compareText;if(e in r){const t=r[e];for(let e=t.length-1;e>=0;e--)if(n.dist(t[e])v&&(x(t,c,n,r,a,l),x(c,i,a,l,o,s))}x(u,h,n,o,r,o),x(h,p,r,o,r,s),x(p,f,r,s,n,s),x(f,u,n,s,n,o),m-=v,_-=v,g+=v,y+=v;const b=1/Math.max(g-m,y-_);return{scale:b,x:m*b,y:_*b,x2:g*b,y2:y*b,projection:e}}function ig(t,{x:e,y:i},n=0){return new Ue(((e-n)*t.scale-t.x)*uo,(i*t.scale-t.y)*uo)}const ng=t.ad.identity(new Float32Array(16));class rg{constructor(t){this.spec=t,this.name=t.name,this.wrap=!1,this.requiresDraping=!1,this.supportsWorldCopies=!1,this.supportsTerrain=!1,this.supportsFog=!1,this.supportsFreeCamera=!1,this.zAxisUnit="meters",this.isReprojectedInTileSpace=!0,this.unsupportedLayers=["custom"],this.center=[0,0],this.range=[3.5,7]}project(t,e){return{x:0,y:0,z:0}}unproject(t,e){return new pd(0,0)}projectTilePoint(t,e,i){return{x:t,y:e,z:0}}locationPoint(t,e,i=!0){return t._coordinatePoint(t.locationCoordinate(e),i)}pixelsPerMeter(t,e){return Cd(1,t)*e}pixelSpaceConversion(t,e,i){return 1}farthestPixelDistance(t){return tg(t,t.pixelsPerMeter)}pointCoordinate(t,e,i,n){const r=t.horizonLineFromTop(!1),o=new Ue(e,Math.max(r,i));return t.rayIntersectionCoordinate(t.pointRayIntersection(o,n))}pointCoordinate3D(t,e,i){const n=new Ue(e,i);if(t.elevation)return t.elevation.pointCoordinate(n);{const e=this.pointCoordinate(t,n.x,n.y,0);return[e.x,e.y,e.z]}}isPointAboveHorizon(t,e){if(t.elevation&&t.elevation.visibleDemTiles.length)return!this.pointCoordinate3D(t,e.x,e.y);const i=t.horizonLineFromTop();return e.y0?epg-i&&(e=pg-i);const o=r/Math.pow(fg(e),n);let s=o*Math.sin(n*t),a=r-o*Math.cos(n*t);return s=.5*(s/Math.PI+.5),a=.5*(a/Math.PI+.5),{x:s,y:this.southernCenter?a:1-a,z:0}}unproject(t,e){t=(2*t-.5)*Math.PI,this.southernCenter&&(e=1-e),e=(2*(1-e)-.5)*Math.PI;const{n:i,f:n}=this,r=n-e,o=Math.sign(r),s=Math.sign(i)*Math.sqrt(t*t+r*r);let a=Math.atan2(t,Math.abs(r))*o;r*i1e-6&&--n>0);o=i*i;const s=Xe(Ze(t/(.8707+o*(o*(o*o*o*(.003971-.001529*o)-.013791)-.131979))),-180,180),a=Ze(i);return new pd(s,a)}}const vg=Ge(Pd);class xg extends rg{project(t,e){e=Ge(e),t=Ge(t);const i=Math.cos(e),n=2/Math.PI,r=Math.acos(i*Math.cos(t/2)),o=Math.sin(r)/r,s=.5*(t*n+2*i*Math.sin(t/2)/o)||0,a=.5*(e+Math.sin(e)/o)||0;return{x:.5*(s/Math.PI+.5),y:1-.5*(a/Math.PI+1),z:0}}unproject(t,e){let i=t=(2*t-.5)*Math.PI,n=e=(2*(1-e)-1)*Math.PI,r=25;const o=1e-6;let s=0,a=0;do{const r=Math.cos(n),o=Math.sin(n),l=2*o*r,c=o*o,d=r*r,u=Math.cos(i/2),h=Math.sin(i/2),p=2*u*h,f=h*h,m=1-d*u*u,_=m?1/m:0,g=m?Math.acos(r*u)*Math.sqrt(1/m):0,y=.5*(2*g*r*h+2*i/Math.PI)-t,v=.5*(g*o+n)-e,x=.5*_*(d*f+g*r*u*c)+1/Math.PI,b=_*(p*l/4-g*o*h),w=.125*_*(l*h-g*o*d*p),T=.5*_*(c*u+g*f*r)+.5,S=b*w-T*x;s=(v*b-y*T)/S,a=(y*w-v*x)/S,i=Xe(i-s,-Math.PI,Math.PI),n=Xe(n-a,-vg,vg)}while((Math.abs(s)>o||Math.abs(a)>o)&&--r>0);return new pd(Ze(i),Ze(n))}}class bg extends rg{constructor(t){super(t),this.center=t.center||[0,0],this.parallels=t.parallels||[0,0],this.cosPhi=Math.max(.01,Math.cos(Ge(this.parallels[0]))),this.scale=1/(2*Math.max(Math.PI*this.cosPhi,1/this.cosPhi)),this.wrap=!0,this.supportsWorldCopies=!0}project(t,e){const{scale:i,cosPhi:n}=this;return{x:Ge(t)*n*i+.5,y:-Math.sin(Ge(e))/n*i+.5,z:0}}unproject(t,e){const{scale:i,cosPhi:n}=this,r=-(e-.5)/i,o=Xe(Ze((t-.5)/i)/n,-180,180),s=Math.asin(Xe(r*n,-1,1)),a=Xe(Ze(s),-Pd,Pd);return new pd(o,a)}}class wg extends _g{constructor(t){super(t),this.requiresDraping=!0,this.supportsWorldCopies=!1,this.supportsFog=!0,this.zAxisUnit="pixels",this.unsupportedLayers=["debug"],this.range=[3,5]}projectTilePoint(e,i,n){const r=Fu(e,i,n),o=ju($u(n));return t._.transformMat4(r,r,o),{x:r[0],y:r[1],z:r[2]}}locationPoint(e,i){const n=dd(i.lat,i.lng),r=t._.normalize([],n),o=e.elevation?e.elevation.getAtPointOrZero(e.locationCoordinate(i),e._centerAltitude):e._centerAltitude,s=Cd(1,0)*uo*o;t._.scaleAndAdd(n,n,r,s);const a=t.ad.identity(new Float64Array(16));return t.ad.multiply(a,e.pixelMatrix,e.globeMatrix),t._.transformMat4(n,n,a),new Ue(n[0],n[1])}pixelsPerMeter(t,e){return Cd(1,0)*e}pixelSpaceConversion(t,e,i){const n=Cd(1,t)*e,r=Vn(Cd(1,45)*e,n,i);return this.pixelsPerMeter(t,e)/r}createTileMatrix(e,i,n){const r=Vu($u(n.canonical));return t.ad.multiply(new Float64Array(16),e.globeMatrix,r)}createInversionMatrix(e,i){const{center:n}=e,r=ju($u(i));return t.ad.rotateY(r,r,Ge(n.lng)),t.ad.rotateX(r,r,Ge(n.lat)),t.ad.scale(r,r,[e._pixelsPerMercatorPixel,e._pixelsPerMercatorPixel,1]),Float32Array.from(r)}pointCoordinate(t,e,i,n){return Iu(t,e,i,!0)||new Rd(0,0)}pointCoordinate3D(t,e,i){const n=this.pointCoordinate(t,e,i,0);return[n.x,n.y,n.z]}isPointAboveHorizon(t,e){return!Iu(t,e.x,e.y,!1)}farthestPixelDistance(e){const i=function(e,i){const n=e.cameraToCenterDistance,r=e._centerAltitude*i,o=e._camera,s=e._camera.forward(),a=t._.add([],t._.scale([],s,-n),[0,0,r]),l=e.worldSize/(2*Math.PI),c=[0,0,-l],d=e.width/e.height,u=Math.tan(e.fovAboveCenter),h=t._.scale([],o.up(),u),p=t._.scale([],o.right(),u*d),f=t._.normalize([],t._.add([],t._.add([],s,h),p)),m=[];let _;if(new mu(a,f).closestPointOnSphere(c,l,m)){const i=t._.add([],m,c),n=t._.sub([],i,a);_=Math.cos(e.fovAboveCenter)*t._.length(n)}else{const e=t._.sub([],a,c),i=t._.sub([],c,a);t._.normalize(i,i);const n=t._.length(e)-l;_=Math.sqrt(n*(n+2*l));const r=Math.acos(_/(l+n))-Math.acos(t._.dot(s,i));_*=Math.cos(r)}return 1.01*_}(e,this.pixelsPerMeter(e.center.lat,e.worldSize)),n=Hu(e.zoom);if(n>0){const t=tg(e,Cd(1,e.center.lat)*e.worldSize),r=e.worldSize/(2*Math.PI),o=Math.max(e.width,e.height)/e.worldSize*Math.PI;return Vn(i,t+r*(1-Math.cos(o)),Math.pow(n,10))}return i}upVector(t,e,i){return Fu(e,i,t,1)}upVectorScale(t){return{metersToTile:Cu(Nu($u(t)))}}}function Tg(t){const e=t.parallels,i=!!e&&Math.abs(e[0]+e[1])0&&(this.iconTransitioningVertexBuffer=t.createVertexBuffer(this.iconTransitioningVertexArray,Vf.members,!0)),this.globeExtVertexArray.length>0&&(this.globeExtVertexBuffer=t.createVertexBuffer(this.globeExtVertexArray,Ff.members,!0)),!this.zOffsetVertexBuffer&&(this.zOffsetVertexArray.length>0||r)&&(this.zOffsetVertexBuffer=t.createVertexBuffer(this.zOffsetVertexArray,jf.members,!0)),this.opacityVertexBuffer.itemSize=1),(i||n)&&this.programConfigurations.upload(t))}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy(),this.dynamicLayoutVertexBuffer.destroy(),this.opacityVertexBuffer.destroy(),this.occlusionQueryOpacityVertexBuffer.destroy(),this.iconTransitioningVertexBuffer&&this.iconTransitioningVertexBuffer.destroy(),this.globeExtVertexBuffer&&this.globeExtVertexBuffer.destroy(),this.zOffsetVertexBuffer&&this.zOffsetVertexBuffer.destroy())}}ba(Ng,"SymbolBuffers");class Ug{constructor(t,e,i){this.layoutVertexArray=new t,this.layoutAttributes=e,this.indexArray=new i,this.segments=new wc,this.collisionVertexArray=new Xl,this.collisionVertexArrayExt=new Ol}upload(t){this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,this.layoutAttributes),this.indexBuffer=t.createIndexBuffer(this.indexArray),this.collisionVertexBuffer=t.createVertexBuffer(this.collisionVertexArray,Gf.members,!0),this.collisionVertexBufferExt=t.createVertexBuffer(this.collisionVertexArrayExt,Zf.members,!0)}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.segments.destroy(),this.collisionVertexBuffer.destroy(),this.collisionVertexBufferExt.destroy())}}ba(Ug,"CollisionBuffers");class jg{constructor(e){this.queries=new Map,this.collisionBoxArray=e.collisionBoxArray,this.zoom=e.zoom,this.lut=e.lut,this.overscaling=e.overscaling,this.layers=e.layers,this.layerIds=this.layers.map((t=>t.fqid)),this.index=e.index,this.pixelRatio=e.pixelRatio,this.sourceLayerIndex=e.sourceLayerIndex,this.hasPattern=!1,this.hasRTLText=!1,this.fullyClipped=!1,this.hasAnyIconTextFit=!1,this.sortKeyRanges=[],this.collisionCircleArray=[],this.placementInvProjMatrix=t.ad.identity([]),this.placementViewportMatrix=t.ad.identity([]);const i=this.layers[0]._unevaluatedLayout._values;this.textSizeData=Fm(this.zoom,i["text-size"]),this.iconSizeData=Fm(this.zoom,i["icon-size"]);const n=this.layers[0].layout,r=n.get("symbol-sort-key"),o=n.get("symbol-z-order");this.canOverlap=n.get("text-allow-overlap")||n.get("icon-allow-overlap")||n.get("text-ignore-placement")||n.get("icon-ignore-placement"),this.sortFeaturesByKey="viewport-y"!==o&&void 0!==r.constantOr(1),this.sortFeaturesByY=("viewport-y"===o||"auto"===o&&!this.sortFeaturesByKey)&&this.canOverlap,this.writingModes=n.get("text-writing-mode").map((t=>Jm[t])),this.stateDependentLayerIds=this.layers.filter((t=>t.isStateDependent())).map((t=>t.id)),this.sourceID=e.sourceID,this.projection=e.projection,this.hasAnyZOffset=!1,this.zOffsetSortDirty=!1,this.zOffsetBuffersNeedUpload=n.get("symbol-z-elevate"),this.activeReplacements=[],this.replacementUpdateTime=0}createArrays(){this.text=new Ng(new Yc(this.layers,{zoom:this.zoom,lut:this.lut},(t=>/^text/.test(t)))),this.icon=new Ng(new Yc(this.layers,{zoom:this.zoom,lut:this.lut},(t=>/^icon/.test(t)))),this.glyphOffsetArray=new mc,this.lineVertexArray=new _c,this.symbolInstances=new fc}calculateGlyphDependencies(t,e,i,n,r){for(let i=0;i0)&&("constant"!==l.value.kind||l.value.value.length>0),h="constant"!==d.value.kind||!!d.value.value||Object.keys(d.parameters).length>0,p=s.get("symbol-sort-key");if(this.features=[],!u&&!h)return;const f=i.iconDependencies,m=i.glyphDependencies,_=i.availableImages,g=new Ha(this.zoom);for(const{feature:i,id:c,index:d,sourceLayerIndex:y}of e){const e=o._featureFilter.needGeometry,v=Zd(i,e);if(!o._featureFilter.filter(g,v,n))continue;if(e||(v.geometry=Gd(i,n,r)),a&&1!==i.type&&n.z{const o=Fu(e.x,e.y,n,1),s=Fu(r.x,r.y,n,1);return t._.dot(o,s)=0;for(const i of x.sections)if(i.image)f[i.image.namePrimary]=!0;else{const n=Ca(x.toString()),r=i.fontStack||t,o=m[r]=m[r]||{};this.calculateGlyphDependencies(i.text,o,e,this.allowVerticalPlacement,n)}}}"line"===s.get("symbol-placement")&&(this.features=function(t){const e={},i={},n=[];let r=0;function o(e){n.push(t[e]),r++}function s(t,e,r){const o=i[t];return delete i[t],i[e]=o,n[o].geometry[0].pop(),n[o].geometry[0]=n[o].geometry[0].concat(r[0]),o}function a(t,i,r){const o=e[i];return delete e[i],e[t]=o,n[o].geometry[0].shift(),n[o].geometry[0]=r[0].concat(n[o].geometry[0]),o}function l(t,e,i){const n=i?e[0][e[0].length-1]:e[0][0];return`${t}:${n.x}:${n.y}`}for(let c=0;ct.geometry))}(this.features)),this.sortFeaturesByKey&&this.features.sort(((t,e)=>t.sortKey-e.sortKey))}update(t,e,i,n,r){const o=0!==Object.keys(t).length;if(o&&!this.stateDependentLayers.length)return;const s=o?this.stateDependentLayers:this.layers;this.text.programConfigurations.updatePaintArrays(t,e,s,i,n,r),this.icon.programConfigurations.updatePaintArrays(t,e,s,i,n,r)}updateOcclusionOpacities(t,e,i){if(!e.useOcclusionQueries)return!1;const n=this;if("globe"===n.projection.name)return!1;let r=!1;n.hasTextData()&&(r=r||0!==n.text.occlusionQueryOpacityVertexArray.length),n.hasIconData()&&(r=r||0!==n.icon.occlusionQueryOpacityVertexArray.length);const o=n.layers[0].paint,s=o.get("icon-occlusion-opacity").constantOr(0),a=o.get("text-occlusion-opacity").constantOr(0);if(!n.layers[0].hasInitialOcclusionOpacityProperties||1===s&&1===a)return!1;let l=!r;for(let t=0;t.5?1:-1)*e.fadeSpeed*i*.001,r.occlusionOpacity=Xe(r.occlusionOpacity,0,1),l=l||r.occlusionOpacity!==o}if(!l)return!1;let c=0,d=0;const u=(t,e,i,n)=>{let r=0,o=0;i?(r=d,d+=n,o=d):(r=c,c+=n,o=c),o>e.occlusionQueryOpacityVertexArray.length&&e.occlusionQueryOpacityVertexArray.resize(o);const s=t.occlusionOpacity;for(let t=0;t0;if((i>0||r>0)&&(u(e,n.text,!1,i),u(e,n.text,!1,r)),s){const{placedIconSymbolIndex:t,verticalPlacedIconSymbolIndex:i}=e;t>=0&&u(e,n.icon,!0,o),i>=0&&u(e,n.icon,!0,e.numVerticalIconVertices)}}return n.hasTextData()&&n.text.occlusionQueryOpacityVertexBuffer&&(n.text.occlusionQueryOpacityVertexBuffer.length{i+=e,i>t.length&&t.resize(i);for(let r=-e;r{n+=e,n>t.length&&t.resize(n);for(let r=-e;r0;if((r>0||o>0)&&(t(this.text.zOffsetVertexArray,r,a),t(this.text.zOffsetVertexArray,o,a)),l){const{placedIconSymbolIndex:t,verticalPlacedIconSymbolIndex:i}=n;t>=0&&e(this.icon.zOffsetVertexArray,s,a),i>=0&&e(this.icon.zOffsetVertexArray,n.numVerticalIconVertices,a)}}this.text.zOffsetVertexBuffer&&this.text.zOffsetVertexBuffer.updateData(this.text.zOffsetVertexArray),this.icon.zOffsetVertexBuffer&&this.icon.zOffsetVertexBuffer.updateData(this.icon.zOffsetVertexArray)}isEmpty(){return 0===this.symbolInstances.length&&!this.hasRTLText}uploadPending(){return!this.uploaded||this.text.programConfigurations.needsUpload||this.icon.programConfigurations.needsUpload}upload(t){!this.uploaded&&this.hasDebugData()&&(this.textCollisionBox.upload(t),this.iconCollisionBox.upload(t)),this.text.upload(t,this.sortFeaturesByY,!this.uploaded,this.text.programConfigurations.needsUpload,this.zOffsetBuffersNeedUpload),this.icon.upload(t,this.sortFeaturesByY,!this.uploaded,this.icon.programConfigurations.needsUpload,this.zOffsetBuffersNeedUpload),this.uploaded=!0}destroyDebugData(){this.textCollisionBox.destroy(),this.iconCollisionBox.destroy()}getProjection(){return this.projectionInstance||(this.projectionInstance=Tg(this.projection)),this.projectionInstance}destroy(){this.text.destroy(),this.icon.destroy(),this.hasDebugData()&&this.destroyDebugData();for(const t of this.queries.values())t.destroy()}addToLineVertexArray(t,e){const i=this.lineVertexArray.length;if(void 0!==t.segment)for(const{x:t,y:i}of e)this.lineVertexArray.emplaceBack(t,i);return{lineStartIndex:i,lineLength:this.lineVertexArray.length-i}}addSymbols(t,e,i,n,r,o,s,a,l,c,d,u,h,p,f,m){const _=t.indexArray,g=t.layoutVertexArray,y=t.globeExtVertexArray,v=t.segments.prepareSegment(4*e.length,g,_,this.canOverlap?o.sortKey:void 0),x=this.glyphOffsetArray.length,b=v.vertexLength,w=this.allowVerticalPlacement&&s===Jm.vertical?Math.PI/2:0,T=o.text&&o.text.sections;for(let n=0;n=0?e.rightJustifiedTextSymbolIndex:e.centerJustifiedTextSymbolIndex>=0?e.centerJustifiedTextSymbolIndex:e.leftJustifiedTextSymbolIndex>=0?e.leftJustifiedTextSymbolIndex:e.verticalPlacedTextSymbolIndex>=0?e.verticalPlacedTextSymbolIndex:n),o=Nm(this.textSizeData,t,r)/Om;return this.tilePixelRatio*o}getSymbolInstanceIconSize(t,e,i){const n=this.icon.placedSymbolArray.get(i),r=Nm(this.iconSizeData,t,n);return this.tilePixelRatio*r}_commitDebugCollisionVertexUpdate(t,e,i,n){t.emplaceBack(e,-i,-i,n),t.emplaceBack(e,i,-i,n),t.emplaceBack(e,i,i,n),t.emplaceBack(e,-i,i,n)}_updateTextDebugCollisionBoxes(t,e,i,n,r,o){for(let s=n;s0}hasIconData(){return this.icon.segments.get().length>0}hasDebugData(){return this.textCollisionBox&&this.iconCollisionBox}hasTextCollisionBoxData(){return this.hasDebugData()&&this.textCollisionBox.segments.get().length>0}hasIconCollisionBoxData(){return this.hasDebugData()&&this.iconCollisionBox.segments.get().length>0}hasIconTextFit(){return this.hasAnyIconTextFit}addIndicesForPlacedSymbol(t,e){const i=t.placedSymbolArray.get(e),n=i.vertexStartIndex+4*i.numGlyphs;for(let e=i.vertexStartIndex;en[t]-n[e]||r[e]-r[t])),o}getSortedIndexesByZOffset(){if(!this.zOffsetSortDirty)return this.symbolInstanceIndexesSortedZOffset;if(!this.symbolInstanceIndexesSortedZOffset){this.symbolInstanceIndexesSortedZOffset=[];for(let t=0;tthis.symbolInstances.get(e).zOffset-this.symbolInstances.get(t).zOffset))}addToSortKeyRanges(t,e){const i=this.sortKeyRanges[this.sortKeyRanges.length-1];i&&i.sortKey===e?i.symbolInstanceEnd=t+1:this.sortKeyRanges.push({sortKey:e,symbolInstanceStart:t,symbolInstanceEnd:t+1})}sortFeatures(t){if(this.sortFeaturesByY&&this.sortedAngle!==t&&!(this.text.segments.get().length>1||this.icon.segments.get().length>1)){this.symbolInstanceIndexes=this.getSortedSymbolIndexes(t),this.sortedAngle=t,this.text.indexArray.clear(),this.icon.indexArray.clear(),this.featureSortOrder=[];for(const t of this.symbolInstanceIndexes){const e=this.symbolInstances.get(t);this.featureSortOrder.push(e.featureIndex);const{rightJustifiedTextSymbolIndex:i,centerJustifiedTextSymbolIndex:n,leftJustifiedTextSymbolIndex:r,verticalPlacedTextSymbolIndex:o,placedIconSymbolIndex:s,verticalPlacedIconSymbolIndex:a}=e;i>=0&&this.addIndicesForPlacedSymbol(this.text,i),n>=0&&n!==i&&this.addIndicesForPlacedSymbol(this.text,n),r>=0&&r!==n&&r!==i&&this.addIndicesForPlacedSymbol(this.text,r),o>=0&&this.addIndicesForPlacedSymbol(this.text,o),s>=0&&this.addIndicesForPlacedSymbol(this.icon,s),a>=0&&this.addIndicesForPlacedSymbol(this.icon,a)}this.text.indexBuffer&&this.text.indexBuffer.updateData(this.text.indexArray),this.icon.indexBuffer&&this.icon.indexBuffer.updateData(this.icon.indexArray)}}}ba(jg,"SymbolBucket",{omit:["layers","collisionBoxArray","features","compareText"]}),jg.addDynamicAttributes=Bg;class Vg{constructor(t,e,i,n){this.context=t,this.format=i,this.texture=t.gl.createTexture(),this.update(e,n)}update(t,e,i){const{width:n,height:r}=t,{context:o}=this,{gl:s}=o;if(s.bindTexture(s.TEXTURE_2D,this.texture),o.pixelStoreUnpackFlipY.set(!1),o.pixelStoreUnpack.set(1),o.pixelStoreUnpackPremultiplyAlpha.set(this.format===s.RGBA&&(!e||!1!==e.premultiply)),this.useMipmap=Boolean(e&&e.useMipmap),i||this.size&&this.size[0]===n&&this.size[1]===r){const{x:e,y:o}=i||{x:0,y:0};if(t instanceof HTMLImageElement||t instanceof HTMLCanvasElement||t instanceof HTMLVideoElement||t instanceof ImageData||ImageBitmap&&t instanceof ImageBitmap)s.texSubImage2D(s.TEXTURE_2D,0,e,o,s.RGBA,s.UNSIGNED_BYTE,t);else{let i=this.format,a=s.UNSIGNED_BYTE;this.format===s.R32F&&(i=s.RED,a=s.FLOAT),s.texSubImage2D(s.TEXTURE_2D,0,e,o,n,r,i,a,t.data)}}else if(this.size=[n,r],t instanceof HTMLImageElement||t instanceof HTMLCanvasElement||t instanceof HTMLVideoElement||t instanceof ImageData||ImageBitmap&&t instanceof ImageBitmap){let e=this.format;this.format===s.R8&&(e=s.RED),s.texImage2D(s.TEXTURE_2D,0,this.format,e,s.UNSIGNED_BYTE,t)}else{let e=this.format,i=this.format,o=s.UNSIGNED_BYTE,a=!1;this.format===s.DEPTH_COMPONENT&&(e=s.DEPTH_COMPONENT16,o=s.UNSIGNED_SHORT),this.format===s.DEPTH_STENCIL&&(e=s.DEPTH24_STENCIL8,o=s.UNSIGNED_INT_24_8,a=!0),this.format===s.R8&&(i=s.RED),this.format===s.R32F&&(o=s.FLOAT,i=s.RED),!this.useMipmap&&a?s.texStorage2D(s.TEXTURE_2D,1,e,n,r):s.texImage2D(s.TEXTURE_2D,0,e,n,r,0,i,o,t.data)}this.useMipmap&&s.generateMipmap(s.TEXTURE_2D)}bind(t,e,i=!1){const{context:n}=this,{gl:r}=n;r.bindTexture(r.TEXTURE_2D,this.texture),t!==this.minFilter&&(r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MAG_FILTER,t),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MIN_FILTER,this.useMipmap&&!i?t===r.NEAREST?r.NEAREST_MIPMAP_NEAREST:r.LINEAR_MIPMAP_LINEAR:t),this.minFilter=t),e!==this.wrapS&&(r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_S,e),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_T,e),this.wrapS=e)}bindExtraParam(t,e,i,n){const{context:r}=this,{gl:o}=r;o.bindTexture(o.TEXTURE_2D,this.texture),e!==this.magFilter&&(o.texParameteri(o.TEXTURE_2D,o.TEXTURE_MAG_FILTER,e),this.magFilter=e),t!==this.minFilter&&(o.texParameteri(o.TEXTURE_2D,o.TEXTURE_MIN_FILTER,this.useMipmap?t===o.NEAREST?o.NEAREST_MIPMAP_NEAREST:o.LINEAR_MIPMAP_LINEAR:t),this.minFilter=t),i!==this.wrapS&&(o.texParameteri(o.TEXTURE_2D,o.TEXTURE_WRAP_S,i),this.wrapS=i),n!==this.wrapT&&(o.texParameteri(o.TEXTURE_2D,o.TEXTURE_WRAP_T,n),this.wrapT=n)}destroy(){const{gl:t}=this.context;t.deleteTexture(this.texture),this.texture=null}}class Gg{constructor(t,e){this.context=t,this.texture=e}bind(t,e){const{context:i}=this,{gl:n}=i;n.bindTexture(n.TEXTURE_2D,this.texture),t!==this.minFilter&&(n.texParameteri(n.TEXTURE_2D,n.TEXTURE_MAG_FILTER,t),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_MIN_FILTER,t),this.minFilter=t),e!==this.wrapS&&(n.texParameteri(n.TEXTURE_2D,n.TEXTURE_WRAP_S,e),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_WRAP_T,e),this.wrapS=e)}}const Zg=32,qg=33,Hg=new Uint16Array(8184);for(let t=0;t>=1)>1;){const t=i+r>>1,l=n+o>>1;1&e?(r=i,o=n,i=s,n=a):(i=r,n=o,r=s,o=a),s=t,a=l}const l=4*t;Hg[l+0]=i,Hg[l+1]=n,Hg[l+2]=r,Hg[l+3]=o}const Wg=new Uint16Array(2178),Yg=new Uint8Array(1089),Xg=new Uint16Array(1089);function Kg(t){return 0===t?-.03125:32===t?.03125:0}var Jg=Ll([{name:"a_pos",type:"Int16",components:2},{name:"a_texture_pos",type:"Int16",components:2}]),Qg=Ll([{name:"a_index",type:"Int16",components:1}]);const ty={type:2,extent:uo,loadGeometry:()=>[[new Ue(0,0),new Ue(uo+1,0),new Ue(uo+1,uo+1),new Ue(0,uo+1),new Ue(0,0)]]};class ey{constructor(t,e,i,n,r){this.tileID=t,this.uid=ni(),this.uses=0,this.tileSize=e,this.tileZoom=i,this.buckets={},this.expirationTime=null,this.queryPadding=0,this.hasSymbolBuckets=!1,this.hasRTLText=!1,this.dependencies={},this.isRaster=r,n&&n.style&&(this._lastUpdatedBrightness=n.style.getBrightness()),this.expiredRequestCount=0,this.state="loading",n&&n.transform&&(this.projection=n.transform.projection)}registerFadeDuration(t){const e=t+this.timeAdded;ee.getLayer(t))).filter(Boolean);if(0!==t.length){n.layers=t,n.stateDependentLayerIds&&(n.stateDependentLayers=n.stateDependentLayerIds.map((e=>t.filter((t=>t.id===e))[0])));for(const e of t)i[e.fqid]=n}}return i}(t.buckets,e.style),this.hasSymbolBuckets=!1;for(const t in this.buckets){const e=this.buckets[t];if(e instanceof jg){if(this.hasSymbolBuckets=!0,!i)break;e.justReloaded=!0}}if(this.hasRTLText=!1,this.hasSymbolBuckets)for(const t in this.buckets){const e=this.buckets[t];if(e instanceof jg&&e.hasRTLText){this.hasRTLText=!0,qa.isLoading()||qa.isLoaded()||"deferred"!==Ga()||Za();break}}this.queryPadding=0;for(const t in this.buckets){const i=this.buckets[t],n=e.style.getOwnLayer(t);if(!n)continue;const r=n.queryRadius(i);this.queryPadding=Math.max(this.queryPadding,r)}t.imageAtlas&&(this.imageAtlas=t.imageAtlas),t.glyphAtlasImage&&(this.glyphAtlasImage=t.glyphAtlasImage),t.lineAtlas&&(this.lineAtlas=t.lineAtlas),this._lastUpdatedBrightness=t.brightness}else this.collisionBoxArray=new dc}unloadVectorData(){if(this.hasData()){for(const t in this.buckets)this.buckets[t].destroy();this.buckets={},this.imageAtlas&&(this.imageAtlas=null),this.lineAtlas&&(this.lineAtlas=null),this.imageAtlasTexture&&this.imageAtlasTexture.destroy(),this.glyphAtlasTexture&&this.glyphAtlasTexture.destroy(),this.lineAtlasTexture&&this.lineAtlasTexture.destroy(),this._tileBoundsBuffer&&(this._tileBoundsBuffer.destroy(),this._tileBoundsIndexBuffer.destroy(),this._tileBoundsSegments.destroy(),this._tileBoundsBuffer=null),this._tileDebugBuffer&&(this._tileDebugBuffer.destroy(),this._tileDebugSegments.destroy(),this._tileDebugBuffer=null),this._tileDebugIndexBuffer&&(this._tileDebugIndexBuffer.destroy(),this._tileDebugIndexBuffer=null),this._globeTileDebugBorderBuffer&&(this._globeTileDebugBorderBuffer.destroy(),this._globeTileDebugBorderBuffer=null),this._tileDebugTextBuffer&&(this._tileDebugTextBuffer.destroy(),this._tileDebugTextSegments.destroy(),this._tileDebugTextIndexBuffer.destroy(),this._tileDebugTextBuffer=null),this._globeTileDebugTextBuffer&&(this._globeTileDebugTextBuffer.destroy(),this._globeTileDebugTextBuffer=null),this.latestFeatureIndex=null,this.state="unloaded"}}getBucket(t){return this.buckets[t.fqid]}upload(t){for(const e in this.buckets){const i=this.buckets[e];i.uploadPending()&&i.upload(t)}const e=t.gl,i=this.imageAtlas;if(i&&!i.uploaded){const n=!!Object.keys(i.patternPositions).length;this.imageAtlasTexture=new Vg(t,i.image,e.RGBA,{useMipmap:n}),this.imageAtlas.uploaded=!0}this.glyphAtlasImage&&(this.glyphAtlasTexture=new Vg(t,this.glyphAtlasImage,e.R8),this.glyphAtlasImage=null),this.lineAtlas&&!this.lineAtlas.uploaded&&(this.lineAtlasTexture=new Vg(t,this.lineAtlas.image,e.R8),this.lineAtlas.uploaded=!0)}prepare(t,e,i){if(this.imageAtlas&&this.imageAtlasTexture&&this.imageAtlas.patchUpdatedImages(t,this.imageAtlasTexture,i),!e||!this.latestFeatureIndex||!this.latestFeatureIndex.rawTileData)return;const n=e.style.getBrightness();(this._lastUpdatedBrightness||n)&&(this._lastUpdatedBrightness&&n&&Math.abs(this._lastUpdatedBrightness-n)t)i=!1;else if(e)if(this.expirationTime=0;t--){const e=4*t,i=Hg[e+0],n=Hg[e+1],r=Hg[e+2],o=Hg[e+3],s=i+r>>1,a=n+o>>1,l=s+a-n,c=a+i-s,d=n*qg+i,u=o*qg+r,h=a*qg+s,p=Math.hypot((Wg[2*d+0]+Wg[2*u+0])/2-Wg[2*h+0],(Wg[2*d+1]+Wg[2*u+1])/2-Wg[2*h+1])>=16;Yg[h]=Yg[h]||(p?1:0),t>1)*qg+(i+l>>1)]||Yg[(o+c>>1)*qg+(r+l>>1)])}const r=new Dl,o=new Kl;let s=0;function a(t,e){const i=e*qg+t;return 0===Xg[i]&&(r.emplaceBack(Wg[2*i+0],Wg[2*i+1],t*uo/Zg,e*uo/Zg),Xg[i]=++s),Xg[i]-1}function l(t,e,i,n,r,s){const c=t+i>>1,d=e+n>>1;if(Math.abs(t-r)+Math.abs(e-s)>1&&Yg[d*qg+c])l(r,s,t,e,c,d),l(i,n,r,s,c,d);else{const l=a(t,e),c=a(i,n),d=a(r,s);o.emplaceBack(l,c,d)}}return l(0,0,Zg,Zg,Zg,0),l(Zg,Zg,0,0,0,Zg),{vertices:r,indices:o}}(this.tileID.canonical,e);n=t.vertices,r=t.indices}else{n=new Dl,r=new Kl;for(const{x:t,y:e}of i)n.emplaceBack(t,e,0,0);const t=xh(n.int16,void 0,4);for(let e=0;e0&&(a=t.ad.invert(new Float64Array(16),i.globeMatrix)),this._makeGlobeTileDebugBorderBuffer(e,r,i,o,a,s),this._makeGlobeTileDebugTextBuffer(e,r,i,o,a,s)}_globePoint(e,i,n,r,o,s,a){let l=Fu(e,i,n);if(s){const o=1.5?h=-1:u{const p=(d-t)/(h-1),f=(u-c)/(h-1),m=s.length;for(let d=0;dd*t+e;for(let t=0;t[t,this.get(t)]))}evict(t=!1){if(t||this.size>0){const t=this.first;delete this.items[t.key],0==--this.size?(this.first=null,this.last=null):(this.first=t.next,this.first.prev=null)}return this}expiresAt(t){let e;return this.has(t)&&(e=this.items[t].expiry),e}get(t){let e;if(this.has(t)){const i=this.items[t];this.ttl>0&&i.expiry0?Date.now()+this.ttl:this.ttl),this.last!==r){const t=this.last,e=r.next,i=r.prev;this.first===r&&(this.first=r.next),r.next=null,r.prev=this.last,t.next=r,null!==i&&(i.next=e),null!==e&&(e.prev=i)}}else this.max>0&&this.size===this.max&&this.evict(!0),r=this.items[t]={expiry:this.ttl>0?Date.now()+this.ttl:this.ttl,key:t,prev:this.last,next:null,value:e},1==++this.size?this.first=r:this.last.next=r;return this.last=r,this}values(t=this.keys()){return t.map((t=>this.get(t)))}}function uy(t,e){if(4!==e.length)throw new Error(`Expected data of dimension 4 but got ${e.length}.`);let i=e[3];for(let n=2;n>=1;n--){const r=1===n?1:0,o=2===n?1:0;for(let n=0;n>>1^-(1&t[e]);return t}function py(t,e){switch(e){case"uint32":return t;case"uint16":for(let e=0;e>4|(61440&i)>>8|(240&n)>4|(15&n)>6|(192&n)>>4|(192&r)>>2|192&o,t[e+1]=(48&i)>>4|(48&n)>>2|48&r|(48&o)>2|12&n|(12&r)>1|(21845&Cy)>2|(13107&Ay)>4|(3855&Ay)>8|(255&Ay)>1}var Iy=function(t,e,i){for(var n=t.length,r=0,o=new _y(e);r>l]=c}else for(s=new _y(n),r=0;r>15-t[r]);return s},Ly=new my(288);for(Cy=0;Cye&&(e=t[i]);return e},zy=function(t,e,i){var n=e/8|0;return(t[n]|t[n+1]>(7&e)&i},Ry=function(t,e){var i=e/8|0;return(t[i]|t[i+1]>(7&e)},Oy=["unexpected EOF","invalid block type","invalid length/literal","invalid distance","stream finished","no stream handler",,"no callback","invalid UTF-8 data","extra field too long","date not in range 1980-2099","filename too long","stream finishing","invalid zip data"],By=function(t,e,i){var n=new Error(e||Oy[t]);if(n.code=t,Error.captureStackTrace&&Error.captureStackTrace(n,By),!i)throw n;return n},Fy=new my(0),Ny="undefined"!=typeof TextDecoder&&new TextDecoder;try{Ny.decode(Fy,{stream:!0})}catch(t){}const Uy={gzip_data:"gzip"},jy={0:"uint32",1:"uint32",2:"uint16",3:"uint8"},Vy={uint32:1,uint16:2,uint8:4},Gy={uint32:Uint32Array,uint16:Uint16Array,uint8:Uint8Array};class Zy{constructor(t=1){this.x=NaN,this.y=NaN,this.z=NaN,this.layers={},this._cacheSize=t}getLayer(t){return this.layers[t]}getHeaderLength(t){const e=new Uint8Array(t),i=new DataView(t);if(13!==e[0])throw new fy("File is not a valid MRT.");return i.getUint32(1,!0)}parseHeader(t){const e=new Uint8Array(t),i=this.getHeaderLength(t);if(e.length= ${i} but got buffer of length ${e.length}`);const n=function(t){return t.readFields(iy,{header_length:0,x:0,y:0,z:0,layers:[]},void 0)}(new Lm(e.subarray(0,i)));if(!isNaN(this.x)&&(this.x!==n.x||this.y!==n.y||this.z!==n.z))throw new fy(`Invalid attempt to parse header ${n.z}/${n.x}/${n.y} for tile ${this.z}/${this.x}/${this.y}`);this.x=n.x,this.y=n.y,this.z=n.z;for(const t of n.layers)this.layers[t.name]=new qy(t,{cacheSize:this._cacheSize});return this}createDecodingTask(t){const e=[],i=this.getLayer(t.layerName);for(let n=0;nt.lastBlock)continue;if(i._blocksInProgress.has(n))continue;const a={layerName:i.name,firstByte:o,lastByte:s,pixelFormat:i.pixelFormat,blockIndex:n,blockShape:[r.bands.length].concat(i.bandShape),buffer:i.buffer,codec:r.codec.codec,filters:r.filters.map((t=>t.filter))};i._blocksInProgress.add(n),e.push(a)}return new Hy(e,(()=>{e.forEach((t=>i._blocksInProgress.delete(t.blockIndex)))}),((t,n)=>{if(e.forEach((t=>i._blocksInProgress.delete(t.blockIndex))),t)throw t;n.forEach((t=>{this.getLayer(t.layerName).processDecodedData(t)}))}))}}class qy{constructor({version:t,name:e,units:i,tilesize:n,pixel_format:r,buffer:o,data_index:s},a){if(this.version=t,1!==this.version)throw new fy(`Cannot parse raster layer encoded with MRT version ${t}`);this.name=e,this.units=i,this.tileSize=n,this.buffer=o,this.pixelFormat=jy[r],this.dataIndex=s,this.bandShape=[n+2*o,n+2*o,Vy[this.pixelFormat]],this._decodedBlocks=function(t=1e3,e=0,i=!1){if(isNaN(t)||t=e&&t=0}hasDataForBand(t){const{blockIndex:e}=this.getBlockForBand(t);return e>=0&&!!this._decodedBlocks.get(e.toString())}getBandView(t){const{blockIndex:e,blockBandIndex:i}=this.getBlockForBand(t),n=this._decodedBlocks.get(e.toString());if(!n)throw new fy(`Data for band ${JSON.stringify(t)} of layer "${this.name}" not decoded.`);const r=this.dataIndex[e],o=this.bandShape.reduce(((t,e)=>t*e),1),s=i*o,a=n.subarray(s,s+o);return{data:a,bytes:new Uint8Array(a.buffer).subarray(a.byteOffset,a.byteOffset+a.byteLength),tileSize:this.tileSize,buffer:this.buffer,offset:r.offset,scale:r.scale}}}class Hy{constructor(t,e,i){this.tasks=t,this._onCancel=e,this._onComplete=i,this._finalized=!1}cancel(){this._finalized||(this._onCancel(),this._finalized=!0)}complete(t,e){this._finalized||(this._onComplete(t,e),this._finalized=!0)}}Zy.performDecoding=function(t,e){return Promise.all(e.tasks.map((e=>{const{layerName:i,firstByte:n,lastByte:r,pixelFormat:o,blockShape:s,blockIndex:a,filters:l,codec:c}=e,d=new Uint8Array(t).subarray(n,r+1),u=new Uint32Array(s[0]*s[1]*s[2]);let h;if("gzip_data"!==c)throw new Error(`Unhandled codec: ${c}`);return h=function(t,e){if(!globalThis.DecompressionStream&&"gzip_data"===e)return Promise.resolve(((o=function(t){31==t[0]&&139==t[1]&&8==t[2]||By(6,"invalid gzip data");var e=t[3],i=10;4&e&&(i+=2+(t[10]|t[11]>3&1)+(e>>4&1);n>0;n-=!t[i++]);return i+(2&e)}(r=t))+8>r.length&&By(6,"invalid gzip data"),function(t,e,i){var n=t.length;if(!n||e.f&&!e.l)return i||new my(0);var r=!i,o=r||2!=e.i,s=e.i;r&&(i=new my(3*n));var a,l,c=function(t){var e=i.length;if(t>e){var n=new my(Math.max(2*e,t));n.set(i),i=n}},d=e.f||0,u=e.p||0,h=e.b||0,p=e.l,f=e.d,m=e.m,_=e.n,g=8*n;do{if(!p){d=zy(t,u,1);var y=zy(t,u+1,3);if(u+=3,!y){var v=t[(L=4+((u+7)/8|0))-4]|t[L-3]n){s&&By(0);break}o&&c(h+v),i.set(t.subarray(L,x),h),e.b=h+=v,e.p=u=8*x,e.f=d;continue}if(1==y)p=$y,f=ky,m=9,_=5;else if(2==y){var b=zy(t,u,31)+257,w=zy(t,u+10,15)+4,T=b+zy(t,u+5,31)+1;u+=14;for(var S=new my(T),E=new my(19),M=0;M>4)g){s&&By(0);break}}o&&c(h+131072);for(var R=(1>4;if((u+=15&$)>g){s&&By(0);break}if($||By(2),F264&&(N=zy(t,u,(1>4;if(U||By(3),u+=15&U,z=Ey[j],j>3){var V=vy[j];z+=Ry(t,u)&(1g){s&&By(0);break}o&&c(h+131072);var G=h+N;if(ha.length)&&(l=a.length),new my(a.subarray(0,l))):i.subarray(0,h)}(r.subarray(o,-8),{i:2},new my(((i=r)[(n=i.length)-4]|i[n-3]>>0))));var i,n,r,o;const s=Uy[e];if(!s)throw new Error(`Unhandled codec: ${e}`);const a=new globalThis.DecompressionStream(s);return new Response(new Blob([t]).stream().pipeThrough(a)).arrayBuffer().then((t=>new Uint8Array(t)))}(d,c).then((t=>(function(t,e){t.readFields(ly,e)}(new Lm(t),u),new(0,Gy[o])(u.buffer)))),h.then((t=>{for(let e=l.length-1;e>=0;e--)switch(l[e]){case"delta_filter":uy(t,s);break;case"zigzag_filter":hy(t);break;case"bitshuffle_filter":py(t,o);break;default:throw new Error(`Unhandled filter "${l[e]}"`)}return{layerName:i,blockIndex:a,data:t}})).catch((t=>{throw t}))})))};class Wy extends ey{constructor(t,e,i,n,r){super(t,e,i,n,r),this._workQueue=[],this._fetchQueue=[],this._isHeaderLoaded=!1}setTexture(t,e){const i=e.context,n=i.gl;this.texture=this.texture||e.getTileTexture(t.width),this.texture&&this.texture instanceof Vg?this.texture.update(t,{useMipmap:!1,premultiply:!1}):this.texture=new Vg(i,t,n.RGBA,{useMipmap:!1,premultiply:!1})}flushQueues(){for(;this._workQueue.length;)this._workQueue.pop()();for(;this._fetchQueue.length;)this._fetchQueue.pop()()}fetchHeader(t=16384,e){const i=this._mrt=new Zy(30),n=Object.assign({},this.requestParams,{headers:{Range:"bytes=0-"+(t-1)}});return this.entireBuffer=null,this.request=en(n,((n,r,o,s)=>{if(n)e(n);else try{const n=i.getHeaderLength(r);if(n>t)return void(this.request=this.fetchHeader(n,e));i.parseHeader(r),this._isHeaderLoaded=!0;let a=0;for(const t of Object.values(i.layers))a=Math.max(a,t.dataIndex[t.dataIndex.length-1].last_byte);r.byteLength>=a&&(this.entireBuffer=r),e(null,this.entireBuffer||r,o,s)}catch(t){e(t)}})),this.request}fetchBand(t,e,i){const n=this._mrt;if(!this._isHeaderLoaded||!n)return void i(new Error("Tile header is not ready"));const r=this.actor;if(!r)return void i(new Error("Can't fetch tile band without an actor"));let o;const s=(n,r)=>{o.complete(n,r),n?i(n):(this.updateTextureDescriptor(t,e),i(null,this.textureDescriptor&&this.textureDescriptor.img))},a=(t,e)=>{if(t)return i(t);const n=r.send("decodeRasterArray",{buffer:e,task:o},s,void 0,!0);this._workQueue.push((()=>{n&&n.cancel(),o.cancel()}))},l=n.getLayer(t);if(!l)return void i(new Error(`Unknown sourceLayer "${t}"`));if(l.hasDataForBand(e))return this.updateTextureDescriptor(t,e),void i(null,this.textureDescriptor?this.textureDescriptor.img:null);const c=l.getDataRange([e]);if(o=n.createDecodingTask(c),!o||o.tasks.length)if(this.flushQueues(),this.entireBuffer)a(null,this.entireBuffer.slice(c.firstByte,c.lastByte+1));else{const t=Object.assign({},this.requestParams,{headers:{Range:`bytes=${c.firstByte}-${c.lastByte}`}}),e=en(t,a);this._fetchQueue.push((()=>{e.cancel(),o.cancel()}))}else i(null)}updateNeeded(t,e){return(!this.textureDescriptor||this.textureDescriptor.band!==e||this.textureDescriptor.layer!==t)&&"errored"!==this.state}updateTextureDescriptor(t,e){if(!this._mrt)return;const i=this._mrt.getLayer(t);if(!i||!i.hasBand(e)||!i.hasDataForBand(e))return;const{bytes:n,tileSize:r,buffer:o,offset:s,scale:a}=i.getBandView(e),l=r+2*o,c={data:n,width:l,height:l},d=this.texture;d&&d instanceof Vg&&d.update(c,{useMipmap:!1,premultiply:!1}),this.textureDescriptor={layer:t,band:e,img:c,buffer:o,offset:s,tileSize:r,format:i.pixelFormat,mix:[a,256*a,65536*a,16777216*a]}}}class Yy{constructor(t,e){this.max=t,this.onRemove=e,this.reset()}reset(){for(const t in this.data)for(const e of this.data[t])e.timeout&&clearTimeout(e.timeout),this.onRemove(e.value);return this.data={},this.order=[],this}add(t,e,i){const n=t.wrapped().key;void 0===this.data[n]&&(this.data[n]=[]);const r={value:e,timeout:void 0};if(void 0!==i&&(r.timeout=setTimeout((()=>{this.remove(t,r)}),i)),this.data[n].push(r),this.order.push(n),this.order.length>this.max){const t=this._getAndRemoveByKey(this.order[0]);t&&this.onRemove(t)}return this}has(t){return t.wrapped().key in this.data}getAndRemove(t){return this.has(t)?this._getAndRemoveByKey(t.wrapped().key):null}_getAndRemoveByKey(t){const e=this.data[t].shift();return e.timeout&&clearTimeout(e.timeout),0===this.data[t].length&&delete this.data[t],this.order.splice(this.order.indexOf(t),1),e.value}getByKey(t){const e=this.data[t];return e?e[0].value:null}get(t){return this.has(t)?this.data[t.wrapped().key][0].value:null}remove(t,e){if(!this.has(t))return this;const i=t.wrapped().key,n=void 0===e?0:this.data[i].indexOf(e),r=this.data[i][n];return this.data[i].splice(n,1),r.timeout&&clearTimeout(r.timeout),0===this.data[i].length&&delete this.data[i],this.onRemove(r.value),this.order.splice(this.order.indexOf(i),1),this}setMaxSize(t){for(this.max=t;this.order.length>this.max;){const t=this._getAndRemoveByKey(this.order[0]);t&&this.onRemove(t)}return this}filter(t){const e=[];for(const i in this.data)for(const n of this.data[i])t(n.value)||e.push(n);for(const t of e)this.remove(t.value.tileID,t)}}class Xy extends zn{constructor(t,e,i){super(),this.id=t,this._onlySymbols=i,e.on("data",(t=>{"source"===t.dataType&&"metadata"===t.sourceDataType&&(this._sourceLoaded=!0),this._sourceLoaded&&!this._paused&&"source"===t.dataType&&"content"===t.sourceDataType&&(this.reload(),this.transform&&this.update(this.transform))})),e.on("error",(()=>{this._sourceErrored=!0})),this._source=e,this._tiles={},this._cache=new Yy(0,this._unloadTile.bind(this)),this._timers={},this._cacheTimers={},this._minTileCacheSize=e.minTileCacheSize,this._maxTileCacheSize=e.maxTileCacheSize,this._loadedParentTiles={},this.castsShadows=!1,this.tileCoverLift=0,this._coveredTiles={},this._shadowCasterTiles={},this._state=new km,this._isRaster="raster"===this._source.type||"raster-dem"===this._source.type||"raster-array"===this._source.type||"custom"===this._source.type&&"raster"===this._source._dataType}onAdd(t){this.map=t,this._minTileCacheSize=void 0===this._minTileCacheSize&&t?t._minTileCacheSize:this._minTileCacheSize,this._maxTileCacheSize=void 0===this._maxTileCacheSize&&t?t._maxTileCacheSize:this._maxTileCacheSize}loaded(){if(this._sourceErrored)return!0;if(!this._sourceLoaded)return!1;if(!this._source.loaded())return!1;for(const t in this._tiles){const e=this._tiles[t];if("errored"!==e.state&&("loaded"!==e.state||!e.bucketsLoaded()))return!1}return!0}getSource(){return this._source}pause(){this._paused=!0}resume(){if(!this._paused)return;const t=this._shouldReloadOnResume;this._paused=!1,this._shouldReloadOnResume=!1,t&&this.reload(),this.transform&&this.update(this.transform)}_loadTile(t,e){return t.isSymbolTile=this._onlySymbols,t.isExtraShadowCaster=this._shadowCasterTiles[t.tileID.key],this._source.loadTile(t,e)}_unloadTile(t){if(this._source.unloadTile)return this._source.unloadTile(t)}_abortTile(t){if(this._source.abortTile)return this._source.abortTile(t)}serialize(){return this._source.serialize()}prepare(t){this._source.prepare&&this._source.prepare(),this._state.coalesceChanges(this._tiles,this.map?this.map.painter:null);for(const e in this._tiles){const i=this._tiles[e];i.upload(t),i.prepare(this.map.style.imageManager,this.map?this.map.painter:null,this._source.scope)}}getIds(){return ti(this._tiles).map((t=>t.tileID)).sort(Ky).map((t=>t.key))}getRenderableIds(t,e){const i=[];for(const n in this._tiles)this._isIdRenderable(+n,t,e)&&i.push(this._tiles[n]);return t?i.sort(((t,e)=>{const i=t.tileID,n=e.tileID,r=new Ue(i.canonical.x,i.canonical.y)._rotate(this.transform.angle),o=new Ue(n.canonical.x,n.canonical.y)._rotate(this.transform.angle);return i.overscaledZ-n.overscaledZ||o.y-r.y||o.x-r.x})).map((t=>t.tileID.key)):i.map((t=>t.tileID)).sort(Ky).map((t=>t.key))}hasRenderableParent(t){const e=this.findLoadedParent(t,0);return!!e&&this._isIdRenderable(e.tileID.key)}_isIdRenderable(t,e,i){return this._tiles[t]&&this._tiles[t].hasData()&&!this._coveredTiles[t]&&(e||!this._tiles[t].holdingForFade())&&(i||!this._shadowCasterTiles[t])}reload(){if(this._paused)this._shouldReloadOnResume=!0;else{this._cache.reset();for(const t in this._tiles)"errored"!==this._tiles[t].state&&this._reloadTile(+t,"reloading")}}_reloadTile(t,e){const i=this._tiles[t];i&&("loading"!==i.state&&(i.state=e),this._loadTile(i,this._tileLoaded.bind(this,i,t,e)))}_tileLoaded(t,e,i,n){if(n)if(t.state="errored",404!==n.status)this._source.fire(new $n(n,{tile:t}));else{if(!(t.tileID.key in this._loadedParentTiles))return void this._source.fire(new Pn("data",{dataType:"source",sourceDataType:"error",sourceId:this._source.id}));if("raster-dem"===this._source.type&&this.usedForTerrain&&this.map.painter.terrain){const t=this.map.painter.terrain;this.update(this.transform,t.getScaledDemTileSize(),!0),t.resetTileLookupCache(this.id)}else this.update(this.transform)}else t.timeAdded=ki.now(),"expired"===i&&(t.refreshedUponExpiration=!0),this._setTileReloadTimer(e,t),"raster-dem"===this._source.type&&t.dem&&this._backfillDEM(t),this._state.initializeTileState(t,this.map?this.map.painter:null),this._source.fire(new Pn("data",{dataType:"source",tile:t,coord:t.tileID,sourceCacheId:this.id}))}_backfillDEM(t){const e=this.getRenderableIds();for(let n=0;n1||(Math.abs(i)>1&&(1===Math.abs(i+r)?i+=r:1===Math.abs(i-r)&&(i-=r)),e.dem&&t.dem&&(t.dem.backfillBorder(e.dem,i,n),t.neighboringTiles&&t.neighboringTiles[o]&&(t.neighboringTiles[o].backfilled=!0)))}}getTile(t){return this.getTileByID(t.key)}getTileByID(t){return this._tiles[t]}_retainLoadedChildren(t,e,i,n){for(const r in this._tiles){let o=this._tiles[r];if(n[r]||!o.hasData()||o.tileID.overscaledZi)continue;let s=o.tileID;for(;o&&o.tileID.overscaledZ>e+1;){const t=o.tileID.scaledTo(o.tileID.overscaledZ-1);o=this._tiles[t.key],o&&o.hasData()&&(s=t)}let a=s;for(;a.overscaledZ>e;)if(a=a.scaledTo(a.overscaledZ-1),t[a.key]){n[s.key]=s;break}}}findLoadedParent(t,e){if(t.key in this._loadedParentTiles){const i=this._loadedParentTiles[t.key];return i&&i.tileID.overscaledZ>=e?i:null}for(let i=t.overscaledZ-1;i>=e;i--){const e=t.scaledTo(i),n=this._getLoadedTile(e);if(n)return n}}_getLoadedTile(t){const e=this._tiles[t.key];return e&&e.hasData()?e:this._cache.getByKey(this._source.reparseOverscaled?t.wrapped().key:t.canonical.key)}updateCacheSize(t,e){e=e||this._source.tileSize;const i=Math.ceil(t.width/e)+1,n=Math.ceil(t.height/e)+1,r=Math.floor(i*n*5),o="number"==typeof this._minTileCacheSize?Math.max(this._minTileCacheSize,r):r,s="number"==typeof this._maxTileCacheSize?Math.min(this._maxTileCacheSize,o):o;this._cache.setMaxSize(s)}handleWrapJump(t){const e=Math.round((t-(void 0===this._prevLng?t:this._prevLng))/360);if(this._prevLng=t,e){const t={};for(const i in this._tiles){const n=this._tiles[i];n.tileID=n.tileID.unwrapTo(n.tileID.wrap+e),t[n.tileID.key]=n}this._tiles=t;for(const t in this._timers)clearTimeout(this._timers[t]),delete this._timers[t];for(const t in this._tiles)this._setTileReloadTimer(+t,this._tiles[t])}}update(t,e,i,n){if(this.transform=t,!this._sourceLoaded||this._paused||this.transform.freezeTileCoverage)return;if(this.usedForTerrain&&!i)return;let r;if(this.updateCacheSize(t,e),"globe"!==this.transform.projection.name&&this.handleWrapJump(this.transform.center.lng),this._shadowCasterTiles={},this._coveredTiles={},this.used||this.usedForTerrain){if(this._source.tileID)r=t.getVisibleUnwrappedCoordinates(this._source.tileID).map((t=>new vd(t.canonical.z,t.wrap,t.canonical.z,t.canonical.x,t.canonical.y)));else if(0!==this.tileCoverLift){const n=t.clone();n.tileCoverLift=this.tileCoverLift,r=n.coveringTiles({tileSize:e||this._source.tileSize,minzoom:this._source.minzoom,maxzoom:this._source.maxzoom,roundZoom:this._source.roundZoom&&!i,reparseOverscaled:this._source.reparseOverscaled,isTerrainDEM:this.usedForTerrain}),this._source.minzoomt(e)))}}else r=[];if(r.length>0&&this.castsShadows&&n&&"globe"!==this.transform.projection.name&&!this.usedForTerrain&&!Jy(this._source.type)){const o=t.coveringZoomLevel({tileSize:e||this._source.tileSize,roundZoom:this._source.roundZoom&&!i}),s=Math.min(o,this._source.maxzoom),a=t.extendTileCoverForShadows(r,n,s);for(const t of a)this._shadowCasterTiles[t.key]=!0,r.push(t)}const o=this._updateRetainedTiles(r);if(Jy(this._source.type)&&0!==r.length){const t={},e={},i=Object.keys(o);for(const n of i){const i=o[n],r=this._tiles[n];if(!r||r.fadeEndTime&&r.fadeEndTimen;){r=r.scaledTo(r.overscaledZ-1);const n=this._tiles[r.key];if(n&&n.hasData()&&e[r.key]){o[t]=i.tileID;break}}}for(const e in t)o[e]||(this._coveredTiles[e]=!0,o[e]=t[e])}for(const t in o)this._tiles[t].clearFadeHold();const s=function(t,e){const i=[];for(const n in t)n in e||i.push(n);return i}(this._tiles,o);for(const t of s){const e=this._tiles[t];e.hasSymbolBuckets&&!e.holdingForFade()?e.setHoldDuration(this.map._fadeDuration):e.hasSymbolBuckets&&!e.symbolFadeFinished()||this._removeTile(+t)}this._updateLoadedParentTileCache(),this._onlySymbols&&this._source.afterUpdate&&this._source.afterUpdate()}releaseSymbolFadeTiles(){for(const t in this._tiles)this._tiles[t].holdingForFade()&&this._removeTile(+t)}_updateRetainedTiles(t){const e={};if(0===t.length)return e;const i={},n=t.reduce(((t,e)=>Math.min(t,e.overscaledZ)),1/0),r=t[0].overscaledZ,o=Math.max(r-Xy.maxOverzooming,this._source.minzoom),s=Math.max(r+Xy.maxUnderzooming,this._source.minzoom),a={};for(const i of t){const t=this._addTile(i);e[i.key]=i,t.hasData()||n=this._source.maxzoom){const t=n.children(this._source.maxzoom)[0],i=this.getTile(t);if(i&&i.hasData()){e[t.key]=t;continue}}else{const t=n.children(this._source.maxzoom);if(e[t[0].key]&&e[t[1].key]&&e[t[2].key]&&e[t[3].key])continue}let r=t.wasRequested();for(let s=n.overscaledZ-1;s>=o;--s){const o=n.scaledTo(s);if(i[o.key])break;if(i[o.key]=!0,t=this.getTile(o),!t&&r&&(t=this._addTile(o)),t&&(e[o.key]=o,r=t.wasRequested(),t.hasData()))break}}return e}_updateLoadedParentTileCache(){this._loadedParentTiles={};for(const t in this._tiles){const e=[];let i,n=this._tiles[t].tileID;for(;n.overscaledZ>0;){if(n.key in this._loadedParentTiles){i=this._loadedParentTiles[n.key];break}e.push(n.key);const t=n.scaledTo(n.overscaledZ-1);if(i=this._getLoadedTile(t),i)break;n=t}for(const t of e)this._loadedParentTiles[t]=i}}_addTile(t){let e=this._tiles[t.key];if(e)return!0!==e.isExtraShadowCaster||!!this._shadowCasterTiles[t.key]||this._reloadTile(t.key,"reloading"),e;e=this._cache.getAndRemove(t),e&&(this._setTileReloadTimer(t.key,e),e.tileID=t,this._state.initializeTileState(e,this.map?this.map.painter:null),this._cacheTimers[t.key]&&(clearTimeout(this._cacheTimers[t.key]),delete this._cacheTimers[t.key],this._setTileReloadTimer(t.key,e)));const i=Boolean(e);if(!i){const i=this.map?this.map.painter:null,n=this._source.tileSize*t.overscaleFactor();e="raster-array"===this._source.type?new Wy(t,n,this.transform.tileZoom,i,this._isRaster):new ey(t,n,this.transform.tileZoom,i,this._isRaster),this._loadTile(e,this._tileLoaded.bind(this,e,t.key,e.state))}return e?(e.uses++,this._tiles[t.key]=e,i||this._source.fire(new Pn("dataloading",{tile:e,coord:e.tileID,dataType:"source"})),e):null}_setTileReloadTimer(t,e){t in this._timers&&(clearTimeout(this._timers[t]),delete this._timers[t]);const i=e.getExpiryTimeout();i&&(this._timers[t]=setTimeout((()=>{this._reloadTile(t,"expired"),delete this._timers[t]}),i))}_removeTile(t){const e=this._tiles[t];e&&(e.uses--,delete this._tiles[t],this._timers[t]&&(clearTimeout(this._timers[t]),delete this._timers[t]),e.uses>0||(e.hasData()&&"reloading"!==e.state||"empty"===e.state?this._cache.add(e.tileID,e,e.getExpiryTimeout()):(e.aborted=!0,this._abortTile(e),this._unloadTile(e))))}clearTiles(){this._shouldReloadOnResume=!1,this._paused=!1;for(const t in this._tiles)this._removeTile(+t);this._source._clear&&this._source._clear(),this._cache.reset(),this.map&&this.usedForTerrain&&this.map.painter.terrain&&this.map.painter.terrain.resetTileLookupCache(this.id)}tilesIn(t,e,i){const n=[],r=this.transform;if(!r)return n;const o="globe"===r.projection.name,s=Ed(r.center.lng);for(const a in this._tiles){const l=this._tiles[a];if(i&&l.clearQueryDebugViz(),l.holdingForFade())continue;let c;if(o){const t=l.tileID.canonical;if(0===t.z){const e=[Math.abs(Xe(s,...Qy(t,-1))-s),Math.abs(Xe(s,...Qy(t,1))-s)];c=[0,2*e.indexOf(Math.min(...e))-1]}else{const e=[Math.abs(Xe(s,...Qy(t,-1))-s),Math.abs(Xe(s,...Qy(t,0))-s),Math.abs(Xe(s,...Qy(t,1))-s)];c=[e.indexOf(Math.min(...e))-1]}}else c=[0];for(const i of c){const o=t.containsTile(l,r,e,i);o&&n.push(o)}}return n}getShadowCasterCoordinates(){return this._getRenderableCoordinates(!1,!0)}getVisibleCoordinates(t){return this._getRenderableCoordinates(t)}_getRenderableCoordinates(t,e){const i=this.getRenderableIds(t,e).map((t=>this._tiles[t].tileID)),n="globe"===this.transform.projection.name;for(const t of i)t.projMatrix=this.transform.calculateProjMatrix(t.toUnwrapped()),t.expandedProjMatrix=n?this.transform.calculateProjMatrix(t.toUnwrapped(),!1,!0):t.projMatrix;return i}sortCoordinatesByDistance(t){const e=t.slice(),i=this.transform._camera.position,n=this.transform._camera.forward(),r={};for(const t of e){const e=1/(1r[t.key]-r[e.key])),e}hasTransition(){if(this._source.hasTransition())return!0;if(Jy(this._source.type))for(const t in this._tiles){const e=this._tiles[t];if(void 0!==e.fadeEndTime&&e.fadeEndTime>=ki.now())return!0}return!1}setFeatureState(t,e,i){this._state.updateState(t=t||"_geojsonTileLayer",e,i)}removeFeatureState(t,e,i){this._state.removeFeatureState(t=t||"_geojsonTileLayer",e,i)}getFeatureState(t,e){return this._state.getState(t=t||"_geojsonTileLayer",e)}setDependencies(t,e,i){const n=this._tiles[t];n&&n.setDependencies(e,i)}reloadTilesForDependencies(t,e){for(const i in this._tiles)this._tiles[i].hasDependency(t,e)&&this._reloadTile(+i,"reloading");this._cache.filter((i=>!i.hasDependency(t,e)))}_preloadTiles(t,e){if(!this._sourceLoaded){const i=()=>{this._sourceLoaded&&(this._source.off("data",i),this._preloadTiles(t,e))};return void this._source.on("data",i)}const i=new Map,n=Array.isArray(t)?t:[t],r=this.map.painter.terrain,o=this.usedForTerrain&&r?r.getScaledDemTileSize():this._source.tileSize;for(const t of n){const e=t.coveringTiles({tileSize:o,minzoom:this._source.minzoom,maxzoom:this._source.maxzoom,roundZoom:this._source.roundZoom&&!this.usedForTerrain,reparseOverscaled:this._source.reparseOverscaled,isTerrainDEM:this.usedForTerrain});for(const t of e)i.set(t.key,t);this.usedForTerrain&&t.updateElevation(!1)}Qe(Array.from(i.values()),((t,e)=>{const i=new ey(t,this._source.tileSize*t.overscaleFactor(),this.transform.tileZoom,this.map.painter,this._isRaster);this._loadTile(i,(t=>{"raster-dem"===this._source.type&&i.dem&&this._backfillDEM(i),e(t,i)}))}),e)}}function Ky(t,e){const i=Math.abs(2*t.wrap)-+(t.wrap0?e+2*t:t}tv.useIntegerZoom=!0;const iv=new ol({"symbol-placement":new il(sl.layout_symbol["symbol-placement"]),"symbol-spacing":new il(sl.layout_symbol["symbol-spacing"]),"symbol-avoid-edges":new il(sl.layout_symbol["symbol-avoid-edges"]),"symbol-sort-key":new nl(sl.layout_symbol["symbol-sort-key"]),"symbol-z-order":new il(sl.layout_symbol["symbol-z-order"]),"symbol-z-elevate":new il(sl.layout_symbol["symbol-z-elevate"]),"icon-allow-overlap":new il(sl.layout_symbol["icon-allow-overlap"]),"icon-ignore-placement":new il(sl.layout_symbol["icon-ignore-placement"]),"icon-optional":new il(sl.layout_symbol["icon-optional"]),"icon-rotation-alignment":new il(sl.layout_symbol["icon-rotation-alignment"]),"icon-size":new nl(sl.layout_symbol["icon-size"]),"icon-text-fit":new nl(sl.layout_symbol["icon-text-fit"]),"icon-text-fit-padding":new nl(sl.layout_symbol["icon-text-fit-padding"]),"icon-image":new nl(sl.layout_symbol["icon-image"]),"icon-rotate":new nl(sl.layout_symbol["icon-rotate"]),"icon-padding":new il(sl.layout_symbol["icon-padding"]),"icon-keep-upright":new il(sl.layout_symbol["icon-keep-upright"]),"icon-offset":new nl(sl.layout_symbol["icon-offset"]),"icon-anchor":new nl(sl.layout_symbol["icon-anchor"]),"icon-pitch-alignment":new il(sl.layout_symbol["icon-pitch-alignment"]),"text-pitch-alignment":new il(sl.layout_symbol["text-pitch-alignment"]),"text-rotation-alignment":new il(sl.layout_symbol["text-rotation-alignment"]),"text-field":new nl(sl.layout_symbol["text-field"]),"text-font":new nl(sl.layout_symbol["text-font"]),"text-size":new nl(sl.layout_symbol["text-size"]),"text-max-width":new nl(sl.layout_symbol["text-max-width"]),"text-line-height":new nl(sl.layout_symbol["text-line-height"]),"text-letter-spacing":new nl(sl.layout_symbol["text-letter-spacing"]),"text-justify":new nl(sl.layout_symbol["text-justify"]),"text-radial-offset":new nl(sl.layout_symbol["text-radial-offset"]),"text-variable-anchor":new il(sl.layout_symbol["text-variable-anchor"]),"text-anchor":new nl(sl.layout_symbol["text-anchor"]),"text-max-angle":new il(sl.layout_symbol["text-max-angle"]),"text-writing-mode":new il(sl.layout_symbol["text-writing-mode"]),"text-rotate":new nl(sl.layout_symbol["text-rotate"]),"text-padding":new il(sl.layout_symbol["text-padding"]),"text-keep-upright":new il(sl.layout_symbol["text-keep-upright"]),"text-transform":new nl(sl.layout_symbol["text-transform"]),"text-offset":new nl(sl.layout_symbol["text-offset"]),"text-allow-overlap":new il(sl.layout_symbol["text-allow-overlap"]),"text-ignore-placement":new il(sl.layout_symbol["text-ignore-placement"]),"text-optional":new il(sl.layout_symbol["text-optional"]),visibility:new il(sl.layout_symbol.visibility)});var nv={paint:new ol({"icon-opacity":new nl(sl.paint_symbol["icon-opacity"]),"icon-occlusion-opacity":new nl(sl.paint_symbol["icon-occlusion-opacity"]),"icon-emissive-strength":new nl(sl.paint_symbol["icon-emissive-strength"]),"text-emissive-strength":new nl(sl.paint_symbol["text-emissive-strength"]),"icon-color":new nl(sl.paint_symbol["icon-color"]),"icon-halo-color":new nl(sl.paint_symbol["icon-halo-color"]),"icon-halo-width":new nl(sl.paint_symbol["icon-halo-width"]),"icon-halo-blur":new nl(sl.paint_symbol["icon-halo-blur"]),"icon-translate":new il(sl.paint_symbol["icon-translate"]),"icon-translate-anchor":new il(sl.paint_symbol["icon-translate-anchor"]),"icon-image-cross-fade":new nl(sl.paint_symbol["icon-image-cross-fade"]),"text-opacity":new nl(sl.paint_symbol["text-opacity"]),"text-occlusion-opacity":new nl(sl.paint_symbol["text-occlusion-opacity"]),"text-color":new nl(sl.paint_symbol["text-color"],{runtimeType:Qn,getOverride:t=>t.textColor,hasOverride:t=>!!t.textColor}),"text-halo-color":new nl(sl.paint_symbol["text-halo-color"]),"text-halo-width":new nl(sl.paint_symbol["text-halo-width"]),"text-halo-blur":new nl(sl.paint_symbol["text-halo-blur"]),"text-translate":new il(sl.paint_symbol["text-translate"]),"text-translate-anchor":new il(sl.paint_symbol["text-translate-anchor"]),"icon-color-saturation":new il(sl.paint_symbol["icon-color-saturation"]),"icon-color-contrast":new il(sl.paint_symbol["icon-color-contrast"]),"icon-color-brightness-min":new il(sl.paint_symbol["icon-color-brightness-min"]),"icon-color-brightness-max":new il(sl.paint_symbol["icon-color-brightness-max"])}),layout:iv};class rv{constructor(t){this.type=t.property.overrides?t.property.overrides.runtimeType:Yn,this.defaultValue=t}evaluate(t){if(t.formattedSection){const e=this.defaultValue.property.overrides;if(e&&e.hasOverride(t.formattedSection))return e.getOverride(t.formattedSection)}return t.feature&&t.featureState?this.defaultValue.evaluate(t.feature,t.featureState):this.defaultValue.property.specification.default}eachChild(t){this.defaultValue.isConstant()||t(this.defaultValue.value._styleExpression.expression)}outputDefined(){return!1}serialize(){return null}}ba(rv,"FormatSectionOverride",{omit:["defaultValue"]});class ov extends Ml{constructor(e,i,n,r){super(e,nv,i,n,r),this._colorAdjustmentMatrix=t.ad.identity([]),this.hasInitialOcclusionOpacityProperties=void 0!==e.paint&&("icon-occlusion-opacity"in e.paint||"text-occlusion-opacity"in e.paint)}recalculate(t,e){super.recalculate(t,e),"auto"===this.layout.get("icon-rotation-alignment")&&(this.layout._values["icon-rotation-alignment"]="point"!==this.layout.get("symbol-placement")?"map":"viewport"),"auto"===this.layout.get("text-rotation-alignment")&&(this.layout._values["text-rotation-alignment"]="point"!==this.layout.get("symbol-placement")?"map":"viewport"),"auto"===this.layout.get("text-pitch-alignment")&&(this.layout._values["text-pitch-alignment"]=this.layout.get("text-rotation-alignment")),"auto"===this.layout.get("icon-pitch-alignment")&&(this.layout._values["icon-pitch-alignment"]=this.layout.get("icon-rotation-alignment"));const i=this.layout.get("text-writing-mode");if(i){const t=[];for(const e of i)t.indexOf(e)i in t?String(t[i]):""))}(e.properties,r)}createBucket(t){return new jg(t)}queryRadius(){return 0}queryIntersectsFeature(){return!1}_setPaintOverrides(){for(const t of nv.paint.overridableProperties){if(!ov.hasPaintOverride(this.layout,t))continue;const e=this.paint.get(t),i=new rv(e),n=new la(i,e.property.specification,this.scope,this.options);let r=null;r="constant"===e.value.kind||"source"===e.value.kind?new ua("source",n):new ha("composite",n,e.value.zoomStops,e.value._interpolationType),this.paint._values[t]=new tl(e.property,r,e.parameters)}}_handleOverridablePaintPropertyUpdate(t,e,i){return!(!this.layout||e.isDataDriven()||i.isDataDriven())&&ov.hasPaintOverride(this.layout,t)}static hasPaintOverride(t,e){const i=t.get("text-field"),n=nv.paint.properties[e];let r=!1;const o=t=>{for(const e of t)if(n.overrides&&n.overrides.hasOverride(e))return void(r=!0)};if("constant"===i.value.kind&&i.value.value instanceof pr)o(i.value.value.sections);else if("source"===i.value.kind){const t=e=>{r||(e instanceof vr&&gr(e.value)===nr?o(e.value.sections):e instanceof Tr?o(e.sections):e.eachChild(t))},e=i.value;e._styleExpression&&t(e._styleExpression.expression)}return r}getProgramIds(){const t=0!==this.paint.get("icon-opacity").constantOr(1),e=0!==this.paint.get("text-opacity").constantOr(1),i=[];return t&&i.push("symbolIcon"),e&&i.push("symbolSDF"),i}getDefaultProgramParams(t,e,i){return{config:new Wc(this,{zoom:e,lut:i}),overrideFog:!1}}}const sv=new ol({visibility:new il(sl.layout_background.visibility)});var av={paint:new ol({"background-color":new il(sl.paint_background["background-color"]),"background-pattern":new il(sl.paint_background["background-pattern"]),"background-opacity":new il(sl.paint_background["background-opacity"]),"background-emissive-strength":new il(sl.paint_background["background-emissive-strength"])}),layout:sv};const lv=new ol({visibility:new il(sl.layout_raster.visibility)});var cv={paint:new ol({"raster-opacity":new il(sl.paint_raster["raster-opacity"]),"raster-color":new rl(sl.paint_raster["raster-color"]),"raster-color-mix":new il(sl.paint_raster["raster-color-mix"]),"raster-color-range":new il(sl.paint_raster["raster-color-range"]),"raster-hue-rotate":new il(sl.paint_raster["raster-hue-rotate"]),"raster-brightness-min":new il(sl.paint_raster["raster-brightness-min"]),"raster-brightness-max":new il(sl.paint_raster["raster-brightness-max"]),"raster-saturation":new il(sl.paint_raster["raster-saturation"]),"raster-contrast":new il(sl.paint_raster["raster-contrast"]),"raster-resampling":new il(sl.paint_raster["raster-resampling"]),"raster-fade-duration":new il(sl.paint_raster["raster-fade-duration"]),"raster-emissive-strength":new il(sl.paint_raster["raster-emissive-strength"]),"raster-array-band":new il(sl.paint_raster["raster-array-band"]),"raster-elevation":new il(sl.paint_raster["raster-elevation"])}),layout:lv};function dv(e,i,n,r,o,s,a,l){const c=[e,i,1,n,r,1,o,s,1],d=[a,l,1],u=t.bC.adjoint([],c),[h,p,f]=t._.transformMat3(d,d,u);return t.bC.multiply(c,c,[h,0,0,0,p,0,0,0,f])}function uv(e,i,n,r,o,s,a,l){const c=function(e,i,n,r,o,s,a,l){const c=dv(0,0,1,0,1,1,0,1),d=dv(e,i,n,r,o,s,a,l),u=t.bC.adjoint([],c);return t.bC.multiply(d,d,u)}(e,i,n,r,o,s,a,l);return[c[2]/c[8]/uo,c[5]/c[8]/uo]}function hv(t){return[t[0],Math.min(Math.max(t[1],-Pd),Pd)]}class pv extends zn{constructor(t,e,i,n){super(),this.id=t,this.dispatcher=i,this.coordinates=e.coordinates,this.type="image",this.minzoom=0,this.maxzoom=22,this.tileSize=512,this.tiles={},this._loaded=!1,this.onNorthPole=!1,this.onSouthPole=!1,this.setEventedParent(n),this.options=e,this._dirty=!1}load(t,e){if(this._loaded=e||!1,this.fire(new Pn("dataloading",{dataType:"source"})),this.url=this.options.url,!this.url)return t&&(this.coordinates=t),this._loaded=!0,void this._finishLoading();this._imageRequest=an(this.map._requestManager.transformRequest(this.url,Ki.Image),((e,i)=>{this._imageRequest=null,this._loaded=!0,e?this.fire(new $n(e)):i&&(this.image=i instanceof HTMLImageElement?ki.getImageData(i):i,this._dirty=!0,this.width=this.image.width,this.height=this.image.height,t&&(this.coordinates=t),this._finishLoading())}))}loaded(){return this._loaded}updateImage(t){return t.url?(this._imageRequest&&t.url!==this.options.url&&(this._imageRequest.cancel(),this._imageRequest=null),this.options.url=t.url,this.load(t.coordinates,this._loaded),this):this}setTexture(t){if(!(t.handle instanceof WebGLTexture))throw new Error("The provided handle is not a WebGLTexture instance");return this.texture=new Gg(this.map.painter.context,t.handle),this.width=t.dimensions[0],this.height=t.dimensions[1],this._dirty=!1,this._loaded=!0,this._finishLoading(),this}_finishLoading(){this.map&&(this.setCoordinates(this.coordinates),this.fire(new Pn("data",{dataType:"source",sourceDataType:"metadata"})))}onAdd(t){this.map=t,this.load()}onRemove(t){this._imageRequest&&(this._imageRequest.cancel(),this._imageRequest=null),!this.texture||this.texture instanceof Gg||this.texture.destroy(),this.boundsBuffer&&(this.boundsBuffer.destroy(),this.elevatedGlobeVertexBuffer&&this.elevatedGlobeVertexBuffer.destroy(),this.elevatedGlobeIndexBuffer&&this.elevatedGlobeIndexBuffer.destroy())}setCoordinates(t){if(this.coordinates=t,this._boundsArray=void 0,this._unsupportedCoords=!1,!t.length)return this;this.onNorthPole=!1,this.onSouthPole=!1;let e=t[0][1],i=t[0][1];for(const n of t)n[1]>i&&(i=n[1]),n[1]Pd?this.onNorthPole=!0:n1&&(l-=1),new gd(s,l,Math.floor((i+r)/2*a))}(e),this.minzoom=this.maxzoom=this.tileID.z}return this.fire(new Pn("data",{dataType:"source",sourceDataType:"content"})),this}_clear(){this._boundsArray=void 0,this._unsupportedCoords=!1}_prepareData(e){for(const t in this.tiles){const e=this.tiles[t];"loaded"!==e.state&&(e.state="loaded",e.texture=this.texture)}if(this._boundsArray||this.onNorthPole||this.onSouthPole||this._unsupportedCoords)return;const i=eg(new gd(0,0,0),this.map.transform.projection),n=[i.projection.project(this.coordinates[0][0],this.coordinates[0][1]),i.projection.project(this.coordinates[1][0],this.coordinates[1][1]),i.projection.project(this.coordinates[2][0],this.coordinates[2][1]),i.projection.project(this.coordinates[3][0],this.coordinates[3][1])];if(!function(t){const e=t[1].x-t[0].x,i=t[1].y-t[0].y,n=t[2].x-t[1].x,r=t[2].y-t[1].y,o=t[3].x-t[2].x,s=t[3].y-t[2].y,a=t[0].x-t[3].x,l=t[0].y-t[3].y,c=e*r-n*i,d=n*s-o*r,u=o*l-a*s,h=a*i-e*l;return c>0&&d>0&&u>0&&h>0||c{const e=r.projection.project(t[0],t[1]);return ig(r,e)._round()}));this.perspectiveTransform=uv(o.x,o.y,s.x,s.y,a.x,a.y,l.x,l.y);const c=this._boundsArray=new Dl;c.emplaceBack(o.x,o.y,0,0),c.emplaceBack(s.x,s.y,uo,0),c.emplaceBack(l.x,l.y,0,uo),c.emplaceBack(a.x,a.y,uo,uo),this.boundsBuffer&&(this.boundsBuffer.destroy(),this.elevatedGlobeVertexBuffer&&this.elevatedGlobeVertexBuffer.destroy(),this.elevatedGlobeIndexBuffer&&this.elevatedGlobeIndexBuffer.destroy()),this.boundsBuffer=e.createVertexBuffer(c,Jg.members),this.boundsSegments=wc.simpleSegment(0,0,4,2);const d=[],u=function(t){return[hv(t[0]),hv(t[1]),hv(t[2]),hv(t[3])]}(this.coordinates),[h,p,f,m]=function(t){let e=t[0][0],i=e,n=t[0][1],r=n;for(let o=1;oi&&(i=t[o][0]),t[o][1]r&&(r=t[o][1]);return[e,n,i-e,r-n]}(u);{const r=new Dl,[o,s,a,l]=function(t){let e=t[0].x,i=e,n=t[0].y,r=n;for(let o=1;oi&&(i=t[o].x),t[o].yr&&(r=t[o].y);return[e,n,i-e,r-n]}(n),c=t=>[(t.x-o)/a,(t.y-s)/l],[u,_,g,y]=n.map(c),v=function(e,i,n,r,o,s,a,l){const c=dv(0,0,1,0,1,1,0,1),d=dv(e,i,n,r,o,s,a,l),u=t.bC.adjoint([],d);return t.bC.multiply(c,c,u)}(u[0],u[1],_[0],_[1],g[0],g[1],y[0],y[1]);this.elevatedGlobePerspectiveTransform=uv(u[0],u[1],_[0],_[1],g[0],g[1],y[0],y[1]);const x=(e,i)=>{d.push(e.lng);const n=Math.round((e.lng-h)/f*uo),o=Math.round((e.lat-p)/m*uo),s=c(i),a=t._.transformMat3([],[s[0],s[1],1],v),l=Math.round(a[0]/a[2]*uo),u=Math.round(a[1]/a[2]*uo);r.emplaceBack(n,o,l,u)},b=n[3].x-n[0].x,w=n[3].y-n[0].y,T=n[2].x-n[1].x,S=n[2].y-n[1].y;for(let t=0;t{i.emplaceBack(e,n,r);const o=d[e],s=d[n],a=d[r],l=Math.min(Math.min(o,s),a),c=Math.max(Math.max(o,s),a)-l;c>this.maxLongitudeTriangleSize&&(this.maxLongitudeTriangleSize=c),t.push(l+c/2)};for(let t=0;te));i.sort(((e,i)=>t[e]-t[i]));const n=[],r=new Kl;for(let o=0;o{o.segments.push({vertexOffset:0,primitiveOffset:t,vertexLength:e.segments[0].vertexLength,primitiveLength:i,sortKey:void 0,vaos:{}})},a=.51*this.maxLongitudeTriangleSize;if(Math.abs(i[0]-n)0){const n=function(e,i){const n=i.worldSize,r=Cd(1,0)*n*kd(i.center.lat,i.zoom)/Gu(n),o=Cd(1,i.center.lat)*n,s=t.ad.identity([]);return t.ad.rotateY(s,s,Ge(i.center.lng)),t.ad.rotateX(s,s,Ge(i.center.lat)),t.ad.translate(s,s,[0,0,ed]),t.ad.scale(s,s,[r,r,r*o]),t.ad.translate(s,s,[i.point.x-.5*n,i.point.y-.5*n,0]),t.ad.multiply(s,s,e),t.ad.multiply(s,i.globeMatrix,s)}(e,i);return function(e,i,n){const r=(e,i,n)=>{const r=t._.length(e),o=t._.length(i),s=ku(e,i,n);return t._.scale(s,s,1/t._.length(s)*Vn(r,o,n))},o=r([e[0],e[1],e[2]],[i[0],i[1],i[2]],n),s=r([e[4],e[5],e[6]],[i[4],i[5],i[6]],n),a=r([e[8],e[9],e[10]],[i[8],i[9],i[10]],n),l=ku([e[12],e[13],e[14]],[i[12],i[13],i[14]],n);return[o[0],o[1],o[2],0,s[0],s[1],s[2],0,a[0],a[1],a[2],0,l[0],l[1],l[2],1]}(o,n,r)}return o}function kv(t,e,i,n){const r=wu.projectAabbCorners(n,i);let o=Number.MAX_VALUE,s=-1;for(let t=0;tnew Ue(r[t][0],r[t][1]);let l;switch(s){case 0:case 6:l=[a(1),a(5),a(4),a(7),a(3),a(2),a(1)];break;case 1:case 7:l=[a(0),a(4),a(5),a(6),a(2),a(3),a(0)];break;case 3:case 5:l=[a(1),a(0),a(4),a(7),a(6),a(2),a(1)];break;default:l=[a(1),a(5),a(6),a(7),a(3),a(0),a(1)]}if(Yd(t,l))return o}const Dv=Ll([{name:"a_pos_3f",components:3,type:"Float32"}]),zv=Ll([{name:"a_color_3f",components:3,type:"Float32"}]),Rv=Ll([{name:"a_color_4f",components:4,type:"Float32"}]),Ov=Ll([{name:"a_uv_2f",components:2,type:"Float32"}]),Bv=Ll([{name:"a_normal_3f",components:3,type:"Float32"}]),Fv=Ll([{name:"a_normal_matrix0",components:4,type:"Float32"},{name:"a_normal_matrix1",components:4,type:"Float32"},{name:"a_normal_matrix2",components:4,type:"Float32"},{name:"a_normal_matrix3",components:4,type:"Float32"}]),Nv=Ll([{name:"a_pbr",components:4,type:"Uint16"},{name:"a_heightBasedEmissiveStrength",components:3,type:"Float32"}]);class Uv{constructor(t,e,i,n){this.message=(t?`${t}: `:"")+i,n&&(this.identifier=n),null!=e&&e.__line__&&(this.line=e.__line__)}}function jv(t,e){const i=-1===t.indexOf("://");try{return new URL(t,i&&e?"http://example.com":void 0),!0}catch(t){return!1}}class Vv{constructor(t,e){this.feature=t,this.instancedDataOffset=e,this.instancedDataCount=0,this.rotation=[0,0,0],this.scale=[1,1,1],this.translation=[0,0,0]}}class Gv{constructor(){this.instancedDataArray=new oc,this.instancesEvaluatedElevation=[],this.features=[],this.idToFeaturesIndex={}}}class Zv{constructor(t){this.zoom=t.zoom,this.canonical=t.canonical,this.layers=t.layers,this.layerIds=this.layers.map((t=>t.fqid)),this.projection=t.projection,this.index=t.index,this.hasZoomDependentProperties=this.layers[0].isZoomDependent(),this.stateDependentLayerIds=this.layers.filter((t=>t.isStateDependent())).map((t=>t.id)),this.hasPattern=!1,this.instancesPerModel={},this.validForExaggeration=0,this.maxVerticalOffset=0,this.maxScale=0,this.maxHeight=0,this.lookupDim=this.zoom>this.canonical.z?256:this.zoom>15?75:100,this.instanceCount=0,this.terrainElevationMin=0,this.terrainElevationMax=0,this.validForDEMTile={id:null,timestamp:0},this.modelUris=[],this.modelsRequested=!1,this.activeReplacements=[],this.replacementUpdateTime=0}updateFootprints(t,e){}populate(t,e,i,n){this.tileToMeter=zd(i);const r=this.layers[0]._featureFilter.needGeometry;this.lookup=new Uint8Array(this.lookupDim*this.lookupDim);for(const{feature:o,id:s,index:a,sourceLayerIndex:l}of t){const t=null!=s?s:o.properties&&o.properties.hasOwnProperty("id")?o.properties.id:void 0,c=Zd(o,r);if(!this.layers[0]._featureFilter.filter(new Ha(this.zoom),c,i))continue;const d={id:t,sourceLayerIndex:l,index:a,geometry:r?c.geometry:Gd(o,i,n),properties:o.properties,type:o.type,patterns:{}},u=this.addFeature(d,d.geometry,c);u&&e.featureIndex.insert(o,d.geometry,a,l,this.index,this.instancesPerModel[u].instancedDataArray.length,uo/32)}this.lookup=null}update(t,e,i,n){for(const e in this.instancesPerModel){const i=this.instancesPerModel[e];for(const e in t)i.idToFeaturesIndex.hasOwnProperty(e)&&(this.evaluate(i.features[i.idToFeaturesIndex[e]],t[e],i,!0),this.uploaded=!1)}this.maxHeight=0}updateZoomBasedPaintProperties(){if(!this.hasZoomDependentProperties)return!1;let e=!1;for(const i in this.instancesPerModel){const n=this.instancesPerModel[i];for(const i of n.features){const r=this.layers[0],o=i.feature,s=this.canonical,a=r.paint.get("model-rotation").evaluate(o,{},s),l=r.paint.get("model-scale").evaluate(o,{},s),c=r.paint.get("model-translation").evaluate(o,{},s);t._.exactEquals(i.rotation,a)&&t._.exactEquals(i.scale,l)&&t._.exactEquals(i.translation,c)||(this.evaluate(i,i.featureStates,n,!0),e=!0)}}return e}updateReplacement(t,e,i){if(e.updateTime===this.replacementUpdateTime)return!1;this.replacementUpdateTime=e.updateTime;const n=e.getReplacementRegionsForTile(t.toUnwrapped(),!0);if(Pp(this.activeReplacements,n))return!1;this.activeReplacements=n;let r=!1;for(const e in this.instancesPerModel){const n=this.instancesPerModel[e],o=n.instancedDataArray;for(const e of n.features){const n=e.instancedDataOffset,s=e.instancedDataCount;for(let e=0;euo?a-uo:a;const l=Math.floor(a),c=o.float32[s+1];let d=!1;for(const e of this.activeReplacements)if(!(e.orderl||l>e.max.x||e.min.y>c||c>e.max.y)&&(d=Op(Rp(l,c,t.canonical,e.footprintTileId.canonical),e),d))break;o.float32[s]=d?a+uo:a,r=r||d}}}return r}isEmpty(){for(const t in this.instancesPerModel)if(0!==this.instancesPerModel[t].instancedDataArray.length)return!1;return!0}uploadPending(){return!this.uploaded}upload(t){if(!this.uploaded)for(const e in this.instancesPerModel){const i=this.instancesPerModel[e];i.instancedDataArray.length=uo||e.y=uo)continue;const t=(this.lookupDim-1)/uo,i=this.lookupDim*(e.y*t|0)+e.x*t|0;if(this.lookup){if(0!==this.lookup[i])continue;this.lookup[i]=1}this.instanceCount++;const n=s.length;s.resize(n+1),o.instancesEvaluatedElevation.push(0),s.float32[16*n]=e.x,s.float32[16*n+1]=e.y}return a.instancedDataCount=o.instancedDataArray.length-a.instancedDataOffset,a.instancedDataCount>0&&(t.id&&(o.idToFeaturesIndex[t.id]=o.features.length),o.features.push(a),this.evaluate(a,{},o,!1)),r}getModelUris(){return this.modelUris}evaluate(t,e,i,n){const r=this.layers[0],o=t.feature,s=this.canonical,a=t.rotation=r.paint.get("model-rotation").evaluate(o,e,s),l=t.scale=r.paint.get("model-scale").evaluate(o,e,s),c=t.translation=r.paint.get("model-translation").evaluate(o,e,s),d=r.paint.get("model-color").evaluate(o,e,s);d.a=r.paint.get("model-color-mix-intensity").evaluate(o,e,s);const u=[];this.maxVerticalOffset10?this.tileToMeter:zd(s,p)),a[o+4]=c[0],a[o+5]=c[1],a[o+6]=c[2]+l,a[o+7]=u[0],a[o+8]=u[1],a[o+9]=u[2],a[o+10]=u[4],a[o+11]=u[5],a[o+12]=u[6],a[o+13]=u[8],a[o+14]=u[9],a[o+15]=u[10],i.instancesEvaluatedElevation[r]=c[2]}}}ba(Zv,"ModelBucket",{omit:["layers"]}),ba(Gv,"PerModelAttributes"),ba(Vv,"ModelFeature");const qv=new ol({visibility:new il(sl.layout_model.visibility),"model-id":new nl(sl.layout_model["model-id"])});var Hv={paint:new ol({"model-opacity":new il(sl.paint_model["model-opacity"]),"model-rotation":new nl(sl.paint_model["model-rotation"]),"model-scale":new nl(sl.paint_model["model-scale"]),"model-translation":new nl(sl.paint_model["model-translation"]),"model-color":new nl(sl.paint_model["model-color"]),"model-color-mix-intensity":new nl(sl.paint_model["model-color-mix-intensity"]),"model-type":new il(sl.paint_model["model-type"]),"model-cast-shadows":new il(sl.paint_model["model-cast-shadows"]),"model-receive-shadows":new il(sl.paint_model["model-receive-shadows"]),"model-ambient-occlusion-intensity":new il(sl.paint_model["model-ambient-occlusion-intensity"]),"model-emissive-strength":new nl(sl.paint_model["model-emissive-strength"]),"model-roughness":new nl(sl.paint_model["model-roughness"]),"model-height-based-emissive-strength-multiplier":new nl(sl.paint_model["model-height-based-emissive-strength-multiplier"]),"model-cutoff-fade-range":new il(sl.paint_model["model-cutoff-fade-range"]),"model-front-cutoff":new il(sl.paint_model["model-front-cutoff"])}),layout:qv};const Wv=64,Yv={CoordinateSpaceTile:1,CoordinateSpaceYUp:2,HasMapboxMeshFeatures:4,HasMeshoptCompression:8};function Xv(e,i,n,r,o,s,a,l,c,d=!1){const u=n.zoom,h=n.project(r),p=kd(r.lat,u),f=1/p;t.ad.identity(e),t.ad.translate(e,e,[h.x+a[0]*f,h.y+a[1]*f,a[2]]);let m=1,_=1;const g=n.worldSize;if(d){if("mercator"===n.projection.name){let e=0;n.elevation&&(e=n.elevation.getAtPointOrZero(new Rd(h.x/g,h.y/g),0));const i=t.aA.transformMat4([],[h.x,h.y,e,1],n.projMatrix)[3]/n.cameraToCenterDistance;m=i,_=i*kd(n.center.lat,u)}else if("globe"===n.projection.name){const i=$v(e,n),o=t.ad.multiply([],n.projMatrix,i),s=[0,0,0,1];t.aA.transformMat4(s,s,o);const a=s[3]/n.cameraToCenterDistance,l=Hu(u),c=n.projection.pixelsPerMeter(r.lat,g)*kd(r.lat,u),d=n.projection.pixelsPerMeter(n.center.lat,g)*kd(n.center.lat,u);m=a/Vn(c,$d(n.center.lat),l),_=a*p/c,m*=d,_*=d}}else m=f;t.ad.scale(e,e,[m,m,_]);const y=[...e],v=i.orientation,x=[];if(Lv(x,[v[0]+o[0],v[1]+o[1],v[2]+o[2]],s),t.ad.multiply(e,y,x),l&&n.elevation){let o=0;const s=[];if(c&&n.elevation){o=function(e,i,n,r,o){const s=i.elevation;if(!s)return 0;const a=wu.projectAabbCorners(n,r),l=Cd(1,o.lat)*i.worldSize,c=function(e,i){const n=[0,0,1],r=[{corners:[0,1,3,2],dotProductWithUp:0},{corners:[1,5,2,6],dotProductWithUp:0},{corners:[0,4,1,5],dotProductWithUp:0},{corners:[2,6,3,7],dotProductWithUp:0},{corners:[4,7,5,6],dotProductWithUp:0},{corners:[0,3,4,7],dotProductWithUp:0}];for(const o of r){const r=e[o.corners[0]],s=e[o.corners[1]],a=e[o.corners[2]],l=[s[0]-r[0],s[1]-r[1],i*(s[2]-r[2])],c=t._.cross(l,l,[a[0]-r[0],a[1]-r[1],i*(a[2]-r[2])]);t._.normalize(c,c),o.dotProductWithUp=t._.dot(c,n)}return r.sort(((t,e)=>t.dotProductWithUp-e.dotProductWithUp)),r[0].corners}(a,l),d=a[c[0]],u=a[c[1]],h=a[c[2]],p=a[c[3]],f=s.getAtPointOrZero(new Rd(d[0]/i.worldSize,d[1]/i.worldSize),0),m=s.getAtPointOrZero(new Rd(u[0]/i.worldSize,u[1]/i.worldSize),0),_=s.getAtPointOrZero(new Rd(h[0]/i.worldSize,h[1]/i.worldSize),0),g=s.getAtPointOrZero(new Rd(p[0]/i.worldSize,p[1]/i.worldSize),0),y=(f+g)/2,v=(m+_)/2;return y>v?m=e.gl.NEAREST_MIPMAP_NEAREST}),t.uploaded=!0,t.image=null)}function Jv(t,e,i){t.indexBuffer=e.createIndexBuffer(t.indexArray,!1,!0),t.vertexBuffer=e.createVertexBuffer(t.vertexArray,Dv.members,!1,!0),t.normalArray&&(t.normalBuffer=e.createVertexBuffer(t.normalArray,Bv.members,!1,!0)),t.texcoordArray&&(t.texcoordBuffer=e.createVertexBuffer(t.texcoordArray,Ov.members,!1,!0)),t.colorArray&&(t.colorBuffer=e.createVertexBuffer(t.colorArray,(12===t.colorArray.bytesPerElement?zv:Rv).members,!1,!0)),t.featureArray&&(t.pbrBuffer=e.createVertexBuffer(t.featureArray,Nv.members,!0)),t.segments=wc.simpleSegment(0,0,t.vertexArray.length,t.indexArray.length);const n=t.material;n.pbrMetallicRoughness.baseColorTexture&&Kv(n.pbrMetallicRoughness.baseColorTexture,e),n.pbrMetallicRoughness.metallicRoughnessTexture&&Kv(n.pbrMetallicRoughness.metallicRoughnessTexture,e),n.normalTexture&&Kv(n.normalTexture,e),n.occlusionTexture&&Kv(n.occlusionTexture,e,i),n.emissionTexture&&Kv(n.emissionTexture,e)}function Qv(t,e,i){if(t.meshes)for(const n of t.meshes)Jv(n,e,i);if(t.children)for(const n of t.children)Qv(n,e,i)}function tx(t){if(t.meshes)for(const e of t.meshes)e.indexArray.destroy(),e.vertexArray.destroy(),e.colorArray&&e.colorArray.destroy(),e.normalArray&&e.normalArray.destroy(),e.texcoordArray&&e.texcoordArray.destroy(),e.featureArray&&e.featureArray.destroy();if(t.children)for(const e of t.children)tx(e)}function ex(t){if(t.meshes)for(const i of t.meshes)i.vertexBuffer&&(i.vertexBuffer.destroy(),i.indexBuffer.destroy(),i.normalBuffer&&i.normalBuffer.destroy(),i.texcoordBuffer&&i.texcoordBuffer.destroy(),i.colorBuffer&&i.colorBuffer.destroy(),i.pbrBuffer&&i.pbrBuffer.destroy(),i.segments.destroy(),i.material&&((e=i.material).pbrMetallicRoughness.baseColorTexture&&e.pbrMetallicRoughness.baseColorTexture.gfxTexture&&e.pbrMetallicRoughness.baseColorTexture.gfxTexture.destroy(),e.pbrMetallicRoughness.metallicRoughnessTexture&&e.pbrMetallicRoughness.metallicRoughnessTexture.gfxTexture&&e.pbrMetallicRoughness.metallicRoughnessTexture.gfxTexture.destroy(),e.normalTexture&&e.normalTexture.gfxTexture&&e.normalTexture.gfxTexture.destroy(),e.emissionTexture&&e.emissionTexture.gfxTexture&&e.emissionTexture.gfxTexture.destroy(),e.occlusionTexture&&e.occlusionTexture.gfxTexture&&e.occlusionTexture.gfxTexture.destroy()));var e;if(t.children)for(const e of t.children)ex(e)}class ix{constructor(t){this._callback=t,this._triggered=!1,"undefined"!=typeof MessageChannel&&(this._channel=new MessageChannel,this._channel.port2.onmessage=()=>{this._triggered=!1,this._callback()})}trigger(){this._triggered||(this._triggered=!0,this._channel?this._channel.port1.postMessage(!0):setTimeout((()=>{this._triggered=!1,this._callback()}),0))}remove(){this._channel=void 0,this._callback=()=>{}}}class nx{constructor(){this.tasks={},this.taskQueue=[],ai(["process"],this),this.invoker=new ix(this.process),this.nextId=0}add(t,e){const i=this.nextId++,n=function({type:t,isSymbolTile:e,zoom:i}){return i=i||0,"message"===t?0:"maybePrepare"!==t||e?"parseTile"!==t||e?"parseTile"===t&&e?300-i:"maybePrepare"===t&&e?400-i:500:200-i:100-i}(e);if(0===n){try{t()}finally{}return null}return this.tasks[i]={fn:t,metadata:e,priority:n,id:i},this.taskQueue.push(i),this.invoker.trigger(),{cancel:()=>{delete this.tasks[i]}}}process(){try{if(this.taskQueue=this.taskQueue.filter((t=>!!this.tasks[t])),!this.taskQueue.length)return;const t=this.pick();if(null===t)return;const e=this.tasks[t];if(delete this.tasks[t],this.taskQueue.length&&this.invoker.trigger(),!e)return;e.fn()}finally{}}pick(){let t=null,e=1/0;for(let i=0;i{i&&delete this.callbacks[s],this.target.postMessage({id:s,type:"",targetMapId:n,sourceMapId:this.mapId})}}}receive(t){const e=t.data,i=e.id;if(i&&(!e.targetMapId||this.mapId===e.targetMapId))if(""===e.type){const t=this.cancelCallbacks[i];delete this.cancelCallbacks[i],t&&t.cancel()}else if(e.mustQueue||gi()){const t=this.callbacks[i],n=this.scheduler.add((()=>this.processTask(i,e)),t&&t.metadata||{type:"message"});n&&(this.cancelCallbacks[i]=n)}else this.processTask(i,e)}processTask(t,e){if(delete this.cancelCallbacks[t],""===e.type){const i=this.callbacks[t];delete this.callbacks[t],i&&(e.error?i(Ea(e.error)):i(null,Ea(e.data)))}else{const i=new Set,n=e.hasCallback?(e,n)=>{this.target.postMessage({id:t,type:"",sourceMapId:this.mapId,error:e?Sa(e):null,data:Sa(n,i)},i)}:t=>{},r=Ea(e.data);if(this.parent[e.type])this.parent[e.type](e.sourceMapId,r,n);else if(this.parent.getWorkerSource){const t=e.type.split(".");this.parent.getWorkerSource(e.sourceMapId,t[0],r.source,r.scope)[t[1]](r,n)}else n(new Error(`Could not find function ${e.type}`))}}remove(){this.scheduler.remove(),this.target.removeEventListener("message",this.receive,!1)}}class ox{constructor(t,e){this.workerPool=t,this.actors=[],this.currentActor=0,this.id=ni();const i=this.workerPool.acquire(this.id);for(let t=0;t{this.ready=!0}))}broadcast(t,e,i){Qe(this.actors,((i,n)=>{i.send(t,e,n)}),i=i||function(){})}getActor(){return this.currentActor=(this.currentActor+1)%this.actors.length,this.actors[this.currentActor]}remove(){this.actors.forEach((t=>{t.remove()})),this.actors=[],this.workerPool.release(this.id)}}ox.Actor=rx;var sx={workerUrl:"",workerClass:null,workerParams:void 0};function ax(){return null!=sx.workerClass?new sx.workerClass:new self.Worker(sx.workerUrl,sx.workerParams)}const lx="mapboxgl_preloaded_worker_pool";class cx{constructor(){this.active={}}acquire(t){if(!this.workers)for(this.workers=[];this.workers.length{t.terminate()})),this.workers=null)}isPreloaded(){return!!this.active[lx]}numActive(){return Object.keys(this.active).length}}let dx;function ux(){return dx||(dx=new cx),dx}cx.workerCount=2;let hx,px,fx,mx,_x,gx=null;function yx(){return gi()&&self.worker&&self.worker.dracoUrl?self.worker.dracoUrl:px||n.DRACO_URL}function vx(){if(gi()&&self.worker&&self.worker.meshoptUrl)return self.worker.meshoptUrl;if(mx)return mx;const t=new Uint8Array([0,97,115,109,1,0,0,0,1,4,1,96,0,0,3,3,2,0,0,5,3,1,0,1,12,1,0,10,22,2,12,0,65,0,65,0,65,0,252,10,0,0,11,7,0,65,0,253,15,26,11]);if("object"!=typeof WebAssembly)throw new Error("WebAssembly not supported, cannot instantiate meshoptimizer");return mx=WebAssembly.validate(t)?n.MESHOPT_SIMD_URL:n.MESHOPT_URL,mx}const xx={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},bx={5120:"DT_INT8",5121:"DT_UINT8",5122:"DT_INT16",5123:"DT_UINT16",5125:"DT_UINT32",5126:"DT_FLOAT32"},wx={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16};function Tx(t,e,i){const n=i.json.bufferViews.length,r=i.buffers.length;e.bufferView=n,i.json.bufferViews[n]={buffer:r,byteLength:t.byteLength},i.buffers[r]=t}const Sx="KHR_draco_mesh_compression";function Ex(t,e){const i=t.extensions&&t.extensions[Sx];if(!i)return;const n=new fx.Decoder,r=$x(e,i.bufferView),o=new fx.Mesh;if(!n.DecodeArrayToMesh(r,r.byteLength,o))throw new Error("Failed to decode Draco mesh");const s=e.json.accessors[t.indices],a=xx[s.componentType],l=s.count*a.BYTES_PER_ELEMENT,c=fx._malloc(l);a===Uint16Array?n.GetTrianglesUInt16Array(o,l,c):n.GetTrianglesUInt32Array(o,l,c),Tx(fx.memory.buffer.slice(c,c+l),s,e),fx._free(c);for(const r of Object.keys(i.attributes)){const s=n.GetAttributeByUniqueId(o,i.attributes[r]),a=e.json.accessors[t.attributes[r]],l=bx[a.componentType],c=a.count*wx[a.type]*xx[a.componentType].BYTES_PER_ELEMENT,d=fx._malloc(c);n.GetAttributeDataArrayForAllPoints(o,s,fx[l],c,d),Tx(fx.memory.buffer.slice(d,d+c),a,e),fx._free(d)}n.destroy(),o.destroy(),delete t.extensions[Sx]}const Mx="EXT_meshopt_compression";function Cx(t,e){if(!t.extensions||!t.extensions[Mx])return;const i=t.extensions[Mx],n=new Uint8Array(e.buffers[i.buffer],i.byteOffset||0,i.byteLength||0),r=new Uint8Array(i.count*i.byteStride);_x.decodeGltfBuffer(r,i.count,i.byteStride,n,i.mode,i.filter),t.buffer=e.buffers.length,t.byteOffset=0,e.buffers[t.buffer]=r.buffer,delete t.extensions[Mx]}const Ax=1179937895,Ix=new TextDecoder("utf8");function Lx(t,e){return new URL(t,e).href}function Px(t,e,i,n){return fetch(Lx(t.uri,n)).then((t=>t.arrayBuffer())).then((t=>{e.buffers[i]=t}))}function $x(t,e){const i=t.json.bufferViews[e];return new Uint8Array(t.buffers[i.buffer],i.byteOffset||0,i.byteLength)}function kx(t,e,i,n){if(t.uri){const r=Lx(t.uri,n);return fetch(r).then((t=>t.blob())).then((t=>createImageBitmap(t))).then((t=>{e.images[i]=t}))}if(void 0!==t.bufferView){const n=$x(e,t.bufferView),r=new Blob([n],{type:t.mimeType});return createImageBitmap(r).then((t=>{e.images[i]=t}))}}function Dx(t,e=0,i){const n={json:null,images:[],buffers:[]};if(new Uint32Array(t,e,1)[0]===Ax){const i=new Uint32Array(t,e);let r=2;const o=(i[r++]>>2)-3,s=i[r++]>>2;if(r++,n.json=JSON.parse(Ix.decode(i.subarray(r,r+s))),r+=s,r{const t=[],e=a&&a.includes(Sx),r=a&&a.includes(Mx);if(e&&t.push(function(){if(!fx)return hx||(hx=function(t){let e,i=null;function n(){e=new Uint8Array(i.buffer)}function r(){throw new Error("Unexpected Draco error.")}const o={a:{a:r,d:function(t,i,n){return e.copyWithin(t,i,i+n)},c:function(t){const r=e.length,o=Math.max(t>>>0,Math.ceil(1.2*r)),s=Math.ceil((o-r)/65536);try{return i.grow(s),n(),!0}catch(t){return!1}},b:r}};return(WebAssembly.instantiateStreaming?WebAssembly.instantiateStreaming(t,o):t.then((t=>t.arrayBuffer())).then((t=>WebAssembly.instantiate(t,o)))).then((t=>{const{Rb:r,Qb:o,P:s,T:a,X:l,Ja:c,La:d,Qa:u,Va:h,Wa:p,eb:f,jb:m,f:_,e:g,yb:y,zb:v,Ab:x,Bb:b,Db:w,Gb:T}=t.instance.exports;i=g;const S=(()=>{let t=0,i=0,n=0,s=0;return a=>{n&&(r(s),r(t),i+=n,n=t=0),t||(i+=128,t=o(i));const l=a.length+7&-8;let c=t;l>=i&&(n=l,c=s=o(l));for(let t=0;t{fx=t,hx=void 0})))}()),r&&t.push(function(){if(_x)return;const t=function(t){let e;const i=WebAssembly.instantiateStreaming(t,{}).then((t=>{e=t.instance,e.exports.__wasm_call_ctors()})),n={NONE:"",OCTAHEDRAL:"meshopt_decodeFilterOct",QUATERNION:"meshopt_decodeFilterQuat",EXPONENTIAL:"meshopt_decodeFilterExp"},r={ATTRIBUTES:"meshopt_decodeVertexBuffer",TRIANGLES:"meshopt_decodeIndexBuffer",INDICES:"meshopt_decodeIndexSequence"};return{ready:i,supported:!0,decodeGltfBuffer(t,i,o,s,a,l){!function(t,e,i,n,r,o,s){const a=t.exports.sbrk,l=n+3&-4,c=a(l*r),d=a(o.length),u=new Uint8Array(t.exports.memory.buffer);u.set(o,d);const h=e(c,n,r,d,o.length);if(0===h&&s&&s(c,l,r),i.set(u.subarray(c,c+n*r)),a(c-a(0)),0!==h)throw new Error(`Malformed buffer data: ${h}`)}(e,e.exports[r[a]],t,i,o,s,e.exports[n[l]])}}}(fetch(vx()));return t.ready.then((()=>{_x=t}))}()),o)for(let e=0;e{if(e&&s)for(const{primitives:t}of s)for(const e of t)Ex(e,n);if(r&&s&&l)for(const t of l)Cx(t,n);return n}))}))}function zx(t,e){const i=t.json.bufferViews[e.bufferView],n=xx[e.componentType];return new n(t.buffers[i.buffer],(e.byteOffset||0)+(i.byteOffset||0),e.count*(i.byteStride&&i.byteStride!==wx[e.type]*n.BYTES_PER_ELEMENT?i.byteStride/n.BYTES_PER_ELEMENT:wx[e.type]))}function Rx(t,e,i,n){const r=xx[e.componentType],o=function(t){switch(t){case Int8Array:return 1/127;case Uint8Array:return 1/255;case Int16Array:return 1/32767;case Uint16Array:return 1/65535;default:return 1}}(r),s=t.json.bufferViews[e.bufferView],a=s.byteStride?s.byteStride/r.BYTES_PER_ELEMENT:wx[e.type],l=i.float32,c=l.length/i.capacity;for(let t=0,i=0;t0){for(let r=0;r0){o.texcoordArray=new ic;const t=e.json.accessors[r.TEXCOORD_0];o.texcoordArray.resize(t.count);const i=zx(e,t);Rx(e,t,o.texcoordArray,i)}if(void 0!==r._FEATURE_ID_RGBA4444){const t=e.json.accessors[r._FEATURE_ID_RGBA4444];e.json.extensionsUsed&&e.json.extensionsUsed.includes("EXT_meshopt_compression")&&(o.featureData=zx(e,t))}void 0!==r._FEATURE_RGBA4444&&(o.featureData=new Uint32Array(zx(e,e.json.accessors[r._FEATURE_RGBA4444]).buffer));const u=t.material;return o.material=function(t,e){const{emissiveFactor:i=[0,0,0],alphaMode:n="OPAQUE",alphaCutoff:r=.5,normalTexture:o,occlusionTexture:s,emissiveTexture:a,doubleSided:l}=t,{baseColorFactor:c=[1,1,1,1],metallicFactor:d=1,roughnessFactor:u=1,baseColorTexture:h,metallicRoughnessTexture:p}=t.pbrMetallicRoughness||{},f=s?e[s.index]:void 0;if(s&&s.extensions&&s.extensions.KHR_texture_transform&&f){const t=s.extensions.KHR_texture_transform;f.offsetScale=[t.offset[0],t.offset[1],t.scale[0],t.scale[1]]}return{pbrMetallicRoughness:{baseColorFactor:new Un(...c),metallicFactor:d,roughnessFactor:u,baseColorTexture:h?e[h.index]:void 0,metallicRoughnessTexture:p?e[p.index]:void 0},doubleSided:l,emissiveFactor:i,alphaMode:n,alphaCutoff:r,normalTexture:o?e[o.index]:void 0,occlusionTexture:f,emissionTexture:a?e[a.index]:void 0,defined:void 0===t.defined}}(void 0!==u?e.json.materials[u]:{defined:!1},i),o}function Bx(e,i,n){const{matrix:r,rotation:o,translation:s,scale:a,mesh:l,extras:c,children:d}=e,u={};if(u.matrix=r||t.ad.fromRotationTranslationScale([],o||[0,0,0,1],s||[0,0,0],a||[1,1,1]),void 0!==l){u.meshes=n[l];const t=u.anchor=[0,0];for(const e of u.meshes){const{min:i,max:n}=e.aabb;t[0]+=i[0]+n[0],t[1]+=i[1]+n[1]}t[0]=Math.floor(t[0]/u.meshes.length/2),t[1]=Math.floor(t[1]/u.meshes.length/2)}if(c&&(c.id&&(u.id=c.id),c.lights&&(u.lights=function(t){if(!t.length)return[];const e=function(t){const e=atob(t),i=new Uint8Array(e.length);for(let t=0;t1&&n[n.length-1].equals(n[0])&&n.pop();let r=0;for(let t=0;t0&&n.reverse();const o=xh(n.flatMap((t=>[t.x,t.y])),[]);return 0===o.length?null:{vertices:n,indices:o}}function Ux(e,i){const n=[],r=[];let o=0;const s=[];for(const a of e){o=n.length;const e=a.vertexArray.float32,l=a.indexArray.uint16;for(let r=0;r0&&([r[t+1],r[t+2]]=[r[t+2],r[t+1]])}return{vertices:n,indices:r}}function jx(t){const e=function(t,e){const i=[],n=WebGL2RenderingContext;if(t.json.textures)for(const r of t.json.textures){const o={magFilter:n.LINEAR,minFilter:n.NEAREST,wrapS:n.REPEAT,wrapT:n.REPEAT};void 0!==r.sampler&&Object.assign(o,t.json.samplers[r.sampler]),i.push({image:e[r.source],sampler:o,uploaded:!1})}return i}(t,t.images),i=function(t,e){const i=[];for(const n of t.json.meshes){const r=[];for(const i of n.primitives)r.push(Ox(i,t,e));i.push(r)}return i}(t,e),{scenes:n,scene:r,nodes:o}=t.json,s=n?n[r||0].nodes:o,a=[];for(const e of s)a.push(Bx(o[e],t,i));return function(t,e,i){const n={},r=new Set;for(let o=0;o0){const e=Array.from(r.values()).sort(((t,e)=>t-e));for(let i=e.length-1;i>=0;i--)t.splice(e[i],1)}}(a,s,t.json.nodes),a}function Vx(t){t.heightmap=new Float32Array(4096),t.heightmap.fill(-1);const e=t.vertexArray.float32,i=t.aabb.min[0]-1,n=t.aabb.min[1]-1,r=Wv/(t.aabb.max[0]-i+2),o=Wv/(t.aabb.max[1]-n+2);for(let s=0;st.heightmap[c*Wv+l]&&(t.heightmap[c*Wv+l]=a)}}function Gx(e,i){const n={};n.indexArray=new Kl,n.indexArray.reserve(4*e.length),n.vertexArray=new Bl,n.vertexArray.reserve(10*e.length),n.colorArray=new Ol,n.vertexArray.reserve(10*e.length);let r=0;for(const o of e){const e=Math.min(10,Math.max(4,1.3*o.height))*i,s=[-o.normal[1],o.normal[0],0],a=Math.min(.29,.1*o.width/o.depth),l=o.width-2*o.depth*i*(a+.01),c=t._.scaleAndAdd([],o.pos,s,l/2),d=t._.scaleAndAdd([],o.pos,s,-l/2),u=[c[0],c[1],c[2]+o.height],h=[d[0],d[1],d[2]+o.height],p=t._.scaleAndAdd([],o.normal,s,a);t._.scale(p,p,e);const f=t._.scaleAndAdd([],o.normal,s,-a);t._.scale(f,f,e),t._.add(p,c,p),t._.add(f,d,f),c[2]+=.1,d[2]+=.1,n.vertexArray.emplaceBack(p[0],p[1],p[2]),n.vertexArray.emplaceBack(f[0],f[1],f[2]),n.vertexArray.emplaceBack(c[0],c[1],c[2]),n.vertexArray.emplaceBack(d[0],d[1],d[2]),n.vertexArray.emplaceBack(u[0],u[1],u[2]),n.vertexArray.emplaceBack(h[0],h[1],h[2]),n.vertexArray.emplaceBack(c[0],c[1],c[2]),n.vertexArray.emplaceBack(d[0],d[1],d[2]),n.vertexArray.emplaceBack(p[0],p[1],p[2]),n.vertexArray.emplaceBack(f[0],f[1],f[2]);const m=l/e/2;n.colorArray.emplaceBack(-m-a,-1,m,.8),n.colorArray.emplaceBack(m+a,-1,m,.8),n.colorArray.emplaceBack(-m,0,m,1.3),n.colorArray.emplaceBack(m,0,m,1.3),n.colorArray.emplaceBack(m+a,-.8,m,.7),n.colorArray.emplaceBack(m+a,-.8,m,.7),n.colorArray.emplaceBack(0,0,m,1.3),n.colorArray.emplaceBack(0,0,m,1.3),n.colorArray.emplaceBack(m+a,-1.2,m,.8),n.colorArray.emplaceBack(m+a,-1.2,m,.8),n.indexArray.emplaceBack(6+r,4+r,8+r),n.indexArray.emplaceBack(7+r,9+r,5+r),n.indexArray.emplaceBack(0+r,1+r,2+r),n.indexArray.emplaceBack(1+r,3+r,2+r),r+=10}const o={defined:!0,emissiveFactor:[0,0,0]},s={};return s.baseColorFactor=Un.white,o.pbrMetallicRoughness=s,n.material=o,n.aabb=new wu([1/0,1/0,1/0],[-1/0,-1/0,-1/0]),n}const Zx=new Float32Array(262144),qx=new Uint8Array(262144);function Hx(t){let e=0;if(t.meshes)for(const i of t.meshes)e=Math.max(e,i.aabb.max[2]);if(t.children)for(const i of t.children)e=Math.max(e,Hx(i));return e}function Wx(t,e,i){if(t.meshes)for(const n of t.meshes)n.aabb.min[0]!==1/0&&i.insert(e,n.aabb.min[0],n.aabb.min[1],n.aabb.max[0],n.aabb.max[1]);if(t.children)for(const n of t.children)Wx(n,e,i)}const Yx=["","wall","door","roof","window","lamp","logo"];class Xx{constructor(t){this.node=t,this.evaluatedRMEA=[[1,0,0,1],[1,0,0,1],[1,0,0,1],[1,0,0,1],[.4,1,0,1],[1,0,0,1],[1,0,0,1]],this.hiddenByReplacement=!1,this.evaluatedScale=[1,1,1],this.evaluatedColor=[],this.emissionHeightBasedParams=[],this.feature={type:"Point",id:t.id,geometry:[],properties:{height:Hx(t)}},this.aabb=this._getLocalBounds()}_getLocalBounds(){if(!this.node.meshes)return new wu([1/0,1/0,1/0],[-1/0,-1/0,-1/0]);if(!this.aabb){let t=0;const e=new wu([1/0,1/0,1/0],[-1/0,-1/0,-1/0]);for(const i of this.node.meshes)this.node.lightMeshIndex!==t&&(i.transformedAabb=wu.applyTransformFast(i.aabb,this.node.matrix),e.encapsulate(i.transformedAabb)),t++;this.aabb=e}return this.aabb}}class Kx{constructor(t,e,i,n,r,o){this.id=e,this.modelTraits|=Yv.CoordinateSpaceTile,this.uploaded=!1,this.hasPattern=!1,i&&(this.modelTraits|=Yv.HasMapboxMeshFeatures),n&&(this.modelTraits|=Yv.HasMeshoptCompression),this.zoom=-1,this.terrainExaggeration=1,this.projection={name:"mercator"},this.replacementUpdateTime=0,this.elevationReadFromZ=255,this.brightness=r,this.dirty=!0,this.needsUpload=!1,this.nodesInfo=[];for(const e of t)this.nodesInfo.push(new Xx(e)),Wx(e,o.featureIndexArray.length,o.grid),o.featureIndexArray.emplaceBack(this.nodesInfo.length-1,0,o.bucketLayerIDs.length-1,0)}updateFootprints(t,e){for(const i of this.getNodesInfo()){const n=i.node;n.footprint&&e.push({footprint:n.footprint,id:t})}}update(){console.log("Update 3D model bucket")}populate(){console.log("populate 3D model bucket")}uploadPending(){return!this.uploaded||this.needsUpload}upload(t){if(!this.needsUpload)return;const e=this.getNodesInfo();for(const i of e){const e=i.node;this.uploaded?this.updatePbrBuffer(e):Qv(e,t,!0)}for(const t of e)tx(t.node);this.uploaded=!0,this.needsUpload=!1}updatePbrBuffer(t){let e=!1;if(!t.meshes)return e;for(const i of t.meshes)i.pbrBuffer&&(i.pbrBuffer.updateData(i.featureArray),e=!0);return e}needsReEvaluation(t,e,i){const n=t.transform.projectionOptions,r=t.style.getBrightness(),o=this.brightness!==r;return!!(!this.uploaded||this.dirty||n.name!==this.projection.name||Jx(i.paint.get("model-color").value,o)||Jx(i.paint.get("model-color-mix-intensity").value,o)||Jx(i.paint.get("model-roughness").value,o)||Jx(i.paint.get("model-emissive-strength").value,o)||Jx(i.paint.get("model-height-based-emissive-strength-multiplier").value,o))&&(this.projection=n,this.brightness=r,!0)}evaluateScale(t,e){if(t.transform.zoom===this.zoom)return;this.zoom=t.transform.zoom;const i=this.getNodesInfo(),n=this.id.canonical;for(const t of i){const i=t.feature;t.evaluatedScale=e.paint.get("model-scale").evaluate(i,{},n)}}evaluate(t){const e=this.getNodesInfo();for(const i of e){if(!i.node.meshes)continue;const e=i.feature,n=i.node.meshes&&i.node.meshes[0].featureData,r=i.evaluatedColor[2],o=i.evaluatedRMEA[2],s=this.id.canonical;if(i.hasTranslucentParts=!1,n){for(let n=0;n=t)continue;const u=Zx[c],h=Math.abs(u);h>a&&(s=u,a=h,l=r,d=e)}if(a>.1){const o=1-(t+.5*Math.abs(l*d))/c;let a=e._dem.get(n,i)+s*o;const u=e._dem.get(n+l,i+d),h=e._dem.get(n-l,i-d,!0);(a-u)*(a-h)>0&&(a=(u+h)/2),Zx[r]=e._dem.set(n,i,a),qx[r]=t}}}}}s&&(e._demTile.needsDEMTextureUpload=!0,e._dem._timestamp=ki.now())}getNodesInfo(){return this.nodesInfo}destroy(){const t=this.getNodesInfo();for(const e of t)tx(e.node),ex(e.node)}isEmpty(){return!this.nodesInfo.length}updateReplacement(t,e){if(e.updateTime===this.replacementUpdateTime)return;this.replacementUpdateTime=e.updateTime;const i=e.getReplacementRegionsForTile(t.toUnwrapped()),n=this.getNodesInfo();for(let t=0;tt.footprint===e.footprint))}}getHeightAtTileCoord(e,i){const n=this.getNodesInfo(),r=[],o=[0,0,0],s=t.ad.identity([]);for(let a=0;ad.max[0]||i>d.max[1])continue;if(!0===l.node.hidden)return{height:0,maxHeight:l.feature.properties.height,hidden:!1,verticalScale:l.evaluatedScale[2]};t.ad.invert(s,l.node.matrix),o[0]=e,o[1]=i,t._.transformMat4(o,o,s);const u=(o[0]-c.aabb.min[0])/(c.aabb.max[0]-c.aabb.min[0])*Wv|0,h=Math.min(63,(o[1]-c.aabb.min[1])/(c.aabb.max[1]-c.aabb.min[1])*Wv|0)*Wv+Math.min(63,u),p=c.heightmap[h];if(!(p0)return{height:void 0,maxHeight:l.feature.properties.height,hidden:l.hiddenByReplacement,verticalScale:l.evaluatedScale[2]}}}}function Jx(t,e){return!t.isLightConstant&&e}function Qx(t,e,i,n,r,o,s,a){let l=(61440&e|(61440&e)>>4)>>8,c=(3840&e|(3840&e)>>4)>>4,d=240&e|(240&e)>>4;i[3]>0&&(l=Vn(l,255*i[0],i[3]),c=Vn(c,255*i[1],i[3]),d=Vn(d,255*i[2],i[3]));const u=l>16&65535,a=o?e>>16&65535:65535&e,l=(15&a)t.polygon)).flat());const g=f?l:null,[y,v]=function(e,i,n,r,o,s,a,l,c,d,u){return"globe"===e.projection.name?function(e,i,n,r,o,s,a,l,c,d,u){const h=[],p=[],f=e.projection.upVectorScale(u,e.center.lat,e.worldSize).metersToTile,m=[0,0,0,1],_=[0,0,0,1],g=(t,e,i,n)=>{t[0]=e,t[1]=i,t[2]=n,t[3]=1},y=Sf();n>0&&(n+=y),r+=y;for(const y of i){const i=[],v=[];for(const h of y){const p=h.x+o.x,y=h.y+o.y,x=e.projection.projectTilePoint(p,y,u),b=e.projection.upVector(u,h.x,h.y);let w=n,T=r;if(a){const t=Pf(p,y,n,r,a,l,c,d);w+=t.base,T+=t.top}0!==n?g(m,x.x+b[0]*f*w,x.y+b[1]*f*w,x.z+b[2]*f*w):g(m,x.x,x.y,x.z),g(_,x.x+b[0]*f*T,x.y+b[1]*f*T,x.z+b[2]*f*T),t._.transformMat4(m,m,s),t._.transformMat4(_,_,s),i.push(new Tp(m[0],m[1],m[2])),v.push(new Tp(_[0],_[1],_[2]))}h.push(i),p.push(v)}return[h,p]}(e,i,n,r,o,s,a,l,c,d,u):a?function(e,i,n,r,o,s,a,l,c){const d=[],u=[],h=[0,0,0,1];for(const p of e){const e=[],f=[];for(const d of p){const u=d.x+r.x,p=d.y+r.y,m=Pf(u,p,i,n,s,a,l,c);h[0]=u,h[1]=p,h[2]=m.base,h[3]=1,t.aA.transformMat4(h,h,o),h[3]=Math.max(h[3],1e-5);const _=new Tp(h[0]/h[3],h[1]/h[3],h[2]/h[3]);h[0]=u,h[1]=p,h[2]=m.top,h[3]=1,t.aA.transformMat4(h,h,o),h[3]=Math.max(h[3],1e-5);const g=new Tp(h[0]/h[3],h[1]/h[3],h[2]/h[3]);e.push(_),f.push(g)}d.push(e),u.push(f)}return[d,u]}(i,n,r,o,s,a,l,c,d):function(t,e,i,n,r){const o=[],s=[],a=r[8]*e,l=r[9]*e,c=r[10]*e,d=r[11]*e,u=r[8]*i,h=r[9]*i,p=r[10]*i,f=r[11]*i;for(const e of t){const t=[],i=[];for(const o of e){const e=o.x+n.x,s=o.y+n.y,m=r[0]*e+r[4]*s+r[12],_=r[1]*e+r[5]*s+r[13],g=r[2]*e+r[6]*s+r[14],y=r[3]*e+r[7]*s+r[15],v=m+a,x=_+l,b=g+c,w=Math.max(y+d,1e-5),T=m+u,S=_+h,E=g+p,M=Math.max(y+f,1e-5);t.push(new Tp(v/w,x/w,b/w)),i.push(new Tp(T/M,S/M,E/M))}o.push(t),s.push(i)}return[o,s]}(i,n,r,o,s)}(s,r,h,u,d,a,g,p,m,s.center.lat,e.tileID.canonical),x=e.queryGeometry;return function(t,e,i){let n=1/0;Kd(i,e)&&(n=Lf(i,e[0]));for(let r=0;r=3)for(let e=0;e>4;if(1!==n)throw new Error(`Got v${n} data when expected v1.`);const r=nb[15&i];if(!r)throw new Error("Unrecognized array type.");const[o]=new Uint16Array(t,2,1),[s]=new Uint32Array(t,4,1);return new rb(s,o,r,t)}constructor(t,e=64,i=Float64Array,n){if(isNaN(t)||t>1;return this.ids[i]=i,this.coords[this._pos++]=t,this.coords[this._pos++]=e,i}finish(){const t=this._pos>>1;if(t!==this.numItems)throw new Error(`Added ${t} items when expected ${this.numItems}.`);return ob(this.ids,this.coords,this.nodeSize,0,this.numItems-1,0),this._finished=!0,this}range(t,e,i,n){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");const{ids:r,coords:o,nodeSize:s}=this,a=[0,r.length-1,0],l=[];for(;a.length;){const c=a.pop()||0,d=a.pop()||0,u=a.pop()||0;if(d-u=t&&a=e&&c>1,p=o[2*h],f=o[2*h+1];p>=t&&p=e&&f=p:n>=f)&&(a.push(h+1),a.push(d),a.push(1-c))}return l}within(t,e,i){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");const{ids:n,coords:r,nodeSize:o}=this,s=[0,n.length-1,0],a=[],l=i*i;for(;s.length;){const c=s.pop()||0,d=s.pop()||0,u=s.pop()||0;if(d-u>1,p=r[2*h],f=r[2*h+1];cb(p,f,t,e)=p:e+i>=f)&&(s.push(h+1),s.push(d),s.push(1-c))}return a}}function ob(t,e,i,n,r,o){if(r-n>1;sb(t,e,s,n,r,o),ob(t,e,i,n,s-1,1-o),ob(t,e,i,s+1,r,1-o)}function sb(t,e,i,n,r,o){for(;r>n;){if(r-n>600){const s=r-n+1,a=i-n+1,l=Math.log(s),c=.5*Math.exp(2*l/3),d=.5*Math.sqrt(l*c*(s-c)/s)*(a-s/2s&&ab(t,e,n,r);as;)l--}e[2*n+o]===s?ab(t,e,n,l):(l++,ab(t,e,l,r)),lr&&(n+=(t[i]-r)*(t[i]-r)),e[i]0&&n[0]0&&n[1]0&&r[0]0&&r[1]0?Math.acos(i/n)*Ve:0;let o=0!==t||0!==e?Math.atan2(-e,-t)*Ve+90:0;return oNi&&(t.getActor().send("enforceCacheSizeLimit",Fi),Vi=0)},t.an=gn,t.ao=class{constructor(t){this.entries={},this.scheduler=t}request(t,e,i,n){const r=this.entries[t]=this.entries[t]||{callbacks:[]};if(r.result){const[t,i]=r.result;return this.scheduler?this.scheduler.add((()=>{n(t,i)}),e):n(t,i),()=>{}}return r.callbacks.push(n),r.cancel||(r.cancel=i(((i,n)=>{r.result=[i,n];for(const t of r.callbacks)this.scheduler?this.scheduler.add((()=>{t(i,n)}),e):t(i,n);setTimeout((()=>delete this.entries[t]),3e3)}))),()=>{r.result||(r.callbacks=r.callbacks.filter((t=>t!==n)),r.callbacks.length||(r.cancel(),delete this.entries[t]))}}},t.ap=function(t,e,i){const n=JSON.stringify(t.request);return t.data&&(this.deduped.entries[n]={result:[null,t.data]}),this.deduped.request(n,{type:"parseTile",isSymbolTile:t.isSymbolTile,zoom:t.tileZoom},(e=>{const n=en(t.request,((t,n,r,o)=>{t?e(t):n&&e(null,{vectorTile:i?void 0:new bp(new Lm(n)),rawData:n,cacheControl:r,expires:o})}));return()=>{n.cancel(),e()}}),e)},t.aq=Dc,t.ar=class extends Lc{constructor(t){super(t),this.current=Fc}set(t,e,i){if(this.fetchUniformLocation(t,e))for(let t=0;t({u_camera_to_center_distance:new $c(t),u_extrude_scale:new Uc(t),u_device_pixel_ratio:new $c(t),u_matrix:new Bc(t),u_inv_rot_matrix:new Bc(t),u_merc_center:new kc(t),u_tile_id:new Dc(t),u_zoom_transition:new $c(t),u_up_dir:new Dc(t),u_emissive_strength:new $c(t)}),t.bJ=t=>({u_matrix:new Bc(t),u_pixels_to_tile_units:new Uc(t),u_device_pixel_ratio:new $c(t),u_units_to_pixels:new kc(t),u_dash_image:new Pc(t),u_gradient_image:new Pc(t),u_image_height:new $c(t),u_texsize:new kc(t),u_tile_units_to_pixels:new $c(t),u_alpha_discard_threshold:new $c(t),u_trim_offset:new kc(t),u_trim_fade_range:new kc(t),u_trim_color:new zc(t),u_emissive_strength:new $c(t)}),t.bK=t=>({u_matrix:new Bc(t),u_texsize:new kc(t),u_pixels_to_tile_units:new Uc(t),u_device_pixel_ratio:new $c(t),u_image:new Pc(t),u_units_to_pixels:new kc(t),u_tile_units_to_pixels:new $c(t),u_alpha_discard_threshold:new $c(t),u_trim_offset:new kc(t)}),t.bL=Yl,t.bM=Hf,t.bN=Om,t.bO=jm,t.bP=G_,t.bQ=c_,t.bR=th,t.bS=(t,e,i,n,r,o)=>{const s=t.transform,a="globe"===s.projection.name;let l;if("map"===o.paint.get("circle-pitch-alignment"))if(a){const t=Zu(s.zoom,e.canonical)*s._pixelsPerMercatorPixel;l=Float32Array.from([t,0,0,t])}else l=s.calculatePixelsToTileUnitsMatrix(i);else l=new Float32Array([s.pixelsToGLUnits[0],0,0,s.pixelsToGLUnits[1]]);const c={u_camera_to_center_distance:t.transform.getCameraToCenterDistance(s.projection),u_matrix:t.translatePosMatrix(e.projMatrix,i,o.paint.get("circle-translate"),o.paint.get("circle-translate-anchor")),u_device_pixel_ratio:ki.devicePixelRatio,u_extrude_scale:l,u_inv_rot_matrix:Qu,u_merc_center:[0,0],u_tile_id:[0,0,0],u_zoom_transition:0,u_up_dir:[0,0,0],u_emissive_strength:o.paint.get("circle-emissive-strength")};if(a){c.u_inv_rot_matrix=n,c.u_merc_center=r,c.u_tile_id=[e.canonical.x,e.canonical.y,1{const s=t.transform;return{u_matrix:rm(t,e,i,n),u_texsize:e.imageAtlasTexture?e.imageAtlasTexture.size:[0,0],u_pixels_to_tile_units:s.calculatePixelsToTileUnitsMatrix(e),u_device_pixel_ratio:r,u_image:0,u_tile_units_to_pixels:nm(e,s),u_units_to_pixels:[1/s.pixelsToGLUnits[0],1/s.pixelsToGLUnits[1]],u_alpha_discard_threshold:0,u_trim_offset:o}},t.bV=(t,e,i,n,r,o,s)=>{const a=t.transform,l=a.calculatePixelsToTileUnitsMatrix(e);return{u_matrix:rm(t,e,i,n),u_pixels_to_tile_units:l,u_device_pixel_ratio:o,u_units_to_pixels:[1/a.pixelsToGLUnits[0],1/a.pixelsToGLUnits[1]],u_dash_image:0,u_gradient_image:1,u_image_height:r,u_texsize:sm(i)&&e.lineAtlasTexture?e.lineAtlasTexture.size:[0,0],u_tile_units_to_pixels:nm(e,t.transform),u_alpha_discard_threshold:0,u_trim_offset:s,u_trim_fade_range:i.paint.get("line-trim-fade-range"),u_trim_color:i.paint.get("line-trim-color").toRenderColor(i.lut).toArray01(),u_emissive_strength:i.paint.get("line-emissive-strength")}},t.bW=oi,t.bX=mh,t.bY=Sf,t.bZ=bd,t.b_=_f,t.ba=function(t,e,i){const n=Hu(i.zoom),r=t.style.map._antialias,o=e.options.extStandardDerivativesForceOff||t.terrain&&t.terrain.exaggeration()>0;return 0===n&&!r&&!o},t.bb=function(e){const i=e.pixelsPerMeter,n=i/Cd(1,e.center.lat),r=t.ad.identity(new Float64Array(16));return t.ad.translate(r,r,[e.point.x,e.point.y,0]),t.ad.scale(r,r,[n,n,i]),Float32Array.from(r)},t.bc=Ou,t.bd=function(t){const e=Pd-5;t=Xe(t,-e,e)/e*90;const i=Math.pow(Math.abs(Math.sin(Ge(t))),3);return Math.round(i*(sd.length-1))},t.be=function(e,i,n,r){const o=i.getNorth(),s=i.getSouth(),a=i.getWest(),l=i.getEast(),c=10){const e=180/r;t.bC.multiply(f,f,[e/d+1,0,0,0,e/u+1,0,-.5*e/h,.5*e/p,1])}return f[2]=c,f[5]=e.x,f[8]=e.y,f},t.bf=ju,t.bg=$u,t.bh=function(e,i,n){const r=t.ad.identity(new Float64Array(16)),o=(i/(1{}}},t.bo=Gg,t.bp=ai,t.bq=class{isDataAvailableAtPoint(t){const e=this._source();if(this.isUsingMockSource()||!e||t.y1)return!1;const i=e.getSource().maxzoom,n=11)return e;const r=n.getSource().maxzoom,o=1{const s=this.getAtTileOffset(e,o.x,o.y),a=r.upVector(e.canonical,o.x,o.y),l=r.upVectorScale(e.canonical,i,n).metersToTile;return t._.scale(a,a,s*l),a}}getForTilePoints(t,e,i,n){if(this.isUsingMockSource())return!1;const r=Xp.create(this,t,n);return!!r&&(e.forEach((t=>{t[2]=this.exaggeration()*r.getElevationAt(t[0],t[1],i)})),!0)}getMinMaxForTile(t){if(this.isUsingMockSource())return null;const e=this.findDEMTileFor(t);if(!e||!e.dem)return null;const i=e.dem.tree,n=e.tileID,r=1=0?t.slice(0,e):t},t.cV=function(t){return t.indexOf(wl)>=0},t.cW=function(t){const e=t.indexOf(wl);return e>=0?t.slice(e+1):""},t.cX=function(t){const e=[],i=t.id;return void 0===i&&e.push({message:`layers.${i}: missing required property "id"`}),void 0===t.render&&e.push({message:`layers.${i}: missing required method "render"`}),t.renderingMode&&"2d"!==t.renderingMode&&"3d"!==t.renderingMode&&e.push({message:`layers.${i}: property "renderingMode" must be either "2d" or "3d"`}),e},t.cY=function(t,e,i,n){return"custom"===t.type?new vv(t,e):new ib[t.type](t,e,i,n)},t.cZ=di,t.c_=Va,t.ca=1,t.cb=Ag,t.cc=0,t.cd=ec,t.ce=function(t,e,i,n,r){return Xe((t-e)/(i-e)*(r-n)+n,n,r)},t.cf=Ns,t.cg=kd,t.ch=class{constructor(t,e,i,n){this.context=t,this.format=n,this.size=i,this.texture=t.gl.createTexture();const[r,o,s]=this.size,{gl:a}=t;a.bindTexture(a.TEXTURE_3D,this.texture),t.pixelStoreUnpackFlipY.set(!1),t.pixelStoreUnpack.set(1),t.pixelStoreUnpackPremultiplyAlpha.set(!1);let l=this.format,c=a.UNSIGNED_BYTE;this.format===a.DEPTH_COMPONENT&&(l=a.DEPTH_COMPONENT16,c=a.UNSIGNED_SHORT),this.format===a.R8&&(n=a.RED),this.format===a.R32F&&(c=a.FLOAT,n=a.RED),a.texImage3D(a.TEXTURE_3D,0,l,r,o,s,0,n,c,e.data)}bind(t,e){const{context:i}=this,{gl:n}=i;n.bindTexture(n.TEXTURE_3D,this.texture),t!==this.minFilter&&(n.texParameteri(n.TEXTURE_3D,n.TEXTURE_MAG_FILTER,t),n.texParameteri(n.TEXTURE_3D,n.TEXTURE_MIN_FILTER,t),this.minFilter=t),e!==this.wrapS&&(n.texParameteri(n.TEXTURE_3D,n.TEXTURE_WRAP_S,e),n.texParameteri(n.TEXTURE_3D,n.TEXTURE_WRAP_T,e),this.wrapS=e)}destroy(){const{gl:t}=this.context;t.deleteTexture(this.texture),this.texture=null}},t.ci=$v,t.cj=[1,1,1],t.ck=Xp,t.cl=Yv,t.cm=ql,t.cn=ic,t.co=class{constructor(){this._updateTime=0,this._sourceIds=[],this._activeRegions=[],this._prevRegions=[],this._globalClipBounds={min:new Ue(1/0,1/0),max:new Ue(-1/0,-1/0)}}clear(){this._activeRegions.length>0&&++this._updateTime,this._activeRegions=[],this._prevRegions=[]}get updateTime(){return this._updateTime}getReplacementRegionsForTile(t,e=!1){const i=$p(new Ue(0,0),new Ue(uo,uo),t),n=[];if(e&&!Lp(i,this._globalClipBounds))return n;for(const e of this._activeRegions){if(e.hiddenByOverlap)continue;if(!Lp(i,e))continue;const r=kp(e.min,e.max,t);n.push({min:r.min,max:r.max,sourceId:this._sourceIds[e.priority],footprint:e.footprint,footprintTileId:e.tileId,order:e.order,clipMask:e.clipMask})}return n}setSources(t){this._setSources(t.map((t=>({getSourceId:()=>t.cache.id,getFootprints:()=>{const e=[];for(const i of t.cache.getVisibleCoordinates()){const n=t.cache.getTile(i).buckets[t.layer];n&&n.updateFootprints(i.toUnwrapped(),e)}return e},getOrder:()=>t.order,getClipMask:()=>t.clipMask}))))}_addSource(t){const e=t.getFootprints();if(0===e.length)return;const i=t.getOrder(),n=t.getClipMask();for(const t of e){if(!t.footprint)continue;const e=$p(t.footprint.min,t.footprint.max,t.id);this._activeRegions.push({min:e.min,max:e.max,hiddenByOverlap:!1,priority:this._sourceIds.length,tileId:t.id,footprint:t.footprint,order:i,clipMask:n})}this._sourceIds.push(t.getSourceId())}_computeReplacement(){this._activeRegions.sort(((t,e)=>t.priority-e.priority||Ap(t.min,e.min)||Ap(t.max,e.max)));let t=this._activeRegions.length!==this._prevRegions.length;if(!t){let e=0;for(;!t&&e!==this._activeRegions.length;){const i=this._activeRegions[e],n=this._prevRegions[e];t=i.priority!==n.priority||!Ip(i,n)||i.order!==n.order||i.clipMask!==n.clipMask,++e}}if(t){++this._updateTime;for(const t of this._activeRegions)t.order!==1/0&&(this._globalClipBounds.min.x=Math.min(this._globalClipBounds.min.x,t.min.x),this._globalClipBounds.min.y=Math.min(this._globalClipBounds.min.y,t.min.y),this._globalClipBounds.max.x=Math.max(this._globalClipBounds.max.x,t.max.x),this._globalClipBounds.max.y=Math.max(this._globalClipBounds.max.y,t.max.y));const t=t=>{const e=this._activeRegions;if(t>=e.length)return t;const i=e[t].priority;for(;t1){let e=0,i=t(e);for(;e!==i;){let n=e;const r=e;for(;n!==i;){const t=this._activeRegions[n];t.hiddenByOverlap=!1;for(let e=0;e=0;e--)this._addSource(t[e]);this._computeReplacement()}},t.cp=Dl,t.cq=Jg,t.cr=rc,t.cs=class{constructor(t){this._createGrid(t),this._createPoles(t)}destroy(){this._poleIndexBuffer.destroy(),this._gridBuffer.destroy(),this._gridIndexBuffer.destroy(),this._poleNorthVertexBuffer.destroy(),this._poleSouthVertexBuffer.destroy();for(const t of this._poleSegments)t.destroy();for(const t of this._gridSegments)t.withSkirts.destroy(),t.withoutSkirts.destroy()}_fillGridMeshWithLods(t,e){const i=new $l,n=new Kl,r=[],o=t+1+2,s=e[0]+1,a=e[0]+1+(1+e.length),l=(t,e,i)=>{let n=t===o-1?t-2:0===t?t:t-1;return n+=i?24575:0,[n,e]};for(let t=0;tt()))},t.dB=sx,t.dC=yx,t.dD=function(t){px=ki.resolveURL(t),gx||(gx=new ox(ux(),new zn)),gx.broadcast("setDracoUrl",px)},t.dE=vx,t.dF=function(t){mx=ki.resolveURL(t),gx||(gx=new ox(ux(),new zn)),gx.broadcast("setMeshoptUrl",mx)},t.dG=ti,t.dH=ba,t.dI=dh,t.dJ=I_,t.dK=eg,t.dL=dc,t.dM=am,t.dN=Dm,t.dO=Wf,t.dP=ci,t.dQ=E_,t.dR=jg,t.dS=function(t,e,i,n,r,o,s,a,l,c,d){t.createArrays(),t.tilePixelRatio=uo/(512*t.overscaling),t.compareText={},t.iconsNeedLinear=!1;const u=t.layers[0].layout,h=t.layers[0]._unevaluatedLayout._values,p={};if("composite"===t.textSizeData.kind){const{minZoom:e,maxZoom:i}=t.textSizeData;p.compositeTextSizes=[h["text-size"].possiblyEvaluate(new Ha(e),a),h["text-size"].possiblyEvaluate(new Ha(i),a)]}if("composite"===t.iconSizeData.kind){const{minZoom:e,maxZoom:i}=t.iconSizeData;p.compositeIconSizes=[h["icon-size"].possiblyEvaluate(new Ha(e),a),h["icon-size"].possiblyEvaluate(new Ha(i),a)]}p.layoutTextSize=h["text-size"].possiblyEvaluate(new Ha(l+1),a),p.layoutIconSize=h["icon-size"].possiblyEvaluate(new Ha(l+1),a),p.textMaxSize=h["text-size"].possiblyEvaluate(new Ha(18),a);const f="map"===u.get("text-rotation-alignment")&&"point"!==u.get("symbol-placement"),m=u.get("text-size");let _=!1;for(const e of t.features)if(e.icon&&e.icon.nameSecondary){_=!0;break}for(const o of t.features){const l=u.get("text-font").evaluate(o,{},a).join(","),h=m.evaluate(o,{},a),g=p.layoutTextSize.evaluate(o,{},a),y=(p.layoutIconSize.evaluate(o,{},a),{horizontal:{},vertical:void 0}),v=o.text;let x,b=[0,0];if(v){const n=v.toString(),s=u.get("text-letter-spacing").evaluate(o,{},a)*Om,c=u.get("text-line-height").evaluate(o,{},a)*Om,d=Aa(n)?s:0,p=u.get("text-anchor").evaluate(o,{},a),m=u.get("text-variable-anchor");if(!m){const t=u.get("text-radial-offset").evaluate(o,{},a);b=t?G_(p,[t*Om,j_]):u.get("text-offset").evaluate(o,{},a).map((t=>t*Om))}let _=f?"center":u.get("text-justify").evaluate(o,{},a);const x="point"===u.get("symbol-placement"),w=x?u.get("text-max-width").evaluate(o,{},a)*Om:1/0,T=o=>{t.allowVerticalPlacement&&Ca(n)&&(y.vertical=e_(v,e,i,r,l,w,c,p,o,d,b,Jm.vertical,!0,g,h))};if(!f&&m){const t="auto"===_?m.map((t=>Z_(t))):[_];let n=!1;for(let o=0;o=0||!Ca(n)){const t=e_(v,e,i,r,l,w,c,p,_,d,b,Jm.horizontal,!1,g,h);t&&(y.horizontal[_]=t)}T(x?"left":_)}}let w=!1;if(o.icon&&o.icon.namePrimary){const e=n[o.icon.namePrimary];e&&(x=u_(r[o.icon.namePrimary],o.icon.nameSecondary?r[o.icon.nameSecondary]:void 0,u.get("icon-offset").evaluate(o,{},a),u.get("icon-anchor").evaluate(o,{},a)),w=e.sdf,void 0===t.sdfIcons?t.sdfIcons=e.sdf:t.sdfIcons!==e.sdf&&pi("Style sheet warning: Cannot mix SDF and non-SDF icons in one buffer"),(e.pixelRatio!==t.pixelRatio||0!==u.get("icon-rotate").constantOr(1))&&(t.iconsNeedLinear=!0))}const T=X_(y.horizontal)||y.vertical;t.iconsInText||(t.iconsInText=!!T&&T.iconsInText),(T||x)&&q_(t,o,y,x,n,p,g,0,b,w,s,a,c,d,_)}o&&t.generateCollisionDebugBuffers(l,t.collisionBoxArray)},t.dT=Jf,t.dU=Yh,t.dV=bp,t.dW=Lm,t.dX=Yp,t.dY=Zy,t.dZ=wp,t.d_=cp,t.da=Wu,t.db=function(e){const i=[0,0,0],n=t.ad.identity(new Float64Array(16));return t.ad.multiply(n,e.pixelMatrix,e.globeMatrix),t._.transformMat4(i,i,n),new Ue(i[0],i[1])},t.dc=d,t.dd=c,t.de=function(t){const e=t.navigator?t.navigator.userAgent:null;return!!function(t){if(null==Ei){const e=t.navigator?t.navigator.userAgent:null;Ei=!!t.safari||!(!e||!(/\b(iPad|iPhone|iPod)\b/.test(e)||e.match("Safari")&&!e.match("Chrome")))}return Ei}(t)&&e&&(e.match("Version/15.4")||e.match("Version/15.5")||e.match(/CPU (OS|iPhone OS) (15_4|15_5) like Mac OS X/))},t.df=ni,t.dg=class{constructor(t,e,i){this._transformRequestFn=t,this._customAccessToken=e,this._silenceAuthErrors=!!i,this._createSkuToken()}_createSkuToken(){const t=function(){let t="";for(let e=0;ethis._skuTokenExpiresAt}transformRequest(t,e){return this._transformRequestFn&&this._transformRequestFn(t,e)||{url:t}}normalizeStyleURL(t,i){if(!o(t))return t;const n=un(t);return n.params.push(`sdk=js-${e}`),n.path=`/styles/v1${n.path}`,this._makeAPIURL(n,this._customAccessToken||i)}normalizeGlyphsURL(t,e){if(!o(t))return t;const i=un(t);return i.path=`/fonts/v1${i.path}`,this._makeAPIURL(i,this._customAccessToken||e)}normalizeModelURL(t,e){if(!o(t))return t;const i=un(t);return i.path=`/models/v1${i.path}`,this._makeAPIURL(i,this._customAccessToken||e)}normalizeSourceURL(t,e,i,n){if(!o(t))return t;const r=un(t);return r.path=`/v4/${r.authority}.json`,r.params.push("secure"),i&&r.params.push(`language=${i}`),n&&r.params.push(`worldview=${n}`),this._makeAPIURL(r,this._customAccessToken||e)}normalizeSpriteURL(t,e,i,n){const r=un(t);return o(t)?(r.path=`/styles/v1${r.path}/sprite${e}${i}`,this._makeAPIURL(r,this._customAccessToken||n)):(r.path+=`${e}${i}`,hn(r))}normalizeTileURL(t,e,i){if(this._isSkuTokenExpired()&&this._createSkuToken(),t&&!o(t))return t;const r=un(t);r.path=r.path.replace(/(\.(png|jpg)\d*)(?=$)/,`${e||i&&"raster"!==r.authority&&512===i?"@2x":""}${Gi.supported?".webp":"$1"}`),"raster"===r.authority?r.path=`/${n.RASTER_URL_PREFIX}${r.path}`:"rasterarrays"===r.authority?r.path=`/${n.RASTERARRAYS_URL_PREFIX}${r.path}`:"3dtiles"===r.authority?r.path=`/${n.TILES3D_URL_PREFIX}${r.path}`:(r.path=r.path.replace(/^.+\/v4\//,"/"),r.path=`/${n.TILE_URL_VERSION}${r.path}`);const s=this._customAccessToken||function(t){for(const e of t){const t=e.match(/^access_token=(.*)$/);if(t)return t[1]}return null}(r.params)||n.ACCESS_TOKEN;return n.REQUIRE_ACCESS_TOKEN&&s&&this._skuToken&&r.params.push(`sku=${this._skuToken}`),this._makeAPIURL(r,s)}canonicalizeTileURL(t,e){const i=un(t);if(!i.path.match(/^(\/v4\/|\/(raster|rasterarrays)\/v1\/)/)||!i.path.match(/\.[\w]+$/))return t;let r="mapbox://";i.path.match(/^\/raster\/v1\//)?r+=`raster/${i.path.replace(`/${n.RASTER_URL_PREFIX}/`,"")}`:i.path.match(/^\/rasterarrays\/v1\//)?r+=`rasterarrays/${i.path.replace(`/${n.RASTERARRAYS_URL_PREFIX}/`,"")}`:r+=`tiles/${i.path.replace(`/${n.TILE_URL_VERSION}/`,"")}`;let o=i.params;return e&&(o=o.filter((t=>!t.match(/^access_token=/)))),o.length&&(r+=`?${o.join("&")}`),r}canonicalizeTileset(t,e){const i=!!e&&o(e),n=[];for(const e of t.tiles||[])r(e)?n.push(this.canonicalizeTileURL(e,i)):n.push(e);return n}_makeAPIURL(t,e){const i="See https://docs.mapbox.com/api/overview/#access-tokens-and-token-scopes",r=un(n.API_URL);if(t.protocol=r.protocol,t.authority=r.authority,"http"===t.protocol){const e=t.params.indexOf("secure");e>=0&&t.params.splice(e,1)}if("/"!==r.path&&(t.path=`${r.path}${t.path}`),!n.REQUIRE_ACCESS_TOKEN)return hn(t);if(e=e||n.ACCESS_TOKEN,!this._silenceAuthErrors){if(!e)throw new Error(`An API access token is required to use Mapbox GL. ${i}`);if("s"===e[0])throw new Error(`Use a public access token (pk.*) with Mapbox GL, not a secret access token (sk.*). ${i}`)}return t.params=t.params.filter((t=>-1===t.indexOf("access_token"))),t.params.push(`access_token=${e||""}`),hn(t)}},t.dh=function(t,e){e?Mn.add(t):Mn.delete(t)},t.di=Gi,t.dj=Tn,t.dk=En,t.dl=cn,t.dm=vn,t.dn=bn,t.dp=function(t){Mn.delete(t)},t.dq=Sn,t.dr=yn,t.ds=Qe,t.dt=e,t.du=function(t,e){Fi=t,Ni=e},t.dv=function(t,e,i=!1){if(Fa===za||Fa===Ra||Fa===Oa)throw new Error("setRTLTextPlugin cannot be called multiple times.");Na=ki.resolveURL(t),Fa=za,Ba=e,ja(),i||Za()},t.dw=Ga,t.dx=function(){ux().acquire(lx)},t.dy=function(){const t=dx;t&&(t.isPreloaded()&&1===t.numActive()?(t.release(lx),dx=null):console.warn("Could not clear WebWorkers since there are active Map instances that still reference it. The pre-warmed WebWorker pool can only be cleared when all map instances have been removed with map.remove()"))},t.dz=cx,t.e=ki,t.e0=cm,t.e1=h,t.e2=en,t.e3=function(t){let e=0;if(new Uint32Array(t,0,1)[0]!==Ax){const i=new Uint32Array(t,0,7),[,,n,r,o,s]=i;e=i.byteLength+r+o+s+o,(n!==t.byteLength||e>=t.byteLength)&&pi("Invalid b3dm header information.")}return Dx(t,e)},t.e4=function(t,e){const i=jx(t);for(const t of i){for(const e of t.meshes)Vx(e);t.lights&&(t.lightMeshIndex=t.meshes.length,t.meshes.push(Gx(t.lights,e)))}return i},t.e5=Kx,t.e6=rx,t.e7=qa,t.e8=function(t){ji(),Oi&&Oi.then((e=>{e.keys().then((i=>{for(let n=0;nt.arrayBuffer())).then((e=>Dx(e,0,t)))},t.m=class extends Uv{},t.n=Er,t.o=qn,t.p=Qg,t.q=Xs,t.r=Js,t.s=Qs,t.t=ca,t.u=al,t.v=ll,t.w=pi,t.x=pa,t.y=da,t.z=qo})),n(0,(function(t){function e(t){const e=t?t.url.toString():void 0;return e?performance.getEntriesByName(e):[]}function i(t){if("number"==typeof t||"boolean"==typeof t||"string"==typeof t||null==t)return JSON.stringify(t);if(Array.isArray(t)){let e="[";for(const n of t)e+=`${i(n)},`;return`${e}]`}let e="{";for(const n of Object.keys(t).sort())e+=`${n}:${i(t[n])},`;return`${e}}`}function n(e){let n="";for(const r of t.cE)n+=`/${i(e[r])}`;return n}class r{constructor(t){this.keyCache={},this._layers={},this._layerConfigs={},t&&this.replace(t)}replace(t,e){this._layerConfigs={},this._layers={},this.update(t,[],e)}update(e,i,r){this._options=r;for(const i of e)this._layerConfigs[i.id]=i,(this._layers[i.id]=t.cY(i,this.scope,null,this._options)).compileFilter(),this.keyCache[i.id]&&delete this.keyCache[i.id];for(const t of i)delete this.keyCache[t],delete this._layerConfigs[t],delete this._layers[t];this.familiesBySource={};const o=function(t,e){const i={};for(let r=0;rthis._layers[t.id])),i=e[0];if("none"===i.visibility)continue;const n=i.source||"";let r=this.familiesBySource[n];r||(r=this.familiesBySource[n]={});const o=i.sourceLayer||"_geojsonTileLayer";let s=r[o];s||(s=r[o]=[]),s.push(e)}}}const o=1*t.dJ;class s{constructor(e){const i={},n=[];for(const t in e){const r=e[t],s=i[t]={};for(const t in r.glyphs){const e=r.glyphs[+t];if(!e||0===e.bitmap.width||0===e.bitmap.height)continue;const i=e.metrics.localGlyph?o:1,a={x:0,y:0,w:e.bitmap.width+2*i,h:e.bitmap.height+2*i};n.push(a),s[t]=a}}const{w:r,h:s}=t.j(n),a=new t.dI({width:r||1,height:s||1});for(const n in e){const r=e[n];for(const e in r.glyphs){const s=r.glyphs[+e];if(!s||0===s.bitmap.width||0===s.bitmap.height)continue;const l=i[n][e],c=s.metrics.localGlyph?o:1;t.dI.copy(s.bitmap,a,{x:0,y:0},{x:l.x+c,y:l.y+c},s.bitmap)}}this.image=a,this.positions=i}}t.dH(s,"GlyphAtlas");class a{constructor(e){this.tileID=new t.aL(e.tileID.overscaledZ,e.tileID.wrap,e.tileID.canonical.z,e.tileID.canonical.x,e.tileID.canonical.y),this.tileZoom=e.tileZoom,this.uid=e.uid,this.zoom=e.zoom,this.lut=e.lut,this.canonical=e.tileID.canonical,this.pixelRatio=e.pixelRatio,this.tileSize=e.tileSize,this.source=e.source,this.scope=e.scope,this.overscaling=this.tileID.overscaleFactor(),this.showCollisionBoxes=e.showCollisionBoxes,this.collectResourceTiming=!!e.collectResourceTiming,this.promoteId=e.promoteId,this.isSymbolTile=e.isSymbolTile,this.tileTransform=t.dK(e.tileID.canonical,e.projection),this.projection=e.projection,this.brightness=e.brightness,this.extraShadowCaster=!!e.extraShadowCaster,this.tessellationStep=e.tessellationStep}parse(e,i,n,r,o){this.status="parsing",this.data=e,this.collisionBoxArray=new t.dL;const a=new t.dM(Object.keys(e.layers).sort()),c=new t.dN(this.tileID,this.promoteId);c.bucketLayerIDs=[];const d={},u=new t.dO(256,256),h={featureIndex:c,iconDependencies:{},patternDependencies:{},glyphDependencies:{},lineAtlas:u,availableImages:n,brightness:this.brightness},p=i.familiesBySource[this.source];for(const i in p){const r=e.layers[i];if(!r)continue;let o=!1,s=!1,u=!1;for(const t of p[i])"symbol"===t[0].type?o=!0:s=!0,t[0].is3D()&&"model"!==t[0].type&&(u=!0);if(this.extraShadowCaster&&!u)continue;if(!0===this.isSymbolTile&&!o)continue;if(!1===this.isSymbolTile&&!s)continue;1===r.version&&t.w(`Vector tile source "${this.source}" layer "${i}" does not use vector tile spec v2 and therefore may have some rendering errors.`);const f=a.encode(i),m=[];for(let t=0;t=e.maxzoom||"none"!==e.visibility&&(l(t,this.zoom,h.brightness,n),(d[e.id]=e.createBucket({index:c.bucketLayerIDs.length,layers:t,zoom:this.zoom,lut:this.lut,canonical:this.canonical,pixelRatio:this.pixelRatio,overscaling:this.overscaling,collisionBoxArray:this.collisionBoxArray,sourceLayerIndex:f,sourceID:this.source,projection:this.projection.spec,tessellationStep:this.tessellationStep})).populate(m,h,this.tileID.canonical,this.tileTransform),c.bucketLayerIDs.push(t.map((t=>t.id)))))}}let f,m,_,g;u.trim();const y={type:"maybePrepare",isSymbolTile:this.isSymbolTile,zoom:this.zoom},v=()=>{if(f)return this.status="done",o(f);if(this.extraShadowCaster)this.status="done",o(null,{buckets:t.dG(d).filter((t=>!t.isEmpty())),featureIndex:c,collisionBoxArray:null,glyphAtlasImage:null,lineAtlas:null,imageAtlas:null,brightness:h.brightness,glyphMap:null,iconMap:null,glyphPositions:null});else if(m&&_&&g){const e=new s(m),i=new t.dQ(_,g,this.lut);for(const r in d){const o=d[r];o instanceof t.dR?(l(o.layers,this.zoom,h.brightness,n),t.dS(o,m,e.positions,_,i.iconPositions,this.showCollisionBoxes,n,this.tileID.canonical,this.tileZoom,this.projection,this.brightness)):o.hasPattern&&(o instanceof t.dT||o instanceof t.dU||o instanceof t.b_)&&(l(o.layers,this.zoom,h.brightness,n),o.addFeatures(h,this.tileID.canonical,i.patternPositions,n,this.tileTransform,this.brightness))}this.status="done",o(null,{buckets:t.dG(d).filter((t=>!t.isEmpty())),featureIndex:c,collisionBoxArray:this.collisionBoxArray,glyphAtlasImage:e.image,lineAtlas:u,imageAtlas:i,brightness:h.brightness})}};if(!this.extraShadowCaster){const e=t.dP(h.glyphDependencies,(t=>Object.keys(t).map(Number)));Object.keys(e).length?r.send("getGlyphs",{uid:this.uid,stacks:e,scope:this.scope},((t,e)=>{f||(f=t,m=e,v())}),void 0,!1,y):m={};const i=Object.keys(h.iconDependencies);i.length?r.send("getImages",{icons:i,source:this.source,scope:this.scope,tileID:this.tileID,type:"icons"},((t,e)=>{f||(f=t,_=e,v())}),void 0,!1,y):_={};const n=Object.keys(h.patternDependencies);n.length?r.send("getImages",{icons:n,source:this.source,scope:this.scope,tileID:this.tileID,type:"patterns"},((t,e)=>{f||(f=t,g=e,v())}),void 0,!1,y):g={}}v()}}function l(e,i,n,r){const o=new t.X(i,{brightness:n});for(const t of e)t.recalculate(o,r)}class c extends t.E{constructor(e,i,n,r,o,s){super(),this.actor=e,this.layerIndex=i,this.availableImages=n,this.loadVectorData=o||t.ap,this.loading={},this.loaded={},this.deduped=new t.ao(e.scheduler),this.isSpriteLoaded=r,this.scheduler=e.scheduler,this.brightness=s}loadTile(i,n){const r=i.uid,o=i&&i.request,s=o&&o.collectResourceTiming,l=this.loading[r]=new a(i);l.abort=this.loadVectorData(i,((a,c)=>{const d=!this.loading[r];if(delete this.loading[r],d||a||!c)return l.status="done",d||(this.loaded[r]=l),n(a);const u=c.rawData,h={};c.expires&&(h.expires=c.expires),c.cacheControl&&(h.cacheControl=c.cacheControl),l.vectorTile=c.vectorTile||new t.dV(new t.dW(u));const p=()=>{l.parse(l.vectorTile,this.layerIndex,this.availableImages,this.actor,((i,r)=>{if(i||!r)return n(i);const a={};if(s){const t=e(o);t.length>0&&(a.resourceTiming=JSON.parse(JSON.stringify(t)))}n(null,t.W({rawTileData:u.slice(0)},r,h,a))}))};this.isSpriteLoaded?p():this.once("isSpriteLoaded",(()=>{this.scheduler?this.scheduler.add(p,{type:"parseTile",isSymbolTile:i.isSymbolTile,zoom:i.tileZoom}):p()})),this.loaded=this.loaded||{},this.loaded[r]=l}))}reloadTile(e,i){const n=this.loaded,r=e.uid;if(n&&n[r]){const o=n[r];o.showCollisionBoxes=e.showCollisionBoxes,o.projection=e.projection,o.brightness=e.brightness,o.tileTransform=t.dK(e.tileID.canonical,e.projection),o.extraShadowCaster=e.extraShadowCaster,o.lut=e.lut;const s=(t,e)=>{const n=o.reloadCallback;n&&(delete o.reloadCallback,o.parse(o.vectorTile,this.layerIndex,this.availableImages,this.actor,n)),i(t,e)};"parsing"===o.status?o.reloadCallback=s:"done"===o.status&&(o.vectorTile?o.parse(o.vectorTile,this.layerIndex,this.availableImages,this.actor,s):s())}else i(null,void 0)}abortTile(t,e){const i=t.uid,n=this.loading[i];n&&(n.abort&&n.abort(),delete this.loading[i]),e()}removeTile(t,e){const i=this.loaded,n=t.uid;i&&i[n]&&delete i[n],e()}}class d{loadTile(e,i){const{uid:n,encoding:r,rawImageData:o,padding:s}=e,a=ImageBitmap&&o instanceof ImageBitmap?this.getImageData(o,s):o;i(null,new t.dX(n,a,r,s{n(null,t)}),(t=>{n(t)}))}}const h=t.dZ.prototype.toGeoJSON;let p=class{constructor(e){this._feature=e,this.extent=t.a3,this.type=e.type,this.properties=e.tags,"id"in e&&!isNaN(e.id)&&(this.id=parseInt(e.id,10))}loadGeometry(){if(1===this._feature.type){const e=[];for(const i of this._feature.geometry)e.push([new t.P(i[0],i[1])]);return e}{const e=[];for(const i of this._feature.geometry){const n=[];for(const e of i)n.push(new t.P(e[0],e[1]));e.push(n)}return e}}toGeoJSON(t,e,i){return h.call(this,t,e,i)}},f=class{constructor(e){this.layers={_geojsonTileLayer:this},this.name="_geojsonTileLayer",this.extent=t.a3,this.length=e.length,this._features=e}feature(t){return new p(this._features[t])}};const m=64/4096;class _{constructor(){this.features=new Map}clear(){this.features.clear()}load(t=[],e){for(const i of t){const t=i.id;if(null==t)continue;let n=this.features.get(t);n&&this.updateCache(n,e),i.geometry?(n=y(i),this.updateCache(n,e),this.features.set(t,n)):this.features.delete(t),this.updateCache(n,e)}}updateCache(t,e){for(const{canonical:i,uid:n}of Object.values(e)){const{z:r,x:o,y:s}=i;g(t,Math.pow(2,r),o,s)&&delete e[n]}}getTile(t,e,i){const n=Math.pow(2,t),r=[];for(const t of this.features.values())g(t,n,e,i)&&r.push(w(t,n,e,i));return{features:r}}getFeatures(){return[...this.features.values()]}}function g({minX:t,minY:e,maxX:i,maxY:n},r,o,s){return t(o-m)/r&&n>(s-m)/r}function y(t){const{id:e,geometry:i,properties:n}=t;if(!i)return;if("GeometryCollection"===i.type)throw new Error("GeometryCollection not supported in dynamic mode.");const{type:r,coordinates:o}=i,s={id:e,type:1,geometry:[],tags:n,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0},a=s.geometry;if("Point"===r)v(o,a,s);else if("MultiPoint"===r)for(const t of o)v(t,a,s);else if("LineString"===r)s.type=2,x(o,a,s);else if("MultiLineString"===r)s.type=2,b(o,a,s);else if("Polygon"===r)s.type=3,b(o,a,s,!0);else{if("MultiPolygon"!==r)throw new Error("Input data is not a valid GeoJSON object.");s.type=3;for(const t of o)b(t,a,s,!0)}return s}function v([e,i],n,r){const o=t.aj(e);let s=t.ak(i);s=s1?1:s,n.push(o,s),r.minX=Math.min(r.minX,o),r.minY=Math.min(r.minY,s),r.maxX=Math.max(r.maxX,o),r.maxY=Math.max(r.maxY,s)}function x(t,e,i,n=!1,r=!1){const o=[];for(const e of t)v(e,o,i);e.push(o),n&&function(t,e){let i=0;for(let e=0,n=t.length,r=n-2;e0===e)for(let e=0,i=t.length;e>31}function F(t,e){for(var i=t.loadGeometry(),n=t.type,r=0,o=0,s=i.length,a=0;at},V=Math.fround||(G=new Float32Array(1),t=>(G[0]=+t,G[0]));var G;const Z=3,q=5,H=6;class W{constructor(t){this.options=Object.assign(Object.create(j),t),this.trees=new Array(this.options.maxZoom+1),this.stride=this.options.reduce?7:6,this.clusterProps=[]}load(t){const{log:e,minZoom:i,maxZoom:n}=this.options;e&&console.time("total time");const r=`prepare ${t.length} points`;e&&console.time(r),this.points=t;const o=[];for(let e=0;e=i;t--){const i=+Date.now();s=this.trees[t]=this._createTree(this._cluster(s,t)),e&&console.log("z%d: %d clusters in %dms",t,s.numItems,+Date.now()-i)}return e&&console.timeEnd("total time"),this}getClusters(t,e){let i=((t[0]+180)%360+360)%360-180;const n=Math.max(-90,Math.min(90,t[1]));let r=180===t[2]?180:((t[2]+180)%360+360)%360-180;const o=Math.max(-90,Math.min(90,t[3]));if(t[2]-t[0]>=360)i=-180,r=180;else if(i>r){const t=this.getClusters([i,n,180,o],e),s=this.getClusters([-180,n,r,o],e);return t.concat(s)}const s=this.trees[this._limitZoom(e)],a=s.range(K(i),J(o),K(r),J(n)),l=s.data,c=[];for(const t of a){const e=this.stride*t;c.push(l[e+q]>1?Y(l,e,this.clusterProps):this.points[l[e+Z]])}return c}getChildren(t){const e=this._getOriginId(t),i=this._getOriginZoom(t),n="No cluster with the specified id.",r=this.trees[i];if(!r)throw new Error(n);const o=r.data;if(e*this.stride>=o.length)throw new Error(n);const s=this.options.radius/(this.options.extent*Math.pow(2,i-1)),a=r.within(o[e*this.stride],o[e*this.stride+1],s),l=[];for(const e of a){const i=e*this.stride;o[i+4]===t&&l.push(o[i+q]>1?Y(o,i,this.clusterProps):this.points[o[i+Z]])}if(0===l.length)throw new Error(n);return l}getLeaves(t,e,i){const n=[];return this._appendLeaves(n,t,e=e||10,i=i||0,0),n}getTile(t,e,i){const n=this.trees[this._limitZoom(t)],r=Math.pow(2,t),{extent:o,radius:s}=this.options,a=s/o,l=(i-a)/r,c=(i+1+a)/r,d={features:[]};return this._addTileFeatures(n.range((e-a)/r,l,(e+1+a)/r,c),n.data,e,i,r,d),0===e&&this._addTileFeatures(n.range(1-a/r,l,1,c),n.data,r,i,r,d),e===r-1&&this._addTileFeatures(n.range(0,l,a/r,c),n.data,-1,i,r,d),d.features.length?d:null}getClusterExpansionZoom(t){let e=this._getOriginZoom(t)-1;for(;e1;let l,c,d;if(a)l=X(e,t,this.clusterProps),c=e[t],d=e[t+1];else{const i=this.points[e[t+Z]];l=i.properties;const[n,r]=i.geometry.coordinates;c=K(n),d=J(r)}const u={type:1,geometry:[[Math.round(this.options.extent*(c*r-i)),Math.round(this.options.extent*(d*r-n))]],tags:l};let h;h=a||this.options.generateId?e[t+Z]:this.points[e[t+Z]].id,void 0!==h&&(u.id=h),o.features.push(u)}}_limitZoom(t){return Math.max(this.options.minZoom,Math.min(Math.floor(+t),this.options.maxZoom+1))}_cluster(t,e){const{radius:i,extent:n,reduce:r,minPoints:o}=this.options,s=i/(n*Math.pow(2,e)),a=t.data,l=[],c=this.stride;for(let i=0;ie&&(p+=a[i+q])}if(p>h&&p>=o){let t,o=n*h,s=d*h,f=-1;const m=(i/c1)for(const t of u){const i=t*c;if(!(a[i+2]>5}_getOriginZoom(t){return(t-this.points.length)%32}_map(t,e,i){if(t[e+q]>1){const n=this.clusterProps[t[e+H]];return i?Object.assign({},n):n}const n=this.points[t[e+Z]].properties,r=this.options.map(n);return i&&r===n?Object.assign({},r):r}}function Y(t,e,i){return{type:"Feature",id:t[e+Z],properties:X(t,e,i),geometry:{type:"Point",coordinates:[(n=t[e],360*(n-.5)),Q(t[e+1])]}};var n}function X(t,e,i){const n=t[e+q],r=n>=1e4?`${Math.round(n/1e3)}k`:n>=1e3?Math.round(n/100)/10+"k":n,o=t[e+H],s=-1===o?{}:Object.assign({},i[o]);return Object.assign(s,{cluster:!0,cluster_id:t[e+Z],point_count:n,point_count_abbreviated:r})}function K(t){return t/360+.5}function J(t){const e=Math.sin(t*Math.PI/180),i=.5-.25*Math.log((1+e)/(1-e))/Math.PI;return i1?1:i}function Q(t){const e=(180-360*t)*Math.PI/180;return 360*Math.atan(Math.exp(e))/Math.PI-90}function tt(t,e,i,n){let r=n;const o=e+(i-e>>1);let s,a=i-e;const l=t[e],c=t[e+1],d=t[i],u=t[i+1];for(let n=e+3;n 0||l>0&&s;)0!==a&&(0===l||!s||r.z1)}(r)}(t,n,r,o);let a=t;for(;t.prev!==t.next;){const l=t.prev,c=t.next;if(o?Eh(t,n,r,o):Sh(t))e.push(l.i,t.i,c.i),Vh(t),t=c.next,a=c.next;else if((t=c)===a){s?1===s?Th(t=Mh(wh(t),e),e,i,n,r,o,2):2===s&&Ch(t,e,i,n,r,o):Th(wh(t),e,i,n,r,o,1);break}}}function Sh(t){const e=t.prev,i=t,n=t.next;if(zh(e,i,n)>=0)return!1;const r=e.x,o=i.x,s=n.x,a=e.y,l=i.y,c=n.y,d=ro?r>s?r:s:o>s?o:s,p=a>l?a>c?a:c:l>c?l:c;let f=n.next;for(;f!==e;){if(f.x>=d&&f.x=u&&f.y=0)return!1;f=f.next}return!0}function Eh(t,e,i,n){const r=t.prev,o=t,s=t.next;if(zh(r,o,s)>=0)return!1;const a=r.x,l=o.x,c=s.x,d=r.y,u=o.y,h=s.y,p=al?a>c?a:c:l>c?l:c,_=d>u?d>h?d:h:u>h?u:h,g=Ph(p,f,e,i,n),y=Ph(m,_,e,i,n);let v=t.prevZ,x=t.nextZ;for(;v&&v.z>=g&&x&&x.z=p&&v.x=f&&v.y=0)return!1;if(v=v.prevZ,x.x>=p&&x.x=f&&x.y=0)return!1;x=x.nextZ}for(;v&&v.z>=g;){if(v.x>=p&&v.x=f&&v.y=0)return!1;v=v.prevZ}for(;x&&x.z=p&&x.x=f&&x.y=0)return!1;x=x.nextZ}return!0}function Mh(t,e){let i=t;do{const n=i.prev,r=i.next.next;!Rh(n,r)&&Oh(n,i,i.next,r)&&Nh(n,r)&&Nh(r,n)&&(e.push(n.i,i.i,r.i),Vh(i),Vh(i.next),i=t=r),i=i.next}while(i!==t);return wh(i)}function Ch(t,e,i,n,r,o){let s=t;do{let t=s.next.next;for(;t!==s.prev;){if(s.i!==t.i&&Dh(s,t)){let a=Uh(s,t);return s=wh(s,s.next),a=wh(a,a.next),Th(s,e,i,n,r,o,0),void Th(a,e,i,n,r,o,0)}t=t.next}s=s.next}while(s!==t)}function Ah(t,e){return t.x-e.x}function Ih(t,e){const i=function(t,e){let i=e;const n=t.x,r=t.y;let o,s=-1/0;do{if(r=i.next.y&&i.next.y!==i.y){const t=i.x+(r-i.y)*(i.next.x-i.x)/(i.next.y-i.y);if(ts&&(s=t,o=i.x=i.x&&i.x>=l&&n!==i.x&&kh(ro.x||i.x===o.x&&Lh(o,i)))&&(o=i,d=e)}i=i.next}while(i!==a);return o}(t,e);if(!i)return e;const n=Uh(i,t);return wh(n,n.next),wh(i,i.next)}function Lh(t,e){return zh(t.prev,t,e.prev)=(t-s)*(o-a)&&(t-s)*(n-a)>=(i-s)*(e-a)&&(i-s)*(o-a)>=(r-s)*(n-a)}function Dh(t,e){return t.next.i!==e.i&&t.prev.i!==e.i&&!function(t,e){let i=t;do{if(i.i!==t.i&&i.next.i!==t.i&&i.i!==e.i&&i.next.i!==e.i&&Oh(i,i.next,t,e))return!0;i=i.next}while(i!==t);return!1}(t,e)&&(Nh(t,e)&&Nh(e,t)&&function(t,e){let i=t,n=!1;const r=(t.x+e.x)/2,o=(t.y+e.y)/2;do{i.y>o!=i.next.y>o&&i.next.y!==i.y&&r0&&zh(e.prev,e,e.next)>0)}function zh(t,e,i){return(e.y-t.y)*(i.x-e.x)-(e.x-t.x)*(i.y-e.y)}function Rh(t,e){return t.x===e.x&&t.y===e.y}function Oh(t,e,i,n){const r=Fh(zh(t,e,i)),o=Fh(zh(t,e,n)),s=Fh(zh(i,n,t)),a=Fh(zh(i,n,e));return r!==o&&s!==a||!(0!==r||!Bh(t,i,e))||!(0!==o||!Bh(t,n,e))||!(0!==s||!Bh(i,t,n))||!(0!==a||!Bh(i,e,n))}function Bh(t,e,i){return e.x=Math.min(t.x,i.x)&&e.y=Math.min(t.y,i.y)}function Fh(t){return t>0?1:t=0&&zh(t,t.prev,e)>=0:zh(t,e,t.prev)1)for(let t=0;tt.fqid)),this.index=t.index,this.hasPattern=!1,this.patternFeatures=[],this.layoutVertexArray=new $l,this.indexArray=new Kl,this.indexArray2=new ql,this.programConfigurations=new Yc(t.layers,{zoom:t.zoom,lut:t.lut}),this.segments=new wc,this.segments2=new wc,this.stateDependentLayerIds=this.layers.filter((t=>t.isStateDependent())).map((t=>t.id)),this.projection=t.projection}updateFootprints(t,e){}populate(t,e,i,n){this.hasPattern=Hh("fill",this.layers,e);const r=this.layers[0].layout.get("fill-sort-key"),o=[];for(const{feature:s,id:a,index:l,sourceLayerIndex:c}of t){const t=this.layers[0]._featureFilter.needGeometry,d=Zd(s,t);if(!this.layers[0]._featureFilter.filter(new Ha(this.zoom),d,i))continue;const u=r?r.evaluate(d,{},i,e.availableImages):void 0,h={id:a,properties:s.properties,type:s.type,sourceLayerIndex:c,index:l,geometry:t?d.geometry:Gd(s,i,n),patterns:{},sortKey:u};o.push(h)}r&&o.sort(((t,e)=>t.sortKey-e.sortKey));for(const n of o){const{geometry:r,index:o,sourceLayerIndex:s}=n;if(this.hasPattern){const t=Wh("fill",this.layers,n,this.zoom,e);this.patternFeatures.push(t)}else this.addFeature(n,r,o,i,{},e.availableImages,e.brightness);e.featureIndex.insert(t[o].feature,r,o,s,this.index)}}update(t,e,i,n,r){const o=0!==Object.keys(t).length;o&&!this.stateDependentLayers.length||this.programConfigurations.updatePaintArrays(t,e,o?this.stateDependentLayers:this.layers,i,n,r)}addFeatures(t,e,i,n,r,o){for(const t of this.patternFeatures)this.addFeature(t,t.geometry,t.index,e,i,n,o)}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(t){this.uploaded||(this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,vh),this.indexBuffer=t.createIndexBuffer(this.indexArray),this.indexBuffer2=t.createIndexBuffer(this.indexArray2)),this.programConfigurations.upload(t),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.indexBuffer2.destroy(),this.programConfigurations.destroy(),this.segments.destroy(),this.segments2.destroy())}addFeature(t,e,i,n,r,o=[],s){for(const t of Zh(e,500)){let e=0;for(const i of t)e+=i.length;const i=this.segments.prepareSegment(e,this.layoutVertexArray,this.indexArray),n=i.vertexLength,r=[],o=[];for(const e of t){if(0===e.length)continue;e!==t[0]&&o.push(r.length/2);const i=this.segments2.prepareSegment(e.length,this.layoutVertexArray,this.indexArray2),n=i.vertexLength;this.layoutVertexArray.emplaceBack(e[0].x,e[0].y),this.indexArray2.emplaceBack(n+e.length-1,n),r.push(e[0].x),r.push(e[0].y);for(let t=1;tt.cellIdx-e.cellIdx||t.triIdx-e.triIdx));let c=0;for(;cthis.max.x||this.min.x>t.x||t.y>this.max.y||this.min.y>t.y)return;const i=Qh(t.x-this.min.x,this.xScale,this.cellsX),n=Qh(t.y-this.min.y,this.yScale,this.cellsY),r=this.cells[n*this.cellsX+i];if(r){this._lazyInitLookup();for(let t=0;tthis.max.x||this.min.x>e.x)return;if(t.y>this.max.y||this.min.y>e.y)return;this._lazyInitLookup();const n=Qh(t.x-this.min.x,this.xScale,this.cellsX),r=Qh(e.x-this.min.x,this.xScale,this.cellsX),o=Qh(t.y-this.min.y,this.yScale,this.cellsY),s=Qh(e.y-this.min.y,this.yScale,this.cellsY);for(let t=o;tt.fqid)),this.index=t.index,this.hasPattern=!1,this.stateDependentLayerIds=this.layers.filter((t=>t.isStateDependent())).map((t=>t.id)),this.footprints=[]}updateFootprints(t,e){for(const i of this.footprints)e.push({footprint:i,id:t})}populate(t,e,i,n){const r=[];for(const{feature:e,id:o,index:s,sourceLayerIndex:a}of t){const t=this.layers[0]._featureFilter.needGeometry,l=Zd(e,t);if(!this.layers[0]._featureFilter.filter(new Ha(this.zoom),l,i))continue;const c={id:o,properties:e.properties,type:e.type,sourceLayerIndex:a,index:s,geometry:t?l.geometry:Gd(e,i,n),patterns:{}};r.push(c)}for(const n of r){const{geometry:r,index:o,sourceLayerIndex:s}=n;this.addFeature(n,r,o,i,{},e.availableImages,e.brightness),e.featureIndex.insert(t[o].feature,r,o,s,this.index)}}isEmpty(){return 0===this.footprints.length}uploadPending(){return!1}upload(t){}update(t,e,i,n,r){}destroy(){}addFeature(t,e,i,n,r,o=[],s){for(const t of Zh(e,2)){const e=[],i=[],n=[],r=new Ue(1/0,1/0),o=new Ue(-1/0,-1/0);for(const s of t)if(0!==s.length){s!==t[0]&&n.push(i.length/2);for(let t=0;t>3}if(r--,1===n||2===n)o+=t.readSVarint(),s+=t.readSVarint(),1===n&&(e&&a.push(e),e=[]),e.push(new dp(o,s));else{if(7!==n)throw new Error("unknown command "+n);e&&e.push(e[0].clone())}}return e&&a.push(e),a},hp.prototype.bbox=function(){var t=this._pbf;t.pos=this._geometry;for(var e=t.readVarint()+t.pos,i=1,n=0,r=0,o=0,s=1/0,a=-1/0,l=1/0,c=-1/0;t.pos>3}if(n--,1===i||2===i)(r+=t.readSVarint())a&&(a=r),(o+=t.readSVarint())c&&(c=o);else if(7!==i)throw new Error("unknown command "+i)}return[s,l,a,c]},hp.prototype.toGeoJSON=function(t,e,i){var n,r,o=this.extent*Math.pow(2,i),s=this.extent*t,a=this.extent*e,l=this.loadGeometry(),c=hp.types[this.type];function d(t){for(var e=0;e>3;e=1===n?t.readString():2===n?t.readFloat():3===n?t.readDouble():4===n?t.readVarint64():5===n?t.readVarint():6===n?t.readSVarint():7===n?t.readBoolean():null}return e}(i))}gp.prototype.feature=function(t){if(t=this._features.length)throw new Error("feature index out of bounds");this._pbf.pos=this._features[t];var e=this._pbf.readVarint()+this._pbf.pos;return new mp(this._pbf,e,this.extent,this._keys,this._values)};var vp=_p;function xp(t,e,i){if(3===t){var n=new vp(i,i.readVarint()+i.pos);n.length&&(e[n.name]=n)}}var bp=cp.VectorTile=function(t,e){this.layers=t.readFields(xp,{},e)},wp=cp.VectorTileFeature=up;cp.VectorTileLayer=_p;class Tp extends Ue{constructor(t,e,i){super(t,e),this.z=i}}class Sp extends Tp{constructor(t,e,i,n){super(t,e,i),this.w=n}}function Ep(t,e,i,n){const r=[],o=0===n?(t,e,i,n,r,o)=>{t.push(new Ue(o,i+(o-e)/(n-e)*(r-i)))}:(t,e,i,n,r,o)=>{t.push(new Ue(e+(o-i)/(r-i)*(n-e),o))};for(const s of t){const t=[];for(const r of s){if(r.lengthe&&o(s,a,l,c,d,e):u>i?h=e&&o(s,a,l,c,d,e),h>i&&u=e&&l=s[i]&&(n=e,s=t),n[i]r&&Mp(n,s,i,r),n[i]o&&Mp(s,n,i,o)}}function Ap(t,e){return t.x-e.x||t.y-e.y}function Ip(t,e){return 0===Ap(t.min,e.min)&&0===Ap(t.max,e.max)}function Lp(t,e){return!(t.min.x>e.max.x||t.max.xe.max.y||t.max.ynew Ue((t.x+o.x*uo)*a-s.x*uo,(t.y+o.y*uo)*a-s.y*uo)))}return Dp(i,r,t.indices,0,t.indices.length,0,0)}function Rp(t,e,i,n){const r=Math.pow(2,n.z-i.z);return new Ue((t+i.x*uo)*r-n.x*uo,(e+i.y*uo)*r-n.y*uo)}function Op(t,e){const i=[];e.footprint.grid.queryPoint(t,i);const n=e.footprint.indices,r=e.footprint.vertices;for(let e=0;ee[s])return null}else{const a=1/n[s];let l=(t[s]-i[s])*a,c=(e[s]-i[s])*a;if(l>c){const t=l;l=c,c=t}if(l>r&&(r=l),co)return null}return r}function Np(t,e,i,n,r,o,s,a,l,c,d){const u=n-t,h=r-e,p=o-i,f=s-t,m=a-e,_=l-i,g=d[1]*_-d[2]*m,y=d[2]*f-d[0]*_,v=d[0]*m-d[1]*f,x=u*g+h*y+p*v;if(Math.abs(x)1)return null;const M=T*p-S*h,C=S*u-w*p,A=w*h-T*u,I=(d[0]*M+d[1]*C+d[2]*A)*b;return I1?null:(f*M+m*C+_*A)*b}function Up(t,e,i){return(t-e)/(i-e)}function jp(t,e,i,n,r,o,s,a,l){const c=1{const o=n?1:0,s=(t+1)*i-o,a=e*i,l=(e+1)*i-o;r[0]=t*i,r[1]=a,r[2]=s,r[3]=l};let s=new Bp(n);const a=[];for(let e=0;e=1;n/=2){const t=i[i.length-1];s=new Bp(n);for(let e=0;e0;){const{idx:l,t:f,nodex:m,nodey:_,depth:g}=p.pop();if(this.leaves[l]){jp(m,_,g,e,i,n,r,u,h);const l=1=e[2])return f}continue}let y=0;for(let t=0;t=c[d[n]]&&(d.splice(n,0,t),i=!0);i||(d[y]=t),y++}}for(let t=0;t=this.dim+1||e=this.dim+1)throw new RangeError("out of range source coordinates for DEM data");return(e+1)*this.stride+(t+1)}static pack(t,e){const i=[0,0,0,0],n=Yp.getUnpackVector(e);let r=Math.floor((t+n[3])/n[2]);return i[2]=r%256,r=Math.floor(r/256),i[1]=r%256,r=Math.floor(r/256),i[0]=r,i}getPixels(){return new hh({width:this.stride,height:this.stride},this.pixels)}backfillBorder(t,e,i){if(this.dim!==t.dim)throw new Error("dem dimension mismatch");let n=e*this.dim,r=e*this.dim+this.dim,o=i*this.dim,s=i*this.dim+this.dim;switch(e){case-1:n=r-1;break;case 1:r=n+1}switch(i){case-1:o=s-1;break;case 1:s=o+1}const a=-e*this.dim,l=-i*this.dim;for(let e=o;et.max.x&&(t.max.x=e.x,n=!0),e.yt.max.y&&(t.max.y=e.y,n=!0),((0===e.x||e.x===uo)&&e.x===i.x)!=((0===e.y||e.y===uo)&&e.y===i.y)&&this.processBorderOverlap(e,i),n&&this.checkBorderIntersection(e,i)}checkBorderIntersection(t,e){e.xuo!=t.x>uo&&this.addBorderIntersection(1,Vn(e.y,t.y,(uo-e.x)/(t.x-e.x))),e.yuo!=t.y>uo&&this.addBorderIntersection(3,Vn(e.x,t.x,(uo-e.y)/(t.y-e.y)))}addBorderIntersection(t,e){this.borders||(this.borders=[[Number.MAX_VALUE,-Number.MAX_VALUE],[Number.MAX_VALUE,-Number.MAX_VALUE],[Number.MAX_VALUE,-Number.MAX_VALUE],[Number.MAX_VALUE,-Number.MAX_VALUE]]);const i=this.borders[t];ei[1]&&(i[1]=e)}processBorderOverlap(t,e){if(t.x===e.x){if(t.y===e.y)return;const i=0===t.x?0:1;this.addBorderIntersection(i,e.y),this.addBorderIntersection(i,t.y)}else{const i=0===t.y?2:3;this.addBorderIntersection(i,e.x),this.addBorderIntersection(i,t.x)}}centroid(){return 0===this.accCount?new Ue(0,0):new Ue(Math.floor(Math.max(0,this.acc.x)/this.accCount),Math.floor(Math.max(0,this.acc.y)/this.accCount))}intersectsCount(){return this.borders?this.borders.reduce(((t,e)=>t+ +(e[0]!==Number.MAX_VALUE)),0):0}}function hf(t,e){const i=t.add(e)._unit(),n=Xe(t.x*i.x+t.y*i.y,-1,1);var r,o,s;return r=Math.acos(n),Math.min(4,Math.max(-4,Math.tan(r)))/4*nf*((o=t).x*(s=e).y-o.y*s.xt.xt.x>uo,t=>t.yt.y>uo];function ff(t,e,i,n){const r=[4];if(0===n)return r;i._mult(n);const o=t.sub(i),s=e.sub(i),a=[t,e,o,s];for(let t=0;ttf.includes(t))),this._segments=new wc,this.hiddenByLandmarkVertexArray=new lc,this._segmentToGroundQuads={},this._segmentToGroundQuads[0]=[],this._segmentToRegionTriCounts={},this._segmentToRegionTriCounts[0]=[0,0,0,0,0],this.regionSegments={},this.regionSegments[4]=new wc}getDefaultSegment(){return this.regionSegments[4]}hasData(){return 0!==this.vertexArray.length}addData(t,e,i,n=!1){const r=t.length;if(r>2){let o=Math.max(0,this._segments.get().length-1);const s=this._segments._prepareSegment(4*r,this.vertexArray.length,2*this._segmentToGroundQuads[o].length);let a;o!==this._segments.get().length-1&&(o++,this._segmentToGroundQuads[o]=[],this._segmentToRegionTriCounts[o]=[0,0,0,0,0]);{const e=t[0],i=t[1];a=hf(e.sub(t[r-1])._perp()._unit(),i.sub(e)._perp()._unit())}for(let l=0;lt.region-e.region));for(let i=0;it+e),0);let o=0;for(let t=0;t0?this.hiddenByLandmarkVertexBuffer=t.createVertexBuffer(this.hiddenByLandmarkVertexArray,sp.members,!0):this.hiddenByLandmarkVertexBuffer&&this.hiddenByLandmarkVertexBuffer.updateData(this.hiddenByLandmarkVertexArray),this._needsHiddenByLandmarkUpdate=!1)}destroy(){if(this.vertexBuffer){this.vertexBuffer.destroy(),this.indexBuffer.destroy(),this.hiddenByLandmarkVertexBuffer&&this.hiddenByLandmarkVertexBuffer.destroy(),this._segments&&this._segments.destroy(),this.programConfigurations.destroy();for(let t=0;tt.fqid)),this.index=t.index,this.hasPattern=!1,this.edgeRadius=0,this.projection=t.projection,this.activeReplacements=[],this.replacementUpdateTime=0,this.centroidData=[],this.footprintIndices=new Kl,this.footprintVertices=new $l,this.footprintSegments=[],this.layoutVertexArray=new Dl,this.centroidVertexArray=new vc,this.indexArray=new Kl,this.programConfigurations=new Yc(t.layers,{zoom:t.zoom,lut:t.lut},(t=>Qp.includes(t))),this.segments=new wc,this.stateDependentLayerIds=this.layers.filter((t=>t.isStateDependent())).map((t=>t.id)),this.groundEffect=new mf(t),this.maxHeight=0,this.partLookup={},this.triangleSubSegments=[],this.polygonSegments=[]}updateFootprints(t,e){}populate(t,e,i,n){this.features=[],this.hasPattern=Hh("fill-extrusion",this.layers,e),this.featuresOnBorder=[],this.borderFeatureIndices=[[],[],[],[]],this.borderDoneWithNeighborZ=[-1,-1,-1,-1],this.tileToMeter=zd(i),this.edgeRadius=this.layers[0].layout.get("fill-extrusion-edge-radius")/this.tileToMeter;for(const{feature:r,id:o,index:s,sourceLayerIndex:a}of t){const t=this.layers[0]._featureFilter.needGeometry,l=Zd(r,t);if(!this.layers[0]._featureFilter.filter(new Ha(this.zoom),l,i))continue;const c={id:o,sourceLayerIndex:a,index:s,geometry:t?l.geometry:Gd(r,i,n),properties:r.properties,type:r.type,patterns:{}},d=this.layoutVertexArray.length;this.hasPattern?this.features.push(Wh("fill-extrusion",this.layers,c,this.zoom,e)):this.addFeature(c,c.geometry,s,i,{},e.availableImages,n,e.brightness),e.featureIndex.insert(r,c.geometry,s,a,this.index,d)}this.sortBorders(),"mercator"===this.projection.name&&this.splitToSubtiles(),this.groundEffect.prepareBorderSegments(),this.polygonSegments.length=0}addFeatures(t,e,i,n,r,o){for(const t of this.features){const{geometry:s}=t;this.addFeature(t,s,t.index,e,i,n,r,o)}this.sortBorders(),"mercator"===this.projection.name&&this.splitToSubtiles()}update(t,e,i,n,r){const o=0!==Object.keys(t).length;if(o&&!this.stateDependentLayers.length)return;const s=o?this.stateDependentLayers:this.layers;this.programConfigurations.updatePaintArrays(t,e,s,i,n,r),this.groundEffect.update(t,e,s,i,n,r)}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload||this.groundEffect.programConfigurations.needsUpload}upload(t){this.uploaded||(this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,lp),this.indexBuffer=t.createIndexBuffer(this.indexArray),this.layoutVertexExtArray&&(this.layoutVertexExtBuffer=t.createVertexBuffer(this.layoutVertexExtArray,ap.members,!0)),this.groundEffect.upload(t)),this.groundEffect.uploadPaintProperties(t),this.programConfigurations.upload(t),this.uploaded=!0}uploadCentroid(t){this.groundEffect.uploadHiddenByLandmark(t),this.needsCentroidUpdate&&(!this.centroidVertexBuffer&&this.centroidVertexArray.length>0?this.centroidVertexBuffer=t.createVertexBuffer(this.centroidVertexArray,op.members,!0):this.centroidVertexBuffer&&this.centroidVertexBuffer.updateData(this.centroidVertexArray),this.needsCentroidUpdate=!1)}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.centroidVertexBuffer&&this.centroidVertexBuffer.destroy(),this.layoutVertexExtBuffer&&this.layoutVertexExtBuffer.destroy(),this.groundEffect.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy())}addFeature(t,e,i,n,r,o,s,a){const l=this.layers[0].paint.get("fill-extrusion-flood-light-ground-radius").evaluate(t,{})/this.tileToMeter,c=[new Ue(0,0),new Ue(uo,uo)],d=s.projection,u="globe"===d.name,h="Polygon"===Jp[t.type],p=new uf;p.centroidDataIndex=this.centroidData.length;const f=new df,m=this.layers[0].paint.get("fill-extrusion-base").evaluate(t,{},n)=0;t--){const e=g[t];(0===e.length||(y=e[0]).every((t=>t.xt.x>=uo))||y.every((t=>t.yt.y>=uo)))&&g.splice(t,1)}var y;let v;if(u)v=Ef(g,c,n);else{v=[];for(const t of g)v.push({polygon:t,bounds:c})}const x=h?this.edgeRadius:0,b=x>0&&this.zoom{if(0===t.length)return!1;const i=t[t.length-1];return e.x===i.x&&e.y===i.y};for(const{polygon:t,bounds:e}of v){let i=0,r=0;for(const e of t)h&&!e[0].equals(e[e.length-1])&&e.push(e[0]),r+=h?e.length-1:e.length;const o=this.segments.prepareSegment((h?5:4)*r,this.layoutVertexArray,this.indexArray);f.footprintSegIdx4&&wf(s[s.length-2],s[0],s[1]),c=x?yf(s[s.length-2],s[0],s[1],x):0;const _=[];let g,y,v;y=s[1].sub(s[0])._perp()._unit();let b=!0;for(let t=1,r=0;t0?1:0,C=l.dist(h);if(r+C>32768&&(r=0),x){v=T.sub(h)._perp()._unit();let t=vf(l,h,T,gf(y,v),x);isNaN(t)&&(t=0);const e=h.sub(l)._unit();l=l.add(e.mult(c))._round(),h=h.add(e.mult(-t))._round(),c=t,y=v,m&&this.zoom>=17&&(w(_,l)||_.push(l),w(_,h)||_.push(h))}const A=o.vertexLength,I=s.length>4&&wf(l,h,T);let L=Tf(r,a,b);if(sf(this.layoutVertexArray,l.x,l.y,E,M,0,0,L),sf(this.layoutVertexArray,l.x,l.y,E,M,0,1,L),r+=C,L=Tf(r,I,!b),a=I,sf(this.layoutVertexArray,h.x,h.y,E,M,0,0,L),sf(this.layoutVertexArray,h.x,h.y,E,M,0,1,L),o.vertexLength+=4,this.indexArray.emplaceBack(A+0,A+1,A+2),this.indexArray.emplaceBack(A+1,A+3,A+2),o.primitiveLength+=2,x){const n=i+(1===t?s.length-2:t-2),r=1===t?i:n+1;if(this.indexArray.emplaceBack(A+1,n,A+3),this.indexArray.emplaceBack(n,r,A+3),o.primitiveLength+=2,void 0===g&&(g=A),!xf(T,s[t],e)){const e=t===s.length-1?g:o.vertexLength;this.indexArray.emplaceBack(A+2,A+3,e),this.indexArray.emplaceBack(A+3,e+1,e),this.indexArray.emplaceBack(A+3,r,e+1),o.primitiveLength+=3}b=!b}if(u){const t=this.layoutVertexExtArray,e=d.projectTilePoint(l.x,l.y,n),i=d.projectTilePoint(h.x,h.y,n),r=d.upVector(n,l.x,l.y),o=d.upVector(n,h.x,h.y);lf(t,e,r),lf(t,e,r),lf(t,i,o),lf(t,i,o)}}h&&(i+=s.length-1),m&&x&&this.zoom>=17&&(0!==_.length&&w(_,_[0])&&_.pop(),this.groundEffect.addData(_,e,l,x>0))}this.footprintSegments.push(a),s.triangleCount=this.indexArray.length-s.triangleArrayOffset,this.polygonSegments.push(s),++f.footprintSegLen,++f.polygonSegLen}if(f.vertexCount=this.layoutVertexArray.length-f.vertexArrayOffset,f.groundVertexCount=this.groundEffect.vertexArray.length-f.groundVertexArrayOffset,0!==f.vertexCount){if(f.centroidXY=p.borders?rf:this.encodeCentroid(p,f),this.centroidData.push(f),p.borders){this.featuresOnBorder.push(p);const t=this.featuresOnBorder.length-1;for(let e=0;ethis.featuresOnBorder[e].borders[t][0]-this.featuresOnBorder[i].borders[t][0]))}splitToSubtiles(){const t=[];for(let e=0;euo),r=2*n+(+(i.min.x+i.max.x>uo)^n);for(let n=0;nt.triangleSegmentIdx===e.triangleSegmentIdx?t.subtile-e.subtile:t.triangleSegmentIdx-e.triangleSegmentIdx));let i=0,n=0,r=0;for(const e of t){if(e.triangleSegmentIdx!==i)break;r++}const o=t.length;for(;n!==t.length;){i=t[n].triangleSegmentIdx;let s=0,a=n,l=n;for(let e=a;e0&&this.triangleSubSegments.push({segment:d,min:o,max:c}),a=l;for(let e=a;e[t[0]*(1-i[0])+e[0]*i[0],t[1]*(1-i[1])+e[1]*i[1]],h=[],p=[];for(const t of this.triangleSubSegments){h[0]=t.min.x/uo,h[1]=t.min.y/uo,p[0]=t.max.x/uo,p[1]=t.max.y/uo;const e=u(l,c,h),o=u(l,c,p);if(0===new wu([e[0],e[1],n],[o[0],o[1],r]).intersectsPrecise(i)){a&&(d.segments.push(a),a=void 0);continue}const s=t.segment;a&&a.vertexOffset!==s.vertexOffset&&(d.segments.push(a),a=void 0),a?(a.vertexLength+=s.vertexLength,a.primitiveLength+=s.primitiveLength):a={vertexOffset:s.vertexOffset,primitiveLength:s.primitiveLength,vertexLength:s.vertexLength,primitiveOffset:s.primitiveOffset,sortKey:void 0,vaos:{}}}return a&&d.segments.push(a),d}encodeCentroid(t,e){const i=t.centroid(),n=e.span(),r=Math.min(7,Math.round(n.x*this.tileToMeter/10)),o=Math.min(7,Math.round(n.y*this.tileToMeter/10));return new Ue(Xe(i.x,1,uo-1)i.max.x||i.min.x>e.max.x||e.min.y>i.max.y||i.min.y>e.max.y))for(let o=0;oe!=l>e&&to.max.x||o.min.x>t||e>o.max.y||o.min.y>e||this.footprintContainsPoint(t,e,o)&&o&&o.height>i&&(i=o.height,this.partLookup[r]=o,n=!!(o.flags&of));if(i!==Number.NEGATIVE_INFINITY)return{height:i,hidden:n};this.partLookup[r]=void 0}}function gf(t,e){const i=t.add(e)._unit();return t.x*i.x+t.y*i.y}function yf(t,e,i,n){const r=e.sub(t)._perp()._unit(),o=i.sub(e)._perp()._unit();return vf(t,e,i,gf(r,o),n)}function vf(t,e,i,n,r){const o=Math.sqrt(1-n*n);return Math.min(t.dist(e)/3,e.dist(i)/3,r*o/n)}function xf(t,e,i){return t.xi[1].x&&e.x>i[1].x||t.yi[1].y&&e.y>i[1].y}function bf(t,e){return t.xe[1].x||t.ye[1].y}function wf(t,e,i){if(t.x=uo||e.x=uo||i.x=uo)return!1;const n=i.sub(e),r=n.perp(),o=t.sub(e);return(n.x*o.x+n.y*o.y)/Math.sqrt((n.x*n.x+n.y*n.y)*(o.x*o.x+o.y*o.y))>-.866&&r.x*o.x+r.y*o.y{for(const i of t)s.push({polygon:i,bounds:e})},l=Math.ceil(Math.log2(i)),c=Math.ceil(Math.log2(n)),d=l-c,u=[];for(let t=0;t0?0:1);for(let t=0;te+1?p.push({polygons:h,bounds:t,depth:e+1}):a(h,t)}if(f.length){const t=[new Ue(0===i?d:n.x,1===i?d:n.y),s];u.length>e+1?p.push({polygons:f,bounds:t,depth:e+1}):a(f,t)}}return s}(t,e,Math.ceil((o-r)/11.25),Math.ceil((s-a)/11.25),1,((t,e,r)=>{if(0===t)return.5*(e+r);{const t=Id((i.y+e/uo)/n);return(Md(.5*(Id((i.y+r/uo)/n)+t))*n-i.y)*uo}}))}function Mf(t,e,i,n,r,o){const s=Math.pow(2,n.z-r.z);for(let a=0;a1&&(s=t[++o]);const l=Math.abs(a-s.left),c=Math.abs(a-s.right),d=Math.min(l,c);let u;const h=e/i*(n+1);if(s.isDash){const t=n-Math.abs(h);u=Math.sqrt(d*d+t*t)}else u=n-Math.sqrt(d*d+h*h);this.image.data[r+a]=Math.max(0,Math.min(255,u+128))}}}addRegularDash(t,e){for(let e=t.length-1;e>=0;--e){const i=t[e],n=t[e+1];i.zeroLength?t.splice(e,1):n&&n.isDash===i.isDash&&(n.left=i.left,t.splice(e,1))}const i=t[0],n=t[t.length-1];i.isDash===n.isDash&&(i.left=n.left-this.width,n.right=i.right+this.width);const r=this.width*this.nextRow;let o=0,s=t[o];for(let i=0;i1&&(s=t[++o]);const n=Math.abs(i-s.left),a=Math.abs(i-s.right),l=Math.min(n,a);this.image.data[r+i]=Math.max(0,Math.min(255,(s.isDash?l:-l)+e+128))}}addDash(t,e){const i=this.getKey(t,e);if(this.positions[i])return this.positions[i];const n="round"===e,r=n?7:0,o=2*r+1;if(this.nextRow+o>this.height)return pi("LineAtlas out of space"),null;0===t.length&&t.push(1);let s=0;for(let e=0;et.fqid)),this.index=t.index,this.projection=t.projection,this.hasPattern=!1,this.hasZOffset=!1,this.patternFeatures=[],this.lineClipsArray=[],this.gradients={},this.layers.forEach((t=>{this.gradients[t.id]={}})),this.layoutVertexArray=new Rl,this.layoutVertexArray2=new Ol,this.patternVertexArray=new Bl,this.indexArray=new Kl,this.programConfigurations=new Yc(t.layers,{zoom:t.zoom,lut:t.lut}),this.segments=new wc,this.maxLineLength=0,this.zOffsetVertexArray=new Zl,this.stateDependentLayerIds=this.layers.filter((t=>t.isStateDependent())).map((t=>t.id)),this.tessellationStep=t.tessellationStep?t.tessellationStep:uo/64}updateFootprints(t,e){}populate(t,e,i,n){this.hasPattern=Hh("line",this.layers,e);const r=this.layers[0].layout.get("line-sort-key"),o=this.layers[0].layout.get("line-z-offset");this.hasZOffset=!o.isConstant()||!!o.constantOr(0);const s=[];for(const{feature:e,id:o,index:a,sourceLayerIndex:l}of t){const t=this.layers[0]._featureFilter.needGeometry,c=Zd(e,t);if(!this.layers[0]._featureFilter.filter(new Ha(this.zoom),c,i))continue;const d=r?r.evaluate(c,{},i):void 0,u={id:o,properties:e.properties,type:e.type,sourceLayerIndex:l,index:a,geometry:t?c.geometry:Gd(e,i,n),patterns:{},sortKey:d};s.push(u)}r&&s.sort(((t,e)=>t.sortKey-e.sortKey));const{lineAtlas:a,featureIndex:l}=e,c=this.addConstantDashes(a);for(const n of s){const{geometry:r,index:o,sourceLayerIndex:s}=n;if(c&&this.addFeatureDashes(n,a),this.hasPattern){const t=Wh("line",this.layers,n,this.zoom,e);this.patternFeatures.push(t)}else this.addFeature(n,r,o,i,a.positions,e.availableImages,e.brightness);l.insert(t[o].feature,r,o,s,this.index)}}addConstantDashes(t){let e=!1;for(const i of this.layers){const n=i.paint.get("line-dasharray").value,r=i.layout.get("line-cap").value;if("constant"!==n.kind||"constant"!==r.kind)e=!0;else{const e=r.value,i=n.value;if(!i)continue;t.addDash(i,e)}}return e}addFeatureDashes(t,e){const i=this.zoom;for(const n of this.layers){const r=n.paint.get("line-dasharray").value,o=n.layout.get("line-cap").value;if("constant"===r.kind&&"constant"===o.kind)continue;let s,a;if("constant"===r.kind){if(s=r.value,!s)continue}else s=r.evaluate({zoom:i},t);a="constant"===o.kind?o.value:o.evaluate({zoom:i},t),e.addDash(s,a),t.patterns[n.id]=e.getKey(s,a)}}update(t,e,i,n,r){const o=0!==Object.keys(t).length;o&&!this.stateDependentLayers.length||this.programConfigurations.updatePaintArrays(t,e,o?this.stateDependentLayers:this.layers,i,n,r)}addFeatures(t,e,i,n,r,o){for(const t of this.patternFeatures)this.addFeature(t,t.geometry,t.index,e,i,n,o)}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(t){this.uploaded||(0!==this.layoutVertexArray2.length&&(this.layoutVertexBuffer2=t.createVertexBuffer(this.layoutVertexArray2,zf)),0!==this.patternVertexArray.length&&(this.patternVertexBuffer=t.createVertexBuffer(this.patternVertexArray,Of)),!this.zOffsetVertexBuffer&&this.zOffsetVertexArray.length>0&&(this.zOffsetVertexBuffer=t.createVertexBuffer(this.zOffsetVertexArray,jf.members,!0)),this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,kf),this.indexBuffer=t.createIndexBuffer(this.indexArray)),this.programConfigurations.upload(t),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.zOffsetVertexBuffer&&this.zOffsetVertexBuffer.destroy(),this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy())}lineFeatureClips(t){if(t.properties&&t.properties.hasOwnProperty("mapbox_clip_start")&&t.properties.hasOwnProperty("mapbox_clip_end"))return{start:+t.properties.mapbox_clip_start,end:+t.properties.mapbox_clip_end}}addFeature(t,e,i,n,r,o,s){const a=this.layers[0].layout,l=a.get("line-join").evaluate(t,{}),c=a.get("line-cap").evaluate(t,{}),d=a.get("line-miter-limit"),u=a.get("line-round-limit");this.lineClips=this.lineFeatureClips(t);for(const i of e)this.addLine(i,t,n,l,c,d,u);this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,t,i,r,o,n,s)}addLine(t,e,i,n,r,o,s){this.distance=0,this.scaledDistance=0,this.totalDistance=0,this.lineSoFar=0,this.currentVertex=void 0;const a={zoom:this.zoom,lineProgress:void 0},l=this.layers[0].layout,c="none"===n;if(this.patternJoinNone=this.hasPattern&&c,this.segmentStart=0,this.segmentStartf32=0,this.segmentPoints=[],this.lineClips){this.lineClipsArray.push(this.lineClips);for(let e=0;e=2&&t[u-1].equals(t[u-2]);)u--;let h=0;for(;h0;if(A&&i>h){const t=m.dist(_);if(t>2*p){const e=m.sub(m.sub(_)._mult(p/t)._round());this.updateDistance(_,e),this.addCurrentVertex(e,y,0,0,f,x),_=e}}if(b&&"round"===w&&(Mo&&(w="bevel"),"bevel"===w&&(M>2&&(w="flipbevel"),M100)S=v.mult(-1);else{const t=M*y.add(v).mag()/y.sub(v).mag();S._perp()._mult(t*(I?-1:1))}this.addCurrentVertex(m,S,0,0,f,x),this.addCurrentVertex(m,S.mult(-1),0,0,f,x)}else if("bevel"===w||"fakeround"===w){const t=-Math.sqrt(M*M-1),e=I?t:0,i=I?0:t;if(_&&this.addCurrentVertex(m,y,e,i,f,x),"fakeround"===w){const t=Math.round(180*C/Math.PI/20);for(let e=1;e2*p){const e=m.add(g.sub(m)._mult(p/t)._round());this.updateDistance(m,e),this.addCurrentVertex(e,v,0,0,f,x),m=e}}}}addVerticesTo(t,e,i,n,r,o,s,a,l,c){const d=(e.w-t.w)/this.tessellationStep|0;if(d>1){this.lineSoFar=t.w;const u=(e.x-t.x)/d,h=(e.y-t.y)/d,p=(e.z-t.z)/d,f=(e.w-t.w)/d;for(let e=1;e=0&&this.e2>=0&&(this.indexArray.emplaceBack(this.e1,this.e2,c),a.primitiveLength++),o?this.e2=c:this.e1=c,null!=l&&this.zOffsetVertexArray.emplaceBack(l)}updateScaledDistance(){if(this.lineClips){const t=this.totalDistance/(this.lineClips.end-this.lineClips.start);this.scaledDistance=this.distance/this.totalDistance,this.lineSoFar=t*this.lineClips.start+this.distance}else this.lineSoFar=this.distance}updateDistance(t,e){this.distance+=t.dist(e),this.updateScaledDistance()}}function Qf(t,e,i){return t.xi||t.yi}ba(Jf,"LineBucket",{omit:["layers","patternFeatures","currentVertex","currentVertexIsOutside"]});const tm=new ol({"line-cap":new nl(sl.layout_line["line-cap"]),"line-join":new nl(sl.layout_line["line-join"]),"line-miter-limit":new il(sl.layout_line["line-miter-limit"]),"line-round-limit":new il(sl.layout_line["line-round-limit"]),"line-sort-key":new nl(sl.layout_line["line-sort-key"]),"line-z-offset":new nl(sl.layout_line["line-z-offset"]),visibility:new il(sl.layout_line.visibility)});var em={paint:new ol({"line-opacity":new nl(sl.paint_line["line-opacity"]),"line-color":new nl(sl.paint_line["line-color"]),"line-translate":new il(sl.paint_line["line-translate"]),"line-translate-anchor":new il(sl.paint_line["line-translate-anchor"]),"line-width":new nl(sl.paint_line["line-width"]),"line-gap-width":new nl(sl.paint_line["line-gap-width"]),"line-offset":new nl(sl.paint_line["line-offset"]),"line-blur":new nl(sl.paint_line["line-blur"]),"line-dasharray":new nl(sl.paint_line["line-dasharray"]),"line-pattern":new nl(sl.paint_line["line-pattern"]),"line-gradient":new rl(sl.paint_line["line-gradient"]),"line-trim-offset":new il(sl.paint_line["line-trim-offset"]),"line-trim-fade-range":new il(sl.paint_line["line-trim-fade-range"]),"line-trim-color":new il(sl.paint_line["line-trim-color"]),"line-emissive-strength":new il(sl.paint_line["line-emissive-strength"]),"line-border-width":new nl(sl.paint_line["line-border-width"]),"line-border-color":new nl(sl.paint_line["line-border-color"]),"line-occlusion-opacity":new il(sl.paint_line["line-occlusion-opacity"])}),layout:tm};function im(t,e,i){return e*(uo/(t.tileSize*Math.pow(2,i-t.tileID.overscaledZ)))}function nm(t,e){return 1/im(t,1,e.tileZoom)}function rm(t,e,i,n){return t.translatePosMatrix(n||e.tileID.projMatrix,e,i.paint.get("line-translate"),i.paint.get("line-translate-anchor"))}const om=t=>{const e=[];sm(t)&&e.push("RENDER_LINE_DASH"),t.paint.get("line-gradient")&&e.push("RENDER_LINE_GRADIENT");const i=t.paint.get("line-trim-offset");0===i[0]&&0===i[1]||e.push("RENDER_LINE_TRIM_OFFSET"),0!==t.paint.get("line-border-width").constantOr(1)&&e.push("RENDER_LINE_BORDER");const n="none"===t.layout.get("line-join").constantOr("miter"),r=!!t.paint.get("line-pattern").constantOr(1);return n&&r&&e.push("LINE_JOIN_NONE"),e};function sm(t){const e=t.paint.get("line-dasharray").value;return e.value||"constant"!==e.kind}class am{constructor(t){this._stringToNumber={},this._numberToString=[];for(let e=0;e>1,d=-7,u=i?r-1:0,h=i?-1:1,p=t[e+u];for(u+=h,o=p&(1>=-d,d+=a;d>0;o=256*o+t[e+u],u+=h,d-=8);for(s=o&(1>=-d,d+=n;d>0;s=256*s+t[e+u],u+=h,d-=8);if(0===o)o=1-c;else{if(o===l)return s?NaN:1/0*(p?-1:1);s+=Math.pow(2,n),o-=c}return(p?-1:1)*s*Math.pow(2,o-n)},write:function(t,e,i,n,r,o){var s,a,l,c=8*o-r-1,d=(1>1,h=23===r?Math.pow(2,-24)-Math.pow(2,-77):0,p=n?0:o-1,f=n?1:-1,m=e=1?h/l:h*Math.pow(2,1-u))*l>=2&&(s++,l/=2),s+u>=d?(a=0,s=d):s+u>=1?(a=(e*l-1)*Math.pow(2,r),s+=u):(a=e*Math.pow(2,u-1)*Math.pow(2,r),s=0));r>=8;t[i+p]=255&a,p+=f,a/=256,r-=8);for(s=s0;t[i+p]=255&s,p+=f,s/=256,c-=8);t[i+p-f]|=128*m}},cm=um,dm=lm;function um(t){this.buf=ArrayBuffer.isView&&ArrayBuffer.isView(t)?t:new Uint8Array(t||0),this.pos=0,this.type=0,this.length=this.buf.length}um.Varint=0,um.Fixed64=1,um.Bytes=2,um.Fixed32=5;var hm=4294967296,pm=1/hm,fm="undefined"==typeof TextDecoder?null:new TextDecoder("utf8");function mm(t){return t.type===um.Bytes?t.readVarint()+t.pos:t.pos+1}function _m(t,e,i){return i?4294967296*e+(t>>>0):4294967296*(e>>>0)+(t>>>0)}function gm(t,e,i){var n=e=t;r--)i.buf[r+n]=i.buf[r]}function ym(t,e){for(var i=0;i>>8,t[i+2]=e>>>16,t[i+3]=e>>>24}function Im(t,e){return(t[e]|t[e+1]>3,o=this.pos;this.type=7&n,t(r,e,this),this.pos===o&&this.skip(n)}return e},readMessage:function(t,e){return this.readFields(t,e,this.readVarint()+this.pos)},readFixed32:function(){var t=Cm(this.buf,this.pos);return this.pos+=4,t},readSFixed32:function(){var t=Im(this.buf,this.pos);return this.pos+=4,t},readFixed64:function(){var t=Cm(this.buf,this.pos)+Cm(this.buf,this.pos+4)*hm;return this.pos+=8,t},readSFixed64:function(){var t=Cm(this.buf,this.pos)+Im(this.buf,this.pos+4)*hm;return this.pos+=8,t},readFloat:function(){var t=dm.read(this.buf,this.pos,!0,23,4);return this.pos+=4,t},readDouble:function(){var t=dm.read(this.buf,this.pos,!0,52,8);return this.pos+=8,t},readVarint:function(t){var e,i,n=this.buf;return e=127&(i=n[this.pos++]),i>4,r=12&&fm?function(t,e,i){return fm.decode(t.subarray(e,i))}(this.buf,e,t):function(t,e,i){for(var n="",r=e;r239?4:l>223?3:l>191?2:1;if(r+d>i)break;1===d?l=55296&&c=1114112)&&(c=null)),null===c?(c=65533,d=1):c>65535&&(c-=65536,n+=String.fromCharCode(c>>>10&1023|55296),c=56320|1023&c),n+=String.fromCharCode(c),r+=d}return n}(this.buf,e,t)},readBytes:function(){var t=this.readVarint()+this.pos,e=this.buf.subarray(this.pos,t);return this.pos=t,e},readPackedVarint:function(t,e){if(this.type!==um.Bytes)return t.push(this.readVarint(e));var i=mm(this);for(t=t||[];this.pos127;);else if(e===um.Bytes)this.pos=this.readVarint()+this.pos;else if(e===um.Fixed32)this.pos+=4;else{if(e!==um.Fixed64)throw new Error("Unimplemented type: "+e);this.pos+=8}},writeTag:function(t,e){this.writeVarint(t268435455||t=0?(i=t%4294967296|0,n=t/4294967296|0):(n=~(-t/4294967296),4294967295^(i=~(-t%4294967296))?i=i+1|0:(i=0,n=n+1|0)),t>=0x10000000000000000||t>>=7,i.buf[i.pos++]=127&t|128,t>>>=7,i.buf[i.pos++]=127&t|128,t>>>=7,i.buf[i.pos++]=127&t|128,i.buf[i.pos]=127&(t>>>=7)}(i,0,e),function(t,e){var i=(7&t)>>=3)?128:0),t&&(e.buf[e.pos++]=127&t|((t>>>=7)?128:0),t&&(e.buf[e.pos++]=127&t|((t>>>=7)?128:0),t&&(e.buf[e.pos++]=127&t|((t>>>=7)?128:0),t&&(e.buf[e.pos++]=127&t|((t>>>=7)?128:0),t&&(e.buf[e.pos++]=127&t)))))}(n,e)}(t,this):(this.realloc(4),this.buf[this.pos++]=127&t|(t>127?128:0),t>>=7)|(t>127?128:0),t>>=7)|(t>127?128:0),t>>7&127))))},writeSVarint:function(t){this.writeVarint(t55295&&n56319||o+1===e.length?(t[i++]=239,t[i++]=191,t[i++]=189):r=n;continue}if(n>6|192:(n>12|224:(t[i++]=n>>18|240,t[i++]=n>>12&63|128),t[i++]=n>>6&63|128),t[i++]=63&n|128)}return i}(this.buf,t,this.pos);var i=this.pos-e;i>=128&&gm(e,i,this),this.pos=e-1,this.writeVarint(i),this.pos+=i},writeFloat:function(t){this.realloc(4),dm.write(this.buf,t,this.pos,!0,23,4),this.pos+=4},writeDouble:function(t){this.realloc(8),dm.write(this.buf,t,this.pos,!0,52,8),this.pos+=8},writeBytes:function(t){var e=t.length;this.writeVarint(e),this.realloc(e);for(var i=0;i=128&&gm(i,n,this),this.pos=i-1,this.writeVarint(n),this.pos+=n},writeMessage:function(t,e,i){this.writeTag(t,um.Bytes),this.writeRawMessage(e,i)},writePackedVarint:function(t,e){e.length&&this.writeMessage(t,ym,e)},writePackedSVarint:function(t,e){e.length&&this.writeMessage(t,vm,e)},writePackedBoolean:function(t,e){e.length&&this.writeMessage(t,wm,e)},writePackedFloat:function(t,e){e.length&&this.writeMessage(t,xm,e)},writePackedDouble:function(t,e){e.length&&this.writeMessage(t,bm,e)},writePackedFixed32:function(t,e){e.length&&this.writeMessage(t,Tm,e)},writePackedSFixed32:function(t,e){e.length&&this.writeMessage(t,Sm,e)},writePackedFixed64:function(t,e){e.length&&this.writeMessage(t,Em,e)},writePackedSFixed64:function(t,e){e.length&&this.writeMessage(t,Mm,e)},writeBytesField:function(t,e){this.writeTag(t,um.Bytes),this.writeBytes(e)},writeFixed32Field:function(t,e){this.writeTag(t,um.Fixed32),this.writeFixed32(e)},writeSFixed32Field:function(t,e){this.writeTag(t,um.Fixed32),this.writeSFixed32(e)},writeFixed64Field:function(t,e){this.writeTag(t,um.Fixed64),this.writeFixed64(e)},writeSFixed64Field:function(t,e){this.writeTag(t,um.Fixed64),this.writeSFixed64(e)},writeVarintField:function(t,e){this.writeTag(t,um.Varint),this.writeVarint(e)},writeSVarintField:function(t,e){this.writeTag(t,um.Varint),this.writeSVarint(e)},writeStringField:function(t,e){this.writeTag(t,um.Bytes),this.writeString(e)},writeFloatField:function(t,e){this.writeTag(t,um.Fixed32),this.writeFloat(e)},writeDoubleField:function(t,e){this.writeTag(t,um.Fixed64),this.writeDouble(e)},writeBooleanField:function(t,e){this.writeVarintField(t,Boolean(e))}};var Lm=h(cm);const Pm=["id","tile","layer","source","sourceLayer","state"];class $m{constructor(t,e,i,n,r){this.type="Feature",this._vectorTileFeature=t,this._z=e,this._x=i,this._y=n,this.properties=t.properties,this.id=r}get geometry(){return void 0===this._geometry&&(this._geometry=this._vectorTileFeature.toGeoJSON(this._x,this._y,this._z).geometry),this._geometry}set geometry(t){this._geometry=t}toJSON(){const t={type:"Feature",state:void 0,geometry:this.geometry,properties:this.properties};for(const e of Pm)void 0!==this[e]&&(t[e]=this[e]);return t}}class km{constructor(){this.state={},this.stateChanges={},this.deletedStates={}}updateState(t,e,i){const n=String(e);if(this.stateChanges[t]=this.stateChanges[t]||{},this.stateChanges[t][n]=this.stateChanges[t][n]||{},ei(this.stateChanges[t][n],i),null===this.deletedStates[t]){this.deletedStates[t]={};for(const e in this.state[t])e!==n&&(this.deletedStates[t][e]=null)}else if(this.deletedStates[t]&&null===this.deletedStates[t][n]){this.deletedStates[t][n]={};for(const e in this.state[t][n])i[e]||(this.deletedStates[t][n][e]=null)}else for(const e in i)this.deletedStates[t]&&this.deletedStates[t][n]&&null===this.deletedStates[t][n][e]&&delete this.deletedStates[t][n][e]}removeFeatureState(t,e,i){if(null===this.deletedStates[t])return;const n=String(e);if(this.deletedStates[t]=this.deletedStates[t]||{},i&&void 0!==e)null!==this.deletedStates[t][n]&&(this.deletedStates[t][n]=this.deletedStates[t][n]||{},this.deletedStates[t][n][i]=null);else if(void 0!==e)if(this.stateChanges[t]&&this.stateChanges[t][n])for(i in this.deletedStates[t][n]={},this.stateChanges[t][n])this.deletedStates[t][n][i]=null;else this.deletedStates[t][n]=null;else this.deletedStates[t]=null}getState(t,e){const i=String(e),n=ei({},(this.state[t]||{})[i],(this.stateChanges[t]||{})[i]);if(null===this.deletedStates[t])return{};if(this.deletedStates[t]){const i=this.deletedStates[t][e];if(null===i)return{};for(const t in i)delete n[t]}return n}initializeTileState(t,e){t.setFeatureState(this.state,e)}coalesceChanges(t,e){const i={};for(const t in this.stateChanges){this.state[t]=this.state[t]||{};const e={};for(const i in this.stateChanges[t])this.state[t][i]||(this.state[t][i]={}),ei(this.state[t][i],this.stateChanges[t][i]),e[i]=this.state[t][i];i[t]=e}for(const t in this.deletedStates){this.state[t]=this.state[t]||{};const e={};if(null===this.deletedStates[t])for(const i in this.state[t])e[i]={},this.state[t][i]={};else for(const i in this.deletedStates[t]){if(null===this.deletedStates[t][i])this.state[t][i]={};else if(this.state[t][i])for(const e of Object.keys(this.deletedStates[t][i]))delete this.state[t][i][e];e[i]=this.state[t][i]}i[t]=i[t]||{},ei(i[t],e)}if(this.stateChanges={},this.deletedStates={},0!==Object.keys(i).length)for(const n in t)t[n].setFeatureState(i,e)}}class Dm{constructor(t,e){this.tileID=t,this.x=t.canonical.x,this.y=t.canonical.y,this.z=t.canonical.z,this.grid=new va(uo,16,0),this.featureIndexArray=new yc,this.promoteId=e,this.is3DTile=!1}insert(t,e,i,n,r,o=0,s=0){const a=this.featureIndexArray.length;this.featureIndexArray.emplaceBack(i,n,r,o);const l=this.grid;for(let t=0;t=0&&n[3]>=0&&l.insert(a,n[0],n[1],n[2],n[3])}}loadVTLayers(){if(!this.vtLayers){this.vtLayers=new bp(new Lm(this.rawTileData)).layers,this.sourceLayerCoder=new am(this.vtLayers?Object.keys(this.vtLayers).sort():["_geojsonTileLayer"]),this.vtFeatures={};for(const t in this.vtLayers)this.vtFeatures[t]=[]}return this.vtLayers}query(t,e,i,n){this.loadVTLayers();const r=t.params||{},o=dl(r.filter),s=t.tileResult,a=t.transform,l=s.bufferedTilespaceBounds,c=this.grid.query(l.min.x,l.min.y,l.max.x,l.max.y,((t,e,i,n)=>ou(s.bufferedTilespaceGeometry,t,e,i,n)));c.sort(Rm);let d=null;a.elevation&&c.length>0&&(d=Xp.create(a.elevation,this.tileID));const u={};let h;for(let l=0;l(m||(m=Gd(e,this.tileID.canonical,t.tileTransform)),i.queryIntersectsFeature(s,e,n,m,this.z,t.transform,t.pixelPosMatrix,d,r))))}return u}loadMatchingFeature(t,e,i,n,r,o,s,a,l){const{featureIndex:c,bucketIndex:d,sourceLayerIndex:u,layoutVertexArrayOffset:h}=e,p=this.bucketLayerIDs[d];if(n&&!function(t,e){for(let i=0;i=0)return!0;return!1}(n,p))return;const f=this.sourceLayerCoder.decode(u),m=this.vtLayers[f].feature(c);if(i.needGeometry){const t=Zd(m,!0);if(!i.filter(new Ha(this.tileID.overscaledZ),t,this.tileID.canonical))return}else if(!i.filter(new Ha(this.tileID.overscaledZ),m))return;const _=this.getId(m,f);for(let e=0;e{const s=e instanceof el?e.get(o):null;return s&&s.evaluate?s.evaluate(i,n,r):s}))}function Rm(t,e){return e-t}ba(Dm,"FeatureIndex",{omit:["rawTileData","sourceLayerCoder"]});var Om=24;const Bm=128;function Fm(t,e){const{expression:i}=e;if("constant"===i.kind)return{kind:"constant",layoutSize:i.evaluate(new Ha(t+1))};if("source"===i.kind)return{kind:"source"};{const{zoomStops:e,interpolationType:n}=i;let r=0;for(;r{t.text=function(t,e,i){const n=e.layout.get("text-transform").evaluate(i,{});return"uppercase"===n?t=t.toLocaleUpperCase():"lowercase"===n&&(t=t.toLocaleLowerCase()),qa.applyArabicShaping&&(t=qa.applyArabicShaping(t)),t}(t.text,e,i)})),t}const Gm={"!":"︕","#":"#",$:"$","%":"%","&":"&","(":"︵",")":"︶","*":"*","+":"+",",":"︐","-":"︲",".":"・","/":"/",":":"︓",";":"︔","":"﹀","?":"︖","@":"@","[":"﹇","\\":"\","]":"﹈","^":"^",_:"︳","`":"`","{":"︷","|":"―","}":"︸","~":"~","¢":"¢","£":"£","¥":"¥","¦":"¦","¬":"¬","¯":" ̄","–":"︲","—":"︱","‘":"﹃","’":"﹄","“":"﹁","”":"﹂","…":"︙","‧":"・","₩":"₩","、":"︑","。":"︒","〈":"︿","〉":"﹀","《":"︽","》":"︾","「":"﹁","」":"﹂","『":"﹃","』":"﹄","【":"︻","】":"︼","〔":"︹","〕":"︺","〖":"︗","〗":"︘","!":"︕","(":"︵",")":"︶",",":"︐","-":"︲",".":"・",":":"︓",";":"︔","<":"︿",">":"﹀","?":"︖","[":"﹇","]":"﹈","_":"︳","{":"︷","|":"―","}":"︸","⦅":"︵","⦆":"︶","。":"︒","「":"﹁","」":"﹂","←":"↑","→":"↓"};function Zm(t){return"︶"===t||"﹈"===t||"︸"===t||"﹄"===t||"﹂"===t||"︾"===t||"︼"===t||"︺"===t||"︘"===t||"﹀"===t||"︐"===t||"︓"===t||"︔"===t||"`"===t||" ̄"===t||"︑"===t||"︒"===t}function qm(t){return"︵"===t||"﹇"===t||"︷"===t||"﹃"===t||"﹁"===t||"︽"===t||"︻"===t||"︹"===t||"︗"===t||"︿"===t}const Hm=3;function Wm(t,e,i){e.glyphs=[],1===t&&i.readMessage(Ym,e)}function Ym(t,e,i){if(3===t){const{id:t,bitmap:n,width:r,height:o,left:s,top:a,advance:l}=i.readMessage(Xm,{});e.glyphs.push({id:t,bitmap:new dh({width:r+2*Hm,height:o+2*Hm},n),metrics:{width:r,height:o,left:s,top:a,advance:l}})}else 4===t?e.ascender=i.readSVarint():5===t&&(e.descender=i.readSVarint())}function Xm(t,e,i){1===t?e.id=i.readVarint():2===t?e.bitmap=i.readBytes():3===t?e.width=i.readVarint():4===t?e.height=i.readVarint():5===t?e.left=i.readSVarint():6===t?e.top=i.readSVarint():7===t&&(e.advance=i.readVarint())}const Km=Hm,Jm={horizontal:1,vertical:2,horizontalOnly:3};class Qm{constructor(){this.scale=1,this.fontStack="",this.imageName=null}static forText(t,e){const i=new Qm;return i.scale=t||1,i.fontStack=e,i}static forImage(t){const e=new Qm;return e.imageName=t,e}}class t_{constructor(){this.text="",this.sectionIndex=[],this.sections=[],this.imageSectionID=null}static fromFeature(t,e){const i=new t_;for(let n=0;n=0&&i>=t&&i_[this.text.charCodeAt(i)];i--)e--;this.text=this.text.substring(t,e),this.sectionIndex=this.sectionIndex.slice(t,e)}substring(t,e){const i=new t_;return i.text=this.text.substring(t,e),i.sectionIndex=this.sectionIndex.slice(t,e),i.sections=this.sections,i}toString(){return this.text}getMaxScale(){return this.sectionIndex.reduce(((t,e)=>Math.max(t,this.sections[e].scale)),0)}addTextSection(t,e){this.text+=t.text,this.sections.push(Qm.forText(t.scale,t.fontStack||e));const i=this.sections.length-1;for(let e=0;e=63743?null:++this.imageSectionID:(this.imageSectionID=57344,this.imageSectionID)}}function e_(t,e,i,n,r,o,s,a,l,c,d,u,h,p,f){const m=t_.fromFeature(t,r);u===Jm.vertical&&m.verticalizePunctuation(h);let _=[];const g=function(t,e,i,n,r,o){if(!t)return[];const s=[],a=function(t,e,i,n,r,o){let s=0;for(let i=0;i=0;let c=0;for(let i=0;i0&&o>b&&(b=o)}else{const t=i[a.fontStack];if(!t)continue;t[m]&&(S=t[m]);const n=e[a.fontStack];if(!n)continue;const o=n.glyphs[m];if(!o)continue;if(v=o.metrics,M=8203!==m?Om:0,_){const t=void 0!==n.ascender?Math.abs(n.ascender):0,e=void 0!==n.descender?Math.abs(n.descender):0,i=(t+e)*g;w-i/2;){if(s--,sn;)c-=l.shift().angleDelta;if(c>r)return!1;s++,a+=e.dist(i)}return!0}function m_(t){let e=0;for(let i=0;ic){const d=(c-l)/o,u=Vn(n.x,r.x,d),h=Vn(n.y,r.y,d),p=new p_(u,h,0,r.angleTo(n),i);return!s||f_(t,p,a,s,e)?p:void 0}l+=o}}function v_(t,e,i,n,r,o,s,a,l){const c=__(n,o,s),d=g_(n,r),u=d*s,h=0===t[0].x||t[0].x===l||0===t[0].y||t[0].y===l;return e-u=0&&g=0&&y=0&&h+c=n&&c.x>=n||(s.x>=n?s=new Ue(n,s.y+(n-s.x)/(c.x-s.x)*(c.y-s.y))._round():c.x>=n&&(c=new Ue(n,s.y+(n-s.x)/(c.x-s.x)*(c.y-s.y))._round()),s.y>=r&&c.y>=r||(s.y>=r?s=new Ue(s.x+(r-s.y)/(c.y-s.y)*(c.x-s.x),r)._round():c.y>=r&&(c=new Ue(s.x+(r-s.y)/(c.y-s.y)*(c.x-s.x),r)._round()),l&&s.equals(l[l.length-1])||(l=[s],o.push(l)),l.push(c)))))}}return o}function w_(t){let e=0,i=0;for(const n of t)e+=n.w*n.h,i=Math.max(i,n.w);t.sort(((t,e)=>e.h-t.h));const n=[{x:0,y:0,w:Math.max(Math.ceil(Math.sqrt(e/.95)),i),h:1/0}];let r=0,o=0;for(const e of t)for(let t=n.length-1;t>=0;t--){const i=n[t];if(!(e.w>i.w||e.h>i.h)){if(e.x=i.x,e.y=i.y,o=Math.max(o,e.y+e.h),r=Math.max(r,e.x+e.w),e.w===i.w&&e.h===i.h){const e=n.pop();tt.hasImage(e,i))),t.dispatchRenderCallbacks(this.haveRenderCallbacks,i);for(const n in t.getUpdatedImages(i))this.patchUpdatedImage(this.iconPositions[n],t.getImage(n,i),e),this.patchUpdatedImage(this.patternPositions[n],t.getImage(n,i),e)}patchUpdatedImage(t,e,i){if(!t||!e)return;if(t.version===e.version)return;t.version=e.version;const[n,r]=t.tl,o=!!Object.keys(this.patternPositions).length;i.update(e.data,{useMipmap:o},{x:n,y:r})}}ba(S_,"ImagePosition"),ba(E_,"ImageAtlas");const M_=1e20;function C_(t,e,i,n,r,o,s,a,l){for(let c=e;c-1);l++,o[l]=a,s[l]=c,s[l+1]=M_}for(let a=0,l=0;a{let n=this.entries[t];n||(n=this.entries[t]={glyphs:{},requests:{},ranges:{},ascender:void 0,descender:void 0});let r=n.glyphs[e];if(void 0!==r)return void i(null,{stack:t,id:e,glyph:r});if(r=this._tinySDF(n,t,e),r)return n.glyphs[e]=r,void i(null,{stack:t,id:e,glyph:r});const s=Math.floor(e/256);if(256*s>65535)return void i(new Error("glyphs > 65535 not supported"));if(n.ranges[s])return void i(null,{stack:t,id:e,glyph:r});let a=n.requests[s];a||(a=n.requests[s]=[],P_.loadGlyphRange(t,s,o,this.requestManager,((t,e)=>{if(e){n.ascender=e.ascender,n.descender=e.descender;for(const t in e.glyphs)this._doesCharSupportLocalGlyph(+t)||(n.glyphs[+t]=e.glyphs[+t]);n.ranges[s]=!0}for(const i of a)i(t,e);delete n.requests[s]}))),a.push(((n,r)=>{n?i(n):r&&i(null,{stack:t,id:e,glyph:r.glyphs[e]||null})}))}),((t,e)=>{if(t)i(t);else if(e){const t={};for(const{stack:i,id:n,glyph:r}of e)void 0===t[i]&&(t[i]={}),void 0===t[i].glyphs&&(t[i].glyphs={}),t[i].glyphs[n]=r&&{id:r.id,bitmap:r.bitmap.clone(),metrics:r.metrics},t[i].ascender=this.entries[i].ascender,t[i].descender=this.entries[i].descender;i(null,t)}}))}_doesCharSupportLocalGlyph(t){return this.localGlyphMode!==L_.none&&(this.localGlyphMode===L_.all?!!this.localFontFamily:!!this.localFontFamily&&(Ma["CJK Unified Ideographs"](t)||Ma["Hangul Syllables"](t)||Ma.Hiragana(t)||Ma.Katakana(t)||Ma["CJK Symbols and Punctuation"](t)||Ma["CJK Unified Ideographs Extension A"](t)||Ma["CJK Unified Ideographs Extension B"](t)))}_tinySDF(t,e,i){const n=this.localFontFamily;if(!n||!this._doesCharSupportLocalGlyph(i))return;let r=t.tinySDF;if(!r){let i="400";/bold/i.test(e)?i="900":/medium/i.test(e)?i="500":/light/i.test(e)&&(i="200"),r=t.tinySDF=new P_.TinySDF({fontFamily:n,fontWeight:i,fontSize:24*I_,buffer:3*I_,radius:8*I_}),r.fontWeight=i}if(this.localGlyphs[r.fontWeight][i])return this.localGlyphs[r.fontWeight][i];const o=String.fromCodePoint(i),{data:s,width:a,height:l,glyphWidth:c,glyphHeight:d,glyphLeft:u,glyphTop:h,glyphAdvance:p}=r.draw(o);return this.localGlyphs[r.fontWeight][i]={id:i,bitmap:new dh({width:a,height:l},s),metrics:{width:c/I_,height:d/I_,left:u/I_,top:h/I_-27,advance:p/I_,localGlyph:!0}}}}P_.loadGlyphRange=function(t,e,i,n,r){const o=256*e,s=o+255,a=n.transformRequest(n.normalizeGlyphsURL(i).replace("{fontstack}",t).replace("{range}",`${o}-${s}`),Ki.Glyphs);en(a,((t,e)=>{if(t)r(t);else if(e){const t={},i=function(t){return new Lm(t).readFields(Wm,{})}(e);for(const e of i.glyphs)t[e.id]=e;r(null,{glyphs:t,ascender:i.ascender,descender:i.descender})}}))},P_.TinySDF=class{constructor({fontSize:t=24,buffer:e=3,radius:i=8,cutoff:n=.25,fontFamily:r="sans-serif",fontWeight:o="normal",fontStyle:s="normal"}={}){this.buffer=e,this.cutoff=n,this.radius=i;const a=this.size=t+4*e,l=this._createCanvas(a),c=this.ctx=l.getContext("2d",{willReadFrequently:!0});c.font=`${s} ${o} ${t}px ${r}`,c.textBaseline="alphabetic",c.textAlign="left",c.fillStyle="black",this.gridOuter=new Float64Array(a*a),this.gridInner=new Float64Array(a*a),this.f=new Float64Array(a),this.z=new Float64Array(a+1),this.v=new Uint16Array(a)}_createCanvas(t){const e=document.createElement("canvas");return e.width=e.height=t,e}draw(t){const{width:e,actualBoundingBoxAscent:i,actualBoundingBoxDescent:n,actualBoundingBoxLeft:r,actualBoundingBoxRight:o}=this.ctx.measureText(t),s=Math.ceil(i),a=Math.max(0,Math.min(this.size-this.buffer,Math.ceil(o-r))),l=Math.min(this.size-this.buffer,s+Math.ceil(n)),c=a+2*this.buffer,d=l+2*this.buffer,u=Math.max(c*d,0),h=new Uint8ClampedArray(u),p={data:h,width:c,height:d,glyphWidth:a,glyphHeight:l,glyphTop:s,glyphLeft:0,glyphAdvance:e};if(0===a||0===l)return p;const{ctx:f,buffer:m,gridInner:_,gridOuter:g}=this;f.clearRect(m,m,a,l),f.fillText(t,m,m+s);const y=f.getImageData(m,m,a,l);g.fill(M_,0,u),_.fill(0,0,u);for(let t=0;t0?t*t:0,_[n]=tt+e[1]-e[0],f=u.reduce(p,0),m=h.reduce(p,0),_=a-f,g=l-m;let y=0,v=f,x=0,b=m,w=0,T=_,S=0,E=g;if(o.content&&n){const t=o.content;y=D_(u,0,t[0]),x=D_(h,0,t[1]),v=D_(u,t[0],t[2]),b=D_(h,t[1],t[3]),w=t[0]-y,S=t[1]-x,T=t[2]-t[0]-v,E=t[3]-t[1]-b}const M=(n,r,a,l)=>{const u=R_(n.stretch-y,v,c,t.left),h=O_(n.fixed-w,T,n.stretch,f),p=R_(r.stretch-x,b,d,t.top),_=O_(r.fixed-S,E,r.stretch,m),g=R_(a.stretch-y,v,c,t.left),M=O_(a.fixed-w,T,a.stretch,f),C=R_(l.stretch-x,b,d,t.top),A=O_(l.fixed-S,E,l.stretch,m),I=new Ue(u,p),L=new Ue(g,p),P=new Ue(g,C),$=new Ue(u,C),k=new Ue(h/s,_/s),D=new Ue(M/s,A/s),z=e*Math.PI/180;if(z){const t=Math.sin(z),e=Math.cos(z),i=[e,-t,t,e];I._matMult(i),L._matMult(i),$._matMult(i),P._matMult(i)}const R=n.stretch+n.fixed,O=a.stretch+a.fixed,B=r.stretch+r.fixed,F=l.stretch+l.fixed,N=t.imageSecondary;return{tl:I,tr:L,bl:$,br:P,texPrimary:{x:o.paddedRect.x+$_+R,y:o.paddedRect.y+$_+B,w:O-R,h:F-B},texSecondary:N?{x:N.paddedRect.x+$_+R,y:N.paddedRect.y+$_+B,w:O-R,h:F-B}:void 0,writingMode:void 0,glyphOffset:[0,0],sectionIndex:0,pixelOffsetTL:k,pixelOffsetBR:D,minFontScaleX:T/s/c,minFontScaleY:E/s/d,isSDF:i}};if(n&&(o.stretchX||o.stretchY)){const t=z_(u,_,f),e=z_(h,g,m);for(let i=0;io)&&(o=e.x),(!t||e.y>s)&&(s=e.y)}const l=Math.min(o-n,s-r);let c=l/2;const d=new co([],N_);if(0===l)return new Ue(n,r);for(let e=n;eu.d||!u.d)&&(u=n,i&&console.log("found best %d after %d probes",Math.round(1e4*n.d)/1e4,h)),n.max-u.dt.y!=a.y>t.y&&t.x18&&P>2&&(P>>=1),Math.max(uo/(512*P),1)*_.get("symbol-spacing")),S=_.get("text-padding")*t.tilePixelRatio,E=_.get("icon-padding")*t.tilePixelRatio,M=Ge(_.get("text-max-angle")),C="map"===_.get("text-rotation-alignment")&&"point"!==_.get("symbol-placement"),A="map"===_.get("icon-rotation-alignment")&&"point"!==_.get("symbol-placement"),I=_.get("symbol-placement"),L=T/2;var P;const $=_.get("icon-text-fit").evaluate(e,{},u),k=_.get("icon-text-fit-padding").evaluate(e,{},u),D="none"!==$;let z;!1===t.hasAnyIconTextFit&&D&&(t.hasAnyIconTextFit=!0),n&&D&&(t.allowVerticalPlacement&&i.vertical&&(z=h_(n,i.vertical,$,k,g,b)),y&&(n=h_(n,y,$,k,g,b)));const R=(s,a,m)=>{if(a.x=uo||a.y=uo)return;let _=null;if(v){const{x:t,y:e,z:i}=h.projectTilePoint(a.x,a.y,m);_={anchor:new p_(t,e,i,0,void 0),up:h.upVector(m,a.x,a.y)}}!function(t,e,i,n,r,o,s,a,l,c,d,u,h,p,f,m,_,g,y,v,x,b,w,T,S,E,M){const C=t.addToLineVertexArray(e,n);let A,I,L,P,$,k,D,z=0,R=0,O=0,B=0,F=-1,N=-1;const U={};let j=Ln("");const V=i?i.anchor:e,G="none"!==l.layout.get("icon-text-fit").evaluate(x,{},S);let Z=0,q=0;if(void 0===l._unevaluatedLayout.getValue("text-radial-offset")?[Z,q]=l.layout.get("text-offset").evaluate(x,{},S).map((t=>t*Om)):(Z=l.layout.get("text-radial-offset").evaluate(x,{},S)*Om,q=j_),t.allowVerticalPlacement&&r.vertical){const t=r.vertical;if(f)k=J_(t),a&&(D=J_(a));else{const i=l.layout.get("text-rotate").evaluate(x,{},S)+90;L=K_(c,V,e,d,u,h,t,p,i,m),a&&(P=K_(c,V,e,d,u,h,a,g,i))}}if(o){const n=l.layout.get("icon-rotate").evaluate(x,{},S),r=k_(o,n,w,G),s=a?k_(a,n,w,G):void 0;I=K_(c,V,e,d,u,h,o,g,n),z=4*r.length;const p=t.iconSizeData;let f=null;"source"===p.kind?(f=[Bm*l.layout.get("icon-size").evaluate(x,{},S)],f[0]>W_&&pi(`${t.layerIds[0]}: Value for "icon-size" is >= ${H_}. Reduce your "icon-size".`)):"composite"===p.kind&&(f=[Bm*b.compositeIconSizes[0].evaluate(x,{},S),Bm*b.compositeIconSizes[1].evaluate(x,{},S)],(f[0]>W_||f[1]>W_)&&pi(`${t.layerIds[0]}: Value for "icon-size" is >= ${H_}. Reduce your "icon-size".`)),t.addSymbols(t.icon,r,f,v,y,x,!1,i,e,C.lineStartIndex,C.lineLength,-1,T,S,E,M),F=t.icon.placedSymbolArray.length-1,s&&(R=4*s.length,t.addSymbols(t.icon,s,f,v,y,x,Jm.vertical,i,e,C.lineStartIndex,C.lineLength,-1,T,S,E,M),N=t.icon.placedSymbolArray.length-1)}for(const n in r.horizontal){const o=r.horizontal[n];A||(j=Ln(o.text),f?$=J_(o):A=K_(c,V,e,d,u,h,o,p,l.layout.get("text-rotate").evaluate(x,{},S),m));const a=1===o.positionedLines.length;if(O+=Y_(t,i,e,o,s,l,f,x,m,C,r.vertical?Jm.horizontal:Jm.horizontalOnly,a?Object.keys(r.horizontal):[n],U,F,b,T,S,E),a)break}r.vertical&&(B+=Y_(t,i,e,r.vertical,s,l,f,x,m,C,Jm.vertical,["vertical"],U,N,b,T,S,E));let H=-1;const W=(t,e)=>t?Math.max(t,e):e;H=W($,H),H=W(k,H),H=W(D,H);const Y=H>-1?1:0;t.glyphOffsetArray.length>=65535&&pi("Too many glyphs being rendered in a tile. See https://github.com/mapbox/mapbox-gl-js/issues/2907"),void 0!==x.sortKey&&t.addToSortKeyRanges(t.symbolInstances.length,x.sortKey),t.symbolInstances.emplaceBack(e.x,e.y,V.x,V.y,V.z,U.right>=0?U.right:-1,U.center>=0?U.center:-1,U.left>=0?U.left:-1,U.vertical>=0?U.vertical:-1,F,N,j,void 0!==A?A:t.collisionBoxArray.length,void 0!==A?A+1:t.collisionBoxArray.length,void 0!==L?L:t.collisionBoxArray.length,void 0!==L?L+1:t.collisionBoxArray.length,void 0!==I?I:t.collisionBoxArray.length,void 0!==I?I+1:t.collisionBoxArray.length,P||t.collisionBoxArray.length,P?P+1:t.collisionBoxArray.length,d,O,B,z,R,Y,0,Z,q,H,0,1,1,G?1:0)}(t,a,_,s,i,n,r,z,t.layers[0],t.collisionBoxArray,e.index,e.sourceLayerIndex,t.index,S,C,l,0,E,A,g,e,o,c,d,u,p,f)};if("line"===I)for(const r of b_(e.geometry,0,0,uo,uo)){const e=v_(r,T,M,i.vertical||y,n,x,w,t.overscaling,uo);for(const i of e)y&&Q_(t,y.text,L,i)||R(r,i,u)}else if("line-center"===I){for(const t of e.geometry)if(t.length>1){const e=y_(t,M,i.vertical||y,n,x,w);e&&R(t,e,u)}}else if("Polygon"===e.type)for(const t of Zh(e.geometry,0)){const e=F_(t,16);R(t[0],new p_(e.x,e.y,0,0,void 0),u)}else if("LineString"===e.type)for(const t of e.geometry)R(t,new p_(t[0].x,t[0].y,0,0,void 0),u);else if("Point"===e.type)for(const t of e.geometry)for(const e of t)R([e],new p_(e.x,e.y,0,0,void 0),u)}const H_=255,W_=H_*Bm;function Y_(t,e,i,n,r,o,s,a,l,c,d,u,h,p,f,m,_,g){const y=function(t,e,i,n,r,o,s,a){const l=[];if(0===e.positionedLines.length)return l;const c=n.layout.get("text-rotate").evaluate(o,{})*Math.PI/180,d=function(t){const e=t[0],i=t[1],n=e*i;return n>0?[e,-i]:nW_&&pi(`${t.layerIds[0]}: Value for "text-size" is >= ${H_}. Reduce your "text-size".`)):"composite"===v.kind&&(x=[Bm*f.compositeTextSizes[0].evaluate(a,{},_),Bm*f.compositeTextSizes[1].evaluate(a,{},_)],(x[0]>W_||x[1]>W_)&&pi(`${t.layerIds[0]}: Value for "text-size" is >= ${H_}. Reduce your "text-size".`)),t.addSymbols(t.text,y,x,l,s,a,d,e,i,c.lineStartIndex,c.lineLength,p,m,_,g,!1);for(const e of u)h[e]=t.text.placedSymbolArray.length-1;return 4*y.length}function X_(t){for(const e in t)return t[e];return null}function K_(t,e,i,n,r,o,s,a,l,c){let d=s.top,u=s.bottom,h=s.left,p=s.right;const f=s.collisionPadding;if(f&&(h-=f[0],d-=f[1],p+=f[2],u+=f[3]),l){const t=new Ue(h,d),e=new Ue(p,d),i=new Ue(h,u),n=new Ue(p,u),r=Ge(l);let o=new Ue(0,0);c&&(o=new Ue(c[0],c[1])),t._rotateAround(r,o),e._rotateAround(r,o),i._rotateAround(r,o),n._rotateAround(r,o),h=Math.min(t.x,e.x,i.x,n.x),p=Math.max(t.x,e.x,i.x,n.x),d=Math.min(t.y,e.y,i.y,n.y),u=Math.max(t.y,e.y,i.y,n.y)}return t.emplaceBack(e.x,e.y,e.z,i.x,i.y,h,d,p,u,a,n,r,o),t.length-1}function J_(t){t.collisionPadding&&(t.top-=t.collisionPadding[1],t.bottom+=t.collisionPadding[3]);const e=t.bottom-t.top;return e>0?Math.max(10,e):null}function Q_(t,e,i,n){const r=t.compareText;if(e in r){const t=r[e];for(let e=t.length-1;e>=0;e--)if(n.dist(t[e])v&&(x(t,c,n,r,a,l),x(c,i,a,l,o,s))}x(u,h,n,o,r,o),x(h,p,r,o,r,s),x(p,f,r,s,n,s),x(f,u,n,s,n,o),m-=v,_-=v,g+=v,y+=v;const b=1/Math.max(g-m,y-_);return{scale:b,x:m*b,y:_*b,x2:g*b,y2:y*b,projection:e}}function ig(t,{x:e,y:i},n=0){return new Ue(((e-n)*t.scale-t.x)*uo,(i*t.scale-t.y)*uo)}const ng=t.ad.identity(new Float32Array(16));class rg{constructor(t){this.spec=t,this.name=t.name,this.wrap=!1,this.requiresDraping=!1,this.supportsWorldCopies=!1,this.supportsTerrain=!1,this.supportsFog=!1,this.supportsFreeCamera=!1,this.zAxisUnit="meters",this.isReprojectedInTileSpace=!0,this.unsupportedLayers=["custom"],this.center=[0,0],this.range=[3.5,7]}project(t,e){return{x:0,y:0,z:0}}unproject(t,e){return new pd(0,0)}projectTilePoint(t,e,i){return{x:t,y:e,z:0}}locationPoint(t,e,i=!0){return t._coordinatePoint(t.locationCoordinate(e),i)}pixelsPerMeter(t,e){return Cd(1,t)*e}pixelSpaceConversion(t,e,i){return 1}farthestPixelDistance(t){return tg(t,t.pixelsPerMeter)}pointCoordinate(t,e,i,n){const r=t.horizonLineFromTop(!1),o=new Ue(e,Math.max(r,i));return t.rayIntersectionCoordinate(t.pointRayIntersection(o,n))}pointCoordinate3D(t,e,i){const n=new Ue(e,i);if(t.elevation)return t.elevation.pointCoordinate(n);{const e=this.pointCoordinate(t,n.x,n.y,0);return[e.x,e.y,e.z]}}isPointAboveHorizon(t,e){if(t.elevation&&t.elevation.visibleDemTiles.length)return!this.pointCoordinate3D(t,e.x,e.y);const i=t.horizonLineFromTop();return e.y0?epg-i&&(e=pg-i);const o=r/Math.pow(fg(e),n);let s=o*Math.sin(n*t),a=r-o*Math.cos(n*t);return s=.5*(s/Math.PI+.5),a=.5*(a/Math.PI+.5),{x:s,y:this.southernCenter?a:1-a,z:0}}unproject(t,e){t=(2*t-.5)*Math.PI,this.southernCenter&&(e=1-e),e=(2*(1-e)-.5)*Math.PI;const{n:i,f:n}=this,r=n-e,o=Math.sign(r),s=Math.sign(i)*Math.sqrt(t*t+r*r);let a=Math.atan2(t,Math.abs(r))*o;r*i1e-6&&--n>0);o=i*i;const s=Xe(Ze(t/(.8707+o*(o*(o*o*o*(.003971-.001529*o)-.013791)-.131979))),-180,180),a=Ze(i);return new pd(s,a)}}const vg=Ge(Pd);class xg extends rg{project(t,e){e=Ge(e),t=Ge(t);const i=Math.cos(e),n=2/Math.PI,r=Math.acos(i*Math.cos(t/2)),o=Math.sin(r)/r,s=.5*(t*n+2*i*Math.sin(t/2)/o)||0,a=.5*(e+Math.sin(e)/o)||0;return{x:.5*(s/Math.PI+.5),y:1-.5*(a/Math.PI+1),z:0}}unproject(t,e){let i=t=(2*t-.5)*Math.PI,n=e=(2*(1-e)-1)*Math.PI,r=25;const o=1e-6;let s=0,a=0;do{const r=Math.cos(n),o=Math.sin(n),l=2*o*r,c=o*o,d=r*r,u=Math.cos(i/2),h=Math.sin(i/2),p=2*u*h,f=h*h,m=1-d*u*u,_=m?1/m:0,g=m?Math.acos(r*u)*Math.sqrt(1/m):0,y=.5*(2*g*r*h+2*i/Math.PI)-t,v=.5*(g*o+n)-e,x=.5*_*(d*f+g*r*u*c)+1/Math.PI,b=_*(p*l/4-g*o*h),w=.125*_*(l*h-g*o*d*p),T=.5*_*(c*u+g*f*r)+.5,S=b*w-T*x;s=(v*b-y*T)/S,a=(y*w-v*x)/S,i=Xe(i-s,-Math.PI,Math.PI),n=Xe(n-a,-vg,vg)}while((Math.abs(s)>o||Math.abs(a)>o)&&--r>0);return new pd(Ze(i),Ze(n))}}class bg extends rg{constructor(t){super(t),this.center=t.center||[0,0],this.parallels=t.parallels||[0,0],this.cosPhi=Math.max(.01,Math.cos(Ge(this.parallels[0]))),this.scale=1/(2*Math.max(Math.PI*this.cosPhi,1/this.cosPhi)),this.wrap=!0,this.supportsWorldCopies=!0}project(t,e){const{scale:i,cosPhi:n}=this;return{x:Ge(t)*n*i+.5,y:-Math.sin(Ge(e))/n*i+.5,z:0}}unproject(t,e){const{scale:i,cosPhi:n}=this,r=-(e-.5)/i,o=Xe(Ze((t-.5)/i)/n,-180,180),s=Math.asin(Xe(r*n,-1,1)),a=Xe(Ze(s),-Pd,Pd);return new pd(o,a)}}class wg extends _g{constructor(t){super(t),this.requiresDraping=!0,this.supportsWorldCopies=!1,this.supportsFog=!0,this.zAxisUnit="pixels",this.unsupportedLayers=["debug"],this.range=[3,5]}projectTilePoint(e,i,n){const r=Fu(e,i,n),o=ju($u(n));return t._.transformMat4(r,r,o),{x:r[0],y:r[1],z:r[2]}}locationPoint(e,i){const n=dd(i.lat,i.lng),r=t._.normalize([],n),o=e.elevation?e.elevation.getAtPointOrZero(e.locationCoordinate(i),e._centerAltitude):e._centerAltitude,s=Cd(1,0)*uo*o;t._.scaleAndAdd(n,n,r,s);const a=t.ad.identity(new Float64Array(16));return t.ad.multiply(a,e.pixelMatrix,e.globeMatrix),t._.transformMat4(n,n,a),new Ue(n[0],n[1])}pixelsPerMeter(t,e){return Cd(1,0)*e}pixelSpaceConversion(t,e,i){const n=Cd(1,t)*e,r=Vn(Cd(1,45)*e,n,i);return this.pixelsPerMeter(t,e)/r}createTileMatrix(e,i,n){const r=Vu($u(n.canonical));return t.ad.multiply(new Float64Array(16),e.globeMatrix,r)}createInversionMatrix(e,i){const{center:n}=e,r=ju($u(i));return t.ad.rotateY(r,r,Ge(n.lng)),t.ad.rotateX(r,r,Ge(n.lat)),t.ad.scale(r,r,[e._pixelsPerMercatorPixel,e._pixelsPerMercatorPixel,1]),Float32Array.from(r)}pointCoordinate(t,e,i,n){return Iu(t,e,i,!0)||new Rd(0,0)}pointCoordinate3D(t,e,i){const n=this.pointCoordinate(t,e,i,0);return[n.x,n.y,n.z]}isPointAboveHorizon(t,e){return!Iu(t,e.x,e.y,!1)}farthestPixelDistance(e){const i=function(e,i){const n=e.cameraToCenterDistance,r=e._centerAltitude*i,o=e._camera,s=e._camera.forward(),a=t._.add([],t._.scale([],s,-n),[0,0,r]),l=e.worldSize/(2*Math.PI),c=[0,0,-l],d=e.width/e.height,u=Math.tan(e.fovAboveCenter),h=t._.scale([],o.up(),u),p=t._.scale([],o.right(),u*d),f=t._.normalize([],t._.add([],t._.add([],s,h),p)),m=[];let _;if(new mu(a,f).closestPointOnSphere(c,l,m)){const i=t._.add([],m,c),n=t._.sub([],i,a);_=Math.cos(e.fovAboveCenter)*t._.length(n)}else{const e=t._.sub([],a,c),i=t._.sub([],c,a);t._.normalize(i,i);const n=t._.length(e)-l;_=Math.sqrt(n*(n+2*l));const r=Math.acos(_/(l+n))-Math.acos(t._.dot(s,i));_*=Math.cos(r)}return 1.01*_}(e,this.pixelsPerMeter(e.center.lat,e.worldSize)),n=Hu(e.zoom);if(n>0){const t=tg(e,Cd(1,e.center.lat)*e.worldSize),r=e.worldSize/(2*Math.PI),o=Math.max(e.width,e.height)/e.worldSize*Math.PI;return Vn(i,t+r*(1-Math.cos(o)),Math.pow(n,10))}return i}upVector(t,e,i){return Fu(e,i,t,1)}upVectorScale(t){return{metersToTile:Cu(Nu($u(t)))}}}function Tg(t){const e=t.parallels,i=!!e&&Math.abs(e[0]+e[1])0&&(this.iconTransitioningVertexBuffer=t.createVertexBuffer(this.iconTransitioningVertexArray,Vf.members,!0)),this.globeExtVertexArray.length>0&&(this.globeExtVertexBuffer=t.createVertexBuffer(this.globeExtVertexArray,Ff.members,!0)),!this.zOffsetVertexBuffer&&(this.zOffsetVertexArray.length>0||r)&&(this.zOffsetVertexBuffer=t.createVertexBuffer(this.zOffsetVertexArray,jf.members,!0)),this.opacityVertexBuffer.itemSize=1),(i||n)&&this.programConfigurations.upload(t))}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy(),this.dynamicLayoutVertexBuffer.destroy(),this.opacityVertexBuffer.destroy(),this.occlusionQueryOpacityVertexBuffer.destroy(),this.iconTransitioningVertexBuffer&&this.iconTransitioningVertexBuffer.destroy(),this.globeExtVertexBuffer&&this.globeExtVertexBuffer.destroy(),this.zOffsetVertexBuffer&&this.zOffsetVertexBuffer.destroy())}}ba(Ng,"SymbolBuffers");class Ug{constructor(t,e,i){this.layoutVertexArray=new t,this.layoutAttributes=e,this.indexArray=new i,this.segments=new wc,this.collisionVertexArray=new Xl,this.collisionVertexArrayExt=new Ol}upload(t){this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,this.layoutAttributes),this.indexBuffer=t.createIndexBuffer(this.indexArray),this.collisionVertexBuffer=t.createVertexBuffer(this.collisionVertexArray,Gf.members,!0),this.collisionVertexBufferExt=t.createVertexBuffer(this.collisionVertexArrayExt,Zf.members,!0)}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.segments.destroy(),this.collisionVertexBuffer.destroy(),this.collisionVertexBufferExt.destroy())}}ba(Ug,"CollisionBuffers");class jg{constructor(e){this.queries=new Map,this.collisionBoxArray=e.collisionBoxArray,this.zoom=e.zoom,this.lut=e.lut,this.overscaling=e.overscaling,this.layers=e.layers,this.layerIds=this.layers.map((t=>t.fqid)),this.index=e.index,this.pixelRatio=e.pixelRatio,this.sourceLayerIndex=e.sourceLayerIndex,this.hasPattern=!1,this.hasRTLText=!1,this.fullyClipped=!1,this.hasAnyIconTextFit=!1,this.sortKeyRanges=[],this.collisionCircleArray=[],this.placementInvProjMatrix=t.ad.identity([]),this.placementViewportMatrix=t.ad.identity([]);const i=this.layers[0]._unevaluatedLayout._values;this.textSizeData=Fm(this.zoom,i["text-size"]),this.iconSizeData=Fm(this.zoom,i["icon-size"]);const n=this.layers[0].layout,r=n.get("symbol-sort-key"),o=n.get("symbol-z-order");this.canOverlap=n.get("text-allow-overlap")||n.get("icon-allow-overlap")||n.get("text-ignore-placement")||n.get("icon-ignore-placement"),this.sortFeaturesByKey="viewport-y"!==o&&void 0!==r.constantOr(1),this.sortFeaturesByY=("viewport-y"===o||"auto"===o&&!this.sortFeaturesByKey)&&this.canOverlap,this.writingModes=n.get("text-writing-mode").map((t=>Jm[t])),this.stateDependentLayerIds=this.layers.filter((t=>t.isStateDependent())).map((t=>t.id)),this.sourceID=e.sourceID,this.projection=e.projection,this.hasAnyZOffset=!1,this.zOffsetSortDirty=!1,this.zOffsetBuffersNeedUpload=n.get("symbol-z-elevate"),this.activeReplacements=[],this.replacementUpdateTime=0}createArrays(){this.text=new Ng(new Yc(this.layers,{zoom:this.zoom,lut:this.lut},(t=>/^text/.test(t)))),this.icon=new Ng(new Yc(this.layers,{zoom:this.zoom,lut:this.lut},(t=>/^icon/.test(t)))),this.glyphOffsetArray=new mc,this.lineVertexArray=new _c,this.symbolInstances=new fc}calculateGlyphDependencies(t,e,i,n,r){for(let i=0;i0)&&("constant"!==l.value.kind||l.value.value.length>0),h="constant"!==d.value.kind||!!d.value.value||Object.keys(d.parameters).length>0,p=s.get("symbol-sort-key");if(this.features=[],!u&&!h)return;const f=i.iconDependencies,m=i.glyphDependencies,_=i.availableImages,g=new Ha(this.zoom);for(const{feature:i,id:c,index:d,sourceLayerIndex:y}of e){const e=o._featureFilter.needGeometry,v=Zd(i,e);if(!o._featureFilter.filter(g,v,n))continue;if(e||(v.geometry=Gd(i,n,r)),a&&1!==i.type&&n.z{const o=Fu(e.x,e.y,n,1),s=Fu(r.x,r.y,n,1);return t._.dot(o,s)=0;for(const i of x.sections)if(i.image)f[i.image.namePrimary]=!0;else{const n=Ca(x.toString()),r=i.fontStack||t,o=m[r]=m[r]||{};this.calculateGlyphDependencies(i.text,o,e,this.allowVerticalPlacement,n)}}}"line"===s.get("symbol-placement")&&(this.features=function(t){const e={},i={},n=[];let r=0;function o(e){n.push(t[e]),r++}function s(t,e,r){const o=i[t];return delete i[t],i[e]=o,n[o].geometry[0].pop(),n[o].geometry[0]=n[o].geometry[0].concat(r[0]),o}function a(t,i,r){const o=e[i];return delete e[i],e[t]=o,n[o].geometry[0].shift(),n[o].geometry[0]=r[0].concat(n[o].geometry[0]),o}function l(t,e,i){const n=i?e[0][e[0].length-1]:e[0][0];return`${t}:${n.x}:${n.y}`}for(let c=0;ct.geometry))}(this.features)),this.sortFeaturesByKey&&this.features.sort(((t,e)=>t.sortKey-e.sortKey))}update(t,e,i,n,r){const o=0!==Object.keys(t).length;if(o&&!this.stateDependentLayers.length)return;const s=o?this.stateDependentLayers:this.layers;this.text.programConfigurations.updatePaintArrays(t,e,s,i,n,r),this.icon.programConfigurations.updatePaintArrays(t,e,s,i,n,r)}updateOcclusionOpacities(t,e,i){if(!e.useOcclusionQueries)return!1;const n=this;if("globe"===n.projection.name)return!1;let r=!1;n.hasTextData()&&(r=r||0!==n.text.occlusionQueryOpacityVertexArray.length),n.hasIconData()&&(r=r||0!==n.icon.occlusionQueryOpacityVertexArray.length);const o=n.layers[0].paint,s=o.get("icon-occlusion-opacity").constantOr(0),a=o.get("text-occlusion-opacity").constantOr(0);if(!n.layers[0].hasInitialOcclusionOpacityProperties||1===s&&1===a)return!1;let l=!r;for(let t=0;t.5?1:-1)*e.fadeSpeed*i*.001,r.occlusionOpacity=Xe(r.occlusionOpacity,0,1),l=l||r.occlusionOpacity!==o}if(!l)return!1;let c=0,d=0;const u=(t,e,i,n)=>{let r=0,o=0;i?(r=d,d+=n,o=d):(r=c,c+=n,o=c),o>e.occlusionQueryOpacityVertexArray.length&&e.occlusionQueryOpacityVertexArray.resize(o);const s=t.occlusionOpacity;for(let t=0;t0;if((i>0||r>0)&&(u(e,n.text,!1,i),u(e,n.text,!1,r)),s){const{placedIconSymbolIndex:t,verticalPlacedIconSymbolIndex:i}=e;t>=0&&u(e,n.icon,!0,o),i>=0&&u(e,n.icon,!0,e.numVerticalIconVertices)}}return n.hasTextData()&&n.text.occlusionQueryOpacityVertexBuffer&&(n.text.occlusionQueryOpacityVertexBuffer.length{i+=e,i>t.length&&t.resize(i);for(let r=-e;r{n+=e,n>t.length&&t.resize(n);for(let r=-e;r0;if((r>0||o>0)&&(t(this.text.zOffsetVertexArray,r,a),t(this.text.zOffsetVertexArray,o,a)),l){const{placedIconSymbolIndex:t,verticalPlacedIconSymbolIndex:i}=n;t>=0&&e(this.icon.zOffsetVertexArray,s,a),i>=0&&e(this.icon.zOffsetVertexArray,n.numVerticalIconVertices,a)}}this.text.zOffsetVertexBuffer&&this.text.zOffsetVertexBuffer.updateData(this.text.zOffsetVertexArray),this.icon.zOffsetVertexBuffer&&this.icon.zOffsetVertexBuffer.updateData(this.icon.zOffsetVertexArray)}isEmpty(){return 0===this.symbolInstances.length&&!this.hasRTLText}uploadPending(){return!this.uploaded||this.text.programConfigurations.needsUpload||this.icon.programConfigurations.needsUpload}upload(t){!this.uploaded&&this.hasDebugData()&&(this.textCollisionBox.upload(t),this.iconCollisionBox.upload(t)),this.text.upload(t,this.sortFeaturesByY,!this.uploaded,this.text.programConfigurations.needsUpload,this.zOffsetBuffersNeedUpload),this.icon.upload(t,this.sortFeaturesByY,!this.uploaded,this.icon.programConfigurations.needsUpload,this.zOffsetBuffersNeedUpload),this.uploaded=!0}destroyDebugData(){this.textCollisionBox.destroy(),this.iconCollisionBox.destroy()}getProjection(){return this.projectionInstance||(this.projectionInstance=Tg(this.projection)),this.projectionInstance}destroy(){this.text.destroy(),this.icon.destroy(),this.hasDebugData()&&this.destroyDebugData();for(const t of this.queries.values())t.destroy()}addToLineVertexArray(t,e){const i=this.lineVertexArray.length;if(void 0!==t.segment)for(const{x:t,y:i}of e)this.lineVertexArray.emplaceBack(t,i);return{lineStartIndex:i,lineLength:this.lineVertexArray.length-i}}addSymbols(t,e,i,n,r,o,s,a,l,c,d,u,h,p,f,m){const _=t.indexArray,g=t.layoutVertexArray,y=t.globeExtVertexArray,v=t.segments.prepareSegment(4*e.length,g,_,this.canOverlap?o.sortKey:void 0),x=this.glyphOffsetArray.length,b=v.vertexLength,w=this.allowVerticalPlacement&&s===Jm.vertical?Math.PI/2:0,T=o.text&&o.text.sections;for(let n=0;n=0?e.rightJustifiedTextSymbolIndex:e.centerJustifiedTextSymbolIndex>=0?e.centerJustifiedTextSymbolIndex:e.leftJustifiedTextSymbolIndex>=0?e.leftJustifiedTextSymbolIndex:e.verticalPlacedTextSymbolIndex>=0?e.verticalPlacedTextSymbolIndex:n),o=Nm(this.textSizeData,t,r)/Om;return this.tilePixelRatio*o}getSymbolInstanceIconSize(t,e,i){const n=this.icon.placedSymbolArray.get(i),r=Nm(this.iconSizeData,t,n);return this.tilePixelRatio*r}_commitDebugCollisionVertexUpdate(t,e,i,n){t.emplaceBack(e,-i,-i,n),t.emplaceBack(e,i,-i,n),t.emplaceBack(e,i,i,n),t.emplaceBack(e,-i,i,n)}_updateTextDebugCollisionBoxes(t,e,i,n,r,o){for(let s=n;s0}hasIconData(){return this.icon.segments.get().length>0}hasDebugData(){return this.textCollisionBox&&this.iconCollisionBox}hasTextCollisionBoxData(){return this.hasDebugData()&&this.textCollisionBox.segments.get().length>0}hasIconCollisionBoxData(){return this.hasDebugData()&&this.iconCollisionBox.segments.get().length>0}hasIconTextFit(){return this.hasAnyIconTextFit}addIndicesForPlacedSymbol(t,e){const i=t.placedSymbolArray.get(e),n=i.vertexStartIndex+4*i.numGlyphs;for(let e=i.vertexStartIndex;en[t]-n[e]||r[e]-r[t])),o}getSortedIndexesByZOffset(){if(!this.zOffsetSortDirty)return this.symbolInstanceIndexesSortedZOffset;if(!this.symbolInstanceIndexesSortedZOffset){this.symbolInstanceIndexesSortedZOffset=[];for(let t=0;tthis.symbolInstances.get(e).zOffset-this.symbolInstances.get(t).zOffset))}addToSortKeyRanges(t,e){const i=this.sortKeyRanges[this.sortKeyRanges.length-1];i&&i.sortKey===e?i.symbolInstanceEnd=t+1:this.sortKeyRanges.push({sortKey:e,symbolInstanceStart:t,symbolInstanceEnd:t+1})}sortFeatures(t){if(this.sortFeaturesByY&&this.sortedAngle!==t&&!(this.text.segments.get().length>1||this.icon.segments.get().length>1)){this.symbolInstanceIndexes=this.getSortedSymbolIndexes(t),this.sortedAngle=t,this.text.indexArray.clear(),this.icon.indexArray.clear(),this.featureSortOrder=[];for(const t of this.symbolInstanceIndexes){const e=this.symbolInstances.get(t);this.featureSortOrder.push(e.featureIndex);const{rightJustifiedTextSymbolIndex:i,centerJustifiedTextSymbolIndex:n,leftJustifiedTextSymbolIndex:r,verticalPlacedTextSymbolIndex:o,placedIconSymbolIndex:s,verticalPlacedIconSymbolIndex:a}=e;i>=0&&this.addIndicesForPlacedSymbol(this.text,i),n>=0&&n!==i&&this.addIndicesForPlacedSymbol(this.text,n),r>=0&&r!==n&&r!==i&&this.addIndicesForPlacedSymbol(this.text,r),o>=0&&this.addIndicesForPlacedSymbol(this.text,o),s>=0&&this.addIndicesForPlacedSymbol(this.icon,s),a>=0&&this.addIndicesForPlacedSymbol(this.icon,a)}this.text.indexBuffer&&this.text.indexBuffer.updateData(this.text.indexArray),this.icon.indexBuffer&&this.icon.indexBuffer.updateData(this.icon.indexArray)}}}ba(jg,"SymbolBucket",{omit:["layers","collisionBoxArray","features","compareText"]}),jg.addDynamicAttributes=Bg;class Vg{constructor(t,e,i,n){this.context=t,this.format=i,this.texture=t.gl.createTexture(),this.update(e,n)}update(t,e,i){const{width:n,height:r}=t,{context:o}=this,{gl:s}=o;if(s.bindTexture(s.TEXTURE_2D,this.texture),o.pixelStoreUnpackFlipY.set(!1),o.pixelStoreUnpack.set(1),o.pixelStoreUnpackPremultiplyAlpha.set(this.format===s.RGBA&&(!e||!1!==e.premultiply)),this.useMipmap=Boolean(e&&e.useMipmap),i||this.size&&this.size[0]===n&&this.size[1]===r){const{x:e,y:o}=i||{x:0,y:0};if(t instanceof HTMLImageElement||t instanceof HTMLCanvasElement||t instanceof HTMLVideoElement||t instanceof ImageData||ImageBitmap&&t instanceof ImageBitmap)s.texSubImage2D(s.TEXTURE_2D,0,e,o,s.RGBA,s.UNSIGNED_BYTE,t);else{let i=this.format,a=s.UNSIGNED_BYTE;this.format===s.R32F&&(i=s.RED,a=s.FLOAT),s.texSubImage2D(s.TEXTURE_2D,0,e,o,n,r,i,a,t.data)}}else if(this.size=[n,r],t instanceof HTMLImageElement||t instanceof HTMLCanvasElement||t instanceof HTMLVideoElement||t instanceof ImageData||ImageBitmap&&t instanceof ImageBitmap){let e=this.format;this.format===s.R8&&(e=s.RED),s.texImage2D(s.TEXTURE_2D,0,this.format,e,s.UNSIGNED_BYTE,t)}else{let e=this.format,i=this.format,o=s.UNSIGNED_BYTE,a=!1;this.format===s.DEPTH_COMPONENT&&(e=s.DEPTH_COMPONENT16,o=s.UNSIGNED_SHORT),this.format===s.DEPTH_STENCIL&&(e=s.DEPTH24_STENCIL8,o=s.UNSIGNED_INT_24_8,a=!0),this.format===s.R8&&(i=s.RED),this.format===s.R32F&&(o=s.FLOAT,i=s.RED),!this.useMipmap&&a?s.texStorage2D(s.TEXTURE_2D,1,e,n,r):s.texImage2D(s.TEXTURE_2D,0,e,n,r,0,i,o,t.data)}this.useMipmap&&s.generateMipmap(s.TEXTURE_2D)}bind(t,e,i=!1){const{context:n}=this,{gl:r}=n;r.bindTexture(r.TEXTURE_2D,this.texture),t!==this.minFilter&&(r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MAG_FILTER,t),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MIN_FILTER,this.useMipmap&&!i?t===r.NEAREST?r.NEAREST_MIPMAP_NEAREST:r.LINEAR_MIPMAP_LINEAR:t),this.minFilter=t),e!==this.wrapS&&(r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_S,e),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_T,e),this.wrapS=e)}bindExtraParam(t,e,i,n){const{context:r}=this,{gl:o}=r;o.bindTexture(o.TEXTURE_2D,this.texture),e!==this.magFilter&&(o.texParameteri(o.TEXTURE_2D,o.TEXTURE_MAG_FILTER,e),this.magFilter=e),t!==this.minFilter&&(o.texParameteri(o.TEXTURE_2D,o.TEXTURE_MIN_FILTER,this.useMipmap?t===o.NEAREST?o.NEAREST_MIPMAP_NEAREST:o.LINEAR_MIPMAP_LINEAR:t),this.minFilter=t),i!==this.wrapS&&(o.texParameteri(o.TEXTURE_2D,o.TEXTURE_WRAP_S,i),this.wrapS=i),n!==this.wrapT&&(o.texParameteri(o.TEXTURE_2D,o.TEXTURE_WRAP_T,n),this.wrapT=n)}destroy(){const{gl:t}=this.context;t.deleteTexture(this.texture),this.texture=null}}class Gg{constructor(t,e){this.context=t,this.texture=e}bind(t,e){const{context:i}=this,{gl:n}=i;n.bindTexture(n.TEXTURE_2D,this.texture),t!==this.minFilter&&(n.texParameteri(n.TEXTURE_2D,n.TEXTURE_MAG_FILTER,t),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_MIN_FILTER,t),this.minFilter=t),e!==this.wrapS&&(n.texParameteri(n.TEXTURE_2D,n.TEXTURE_WRAP_S,e),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_WRAP_T,e),this.wrapS=e)}}const Zg=32,qg=33,Hg=new Uint16Array(8184);for(let t=0;t>=1)>1;){const t=i+r>>1,l=n+o>>1;1&e?(r=i,o=n,i=s,n=a):(i=r,n=o,r=s,o=a),s=t,a=l}const l=4*t;Hg[l+0]=i,Hg[l+1]=n,Hg[l+2]=r,Hg[l+3]=o}const Wg=new Uint16Array(2178),Yg=new Uint8Array(1089),Xg=new Uint16Array(1089);function Kg(t){return 0===t?-.03125:32===t?.03125:0}var Jg=Ll([{name:"a_pos",type:"Int16",components:2},{name:"a_texture_pos",type:"Int16",components:2}]),Qg=Ll([{name:"a_index",type:"Int16",components:1}]);const ty={type:2,extent:uo,loadGeometry:()=>[[new Ue(0,0),new Ue(uo+1,0),new Ue(uo+1,uo+1),new Ue(0,uo+1),new Ue(0,0)]]};class ey{constructor(t,e,i,n,r){this.tileID=t,this.uid=ni(),this.uses=0,this.tileSize=e,this.tileZoom=i,this.buckets={},this.expirationTime=null,this.queryPadding=0,this.hasSymbolBuckets=!1,this.hasRTLText=!1,this.dependencies={},this.isRaster=r,n&&n.style&&(this._lastUpdatedBrightness=n.style.getBrightness()),this.expiredRequestCount=0,this.state="loading",n&&n.transform&&(this.projection=n.transform.projection)}registerFadeDuration(t){const e=t+this.timeAdded;ee.getLayer(t))).filter(Boolean);if(0!==t.length){n.layers=t,n.stateDependentLayerIds&&(n.stateDependentLayers=n.stateDependentLayerIds.map((e=>t.filter((t=>t.id===e))[0])));for(const e of t)i[e.fqid]=n}}return i}(t.buckets,e.style),this.hasSymbolBuckets=!1;for(const t in this.buckets){const e=this.buckets[t];if(e instanceof jg){if(this.hasSymbolBuckets=!0,!i)break;e.justReloaded=!0}}if(this.hasRTLText=!1,this.hasSymbolBuckets)for(const t in this.buckets){const e=this.buckets[t];if(e instanceof jg&&e.hasRTLText){this.hasRTLText=!0,qa.isLoading()||qa.isLoaded()||"deferred"!==Ga()||Za();break}}this.queryPadding=0;for(const t in this.buckets){const i=this.buckets[t],n=e.style.getOwnLayer(t);if(!n)continue;const r=n.queryRadius(i);this.queryPadding=Math.max(this.queryPadding,r)}t.imageAtlas&&(this.imageAtlas=t.imageAtlas),t.glyphAtlasImage&&(this.glyphAtlasImage=t.glyphAtlasImage),t.lineAtlas&&(this.lineAtlas=t.lineAtlas),this._lastUpdatedBrightness=t.brightness}else this.collisionBoxArray=new dc}unloadVectorData(){if(this.hasData()){for(const t in this.buckets)this.buckets[t].destroy();this.buckets={},this.imageAtlas&&(this.imageAtlas=null),this.lineAtlas&&(this.lineAtlas=null),this.imageAtlasTexture&&this.imageAtlasTexture.destroy(),this.glyphAtlasTexture&&this.glyphAtlasTexture.destroy(),this.lineAtlasTexture&&this.lineAtlasTexture.destroy(),this._tileBoundsBuffer&&(this._tileBoundsBuffer.destroy(),this._tileBoundsIndexBuffer.destroy(),this._tileBoundsSegments.destroy(),this._tileBoundsBuffer=null),this._tileDebugBuffer&&(this._tileDebugBuffer.destroy(),this._tileDebugSegments.destroy(),this._tileDebugBuffer=null),this._tileDebugIndexBuffer&&(this._tileDebugIndexBuffer.destroy(),this._tileDebugIndexBuffer=null),this._globeTileDebugBorderBuffer&&(this._globeTileDebugBorderBuffer.destroy(),this._globeTileDebugBorderBuffer=null),this._tileDebugTextBuffer&&(this._tileDebugTextBuffer.destroy(),this._tileDebugTextSegments.destroy(),this._tileDebugTextIndexBuffer.destroy(),this._tileDebugTextBuffer=null),this._globeTileDebugTextBuffer&&(this._globeTileDebugTextBuffer.destroy(),this._globeTileDebugTextBuffer=null),this.latestFeatureIndex=null,this.state="unloaded"}}getBucket(t){return this.buckets[t.fqid]}upload(t){for(const e in this.buckets){const i=this.buckets[e];i.uploadPending()&&i.upload(t)}const e=t.gl,i=this.imageAtlas;if(i&&!i.uploaded){const n=!!Object.keys(i.patternPositions).length;this.imageAtlasTexture=new Vg(t,i.image,e.RGBA,{useMipmap:n}),this.imageAtlas.uploaded=!0}this.glyphAtlasImage&&(this.glyphAtlasTexture=new Vg(t,this.glyphAtlasImage,e.R8),this.glyphAtlasImage=null),this.lineAtlas&&!this.lineAtlas.uploaded&&(this.lineAtlasTexture=new Vg(t,this.lineAtlas.image,e.R8),this.lineAtlas.uploaded=!0)}prepare(t,e,i){if(this.imageAtlas&&this.imageAtlasTexture&&this.imageAtlas.patchUpdatedImages(t,this.imageAtlasTexture,i),!e||!this.latestFeatureIndex||!this.latestFeatureIndex.rawTileData)return;const n=e.style.getBrightness();(this._lastUpdatedBrightness||n)&&(this._lastUpdatedBrightness&&n&&Math.abs(this._lastUpdatedBrightness-n)t)i=!1;else if(e)if(this.expirationTime=0;t--){const e=4*t,i=Hg[e+0],n=Hg[e+1],r=Hg[e+2],o=Hg[e+3],s=i+r>>1,a=n+o>>1,l=s+a-n,c=a+i-s,d=n*qg+i,u=o*qg+r,h=a*qg+s,p=Math.hypot((Wg[2*d+0]+Wg[2*u+0])/2-Wg[2*h+0],(Wg[2*d+1]+Wg[2*u+1])/2-Wg[2*h+1])>=16;Yg[h]=Yg[h]||(p?1:0),t>1)*qg+(i+l>>1)]||Yg[(o+c>>1)*qg+(r+l>>1)])}const r=new Dl,o=new Kl;let s=0;function a(t,e){const i=e*qg+t;return 0===Xg[i]&&(r.emplaceBack(Wg[2*i+0],Wg[2*i+1],t*uo/Zg,e*uo/Zg),Xg[i]=++s),Xg[i]-1}function l(t,e,i,n,r,s){const c=t+i>>1,d=e+n>>1;if(Math.abs(t-r)+Math.abs(e-s)>1&&Yg[d*qg+c])l(r,s,t,e,c,d),l(i,n,r,s,c,d);else{const l=a(t,e),c=a(i,n),d=a(r,s);o.emplaceBack(l,c,d)}}return l(0,0,Zg,Zg,Zg,0),l(Zg,Zg,0,0,0,Zg),{vertices:r,indices:o}}(this.tileID.canonical,e);n=t.vertices,r=t.indices}else{n=new Dl,r=new Kl;for(const{x:t,y:e}of i)n.emplaceBack(t,e,0,0);const t=xh(n.int16,void 0,4);for(let e=0;e0&&(a=t.ad.invert(new Float64Array(16),i.globeMatrix)),this._makeGlobeTileDebugBorderBuffer(e,r,i,o,a,s),this._makeGlobeTileDebugTextBuffer(e,r,i,o,a,s)}_globePoint(e,i,n,r,o,s,a){let l=Fu(e,i,n);if(s){const o=1.5?h=-1:u{const p=(d-t)/(h-1),f=(u-c)/(h-1),m=s.length;for(let d=0;dd*t+e;for(let t=0;t[t,this.get(t)]))}evict(t=!1){if(t||this.size>0){const t=this.first;delete this.items[t.key],0==--this.size?(this.first=null,this.last=null):(this.first=t.next,this.first.prev=null)}return this}expiresAt(t){let e;return this.has(t)&&(e=this.items[t].expiry),e}get(t){let e;if(this.has(t)){const i=this.items[t];this.ttl>0&&i.expiry0?Date.now()+this.ttl:this.ttl),this.last!==r){const t=this.last,e=r.next,i=r.prev;this.first===r&&(this.first=r.next),r.next=null,r.prev=this.last,t.next=r,null!==i&&(i.next=e),null!==e&&(e.prev=i)}}else this.max>0&&this.size===this.max&&this.evict(!0),r=this.items[t]={expiry:this.ttl>0?Date.now()+this.ttl:this.ttl,key:t,prev:this.last,next:null,value:e},1==++this.size?this.first=r:this.last.next=r;return this.last=r,this}values(t=this.keys()){return t.map((t=>this.get(t)))}}function uy(t,e){if(4!==e.length)throw new Error(`Expected data of dimension 4 but got ${e.length}.`);let i=e[3];for(let n=2;n>=1;n--){const r=1===n?1:0,o=2===n?1:0;for(let n=0;n>>1^-(1&t[e]);return t}function py(t,e){switch(e){case"uint32":return t;case"uint16":for(let e=0;e>4|(61440&i)>>8|(240&n)>4|(15&n)>6|(192&n)>>4|(192&r)>>2|192&o,t[e+1]=(48&i)>>4|(48&n)>>2|48&r|(48&o)>2|12&n|(12&r)>1|(21845&Cy)>2|(13107&Ay)>4|(3855&Ay)>8|(255&Ay)>1}var Iy=function(t,e,i){for(var n=t.length,r=0,o=new _y(e);r>l]=c}else for(s=new _y(n),r=0;r>15-t[r]);return s},Ly=new my(288);for(Cy=0;Cye&&(e=t[i]);return e},zy=function(t,e,i){var n=e/8|0;return(t[n]|t[n+1]>(7&e)&i},Ry=function(t,e){var i=e/8|0;return(t[i]|t[i+1]>(7&e)},Oy=["unexpected EOF","invalid block type","invalid length/literal","invalid distance","stream finished","no stream handler",,"no callback","invalid UTF-8 data","extra field too long","date not in range 1980-2099","filename too long","stream finishing","invalid zip data"],By=function(t,e,i){var n=new Error(e||Oy[t]);if(n.code=t,Error.captureStackTrace&&Error.captureStackTrace(n,By),!i)throw n;return n},Fy=new my(0),Ny="undefined"!=typeof TextDecoder&&new TextDecoder;try{Ny.decode(Fy,{stream:!0})}catch(t){}const Uy={gzip_data:"gzip"},jy={0:"uint32",1:"uint32",2:"uint16",3:"uint8"},Vy={uint32:1,uint16:2,uint8:4},Gy={uint32:Uint32Array,uint16:Uint16Array,uint8:Uint8Array};class Zy{constructor(t=1){this.x=NaN,this.y=NaN,this.z=NaN,this.layers={},this._cacheSize=t}getLayer(t){return this.layers[t]}getHeaderLength(t){const e=new Uint8Array(t),i=new DataView(t);if(13!==e[0])throw new fy("File is not a valid MRT.");return i.getUint32(1,!0)}parseHeader(t){const e=new Uint8Array(t),i=this.getHeaderLength(t);if(e.length= ${i} but got buffer of length ${e.length}`);const n=function(t){return t.readFields(iy,{header_length:0,x:0,y:0,z:0,layers:[]},void 0)}(new Lm(e.subarray(0,i)));if(!isNaN(this.x)&&(this.x!==n.x||this.y!==n.y||this.z!==n.z))throw new fy(`Invalid attempt to parse header ${n.z}/${n.x}/${n.y} for tile ${this.z}/${this.x}/${this.y}`);this.x=n.x,this.y=n.y,this.z=n.z;for(const t of n.layers)this.layers[t.name]=new qy(t,{cacheSize:this._cacheSize});return this}createDecodingTask(t){const e=[],i=this.getLayer(t.layerName);for(let n=0;nt.lastBlock)continue;if(i._blocksInProgress.has(n))continue;const a={layerName:i.name,firstByte:o,lastByte:s,pixelFormat:i.pixelFormat,blockIndex:n,blockShape:[r.bands.length].concat(i.bandShape),buffer:i.buffer,codec:r.codec.codec,filters:r.filters.map((t=>t.filter))};i._blocksInProgress.add(n),e.push(a)}return new Hy(e,(()=>{e.forEach((t=>i._blocksInProgress.delete(t.blockIndex)))}),((t,n)=>{if(e.forEach((t=>i._blocksInProgress.delete(t.blockIndex))),t)throw t;n.forEach((t=>{this.getLayer(t.layerName).processDecodedData(t)}))}))}}class qy{constructor({version:t,name:e,units:i,tilesize:n,pixel_format:r,buffer:o,data_index:s},a){if(this.version=t,1!==this.version)throw new fy(`Cannot parse raster layer encoded with MRT version ${t}`);this.name=e,this.units=i,this.tileSize=n,this.buffer=o,this.pixelFormat=jy[r],this.dataIndex=s,this.bandShape=[n+2*o,n+2*o,Vy[this.pixelFormat]],this._decodedBlocks=function(t=1e3,e=0,i=!1){if(isNaN(t)||t=e&&t=0}hasDataForBand(t){const{blockIndex:e}=this.getBlockForBand(t);return e>=0&&!!this._decodedBlocks.get(e.toString())}getBandView(t){const{blockIndex:e,blockBandIndex:i}=this.getBlockForBand(t),n=this._decodedBlocks.get(e.toString());if(!n)throw new fy(`Data for band ${JSON.stringify(t)} of layer "${this.name}" not decoded.`);const r=this.dataIndex[e],o=this.bandShape.reduce(((t,e)=>t*e),1),s=i*o,a=n.subarray(s,s+o);return{data:a,bytes:new Uint8Array(a.buffer).subarray(a.byteOffset,a.byteOffset+a.byteLength),tileSize:this.tileSize,buffer:this.buffer,offset:r.offset,scale:r.scale}}}class Hy{constructor(t,e,i){this.tasks=t,this._onCancel=e,this._onComplete=i,this._finalized=!1}cancel(){this._finalized||(this._onCancel(),this._finalized=!0)}complete(t,e){this._finalized||(this._onComplete(t,e),this._finalized=!0)}}Zy.performDecoding=function(t,e){return Promise.all(e.tasks.map((e=>{const{layerName:i,firstByte:n,lastByte:r,pixelFormat:o,blockShape:s,blockIndex:a,filters:l,codec:c}=e,d=new Uint8Array(t).subarray(n,r+1),u=new Uint32Array(s[0]*s[1]*s[2]);let h;if("gzip_data"!==c)throw new Error(`Unhandled codec: ${c}`);return h=function(t,e){if(!globalThis.DecompressionStream&&"gzip_data"===e)return Promise.resolve(((o=function(t){31==t[0]&&139==t[1]&&8==t[2]||By(6,"invalid gzip data");var e=t[3],i=10;4&e&&(i+=2+(t[10]|t[11]>3&1)+(e>>4&1);n>0;n-=!t[i++]);return i+(2&e)}(r=t))+8>r.length&&By(6,"invalid gzip data"),function(t,e,i){var n=t.length;if(!n||e.f&&!e.l)return i||new my(0);var r=!i,o=r||2!=e.i,s=e.i;r&&(i=new my(3*n));var a,l,c=function(t){var e=i.length;if(t>e){var n=new my(Math.max(2*e,t));n.set(i),i=n}},d=e.f||0,u=e.p||0,h=e.b||0,p=e.l,f=e.d,m=e.m,_=e.n,g=8*n;do{if(!p){d=zy(t,u,1);var y=zy(t,u+1,3);if(u+=3,!y){var v=t[(L=4+((u+7)/8|0))-4]|t[L-3]n){s&&By(0);break}o&&c(h+v),i.set(t.subarray(L,x),h),e.b=h+=v,e.p=u=8*x,e.f=d;continue}if(1==y)p=$y,f=ky,m=9,_=5;else if(2==y){var b=zy(t,u,31)+257,w=zy(t,u+10,15)+4,T=b+zy(t,u+5,31)+1;u+=14;for(var S=new my(T),E=new my(19),M=0;M>4)g){s&&By(0);break}}o&&c(h+131072);for(var R=(1>4;if((u+=15&$)>g){s&&By(0);break}if($||By(2),F264&&(N=zy(t,u,(1>4;if(U||By(3),u+=15&U,z=Ey[j],j>3){var V=vy[j];z+=Ry(t,u)&(1g){s&&By(0);break}o&&c(h+131072);var G=h+N;if(ha.length)&&(l=a.length),new my(a.subarray(0,l))):i.subarray(0,h)}(r.subarray(o,-8),{i:2},new my(((i=r)[(n=i.length)-4]|i[n-3]>>0))));var i,n,r,o;const s=Uy[e];if(!s)throw new Error(`Unhandled codec: ${e}`);const a=new globalThis.DecompressionStream(s);return new Response(new Blob([t]).stream().pipeThrough(a)).arrayBuffer().then((t=>new Uint8Array(t)))}(d,c).then((t=>(function(t,e){t.readFields(ly,e)}(new Lm(t),u),new(0,Gy[o])(u.buffer)))),h.then((t=>{for(let e=l.length-1;e>=0;e--)switch(l[e]){case"delta_filter":uy(t,s);break;case"zigzag_filter":hy(t);break;case"bitshuffle_filter":py(t,o);break;default:throw new Error(`Unhandled filter "${l[e]}"`)}return{layerName:i,blockIndex:a,data:t}})).catch((t=>{throw t}))})))};class Wy extends ey{constructor(t,e,i,n,r){super(t,e,i,n,r),this._workQueue=[],this._fetchQueue=[],this._isHeaderLoaded=!1}setTexture(t,e){const i=e.context,n=i.gl;this.texture=this.texture||e.getTileTexture(t.width),this.texture&&this.texture instanceof Vg?this.texture.update(t,{useMipmap:!1,premultiply:!1}):this.texture=new Vg(i,t,n.RGBA,{useMipmap:!1,premultiply:!1})}flushQueues(){for(;this._workQueue.length;)this._workQueue.pop()();for(;this._fetchQueue.length;)this._fetchQueue.pop()()}fetchHeader(t=16384,e){const i=this._mrt=new Zy(30),n=Object.assign({},this.requestParams,{headers:{Range:"bytes=0-"+(t-1)}});return this.entireBuffer=null,this.request=en(n,((n,r,o,s)=>{if(n)e(n);else try{const n=i.getHeaderLength(r);if(n>t)return void(this.request=this.fetchHeader(n,e));i.parseHeader(r),this._isHeaderLoaded=!0;let a=0;for(const t of Object.values(i.layers))a=Math.max(a,t.dataIndex[t.dataIndex.length-1].last_byte);r.byteLength>=a&&(this.entireBuffer=r),e(null,this.entireBuffer||r,o,s)}catch(t){e(t)}})),this.request}fetchBand(t,e,i){const n=this._mrt;if(!this._isHeaderLoaded||!n)return void i(new Error("Tile header is not ready"));const r=this.actor;if(!r)return void i(new Error("Can't fetch tile band without an actor"));let o;const s=(n,r)=>{o.complete(n,r),n?i(n):(this.updateTextureDescriptor(t,e),i(null,this.textureDescriptor&&this.textureDescriptor.img))},a=(t,e)=>{if(t)return i(t);const n=r.send("decodeRasterArray",{buffer:e,task:o},s,void 0,!0);this._workQueue.push((()=>{n&&n.cancel(),o.cancel()}))},l=n.getLayer(t);if(!l)return void i(new Error(`Unknown sourceLayer "${t}"`));if(l.hasDataForBand(e))return this.updateTextureDescriptor(t,e),void i(null,this.textureDescriptor?this.textureDescriptor.img:null);const c=l.getDataRange([e]);if(o=n.createDecodingTask(c),!o||o.tasks.length)if(this.flushQueues(),this.entireBuffer)a(null,this.entireBuffer.slice(c.firstByte,c.lastByte+1));else{const t=Object.assign({},this.requestParams,{headers:{Range:`bytes=${c.firstByte}-${c.lastByte}`}}),e=en(t,a);this._fetchQueue.push((()=>{e.cancel(),o.cancel()}))}else i(null)}updateNeeded(t,e){return(!this.textureDescriptor||this.textureDescriptor.band!==e||this.textureDescriptor.layer!==t)&&"errored"!==this.state}updateTextureDescriptor(t,e){if(!this._mrt)return;const i=this._mrt.getLayer(t);if(!i||!i.hasBand(e)||!i.hasDataForBand(e))return;const{bytes:n,tileSize:r,buffer:o,offset:s,scale:a}=i.getBandView(e),l=r+2*o,c={data:n,width:l,height:l},d=this.texture;d&&d instanceof Vg&&d.update(c,{useMipmap:!1,premultiply:!1}),this.textureDescriptor={layer:t,band:e,img:c,buffer:o,offset:s,tileSize:r,format:i.pixelFormat,mix:[a,256*a,65536*a,16777216*a]}}}class Yy{constructor(t,e){this.max=t,this.onRemove=e,this.reset()}reset(){for(const t in this.data)for(const e of this.data[t])e.timeout&&clearTimeout(e.timeout),this.onRemove(e.value);return this.data={},this.order=[],this}add(t,e,i){const n=t.wrapped().key;void 0===this.data[n]&&(this.data[n]=[]);const r={value:e,timeout:void 0};if(void 0!==i&&(r.timeout=setTimeout((()=>{this.remove(t,r)}),i)),this.data[n].push(r),this.order.push(n),this.order.length>this.max){const t=this._getAndRemoveByKey(this.order[0]);t&&this.onRemove(t)}return this}has(t){return t.wrapped().key in this.data}getAndRemove(t){return this.has(t)?this._getAndRemoveByKey(t.wrapped().key):null}_getAndRemoveByKey(t){const e=this.data[t].shift();return e.timeout&&clearTimeout(e.timeout),0===this.data[t].length&&delete this.data[t],this.order.splice(this.order.indexOf(t),1),e.value}getByKey(t){const e=this.data[t];return e?e[0].value:null}get(t){return this.has(t)?this.data[t.wrapped().key][0].value:null}remove(t,e){if(!this.has(t))return this;const i=t.wrapped().key,n=void 0===e?0:this.data[i].indexOf(e),r=this.data[i][n];return this.data[i].splice(n,1),r.timeout&&clearTimeout(r.timeout),0===this.data[i].length&&delete this.data[i],this.onRemove(r.value),this.order.splice(this.order.indexOf(i),1),this}setMaxSize(t){for(this.max=t;this.order.length>this.max;){const t=this._getAndRemoveByKey(this.order[0]);t&&this.onRemove(t)}return this}filter(t){const e=[];for(const i in this.data)for(const n of this.data[i])t(n.value)||e.push(n);for(const t of e)this.remove(t.value.tileID,t)}}class Xy extends zn{constructor(t,e,i){super(),this.id=t,this._onlySymbols=i,e.on("data",(t=>{"source"===t.dataType&&"metadata"===t.sourceDataType&&(this._sourceLoaded=!0),this._sourceLoaded&&!this._paused&&"source"===t.dataType&&"content"===t.sourceDataType&&(this.reload(),this.transform&&this.update(this.transform))})),e.on("error",(()=>{this._sourceErrored=!0})),this._source=e,this._tiles={},this._cache=new Yy(0,this._unloadTile.bind(this)),this._timers={},this._cacheTimers={},this._minTileCacheSize=e.minTileCacheSize,this._maxTileCacheSize=e.maxTileCacheSize,this._loadedParentTiles={},this.castsShadows=!1,this.tileCoverLift=0,this._coveredTiles={},this._shadowCasterTiles={},this._state=new km,this._isRaster="raster"===this._source.type||"raster-dem"===this._source.type||"raster-array"===this._source.type||"custom"===this._source.type&&"raster"===this._source._dataType}onAdd(t){this.map=t,this._minTileCacheSize=void 0===this._minTileCacheSize&&t?t._minTileCacheSize:this._minTileCacheSize,this._maxTileCacheSize=void 0===this._maxTileCacheSize&&t?t._maxTileCacheSize:this._maxTileCacheSize}loaded(){if(this._sourceErrored)return!0;if(!this._sourceLoaded)return!1;if(!this._source.loaded())return!1;for(const t in this._tiles){const e=this._tiles[t];if("errored"!==e.state&&("loaded"!==e.state||!e.bucketsLoaded()))return!1}return!0}getSource(){return this._source}pause(){this._paused=!0}resume(){if(!this._paused)return;const t=this._shouldReloadOnResume;this._paused=!1,this._shouldReloadOnResume=!1,t&&this.reload(),this.transform&&this.update(this.transform)}_loadTile(t,e){return t.isSymbolTile=this._onlySymbols,t.isExtraShadowCaster=this._shadowCasterTiles[t.tileID.key],this._source.loadTile(t,e)}_unloadTile(t){if(this._source.unloadTile)return this._source.unloadTile(t)}_abortTile(t){if(this._source.abortTile)return this._source.abortTile(t)}serialize(){return this._source.serialize()}prepare(t){this._source.prepare&&this._source.prepare(),this._state.coalesceChanges(this._tiles,this.map?this.map.painter:null);for(const e in this._tiles){const i=this._tiles[e];i.upload(t),i.prepare(this.map.style.imageManager,this.map?this.map.painter:null,this._source.scope)}}getIds(){return ti(this._tiles).map((t=>t.tileID)).sort(Ky).map((t=>t.key))}getRenderableIds(t,e){const i=[];for(const n in this._tiles)this._isIdRenderable(+n,t,e)&&i.push(this._tiles[n]);return t?i.sort(((t,e)=>{const i=t.tileID,n=e.tileID,r=new Ue(i.canonical.x,i.canonical.y)._rotate(this.transform.angle),o=new Ue(n.canonical.x,n.canonical.y)._rotate(this.transform.angle);return i.overscaledZ-n.overscaledZ||o.y-r.y||o.x-r.x})).map((t=>t.tileID.key)):i.map((t=>t.tileID)).sort(Ky).map((t=>t.key))}hasRenderableParent(t){const e=this.findLoadedParent(t,0);return!!e&&this._isIdRenderable(e.tileID.key)}_isIdRenderable(t,e,i){return this._tiles[t]&&this._tiles[t].hasData()&&!this._coveredTiles[t]&&(e||!this._tiles[t].holdingForFade())&&(i||!this._shadowCasterTiles[t])}reload(){if(this._paused)this._shouldReloadOnResume=!0;else{this._cache.reset();for(const t in this._tiles)"errored"!==this._tiles[t].state&&this._reloadTile(+t,"reloading")}}_reloadTile(t,e){const i=this._tiles[t];i&&("loading"!==i.state&&(i.state=e),this._loadTile(i,this._tileLoaded.bind(this,i,t,e)))}_tileLoaded(t,e,i,n){if(n)if(t.state="errored",404!==n.status)this._source.fire(new $n(n,{tile:t}));else{if(!(t.tileID.key in this._loadedParentTiles))return void this._source.fire(new Pn("data",{dataType:"source",sourceDataType:"error",sourceId:this._source.id}));if("raster-dem"===this._source.type&&this.usedForTerrain&&this.map.painter.terrain){const t=this.map.painter.terrain;this.update(this.transform,t.getScaledDemTileSize(),!0),t.resetTileLookupCache(this.id)}else this.update(this.transform)}else t.timeAdded=ki.now(),"expired"===i&&(t.refreshedUponExpiration=!0),this._setTileReloadTimer(e,t),"raster-dem"===this._source.type&&t.dem&&this._backfillDEM(t),this._state.initializeTileState(t,this.map?this.map.painter:null),this._source.fire(new Pn("data",{dataType:"source",tile:t,coord:t.tileID,sourceCacheId:this.id}))}_backfillDEM(t){const e=this.getRenderableIds();for(let n=0;n1||(Math.abs(i)>1&&(1===Math.abs(i+r)?i+=r:1===Math.abs(i-r)&&(i-=r)),e.dem&&t.dem&&(t.dem.backfillBorder(e.dem,i,n),t.neighboringTiles&&t.neighboringTiles[o]&&(t.neighboringTiles[o].backfilled=!0)))}}getTile(t){return this.getTileByID(t.key)}getTileByID(t){return this._tiles[t]}_retainLoadedChildren(t,e,i,n){for(const r in this._tiles){let o=this._tiles[r];if(n[r]||!o.hasData()||o.tileID.overscaledZi)continue;let s=o.tileID;for(;o&&o.tileID.overscaledZ>e+1;){const t=o.tileID.scaledTo(o.tileID.overscaledZ-1);o=this._tiles[t.key],o&&o.hasData()&&(s=t)}let a=s;for(;a.overscaledZ>e;)if(a=a.scaledTo(a.overscaledZ-1),t[a.key]){n[s.key]=s;break}}}findLoadedParent(t,e){if(t.key in this._loadedParentTiles){const i=this._loadedParentTiles[t.key];return i&&i.tileID.overscaledZ>=e?i:null}for(let i=t.overscaledZ-1;i>=e;i--){const e=t.scaledTo(i),n=this._getLoadedTile(e);if(n)return n}}_getLoadedTile(t){const e=this._tiles[t.key];return e&&e.hasData()?e:this._cache.getByKey(this._source.reparseOverscaled?t.wrapped().key:t.canonical.key)}updateCacheSize(t,e){e=e||this._source.tileSize;const i=Math.ceil(t.width/e)+1,n=Math.ceil(t.height/e)+1,r=Math.floor(i*n*5),o="number"==typeof this._minTileCacheSize?Math.max(this._minTileCacheSize,r):r,s="number"==typeof this._maxTileCacheSize?Math.min(this._maxTileCacheSize,o):o;this._cache.setMaxSize(s)}handleWrapJump(t){const e=Math.round((t-(void 0===this._prevLng?t:this._prevLng))/360);if(this._prevLng=t,e){const t={};for(const i in this._tiles){const n=this._tiles[i];n.tileID=n.tileID.unwrapTo(n.tileID.wrap+e),t[n.tileID.key]=n}this._tiles=t;for(const t in this._timers)clearTimeout(this._timers[t]),delete this._timers[t];for(const t in this._tiles)this._setTileReloadTimer(+t,this._tiles[t])}}update(t,e,i,n){if(this.transform=t,!this._sourceLoaded||this._paused||this.transform.freezeTileCoverage)return;if(this.usedForTerrain&&!i)return;let r;if(this.updateCacheSize(t,e),"globe"!==this.transform.projection.name&&this.handleWrapJump(this.transform.center.lng),this._shadowCasterTiles={},this._coveredTiles={},this.used||this.usedForTerrain){if(this._source.tileID)r=t.getVisibleUnwrappedCoordinates(this._source.tileID).map((t=>new vd(t.canonical.z,t.wrap,t.canonical.z,t.canonical.x,t.canonical.y)));else if(0!==this.tileCoverLift){const n=t.clone();n.tileCoverLift=this.tileCoverLift,r=n.coveringTiles({tileSize:e||this._source.tileSize,minzoom:this._source.minzoom,maxzoom:this._source.maxzoom,roundZoom:this._source.roundZoom&&!i,reparseOverscaled:this._source.reparseOverscaled,isTerrainDEM:this.usedForTerrain}),this._source.minzoomt(e)))}}else r=[];if(r.length>0&&this.castsShadows&&n&&"globe"!==this.transform.projection.name&&!this.usedForTerrain&&!Jy(this._source.type)){const o=t.coveringZoomLevel({tileSize:e||this._source.tileSize,roundZoom:this._source.roundZoom&&!i}),s=Math.min(o,this._source.maxzoom),a=t.extendTileCoverForShadows(r,n,s);for(const t of a)this._shadowCasterTiles[t.key]=!0,r.push(t)}const o=this._updateRetainedTiles(r);if(Jy(this._source.type)&&0!==r.length){const t={},e={},i=Object.keys(o);for(const n of i){const i=o[n],r=this._tiles[n];if(!r||r.fadeEndTime&&r.fadeEndTimen;){r=r.scaledTo(r.overscaledZ-1);const n=this._tiles[r.key];if(n&&n.hasData()&&e[r.key]){o[t]=i.tileID;break}}}for(const e in t)o[e]||(this._coveredTiles[e]=!0,o[e]=t[e])}for(const t in o)this._tiles[t].clearFadeHold();const s=function(t,e){const i=[];for(const n in t)n in e||i.push(n);return i}(this._tiles,o);for(const t of s){const e=this._tiles[t];e.hasSymbolBuckets&&!e.holdingForFade()?e.setHoldDuration(this.map._fadeDuration):e.hasSymbolBuckets&&!e.symbolFadeFinished()||this._removeTile(+t)}this._updateLoadedParentTileCache(),this._onlySymbols&&this._source.afterUpdate&&this._source.afterUpdate()}releaseSymbolFadeTiles(){for(const t in this._tiles)this._tiles[t].holdingForFade()&&this._removeTile(+t)}_updateRetainedTiles(t){const e={};if(0===t.length)return e;const i={},n=t.reduce(((t,e)=>Math.min(t,e.overscaledZ)),1/0),r=t[0].overscaledZ,o=Math.max(r-Xy.maxOverzooming,this._source.minzoom),s=Math.max(r+Xy.maxUnderzooming,this._source.minzoom),a={};for(const i of t){const t=this._addTile(i);e[i.key]=i,t.hasData()||n=this._source.maxzoom){const t=n.children(this._source.maxzoom)[0],i=this.getTile(t);if(i&&i.hasData()){e[t.key]=t;continue}}else{const t=n.children(this._source.maxzoom);if(e[t[0].key]&&e[t[1].key]&&e[t[2].key]&&e[t[3].key])continue}let r=t.wasRequested();for(let s=n.overscaledZ-1;s>=o;--s){const o=n.scaledTo(s);if(i[o.key])break;if(i[o.key]=!0,t=this.getTile(o),!t&&r&&(t=this._addTile(o)),t&&(e[o.key]=o,r=t.wasRequested(),t.hasData()))break}}return e}_updateLoadedParentTileCache(){this._loadedParentTiles={};for(const t in this._tiles){const e=[];let i,n=this._tiles[t].tileID;for(;n.overscaledZ>0;){if(n.key in this._loadedParentTiles){i=this._loadedParentTiles[n.key];break}e.push(n.key);const t=n.scaledTo(n.overscaledZ-1);if(i=this._getLoadedTile(t),i)break;n=t}for(const t of e)this._loadedParentTiles[t]=i}}_addTile(t){let e=this._tiles[t.key];if(e)return!0!==e.isExtraShadowCaster||!!this._shadowCasterTiles[t.key]||this._reloadTile(t.key,"reloading"),e;e=this._cache.getAndRemove(t),e&&(this._setTileReloadTimer(t.key,e),e.tileID=t,this._state.initializeTileState(e,this.map?this.map.painter:null),this._cacheTimers[t.key]&&(clearTimeout(this._cacheTimers[t.key]),delete this._cacheTimers[t.key],this._setTileReloadTimer(t.key,e)));const i=Boolean(e);if(!i){const i=this.map?this.map.painter:null,n=this._source.tileSize*t.overscaleFactor();e="raster-array"===this._source.type?new Wy(t,n,this.transform.tileZoom,i,this._isRaster):new ey(t,n,this.transform.tileZoom,i,this._isRaster),this._loadTile(e,this._tileLoaded.bind(this,e,t.key,e.state))}return e?(e.uses++,this._tiles[t.key]=e,i||this._source.fire(new Pn("dataloading",{tile:e,coord:e.tileID,dataType:"source"})),e):null}_setTileReloadTimer(t,e){t in this._timers&&(clearTimeout(this._timers[t]),delete this._timers[t]);const i=e.getExpiryTimeout();i&&(this._timers[t]=setTimeout((()=>{this._reloadTile(t,"expired"),delete this._timers[t]}),i))}_removeTile(t){const e=this._tiles[t];e&&(e.uses--,delete this._tiles[t],this._timers[t]&&(clearTimeout(this._timers[t]),delete this._timers[t]),e.uses>0||(e.hasData()&&"reloading"!==e.state||"empty"===e.state?this._cache.add(e.tileID,e,e.getExpiryTimeout()):(e.aborted=!0,this._abortTile(e),this._unloadTile(e))))}clearTiles(){this._shouldReloadOnResume=!1,this._paused=!1;for(const t in this._tiles)this._removeTile(+t);this._source._clear&&this._source._clear(),this._cache.reset(),this.map&&this.usedForTerrain&&this.map.painter.terrain&&this.map.painter.terrain.resetTileLookupCache(this.id)}tilesIn(t,e,i){const n=[],r=this.transform;if(!r)return n;const o="globe"===r.projection.name,s=Ed(r.center.lng);for(const a in this._tiles){const l=this._tiles[a];if(i&&l.clearQueryDebugViz(),l.holdingForFade())continue;let c;if(o){const t=l.tileID.canonical;if(0===t.z){const e=[Math.abs(Xe(s,...Qy(t,-1))-s),Math.abs(Xe(s,...Qy(t,1))-s)];c=[0,2*e.indexOf(Math.min(...e))-1]}else{const e=[Math.abs(Xe(s,...Qy(t,-1))-s),Math.abs(Xe(s,...Qy(t,0))-s),Math.abs(Xe(s,...Qy(t,1))-s)];c=[e.indexOf(Math.min(...e))-1]}}else c=[0];for(const i of c){const o=t.containsTile(l,r,e,i);o&&n.push(o)}}return n}getShadowCasterCoordinates(){return this._getRenderableCoordinates(!1,!0)}getVisibleCoordinates(t){return this._getRenderableCoordinates(t)}_getRenderableCoordinates(t,e){const i=this.getRenderableIds(t,e).map((t=>this._tiles[t].tileID)),n="globe"===this.transform.projection.name;for(const t of i)t.projMatrix=this.transform.calculateProjMatrix(t.toUnwrapped()),t.expandedProjMatrix=n?this.transform.calculateProjMatrix(t.toUnwrapped(),!1,!0):t.projMatrix;return i}sortCoordinatesByDistance(t){const e=t.slice(),i=this.transform._camera.position,n=this.transform._camera.forward(),r={};for(const t of e){const e=1/(1r[t.key]-r[e.key])),e}hasTransition(){if(this._source.hasTransition())return!0;if(Jy(this._source.type))for(const t in this._tiles){const e=this._tiles[t];if(void 0!==e.fadeEndTime&&e.fadeEndTime>=ki.now())return!0}return!1}setFeatureState(t,e,i){this._state.updateState(t=t||"_geojsonTileLayer",e,i)}removeFeatureState(t,e,i){this._state.removeFeatureState(t=t||"_geojsonTileLayer",e,i)}getFeatureState(t,e){return this._state.getState(t=t||"_geojsonTileLayer",e)}setDependencies(t,e,i){const n=this._tiles[t];n&&n.setDependencies(e,i)}reloadTilesForDependencies(t,e){for(const i in this._tiles)this._tiles[i].hasDependency(t,e)&&this._reloadTile(+i,"reloading");this._cache.filter((i=>!i.hasDependency(t,e)))}_preloadTiles(t,e){if(!this._sourceLoaded){const i=()=>{this._sourceLoaded&&(this._source.off("data",i),this._preloadTiles(t,e))};return void this._source.on("data",i)}const i=new Map,n=Array.isArray(t)?t:[t],r=this.map.painter.terrain,o=this.usedForTerrain&&r?r.getScaledDemTileSize():this._source.tileSize;for(const t of n){const e=t.coveringTiles({tileSize:o,minzoom:this._source.minzoom,maxzoom:this._source.maxzoom,roundZoom:this._source.roundZoom&&!this.usedForTerrain,reparseOverscaled:this._source.reparseOverscaled,isTerrainDEM:this.usedForTerrain});for(const t of e)i.set(t.key,t);this.usedForTerrain&&t.updateElevation(!1)}Qe(Array.from(i.values()),((t,e)=>{const i=new ey(t,this._source.tileSize*t.overscaleFactor(),this.transform.tileZoom,this.map.painter,this._isRaster);this._loadTile(i,(t=>{"raster-dem"===this._source.type&&i.dem&&this._backfillDEM(i),e(t,i)}))}),e)}}function Ky(t,e){const i=Math.abs(2*t.wrap)-+(t.wrap0?e+2*t:t}tv.useIntegerZoom=!0;const iv=new ol({"symbol-placement":new il(sl.layout_symbol["symbol-placement"]),"symbol-spacing":new il(sl.layout_symbol["symbol-spacing"]),"symbol-avoid-edges":new il(sl.layout_symbol["symbol-avoid-edges"]),"symbol-sort-key":new nl(sl.layout_symbol["symbol-sort-key"]),"symbol-z-order":new il(sl.layout_symbol["symbol-z-order"]),"symbol-z-elevate":new il(sl.layout_symbol["symbol-z-elevate"]),"icon-allow-overlap":new il(sl.layout_symbol["icon-allow-overlap"]),"icon-ignore-placement":new il(sl.layout_symbol["icon-ignore-placement"]),"icon-optional":new il(sl.layout_symbol["icon-optional"]),"icon-rotation-alignment":new il(sl.layout_symbol["icon-rotation-alignment"]),"icon-size":new nl(sl.layout_symbol["icon-size"]),"icon-text-fit":new nl(sl.layout_symbol["icon-text-fit"]),"icon-text-fit-padding":new nl(sl.layout_symbol["icon-text-fit-padding"]),"icon-image":new nl(sl.layout_symbol["icon-image"]),"icon-rotate":new nl(sl.layout_symbol["icon-rotate"]),"icon-padding":new il(sl.layout_symbol["icon-padding"]),"icon-keep-upright":new il(sl.layout_symbol["icon-keep-upright"]),"icon-offset":new nl(sl.layout_symbol["icon-offset"]),"icon-anchor":new nl(sl.layout_symbol["icon-anchor"]),"icon-pitch-alignment":new il(sl.layout_symbol["icon-pitch-alignment"]),"text-pitch-alignment":new il(sl.layout_symbol["text-pitch-alignment"]),"text-rotation-alignment":new il(sl.layout_symbol["text-rotation-alignment"]),"text-field":new nl(sl.layout_symbol["text-field"]),"text-font":new nl(sl.layout_symbol["text-font"]),"text-size":new nl(sl.layout_symbol["text-size"]),"text-max-width":new nl(sl.layout_symbol["text-max-width"]),"text-line-height":new nl(sl.layout_symbol["text-line-height"]),"text-letter-spacing":new nl(sl.layout_symbol["text-letter-spacing"]),"text-justify":new nl(sl.layout_symbol["text-justify"]),"text-radial-offset":new nl(sl.layout_symbol["text-radial-offset"]),"text-variable-anchor":new il(sl.layout_symbol["text-variable-anchor"]),"text-anchor":new nl(sl.layout_symbol["text-anchor"]),"text-max-angle":new il(sl.layout_symbol["text-max-angle"]),"text-writing-mode":new il(sl.layout_symbol["text-writing-mode"]),"text-rotate":new nl(sl.layout_symbol["text-rotate"]),"text-padding":new il(sl.layout_symbol["text-padding"]),"text-keep-upright":new il(sl.layout_symbol["text-keep-upright"]),"text-transform":new nl(sl.layout_symbol["text-transform"]),"text-offset":new nl(sl.layout_symbol["text-offset"]),"text-allow-overlap":new il(sl.layout_symbol["text-allow-overlap"]),"text-ignore-placement":new il(sl.layout_symbol["text-ignore-placement"]),"text-optional":new il(sl.layout_symbol["text-optional"]),visibility:new il(sl.layout_symbol.visibility)});var nv={paint:new ol({"icon-opacity":new nl(sl.paint_symbol["icon-opacity"]),"icon-occlusion-opacity":new nl(sl.paint_symbol["icon-occlusion-opacity"]),"icon-emissive-strength":new nl(sl.paint_symbol["icon-emissive-strength"]),"text-emissive-strength":new nl(sl.paint_symbol["text-emissive-strength"]),"icon-color":new nl(sl.paint_symbol["icon-color"]),"icon-halo-color":new nl(sl.paint_symbol["icon-halo-color"]),"icon-halo-width":new nl(sl.paint_symbol["icon-halo-width"]),"icon-halo-blur":new nl(sl.paint_symbol["icon-halo-blur"]),"icon-translate":new il(sl.paint_symbol["icon-translate"]),"icon-translate-anchor":new il(sl.paint_symbol["icon-translate-anchor"]),"icon-image-cross-fade":new nl(sl.paint_symbol["icon-image-cross-fade"]),"text-opacity":new nl(sl.paint_symbol["text-opacity"]),"text-occlusion-opacity":new nl(sl.paint_symbol["text-occlusion-opacity"]),"text-color":new nl(sl.paint_symbol["text-color"],{runtimeType:Qn,getOverride:t=>t.textColor,hasOverride:t=>!!t.textColor}),"text-halo-color":new nl(sl.paint_symbol["text-halo-color"]),"text-halo-width":new nl(sl.paint_symbol["text-halo-width"]),"text-halo-blur":new nl(sl.paint_symbol["text-halo-blur"]),"text-translate":new il(sl.paint_symbol["text-translate"]),"text-translate-anchor":new il(sl.paint_symbol["text-translate-anchor"]),"icon-color-saturation":new il(sl.paint_symbol["icon-color-saturation"]),"icon-color-contrast":new il(sl.paint_symbol["icon-color-contrast"]),"icon-color-brightness-min":new il(sl.paint_symbol["icon-color-brightness-min"]),"icon-color-brightness-max":new il(sl.paint_symbol["icon-color-brightness-max"])}),layout:iv};class rv{constructor(t){this.type=t.property.overrides?t.property.overrides.runtimeType:Yn,this.defaultValue=t}evaluate(t){if(t.formattedSection){const e=this.defaultValue.property.overrides;if(e&&e.hasOverride(t.formattedSection))return e.getOverride(t.formattedSection)}return t.feature&&t.featureState?this.defaultValue.evaluate(t.feature,t.featureState):this.defaultValue.property.specification.default}eachChild(t){this.defaultValue.isConstant()||t(this.defaultValue.value._styleExpression.expression)}outputDefined(){return!1}serialize(){return null}}ba(rv,"FormatSectionOverride",{omit:["defaultValue"]});class ov extends Ml{constructor(e,i,n,r){super(e,nv,i,n,r),this._colorAdjustmentMatrix=t.ad.identity([]),this.hasInitialOcclusionOpacityProperties=void 0!==e.paint&&("icon-occlusion-opacity"in e.paint||"text-occlusion-opacity"in e.paint)}recalculate(t,e){super.recalculate(t,e),"auto"===this.layout.get("icon-rotation-alignment")&&(this.layout._values["icon-rotation-alignment"]="point"!==this.layout.get("symbol-placement")?"map":"viewport"),"auto"===this.layout.get("text-rotation-alignment")&&(this.layout._values["text-rotation-alignment"]="point"!==this.layout.get("symbol-placement")?"map":"viewport"),"auto"===this.layout.get("text-pitch-alignment")&&(this.layout._values["text-pitch-alignment"]=this.layout.get("text-rotation-alignment")),"auto"===this.layout.get("icon-pitch-alignment")&&(this.layout._values["icon-pitch-alignment"]=this.layout.get("icon-rotation-alignment"));const i=this.layout.get("text-writing-mode");if(i){const t=[];for(const e of i)t.indexOf(e)i in t?String(t[i]):""))}(e.properties,r)}createBucket(t){return new jg(t)}queryRadius(){return 0}queryIntersectsFeature(){return!1}_setPaintOverrides(){for(const t of nv.paint.overridableProperties){if(!ov.hasPaintOverride(this.layout,t))continue;const e=this.paint.get(t),i=new rv(e),n=new la(i,e.property.specification,this.scope,this.options);let r=null;r="constant"===e.value.kind||"source"===e.value.kind?new ua("source",n):new ha("composite",n,e.value.zoomStops,e.value._interpolationType),this.paint._values[t]=new tl(e.property,r,e.parameters)}}_handleOverridablePaintPropertyUpdate(t,e,i){return!(!this.layout||e.isDataDriven()||i.isDataDriven())&&ov.hasPaintOverride(this.layout,t)}static hasPaintOverride(t,e){const i=t.get("text-field"),n=nv.paint.properties[e];let r=!1;const o=t=>{for(const e of t)if(n.overrides&&n.overrides.hasOverride(e))return void(r=!0)};if("constant"===i.value.kind&&i.value.value instanceof pr)o(i.value.value.sections);else if("source"===i.value.kind){const t=e=>{r||(e instanceof vr&&gr(e.value)===nr?o(e.value.sections):e instanceof Tr?o(e.sections):e.eachChild(t))},e=i.value;e._styleExpression&&t(e._styleExpression.expression)}return r}getProgramIds(){const t=0!==this.paint.get("icon-opacity").constantOr(1),e=0!==this.paint.get("text-opacity").constantOr(1),i=[];return t&&i.push("symbolIcon"),e&&i.push("symbolSDF"),i}getDefaultProgramParams(t,e,i){return{config:new Wc(this,{zoom:e,lut:i}),overrideFog:!1}}}const sv=new ol({visibility:new il(sl.layout_background.visibility)});var av={paint:new ol({"background-color":new il(sl.paint_background["background-color"]),"background-pattern":new il(sl.paint_background["background-pattern"]),"background-opacity":new il(sl.paint_background["background-opacity"]),"background-emissive-strength":new il(sl.paint_background["background-emissive-strength"])}),layout:sv};const lv=new ol({visibility:new il(sl.layout_raster.visibility)});var cv={paint:new ol({"raster-opacity":new il(sl.paint_raster["raster-opacity"]),"raster-color":new rl(sl.paint_raster["raster-color"]),"raster-color-mix":new il(sl.paint_raster["raster-color-mix"]),"raster-color-range":new il(sl.paint_raster["raster-color-range"]),"raster-hue-rotate":new il(sl.paint_raster["raster-hue-rotate"]),"raster-brightness-min":new il(sl.paint_raster["raster-brightness-min"]),"raster-brightness-max":new il(sl.paint_raster["raster-brightness-max"]),"raster-saturation":new il(sl.paint_raster["raster-saturation"]),"raster-contrast":new il(sl.paint_raster["raster-contrast"]),"raster-resampling":new il(sl.paint_raster["raster-resampling"]),"raster-fade-duration":new il(sl.paint_raster["raster-fade-duration"]),"raster-emissive-strength":new il(sl.paint_raster["raster-emissive-strength"]),"raster-array-band":new il(sl.paint_raster["raster-array-band"]),"raster-elevation":new il(sl.paint_raster["raster-elevation"])}),layout:lv};function dv(e,i,n,r,o,s,a,l){const c=[e,i,1,n,r,1,o,s,1],d=[a,l,1],u=t.bC.adjoint([],c),[h,p,f]=t._.transformMat3(d,d,u);return t.bC.multiply(c,c,[h,0,0,0,p,0,0,0,f])}function uv(e,i,n,r,o,s,a,l){const c=function(e,i,n,r,o,s,a,l){const c=dv(0,0,1,0,1,1,0,1),d=dv(e,i,n,r,o,s,a,l),u=t.bC.adjoint([],c);return t.bC.multiply(d,d,u)}(e,i,n,r,o,s,a,l);return[c[2]/c[8]/uo,c[5]/c[8]/uo]}function hv(t){return[t[0],Math.min(Math.max(t[1],-Pd),Pd)]}class pv extends zn{constructor(t,e,i,n){super(),this.id=t,this.dispatcher=i,this.coordinates=e.coordinates,this.type="image",this.minzoom=0,this.maxzoom=22,this.tileSize=512,this.tiles={},this._loaded=!1,this.onNorthPole=!1,this.onSouthPole=!1,this.setEventedParent(n),this.options=e,this._dirty=!1}load(t,e){if(this._loaded=e||!1,this.fire(new Pn("dataloading",{dataType:"source"})),this.url=this.options.url,!this.url)return t&&(this.coordinates=t),this._loaded=!0,void this._finishLoading();this._imageRequest=an(this.map._requestManager.transformRequest(this.url,Ki.Image),((e,i)=>{this._imageRequest=null,this._loaded=!0,e?this.fire(new $n(e)):i&&(this.image=i instanceof HTMLImageElement?ki.getImageData(i):i,this._dirty=!0,this.width=this.image.width,this.height=this.image.height,t&&(this.coordinates=t),this._finishLoading())}))}loaded(){return this._loaded}updateImage(t){return t.url?(this._imageRequest&&t.url!==this.options.url&&(this._imageRequest.cancel(),this._imageRequest=null),this.options.url=t.url,this.load(t.coordinates,this._loaded),this):this}setTexture(t){if(!(t.handle instanceof WebGLTexture))throw new Error("The provided handle is not a WebGLTexture instance");return this.texture=new Gg(this.map.painter.context,t.handle),this.width=t.dimensions[0],this.height=t.dimensions[1],this._dirty=!1,this._loaded=!0,this._finishLoading(),this}_finishLoading(){this.map&&(this.setCoordinates(this.coordinates),this.fire(new Pn("data",{dataType:"source",sourceDataType:"metadata"})))}onAdd(t){this.map=t,this.load()}onRemove(t){this._imageRequest&&(this._imageRequest.cancel(),this._imageRequest=null),!this.texture||this.texture instanceof Gg||this.texture.destroy(),this.boundsBuffer&&(this.boundsBuffer.destroy(),this.elevatedGlobeVertexBuffer&&this.elevatedGlobeVertexBuffer.destroy(),this.elevatedGlobeIndexBuffer&&this.elevatedGlobeIndexBuffer.destroy())}setCoordinates(t){if(this.coordinates=t,this._boundsArray=void 0,this._unsupportedCoords=!1,!t.length)return this;this.onNorthPole=!1,this.onSouthPole=!1;let e=t[0][1],i=t[0][1];for(const n of t)n[1]>i&&(i=n[1]),n[1]Pd?this.onNorthPole=!0:n1&&(l-=1),new gd(s,l,Math.floor((i+r)/2*a))}(e),this.minzoom=this.maxzoom=this.tileID.z}return this.fire(new Pn("data",{dataType:"source",sourceDataType:"content"})),this}_clear(){this._boundsArray=void 0,this._unsupportedCoords=!1}_prepareData(e){for(const t in this.tiles){const e=this.tiles[t];"loaded"!==e.state&&(e.state="loaded",e.texture=this.texture)}if(this._boundsArray||this.onNorthPole||this.onSouthPole||this._unsupportedCoords)return;const i=eg(new gd(0,0,0),this.map.transform.projection),n=[i.projection.project(this.coordinates[0][0],this.coordinates[0][1]),i.projection.project(this.coordinates[1][0],this.coordinates[1][1]),i.projection.project(this.coordinates[2][0],this.coordinates[2][1]),i.projection.project(this.coordinates[3][0],this.coordinates[3][1])];if(!function(t){const e=t[1].x-t[0].x,i=t[1].y-t[0].y,n=t[2].x-t[1].x,r=t[2].y-t[1].y,o=t[3].x-t[2].x,s=t[3].y-t[2].y,a=t[0].x-t[3].x,l=t[0].y-t[3].y,c=e*r-n*i,d=n*s-o*r,u=o*l-a*s,h=a*i-e*l;return c>0&&d>0&&u>0&&h>0||c{const e=r.projection.project(t[0],t[1]);return ig(r,e)._round()}));this.perspectiveTransform=uv(o.x,o.y,s.x,s.y,a.x,a.y,l.x,l.y);const c=this._boundsArray=new Dl;c.emplaceBack(o.x,o.y,0,0),c.emplaceBack(s.x,s.y,uo,0),c.emplaceBack(l.x,l.y,0,uo),c.emplaceBack(a.x,a.y,uo,uo),this.boundsBuffer&&(this.boundsBuffer.destroy(),this.elevatedGlobeVertexBuffer&&this.elevatedGlobeVertexBuffer.destroy(),this.elevatedGlobeIndexBuffer&&this.elevatedGlobeIndexBuffer.destroy()),this.boundsBuffer=e.createVertexBuffer(c,Jg.members),this.boundsSegments=wc.simpleSegment(0,0,4,2);const d=[],u=function(t){return[hv(t[0]),hv(t[1]),hv(t[2]),hv(t[3])]}(this.coordinates),[h,p,f,m]=function(t){let e=t[0][0],i=e,n=t[0][1],r=n;for(let o=1;oi&&(i=t[o][0]),t[o][1]r&&(r=t[o][1]);return[e,n,i-e,r-n]}(u);{const r=new Dl,[o,s,a,l]=function(t){let e=t[0].x,i=e,n=t[0].y,r=n;for(let o=1;oi&&(i=t[o].x),t[o].yr&&(r=t[o].y);return[e,n,i-e,r-n]}(n),c=t=>[(t.x-o)/a,(t.y-s)/l],[u,_,g,y]=n.map(c),v=function(e,i,n,r,o,s,a,l){const c=dv(0,0,1,0,1,1,0,1),d=dv(e,i,n,r,o,s,a,l),u=t.bC.adjoint([],d);return t.bC.multiply(c,c,u)}(u[0],u[1],_[0],_[1],g[0],g[1],y[0],y[1]);this.elevatedGlobePerspectiveTransform=uv(u[0],u[1],_[0],_[1],g[0],g[1],y[0],y[1]);const x=(e,i)=>{d.push(e.lng);const n=Math.round((e.lng-h)/f*uo),o=Math.round((e.lat-p)/m*uo),s=c(i),a=t._.transformMat3([],[s[0],s[1],1],v),l=Math.round(a[0]/a[2]*uo),u=Math.round(a[1]/a[2]*uo);r.emplaceBack(n,o,l,u)},b=n[3].x-n[0].x,w=n[3].y-n[0].y,T=n[2].x-n[1].x,S=n[2].y-n[1].y;for(let t=0;t{i.emplaceBack(e,n,r);const o=d[e],s=d[n],a=d[r],l=Math.min(Math.min(o,s),a),c=Math.max(Math.max(o,s),a)-l;c>this.maxLongitudeTriangleSize&&(this.maxLongitudeTriangleSize=c),t.push(l+c/2)};for(let t=0;te));i.sort(((e,i)=>t[e]-t[i]));const n=[],r=new Kl;for(let o=0;o{o.segments.push({vertexOffset:0,primitiveOffset:t,vertexLength:e.segments[0].vertexLength,primitiveLength:i,sortKey:void 0,vaos:{}})},a=.51*this.maxLongitudeTriangleSize;if(Math.abs(i[0]-n)0){const n=function(e,i){const n=i.worldSize,r=Cd(1,0)*n*kd(i.center.lat,i.zoom)/Gu(n),o=Cd(1,i.center.lat)*n,s=t.ad.identity([]);return t.ad.rotateY(s,s,Ge(i.center.lng)),t.ad.rotateX(s,s,Ge(i.center.lat)),t.ad.translate(s,s,[0,0,ed]),t.ad.scale(s,s,[r,r,r*o]),t.ad.translate(s,s,[i.point.x-.5*n,i.point.y-.5*n,0]),t.ad.multiply(s,s,e),t.ad.multiply(s,i.globeMatrix,s)}(e,i);return function(e,i,n){const r=(e,i,n)=>{const r=t._.length(e),o=t._.length(i),s=ku(e,i,n);return t._.scale(s,s,1/t._.length(s)*Vn(r,o,n))},o=r([e[0],e[1],e[2]],[i[0],i[1],i[2]],n),s=r([e[4],e[5],e[6]],[i[4],i[5],i[6]],n),a=r([e[8],e[9],e[10]],[i[8],i[9],i[10]],n),l=ku([e[12],e[13],e[14]],[i[12],i[13],i[14]],n);return[o[0],o[1],o[2],0,s[0],s[1],s[2],0,a[0],a[1],a[2],0,l[0],l[1],l[2],1]}(o,n,r)}return o}function kv(t,e,i,n){const r=wu.projectAabbCorners(n,i);let o=Number.MAX_VALUE,s=-1;for(let t=0;tnew Ue(r[t][0],r[t][1]);let l;switch(s){case 0:case 6:l=[a(1),a(5),a(4),a(7),a(3),a(2),a(1)];break;case 1:case 7:l=[a(0),a(4),a(5),a(6),a(2),a(3),a(0)];break;case 3:case 5:l=[a(1),a(0),a(4),a(7),a(6),a(2),a(1)];break;default:l=[a(1),a(5),a(6),a(7),a(3),a(0),a(1)]}if(Yd(t,l))return o}const Dv=Ll([{name:"a_pos_3f",components:3,type:"Float32"}]),zv=Ll([{name:"a_color_3f",components:3,type:"Float32"}]),Rv=Ll([{name:"a_color_4f",components:4,type:"Float32"}]),Ov=Ll([{name:"a_uv_2f",components:2,type:"Float32"}]),Bv=Ll([{name:"a_normal_3f",components:3,type:"Float32"}]),Fv=Ll([{name:"a_normal_matrix0",components:4,type:"Float32"},{name:"a_normal_matrix1",components:4,type:"Float32"},{name:"a_normal_matrix2",components:4,type:"Float32"},{name:"a_normal_matrix3",components:4,type:"Float32"}]),Nv=Ll([{name:"a_pbr",components:4,type:"Uint16"},{name:"a_heightBasedEmissiveStrength",components:3,type:"Float32"}]);class Uv{constructor(t,e,i,n){this.message=(t?`${t}: `:"")+i,n&&(this.identifier=n),null!=e&&e.__line__&&(this.line=e.__line__)}}function jv(t,e){const i=-1===t.indexOf("://");try{return new URL(t,i&&e?"http://example.com":void 0),!0}catch(t){return!1}}class Vv{constructor(t,e){this.feature=t,this.instancedDataOffset=e,this.instancedDataCount=0,this.rotation=[0,0,0],this.scale=[1,1,1],this.translation=[0,0,0]}}class Gv{constructor(){this.instancedDataArray=new oc,this.instancesEvaluatedElevation=[],this.features=[],this.idToFeaturesIndex={}}}class Zv{constructor(t){this.zoom=t.zoom,this.canonical=t.canonical,this.layers=t.layers,this.layerIds=this.layers.map((t=>t.fqid)),this.projection=t.projection,this.index=t.index,this.hasZoomDependentProperties=this.layers[0].isZoomDependent(),this.stateDependentLayerIds=this.layers.filter((t=>t.isStateDependent())).map((t=>t.id)),this.hasPattern=!1,this.instancesPerModel={},this.validForExaggeration=0,this.maxVerticalOffset=0,this.maxScale=0,this.maxHeight=0,this.lookupDim=this.zoom>this.canonical.z?256:this.zoom>15?75:100,this.instanceCount=0,this.terrainElevationMin=0,this.terrainElevationMax=0,this.validForDEMTile={id:null,timestamp:0},this.modelUris=[],this.modelsRequested=!1,this.activeReplacements=[],this.replacementUpdateTime=0}updateFootprints(t,e){}populate(t,e,i,n){this.tileToMeter=zd(i);const r=this.layers[0]._featureFilter.needGeometry;this.lookup=new Uint8Array(this.lookupDim*this.lookupDim);for(const{feature:o,id:s,index:a,sourceLayerIndex:l}of t){const t=null!=s?s:o.properties&&o.properties.hasOwnProperty("id")?o.properties.id:void 0,c=Zd(o,r);if(!this.layers[0]._featureFilter.filter(new Ha(this.zoom),c,i))continue;const d={id:t,sourceLayerIndex:l,index:a,geometry:r?c.geometry:Gd(o,i,n),properties:o.properties,type:o.type,patterns:{}},u=this.addFeature(d,d.geometry,c);u&&e.featureIndex.insert(o,d.geometry,a,l,this.index,this.instancesPerModel[u].instancedDataArray.length,uo/32)}this.lookup=null}update(t,e,i,n){for(const e in this.instancesPerModel){const i=this.instancesPerModel[e];for(const e in t)i.idToFeaturesIndex.hasOwnProperty(e)&&(this.evaluate(i.features[i.idToFeaturesIndex[e]],t[e],i,!0),this.uploaded=!1)}this.maxHeight=0}updateZoomBasedPaintProperties(){if(!this.hasZoomDependentProperties)return!1;let e=!1;for(const i in this.instancesPerModel){const n=this.instancesPerModel[i];for(const i of n.features){const r=this.layers[0],o=i.feature,s=this.canonical,a=r.paint.get("model-rotation").evaluate(o,{},s),l=r.paint.get("model-scale").evaluate(o,{},s),c=r.paint.get("model-translation").evaluate(o,{},s);t._.exactEquals(i.rotation,a)&&t._.exactEquals(i.scale,l)&&t._.exactEquals(i.translation,c)||(this.evaluate(i,i.featureStates,n,!0),e=!0)}}return e}updateReplacement(t,e,i){if(e.updateTime===this.replacementUpdateTime)return!1;this.replacementUpdateTime=e.updateTime;const n=e.getReplacementRegionsForTile(t.toUnwrapped(),!0);if(Pp(this.activeReplacements,n))return!1;this.activeReplacements=n;let r=!1;for(const e in this.instancesPerModel){const n=this.instancesPerModel[e],o=n.instancedDataArray;for(const e of n.features){const n=e.instancedDataOffset,s=e.instancedDataCount;for(let e=0;euo?a-uo:a;const l=Math.floor(a),c=o.float32[s+1];let d=!1;for(const e of this.activeReplacements)if(!(e.orderl||l>e.max.x||e.min.y>c||c>e.max.y)&&(d=Op(Rp(l,c,t.canonical,e.footprintTileId.canonical),e),d))break;o.float32[s]=d?a+uo:a,r=r||d}}}return r}isEmpty(){for(const t in this.instancesPerModel)if(0!==this.instancesPerModel[t].instancedDataArray.length)return!1;return!0}uploadPending(){return!this.uploaded}upload(t){if(!this.uploaded)for(const e in this.instancesPerModel){const i=this.instancesPerModel[e];i.instancedDataArray.length=uo||e.y=uo)continue;const t=(this.lookupDim-1)/uo,i=this.lookupDim*(e.y*t|0)+e.x*t|0;if(this.lookup){if(0!==this.lookup[i])continue;this.lookup[i]=1}this.instanceCount++;const n=s.length;s.resize(n+1),o.instancesEvaluatedElevation.push(0),s.float32[16*n]=e.x,s.float32[16*n+1]=e.y}return a.instancedDataCount=o.instancedDataArray.length-a.instancedDataOffset,a.instancedDataCount>0&&(t.id&&(o.idToFeaturesIndex[t.id]=o.features.length),o.features.push(a),this.evaluate(a,{},o,!1)),r}getModelUris(){return this.modelUris}evaluate(t,e,i,n){const r=this.layers[0],o=t.feature,s=this.canonical,a=t.rotation=r.paint.get("model-rotation").evaluate(o,e,s),l=t.scale=r.paint.get("model-scale").evaluate(o,e,s),c=t.translation=r.paint.get("model-translation").evaluate(o,e,s),d=r.paint.get("model-color").evaluate(o,e,s);d.a=r.paint.get("model-color-mix-intensity").evaluate(o,e,s);const u=[];this.maxVerticalOffset10?this.tileToMeter:zd(s,p)),a[o+4]=c[0],a[o+5]=c[1],a[o+6]=c[2]+l,a[o+7]=u[0],a[o+8]=u[1],a[o+9]=u[2],a[o+10]=u[4],a[o+11]=u[5],a[o+12]=u[6],a[o+13]=u[8],a[o+14]=u[9],a[o+15]=u[10],i.instancesEvaluatedElevation[r]=c[2]}}}ba(Zv,"ModelBucket",{omit:["layers"]}),ba(Gv,"PerModelAttributes"),ba(Vv,"ModelFeature");const qv=new ol({visibility:new il(sl.layout_model.visibility),"model-id":new nl(sl.layout_model["model-id"])});var Hv={paint:new ol({"model-opacity":new il(sl.paint_model["model-opacity"]),"model-rotation":new nl(sl.paint_model["model-rotation"]),"model-scale":new nl(sl.paint_model["model-scale"]),"model-translation":new nl(sl.paint_model["model-translation"]),"model-color":new nl(sl.paint_model["model-color"]),"model-color-mix-intensity":new nl(sl.paint_model["model-color-mix-intensity"]),"model-type":new il(sl.paint_model["model-type"]),"model-cast-shadows":new il(sl.paint_model["model-cast-shadows"]),"model-receive-shadows":new il(sl.paint_model["model-receive-shadows"]),"model-ambient-occlusion-intensity":new il(sl.paint_model["model-ambient-occlusion-intensity"]),"model-emissive-strength":new nl(sl.paint_model["model-emissive-strength"]),"model-roughness":new nl(sl.paint_model["model-roughness"]),"model-height-based-emissive-strength-multiplier":new nl(sl.paint_model["model-height-based-emissive-strength-multiplier"]),"model-cutoff-fade-range":new il(sl.paint_model["model-cutoff-fade-range"]),"model-front-cutoff":new il(sl.paint_model["model-front-cutoff"])}),layout:qv};const Wv=64,Yv={CoordinateSpaceTile:1,CoordinateSpaceYUp:2,HasMapboxMeshFeatures:4,HasMeshoptCompression:8};function Xv(e,i,n,r,o,s,a,l,c,d=!1){const u=n.zoom,h=n.project(r),p=kd(r.lat,u),f=1/p;t.ad.identity(e),t.ad.translate(e,e,[h.x+a[0]*f,h.y+a[1]*f,a[2]]);let m=1,_=1;const g=n.worldSize;if(d){if("mercator"===n.projection.name){let e=0;n.elevation&&(e=n.elevation.getAtPointOrZero(new Rd(h.x/g,h.y/g),0));const i=t.aA.transformMat4([],[h.x,h.y,e,1],n.projMatrix)[3]/n.cameraToCenterDistance;m=i,_=i*kd(n.center.lat,u)}else if("globe"===n.projection.name){const i=$v(e,n),o=t.ad.multiply([],n.projMatrix,i),s=[0,0,0,1];t.aA.transformMat4(s,s,o);const a=s[3]/n.cameraToCenterDistance,l=Hu(u),c=n.projection.pixelsPerMeter(r.lat,g)*kd(r.lat,u),d=n.projection.pixelsPerMeter(n.center.lat,g)*kd(n.center.lat,u);m=a/Vn(c,$d(n.center.lat),l),_=a*p/c,m*=d,_*=d}}else m=f;t.ad.scale(e,e,[m,m,_]);const y=[...e],v=i.orientation,x=[];if(Lv(x,[v[0]+o[0],v[1]+o[1],v[2]+o[2]],s),t.ad.multiply(e,y,x),l&&n.elevation){let o=0;const s=[];if(c&&n.elevation){o=function(e,i,n,r,o){const s=i.elevation;if(!s)return 0;const a=wu.projectAabbCorners(n,r),l=Cd(1,o.lat)*i.worldSize,c=function(e,i){const n=[0,0,1],r=[{corners:[0,1,3,2],dotProductWithUp:0},{corners:[1,5,2,6],dotProductWithUp:0},{corners:[0,4,1,5],dotProductWithUp:0},{corners:[2,6,3,7],dotProductWithUp:0},{corners:[4,7,5,6],dotProductWithUp:0},{corners:[0,3,4,7],dotProductWithUp:0}];for(const o of r){const r=e[o.corners[0]],s=e[o.corners[1]],a=e[o.corners[2]],l=[s[0]-r[0],s[1]-r[1],i*(s[2]-r[2])],c=t._.cross(l,l,[a[0]-r[0],a[1]-r[1],i*(a[2]-r[2])]);t._.normalize(c,c),o.dotProductWithUp=t._.dot(c,n)}return r.sort(((t,e)=>t.dotProductWithUp-e.dotProductWithUp)),r[0].corners}(a,l),d=a[c[0]],u=a[c[1]],h=a[c[2]],p=a[c[3]],f=s.getAtPointOrZero(new Rd(d[0]/i.worldSize,d[1]/i.worldSize),0),m=s.getAtPointOrZero(new Rd(u[0]/i.worldSize,u[1]/i.worldSize),0),_=s.getAtPointOrZero(new Rd(h[0]/i.worldSize,h[1]/i.worldSize),0),g=s.getAtPointOrZero(new Rd(p[0]/i.worldSize,p[1]/i.worldSize),0),y=(f+g)/2,v=(m+_)/2;return y>v?m=e.gl.NEAREST_MIPMAP_NEAREST}),t.uploaded=!0,t.image=null)}function Jv(t,e,i){t.indexBuffer=e.createIndexBuffer(t.indexArray,!1,!0),t.vertexBuffer=e.createVertexBuffer(t.vertexArray,Dv.members,!1,!0),t.normalArray&&(t.normalBuffer=e.createVertexBuffer(t.normalArray,Bv.members,!1,!0)),t.texcoordArray&&(t.texcoordBuffer=e.createVertexBuffer(t.texcoordArray,Ov.members,!1,!0)),t.colorArray&&(t.colorBuffer=e.createVertexBuffer(t.colorArray,(12===t.colorArray.bytesPerElement?zv:Rv).members,!1,!0)),t.featureArray&&(t.pbrBuffer=e.createVertexBuffer(t.featureArray,Nv.members,!0)),t.segments=wc.simpleSegment(0,0,t.vertexArray.length,t.indexArray.length);const n=t.material;n.pbrMetallicRoughness.baseColorTexture&&Kv(n.pbrMetallicRoughness.baseColorTexture,e),n.pbrMetallicRoughness.metallicRoughnessTexture&&Kv(n.pbrMetallicRoughness.metallicRoughnessTexture,e),n.normalTexture&&Kv(n.normalTexture,e),n.occlusionTexture&&Kv(n.occlusionTexture,e,i),n.emissionTexture&&Kv(n.emissionTexture,e)}function Qv(t,e,i){if(t.meshes)for(const n of t.meshes)Jv(n,e,i);if(t.children)for(const n of t.children)Qv(n,e,i)}function tx(t){if(t.meshes)for(const e of t.meshes)e.indexArray.destroy(),e.vertexArray.destroy(),e.colorArray&&e.colorArray.destroy(),e.normalArray&&e.normalArray.destroy(),e.texcoordArray&&e.texcoordArray.destroy(),e.featureArray&&e.featureArray.destroy();if(t.children)for(const e of t.children)tx(e)}function ex(t){if(t.meshes)for(const i of t.meshes)i.vertexBuffer&&(i.vertexBuffer.destroy(),i.indexBuffer.destroy(),i.normalBuffer&&i.normalBuffer.destroy(),i.texcoordBuffer&&i.texcoordBuffer.destroy(),i.colorBuffer&&i.colorBuffer.destroy(),i.pbrBuffer&&i.pbrBuffer.destroy(),i.segments.destroy(),i.material&&((e=i.material).pbrMetallicRoughness.baseColorTexture&&e.pbrMetallicRoughness.baseColorTexture.gfxTexture&&e.pbrMetallicRoughness.baseColorTexture.gfxTexture.destroy(),e.pbrMetallicRoughness.metallicRoughnessTexture&&e.pbrMetallicRoughness.metallicRoughnessTexture.gfxTexture&&e.pbrMetallicRoughness.metallicRoughnessTexture.gfxTexture.destroy(),e.normalTexture&&e.normalTexture.gfxTexture&&e.normalTexture.gfxTexture.destroy(),e.emissionTexture&&e.emissionTexture.gfxTexture&&e.emissionTexture.gfxTexture.destroy(),e.occlusionTexture&&e.occlusionTexture.gfxTexture&&e.occlusionTexture.gfxTexture.destroy()));var e;if(t.children)for(const e of t.children)ex(e)}class ix{constructor(t){this._callback=t,this._triggered=!1,"undefined"!=typeof MessageChannel&&(this._channel=new MessageChannel,this._channel.port2.onmessage=()=>{this._triggered=!1,this._callback()})}trigger(){this._triggered||(this._triggered=!0,this._channel?this._channel.port1.postMessage(!0):setTimeout((()=>{this._triggered=!1,this._callback()}),0))}remove(){this._channel=void 0,this._callback=()=>{}}}class nx{constructor(){this.tasks={},this.taskQueue=[],ai(["process"],this),this.invoker=new ix(this.process),this.nextId=0}add(t,e){const i=this.nextId++,n=function({type:t,isSymbolTile:e,zoom:i}){return i=i||0,"message"===t?0:"maybePrepare"!==t||e?"parseTile"!==t||e?"parseTile"===t&&e?300-i:"maybePrepare"===t&&e?400-i:500:200-i:100-i}(e);if(0===n){try{t()}finally{}return null}return this.tasks[i]={fn:t,metadata:e,priority:n,id:i},this.taskQueue.push(i),this.invoker.trigger(),{cancel:()=>{delete this.tasks[i]}}}process(){try{if(this.taskQueue=this.taskQueue.filter((t=>!!this.tasks[t])),!this.taskQueue.length)return;const t=this.pick();if(null===t)return;const e=this.tasks[t];if(delete this.tasks[t],this.taskQueue.length&&this.invoker.trigger(),!e)return;e.fn()}finally{}}pick(){let t=null,e=1/0;for(let i=0;i{i&&delete this.callbacks[s],this.target.postMessage({id:s,type:"",targetMapId:n,sourceMapId:this.mapId})}}}receive(t){const e=t.data,i=e.id;if(i&&(!e.targetMapId||this.mapId===e.targetMapId))if(""===e.type){const t=this.cancelCallbacks[i];delete this.cancelCallbacks[i],t&&t.cancel()}else if(e.mustQueue||gi()){const t=this.callbacks[i],n=this.scheduler.add((()=>this.processTask(i,e)),t&&t.metadata||{type:"message"});n&&(this.cancelCallbacks[i]=n)}else this.processTask(i,e)}processTask(t,e){if(delete this.cancelCallbacks[t],""===e.type){const i=this.callbacks[t];delete this.callbacks[t],i&&(e.error?i(Ea(e.error)):i(null,Ea(e.data)))}else{const i=new Set,n=e.hasCallback?(e,n)=>{this.target.postMessage({id:t,type:"",sourceMapId:this.mapId,error:e?Sa(e):null,data:Sa(n,i)},i)}:t=>{},r=Ea(e.data);if(this.parent[e.type])this.parent[e.type](e.sourceMapId,r,n);else if(this.parent.getWorkerSource){const t=e.type.split(".");this.parent.getWorkerSource(e.sourceMapId,t[0],r.source,r.scope)[t[1]](r,n)}else n(new Error(`Could not find function ${e.type}`))}}remove(){this.scheduler.remove(),this.target.removeEventListener("message",this.receive,!1)}}class ox{constructor(t,e){this.workerPool=t,this.actors=[],this.currentActor=0,this.id=ni();const i=this.workerPool.acquire(this.id);for(let t=0;t{this.ready=!0}))}broadcast(t,e,i){Qe(this.actors,((i,n)=>{i.send(t,e,n)}),i=i||function(){})}getActor(){return this.currentActor=(this.currentActor+1)%this.actors.length,this.actors[this.currentActor]}remove(){this.actors.forEach((t=>{t.remove()})),this.actors=[],this.workerPool.release(this.id)}}ox.Actor=rx;var sx={workerUrl:"",workerClass:null,workerParams:void 0};function ax(){return null!=sx.workerClass?new sx.workerClass:new self.Worker(sx.workerUrl,sx.workerParams)}const lx="mapboxgl_preloaded_worker_pool";class cx{constructor(){this.active={}}acquire(t){if(!this.workers)for(this.workers=[];this.workers.length{t.terminate()})),this.workers=null)}isPreloaded(){return!!this.active[lx]}numActive(){return Object.keys(this.active).length}}let dx;function ux(){return dx||(dx=new cx),dx}cx.workerCount=2;let hx,px,fx,mx,_x,gx=null;function yx(){return gi()&&self.worker&&self.worker.dracoUrl?self.worker.dracoUrl:px||n.DRACO_URL}function vx(){if(gi()&&self.worker&&self.worker.meshoptUrl)return self.worker.meshoptUrl;if(mx)return mx;const t=new Uint8Array([0,97,115,109,1,0,0,0,1,4,1,96,0,0,3,3,2,0,0,5,3,1,0,1,12,1,0,10,22,2,12,0,65,0,65,0,65,0,252,10,0,0,11,7,0,65,0,253,15,26,11]);if("object"!=typeof WebAssembly)throw new Error("WebAssembly not supported, cannot instantiate meshoptimizer");return mx=WebAssembly.validate(t)?n.MESHOPT_SIMD_URL:n.MESHOPT_URL,mx}const xx={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},bx={5120:"DT_INT8",5121:"DT_UINT8",5122:"DT_INT16",5123:"DT_UINT16",5125:"DT_UINT32",5126:"DT_FLOAT32"},wx={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16};function Tx(t,e,i){const n=i.json.bufferViews.length,r=i.buffers.length;e.bufferView=n,i.json.bufferViews[n]={buffer:r,byteLength:t.byteLength},i.buffers[r]=t}const Sx="KHR_draco_mesh_compression";function Ex(t,e){const i=t.extensions&&t.extensions[Sx];if(!i)return;const n=new fx.Decoder,r=$x(e,i.bufferView),o=new fx.Mesh;if(!n.DecodeArrayToMesh(r,r.byteLength,o))throw new Error("Failed to decode Draco mesh");const s=e.json.accessors[t.indices],a=xx[s.componentType],l=s.count*a.BYTES_PER_ELEMENT,c=fx._malloc(l);a===Uint16Array?n.GetTrianglesUInt16Array(o,l,c):n.GetTrianglesUInt32Array(o,l,c),Tx(fx.memory.buffer.slice(c,c+l),s,e),fx._free(c);for(const r of Object.keys(i.attributes)){const s=n.GetAttributeByUniqueId(o,i.attributes[r]),a=e.json.accessors[t.attributes[r]],l=bx[a.componentType],c=a.count*wx[a.type]*xx[a.componentType].BYTES_PER_ELEMENT,d=fx._malloc(c);n.GetAttributeDataArrayForAllPoints(o,s,fx[l],c,d),Tx(fx.memory.buffer.slice(d,d+c),a,e),fx._free(d)}n.destroy(),o.destroy(),delete t.extensions[Sx]}const Mx="EXT_meshopt_compression";function Cx(t,e){if(!t.extensions||!t.extensions[Mx])return;const i=t.extensions[Mx],n=new Uint8Array(e.buffers[i.buffer],i.byteOffset||0,i.byteLength||0),r=new Uint8Array(i.count*i.byteStride);_x.decodeGltfBuffer(r,i.count,i.byteStride,n,i.mode,i.filter),t.buffer=e.buffers.length,t.byteOffset=0,e.buffers[t.buffer]=r.buffer,delete t.extensions[Mx]}const Ax=1179937895,Ix=new TextDecoder("utf8");function Lx(t,e){return new URL(t,e).href}function Px(t,e,i,n){return fetch(Lx(t.uri,n)).then((t=>t.arrayBuffer())).then((t=>{e.buffers[i]=t}))}function $x(t,e){const i=t.json.bufferViews[e];return new Uint8Array(t.buffers[i.buffer],i.byteOffset||0,i.byteLength)}function kx(t,e,i,n){if(t.uri){const r=Lx(t.uri,n);return fetch(r).then((t=>t.blob())).then((t=>createImageBitmap(t))).then((t=>{e.images[i]=t}))}if(void 0!==t.bufferView){const n=$x(e,t.bufferView),r=new Blob([n],{type:t.mimeType});return createImageBitmap(r).then((t=>{e.images[i]=t}))}}function Dx(t,e=0,i){const n={json:null,images:[],buffers:[]};if(new Uint32Array(t,e,1)[0]===Ax){const i=new Uint32Array(t,e);let r=2;const o=(i[r++]>>2)-3,s=i[r++]>>2;if(r++,n.json=JSON.parse(Ix.decode(i.subarray(r,r+s))),r+=s,r{const t=[],e=a&&a.includes(Sx),r=a&&a.includes(Mx);if(e&&t.push(function(){if(!fx)return hx||(hx=function(t){let e,i=null;function n(){e=new Uint8Array(i.buffer)}function r(){throw new Error("Unexpected Draco error.")}const o={a:{a:r,d:function(t,i,n){return e.copyWithin(t,i,i+n)},c:function(t){const r=e.length,o=Math.max(t>>>0,Math.ceil(1.2*r)),s=Math.ceil((o-r)/65536);try{return i.grow(s),n(),!0}catch(t){return!1}},b:r}};return(WebAssembly.instantiateStreaming?WebAssembly.instantiateStreaming(t,o):t.then((t=>t.arrayBuffer())).then((t=>WebAssembly.instantiate(t,o)))).then((t=>{const{Rb:r,Qb:o,P:s,T:a,X:l,Ja:c,La:d,Qa:u,Va:h,Wa:p,eb:f,jb:m,f:_,e:g,yb:y,zb:v,Ab:x,Bb:b,Db:w,Gb:T}=t.instance.exports;i=g;const S=(()=>{let t=0,i=0,n=0,s=0;return a=>{n&&(r(s),r(t),i+=n,n=t=0),t||(i+=128,t=o(i));const l=a.length+7&-8;let c=t;l>=i&&(n=l,c=s=o(l));for(let t=0;t{fx=t,hx=void 0})))}()),r&&t.push(function(){if(_x)return;const t=function(t){let e;const i=WebAssembly.instantiateStreaming(t,{}).then((t=>{e=t.instance,e.exports.__wasm_call_ctors()})),n={NONE:"",OCTAHEDRAL:"meshopt_decodeFilterOct",QUATERNION:"meshopt_decodeFilterQuat",EXPONENTIAL:"meshopt_decodeFilterExp"},r={ATTRIBUTES:"meshopt_decodeVertexBuffer",TRIANGLES:"meshopt_decodeIndexBuffer",INDICES:"meshopt_decodeIndexSequence"};return{ready:i,supported:!0,decodeGltfBuffer(t,i,o,s,a,l){!function(t,e,i,n,r,o,s){const a=t.exports.sbrk,l=n+3&-4,c=a(l*r),d=a(o.length),u=new Uint8Array(t.exports.memory.buffer);u.set(o,d);const h=e(c,n,r,d,o.length);if(0===h&&s&&s(c,l,r),i.set(u.subarray(c,c+n*r)),a(c-a(0)),0!==h)throw new Error(`Malformed buffer data: ${h}`)}(e,e.exports[r[a]],t,i,o,s,e.exports[n[l]])}}}(fetch(vx()));return t.ready.then((()=>{_x=t}))}()),o)for(let e=0;e{if(e&&s)for(const{primitives:t}of s)for(const e of t)Ex(e,n);if(r&&s&&l)for(const t of l)Cx(t,n);return n}))}))}function zx(t,e){const i=t.json.bufferViews[e.bufferView],n=xx[e.componentType];return new n(t.buffers[i.buffer],(e.byteOffset||0)+(i.byteOffset||0),e.count*(i.byteStride&&i.byteStride!==wx[e.type]*n.BYTES_PER_ELEMENT?i.byteStride/n.BYTES_PER_ELEMENT:wx[e.type]))}function Rx(t,e,i,n){const r=xx[e.componentType],o=function(t){switch(t){case Int8Array:return 1/127;case Uint8Array:return 1/255;case Int16Array:return 1/32767;case Uint16Array:return 1/65535;default:return 1}}(r),s=t.json.bufferViews[e.bufferView],a=s.byteStride?s.byteStride/r.BYTES_PER_ELEMENT:wx[e.type],l=i.float32,c=l.length/i.capacity;for(let t=0,i=0;t0){for(let r=0;r0){o.texcoordArray=new ic;const t=e.json.accessors[r.TEXCOORD_0];o.texcoordArray.resize(t.count);const i=zx(e,t);Rx(e,t,o.texcoordArray,i)}if(void 0!==r._FEATURE_ID_RGBA4444){const t=e.json.accessors[r._FEATURE_ID_RGBA4444];e.json.extensionsUsed&&e.json.extensionsUsed.includes("EXT_meshopt_compression")&&(o.featureData=zx(e,t))}void 0!==r._FEATURE_RGBA4444&&(o.featureData=new Uint32Array(zx(e,e.json.accessors[r._FEATURE_RGBA4444]).buffer));const u=t.material;return o.material=function(t,e){const{emissiveFactor:i=[0,0,0],alphaMode:n="OPAQUE",alphaCutoff:r=.5,normalTexture:o,occlusionTexture:s,emissiveTexture:a,doubleSided:l}=t,{baseColorFactor:c=[1,1,1,1],metallicFactor:d=1,roughnessFactor:u=1,baseColorTexture:h,metallicRoughnessTexture:p}=t.pbrMetallicRoughness||{},f=s?e[s.index]:void 0;if(s&&s.extensions&&s.extensions.KHR_texture_transform&&f){const t=s.extensions.KHR_texture_transform;f.offsetScale=[t.offset[0],t.offset[1],t.scale[0],t.scale[1]]}return{pbrMetallicRoughness:{baseColorFactor:new Un(...c),metallicFactor:d,roughnessFactor:u,baseColorTexture:h?e[h.index]:void 0,metallicRoughnessTexture:p?e[p.index]:void 0},doubleSided:l,emissiveFactor:i,alphaMode:n,alphaCutoff:r,normalTexture:o?e[o.index]:void 0,occlusionTexture:f,emissionTexture:a?e[a.index]:void 0,defined:void 0===t.defined}}(void 0!==u?e.json.materials[u]:{defined:!1},i),o}function Bx(e,i,n){const{matrix:r,rotation:o,translation:s,scale:a,mesh:l,extras:c,children:d}=e,u={};if(u.matrix=r||t.ad.fromRotationTranslationScale([],o||[0,0,0,1],s||[0,0,0],a||[1,1,1]),void 0!==l){u.meshes=n[l];const t=u.anchor=[0,0];for(const e of u.meshes){const{min:i,max:n}=e.aabb;t[0]+=i[0]+n[0],t[1]+=i[1]+n[1]}t[0]=Math.floor(t[0]/u.meshes.length/2),t[1]=Math.floor(t[1]/u.meshes.length/2)}if(c&&(c.id&&(u.id=c.id),c.lights&&(u.lights=function(t){if(!t.length)return[];const e=function(t){const e=atob(t),i=new Uint8Array(e.length);for(let t=0;t1&&n[n.length-1].equals(n[0])&&n.pop();let r=0;for(let t=0;t0&&n.reverse();const o=xh(n.flatMap((t=>[t.x,t.y])),[]);return 0===o.length?null:{vertices:n,indices:o}}function Ux(e,i){const n=[],r=[];let o=0;const s=[];for(const a of e){o=n.length;const e=a.vertexArray.float32,l=a.indexArray.uint16;for(let r=0;r0&&([r[t+1],r[t+2]]=[r[t+2],r[t+1]])}return{vertices:n,indices:r}}function jx(t){const e=function(t,e){const i=[],n=WebGL2RenderingContext;if(t.json.textures)for(const r of t.json.textures){const o={magFilter:n.LINEAR,minFilter:n.NEAREST,wrapS:n.REPEAT,wrapT:n.REPEAT};void 0!==r.sampler&&Object.assign(o,t.json.samplers[r.sampler]),i.push({image:e[r.source],sampler:o,uploaded:!1})}return i}(t,t.images),i=function(t,e){const i=[];for(const n of t.json.meshes){const r=[];for(const i of n.primitives)r.push(Ox(i,t,e));i.push(r)}return i}(t,e),{scenes:n,scene:r,nodes:o}=t.json,s=n?n[r||0].nodes:o,a=[];for(const e of s)a.push(Bx(o[e],t,i));return function(t,e,i){const n={},r=new Set;for(let o=0;o0){const e=Array.from(r.values()).sort(((t,e)=>t-e));for(let i=e.length-1;i>=0;i--)t.splice(e[i],1)}}(a,s,t.json.nodes),a}function Vx(t){t.heightmap=new Float32Array(4096),t.heightmap.fill(-1);const e=t.vertexArray.float32,i=t.aabb.min[0]-1,n=t.aabb.min[1]-1,r=Wv/(t.aabb.max[0]-i+2),o=Wv/(t.aabb.max[1]-n+2);for(let s=0;st.heightmap[c*Wv+l]&&(t.heightmap[c*Wv+l]=a)}}function Gx(e,i){const n={};n.indexArray=new Kl,n.indexArray.reserve(4*e.length),n.vertexArray=new Bl,n.vertexArray.reserve(10*e.length),n.colorArray=new Ol,n.vertexArray.reserve(10*e.length);let r=0;for(const o of e){const e=Math.min(10,Math.max(4,1.3*o.height))*i,s=[-o.normal[1],o.normal[0],0],a=Math.min(.29,.1*o.width/o.depth),l=o.width-2*o.depth*i*(a+.01),c=t._.scaleAndAdd([],o.pos,s,l/2),d=t._.scaleAndAdd([],o.pos,s,-l/2),u=[c[0],c[1],c[2]+o.height],h=[d[0],d[1],d[2]+o.height],p=t._.scaleAndAdd([],o.normal,s,a);t._.scale(p,p,e);const f=t._.scaleAndAdd([],o.normal,s,-a);t._.scale(f,f,e),t._.add(p,c,p),t._.add(f,d,f),c[2]+=.1,d[2]+=.1,n.vertexArray.emplaceBack(p[0],p[1],p[2]),n.vertexArray.emplaceBack(f[0],f[1],f[2]),n.vertexArray.emplaceBack(c[0],c[1],c[2]),n.vertexArray.emplaceBack(d[0],d[1],d[2]),n.vertexArray.emplaceBack(u[0],u[1],u[2]),n.vertexArray.emplaceBack(h[0],h[1],h[2]),n.vertexArray.emplaceBack(c[0],c[1],c[2]),n.vertexArray.emplaceBack(d[0],d[1],d[2]),n.vertexArray.emplaceBack(p[0],p[1],p[2]),n.vertexArray.emplaceBack(f[0],f[1],f[2]);const m=l/e/2;n.colorArray.emplaceBack(-m-a,-1,m,.8),n.colorArray.emplaceBack(m+a,-1,m,.8),n.colorArray.emplaceBack(-m,0,m,1.3),n.colorArray.emplaceBack(m,0,m,1.3),n.colorArray.emplaceBack(m+a,-.8,m,.7),n.colorArray.emplaceBack(m+a,-.8,m,.7),n.colorArray.emplaceBack(0,0,m,1.3),n.colorArray.emplaceBack(0,0,m,1.3),n.colorArray.emplaceBack(m+a,-1.2,m,.8),n.colorArray.emplaceBack(m+a,-1.2,m,.8),n.indexArray.emplaceBack(6+r,4+r,8+r),n.indexArray.emplaceBack(7+r,9+r,5+r),n.indexArray.emplaceBack(0+r,1+r,2+r),n.indexArray.emplaceBack(1+r,3+r,2+r),r+=10}const o={defined:!0,emissiveFactor:[0,0,0]},s={};return s.baseColorFactor=Un.white,o.pbrMetallicRoughness=s,n.material=o,n.aabb=new wu([1/0,1/0,1/0],[-1/0,-1/0,-1/0]),n}const Zx=new Float32Array(262144),qx=new Uint8Array(262144);function Hx(t){let e=0;if(t.meshes)for(const i of t.meshes)e=Math.max(e,i.aabb.max[2]);if(t.children)for(const i of t.children)e=Math.max(e,Hx(i));return e}function Wx(t,e,i){if(t.meshes)for(const n of t.meshes)n.aabb.min[0]!==1/0&&i.insert(e,n.aabb.min[0],n.aabb.min[1],n.aabb.max[0],n.aabb.max[1]);if(t.children)for(const n of t.children)Wx(n,e,i)}const Yx=["","wall","door","roof","window","lamp","logo"];class Xx{constructor(t){this.node=t,this.evaluatedRMEA=[[1,0,0,1],[1,0,0,1],[1,0,0,1],[1,0,0,1],[.4,1,0,1],[1,0,0,1],[1,0,0,1]],this.hiddenByReplacement=!1,this.evaluatedScale=[1,1,1],this.evaluatedColor=[],this.emissionHeightBasedParams=[],this.feature={type:"Point",id:t.id,geometry:[],properties:{height:Hx(t)}},this.aabb=this._getLocalBounds()}_getLocalBounds(){if(!this.node.meshes)return new wu([1/0,1/0,1/0],[-1/0,-1/0,-1/0]);if(!this.aabb){let t=0;const e=new wu([1/0,1/0,1/0],[-1/0,-1/0,-1/0]);for(const i of this.node.meshes)this.node.lightMeshIndex!==t&&(i.transformedAabb=wu.applyTransformFast(i.aabb,this.node.matrix),e.encapsulate(i.transformedAabb)),t++;this.aabb=e}return this.aabb}}class Kx{constructor(t,e,i,n,r,o){this.id=e,this.modelTraits|=Yv.CoordinateSpaceTile,this.uploaded=!1,this.hasPattern=!1,i&&(this.modelTraits|=Yv.HasMapboxMeshFeatures),n&&(this.modelTraits|=Yv.HasMeshoptCompression),this.zoom=-1,this.terrainExaggeration=1,this.projection={name:"mercator"},this.replacementUpdateTime=0,this.elevationReadFromZ=255,this.brightness=r,this.dirty=!0,this.needsUpload=!1,this.nodesInfo=[];for(const e of t)this.nodesInfo.push(new Xx(e)),Wx(e,o.featureIndexArray.length,o.grid),o.featureIndexArray.emplaceBack(this.nodesInfo.length-1,0,o.bucketLayerIDs.length-1,0)}updateFootprints(t,e){for(const i of this.getNodesInfo()){const n=i.node;n.footprint&&e.push({footprint:n.footprint,id:t})}}update(){console.log("Update 3D model bucket")}populate(){console.log("populate 3D model bucket")}uploadPending(){return!this.uploaded||this.needsUpload}upload(t){if(!this.needsUpload)return;const e=this.getNodesInfo();for(const i of e){const e=i.node;this.uploaded?this.updatePbrBuffer(e):Qv(e,t,!0)}for(const t of e)tx(t.node);this.uploaded=!0,this.needsUpload=!1}updatePbrBuffer(t){let e=!1;if(!t.meshes)return e;for(const i of t.meshes)i.pbrBuffer&&(i.pbrBuffer.updateData(i.featureArray),e=!0);return e}needsReEvaluation(t,e,i){const n=t.transform.projectionOptions,r=t.style.getBrightness(),o=this.brightness!==r;return!!(!this.uploaded||this.dirty||n.name!==this.projection.name||Jx(i.paint.get("model-color").value,o)||Jx(i.paint.get("model-color-mix-intensity").value,o)||Jx(i.paint.get("model-roughness").value,o)||Jx(i.paint.get("model-emissive-strength").value,o)||Jx(i.paint.get("model-height-based-emissive-strength-multiplier").value,o))&&(this.projection=n,this.brightness=r,!0)}evaluateScale(t,e){if(t.transform.zoom===this.zoom)return;this.zoom=t.transform.zoom;const i=this.getNodesInfo(),n=this.id.canonical;for(const t of i){const i=t.feature;t.evaluatedScale=e.paint.get("model-scale").evaluate(i,{},n)}}evaluate(t){const e=this.getNodesInfo();for(const i of e){if(!i.node.meshes)continue;const e=i.feature,n=i.node.meshes&&i.node.meshes[0].featureData,r=i.evaluatedColor[2],o=i.evaluatedRMEA[2],s=this.id.canonical;if(i.hasTranslucentParts=!1,n){for(let n=0;n=t)continue;const u=Zx[c],h=Math.abs(u);h>a&&(s=u,a=h,l=r,d=e)}if(a>.1){const o=1-(t+.5*Math.abs(l*d))/c;let a=e._dem.get(n,i)+s*o;const u=e._dem.get(n+l,i+d),h=e._dem.get(n-l,i-d,!0);(a-u)*(a-h)>0&&(a=(u+h)/2),Zx[r]=e._dem.set(n,i,a),qx[r]=t}}}}}s&&(e._demTile.needsDEMTextureUpload=!0,e._dem._timestamp=ki.now())}getNodesInfo(){return this.nodesInfo}destroy(){const t=this.getNodesInfo();for(const e of t)tx(e.node),ex(e.node)}isEmpty(){return!this.nodesInfo.length}updateReplacement(t,e){if(e.updateTime===this.replacementUpdateTime)return;this.replacementUpdateTime=e.updateTime;const i=e.getReplacementRegionsForTile(t.toUnwrapped()),n=this.getNodesInfo();for(let t=0;tt.footprint===e.footprint))}}getHeightAtTileCoord(e,i){const n=this.getNodesInfo(),r=[],o=[0,0,0],s=t.ad.identity([]);for(let a=0;ad.max[0]||i>d.max[1])continue;if(!0===l.node.hidden)return{height:0,maxHeight:l.feature.properties.height,hidden:!1,verticalScale:l.evaluatedScale[2]};t.ad.invert(s,l.node.matrix),o[0]=e,o[1]=i,t._.transformMat4(o,o,s);const u=(o[0]-c.aabb.min[0])/(c.aabb.max[0]-c.aabb.min[0])*Wv|0,h=Math.min(63,(o[1]-c.aabb.min[1])/(c.aabb.max[1]-c.aabb.min[1])*Wv|0)*Wv+Math.min(63,u),p=c.heightmap[h];if(!(p0)return{height:void 0,maxHeight:l.feature.properties.height,hidden:l.hiddenByReplacement,verticalScale:l.evaluatedScale[2]}}}}function Jx(t,e){return!t.isLightConstant&&e}function Qx(t,e,i,n,r,o,s,a){let l=(61440&e|(61440&e)>>4)>>8,c=(3840&e|(3840&e)>>4)>>4,d=240&e|(240&e)>>4;i[3]>0&&(l=Vn(l,255*i[0],i[3]),c=Vn(c,255*i[1],i[3]),d=Vn(d,255*i[2],i[3]));const u=l>16&65535,a=o?e>>16&65535:65535&e,l=(15&a)t.polygon)).flat());const g=f?l:null,[y,v]=function(e,i,n,r,o,s,a,l,c,d,u){return"globe"===e.projection.name?function(e,i,n,r,o,s,a,l,c,d,u){const h=[],p=[],f=e.projection.upVectorScale(u,e.center.lat,e.worldSize).metersToTile,m=[0,0,0,1],_=[0,0,0,1],g=(t,e,i,n)=>{t[0]=e,t[1]=i,t[2]=n,t[3]=1},y=Sf();n>0&&(n+=y),r+=y;for(const y of i){const i=[],v=[];for(const h of y){const p=h.x+o.x,y=h.y+o.y,x=e.projection.projectTilePoint(p,y,u),b=e.projection.upVector(u,h.x,h.y);let w=n,T=r;if(a){const t=Pf(p,y,n,r,a,l,c,d);w+=t.base,T+=t.top}0!==n?g(m,x.x+b[0]*f*w,x.y+b[1]*f*w,x.z+b[2]*f*w):g(m,x.x,x.y,x.z),g(_,x.x+b[0]*f*T,x.y+b[1]*f*T,x.z+b[2]*f*T),t._.transformMat4(m,m,s),t._.transformMat4(_,_,s),i.push(new Tp(m[0],m[1],m[2])),v.push(new Tp(_[0],_[1],_[2]))}h.push(i),p.push(v)}return[h,p]}(e,i,n,r,o,s,a,l,c,d,u):a?function(e,i,n,r,o,s,a,l,c){const d=[],u=[],h=[0,0,0,1];for(const p of e){const e=[],f=[];for(const d of p){const u=d.x+r.x,p=d.y+r.y,m=Pf(u,p,i,n,s,a,l,c);h[0]=u,h[1]=p,h[2]=m.base,h[3]=1,t.aA.transformMat4(h,h,o),h[3]=Math.max(h[3],1e-5);const _=new Tp(h[0]/h[3],h[1]/h[3],h[2]/h[3]);h[0]=u,h[1]=p,h[2]=m.top,h[3]=1,t.aA.transformMat4(h,h,o),h[3]=Math.max(h[3],1e-5);const g=new Tp(h[0]/h[3],h[1]/h[3],h[2]/h[3]);e.push(_),f.push(g)}d.push(e),u.push(f)}return[d,u]}(i,n,r,o,s,a,l,c,d):function(t,e,i,n,r){const o=[],s=[],a=r[8]*e,l=r[9]*e,c=r[10]*e,d=r[11]*e,u=r[8]*i,h=r[9]*i,p=r[10]*i,f=r[11]*i;for(const e of t){const t=[],i=[];for(const o of e){const e=o.x+n.x,s=o.y+n.y,m=r[0]*e+r[4]*s+r[12],_=r[1]*e+r[5]*s+r[13],g=r[2]*e+r[6]*s+r[14],y=r[3]*e+r[7]*s+r[15],v=m+a,x=_+l,b=g+c,w=Math.max(y+d,1e-5),T=m+u,S=_+h,E=g+p,M=Math.max(y+f,1e-5);t.push(new Tp(v/w,x/w,b/w)),i.push(new Tp(T/M,S/M,E/M))}o.push(t),s.push(i)}return[o,s]}(i,n,r,o,s)}(s,r,h,u,d,a,g,p,m,s.center.lat,e.tileID.canonical),x=e.queryGeometry;return function(t,e,i){let n=1/0;Kd(i,e)&&(n=Lf(i,e[0]));for(let r=0;r=3)for(let e=0;e>4;if(1!==n)throw new Error(`Got v${n} data when expected v1.`);const r=nb[15&i];if(!r)throw new Error("Unrecognized array type.");const[o]=new Uint16Array(t,2,1),[s]=new Uint32Array(t,4,1);return new rb(s,o,r,t)}constructor(t,e=64,i=Float64Array,n){if(isNaN(t)||t>1;return this.ids[i]=i,this.coords[this._pos++]=t,this.coords[this._pos++]=e,i}finish(){const t=this._pos>>1;if(t!==this.numItems)throw new Error(`Added ${t} items when expected ${this.numItems}.`);return ob(this.ids,this.coords,this.nodeSize,0,this.numItems-1,0),this._finished=!0,this}range(t,e,i,n){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");const{ids:r,coords:o,nodeSize:s}=this,a=[0,r.length-1,0],l=[];for(;a.length;){const c=a.pop()||0,d=a.pop()||0,u=a.pop()||0;if(d-u=t&&a=e&&c>1,p=o[2*h],f=o[2*h+1];p>=t&&p=e&&f=p:n>=f)&&(a.push(h+1),a.push(d),a.push(1-c))}return l}within(t,e,i){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");const{ids:n,coords:r,nodeSize:o}=this,s=[0,n.length-1,0],a=[],l=i*i;for(;s.length;){const c=s.pop()||0,d=s.pop()||0,u=s.pop()||0;if(d-u>1,p=r[2*h],f=r[2*h+1];cb(p,f,t,e)=p:e+i>=f)&&(s.push(h+1),s.push(d),s.push(1-c))}return a}}function ob(t,e,i,n,r,o){if(r-n>1;sb(t,e,s,n,r,o),ob(t,e,i,n,s-1,1-o),ob(t,e,i,s+1,r,1-o)}function sb(t,e,i,n,r,o){for(;r>n;){if(r-n>600){const s=r-n+1,a=i-n+1,l=Math.log(s),c=.5*Math.exp(2*l/3),d=.5*Math.sqrt(l*c*(s-c)/s)*(a-s/2s&&ab(t,e,n,r);as;)l--}e[2*n+o]===s?ab(t,e,n,l):(l++,ab(t,e,l,r)),lr&&(n+=(t[i]-r)*(t[i]-r)),e[i]0&&n[0]0&&n[1]0&&r[0]0&&r[1]0?Math.acos(i/n)*Ve:0;let o=0!==t||0!==e?Math.atan2(-e,-t)*Ve+90:0;return oNi&&(t.getActor().send("enforceCacheSizeLimit",Fi),Vi=0)},t.an=gn,t.ao=class{constructor(t){this.entries={},this.scheduler=t}request(t,e,i,n){const r=this.entries[t]=this.entries[t]||{callbacks:[]};if(r.result){const[t,i]=r.result;return this.scheduler?this.scheduler.add((()=>{n(t,i)}),e):n(t,i),()=>{}}return r.callbacks.push(n),r.cancel||(r.cancel=i(((i,n)=>{r.result=[i,n];for(const t of r.callbacks)this.scheduler?this.scheduler.add((()=>{t(i,n)}),e):t(i,n);setTimeout((()=>delete this.entries[t]),3e3)}))),()=>{r.result||(r.callbacks=r.callbacks.filter((t=>t!==n)),r.callbacks.length||(r.cancel(),delete this.entries[t]))}}},t.ap=function(t,e,i){const n=JSON.stringify(t.request);return t.data&&(this.deduped.entries[n]={result:[null,t.data]}),this.deduped.request(n,{type:"parseTile",isSymbolTile:t.isSymbolTile,zoom:t.tileZoom},(e=>{const n=en(t.request,((t,n,r,o)=>{t?e(t):n&&e(null,{vectorTile:i?void 0:new bp(new Lm(n)),rawData:n,cacheControl:r,expires:o})}));return()=>{n.cancel(),e()}}),e)},t.aq=Dc,t.ar=class extends Lc{constructor(t){super(t),this.current=Fc}set(t,e,i){if(this.fetchUniformLocation(t,e))for(let t=0;t({u_camera_to_center_distance:new $c(t),u_extrude_scale:new Uc(t),u_device_pixel_ratio:new $c(t),u_matrix:new Bc(t),u_inv_rot_matrix:new Bc(t),u_merc_center:new kc(t),u_tile_id:new Dc(t),u_zoom_transition:new $c(t),u_up_dir:new Dc(t),u_emissive_strength:new $c(t)}),t.bJ=t=>({u_matrix:new Bc(t),u_pixels_to_tile_units:new Uc(t),u_device_pixel_ratio:new $c(t),u_units_to_pixels:new kc(t),u_dash_image:new Pc(t),u_gradient_image:new Pc(t),u_image_height:new $c(t),u_texsize:new kc(t),u_tile_units_to_pixels:new $c(t),u_alpha_discard_threshold:new $c(t),u_trim_offset:new kc(t),u_trim_fade_range:new kc(t),u_trim_color:new zc(t),u_emissive_strength:new $c(t)}),t.bK=t=>({u_matrix:new Bc(t),u_texsize:new kc(t),u_pixels_to_tile_units:new Uc(t),u_device_pixel_ratio:new $c(t),u_image:new Pc(t),u_units_to_pixels:new kc(t),u_tile_units_to_pixels:new $c(t),u_alpha_discard_threshold:new $c(t),u_trim_offset:new kc(t)}),t.bL=Yl,t.bM=Hf,t.bN=Om,t.bO=jm,t.bP=G_,t.bQ=c_,t.bR=th,t.bS=(t,e,i,n,r,o)=>{const s=t.transform,a="globe"===s.projection.name;let l;if("map"===o.paint.get("circle-pitch-alignment"))if(a){const t=Zu(s.zoom,e.canonical)*s._pixelsPerMercatorPixel;l=Float32Array.from([t,0,0,t])}else l=s.calculatePixelsToTileUnitsMatrix(i);else l=new Float32Array([s.pixelsToGLUnits[0],0,0,s.pixelsToGLUnits[1]]);const c={u_camera_to_center_distance:t.transform.getCameraToCenterDistance(s.projection),u_matrix:t.translatePosMatrix(e.projMatrix,i,o.paint.get("circle-translate"),o.paint.get("circle-translate-anchor")),u_device_pixel_ratio:ki.devicePixelRatio,u_extrude_scale:l,u_inv_rot_matrix:Qu,u_merc_center:[0,0],u_tile_id:[0,0,0],u_zoom_transition:0,u_up_dir:[0,0,0],u_emissive_strength:o.paint.get("circle-emissive-strength")};if(a){c.u_inv_rot_matrix=n,c.u_merc_center=r,c.u_tile_id=[e.canonical.x,e.canonical.y,1{const s=t.transform;return{u_matrix:rm(t,e,i,n),u_texsize:e.imageAtlasTexture?e.imageAtlasTexture.size:[0,0],u_pixels_to_tile_units:s.calculatePixelsToTileUnitsMatrix(e),u_device_pixel_ratio:r,u_image:0,u_tile_units_to_pixels:nm(e,s),u_units_to_pixels:[1/s.pixelsToGLUnits[0],1/s.pixelsToGLUnits[1]],u_alpha_discard_threshold:0,u_trim_offset:o}},t.bV=(t,e,i,n,r,o,s)=>{const a=t.transform,l=a.calculatePixelsToTileUnitsMatrix(e);return{u_matrix:rm(t,e,i,n),u_pixels_to_tile_units:l,u_device_pixel_ratio:o,u_units_to_pixels:[1/a.pixelsToGLUnits[0],1/a.pixelsToGLUnits[1]],u_dash_image:0,u_gradient_image:1,u_image_height:r,u_texsize:sm(i)&&e.lineAtlasTexture?e.lineAtlasTexture.size:[0,0],u_tile_units_to_pixels:nm(e,t.transform),u_alpha_discard_threshold:0,u_trim_offset:s,u_trim_fade_range:i.paint.get("line-trim-fade-range"),u_trim_color:i.paint.get("line-trim-color").toRenderColor(i.lut).toArray01(),u_emissive_strength:i.paint.get("line-emissive-strength")}},t.bW=oi,t.bX=mh,t.bY=Sf,t.bZ=bd,t.b_=_f,t.ba=function(t,e,i){const n=Hu(i.zoom),r=t.style.map._antialias,o=e.options.extStandardDerivativesForceOff||t.terrain&&t.terrain.exaggeration()>0;return 0===n&&!r&&!o},t.bb=function(e){const i=e.pixelsPerMeter,n=i/Cd(1,e.center.lat),r=t.ad.identity(new Float64Array(16));return t.ad.translate(r,r,[e.point.x,e.point.y,0]),t.ad.scale(r,r,[n,n,i]),Float32Array.from(r)},t.bc=Ou,t.bd=function(t){const e=Pd-5;t=Xe(t,-e,e)/e*90;const i=Math.pow(Math.abs(Math.sin(Ge(t))),3);return Math.round(i*(sd.length-1))},t.be=function(e,i,n,r){const o=i.getNorth(),s=i.getSouth(),a=i.getWest(),l=i.getEast(),c=10){const e=180/r;t.bC.multiply(f,f,[e/d+1,0,0,0,e/u+1,0,-.5*e/h,.5*e/p,1])}return f[2]=c,f[5]=e.x,f[8]=e.y,f},t.bf=ju,t.bg=$u,t.bh=function(e,i,n){const r=t.ad.identity(new Float64Array(16)),o=(i/(1{}}},t.bo=Gg,t.bp=ai,t.bq=class{isDataAvailableAtPoint(t){const e=this._source();if(this.isUsingMockSource()||!e||t.y1)return!1;const i=e.getSource().maxzoom,n=11)return e;const r=n.getSource().maxzoom,o=1{const s=this.getAtTileOffset(e,o.x,o.y),a=r.upVector(e.canonical,o.x,o.y),l=r.upVectorScale(e.canonical,i,n).metersToTile;return t._.scale(a,a,s*l),a}}getForTilePoints(t,e,i,n){if(this.isUsingMockSource())return!1;const r=Xp.create(this,t,n);return!!r&&(e.forEach((t=>{t[2]=this.exaggeration()*r.getElevationAt(t[0],t[1],i)})),!0)}getMinMaxForTile(t){if(this.isUsingMockSource())return null;const e=this.findDEMTileFor(t);if(!e||!e.dem)return null;const i=e.dem.tree,n=e.tileID,r=1=0?t.slice(0,e):t},t.cV=function(t){return t.indexOf(wl)>=0},t.cW=function(t){const e=t.indexOf(wl);return e>=0?t.slice(e+1):""},t.cX=function(t){const e=[],i=t.id;return void 0===i&&e.push({message:`layers.${i}: missing required property "id"`}),void 0===t.render&&e.push({message:`layers.${i}: missing required method "render"`}),t.renderingMode&&"2d"!==t.renderingMode&&"3d"!==t.renderingMode&&e.push({message:`layers.${i}: property "renderingMode" must be either "2d" or "3d"`}),e},t.cY=function(t,e,i,n){return"custom"===t.type?new vv(t,e):new ib[t.type](t,e,i,n)},t.cZ=di,t.c_=Va,t.ca=1,t.cb=Ag,t.cc=0,t.cd=ec,t.ce=function(t,e,i,n,r){return Xe((t-e)/(i-e)*(r-n)+n,n,r)},t.cf=Ns,t.cg=kd,t.ch=class{constructor(t,e,i,n){this.context=t,this.format=n,this.size=i,this.texture=t.gl.createTexture();const[r,o,s]=this.size,{gl:a}=t;a.bindTexture(a.TEXTURE_3D,this.texture),t.pixelStoreUnpackFlipY.set(!1),t.pixelStoreUnpack.set(1),t.pixelStoreUnpackPremultiplyAlpha.set(!1);let l=this.format,c=a.UNSIGNED_BYTE;this.format===a.DEPTH_COMPONENT&&(l=a.DEPTH_COMPONENT16,c=a.UNSIGNED_SHORT),this.format===a.R8&&(n=a.RED),this.format===a.R32F&&(c=a.FLOAT,n=a.RED),a.texImage3D(a.TEXTURE_3D,0,l,r,o,s,0,n,c,e.data)}bind(t,e){const{context:i}=this,{gl:n}=i;n.bindTexture(n.TEXTURE_3D,this.texture),t!==this.minFilter&&(n.texParameteri(n.TEXTURE_3D,n.TEXTURE_MAG_FILTER,t),n.texParameteri(n.TEXTURE_3D,n.TEXTURE_MIN_FILTER,t),this.minFilter=t),e!==this.wrapS&&(n.texParameteri(n.TEXTURE_3D,n.TEXTURE_WRAP_S,e),n.texParameteri(n.TEXTURE_3D,n.TEXTURE_WRAP_T,e),this.wrapS=e)}destroy(){const{gl:t}=this.context;t.deleteTexture(this.texture),this.texture=null}},t.ci=$v,t.cj=[1,1,1],t.ck=Xp,t.cl=Yv,t.cm=ql,t.cn=ic,t.co=class{constructor(){this._updateTime=0,this._sourceIds=[],this._activeRegions=[],this._prevRegions=[],this._globalClipBounds={min:new Ue(1/0,1/0),max:new Ue(-1/0,-1/0)}}clear(){this._activeRegions.length>0&&++this._updateTime,this._activeRegions=[],this._prevRegions=[]}get updateTime(){return this._updateTime}getReplacementRegionsForTile(t,e=!1){const i=$p(new Ue(0,0),new Ue(uo,uo),t),n=[];if(e&&!Lp(i,this._globalClipBounds))return n;for(const e of this._activeRegions){if(e.hiddenByOverlap)continue;if(!Lp(i,e))continue;const r=kp(e.min,e.max,t);n.push({min:r.min,max:r.max,sourceId:this._sourceIds[e.priority],footprint:e.footprint,footprintTileId:e.tileId,order:e.order,clipMask:e.clipMask})}return n}setSources(t){this._setSources(t.map((t=>({getSourceId:()=>t.cache.id,getFootprints:()=>{const e=[];for(const i of t.cache.getVisibleCoordinates()){const n=t.cache.getTile(i).buckets[t.layer];n&&n.updateFootprints(i.toUnwrapped(),e)}return e},getOrder:()=>t.order,getClipMask:()=>t.clipMask}))))}_addSource(t){const e=t.getFootprints();if(0===e.length)return;const i=t.getOrder(),n=t.getClipMask();for(const t of e){if(!t.footprint)continue;const e=$p(t.footprint.min,t.footprint.max,t.id);this._activeRegions.push({min:e.min,max:e.max,hiddenByOverlap:!1,priority:this._sourceIds.length,tileId:t.id,footprint:t.footprint,order:i,clipMask:n})}this._sourceIds.push(t.getSourceId())}_computeReplacement(){this._activeRegions.sort(((t,e)=>t.priority-e.priority||Ap(t.min,e.min)||Ap(t.max,e.max)));let t=this._activeRegions.length!==this._prevRegions.length;if(!t){let e=0;for(;!t&&e!==this._activeRegions.length;){const i=this._activeRegions[e],n=this._prevRegions[e];t=i.priority!==n.priority||!Ip(i,n)||i.order!==n.order||i.clipMask!==n.clipMask,++e}}if(t){++this._updateTime;for(const t of this._activeRegions)t.order!==1/0&&(this._globalClipBounds.min.x=Math.min(this._globalClipBounds.min.x,t.min.x),this._globalClipBounds.min.y=Math.min(this._globalClipBounds.min.y,t.min.y),this._globalClipBounds.max.x=Math.max(this._globalClipBounds.max.x,t.max.x),this._globalClipBounds.max.y=Math.max(this._globalClipBounds.max.y,t.max.y));const t=t=>{const e=this._activeRegions;if(t>=e.length)return t;const i=e[t].priority;for(;t1){let e=0,i=t(e);for(;e!==i;){let n=e;const r=e;for(;n!==i;){const t=this._activeRegions[n];t.hiddenByOverlap=!1;for(let e=0;e=0;e--)this._addSource(t[e]);this._computeReplacement()}},t.cp=Dl,t.cq=Jg,t.cr=rc,t.cs=class{constructor(t){this._createGrid(t),this._createPoles(t)}destroy(){this._poleIndexBuffer.destroy(),this._gridBuffer.destroy(),this._gridIndexBuffer.destroy(),this._poleNorthVertexBuffer.destroy(),this._poleSouthVertexBuffer.destroy();for(const t of this._poleSegments)t.destroy();for(const t of this._gridSegments)t.withSkirts.destroy(),t.withoutSkirts.destroy()}_fillGridMeshWithLods(t,e){const i=new $l,n=new Kl,r=[],o=t+1+2,s=e[0]+1,a=e[0]+1+(1+e.length),l=(t,e,i)=>{let n=t===o-1?t-2:0===t?t:t-1;return n+=i?24575:0,[n,e]};for(let t=0;tt()))},t.dB=sx,t.dC=yx,t.dD=function(t){px=ki.resolveURL(t),gx||(gx=new ox(ux(),new zn)),gx.broadcast("setDracoUrl",px)},t.dE=vx,t.dF=function(t){mx=ki.resolveURL(t),gx||(gx=new ox(ux(),new zn)),gx.broadcast("setMeshoptUrl",mx)},t.dG=ti,t.dH=ba,t.dI=dh,t.dJ=I_,t.dK=eg,t.dL=dc,t.dM=am,t.dN=Dm,t.dO=Wf,t.dP=ci,t.dQ=E_,t.dR=jg,t.dS=function(t,e,i,n,r,o,s,a,l,c,d){t.createArrays(),t.tilePixelRatio=uo/(512*t.overscaling),t.compareText={},t.iconsNeedLinear=!1;const u=t.layers[0].layout,h=t.layers[0]._unevaluatedLayout._values,p={};if("composite"===t.textSizeData.kind){const{minZoom:e,maxZoom:i}=t.textSizeData;p.compositeTextSizes=[h["text-size"].possiblyEvaluate(new Ha(e),a),h["text-size"].possiblyEvaluate(new Ha(i),a)]}if("composite"===t.iconSizeData.kind){const{minZoom:e,maxZoom:i}=t.iconSizeData;p.compositeIconSizes=[h["icon-size"].possiblyEvaluate(new Ha(e),a),h["icon-size"].possiblyEvaluate(new Ha(i),a)]}p.layoutTextSize=h["text-size"].possiblyEvaluate(new Ha(l+1),a),p.layoutIconSize=h["icon-size"].possiblyEvaluate(new Ha(l+1),a),p.textMaxSize=h["text-size"].possiblyEvaluate(new Ha(18),a);const f="map"===u.get("text-rotation-alignment")&&"point"!==u.get("symbol-placement"),m=u.get("text-size");let _=!1;for(const e of t.features)if(e.icon&&e.icon.nameSecondary){_=!0;break}for(const o of t.features){const l=u.get("text-font").evaluate(o,{},a).join(","),h=m.evaluate(o,{},a),g=p.layoutTextSize.evaluate(o,{},a),y=(p.layoutIconSize.evaluate(o,{},a),{horizontal:{},vertical:void 0}),v=o.text;let x,b=[0,0];if(v){const n=v.toString(),s=u.get("text-letter-spacing").evaluate(o,{},a)*Om,c=u.get("text-line-height").evaluate(o,{},a)*Om,d=Aa(n)?s:0,p=u.get("text-anchor").evaluate(o,{},a),m=u.get("text-variable-anchor");if(!m){const t=u.get("text-radial-offset").evaluate(o,{},a);b=t?G_(p,[t*Om,j_]):u.get("text-offset").evaluate(o,{},a).map((t=>t*Om))}let _=f?"center":u.get("text-justify").evaluate(o,{},a);const x="point"===u.get("symbol-placement"),w=x?u.get("text-max-width").evaluate(o,{},a)*Om:1/0,T=o=>{t.allowVerticalPlacement&&Ca(n)&&(y.vertical=e_(v,e,i,r,l,w,c,p,o,d,b,Jm.vertical,!0,g,h))};if(!f&&m){const t="auto"===_?m.map((t=>Z_(t))):[_];let n=!1;for(let o=0;o=0||!Ca(n)){const t=e_(v,e,i,r,l,w,c,p,_,d,b,Jm.horizontal,!1,g,h);t&&(y.horizontal[_]=t)}T(x?"left":_)}}let w=!1;if(o.icon&&o.icon.namePrimary){const e=n[o.icon.namePrimary];e&&(x=u_(r[o.icon.namePrimary],o.icon.nameSecondary?r[o.icon.nameSecondary]:void 0,u.get("icon-offset").evaluate(o,{},a),u.get("icon-anchor").evaluate(o,{},a)),w=e.sdf,void 0===t.sdfIcons?t.sdfIcons=e.sdf:t.sdfIcons!==e.sdf&&pi("Style sheet warning: Cannot mix SDF and non-SDF icons in one buffer"),(e.pixelRatio!==t.pixelRatio||0!==u.get("icon-rotate").constantOr(1))&&(t.iconsNeedLinear=!0))}const T=X_(y.horizontal)||y.vertical;t.iconsInText||(t.iconsInText=!!T&&T.iconsInText),(T||x)&&q_(t,o,y,x,n,p,g,0,b,w,s,a,c,d,_)}o&&t.generateCollisionDebugBuffers(l,t.collisionBoxArray)},t.dT=Jf,t.dU=Yh,t.dV=bp,t.dW=Lm,t.dX=Yp,t.dY=Zy,t.dZ=wp,t.d_=cp,t.da=Wu,t.db=function(e){const i=[0,0,0],n=t.ad.identity(new Float64Array(16));return t.ad.multiply(n,e.pixelMatrix,e.globeMatrix),t._.transformMat4(i,i,n),new Ue(i[0],i[1])},t.dc=d,t.dd=c,t.de=function(t){const e=t.navigator?t.navigator.userAgent:null;return!!function(t){if(null==Ei){const e=t.navigator?t.navigator.userAgent:null;Ei=!!t.safari||!(!e||!(/\b(iPad|iPhone|iPod)\b/.test(e)||e.match("Safari")&&!e.match("Chrome")))}return Ei}(t)&&e&&(e.match("Version/15.4")||e.match("Version/15.5")||e.match(/CPU (OS|iPhone OS) (15_4|15_5) like Mac OS X/))},t.df=ni,t.dg=class{constructor(t,e,i){this._transformRequestFn=t,this._customAccessToken=e,this._silenceAuthErrors=!!i,this._createSkuToken()}_createSkuToken(){const t=function(){let t="";for(let e=0;ethis._skuTokenExpiresAt}transformRequest(t,e){return this._transformRequestFn&&this._transformRequestFn(t,e)||{url:t}}normalizeStyleURL(t,i){if(!o(t))return t;const n=un(t);return n.params.push(`sdk=js-${e}`),n.path=`/styles/v1${n.path}`,this._makeAPIURL(n,this._customAccessToken||i)}normalizeGlyphsURL(t,e){if(!o(t))return t;const i=un(t);return i.path=`/fonts/v1${i.path}`,this._makeAPIURL(i,this._customAccessToken||e)}normalizeModelURL(t,e){if(!o(t))return t;const i=un(t);return i.path=`/models/v1${i.path}`,this._makeAPIURL(i,this._customAccessToken||e)}normalizeSourceURL(t,e,i,n){if(!o(t))return t;const r=un(t);return r.path=`/v4/${r.authority}.json`,r.params.push("secure"),i&&r.params.push(`language=${i}`),n&&r.params.push(`worldview=${n}`),this._makeAPIURL(r,this._customAccessToken||e)}normalizeSpriteURL(t,e,i,n){const r=un(t);return o(t)?(r.path=`/styles/v1${r.path}/sprite${e}${i}`,this._makeAPIURL(r,this._customAccessToken||n)):(r.path+=`${e}${i}`,hn(r))}normalizeTileURL(t,e,i){if(this._isSkuTokenExpired()&&this._createSkuToken(),t&&!o(t))return t;const r=un(t);r.path=r.path.replace(/(\.(png|jpg)\d*)(?=$)/,`${e||i&&"raster"!==r.authority&&512===i?"@2x":""}${Gi.supported?".webp":"$1"}`),"raster"===r.authority?r.path=`/${n.RASTER_URL_PREFIX}${r.path}`:"rasterarrays"===r.authority?r.path=`/${n.RASTERARRAYS_URL_PREFIX}${r.path}`:"3dtiles"===r.authority?r.path=`/${n.TILES3D_URL_PREFIX}${r.path}`:(r.path=r.path.replace(/^.+\/v4\//,"/"),r.path=`/${n.TILE_URL_VERSION}${r.path}`);const s=this._customAccessToken||function(t){for(const e of t){const t=e.match(/^access_token=(.*)$/);if(t)return t[1]}return null}(r.params)||n.ACCESS_TOKEN;return n.REQUIRE_ACCESS_TOKEN&&s&&this._skuToken&&r.params.push(`sku=${this._skuToken}`),this._makeAPIURL(r,s)}canonicalizeTileURL(t,e){const i=un(t);if(!i.path.match(/^(\/v4\/|\/(raster|rasterarrays)\/v1\/)/)||!i.path.match(/\.[\w]+$/))return t;let r="mapbox://";i.path.match(/^\/raster\/v1\//)?r+=`raster/${i.path.replace(`/${n.RASTER_URL_PREFIX}/`,"")}`:i.path.match(/^\/rasterarrays\/v1\//)?r+=`rasterarrays/${i.path.replace(`/${n.RASTERARRAYS_URL_PREFIX}/`,"")}`:r+=`tiles/${i.path.replace(`/${n.TILE_URL_VERSION}/`,"")}`;let o=i.params;return e&&(o=o.filter((t=>!t.match(/^access_token=/)))),o.length&&(r+=`?${o.join("&")}`),r}canonicalizeTileset(t,e){const i=!!e&&o(e),n=[];for(const e of t.tiles||[])r(e)?n.push(this.canonicalizeTileURL(e,i)):n.push(e);return n}_makeAPIURL(t,e){const i="See https://docs.mapbox.com/api/overview/#access-tokens-and-token-scopes",r=un(n.API_URL);if(t.protocol=r.protocol,t.authority=r.authority,"http"===t.protocol){const e=t.params.indexOf("secure");e>=0&&t.params.splice(e,1)}if("/"!==r.path&&(t.path=`${r.path}${t.path}`),!n.REQUIRE_ACCESS_TOKEN)return hn(t);if(e=e||n.ACCESS_TOKEN,!this._silenceAuthErrors){if(!e)throw new Error(`An API access token is required to use Mapbox GL. ${i}`);if("s"===e[0])throw new Error(`Use a public access token (pk.*) with Mapbox GL, not a secret access token (sk.*). ${i}`)}return t.params=t.params.filter((t=>-1===t.indexOf("access_token"))),t.params.push(`access_token=${e||""}`),hn(t)}},t.dh=function(t,e){e?Mn.add(t):Mn.delete(t)},t.di=Gi,t.dj=Tn,t.dk=En,t.dl=cn,t.dm=vn,t.dn=bn,t.dp=function(t){Mn.delete(t)},t.dq=Sn,t.dr=yn,t.ds=Qe,t.dt=e,t.du=function(t,e){Fi=t,Ni=e},t.dv=function(t,e,i=!1){if(Fa===za||Fa===Ra||Fa===Oa)throw new Error("setRTLTextPlugin cannot be called multiple times.");Na=ki.resolveURL(t),Fa=za,Ba=e,ja(),i||Za()},t.dw=Ga,t.dx=function(){ux().acquire(lx)},t.dy=function(){const t=dx;t&&(t.isPreloaded()&&1===t.numActive()?(t.release(lx),dx=null):console.warn("Could not clear WebWorkers since there are active Map instances that still reference it. The pre-warmed WebWorker pool can only be cleared when all map instances have been removed with map.remove()"))},t.dz=cx,t.e=ki,t.e0=cm,t.e1=h,t.e2=en,t.e3=function(t){let e=0;if(new Uint32Array(t,0,1)[0]!==Ax){const i=new Uint32Array(t,0,7),[,,n,r,o,s]=i;e=i.byteLength+r+o+s+o,(n!==t.byteLength||e>=t.byteLength)&&pi("Invalid b3dm header information.")}return Dx(t,e)},t.e4=function(t,e){const i=jx(t);for(const t of i){for(const e of t.meshes)Vx(e);t.lights&&(t.lightMeshIndex=t.meshes.length,t.meshes.push(Gx(t.lights,e)))}return i},t.e5=Kx,t.e6=rx,t.e7=qa,t.e8=function(t){ji(),Oi&&Oi.then((e=>{e.keys().then((i=>{for(let n=0;nt.arrayBuffer())).then((e=>Dx(e,0,t)))},t.m=class extends Uv{},t.n=Er,t.o=qn,t.p=Qg,t.q=Xs,t.r=Js,t.s=Qs,t.t=ca,t.u=al,t.v=ll,t.w=pi,t.x=pa,t.y=da,t.z=qo})),n(0,(function(t){function e(t){const e=t?t.url.toString():void 0;return e?performance.getEntriesByName(e):[]}function i(t){if("number"==typeof t||"boolean"==typeof t||"string"==typeof t||null==t)return JSON.stringify(t);if(Array.isArray(t)){let e="[";for(const n of t)e+=`${i(n)},`;return`${e}]`}let e="{";for(const n of Object.keys(t).sort())e+=`${n}:${i(t[n])},`;return`${e}}`}function n(e){let n="";for(const r of t.cE)n+=`/${i(e[r])}`;return n}class r{constructor(t){this.keyCache={},this._layers={},this._layerConfigs={},t&&this.replace(t)}replace(t,e){this._layerConfigs={},this._layers={},this.update(t,[],e)}update(e,i,r){this._options=r;for(const i of e)this._layerConfigs[i.id]=i,(this._layers[i.id]=t.cY(i,this.scope,null,this._options)).compileFilter(),this.keyCache[i.id]&&delete this.keyCache[i.id];for(const t of i)delete this.keyCache[t],delete this._layerConfigs[t],delete this._layers[t];this.familiesBySource={};const o=function(t,e){const i={};for(let r=0;rthis._layers[t.id])),i=e[0];if("none"===i.visibility)continue;const n=i.source||"";let r=this.familiesBySource[n];r||(r=this.familiesBySource[n]={});const o=i.sourceLayer||"_geojsonTileLayer";let s=r[o];s||(s=r[o]=[]),s.push(e)}}}const o=1*t.dJ;class s{constructor(e){const i={},n=[];for(const t in e){const r=e[t],s=i[t]={};for(const t in r.glyphs){const e=r.glyphs[+t];if(!e||0===e.bitmap.width||0===e.bitmap.height)continue;const i=e.metrics.localGlyph?o:1,a={x:0,y:0,w:e.bitmap.width+2*i,h:e.bitmap.height+2*i};n.push(a),s[t]=a}}const{w:r,h:s}=t.j(n),a=new t.dI({width:r||1,height:s||1});for(const n in e){const r=e[n];for(const e in r.glyphs){const s=r.glyphs[+e];if(!s||0===s.bitmap.width||0===s.bitmap.height)continue;const l=i[n][e],c=s.metrics.localGlyph?o:1;t.dI.copy(s.bitmap,a,{x:0,y:0},{x:l.x+c,y:l.y+c},s.bitmap)}}this.image=a,this.positions=i}}t.dH(s,"GlyphAtlas");class a{constructor(e){this.tileID=new t.aL(e.tileID.overscaledZ,e.tileID.wrap,e.tileID.canonical.z,e.tileID.canonical.x,e.tileID.canonical.y),this.tileZoom=e.tileZoom,this.uid=e.uid,this.zoom=e.zoom,this.lut=e.lut,this.canonical=e.tileID.canonical,this.pixelRatio=e.pixelRatio,this.tileSize=e.tileSize,this.source=e.source,this.scope=e.scope,this.overscaling=this.tileID.overscaleFactor(),this.showCollisionBoxes=e.showCollisionBoxes,this.collectResourceTiming=!!e.collectResourceTiming,this.promoteId=e.promoteId,this.isSymbolTile=e.isSymbolTile,this.tileTransform=t.dK(e.tileID.canonical,e.projection),this.projection=e.projection,this.brightness=e.brightness,this.extraShadowCaster=!!e.extraShadowCaster,this.tessellationStep=e.tessellationStep}parse(e,i,n,r,o){this.status="parsing",this.data=e,this.collisionBoxArray=new t.dL;const a=new t.dM(Object.keys(e.layers).sort()),c=new t.dN(this.tileID,this.promoteId);c.bucketLayerIDs=[];const d={},u=new t.dO(256,256),h={featureIndex:c,iconDependencies:{},patternDependencies:{},glyphDependencies:{},lineAtlas:u,availableImages:n,brightness:this.brightness},p=i.familiesBySource[this.source];for(const i in p){const r=e.layers[i];if(!r)continue;let o=!1,s=!1,u=!1;for(const t of p[i])"symbol"===t[0].type?o=!0:s=!0,t[0].is3D()&&"model"!==t[0].type&&(u=!0);if(this.extraShadowCaster&&!u)continue;if(!0===this.isSymbolTile&&!o)continue;if(!1===this.isSymbolTile&&!s)continue;1===r.version&&t.w(`Vector tile source "${this.source}" layer "${i}" does not use vector tile spec v2 and therefore may have some rendering errors.`);const f=a.encode(i),m=[];for(let t=0;t=e.maxzoom||"none"!==e.visibility&&(l(t,this.zoom,h.brightness,n),(d[e.id]=e.createBucket({index:c.bucketLayerIDs.length,layers:t,zoom:this.zoom,lut:this.lut,canonical:this.canonical,pixelRatio:this.pixelRatio,overscaling:this.overscaling,collisionBoxArray:this.collisionBoxArray,sourceLayerIndex:f,sourceID:this.source,projection:this.projection.spec,tessellationStep:this.tessellationStep})).populate(m,h,this.tileID.canonical,this.tileTransform),c.bucketLayerIDs.push(t.map((t=>t.id)))))}}let f,m,_,g;u.trim();const y={type:"maybePrepare",isSymbolTile:this.isSymbolTile,zoom:this.zoom},v=()=>{if(f)return this.status="done",o(f);if(this.extraShadowCaster)this.status="done",o(null,{buckets:t.dG(d).filter((t=>!t.isEmpty())),featureIndex:c,collisionBoxArray:null,glyphAtlasImage:null,lineAtlas:null,imageAtlas:null,brightness:h.brightness,glyphMap:null,iconMap:null,glyphPositions:null});else if(m&&_&&g){const e=new s(m),i=new t.dQ(_,g,this.lut);for(const r in d){const o=d[r];o instanceof t.dR?(l(o.layers,this.zoom,h.brightness,n),t.dS(o,m,e.positions,_,i.iconPositions,this.showCollisionBoxes,n,this.tileID.canonical,this.tileZoom,this.projection,this.brightness)):o.hasPattern&&(o instanceof t.dT||o instanceof t.dU||o instanceof t.b_)&&(l(o.layers,this.zoom,h.brightness,n),o.addFeatures(h,this.tileID.canonical,i.patternPositions,n,this.tileTransform,this.brightness))}this.status="done",o(null,{buckets:t.dG(d).filter((t=>!t.isEmpty())),featureIndex:c,collisionBoxArray:this.collisionBoxArray,glyphAtlasImage:e.image,lineAtlas:u,imageAtlas:i,brightness:h.brightness})}};if(!this.extraShadowCaster){const e=t.dP(h.glyphDependencies,(t=>Object.keys(t).map(Number)));Object.keys(e).length?r.send("getGlyphs",{uid:this.uid,stacks:e,scope:this.scope},((t,e)=>{f||(f=t,m=e,v())}),void 0,!1,y):m={};const i=Object.keys(h.iconDependencies);i.length?r.send("getImages",{icons:i,source:this.source,scope:this.scope,tileID:this.tileID,type:"icons"},((t,e)=>{f||(f=t,_=e,v())}),void 0,!1,y):_={};const n=Object.keys(h.patternDependencies);n.length?r.send("getImages",{icons:n,source:this.source,scope:this.scope,tileID:this.tileID,type:"patterns"},((t,e)=>{f||(f=t,g=e,v())}),void 0,!1,y):g={}}v()}}function l(e,i,n,r){const o=new t.X(i,{brightness:n});for(const t of e)t.recalculate(o,r)}class c extends t.E{constructor(e,i,n,r,o,s){super(),this.actor=e,this.layerIndex=i,this.availableImages=n,this.loadVectorData=o||t.ap,this.loading={},this.loaded={},this.deduped=new t.ao(e.scheduler),this.isSpriteLoaded=r,this.scheduler=e.scheduler,this.brightness=s}loadTile(i,n){const r=i.uid,o=i&&i.request,s=o&&o.collectResourceTiming,l=this.loading[r]=new a(i);l.abort=this.loadVectorData(i,((a,c)=>{const d=!this.loading[r];if(delete this.loading[r],d||a||!c)return l.status="done",d||(this.loaded[r]=l),n(a);const u=c.rawData,h={};c.expires&&(h.expires=c.expires),c.cacheControl&&(h.cacheControl=c.cacheControl),l.vectorTile=c.vectorTile||new t.dV(new t.dW(u));const p=()=>{l.parse(l.vectorTile,this.layerIndex,this.availableImages,this.actor,((i,r)=>{if(i||!r)return n(i);const a={};if(s){const t=e(o);t.length>0&&(a.resourceTiming=JSON.parse(JSON.stringify(t)))}n(null,t.W({rawTileData:u.slice(0)},r,h,a))}))};this.isSpriteLoaded?p():this.once("isSpriteLoaded",(()=>{this.scheduler?this.scheduler.add(p,{type:"parseTile",isSymbolTile:i.isSymbolTile,zoom:i.tileZoom}):p()})),this.loaded=this.loaded||{},this.loaded[r]=l}))}reloadTile(e,i){const n=this.loaded,r=e.uid;if(n&&n[r]){const o=n[r];o.showCollisionBoxes=e.showCollisionBoxes,o.projection=e.projection,o.brightness=e.brightness,o.tileTransform=t.dK(e.tileID.canonical,e.projection),o.extraShadowCaster=e.extraShadowCaster,o.lut=e.lut;const s=(t,e)=>{const n=o.reloadCallback;n&&(delete o.reloadCallback,o.parse(o.vectorTile,this.layerIndex,this.availableImages,this.actor,n)),i(t,e)};"parsing"===o.status?o.reloadCallback=s:"done"===o.status&&(o.vectorTile?o.parse(o.vectorTile,this.layerIndex,this.availableImages,this.actor,s):s())}else i(null,void 0)}abortTile(t,e){const i=t.uid,n=this.loading[i];n&&(n.abort&&n.abort(),delete this.loading[i]),e()}removeTile(t,e){const i=this.loaded,n=t.uid;i&&i[n]&&delete i[n],e()}}class d{loadTile(e,i){const{uid:n,encoding:r,rawImageData:o,padding:s}=e,a=ImageBitmap&&o instanceof ImageBitmap?this.getImageData(o,s):o;i(null,new t.dX(n,a,r,s{n(null,t)}),(t=>{n(t)}))}}const h=t.dZ.prototype.toGeoJSON;let p=class{constructor(e){this._feature=e,this.extent=t.a3,this.type=e.type,this.properties=e.tags,"id"in e&&!isNaN(e.id)&&(this.id=parseInt(e.id,10))}loadGeometry(){if(1===this._feature.type){const e=[];for(const i of this._feature.geometry)e.push([new t.P(i[0],i[1])]);return e}{const e=[];for(const i of this._feature.geometry){const n=[];for(const e of i)n.push(new t.P(e[0],e[1]));e.push(n)}return e}}toGeoJSON(t,e,i){return h.call(this,t,e,i)}},f=class{constructor(e){this.layers={_geojsonTileLayer:this},this.name="_geojsonTileLayer",this.extent=t.a3,this.length=e.length,this._features=e}feature(t){return new p(this._features[t])}};const m=64/4096;class _{constructor(){this.features=new Map}clear(){this.features.clear()}load(t=[],e){for(const i of t){const t=i.id;if(null==t)continue;let n=this.features.get(t);n&&this.updateCache(n,e),i.geometry?(n=y(i),this.updateCache(n,e),this.features.set(t,n)):this.features.delete(t),this.updateCache(n,e)}}updateCache(t,e){for(const{canonical:i,uid:n}of Object.values(e)){const{z:r,x:o,y:s}=i;g(t,Math.pow(2,r),o,s)&&delete e[n]}}getTile(t,e,i){const n=Math.pow(2,t),r=[];for(const t of this.features.values())g(t,n,e,i)&&r.push(w(t,n,e,i));return{features:r}}getFeatures(){return[...this.features.values()]}}function g({minX:t,minY:e,maxX:i,maxY:n},r,o,s){return t(o-m)/r&&n>(s-m)/r}function y(t){const{id:e,geometry:i,properties:n}=t;if(!i)return;if("GeometryCollection"===i.type)throw new Error("GeometryCollection not supported in dynamic mode.");const{type:r,coordinates:o}=i,s={id:e,type:1,geometry:[],tags:n,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0},a=s.geometry;if("Point"===r)v(o,a,s);else if("MultiPoint"===r)for(const t of o)v(t,a,s);else if("LineString"===r)s.type=2,x(o,a,s);else if("MultiLineString"===r)s.type=2,b(o,a,s);else if("Polygon"===r)s.type=3,b(o,a,s,!0);else{if("MultiPolygon"!==r)throw new Error("Input data is not a valid GeoJSON object.");s.type=3;for(const t of o)b(t,a,s,!0)}return s}function v([e,i],n,r){const o=t.aj(e);let s=t.ak(i);s=s1?1:s,n.push(o,s),r.minX=Math.min(r.minX,o),r.minY=Math.min(r.minY,s),r.maxX=Math.max(r.maxX,o),r.maxY=Math.max(r.maxY,s)}function x(t,e,i,n=!1,r=!1){const o=[];for(const e of t)v(e,o,i);e.push(o),n&&function(t,e){let i=0;for(let e=0,n=t.length,r=n-2;e0===e)for(let e=0,i=t.length;e>31}function F(t,e){for(var i=t.loadGeometry(),n=t.type,r=0,o=0,s=i.length,a=0;at},V=Math.fround||(G=new Float32Array(1),t=>(G[0]=+t,G[0]));var G;const Z=3,q=5,H=6;class W{constructor(t){this.options=Object.assign(Object.create(j),t),this.trees=new Array(this.options.maxZoom+1),this.stride=this.options.reduce?7:6,this.clusterProps=[]}load(t){const{log:e,minZoom:i,maxZoom:n}=this.options;e&&console.time("total time");const r=`prepare ${t.length} points`;e&&console.time(r),this.points=t;const o=[];for(let e=0;e=i;t--){const i=+Date.now();s=this.trees[t]=this._createTree(this._cluster(s,t)),e&&console.log("z%d: %d clusters in %dms",t,s.numItems,+Date.now()-i)}return e&&console.timeEnd("total time"),this}getClusters(t,e){let i=((t[0]+180)%360+360)%360-180;const n=Math.max(-90,Math.min(90,t[1]));let r=180===t[2]?180:((t[2]+180)%360+360)%360-180;const o=Math.max(-90,Math.min(90,t[3]));if(t[2]-t[0]>=360)i=-180,r=180;else if(i>r){const t=this.getClusters([i,n,180,o],e),s=this.getClusters([-180,n,r,o],e);return t.concat(s)}const s=this.trees[this._limitZoom(e)],a=s.range(K(i),J(o),K(r),J(n)),l=s.data,c=[];for(const t of a){const e=this.stride*t;c.push(l[e+q]>1?Y(l,e,this.clusterProps):this.points[l[e+Z]])}return c}getChildren(t){const e=this._getOriginId(t),i=this._getOriginZoom(t),n="No cluster with the specified id.",r=this.trees[i];if(!r)throw new Error(n);const o=r.data;if(e*this.stride>=o.length)throw new Error(n);const s=this.options.radius/(this.options.extent*Math.pow(2,i-1)),a=r.within(o[e*this.stride],o[e*this.stride+1],s),l=[];for(const e of a){const i=e*this.stride;o[i+4]===t&&l.push(o[i+q]>1?Y(o,i,this.clusterProps):this.points[o[i+Z]])}if(0===l.length)throw new Error(n);return l}getLeaves(t,e,i){const n=[];return this._appendLeaves(n,t,e=e||10,i=i||0,0),n}getTile(t,e,i){const n=this.trees[this._limitZoom(t)],r=Math.pow(2,t),{extent:o,radius:s}=this.options,a=s/o,l=(i-a)/r,c=(i+1+a)/r,d={features:[]};return this._addTileFeatures(n.range((e-a)/r,l,(e+1+a)/r,c),n.data,e,i,r,d),0===e&&this._addTileFeatures(n.range(1-a/r,l,1,c),n.data,r,i,r,d),e===r-1&&this._addTileFeatures(n.range(0,l,a/r,c),n.data,-1,i,r,d),d.features.length?d:null}getClusterExpansionZoom(t){let e=this._getOriginZoom(t)-1;for(;e1;let l,c,d;if(a)l=X(e,t,this.clusterProps),c=e[t],d=e[t+1];else{const i=this.points[e[t+Z]];l=i.properties;const[n,r]=i.geometry.coordinates;c=K(n),d=J(r)}const u={type:1,geometry:[[Math.round(this.options.extent*(c*r-i)),Math.round(this.options.extent*(d*r-n))]],tags:l};let h;h=a||this.options.generateId?e[t+Z]:this.points[e[t+Z]].id,void 0!==h&&(u.id=h),o.features.push(u)}}_limitZoom(t){return Math.max(this.options.minZoom,Math.min(Math.floor(+t),this.options.maxZoom+1))}_cluster(t,e){const{radius:i,extent:n,reduce:r,minPoints:o}=this.options,s=i/(n*Math.pow(2,e)),a=t.data,l=[],c=this.stride;for(let i=0;ie&&(p+=a[i+q])}if(p>h&&p>=o){let t,o=n*h,s=d*h,f=-1;const m=(i/c1)for(const t of u){const i=t*c;if(!(a[i+2]>5}_getOriginZoom(t){return(t-this.points.length)%32}_map(t,e,i){if(t[e+q]>1){const n=this.clusterProps[t[e+H]];return i?Object.assign({},n):n}const n=this.points[t[e+Z]].properties,r=this.options.map(n);return i&&r===n?Object.assign({},r):r}}function Y(t,e,i){return{type:"Feature",id:t[e+Z],properties:X(t,e,i),geometry:{type:"Point",coordinates:[(n=t[e],360*(n-.5)),Q(t[e+1])]}};var n}function X(t,e,i){const n=t[e+q],r=n>=1e4?`${Math.round(n/1e3)}k`:n>=1e3?Math.round(n/100)/10+"k":n,o=t[e+H],s=-1===o?{}:Object.assign({},i[o]);return Object.assign(s,{cluster:!0,cluster_id:t[e+Z],point_count:n,point_count_abbreviated:r})}function K(t){return t/360+.5}function J(t){const e=Math.sin(t*Math.PI/180),i=.5-.25*Math.log((1+e)/(1-e))/Math.PI;return i1?1:i}function Q(t){const e=(180-360*t)*Math.PI/180;return 360*Math.atan(Math.exp(e))/Math.PI-90}function tt(t,e,i,n){let r=n;const o=e+(i-e>>1);let s,a=i-e;const l=t[e],c=t[e+1],d=t[i],u=t[i+1];for(let n=e+3;n =e&&o(s,a,l,c,d,e),h>i&&u=e&&l=s[i]&&(n=e,s=t),n[i]r&&Mp(n,s,i,r),n[i]o&&Mp(s,n,i,o)}}function Ap(t,e){return t.x-e.x||t.y-e.y}function Ip(t,e){return 0===Ap(t.min,e.min)&&0===Ap(t.max,e.max)}function Lp(t,e){return!(t.min.x>e.max.x||t.max.xe.max.y||t.max.ynew Ue((t.x+o.x*uo)*a-s.x*uo,(t.y+o.y*uo)*a-s.y*uo)))}return Dp(i,r,t.indices,0,t.indices.length,0,0)}function Rp(t,e,i,n){const r=Math.pow(2,n.z-i.z);return new Ue((t+i.x*uo)*r-n.x*uo,(e+i.y*uo)*r-n.y*uo)}function Op(t,e){const i=[];e.footprint.grid.queryPoint(t,i);const n=e.footprint.indices,r=e.footprint.vertices;for(let e=0;ee[s])return null}else{const a=1/n[s];let l=(t[s]-i[s])*a,c=(e[s]-i[s])*a;if(l>c){const t=l;l=c,c=t}if(l>r&&(r=l),co)return null}return r}function Np(t,e,i,n,r,o,s,a,l,c,d){const u=n-t,h=r-e,p=o-i,f=s-t,m=a-e,_=l-i,g=d[1]*_-d[2]*m,y=d[2]*f-d[0]*_,v=d[0]*m-d[1]*f,x=u*g+h*y+p*v;if(Math.abs(x)1)return null;const M=T*p-S*h,C=S*u-w*p,A=w*h-T*u,I=(d[0]*M+d[1]*C+d[2]*A)*b;return I1?null:(f*M+m*C+_*A)*b}function Up(t,e,i){return(t-e)/(i-e)}function jp(t,e,i,n,r,o,s,a,l){const c=1{const o=n?1:0,s=(t+1)*i-o,a=e*i,l=(e+1)*i-o;r[0]=t*i,r[1]=a,r[2]=s,r[3]=l};let s=new Bp(n);const a=[];for(let e=0;e=1;n/=2){const t=i[i.length-1];s=new Bp(n);for(let e=0;e0;){const{idx:l,t:f,nodex:m,nodey:_,depth:g}=p.pop();if(this.leaves[l]){jp(m,_,g,e,i,n,r,u,h);const l=1=e[2])return f}continue}let y=0;for(let t=0;t=c[d[n]]&&(d.splice(n,0,t),i=!0);i||(d[y]=t),y++}}for(let t=0;t=this.dim+1||e=this.dim+1)throw new RangeError("out of range source coordinates for DEM data");return(e+1)*this.stride+(t+1)}static pack(t,e){const i=[0,0,0,0],n=Yp.getUnpackVector(e);let r=Math.floor((t+n[3])/n[2]);return i[2]=r%256,r=Math.floor(r/256),i[1]=r%256,r=Math.floor(r/256),i[0]=r,i}getPixels(){return new hh({width:this.stride,height:this.stride},this.pixels)}backfillBorder(t,e,i){if(this.dim!==t.dim)throw new Error("dem dimension mismatch");let n=e*this.dim,r=e*this.dim+this.dim,o=i*this.dim,s=i*this.dim+this.dim;switch(e){case-1:n=r-1;break;case 1:r=n+1}switch(i){case-1:o=s-1;break;case 1:s=o+1}const a=-e*this.dim,l=-i*this.dim;for(let e=o;et.max.x&&(t.max.x=e.x,n=!0),e.yt.max.y&&(t.max.y=e.y,n=!0),((0===e.x||e.x===uo)&&e.x===i.x)!=((0===e.y||e.y===uo)&&e.y===i.y)&&this.processBorderOverlap(e,i),n&&this.checkBorderIntersection(e,i)}checkBorderIntersection(t,e){e.xuo!=t.x>uo&&this.addBorderIntersection(1,Vn(e.y,t.y,(uo-e.x)/(t.x-e.x))),e.yuo!=t.y>uo&&this.addBorderIntersection(3,Vn(e.x,t.x,(uo-e.y)/(t.y-e.y)))}addBorderIntersection(t,e){this.borders||(this.borders=[[Number.MAX_VALUE,-Number.MAX_VALUE],[Number.MAX_VALUE,-Number.MAX_VALUE],[Number.MAX_VALUE,-Number.MAX_VALUE],[Number.MAX_VALUE,-Number.MAX_VALUE]]);const i=this.borders[t];ei[1]&&(i[1]=e)}processBorderOverlap(t,e){if(t.x===e.x){if(t.y===e.y)return;const i=0===t.x?0:1;this.addBorderIntersection(i,e.y),this.addBorderIntersection(i,t.y)}else{const i=0===t.y?2:3;this.addBorderIntersection(i,e.x),this.addBorderIntersection(i,t.x)}}centroid(){return 0===this.accCount?new Ue(0,0):new Ue(Math.floor(Math.max(0,this.acc.x)/this.accCount),Math.floor(Math.max(0,this.acc.y)/this.accCount))}intersectsCount(){return this.borders?this.borders.reduce(((t,e)=>t+ +(e[0]!==Number.MAX_VALUE)),0):0}}function hf(t,e){const i=t.add(e)._unit(),n=Xe(t.x*i.x+t.y*i.y,-1,1);var r,o,s;return r=Math.acos(n),Math.min(4,Math.max(-4,Math.tan(r)))/4*nf*((o=t).x*(s=e).y-o.y*s.xt.xt.x>uo,t=>t.yt.y>uo];function ff(t,e,i,n){const r=[4];if(0===n)return r;i._mult(n);const o=t.sub(i),s=e.sub(i),a=[t,e,o,s];for(let t=0;ttf.includes(t))),this._segments=new wc,this.hiddenByLandmarkVertexArray=new lc,this._segmentToGroundQuads={},this._segmentToGroundQuads[0]=[],this._segmentToRegionTriCounts={},this._segmentToRegionTriCounts[0]=[0,0,0,0,0],this.regionSegments={},this.regionSegments[4]=new wc}getDefaultSegment(){return this.regionSegments[4]}hasData(){return 0!==this.vertexArray.length}addData(t,e,i,n=!1){const r=t.length;if(r>2){let o=Math.max(0,this._segments.get().length-1);const s=this._segments._prepareSegment(4*r,this.vertexArray.length,2*this._segmentToGroundQuads[o].length);let a;o!==this._segments.get().length-1&&(o++,this._segmentToGroundQuads[o]=[],this._segmentToRegionTriCounts[o]=[0,0,0,0,0]);{const e=t[0],i=t[1];a=hf(e.sub(t[r-1])._perp()._unit(),i.sub(e)._perp()._unit())}for(let l=0;lt.region-e.region));for(let i=0;it+e),0);let o=0;for(let t=0;t0?this.hiddenByLandmarkVertexBuffer=t.createVertexBuffer(this.hiddenByLandmarkVertexArray,sp.members,!0):this.hiddenByLandmarkVertexBuffer&&this.hiddenByLandmarkVertexBuffer.updateData(this.hiddenByLandmarkVertexArray),this._needsHiddenByLandmarkUpdate=!1)}destroy(){if(this.vertexBuffer){this.vertexBuffer.destroy(),this.indexBuffer.destroy(),this.hiddenByLandmarkVertexBuffer&&this.hiddenByLandmarkVertexBuffer.destroy(),this._segments&&this._segments.destroy(),this.programConfigurations.destroy();for(let t=0;tt.fqid)),this.index=t.index,this.hasPattern=!1,this.edgeRadius=0,this.projection=t.projection,this.activeReplacements=[],this.replacementUpdateTime=0,this.centroidData=[],this.footprintIndices=new Kl,this.footprintVertices=new $l,this.footprintSegments=[],this.layoutVertexArray=new Dl,this.centroidVertexArray=new vc,this.indexArray=new Kl,this.programConfigurations=new Yc(t.layers,{zoom:t.zoom,lut:t.lut},(t=>Qp.includes(t))),this.segments=new wc,this.stateDependentLayerIds=this.layers.filter((t=>t.isStateDependent())).map((t=>t.id)),this.groundEffect=new mf(t),this.maxHeight=0,this.partLookup={},this.triangleSubSegments=[],this.polygonSegments=[]}updateFootprints(t,e){}populate(t,e,i,n){this.features=[],this.hasPattern=Hh("fill-extrusion",this.layers,e),this.featuresOnBorder=[],this.borderFeatureIndices=[[],[],[],[]],this.borderDoneWithNeighborZ=[-1,-1,-1,-1],this.tileToMeter=zd(i),this.edgeRadius=this.layers[0].layout.get("fill-extrusion-edge-radius")/this.tileToMeter;for(const{feature:r,id:o,index:s,sourceLayerIndex:a}of t){const t=this.layers[0]._featureFilter.needGeometry,l=Zd(r,t);if(!this.layers[0]._featureFilter.filter(new Ha(this.zoom),l,i))continue;const c={id:o,sourceLayerIndex:a,index:s,geometry:t?l.geometry:Gd(r,i,n),properties:r.properties,type:r.type,patterns:{}},d=this.layoutVertexArray.length;this.hasPattern?this.features.push(Wh("fill-extrusion",this.layers,c,this.zoom,e)):this.addFeature(c,c.geometry,s,i,{},e.availableImages,n,e.brightness),e.featureIndex.insert(r,c.geometry,s,a,this.index,d)}this.sortBorders(),"mercator"===this.projection.name&&this.splitToSubtiles(),this.groundEffect.prepareBorderSegments(),this.polygonSegments.length=0}addFeatures(t,e,i,n,r,o){for(const t of this.features){const{geometry:s}=t;this.addFeature(t,s,t.index,e,i,n,r,o)}this.sortBorders(),"mercator"===this.projection.name&&this.splitToSubtiles()}update(t,e,i,n,r){const o=0!==Object.keys(t).length;if(o&&!this.stateDependentLayers.length)return;const s=o?this.stateDependentLayers:this.layers;this.programConfigurations.updatePaintArrays(t,e,s,i,n,r),this.groundEffect.update(t,e,s,i,n,r)}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload||this.groundEffect.programConfigurations.needsUpload}upload(t){this.uploaded||(this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,lp),this.indexBuffer=t.createIndexBuffer(this.indexArray),this.layoutVertexExtArray&&(this.layoutVertexExtBuffer=t.createVertexBuffer(this.layoutVertexExtArray,ap.members,!0)),this.groundEffect.upload(t)),this.groundEffect.uploadPaintProperties(t),this.programConfigurations.upload(t),this.uploaded=!0}uploadCentroid(t){this.groundEffect.uploadHiddenByLandmark(t),this.needsCentroidUpdate&&(!this.centroidVertexBuffer&&this.centroidVertexArray.length>0?this.centroidVertexBuffer=t.createVertexBuffer(this.centroidVertexArray,op.members,!0):this.centroidVertexBuffer&&this.centroidVertexBuffer.updateData(this.centroidVertexArray),this.needsCentroidUpdate=!1)}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.centroidVertexBuffer&&this.centroidVertexBuffer.destroy(),this.layoutVertexExtBuffer&&this.layoutVertexExtBuffer.destroy(),this.groundEffect.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy())}addFeature(t,e,i,n,r,o,s,a){const l=this.layers[0].paint.get("fill-extrusion-flood-light-ground-radius").evaluate(t,{})/this.tileToMeter,c=[new Ue(0,0),new Ue(uo,uo)],d=s.projection,u="globe"===d.name,h="Polygon"===Jp[t.type],p=new uf;p.centroidDataIndex=this.centroidData.length;const f=new df,m=this.layers[0].paint.get("fill-extrusion-base").evaluate(t,{},n)=0;t--){const e=g[t];(0===e.length||(y=e[0]).every((t=>t.xt.x>=uo))||y.every((t=>t.yt.y>=uo)))&&g.splice(t,1)}var y;let v;if(u)v=Ef(g,c,n);else{v=[];for(const t of g)v.push({polygon:t,bounds:c})}const x=h?this.edgeRadius:0,b=x>0&&this.zoom{if(0===t.length)return!1;const i=t[t.length-1];return e.x===i.x&&e.y===i.y};for(const{polygon:t,bounds:e}of v){let i=0,r=0;for(const e of t)h&&!e[0].equals(e[e.length-1])&&e.push(e[0]),r+=h?e.length-1:e.length;const o=this.segments.prepareSegment((h?5:4)*r,this.layoutVertexArray,this.indexArray);f.footprintSegIdx4&&wf(s[s.length-2],s[0],s[1]),c=x?yf(s[s.length-2],s[0],s[1],x):0;const _=[];let g,y,v;y=s[1].sub(s[0])._perp()._unit();let b=!0;for(let t=1,r=0;t0?1:0,C=l.dist(h);if(r+C>32768&&(r=0),x){v=T.sub(h)._perp()._unit();let t=vf(l,h,T,gf(y,v),x);isNaN(t)&&(t=0);const e=h.sub(l)._unit();l=l.add(e.mult(c))._round(),h=h.add(e.mult(-t))._round(),c=t,y=v,m&&this.zoom>=17&&(w(_,l)||_.push(l),w(_,h)||_.push(h))}const A=o.vertexLength,I=s.length>4&&wf(l,h,T);let L=Tf(r,a,b);if(sf(this.layoutVertexArray,l.x,l.y,E,M,0,0,L),sf(this.layoutVertexArray,l.x,l.y,E,M,0,1,L),r+=C,L=Tf(r,I,!b),a=I,sf(this.layoutVertexArray,h.x,h.y,E,M,0,0,L),sf(this.layoutVertexArray,h.x,h.y,E,M,0,1,L),o.vertexLength+=4,this.indexArray.emplaceBack(A+0,A+1,A+2),this.indexArray.emplaceBack(A+1,A+3,A+2),o.primitiveLength+=2,x){const n=i+(1===t?s.length-2:t-2),r=1===t?i:n+1;if(this.indexArray.emplaceBack(A+1,n,A+3),this.indexArray.emplaceBack(n,r,A+3),o.primitiveLength+=2,void 0===g&&(g=A),!xf(T,s[t],e)){const e=t===s.length-1?g:o.vertexLength;this.indexArray.emplaceBack(A+2,A+3,e),this.indexArray.emplaceBack(A+3,e+1,e),this.indexArray.emplaceBack(A+3,r,e+1),o.primitiveLength+=3}b=!b}if(u){const t=this.layoutVertexExtArray,e=d.projectTilePoint(l.x,l.y,n),i=d.projectTilePoint(h.x,h.y,n),r=d.upVector(n,l.x,l.y),o=d.upVector(n,h.x,h.y);lf(t,e,r),lf(t,e,r),lf(t,i,o),lf(t,i,o)}}h&&(i+=s.length-1),m&&x&&this.zoom>=17&&(0!==_.length&&w(_,_[0])&&_.pop(),this.groundEffect.addData(_,e,l,x>0))}this.footprintSegments.push(a),s.triangleCount=this.indexArray.length-s.triangleArrayOffset,this.polygonSegments.push(s),++f.footprintSegLen,++f.polygonSegLen}if(f.vertexCount=this.layoutVertexArray.length-f.vertexArrayOffset,f.groundVertexCount=this.groundEffect.vertexArray.length-f.groundVertexArrayOffset,0!==f.vertexCount){if(f.centroidXY=p.borders?rf:this.encodeCentroid(p,f),this.centroidData.push(f),p.borders){this.featuresOnBorder.push(p);const t=this.featuresOnBorder.length-1;for(let e=0;ethis.featuresOnBorder[e].borders[t][0]-this.featuresOnBorder[i].borders[t][0]))}splitToSubtiles(){const t=[];for(let e=0;euo),r=2*n+(+(i.min.x+i.max.x>uo)^n);for(let n=0;nt.triangleSegmentIdx===e.triangleSegmentIdx?t.subtile-e.subtile:t.triangleSegmentIdx-e.triangleSegmentIdx));let i=0,n=0,r=0;for(const e of t){if(e.triangleSegmentIdx!==i)break;r++}const o=t.length;for(;n!==t.length;){i=t[n].triangleSegmentIdx;let s=0,a=n,l=n;for(let e=a;e0&&this.triangleSubSegments.push({segment:d,min:o,max:c}),a=l;for(let e=a;e[t[0]*(1-i[0])+e[0]*i[0],t[1]*(1-i[1])+e[1]*i[1]],h=[],p=[];for(const t of this.triangleSubSegments){h[0]=t.min.x/uo,h[1]=t.min.y/uo,p[0]=t.max.x/uo,p[1]=t.max.y/uo;const e=u(l,c,h),o=u(l,c,p);if(0===new wu([e[0],e[1],n],[o[0],o[1],r]).intersectsPrecise(i)){a&&(d.segments.push(a),a=void 0);continue}const s=t.segment;a&&a.vertexOffset!==s.vertexOffset&&(d.segments.push(a),a=void 0),a?(a.vertexLength+=s.vertexLength,a.primitiveLength+=s.primitiveLength):a={vertexOffset:s.vertexOffset,primitiveLength:s.primitiveLength,vertexLength:s.vertexLength,primitiveOffset:s.primitiveOffset,sortKey:void 0,vaos:{}}}return a&&d.segments.push(a),d}encodeCentroid(t,e){const i=t.centroid(),n=e.span(),r=Math.min(7,Math.round(n.x*this.tileToMeter/10)),o=Math.min(7,Math.round(n.y*this.tileToMeter/10));return new Ue(Xe(i.x,1,uo-1)i.max.x||i.min.x>e.max.x||e.min.y>i.max.y||i.min.y>e.max.y))for(let o=0;oe!=l>e&&to.max.x||o.min.x>t||e>o.max.y||o.min.y>e||this.footprintContainsPoint(t,e,o)&&o&&o.height>i&&(i=o.height,this.partLookup[r]=o,n=!!(o.flags&of));if(i!==Number.NEGATIVE_INFINITY)return{height:i,hidden:n};this.partLookup[r]=void 0}}function gf(t,e){const i=t.add(e)._unit();return t.x*i.x+t.y*i.y}function yf(t,e,i,n){const r=e.sub(t)._perp()._unit(),o=i.sub(e)._perp()._unit();return vf(t,e,i,gf(r,o),n)}function vf(t,e,i,n,r){const o=Math.sqrt(1-n*n);return Math.min(t.dist(e)/3,e.dist(i)/3,r*o/n)}function xf(t,e,i){return t.xi[1].x&&e.x>i[1].x||t.yi[1].y&&e.y>i[1].y}function bf(t,e){return t.xe[1].x||t.ye[1].y}function wf(t,e,i){if(t.x=uo||e.x=uo||i.x=uo)return!1;const n=i.sub(e),r=n.perp(),o=t.sub(e);return(n.x*o.x+n.y*o.y)/Math.sqrt((n.x*n.x+n.y*n.y)*(o.x*o.x+o.y*o.y))>-.866&&r.x*o.x+r.y*o.y{for(const i of t)s.push({polygon:i,bounds:e})},l=Math.ceil(Math.log2(i)),c=Math.ceil(Math.log2(n)),d=l-c,u=[];for(let t=0;t0?0:1);for(let t=0;te+1?p.push({polygons:h,bounds:t,depth:e+1}):a(h,t)}if(f.length){const t=[new Ue(0===i?d:n.x,1===i?d:n.y),s];u.length>e+1?p.push({polygons:f,bounds:t,depth:e+1}):a(f,t)}}return s}(t,e,Math.ceil((o-r)/11.25),Math.ceil((s-a)/11.25),1,((t,e,r)=>{if(0===t)return.5*(e+r);{const t=Id((i.y+e/uo)/n);return(Md(.5*(Id((i.y+r/uo)/n)+t))*n-i.y)*uo}}))}function Mf(t,e,i,n,r,o){const s=Math.pow(2,n.z-r.z);for(let a=0;a1&&(s=t[++o]);const l=Math.abs(a-s.left),c=Math.abs(a-s.right),d=Math.min(l,c);let u;const h=e/i*(n+1);if(s.isDash){const t=n-Math.abs(h);u=Math.sqrt(d*d+t*t)}else u=n-Math.sqrt(d*d+h*h);this.image.data[r+a]=Math.max(0,Math.min(255,u+128))}}}addRegularDash(t,e){for(let e=t.length-1;e>=0;--e){const i=t[e],n=t[e+1];i.zeroLength?t.splice(e,1):n&&n.isDash===i.isDash&&(n.left=i.left,t.splice(e,1))}const i=t[0],n=t[t.length-1];i.isDash===n.isDash&&(i.left=n.left-this.width,n.right=i.right+this.width);const r=this.width*this.nextRow;let o=0,s=t[o];for(let i=0;i1&&(s=t[++o]);const n=Math.abs(i-s.left),a=Math.abs(i-s.right),l=Math.min(n,a);this.image.data[r+i]=Math.max(0,Math.min(255,(s.isDash?l:-l)+e+128))}}addDash(t,e){const i=this.getKey(t,e);if(this.positions[i])return this.positions[i];const n="round"===e,r=n?7:0,o=2*r+1;if(this.nextRow+o>this.height)return pi("LineAtlas out of space"),null;0===t.length&&t.push(1);let s=0;for(let e=0;et.fqid)),this.index=t.index,this.projection=t.projection,this.hasPattern=!1,this.hasZOffset=!1,this.patternFeatures=[],this.lineClipsArray=[],this.gradients={},this.layers.forEach((t=>{this.gradients[t.id]={}})),this.layoutVertexArray=new Rl,this.layoutVertexArray2=new Ol,this.patternVertexArray=new Bl,this.indexArray=new Kl,this.programConfigurations=new Yc(t.layers,{zoom:t.zoom,lut:t.lut}),this.segments=new wc,this.maxLineLength=0,this.zOffsetVertexArray=new Zl,this.stateDependentLayerIds=this.layers.filter((t=>t.isStateDependent())).map((t=>t.id)),this.tessellationStep=t.tessellationStep?t.tessellationStep:uo/64}updateFootprints(t,e){}populate(t,e,i,n){this.hasPattern=Hh("line",this.layers,e);const r=this.layers[0].layout.get("line-sort-key"),o=this.layers[0].layout.get("line-z-offset");this.hasZOffset=!o.isConstant()||!!o.constantOr(0);const s=[];for(const{feature:e,id:o,index:a,sourceLayerIndex:l}of t){const t=this.layers[0]._featureFilter.needGeometry,c=Zd(e,t);if(!this.layers[0]._featureFilter.filter(new Ha(this.zoom),c,i))continue;const d=r?r.evaluate(c,{},i):void 0,u={id:o,properties:e.properties,type:e.type,sourceLayerIndex:l,index:a,geometry:t?c.geometry:Gd(e,i,n),patterns:{},sortKey:d};s.push(u)}r&&s.sort(((t,e)=>t.sortKey-e.sortKey));const{lineAtlas:a,featureIndex:l}=e,c=this.addConstantDashes(a);for(const n of s){const{geometry:r,index:o,sourceLayerIndex:s}=n;if(c&&this.addFeatureDashes(n,a),this.hasPattern){const t=Wh("line",this.layers,n,this.zoom,e);this.patternFeatures.push(t)}else this.addFeature(n,r,o,i,a.positions,e.availableImages,e.brightness);l.insert(t[o].feature,r,o,s,this.index)}}addConstantDashes(t){let e=!1;for(const i of this.layers){const n=i.paint.get("line-dasharray").value,r=i.layout.get("line-cap").value;if("constant"!==n.kind||"constant"!==r.kind)e=!0;else{const e=r.value,i=n.value;if(!i)continue;t.addDash(i,e)}}return e}addFeatureDashes(t,e){const i=this.zoom;for(const n of this.layers){const r=n.paint.get("line-dasharray").value,o=n.layout.get("line-cap").value;if("constant"===r.kind&&"constant"===o.kind)continue;let s,a;if("constant"===r.kind){if(s=r.value,!s)continue}else s=r.evaluate({zoom:i},t);a="constant"===o.kind?o.value:o.evaluate({zoom:i},t),e.addDash(s,a),t.patterns[n.id]=e.getKey(s,a)}}update(t,e,i,n,r){const o=0!==Object.keys(t).length;o&&!this.stateDependentLayers.length||this.programConfigurations.updatePaintArrays(t,e,o?this.stateDependentLayers:this.layers,i,n,r)}addFeatures(t,e,i,n,r,o){for(const t of this.patternFeatures)this.addFeature(t,t.geometry,t.index,e,i,n,o)}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(t){this.uploaded||(0!==this.layoutVertexArray2.length&&(this.layoutVertexBuffer2=t.createVertexBuffer(this.layoutVertexArray2,zf)),0!==this.patternVertexArray.length&&(this.patternVertexBuffer=t.createVertexBuffer(this.patternVertexArray,Of)),!this.zOffsetVertexBuffer&&this.zOffsetVertexArray.length>0&&(this.zOffsetVertexBuffer=t.createVertexBuffer(this.zOffsetVertexArray,jf.members,!0)),this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,kf),this.indexBuffer=t.createIndexBuffer(this.indexArray)),this.programConfigurations.upload(t),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.zOffsetVertexBuffer&&this.zOffsetVertexBuffer.destroy(),this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy())}lineFeatureClips(t){if(t.properties&&t.properties.hasOwnProperty("mapbox_clip_start")&&t.properties.hasOwnProperty("mapbox_clip_end"))return{start:+t.properties.mapbox_clip_start,end:+t.properties.mapbox_clip_end}}addFeature(t,e,i,n,r,o,s){const a=this.layers[0].layout,l=a.get("line-join").evaluate(t,{}),c=a.get("line-cap").evaluate(t,{}),d=a.get("line-miter-limit"),u=a.get("line-round-limit");this.lineClips=this.lineFeatureClips(t);for(const i of e)this.addLine(i,t,n,l,c,d,u);this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,t,i,r,o,n,s)}addLine(t,e,i,n,r,o,s){this.distance=0,this.scaledDistance=0,this.totalDistance=0,this.lineSoFar=0,this.currentVertex=void 0;const a={zoom:this.zoom,lineProgress:void 0},l=this.layers[0].layout,c="none"===n;if(this.patternJoinNone=this.hasPattern&&c,this.segmentStart=0,this.segmentStartf32=0,this.segmentPoints=[],this.lineClips){this.lineClipsArray.push(this.lineClips);for(let e=0;e=2&&t[u-1].equals(t[u-2]);)u--;let h=0;for(;h0;if(A&&i>h){const t=m.dist(_);if(t>2*p){const e=m.sub(m.sub(_)._mult(p/t)._round());this.updateDistance(_,e),this.addCurrentVertex(e,y,0,0,f,x),_=e}}if(b&&"round"===w&&(Mo&&(w="bevel"),"bevel"===w&&(M>2&&(w="flipbevel"),M100)S=v.mult(-1);else{const t=M*y.add(v).mag()/y.sub(v).mag();S._perp()._mult(t*(I?-1:1))}this.addCurrentVertex(m,S,0,0,f,x),this.addCurrentVertex(m,S.mult(-1),0,0,f,x)}else if("bevel"===w||"fakeround"===w){const t=-Math.sqrt(M*M-1),e=I?t:0,i=I?0:t;if(_&&this.addCurrentVertex(m,y,e,i,f,x),"fakeround"===w){const t=Math.round(180*C/Math.PI/20);for(let e=1;e2*p){const e=m.add(g.sub(m)._mult(p/t)._round());this.updateDistance(m,e),this.addCurrentVertex(e,v,0,0,f,x),m=e}}}}addVerticesTo(t,e,i,n,r,o,s,a,l,c){const d=(e.w-t.w)/this.tessellationStep|0;if(d>1){this.lineSoFar=t.w;const u=(e.x-t.x)/d,h=(e.y-t.y)/d,p=(e.z-t.z)/d,f=(e.w-t.w)/d;for(let e=1;e=0&&this.e2>=0&&(this.indexArray.emplaceBack(this.e1,this.e2,c),a.primitiveLength++),o?this.e2=c:this.e1=c,null!=l&&this.zOffsetVertexArray.emplaceBack(l)}updateScaledDistance(){if(this.lineClips){const t=this.totalDistance/(this.lineClips.end-this.lineClips.start);this.scaledDistance=this.distance/this.totalDistance,this.lineSoFar=t*this.lineClips.start+this.distance}else this.lineSoFar=this.distance}updateDistance(t,e){this.distance+=t.dist(e),this.updateScaledDistance()}}function Qf(t,e,i){return t.xi||t.yi}ba(Jf,"LineBucket",{omit:["layers","patternFeatures","currentVertex","currentVertexIsOutside"]});const tm=new ol({"line-cap":new nl(sl.layout_line["line-cap"]),"line-join":new nl(sl.layout_line["line-join"]),"line-miter-limit":new il(sl.layout_line["line-miter-limit"]),"line-round-limit":new il(sl.layout_line["line-round-limit"]),"line-sort-key":new nl(sl.layout_line["line-sort-key"]),"line-z-offset":new nl(sl.layout_line["line-z-offset"]),visibility:new il(sl.layout_line.visibility)});var em={paint:new ol({"line-opacity":new nl(sl.paint_line["line-opacity"]),"line-color":new nl(sl.paint_line["line-color"]),"line-translate":new il(sl.paint_line["line-translate"]),"line-translate-anchor":new il(sl.paint_line["line-translate-anchor"]),"line-width":new nl(sl.paint_line["line-width"]),"line-gap-width":new nl(sl.paint_line["line-gap-width"]),"line-offset":new nl(sl.paint_line["line-offset"]),"line-blur":new nl(sl.paint_line["line-blur"]),"line-dasharray":new nl(sl.paint_line["line-dasharray"]),"line-pattern":new nl(sl.paint_line["line-pattern"]),"line-gradient":new rl(sl.paint_line["line-gradient"]),"line-trim-offset":new il(sl.paint_line["line-trim-offset"]),"line-trim-fade-range":new il(sl.paint_line["line-trim-fade-range"]),"line-trim-color":new il(sl.paint_line["line-trim-color"]),"line-emissive-strength":new il(sl.paint_line["line-emissive-strength"]),"line-border-width":new nl(sl.paint_line["line-border-width"]),"line-border-color":new nl(sl.paint_line["line-border-color"]),"line-occlusion-opacity":new il(sl.paint_line["line-occlusion-opacity"])}),layout:tm};function im(t,e,i){return e*(uo/(t.tileSize*Math.pow(2,i-t.tileID.overscaledZ)))}function nm(t,e){return 1/im(t,1,e.tileZoom)}function rm(t,e,i,n){return t.translatePosMatrix(n||e.tileID.projMatrix,e,i.paint.get("line-translate"),i.paint.get("line-translate-anchor"))}const om=t=>{const e=[];sm(t)&&e.push("RENDER_LINE_DASH"),t.paint.get("line-gradient")&&e.push("RENDER_LINE_GRADIENT");const i=t.paint.get("line-trim-offset");0===i[0]&&0===i[1]||e.push("RENDER_LINE_TRIM_OFFSET"),0!==t.paint.get("line-border-width").constantOr(1)&&e.push("RENDER_LINE_BORDER");const n="none"===t.layout.get("line-join").constantOr("miter"),r=!!t.paint.get("line-pattern").constantOr(1);return n&&r&&e.push("LINE_JOIN_NONE"),e};function sm(t){const e=t.paint.get("line-dasharray").value;return e.value||"constant"!==e.kind}class am{constructor(t){this._stringToNumber={},this._numberToString=[];for(let e=0;e>1,d=-7,u=i?r-1:0,h=i?-1:1,p=t[e+u];for(u+=h,o=p&(1>=-d,d+=a;d>0;o=256*o+t[e+u],u+=h,d-=8);for(s=o&(1>=-d,d+=n;d>0;s=256*s+t[e+u],u+=h,d-=8);if(0===o)o=1-c;else{if(o===l)return s?NaN:1/0*(p?-1:1);s+=Math.pow(2,n),o-=c}return(p?-1:1)*s*Math.pow(2,o-n)},write:function(t,e,i,n,r,o){var s,a,l,c=8*o-r-1,d=(1>1,h=23===r?Math.pow(2,-24)-Math.pow(2,-77):0,p=n?0:o-1,f=n?1:-1,m=e=1?h/l:h*Math.pow(2,1-u))*l>=2&&(s++,l/=2),s+u>=d?(a=0,s=d):s+u>=1?(a=(e*l-1)*Math.pow(2,r),s+=u):(a=e*Math.pow(2,u-1)*Math.pow(2,r),s=0));r>=8;t[i+p]=255&a,p+=f,a/=256,r-=8);for(s=s0;t[i+p]=255&s,p+=f,s/=256,c-=8);t[i+p-f]|=128*m}},cm=um,dm=lm;function um(t){this.buf=ArrayBuffer.isView&&ArrayBuffer.isView(t)?t:new Uint8Array(t||0),this.pos=0,this.type=0,this.length=this.buf.length}um.Varint=0,um.Fixed64=1,um.Bytes=2,um.Fixed32=5;var hm=4294967296,pm=1/hm,fm="undefined"==typeof TextDecoder?null:new TextDecoder("utf8");function mm(t){return t.type===um.Bytes?t.readVarint()+t.pos:t.pos+1}function _m(t,e,i){return i?4294967296*e+(t>>>0):4294967296*(e>>>0)+(t>>>0)}function gm(t,e,i){var n=e=t;r--)i.buf[r+n]=i.buf[r]}function ym(t,e){for(var i=0;i>>8,t[i+2]=e>>>16,t[i+3]=e>>>24}function Im(t,e){return(t[e]|t[e+1]>3,o=this.pos;this.type=7&n,t(r,e,this),this.pos===o&&this.skip(n)}return e},readMessage:function(t,e){return this.readFields(t,e,this.readVarint()+this.pos)},readFixed32:function(){var t=Cm(this.buf,this.pos);return this.pos+=4,t},readSFixed32:function(){var t=Im(this.buf,this.pos);return this.pos+=4,t},readFixed64:function(){var t=Cm(this.buf,this.pos)+Cm(this.buf,this.pos+4)*hm;return this.pos+=8,t},readSFixed64:function(){var t=Cm(this.buf,this.pos)+Im(this.buf,this.pos+4)*hm;return this.pos+=8,t},readFloat:function(){var t=dm.read(this.buf,this.pos,!0,23,4);return this.pos+=4,t},readDouble:function(){var t=dm.read(this.buf,this.pos,!0,52,8);return this.pos+=8,t},readVarint:function(t){var e,i,n=this.buf;return e=127&(i=n[this.pos++]),i>4,r=12&&fm?function(t,e,i){return fm.decode(t.subarray(e,i))}(this.buf,e,t):function(t,e,i){for(var n="",r=e;r239?4:l>223?3:l>191?2:1;if(r+d>i)break;1===d?l=55296&&c=1114112)&&(c=null)),null===c?(c=65533,d=1):c>65535&&(c-=65536,n+=String.fromCharCode(c>>>10&1023|55296),c=56320|1023&c),n+=String.fromCharCode(c),r+=d}return n}(this.buf,e,t)},readBytes:function(){var t=this.readVarint()+this.pos,e=this.buf.subarray(this.pos,t);return this.pos=t,e},readPackedVarint:function(t,e){if(this.type!==um.Bytes)return t.push(this.readVarint(e));var i=mm(this);for(t=t||[];this.pos127;);else if(e===um.Bytes)this.pos=this.readVarint()+this.pos;else if(e===um.Fixed32)this.pos+=4;else{if(e!==um.Fixed64)throw new Error("Unimplemented type: "+e);this.pos+=8}},writeTag:function(t,e){this.writeVarint(t268435455||t=0?(i=t%4294967296|0,n=t/4294967296|0):(n=~(-t/4294967296),4294967295^(i=~(-t%4294967296))?i=i+1|0:(i=0,n=n+1|0)),t>=0x10000000000000000||t>>=7,i.buf[i.pos++]=127&t|128,t>>>=7,i.buf[i.pos++]=127&t|128,t>>>=7,i.buf[i.pos++]=127&t|128,i.buf[i.pos]=127&(t>>>=7)}(i,0,e),function(t,e){var i=(7&t)>>=3)?128:0),t&&(e.buf[e.pos++]=127&t|((t>>>=7)?128:0),t&&(e.buf[e.pos++]=127&t|((t>>>=7)?128:0),t&&(e.buf[e.pos++]=127&t|((t>>>=7)?128:0),t&&(e.buf[e.pos++]=127&t|((t>>>=7)?128:0),t&&(e.buf[e.pos++]=127&t)))))}(n,e)}(t,this):(this.realloc(4),this.buf[this.pos++]=127&t|(t>127?128:0),t>>=7)|(t>127?128:0),t>>=7)|(t>127?128:0),t>>7&127))))},writeSVarint:function(t){this.writeVarint(t55295&&n56319||o+1===e.length?(t[i++]=239,t[i++]=191,t[i++]=189):r=n;continue}if(n>6|192:(n>12|224:(t[i++]=n>>18|240,t[i++]=n>>12&63|128),t[i++]=n>>6&63|128),t[i++]=63&n|128)}return i}(this.buf,t,this.pos);var i=this.pos-e;i>=128&&gm(e,i,this),this.pos=e-1,this.writeVarint(i),this.pos+=i},writeFloat:function(t){this.realloc(4),dm.write(this.buf,t,this.pos,!0,23,4),this.pos+=4},writeDouble:function(t){this.realloc(8),dm.write(this.buf,t,this.pos,!0,52,8),this.pos+=8},writeBytes:function(t){var e=t.length;this.writeVarint(e),this.realloc(e);for(var i=0;i=128&&gm(i,n,this),this.pos=i-1,this.writeVarint(n),this.pos+=n},writeMessage:function(t,e,i){this.writeTag(t,um.Bytes),this.writeRawMessage(e,i)},writePackedVarint:function(t,e){e.length&&this.writeMessage(t,ym,e)},writePackedSVarint:function(t,e){e.length&&this.writeMessage(t,vm,e)},writePackedBoolean:function(t,e){e.length&&this.writeMessage(t,wm,e)},writePackedFloat:function(t,e){e.length&&this.writeMessage(t,xm,e)},writePackedDouble:function(t,e){e.length&&this.writeMessage(t,bm,e)},writePackedFixed32:function(t,e){e.length&&this.writeMessage(t,Tm,e)},writePackedSFixed32:function(t,e){e.length&&this.writeMessage(t,Sm,e)},writePackedFixed64:function(t,e){e.length&&this.writeMessage(t,Em,e)},writePackedSFixed64:function(t,e){e.length&&this.writeMessage(t,Mm,e)},writeBytesField:function(t,e){this.writeTag(t,um.Bytes),this.writeBytes(e)},writeFixed32Field:function(t,e){this.writeTag(t,um.Fixed32),this.writeFixed32(e)},writeSFixed32Field:function(t,e){this.writeTag(t,um.Fixed32),this.writeSFixed32(e)},writeFixed64Field:function(t,e){this.writeTag(t,um.Fixed64),this.writeFixed64(e)},writeSFixed64Field:function(t,e){this.writeTag(t,um.Fixed64),this.writeSFixed64(e)},writeVarintField:function(t,e){this.writeTag(t,um.Varint),this.writeVarint(e)},writeSVarintField:function(t,e){this.writeTag(t,um.Varint),this.writeSVarint(e)},writeStringField:function(t,e){this.writeTag(t,um.Bytes),this.writeString(e)},writeFloatField:function(t,e){this.writeTag(t,um.Fixed32),this.writeFloat(e)},writeDoubleField:function(t,e){this.writeTag(t,um.Fixed64),this.writeDouble(e)},writeBooleanField:function(t,e){this.writeVarintField(t,Boolean(e))}};var Lm=h(cm);const Pm=["id","tile","layer","source","sourceLayer","state"];class $m{constructor(t,e,i,n,r){this.type="Feature",this._vectorTileFeature=t,this._z=e,this._x=i,this._y=n,this.properties=t.properties,this.id=r}get geometry(){return void 0===this._geometry&&(this._geometry=this._vectorTileFeature.toGeoJSON(this._x,this._y,this._z).geometry),this._geometry}set geometry(t){this._geometry=t}toJSON(){const t={type:"Feature",state:void 0,geometry:this.geometry,properties:this.properties};for(const e of Pm)void 0!==this[e]&&(t[e]=this[e]);return t}}class km{constructor(){this.state={},this.stateChanges={},this.deletedStates={}}updateState(t,e,i){const n=String(e);if(this.stateChanges[t]=this.stateChanges[t]||{},this.stateChanges[t][n]=this.stateChanges[t][n]||{},ei(this.stateChanges[t][n],i),null===this.deletedStates[t]){this.deletedStates[t]={};for(const e in this.state[t])e!==n&&(this.deletedStates[t][e]=null)}else if(this.deletedStates[t]&&null===this.deletedStates[t][n]){this.deletedStates[t][n]={};for(const e in this.state[t][n])i[e]||(this.deletedStates[t][n][e]=null)}else for(const e in i)this.deletedStates[t]&&this.deletedStates[t][n]&&null===this.deletedStates[t][n][e]&&delete this.deletedStates[t][n][e]}removeFeatureState(t,e,i){if(null===this.deletedStates[t])return;const n=String(e);if(this.deletedStates[t]=this.deletedStates[t]||{},i&&void 0!==e)null!==this.deletedStates[t][n]&&(this.deletedStates[t][n]=this.deletedStates[t][n]||{},this.deletedStates[t][n][i]=null);else if(void 0!==e)if(this.stateChanges[t]&&this.stateChanges[t][n])for(i in this.deletedStates[t][n]={},this.stateChanges[t][n])this.deletedStates[t][n][i]=null;else this.deletedStates[t][n]=null;else this.deletedStates[t]=null}getState(t,e){const i=String(e),n=ei({},(this.state[t]||{})[i],(this.stateChanges[t]||{})[i]);if(null===this.deletedStates[t])return{};if(this.deletedStates[t]){const i=this.deletedStates[t][e];if(null===i)return{};for(const t in i)delete n[t]}return n}initializeTileState(t,e){t.setFeatureState(this.state,e)}coalesceChanges(t,e){const i={};for(const t in this.stateChanges){this.state[t]=this.state[t]||{};const e={};for(const i in this.stateChanges[t])this.state[t][i]||(this.state[t][i]={}),ei(this.state[t][i],this.stateChanges[t][i]),e[i]=this.state[t][i];i[t]=e}for(const t in this.deletedStates){this.state[t]=this.state[t]||{};const e={};if(null===this.deletedStates[t])for(const i in this.state[t])e[i]={},this.state[t][i]={};else for(const i in this.deletedStates[t]){if(null===this.deletedStates[t][i])this.state[t][i]={};else if(this.state[t][i])for(const e of Object.keys(this.deletedStates[t][i]))delete this.state[t][i][e];e[i]=this.state[t][i]}i[t]=i[t]||{},ei(i[t],e)}if(this.stateChanges={},this.deletedStates={},0!==Object.keys(i).length)for(const n in t)t[n].setFeatureState(i,e)}}class Dm{constructor(t,e){this.tileID=t,this.x=t.canonical.x,this.y=t.canonical.y,this.z=t.canonical.z,this.grid=new va(uo,16,0),this.featureIndexArray=new yc,this.promoteId=e,this.is3DTile=!1}insert(t,e,i,n,r,o=0,s=0){const a=this.featureIndexArray.length;this.featureIndexArray.emplaceBack(i,n,r,o);const l=this.grid;for(let t=0;t=0&&n[3]>=0&&l.insert(a,n[0],n[1],n[2],n[3])}}loadVTLayers(){if(!this.vtLayers){this.vtLayers=new bp(new Lm(this.rawTileData)).layers,this.sourceLayerCoder=new am(this.vtLayers?Object.keys(this.vtLayers).sort():["_geojsonTileLayer"]),this.vtFeatures={};for(const t in this.vtLayers)this.vtFeatures[t]=[]}return this.vtLayers}query(t,e,i,n){this.loadVTLayers();const r=t.params||{},o=dl(r.filter),s=t.tileResult,a=t.transform,l=s.bufferedTilespaceBounds,c=this.grid.query(l.min.x,l.min.y,l.max.x,l.max.y,((t,e,i,n)=>ou(s.bufferedTilespaceGeometry,t,e,i,n)));c.sort(Rm);let d=null;a.elevation&&c.length>0&&(d=Xp.create(a.elevation,this.tileID));const u={};let h;for(let l=0;l(m||(m=Gd(e,this.tileID.canonical,t.tileTransform)),i.queryIntersectsFeature(s,e,n,m,this.z,t.transform,t.pixelPosMatrix,d,r))))}return u}loadMatchingFeature(t,e,i,n,r,o,s,a,l){const{featureIndex:c,bucketIndex:d,sourceLayerIndex:u,layoutVertexArrayOffset:h}=e,p=this.bucketLayerIDs[d];if(n&&!function(t,e){for(let i=0;i=0)return!0;return!1}(n,p))return;const f=this.sourceLayerCoder.decode(u),m=this.vtLayers[f].feature(c);if(i.needGeometry){const t=Zd(m,!0);if(!i.filter(new Ha(this.tileID.overscaledZ),t,this.tileID.canonical))return}else if(!i.filter(new Ha(this.tileID.overscaledZ),m))return;const _=this.getId(m,f);for(let e=0;e{const s=e instanceof el?e.get(o):null;return s&&s.evaluate?s.evaluate(i,n,r):s}))}function Rm(t,e){return e-t}ba(Dm,"FeatureIndex",{omit:["rawTileData","sourceLayerCoder"]});var Om=24;const Bm=128;function Fm(t,e){const{expression:i}=e;if("constant"===i.kind)return{kind:"constant",layoutSize:i.evaluate(new Ha(t+1))};if("source"===i.kind)return{kind:"source"};{const{zoomStops:e,interpolationType:n}=i;let r=0;for(;r{t.text=function(t,e,i){const n=e.layout.get("text-transform").evaluate(i,{});return"uppercase"===n?t=t.toLocaleUpperCase():"lowercase"===n&&(t=t.toLocaleLowerCase()),qa.applyArabicShaping&&(t=qa.applyArabicShaping(t)),t}(t.text,e,i)})),t}const Gm={"!":"︕","#":"#",$:"$","%":"%","&":"&","(":"︵",")":"︶","*":"*","+":"+",",":"︐","-":"︲",".":"・","/":"/",":":"︓",";":"︔","":"﹀","?":"︖","@":"@","[":"﹇","\\":"\","]":"﹈","^":"^",_:"︳","`":"`","{":"︷","|":"―","}":"︸","~":"~","¢":"¢","£":"£","¥":"¥","¦":"¦","¬":"¬","¯":" ̄","–":"︲","—":"︱","‘":"﹃","’":"﹄","“":"﹁","”":"﹂","…":"︙","‧":"・","₩":"₩","、":"︑","。":"︒","〈":"︿","〉":"﹀","《":"︽","》":"︾","「":"﹁","」":"﹂","『":"﹃","』":"﹄","【":"︻","】":"︼","〔":"︹","〕":"︺","〖":"︗","〗":"︘","!":"︕","(":"︵",")":"︶",",":"︐","-":"︲",".":"・",":":"︓",";":"︔","<":"︿",">":"﹀","?":"︖","[":"﹇","]":"﹈","_":"︳","{":"︷","|":"―","}":"︸","⦅":"︵","⦆":"︶","。":"︒","「":"﹁","」":"﹂","←":"↑","→":"↓"};function Zm(t){return"︶"===t||"﹈"===t||"︸"===t||"﹄"===t||"﹂"===t||"︾"===t||"︼"===t||"︺"===t||"︘"===t||"﹀"===t||"︐"===t||"︓"===t||"︔"===t||"`"===t||" ̄"===t||"︑"===t||"︒"===t}function qm(t){return"︵"===t||"﹇"===t||"︷"===t||"﹃"===t||"﹁"===t||"︽"===t||"︻"===t||"︹"===t||"︗"===t||"︿"===t}const Hm=3;function Wm(t,e,i){e.glyphs=[],1===t&&i.readMessage(Ym,e)}function Ym(t,e,i){if(3===t){const{id:t,bitmap:n,width:r,height:o,left:s,top:a,advance:l}=i.readMessage(Xm,{});e.glyphs.push({id:t,bitmap:new dh({width:r+2*Hm,height:o+2*Hm},n),metrics:{width:r,height:o,left:s,top:a,advance:l}})}else 4===t?e.ascender=i.readSVarint():5===t&&(e.descender=i.readSVarint())}function Xm(t,e,i){1===t?e.id=i.readVarint():2===t?e.bitmap=i.readBytes():3===t?e.width=i.readVarint():4===t?e.height=i.readVarint():5===t?e.left=i.readSVarint():6===t?e.top=i.readSVarint():7===t&&(e.advance=i.readVarint())}const Km=Hm,Jm={horizontal:1,vertical:2,horizontalOnly:3};class Qm{constructor(){this.scale=1,this.fontStack="",this.imageName=null}static forText(t,e){const i=new Qm;return i.scale=t||1,i.fontStack=e,i}static forImage(t){const e=new Qm;return e.imageName=t,e}}class t_{constructor(){this.text="",this.sectionIndex=[],this.sections=[],this.imageSectionID=null}static fromFeature(t,e){const i=new t_;for(let n=0;n=0&&i>=t&&i_[this.text.charCodeAt(i)];i--)e--;this.text=this.text.substring(t,e),this.sectionIndex=this.sectionIndex.slice(t,e)}substring(t,e){const i=new t_;return i.text=this.text.substring(t,e),i.sectionIndex=this.sectionIndex.slice(t,e),i.sections=this.sections,i}toString(){return this.text}getMaxScale(){return this.sectionIndex.reduce(((t,e)=>Math.max(t,this.sections[e].scale)),0)}addTextSection(t,e){this.text+=t.text,this.sections.push(Qm.forText(t.scale,t.fontStack||e));const i=this.sections.length-1;for(let e=0;e=63743?null:++this.imageSectionID:(this.imageSectionID=57344,this.imageSectionID)}}function e_(t,e,i,n,r,o,s,a,l,c,d,u,h,p,f){const m=t_.fromFeature(t,r);u===Jm.vertical&&m.verticalizePunctuation(h);let _=[];const g=function(t,e,i,n,r,o){if(!t)return[];const s=[],a=function(t,e,i,n,r,o){let s=0;for(let i=0;i=0;let c=0;for(let i=0;i0&&o>b&&(b=o)}else{const t=i[a.fontStack];if(!t)continue;t[m]&&(S=t[m]);const n=e[a.fontStack];if(!n)continue;const o=n.glyphs[m];if(!o)continue;if(v=o.metrics,M=8203!==m?Om:0,_){const t=void 0!==n.ascender?Math.abs(n.ascender):0,e=void 0!==n.descender?Math.abs(n.descender):0,i=(t+e)*g;w-i/2;){if(s--,sn;)c-=l.shift().angleDelta;if(c>r)return!1;s++,a+=e.dist(i)}return!0}function m_(t){let e=0;for(let i=0;ic){const d=(c-l)/o,u=Vn(n.x,r.x,d),h=Vn(n.y,r.y,d),p=new p_(u,h,0,r.angleTo(n),i);return!s||f_(t,p,a,s,e)?p:void 0}l+=o}}function v_(t,e,i,n,r,o,s,a,l){const c=__(n,o,s),d=g_(n,r),u=d*s,h=0===t[0].x||t[0].x===l||0===t[0].y||t[0].y===l;return e-u=0&&g=0&&y=0&&h+c=n&&c.x>=n||(s.x>=n?s=new Ue(n,s.y+(n-s.x)/(c.x-s.x)*(c.y-s.y))._round():c.x>=n&&(c=new Ue(n,s.y+(n-s.x)/(c.x-s.x)*(c.y-s.y))._round()),s.y>=r&&c.y>=r||(s.y>=r?s=new Ue(s.x+(r-s.y)/(c.y-s.y)*(c.x-s.x),r)._round():c.y>=r&&(c=new Ue(s.x+(r-s.y)/(c.y-s.y)*(c.x-s.x),r)._round()),l&&s.equals(l[l.length-1])||(l=[s],o.push(l)),l.push(c)))))}}return o}function w_(t){let e=0,i=0;for(const n of t)e+=n.w*n.h,i=Math.max(i,n.w);t.sort(((t,e)=>e.h-t.h));const n=[{x:0,y:0,w:Math.max(Math.ceil(Math.sqrt(e/.95)),i),h:1/0}];let r=0,o=0;for(const e of t)for(let t=n.length-1;t>=0;t--){const i=n[t];if(!(e.w>i.w||e.h>i.h)){if(e.x=i.x,e.y=i.y,o=Math.max(o,e.y+e.h),r=Math.max(r,e.x+e.w),e.w===i.w&&e.h===i.h){const e=n.pop();tt.hasImage(e,i))),t.dispatchRenderCallbacks(this.haveRenderCallbacks,i);for(const n in t.getUpdatedImages(i))this.patchUpdatedImage(this.iconPositions[n],t.getImage(n,i),e),this.patchUpdatedImage(this.patternPositions[n],t.getImage(n,i),e)}patchUpdatedImage(t,e,i){if(!t||!e)return;if(t.version===e.version)return;t.version=e.version;const[n,r]=t.tl,o=!!Object.keys(this.patternPositions).length;i.update(e.data,{useMipmap:o},{x:n,y:r})}}ba(S_,"ImagePosition"),ba(E_,"ImageAtlas");const M_=1e20;function C_(t,e,i,n,r,o,s,a,l){for(let c=e;c-1);l++,o[l]=a,s[l]=c,s[l+1]=M_}for(let a=0,l=0;a{let n=this.entries[t];n||(n=this.entries[t]={glyphs:{},requests:{},ranges:{},ascender:void 0,descender:void 0});let r=n.glyphs[e];if(void 0!==r)return void i(null,{stack:t,id:e,glyph:r});if(r=this._tinySDF(n,t,e),r)return n.glyphs[e]=r,void i(null,{stack:t,id:e,glyph:r});const s=Math.floor(e/256);if(256*s>65535)return void i(new Error("glyphs > 65535 not supported"));if(n.ranges[s])return void i(null,{stack:t,id:e,glyph:r});let a=n.requests[s];a||(a=n.requests[s]=[],P_.loadGlyphRange(t,s,o,this.requestManager,((t,e)=>{if(e){n.ascender=e.ascender,n.descender=e.descender;for(const t in e.glyphs)this._doesCharSupportLocalGlyph(+t)||(n.glyphs[+t]=e.glyphs[+t]);n.ranges[s]=!0}for(const i of a)i(t,e);delete n.requests[s]}))),a.push(((n,r)=>{n?i(n):r&&i(null,{stack:t,id:e,glyph:r.glyphs[e]||null})}))}),((t,e)=>{if(t)i(t);else if(e){const t={};for(const{stack:i,id:n,glyph:r}of e)void 0===t[i]&&(t[i]={}),void 0===t[i].glyphs&&(t[i].glyphs={}),t[i].glyphs[n]=r&&{id:r.id,bitmap:r.bitmap.clone(),metrics:r.metrics},t[i].ascender=this.entries[i].ascender,t[i].descender=this.entries[i].descender;i(null,t)}}))}_doesCharSupportLocalGlyph(t){return this.localGlyphMode!==L_.none&&(this.localGlyphMode===L_.all?!!this.localFontFamily:!!this.localFontFamily&&(Ma["CJK Unified Ideographs"](t)||Ma["Hangul Syllables"](t)||Ma.Hiragana(t)||Ma.Katakana(t)||Ma["CJK Symbols and Punctuation"](t)||Ma["CJK Unified Ideographs Extension A"](t)||Ma["CJK Unified Ideographs Extension B"](t)))}_tinySDF(t,e,i){const n=this.localFontFamily;if(!n||!this._doesCharSupportLocalGlyph(i))return;let r=t.tinySDF;if(!r){let i="400";/bold/i.test(e)?i="900":/medium/i.test(e)?i="500":/light/i.test(e)&&(i="200"),r=t.tinySDF=new P_.TinySDF({fontFamily:n,fontWeight:i,fontSize:24*I_,buffer:3*I_,radius:8*I_}),r.fontWeight=i}if(this.localGlyphs[r.fontWeight][i])return this.localGlyphs[r.fontWeight][i];const o=String.fromCodePoint(i),{data:s,width:a,height:l,glyphWidth:c,glyphHeight:d,glyphLeft:u,glyphTop:h,glyphAdvance:p}=r.draw(o);return this.localGlyphs[r.fontWeight][i]={id:i,bitmap:new dh({width:a,height:l},s),metrics:{width:c/I_,height:d/I_,left:u/I_,top:h/I_-27,advance:p/I_,localGlyph:!0}}}}P_.loadGlyphRange=function(t,e,i,n,r){const o=256*e,s=o+255,a=n.transformRequest(n.normalizeGlyphsURL(i).replace("{fontstack}",t).replace("{range}",`${o}-${s}`),Ki.Glyphs);en(a,((t,e)=>{if(t)r(t);else if(e){const t={},i=function(t){return new Lm(t).readFields(Wm,{})}(e);for(const e of i.glyphs)t[e.id]=e;r(null,{glyphs:t,ascender:i.ascender,descender:i.descender})}}))},P_.TinySDF=class{constructor({fontSize:t=24,buffer:e=3,radius:i=8,cutoff:n=.25,fontFamily:r="sans-serif",fontWeight:o="normal",fontStyle:s="normal"}={}){this.buffer=e,this.cutoff=n,this.radius=i;const a=this.size=t+4*e,l=this._createCanvas(a),c=this.ctx=l.getContext("2d",{willReadFrequently:!0});c.font=`${s} ${o} ${t}px ${r}`,c.textBaseline="alphabetic",c.textAlign="left",c.fillStyle="black",this.gridOuter=new Float64Array(a*a),this.gridInner=new Float64Array(a*a),this.f=new Float64Array(a),this.z=new Float64Array(a+1),this.v=new Uint16Array(a)}_createCanvas(t){const e=document.createElement("canvas");return e.width=e.height=t,e}draw(t){const{width:e,actualBoundingBoxAscent:i,actualBoundingBoxDescent:n,actualBoundingBoxLeft:r,actualBoundingBoxRight:o}=this.ctx.measureText(t),s=Math.ceil(i),a=Math.max(0,Math.min(this.size-this.buffer,Math.ceil(o-r))),l=Math.min(this.size-this.buffer,s+Math.ceil(n)),c=a+2*this.buffer,d=l+2*this.buffer,u=Math.max(c*d,0),h=new Uint8ClampedArray(u),p={data:h,width:c,height:d,glyphWidth:a,glyphHeight:l,glyphTop:s,glyphLeft:0,glyphAdvance:e};if(0===a||0===l)return p;const{ctx:f,buffer:m,gridInner:_,gridOuter:g}=this;f.clearRect(m,m,a,l),f.fillText(t,m,m+s);const y=f.getImageData(m,m,a,l);g.fill(M_,0,u),_.fill(0,0,u);for(let t=0;t0?t*t:0,_[n]=tt+e[1]-e[0],f=u.reduce(p,0),m=h.reduce(p,0),_=a-f,g=l-m;let y=0,v=f,x=0,b=m,w=0,T=_,S=0,E=g;if(o.content&&n){const t=o.content;y=D_(u,0,t[0]),x=D_(h,0,t[1]),v=D_(u,t[0],t[2]),b=D_(h,t[1],t[3]),w=t[0]-y,S=t[1]-x,T=t[2]-t[0]-v,E=t[3]-t[1]-b}const M=(n,r,a,l)=>{const u=R_(n.stretch-y,v,c,t.left),h=O_(n.fixed-w,T,n.stretch,f),p=R_(r.stretch-x,b,d,t.top),_=O_(r.fixed-S,E,r.stretch,m),g=R_(a.stretch-y,v,c,t.left),M=O_(a.fixed-w,T,a.stretch,f),C=R_(l.stretch-x,b,d,t.top),A=O_(l.fixed-S,E,l.stretch,m),I=new Ue(u,p),L=new Ue(g,p),P=new Ue(g,C),$=new Ue(u,C),k=new Ue(h/s,_/s),D=new Ue(M/s,A/s),z=e*Math.PI/180;if(z){const t=Math.sin(z),e=Math.cos(z),i=[e,-t,t,e];I._matMult(i),L._matMult(i),$._matMult(i),P._matMult(i)}const R=n.stretch+n.fixed,O=a.stretch+a.fixed,B=r.stretch+r.fixed,F=l.stretch+l.fixed,N=t.imageSecondary;return{tl:I,tr:L,bl:$,br:P,texPrimary:{x:o.paddedRect.x+$_+R,y:o.paddedRect.y+$_+B,w:O-R,h:F-B},texSecondary:N?{x:N.paddedRect.x+$_+R,y:N.paddedRect.y+$_+B,w:O-R,h:F-B}:void 0,writingMode:void 0,glyphOffset:[0,0],sectionIndex:0,pixelOffsetTL:k,pixelOffsetBR:D,minFontScaleX:T/s/c,minFontScaleY:E/s/d,isSDF:i}};if(n&&(o.stretchX||o.stretchY)){const t=z_(u,_,f),e=z_(h,g,m);for(let i=0;io)&&(o=e.x),(!t||e.y>s)&&(s=e.y)}const l=Math.min(o-n,s-r);let c=l/2;const d=new co([],N_);if(0===l)return new Ue(n,r);for(let e=n;eu.d||!u.d)&&(u=n,i&&console.log("found best %d after %d probes",Math.round(1e4*n.d)/1e4,h)),n.max-u.dt.y!=a.y>t.y&&t.x18&&P>2&&(P>>=1),Math.max(uo/(512*P),1)*_.get("symbol-spacing")),S=_.get("text-padding")*t.tilePixelRatio,E=_.get("icon-padding")*t.tilePixelRatio,M=Ge(_.get("text-max-angle")),C="map"===_.get("text-rotation-alignment")&&"point"!==_.get("symbol-placement"),A="map"===_.get("icon-rotation-alignment")&&"point"!==_.get("symbol-placement"),I=_.get("symbol-placement"),L=T/2;var P;const $=_.get("icon-text-fit").evaluate(e,{},u),k=_.get("icon-text-fit-padding").evaluate(e,{},u),D="none"!==$;let z;!1===t.hasAnyIconTextFit&&D&&(t.hasAnyIconTextFit=!0),n&&D&&(t.allowVerticalPlacement&&i.vertical&&(z=h_(n,i.vertical,$,k,g,b)),y&&(n=h_(n,y,$,k,g,b)));const R=(s,a,m)=>{if(a.x=uo||a.y=uo)return;let _=null;if(v){const{x:t,y:e,z:i}=h.projectTilePoint(a.x,a.y,m);_={anchor:new p_(t,e,i,0,void 0),up:h.upVector(m,a.x,a.y)}}!function(t,e,i,n,r,o,s,a,l,c,d,u,h,p,f,m,_,g,y,v,x,b,w,T,S,E,M){const C=t.addToLineVertexArray(e,n);let A,I,L,P,$,k,D,z=0,R=0,O=0,B=0,F=-1,N=-1;const U={};let j=Ln("");const V=i?i.anchor:e,G="none"!==l.layout.get("icon-text-fit").evaluate(x,{},S);let Z=0,q=0;if(void 0===l._unevaluatedLayout.getValue("text-radial-offset")?[Z,q]=l.layout.get("text-offset").evaluate(x,{},S).map((t=>t*Om)):(Z=l.layout.get("text-radial-offset").evaluate(x,{},S)*Om,q=j_),t.allowVerticalPlacement&&r.vertical){const t=r.vertical;if(f)k=J_(t),a&&(D=J_(a));else{const i=l.layout.get("text-rotate").evaluate(x,{},S)+90;L=K_(c,V,e,d,u,h,t,p,i,m),a&&(P=K_(c,V,e,d,u,h,a,g,i))}}if(o){const n=l.layout.get("icon-rotate").evaluate(x,{},S),r=k_(o,n,w,G),s=a?k_(a,n,w,G):void 0;I=K_(c,V,e,d,u,h,o,g,n),z=4*r.length;const p=t.iconSizeData;let f=null;"source"===p.kind?(f=[Bm*l.layout.get("icon-size").evaluate(x,{},S)],f[0]>W_&&pi(`${t.layerIds[0]}: Value for "icon-size" is >= ${H_}. Reduce your "icon-size".`)):"composite"===p.kind&&(f=[Bm*b.compositeIconSizes[0].evaluate(x,{},S),Bm*b.compositeIconSizes[1].evaluate(x,{},S)],(f[0]>W_||f[1]>W_)&&pi(`${t.layerIds[0]}: Value for "icon-size" is >= ${H_}. Reduce your "icon-size".`)),t.addSymbols(t.icon,r,f,v,y,x,!1,i,e,C.lineStartIndex,C.lineLength,-1,T,S,E,M),F=t.icon.placedSymbolArray.length-1,s&&(R=4*s.length,t.addSymbols(t.icon,s,f,v,y,x,Jm.vertical,i,e,C.lineStartIndex,C.lineLength,-1,T,S,E,M),N=t.icon.placedSymbolArray.length-1)}for(const n in r.horizontal){const o=r.horizontal[n];A||(j=Ln(o.text),f?$=J_(o):A=K_(c,V,e,d,u,h,o,p,l.layout.get("text-rotate").evaluate(x,{},S),m));const a=1===o.positionedLines.length;if(O+=Y_(t,i,e,o,s,l,f,x,m,C,r.vertical?Jm.horizontal:Jm.horizontalOnly,a?Object.keys(r.horizontal):[n],U,F,b,T,S,E),a)break}r.vertical&&(B+=Y_(t,i,e,r.vertical,s,l,f,x,m,C,Jm.vertical,["vertical"],U,N,b,T,S,E));let H=-1;const W=(t,e)=>t?Math.max(t,e):e;H=W($,H),H=W(k,H),H=W(D,H);const Y=H>-1?1:0;t.glyphOffsetArray.length>=65535&&pi("Too many glyphs being rendered in a tile. See https://github.com/mapbox/mapbox-gl-js/issues/2907"),void 0!==x.sortKey&&t.addToSortKeyRanges(t.symbolInstances.length,x.sortKey),t.symbolInstances.emplaceBack(e.x,e.y,V.x,V.y,V.z,U.right>=0?U.right:-1,U.center>=0?U.center:-1,U.left>=0?U.left:-1,U.vertical>=0?U.vertical:-1,F,N,j,void 0!==A?A:t.collisionBoxArray.length,void 0!==A?A+1:t.collisionBoxArray.length,void 0!==L?L:t.collisionBoxArray.length,void 0!==L?L+1:t.collisionBoxArray.length,void 0!==I?I:t.collisionBoxArray.length,void 0!==I?I+1:t.collisionBoxArray.length,P||t.collisionBoxArray.length,P?P+1:t.collisionBoxArray.length,d,O,B,z,R,Y,0,Z,q,H,0,1,1,G?1:0)}(t,a,_,s,i,n,r,z,t.layers[0],t.collisionBoxArray,e.index,e.sourceLayerIndex,t.index,S,C,l,0,E,A,g,e,o,c,d,u,p,f)};if("line"===I)for(const r of b_(e.geometry,0,0,uo,uo)){const e=v_(r,T,M,i.vertical||y,n,x,w,t.overscaling,uo);for(const i of e)y&&Q_(t,y.text,L,i)||R(r,i,u)}else if("line-center"===I){for(const t of e.geometry)if(t.length>1){const e=y_(t,M,i.vertical||y,n,x,w);e&&R(t,e,u)}}else if("Polygon"===e.type)for(const t of Zh(e.geometry,0)){const e=F_(t,16);R(t[0],new p_(e.x,e.y,0,0,void 0),u)}else if("LineString"===e.type)for(const t of e.geometry)R(t,new p_(t[0].x,t[0].y,0,0,void 0),u);else if("Point"===e.type)for(const t of e.geometry)for(const e of t)R([e],new p_(e.x,e.y,0,0,void 0),u)}const H_=255,W_=H_*Bm;function Y_(t,e,i,n,r,o,s,a,l,c,d,u,h,p,f,m,_,g){const y=function(t,e,i,n,r,o,s,a){const l=[];if(0===e.positionedLines.length)return l;const c=n.layout.get("text-rotate").evaluate(o,{})*Math.PI/180,d=function(t){const e=t[0],i=t[1],n=e*i;return n>0?[e,-i]:nW_&&pi(`${t.layerIds[0]}: Value for "text-size" is >= ${H_}. Reduce your "text-size".`)):"composite"===v.kind&&(x=[Bm*f.compositeTextSizes[0].evaluate(a,{},_),Bm*f.compositeTextSizes[1].evaluate(a,{},_)],(x[0]>W_||x[1]>W_)&&pi(`${t.layerIds[0]}: Value for "text-size" is >= ${H_}. Reduce your "text-size".`)),t.addSymbols(t.text,y,x,l,s,a,d,e,i,c.lineStartIndex,c.lineLength,p,m,_,g,!1);for(const e of u)h[e]=t.text.placedSymbolArray.length-1;return 4*y.length}function X_(t){for(const e in t)return t[e];return null}function K_(t,e,i,n,r,o,s,a,l,c){let d=s.top,u=s.bottom,h=s.left,p=s.right;const f=s.collisionPadding;if(f&&(h-=f[0],d-=f[1],p+=f[2],u+=f[3]),l){const t=new Ue(h,d),e=new Ue(p,d),i=new Ue(h,u),n=new Ue(p,u),r=Ge(l);let o=new Ue(0,0);c&&(o=new Ue(c[0],c[1])),t._rotateAround(r,o),e._rotateAround(r,o),i._rotateAround(r,o),n._rotateAround(r,o),h=Math.min(t.x,e.x,i.x,n.x),p=Math.max(t.x,e.x,i.x,n.x),d=Math.min(t.y,e.y,i.y,n.y),u=Math.max(t.y,e.y,i.y,n.y)}return t.emplaceBack(e.x,e.y,e.z,i.x,i.y,h,d,p,u,a,n,r,o),t.length-1}function J_(t){t.collisionPadding&&(t.top-=t.collisionPadding[1],t.bottom+=t.collisionPadding[3]);const e=t.bottom-t.top;return e>0?Math.max(10,e):null}function Q_(t,e,i,n){const r=t.compareText;if(e in r){const t=r[e];for(let e=t.length-1;e>=0;e--)if(n.dist(t[e])v&&(x(t,c,n,r,a,l),x(c,i,a,l,o,s))}x(u,h,n,o,r,o),x(h,p,r,o,r,s),x(p,f,r,s,n,s),x(f,u,n,s,n,o),m-=v,_-=v,g+=v,y+=v;const b=1/Math.max(g-m,y-_);return{scale:b,x:m*b,y:_*b,x2:g*b,y2:y*b,projection:e}}function ig(t,{x:e,y:i},n=0){return new Ue(((e-n)*t.scale-t.x)*uo,(i*t.scale-t.y)*uo)}const ng=t.ad.identity(new Float32Array(16));class rg{constructor(t){this.spec=t,this.name=t.name,this.wrap=!1,this.requiresDraping=!1,this.supportsWorldCopies=!1,this.supportsTerrain=!1,this.supportsFog=!1,this.supportsFreeCamera=!1,this.zAxisUnit="meters",this.isReprojectedInTileSpace=!0,this.unsupportedLayers=["custom"],this.center=[0,0],this.range=[3.5,7]}project(t,e){return{x:0,y:0,z:0}}unproject(t,e){return new pd(0,0)}projectTilePoint(t,e,i){return{x:t,y:e,z:0}}locationPoint(t,e,i=!0){return t._coordinatePoint(t.locationCoordinate(e),i)}pixelsPerMeter(t,e){return Cd(1,t)*e}pixelSpaceConversion(t,e,i){return 1}farthestPixelDistance(t){return tg(t,t.pixelsPerMeter)}pointCoordinate(t,e,i,n){const r=t.horizonLineFromTop(!1),o=new Ue(e,Math.max(r,i));return t.rayIntersectionCoordinate(t.pointRayIntersection(o,n))}pointCoordinate3D(t,e,i){const n=new Ue(e,i);if(t.elevation)return t.elevation.pointCoordinate(n);{const e=this.pointCoordinate(t,n.x,n.y,0);return[e.x,e.y,e.z]}}isPointAboveHorizon(t,e){if(t.elevation&&t.elevation.visibleDemTiles.length)return!this.pointCoordinate3D(t,e.x,e.y);const i=t.horizonLineFromTop();return e.y0?epg-i&&(e=pg-i);const o=r/Math.pow(fg(e),n);let s=o*Math.sin(n*t),a=r-o*Math.cos(n*t);return s=.5*(s/Math.PI+.5),a=.5*(a/Math.PI+.5),{x:s,y:this.southernCenter?a:1-a,z:0}}unproject(t,e){t=(2*t-.5)*Math.PI,this.southernCenter&&(e=1-e),e=(2*(1-e)-.5)*Math.PI;const{n:i,f:n}=this,r=n-e,o=Math.sign(r),s=Math.sign(i)*Math.sqrt(t*t+r*r);let a=Math.atan2(t,Math.abs(r))*o;r*i1e-6&&--n>0);o=i*i;const s=Xe(Ze(t/(.8707+o*(o*(o*o*o*(.003971-.001529*o)-.013791)-.131979))),-180,180),a=Ze(i);return new pd(s,a)}}const vg=Ge(Pd);class xg extends rg{project(t,e){e=Ge(e),t=Ge(t);const i=Math.cos(e),n=2/Math.PI,r=Math.acos(i*Math.cos(t/2)),o=Math.sin(r)/r,s=.5*(t*n+2*i*Math.sin(t/2)/o)||0,a=.5*(e+Math.sin(e)/o)||0;return{x:.5*(s/Math.PI+.5),y:1-.5*(a/Math.PI+1),z:0}}unproject(t,e){let i=t=(2*t-.5)*Math.PI,n=e=(2*(1-e)-1)*Math.PI,r=25;const o=1e-6;let s=0,a=0;do{const r=Math.cos(n),o=Math.sin(n),l=2*o*r,c=o*o,d=r*r,u=Math.cos(i/2),h=Math.sin(i/2),p=2*u*h,f=h*h,m=1-d*u*u,_=m?1/m:0,g=m?Math.acos(r*u)*Math.sqrt(1/m):0,y=.5*(2*g*r*h+2*i/Math.PI)-t,v=.5*(g*o+n)-e,x=.5*_*(d*f+g*r*u*c)+1/Math.PI,b=_*(p*l/4-g*o*h),w=.125*_*(l*h-g*o*d*p),T=.5*_*(c*u+g*f*r)+.5,S=b*w-T*x;s=(v*b-y*T)/S,a=(y*w-v*x)/S,i=Xe(i-s,-Math.PI,Math.PI),n=Xe(n-a,-vg,vg)}while((Math.abs(s)>o||Math.abs(a)>o)&&--r>0);return new pd(Ze(i),Ze(n))}}class bg extends rg{constructor(t){super(t),this.center=t.center||[0,0],this.parallels=t.parallels||[0,0],this.cosPhi=Math.max(.01,Math.cos(Ge(this.parallels[0]))),this.scale=1/(2*Math.max(Math.PI*this.cosPhi,1/this.cosPhi)),this.wrap=!0,this.supportsWorldCopies=!0}project(t,e){const{scale:i,cosPhi:n}=this;return{x:Ge(t)*n*i+.5,y:-Math.sin(Ge(e))/n*i+.5,z:0}}unproject(t,e){const{scale:i,cosPhi:n}=this,r=-(e-.5)/i,o=Xe(Ze((t-.5)/i)/n,-180,180),s=Math.asin(Xe(r*n,-1,1)),a=Xe(Ze(s),-Pd,Pd);return new pd(o,a)}}class wg extends _g{constructor(t){super(t),this.requiresDraping=!0,this.supportsWorldCopies=!1,this.supportsFog=!0,this.zAxisUnit="pixels",this.unsupportedLayers=["debug"],this.range=[3,5]}projectTilePoint(e,i,n){const r=Fu(e,i,n),o=ju($u(n));return t._.transformMat4(r,r,o),{x:r[0],y:r[1],z:r[2]}}locationPoint(e,i){const n=dd(i.lat,i.lng),r=t._.normalize([],n),o=e.elevation?e.elevation.getAtPointOrZero(e.locationCoordinate(i),e._centerAltitude):e._centerAltitude,s=Cd(1,0)*uo*o;t._.scaleAndAdd(n,n,r,s);const a=t.ad.identity(new Float64Array(16));return t.ad.multiply(a,e.pixelMatrix,e.globeMatrix),t._.transformMat4(n,n,a),new Ue(n[0],n[1])}pixelsPerMeter(t,e){return Cd(1,0)*e}pixelSpaceConversion(t,e,i){const n=Cd(1,t)*e,r=Vn(Cd(1,45)*e,n,i);return this.pixelsPerMeter(t,e)/r}createTileMatrix(e,i,n){const r=Vu($u(n.canonical));return t.ad.multiply(new Float64Array(16),e.globeMatrix,r)}createInversionMatrix(e,i){const{center:n}=e,r=ju($u(i));return t.ad.rotateY(r,r,Ge(n.lng)),t.ad.rotateX(r,r,Ge(n.lat)),t.ad.scale(r,r,[e._pixelsPerMercatorPixel,e._pixelsPerMercatorPixel,1]),Float32Array.from(r)}pointCoordinate(t,e,i,n){return Iu(t,e,i,!0)||new Rd(0,0)}pointCoordinate3D(t,e,i){const n=this.pointCoordinate(t,e,i,0);return[n.x,n.y,n.z]}isPointAboveHorizon(t,e){return!Iu(t,e.x,e.y,!1)}farthestPixelDistance(e){const i=function(e,i){const n=e.cameraToCenterDistance,r=e._centerAltitude*i,o=e._camera,s=e._camera.forward(),a=t._.add([],t._.scale([],s,-n),[0,0,r]),l=e.worldSize/(2*Math.PI),c=[0,0,-l],d=e.width/e.height,u=Math.tan(e.fovAboveCenter),h=t._.scale([],o.up(),u),p=t._.scale([],o.right(),u*d),f=t._.normalize([],t._.add([],t._.add([],s,h),p)),m=[];let _;if(new mu(a,f).closestPointOnSphere(c,l,m)){const i=t._.add([],m,c),n=t._.sub([],i,a);_=Math.cos(e.fovAboveCenter)*t._.length(n)}else{const e=t._.sub([],a,c),i=t._.sub([],c,a);t._.normalize(i,i);const n=t._.length(e)-l;_=Math.sqrt(n*(n+2*l));const r=Math.acos(_/(l+n))-Math.acos(t._.dot(s,i));_*=Math.cos(r)}return 1.01*_}(e,this.pixelsPerMeter(e.center.lat,e.worldSize)),n=Hu(e.zoom);if(n>0){const t=tg(e,Cd(1,e.center.lat)*e.worldSize),r=e.worldSize/(2*Math.PI),o=Math.max(e.width,e.height)/e.worldSize*Math.PI;return Vn(i,t+r*(1-Math.cos(o)),Math.pow(n,10))}return i}upVector(t,e,i){return Fu(e,i,t,1)}upVectorScale(t){return{metersToTile:Cu(Nu($u(t)))}}}function Tg(t){const e=t.parallels,i=!!e&&Math.abs(e[0]+e[1])0&&(this.iconTransitioningVertexBuffer=t.createVertexBuffer(this.iconTransitioningVertexArray,Vf.members,!0)),this.globeExtVertexArray.length>0&&(this.globeExtVertexBuffer=t.createVertexBuffer(this.globeExtVertexArray,Ff.members,!0)),!this.zOffsetVertexBuffer&&(this.zOffsetVertexArray.length>0||r)&&(this.zOffsetVertexBuffer=t.createVertexBuffer(this.zOffsetVertexArray,jf.members,!0)),this.opacityVertexBuffer.itemSize=1),(i||n)&&this.programConfigurations.upload(t))}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy(),this.dynamicLayoutVertexBuffer.destroy(),this.opacityVertexBuffer.destroy(),this.occlusionQueryOpacityVertexBuffer.destroy(),this.iconTransitioningVertexBuffer&&this.iconTransitioningVertexBuffer.destroy(),this.globeExtVertexBuffer&&this.globeExtVertexBuffer.destroy(),this.zOffsetVertexBuffer&&this.zOffsetVertexBuffer.destroy())}}ba(Ng,"SymbolBuffers");class Ug{constructor(t,e,i){this.layoutVertexArray=new t,this.layoutAttributes=e,this.indexArray=new i,this.segments=new wc,this.collisionVertexArray=new Xl,this.collisionVertexArrayExt=new Ol}upload(t){this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,this.layoutAttributes),this.indexBuffer=t.createIndexBuffer(this.indexArray),this.collisionVertexBuffer=t.createVertexBuffer(this.collisionVertexArray,Gf.members,!0),this.collisionVertexBufferExt=t.createVertexBuffer(this.collisionVertexArrayExt,Zf.members,!0)}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.segments.destroy(),this.collisionVertexBuffer.destroy(),this.collisionVertexBufferExt.destroy())}}ba(Ug,"CollisionBuffers");class jg{constructor(e){this.queries=new Map,this.collisionBoxArray=e.collisionBoxArray,this.zoom=e.zoom,this.lut=e.lut,this.overscaling=e.overscaling,this.layers=e.layers,this.layerIds=this.layers.map((t=>t.fqid)),this.index=e.index,this.pixelRatio=e.pixelRatio,this.sourceLayerIndex=e.sourceLayerIndex,this.hasPattern=!1,this.hasRTLText=!1,this.fullyClipped=!1,this.hasAnyIconTextFit=!1,this.sortKeyRanges=[],this.collisionCircleArray=[],this.placementInvProjMatrix=t.ad.identity([]),this.placementViewportMatrix=t.ad.identity([]);const i=this.layers[0]._unevaluatedLayout._values;this.textSizeData=Fm(this.zoom,i["text-size"]),this.iconSizeData=Fm(this.zoom,i["icon-size"]);const n=this.layers[0].layout,r=n.get("symbol-sort-key"),o=n.get("symbol-z-order");this.canOverlap=n.get("text-allow-overlap")||n.get("icon-allow-overlap")||n.get("text-ignore-placement")||n.get("icon-ignore-placement"),this.sortFeaturesByKey="viewport-y"!==o&&void 0!==r.constantOr(1),this.sortFeaturesByY=("viewport-y"===o||"auto"===o&&!this.sortFeaturesByKey)&&this.canOverlap,this.writingModes=n.get("text-writing-mode").map((t=>Jm[t])),this.stateDependentLayerIds=this.layers.filter((t=>t.isStateDependent())).map((t=>t.id)),this.sourceID=e.sourceID,this.projection=e.projection,this.hasAnyZOffset=!1,this.zOffsetSortDirty=!1,this.zOffsetBuffersNeedUpload=n.get("symbol-z-elevate"),this.activeReplacements=[],this.replacementUpdateTime=0}createArrays(){this.text=new Ng(new Yc(this.layers,{zoom:this.zoom,lut:this.lut},(t=>/^text/.test(t)))),this.icon=new Ng(new Yc(this.layers,{zoom:this.zoom,lut:this.lut},(t=>/^icon/.test(t)))),this.glyphOffsetArray=new mc,this.lineVertexArray=new _c,this.symbolInstances=new fc}calculateGlyphDependencies(t,e,i,n,r){for(let i=0;i0)&&("constant"!==l.value.kind||l.value.value.length>0),h="constant"!==d.value.kind||!!d.value.value||Object.keys(d.parameters).length>0,p=s.get("symbol-sort-key");if(this.features=[],!u&&!h)return;const f=i.iconDependencies,m=i.glyphDependencies,_=i.availableImages,g=new Ha(this.zoom);for(const{feature:i,id:c,index:d,sourceLayerIndex:y}of e){const e=o._featureFilter.needGeometry,v=Zd(i,e);if(!o._featureFilter.filter(g,v,n))continue;if(e||(v.geometry=Gd(i,n,r)),a&&1!==i.type&&n.z{const o=Fu(e.x,e.y,n,1),s=Fu(r.x,r.y,n,1);return t._.dot(o,s)=0;for(const i of x.sections)if(i.image)f[i.image.namePrimary]=!0;else{const n=Ca(x.toString()),r=i.fontStack||t,o=m[r]=m[r]||{};this.calculateGlyphDependencies(i.text,o,e,this.allowVerticalPlacement,n)}}}"line"===s.get("symbol-placement")&&(this.features=function(t){const e={},i={},n=[];let r=0;function o(e){n.push(t[e]),r++}function s(t,e,r){const o=i[t];return delete i[t],i[e]=o,n[o].geometry[0].pop(),n[o].geometry[0]=n[o].geometry[0].concat(r[0]),o}function a(t,i,r){const o=e[i];return delete e[i],e[t]=o,n[o].geometry[0].shift(),n[o].geometry[0]=r[0].concat(n[o].geometry[0]),o}function l(t,e,i){const n=i?e[0][e[0].length-1]:e[0][0];return`${t}:${n.x}:${n.y}`}for(let c=0;ct.geometry))}(this.features)),this.sortFeaturesByKey&&this.features.sort(((t,e)=>t.sortKey-e.sortKey))}update(t,e,i,n,r){const o=0!==Object.keys(t).length;if(o&&!this.stateDependentLayers.length)return;const s=o?this.stateDependentLayers:this.layers;this.text.programConfigurations.updatePaintArrays(t,e,s,i,n,r),this.icon.programConfigurations.updatePaintArrays(t,e,s,i,n,r)}updateOcclusionOpacities(t,e,i){if(!e.useOcclusionQueries)return!1;const n=this;if("globe"===n.projection.name)return!1;let r=!1;n.hasTextData()&&(r=r||0!==n.text.occlusionQueryOpacityVertexArray.length),n.hasIconData()&&(r=r||0!==n.icon.occlusionQueryOpacityVertexArray.length);const o=n.layers[0].paint,s=o.get("icon-occlusion-opacity").constantOr(0),a=o.get("text-occlusion-opacity").constantOr(0);if(!n.layers[0].hasInitialOcclusionOpacityProperties||1===s&&1===a)return!1;let l=!r;for(let t=0;t.5?1:-1)*e.fadeSpeed*i*.001,r.occlusionOpacity=Xe(r.occlusionOpacity,0,1),l=l||r.occlusionOpacity!==o}if(!l)return!1;let c=0,d=0;const u=(t,e,i,n)=>{let r=0,o=0;i?(r=d,d+=n,o=d):(r=c,c+=n,o=c),o>e.occlusionQueryOpacityVertexArray.length&&e.occlusionQueryOpacityVertexArray.resize(o);const s=t.occlusionOpacity;for(let t=0;t0;if((i>0||r>0)&&(u(e,n.text,!1,i),u(e,n.text,!1,r)),s){const{placedIconSymbolIndex:t,verticalPlacedIconSymbolIndex:i}=e;t>=0&&u(e,n.icon,!0,o),i>=0&&u(e,n.icon,!0,e.numVerticalIconVertices)}}return n.hasTextData()&&n.text.occlusionQueryOpacityVertexBuffer&&(n.text.occlusionQueryOpacityVertexBuffer.length{i+=e,i>t.length&&t.resize(i);for(let r=-e;r{n+=e,n>t.length&&t.resize(n);for(let r=-e;r0;if((r>0||o>0)&&(t(this.text.zOffsetVertexArray,r,a),t(this.text.zOffsetVertexArray,o,a)),l){const{placedIconSymbolIndex:t,verticalPlacedIconSymbolIndex:i}=n;t>=0&&e(this.icon.zOffsetVertexArray,s,a),i>=0&&e(this.icon.zOffsetVertexArray,n.numVerticalIconVertices,a)}}this.text.zOffsetVertexBuffer&&this.text.zOffsetVertexBuffer.updateData(this.text.zOffsetVertexArray),this.icon.zOffsetVertexBuffer&&this.icon.zOffsetVertexBuffer.updateData(this.icon.zOffsetVertexArray)}isEmpty(){return 0===this.symbolInstances.length&&!this.hasRTLText}uploadPending(){return!this.uploaded||this.text.programConfigurations.needsUpload||this.icon.programConfigurations.needsUpload}upload(t){!this.uploaded&&this.hasDebugData()&&(this.textCollisionBox.upload(t),this.iconCollisionBox.upload(t)),this.text.upload(t,this.sortFeaturesByY,!this.uploaded,this.text.programConfigurations.needsUpload,this.zOffsetBuffersNeedUpload),this.icon.upload(t,this.sortFeaturesByY,!this.uploaded,this.icon.programConfigurations.needsUpload,this.zOffsetBuffersNeedUpload),this.uploaded=!0}destroyDebugData(){this.textCollisionBox.destroy(),this.iconCollisionBox.destroy()}getProjection(){return this.projectionInstance||(this.projectionInstance=Tg(this.projection)),this.projectionInstance}destroy(){this.text.destroy(),this.icon.destroy(),this.hasDebugData()&&this.destroyDebugData();for(const t of this.queries.values())t.destroy()}addToLineVertexArray(t,e){const i=this.lineVertexArray.length;if(void 0!==t.segment)for(const{x:t,y:i}of e)this.lineVertexArray.emplaceBack(t,i);return{lineStartIndex:i,lineLength:this.lineVertexArray.length-i}}addSymbols(t,e,i,n,r,o,s,a,l,c,d,u,h,p,f,m){const _=t.indexArray,g=t.layoutVertexArray,y=t.globeExtVertexArray,v=t.segments.prepareSegment(4*e.length,g,_,this.canOverlap?o.sortKey:void 0),x=this.glyphOffsetArray.length,b=v.vertexLength,w=this.allowVerticalPlacement&&s===Jm.vertical?Math.PI/2:0,T=o.text&&o.text.sections;for(let n=0;n=0?e.rightJustifiedTextSymbolIndex:e.centerJustifiedTextSymbolIndex>=0?e.centerJustifiedTextSymbolIndex:e.leftJustifiedTextSymbolIndex>=0?e.leftJustifiedTextSymbolIndex:e.verticalPlacedTextSymbolIndex>=0?e.verticalPlacedTextSymbolIndex:n),o=Nm(this.textSizeData,t,r)/Om;return this.tilePixelRatio*o}getSymbolInstanceIconSize(t,e,i){const n=this.icon.placedSymbolArray.get(i),r=Nm(this.iconSizeData,t,n);return this.tilePixelRatio*r}_commitDebugCollisionVertexUpdate(t,e,i,n){t.emplaceBack(e,-i,-i,n),t.emplaceBack(e,i,-i,n),t.emplaceBack(e,i,i,n),t.emplaceBack(e,-i,i,n)}_updateTextDebugCollisionBoxes(t,e,i,n,r,o){for(let s=n;s0}hasIconData(){return this.icon.segments.get().length>0}hasDebugData(){return this.textCollisionBox&&this.iconCollisionBox}hasTextCollisionBoxData(){return this.hasDebugData()&&this.textCollisionBox.segments.get().length>0}hasIconCollisionBoxData(){return this.hasDebugData()&&this.iconCollisionBox.segments.get().length>0}hasIconTextFit(){return this.hasAnyIconTextFit}addIndicesForPlacedSymbol(t,e){const i=t.placedSymbolArray.get(e),n=i.vertexStartIndex+4*i.numGlyphs;for(let e=i.vertexStartIndex;en[t]-n[e]||r[e]-r[t])),o}getSortedIndexesByZOffset(){if(!this.zOffsetSortDirty)return this.symbolInstanceIndexesSortedZOffset;if(!this.symbolInstanceIndexesSortedZOffset){this.symbolInstanceIndexesSortedZOffset=[];for(let t=0;tthis.symbolInstances.get(e).zOffset-this.symbolInstances.get(t).zOffset))}addToSortKeyRanges(t,e){const i=this.sortKeyRanges[this.sortKeyRanges.length-1];i&&i.sortKey===e?i.symbolInstanceEnd=t+1:this.sortKeyRanges.push({sortKey:e,symbolInstanceStart:t,symbolInstanceEnd:t+1})}sortFeatures(t){if(this.sortFeaturesByY&&this.sortedAngle!==t&&!(this.text.segments.get().length>1||this.icon.segments.get().length>1)){this.symbolInstanceIndexes=this.getSortedSymbolIndexes(t),this.sortedAngle=t,this.text.indexArray.clear(),this.icon.indexArray.clear(),this.featureSortOrder=[];for(const t of this.symbolInstanceIndexes){const e=this.symbolInstances.get(t);this.featureSortOrder.push(e.featureIndex);const{rightJustifiedTextSymbolIndex:i,centerJustifiedTextSymbolIndex:n,leftJustifiedTextSymbolIndex:r,verticalPlacedTextSymbolIndex:o,placedIconSymbolIndex:s,verticalPlacedIconSymbolIndex:a}=e;i>=0&&this.addIndicesForPlacedSymbol(this.text,i),n>=0&&n!==i&&this.addIndicesForPlacedSymbol(this.text,n),r>=0&&r!==n&&r!==i&&this.addIndicesForPlacedSymbol(this.text,r),o>=0&&this.addIndicesForPlacedSymbol(this.text,o),s>=0&&this.addIndicesForPlacedSymbol(this.icon,s),a>=0&&this.addIndicesForPlacedSymbol(this.icon,a)}this.text.indexBuffer&&this.text.indexBuffer.updateData(this.text.indexArray),this.icon.indexBuffer&&this.icon.indexBuffer.updateData(this.icon.indexArray)}}}ba(jg,"SymbolBucket",{omit:["layers","collisionBoxArray","features","compareText"]}),jg.addDynamicAttributes=Bg;class Vg{constructor(t,e,i,n){this.context=t,this.format=i,this.texture=t.gl.createTexture(),this.update(e,n)}update(t,e,i){const{width:n,height:r}=t,{context:o}=this,{gl:s}=o;if(s.bindTexture(s.TEXTURE_2D,this.texture),o.pixelStoreUnpackFlipY.set(!1),o.pixelStoreUnpack.set(1),o.pixelStoreUnpackPremultiplyAlpha.set(this.format===s.RGBA&&(!e||!1!==e.premultiply)),this.useMipmap=Boolean(e&&e.useMipmap),i||this.size&&this.size[0]===n&&this.size[1]===r){const{x:e,y:o}=i||{x:0,y:0};if(t instanceof HTMLImageElement||t instanceof HTMLCanvasElement||t instanceof HTMLVideoElement||t instanceof ImageData||ImageBitmap&&t instanceof ImageBitmap)s.texSubImage2D(s.TEXTURE_2D,0,e,o,s.RGBA,s.UNSIGNED_BYTE,t);else{let i=this.format,a=s.UNSIGNED_BYTE;this.format===s.R32F&&(i=s.RED,a=s.FLOAT),s.texSubImage2D(s.TEXTURE_2D,0,e,o,n,r,i,a,t.data)}}else if(this.size=[n,r],t instanceof HTMLImageElement||t instanceof HTMLCanvasElement||t instanceof HTMLVideoElement||t instanceof ImageData||ImageBitmap&&t instanceof ImageBitmap){let e=this.format;this.format===s.R8&&(e=s.RED),s.texImage2D(s.TEXTURE_2D,0,this.format,e,s.UNSIGNED_BYTE,t)}else{let e=this.format,i=this.format,o=s.UNSIGNED_BYTE,a=!1;this.format===s.DEPTH_COMPONENT&&(e=s.DEPTH_COMPONENT16,o=s.UNSIGNED_SHORT),this.format===s.DEPTH_STENCIL&&(e=s.DEPTH24_STENCIL8,o=s.UNSIGNED_INT_24_8,a=!0),this.format===s.R8&&(i=s.RED),this.format===s.R32F&&(o=s.FLOAT,i=s.RED),!this.useMipmap&&a?s.texStorage2D(s.TEXTURE_2D,1,e,n,r):s.texImage2D(s.TEXTURE_2D,0,e,n,r,0,i,o,t.data)}this.useMipmap&&s.generateMipmap(s.TEXTURE_2D)}bind(t,e,i=!1){const{context:n}=this,{gl:r}=n;r.bindTexture(r.TEXTURE_2D,this.texture),t!==this.minFilter&&(r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MAG_FILTER,t),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MIN_FILTER,this.useMipmap&&!i?t===r.NEAREST?r.NEAREST_MIPMAP_NEAREST:r.LINEAR_MIPMAP_LINEAR:t),this.minFilter=t),e!==this.wrapS&&(r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_S,e),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_T,e),this.wrapS=e)}bindExtraParam(t,e,i,n){const{context:r}=this,{gl:o}=r;o.bindTexture(o.TEXTURE_2D,this.texture),e!==this.magFilter&&(o.texParameteri(o.TEXTURE_2D,o.TEXTURE_MAG_FILTER,e),this.magFilter=e),t!==this.minFilter&&(o.texParameteri(o.TEXTURE_2D,o.TEXTURE_MIN_FILTER,this.useMipmap?t===o.NEAREST?o.NEAREST_MIPMAP_NEAREST:o.LINEAR_MIPMAP_LINEAR:t),this.minFilter=t),i!==this.wrapS&&(o.texParameteri(o.TEXTURE_2D,o.TEXTURE_WRAP_S,i),this.wrapS=i),n!==this.wrapT&&(o.texParameteri(o.TEXTURE_2D,o.TEXTURE_WRAP_T,n),this.wrapT=n)}destroy(){const{gl:t}=this.context;t.deleteTexture(this.texture),this.texture=null}}class Gg{constructor(t,e){this.context=t,this.texture=e}bind(t,e){const{context:i}=this,{gl:n}=i;n.bindTexture(n.TEXTURE_2D,this.texture),t!==this.minFilter&&(n.texParameteri(n.TEXTURE_2D,n.TEXTURE_MAG_FILTER,t),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_MIN_FILTER,t),this.minFilter=t),e!==this.wrapS&&(n.texParameteri(n.TEXTURE_2D,n.TEXTURE_WRAP_S,e),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_WRAP_T,e),this.wrapS=e)}}const Zg=32,qg=33,Hg=new Uint16Array(8184);for(let t=0;t>=1)>1;){const t=i+r>>1,l=n+o>>1;1&e?(r=i,o=n,i=s,n=a):(i=r,n=o,r=s,o=a),s=t,a=l}const l=4*t;Hg[l+0]=i,Hg[l+1]=n,Hg[l+2]=r,Hg[l+3]=o}const Wg=new Uint16Array(2178),Yg=new Uint8Array(1089),Xg=new Uint16Array(1089);function Kg(t){return 0===t?-.03125:32===t?.03125:0}var Jg=Ll([{name:"a_pos",type:"Int16",components:2},{name:"a_texture_pos",type:"Int16",components:2}]),Qg=Ll([{name:"a_index",type:"Int16",components:1}]);const ty={type:2,extent:uo,loadGeometry:()=>[[new Ue(0,0),new Ue(uo+1,0),new Ue(uo+1,uo+1),new Ue(0,uo+1),new Ue(0,0)]]};class ey{constructor(t,e,i,n,r){this.tileID=t,this.uid=ni(),this.uses=0,this.tileSize=e,this.tileZoom=i,this.buckets={},this.expirationTime=null,this.queryPadding=0,this.hasSymbolBuckets=!1,this.hasRTLText=!1,this.dependencies={},this.isRaster=r,n&&n.style&&(this._lastUpdatedBrightness=n.style.getBrightness()),this.expiredRequestCount=0,this.state="loading",n&&n.transform&&(this.projection=n.transform.projection)}registerFadeDuration(t){const e=t+this.timeAdded;ee.getLayer(t))).filter(Boolean);if(0!==t.length){n.layers=t,n.stateDependentLayerIds&&(n.stateDependentLayers=n.stateDependentLayerIds.map((e=>t.filter((t=>t.id===e))[0])));for(const e of t)i[e.fqid]=n}}return i}(t.buckets,e.style),this.hasSymbolBuckets=!1;for(const t in this.buckets){const e=this.buckets[t];if(e instanceof jg){if(this.hasSymbolBuckets=!0,!i)break;e.justReloaded=!0}}if(this.hasRTLText=!1,this.hasSymbolBuckets)for(const t in this.buckets){const e=this.buckets[t];if(e instanceof jg&&e.hasRTLText){this.hasRTLText=!0,qa.isLoading()||qa.isLoaded()||"deferred"!==Ga()||Za();break}}this.queryPadding=0;for(const t in this.buckets){const i=this.buckets[t],n=e.style.getOwnLayer(t);if(!n)continue;const r=n.queryRadius(i);this.queryPadding=Math.max(this.queryPadding,r)}t.imageAtlas&&(this.imageAtlas=t.imageAtlas),t.glyphAtlasImage&&(this.glyphAtlasImage=t.glyphAtlasImage),t.lineAtlas&&(this.lineAtlas=t.lineAtlas),this._lastUpdatedBrightness=t.brightness}else this.collisionBoxArray=new dc}unloadVectorData(){if(this.hasData()){for(const t in this.buckets)this.buckets[t].destroy();this.buckets={},this.imageAtlas&&(this.imageAtlas=null),this.lineAtlas&&(this.lineAtlas=null),this.imageAtlasTexture&&this.imageAtlasTexture.destroy(),this.glyphAtlasTexture&&this.glyphAtlasTexture.destroy(),this.lineAtlasTexture&&this.lineAtlasTexture.destroy(),this._tileBoundsBuffer&&(this._tileBoundsBuffer.destroy(),this._tileBoundsIndexBuffer.destroy(),this._tileBoundsSegments.destroy(),this._tileBoundsBuffer=null),this._tileDebugBuffer&&(this._tileDebugBuffer.destroy(),this._tileDebugSegments.destroy(),this._tileDebugBuffer=null),this._tileDebugIndexBuffer&&(this._tileDebugIndexBuffer.destroy(),this._tileDebugIndexBuffer=null),this._globeTileDebugBorderBuffer&&(this._globeTileDebugBorderBuffer.destroy(),this._globeTileDebugBorderBuffer=null),this._tileDebugTextBuffer&&(this._tileDebugTextBuffer.destroy(),this._tileDebugTextSegments.destroy(),this._tileDebugTextIndexBuffer.destroy(),this._tileDebugTextBuffer=null),this._globeTileDebugTextBuffer&&(this._globeTileDebugTextBuffer.destroy(),this._globeTileDebugTextBuffer=null),this.latestFeatureIndex=null,this.state="unloaded"}}getBucket(t){return this.buckets[t.fqid]}upload(t){for(const e in this.buckets){const i=this.buckets[e];i.uploadPending()&&i.upload(t)}const e=t.gl,i=this.imageAtlas;if(i&&!i.uploaded){const n=!!Object.keys(i.patternPositions).length;this.imageAtlasTexture=new Vg(t,i.image,e.RGBA,{useMipmap:n}),this.imageAtlas.uploaded=!0}this.glyphAtlasImage&&(this.glyphAtlasTexture=new Vg(t,this.glyphAtlasImage,e.R8),this.glyphAtlasImage=null),this.lineAtlas&&!this.lineAtlas.uploaded&&(this.lineAtlasTexture=new Vg(t,this.lineAtlas.image,e.R8),this.lineAtlas.uploaded=!0)}prepare(t,e,i){if(this.imageAtlas&&this.imageAtlasTexture&&this.imageAtlas.patchUpdatedImages(t,this.imageAtlasTexture,i),!e||!this.latestFeatureIndex||!this.latestFeatureIndex.rawTileData)return;const n=e.style.getBrightness();(this._lastUpdatedBrightness||n)&&(this._lastUpdatedBrightness&&n&&Math.abs(this._lastUpdatedBrightness-n)t)i=!1;else if(e)if(this.expirationTime=0;t--){const e=4*t,i=Hg[e+0],n=Hg[e+1],r=Hg[e+2],o=Hg[e+3],s=i+r>>1,a=n+o>>1,l=s+a-n,c=a+i-s,d=n*qg+i,u=o*qg+r,h=a*qg+s,p=Math.hypot((Wg[2*d+0]+Wg[2*u+0])/2-Wg[2*h+0],(Wg[2*d+1]+Wg[2*u+1])/2-Wg[2*h+1])>=16;Yg[h]=Yg[h]||(p?1:0),t>1)*qg+(i+l>>1)]||Yg[(o+c>>1)*qg+(r+l>>1)])}const r=new Dl,o=new Kl;let s=0;function a(t,e){const i=e*qg+t;return 0===Xg[i]&&(r.emplaceBack(Wg[2*i+0],Wg[2*i+1],t*uo/Zg,e*uo/Zg),Xg[i]=++s),Xg[i]-1}function l(t,e,i,n,r,s){const c=t+i>>1,d=e+n>>1;if(Math.abs(t-r)+Math.abs(e-s)>1&&Yg[d*qg+c])l(r,s,t,e,c,d),l(i,n,r,s,c,d);else{const l=a(t,e),c=a(i,n),d=a(r,s);o.emplaceBack(l,c,d)}}return l(0,0,Zg,Zg,Zg,0),l(Zg,Zg,0,0,0,Zg),{vertices:r,indices:o}}(this.tileID.canonical,e);n=t.vertices,r=t.indices}else{n=new Dl,r=new Kl;for(const{x:t,y:e}of i)n.emplaceBack(t,e,0,0);const t=xh(n.int16,void 0,4);for(let e=0;e0&&(a=t.ad.invert(new Float64Array(16),i.globeMatrix)),this._makeGlobeTileDebugBorderBuffer(e,r,i,o,a,s),this._makeGlobeTileDebugTextBuffer(e,r,i,o,a,s)}_globePoint(e,i,n,r,o,s,a){let l=Fu(e,i,n);if(s){const o=1.5?h=-1:u{const p=(d-t)/(h-1),f=(u-c)/(h-1),m=s.length;for(let d=0;dd*t+e;for(let t=0;t[t,this.get(t)]))}evict(t=!1){if(t||this.size>0){const t=this.first;delete this.items[t.key],0==--this.size?(this.first=null,this.last=null):(this.first=t.next,this.first.prev=null)}return this}expiresAt(t){let e;return this.has(t)&&(e=this.items[t].expiry),e}get(t){let e;if(this.has(t)){const i=this.items[t];this.ttl>0&&i.expiry0?Date.now()+this.ttl:this.ttl),this.last!==r){const t=this.last,e=r.next,i=r.prev;this.first===r&&(this.first=r.next),r.next=null,r.prev=this.last,t.next=r,null!==i&&(i.next=e),null!==e&&(e.prev=i)}}else this.max>0&&this.size===this.max&&this.evict(!0),r=this.items[t]={expiry:this.ttl>0?Date.now()+this.ttl:this.ttl,key:t,prev:this.last,next:null,value:e},1==++this.size?this.first=r:this.last.next=r;return this.last=r,this}values(t=this.keys()){return t.map((t=>this.get(t)))}}function uy(t,e){if(4!==e.length)throw new Error(`Expected data of dimension 4 but got ${e.length}.`);let i=e[3];for(let n=2;n>=1;n--){const r=1===n?1:0,o=2===n?1:0;for(let n=0;n>>1^-(1&t[e]);return t}function py(t,e){switch(e){case"uint32":return t;case"uint16":for(let e=0;e>4|(61440&i)>>8|(240&n)>4|(15&n)>6|(192&n)>>4|(192&r)>>2|192&o,t[e+1]=(48&i)>>4|(48&n)>>2|48&r|(48&o)>2|12&n|(12&r)>1|(21845&Cy)>2|(13107&Ay)>4|(3855&Ay)>8|(255&Ay)>1}var Iy=function(t,e,i){for(var n=t.length,r=0,o=new _y(e);r>l]=c}else for(s=new _y(n),r=0;r>15-t[r]);return s},Ly=new my(288);for(Cy=0;Cye&&(e=t[i]);return e},zy=function(t,e,i){var n=e/8|0;return(t[n]|t[n+1]>(7&e)&i},Ry=function(t,e){var i=e/8|0;return(t[i]|t[i+1]>(7&e)},Oy=["unexpected EOF","invalid block type","invalid length/literal","invalid distance","stream finished","no stream handler",,"no callback","invalid UTF-8 data","extra field too long","date not in range 1980-2099","filename too long","stream finishing","invalid zip data"],By=function(t,e,i){var n=new Error(e||Oy[t]);if(n.code=t,Error.captureStackTrace&&Error.captureStackTrace(n,By),!i)throw n;return n},Fy=new my(0),Ny="undefined"!=typeof TextDecoder&&new TextDecoder;try{Ny.decode(Fy,{stream:!0})}catch(t){}const Uy={gzip_data:"gzip"},jy={0:"uint32",1:"uint32",2:"uint16",3:"uint8"},Vy={uint32:1,uint16:2,uint8:4},Gy={uint32:Uint32Array,uint16:Uint16Array,uint8:Uint8Array};class Zy{constructor(t=1){this.x=NaN,this.y=NaN,this.z=NaN,this.layers={},this._cacheSize=t}getLayer(t){return this.layers[t]}getHeaderLength(t){const e=new Uint8Array(t),i=new DataView(t);if(13!==e[0])throw new fy("File is not a valid MRT.");return i.getUint32(1,!0)}parseHeader(t){const e=new Uint8Array(t),i=this.getHeaderLength(t);if(e.length= ${i} but got buffer of length ${e.length}`);const n=function(t){return t.readFields(iy,{header_length:0,x:0,y:0,z:0,layers:[]},void 0)}(new Lm(e.subarray(0,i)));if(!isNaN(this.x)&&(this.x!==n.x||this.y!==n.y||this.z!==n.z))throw new fy(`Invalid attempt to parse header ${n.z}/${n.x}/${n.y} for tile ${this.z}/${this.x}/${this.y}`);this.x=n.x,this.y=n.y,this.z=n.z;for(const t of n.layers)this.layers[t.name]=new qy(t,{cacheSize:this._cacheSize});return this}createDecodingTask(t){const e=[],i=this.getLayer(t.layerName);for(let n=0;nt.lastBlock)continue;if(i._blocksInProgress.has(n))continue;const a={layerName:i.name,firstByte:o,lastByte:s,pixelFormat:i.pixelFormat,blockIndex:n,blockShape:[r.bands.length].concat(i.bandShape),buffer:i.buffer,codec:r.codec.codec,filters:r.filters.map((t=>t.filter))};i._blocksInProgress.add(n),e.push(a)}return new Hy(e,(()=>{e.forEach((t=>i._blocksInProgress.delete(t.blockIndex)))}),((t,n)=>{if(e.forEach((t=>i._blocksInProgress.delete(t.blockIndex))),t)throw t;n.forEach((t=>{this.getLayer(t.layerName).processDecodedData(t)}))}))}}class qy{constructor({version:t,name:e,units:i,tilesize:n,pixel_format:r,buffer:o,data_index:s},a){if(this.version=t,1!==this.version)throw new fy(`Cannot parse raster layer encoded with MRT version ${t}`);this.name=e,this.units=i,this.tileSize=n,this.buffer=o,this.pixelFormat=jy[r],this.dataIndex=s,this.bandShape=[n+2*o,n+2*o,Vy[this.pixelFormat]],this._decodedBlocks=function(t=1e3,e=0,i=!1){if(isNaN(t)||t=e&&t=0}hasDataForBand(t){const{blockIndex:e}=this.getBlockForBand(t);return e>=0&&!!this._decodedBlocks.get(e.toString())}getBandView(t){const{blockIndex:e,blockBandIndex:i}=this.getBlockForBand(t),n=this._decodedBlocks.get(e.toString());if(!n)throw new fy(`Data for band ${JSON.stringify(t)} of layer "${this.name}" not decoded.`);const r=this.dataIndex[e],o=this.bandShape.reduce(((t,e)=>t*e),1),s=i*o,a=n.subarray(s,s+o);return{data:a,bytes:new Uint8Array(a.buffer).subarray(a.byteOffset,a.byteOffset+a.byteLength),tileSize:this.tileSize,buffer:this.buffer,offset:r.offset,scale:r.scale}}}class Hy{constructor(t,e,i){this.tasks=t,this._onCancel=e,this._onComplete=i,this._finalized=!1}cancel(){this._finalized||(this._onCancel(),this._finalized=!0)}complete(t,e){this._finalized||(this._onComplete(t,e),this._finalized=!0)}}Zy.performDecoding=function(t,e){return Promise.all(e.tasks.map((e=>{const{layerName:i,firstByte:n,lastByte:r,pixelFormat:o,blockShape:s,blockIndex:a,filters:l,codec:c}=e,d=new Uint8Array(t).subarray(n,r+1),u=new Uint32Array(s[0]*s[1]*s[2]);let h;if("gzip_data"!==c)throw new Error(`Unhandled codec: ${c}`);return h=function(t,e){if(!globalThis.DecompressionStream&&"gzip_data"===e)return Promise.resolve(((o=function(t){31==t[0]&&139==t[1]&&8==t[2]||By(6,"invalid gzip data");var e=t[3],i=10;4&e&&(i+=2+(t[10]|t[11]>3&1)+(e>>4&1);n>0;n-=!t[i++]);return i+(2&e)}(r=t))+8>r.length&&By(6,"invalid gzip data"),function(t,e,i){var n=t.length;if(!n||e.f&&!e.l)return i||new my(0);var r=!i,o=r||2!=e.i,s=e.i;r&&(i=new my(3*n));var a,l,c=function(t){var e=i.length;if(t>e){var n=new my(Math.max(2*e,t));n.set(i),i=n}},d=e.f||0,u=e.p||0,h=e.b||0,p=e.l,f=e.d,m=e.m,_=e.n,g=8*n;do{if(!p){d=zy(t,u,1);var y=zy(t,u+1,3);if(u+=3,!y){var v=t[(L=4+((u+7)/8|0))-4]|t[L-3]n){s&&By(0);break}o&&c(h+v),i.set(t.subarray(L,x),h),e.b=h+=v,e.p=u=8*x,e.f=d;continue}if(1==y)p=$y,f=ky,m=9,_=5;else if(2==y){var b=zy(t,u,31)+257,w=zy(t,u+10,15)+4,T=b+zy(t,u+5,31)+1;u+=14;for(var S=new my(T),E=new my(19),M=0;M>4)g){s&&By(0);break}}o&&c(h+131072);for(var R=(1>4;if((u+=15&$)>g){s&&By(0);break}if($||By(2),F264&&(N=zy(t,u,(1>4;if(U||By(3),u+=15&U,z=Ey[j],j>3){var V=vy[j];z+=Ry(t,u)&(1g){s&&By(0);break}o&&c(h+131072);var G=h+N;if(ha.length)&&(l=a.length),new my(a.subarray(0,l))):i.subarray(0,h)}(r.subarray(o,-8),{i:2},new my(((i=r)[(n=i.length)-4]|i[n-3]>>0))));var i,n,r,o;const s=Uy[e];if(!s)throw new Error(`Unhandled codec: ${e}`);const a=new globalThis.DecompressionStream(s);return new Response(new Blob([t]).stream().pipeThrough(a)).arrayBuffer().then((t=>new Uint8Array(t)))}(d,c).then((t=>(function(t,e){t.readFields(ly,e)}(new Lm(t),u),new(0,Gy[o])(u.buffer)))),h.then((t=>{for(let e=l.length-1;e>=0;e--)switch(l[e]){case"delta_filter":uy(t,s);break;case"zigzag_filter":hy(t);break;case"bitshuffle_filter":py(t,o);break;default:throw new Error(`Unhandled filter "${l[e]}"`)}return{layerName:i,blockIndex:a,data:t}})).catch((t=>{throw t}))})))};class Wy extends ey{constructor(t,e,i,n,r){super(t,e,i,n,r),this._workQueue=[],this._fetchQueue=[],this._isHeaderLoaded=!1}setTexture(t,e){const i=e.context,n=i.gl;this.texture=this.texture||e.getTileTexture(t.width),this.texture&&this.texture instanceof Vg?this.texture.update(t,{useMipmap:!1,premultiply:!1}):this.texture=new Vg(i,t,n.RGBA,{useMipmap:!1,premultiply:!1})}flushQueues(){for(;this._workQueue.length;)this._workQueue.pop()();for(;this._fetchQueue.length;)this._fetchQueue.pop()()}fetchHeader(t=16384,e){const i=this._mrt=new Zy(30),n=Object.assign({},this.requestParams,{headers:{Range:"bytes=0-"+(t-1)}});return this.entireBuffer=null,this.request=en(n,((n,r,o,s)=>{if(n)e(n);else try{const n=i.getHeaderLength(r);if(n>t)return void(this.request=this.fetchHeader(n,e));i.parseHeader(r),this._isHeaderLoaded=!0;let a=0;for(const t of Object.values(i.layers))a=Math.max(a,t.dataIndex[t.dataIndex.length-1].last_byte);r.byteLength>=a&&(this.entireBuffer=r),e(null,this.entireBuffer||r,o,s)}catch(t){e(t)}})),this.request}fetchBand(t,e,i){const n=this._mrt;if(!this._isHeaderLoaded||!n)return void i(new Error("Tile header is not ready"));const r=this.actor;if(!r)return void i(new Error("Can't fetch tile band without an actor"));let o;const s=(n,r)=>{o.complete(n,r),n?i(n):(this.updateTextureDescriptor(t,e),i(null,this.textureDescriptor&&this.textureDescriptor.img))},a=(t,e)=>{if(t)return i(t);const n=r.send("decodeRasterArray",{buffer:e,task:o},s,void 0,!0);this._workQueue.push((()=>{n&&n.cancel(),o.cancel()}))},l=n.getLayer(t);if(!l)return void i(new Error(`Unknown sourceLayer "${t}"`));if(l.hasDataForBand(e))return this.updateTextureDescriptor(t,e),void i(null,this.textureDescriptor?this.textureDescriptor.img:null);const c=l.getDataRange([e]);if(o=n.createDecodingTask(c),!o||o.tasks.length)if(this.flushQueues(),this.entireBuffer)a(null,this.entireBuffer.slice(c.firstByte,c.lastByte+1));else{const t=Object.assign({},this.requestParams,{headers:{Range:`bytes=${c.firstByte}-${c.lastByte}`}}),e=en(t,a);this._fetchQueue.push((()=>{e.cancel(),o.cancel()}))}else i(null)}updateNeeded(t,e){return(!this.textureDescriptor||this.textureDescriptor.band!==e||this.textureDescriptor.layer!==t)&&"errored"!==this.state}updateTextureDescriptor(t,e){if(!this._mrt)return;const i=this._mrt.getLayer(t);if(!i||!i.hasBand(e)||!i.hasDataForBand(e))return;const{bytes:n,tileSize:r,buffer:o,offset:s,scale:a}=i.getBandView(e),l=r+2*o,c={data:n,width:l,height:l},d=this.texture;d&&d instanceof Vg&&d.update(c,{useMipmap:!1,premultiply:!1}),this.textureDescriptor={layer:t,band:e,img:c,buffer:o,offset:s,tileSize:r,format:i.pixelFormat,mix:[a,256*a,65536*a,16777216*a]}}}class Yy{constructor(t,e){this.max=t,this.onRemove=e,this.reset()}reset(){for(const t in this.data)for(const e of this.data[t])e.timeout&&clearTimeout(e.timeout),this.onRemove(e.value);return this.data={},this.order=[],this}add(t,e,i){const n=t.wrapped().key;void 0===this.data[n]&&(this.data[n]=[]);const r={value:e,timeout:void 0};if(void 0!==i&&(r.timeout=setTimeout((()=>{this.remove(t,r)}),i)),this.data[n].push(r),this.order.push(n),this.order.length>this.max){const t=this._getAndRemoveByKey(this.order[0]);t&&this.onRemove(t)}return this}has(t){return t.wrapped().key in this.data}getAndRemove(t){return this.has(t)?this._getAndRemoveByKey(t.wrapped().key):null}_getAndRemoveByKey(t){const e=this.data[t].shift();return e.timeout&&clearTimeout(e.timeout),0===this.data[t].length&&delete this.data[t],this.order.splice(this.order.indexOf(t),1),e.value}getByKey(t){const e=this.data[t];return e?e[0].value:null}get(t){return this.has(t)?this.data[t.wrapped().key][0].value:null}remove(t,e){if(!this.has(t))return this;const i=t.wrapped().key,n=void 0===e?0:this.data[i].indexOf(e),r=this.data[i][n];return this.data[i].splice(n,1),r.timeout&&clearTimeout(r.timeout),0===this.data[i].length&&delete this.data[i],this.onRemove(r.value),this.order.splice(this.order.indexOf(i),1),this}setMaxSize(t){for(this.max=t;this.order.length>this.max;){const t=this._getAndRemoveByKey(this.order[0]);t&&this.onRemove(t)}return this}filter(t){const e=[];for(const i in this.data)for(const n of this.data[i])t(n.value)||e.push(n);for(const t of e)this.remove(t.value.tileID,t)}}class Xy extends zn{constructor(t,e,i){super(),this.id=t,this._onlySymbols=i,e.on("data",(t=>{"source"===t.dataType&&"metadata"===t.sourceDataType&&(this._sourceLoaded=!0),this._sourceLoaded&&!this._paused&&"source"===t.dataType&&"content"===t.sourceDataType&&(this.reload(),this.transform&&this.update(this.transform))})),e.on("error",(()=>{this._sourceErrored=!0})),this._source=e,this._tiles={},this._cache=new Yy(0,this._unloadTile.bind(this)),this._timers={},this._cacheTimers={},this._minTileCacheSize=e.minTileCacheSize,this._maxTileCacheSize=e.maxTileCacheSize,this._loadedParentTiles={},this.castsShadows=!1,this.tileCoverLift=0,this._coveredTiles={},this._shadowCasterTiles={},this._state=new km,this._isRaster="raster"===this._source.type||"raster-dem"===this._source.type||"raster-array"===this._source.type||"custom"===this._source.type&&"raster"===this._source._dataType}onAdd(t){this.map=t,this._minTileCacheSize=void 0===this._minTileCacheSize&&t?t._minTileCacheSize:this._minTileCacheSize,this._maxTileCacheSize=void 0===this._maxTileCacheSize&&t?t._maxTileCacheSize:this._maxTileCacheSize}loaded(){if(this._sourceErrored)return!0;if(!this._sourceLoaded)return!1;if(!this._source.loaded())return!1;for(const t in this._tiles){const e=this._tiles[t];if("errored"!==e.state&&("loaded"!==e.state||!e.bucketsLoaded()))return!1}return!0}getSource(){return this._source}pause(){this._paused=!0}resume(){if(!this._paused)return;const t=this._shouldReloadOnResume;this._paused=!1,this._shouldReloadOnResume=!1,t&&this.reload(),this.transform&&this.update(this.transform)}_loadTile(t,e){return t.isSymbolTile=this._onlySymbols,t.isExtraShadowCaster=this._shadowCasterTiles[t.tileID.key],this._source.loadTile(t,e)}_unloadTile(t){if(this._source.unloadTile)return this._source.unloadTile(t)}_abortTile(t){if(this._source.abortTile)return this._source.abortTile(t)}serialize(){return this._source.serialize()}prepare(t){this._source.prepare&&this._source.prepare(),this._state.coalesceChanges(this._tiles,this.map?this.map.painter:null);for(const e in this._tiles){const i=this._tiles[e];i.upload(t),i.prepare(this.map.style.imageManager,this.map?this.map.painter:null,this._source.scope)}}getIds(){return ti(this._tiles).map((t=>t.tileID)).sort(Ky).map((t=>t.key))}getRenderableIds(t,e){const i=[];for(const n in this._tiles)this._isIdRenderable(+n,t,e)&&i.push(this._tiles[n]);return t?i.sort(((t,e)=>{const i=t.tileID,n=e.tileID,r=new Ue(i.canonical.x,i.canonical.y)._rotate(this.transform.angle),o=new Ue(n.canonical.x,n.canonical.y)._rotate(this.transform.angle);return i.overscaledZ-n.overscaledZ||o.y-r.y||o.x-r.x})).map((t=>t.tileID.key)):i.map((t=>t.tileID)).sort(Ky).map((t=>t.key))}hasRenderableParent(t){const e=this.findLoadedParent(t,0);return!!e&&this._isIdRenderable(e.tileID.key)}_isIdRenderable(t,e,i){return this._tiles[t]&&this._tiles[t].hasData()&&!this._coveredTiles[t]&&(e||!this._tiles[t].holdingForFade())&&(i||!this._shadowCasterTiles[t])}reload(){if(this._paused)this._shouldReloadOnResume=!0;else{this._cache.reset();for(const t in this._tiles)"errored"!==this._tiles[t].state&&this._reloadTile(+t,"reloading")}}_reloadTile(t,e){const i=this._tiles[t];i&&("loading"!==i.state&&(i.state=e),this._loadTile(i,this._tileLoaded.bind(this,i,t,e)))}_tileLoaded(t,e,i,n){if(n)if(t.state="errored",404!==n.status)this._source.fire(new $n(n,{tile:t}));else{if(!(t.tileID.key in this._loadedParentTiles))return void this._source.fire(new Pn("data",{dataType:"source",sourceDataType:"error",sourceId:this._source.id}));if("raster-dem"===this._source.type&&this.usedForTerrain&&this.map.painter.terrain){const t=this.map.painter.terrain;this.update(this.transform,t.getScaledDemTileSize(),!0),t.resetTileLookupCache(this.id)}else this.update(this.transform)}else t.timeAdded=ki.now(),"expired"===i&&(t.refreshedUponExpiration=!0),this._setTileReloadTimer(e,t),"raster-dem"===this._source.type&&t.dem&&this._backfillDEM(t),this._state.initializeTileState(t,this.map?this.map.painter:null),this._source.fire(new Pn("data",{dataType:"source",tile:t,coord:t.tileID,sourceCacheId:this.id}))}_backfillDEM(t){const e=this.getRenderableIds();for(let n=0;n1||(Math.abs(i)>1&&(1===Math.abs(i+r)?i+=r:1===Math.abs(i-r)&&(i-=r)),e.dem&&t.dem&&(t.dem.backfillBorder(e.dem,i,n),t.neighboringTiles&&t.neighboringTiles[o]&&(t.neighboringTiles[o].backfilled=!0)))}}getTile(t){return this.getTileByID(t.key)}getTileByID(t){return this._tiles[t]}_retainLoadedChildren(t,e,i,n){for(const r in this._tiles){let o=this._tiles[r];if(n[r]||!o.hasData()||o.tileID.overscaledZi)continue;let s=o.tileID;for(;o&&o.tileID.overscaledZ>e+1;){const t=o.tileID.scaledTo(o.tileID.overscaledZ-1);o=this._tiles[t.key],o&&o.hasData()&&(s=t)}let a=s;for(;a.overscaledZ>e;)if(a=a.scaledTo(a.overscaledZ-1),t[a.key]){n[s.key]=s;break}}}findLoadedParent(t,e){if(t.key in this._loadedParentTiles){const i=this._loadedParentTiles[t.key];return i&&i.tileID.overscaledZ>=e?i:null}for(let i=t.overscaledZ-1;i>=e;i--){const e=t.scaledTo(i),n=this._getLoadedTile(e);if(n)return n}}_getLoadedTile(t){const e=this._tiles[t.key];return e&&e.hasData()?e:this._cache.getByKey(this._source.reparseOverscaled?t.wrapped().key:t.canonical.key)}updateCacheSize(t,e){e=e||this._source.tileSize;const i=Math.ceil(t.width/e)+1,n=Math.ceil(t.height/e)+1,r=Math.floor(i*n*5),o="number"==typeof this._minTileCacheSize?Math.max(this._minTileCacheSize,r):r,s="number"==typeof this._maxTileCacheSize?Math.min(this._maxTileCacheSize,o):o;this._cache.setMaxSize(s)}handleWrapJump(t){const e=Math.round((t-(void 0===this._prevLng?t:this._prevLng))/360);if(this._prevLng=t,e){const t={};for(const i in this._tiles){const n=this._tiles[i];n.tileID=n.tileID.unwrapTo(n.tileID.wrap+e),t[n.tileID.key]=n}this._tiles=t;for(const t in this._timers)clearTimeout(this._timers[t]),delete this._timers[t];for(const t in this._tiles)this._setTileReloadTimer(+t,this._tiles[t])}}update(t,e,i,n){if(this.transform=t,!this._sourceLoaded||this._paused||this.transform.freezeTileCoverage)return;if(this.usedForTerrain&&!i)return;let r;if(this.updateCacheSize(t,e),"globe"!==this.transform.projection.name&&this.handleWrapJump(this.transform.center.lng),this._shadowCasterTiles={},this._coveredTiles={},this.used||this.usedForTerrain){if(this._source.tileID)r=t.getVisibleUnwrappedCoordinates(this._source.tileID).map((t=>new vd(t.canonical.z,t.wrap,t.canonical.z,t.canonical.x,t.canonical.y)));else if(0!==this.tileCoverLift){const n=t.clone();n.tileCoverLift=this.tileCoverLift,r=n.coveringTiles({tileSize:e||this._source.tileSize,minzoom:this._source.minzoom,maxzoom:this._source.maxzoom,roundZoom:this._source.roundZoom&&!i,reparseOverscaled:this._source.reparseOverscaled,isTerrainDEM:this.usedForTerrain}),this._source.minzoomt(e)))}}else r=[];if(r.length>0&&this.castsShadows&&n&&"globe"!==this.transform.projection.name&&!this.usedForTerrain&&!Jy(this._source.type)){const o=t.coveringZoomLevel({tileSize:e||this._source.tileSize,roundZoom:this._source.roundZoom&&!i}),s=Math.min(o,this._source.maxzoom),a=t.extendTileCoverForShadows(r,n,s);for(const t of a)this._shadowCasterTiles[t.key]=!0,r.push(t)}const o=this._updateRetainedTiles(r);if(Jy(this._source.type)&&0!==r.length){const t={},e={},i=Object.keys(o);for(const n of i){const i=o[n],r=this._tiles[n];if(!r||r.fadeEndTime&&r.fadeEndTimen;){r=r.scaledTo(r.overscaledZ-1);const n=this._tiles[r.key];if(n&&n.hasData()&&e[r.key]){o[t]=i.tileID;break}}}for(const e in t)o[e]||(this._coveredTiles[e]=!0,o[e]=t[e])}for(const t in o)this._tiles[t].clearFadeHold();const s=function(t,e){const i=[];for(const n in t)n in e||i.push(n);return i}(this._tiles,o);for(const t of s){const e=this._tiles[t];e.hasSymbolBuckets&&!e.holdingForFade()?e.setHoldDuration(this.map._fadeDuration):e.hasSymbolBuckets&&!e.symbolFadeFinished()||this._removeTile(+t)}this._updateLoadedParentTileCache(),this._onlySymbols&&this._source.afterUpdate&&this._source.afterUpdate()}releaseSymbolFadeTiles(){for(const t in this._tiles)this._tiles[t].holdingForFade()&&this._removeTile(+t)}_updateRetainedTiles(t){const e={};if(0===t.length)return e;const i={},n=t.reduce(((t,e)=>Math.min(t,e.overscaledZ)),1/0),r=t[0].overscaledZ,o=Math.max(r-Xy.maxOverzooming,this._source.minzoom),s=Math.max(r+Xy.maxUnderzooming,this._source.minzoom),a={};for(const i of t){const t=this._addTile(i);e[i.key]=i,t.hasData()||n=this._source.maxzoom){const t=n.children(this._source.maxzoom)[0],i=this.getTile(t);if(i&&i.hasData()){e[t.key]=t;continue}}else{const t=n.children(this._source.maxzoom);if(e[t[0].key]&&e[t[1].key]&&e[t[2].key]&&e[t[3].key])continue}let r=t.wasRequested();for(let s=n.overscaledZ-1;s>=o;--s){const o=n.scaledTo(s);if(i[o.key])break;if(i[o.key]=!0,t=this.getTile(o),!t&&r&&(t=this._addTile(o)),t&&(e[o.key]=o,r=t.wasRequested(),t.hasData()))break}}return e}_updateLoadedParentTileCache(){this._loadedParentTiles={};for(const t in this._tiles){const e=[];let i,n=this._tiles[t].tileID;for(;n.overscaledZ>0;){if(n.key in this._loadedParentTiles){i=this._loadedParentTiles[n.key];break}e.push(n.key);const t=n.scaledTo(n.overscaledZ-1);if(i=this._getLoadedTile(t),i)break;n=t}for(const t of e)this._loadedParentTiles[t]=i}}_addTile(t){let e=this._tiles[t.key];if(e)return!0!==e.isExtraShadowCaster||!!this._shadowCasterTiles[t.key]||this._reloadTile(t.key,"reloading"),e;e=this._cache.getAndRemove(t),e&&(this._setTileReloadTimer(t.key,e),e.tileID=t,this._state.initializeTileState(e,this.map?this.map.painter:null),this._cacheTimers[t.key]&&(clearTimeout(this._cacheTimers[t.key]),delete this._cacheTimers[t.key],this._setTileReloadTimer(t.key,e)));const i=Boolean(e);if(!i){const i=this.map?this.map.painter:null,n=this._source.tileSize*t.overscaleFactor();e="raster-array"===this._source.type?new Wy(t,n,this.transform.tileZoom,i,this._isRaster):new ey(t,n,this.transform.tileZoom,i,this._isRaster),this._loadTile(e,this._tileLoaded.bind(this,e,t.key,e.state))}return e?(e.uses++,this._tiles[t.key]=e,i||this._source.fire(new Pn("dataloading",{tile:e,coord:e.tileID,dataType:"source"})),e):null}_setTileReloadTimer(t,e){t in this._timers&&(clearTimeout(this._timers[t]),delete this._timers[t]);const i=e.getExpiryTimeout();i&&(this._timers[t]=setTimeout((()=>{this._reloadTile(t,"expired"),delete this._timers[t]}),i))}_removeTile(t){const e=this._tiles[t];e&&(e.uses--,delete this._tiles[t],this._timers[t]&&(clearTimeout(this._timers[t]),delete this._timers[t]),e.uses>0||(e.hasData()&&"reloading"!==e.state||"empty"===e.state?this._cache.add(e.tileID,e,e.getExpiryTimeout()):(e.aborted=!0,this._abortTile(e),this._unloadTile(e))))}clearTiles(){this._shouldReloadOnResume=!1,this._paused=!1;for(const t in this._tiles)this._removeTile(+t);this._source._clear&&this._source._clear(),this._cache.reset(),this.map&&this.usedForTerrain&&this.map.painter.terrain&&this.map.painter.terrain.resetTileLookupCache(this.id)}tilesIn(t,e,i){const n=[],r=this.transform;if(!r)return n;const o="globe"===r.projection.name,s=Ed(r.center.lng);for(const a in this._tiles){const l=this._tiles[a];if(i&&l.clearQueryDebugViz(),l.holdingForFade())continue;let c;if(o){const t=l.tileID.canonical;if(0===t.z){const e=[Math.abs(Xe(s,...Qy(t,-1))-s),Math.abs(Xe(s,...Qy(t,1))-s)];c=[0,2*e.indexOf(Math.min(...e))-1]}else{const e=[Math.abs(Xe(s,...Qy(t,-1))-s),Math.abs(Xe(s,...Qy(t,0))-s),Math.abs(Xe(s,...Qy(t,1))-s)];c=[e.indexOf(Math.min(...e))-1]}}else c=[0];for(const i of c){const o=t.containsTile(l,r,e,i);o&&n.push(o)}}return n}getShadowCasterCoordinates(){return this._getRenderableCoordinates(!1,!0)}getVisibleCoordinates(t){return this._getRenderableCoordinates(t)}_getRenderableCoordinates(t,e){const i=this.getRenderableIds(t,e).map((t=>this._tiles[t].tileID)),n="globe"===this.transform.projection.name;for(const t of i)t.projMatrix=this.transform.calculateProjMatrix(t.toUnwrapped()),t.expandedProjMatrix=n?this.transform.calculateProjMatrix(t.toUnwrapped(),!1,!0):t.projMatrix;return i}sortCoordinatesByDistance(t){const e=t.slice(),i=this.transform._camera.position,n=this.transform._camera.forward(),r={};for(const t of e){const e=1/(1r[t.key]-r[e.key])),e}hasTransition(){if(this._source.hasTransition())return!0;if(Jy(this._source.type))for(const t in this._tiles){const e=this._tiles[t];if(void 0!==e.fadeEndTime&&e.fadeEndTime>=ki.now())return!0}return!1}setFeatureState(t,e,i){this._state.updateState(t=t||"_geojsonTileLayer",e,i)}removeFeatureState(t,e,i){this._state.removeFeatureState(t=t||"_geojsonTileLayer",e,i)}getFeatureState(t,e){return this._state.getState(t=t||"_geojsonTileLayer",e)}setDependencies(t,e,i){const n=this._tiles[t];n&&n.setDependencies(e,i)}reloadTilesForDependencies(t,e){for(const i in this._tiles)this._tiles[i].hasDependency(t,e)&&this._reloadTile(+i,"reloading");this._cache.filter((i=>!i.hasDependency(t,e)))}_preloadTiles(t,e){if(!this._sourceLoaded){const i=()=>{this._sourceLoaded&&(this._source.off("data",i),this._preloadTiles(t,e))};return void this._source.on("data",i)}const i=new Map,n=Array.isArray(t)?t:[t],r=this.map.painter.terrain,o=this.usedForTerrain&&r?r.getScaledDemTileSize():this._source.tileSize;for(const t of n){const e=t.coveringTiles({tileSize:o,minzoom:this._source.minzoom,maxzoom:this._source.maxzoom,roundZoom:this._source.roundZoom&&!this.usedForTerrain,reparseOverscaled:this._source.reparseOverscaled,isTerrainDEM:this.usedForTerrain});for(const t of e)i.set(t.key,t);this.usedForTerrain&&t.updateElevation(!1)}Qe(Array.from(i.values()),((t,e)=>{const i=new ey(t,this._source.tileSize*t.overscaleFactor(),this.transform.tileZoom,this.map.painter,this._isRaster);this._loadTile(i,(t=>{"raster-dem"===this._source.type&&i.dem&&this._backfillDEM(i),e(t,i)}))}),e)}}function Ky(t,e){const i=Math.abs(2*t.wrap)-+(t.wrap0?e+2*t:t}tv.useIntegerZoom=!0;const iv=new ol({"symbol-placement":new il(sl.layout_symbol["symbol-placement"]),"symbol-spacing":new il(sl.layout_symbol["symbol-spacing"]),"symbol-avoid-edges":new il(sl.layout_symbol["symbol-avoid-edges"]),"symbol-sort-key":new nl(sl.layout_symbol["symbol-sort-key"]),"symbol-z-order":new il(sl.layout_symbol["symbol-z-order"]),"symbol-z-elevate":new il(sl.layout_symbol["symbol-z-elevate"]),"icon-allow-overlap":new il(sl.layout_symbol["icon-allow-overlap"]),"icon-ignore-placement":new il(sl.layout_symbol["icon-ignore-placement"]),"icon-optional":new il(sl.layout_symbol["icon-optional"]),"icon-rotation-alignment":new il(sl.layout_symbol["icon-rotation-alignment"]),"icon-size":new nl(sl.layout_symbol["icon-size"]),"icon-text-fit":new nl(sl.layout_symbol["icon-text-fit"]),"icon-text-fit-padding":new nl(sl.layout_symbol["icon-text-fit-padding"]),"icon-image":new nl(sl.layout_symbol["icon-image"]),"icon-rotate":new nl(sl.layout_symbol["icon-rotate"]),"icon-padding":new il(sl.layout_symbol["icon-padding"]),"icon-keep-upright":new il(sl.layout_symbol["icon-keep-upright"]),"icon-offset":new nl(sl.layout_symbol["icon-offset"]),"icon-anchor":new nl(sl.layout_symbol["icon-anchor"]),"icon-pitch-alignment":new il(sl.layout_symbol["icon-pitch-alignment"]),"text-pitch-alignment":new il(sl.layout_symbol["text-pitch-alignment"]),"text-rotation-alignment":new il(sl.layout_symbol["text-rotation-alignment"]),"text-field":new nl(sl.layout_symbol["text-field"]),"text-font":new nl(sl.layout_symbol["text-font"]),"text-size":new nl(sl.layout_symbol["text-size"]),"text-max-width":new nl(sl.layout_symbol["text-max-width"]),"text-line-height":new nl(sl.layout_symbol["text-line-height"]),"text-letter-spacing":new nl(sl.layout_symbol["text-letter-spacing"]),"text-justify":new nl(sl.layout_symbol["text-justify"]),"text-radial-offset":new nl(sl.layout_symbol["text-radial-offset"]),"text-variable-anchor":new il(sl.layout_symbol["text-variable-anchor"]),"text-anchor":new nl(sl.layout_symbol["text-anchor"]),"text-max-angle":new il(sl.layout_symbol["text-max-angle"]),"text-writing-mode":new il(sl.layout_symbol["text-writing-mode"]),"text-rotate":new nl(sl.layout_symbol["text-rotate"]),"text-padding":new il(sl.layout_symbol["text-padding"]),"text-keep-upright":new il(sl.layout_symbol["text-keep-upright"]),"text-transform":new nl(sl.layout_symbol["text-transform"]),"text-offset":new nl(sl.layout_symbol["text-offset"]),"text-allow-overlap":new il(sl.layout_symbol["text-allow-overlap"]),"text-ignore-placement":new il(sl.layout_symbol["text-ignore-placement"]),"text-optional":new il(sl.layout_symbol["text-optional"]),visibility:new il(sl.layout_symbol.visibility)});var nv={paint:new ol({"icon-opacity":new nl(sl.paint_symbol["icon-opacity"]),"icon-occlusion-opacity":new nl(sl.paint_symbol["icon-occlusion-opacity"]),"icon-emissive-strength":new nl(sl.paint_symbol["icon-emissive-strength"]),"text-emissive-strength":new nl(sl.paint_symbol["text-emissive-strength"]),"icon-color":new nl(sl.paint_symbol["icon-color"]),"icon-halo-color":new nl(sl.paint_symbol["icon-halo-color"]),"icon-halo-width":new nl(sl.paint_symbol["icon-halo-width"]),"icon-halo-blur":new nl(sl.paint_symbol["icon-halo-blur"]),"icon-translate":new il(sl.paint_symbol["icon-translate"]),"icon-translate-anchor":new il(sl.paint_symbol["icon-translate-anchor"]),"icon-image-cross-fade":new nl(sl.paint_symbol["icon-image-cross-fade"]),"text-opacity":new nl(sl.paint_symbol["text-opacity"]),"text-occlusion-opacity":new nl(sl.paint_symbol["text-occlusion-opacity"]),"text-color":new nl(sl.paint_symbol["text-color"],{runtimeType:Qn,getOverride:t=>t.textColor,hasOverride:t=>!!t.textColor}),"text-halo-color":new nl(sl.paint_symbol["text-halo-color"]),"text-halo-width":new nl(sl.paint_symbol["text-halo-width"]),"text-halo-blur":new nl(sl.paint_symbol["text-halo-blur"]),"text-translate":new il(sl.paint_symbol["text-translate"]),"text-translate-anchor":new il(sl.paint_symbol["text-translate-anchor"]),"icon-color-saturation":new il(sl.paint_symbol["icon-color-saturation"]),"icon-color-contrast":new il(sl.paint_symbol["icon-color-contrast"]),"icon-color-brightness-min":new il(sl.paint_symbol["icon-color-brightness-min"]),"icon-color-brightness-max":new il(sl.paint_symbol["icon-color-brightness-max"])}),layout:iv};class rv{constructor(t){this.type=t.property.overrides?t.property.overrides.runtimeType:Yn,this.defaultValue=t}evaluate(t){if(t.formattedSection){const e=this.defaultValue.property.overrides;if(e&&e.hasOverride(t.formattedSection))return e.getOverride(t.formattedSection)}return t.feature&&t.featureState?this.defaultValue.evaluate(t.feature,t.featureState):this.defaultValue.property.specification.default}eachChild(t){this.defaultValue.isConstant()||t(this.defaultValue.value._styleExpression.expression)}outputDefined(){return!1}serialize(){return null}}ba(rv,"FormatSectionOverride",{omit:["defaultValue"]});class ov extends Ml{constructor(e,i,n,r){super(e,nv,i,n,r),this._colorAdjustmentMatrix=t.ad.identity([]),this.hasInitialOcclusionOpacityProperties=void 0!==e.paint&&("icon-occlusion-opacity"in e.paint||"text-occlusion-opacity"in e.paint)}recalculate(t,e){super.recalculate(t,e),"auto"===this.layout.get("icon-rotation-alignment")&&(this.layout._values["icon-rotation-alignment"]="point"!==this.layout.get("symbol-placement")?"map":"viewport"),"auto"===this.layout.get("text-rotation-alignment")&&(this.layout._values["text-rotation-alignment"]="point"!==this.layout.get("symbol-placement")?"map":"viewport"),"auto"===this.layout.get("text-pitch-alignment")&&(this.layout._values["text-pitch-alignment"]=this.layout.get("text-rotation-alignment")),"auto"===this.layout.get("icon-pitch-alignment")&&(this.layout._values["icon-pitch-alignment"]=this.layout.get("icon-rotation-alignment"));const i=this.layout.get("text-writing-mode");if(i){const t=[];for(const e of i)t.indexOf(e)i in t?String(t[i]):""))}(e.properties,r)}createBucket(t){return new jg(t)}queryRadius(){return 0}queryIntersectsFeature(){return!1}_setPaintOverrides(){for(const t of nv.paint.overridableProperties){if(!ov.hasPaintOverride(this.layout,t))continue;const e=this.paint.get(t),i=new rv(e),n=new la(i,e.property.specification,this.scope,this.options);let r=null;r="constant"===e.value.kind||"source"===e.value.kind?new ua("source",n):new ha("composite",n,e.value.zoomStops,e.value._interpolationType),this.paint._values[t]=new tl(e.property,r,e.parameters)}}_handleOverridablePaintPropertyUpdate(t,e,i){return!(!this.layout||e.isDataDriven()||i.isDataDriven())&&ov.hasPaintOverride(this.layout,t)}static hasPaintOverride(t,e){const i=t.get("text-field"),n=nv.paint.properties[e];let r=!1;const o=t=>{for(const e of t)if(n.overrides&&n.overrides.hasOverride(e))return void(r=!0)};if("constant"===i.value.kind&&i.value.value instanceof pr)o(i.value.value.sections);else if("source"===i.value.kind){const t=e=>{r||(e instanceof vr&&gr(e.value)===nr?o(e.value.sections):e instanceof Tr?o(e.sections):e.eachChild(t))},e=i.value;e._styleExpression&&t(e._styleExpression.expression)}return r}getProgramIds(){const t=0!==this.paint.get("icon-opacity").constantOr(1),e=0!==this.paint.get("text-opacity").constantOr(1),i=[];return t&&i.push("symbolIcon"),e&&i.push("symbolSDF"),i}getDefaultProgramParams(t,e,i){return{config:new Wc(this,{zoom:e,lut:i}),overrideFog:!1}}}const sv=new ol({visibility:new il(sl.layout_background.visibility)});var av={paint:new ol({"background-color":new il(sl.paint_background["background-color"]),"background-pattern":new il(sl.paint_background["background-pattern"]),"background-opacity":new il(sl.paint_background["background-opacity"]),"background-emissive-strength":new il(sl.paint_background["background-emissive-strength"])}),layout:sv};const lv=new ol({visibility:new il(sl.layout_raster.visibility)});var cv={paint:new ol({"raster-opacity":new il(sl.paint_raster["raster-opacity"]),"raster-color":new rl(sl.paint_raster["raster-color"]),"raster-color-mix":new il(sl.paint_raster["raster-color-mix"]),"raster-color-range":new il(sl.paint_raster["raster-color-range"]),"raster-hue-rotate":new il(sl.paint_raster["raster-hue-rotate"]),"raster-brightness-min":new il(sl.paint_raster["raster-brightness-min"]),"raster-brightness-max":new il(sl.paint_raster["raster-brightness-max"]),"raster-saturation":new il(sl.paint_raster["raster-saturation"]),"raster-contrast":new il(sl.paint_raster["raster-contrast"]),"raster-resampling":new il(sl.paint_raster["raster-resampling"]),"raster-fade-duration":new il(sl.paint_raster["raster-fade-duration"]),"raster-emissive-strength":new il(sl.paint_raster["raster-emissive-strength"]),"raster-array-band":new il(sl.paint_raster["raster-array-band"]),"raster-elevation":new il(sl.paint_raster["raster-elevation"])}),layout:lv};function dv(e,i,n,r,o,s,a,l){const c=[e,i,1,n,r,1,o,s,1],d=[a,l,1],u=t.bC.adjoint([],c),[h,p,f]=t._.transformMat3(d,d,u);return t.bC.multiply(c,c,[h,0,0,0,p,0,0,0,f])}function uv(e,i,n,r,o,s,a,l){const c=function(e,i,n,r,o,s,a,l){const c=dv(0,0,1,0,1,1,0,1),d=dv(e,i,n,r,o,s,a,l),u=t.bC.adjoint([],c);return t.bC.multiply(d,d,u)}(e,i,n,r,o,s,a,l);return[c[2]/c[8]/uo,c[5]/c[8]/uo]}function hv(t){return[t[0],Math.min(Math.max(t[1],-Pd),Pd)]}class pv extends zn{constructor(t,e,i,n){super(),this.id=t,this.dispatcher=i,this.coordinates=e.coordinates,this.type="image",this.minzoom=0,this.maxzoom=22,this.tileSize=512,this.tiles={},this._loaded=!1,this.onNorthPole=!1,this.onSouthPole=!1,this.setEventedParent(n),this.options=e,this._dirty=!1}load(t,e){if(this._loaded=e||!1,this.fire(new Pn("dataloading",{dataType:"source"})),this.url=this.options.url,!this.url)return t&&(this.coordinates=t),this._loaded=!0,void this._finishLoading();this._imageRequest=an(this.map._requestManager.transformRequest(this.url,Ki.Image),((e,i)=>{this._imageRequest=null,this._loaded=!0,e?this.fire(new $n(e)):i&&(this.image=i instanceof HTMLImageElement?ki.getImageData(i):i,this._dirty=!0,this.width=this.image.width,this.height=this.image.height,t&&(this.coordinates=t),this._finishLoading())}))}loaded(){return this._loaded}updateImage(t){return t.url?(this._imageRequest&&t.url!==this.options.url&&(this._imageRequest.cancel(),this._imageRequest=null),this.options.url=t.url,this.load(t.coordinates,this._loaded),this):this}setTexture(t){if(!(t.handle instanceof WebGLTexture))throw new Error("The provided handle is not a WebGLTexture instance");return this.texture=new Gg(this.map.painter.context,t.handle),this.width=t.dimensions[0],this.height=t.dimensions[1],this._dirty=!1,this._loaded=!0,this._finishLoading(),this}_finishLoading(){this.map&&(this.setCoordinates(this.coordinates),this.fire(new Pn("data",{dataType:"source",sourceDataType:"metadata"})))}onAdd(t){this.map=t,this.load()}onRemove(t){this._imageRequest&&(this._imageRequest.cancel(),this._imageRequest=null),!this.texture||this.texture instanceof Gg||this.texture.destroy(),this.boundsBuffer&&(this.boundsBuffer.destroy(),this.elevatedGlobeVertexBuffer&&this.elevatedGlobeVertexBuffer.destroy(),this.elevatedGlobeIndexBuffer&&this.elevatedGlobeIndexBuffer.destroy())}setCoordinates(t){if(this.coordinates=t,this._boundsArray=void 0,this._unsupportedCoords=!1,!t.length)return this;this.onNorthPole=!1,this.onSouthPole=!1;let e=t[0][1],i=t[0][1];for(const n of t)n[1]>i&&(i=n[1]),n[1]Pd?this.onNorthPole=!0:n1&&(l-=1),new gd(s,l,Math.floor((i+r)/2*a))}(e),this.minzoom=this.maxzoom=this.tileID.z}return this.fire(new Pn("data",{dataType:"source",sourceDataType:"content"})),this}_clear(){this._boundsArray=void 0,this._unsupportedCoords=!1}_prepareData(e){for(const t in this.tiles){const e=this.tiles[t];"loaded"!==e.state&&(e.state="loaded",e.texture=this.texture)}if(this._boundsArray||this.onNorthPole||this.onSouthPole||this._unsupportedCoords)return;const i=eg(new gd(0,0,0),this.map.transform.projection),n=[i.projection.project(this.coordinates[0][0],this.coordinates[0][1]),i.projection.project(this.coordinates[1][0],this.coordinates[1][1]),i.projection.project(this.coordinates[2][0],this.coordinates[2][1]),i.projection.project(this.coordinates[3][0],this.coordinates[3][1])];if(!function(t){const e=t[1].x-t[0].x,i=t[1].y-t[0].y,n=t[2].x-t[1].x,r=t[2].y-t[1].y,o=t[3].x-t[2].x,s=t[3].y-t[2].y,a=t[0].x-t[3].x,l=t[0].y-t[3].y,c=e*r-n*i,d=n*s-o*r,u=o*l-a*s,h=a*i-e*l;return c>0&&d>0&&u>0&&h>0||c{const e=r.projection.project(t[0],t[1]);return ig(r,e)._round()}));this.perspectiveTransform=uv(o.x,o.y,s.x,s.y,a.x,a.y,l.x,l.y);const c=this._boundsArray=new Dl;c.emplaceBack(o.x,o.y,0,0),c.emplaceBack(s.x,s.y,uo,0),c.emplaceBack(l.x,l.y,0,uo),c.emplaceBack(a.x,a.y,uo,uo),this.boundsBuffer&&(this.boundsBuffer.destroy(),this.elevatedGlobeVertexBuffer&&this.elevatedGlobeVertexBuffer.destroy(),this.elevatedGlobeIndexBuffer&&this.elevatedGlobeIndexBuffer.destroy()),this.boundsBuffer=e.createVertexBuffer(c,Jg.members),this.boundsSegments=wc.simpleSegment(0,0,4,2);const d=[],u=function(t){return[hv(t[0]),hv(t[1]),hv(t[2]),hv(t[3])]}(this.coordinates),[h,p,f,m]=function(t){let e=t[0][0],i=e,n=t[0][1],r=n;for(let o=1;oi&&(i=t[o][0]),t[o][1]r&&(r=t[o][1]);return[e,n,i-e,r-n]}(u);{const r=new Dl,[o,s,a,l]=function(t){let e=t[0].x,i=e,n=t[0].y,r=n;for(let o=1;oi&&(i=t[o].x),t[o].yr&&(r=t[o].y);return[e,n,i-e,r-n]}(n),c=t=>[(t.x-o)/a,(t.y-s)/l],[u,_,g,y]=n.map(c),v=function(e,i,n,r,o,s,a,l){const c=dv(0,0,1,0,1,1,0,1),d=dv(e,i,n,r,o,s,a,l),u=t.bC.adjoint([],d);return t.bC.multiply(c,c,u)}(u[0],u[1],_[0],_[1],g[0],g[1],y[0],y[1]);this.elevatedGlobePerspectiveTransform=uv(u[0],u[1],_[0],_[1],g[0],g[1],y[0],y[1]);const x=(e,i)=>{d.push(e.lng);const n=Math.round((e.lng-h)/f*uo),o=Math.round((e.lat-p)/m*uo),s=c(i),a=t._.transformMat3([],[s[0],s[1],1],v),l=Math.round(a[0]/a[2]*uo),u=Math.round(a[1]/a[2]*uo);r.emplaceBack(n,o,l,u)},b=n[3].x-n[0].x,w=n[3].y-n[0].y,T=n[2].x-n[1].x,S=n[2].y-n[1].y;for(let t=0;t{i.emplaceBack(e,n,r);const o=d[e],s=d[n],a=d[r],l=Math.min(Math.min(o,s),a),c=Math.max(Math.max(o,s),a)-l;c>this.maxLongitudeTriangleSize&&(this.maxLongitudeTriangleSize=c),t.push(l+c/2)};for(let t=0;te));i.sort(((e,i)=>t[e]-t[i]));const n=[],r=new Kl;for(let o=0;o{o.segments.push({vertexOffset:0,primitiveOffset:t,vertexLength:e.segments[0].vertexLength,primitiveLength:i,sortKey:void 0,vaos:{}})},a=.51*this.maxLongitudeTriangleSize;if(Math.abs(i[0]-n)0){const n=function(e,i){const n=i.worldSize,r=Cd(1,0)*n*kd(i.center.lat,i.zoom)/Gu(n),o=Cd(1,i.center.lat)*n,s=t.ad.identity([]);return t.ad.rotateY(s,s,Ge(i.center.lng)),t.ad.rotateX(s,s,Ge(i.center.lat)),t.ad.translate(s,s,[0,0,ed]),t.ad.scale(s,s,[r,r,r*o]),t.ad.translate(s,s,[i.point.x-.5*n,i.point.y-.5*n,0]),t.ad.multiply(s,s,e),t.ad.multiply(s,i.globeMatrix,s)}(e,i);return function(e,i,n){const r=(e,i,n)=>{const r=t._.length(e),o=t._.length(i),s=ku(e,i,n);return t._.scale(s,s,1/t._.length(s)*Vn(r,o,n))},o=r([e[0],e[1],e[2]],[i[0],i[1],i[2]],n),s=r([e[4],e[5],e[6]],[i[4],i[5],i[6]],n),a=r([e[8],e[9],e[10]],[i[8],i[9],i[10]],n),l=ku([e[12],e[13],e[14]],[i[12],i[13],i[14]],n);return[o[0],o[1],o[2],0,s[0],s[1],s[2],0,a[0],a[1],a[2],0,l[0],l[1],l[2],1]}(o,n,r)}return o}function kv(t,e,i,n){const r=wu.projectAabbCorners(n,i);let o=Number.MAX_VALUE,s=-1;for(let t=0;tnew Ue(r[t][0],r[t][1]);let l;switch(s){case 0:case 6:l=[a(1),a(5),a(4),a(7),a(3),a(2),a(1)];break;case 1:case 7:l=[a(0),a(4),a(5),a(6),a(2),a(3),a(0)];break;case 3:case 5:l=[a(1),a(0),a(4),a(7),a(6),a(2),a(1)];break;default:l=[a(1),a(5),a(6),a(7),a(3),a(0),a(1)]}if(Yd(t,l))return o}const Dv=Ll([{name:"a_pos_3f",components:3,type:"Float32"}]),zv=Ll([{name:"a_color_3f",components:3,type:"Float32"}]),Rv=Ll([{name:"a_color_4f",components:4,type:"Float32"}]),Ov=Ll([{name:"a_uv_2f",components:2,type:"Float32"}]),Bv=Ll([{name:"a_normal_3f",components:3,type:"Float32"}]),Fv=Ll([{name:"a_normal_matrix0",components:4,type:"Float32"},{name:"a_normal_matrix1",components:4,type:"Float32"},{name:"a_normal_matrix2",components:4,type:"Float32"},{name:"a_normal_matrix3",components:4,type:"Float32"}]),Nv=Ll([{name:"a_pbr",components:4,type:"Uint16"},{name:"a_heightBasedEmissiveStrength",components:3,type:"Float32"}]);class Uv{constructor(t,e,i,n){this.message=(t?`${t}: `:"")+i,n&&(this.identifier=n),null!=e&&e.__line__&&(this.line=e.__line__)}}function jv(t,e){const i=-1===t.indexOf("://");try{return new URL(t,i&&e?"http://example.com":void 0),!0}catch(t){return!1}}class Vv{constructor(t,e){this.feature=t,this.instancedDataOffset=e,this.instancedDataCount=0,this.rotation=[0,0,0],this.scale=[1,1,1],this.translation=[0,0,0]}}class Gv{constructor(){this.instancedDataArray=new oc,this.instancesEvaluatedElevation=[],this.features=[],this.idToFeaturesIndex={}}}class Zv{constructor(t){this.zoom=t.zoom,this.canonical=t.canonical,this.layers=t.layers,this.layerIds=this.layers.map((t=>t.fqid)),this.projection=t.projection,this.index=t.index,this.hasZoomDependentProperties=this.layers[0].isZoomDependent(),this.stateDependentLayerIds=this.layers.filter((t=>t.isStateDependent())).map((t=>t.id)),this.hasPattern=!1,this.instancesPerModel={},this.validForExaggeration=0,this.maxVerticalOffset=0,this.maxScale=0,this.maxHeight=0,this.lookupDim=this.zoom>this.canonical.z?256:this.zoom>15?75:100,this.instanceCount=0,this.terrainElevationMin=0,this.terrainElevationMax=0,this.validForDEMTile={id:null,timestamp:0},this.modelUris=[],this.modelsRequested=!1,this.activeReplacements=[],this.replacementUpdateTime=0}updateFootprints(t,e){}populate(t,e,i,n){this.tileToMeter=zd(i);const r=this.layers[0]._featureFilter.needGeometry;this.lookup=new Uint8Array(this.lookupDim*this.lookupDim);for(const{feature:o,id:s,index:a,sourceLayerIndex:l}of t){const t=null!=s?s:o.properties&&o.properties.hasOwnProperty("id")?o.properties.id:void 0,c=Zd(o,r);if(!this.layers[0]._featureFilter.filter(new Ha(this.zoom),c,i))continue;const d={id:t,sourceLayerIndex:l,index:a,geometry:r?c.geometry:Gd(o,i,n),properties:o.properties,type:o.type,patterns:{}},u=this.addFeature(d,d.geometry,c);u&&e.featureIndex.insert(o,d.geometry,a,l,this.index,this.instancesPerModel[u].instancedDataArray.length,uo/32)}this.lookup=null}update(t,e,i,n){for(const e in this.instancesPerModel){const i=this.instancesPerModel[e];for(const e in t)i.idToFeaturesIndex.hasOwnProperty(e)&&(this.evaluate(i.features[i.idToFeaturesIndex[e]],t[e],i,!0),this.uploaded=!1)}this.maxHeight=0}updateZoomBasedPaintProperties(){if(!this.hasZoomDependentProperties)return!1;let e=!1;for(const i in this.instancesPerModel){const n=this.instancesPerModel[i];for(const i of n.features){const r=this.layers[0],o=i.feature,s=this.canonical,a=r.paint.get("model-rotation").evaluate(o,{},s),l=r.paint.get("model-scale").evaluate(o,{},s),c=r.paint.get("model-translation").evaluate(o,{},s);t._.exactEquals(i.rotation,a)&&t._.exactEquals(i.scale,l)&&t._.exactEquals(i.translation,c)||(this.evaluate(i,i.featureStates,n,!0),e=!0)}}return e}updateReplacement(t,e,i){if(e.updateTime===this.replacementUpdateTime)return!1;this.replacementUpdateTime=e.updateTime;const n=e.getReplacementRegionsForTile(t.toUnwrapped(),!0);if(Pp(this.activeReplacements,n))return!1;this.activeReplacements=n;let r=!1;for(const e in this.instancesPerModel){const n=this.instancesPerModel[e],o=n.instancedDataArray;for(const e of n.features){const n=e.instancedDataOffset,s=e.instancedDataCount;for(let e=0;euo?a-uo:a;const l=Math.floor(a),c=o.float32[s+1];let d=!1;for(const e of this.activeReplacements)if(!(e.orderl||l>e.max.x||e.min.y>c||c>e.max.y)&&(d=Op(Rp(l,c,t.canonical,e.footprintTileId.canonical),e),d))break;o.float32[s]=d?a+uo:a,r=r||d}}}return r}isEmpty(){for(const t in this.instancesPerModel)if(0!==this.instancesPerModel[t].instancedDataArray.length)return!1;return!0}uploadPending(){return!this.uploaded}upload(t){if(!this.uploaded)for(const e in this.instancesPerModel){const i=this.instancesPerModel[e];i.instancedDataArray.length=uo||e.y=uo)continue;const t=(this.lookupDim-1)/uo,i=this.lookupDim*(e.y*t|0)+e.x*t|0;if(this.lookup){if(0!==this.lookup[i])continue;this.lookup[i]=1}this.instanceCount++;const n=s.length;s.resize(n+1),o.instancesEvaluatedElevation.push(0),s.float32[16*n]=e.x,s.float32[16*n+1]=e.y}return a.instancedDataCount=o.instancedDataArray.length-a.instancedDataOffset,a.instancedDataCount>0&&(t.id&&(o.idToFeaturesIndex[t.id]=o.features.length),o.features.push(a),this.evaluate(a,{},o,!1)),r}getModelUris(){return this.modelUris}evaluate(t,e,i,n){const r=this.layers[0],o=t.feature,s=this.canonical,a=t.rotation=r.paint.get("model-rotation").evaluate(o,e,s),l=t.scale=r.paint.get("model-scale").evaluate(o,e,s),c=t.translation=r.paint.get("model-translation").evaluate(o,e,s),d=r.paint.get("model-color").evaluate(o,e,s);d.a=r.paint.get("model-color-mix-intensity").evaluate(o,e,s);const u=[];this.maxVerticalOffset10?this.tileToMeter:zd(s,p)),a[o+4]=c[0],a[o+5]=c[1],a[o+6]=c[2]+l,a[o+7]=u[0],a[o+8]=u[1],a[o+9]=u[2],a[o+10]=u[4],a[o+11]=u[5],a[o+12]=u[6],a[o+13]=u[8],a[o+14]=u[9],a[o+15]=u[10],i.instancesEvaluatedElevation[r]=c[2]}}}ba(Zv,"ModelBucket",{omit:["layers"]}),ba(Gv,"PerModelAttributes"),ba(Vv,"ModelFeature");const qv=new ol({visibility:new il(sl.layout_model.visibility),"model-id":new nl(sl.layout_model["model-id"])});var Hv={paint:new ol({"model-opacity":new il(sl.paint_model["model-opacity"]),"model-rotation":new nl(sl.paint_model["model-rotation"]),"model-scale":new nl(sl.paint_model["model-scale"]),"model-translation":new nl(sl.paint_model["model-translation"]),"model-color":new nl(sl.paint_model["model-color"]),"model-color-mix-intensity":new nl(sl.paint_model["model-color-mix-intensity"]),"model-type":new il(sl.paint_model["model-type"]),"model-cast-shadows":new il(sl.paint_model["model-cast-shadows"]),"model-receive-shadows":new il(sl.paint_model["model-receive-shadows"]),"model-ambient-occlusion-intensity":new il(sl.paint_model["model-ambient-occlusion-intensity"]),"model-emissive-strength":new nl(sl.paint_model["model-emissive-strength"]),"model-roughness":new nl(sl.paint_model["model-roughness"]),"model-height-based-emissive-strength-multiplier":new nl(sl.paint_model["model-height-based-emissive-strength-multiplier"]),"model-cutoff-fade-range":new il(sl.paint_model["model-cutoff-fade-range"]),"model-front-cutoff":new il(sl.paint_model["model-front-cutoff"])}),layout:qv};const Wv=64,Yv={CoordinateSpaceTile:1,CoordinateSpaceYUp:2,HasMapboxMeshFeatures:4,HasMeshoptCompression:8};function Xv(e,i,n,r,o,s,a,l,c,d=!1){const u=n.zoom,h=n.project(r),p=kd(r.lat,u),f=1/p;t.ad.identity(e),t.ad.translate(e,e,[h.x+a[0]*f,h.y+a[1]*f,a[2]]);let m=1,_=1;const g=n.worldSize;if(d){if("mercator"===n.projection.name){let e=0;n.elevation&&(e=n.elevation.getAtPointOrZero(new Rd(h.x/g,h.y/g),0));const i=t.aA.transformMat4([],[h.x,h.y,e,1],n.projMatrix)[3]/n.cameraToCenterDistance;m=i,_=i*kd(n.center.lat,u)}else if("globe"===n.projection.name){const i=$v(e,n),o=t.ad.multiply([],n.projMatrix,i),s=[0,0,0,1];t.aA.transformMat4(s,s,o);const a=s[3]/n.cameraToCenterDistance,l=Hu(u),c=n.projection.pixelsPerMeter(r.lat,g)*kd(r.lat,u),d=n.projection.pixelsPerMeter(n.center.lat,g)*kd(n.center.lat,u);m=a/Vn(c,$d(n.center.lat),l),_=a*p/c,m*=d,_*=d}}else m=f;t.ad.scale(e,e,[m,m,_]);const y=[...e],v=i.orientation,x=[];if(Lv(x,[v[0]+o[0],v[1]+o[1],v[2]+o[2]],s),t.ad.multiply(e,y,x),l&&n.elevation){let o=0;const s=[];if(c&&n.elevation){o=function(e,i,n,r,o){const s=i.elevation;if(!s)return 0;const a=wu.projectAabbCorners(n,r),l=Cd(1,o.lat)*i.worldSize,c=function(e,i){const n=[0,0,1],r=[{corners:[0,1,3,2],dotProductWithUp:0},{corners:[1,5,2,6],dotProductWithUp:0},{corners:[0,4,1,5],dotProductWithUp:0},{corners:[2,6,3,7],dotProductWithUp:0},{corners:[4,7,5,6],dotProductWithUp:0},{corners:[0,3,4,7],dotProductWithUp:0}];for(const o of r){const r=e[o.corners[0]],s=e[o.corners[1]],a=e[o.corners[2]],l=[s[0]-r[0],s[1]-r[1],i*(s[2]-r[2])],c=t._.cross(l,l,[a[0]-r[0],a[1]-r[1],i*(a[2]-r[2])]);t._.normalize(c,c),o.dotProductWithUp=t._.dot(c,n)}return r.sort(((t,e)=>t.dotProductWithUp-e.dotProductWithUp)),r[0].corners}(a,l),d=a[c[0]],u=a[c[1]],h=a[c[2]],p=a[c[3]],f=s.getAtPointOrZero(new Rd(d[0]/i.worldSize,d[1]/i.worldSize),0),m=s.getAtPointOrZero(new Rd(u[0]/i.worldSize,u[1]/i.worldSize),0),_=s.getAtPointOrZero(new Rd(h[0]/i.worldSize,h[1]/i.worldSize),0),g=s.getAtPointOrZero(new Rd(p[0]/i.worldSize,p[1]/i.worldSize),0),y=(f+g)/2,v=(m+_)/2;return y>v?m=e.gl.NEAREST_MIPMAP_NEAREST}),t.uploaded=!0,t.image=null)}function Jv(t,e,i){t.indexBuffer=e.createIndexBuffer(t.indexArray,!1,!0),t.vertexBuffer=e.createVertexBuffer(t.vertexArray,Dv.members,!1,!0),t.normalArray&&(t.normalBuffer=e.createVertexBuffer(t.normalArray,Bv.members,!1,!0)),t.texcoordArray&&(t.texcoordBuffer=e.createVertexBuffer(t.texcoordArray,Ov.members,!1,!0)),t.colorArray&&(t.colorBuffer=e.createVertexBuffer(t.colorArray,(12===t.colorArray.bytesPerElement?zv:Rv).members,!1,!0)),t.featureArray&&(t.pbrBuffer=e.createVertexBuffer(t.featureArray,Nv.members,!0)),t.segments=wc.simpleSegment(0,0,t.vertexArray.length,t.indexArray.length);const n=t.material;n.pbrMetallicRoughness.baseColorTexture&&Kv(n.pbrMetallicRoughness.baseColorTexture,e),n.pbrMetallicRoughness.metallicRoughnessTexture&&Kv(n.pbrMetallicRoughness.metallicRoughnessTexture,e),n.normalTexture&&Kv(n.normalTexture,e),n.occlusionTexture&&Kv(n.occlusionTexture,e,i),n.emissionTexture&&Kv(n.emissionTexture,e)}function Qv(t,e,i){if(t.meshes)for(const n of t.meshes)Jv(n,e,i);if(t.children)for(const n of t.children)Qv(n,e,i)}function tx(t){if(t.meshes)for(const e of t.meshes)e.indexArray.destroy(),e.vertexArray.destroy(),e.colorArray&&e.colorArray.destroy(),e.normalArray&&e.normalArray.destroy(),e.texcoordArray&&e.texcoordArray.destroy(),e.featureArray&&e.featureArray.destroy();if(t.children)for(const e of t.children)tx(e)}function ex(t){if(t.meshes)for(const i of t.meshes)i.vertexBuffer&&(i.vertexBuffer.destroy(),i.indexBuffer.destroy(),i.normalBuffer&&i.normalBuffer.destroy(),i.texcoordBuffer&&i.texcoordBuffer.destroy(),i.colorBuffer&&i.colorBuffer.destroy(),i.pbrBuffer&&i.pbrBuffer.destroy(),i.segments.destroy(),i.material&&((e=i.material).pbrMetallicRoughness.baseColorTexture&&e.pbrMetallicRoughness.baseColorTexture.gfxTexture&&e.pbrMetallicRoughness.baseColorTexture.gfxTexture.destroy(),e.pbrMetallicRoughness.metallicRoughnessTexture&&e.pbrMetallicRoughness.metallicRoughnessTexture.gfxTexture&&e.pbrMetallicRoughness.metallicRoughnessTexture.gfxTexture.destroy(),e.normalTexture&&e.normalTexture.gfxTexture&&e.normalTexture.gfxTexture.destroy(),e.emissionTexture&&e.emissionTexture.gfxTexture&&e.emissionTexture.gfxTexture.destroy(),e.occlusionTexture&&e.occlusionTexture.gfxTexture&&e.occlusionTexture.gfxTexture.destroy()));var e;if(t.children)for(const e of t.children)ex(e)}class ix{constructor(t){this._callback=t,this._triggered=!1,"undefined"!=typeof MessageChannel&&(this._channel=new MessageChannel,this._channel.port2.onmessage=()=>{this._triggered=!1,this._callback()})}trigger(){this._triggered||(this._triggered=!0,this._channel?this._channel.port1.postMessage(!0):setTimeout((()=>{this._triggered=!1,this._callback()}),0))}remove(){this._channel=void 0,this._callback=()=>{}}}class nx{constructor(){this.tasks={},this.taskQueue=[],ai(["process"],this),this.invoker=new ix(this.process),this.nextId=0}add(t,e){const i=this.nextId++,n=function({type:t,isSymbolTile:e,zoom:i}){return i=i||0,"message"===t?0:"maybePrepare"!==t||e?"parseTile"!==t||e?"parseTile"===t&&e?300-i:"maybePrepare"===t&&e?400-i:500:200-i:100-i}(e);if(0===n){try{t()}finally{}return null}return this.tasks[i]={fn:t,metadata:e,priority:n,id:i},this.taskQueue.push(i),this.invoker.trigger(),{cancel:()=>{delete this.tasks[i]}}}process(){try{if(this.taskQueue=this.taskQueue.filter((t=>!!this.tasks[t])),!this.taskQueue.length)return;const t=this.pick();if(null===t)return;const e=this.tasks[t];if(delete this.tasks[t],this.taskQueue.length&&this.invoker.trigger(),!e)return;e.fn()}finally{}}pick(){let t=null,e=1/0;for(let i=0;i{i&&delete this.callbacks[s],this.target.postMessage({id:s,type:"",targetMapId:n,sourceMapId:this.mapId})}}}receive(t){const e=t.data,i=e.id;if(i&&(!e.targetMapId||this.mapId===e.targetMapId))if(""===e.type){const t=this.cancelCallbacks[i];delete this.cancelCallbacks[i],t&&t.cancel()}else if(e.mustQueue||gi()){const t=this.callbacks[i],n=this.scheduler.add((()=>this.processTask(i,e)),t&&t.metadata||{type:"message"});n&&(this.cancelCallbacks[i]=n)}else this.processTask(i,e)}processTask(t,e){if(delete this.cancelCallbacks[t],""===e.type){const i=this.callbacks[t];delete this.callbacks[t],i&&(e.error?i(Ea(e.error)):i(null,Ea(e.data)))}else{const i=new Set,n=e.hasCallback?(e,n)=>{this.target.postMessage({id:t,type:"",sourceMapId:this.mapId,error:e?Sa(e):null,data:Sa(n,i)},i)}:t=>{},r=Ea(e.data);if(this.parent[e.type])this.parent[e.type](e.sourceMapId,r,n);else if(this.parent.getWorkerSource){const t=e.type.split(".");this.parent.getWorkerSource(e.sourceMapId,t[0],r.source,r.scope)[t[1]](r,n)}else n(new Error(`Could not find function ${e.type}`))}}remove(){this.scheduler.remove(),this.target.removeEventListener("message",this.receive,!1)}}class ox{constructor(t,e){this.workerPool=t,this.actors=[],this.currentActor=0,this.id=ni();const i=this.workerPool.acquire(this.id);for(let t=0;t{this.ready=!0}))}broadcast(t,e,i){Qe(this.actors,((i,n)=>{i.send(t,e,n)}),i=i||function(){})}getActor(){return this.currentActor=(this.currentActor+1)%this.actors.length,this.actors[this.currentActor]}remove(){this.actors.forEach((t=>{t.remove()})),this.actors=[],this.workerPool.release(this.id)}}ox.Actor=rx;var sx={workerUrl:"",workerClass:null,workerParams:void 0};function ax(){return null!=sx.workerClass?new sx.workerClass:new self.Worker(sx.workerUrl,sx.workerParams)}const lx="mapboxgl_preloaded_worker_pool";class cx{constructor(){this.active={}}acquire(t){if(!this.workers)for(this.workers=[];this.workers.length{t.terminate()})),this.workers=null)}isPreloaded(){return!!this.active[lx]}numActive(){return Object.keys(this.active).length}}let dx;function ux(){return dx||(dx=new cx),dx}cx.workerCount=2;let hx,px,fx,mx,_x,gx=null;function yx(){return gi()&&self.worker&&self.worker.dracoUrl?self.worker.dracoUrl:px||n.DRACO_URL}function vx(){if(gi()&&self.worker&&self.worker.meshoptUrl)return self.worker.meshoptUrl;if(mx)return mx;const t=new Uint8Array([0,97,115,109,1,0,0,0,1,4,1,96,0,0,3,3,2,0,0,5,3,1,0,1,12,1,0,10,22,2,12,0,65,0,65,0,65,0,252,10,0,0,11,7,0,65,0,253,15,26,11]);if("object"!=typeof WebAssembly)throw new Error("WebAssembly not supported, cannot instantiate meshoptimizer");return mx=WebAssembly.validate(t)?n.MESHOPT_SIMD_URL:n.MESHOPT_URL,mx}const xx={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},bx={5120:"DT_INT8",5121:"DT_UINT8",5122:"DT_INT16",5123:"DT_UINT16",5125:"DT_UINT32",5126:"DT_FLOAT32"},wx={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16};function Tx(t,e,i){const n=i.json.bufferViews.length,r=i.buffers.length;e.bufferView=n,i.json.bufferViews[n]={buffer:r,byteLength:t.byteLength},i.buffers[r]=t}const Sx="KHR_draco_mesh_compression";function Ex(t,e){const i=t.extensions&&t.extensions[Sx];if(!i)return;const n=new fx.Decoder,r=$x(e,i.bufferView),o=new fx.Mesh;if(!n.DecodeArrayToMesh(r,r.byteLength,o))throw new Error("Failed to decode Draco mesh");const s=e.json.accessors[t.indices],a=xx[s.componentType],l=s.count*a.BYTES_PER_ELEMENT,c=fx._malloc(l);a===Uint16Array?n.GetTrianglesUInt16Array(o,l,c):n.GetTrianglesUInt32Array(o,l,c),Tx(fx.memory.buffer.slice(c,c+l),s,e),fx._free(c);for(const r of Object.keys(i.attributes)){const s=n.GetAttributeByUniqueId(o,i.attributes[r]),a=e.json.accessors[t.attributes[r]],l=bx[a.componentType],c=a.count*wx[a.type]*xx[a.componentType].BYTES_PER_ELEMENT,d=fx._malloc(c);n.GetAttributeDataArrayForAllPoints(o,s,fx[l],c,d),Tx(fx.memory.buffer.slice(d,d+c),a,e),fx._free(d)}n.destroy(),o.destroy(),delete t.extensions[Sx]}const Mx="EXT_meshopt_compression";function Cx(t,e){if(!t.extensions||!t.extensions[Mx])return;const i=t.extensions[Mx],n=new Uint8Array(e.buffers[i.buffer],i.byteOffset||0,i.byteLength||0),r=new Uint8Array(i.count*i.byteStride);_x.decodeGltfBuffer(r,i.count,i.byteStride,n,i.mode,i.filter),t.buffer=e.buffers.length,t.byteOffset=0,e.buffers[t.buffer]=r.buffer,delete t.extensions[Mx]}const Ax=1179937895,Ix=new TextDecoder("utf8");function Lx(t,e){return new URL(t,e).href}function Px(t,e,i,n){return fetch(Lx(t.uri,n)).then((t=>t.arrayBuffer())).then((t=>{e.buffers[i]=t}))}function $x(t,e){const i=t.json.bufferViews[e];return new Uint8Array(t.buffers[i.buffer],i.byteOffset||0,i.byteLength)}function kx(t,e,i,n){if(t.uri){const r=Lx(t.uri,n);return fetch(r).then((t=>t.blob())).then((t=>createImageBitmap(t))).then((t=>{e.images[i]=t}))}if(void 0!==t.bufferView){const n=$x(e,t.bufferView),r=new Blob([n],{type:t.mimeType});return createImageBitmap(r).then((t=>{e.images[i]=t}))}}function Dx(t,e=0,i){const n={json:null,images:[],buffers:[]};if(new Uint32Array(t,e,1)[0]===Ax){const i=new Uint32Array(t,e);let r=2;const o=(i[r++]>>2)-3,s=i[r++]>>2;if(r++,n.json=JSON.parse(Ix.decode(i.subarray(r,r+s))),r+=s,r{const t=[],e=a&&a.includes(Sx),r=a&&a.includes(Mx);if(e&&t.push(function(){if(!fx)return hx||(hx=function(t){let e,i=null;function n(){e=new Uint8Array(i.buffer)}function r(){throw new Error("Unexpected Draco error.")}const o={a:{a:r,d:function(t,i,n){return e.copyWithin(t,i,i+n)},c:function(t){const r=e.length,o=Math.max(t>>>0,Math.ceil(1.2*r)),s=Math.ceil((o-r)/65536);try{return i.grow(s),n(),!0}catch(t){return!1}},b:r}};return(WebAssembly.instantiateStreaming?WebAssembly.instantiateStreaming(t,o):t.then((t=>t.arrayBuffer())).then((t=>WebAssembly.instantiate(t,o)))).then((t=>{const{Rb:r,Qb:o,P:s,T:a,X:l,Ja:c,La:d,Qa:u,Va:h,Wa:p,eb:f,jb:m,f:_,e:g,yb:y,zb:v,Ab:x,Bb:b,Db:w,Gb:T}=t.instance.exports;i=g;const S=(()=>{let t=0,i=0,n=0,s=0;return a=>{n&&(r(s),r(t),i+=n,n=t=0),t||(i+=128,t=o(i));const l=a.length+7&-8;let c=t;l>=i&&(n=l,c=s=o(l));for(let t=0;t{fx=t,hx=void 0})))}()),r&&t.push(function(){if(_x)return;const t=function(t){let e;const i=WebAssembly.instantiateStreaming(t,{}).then((t=>{e=t.instance,e.exports.__wasm_call_ctors()})),n={NONE:"",OCTAHEDRAL:"meshopt_decodeFilterOct",QUATERNION:"meshopt_decodeFilterQuat",EXPONENTIAL:"meshopt_decodeFilterExp"},r={ATTRIBUTES:"meshopt_decodeVertexBuffer",TRIANGLES:"meshopt_decodeIndexBuffer",INDICES:"meshopt_decodeIndexSequence"};return{ready:i,supported:!0,decodeGltfBuffer(t,i,o,s,a,l){!function(t,e,i,n,r,o,s){const a=t.exports.sbrk,l=n+3&-4,c=a(l*r),d=a(o.length),u=new Uint8Array(t.exports.memory.buffer);u.set(o,d);const h=e(c,n,r,d,o.length);if(0===h&&s&&s(c,l,r),i.set(u.subarray(c,c+n*r)),a(c-a(0)),0!==h)throw new Error(`Malformed buffer data: ${h}`)}(e,e.exports[r[a]],t,i,o,s,e.exports[n[l]])}}}(fetch(vx()));return t.ready.then((()=>{_x=t}))}()),o)for(let e=0;e{if(e&&s)for(const{primitives:t}of s)for(const e of t)Ex(e,n);if(r&&s&&l)for(const t of l)Cx(t,n);return n}))}))}function zx(t,e){const i=t.json.bufferViews[e.bufferView],n=xx[e.componentType];return new n(t.buffers[i.buffer],(e.byteOffset||0)+(i.byteOffset||0),e.count*(i.byteStride&&i.byteStride!==wx[e.type]*n.BYTES_PER_ELEMENT?i.byteStride/n.BYTES_PER_ELEMENT:wx[e.type]))}function Rx(t,e,i,n){const r=xx[e.componentType],o=function(t){switch(t){case Int8Array:return 1/127;case Uint8Array:return 1/255;case Int16Array:return 1/32767;case Uint16Array:return 1/65535;default:return 1}}(r),s=t.json.bufferViews[e.bufferView],a=s.byteStride?s.byteStride/r.BYTES_PER_ELEMENT:wx[e.type],l=i.float32,c=l.length/i.capacity;for(let t=0,i=0;t0){for(let r=0;r0){o.texcoordArray=new ic;const t=e.json.accessors[r.TEXCOORD_0];o.texcoordArray.resize(t.count);const i=zx(e,t);Rx(e,t,o.texcoordArray,i)}if(void 0!==r._FEATURE_ID_RGBA4444){const t=e.json.accessors[r._FEATURE_ID_RGBA4444];e.json.extensionsUsed&&e.json.extensionsUsed.includes("EXT_meshopt_compression")&&(o.featureData=zx(e,t))}void 0!==r._FEATURE_RGBA4444&&(o.featureData=new Uint32Array(zx(e,e.json.accessors[r._FEATURE_RGBA4444]).buffer));const u=t.material;return o.material=function(t,e){const{emissiveFactor:i=[0,0,0],alphaMode:n="OPAQUE",alphaCutoff:r=.5,normalTexture:o,occlusionTexture:s,emissiveTexture:a,doubleSided:l}=t,{baseColorFactor:c=[1,1,1,1],metallicFactor:d=1,roughnessFactor:u=1,baseColorTexture:h,metallicRoughnessTexture:p}=t.pbrMetallicRoughness||{},f=s?e[s.index]:void 0;if(s&&s.extensions&&s.extensions.KHR_texture_transform&&f){const t=s.extensions.KHR_texture_transform;f.offsetScale=[t.offset[0],t.offset[1],t.scale[0],t.scale[1]]}return{pbrMetallicRoughness:{baseColorFactor:new Un(...c),metallicFactor:d,roughnessFactor:u,baseColorTexture:h?e[h.index]:void 0,metallicRoughnessTexture:p?e[p.index]:void 0},doubleSided:l,emissiveFactor:i,alphaMode:n,alphaCutoff:r,normalTexture:o?e[o.index]:void 0,occlusionTexture:f,emissionTexture:a?e[a.index]:void 0,defined:void 0===t.defined}}(void 0!==u?e.json.materials[u]:{defined:!1},i),o}function Bx(e,i,n){const{matrix:r,rotation:o,translation:s,scale:a,mesh:l,extras:c,children:d}=e,u={};if(u.matrix=r||t.ad.fromRotationTranslationScale([],o||[0,0,0,1],s||[0,0,0],a||[1,1,1]),void 0!==l){u.meshes=n[l];const t=u.anchor=[0,0];for(const e of u.meshes){const{min:i,max:n}=e.aabb;t[0]+=i[0]+n[0],t[1]+=i[1]+n[1]}t[0]=Math.floor(t[0]/u.meshes.length/2),t[1]=Math.floor(t[1]/u.meshes.length/2)}if(c&&(c.id&&(u.id=c.id),c.lights&&(u.lights=function(t){if(!t.length)return[];const e=function(t){const e=atob(t),i=new Uint8Array(e.length);for(let t=0;t1&&n[n.length-1].equals(n[0])&&n.pop();let r=0;for(let t=0;t0&&n.reverse();const o=xh(n.flatMap((t=>[t.x,t.y])),[]);return 0===o.length?null:{vertices:n,indices:o}}function Ux(e,i){const n=[],r=[];let o=0;const s=[];for(const a of e){o=n.length;const e=a.vertexArray.float32,l=a.indexArray.uint16;for(let r=0;r0&&([r[t+1],r[t+2]]=[r[t+2],r[t+1]])}return{vertices:n,indices:r}}function jx(t){const e=function(t,e){const i=[],n=WebGL2RenderingContext;if(t.json.textures)for(const r of t.json.textures){const o={magFilter:n.LINEAR,minFilter:n.NEAREST,wrapS:n.REPEAT,wrapT:n.REPEAT};void 0!==r.sampler&&Object.assign(o,t.json.samplers[r.sampler]),i.push({image:e[r.source],sampler:o,uploaded:!1})}return i}(t,t.images),i=function(t,e){const i=[];for(const n of t.json.meshes){const r=[];for(const i of n.primitives)r.push(Ox(i,t,e));i.push(r)}return i}(t,e),{scenes:n,scene:r,nodes:o}=t.json,s=n?n[r||0].nodes:o,a=[];for(const e of s)a.push(Bx(o[e],t,i));return function(t,e,i){const n={},r=new Set;for(let o=0;o0){const e=Array.from(r.values()).sort(((t,e)=>t-e));for(let i=e.length-1;i>=0;i--)t.splice(e[i],1)}}(a,s,t.json.nodes),a}function Vx(t){t.heightmap=new Float32Array(4096),t.heightmap.fill(-1);const e=t.vertexArray.float32,i=t.aabb.min[0]-1,n=t.aabb.min[1]-1,r=Wv/(t.aabb.max[0]-i+2),o=Wv/(t.aabb.max[1]-n+2);for(let s=0;st.heightmap[c*Wv+l]&&(t.heightmap[c*Wv+l]=a)}}function Gx(e,i){const n={};n.indexArray=new Kl,n.indexArray.reserve(4*e.length),n.vertexArray=new Bl,n.vertexArray.reserve(10*e.length),n.colorArray=new Ol,n.vertexArray.reserve(10*e.length);let r=0;for(const o of e){const e=Math.min(10,Math.max(4,1.3*o.height))*i,s=[-o.normal[1],o.normal[0],0],a=Math.min(.29,.1*o.width/o.depth),l=o.width-2*o.depth*i*(a+.01),c=t._.scaleAndAdd([],o.pos,s,l/2),d=t._.scaleAndAdd([],o.pos,s,-l/2),u=[c[0],c[1],c[2]+o.height],h=[d[0],d[1],d[2]+o.height],p=t._.scaleAndAdd([],o.normal,s,a);t._.scale(p,p,e);const f=t._.scaleAndAdd([],o.normal,s,-a);t._.scale(f,f,e),t._.add(p,c,p),t._.add(f,d,f),c[2]+=.1,d[2]+=.1,n.vertexArray.emplaceBack(p[0],p[1],p[2]),n.vertexArray.emplaceBack(f[0],f[1],f[2]),n.vertexArray.emplaceBack(c[0],c[1],c[2]),n.vertexArray.emplaceBack(d[0],d[1],d[2]),n.vertexArray.emplaceBack(u[0],u[1],u[2]),n.vertexArray.emplaceBack(h[0],h[1],h[2]),n.vertexArray.emplaceBack(c[0],c[1],c[2]),n.vertexArray.emplaceBack(d[0],d[1],d[2]),n.vertexArray.emplaceBack(p[0],p[1],p[2]),n.vertexArray.emplaceBack(f[0],f[1],f[2]);const m=l/e/2;n.colorArray.emplaceBack(-m-a,-1,m,.8),n.colorArray.emplaceBack(m+a,-1,m,.8),n.colorArray.emplaceBack(-m,0,m,1.3),n.colorArray.emplaceBack(m,0,m,1.3),n.colorArray.emplaceBack(m+a,-.8,m,.7),n.colorArray.emplaceBack(m+a,-.8,m,.7),n.colorArray.emplaceBack(0,0,m,1.3),n.colorArray.emplaceBack(0,0,m,1.3),n.colorArray.emplaceBack(m+a,-1.2,m,.8),n.colorArray.emplaceBack(m+a,-1.2,m,.8),n.indexArray.emplaceBack(6+r,4+r,8+r),n.indexArray.emplaceBack(7+r,9+r,5+r),n.indexArray.emplaceBack(0+r,1+r,2+r),n.indexArray.emplaceBack(1+r,3+r,2+r),r+=10}const o={defined:!0,emissiveFactor:[0,0,0]},s={};return s.baseColorFactor=Un.white,o.pbrMetallicRoughness=s,n.material=o,n.aabb=new wu([1/0,1/0,1/0],[-1/0,-1/0,-1/0]),n}const Zx=new Float32Array(262144),qx=new Uint8Array(262144);function Hx(t){let e=0;if(t.meshes)for(const i of t.meshes)e=Math.max(e,i.aabb.max[2]);if(t.children)for(const i of t.children)e=Math.max(e,Hx(i));return e}function Wx(t,e,i){if(t.meshes)for(const n of t.meshes)n.aabb.min[0]!==1/0&&i.insert(e,n.aabb.min[0],n.aabb.min[1],n.aabb.max[0],n.aabb.max[1]);if(t.children)for(const n of t.children)Wx(n,e,i)}const Yx=["","wall","door","roof","window","lamp","logo"];class Xx{constructor(t){this.node=t,this.evaluatedRMEA=[[1,0,0,1],[1,0,0,1],[1,0,0,1],[1,0,0,1],[.4,1,0,1],[1,0,0,1],[1,0,0,1]],this.hiddenByReplacement=!1,this.evaluatedScale=[1,1,1],this.evaluatedColor=[],this.emissionHeightBasedParams=[],this.feature={type:"Point",id:t.id,geometry:[],properties:{height:Hx(t)}},this.aabb=this._getLocalBounds()}_getLocalBounds(){if(!this.node.meshes)return new wu([1/0,1/0,1/0],[-1/0,-1/0,-1/0]);if(!this.aabb){let t=0;const e=new wu([1/0,1/0,1/0],[-1/0,-1/0,-1/0]);for(const i of this.node.meshes)this.node.lightMeshIndex!==t&&(i.transformedAabb=wu.applyTransformFast(i.aabb,this.node.matrix),e.encapsulate(i.transformedAabb)),t++;this.aabb=e}return this.aabb}}class Kx{constructor(t,e,i,n,r,o){this.id=e,this.modelTraits|=Yv.CoordinateSpaceTile,this.uploaded=!1,this.hasPattern=!1,i&&(this.modelTraits|=Yv.HasMapboxMeshFeatures),n&&(this.modelTraits|=Yv.HasMeshoptCompression),this.zoom=-1,this.terrainExaggeration=1,this.projection={name:"mercator"},this.replacementUpdateTime=0,this.elevationReadFromZ=255,this.brightness=r,this.dirty=!0,this.needsUpload=!1,this.nodesInfo=[];for(const e of t)this.nodesInfo.push(new Xx(e)),Wx(e,o.featureIndexArray.length,o.grid),o.featureIndexArray.emplaceBack(this.nodesInfo.length-1,0,o.bucketLayerIDs.length-1,0)}updateFootprints(t,e){for(const i of this.getNodesInfo()){const n=i.node;n.footprint&&e.push({footprint:n.footprint,id:t})}}update(){console.log("Update 3D model bucket")}populate(){console.log("populate 3D model bucket")}uploadPending(){return!this.uploaded||this.needsUpload}upload(t){if(!this.needsUpload)return;const e=this.getNodesInfo();for(const i of e){const e=i.node;this.uploaded?this.updatePbrBuffer(e):Qv(e,t,!0)}for(const t of e)tx(t.node);this.uploaded=!0,this.needsUpload=!1}updatePbrBuffer(t){let e=!1;if(!t.meshes)return e;for(const i of t.meshes)i.pbrBuffer&&(i.pbrBuffer.updateData(i.featureArray),e=!0);return e}needsReEvaluation(t,e,i){const n=t.transform.projectionOptions,r=t.style.getBrightness(),o=this.brightness!==r;return!!(!this.uploaded||this.dirty||n.name!==this.projection.name||Jx(i.paint.get("model-color").value,o)||Jx(i.paint.get("model-color-mix-intensity").value,o)||Jx(i.paint.get("model-roughness").value,o)||Jx(i.paint.get("model-emissive-strength").value,o)||Jx(i.paint.get("model-height-based-emissive-strength-multiplier").value,o))&&(this.projection=n,this.brightness=r,!0)}evaluateScale(t,e){if(t.transform.zoom===this.zoom)return;this.zoom=t.transform.zoom;const i=this.getNodesInfo(),n=this.id.canonical;for(const t of i){const i=t.feature;t.evaluatedScale=e.paint.get("model-scale").evaluate(i,{},n)}}evaluate(t){const e=this.getNodesInfo();for(const i of e){if(!i.node.meshes)continue;const e=i.feature,n=i.node.meshes&&i.node.meshes[0].featureData,r=i.evaluatedColor[2],o=i.evaluatedRMEA[2],s=this.id.canonical;if(i.hasTranslucentParts=!1,n){for(let n=0;n=t)continue;const u=Zx[c],h=Math.abs(u);h>a&&(s=u,a=h,l=r,d=e)}if(a>.1){const o=1-(t+.5*Math.abs(l*d))/c;let a=e._dem.get(n,i)+s*o;const u=e._dem.get(n+l,i+d),h=e._dem.get(n-l,i-d,!0);(a-u)*(a-h)>0&&(a=(u+h)/2),Zx[r]=e._dem.set(n,i,a),qx[r]=t}}}}}s&&(e._demTile.needsDEMTextureUpload=!0,e._dem._timestamp=ki.now())}getNodesInfo(){return this.nodesInfo}destroy(){const t=this.getNodesInfo();for(const e of t)tx(e.node),ex(e.node)}isEmpty(){return!this.nodesInfo.length}updateReplacement(t,e){if(e.updateTime===this.replacementUpdateTime)return;this.replacementUpdateTime=e.updateTime;const i=e.getReplacementRegionsForTile(t.toUnwrapped()),n=this.getNodesInfo();for(let t=0;tt.footprint===e.footprint))}}getHeightAtTileCoord(e,i){const n=this.getNodesInfo(),r=[],o=[0,0,0],s=t.ad.identity([]);for(let a=0;ad.max[0]||i>d.max[1])continue;if(!0===l.node.hidden)return{height:0,maxHeight:l.feature.properties.height,hidden:!1,verticalScale:l.evaluatedScale[2]};t.ad.invert(s,l.node.matrix),o[0]=e,o[1]=i,t._.transformMat4(o,o,s);const u=(o[0]-c.aabb.min[0])/(c.aabb.max[0]-c.aabb.min[0])*Wv|0,h=Math.min(63,(o[1]-c.aabb.min[1])/(c.aabb.max[1]-c.aabb.min[1])*Wv|0)*Wv+Math.min(63,u),p=c.heightmap[h];if(!(p0)return{height:void 0,maxHeight:l.feature.properties.height,hidden:l.hiddenByReplacement,verticalScale:l.evaluatedScale[2]}}}}function Jx(t,e){return!t.isLightConstant&&e}function Qx(t,e,i,n,r,o,s,a){let l=(61440&e|(61440&e)>>4)>>8,c=(3840&e|(3840&e)>>4)>>4,d=240&e|(240&e)>>4;i[3]>0&&(l=Vn(l,255*i[0],i[3]),c=Vn(c,255*i[1],i[3]),d=Vn(d,255*i[2],i[3]));const u=l>16&65535,a=o?e>>16&65535:65535&e,l=(15&a)t.polygon)).flat());const g=f?l:null,[y,v]=function(e,i,n,r,o,s,a,l,c,d,u){return"globe"===e.projection.name?function(e,i,n,r,o,s,a,l,c,d,u){const h=[],p=[],f=e.projection.upVectorScale(u,e.center.lat,e.worldSize).metersToTile,m=[0,0,0,1],_=[0,0,0,1],g=(t,e,i,n)=>{t[0]=e,t[1]=i,t[2]=n,t[3]=1},y=Sf();n>0&&(n+=y),r+=y;for(const y of i){const i=[],v=[];for(const h of y){const p=h.x+o.x,y=h.y+o.y,x=e.projection.projectTilePoint(p,y,u),b=e.projection.upVector(u,h.x,h.y);let w=n,T=r;if(a){const t=Pf(p,y,n,r,a,l,c,d);w+=t.base,T+=t.top}0!==n?g(m,x.x+b[0]*f*w,x.y+b[1]*f*w,x.z+b[2]*f*w):g(m,x.x,x.y,x.z),g(_,x.x+b[0]*f*T,x.y+b[1]*f*T,x.z+b[2]*f*T),t._.transformMat4(m,m,s),t._.transformMat4(_,_,s),i.push(new Tp(m[0],m[1],m[2])),v.push(new Tp(_[0],_[1],_[2]))}h.push(i),p.push(v)}return[h,p]}(e,i,n,r,o,s,a,l,c,d,u):a?function(e,i,n,r,o,s,a,l,c){const d=[],u=[],h=[0,0,0,1];for(const p of e){const e=[],f=[];for(const d of p){const u=d.x+r.x,p=d.y+r.y,m=Pf(u,p,i,n,s,a,l,c);h[0]=u,h[1]=p,h[2]=m.base,h[3]=1,t.aA.transformMat4(h,h,o),h[3]=Math.max(h[3],1e-5);const _=new Tp(h[0]/h[3],h[1]/h[3],h[2]/h[3]);h[0]=u,h[1]=p,h[2]=m.top,h[3]=1,t.aA.transformMat4(h,h,o),h[3]=Math.max(h[3],1e-5);const g=new Tp(h[0]/h[3],h[1]/h[3],h[2]/h[3]);e.push(_),f.push(g)}d.push(e),u.push(f)}return[d,u]}(i,n,r,o,s,a,l,c,d):function(t,e,i,n,r){const o=[],s=[],a=r[8]*e,l=r[9]*e,c=r[10]*e,d=r[11]*e,u=r[8]*i,h=r[9]*i,p=r[10]*i,f=r[11]*i;for(const e of t){const t=[],i=[];for(const o of e){const e=o.x+n.x,s=o.y+n.y,m=r[0]*e+r[4]*s+r[12],_=r[1]*e+r[5]*s+r[13],g=r[2]*e+r[6]*s+r[14],y=r[3]*e+r[7]*s+r[15],v=m+a,x=_+l,b=g+c,w=Math.max(y+d,1e-5),T=m+u,S=_+h,E=g+p,M=Math.max(y+f,1e-5);t.push(new Tp(v/w,x/w,b/w)),i.push(new Tp(T/M,S/M,E/M))}o.push(t),s.push(i)}return[o,s]}(i,n,r,o,s)}(s,r,h,u,d,a,g,p,m,s.center.lat,e.tileID.canonical),x=e.queryGeometry;return function(t,e,i){let n=1/0;Kd(i,e)&&(n=Lf(i,e[0]));for(let r=0;r=3)for(let e=0;e>4;if(1!==n)throw new Error(`Got v${n} data when expected v1.`);const r=nb[15&i];if(!r)throw new Error("Unrecognized array type.");const[o]=new Uint16Array(t,2,1),[s]=new Uint32Array(t,4,1);return new rb(s,o,r,t)}constructor(t,e=64,i=Float64Array,n){if(isNaN(t)||t>1;return this.ids[i]=i,this.coords[this._pos++]=t,this.coords[this._pos++]=e,i}finish(){const t=this._pos>>1;if(t!==this.numItems)throw new Error(`Added ${t} items when expected ${this.numItems}.`);return ob(this.ids,this.coords,this.nodeSize,0,this.numItems-1,0),this._finished=!0,this}range(t,e,i,n){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");const{ids:r,coords:o,nodeSize:s}=this,a=[0,r.length-1,0],l=[];for(;a.length;){const c=a.pop()||0,d=a.pop()||0,u=a.pop()||0;if(d-u=t&&a=e&&c>1,p=o[2*h],f=o[2*h+1];p>=t&&p=e&&f=p:n>=f)&&(a.push(h+1),a.push(d),a.push(1-c))}return l}within(t,e,i){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");const{ids:n,coords:r,nodeSize:o}=this,s=[0,n.length-1,0],a=[],l=i*i;for(;s.length;){const c=s.pop()||0,d=s.pop()||0,u=s.pop()||0;if(d-u>1,p=r[2*h],f=r[2*h+1];cb(p,f,t,e)=p:e+i>=f)&&(s.push(h+1),s.push(d),s.push(1-c))}return a}}function ob(t,e,i,n,r,o){if(r-n>1;sb(t,e,s,n,r,o),ob(t,e,i,n,s-1,1-o),ob(t,e,i,s+1,r,1-o)}function sb(t,e,i,n,r,o){for(;r>n;){if(r-n>600){const s=r-n+1,a=i-n+1,l=Math.log(s),c=.5*Math.exp(2*l/3),d=.5*Math.sqrt(l*c*(s-c)/s)*(a-s/2s&&ab(t,e,n,r);as;)l--}e[2*n+o]===s?ab(t,e,n,l):(l++,ab(t,e,l,r)),lr&&(n+=(t[i]-r)*(t[i]-r)),e[i]0&&n[0]0&&n[1]0&&r[0]0&&r[1]0?Math.acos(i/n)*Ve:0;let o=0!==t||0!==e?Math.atan2(-e,-t)*Ve+90:0;return oNi&&(t.getActor().send("enforceCacheSizeLimit",Fi),Vi=0)},t.an=gn,t.ao=class{constructor(t){this.entries={},this.scheduler=t}request(t,e,i,n){const r=this.entries[t]=this.entries[t]||{callbacks:[]};if(r.result){const[t,i]=r.result;return this.scheduler?this.scheduler.add((()=>{n(t,i)}),e):n(t,i),()=>{}}return r.callbacks.push(n),r.cancel||(r.cancel=i(((i,n)=>{r.result=[i,n];for(const t of r.callbacks)this.scheduler?this.scheduler.add((()=>{t(i,n)}),e):t(i,n);setTimeout((()=>delete this.entries[t]),3e3)}))),()=>{r.result||(r.callbacks=r.callbacks.filter((t=>t!==n)),r.callbacks.length||(r.cancel(),delete this.entries[t]))}}},t.ap=function(t,e,i){const n=JSON.stringify(t.request);return t.data&&(this.deduped.entries[n]={result:[null,t.data]}),this.deduped.request(n,{type:"parseTile",isSymbolTile:t.isSymbolTile,zoom:t.tileZoom},(e=>{const n=en(t.request,((t,n,r,o)=>{t?e(t):n&&e(null,{vectorTile:i?void 0:new bp(new Lm(n)),rawData:n,cacheControl:r,expires:o})}));return()=>{n.cancel(),e()}}),e)},t.aq=Dc,t.ar=class extends Lc{constructor(t){super(t),this.current=Fc}set(t,e,i){if(this.fetchUniformLocation(t,e))for(let t=0;t({u_camera_to_center_distance:new $c(t),u_extrude_scale:new Uc(t),u_device_pixel_ratio:new $c(t),u_matrix:new Bc(t),u_inv_rot_matrix:new Bc(t),u_merc_center:new kc(t),u_tile_id:new Dc(t),u_zoom_transition:new $c(t),u_up_dir:new Dc(t),u_emissive_strength:new $c(t)}),t.bJ=t=>({u_matrix:new Bc(t),u_pixels_to_tile_units:new Uc(t),u_device_pixel_ratio:new $c(t),u_units_to_pixels:new kc(t),u_dash_image:new Pc(t),u_gradient_image:new Pc(t),u_image_height:new $c(t),u_texsize:new kc(t),u_tile_units_to_pixels:new $c(t),u_alpha_discard_threshold:new $c(t),u_trim_offset:new kc(t),u_trim_fade_range:new kc(t),u_trim_color:new zc(t),u_emissive_strength:new $c(t)}),t.bK=t=>({u_matrix:new Bc(t),u_texsize:new kc(t),u_pixels_to_tile_units:new Uc(t),u_device_pixel_ratio:new $c(t),u_image:new Pc(t),u_units_to_pixels:new kc(t),u_tile_units_to_pixels:new $c(t),u_alpha_discard_threshold:new $c(t),u_trim_offset:new kc(t)}),t.bL=Yl,t.bM=Hf,t.bN=Om,t.bO=jm,t.bP=G_,t.bQ=c_,t.bR=th,t.bS=(t,e,i,n,r,o)=>{const s=t.transform,a="globe"===s.projection.name;let l;if("map"===o.paint.get("circle-pitch-alignment"))if(a){const t=Zu(s.zoom,e.canonical)*s._pixelsPerMercatorPixel;l=Float32Array.from([t,0,0,t])}else l=s.calculatePixelsToTileUnitsMatrix(i);else l=new Float32Array([s.pixelsToGLUnits[0],0,0,s.pixelsToGLUnits[1]]);const c={u_camera_to_center_distance:t.transform.getCameraToCenterDistance(s.projection),u_matrix:t.translatePosMatrix(e.projMatrix,i,o.paint.get("circle-translate"),o.paint.get("circle-translate-anchor")),u_device_pixel_ratio:ki.devicePixelRatio,u_extrude_scale:l,u_inv_rot_matrix:Qu,u_merc_center:[0,0],u_tile_id:[0,0,0],u_zoom_transition:0,u_up_dir:[0,0,0],u_emissive_strength:o.paint.get("circle-emissive-strength")};if(a){c.u_inv_rot_matrix=n,c.u_merc_center=r,c.u_tile_id=[e.canonical.x,e.canonical.y,1{const s=t.transform;return{u_matrix:rm(t,e,i,n),u_texsize:e.imageAtlasTexture?e.imageAtlasTexture.size:[0,0],u_pixels_to_tile_units:s.calculatePixelsToTileUnitsMatrix(e),u_device_pixel_ratio:r,u_image:0,u_tile_units_to_pixels:nm(e,s),u_units_to_pixels:[1/s.pixelsToGLUnits[0],1/s.pixelsToGLUnits[1]],u_alpha_discard_threshold:0,u_trim_offset:o}},t.bV=(t,e,i,n,r,o,s)=>{const a=t.transform,l=a.calculatePixelsToTileUnitsMatrix(e);return{u_matrix:rm(t,e,i,n),u_pixels_to_tile_units:l,u_device_pixel_ratio:o,u_units_to_pixels:[1/a.pixelsToGLUnits[0],1/a.pixelsToGLUnits[1]],u_dash_image:0,u_gradient_image:1,u_image_height:r,u_texsize:sm(i)&&e.lineAtlasTexture?e.lineAtlasTexture.size:[0,0],u_tile_units_to_pixels:nm(e,t.transform),u_alpha_discard_threshold:0,u_trim_offset:s,u_trim_fade_range:i.paint.get("line-trim-fade-range"),u_trim_color:i.paint.get("line-trim-color").toRenderColor(i.lut).toArray01(),u_emissive_strength:i.paint.get("line-emissive-strength")}},t.bW=oi,t.bX=mh,t.bY=Sf,t.bZ=bd,t.b_=_f,t.ba=function(t,e,i){const n=Hu(i.zoom),r=t.style.map._antialias,o=e.options.extStandardDerivativesForceOff||t.terrain&&t.terrain.exaggeration()>0;return 0===n&&!r&&!o},t.bb=function(e){const i=e.pixelsPerMeter,n=i/Cd(1,e.center.lat),r=t.ad.identity(new Float64Array(16));return t.ad.translate(r,r,[e.point.x,e.point.y,0]),t.ad.scale(r,r,[n,n,i]),Float32Array.from(r)},t.bc=Ou,t.bd=function(t){const e=Pd-5;t=Xe(t,-e,e)/e*90;const i=Math.pow(Math.abs(Math.sin(Ge(t))),3);return Math.round(i*(sd.length-1))},t.be=function(e,i,n,r){const o=i.getNorth(),s=i.getSouth(),a=i.getWest(),l=i.getEast(),c=10){const e=180/r;t.bC.multiply(f,f,[e/d+1,0,0,0,e/u+1,0,-.5*e/h,.5*e/p,1])}return f[2]=c,f[5]=e.x,f[8]=e.y,f},t.bf=ju,t.bg=$u,t.bh=function(e,i,n){const r=t.ad.identity(new Float64Array(16)),o=(i/(1{}}},t.bo=Gg,t.bp=ai,t.bq=class{isDataAvailableAtPoint(t){const e=this._source();if(this.isUsingMockSource()||!e||t.y1)return!1;const i=e.getSource().maxzoom,n=11)return e;const r=n.getSource().maxzoom,o=1{const s=this.getAtTileOffset(e,o.x,o.y),a=r.upVector(e.canonical,o.x,o.y),l=r.upVectorScale(e.canonical,i,n).metersToTile;return t._.scale(a,a,s*l),a}}getForTilePoints(t,e,i,n){if(this.isUsingMockSource())return!1;const r=Xp.create(this,t,n);return!!r&&(e.forEach((t=>{t[2]=this.exaggeration()*r.getElevationAt(t[0],t[1],i)})),!0)}getMinMaxForTile(t){if(this.isUsingMockSource())return null;const e=this.findDEMTileFor(t);if(!e||!e.dem)return null;const i=e.dem.tree,n=e.tileID,r=1=0?t.slice(0,e):t},t.cV=function(t){return t.indexOf(wl)>=0},t.cW=function(t){const e=t.indexOf(wl);return e>=0?t.slice(e+1):""},t.cX=function(t){const e=[],i=t.id;return void 0===i&&e.push({message:`layers.${i}: missing required property "id"`}),void 0===t.render&&e.push({message:`layers.${i}: missing required method "render"`}),t.renderingMode&&"2d"!==t.renderingMode&&"3d"!==t.renderingMode&&e.push({message:`layers.${i}: property "renderingMode" must be either "2d" or "3d"`}),e},t.cY=function(t,e,i,n){return"custom"===t.type?new vv(t,e):new ib[t.type](t,e,i,n)},t.cZ=di,t.c_=Va,t.ca=1,t.cb=Ag,t.cc=0,t.cd=ec,t.ce=function(t,e,i,n,r){return Xe((t-e)/(i-e)*(r-n)+n,n,r)},t.cf=Ns,t.cg=kd,t.ch=class{constructor(t,e,i,n){this.context=t,this.format=n,this.size=i,this.texture=t.gl.createTexture();const[r,o,s]=this.size,{gl:a}=t;a.bindTexture(a.TEXTURE_3D,this.texture),t.pixelStoreUnpackFlipY.set(!1),t.pixelStoreUnpack.set(1),t.pixelStoreUnpackPremultiplyAlpha.set(!1);let l=this.format,c=a.UNSIGNED_BYTE;this.format===a.DEPTH_COMPONENT&&(l=a.DEPTH_COMPONENT16,c=a.UNSIGNED_SHORT),this.format===a.R8&&(n=a.RED),this.format===a.R32F&&(c=a.FLOAT,n=a.RED),a.texImage3D(a.TEXTURE_3D,0,l,r,o,s,0,n,c,e.data)}bind(t,e){const{context:i}=this,{gl:n}=i;n.bindTexture(n.TEXTURE_3D,this.texture),t!==this.minFilter&&(n.texParameteri(n.TEXTURE_3D,n.TEXTURE_MAG_FILTER,t),n.texParameteri(n.TEXTURE_3D,n.TEXTURE_MIN_FILTER,t),this.minFilter=t),e!==this.wrapS&&(n.texParameteri(n.TEXTURE_3D,n.TEXTURE_WRAP_S,e),n.texParameteri(n.TEXTURE_3D,n.TEXTURE_WRAP_T,e),this.wrapS=e)}destroy(){const{gl:t}=this.context;t.deleteTexture(this.texture),this.texture=null}},t.ci=$v,t.cj=[1,1,1],t.ck=Xp,t.cl=Yv,t.cm=ql,t.cn=ic,t.co=class{constructor(){this._updateTime=0,this._sourceIds=[],this._activeRegions=[],this._prevRegions=[],this._globalClipBounds={min:new Ue(1/0,1/0),max:new Ue(-1/0,-1/0)}}clear(){this._activeRegions.length>0&&++this._updateTime,this._activeRegions=[],this._prevRegions=[]}get updateTime(){return this._updateTime}getReplacementRegionsForTile(t,e=!1){const i=$p(new Ue(0,0),new Ue(uo,uo),t),n=[];if(e&&!Lp(i,this._globalClipBounds))return n;for(const e of this._activeRegions){if(e.hiddenByOverlap)continue;if(!Lp(i,e))continue;const r=kp(e.min,e.max,t);n.push({min:r.min,max:r.max,sourceId:this._sourceIds[e.priority],footprint:e.footprint,footprintTileId:e.tileId,order:e.order,clipMask:e.clipMask})}return n}setSources(t){this._setSources(t.map((t=>({getSourceId:()=>t.cache.id,getFootprints:()=>{const e=[];for(const i of t.cache.getVisibleCoordinates()){const n=t.cache.getTile(i).buckets[t.layer];n&&n.updateFootprints(i.toUnwrapped(),e)}return e},getOrder:()=>t.order,getClipMask:()=>t.clipMask}))))}_addSource(t){const e=t.getFootprints();if(0===e.length)return;const i=t.getOrder(),n=t.getClipMask();for(const t of e){if(!t.footprint)continue;const e=$p(t.footprint.min,t.footprint.max,t.id);this._activeRegions.push({min:e.min,max:e.max,hiddenByOverlap:!1,priority:this._sourceIds.length,tileId:t.id,footprint:t.footprint,order:i,clipMask:n})}this._sourceIds.push(t.getSourceId())}_computeReplacement(){this._activeRegions.sort(((t,e)=>t.priority-e.priority||Ap(t.min,e.min)||Ap(t.max,e.max)));let t=this._activeRegions.length!==this._prevRegions.length;if(!t){let e=0;for(;!t&&e!==this._activeRegions.length;){const i=this._activeRegions[e],n=this._prevRegions[e];t=i.priority!==n.priority||!Ip(i,n)||i.order!==n.order||i.clipMask!==n.clipMask,++e}}if(t){++this._updateTime;for(const t of this._activeRegions)t.order!==1/0&&(this._globalClipBounds.min.x=Math.min(this._globalClipBounds.min.x,t.min.x),this._globalClipBounds.min.y=Math.min(this._globalClipBounds.min.y,t.min.y),this._globalClipBounds.max.x=Math.max(this._globalClipBounds.max.x,t.max.x),this._globalClipBounds.max.y=Math.max(this._globalClipBounds.max.y,t.max.y));const t=t=>{const e=this._activeRegions;if(t>=e.length)return t;const i=e[t].priority;for(;t1){let e=0,i=t(e);for(;e!==i;){let n=e;const r=e;for(;n!==i;){const t=this._activeRegions[n];t.hiddenByOverlap=!1;for(let e=0;e=0;e--)this._addSource(t[e]);this._computeReplacement()}},t.cp=Dl,t.cq=Jg,t.cr=rc,t.cs=class{constructor(t){this._createGrid(t),this._createPoles(t)}destroy(){this._poleIndexBuffer.destroy(),this._gridBuffer.destroy(),this._gridIndexBuffer.destroy(),this._poleNorthVertexBuffer.destroy(),this._poleSouthVertexBuffer.destroy();for(const t of this._poleSegments)t.destroy();for(const t of this._gridSegments)t.withSkirts.destroy(),t.withoutSkirts.destroy()}_fillGridMeshWithLods(t,e){const i=new $l,n=new Kl,r=[],o=t+1+2,s=e[0]+1,a=e[0]+1+(1+e.length),l=(t,e,i)=>{let n=t===o-1?t-2:0===t?t:t-1;return n+=i?24575:0,[n,e]};for(let t=0;tt()))},t.dB=sx,t.dC=yx,t.dD=function(t){px=ki.resolveURL(t),gx||(gx=new ox(ux(),new zn)),gx.broadcast("setDracoUrl",px)},t.dE=vx,t.dF=function(t){mx=ki.resolveURL(t),gx||(gx=new ox(ux(),new zn)),gx.broadcast("setMeshoptUrl",mx)},t.dG=ti,t.dH=ba,t.dI=dh,t.dJ=I_,t.dK=eg,t.dL=dc,t.dM=am,t.dN=Dm,t.dO=Wf,t.dP=ci,t.dQ=E_,t.dR=jg,t.dS=function(t,e,i,n,r,o,s,a,l,c,d){t.createArrays(),t.tilePixelRatio=uo/(512*t.overscaling),t.compareText={},t.iconsNeedLinear=!1;const u=t.layers[0].layout,h=t.layers[0]._unevaluatedLayout._values,p={};if("composite"===t.textSizeData.kind){const{minZoom:e,maxZoom:i}=t.textSizeData;p.compositeTextSizes=[h["text-size"].possiblyEvaluate(new Ha(e),a),h["text-size"].possiblyEvaluate(new Ha(i),a)]}if("composite"===t.iconSizeData.kind){const{minZoom:e,maxZoom:i}=t.iconSizeData;p.compositeIconSizes=[h["icon-size"].possiblyEvaluate(new Ha(e),a),h["icon-size"].possiblyEvaluate(new Ha(i),a)]}p.layoutTextSize=h["text-size"].possiblyEvaluate(new Ha(l+1),a),p.layoutIconSize=h["icon-size"].possiblyEvaluate(new Ha(l+1),a),p.textMaxSize=h["text-size"].possiblyEvaluate(new Ha(18),a);const f="map"===u.get("text-rotation-alignment")&&"point"!==u.get("symbol-placement"),m=u.get("text-size");let _=!1;for(const e of t.features)if(e.icon&&e.icon.nameSecondary){_=!0;break}for(const o of t.features){const l=u.get("text-font").evaluate(o,{},a).join(","),h=m.evaluate(o,{},a),g=p.layoutTextSize.evaluate(o,{},a),y=(p.layoutIconSize.evaluate(o,{},a),{horizontal:{},vertical:void 0}),v=o.text;let x,b=[0,0];if(v){const n=v.toString(),s=u.get("text-letter-spacing").evaluate(o,{},a)*Om,c=u.get("text-line-height").evaluate(o,{},a)*Om,d=Aa(n)?s:0,p=u.get("text-anchor").evaluate(o,{},a),m=u.get("text-variable-anchor");if(!m){const t=u.get("text-radial-offset").evaluate(o,{},a);b=t?G_(p,[t*Om,j_]):u.get("text-offset").evaluate(o,{},a).map((t=>t*Om))}let _=f?"center":u.get("text-justify").evaluate(o,{},a);const x="point"===u.get("symbol-placement"),w=x?u.get("text-max-width").evaluate(o,{},a)*Om:1/0,T=o=>{t.allowVerticalPlacement&&Ca(n)&&(y.vertical=e_(v,e,i,r,l,w,c,p,o,d,b,Jm.vertical,!0,g,h))};if(!f&&m){const t="auto"===_?m.map((t=>Z_(t))):[_];let n=!1;for(let o=0;o=0||!Ca(n)){const t=e_(v,e,i,r,l,w,c,p,_,d,b,Jm.horizontal,!1,g,h);t&&(y.horizontal[_]=t)}T(x?"left":_)}}let w=!1;if(o.icon&&o.icon.namePrimary){const e=n[o.icon.namePrimary];e&&(x=u_(r[o.icon.namePrimary],o.icon.nameSecondary?r[o.icon.nameSecondary]:void 0,u.get("icon-offset").evaluate(o,{},a),u.get("icon-anchor").evaluate(o,{},a)),w=e.sdf,void 0===t.sdfIcons?t.sdfIcons=e.sdf:t.sdfIcons!==e.sdf&&pi("Style sheet warning: Cannot mix SDF and non-SDF icons in one buffer"),(e.pixelRatio!==t.pixelRatio||0!==u.get("icon-rotate").constantOr(1))&&(t.iconsNeedLinear=!0))}const T=X_(y.horizontal)||y.vertical;t.iconsInText||(t.iconsInText=!!T&&T.iconsInText),(T||x)&&q_(t,o,y,x,n,p,g,0,b,w,s,a,c,d,_)}o&&t.generateCollisionDebugBuffers(l,t.collisionBoxArray)},t.dT=Jf,t.dU=Yh,t.dV=bp,t.dW=Lm,t.dX=Yp,t.dY=Zy,t.dZ=wp,t.d_=cp,t.da=Wu,t.db=function(e){const i=[0,0,0],n=t.ad.identity(new Float64Array(16));return t.ad.multiply(n,e.pixelMatrix,e.globeMatrix),t._.transformMat4(i,i,n),new Ue(i[0],i[1])},t.dc=d,t.dd=c,t.de=function(t){const e=t.navigator?t.navigator.userAgent:null;return!!function(t){if(null==Ei){const e=t.navigator?t.navigator.userAgent:null;Ei=!!t.safari||!(!e||!(/\b(iPad|iPhone|iPod)\b/.test(e)||e.match("Safari")&&!e.match("Chrome")))}return Ei}(t)&&e&&(e.match("Version/15.4")||e.match("Version/15.5")||e.match(/CPU (OS|iPhone OS) (15_4|15_5) like Mac OS X/))},t.df=ni,t.dg=class{constructor(t,e,i){this._transformRequestFn=t,this._customAccessToken=e,this._silenceAuthErrors=!!i,this._createSkuToken()}_createSkuToken(){const t=function(){let t="";for(let e=0;ethis._skuTokenExpiresAt}transformRequest(t,e){return this._transformRequestFn&&this._transformRequestFn(t,e)||{url:t}}normalizeStyleURL(t,i){if(!o(t))return t;const n=un(t);return n.params.push(`sdk=js-${e}`),n.path=`/styles/v1${n.path}`,this._makeAPIURL(n,this._customAccessToken||i)}normalizeGlyphsURL(t,e){if(!o(t))return t;const i=un(t);return i.path=`/fonts/v1${i.path}`,this._makeAPIURL(i,this._customAccessToken||e)}normalizeModelURL(t,e){if(!o(t))return t;const i=un(t);return i.path=`/models/v1${i.path}`,this._makeAPIURL(i,this._customAccessToken||e)}normalizeSourceURL(t,e,i,n){if(!o(t))return t;const r=un(t);return r.path=`/v4/${r.authority}.json`,r.params.push("secure"),i&&r.params.push(`language=${i}`),n&&r.params.push(`worldview=${n}`),this._makeAPIURL(r,this._customAccessToken||e)}normalizeSpriteURL(t,e,i,n){const r=un(t);return o(t)?(r.path=`/styles/v1${r.path}/sprite${e}${i}`,this._makeAPIURL(r,this._customAccessToken||n)):(r.path+=`${e}${i}`,hn(r))}normalizeTileURL(t,e,i){if(this._isSkuTokenExpired()&&this._createSkuToken(),t&&!o(t))return t;const r=un(t);r.path=r.path.replace(/(\.(png|jpg)\d*)(?=$)/,`${e||i&&"raster"!==r.authority&&512===i?"@2x":""}${Gi.supported?".webp":"$1"}`),"raster"===r.authority?r.path=`/${n.RASTER_URL_PREFIX}${r.path}`:"rasterarrays"===r.authority?r.path=`/${n.RASTERARRAYS_URL_PREFIX}${r.path}`:"3dtiles"===r.authority?r.path=`/${n.TILES3D_URL_PREFIX}${r.path}`:(r.path=r.path.replace(/^.+\/v4\//,"/"),r.path=`/${n.TILE_URL_VERSION}${r.path}`);const s=this._customAccessToken||function(t){for(const e of t){const t=e.match(/^access_token=(.*)$/);if(t)return t[1]}return null}(r.params)||n.ACCESS_TOKEN;return n.REQUIRE_ACCESS_TOKEN&&s&&this._skuToken&&r.params.push(`sku=${this._skuToken}`),this._makeAPIURL(r,s)}canonicalizeTileURL(t,e){const i=un(t);if(!i.path.match(/^(\/v4\/|\/(raster|rasterarrays)\/v1\/)/)||!i.path.match(/\.[\w]+$/))return t;let r="mapbox://";i.path.match(/^\/raster\/v1\//)?r+=`raster/${i.path.replace(`/${n.RASTER_URL_PREFIX}/`,"")}`:i.path.match(/^\/rasterarrays\/v1\//)?r+=`rasterarrays/${i.path.replace(`/${n.RASTERARRAYS_URL_PREFIX}/`,"")}`:r+=`tiles/${i.path.replace(`/${n.TILE_URL_VERSION}/`,"")}`;let o=i.params;return e&&(o=o.filter((t=>!t.match(/^access_token=/)))),o.length&&(r+=`?${o.join("&")}`),r}canonicalizeTileset(t,e){const i=!!e&&o(e),n=[];for(const e of t.tiles||[])r(e)?n.push(this.canonicalizeTileURL(e,i)):n.push(e);return n}_makeAPIURL(t,e){const i="See https://docs.mapbox.com/api/overview/#access-tokens-and-token-scopes",r=un(n.API_URL);if(t.protocol=r.protocol,t.authority=r.authority,"http"===t.protocol){const e=t.params.indexOf("secure");e>=0&&t.params.splice(e,1)}if("/"!==r.path&&(t.path=`${r.path}${t.path}`),!n.REQUIRE_ACCESS_TOKEN)return hn(t);if(e=e||n.ACCESS_TOKEN,!this._silenceAuthErrors){if(!e)throw new Error(`An API access token is required to use Mapbox GL. ${i}`);if("s"===e[0])throw new Error(`Use a public access token (pk.*) with Mapbox GL, not a secret access token (sk.*). ${i}`)}return t.params=t.params.filter((t=>-1===t.indexOf("access_token"))),t.params.push(`access_token=${e||""}`),hn(t)}},t.dh=function(t,e){e?Mn.add(t):Mn.delete(t)},t.di=Gi,t.dj=Tn,t.dk=En,t.dl=cn,t.dm=vn,t.dn=bn,t.dp=function(t){Mn.delete(t)},t.dq=Sn,t.dr=yn,t.ds=Qe,t.dt=e,t.du=function(t,e){Fi=t,Ni=e},t.dv=function(t,e,i=!1){if(Fa===za||Fa===Ra||Fa===Oa)throw new Error("setRTLTextPlugin cannot be called multiple times.");Na=ki.resolveURL(t),Fa=za,Ba=e,ja(),i||Za()},t.dw=Ga,t.dx=function(){ux().acquire(lx)},t.dy=function(){const t=dx;t&&(t.isPreloaded()&&1===t.numActive()?(t.release(lx),dx=null):console.warn("Could not clear WebWorkers since there are active Map instances that still reference it. The pre-warmed WebWorker pool can only be cleared when all map instances have been removed with map.remove()"))},t.dz=cx,t.e=ki,t.e0=cm,t.e1=h,t.e2=en,t.e3=function(t){let e=0;if(new Uint32Array(t,0,1)[0]!==Ax){const i=new Uint32Array(t,0,7),[,,n,r,o,s]=i;e=i.byteLength+r+o+s+o,(n!==t.byteLength||e>=t.byteLength)&&pi("Invalid b3dm header information.")}return Dx(t,e)},t.e4=function(t,e){const i=jx(t);for(const t of i){for(const e of t.meshes)Vx(e);t.lights&&(t.lightMeshIndex=t.meshes.length,t.meshes.push(Gx(t.lights,e)))}return i},t.e5=Kx,t.e6=rx,t.e7=qa,t.e8=function(t){ji(),Oi&&Oi.then((e=>{e.keys().then((i=>{for(let n=0;nt.arrayBuffer())).then((e=>Dx(e,0,t)))},t.m=class extends Uv{},t.n=Er,t.o=qn,t.p=Qg,t.q=Xs,t.r=Js,t.s=Qs,t.t=ca,t.u=al,t.v=ll,t.w=pi,t.x=pa,t.y=da,t.z=qo})),n(0,(function(t){function e(t){const e=t?t.url.toString():void 0;return e?performance.getEntriesByName(e):[]}function i(t){if("number"==typeof t||"boolean"==typeof t||"string"==typeof t||null==t)return JSON.stringify(t);if(Array.isArray(t)){let e="[";for(const n of t)e+=`${i(n)},`;return`${e}]`}let e="{";for(const n of Object.keys(t).sort())e+=`${n}:${i(t[n])},`;return`${e}}`}function n(e){let n="";for(const r of t.cE)n+=`/${i(e[r])}`;return n}class r{constructor(t){this.keyCache={},this._layers={},this._layerConfigs={},t&&this.replace(t)}replace(t,e){this._layerConfigs={},this._layers={},this.update(t,[],e)}update(e,i,r){this._options=r;for(const i of e)this._layerConfigs[i.id]=i,(this._layers[i.id]=t.cY(i,this.scope,null,this._options)).compileFilter(),this.keyCache[i.id]&&delete this.keyCache[i.id];for(const t of i)delete this.keyCache[t],delete this._layerConfigs[t],delete this._layers[t];this.familiesBySource={};const o=function(t,e){const i={};for(let r=0;rthis._layers[t.id])),i=e[0];if("none"===i.visibility)continue;const n=i.source||"";let r=this.familiesBySource[n];r||(r=this.familiesBySource[n]={});const o=i.sourceLayer||"_geojsonTileLayer";let s=r[o];s||(s=r[o]=[]),s.push(e)}}}const o=1*t.dJ;class s{constructor(e){const i={},n=[];for(const t in e){const r=e[t],s=i[t]={};for(const t in r.glyphs){const e=r.glyphs[+t];if(!e||0===e.bitmap.width||0===e.bitmap.height)continue;const i=e.metrics.localGlyph?o:1,a={x:0,y:0,w:e.bitmap.width+2*i,h:e.bitmap.height+2*i};n.push(a),s[t]=a}}const{w:r,h:s}=t.j(n),a=new t.dI({width:r||1,height:s||1});for(const n in e){const r=e[n];for(const e in r.glyphs){const s=r.glyphs[+e];if(!s||0===s.bitmap.width||0===s.bitmap.height)continue;const l=i[n][e],c=s.metrics.localGlyph?o:1;t.dI.copy(s.bitmap,a,{x:0,y:0},{x:l.x+c,y:l.y+c},s.bitmap)}}this.image=a,this.positions=i}}t.dH(s,"GlyphAtlas");class a{constructor(e){this.tileID=new t.aL(e.tileID.overscaledZ,e.tileID.wrap,e.tileID.canonical.z,e.tileID.canonical.x,e.tileID.canonical.y),this.tileZoom=e.tileZoom,this.uid=e.uid,this.zoom=e.zoom,this.lut=e.lut,this.canonical=e.tileID.canonical,this.pixelRatio=e.pixelRatio,this.tileSize=e.tileSize,this.source=e.source,this.scope=e.scope,this.overscaling=this.tileID.overscaleFactor(),this.showCollisionBoxes=e.showCollisionBoxes,this.collectResourceTiming=!!e.collectResourceTiming,this.promoteId=e.promoteId,this.isSymbolTile=e.isSymbolTile,this.tileTransform=t.dK(e.tileID.canonical,e.projection),this.projection=e.projection,this.brightness=e.brightness,this.extraShadowCaster=!!e.extraShadowCaster,this.tessellationStep=e.tessellationStep}parse(e,i,n,r,o){this.status="parsing",this.data=e,this.collisionBoxArray=new t.dL;const a=new t.dM(Object.keys(e.layers).sort()),c=new t.dN(this.tileID,this.promoteId);c.bucketLayerIDs=[];const d={},u=new t.dO(256,256),h={featureIndex:c,iconDependencies:{},patternDependencies:{},glyphDependencies:{},lineAtlas:u,availableImages:n,brightness:this.brightness},p=i.familiesBySource[this.source];for(const i in p){const r=e.layers[i];if(!r)continue;let o=!1,s=!1,u=!1;for(const t of p[i])"symbol"===t[0].type?o=!0:s=!0,t[0].is3D()&&"model"!==t[0].type&&(u=!0);if(this.extraShadowCaster&&!u)continue;if(!0===this.isSymbolTile&&!o)continue;if(!1===this.isSymbolTile&&!s)continue;1===r.version&&t.w(`Vector tile source "${this.source}" layer "${i}" does not use vector tile spec v2 and therefore may have some rendering errors.`);const f=a.encode(i),m=[];for(let t=0;t=e.maxzoom||"none"!==e.visibility&&(l(t,this.zoom,h.brightness,n),(d[e.id]=e.createBucket({index:c.bucketLayerIDs.length,layers:t,zoom:this.zoom,lut:this.lut,canonical:this.canonical,pixelRatio:this.pixelRatio,overscaling:this.overscaling,collisionBoxArray:this.collisionBoxArray,sourceLayerIndex:f,sourceID:this.source,projection:this.projection.spec,tessellationStep:this.tessellationStep})).populate(m,h,this.tileID.canonical,this.tileTransform),c.bucketLayerIDs.push(t.map((t=>t.id)))))}}let f,m,_,g;u.trim();const y={type:"maybePrepare",isSymbolTile:this.isSymbolTile,zoom:this.zoom},v=()=>{if(f)return this.status="done",o(f);if(this.extraShadowCaster)this.status="done",o(null,{buckets:t.dG(d).filter((t=>!t.isEmpty())),featureIndex:c,collisionBoxArray:null,glyphAtlasImage:null,lineAtlas:null,imageAtlas:null,brightness:h.brightness,glyphMap:null,iconMap:null,glyphPositions:null});else if(m&&_&&g){const e=new s(m),i=new t.dQ(_,g,this.lut);for(const r in d){const o=d[r];o instanceof t.dR?(l(o.layers,this.zoom,h.brightness,n),t.dS(o,m,e.positions,_,i.iconPositions,this.showCollisionBoxes,n,this.tileID.canonical,this.tileZoom,this.projection,this.brightness)):o.hasPattern&&(o instanceof t.dT||o instanceof t.dU||o instanceof t.b_)&&(l(o.layers,this.zoom,h.brightness,n),o.addFeatures(h,this.tileID.canonical,i.patternPositions,n,this.tileTransform,this.brightness))}this.status="done",o(null,{buckets:t.dG(d).filter((t=>!t.isEmpty())),featureIndex:c,collisionBoxArray:this.collisionBoxArray,glyphAtlasImage:e.image,lineAtlas:u,imageAtlas:i,brightness:h.brightness})}};if(!this.extraShadowCaster){const e=t.dP(h.glyphDependencies,(t=>Object.keys(t).map(Number)));Object.keys(e).length?r.send("getGlyphs",{uid:this.uid,stacks:e,scope:this.scope},((t,e)=>{f||(f=t,m=e,v())}),void 0,!1,y):m={};const i=Object.keys(h.iconDependencies);i.length?r.send("getImages",{icons:i,source:this.source,scope:this.scope,tileID:this.tileID,type:"icons"},((t,e)=>{f||(f=t,_=e,v())}),void 0,!1,y):_={};const n=Object.keys(h.patternDependencies);n.length?r.send("getImages",{icons:n,source:this.source,scope:this.scope,tileID:this.tileID,type:"patterns"},((t,e)=>{f||(f=t,g=e,v())}),void 0,!1,y):g={}}v()}}function l(e,i,n,r){const o=new t.X(i,{brightness:n});for(const t of e)t.recalculate(o,r)}class c extends t.E{constructor(e,i,n,r,o,s){super(),this.actor=e,this.layerIndex=i,this.availableImages=n,this.loadVectorData=o||t.ap,this.loading={},this.loaded={},this.deduped=new t.ao(e.scheduler),this.isSpriteLoaded=r,this.scheduler=e.scheduler,this.brightness=s}loadTile(i,n){const r=i.uid,o=i&&i.request,s=o&&o.collectResourceTiming,l=this.loading[r]=new a(i);l.abort=this.loadVectorData(i,((a,c)=>{const d=!this.loading[r];if(delete this.loading[r],d||a||!c)return l.status="done",d||(this.loaded[r]=l),n(a);const u=c.rawData,h={};c.expires&&(h.expires=c.expires),c.cacheControl&&(h.cacheControl=c.cacheControl),l.vectorTile=c.vectorTile||new t.dV(new t.dW(u));const p=()=>{l.parse(l.vectorTile,this.layerIndex,this.availableImages,this.actor,((i,r)=>{if(i||!r)return n(i);const a={};if(s){const t=e(o);t.length>0&&(a.resourceTiming=JSON.parse(JSON.stringify(t)))}n(null,t.W({rawTileData:u.slice(0)},r,h,a))}))};this.isSpriteLoaded?p():this.once("isSpriteLoaded",(()=>{this.scheduler?this.scheduler.add(p,{type:"parseTile",isSymbolTile:i.isSymbolTile,zoom:i.tileZoom}):p()})),this.loaded=this.loaded||{},this.loaded[r]=l}))}reloadTile(e,i){const n=this.loaded,r=e.uid;if(n&&n[r]){const o=n[r];o.showCollisionBoxes=e.showCollisionBoxes,o.projection=e.projection,o.brightness=e.brightness,o.tileTransform=t.dK(e.tileID.canonical,e.projection),o.extraShadowCaster=e.extraShadowCaster,o.lut=e.lut;const s=(t,e)=>{const n=o.reloadCallback;n&&(delete o.reloadCallback,o.parse(o.vectorTile,this.layerIndex,this.availableImages,this.actor,n)),i(t,e)};"parsing"===o.status?o.reloadCallback=s:"done"===o.status&&(o.vectorTile?o.parse(o.vectorTile,this.layerIndex,this.availableImages,this.actor,s):s())}else i(null,void 0)}abortTile(t,e){const i=t.uid,n=this.loading[i];n&&(n.abort&&n.abort(),delete this.loading[i]),e()}removeTile(t,e){const i=this.loaded,n=t.uid;i&&i[n]&&delete i[n],e()}}class d{loadTile(e,i){const{uid:n,encoding:r,rawImageData:o,padding:s}=e,a=ImageBitmap&&o instanceof ImageBitmap?this.getImageData(o,s):o;i(null,new t.dX(n,a,r,s{n(null,t)}),(t=>{n(t)}))}}const h=t.dZ.prototype.toGeoJSON;let p=class{constructor(e){this._feature=e,this.extent=t.a3,this.type=e.type,this.properties=e.tags,"id"in e&&!isNaN(e.id)&&(this.id=parseInt(e.id,10))}loadGeometry(){if(1===this._feature.type){const e=[];for(const i of this._feature.geometry)e.push([new t.P(i[0],i[1])]);return e}{const e=[];for(const i of this._feature.geometry){const n=[];for(const e of i)n.push(new t.P(e[0],e[1]));e.push(n)}return e}}toGeoJSON(t,e,i){return h.call(this,t,e,i)}},f=class{constructor(e){this.layers={_geojsonTileLayer:this},this.name="_geojsonTileLayer",this.extent=t.a3,this.length=e.length,this._features=e}feature(t){return new p(this._features[t])}};const m=64/4096;class _{constructor(){this.features=new Map}clear(){this.features.clear()}load(t=[],e){for(const i of t){const t=i.id;if(null==t)continue;let n=this.features.get(t);n&&this.updateCache(n,e),i.geometry?(n=y(i),this.updateCache(n,e),this.features.set(t,n)):this.features.delete(t),this.updateCache(n,e)}}updateCache(t,e){for(const{canonical:i,uid:n}of Object.values(e)){const{z:r,x:o,y:s}=i;g(t,Math.pow(2,r),o,s)&&delete e[n]}}getTile(t,e,i){const n=Math.pow(2,t),r=[];for(const t of this.features.values())g(t,n,e,i)&&r.push(w(t,n,e,i));return{features:r}}getFeatures(){return[...this.features.values()]}}function g({minX:t,minY:e,maxX:i,maxY:n},r,o,s){return t(o-m)/r&&n>(s-m)/r}function y(t){const{id:e,geometry:i,properties:n}=t;if(!i)return;if("GeometryCollection"===i.type)throw new Error("GeometryCollection not supported in dynamic mode.");const{type:r,coordinates:o}=i,s={id:e,type:1,geometry:[],tags:n,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0},a=s.geometry;if("Point"===r)v(o,a,s);else if("MultiPoint"===r)for(const t of o)v(t,a,s);else if("LineString"===r)s.type=2,x(o,a,s);else if("MultiLineString"===r)s.type=2,b(o,a,s);else if("Polygon"===r)s.type=3,b(o,a,s,!0);else{if("MultiPolygon"!==r)throw new Error("Input data is not a valid GeoJSON object.");s.type=3;for(const t of o)b(t,a,s,!0)}return s}function v([e,i],n,r){const o=t.aj(e);let s=t.ak(i);s=s1?1:s,n.push(o,s),r.minX=Math.min(r.minX,o),r.minY=Math.min(r.minY,s),r.maxX=Math.max(r.maxX,o),r.maxY=Math.max(r.maxY,s)}function x(t,e,i,n=!1,r=!1){const o=[];for(const e of t)v(e,o,i);e.push(o),n&&function(t,e){let i=0;for(let e=0,n=t.length,r=n-2;e0===e)for(let e=0,i=t.length;e>31}function F(t,e){for(var i=t.loadGeometry(),n=t.type,r=0,o=0,s=i.length,a=0;at},V=Math.fround||(G=new Float32Array(1),t=>(G[0]=+t,G[0]));var G;const Z=3,q=5,H=6;class W{constructor(t){this.options=Object.assign(Object.create(j),t),this.trees=new Array(this.options.maxZoom+1),this.stride=this.options.reduce?7:6,this.clusterProps=[]}load(t){const{log:e,minZoom:i,maxZoom:n}=this.options;e&&console.time("total time");const r=`prepare ${t.length} points`;e&&console.time(r),this.points=t;const o=[];for(let e=0;e=i;t--){const i=+Date.now();s=this.trees[t]=this._createTree(this._cluster(s,t)),e&&console.log("z%d: %d clusters in %dms",t,s.numItems,+Date.now()-i)}return e&&console.timeEnd("total time"),this}getClusters(t,e){let i=((t[0]+180)%360+360)%360-180;const n=Math.max(-90,Math.min(90,t[1]));let r=180===t[2]?180:((t[2]+180)%360+360)%360-180;const o=Math.max(-90,Math.min(90,t[3]));if(t[2]-t[0]>=360)i=-180,r=180;else if(i>r){const t=this.getClusters([i,n,180,o],e),s=this.getClusters([-180,n,r,o],e);return t.concat(s)}const s=this.trees[this._limitZoom(e)],a=s.range(K(i),J(o),K(r),J(n)),l=s.data,c=[];for(const t of a){const e=this.stride*t;c.push(l[e+q]>1?Y(l,e,this.clusterProps):this.points[l[e+Z]])}return c}getChildren(t){const e=this._getOriginId(t),i=this._getOriginZoom(t),n="No cluster with the specified id.",r=this.trees[i];if(!r)throw new Error(n);const o=r.data;if(e*this.stride>=o.length)throw new Error(n);const s=this.options.radius/(this.options.extent*Math.pow(2,i-1)),a=r.within(o[e*this.stride],o[e*this.stride+1],s),l=[];for(const e of a){const i=e*this.stride;o[i+4]===t&&l.push(o[i+q]>1?Y(o,i,this.clusterProps):this.points[o[i+Z]])}if(0===l.length)throw new Error(n);return l}getLeaves(t,e,i){const n=[];return this._appendLeaves(n,t,e=e||10,i=i||0,0),n}getTile(t,e,i){const n=this.trees[this._limitZoom(t)],r=Math.pow(2,t),{extent:o,radius:s}=this.options,a=s/o,l=(i-a)/r,c=(i+1+a)/r,d={features:[]};return this._addTileFeatures(n.range((e-a)/r,l,(e+1+a)/r,c),n.data,e,i,r,d),0===e&&this._addTileFeatures(n.range(1-a/r,l,1,c),n.data,r,i,r,d),e===r-1&&this._addTileFeatures(n.range(0,l,a/r,c),n.data,-1,i,r,d),d.features.length?d:null}getClusterExpansionZoom(t){let e=this._getOriginZoom(t)-1;for(;e1;let l,c,d;if(a)l=X(e,t,this.clusterProps),c=e[t],d=e[t+1];else{const i=this.points[e[t+Z]];l=i.properties;const[n,r]=i.geometry.coordinates;c=K(n),d=J(r)}const u={type:1,geometry:[[Math.round(this.options.extent*(c*r-i)),Math.round(this.options.extent*(d*r-n))]],tags:l};let h;h=a||this.options.generateId?e[t+Z]:this.points[e[t+Z]].id,void 0!==h&&(u.id=h),o.features.push(u)}}_limitZoom(t){return Math.max(this.options.minZoom,Math.min(Math.floor(+t),this.options.maxZoom+1))}_cluster(t,e){const{radius:i,extent:n,reduce:r,minPoints:o}=this.options,s=i/(n*Math.pow(2,e)),a=t.data,l=[],c=this.stride;for(let i=0;ie&&(p+=a[i+q])}if(p>h&&p>=o){let t,o=n*h,s=d*h,f=-1;const m=(i/c1)for(const t of u){const i=t*c;if(!(a[i+2]>5}_getOriginZoom(t){return(t-this.points.length)%32}_map(t,e,i){if(t[e+q]>1){const n=this.clusterProps[t[e+H]];return i?Object.assign({},n):n}const n=this.points[t[e+Z]].properties,r=this.options.map(n);return i&&r===n?Object.assign({},r):r}}function Y(t,e,i){return{type:"Feature",id:t[e+Z],properties:X(t,e,i),geometry:{type:"Point",coordinates:[(n=t[e],360*(n-.5)),Q(t[e+1])]}};var n}function X(t,e,i){const n=t[e+q],r=n>=1e4?`${Math.round(n/1e3)}k`:n>=1e3?Math.round(n/100)/10+"k":n,o=t[e+H],s=-1===o?{}:Object.assign({},i[o]);return Object.assign(s,{cluster:!0,cluster_id:t[e+Z],point_count:n,point_count_abbreviated:r})}function K(t){return t/360+.5}function J(t){const e=Math.sin(t*Math.PI/180),i=.5-.25*Math.log((1+e)/(1-e))/Math.PI;return i1?1:i}function Q(t){const e=(180-360*t)*Math.PI/180;return 360*Math.atan(Math.exp(e))/Math.PI-90}function tt(t,e,i,n){let r=n;const o=e+(i-e>>1);let s,a=i-e;const l=t[e],c=t[e+1],d=t[i],u=t[i+1];for(let n=e+3;n i[1]&&(i[1]=e)}processBorderOverlap(t,e){if(t.x===e.x){if(t.y===e.y)return;const i=0===t.x?0:1;this.addBorderIntersection(i,e.y),this.addBorderIntersection(i,t.y)}else{const i=0===t.y?2:3;this.addBorderIntersection(i,e.x),this.addBorderIntersection(i,t.x)}}centroid(){return 0===this.accCount?new Ue(0,0):new Ue(Math.floor(Math.max(0,this.acc.x)/this.accCount),Math.floor(Math.max(0,this.acc.y)/this.accCount))}intersectsCount(){return this.borders?this.borders.reduce(((t,e)=>t+ +(e[0]!==Number.MAX_VALUE)),0):0}}function hf(t,e){const i=t.add(e)._unit(),n=Xe(t.x*i.x+t.y*i.y,-1,1);var r,o,s;return r=Math.acos(n),Math.min(4,Math.max(-4,Math.tan(r)))/4*nf*((o=t).x*(s=e).y-o.y*s.xt.xt.x>uo,t=>t.yt.y>uo];function ff(t,e,i,n){const r=[4];if(0===n)return r;i._mult(n);const o=t.sub(i),s=e.sub(i),a=[t,e,o,s];for(let t=0;ttf.includes(t))),this._segments=new wc,this.hiddenByLandmarkVertexArray=new lc,this._segmentToGroundQuads={},this._segmentToGroundQuads[0]=[],this._segmentToRegionTriCounts={},this._segmentToRegionTriCounts[0]=[0,0,0,0,0],this.regionSegments={},this.regionSegments[4]=new wc}getDefaultSegment(){return this.regionSegments[4]}hasData(){return 0!==this.vertexArray.length}addData(t,e,i,n=!1){const r=t.length;if(r>2){let o=Math.max(0,this._segments.get().length-1);const s=this._segments._prepareSegment(4*r,this.vertexArray.length,2*this._segmentToGroundQuads[o].length);let a;o!==this._segments.get().length-1&&(o++,this._segmentToGroundQuads[o]=[],this._segmentToRegionTriCounts[o]=[0,0,0,0,0]);{const e=t[0],i=t[1];a=hf(e.sub(t[r-1])._perp()._unit(),i.sub(e)._perp()._unit())}for(let l=0;lt.region-e.region));for(let i=0;it+e),0);let o=0;for(let t=0;t0?this.hiddenByLandmarkVertexBuffer=t.createVertexBuffer(this.hiddenByLandmarkVertexArray,sp.members,!0):this.hiddenByLandmarkVertexBuffer&&this.hiddenByLandmarkVertexBuffer.updateData(this.hiddenByLandmarkVertexArray),this._needsHiddenByLandmarkUpdate=!1)}destroy(){if(this.vertexBuffer){this.vertexBuffer.destroy(),this.indexBuffer.destroy(),this.hiddenByLandmarkVertexBuffer&&this.hiddenByLandmarkVertexBuffer.destroy(),this._segments&&this._segments.destroy(),this.programConfigurations.destroy();for(let t=0;tt.fqid)),this.index=t.index,this.hasPattern=!1,this.edgeRadius=0,this.projection=t.projection,this.activeReplacements=[],this.replacementUpdateTime=0,this.centroidData=[],this.footprintIndices=new Kl,this.footprintVertices=new $l,this.footprintSegments=[],this.layoutVertexArray=new Dl,this.centroidVertexArray=new vc,this.indexArray=new Kl,this.programConfigurations=new Yc(t.layers,{zoom:t.zoom,lut:t.lut},(t=>Qp.includes(t))),this.segments=new wc,this.stateDependentLayerIds=this.layers.filter((t=>t.isStateDependent())).map((t=>t.id)),this.groundEffect=new mf(t),this.maxHeight=0,this.partLookup={},this.triangleSubSegments=[],this.polygonSegments=[]}updateFootprints(t,e){}populate(t,e,i,n){this.features=[],this.hasPattern=Hh("fill-extrusion",this.layers,e),this.featuresOnBorder=[],this.borderFeatureIndices=[[],[],[],[]],this.borderDoneWithNeighborZ=[-1,-1,-1,-1],this.tileToMeter=zd(i),this.edgeRadius=this.layers[0].layout.get("fill-extrusion-edge-radius")/this.tileToMeter;for(const{feature:r,id:o,index:s,sourceLayerIndex:a}of t){const t=this.layers[0]._featureFilter.needGeometry,l=Zd(r,t);if(!this.layers[0]._featureFilter.filter(new Ha(this.zoom),l,i))continue;const c={id:o,sourceLayerIndex:a,index:s,geometry:t?l.geometry:Gd(r,i,n),properties:r.properties,type:r.type,patterns:{}},d=this.layoutVertexArray.length;this.hasPattern?this.features.push(Wh("fill-extrusion",this.layers,c,this.zoom,e)):this.addFeature(c,c.geometry,s,i,{},e.availableImages,n,e.brightness),e.featureIndex.insert(r,c.geometry,s,a,this.index,d)}this.sortBorders(),"mercator"===this.projection.name&&this.splitToSubtiles(),this.groundEffect.prepareBorderSegments(),this.polygonSegments.length=0}addFeatures(t,e,i,n,r,o){for(const t of this.features){const{geometry:s}=t;this.addFeature(t,s,t.index,e,i,n,r,o)}this.sortBorders(),"mercator"===this.projection.name&&this.splitToSubtiles()}update(t,e,i,n,r){const o=0!==Object.keys(t).length;if(o&&!this.stateDependentLayers.length)return;const s=o?this.stateDependentLayers:this.layers;this.programConfigurations.updatePaintArrays(t,e,s,i,n,r),this.groundEffect.update(t,e,s,i,n,r)}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload||this.groundEffect.programConfigurations.needsUpload}upload(t){this.uploaded||(this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,lp),this.indexBuffer=t.createIndexBuffer(this.indexArray),this.layoutVertexExtArray&&(this.layoutVertexExtBuffer=t.createVertexBuffer(this.layoutVertexExtArray,ap.members,!0)),this.groundEffect.upload(t)),this.groundEffect.uploadPaintProperties(t),this.programConfigurations.upload(t),this.uploaded=!0}uploadCentroid(t){this.groundEffect.uploadHiddenByLandmark(t),this.needsCentroidUpdate&&(!this.centroidVertexBuffer&&this.centroidVertexArray.length>0?this.centroidVertexBuffer=t.createVertexBuffer(this.centroidVertexArray,op.members,!0):this.centroidVertexBuffer&&this.centroidVertexBuffer.updateData(this.centroidVertexArray),this.needsCentroidUpdate=!1)}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.centroidVertexBuffer&&this.centroidVertexBuffer.destroy(),this.layoutVertexExtBuffer&&this.layoutVertexExtBuffer.destroy(),this.groundEffect.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy())}addFeature(t,e,i,n,r,o,s,a){const l=this.layers[0].paint.get("fill-extrusion-flood-light-ground-radius").evaluate(t,{})/this.tileToMeter,c=[new Ue(0,0),new Ue(uo,uo)],d=s.projection,u="globe"===d.name,h="Polygon"===Jp[t.type],p=new uf;p.centroidDataIndex=this.centroidData.length;const f=new df,m=this.layers[0].paint.get("fill-extrusion-base").evaluate(t,{},n)=0;t--){const e=g[t];(0===e.length||(y=e[0]).every((t=>t.xt.x>=uo))||y.every((t=>t.yt.y>=uo)))&&g.splice(t,1)}var y;let v;if(u)v=Ef(g,c,n);else{v=[];for(const t of g)v.push({polygon:t,bounds:c})}const x=h?this.edgeRadius:0,b=x>0&&this.zoom{if(0===t.length)return!1;const i=t[t.length-1];return e.x===i.x&&e.y===i.y};for(const{polygon:t,bounds:e}of v){let i=0,r=0;for(const e of t)h&&!e[0].equals(e[e.length-1])&&e.push(e[0]),r+=h?e.length-1:e.length;const o=this.segments.prepareSegment((h?5:4)*r,this.layoutVertexArray,this.indexArray);f.footprintSegIdx4&&wf(s[s.length-2],s[0],s[1]),c=x?yf(s[s.length-2],s[0],s[1],x):0;const _=[];let g,y,v;y=s[1].sub(s[0])._perp()._unit();let b=!0;for(let t=1,r=0;t0?1:0,C=l.dist(h);if(r+C>32768&&(r=0),x){v=T.sub(h)._perp()._unit();let t=vf(l,h,T,gf(y,v),x);isNaN(t)&&(t=0);const e=h.sub(l)._unit();l=l.add(e.mult(c))._round(),h=h.add(e.mult(-t))._round(),c=t,y=v,m&&this.zoom>=17&&(w(_,l)||_.push(l),w(_,h)||_.push(h))}const A=o.vertexLength,I=s.length>4&&wf(l,h,T);let L=Tf(r,a,b);if(sf(this.layoutVertexArray,l.x,l.y,E,M,0,0,L),sf(this.layoutVertexArray,l.x,l.y,E,M,0,1,L),r+=C,L=Tf(r,I,!b),a=I,sf(this.layoutVertexArray,h.x,h.y,E,M,0,0,L),sf(this.layoutVertexArray,h.x,h.y,E,M,0,1,L),o.vertexLength+=4,this.indexArray.emplaceBack(A+0,A+1,A+2),this.indexArray.emplaceBack(A+1,A+3,A+2),o.primitiveLength+=2,x){const n=i+(1===t?s.length-2:t-2),r=1===t?i:n+1;if(this.indexArray.emplaceBack(A+1,n,A+3),this.indexArray.emplaceBack(n,r,A+3),o.primitiveLength+=2,void 0===g&&(g=A),!xf(T,s[t],e)){const e=t===s.length-1?g:o.vertexLength;this.indexArray.emplaceBack(A+2,A+3,e),this.indexArray.emplaceBack(A+3,e+1,e),this.indexArray.emplaceBack(A+3,r,e+1),o.primitiveLength+=3}b=!b}if(u){const t=this.layoutVertexExtArray,e=d.projectTilePoint(l.x,l.y,n),i=d.projectTilePoint(h.x,h.y,n),r=d.upVector(n,l.x,l.y),o=d.upVector(n,h.x,h.y);lf(t,e,r),lf(t,e,r),lf(t,i,o),lf(t,i,o)}}h&&(i+=s.length-1),m&&x&&this.zoom>=17&&(0!==_.length&&w(_,_[0])&&_.pop(),this.groundEffect.addData(_,e,l,x>0))}this.footprintSegments.push(a),s.triangleCount=this.indexArray.length-s.triangleArrayOffset,this.polygonSegments.push(s),++f.footprintSegLen,++f.polygonSegLen}if(f.vertexCount=this.layoutVertexArray.length-f.vertexArrayOffset,f.groundVertexCount=this.groundEffect.vertexArray.length-f.groundVertexArrayOffset,0!==f.vertexCount){if(f.centroidXY=p.borders?rf:this.encodeCentroid(p,f),this.centroidData.push(f),p.borders){this.featuresOnBorder.push(p);const t=this.featuresOnBorder.length-1;for(let e=0;ethis.featuresOnBorder[e].borders[t][0]-this.featuresOnBorder[i].borders[t][0]))}splitToSubtiles(){const t=[];for(let e=0;euo),r=2*n+(+(i.min.x+i.max.x>uo)^n);for(let n=0;nt.triangleSegmentIdx===e.triangleSegmentIdx?t.subtile-e.subtile:t.triangleSegmentIdx-e.triangleSegmentIdx));let i=0,n=0,r=0;for(const e of t){if(e.triangleSegmentIdx!==i)break;r++}const o=t.length;for(;n!==t.length;){i=t[n].triangleSegmentIdx;let s=0,a=n,l=n;for(let e=a;e0&&this.triangleSubSegments.push({segment:d,min:o,max:c}),a=l;for(let e=a;e[t[0]*(1-i[0])+e[0]*i[0],t[1]*(1-i[1])+e[1]*i[1]],h=[],p=[];for(const t of this.triangleSubSegments){h[0]=t.min.x/uo,h[1]=t.min.y/uo,p[0]=t.max.x/uo,p[1]=t.max.y/uo;const e=u(l,c,h),o=u(l,c,p);if(0===new wu([e[0],e[1],n],[o[0],o[1],r]).intersectsPrecise(i)){a&&(d.segments.push(a),a=void 0);continue}const s=t.segment;a&&a.vertexOffset!==s.vertexOffset&&(d.segments.push(a),a=void 0),a?(a.vertexLength+=s.vertexLength,a.primitiveLength+=s.primitiveLength):a={vertexOffset:s.vertexOffset,primitiveLength:s.primitiveLength,vertexLength:s.vertexLength,primitiveOffset:s.primitiveOffset,sortKey:void 0,vaos:{}}}return a&&d.segments.push(a),d}encodeCentroid(t,e){const i=t.centroid(),n=e.span(),r=Math.min(7,Math.round(n.x*this.tileToMeter/10)),o=Math.min(7,Math.round(n.y*this.tileToMeter/10));return new Ue(Xe(i.x,1,uo-1)i.max.x||i.min.x>e.max.x||e.min.y>i.max.y||i.min.y>e.max.y))for(let o=0;oe!=l>e&&to.max.x||o.min.x>t||e>o.max.y||o.min.y>e||this.footprintContainsPoint(t,e,o)&&o&&o.height>i&&(i=o.height,this.partLookup[r]=o,n=!!(o.flags&of));if(i!==Number.NEGATIVE_INFINITY)return{height:i,hidden:n};this.partLookup[r]=void 0}}function gf(t,e){const i=t.add(e)._unit();return t.x*i.x+t.y*i.y}function yf(t,e,i,n){const r=e.sub(t)._perp()._unit(),o=i.sub(e)._perp()._unit();return vf(t,e,i,gf(r,o),n)}function vf(t,e,i,n,r){const o=Math.sqrt(1-n*n);return Math.min(t.dist(e)/3,e.dist(i)/3,r*o/n)}function xf(t,e,i){return t.xi[1].x&&e.x>i[1].x||t.yi[1].y&&e.y>i[1].y}function bf(t,e){return t.xe[1].x||t.ye[1].y}function wf(t,e,i){if(t.x=uo||e.x=uo||i.x=uo)return!1;const n=i.sub(e),r=n.perp(),o=t.sub(e);return(n.x*o.x+n.y*o.y)/Math.sqrt((n.x*n.x+n.y*n.y)*(o.x*o.x+o.y*o.y))>-.866&&r.x*o.x+r.y*o.y{for(const i of t)s.push({polygon:i,bounds:e})},l=Math.ceil(Math.log2(i)),c=Math.ceil(Math.log2(n)),d=l-c,u=[];for(let t=0;t0?0:1);for(let t=0;te+1?p.push({polygons:h,bounds:t,depth:e+1}):a(h,t)}if(f.length){const t=[new Ue(0===i?d:n.x,1===i?d:n.y),s];u.length>e+1?p.push({polygons:f,bounds:t,depth:e+1}):a(f,t)}}return s}(t,e,Math.ceil((o-r)/11.25),Math.ceil((s-a)/11.25),1,((t,e,r)=>{if(0===t)return.5*(e+r);{const t=Id((i.y+e/uo)/n);return(Md(.5*(Id((i.y+r/uo)/n)+t))*n-i.y)*uo}}))}function Mf(t,e,i,n,r,o){const s=Math.pow(2,n.z-r.z);for(let a=0;a1&&(s=t[++o]);const l=Math.abs(a-s.left),c=Math.abs(a-s.right),d=Math.min(l,c);let u;const h=e/i*(n+1);if(s.isDash){const t=n-Math.abs(h);u=Math.sqrt(d*d+t*t)}else u=n-Math.sqrt(d*d+h*h);this.image.data[r+a]=Math.max(0,Math.min(255,u+128))}}}addRegularDash(t,e){for(let e=t.length-1;e>=0;--e){const i=t[e],n=t[e+1];i.zeroLength?t.splice(e,1):n&&n.isDash===i.isDash&&(n.left=i.left,t.splice(e,1))}const i=t[0],n=t[t.length-1];i.isDash===n.isDash&&(i.left=n.left-this.width,n.right=i.right+this.width);const r=this.width*this.nextRow;let o=0,s=t[o];for(let i=0;i1&&(s=t[++o]);const n=Math.abs(i-s.left),a=Math.abs(i-s.right),l=Math.min(n,a);this.image.data[r+i]=Math.max(0,Math.min(255,(s.isDash?l:-l)+e+128))}}addDash(t,e){const i=this.getKey(t,e);if(this.positions[i])return this.positions[i];const n="round"===e,r=n?7:0,o=2*r+1;if(this.nextRow+o>this.height)return pi("LineAtlas out of space"),null;0===t.length&&t.push(1);let s=0;for(let e=0;et.fqid)),this.index=t.index,this.projection=t.projection,this.hasPattern=!1,this.hasZOffset=!1,this.patternFeatures=[],this.lineClipsArray=[],this.gradients={},this.layers.forEach((t=>{this.gradients[t.id]={}})),this.layoutVertexArray=new Rl,this.layoutVertexArray2=new Ol,this.patternVertexArray=new Bl,this.indexArray=new Kl,this.programConfigurations=new Yc(t.layers,{zoom:t.zoom,lut:t.lut}),this.segments=new wc,this.maxLineLength=0,this.zOffsetVertexArray=new Zl,this.stateDependentLayerIds=this.layers.filter((t=>t.isStateDependent())).map((t=>t.id)),this.tessellationStep=t.tessellationStep?t.tessellationStep:uo/64}updateFootprints(t,e){}populate(t,e,i,n){this.hasPattern=Hh("line",this.layers,e);const r=this.layers[0].layout.get("line-sort-key"),o=this.layers[0].layout.get("line-z-offset");this.hasZOffset=!o.isConstant()||!!o.constantOr(0);const s=[];for(const{feature:e,id:o,index:a,sourceLayerIndex:l}of t){const t=this.layers[0]._featureFilter.needGeometry,c=Zd(e,t);if(!this.layers[0]._featureFilter.filter(new Ha(this.zoom),c,i))continue;const d=r?r.evaluate(c,{},i):void 0,u={id:o,properties:e.properties,type:e.type,sourceLayerIndex:l,index:a,geometry:t?c.geometry:Gd(e,i,n),patterns:{},sortKey:d};s.push(u)}r&&s.sort(((t,e)=>t.sortKey-e.sortKey));const{lineAtlas:a,featureIndex:l}=e,c=this.addConstantDashes(a);for(const n of s){const{geometry:r,index:o,sourceLayerIndex:s}=n;if(c&&this.addFeatureDashes(n,a),this.hasPattern){const t=Wh("line",this.layers,n,this.zoom,e);this.patternFeatures.push(t)}else this.addFeature(n,r,o,i,a.positions,e.availableImages,e.brightness);l.insert(t[o].feature,r,o,s,this.index)}}addConstantDashes(t){let e=!1;for(const i of this.layers){const n=i.paint.get("line-dasharray").value,r=i.layout.get("line-cap").value;if("constant"!==n.kind||"constant"!==r.kind)e=!0;else{const e=r.value,i=n.value;if(!i)continue;t.addDash(i,e)}}return e}addFeatureDashes(t,e){const i=this.zoom;for(const n of this.layers){const r=n.paint.get("line-dasharray").value,o=n.layout.get("line-cap").value;if("constant"===r.kind&&"constant"===o.kind)continue;let s,a;if("constant"===r.kind){if(s=r.value,!s)continue}else s=r.evaluate({zoom:i},t);a="constant"===o.kind?o.value:o.evaluate({zoom:i},t),e.addDash(s,a),t.patterns[n.id]=e.getKey(s,a)}}update(t,e,i,n,r){const o=0!==Object.keys(t).length;o&&!this.stateDependentLayers.length||this.programConfigurations.updatePaintArrays(t,e,o?this.stateDependentLayers:this.layers,i,n,r)}addFeatures(t,e,i,n,r,o){for(const t of this.patternFeatures)this.addFeature(t,t.geometry,t.index,e,i,n,o)}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(t){this.uploaded||(0!==this.layoutVertexArray2.length&&(this.layoutVertexBuffer2=t.createVertexBuffer(this.layoutVertexArray2,zf)),0!==this.patternVertexArray.length&&(this.patternVertexBuffer=t.createVertexBuffer(this.patternVertexArray,Of)),!this.zOffsetVertexBuffer&&this.zOffsetVertexArray.length>0&&(this.zOffsetVertexBuffer=t.createVertexBuffer(this.zOffsetVertexArray,jf.members,!0)),this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,kf),this.indexBuffer=t.createIndexBuffer(this.indexArray)),this.programConfigurations.upload(t),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.zOffsetVertexBuffer&&this.zOffsetVertexBuffer.destroy(),this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy())}lineFeatureClips(t){if(t.properties&&t.properties.hasOwnProperty("mapbox_clip_start")&&t.properties.hasOwnProperty("mapbox_clip_end"))return{start:+t.properties.mapbox_clip_start,end:+t.properties.mapbox_clip_end}}addFeature(t,e,i,n,r,o,s){const a=this.layers[0].layout,l=a.get("line-join").evaluate(t,{}),c=a.get("line-cap").evaluate(t,{}),d=a.get("line-miter-limit"),u=a.get("line-round-limit");this.lineClips=this.lineFeatureClips(t);for(const i of e)this.addLine(i,t,n,l,c,d,u);this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,t,i,r,o,n,s)}addLine(t,e,i,n,r,o,s){this.distance=0,this.scaledDistance=0,this.totalDistance=0,this.lineSoFar=0,this.currentVertex=void 0;const a={zoom:this.zoom,lineProgress:void 0},l=this.layers[0].layout,c="none"===n;if(this.patternJoinNone=this.hasPattern&&c,this.segmentStart=0,this.segmentStartf32=0,this.segmentPoints=[],this.lineClips){this.lineClipsArray.push(this.lineClips);for(let e=0;e=2&&t[u-1].equals(t[u-2]);)u--;let h=0;for(;h0;if(A&&i>h){const t=m.dist(_);if(t>2*p){const e=m.sub(m.sub(_)._mult(p/t)._round());this.updateDistance(_,e),this.addCurrentVertex(e,y,0,0,f,x),_=e}}if(b&&"round"===w&&(Mo&&(w="bevel"),"bevel"===w&&(M>2&&(w="flipbevel"),M100)S=v.mult(-1);else{const t=M*y.add(v).mag()/y.sub(v).mag();S._perp()._mult(t*(I?-1:1))}this.addCurrentVertex(m,S,0,0,f,x),this.addCurrentVertex(m,S.mult(-1),0,0,f,x)}else if("bevel"===w||"fakeround"===w){const t=-Math.sqrt(M*M-1),e=I?t:0,i=I?0:t;if(_&&this.addCurrentVertex(m,y,e,i,f,x),"fakeround"===w){const t=Math.round(180*C/Math.PI/20);for(let e=1;e2*p){const e=m.add(g.sub(m)._mult(p/t)._round());this.updateDistance(m,e),this.addCurrentVertex(e,v,0,0,f,x),m=e}}}}addVerticesTo(t,e,i,n,r,o,s,a,l,c){const d=(e.w-t.w)/this.tessellationStep|0;if(d>1){this.lineSoFar=t.w;const u=(e.x-t.x)/d,h=(e.y-t.y)/d,p=(e.z-t.z)/d,f=(e.w-t.w)/d;for(let e=1;e=0&&this.e2>=0&&(this.indexArray.emplaceBack(this.e1,this.e2,c),a.primitiveLength++),o?this.e2=c:this.e1=c,null!=l&&this.zOffsetVertexArray.emplaceBack(l)}updateScaledDistance(){if(this.lineClips){const t=this.totalDistance/(this.lineClips.end-this.lineClips.start);this.scaledDistance=this.distance/this.totalDistance,this.lineSoFar=t*this.lineClips.start+this.distance}else this.lineSoFar=this.distance}updateDistance(t,e){this.distance+=t.dist(e),this.updateScaledDistance()}}function Qf(t,e,i){return t.xi||t.yi}ba(Jf,"LineBucket",{omit:["layers","patternFeatures","currentVertex","currentVertexIsOutside"]});const tm=new ol({"line-cap":new nl(sl.layout_line["line-cap"]),"line-join":new nl(sl.layout_line["line-join"]),"line-miter-limit":new il(sl.layout_line["line-miter-limit"]),"line-round-limit":new il(sl.layout_line["line-round-limit"]),"line-sort-key":new nl(sl.layout_line["line-sort-key"]),"line-z-offset":new nl(sl.layout_line["line-z-offset"]),visibility:new il(sl.layout_line.visibility)});var em={paint:new ol({"line-opacity":new nl(sl.paint_line["line-opacity"]),"line-color":new nl(sl.paint_line["line-color"]),"line-translate":new il(sl.paint_line["line-translate"]),"line-translate-anchor":new il(sl.paint_line["line-translate-anchor"]),"line-width":new nl(sl.paint_line["line-width"]),"line-gap-width":new nl(sl.paint_line["line-gap-width"]),"line-offset":new nl(sl.paint_line["line-offset"]),"line-blur":new nl(sl.paint_line["line-blur"]),"line-dasharray":new nl(sl.paint_line["line-dasharray"]),"line-pattern":new nl(sl.paint_line["line-pattern"]),"line-gradient":new rl(sl.paint_line["line-gradient"]),"line-trim-offset":new il(sl.paint_line["line-trim-offset"]),"line-trim-fade-range":new il(sl.paint_line["line-trim-fade-range"]),"line-trim-color":new il(sl.paint_line["line-trim-color"]),"line-emissive-strength":new il(sl.paint_line["line-emissive-strength"]),"line-border-width":new nl(sl.paint_line["line-border-width"]),"line-border-color":new nl(sl.paint_line["line-border-color"]),"line-occlusion-opacity":new il(sl.paint_line["line-occlusion-opacity"])}),layout:tm};function im(t,e,i){return e*(uo/(t.tileSize*Math.pow(2,i-t.tileID.overscaledZ)))}function nm(t,e){return 1/im(t,1,e.tileZoom)}function rm(t,e,i,n){return t.translatePosMatrix(n||e.tileID.projMatrix,e,i.paint.get("line-translate"),i.paint.get("line-translate-anchor"))}const om=t=>{const e=[];sm(t)&&e.push("RENDER_LINE_DASH"),t.paint.get("line-gradient")&&e.push("RENDER_LINE_GRADIENT");const i=t.paint.get("line-trim-offset");0===i[0]&&0===i[1]||e.push("RENDER_LINE_TRIM_OFFSET"),0!==t.paint.get("line-border-width").constantOr(1)&&e.push("RENDER_LINE_BORDER");const n="none"===t.layout.get("line-join").constantOr("miter"),r=!!t.paint.get("line-pattern").constantOr(1);return n&&r&&e.push("LINE_JOIN_NONE"),e};function sm(t){const e=t.paint.get("line-dasharray").value;return e.value||"constant"!==e.kind}class am{constructor(t){this._stringToNumber={},this._numberToString=[];for(let e=0;e>1,d=-7,u=i?r-1:0,h=i?-1:1,p=t[e+u];for(u+=h,o=p&(1>=-d,d+=a;d>0;o=256*o+t[e+u],u+=h,d-=8);for(s=o&(1>=-d,d+=n;d>0;s=256*s+t[e+u],u+=h,d-=8);if(0===o)o=1-c;else{if(o===l)return s?NaN:1/0*(p?-1:1);s+=Math.pow(2,n),o-=c}return(p?-1:1)*s*Math.pow(2,o-n)},write:function(t,e,i,n,r,o){var s,a,l,c=8*o-r-1,d=(1>1,h=23===r?Math.pow(2,-24)-Math.pow(2,-77):0,p=n?0:o-1,f=n?1:-1,m=e=1?h/l:h*Math.pow(2,1-u))*l>=2&&(s++,l/=2),s+u>=d?(a=0,s=d):s+u>=1?(a=(e*l-1)*Math.pow(2,r),s+=u):(a=e*Math.pow(2,u-1)*Math.pow(2,r),s=0));r>=8;t[i+p]=255&a,p+=f,a/=256,r-=8);for(s=s0;t[i+p]=255&s,p+=f,s/=256,c-=8);t[i+p-f]|=128*m}},cm=um,dm=lm;function um(t){this.buf=ArrayBuffer.isView&&ArrayBuffer.isView(t)?t:new Uint8Array(t||0),this.pos=0,this.type=0,this.length=this.buf.length}um.Varint=0,um.Fixed64=1,um.Bytes=2,um.Fixed32=5;var hm=4294967296,pm=1/hm,fm="undefined"==typeof TextDecoder?null:new TextDecoder("utf8");function mm(t){return t.type===um.Bytes?t.readVarint()+t.pos:t.pos+1}function _m(t,e,i){return i?4294967296*e+(t>>>0):4294967296*(e>>>0)+(t>>>0)}function gm(t,e,i){var n=e=t;r--)i.buf[r+n]=i.buf[r]}function ym(t,e){for(var i=0;i>>8,t[i+2]=e>>>16,t[i+3]=e>>>24}function Im(t,e){return(t[e]|t[e+1]>3,o=this.pos;this.type=7&n,t(r,e,this),this.pos===o&&this.skip(n)}return e},readMessage:function(t,e){return this.readFields(t,e,this.readVarint()+this.pos)},readFixed32:function(){var t=Cm(this.buf,this.pos);return this.pos+=4,t},readSFixed32:function(){var t=Im(this.buf,this.pos);return this.pos+=4,t},readFixed64:function(){var t=Cm(this.buf,this.pos)+Cm(this.buf,this.pos+4)*hm;return this.pos+=8,t},readSFixed64:function(){var t=Cm(this.buf,this.pos)+Im(this.buf,this.pos+4)*hm;return this.pos+=8,t},readFloat:function(){var t=dm.read(this.buf,this.pos,!0,23,4);return this.pos+=4,t},readDouble:function(){var t=dm.read(this.buf,this.pos,!0,52,8);return this.pos+=8,t},readVarint:function(t){var e,i,n=this.buf;return e=127&(i=n[this.pos++]),i>4,r=12&&fm?function(t,e,i){return fm.decode(t.subarray(e,i))}(this.buf,e,t):function(t,e,i){for(var n="",r=e;r239?4:l>223?3:l>191?2:1;if(r+d>i)break;1===d?l=55296&&c=1114112)&&(c=null)),null===c?(c=65533,d=1):c>65535&&(c-=65536,n+=String.fromCharCode(c>>>10&1023|55296),c=56320|1023&c),n+=String.fromCharCode(c),r+=d}return n}(this.buf,e,t)},readBytes:function(){var t=this.readVarint()+this.pos,e=this.buf.subarray(this.pos,t);return this.pos=t,e},readPackedVarint:function(t,e){if(this.type!==um.Bytes)return t.push(this.readVarint(e));var i=mm(this);for(t=t||[];this.pos127;);else if(e===um.Bytes)this.pos=this.readVarint()+this.pos;else if(e===um.Fixed32)this.pos+=4;else{if(e!==um.Fixed64)throw new Error("Unimplemented type: "+e);this.pos+=8}},writeTag:function(t,e){this.writeVarint(t268435455||t=0?(i=t%4294967296|0,n=t/4294967296|0):(n=~(-t/4294967296),4294967295^(i=~(-t%4294967296))?i=i+1|0:(i=0,n=n+1|0)),t>=0x10000000000000000||t>>=7,i.buf[i.pos++]=127&t|128,t>>>=7,i.buf[i.pos++]=127&t|128,t>>>=7,i.buf[i.pos++]=127&t|128,i.buf[i.pos]=127&(t>>>=7)}(i,0,e),function(t,e){var i=(7&t)>>=3)?128:0),t&&(e.buf[e.pos++]=127&t|((t>>>=7)?128:0),t&&(e.buf[e.pos++]=127&t|((t>>>=7)?128:0),t&&(e.buf[e.pos++]=127&t|((t>>>=7)?128:0),t&&(e.buf[e.pos++]=127&t|((t>>>=7)?128:0),t&&(e.buf[e.pos++]=127&t)))))}(n,e)}(t,this):(this.realloc(4),this.buf[this.pos++]=127&t|(t>127?128:0),t>>=7)|(t>127?128:0),t>>=7)|(t>127?128:0),t>>7&127))))},writeSVarint:function(t){this.writeVarint(t55295&&n56319||o+1===e.length?(t[i++]=239,t[i++]=191,t[i++]=189):r=n;continue}if(n>6|192:(n>12|224:(t[i++]=n>>18|240,t[i++]=n>>12&63|128),t[i++]=n>>6&63|128),t[i++]=63&n|128)}return i}(this.buf,t,this.pos);var i=this.pos-e;i>=128&&gm(e,i,this),this.pos=e-1,this.writeVarint(i),this.pos+=i},writeFloat:function(t){this.realloc(4),dm.write(this.buf,t,this.pos,!0,23,4),this.pos+=4},writeDouble:function(t){this.realloc(8),dm.write(this.buf,t,this.pos,!0,52,8),this.pos+=8},writeBytes:function(t){var e=t.length;this.writeVarint(e),this.realloc(e);for(var i=0;i=128&&gm(i,n,this),this.pos=i-1,this.writeVarint(n),this.pos+=n},writeMessage:function(t,e,i){this.writeTag(t,um.Bytes),this.writeRawMessage(e,i)},writePackedVarint:function(t,e){e.length&&this.writeMessage(t,ym,e)},writePackedSVarint:function(t,e){e.length&&this.writeMessage(t,vm,e)},writePackedBoolean:function(t,e){e.length&&this.writeMessage(t,wm,e)},writePackedFloat:function(t,e){e.length&&this.writeMessage(t,xm,e)},writePackedDouble:function(t,e){e.length&&this.writeMessage(t,bm,e)},writePackedFixed32:function(t,e){e.length&&this.writeMessage(t,Tm,e)},writePackedSFixed32:function(t,e){e.length&&this.writeMessage(t,Sm,e)},writePackedFixed64:function(t,e){e.length&&this.writeMessage(t,Em,e)},writePackedSFixed64:function(t,e){e.length&&this.writeMessage(t,Mm,e)},writeBytesField:function(t,e){this.writeTag(t,um.Bytes),this.writeBytes(e)},writeFixed32Field:function(t,e){this.writeTag(t,um.Fixed32),this.writeFixed32(e)},writeSFixed32Field:function(t,e){this.writeTag(t,um.Fixed32),this.writeSFixed32(e)},writeFixed64Field:function(t,e){this.writeTag(t,um.Fixed64),this.writeFixed64(e)},writeSFixed64Field:function(t,e){this.writeTag(t,um.Fixed64),this.writeSFixed64(e)},writeVarintField:function(t,e){this.writeTag(t,um.Varint),this.writeVarint(e)},writeSVarintField:function(t,e){this.writeTag(t,um.Varint),this.writeSVarint(e)},writeStringField:function(t,e){this.writeTag(t,um.Bytes),this.writeString(e)},writeFloatField:function(t,e){this.writeTag(t,um.Fixed32),this.writeFloat(e)},writeDoubleField:function(t,e){this.writeTag(t,um.Fixed64),this.writeDouble(e)},writeBooleanField:function(t,e){this.writeVarintField(t,Boolean(e))}};var Lm=h(cm);const Pm=["id","tile","layer","source","sourceLayer","state"];class $m{constructor(t,e,i,n,r){this.type="Feature",this._vectorTileFeature=t,this._z=e,this._x=i,this._y=n,this.properties=t.properties,this.id=r}get geometry(){return void 0===this._geometry&&(this._geometry=this._vectorTileFeature.toGeoJSON(this._x,this._y,this._z).geometry),this._geometry}set geometry(t){this._geometry=t}toJSON(){const t={type:"Feature",state:void 0,geometry:this.geometry,properties:this.properties};for(const e of Pm)void 0!==this[e]&&(t[e]=this[e]);return t}}class km{constructor(){this.state={},this.stateChanges={},this.deletedStates={}}updateState(t,e,i){const n=String(e);if(this.stateChanges[t]=this.stateChanges[t]||{},this.stateChanges[t][n]=this.stateChanges[t][n]||{},ei(this.stateChanges[t][n],i),null===this.deletedStates[t]){this.deletedStates[t]={};for(const e in this.state[t])e!==n&&(this.deletedStates[t][e]=null)}else if(this.deletedStates[t]&&null===this.deletedStates[t][n]){this.deletedStates[t][n]={};for(const e in this.state[t][n])i[e]||(this.deletedStates[t][n][e]=null)}else for(const e in i)this.deletedStates[t]&&this.deletedStates[t][n]&&null===this.deletedStates[t][n][e]&&delete this.deletedStates[t][n][e]}removeFeatureState(t,e,i){if(null===this.deletedStates[t])return;const n=String(e);if(this.deletedStates[t]=this.deletedStates[t]||{},i&&void 0!==e)null!==this.deletedStates[t][n]&&(this.deletedStates[t][n]=this.deletedStates[t][n]||{},this.deletedStates[t][n][i]=null);else if(void 0!==e)if(this.stateChanges[t]&&this.stateChanges[t][n])for(i in this.deletedStates[t][n]={},this.stateChanges[t][n])this.deletedStates[t][n][i]=null;else this.deletedStates[t][n]=null;else this.deletedStates[t]=null}getState(t,e){const i=String(e),n=ei({},(this.state[t]||{})[i],(this.stateChanges[t]||{})[i]);if(null===this.deletedStates[t])return{};if(this.deletedStates[t]){const i=this.deletedStates[t][e];if(null===i)return{};for(const t in i)delete n[t]}return n}initializeTileState(t,e){t.setFeatureState(this.state,e)}coalesceChanges(t,e){const i={};for(const t in this.stateChanges){this.state[t]=this.state[t]||{};const e={};for(const i in this.stateChanges[t])this.state[t][i]||(this.state[t][i]={}),ei(this.state[t][i],this.stateChanges[t][i]),e[i]=this.state[t][i];i[t]=e}for(const t in this.deletedStates){this.state[t]=this.state[t]||{};const e={};if(null===this.deletedStates[t])for(const i in this.state[t])e[i]={},this.state[t][i]={};else for(const i in this.deletedStates[t]){if(null===this.deletedStates[t][i])this.state[t][i]={};else if(this.state[t][i])for(const e of Object.keys(this.deletedStates[t][i]))delete this.state[t][i][e];e[i]=this.state[t][i]}i[t]=i[t]||{},ei(i[t],e)}if(this.stateChanges={},this.deletedStates={},0!==Object.keys(i).length)for(const n in t)t[n].setFeatureState(i,e)}}class Dm{constructor(t,e){this.tileID=t,this.x=t.canonical.x,this.y=t.canonical.y,this.z=t.canonical.z,this.grid=new va(uo,16,0),this.featureIndexArray=new yc,this.promoteId=e,this.is3DTile=!1}insert(t,e,i,n,r,o=0,s=0){const a=this.featureIndexArray.length;this.featureIndexArray.emplaceBack(i,n,r,o);const l=this.grid;for(let t=0;t=0&&n[3]>=0&&l.insert(a,n[0],n[1],n[2],n[3])}}loadVTLayers(){if(!this.vtLayers){this.vtLayers=new bp(new Lm(this.rawTileData)).layers,this.sourceLayerCoder=new am(this.vtLayers?Object.keys(this.vtLayers).sort():["_geojsonTileLayer"]),this.vtFeatures={};for(const t in this.vtLayers)this.vtFeatures[t]=[]}return this.vtLayers}query(t,e,i,n){this.loadVTLayers();const r=t.params||{},o=dl(r.filter),s=t.tileResult,a=t.transform,l=s.bufferedTilespaceBounds,c=this.grid.query(l.min.x,l.min.y,l.max.x,l.max.y,((t,e,i,n)=>ou(s.bufferedTilespaceGeometry,t,e,i,n)));c.sort(Rm);let d=null;a.elevation&&c.length>0&&(d=Xp.create(a.elevation,this.tileID));const u={};let h;for(let l=0;l(m||(m=Gd(e,this.tileID.canonical,t.tileTransform)),i.queryIntersectsFeature(s,e,n,m,this.z,t.transform,t.pixelPosMatrix,d,r))))}return u}loadMatchingFeature(t,e,i,n,r,o,s,a,l){const{featureIndex:c,bucketIndex:d,sourceLayerIndex:u,layoutVertexArrayOffset:h}=e,p=this.bucketLayerIDs[d];if(n&&!function(t,e){for(let i=0;i=0)return!0;return!1}(n,p))return;const f=this.sourceLayerCoder.decode(u),m=this.vtLayers[f].feature(c);if(i.needGeometry){const t=Zd(m,!0);if(!i.filter(new Ha(this.tileID.overscaledZ),t,this.tileID.canonical))return}else if(!i.filter(new Ha(this.tileID.overscaledZ),m))return;const _=this.getId(m,f);for(let e=0;e{const s=e instanceof el?e.get(o):null;return s&&s.evaluate?s.evaluate(i,n,r):s}))}function Rm(t,e){return e-t}ba(Dm,"FeatureIndex",{omit:["rawTileData","sourceLayerCoder"]});var Om=24;const Bm=128;function Fm(t,e){const{expression:i}=e;if("constant"===i.kind)return{kind:"constant",layoutSize:i.evaluate(new Ha(t+1))};if("source"===i.kind)return{kind:"source"};{const{zoomStops:e,interpolationType:n}=i;let r=0;for(;r{t.text=function(t,e,i){const n=e.layout.get("text-transform").evaluate(i,{});return"uppercase"===n?t=t.toLocaleUpperCase():"lowercase"===n&&(t=t.toLocaleLowerCase()),qa.applyArabicShaping&&(t=qa.applyArabicShaping(t)),t}(t.text,e,i)})),t}const Gm={"!":"︕","#":"#",$:"$","%":"%","&":"&","(":"︵",")":"︶","*":"*","+":"+",",":"︐","-":"︲",".":"・","/":"/",":":"︓",";":"︔","":"﹀","?":"︖","@":"@","[":"﹇","\\":"\","]":"﹈","^":"^",_:"︳","`":"`","{":"︷","|":"―","}":"︸","~":"~","¢":"¢","£":"£","¥":"¥","¦":"¦","¬":"¬","¯":" ̄","–":"︲","—":"︱","‘":"﹃","’":"﹄","“":"﹁","”":"﹂","…":"︙","‧":"・","₩":"₩","、":"︑","。":"︒","〈":"︿","〉":"﹀","《":"︽","》":"︾","「":"﹁","」":"﹂","『":"﹃","』":"﹄","【":"︻","】":"︼","〔":"︹","〕":"︺","〖":"︗","〗":"︘","!":"︕","(":"︵",")":"︶",",":"︐","-":"︲",".":"・",":":"︓",";":"︔","<":"︿",">":"﹀","?":"︖","[":"﹇","]":"﹈","_":"︳","{":"︷","|":"―","}":"︸","⦅":"︵","⦆":"︶","。":"︒","「":"﹁","」":"﹂","←":"↑","→":"↓"};function Zm(t){return"︶"===t||"﹈"===t||"︸"===t||"﹄"===t||"﹂"===t||"︾"===t||"︼"===t||"︺"===t||"︘"===t||"﹀"===t||"︐"===t||"︓"===t||"︔"===t||"`"===t||" ̄"===t||"︑"===t||"︒"===t}function qm(t){return"︵"===t||"﹇"===t||"︷"===t||"﹃"===t||"﹁"===t||"︽"===t||"︻"===t||"︹"===t||"︗"===t||"︿"===t}const Hm=3;function Wm(t,e,i){e.glyphs=[],1===t&&i.readMessage(Ym,e)}function Ym(t,e,i){if(3===t){const{id:t,bitmap:n,width:r,height:o,left:s,top:a,advance:l}=i.readMessage(Xm,{});e.glyphs.push({id:t,bitmap:new dh({width:r+2*Hm,height:o+2*Hm},n),metrics:{width:r,height:o,left:s,top:a,advance:l}})}else 4===t?e.ascender=i.readSVarint():5===t&&(e.descender=i.readSVarint())}function Xm(t,e,i){1===t?e.id=i.readVarint():2===t?e.bitmap=i.readBytes():3===t?e.width=i.readVarint():4===t?e.height=i.readVarint():5===t?e.left=i.readSVarint():6===t?e.top=i.readSVarint():7===t&&(e.advance=i.readVarint())}const Km=Hm,Jm={horizontal:1,vertical:2,horizontalOnly:3};class Qm{constructor(){this.scale=1,this.fontStack="",this.imageName=null}static forText(t,e){const i=new Qm;return i.scale=t||1,i.fontStack=e,i}static forImage(t){const e=new Qm;return e.imageName=t,e}}class t_{constructor(){this.text="",this.sectionIndex=[],this.sections=[],this.imageSectionID=null}static fromFeature(t,e){const i=new t_;for(let n=0;n=0&&i>=t&&i_[this.text.charCodeAt(i)];i--)e--;this.text=this.text.substring(t,e),this.sectionIndex=this.sectionIndex.slice(t,e)}substring(t,e){const i=new t_;return i.text=this.text.substring(t,e),i.sectionIndex=this.sectionIndex.slice(t,e),i.sections=this.sections,i}toString(){return this.text}getMaxScale(){return this.sectionIndex.reduce(((t,e)=>Math.max(t,this.sections[e].scale)),0)}addTextSection(t,e){this.text+=t.text,this.sections.push(Qm.forText(t.scale,t.fontStack||e));const i=this.sections.length-1;for(let e=0;e=63743?null:++this.imageSectionID:(this.imageSectionID=57344,this.imageSectionID)}}function e_(t,e,i,n,r,o,s,a,l,c,d,u,h,p,f){const m=t_.fromFeature(t,r);u===Jm.vertical&&m.verticalizePunctuation(h);let _=[];const g=function(t,e,i,n,r,o){if(!t)return[];const s=[],a=function(t,e,i,n,r,o){let s=0;for(let i=0;i=0;let c=0;for(let i=0;i0&&o>b&&(b=o)}else{const t=i[a.fontStack];if(!t)continue;t[m]&&(S=t[m]);const n=e[a.fontStack];if(!n)continue;const o=n.glyphs[m];if(!o)continue;if(v=o.metrics,M=8203!==m?Om:0,_){const t=void 0!==n.ascender?Math.abs(n.ascender):0,e=void 0!==n.descender?Math.abs(n.descender):0,i=(t+e)*g;w-i/2;){if(s--,sn;)c-=l.shift().angleDelta;if(c>r)return!1;s++,a+=e.dist(i)}return!0}function m_(t){let e=0;for(let i=0;ic){const d=(c-l)/o,u=Vn(n.x,r.x,d),h=Vn(n.y,r.y,d),p=new p_(u,h,0,r.angleTo(n),i);return!s||f_(t,p,a,s,e)?p:void 0}l+=o}}function v_(t,e,i,n,r,o,s,a,l){const c=__(n,o,s),d=g_(n,r),u=d*s,h=0===t[0].x||t[0].x===l||0===t[0].y||t[0].y===l;return e-u=0&&g=0&&y=0&&h+c=n&&c.x>=n||(s.x>=n?s=new Ue(n,s.y+(n-s.x)/(c.x-s.x)*(c.y-s.y))._round():c.x>=n&&(c=new Ue(n,s.y+(n-s.x)/(c.x-s.x)*(c.y-s.y))._round()),s.y>=r&&c.y>=r||(s.y>=r?s=new Ue(s.x+(r-s.y)/(c.y-s.y)*(c.x-s.x),r)._round():c.y>=r&&(c=new Ue(s.x+(r-s.y)/(c.y-s.y)*(c.x-s.x),r)._round()),l&&s.equals(l[l.length-1])||(l=[s],o.push(l)),l.push(c)))))}}return o}function w_(t){let e=0,i=0;for(const n of t)e+=n.w*n.h,i=Math.max(i,n.w);t.sort(((t,e)=>e.h-t.h));const n=[{x:0,y:0,w:Math.max(Math.ceil(Math.sqrt(e/.95)),i),h:1/0}];let r=0,o=0;for(const e of t)for(let t=n.length-1;t>=0;t--){const i=n[t];if(!(e.w>i.w||e.h>i.h)){if(e.x=i.x,e.y=i.y,o=Math.max(o,e.y+e.h),r=Math.max(r,e.x+e.w),e.w===i.w&&e.h===i.h){const e=n.pop();tt.hasImage(e,i))),t.dispatchRenderCallbacks(this.haveRenderCallbacks,i);for(const n in t.getUpdatedImages(i))this.patchUpdatedImage(this.iconPositions[n],t.getImage(n,i),e),this.patchUpdatedImage(this.patternPositions[n],t.getImage(n,i),e)}patchUpdatedImage(t,e,i){if(!t||!e)return;if(t.version===e.version)return;t.version=e.version;const[n,r]=t.tl,o=!!Object.keys(this.patternPositions).length;i.update(e.data,{useMipmap:o},{x:n,y:r})}}ba(S_,"ImagePosition"),ba(E_,"ImageAtlas");const M_=1e20;function C_(t,e,i,n,r,o,s,a,l){for(let c=e;c-1);l++,o[l]=a,s[l]=c,s[l+1]=M_}for(let a=0,l=0;a{let n=this.entries[t];n||(n=this.entries[t]={glyphs:{},requests:{},ranges:{},ascender:void 0,descender:void 0});let r=n.glyphs[e];if(void 0!==r)return void i(null,{stack:t,id:e,glyph:r});if(r=this._tinySDF(n,t,e),r)return n.glyphs[e]=r,void i(null,{stack:t,id:e,glyph:r});const s=Math.floor(e/256);if(256*s>65535)return void i(new Error("glyphs > 65535 not supported"));if(n.ranges[s])return void i(null,{stack:t,id:e,glyph:r});let a=n.requests[s];a||(a=n.requests[s]=[],P_.loadGlyphRange(t,s,o,this.requestManager,((t,e)=>{if(e){n.ascender=e.ascender,n.descender=e.descender;for(const t in e.glyphs)this._doesCharSupportLocalGlyph(+t)||(n.glyphs[+t]=e.glyphs[+t]);n.ranges[s]=!0}for(const i of a)i(t,e);delete n.requests[s]}))),a.push(((n,r)=>{n?i(n):r&&i(null,{stack:t,id:e,glyph:r.glyphs[e]||null})}))}),((t,e)=>{if(t)i(t);else if(e){const t={};for(const{stack:i,id:n,glyph:r}of e)void 0===t[i]&&(t[i]={}),void 0===t[i].glyphs&&(t[i].glyphs={}),t[i].glyphs[n]=r&&{id:r.id,bitmap:r.bitmap.clone(),metrics:r.metrics},t[i].ascender=this.entries[i].ascender,t[i].descender=this.entries[i].descender;i(null,t)}}))}_doesCharSupportLocalGlyph(t){return this.localGlyphMode!==L_.none&&(this.localGlyphMode===L_.all?!!this.localFontFamily:!!this.localFontFamily&&(Ma["CJK Unified Ideographs"](t)||Ma["Hangul Syllables"](t)||Ma.Hiragana(t)||Ma.Katakana(t)||Ma["CJK Symbols and Punctuation"](t)||Ma["CJK Unified Ideographs Extension A"](t)||Ma["CJK Unified Ideographs Extension B"](t)))}_tinySDF(t,e,i){const n=this.localFontFamily;if(!n||!this._doesCharSupportLocalGlyph(i))return;let r=t.tinySDF;if(!r){let i="400";/bold/i.test(e)?i="900":/medium/i.test(e)?i="500":/light/i.test(e)&&(i="200"),r=t.tinySDF=new P_.TinySDF({fontFamily:n,fontWeight:i,fontSize:24*I_,buffer:3*I_,radius:8*I_}),r.fontWeight=i}if(this.localGlyphs[r.fontWeight][i])return this.localGlyphs[r.fontWeight][i];const o=String.fromCodePoint(i),{data:s,width:a,height:l,glyphWidth:c,glyphHeight:d,glyphLeft:u,glyphTop:h,glyphAdvance:p}=r.draw(o);return this.localGlyphs[r.fontWeight][i]={id:i,bitmap:new dh({width:a,height:l},s),metrics:{width:c/I_,height:d/I_,left:u/I_,top:h/I_-27,advance:p/I_,localGlyph:!0}}}}P_.loadGlyphRange=function(t,e,i,n,r){const o=256*e,s=o+255,a=n.transformRequest(n.normalizeGlyphsURL(i).replace("{fontstack}",t).replace("{range}",`${o}-${s}`),Ki.Glyphs);en(a,((t,e)=>{if(t)r(t);else if(e){const t={},i=function(t){return new Lm(t).readFields(Wm,{})}(e);for(const e of i.glyphs)t[e.id]=e;r(null,{glyphs:t,ascender:i.ascender,descender:i.descender})}}))},P_.TinySDF=class{constructor({fontSize:t=24,buffer:e=3,radius:i=8,cutoff:n=.25,fontFamily:r="sans-serif",fontWeight:o="normal",fontStyle:s="normal"}={}){this.buffer=e,this.cutoff=n,this.radius=i;const a=this.size=t+4*e,l=this._createCanvas(a),c=this.ctx=l.getContext("2d",{willReadFrequently:!0});c.font=`${s} ${o} ${t}px ${r}`,c.textBaseline="alphabetic",c.textAlign="left",c.fillStyle="black",this.gridOuter=new Float64Array(a*a),this.gridInner=new Float64Array(a*a),this.f=new Float64Array(a),this.z=new Float64Array(a+1),this.v=new Uint16Array(a)}_createCanvas(t){const e=document.createElement("canvas");return e.width=e.height=t,e}draw(t){const{width:e,actualBoundingBoxAscent:i,actualBoundingBoxDescent:n,actualBoundingBoxLeft:r,actualBoundingBoxRight:o}=this.ctx.measureText(t),s=Math.ceil(i),a=Math.max(0,Math.min(this.size-this.buffer,Math.ceil(o-r))),l=Math.min(this.size-this.buffer,s+Math.ceil(n)),c=a+2*this.buffer,d=l+2*this.buffer,u=Math.max(c*d,0),h=new Uint8ClampedArray(u),p={data:h,width:c,height:d,glyphWidth:a,glyphHeight:l,glyphTop:s,glyphLeft:0,glyphAdvance:e};if(0===a||0===l)return p;const{ctx:f,buffer:m,gridInner:_,gridOuter:g}=this;f.clearRect(m,m,a,l),f.fillText(t,m,m+s);const y=f.getImageData(m,m,a,l);g.fill(M_,0,u),_.fill(0,0,u);for(let t=0;t0?t*t:0,_[n]=tt+e[1]-e[0],f=u.reduce(p,0),m=h.reduce(p,0),_=a-f,g=l-m;let y=0,v=f,x=0,b=m,w=0,T=_,S=0,E=g;if(o.content&&n){const t=o.content;y=D_(u,0,t[0]),x=D_(h,0,t[1]),v=D_(u,t[0],t[2]),b=D_(h,t[1],t[3]),w=t[0]-y,S=t[1]-x,T=t[2]-t[0]-v,E=t[3]-t[1]-b}const M=(n,r,a,l)=>{const u=R_(n.stretch-y,v,c,t.left),h=O_(n.fixed-w,T,n.stretch,f),p=R_(r.stretch-x,b,d,t.top),_=O_(r.fixed-S,E,r.stretch,m),g=R_(a.stretch-y,v,c,t.left),M=O_(a.fixed-w,T,a.stretch,f),C=R_(l.stretch-x,b,d,t.top),A=O_(l.fixed-S,E,l.stretch,m),I=new Ue(u,p),L=new Ue(g,p),P=new Ue(g,C),$=new Ue(u,C),k=new Ue(h/s,_/s),D=new Ue(M/s,A/s),z=e*Math.PI/180;if(z){const t=Math.sin(z),e=Math.cos(z),i=[e,-t,t,e];I._matMult(i),L._matMult(i),$._matMult(i),P._matMult(i)}const R=n.stretch+n.fixed,O=a.stretch+a.fixed,B=r.stretch+r.fixed,F=l.stretch+l.fixed,N=t.imageSecondary;return{tl:I,tr:L,bl:$,br:P,texPrimary:{x:o.paddedRect.x+$_+R,y:o.paddedRect.y+$_+B,w:O-R,h:F-B},texSecondary:N?{x:N.paddedRect.x+$_+R,y:N.paddedRect.y+$_+B,w:O-R,h:F-B}:void 0,writingMode:void 0,glyphOffset:[0,0],sectionIndex:0,pixelOffsetTL:k,pixelOffsetBR:D,minFontScaleX:T/s/c,minFontScaleY:E/s/d,isSDF:i}};if(n&&(o.stretchX||o.stretchY)){const t=z_(u,_,f),e=z_(h,g,m);for(let i=0;io)&&(o=e.x),(!t||e.y>s)&&(s=e.y)}const l=Math.min(o-n,s-r);let c=l/2;const d=new co([],N_);if(0===l)return new Ue(n,r);for(let e=n;eu.d||!u.d)&&(u=n,i&&console.log("found best %d after %d probes",Math.round(1e4*n.d)/1e4,h)),n.max-u.dt.y!=a.y>t.y&&t.x18&&P>2&&(P>>=1),Math.max(uo/(512*P),1)*_.get("symbol-spacing")),S=_.get("text-padding")*t.tilePixelRatio,E=_.get("icon-padding")*t.tilePixelRatio,M=Ge(_.get("text-max-angle")),C="map"===_.get("text-rotation-alignment")&&"point"!==_.get("symbol-placement"),A="map"===_.get("icon-rotation-alignment")&&"point"!==_.get("symbol-placement"),I=_.get("symbol-placement"),L=T/2;var P;const $=_.get("icon-text-fit").evaluate(e,{},u),k=_.get("icon-text-fit-padding").evaluate(e,{},u),D="none"!==$;let z;!1===t.hasAnyIconTextFit&&D&&(t.hasAnyIconTextFit=!0),n&&D&&(t.allowVerticalPlacement&&i.vertical&&(z=h_(n,i.vertical,$,k,g,b)),y&&(n=h_(n,y,$,k,g,b)));const R=(s,a,m)=>{if(a.x=uo||a.y=uo)return;let _=null;if(v){const{x:t,y:e,z:i}=h.projectTilePoint(a.x,a.y,m);_={anchor:new p_(t,e,i,0,void 0),up:h.upVector(m,a.x,a.y)}}!function(t,e,i,n,r,o,s,a,l,c,d,u,h,p,f,m,_,g,y,v,x,b,w,T,S,E,M){const C=t.addToLineVertexArray(e,n);let A,I,L,P,$,k,D,z=0,R=0,O=0,B=0,F=-1,N=-1;const U={};let j=Ln("");const V=i?i.anchor:e,G="none"!==l.layout.get("icon-text-fit").evaluate(x,{},S);let Z=0,q=0;if(void 0===l._unevaluatedLayout.getValue("text-radial-offset")?[Z,q]=l.layout.get("text-offset").evaluate(x,{},S).map((t=>t*Om)):(Z=l.layout.get("text-radial-offset").evaluate(x,{},S)*Om,q=j_),t.allowVerticalPlacement&&r.vertical){const t=r.vertical;if(f)k=J_(t),a&&(D=J_(a));else{const i=l.layout.get("text-rotate").evaluate(x,{},S)+90;L=K_(c,V,e,d,u,h,t,p,i,m),a&&(P=K_(c,V,e,d,u,h,a,g,i))}}if(o){const n=l.layout.get("icon-rotate").evaluate(x,{},S),r=k_(o,n,w,G),s=a?k_(a,n,w,G):void 0;I=K_(c,V,e,d,u,h,o,g,n),z=4*r.length;const p=t.iconSizeData;let f=null;"source"===p.kind?(f=[Bm*l.layout.get("icon-size").evaluate(x,{},S)],f[0]>W_&&pi(`${t.layerIds[0]}: Value for "icon-size" is >= ${H_}. Reduce your "icon-size".`)):"composite"===p.kind&&(f=[Bm*b.compositeIconSizes[0].evaluate(x,{},S),Bm*b.compositeIconSizes[1].evaluate(x,{},S)],(f[0]>W_||f[1]>W_)&&pi(`${t.layerIds[0]}: Value for "icon-size" is >= ${H_}. Reduce your "icon-size".`)),t.addSymbols(t.icon,r,f,v,y,x,!1,i,e,C.lineStartIndex,C.lineLength,-1,T,S,E,M),F=t.icon.placedSymbolArray.length-1,s&&(R=4*s.length,t.addSymbols(t.icon,s,f,v,y,x,Jm.vertical,i,e,C.lineStartIndex,C.lineLength,-1,T,S,E,M),N=t.icon.placedSymbolArray.length-1)}for(const n in r.horizontal){const o=r.horizontal[n];A||(j=Ln(o.text),f?$=J_(o):A=K_(c,V,e,d,u,h,o,p,l.layout.get("text-rotate").evaluate(x,{},S),m));const a=1===o.positionedLines.length;if(O+=Y_(t,i,e,o,s,l,f,x,m,C,r.vertical?Jm.horizontal:Jm.horizontalOnly,a?Object.keys(r.horizontal):[n],U,F,b,T,S,E),a)break}r.vertical&&(B+=Y_(t,i,e,r.vertical,s,l,f,x,m,C,Jm.vertical,["vertical"],U,N,b,T,S,E));let H=-1;const W=(t,e)=>t?Math.max(t,e):e;H=W($,H),H=W(k,H),H=W(D,H);const Y=H>-1?1:0;t.glyphOffsetArray.length>=65535&&pi("Too many glyphs being rendered in a tile. See https://github.com/mapbox/mapbox-gl-js/issues/2907"),void 0!==x.sortKey&&t.addToSortKeyRanges(t.symbolInstances.length,x.sortKey),t.symbolInstances.emplaceBack(e.x,e.y,V.x,V.y,V.z,U.right>=0?U.right:-1,U.center>=0?U.center:-1,U.left>=0?U.left:-1,U.vertical>=0?U.vertical:-1,F,N,j,void 0!==A?A:t.collisionBoxArray.length,void 0!==A?A+1:t.collisionBoxArray.length,void 0!==L?L:t.collisionBoxArray.length,void 0!==L?L+1:t.collisionBoxArray.length,void 0!==I?I:t.collisionBoxArray.length,void 0!==I?I+1:t.collisionBoxArray.length,P||t.collisionBoxArray.length,P?P+1:t.collisionBoxArray.length,d,O,B,z,R,Y,0,Z,q,H,0,1,1,G?1:0)}(t,a,_,s,i,n,r,z,t.layers[0],t.collisionBoxArray,e.index,e.sourceLayerIndex,t.index,S,C,l,0,E,A,g,e,o,c,d,u,p,f)};if("line"===I)for(const r of b_(e.geometry,0,0,uo,uo)){const e=v_(r,T,M,i.vertical||y,n,x,w,t.overscaling,uo);for(const i of e)y&&Q_(t,y.text,L,i)||R(r,i,u)}else if("line-center"===I){for(const t of e.geometry)if(t.length>1){const e=y_(t,M,i.vertical||y,n,x,w);e&&R(t,e,u)}}else if("Polygon"===e.type)for(const t of Zh(e.geometry,0)){const e=F_(t,16);R(t[0],new p_(e.x,e.y,0,0,void 0),u)}else if("LineString"===e.type)for(const t of e.geometry)R(t,new p_(t[0].x,t[0].y,0,0,void 0),u);else if("Point"===e.type)for(const t of e.geometry)for(const e of t)R([e],new p_(e.x,e.y,0,0,void 0),u)}const H_=255,W_=H_*Bm;function Y_(t,e,i,n,r,o,s,a,l,c,d,u,h,p,f,m,_,g){const y=function(t,e,i,n,r,o,s,a){const l=[];if(0===e.positionedLines.length)return l;const c=n.layout.get("text-rotate").evaluate(o,{})*Math.PI/180,d=function(t){const e=t[0],i=t[1],n=e*i;return n>0?[e,-i]:nW_&&pi(`${t.layerIds[0]}: Value for "text-size" is >= ${H_}. Reduce your "text-size".`)):"composite"===v.kind&&(x=[Bm*f.compositeTextSizes[0].evaluate(a,{},_),Bm*f.compositeTextSizes[1].evaluate(a,{},_)],(x[0]>W_||x[1]>W_)&&pi(`${t.layerIds[0]}: Value for "text-size" is >= ${H_}. Reduce your "text-size".`)),t.addSymbols(t.text,y,x,l,s,a,d,e,i,c.lineStartIndex,c.lineLength,p,m,_,g,!1);for(const e of u)h[e]=t.text.placedSymbolArray.length-1;return 4*y.length}function X_(t){for(const e in t)return t[e];return null}function K_(t,e,i,n,r,o,s,a,l,c){let d=s.top,u=s.bottom,h=s.left,p=s.right;const f=s.collisionPadding;if(f&&(h-=f[0],d-=f[1],p+=f[2],u+=f[3]),l){const t=new Ue(h,d),e=new Ue(p,d),i=new Ue(h,u),n=new Ue(p,u),r=Ge(l);let o=new Ue(0,0);c&&(o=new Ue(c[0],c[1])),t._rotateAround(r,o),e._rotateAround(r,o),i._rotateAround(r,o),n._rotateAround(r,o),h=Math.min(t.x,e.x,i.x,n.x),p=Math.max(t.x,e.x,i.x,n.x),d=Math.min(t.y,e.y,i.y,n.y),u=Math.max(t.y,e.y,i.y,n.y)}return t.emplaceBack(e.x,e.y,e.z,i.x,i.y,h,d,p,u,a,n,r,o),t.length-1}function J_(t){t.collisionPadding&&(t.top-=t.collisionPadding[1],t.bottom+=t.collisionPadding[3]);const e=t.bottom-t.top;return e>0?Math.max(10,e):null}function Q_(t,e,i,n){const r=t.compareText;if(e in r){const t=r[e];for(let e=t.length-1;e>=0;e--)if(n.dist(t[e])v&&(x(t,c,n,r,a,l),x(c,i,a,l,o,s))}x(u,h,n,o,r,o),x(h,p,r,o,r,s),x(p,f,r,s,n,s),x(f,u,n,s,n,o),m-=v,_-=v,g+=v,y+=v;const b=1/Math.max(g-m,y-_);return{scale:b,x:m*b,y:_*b,x2:g*b,y2:y*b,projection:e}}function ig(t,{x:e,y:i},n=0){return new Ue(((e-n)*t.scale-t.x)*uo,(i*t.scale-t.y)*uo)}const ng=t.ad.identity(new Float32Array(16));class rg{constructor(t){this.spec=t,this.name=t.name,this.wrap=!1,this.requiresDraping=!1,this.supportsWorldCopies=!1,this.supportsTerrain=!1,this.supportsFog=!1,this.supportsFreeCamera=!1,this.zAxisUnit="meters",this.isReprojectedInTileSpace=!0,this.unsupportedLayers=["custom"],this.center=[0,0],this.range=[3.5,7]}project(t,e){return{x:0,y:0,z:0}}unproject(t,e){return new pd(0,0)}projectTilePoint(t,e,i){return{x:t,y:e,z:0}}locationPoint(t,e,i=!0){return t._coordinatePoint(t.locationCoordinate(e),i)}pixelsPerMeter(t,e){return Cd(1,t)*e}pixelSpaceConversion(t,e,i){return 1}farthestPixelDistance(t){return tg(t,t.pixelsPerMeter)}pointCoordinate(t,e,i,n){const r=t.horizonLineFromTop(!1),o=new Ue(e,Math.max(r,i));return t.rayIntersectionCoordinate(t.pointRayIntersection(o,n))}pointCoordinate3D(t,e,i){const n=new Ue(e,i);if(t.elevation)return t.elevation.pointCoordinate(n);{const e=this.pointCoordinate(t,n.x,n.y,0);return[e.x,e.y,e.z]}}isPointAboveHorizon(t,e){if(t.elevation&&t.elevation.visibleDemTiles.length)return!this.pointCoordinate3D(t,e.x,e.y);const i=t.horizonLineFromTop();return e.y0?epg-i&&(e=pg-i);const o=r/Math.pow(fg(e),n);let s=o*Math.sin(n*t),a=r-o*Math.cos(n*t);return s=.5*(s/Math.PI+.5),a=.5*(a/Math.PI+.5),{x:s,y:this.southernCenter?a:1-a,z:0}}unproject(t,e){t=(2*t-.5)*Math.PI,this.southernCenter&&(e=1-e),e=(2*(1-e)-.5)*Math.PI;const{n:i,f:n}=this,r=n-e,o=Math.sign(r),s=Math.sign(i)*Math.sqrt(t*t+r*r);let a=Math.atan2(t,Math.abs(r))*o;r*i1e-6&&--n>0);o=i*i;const s=Xe(Ze(t/(.8707+o*(o*(o*o*o*(.003971-.001529*o)-.013791)-.131979))),-180,180),a=Ze(i);return new pd(s,a)}}const vg=Ge(Pd);class xg extends rg{project(t,e){e=Ge(e),t=Ge(t);const i=Math.cos(e),n=2/Math.PI,r=Math.acos(i*Math.cos(t/2)),o=Math.sin(r)/r,s=.5*(t*n+2*i*Math.sin(t/2)/o)||0,a=.5*(e+Math.sin(e)/o)||0;return{x:.5*(s/Math.PI+.5),y:1-.5*(a/Math.PI+1),z:0}}unproject(t,e){let i=t=(2*t-.5)*Math.PI,n=e=(2*(1-e)-1)*Math.PI,r=25;const o=1e-6;let s=0,a=0;do{const r=Math.cos(n),o=Math.sin(n),l=2*o*r,c=o*o,d=r*r,u=Math.cos(i/2),h=Math.sin(i/2),p=2*u*h,f=h*h,m=1-d*u*u,_=m?1/m:0,g=m?Math.acos(r*u)*Math.sqrt(1/m):0,y=.5*(2*g*r*h+2*i/Math.PI)-t,v=.5*(g*o+n)-e,x=.5*_*(d*f+g*r*u*c)+1/Math.PI,b=_*(p*l/4-g*o*h),w=.125*_*(l*h-g*o*d*p),T=.5*_*(c*u+g*f*r)+.5,S=b*w-T*x;s=(v*b-y*T)/S,a=(y*w-v*x)/S,i=Xe(i-s,-Math.PI,Math.PI),n=Xe(n-a,-vg,vg)}while((Math.abs(s)>o||Math.abs(a)>o)&&--r>0);return new pd(Ze(i),Ze(n))}}class bg extends rg{constructor(t){super(t),this.center=t.center||[0,0],this.parallels=t.parallels||[0,0],this.cosPhi=Math.max(.01,Math.cos(Ge(this.parallels[0]))),this.scale=1/(2*Math.max(Math.PI*this.cosPhi,1/this.cosPhi)),this.wrap=!0,this.supportsWorldCopies=!0}project(t,e){const{scale:i,cosPhi:n}=this;return{x:Ge(t)*n*i+.5,y:-Math.sin(Ge(e))/n*i+.5,z:0}}unproject(t,e){const{scale:i,cosPhi:n}=this,r=-(e-.5)/i,o=Xe(Ze((t-.5)/i)/n,-180,180),s=Math.asin(Xe(r*n,-1,1)),a=Xe(Ze(s),-Pd,Pd);return new pd(o,a)}}class wg extends _g{constructor(t){super(t),this.requiresDraping=!0,this.supportsWorldCopies=!1,this.supportsFog=!0,this.zAxisUnit="pixels",this.unsupportedLayers=["debug"],this.range=[3,5]}projectTilePoint(e,i,n){const r=Fu(e,i,n),o=ju($u(n));return t._.transformMat4(r,r,o),{x:r[0],y:r[1],z:r[2]}}locationPoint(e,i){const n=dd(i.lat,i.lng),r=t._.normalize([],n),o=e.elevation?e.elevation.getAtPointOrZero(e.locationCoordinate(i),e._centerAltitude):e._centerAltitude,s=Cd(1,0)*uo*o;t._.scaleAndAdd(n,n,r,s);const a=t.ad.identity(new Float64Array(16));return t.ad.multiply(a,e.pixelMatrix,e.globeMatrix),t._.transformMat4(n,n,a),new Ue(n[0],n[1])}pixelsPerMeter(t,e){return Cd(1,0)*e}pixelSpaceConversion(t,e,i){const n=Cd(1,t)*e,r=Vn(Cd(1,45)*e,n,i);return this.pixelsPerMeter(t,e)/r}createTileMatrix(e,i,n){const r=Vu($u(n.canonical));return t.ad.multiply(new Float64Array(16),e.globeMatrix,r)}createInversionMatrix(e,i){const{center:n}=e,r=ju($u(i));return t.ad.rotateY(r,r,Ge(n.lng)),t.ad.rotateX(r,r,Ge(n.lat)),t.ad.scale(r,r,[e._pixelsPerMercatorPixel,e._pixelsPerMercatorPixel,1]),Float32Array.from(r)}pointCoordinate(t,e,i,n){return Iu(t,e,i,!0)||new Rd(0,0)}pointCoordinate3D(t,e,i){const n=this.pointCoordinate(t,e,i,0);return[n.x,n.y,n.z]}isPointAboveHorizon(t,e){return!Iu(t,e.x,e.y,!1)}farthestPixelDistance(e){const i=function(e,i){const n=e.cameraToCenterDistance,r=e._centerAltitude*i,o=e._camera,s=e._camera.forward(),a=t._.add([],t._.scale([],s,-n),[0,0,r]),l=e.worldSize/(2*Math.PI),c=[0,0,-l],d=e.width/e.height,u=Math.tan(e.fovAboveCenter),h=t._.scale([],o.up(),u),p=t._.scale([],o.right(),u*d),f=t._.normalize([],t._.add([],t._.add([],s,h),p)),m=[];let _;if(new mu(a,f).closestPointOnSphere(c,l,m)){const i=t._.add([],m,c),n=t._.sub([],i,a);_=Math.cos(e.fovAboveCenter)*t._.length(n)}else{const e=t._.sub([],a,c),i=t._.sub([],c,a);t._.normalize(i,i);const n=t._.length(e)-l;_=Math.sqrt(n*(n+2*l));const r=Math.acos(_/(l+n))-Math.acos(t._.dot(s,i));_*=Math.cos(r)}return 1.01*_}(e,this.pixelsPerMeter(e.center.lat,e.worldSize)),n=Hu(e.zoom);if(n>0){const t=tg(e,Cd(1,e.center.lat)*e.worldSize),r=e.worldSize/(2*Math.PI),o=Math.max(e.width,e.height)/e.worldSize*Math.PI;return Vn(i,t+r*(1-Math.cos(o)),Math.pow(n,10))}return i}upVector(t,e,i){return Fu(e,i,t,1)}upVectorScale(t){return{metersToTile:Cu(Nu($u(t)))}}}function Tg(t){const e=t.parallels,i=!!e&&Math.abs(e[0]+e[1])0&&(this.iconTransitioningVertexBuffer=t.createVertexBuffer(this.iconTransitioningVertexArray,Vf.members,!0)),this.globeExtVertexArray.length>0&&(this.globeExtVertexBuffer=t.createVertexBuffer(this.globeExtVertexArray,Ff.members,!0)),!this.zOffsetVertexBuffer&&(this.zOffsetVertexArray.length>0||r)&&(this.zOffsetVertexBuffer=t.createVertexBuffer(this.zOffsetVertexArray,jf.members,!0)),this.opacityVertexBuffer.itemSize=1),(i||n)&&this.programConfigurations.upload(t))}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy(),this.dynamicLayoutVertexBuffer.destroy(),this.opacityVertexBuffer.destroy(),this.occlusionQueryOpacityVertexBuffer.destroy(),this.iconTransitioningVertexBuffer&&this.iconTransitioningVertexBuffer.destroy(),this.globeExtVertexBuffer&&this.globeExtVertexBuffer.destroy(),this.zOffsetVertexBuffer&&this.zOffsetVertexBuffer.destroy())}}ba(Ng,"SymbolBuffers");class Ug{constructor(t,e,i){this.layoutVertexArray=new t,this.layoutAttributes=e,this.indexArray=new i,this.segments=new wc,this.collisionVertexArray=new Xl,this.collisionVertexArrayExt=new Ol}upload(t){this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,this.layoutAttributes),this.indexBuffer=t.createIndexBuffer(this.indexArray),this.collisionVertexBuffer=t.createVertexBuffer(this.collisionVertexArray,Gf.members,!0),this.collisionVertexBufferExt=t.createVertexBuffer(this.collisionVertexArrayExt,Zf.members,!0)}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.segments.destroy(),this.collisionVertexBuffer.destroy(),this.collisionVertexBufferExt.destroy())}}ba(Ug,"CollisionBuffers");class jg{constructor(e){this.queries=new Map,this.collisionBoxArray=e.collisionBoxArray,this.zoom=e.zoom,this.lut=e.lut,this.overscaling=e.overscaling,this.layers=e.layers,this.layerIds=this.layers.map((t=>t.fqid)),this.index=e.index,this.pixelRatio=e.pixelRatio,this.sourceLayerIndex=e.sourceLayerIndex,this.hasPattern=!1,this.hasRTLText=!1,this.fullyClipped=!1,this.hasAnyIconTextFit=!1,this.sortKeyRanges=[],this.collisionCircleArray=[],this.placementInvProjMatrix=t.ad.identity([]),this.placementViewportMatrix=t.ad.identity([]);const i=this.layers[0]._unevaluatedLayout._values;this.textSizeData=Fm(this.zoom,i["text-size"]),this.iconSizeData=Fm(this.zoom,i["icon-size"]);const n=this.layers[0].layout,r=n.get("symbol-sort-key"),o=n.get("symbol-z-order");this.canOverlap=n.get("text-allow-overlap")||n.get("icon-allow-overlap")||n.get("text-ignore-placement")||n.get("icon-ignore-placement"),this.sortFeaturesByKey="viewport-y"!==o&&void 0!==r.constantOr(1),this.sortFeaturesByY=("viewport-y"===o||"auto"===o&&!this.sortFeaturesByKey)&&this.canOverlap,this.writingModes=n.get("text-writing-mode").map((t=>Jm[t])),this.stateDependentLayerIds=this.layers.filter((t=>t.isStateDependent())).map((t=>t.id)),this.sourceID=e.sourceID,this.projection=e.projection,this.hasAnyZOffset=!1,this.zOffsetSortDirty=!1,this.zOffsetBuffersNeedUpload=n.get("symbol-z-elevate"),this.activeReplacements=[],this.replacementUpdateTime=0}createArrays(){this.text=new Ng(new Yc(this.layers,{zoom:this.zoom,lut:this.lut},(t=>/^text/.test(t)))),this.icon=new Ng(new Yc(this.layers,{zoom:this.zoom,lut:this.lut},(t=>/^icon/.test(t)))),this.glyphOffsetArray=new mc,this.lineVertexArray=new _c,this.symbolInstances=new fc}calculateGlyphDependencies(t,e,i,n,r){for(let i=0;i0)&&("constant"!==l.value.kind||l.value.value.length>0),h="constant"!==d.value.kind||!!d.value.value||Object.keys(d.parameters).length>0,p=s.get("symbol-sort-key");if(this.features=[],!u&&!h)return;const f=i.iconDependencies,m=i.glyphDependencies,_=i.availableImages,g=new Ha(this.zoom);for(const{feature:i,id:c,index:d,sourceLayerIndex:y}of e){const e=o._featureFilter.needGeometry,v=Zd(i,e);if(!o._featureFilter.filter(g,v,n))continue;if(e||(v.geometry=Gd(i,n,r)),a&&1!==i.type&&n.z{const o=Fu(e.x,e.y,n,1),s=Fu(r.x,r.y,n,1);return t._.dot(o,s)=0;for(const i of x.sections)if(i.image)f[i.image.namePrimary]=!0;else{const n=Ca(x.toString()),r=i.fontStack||t,o=m[r]=m[r]||{};this.calculateGlyphDependencies(i.text,o,e,this.allowVerticalPlacement,n)}}}"line"===s.get("symbol-placement")&&(this.features=function(t){const e={},i={},n=[];let r=0;function o(e){n.push(t[e]),r++}function s(t,e,r){const o=i[t];return delete i[t],i[e]=o,n[o].geometry[0].pop(),n[o].geometry[0]=n[o].geometry[0].concat(r[0]),o}function a(t,i,r){const o=e[i];return delete e[i],e[t]=o,n[o].geometry[0].shift(),n[o].geometry[0]=r[0].concat(n[o].geometry[0]),o}function l(t,e,i){const n=i?e[0][e[0].length-1]:e[0][0];return`${t}:${n.x}:${n.y}`}for(let c=0;ct.geometry))}(this.features)),this.sortFeaturesByKey&&this.features.sort(((t,e)=>t.sortKey-e.sortKey))}update(t,e,i,n,r){const o=0!==Object.keys(t).length;if(o&&!this.stateDependentLayers.length)return;const s=o?this.stateDependentLayers:this.layers;this.text.programConfigurations.updatePaintArrays(t,e,s,i,n,r),this.icon.programConfigurations.updatePaintArrays(t,e,s,i,n,r)}updateOcclusionOpacities(t,e,i){if(!e.useOcclusionQueries)return!1;const n=this;if("globe"===n.projection.name)return!1;let r=!1;n.hasTextData()&&(r=r||0!==n.text.occlusionQueryOpacityVertexArray.length),n.hasIconData()&&(r=r||0!==n.icon.occlusionQueryOpacityVertexArray.length);const o=n.layers[0].paint,s=o.get("icon-occlusion-opacity").constantOr(0),a=o.get("text-occlusion-opacity").constantOr(0);if(!n.layers[0].hasInitialOcclusionOpacityProperties||1===s&&1===a)return!1;let l=!r;for(let t=0;t.5?1:-1)*e.fadeSpeed*i*.001,r.occlusionOpacity=Xe(r.occlusionOpacity,0,1),l=l||r.occlusionOpacity!==o}if(!l)return!1;let c=0,d=0;const u=(t,e,i,n)=>{let r=0,o=0;i?(r=d,d+=n,o=d):(r=c,c+=n,o=c),o>e.occlusionQueryOpacityVertexArray.length&&e.occlusionQueryOpacityVertexArray.resize(o);const s=t.occlusionOpacity;for(let t=0;t0;if((i>0||r>0)&&(u(e,n.text,!1,i),u(e,n.text,!1,r)),s){const{placedIconSymbolIndex:t,verticalPlacedIconSymbolIndex:i}=e;t>=0&&u(e,n.icon,!0,o),i>=0&&u(e,n.icon,!0,e.numVerticalIconVertices)}}return n.hasTextData()&&n.text.occlusionQueryOpacityVertexBuffer&&(n.text.occlusionQueryOpacityVertexBuffer.length{i+=e,i>t.length&&t.resize(i);for(let r=-e;r{n+=e,n>t.length&&t.resize(n);for(let r=-e;r0;if((r>0||o>0)&&(t(this.text.zOffsetVertexArray,r,a),t(this.text.zOffsetVertexArray,o,a)),l){const{placedIconSymbolIndex:t,verticalPlacedIconSymbolIndex:i}=n;t>=0&&e(this.icon.zOffsetVertexArray,s,a),i>=0&&e(this.icon.zOffsetVertexArray,n.numVerticalIconVertices,a)}}this.text.zOffsetVertexBuffer&&this.text.zOffsetVertexBuffer.updateData(this.text.zOffsetVertexArray),this.icon.zOffsetVertexBuffer&&this.icon.zOffsetVertexBuffer.updateData(this.icon.zOffsetVertexArray)}isEmpty(){return 0===this.symbolInstances.length&&!this.hasRTLText}uploadPending(){return!this.uploaded||this.text.programConfigurations.needsUpload||this.icon.programConfigurations.needsUpload}upload(t){!this.uploaded&&this.hasDebugData()&&(this.textCollisionBox.upload(t),this.iconCollisionBox.upload(t)),this.text.upload(t,this.sortFeaturesByY,!this.uploaded,this.text.programConfigurations.needsUpload,this.zOffsetBuffersNeedUpload),this.icon.upload(t,this.sortFeaturesByY,!this.uploaded,this.icon.programConfigurations.needsUpload,this.zOffsetBuffersNeedUpload),this.uploaded=!0}destroyDebugData(){this.textCollisionBox.destroy(),this.iconCollisionBox.destroy()}getProjection(){return this.projectionInstance||(this.projectionInstance=Tg(this.projection)),this.projectionInstance}destroy(){this.text.destroy(),this.icon.destroy(),this.hasDebugData()&&this.destroyDebugData();for(const t of this.queries.values())t.destroy()}addToLineVertexArray(t,e){const i=this.lineVertexArray.length;if(void 0!==t.segment)for(const{x:t,y:i}of e)this.lineVertexArray.emplaceBack(t,i);return{lineStartIndex:i,lineLength:this.lineVertexArray.length-i}}addSymbols(t,e,i,n,r,o,s,a,l,c,d,u,h,p,f,m){const _=t.indexArray,g=t.layoutVertexArray,y=t.globeExtVertexArray,v=t.segments.prepareSegment(4*e.length,g,_,this.canOverlap?o.sortKey:void 0),x=this.glyphOffsetArray.length,b=v.vertexLength,w=this.allowVerticalPlacement&&s===Jm.vertical?Math.PI/2:0,T=o.text&&o.text.sections;for(let n=0;n=0?e.rightJustifiedTextSymbolIndex:e.centerJustifiedTextSymbolIndex>=0?e.centerJustifiedTextSymbolIndex:e.leftJustifiedTextSymbolIndex>=0?e.leftJustifiedTextSymbolIndex:e.verticalPlacedTextSymbolIndex>=0?e.verticalPlacedTextSymbolIndex:n),o=Nm(this.textSizeData,t,r)/Om;return this.tilePixelRatio*o}getSymbolInstanceIconSize(t,e,i){const n=this.icon.placedSymbolArray.get(i),r=Nm(this.iconSizeData,t,n);return this.tilePixelRatio*r}_commitDebugCollisionVertexUpdate(t,e,i,n){t.emplaceBack(e,-i,-i,n),t.emplaceBack(e,i,-i,n),t.emplaceBack(e,i,i,n),t.emplaceBack(e,-i,i,n)}_updateTextDebugCollisionBoxes(t,e,i,n,r,o){for(let s=n;s0}hasIconData(){return this.icon.segments.get().length>0}hasDebugData(){return this.textCollisionBox&&this.iconCollisionBox}hasTextCollisionBoxData(){return this.hasDebugData()&&this.textCollisionBox.segments.get().length>0}hasIconCollisionBoxData(){return this.hasDebugData()&&this.iconCollisionBox.segments.get().length>0}hasIconTextFit(){return this.hasAnyIconTextFit}addIndicesForPlacedSymbol(t,e){const i=t.placedSymbolArray.get(e),n=i.vertexStartIndex+4*i.numGlyphs;for(let e=i.vertexStartIndex;en[t]-n[e]||r[e]-r[t])),o}getSortedIndexesByZOffset(){if(!this.zOffsetSortDirty)return this.symbolInstanceIndexesSortedZOffset;if(!this.symbolInstanceIndexesSortedZOffset){this.symbolInstanceIndexesSortedZOffset=[];for(let t=0;tthis.symbolInstances.get(e).zOffset-this.symbolInstances.get(t).zOffset))}addToSortKeyRanges(t,e){const i=this.sortKeyRanges[this.sortKeyRanges.length-1];i&&i.sortKey===e?i.symbolInstanceEnd=t+1:this.sortKeyRanges.push({sortKey:e,symbolInstanceStart:t,symbolInstanceEnd:t+1})}sortFeatures(t){if(this.sortFeaturesByY&&this.sortedAngle!==t&&!(this.text.segments.get().length>1||this.icon.segments.get().length>1)){this.symbolInstanceIndexes=this.getSortedSymbolIndexes(t),this.sortedAngle=t,this.text.indexArray.clear(),this.icon.indexArray.clear(),this.featureSortOrder=[];for(const t of this.symbolInstanceIndexes){const e=this.symbolInstances.get(t);this.featureSortOrder.push(e.featureIndex);const{rightJustifiedTextSymbolIndex:i,centerJustifiedTextSymbolIndex:n,leftJustifiedTextSymbolIndex:r,verticalPlacedTextSymbolIndex:o,placedIconSymbolIndex:s,verticalPlacedIconSymbolIndex:a}=e;i>=0&&this.addIndicesForPlacedSymbol(this.text,i),n>=0&&n!==i&&this.addIndicesForPlacedSymbol(this.text,n),r>=0&&r!==n&&r!==i&&this.addIndicesForPlacedSymbol(this.text,r),o>=0&&this.addIndicesForPlacedSymbol(this.text,o),s>=0&&this.addIndicesForPlacedSymbol(this.icon,s),a>=0&&this.addIndicesForPlacedSymbol(this.icon,a)}this.text.indexBuffer&&this.text.indexBuffer.updateData(this.text.indexArray),this.icon.indexBuffer&&this.icon.indexBuffer.updateData(this.icon.indexArray)}}}ba(jg,"SymbolBucket",{omit:["layers","collisionBoxArray","features","compareText"]}),jg.addDynamicAttributes=Bg;class Vg{constructor(t,e,i,n){this.context=t,this.format=i,this.texture=t.gl.createTexture(),this.update(e,n)}update(t,e,i){const{width:n,height:r}=t,{context:o}=this,{gl:s}=o;if(s.bindTexture(s.TEXTURE_2D,this.texture),o.pixelStoreUnpackFlipY.set(!1),o.pixelStoreUnpack.set(1),o.pixelStoreUnpackPremultiplyAlpha.set(this.format===s.RGBA&&(!e||!1!==e.premultiply)),this.useMipmap=Boolean(e&&e.useMipmap),i||this.size&&this.size[0]===n&&this.size[1]===r){const{x:e,y:o}=i||{x:0,y:0};if(t instanceof HTMLImageElement||t instanceof HTMLCanvasElement||t instanceof HTMLVideoElement||t instanceof ImageData||ImageBitmap&&t instanceof ImageBitmap)s.texSubImage2D(s.TEXTURE_2D,0,e,o,s.RGBA,s.UNSIGNED_BYTE,t);else{let i=this.format,a=s.UNSIGNED_BYTE;this.format===s.R32F&&(i=s.RED,a=s.FLOAT),s.texSubImage2D(s.TEXTURE_2D,0,e,o,n,r,i,a,t.data)}}else if(this.size=[n,r],t instanceof HTMLImageElement||t instanceof HTMLCanvasElement||t instanceof HTMLVideoElement||t instanceof ImageData||ImageBitmap&&t instanceof ImageBitmap){let e=this.format;this.format===s.R8&&(e=s.RED),s.texImage2D(s.TEXTURE_2D,0,this.format,e,s.UNSIGNED_BYTE,t)}else{let e=this.format,i=this.format,o=s.UNSIGNED_BYTE,a=!1;this.format===s.DEPTH_COMPONENT&&(e=s.DEPTH_COMPONENT16,o=s.UNSIGNED_SHORT),this.format===s.DEPTH_STENCIL&&(e=s.DEPTH24_STENCIL8,o=s.UNSIGNED_INT_24_8,a=!0),this.format===s.R8&&(i=s.RED),this.format===s.R32F&&(o=s.FLOAT,i=s.RED),!this.useMipmap&&a?s.texStorage2D(s.TEXTURE_2D,1,e,n,r):s.texImage2D(s.TEXTURE_2D,0,e,n,r,0,i,o,t.data)}this.useMipmap&&s.generateMipmap(s.TEXTURE_2D)}bind(t,e,i=!1){const{context:n}=this,{gl:r}=n;r.bindTexture(r.TEXTURE_2D,this.texture),t!==this.minFilter&&(r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MAG_FILTER,t),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MIN_FILTER,this.useMipmap&&!i?t===r.NEAREST?r.NEAREST_MIPMAP_NEAREST:r.LINEAR_MIPMAP_LINEAR:t),this.minFilter=t),e!==this.wrapS&&(r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_S,e),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_T,e),this.wrapS=e)}bindExtraParam(t,e,i,n){const{context:r}=this,{gl:o}=r;o.bindTexture(o.TEXTURE_2D,this.texture),e!==this.magFilter&&(o.texParameteri(o.TEXTURE_2D,o.TEXTURE_MAG_FILTER,e),this.magFilter=e),t!==this.minFilter&&(o.texParameteri(o.TEXTURE_2D,o.TEXTURE_MIN_FILTER,this.useMipmap?t===o.NEAREST?o.NEAREST_MIPMAP_NEAREST:o.LINEAR_MIPMAP_LINEAR:t),this.minFilter=t),i!==this.wrapS&&(o.texParameteri(o.TEXTURE_2D,o.TEXTURE_WRAP_S,i),this.wrapS=i),n!==this.wrapT&&(o.texParameteri(o.TEXTURE_2D,o.TEXTURE_WRAP_T,n),this.wrapT=n)}destroy(){const{gl:t}=this.context;t.deleteTexture(this.texture),this.texture=null}}class Gg{constructor(t,e){this.context=t,this.texture=e}bind(t,e){const{context:i}=this,{gl:n}=i;n.bindTexture(n.TEXTURE_2D,this.texture),t!==this.minFilter&&(n.texParameteri(n.TEXTURE_2D,n.TEXTURE_MAG_FILTER,t),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_MIN_FILTER,t),this.minFilter=t),e!==this.wrapS&&(n.texParameteri(n.TEXTURE_2D,n.TEXTURE_WRAP_S,e),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_WRAP_T,e),this.wrapS=e)}}const Zg=32,qg=33,Hg=new Uint16Array(8184);for(let t=0;t>=1)>1;){const t=i+r>>1,l=n+o>>1;1&e?(r=i,o=n,i=s,n=a):(i=r,n=o,r=s,o=a),s=t,a=l}const l=4*t;Hg[l+0]=i,Hg[l+1]=n,Hg[l+2]=r,Hg[l+3]=o}const Wg=new Uint16Array(2178),Yg=new Uint8Array(1089),Xg=new Uint16Array(1089);function Kg(t){return 0===t?-.03125:32===t?.03125:0}var Jg=Ll([{name:"a_pos",type:"Int16",components:2},{name:"a_texture_pos",type:"Int16",components:2}]),Qg=Ll([{name:"a_index",type:"Int16",components:1}]);const ty={type:2,extent:uo,loadGeometry:()=>[[new Ue(0,0),new Ue(uo+1,0),new Ue(uo+1,uo+1),new Ue(0,uo+1),new Ue(0,0)]]};class ey{constructor(t,e,i,n,r){this.tileID=t,this.uid=ni(),this.uses=0,this.tileSize=e,this.tileZoom=i,this.buckets={},this.expirationTime=null,this.queryPadding=0,this.hasSymbolBuckets=!1,this.hasRTLText=!1,this.dependencies={},this.isRaster=r,n&&n.style&&(this._lastUpdatedBrightness=n.style.getBrightness()),this.expiredRequestCount=0,this.state="loading",n&&n.transform&&(this.projection=n.transform.projection)}registerFadeDuration(t){const e=t+this.timeAdded;ee.getLayer(t))).filter(Boolean);if(0!==t.length){n.layers=t,n.stateDependentLayerIds&&(n.stateDependentLayers=n.stateDependentLayerIds.map((e=>t.filter((t=>t.id===e))[0])));for(const e of t)i[e.fqid]=n}}return i}(t.buckets,e.style),this.hasSymbolBuckets=!1;for(const t in this.buckets){const e=this.buckets[t];if(e instanceof jg){if(this.hasSymbolBuckets=!0,!i)break;e.justReloaded=!0}}if(this.hasRTLText=!1,this.hasSymbolBuckets)for(const t in this.buckets){const e=this.buckets[t];if(e instanceof jg&&e.hasRTLText){this.hasRTLText=!0,qa.isLoading()||qa.isLoaded()||"deferred"!==Ga()||Za();break}}this.queryPadding=0;for(const t in this.buckets){const i=this.buckets[t],n=e.style.getOwnLayer(t);if(!n)continue;const r=n.queryRadius(i);this.queryPadding=Math.max(this.queryPadding,r)}t.imageAtlas&&(this.imageAtlas=t.imageAtlas),t.glyphAtlasImage&&(this.glyphAtlasImage=t.glyphAtlasImage),t.lineAtlas&&(this.lineAtlas=t.lineAtlas),this._lastUpdatedBrightness=t.brightness}else this.collisionBoxArray=new dc}unloadVectorData(){if(this.hasData()){for(const t in this.buckets)this.buckets[t].destroy();this.buckets={},this.imageAtlas&&(this.imageAtlas=null),this.lineAtlas&&(this.lineAtlas=null),this.imageAtlasTexture&&this.imageAtlasTexture.destroy(),this.glyphAtlasTexture&&this.glyphAtlasTexture.destroy(),this.lineAtlasTexture&&this.lineAtlasTexture.destroy(),this._tileBoundsBuffer&&(this._tileBoundsBuffer.destroy(),this._tileBoundsIndexBuffer.destroy(),this._tileBoundsSegments.destroy(),this._tileBoundsBuffer=null),this._tileDebugBuffer&&(this._tileDebugBuffer.destroy(),this._tileDebugSegments.destroy(),this._tileDebugBuffer=null),this._tileDebugIndexBuffer&&(this._tileDebugIndexBuffer.destroy(),this._tileDebugIndexBuffer=null),this._globeTileDebugBorderBuffer&&(this._globeTileDebugBorderBuffer.destroy(),this._globeTileDebugBorderBuffer=null),this._tileDebugTextBuffer&&(this._tileDebugTextBuffer.destroy(),this._tileDebugTextSegments.destroy(),this._tileDebugTextIndexBuffer.destroy(),this._tileDebugTextBuffer=null),this._globeTileDebugTextBuffer&&(this._globeTileDebugTextBuffer.destroy(),this._globeTileDebugTextBuffer=null),this.latestFeatureIndex=null,this.state="unloaded"}}getBucket(t){return this.buckets[t.fqid]}upload(t){for(const e in this.buckets){const i=this.buckets[e];i.uploadPending()&&i.upload(t)}const e=t.gl,i=this.imageAtlas;if(i&&!i.uploaded){const n=!!Object.keys(i.patternPositions).length;this.imageAtlasTexture=new Vg(t,i.image,e.RGBA,{useMipmap:n}),this.imageAtlas.uploaded=!0}this.glyphAtlasImage&&(this.glyphAtlasTexture=new Vg(t,this.glyphAtlasImage,e.R8),this.glyphAtlasImage=null),this.lineAtlas&&!this.lineAtlas.uploaded&&(this.lineAtlasTexture=new Vg(t,this.lineAtlas.image,e.R8),this.lineAtlas.uploaded=!0)}prepare(t,e,i){if(this.imageAtlas&&this.imageAtlasTexture&&this.imageAtlas.patchUpdatedImages(t,this.imageAtlasTexture,i),!e||!this.latestFeatureIndex||!this.latestFeatureIndex.rawTileData)return;const n=e.style.getBrightness();(this._lastUpdatedBrightness||n)&&(this._lastUpdatedBrightness&&n&&Math.abs(this._lastUpdatedBrightness-n)t)i=!1;else if(e)if(this.expirationTime=0;t--){const e=4*t,i=Hg[e+0],n=Hg[e+1],r=Hg[e+2],o=Hg[e+3],s=i+r>>1,a=n+o>>1,l=s+a-n,c=a+i-s,d=n*qg+i,u=o*qg+r,h=a*qg+s,p=Math.hypot((Wg[2*d+0]+Wg[2*u+0])/2-Wg[2*h+0],(Wg[2*d+1]+Wg[2*u+1])/2-Wg[2*h+1])>=16;Yg[h]=Yg[h]||(p?1:0),t>1)*qg+(i+l>>1)]||Yg[(o+c>>1)*qg+(r+l>>1)])}const r=new Dl,o=new Kl;let s=0;function a(t,e){const i=e*qg+t;return 0===Xg[i]&&(r.emplaceBack(Wg[2*i+0],Wg[2*i+1],t*uo/Zg,e*uo/Zg),Xg[i]=++s),Xg[i]-1}function l(t,e,i,n,r,s){const c=t+i>>1,d=e+n>>1;if(Math.abs(t-r)+Math.abs(e-s)>1&&Yg[d*qg+c])l(r,s,t,e,c,d),l(i,n,r,s,c,d);else{const l=a(t,e),c=a(i,n),d=a(r,s);o.emplaceBack(l,c,d)}}return l(0,0,Zg,Zg,Zg,0),l(Zg,Zg,0,0,0,Zg),{vertices:r,indices:o}}(this.tileID.canonical,e);n=t.vertices,r=t.indices}else{n=new Dl,r=new Kl;for(const{x:t,y:e}of i)n.emplaceBack(t,e,0,0);const t=xh(n.int16,void 0,4);for(let e=0;e0&&(a=t.ad.invert(new Float64Array(16),i.globeMatrix)),this._makeGlobeTileDebugBorderBuffer(e,r,i,o,a,s),this._makeGlobeTileDebugTextBuffer(e,r,i,o,a,s)}_globePoint(e,i,n,r,o,s,a){let l=Fu(e,i,n);if(s){const o=1.5?h=-1:u{const p=(d-t)/(h-1),f=(u-c)/(h-1),m=s.length;for(let d=0;dd*t+e;for(let t=0;t[t,this.get(t)]))}evict(t=!1){if(t||this.size>0){const t=this.first;delete this.items[t.key],0==--this.size?(this.first=null,this.last=null):(this.first=t.next,this.first.prev=null)}return this}expiresAt(t){let e;return this.has(t)&&(e=this.items[t].expiry),e}get(t){let e;if(this.has(t)){const i=this.items[t];this.ttl>0&&i.expiry0?Date.now()+this.ttl:this.ttl),this.last!==r){const t=this.last,e=r.next,i=r.prev;this.first===r&&(this.first=r.next),r.next=null,r.prev=this.last,t.next=r,null!==i&&(i.next=e),null!==e&&(e.prev=i)}}else this.max>0&&this.size===this.max&&this.evict(!0),r=this.items[t]={expiry:this.ttl>0?Date.now()+this.ttl:this.ttl,key:t,prev:this.last,next:null,value:e},1==++this.size?this.first=r:this.last.next=r;return this.last=r,this}values(t=this.keys()){return t.map((t=>this.get(t)))}}function uy(t,e){if(4!==e.length)throw new Error(`Expected data of dimension 4 but got ${e.length}.`);let i=e[3];for(let n=2;n>=1;n--){const r=1===n?1:0,o=2===n?1:0;for(let n=0;n>>1^-(1&t[e]);return t}function py(t,e){switch(e){case"uint32":return t;case"uint16":for(let e=0;e>4|(61440&i)>>8|(240&n)>4|(15&n)>6|(192&n)>>4|(192&r)>>2|192&o,t[e+1]=(48&i)>>4|(48&n)>>2|48&r|(48&o)>2|12&n|(12&r)>1|(21845&Cy)>2|(13107&Ay)>4|(3855&Ay)>8|(255&Ay)>1}var Iy=function(t,e,i){for(var n=t.length,r=0,o=new _y(e);r>l]=c}else for(s=new _y(n),r=0;r>15-t[r]);return s},Ly=new my(288);for(Cy=0;Cye&&(e=t[i]);return e},zy=function(t,e,i){var n=e/8|0;return(t[n]|t[n+1]>(7&e)&i},Ry=function(t,e){var i=e/8|0;return(t[i]|t[i+1]>(7&e)},Oy=["unexpected EOF","invalid block type","invalid length/literal","invalid distance","stream finished","no stream handler",,"no callback","invalid UTF-8 data","extra field too long","date not in range 1980-2099","filename too long","stream finishing","invalid zip data"],By=function(t,e,i){var n=new Error(e||Oy[t]);if(n.code=t,Error.captureStackTrace&&Error.captureStackTrace(n,By),!i)throw n;return n},Fy=new my(0),Ny="undefined"!=typeof TextDecoder&&new TextDecoder;try{Ny.decode(Fy,{stream:!0})}catch(t){}const Uy={gzip_data:"gzip"},jy={0:"uint32",1:"uint32",2:"uint16",3:"uint8"},Vy={uint32:1,uint16:2,uint8:4},Gy={uint32:Uint32Array,uint16:Uint16Array,uint8:Uint8Array};class Zy{constructor(t=1){this.x=NaN,this.y=NaN,this.z=NaN,this.layers={},this._cacheSize=t}getLayer(t){return this.layers[t]}getHeaderLength(t){const e=new Uint8Array(t),i=new DataView(t);if(13!==e[0])throw new fy("File is not a valid MRT.");return i.getUint32(1,!0)}parseHeader(t){const e=new Uint8Array(t),i=this.getHeaderLength(t);if(e.length= ${i} but got buffer of length ${e.length}`);const n=function(t){return t.readFields(iy,{header_length:0,x:0,y:0,z:0,layers:[]},void 0)}(new Lm(e.subarray(0,i)));if(!isNaN(this.x)&&(this.x!==n.x||this.y!==n.y||this.z!==n.z))throw new fy(`Invalid attempt to parse header ${n.z}/${n.x}/${n.y} for tile ${this.z}/${this.x}/${this.y}`);this.x=n.x,this.y=n.y,this.z=n.z;for(const t of n.layers)this.layers[t.name]=new qy(t,{cacheSize:this._cacheSize});return this}createDecodingTask(t){const e=[],i=this.getLayer(t.layerName);for(let n=0;nt.lastBlock)continue;if(i._blocksInProgress.has(n))continue;const a={layerName:i.name,firstByte:o,lastByte:s,pixelFormat:i.pixelFormat,blockIndex:n,blockShape:[r.bands.length].concat(i.bandShape),buffer:i.buffer,codec:r.codec.codec,filters:r.filters.map((t=>t.filter))};i._blocksInProgress.add(n),e.push(a)}return new Hy(e,(()=>{e.forEach((t=>i._blocksInProgress.delete(t.blockIndex)))}),((t,n)=>{if(e.forEach((t=>i._blocksInProgress.delete(t.blockIndex))),t)throw t;n.forEach((t=>{this.getLayer(t.layerName).processDecodedData(t)}))}))}}class qy{constructor({version:t,name:e,units:i,tilesize:n,pixel_format:r,buffer:o,data_index:s},a){if(this.version=t,1!==this.version)throw new fy(`Cannot parse raster layer encoded with MRT version ${t}`);this.name=e,this.units=i,this.tileSize=n,this.buffer=o,this.pixelFormat=jy[r],this.dataIndex=s,this.bandShape=[n+2*o,n+2*o,Vy[this.pixelFormat]],this._decodedBlocks=function(t=1e3,e=0,i=!1){if(isNaN(t)||t=e&&t=0}hasDataForBand(t){const{blockIndex:e}=this.getBlockForBand(t);return e>=0&&!!this._decodedBlocks.get(e.toString())}getBandView(t){const{blockIndex:e,blockBandIndex:i}=this.getBlockForBand(t),n=this._decodedBlocks.get(e.toString());if(!n)throw new fy(`Data for band ${JSON.stringify(t)} of layer "${this.name}" not decoded.`);const r=this.dataIndex[e],o=this.bandShape.reduce(((t,e)=>t*e),1),s=i*o,a=n.subarray(s,s+o);return{data:a,bytes:new Uint8Array(a.buffer).subarray(a.byteOffset,a.byteOffset+a.byteLength),tileSize:this.tileSize,buffer:this.buffer,offset:r.offset,scale:r.scale}}}class Hy{constructor(t,e,i){this.tasks=t,this._onCancel=e,this._onComplete=i,this._finalized=!1}cancel(){this._finalized||(this._onCancel(),this._finalized=!0)}complete(t,e){this._finalized||(this._onComplete(t,e),this._finalized=!0)}}Zy.performDecoding=function(t,e){return Promise.all(e.tasks.map((e=>{const{layerName:i,firstByte:n,lastByte:r,pixelFormat:o,blockShape:s,blockIndex:a,filters:l,codec:c}=e,d=new Uint8Array(t).subarray(n,r+1),u=new Uint32Array(s[0]*s[1]*s[2]);let h;if("gzip_data"!==c)throw new Error(`Unhandled codec: ${c}`);return h=function(t,e){if(!globalThis.DecompressionStream&&"gzip_data"===e)return Promise.resolve(((o=function(t){31==t[0]&&139==t[1]&&8==t[2]||By(6,"invalid gzip data");var e=t[3],i=10;4&e&&(i+=2+(t[10]|t[11]>3&1)+(e>>4&1);n>0;n-=!t[i++]);return i+(2&e)}(r=t))+8>r.length&&By(6,"invalid gzip data"),function(t,e,i){var n=t.length;if(!n||e.f&&!e.l)return i||new my(0);var r=!i,o=r||2!=e.i,s=e.i;r&&(i=new my(3*n));var a,l,c=function(t){var e=i.length;if(t>e){var n=new my(Math.max(2*e,t));n.set(i),i=n}},d=e.f||0,u=e.p||0,h=e.b||0,p=e.l,f=e.d,m=e.m,_=e.n,g=8*n;do{if(!p){d=zy(t,u,1);var y=zy(t,u+1,3);if(u+=3,!y){var v=t[(L=4+((u+7)/8|0))-4]|t[L-3]n){s&&By(0);break}o&&c(h+v),i.set(t.subarray(L,x),h),e.b=h+=v,e.p=u=8*x,e.f=d;continue}if(1==y)p=$y,f=ky,m=9,_=5;else if(2==y){var b=zy(t,u,31)+257,w=zy(t,u+10,15)+4,T=b+zy(t,u+5,31)+1;u+=14;for(var S=new my(T),E=new my(19),M=0;M>4)g){s&&By(0);break}}o&&c(h+131072);for(var R=(1>4;if((u+=15&$)>g){s&&By(0);break}if($||By(2),F264&&(N=zy(t,u,(1>4;if(U||By(3),u+=15&U,z=Ey[j],j>3){var V=vy[j];z+=Ry(t,u)&(1g){s&&By(0);break}o&&c(h+131072);var G=h+N;if(ha.length)&&(l=a.length),new my(a.subarray(0,l))):i.subarray(0,h)}(r.subarray(o,-8),{i:2},new my(((i=r)[(n=i.length)-4]|i[n-3]>>0))));var i,n,r,o;const s=Uy[e];if(!s)throw new Error(`Unhandled codec: ${e}`);const a=new globalThis.DecompressionStream(s);return new Response(new Blob([t]).stream().pipeThrough(a)).arrayBuffer().then((t=>new Uint8Array(t)))}(d,c).then((t=>(function(t,e){t.readFields(ly,e)}(new Lm(t),u),new(0,Gy[o])(u.buffer)))),h.then((t=>{for(let e=l.length-1;e>=0;e--)switch(l[e]){case"delta_filter":uy(t,s);break;case"zigzag_filter":hy(t);break;case"bitshuffle_filter":py(t,o);break;default:throw new Error(`Unhandled filter "${l[e]}"`)}return{layerName:i,blockIndex:a,data:t}})).catch((t=>{throw t}))})))};class Wy extends ey{constructor(t,e,i,n,r){super(t,e,i,n,r),this._workQueue=[],this._fetchQueue=[],this._isHeaderLoaded=!1}setTexture(t,e){const i=e.context,n=i.gl;this.texture=this.texture||e.getTileTexture(t.width),this.texture&&this.texture instanceof Vg?this.texture.update(t,{useMipmap:!1,premultiply:!1}):this.texture=new Vg(i,t,n.RGBA,{useMipmap:!1,premultiply:!1})}flushQueues(){for(;this._workQueue.length;)this._workQueue.pop()();for(;this._fetchQueue.length;)this._fetchQueue.pop()()}fetchHeader(t=16384,e){const i=this._mrt=new Zy(30),n=Object.assign({},this.requestParams,{headers:{Range:"bytes=0-"+(t-1)}});return this.entireBuffer=null,this.request=en(n,((n,r,o,s)=>{if(n)e(n);else try{const n=i.getHeaderLength(r);if(n>t)return void(this.request=this.fetchHeader(n,e));i.parseHeader(r),this._isHeaderLoaded=!0;let a=0;for(const t of Object.values(i.layers))a=Math.max(a,t.dataIndex[t.dataIndex.length-1].last_byte);r.byteLength>=a&&(this.entireBuffer=r),e(null,this.entireBuffer||r,o,s)}catch(t){e(t)}})),this.request}fetchBand(t,e,i){const n=this._mrt;if(!this._isHeaderLoaded||!n)return void i(new Error("Tile header is not ready"));const r=this.actor;if(!r)return void i(new Error("Can't fetch tile band without an actor"));let o;const s=(n,r)=>{o.complete(n,r),n?i(n):(this.updateTextureDescriptor(t,e),i(null,this.textureDescriptor&&this.textureDescriptor.img))},a=(t,e)=>{if(t)return i(t);const n=r.send("decodeRasterArray",{buffer:e,task:o},s,void 0,!0);this._workQueue.push((()=>{n&&n.cancel(),o.cancel()}))},l=n.getLayer(t);if(!l)return void i(new Error(`Unknown sourceLayer "${t}"`));if(l.hasDataForBand(e))return this.updateTextureDescriptor(t,e),void i(null,this.textureDescriptor?this.textureDescriptor.img:null);const c=l.getDataRange([e]);if(o=n.createDecodingTask(c),!o||o.tasks.length)if(this.flushQueues(),this.entireBuffer)a(null,this.entireBuffer.slice(c.firstByte,c.lastByte+1));else{const t=Object.assign({},this.requestParams,{headers:{Range:`bytes=${c.firstByte}-${c.lastByte}`}}),e=en(t,a);this._fetchQueue.push((()=>{e.cancel(),o.cancel()}))}else i(null)}updateNeeded(t,e){return(!this.textureDescriptor||this.textureDescriptor.band!==e||this.textureDescriptor.layer!==t)&&"errored"!==this.state}updateTextureDescriptor(t,e){if(!this._mrt)return;const i=this._mrt.getLayer(t);if(!i||!i.hasBand(e)||!i.hasDataForBand(e))return;const{bytes:n,tileSize:r,buffer:o,offset:s,scale:a}=i.getBandView(e),l=r+2*o,c={data:n,width:l,height:l},d=this.texture;d&&d instanceof Vg&&d.update(c,{useMipmap:!1,premultiply:!1}),this.textureDescriptor={layer:t,band:e,img:c,buffer:o,offset:s,tileSize:r,format:i.pixelFormat,mix:[a,256*a,65536*a,16777216*a]}}}class Yy{constructor(t,e){this.max=t,this.onRemove=e,this.reset()}reset(){for(const t in this.data)for(const e of this.data[t])e.timeout&&clearTimeout(e.timeout),this.onRemove(e.value);return this.data={},this.order=[],this}add(t,e,i){const n=t.wrapped().key;void 0===this.data[n]&&(this.data[n]=[]);const r={value:e,timeout:void 0};if(void 0!==i&&(r.timeout=setTimeout((()=>{this.remove(t,r)}),i)),this.data[n].push(r),this.order.push(n),this.order.length>this.max){const t=this._getAndRemoveByKey(this.order[0]);t&&this.onRemove(t)}return this}has(t){return t.wrapped().key in this.data}getAndRemove(t){return this.has(t)?this._getAndRemoveByKey(t.wrapped().key):null}_getAndRemoveByKey(t){const e=this.data[t].shift();return e.timeout&&clearTimeout(e.timeout),0===this.data[t].length&&delete this.data[t],this.order.splice(this.order.indexOf(t),1),e.value}getByKey(t){const e=this.data[t];return e?e[0].value:null}get(t){return this.has(t)?this.data[t.wrapped().key][0].value:null}remove(t,e){if(!this.has(t))return this;const i=t.wrapped().key,n=void 0===e?0:this.data[i].indexOf(e),r=this.data[i][n];return this.data[i].splice(n,1),r.timeout&&clearTimeout(r.timeout),0===this.data[i].length&&delete this.data[i],this.onRemove(r.value),this.order.splice(this.order.indexOf(i),1),this}setMaxSize(t){for(this.max=t;this.order.length>this.max;){const t=this._getAndRemoveByKey(this.order[0]);t&&this.onRemove(t)}return this}filter(t){const e=[];for(const i in this.data)for(const n of this.data[i])t(n.value)||e.push(n);for(const t of e)this.remove(t.value.tileID,t)}}class Xy extends zn{constructor(t,e,i){super(),this.id=t,this._onlySymbols=i,e.on("data",(t=>{"source"===t.dataType&&"metadata"===t.sourceDataType&&(this._sourceLoaded=!0),this._sourceLoaded&&!this._paused&&"source"===t.dataType&&"content"===t.sourceDataType&&(this.reload(),this.transform&&this.update(this.transform))})),e.on("error",(()=>{this._sourceErrored=!0})),this._source=e,this._tiles={},this._cache=new Yy(0,this._unloadTile.bind(this)),this._timers={},this._cacheTimers={},this._minTileCacheSize=e.minTileCacheSize,this._maxTileCacheSize=e.maxTileCacheSize,this._loadedParentTiles={},this.castsShadows=!1,this.tileCoverLift=0,this._coveredTiles={},this._shadowCasterTiles={},this._state=new km,this._isRaster="raster"===this._source.type||"raster-dem"===this._source.type||"raster-array"===this._source.type||"custom"===this._source.type&&"raster"===this._source._dataType}onAdd(t){this.map=t,this._minTileCacheSize=void 0===this._minTileCacheSize&&t?t._minTileCacheSize:this._minTileCacheSize,this._maxTileCacheSize=void 0===this._maxTileCacheSize&&t?t._maxTileCacheSize:this._maxTileCacheSize}loaded(){if(this._sourceErrored)return!0;if(!this._sourceLoaded)return!1;if(!this._source.loaded())return!1;for(const t in this._tiles){const e=this._tiles[t];if("errored"!==e.state&&("loaded"!==e.state||!e.bucketsLoaded()))return!1}return!0}getSource(){return this._source}pause(){this._paused=!0}resume(){if(!this._paused)return;const t=this._shouldReloadOnResume;this._paused=!1,this._shouldReloadOnResume=!1,t&&this.reload(),this.transform&&this.update(this.transform)}_loadTile(t,e){return t.isSymbolTile=this._onlySymbols,t.isExtraShadowCaster=this._shadowCasterTiles[t.tileID.key],this._source.loadTile(t,e)}_unloadTile(t){if(this._source.unloadTile)return this._source.unloadTile(t)}_abortTile(t){if(this._source.abortTile)return this._source.abortTile(t)}serialize(){return this._source.serialize()}prepare(t){this._source.prepare&&this._source.prepare(),this._state.coalesceChanges(this._tiles,this.map?this.map.painter:null);for(const e in this._tiles){const i=this._tiles[e];i.upload(t),i.prepare(this.map.style.imageManager,this.map?this.map.painter:null,this._source.scope)}}getIds(){return ti(this._tiles).map((t=>t.tileID)).sort(Ky).map((t=>t.key))}getRenderableIds(t,e){const i=[];for(const n in this._tiles)this._isIdRenderable(+n,t,e)&&i.push(this._tiles[n]);return t?i.sort(((t,e)=>{const i=t.tileID,n=e.tileID,r=new Ue(i.canonical.x,i.canonical.y)._rotate(this.transform.angle),o=new Ue(n.canonical.x,n.canonical.y)._rotate(this.transform.angle);return i.overscaledZ-n.overscaledZ||o.y-r.y||o.x-r.x})).map((t=>t.tileID.key)):i.map((t=>t.tileID)).sort(Ky).map((t=>t.key))}hasRenderableParent(t){const e=this.findLoadedParent(t,0);return!!e&&this._isIdRenderable(e.tileID.key)}_isIdRenderable(t,e,i){return this._tiles[t]&&this._tiles[t].hasData()&&!this._coveredTiles[t]&&(e||!this._tiles[t].holdingForFade())&&(i||!this._shadowCasterTiles[t])}reload(){if(this._paused)this._shouldReloadOnResume=!0;else{this._cache.reset();for(const t in this._tiles)"errored"!==this._tiles[t].state&&this._reloadTile(+t,"reloading")}}_reloadTile(t,e){const i=this._tiles[t];i&&("loading"!==i.state&&(i.state=e),this._loadTile(i,this._tileLoaded.bind(this,i,t,e)))}_tileLoaded(t,e,i,n){if(n)if(t.state="errored",404!==n.status)this._source.fire(new $n(n,{tile:t}));else{if(!(t.tileID.key in this._loadedParentTiles))return void this._source.fire(new Pn("data",{dataType:"source",sourceDataType:"error",sourceId:this._source.id}));if("raster-dem"===this._source.type&&this.usedForTerrain&&this.map.painter.terrain){const t=this.map.painter.terrain;this.update(this.transform,t.getScaledDemTileSize(),!0),t.resetTileLookupCache(this.id)}else this.update(this.transform)}else t.timeAdded=ki.now(),"expired"===i&&(t.refreshedUponExpiration=!0),this._setTileReloadTimer(e,t),"raster-dem"===this._source.type&&t.dem&&this._backfillDEM(t),this._state.initializeTileState(t,this.map?this.map.painter:null),this._source.fire(new Pn("data",{dataType:"source",tile:t,coord:t.tileID,sourceCacheId:this.id}))}_backfillDEM(t){const e=this.getRenderableIds();for(let n=0;n1||(Math.abs(i)>1&&(1===Math.abs(i+r)?i+=r:1===Math.abs(i-r)&&(i-=r)),e.dem&&t.dem&&(t.dem.backfillBorder(e.dem,i,n),t.neighboringTiles&&t.neighboringTiles[o]&&(t.neighboringTiles[o].backfilled=!0)))}}getTile(t){return this.getTileByID(t.key)}getTileByID(t){return this._tiles[t]}_retainLoadedChildren(t,e,i,n){for(const r in this._tiles){let o=this._tiles[r];if(n[r]||!o.hasData()||o.tileID.overscaledZi)continue;let s=o.tileID;for(;o&&o.tileID.overscaledZ>e+1;){const t=o.tileID.scaledTo(o.tileID.overscaledZ-1);o=this._tiles[t.key],o&&o.hasData()&&(s=t)}let a=s;for(;a.overscaledZ>e;)if(a=a.scaledTo(a.overscaledZ-1),t[a.key]){n[s.key]=s;break}}}findLoadedParent(t,e){if(t.key in this._loadedParentTiles){const i=this._loadedParentTiles[t.key];return i&&i.tileID.overscaledZ>=e?i:null}for(let i=t.overscaledZ-1;i>=e;i--){const e=t.scaledTo(i),n=this._getLoadedTile(e);if(n)return n}}_getLoadedTile(t){const e=this._tiles[t.key];return e&&e.hasData()?e:this._cache.getByKey(this._source.reparseOverscaled?t.wrapped().key:t.canonical.key)}updateCacheSize(t,e){e=e||this._source.tileSize;const i=Math.ceil(t.width/e)+1,n=Math.ceil(t.height/e)+1,r=Math.floor(i*n*5),o="number"==typeof this._minTileCacheSize?Math.max(this._minTileCacheSize,r):r,s="number"==typeof this._maxTileCacheSize?Math.min(this._maxTileCacheSize,o):o;this._cache.setMaxSize(s)}handleWrapJump(t){const e=Math.round((t-(void 0===this._prevLng?t:this._prevLng))/360);if(this._prevLng=t,e){const t={};for(const i in this._tiles){const n=this._tiles[i];n.tileID=n.tileID.unwrapTo(n.tileID.wrap+e),t[n.tileID.key]=n}this._tiles=t;for(const t in this._timers)clearTimeout(this._timers[t]),delete this._timers[t];for(const t in this._tiles)this._setTileReloadTimer(+t,this._tiles[t])}}update(t,e,i,n){if(this.transform=t,!this._sourceLoaded||this._paused||this.transform.freezeTileCoverage)return;if(this.usedForTerrain&&!i)return;let r;if(this.updateCacheSize(t,e),"globe"!==this.transform.projection.name&&this.handleWrapJump(this.transform.center.lng),this._shadowCasterTiles={},this._coveredTiles={},this.used||this.usedForTerrain){if(this._source.tileID)r=t.getVisibleUnwrappedCoordinates(this._source.tileID).map((t=>new vd(t.canonical.z,t.wrap,t.canonical.z,t.canonical.x,t.canonical.y)));else if(0!==this.tileCoverLift){const n=t.clone();n.tileCoverLift=this.tileCoverLift,r=n.coveringTiles({tileSize:e||this._source.tileSize,minzoom:this._source.minzoom,maxzoom:this._source.maxzoom,roundZoom:this._source.roundZoom&&!i,reparseOverscaled:this._source.reparseOverscaled,isTerrainDEM:this.usedForTerrain}),this._source.minzoomt(e)))}}else r=[];if(r.length>0&&this.castsShadows&&n&&"globe"!==this.transform.projection.name&&!this.usedForTerrain&&!Jy(this._source.type)){const o=t.coveringZoomLevel({tileSize:e||this._source.tileSize,roundZoom:this._source.roundZoom&&!i}),s=Math.min(o,this._source.maxzoom),a=t.extendTileCoverForShadows(r,n,s);for(const t of a)this._shadowCasterTiles[t.key]=!0,r.push(t)}const o=this._updateRetainedTiles(r);if(Jy(this._source.type)&&0!==r.length){const t={},e={},i=Object.keys(o);for(const n of i){const i=o[n],r=this._tiles[n];if(!r||r.fadeEndTime&&r.fadeEndTimen;){r=r.scaledTo(r.overscaledZ-1);const n=this._tiles[r.key];if(n&&n.hasData()&&e[r.key]){o[t]=i.tileID;break}}}for(const e in t)o[e]||(this._coveredTiles[e]=!0,o[e]=t[e])}for(const t in o)this._tiles[t].clearFadeHold();const s=function(t,e){const i=[];for(const n in t)n in e||i.push(n);return i}(this._tiles,o);for(const t of s){const e=this._tiles[t];e.hasSymbolBuckets&&!e.holdingForFade()?e.setHoldDuration(this.map._fadeDuration):e.hasSymbolBuckets&&!e.symbolFadeFinished()||this._removeTile(+t)}this._updateLoadedParentTileCache(),this._onlySymbols&&this._source.afterUpdate&&this._source.afterUpdate()}releaseSymbolFadeTiles(){for(const t in this._tiles)this._tiles[t].holdingForFade()&&this._removeTile(+t)}_updateRetainedTiles(t){const e={};if(0===t.length)return e;const i={},n=t.reduce(((t,e)=>Math.min(t,e.overscaledZ)),1/0),r=t[0].overscaledZ,o=Math.max(r-Xy.maxOverzooming,this._source.minzoom),s=Math.max(r+Xy.maxUnderzooming,this._source.minzoom),a={};for(const i of t){const t=this._addTile(i);e[i.key]=i,t.hasData()||n=this._source.maxzoom){const t=n.children(this._source.maxzoom)[0],i=this.getTile(t);if(i&&i.hasData()){e[t.key]=t;continue}}else{const t=n.children(this._source.maxzoom);if(e[t[0].key]&&e[t[1].key]&&e[t[2].key]&&e[t[3].key])continue}let r=t.wasRequested();for(let s=n.overscaledZ-1;s>=o;--s){const o=n.scaledTo(s);if(i[o.key])break;if(i[o.key]=!0,t=this.getTile(o),!t&&r&&(t=this._addTile(o)),t&&(e[o.key]=o,r=t.wasRequested(),t.hasData()))break}}return e}_updateLoadedParentTileCache(){this._loadedParentTiles={};for(const t in this._tiles){const e=[];let i,n=this._tiles[t].tileID;for(;n.overscaledZ>0;){if(n.key in this._loadedParentTiles){i=this._loadedParentTiles[n.key];break}e.push(n.key);const t=n.scaledTo(n.overscaledZ-1);if(i=this._getLoadedTile(t),i)break;n=t}for(const t of e)this._loadedParentTiles[t]=i}}_addTile(t){let e=this._tiles[t.key];if(e)return!0!==e.isExtraShadowCaster||!!this._shadowCasterTiles[t.key]||this._reloadTile(t.key,"reloading"),e;e=this._cache.getAndRemove(t),e&&(this._setTileReloadTimer(t.key,e),e.tileID=t,this._state.initializeTileState(e,this.map?this.map.painter:null),this._cacheTimers[t.key]&&(clearTimeout(this._cacheTimers[t.key]),delete this._cacheTimers[t.key],this._setTileReloadTimer(t.key,e)));const i=Boolean(e);if(!i){const i=this.map?this.map.painter:null,n=this._source.tileSize*t.overscaleFactor();e="raster-array"===this._source.type?new Wy(t,n,this.transform.tileZoom,i,this._isRaster):new ey(t,n,this.transform.tileZoom,i,this._isRaster),this._loadTile(e,this._tileLoaded.bind(this,e,t.key,e.state))}return e?(e.uses++,this._tiles[t.key]=e,i||this._source.fire(new Pn("dataloading",{tile:e,coord:e.tileID,dataType:"source"})),e):null}_setTileReloadTimer(t,e){t in this._timers&&(clearTimeout(this._timers[t]),delete this._timers[t]);const i=e.getExpiryTimeout();i&&(this._timers[t]=setTimeout((()=>{this._reloadTile(t,"expired"),delete this._timers[t]}),i))}_removeTile(t){const e=this._tiles[t];e&&(e.uses--,delete this._tiles[t],this._timers[t]&&(clearTimeout(this._timers[t]),delete this._timers[t]),e.uses>0||(e.hasData()&&"reloading"!==e.state||"empty"===e.state?this._cache.add(e.tileID,e,e.getExpiryTimeout()):(e.aborted=!0,this._abortTile(e),this._unloadTile(e))))}clearTiles(){this._shouldReloadOnResume=!1,this._paused=!1;for(const t in this._tiles)this._removeTile(+t);this._source._clear&&this._source._clear(),this._cache.reset(),this.map&&this.usedForTerrain&&this.map.painter.terrain&&this.map.painter.terrain.resetTileLookupCache(this.id)}tilesIn(t,e,i){const n=[],r=this.transform;if(!r)return n;const o="globe"===r.projection.name,s=Ed(r.center.lng);for(const a in this._tiles){const l=this._tiles[a];if(i&&l.clearQueryDebugViz(),l.holdingForFade())continue;let c;if(o){const t=l.tileID.canonical;if(0===t.z){const e=[Math.abs(Xe(s,...Qy(t,-1))-s),Math.abs(Xe(s,...Qy(t,1))-s)];c=[0,2*e.indexOf(Math.min(...e))-1]}else{const e=[Math.abs(Xe(s,...Qy(t,-1))-s),Math.abs(Xe(s,...Qy(t,0))-s),Math.abs(Xe(s,...Qy(t,1))-s)];c=[e.indexOf(Math.min(...e))-1]}}else c=[0];for(const i of c){const o=t.containsTile(l,r,e,i);o&&n.push(o)}}return n}getShadowCasterCoordinates(){return this._getRenderableCoordinates(!1,!0)}getVisibleCoordinates(t){return this._getRenderableCoordinates(t)}_getRenderableCoordinates(t,e){const i=this.getRenderableIds(t,e).map((t=>this._tiles[t].tileID)),n="globe"===this.transform.projection.name;for(const t of i)t.projMatrix=this.transform.calculateProjMatrix(t.toUnwrapped()),t.expandedProjMatrix=n?this.transform.calculateProjMatrix(t.toUnwrapped(),!1,!0):t.projMatrix;return i}sortCoordinatesByDistance(t){const e=t.slice(),i=this.transform._camera.position,n=this.transform._camera.forward(),r={};for(const t of e){const e=1/(1r[t.key]-r[e.key])),e}hasTransition(){if(this._source.hasTransition())return!0;if(Jy(this._source.type))for(const t in this._tiles){const e=this._tiles[t];if(void 0!==e.fadeEndTime&&e.fadeEndTime>=ki.now())return!0}return!1}setFeatureState(t,e,i){this._state.updateState(t=t||"_geojsonTileLayer",e,i)}removeFeatureState(t,e,i){this._state.removeFeatureState(t=t||"_geojsonTileLayer",e,i)}getFeatureState(t,e){return this._state.getState(t=t||"_geojsonTileLayer",e)}setDependencies(t,e,i){const n=this._tiles[t];n&&n.setDependencies(e,i)}reloadTilesForDependencies(t,e){for(const i in this._tiles)this._tiles[i].hasDependency(t,e)&&this._reloadTile(+i,"reloading");this._cache.filter((i=>!i.hasDependency(t,e)))}_preloadTiles(t,e){if(!this._sourceLoaded){const i=()=>{this._sourceLoaded&&(this._source.off("data",i),this._preloadTiles(t,e))};return void this._source.on("data",i)}const i=new Map,n=Array.isArray(t)?t:[t],r=this.map.painter.terrain,o=this.usedForTerrain&&r?r.getScaledDemTileSize():this._source.tileSize;for(const t of n){const e=t.coveringTiles({tileSize:o,minzoom:this._source.minzoom,maxzoom:this._source.maxzoom,roundZoom:this._source.roundZoom&&!this.usedForTerrain,reparseOverscaled:this._source.reparseOverscaled,isTerrainDEM:this.usedForTerrain});for(const t of e)i.set(t.key,t);this.usedForTerrain&&t.updateElevation(!1)}Qe(Array.from(i.values()),((t,e)=>{const i=new ey(t,this._source.tileSize*t.overscaleFactor(),this.transform.tileZoom,this.map.painter,this._isRaster);this._loadTile(i,(t=>{"raster-dem"===this._source.type&&i.dem&&this._backfillDEM(i),e(t,i)}))}),e)}}function Ky(t,e){const i=Math.abs(2*t.wrap)-+(t.wrap0?e+2*t:t}tv.useIntegerZoom=!0;const iv=new ol({"symbol-placement":new il(sl.layout_symbol["symbol-placement"]),"symbol-spacing":new il(sl.layout_symbol["symbol-spacing"]),"symbol-avoid-edges":new il(sl.layout_symbol["symbol-avoid-edges"]),"symbol-sort-key":new nl(sl.layout_symbol["symbol-sort-key"]),"symbol-z-order":new il(sl.layout_symbol["symbol-z-order"]),"symbol-z-elevate":new il(sl.layout_symbol["symbol-z-elevate"]),"icon-allow-overlap":new il(sl.layout_symbol["icon-allow-overlap"]),"icon-ignore-placement":new il(sl.layout_symbol["icon-ignore-placement"]),"icon-optional":new il(sl.layout_symbol["icon-optional"]),"icon-rotation-alignment":new il(sl.layout_symbol["icon-rotation-alignment"]),"icon-size":new nl(sl.layout_symbol["icon-size"]),"icon-text-fit":new nl(sl.layout_symbol["icon-text-fit"]),"icon-text-fit-padding":new nl(sl.layout_symbol["icon-text-fit-padding"]),"icon-image":new nl(sl.layout_symbol["icon-image"]),"icon-rotate":new nl(sl.layout_symbol["icon-rotate"]),"icon-padding":new il(sl.layout_symbol["icon-padding"]),"icon-keep-upright":new il(sl.layout_symbol["icon-keep-upright"]),"icon-offset":new nl(sl.layout_symbol["icon-offset"]),"icon-anchor":new nl(sl.layout_symbol["icon-anchor"]),"icon-pitch-alignment":new il(sl.layout_symbol["icon-pitch-alignment"]),"text-pitch-alignment":new il(sl.layout_symbol["text-pitch-alignment"]),"text-rotation-alignment":new il(sl.layout_symbol["text-rotation-alignment"]),"text-field":new nl(sl.layout_symbol["text-field"]),"text-font":new nl(sl.layout_symbol["text-font"]),"text-size":new nl(sl.layout_symbol["text-size"]),"text-max-width":new nl(sl.layout_symbol["text-max-width"]),"text-line-height":new nl(sl.layout_symbol["text-line-height"]),"text-letter-spacing":new nl(sl.layout_symbol["text-letter-spacing"]),"text-justify":new nl(sl.layout_symbol["text-justify"]),"text-radial-offset":new nl(sl.layout_symbol["text-radial-offset"]),"text-variable-anchor":new il(sl.layout_symbol["text-variable-anchor"]),"text-anchor":new nl(sl.layout_symbol["text-anchor"]),"text-max-angle":new il(sl.layout_symbol["text-max-angle"]),"text-writing-mode":new il(sl.layout_symbol["text-writing-mode"]),"text-rotate":new nl(sl.layout_symbol["text-rotate"]),"text-padding":new il(sl.layout_symbol["text-padding"]),"text-keep-upright":new il(sl.layout_symbol["text-keep-upright"]),"text-transform":new nl(sl.layout_symbol["text-transform"]),"text-offset":new nl(sl.layout_symbol["text-offset"]),"text-allow-overlap":new il(sl.layout_symbol["text-allow-overlap"]),"text-ignore-placement":new il(sl.layout_symbol["text-ignore-placement"]),"text-optional":new il(sl.layout_symbol["text-optional"]),visibility:new il(sl.layout_symbol.visibility)});var nv={paint:new ol({"icon-opacity":new nl(sl.paint_symbol["icon-opacity"]),"icon-occlusion-opacity":new nl(sl.paint_symbol["icon-occlusion-opacity"]),"icon-emissive-strength":new nl(sl.paint_symbol["icon-emissive-strength"]),"text-emissive-strength":new nl(sl.paint_symbol["text-emissive-strength"]),"icon-color":new nl(sl.paint_symbol["icon-color"]),"icon-halo-color":new nl(sl.paint_symbol["icon-halo-color"]),"icon-halo-width":new nl(sl.paint_symbol["icon-halo-width"]),"icon-halo-blur":new nl(sl.paint_symbol["icon-halo-blur"]),"icon-translate":new il(sl.paint_symbol["icon-translate"]),"icon-translate-anchor":new il(sl.paint_symbol["icon-translate-anchor"]),"icon-image-cross-fade":new nl(sl.paint_symbol["icon-image-cross-fade"]),"text-opacity":new nl(sl.paint_symbol["text-opacity"]),"text-occlusion-opacity":new nl(sl.paint_symbol["text-occlusion-opacity"]),"text-color":new nl(sl.paint_symbol["text-color"],{runtimeType:Qn,getOverride:t=>t.textColor,hasOverride:t=>!!t.textColor}),"text-halo-color":new nl(sl.paint_symbol["text-halo-color"]),"text-halo-width":new nl(sl.paint_symbol["text-halo-width"]),"text-halo-blur":new nl(sl.paint_symbol["text-halo-blur"]),"text-translate":new il(sl.paint_symbol["text-translate"]),"text-translate-anchor":new il(sl.paint_symbol["text-translate-anchor"]),"icon-color-saturation":new il(sl.paint_symbol["icon-color-saturation"]),"icon-color-contrast":new il(sl.paint_symbol["icon-color-contrast"]),"icon-color-brightness-min":new il(sl.paint_symbol["icon-color-brightness-min"]),"icon-color-brightness-max":new il(sl.paint_symbol["icon-color-brightness-max"])}),layout:iv};class rv{constructor(t){this.type=t.property.overrides?t.property.overrides.runtimeType:Yn,this.defaultValue=t}evaluate(t){if(t.formattedSection){const e=this.defaultValue.property.overrides;if(e&&e.hasOverride(t.formattedSection))return e.getOverride(t.formattedSection)}return t.feature&&t.featureState?this.defaultValue.evaluate(t.feature,t.featureState):this.defaultValue.property.specification.default}eachChild(t){this.defaultValue.isConstant()||t(this.defaultValue.value._styleExpression.expression)}outputDefined(){return!1}serialize(){return null}}ba(rv,"FormatSectionOverride",{omit:["defaultValue"]});class ov extends Ml{constructor(e,i,n,r){super(e,nv,i,n,r),this._colorAdjustmentMatrix=t.ad.identity([]),this.hasInitialOcclusionOpacityProperties=void 0!==e.paint&&("icon-occlusion-opacity"in e.paint||"text-occlusion-opacity"in e.paint)}recalculate(t,e){super.recalculate(t,e),"auto"===this.layout.get("icon-rotation-alignment")&&(this.layout._values["icon-rotation-alignment"]="point"!==this.layout.get("symbol-placement")?"map":"viewport"),"auto"===this.layout.get("text-rotation-alignment")&&(this.layout._values["text-rotation-alignment"]="point"!==this.layout.get("symbol-placement")?"map":"viewport"),"auto"===this.layout.get("text-pitch-alignment")&&(this.layout._values["text-pitch-alignment"]=this.layout.get("text-rotation-alignment")),"auto"===this.layout.get("icon-pitch-alignment")&&(this.layout._values["icon-pitch-alignment"]=this.layout.get("icon-rotation-alignment"));const i=this.layout.get("text-writing-mode");if(i){const t=[];for(const e of i)t.indexOf(e)i in t?String(t[i]):""))}(e.properties,r)}createBucket(t){return new jg(t)}queryRadius(){return 0}queryIntersectsFeature(){return!1}_setPaintOverrides(){for(const t of nv.paint.overridableProperties){if(!ov.hasPaintOverride(this.layout,t))continue;const e=this.paint.get(t),i=new rv(e),n=new la(i,e.property.specification,this.scope,this.options);let r=null;r="constant"===e.value.kind||"source"===e.value.kind?new ua("source",n):new ha("composite",n,e.value.zoomStops,e.value._interpolationType),this.paint._values[t]=new tl(e.property,r,e.parameters)}}_handleOverridablePaintPropertyUpdate(t,e,i){return!(!this.layout||e.isDataDriven()||i.isDataDriven())&&ov.hasPaintOverride(this.layout,t)}static hasPaintOverride(t,e){const i=t.get("text-field"),n=nv.paint.properties[e];let r=!1;const o=t=>{for(const e of t)if(n.overrides&&n.overrides.hasOverride(e))return void(r=!0)};if("constant"===i.value.kind&&i.value.value instanceof pr)o(i.value.value.sections);else if("source"===i.value.kind){const t=e=>{r||(e instanceof vr&&gr(e.value)===nr?o(e.value.sections):e instanceof Tr?o(e.sections):e.eachChild(t))},e=i.value;e._styleExpression&&t(e._styleExpression.expression)}return r}getProgramIds(){const t=0!==this.paint.get("icon-opacity").constantOr(1),e=0!==this.paint.get("text-opacity").constantOr(1),i=[];return t&&i.push("symbolIcon"),e&&i.push("symbolSDF"),i}getDefaultProgramParams(t,e,i){return{config:new Wc(this,{zoom:e,lut:i}),overrideFog:!1}}}const sv=new ol({visibility:new il(sl.layout_background.visibility)});var av={paint:new ol({"background-color":new il(sl.paint_background["background-color"]),"background-pattern":new il(sl.paint_background["background-pattern"]),"background-opacity":new il(sl.paint_background["background-opacity"]),"background-emissive-strength":new il(sl.paint_background["background-emissive-strength"])}),layout:sv};const lv=new ol({visibility:new il(sl.layout_raster.visibility)});var cv={paint:new ol({"raster-opacity":new il(sl.paint_raster["raster-opacity"]),"raster-color":new rl(sl.paint_raster["raster-color"]),"raster-color-mix":new il(sl.paint_raster["raster-color-mix"]),"raster-color-range":new il(sl.paint_raster["raster-color-range"]),"raster-hue-rotate":new il(sl.paint_raster["raster-hue-rotate"]),"raster-brightness-min":new il(sl.paint_raster["raster-brightness-min"]),"raster-brightness-max":new il(sl.paint_raster["raster-brightness-max"]),"raster-saturation":new il(sl.paint_raster["raster-saturation"]),"raster-contrast":new il(sl.paint_raster["raster-contrast"]),"raster-resampling":new il(sl.paint_raster["raster-resampling"]),"raster-fade-duration":new il(sl.paint_raster["raster-fade-duration"]),"raster-emissive-strength":new il(sl.paint_raster["raster-emissive-strength"]),"raster-array-band":new il(sl.paint_raster["raster-array-band"]),"raster-elevation":new il(sl.paint_raster["raster-elevation"])}),layout:lv};function dv(e,i,n,r,o,s,a,l){const c=[e,i,1,n,r,1,o,s,1],d=[a,l,1],u=t.bC.adjoint([],c),[h,p,f]=t._.transformMat3(d,d,u);return t.bC.multiply(c,c,[h,0,0,0,p,0,0,0,f])}function uv(e,i,n,r,o,s,a,l){const c=function(e,i,n,r,o,s,a,l){const c=dv(0,0,1,0,1,1,0,1),d=dv(e,i,n,r,o,s,a,l),u=t.bC.adjoint([],c);return t.bC.multiply(d,d,u)}(e,i,n,r,o,s,a,l);return[c[2]/c[8]/uo,c[5]/c[8]/uo]}function hv(t){return[t[0],Math.min(Math.max(t[1],-Pd),Pd)]}class pv extends zn{constructor(t,e,i,n){super(),this.id=t,this.dispatcher=i,this.coordinates=e.coordinates,this.type="image",this.minzoom=0,this.maxzoom=22,this.tileSize=512,this.tiles={},this._loaded=!1,this.onNorthPole=!1,this.onSouthPole=!1,this.setEventedParent(n),this.options=e,this._dirty=!1}load(t,e){if(this._loaded=e||!1,this.fire(new Pn("dataloading",{dataType:"source"})),this.url=this.options.url,!this.url)return t&&(this.coordinates=t),this._loaded=!0,void this._finishLoading();this._imageRequest=an(this.map._requestManager.transformRequest(this.url,Ki.Image),((e,i)=>{this._imageRequest=null,this._loaded=!0,e?this.fire(new $n(e)):i&&(this.image=i instanceof HTMLImageElement?ki.getImageData(i):i,this._dirty=!0,this.width=this.image.width,this.height=this.image.height,t&&(this.coordinates=t),this._finishLoading())}))}loaded(){return this._loaded}updateImage(t){return t.url?(this._imageRequest&&t.url!==this.options.url&&(this._imageRequest.cancel(),this._imageRequest=null),this.options.url=t.url,this.load(t.coordinates,this._loaded),this):this}setTexture(t){if(!(t.handle instanceof WebGLTexture))throw new Error("The provided handle is not a WebGLTexture instance");return this.texture=new Gg(this.map.painter.context,t.handle),this.width=t.dimensions[0],this.height=t.dimensions[1],this._dirty=!1,this._loaded=!0,this._finishLoading(),this}_finishLoading(){this.map&&(this.setCoordinates(this.coordinates),this.fire(new Pn("data",{dataType:"source",sourceDataType:"metadata"})))}onAdd(t){this.map=t,this.load()}onRemove(t){this._imageRequest&&(this._imageRequest.cancel(),this._imageRequest=null),!this.texture||this.texture instanceof Gg||this.texture.destroy(),this.boundsBuffer&&(this.boundsBuffer.destroy(),this.elevatedGlobeVertexBuffer&&this.elevatedGlobeVertexBuffer.destroy(),this.elevatedGlobeIndexBuffer&&this.elevatedGlobeIndexBuffer.destroy())}setCoordinates(t){if(this.coordinates=t,this._boundsArray=void 0,this._unsupportedCoords=!1,!t.length)return this;this.onNorthPole=!1,this.onSouthPole=!1;let e=t[0][1],i=t[0][1];for(const n of t)n[1]>i&&(i=n[1]),n[1]Pd?this.onNorthPole=!0:n1&&(l-=1),new gd(s,l,Math.floor((i+r)/2*a))}(e),this.minzoom=this.maxzoom=this.tileID.z}return this.fire(new Pn("data",{dataType:"source",sourceDataType:"content"})),this}_clear(){this._boundsArray=void 0,this._unsupportedCoords=!1}_prepareData(e){for(const t in this.tiles){const e=this.tiles[t];"loaded"!==e.state&&(e.state="loaded",e.texture=this.texture)}if(this._boundsArray||this.onNorthPole||this.onSouthPole||this._unsupportedCoords)return;const i=eg(new gd(0,0,0),this.map.transform.projection),n=[i.projection.project(this.coordinates[0][0],this.coordinates[0][1]),i.projection.project(this.coordinates[1][0],this.coordinates[1][1]),i.projection.project(this.coordinates[2][0],this.coordinates[2][1]),i.projection.project(this.coordinates[3][0],this.coordinates[3][1])];if(!function(t){const e=t[1].x-t[0].x,i=t[1].y-t[0].y,n=t[2].x-t[1].x,r=t[2].y-t[1].y,o=t[3].x-t[2].x,s=t[3].y-t[2].y,a=t[0].x-t[3].x,l=t[0].y-t[3].y,c=e*r-n*i,d=n*s-o*r,u=o*l-a*s,h=a*i-e*l;return c>0&&d>0&&u>0&&h>0||c{const e=r.projection.project(t[0],t[1]);return ig(r,e)._round()}));this.perspectiveTransform=uv(o.x,o.y,s.x,s.y,a.x,a.y,l.x,l.y);const c=this._boundsArray=new Dl;c.emplaceBack(o.x,o.y,0,0),c.emplaceBack(s.x,s.y,uo,0),c.emplaceBack(l.x,l.y,0,uo),c.emplaceBack(a.x,a.y,uo,uo),this.boundsBuffer&&(this.boundsBuffer.destroy(),this.elevatedGlobeVertexBuffer&&this.elevatedGlobeVertexBuffer.destroy(),this.elevatedGlobeIndexBuffer&&this.elevatedGlobeIndexBuffer.destroy()),this.boundsBuffer=e.createVertexBuffer(c,Jg.members),this.boundsSegments=wc.simpleSegment(0,0,4,2);const d=[],u=function(t){return[hv(t[0]),hv(t[1]),hv(t[2]),hv(t[3])]}(this.coordinates),[h,p,f,m]=function(t){let e=t[0][0],i=e,n=t[0][1],r=n;for(let o=1;oi&&(i=t[o][0]),t[o][1]r&&(r=t[o][1]);return[e,n,i-e,r-n]}(u);{const r=new Dl,[o,s,a,l]=function(t){let e=t[0].x,i=e,n=t[0].y,r=n;for(let o=1;oi&&(i=t[o].x),t[o].yr&&(r=t[o].y);return[e,n,i-e,r-n]}(n),c=t=>[(t.x-o)/a,(t.y-s)/l],[u,_,g,y]=n.map(c),v=function(e,i,n,r,o,s,a,l){const c=dv(0,0,1,0,1,1,0,1),d=dv(e,i,n,r,o,s,a,l),u=t.bC.adjoint([],d);return t.bC.multiply(c,c,u)}(u[0],u[1],_[0],_[1],g[0],g[1],y[0],y[1]);this.elevatedGlobePerspectiveTransform=uv(u[0],u[1],_[0],_[1],g[0],g[1],y[0],y[1]);const x=(e,i)=>{d.push(e.lng);const n=Math.round((e.lng-h)/f*uo),o=Math.round((e.lat-p)/m*uo),s=c(i),a=t._.transformMat3([],[s[0],s[1],1],v),l=Math.round(a[0]/a[2]*uo),u=Math.round(a[1]/a[2]*uo);r.emplaceBack(n,o,l,u)},b=n[3].x-n[0].x,w=n[3].y-n[0].y,T=n[2].x-n[1].x,S=n[2].y-n[1].y;for(let t=0;t{i.emplaceBack(e,n,r);const o=d[e],s=d[n],a=d[r],l=Math.min(Math.min(o,s),a),c=Math.max(Math.max(o,s),a)-l;c>this.maxLongitudeTriangleSize&&(this.maxLongitudeTriangleSize=c),t.push(l+c/2)};for(let t=0;te));i.sort(((e,i)=>t[e]-t[i]));const n=[],r=new Kl;for(let o=0;o{o.segments.push({vertexOffset:0,primitiveOffset:t,vertexLength:e.segments[0].vertexLength,primitiveLength:i,sortKey:void 0,vaos:{}})},a=.51*this.maxLongitudeTriangleSize;if(Math.abs(i[0]-n)0){const n=function(e,i){const n=i.worldSize,r=Cd(1,0)*n*kd(i.center.lat,i.zoom)/Gu(n),o=Cd(1,i.center.lat)*n,s=t.ad.identity([]);return t.ad.rotateY(s,s,Ge(i.center.lng)),t.ad.rotateX(s,s,Ge(i.center.lat)),t.ad.translate(s,s,[0,0,ed]),t.ad.scale(s,s,[r,r,r*o]),t.ad.translate(s,s,[i.point.x-.5*n,i.point.y-.5*n,0]),t.ad.multiply(s,s,e),t.ad.multiply(s,i.globeMatrix,s)}(e,i);return function(e,i,n){const r=(e,i,n)=>{const r=t._.length(e),o=t._.length(i),s=ku(e,i,n);return t._.scale(s,s,1/t._.length(s)*Vn(r,o,n))},o=r([e[0],e[1],e[2]],[i[0],i[1],i[2]],n),s=r([e[4],e[5],e[6]],[i[4],i[5],i[6]],n),a=r([e[8],e[9],e[10]],[i[8],i[9],i[10]],n),l=ku([e[12],e[13],e[14]],[i[12],i[13],i[14]],n);return[o[0],o[1],o[2],0,s[0],s[1],s[2],0,a[0],a[1],a[2],0,l[0],l[1],l[2],1]}(o,n,r)}return o}function kv(t,e,i,n){const r=wu.projectAabbCorners(n,i);let o=Number.MAX_VALUE,s=-1;for(let t=0;tnew Ue(r[t][0],r[t][1]);let l;switch(s){case 0:case 6:l=[a(1),a(5),a(4),a(7),a(3),a(2),a(1)];break;case 1:case 7:l=[a(0),a(4),a(5),a(6),a(2),a(3),a(0)];break;case 3:case 5:l=[a(1),a(0),a(4),a(7),a(6),a(2),a(1)];break;default:l=[a(1),a(5),a(6),a(7),a(3),a(0),a(1)]}if(Yd(t,l))return o}const Dv=Ll([{name:"a_pos_3f",components:3,type:"Float32"}]),zv=Ll([{name:"a_color_3f",components:3,type:"Float32"}]),Rv=Ll([{name:"a_color_4f",components:4,type:"Float32"}]),Ov=Ll([{name:"a_uv_2f",components:2,type:"Float32"}]),Bv=Ll([{name:"a_normal_3f",components:3,type:"Float32"}]),Fv=Ll([{name:"a_normal_matrix0",components:4,type:"Float32"},{name:"a_normal_matrix1",components:4,type:"Float32"},{name:"a_normal_matrix2",components:4,type:"Float32"},{name:"a_normal_matrix3",components:4,type:"Float32"}]),Nv=Ll([{name:"a_pbr",components:4,type:"Uint16"},{name:"a_heightBasedEmissiveStrength",components:3,type:"Float32"}]);class Uv{constructor(t,e,i,n){this.message=(t?`${t}: `:"")+i,n&&(this.identifier=n),null!=e&&e.__line__&&(this.line=e.__line__)}}function jv(t,e){const i=-1===t.indexOf("://");try{return new URL(t,i&&e?"http://example.com":void 0),!0}catch(t){return!1}}class Vv{constructor(t,e){this.feature=t,this.instancedDataOffset=e,this.instancedDataCount=0,this.rotation=[0,0,0],this.scale=[1,1,1],this.translation=[0,0,0]}}class Gv{constructor(){this.instancedDataArray=new oc,this.instancesEvaluatedElevation=[],this.features=[],this.idToFeaturesIndex={}}}class Zv{constructor(t){this.zoom=t.zoom,this.canonical=t.canonical,this.layers=t.layers,this.layerIds=this.layers.map((t=>t.fqid)),this.projection=t.projection,this.index=t.index,this.hasZoomDependentProperties=this.layers[0].isZoomDependent(),this.stateDependentLayerIds=this.layers.filter((t=>t.isStateDependent())).map((t=>t.id)),this.hasPattern=!1,this.instancesPerModel={},this.validForExaggeration=0,this.maxVerticalOffset=0,this.maxScale=0,this.maxHeight=0,this.lookupDim=this.zoom>this.canonical.z?256:this.zoom>15?75:100,this.instanceCount=0,this.terrainElevationMin=0,this.terrainElevationMax=0,this.validForDEMTile={id:null,timestamp:0},this.modelUris=[],this.modelsRequested=!1,this.activeReplacements=[],this.replacementUpdateTime=0}updateFootprints(t,e){}populate(t,e,i,n){this.tileToMeter=zd(i);const r=this.layers[0]._featureFilter.needGeometry;this.lookup=new Uint8Array(this.lookupDim*this.lookupDim);for(const{feature:o,id:s,index:a,sourceLayerIndex:l}of t){const t=null!=s?s:o.properties&&o.properties.hasOwnProperty("id")?o.properties.id:void 0,c=Zd(o,r);if(!this.layers[0]._featureFilter.filter(new Ha(this.zoom),c,i))continue;const d={id:t,sourceLayerIndex:l,index:a,geometry:r?c.geometry:Gd(o,i,n),properties:o.properties,type:o.type,patterns:{}},u=this.addFeature(d,d.geometry,c);u&&e.featureIndex.insert(o,d.geometry,a,l,this.index,this.instancesPerModel[u].instancedDataArray.length,uo/32)}this.lookup=null}update(t,e,i,n){for(const e in this.instancesPerModel){const i=this.instancesPerModel[e];for(const e in t)i.idToFeaturesIndex.hasOwnProperty(e)&&(this.evaluate(i.features[i.idToFeaturesIndex[e]],t[e],i,!0),this.uploaded=!1)}this.maxHeight=0}updateZoomBasedPaintProperties(){if(!this.hasZoomDependentProperties)return!1;let e=!1;for(const i in this.instancesPerModel){const n=this.instancesPerModel[i];for(const i of n.features){const r=this.layers[0],o=i.feature,s=this.canonical,a=r.paint.get("model-rotation").evaluate(o,{},s),l=r.paint.get("model-scale").evaluate(o,{},s),c=r.paint.get("model-translation").evaluate(o,{},s);t._.exactEquals(i.rotation,a)&&t._.exactEquals(i.scale,l)&&t._.exactEquals(i.translation,c)||(this.evaluate(i,i.featureStates,n,!0),e=!0)}}return e}updateReplacement(t,e,i){if(e.updateTime===this.replacementUpdateTime)return!1;this.replacementUpdateTime=e.updateTime;const n=e.getReplacementRegionsForTile(t.toUnwrapped(),!0);if(Pp(this.activeReplacements,n))return!1;this.activeReplacements=n;let r=!1;for(const e in this.instancesPerModel){const n=this.instancesPerModel[e],o=n.instancedDataArray;for(const e of n.features){const n=e.instancedDataOffset,s=e.instancedDataCount;for(let e=0;euo?a-uo:a;const l=Math.floor(a),c=o.float32[s+1];let d=!1;for(const e of this.activeReplacements)if(!(e.orderl||l>e.max.x||e.min.y>c||c>e.max.y)&&(d=Op(Rp(l,c,t.canonical,e.footprintTileId.canonical),e),d))break;o.float32[s]=d?a+uo:a,r=r||d}}}return r}isEmpty(){for(const t in this.instancesPerModel)if(0!==this.instancesPerModel[t].instancedDataArray.length)return!1;return!0}uploadPending(){return!this.uploaded}upload(t){if(!this.uploaded)for(const e in this.instancesPerModel){const i=this.instancesPerModel[e];i.instancedDataArray.length=uo||e.y=uo)continue;const t=(this.lookupDim-1)/uo,i=this.lookupDim*(e.y*t|0)+e.x*t|0;if(this.lookup){if(0!==this.lookup[i])continue;this.lookup[i]=1}this.instanceCount++;const n=s.length;s.resize(n+1),o.instancesEvaluatedElevation.push(0),s.float32[16*n]=e.x,s.float32[16*n+1]=e.y}return a.instancedDataCount=o.instancedDataArray.length-a.instancedDataOffset,a.instancedDataCount>0&&(t.id&&(o.idToFeaturesIndex[t.id]=o.features.length),o.features.push(a),this.evaluate(a,{},o,!1)),r}getModelUris(){return this.modelUris}evaluate(t,e,i,n){const r=this.layers[0],o=t.feature,s=this.canonical,a=t.rotation=r.paint.get("model-rotation").evaluate(o,e,s),l=t.scale=r.paint.get("model-scale").evaluate(o,e,s),c=t.translation=r.paint.get("model-translation").evaluate(o,e,s),d=r.paint.get("model-color").evaluate(o,e,s);d.a=r.paint.get("model-color-mix-intensity").evaluate(o,e,s);const u=[];this.maxVerticalOffset10?this.tileToMeter:zd(s,p)),a[o+4]=c[0],a[o+5]=c[1],a[o+6]=c[2]+l,a[o+7]=u[0],a[o+8]=u[1],a[o+9]=u[2],a[o+10]=u[4],a[o+11]=u[5],a[o+12]=u[6],a[o+13]=u[8],a[o+14]=u[9],a[o+15]=u[10],i.instancesEvaluatedElevation[r]=c[2]}}}ba(Zv,"ModelBucket",{omit:["layers"]}),ba(Gv,"PerModelAttributes"),ba(Vv,"ModelFeature");const qv=new ol({visibility:new il(sl.layout_model.visibility),"model-id":new nl(sl.layout_model["model-id"])});var Hv={paint:new ol({"model-opacity":new il(sl.paint_model["model-opacity"]),"model-rotation":new nl(sl.paint_model["model-rotation"]),"model-scale":new nl(sl.paint_model["model-scale"]),"model-translation":new nl(sl.paint_model["model-translation"]),"model-color":new nl(sl.paint_model["model-color"]),"model-color-mix-intensity":new nl(sl.paint_model["model-color-mix-intensity"]),"model-type":new il(sl.paint_model["model-type"]),"model-cast-shadows":new il(sl.paint_model["model-cast-shadows"]),"model-receive-shadows":new il(sl.paint_model["model-receive-shadows"]),"model-ambient-occlusion-intensity":new il(sl.paint_model["model-ambient-occlusion-intensity"]),"model-emissive-strength":new nl(sl.paint_model["model-emissive-strength"]),"model-roughness":new nl(sl.paint_model["model-roughness"]),"model-height-based-emissive-strength-multiplier":new nl(sl.paint_model["model-height-based-emissive-strength-multiplier"]),"model-cutoff-fade-range":new il(sl.paint_model["model-cutoff-fade-range"]),"model-front-cutoff":new il(sl.paint_model["model-front-cutoff"])}),layout:qv};const Wv=64,Yv={CoordinateSpaceTile:1,CoordinateSpaceYUp:2,HasMapboxMeshFeatures:4,HasMeshoptCompression:8};function Xv(e,i,n,r,o,s,a,l,c,d=!1){const u=n.zoom,h=n.project(r),p=kd(r.lat,u),f=1/p;t.ad.identity(e),t.ad.translate(e,e,[h.x+a[0]*f,h.y+a[1]*f,a[2]]);let m=1,_=1;const g=n.worldSize;if(d){if("mercator"===n.projection.name){let e=0;n.elevation&&(e=n.elevation.getAtPointOrZero(new Rd(h.x/g,h.y/g),0));const i=t.aA.transformMat4([],[h.x,h.y,e,1],n.projMatrix)[3]/n.cameraToCenterDistance;m=i,_=i*kd(n.center.lat,u)}else if("globe"===n.projection.name){const i=$v(e,n),o=t.ad.multiply([],n.projMatrix,i),s=[0,0,0,1];t.aA.transformMat4(s,s,o);const a=s[3]/n.cameraToCenterDistance,l=Hu(u),c=n.projection.pixelsPerMeter(r.lat,g)*kd(r.lat,u),d=n.projection.pixelsPerMeter(n.center.lat,g)*kd(n.center.lat,u);m=a/Vn(c,$d(n.center.lat),l),_=a*p/c,m*=d,_*=d}}else m=f;t.ad.scale(e,e,[m,m,_]);const y=[...e],v=i.orientation,x=[];if(Lv(x,[v[0]+o[0],v[1]+o[1],v[2]+o[2]],s),t.ad.multiply(e,y,x),l&&n.elevation){let o=0;const s=[];if(c&&n.elevation){o=function(e,i,n,r,o){const s=i.elevation;if(!s)return 0;const a=wu.projectAabbCorners(n,r),l=Cd(1,o.lat)*i.worldSize,c=function(e,i){const n=[0,0,1],r=[{corners:[0,1,3,2],dotProductWithUp:0},{corners:[1,5,2,6],dotProductWithUp:0},{corners:[0,4,1,5],dotProductWithUp:0},{corners:[2,6,3,7],dotProductWithUp:0},{corners:[4,7,5,6],dotProductWithUp:0},{corners:[0,3,4,7],dotProductWithUp:0}];for(const o of r){const r=e[o.corners[0]],s=e[o.corners[1]],a=e[o.corners[2]],l=[s[0]-r[0],s[1]-r[1],i*(s[2]-r[2])],c=t._.cross(l,l,[a[0]-r[0],a[1]-r[1],i*(a[2]-r[2])]);t._.normalize(c,c),o.dotProductWithUp=t._.dot(c,n)}return r.sort(((t,e)=>t.dotProductWithUp-e.dotProductWithUp)),r[0].corners}(a,l),d=a[c[0]],u=a[c[1]],h=a[c[2]],p=a[c[3]],f=s.getAtPointOrZero(new Rd(d[0]/i.worldSize,d[1]/i.worldSize),0),m=s.getAtPointOrZero(new Rd(u[0]/i.worldSize,u[1]/i.worldSize),0),_=s.getAtPointOrZero(new Rd(h[0]/i.worldSize,h[1]/i.worldSize),0),g=s.getAtPointOrZero(new Rd(p[0]/i.worldSize,p[1]/i.worldSize),0),y=(f+g)/2,v=(m+_)/2;return y>v?m=e.gl.NEAREST_MIPMAP_NEAREST}),t.uploaded=!0,t.image=null)}function Jv(t,e,i){t.indexBuffer=e.createIndexBuffer(t.indexArray,!1,!0),t.vertexBuffer=e.createVertexBuffer(t.vertexArray,Dv.members,!1,!0),t.normalArray&&(t.normalBuffer=e.createVertexBuffer(t.normalArray,Bv.members,!1,!0)),t.texcoordArray&&(t.texcoordBuffer=e.createVertexBuffer(t.texcoordArray,Ov.members,!1,!0)),t.colorArray&&(t.colorBuffer=e.createVertexBuffer(t.colorArray,(12===t.colorArray.bytesPerElement?zv:Rv).members,!1,!0)),t.featureArray&&(t.pbrBuffer=e.createVertexBuffer(t.featureArray,Nv.members,!0)),t.segments=wc.simpleSegment(0,0,t.vertexArray.length,t.indexArray.length);const n=t.material;n.pbrMetallicRoughness.baseColorTexture&&Kv(n.pbrMetallicRoughness.baseColorTexture,e),n.pbrMetallicRoughness.metallicRoughnessTexture&&Kv(n.pbrMetallicRoughness.metallicRoughnessTexture,e),n.normalTexture&&Kv(n.normalTexture,e),n.occlusionTexture&&Kv(n.occlusionTexture,e,i),n.emissionTexture&&Kv(n.emissionTexture,e)}function Qv(t,e,i){if(t.meshes)for(const n of t.meshes)Jv(n,e,i);if(t.children)for(const n of t.children)Qv(n,e,i)}function tx(t){if(t.meshes)for(const e of t.meshes)e.indexArray.destroy(),e.vertexArray.destroy(),e.colorArray&&e.colorArray.destroy(),e.normalArray&&e.normalArray.destroy(),e.texcoordArray&&e.texcoordArray.destroy(),e.featureArray&&e.featureArray.destroy();if(t.children)for(const e of t.children)tx(e)}function ex(t){if(t.meshes)for(const i of t.meshes)i.vertexBuffer&&(i.vertexBuffer.destroy(),i.indexBuffer.destroy(),i.normalBuffer&&i.normalBuffer.destroy(),i.texcoordBuffer&&i.texcoordBuffer.destroy(),i.colorBuffer&&i.colorBuffer.destroy(),i.pbrBuffer&&i.pbrBuffer.destroy(),i.segments.destroy(),i.material&&((e=i.material).pbrMetallicRoughness.baseColorTexture&&e.pbrMetallicRoughness.baseColorTexture.gfxTexture&&e.pbrMetallicRoughness.baseColorTexture.gfxTexture.destroy(),e.pbrMetallicRoughness.metallicRoughnessTexture&&e.pbrMetallicRoughness.metallicRoughnessTexture.gfxTexture&&e.pbrMetallicRoughness.metallicRoughnessTexture.gfxTexture.destroy(),e.normalTexture&&e.normalTexture.gfxTexture&&e.normalTexture.gfxTexture.destroy(),e.emissionTexture&&e.emissionTexture.gfxTexture&&e.emissionTexture.gfxTexture.destroy(),e.occlusionTexture&&e.occlusionTexture.gfxTexture&&e.occlusionTexture.gfxTexture.destroy()));var e;if(t.children)for(const e of t.children)ex(e)}class ix{constructor(t){this._callback=t,this._triggered=!1,"undefined"!=typeof MessageChannel&&(this._channel=new MessageChannel,this._channel.port2.onmessage=()=>{this._triggered=!1,this._callback()})}trigger(){this._triggered||(this._triggered=!0,this._channel?this._channel.port1.postMessage(!0):setTimeout((()=>{this._triggered=!1,this._callback()}),0))}remove(){this._channel=void 0,this._callback=()=>{}}}class nx{constructor(){this.tasks={},this.taskQueue=[],ai(["process"],this),this.invoker=new ix(this.process),this.nextId=0}add(t,e){const i=this.nextId++,n=function({type:t,isSymbolTile:e,zoom:i}){return i=i||0,"message"===t?0:"maybePrepare"!==t||e?"parseTile"!==t||e?"parseTile"===t&&e?300-i:"maybePrepare"===t&&e?400-i:500:200-i:100-i}(e);if(0===n){try{t()}finally{}return null}return this.tasks[i]={fn:t,metadata:e,priority:n,id:i},this.taskQueue.push(i),this.invoker.trigger(),{cancel:()=>{delete this.tasks[i]}}}process(){try{if(this.taskQueue=this.taskQueue.filter((t=>!!this.tasks[t])),!this.taskQueue.length)return;const t=this.pick();if(null===t)return;const e=this.tasks[t];if(delete this.tasks[t],this.taskQueue.length&&this.invoker.trigger(),!e)return;e.fn()}finally{}}pick(){let t=null,e=1/0;for(let i=0;i{i&&delete this.callbacks[s],this.target.postMessage({id:s,type:"",targetMapId:n,sourceMapId:this.mapId})}}}receive(t){const e=t.data,i=e.id;if(i&&(!e.targetMapId||this.mapId===e.targetMapId))if(""===e.type){const t=this.cancelCallbacks[i];delete this.cancelCallbacks[i],t&&t.cancel()}else if(e.mustQueue||gi()){const t=this.callbacks[i],n=this.scheduler.add((()=>this.processTask(i,e)),t&&t.metadata||{type:"message"});n&&(this.cancelCallbacks[i]=n)}else this.processTask(i,e)}processTask(t,e){if(delete this.cancelCallbacks[t],""===e.type){const i=this.callbacks[t];delete this.callbacks[t],i&&(e.error?i(Ea(e.error)):i(null,Ea(e.data)))}else{const i=new Set,n=e.hasCallback?(e,n)=>{this.target.postMessage({id:t,type:"",sourceMapId:this.mapId,error:e?Sa(e):null,data:Sa(n,i)},i)}:t=>{},r=Ea(e.data);if(this.parent[e.type])this.parent[e.type](e.sourceMapId,r,n);else if(this.parent.getWorkerSource){const t=e.type.split(".");this.parent.getWorkerSource(e.sourceMapId,t[0],r.source,r.scope)[t[1]](r,n)}else n(new Error(`Could not find function ${e.type}`))}}remove(){this.scheduler.remove(),this.target.removeEventListener("message",this.receive,!1)}}class ox{constructor(t,e){this.workerPool=t,this.actors=[],this.currentActor=0,this.id=ni();const i=this.workerPool.acquire(this.id);for(let t=0;t{this.ready=!0}))}broadcast(t,e,i){Qe(this.actors,((i,n)=>{i.send(t,e,n)}),i=i||function(){})}getActor(){return this.currentActor=(this.currentActor+1)%this.actors.length,this.actors[this.currentActor]}remove(){this.actors.forEach((t=>{t.remove()})),this.actors=[],this.workerPool.release(this.id)}}ox.Actor=rx;var sx={workerUrl:"",workerClass:null,workerParams:void 0};function ax(){return null!=sx.workerClass?new sx.workerClass:new self.Worker(sx.workerUrl,sx.workerParams)}const lx="mapboxgl_preloaded_worker_pool";class cx{constructor(){this.active={}}acquire(t){if(!this.workers)for(this.workers=[];this.workers.length{t.terminate()})),this.workers=null)}isPreloaded(){return!!this.active[lx]}numActive(){return Object.keys(this.active).length}}let dx;function ux(){return dx||(dx=new cx),dx}cx.workerCount=2;let hx,px,fx,mx,_x,gx=null;function yx(){return gi()&&self.worker&&self.worker.dracoUrl?self.worker.dracoUrl:px||n.DRACO_URL}function vx(){if(gi()&&self.worker&&self.worker.meshoptUrl)return self.worker.meshoptUrl;if(mx)return mx;const t=new Uint8Array([0,97,115,109,1,0,0,0,1,4,1,96,0,0,3,3,2,0,0,5,3,1,0,1,12,1,0,10,22,2,12,0,65,0,65,0,65,0,252,10,0,0,11,7,0,65,0,253,15,26,11]);if("object"!=typeof WebAssembly)throw new Error("WebAssembly not supported, cannot instantiate meshoptimizer");return mx=WebAssembly.validate(t)?n.MESHOPT_SIMD_URL:n.MESHOPT_URL,mx}const xx={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},bx={5120:"DT_INT8",5121:"DT_UINT8",5122:"DT_INT16",5123:"DT_UINT16",5125:"DT_UINT32",5126:"DT_FLOAT32"},wx={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16};function Tx(t,e,i){const n=i.json.bufferViews.length,r=i.buffers.length;e.bufferView=n,i.json.bufferViews[n]={buffer:r,byteLength:t.byteLength},i.buffers[r]=t}const Sx="KHR_draco_mesh_compression";function Ex(t,e){const i=t.extensions&&t.extensions[Sx];if(!i)return;const n=new fx.Decoder,r=$x(e,i.bufferView),o=new fx.Mesh;if(!n.DecodeArrayToMesh(r,r.byteLength,o))throw new Error("Failed to decode Draco mesh");const s=e.json.accessors[t.indices],a=xx[s.componentType],l=s.count*a.BYTES_PER_ELEMENT,c=fx._malloc(l);a===Uint16Array?n.GetTrianglesUInt16Array(o,l,c):n.GetTrianglesUInt32Array(o,l,c),Tx(fx.memory.buffer.slice(c,c+l),s,e),fx._free(c);for(const r of Object.keys(i.attributes)){const s=n.GetAttributeByUniqueId(o,i.attributes[r]),a=e.json.accessors[t.attributes[r]],l=bx[a.componentType],c=a.count*wx[a.type]*xx[a.componentType].BYTES_PER_ELEMENT,d=fx._malloc(c);n.GetAttributeDataArrayForAllPoints(o,s,fx[l],c,d),Tx(fx.memory.buffer.slice(d,d+c),a,e),fx._free(d)}n.destroy(),o.destroy(),delete t.extensions[Sx]}const Mx="EXT_meshopt_compression";function Cx(t,e){if(!t.extensions||!t.extensions[Mx])return;const i=t.extensions[Mx],n=new Uint8Array(e.buffers[i.buffer],i.byteOffset||0,i.byteLength||0),r=new Uint8Array(i.count*i.byteStride);_x.decodeGltfBuffer(r,i.count,i.byteStride,n,i.mode,i.filter),t.buffer=e.buffers.length,t.byteOffset=0,e.buffers[t.buffer]=r.buffer,delete t.extensions[Mx]}const Ax=1179937895,Ix=new TextDecoder("utf8");function Lx(t,e){return new URL(t,e).href}function Px(t,e,i,n){return fetch(Lx(t.uri,n)).then((t=>t.arrayBuffer())).then((t=>{e.buffers[i]=t}))}function $x(t,e){const i=t.json.bufferViews[e];return new Uint8Array(t.buffers[i.buffer],i.byteOffset||0,i.byteLength)}function kx(t,e,i,n){if(t.uri){const r=Lx(t.uri,n);return fetch(r).then((t=>t.blob())).then((t=>createImageBitmap(t))).then((t=>{e.images[i]=t}))}if(void 0!==t.bufferView){const n=$x(e,t.bufferView),r=new Blob([n],{type:t.mimeType});return createImageBitmap(r).then((t=>{e.images[i]=t}))}}function Dx(t,e=0,i){const n={json:null,images:[],buffers:[]};if(new Uint32Array(t,e,1)[0]===Ax){const i=new Uint32Array(t,e);let r=2;const o=(i[r++]>>2)-3,s=i[r++]>>2;if(r++,n.json=JSON.parse(Ix.decode(i.subarray(r,r+s))),r+=s,r{const t=[],e=a&&a.includes(Sx),r=a&&a.includes(Mx);if(e&&t.push(function(){if(!fx)return hx||(hx=function(t){let e,i=null;function n(){e=new Uint8Array(i.buffer)}function r(){throw new Error("Unexpected Draco error.")}const o={a:{a:r,d:function(t,i,n){return e.copyWithin(t,i,i+n)},c:function(t){const r=e.length,o=Math.max(t>>>0,Math.ceil(1.2*r)),s=Math.ceil((o-r)/65536);try{return i.grow(s),n(),!0}catch(t){return!1}},b:r}};return(WebAssembly.instantiateStreaming?WebAssembly.instantiateStreaming(t,o):t.then((t=>t.arrayBuffer())).then((t=>WebAssembly.instantiate(t,o)))).then((t=>{const{Rb:r,Qb:o,P:s,T:a,X:l,Ja:c,La:d,Qa:u,Va:h,Wa:p,eb:f,jb:m,f:_,e:g,yb:y,zb:v,Ab:x,Bb:b,Db:w,Gb:T}=t.instance.exports;i=g;const S=(()=>{let t=0,i=0,n=0,s=0;return a=>{n&&(r(s),r(t),i+=n,n=t=0),t||(i+=128,t=o(i));const l=a.length+7&-8;let c=t;l>=i&&(n=l,c=s=o(l));for(let t=0;t{fx=t,hx=void 0})))}()),r&&t.push(function(){if(_x)return;const t=function(t){let e;const i=WebAssembly.instantiateStreaming(t,{}).then((t=>{e=t.instance,e.exports.__wasm_call_ctors()})),n={NONE:"",OCTAHEDRAL:"meshopt_decodeFilterOct",QUATERNION:"meshopt_decodeFilterQuat",EXPONENTIAL:"meshopt_decodeFilterExp"},r={ATTRIBUTES:"meshopt_decodeVertexBuffer",TRIANGLES:"meshopt_decodeIndexBuffer",INDICES:"meshopt_decodeIndexSequence"};return{ready:i,supported:!0,decodeGltfBuffer(t,i,o,s,a,l){!function(t,e,i,n,r,o,s){const a=t.exports.sbrk,l=n+3&-4,c=a(l*r),d=a(o.length),u=new Uint8Array(t.exports.memory.buffer);u.set(o,d);const h=e(c,n,r,d,o.length);if(0===h&&s&&s(c,l,r),i.set(u.subarray(c,c+n*r)),a(c-a(0)),0!==h)throw new Error(`Malformed buffer data: ${h}`)}(e,e.exports[r[a]],t,i,o,s,e.exports[n[l]])}}}(fetch(vx()));return t.ready.then((()=>{_x=t}))}()),o)for(let e=0;e{if(e&&s)for(const{primitives:t}of s)for(const e of t)Ex(e,n);if(r&&s&&l)for(const t of l)Cx(t,n);return n}))}))}function zx(t,e){const i=t.json.bufferViews[e.bufferView],n=xx[e.componentType];return new n(t.buffers[i.buffer],(e.byteOffset||0)+(i.byteOffset||0),e.count*(i.byteStride&&i.byteStride!==wx[e.type]*n.BYTES_PER_ELEMENT?i.byteStride/n.BYTES_PER_ELEMENT:wx[e.type]))}function Rx(t,e,i,n){const r=xx[e.componentType],o=function(t){switch(t){case Int8Array:return 1/127;case Uint8Array:return 1/255;case Int16Array:return 1/32767;case Uint16Array:return 1/65535;default:return 1}}(r),s=t.json.bufferViews[e.bufferView],a=s.byteStride?s.byteStride/r.BYTES_PER_ELEMENT:wx[e.type],l=i.float32,c=l.length/i.capacity;for(let t=0,i=0;t0){for(let r=0;r0){o.texcoordArray=new ic;const t=e.json.accessors[r.TEXCOORD_0];o.texcoordArray.resize(t.count);const i=zx(e,t);Rx(e,t,o.texcoordArray,i)}if(void 0!==r._FEATURE_ID_RGBA4444){const t=e.json.accessors[r._FEATURE_ID_RGBA4444];e.json.extensionsUsed&&e.json.extensionsUsed.includes("EXT_meshopt_compression")&&(o.featureData=zx(e,t))}void 0!==r._FEATURE_RGBA4444&&(o.featureData=new Uint32Array(zx(e,e.json.accessors[r._FEATURE_RGBA4444]).buffer));const u=t.material;return o.material=function(t,e){const{emissiveFactor:i=[0,0,0],alphaMode:n="OPAQUE",alphaCutoff:r=.5,normalTexture:o,occlusionTexture:s,emissiveTexture:a,doubleSided:l}=t,{baseColorFactor:c=[1,1,1,1],metallicFactor:d=1,roughnessFactor:u=1,baseColorTexture:h,metallicRoughnessTexture:p}=t.pbrMetallicRoughness||{},f=s?e[s.index]:void 0;if(s&&s.extensions&&s.extensions.KHR_texture_transform&&f){const t=s.extensions.KHR_texture_transform;f.offsetScale=[t.offset[0],t.offset[1],t.scale[0],t.scale[1]]}return{pbrMetallicRoughness:{baseColorFactor:new Un(...c),metallicFactor:d,roughnessFactor:u,baseColorTexture:h?e[h.index]:void 0,metallicRoughnessTexture:p?e[p.index]:void 0},doubleSided:l,emissiveFactor:i,alphaMode:n,alphaCutoff:r,normalTexture:o?e[o.index]:void 0,occlusionTexture:f,emissionTexture:a?e[a.index]:void 0,defined:void 0===t.defined}}(void 0!==u?e.json.materials[u]:{defined:!1},i),o}function Bx(e,i,n){const{matrix:r,rotation:o,translation:s,scale:a,mesh:l,extras:c,children:d}=e,u={};if(u.matrix=r||t.ad.fromRotationTranslationScale([],o||[0,0,0,1],s||[0,0,0],a||[1,1,1]),void 0!==l){u.meshes=n[l];const t=u.anchor=[0,0];for(const e of u.meshes){const{min:i,max:n}=e.aabb;t[0]+=i[0]+n[0],t[1]+=i[1]+n[1]}t[0]=Math.floor(t[0]/u.meshes.length/2),t[1]=Math.floor(t[1]/u.meshes.length/2)}if(c&&(c.id&&(u.id=c.id),c.lights&&(u.lights=function(t){if(!t.length)return[];const e=function(t){const e=atob(t),i=new Uint8Array(e.length);for(let t=0;t1&&n[n.length-1].equals(n[0])&&n.pop();let r=0;for(let t=0;t0&&n.reverse();const o=xh(n.flatMap((t=>[t.x,t.y])),[]);return 0===o.length?null:{vertices:n,indices:o}}function Ux(e,i){const n=[],r=[];let o=0;const s=[];for(const a of e){o=n.length;const e=a.vertexArray.float32,l=a.indexArray.uint16;for(let r=0;r0&&([r[t+1],r[t+2]]=[r[t+2],r[t+1]])}return{vertices:n,indices:r}}function jx(t){const e=function(t,e){const i=[],n=WebGL2RenderingContext;if(t.json.textures)for(const r of t.json.textures){const o={magFilter:n.LINEAR,minFilter:n.NEAREST,wrapS:n.REPEAT,wrapT:n.REPEAT};void 0!==r.sampler&&Object.assign(o,t.json.samplers[r.sampler]),i.push({image:e[r.source],sampler:o,uploaded:!1})}return i}(t,t.images),i=function(t,e){const i=[];for(const n of t.json.meshes){const r=[];for(const i of n.primitives)r.push(Ox(i,t,e));i.push(r)}return i}(t,e),{scenes:n,scene:r,nodes:o}=t.json,s=n?n[r||0].nodes:o,a=[];for(const e of s)a.push(Bx(o[e],t,i));return function(t,e,i){const n={},r=new Set;for(let o=0;o0){const e=Array.from(r.values()).sort(((t,e)=>t-e));for(let i=e.length-1;i>=0;i--)t.splice(e[i],1)}}(a,s,t.json.nodes),a}function Vx(t){t.heightmap=new Float32Array(4096),t.heightmap.fill(-1);const e=t.vertexArray.float32,i=t.aabb.min[0]-1,n=t.aabb.min[1]-1,r=Wv/(t.aabb.max[0]-i+2),o=Wv/(t.aabb.max[1]-n+2);for(let s=0;st.heightmap[c*Wv+l]&&(t.heightmap[c*Wv+l]=a)}}function Gx(e,i){const n={};n.indexArray=new Kl,n.indexArray.reserve(4*e.length),n.vertexArray=new Bl,n.vertexArray.reserve(10*e.length),n.colorArray=new Ol,n.vertexArray.reserve(10*e.length);let r=0;for(const o of e){const e=Math.min(10,Math.max(4,1.3*o.height))*i,s=[-o.normal[1],o.normal[0],0],a=Math.min(.29,.1*o.width/o.depth),l=o.width-2*o.depth*i*(a+.01),c=t._.scaleAndAdd([],o.pos,s,l/2),d=t._.scaleAndAdd([],o.pos,s,-l/2),u=[c[0],c[1],c[2]+o.height],h=[d[0],d[1],d[2]+o.height],p=t._.scaleAndAdd([],o.normal,s,a);t._.scale(p,p,e);const f=t._.scaleAndAdd([],o.normal,s,-a);t._.scale(f,f,e),t._.add(p,c,p),t._.add(f,d,f),c[2]+=.1,d[2]+=.1,n.vertexArray.emplaceBack(p[0],p[1],p[2]),n.vertexArray.emplaceBack(f[0],f[1],f[2]),n.vertexArray.emplaceBack(c[0],c[1],c[2]),n.vertexArray.emplaceBack(d[0],d[1],d[2]),n.vertexArray.emplaceBack(u[0],u[1],u[2]),n.vertexArray.emplaceBack(h[0],h[1],h[2]),n.vertexArray.emplaceBack(c[0],c[1],c[2]),n.vertexArray.emplaceBack(d[0],d[1],d[2]),n.vertexArray.emplaceBack(p[0],p[1],p[2]),n.vertexArray.emplaceBack(f[0],f[1],f[2]);const m=l/e/2;n.colorArray.emplaceBack(-m-a,-1,m,.8),n.colorArray.emplaceBack(m+a,-1,m,.8),n.colorArray.emplaceBack(-m,0,m,1.3),n.colorArray.emplaceBack(m,0,m,1.3),n.colorArray.emplaceBack(m+a,-.8,m,.7),n.colorArray.emplaceBack(m+a,-.8,m,.7),n.colorArray.emplaceBack(0,0,m,1.3),n.colorArray.emplaceBack(0,0,m,1.3),n.colorArray.emplaceBack(m+a,-1.2,m,.8),n.colorArray.emplaceBack(m+a,-1.2,m,.8),n.indexArray.emplaceBack(6+r,4+r,8+r),n.indexArray.emplaceBack(7+r,9+r,5+r),n.indexArray.emplaceBack(0+r,1+r,2+r),n.indexArray.emplaceBack(1+r,3+r,2+r),r+=10}const o={defined:!0,emissiveFactor:[0,0,0]},s={};return s.baseColorFactor=Un.white,o.pbrMetallicRoughness=s,n.material=o,n.aabb=new wu([1/0,1/0,1/0],[-1/0,-1/0,-1/0]),n}const Zx=new Float32Array(262144),qx=new Uint8Array(262144);function Hx(t){let e=0;if(t.meshes)for(const i of t.meshes)e=Math.max(e,i.aabb.max[2]);if(t.children)for(const i of t.children)e=Math.max(e,Hx(i));return e}function Wx(t,e,i){if(t.meshes)for(const n of t.meshes)n.aabb.min[0]!==1/0&&i.insert(e,n.aabb.min[0],n.aabb.min[1],n.aabb.max[0],n.aabb.max[1]);if(t.children)for(const n of t.children)Wx(n,e,i)}const Yx=["","wall","door","roof","window","lamp","logo"];class Xx{constructor(t){this.node=t,this.evaluatedRMEA=[[1,0,0,1],[1,0,0,1],[1,0,0,1],[1,0,0,1],[.4,1,0,1],[1,0,0,1],[1,0,0,1]],this.hiddenByReplacement=!1,this.evaluatedScale=[1,1,1],this.evaluatedColor=[],this.emissionHeightBasedParams=[],this.feature={type:"Point",id:t.id,geometry:[],properties:{height:Hx(t)}},this.aabb=this._getLocalBounds()}_getLocalBounds(){if(!this.node.meshes)return new wu([1/0,1/0,1/0],[-1/0,-1/0,-1/0]);if(!this.aabb){let t=0;const e=new wu([1/0,1/0,1/0],[-1/0,-1/0,-1/0]);for(const i of this.node.meshes)this.node.lightMeshIndex!==t&&(i.transformedAabb=wu.applyTransformFast(i.aabb,this.node.matrix),e.encapsulate(i.transformedAabb)),t++;this.aabb=e}return this.aabb}}class Kx{constructor(t,e,i,n,r,o){this.id=e,this.modelTraits|=Yv.CoordinateSpaceTile,this.uploaded=!1,this.hasPattern=!1,i&&(this.modelTraits|=Yv.HasMapboxMeshFeatures),n&&(this.modelTraits|=Yv.HasMeshoptCompression),this.zoom=-1,this.terrainExaggeration=1,this.projection={name:"mercator"},this.replacementUpdateTime=0,this.elevationReadFromZ=255,this.brightness=r,this.dirty=!0,this.needsUpload=!1,this.nodesInfo=[];for(const e of t)this.nodesInfo.push(new Xx(e)),Wx(e,o.featureIndexArray.length,o.grid),o.featureIndexArray.emplaceBack(this.nodesInfo.length-1,0,o.bucketLayerIDs.length-1,0)}updateFootprints(t,e){for(const i of this.getNodesInfo()){const n=i.node;n.footprint&&e.push({footprint:n.footprint,id:t})}}update(){console.log("Update 3D model bucket")}populate(){console.log("populate 3D model bucket")}uploadPending(){return!this.uploaded||this.needsUpload}upload(t){if(!this.needsUpload)return;const e=this.getNodesInfo();for(const i of e){const e=i.node;this.uploaded?this.updatePbrBuffer(e):Qv(e,t,!0)}for(const t of e)tx(t.node);this.uploaded=!0,this.needsUpload=!1}updatePbrBuffer(t){let e=!1;if(!t.meshes)return e;for(const i of t.meshes)i.pbrBuffer&&(i.pbrBuffer.updateData(i.featureArray),e=!0);return e}needsReEvaluation(t,e,i){const n=t.transform.projectionOptions,r=t.style.getBrightness(),o=this.brightness!==r;return!!(!this.uploaded||this.dirty||n.name!==this.projection.name||Jx(i.paint.get("model-color").value,o)||Jx(i.paint.get("model-color-mix-intensity").value,o)||Jx(i.paint.get("model-roughness").value,o)||Jx(i.paint.get("model-emissive-strength").value,o)||Jx(i.paint.get("model-height-based-emissive-strength-multiplier").value,o))&&(this.projection=n,this.brightness=r,!0)}evaluateScale(t,e){if(t.transform.zoom===this.zoom)return;this.zoom=t.transform.zoom;const i=this.getNodesInfo(),n=this.id.canonical;for(const t of i){const i=t.feature;t.evaluatedScale=e.paint.get("model-scale").evaluate(i,{},n)}}evaluate(t){const e=this.getNodesInfo();for(const i of e){if(!i.node.meshes)continue;const e=i.feature,n=i.node.meshes&&i.node.meshes[0].featureData,r=i.evaluatedColor[2],o=i.evaluatedRMEA[2],s=this.id.canonical;if(i.hasTranslucentParts=!1,n){for(let n=0;n=t)continue;const u=Zx[c],h=Math.abs(u);h>a&&(s=u,a=h,l=r,d=e)}if(a>.1){const o=1-(t+.5*Math.abs(l*d))/c;let a=e._dem.get(n,i)+s*o;const u=e._dem.get(n+l,i+d),h=e._dem.get(n-l,i-d,!0);(a-u)*(a-h)>0&&(a=(u+h)/2),Zx[r]=e._dem.set(n,i,a),qx[r]=t}}}}}s&&(e._demTile.needsDEMTextureUpload=!0,e._dem._timestamp=ki.now())}getNodesInfo(){return this.nodesInfo}destroy(){const t=this.getNodesInfo();for(const e of t)tx(e.node),ex(e.node)}isEmpty(){return!this.nodesInfo.length}updateReplacement(t,e){if(e.updateTime===this.replacementUpdateTime)return;this.replacementUpdateTime=e.updateTime;const i=e.getReplacementRegionsForTile(t.toUnwrapped()),n=this.getNodesInfo();for(let t=0;tt.footprint===e.footprint))}}getHeightAtTileCoord(e,i){const n=this.getNodesInfo(),r=[],o=[0,0,0],s=t.ad.identity([]);for(let a=0;ad.max[0]||i>d.max[1])continue;if(!0===l.node.hidden)return{height:0,maxHeight:l.feature.properties.height,hidden:!1,verticalScale:l.evaluatedScale[2]};t.ad.invert(s,l.node.matrix),o[0]=e,o[1]=i,t._.transformMat4(o,o,s);const u=(o[0]-c.aabb.min[0])/(c.aabb.max[0]-c.aabb.min[0])*Wv|0,h=Math.min(63,(o[1]-c.aabb.min[1])/(c.aabb.max[1]-c.aabb.min[1])*Wv|0)*Wv+Math.min(63,u),p=c.heightmap[h];if(!(p0)return{height:void 0,maxHeight:l.feature.properties.height,hidden:l.hiddenByReplacement,verticalScale:l.evaluatedScale[2]}}}}function Jx(t,e){return!t.isLightConstant&&e}function Qx(t,e,i,n,r,o,s,a){let l=(61440&e|(61440&e)>>4)>>8,c=(3840&e|(3840&e)>>4)>>4,d=240&e|(240&e)>>4;i[3]>0&&(l=Vn(l,255*i[0],i[3]),c=Vn(c,255*i[1],i[3]),d=Vn(d,255*i[2],i[3]));const u=l>16&65535,a=o?e>>16&65535:65535&e,l=(15&a)t.polygon)).flat());const g=f?l:null,[y,v]=function(e,i,n,r,o,s,a,l,c,d,u){return"globe"===e.projection.name?function(e,i,n,r,o,s,a,l,c,d,u){const h=[],p=[],f=e.projection.upVectorScale(u,e.center.lat,e.worldSize).metersToTile,m=[0,0,0,1],_=[0,0,0,1],g=(t,e,i,n)=>{t[0]=e,t[1]=i,t[2]=n,t[3]=1},y=Sf();n>0&&(n+=y),r+=y;for(const y of i){const i=[],v=[];for(const h of y){const p=h.x+o.x,y=h.y+o.y,x=e.projection.projectTilePoint(p,y,u),b=e.projection.upVector(u,h.x,h.y);let w=n,T=r;if(a){const t=Pf(p,y,n,r,a,l,c,d);w+=t.base,T+=t.top}0!==n?g(m,x.x+b[0]*f*w,x.y+b[1]*f*w,x.z+b[2]*f*w):g(m,x.x,x.y,x.z),g(_,x.x+b[0]*f*T,x.y+b[1]*f*T,x.z+b[2]*f*T),t._.transformMat4(m,m,s),t._.transformMat4(_,_,s),i.push(new Tp(m[0],m[1],m[2])),v.push(new Tp(_[0],_[1],_[2]))}h.push(i),p.push(v)}return[h,p]}(e,i,n,r,o,s,a,l,c,d,u):a?function(e,i,n,r,o,s,a,l,c){const d=[],u=[],h=[0,0,0,1];for(const p of e){const e=[],f=[];for(const d of p){const u=d.x+r.x,p=d.y+r.y,m=Pf(u,p,i,n,s,a,l,c);h[0]=u,h[1]=p,h[2]=m.base,h[3]=1,t.aA.transformMat4(h,h,o),h[3]=Math.max(h[3],1e-5);const _=new Tp(h[0]/h[3],h[1]/h[3],h[2]/h[3]);h[0]=u,h[1]=p,h[2]=m.top,h[3]=1,t.aA.transformMat4(h,h,o),h[3]=Math.max(h[3],1e-5);const g=new Tp(h[0]/h[3],h[1]/h[3],h[2]/h[3]);e.push(_),f.push(g)}d.push(e),u.push(f)}return[d,u]}(i,n,r,o,s,a,l,c,d):function(t,e,i,n,r){const o=[],s=[],a=r[8]*e,l=r[9]*e,c=r[10]*e,d=r[11]*e,u=r[8]*i,h=r[9]*i,p=r[10]*i,f=r[11]*i;for(const e of t){const t=[],i=[];for(const o of e){const e=o.x+n.x,s=o.y+n.y,m=r[0]*e+r[4]*s+r[12],_=r[1]*e+r[5]*s+r[13],g=r[2]*e+r[6]*s+r[14],y=r[3]*e+r[7]*s+r[15],v=m+a,x=_+l,b=g+c,w=Math.max(y+d,1e-5),T=m+u,S=_+h,E=g+p,M=Math.max(y+f,1e-5);t.push(new Tp(v/w,x/w,b/w)),i.push(new Tp(T/M,S/M,E/M))}o.push(t),s.push(i)}return[o,s]}(i,n,r,o,s)}(s,r,h,u,d,a,g,p,m,s.center.lat,e.tileID.canonical),x=e.queryGeometry;return function(t,e,i){let n=1/0;Kd(i,e)&&(n=Lf(i,e[0]));for(let r=0;r=3)for(let e=0;e>4;if(1!==n)throw new Error(`Got v${n} data when expected v1.`);const r=nb[15&i];if(!r)throw new Error("Unrecognized array type.");const[o]=new Uint16Array(t,2,1),[s]=new Uint32Array(t,4,1);return new rb(s,o,r,t)}constructor(t,e=64,i=Float64Array,n){if(isNaN(t)||t>1;return this.ids[i]=i,this.coords[this._pos++]=t,this.coords[this._pos++]=e,i}finish(){const t=this._pos>>1;if(t!==this.numItems)throw new Error(`Added ${t} items when expected ${this.numItems}.`);return ob(this.ids,this.coords,this.nodeSize,0,this.numItems-1,0),this._finished=!0,this}range(t,e,i,n){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");const{ids:r,coords:o,nodeSize:s}=this,a=[0,r.length-1,0],l=[];for(;a.length;){const c=a.pop()||0,d=a.pop()||0,u=a.pop()||0;if(d-u=t&&a=e&&c>1,p=o[2*h],f=o[2*h+1];p>=t&&p=e&&f=p:n>=f)&&(a.push(h+1),a.push(d),a.push(1-c))}return l}within(t,e,i){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");const{ids:n,coords:r,nodeSize:o}=this,s=[0,n.length-1,0],a=[],l=i*i;for(;s.length;){const c=s.pop()||0,d=s.pop()||0,u=s.pop()||0;if(d-u>1,p=r[2*h],f=r[2*h+1];cb(p,f,t,e)=p:e+i>=f)&&(s.push(h+1),s.push(d),s.push(1-c))}return a}}function ob(t,e,i,n,r,o){if(r-n>1;sb(t,e,s,n,r,o),ob(t,e,i,n,s-1,1-o),ob(t,e,i,s+1,r,1-o)}function sb(t,e,i,n,r,o){for(;r>n;){if(r-n>600){const s=r-n+1,a=i-n+1,l=Math.log(s),c=.5*Math.exp(2*l/3),d=.5*Math.sqrt(l*c*(s-c)/s)*(a-s/2s&&ab(t,e,n,r);as;)l--}e[2*n+o]===s?ab(t,e,n,l):(l++,ab(t,e,l,r)),lr&&(n+=(t[i]-r)*(t[i]-r)),e[i]0&&n[0]0&&n[1]0&&r[0]0&&r[1]0?Math.acos(i/n)*Ve:0;let o=0!==t||0!==e?Math.atan2(-e,-t)*Ve+90:0;return oNi&&(t.getActor().send("enforceCacheSizeLimit",Fi),Vi=0)},t.an=gn,t.ao=class{constructor(t){this.entries={},this.scheduler=t}request(t,e,i,n){const r=this.entries[t]=this.entries[t]||{callbacks:[]};if(r.result){const[t,i]=r.result;return this.scheduler?this.scheduler.add((()=>{n(t,i)}),e):n(t,i),()=>{}}return r.callbacks.push(n),r.cancel||(r.cancel=i(((i,n)=>{r.result=[i,n];for(const t of r.callbacks)this.scheduler?this.scheduler.add((()=>{t(i,n)}),e):t(i,n);setTimeout((()=>delete this.entries[t]),3e3)}))),()=>{r.result||(r.callbacks=r.callbacks.filter((t=>t!==n)),r.callbacks.length||(r.cancel(),delete this.entries[t]))}}},t.ap=function(t,e,i){const n=JSON.stringify(t.request);return t.data&&(this.deduped.entries[n]={result:[null,t.data]}),this.deduped.request(n,{type:"parseTile",isSymbolTile:t.isSymbolTile,zoom:t.tileZoom},(e=>{const n=en(t.request,((t,n,r,o)=>{t?e(t):n&&e(null,{vectorTile:i?void 0:new bp(new Lm(n)),rawData:n,cacheControl:r,expires:o})}));return()=>{n.cancel(),e()}}),e)},t.aq=Dc,t.ar=class extends Lc{constructor(t){super(t),this.current=Fc}set(t,e,i){if(this.fetchUniformLocation(t,e))for(let t=0;t({u_camera_to_center_distance:new $c(t),u_extrude_scale:new Uc(t),u_device_pixel_ratio:new $c(t),u_matrix:new Bc(t),u_inv_rot_matrix:new Bc(t),u_merc_center:new kc(t),u_tile_id:new Dc(t),u_zoom_transition:new $c(t),u_up_dir:new Dc(t),u_emissive_strength:new $c(t)}),t.bJ=t=>({u_matrix:new Bc(t),u_pixels_to_tile_units:new Uc(t),u_device_pixel_ratio:new $c(t),u_units_to_pixels:new kc(t),u_dash_image:new Pc(t),u_gradient_image:new Pc(t),u_image_height:new $c(t),u_texsize:new kc(t),u_tile_units_to_pixels:new $c(t),u_alpha_discard_threshold:new $c(t),u_trim_offset:new kc(t),u_trim_fade_range:new kc(t),u_trim_color:new zc(t),u_emissive_strength:new $c(t)}),t.bK=t=>({u_matrix:new Bc(t),u_texsize:new kc(t),u_pixels_to_tile_units:new Uc(t),u_device_pixel_ratio:new $c(t),u_image:new Pc(t),u_units_to_pixels:new kc(t),u_tile_units_to_pixels:new $c(t),u_alpha_discard_threshold:new $c(t),u_trim_offset:new kc(t)}),t.bL=Yl,t.bM=Hf,t.bN=Om,t.bO=jm,t.bP=G_,t.bQ=c_,t.bR=th,t.bS=(t,e,i,n,r,o)=>{const s=t.transform,a="globe"===s.projection.name;let l;if("map"===o.paint.get("circle-pitch-alignment"))if(a){const t=Zu(s.zoom,e.canonical)*s._pixelsPerMercatorPixel;l=Float32Array.from([t,0,0,t])}else l=s.calculatePixelsToTileUnitsMatrix(i);else l=new Float32Array([s.pixelsToGLUnits[0],0,0,s.pixelsToGLUnits[1]]);const c={u_camera_to_center_distance:t.transform.getCameraToCenterDistance(s.projection),u_matrix:t.translatePosMatrix(e.projMatrix,i,o.paint.get("circle-translate"),o.paint.get("circle-translate-anchor")),u_device_pixel_ratio:ki.devicePixelRatio,u_extrude_scale:l,u_inv_rot_matrix:Qu,u_merc_center:[0,0],u_tile_id:[0,0,0],u_zoom_transition:0,u_up_dir:[0,0,0],u_emissive_strength:o.paint.get("circle-emissive-strength")};if(a){c.u_inv_rot_matrix=n,c.u_merc_center=r,c.u_tile_id=[e.canonical.x,e.canonical.y,1{const s=t.transform;return{u_matrix:rm(t,e,i,n),u_texsize:e.imageAtlasTexture?e.imageAtlasTexture.size:[0,0],u_pixels_to_tile_units:s.calculatePixelsToTileUnitsMatrix(e),u_device_pixel_ratio:r,u_image:0,u_tile_units_to_pixels:nm(e,s),u_units_to_pixels:[1/s.pixelsToGLUnits[0],1/s.pixelsToGLUnits[1]],u_alpha_discard_threshold:0,u_trim_offset:o}},t.bV=(t,e,i,n,r,o,s)=>{const a=t.transform,l=a.calculatePixelsToTileUnitsMatrix(e);return{u_matrix:rm(t,e,i,n),u_pixels_to_tile_units:l,u_device_pixel_ratio:o,u_units_to_pixels:[1/a.pixelsToGLUnits[0],1/a.pixelsToGLUnits[1]],u_dash_image:0,u_gradient_image:1,u_image_height:r,u_texsize:sm(i)&&e.lineAtlasTexture?e.lineAtlasTexture.size:[0,0],u_tile_units_to_pixels:nm(e,t.transform),u_alpha_discard_threshold:0,u_trim_offset:s,u_trim_fade_range:i.paint.get("line-trim-fade-range"),u_trim_color:i.paint.get("line-trim-color").toRenderColor(i.lut).toArray01(),u_emissive_strength:i.paint.get("line-emissive-strength")}},t.bW=oi,t.bX=mh,t.bY=Sf,t.bZ=bd,t.b_=_f,t.ba=function(t,e,i){const n=Hu(i.zoom),r=t.style.map._antialias,o=e.options.extStandardDerivativesForceOff||t.terrain&&t.terrain.exaggeration()>0;return 0===n&&!r&&!o},t.bb=function(e){const i=e.pixelsPerMeter,n=i/Cd(1,e.center.lat),r=t.ad.identity(new Float64Array(16));return t.ad.translate(r,r,[e.point.x,e.point.y,0]),t.ad.scale(r,r,[n,n,i]),Float32Array.from(r)},t.bc=Ou,t.bd=function(t){const e=Pd-5;t=Xe(t,-e,e)/e*90;const i=Math.pow(Math.abs(Math.sin(Ge(t))),3);return Math.round(i*(sd.length-1))},t.be=function(e,i,n,r){const o=i.getNorth(),s=i.getSouth(),a=i.getWest(),l=i.getEast(),c=10){const e=180/r;t.bC.multiply(f,f,[e/d+1,0,0,0,e/u+1,0,-.5*e/h,.5*e/p,1])}return f[2]=c,f[5]=e.x,f[8]=e.y,f},t.bf=ju,t.bg=$u,t.bh=function(e,i,n){const r=t.ad.identity(new Float64Array(16)),o=(i/(1{}}},t.bo=Gg,t.bp=ai,t.bq=class{isDataAvailableAtPoint(t){const e=this._source();if(this.isUsingMockSource()||!e||t.y1)return!1;const i=e.getSource().maxzoom,n=11)return e;const r=n.getSource().maxzoom,o=1{const s=this.getAtTileOffset(e,o.x,o.y),a=r.upVector(e.canonical,o.x,o.y),l=r.upVectorScale(e.canonical,i,n).metersToTile;return t._.scale(a,a,s*l),a}}getForTilePoints(t,e,i,n){if(this.isUsingMockSource())return!1;const r=Xp.create(this,t,n);return!!r&&(e.forEach((t=>{t[2]=this.exaggeration()*r.getElevationAt(t[0],t[1],i)})),!0)}getMinMaxForTile(t){if(this.isUsingMockSource())return null;const e=this.findDEMTileFor(t);if(!e||!e.dem)return null;const i=e.dem.tree,n=e.tileID,r=1=0?t.slice(0,e):t},t.cV=function(t){return t.indexOf(wl)>=0},t.cW=function(t){const e=t.indexOf(wl);return e>=0?t.slice(e+1):""},t.cX=function(t){const e=[],i=t.id;return void 0===i&&e.push({message:`layers.${i}: missing required property "id"`}),void 0===t.render&&e.push({message:`layers.${i}: missing required method "render"`}),t.renderingMode&&"2d"!==t.renderingMode&&"3d"!==t.renderingMode&&e.push({message:`layers.${i}: property "renderingMode" must be either "2d" or "3d"`}),e},t.cY=function(t,e,i,n){return"custom"===t.type?new vv(t,e):new ib[t.type](t,e,i,n)},t.cZ=di,t.c_=Va,t.ca=1,t.cb=Ag,t.cc=0,t.cd=ec,t.ce=function(t,e,i,n,r){return Xe((t-e)/(i-e)*(r-n)+n,n,r)},t.cf=Ns,t.cg=kd,t.ch=class{constructor(t,e,i,n){this.context=t,this.format=n,this.size=i,this.texture=t.gl.createTexture();const[r,o,s]=this.size,{gl:a}=t;a.bindTexture(a.TEXTURE_3D,this.texture),t.pixelStoreUnpackFlipY.set(!1),t.pixelStoreUnpack.set(1),t.pixelStoreUnpackPremultiplyAlpha.set(!1);let l=this.format,c=a.UNSIGNED_BYTE;this.format===a.DEPTH_COMPONENT&&(l=a.DEPTH_COMPONENT16,c=a.UNSIGNED_SHORT),this.format===a.R8&&(n=a.RED),this.format===a.R32F&&(c=a.FLOAT,n=a.RED),a.texImage3D(a.TEXTURE_3D,0,l,r,o,s,0,n,c,e.data)}bind(t,e){const{context:i}=this,{gl:n}=i;n.bindTexture(n.TEXTURE_3D,this.texture),t!==this.minFilter&&(n.texParameteri(n.TEXTURE_3D,n.TEXTURE_MAG_FILTER,t),n.texParameteri(n.TEXTURE_3D,n.TEXTURE_MIN_FILTER,t),this.minFilter=t),e!==this.wrapS&&(n.texParameteri(n.TEXTURE_3D,n.TEXTURE_WRAP_S,e),n.texParameteri(n.TEXTURE_3D,n.TEXTURE_WRAP_T,e),this.wrapS=e)}destroy(){const{gl:t}=this.context;t.deleteTexture(this.texture),this.texture=null}},t.ci=$v,t.cj=[1,1,1],t.ck=Xp,t.cl=Yv,t.cm=ql,t.cn=ic,t.co=class{constructor(){this._updateTime=0,this._sourceIds=[],this._activeRegions=[],this._prevRegions=[],this._globalClipBounds={min:new Ue(1/0,1/0),max:new Ue(-1/0,-1/0)}}clear(){this._activeRegions.length>0&&++this._updateTime,this._activeRegions=[],this._prevRegions=[]}get updateTime(){return this._updateTime}getReplacementRegionsForTile(t,e=!1){const i=$p(new Ue(0,0),new Ue(uo,uo),t),n=[];if(e&&!Lp(i,this._globalClipBounds))return n;for(const e of this._activeRegions){if(e.hiddenByOverlap)continue;if(!Lp(i,e))continue;const r=kp(e.min,e.max,t);n.push({min:r.min,max:r.max,sourceId:this._sourceIds[e.priority],footprint:e.footprint,footprintTileId:e.tileId,order:e.order,clipMask:e.clipMask})}return n}setSources(t){this._setSources(t.map((t=>({getSourceId:()=>t.cache.id,getFootprints:()=>{const e=[];for(const i of t.cache.getVisibleCoordinates()){const n=t.cache.getTile(i).buckets[t.layer];n&&n.updateFootprints(i.toUnwrapped(),e)}return e},getOrder:()=>t.order,getClipMask:()=>t.clipMask}))))}_addSource(t){const e=t.getFootprints();if(0===e.length)return;const i=t.getOrder(),n=t.getClipMask();for(const t of e){if(!t.footprint)continue;const e=$p(t.footprint.min,t.footprint.max,t.id);this._activeRegions.push({min:e.min,max:e.max,hiddenByOverlap:!1,priority:this._sourceIds.length,tileId:t.id,footprint:t.footprint,order:i,clipMask:n})}this._sourceIds.push(t.getSourceId())}_computeReplacement(){this._activeRegions.sort(((t,e)=>t.priority-e.priority||Ap(t.min,e.min)||Ap(t.max,e.max)));let t=this._activeRegions.length!==this._prevRegions.length;if(!t){let e=0;for(;!t&&e!==this._activeRegions.length;){const i=this._activeRegions[e],n=this._prevRegions[e];t=i.priority!==n.priority||!Ip(i,n)||i.order!==n.order||i.clipMask!==n.clipMask,++e}}if(t){++this._updateTime;for(const t of this._activeRegions)t.order!==1/0&&(this._globalClipBounds.min.x=Math.min(this._globalClipBounds.min.x,t.min.x),this._globalClipBounds.min.y=Math.min(this._globalClipBounds.min.y,t.min.y),this._globalClipBounds.max.x=Math.max(this._globalClipBounds.max.x,t.max.x),this._globalClipBounds.max.y=Math.max(this._globalClipBounds.max.y,t.max.y));const t=t=>{const e=this._activeRegions;if(t>=e.length)return t;const i=e[t].priority;for(;t1){let e=0,i=t(e);for(;e!==i;){let n=e;const r=e;for(;n!==i;){const t=this._activeRegions[n];t.hiddenByOverlap=!1;for(let e=0;e=0;e--)this._addSource(t[e]);this._computeReplacement()}},t.cp=Dl,t.cq=Jg,t.cr=rc,t.cs=class{constructor(t){this._createGrid(t),this._createPoles(t)}destroy(){this._poleIndexBuffer.destroy(),this._gridBuffer.destroy(),this._gridIndexBuffer.destroy(),this._poleNorthVertexBuffer.destroy(),this._poleSouthVertexBuffer.destroy();for(const t of this._poleSegments)t.destroy();for(const t of this._gridSegments)t.withSkirts.destroy(),t.withoutSkirts.destroy()}_fillGridMeshWithLods(t,e){const i=new $l,n=new Kl,r=[],o=t+1+2,s=e[0]+1,a=e[0]+1+(1+e.length),l=(t,e,i)=>{let n=t===o-1?t-2:0===t?t:t-1;return n+=i?24575:0,[n,e]};for(let t=0;tt()))},t.dB=sx,t.dC=yx,t.dD=function(t){px=ki.resolveURL(t),gx||(gx=new ox(ux(),new zn)),gx.broadcast("setDracoUrl",px)},t.dE=vx,t.dF=function(t){mx=ki.resolveURL(t),gx||(gx=new ox(ux(),new zn)),gx.broadcast("setMeshoptUrl",mx)},t.dG=ti,t.dH=ba,t.dI=dh,t.dJ=I_,t.dK=eg,t.dL=dc,t.dM=am,t.dN=Dm,t.dO=Wf,t.dP=ci,t.dQ=E_,t.dR=jg,t.dS=function(t,e,i,n,r,o,s,a,l,c,d){t.createArrays(),t.tilePixelRatio=uo/(512*t.overscaling),t.compareText={},t.iconsNeedLinear=!1;const u=t.layers[0].layout,h=t.layers[0]._unevaluatedLayout._values,p={};if("composite"===t.textSizeData.kind){const{minZoom:e,maxZoom:i}=t.textSizeData;p.compositeTextSizes=[h["text-size"].possiblyEvaluate(new Ha(e),a),h["text-size"].possiblyEvaluate(new Ha(i),a)]}if("composite"===t.iconSizeData.kind){const{minZoom:e,maxZoom:i}=t.iconSizeData;p.compositeIconSizes=[h["icon-size"].possiblyEvaluate(new Ha(e),a),h["icon-size"].possiblyEvaluate(new Ha(i),a)]}p.layoutTextSize=h["text-size"].possiblyEvaluate(new Ha(l+1),a),p.layoutIconSize=h["icon-size"].possiblyEvaluate(new Ha(l+1),a),p.textMaxSize=h["text-size"].possiblyEvaluate(new Ha(18),a);const f="map"===u.get("text-rotation-alignment")&&"point"!==u.get("symbol-placement"),m=u.get("text-size");let _=!1;for(const e of t.features)if(e.icon&&e.icon.nameSecondary){_=!0;break}for(const o of t.features){const l=u.get("text-font").evaluate(o,{},a).join(","),h=m.evaluate(o,{},a),g=p.layoutTextSize.evaluate(o,{},a),y=(p.layoutIconSize.evaluate(o,{},a),{horizontal:{},vertical:void 0}),v=o.text;let x,b=[0,0];if(v){const n=v.toString(),s=u.get("text-letter-spacing").evaluate(o,{},a)*Om,c=u.get("text-line-height").evaluate(o,{},a)*Om,d=Aa(n)?s:0,p=u.get("text-anchor").evaluate(o,{},a),m=u.get("text-variable-anchor");if(!m){const t=u.get("text-radial-offset").evaluate(o,{},a);b=t?G_(p,[t*Om,j_]):u.get("text-offset").evaluate(o,{},a).map((t=>t*Om))}let _=f?"center":u.get("text-justify").evaluate(o,{},a);const x="point"===u.get("symbol-placement"),w=x?u.get("text-max-width").evaluate(o,{},a)*Om:1/0,T=o=>{t.allowVerticalPlacement&&Ca(n)&&(y.vertical=e_(v,e,i,r,l,w,c,p,o,d,b,Jm.vertical,!0,g,h))};if(!f&&m){const t="auto"===_?m.map((t=>Z_(t))):[_];let n=!1;for(let o=0;o=0||!Ca(n)){const t=e_(v,e,i,r,l,w,c,p,_,d,b,Jm.horizontal,!1,g,h);t&&(y.horizontal[_]=t)}T(x?"left":_)}}let w=!1;if(o.icon&&o.icon.namePrimary){const e=n[o.icon.namePrimary];e&&(x=u_(r[o.icon.namePrimary],o.icon.nameSecondary?r[o.icon.nameSecondary]:void 0,u.get("icon-offset").evaluate(o,{},a),u.get("icon-anchor").evaluate(o,{},a)),w=e.sdf,void 0===t.sdfIcons?t.sdfIcons=e.sdf:t.sdfIcons!==e.sdf&&pi("Style sheet warning: Cannot mix SDF and non-SDF icons in one buffer"),(e.pixelRatio!==t.pixelRatio||0!==u.get("icon-rotate").constantOr(1))&&(t.iconsNeedLinear=!0))}const T=X_(y.horizontal)||y.vertical;t.iconsInText||(t.iconsInText=!!T&&T.iconsInText),(T||x)&&q_(t,o,y,x,n,p,g,0,b,w,s,a,c,d,_)}o&&t.generateCollisionDebugBuffers(l,t.collisionBoxArray)},t.dT=Jf,t.dU=Yh,t.dV=bp,t.dW=Lm,t.dX=Yp,t.dY=Zy,t.dZ=wp,t.d_=cp,t.da=Wu,t.db=function(e){const i=[0,0,0],n=t.ad.identity(new Float64Array(16));return t.ad.multiply(n,e.pixelMatrix,e.globeMatrix),t._.transformMat4(i,i,n),new Ue(i[0],i[1])},t.dc=d,t.dd=c,t.de=function(t){const e=t.navigator?t.navigator.userAgent:null;return!!function(t){if(null==Ei){const e=t.navigator?t.navigator.userAgent:null;Ei=!!t.safari||!(!e||!(/\b(iPad|iPhone|iPod)\b/.test(e)||e.match("Safari")&&!e.match("Chrome")))}return Ei}(t)&&e&&(e.match("Version/15.4")||e.match("Version/15.5")||e.match(/CPU (OS|iPhone OS) (15_4|15_5) like Mac OS X/))},t.df=ni,t.dg=class{constructor(t,e,i){this._transformRequestFn=t,this._customAccessToken=e,this._silenceAuthErrors=!!i,this._createSkuToken()}_createSkuToken(){const t=function(){let t="";for(let e=0;ethis._skuTokenExpiresAt}transformRequest(t,e){return this._transformRequestFn&&this._transformRequestFn(t,e)||{url:t}}normalizeStyleURL(t,i){if(!o(t))return t;const n=un(t);return n.params.push(`sdk=js-${e}`),n.path=`/styles/v1${n.path}`,this._makeAPIURL(n,this._customAccessToken||i)}normalizeGlyphsURL(t,e){if(!o(t))return t;const i=un(t);return i.path=`/fonts/v1${i.path}`,this._makeAPIURL(i,this._customAccessToken||e)}normalizeModelURL(t,e){if(!o(t))return t;const i=un(t);return i.path=`/models/v1${i.path}`,this._makeAPIURL(i,this._customAccessToken||e)}normalizeSourceURL(t,e,i,n){if(!o(t))return t;const r=un(t);return r.path=`/v4/${r.authority}.json`,r.params.push("secure"),i&&r.params.push(`language=${i}`),n&&r.params.push(`worldview=${n}`),this._makeAPIURL(r,this._customAccessToken||e)}normalizeSpriteURL(t,e,i,n){const r=un(t);return o(t)?(r.path=`/styles/v1${r.path}/sprite${e}${i}`,this._makeAPIURL(r,this._customAccessToken||n)):(r.path+=`${e}${i}`,hn(r))}normalizeTileURL(t,e,i){if(this._isSkuTokenExpired()&&this._createSkuToken(),t&&!o(t))return t;const r=un(t);r.path=r.path.replace(/(\.(png|jpg)\d*)(?=$)/,`${e||i&&"raster"!==r.authority&&512===i?"@2x":""}${Gi.supported?".webp":"$1"}`),"raster"===r.authority?r.path=`/${n.RASTER_URL_PREFIX}${r.path}`:"rasterarrays"===r.authority?r.path=`/${n.RASTERARRAYS_URL_PREFIX}${r.path}`:"3dtiles"===r.authority?r.path=`/${n.TILES3D_URL_PREFIX}${r.path}`:(r.path=r.path.replace(/^.+\/v4\//,"/"),r.path=`/${n.TILE_URL_VERSION}${r.path}`);const s=this._customAccessToken||function(t){for(const e of t){const t=e.match(/^access_token=(.*)$/);if(t)return t[1]}return null}(r.params)||n.ACCESS_TOKEN;return n.REQUIRE_ACCESS_TOKEN&&s&&this._skuToken&&r.params.push(`sku=${this._skuToken}`),this._makeAPIURL(r,s)}canonicalizeTileURL(t,e){const i=un(t);if(!i.path.match(/^(\/v4\/|\/(raster|rasterarrays)\/v1\/)/)||!i.path.match(/\.[\w]+$/))return t;let r="mapbox://";i.path.match(/^\/raster\/v1\//)?r+=`raster/${i.path.replace(`/${n.RASTER_URL_PREFIX}/`,"")}`:i.path.match(/^\/rasterarrays\/v1\//)?r+=`rasterarrays/${i.path.replace(`/${n.RASTERARRAYS_URL_PREFIX}/`,"")}`:r+=`tiles/${i.path.replace(`/${n.TILE_URL_VERSION}/`,"")}`;let o=i.params;return e&&(o=o.filter((t=>!t.match(/^access_token=/)))),o.length&&(r+=`?${o.join("&")}`),r}canonicalizeTileset(t,e){const i=!!e&&o(e),n=[];for(const e of t.tiles||[])r(e)?n.push(this.canonicalizeTileURL(e,i)):n.push(e);return n}_makeAPIURL(t,e){const i="See https://docs.mapbox.com/api/overview/#access-tokens-and-token-scopes",r=un(n.API_URL);if(t.protocol=r.protocol,t.authority=r.authority,"http"===t.protocol){const e=t.params.indexOf("secure");e>=0&&t.params.splice(e,1)}if("/"!==r.path&&(t.path=`${r.path}${t.path}`),!n.REQUIRE_ACCESS_TOKEN)return hn(t);if(e=e||n.ACCESS_TOKEN,!this._silenceAuthErrors){if(!e)throw new Error(`An API access token is required to use Mapbox GL. ${i}`);if("s"===e[0])throw new Error(`Use a public access token (pk.*) with Mapbox GL, not a secret access token (sk.*). ${i}`)}return t.params=t.params.filter((t=>-1===t.indexOf("access_token"))),t.params.push(`access_token=${e||""}`),hn(t)}},t.dh=function(t,e){e?Mn.add(t):Mn.delete(t)},t.di=Gi,t.dj=Tn,t.dk=En,t.dl=cn,t.dm=vn,t.dn=bn,t.dp=function(t){Mn.delete(t)},t.dq=Sn,t.dr=yn,t.ds=Qe,t.dt=e,t.du=function(t,e){Fi=t,Ni=e},t.dv=function(t,e,i=!1){if(Fa===za||Fa===Ra||Fa===Oa)throw new Error("setRTLTextPlugin cannot be called multiple times.");Na=ki.resolveURL(t),Fa=za,Ba=e,ja(),i||Za()},t.dw=Ga,t.dx=function(){ux().acquire(lx)},t.dy=function(){const t=dx;t&&(t.isPreloaded()&&1===t.numActive()?(t.release(lx),dx=null):console.warn("Could not clear WebWorkers since there are active Map instances that still reference it. The pre-warmed WebWorker pool can only be cleared when all map instances have been removed with map.remove()"))},t.dz=cx,t.e=ki,t.e0=cm,t.e1=h,t.e2=en,t.e3=function(t){let e=0;if(new Uint32Array(t,0,1)[0]!==Ax){const i=new Uint32Array(t,0,7),[,,n,r,o,s]=i;e=i.byteLength+r+o+s+o,(n!==t.byteLength||e>=t.byteLength)&&pi("Invalid b3dm header information.")}return Dx(t,e)},t.e4=function(t,e){const i=jx(t);for(const t of i){for(const e of t.meshes)Vx(e);t.lights&&(t.lightMeshIndex=t.meshes.length,t.meshes.push(Gx(t.lights,e)))}return i},t.e5=Kx,t.e6=rx,t.e7=qa,t.e8=function(t){ji(),Oi&&Oi.then((e=>{e.keys().then((i=>{for(let n=0;nt.arrayBuffer())).then((e=>Dx(e,0,t)))},t.m=class extends Uv{},t.n=Er,t.o=qn,t.p=Qg,t.q=Xs,t.r=Js,t.s=Qs,t.t=ca,t.u=al,t.v=ll,t.w=pi,t.x=pa,t.y=da,t.z=qo})),n(0,(function(t){function e(t){const e=t?t.url.toString():void 0;return e?performance.getEntriesByName(e):[]}function i(t){if("number"==typeof t||"boolean"==typeof t||"string"==typeof t||null==t)return JSON.stringify(t);if(Array.isArray(t)){let e="[";for(const n of t)e+=`${i(n)},`;return`${e}]`}let e="{";for(const n of Object.keys(t).sort())e+=`${n}:${i(t[n])},`;return`${e}}`}function n(e){let n="";for(const r of t.cE)n+=`/${i(e[r])}`;return n}class r{constructor(t){this.keyCache={},this._layers={},this._layerConfigs={},t&&this.replace(t)}replace(t,e){this._layerConfigs={},this._layers={},this.update(t,[],e)}update(e,i,r){this._options=r;for(const i of e)this._layerConfigs[i.id]=i,(this._layers[i.id]=t.cY(i,this.scope,null,this._options)).compileFilter(),this.keyCache[i.id]&&delete this.keyCache[i.id];for(const t of i)delete this.keyCache[t],delete this._layerConfigs[t],delete this._layers[t];this.familiesBySource={};const o=function(t,e){const i={};for(let r=0;rthis._layers[t.id])),i=e[0];if("none"===i.visibility)continue;const n=i.source||"";let r=this.familiesBySource[n];r||(r=this.familiesBySource[n]={});const o=i.sourceLayer||"_geojsonTileLayer";let s=r[o];s||(s=r[o]=[]),s.push(e)}}}const o=1*t.dJ;class s{constructor(e){const i={},n=[];for(const t in e){const r=e[t],s=i[t]={};for(const t in r.glyphs){const e=r.glyphs[+t];if(!e||0===e.bitmap.width||0===e.bitmap.height)continue;const i=e.metrics.localGlyph?o:1,a={x:0,y:0,w:e.bitmap.width+2*i,h:e.bitmap.height+2*i};n.push(a),s[t]=a}}const{w:r,h:s}=t.j(n),a=new t.dI({width:r||1,height:s||1});for(const n in e){const r=e[n];for(const e in r.glyphs){const s=r.glyphs[+e];if(!s||0===s.bitmap.width||0===s.bitmap.height)continue;const l=i[n][e],c=s.metrics.localGlyph?o:1;t.dI.copy(s.bitmap,a,{x:0,y:0},{x:l.x+c,y:l.y+c},s.bitmap)}}this.image=a,this.positions=i}}t.dH(s,"GlyphAtlas");class a{constructor(e){this.tileID=new t.aL(e.tileID.overscaledZ,e.tileID.wrap,e.tileID.canonical.z,e.tileID.canonical.x,e.tileID.canonical.y),this.tileZoom=e.tileZoom,this.uid=e.uid,this.zoom=e.zoom,this.lut=e.lut,this.canonical=e.tileID.canonical,this.pixelRatio=e.pixelRatio,this.tileSize=e.tileSize,this.source=e.source,this.scope=e.scope,this.overscaling=this.tileID.overscaleFactor(),this.showCollisionBoxes=e.showCollisionBoxes,this.collectResourceTiming=!!e.collectResourceTiming,this.promoteId=e.promoteId,this.isSymbolTile=e.isSymbolTile,this.tileTransform=t.dK(e.tileID.canonical,e.projection),this.projection=e.projection,this.brightness=e.brightness,this.extraShadowCaster=!!e.extraShadowCaster,this.tessellationStep=e.tessellationStep}parse(e,i,n,r,o){this.status="parsing",this.data=e,this.collisionBoxArray=new t.dL;const a=new t.dM(Object.keys(e.layers).sort()),c=new t.dN(this.tileID,this.promoteId);c.bucketLayerIDs=[];const d={},u=new t.dO(256,256),h={featureIndex:c,iconDependencies:{},patternDependencies:{},glyphDependencies:{},lineAtlas:u,availableImages:n,brightness:this.brightness},p=i.familiesBySource[this.source];for(const i in p){const r=e.layers[i];if(!r)continue;let o=!1,s=!1,u=!1;for(const t of p[i])"symbol"===t[0].type?o=!0:s=!0,t[0].is3D()&&"model"!==t[0].type&&(u=!0);if(this.extraShadowCaster&&!u)continue;if(!0===this.isSymbolTile&&!o)continue;if(!1===this.isSymbolTile&&!s)continue;1===r.version&&t.w(`Vector tile source "${this.source}" layer "${i}" does not use vector tile spec v2 and therefore may have some rendering errors.`);const f=a.encode(i),m=[];for(let t=0;t=e.maxzoom||"none"!==e.visibility&&(l(t,this.zoom,h.brightness,n),(d[e.id]=e.createBucket({index:c.bucketLayerIDs.length,layers:t,zoom:this.zoom,lut:this.lut,canonical:this.canonical,pixelRatio:this.pixelRatio,overscaling:this.overscaling,collisionBoxArray:this.collisionBoxArray,sourceLayerIndex:f,sourceID:this.source,projection:this.projection.spec,tessellationStep:this.tessellationStep})).populate(m,h,this.tileID.canonical,this.tileTransform),c.bucketLayerIDs.push(t.map((t=>t.id)))))}}let f,m,_,g;u.trim();const y={type:"maybePrepare",isSymbolTile:this.isSymbolTile,zoom:this.zoom},v=()=>{if(f)return this.status="done",o(f);if(this.extraShadowCaster)this.status="done",o(null,{buckets:t.dG(d).filter((t=>!t.isEmpty())),featureIndex:c,collisionBoxArray:null,glyphAtlasImage:null,lineAtlas:null,imageAtlas:null,brightness:h.brightness,glyphMap:null,iconMap:null,glyphPositions:null});else if(m&&_&&g){const e=new s(m),i=new t.dQ(_,g,this.lut);for(const r in d){const o=d[r];o instanceof t.dR?(l(o.layers,this.zoom,h.brightness,n),t.dS(o,m,e.positions,_,i.iconPositions,this.showCollisionBoxes,n,this.tileID.canonical,this.tileZoom,this.projection,this.brightness)):o.hasPattern&&(o instanceof t.dT||o instanceof t.dU||o instanceof t.b_)&&(l(o.layers,this.zoom,h.brightness,n),o.addFeatures(h,this.tileID.canonical,i.patternPositions,n,this.tileTransform,this.brightness))}this.status="done",o(null,{buckets:t.dG(d).filter((t=>!t.isEmpty())),featureIndex:c,collisionBoxArray:this.collisionBoxArray,glyphAtlasImage:e.image,lineAtlas:u,imageAtlas:i,brightness:h.brightness})}};if(!this.extraShadowCaster){const e=t.dP(h.glyphDependencies,(t=>Object.keys(t).map(Number)));Object.keys(e).length?r.send("getGlyphs",{uid:this.uid,stacks:e,scope:this.scope},((t,e)=>{f||(f=t,m=e,v())}),void 0,!1,y):m={};const i=Object.keys(h.iconDependencies);i.length?r.send("getImages",{icons:i,source:this.source,scope:this.scope,tileID:this.tileID,type:"icons"},((t,e)=>{f||(f=t,_=e,v())}),void 0,!1,y):_={};const n=Object.keys(h.patternDependencies);n.length?r.send("getImages",{icons:n,source:this.source,scope:this.scope,tileID:this.tileID,type:"patterns"},((t,e)=>{f||(f=t,g=e,v())}),void 0,!1,y):g={}}v()}}function l(e,i,n,r){const o=new t.X(i,{brightness:n});for(const t of e)t.recalculate(o,r)}class c extends t.E{constructor(e,i,n,r,o,s){super(),this.actor=e,this.layerIndex=i,this.availableImages=n,this.loadVectorData=o||t.ap,this.loading={},this.loaded={},this.deduped=new t.ao(e.scheduler),this.isSpriteLoaded=r,this.scheduler=e.scheduler,this.brightness=s}loadTile(i,n){const r=i.uid,o=i&&i.request,s=o&&o.collectResourceTiming,l=this.loading[r]=new a(i);l.abort=this.loadVectorData(i,((a,c)=>{const d=!this.loading[r];if(delete this.loading[r],d||a||!c)return l.status="done",d||(this.loaded[r]=l),n(a);const u=c.rawData,h={};c.expires&&(h.expires=c.expires),c.cacheControl&&(h.cacheControl=c.cacheControl),l.vectorTile=c.vectorTile||new t.dV(new t.dW(u));const p=()=>{l.parse(l.vectorTile,this.layerIndex,this.availableImages,this.actor,((i,r)=>{if(i||!r)return n(i);const a={};if(s){const t=e(o);t.length>0&&(a.resourceTiming=JSON.parse(JSON.stringify(t)))}n(null,t.W({rawTileData:u.slice(0)},r,h,a))}))};this.isSpriteLoaded?p():this.once("isSpriteLoaded",(()=>{this.scheduler?this.scheduler.add(p,{type:"parseTile",isSymbolTile:i.isSymbolTile,zoom:i.tileZoom}):p()})),this.loaded=this.loaded||{},this.loaded[r]=l}))}reloadTile(e,i){const n=this.loaded,r=e.uid;if(n&&n[r]){const o=n[r];o.showCollisionBoxes=e.showCollisionBoxes,o.projection=e.projection,o.brightness=e.brightness,o.tileTransform=t.dK(e.tileID.canonical,e.projection),o.extraShadowCaster=e.extraShadowCaster,o.lut=e.lut;const s=(t,e)=>{const n=o.reloadCallback;n&&(delete o.reloadCallback,o.parse(o.vectorTile,this.layerIndex,this.availableImages,this.actor,n)),i(t,e)};"parsing"===o.status?o.reloadCallback=s:"done"===o.status&&(o.vectorTile?o.parse(o.vectorTile,this.layerIndex,this.availableImages,this.actor,s):s())}else i(null,void 0)}abortTile(t,e){const i=t.uid,n=this.loading[i];n&&(n.abort&&n.abort(),delete this.loading[i]),e()}removeTile(t,e){const i=this.loaded,n=t.uid;i&&i[n]&&delete i[n],e()}}class d{loadTile(e,i){const{uid:n,encoding:r,rawImageData:o,padding:s}=e,a=ImageBitmap&&o instanceof ImageBitmap?this.getImageData(o,s):o;i(null,new t.dX(n,a,r,s{n(null,t)}),(t=>{n(t)}))}}const h=t.dZ.prototype.toGeoJSON;let p=class{constructor(e){this._feature=e,this.extent=t.a3,this.type=e.type,this.properties=e.tags,"id"in e&&!isNaN(e.id)&&(this.id=parseInt(e.id,10))}loadGeometry(){if(1===this._feature.type){const e=[];for(const i of this._feature.geometry)e.push([new t.P(i[0],i[1])]);return e}{const e=[];for(const i of this._feature.geometry){const n=[];for(const e of i)n.push(new t.P(e[0],e[1]));e.push(n)}return e}}toGeoJSON(t,e,i){return h.call(this,t,e,i)}},f=class{constructor(e){this.layers={_geojsonTileLayer:this},this.name="_geojsonTileLayer",this.extent=t.a3,this.length=e.length,this._features=e}feature(t){return new p(this._features[t])}};const m=64/4096;class _{constructor(){this.features=new Map}clear(){this.features.clear()}load(t=[],e){for(const i of t){const t=i.id;if(null==t)continue;let n=this.features.get(t);n&&this.updateCache(n,e),i.geometry?(n=y(i),this.updateCache(n,e),this.features.set(t,n)):this.features.delete(t),this.updateCache(n,e)}}updateCache(t,e){for(const{canonical:i,uid:n}of Object.values(e)){const{z:r,x:o,y:s}=i;g(t,Math.pow(2,r),o,s)&&delete e[n]}}getTile(t,e,i){const n=Math.pow(2,t),r=[];for(const t of this.features.values())g(t,n,e,i)&&r.push(w(t,n,e,i));return{features:r}}getFeatures(){return[...this.features.values()]}}function g({minX:t,minY:e,maxX:i,maxY:n},r,o,s){return t(o-m)/r&&n>(s-m)/r}function y(t){const{id:e,geometry:i,properties:n}=t;if(!i)return;if("GeometryCollection"===i.type)throw new Error("GeometryCollection not supported in dynamic mode.");const{type:r,coordinates:o}=i,s={id:e,type:1,geometry:[],tags:n,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0},a=s.geometry;if("Point"===r)v(o,a,s);else if("MultiPoint"===r)for(const t of o)v(t,a,s);else if("LineString"===r)s.type=2,x(o,a,s);else if("MultiLineString"===r)s.type=2,b(o,a,s);else if("Polygon"===r)s.type=3,b(o,a,s,!0);else{if("MultiPolygon"!==r)throw new Error("Input data is not a valid GeoJSON object.");s.type=3;for(const t of o)b(t,a,s,!0)}return s}function v([e,i],n,r){const o=t.aj(e);let s=t.ak(i);s=s1?1:s,n.push(o,s),r.minX=Math.min(r.minX,o),r.minY=Math.min(r.minY,s),r.maxX=Math.max(r.maxX,o),r.maxY=Math.max(r.maxY,s)}function x(t,e,i,n=!1,r=!1){const o=[];for(const e of t)v(e,o,i);e.push(o),n&&function(t,e){let i=0;for(let e=0,n=t.length,r=n-2;e0===e)for(let e=0,i=t.length;e>31}function F(t,e){for(var i=t.loadGeometry(),n=t.type,r=0,o=0,s=i.length,a=0;at},V=Math.fround||(G=new Float32Array(1),t=>(G[0]=+t,G[0]));var G;const Z=3,q=5,H=6;class W{constructor(t){this.options=Object.assign(Object.create(j),t),this.trees=new Array(this.options.maxZoom+1),this.stride=this.options.reduce?7:6,this.clusterProps=[]}load(t){const{log:e,minZoom:i,maxZoom:n}=this.options;e&&console.time("total time");const r=`prepare ${t.length} points`;e&&console.time(r),this.points=t;const o=[];for(let e=0;e=i;t--){const i=+Date.now();s=this.trees[t]=this._createTree(this._cluster(s,t)),e&&console.log("z%d: %d clusters in %dms",t,s.numItems,+Date.now()-i)}return e&&console.timeEnd("total time"),this}getClusters(t,e){let i=((t[0]+180)%360+360)%360-180;const n=Math.max(-90,Math.min(90,t[1]));let r=180===t[2]?180:((t[2]+180)%360+360)%360-180;const o=Math.max(-90,Math.min(90,t[3]));if(t[2]-t[0]>=360)i=-180,r=180;else if(i>r){const t=this.getClusters([i,n,180,o],e),s=this.getClusters([-180,n,r,o],e);return t.concat(s)}const s=this.trees[this._limitZoom(e)],a=s.range(K(i),J(o),K(r),J(n)),l=s.data,c=[];for(const t of a){const e=this.stride*t;c.push(l[e+q]>1?Y(l,e,this.clusterProps):this.points[l[e+Z]])}return c}getChildren(t){const e=this._getOriginId(t),i=this._getOriginZoom(t),n="No cluster with the specified id.",r=this.trees[i];if(!r)throw new Error(n);const o=r.data;if(e*this.stride>=o.length)throw new Error(n);const s=this.options.radius/(this.options.extent*Math.pow(2,i-1)),a=r.within(o[e*this.stride],o[e*this.stride+1],s),l=[];for(const e of a){const i=e*this.stride;o[i+4]===t&&l.push(o[i+q]>1?Y(o,i,this.clusterProps):this.points[o[i+Z]])}if(0===l.length)throw new Error(n);return l}getLeaves(t,e,i){const n=[];return this._appendLeaves(n,t,e=e||10,i=i||0,0),n}getTile(t,e,i){const n=this.trees[this._limitZoom(t)],r=Math.pow(2,t),{extent:o,radius:s}=this.options,a=s/o,l=(i-a)/r,c=(i+1+a)/r,d={features:[]};return this._addTileFeatures(n.range((e-a)/r,l,(e+1+a)/r,c),n.data,e,i,r,d),0===e&&this._addTileFeatures(n.range(1-a/r,l,1,c),n.data,r,i,r,d),e===r-1&&this._addTileFeatures(n.range(0,l,a/r,c),n.data,-1,i,r,d),d.features.length?d:null}getClusterExpansionZoom(t){let e=this._getOriginZoom(t)-1;for(;e1;let l,c,d;if(a)l=X(e,t,this.clusterProps),c=e[t],d=e[t+1];else{const i=this.points[e[t+Z]];l=i.properties;const[n,r]=i.geometry.coordinates;c=K(n),d=J(r)}const u={type:1,geometry:[[Math.round(this.options.extent*(c*r-i)),Math.round(this.options.extent*(d*r-n))]],tags:l};let h;h=a||this.options.generateId?e[t+Z]:this.points[e[t+Z]].id,void 0!==h&&(u.id=h),o.features.push(u)}}_limitZoom(t){return Math.max(this.options.minZoom,Math.min(Math.floor(+t),this.options.maxZoom+1))}_cluster(t,e){const{radius:i,extent:n,reduce:r,minPoints:o}=this.options,s=i/(n*Math.pow(2,e)),a=t.data,l=[],c=this.stride;for(let i=0;ie&&(p+=a[i+q])}if(p>h&&p>=o){let t,o=n*h,s=d*h,f=-1;const m=(i/c1)for(const t of u){const i=t*c;if(!(a[i+2]>5}_getOriginZoom(t){return(t-this.points.length)%32}_map(t,e,i){if(t[e+q]>1){const n=this.clusterProps[t[e+H]];return i?Object.assign({},n):n}const n=this.points[t[e+Z]].properties,r=this.options.map(n);return i&&r===n?Object.assign({},r):r}}function Y(t,e,i){return{type:"Feature",id:t[e+Z],properties:X(t,e,i),geometry:{type:"Point",coordinates:[(n=t[e],360*(n-.5)),Q(t[e+1])]}};var n}function X(t,e,i){const n=t[e+q],r=n>=1e4?`${Math.round(n/1e3)}k`:n>=1e3?Math.round(n/100)/10+"k":n,o=t[e+H],s=-1===o?{}:Object.assign({},i[o]);return Object.assign(s,{cluster:!0,cluster_id:t[e+Z],point_count:n,point_count_abbreviated:r})}function K(t){return t/360+.5}function J(t){const e=Math.sin(t*Math.PI/180),i=.5-.25*Math.log((1+e)/(1-e))/Math.PI;return i1?1:i}function Q(t){const e=(180-360*t)*Math.PI/180;return 360*Math.atan(Math.exp(e))/Math.PI-90}function tt(t,e,i,n){let r=n;const o=e+(i-e>>1);let s,a=i-e;const l=t[e],c=t[e+1],d=t[i],u=t[i+1];for(let n=e+3;n i[1].x&&e.x>i[1].x||t.yi[1].y&&e.y>i[1].y}function bf(t,e){return t.xe[1].x||t.ye[1].y}function wf(t,e,i){if(t.x=uo||e.x=uo||i.x=uo)return!1;const n=i.sub(e),r=n.perp(),o=t.sub(e);return(n.x*o.x+n.y*o.y)/Math.sqrt((n.x*n.x+n.y*n.y)*(o.x*o.x+o.y*o.y))>-.866&&r.x*o.x+r.y*o.y{for(const i of t)s.push({polygon:i,bounds:e})},l=Math.ceil(Math.log2(i)),c=Math.ceil(Math.log2(n)),d=l-c,u=[];for(let t=0;t0?0:1);for(let t=0;te+1?p.push({polygons:h,bounds:t,depth:e+1}):a(h,t)}if(f.length){const t=[new Ue(0===i?d:n.x,1===i?d:n.y),s];u.length>e+1?p.push({polygons:f,bounds:t,depth:e+1}):a(f,t)}}return s}(t,e,Math.ceil((o-r)/11.25),Math.ceil((s-a)/11.25),1,((t,e,r)=>{if(0===t)return.5*(e+r);{const t=Id((i.y+e/uo)/n);return(Md(.5*(Id((i.y+r/uo)/n)+t))*n-i.y)*uo}}))}function Mf(t,e,i,n,r,o){const s=Math.pow(2,n.z-r.z);for(let a=0;a1&&(s=t[++o]);const l=Math.abs(a-s.left),c=Math.abs(a-s.right),d=Math.min(l,c);let u;const h=e/i*(n+1);if(s.isDash){const t=n-Math.abs(h);u=Math.sqrt(d*d+t*t)}else u=n-Math.sqrt(d*d+h*h);this.image.data[r+a]=Math.max(0,Math.min(255,u+128))}}}addRegularDash(t,e){for(let e=t.length-1;e>=0;--e){const i=t[e],n=t[e+1];i.zeroLength?t.splice(e,1):n&&n.isDash===i.isDash&&(n.left=i.left,t.splice(e,1))}const i=t[0],n=t[t.length-1];i.isDash===n.isDash&&(i.left=n.left-this.width,n.right=i.right+this.width);const r=this.width*this.nextRow;let o=0,s=t[o];for(let i=0;i1&&(s=t[++o]);const n=Math.abs(i-s.left),a=Math.abs(i-s.right),l=Math.min(n,a);this.image.data[r+i]=Math.max(0,Math.min(255,(s.isDash?l:-l)+e+128))}}addDash(t,e){const i=this.getKey(t,e);if(this.positions[i])return this.positions[i];const n="round"===e,r=n?7:0,o=2*r+1;if(this.nextRow+o>this.height)return pi("LineAtlas out of space"),null;0===t.length&&t.push(1);let s=0;for(let e=0;et.fqid)),this.index=t.index,this.projection=t.projection,this.hasPattern=!1,this.hasZOffset=!1,this.patternFeatures=[],this.lineClipsArray=[],this.gradients={},this.layers.forEach((t=>{this.gradients[t.id]={}})),this.layoutVertexArray=new Rl,this.layoutVertexArray2=new Ol,this.patternVertexArray=new Bl,this.indexArray=new Kl,this.programConfigurations=new Yc(t.layers,{zoom:t.zoom,lut:t.lut}),this.segments=new wc,this.maxLineLength=0,this.zOffsetVertexArray=new Zl,this.stateDependentLayerIds=this.layers.filter((t=>t.isStateDependent())).map((t=>t.id)),this.tessellationStep=t.tessellationStep?t.tessellationStep:uo/64}updateFootprints(t,e){}populate(t,e,i,n){this.hasPattern=Hh("line",this.layers,e);const r=this.layers[0].layout.get("line-sort-key"),o=this.layers[0].layout.get("line-z-offset");this.hasZOffset=!o.isConstant()||!!o.constantOr(0);const s=[];for(const{feature:e,id:o,index:a,sourceLayerIndex:l}of t){const t=this.layers[0]._featureFilter.needGeometry,c=Zd(e,t);if(!this.layers[0]._featureFilter.filter(new Ha(this.zoom),c,i))continue;const d=r?r.evaluate(c,{},i):void 0,u={id:o,properties:e.properties,type:e.type,sourceLayerIndex:l,index:a,geometry:t?c.geometry:Gd(e,i,n),patterns:{},sortKey:d};s.push(u)}r&&s.sort(((t,e)=>t.sortKey-e.sortKey));const{lineAtlas:a,featureIndex:l}=e,c=this.addConstantDashes(a);for(const n of s){const{geometry:r,index:o,sourceLayerIndex:s}=n;if(c&&this.addFeatureDashes(n,a),this.hasPattern){const t=Wh("line",this.layers,n,this.zoom,e);this.patternFeatures.push(t)}else this.addFeature(n,r,o,i,a.positions,e.availableImages,e.brightness);l.insert(t[o].feature,r,o,s,this.index)}}addConstantDashes(t){let e=!1;for(const i of this.layers){const n=i.paint.get("line-dasharray").value,r=i.layout.get("line-cap").value;if("constant"!==n.kind||"constant"!==r.kind)e=!0;else{const e=r.value,i=n.value;if(!i)continue;t.addDash(i,e)}}return e}addFeatureDashes(t,e){const i=this.zoom;for(const n of this.layers){const r=n.paint.get("line-dasharray").value,o=n.layout.get("line-cap").value;if("constant"===r.kind&&"constant"===o.kind)continue;let s,a;if("constant"===r.kind){if(s=r.value,!s)continue}else s=r.evaluate({zoom:i},t);a="constant"===o.kind?o.value:o.evaluate({zoom:i},t),e.addDash(s,a),t.patterns[n.id]=e.getKey(s,a)}}update(t,e,i,n,r){const o=0!==Object.keys(t).length;o&&!this.stateDependentLayers.length||this.programConfigurations.updatePaintArrays(t,e,o?this.stateDependentLayers:this.layers,i,n,r)}addFeatures(t,e,i,n,r,o){for(const t of this.patternFeatures)this.addFeature(t,t.geometry,t.index,e,i,n,o)}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(t){this.uploaded||(0!==this.layoutVertexArray2.length&&(this.layoutVertexBuffer2=t.createVertexBuffer(this.layoutVertexArray2,zf)),0!==this.patternVertexArray.length&&(this.patternVertexBuffer=t.createVertexBuffer(this.patternVertexArray,Of)),!this.zOffsetVertexBuffer&&this.zOffsetVertexArray.length>0&&(this.zOffsetVertexBuffer=t.createVertexBuffer(this.zOffsetVertexArray,jf.members,!0)),this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,kf),this.indexBuffer=t.createIndexBuffer(this.indexArray)),this.programConfigurations.upload(t),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.zOffsetVertexBuffer&&this.zOffsetVertexBuffer.destroy(),this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy())}lineFeatureClips(t){if(t.properties&&t.properties.hasOwnProperty("mapbox_clip_start")&&t.properties.hasOwnProperty("mapbox_clip_end"))return{start:+t.properties.mapbox_clip_start,end:+t.properties.mapbox_clip_end}}addFeature(t,e,i,n,r,o,s){const a=this.layers[0].layout,l=a.get("line-join").evaluate(t,{}),c=a.get("line-cap").evaluate(t,{}),d=a.get("line-miter-limit"),u=a.get("line-round-limit");this.lineClips=this.lineFeatureClips(t);for(const i of e)this.addLine(i,t,n,l,c,d,u);this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,t,i,r,o,n,s)}addLine(t,e,i,n,r,o,s){this.distance=0,this.scaledDistance=0,this.totalDistance=0,this.lineSoFar=0,this.currentVertex=void 0;const a={zoom:this.zoom,lineProgress:void 0},l=this.layers[0].layout,c="none"===n;if(this.patternJoinNone=this.hasPattern&&c,this.segmentStart=0,this.segmentStartf32=0,this.segmentPoints=[],this.lineClips){this.lineClipsArray.push(this.lineClips);for(let e=0;e=2&&t[u-1].equals(t[u-2]);)u--;let h=0;for(;h0;if(A&&i>h){const t=m.dist(_);if(t>2*p){const e=m.sub(m.sub(_)._mult(p/t)._round());this.updateDistance(_,e),this.addCurrentVertex(e,y,0,0,f,x),_=e}}if(b&&"round"===w&&(Mo&&(w="bevel"),"bevel"===w&&(M>2&&(w="flipbevel"),M100)S=v.mult(-1);else{const t=M*y.add(v).mag()/y.sub(v).mag();S._perp()._mult(t*(I?-1:1))}this.addCurrentVertex(m,S,0,0,f,x),this.addCurrentVertex(m,S.mult(-1),0,0,f,x)}else if("bevel"===w||"fakeround"===w){const t=-Math.sqrt(M*M-1),e=I?t:0,i=I?0:t;if(_&&this.addCurrentVertex(m,y,e,i,f,x),"fakeround"===w){const t=Math.round(180*C/Math.PI/20);for(let e=1;e2*p){const e=m.add(g.sub(m)._mult(p/t)._round());this.updateDistance(m,e),this.addCurrentVertex(e,v,0,0,f,x),m=e}}}}addVerticesTo(t,e,i,n,r,o,s,a,l,c){const d=(e.w-t.w)/this.tessellationStep|0;if(d>1){this.lineSoFar=t.w;const u=(e.x-t.x)/d,h=(e.y-t.y)/d,p=(e.z-t.z)/d,f=(e.w-t.w)/d;for(let e=1;e=0&&this.e2>=0&&(this.indexArray.emplaceBack(this.e1,this.e2,c),a.primitiveLength++),o?this.e2=c:this.e1=c,null!=l&&this.zOffsetVertexArray.emplaceBack(l)}updateScaledDistance(){if(this.lineClips){const t=this.totalDistance/(this.lineClips.end-this.lineClips.start);this.scaledDistance=this.distance/this.totalDistance,this.lineSoFar=t*this.lineClips.start+this.distance}else this.lineSoFar=this.distance}updateDistance(t,e){this.distance+=t.dist(e),this.updateScaledDistance()}}function Qf(t,e,i){return t.xi||t.yi}ba(Jf,"LineBucket",{omit:["layers","patternFeatures","currentVertex","currentVertexIsOutside"]});const tm=new ol({"line-cap":new nl(sl.layout_line["line-cap"]),"line-join":new nl(sl.layout_line["line-join"]),"line-miter-limit":new il(sl.layout_line["line-miter-limit"]),"line-round-limit":new il(sl.layout_line["line-round-limit"]),"line-sort-key":new nl(sl.layout_line["line-sort-key"]),"line-z-offset":new nl(sl.layout_line["line-z-offset"]),visibility:new il(sl.layout_line.visibility)});var em={paint:new ol({"line-opacity":new nl(sl.paint_line["line-opacity"]),"line-color":new nl(sl.paint_line["line-color"]),"line-translate":new il(sl.paint_line["line-translate"]),"line-translate-anchor":new il(sl.paint_line["line-translate-anchor"]),"line-width":new nl(sl.paint_line["line-width"]),"line-gap-width":new nl(sl.paint_line["line-gap-width"]),"line-offset":new nl(sl.paint_line["line-offset"]),"line-blur":new nl(sl.paint_line["line-blur"]),"line-dasharray":new nl(sl.paint_line["line-dasharray"]),"line-pattern":new nl(sl.paint_line["line-pattern"]),"line-gradient":new rl(sl.paint_line["line-gradient"]),"line-trim-offset":new il(sl.paint_line["line-trim-offset"]),"line-trim-fade-range":new il(sl.paint_line["line-trim-fade-range"]),"line-trim-color":new il(sl.paint_line["line-trim-color"]),"line-emissive-strength":new il(sl.paint_line["line-emissive-strength"]),"line-border-width":new nl(sl.paint_line["line-border-width"]),"line-border-color":new nl(sl.paint_line["line-border-color"]),"line-occlusion-opacity":new il(sl.paint_line["line-occlusion-opacity"])}),layout:tm};function im(t,e,i){return e*(uo/(t.tileSize*Math.pow(2,i-t.tileID.overscaledZ)))}function nm(t,e){return 1/im(t,1,e.tileZoom)}function rm(t,e,i,n){return t.translatePosMatrix(n||e.tileID.projMatrix,e,i.paint.get("line-translate"),i.paint.get("line-translate-anchor"))}const om=t=>{const e=[];sm(t)&&e.push("RENDER_LINE_DASH"),t.paint.get("line-gradient")&&e.push("RENDER_LINE_GRADIENT");const i=t.paint.get("line-trim-offset");0===i[0]&&0===i[1]||e.push("RENDER_LINE_TRIM_OFFSET"),0!==t.paint.get("line-border-width").constantOr(1)&&e.push("RENDER_LINE_BORDER");const n="none"===t.layout.get("line-join").constantOr("miter"),r=!!t.paint.get("line-pattern").constantOr(1);return n&&r&&e.push("LINE_JOIN_NONE"),e};function sm(t){const e=t.paint.get("line-dasharray").value;return e.value||"constant"!==e.kind}class am{constructor(t){this._stringToNumber={},this._numberToString=[];for(let e=0;e>1,d=-7,u=i?r-1:0,h=i?-1:1,p=t[e+u];for(u+=h,o=p&(1>=-d,d+=a;d>0;o=256*o+t[e+u],u+=h,d-=8);for(s=o&(1>=-d,d+=n;d>0;s=256*s+t[e+u],u+=h,d-=8);if(0===o)o=1-c;else{if(o===l)return s?NaN:1/0*(p?-1:1);s+=Math.pow(2,n),o-=c}return(p?-1:1)*s*Math.pow(2,o-n)},write:function(t,e,i,n,r,o){var s,a,l,c=8*o-r-1,d=(1>1,h=23===r?Math.pow(2,-24)-Math.pow(2,-77):0,p=n?0:o-1,f=n?1:-1,m=e=1?h/l:h*Math.pow(2,1-u))*l>=2&&(s++,l/=2),s+u>=d?(a=0,s=d):s+u>=1?(a=(e*l-1)*Math.pow(2,r),s+=u):(a=e*Math.pow(2,u-1)*Math.pow(2,r),s=0));r>=8;t[i+p]=255&a,p+=f,a/=256,r-=8);for(s=s0;t[i+p]=255&s,p+=f,s/=256,c-=8);t[i+p-f]|=128*m}},cm=um,dm=lm;function um(t){this.buf=ArrayBuffer.isView&&ArrayBuffer.isView(t)?t:new Uint8Array(t||0),this.pos=0,this.type=0,this.length=this.buf.length}um.Varint=0,um.Fixed64=1,um.Bytes=2,um.Fixed32=5;var hm=4294967296,pm=1/hm,fm="undefined"==typeof TextDecoder?null:new TextDecoder("utf8");function mm(t){return t.type===um.Bytes?t.readVarint()+t.pos:t.pos+1}function _m(t,e,i){return i?4294967296*e+(t>>>0):4294967296*(e>>>0)+(t>>>0)}function gm(t,e,i){var n=e=t;r--)i.buf[r+n]=i.buf[r]}function ym(t,e){for(var i=0;i>>8,t[i+2]=e>>>16,t[i+3]=e>>>24}function Im(t,e){return(t[e]|t[e+1]>3,o=this.pos;this.type=7&n,t(r,e,this),this.pos===o&&this.skip(n)}return e},readMessage:function(t,e){return this.readFields(t,e,this.readVarint()+this.pos)},readFixed32:function(){var t=Cm(this.buf,this.pos);return this.pos+=4,t},readSFixed32:function(){var t=Im(this.buf,this.pos);return this.pos+=4,t},readFixed64:function(){var t=Cm(this.buf,this.pos)+Cm(this.buf,this.pos+4)*hm;return this.pos+=8,t},readSFixed64:function(){var t=Cm(this.buf,this.pos)+Im(this.buf,this.pos+4)*hm;return this.pos+=8,t},readFloat:function(){var t=dm.read(this.buf,this.pos,!0,23,4);return this.pos+=4,t},readDouble:function(){var t=dm.read(this.buf,this.pos,!0,52,8);return this.pos+=8,t},readVarint:function(t){var e,i,n=this.buf;return e=127&(i=n[this.pos++]),i>4,r=12&&fm?function(t,e,i){return fm.decode(t.subarray(e,i))}(this.buf,e,t):function(t,e,i){for(var n="",r=e;r239?4:l>223?3:l>191?2:1;if(r+d>i)break;1===d?l=55296&&c=1114112)&&(c=null)),null===c?(c=65533,d=1):c>65535&&(c-=65536,n+=String.fromCharCode(c>>>10&1023|55296),c=56320|1023&c),n+=String.fromCharCode(c),r+=d}return n}(this.buf,e,t)},readBytes:function(){var t=this.readVarint()+this.pos,e=this.buf.subarray(this.pos,t);return this.pos=t,e},readPackedVarint:function(t,e){if(this.type!==um.Bytes)return t.push(this.readVarint(e));var i=mm(this);for(t=t||[];this.pos127;);else if(e===um.Bytes)this.pos=this.readVarint()+this.pos;else if(e===um.Fixed32)this.pos+=4;else{if(e!==um.Fixed64)throw new Error("Unimplemented type: "+e);this.pos+=8}},writeTag:function(t,e){this.writeVarint(t268435455||t=0?(i=t%4294967296|0,n=t/4294967296|0):(n=~(-t/4294967296),4294967295^(i=~(-t%4294967296))?i=i+1|0:(i=0,n=n+1|0)),t>=0x10000000000000000||t>>=7,i.buf[i.pos++]=127&t|128,t>>>=7,i.buf[i.pos++]=127&t|128,t>>>=7,i.buf[i.pos++]=127&t|128,i.buf[i.pos]=127&(t>>>=7)}(i,0,e),function(t,e){var i=(7&t)>>=3)?128:0),t&&(e.buf[e.pos++]=127&t|((t>>>=7)?128:0),t&&(e.buf[e.pos++]=127&t|((t>>>=7)?128:0),t&&(e.buf[e.pos++]=127&t|((t>>>=7)?128:0),t&&(e.buf[e.pos++]=127&t|((t>>>=7)?128:0),t&&(e.buf[e.pos++]=127&t)))))}(n,e)}(t,this):(this.realloc(4),this.buf[this.pos++]=127&t|(t>127?128:0),t>>=7)|(t>127?128:0),t>>=7)|(t>127?128:0),t>>7&127))))},writeSVarint:function(t){this.writeVarint(t55295&&n56319||o+1===e.length?(t[i++]=239,t[i++]=191,t[i++]=189):r=n;continue}if(n>6|192:(n>12|224:(t[i++]=n>>18|240,t[i++]=n>>12&63|128),t[i++]=n>>6&63|128),t[i++]=63&n|128)}return i}(this.buf,t,this.pos);var i=this.pos-e;i>=128&&gm(e,i,this),this.pos=e-1,this.writeVarint(i),this.pos+=i},writeFloat:function(t){this.realloc(4),dm.write(this.buf,t,this.pos,!0,23,4),this.pos+=4},writeDouble:function(t){this.realloc(8),dm.write(this.buf,t,this.pos,!0,52,8),this.pos+=8},writeBytes:function(t){var e=t.length;this.writeVarint(e),this.realloc(e);for(var i=0;i=128&&gm(i,n,this),this.pos=i-1,this.writeVarint(n),this.pos+=n},writeMessage:function(t,e,i){this.writeTag(t,um.Bytes),this.writeRawMessage(e,i)},writePackedVarint:function(t,e){e.length&&this.writeMessage(t,ym,e)},writePackedSVarint:function(t,e){e.length&&this.writeMessage(t,vm,e)},writePackedBoolean:function(t,e){e.length&&this.writeMessage(t,wm,e)},writePackedFloat:function(t,e){e.length&&this.writeMessage(t,xm,e)},writePackedDouble:function(t,e){e.length&&this.writeMessage(t,bm,e)},writePackedFixed32:function(t,e){e.length&&this.writeMessage(t,Tm,e)},writePackedSFixed32:function(t,e){e.length&&this.writeMessage(t,Sm,e)},writePackedFixed64:function(t,e){e.length&&this.writeMessage(t,Em,e)},writePackedSFixed64:function(t,e){e.length&&this.writeMessage(t,Mm,e)},writeBytesField:function(t,e){this.writeTag(t,um.Bytes),this.writeBytes(e)},writeFixed32Field:function(t,e){this.writeTag(t,um.Fixed32),this.writeFixed32(e)},writeSFixed32Field:function(t,e){this.writeTag(t,um.Fixed32),this.writeSFixed32(e)},writeFixed64Field:function(t,e){this.writeTag(t,um.Fixed64),this.writeFixed64(e)},writeSFixed64Field:function(t,e){this.writeTag(t,um.Fixed64),this.writeSFixed64(e)},writeVarintField:function(t,e){this.writeTag(t,um.Varint),this.writeVarint(e)},writeSVarintField:function(t,e){this.writeTag(t,um.Varint),this.writeSVarint(e)},writeStringField:function(t,e){this.writeTag(t,um.Bytes),this.writeString(e)},writeFloatField:function(t,e){this.writeTag(t,um.Fixed32),this.writeFloat(e)},writeDoubleField:function(t,e){this.writeTag(t,um.Fixed64),this.writeDouble(e)},writeBooleanField:function(t,e){this.writeVarintField(t,Boolean(e))}};var Lm=h(cm);const Pm=["id","tile","layer","source","sourceLayer","state"];class $m{constructor(t,e,i,n,r){this.type="Feature",this._vectorTileFeature=t,this._z=e,this._x=i,this._y=n,this.properties=t.properties,this.id=r}get geometry(){return void 0===this._geometry&&(this._geometry=this._vectorTileFeature.toGeoJSON(this._x,this._y,this._z).geometry),this._geometry}set geometry(t){this._geometry=t}toJSON(){const t={type:"Feature",state:void 0,geometry:this.geometry,properties:this.properties};for(const e of Pm)void 0!==this[e]&&(t[e]=this[e]);return t}}class km{constructor(){this.state={},this.stateChanges={},this.deletedStates={}}updateState(t,e,i){const n=String(e);if(this.stateChanges[t]=this.stateChanges[t]||{},this.stateChanges[t][n]=this.stateChanges[t][n]||{},ei(this.stateChanges[t][n],i),null===this.deletedStates[t]){this.deletedStates[t]={};for(const e in this.state[t])e!==n&&(this.deletedStates[t][e]=null)}else if(this.deletedStates[t]&&null===this.deletedStates[t][n]){this.deletedStates[t][n]={};for(const e in this.state[t][n])i[e]||(this.deletedStates[t][n][e]=null)}else for(const e in i)this.deletedStates[t]&&this.deletedStates[t][n]&&null===this.deletedStates[t][n][e]&&delete this.deletedStates[t][n][e]}removeFeatureState(t,e,i){if(null===this.deletedStates[t])return;const n=String(e);if(this.deletedStates[t]=this.deletedStates[t]||{},i&&void 0!==e)null!==this.deletedStates[t][n]&&(this.deletedStates[t][n]=this.deletedStates[t][n]||{},this.deletedStates[t][n][i]=null);else if(void 0!==e)if(this.stateChanges[t]&&this.stateChanges[t][n])for(i in this.deletedStates[t][n]={},this.stateChanges[t][n])this.deletedStates[t][n][i]=null;else this.deletedStates[t][n]=null;else this.deletedStates[t]=null}getState(t,e){const i=String(e),n=ei({},(this.state[t]||{})[i],(this.stateChanges[t]||{})[i]);if(null===this.deletedStates[t])return{};if(this.deletedStates[t]){const i=this.deletedStates[t][e];if(null===i)return{};for(const t in i)delete n[t]}return n}initializeTileState(t,e){t.setFeatureState(this.state,e)}coalesceChanges(t,e){const i={};for(const t in this.stateChanges){this.state[t]=this.state[t]||{};const e={};for(const i in this.stateChanges[t])this.state[t][i]||(this.state[t][i]={}),ei(this.state[t][i],this.stateChanges[t][i]),e[i]=this.state[t][i];i[t]=e}for(const t in this.deletedStates){this.state[t]=this.state[t]||{};const e={};if(null===this.deletedStates[t])for(const i in this.state[t])e[i]={},this.state[t][i]={};else for(const i in this.deletedStates[t]){if(null===this.deletedStates[t][i])this.state[t][i]={};else if(this.state[t][i])for(const e of Object.keys(this.deletedStates[t][i]))delete this.state[t][i][e];e[i]=this.state[t][i]}i[t]=i[t]||{},ei(i[t],e)}if(this.stateChanges={},this.deletedStates={},0!==Object.keys(i).length)for(const n in t)t[n].setFeatureState(i,e)}}class Dm{constructor(t,e){this.tileID=t,this.x=t.canonical.x,this.y=t.canonical.y,this.z=t.canonical.z,this.grid=new va(uo,16,0),this.featureIndexArray=new yc,this.promoteId=e,this.is3DTile=!1}insert(t,e,i,n,r,o=0,s=0){const a=this.featureIndexArray.length;this.featureIndexArray.emplaceBack(i,n,r,o);const l=this.grid;for(let t=0;t=0&&n[3]>=0&&l.insert(a,n[0],n[1],n[2],n[3])}}loadVTLayers(){if(!this.vtLayers){this.vtLayers=new bp(new Lm(this.rawTileData)).layers,this.sourceLayerCoder=new am(this.vtLayers?Object.keys(this.vtLayers).sort():["_geojsonTileLayer"]),this.vtFeatures={};for(const t in this.vtLayers)this.vtFeatures[t]=[]}return this.vtLayers}query(t,e,i,n){this.loadVTLayers();const r=t.params||{},o=dl(r.filter),s=t.tileResult,a=t.transform,l=s.bufferedTilespaceBounds,c=this.grid.query(l.min.x,l.min.y,l.max.x,l.max.y,((t,e,i,n)=>ou(s.bufferedTilespaceGeometry,t,e,i,n)));c.sort(Rm);let d=null;a.elevation&&c.length>0&&(d=Xp.create(a.elevation,this.tileID));const u={};let h;for(let l=0;l(m||(m=Gd(e,this.tileID.canonical,t.tileTransform)),i.queryIntersectsFeature(s,e,n,m,this.z,t.transform,t.pixelPosMatrix,d,r))))}return u}loadMatchingFeature(t,e,i,n,r,o,s,a,l){const{featureIndex:c,bucketIndex:d,sourceLayerIndex:u,layoutVertexArrayOffset:h}=e,p=this.bucketLayerIDs[d];if(n&&!function(t,e){for(let i=0;i=0)return!0;return!1}(n,p))return;const f=this.sourceLayerCoder.decode(u),m=this.vtLayers[f].feature(c);if(i.needGeometry){const t=Zd(m,!0);if(!i.filter(new Ha(this.tileID.overscaledZ),t,this.tileID.canonical))return}else if(!i.filter(new Ha(this.tileID.overscaledZ),m))return;const _=this.getId(m,f);for(let e=0;e{const s=e instanceof el?e.get(o):null;return s&&s.evaluate?s.evaluate(i,n,r):s}))}function Rm(t,e){return e-t}ba(Dm,"FeatureIndex",{omit:["rawTileData","sourceLayerCoder"]});var Om=24;const Bm=128;function Fm(t,e){const{expression:i}=e;if("constant"===i.kind)return{kind:"constant",layoutSize:i.evaluate(new Ha(t+1))};if("source"===i.kind)return{kind:"source"};{const{zoomStops:e,interpolationType:n}=i;let r=0;for(;r{t.text=function(t,e,i){const n=e.layout.get("text-transform").evaluate(i,{});return"uppercase"===n?t=t.toLocaleUpperCase():"lowercase"===n&&(t=t.toLocaleLowerCase()),qa.applyArabicShaping&&(t=qa.applyArabicShaping(t)),t}(t.text,e,i)})),t}const Gm={"!":"︕","#":"#",$:"$","%":"%","&":"&","(":"︵",")":"︶","*":"*","+":"+",",":"︐","-":"︲",".":"・","/":"/",":":"︓",";":"︔","":"﹀","?":"︖","@":"@","[":"﹇","\\":"\","]":"﹈","^":"^",_:"︳","`":"`","{":"︷","|":"―","}":"︸","~":"~","¢":"¢","£":"£","¥":"¥","¦":"¦","¬":"¬","¯":" ̄","–":"︲","—":"︱","‘":"﹃","’":"﹄","“":"﹁","”":"﹂","…":"︙","‧":"・","₩":"₩","、":"︑","。":"︒","〈":"︿","〉":"﹀","《":"︽","》":"︾","「":"﹁","」":"﹂","『":"﹃","』":"﹄","【":"︻","】":"︼","〔":"︹","〕":"︺","〖":"︗","〗":"︘","!":"︕","(":"︵",")":"︶",",":"︐","-":"︲",".":"・",":":"︓",";":"︔","<":"︿",">":"﹀","?":"︖","[":"﹇","]":"﹈","_":"︳","{":"︷","|":"―","}":"︸","⦅":"︵","⦆":"︶","。":"︒","「":"﹁","」":"﹂","←":"↑","→":"↓"};function Zm(t){return"︶"===t||"﹈"===t||"︸"===t||"﹄"===t||"﹂"===t||"︾"===t||"︼"===t||"︺"===t||"︘"===t||"﹀"===t||"︐"===t||"︓"===t||"︔"===t||"`"===t||" ̄"===t||"︑"===t||"︒"===t}function qm(t){return"︵"===t||"﹇"===t||"︷"===t||"﹃"===t||"﹁"===t||"︽"===t||"︻"===t||"︹"===t||"︗"===t||"︿"===t}const Hm=3;function Wm(t,e,i){e.glyphs=[],1===t&&i.readMessage(Ym,e)}function Ym(t,e,i){if(3===t){const{id:t,bitmap:n,width:r,height:o,left:s,top:a,advance:l}=i.readMessage(Xm,{});e.glyphs.push({id:t,bitmap:new dh({width:r+2*Hm,height:o+2*Hm},n),metrics:{width:r,height:o,left:s,top:a,advance:l}})}else 4===t?e.ascender=i.readSVarint():5===t&&(e.descender=i.readSVarint())}function Xm(t,e,i){1===t?e.id=i.readVarint():2===t?e.bitmap=i.readBytes():3===t?e.width=i.readVarint():4===t?e.height=i.readVarint():5===t?e.left=i.readSVarint():6===t?e.top=i.readSVarint():7===t&&(e.advance=i.readVarint())}const Km=Hm,Jm={horizontal:1,vertical:2,horizontalOnly:3};class Qm{constructor(){this.scale=1,this.fontStack="",this.imageName=null}static forText(t,e){const i=new Qm;return i.scale=t||1,i.fontStack=e,i}static forImage(t){const e=new Qm;return e.imageName=t,e}}class t_{constructor(){this.text="",this.sectionIndex=[],this.sections=[],this.imageSectionID=null}static fromFeature(t,e){const i=new t_;for(let n=0;n=0&&i>=t&&i_[this.text.charCodeAt(i)];i--)e--;this.text=this.text.substring(t,e),this.sectionIndex=this.sectionIndex.slice(t,e)}substring(t,e){const i=new t_;return i.text=this.text.substring(t,e),i.sectionIndex=this.sectionIndex.slice(t,e),i.sections=this.sections,i}toString(){return this.text}getMaxScale(){return this.sectionIndex.reduce(((t,e)=>Math.max(t,this.sections[e].scale)),0)}addTextSection(t,e){this.text+=t.text,this.sections.push(Qm.forText(t.scale,t.fontStack||e));const i=this.sections.length-1;for(let e=0;e=63743?null:++this.imageSectionID:(this.imageSectionID=57344,this.imageSectionID)}}function e_(t,e,i,n,r,o,s,a,l,c,d,u,h,p,f){const m=t_.fromFeature(t,r);u===Jm.vertical&&m.verticalizePunctuation(h);let _=[];const g=function(t,e,i,n,r,o){if(!t)return[];const s=[],a=function(t,e,i,n,r,o){let s=0;for(let i=0;i=0;let c=0;for(let i=0;i0&&o>b&&(b=o)}else{const t=i[a.fontStack];if(!t)continue;t[m]&&(S=t[m]);const n=e[a.fontStack];if(!n)continue;const o=n.glyphs[m];if(!o)continue;if(v=o.metrics,M=8203!==m?Om:0,_){const t=void 0!==n.ascender?Math.abs(n.ascender):0,e=void 0!==n.descender?Math.abs(n.descender):0,i=(t+e)*g;w-i/2;){if(s--,sn;)c-=l.shift().angleDelta;if(c>r)return!1;s++,a+=e.dist(i)}return!0}function m_(t){let e=0;for(let i=0;ic){const d=(c-l)/o,u=Vn(n.x,r.x,d),h=Vn(n.y,r.y,d),p=new p_(u,h,0,r.angleTo(n),i);return!s||f_(t,p,a,s,e)?p:void 0}l+=o}}function v_(t,e,i,n,r,o,s,a,l){const c=__(n,o,s),d=g_(n,r),u=d*s,h=0===t[0].x||t[0].x===l||0===t[0].y||t[0].y===l;return e-u=0&&g=0&&y=0&&h+c=n&&c.x>=n||(s.x>=n?s=new Ue(n,s.y+(n-s.x)/(c.x-s.x)*(c.y-s.y))._round():c.x>=n&&(c=new Ue(n,s.y+(n-s.x)/(c.x-s.x)*(c.y-s.y))._round()),s.y>=r&&c.y>=r||(s.y>=r?s=new Ue(s.x+(r-s.y)/(c.y-s.y)*(c.x-s.x),r)._round():c.y>=r&&(c=new Ue(s.x+(r-s.y)/(c.y-s.y)*(c.x-s.x),r)._round()),l&&s.equals(l[l.length-1])||(l=[s],o.push(l)),l.push(c)))))}}return o}function w_(t){let e=0,i=0;for(const n of t)e+=n.w*n.h,i=Math.max(i,n.w);t.sort(((t,e)=>e.h-t.h));const n=[{x:0,y:0,w:Math.max(Math.ceil(Math.sqrt(e/.95)),i),h:1/0}];let r=0,o=0;for(const e of t)for(let t=n.length-1;t>=0;t--){const i=n[t];if(!(e.w>i.w||e.h>i.h)){if(e.x=i.x,e.y=i.y,o=Math.max(o,e.y+e.h),r=Math.max(r,e.x+e.w),e.w===i.w&&e.h===i.h){const e=n.pop();tt.hasImage(e,i))),t.dispatchRenderCallbacks(this.haveRenderCallbacks,i);for(const n in t.getUpdatedImages(i))this.patchUpdatedImage(this.iconPositions[n],t.getImage(n,i),e),this.patchUpdatedImage(this.patternPositions[n],t.getImage(n,i),e)}patchUpdatedImage(t,e,i){if(!t||!e)return;if(t.version===e.version)return;t.version=e.version;const[n,r]=t.tl,o=!!Object.keys(this.patternPositions).length;i.update(e.data,{useMipmap:o},{x:n,y:r})}}ba(S_,"ImagePosition"),ba(E_,"ImageAtlas");const M_=1e20;function C_(t,e,i,n,r,o,s,a,l){for(let c=e;c-1);l++,o[l]=a,s[l]=c,s[l+1]=M_}for(let a=0,l=0;a{let n=this.entries[t];n||(n=this.entries[t]={glyphs:{},requests:{},ranges:{},ascender:void 0,descender:void 0});let r=n.glyphs[e];if(void 0!==r)return void i(null,{stack:t,id:e,glyph:r});if(r=this._tinySDF(n,t,e),r)return n.glyphs[e]=r,void i(null,{stack:t,id:e,glyph:r});const s=Math.floor(e/256);if(256*s>65535)return void i(new Error("glyphs > 65535 not supported"));if(n.ranges[s])return void i(null,{stack:t,id:e,glyph:r});let a=n.requests[s];a||(a=n.requests[s]=[],P_.loadGlyphRange(t,s,o,this.requestManager,((t,e)=>{if(e){n.ascender=e.ascender,n.descender=e.descender;for(const t in e.glyphs)this._doesCharSupportLocalGlyph(+t)||(n.glyphs[+t]=e.glyphs[+t]);n.ranges[s]=!0}for(const i of a)i(t,e);delete n.requests[s]}))),a.push(((n,r)=>{n?i(n):r&&i(null,{stack:t,id:e,glyph:r.glyphs[e]||null})}))}),((t,e)=>{if(t)i(t);else if(e){const t={};for(const{stack:i,id:n,glyph:r}of e)void 0===t[i]&&(t[i]={}),void 0===t[i].glyphs&&(t[i].glyphs={}),t[i].glyphs[n]=r&&{id:r.id,bitmap:r.bitmap.clone(),metrics:r.metrics},t[i].ascender=this.entries[i].ascender,t[i].descender=this.entries[i].descender;i(null,t)}}))}_doesCharSupportLocalGlyph(t){return this.localGlyphMode!==L_.none&&(this.localGlyphMode===L_.all?!!this.localFontFamily:!!this.localFontFamily&&(Ma["CJK Unified Ideographs"](t)||Ma["Hangul Syllables"](t)||Ma.Hiragana(t)||Ma.Katakana(t)||Ma["CJK Symbols and Punctuation"](t)||Ma["CJK Unified Ideographs Extension A"](t)||Ma["CJK Unified Ideographs Extension B"](t)))}_tinySDF(t,e,i){const n=this.localFontFamily;if(!n||!this._doesCharSupportLocalGlyph(i))return;let r=t.tinySDF;if(!r){let i="400";/bold/i.test(e)?i="900":/medium/i.test(e)?i="500":/light/i.test(e)&&(i="200"),r=t.tinySDF=new P_.TinySDF({fontFamily:n,fontWeight:i,fontSize:24*I_,buffer:3*I_,radius:8*I_}),r.fontWeight=i}if(this.localGlyphs[r.fontWeight][i])return this.localGlyphs[r.fontWeight][i];const o=String.fromCodePoint(i),{data:s,width:a,height:l,glyphWidth:c,glyphHeight:d,glyphLeft:u,glyphTop:h,glyphAdvance:p}=r.draw(o);return this.localGlyphs[r.fontWeight][i]={id:i,bitmap:new dh({width:a,height:l},s),metrics:{width:c/I_,height:d/I_,left:u/I_,top:h/I_-27,advance:p/I_,localGlyph:!0}}}}P_.loadGlyphRange=function(t,e,i,n,r){const o=256*e,s=o+255,a=n.transformRequest(n.normalizeGlyphsURL(i).replace("{fontstack}",t).replace("{range}",`${o}-${s}`),Ki.Glyphs);en(a,((t,e)=>{if(t)r(t);else if(e){const t={},i=function(t){return new Lm(t).readFields(Wm,{})}(e);for(const e of i.glyphs)t[e.id]=e;r(null,{glyphs:t,ascender:i.ascender,descender:i.descender})}}))},P_.TinySDF=class{constructor({fontSize:t=24,buffer:e=3,radius:i=8,cutoff:n=.25,fontFamily:r="sans-serif",fontWeight:o="normal",fontStyle:s="normal"}={}){this.buffer=e,this.cutoff=n,this.radius=i;const a=this.size=t+4*e,l=this._createCanvas(a),c=this.ctx=l.getContext("2d",{willReadFrequently:!0});c.font=`${s} ${o} ${t}px ${r}`,c.textBaseline="alphabetic",c.textAlign="left",c.fillStyle="black",this.gridOuter=new Float64Array(a*a),this.gridInner=new Float64Array(a*a),this.f=new Float64Array(a),this.z=new Float64Array(a+1),this.v=new Uint16Array(a)}_createCanvas(t){const e=document.createElement("canvas");return e.width=e.height=t,e}draw(t){const{width:e,actualBoundingBoxAscent:i,actualBoundingBoxDescent:n,actualBoundingBoxLeft:r,actualBoundingBoxRight:o}=this.ctx.measureText(t),s=Math.ceil(i),a=Math.max(0,Math.min(this.size-this.buffer,Math.ceil(o-r))),l=Math.min(this.size-this.buffer,s+Math.ceil(n)),c=a+2*this.buffer,d=l+2*this.buffer,u=Math.max(c*d,0),h=new Uint8ClampedArray(u),p={data:h,width:c,height:d,glyphWidth:a,glyphHeight:l,glyphTop:s,glyphLeft:0,glyphAdvance:e};if(0===a||0===l)return p;const{ctx:f,buffer:m,gridInner:_,gridOuter:g}=this;f.clearRect(m,m,a,l),f.fillText(t,m,m+s);const y=f.getImageData(m,m,a,l);g.fill(M_,0,u),_.fill(0,0,u);for(let t=0;t0?t*t:0,_[n]=tt+e[1]-e[0],f=u.reduce(p,0),m=h.reduce(p,0),_=a-f,g=l-m;let y=0,v=f,x=0,b=m,w=0,T=_,S=0,E=g;if(o.content&&n){const t=o.content;y=D_(u,0,t[0]),x=D_(h,0,t[1]),v=D_(u,t[0],t[2]),b=D_(h,t[1],t[3]),w=t[0]-y,S=t[1]-x,T=t[2]-t[0]-v,E=t[3]-t[1]-b}const M=(n,r,a,l)=>{const u=R_(n.stretch-y,v,c,t.left),h=O_(n.fixed-w,T,n.stretch,f),p=R_(r.stretch-x,b,d,t.top),_=O_(r.fixed-S,E,r.stretch,m),g=R_(a.stretch-y,v,c,t.left),M=O_(a.fixed-w,T,a.stretch,f),C=R_(l.stretch-x,b,d,t.top),A=O_(l.fixed-S,E,l.stretch,m),I=new Ue(u,p),L=new Ue(g,p),P=new Ue(g,C),$=new Ue(u,C),k=new Ue(h/s,_/s),D=new Ue(M/s,A/s),z=e*Math.PI/180;if(z){const t=Math.sin(z),e=Math.cos(z),i=[e,-t,t,e];I._matMult(i),L._matMult(i),$._matMult(i),P._matMult(i)}const R=n.stretch+n.fixed,O=a.stretch+a.fixed,B=r.stretch+r.fixed,F=l.stretch+l.fixed,N=t.imageSecondary;return{tl:I,tr:L,bl:$,br:P,texPrimary:{x:o.paddedRect.x+$_+R,y:o.paddedRect.y+$_+B,w:O-R,h:F-B},texSecondary:N?{x:N.paddedRect.x+$_+R,y:N.paddedRect.y+$_+B,w:O-R,h:F-B}:void 0,writingMode:void 0,glyphOffset:[0,0],sectionIndex:0,pixelOffsetTL:k,pixelOffsetBR:D,minFontScaleX:T/s/c,minFontScaleY:E/s/d,isSDF:i}};if(n&&(o.stretchX||o.stretchY)){const t=z_(u,_,f),e=z_(h,g,m);for(let i=0;io)&&(o=e.x),(!t||e.y>s)&&(s=e.y)}const l=Math.min(o-n,s-r);let c=l/2;const d=new co([],N_);if(0===l)return new Ue(n,r);for(let e=n;eu.d||!u.d)&&(u=n,i&&console.log("found best %d after %d probes",Math.round(1e4*n.d)/1e4,h)),n.max-u.dt.y!=a.y>t.y&&t.x18&&P>2&&(P>>=1),Math.max(uo/(512*P),1)*_.get("symbol-spacing")),S=_.get("text-padding")*t.tilePixelRatio,E=_.get("icon-padding")*t.tilePixelRatio,M=Ge(_.get("text-max-angle")),C="map"===_.get("text-rotation-alignment")&&"point"!==_.get("symbol-placement"),A="map"===_.get("icon-rotation-alignment")&&"point"!==_.get("symbol-placement"),I=_.get("symbol-placement"),L=T/2;var P;const $=_.get("icon-text-fit").evaluate(e,{},u),k=_.get("icon-text-fit-padding").evaluate(e,{},u),D="none"!==$;let z;!1===t.hasAnyIconTextFit&&D&&(t.hasAnyIconTextFit=!0),n&&D&&(t.allowVerticalPlacement&&i.vertical&&(z=h_(n,i.vertical,$,k,g,b)),y&&(n=h_(n,y,$,k,g,b)));const R=(s,a,m)=>{if(a.x=uo||a.y=uo)return;let _=null;if(v){const{x:t,y:e,z:i}=h.projectTilePoint(a.x,a.y,m);_={anchor:new p_(t,e,i,0,void 0),up:h.upVector(m,a.x,a.y)}}!function(t,e,i,n,r,o,s,a,l,c,d,u,h,p,f,m,_,g,y,v,x,b,w,T,S,E,M){const C=t.addToLineVertexArray(e,n);let A,I,L,P,$,k,D,z=0,R=0,O=0,B=0,F=-1,N=-1;const U={};let j=Ln("");const V=i?i.anchor:e,G="none"!==l.layout.get("icon-text-fit").evaluate(x,{},S);let Z=0,q=0;if(void 0===l._unevaluatedLayout.getValue("text-radial-offset")?[Z,q]=l.layout.get("text-offset").evaluate(x,{},S).map((t=>t*Om)):(Z=l.layout.get("text-radial-offset").evaluate(x,{},S)*Om,q=j_),t.allowVerticalPlacement&&r.vertical){const t=r.vertical;if(f)k=J_(t),a&&(D=J_(a));else{const i=l.layout.get("text-rotate").evaluate(x,{},S)+90;L=K_(c,V,e,d,u,h,t,p,i,m),a&&(P=K_(c,V,e,d,u,h,a,g,i))}}if(o){const n=l.layout.get("icon-rotate").evaluate(x,{},S),r=k_(o,n,w,G),s=a?k_(a,n,w,G):void 0;I=K_(c,V,e,d,u,h,o,g,n),z=4*r.length;const p=t.iconSizeData;let f=null;"source"===p.kind?(f=[Bm*l.layout.get("icon-size").evaluate(x,{},S)],f[0]>W_&&pi(`${t.layerIds[0]}: Value for "icon-size" is >= ${H_}. Reduce your "icon-size".`)):"composite"===p.kind&&(f=[Bm*b.compositeIconSizes[0].evaluate(x,{},S),Bm*b.compositeIconSizes[1].evaluate(x,{},S)],(f[0]>W_||f[1]>W_)&&pi(`${t.layerIds[0]}: Value for "icon-size" is >= ${H_}. Reduce your "icon-size".`)),t.addSymbols(t.icon,r,f,v,y,x,!1,i,e,C.lineStartIndex,C.lineLength,-1,T,S,E,M),F=t.icon.placedSymbolArray.length-1,s&&(R=4*s.length,t.addSymbols(t.icon,s,f,v,y,x,Jm.vertical,i,e,C.lineStartIndex,C.lineLength,-1,T,S,E,M),N=t.icon.placedSymbolArray.length-1)}for(const n in r.horizontal){const o=r.horizontal[n];A||(j=Ln(o.text),f?$=J_(o):A=K_(c,V,e,d,u,h,o,p,l.layout.get("text-rotate").evaluate(x,{},S),m));const a=1===o.positionedLines.length;if(O+=Y_(t,i,e,o,s,l,f,x,m,C,r.vertical?Jm.horizontal:Jm.horizontalOnly,a?Object.keys(r.horizontal):[n],U,F,b,T,S,E),a)break}r.vertical&&(B+=Y_(t,i,e,r.vertical,s,l,f,x,m,C,Jm.vertical,["vertical"],U,N,b,T,S,E));let H=-1;const W=(t,e)=>t?Math.max(t,e):e;H=W($,H),H=W(k,H),H=W(D,H);const Y=H>-1?1:0;t.glyphOffsetArray.length>=65535&&pi("Too many glyphs being rendered in a tile. See https://github.com/mapbox/mapbox-gl-js/issues/2907"),void 0!==x.sortKey&&t.addToSortKeyRanges(t.symbolInstances.length,x.sortKey),t.symbolInstances.emplaceBack(e.x,e.y,V.x,V.y,V.z,U.right>=0?U.right:-1,U.center>=0?U.center:-1,U.left>=0?U.left:-1,U.vertical>=0?U.vertical:-1,F,N,j,void 0!==A?A:t.collisionBoxArray.length,void 0!==A?A+1:t.collisionBoxArray.length,void 0!==L?L:t.collisionBoxArray.length,void 0!==L?L+1:t.collisionBoxArray.length,void 0!==I?I:t.collisionBoxArray.length,void 0!==I?I+1:t.collisionBoxArray.length,P||t.collisionBoxArray.length,P?P+1:t.collisionBoxArray.length,d,O,B,z,R,Y,0,Z,q,H,0,1,1,G?1:0)}(t,a,_,s,i,n,r,z,t.layers[0],t.collisionBoxArray,e.index,e.sourceLayerIndex,t.index,S,C,l,0,E,A,g,e,o,c,d,u,p,f)};if("line"===I)for(const r of b_(e.geometry,0,0,uo,uo)){const e=v_(r,T,M,i.vertical||y,n,x,w,t.overscaling,uo);for(const i of e)y&&Q_(t,y.text,L,i)||R(r,i,u)}else if("line-center"===I){for(const t of e.geometry)if(t.length>1){const e=y_(t,M,i.vertical||y,n,x,w);e&&R(t,e,u)}}else if("Polygon"===e.type)for(const t of Zh(e.geometry,0)){const e=F_(t,16);R(t[0],new p_(e.x,e.y,0,0,void 0),u)}else if("LineString"===e.type)for(const t of e.geometry)R(t,new p_(t[0].x,t[0].y,0,0,void 0),u);else if("Point"===e.type)for(const t of e.geometry)for(const e of t)R([e],new p_(e.x,e.y,0,0,void 0),u)}const H_=255,W_=H_*Bm;function Y_(t,e,i,n,r,o,s,a,l,c,d,u,h,p,f,m,_,g){const y=function(t,e,i,n,r,o,s,a){const l=[];if(0===e.positionedLines.length)return l;const c=n.layout.get("text-rotate").evaluate(o,{})*Math.PI/180,d=function(t){const e=t[0],i=t[1],n=e*i;return n>0?[e,-i]:nW_&&pi(`${t.layerIds[0]}: Value for "text-size" is >= ${H_}. Reduce your "text-size".`)):"composite"===v.kind&&(x=[Bm*f.compositeTextSizes[0].evaluate(a,{},_),Bm*f.compositeTextSizes[1].evaluate(a,{},_)],(x[0]>W_||x[1]>W_)&&pi(`${t.layerIds[0]}: Value for "text-size" is >= ${H_}. Reduce your "text-size".`)),t.addSymbols(t.text,y,x,l,s,a,d,e,i,c.lineStartIndex,c.lineLength,p,m,_,g,!1);for(const e of u)h[e]=t.text.placedSymbolArray.length-1;return 4*y.length}function X_(t){for(const e in t)return t[e];return null}function K_(t,e,i,n,r,o,s,a,l,c){let d=s.top,u=s.bottom,h=s.left,p=s.right;const f=s.collisionPadding;if(f&&(h-=f[0],d-=f[1],p+=f[2],u+=f[3]),l){const t=new Ue(h,d),e=new Ue(p,d),i=new Ue(h,u),n=new Ue(p,u),r=Ge(l);let o=new Ue(0,0);c&&(o=new Ue(c[0],c[1])),t._rotateAround(r,o),e._rotateAround(r,o),i._rotateAround(r,o),n._rotateAround(r,o),h=Math.min(t.x,e.x,i.x,n.x),p=Math.max(t.x,e.x,i.x,n.x),d=Math.min(t.y,e.y,i.y,n.y),u=Math.max(t.y,e.y,i.y,n.y)}return t.emplaceBack(e.x,e.y,e.z,i.x,i.y,h,d,p,u,a,n,r,o),t.length-1}function J_(t){t.collisionPadding&&(t.top-=t.collisionPadding[1],t.bottom+=t.collisionPadding[3]);const e=t.bottom-t.top;return e>0?Math.max(10,e):null}function Q_(t,e,i,n){const r=t.compareText;if(e in r){const t=r[e];for(let e=t.length-1;e>=0;e--)if(n.dist(t[e])v&&(x(t,c,n,r,a,l),x(c,i,a,l,o,s))}x(u,h,n,o,r,o),x(h,p,r,o,r,s),x(p,f,r,s,n,s),x(f,u,n,s,n,o),m-=v,_-=v,g+=v,y+=v;const b=1/Math.max(g-m,y-_);return{scale:b,x:m*b,y:_*b,x2:g*b,y2:y*b,projection:e}}function ig(t,{x:e,y:i},n=0){return new Ue(((e-n)*t.scale-t.x)*uo,(i*t.scale-t.y)*uo)}const ng=t.ad.identity(new Float32Array(16));class rg{constructor(t){this.spec=t,this.name=t.name,this.wrap=!1,this.requiresDraping=!1,this.supportsWorldCopies=!1,this.supportsTerrain=!1,this.supportsFog=!1,this.supportsFreeCamera=!1,this.zAxisUnit="meters",this.isReprojectedInTileSpace=!0,this.unsupportedLayers=["custom"],this.center=[0,0],this.range=[3.5,7]}project(t,e){return{x:0,y:0,z:0}}unproject(t,e){return new pd(0,0)}projectTilePoint(t,e,i){return{x:t,y:e,z:0}}locationPoint(t,e,i=!0){return t._coordinatePoint(t.locationCoordinate(e),i)}pixelsPerMeter(t,e){return Cd(1,t)*e}pixelSpaceConversion(t,e,i){return 1}farthestPixelDistance(t){return tg(t,t.pixelsPerMeter)}pointCoordinate(t,e,i,n){const r=t.horizonLineFromTop(!1),o=new Ue(e,Math.max(r,i));return t.rayIntersectionCoordinate(t.pointRayIntersection(o,n))}pointCoordinate3D(t,e,i){const n=new Ue(e,i);if(t.elevation)return t.elevation.pointCoordinate(n);{const e=this.pointCoordinate(t,n.x,n.y,0);return[e.x,e.y,e.z]}}isPointAboveHorizon(t,e){if(t.elevation&&t.elevation.visibleDemTiles.length)return!this.pointCoordinate3D(t,e.x,e.y);const i=t.horizonLineFromTop();return e.y0?epg-i&&(e=pg-i);const o=r/Math.pow(fg(e),n);let s=o*Math.sin(n*t),a=r-o*Math.cos(n*t);return s=.5*(s/Math.PI+.5),a=.5*(a/Math.PI+.5),{x:s,y:this.southernCenter?a:1-a,z:0}}unproject(t,e){t=(2*t-.5)*Math.PI,this.southernCenter&&(e=1-e),e=(2*(1-e)-.5)*Math.PI;const{n:i,f:n}=this,r=n-e,o=Math.sign(r),s=Math.sign(i)*Math.sqrt(t*t+r*r);let a=Math.atan2(t,Math.abs(r))*o;r*i1e-6&&--n>0);o=i*i;const s=Xe(Ze(t/(.8707+o*(o*(o*o*o*(.003971-.001529*o)-.013791)-.131979))),-180,180),a=Ze(i);return new pd(s,a)}}const vg=Ge(Pd);class xg extends rg{project(t,e){e=Ge(e),t=Ge(t);const i=Math.cos(e),n=2/Math.PI,r=Math.acos(i*Math.cos(t/2)),o=Math.sin(r)/r,s=.5*(t*n+2*i*Math.sin(t/2)/o)||0,a=.5*(e+Math.sin(e)/o)||0;return{x:.5*(s/Math.PI+.5),y:1-.5*(a/Math.PI+1),z:0}}unproject(t,e){let i=t=(2*t-.5)*Math.PI,n=e=(2*(1-e)-1)*Math.PI,r=25;const o=1e-6;let s=0,a=0;do{const r=Math.cos(n),o=Math.sin(n),l=2*o*r,c=o*o,d=r*r,u=Math.cos(i/2),h=Math.sin(i/2),p=2*u*h,f=h*h,m=1-d*u*u,_=m?1/m:0,g=m?Math.acos(r*u)*Math.sqrt(1/m):0,y=.5*(2*g*r*h+2*i/Math.PI)-t,v=.5*(g*o+n)-e,x=.5*_*(d*f+g*r*u*c)+1/Math.PI,b=_*(p*l/4-g*o*h),w=.125*_*(l*h-g*o*d*p),T=.5*_*(c*u+g*f*r)+.5,S=b*w-T*x;s=(v*b-y*T)/S,a=(y*w-v*x)/S,i=Xe(i-s,-Math.PI,Math.PI),n=Xe(n-a,-vg,vg)}while((Math.abs(s)>o||Math.abs(a)>o)&&--r>0);return new pd(Ze(i),Ze(n))}}class bg extends rg{constructor(t){super(t),this.center=t.center||[0,0],this.parallels=t.parallels||[0,0],this.cosPhi=Math.max(.01,Math.cos(Ge(this.parallels[0]))),this.scale=1/(2*Math.max(Math.PI*this.cosPhi,1/this.cosPhi)),this.wrap=!0,this.supportsWorldCopies=!0}project(t,e){const{scale:i,cosPhi:n}=this;return{x:Ge(t)*n*i+.5,y:-Math.sin(Ge(e))/n*i+.5,z:0}}unproject(t,e){const{scale:i,cosPhi:n}=this,r=-(e-.5)/i,o=Xe(Ze((t-.5)/i)/n,-180,180),s=Math.asin(Xe(r*n,-1,1)),a=Xe(Ze(s),-Pd,Pd);return new pd(o,a)}}class wg extends _g{constructor(t){super(t),this.requiresDraping=!0,this.supportsWorldCopies=!1,this.supportsFog=!0,this.zAxisUnit="pixels",this.unsupportedLayers=["debug"],this.range=[3,5]}projectTilePoint(e,i,n){const r=Fu(e,i,n),o=ju($u(n));return t._.transformMat4(r,r,o),{x:r[0],y:r[1],z:r[2]}}locationPoint(e,i){const n=dd(i.lat,i.lng),r=t._.normalize([],n),o=e.elevation?e.elevation.getAtPointOrZero(e.locationCoordinate(i),e._centerAltitude):e._centerAltitude,s=Cd(1,0)*uo*o;t._.scaleAndAdd(n,n,r,s);const a=t.ad.identity(new Float64Array(16));return t.ad.multiply(a,e.pixelMatrix,e.globeMatrix),t._.transformMat4(n,n,a),new Ue(n[0],n[1])}pixelsPerMeter(t,e){return Cd(1,0)*e}pixelSpaceConversion(t,e,i){const n=Cd(1,t)*e,r=Vn(Cd(1,45)*e,n,i);return this.pixelsPerMeter(t,e)/r}createTileMatrix(e,i,n){const r=Vu($u(n.canonical));return t.ad.multiply(new Float64Array(16),e.globeMatrix,r)}createInversionMatrix(e,i){const{center:n}=e,r=ju($u(i));return t.ad.rotateY(r,r,Ge(n.lng)),t.ad.rotateX(r,r,Ge(n.lat)),t.ad.scale(r,r,[e._pixelsPerMercatorPixel,e._pixelsPerMercatorPixel,1]),Float32Array.from(r)}pointCoordinate(t,e,i,n){return Iu(t,e,i,!0)||new Rd(0,0)}pointCoordinate3D(t,e,i){const n=this.pointCoordinate(t,e,i,0);return[n.x,n.y,n.z]}isPointAboveHorizon(t,e){return!Iu(t,e.x,e.y,!1)}farthestPixelDistance(e){const i=function(e,i){const n=e.cameraToCenterDistance,r=e._centerAltitude*i,o=e._camera,s=e._camera.forward(),a=t._.add([],t._.scale([],s,-n),[0,0,r]),l=e.worldSize/(2*Math.PI),c=[0,0,-l],d=e.width/e.height,u=Math.tan(e.fovAboveCenter),h=t._.scale([],o.up(),u),p=t._.scale([],o.right(),u*d),f=t._.normalize([],t._.add([],t._.add([],s,h),p)),m=[];let _;if(new mu(a,f).closestPointOnSphere(c,l,m)){const i=t._.add([],m,c),n=t._.sub([],i,a);_=Math.cos(e.fovAboveCenter)*t._.length(n)}else{const e=t._.sub([],a,c),i=t._.sub([],c,a);t._.normalize(i,i);const n=t._.length(e)-l;_=Math.sqrt(n*(n+2*l));const r=Math.acos(_/(l+n))-Math.acos(t._.dot(s,i));_*=Math.cos(r)}return 1.01*_}(e,this.pixelsPerMeter(e.center.lat,e.worldSize)),n=Hu(e.zoom);if(n>0){const t=tg(e,Cd(1,e.center.lat)*e.worldSize),r=e.worldSize/(2*Math.PI),o=Math.max(e.width,e.height)/e.worldSize*Math.PI;return Vn(i,t+r*(1-Math.cos(o)),Math.pow(n,10))}return i}upVector(t,e,i){return Fu(e,i,t,1)}upVectorScale(t){return{metersToTile:Cu(Nu($u(t)))}}}function Tg(t){const e=t.parallels,i=!!e&&Math.abs(e[0]+e[1])0&&(this.iconTransitioningVertexBuffer=t.createVertexBuffer(this.iconTransitioningVertexArray,Vf.members,!0)),this.globeExtVertexArray.length>0&&(this.globeExtVertexBuffer=t.createVertexBuffer(this.globeExtVertexArray,Ff.members,!0)),!this.zOffsetVertexBuffer&&(this.zOffsetVertexArray.length>0||r)&&(this.zOffsetVertexBuffer=t.createVertexBuffer(this.zOffsetVertexArray,jf.members,!0)),this.opacityVertexBuffer.itemSize=1),(i||n)&&this.programConfigurations.upload(t))}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy(),this.dynamicLayoutVertexBuffer.destroy(),this.opacityVertexBuffer.destroy(),this.occlusionQueryOpacityVertexBuffer.destroy(),this.iconTransitioningVertexBuffer&&this.iconTransitioningVertexBuffer.destroy(),this.globeExtVertexBuffer&&this.globeExtVertexBuffer.destroy(),this.zOffsetVertexBuffer&&this.zOffsetVertexBuffer.destroy())}}ba(Ng,"SymbolBuffers");class Ug{constructor(t,e,i){this.layoutVertexArray=new t,this.layoutAttributes=e,this.indexArray=new i,this.segments=new wc,this.collisionVertexArray=new Xl,this.collisionVertexArrayExt=new Ol}upload(t){this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,this.layoutAttributes),this.indexBuffer=t.createIndexBuffer(this.indexArray),this.collisionVertexBuffer=t.createVertexBuffer(this.collisionVertexArray,Gf.members,!0),this.collisionVertexBufferExt=t.createVertexBuffer(this.collisionVertexArrayExt,Zf.members,!0)}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.segments.destroy(),this.collisionVertexBuffer.destroy(),this.collisionVertexBufferExt.destroy())}}ba(Ug,"CollisionBuffers");class jg{constructor(e){this.queries=new Map,this.collisionBoxArray=e.collisionBoxArray,this.zoom=e.zoom,this.lut=e.lut,this.overscaling=e.overscaling,this.layers=e.layers,this.layerIds=this.layers.map((t=>t.fqid)),this.index=e.index,this.pixelRatio=e.pixelRatio,this.sourceLayerIndex=e.sourceLayerIndex,this.hasPattern=!1,this.hasRTLText=!1,this.fullyClipped=!1,this.hasAnyIconTextFit=!1,this.sortKeyRanges=[],this.collisionCircleArray=[],this.placementInvProjMatrix=t.ad.identity([]),this.placementViewportMatrix=t.ad.identity([]);const i=this.layers[0]._unevaluatedLayout._values;this.textSizeData=Fm(this.zoom,i["text-size"]),this.iconSizeData=Fm(this.zoom,i["icon-size"]);const n=this.layers[0].layout,r=n.get("symbol-sort-key"),o=n.get("symbol-z-order");this.canOverlap=n.get("text-allow-overlap")||n.get("icon-allow-overlap")||n.get("text-ignore-placement")||n.get("icon-ignore-placement"),this.sortFeaturesByKey="viewport-y"!==o&&void 0!==r.constantOr(1),this.sortFeaturesByY=("viewport-y"===o||"auto"===o&&!this.sortFeaturesByKey)&&this.canOverlap,this.writingModes=n.get("text-writing-mode").map((t=>Jm[t])),this.stateDependentLayerIds=this.layers.filter((t=>t.isStateDependent())).map((t=>t.id)),this.sourceID=e.sourceID,this.projection=e.projection,this.hasAnyZOffset=!1,this.zOffsetSortDirty=!1,this.zOffsetBuffersNeedUpload=n.get("symbol-z-elevate"),this.activeReplacements=[],this.replacementUpdateTime=0}createArrays(){this.text=new Ng(new Yc(this.layers,{zoom:this.zoom,lut:this.lut},(t=>/^text/.test(t)))),this.icon=new Ng(new Yc(this.layers,{zoom:this.zoom,lut:this.lut},(t=>/^icon/.test(t)))),this.glyphOffsetArray=new mc,this.lineVertexArray=new _c,this.symbolInstances=new fc}calculateGlyphDependencies(t,e,i,n,r){for(let i=0;i0)&&("constant"!==l.value.kind||l.value.value.length>0),h="constant"!==d.value.kind||!!d.value.value||Object.keys(d.parameters).length>0,p=s.get("symbol-sort-key");if(this.features=[],!u&&!h)return;const f=i.iconDependencies,m=i.glyphDependencies,_=i.availableImages,g=new Ha(this.zoom);for(const{feature:i,id:c,index:d,sourceLayerIndex:y}of e){const e=o._featureFilter.needGeometry,v=Zd(i,e);if(!o._featureFilter.filter(g,v,n))continue;if(e||(v.geometry=Gd(i,n,r)),a&&1!==i.type&&n.z{const o=Fu(e.x,e.y,n,1),s=Fu(r.x,r.y,n,1);return t._.dot(o,s)=0;for(const i of x.sections)if(i.image)f[i.image.namePrimary]=!0;else{const n=Ca(x.toString()),r=i.fontStack||t,o=m[r]=m[r]||{};this.calculateGlyphDependencies(i.text,o,e,this.allowVerticalPlacement,n)}}}"line"===s.get("symbol-placement")&&(this.features=function(t){const e={},i={},n=[];let r=0;function o(e){n.push(t[e]),r++}function s(t,e,r){const o=i[t];return delete i[t],i[e]=o,n[o].geometry[0].pop(),n[o].geometry[0]=n[o].geometry[0].concat(r[0]),o}function a(t,i,r){const o=e[i];return delete e[i],e[t]=o,n[o].geometry[0].shift(),n[o].geometry[0]=r[0].concat(n[o].geometry[0]),o}function l(t,e,i){const n=i?e[0][e[0].length-1]:e[0][0];return`${t}:${n.x}:${n.y}`}for(let c=0;ct.geometry))}(this.features)),this.sortFeaturesByKey&&this.features.sort(((t,e)=>t.sortKey-e.sortKey))}update(t,e,i,n,r){const o=0!==Object.keys(t).length;if(o&&!this.stateDependentLayers.length)return;const s=o?this.stateDependentLayers:this.layers;this.text.programConfigurations.updatePaintArrays(t,e,s,i,n,r),this.icon.programConfigurations.updatePaintArrays(t,e,s,i,n,r)}updateOcclusionOpacities(t,e,i){if(!e.useOcclusionQueries)return!1;const n=this;if("globe"===n.projection.name)return!1;let r=!1;n.hasTextData()&&(r=r||0!==n.text.occlusionQueryOpacityVertexArray.length),n.hasIconData()&&(r=r||0!==n.icon.occlusionQueryOpacityVertexArray.length);const o=n.layers[0].paint,s=o.get("icon-occlusion-opacity").constantOr(0),a=o.get("text-occlusion-opacity").constantOr(0);if(!n.layers[0].hasInitialOcclusionOpacityProperties||1===s&&1===a)return!1;let l=!r;for(let t=0;t.5?1:-1)*e.fadeSpeed*i*.001,r.occlusionOpacity=Xe(r.occlusionOpacity,0,1),l=l||r.occlusionOpacity!==o}if(!l)return!1;let c=0,d=0;const u=(t,e,i,n)=>{let r=0,o=0;i?(r=d,d+=n,o=d):(r=c,c+=n,o=c),o>e.occlusionQueryOpacityVertexArray.length&&e.occlusionQueryOpacityVertexArray.resize(o);const s=t.occlusionOpacity;for(let t=0;t0;if((i>0||r>0)&&(u(e,n.text,!1,i),u(e,n.text,!1,r)),s){const{placedIconSymbolIndex:t,verticalPlacedIconSymbolIndex:i}=e;t>=0&&u(e,n.icon,!0,o),i>=0&&u(e,n.icon,!0,e.numVerticalIconVertices)}}return n.hasTextData()&&n.text.occlusionQueryOpacityVertexBuffer&&(n.text.occlusionQueryOpacityVertexBuffer.length{i+=e,i>t.length&&t.resize(i);for(let r=-e;r{n+=e,n>t.length&&t.resize(n);for(let r=-e;r0;if((r>0||o>0)&&(t(this.text.zOffsetVertexArray,r,a),t(this.text.zOffsetVertexArray,o,a)),l){const{placedIconSymbolIndex:t,verticalPlacedIconSymbolIndex:i}=n;t>=0&&e(this.icon.zOffsetVertexArray,s,a),i>=0&&e(this.icon.zOffsetVertexArray,n.numVerticalIconVertices,a)}}this.text.zOffsetVertexBuffer&&this.text.zOffsetVertexBuffer.updateData(this.text.zOffsetVertexArray),this.icon.zOffsetVertexBuffer&&this.icon.zOffsetVertexBuffer.updateData(this.icon.zOffsetVertexArray)}isEmpty(){return 0===this.symbolInstances.length&&!this.hasRTLText}uploadPending(){return!this.uploaded||this.text.programConfigurations.needsUpload||this.icon.programConfigurations.needsUpload}upload(t){!this.uploaded&&this.hasDebugData()&&(this.textCollisionBox.upload(t),this.iconCollisionBox.upload(t)),this.text.upload(t,this.sortFeaturesByY,!this.uploaded,this.text.programConfigurations.needsUpload,this.zOffsetBuffersNeedUpload),this.icon.upload(t,this.sortFeaturesByY,!this.uploaded,this.icon.programConfigurations.needsUpload,this.zOffsetBuffersNeedUpload),this.uploaded=!0}destroyDebugData(){this.textCollisionBox.destroy(),this.iconCollisionBox.destroy()}getProjection(){return this.projectionInstance||(this.projectionInstance=Tg(this.projection)),this.projectionInstance}destroy(){this.text.destroy(),this.icon.destroy(),this.hasDebugData()&&this.destroyDebugData();for(const t of this.queries.values())t.destroy()}addToLineVertexArray(t,e){const i=this.lineVertexArray.length;if(void 0!==t.segment)for(const{x:t,y:i}of e)this.lineVertexArray.emplaceBack(t,i);return{lineStartIndex:i,lineLength:this.lineVertexArray.length-i}}addSymbols(t,e,i,n,r,o,s,a,l,c,d,u,h,p,f,m){const _=t.indexArray,g=t.layoutVertexArray,y=t.globeExtVertexArray,v=t.segments.prepareSegment(4*e.length,g,_,this.canOverlap?o.sortKey:void 0),x=this.glyphOffsetArray.length,b=v.vertexLength,w=this.allowVerticalPlacement&&s===Jm.vertical?Math.PI/2:0,T=o.text&&o.text.sections;for(let n=0;n=0?e.rightJustifiedTextSymbolIndex:e.centerJustifiedTextSymbolIndex>=0?e.centerJustifiedTextSymbolIndex:e.leftJustifiedTextSymbolIndex>=0?e.leftJustifiedTextSymbolIndex:e.verticalPlacedTextSymbolIndex>=0?e.verticalPlacedTextSymbolIndex:n),o=Nm(this.textSizeData,t,r)/Om;return this.tilePixelRatio*o}getSymbolInstanceIconSize(t,e,i){const n=this.icon.placedSymbolArray.get(i),r=Nm(this.iconSizeData,t,n);return this.tilePixelRatio*r}_commitDebugCollisionVertexUpdate(t,e,i,n){t.emplaceBack(e,-i,-i,n),t.emplaceBack(e,i,-i,n),t.emplaceBack(e,i,i,n),t.emplaceBack(e,-i,i,n)}_updateTextDebugCollisionBoxes(t,e,i,n,r,o){for(let s=n;s0}hasIconData(){return this.icon.segments.get().length>0}hasDebugData(){return this.textCollisionBox&&this.iconCollisionBox}hasTextCollisionBoxData(){return this.hasDebugData()&&this.textCollisionBox.segments.get().length>0}hasIconCollisionBoxData(){return this.hasDebugData()&&this.iconCollisionBox.segments.get().length>0}hasIconTextFit(){return this.hasAnyIconTextFit}addIndicesForPlacedSymbol(t,e){const i=t.placedSymbolArray.get(e),n=i.vertexStartIndex+4*i.numGlyphs;for(let e=i.vertexStartIndex;en[t]-n[e]||r[e]-r[t])),o}getSortedIndexesByZOffset(){if(!this.zOffsetSortDirty)return this.symbolInstanceIndexesSortedZOffset;if(!this.symbolInstanceIndexesSortedZOffset){this.symbolInstanceIndexesSortedZOffset=[];for(let t=0;tthis.symbolInstances.get(e).zOffset-this.symbolInstances.get(t).zOffset))}addToSortKeyRanges(t,e){const i=this.sortKeyRanges[this.sortKeyRanges.length-1];i&&i.sortKey===e?i.symbolInstanceEnd=t+1:this.sortKeyRanges.push({sortKey:e,symbolInstanceStart:t,symbolInstanceEnd:t+1})}sortFeatures(t){if(this.sortFeaturesByY&&this.sortedAngle!==t&&!(this.text.segments.get().length>1||this.icon.segments.get().length>1)){this.symbolInstanceIndexes=this.getSortedSymbolIndexes(t),this.sortedAngle=t,this.text.indexArray.clear(),this.icon.indexArray.clear(),this.featureSortOrder=[];for(const t of this.symbolInstanceIndexes){const e=this.symbolInstances.get(t);this.featureSortOrder.push(e.featureIndex);const{rightJustifiedTextSymbolIndex:i,centerJustifiedTextSymbolIndex:n,leftJustifiedTextSymbolIndex:r,verticalPlacedTextSymbolIndex:o,placedIconSymbolIndex:s,verticalPlacedIconSymbolIndex:a}=e;i>=0&&this.addIndicesForPlacedSymbol(this.text,i),n>=0&&n!==i&&this.addIndicesForPlacedSymbol(this.text,n),r>=0&&r!==n&&r!==i&&this.addIndicesForPlacedSymbol(this.text,r),o>=0&&this.addIndicesForPlacedSymbol(this.text,o),s>=0&&this.addIndicesForPlacedSymbol(this.icon,s),a>=0&&this.addIndicesForPlacedSymbol(this.icon,a)}this.text.indexBuffer&&this.text.indexBuffer.updateData(this.text.indexArray),this.icon.indexBuffer&&this.icon.indexBuffer.updateData(this.icon.indexArray)}}}ba(jg,"SymbolBucket",{omit:["layers","collisionBoxArray","features","compareText"]}),jg.addDynamicAttributes=Bg;class Vg{constructor(t,e,i,n){this.context=t,this.format=i,this.texture=t.gl.createTexture(),this.update(e,n)}update(t,e,i){const{width:n,height:r}=t,{context:o}=this,{gl:s}=o;if(s.bindTexture(s.TEXTURE_2D,this.texture),o.pixelStoreUnpackFlipY.set(!1),o.pixelStoreUnpack.set(1),o.pixelStoreUnpackPremultiplyAlpha.set(this.format===s.RGBA&&(!e||!1!==e.premultiply)),this.useMipmap=Boolean(e&&e.useMipmap),i||this.size&&this.size[0]===n&&this.size[1]===r){const{x:e,y:o}=i||{x:0,y:0};if(t instanceof HTMLImageElement||t instanceof HTMLCanvasElement||t instanceof HTMLVideoElement||t instanceof ImageData||ImageBitmap&&t instanceof ImageBitmap)s.texSubImage2D(s.TEXTURE_2D,0,e,o,s.RGBA,s.UNSIGNED_BYTE,t);else{let i=this.format,a=s.UNSIGNED_BYTE;this.format===s.R32F&&(i=s.RED,a=s.FLOAT),s.texSubImage2D(s.TEXTURE_2D,0,e,o,n,r,i,a,t.data)}}else if(this.size=[n,r],t instanceof HTMLImageElement||t instanceof HTMLCanvasElement||t instanceof HTMLVideoElement||t instanceof ImageData||ImageBitmap&&t instanceof ImageBitmap){let e=this.format;this.format===s.R8&&(e=s.RED),s.texImage2D(s.TEXTURE_2D,0,this.format,e,s.UNSIGNED_BYTE,t)}else{let e=this.format,i=this.format,o=s.UNSIGNED_BYTE,a=!1;this.format===s.DEPTH_COMPONENT&&(e=s.DEPTH_COMPONENT16,o=s.UNSIGNED_SHORT),this.format===s.DEPTH_STENCIL&&(e=s.DEPTH24_STENCIL8,o=s.UNSIGNED_INT_24_8,a=!0),this.format===s.R8&&(i=s.RED),this.format===s.R32F&&(o=s.FLOAT,i=s.RED),!this.useMipmap&&a?s.texStorage2D(s.TEXTURE_2D,1,e,n,r):s.texImage2D(s.TEXTURE_2D,0,e,n,r,0,i,o,t.data)}this.useMipmap&&s.generateMipmap(s.TEXTURE_2D)}bind(t,e,i=!1){const{context:n}=this,{gl:r}=n;r.bindTexture(r.TEXTURE_2D,this.texture),t!==this.minFilter&&(r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MAG_FILTER,t),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MIN_FILTER,this.useMipmap&&!i?t===r.NEAREST?r.NEAREST_MIPMAP_NEAREST:r.LINEAR_MIPMAP_LINEAR:t),this.minFilter=t),e!==this.wrapS&&(r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_S,e),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_T,e),this.wrapS=e)}bindExtraParam(t,e,i,n){const{context:r}=this,{gl:o}=r;o.bindTexture(o.TEXTURE_2D,this.texture),e!==this.magFilter&&(o.texParameteri(o.TEXTURE_2D,o.TEXTURE_MAG_FILTER,e),this.magFilter=e),t!==this.minFilter&&(o.texParameteri(o.TEXTURE_2D,o.TEXTURE_MIN_FILTER,this.useMipmap?t===o.NEAREST?o.NEAREST_MIPMAP_NEAREST:o.LINEAR_MIPMAP_LINEAR:t),this.minFilter=t),i!==this.wrapS&&(o.texParameteri(o.TEXTURE_2D,o.TEXTURE_WRAP_S,i),this.wrapS=i),n!==this.wrapT&&(o.texParameteri(o.TEXTURE_2D,o.TEXTURE_WRAP_T,n),this.wrapT=n)}destroy(){const{gl:t}=this.context;t.deleteTexture(this.texture),this.texture=null}}class Gg{constructor(t,e){this.context=t,this.texture=e}bind(t,e){const{context:i}=this,{gl:n}=i;n.bindTexture(n.TEXTURE_2D,this.texture),t!==this.minFilter&&(n.texParameteri(n.TEXTURE_2D,n.TEXTURE_MAG_FILTER,t),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_MIN_FILTER,t),this.minFilter=t),e!==this.wrapS&&(n.texParameteri(n.TEXTURE_2D,n.TEXTURE_WRAP_S,e),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_WRAP_T,e),this.wrapS=e)}}const Zg=32,qg=33,Hg=new Uint16Array(8184);for(let t=0;t>=1)>1;){const t=i+r>>1,l=n+o>>1;1&e?(r=i,o=n,i=s,n=a):(i=r,n=o,r=s,o=a),s=t,a=l}const l=4*t;Hg[l+0]=i,Hg[l+1]=n,Hg[l+2]=r,Hg[l+3]=o}const Wg=new Uint16Array(2178),Yg=new Uint8Array(1089),Xg=new Uint16Array(1089);function Kg(t){return 0===t?-.03125:32===t?.03125:0}var Jg=Ll([{name:"a_pos",type:"Int16",components:2},{name:"a_texture_pos",type:"Int16",components:2}]),Qg=Ll([{name:"a_index",type:"Int16",components:1}]);const ty={type:2,extent:uo,loadGeometry:()=>[[new Ue(0,0),new Ue(uo+1,0),new Ue(uo+1,uo+1),new Ue(0,uo+1),new Ue(0,0)]]};class ey{constructor(t,e,i,n,r){this.tileID=t,this.uid=ni(),this.uses=0,this.tileSize=e,this.tileZoom=i,this.buckets={},this.expirationTime=null,this.queryPadding=0,this.hasSymbolBuckets=!1,this.hasRTLText=!1,this.dependencies={},this.isRaster=r,n&&n.style&&(this._lastUpdatedBrightness=n.style.getBrightness()),this.expiredRequestCount=0,this.state="loading",n&&n.transform&&(this.projection=n.transform.projection)}registerFadeDuration(t){const e=t+this.timeAdded;ee.getLayer(t))).filter(Boolean);if(0!==t.length){n.layers=t,n.stateDependentLayerIds&&(n.stateDependentLayers=n.stateDependentLayerIds.map((e=>t.filter((t=>t.id===e))[0])));for(const e of t)i[e.fqid]=n}}return i}(t.buckets,e.style),this.hasSymbolBuckets=!1;for(const t in this.buckets){const e=this.buckets[t];if(e instanceof jg){if(this.hasSymbolBuckets=!0,!i)break;e.justReloaded=!0}}if(this.hasRTLText=!1,this.hasSymbolBuckets)for(const t in this.buckets){const e=this.buckets[t];if(e instanceof jg&&e.hasRTLText){this.hasRTLText=!0,qa.isLoading()||qa.isLoaded()||"deferred"!==Ga()||Za();break}}this.queryPadding=0;for(const t in this.buckets){const i=this.buckets[t],n=e.style.getOwnLayer(t);if(!n)continue;const r=n.queryRadius(i);this.queryPadding=Math.max(this.queryPadding,r)}t.imageAtlas&&(this.imageAtlas=t.imageAtlas),t.glyphAtlasImage&&(this.glyphAtlasImage=t.glyphAtlasImage),t.lineAtlas&&(this.lineAtlas=t.lineAtlas),this._lastUpdatedBrightness=t.brightness}else this.collisionBoxArray=new dc}unloadVectorData(){if(this.hasData()){for(const t in this.buckets)this.buckets[t].destroy();this.buckets={},this.imageAtlas&&(this.imageAtlas=null),this.lineAtlas&&(this.lineAtlas=null),this.imageAtlasTexture&&this.imageAtlasTexture.destroy(),this.glyphAtlasTexture&&this.glyphAtlasTexture.destroy(),this.lineAtlasTexture&&this.lineAtlasTexture.destroy(),this._tileBoundsBuffer&&(this._tileBoundsBuffer.destroy(),this._tileBoundsIndexBuffer.destroy(),this._tileBoundsSegments.destroy(),this._tileBoundsBuffer=null),this._tileDebugBuffer&&(this._tileDebugBuffer.destroy(),this._tileDebugSegments.destroy(),this._tileDebugBuffer=null),this._tileDebugIndexBuffer&&(this._tileDebugIndexBuffer.destroy(),this._tileDebugIndexBuffer=null),this._globeTileDebugBorderBuffer&&(this._globeTileDebugBorderBuffer.destroy(),this._globeTileDebugBorderBuffer=null),this._tileDebugTextBuffer&&(this._tileDebugTextBuffer.destroy(),this._tileDebugTextSegments.destroy(),this._tileDebugTextIndexBuffer.destroy(),this._tileDebugTextBuffer=null),this._globeTileDebugTextBuffer&&(this._globeTileDebugTextBuffer.destroy(),this._globeTileDebugTextBuffer=null),this.latestFeatureIndex=null,this.state="unloaded"}}getBucket(t){return this.buckets[t.fqid]}upload(t){for(const e in this.buckets){const i=this.buckets[e];i.uploadPending()&&i.upload(t)}const e=t.gl,i=this.imageAtlas;if(i&&!i.uploaded){const n=!!Object.keys(i.patternPositions).length;this.imageAtlasTexture=new Vg(t,i.image,e.RGBA,{useMipmap:n}),this.imageAtlas.uploaded=!0}this.glyphAtlasImage&&(this.glyphAtlasTexture=new Vg(t,this.glyphAtlasImage,e.R8),this.glyphAtlasImage=null),this.lineAtlas&&!this.lineAtlas.uploaded&&(this.lineAtlasTexture=new Vg(t,this.lineAtlas.image,e.R8),this.lineAtlas.uploaded=!0)}prepare(t,e,i){if(this.imageAtlas&&this.imageAtlasTexture&&this.imageAtlas.patchUpdatedImages(t,this.imageAtlasTexture,i),!e||!this.latestFeatureIndex||!this.latestFeatureIndex.rawTileData)return;const n=e.style.getBrightness();(this._lastUpdatedBrightness||n)&&(this._lastUpdatedBrightness&&n&&Math.abs(this._lastUpdatedBrightness-n)t)i=!1;else if(e)if(this.expirationTime=0;t--){const e=4*t,i=Hg[e+0],n=Hg[e+1],r=Hg[e+2],o=Hg[e+3],s=i+r>>1,a=n+o>>1,l=s+a-n,c=a+i-s,d=n*qg+i,u=o*qg+r,h=a*qg+s,p=Math.hypot((Wg[2*d+0]+Wg[2*u+0])/2-Wg[2*h+0],(Wg[2*d+1]+Wg[2*u+1])/2-Wg[2*h+1])>=16;Yg[h]=Yg[h]||(p?1:0),t>1)*qg+(i+l>>1)]||Yg[(o+c>>1)*qg+(r+l>>1)])}const r=new Dl,o=new Kl;let s=0;function a(t,e){const i=e*qg+t;return 0===Xg[i]&&(r.emplaceBack(Wg[2*i+0],Wg[2*i+1],t*uo/Zg,e*uo/Zg),Xg[i]=++s),Xg[i]-1}function l(t,e,i,n,r,s){const c=t+i>>1,d=e+n>>1;if(Math.abs(t-r)+Math.abs(e-s)>1&&Yg[d*qg+c])l(r,s,t,e,c,d),l(i,n,r,s,c,d);else{const l=a(t,e),c=a(i,n),d=a(r,s);o.emplaceBack(l,c,d)}}return l(0,0,Zg,Zg,Zg,0),l(Zg,Zg,0,0,0,Zg),{vertices:r,indices:o}}(this.tileID.canonical,e);n=t.vertices,r=t.indices}else{n=new Dl,r=new Kl;for(const{x:t,y:e}of i)n.emplaceBack(t,e,0,0);const t=xh(n.int16,void 0,4);for(let e=0;e0&&(a=t.ad.invert(new Float64Array(16),i.globeMatrix)),this._makeGlobeTileDebugBorderBuffer(e,r,i,o,a,s),this._makeGlobeTileDebugTextBuffer(e,r,i,o,a,s)}_globePoint(e,i,n,r,o,s,a){let l=Fu(e,i,n);if(s){const o=1.5?h=-1:u{const p=(d-t)/(h-1),f=(u-c)/(h-1),m=s.length;for(let d=0;dd*t+e;for(let t=0;t[t,this.get(t)]))}evict(t=!1){if(t||this.size>0){const t=this.first;delete this.items[t.key],0==--this.size?(this.first=null,this.last=null):(this.first=t.next,this.first.prev=null)}return this}expiresAt(t){let e;return this.has(t)&&(e=this.items[t].expiry),e}get(t){let e;if(this.has(t)){const i=this.items[t];this.ttl>0&&i.expiry0?Date.now()+this.ttl:this.ttl),this.last!==r){const t=this.last,e=r.next,i=r.prev;this.first===r&&(this.first=r.next),r.next=null,r.prev=this.last,t.next=r,null!==i&&(i.next=e),null!==e&&(e.prev=i)}}else this.max>0&&this.size===this.max&&this.evict(!0),r=this.items[t]={expiry:this.ttl>0?Date.now()+this.ttl:this.ttl,key:t,prev:this.last,next:null,value:e},1==++this.size?this.first=r:this.last.next=r;return this.last=r,this}values(t=this.keys()){return t.map((t=>this.get(t)))}}function uy(t,e){if(4!==e.length)throw new Error(`Expected data of dimension 4 but got ${e.length}.`);let i=e[3];for(let n=2;n>=1;n--){const r=1===n?1:0,o=2===n?1:0;for(let n=0;n>>1^-(1&t[e]);return t}function py(t,e){switch(e){case"uint32":return t;case"uint16":for(let e=0;e>4|(61440&i)>>8|(240&n)>4|(15&n)>6|(192&n)>>4|(192&r)>>2|192&o,t[e+1]=(48&i)>>4|(48&n)>>2|48&r|(48&o)>2|12&n|(12&r)>1|(21845&Cy)>2|(13107&Ay)>4|(3855&Ay)>8|(255&Ay)>1}var Iy=function(t,e,i){for(var n=t.length,r=0,o=new _y(e);r>l]=c}else for(s=new _y(n),r=0;r>15-t[r]);return s},Ly=new my(288);for(Cy=0;Cye&&(e=t[i]);return e},zy=function(t,e,i){var n=e/8|0;return(t[n]|t[n+1]>(7&e)&i},Ry=function(t,e){var i=e/8|0;return(t[i]|t[i+1]>(7&e)},Oy=["unexpected EOF","invalid block type","invalid length/literal","invalid distance","stream finished","no stream handler",,"no callback","invalid UTF-8 data","extra field too long","date not in range 1980-2099","filename too long","stream finishing","invalid zip data"],By=function(t,e,i){var n=new Error(e||Oy[t]);if(n.code=t,Error.captureStackTrace&&Error.captureStackTrace(n,By),!i)throw n;return n},Fy=new my(0),Ny="undefined"!=typeof TextDecoder&&new TextDecoder;try{Ny.decode(Fy,{stream:!0})}catch(t){}const Uy={gzip_data:"gzip"},jy={0:"uint32",1:"uint32",2:"uint16",3:"uint8"},Vy={uint32:1,uint16:2,uint8:4},Gy={uint32:Uint32Array,uint16:Uint16Array,uint8:Uint8Array};class Zy{constructor(t=1){this.x=NaN,this.y=NaN,this.z=NaN,this.layers={},this._cacheSize=t}getLayer(t){return this.layers[t]}getHeaderLength(t){const e=new Uint8Array(t),i=new DataView(t);if(13!==e[0])throw new fy("File is not a valid MRT.");return i.getUint32(1,!0)}parseHeader(t){const e=new Uint8Array(t),i=this.getHeaderLength(t);if(e.length= ${i} but got buffer of length ${e.length}`);const n=function(t){return t.readFields(iy,{header_length:0,x:0,y:0,z:0,layers:[]},void 0)}(new Lm(e.subarray(0,i)));if(!isNaN(this.x)&&(this.x!==n.x||this.y!==n.y||this.z!==n.z))throw new fy(`Invalid attempt to parse header ${n.z}/${n.x}/${n.y} for tile ${this.z}/${this.x}/${this.y}`);this.x=n.x,this.y=n.y,this.z=n.z;for(const t of n.layers)this.layers[t.name]=new qy(t,{cacheSize:this._cacheSize});return this}createDecodingTask(t){const e=[],i=this.getLayer(t.layerName);for(let n=0;nt.lastBlock)continue;if(i._blocksInProgress.has(n))continue;const a={layerName:i.name,firstByte:o,lastByte:s,pixelFormat:i.pixelFormat,blockIndex:n,blockShape:[r.bands.length].concat(i.bandShape),buffer:i.buffer,codec:r.codec.codec,filters:r.filters.map((t=>t.filter))};i._blocksInProgress.add(n),e.push(a)}return new Hy(e,(()=>{e.forEach((t=>i._blocksInProgress.delete(t.blockIndex)))}),((t,n)=>{if(e.forEach((t=>i._blocksInProgress.delete(t.blockIndex))),t)throw t;n.forEach((t=>{this.getLayer(t.layerName).processDecodedData(t)}))}))}}class qy{constructor({version:t,name:e,units:i,tilesize:n,pixel_format:r,buffer:o,data_index:s},a){if(this.version=t,1!==this.version)throw new fy(`Cannot parse raster layer encoded with MRT version ${t}`);this.name=e,this.units=i,this.tileSize=n,this.buffer=o,this.pixelFormat=jy[r],this.dataIndex=s,this.bandShape=[n+2*o,n+2*o,Vy[this.pixelFormat]],this._decodedBlocks=function(t=1e3,e=0,i=!1){if(isNaN(t)||t=e&&t=0}hasDataForBand(t){const{blockIndex:e}=this.getBlockForBand(t);return e>=0&&!!this._decodedBlocks.get(e.toString())}getBandView(t){const{blockIndex:e,blockBandIndex:i}=this.getBlockForBand(t),n=this._decodedBlocks.get(e.toString());if(!n)throw new fy(`Data for band ${JSON.stringify(t)} of layer "${this.name}" not decoded.`);const r=this.dataIndex[e],o=this.bandShape.reduce(((t,e)=>t*e),1),s=i*o,a=n.subarray(s,s+o);return{data:a,bytes:new Uint8Array(a.buffer).subarray(a.byteOffset,a.byteOffset+a.byteLength),tileSize:this.tileSize,buffer:this.buffer,offset:r.offset,scale:r.scale}}}class Hy{constructor(t,e,i){this.tasks=t,this._onCancel=e,this._onComplete=i,this._finalized=!1}cancel(){this._finalized||(this._onCancel(),this._finalized=!0)}complete(t,e){this._finalized||(this._onComplete(t,e),this._finalized=!0)}}Zy.performDecoding=function(t,e){return Promise.all(e.tasks.map((e=>{const{layerName:i,firstByte:n,lastByte:r,pixelFormat:o,blockShape:s,blockIndex:a,filters:l,codec:c}=e,d=new Uint8Array(t).subarray(n,r+1),u=new Uint32Array(s[0]*s[1]*s[2]);let h;if("gzip_data"!==c)throw new Error(`Unhandled codec: ${c}`);return h=function(t,e){if(!globalThis.DecompressionStream&&"gzip_data"===e)return Promise.resolve(((o=function(t){31==t[0]&&139==t[1]&&8==t[2]||By(6,"invalid gzip data");var e=t[3],i=10;4&e&&(i+=2+(t[10]|t[11]>3&1)+(e>>4&1);n>0;n-=!t[i++]);return i+(2&e)}(r=t))+8>r.length&&By(6,"invalid gzip data"),function(t,e,i){var n=t.length;if(!n||e.f&&!e.l)return i||new my(0);var r=!i,o=r||2!=e.i,s=e.i;r&&(i=new my(3*n));var a,l,c=function(t){var e=i.length;if(t>e){var n=new my(Math.max(2*e,t));n.set(i),i=n}},d=e.f||0,u=e.p||0,h=e.b||0,p=e.l,f=e.d,m=e.m,_=e.n,g=8*n;do{if(!p){d=zy(t,u,1);var y=zy(t,u+1,3);if(u+=3,!y){var v=t[(L=4+((u+7)/8|0))-4]|t[L-3]n){s&&By(0);break}o&&c(h+v),i.set(t.subarray(L,x),h),e.b=h+=v,e.p=u=8*x,e.f=d;continue}if(1==y)p=$y,f=ky,m=9,_=5;else if(2==y){var b=zy(t,u,31)+257,w=zy(t,u+10,15)+4,T=b+zy(t,u+5,31)+1;u+=14;for(var S=new my(T),E=new my(19),M=0;M>4)g){s&&By(0);break}}o&&c(h+131072);for(var R=(1>4;if((u+=15&$)>g){s&&By(0);break}if($||By(2),F264&&(N=zy(t,u,(1>4;if(U||By(3),u+=15&U,z=Ey[j],j>3){var V=vy[j];z+=Ry(t,u)&(1g){s&&By(0);break}o&&c(h+131072);var G=h+N;if(ha.length)&&(l=a.length),new my(a.subarray(0,l))):i.subarray(0,h)}(r.subarray(o,-8),{i:2},new my(((i=r)[(n=i.length)-4]|i[n-3]>>0))));var i,n,r,o;const s=Uy[e];if(!s)throw new Error(`Unhandled codec: ${e}`);const a=new globalThis.DecompressionStream(s);return new Response(new Blob([t]).stream().pipeThrough(a)).arrayBuffer().then((t=>new Uint8Array(t)))}(d,c).then((t=>(function(t,e){t.readFields(ly,e)}(new Lm(t),u),new(0,Gy[o])(u.buffer)))),h.then((t=>{for(let e=l.length-1;e>=0;e--)switch(l[e]){case"delta_filter":uy(t,s);break;case"zigzag_filter":hy(t);break;case"bitshuffle_filter":py(t,o);break;default:throw new Error(`Unhandled filter "${l[e]}"`)}return{layerName:i,blockIndex:a,data:t}})).catch((t=>{throw t}))})))};class Wy extends ey{constructor(t,e,i,n,r){super(t,e,i,n,r),this._workQueue=[],this._fetchQueue=[],this._isHeaderLoaded=!1}setTexture(t,e){const i=e.context,n=i.gl;this.texture=this.texture||e.getTileTexture(t.width),this.texture&&this.texture instanceof Vg?this.texture.update(t,{useMipmap:!1,premultiply:!1}):this.texture=new Vg(i,t,n.RGBA,{useMipmap:!1,premultiply:!1})}flushQueues(){for(;this._workQueue.length;)this._workQueue.pop()();for(;this._fetchQueue.length;)this._fetchQueue.pop()()}fetchHeader(t=16384,e){const i=this._mrt=new Zy(30),n=Object.assign({},this.requestParams,{headers:{Range:"bytes=0-"+(t-1)}});return this.entireBuffer=null,this.request=en(n,((n,r,o,s)=>{if(n)e(n);else try{const n=i.getHeaderLength(r);if(n>t)return void(this.request=this.fetchHeader(n,e));i.parseHeader(r),this._isHeaderLoaded=!0;let a=0;for(const t of Object.values(i.layers))a=Math.max(a,t.dataIndex[t.dataIndex.length-1].last_byte);r.byteLength>=a&&(this.entireBuffer=r),e(null,this.entireBuffer||r,o,s)}catch(t){e(t)}})),this.request}fetchBand(t,e,i){const n=this._mrt;if(!this._isHeaderLoaded||!n)return void i(new Error("Tile header is not ready"));const r=this.actor;if(!r)return void i(new Error("Can't fetch tile band without an actor"));let o;const s=(n,r)=>{o.complete(n,r),n?i(n):(this.updateTextureDescriptor(t,e),i(null,this.textureDescriptor&&this.textureDescriptor.img))},a=(t,e)=>{if(t)return i(t);const n=r.send("decodeRasterArray",{buffer:e,task:o},s,void 0,!0);this._workQueue.push((()=>{n&&n.cancel(),o.cancel()}))},l=n.getLayer(t);if(!l)return void i(new Error(`Unknown sourceLayer "${t}"`));if(l.hasDataForBand(e))return this.updateTextureDescriptor(t,e),void i(null,this.textureDescriptor?this.textureDescriptor.img:null);const c=l.getDataRange([e]);if(o=n.createDecodingTask(c),!o||o.tasks.length)if(this.flushQueues(),this.entireBuffer)a(null,this.entireBuffer.slice(c.firstByte,c.lastByte+1));else{const t=Object.assign({},this.requestParams,{headers:{Range:`bytes=${c.firstByte}-${c.lastByte}`}}),e=en(t,a);this._fetchQueue.push((()=>{e.cancel(),o.cancel()}))}else i(null)}updateNeeded(t,e){return(!this.textureDescriptor||this.textureDescriptor.band!==e||this.textureDescriptor.layer!==t)&&"errored"!==this.state}updateTextureDescriptor(t,e){if(!this._mrt)return;const i=this._mrt.getLayer(t);if(!i||!i.hasBand(e)||!i.hasDataForBand(e))return;const{bytes:n,tileSize:r,buffer:o,offset:s,scale:a}=i.getBandView(e),l=r+2*o,c={data:n,width:l,height:l},d=this.texture;d&&d instanceof Vg&&d.update(c,{useMipmap:!1,premultiply:!1}),this.textureDescriptor={layer:t,band:e,img:c,buffer:o,offset:s,tileSize:r,format:i.pixelFormat,mix:[a,256*a,65536*a,16777216*a]}}}class Yy{constructor(t,e){this.max=t,this.onRemove=e,this.reset()}reset(){for(const t in this.data)for(const e of this.data[t])e.timeout&&clearTimeout(e.timeout),this.onRemove(e.value);return this.data={},this.order=[],this}add(t,e,i){const n=t.wrapped().key;void 0===this.data[n]&&(this.data[n]=[]);const r={value:e,timeout:void 0};if(void 0!==i&&(r.timeout=setTimeout((()=>{this.remove(t,r)}),i)),this.data[n].push(r),this.order.push(n),this.order.length>this.max){const t=this._getAndRemoveByKey(this.order[0]);t&&this.onRemove(t)}return this}has(t){return t.wrapped().key in this.data}getAndRemove(t){return this.has(t)?this._getAndRemoveByKey(t.wrapped().key):null}_getAndRemoveByKey(t){const e=this.data[t].shift();return e.timeout&&clearTimeout(e.timeout),0===this.data[t].length&&delete this.data[t],this.order.splice(this.order.indexOf(t),1),e.value}getByKey(t){const e=this.data[t];return e?e[0].value:null}get(t){return this.has(t)?this.data[t.wrapped().key][0].value:null}remove(t,e){if(!this.has(t))return this;const i=t.wrapped().key,n=void 0===e?0:this.data[i].indexOf(e),r=this.data[i][n];return this.data[i].splice(n,1),r.timeout&&clearTimeout(r.timeout),0===this.data[i].length&&delete this.data[i],this.onRemove(r.value),this.order.splice(this.order.indexOf(i),1),this}setMaxSize(t){for(this.max=t;this.order.length>this.max;){const t=this._getAndRemoveByKey(this.order[0]);t&&this.onRemove(t)}return this}filter(t){const e=[];for(const i in this.data)for(const n of this.data[i])t(n.value)||e.push(n);for(const t of e)this.remove(t.value.tileID,t)}}class Xy extends zn{constructor(t,e,i){super(),this.id=t,this._onlySymbols=i,e.on("data",(t=>{"source"===t.dataType&&"metadata"===t.sourceDataType&&(this._sourceLoaded=!0),this._sourceLoaded&&!this._paused&&"source"===t.dataType&&"content"===t.sourceDataType&&(this.reload(),this.transform&&this.update(this.transform))})),e.on("error",(()=>{this._sourceErrored=!0})),this._source=e,this._tiles={},this._cache=new Yy(0,this._unloadTile.bind(this)),this._timers={},this._cacheTimers={},this._minTileCacheSize=e.minTileCacheSize,this._maxTileCacheSize=e.maxTileCacheSize,this._loadedParentTiles={},this.castsShadows=!1,this.tileCoverLift=0,this._coveredTiles={},this._shadowCasterTiles={},this._state=new km,this._isRaster="raster"===this._source.type||"raster-dem"===this._source.type||"raster-array"===this._source.type||"custom"===this._source.type&&"raster"===this._source._dataType}onAdd(t){this.map=t,this._minTileCacheSize=void 0===this._minTileCacheSize&&t?t._minTileCacheSize:this._minTileCacheSize,this._maxTileCacheSize=void 0===this._maxTileCacheSize&&t?t._maxTileCacheSize:this._maxTileCacheSize}loaded(){if(this._sourceErrored)return!0;if(!this._sourceLoaded)return!1;if(!this._source.loaded())return!1;for(const t in this._tiles){const e=this._tiles[t];if("errored"!==e.state&&("loaded"!==e.state||!e.bucketsLoaded()))return!1}return!0}getSource(){return this._source}pause(){this._paused=!0}resume(){if(!this._paused)return;const t=this._shouldReloadOnResume;this._paused=!1,this._shouldReloadOnResume=!1,t&&this.reload(),this.transform&&this.update(this.transform)}_loadTile(t,e){return t.isSymbolTile=this._onlySymbols,t.isExtraShadowCaster=this._shadowCasterTiles[t.tileID.key],this._source.loadTile(t,e)}_unloadTile(t){if(this._source.unloadTile)return this._source.unloadTile(t)}_abortTile(t){if(this._source.abortTile)return this._source.abortTile(t)}serialize(){return this._source.serialize()}prepare(t){this._source.prepare&&this._source.prepare(),this._state.coalesceChanges(this._tiles,this.map?this.map.painter:null);for(const e in this._tiles){const i=this._tiles[e];i.upload(t),i.prepare(this.map.style.imageManager,this.map?this.map.painter:null,this._source.scope)}}getIds(){return ti(this._tiles).map((t=>t.tileID)).sort(Ky).map((t=>t.key))}getRenderableIds(t,e){const i=[];for(const n in this._tiles)this._isIdRenderable(+n,t,e)&&i.push(this._tiles[n]);return t?i.sort(((t,e)=>{const i=t.tileID,n=e.tileID,r=new Ue(i.canonical.x,i.canonical.y)._rotate(this.transform.angle),o=new Ue(n.canonical.x,n.canonical.y)._rotate(this.transform.angle);return i.overscaledZ-n.overscaledZ||o.y-r.y||o.x-r.x})).map((t=>t.tileID.key)):i.map((t=>t.tileID)).sort(Ky).map((t=>t.key))}hasRenderableParent(t){const e=this.findLoadedParent(t,0);return!!e&&this._isIdRenderable(e.tileID.key)}_isIdRenderable(t,e,i){return this._tiles[t]&&this._tiles[t].hasData()&&!this._coveredTiles[t]&&(e||!this._tiles[t].holdingForFade())&&(i||!this._shadowCasterTiles[t])}reload(){if(this._paused)this._shouldReloadOnResume=!0;else{this._cache.reset();for(const t in this._tiles)"errored"!==this._tiles[t].state&&this._reloadTile(+t,"reloading")}}_reloadTile(t,e){const i=this._tiles[t];i&&("loading"!==i.state&&(i.state=e),this._loadTile(i,this._tileLoaded.bind(this,i,t,e)))}_tileLoaded(t,e,i,n){if(n)if(t.state="errored",404!==n.status)this._source.fire(new $n(n,{tile:t}));else{if(!(t.tileID.key in this._loadedParentTiles))return void this._source.fire(new Pn("data",{dataType:"source",sourceDataType:"error",sourceId:this._source.id}));if("raster-dem"===this._source.type&&this.usedForTerrain&&this.map.painter.terrain){const t=this.map.painter.terrain;this.update(this.transform,t.getScaledDemTileSize(),!0),t.resetTileLookupCache(this.id)}else this.update(this.transform)}else t.timeAdded=ki.now(),"expired"===i&&(t.refreshedUponExpiration=!0),this._setTileReloadTimer(e,t),"raster-dem"===this._source.type&&t.dem&&this._backfillDEM(t),this._state.initializeTileState(t,this.map?this.map.painter:null),this._source.fire(new Pn("data",{dataType:"source",tile:t,coord:t.tileID,sourceCacheId:this.id}))}_backfillDEM(t){const e=this.getRenderableIds();for(let n=0;n1||(Math.abs(i)>1&&(1===Math.abs(i+r)?i+=r:1===Math.abs(i-r)&&(i-=r)),e.dem&&t.dem&&(t.dem.backfillBorder(e.dem,i,n),t.neighboringTiles&&t.neighboringTiles[o]&&(t.neighboringTiles[o].backfilled=!0)))}}getTile(t){return this.getTileByID(t.key)}getTileByID(t){return this._tiles[t]}_retainLoadedChildren(t,e,i,n){for(const r in this._tiles){let o=this._tiles[r];if(n[r]||!o.hasData()||o.tileID.overscaledZi)continue;let s=o.tileID;for(;o&&o.tileID.overscaledZ>e+1;){const t=o.tileID.scaledTo(o.tileID.overscaledZ-1);o=this._tiles[t.key],o&&o.hasData()&&(s=t)}let a=s;for(;a.overscaledZ>e;)if(a=a.scaledTo(a.overscaledZ-1),t[a.key]){n[s.key]=s;break}}}findLoadedParent(t,e){if(t.key in this._loadedParentTiles){const i=this._loadedParentTiles[t.key];return i&&i.tileID.overscaledZ>=e?i:null}for(let i=t.overscaledZ-1;i>=e;i--){const e=t.scaledTo(i),n=this._getLoadedTile(e);if(n)return n}}_getLoadedTile(t){const e=this._tiles[t.key];return e&&e.hasData()?e:this._cache.getByKey(this._source.reparseOverscaled?t.wrapped().key:t.canonical.key)}updateCacheSize(t,e){e=e||this._source.tileSize;const i=Math.ceil(t.width/e)+1,n=Math.ceil(t.height/e)+1,r=Math.floor(i*n*5),o="number"==typeof this._minTileCacheSize?Math.max(this._minTileCacheSize,r):r,s="number"==typeof this._maxTileCacheSize?Math.min(this._maxTileCacheSize,o):o;this._cache.setMaxSize(s)}handleWrapJump(t){const e=Math.round((t-(void 0===this._prevLng?t:this._prevLng))/360);if(this._prevLng=t,e){const t={};for(const i in this._tiles){const n=this._tiles[i];n.tileID=n.tileID.unwrapTo(n.tileID.wrap+e),t[n.tileID.key]=n}this._tiles=t;for(const t in this._timers)clearTimeout(this._timers[t]),delete this._timers[t];for(const t in this._tiles)this._setTileReloadTimer(+t,this._tiles[t])}}update(t,e,i,n){if(this.transform=t,!this._sourceLoaded||this._paused||this.transform.freezeTileCoverage)return;if(this.usedForTerrain&&!i)return;let r;if(this.updateCacheSize(t,e),"globe"!==this.transform.projection.name&&this.handleWrapJump(this.transform.center.lng),this._shadowCasterTiles={},this._coveredTiles={},this.used||this.usedForTerrain){if(this._source.tileID)r=t.getVisibleUnwrappedCoordinates(this._source.tileID).map((t=>new vd(t.canonical.z,t.wrap,t.canonical.z,t.canonical.x,t.canonical.y)));else if(0!==this.tileCoverLift){const n=t.clone();n.tileCoverLift=this.tileCoverLift,r=n.coveringTiles({tileSize:e||this._source.tileSize,minzoom:this._source.minzoom,maxzoom:this._source.maxzoom,roundZoom:this._source.roundZoom&&!i,reparseOverscaled:this._source.reparseOverscaled,isTerrainDEM:this.usedForTerrain}),this._source.minzoomt(e)))}}else r=[];if(r.length>0&&this.castsShadows&&n&&"globe"!==this.transform.projection.name&&!this.usedForTerrain&&!Jy(this._source.type)){const o=t.coveringZoomLevel({tileSize:e||this._source.tileSize,roundZoom:this._source.roundZoom&&!i}),s=Math.min(o,this._source.maxzoom),a=t.extendTileCoverForShadows(r,n,s);for(const t of a)this._shadowCasterTiles[t.key]=!0,r.push(t)}const o=this._updateRetainedTiles(r);if(Jy(this._source.type)&&0!==r.length){const t={},e={},i=Object.keys(o);for(const n of i){const i=o[n],r=this._tiles[n];if(!r||r.fadeEndTime&&r.fadeEndTimen;){r=r.scaledTo(r.overscaledZ-1);const n=this._tiles[r.key];if(n&&n.hasData()&&e[r.key]){o[t]=i.tileID;break}}}for(const e in t)o[e]||(this._coveredTiles[e]=!0,o[e]=t[e])}for(const t in o)this._tiles[t].clearFadeHold();const s=function(t,e){const i=[];for(const n in t)n in e||i.push(n);return i}(this._tiles,o);for(const t of s){const e=this._tiles[t];e.hasSymbolBuckets&&!e.holdingForFade()?e.setHoldDuration(this.map._fadeDuration):e.hasSymbolBuckets&&!e.symbolFadeFinished()||this._removeTile(+t)}this._updateLoadedParentTileCache(),this._onlySymbols&&this._source.afterUpdate&&this._source.afterUpdate()}releaseSymbolFadeTiles(){for(const t in this._tiles)this._tiles[t].holdingForFade()&&this._removeTile(+t)}_updateRetainedTiles(t){const e={};if(0===t.length)return e;const i={},n=t.reduce(((t,e)=>Math.min(t,e.overscaledZ)),1/0),r=t[0].overscaledZ,o=Math.max(r-Xy.maxOverzooming,this._source.minzoom),s=Math.max(r+Xy.maxUnderzooming,this._source.minzoom),a={};for(const i of t){const t=this._addTile(i);e[i.key]=i,t.hasData()||n=this._source.maxzoom){const t=n.children(this._source.maxzoom)[0],i=this.getTile(t);if(i&&i.hasData()){e[t.key]=t;continue}}else{const t=n.children(this._source.maxzoom);if(e[t[0].key]&&e[t[1].key]&&e[t[2].key]&&e[t[3].key])continue}let r=t.wasRequested();for(let s=n.overscaledZ-1;s>=o;--s){const o=n.scaledTo(s);if(i[o.key])break;if(i[o.key]=!0,t=this.getTile(o),!t&&r&&(t=this._addTile(o)),t&&(e[o.key]=o,r=t.wasRequested(),t.hasData()))break}}return e}_updateLoadedParentTileCache(){this._loadedParentTiles={};for(const t in this._tiles){const e=[];let i,n=this._tiles[t].tileID;for(;n.overscaledZ>0;){if(n.key in this._loadedParentTiles){i=this._loadedParentTiles[n.key];break}e.push(n.key);const t=n.scaledTo(n.overscaledZ-1);if(i=this._getLoadedTile(t),i)break;n=t}for(const t of e)this._loadedParentTiles[t]=i}}_addTile(t){let e=this._tiles[t.key];if(e)return!0!==e.isExtraShadowCaster||!!this._shadowCasterTiles[t.key]||this._reloadTile(t.key,"reloading"),e;e=this._cache.getAndRemove(t),e&&(this._setTileReloadTimer(t.key,e),e.tileID=t,this._state.initializeTileState(e,this.map?this.map.painter:null),this._cacheTimers[t.key]&&(clearTimeout(this._cacheTimers[t.key]),delete this._cacheTimers[t.key],this._setTileReloadTimer(t.key,e)));const i=Boolean(e);if(!i){const i=this.map?this.map.painter:null,n=this._source.tileSize*t.overscaleFactor();e="raster-array"===this._source.type?new Wy(t,n,this.transform.tileZoom,i,this._isRaster):new ey(t,n,this.transform.tileZoom,i,this._isRaster),this._loadTile(e,this._tileLoaded.bind(this,e,t.key,e.state))}return e?(e.uses++,this._tiles[t.key]=e,i||this._source.fire(new Pn("dataloading",{tile:e,coord:e.tileID,dataType:"source"})),e):null}_setTileReloadTimer(t,e){t in this._timers&&(clearTimeout(this._timers[t]),delete this._timers[t]);const i=e.getExpiryTimeout();i&&(this._timers[t]=setTimeout((()=>{this._reloadTile(t,"expired"),delete this._timers[t]}),i))}_removeTile(t){const e=this._tiles[t];e&&(e.uses--,delete this._tiles[t],this._timers[t]&&(clearTimeout(this._timers[t]),delete this._timers[t]),e.uses>0||(e.hasData()&&"reloading"!==e.state||"empty"===e.state?this._cache.add(e.tileID,e,e.getExpiryTimeout()):(e.aborted=!0,this._abortTile(e),this._unloadTile(e))))}clearTiles(){this._shouldReloadOnResume=!1,this._paused=!1;for(const t in this._tiles)this._removeTile(+t);this._source._clear&&this._source._clear(),this._cache.reset(),this.map&&this.usedForTerrain&&this.map.painter.terrain&&this.map.painter.terrain.resetTileLookupCache(this.id)}tilesIn(t,e,i){const n=[],r=this.transform;if(!r)return n;const o="globe"===r.projection.name,s=Ed(r.center.lng);for(const a in this._tiles){const l=this._tiles[a];if(i&&l.clearQueryDebugViz(),l.holdingForFade())continue;let c;if(o){const t=l.tileID.canonical;if(0===t.z){const e=[Math.abs(Xe(s,...Qy(t,-1))-s),Math.abs(Xe(s,...Qy(t,1))-s)];c=[0,2*e.indexOf(Math.min(...e))-1]}else{const e=[Math.abs(Xe(s,...Qy(t,-1))-s),Math.abs(Xe(s,...Qy(t,0))-s),Math.abs(Xe(s,...Qy(t,1))-s)];c=[e.indexOf(Math.min(...e))-1]}}else c=[0];for(const i of c){const o=t.containsTile(l,r,e,i);o&&n.push(o)}}return n}getShadowCasterCoordinates(){return this._getRenderableCoordinates(!1,!0)}getVisibleCoordinates(t){return this._getRenderableCoordinates(t)}_getRenderableCoordinates(t,e){const i=this.getRenderableIds(t,e).map((t=>this._tiles[t].tileID)),n="globe"===this.transform.projection.name;for(const t of i)t.projMatrix=this.transform.calculateProjMatrix(t.toUnwrapped()),t.expandedProjMatrix=n?this.transform.calculateProjMatrix(t.toUnwrapped(),!1,!0):t.projMatrix;return i}sortCoordinatesByDistance(t){const e=t.slice(),i=this.transform._camera.position,n=this.transform._camera.forward(),r={};for(const t of e){const e=1/(1r[t.key]-r[e.key])),e}hasTransition(){if(this._source.hasTransition())return!0;if(Jy(this._source.type))for(const t in this._tiles){const e=this._tiles[t];if(void 0!==e.fadeEndTime&&e.fadeEndTime>=ki.now())return!0}return!1}setFeatureState(t,e,i){this._state.updateState(t=t||"_geojsonTileLayer",e,i)}removeFeatureState(t,e,i){this._state.removeFeatureState(t=t||"_geojsonTileLayer",e,i)}getFeatureState(t,e){return this._state.getState(t=t||"_geojsonTileLayer",e)}setDependencies(t,e,i){const n=this._tiles[t];n&&n.setDependencies(e,i)}reloadTilesForDependencies(t,e){for(const i in this._tiles)this._tiles[i].hasDependency(t,e)&&this._reloadTile(+i,"reloading");this._cache.filter((i=>!i.hasDependency(t,e)))}_preloadTiles(t,e){if(!this._sourceLoaded){const i=()=>{this._sourceLoaded&&(this._source.off("data",i),this._preloadTiles(t,e))};return void this._source.on("data",i)}const i=new Map,n=Array.isArray(t)?t:[t],r=this.map.painter.terrain,o=this.usedForTerrain&&r?r.getScaledDemTileSize():this._source.tileSize;for(const t of n){const e=t.coveringTiles({tileSize:o,minzoom:this._source.minzoom,maxzoom:this._source.maxzoom,roundZoom:this._source.roundZoom&&!this.usedForTerrain,reparseOverscaled:this._source.reparseOverscaled,isTerrainDEM:this.usedForTerrain});for(const t of e)i.set(t.key,t);this.usedForTerrain&&t.updateElevation(!1)}Qe(Array.from(i.values()),((t,e)=>{const i=new ey(t,this._source.tileSize*t.overscaleFactor(),this.transform.tileZoom,this.map.painter,this._isRaster);this._loadTile(i,(t=>{"raster-dem"===this._source.type&&i.dem&&this._backfillDEM(i),e(t,i)}))}),e)}}function Ky(t,e){const i=Math.abs(2*t.wrap)-+(t.wrap0?e+2*t:t}tv.useIntegerZoom=!0;const iv=new ol({"symbol-placement":new il(sl.layout_symbol["symbol-placement"]),"symbol-spacing":new il(sl.layout_symbol["symbol-spacing"]),"symbol-avoid-edges":new il(sl.layout_symbol["symbol-avoid-edges"]),"symbol-sort-key":new nl(sl.layout_symbol["symbol-sort-key"]),"symbol-z-order":new il(sl.layout_symbol["symbol-z-order"]),"symbol-z-elevate":new il(sl.layout_symbol["symbol-z-elevate"]),"icon-allow-overlap":new il(sl.layout_symbol["icon-allow-overlap"]),"icon-ignore-placement":new il(sl.layout_symbol["icon-ignore-placement"]),"icon-optional":new il(sl.layout_symbol["icon-optional"]),"icon-rotation-alignment":new il(sl.layout_symbol["icon-rotation-alignment"]),"icon-size":new nl(sl.layout_symbol["icon-size"]),"icon-text-fit":new nl(sl.layout_symbol["icon-text-fit"]),"icon-text-fit-padding":new nl(sl.layout_symbol["icon-text-fit-padding"]),"icon-image":new nl(sl.layout_symbol["icon-image"]),"icon-rotate":new nl(sl.layout_symbol["icon-rotate"]),"icon-padding":new il(sl.layout_symbol["icon-padding"]),"icon-keep-upright":new il(sl.layout_symbol["icon-keep-upright"]),"icon-offset":new nl(sl.layout_symbol["icon-offset"]),"icon-anchor":new nl(sl.layout_symbol["icon-anchor"]),"icon-pitch-alignment":new il(sl.layout_symbol["icon-pitch-alignment"]),"text-pitch-alignment":new il(sl.layout_symbol["text-pitch-alignment"]),"text-rotation-alignment":new il(sl.layout_symbol["text-rotation-alignment"]),"text-field":new nl(sl.layout_symbol["text-field"]),"text-font":new nl(sl.layout_symbol["text-font"]),"text-size":new nl(sl.layout_symbol["text-size"]),"text-max-width":new nl(sl.layout_symbol["text-max-width"]),"text-line-height":new nl(sl.layout_symbol["text-line-height"]),"text-letter-spacing":new nl(sl.layout_symbol["text-letter-spacing"]),"text-justify":new nl(sl.layout_symbol["text-justify"]),"text-radial-offset":new nl(sl.layout_symbol["text-radial-offset"]),"text-variable-anchor":new il(sl.layout_symbol["text-variable-anchor"]),"text-anchor":new nl(sl.layout_symbol["text-anchor"]),"text-max-angle":new il(sl.layout_symbol["text-max-angle"]),"text-writing-mode":new il(sl.layout_symbol["text-writing-mode"]),"text-rotate":new nl(sl.layout_symbol["text-rotate"]),"text-padding":new il(sl.layout_symbol["text-padding"]),"text-keep-upright":new il(sl.layout_symbol["text-keep-upright"]),"text-transform":new nl(sl.layout_symbol["text-transform"]),"text-offset":new nl(sl.layout_symbol["text-offset"]),"text-allow-overlap":new il(sl.layout_symbol["text-allow-overlap"]),"text-ignore-placement":new il(sl.layout_symbol["text-ignore-placement"]),"text-optional":new il(sl.layout_symbol["text-optional"]),visibility:new il(sl.layout_symbol.visibility)});var nv={paint:new ol({"icon-opacity":new nl(sl.paint_symbol["icon-opacity"]),"icon-occlusion-opacity":new nl(sl.paint_symbol["icon-occlusion-opacity"]),"icon-emissive-strength":new nl(sl.paint_symbol["icon-emissive-strength"]),"text-emissive-strength":new nl(sl.paint_symbol["text-emissive-strength"]),"icon-color":new nl(sl.paint_symbol["icon-color"]),"icon-halo-color":new nl(sl.paint_symbol["icon-halo-color"]),"icon-halo-width":new nl(sl.paint_symbol["icon-halo-width"]),"icon-halo-blur":new nl(sl.paint_symbol["icon-halo-blur"]),"icon-translate":new il(sl.paint_symbol["icon-translate"]),"icon-translate-anchor":new il(sl.paint_symbol["icon-translate-anchor"]),"icon-image-cross-fade":new nl(sl.paint_symbol["icon-image-cross-fade"]),"text-opacity":new nl(sl.paint_symbol["text-opacity"]),"text-occlusion-opacity":new nl(sl.paint_symbol["text-occlusion-opacity"]),"text-color":new nl(sl.paint_symbol["text-color"],{runtimeType:Qn,getOverride:t=>t.textColor,hasOverride:t=>!!t.textColor}),"text-halo-color":new nl(sl.paint_symbol["text-halo-color"]),"text-halo-width":new nl(sl.paint_symbol["text-halo-width"]),"text-halo-blur":new nl(sl.paint_symbol["text-halo-blur"]),"text-translate":new il(sl.paint_symbol["text-translate"]),"text-translate-anchor":new il(sl.paint_symbol["text-translate-anchor"]),"icon-color-saturation":new il(sl.paint_symbol["icon-color-saturation"]),"icon-color-contrast":new il(sl.paint_symbol["icon-color-contrast"]),"icon-color-brightness-min":new il(sl.paint_symbol["icon-color-brightness-min"]),"icon-color-brightness-max":new il(sl.paint_symbol["icon-color-brightness-max"])}),layout:iv};class rv{constructor(t){this.type=t.property.overrides?t.property.overrides.runtimeType:Yn,this.defaultValue=t}evaluate(t){if(t.formattedSection){const e=this.defaultValue.property.overrides;if(e&&e.hasOverride(t.formattedSection))return e.getOverride(t.formattedSection)}return t.feature&&t.featureState?this.defaultValue.evaluate(t.feature,t.featureState):this.defaultValue.property.specification.default}eachChild(t){this.defaultValue.isConstant()||t(this.defaultValue.value._styleExpression.expression)}outputDefined(){return!1}serialize(){return null}}ba(rv,"FormatSectionOverride",{omit:["defaultValue"]});class ov extends Ml{constructor(e,i,n,r){super(e,nv,i,n,r),this._colorAdjustmentMatrix=t.ad.identity([]),this.hasInitialOcclusionOpacityProperties=void 0!==e.paint&&("icon-occlusion-opacity"in e.paint||"text-occlusion-opacity"in e.paint)}recalculate(t,e){super.recalculate(t,e),"auto"===this.layout.get("icon-rotation-alignment")&&(this.layout._values["icon-rotation-alignment"]="point"!==this.layout.get("symbol-placement")?"map":"viewport"),"auto"===this.layout.get("text-rotation-alignment")&&(this.layout._values["text-rotation-alignment"]="point"!==this.layout.get("symbol-placement")?"map":"viewport"),"auto"===this.layout.get("text-pitch-alignment")&&(this.layout._values["text-pitch-alignment"]=this.layout.get("text-rotation-alignment")),"auto"===this.layout.get("icon-pitch-alignment")&&(this.layout._values["icon-pitch-alignment"]=this.layout.get("icon-rotation-alignment"));const i=this.layout.get("text-writing-mode");if(i){const t=[];for(const e of i)t.indexOf(e)i in t?String(t[i]):""))}(e.properties,r)}createBucket(t){return new jg(t)}queryRadius(){return 0}queryIntersectsFeature(){return!1}_setPaintOverrides(){for(const t of nv.paint.overridableProperties){if(!ov.hasPaintOverride(this.layout,t))continue;const e=this.paint.get(t),i=new rv(e),n=new la(i,e.property.specification,this.scope,this.options);let r=null;r="constant"===e.value.kind||"source"===e.value.kind?new ua("source",n):new ha("composite",n,e.value.zoomStops,e.value._interpolationType),this.paint._values[t]=new tl(e.property,r,e.parameters)}}_handleOverridablePaintPropertyUpdate(t,e,i){return!(!this.layout||e.isDataDriven()||i.isDataDriven())&&ov.hasPaintOverride(this.layout,t)}static hasPaintOverride(t,e){const i=t.get("text-field"),n=nv.paint.properties[e];let r=!1;const o=t=>{for(const e of t)if(n.overrides&&n.overrides.hasOverride(e))return void(r=!0)};if("constant"===i.value.kind&&i.value.value instanceof pr)o(i.value.value.sections);else if("source"===i.value.kind){const t=e=>{r||(e instanceof vr&&gr(e.value)===nr?o(e.value.sections):e instanceof Tr?o(e.sections):e.eachChild(t))},e=i.value;e._styleExpression&&t(e._styleExpression.expression)}return r}getProgramIds(){const t=0!==this.paint.get("icon-opacity").constantOr(1),e=0!==this.paint.get("text-opacity").constantOr(1),i=[];return t&&i.push("symbolIcon"),e&&i.push("symbolSDF"),i}getDefaultProgramParams(t,e,i){return{config:new Wc(this,{zoom:e,lut:i}),overrideFog:!1}}}const sv=new ol({visibility:new il(sl.layout_background.visibility)});var av={paint:new ol({"background-color":new il(sl.paint_background["background-color"]),"background-pattern":new il(sl.paint_background["background-pattern"]),"background-opacity":new il(sl.paint_background["background-opacity"]),"background-emissive-strength":new il(sl.paint_background["background-emissive-strength"])}),layout:sv};const lv=new ol({visibility:new il(sl.layout_raster.visibility)});var cv={paint:new ol({"raster-opacity":new il(sl.paint_raster["raster-opacity"]),"raster-color":new rl(sl.paint_raster["raster-color"]),"raster-color-mix":new il(sl.paint_raster["raster-color-mix"]),"raster-color-range":new il(sl.paint_raster["raster-color-range"]),"raster-hue-rotate":new il(sl.paint_raster["raster-hue-rotate"]),"raster-brightness-min":new il(sl.paint_raster["raster-brightness-min"]),"raster-brightness-max":new il(sl.paint_raster["raster-brightness-max"]),"raster-saturation":new il(sl.paint_raster["raster-saturation"]),"raster-contrast":new il(sl.paint_raster["raster-contrast"]),"raster-resampling":new il(sl.paint_raster["raster-resampling"]),"raster-fade-duration":new il(sl.paint_raster["raster-fade-duration"]),"raster-emissive-strength":new il(sl.paint_raster["raster-emissive-strength"]),"raster-array-band":new il(sl.paint_raster["raster-array-band"]),"raster-elevation":new il(sl.paint_raster["raster-elevation"])}),layout:lv};function dv(e,i,n,r,o,s,a,l){const c=[e,i,1,n,r,1,o,s,1],d=[a,l,1],u=t.bC.adjoint([],c),[h,p,f]=t._.transformMat3(d,d,u);return t.bC.multiply(c,c,[h,0,0,0,p,0,0,0,f])}function uv(e,i,n,r,o,s,a,l){const c=function(e,i,n,r,o,s,a,l){const c=dv(0,0,1,0,1,1,0,1),d=dv(e,i,n,r,o,s,a,l),u=t.bC.adjoint([],c);return t.bC.multiply(d,d,u)}(e,i,n,r,o,s,a,l);return[c[2]/c[8]/uo,c[5]/c[8]/uo]}function hv(t){return[t[0],Math.min(Math.max(t[1],-Pd),Pd)]}class pv extends zn{constructor(t,e,i,n){super(),this.id=t,this.dispatcher=i,this.coordinates=e.coordinates,this.type="image",this.minzoom=0,this.maxzoom=22,this.tileSize=512,this.tiles={},this._loaded=!1,this.onNorthPole=!1,this.onSouthPole=!1,this.setEventedParent(n),this.options=e,this._dirty=!1}load(t,e){if(this._loaded=e||!1,this.fire(new Pn("dataloading",{dataType:"source"})),this.url=this.options.url,!this.url)return t&&(this.coordinates=t),this._loaded=!0,void this._finishLoading();this._imageRequest=an(this.map._requestManager.transformRequest(this.url,Ki.Image),((e,i)=>{this._imageRequest=null,this._loaded=!0,e?this.fire(new $n(e)):i&&(this.image=i instanceof HTMLImageElement?ki.getImageData(i):i,this._dirty=!0,this.width=this.image.width,this.height=this.image.height,t&&(this.coordinates=t),this._finishLoading())}))}loaded(){return this._loaded}updateImage(t){return t.url?(this._imageRequest&&t.url!==this.options.url&&(this._imageRequest.cancel(),this._imageRequest=null),this.options.url=t.url,this.load(t.coordinates,this._loaded),this):this}setTexture(t){if(!(t.handle instanceof WebGLTexture))throw new Error("The provided handle is not a WebGLTexture instance");return this.texture=new Gg(this.map.painter.context,t.handle),this.width=t.dimensions[0],this.height=t.dimensions[1],this._dirty=!1,this._loaded=!0,this._finishLoading(),this}_finishLoading(){this.map&&(this.setCoordinates(this.coordinates),this.fire(new Pn("data",{dataType:"source",sourceDataType:"metadata"})))}onAdd(t){this.map=t,this.load()}onRemove(t){this._imageRequest&&(this._imageRequest.cancel(),this._imageRequest=null),!this.texture||this.texture instanceof Gg||this.texture.destroy(),this.boundsBuffer&&(this.boundsBuffer.destroy(),this.elevatedGlobeVertexBuffer&&this.elevatedGlobeVertexBuffer.destroy(),this.elevatedGlobeIndexBuffer&&this.elevatedGlobeIndexBuffer.destroy())}setCoordinates(t){if(this.coordinates=t,this._boundsArray=void 0,this._unsupportedCoords=!1,!t.length)return this;this.onNorthPole=!1,this.onSouthPole=!1;let e=t[0][1],i=t[0][1];for(const n of t)n[1]>i&&(i=n[1]),n[1]Pd?this.onNorthPole=!0:n1&&(l-=1),new gd(s,l,Math.floor((i+r)/2*a))}(e),this.minzoom=this.maxzoom=this.tileID.z}return this.fire(new Pn("data",{dataType:"source",sourceDataType:"content"})),this}_clear(){this._boundsArray=void 0,this._unsupportedCoords=!1}_prepareData(e){for(const t in this.tiles){const e=this.tiles[t];"loaded"!==e.state&&(e.state="loaded",e.texture=this.texture)}if(this._boundsArray||this.onNorthPole||this.onSouthPole||this._unsupportedCoords)return;const i=eg(new gd(0,0,0),this.map.transform.projection),n=[i.projection.project(this.coordinates[0][0],this.coordinates[0][1]),i.projection.project(this.coordinates[1][0],this.coordinates[1][1]),i.projection.project(this.coordinates[2][0],this.coordinates[2][1]),i.projection.project(this.coordinates[3][0],this.coordinates[3][1])];if(!function(t){const e=t[1].x-t[0].x,i=t[1].y-t[0].y,n=t[2].x-t[1].x,r=t[2].y-t[1].y,o=t[3].x-t[2].x,s=t[3].y-t[2].y,a=t[0].x-t[3].x,l=t[0].y-t[3].y,c=e*r-n*i,d=n*s-o*r,u=o*l-a*s,h=a*i-e*l;return c>0&&d>0&&u>0&&h>0||c{const e=r.projection.project(t[0],t[1]);return ig(r,e)._round()}));this.perspectiveTransform=uv(o.x,o.y,s.x,s.y,a.x,a.y,l.x,l.y);const c=this._boundsArray=new Dl;c.emplaceBack(o.x,o.y,0,0),c.emplaceBack(s.x,s.y,uo,0),c.emplaceBack(l.x,l.y,0,uo),c.emplaceBack(a.x,a.y,uo,uo),this.boundsBuffer&&(this.boundsBuffer.destroy(),this.elevatedGlobeVertexBuffer&&this.elevatedGlobeVertexBuffer.destroy(),this.elevatedGlobeIndexBuffer&&this.elevatedGlobeIndexBuffer.destroy()),this.boundsBuffer=e.createVertexBuffer(c,Jg.members),this.boundsSegments=wc.simpleSegment(0,0,4,2);const d=[],u=function(t){return[hv(t[0]),hv(t[1]),hv(t[2]),hv(t[3])]}(this.coordinates),[h,p,f,m]=function(t){let e=t[0][0],i=e,n=t[0][1],r=n;for(let o=1;oi&&(i=t[o][0]),t[o][1]r&&(r=t[o][1]);return[e,n,i-e,r-n]}(u);{const r=new Dl,[o,s,a,l]=function(t){let e=t[0].x,i=e,n=t[0].y,r=n;for(let o=1;oi&&(i=t[o].x),t[o].yr&&(r=t[o].y);return[e,n,i-e,r-n]}(n),c=t=>[(t.x-o)/a,(t.y-s)/l],[u,_,g,y]=n.map(c),v=function(e,i,n,r,o,s,a,l){const c=dv(0,0,1,0,1,1,0,1),d=dv(e,i,n,r,o,s,a,l),u=t.bC.adjoint([],d);return t.bC.multiply(c,c,u)}(u[0],u[1],_[0],_[1],g[0],g[1],y[0],y[1]);this.elevatedGlobePerspectiveTransform=uv(u[0],u[1],_[0],_[1],g[0],g[1],y[0],y[1]);const x=(e,i)=>{d.push(e.lng);const n=Math.round((e.lng-h)/f*uo),o=Math.round((e.lat-p)/m*uo),s=c(i),a=t._.transformMat3([],[s[0],s[1],1],v),l=Math.round(a[0]/a[2]*uo),u=Math.round(a[1]/a[2]*uo);r.emplaceBack(n,o,l,u)},b=n[3].x-n[0].x,w=n[3].y-n[0].y,T=n[2].x-n[1].x,S=n[2].y-n[1].y;for(let t=0;t{i.emplaceBack(e,n,r);const o=d[e],s=d[n],a=d[r],l=Math.min(Math.min(o,s),a),c=Math.max(Math.max(o,s),a)-l;c>this.maxLongitudeTriangleSize&&(this.maxLongitudeTriangleSize=c),t.push(l+c/2)};for(let t=0;te));i.sort(((e,i)=>t[e]-t[i]));const n=[],r=new Kl;for(let o=0;o{o.segments.push({vertexOffset:0,primitiveOffset:t,vertexLength:e.segments[0].vertexLength,primitiveLength:i,sortKey:void 0,vaos:{}})},a=.51*this.maxLongitudeTriangleSize;if(Math.abs(i[0]-n)0){const n=function(e,i){const n=i.worldSize,r=Cd(1,0)*n*kd(i.center.lat,i.zoom)/Gu(n),o=Cd(1,i.center.lat)*n,s=t.ad.identity([]);return t.ad.rotateY(s,s,Ge(i.center.lng)),t.ad.rotateX(s,s,Ge(i.center.lat)),t.ad.translate(s,s,[0,0,ed]),t.ad.scale(s,s,[r,r,r*o]),t.ad.translate(s,s,[i.point.x-.5*n,i.point.y-.5*n,0]),t.ad.multiply(s,s,e),t.ad.multiply(s,i.globeMatrix,s)}(e,i);return function(e,i,n){const r=(e,i,n)=>{const r=t._.length(e),o=t._.length(i),s=ku(e,i,n);return t._.scale(s,s,1/t._.length(s)*Vn(r,o,n))},o=r([e[0],e[1],e[2]],[i[0],i[1],i[2]],n),s=r([e[4],e[5],e[6]],[i[4],i[5],i[6]],n),a=r([e[8],e[9],e[10]],[i[8],i[9],i[10]],n),l=ku([e[12],e[13],e[14]],[i[12],i[13],i[14]],n);return[o[0],o[1],o[2],0,s[0],s[1],s[2],0,a[0],a[1],a[2],0,l[0],l[1],l[2],1]}(o,n,r)}return o}function kv(t,e,i,n){const r=wu.projectAabbCorners(n,i);let o=Number.MAX_VALUE,s=-1;for(let t=0;tnew Ue(r[t][0],r[t][1]);let l;switch(s){case 0:case 6:l=[a(1),a(5),a(4),a(7),a(3),a(2),a(1)];break;case 1:case 7:l=[a(0),a(4),a(5),a(6),a(2),a(3),a(0)];break;case 3:case 5:l=[a(1),a(0),a(4),a(7),a(6),a(2),a(1)];break;default:l=[a(1),a(5),a(6),a(7),a(3),a(0),a(1)]}if(Yd(t,l))return o}const Dv=Ll([{name:"a_pos_3f",components:3,type:"Float32"}]),zv=Ll([{name:"a_color_3f",components:3,type:"Float32"}]),Rv=Ll([{name:"a_color_4f",components:4,type:"Float32"}]),Ov=Ll([{name:"a_uv_2f",components:2,type:"Float32"}]),Bv=Ll([{name:"a_normal_3f",components:3,type:"Float32"}]),Fv=Ll([{name:"a_normal_matrix0",components:4,type:"Float32"},{name:"a_normal_matrix1",components:4,type:"Float32"},{name:"a_normal_matrix2",components:4,type:"Float32"},{name:"a_normal_matrix3",components:4,type:"Float32"}]),Nv=Ll([{name:"a_pbr",components:4,type:"Uint16"},{name:"a_heightBasedEmissiveStrength",components:3,type:"Float32"}]);class Uv{constructor(t,e,i,n){this.message=(t?`${t}: `:"")+i,n&&(this.identifier=n),null!=e&&e.__line__&&(this.line=e.__line__)}}function jv(t,e){const i=-1===t.indexOf("://");try{return new URL(t,i&&e?"http://example.com":void 0),!0}catch(t){return!1}}class Vv{constructor(t,e){this.feature=t,this.instancedDataOffset=e,this.instancedDataCount=0,this.rotation=[0,0,0],this.scale=[1,1,1],this.translation=[0,0,0]}}class Gv{constructor(){this.instancedDataArray=new oc,this.instancesEvaluatedElevation=[],this.features=[],this.idToFeaturesIndex={}}}class Zv{constructor(t){this.zoom=t.zoom,this.canonical=t.canonical,this.layers=t.layers,this.layerIds=this.layers.map((t=>t.fqid)),this.projection=t.projection,this.index=t.index,this.hasZoomDependentProperties=this.layers[0].isZoomDependent(),this.stateDependentLayerIds=this.layers.filter((t=>t.isStateDependent())).map((t=>t.id)),this.hasPattern=!1,this.instancesPerModel={},this.validForExaggeration=0,this.maxVerticalOffset=0,this.maxScale=0,this.maxHeight=0,this.lookupDim=this.zoom>this.canonical.z?256:this.zoom>15?75:100,this.instanceCount=0,this.terrainElevationMin=0,this.terrainElevationMax=0,this.validForDEMTile={id:null,timestamp:0},this.modelUris=[],this.modelsRequested=!1,this.activeReplacements=[],this.replacementUpdateTime=0}updateFootprints(t,e){}populate(t,e,i,n){this.tileToMeter=zd(i);const r=this.layers[0]._featureFilter.needGeometry;this.lookup=new Uint8Array(this.lookupDim*this.lookupDim);for(const{feature:o,id:s,index:a,sourceLayerIndex:l}of t){const t=null!=s?s:o.properties&&o.properties.hasOwnProperty("id")?o.properties.id:void 0,c=Zd(o,r);if(!this.layers[0]._featureFilter.filter(new Ha(this.zoom),c,i))continue;const d={id:t,sourceLayerIndex:l,index:a,geometry:r?c.geometry:Gd(o,i,n),properties:o.properties,type:o.type,patterns:{}},u=this.addFeature(d,d.geometry,c);u&&e.featureIndex.insert(o,d.geometry,a,l,this.index,this.instancesPerModel[u].instancedDataArray.length,uo/32)}this.lookup=null}update(t,e,i,n){for(const e in this.instancesPerModel){const i=this.instancesPerModel[e];for(const e in t)i.idToFeaturesIndex.hasOwnProperty(e)&&(this.evaluate(i.features[i.idToFeaturesIndex[e]],t[e],i,!0),this.uploaded=!1)}this.maxHeight=0}updateZoomBasedPaintProperties(){if(!this.hasZoomDependentProperties)return!1;let e=!1;for(const i in this.instancesPerModel){const n=this.instancesPerModel[i];for(const i of n.features){const r=this.layers[0],o=i.feature,s=this.canonical,a=r.paint.get("model-rotation").evaluate(o,{},s),l=r.paint.get("model-scale").evaluate(o,{},s),c=r.paint.get("model-translation").evaluate(o,{},s);t._.exactEquals(i.rotation,a)&&t._.exactEquals(i.scale,l)&&t._.exactEquals(i.translation,c)||(this.evaluate(i,i.featureStates,n,!0),e=!0)}}return e}updateReplacement(t,e,i){if(e.updateTime===this.replacementUpdateTime)return!1;this.replacementUpdateTime=e.updateTime;const n=e.getReplacementRegionsForTile(t.toUnwrapped(),!0);if(Pp(this.activeReplacements,n))return!1;this.activeReplacements=n;let r=!1;for(const e in this.instancesPerModel){const n=this.instancesPerModel[e],o=n.instancedDataArray;for(const e of n.features){const n=e.instancedDataOffset,s=e.instancedDataCount;for(let e=0;euo?a-uo:a;const l=Math.floor(a),c=o.float32[s+1];let d=!1;for(const e of this.activeReplacements)if(!(e.orderl||l>e.max.x||e.min.y>c||c>e.max.y)&&(d=Op(Rp(l,c,t.canonical,e.footprintTileId.canonical),e),d))break;o.float32[s]=d?a+uo:a,r=r||d}}}return r}isEmpty(){for(const t in this.instancesPerModel)if(0!==this.instancesPerModel[t].instancedDataArray.length)return!1;return!0}uploadPending(){return!this.uploaded}upload(t){if(!this.uploaded)for(const e in this.instancesPerModel){const i=this.instancesPerModel[e];i.instancedDataArray.length=uo||e.y=uo)continue;const t=(this.lookupDim-1)/uo,i=this.lookupDim*(e.y*t|0)+e.x*t|0;if(this.lookup){if(0!==this.lookup[i])continue;this.lookup[i]=1}this.instanceCount++;const n=s.length;s.resize(n+1),o.instancesEvaluatedElevation.push(0),s.float32[16*n]=e.x,s.float32[16*n+1]=e.y}return a.instancedDataCount=o.instancedDataArray.length-a.instancedDataOffset,a.instancedDataCount>0&&(t.id&&(o.idToFeaturesIndex[t.id]=o.features.length),o.features.push(a),this.evaluate(a,{},o,!1)),r}getModelUris(){return this.modelUris}evaluate(t,e,i,n){const r=this.layers[0],o=t.feature,s=this.canonical,a=t.rotation=r.paint.get("model-rotation").evaluate(o,e,s),l=t.scale=r.paint.get("model-scale").evaluate(o,e,s),c=t.translation=r.paint.get("model-translation").evaluate(o,e,s),d=r.paint.get("model-color").evaluate(o,e,s);d.a=r.paint.get("model-color-mix-intensity").evaluate(o,e,s);const u=[];this.maxVerticalOffset10?this.tileToMeter:zd(s,p)),a[o+4]=c[0],a[o+5]=c[1],a[o+6]=c[2]+l,a[o+7]=u[0],a[o+8]=u[1],a[o+9]=u[2],a[o+10]=u[4],a[o+11]=u[5],a[o+12]=u[6],a[o+13]=u[8],a[o+14]=u[9],a[o+15]=u[10],i.instancesEvaluatedElevation[r]=c[2]}}}ba(Zv,"ModelBucket",{omit:["layers"]}),ba(Gv,"PerModelAttributes"),ba(Vv,"ModelFeature");const qv=new ol({visibility:new il(sl.layout_model.visibility),"model-id":new nl(sl.layout_model["model-id"])});var Hv={paint:new ol({"model-opacity":new il(sl.paint_model["model-opacity"]),"model-rotation":new nl(sl.paint_model["model-rotation"]),"model-scale":new nl(sl.paint_model["model-scale"]),"model-translation":new nl(sl.paint_model["model-translation"]),"model-color":new nl(sl.paint_model["model-color"]),"model-color-mix-intensity":new nl(sl.paint_model["model-color-mix-intensity"]),"model-type":new il(sl.paint_model["model-type"]),"model-cast-shadows":new il(sl.paint_model["model-cast-shadows"]),"model-receive-shadows":new il(sl.paint_model["model-receive-shadows"]),"model-ambient-occlusion-intensity":new il(sl.paint_model["model-ambient-occlusion-intensity"]),"model-emissive-strength":new nl(sl.paint_model["model-emissive-strength"]),"model-roughness":new nl(sl.paint_model["model-roughness"]),"model-height-based-emissive-strength-multiplier":new nl(sl.paint_model["model-height-based-emissive-strength-multiplier"]),"model-cutoff-fade-range":new il(sl.paint_model["model-cutoff-fade-range"]),"model-front-cutoff":new il(sl.paint_model["model-front-cutoff"])}),layout:qv};const Wv=64,Yv={CoordinateSpaceTile:1,CoordinateSpaceYUp:2,HasMapboxMeshFeatures:4,HasMeshoptCompression:8};function Xv(e,i,n,r,o,s,a,l,c,d=!1){const u=n.zoom,h=n.project(r),p=kd(r.lat,u),f=1/p;t.ad.identity(e),t.ad.translate(e,e,[h.x+a[0]*f,h.y+a[1]*f,a[2]]);let m=1,_=1;const g=n.worldSize;if(d){if("mercator"===n.projection.name){let e=0;n.elevation&&(e=n.elevation.getAtPointOrZero(new Rd(h.x/g,h.y/g),0));const i=t.aA.transformMat4([],[h.x,h.y,e,1],n.projMatrix)[3]/n.cameraToCenterDistance;m=i,_=i*kd(n.center.lat,u)}else if("globe"===n.projection.name){const i=$v(e,n),o=t.ad.multiply([],n.projMatrix,i),s=[0,0,0,1];t.aA.transformMat4(s,s,o);const a=s[3]/n.cameraToCenterDistance,l=Hu(u),c=n.projection.pixelsPerMeter(r.lat,g)*kd(r.lat,u),d=n.projection.pixelsPerMeter(n.center.lat,g)*kd(n.center.lat,u);m=a/Vn(c,$d(n.center.lat),l),_=a*p/c,m*=d,_*=d}}else m=f;t.ad.scale(e,e,[m,m,_]);const y=[...e],v=i.orientation,x=[];if(Lv(x,[v[0]+o[0],v[1]+o[1],v[2]+o[2]],s),t.ad.multiply(e,y,x),l&&n.elevation){let o=0;const s=[];if(c&&n.elevation){o=function(e,i,n,r,o){const s=i.elevation;if(!s)return 0;const a=wu.projectAabbCorners(n,r),l=Cd(1,o.lat)*i.worldSize,c=function(e,i){const n=[0,0,1],r=[{corners:[0,1,3,2],dotProductWithUp:0},{corners:[1,5,2,6],dotProductWithUp:0},{corners:[0,4,1,5],dotProductWithUp:0},{corners:[2,6,3,7],dotProductWithUp:0},{corners:[4,7,5,6],dotProductWithUp:0},{corners:[0,3,4,7],dotProductWithUp:0}];for(const o of r){const r=e[o.corners[0]],s=e[o.corners[1]],a=e[o.corners[2]],l=[s[0]-r[0],s[1]-r[1],i*(s[2]-r[2])],c=t._.cross(l,l,[a[0]-r[0],a[1]-r[1],i*(a[2]-r[2])]);t._.normalize(c,c),o.dotProductWithUp=t._.dot(c,n)}return r.sort(((t,e)=>t.dotProductWithUp-e.dotProductWithUp)),r[0].corners}(a,l),d=a[c[0]],u=a[c[1]],h=a[c[2]],p=a[c[3]],f=s.getAtPointOrZero(new Rd(d[0]/i.worldSize,d[1]/i.worldSize),0),m=s.getAtPointOrZero(new Rd(u[0]/i.worldSize,u[1]/i.worldSize),0),_=s.getAtPointOrZero(new Rd(h[0]/i.worldSize,h[1]/i.worldSize),0),g=s.getAtPointOrZero(new Rd(p[0]/i.worldSize,p[1]/i.worldSize),0),y=(f+g)/2,v=(m+_)/2;return y>v?m=e.gl.NEAREST_MIPMAP_NEAREST}),t.uploaded=!0,t.image=null)}function Jv(t,e,i){t.indexBuffer=e.createIndexBuffer(t.indexArray,!1,!0),t.vertexBuffer=e.createVertexBuffer(t.vertexArray,Dv.members,!1,!0),t.normalArray&&(t.normalBuffer=e.createVertexBuffer(t.normalArray,Bv.members,!1,!0)),t.texcoordArray&&(t.texcoordBuffer=e.createVertexBuffer(t.texcoordArray,Ov.members,!1,!0)),t.colorArray&&(t.colorBuffer=e.createVertexBuffer(t.colorArray,(12===t.colorArray.bytesPerElement?zv:Rv).members,!1,!0)),t.featureArray&&(t.pbrBuffer=e.createVertexBuffer(t.featureArray,Nv.members,!0)),t.segments=wc.simpleSegment(0,0,t.vertexArray.length,t.indexArray.length);const n=t.material;n.pbrMetallicRoughness.baseColorTexture&&Kv(n.pbrMetallicRoughness.baseColorTexture,e),n.pbrMetallicRoughness.metallicRoughnessTexture&&Kv(n.pbrMetallicRoughness.metallicRoughnessTexture,e),n.normalTexture&&Kv(n.normalTexture,e),n.occlusionTexture&&Kv(n.occlusionTexture,e,i),n.emissionTexture&&Kv(n.emissionTexture,e)}function Qv(t,e,i){if(t.meshes)for(const n of t.meshes)Jv(n,e,i);if(t.children)for(const n of t.children)Qv(n,e,i)}function tx(t){if(t.meshes)for(const e of t.meshes)e.indexArray.destroy(),e.vertexArray.destroy(),e.colorArray&&e.colorArray.destroy(),e.normalArray&&e.normalArray.destroy(),e.texcoordArray&&e.texcoordArray.destroy(),e.featureArray&&e.featureArray.destroy();if(t.children)for(const e of t.children)tx(e)}function ex(t){if(t.meshes)for(const i of t.meshes)i.vertexBuffer&&(i.vertexBuffer.destroy(),i.indexBuffer.destroy(),i.normalBuffer&&i.normalBuffer.destroy(),i.texcoordBuffer&&i.texcoordBuffer.destroy(),i.colorBuffer&&i.colorBuffer.destroy(),i.pbrBuffer&&i.pbrBuffer.destroy(),i.segments.destroy(),i.material&&((e=i.material).pbrMetallicRoughness.baseColorTexture&&e.pbrMetallicRoughness.baseColorTexture.gfxTexture&&e.pbrMetallicRoughness.baseColorTexture.gfxTexture.destroy(),e.pbrMetallicRoughness.metallicRoughnessTexture&&e.pbrMetallicRoughness.metallicRoughnessTexture.gfxTexture&&e.pbrMetallicRoughness.metallicRoughnessTexture.gfxTexture.destroy(),e.normalTexture&&e.normalTexture.gfxTexture&&e.normalTexture.gfxTexture.destroy(),e.emissionTexture&&e.emissionTexture.gfxTexture&&e.emissionTexture.gfxTexture.destroy(),e.occlusionTexture&&e.occlusionTexture.gfxTexture&&e.occlusionTexture.gfxTexture.destroy()));var e;if(t.children)for(const e of t.children)ex(e)}class ix{constructor(t){this._callback=t,this._triggered=!1,"undefined"!=typeof MessageChannel&&(this._channel=new MessageChannel,this._channel.port2.onmessage=()=>{this._triggered=!1,this._callback()})}trigger(){this._triggered||(this._triggered=!0,this._channel?this._channel.port1.postMessage(!0):setTimeout((()=>{this._triggered=!1,this._callback()}),0))}remove(){this._channel=void 0,this._callback=()=>{}}}class nx{constructor(){this.tasks={},this.taskQueue=[],ai(["process"],this),this.invoker=new ix(this.process),this.nextId=0}add(t,e){const i=this.nextId++,n=function({type:t,isSymbolTile:e,zoom:i}){return i=i||0,"message"===t?0:"maybePrepare"!==t||e?"parseTile"!==t||e?"parseTile"===t&&e?300-i:"maybePrepare"===t&&e?400-i:500:200-i:100-i}(e);if(0===n){try{t()}finally{}return null}return this.tasks[i]={fn:t,metadata:e,priority:n,id:i},this.taskQueue.push(i),this.invoker.trigger(),{cancel:()=>{delete this.tasks[i]}}}process(){try{if(this.taskQueue=this.taskQueue.filter((t=>!!this.tasks[t])),!this.taskQueue.length)return;const t=this.pick();if(null===t)return;const e=this.tasks[t];if(delete this.tasks[t],this.taskQueue.length&&this.invoker.trigger(),!e)return;e.fn()}finally{}}pick(){let t=null,e=1/0;for(let i=0;i{i&&delete this.callbacks[s],this.target.postMessage({id:s,type:"",targetMapId:n,sourceMapId:this.mapId})}}}receive(t){const e=t.data,i=e.id;if(i&&(!e.targetMapId||this.mapId===e.targetMapId))if(""===e.type){const t=this.cancelCallbacks[i];delete this.cancelCallbacks[i],t&&t.cancel()}else if(e.mustQueue||gi()){const t=this.callbacks[i],n=this.scheduler.add((()=>this.processTask(i,e)),t&&t.metadata||{type:"message"});n&&(this.cancelCallbacks[i]=n)}else this.processTask(i,e)}processTask(t,e){if(delete this.cancelCallbacks[t],""===e.type){const i=this.callbacks[t];delete this.callbacks[t],i&&(e.error?i(Ea(e.error)):i(null,Ea(e.data)))}else{const i=new Set,n=e.hasCallback?(e,n)=>{this.target.postMessage({id:t,type:"",sourceMapId:this.mapId,error:e?Sa(e):null,data:Sa(n,i)},i)}:t=>{},r=Ea(e.data);if(this.parent[e.type])this.parent[e.type](e.sourceMapId,r,n);else if(this.parent.getWorkerSource){const t=e.type.split(".");this.parent.getWorkerSource(e.sourceMapId,t[0],r.source,r.scope)[t[1]](r,n)}else n(new Error(`Could not find function ${e.type}`))}}remove(){this.scheduler.remove(),this.target.removeEventListener("message",this.receive,!1)}}class ox{constructor(t,e){this.workerPool=t,this.actors=[],this.currentActor=0,this.id=ni();const i=this.workerPool.acquire(this.id);for(let t=0;t{this.ready=!0}))}broadcast(t,e,i){Qe(this.actors,((i,n)=>{i.send(t,e,n)}),i=i||function(){})}getActor(){return this.currentActor=(this.currentActor+1)%this.actors.length,this.actors[this.currentActor]}remove(){this.actors.forEach((t=>{t.remove()})),this.actors=[],this.workerPool.release(this.id)}}ox.Actor=rx;var sx={workerUrl:"",workerClass:null,workerParams:void 0};function ax(){return null!=sx.workerClass?new sx.workerClass:new self.Worker(sx.workerUrl,sx.workerParams)}const lx="mapboxgl_preloaded_worker_pool";class cx{constructor(){this.active={}}acquire(t){if(!this.workers)for(this.workers=[];this.workers.length{t.terminate()})),this.workers=null)}isPreloaded(){return!!this.active[lx]}numActive(){return Object.keys(this.active).length}}let dx;function ux(){return dx||(dx=new cx),dx}cx.workerCount=2;let hx,px,fx,mx,_x,gx=null;function yx(){return gi()&&self.worker&&self.worker.dracoUrl?self.worker.dracoUrl:px||n.DRACO_URL}function vx(){if(gi()&&self.worker&&self.worker.meshoptUrl)return self.worker.meshoptUrl;if(mx)return mx;const t=new Uint8Array([0,97,115,109,1,0,0,0,1,4,1,96,0,0,3,3,2,0,0,5,3,1,0,1,12,1,0,10,22,2,12,0,65,0,65,0,65,0,252,10,0,0,11,7,0,65,0,253,15,26,11]);if("object"!=typeof WebAssembly)throw new Error("WebAssembly not supported, cannot instantiate meshoptimizer");return mx=WebAssembly.validate(t)?n.MESHOPT_SIMD_URL:n.MESHOPT_URL,mx}const xx={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},bx={5120:"DT_INT8",5121:"DT_UINT8",5122:"DT_INT16",5123:"DT_UINT16",5125:"DT_UINT32",5126:"DT_FLOAT32"},wx={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16};function Tx(t,e,i){const n=i.json.bufferViews.length,r=i.buffers.length;e.bufferView=n,i.json.bufferViews[n]={buffer:r,byteLength:t.byteLength},i.buffers[r]=t}const Sx="KHR_draco_mesh_compression";function Ex(t,e){const i=t.extensions&&t.extensions[Sx];if(!i)return;const n=new fx.Decoder,r=$x(e,i.bufferView),o=new fx.Mesh;if(!n.DecodeArrayToMesh(r,r.byteLength,o))throw new Error("Failed to decode Draco mesh");const s=e.json.accessors[t.indices],a=xx[s.componentType],l=s.count*a.BYTES_PER_ELEMENT,c=fx._malloc(l);a===Uint16Array?n.GetTrianglesUInt16Array(o,l,c):n.GetTrianglesUInt32Array(o,l,c),Tx(fx.memory.buffer.slice(c,c+l),s,e),fx._free(c);for(const r of Object.keys(i.attributes)){const s=n.GetAttributeByUniqueId(o,i.attributes[r]),a=e.json.accessors[t.attributes[r]],l=bx[a.componentType],c=a.count*wx[a.type]*xx[a.componentType].BYTES_PER_ELEMENT,d=fx._malloc(c);n.GetAttributeDataArrayForAllPoints(o,s,fx[l],c,d),Tx(fx.memory.buffer.slice(d,d+c),a,e),fx._free(d)}n.destroy(),o.destroy(),delete t.extensions[Sx]}const Mx="EXT_meshopt_compression";function Cx(t,e){if(!t.extensions||!t.extensions[Mx])return;const i=t.extensions[Mx],n=new Uint8Array(e.buffers[i.buffer],i.byteOffset||0,i.byteLength||0),r=new Uint8Array(i.count*i.byteStride);_x.decodeGltfBuffer(r,i.count,i.byteStride,n,i.mode,i.filter),t.buffer=e.buffers.length,t.byteOffset=0,e.buffers[t.buffer]=r.buffer,delete t.extensions[Mx]}const Ax=1179937895,Ix=new TextDecoder("utf8");function Lx(t,e){return new URL(t,e).href}function Px(t,e,i,n){return fetch(Lx(t.uri,n)).then((t=>t.arrayBuffer())).then((t=>{e.buffers[i]=t}))}function $x(t,e){const i=t.json.bufferViews[e];return new Uint8Array(t.buffers[i.buffer],i.byteOffset||0,i.byteLength)}function kx(t,e,i,n){if(t.uri){const r=Lx(t.uri,n);return fetch(r).then((t=>t.blob())).then((t=>createImageBitmap(t))).then((t=>{e.images[i]=t}))}if(void 0!==t.bufferView){const n=$x(e,t.bufferView),r=new Blob([n],{type:t.mimeType});return createImageBitmap(r).then((t=>{e.images[i]=t}))}}function Dx(t,e=0,i){const n={json:null,images:[],buffers:[]};if(new Uint32Array(t,e,1)[0]===Ax){const i=new Uint32Array(t,e);let r=2;const o=(i[r++]>>2)-3,s=i[r++]>>2;if(r++,n.json=JSON.parse(Ix.decode(i.subarray(r,r+s))),r+=s,r{const t=[],e=a&&a.includes(Sx),r=a&&a.includes(Mx);if(e&&t.push(function(){if(!fx)return hx||(hx=function(t){let e,i=null;function n(){e=new Uint8Array(i.buffer)}function r(){throw new Error("Unexpected Draco error.")}const o={a:{a:r,d:function(t,i,n){return e.copyWithin(t,i,i+n)},c:function(t){const r=e.length,o=Math.max(t>>>0,Math.ceil(1.2*r)),s=Math.ceil((o-r)/65536);try{return i.grow(s),n(),!0}catch(t){return!1}},b:r}};return(WebAssembly.instantiateStreaming?WebAssembly.instantiateStreaming(t,o):t.then((t=>t.arrayBuffer())).then((t=>WebAssembly.instantiate(t,o)))).then((t=>{const{Rb:r,Qb:o,P:s,T:a,X:l,Ja:c,La:d,Qa:u,Va:h,Wa:p,eb:f,jb:m,f:_,e:g,yb:y,zb:v,Ab:x,Bb:b,Db:w,Gb:T}=t.instance.exports;i=g;const S=(()=>{let t=0,i=0,n=0,s=0;return a=>{n&&(r(s),r(t),i+=n,n=t=0),t||(i+=128,t=o(i));const l=a.length+7&-8;let c=t;l>=i&&(n=l,c=s=o(l));for(let t=0;t{fx=t,hx=void 0})))}()),r&&t.push(function(){if(_x)return;const t=function(t){let e;const i=WebAssembly.instantiateStreaming(t,{}).then((t=>{e=t.instance,e.exports.__wasm_call_ctors()})),n={NONE:"",OCTAHEDRAL:"meshopt_decodeFilterOct",QUATERNION:"meshopt_decodeFilterQuat",EXPONENTIAL:"meshopt_decodeFilterExp"},r={ATTRIBUTES:"meshopt_decodeVertexBuffer",TRIANGLES:"meshopt_decodeIndexBuffer",INDICES:"meshopt_decodeIndexSequence"};return{ready:i,supported:!0,decodeGltfBuffer(t,i,o,s,a,l){!function(t,e,i,n,r,o,s){const a=t.exports.sbrk,l=n+3&-4,c=a(l*r),d=a(o.length),u=new Uint8Array(t.exports.memory.buffer);u.set(o,d);const h=e(c,n,r,d,o.length);if(0===h&&s&&s(c,l,r),i.set(u.subarray(c,c+n*r)),a(c-a(0)),0!==h)throw new Error(`Malformed buffer data: ${h}`)}(e,e.exports[r[a]],t,i,o,s,e.exports[n[l]])}}}(fetch(vx()));return t.ready.then((()=>{_x=t}))}()),o)for(let e=0;e{if(e&&s)for(const{primitives:t}of s)for(const e of t)Ex(e,n);if(r&&s&&l)for(const t of l)Cx(t,n);return n}))}))}function zx(t,e){const i=t.json.bufferViews[e.bufferView],n=xx[e.componentType];return new n(t.buffers[i.buffer],(e.byteOffset||0)+(i.byteOffset||0),e.count*(i.byteStride&&i.byteStride!==wx[e.type]*n.BYTES_PER_ELEMENT?i.byteStride/n.BYTES_PER_ELEMENT:wx[e.type]))}function Rx(t,e,i,n){const r=xx[e.componentType],o=function(t){switch(t){case Int8Array:return 1/127;case Uint8Array:return 1/255;case Int16Array:return 1/32767;case Uint16Array:return 1/65535;default:return 1}}(r),s=t.json.bufferViews[e.bufferView],a=s.byteStride?s.byteStride/r.BYTES_PER_ELEMENT:wx[e.type],l=i.float32,c=l.length/i.capacity;for(let t=0,i=0;t0){for(let r=0;r0){o.texcoordArray=new ic;const t=e.json.accessors[r.TEXCOORD_0];o.texcoordArray.resize(t.count);const i=zx(e,t);Rx(e,t,o.texcoordArray,i)}if(void 0!==r._FEATURE_ID_RGBA4444){const t=e.json.accessors[r._FEATURE_ID_RGBA4444];e.json.extensionsUsed&&e.json.extensionsUsed.includes("EXT_meshopt_compression")&&(o.featureData=zx(e,t))}void 0!==r._FEATURE_RGBA4444&&(o.featureData=new Uint32Array(zx(e,e.json.accessors[r._FEATURE_RGBA4444]).buffer));const u=t.material;return o.material=function(t,e){const{emissiveFactor:i=[0,0,0],alphaMode:n="OPAQUE",alphaCutoff:r=.5,normalTexture:o,occlusionTexture:s,emissiveTexture:a,doubleSided:l}=t,{baseColorFactor:c=[1,1,1,1],metallicFactor:d=1,roughnessFactor:u=1,baseColorTexture:h,metallicRoughnessTexture:p}=t.pbrMetallicRoughness||{},f=s?e[s.index]:void 0;if(s&&s.extensions&&s.extensions.KHR_texture_transform&&f){const t=s.extensions.KHR_texture_transform;f.offsetScale=[t.offset[0],t.offset[1],t.scale[0],t.scale[1]]}return{pbrMetallicRoughness:{baseColorFactor:new Un(...c),metallicFactor:d,roughnessFactor:u,baseColorTexture:h?e[h.index]:void 0,metallicRoughnessTexture:p?e[p.index]:void 0},doubleSided:l,emissiveFactor:i,alphaMode:n,alphaCutoff:r,normalTexture:o?e[o.index]:void 0,occlusionTexture:f,emissionTexture:a?e[a.index]:void 0,defined:void 0===t.defined}}(void 0!==u?e.json.materials[u]:{defined:!1},i),o}function Bx(e,i,n){const{matrix:r,rotation:o,translation:s,scale:a,mesh:l,extras:c,children:d}=e,u={};if(u.matrix=r||t.ad.fromRotationTranslationScale([],o||[0,0,0,1],s||[0,0,0],a||[1,1,1]),void 0!==l){u.meshes=n[l];const t=u.anchor=[0,0];for(const e of u.meshes){const{min:i,max:n}=e.aabb;t[0]+=i[0]+n[0],t[1]+=i[1]+n[1]}t[0]=Math.floor(t[0]/u.meshes.length/2),t[1]=Math.floor(t[1]/u.meshes.length/2)}if(c&&(c.id&&(u.id=c.id),c.lights&&(u.lights=function(t){if(!t.length)return[];const e=function(t){const e=atob(t),i=new Uint8Array(e.length);for(let t=0;t1&&n[n.length-1].equals(n[0])&&n.pop();let r=0;for(let t=0;t0&&n.reverse();const o=xh(n.flatMap((t=>[t.x,t.y])),[]);return 0===o.length?null:{vertices:n,indices:o}}function Ux(e,i){const n=[],r=[];let o=0;const s=[];for(const a of e){o=n.length;const e=a.vertexArray.float32,l=a.indexArray.uint16;for(let r=0;r0&&([r[t+1],r[t+2]]=[r[t+2],r[t+1]])}return{vertices:n,indices:r}}function jx(t){const e=function(t,e){const i=[],n=WebGL2RenderingContext;if(t.json.textures)for(const r of t.json.textures){const o={magFilter:n.LINEAR,minFilter:n.NEAREST,wrapS:n.REPEAT,wrapT:n.REPEAT};void 0!==r.sampler&&Object.assign(o,t.json.samplers[r.sampler]),i.push({image:e[r.source],sampler:o,uploaded:!1})}return i}(t,t.images),i=function(t,e){const i=[];for(const n of t.json.meshes){const r=[];for(const i of n.primitives)r.push(Ox(i,t,e));i.push(r)}return i}(t,e),{scenes:n,scene:r,nodes:o}=t.json,s=n?n[r||0].nodes:o,a=[];for(const e of s)a.push(Bx(o[e],t,i));return function(t,e,i){const n={},r=new Set;for(let o=0;o0){const e=Array.from(r.values()).sort(((t,e)=>t-e));for(let i=e.length-1;i>=0;i--)t.splice(e[i],1)}}(a,s,t.json.nodes),a}function Vx(t){t.heightmap=new Float32Array(4096),t.heightmap.fill(-1);const e=t.vertexArray.float32,i=t.aabb.min[0]-1,n=t.aabb.min[1]-1,r=Wv/(t.aabb.max[0]-i+2),o=Wv/(t.aabb.max[1]-n+2);for(let s=0;st.heightmap[c*Wv+l]&&(t.heightmap[c*Wv+l]=a)}}function Gx(e,i){const n={};n.indexArray=new Kl,n.indexArray.reserve(4*e.length),n.vertexArray=new Bl,n.vertexArray.reserve(10*e.length),n.colorArray=new Ol,n.vertexArray.reserve(10*e.length);let r=0;for(const o of e){const e=Math.min(10,Math.max(4,1.3*o.height))*i,s=[-o.normal[1],o.normal[0],0],a=Math.min(.29,.1*o.width/o.depth),l=o.width-2*o.depth*i*(a+.01),c=t._.scaleAndAdd([],o.pos,s,l/2),d=t._.scaleAndAdd([],o.pos,s,-l/2),u=[c[0],c[1],c[2]+o.height],h=[d[0],d[1],d[2]+o.height],p=t._.scaleAndAdd([],o.normal,s,a);t._.scale(p,p,e);const f=t._.scaleAndAdd([],o.normal,s,-a);t._.scale(f,f,e),t._.add(p,c,p),t._.add(f,d,f),c[2]+=.1,d[2]+=.1,n.vertexArray.emplaceBack(p[0],p[1],p[2]),n.vertexArray.emplaceBack(f[0],f[1],f[2]),n.vertexArray.emplaceBack(c[0],c[1],c[2]),n.vertexArray.emplaceBack(d[0],d[1],d[2]),n.vertexArray.emplaceBack(u[0],u[1],u[2]),n.vertexArray.emplaceBack(h[0],h[1],h[2]),n.vertexArray.emplaceBack(c[0],c[1],c[2]),n.vertexArray.emplaceBack(d[0],d[1],d[2]),n.vertexArray.emplaceBack(p[0],p[1],p[2]),n.vertexArray.emplaceBack(f[0],f[1],f[2]);const m=l/e/2;n.colorArray.emplaceBack(-m-a,-1,m,.8),n.colorArray.emplaceBack(m+a,-1,m,.8),n.colorArray.emplaceBack(-m,0,m,1.3),n.colorArray.emplaceBack(m,0,m,1.3),n.colorArray.emplaceBack(m+a,-.8,m,.7),n.colorArray.emplaceBack(m+a,-.8,m,.7),n.colorArray.emplaceBack(0,0,m,1.3),n.colorArray.emplaceBack(0,0,m,1.3),n.colorArray.emplaceBack(m+a,-1.2,m,.8),n.colorArray.emplaceBack(m+a,-1.2,m,.8),n.indexArray.emplaceBack(6+r,4+r,8+r),n.indexArray.emplaceBack(7+r,9+r,5+r),n.indexArray.emplaceBack(0+r,1+r,2+r),n.indexArray.emplaceBack(1+r,3+r,2+r),r+=10}const o={defined:!0,emissiveFactor:[0,0,0]},s={};return s.baseColorFactor=Un.white,o.pbrMetallicRoughness=s,n.material=o,n.aabb=new wu([1/0,1/0,1/0],[-1/0,-1/0,-1/0]),n}const Zx=new Float32Array(262144),qx=new Uint8Array(262144);function Hx(t){let e=0;if(t.meshes)for(const i of t.meshes)e=Math.max(e,i.aabb.max[2]);if(t.children)for(const i of t.children)e=Math.max(e,Hx(i));return e}function Wx(t,e,i){if(t.meshes)for(const n of t.meshes)n.aabb.min[0]!==1/0&&i.insert(e,n.aabb.min[0],n.aabb.min[1],n.aabb.max[0],n.aabb.max[1]);if(t.children)for(const n of t.children)Wx(n,e,i)}const Yx=["","wall","door","roof","window","lamp","logo"];class Xx{constructor(t){this.node=t,this.evaluatedRMEA=[[1,0,0,1],[1,0,0,1],[1,0,0,1],[1,0,0,1],[.4,1,0,1],[1,0,0,1],[1,0,0,1]],this.hiddenByReplacement=!1,this.evaluatedScale=[1,1,1],this.evaluatedColor=[],this.emissionHeightBasedParams=[],this.feature={type:"Point",id:t.id,geometry:[],properties:{height:Hx(t)}},this.aabb=this._getLocalBounds()}_getLocalBounds(){if(!this.node.meshes)return new wu([1/0,1/0,1/0],[-1/0,-1/0,-1/0]);if(!this.aabb){let t=0;const e=new wu([1/0,1/0,1/0],[-1/0,-1/0,-1/0]);for(const i of this.node.meshes)this.node.lightMeshIndex!==t&&(i.transformedAabb=wu.applyTransformFast(i.aabb,this.node.matrix),e.encapsulate(i.transformedAabb)),t++;this.aabb=e}return this.aabb}}class Kx{constructor(t,e,i,n,r,o){this.id=e,this.modelTraits|=Yv.CoordinateSpaceTile,this.uploaded=!1,this.hasPattern=!1,i&&(this.modelTraits|=Yv.HasMapboxMeshFeatures),n&&(this.modelTraits|=Yv.HasMeshoptCompression),this.zoom=-1,this.terrainExaggeration=1,this.projection={name:"mercator"},this.replacementUpdateTime=0,this.elevationReadFromZ=255,this.brightness=r,this.dirty=!0,this.needsUpload=!1,this.nodesInfo=[];for(const e of t)this.nodesInfo.push(new Xx(e)),Wx(e,o.featureIndexArray.length,o.grid),o.featureIndexArray.emplaceBack(this.nodesInfo.length-1,0,o.bucketLayerIDs.length-1,0)}updateFootprints(t,e){for(const i of this.getNodesInfo()){const n=i.node;n.footprint&&e.push({footprint:n.footprint,id:t})}}update(){console.log("Update 3D model bucket")}populate(){console.log("populate 3D model bucket")}uploadPending(){return!this.uploaded||this.needsUpload}upload(t){if(!this.needsUpload)return;const e=this.getNodesInfo();for(const i of e){const e=i.node;this.uploaded?this.updatePbrBuffer(e):Qv(e,t,!0)}for(const t of e)tx(t.node);this.uploaded=!0,this.needsUpload=!1}updatePbrBuffer(t){let e=!1;if(!t.meshes)return e;for(const i of t.meshes)i.pbrBuffer&&(i.pbrBuffer.updateData(i.featureArray),e=!0);return e}needsReEvaluation(t,e,i){const n=t.transform.projectionOptions,r=t.style.getBrightness(),o=this.brightness!==r;return!!(!this.uploaded||this.dirty||n.name!==this.projection.name||Jx(i.paint.get("model-color").value,o)||Jx(i.paint.get("model-color-mix-intensity").value,o)||Jx(i.paint.get("model-roughness").value,o)||Jx(i.paint.get("model-emissive-strength").value,o)||Jx(i.paint.get("model-height-based-emissive-strength-multiplier").value,o))&&(this.projection=n,this.brightness=r,!0)}evaluateScale(t,e){if(t.transform.zoom===this.zoom)return;this.zoom=t.transform.zoom;const i=this.getNodesInfo(),n=this.id.canonical;for(const t of i){const i=t.feature;t.evaluatedScale=e.paint.get("model-scale").evaluate(i,{},n)}}evaluate(t){const e=this.getNodesInfo();for(const i of e){if(!i.node.meshes)continue;const e=i.feature,n=i.node.meshes&&i.node.meshes[0].featureData,r=i.evaluatedColor[2],o=i.evaluatedRMEA[2],s=this.id.canonical;if(i.hasTranslucentParts=!1,n){for(let n=0;n=t)continue;const u=Zx[c],h=Math.abs(u);h>a&&(s=u,a=h,l=r,d=e)}if(a>.1){const o=1-(t+.5*Math.abs(l*d))/c;let a=e._dem.get(n,i)+s*o;const u=e._dem.get(n+l,i+d),h=e._dem.get(n-l,i-d,!0);(a-u)*(a-h)>0&&(a=(u+h)/2),Zx[r]=e._dem.set(n,i,a),qx[r]=t}}}}}s&&(e._demTile.needsDEMTextureUpload=!0,e._dem._timestamp=ki.now())}getNodesInfo(){return this.nodesInfo}destroy(){const t=this.getNodesInfo();for(const e of t)tx(e.node),ex(e.node)}isEmpty(){return!this.nodesInfo.length}updateReplacement(t,e){if(e.updateTime===this.replacementUpdateTime)return;this.replacementUpdateTime=e.updateTime;const i=e.getReplacementRegionsForTile(t.toUnwrapped()),n=this.getNodesInfo();for(let t=0;tt.footprint===e.footprint))}}getHeightAtTileCoord(e,i){const n=this.getNodesInfo(),r=[],o=[0,0,0],s=t.ad.identity([]);for(let a=0;ad.max[0]||i>d.max[1])continue;if(!0===l.node.hidden)return{height:0,maxHeight:l.feature.properties.height,hidden:!1,verticalScale:l.evaluatedScale[2]};t.ad.invert(s,l.node.matrix),o[0]=e,o[1]=i,t._.transformMat4(o,o,s);const u=(o[0]-c.aabb.min[0])/(c.aabb.max[0]-c.aabb.min[0])*Wv|0,h=Math.min(63,(o[1]-c.aabb.min[1])/(c.aabb.max[1]-c.aabb.min[1])*Wv|0)*Wv+Math.min(63,u),p=c.heightmap[h];if(!(p0)return{height:void 0,maxHeight:l.feature.properties.height,hidden:l.hiddenByReplacement,verticalScale:l.evaluatedScale[2]}}}}function Jx(t,e){return!t.isLightConstant&&e}function Qx(t,e,i,n,r,o,s,a){let l=(61440&e|(61440&e)>>4)>>8,c=(3840&e|(3840&e)>>4)>>4,d=240&e|(240&e)>>4;i[3]>0&&(l=Vn(l,255*i[0],i[3]),c=Vn(c,255*i[1],i[3]),d=Vn(d,255*i[2],i[3]));const u=l>16&65535,a=o?e>>16&65535:65535&e,l=(15&a)t.polygon)).flat());const g=f?l:null,[y,v]=function(e,i,n,r,o,s,a,l,c,d,u){return"globe"===e.projection.name?function(e,i,n,r,o,s,a,l,c,d,u){const h=[],p=[],f=e.projection.upVectorScale(u,e.center.lat,e.worldSize).metersToTile,m=[0,0,0,1],_=[0,0,0,1],g=(t,e,i,n)=>{t[0]=e,t[1]=i,t[2]=n,t[3]=1},y=Sf();n>0&&(n+=y),r+=y;for(const y of i){const i=[],v=[];for(const h of y){const p=h.x+o.x,y=h.y+o.y,x=e.projection.projectTilePoint(p,y,u),b=e.projection.upVector(u,h.x,h.y);let w=n,T=r;if(a){const t=Pf(p,y,n,r,a,l,c,d);w+=t.base,T+=t.top}0!==n?g(m,x.x+b[0]*f*w,x.y+b[1]*f*w,x.z+b[2]*f*w):g(m,x.x,x.y,x.z),g(_,x.x+b[0]*f*T,x.y+b[1]*f*T,x.z+b[2]*f*T),t._.transformMat4(m,m,s),t._.transformMat4(_,_,s),i.push(new Tp(m[0],m[1],m[2])),v.push(new Tp(_[0],_[1],_[2]))}h.push(i),p.push(v)}return[h,p]}(e,i,n,r,o,s,a,l,c,d,u):a?function(e,i,n,r,o,s,a,l,c){const d=[],u=[],h=[0,0,0,1];for(const p of e){const e=[],f=[];for(const d of p){const u=d.x+r.x,p=d.y+r.y,m=Pf(u,p,i,n,s,a,l,c);h[0]=u,h[1]=p,h[2]=m.base,h[3]=1,t.aA.transformMat4(h,h,o),h[3]=Math.max(h[3],1e-5);const _=new Tp(h[0]/h[3],h[1]/h[3],h[2]/h[3]);h[0]=u,h[1]=p,h[2]=m.top,h[3]=1,t.aA.transformMat4(h,h,o),h[3]=Math.max(h[3],1e-5);const g=new Tp(h[0]/h[3],h[1]/h[3],h[2]/h[3]);e.push(_),f.push(g)}d.push(e),u.push(f)}return[d,u]}(i,n,r,o,s,a,l,c,d):function(t,e,i,n,r){const o=[],s=[],a=r[8]*e,l=r[9]*e,c=r[10]*e,d=r[11]*e,u=r[8]*i,h=r[9]*i,p=r[10]*i,f=r[11]*i;for(const e of t){const t=[],i=[];for(const o of e){const e=o.x+n.x,s=o.y+n.y,m=r[0]*e+r[4]*s+r[12],_=r[1]*e+r[5]*s+r[13],g=r[2]*e+r[6]*s+r[14],y=r[3]*e+r[7]*s+r[15],v=m+a,x=_+l,b=g+c,w=Math.max(y+d,1e-5),T=m+u,S=_+h,E=g+p,M=Math.max(y+f,1e-5);t.push(new Tp(v/w,x/w,b/w)),i.push(new Tp(T/M,S/M,E/M))}o.push(t),s.push(i)}return[o,s]}(i,n,r,o,s)}(s,r,h,u,d,a,g,p,m,s.center.lat,e.tileID.canonical),x=e.queryGeometry;return function(t,e,i){let n=1/0;Kd(i,e)&&(n=Lf(i,e[0]));for(let r=0;r=3)for(let e=0;e>4;if(1!==n)throw new Error(`Got v${n} data when expected v1.`);const r=nb[15&i];if(!r)throw new Error("Unrecognized array type.");const[o]=new Uint16Array(t,2,1),[s]=new Uint32Array(t,4,1);return new rb(s,o,r,t)}constructor(t,e=64,i=Float64Array,n){if(isNaN(t)||t>1;return this.ids[i]=i,this.coords[this._pos++]=t,this.coords[this._pos++]=e,i}finish(){const t=this._pos>>1;if(t!==this.numItems)throw new Error(`Added ${t} items when expected ${this.numItems}.`);return ob(this.ids,this.coords,this.nodeSize,0,this.numItems-1,0),this._finished=!0,this}range(t,e,i,n){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");const{ids:r,coords:o,nodeSize:s}=this,a=[0,r.length-1,0],l=[];for(;a.length;){const c=a.pop()||0,d=a.pop()||0,u=a.pop()||0;if(d-u=t&&a=e&&c>1,p=o[2*h],f=o[2*h+1];p>=t&&p=e&&f=p:n>=f)&&(a.push(h+1),a.push(d),a.push(1-c))}return l}within(t,e,i){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");const{ids:n,coords:r,nodeSize:o}=this,s=[0,n.length-1,0],a=[],l=i*i;for(;s.length;){const c=s.pop()||0,d=s.pop()||0,u=s.pop()||0;if(d-u>1,p=r[2*h],f=r[2*h+1];cb(p,f,t,e)=p:e+i>=f)&&(s.push(h+1),s.push(d),s.push(1-c))}return a}}function ob(t,e,i,n,r,o){if(r-n>1;sb(t,e,s,n,r,o),ob(t,e,i,n,s-1,1-o),ob(t,e,i,s+1,r,1-o)}function sb(t,e,i,n,r,o){for(;r>n;){if(r-n>600){const s=r-n+1,a=i-n+1,l=Math.log(s),c=.5*Math.exp(2*l/3),d=.5*Math.sqrt(l*c*(s-c)/s)*(a-s/2s&&ab(t,e,n,r);as;)l--}e[2*n+o]===s?ab(t,e,n,l):(l++,ab(t,e,l,r)),lr&&(n+=(t[i]-r)*(t[i]-r)),e[i]0&&n[0]0&&n[1]0&&r[0]0&&r[1]0?Math.acos(i/n)*Ve:0;let o=0!==t||0!==e?Math.atan2(-e,-t)*Ve+90:0;return oNi&&(t.getActor().send("enforceCacheSizeLimit",Fi),Vi=0)},t.an=gn,t.ao=class{constructor(t){this.entries={},this.scheduler=t}request(t,e,i,n){const r=this.entries[t]=this.entries[t]||{callbacks:[]};if(r.result){const[t,i]=r.result;return this.scheduler?this.scheduler.add((()=>{n(t,i)}),e):n(t,i),()=>{}}return r.callbacks.push(n),r.cancel||(r.cancel=i(((i,n)=>{r.result=[i,n];for(const t of r.callbacks)this.scheduler?this.scheduler.add((()=>{t(i,n)}),e):t(i,n);setTimeout((()=>delete this.entries[t]),3e3)}))),()=>{r.result||(r.callbacks=r.callbacks.filter((t=>t!==n)),r.callbacks.length||(r.cancel(),delete this.entries[t]))}}},t.ap=function(t,e,i){const n=JSON.stringify(t.request);return t.data&&(this.deduped.entries[n]={result:[null,t.data]}),this.deduped.request(n,{type:"parseTile",isSymbolTile:t.isSymbolTile,zoom:t.tileZoom},(e=>{const n=en(t.request,((t,n,r,o)=>{t?e(t):n&&e(null,{vectorTile:i?void 0:new bp(new Lm(n)),rawData:n,cacheControl:r,expires:o})}));return()=>{n.cancel(),e()}}),e)},t.aq=Dc,t.ar=class extends Lc{constructor(t){super(t),this.current=Fc}set(t,e,i){if(this.fetchUniformLocation(t,e))for(let t=0;t({u_camera_to_center_distance:new $c(t),u_extrude_scale:new Uc(t),u_device_pixel_ratio:new $c(t),u_matrix:new Bc(t),u_inv_rot_matrix:new Bc(t),u_merc_center:new kc(t),u_tile_id:new Dc(t),u_zoom_transition:new $c(t),u_up_dir:new Dc(t),u_emissive_strength:new $c(t)}),t.bJ=t=>({u_matrix:new Bc(t),u_pixels_to_tile_units:new Uc(t),u_device_pixel_ratio:new $c(t),u_units_to_pixels:new kc(t),u_dash_image:new Pc(t),u_gradient_image:new Pc(t),u_image_height:new $c(t),u_texsize:new kc(t),u_tile_units_to_pixels:new $c(t),u_alpha_discard_threshold:new $c(t),u_trim_offset:new kc(t),u_trim_fade_range:new kc(t),u_trim_color:new zc(t),u_emissive_strength:new $c(t)}),t.bK=t=>({u_matrix:new Bc(t),u_texsize:new kc(t),u_pixels_to_tile_units:new Uc(t),u_device_pixel_ratio:new $c(t),u_image:new Pc(t),u_units_to_pixels:new kc(t),u_tile_units_to_pixels:new $c(t),u_alpha_discard_threshold:new $c(t),u_trim_offset:new kc(t)}),t.bL=Yl,t.bM=Hf,t.bN=Om,t.bO=jm,t.bP=G_,t.bQ=c_,t.bR=th,t.bS=(t,e,i,n,r,o)=>{const s=t.transform,a="globe"===s.projection.name;let l;if("map"===o.paint.get("circle-pitch-alignment"))if(a){const t=Zu(s.zoom,e.canonical)*s._pixelsPerMercatorPixel;l=Float32Array.from([t,0,0,t])}else l=s.calculatePixelsToTileUnitsMatrix(i);else l=new Float32Array([s.pixelsToGLUnits[0],0,0,s.pixelsToGLUnits[1]]);const c={u_camera_to_center_distance:t.transform.getCameraToCenterDistance(s.projection),u_matrix:t.translatePosMatrix(e.projMatrix,i,o.paint.get("circle-translate"),o.paint.get("circle-translate-anchor")),u_device_pixel_ratio:ki.devicePixelRatio,u_extrude_scale:l,u_inv_rot_matrix:Qu,u_merc_center:[0,0],u_tile_id:[0,0,0],u_zoom_transition:0,u_up_dir:[0,0,0],u_emissive_strength:o.paint.get("circle-emissive-strength")};if(a){c.u_inv_rot_matrix=n,c.u_merc_center=r,c.u_tile_id=[e.canonical.x,e.canonical.y,1{const s=t.transform;return{u_matrix:rm(t,e,i,n),u_texsize:e.imageAtlasTexture?e.imageAtlasTexture.size:[0,0],u_pixels_to_tile_units:s.calculatePixelsToTileUnitsMatrix(e),u_device_pixel_ratio:r,u_image:0,u_tile_units_to_pixels:nm(e,s),u_units_to_pixels:[1/s.pixelsToGLUnits[0],1/s.pixelsToGLUnits[1]],u_alpha_discard_threshold:0,u_trim_offset:o}},t.bV=(t,e,i,n,r,o,s)=>{const a=t.transform,l=a.calculatePixelsToTileUnitsMatrix(e);return{u_matrix:rm(t,e,i,n),u_pixels_to_tile_units:l,u_device_pixel_ratio:o,u_units_to_pixels:[1/a.pixelsToGLUnits[0],1/a.pixelsToGLUnits[1]],u_dash_image:0,u_gradient_image:1,u_image_height:r,u_texsize:sm(i)&&e.lineAtlasTexture?e.lineAtlasTexture.size:[0,0],u_tile_units_to_pixels:nm(e,t.transform),u_alpha_discard_threshold:0,u_trim_offset:s,u_trim_fade_range:i.paint.get("line-trim-fade-range"),u_trim_color:i.paint.get("line-trim-color").toRenderColor(i.lut).toArray01(),u_emissive_strength:i.paint.get("line-emissive-strength")}},t.bW=oi,t.bX=mh,t.bY=Sf,t.bZ=bd,t.b_=_f,t.ba=function(t,e,i){const n=Hu(i.zoom),r=t.style.map._antialias,o=e.options.extStandardDerivativesForceOff||t.terrain&&t.terrain.exaggeration()>0;return 0===n&&!r&&!o},t.bb=function(e){const i=e.pixelsPerMeter,n=i/Cd(1,e.center.lat),r=t.ad.identity(new Float64Array(16));return t.ad.translate(r,r,[e.point.x,e.point.y,0]),t.ad.scale(r,r,[n,n,i]),Float32Array.from(r)},t.bc=Ou,t.bd=function(t){const e=Pd-5;t=Xe(t,-e,e)/e*90;const i=Math.pow(Math.abs(Math.sin(Ge(t))),3);return Math.round(i*(sd.length-1))},t.be=function(e,i,n,r){const o=i.getNorth(),s=i.getSouth(),a=i.getWest(),l=i.getEast(),c=10){const e=180/r;t.bC.multiply(f,f,[e/d+1,0,0,0,e/u+1,0,-.5*e/h,.5*e/p,1])}return f[2]=c,f[5]=e.x,f[8]=e.y,f},t.bf=ju,t.bg=$u,t.bh=function(e,i,n){const r=t.ad.identity(new Float64Array(16)),o=(i/(1{}}},t.bo=Gg,t.bp=ai,t.bq=class{isDataAvailableAtPoint(t){const e=this._source();if(this.isUsingMockSource()||!e||t.y1)return!1;const i=e.getSource().maxzoom,n=11)return e;const r=n.getSource().maxzoom,o=1{const s=this.getAtTileOffset(e,o.x,o.y),a=r.upVector(e.canonical,o.x,o.y),l=r.upVectorScale(e.canonical,i,n).metersToTile;return t._.scale(a,a,s*l),a}}getForTilePoints(t,e,i,n){if(this.isUsingMockSource())return!1;const r=Xp.create(this,t,n);return!!r&&(e.forEach((t=>{t[2]=this.exaggeration()*r.getElevationAt(t[0],t[1],i)})),!0)}getMinMaxForTile(t){if(this.isUsingMockSource())return null;const e=this.findDEMTileFor(t);if(!e||!e.dem)return null;const i=e.dem.tree,n=e.tileID,r=1=0?t.slice(0,e):t},t.cV=function(t){return t.indexOf(wl)>=0},t.cW=function(t){const e=t.indexOf(wl);return e>=0?t.slice(e+1):""},t.cX=function(t){const e=[],i=t.id;return void 0===i&&e.push({message:`layers.${i}: missing required property "id"`}),void 0===t.render&&e.push({message:`layers.${i}: missing required method "render"`}),t.renderingMode&&"2d"!==t.renderingMode&&"3d"!==t.renderingMode&&e.push({message:`layers.${i}: property "renderingMode" must be either "2d" or "3d"`}),e},t.cY=function(t,e,i,n){return"custom"===t.type?new vv(t,e):new ib[t.type](t,e,i,n)},t.cZ=di,t.c_=Va,t.ca=1,t.cb=Ag,t.cc=0,t.cd=ec,t.ce=function(t,e,i,n,r){return Xe((t-e)/(i-e)*(r-n)+n,n,r)},t.cf=Ns,t.cg=kd,t.ch=class{constructor(t,e,i,n){this.context=t,this.format=n,this.size=i,this.texture=t.gl.createTexture();const[r,o,s]=this.size,{gl:a}=t;a.bindTexture(a.TEXTURE_3D,this.texture),t.pixelStoreUnpackFlipY.set(!1),t.pixelStoreUnpack.set(1),t.pixelStoreUnpackPremultiplyAlpha.set(!1);let l=this.format,c=a.UNSIGNED_BYTE;this.format===a.DEPTH_COMPONENT&&(l=a.DEPTH_COMPONENT16,c=a.UNSIGNED_SHORT),this.format===a.R8&&(n=a.RED),this.format===a.R32F&&(c=a.FLOAT,n=a.RED),a.texImage3D(a.TEXTURE_3D,0,l,r,o,s,0,n,c,e.data)}bind(t,e){const{context:i}=this,{gl:n}=i;n.bindTexture(n.TEXTURE_3D,this.texture),t!==this.minFilter&&(n.texParameteri(n.TEXTURE_3D,n.TEXTURE_MAG_FILTER,t),n.texParameteri(n.TEXTURE_3D,n.TEXTURE_MIN_FILTER,t),this.minFilter=t),e!==this.wrapS&&(n.texParameteri(n.TEXTURE_3D,n.TEXTURE_WRAP_S,e),n.texParameteri(n.TEXTURE_3D,n.TEXTURE_WRAP_T,e),this.wrapS=e)}destroy(){const{gl:t}=this.context;t.deleteTexture(this.texture),this.texture=null}},t.ci=$v,t.cj=[1,1,1],t.ck=Xp,t.cl=Yv,t.cm=ql,t.cn=ic,t.co=class{constructor(){this._updateTime=0,this._sourceIds=[],this._activeRegions=[],this._prevRegions=[],this._globalClipBounds={min:new Ue(1/0,1/0),max:new Ue(-1/0,-1/0)}}clear(){this._activeRegions.length>0&&++this._updateTime,this._activeRegions=[],this._prevRegions=[]}get updateTime(){return this._updateTime}getReplacementRegionsForTile(t,e=!1){const i=$p(new Ue(0,0),new Ue(uo,uo),t),n=[];if(e&&!Lp(i,this._globalClipBounds))return n;for(const e of this._activeRegions){if(e.hiddenByOverlap)continue;if(!Lp(i,e))continue;const r=kp(e.min,e.max,t);n.push({min:r.min,max:r.max,sourceId:this._sourceIds[e.priority],footprint:e.footprint,footprintTileId:e.tileId,order:e.order,clipMask:e.clipMask})}return n}setSources(t){this._setSources(t.map((t=>({getSourceId:()=>t.cache.id,getFootprints:()=>{const e=[];for(const i of t.cache.getVisibleCoordinates()){const n=t.cache.getTile(i).buckets[t.layer];n&&n.updateFootprints(i.toUnwrapped(),e)}return e},getOrder:()=>t.order,getClipMask:()=>t.clipMask}))))}_addSource(t){const e=t.getFootprints();if(0===e.length)return;const i=t.getOrder(),n=t.getClipMask();for(const t of e){if(!t.footprint)continue;const e=$p(t.footprint.min,t.footprint.max,t.id);this._activeRegions.push({min:e.min,max:e.max,hiddenByOverlap:!1,priority:this._sourceIds.length,tileId:t.id,footprint:t.footprint,order:i,clipMask:n})}this._sourceIds.push(t.getSourceId())}_computeReplacement(){this._activeRegions.sort(((t,e)=>t.priority-e.priority||Ap(t.min,e.min)||Ap(t.max,e.max)));let t=this._activeRegions.length!==this._prevRegions.length;if(!t){let e=0;for(;!t&&e!==this._activeRegions.length;){const i=this._activeRegions[e],n=this._prevRegions[e];t=i.priority!==n.priority||!Ip(i,n)||i.order!==n.order||i.clipMask!==n.clipMask,++e}}if(t){++this._updateTime;for(const t of this._activeRegions)t.order!==1/0&&(this._globalClipBounds.min.x=Math.min(this._globalClipBounds.min.x,t.min.x),this._globalClipBounds.min.y=Math.min(this._globalClipBounds.min.y,t.min.y),this._globalClipBounds.max.x=Math.max(this._globalClipBounds.max.x,t.max.x),this._globalClipBounds.max.y=Math.max(this._globalClipBounds.max.y,t.max.y));const t=t=>{const e=this._activeRegions;if(t>=e.length)return t;const i=e[t].priority;for(;t1){let e=0,i=t(e);for(;e!==i;){let n=e;const r=e;for(;n!==i;){const t=this._activeRegions[n];t.hiddenByOverlap=!1;for(let e=0;e=0;e--)this._addSource(t[e]);this._computeReplacement()}},t.cp=Dl,t.cq=Jg,t.cr=rc,t.cs=class{constructor(t){this._createGrid(t),this._createPoles(t)}destroy(){this._poleIndexBuffer.destroy(),this._gridBuffer.destroy(),this._gridIndexBuffer.destroy(),this._poleNorthVertexBuffer.destroy(),this._poleSouthVertexBuffer.destroy();for(const t of this._poleSegments)t.destroy();for(const t of this._gridSegments)t.withSkirts.destroy(),t.withoutSkirts.destroy()}_fillGridMeshWithLods(t,e){const i=new $l,n=new Kl,r=[],o=t+1+2,s=e[0]+1,a=e[0]+1+(1+e.length),l=(t,e,i)=>{let n=t===o-1?t-2:0===t?t:t-1;return n+=i?24575:0,[n,e]};for(let t=0;tt()))},t.dB=sx,t.dC=yx,t.dD=function(t){px=ki.resolveURL(t),gx||(gx=new ox(ux(),new zn)),gx.broadcast("setDracoUrl",px)},t.dE=vx,t.dF=function(t){mx=ki.resolveURL(t),gx||(gx=new ox(ux(),new zn)),gx.broadcast("setMeshoptUrl",mx)},t.dG=ti,t.dH=ba,t.dI=dh,t.dJ=I_,t.dK=eg,t.dL=dc,t.dM=am,t.dN=Dm,t.dO=Wf,t.dP=ci,t.dQ=E_,t.dR=jg,t.dS=function(t,e,i,n,r,o,s,a,l,c,d){t.createArrays(),t.tilePixelRatio=uo/(512*t.overscaling),t.compareText={},t.iconsNeedLinear=!1;const u=t.layers[0].layout,h=t.layers[0]._unevaluatedLayout._values,p={};if("composite"===t.textSizeData.kind){const{minZoom:e,maxZoom:i}=t.textSizeData;p.compositeTextSizes=[h["text-size"].possiblyEvaluate(new Ha(e),a),h["text-size"].possiblyEvaluate(new Ha(i),a)]}if("composite"===t.iconSizeData.kind){const{minZoom:e,maxZoom:i}=t.iconSizeData;p.compositeIconSizes=[h["icon-size"].possiblyEvaluate(new Ha(e),a),h["icon-size"].possiblyEvaluate(new Ha(i),a)]}p.layoutTextSize=h["text-size"].possiblyEvaluate(new Ha(l+1),a),p.layoutIconSize=h["icon-size"].possiblyEvaluate(new Ha(l+1),a),p.textMaxSize=h["text-size"].possiblyEvaluate(new Ha(18),a);const f="map"===u.get("text-rotation-alignment")&&"point"!==u.get("symbol-placement"),m=u.get("text-size");let _=!1;for(const e of t.features)if(e.icon&&e.icon.nameSecondary){_=!0;break}for(const o of t.features){const l=u.get("text-font").evaluate(o,{},a).join(","),h=m.evaluate(o,{},a),g=p.layoutTextSize.evaluate(o,{},a),y=(p.layoutIconSize.evaluate(o,{},a),{horizontal:{},vertical:void 0}),v=o.text;let x,b=[0,0];if(v){const n=v.toString(),s=u.get("text-letter-spacing").evaluate(o,{},a)*Om,c=u.get("text-line-height").evaluate(o,{},a)*Om,d=Aa(n)?s:0,p=u.get("text-anchor").evaluate(o,{},a),m=u.get("text-variable-anchor");if(!m){const t=u.get("text-radial-offset").evaluate(o,{},a);b=t?G_(p,[t*Om,j_]):u.get("text-offset").evaluate(o,{},a).map((t=>t*Om))}let _=f?"center":u.get("text-justify").evaluate(o,{},a);const x="point"===u.get("symbol-placement"),w=x?u.get("text-max-width").evaluate(o,{},a)*Om:1/0,T=o=>{t.allowVerticalPlacement&&Ca(n)&&(y.vertical=e_(v,e,i,r,l,w,c,p,o,d,b,Jm.vertical,!0,g,h))};if(!f&&m){const t="auto"===_?m.map((t=>Z_(t))):[_];let n=!1;for(let o=0;o=0||!Ca(n)){const t=e_(v,e,i,r,l,w,c,p,_,d,b,Jm.horizontal,!1,g,h);t&&(y.horizontal[_]=t)}T(x?"left":_)}}let w=!1;if(o.icon&&o.icon.namePrimary){const e=n[o.icon.namePrimary];e&&(x=u_(r[o.icon.namePrimary],o.icon.nameSecondary?r[o.icon.nameSecondary]:void 0,u.get("icon-offset").evaluate(o,{},a),u.get("icon-anchor").evaluate(o,{},a)),w=e.sdf,void 0===t.sdfIcons?t.sdfIcons=e.sdf:t.sdfIcons!==e.sdf&&pi("Style sheet warning: Cannot mix SDF and non-SDF icons in one buffer"),(e.pixelRatio!==t.pixelRatio||0!==u.get("icon-rotate").constantOr(1))&&(t.iconsNeedLinear=!0))}const T=X_(y.horizontal)||y.vertical;t.iconsInText||(t.iconsInText=!!T&&T.iconsInText),(T||x)&&q_(t,o,y,x,n,p,g,0,b,w,s,a,c,d,_)}o&&t.generateCollisionDebugBuffers(l,t.collisionBoxArray)},t.dT=Jf,t.dU=Yh,t.dV=bp,t.dW=Lm,t.dX=Yp,t.dY=Zy,t.dZ=wp,t.d_=cp,t.da=Wu,t.db=function(e){const i=[0,0,0],n=t.ad.identity(new Float64Array(16));return t.ad.multiply(n,e.pixelMatrix,e.globeMatrix),t._.transformMat4(i,i,n),new Ue(i[0],i[1])},t.dc=d,t.dd=c,t.de=function(t){const e=t.navigator?t.navigator.userAgent:null;return!!function(t){if(null==Ei){const e=t.navigator?t.navigator.userAgent:null;Ei=!!t.safari||!(!e||!(/\b(iPad|iPhone|iPod)\b/.test(e)||e.match("Safari")&&!e.match("Chrome")))}return Ei}(t)&&e&&(e.match("Version/15.4")||e.match("Version/15.5")||e.match(/CPU (OS|iPhone OS) (15_4|15_5) like Mac OS X/))},t.df=ni,t.dg=class{constructor(t,e,i){this._transformRequestFn=t,this._customAccessToken=e,this._silenceAuthErrors=!!i,this._createSkuToken()}_createSkuToken(){const t=function(){let t="";for(let e=0;ethis._skuTokenExpiresAt}transformRequest(t,e){return this._transformRequestFn&&this._transformRequestFn(t,e)||{url:t}}normalizeStyleURL(t,i){if(!o(t))return t;const n=un(t);return n.params.push(`sdk=js-${e}`),n.path=`/styles/v1${n.path}`,this._makeAPIURL(n,this._customAccessToken||i)}normalizeGlyphsURL(t,e){if(!o(t))return t;const i=un(t);return i.path=`/fonts/v1${i.path}`,this._makeAPIURL(i,this._customAccessToken||e)}normalizeModelURL(t,e){if(!o(t))return t;const i=un(t);return i.path=`/models/v1${i.path}`,this._makeAPIURL(i,this._customAccessToken||e)}normalizeSourceURL(t,e,i,n){if(!o(t))return t;const r=un(t);return r.path=`/v4/${r.authority}.json`,r.params.push("secure"),i&&r.params.push(`language=${i}`),n&&r.params.push(`worldview=${n}`),this._makeAPIURL(r,this._customAccessToken||e)}normalizeSpriteURL(t,e,i,n){const r=un(t);return o(t)?(r.path=`/styles/v1${r.path}/sprite${e}${i}`,this._makeAPIURL(r,this._customAccessToken||n)):(r.path+=`${e}${i}`,hn(r))}normalizeTileURL(t,e,i){if(this._isSkuTokenExpired()&&this._createSkuToken(),t&&!o(t))return t;const r=un(t);r.path=r.path.replace(/(\.(png|jpg)\d*)(?=$)/,`${e||i&&"raster"!==r.authority&&512===i?"@2x":""}${Gi.supported?".webp":"$1"}`),"raster"===r.authority?r.path=`/${n.RASTER_URL_PREFIX}${r.path}`:"rasterarrays"===r.authority?r.path=`/${n.RASTERARRAYS_URL_PREFIX}${r.path}`:"3dtiles"===r.authority?r.path=`/${n.TILES3D_URL_PREFIX}${r.path}`:(r.path=r.path.replace(/^.+\/v4\//,"/"),r.path=`/${n.TILE_URL_VERSION}${r.path}`);const s=this._customAccessToken||function(t){for(const e of t){const t=e.match(/^access_token=(.*)$/);if(t)return t[1]}return null}(r.params)||n.ACCESS_TOKEN;return n.REQUIRE_ACCESS_TOKEN&&s&&this._skuToken&&r.params.push(`sku=${this._skuToken}`),this._makeAPIURL(r,s)}canonicalizeTileURL(t,e){const i=un(t);if(!i.path.match(/^(\/v4\/|\/(raster|rasterarrays)\/v1\/)/)||!i.path.match(/\.[\w]+$/))return t;let r="mapbox://";i.path.match(/^\/raster\/v1\//)?r+=`raster/${i.path.replace(`/${n.RASTER_URL_PREFIX}/`,"")}`:i.path.match(/^\/rasterarrays\/v1\//)?r+=`rasterarrays/${i.path.replace(`/${n.RASTERARRAYS_URL_PREFIX}/`,"")}`:r+=`tiles/${i.path.replace(`/${n.TILE_URL_VERSION}/`,"")}`;let o=i.params;return e&&(o=o.filter((t=>!t.match(/^access_token=/)))),o.length&&(r+=`?${o.join("&")}`),r}canonicalizeTileset(t,e){const i=!!e&&o(e),n=[];for(const e of t.tiles||[])r(e)?n.push(this.canonicalizeTileURL(e,i)):n.push(e);return n}_makeAPIURL(t,e){const i="See https://docs.mapbox.com/api/overview/#access-tokens-and-token-scopes",r=un(n.API_URL);if(t.protocol=r.protocol,t.authority=r.authority,"http"===t.protocol){const e=t.params.indexOf("secure");e>=0&&t.params.splice(e,1)}if("/"!==r.path&&(t.path=`${r.path}${t.path}`),!n.REQUIRE_ACCESS_TOKEN)return hn(t);if(e=e||n.ACCESS_TOKEN,!this._silenceAuthErrors){if(!e)throw new Error(`An API access token is required to use Mapbox GL. ${i}`);if("s"===e[0])throw new Error(`Use a public access token (pk.*) with Mapbox GL, not a secret access token (sk.*). ${i}`)}return t.params=t.params.filter((t=>-1===t.indexOf("access_token"))),t.params.push(`access_token=${e||""}`),hn(t)}},t.dh=function(t,e){e?Mn.add(t):Mn.delete(t)},t.di=Gi,t.dj=Tn,t.dk=En,t.dl=cn,t.dm=vn,t.dn=bn,t.dp=function(t){Mn.delete(t)},t.dq=Sn,t.dr=yn,t.ds=Qe,t.dt=e,t.du=function(t,e){Fi=t,Ni=e},t.dv=function(t,e,i=!1){if(Fa===za||Fa===Ra||Fa===Oa)throw new Error("setRTLTextPlugin cannot be called multiple times.");Na=ki.resolveURL(t),Fa=za,Ba=e,ja(),i||Za()},t.dw=Ga,t.dx=function(){ux().acquire(lx)},t.dy=function(){const t=dx;t&&(t.isPreloaded()&&1===t.numActive()?(t.release(lx),dx=null):console.warn("Could not clear WebWorkers since there are active Map instances that still reference it. The pre-warmed WebWorker pool can only be cleared when all map instances have been removed with map.remove()"))},t.dz=cx,t.e=ki,t.e0=cm,t.e1=h,t.e2=en,t.e3=function(t){let e=0;if(new Uint32Array(t,0,1)[0]!==Ax){const i=new Uint32Array(t,0,7),[,,n,r,o,s]=i;e=i.byteLength+r+o+s+o,(n!==t.byteLength||e>=t.byteLength)&&pi("Invalid b3dm header information.")}return Dx(t,e)},t.e4=function(t,e){const i=jx(t);for(const t of i){for(const e of t.meshes)Vx(e);t.lights&&(t.lightMeshIndex=t.meshes.length,t.meshes.push(Gx(t.lights,e)))}return i},t.e5=Kx,t.e6=rx,t.e7=qa,t.e8=function(t){ji(),Oi&&Oi.then((e=>{e.keys().then((i=>{for(let n=0;nt.arrayBuffer())).then((e=>Dx(e,0,t)))},t.m=class extends Uv{},t.n=Er,t.o=qn,t.p=Qg,t.q=Xs,t.r=Js,t.s=Qs,t.t=ca,t.u=al,t.v=ll,t.w=pi,t.x=pa,t.y=da,t.z=qo})),n(0,(function(t){function e(t){const e=t?t.url.toString():void 0;return e?performance.getEntriesByName(e):[]}function i(t){if("number"==typeof t||"boolean"==typeof t||"string"==typeof t||null==t)return JSON.stringify(t);if(Array.isArray(t)){let e="[";for(const n of t)e+=`${i(n)},`;return`${e}]`}let e="{";for(const n of Object.keys(t).sort())e+=`${n}:${i(t[n])},`;return`${e}}`}function n(e){let n="";for(const r of t.cE)n+=`/${i(e[r])}`;return n}class r{constructor(t){this.keyCache={},this._layers={},this._layerConfigs={},t&&this.replace(t)}replace(t,e){this._layerConfigs={},this._layers={},this.update(t,[],e)}update(e,i,r){this._options=r;for(const i of e)this._layerConfigs[i.id]=i,(this._layers[i.id]=t.cY(i,this.scope,null,this._options)).compileFilter(),this.keyCache[i.id]&&delete this.keyCache[i.id];for(const t of i)delete this.keyCache[t],delete this._layerConfigs[t],delete this._layers[t];this.familiesBySource={};const o=function(t,e){const i={};for(let r=0;rthis._layers[t.id])),i=e[0];if("none"===i.visibility)continue;const n=i.source||"";let r=this.familiesBySource[n];r||(r=this.familiesBySource[n]={});const o=i.sourceLayer||"_geojsonTileLayer";let s=r[o];s||(s=r[o]=[]),s.push(e)}}}const o=1*t.dJ;class s{constructor(e){const i={},n=[];for(const t in e){const r=e[t],s=i[t]={};for(const t in r.glyphs){const e=r.glyphs[+t];if(!e||0===e.bitmap.width||0===e.bitmap.height)continue;const i=e.metrics.localGlyph?o:1,a={x:0,y:0,w:e.bitmap.width+2*i,h:e.bitmap.height+2*i};n.push(a),s[t]=a}}const{w:r,h:s}=t.j(n),a=new t.dI({width:r||1,height:s||1});for(const n in e){const r=e[n];for(const e in r.glyphs){const s=r.glyphs[+e];if(!s||0===s.bitmap.width||0===s.bitmap.height)continue;const l=i[n][e],c=s.metrics.localGlyph?o:1;t.dI.copy(s.bitmap,a,{x:0,y:0},{x:l.x+c,y:l.y+c},s.bitmap)}}this.image=a,this.positions=i}}t.dH(s,"GlyphAtlas");class a{constructor(e){this.tileID=new t.aL(e.tileID.overscaledZ,e.tileID.wrap,e.tileID.canonical.z,e.tileID.canonical.x,e.tileID.canonical.y),this.tileZoom=e.tileZoom,this.uid=e.uid,this.zoom=e.zoom,this.lut=e.lut,this.canonical=e.tileID.canonical,this.pixelRatio=e.pixelRatio,this.tileSize=e.tileSize,this.source=e.source,this.scope=e.scope,this.overscaling=this.tileID.overscaleFactor(),this.showCollisionBoxes=e.showCollisionBoxes,this.collectResourceTiming=!!e.collectResourceTiming,this.promoteId=e.promoteId,this.isSymbolTile=e.isSymbolTile,this.tileTransform=t.dK(e.tileID.canonical,e.projection),this.projection=e.projection,this.brightness=e.brightness,this.extraShadowCaster=!!e.extraShadowCaster,this.tessellationStep=e.tessellationStep}parse(e,i,n,r,o){this.status="parsing",this.data=e,this.collisionBoxArray=new t.dL;const a=new t.dM(Object.keys(e.layers).sort()),c=new t.dN(this.tileID,this.promoteId);c.bucketLayerIDs=[];const d={},u=new t.dO(256,256),h={featureIndex:c,iconDependencies:{},patternDependencies:{},glyphDependencies:{},lineAtlas:u,availableImages:n,brightness:this.brightness},p=i.familiesBySource[this.source];for(const i in p){const r=e.layers[i];if(!r)continue;let o=!1,s=!1,u=!1;for(const t of p[i])"symbol"===t[0].type?o=!0:s=!0,t[0].is3D()&&"model"!==t[0].type&&(u=!0);if(this.extraShadowCaster&&!u)continue;if(!0===this.isSymbolTile&&!o)continue;if(!1===this.isSymbolTile&&!s)continue;1===r.version&&t.w(`Vector tile source "${this.source}" layer "${i}" does not use vector tile spec v2 and therefore may have some rendering errors.`);const f=a.encode(i),m=[];for(let t=0;t=e.maxzoom||"none"!==e.visibility&&(l(t,this.zoom,h.brightness,n),(d[e.id]=e.createBucket({index:c.bucketLayerIDs.length,layers:t,zoom:this.zoom,lut:this.lut,canonical:this.canonical,pixelRatio:this.pixelRatio,overscaling:this.overscaling,collisionBoxArray:this.collisionBoxArray,sourceLayerIndex:f,sourceID:this.source,projection:this.projection.spec,tessellationStep:this.tessellationStep})).populate(m,h,this.tileID.canonical,this.tileTransform),c.bucketLayerIDs.push(t.map((t=>t.id)))))}}let f,m,_,g;u.trim();const y={type:"maybePrepare",isSymbolTile:this.isSymbolTile,zoom:this.zoom},v=()=>{if(f)return this.status="done",o(f);if(this.extraShadowCaster)this.status="done",o(null,{buckets:t.dG(d).filter((t=>!t.isEmpty())),featureIndex:c,collisionBoxArray:null,glyphAtlasImage:null,lineAtlas:null,imageAtlas:null,brightness:h.brightness,glyphMap:null,iconMap:null,glyphPositions:null});else if(m&&_&&g){const e=new s(m),i=new t.dQ(_,g,this.lut);for(const r in d){const o=d[r];o instanceof t.dR?(l(o.layers,this.zoom,h.brightness,n),t.dS(o,m,e.positions,_,i.iconPositions,this.showCollisionBoxes,n,this.tileID.canonical,this.tileZoom,this.projection,this.brightness)):o.hasPattern&&(o instanceof t.dT||o instanceof t.dU||o instanceof t.b_)&&(l(o.layers,this.zoom,h.brightness,n),o.addFeatures(h,this.tileID.canonical,i.patternPositions,n,this.tileTransform,this.brightness))}this.status="done",o(null,{buckets:t.dG(d).filter((t=>!t.isEmpty())),featureIndex:c,collisionBoxArray:this.collisionBoxArray,glyphAtlasImage:e.image,lineAtlas:u,imageAtlas:i,brightness:h.brightness})}};if(!this.extraShadowCaster){const e=t.dP(h.glyphDependencies,(t=>Object.keys(t).map(Number)));Object.keys(e).length?r.send("getGlyphs",{uid:this.uid,stacks:e,scope:this.scope},((t,e)=>{f||(f=t,m=e,v())}),void 0,!1,y):m={};const i=Object.keys(h.iconDependencies);i.length?r.send("getImages",{icons:i,source:this.source,scope:this.scope,tileID:this.tileID,type:"icons"},((t,e)=>{f||(f=t,_=e,v())}),void 0,!1,y):_={};const n=Object.keys(h.patternDependencies);n.length?r.send("getImages",{icons:n,source:this.source,scope:this.scope,tileID:this.tileID,type:"patterns"},((t,e)=>{f||(f=t,g=e,v())}),void 0,!1,y):g={}}v()}}function l(e,i,n,r){const o=new t.X(i,{brightness:n});for(const t of e)t.recalculate(o,r)}class c extends t.E{constructor(e,i,n,r,o,s){super(),this.actor=e,this.layerIndex=i,this.availableImages=n,this.loadVectorData=o||t.ap,this.loading={},this.loaded={},this.deduped=new t.ao(e.scheduler),this.isSpriteLoaded=r,this.scheduler=e.scheduler,this.brightness=s}loadTile(i,n){const r=i.uid,o=i&&i.request,s=o&&o.collectResourceTiming,l=this.loading[r]=new a(i);l.abort=this.loadVectorData(i,((a,c)=>{const d=!this.loading[r];if(delete this.loading[r],d||a||!c)return l.status="done",d||(this.loaded[r]=l),n(a);const u=c.rawData,h={};c.expires&&(h.expires=c.expires),c.cacheControl&&(h.cacheControl=c.cacheControl),l.vectorTile=c.vectorTile||new t.dV(new t.dW(u));const p=()=>{l.parse(l.vectorTile,this.layerIndex,this.availableImages,this.actor,((i,r)=>{if(i||!r)return n(i);const a={};if(s){const t=e(o);t.length>0&&(a.resourceTiming=JSON.parse(JSON.stringify(t)))}n(null,t.W({rawTileData:u.slice(0)},r,h,a))}))};this.isSpriteLoaded?p():this.once("isSpriteLoaded",(()=>{this.scheduler?this.scheduler.add(p,{type:"parseTile",isSymbolTile:i.isSymbolTile,zoom:i.tileZoom}):p()})),this.loaded=this.loaded||{},this.loaded[r]=l}))}reloadTile(e,i){const n=this.loaded,r=e.uid;if(n&&n[r]){const o=n[r];o.showCollisionBoxes=e.showCollisionBoxes,o.projection=e.projection,o.brightness=e.brightness,o.tileTransform=t.dK(e.tileID.canonical,e.projection),o.extraShadowCaster=e.extraShadowCaster,o.lut=e.lut;const s=(t,e)=>{const n=o.reloadCallback;n&&(delete o.reloadCallback,o.parse(o.vectorTile,this.layerIndex,this.availableImages,this.actor,n)),i(t,e)};"parsing"===o.status?o.reloadCallback=s:"done"===o.status&&(o.vectorTile?o.parse(o.vectorTile,this.layerIndex,this.availableImages,this.actor,s):s())}else i(null,void 0)}abortTile(t,e){const i=t.uid,n=this.loading[i];n&&(n.abort&&n.abort(),delete this.loading[i]),e()}removeTile(t,e){const i=this.loaded,n=t.uid;i&&i[n]&&delete i[n],e()}}class d{loadTile(e,i){const{uid:n,encoding:r,rawImageData:o,padding:s}=e,a=ImageBitmap&&o instanceof ImageBitmap?this.getImageData(o,s):o;i(null,new t.dX(n,a,r,s{n(null,t)}),(t=>{n(t)}))}}const h=t.dZ.prototype.toGeoJSON;let p=class{constructor(e){this._feature=e,this.extent=t.a3,this.type=e.type,this.properties=e.tags,"id"in e&&!isNaN(e.id)&&(this.id=parseInt(e.id,10))}loadGeometry(){if(1===this._feature.type){const e=[];for(const i of this._feature.geometry)e.push([new t.P(i[0],i[1])]);return e}{const e=[];for(const i of this._feature.geometry){const n=[];for(const e of i)n.push(new t.P(e[0],e[1]));e.push(n)}return e}}toGeoJSON(t,e,i){return h.call(this,t,e,i)}},f=class{constructor(e){this.layers={_geojsonTileLayer:this},this.name="_geojsonTileLayer",this.extent=t.a3,this.length=e.length,this._features=e}feature(t){return new p(this._features[t])}};const m=64/4096;class _{constructor(){this.features=new Map}clear(){this.features.clear()}load(t=[],e){for(const i of t){const t=i.id;if(null==t)continue;let n=this.features.get(t);n&&this.updateCache(n,e),i.geometry?(n=y(i),this.updateCache(n,e),this.features.set(t,n)):this.features.delete(t),this.updateCache(n,e)}}updateCache(t,e){for(const{canonical:i,uid:n}of Object.values(e)){const{z:r,x:o,y:s}=i;g(t,Math.pow(2,r),o,s)&&delete e[n]}}getTile(t,e,i){const n=Math.pow(2,t),r=[];for(const t of this.features.values())g(t,n,e,i)&&r.push(w(t,n,e,i));return{features:r}}getFeatures(){return[...this.features.values()]}}function g({minX:t,minY:e,maxX:i,maxY:n},r,o,s){return t(o-m)/r&&n>(s-m)/r}function y(t){const{id:e,geometry:i,properties:n}=t;if(!i)return;if("GeometryCollection"===i.type)throw new Error("GeometryCollection not supported in dynamic mode.");const{type:r,coordinates:o}=i,s={id:e,type:1,geometry:[],tags:n,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0},a=s.geometry;if("Point"===r)v(o,a,s);else if("MultiPoint"===r)for(const t of o)v(t,a,s);else if("LineString"===r)s.type=2,x(o,a,s);else if("MultiLineString"===r)s.type=2,b(o,a,s);else if("Polygon"===r)s.type=3,b(o,a,s,!0);else{if("MultiPolygon"!==r)throw new Error("Input data is not a valid GeoJSON object.");s.type=3;for(const t of o)b(t,a,s,!0)}return s}function v([e,i],n,r){const o=t.aj(e);let s=t.ak(i);s=s1?1:s,n.push(o,s),r.minX=Math.min(r.minX,o),r.minY=Math.min(r.minY,s),r.maxX=Math.max(r.maxX,o),r.maxY=Math.max(r.maxY,s)}function x(t,e,i,n=!1,r=!1){const o=[];for(const e of t)v(e,o,i);e.push(o),n&&function(t,e){let i=0;for(let e=0,n=t.length,r=n-2;e0===e)for(let e=0,i=t.length;e>31}function F(t,e){for(var i=t.loadGeometry(),n=t.type,r=0,o=0,s=i.length,a=0;at},V=Math.fround||(G=new Float32Array(1),t=>(G[0]=+t,G[0]));var G;const Z=3,q=5,H=6;class W{constructor(t){this.options=Object.assign(Object.create(j),t),this.trees=new Array(this.options.maxZoom+1),this.stride=this.options.reduce?7:6,this.clusterProps=[]}load(t){const{log:e,minZoom:i,maxZoom:n}=this.options;e&&console.time("total time");const r=`prepare ${t.length} points`;e&&console.time(r),this.points=t;const o=[];for(let e=0;e=i;t--){const i=+Date.now();s=this.trees[t]=this._createTree(this._cluster(s,t)),e&&console.log("z%d: %d clusters in %dms",t,s.numItems,+Date.now()-i)}return e&&console.timeEnd("total time"),this}getClusters(t,e){let i=((t[0]+180)%360+360)%360-180;const n=Math.max(-90,Math.min(90,t[1]));let r=180===t[2]?180:((t[2]+180)%360+360)%360-180;const o=Math.max(-90,Math.min(90,t[3]));if(t[2]-t[0]>=360)i=-180,r=180;else if(i>r){const t=this.getClusters([i,n,180,o],e),s=this.getClusters([-180,n,r,o],e);return t.concat(s)}const s=this.trees[this._limitZoom(e)],a=s.range(K(i),J(o),K(r),J(n)),l=s.data,c=[];for(const t of a){const e=this.stride*t;c.push(l[e+q]>1?Y(l,e,this.clusterProps):this.points[l[e+Z]])}return c}getChildren(t){const e=this._getOriginId(t),i=this._getOriginZoom(t),n="No cluster with the specified id.",r=this.trees[i];if(!r)throw new Error(n);const o=r.data;if(e*this.stride>=o.length)throw new Error(n);const s=this.options.radius/(this.options.extent*Math.pow(2,i-1)),a=r.within(o[e*this.stride],o[e*this.stride+1],s),l=[];for(const e of a){const i=e*this.stride;o[i+4]===t&&l.push(o[i+q]>1?Y(o,i,this.clusterProps):this.points[o[i+Z]])}if(0===l.length)throw new Error(n);return l}getLeaves(t,e,i){const n=[];return this._appendLeaves(n,t,e=e||10,i=i||0,0),n}getTile(t,e,i){const n=this.trees[this._limitZoom(t)],r=Math.pow(2,t),{extent:o,radius:s}=this.options,a=s/o,l=(i-a)/r,c=(i+1+a)/r,d={features:[]};return this._addTileFeatures(n.range((e-a)/r,l,(e+1+a)/r,c),n.data,e,i,r,d),0===e&&this._addTileFeatures(n.range(1-a/r,l,1,c),n.data,r,i,r,d),e===r-1&&this._addTileFeatures(n.range(0,l,a/r,c),n.data,-1,i,r,d),d.features.length?d:null}getClusterExpansionZoom(t){let e=this._getOriginZoom(t)-1;for(;e1;let l,c,d;if(a)l=X(e,t,this.clusterProps),c=e[t],d=e[t+1];else{const i=this.points[e[t+Z]];l=i.properties;const[n,r]=i.geometry.coordinates;c=K(n),d=J(r)}const u={type:1,geometry:[[Math.round(this.options.extent*(c*r-i)),Math.round(this.options.extent*(d*r-n))]],tags:l};let h;h=a||this.options.generateId?e[t+Z]:this.points[e[t+Z]].id,void 0!==h&&(u.id=h),o.features.push(u)}}_limitZoom(t){return Math.max(this.options.minZoom,Math.min(Math.floor(+t),this.options.maxZoom+1))}_cluster(t,e){const{radius:i,extent:n,reduce:r,minPoints:o}=this.options,s=i/(n*Math.pow(2,e)),a=t.data,l=[],c=this.stride;for(let i=0;ie&&(p+=a[i+q])}if(p>h&&p>=o){let t,o=n*h,s=d*h,f=-1;const m=(i/c1)for(const t of u){const i=t*c;if(!(a[i+2]>5}_getOriginZoom(t){return(t-this.points.length)%32}_map(t,e,i){if(t[e+q]>1){const n=this.clusterProps[t[e+H]];return i?Object.assign({},n):n}const n=this.points[t[e+Z]].properties,r=this.options.map(n);return i&&r===n?Object.assign({},r):r}}function Y(t,e,i){return{type:"Feature",id:t[e+Z],properties:X(t,e,i),geometry:{type:"Point",coordinates:[(n=t[e],360*(n-.5)),Q(t[e+1])]}};var n}function X(t,e,i){const n=t[e+q],r=n>=1e4?`${Math.round(n/1e3)}k`:n>=1e3?Math.round(n/100)/10+"k":n,o=t[e+H],s=-1===o?{}:Object.assign({},i[o]);return Object.assign(s,{cluster:!0,cluster_id:t[e+Z],point_count:n,point_count_abbreviated:r})}function K(t){return t/360+.5}function J(t){const e=Math.sin(t*Math.PI/180),i=.5-.25*Math.log((1+e)/(1-e))/Math.PI;return i1?1:i}function Q(t){const e=(180-360*t)*Math.PI/180;return 360*Math.atan(Math.exp(e))/Math.PI-90}function tt(t,e,i,n){let r=n;const o=e+(i-e>>1);let s,a=i-e;const l=t[e],c=t[e+1],d=t[i],u=t[i+1];for(let n=e+3;n i[1].y&&e.y>i[1].y}function bf(t,e){return t.xe[1].x||t.ye[1].y}function wf(t,e,i){if(t.x=uo||e.x=uo||i.x=uo)return!1;const n=i.sub(e),r=n.perp(),o=t.sub(e);return(n.x*o.x+n.y*o.y)/Math.sqrt((n.x*n.x+n.y*n.y)*(o.x*o.x+o.y*o.y))>-.866&&r.x*o.x+r.y*o.y{for(const i of t)s.push({polygon:i,bounds:e})},l=Math.ceil(Math.log2(i)),c=Math.ceil(Math.log2(n)),d=l-c,u=[];for(let t=0;t0?0:1);for(let t=0;te+1?p.push({polygons:h,bounds:t,depth:e+1}):a(h,t)}if(f.length){const t=[new Ue(0===i?d:n.x,1===i?d:n.y),s];u.length>e+1?p.push({polygons:f,bounds:t,depth:e+1}):a(f,t)}}return s}(t,e,Math.ceil((o-r)/11.25),Math.ceil((s-a)/11.25),1,((t,e,r)=>{if(0===t)return.5*(e+r);{const t=Id((i.y+e/uo)/n);return(Md(.5*(Id((i.y+r/uo)/n)+t))*n-i.y)*uo}}))}function Mf(t,e,i,n,r,o){const s=Math.pow(2,n.z-r.z);for(let a=0;a1&&(s=t[++o]);const l=Math.abs(a-s.left),c=Math.abs(a-s.right),d=Math.min(l,c);let u;const h=e/i*(n+1);if(s.isDash){const t=n-Math.abs(h);u=Math.sqrt(d*d+t*t)}else u=n-Math.sqrt(d*d+h*h);this.image.data[r+a]=Math.max(0,Math.min(255,u+128))}}}addRegularDash(t,e){for(let e=t.length-1;e>=0;--e){const i=t[e],n=t[e+1];i.zeroLength?t.splice(e,1):n&&n.isDash===i.isDash&&(n.left=i.left,t.splice(e,1))}const i=t[0],n=t[t.length-1];i.isDash===n.isDash&&(i.left=n.left-this.width,n.right=i.right+this.width);const r=this.width*this.nextRow;let o=0,s=t[o];for(let i=0;i1&&(s=t[++o]);const n=Math.abs(i-s.left),a=Math.abs(i-s.right),l=Math.min(n,a);this.image.data[r+i]=Math.max(0,Math.min(255,(s.isDash?l:-l)+e+128))}}addDash(t,e){const i=this.getKey(t,e);if(this.positions[i])return this.positions[i];const n="round"===e,r=n?7:0,o=2*r+1;if(this.nextRow+o>this.height)return pi("LineAtlas out of space"),null;0===t.length&&t.push(1);let s=0;for(let e=0;et.fqid)),this.index=t.index,this.projection=t.projection,this.hasPattern=!1,this.hasZOffset=!1,this.patternFeatures=[],this.lineClipsArray=[],this.gradients={},this.layers.forEach((t=>{this.gradients[t.id]={}})),this.layoutVertexArray=new Rl,this.layoutVertexArray2=new Ol,this.patternVertexArray=new Bl,this.indexArray=new Kl,this.programConfigurations=new Yc(t.layers,{zoom:t.zoom,lut:t.lut}),this.segments=new wc,this.maxLineLength=0,this.zOffsetVertexArray=new Zl,this.stateDependentLayerIds=this.layers.filter((t=>t.isStateDependent())).map((t=>t.id)),this.tessellationStep=t.tessellationStep?t.tessellationStep:uo/64}updateFootprints(t,e){}populate(t,e,i,n){this.hasPattern=Hh("line",this.layers,e);const r=this.layers[0].layout.get("line-sort-key"),o=this.layers[0].layout.get("line-z-offset");this.hasZOffset=!o.isConstant()||!!o.constantOr(0);const s=[];for(const{feature:e,id:o,index:a,sourceLayerIndex:l}of t){const t=this.layers[0]._featureFilter.needGeometry,c=Zd(e,t);if(!this.layers[0]._featureFilter.filter(new Ha(this.zoom),c,i))continue;const d=r?r.evaluate(c,{},i):void 0,u={id:o,properties:e.properties,type:e.type,sourceLayerIndex:l,index:a,geometry:t?c.geometry:Gd(e,i,n),patterns:{},sortKey:d};s.push(u)}r&&s.sort(((t,e)=>t.sortKey-e.sortKey));const{lineAtlas:a,featureIndex:l}=e,c=this.addConstantDashes(a);for(const n of s){const{geometry:r,index:o,sourceLayerIndex:s}=n;if(c&&this.addFeatureDashes(n,a),this.hasPattern){const t=Wh("line",this.layers,n,this.zoom,e);this.patternFeatures.push(t)}else this.addFeature(n,r,o,i,a.positions,e.availableImages,e.brightness);l.insert(t[o].feature,r,o,s,this.index)}}addConstantDashes(t){let e=!1;for(const i of this.layers){const n=i.paint.get("line-dasharray").value,r=i.layout.get("line-cap").value;if("constant"!==n.kind||"constant"!==r.kind)e=!0;else{const e=r.value,i=n.value;if(!i)continue;t.addDash(i,e)}}return e}addFeatureDashes(t,e){const i=this.zoom;for(const n of this.layers){const r=n.paint.get("line-dasharray").value,o=n.layout.get("line-cap").value;if("constant"===r.kind&&"constant"===o.kind)continue;let s,a;if("constant"===r.kind){if(s=r.value,!s)continue}else s=r.evaluate({zoom:i},t);a="constant"===o.kind?o.value:o.evaluate({zoom:i},t),e.addDash(s,a),t.patterns[n.id]=e.getKey(s,a)}}update(t,e,i,n,r){const o=0!==Object.keys(t).length;o&&!this.stateDependentLayers.length||this.programConfigurations.updatePaintArrays(t,e,o?this.stateDependentLayers:this.layers,i,n,r)}addFeatures(t,e,i,n,r,o){for(const t of this.patternFeatures)this.addFeature(t,t.geometry,t.index,e,i,n,o)}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(t){this.uploaded||(0!==this.layoutVertexArray2.length&&(this.layoutVertexBuffer2=t.createVertexBuffer(this.layoutVertexArray2,zf)),0!==this.patternVertexArray.length&&(this.patternVertexBuffer=t.createVertexBuffer(this.patternVertexArray,Of)),!this.zOffsetVertexBuffer&&this.zOffsetVertexArray.length>0&&(this.zOffsetVertexBuffer=t.createVertexBuffer(this.zOffsetVertexArray,jf.members,!0)),this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,kf),this.indexBuffer=t.createIndexBuffer(this.indexArray)),this.programConfigurations.upload(t),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.zOffsetVertexBuffer&&this.zOffsetVertexBuffer.destroy(),this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy())}lineFeatureClips(t){if(t.properties&&t.properties.hasOwnProperty("mapbox_clip_start")&&t.properties.hasOwnProperty("mapbox_clip_end"))return{start:+t.properties.mapbox_clip_start,end:+t.properties.mapbox_clip_end}}addFeature(t,e,i,n,r,o,s){const a=this.layers[0].layout,l=a.get("line-join").evaluate(t,{}),c=a.get("line-cap").evaluate(t,{}),d=a.get("line-miter-limit"),u=a.get("line-round-limit");this.lineClips=this.lineFeatureClips(t);for(const i of e)this.addLine(i,t,n,l,c,d,u);this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,t,i,r,o,n,s)}addLine(t,e,i,n,r,o,s){this.distance=0,this.scaledDistance=0,this.totalDistance=0,this.lineSoFar=0,this.currentVertex=void 0;const a={zoom:this.zoom,lineProgress:void 0},l=this.layers[0].layout,c="none"===n;if(this.patternJoinNone=this.hasPattern&&c,this.segmentStart=0,this.segmentStartf32=0,this.segmentPoints=[],this.lineClips){this.lineClipsArray.push(this.lineClips);for(let e=0;e=2&&t[u-1].equals(t[u-2]);)u--;let h=0;for(;h0;if(A&&i>h){const t=m.dist(_);if(t>2*p){const e=m.sub(m.sub(_)._mult(p/t)._round());this.updateDistance(_,e),this.addCurrentVertex(e,y,0,0,f,x),_=e}}if(b&&"round"===w&&(Mo&&(w="bevel"),"bevel"===w&&(M>2&&(w="flipbevel"),M100)S=v.mult(-1);else{const t=M*y.add(v).mag()/y.sub(v).mag();S._perp()._mult(t*(I?-1:1))}this.addCurrentVertex(m,S,0,0,f,x),this.addCurrentVertex(m,S.mult(-1),0,0,f,x)}else if("bevel"===w||"fakeround"===w){const t=-Math.sqrt(M*M-1),e=I?t:0,i=I?0:t;if(_&&this.addCurrentVertex(m,y,e,i,f,x),"fakeround"===w){const t=Math.round(180*C/Math.PI/20);for(let e=1;e2*p){const e=m.add(g.sub(m)._mult(p/t)._round());this.updateDistance(m,e),this.addCurrentVertex(e,v,0,0,f,x),m=e}}}}addVerticesTo(t,e,i,n,r,o,s,a,l,c){const d=(e.w-t.w)/this.tessellationStep|0;if(d>1){this.lineSoFar=t.w;const u=(e.x-t.x)/d,h=(e.y-t.y)/d,p=(e.z-t.z)/d,f=(e.w-t.w)/d;for(let e=1;e=0&&this.e2>=0&&(this.indexArray.emplaceBack(this.e1,this.e2,c),a.primitiveLength++),o?this.e2=c:this.e1=c,null!=l&&this.zOffsetVertexArray.emplaceBack(l)}updateScaledDistance(){if(this.lineClips){const t=this.totalDistance/(this.lineClips.end-this.lineClips.start);this.scaledDistance=this.distance/this.totalDistance,this.lineSoFar=t*this.lineClips.start+this.distance}else this.lineSoFar=this.distance}updateDistance(t,e){this.distance+=t.dist(e),this.updateScaledDistance()}}function Qf(t,e,i){return t.xi||t.yi}ba(Jf,"LineBucket",{omit:["layers","patternFeatures","currentVertex","currentVertexIsOutside"]});const tm=new ol({"line-cap":new nl(sl.layout_line["line-cap"]),"line-join":new nl(sl.layout_line["line-join"]),"line-miter-limit":new il(sl.layout_line["line-miter-limit"]),"line-round-limit":new il(sl.layout_line["line-round-limit"]),"line-sort-key":new nl(sl.layout_line["line-sort-key"]),"line-z-offset":new nl(sl.layout_line["line-z-offset"]),visibility:new il(sl.layout_line.visibility)});var em={paint:new ol({"line-opacity":new nl(sl.paint_line["line-opacity"]),"line-color":new nl(sl.paint_line["line-color"]),"line-translate":new il(sl.paint_line["line-translate"]),"line-translate-anchor":new il(sl.paint_line["line-translate-anchor"]),"line-width":new nl(sl.paint_line["line-width"]),"line-gap-width":new nl(sl.paint_line["line-gap-width"]),"line-offset":new nl(sl.paint_line["line-offset"]),"line-blur":new nl(sl.paint_line["line-blur"]),"line-dasharray":new nl(sl.paint_line["line-dasharray"]),"line-pattern":new nl(sl.paint_line["line-pattern"]),"line-gradient":new rl(sl.paint_line["line-gradient"]),"line-trim-offset":new il(sl.paint_line["line-trim-offset"]),"line-trim-fade-range":new il(sl.paint_line["line-trim-fade-range"]),"line-trim-color":new il(sl.paint_line["line-trim-color"]),"line-emissive-strength":new il(sl.paint_line["line-emissive-strength"]),"line-border-width":new nl(sl.paint_line["line-border-width"]),"line-border-color":new nl(sl.paint_line["line-border-color"]),"line-occlusion-opacity":new il(sl.paint_line["line-occlusion-opacity"])}),layout:tm};function im(t,e,i){return e*(uo/(t.tileSize*Math.pow(2,i-t.tileID.overscaledZ)))}function nm(t,e){return 1/im(t,1,e.tileZoom)}function rm(t,e,i,n){return t.translatePosMatrix(n||e.tileID.projMatrix,e,i.paint.get("line-translate"),i.paint.get("line-translate-anchor"))}const om=t=>{const e=[];sm(t)&&e.push("RENDER_LINE_DASH"),t.paint.get("line-gradient")&&e.push("RENDER_LINE_GRADIENT");const i=t.paint.get("line-trim-offset");0===i[0]&&0===i[1]||e.push("RENDER_LINE_TRIM_OFFSET"),0!==t.paint.get("line-border-width").constantOr(1)&&e.push("RENDER_LINE_BORDER");const n="none"===t.layout.get("line-join").constantOr("miter"),r=!!t.paint.get("line-pattern").constantOr(1);return n&&r&&e.push("LINE_JOIN_NONE"),e};function sm(t){const e=t.paint.get("line-dasharray").value;return e.value||"constant"!==e.kind}class am{constructor(t){this._stringToNumber={},this._numberToString=[];for(let e=0;e>1,d=-7,u=i?r-1:0,h=i?-1:1,p=t[e+u];for(u+=h,o=p&(1>=-d,d+=a;d>0;o=256*o+t[e+u],u+=h,d-=8);for(s=o&(1>=-d,d+=n;d>0;s=256*s+t[e+u],u+=h,d-=8);if(0===o)o=1-c;else{if(o===l)return s?NaN:1/0*(p?-1:1);s+=Math.pow(2,n),o-=c}return(p?-1:1)*s*Math.pow(2,o-n)},write:function(t,e,i,n,r,o){var s,a,l,c=8*o-r-1,d=(1>1,h=23===r?Math.pow(2,-24)-Math.pow(2,-77):0,p=n?0:o-1,f=n?1:-1,m=e=1?h/l:h*Math.pow(2,1-u))*l>=2&&(s++,l/=2),s+u>=d?(a=0,s=d):s+u>=1?(a=(e*l-1)*Math.pow(2,r),s+=u):(a=e*Math.pow(2,u-1)*Math.pow(2,r),s=0));r>=8;t[i+p]=255&a,p+=f,a/=256,r-=8);for(s=s0;t[i+p]=255&s,p+=f,s/=256,c-=8);t[i+p-f]|=128*m}},cm=um,dm=lm;function um(t){this.buf=ArrayBuffer.isView&&ArrayBuffer.isView(t)?t:new Uint8Array(t||0),this.pos=0,this.type=0,this.length=this.buf.length}um.Varint=0,um.Fixed64=1,um.Bytes=2,um.Fixed32=5;var hm=4294967296,pm=1/hm,fm="undefined"==typeof TextDecoder?null:new TextDecoder("utf8");function mm(t){return t.type===um.Bytes?t.readVarint()+t.pos:t.pos+1}function _m(t,e,i){return i?4294967296*e+(t>>>0):4294967296*(e>>>0)+(t>>>0)}function gm(t,e,i){var n=e=t;r--)i.buf[r+n]=i.buf[r]}function ym(t,e){for(var i=0;i>>8,t[i+2]=e>>>16,t[i+3]=e>>>24}function Im(t,e){return(t[e]|t[e+1]>3,o=this.pos;this.type=7&n,t(r,e,this),this.pos===o&&this.skip(n)}return e},readMessage:function(t,e){return this.readFields(t,e,this.readVarint()+this.pos)},readFixed32:function(){var t=Cm(this.buf,this.pos);return this.pos+=4,t},readSFixed32:function(){var t=Im(this.buf,this.pos);return this.pos+=4,t},readFixed64:function(){var t=Cm(this.buf,this.pos)+Cm(this.buf,this.pos+4)*hm;return this.pos+=8,t},readSFixed64:function(){var t=Cm(this.buf,this.pos)+Im(this.buf,this.pos+4)*hm;return this.pos+=8,t},readFloat:function(){var t=dm.read(this.buf,this.pos,!0,23,4);return this.pos+=4,t},readDouble:function(){var t=dm.read(this.buf,this.pos,!0,52,8);return this.pos+=8,t},readVarint:function(t){var e,i,n=this.buf;return e=127&(i=n[this.pos++]),i>4,r=12&&fm?function(t,e,i){return fm.decode(t.subarray(e,i))}(this.buf,e,t):function(t,e,i){for(var n="",r=e;r239?4:l>223?3:l>191?2:1;if(r+d>i)break;1===d?l=55296&&c=1114112)&&(c=null)),null===c?(c=65533,d=1):c>65535&&(c-=65536,n+=String.fromCharCode(c>>>10&1023|55296),c=56320|1023&c),n+=String.fromCharCode(c),r+=d}return n}(this.buf,e,t)},readBytes:function(){var t=this.readVarint()+this.pos,e=this.buf.subarray(this.pos,t);return this.pos=t,e},readPackedVarint:function(t,e){if(this.type!==um.Bytes)return t.push(this.readVarint(e));var i=mm(this);for(t=t||[];this.pos127;);else if(e===um.Bytes)this.pos=this.readVarint()+this.pos;else if(e===um.Fixed32)this.pos+=4;else{if(e!==um.Fixed64)throw new Error("Unimplemented type: "+e);this.pos+=8}},writeTag:function(t,e){this.writeVarint(t268435455||t=0?(i=t%4294967296|0,n=t/4294967296|0):(n=~(-t/4294967296),4294967295^(i=~(-t%4294967296))?i=i+1|0:(i=0,n=n+1|0)),t>=0x10000000000000000||t>>=7,i.buf[i.pos++]=127&t|128,t>>>=7,i.buf[i.pos++]=127&t|128,t>>>=7,i.buf[i.pos++]=127&t|128,i.buf[i.pos]=127&(t>>>=7)}(i,0,e),function(t,e){var i=(7&t)>>=3)?128:0),t&&(e.buf[e.pos++]=127&t|((t>>>=7)?128:0),t&&(e.buf[e.pos++]=127&t|((t>>>=7)?128:0),t&&(e.buf[e.pos++]=127&t|((t>>>=7)?128:0),t&&(e.buf[e.pos++]=127&t|((t>>>=7)?128:0),t&&(e.buf[e.pos++]=127&t)))))}(n,e)}(t,this):(this.realloc(4),this.buf[this.pos++]=127&t|(t>127?128:0),t>>=7)|(t>127?128:0),t>>=7)|(t>127?128:0),t>>7&127))))},writeSVarint:function(t){this.writeVarint(t55295&&n56319||o+1===e.length?(t[i++]=239,t[i++]=191,t[i++]=189):r=n;continue}if(n>6|192:(n>12|224:(t[i++]=n>>18|240,t[i++]=n>>12&63|128),t[i++]=n>>6&63|128),t[i++]=63&n|128)}return i}(this.buf,t,this.pos);var i=this.pos-e;i>=128&&gm(e,i,this),this.pos=e-1,this.writeVarint(i),this.pos+=i},writeFloat:function(t){this.realloc(4),dm.write(this.buf,t,this.pos,!0,23,4),this.pos+=4},writeDouble:function(t){this.realloc(8),dm.write(this.buf,t,this.pos,!0,52,8),this.pos+=8},writeBytes:function(t){var e=t.length;this.writeVarint(e),this.realloc(e);for(var i=0;i=128&&gm(i,n,this),this.pos=i-1,this.writeVarint(n),this.pos+=n},writeMessage:function(t,e,i){this.writeTag(t,um.Bytes),this.writeRawMessage(e,i)},writePackedVarint:function(t,e){e.length&&this.writeMessage(t,ym,e)},writePackedSVarint:function(t,e){e.length&&this.writeMessage(t,vm,e)},writePackedBoolean:function(t,e){e.length&&this.writeMessage(t,wm,e)},writePackedFloat:function(t,e){e.length&&this.writeMessage(t,xm,e)},writePackedDouble:function(t,e){e.length&&this.writeMessage(t,bm,e)},writePackedFixed32:function(t,e){e.length&&this.writeMessage(t,Tm,e)},writePackedSFixed32:function(t,e){e.length&&this.writeMessage(t,Sm,e)},writePackedFixed64:function(t,e){e.length&&this.writeMessage(t,Em,e)},writePackedSFixed64:function(t,e){e.length&&this.writeMessage(t,Mm,e)},writeBytesField:function(t,e){this.writeTag(t,um.Bytes),this.writeBytes(e)},writeFixed32Field:function(t,e){this.writeTag(t,um.Fixed32),this.writeFixed32(e)},writeSFixed32Field:function(t,e){this.writeTag(t,um.Fixed32),this.writeSFixed32(e)},writeFixed64Field:function(t,e){this.writeTag(t,um.Fixed64),this.writeFixed64(e)},writeSFixed64Field:function(t,e){this.writeTag(t,um.Fixed64),this.writeSFixed64(e)},writeVarintField:function(t,e){this.writeTag(t,um.Varint),this.writeVarint(e)},writeSVarintField:function(t,e){this.writeTag(t,um.Varint),this.writeSVarint(e)},writeStringField:function(t,e){this.writeTag(t,um.Bytes),this.writeString(e)},writeFloatField:function(t,e){this.writeTag(t,um.Fixed32),this.writeFloat(e)},writeDoubleField:function(t,e){this.writeTag(t,um.Fixed64),this.writeDouble(e)},writeBooleanField:function(t,e){this.writeVarintField(t,Boolean(e))}};var Lm=h(cm);const Pm=["id","tile","layer","source","sourceLayer","state"];class $m{constructor(t,e,i,n,r){this.type="Feature",this._vectorTileFeature=t,this._z=e,this._x=i,this._y=n,this.properties=t.properties,this.id=r}get geometry(){return void 0===this._geometry&&(this._geometry=this._vectorTileFeature.toGeoJSON(this._x,this._y,this._z).geometry),this._geometry}set geometry(t){this._geometry=t}toJSON(){const t={type:"Feature",state:void 0,geometry:this.geometry,properties:this.properties};for(const e of Pm)void 0!==this[e]&&(t[e]=this[e]);return t}}class km{constructor(){this.state={},this.stateChanges={},this.deletedStates={}}updateState(t,e,i){const n=String(e);if(this.stateChanges[t]=this.stateChanges[t]||{},this.stateChanges[t][n]=this.stateChanges[t][n]||{},ei(this.stateChanges[t][n],i),null===this.deletedStates[t]){this.deletedStates[t]={};for(const e in this.state[t])e!==n&&(this.deletedStates[t][e]=null)}else if(this.deletedStates[t]&&null===this.deletedStates[t][n]){this.deletedStates[t][n]={};for(const e in this.state[t][n])i[e]||(this.deletedStates[t][n][e]=null)}else for(const e in i)this.deletedStates[t]&&this.deletedStates[t][n]&&null===this.deletedStates[t][n][e]&&delete this.deletedStates[t][n][e]}removeFeatureState(t,e,i){if(null===this.deletedStates[t])return;const n=String(e);if(this.deletedStates[t]=this.deletedStates[t]||{},i&&void 0!==e)null!==this.deletedStates[t][n]&&(this.deletedStates[t][n]=this.deletedStates[t][n]||{},this.deletedStates[t][n][i]=null);else if(void 0!==e)if(this.stateChanges[t]&&this.stateChanges[t][n])for(i in this.deletedStates[t][n]={},this.stateChanges[t][n])this.deletedStates[t][n][i]=null;else this.deletedStates[t][n]=null;else this.deletedStates[t]=null}getState(t,e){const i=String(e),n=ei({},(this.state[t]||{})[i],(this.stateChanges[t]||{})[i]);if(null===this.deletedStates[t])return{};if(this.deletedStates[t]){const i=this.deletedStates[t][e];if(null===i)return{};for(const t in i)delete n[t]}return n}initializeTileState(t,e){t.setFeatureState(this.state,e)}coalesceChanges(t,e){const i={};for(const t in this.stateChanges){this.state[t]=this.state[t]||{};const e={};for(const i in this.stateChanges[t])this.state[t][i]||(this.state[t][i]={}),ei(this.state[t][i],this.stateChanges[t][i]),e[i]=this.state[t][i];i[t]=e}for(const t in this.deletedStates){this.state[t]=this.state[t]||{};const e={};if(null===this.deletedStates[t])for(const i in this.state[t])e[i]={},this.state[t][i]={};else for(const i in this.deletedStates[t]){if(null===this.deletedStates[t][i])this.state[t][i]={};else if(this.state[t][i])for(const e of Object.keys(this.deletedStates[t][i]))delete this.state[t][i][e];e[i]=this.state[t][i]}i[t]=i[t]||{},ei(i[t],e)}if(this.stateChanges={},this.deletedStates={},0!==Object.keys(i).length)for(const n in t)t[n].setFeatureState(i,e)}}class Dm{constructor(t,e){this.tileID=t,this.x=t.canonical.x,this.y=t.canonical.y,this.z=t.canonical.z,this.grid=new va(uo,16,0),this.featureIndexArray=new yc,this.promoteId=e,this.is3DTile=!1}insert(t,e,i,n,r,o=0,s=0){const a=this.featureIndexArray.length;this.featureIndexArray.emplaceBack(i,n,r,o);const l=this.grid;for(let t=0;t=0&&n[3]>=0&&l.insert(a,n[0],n[1],n[2],n[3])}}loadVTLayers(){if(!this.vtLayers){this.vtLayers=new bp(new Lm(this.rawTileData)).layers,this.sourceLayerCoder=new am(this.vtLayers?Object.keys(this.vtLayers).sort():["_geojsonTileLayer"]),this.vtFeatures={};for(const t in this.vtLayers)this.vtFeatures[t]=[]}return this.vtLayers}query(t,e,i,n){this.loadVTLayers();const r=t.params||{},o=dl(r.filter),s=t.tileResult,a=t.transform,l=s.bufferedTilespaceBounds,c=this.grid.query(l.min.x,l.min.y,l.max.x,l.max.y,((t,e,i,n)=>ou(s.bufferedTilespaceGeometry,t,e,i,n)));c.sort(Rm);let d=null;a.elevation&&c.length>0&&(d=Xp.create(a.elevation,this.tileID));const u={};let h;for(let l=0;l(m||(m=Gd(e,this.tileID.canonical,t.tileTransform)),i.queryIntersectsFeature(s,e,n,m,this.z,t.transform,t.pixelPosMatrix,d,r))))}return u}loadMatchingFeature(t,e,i,n,r,o,s,a,l){const{featureIndex:c,bucketIndex:d,sourceLayerIndex:u,layoutVertexArrayOffset:h}=e,p=this.bucketLayerIDs[d];if(n&&!function(t,e){for(let i=0;i=0)return!0;return!1}(n,p))return;const f=this.sourceLayerCoder.decode(u),m=this.vtLayers[f].feature(c);if(i.needGeometry){const t=Zd(m,!0);if(!i.filter(new Ha(this.tileID.overscaledZ),t,this.tileID.canonical))return}else if(!i.filter(new Ha(this.tileID.overscaledZ),m))return;const _=this.getId(m,f);for(let e=0;e{const s=e instanceof el?e.get(o):null;return s&&s.evaluate?s.evaluate(i,n,r):s}))}function Rm(t,e){return e-t}ba(Dm,"FeatureIndex",{omit:["rawTileData","sourceLayerCoder"]});var Om=24;const Bm=128;function Fm(t,e){const{expression:i}=e;if("constant"===i.kind)return{kind:"constant",layoutSize:i.evaluate(new Ha(t+1))};if("source"===i.kind)return{kind:"source"};{const{zoomStops:e,interpolationType:n}=i;let r=0;for(;r{t.text=function(t,e,i){const n=e.layout.get("text-transform").evaluate(i,{});return"uppercase"===n?t=t.toLocaleUpperCase():"lowercase"===n&&(t=t.toLocaleLowerCase()),qa.applyArabicShaping&&(t=qa.applyArabicShaping(t)),t}(t.text,e,i)})),t}const Gm={"!":"︕","#":"#",$:"$","%":"%","&":"&","(":"︵",")":"︶","*":"*","+":"+",",":"︐","-":"︲",".":"・","/":"/",":":"︓",";":"︔","":"﹀","?":"︖","@":"@","[":"﹇","\\":"\","]":"﹈","^":"^",_:"︳","`":"`","{":"︷","|":"―","}":"︸","~":"~","¢":"¢","£":"£","¥":"¥","¦":"¦","¬":"¬","¯":" ̄","–":"︲","—":"︱","‘":"﹃","’":"﹄","“":"﹁","”":"﹂","…":"︙","‧":"・","₩":"₩","、":"︑","。":"︒","〈":"︿","〉":"﹀","《":"︽","》":"︾","「":"﹁","」":"﹂","『":"﹃","』":"﹄","【":"︻","】":"︼","〔":"︹","〕":"︺","〖":"︗","〗":"︘","!":"︕","(":"︵",")":"︶",",":"︐","-":"︲",".":"・",":":"︓",";":"︔","<":"︿",">":"﹀","?":"︖","[":"﹇","]":"﹈","_":"︳","{":"︷","|":"―","}":"︸","⦅":"︵","⦆":"︶","。":"︒","「":"﹁","」":"﹂","←":"↑","→":"↓"};function Zm(t){return"︶"===t||"﹈"===t||"︸"===t||"﹄"===t||"﹂"===t||"︾"===t||"︼"===t||"︺"===t||"︘"===t||"﹀"===t||"︐"===t||"︓"===t||"︔"===t||"`"===t||" ̄"===t||"︑"===t||"︒"===t}function qm(t){return"︵"===t||"﹇"===t||"︷"===t||"﹃"===t||"﹁"===t||"︽"===t||"︻"===t||"︹"===t||"︗"===t||"︿"===t}const Hm=3;function Wm(t,e,i){e.glyphs=[],1===t&&i.readMessage(Ym,e)}function Ym(t,e,i){if(3===t){const{id:t,bitmap:n,width:r,height:o,left:s,top:a,advance:l}=i.readMessage(Xm,{});e.glyphs.push({id:t,bitmap:new dh({width:r+2*Hm,height:o+2*Hm},n),metrics:{width:r,height:o,left:s,top:a,advance:l}})}else 4===t?e.ascender=i.readSVarint():5===t&&(e.descender=i.readSVarint())}function Xm(t,e,i){1===t?e.id=i.readVarint():2===t?e.bitmap=i.readBytes():3===t?e.width=i.readVarint():4===t?e.height=i.readVarint():5===t?e.left=i.readSVarint():6===t?e.top=i.readSVarint():7===t&&(e.advance=i.readVarint())}const Km=Hm,Jm={horizontal:1,vertical:2,horizontalOnly:3};class Qm{constructor(){this.scale=1,this.fontStack="",this.imageName=null}static forText(t,e){const i=new Qm;return i.scale=t||1,i.fontStack=e,i}static forImage(t){const e=new Qm;return e.imageName=t,e}}class t_{constructor(){this.text="",this.sectionIndex=[],this.sections=[],this.imageSectionID=null}static fromFeature(t,e){const i=new t_;for(let n=0;n=0&&i>=t&&i_[this.text.charCodeAt(i)];i--)e--;this.text=this.text.substring(t,e),this.sectionIndex=this.sectionIndex.slice(t,e)}substring(t,e){const i=new t_;return i.text=this.text.substring(t,e),i.sectionIndex=this.sectionIndex.slice(t,e),i.sections=this.sections,i}toString(){return this.text}getMaxScale(){return this.sectionIndex.reduce(((t,e)=>Math.max(t,this.sections[e].scale)),0)}addTextSection(t,e){this.text+=t.text,this.sections.push(Qm.forText(t.scale,t.fontStack||e));const i=this.sections.length-1;for(let e=0;e=63743?null:++this.imageSectionID:(this.imageSectionID=57344,this.imageSectionID)}}function e_(t,e,i,n,r,o,s,a,l,c,d,u,h,p,f){const m=t_.fromFeature(t,r);u===Jm.vertical&&m.verticalizePunctuation(h);let _=[];const g=function(t,e,i,n,r,o){if(!t)return[];const s=[],a=function(t,e,i,n,r,o){let s=0;for(let i=0;i=0;let c=0;for(let i=0;i0&&o>b&&(b=o)}else{const t=i[a.fontStack];if(!t)continue;t[m]&&(S=t[m]);const n=e[a.fontStack];if(!n)continue;const o=n.glyphs[m];if(!o)continue;if(v=o.metrics,M=8203!==m?Om:0,_){const t=void 0!==n.ascender?Math.abs(n.ascender):0,e=void 0!==n.descender?Math.abs(n.descender):0,i=(t+e)*g;w-i/2;){if(s--,sn;)c-=l.shift().angleDelta;if(c>r)return!1;s++,a+=e.dist(i)}return!0}function m_(t){let e=0;for(let i=0;ic){const d=(c-l)/o,u=Vn(n.x,r.x,d),h=Vn(n.y,r.y,d),p=new p_(u,h,0,r.angleTo(n),i);return!s||f_(t,p,a,s,e)?p:void 0}l+=o}}function v_(t,e,i,n,r,o,s,a,l){const c=__(n,o,s),d=g_(n,r),u=d*s,h=0===t[0].x||t[0].x===l||0===t[0].y||t[0].y===l;return e-u=0&&g=0&&y=0&&h+c=n&&c.x>=n||(s.x>=n?s=new Ue(n,s.y+(n-s.x)/(c.x-s.x)*(c.y-s.y))._round():c.x>=n&&(c=new Ue(n,s.y+(n-s.x)/(c.x-s.x)*(c.y-s.y))._round()),s.y>=r&&c.y>=r||(s.y>=r?s=new Ue(s.x+(r-s.y)/(c.y-s.y)*(c.x-s.x),r)._round():c.y>=r&&(c=new Ue(s.x+(r-s.y)/(c.y-s.y)*(c.x-s.x),r)._round()),l&&s.equals(l[l.length-1])||(l=[s],o.push(l)),l.push(c)))))}}return o}function w_(t){let e=0,i=0;for(const n of t)e+=n.w*n.h,i=Math.max(i,n.w);t.sort(((t,e)=>e.h-t.h));const n=[{x:0,y:0,w:Math.max(Math.ceil(Math.sqrt(e/.95)),i),h:1/0}];let r=0,o=0;for(const e of t)for(let t=n.length-1;t>=0;t--){const i=n[t];if(!(e.w>i.w||e.h>i.h)){if(e.x=i.x,e.y=i.y,o=Math.max(o,e.y+e.h),r=Math.max(r,e.x+e.w),e.w===i.w&&e.h===i.h){const e=n.pop();tt.hasImage(e,i))),t.dispatchRenderCallbacks(this.haveRenderCallbacks,i);for(const n in t.getUpdatedImages(i))this.patchUpdatedImage(this.iconPositions[n],t.getImage(n,i),e),this.patchUpdatedImage(this.patternPositions[n],t.getImage(n,i),e)}patchUpdatedImage(t,e,i){if(!t||!e)return;if(t.version===e.version)return;t.version=e.version;const[n,r]=t.tl,o=!!Object.keys(this.patternPositions).length;i.update(e.data,{useMipmap:o},{x:n,y:r})}}ba(S_,"ImagePosition"),ba(E_,"ImageAtlas");const M_=1e20;function C_(t,e,i,n,r,o,s,a,l){for(let c=e;c-1);l++,o[l]=a,s[l]=c,s[l+1]=M_}for(let a=0,l=0;a{let n=this.entries[t];n||(n=this.entries[t]={glyphs:{},requests:{},ranges:{},ascender:void 0,descender:void 0});let r=n.glyphs[e];if(void 0!==r)return void i(null,{stack:t,id:e,glyph:r});if(r=this._tinySDF(n,t,e),r)return n.glyphs[e]=r,void i(null,{stack:t,id:e,glyph:r});const s=Math.floor(e/256);if(256*s>65535)return void i(new Error("glyphs > 65535 not supported"));if(n.ranges[s])return void i(null,{stack:t,id:e,glyph:r});let a=n.requests[s];a||(a=n.requests[s]=[],P_.loadGlyphRange(t,s,o,this.requestManager,((t,e)=>{if(e){n.ascender=e.ascender,n.descender=e.descender;for(const t in e.glyphs)this._doesCharSupportLocalGlyph(+t)||(n.glyphs[+t]=e.glyphs[+t]);n.ranges[s]=!0}for(const i of a)i(t,e);delete n.requests[s]}))),a.push(((n,r)=>{n?i(n):r&&i(null,{stack:t,id:e,glyph:r.glyphs[e]||null})}))}),((t,e)=>{if(t)i(t);else if(e){const t={};for(const{stack:i,id:n,glyph:r}of e)void 0===t[i]&&(t[i]={}),void 0===t[i].glyphs&&(t[i].glyphs={}),t[i].glyphs[n]=r&&{id:r.id,bitmap:r.bitmap.clone(),metrics:r.metrics},t[i].ascender=this.entries[i].ascender,t[i].descender=this.entries[i].descender;i(null,t)}}))}_doesCharSupportLocalGlyph(t){return this.localGlyphMode!==L_.none&&(this.localGlyphMode===L_.all?!!this.localFontFamily:!!this.localFontFamily&&(Ma["CJK Unified Ideographs"](t)||Ma["Hangul Syllables"](t)||Ma.Hiragana(t)||Ma.Katakana(t)||Ma["CJK Symbols and Punctuation"](t)||Ma["CJK Unified Ideographs Extension A"](t)||Ma["CJK Unified Ideographs Extension B"](t)))}_tinySDF(t,e,i){const n=this.localFontFamily;if(!n||!this._doesCharSupportLocalGlyph(i))return;let r=t.tinySDF;if(!r){let i="400";/bold/i.test(e)?i="900":/medium/i.test(e)?i="500":/light/i.test(e)&&(i="200"),r=t.tinySDF=new P_.TinySDF({fontFamily:n,fontWeight:i,fontSize:24*I_,buffer:3*I_,radius:8*I_}),r.fontWeight=i}if(this.localGlyphs[r.fontWeight][i])return this.localGlyphs[r.fontWeight][i];const o=String.fromCodePoint(i),{data:s,width:a,height:l,glyphWidth:c,glyphHeight:d,glyphLeft:u,glyphTop:h,glyphAdvance:p}=r.draw(o);return this.localGlyphs[r.fontWeight][i]={id:i,bitmap:new dh({width:a,height:l},s),metrics:{width:c/I_,height:d/I_,left:u/I_,top:h/I_-27,advance:p/I_,localGlyph:!0}}}}P_.loadGlyphRange=function(t,e,i,n,r){const o=256*e,s=o+255,a=n.transformRequest(n.normalizeGlyphsURL(i).replace("{fontstack}",t).replace("{range}",`${o}-${s}`),Ki.Glyphs);en(a,((t,e)=>{if(t)r(t);else if(e){const t={},i=function(t){return new Lm(t).readFields(Wm,{})}(e);for(const e of i.glyphs)t[e.id]=e;r(null,{glyphs:t,ascender:i.ascender,descender:i.descender})}}))},P_.TinySDF=class{constructor({fontSize:t=24,buffer:e=3,radius:i=8,cutoff:n=.25,fontFamily:r="sans-serif",fontWeight:o="normal",fontStyle:s="normal"}={}){this.buffer=e,this.cutoff=n,this.radius=i;const a=this.size=t+4*e,l=this._createCanvas(a),c=this.ctx=l.getContext("2d",{willReadFrequently:!0});c.font=`${s} ${o} ${t}px ${r}`,c.textBaseline="alphabetic",c.textAlign="left",c.fillStyle="black",this.gridOuter=new Float64Array(a*a),this.gridInner=new Float64Array(a*a),this.f=new Float64Array(a),this.z=new Float64Array(a+1),this.v=new Uint16Array(a)}_createCanvas(t){const e=document.createElement("canvas");return e.width=e.height=t,e}draw(t){const{width:e,actualBoundingBoxAscent:i,actualBoundingBoxDescent:n,actualBoundingBoxLeft:r,actualBoundingBoxRight:o}=this.ctx.measureText(t),s=Math.ceil(i),a=Math.max(0,Math.min(this.size-this.buffer,Math.ceil(o-r))),l=Math.min(this.size-this.buffer,s+Math.ceil(n)),c=a+2*this.buffer,d=l+2*this.buffer,u=Math.max(c*d,0),h=new Uint8ClampedArray(u),p={data:h,width:c,height:d,glyphWidth:a,glyphHeight:l,glyphTop:s,glyphLeft:0,glyphAdvance:e};if(0===a||0===l)return p;const{ctx:f,buffer:m,gridInner:_,gridOuter:g}=this;f.clearRect(m,m,a,l),f.fillText(t,m,m+s);const y=f.getImageData(m,m,a,l);g.fill(M_,0,u),_.fill(0,0,u);for(let t=0;t0?t*t:0,_[n]=tt+e[1]-e[0],f=u.reduce(p,0),m=h.reduce(p,0),_=a-f,g=l-m;let y=0,v=f,x=0,b=m,w=0,T=_,S=0,E=g;if(o.content&&n){const t=o.content;y=D_(u,0,t[0]),x=D_(h,0,t[1]),v=D_(u,t[0],t[2]),b=D_(h,t[1],t[3]),w=t[0]-y,S=t[1]-x,T=t[2]-t[0]-v,E=t[3]-t[1]-b}const M=(n,r,a,l)=>{const u=R_(n.stretch-y,v,c,t.left),h=O_(n.fixed-w,T,n.stretch,f),p=R_(r.stretch-x,b,d,t.top),_=O_(r.fixed-S,E,r.stretch,m),g=R_(a.stretch-y,v,c,t.left),M=O_(a.fixed-w,T,a.stretch,f),C=R_(l.stretch-x,b,d,t.top),A=O_(l.fixed-S,E,l.stretch,m),I=new Ue(u,p),L=new Ue(g,p),P=new Ue(g,C),$=new Ue(u,C),k=new Ue(h/s,_/s),D=new Ue(M/s,A/s),z=e*Math.PI/180;if(z){const t=Math.sin(z),e=Math.cos(z),i=[e,-t,t,e];I._matMult(i),L._matMult(i),$._matMult(i),P._matMult(i)}const R=n.stretch+n.fixed,O=a.stretch+a.fixed,B=r.stretch+r.fixed,F=l.stretch+l.fixed,N=t.imageSecondary;return{tl:I,tr:L,bl:$,br:P,texPrimary:{x:o.paddedRect.x+$_+R,y:o.paddedRect.y+$_+B,w:O-R,h:F-B},texSecondary:N?{x:N.paddedRect.x+$_+R,y:N.paddedRect.y+$_+B,w:O-R,h:F-B}:void 0,writingMode:void 0,glyphOffset:[0,0],sectionIndex:0,pixelOffsetTL:k,pixelOffsetBR:D,minFontScaleX:T/s/c,minFontScaleY:E/s/d,isSDF:i}};if(n&&(o.stretchX||o.stretchY)){const t=z_(u,_,f),e=z_(h,g,m);for(let i=0;io)&&(o=e.x),(!t||e.y>s)&&(s=e.y)}const l=Math.min(o-n,s-r);let c=l/2;const d=new co([],N_);if(0===l)return new Ue(n,r);for(let e=n;eu.d||!u.d)&&(u=n,i&&console.log("found best %d after %d probes",Math.round(1e4*n.d)/1e4,h)),n.max-u.dt.y!=a.y>t.y&&t.x18&&P>2&&(P>>=1),Math.max(uo/(512*P),1)*_.get("symbol-spacing")),S=_.get("text-padding")*t.tilePixelRatio,E=_.get("icon-padding")*t.tilePixelRatio,M=Ge(_.get("text-max-angle")),C="map"===_.get("text-rotation-alignment")&&"point"!==_.get("symbol-placement"),A="map"===_.get("icon-rotation-alignment")&&"point"!==_.get("symbol-placement"),I=_.get("symbol-placement"),L=T/2;var P;const $=_.get("icon-text-fit").evaluate(e,{},u),k=_.get("icon-text-fit-padding").evaluate(e,{},u),D="none"!==$;let z;!1===t.hasAnyIconTextFit&&D&&(t.hasAnyIconTextFit=!0),n&&D&&(t.allowVerticalPlacement&&i.vertical&&(z=h_(n,i.vertical,$,k,g,b)),y&&(n=h_(n,y,$,k,g,b)));const R=(s,a,m)=>{if(a.x=uo||a.y=uo)return;let _=null;if(v){const{x:t,y:e,z:i}=h.projectTilePoint(a.x,a.y,m);_={anchor:new p_(t,e,i,0,void 0),up:h.upVector(m,a.x,a.y)}}!function(t,e,i,n,r,o,s,a,l,c,d,u,h,p,f,m,_,g,y,v,x,b,w,T,S,E,M){const C=t.addToLineVertexArray(e,n);let A,I,L,P,$,k,D,z=0,R=0,O=0,B=0,F=-1,N=-1;const U={};let j=Ln("");const V=i?i.anchor:e,G="none"!==l.layout.get("icon-text-fit").evaluate(x,{},S);let Z=0,q=0;if(void 0===l._unevaluatedLayout.getValue("text-radial-offset")?[Z,q]=l.layout.get("text-offset").evaluate(x,{},S).map((t=>t*Om)):(Z=l.layout.get("text-radial-offset").evaluate(x,{},S)*Om,q=j_),t.allowVerticalPlacement&&r.vertical){const t=r.vertical;if(f)k=J_(t),a&&(D=J_(a));else{const i=l.layout.get("text-rotate").evaluate(x,{},S)+90;L=K_(c,V,e,d,u,h,t,p,i,m),a&&(P=K_(c,V,e,d,u,h,a,g,i))}}if(o){const n=l.layout.get("icon-rotate").evaluate(x,{},S),r=k_(o,n,w,G),s=a?k_(a,n,w,G):void 0;I=K_(c,V,e,d,u,h,o,g,n),z=4*r.length;const p=t.iconSizeData;let f=null;"source"===p.kind?(f=[Bm*l.layout.get("icon-size").evaluate(x,{},S)],f[0]>W_&&pi(`${t.layerIds[0]}: Value for "icon-size" is >= ${H_}. Reduce your "icon-size".`)):"composite"===p.kind&&(f=[Bm*b.compositeIconSizes[0].evaluate(x,{},S),Bm*b.compositeIconSizes[1].evaluate(x,{},S)],(f[0]>W_||f[1]>W_)&&pi(`${t.layerIds[0]}: Value for "icon-size" is >= ${H_}. Reduce your "icon-size".`)),t.addSymbols(t.icon,r,f,v,y,x,!1,i,e,C.lineStartIndex,C.lineLength,-1,T,S,E,M),F=t.icon.placedSymbolArray.length-1,s&&(R=4*s.length,t.addSymbols(t.icon,s,f,v,y,x,Jm.vertical,i,e,C.lineStartIndex,C.lineLength,-1,T,S,E,M),N=t.icon.placedSymbolArray.length-1)}for(const n in r.horizontal){const o=r.horizontal[n];A||(j=Ln(o.text),f?$=J_(o):A=K_(c,V,e,d,u,h,o,p,l.layout.get("text-rotate").evaluate(x,{},S),m));const a=1===o.positionedLines.length;if(O+=Y_(t,i,e,o,s,l,f,x,m,C,r.vertical?Jm.horizontal:Jm.horizontalOnly,a?Object.keys(r.horizontal):[n],U,F,b,T,S,E),a)break}r.vertical&&(B+=Y_(t,i,e,r.vertical,s,l,f,x,m,C,Jm.vertical,["vertical"],U,N,b,T,S,E));let H=-1;const W=(t,e)=>t?Math.max(t,e):e;H=W($,H),H=W(k,H),H=W(D,H);const Y=H>-1?1:0;t.glyphOffsetArray.length>=65535&&pi("Too many glyphs being rendered in a tile. See https://github.com/mapbox/mapbox-gl-js/issues/2907"),void 0!==x.sortKey&&t.addToSortKeyRanges(t.symbolInstances.length,x.sortKey),t.symbolInstances.emplaceBack(e.x,e.y,V.x,V.y,V.z,U.right>=0?U.right:-1,U.center>=0?U.center:-1,U.left>=0?U.left:-1,U.vertical>=0?U.vertical:-1,F,N,j,void 0!==A?A:t.collisionBoxArray.length,void 0!==A?A+1:t.collisionBoxArray.length,void 0!==L?L:t.collisionBoxArray.length,void 0!==L?L+1:t.collisionBoxArray.length,void 0!==I?I:t.collisionBoxArray.length,void 0!==I?I+1:t.collisionBoxArray.length,P||t.collisionBoxArray.length,P?P+1:t.collisionBoxArray.length,d,O,B,z,R,Y,0,Z,q,H,0,1,1,G?1:0)}(t,a,_,s,i,n,r,z,t.layers[0],t.collisionBoxArray,e.index,e.sourceLayerIndex,t.index,S,C,l,0,E,A,g,e,o,c,d,u,p,f)};if("line"===I)for(const r of b_(e.geometry,0,0,uo,uo)){const e=v_(r,T,M,i.vertical||y,n,x,w,t.overscaling,uo);for(const i of e)y&&Q_(t,y.text,L,i)||R(r,i,u)}else if("line-center"===I){for(const t of e.geometry)if(t.length>1){const e=y_(t,M,i.vertical||y,n,x,w);e&&R(t,e,u)}}else if("Polygon"===e.type)for(const t of Zh(e.geometry,0)){const e=F_(t,16);R(t[0],new p_(e.x,e.y,0,0,void 0),u)}else if("LineString"===e.type)for(const t of e.geometry)R(t,new p_(t[0].x,t[0].y,0,0,void 0),u);else if("Point"===e.type)for(const t of e.geometry)for(const e of t)R([e],new p_(e.x,e.y,0,0,void 0),u)}const H_=255,W_=H_*Bm;function Y_(t,e,i,n,r,o,s,a,l,c,d,u,h,p,f,m,_,g){const y=function(t,e,i,n,r,o,s,a){const l=[];if(0===e.positionedLines.length)return l;const c=n.layout.get("text-rotate").evaluate(o,{})*Math.PI/180,d=function(t){const e=t[0],i=t[1],n=e*i;return n>0?[e,-i]:nW_&&pi(`${t.layerIds[0]}: Value for "text-size" is >= ${H_}. Reduce your "text-size".`)):"composite"===v.kind&&(x=[Bm*f.compositeTextSizes[0].evaluate(a,{},_),Bm*f.compositeTextSizes[1].evaluate(a,{},_)],(x[0]>W_||x[1]>W_)&&pi(`${t.layerIds[0]}: Value for "text-size" is >= ${H_}. Reduce your "text-size".`)),t.addSymbols(t.text,y,x,l,s,a,d,e,i,c.lineStartIndex,c.lineLength,p,m,_,g,!1);for(const e of u)h[e]=t.text.placedSymbolArray.length-1;return 4*y.length}function X_(t){for(const e in t)return t[e];return null}function K_(t,e,i,n,r,o,s,a,l,c){let d=s.top,u=s.bottom,h=s.left,p=s.right;const f=s.collisionPadding;if(f&&(h-=f[0],d-=f[1],p+=f[2],u+=f[3]),l){const t=new Ue(h,d),e=new Ue(p,d),i=new Ue(h,u),n=new Ue(p,u),r=Ge(l);let o=new Ue(0,0);c&&(o=new Ue(c[0],c[1])),t._rotateAround(r,o),e._rotateAround(r,o),i._rotateAround(r,o),n._rotateAround(r,o),h=Math.min(t.x,e.x,i.x,n.x),p=Math.max(t.x,e.x,i.x,n.x),d=Math.min(t.y,e.y,i.y,n.y),u=Math.max(t.y,e.y,i.y,n.y)}return t.emplaceBack(e.x,e.y,e.z,i.x,i.y,h,d,p,u,a,n,r,o),t.length-1}function J_(t){t.collisionPadding&&(t.top-=t.collisionPadding[1],t.bottom+=t.collisionPadding[3]);const e=t.bottom-t.top;return e>0?Math.max(10,e):null}function Q_(t,e,i,n){const r=t.compareText;if(e in r){const t=r[e];for(let e=t.length-1;e>=0;e--)if(n.dist(t[e])v&&(x(t,c,n,r,a,l),x(c,i,a,l,o,s))}x(u,h,n,o,r,o),x(h,p,r,o,r,s),x(p,f,r,s,n,s),x(f,u,n,s,n,o),m-=v,_-=v,g+=v,y+=v;const b=1/Math.max(g-m,y-_);return{scale:b,x:m*b,y:_*b,x2:g*b,y2:y*b,projection:e}}function ig(t,{x:e,y:i},n=0){return new Ue(((e-n)*t.scale-t.x)*uo,(i*t.scale-t.y)*uo)}const ng=t.ad.identity(new Float32Array(16));class rg{constructor(t){this.spec=t,this.name=t.name,this.wrap=!1,this.requiresDraping=!1,this.supportsWorldCopies=!1,this.supportsTerrain=!1,this.supportsFog=!1,this.supportsFreeCamera=!1,this.zAxisUnit="meters",this.isReprojectedInTileSpace=!0,this.unsupportedLayers=["custom"],this.center=[0,0],this.range=[3.5,7]}project(t,e){return{x:0,y:0,z:0}}unproject(t,e){return new pd(0,0)}projectTilePoint(t,e,i){return{x:t,y:e,z:0}}locationPoint(t,e,i=!0){return t._coordinatePoint(t.locationCoordinate(e),i)}pixelsPerMeter(t,e){return Cd(1,t)*e}pixelSpaceConversion(t,e,i){return 1}farthestPixelDistance(t){return tg(t,t.pixelsPerMeter)}pointCoordinate(t,e,i,n){const r=t.horizonLineFromTop(!1),o=new Ue(e,Math.max(r,i));return t.rayIntersectionCoordinate(t.pointRayIntersection(o,n))}pointCoordinate3D(t,e,i){const n=new Ue(e,i);if(t.elevation)return t.elevation.pointCoordinate(n);{const e=this.pointCoordinate(t,n.x,n.y,0);return[e.x,e.y,e.z]}}isPointAboveHorizon(t,e){if(t.elevation&&t.elevation.visibleDemTiles.length)return!this.pointCoordinate3D(t,e.x,e.y);const i=t.horizonLineFromTop();return e.y0?epg-i&&(e=pg-i);const o=r/Math.pow(fg(e),n);let s=o*Math.sin(n*t),a=r-o*Math.cos(n*t);return s=.5*(s/Math.PI+.5),a=.5*(a/Math.PI+.5),{x:s,y:this.southernCenter?a:1-a,z:0}}unproject(t,e){t=(2*t-.5)*Math.PI,this.southernCenter&&(e=1-e),e=(2*(1-e)-.5)*Math.PI;const{n:i,f:n}=this,r=n-e,o=Math.sign(r),s=Math.sign(i)*Math.sqrt(t*t+r*r);let a=Math.atan2(t,Math.abs(r))*o;r*i1e-6&&--n>0);o=i*i;const s=Xe(Ze(t/(.8707+o*(o*(o*o*o*(.003971-.001529*o)-.013791)-.131979))),-180,180),a=Ze(i);return new pd(s,a)}}const vg=Ge(Pd);class xg extends rg{project(t,e){e=Ge(e),t=Ge(t);const i=Math.cos(e),n=2/Math.PI,r=Math.acos(i*Math.cos(t/2)),o=Math.sin(r)/r,s=.5*(t*n+2*i*Math.sin(t/2)/o)||0,a=.5*(e+Math.sin(e)/o)||0;return{x:.5*(s/Math.PI+.5),y:1-.5*(a/Math.PI+1),z:0}}unproject(t,e){let i=t=(2*t-.5)*Math.PI,n=e=(2*(1-e)-1)*Math.PI,r=25;const o=1e-6;let s=0,a=0;do{const r=Math.cos(n),o=Math.sin(n),l=2*o*r,c=o*o,d=r*r,u=Math.cos(i/2),h=Math.sin(i/2),p=2*u*h,f=h*h,m=1-d*u*u,_=m?1/m:0,g=m?Math.acos(r*u)*Math.sqrt(1/m):0,y=.5*(2*g*r*h+2*i/Math.PI)-t,v=.5*(g*o+n)-e,x=.5*_*(d*f+g*r*u*c)+1/Math.PI,b=_*(p*l/4-g*o*h),w=.125*_*(l*h-g*o*d*p),T=.5*_*(c*u+g*f*r)+.5,S=b*w-T*x;s=(v*b-y*T)/S,a=(y*w-v*x)/S,i=Xe(i-s,-Math.PI,Math.PI),n=Xe(n-a,-vg,vg)}while((Math.abs(s)>o||Math.abs(a)>o)&&--r>0);return new pd(Ze(i),Ze(n))}}class bg extends rg{constructor(t){super(t),this.center=t.center||[0,0],this.parallels=t.parallels||[0,0],this.cosPhi=Math.max(.01,Math.cos(Ge(this.parallels[0]))),this.scale=1/(2*Math.max(Math.PI*this.cosPhi,1/this.cosPhi)),this.wrap=!0,this.supportsWorldCopies=!0}project(t,e){const{scale:i,cosPhi:n}=this;return{x:Ge(t)*n*i+.5,y:-Math.sin(Ge(e))/n*i+.5,z:0}}unproject(t,e){const{scale:i,cosPhi:n}=this,r=-(e-.5)/i,o=Xe(Ze((t-.5)/i)/n,-180,180),s=Math.asin(Xe(r*n,-1,1)),a=Xe(Ze(s),-Pd,Pd);return new pd(o,a)}}class wg extends _g{constructor(t){super(t),this.requiresDraping=!0,this.supportsWorldCopies=!1,this.supportsFog=!0,this.zAxisUnit="pixels",this.unsupportedLayers=["debug"],this.range=[3,5]}projectTilePoint(e,i,n){const r=Fu(e,i,n),o=ju($u(n));return t._.transformMat4(r,r,o),{x:r[0],y:r[1],z:r[2]}}locationPoint(e,i){const n=dd(i.lat,i.lng),r=t._.normalize([],n),o=e.elevation?e.elevation.getAtPointOrZero(e.locationCoordinate(i),e._centerAltitude):e._centerAltitude,s=Cd(1,0)*uo*o;t._.scaleAndAdd(n,n,r,s);const a=t.ad.identity(new Float64Array(16));return t.ad.multiply(a,e.pixelMatrix,e.globeMatrix),t._.transformMat4(n,n,a),new Ue(n[0],n[1])}pixelsPerMeter(t,e){return Cd(1,0)*e}pixelSpaceConversion(t,e,i){const n=Cd(1,t)*e,r=Vn(Cd(1,45)*e,n,i);return this.pixelsPerMeter(t,e)/r}createTileMatrix(e,i,n){const r=Vu($u(n.canonical));return t.ad.multiply(new Float64Array(16),e.globeMatrix,r)}createInversionMatrix(e,i){const{center:n}=e,r=ju($u(i));return t.ad.rotateY(r,r,Ge(n.lng)),t.ad.rotateX(r,r,Ge(n.lat)),t.ad.scale(r,r,[e._pixelsPerMercatorPixel,e._pixelsPerMercatorPixel,1]),Float32Array.from(r)}pointCoordinate(t,e,i,n){return Iu(t,e,i,!0)||new Rd(0,0)}pointCoordinate3D(t,e,i){const n=this.pointCoordinate(t,e,i,0);return[n.x,n.y,n.z]}isPointAboveHorizon(t,e){return!Iu(t,e.x,e.y,!1)}farthestPixelDistance(e){const i=function(e,i){const n=e.cameraToCenterDistance,r=e._centerAltitude*i,o=e._camera,s=e._camera.forward(),a=t._.add([],t._.scale([],s,-n),[0,0,r]),l=e.worldSize/(2*Math.PI),c=[0,0,-l],d=e.width/e.height,u=Math.tan(e.fovAboveCenter),h=t._.scale([],o.up(),u),p=t._.scale([],o.right(),u*d),f=t._.normalize([],t._.add([],t._.add([],s,h),p)),m=[];let _;if(new mu(a,f).closestPointOnSphere(c,l,m)){const i=t._.add([],m,c),n=t._.sub([],i,a);_=Math.cos(e.fovAboveCenter)*t._.length(n)}else{const e=t._.sub([],a,c),i=t._.sub([],c,a);t._.normalize(i,i);const n=t._.length(e)-l;_=Math.sqrt(n*(n+2*l));const r=Math.acos(_/(l+n))-Math.acos(t._.dot(s,i));_*=Math.cos(r)}return 1.01*_}(e,this.pixelsPerMeter(e.center.lat,e.worldSize)),n=Hu(e.zoom);if(n>0){const t=tg(e,Cd(1,e.center.lat)*e.worldSize),r=e.worldSize/(2*Math.PI),o=Math.max(e.width,e.height)/e.worldSize*Math.PI;return Vn(i,t+r*(1-Math.cos(o)),Math.pow(n,10))}return i}upVector(t,e,i){return Fu(e,i,t,1)}upVectorScale(t){return{metersToTile:Cu(Nu($u(t)))}}}function Tg(t){const e=t.parallels,i=!!e&&Math.abs(e[0]+e[1])0&&(this.iconTransitioningVertexBuffer=t.createVertexBuffer(this.iconTransitioningVertexArray,Vf.members,!0)),this.globeExtVertexArray.length>0&&(this.globeExtVertexBuffer=t.createVertexBuffer(this.globeExtVertexArray,Ff.members,!0)),!this.zOffsetVertexBuffer&&(this.zOffsetVertexArray.length>0||r)&&(this.zOffsetVertexBuffer=t.createVertexBuffer(this.zOffsetVertexArray,jf.members,!0)),this.opacityVertexBuffer.itemSize=1),(i||n)&&this.programConfigurations.upload(t))}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy(),this.dynamicLayoutVertexBuffer.destroy(),this.opacityVertexBuffer.destroy(),this.occlusionQueryOpacityVertexBuffer.destroy(),this.iconTransitioningVertexBuffer&&this.iconTransitioningVertexBuffer.destroy(),this.globeExtVertexBuffer&&this.globeExtVertexBuffer.destroy(),this.zOffsetVertexBuffer&&this.zOffsetVertexBuffer.destroy())}}ba(Ng,"SymbolBuffers");class Ug{constructor(t,e,i){this.layoutVertexArray=new t,this.layoutAttributes=e,this.indexArray=new i,this.segments=new wc,this.collisionVertexArray=new Xl,this.collisionVertexArrayExt=new Ol}upload(t){this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,this.layoutAttributes),this.indexBuffer=t.createIndexBuffer(this.indexArray),this.collisionVertexBuffer=t.createVertexBuffer(this.collisionVertexArray,Gf.members,!0),this.collisionVertexBufferExt=t.createVertexBuffer(this.collisionVertexArrayExt,Zf.members,!0)}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.segments.destroy(),this.collisionVertexBuffer.destroy(),this.collisionVertexBufferExt.destroy())}}ba(Ug,"CollisionBuffers");class jg{constructor(e){this.queries=new Map,this.collisionBoxArray=e.collisionBoxArray,this.zoom=e.zoom,this.lut=e.lut,this.overscaling=e.overscaling,this.layers=e.layers,this.layerIds=this.layers.map((t=>t.fqid)),this.index=e.index,this.pixelRatio=e.pixelRatio,this.sourceLayerIndex=e.sourceLayerIndex,this.hasPattern=!1,this.hasRTLText=!1,this.fullyClipped=!1,this.hasAnyIconTextFit=!1,this.sortKeyRanges=[],this.collisionCircleArray=[],this.placementInvProjMatrix=t.ad.identity([]),this.placementViewportMatrix=t.ad.identity([]);const i=this.layers[0]._unevaluatedLayout._values;this.textSizeData=Fm(this.zoom,i["text-size"]),this.iconSizeData=Fm(this.zoom,i["icon-size"]);const n=this.layers[0].layout,r=n.get("symbol-sort-key"),o=n.get("symbol-z-order");this.canOverlap=n.get("text-allow-overlap")||n.get("icon-allow-overlap")||n.get("text-ignore-placement")||n.get("icon-ignore-placement"),this.sortFeaturesByKey="viewport-y"!==o&&void 0!==r.constantOr(1),this.sortFeaturesByY=("viewport-y"===o||"auto"===o&&!this.sortFeaturesByKey)&&this.canOverlap,this.writingModes=n.get("text-writing-mode").map((t=>Jm[t])),this.stateDependentLayerIds=this.layers.filter((t=>t.isStateDependent())).map((t=>t.id)),this.sourceID=e.sourceID,this.projection=e.projection,this.hasAnyZOffset=!1,this.zOffsetSortDirty=!1,this.zOffsetBuffersNeedUpload=n.get("symbol-z-elevate"),this.activeReplacements=[],this.replacementUpdateTime=0}createArrays(){this.text=new Ng(new Yc(this.layers,{zoom:this.zoom,lut:this.lut},(t=>/^text/.test(t)))),this.icon=new Ng(new Yc(this.layers,{zoom:this.zoom,lut:this.lut},(t=>/^icon/.test(t)))),this.glyphOffsetArray=new mc,this.lineVertexArray=new _c,this.symbolInstances=new fc}calculateGlyphDependencies(t,e,i,n,r){for(let i=0;i0)&&("constant"!==l.value.kind||l.value.value.length>0),h="constant"!==d.value.kind||!!d.value.value||Object.keys(d.parameters).length>0,p=s.get("symbol-sort-key");if(this.features=[],!u&&!h)return;const f=i.iconDependencies,m=i.glyphDependencies,_=i.availableImages,g=new Ha(this.zoom);for(const{feature:i,id:c,index:d,sourceLayerIndex:y}of e){const e=o._featureFilter.needGeometry,v=Zd(i,e);if(!o._featureFilter.filter(g,v,n))continue;if(e||(v.geometry=Gd(i,n,r)),a&&1!==i.type&&n.z{const o=Fu(e.x,e.y,n,1),s=Fu(r.x,r.y,n,1);return t._.dot(o,s)=0;for(const i of x.sections)if(i.image)f[i.image.namePrimary]=!0;else{const n=Ca(x.toString()),r=i.fontStack||t,o=m[r]=m[r]||{};this.calculateGlyphDependencies(i.text,o,e,this.allowVerticalPlacement,n)}}}"line"===s.get("symbol-placement")&&(this.features=function(t){const e={},i={},n=[];let r=0;function o(e){n.push(t[e]),r++}function s(t,e,r){const o=i[t];return delete i[t],i[e]=o,n[o].geometry[0].pop(),n[o].geometry[0]=n[o].geometry[0].concat(r[0]),o}function a(t,i,r){const o=e[i];return delete e[i],e[t]=o,n[o].geometry[0].shift(),n[o].geometry[0]=r[0].concat(n[o].geometry[0]),o}function l(t,e,i){const n=i?e[0][e[0].length-1]:e[0][0];return`${t}:${n.x}:${n.y}`}for(let c=0;ct.geometry))}(this.features)),this.sortFeaturesByKey&&this.features.sort(((t,e)=>t.sortKey-e.sortKey))}update(t,e,i,n,r){const o=0!==Object.keys(t).length;if(o&&!this.stateDependentLayers.length)return;const s=o?this.stateDependentLayers:this.layers;this.text.programConfigurations.updatePaintArrays(t,e,s,i,n,r),this.icon.programConfigurations.updatePaintArrays(t,e,s,i,n,r)}updateOcclusionOpacities(t,e,i){if(!e.useOcclusionQueries)return!1;const n=this;if("globe"===n.projection.name)return!1;let r=!1;n.hasTextData()&&(r=r||0!==n.text.occlusionQueryOpacityVertexArray.length),n.hasIconData()&&(r=r||0!==n.icon.occlusionQueryOpacityVertexArray.length);const o=n.layers[0].paint,s=o.get("icon-occlusion-opacity").constantOr(0),a=o.get("text-occlusion-opacity").constantOr(0);if(!n.layers[0].hasInitialOcclusionOpacityProperties||1===s&&1===a)return!1;let l=!r;for(let t=0;t.5?1:-1)*e.fadeSpeed*i*.001,r.occlusionOpacity=Xe(r.occlusionOpacity,0,1),l=l||r.occlusionOpacity!==o}if(!l)return!1;let c=0,d=0;const u=(t,e,i,n)=>{let r=0,o=0;i?(r=d,d+=n,o=d):(r=c,c+=n,o=c),o>e.occlusionQueryOpacityVertexArray.length&&e.occlusionQueryOpacityVertexArray.resize(o);const s=t.occlusionOpacity;for(let t=0;t0;if((i>0||r>0)&&(u(e,n.text,!1,i),u(e,n.text,!1,r)),s){const{placedIconSymbolIndex:t,verticalPlacedIconSymbolIndex:i}=e;t>=0&&u(e,n.icon,!0,o),i>=0&&u(e,n.icon,!0,e.numVerticalIconVertices)}}return n.hasTextData()&&n.text.occlusionQueryOpacityVertexBuffer&&(n.text.occlusionQueryOpacityVertexBuffer.length{i+=e,i>t.length&&t.resize(i);for(let r=-e;r{n+=e,n>t.length&&t.resize(n);for(let r=-e;r0;if((r>0||o>0)&&(t(this.text.zOffsetVertexArray,r,a),t(this.text.zOffsetVertexArray,o,a)),l){const{placedIconSymbolIndex:t,verticalPlacedIconSymbolIndex:i}=n;t>=0&&e(this.icon.zOffsetVertexArray,s,a),i>=0&&e(this.icon.zOffsetVertexArray,n.numVerticalIconVertices,a)}}this.text.zOffsetVertexBuffer&&this.text.zOffsetVertexBuffer.updateData(this.text.zOffsetVertexArray),this.icon.zOffsetVertexBuffer&&this.icon.zOffsetVertexBuffer.updateData(this.icon.zOffsetVertexArray)}isEmpty(){return 0===this.symbolInstances.length&&!this.hasRTLText}uploadPending(){return!this.uploaded||this.text.programConfigurations.needsUpload||this.icon.programConfigurations.needsUpload}upload(t){!this.uploaded&&this.hasDebugData()&&(this.textCollisionBox.upload(t),this.iconCollisionBox.upload(t)),this.text.upload(t,this.sortFeaturesByY,!this.uploaded,this.text.programConfigurations.needsUpload,this.zOffsetBuffersNeedUpload),this.icon.upload(t,this.sortFeaturesByY,!this.uploaded,this.icon.programConfigurations.needsUpload,this.zOffsetBuffersNeedUpload),this.uploaded=!0}destroyDebugData(){this.textCollisionBox.destroy(),this.iconCollisionBox.destroy()}getProjection(){return this.projectionInstance||(this.projectionInstance=Tg(this.projection)),this.projectionInstance}destroy(){this.text.destroy(),this.icon.destroy(),this.hasDebugData()&&this.destroyDebugData();for(const t of this.queries.values())t.destroy()}addToLineVertexArray(t,e){const i=this.lineVertexArray.length;if(void 0!==t.segment)for(const{x:t,y:i}of e)this.lineVertexArray.emplaceBack(t,i);return{lineStartIndex:i,lineLength:this.lineVertexArray.length-i}}addSymbols(t,e,i,n,r,o,s,a,l,c,d,u,h,p,f,m){const _=t.indexArray,g=t.layoutVertexArray,y=t.globeExtVertexArray,v=t.segments.prepareSegment(4*e.length,g,_,this.canOverlap?o.sortKey:void 0),x=this.glyphOffsetArray.length,b=v.vertexLength,w=this.allowVerticalPlacement&&s===Jm.vertical?Math.PI/2:0,T=o.text&&o.text.sections;for(let n=0;n=0?e.rightJustifiedTextSymbolIndex:e.centerJustifiedTextSymbolIndex>=0?e.centerJustifiedTextSymbolIndex:e.leftJustifiedTextSymbolIndex>=0?e.leftJustifiedTextSymbolIndex:e.verticalPlacedTextSymbolIndex>=0?e.verticalPlacedTextSymbolIndex:n),o=Nm(this.textSizeData,t,r)/Om;return this.tilePixelRatio*o}getSymbolInstanceIconSize(t,e,i){const n=this.icon.placedSymbolArray.get(i),r=Nm(this.iconSizeData,t,n);return this.tilePixelRatio*r}_commitDebugCollisionVertexUpdate(t,e,i,n){t.emplaceBack(e,-i,-i,n),t.emplaceBack(e,i,-i,n),t.emplaceBack(e,i,i,n),t.emplaceBack(e,-i,i,n)}_updateTextDebugCollisionBoxes(t,e,i,n,r,o){for(let s=n;s0}hasIconData(){return this.icon.segments.get().length>0}hasDebugData(){return this.textCollisionBox&&this.iconCollisionBox}hasTextCollisionBoxData(){return this.hasDebugData()&&this.textCollisionBox.segments.get().length>0}hasIconCollisionBoxData(){return this.hasDebugData()&&this.iconCollisionBox.segments.get().length>0}hasIconTextFit(){return this.hasAnyIconTextFit}addIndicesForPlacedSymbol(t,e){const i=t.placedSymbolArray.get(e),n=i.vertexStartIndex+4*i.numGlyphs;for(let e=i.vertexStartIndex;en[t]-n[e]||r[e]-r[t])),o}getSortedIndexesByZOffset(){if(!this.zOffsetSortDirty)return this.symbolInstanceIndexesSortedZOffset;if(!this.symbolInstanceIndexesSortedZOffset){this.symbolInstanceIndexesSortedZOffset=[];for(let t=0;tthis.symbolInstances.get(e).zOffset-this.symbolInstances.get(t).zOffset))}addToSortKeyRanges(t,e){const i=this.sortKeyRanges[this.sortKeyRanges.length-1];i&&i.sortKey===e?i.symbolInstanceEnd=t+1:this.sortKeyRanges.push({sortKey:e,symbolInstanceStart:t,symbolInstanceEnd:t+1})}sortFeatures(t){if(this.sortFeaturesByY&&this.sortedAngle!==t&&!(this.text.segments.get().length>1||this.icon.segments.get().length>1)){this.symbolInstanceIndexes=this.getSortedSymbolIndexes(t),this.sortedAngle=t,this.text.indexArray.clear(),this.icon.indexArray.clear(),this.featureSortOrder=[];for(const t of this.symbolInstanceIndexes){const e=this.symbolInstances.get(t);this.featureSortOrder.push(e.featureIndex);const{rightJustifiedTextSymbolIndex:i,centerJustifiedTextSymbolIndex:n,leftJustifiedTextSymbolIndex:r,verticalPlacedTextSymbolIndex:o,placedIconSymbolIndex:s,verticalPlacedIconSymbolIndex:a}=e;i>=0&&this.addIndicesForPlacedSymbol(this.text,i),n>=0&&n!==i&&this.addIndicesForPlacedSymbol(this.text,n),r>=0&&r!==n&&r!==i&&this.addIndicesForPlacedSymbol(this.text,r),o>=0&&this.addIndicesForPlacedSymbol(this.text,o),s>=0&&this.addIndicesForPlacedSymbol(this.icon,s),a>=0&&this.addIndicesForPlacedSymbol(this.icon,a)}this.text.indexBuffer&&this.text.indexBuffer.updateData(this.text.indexArray),this.icon.indexBuffer&&this.icon.indexBuffer.updateData(this.icon.indexArray)}}}ba(jg,"SymbolBucket",{omit:["layers","collisionBoxArray","features","compareText"]}),jg.addDynamicAttributes=Bg;class Vg{constructor(t,e,i,n){this.context=t,this.format=i,this.texture=t.gl.createTexture(),this.update(e,n)}update(t,e,i){const{width:n,height:r}=t,{context:o}=this,{gl:s}=o;if(s.bindTexture(s.TEXTURE_2D,this.texture),o.pixelStoreUnpackFlipY.set(!1),o.pixelStoreUnpack.set(1),o.pixelStoreUnpackPremultiplyAlpha.set(this.format===s.RGBA&&(!e||!1!==e.premultiply)),this.useMipmap=Boolean(e&&e.useMipmap),i||this.size&&this.size[0]===n&&this.size[1]===r){const{x:e,y:o}=i||{x:0,y:0};if(t instanceof HTMLImageElement||t instanceof HTMLCanvasElement||t instanceof HTMLVideoElement||t instanceof ImageData||ImageBitmap&&t instanceof ImageBitmap)s.texSubImage2D(s.TEXTURE_2D,0,e,o,s.RGBA,s.UNSIGNED_BYTE,t);else{let i=this.format,a=s.UNSIGNED_BYTE;this.format===s.R32F&&(i=s.RED,a=s.FLOAT),s.texSubImage2D(s.TEXTURE_2D,0,e,o,n,r,i,a,t.data)}}else if(this.size=[n,r],t instanceof HTMLImageElement||t instanceof HTMLCanvasElement||t instanceof HTMLVideoElement||t instanceof ImageData||ImageBitmap&&t instanceof ImageBitmap){let e=this.format;this.format===s.R8&&(e=s.RED),s.texImage2D(s.TEXTURE_2D,0,this.format,e,s.UNSIGNED_BYTE,t)}else{let e=this.format,i=this.format,o=s.UNSIGNED_BYTE,a=!1;this.format===s.DEPTH_COMPONENT&&(e=s.DEPTH_COMPONENT16,o=s.UNSIGNED_SHORT),this.format===s.DEPTH_STENCIL&&(e=s.DEPTH24_STENCIL8,o=s.UNSIGNED_INT_24_8,a=!0),this.format===s.R8&&(i=s.RED),this.format===s.R32F&&(o=s.FLOAT,i=s.RED),!this.useMipmap&&a?s.texStorage2D(s.TEXTURE_2D,1,e,n,r):s.texImage2D(s.TEXTURE_2D,0,e,n,r,0,i,o,t.data)}this.useMipmap&&s.generateMipmap(s.TEXTURE_2D)}bind(t,e,i=!1){const{context:n}=this,{gl:r}=n;r.bindTexture(r.TEXTURE_2D,this.texture),t!==this.minFilter&&(r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MAG_FILTER,t),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MIN_FILTER,this.useMipmap&&!i?t===r.NEAREST?r.NEAREST_MIPMAP_NEAREST:r.LINEAR_MIPMAP_LINEAR:t),this.minFilter=t),e!==this.wrapS&&(r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_S,e),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_T,e),this.wrapS=e)}bindExtraParam(t,e,i,n){const{context:r}=this,{gl:o}=r;o.bindTexture(o.TEXTURE_2D,this.texture),e!==this.magFilter&&(o.texParameteri(o.TEXTURE_2D,o.TEXTURE_MAG_FILTER,e),this.magFilter=e),t!==this.minFilter&&(o.texParameteri(o.TEXTURE_2D,o.TEXTURE_MIN_FILTER,this.useMipmap?t===o.NEAREST?o.NEAREST_MIPMAP_NEAREST:o.LINEAR_MIPMAP_LINEAR:t),this.minFilter=t),i!==this.wrapS&&(o.texParameteri(o.TEXTURE_2D,o.TEXTURE_WRAP_S,i),this.wrapS=i),n!==this.wrapT&&(o.texParameteri(o.TEXTURE_2D,o.TEXTURE_WRAP_T,n),this.wrapT=n)}destroy(){const{gl:t}=this.context;t.deleteTexture(this.texture),this.texture=null}}class Gg{constructor(t,e){this.context=t,this.texture=e}bind(t,e){const{context:i}=this,{gl:n}=i;n.bindTexture(n.TEXTURE_2D,this.texture),t!==this.minFilter&&(n.texParameteri(n.TEXTURE_2D,n.TEXTURE_MAG_FILTER,t),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_MIN_FILTER,t),this.minFilter=t),e!==this.wrapS&&(n.texParameteri(n.TEXTURE_2D,n.TEXTURE_WRAP_S,e),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_WRAP_T,e),this.wrapS=e)}}const Zg=32,qg=33,Hg=new Uint16Array(8184);for(let t=0;t>=1)>1;){const t=i+r>>1,l=n+o>>1;1&e?(r=i,o=n,i=s,n=a):(i=r,n=o,r=s,o=a),s=t,a=l}const l=4*t;Hg[l+0]=i,Hg[l+1]=n,Hg[l+2]=r,Hg[l+3]=o}const Wg=new Uint16Array(2178),Yg=new Uint8Array(1089),Xg=new Uint16Array(1089);function Kg(t){return 0===t?-.03125:32===t?.03125:0}var Jg=Ll([{name:"a_pos",type:"Int16",components:2},{name:"a_texture_pos",type:"Int16",components:2}]),Qg=Ll([{name:"a_index",type:"Int16",components:1}]);const ty={type:2,extent:uo,loadGeometry:()=>[[new Ue(0,0),new Ue(uo+1,0),new Ue(uo+1,uo+1),new Ue(0,uo+1),new Ue(0,0)]]};class ey{constructor(t,e,i,n,r){this.tileID=t,this.uid=ni(),this.uses=0,this.tileSize=e,this.tileZoom=i,this.buckets={},this.expirationTime=null,this.queryPadding=0,this.hasSymbolBuckets=!1,this.hasRTLText=!1,this.dependencies={},this.isRaster=r,n&&n.style&&(this._lastUpdatedBrightness=n.style.getBrightness()),this.expiredRequestCount=0,this.state="loading",n&&n.transform&&(this.projection=n.transform.projection)}registerFadeDuration(t){const e=t+this.timeAdded;ee.getLayer(t))).filter(Boolean);if(0!==t.length){n.layers=t,n.stateDependentLayerIds&&(n.stateDependentLayers=n.stateDependentLayerIds.map((e=>t.filter((t=>t.id===e))[0])));for(const e of t)i[e.fqid]=n}}return i}(t.buckets,e.style),this.hasSymbolBuckets=!1;for(const t in this.buckets){const e=this.buckets[t];if(e instanceof jg){if(this.hasSymbolBuckets=!0,!i)break;e.justReloaded=!0}}if(this.hasRTLText=!1,this.hasSymbolBuckets)for(const t in this.buckets){const e=this.buckets[t];if(e instanceof jg&&e.hasRTLText){this.hasRTLText=!0,qa.isLoading()||qa.isLoaded()||"deferred"!==Ga()||Za();break}}this.queryPadding=0;for(const t in this.buckets){const i=this.buckets[t],n=e.style.getOwnLayer(t);if(!n)continue;const r=n.queryRadius(i);this.queryPadding=Math.max(this.queryPadding,r)}t.imageAtlas&&(this.imageAtlas=t.imageAtlas),t.glyphAtlasImage&&(this.glyphAtlasImage=t.glyphAtlasImage),t.lineAtlas&&(this.lineAtlas=t.lineAtlas),this._lastUpdatedBrightness=t.brightness}else this.collisionBoxArray=new dc}unloadVectorData(){if(this.hasData()){for(const t in this.buckets)this.buckets[t].destroy();this.buckets={},this.imageAtlas&&(this.imageAtlas=null),this.lineAtlas&&(this.lineAtlas=null),this.imageAtlasTexture&&this.imageAtlasTexture.destroy(),this.glyphAtlasTexture&&this.glyphAtlasTexture.destroy(),this.lineAtlasTexture&&this.lineAtlasTexture.destroy(),this._tileBoundsBuffer&&(this._tileBoundsBuffer.destroy(),this._tileBoundsIndexBuffer.destroy(),this._tileBoundsSegments.destroy(),this._tileBoundsBuffer=null),this._tileDebugBuffer&&(this._tileDebugBuffer.destroy(),this._tileDebugSegments.destroy(),this._tileDebugBuffer=null),this._tileDebugIndexBuffer&&(this._tileDebugIndexBuffer.destroy(),this._tileDebugIndexBuffer=null),this._globeTileDebugBorderBuffer&&(this._globeTileDebugBorderBuffer.destroy(),this._globeTileDebugBorderBuffer=null),this._tileDebugTextBuffer&&(this._tileDebugTextBuffer.destroy(),this._tileDebugTextSegments.destroy(),this._tileDebugTextIndexBuffer.destroy(),this._tileDebugTextBuffer=null),this._globeTileDebugTextBuffer&&(this._globeTileDebugTextBuffer.destroy(),this._globeTileDebugTextBuffer=null),this.latestFeatureIndex=null,this.state="unloaded"}}getBucket(t){return this.buckets[t.fqid]}upload(t){for(const e in this.buckets){const i=this.buckets[e];i.uploadPending()&&i.upload(t)}const e=t.gl,i=this.imageAtlas;if(i&&!i.uploaded){const n=!!Object.keys(i.patternPositions).length;this.imageAtlasTexture=new Vg(t,i.image,e.RGBA,{useMipmap:n}),this.imageAtlas.uploaded=!0}this.glyphAtlasImage&&(this.glyphAtlasTexture=new Vg(t,this.glyphAtlasImage,e.R8),this.glyphAtlasImage=null),this.lineAtlas&&!this.lineAtlas.uploaded&&(this.lineAtlasTexture=new Vg(t,this.lineAtlas.image,e.R8),this.lineAtlas.uploaded=!0)}prepare(t,e,i){if(this.imageAtlas&&this.imageAtlasTexture&&this.imageAtlas.patchUpdatedImages(t,this.imageAtlasTexture,i),!e||!this.latestFeatureIndex||!this.latestFeatureIndex.rawTileData)return;const n=e.style.getBrightness();(this._lastUpdatedBrightness||n)&&(this._lastUpdatedBrightness&&n&&Math.abs(this._lastUpdatedBrightness-n)t)i=!1;else if(e)if(this.expirationTime=0;t--){const e=4*t,i=Hg[e+0],n=Hg[e+1],r=Hg[e+2],o=Hg[e+3],s=i+r>>1,a=n+o>>1,l=s+a-n,c=a+i-s,d=n*qg+i,u=o*qg+r,h=a*qg+s,p=Math.hypot((Wg[2*d+0]+Wg[2*u+0])/2-Wg[2*h+0],(Wg[2*d+1]+Wg[2*u+1])/2-Wg[2*h+1])>=16;Yg[h]=Yg[h]||(p?1:0),t>1)*qg+(i+l>>1)]||Yg[(o+c>>1)*qg+(r+l>>1)])}const r=new Dl,o=new Kl;let s=0;function a(t,e){const i=e*qg+t;return 0===Xg[i]&&(r.emplaceBack(Wg[2*i+0],Wg[2*i+1],t*uo/Zg,e*uo/Zg),Xg[i]=++s),Xg[i]-1}function l(t,e,i,n,r,s){const c=t+i>>1,d=e+n>>1;if(Math.abs(t-r)+Math.abs(e-s)>1&&Yg[d*qg+c])l(r,s,t,e,c,d),l(i,n,r,s,c,d);else{const l=a(t,e),c=a(i,n),d=a(r,s);o.emplaceBack(l,c,d)}}return l(0,0,Zg,Zg,Zg,0),l(Zg,Zg,0,0,0,Zg),{vertices:r,indices:o}}(this.tileID.canonical,e);n=t.vertices,r=t.indices}else{n=new Dl,r=new Kl;for(const{x:t,y:e}of i)n.emplaceBack(t,e,0,0);const t=xh(n.int16,void 0,4);for(let e=0;e0&&(a=t.ad.invert(new Float64Array(16),i.globeMatrix)),this._makeGlobeTileDebugBorderBuffer(e,r,i,o,a,s),this._makeGlobeTileDebugTextBuffer(e,r,i,o,a,s)}_globePoint(e,i,n,r,o,s,a){let l=Fu(e,i,n);if(s){const o=1.5?h=-1:u{const p=(d-t)/(h-1),f=(u-c)/(h-1),m=s.length;for(let d=0;dd*t+e;for(let t=0;t[t,this.get(t)]))}evict(t=!1){if(t||this.size>0){const t=this.first;delete this.items[t.key],0==--this.size?(this.first=null,this.last=null):(this.first=t.next,this.first.prev=null)}return this}expiresAt(t){let e;return this.has(t)&&(e=this.items[t].expiry),e}get(t){let e;if(this.has(t)){const i=this.items[t];this.ttl>0&&i.expiry0?Date.now()+this.ttl:this.ttl),this.last!==r){const t=this.last,e=r.next,i=r.prev;this.first===r&&(this.first=r.next),r.next=null,r.prev=this.last,t.next=r,null!==i&&(i.next=e),null!==e&&(e.prev=i)}}else this.max>0&&this.size===this.max&&this.evict(!0),r=this.items[t]={expiry:this.ttl>0?Date.now()+this.ttl:this.ttl,key:t,prev:this.last,next:null,value:e},1==++this.size?this.first=r:this.last.next=r;return this.last=r,this}values(t=this.keys()){return t.map((t=>this.get(t)))}}function uy(t,e){if(4!==e.length)throw new Error(`Expected data of dimension 4 but got ${e.length}.`);let i=e[3];for(let n=2;n>=1;n--){const r=1===n?1:0,o=2===n?1:0;for(let n=0;n>>1^-(1&t[e]);return t}function py(t,e){switch(e){case"uint32":return t;case"uint16":for(let e=0;e>4|(61440&i)>>8|(240&n)>4|(15&n)>6|(192&n)>>4|(192&r)>>2|192&o,t[e+1]=(48&i)>>4|(48&n)>>2|48&r|(48&o)>2|12&n|(12&r)>1|(21845&Cy)>2|(13107&Ay)>4|(3855&Ay)>8|(255&Ay)>1}var Iy=function(t,e,i){for(var n=t.length,r=0,o=new _y(e);r>l]=c}else for(s=new _y(n),r=0;r>15-t[r]);return s},Ly=new my(288);for(Cy=0;Cye&&(e=t[i]);return e},zy=function(t,e,i){var n=e/8|0;return(t[n]|t[n+1]>(7&e)&i},Ry=function(t,e){var i=e/8|0;return(t[i]|t[i+1]>(7&e)},Oy=["unexpected EOF","invalid block type","invalid length/literal","invalid distance","stream finished","no stream handler",,"no callback","invalid UTF-8 data","extra field too long","date not in range 1980-2099","filename too long","stream finishing","invalid zip data"],By=function(t,e,i){var n=new Error(e||Oy[t]);if(n.code=t,Error.captureStackTrace&&Error.captureStackTrace(n,By),!i)throw n;return n},Fy=new my(0),Ny="undefined"!=typeof TextDecoder&&new TextDecoder;try{Ny.decode(Fy,{stream:!0})}catch(t){}const Uy={gzip_data:"gzip"},jy={0:"uint32",1:"uint32",2:"uint16",3:"uint8"},Vy={uint32:1,uint16:2,uint8:4},Gy={uint32:Uint32Array,uint16:Uint16Array,uint8:Uint8Array};class Zy{constructor(t=1){this.x=NaN,this.y=NaN,this.z=NaN,this.layers={},this._cacheSize=t}getLayer(t){return this.layers[t]}getHeaderLength(t){const e=new Uint8Array(t),i=new DataView(t);if(13!==e[0])throw new fy("File is not a valid MRT.");return i.getUint32(1,!0)}parseHeader(t){const e=new Uint8Array(t),i=this.getHeaderLength(t);if(e.length= ${i} but got buffer of length ${e.length}`);const n=function(t){return t.readFields(iy,{header_length:0,x:0,y:0,z:0,layers:[]},void 0)}(new Lm(e.subarray(0,i)));if(!isNaN(this.x)&&(this.x!==n.x||this.y!==n.y||this.z!==n.z))throw new fy(`Invalid attempt to parse header ${n.z}/${n.x}/${n.y} for tile ${this.z}/${this.x}/${this.y}`);this.x=n.x,this.y=n.y,this.z=n.z;for(const t of n.layers)this.layers[t.name]=new qy(t,{cacheSize:this._cacheSize});return this}createDecodingTask(t){const e=[],i=this.getLayer(t.layerName);for(let n=0;nt.lastBlock)continue;if(i._blocksInProgress.has(n))continue;const a={layerName:i.name,firstByte:o,lastByte:s,pixelFormat:i.pixelFormat,blockIndex:n,blockShape:[r.bands.length].concat(i.bandShape),buffer:i.buffer,codec:r.codec.codec,filters:r.filters.map((t=>t.filter))};i._blocksInProgress.add(n),e.push(a)}return new Hy(e,(()=>{e.forEach((t=>i._blocksInProgress.delete(t.blockIndex)))}),((t,n)=>{if(e.forEach((t=>i._blocksInProgress.delete(t.blockIndex))),t)throw t;n.forEach((t=>{this.getLayer(t.layerName).processDecodedData(t)}))}))}}class qy{constructor({version:t,name:e,units:i,tilesize:n,pixel_format:r,buffer:o,data_index:s},a){if(this.version=t,1!==this.version)throw new fy(`Cannot parse raster layer encoded with MRT version ${t}`);this.name=e,this.units=i,this.tileSize=n,this.buffer=o,this.pixelFormat=jy[r],this.dataIndex=s,this.bandShape=[n+2*o,n+2*o,Vy[this.pixelFormat]],this._decodedBlocks=function(t=1e3,e=0,i=!1){if(isNaN(t)||t=e&&t=0}hasDataForBand(t){const{blockIndex:e}=this.getBlockForBand(t);return e>=0&&!!this._decodedBlocks.get(e.toString())}getBandView(t){const{blockIndex:e,blockBandIndex:i}=this.getBlockForBand(t),n=this._decodedBlocks.get(e.toString());if(!n)throw new fy(`Data for band ${JSON.stringify(t)} of layer "${this.name}" not decoded.`);const r=this.dataIndex[e],o=this.bandShape.reduce(((t,e)=>t*e),1),s=i*o,a=n.subarray(s,s+o);return{data:a,bytes:new Uint8Array(a.buffer).subarray(a.byteOffset,a.byteOffset+a.byteLength),tileSize:this.tileSize,buffer:this.buffer,offset:r.offset,scale:r.scale}}}class Hy{constructor(t,e,i){this.tasks=t,this._onCancel=e,this._onComplete=i,this._finalized=!1}cancel(){this._finalized||(this._onCancel(),this._finalized=!0)}complete(t,e){this._finalized||(this._onComplete(t,e),this._finalized=!0)}}Zy.performDecoding=function(t,e){return Promise.all(e.tasks.map((e=>{const{layerName:i,firstByte:n,lastByte:r,pixelFormat:o,blockShape:s,blockIndex:a,filters:l,codec:c}=e,d=new Uint8Array(t).subarray(n,r+1),u=new Uint32Array(s[0]*s[1]*s[2]);let h;if("gzip_data"!==c)throw new Error(`Unhandled codec: ${c}`);return h=function(t,e){if(!globalThis.DecompressionStream&&"gzip_data"===e)return Promise.resolve(((o=function(t){31==t[0]&&139==t[1]&&8==t[2]||By(6,"invalid gzip data");var e=t[3],i=10;4&e&&(i+=2+(t[10]|t[11]>3&1)+(e>>4&1);n>0;n-=!t[i++]);return i+(2&e)}(r=t))+8>r.length&&By(6,"invalid gzip data"),function(t,e,i){var n=t.length;if(!n||e.f&&!e.l)return i||new my(0);var r=!i,o=r||2!=e.i,s=e.i;r&&(i=new my(3*n));var a,l,c=function(t){var e=i.length;if(t>e){var n=new my(Math.max(2*e,t));n.set(i),i=n}},d=e.f||0,u=e.p||0,h=e.b||0,p=e.l,f=e.d,m=e.m,_=e.n,g=8*n;do{if(!p){d=zy(t,u,1);var y=zy(t,u+1,3);if(u+=3,!y){var v=t[(L=4+((u+7)/8|0))-4]|t[L-3]n){s&&By(0);break}o&&c(h+v),i.set(t.subarray(L,x),h),e.b=h+=v,e.p=u=8*x,e.f=d;continue}if(1==y)p=$y,f=ky,m=9,_=5;else if(2==y){var b=zy(t,u,31)+257,w=zy(t,u+10,15)+4,T=b+zy(t,u+5,31)+1;u+=14;for(var S=new my(T),E=new my(19),M=0;M>4)g){s&&By(0);break}}o&&c(h+131072);for(var R=(1>4;if((u+=15&$)>g){s&&By(0);break}if($||By(2),F264&&(N=zy(t,u,(1>4;if(U||By(3),u+=15&U,z=Ey[j],j>3){var V=vy[j];z+=Ry(t,u)&(1g){s&&By(0);break}o&&c(h+131072);var G=h+N;if(ha.length)&&(l=a.length),new my(a.subarray(0,l))):i.subarray(0,h)}(r.subarray(o,-8),{i:2},new my(((i=r)[(n=i.length)-4]|i[n-3]>>0))));var i,n,r,o;const s=Uy[e];if(!s)throw new Error(`Unhandled codec: ${e}`);const a=new globalThis.DecompressionStream(s);return new Response(new Blob([t]).stream().pipeThrough(a)).arrayBuffer().then((t=>new Uint8Array(t)))}(d,c).then((t=>(function(t,e){t.readFields(ly,e)}(new Lm(t),u),new(0,Gy[o])(u.buffer)))),h.then((t=>{for(let e=l.length-1;e>=0;e--)switch(l[e]){case"delta_filter":uy(t,s);break;case"zigzag_filter":hy(t);break;case"bitshuffle_filter":py(t,o);break;default:throw new Error(`Unhandled filter "${l[e]}"`)}return{layerName:i,blockIndex:a,data:t}})).catch((t=>{throw t}))})))};class Wy extends ey{constructor(t,e,i,n,r){super(t,e,i,n,r),this._workQueue=[],this._fetchQueue=[],this._isHeaderLoaded=!1}setTexture(t,e){const i=e.context,n=i.gl;this.texture=this.texture||e.getTileTexture(t.width),this.texture&&this.texture instanceof Vg?this.texture.update(t,{useMipmap:!1,premultiply:!1}):this.texture=new Vg(i,t,n.RGBA,{useMipmap:!1,premultiply:!1})}flushQueues(){for(;this._workQueue.length;)this._workQueue.pop()();for(;this._fetchQueue.length;)this._fetchQueue.pop()()}fetchHeader(t=16384,e){const i=this._mrt=new Zy(30),n=Object.assign({},this.requestParams,{headers:{Range:"bytes=0-"+(t-1)}});return this.entireBuffer=null,this.request=en(n,((n,r,o,s)=>{if(n)e(n);else try{const n=i.getHeaderLength(r);if(n>t)return void(this.request=this.fetchHeader(n,e));i.parseHeader(r),this._isHeaderLoaded=!0;let a=0;for(const t of Object.values(i.layers))a=Math.max(a,t.dataIndex[t.dataIndex.length-1].last_byte);r.byteLength>=a&&(this.entireBuffer=r),e(null,this.entireBuffer||r,o,s)}catch(t){e(t)}})),this.request}fetchBand(t,e,i){const n=this._mrt;if(!this._isHeaderLoaded||!n)return void i(new Error("Tile header is not ready"));const r=this.actor;if(!r)return void i(new Error("Can't fetch tile band without an actor"));let o;const s=(n,r)=>{o.complete(n,r),n?i(n):(this.updateTextureDescriptor(t,e),i(null,this.textureDescriptor&&this.textureDescriptor.img))},a=(t,e)=>{if(t)return i(t);const n=r.send("decodeRasterArray",{buffer:e,task:o},s,void 0,!0);this._workQueue.push((()=>{n&&n.cancel(),o.cancel()}))},l=n.getLayer(t);if(!l)return void i(new Error(`Unknown sourceLayer "${t}"`));if(l.hasDataForBand(e))return this.updateTextureDescriptor(t,e),void i(null,this.textureDescriptor?this.textureDescriptor.img:null);const c=l.getDataRange([e]);if(o=n.createDecodingTask(c),!o||o.tasks.length)if(this.flushQueues(),this.entireBuffer)a(null,this.entireBuffer.slice(c.firstByte,c.lastByte+1));else{const t=Object.assign({},this.requestParams,{headers:{Range:`bytes=${c.firstByte}-${c.lastByte}`}}),e=en(t,a);this._fetchQueue.push((()=>{e.cancel(),o.cancel()}))}else i(null)}updateNeeded(t,e){return(!this.textureDescriptor||this.textureDescriptor.band!==e||this.textureDescriptor.layer!==t)&&"errored"!==this.state}updateTextureDescriptor(t,e){if(!this._mrt)return;const i=this._mrt.getLayer(t);if(!i||!i.hasBand(e)||!i.hasDataForBand(e))return;const{bytes:n,tileSize:r,buffer:o,offset:s,scale:a}=i.getBandView(e),l=r+2*o,c={data:n,width:l,height:l},d=this.texture;d&&d instanceof Vg&&d.update(c,{useMipmap:!1,premultiply:!1}),this.textureDescriptor={layer:t,band:e,img:c,buffer:o,offset:s,tileSize:r,format:i.pixelFormat,mix:[a,256*a,65536*a,16777216*a]}}}class Yy{constructor(t,e){this.max=t,this.onRemove=e,this.reset()}reset(){for(const t in this.data)for(const e of this.data[t])e.timeout&&clearTimeout(e.timeout),this.onRemove(e.value);return this.data={},this.order=[],this}add(t,e,i){const n=t.wrapped().key;void 0===this.data[n]&&(this.data[n]=[]);const r={value:e,timeout:void 0};if(void 0!==i&&(r.timeout=setTimeout((()=>{this.remove(t,r)}),i)),this.data[n].push(r),this.order.push(n),this.order.length>this.max){const t=this._getAndRemoveByKey(this.order[0]);t&&this.onRemove(t)}return this}has(t){return t.wrapped().key in this.data}getAndRemove(t){return this.has(t)?this._getAndRemoveByKey(t.wrapped().key):null}_getAndRemoveByKey(t){const e=this.data[t].shift();return e.timeout&&clearTimeout(e.timeout),0===this.data[t].length&&delete this.data[t],this.order.splice(this.order.indexOf(t),1),e.value}getByKey(t){const e=this.data[t];return e?e[0].value:null}get(t){return this.has(t)?this.data[t.wrapped().key][0].value:null}remove(t,e){if(!this.has(t))return this;const i=t.wrapped().key,n=void 0===e?0:this.data[i].indexOf(e),r=this.data[i][n];return this.data[i].splice(n,1),r.timeout&&clearTimeout(r.timeout),0===this.data[i].length&&delete this.data[i],this.onRemove(r.value),this.order.splice(this.order.indexOf(i),1),this}setMaxSize(t){for(this.max=t;this.order.length>this.max;){const t=this._getAndRemoveByKey(this.order[0]);t&&this.onRemove(t)}return this}filter(t){const e=[];for(const i in this.data)for(const n of this.data[i])t(n.value)||e.push(n);for(const t of e)this.remove(t.value.tileID,t)}}class Xy extends zn{constructor(t,e,i){super(),this.id=t,this._onlySymbols=i,e.on("data",(t=>{"source"===t.dataType&&"metadata"===t.sourceDataType&&(this._sourceLoaded=!0),this._sourceLoaded&&!this._paused&&"source"===t.dataType&&"content"===t.sourceDataType&&(this.reload(),this.transform&&this.update(this.transform))})),e.on("error",(()=>{this._sourceErrored=!0})),this._source=e,this._tiles={},this._cache=new Yy(0,this._unloadTile.bind(this)),this._timers={},this._cacheTimers={},this._minTileCacheSize=e.minTileCacheSize,this._maxTileCacheSize=e.maxTileCacheSize,this._loadedParentTiles={},this.castsShadows=!1,this.tileCoverLift=0,this._coveredTiles={},this._shadowCasterTiles={},this._state=new km,this._isRaster="raster"===this._source.type||"raster-dem"===this._source.type||"raster-array"===this._source.type||"custom"===this._source.type&&"raster"===this._source._dataType}onAdd(t){this.map=t,this._minTileCacheSize=void 0===this._minTileCacheSize&&t?t._minTileCacheSize:this._minTileCacheSize,this._maxTileCacheSize=void 0===this._maxTileCacheSize&&t?t._maxTileCacheSize:this._maxTileCacheSize}loaded(){if(this._sourceErrored)return!0;if(!this._sourceLoaded)return!1;if(!this._source.loaded())return!1;for(const t in this._tiles){const e=this._tiles[t];if("errored"!==e.state&&("loaded"!==e.state||!e.bucketsLoaded()))return!1}return!0}getSource(){return this._source}pause(){this._paused=!0}resume(){if(!this._paused)return;const t=this._shouldReloadOnResume;this._paused=!1,this._shouldReloadOnResume=!1,t&&this.reload(),this.transform&&this.update(this.transform)}_loadTile(t,e){return t.isSymbolTile=this._onlySymbols,t.isExtraShadowCaster=this._shadowCasterTiles[t.tileID.key],this._source.loadTile(t,e)}_unloadTile(t){if(this._source.unloadTile)return this._source.unloadTile(t)}_abortTile(t){if(this._source.abortTile)return this._source.abortTile(t)}serialize(){return this._source.serialize()}prepare(t){this._source.prepare&&this._source.prepare(),this._state.coalesceChanges(this._tiles,this.map?this.map.painter:null);for(const e in this._tiles){const i=this._tiles[e];i.upload(t),i.prepare(this.map.style.imageManager,this.map?this.map.painter:null,this._source.scope)}}getIds(){return ti(this._tiles).map((t=>t.tileID)).sort(Ky).map((t=>t.key))}getRenderableIds(t,e){const i=[];for(const n in this._tiles)this._isIdRenderable(+n,t,e)&&i.push(this._tiles[n]);return t?i.sort(((t,e)=>{const i=t.tileID,n=e.tileID,r=new Ue(i.canonical.x,i.canonical.y)._rotate(this.transform.angle),o=new Ue(n.canonical.x,n.canonical.y)._rotate(this.transform.angle);return i.overscaledZ-n.overscaledZ||o.y-r.y||o.x-r.x})).map((t=>t.tileID.key)):i.map((t=>t.tileID)).sort(Ky).map((t=>t.key))}hasRenderableParent(t){const e=this.findLoadedParent(t,0);return!!e&&this._isIdRenderable(e.tileID.key)}_isIdRenderable(t,e,i){return this._tiles[t]&&this._tiles[t].hasData()&&!this._coveredTiles[t]&&(e||!this._tiles[t].holdingForFade())&&(i||!this._shadowCasterTiles[t])}reload(){if(this._paused)this._shouldReloadOnResume=!0;else{this._cache.reset();for(const t in this._tiles)"errored"!==this._tiles[t].state&&this._reloadTile(+t,"reloading")}}_reloadTile(t,e){const i=this._tiles[t];i&&("loading"!==i.state&&(i.state=e),this._loadTile(i,this._tileLoaded.bind(this,i,t,e)))}_tileLoaded(t,e,i,n){if(n)if(t.state="errored",404!==n.status)this._source.fire(new $n(n,{tile:t}));else{if(!(t.tileID.key in this._loadedParentTiles))return void this._source.fire(new Pn("data",{dataType:"source",sourceDataType:"error",sourceId:this._source.id}));if("raster-dem"===this._source.type&&this.usedForTerrain&&this.map.painter.terrain){const t=this.map.painter.terrain;this.update(this.transform,t.getScaledDemTileSize(),!0),t.resetTileLookupCache(this.id)}else this.update(this.transform)}else t.timeAdded=ki.now(),"expired"===i&&(t.refreshedUponExpiration=!0),this._setTileReloadTimer(e,t),"raster-dem"===this._source.type&&t.dem&&this._backfillDEM(t),this._state.initializeTileState(t,this.map?this.map.painter:null),this._source.fire(new Pn("data",{dataType:"source",tile:t,coord:t.tileID,sourceCacheId:this.id}))}_backfillDEM(t){const e=this.getRenderableIds();for(let n=0;n1||(Math.abs(i)>1&&(1===Math.abs(i+r)?i+=r:1===Math.abs(i-r)&&(i-=r)),e.dem&&t.dem&&(t.dem.backfillBorder(e.dem,i,n),t.neighboringTiles&&t.neighboringTiles[o]&&(t.neighboringTiles[o].backfilled=!0)))}}getTile(t){return this.getTileByID(t.key)}getTileByID(t){return this._tiles[t]}_retainLoadedChildren(t,e,i,n){for(const r in this._tiles){let o=this._tiles[r];if(n[r]||!o.hasData()||o.tileID.overscaledZi)continue;let s=o.tileID;for(;o&&o.tileID.overscaledZ>e+1;){const t=o.tileID.scaledTo(o.tileID.overscaledZ-1);o=this._tiles[t.key],o&&o.hasData()&&(s=t)}let a=s;for(;a.overscaledZ>e;)if(a=a.scaledTo(a.overscaledZ-1),t[a.key]){n[s.key]=s;break}}}findLoadedParent(t,e){if(t.key in this._loadedParentTiles){const i=this._loadedParentTiles[t.key];return i&&i.tileID.overscaledZ>=e?i:null}for(let i=t.overscaledZ-1;i>=e;i--){const e=t.scaledTo(i),n=this._getLoadedTile(e);if(n)return n}}_getLoadedTile(t){const e=this._tiles[t.key];return e&&e.hasData()?e:this._cache.getByKey(this._source.reparseOverscaled?t.wrapped().key:t.canonical.key)}updateCacheSize(t,e){e=e||this._source.tileSize;const i=Math.ceil(t.width/e)+1,n=Math.ceil(t.height/e)+1,r=Math.floor(i*n*5),o="number"==typeof this._minTileCacheSize?Math.max(this._minTileCacheSize,r):r,s="number"==typeof this._maxTileCacheSize?Math.min(this._maxTileCacheSize,o):o;this._cache.setMaxSize(s)}handleWrapJump(t){const e=Math.round((t-(void 0===this._prevLng?t:this._prevLng))/360);if(this._prevLng=t,e){const t={};for(const i in this._tiles){const n=this._tiles[i];n.tileID=n.tileID.unwrapTo(n.tileID.wrap+e),t[n.tileID.key]=n}this._tiles=t;for(const t in this._timers)clearTimeout(this._timers[t]),delete this._timers[t];for(const t in this._tiles)this._setTileReloadTimer(+t,this._tiles[t])}}update(t,e,i,n){if(this.transform=t,!this._sourceLoaded||this._paused||this.transform.freezeTileCoverage)return;if(this.usedForTerrain&&!i)return;let r;if(this.updateCacheSize(t,e),"globe"!==this.transform.projection.name&&this.handleWrapJump(this.transform.center.lng),this._shadowCasterTiles={},this._coveredTiles={},this.used||this.usedForTerrain){if(this._source.tileID)r=t.getVisibleUnwrappedCoordinates(this._source.tileID).map((t=>new vd(t.canonical.z,t.wrap,t.canonical.z,t.canonical.x,t.canonical.y)));else if(0!==this.tileCoverLift){const n=t.clone();n.tileCoverLift=this.tileCoverLift,r=n.coveringTiles({tileSize:e||this._source.tileSize,minzoom:this._source.minzoom,maxzoom:this._source.maxzoom,roundZoom:this._source.roundZoom&&!i,reparseOverscaled:this._source.reparseOverscaled,isTerrainDEM:this.usedForTerrain}),this._source.minzoomt(e)))}}else r=[];if(r.length>0&&this.castsShadows&&n&&"globe"!==this.transform.projection.name&&!this.usedForTerrain&&!Jy(this._source.type)){const o=t.coveringZoomLevel({tileSize:e||this._source.tileSize,roundZoom:this._source.roundZoom&&!i}),s=Math.min(o,this._source.maxzoom),a=t.extendTileCoverForShadows(r,n,s);for(const t of a)this._shadowCasterTiles[t.key]=!0,r.push(t)}const o=this._updateRetainedTiles(r);if(Jy(this._source.type)&&0!==r.length){const t={},e={},i=Object.keys(o);for(const n of i){const i=o[n],r=this._tiles[n];if(!r||r.fadeEndTime&&r.fadeEndTimen;){r=r.scaledTo(r.overscaledZ-1);const n=this._tiles[r.key];if(n&&n.hasData()&&e[r.key]){o[t]=i.tileID;break}}}for(const e in t)o[e]||(this._coveredTiles[e]=!0,o[e]=t[e])}for(const t in o)this._tiles[t].clearFadeHold();const s=function(t,e){const i=[];for(const n in t)n in e||i.push(n);return i}(this._tiles,o);for(const t of s){const e=this._tiles[t];e.hasSymbolBuckets&&!e.holdingForFade()?e.setHoldDuration(this.map._fadeDuration):e.hasSymbolBuckets&&!e.symbolFadeFinished()||this._removeTile(+t)}this._updateLoadedParentTileCache(),this._onlySymbols&&this._source.afterUpdate&&this._source.afterUpdate()}releaseSymbolFadeTiles(){for(const t in this._tiles)this._tiles[t].holdingForFade()&&this._removeTile(+t)}_updateRetainedTiles(t){const e={};if(0===t.length)return e;const i={},n=t.reduce(((t,e)=>Math.min(t,e.overscaledZ)),1/0),r=t[0].overscaledZ,o=Math.max(r-Xy.maxOverzooming,this._source.minzoom),s=Math.max(r+Xy.maxUnderzooming,this._source.minzoom),a={};for(const i of t){const t=this._addTile(i);e[i.key]=i,t.hasData()||n=this._source.maxzoom){const t=n.children(this._source.maxzoom)[0],i=this.getTile(t);if(i&&i.hasData()){e[t.key]=t;continue}}else{const t=n.children(this._source.maxzoom);if(e[t[0].key]&&e[t[1].key]&&e[t[2].key]&&e[t[3].key])continue}let r=t.wasRequested();for(let s=n.overscaledZ-1;s>=o;--s){const o=n.scaledTo(s);if(i[o.key])break;if(i[o.key]=!0,t=this.getTile(o),!t&&r&&(t=this._addTile(o)),t&&(e[o.key]=o,r=t.wasRequested(),t.hasData()))break}}return e}_updateLoadedParentTileCache(){this._loadedParentTiles={};for(const t in this._tiles){const e=[];let i,n=this._tiles[t].tileID;for(;n.overscaledZ>0;){if(n.key in this._loadedParentTiles){i=this._loadedParentTiles[n.key];break}e.push(n.key);const t=n.scaledTo(n.overscaledZ-1);if(i=this._getLoadedTile(t),i)break;n=t}for(const t of e)this._loadedParentTiles[t]=i}}_addTile(t){let e=this._tiles[t.key];if(e)return!0!==e.isExtraShadowCaster||!!this._shadowCasterTiles[t.key]||this._reloadTile(t.key,"reloading"),e;e=this._cache.getAndRemove(t),e&&(this._setTileReloadTimer(t.key,e),e.tileID=t,this._state.initializeTileState(e,this.map?this.map.painter:null),this._cacheTimers[t.key]&&(clearTimeout(this._cacheTimers[t.key]),delete this._cacheTimers[t.key],this._setTileReloadTimer(t.key,e)));const i=Boolean(e);if(!i){const i=this.map?this.map.painter:null,n=this._source.tileSize*t.overscaleFactor();e="raster-array"===this._source.type?new Wy(t,n,this.transform.tileZoom,i,this._isRaster):new ey(t,n,this.transform.tileZoom,i,this._isRaster),this._loadTile(e,this._tileLoaded.bind(this,e,t.key,e.state))}return e?(e.uses++,this._tiles[t.key]=e,i||this._source.fire(new Pn("dataloading",{tile:e,coord:e.tileID,dataType:"source"})),e):null}_setTileReloadTimer(t,e){t in this._timers&&(clearTimeout(this._timers[t]),delete this._timers[t]);const i=e.getExpiryTimeout();i&&(this._timers[t]=setTimeout((()=>{this._reloadTile(t,"expired"),delete this._timers[t]}),i))}_removeTile(t){const e=this._tiles[t];e&&(e.uses--,delete this._tiles[t],this._timers[t]&&(clearTimeout(this._timers[t]),delete this._timers[t]),e.uses>0||(e.hasData()&&"reloading"!==e.state||"empty"===e.state?this._cache.add(e.tileID,e,e.getExpiryTimeout()):(e.aborted=!0,this._abortTile(e),this._unloadTile(e))))}clearTiles(){this._shouldReloadOnResume=!1,this._paused=!1;for(const t in this._tiles)this._removeTile(+t);this._source._clear&&this._source._clear(),this._cache.reset(),this.map&&this.usedForTerrain&&this.map.painter.terrain&&this.map.painter.terrain.resetTileLookupCache(this.id)}tilesIn(t,e,i){const n=[],r=this.transform;if(!r)return n;const o="globe"===r.projection.name,s=Ed(r.center.lng);for(const a in this._tiles){const l=this._tiles[a];if(i&&l.clearQueryDebugViz(),l.holdingForFade())continue;let c;if(o){const t=l.tileID.canonical;if(0===t.z){const e=[Math.abs(Xe(s,...Qy(t,-1))-s),Math.abs(Xe(s,...Qy(t,1))-s)];c=[0,2*e.indexOf(Math.min(...e))-1]}else{const e=[Math.abs(Xe(s,...Qy(t,-1))-s),Math.abs(Xe(s,...Qy(t,0))-s),Math.abs(Xe(s,...Qy(t,1))-s)];c=[e.indexOf(Math.min(...e))-1]}}else c=[0];for(const i of c){const o=t.containsTile(l,r,e,i);o&&n.push(o)}}return n}getShadowCasterCoordinates(){return this._getRenderableCoordinates(!1,!0)}getVisibleCoordinates(t){return this._getRenderableCoordinates(t)}_getRenderableCoordinates(t,e){const i=this.getRenderableIds(t,e).map((t=>this._tiles[t].tileID)),n="globe"===this.transform.projection.name;for(const t of i)t.projMatrix=this.transform.calculateProjMatrix(t.toUnwrapped()),t.expandedProjMatrix=n?this.transform.calculateProjMatrix(t.toUnwrapped(),!1,!0):t.projMatrix;return i}sortCoordinatesByDistance(t){const e=t.slice(),i=this.transform._camera.position,n=this.transform._camera.forward(),r={};for(const t of e){const e=1/(1r[t.key]-r[e.key])),e}hasTransition(){if(this._source.hasTransition())return!0;if(Jy(this._source.type))for(const t in this._tiles){const e=this._tiles[t];if(void 0!==e.fadeEndTime&&e.fadeEndTime>=ki.now())return!0}return!1}setFeatureState(t,e,i){this._state.updateState(t=t||"_geojsonTileLayer",e,i)}removeFeatureState(t,e,i){this._state.removeFeatureState(t=t||"_geojsonTileLayer",e,i)}getFeatureState(t,e){return this._state.getState(t=t||"_geojsonTileLayer",e)}setDependencies(t,e,i){const n=this._tiles[t];n&&n.setDependencies(e,i)}reloadTilesForDependencies(t,e){for(const i in this._tiles)this._tiles[i].hasDependency(t,e)&&this._reloadTile(+i,"reloading");this._cache.filter((i=>!i.hasDependency(t,e)))}_preloadTiles(t,e){if(!this._sourceLoaded){const i=()=>{this._sourceLoaded&&(this._source.off("data",i),this._preloadTiles(t,e))};return void this._source.on("data",i)}const i=new Map,n=Array.isArray(t)?t:[t],r=this.map.painter.terrain,o=this.usedForTerrain&&r?r.getScaledDemTileSize():this._source.tileSize;for(const t of n){const e=t.coveringTiles({tileSize:o,minzoom:this._source.minzoom,maxzoom:this._source.maxzoom,roundZoom:this._source.roundZoom&&!this.usedForTerrain,reparseOverscaled:this._source.reparseOverscaled,isTerrainDEM:this.usedForTerrain});for(const t of e)i.set(t.key,t);this.usedForTerrain&&t.updateElevation(!1)}Qe(Array.from(i.values()),((t,e)=>{const i=new ey(t,this._source.tileSize*t.overscaleFactor(),this.transform.tileZoom,this.map.painter,this._isRaster);this._loadTile(i,(t=>{"raster-dem"===this._source.type&&i.dem&&this._backfillDEM(i),e(t,i)}))}),e)}}function Ky(t,e){const i=Math.abs(2*t.wrap)-+(t.wrap0?e+2*t:t}tv.useIntegerZoom=!0;const iv=new ol({"symbol-placement":new il(sl.layout_symbol["symbol-placement"]),"symbol-spacing":new il(sl.layout_symbol["symbol-spacing"]),"symbol-avoid-edges":new il(sl.layout_symbol["symbol-avoid-edges"]),"symbol-sort-key":new nl(sl.layout_symbol["symbol-sort-key"]),"symbol-z-order":new il(sl.layout_symbol["symbol-z-order"]),"symbol-z-elevate":new il(sl.layout_symbol["symbol-z-elevate"]),"icon-allow-overlap":new il(sl.layout_symbol["icon-allow-overlap"]),"icon-ignore-placement":new il(sl.layout_symbol["icon-ignore-placement"]),"icon-optional":new il(sl.layout_symbol["icon-optional"]),"icon-rotation-alignment":new il(sl.layout_symbol["icon-rotation-alignment"]),"icon-size":new nl(sl.layout_symbol["icon-size"]),"icon-text-fit":new nl(sl.layout_symbol["icon-text-fit"]),"icon-text-fit-padding":new nl(sl.layout_symbol["icon-text-fit-padding"]),"icon-image":new nl(sl.layout_symbol["icon-image"]),"icon-rotate":new nl(sl.layout_symbol["icon-rotate"]),"icon-padding":new il(sl.layout_symbol["icon-padding"]),"icon-keep-upright":new il(sl.layout_symbol["icon-keep-upright"]),"icon-offset":new nl(sl.layout_symbol["icon-offset"]),"icon-anchor":new nl(sl.layout_symbol["icon-anchor"]),"icon-pitch-alignment":new il(sl.layout_symbol["icon-pitch-alignment"]),"text-pitch-alignment":new il(sl.layout_symbol["text-pitch-alignment"]),"text-rotation-alignment":new il(sl.layout_symbol["text-rotation-alignment"]),"text-field":new nl(sl.layout_symbol["text-field"]),"text-font":new nl(sl.layout_symbol["text-font"]),"text-size":new nl(sl.layout_symbol["text-size"]),"text-max-width":new nl(sl.layout_symbol["text-max-width"]),"text-line-height":new nl(sl.layout_symbol["text-line-height"]),"text-letter-spacing":new nl(sl.layout_symbol["text-letter-spacing"]),"text-justify":new nl(sl.layout_symbol["text-justify"]),"text-radial-offset":new nl(sl.layout_symbol["text-radial-offset"]),"text-variable-anchor":new il(sl.layout_symbol["text-variable-anchor"]),"text-anchor":new nl(sl.layout_symbol["text-anchor"]),"text-max-angle":new il(sl.layout_symbol["text-max-angle"]),"text-writing-mode":new il(sl.layout_symbol["text-writing-mode"]),"text-rotate":new nl(sl.layout_symbol["text-rotate"]),"text-padding":new il(sl.layout_symbol["text-padding"]),"text-keep-upright":new il(sl.layout_symbol["text-keep-upright"]),"text-transform":new nl(sl.layout_symbol["text-transform"]),"text-offset":new nl(sl.layout_symbol["text-offset"]),"text-allow-overlap":new il(sl.layout_symbol["text-allow-overlap"]),"text-ignore-placement":new il(sl.layout_symbol["text-ignore-placement"]),"text-optional":new il(sl.layout_symbol["text-optional"]),visibility:new il(sl.layout_symbol.visibility)});var nv={paint:new ol({"icon-opacity":new nl(sl.paint_symbol["icon-opacity"]),"icon-occlusion-opacity":new nl(sl.paint_symbol["icon-occlusion-opacity"]),"icon-emissive-strength":new nl(sl.paint_symbol["icon-emissive-strength"]),"text-emissive-strength":new nl(sl.paint_symbol["text-emissive-strength"]),"icon-color":new nl(sl.paint_symbol["icon-color"]),"icon-halo-color":new nl(sl.paint_symbol["icon-halo-color"]),"icon-halo-width":new nl(sl.paint_symbol["icon-halo-width"]),"icon-halo-blur":new nl(sl.paint_symbol["icon-halo-blur"]),"icon-translate":new il(sl.paint_symbol["icon-translate"]),"icon-translate-anchor":new il(sl.paint_symbol["icon-translate-anchor"]),"icon-image-cross-fade":new nl(sl.paint_symbol["icon-image-cross-fade"]),"text-opacity":new nl(sl.paint_symbol["text-opacity"]),"text-occlusion-opacity":new nl(sl.paint_symbol["text-occlusion-opacity"]),"text-color":new nl(sl.paint_symbol["text-color"],{runtimeType:Qn,getOverride:t=>t.textColor,hasOverride:t=>!!t.textColor}),"text-halo-color":new nl(sl.paint_symbol["text-halo-color"]),"text-halo-width":new nl(sl.paint_symbol["text-halo-width"]),"text-halo-blur":new nl(sl.paint_symbol["text-halo-blur"]),"text-translate":new il(sl.paint_symbol["text-translate"]),"text-translate-anchor":new il(sl.paint_symbol["text-translate-anchor"]),"icon-color-saturation":new il(sl.paint_symbol["icon-color-saturation"]),"icon-color-contrast":new il(sl.paint_symbol["icon-color-contrast"]),"icon-color-brightness-min":new il(sl.paint_symbol["icon-color-brightness-min"]),"icon-color-brightness-max":new il(sl.paint_symbol["icon-color-brightness-max"])}),layout:iv};class rv{constructor(t){this.type=t.property.overrides?t.property.overrides.runtimeType:Yn,this.defaultValue=t}evaluate(t){if(t.formattedSection){const e=this.defaultValue.property.overrides;if(e&&e.hasOverride(t.formattedSection))return e.getOverride(t.formattedSection)}return t.feature&&t.featureState?this.defaultValue.evaluate(t.feature,t.featureState):this.defaultValue.property.specification.default}eachChild(t){this.defaultValue.isConstant()||t(this.defaultValue.value._styleExpression.expression)}outputDefined(){return!1}serialize(){return null}}ba(rv,"FormatSectionOverride",{omit:["defaultValue"]});class ov extends Ml{constructor(e,i,n,r){super(e,nv,i,n,r),this._colorAdjustmentMatrix=t.ad.identity([]),this.hasInitialOcclusionOpacityProperties=void 0!==e.paint&&("icon-occlusion-opacity"in e.paint||"text-occlusion-opacity"in e.paint)}recalculate(t,e){super.recalculate(t,e),"auto"===this.layout.get("icon-rotation-alignment")&&(this.layout._values["icon-rotation-alignment"]="point"!==this.layout.get("symbol-placement")?"map":"viewport"),"auto"===this.layout.get("text-rotation-alignment")&&(this.layout._values["text-rotation-alignment"]="point"!==this.layout.get("symbol-placement")?"map":"viewport"),"auto"===this.layout.get("text-pitch-alignment")&&(this.layout._values["text-pitch-alignment"]=this.layout.get("text-rotation-alignment")),"auto"===this.layout.get("icon-pitch-alignment")&&(this.layout._values["icon-pitch-alignment"]=this.layout.get("icon-rotation-alignment"));const i=this.layout.get("text-writing-mode");if(i){const t=[];for(const e of i)t.indexOf(e)i in t?String(t[i]):""))}(e.properties,r)}createBucket(t){return new jg(t)}queryRadius(){return 0}queryIntersectsFeature(){return!1}_setPaintOverrides(){for(const t of nv.paint.overridableProperties){if(!ov.hasPaintOverride(this.layout,t))continue;const e=this.paint.get(t),i=new rv(e),n=new la(i,e.property.specification,this.scope,this.options);let r=null;r="constant"===e.value.kind||"source"===e.value.kind?new ua("source",n):new ha("composite",n,e.value.zoomStops,e.value._interpolationType),this.paint._values[t]=new tl(e.property,r,e.parameters)}}_handleOverridablePaintPropertyUpdate(t,e,i){return!(!this.layout||e.isDataDriven()||i.isDataDriven())&&ov.hasPaintOverride(this.layout,t)}static hasPaintOverride(t,e){const i=t.get("text-field"),n=nv.paint.properties[e];let r=!1;const o=t=>{for(const e of t)if(n.overrides&&n.overrides.hasOverride(e))return void(r=!0)};if("constant"===i.value.kind&&i.value.value instanceof pr)o(i.value.value.sections);else if("source"===i.value.kind){const t=e=>{r||(e instanceof vr&&gr(e.value)===nr?o(e.value.sections):e instanceof Tr?o(e.sections):e.eachChild(t))},e=i.value;e._styleExpression&&t(e._styleExpression.expression)}return r}getProgramIds(){const t=0!==this.paint.get("icon-opacity").constantOr(1),e=0!==this.paint.get("text-opacity").constantOr(1),i=[];return t&&i.push("symbolIcon"),e&&i.push("symbolSDF"),i}getDefaultProgramParams(t,e,i){return{config:new Wc(this,{zoom:e,lut:i}),overrideFog:!1}}}const sv=new ol({visibility:new il(sl.layout_background.visibility)});var av={paint:new ol({"background-color":new il(sl.paint_background["background-color"]),"background-pattern":new il(sl.paint_background["background-pattern"]),"background-opacity":new il(sl.paint_background["background-opacity"]),"background-emissive-strength":new il(sl.paint_background["background-emissive-strength"])}),layout:sv};const lv=new ol({visibility:new il(sl.layout_raster.visibility)});var cv={paint:new ol({"raster-opacity":new il(sl.paint_raster["raster-opacity"]),"raster-color":new rl(sl.paint_raster["raster-color"]),"raster-color-mix":new il(sl.paint_raster["raster-color-mix"]),"raster-color-range":new il(sl.paint_raster["raster-color-range"]),"raster-hue-rotate":new il(sl.paint_raster["raster-hue-rotate"]),"raster-brightness-min":new il(sl.paint_raster["raster-brightness-min"]),"raster-brightness-max":new il(sl.paint_raster["raster-brightness-max"]),"raster-saturation":new il(sl.paint_raster["raster-saturation"]),"raster-contrast":new il(sl.paint_raster["raster-contrast"]),"raster-resampling":new il(sl.paint_raster["raster-resampling"]),"raster-fade-duration":new il(sl.paint_raster["raster-fade-duration"]),"raster-emissive-strength":new il(sl.paint_raster["raster-emissive-strength"]),"raster-array-band":new il(sl.paint_raster["raster-array-band"]),"raster-elevation":new il(sl.paint_raster["raster-elevation"])}),layout:lv};function dv(e,i,n,r,o,s,a,l){const c=[e,i,1,n,r,1,o,s,1],d=[a,l,1],u=t.bC.adjoint([],c),[h,p,f]=t._.transformMat3(d,d,u);return t.bC.multiply(c,c,[h,0,0,0,p,0,0,0,f])}function uv(e,i,n,r,o,s,a,l){const c=function(e,i,n,r,o,s,a,l){const c=dv(0,0,1,0,1,1,0,1),d=dv(e,i,n,r,o,s,a,l),u=t.bC.adjoint([],c);return t.bC.multiply(d,d,u)}(e,i,n,r,o,s,a,l);return[c[2]/c[8]/uo,c[5]/c[8]/uo]}function hv(t){return[t[0],Math.min(Math.max(t[1],-Pd),Pd)]}class pv extends zn{constructor(t,e,i,n){super(),this.id=t,this.dispatcher=i,this.coordinates=e.coordinates,this.type="image",this.minzoom=0,this.maxzoom=22,this.tileSize=512,this.tiles={},this._loaded=!1,this.onNorthPole=!1,this.onSouthPole=!1,this.setEventedParent(n),this.options=e,this._dirty=!1}load(t,e){if(this._loaded=e||!1,this.fire(new Pn("dataloading",{dataType:"source"})),this.url=this.options.url,!this.url)return t&&(this.coordinates=t),this._loaded=!0,void this._finishLoading();this._imageRequest=an(this.map._requestManager.transformRequest(this.url,Ki.Image),((e,i)=>{this._imageRequest=null,this._loaded=!0,e?this.fire(new $n(e)):i&&(this.image=i instanceof HTMLImageElement?ki.getImageData(i):i,this._dirty=!0,this.width=this.image.width,this.height=this.image.height,t&&(this.coordinates=t),this._finishLoading())}))}loaded(){return this._loaded}updateImage(t){return t.url?(this._imageRequest&&t.url!==this.options.url&&(this._imageRequest.cancel(),this._imageRequest=null),this.options.url=t.url,this.load(t.coordinates,this._loaded),this):this}setTexture(t){if(!(t.handle instanceof WebGLTexture))throw new Error("The provided handle is not a WebGLTexture instance");return this.texture=new Gg(this.map.painter.context,t.handle),this.width=t.dimensions[0],this.height=t.dimensions[1],this._dirty=!1,this._loaded=!0,this._finishLoading(),this}_finishLoading(){this.map&&(this.setCoordinates(this.coordinates),this.fire(new Pn("data",{dataType:"source",sourceDataType:"metadata"})))}onAdd(t){this.map=t,this.load()}onRemove(t){this._imageRequest&&(this._imageRequest.cancel(),this._imageRequest=null),!this.texture||this.texture instanceof Gg||this.texture.destroy(),this.boundsBuffer&&(this.boundsBuffer.destroy(),this.elevatedGlobeVertexBuffer&&this.elevatedGlobeVertexBuffer.destroy(),this.elevatedGlobeIndexBuffer&&this.elevatedGlobeIndexBuffer.destroy())}setCoordinates(t){if(this.coordinates=t,this._boundsArray=void 0,this._unsupportedCoords=!1,!t.length)return this;this.onNorthPole=!1,this.onSouthPole=!1;let e=t[0][1],i=t[0][1];for(const n of t)n[1]>i&&(i=n[1]),n[1]Pd?this.onNorthPole=!0:n1&&(l-=1),new gd(s,l,Math.floor((i+r)/2*a))}(e),this.minzoom=this.maxzoom=this.tileID.z}return this.fire(new Pn("data",{dataType:"source",sourceDataType:"content"})),this}_clear(){this._boundsArray=void 0,this._unsupportedCoords=!1}_prepareData(e){for(const t in this.tiles){const e=this.tiles[t];"loaded"!==e.state&&(e.state="loaded",e.texture=this.texture)}if(this._boundsArray||this.onNorthPole||this.onSouthPole||this._unsupportedCoords)return;const i=eg(new gd(0,0,0),this.map.transform.projection),n=[i.projection.project(this.coordinates[0][0],this.coordinates[0][1]),i.projection.project(this.coordinates[1][0],this.coordinates[1][1]),i.projection.project(this.coordinates[2][0],this.coordinates[2][1]),i.projection.project(this.coordinates[3][0],this.coordinates[3][1])];if(!function(t){const e=t[1].x-t[0].x,i=t[1].y-t[0].y,n=t[2].x-t[1].x,r=t[2].y-t[1].y,o=t[3].x-t[2].x,s=t[3].y-t[2].y,a=t[0].x-t[3].x,l=t[0].y-t[3].y,c=e*r-n*i,d=n*s-o*r,u=o*l-a*s,h=a*i-e*l;return c>0&&d>0&&u>0&&h>0||c{const e=r.projection.project(t[0],t[1]);return ig(r,e)._round()}));this.perspectiveTransform=uv(o.x,o.y,s.x,s.y,a.x,a.y,l.x,l.y);const c=this._boundsArray=new Dl;c.emplaceBack(o.x,o.y,0,0),c.emplaceBack(s.x,s.y,uo,0),c.emplaceBack(l.x,l.y,0,uo),c.emplaceBack(a.x,a.y,uo,uo),this.boundsBuffer&&(this.boundsBuffer.destroy(),this.elevatedGlobeVertexBuffer&&this.elevatedGlobeVertexBuffer.destroy(),this.elevatedGlobeIndexBuffer&&this.elevatedGlobeIndexBuffer.destroy()),this.boundsBuffer=e.createVertexBuffer(c,Jg.members),this.boundsSegments=wc.simpleSegment(0,0,4,2);const d=[],u=function(t){return[hv(t[0]),hv(t[1]),hv(t[2]),hv(t[3])]}(this.coordinates),[h,p,f,m]=function(t){let e=t[0][0],i=e,n=t[0][1],r=n;for(let o=1;oi&&(i=t[o][0]),t[o][1]r&&(r=t[o][1]);return[e,n,i-e,r-n]}(u);{const r=new Dl,[o,s,a,l]=function(t){let e=t[0].x,i=e,n=t[0].y,r=n;for(let o=1;oi&&(i=t[o].x),t[o].yr&&(r=t[o].y);return[e,n,i-e,r-n]}(n),c=t=>[(t.x-o)/a,(t.y-s)/l],[u,_,g,y]=n.map(c),v=function(e,i,n,r,o,s,a,l){const c=dv(0,0,1,0,1,1,0,1),d=dv(e,i,n,r,o,s,a,l),u=t.bC.adjoint([],d);return t.bC.multiply(c,c,u)}(u[0],u[1],_[0],_[1],g[0],g[1],y[0],y[1]);this.elevatedGlobePerspectiveTransform=uv(u[0],u[1],_[0],_[1],g[0],g[1],y[0],y[1]);const x=(e,i)=>{d.push(e.lng);const n=Math.round((e.lng-h)/f*uo),o=Math.round((e.lat-p)/m*uo),s=c(i),a=t._.transformMat3([],[s[0],s[1],1],v),l=Math.round(a[0]/a[2]*uo),u=Math.round(a[1]/a[2]*uo);r.emplaceBack(n,o,l,u)},b=n[3].x-n[0].x,w=n[3].y-n[0].y,T=n[2].x-n[1].x,S=n[2].y-n[1].y;for(let t=0;t{i.emplaceBack(e,n,r);const o=d[e],s=d[n],a=d[r],l=Math.min(Math.min(o,s),a),c=Math.max(Math.max(o,s),a)-l;c>this.maxLongitudeTriangleSize&&(this.maxLongitudeTriangleSize=c),t.push(l+c/2)};for(let t=0;te));i.sort(((e,i)=>t[e]-t[i]));const n=[],r=new Kl;for(let o=0;o{o.segments.push({vertexOffset:0,primitiveOffset:t,vertexLength:e.segments[0].vertexLength,primitiveLength:i,sortKey:void 0,vaos:{}})},a=.51*this.maxLongitudeTriangleSize;if(Math.abs(i[0]-n)0){const n=function(e,i){const n=i.worldSize,r=Cd(1,0)*n*kd(i.center.lat,i.zoom)/Gu(n),o=Cd(1,i.center.lat)*n,s=t.ad.identity([]);return t.ad.rotateY(s,s,Ge(i.center.lng)),t.ad.rotateX(s,s,Ge(i.center.lat)),t.ad.translate(s,s,[0,0,ed]),t.ad.scale(s,s,[r,r,r*o]),t.ad.translate(s,s,[i.point.x-.5*n,i.point.y-.5*n,0]),t.ad.multiply(s,s,e),t.ad.multiply(s,i.globeMatrix,s)}(e,i);return function(e,i,n){const r=(e,i,n)=>{const r=t._.length(e),o=t._.length(i),s=ku(e,i,n);return t._.scale(s,s,1/t._.length(s)*Vn(r,o,n))},o=r([e[0],e[1],e[2]],[i[0],i[1],i[2]],n),s=r([e[4],e[5],e[6]],[i[4],i[5],i[6]],n),a=r([e[8],e[9],e[10]],[i[8],i[9],i[10]],n),l=ku([e[12],e[13],e[14]],[i[12],i[13],i[14]],n);return[o[0],o[1],o[2],0,s[0],s[1],s[2],0,a[0],a[1],a[2],0,l[0],l[1],l[2],1]}(o,n,r)}return o}function kv(t,e,i,n){const r=wu.projectAabbCorners(n,i);let o=Number.MAX_VALUE,s=-1;for(let t=0;tnew Ue(r[t][0],r[t][1]);let l;switch(s){case 0:case 6:l=[a(1),a(5),a(4),a(7),a(3),a(2),a(1)];break;case 1:case 7:l=[a(0),a(4),a(5),a(6),a(2),a(3),a(0)];break;case 3:case 5:l=[a(1),a(0),a(4),a(7),a(6),a(2),a(1)];break;default:l=[a(1),a(5),a(6),a(7),a(3),a(0),a(1)]}if(Yd(t,l))return o}const Dv=Ll([{name:"a_pos_3f",components:3,type:"Float32"}]),zv=Ll([{name:"a_color_3f",components:3,type:"Float32"}]),Rv=Ll([{name:"a_color_4f",components:4,type:"Float32"}]),Ov=Ll([{name:"a_uv_2f",components:2,type:"Float32"}]),Bv=Ll([{name:"a_normal_3f",components:3,type:"Float32"}]),Fv=Ll([{name:"a_normal_matrix0",components:4,type:"Float32"},{name:"a_normal_matrix1",components:4,type:"Float32"},{name:"a_normal_matrix2",components:4,type:"Float32"},{name:"a_normal_matrix3",components:4,type:"Float32"}]),Nv=Ll([{name:"a_pbr",components:4,type:"Uint16"},{name:"a_heightBasedEmissiveStrength",components:3,type:"Float32"}]);class Uv{constructor(t,e,i,n){this.message=(t?`${t}: `:"")+i,n&&(this.identifier=n),null!=e&&e.__line__&&(this.line=e.__line__)}}function jv(t,e){const i=-1===t.indexOf("://");try{return new URL(t,i&&e?"http://example.com":void 0),!0}catch(t){return!1}}class Vv{constructor(t,e){this.feature=t,this.instancedDataOffset=e,this.instancedDataCount=0,this.rotation=[0,0,0],this.scale=[1,1,1],this.translation=[0,0,0]}}class Gv{constructor(){this.instancedDataArray=new oc,this.instancesEvaluatedElevation=[],this.features=[],this.idToFeaturesIndex={}}}class Zv{constructor(t){this.zoom=t.zoom,this.canonical=t.canonical,this.layers=t.layers,this.layerIds=this.layers.map((t=>t.fqid)),this.projection=t.projection,this.index=t.index,this.hasZoomDependentProperties=this.layers[0].isZoomDependent(),this.stateDependentLayerIds=this.layers.filter((t=>t.isStateDependent())).map((t=>t.id)),this.hasPattern=!1,this.instancesPerModel={},this.validForExaggeration=0,this.maxVerticalOffset=0,this.maxScale=0,this.maxHeight=0,this.lookupDim=this.zoom>this.canonical.z?256:this.zoom>15?75:100,this.instanceCount=0,this.terrainElevationMin=0,this.terrainElevationMax=0,this.validForDEMTile={id:null,timestamp:0},this.modelUris=[],this.modelsRequested=!1,this.activeReplacements=[],this.replacementUpdateTime=0}updateFootprints(t,e){}populate(t,e,i,n){this.tileToMeter=zd(i);const r=this.layers[0]._featureFilter.needGeometry;this.lookup=new Uint8Array(this.lookupDim*this.lookupDim);for(const{feature:o,id:s,index:a,sourceLayerIndex:l}of t){const t=null!=s?s:o.properties&&o.properties.hasOwnProperty("id")?o.properties.id:void 0,c=Zd(o,r);if(!this.layers[0]._featureFilter.filter(new Ha(this.zoom),c,i))continue;const d={id:t,sourceLayerIndex:l,index:a,geometry:r?c.geometry:Gd(o,i,n),properties:o.properties,type:o.type,patterns:{}},u=this.addFeature(d,d.geometry,c);u&&e.featureIndex.insert(o,d.geometry,a,l,this.index,this.instancesPerModel[u].instancedDataArray.length,uo/32)}this.lookup=null}update(t,e,i,n){for(const e in this.instancesPerModel){const i=this.instancesPerModel[e];for(const e in t)i.idToFeaturesIndex.hasOwnProperty(e)&&(this.evaluate(i.features[i.idToFeaturesIndex[e]],t[e],i,!0),this.uploaded=!1)}this.maxHeight=0}updateZoomBasedPaintProperties(){if(!this.hasZoomDependentProperties)return!1;let e=!1;for(const i in this.instancesPerModel){const n=this.instancesPerModel[i];for(const i of n.features){const r=this.layers[0],o=i.feature,s=this.canonical,a=r.paint.get("model-rotation").evaluate(o,{},s),l=r.paint.get("model-scale").evaluate(o,{},s),c=r.paint.get("model-translation").evaluate(o,{},s);t._.exactEquals(i.rotation,a)&&t._.exactEquals(i.scale,l)&&t._.exactEquals(i.translation,c)||(this.evaluate(i,i.featureStates,n,!0),e=!0)}}return e}updateReplacement(t,e,i){if(e.updateTime===this.replacementUpdateTime)return!1;this.replacementUpdateTime=e.updateTime;const n=e.getReplacementRegionsForTile(t.toUnwrapped(),!0);if(Pp(this.activeReplacements,n))return!1;this.activeReplacements=n;let r=!1;for(const e in this.instancesPerModel){const n=this.instancesPerModel[e],o=n.instancedDataArray;for(const e of n.features){const n=e.instancedDataOffset,s=e.instancedDataCount;for(let e=0;euo?a-uo:a;const l=Math.floor(a),c=o.float32[s+1];let d=!1;for(const e of this.activeReplacements)if(!(e.orderl||l>e.max.x||e.min.y>c||c>e.max.y)&&(d=Op(Rp(l,c,t.canonical,e.footprintTileId.canonical),e),d))break;o.float32[s]=d?a+uo:a,r=r||d}}}return r}isEmpty(){for(const t in this.instancesPerModel)if(0!==this.instancesPerModel[t].instancedDataArray.length)return!1;return!0}uploadPending(){return!this.uploaded}upload(t){if(!this.uploaded)for(const e in this.instancesPerModel){const i=this.instancesPerModel[e];i.instancedDataArray.length=uo||e.y=uo)continue;const t=(this.lookupDim-1)/uo,i=this.lookupDim*(e.y*t|0)+e.x*t|0;if(this.lookup){if(0!==this.lookup[i])continue;this.lookup[i]=1}this.instanceCount++;const n=s.length;s.resize(n+1),o.instancesEvaluatedElevation.push(0),s.float32[16*n]=e.x,s.float32[16*n+1]=e.y}return a.instancedDataCount=o.instancedDataArray.length-a.instancedDataOffset,a.instancedDataCount>0&&(t.id&&(o.idToFeaturesIndex[t.id]=o.features.length),o.features.push(a),this.evaluate(a,{},o,!1)),r}getModelUris(){return this.modelUris}evaluate(t,e,i,n){const r=this.layers[0],o=t.feature,s=this.canonical,a=t.rotation=r.paint.get("model-rotation").evaluate(o,e,s),l=t.scale=r.paint.get("model-scale").evaluate(o,e,s),c=t.translation=r.paint.get("model-translation").evaluate(o,e,s),d=r.paint.get("model-color").evaluate(o,e,s);d.a=r.paint.get("model-color-mix-intensity").evaluate(o,e,s);const u=[];this.maxVerticalOffset10?this.tileToMeter:zd(s,p)),a[o+4]=c[0],a[o+5]=c[1],a[o+6]=c[2]+l,a[o+7]=u[0],a[o+8]=u[1],a[o+9]=u[2],a[o+10]=u[4],a[o+11]=u[5],a[o+12]=u[6],a[o+13]=u[8],a[o+14]=u[9],a[o+15]=u[10],i.instancesEvaluatedElevation[r]=c[2]}}}ba(Zv,"ModelBucket",{omit:["layers"]}),ba(Gv,"PerModelAttributes"),ba(Vv,"ModelFeature");const qv=new ol({visibility:new il(sl.layout_model.visibility),"model-id":new nl(sl.layout_model["model-id"])});var Hv={paint:new ol({"model-opacity":new il(sl.paint_model["model-opacity"]),"model-rotation":new nl(sl.paint_model["model-rotation"]),"model-scale":new nl(sl.paint_model["model-scale"]),"model-translation":new nl(sl.paint_model["model-translation"]),"model-color":new nl(sl.paint_model["model-color"]),"model-color-mix-intensity":new nl(sl.paint_model["model-color-mix-intensity"]),"model-type":new il(sl.paint_model["model-type"]),"model-cast-shadows":new il(sl.paint_model["model-cast-shadows"]),"model-receive-shadows":new il(sl.paint_model["model-receive-shadows"]),"model-ambient-occlusion-intensity":new il(sl.paint_model["model-ambient-occlusion-intensity"]),"model-emissive-strength":new nl(sl.paint_model["model-emissive-strength"]),"model-roughness":new nl(sl.paint_model["model-roughness"]),"model-height-based-emissive-strength-multiplier":new nl(sl.paint_model["model-height-based-emissive-strength-multiplier"]),"model-cutoff-fade-range":new il(sl.paint_model["model-cutoff-fade-range"]),"model-front-cutoff":new il(sl.paint_model["model-front-cutoff"])}),layout:qv};const Wv=64,Yv={CoordinateSpaceTile:1,CoordinateSpaceYUp:2,HasMapboxMeshFeatures:4,HasMeshoptCompression:8};function Xv(e,i,n,r,o,s,a,l,c,d=!1){const u=n.zoom,h=n.project(r),p=kd(r.lat,u),f=1/p;t.ad.identity(e),t.ad.translate(e,e,[h.x+a[0]*f,h.y+a[1]*f,a[2]]);let m=1,_=1;const g=n.worldSize;if(d){if("mercator"===n.projection.name){let e=0;n.elevation&&(e=n.elevation.getAtPointOrZero(new Rd(h.x/g,h.y/g),0));const i=t.aA.transformMat4([],[h.x,h.y,e,1],n.projMatrix)[3]/n.cameraToCenterDistance;m=i,_=i*kd(n.center.lat,u)}else if("globe"===n.projection.name){const i=$v(e,n),o=t.ad.multiply([],n.projMatrix,i),s=[0,0,0,1];t.aA.transformMat4(s,s,o);const a=s[3]/n.cameraToCenterDistance,l=Hu(u),c=n.projection.pixelsPerMeter(r.lat,g)*kd(r.lat,u),d=n.projection.pixelsPerMeter(n.center.lat,g)*kd(n.center.lat,u);m=a/Vn(c,$d(n.center.lat),l),_=a*p/c,m*=d,_*=d}}else m=f;t.ad.scale(e,e,[m,m,_]);const y=[...e],v=i.orientation,x=[];if(Lv(x,[v[0]+o[0],v[1]+o[1],v[2]+o[2]],s),t.ad.multiply(e,y,x),l&&n.elevation){let o=0;const s=[];if(c&&n.elevation){o=function(e,i,n,r,o){const s=i.elevation;if(!s)return 0;const a=wu.projectAabbCorners(n,r),l=Cd(1,o.lat)*i.worldSize,c=function(e,i){const n=[0,0,1],r=[{corners:[0,1,3,2],dotProductWithUp:0},{corners:[1,5,2,6],dotProductWithUp:0},{corners:[0,4,1,5],dotProductWithUp:0},{corners:[2,6,3,7],dotProductWithUp:0},{corners:[4,7,5,6],dotProductWithUp:0},{corners:[0,3,4,7],dotProductWithUp:0}];for(const o of r){const r=e[o.corners[0]],s=e[o.corners[1]],a=e[o.corners[2]],l=[s[0]-r[0],s[1]-r[1],i*(s[2]-r[2])],c=t._.cross(l,l,[a[0]-r[0],a[1]-r[1],i*(a[2]-r[2])]);t._.normalize(c,c),o.dotProductWithUp=t._.dot(c,n)}return r.sort(((t,e)=>t.dotProductWithUp-e.dotProductWithUp)),r[0].corners}(a,l),d=a[c[0]],u=a[c[1]],h=a[c[2]],p=a[c[3]],f=s.getAtPointOrZero(new Rd(d[0]/i.worldSize,d[1]/i.worldSize),0),m=s.getAtPointOrZero(new Rd(u[0]/i.worldSize,u[1]/i.worldSize),0),_=s.getAtPointOrZero(new Rd(h[0]/i.worldSize,h[1]/i.worldSize),0),g=s.getAtPointOrZero(new Rd(p[0]/i.worldSize,p[1]/i.worldSize),0),y=(f+g)/2,v=(m+_)/2;return y>v?m=e.gl.NEAREST_MIPMAP_NEAREST}),t.uploaded=!0,t.image=null)}function Jv(t,e,i){t.indexBuffer=e.createIndexBuffer(t.indexArray,!1,!0),t.vertexBuffer=e.createVertexBuffer(t.vertexArray,Dv.members,!1,!0),t.normalArray&&(t.normalBuffer=e.createVertexBuffer(t.normalArray,Bv.members,!1,!0)),t.texcoordArray&&(t.texcoordBuffer=e.createVertexBuffer(t.texcoordArray,Ov.members,!1,!0)),t.colorArray&&(t.colorBuffer=e.createVertexBuffer(t.colorArray,(12===t.colorArray.bytesPerElement?zv:Rv).members,!1,!0)),t.featureArray&&(t.pbrBuffer=e.createVertexBuffer(t.featureArray,Nv.members,!0)),t.segments=wc.simpleSegment(0,0,t.vertexArray.length,t.indexArray.length);const n=t.material;n.pbrMetallicRoughness.baseColorTexture&&Kv(n.pbrMetallicRoughness.baseColorTexture,e),n.pbrMetallicRoughness.metallicRoughnessTexture&&Kv(n.pbrMetallicRoughness.metallicRoughnessTexture,e),n.normalTexture&&Kv(n.normalTexture,e),n.occlusionTexture&&Kv(n.occlusionTexture,e,i),n.emissionTexture&&Kv(n.emissionTexture,e)}function Qv(t,e,i){if(t.meshes)for(const n of t.meshes)Jv(n,e,i);if(t.children)for(const n of t.children)Qv(n,e,i)}function tx(t){if(t.meshes)for(const e of t.meshes)e.indexArray.destroy(),e.vertexArray.destroy(),e.colorArray&&e.colorArray.destroy(),e.normalArray&&e.normalArray.destroy(),e.texcoordArray&&e.texcoordArray.destroy(),e.featureArray&&e.featureArray.destroy();if(t.children)for(const e of t.children)tx(e)}function ex(t){if(t.meshes)for(const i of t.meshes)i.vertexBuffer&&(i.vertexBuffer.destroy(),i.indexBuffer.destroy(),i.normalBuffer&&i.normalBuffer.destroy(),i.texcoordBuffer&&i.texcoordBuffer.destroy(),i.colorBuffer&&i.colorBuffer.destroy(),i.pbrBuffer&&i.pbrBuffer.destroy(),i.segments.destroy(),i.material&&((e=i.material).pbrMetallicRoughness.baseColorTexture&&e.pbrMetallicRoughness.baseColorTexture.gfxTexture&&e.pbrMetallicRoughness.baseColorTexture.gfxTexture.destroy(),e.pbrMetallicRoughness.metallicRoughnessTexture&&e.pbrMetallicRoughness.metallicRoughnessTexture.gfxTexture&&e.pbrMetallicRoughness.metallicRoughnessTexture.gfxTexture.destroy(),e.normalTexture&&e.normalTexture.gfxTexture&&e.normalTexture.gfxTexture.destroy(),e.emissionTexture&&e.emissionTexture.gfxTexture&&e.emissionTexture.gfxTexture.destroy(),e.occlusionTexture&&e.occlusionTexture.gfxTexture&&e.occlusionTexture.gfxTexture.destroy()));var e;if(t.children)for(const e of t.children)ex(e)}class ix{constructor(t){this._callback=t,this._triggered=!1,"undefined"!=typeof MessageChannel&&(this._channel=new MessageChannel,this._channel.port2.onmessage=()=>{this._triggered=!1,this._callback()})}trigger(){this._triggered||(this._triggered=!0,this._channel?this._channel.port1.postMessage(!0):setTimeout((()=>{this._triggered=!1,this._callback()}),0))}remove(){this._channel=void 0,this._callback=()=>{}}}class nx{constructor(){this.tasks={},this.taskQueue=[],ai(["process"],this),this.invoker=new ix(this.process),this.nextId=0}add(t,e){const i=this.nextId++,n=function({type:t,isSymbolTile:e,zoom:i}){return i=i||0,"message"===t?0:"maybePrepare"!==t||e?"parseTile"!==t||e?"parseTile"===t&&e?300-i:"maybePrepare"===t&&e?400-i:500:200-i:100-i}(e);if(0===n){try{t()}finally{}return null}return this.tasks[i]={fn:t,metadata:e,priority:n,id:i},this.taskQueue.push(i),this.invoker.trigger(),{cancel:()=>{delete this.tasks[i]}}}process(){try{if(this.taskQueue=this.taskQueue.filter((t=>!!this.tasks[t])),!this.taskQueue.length)return;const t=this.pick();if(null===t)return;const e=this.tasks[t];if(delete this.tasks[t],this.taskQueue.length&&this.invoker.trigger(),!e)return;e.fn()}finally{}}pick(){let t=null,e=1/0;for(let i=0;i{i&&delete this.callbacks[s],this.target.postMessage({id:s,type:"",targetMapId:n,sourceMapId:this.mapId})}}}receive(t){const e=t.data,i=e.id;if(i&&(!e.targetMapId||this.mapId===e.targetMapId))if(""===e.type){const t=this.cancelCallbacks[i];delete this.cancelCallbacks[i],t&&t.cancel()}else if(e.mustQueue||gi()){const t=this.callbacks[i],n=this.scheduler.add((()=>this.processTask(i,e)),t&&t.metadata||{type:"message"});n&&(this.cancelCallbacks[i]=n)}else this.processTask(i,e)}processTask(t,e){if(delete this.cancelCallbacks[t],""===e.type){const i=this.callbacks[t];delete this.callbacks[t],i&&(e.error?i(Ea(e.error)):i(null,Ea(e.data)))}else{const i=new Set,n=e.hasCallback?(e,n)=>{this.target.postMessage({id:t,type:"",sourceMapId:this.mapId,error:e?Sa(e):null,data:Sa(n,i)},i)}:t=>{},r=Ea(e.data);if(this.parent[e.type])this.parent[e.type](e.sourceMapId,r,n);else if(this.parent.getWorkerSource){const t=e.type.split(".");this.parent.getWorkerSource(e.sourceMapId,t[0],r.source,r.scope)[t[1]](r,n)}else n(new Error(`Could not find function ${e.type}`))}}remove(){this.scheduler.remove(),this.target.removeEventListener("message",this.receive,!1)}}class ox{constructor(t,e){this.workerPool=t,this.actors=[],this.currentActor=0,this.id=ni();const i=this.workerPool.acquire(this.id);for(let t=0;t{this.ready=!0}))}broadcast(t,e,i){Qe(this.actors,((i,n)=>{i.send(t,e,n)}),i=i||function(){})}getActor(){return this.currentActor=(this.currentActor+1)%this.actors.length,this.actors[this.currentActor]}remove(){this.actors.forEach((t=>{t.remove()})),this.actors=[],this.workerPool.release(this.id)}}ox.Actor=rx;var sx={workerUrl:"",workerClass:null,workerParams:void 0};function ax(){return null!=sx.workerClass?new sx.workerClass:new self.Worker(sx.workerUrl,sx.workerParams)}const lx="mapboxgl_preloaded_worker_pool";class cx{constructor(){this.active={}}acquire(t){if(!this.workers)for(this.workers=[];this.workers.length{t.terminate()})),this.workers=null)}isPreloaded(){return!!this.active[lx]}numActive(){return Object.keys(this.active).length}}let dx;function ux(){return dx||(dx=new cx),dx}cx.workerCount=2;let hx,px,fx,mx,_x,gx=null;function yx(){return gi()&&self.worker&&self.worker.dracoUrl?self.worker.dracoUrl:px||n.DRACO_URL}function vx(){if(gi()&&self.worker&&self.worker.meshoptUrl)return self.worker.meshoptUrl;if(mx)return mx;const t=new Uint8Array([0,97,115,109,1,0,0,0,1,4,1,96,0,0,3,3,2,0,0,5,3,1,0,1,12,1,0,10,22,2,12,0,65,0,65,0,65,0,252,10,0,0,11,7,0,65,0,253,15,26,11]);if("object"!=typeof WebAssembly)throw new Error("WebAssembly not supported, cannot instantiate meshoptimizer");return mx=WebAssembly.validate(t)?n.MESHOPT_SIMD_URL:n.MESHOPT_URL,mx}const xx={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},bx={5120:"DT_INT8",5121:"DT_UINT8",5122:"DT_INT16",5123:"DT_UINT16",5125:"DT_UINT32",5126:"DT_FLOAT32"},wx={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16};function Tx(t,e,i){const n=i.json.bufferViews.length,r=i.buffers.length;e.bufferView=n,i.json.bufferViews[n]={buffer:r,byteLength:t.byteLength},i.buffers[r]=t}const Sx="KHR_draco_mesh_compression";function Ex(t,e){const i=t.extensions&&t.extensions[Sx];if(!i)return;const n=new fx.Decoder,r=$x(e,i.bufferView),o=new fx.Mesh;if(!n.DecodeArrayToMesh(r,r.byteLength,o))throw new Error("Failed to decode Draco mesh");const s=e.json.accessors[t.indices],a=xx[s.componentType],l=s.count*a.BYTES_PER_ELEMENT,c=fx._malloc(l);a===Uint16Array?n.GetTrianglesUInt16Array(o,l,c):n.GetTrianglesUInt32Array(o,l,c),Tx(fx.memory.buffer.slice(c,c+l),s,e),fx._free(c);for(const r of Object.keys(i.attributes)){const s=n.GetAttributeByUniqueId(o,i.attributes[r]),a=e.json.accessors[t.attributes[r]],l=bx[a.componentType],c=a.count*wx[a.type]*xx[a.componentType].BYTES_PER_ELEMENT,d=fx._malloc(c);n.GetAttributeDataArrayForAllPoints(o,s,fx[l],c,d),Tx(fx.memory.buffer.slice(d,d+c),a,e),fx._free(d)}n.destroy(),o.destroy(),delete t.extensions[Sx]}const Mx="EXT_meshopt_compression";function Cx(t,e){if(!t.extensions||!t.extensions[Mx])return;const i=t.extensions[Mx],n=new Uint8Array(e.buffers[i.buffer],i.byteOffset||0,i.byteLength||0),r=new Uint8Array(i.count*i.byteStride);_x.decodeGltfBuffer(r,i.count,i.byteStride,n,i.mode,i.filter),t.buffer=e.buffers.length,t.byteOffset=0,e.buffers[t.buffer]=r.buffer,delete t.extensions[Mx]}const Ax=1179937895,Ix=new TextDecoder("utf8");function Lx(t,e){return new URL(t,e).href}function Px(t,e,i,n){return fetch(Lx(t.uri,n)).then((t=>t.arrayBuffer())).then((t=>{e.buffers[i]=t}))}function $x(t,e){const i=t.json.bufferViews[e];return new Uint8Array(t.buffers[i.buffer],i.byteOffset||0,i.byteLength)}function kx(t,e,i,n){if(t.uri){const r=Lx(t.uri,n);return fetch(r).then((t=>t.blob())).then((t=>createImageBitmap(t))).then((t=>{e.images[i]=t}))}if(void 0!==t.bufferView){const n=$x(e,t.bufferView),r=new Blob([n],{type:t.mimeType});return createImageBitmap(r).then((t=>{e.images[i]=t}))}}function Dx(t,e=0,i){const n={json:null,images:[],buffers:[]};if(new Uint32Array(t,e,1)[0]===Ax){const i=new Uint32Array(t,e);let r=2;const o=(i[r++]>>2)-3,s=i[r++]>>2;if(r++,n.json=JSON.parse(Ix.decode(i.subarray(r,r+s))),r+=s,r{const t=[],e=a&&a.includes(Sx),r=a&&a.includes(Mx);if(e&&t.push(function(){if(!fx)return hx||(hx=function(t){let e,i=null;function n(){e=new Uint8Array(i.buffer)}function r(){throw new Error("Unexpected Draco error.")}const o={a:{a:r,d:function(t,i,n){return e.copyWithin(t,i,i+n)},c:function(t){const r=e.length,o=Math.max(t>>>0,Math.ceil(1.2*r)),s=Math.ceil((o-r)/65536);try{return i.grow(s),n(),!0}catch(t){return!1}},b:r}};return(WebAssembly.instantiateStreaming?WebAssembly.instantiateStreaming(t,o):t.then((t=>t.arrayBuffer())).then((t=>WebAssembly.instantiate(t,o)))).then((t=>{const{Rb:r,Qb:o,P:s,T:a,X:l,Ja:c,La:d,Qa:u,Va:h,Wa:p,eb:f,jb:m,f:_,e:g,yb:y,zb:v,Ab:x,Bb:b,Db:w,Gb:T}=t.instance.exports;i=g;const S=(()=>{let t=0,i=0,n=0,s=0;return a=>{n&&(r(s),r(t),i+=n,n=t=0),t||(i+=128,t=o(i));const l=a.length+7&-8;let c=t;l>=i&&(n=l,c=s=o(l));for(let t=0;t{fx=t,hx=void 0})))}()),r&&t.push(function(){if(_x)return;const t=function(t){let e;const i=WebAssembly.instantiateStreaming(t,{}).then((t=>{e=t.instance,e.exports.__wasm_call_ctors()})),n={NONE:"",OCTAHEDRAL:"meshopt_decodeFilterOct",QUATERNION:"meshopt_decodeFilterQuat",EXPONENTIAL:"meshopt_decodeFilterExp"},r={ATTRIBUTES:"meshopt_decodeVertexBuffer",TRIANGLES:"meshopt_decodeIndexBuffer",INDICES:"meshopt_decodeIndexSequence"};return{ready:i,supported:!0,decodeGltfBuffer(t,i,o,s,a,l){!function(t,e,i,n,r,o,s){const a=t.exports.sbrk,l=n+3&-4,c=a(l*r),d=a(o.length),u=new Uint8Array(t.exports.memory.buffer);u.set(o,d);const h=e(c,n,r,d,o.length);if(0===h&&s&&s(c,l,r),i.set(u.subarray(c,c+n*r)),a(c-a(0)),0!==h)throw new Error(`Malformed buffer data: ${h}`)}(e,e.exports[r[a]],t,i,o,s,e.exports[n[l]])}}}(fetch(vx()));return t.ready.then((()=>{_x=t}))}()),o)for(let e=0;e{if(e&&s)for(const{primitives:t}of s)for(const e of t)Ex(e,n);if(r&&s&&l)for(const t of l)Cx(t,n);return n}))}))}function zx(t,e){const i=t.json.bufferViews[e.bufferView],n=xx[e.componentType];return new n(t.buffers[i.buffer],(e.byteOffset||0)+(i.byteOffset||0),e.count*(i.byteStride&&i.byteStride!==wx[e.type]*n.BYTES_PER_ELEMENT?i.byteStride/n.BYTES_PER_ELEMENT:wx[e.type]))}function Rx(t,e,i,n){const r=xx[e.componentType],o=function(t){switch(t){case Int8Array:return 1/127;case Uint8Array:return 1/255;case Int16Array:return 1/32767;case Uint16Array:return 1/65535;default:return 1}}(r),s=t.json.bufferViews[e.bufferView],a=s.byteStride?s.byteStride/r.BYTES_PER_ELEMENT:wx[e.type],l=i.float32,c=l.length/i.capacity;for(let t=0,i=0;t0){for(let r=0;r0){o.texcoordArray=new ic;const t=e.json.accessors[r.TEXCOORD_0];o.texcoordArray.resize(t.count);const i=zx(e,t);Rx(e,t,o.texcoordArray,i)}if(void 0!==r._FEATURE_ID_RGBA4444){const t=e.json.accessors[r._FEATURE_ID_RGBA4444];e.json.extensionsUsed&&e.json.extensionsUsed.includes("EXT_meshopt_compression")&&(o.featureData=zx(e,t))}void 0!==r._FEATURE_RGBA4444&&(o.featureData=new Uint32Array(zx(e,e.json.accessors[r._FEATURE_RGBA4444]).buffer));const u=t.material;return o.material=function(t,e){const{emissiveFactor:i=[0,0,0],alphaMode:n="OPAQUE",alphaCutoff:r=.5,normalTexture:o,occlusionTexture:s,emissiveTexture:a,doubleSided:l}=t,{baseColorFactor:c=[1,1,1,1],metallicFactor:d=1,roughnessFactor:u=1,baseColorTexture:h,metallicRoughnessTexture:p}=t.pbrMetallicRoughness||{},f=s?e[s.index]:void 0;if(s&&s.extensions&&s.extensions.KHR_texture_transform&&f){const t=s.extensions.KHR_texture_transform;f.offsetScale=[t.offset[0],t.offset[1],t.scale[0],t.scale[1]]}return{pbrMetallicRoughness:{baseColorFactor:new Un(...c),metallicFactor:d,roughnessFactor:u,baseColorTexture:h?e[h.index]:void 0,metallicRoughnessTexture:p?e[p.index]:void 0},doubleSided:l,emissiveFactor:i,alphaMode:n,alphaCutoff:r,normalTexture:o?e[o.index]:void 0,occlusionTexture:f,emissionTexture:a?e[a.index]:void 0,defined:void 0===t.defined}}(void 0!==u?e.json.materials[u]:{defined:!1},i),o}function Bx(e,i,n){const{matrix:r,rotation:o,translation:s,scale:a,mesh:l,extras:c,children:d}=e,u={};if(u.matrix=r||t.ad.fromRotationTranslationScale([],o||[0,0,0,1],s||[0,0,0],a||[1,1,1]),void 0!==l){u.meshes=n[l];const t=u.anchor=[0,0];for(const e of u.meshes){const{min:i,max:n}=e.aabb;t[0]+=i[0]+n[0],t[1]+=i[1]+n[1]}t[0]=Math.floor(t[0]/u.meshes.length/2),t[1]=Math.floor(t[1]/u.meshes.length/2)}if(c&&(c.id&&(u.id=c.id),c.lights&&(u.lights=function(t){if(!t.length)return[];const e=function(t){const e=atob(t),i=new Uint8Array(e.length);for(let t=0;t1&&n[n.length-1].equals(n[0])&&n.pop();let r=0;for(let t=0;t0&&n.reverse();const o=xh(n.flatMap((t=>[t.x,t.y])),[]);return 0===o.length?null:{vertices:n,indices:o}}function Ux(e,i){const n=[],r=[];let o=0;const s=[];for(const a of e){o=n.length;const e=a.vertexArray.float32,l=a.indexArray.uint16;for(let r=0;r0&&([r[t+1],r[t+2]]=[r[t+2],r[t+1]])}return{vertices:n,indices:r}}function jx(t){const e=function(t,e){const i=[],n=WebGL2RenderingContext;if(t.json.textures)for(const r of t.json.textures){const o={magFilter:n.LINEAR,minFilter:n.NEAREST,wrapS:n.REPEAT,wrapT:n.REPEAT};void 0!==r.sampler&&Object.assign(o,t.json.samplers[r.sampler]),i.push({image:e[r.source],sampler:o,uploaded:!1})}return i}(t,t.images),i=function(t,e){const i=[];for(const n of t.json.meshes){const r=[];for(const i of n.primitives)r.push(Ox(i,t,e));i.push(r)}return i}(t,e),{scenes:n,scene:r,nodes:o}=t.json,s=n?n[r||0].nodes:o,a=[];for(const e of s)a.push(Bx(o[e],t,i));return function(t,e,i){const n={},r=new Set;for(let o=0;o0){const e=Array.from(r.values()).sort(((t,e)=>t-e));for(let i=e.length-1;i>=0;i--)t.splice(e[i],1)}}(a,s,t.json.nodes),a}function Vx(t){t.heightmap=new Float32Array(4096),t.heightmap.fill(-1);const e=t.vertexArray.float32,i=t.aabb.min[0]-1,n=t.aabb.min[1]-1,r=Wv/(t.aabb.max[0]-i+2),o=Wv/(t.aabb.max[1]-n+2);for(let s=0;st.heightmap[c*Wv+l]&&(t.heightmap[c*Wv+l]=a)}}function Gx(e,i){const n={};n.indexArray=new Kl,n.indexArray.reserve(4*e.length),n.vertexArray=new Bl,n.vertexArray.reserve(10*e.length),n.colorArray=new Ol,n.vertexArray.reserve(10*e.length);let r=0;for(const o of e){const e=Math.min(10,Math.max(4,1.3*o.height))*i,s=[-o.normal[1],o.normal[0],0],a=Math.min(.29,.1*o.width/o.depth),l=o.width-2*o.depth*i*(a+.01),c=t._.scaleAndAdd([],o.pos,s,l/2),d=t._.scaleAndAdd([],o.pos,s,-l/2),u=[c[0],c[1],c[2]+o.height],h=[d[0],d[1],d[2]+o.height],p=t._.scaleAndAdd([],o.normal,s,a);t._.scale(p,p,e);const f=t._.scaleAndAdd([],o.normal,s,-a);t._.scale(f,f,e),t._.add(p,c,p),t._.add(f,d,f),c[2]+=.1,d[2]+=.1,n.vertexArray.emplaceBack(p[0],p[1],p[2]),n.vertexArray.emplaceBack(f[0],f[1],f[2]),n.vertexArray.emplaceBack(c[0],c[1],c[2]),n.vertexArray.emplaceBack(d[0],d[1],d[2]),n.vertexArray.emplaceBack(u[0],u[1],u[2]),n.vertexArray.emplaceBack(h[0],h[1],h[2]),n.vertexArray.emplaceBack(c[0],c[1],c[2]),n.vertexArray.emplaceBack(d[0],d[1],d[2]),n.vertexArray.emplaceBack(p[0],p[1],p[2]),n.vertexArray.emplaceBack(f[0],f[1],f[2]);const m=l/e/2;n.colorArray.emplaceBack(-m-a,-1,m,.8),n.colorArray.emplaceBack(m+a,-1,m,.8),n.colorArray.emplaceBack(-m,0,m,1.3),n.colorArray.emplaceBack(m,0,m,1.3),n.colorArray.emplaceBack(m+a,-.8,m,.7),n.colorArray.emplaceBack(m+a,-.8,m,.7),n.colorArray.emplaceBack(0,0,m,1.3),n.colorArray.emplaceBack(0,0,m,1.3),n.colorArray.emplaceBack(m+a,-1.2,m,.8),n.colorArray.emplaceBack(m+a,-1.2,m,.8),n.indexArray.emplaceBack(6+r,4+r,8+r),n.indexArray.emplaceBack(7+r,9+r,5+r),n.indexArray.emplaceBack(0+r,1+r,2+r),n.indexArray.emplaceBack(1+r,3+r,2+r),r+=10}const o={defined:!0,emissiveFactor:[0,0,0]},s={};return s.baseColorFactor=Un.white,o.pbrMetallicRoughness=s,n.material=o,n.aabb=new wu([1/0,1/0,1/0],[-1/0,-1/0,-1/0]),n}const Zx=new Float32Array(262144),qx=new Uint8Array(262144);function Hx(t){let e=0;if(t.meshes)for(const i of t.meshes)e=Math.max(e,i.aabb.max[2]);if(t.children)for(const i of t.children)e=Math.max(e,Hx(i));return e}function Wx(t,e,i){if(t.meshes)for(const n of t.meshes)n.aabb.min[0]!==1/0&&i.insert(e,n.aabb.min[0],n.aabb.min[1],n.aabb.max[0],n.aabb.max[1]);if(t.children)for(const n of t.children)Wx(n,e,i)}const Yx=["","wall","door","roof","window","lamp","logo"];class Xx{constructor(t){this.node=t,this.evaluatedRMEA=[[1,0,0,1],[1,0,0,1],[1,0,0,1],[1,0,0,1],[.4,1,0,1],[1,0,0,1],[1,0,0,1]],this.hiddenByReplacement=!1,this.evaluatedScale=[1,1,1],this.evaluatedColor=[],this.emissionHeightBasedParams=[],this.feature={type:"Point",id:t.id,geometry:[],properties:{height:Hx(t)}},this.aabb=this._getLocalBounds()}_getLocalBounds(){if(!this.node.meshes)return new wu([1/0,1/0,1/0],[-1/0,-1/0,-1/0]);if(!this.aabb){let t=0;const e=new wu([1/0,1/0,1/0],[-1/0,-1/0,-1/0]);for(const i of this.node.meshes)this.node.lightMeshIndex!==t&&(i.transformedAabb=wu.applyTransformFast(i.aabb,this.node.matrix),e.encapsulate(i.transformedAabb)),t++;this.aabb=e}return this.aabb}}class Kx{constructor(t,e,i,n,r,o){this.id=e,this.modelTraits|=Yv.CoordinateSpaceTile,this.uploaded=!1,this.hasPattern=!1,i&&(this.modelTraits|=Yv.HasMapboxMeshFeatures),n&&(this.modelTraits|=Yv.HasMeshoptCompression),this.zoom=-1,this.terrainExaggeration=1,this.projection={name:"mercator"},this.replacementUpdateTime=0,this.elevationReadFromZ=255,this.brightness=r,this.dirty=!0,this.needsUpload=!1,this.nodesInfo=[];for(const e of t)this.nodesInfo.push(new Xx(e)),Wx(e,o.featureIndexArray.length,o.grid),o.featureIndexArray.emplaceBack(this.nodesInfo.length-1,0,o.bucketLayerIDs.length-1,0)}updateFootprints(t,e){for(const i of this.getNodesInfo()){const n=i.node;n.footprint&&e.push({footprint:n.footprint,id:t})}}update(){console.log("Update 3D model bucket")}populate(){console.log("populate 3D model bucket")}uploadPending(){return!this.uploaded||this.needsUpload}upload(t){if(!this.needsUpload)return;const e=this.getNodesInfo();for(const i of e){const e=i.node;this.uploaded?this.updatePbrBuffer(e):Qv(e,t,!0)}for(const t of e)tx(t.node);this.uploaded=!0,this.needsUpload=!1}updatePbrBuffer(t){let e=!1;if(!t.meshes)return e;for(const i of t.meshes)i.pbrBuffer&&(i.pbrBuffer.updateData(i.featureArray),e=!0);return e}needsReEvaluation(t,e,i){const n=t.transform.projectionOptions,r=t.style.getBrightness(),o=this.brightness!==r;return!!(!this.uploaded||this.dirty||n.name!==this.projection.name||Jx(i.paint.get("model-color").value,o)||Jx(i.paint.get("model-color-mix-intensity").value,o)||Jx(i.paint.get("model-roughness").value,o)||Jx(i.paint.get("model-emissive-strength").value,o)||Jx(i.paint.get("model-height-based-emissive-strength-multiplier").value,o))&&(this.projection=n,this.brightness=r,!0)}evaluateScale(t,e){if(t.transform.zoom===this.zoom)return;this.zoom=t.transform.zoom;const i=this.getNodesInfo(),n=this.id.canonical;for(const t of i){const i=t.feature;t.evaluatedScale=e.paint.get("model-scale").evaluate(i,{},n)}}evaluate(t){const e=this.getNodesInfo();for(const i of e){if(!i.node.meshes)continue;const e=i.feature,n=i.node.meshes&&i.node.meshes[0].featureData,r=i.evaluatedColor[2],o=i.evaluatedRMEA[2],s=this.id.canonical;if(i.hasTranslucentParts=!1,n){for(let n=0;n=t)continue;const u=Zx[c],h=Math.abs(u);h>a&&(s=u,a=h,l=r,d=e)}if(a>.1){const o=1-(t+.5*Math.abs(l*d))/c;let a=e._dem.get(n,i)+s*o;const u=e._dem.get(n+l,i+d),h=e._dem.get(n-l,i-d,!0);(a-u)*(a-h)>0&&(a=(u+h)/2),Zx[r]=e._dem.set(n,i,a),qx[r]=t}}}}}s&&(e._demTile.needsDEMTextureUpload=!0,e._dem._timestamp=ki.now())}getNodesInfo(){return this.nodesInfo}destroy(){const t=this.getNodesInfo();for(const e of t)tx(e.node),ex(e.node)}isEmpty(){return!this.nodesInfo.length}updateReplacement(t,e){if(e.updateTime===this.replacementUpdateTime)return;this.replacementUpdateTime=e.updateTime;const i=e.getReplacementRegionsForTile(t.toUnwrapped()),n=this.getNodesInfo();for(let t=0;tt.footprint===e.footprint))}}getHeightAtTileCoord(e,i){const n=this.getNodesInfo(),r=[],o=[0,0,0],s=t.ad.identity([]);for(let a=0;ad.max[0]||i>d.max[1])continue;if(!0===l.node.hidden)return{height:0,maxHeight:l.feature.properties.height,hidden:!1,verticalScale:l.evaluatedScale[2]};t.ad.invert(s,l.node.matrix),o[0]=e,o[1]=i,t._.transformMat4(o,o,s);const u=(o[0]-c.aabb.min[0])/(c.aabb.max[0]-c.aabb.min[0])*Wv|0,h=Math.min(63,(o[1]-c.aabb.min[1])/(c.aabb.max[1]-c.aabb.min[1])*Wv|0)*Wv+Math.min(63,u),p=c.heightmap[h];if(!(p0)return{height:void 0,maxHeight:l.feature.properties.height,hidden:l.hiddenByReplacement,verticalScale:l.evaluatedScale[2]}}}}function Jx(t,e){return!t.isLightConstant&&e}function Qx(t,e,i,n,r,o,s,a){let l=(61440&e|(61440&e)>>4)>>8,c=(3840&e|(3840&e)>>4)>>4,d=240&e|(240&e)>>4;i[3]>0&&(l=Vn(l,255*i[0],i[3]),c=Vn(c,255*i[1],i[3]),d=Vn(d,255*i[2],i[3]));const u=l>16&65535,a=o?e>>16&65535:65535&e,l=(15&a)t.polygon)).flat());const g=f?l:null,[y,v]=function(e,i,n,r,o,s,a,l,c,d,u){return"globe"===e.projection.name?function(e,i,n,r,o,s,a,l,c,d,u){const h=[],p=[],f=e.projection.upVectorScale(u,e.center.lat,e.worldSize).metersToTile,m=[0,0,0,1],_=[0,0,0,1],g=(t,e,i,n)=>{t[0]=e,t[1]=i,t[2]=n,t[3]=1},y=Sf();n>0&&(n+=y),r+=y;for(const y of i){const i=[],v=[];for(const h of y){const p=h.x+o.x,y=h.y+o.y,x=e.projection.projectTilePoint(p,y,u),b=e.projection.upVector(u,h.x,h.y);let w=n,T=r;if(a){const t=Pf(p,y,n,r,a,l,c,d);w+=t.base,T+=t.top}0!==n?g(m,x.x+b[0]*f*w,x.y+b[1]*f*w,x.z+b[2]*f*w):g(m,x.x,x.y,x.z),g(_,x.x+b[0]*f*T,x.y+b[1]*f*T,x.z+b[2]*f*T),t._.transformMat4(m,m,s),t._.transformMat4(_,_,s),i.push(new Tp(m[0],m[1],m[2])),v.push(new Tp(_[0],_[1],_[2]))}h.push(i),p.push(v)}return[h,p]}(e,i,n,r,o,s,a,l,c,d,u):a?function(e,i,n,r,o,s,a,l,c){const d=[],u=[],h=[0,0,0,1];for(const p of e){const e=[],f=[];for(const d of p){const u=d.x+r.x,p=d.y+r.y,m=Pf(u,p,i,n,s,a,l,c);h[0]=u,h[1]=p,h[2]=m.base,h[3]=1,t.aA.transformMat4(h,h,o),h[3]=Math.max(h[3],1e-5);const _=new Tp(h[0]/h[3],h[1]/h[3],h[2]/h[3]);h[0]=u,h[1]=p,h[2]=m.top,h[3]=1,t.aA.transformMat4(h,h,o),h[3]=Math.max(h[3],1e-5);const g=new Tp(h[0]/h[3],h[1]/h[3],h[2]/h[3]);e.push(_),f.push(g)}d.push(e),u.push(f)}return[d,u]}(i,n,r,o,s,a,l,c,d):function(t,e,i,n,r){const o=[],s=[],a=r[8]*e,l=r[9]*e,c=r[10]*e,d=r[11]*e,u=r[8]*i,h=r[9]*i,p=r[10]*i,f=r[11]*i;for(const e of t){const t=[],i=[];for(const o of e){const e=o.x+n.x,s=o.y+n.y,m=r[0]*e+r[4]*s+r[12],_=r[1]*e+r[5]*s+r[13],g=r[2]*e+r[6]*s+r[14],y=r[3]*e+r[7]*s+r[15],v=m+a,x=_+l,b=g+c,w=Math.max(y+d,1e-5),T=m+u,S=_+h,E=g+p,M=Math.max(y+f,1e-5);t.push(new Tp(v/w,x/w,b/w)),i.push(new Tp(T/M,S/M,E/M))}o.push(t),s.push(i)}return[o,s]}(i,n,r,o,s)}(s,r,h,u,d,a,g,p,m,s.center.lat,e.tileID.canonical),x=e.queryGeometry;return function(t,e,i){let n=1/0;Kd(i,e)&&(n=Lf(i,e[0]));for(let r=0;r=3)for(let e=0;e>4;if(1!==n)throw new Error(`Got v${n} data when expected v1.`);const r=nb[15&i];if(!r)throw new Error("Unrecognized array type.");const[o]=new Uint16Array(t,2,1),[s]=new Uint32Array(t,4,1);return new rb(s,o,r,t)}constructor(t,e=64,i=Float64Array,n){if(isNaN(t)||t>1;return this.ids[i]=i,this.coords[this._pos++]=t,this.coords[this._pos++]=e,i}finish(){const t=this._pos>>1;if(t!==this.numItems)throw new Error(`Added ${t} items when expected ${this.numItems}.`);return ob(this.ids,this.coords,this.nodeSize,0,this.numItems-1,0),this._finished=!0,this}range(t,e,i,n){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");const{ids:r,coords:o,nodeSize:s}=this,a=[0,r.length-1,0],l=[];for(;a.length;){const c=a.pop()||0,d=a.pop()||0,u=a.pop()||0;if(d-u=t&&a=e&&c>1,p=o[2*h],f=o[2*h+1];p>=t&&p=e&&f=p:n>=f)&&(a.push(h+1),a.push(d),a.push(1-c))}return l}within(t,e,i){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");const{ids:n,coords:r,nodeSize:o}=this,s=[0,n.length-1,0],a=[],l=i*i;for(;s.length;){const c=s.pop()||0,d=s.pop()||0,u=s.pop()||0;if(d-u>1,p=r[2*h],f=r[2*h+1];cb(p,f,t,e)=p:e+i>=f)&&(s.push(h+1),s.push(d),s.push(1-c))}return a}}function ob(t,e,i,n,r,o){if(r-n>1;sb(t,e,s,n,r,o),ob(t,e,i,n,s-1,1-o),ob(t,e,i,s+1,r,1-o)}function sb(t,e,i,n,r,o){for(;r>n;){if(r-n>600){const s=r-n+1,a=i-n+1,l=Math.log(s),c=.5*Math.exp(2*l/3),d=.5*Math.sqrt(l*c*(s-c)/s)*(a-s/2s&&ab(t,e,n,r);as;)l--}e[2*n+o]===s?ab(t,e,n,l):(l++,ab(t,e,l,r)),lr&&(n+=(t[i]-r)*(t[i]-r)),e[i]0&&n[0]0&&n[1]0&&r[0]0&&r[1]0?Math.acos(i/n)*Ve:0;let o=0!==t||0!==e?Math.atan2(-e,-t)*Ve+90:0;return oNi&&(t.getActor().send("enforceCacheSizeLimit",Fi),Vi=0)},t.an=gn,t.ao=class{constructor(t){this.entries={},this.scheduler=t}request(t,e,i,n){const r=this.entries[t]=this.entries[t]||{callbacks:[]};if(r.result){const[t,i]=r.result;return this.scheduler?this.scheduler.add((()=>{n(t,i)}),e):n(t,i),()=>{}}return r.callbacks.push(n),r.cancel||(r.cancel=i(((i,n)=>{r.result=[i,n];for(const t of r.callbacks)this.scheduler?this.scheduler.add((()=>{t(i,n)}),e):t(i,n);setTimeout((()=>delete this.entries[t]),3e3)}))),()=>{r.result||(r.callbacks=r.callbacks.filter((t=>t!==n)),r.callbacks.length||(r.cancel(),delete this.entries[t]))}}},t.ap=function(t,e,i){const n=JSON.stringify(t.request);return t.data&&(this.deduped.entries[n]={result:[null,t.data]}),this.deduped.request(n,{type:"parseTile",isSymbolTile:t.isSymbolTile,zoom:t.tileZoom},(e=>{const n=en(t.request,((t,n,r,o)=>{t?e(t):n&&e(null,{vectorTile:i?void 0:new bp(new Lm(n)),rawData:n,cacheControl:r,expires:o})}));return()=>{n.cancel(),e()}}),e)},t.aq=Dc,t.ar=class extends Lc{constructor(t){super(t),this.current=Fc}set(t,e,i){if(this.fetchUniformLocation(t,e))for(let t=0;t({u_camera_to_center_distance:new $c(t),u_extrude_scale:new Uc(t),u_device_pixel_ratio:new $c(t),u_matrix:new Bc(t),u_inv_rot_matrix:new Bc(t),u_merc_center:new kc(t),u_tile_id:new Dc(t),u_zoom_transition:new $c(t),u_up_dir:new Dc(t),u_emissive_strength:new $c(t)}),t.bJ=t=>({u_matrix:new Bc(t),u_pixels_to_tile_units:new Uc(t),u_device_pixel_ratio:new $c(t),u_units_to_pixels:new kc(t),u_dash_image:new Pc(t),u_gradient_image:new Pc(t),u_image_height:new $c(t),u_texsize:new kc(t),u_tile_units_to_pixels:new $c(t),u_alpha_discard_threshold:new $c(t),u_trim_offset:new kc(t),u_trim_fade_range:new kc(t),u_trim_color:new zc(t),u_emissive_strength:new $c(t)}),t.bK=t=>({u_matrix:new Bc(t),u_texsize:new kc(t),u_pixels_to_tile_units:new Uc(t),u_device_pixel_ratio:new $c(t),u_image:new Pc(t),u_units_to_pixels:new kc(t),u_tile_units_to_pixels:new $c(t),u_alpha_discard_threshold:new $c(t),u_trim_offset:new kc(t)}),t.bL=Yl,t.bM=Hf,t.bN=Om,t.bO=jm,t.bP=G_,t.bQ=c_,t.bR=th,t.bS=(t,e,i,n,r,o)=>{const s=t.transform,a="globe"===s.projection.name;let l;if("map"===o.paint.get("circle-pitch-alignment"))if(a){const t=Zu(s.zoom,e.canonical)*s._pixelsPerMercatorPixel;l=Float32Array.from([t,0,0,t])}else l=s.calculatePixelsToTileUnitsMatrix(i);else l=new Float32Array([s.pixelsToGLUnits[0],0,0,s.pixelsToGLUnits[1]]);const c={u_camera_to_center_distance:t.transform.getCameraToCenterDistance(s.projection),u_matrix:t.translatePosMatrix(e.projMatrix,i,o.paint.get("circle-translate"),o.paint.get("circle-translate-anchor")),u_device_pixel_ratio:ki.devicePixelRatio,u_extrude_scale:l,u_inv_rot_matrix:Qu,u_merc_center:[0,0],u_tile_id:[0,0,0],u_zoom_transition:0,u_up_dir:[0,0,0],u_emissive_strength:o.paint.get("circle-emissive-strength")};if(a){c.u_inv_rot_matrix=n,c.u_merc_center=r,c.u_tile_id=[e.canonical.x,e.canonical.y,1{const s=t.transform;return{u_matrix:rm(t,e,i,n),u_texsize:e.imageAtlasTexture?e.imageAtlasTexture.size:[0,0],u_pixels_to_tile_units:s.calculatePixelsToTileUnitsMatrix(e),u_device_pixel_ratio:r,u_image:0,u_tile_units_to_pixels:nm(e,s),u_units_to_pixels:[1/s.pixelsToGLUnits[0],1/s.pixelsToGLUnits[1]],u_alpha_discard_threshold:0,u_trim_offset:o}},t.bV=(t,e,i,n,r,o,s)=>{const a=t.transform,l=a.calculatePixelsToTileUnitsMatrix(e);return{u_matrix:rm(t,e,i,n),u_pixels_to_tile_units:l,u_device_pixel_ratio:o,u_units_to_pixels:[1/a.pixelsToGLUnits[0],1/a.pixelsToGLUnits[1]],u_dash_image:0,u_gradient_image:1,u_image_height:r,u_texsize:sm(i)&&e.lineAtlasTexture?e.lineAtlasTexture.size:[0,0],u_tile_units_to_pixels:nm(e,t.transform),u_alpha_discard_threshold:0,u_trim_offset:s,u_trim_fade_range:i.paint.get("line-trim-fade-range"),u_trim_color:i.paint.get("line-trim-color").toRenderColor(i.lut).toArray01(),u_emissive_strength:i.paint.get("line-emissive-strength")}},t.bW=oi,t.bX=mh,t.bY=Sf,t.bZ=bd,t.b_=_f,t.ba=function(t,e,i){const n=Hu(i.zoom),r=t.style.map._antialias,o=e.options.extStandardDerivativesForceOff||t.terrain&&t.terrain.exaggeration()>0;return 0===n&&!r&&!o},t.bb=function(e){const i=e.pixelsPerMeter,n=i/Cd(1,e.center.lat),r=t.ad.identity(new Float64Array(16));return t.ad.translate(r,r,[e.point.x,e.point.y,0]),t.ad.scale(r,r,[n,n,i]),Float32Array.from(r)},t.bc=Ou,t.bd=function(t){const e=Pd-5;t=Xe(t,-e,e)/e*90;const i=Math.pow(Math.abs(Math.sin(Ge(t))),3);return Math.round(i*(sd.length-1))},t.be=function(e,i,n,r){const o=i.getNorth(),s=i.getSouth(),a=i.getWest(),l=i.getEast(),c=10){const e=180/r;t.bC.multiply(f,f,[e/d+1,0,0,0,e/u+1,0,-.5*e/h,.5*e/p,1])}return f[2]=c,f[5]=e.x,f[8]=e.y,f},t.bf=ju,t.bg=$u,t.bh=function(e,i,n){const r=t.ad.identity(new Float64Array(16)),o=(i/(1{}}},t.bo=Gg,t.bp=ai,t.bq=class{isDataAvailableAtPoint(t){const e=this._source();if(this.isUsingMockSource()||!e||t.y1)return!1;const i=e.getSource().maxzoom,n=11)return e;const r=n.getSource().maxzoom,o=1{const s=this.getAtTileOffset(e,o.x,o.y),a=r.upVector(e.canonical,o.x,o.y),l=r.upVectorScale(e.canonical,i,n).metersToTile;return t._.scale(a,a,s*l),a}}getForTilePoints(t,e,i,n){if(this.isUsingMockSource())return!1;const r=Xp.create(this,t,n);return!!r&&(e.forEach((t=>{t[2]=this.exaggeration()*r.getElevationAt(t[0],t[1],i)})),!0)}getMinMaxForTile(t){if(this.isUsingMockSource())return null;const e=this.findDEMTileFor(t);if(!e||!e.dem)return null;const i=e.dem.tree,n=e.tileID,r=1=0?t.slice(0,e):t},t.cV=function(t){return t.indexOf(wl)>=0},t.cW=function(t){const e=t.indexOf(wl);return e>=0?t.slice(e+1):""},t.cX=function(t){const e=[],i=t.id;return void 0===i&&e.push({message:`layers.${i}: missing required property "id"`}),void 0===t.render&&e.push({message:`layers.${i}: missing required method "render"`}),t.renderingMode&&"2d"!==t.renderingMode&&"3d"!==t.renderingMode&&e.push({message:`layers.${i}: property "renderingMode" must be either "2d" or "3d"`}),e},t.cY=function(t,e,i,n){return"custom"===t.type?new vv(t,e):new ib[t.type](t,e,i,n)},t.cZ=di,t.c_=Va,t.ca=1,t.cb=Ag,t.cc=0,t.cd=ec,t.ce=function(t,e,i,n,r){return Xe((t-e)/(i-e)*(r-n)+n,n,r)},t.cf=Ns,t.cg=kd,t.ch=class{constructor(t,e,i,n){this.context=t,this.format=n,this.size=i,this.texture=t.gl.createTexture();const[r,o,s]=this.size,{gl:a}=t;a.bindTexture(a.TEXTURE_3D,this.texture),t.pixelStoreUnpackFlipY.set(!1),t.pixelStoreUnpack.set(1),t.pixelStoreUnpackPremultiplyAlpha.set(!1);let l=this.format,c=a.UNSIGNED_BYTE;this.format===a.DEPTH_COMPONENT&&(l=a.DEPTH_COMPONENT16,c=a.UNSIGNED_SHORT),this.format===a.R8&&(n=a.RED),this.format===a.R32F&&(c=a.FLOAT,n=a.RED),a.texImage3D(a.TEXTURE_3D,0,l,r,o,s,0,n,c,e.data)}bind(t,e){const{context:i}=this,{gl:n}=i;n.bindTexture(n.TEXTURE_3D,this.texture),t!==this.minFilter&&(n.texParameteri(n.TEXTURE_3D,n.TEXTURE_MAG_FILTER,t),n.texParameteri(n.TEXTURE_3D,n.TEXTURE_MIN_FILTER,t),this.minFilter=t),e!==this.wrapS&&(n.texParameteri(n.TEXTURE_3D,n.TEXTURE_WRAP_S,e),n.texParameteri(n.TEXTURE_3D,n.TEXTURE_WRAP_T,e),this.wrapS=e)}destroy(){const{gl:t}=this.context;t.deleteTexture(this.texture),this.texture=null}},t.ci=$v,t.cj=[1,1,1],t.ck=Xp,t.cl=Yv,t.cm=ql,t.cn=ic,t.co=class{constructor(){this._updateTime=0,this._sourceIds=[],this._activeRegions=[],this._prevRegions=[],this._globalClipBounds={min:new Ue(1/0,1/0),max:new Ue(-1/0,-1/0)}}clear(){this._activeRegions.length>0&&++this._updateTime,this._activeRegions=[],this._prevRegions=[]}get updateTime(){return this._updateTime}getReplacementRegionsForTile(t,e=!1){const i=$p(new Ue(0,0),new Ue(uo,uo),t),n=[];if(e&&!Lp(i,this._globalClipBounds))return n;for(const e of this._activeRegions){if(e.hiddenByOverlap)continue;if(!Lp(i,e))continue;const r=kp(e.min,e.max,t);n.push({min:r.min,max:r.max,sourceId:this._sourceIds[e.priority],footprint:e.footprint,footprintTileId:e.tileId,order:e.order,clipMask:e.clipMask})}return n}setSources(t){this._setSources(t.map((t=>({getSourceId:()=>t.cache.id,getFootprints:()=>{const e=[];for(const i of t.cache.getVisibleCoordinates()){const n=t.cache.getTile(i).buckets[t.layer];n&&n.updateFootprints(i.toUnwrapped(),e)}return e},getOrder:()=>t.order,getClipMask:()=>t.clipMask}))))}_addSource(t){const e=t.getFootprints();if(0===e.length)return;const i=t.getOrder(),n=t.getClipMask();for(const t of e){if(!t.footprint)continue;const e=$p(t.footprint.min,t.footprint.max,t.id);this._activeRegions.push({min:e.min,max:e.max,hiddenByOverlap:!1,priority:this._sourceIds.length,tileId:t.id,footprint:t.footprint,order:i,clipMask:n})}this._sourceIds.push(t.getSourceId())}_computeReplacement(){this._activeRegions.sort(((t,e)=>t.priority-e.priority||Ap(t.min,e.min)||Ap(t.max,e.max)));let t=this._activeRegions.length!==this._prevRegions.length;if(!t){let e=0;for(;!t&&e!==this._activeRegions.length;){const i=this._activeRegions[e],n=this._prevRegions[e];t=i.priority!==n.priority||!Ip(i,n)||i.order!==n.order||i.clipMask!==n.clipMask,++e}}if(t){++this._updateTime;for(const t of this._activeRegions)t.order!==1/0&&(this._globalClipBounds.min.x=Math.min(this._globalClipBounds.min.x,t.min.x),this._globalClipBounds.min.y=Math.min(this._globalClipBounds.min.y,t.min.y),this._globalClipBounds.max.x=Math.max(this._globalClipBounds.max.x,t.max.x),this._globalClipBounds.max.y=Math.max(this._globalClipBounds.max.y,t.max.y));const t=t=>{const e=this._activeRegions;if(t>=e.length)return t;const i=e[t].priority;for(;t1){let e=0,i=t(e);for(;e!==i;){let n=e;const r=e;for(;n!==i;){const t=this._activeRegions[n];t.hiddenByOverlap=!1;for(let e=0;e=0;e--)this._addSource(t[e]);this._computeReplacement()}},t.cp=Dl,t.cq=Jg,t.cr=rc,t.cs=class{constructor(t){this._createGrid(t),this._createPoles(t)}destroy(){this._poleIndexBuffer.destroy(),this._gridBuffer.destroy(),this._gridIndexBuffer.destroy(),this._poleNorthVertexBuffer.destroy(),this._poleSouthVertexBuffer.destroy();for(const t of this._poleSegments)t.destroy();for(const t of this._gridSegments)t.withSkirts.destroy(),t.withoutSkirts.destroy()}_fillGridMeshWithLods(t,e){const i=new $l,n=new Kl,r=[],o=t+1+2,s=e[0]+1,a=e[0]+1+(1+e.length),l=(t,e,i)=>{let n=t===o-1?t-2:0===t?t:t-1;return n+=i?24575:0,[n,e]};for(let t=0;tt()))},t.dB=sx,t.dC=yx,t.dD=function(t){px=ki.resolveURL(t),gx||(gx=new ox(ux(),new zn)),gx.broadcast("setDracoUrl",px)},t.dE=vx,t.dF=function(t){mx=ki.resolveURL(t),gx||(gx=new ox(ux(),new zn)),gx.broadcast("setMeshoptUrl",mx)},t.dG=ti,t.dH=ba,t.dI=dh,t.dJ=I_,t.dK=eg,t.dL=dc,t.dM=am,t.dN=Dm,t.dO=Wf,t.dP=ci,t.dQ=E_,t.dR=jg,t.dS=function(t,e,i,n,r,o,s,a,l,c,d){t.createArrays(),t.tilePixelRatio=uo/(512*t.overscaling),t.compareText={},t.iconsNeedLinear=!1;const u=t.layers[0].layout,h=t.layers[0]._unevaluatedLayout._values,p={};if("composite"===t.textSizeData.kind){const{minZoom:e,maxZoom:i}=t.textSizeData;p.compositeTextSizes=[h["text-size"].possiblyEvaluate(new Ha(e),a),h["text-size"].possiblyEvaluate(new Ha(i),a)]}if("composite"===t.iconSizeData.kind){const{minZoom:e,maxZoom:i}=t.iconSizeData;p.compositeIconSizes=[h["icon-size"].possiblyEvaluate(new Ha(e),a),h["icon-size"].possiblyEvaluate(new Ha(i),a)]}p.layoutTextSize=h["text-size"].possiblyEvaluate(new Ha(l+1),a),p.layoutIconSize=h["icon-size"].possiblyEvaluate(new Ha(l+1),a),p.textMaxSize=h["text-size"].possiblyEvaluate(new Ha(18),a);const f="map"===u.get("text-rotation-alignment")&&"point"!==u.get("symbol-placement"),m=u.get("text-size");let _=!1;for(const e of t.features)if(e.icon&&e.icon.nameSecondary){_=!0;break}for(const o of t.features){const l=u.get("text-font").evaluate(o,{},a).join(","),h=m.evaluate(o,{},a),g=p.layoutTextSize.evaluate(o,{},a),y=(p.layoutIconSize.evaluate(o,{},a),{horizontal:{},vertical:void 0}),v=o.text;let x,b=[0,0];if(v){const n=v.toString(),s=u.get("text-letter-spacing").evaluate(o,{},a)*Om,c=u.get("text-line-height").evaluate(o,{},a)*Om,d=Aa(n)?s:0,p=u.get("text-anchor").evaluate(o,{},a),m=u.get("text-variable-anchor");if(!m){const t=u.get("text-radial-offset").evaluate(o,{},a);b=t?G_(p,[t*Om,j_]):u.get("text-offset").evaluate(o,{},a).map((t=>t*Om))}let _=f?"center":u.get("text-justify").evaluate(o,{},a);const x="point"===u.get("symbol-placement"),w=x?u.get("text-max-width").evaluate(o,{},a)*Om:1/0,T=o=>{t.allowVerticalPlacement&&Ca(n)&&(y.vertical=e_(v,e,i,r,l,w,c,p,o,d,b,Jm.vertical,!0,g,h))};if(!f&&m){const t="auto"===_?m.map((t=>Z_(t))):[_];let n=!1;for(let o=0;o=0||!Ca(n)){const t=e_(v,e,i,r,l,w,c,p,_,d,b,Jm.horizontal,!1,g,h);t&&(y.horizontal[_]=t)}T(x?"left":_)}}let w=!1;if(o.icon&&o.icon.namePrimary){const e=n[o.icon.namePrimary];e&&(x=u_(r[o.icon.namePrimary],o.icon.nameSecondary?r[o.icon.nameSecondary]:void 0,u.get("icon-offset").evaluate(o,{},a),u.get("icon-anchor").evaluate(o,{},a)),w=e.sdf,void 0===t.sdfIcons?t.sdfIcons=e.sdf:t.sdfIcons!==e.sdf&&pi("Style sheet warning: Cannot mix SDF and non-SDF icons in one buffer"),(e.pixelRatio!==t.pixelRatio||0!==u.get("icon-rotate").constantOr(1))&&(t.iconsNeedLinear=!0))}const T=X_(y.horizontal)||y.vertical;t.iconsInText||(t.iconsInText=!!T&&T.iconsInText),(T||x)&&q_(t,o,y,x,n,p,g,0,b,w,s,a,c,d,_)}o&&t.generateCollisionDebugBuffers(l,t.collisionBoxArray)},t.dT=Jf,t.dU=Yh,t.dV=bp,t.dW=Lm,t.dX=Yp,t.dY=Zy,t.dZ=wp,t.d_=cp,t.da=Wu,t.db=function(e){const i=[0,0,0],n=t.ad.identity(new Float64Array(16));return t.ad.multiply(n,e.pixelMatrix,e.globeMatrix),t._.transformMat4(i,i,n),new Ue(i[0],i[1])},t.dc=d,t.dd=c,t.de=function(t){const e=t.navigator?t.navigator.userAgent:null;return!!function(t){if(null==Ei){const e=t.navigator?t.navigator.userAgent:null;Ei=!!t.safari||!(!e||!(/\b(iPad|iPhone|iPod)\b/.test(e)||e.match("Safari")&&!e.match("Chrome")))}return Ei}(t)&&e&&(e.match("Version/15.4")||e.match("Version/15.5")||e.match(/CPU (OS|iPhone OS) (15_4|15_5) like Mac OS X/))},t.df=ni,t.dg=class{constructor(t,e,i){this._transformRequestFn=t,this._customAccessToken=e,this._silenceAuthErrors=!!i,this._createSkuToken()}_createSkuToken(){const t=function(){let t="";for(let e=0;ethis._skuTokenExpiresAt}transformRequest(t,e){return this._transformRequestFn&&this._transformRequestFn(t,e)||{url:t}}normalizeStyleURL(t,i){if(!o(t))return t;const n=un(t);return n.params.push(`sdk=js-${e}`),n.path=`/styles/v1${n.path}`,this._makeAPIURL(n,this._customAccessToken||i)}normalizeGlyphsURL(t,e){if(!o(t))return t;const i=un(t);return i.path=`/fonts/v1${i.path}`,this._makeAPIURL(i,this._customAccessToken||e)}normalizeModelURL(t,e){if(!o(t))return t;const i=un(t);return i.path=`/models/v1${i.path}`,this._makeAPIURL(i,this._customAccessToken||e)}normalizeSourceURL(t,e,i,n){if(!o(t))return t;const r=un(t);return r.path=`/v4/${r.authority}.json`,r.params.push("secure"),i&&r.params.push(`language=${i}`),n&&r.params.push(`worldview=${n}`),this._makeAPIURL(r,this._customAccessToken||e)}normalizeSpriteURL(t,e,i,n){const r=un(t);return o(t)?(r.path=`/styles/v1${r.path}/sprite${e}${i}`,this._makeAPIURL(r,this._customAccessToken||n)):(r.path+=`${e}${i}`,hn(r))}normalizeTileURL(t,e,i){if(this._isSkuTokenExpired()&&this._createSkuToken(),t&&!o(t))return t;const r=un(t);r.path=r.path.replace(/(\.(png|jpg)\d*)(?=$)/,`${e||i&&"raster"!==r.authority&&512===i?"@2x":""}${Gi.supported?".webp":"$1"}`),"raster"===r.authority?r.path=`/${n.RASTER_URL_PREFIX}${r.path}`:"rasterarrays"===r.authority?r.path=`/${n.RASTERARRAYS_URL_PREFIX}${r.path}`:"3dtiles"===r.authority?r.path=`/${n.TILES3D_URL_PREFIX}${r.path}`:(r.path=r.path.replace(/^.+\/v4\//,"/"),r.path=`/${n.TILE_URL_VERSION}${r.path}`);const s=this._customAccessToken||function(t){for(const e of t){const t=e.match(/^access_token=(.*)$/);if(t)return t[1]}return null}(r.params)||n.ACCESS_TOKEN;return n.REQUIRE_ACCESS_TOKEN&&s&&this._skuToken&&r.params.push(`sku=${this._skuToken}`),this._makeAPIURL(r,s)}canonicalizeTileURL(t,e){const i=un(t);if(!i.path.match(/^(\/v4\/|\/(raster|rasterarrays)\/v1\/)/)||!i.path.match(/\.[\w]+$/))return t;let r="mapbox://";i.path.match(/^\/raster\/v1\//)?r+=`raster/${i.path.replace(`/${n.RASTER_URL_PREFIX}/`,"")}`:i.path.match(/^\/rasterarrays\/v1\//)?r+=`rasterarrays/${i.path.replace(`/${n.RASTERARRAYS_URL_PREFIX}/`,"")}`:r+=`tiles/${i.path.replace(`/${n.TILE_URL_VERSION}/`,"")}`;let o=i.params;return e&&(o=o.filter((t=>!t.match(/^access_token=/)))),o.length&&(r+=`?${o.join("&")}`),r}canonicalizeTileset(t,e){const i=!!e&&o(e),n=[];for(const e of t.tiles||[])r(e)?n.push(this.canonicalizeTileURL(e,i)):n.push(e);return n}_makeAPIURL(t,e){const i="See https://docs.mapbox.com/api/overview/#access-tokens-and-token-scopes",r=un(n.API_URL);if(t.protocol=r.protocol,t.authority=r.authority,"http"===t.protocol){const e=t.params.indexOf("secure");e>=0&&t.params.splice(e,1)}if("/"!==r.path&&(t.path=`${r.path}${t.path}`),!n.REQUIRE_ACCESS_TOKEN)return hn(t);if(e=e||n.ACCESS_TOKEN,!this._silenceAuthErrors){if(!e)throw new Error(`An API access token is required to use Mapbox GL. ${i}`);if("s"===e[0])throw new Error(`Use a public access token (pk.*) with Mapbox GL, not a secret access token (sk.*). ${i}`)}return t.params=t.params.filter((t=>-1===t.indexOf("access_token"))),t.params.push(`access_token=${e||""}`),hn(t)}},t.dh=function(t,e){e?Mn.add(t):Mn.delete(t)},t.di=Gi,t.dj=Tn,t.dk=En,t.dl=cn,t.dm=vn,t.dn=bn,t.dp=function(t){Mn.delete(t)},t.dq=Sn,t.dr=yn,t.ds=Qe,t.dt=e,t.du=function(t,e){Fi=t,Ni=e},t.dv=function(t,e,i=!1){if(Fa===za||Fa===Ra||Fa===Oa)throw new Error("setRTLTextPlugin cannot be called multiple times.");Na=ki.resolveURL(t),Fa=za,Ba=e,ja(),i||Za()},t.dw=Ga,t.dx=function(){ux().acquire(lx)},t.dy=function(){const t=dx;t&&(t.isPreloaded()&&1===t.numActive()?(t.release(lx),dx=null):console.warn("Could not clear WebWorkers since there are active Map instances that still reference it. The pre-warmed WebWorker pool can only be cleared when all map instances have been removed with map.remove()"))},t.dz=cx,t.e=ki,t.e0=cm,t.e1=h,t.e2=en,t.e3=function(t){let e=0;if(new Uint32Array(t,0,1)[0]!==Ax){const i=new Uint32Array(t,0,7),[,,n,r,o,s]=i;e=i.byteLength+r+o+s+o,(n!==t.byteLength||e>=t.byteLength)&&pi("Invalid b3dm header information.")}return Dx(t,e)},t.e4=function(t,e){const i=jx(t);for(const t of i){for(const e of t.meshes)Vx(e);t.lights&&(t.lightMeshIndex=t.meshes.length,t.meshes.push(Gx(t.lights,e)))}return i},t.e5=Kx,t.e6=rx,t.e7=qa,t.e8=function(t){ji(),Oi&&Oi.then((e=>{e.keys().then((i=>{for(let n=0;nt.arrayBuffer())).then((e=>Dx(e,0,t)))},t.m=class extends Uv{},t.n=Er,t.o=qn,t.p=Qg,t.q=Xs,t.r=Js,t.s=Qs,t.t=ca,t.u=al,t.v=ll,t.w=pi,t.x=pa,t.y=da,t.z=qo})),n(0,(function(t){function e(t){const e=t?t.url.toString():void 0;return e?performance.getEntriesByName(e):[]}function i(t){if("number"==typeof t||"boolean"==typeof t||"string"==typeof t||null==t)return JSON.stringify(t);if(Array.isArray(t)){let e="[";for(const n of t)e+=`${i(n)},`;return`${e}]`}let e="{";for(const n of Object.keys(t).sort())e+=`${n}:${i(t[n])},`;return`${e}}`}function n(e){let n="";for(const r of t.cE)n+=`/${i(e[r])}`;return n}class r{constructor(t){this.keyCache={},this._layers={},this._layerConfigs={},t&&this.replace(t)}replace(t,e){this._layerConfigs={},this._layers={},this.update(t,[],e)}update(e,i,r){this._options=r;for(const i of e)this._layerConfigs[i.id]=i,(this._layers[i.id]=t.cY(i,this.scope,null,this._options)).compileFilter(),this.keyCache[i.id]&&delete this.keyCache[i.id];for(const t of i)delete this.keyCache[t],delete this._layerConfigs[t],delete this._layers[t];this.familiesBySource={};const o=function(t,e){const i={};for(let r=0;rthis._layers[t.id])),i=e[0];if("none"===i.visibility)continue;const n=i.source||"";let r=this.familiesBySource[n];r||(r=this.familiesBySource[n]={});const o=i.sourceLayer||"_geojsonTileLayer";let s=r[o];s||(s=r[o]=[]),s.push(e)}}}const o=1*t.dJ;class s{constructor(e){const i={},n=[];for(const t in e){const r=e[t],s=i[t]={};for(const t in r.glyphs){const e=r.glyphs[+t];if(!e||0===e.bitmap.width||0===e.bitmap.height)continue;const i=e.metrics.localGlyph?o:1,a={x:0,y:0,w:e.bitmap.width+2*i,h:e.bitmap.height+2*i};n.push(a),s[t]=a}}const{w:r,h:s}=t.j(n),a=new t.dI({width:r||1,height:s||1});for(const n in e){const r=e[n];for(const e in r.glyphs){const s=r.glyphs[+e];if(!s||0===s.bitmap.width||0===s.bitmap.height)continue;const l=i[n][e],c=s.metrics.localGlyph?o:1;t.dI.copy(s.bitmap,a,{x:0,y:0},{x:l.x+c,y:l.y+c},s.bitmap)}}this.image=a,this.positions=i}}t.dH(s,"GlyphAtlas");class a{constructor(e){this.tileID=new t.aL(e.tileID.overscaledZ,e.tileID.wrap,e.tileID.canonical.z,e.tileID.canonical.x,e.tileID.canonical.y),this.tileZoom=e.tileZoom,this.uid=e.uid,this.zoom=e.zoom,this.lut=e.lut,this.canonical=e.tileID.canonical,this.pixelRatio=e.pixelRatio,this.tileSize=e.tileSize,this.source=e.source,this.scope=e.scope,this.overscaling=this.tileID.overscaleFactor(),this.showCollisionBoxes=e.showCollisionBoxes,this.collectResourceTiming=!!e.collectResourceTiming,this.promoteId=e.promoteId,this.isSymbolTile=e.isSymbolTile,this.tileTransform=t.dK(e.tileID.canonical,e.projection),this.projection=e.projection,this.brightness=e.brightness,this.extraShadowCaster=!!e.extraShadowCaster,this.tessellationStep=e.tessellationStep}parse(e,i,n,r,o){this.status="parsing",this.data=e,this.collisionBoxArray=new t.dL;const a=new t.dM(Object.keys(e.layers).sort()),c=new t.dN(this.tileID,this.promoteId);c.bucketLayerIDs=[];const d={},u=new t.dO(256,256),h={featureIndex:c,iconDependencies:{},patternDependencies:{},glyphDependencies:{},lineAtlas:u,availableImages:n,brightness:this.brightness},p=i.familiesBySource[this.source];for(const i in p){const r=e.layers[i];if(!r)continue;let o=!1,s=!1,u=!1;for(const t of p[i])"symbol"===t[0].type?o=!0:s=!0,t[0].is3D()&&"model"!==t[0].type&&(u=!0);if(this.extraShadowCaster&&!u)continue;if(!0===this.isSymbolTile&&!o)continue;if(!1===this.isSymbolTile&&!s)continue;1===r.version&&t.w(`Vector tile source "${this.source}" layer "${i}" does not use vector tile spec v2 and therefore may have some rendering errors.`);const f=a.encode(i),m=[];for(let t=0;t=e.maxzoom||"none"!==e.visibility&&(l(t,this.zoom,h.brightness,n),(d[e.id]=e.createBucket({index:c.bucketLayerIDs.length,layers:t,zoom:this.zoom,lut:this.lut,canonical:this.canonical,pixelRatio:this.pixelRatio,overscaling:this.overscaling,collisionBoxArray:this.collisionBoxArray,sourceLayerIndex:f,sourceID:this.source,projection:this.projection.spec,tessellationStep:this.tessellationStep})).populate(m,h,this.tileID.canonical,this.tileTransform),c.bucketLayerIDs.push(t.map((t=>t.id)))))}}let f,m,_,g;u.trim();const y={type:"maybePrepare",isSymbolTile:this.isSymbolTile,zoom:this.zoom},v=()=>{if(f)return this.status="done",o(f);if(this.extraShadowCaster)this.status="done",o(null,{buckets:t.dG(d).filter((t=>!t.isEmpty())),featureIndex:c,collisionBoxArray:null,glyphAtlasImage:null,lineAtlas:null,imageAtlas:null,brightness:h.brightness,glyphMap:null,iconMap:null,glyphPositions:null});else if(m&&_&&g){const e=new s(m),i=new t.dQ(_,g,this.lut);for(const r in d){const o=d[r];o instanceof t.dR?(l(o.layers,this.zoom,h.brightness,n),t.dS(o,m,e.positions,_,i.iconPositions,this.showCollisionBoxes,n,this.tileID.canonical,this.tileZoom,this.projection,this.brightness)):o.hasPattern&&(o instanceof t.dT||o instanceof t.dU||o instanceof t.b_)&&(l(o.layers,this.zoom,h.brightness,n),o.addFeatures(h,this.tileID.canonical,i.patternPositions,n,this.tileTransform,this.brightness))}this.status="done",o(null,{buckets:t.dG(d).filter((t=>!t.isEmpty())),featureIndex:c,collisionBoxArray:this.collisionBoxArray,glyphAtlasImage:e.image,lineAtlas:u,imageAtlas:i,brightness:h.brightness})}};if(!this.extraShadowCaster){const e=t.dP(h.glyphDependencies,(t=>Object.keys(t).map(Number)));Object.keys(e).length?r.send("getGlyphs",{uid:this.uid,stacks:e,scope:this.scope},((t,e)=>{f||(f=t,m=e,v())}),void 0,!1,y):m={};const i=Object.keys(h.iconDependencies);i.length?r.send("getImages",{icons:i,source:this.source,scope:this.scope,tileID:this.tileID,type:"icons"},((t,e)=>{f||(f=t,_=e,v())}),void 0,!1,y):_={};const n=Object.keys(h.patternDependencies);n.length?r.send("getImages",{icons:n,source:this.source,scope:this.scope,tileID:this.tileID,type:"patterns"},((t,e)=>{f||(f=t,g=e,v())}),void 0,!1,y):g={}}v()}}function l(e,i,n,r){const o=new t.X(i,{brightness:n});for(const t of e)t.recalculate(o,r)}class c extends t.E{constructor(e,i,n,r,o,s){super(),this.actor=e,this.layerIndex=i,this.availableImages=n,this.loadVectorData=o||t.ap,this.loading={},this.loaded={},this.deduped=new t.ao(e.scheduler),this.isSpriteLoaded=r,this.scheduler=e.scheduler,this.brightness=s}loadTile(i,n){const r=i.uid,o=i&&i.request,s=o&&o.collectResourceTiming,l=this.loading[r]=new a(i);l.abort=this.loadVectorData(i,((a,c)=>{const d=!this.loading[r];if(delete this.loading[r],d||a||!c)return l.status="done",d||(this.loaded[r]=l),n(a);const u=c.rawData,h={};c.expires&&(h.expires=c.expires),c.cacheControl&&(h.cacheControl=c.cacheControl),l.vectorTile=c.vectorTile||new t.dV(new t.dW(u));const p=()=>{l.parse(l.vectorTile,this.layerIndex,this.availableImages,this.actor,((i,r)=>{if(i||!r)return n(i);const a={};if(s){const t=e(o);t.length>0&&(a.resourceTiming=JSON.parse(JSON.stringify(t)))}n(null,t.W({rawTileData:u.slice(0)},r,h,a))}))};this.isSpriteLoaded?p():this.once("isSpriteLoaded",(()=>{this.scheduler?this.scheduler.add(p,{type:"parseTile",isSymbolTile:i.isSymbolTile,zoom:i.tileZoom}):p()})),this.loaded=this.loaded||{},this.loaded[r]=l}))}reloadTile(e,i){const n=this.loaded,r=e.uid;if(n&&n[r]){const o=n[r];o.showCollisionBoxes=e.showCollisionBoxes,o.projection=e.projection,o.brightness=e.brightness,o.tileTransform=t.dK(e.tileID.canonical,e.projection),o.extraShadowCaster=e.extraShadowCaster,o.lut=e.lut;const s=(t,e)=>{const n=o.reloadCallback;n&&(delete o.reloadCallback,o.parse(o.vectorTile,this.layerIndex,this.availableImages,this.actor,n)),i(t,e)};"parsing"===o.status?o.reloadCallback=s:"done"===o.status&&(o.vectorTile?o.parse(o.vectorTile,this.layerIndex,this.availableImages,this.actor,s):s())}else i(null,void 0)}abortTile(t,e){const i=t.uid,n=this.loading[i];n&&(n.abort&&n.abort(),delete this.loading[i]),e()}removeTile(t,e){const i=this.loaded,n=t.uid;i&&i[n]&&delete i[n],e()}}class d{loadTile(e,i){const{uid:n,encoding:r,rawImageData:o,padding:s}=e,a=ImageBitmap&&o instanceof ImageBitmap?this.getImageData(o,s):o;i(null,new t.dX(n,a,r,s{n(null,t)}),(t=>{n(t)}))}}const h=t.dZ.prototype.toGeoJSON;let p=class{constructor(e){this._feature=e,this.extent=t.a3,this.type=e.type,this.properties=e.tags,"id"in e&&!isNaN(e.id)&&(this.id=parseInt(e.id,10))}loadGeometry(){if(1===this._feature.type){const e=[];for(const i of this._feature.geometry)e.push([new t.P(i[0],i[1])]);return e}{const e=[];for(const i of this._feature.geometry){const n=[];for(const e of i)n.push(new t.P(e[0],e[1]));e.push(n)}return e}}toGeoJSON(t,e,i){return h.call(this,t,e,i)}},f=class{constructor(e){this.layers={_geojsonTileLayer:this},this.name="_geojsonTileLayer",this.extent=t.a3,this.length=e.length,this._features=e}feature(t){return new p(this._features[t])}};const m=64/4096;class _{constructor(){this.features=new Map}clear(){this.features.clear()}load(t=[],e){for(const i of t){const t=i.id;if(null==t)continue;let n=this.features.get(t);n&&this.updateCache(n,e),i.geometry?(n=y(i),this.updateCache(n,e),this.features.set(t,n)):this.features.delete(t),this.updateCache(n,e)}}updateCache(t,e){for(const{canonical:i,uid:n}of Object.values(e)){const{z:r,x:o,y:s}=i;g(t,Math.pow(2,r),o,s)&&delete e[n]}}getTile(t,e,i){const n=Math.pow(2,t),r=[];for(const t of this.features.values())g(t,n,e,i)&&r.push(w(t,n,e,i));return{features:r}}getFeatures(){return[...this.features.values()]}}function g({minX:t,minY:e,maxX:i,maxY:n},r,o,s){return t(o-m)/r&&n>(s-m)/r}function y(t){const{id:e,geometry:i,properties:n}=t;if(!i)return;if("GeometryCollection"===i.type)throw new Error("GeometryCollection not supported in dynamic mode.");const{type:r,coordinates:o}=i,s={id:e,type:1,geometry:[],tags:n,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0},a=s.geometry;if("Point"===r)v(o,a,s);else if("MultiPoint"===r)for(const t of o)v(t,a,s);else if("LineString"===r)s.type=2,x(o,a,s);else if("MultiLineString"===r)s.type=2,b(o,a,s);else if("Polygon"===r)s.type=3,b(o,a,s,!0);else{if("MultiPolygon"!==r)throw new Error("Input data is not a valid GeoJSON object.");s.type=3;for(const t of o)b(t,a,s,!0)}return s}function v([e,i],n,r){const o=t.aj(e);let s=t.ak(i);s=s1?1:s,n.push(o,s),r.minX=Math.min(r.minX,o),r.minY=Math.min(r.minY,s),r.maxX=Math.max(r.maxX,o),r.maxY=Math.max(r.maxY,s)}function x(t,e,i,n=!1,r=!1){const o=[];for(const e of t)v(e,o,i);e.push(o),n&&function(t,e){let i=0;for(let e=0,n=t.length,r=n-2;e0===e)for(let e=0,i=t.length;e>31}function F(t,e){for(var i=t.loadGeometry(),n=t.type,r=0,o=0,s=i.length,a=0;at},V=Math.fround||(G=new Float32Array(1),t=>(G[0]=+t,G[0]));var G;const Z=3,q=5,H=6;class W{constructor(t){this.options=Object.assign(Object.create(j),t),this.trees=new Array(this.options.maxZoom+1),this.stride=this.options.reduce?7:6,this.clusterProps=[]}load(t){const{log:e,minZoom:i,maxZoom:n}=this.options;e&&console.time("total time");const r=`prepare ${t.length} points`;e&&console.time(r),this.points=t;const o=[];for(let e=0;e=i;t--){const i=+Date.now();s=this.trees[t]=this._createTree(this._cluster(s,t)),e&&console.log("z%d: %d clusters in %dms",t,s.numItems,+Date.now()-i)}return e&&console.timeEnd("total time"),this}getClusters(t,e){let i=((t[0]+180)%360+360)%360-180;const n=Math.max(-90,Math.min(90,t[1]));let r=180===t[2]?180:((t[2]+180)%360+360)%360-180;const o=Math.max(-90,Math.min(90,t[3]));if(t[2]-t[0]>=360)i=-180,r=180;else if(i>r){const t=this.getClusters([i,n,180,o],e),s=this.getClusters([-180,n,r,o],e);return t.concat(s)}const s=this.trees[this._limitZoom(e)],a=s.range(K(i),J(o),K(r),J(n)),l=s.data,c=[];for(const t of a){const e=this.stride*t;c.push(l[e+q]>1?Y(l,e,this.clusterProps):this.points[l[e+Z]])}return c}getChildren(t){const e=this._getOriginId(t),i=this._getOriginZoom(t),n="No cluster with the specified id.",r=this.trees[i];if(!r)throw new Error(n);const o=r.data;if(e*this.stride>=o.length)throw new Error(n);const s=this.options.radius/(this.options.extent*Math.pow(2,i-1)),a=r.within(o[e*this.stride],o[e*this.stride+1],s),l=[];for(const e of a){const i=e*this.stride;o[i+4]===t&&l.push(o[i+q]>1?Y(o,i,this.clusterProps):this.points[o[i+Z]])}if(0===l.length)throw new Error(n);return l}getLeaves(t,e,i){const n=[];return this._appendLeaves(n,t,e=e||10,i=i||0,0),n}getTile(t,e,i){const n=this.trees[this._limitZoom(t)],r=Math.pow(2,t),{extent:o,radius:s}=this.options,a=s/o,l=(i-a)/r,c=(i+1+a)/r,d={features:[]};return this._addTileFeatures(n.range((e-a)/r,l,(e+1+a)/r,c),n.data,e,i,r,d),0===e&&this._addTileFeatures(n.range(1-a/r,l,1,c),n.data,r,i,r,d),e===r-1&&this._addTileFeatures(n.range(0,l,a/r,c),n.data,-1,i,r,d),d.features.length?d:null}getClusterExpansionZoom(t){let e=this._getOriginZoom(t)-1;for(;e1;let l,c,d;if(a)l=X(e,t,this.clusterProps),c=e[t],d=e[t+1];else{const i=this.points[e[t+Z]];l=i.properties;const[n,r]=i.geometry.coordinates;c=K(n),d=J(r)}const u={type:1,geometry:[[Math.round(this.options.extent*(c*r-i)),Math.round(this.options.extent*(d*r-n))]],tags:l};let h;h=a||this.options.generateId?e[t+Z]:this.points[e[t+Z]].id,void 0!==h&&(u.id=h),o.features.push(u)}}_limitZoom(t){return Math.max(this.options.minZoom,Math.min(Math.floor(+t),this.options.maxZoom+1))}_cluster(t,e){const{radius:i,extent:n,reduce:r,minPoints:o}=this.options,s=i/(n*Math.pow(2,e)),a=t.data,l=[],c=this.stride;for(let i=0;ie&&(p+=a[i+q])}if(p>h&&p>=o){let t,o=n*h,s=d*h,f=-1;const m=(i/c1)for(const t of u){const i=t*c;if(!(a[i+2]>5}_getOriginZoom(t){return(t-this.points.length)%32}_map(t,e,i){if(t[e+q]>1){const n=this.clusterProps[t[e+H]];return i?Object.assign({},n):n}const n=this.points[t[e+Z]].properties,r=this.options.map(n);return i&&r===n?Object.assign({},r):r}}function Y(t,e,i){return{type:"Feature",id:t[e+Z],properties:X(t,e,i),geometry:{type:"Point",coordinates:[(n=t[e],360*(n-.5)),Q(t[e+1])]}};var n}function X(t,e,i){const n=t[e+q],r=n>=1e4?`${Math.round(n/1e3)}k`:n>=1e3?Math.round(n/100)/10+"k":n,o=t[e+H],s=-1===o?{}:Object.assign({},i[o]);return Object.assign(s,{cluster:!0,cluster_id:t[e+Z],point_count:n,point_count_abbreviated:r})}function K(t){return t/360+.5}function J(t){const e=Math.sin(t*Math.PI/180),i=.5-.25*Math.log((1+e)/(1-e))/Math.PI;return i1?1:i}function Q(t){const e=(180-360*t)*Math.PI/180;return 360*Math.atan(Math.exp(e))/Math.PI-90}function tt(t,e,i,n){let r=n;const o=e+(i-e>>1);let s,a=i-e;const l=t[e],c=t[e+1],d=t[i],u=t[i+1];for(let n=e+3;n 1&&(s=t[++o]);const l=Math.abs(a-s.left),c=Math.abs(a-s.right),d=Math.min(l,c);let u;const h=e/i*(n+1);if(s.isDash){const t=n-Math.abs(h);u=Math.sqrt(d*d+t*t)}else u=n-Math.sqrt(d*d+h*h);this.image.data[r+a]=Math.max(0,Math.min(255,u+128))}}}addRegularDash(t,e){for(let e=t.length-1;e>=0;--e){const i=t[e],n=t[e+1];i.zeroLength?t.splice(e,1):n&&n.isDash===i.isDash&&(n.left=i.left,t.splice(e,1))}const i=t[0],n=t[t.length-1];i.isDash===n.isDash&&(i.left=n.left-this.width,n.right=i.right+this.width);const r=this.width*this.nextRow;let o=0,s=t[o];for(let i=0;i1&&(s=t[++o]);const n=Math.abs(i-s.left),a=Math.abs(i-s.right),l=Math.min(n,a);this.image.data[r+i]=Math.max(0,Math.min(255,(s.isDash?l:-l)+e+128))}}addDash(t,e){const i=this.getKey(t,e);if(this.positions[i])return this.positions[i];const n="round"===e,r=n?7:0,o=2*r+1;if(this.nextRow+o>this.height)return pi("LineAtlas out of space"),null;0===t.length&&t.push(1);let s=0;for(let e=0;et.fqid)),this.index=t.index,this.projection=t.projection,this.hasPattern=!1,this.hasZOffset=!1,this.patternFeatures=[],this.lineClipsArray=[],this.gradients={},this.layers.forEach((t=>{this.gradients[t.id]={}})),this.layoutVertexArray=new Rl,this.layoutVertexArray2=new Ol,this.patternVertexArray=new Bl,this.indexArray=new Kl,this.programConfigurations=new Yc(t.layers,{zoom:t.zoom,lut:t.lut}),this.segments=new wc,this.maxLineLength=0,this.zOffsetVertexArray=new Zl,this.stateDependentLayerIds=this.layers.filter((t=>t.isStateDependent())).map((t=>t.id)),this.tessellationStep=t.tessellationStep?t.tessellationStep:uo/64}updateFootprints(t,e){}populate(t,e,i,n){this.hasPattern=Hh("line",this.layers,e);const r=this.layers[0].layout.get("line-sort-key"),o=this.layers[0].layout.get("line-z-offset");this.hasZOffset=!o.isConstant()||!!o.constantOr(0);const s=[];for(const{feature:e,id:o,index:a,sourceLayerIndex:l}of t){const t=this.layers[0]._featureFilter.needGeometry,c=Zd(e,t);if(!this.layers[0]._featureFilter.filter(new Ha(this.zoom),c,i))continue;const d=r?r.evaluate(c,{},i):void 0,u={id:o,properties:e.properties,type:e.type,sourceLayerIndex:l,index:a,geometry:t?c.geometry:Gd(e,i,n),patterns:{},sortKey:d};s.push(u)}r&&s.sort(((t,e)=>t.sortKey-e.sortKey));const{lineAtlas:a,featureIndex:l}=e,c=this.addConstantDashes(a);for(const n of s){const{geometry:r,index:o,sourceLayerIndex:s}=n;if(c&&this.addFeatureDashes(n,a),this.hasPattern){const t=Wh("line",this.layers,n,this.zoom,e);this.patternFeatures.push(t)}else this.addFeature(n,r,o,i,a.positions,e.availableImages,e.brightness);l.insert(t[o].feature,r,o,s,this.index)}}addConstantDashes(t){let e=!1;for(const i of this.layers){const n=i.paint.get("line-dasharray").value,r=i.layout.get("line-cap").value;if("constant"!==n.kind||"constant"!==r.kind)e=!0;else{const e=r.value,i=n.value;if(!i)continue;t.addDash(i,e)}}return e}addFeatureDashes(t,e){const i=this.zoom;for(const n of this.layers){const r=n.paint.get("line-dasharray").value,o=n.layout.get("line-cap").value;if("constant"===r.kind&&"constant"===o.kind)continue;let s,a;if("constant"===r.kind){if(s=r.value,!s)continue}else s=r.evaluate({zoom:i},t);a="constant"===o.kind?o.value:o.evaluate({zoom:i},t),e.addDash(s,a),t.patterns[n.id]=e.getKey(s,a)}}update(t,e,i,n,r){const o=0!==Object.keys(t).length;o&&!this.stateDependentLayers.length||this.programConfigurations.updatePaintArrays(t,e,o?this.stateDependentLayers:this.layers,i,n,r)}addFeatures(t,e,i,n,r,o){for(const t of this.patternFeatures)this.addFeature(t,t.geometry,t.index,e,i,n,o)}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(t){this.uploaded||(0!==this.layoutVertexArray2.length&&(this.layoutVertexBuffer2=t.createVertexBuffer(this.layoutVertexArray2,zf)),0!==this.patternVertexArray.length&&(this.patternVertexBuffer=t.createVertexBuffer(this.patternVertexArray,Of)),!this.zOffsetVertexBuffer&&this.zOffsetVertexArray.length>0&&(this.zOffsetVertexBuffer=t.createVertexBuffer(this.zOffsetVertexArray,jf.members,!0)),this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,kf),this.indexBuffer=t.createIndexBuffer(this.indexArray)),this.programConfigurations.upload(t),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.zOffsetVertexBuffer&&this.zOffsetVertexBuffer.destroy(),this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy())}lineFeatureClips(t){if(t.properties&&t.properties.hasOwnProperty("mapbox_clip_start")&&t.properties.hasOwnProperty("mapbox_clip_end"))return{start:+t.properties.mapbox_clip_start,end:+t.properties.mapbox_clip_end}}addFeature(t,e,i,n,r,o,s){const a=this.layers[0].layout,l=a.get("line-join").evaluate(t,{}),c=a.get("line-cap").evaluate(t,{}),d=a.get("line-miter-limit"),u=a.get("line-round-limit");this.lineClips=this.lineFeatureClips(t);for(const i of e)this.addLine(i,t,n,l,c,d,u);this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,t,i,r,o,n,s)}addLine(t,e,i,n,r,o,s){this.distance=0,this.scaledDistance=0,this.totalDistance=0,this.lineSoFar=0,this.currentVertex=void 0;const a={zoom:this.zoom,lineProgress:void 0},l=this.layers[0].layout,c="none"===n;if(this.patternJoinNone=this.hasPattern&&c,this.segmentStart=0,this.segmentStartf32=0,this.segmentPoints=[],this.lineClips){this.lineClipsArray.push(this.lineClips);for(let e=0;e=2&&t[u-1].equals(t[u-2]);)u--;let h=0;for(;h0;if(A&&i>h){const t=m.dist(_);if(t>2*p){const e=m.sub(m.sub(_)._mult(p/t)._round());this.updateDistance(_,e),this.addCurrentVertex(e,y,0,0,f,x),_=e}}if(b&&"round"===w&&(Mo&&(w="bevel"),"bevel"===w&&(M>2&&(w="flipbevel"),M100)S=v.mult(-1);else{const t=M*y.add(v).mag()/y.sub(v).mag();S._perp()._mult(t*(I?-1:1))}this.addCurrentVertex(m,S,0,0,f,x),this.addCurrentVertex(m,S.mult(-1),0,0,f,x)}else if("bevel"===w||"fakeround"===w){const t=-Math.sqrt(M*M-1),e=I?t:0,i=I?0:t;if(_&&this.addCurrentVertex(m,y,e,i,f,x),"fakeround"===w){const t=Math.round(180*C/Math.PI/20);for(let e=1;e2*p){const e=m.add(g.sub(m)._mult(p/t)._round());this.updateDistance(m,e),this.addCurrentVertex(e,v,0,0,f,x),m=e}}}}addVerticesTo(t,e,i,n,r,o,s,a,l,c){const d=(e.w-t.w)/this.tessellationStep|0;if(d>1){this.lineSoFar=t.w;const u=(e.x-t.x)/d,h=(e.y-t.y)/d,p=(e.z-t.z)/d,f=(e.w-t.w)/d;for(let e=1;e=0&&this.e2>=0&&(this.indexArray.emplaceBack(this.e1,this.e2,c),a.primitiveLength++),o?this.e2=c:this.e1=c,null!=l&&this.zOffsetVertexArray.emplaceBack(l)}updateScaledDistance(){if(this.lineClips){const t=this.totalDistance/(this.lineClips.end-this.lineClips.start);this.scaledDistance=this.distance/this.totalDistance,this.lineSoFar=t*this.lineClips.start+this.distance}else this.lineSoFar=this.distance}updateDistance(t,e){this.distance+=t.dist(e),this.updateScaledDistance()}}function Qf(t,e,i){return t.xi||t.yi}ba(Jf,"LineBucket",{omit:["layers","patternFeatures","currentVertex","currentVertexIsOutside"]});const tm=new ol({"line-cap":new nl(sl.layout_line["line-cap"]),"line-join":new nl(sl.layout_line["line-join"]),"line-miter-limit":new il(sl.layout_line["line-miter-limit"]),"line-round-limit":new il(sl.layout_line["line-round-limit"]),"line-sort-key":new nl(sl.layout_line["line-sort-key"]),"line-z-offset":new nl(sl.layout_line["line-z-offset"]),visibility:new il(sl.layout_line.visibility)});var em={paint:new ol({"line-opacity":new nl(sl.paint_line["line-opacity"]),"line-color":new nl(sl.paint_line["line-color"]),"line-translate":new il(sl.paint_line["line-translate"]),"line-translate-anchor":new il(sl.paint_line["line-translate-anchor"]),"line-width":new nl(sl.paint_line["line-width"]),"line-gap-width":new nl(sl.paint_line["line-gap-width"]),"line-offset":new nl(sl.paint_line["line-offset"]),"line-blur":new nl(sl.paint_line["line-blur"]),"line-dasharray":new nl(sl.paint_line["line-dasharray"]),"line-pattern":new nl(sl.paint_line["line-pattern"]),"line-gradient":new rl(sl.paint_line["line-gradient"]),"line-trim-offset":new il(sl.paint_line["line-trim-offset"]),"line-trim-fade-range":new il(sl.paint_line["line-trim-fade-range"]),"line-trim-color":new il(sl.paint_line["line-trim-color"]),"line-emissive-strength":new il(sl.paint_line["line-emissive-strength"]),"line-border-width":new nl(sl.paint_line["line-border-width"]),"line-border-color":new nl(sl.paint_line["line-border-color"]),"line-occlusion-opacity":new il(sl.paint_line["line-occlusion-opacity"])}),layout:tm};function im(t,e,i){return e*(uo/(t.tileSize*Math.pow(2,i-t.tileID.overscaledZ)))}function nm(t,e){return 1/im(t,1,e.tileZoom)}function rm(t,e,i,n){return t.translatePosMatrix(n||e.tileID.projMatrix,e,i.paint.get("line-translate"),i.paint.get("line-translate-anchor"))}const om=t=>{const e=[];sm(t)&&e.push("RENDER_LINE_DASH"),t.paint.get("line-gradient")&&e.push("RENDER_LINE_GRADIENT");const i=t.paint.get("line-trim-offset");0===i[0]&&0===i[1]||e.push("RENDER_LINE_TRIM_OFFSET"),0!==t.paint.get("line-border-width").constantOr(1)&&e.push("RENDER_LINE_BORDER");const n="none"===t.layout.get("line-join").constantOr("miter"),r=!!t.paint.get("line-pattern").constantOr(1);return n&&r&&e.push("LINE_JOIN_NONE"),e};function sm(t){const e=t.paint.get("line-dasharray").value;return e.value||"constant"!==e.kind}class am{constructor(t){this._stringToNumber={},this._numberToString=[];for(let e=0;e>1,d=-7,u=i?r-1:0,h=i?-1:1,p=t[e+u];for(u+=h,o=p&(1>=-d,d+=a;d>0;o=256*o+t[e+u],u+=h,d-=8);for(s=o&(1>=-d,d+=n;d>0;s=256*s+t[e+u],u+=h,d-=8);if(0===o)o=1-c;else{if(o===l)return s?NaN:1/0*(p?-1:1);s+=Math.pow(2,n),o-=c}return(p?-1:1)*s*Math.pow(2,o-n)},write:function(t,e,i,n,r,o){var s,a,l,c=8*o-r-1,d=(1>1,h=23===r?Math.pow(2,-24)-Math.pow(2,-77):0,p=n?0:o-1,f=n?1:-1,m=e=1?h/l:h*Math.pow(2,1-u))*l>=2&&(s++,l/=2),s+u>=d?(a=0,s=d):s+u>=1?(a=(e*l-1)*Math.pow(2,r),s+=u):(a=e*Math.pow(2,u-1)*Math.pow(2,r),s=0));r>=8;t[i+p]=255&a,p+=f,a/=256,r-=8);for(s=s0;t[i+p]=255&s,p+=f,s/=256,c-=8);t[i+p-f]|=128*m}},cm=um,dm=lm;function um(t){this.buf=ArrayBuffer.isView&&ArrayBuffer.isView(t)?t:new Uint8Array(t||0),this.pos=0,this.type=0,this.length=this.buf.length}um.Varint=0,um.Fixed64=1,um.Bytes=2,um.Fixed32=5;var hm=4294967296,pm=1/hm,fm="undefined"==typeof TextDecoder?null:new TextDecoder("utf8");function mm(t){return t.type===um.Bytes?t.readVarint()+t.pos:t.pos+1}function _m(t,e,i){return i?4294967296*e+(t>>>0):4294967296*(e>>>0)+(t>>>0)}function gm(t,e,i){var n=e=t;r--)i.buf[r+n]=i.buf[r]}function ym(t,e){for(var i=0;i>>8,t[i+2]=e>>>16,t[i+3]=e>>>24}function Im(t,e){return(t[e]|t[e+1]>3,o=this.pos;this.type=7&n,t(r,e,this),this.pos===o&&this.skip(n)}return e},readMessage:function(t,e){return this.readFields(t,e,this.readVarint()+this.pos)},readFixed32:function(){var t=Cm(this.buf,this.pos);return this.pos+=4,t},readSFixed32:function(){var t=Im(this.buf,this.pos);return this.pos+=4,t},readFixed64:function(){var t=Cm(this.buf,this.pos)+Cm(this.buf,this.pos+4)*hm;return this.pos+=8,t},readSFixed64:function(){var t=Cm(this.buf,this.pos)+Im(this.buf,this.pos+4)*hm;return this.pos+=8,t},readFloat:function(){var t=dm.read(this.buf,this.pos,!0,23,4);return this.pos+=4,t},readDouble:function(){var t=dm.read(this.buf,this.pos,!0,52,8);return this.pos+=8,t},readVarint:function(t){var e,i,n=this.buf;return e=127&(i=n[this.pos++]),i>4,r=12&&fm?function(t,e,i){return fm.decode(t.subarray(e,i))}(this.buf,e,t):function(t,e,i){for(var n="",r=e;r239?4:l>223?3:l>191?2:1;if(r+d>i)break;1===d?l=55296&&c=1114112)&&(c=null)),null===c?(c=65533,d=1):c>65535&&(c-=65536,n+=String.fromCharCode(c>>>10&1023|55296),c=56320|1023&c),n+=String.fromCharCode(c),r+=d}return n}(this.buf,e,t)},readBytes:function(){var t=this.readVarint()+this.pos,e=this.buf.subarray(this.pos,t);return this.pos=t,e},readPackedVarint:function(t,e){if(this.type!==um.Bytes)return t.push(this.readVarint(e));var i=mm(this);for(t=t||[];this.pos127;);else if(e===um.Bytes)this.pos=this.readVarint()+this.pos;else if(e===um.Fixed32)this.pos+=4;else{if(e!==um.Fixed64)throw new Error("Unimplemented type: "+e);this.pos+=8}},writeTag:function(t,e){this.writeVarint(t268435455||t=0?(i=t%4294967296|0,n=t/4294967296|0):(n=~(-t/4294967296),4294967295^(i=~(-t%4294967296))?i=i+1|0:(i=0,n=n+1|0)),t>=0x10000000000000000||t>>=7,i.buf[i.pos++]=127&t|128,t>>>=7,i.buf[i.pos++]=127&t|128,t>>>=7,i.buf[i.pos++]=127&t|128,i.buf[i.pos]=127&(t>>>=7)}(i,0,e),function(t,e){var i=(7&t)>>=3)?128:0),t&&(e.buf[e.pos++]=127&t|((t>>>=7)?128:0),t&&(e.buf[e.pos++]=127&t|((t>>>=7)?128:0),t&&(e.buf[e.pos++]=127&t|((t>>>=7)?128:0),t&&(e.buf[e.pos++]=127&t|((t>>>=7)?128:0),t&&(e.buf[e.pos++]=127&t)))))}(n,e)}(t,this):(this.realloc(4),this.buf[this.pos++]=127&t|(t>127?128:0),t>>=7)|(t>127?128:0),t>>=7)|(t>127?128:0),t>>7&127))))},writeSVarint:function(t){this.writeVarint(t55295&&n56319||o+1===e.length?(t[i++]=239,t[i++]=191,t[i++]=189):r=n;continue}if(n>6|192:(n>12|224:(t[i++]=n>>18|240,t[i++]=n>>12&63|128),t[i++]=n>>6&63|128),t[i++]=63&n|128)}return i}(this.buf,t,this.pos);var i=this.pos-e;i>=128&&gm(e,i,this),this.pos=e-1,this.writeVarint(i),this.pos+=i},writeFloat:function(t){this.realloc(4),dm.write(this.buf,t,this.pos,!0,23,4),this.pos+=4},writeDouble:function(t){this.realloc(8),dm.write(this.buf,t,this.pos,!0,52,8),this.pos+=8},writeBytes:function(t){var e=t.length;this.writeVarint(e),this.realloc(e);for(var i=0;i=128&&gm(i,n,this),this.pos=i-1,this.writeVarint(n),this.pos+=n},writeMessage:function(t,e,i){this.writeTag(t,um.Bytes),this.writeRawMessage(e,i)},writePackedVarint:function(t,e){e.length&&this.writeMessage(t,ym,e)},writePackedSVarint:function(t,e){e.length&&this.writeMessage(t,vm,e)},writePackedBoolean:function(t,e){e.length&&this.writeMessage(t,wm,e)},writePackedFloat:function(t,e){e.length&&this.writeMessage(t,xm,e)},writePackedDouble:function(t,e){e.length&&this.writeMessage(t,bm,e)},writePackedFixed32:function(t,e){e.length&&this.writeMessage(t,Tm,e)},writePackedSFixed32:function(t,e){e.length&&this.writeMessage(t,Sm,e)},writePackedFixed64:function(t,e){e.length&&this.writeMessage(t,Em,e)},writePackedSFixed64:function(t,e){e.length&&this.writeMessage(t,Mm,e)},writeBytesField:function(t,e){this.writeTag(t,um.Bytes),this.writeBytes(e)},writeFixed32Field:function(t,e){this.writeTag(t,um.Fixed32),this.writeFixed32(e)},writeSFixed32Field:function(t,e){this.writeTag(t,um.Fixed32),this.writeSFixed32(e)},writeFixed64Field:function(t,e){this.writeTag(t,um.Fixed64),this.writeFixed64(e)},writeSFixed64Field:function(t,e){this.writeTag(t,um.Fixed64),this.writeSFixed64(e)},writeVarintField:function(t,e){this.writeTag(t,um.Varint),this.writeVarint(e)},writeSVarintField:function(t,e){this.writeTag(t,um.Varint),this.writeSVarint(e)},writeStringField:function(t,e){this.writeTag(t,um.Bytes),this.writeString(e)},writeFloatField:function(t,e){this.writeTag(t,um.Fixed32),this.writeFloat(e)},writeDoubleField:function(t,e){this.writeTag(t,um.Fixed64),this.writeDouble(e)},writeBooleanField:function(t,e){this.writeVarintField(t,Boolean(e))}};var Lm=h(cm);const Pm=["id","tile","layer","source","sourceLayer","state"];class $m{constructor(t,e,i,n,r){this.type="Feature",this._vectorTileFeature=t,this._z=e,this._x=i,this._y=n,this.properties=t.properties,this.id=r}get geometry(){return void 0===this._geometry&&(this._geometry=this._vectorTileFeature.toGeoJSON(this._x,this._y,this._z).geometry),this._geometry}set geometry(t){this._geometry=t}toJSON(){const t={type:"Feature",state:void 0,geometry:this.geometry,properties:this.properties};for(const e of Pm)void 0!==this[e]&&(t[e]=this[e]);return t}}class km{constructor(){this.state={},this.stateChanges={},this.deletedStates={}}updateState(t,e,i){const n=String(e);if(this.stateChanges[t]=this.stateChanges[t]||{},this.stateChanges[t][n]=this.stateChanges[t][n]||{},ei(this.stateChanges[t][n],i),null===this.deletedStates[t]){this.deletedStates[t]={};for(const e in this.state[t])e!==n&&(this.deletedStates[t][e]=null)}else if(this.deletedStates[t]&&null===this.deletedStates[t][n]){this.deletedStates[t][n]={};for(const e in this.state[t][n])i[e]||(this.deletedStates[t][n][e]=null)}else for(const e in i)this.deletedStates[t]&&this.deletedStates[t][n]&&null===this.deletedStates[t][n][e]&&delete this.deletedStates[t][n][e]}removeFeatureState(t,e,i){if(null===this.deletedStates[t])return;const n=String(e);if(this.deletedStates[t]=this.deletedStates[t]||{},i&&void 0!==e)null!==this.deletedStates[t][n]&&(this.deletedStates[t][n]=this.deletedStates[t][n]||{},this.deletedStates[t][n][i]=null);else if(void 0!==e)if(this.stateChanges[t]&&this.stateChanges[t][n])for(i in this.deletedStates[t][n]={},this.stateChanges[t][n])this.deletedStates[t][n][i]=null;else this.deletedStates[t][n]=null;else this.deletedStates[t]=null}getState(t,e){const i=String(e),n=ei({},(this.state[t]||{})[i],(this.stateChanges[t]||{})[i]);if(null===this.deletedStates[t])return{};if(this.deletedStates[t]){const i=this.deletedStates[t][e];if(null===i)return{};for(const t in i)delete n[t]}return n}initializeTileState(t,e){t.setFeatureState(this.state,e)}coalesceChanges(t,e){const i={};for(const t in this.stateChanges){this.state[t]=this.state[t]||{};const e={};for(const i in this.stateChanges[t])this.state[t][i]||(this.state[t][i]={}),ei(this.state[t][i],this.stateChanges[t][i]),e[i]=this.state[t][i];i[t]=e}for(const t in this.deletedStates){this.state[t]=this.state[t]||{};const e={};if(null===this.deletedStates[t])for(const i in this.state[t])e[i]={},this.state[t][i]={};else for(const i in this.deletedStates[t]){if(null===this.deletedStates[t][i])this.state[t][i]={};else if(this.state[t][i])for(const e of Object.keys(this.deletedStates[t][i]))delete this.state[t][i][e];e[i]=this.state[t][i]}i[t]=i[t]||{},ei(i[t],e)}if(this.stateChanges={},this.deletedStates={},0!==Object.keys(i).length)for(const n in t)t[n].setFeatureState(i,e)}}class Dm{constructor(t,e){this.tileID=t,this.x=t.canonical.x,this.y=t.canonical.y,this.z=t.canonical.z,this.grid=new va(uo,16,0),this.featureIndexArray=new yc,this.promoteId=e,this.is3DTile=!1}insert(t,e,i,n,r,o=0,s=0){const a=this.featureIndexArray.length;this.featureIndexArray.emplaceBack(i,n,r,o);const l=this.grid;for(let t=0;t=0&&n[3]>=0&&l.insert(a,n[0],n[1],n[2],n[3])}}loadVTLayers(){if(!this.vtLayers){this.vtLayers=new bp(new Lm(this.rawTileData)).layers,this.sourceLayerCoder=new am(this.vtLayers?Object.keys(this.vtLayers).sort():["_geojsonTileLayer"]),this.vtFeatures={};for(const t in this.vtLayers)this.vtFeatures[t]=[]}return this.vtLayers}query(t,e,i,n){this.loadVTLayers();const r=t.params||{},o=dl(r.filter),s=t.tileResult,a=t.transform,l=s.bufferedTilespaceBounds,c=this.grid.query(l.min.x,l.min.y,l.max.x,l.max.y,((t,e,i,n)=>ou(s.bufferedTilespaceGeometry,t,e,i,n)));c.sort(Rm);let d=null;a.elevation&&c.length>0&&(d=Xp.create(a.elevation,this.tileID));const u={};let h;for(let l=0;l(m||(m=Gd(e,this.tileID.canonical,t.tileTransform)),i.queryIntersectsFeature(s,e,n,m,this.z,t.transform,t.pixelPosMatrix,d,r))))}return u}loadMatchingFeature(t,e,i,n,r,o,s,a,l){const{featureIndex:c,bucketIndex:d,sourceLayerIndex:u,layoutVertexArrayOffset:h}=e,p=this.bucketLayerIDs[d];if(n&&!function(t,e){for(let i=0;i=0)return!0;return!1}(n,p))return;const f=this.sourceLayerCoder.decode(u),m=this.vtLayers[f].feature(c);if(i.needGeometry){const t=Zd(m,!0);if(!i.filter(new Ha(this.tileID.overscaledZ),t,this.tileID.canonical))return}else if(!i.filter(new Ha(this.tileID.overscaledZ),m))return;const _=this.getId(m,f);for(let e=0;e{const s=e instanceof el?e.get(o):null;return s&&s.evaluate?s.evaluate(i,n,r):s}))}function Rm(t,e){return e-t}ba(Dm,"FeatureIndex",{omit:["rawTileData","sourceLayerCoder"]});var Om=24;const Bm=128;function Fm(t,e){const{expression:i}=e;if("constant"===i.kind)return{kind:"constant",layoutSize:i.evaluate(new Ha(t+1))};if("source"===i.kind)return{kind:"source"};{const{zoomStops:e,interpolationType:n}=i;let r=0;for(;r{t.text=function(t,e,i){const n=e.layout.get("text-transform").evaluate(i,{});return"uppercase"===n?t=t.toLocaleUpperCase():"lowercase"===n&&(t=t.toLocaleLowerCase()),qa.applyArabicShaping&&(t=qa.applyArabicShaping(t)),t}(t.text,e,i)})),t}const Gm={"!":"︕","#":"#",$:"$","%":"%","&":"&","(":"︵",")":"︶","*":"*","+":"+",",":"︐","-":"︲",".":"・","/":"/",":":"︓",";":"︔","":"﹀","?":"︖","@":"@","[":"﹇","\\":"\","]":"﹈","^":"^",_:"︳","`":"`","{":"︷","|":"―","}":"︸","~":"~","¢":"¢","£":"£","¥":"¥","¦":"¦","¬":"¬","¯":" ̄","–":"︲","—":"︱","‘":"﹃","’":"﹄","“":"﹁","”":"﹂","…":"︙","‧":"・","₩":"₩","、":"︑","。":"︒","〈":"︿","〉":"﹀","《":"︽","》":"︾","「":"﹁","」":"﹂","『":"﹃","』":"﹄","【":"︻","】":"︼","〔":"︹","〕":"︺","〖":"︗","〗":"︘","!":"︕","(":"︵",")":"︶",",":"︐","-":"︲",".":"・",":":"︓",";":"︔","<":"︿",">":"﹀","?":"︖","[":"﹇","]":"﹈","_":"︳","{":"︷","|":"―","}":"︸","⦅":"︵","⦆":"︶","。":"︒","「":"﹁","」":"﹂","←":"↑","→":"↓"};function Zm(t){return"︶"===t||"﹈"===t||"︸"===t||"﹄"===t||"﹂"===t||"︾"===t||"︼"===t||"︺"===t||"︘"===t||"﹀"===t||"︐"===t||"︓"===t||"︔"===t||"`"===t||" ̄"===t||"︑"===t||"︒"===t}function qm(t){return"︵"===t||"﹇"===t||"︷"===t||"﹃"===t||"﹁"===t||"︽"===t||"︻"===t||"︹"===t||"︗"===t||"︿"===t}const Hm=3;function Wm(t,e,i){e.glyphs=[],1===t&&i.readMessage(Ym,e)}function Ym(t,e,i){if(3===t){const{id:t,bitmap:n,width:r,height:o,left:s,top:a,advance:l}=i.readMessage(Xm,{});e.glyphs.push({id:t,bitmap:new dh({width:r+2*Hm,height:o+2*Hm},n),metrics:{width:r,height:o,left:s,top:a,advance:l}})}else 4===t?e.ascender=i.readSVarint():5===t&&(e.descender=i.readSVarint())}function Xm(t,e,i){1===t?e.id=i.readVarint():2===t?e.bitmap=i.readBytes():3===t?e.width=i.readVarint():4===t?e.height=i.readVarint():5===t?e.left=i.readSVarint():6===t?e.top=i.readSVarint():7===t&&(e.advance=i.readVarint())}const Km=Hm,Jm={horizontal:1,vertical:2,horizontalOnly:3};class Qm{constructor(){this.scale=1,this.fontStack="",this.imageName=null}static forText(t,e){const i=new Qm;return i.scale=t||1,i.fontStack=e,i}static forImage(t){const e=new Qm;return e.imageName=t,e}}class t_{constructor(){this.text="",this.sectionIndex=[],this.sections=[],this.imageSectionID=null}static fromFeature(t,e){const i=new t_;for(let n=0;n=0&&i>=t&&i_[this.text.charCodeAt(i)];i--)e--;this.text=this.text.substring(t,e),this.sectionIndex=this.sectionIndex.slice(t,e)}substring(t,e){const i=new t_;return i.text=this.text.substring(t,e),i.sectionIndex=this.sectionIndex.slice(t,e),i.sections=this.sections,i}toString(){return this.text}getMaxScale(){return this.sectionIndex.reduce(((t,e)=>Math.max(t,this.sections[e].scale)),0)}addTextSection(t,e){this.text+=t.text,this.sections.push(Qm.forText(t.scale,t.fontStack||e));const i=this.sections.length-1;for(let e=0;e=63743?null:++this.imageSectionID:(this.imageSectionID=57344,this.imageSectionID)}}function e_(t,e,i,n,r,o,s,a,l,c,d,u,h,p,f){const m=t_.fromFeature(t,r);u===Jm.vertical&&m.verticalizePunctuation(h);let _=[];const g=function(t,e,i,n,r,o){if(!t)return[];const s=[],a=function(t,e,i,n,r,o){let s=0;for(let i=0;i=0;let c=0;for(let i=0;i0&&o>b&&(b=o)}else{const t=i[a.fontStack];if(!t)continue;t[m]&&(S=t[m]);const n=e[a.fontStack];if(!n)continue;const o=n.glyphs[m];if(!o)continue;if(v=o.metrics,M=8203!==m?Om:0,_){const t=void 0!==n.ascender?Math.abs(n.ascender):0,e=void 0!==n.descender?Math.abs(n.descender):0,i=(t+e)*g;w-i/2;){if(s--,sn;)c-=l.shift().angleDelta;if(c>r)return!1;s++,a+=e.dist(i)}return!0}function m_(t){let e=0;for(let i=0;ic){const d=(c-l)/o,u=Vn(n.x,r.x,d),h=Vn(n.y,r.y,d),p=new p_(u,h,0,r.angleTo(n),i);return!s||f_(t,p,a,s,e)?p:void 0}l+=o}}function v_(t,e,i,n,r,o,s,a,l){const c=__(n,o,s),d=g_(n,r),u=d*s,h=0===t[0].x||t[0].x===l||0===t[0].y||t[0].y===l;return e-u=0&&g=0&&y=0&&h+c=n&&c.x>=n||(s.x>=n?s=new Ue(n,s.y+(n-s.x)/(c.x-s.x)*(c.y-s.y))._round():c.x>=n&&(c=new Ue(n,s.y+(n-s.x)/(c.x-s.x)*(c.y-s.y))._round()),s.y>=r&&c.y>=r||(s.y>=r?s=new Ue(s.x+(r-s.y)/(c.y-s.y)*(c.x-s.x),r)._round():c.y>=r&&(c=new Ue(s.x+(r-s.y)/(c.y-s.y)*(c.x-s.x),r)._round()),l&&s.equals(l[l.length-1])||(l=[s],o.push(l)),l.push(c)))))}}return o}function w_(t){let e=0,i=0;for(const n of t)e+=n.w*n.h,i=Math.max(i,n.w);t.sort(((t,e)=>e.h-t.h));const n=[{x:0,y:0,w:Math.max(Math.ceil(Math.sqrt(e/.95)),i),h:1/0}];let r=0,o=0;for(const e of t)for(let t=n.length-1;t>=0;t--){const i=n[t];if(!(e.w>i.w||e.h>i.h)){if(e.x=i.x,e.y=i.y,o=Math.max(o,e.y+e.h),r=Math.max(r,e.x+e.w),e.w===i.w&&e.h===i.h){const e=n.pop();tt.hasImage(e,i))),t.dispatchRenderCallbacks(this.haveRenderCallbacks,i);for(const n in t.getUpdatedImages(i))this.patchUpdatedImage(this.iconPositions[n],t.getImage(n,i),e),this.patchUpdatedImage(this.patternPositions[n],t.getImage(n,i),e)}patchUpdatedImage(t,e,i){if(!t||!e)return;if(t.version===e.version)return;t.version=e.version;const[n,r]=t.tl,o=!!Object.keys(this.patternPositions).length;i.update(e.data,{useMipmap:o},{x:n,y:r})}}ba(S_,"ImagePosition"),ba(E_,"ImageAtlas");const M_=1e20;function C_(t,e,i,n,r,o,s,a,l){for(let c=e;c-1);l++,o[l]=a,s[l]=c,s[l+1]=M_}for(let a=0,l=0;a{let n=this.entries[t];n||(n=this.entries[t]={glyphs:{},requests:{},ranges:{},ascender:void 0,descender:void 0});let r=n.glyphs[e];if(void 0!==r)return void i(null,{stack:t,id:e,glyph:r});if(r=this._tinySDF(n,t,e),r)return n.glyphs[e]=r,void i(null,{stack:t,id:e,glyph:r});const s=Math.floor(e/256);if(256*s>65535)return void i(new Error("glyphs > 65535 not supported"));if(n.ranges[s])return void i(null,{stack:t,id:e,glyph:r});let a=n.requests[s];a||(a=n.requests[s]=[],P_.loadGlyphRange(t,s,o,this.requestManager,((t,e)=>{if(e){n.ascender=e.ascender,n.descender=e.descender;for(const t in e.glyphs)this._doesCharSupportLocalGlyph(+t)||(n.glyphs[+t]=e.glyphs[+t]);n.ranges[s]=!0}for(const i of a)i(t,e);delete n.requests[s]}))),a.push(((n,r)=>{n?i(n):r&&i(null,{stack:t,id:e,glyph:r.glyphs[e]||null})}))}),((t,e)=>{if(t)i(t);else if(e){const t={};for(const{stack:i,id:n,glyph:r}of e)void 0===t[i]&&(t[i]={}),void 0===t[i].glyphs&&(t[i].glyphs={}),t[i].glyphs[n]=r&&{id:r.id,bitmap:r.bitmap.clone(),metrics:r.metrics},t[i].ascender=this.entries[i].ascender,t[i].descender=this.entries[i].descender;i(null,t)}}))}_doesCharSupportLocalGlyph(t){return this.localGlyphMode!==L_.none&&(this.localGlyphMode===L_.all?!!this.localFontFamily:!!this.localFontFamily&&(Ma["CJK Unified Ideographs"](t)||Ma["Hangul Syllables"](t)||Ma.Hiragana(t)||Ma.Katakana(t)||Ma["CJK Symbols and Punctuation"](t)||Ma["CJK Unified Ideographs Extension A"](t)||Ma["CJK Unified Ideographs Extension B"](t)))}_tinySDF(t,e,i){const n=this.localFontFamily;if(!n||!this._doesCharSupportLocalGlyph(i))return;let r=t.tinySDF;if(!r){let i="400";/bold/i.test(e)?i="900":/medium/i.test(e)?i="500":/light/i.test(e)&&(i="200"),r=t.tinySDF=new P_.TinySDF({fontFamily:n,fontWeight:i,fontSize:24*I_,buffer:3*I_,radius:8*I_}),r.fontWeight=i}if(this.localGlyphs[r.fontWeight][i])return this.localGlyphs[r.fontWeight][i];const o=String.fromCodePoint(i),{data:s,width:a,height:l,glyphWidth:c,glyphHeight:d,glyphLeft:u,glyphTop:h,glyphAdvance:p}=r.draw(o);return this.localGlyphs[r.fontWeight][i]={id:i,bitmap:new dh({width:a,height:l},s),metrics:{width:c/I_,height:d/I_,left:u/I_,top:h/I_-27,advance:p/I_,localGlyph:!0}}}}P_.loadGlyphRange=function(t,e,i,n,r){const o=256*e,s=o+255,a=n.transformRequest(n.normalizeGlyphsURL(i).replace("{fontstack}",t).replace("{range}",`${o}-${s}`),Ki.Glyphs);en(a,((t,e)=>{if(t)r(t);else if(e){const t={},i=function(t){return new Lm(t).readFields(Wm,{})}(e);for(const e of i.glyphs)t[e.id]=e;r(null,{glyphs:t,ascender:i.ascender,descender:i.descender})}}))},P_.TinySDF=class{constructor({fontSize:t=24,buffer:e=3,radius:i=8,cutoff:n=.25,fontFamily:r="sans-serif",fontWeight:o="normal",fontStyle:s="normal"}={}){this.buffer=e,this.cutoff=n,this.radius=i;const a=this.size=t+4*e,l=this._createCanvas(a),c=this.ctx=l.getContext("2d",{willReadFrequently:!0});c.font=`${s} ${o} ${t}px ${r}`,c.textBaseline="alphabetic",c.textAlign="left",c.fillStyle="black",this.gridOuter=new Float64Array(a*a),this.gridInner=new Float64Array(a*a),this.f=new Float64Array(a),this.z=new Float64Array(a+1),this.v=new Uint16Array(a)}_createCanvas(t){const e=document.createElement("canvas");return e.width=e.height=t,e}draw(t){const{width:e,actualBoundingBoxAscent:i,actualBoundingBoxDescent:n,actualBoundingBoxLeft:r,actualBoundingBoxRight:o}=this.ctx.measureText(t),s=Math.ceil(i),a=Math.max(0,Math.min(this.size-this.buffer,Math.ceil(o-r))),l=Math.min(this.size-this.buffer,s+Math.ceil(n)),c=a+2*this.buffer,d=l+2*this.buffer,u=Math.max(c*d,0),h=new Uint8ClampedArray(u),p={data:h,width:c,height:d,glyphWidth:a,glyphHeight:l,glyphTop:s,glyphLeft:0,glyphAdvance:e};if(0===a||0===l)return p;const{ctx:f,buffer:m,gridInner:_,gridOuter:g}=this;f.clearRect(m,m,a,l),f.fillText(t,m,m+s);const y=f.getImageData(m,m,a,l);g.fill(M_,0,u),_.fill(0,0,u);for(let t=0;t0?t*t:0,_[n]=tt+e[1]-e[0],f=u.reduce(p,0),m=h.reduce(p,0),_=a-f,g=l-m;let y=0,v=f,x=0,b=m,w=0,T=_,S=0,E=g;if(o.content&&n){const t=o.content;y=D_(u,0,t[0]),x=D_(h,0,t[1]),v=D_(u,t[0],t[2]),b=D_(h,t[1],t[3]),w=t[0]-y,S=t[1]-x,T=t[2]-t[0]-v,E=t[3]-t[1]-b}const M=(n,r,a,l)=>{const u=R_(n.stretch-y,v,c,t.left),h=O_(n.fixed-w,T,n.stretch,f),p=R_(r.stretch-x,b,d,t.top),_=O_(r.fixed-S,E,r.stretch,m),g=R_(a.stretch-y,v,c,t.left),M=O_(a.fixed-w,T,a.stretch,f),C=R_(l.stretch-x,b,d,t.top),A=O_(l.fixed-S,E,l.stretch,m),I=new Ue(u,p),L=new Ue(g,p),P=new Ue(g,C),$=new Ue(u,C),k=new Ue(h/s,_/s),D=new Ue(M/s,A/s),z=e*Math.PI/180;if(z){const t=Math.sin(z),e=Math.cos(z),i=[e,-t,t,e];I._matMult(i),L._matMult(i),$._matMult(i),P._matMult(i)}const R=n.stretch+n.fixed,O=a.stretch+a.fixed,B=r.stretch+r.fixed,F=l.stretch+l.fixed,N=t.imageSecondary;return{tl:I,tr:L,bl:$,br:P,texPrimary:{x:o.paddedRect.x+$_+R,y:o.paddedRect.y+$_+B,w:O-R,h:F-B},texSecondary:N?{x:N.paddedRect.x+$_+R,y:N.paddedRect.y+$_+B,w:O-R,h:F-B}:void 0,writingMode:void 0,glyphOffset:[0,0],sectionIndex:0,pixelOffsetTL:k,pixelOffsetBR:D,minFontScaleX:T/s/c,minFontScaleY:E/s/d,isSDF:i}};if(n&&(o.stretchX||o.stretchY)){const t=z_(u,_,f),e=z_(h,g,m);for(let i=0;io)&&(o=e.x),(!t||e.y>s)&&(s=e.y)}const l=Math.min(o-n,s-r);let c=l/2;const d=new co([],N_);if(0===l)return new Ue(n,r);for(let e=n;eu.d||!u.d)&&(u=n,i&&console.log("found best %d after %d probes",Math.round(1e4*n.d)/1e4,h)),n.max-u.dt.y!=a.y>t.y&&t.x18&&P>2&&(P>>=1),Math.max(uo/(512*P),1)*_.get("symbol-spacing")),S=_.get("text-padding")*t.tilePixelRatio,E=_.get("icon-padding")*t.tilePixelRatio,M=Ge(_.get("text-max-angle")),C="map"===_.get("text-rotation-alignment")&&"point"!==_.get("symbol-placement"),A="map"===_.get("icon-rotation-alignment")&&"point"!==_.get("symbol-placement"),I=_.get("symbol-placement"),L=T/2;var P;const $=_.get("icon-text-fit").evaluate(e,{},u),k=_.get("icon-text-fit-padding").evaluate(e,{},u),D="none"!==$;let z;!1===t.hasAnyIconTextFit&&D&&(t.hasAnyIconTextFit=!0),n&&D&&(t.allowVerticalPlacement&&i.vertical&&(z=h_(n,i.vertical,$,k,g,b)),y&&(n=h_(n,y,$,k,g,b)));const R=(s,a,m)=>{if(a.x=uo||a.y=uo)return;let _=null;if(v){const{x:t,y:e,z:i}=h.projectTilePoint(a.x,a.y,m);_={anchor:new p_(t,e,i,0,void 0),up:h.upVector(m,a.x,a.y)}}!function(t,e,i,n,r,o,s,a,l,c,d,u,h,p,f,m,_,g,y,v,x,b,w,T,S,E,M){const C=t.addToLineVertexArray(e,n);let A,I,L,P,$,k,D,z=0,R=0,O=0,B=0,F=-1,N=-1;const U={};let j=Ln("");const V=i?i.anchor:e,G="none"!==l.layout.get("icon-text-fit").evaluate(x,{},S);let Z=0,q=0;if(void 0===l._unevaluatedLayout.getValue("text-radial-offset")?[Z,q]=l.layout.get("text-offset").evaluate(x,{},S).map((t=>t*Om)):(Z=l.layout.get("text-radial-offset").evaluate(x,{},S)*Om,q=j_),t.allowVerticalPlacement&&r.vertical){const t=r.vertical;if(f)k=J_(t),a&&(D=J_(a));else{const i=l.layout.get("text-rotate").evaluate(x,{},S)+90;L=K_(c,V,e,d,u,h,t,p,i,m),a&&(P=K_(c,V,e,d,u,h,a,g,i))}}if(o){const n=l.layout.get("icon-rotate").evaluate(x,{},S),r=k_(o,n,w,G),s=a?k_(a,n,w,G):void 0;I=K_(c,V,e,d,u,h,o,g,n),z=4*r.length;const p=t.iconSizeData;let f=null;"source"===p.kind?(f=[Bm*l.layout.get("icon-size").evaluate(x,{},S)],f[0]>W_&&pi(`${t.layerIds[0]}: Value for "icon-size" is >= ${H_}. Reduce your "icon-size".`)):"composite"===p.kind&&(f=[Bm*b.compositeIconSizes[0].evaluate(x,{},S),Bm*b.compositeIconSizes[1].evaluate(x,{},S)],(f[0]>W_||f[1]>W_)&&pi(`${t.layerIds[0]}: Value for "icon-size" is >= ${H_}. Reduce your "icon-size".`)),t.addSymbols(t.icon,r,f,v,y,x,!1,i,e,C.lineStartIndex,C.lineLength,-1,T,S,E,M),F=t.icon.placedSymbolArray.length-1,s&&(R=4*s.length,t.addSymbols(t.icon,s,f,v,y,x,Jm.vertical,i,e,C.lineStartIndex,C.lineLength,-1,T,S,E,M),N=t.icon.placedSymbolArray.length-1)}for(const n in r.horizontal){const o=r.horizontal[n];A||(j=Ln(o.text),f?$=J_(o):A=K_(c,V,e,d,u,h,o,p,l.layout.get("text-rotate").evaluate(x,{},S),m));const a=1===o.positionedLines.length;if(O+=Y_(t,i,e,o,s,l,f,x,m,C,r.vertical?Jm.horizontal:Jm.horizontalOnly,a?Object.keys(r.horizontal):[n],U,F,b,T,S,E),a)break}r.vertical&&(B+=Y_(t,i,e,r.vertical,s,l,f,x,m,C,Jm.vertical,["vertical"],U,N,b,T,S,E));let H=-1;const W=(t,e)=>t?Math.max(t,e):e;H=W($,H),H=W(k,H),H=W(D,H);const Y=H>-1?1:0;t.glyphOffsetArray.length>=65535&&pi("Too many glyphs being rendered in a tile. See https://github.com/mapbox/mapbox-gl-js/issues/2907"),void 0!==x.sortKey&&t.addToSortKeyRanges(t.symbolInstances.length,x.sortKey),t.symbolInstances.emplaceBack(e.x,e.y,V.x,V.y,V.z,U.right>=0?U.right:-1,U.center>=0?U.center:-1,U.left>=0?U.left:-1,U.vertical>=0?U.vertical:-1,F,N,j,void 0!==A?A:t.collisionBoxArray.length,void 0!==A?A+1:t.collisionBoxArray.length,void 0!==L?L:t.collisionBoxArray.length,void 0!==L?L+1:t.collisionBoxArray.length,void 0!==I?I:t.collisionBoxArray.length,void 0!==I?I+1:t.collisionBoxArray.length,P||t.collisionBoxArray.length,P?P+1:t.collisionBoxArray.length,d,O,B,z,R,Y,0,Z,q,H,0,1,1,G?1:0)}(t,a,_,s,i,n,r,z,t.layers[0],t.collisionBoxArray,e.index,e.sourceLayerIndex,t.index,S,C,l,0,E,A,g,e,o,c,d,u,p,f)};if("line"===I)for(const r of b_(e.geometry,0,0,uo,uo)){const e=v_(r,T,M,i.vertical||y,n,x,w,t.overscaling,uo);for(const i of e)y&&Q_(t,y.text,L,i)||R(r,i,u)}else if("line-center"===I){for(const t of e.geometry)if(t.length>1){const e=y_(t,M,i.vertical||y,n,x,w);e&&R(t,e,u)}}else if("Polygon"===e.type)for(const t of Zh(e.geometry,0)){const e=F_(t,16);R(t[0],new p_(e.x,e.y,0,0,void 0),u)}else if("LineString"===e.type)for(const t of e.geometry)R(t,new p_(t[0].x,t[0].y,0,0,void 0),u);else if("Point"===e.type)for(const t of e.geometry)for(const e of t)R([e],new p_(e.x,e.y,0,0,void 0),u)}const H_=255,W_=H_*Bm;function Y_(t,e,i,n,r,o,s,a,l,c,d,u,h,p,f,m,_,g){const y=function(t,e,i,n,r,o,s,a){const l=[];if(0===e.positionedLines.length)return l;const c=n.layout.get("text-rotate").evaluate(o,{})*Math.PI/180,d=function(t){const e=t[0],i=t[1],n=e*i;return n>0?[e,-i]:nW_&&pi(`${t.layerIds[0]}: Value for "text-size" is >= ${H_}. Reduce your "text-size".`)):"composite"===v.kind&&(x=[Bm*f.compositeTextSizes[0].evaluate(a,{},_),Bm*f.compositeTextSizes[1].evaluate(a,{},_)],(x[0]>W_||x[1]>W_)&&pi(`${t.layerIds[0]}: Value for "text-size" is >= ${H_}. Reduce your "text-size".`)),t.addSymbols(t.text,y,x,l,s,a,d,e,i,c.lineStartIndex,c.lineLength,p,m,_,g,!1);for(const e of u)h[e]=t.text.placedSymbolArray.length-1;return 4*y.length}function X_(t){for(const e in t)return t[e];return null}function K_(t,e,i,n,r,o,s,a,l,c){let d=s.top,u=s.bottom,h=s.left,p=s.right;const f=s.collisionPadding;if(f&&(h-=f[0],d-=f[1],p+=f[2],u+=f[3]),l){const t=new Ue(h,d),e=new Ue(p,d),i=new Ue(h,u),n=new Ue(p,u),r=Ge(l);let o=new Ue(0,0);c&&(o=new Ue(c[0],c[1])),t._rotateAround(r,o),e._rotateAround(r,o),i._rotateAround(r,o),n._rotateAround(r,o),h=Math.min(t.x,e.x,i.x,n.x),p=Math.max(t.x,e.x,i.x,n.x),d=Math.min(t.y,e.y,i.y,n.y),u=Math.max(t.y,e.y,i.y,n.y)}return t.emplaceBack(e.x,e.y,e.z,i.x,i.y,h,d,p,u,a,n,r,o),t.length-1}function J_(t){t.collisionPadding&&(t.top-=t.collisionPadding[1],t.bottom+=t.collisionPadding[3]);const e=t.bottom-t.top;return e>0?Math.max(10,e):null}function Q_(t,e,i,n){const r=t.compareText;if(e in r){const t=r[e];for(let e=t.length-1;e>=0;e--)if(n.dist(t[e])v&&(x(t,c,n,r,a,l),x(c,i,a,l,o,s))}x(u,h,n,o,r,o),x(h,p,r,o,r,s),x(p,f,r,s,n,s),x(f,u,n,s,n,o),m-=v,_-=v,g+=v,y+=v;const b=1/Math.max(g-m,y-_);return{scale:b,x:m*b,y:_*b,x2:g*b,y2:y*b,projection:e}}function ig(t,{x:e,y:i},n=0){return new Ue(((e-n)*t.scale-t.x)*uo,(i*t.scale-t.y)*uo)}const ng=t.ad.identity(new Float32Array(16));class rg{constructor(t){this.spec=t,this.name=t.name,this.wrap=!1,this.requiresDraping=!1,this.supportsWorldCopies=!1,this.supportsTerrain=!1,this.supportsFog=!1,this.supportsFreeCamera=!1,this.zAxisUnit="meters",this.isReprojectedInTileSpace=!0,this.unsupportedLayers=["custom"],this.center=[0,0],this.range=[3.5,7]}project(t,e){return{x:0,y:0,z:0}}unproject(t,e){return new pd(0,0)}projectTilePoint(t,e,i){return{x:t,y:e,z:0}}locationPoint(t,e,i=!0){return t._coordinatePoint(t.locationCoordinate(e),i)}pixelsPerMeter(t,e){return Cd(1,t)*e}pixelSpaceConversion(t,e,i){return 1}farthestPixelDistance(t){return tg(t,t.pixelsPerMeter)}pointCoordinate(t,e,i,n){const r=t.horizonLineFromTop(!1),o=new Ue(e,Math.max(r,i));return t.rayIntersectionCoordinate(t.pointRayIntersection(o,n))}pointCoordinate3D(t,e,i){const n=new Ue(e,i);if(t.elevation)return t.elevation.pointCoordinate(n);{const e=this.pointCoordinate(t,n.x,n.y,0);return[e.x,e.y,e.z]}}isPointAboveHorizon(t,e){if(t.elevation&&t.elevation.visibleDemTiles.length)return!this.pointCoordinate3D(t,e.x,e.y);const i=t.horizonLineFromTop();return e.y0?epg-i&&(e=pg-i);const o=r/Math.pow(fg(e),n);let s=o*Math.sin(n*t),a=r-o*Math.cos(n*t);return s=.5*(s/Math.PI+.5),a=.5*(a/Math.PI+.5),{x:s,y:this.southernCenter?a:1-a,z:0}}unproject(t,e){t=(2*t-.5)*Math.PI,this.southernCenter&&(e=1-e),e=(2*(1-e)-.5)*Math.PI;const{n:i,f:n}=this,r=n-e,o=Math.sign(r),s=Math.sign(i)*Math.sqrt(t*t+r*r);let a=Math.atan2(t,Math.abs(r))*o;r*i1e-6&&--n>0);o=i*i;const s=Xe(Ze(t/(.8707+o*(o*(o*o*o*(.003971-.001529*o)-.013791)-.131979))),-180,180),a=Ze(i);return new pd(s,a)}}const vg=Ge(Pd);class xg extends rg{project(t,e){e=Ge(e),t=Ge(t);const i=Math.cos(e),n=2/Math.PI,r=Math.acos(i*Math.cos(t/2)),o=Math.sin(r)/r,s=.5*(t*n+2*i*Math.sin(t/2)/o)||0,a=.5*(e+Math.sin(e)/o)||0;return{x:.5*(s/Math.PI+.5),y:1-.5*(a/Math.PI+1),z:0}}unproject(t,e){let i=t=(2*t-.5)*Math.PI,n=e=(2*(1-e)-1)*Math.PI,r=25;const o=1e-6;let s=0,a=0;do{const r=Math.cos(n),o=Math.sin(n),l=2*o*r,c=o*o,d=r*r,u=Math.cos(i/2),h=Math.sin(i/2),p=2*u*h,f=h*h,m=1-d*u*u,_=m?1/m:0,g=m?Math.acos(r*u)*Math.sqrt(1/m):0,y=.5*(2*g*r*h+2*i/Math.PI)-t,v=.5*(g*o+n)-e,x=.5*_*(d*f+g*r*u*c)+1/Math.PI,b=_*(p*l/4-g*o*h),w=.125*_*(l*h-g*o*d*p),T=.5*_*(c*u+g*f*r)+.5,S=b*w-T*x;s=(v*b-y*T)/S,a=(y*w-v*x)/S,i=Xe(i-s,-Math.PI,Math.PI),n=Xe(n-a,-vg,vg)}while((Math.abs(s)>o||Math.abs(a)>o)&&--r>0);return new pd(Ze(i),Ze(n))}}class bg extends rg{constructor(t){super(t),this.center=t.center||[0,0],this.parallels=t.parallels||[0,0],this.cosPhi=Math.max(.01,Math.cos(Ge(this.parallels[0]))),this.scale=1/(2*Math.max(Math.PI*this.cosPhi,1/this.cosPhi)),this.wrap=!0,this.supportsWorldCopies=!0}project(t,e){const{scale:i,cosPhi:n}=this;return{x:Ge(t)*n*i+.5,y:-Math.sin(Ge(e))/n*i+.5,z:0}}unproject(t,e){const{scale:i,cosPhi:n}=this,r=-(e-.5)/i,o=Xe(Ze((t-.5)/i)/n,-180,180),s=Math.asin(Xe(r*n,-1,1)),a=Xe(Ze(s),-Pd,Pd);return new pd(o,a)}}class wg extends _g{constructor(t){super(t),this.requiresDraping=!0,this.supportsWorldCopies=!1,this.supportsFog=!0,this.zAxisUnit="pixels",this.unsupportedLayers=["debug"],this.range=[3,5]}projectTilePoint(e,i,n){const r=Fu(e,i,n),o=ju($u(n));return t._.transformMat4(r,r,o),{x:r[0],y:r[1],z:r[2]}}locationPoint(e,i){const n=dd(i.lat,i.lng),r=t._.normalize([],n),o=e.elevation?e.elevation.getAtPointOrZero(e.locationCoordinate(i),e._centerAltitude):e._centerAltitude,s=Cd(1,0)*uo*o;t._.scaleAndAdd(n,n,r,s);const a=t.ad.identity(new Float64Array(16));return t.ad.multiply(a,e.pixelMatrix,e.globeMatrix),t._.transformMat4(n,n,a),new Ue(n[0],n[1])}pixelsPerMeter(t,e){return Cd(1,0)*e}pixelSpaceConversion(t,e,i){const n=Cd(1,t)*e,r=Vn(Cd(1,45)*e,n,i);return this.pixelsPerMeter(t,e)/r}createTileMatrix(e,i,n){const r=Vu($u(n.canonical));return t.ad.multiply(new Float64Array(16),e.globeMatrix,r)}createInversionMatrix(e,i){const{center:n}=e,r=ju($u(i));return t.ad.rotateY(r,r,Ge(n.lng)),t.ad.rotateX(r,r,Ge(n.lat)),t.ad.scale(r,r,[e._pixelsPerMercatorPixel,e._pixelsPerMercatorPixel,1]),Float32Array.from(r)}pointCoordinate(t,e,i,n){return Iu(t,e,i,!0)||new Rd(0,0)}pointCoordinate3D(t,e,i){const n=this.pointCoordinate(t,e,i,0);return[n.x,n.y,n.z]}isPointAboveHorizon(t,e){return!Iu(t,e.x,e.y,!1)}farthestPixelDistance(e){const i=function(e,i){const n=e.cameraToCenterDistance,r=e._centerAltitude*i,o=e._camera,s=e._camera.forward(),a=t._.add([],t._.scale([],s,-n),[0,0,r]),l=e.worldSize/(2*Math.PI),c=[0,0,-l],d=e.width/e.height,u=Math.tan(e.fovAboveCenter),h=t._.scale([],o.up(),u),p=t._.scale([],o.right(),u*d),f=t._.normalize([],t._.add([],t._.add([],s,h),p)),m=[];let _;if(new mu(a,f).closestPointOnSphere(c,l,m)){const i=t._.add([],m,c),n=t._.sub([],i,a);_=Math.cos(e.fovAboveCenter)*t._.length(n)}else{const e=t._.sub([],a,c),i=t._.sub([],c,a);t._.normalize(i,i);const n=t._.length(e)-l;_=Math.sqrt(n*(n+2*l));const r=Math.acos(_/(l+n))-Math.acos(t._.dot(s,i));_*=Math.cos(r)}return 1.01*_}(e,this.pixelsPerMeter(e.center.lat,e.worldSize)),n=Hu(e.zoom);if(n>0){const t=tg(e,Cd(1,e.center.lat)*e.worldSize),r=e.worldSize/(2*Math.PI),o=Math.max(e.width,e.height)/e.worldSize*Math.PI;return Vn(i,t+r*(1-Math.cos(o)),Math.pow(n,10))}return i}upVector(t,e,i){return Fu(e,i,t,1)}upVectorScale(t){return{metersToTile:Cu(Nu($u(t)))}}}function Tg(t){const e=t.parallels,i=!!e&&Math.abs(e[0]+e[1])0&&(this.iconTransitioningVertexBuffer=t.createVertexBuffer(this.iconTransitioningVertexArray,Vf.members,!0)),this.globeExtVertexArray.length>0&&(this.globeExtVertexBuffer=t.createVertexBuffer(this.globeExtVertexArray,Ff.members,!0)),!this.zOffsetVertexBuffer&&(this.zOffsetVertexArray.length>0||r)&&(this.zOffsetVertexBuffer=t.createVertexBuffer(this.zOffsetVertexArray,jf.members,!0)),this.opacityVertexBuffer.itemSize=1),(i||n)&&this.programConfigurations.upload(t))}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy(),this.dynamicLayoutVertexBuffer.destroy(),this.opacityVertexBuffer.destroy(),this.occlusionQueryOpacityVertexBuffer.destroy(),this.iconTransitioningVertexBuffer&&this.iconTransitioningVertexBuffer.destroy(),this.globeExtVertexBuffer&&this.globeExtVertexBuffer.destroy(),this.zOffsetVertexBuffer&&this.zOffsetVertexBuffer.destroy())}}ba(Ng,"SymbolBuffers");class Ug{constructor(t,e,i){this.layoutVertexArray=new t,this.layoutAttributes=e,this.indexArray=new i,this.segments=new wc,this.collisionVertexArray=new Xl,this.collisionVertexArrayExt=new Ol}upload(t){this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,this.layoutAttributes),this.indexBuffer=t.createIndexBuffer(this.indexArray),this.collisionVertexBuffer=t.createVertexBuffer(this.collisionVertexArray,Gf.members,!0),this.collisionVertexBufferExt=t.createVertexBuffer(this.collisionVertexArrayExt,Zf.members,!0)}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.segments.destroy(),this.collisionVertexBuffer.destroy(),this.collisionVertexBufferExt.destroy())}}ba(Ug,"CollisionBuffers");class jg{constructor(e){this.queries=new Map,this.collisionBoxArray=e.collisionBoxArray,this.zoom=e.zoom,this.lut=e.lut,this.overscaling=e.overscaling,this.layers=e.layers,this.layerIds=this.layers.map((t=>t.fqid)),this.index=e.index,this.pixelRatio=e.pixelRatio,this.sourceLayerIndex=e.sourceLayerIndex,this.hasPattern=!1,this.hasRTLText=!1,this.fullyClipped=!1,this.hasAnyIconTextFit=!1,this.sortKeyRanges=[],this.collisionCircleArray=[],this.placementInvProjMatrix=t.ad.identity([]),this.placementViewportMatrix=t.ad.identity([]);const i=this.layers[0]._unevaluatedLayout._values;this.textSizeData=Fm(this.zoom,i["text-size"]),this.iconSizeData=Fm(this.zoom,i["icon-size"]);const n=this.layers[0].layout,r=n.get("symbol-sort-key"),o=n.get("symbol-z-order");this.canOverlap=n.get("text-allow-overlap")||n.get("icon-allow-overlap")||n.get("text-ignore-placement")||n.get("icon-ignore-placement"),this.sortFeaturesByKey="viewport-y"!==o&&void 0!==r.constantOr(1),this.sortFeaturesByY=("viewport-y"===o||"auto"===o&&!this.sortFeaturesByKey)&&this.canOverlap,this.writingModes=n.get("text-writing-mode").map((t=>Jm[t])),this.stateDependentLayerIds=this.layers.filter((t=>t.isStateDependent())).map((t=>t.id)),this.sourceID=e.sourceID,this.projection=e.projection,this.hasAnyZOffset=!1,this.zOffsetSortDirty=!1,this.zOffsetBuffersNeedUpload=n.get("symbol-z-elevate"),this.activeReplacements=[],this.replacementUpdateTime=0}createArrays(){this.text=new Ng(new Yc(this.layers,{zoom:this.zoom,lut:this.lut},(t=>/^text/.test(t)))),this.icon=new Ng(new Yc(this.layers,{zoom:this.zoom,lut:this.lut},(t=>/^icon/.test(t)))),this.glyphOffsetArray=new mc,this.lineVertexArray=new _c,this.symbolInstances=new fc}calculateGlyphDependencies(t,e,i,n,r){for(let i=0;i0)&&("constant"!==l.value.kind||l.value.value.length>0),h="constant"!==d.value.kind||!!d.value.value||Object.keys(d.parameters).length>0,p=s.get("symbol-sort-key");if(this.features=[],!u&&!h)return;const f=i.iconDependencies,m=i.glyphDependencies,_=i.availableImages,g=new Ha(this.zoom);for(const{feature:i,id:c,index:d,sourceLayerIndex:y}of e){const e=o._featureFilter.needGeometry,v=Zd(i,e);if(!o._featureFilter.filter(g,v,n))continue;if(e||(v.geometry=Gd(i,n,r)),a&&1!==i.type&&n.z{const o=Fu(e.x,e.y,n,1),s=Fu(r.x,r.y,n,1);return t._.dot(o,s)=0;for(const i of x.sections)if(i.image)f[i.image.namePrimary]=!0;else{const n=Ca(x.toString()),r=i.fontStack||t,o=m[r]=m[r]||{};this.calculateGlyphDependencies(i.text,o,e,this.allowVerticalPlacement,n)}}}"line"===s.get("symbol-placement")&&(this.features=function(t){const e={},i={},n=[];let r=0;function o(e){n.push(t[e]),r++}function s(t,e,r){const o=i[t];return delete i[t],i[e]=o,n[o].geometry[0].pop(),n[o].geometry[0]=n[o].geometry[0].concat(r[0]),o}function a(t,i,r){const o=e[i];return delete e[i],e[t]=o,n[o].geometry[0].shift(),n[o].geometry[0]=r[0].concat(n[o].geometry[0]),o}function l(t,e,i){const n=i?e[0][e[0].length-1]:e[0][0];return`${t}:${n.x}:${n.y}`}for(let c=0;ct.geometry))}(this.features)),this.sortFeaturesByKey&&this.features.sort(((t,e)=>t.sortKey-e.sortKey))}update(t,e,i,n,r){const o=0!==Object.keys(t).length;if(o&&!this.stateDependentLayers.length)return;const s=o?this.stateDependentLayers:this.layers;this.text.programConfigurations.updatePaintArrays(t,e,s,i,n,r),this.icon.programConfigurations.updatePaintArrays(t,e,s,i,n,r)}updateOcclusionOpacities(t,e,i){if(!e.useOcclusionQueries)return!1;const n=this;if("globe"===n.projection.name)return!1;let r=!1;n.hasTextData()&&(r=r||0!==n.text.occlusionQueryOpacityVertexArray.length),n.hasIconData()&&(r=r||0!==n.icon.occlusionQueryOpacityVertexArray.length);const o=n.layers[0].paint,s=o.get("icon-occlusion-opacity").constantOr(0),a=o.get("text-occlusion-opacity").constantOr(0);if(!n.layers[0].hasInitialOcclusionOpacityProperties||1===s&&1===a)return!1;let l=!r;for(let t=0;t.5?1:-1)*e.fadeSpeed*i*.001,r.occlusionOpacity=Xe(r.occlusionOpacity,0,1),l=l||r.occlusionOpacity!==o}if(!l)return!1;let c=0,d=0;const u=(t,e,i,n)=>{let r=0,o=0;i?(r=d,d+=n,o=d):(r=c,c+=n,o=c),o>e.occlusionQueryOpacityVertexArray.length&&e.occlusionQueryOpacityVertexArray.resize(o);const s=t.occlusionOpacity;for(let t=0;t0;if((i>0||r>0)&&(u(e,n.text,!1,i),u(e,n.text,!1,r)),s){const{placedIconSymbolIndex:t,verticalPlacedIconSymbolIndex:i}=e;t>=0&&u(e,n.icon,!0,o),i>=0&&u(e,n.icon,!0,e.numVerticalIconVertices)}}return n.hasTextData()&&n.text.occlusionQueryOpacityVertexBuffer&&(n.text.occlusionQueryOpacityVertexBuffer.length{i+=e,i>t.length&&t.resize(i);for(let r=-e;r{n+=e,n>t.length&&t.resize(n);for(let r=-e;r0;if((r>0||o>0)&&(t(this.text.zOffsetVertexArray,r,a),t(this.text.zOffsetVertexArray,o,a)),l){const{placedIconSymbolIndex:t,verticalPlacedIconSymbolIndex:i}=n;t>=0&&e(this.icon.zOffsetVertexArray,s,a),i>=0&&e(this.icon.zOffsetVertexArray,n.numVerticalIconVertices,a)}}this.text.zOffsetVertexBuffer&&this.text.zOffsetVertexBuffer.updateData(this.text.zOffsetVertexArray),this.icon.zOffsetVertexBuffer&&this.icon.zOffsetVertexBuffer.updateData(this.icon.zOffsetVertexArray)}isEmpty(){return 0===this.symbolInstances.length&&!this.hasRTLText}uploadPending(){return!this.uploaded||this.text.programConfigurations.needsUpload||this.icon.programConfigurations.needsUpload}upload(t){!this.uploaded&&this.hasDebugData()&&(this.textCollisionBox.upload(t),this.iconCollisionBox.upload(t)),this.text.upload(t,this.sortFeaturesByY,!this.uploaded,this.text.programConfigurations.needsUpload,this.zOffsetBuffersNeedUpload),this.icon.upload(t,this.sortFeaturesByY,!this.uploaded,this.icon.programConfigurations.needsUpload,this.zOffsetBuffersNeedUpload),this.uploaded=!0}destroyDebugData(){this.textCollisionBox.destroy(),this.iconCollisionBox.destroy()}getProjection(){return this.projectionInstance||(this.projectionInstance=Tg(this.projection)),this.projectionInstance}destroy(){this.text.destroy(),this.icon.destroy(),this.hasDebugData()&&this.destroyDebugData();for(const t of this.queries.values())t.destroy()}addToLineVertexArray(t,e){const i=this.lineVertexArray.length;if(void 0!==t.segment)for(const{x:t,y:i}of e)this.lineVertexArray.emplaceBack(t,i);return{lineStartIndex:i,lineLength:this.lineVertexArray.length-i}}addSymbols(t,e,i,n,r,o,s,a,l,c,d,u,h,p,f,m){const _=t.indexArray,g=t.layoutVertexArray,y=t.globeExtVertexArray,v=t.segments.prepareSegment(4*e.length,g,_,this.canOverlap?o.sortKey:void 0),x=this.glyphOffsetArray.length,b=v.vertexLength,w=this.allowVerticalPlacement&&s===Jm.vertical?Math.PI/2:0,T=o.text&&o.text.sections;for(let n=0;n=0?e.rightJustifiedTextSymbolIndex:e.centerJustifiedTextSymbolIndex>=0?e.centerJustifiedTextSymbolIndex:e.leftJustifiedTextSymbolIndex>=0?e.leftJustifiedTextSymbolIndex:e.verticalPlacedTextSymbolIndex>=0?e.verticalPlacedTextSymbolIndex:n),o=Nm(this.textSizeData,t,r)/Om;return this.tilePixelRatio*o}getSymbolInstanceIconSize(t,e,i){const n=this.icon.placedSymbolArray.get(i),r=Nm(this.iconSizeData,t,n);return this.tilePixelRatio*r}_commitDebugCollisionVertexUpdate(t,e,i,n){t.emplaceBack(e,-i,-i,n),t.emplaceBack(e,i,-i,n),t.emplaceBack(e,i,i,n),t.emplaceBack(e,-i,i,n)}_updateTextDebugCollisionBoxes(t,e,i,n,r,o){for(let s=n;s0}hasIconData(){return this.icon.segments.get().length>0}hasDebugData(){return this.textCollisionBox&&this.iconCollisionBox}hasTextCollisionBoxData(){return this.hasDebugData()&&this.textCollisionBox.segments.get().length>0}hasIconCollisionBoxData(){return this.hasDebugData()&&this.iconCollisionBox.segments.get().length>0}hasIconTextFit(){return this.hasAnyIconTextFit}addIndicesForPlacedSymbol(t,e){const i=t.placedSymbolArray.get(e),n=i.vertexStartIndex+4*i.numGlyphs;for(let e=i.vertexStartIndex;en[t]-n[e]||r[e]-r[t])),o}getSortedIndexesByZOffset(){if(!this.zOffsetSortDirty)return this.symbolInstanceIndexesSortedZOffset;if(!this.symbolInstanceIndexesSortedZOffset){this.symbolInstanceIndexesSortedZOffset=[];for(let t=0;tthis.symbolInstances.get(e).zOffset-this.symbolInstances.get(t).zOffset))}addToSortKeyRanges(t,e){const i=this.sortKeyRanges[this.sortKeyRanges.length-1];i&&i.sortKey===e?i.symbolInstanceEnd=t+1:this.sortKeyRanges.push({sortKey:e,symbolInstanceStart:t,symbolInstanceEnd:t+1})}sortFeatures(t){if(this.sortFeaturesByY&&this.sortedAngle!==t&&!(this.text.segments.get().length>1||this.icon.segments.get().length>1)){this.symbolInstanceIndexes=this.getSortedSymbolIndexes(t),this.sortedAngle=t,this.text.indexArray.clear(),this.icon.indexArray.clear(),this.featureSortOrder=[];for(const t of this.symbolInstanceIndexes){const e=this.symbolInstances.get(t);this.featureSortOrder.push(e.featureIndex);const{rightJustifiedTextSymbolIndex:i,centerJustifiedTextSymbolIndex:n,leftJustifiedTextSymbolIndex:r,verticalPlacedTextSymbolIndex:o,placedIconSymbolIndex:s,verticalPlacedIconSymbolIndex:a}=e;i>=0&&this.addIndicesForPlacedSymbol(this.text,i),n>=0&&n!==i&&this.addIndicesForPlacedSymbol(this.text,n),r>=0&&r!==n&&r!==i&&this.addIndicesForPlacedSymbol(this.text,r),o>=0&&this.addIndicesForPlacedSymbol(this.text,o),s>=0&&this.addIndicesForPlacedSymbol(this.icon,s),a>=0&&this.addIndicesForPlacedSymbol(this.icon,a)}this.text.indexBuffer&&this.text.indexBuffer.updateData(this.text.indexArray),this.icon.indexBuffer&&this.icon.indexBuffer.updateData(this.icon.indexArray)}}}ba(jg,"SymbolBucket",{omit:["layers","collisionBoxArray","features","compareText"]}),jg.addDynamicAttributes=Bg;class Vg{constructor(t,e,i,n){this.context=t,this.format=i,this.texture=t.gl.createTexture(),this.update(e,n)}update(t,e,i){const{width:n,height:r}=t,{context:o}=this,{gl:s}=o;if(s.bindTexture(s.TEXTURE_2D,this.texture),o.pixelStoreUnpackFlipY.set(!1),o.pixelStoreUnpack.set(1),o.pixelStoreUnpackPremultiplyAlpha.set(this.format===s.RGBA&&(!e||!1!==e.premultiply)),this.useMipmap=Boolean(e&&e.useMipmap),i||this.size&&this.size[0]===n&&this.size[1]===r){const{x:e,y:o}=i||{x:0,y:0};if(t instanceof HTMLImageElement||t instanceof HTMLCanvasElement||t instanceof HTMLVideoElement||t instanceof ImageData||ImageBitmap&&t instanceof ImageBitmap)s.texSubImage2D(s.TEXTURE_2D,0,e,o,s.RGBA,s.UNSIGNED_BYTE,t);else{let i=this.format,a=s.UNSIGNED_BYTE;this.format===s.R32F&&(i=s.RED,a=s.FLOAT),s.texSubImage2D(s.TEXTURE_2D,0,e,o,n,r,i,a,t.data)}}else if(this.size=[n,r],t instanceof HTMLImageElement||t instanceof HTMLCanvasElement||t instanceof HTMLVideoElement||t instanceof ImageData||ImageBitmap&&t instanceof ImageBitmap){let e=this.format;this.format===s.R8&&(e=s.RED),s.texImage2D(s.TEXTURE_2D,0,this.format,e,s.UNSIGNED_BYTE,t)}else{let e=this.format,i=this.format,o=s.UNSIGNED_BYTE,a=!1;this.format===s.DEPTH_COMPONENT&&(e=s.DEPTH_COMPONENT16,o=s.UNSIGNED_SHORT),this.format===s.DEPTH_STENCIL&&(e=s.DEPTH24_STENCIL8,o=s.UNSIGNED_INT_24_8,a=!0),this.format===s.R8&&(i=s.RED),this.format===s.R32F&&(o=s.FLOAT,i=s.RED),!this.useMipmap&&a?s.texStorage2D(s.TEXTURE_2D,1,e,n,r):s.texImage2D(s.TEXTURE_2D,0,e,n,r,0,i,o,t.data)}this.useMipmap&&s.generateMipmap(s.TEXTURE_2D)}bind(t,e,i=!1){const{context:n}=this,{gl:r}=n;r.bindTexture(r.TEXTURE_2D,this.texture),t!==this.minFilter&&(r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MAG_FILTER,t),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MIN_FILTER,this.useMipmap&&!i?t===r.NEAREST?r.NEAREST_MIPMAP_NEAREST:r.LINEAR_MIPMAP_LINEAR:t),this.minFilter=t),e!==this.wrapS&&(r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_S,e),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_T,e),this.wrapS=e)}bindExtraParam(t,e,i,n){const{context:r}=this,{gl:o}=r;o.bindTexture(o.TEXTURE_2D,this.texture),e!==this.magFilter&&(o.texParameteri(o.TEXTURE_2D,o.TEXTURE_MAG_FILTER,e),this.magFilter=e),t!==this.minFilter&&(o.texParameteri(o.TEXTURE_2D,o.TEXTURE_MIN_FILTER,this.useMipmap?t===o.NEAREST?o.NEAREST_MIPMAP_NEAREST:o.LINEAR_MIPMAP_LINEAR:t),this.minFilter=t),i!==this.wrapS&&(o.texParameteri(o.TEXTURE_2D,o.TEXTURE_WRAP_S,i),this.wrapS=i),n!==this.wrapT&&(o.texParameteri(o.TEXTURE_2D,o.TEXTURE_WRAP_T,n),this.wrapT=n)}destroy(){const{gl:t}=this.context;t.deleteTexture(this.texture),this.texture=null}}class Gg{constructor(t,e){this.context=t,this.texture=e}bind(t,e){const{context:i}=this,{gl:n}=i;n.bindTexture(n.TEXTURE_2D,this.texture),t!==this.minFilter&&(n.texParameteri(n.TEXTURE_2D,n.TEXTURE_MAG_FILTER,t),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_MIN_FILTER,t),this.minFilter=t),e!==this.wrapS&&(n.texParameteri(n.TEXTURE_2D,n.TEXTURE_WRAP_S,e),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_WRAP_T,e),this.wrapS=e)}}const Zg=32,qg=33,Hg=new Uint16Array(8184);for(let t=0;t>=1)>1;){const t=i+r>>1,l=n+o>>1;1&e?(r=i,o=n,i=s,n=a):(i=r,n=o,r=s,o=a),s=t,a=l}const l=4*t;Hg[l+0]=i,Hg[l+1]=n,Hg[l+2]=r,Hg[l+3]=o}const Wg=new Uint16Array(2178),Yg=new Uint8Array(1089),Xg=new Uint16Array(1089);function Kg(t){return 0===t?-.03125:32===t?.03125:0}var Jg=Ll([{name:"a_pos",type:"Int16",components:2},{name:"a_texture_pos",type:"Int16",components:2}]),Qg=Ll([{name:"a_index",type:"Int16",components:1}]);const ty={type:2,extent:uo,loadGeometry:()=>[[new Ue(0,0),new Ue(uo+1,0),new Ue(uo+1,uo+1),new Ue(0,uo+1),new Ue(0,0)]]};class ey{constructor(t,e,i,n,r){this.tileID=t,this.uid=ni(),this.uses=0,this.tileSize=e,this.tileZoom=i,this.buckets={},this.expirationTime=null,this.queryPadding=0,this.hasSymbolBuckets=!1,this.hasRTLText=!1,this.dependencies={},this.isRaster=r,n&&n.style&&(this._lastUpdatedBrightness=n.style.getBrightness()),this.expiredRequestCount=0,this.state="loading",n&&n.transform&&(this.projection=n.transform.projection)}registerFadeDuration(t){const e=t+this.timeAdded;ee.getLayer(t))).filter(Boolean);if(0!==t.length){n.layers=t,n.stateDependentLayerIds&&(n.stateDependentLayers=n.stateDependentLayerIds.map((e=>t.filter((t=>t.id===e))[0])));for(const e of t)i[e.fqid]=n}}return i}(t.buckets,e.style),this.hasSymbolBuckets=!1;for(const t in this.buckets){const e=this.buckets[t];if(e instanceof jg){if(this.hasSymbolBuckets=!0,!i)break;e.justReloaded=!0}}if(this.hasRTLText=!1,this.hasSymbolBuckets)for(const t in this.buckets){const e=this.buckets[t];if(e instanceof jg&&e.hasRTLText){this.hasRTLText=!0,qa.isLoading()||qa.isLoaded()||"deferred"!==Ga()||Za();break}}this.queryPadding=0;for(const t in this.buckets){const i=this.buckets[t],n=e.style.getOwnLayer(t);if(!n)continue;const r=n.queryRadius(i);this.queryPadding=Math.max(this.queryPadding,r)}t.imageAtlas&&(this.imageAtlas=t.imageAtlas),t.glyphAtlasImage&&(this.glyphAtlasImage=t.glyphAtlasImage),t.lineAtlas&&(this.lineAtlas=t.lineAtlas),this._lastUpdatedBrightness=t.brightness}else this.collisionBoxArray=new dc}unloadVectorData(){if(this.hasData()){for(const t in this.buckets)this.buckets[t].destroy();this.buckets={},this.imageAtlas&&(this.imageAtlas=null),this.lineAtlas&&(this.lineAtlas=null),this.imageAtlasTexture&&this.imageAtlasTexture.destroy(),this.glyphAtlasTexture&&this.glyphAtlasTexture.destroy(),this.lineAtlasTexture&&this.lineAtlasTexture.destroy(),this._tileBoundsBuffer&&(this._tileBoundsBuffer.destroy(),this._tileBoundsIndexBuffer.destroy(),this._tileBoundsSegments.destroy(),this._tileBoundsBuffer=null),this._tileDebugBuffer&&(this._tileDebugBuffer.destroy(),this._tileDebugSegments.destroy(),this._tileDebugBuffer=null),this._tileDebugIndexBuffer&&(this._tileDebugIndexBuffer.destroy(),this._tileDebugIndexBuffer=null),this._globeTileDebugBorderBuffer&&(this._globeTileDebugBorderBuffer.destroy(),this._globeTileDebugBorderBuffer=null),this._tileDebugTextBuffer&&(this._tileDebugTextBuffer.destroy(),this._tileDebugTextSegments.destroy(),this._tileDebugTextIndexBuffer.destroy(),this._tileDebugTextBuffer=null),this._globeTileDebugTextBuffer&&(this._globeTileDebugTextBuffer.destroy(),this._globeTileDebugTextBuffer=null),this.latestFeatureIndex=null,this.state="unloaded"}}getBucket(t){return this.buckets[t.fqid]}upload(t){for(const e in this.buckets){const i=this.buckets[e];i.uploadPending()&&i.upload(t)}const e=t.gl,i=this.imageAtlas;if(i&&!i.uploaded){const n=!!Object.keys(i.patternPositions).length;this.imageAtlasTexture=new Vg(t,i.image,e.RGBA,{useMipmap:n}),this.imageAtlas.uploaded=!0}this.glyphAtlasImage&&(this.glyphAtlasTexture=new Vg(t,this.glyphAtlasImage,e.R8),this.glyphAtlasImage=null),this.lineAtlas&&!this.lineAtlas.uploaded&&(this.lineAtlasTexture=new Vg(t,this.lineAtlas.image,e.R8),this.lineAtlas.uploaded=!0)}prepare(t,e,i){if(this.imageAtlas&&this.imageAtlasTexture&&this.imageAtlas.patchUpdatedImages(t,this.imageAtlasTexture,i),!e||!this.latestFeatureIndex||!this.latestFeatureIndex.rawTileData)return;const n=e.style.getBrightness();(this._lastUpdatedBrightness||n)&&(this._lastUpdatedBrightness&&n&&Math.abs(this._lastUpdatedBrightness-n)t)i=!1;else if(e)if(this.expirationTime=0;t--){const e=4*t,i=Hg[e+0],n=Hg[e+1],r=Hg[e+2],o=Hg[e+3],s=i+r>>1,a=n+o>>1,l=s+a-n,c=a+i-s,d=n*qg+i,u=o*qg+r,h=a*qg+s,p=Math.hypot((Wg[2*d+0]+Wg[2*u+0])/2-Wg[2*h+0],(Wg[2*d+1]+Wg[2*u+1])/2-Wg[2*h+1])>=16;Yg[h]=Yg[h]||(p?1:0),t>1)*qg+(i+l>>1)]||Yg[(o+c>>1)*qg+(r+l>>1)])}const r=new Dl,o=new Kl;let s=0;function a(t,e){const i=e*qg+t;return 0===Xg[i]&&(r.emplaceBack(Wg[2*i+0],Wg[2*i+1],t*uo/Zg,e*uo/Zg),Xg[i]=++s),Xg[i]-1}function l(t,e,i,n,r,s){const c=t+i>>1,d=e+n>>1;if(Math.abs(t-r)+Math.abs(e-s)>1&&Yg[d*qg+c])l(r,s,t,e,c,d),l(i,n,r,s,c,d);else{const l=a(t,e),c=a(i,n),d=a(r,s);o.emplaceBack(l,c,d)}}return l(0,0,Zg,Zg,Zg,0),l(Zg,Zg,0,0,0,Zg),{vertices:r,indices:o}}(this.tileID.canonical,e);n=t.vertices,r=t.indices}else{n=new Dl,r=new Kl;for(const{x:t,y:e}of i)n.emplaceBack(t,e,0,0);const t=xh(n.int16,void 0,4);for(let e=0;e0&&(a=t.ad.invert(new Float64Array(16),i.globeMatrix)),this._makeGlobeTileDebugBorderBuffer(e,r,i,o,a,s),this._makeGlobeTileDebugTextBuffer(e,r,i,o,a,s)}_globePoint(e,i,n,r,o,s,a){let l=Fu(e,i,n);if(s){const o=1.5?h=-1:u{const p=(d-t)/(h-1),f=(u-c)/(h-1),m=s.length;for(let d=0;dd*t+e;for(let t=0;t[t,this.get(t)]))}evict(t=!1){if(t||this.size>0){const t=this.first;delete this.items[t.key],0==--this.size?(this.first=null,this.last=null):(this.first=t.next,this.first.prev=null)}return this}expiresAt(t){let e;return this.has(t)&&(e=this.items[t].expiry),e}get(t){let e;if(this.has(t)){const i=this.items[t];this.ttl>0&&i.expiry0?Date.now()+this.ttl:this.ttl),this.last!==r){const t=this.last,e=r.next,i=r.prev;this.first===r&&(this.first=r.next),r.next=null,r.prev=this.last,t.next=r,null!==i&&(i.next=e),null!==e&&(e.prev=i)}}else this.max>0&&this.size===this.max&&this.evict(!0),r=this.items[t]={expiry:this.ttl>0?Date.now()+this.ttl:this.ttl,key:t,prev:this.last,next:null,value:e},1==++this.size?this.first=r:this.last.next=r;return this.last=r,this}values(t=this.keys()){return t.map((t=>this.get(t)))}}function uy(t,e){if(4!==e.length)throw new Error(`Expected data of dimension 4 but got ${e.length}.`);let i=e[3];for(let n=2;n>=1;n--){const r=1===n?1:0,o=2===n?1:0;for(let n=0;n>>1^-(1&t[e]);return t}function py(t,e){switch(e){case"uint32":return t;case"uint16":for(let e=0;e>4|(61440&i)>>8|(240&n)>4|(15&n)>6|(192&n)>>4|(192&r)>>2|192&o,t[e+1]=(48&i)>>4|(48&n)>>2|48&r|(48&o)>2|12&n|(12&r)>1|(21845&Cy)>2|(13107&Ay)>4|(3855&Ay)>8|(255&Ay)>1}var Iy=function(t,e,i){for(var n=t.length,r=0,o=new _y(e);r>l]=c}else for(s=new _y(n),r=0;r>15-t[r]);return s},Ly=new my(288);for(Cy=0;Cye&&(e=t[i]);return e},zy=function(t,e,i){var n=e/8|0;return(t[n]|t[n+1]>(7&e)&i},Ry=function(t,e){var i=e/8|0;return(t[i]|t[i+1]>(7&e)},Oy=["unexpected EOF","invalid block type","invalid length/literal","invalid distance","stream finished","no stream handler",,"no callback","invalid UTF-8 data","extra field too long","date not in range 1980-2099","filename too long","stream finishing","invalid zip data"],By=function(t,e,i){var n=new Error(e||Oy[t]);if(n.code=t,Error.captureStackTrace&&Error.captureStackTrace(n,By),!i)throw n;return n},Fy=new my(0),Ny="undefined"!=typeof TextDecoder&&new TextDecoder;try{Ny.decode(Fy,{stream:!0})}catch(t){}const Uy={gzip_data:"gzip"},jy={0:"uint32",1:"uint32",2:"uint16",3:"uint8"},Vy={uint32:1,uint16:2,uint8:4},Gy={uint32:Uint32Array,uint16:Uint16Array,uint8:Uint8Array};class Zy{constructor(t=1){this.x=NaN,this.y=NaN,this.z=NaN,this.layers={},this._cacheSize=t}getLayer(t){return this.layers[t]}getHeaderLength(t){const e=new Uint8Array(t),i=new DataView(t);if(13!==e[0])throw new fy("File is not a valid MRT.");return i.getUint32(1,!0)}parseHeader(t){const e=new Uint8Array(t),i=this.getHeaderLength(t);if(e.length= ${i} but got buffer of length ${e.length}`);const n=function(t){return t.readFields(iy,{header_length:0,x:0,y:0,z:0,layers:[]},void 0)}(new Lm(e.subarray(0,i)));if(!isNaN(this.x)&&(this.x!==n.x||this.y!==n.y||this.z!==n.z))throw new fy(`Invalid attempt to parse header ${n.z}/${n.x}/${n.y} for tile ${this.z}/${this.x}/${this.y}`);this.x=n.x,this.y=n.y,this.z=n.z;for(const t of n.layers)this.layers[t.name]=new qy(t,{cacheSize:this._cacheSize});return this}createDecodingTask(t){const e=[],i=this.getLayer(t.layerName);for(let n=0;nt.lastBlock)continue;if(i._blocksInProgress.has(n))continue;const a={layerName:i.name,firstByte:o,lastByte:s,pixelFormat:i.pixelFormat,blockIndex:n,blockShape:[r.bands.length].concat(i.bandShape),buffer:i.buffer,codec:r.codec.codec,filters:r.filters.map((t=>t.filter))};i._blocksInProgress.add(n),e.push(a)}return new Hy(e,(()=>{e.forEach((t=>i._blocksInProgress.delete(t.blockIndex)))}),((t,n)=>{if(e.forEach((t=>i._blocksInProgress.delete(t.blockIndex))),t)throw t;n.forEach((t=>{this.getLayer(t.layerName).processDecodedData(t)}))}))}}class qy{constructor({version:t,name:e,units:i,tilesize:n,pixel_format:r,buffer:o,data_index:s},a){if(this.version=t,1!==this.version)throw new fy(`Cannot parse raster layer encoded with MRT version ${t}`);this.name=e,this.units=i,this.tileSize=n,this.buffer=o,this.pixelFormat=jy[r],this.dataIndex=s,this.bandShape=[n+2*o,n+2*o,Vy[this.pixelFormat]],this._decodedBlocks=function(t=1e3,e=0,i=!1){if(isNaN(t)||t=e&&t=0}hasDataForBand(t){const{blockIndex:e}=this.getBlockForBand(t);return e>=0&&!!this._decodedBlocks.get(e.toString())}getBandView(t){const{blockIndex:e,blockBandIndex:i}=this.getBlockForBand(t),n=this._decodedBlocks.get(e.toString());if(!n)throw new fy(`Data for band ${JSON.stringify(t)} of layer "${this.name}" not decoded.`);const r=this.dataIndex[e],o=this.bandShape.reduce(((t,e)=>t*e),1),s=i*o,a=n.subarray(s,s+o);return{data:a,bytes:new Uint8Array(a.buffer).subarray(a.byteOffset,a.byteOffset+a.byteLength),tileSize:this.tileSize,buffer:this.buffer,offset:r.offset,scale:r.scale}}}class Hy{constructor(t,e,i){this.tasks=t,this._onCancel=e,this._onComplete=i,this._finalized=!1}cancel(){this._finalized||(this._onCancel(),this._finalized=!0)}complete(t,e){this._finalized||(this._onComplete(t,e),this._finalized=!0)}}Zy.performDecoding=function(t,e){return Promise.all(e.tasks.map((e=>{const{layerName:i,firstByte:n,lastByte:r,pixelFormat:o,blockShape:s,blockIndex:a,filters:l,codec:c}=e,d=new Uint8Array(t).subarray(n,r+1),u=new Uint32Array(s[0]*s[1]*s[2]);let h;if("gzip_data"!==c)throw new Error(`Unhandled codec: ${c}`);return h=function(t,e){if(!globalThis.DecompressionStream&&"gzip_data"===e)return Promise.resolve(((o=function(t){31==t[0]&&139==t[1]&&8==t[2]||By(6,"invalid gzip data");var e=t[3],i=10;4&e&&(i+=2+(t[10]|t[11]>3&1)+(e>>4&1);n>0;n-=!t[i++]);return i+(2&e)}(r=t))+8>r.length&&By(6,"invalid gzip data"),function(t,e,i){var n=t.length;if(!n||e.f&&!e.l)return i||new my(0);var r=!i,o=r||2!=e.i,s=e.i;r&&(i=new my(3*n));var a,l,c=function(t){var e=i.length;if(t>e){var n=new my(Math.max(2*e,t));n.set(i),i=n}},d=e.f||0,u=e.p||0,h=e.b||0,p=e.l,f=e.d,m=e.m,_=e.n,g=8*n;do{if(!p){d=zy(t,u,1);var y=zy(t,u+1,3);if(u+=3,!y){var v=t[(L=4+((u+7)/8|0))-4]|t[L-3]n){s&&By(0);break}o&&c(h+v),i.set(t.subarray(L,x),h),e.b=h+=v,e.p=u=8*x,e.f=d;continue}if(1==y)p=$y,f=ky,m=9,_=5;else if(2==y){var b=zy(t,u,31)+257,w=zy(t,u+10,15)+4,T=b+zy(t,u+5,31)+1;u+=14;for(var S=new my(T),E=new my(19),M=0;M>4)g){s&&By(0);break}}o&&c(h+131072);for(var R=(1>4;if((u+=15&$)>g){s&&By(0);break}if($||By(2),F264&&(N=zy(t,u,(1>4;if(U||By(3),u+=15&U,z=Ey[j],j>3){var V=vy[j];z+=Ry(t,u)&(1g){s&&By(0);break}o&&c(h+131072);var G=h+N;if(ha.length)&&(l=a.length),new my(a.subarray(0,l))):i.subarray(0,h)}(r.subarray(o,-8),{i:2},new my(((i=r)[(n=i.length)-4]|i[n-3]>>0))));var i,n,r,o;const s=Uy[e];if(!s)throw new Error(`Unhandled codec: ${e}`);const a=new globalThis.DecompressionStream(s);return new Response(new Blob([t]).stream().pipeThrough(a)).arrayBuffer().then((t=>new Uint8Array(t)))}(d,c).then((t=>(function(t,e){t.readFields(ly,e)}(new Lm(t),u),new(0,Gy[o])(u.buffer)))),h.then((t=>{for(let e=l.length-1;e>=0;e--)switch(l[e]){case"delta_filter":uy(t,s);break;case"zigzag_filter":hy(t);break;case"bitshuffle_filter":py(t,o);break;default:throw new Error(`Unhandled filter "${l[e]}"`)}return{layerName:i,blockIndex:a,data:t}})).catch((t=>{throw t}))})))};class Wy extends ey{constructor(t,e,i,n,r){super(t,e,i,n,r),this._workQueue=[],this._fetchQueue=[],this._isHeaderLoaded=!1}setTexture(t,e){const i=e.context,n=i.gl;this.texture=this.texture||e.getTileTexture(t.width),this.texture&&this.texture instanceof Vg?this.texture.update(t,{useMipmap:!1,premultiply:!1}):this.texture=new Vg(i,t,n.RGBA,{useMipmap:!1,premultiply:!1})}flushQueues(){for(;this._workQueue.length;)this._workQueue.pop()();for(;this._fetchQueue.length;)this._fetchQueue.pop()()}fetchHeader(t=16384,e){const i=this._mrt=new Zy(30),n=Object.assign({},this.requestParams,{headers:{Range:"bytes=0-"+(t-1)}});return this.entireBuffer=null,this.request=en(n,((n,r,o,s)=>{if(n)e(n);else try{const n=i.getHeaderLength(r);if(n>t)return void(this.request=this.fetchHeader(n,e));i.parseHeader(r),this._isHeaderLoaded=!0;let a=0;for(const t of Object.values(i.layers))a=Math.max(a,t.dataIndex[t.dataIndex.length-1].last_byte);r.byteLength>=a&&(this.entireBuffer=r),e(null,this.entireBuffer||r,o,s)}catch(t){e(t)}})),this.request}fetchBand(t,e,i){const n=this._mrt;if(!this._isHeaderLoaded||!n)return void i(new Error("Tile header is not ready"));const r=this.actor;if(!r)return void i(new Error("Can't fetch tile band without an actor"));let o;const s=(n,r)=>{o.complete(n,r),n?i(n):(this.updateTextureDescriptor(t,e),i(null,this.textureDescriptor&&this.textureDescriptor.img))},a=(t,e)=>{if(t)return i(t);const n=r.send("decodeRasterArray",{buffer:e,task:o},s,void 0,!0);this._workQueue.push((()=>{n&&n.cancel(),o.cancel()}))},l=n.getLayer(t);if(!l)return void i(new Error(`Unknown sourceLayer "${t}"`));if(l.hasDataForBand(e))return this.updateTextureDescriptor(t,e),void i(null,this.textureDescriptor?this.textureDescriptor.img:null);const c=l.getDataRange([e]);if(o=n.createDecodingTask(c),!o||o.tasks.length)if(this.flushQueues(),this.entireBuffer)a(null,this.entireBuffer.slice(c.firstByte,c.lastByte+1));else{const t=Object.assign({},this.requestParams,{headers:{Range:`bytes=${c.firstByte}-${c.lastByte}`}}),e=en(t,a);this._fetchQueue.push((()=>{e.cancel(),o.cancel()}))}else i(null)}updateNeeded(t,e){return(!this.textureDescriptor||this.textureDescriptor.band!==e||this.textureDescriptor.layer!==t)&&"errored"!==this.state}updateTextureDescriptor(t,e){if(!this._mrt)return;const i=this._mrt.getLayer(t);if(!i||!i.hasBand(e)||!i.hasDataForBand(e))return;const{bytes:n,tileSize:r,buffer:o,offset:s,scale:a}=i.getBandView(e),l=r+2*o,c={data:n,width:l,height:l},d=this.texture;d&&d instanceof Vg&&d.update(c,{useMipmap:!1,premultiply:!1}),this.textureDescriptor={layer:t,band:e,img:c,buffer:o,offset:s,tileSize:r,format:i.pixelFormat,mix:[a,256*a,65536*a,16777216*a]}}}class Yy{constructor(t,e){this.max=t,this.onRemove=e,this.reset()}reset(){for(const t in this.data)for(const e of this.data[t])e.timeout&&clearTimeout(e.timeout),this.onRemove(e.value);return this.data={},this.order=[],this}add(t,e,i){const n=t.wrapped().key;void 0===this.data[n]&&(this.data[n]=[]);const r={value:e,timeout:void 0};if(void 0!==i&&(r.timeout=setTimeout((()=>{this.remove(t,r)}),i)),this.data[n].push(r),this.order.push(n),this.order.length>this.max){const t=this._getAndRemoveByKey(this.order[0]);t&&this.onRemove(t)}return this}has(t){return t.wrapped().key in this.data}getAndRemove(t){return this.has(t)?this._getAndRemoveByKey(t.wrapped().key):null}_getAndRemoveByKey(t){const e=this.data[t].shift();return e.timeout&&clearTimeout(e.timeout),0===this.data[t].length&&delete this.data[t],this.order.splice(this.order.indexOf(t),1),e.value}getByKey(t){const e=this.data[t];return e?e[0].value:null}get(t){return this.has(t)?this.data[t.wrapped().key][0].value:null}remove(t,e){if(!this.has(t))return this;const i=t.wrapped().key,n=void 0===e?0:this.data[i].indexOf(e),r=this.data[i][n];return this.data[i].splice(n,1),r.timeout&&clearTimeout(r.timeout),0===this.data[i].length&&delete this.data[i],this.onRemove(r.value),this.order.splice(this.order.indexOf(i),1),this}setMaxSize(t){for(this.max=t;this.order.length>this.max;){const t=this._getAndRemoveByKey(this.order[0]);t&&this.onRemove(t)}return this}filter(t){const e=[];for(const i in this.data)for(const n of this.data[i])t(n.value)||e.push(n);for(const t of e)this.remove(t.value.tileID,t)}}class Xy extends zn{constructor(t,e,i){super(),this.id=t,this._onlySymbols=i,e.on("data",(t=>{"source"===t.dataType&&"metadata"===t.sourceDataType&&(this._sourceLoaded=!0),this._sourceLoaded&&!this._paused&&"source"===t.dataType&&"content"===t.sourceDataType&&(this.reload(),this.transform&&this.update(this.transform))})),e.on("error",(()=>{this._sourceErrored=!0})),this._source=e,this._tiles={},this._cache=new Yy(0,this._unloadTile.bind(this)),this._timers={},this._cacheTimers={},this._minTileCacheSize=e.minTileCacheSize,this._maxTileCacheSize=e.maxTileCacheSize,this._loadedParentTiles={},this.castsShadows=!1,this.tileCoverLift=0,this._coveredTiles={},this._shadowCasterTiles={},this._state=new km,this._isRaster="raster"===this._source.type||"raster-dem"===this._source.type||"raster-array"===this._source.type||"custom"===this._source.type&&"raster"===this._source._dataType}onAdd(t){this.map=t,this._minTileCacheSize=void 0===this._minTileCacheSize&&t?t._minTileCacheSize:this._minTileCacheSize,this._maxTileCacheSize=void 0===this._maxTileCacheSize&&t?t._maxTileCacheSize:this._maxTileCacheSize}loaded(){if(this._sourceErrored)return!0;if(!this._sourceLoaded)return!1;if(!this._source.loaded())return!1;for(const t in this._tiles){const e=this._tiles[t];if("errored"!==e.state&&("loaded"!==e.state||!e.bucketsLoaded()))return!1}return!0}getSource(){return this._source}pause(){this._paused=!0}resume(){if(!this._paused)return;const t=this._shouldReloadOnResume;this._paused=!1,this._shouldReloadOnResume=!1,t&&this.reload(),this.transform&&this.update(this.transform)}_loadTile(t,e){return t.isSymbolTile=this._onlySymbols,t.isExtraShadowCaster=this._shadowCasterTiles[t.tileID.key],this._source.loadTile(t,e)}_unloadTile(t){if(this._source.unloadTile)return this._source.unloadTile(t)}_abortTile(t){if(this._source.abortTile)return this._source.abortTile(t)}serialize(){return this._source.serialize()}prepare(t){this._source.prepare&&this._source.prepare(),this._state.coalesceChanges(this._tiles,this.map?this.map.painter:null);for(const e in this._tiles){const i=this._tiles[e];i.upload(t),i.prepare(this.map.style.imageManager,this.map?this.map.painter:null,this._source.scope)}}getIds(){return ti(this._tiles).map((t=>t.tileID)).sort(Ky).map((t=>t.key))}getRenderableIds(t,e){const i=[];for(const n in this._tiles)this._isIdRenderable(+n,t,e)&&i.push(this._tiles[n]);return t?i.sort(((t,e)=>{const i=t.tileID,n=e.tileID,r=new Ue(i.canonical.x,i.canonical.y)._rotate(this.transform.angle),o=new Ue(n.canonical.x,n.canonical.y)._rotate(this.transform.angle);return i.overscaledZ-n.overscaledZ||o.y-r.y||o.x-r.x})).map((t=>t.tileID.key)):i.map((t=>t.tileID)).sort(Ky).map((t=>t.key))}hasRenderableParent(t){const e=this.findLoadedParent(t,0);return!!e&&this._isIdRenderable(e.tileID.key)}_isIdRenderable(t,e,i){return this._tiles[t]&&this._tiles[t].hasData()&&!this._coveredTiles[t]&&(e||!this._tiles[t].holdingForFade())&&(i||!this._shadowCasterTiles[t])}reload(){if(this._paused)this._shouldReloadOnResume=!0;else{this._cache.reset();for(const t in this._tiles)"errored"!==this._tiles[t].state&&this._reloadTile(+t,"reloading")}}_reloadTile(t,e){const i=this._tiles[t];i&&("loading"!==i.state&&(i.state=e),this._loadTile(i,this._tileLoaded.bind(this,i,t,e)))}_tileLoaded(t,e,i,n){if(n)if(t.state="errored",404!==n.status)this._source.fire(new $n(n,{tile:t}));else{if(!(t.tileID.key in this._loadedParentTiles))return void this._source.fire(new Pn("data",{dataType:"source",sourceDataType:"error",sourceId:this._source.id}));if("raster-dem"===this._source.type&&this.usedForTerrain&&this.map.painter.terrain){const t=this.map.painter.terrain;this.update(this.transform,t.getScaledDemTileSize(),!0),t.resetTileLookupCache(this.id)}else this.update(this.transform)}else t.timeAdded=ki.now(),"expired"===i&&(t.refreshedUponExpiration=!0),this._setTileReloadTimer(e,t),"raster-dem"===this._source.type&&t.dem&&this._backfillDEM(t),this._state.initializeTileState(t,this.map?this.map.painter:null),this._source.fire(new Pn("data",{dataType:"source",tile:t,coord:t.tileID,sourceCacheId:this.id}))}_backfillDEM(t){const e=this.getRenderableIds();for(let n=0;n1||(Math.abs(i)>1&&(1===Math.abs(i+r)?i+=r:1===Math.abs(i-r)&&(i-=r)),e.dem&&t.dem&&(t.dem.backfillBorder(e.dem,i,n),t.neighboringTiles&&t.neighboringTiles[o]&&(t.neighboringTiles[o].backfilled=!0)))}}getTile(t){return this.getTileByID(t.key)}getTileByID(t){return this._tiles[t]}_retainLoadedChildren(t,e,i,n){for(const r in this._tiles){let o=this._tiles[r];if(n[r]||!o.hasData()||o.tileID.overscaledZi)continue;let s=o.tileID;for(;o&&o.tileID.overscaledZ>e+1;){const t=o.tileID.scaledTo(o.tileID.overscaledZ-1);o=this._tiles[t.key],o&&o.hasData()&&(s=t)}let a=s;for(;a.overscaledZ>e;)if(a=a.scaledTo(a.overscaledZ-1),t[a.key]){n[s.key]=s;break}}}findLoadedParent(t,e){if(t.key in this._loadedParentTiles){const i=this._loadedParentTiles[t.key];return i&&i.tileID.overscaledZ>=e?i:null}for(let i=t.overscaledZ-1;i>=e;i--){const e=t.scaledTo(i),n=this._getLoadedTile(e);if(n)return n}}_getLoadedTile(t){const e=this._tiles[t.key];return e&&e.hasData()?e:this._cache.getByKey(this._source.reparseOverscaled?t.wrapped().key:t.canonical.key)}updateCacheSize(t,e){e=e||this._source.tileSize;const i=Math.ceil(t.width/e)+1,n=Math.ceil(t.height/e)+1,r=Math.floor(i*n*5),o="number"==typeof this._minTileCacheSize?Math.max(this._minTileCacheSize,r):r,s="number"==typeof this._maxTileCacheSize?Math.min(this._maxTileCacheSize,o):o;this._cache.setMaxSize(s)}handleWrapJump(t){const e=Math.round((t-(void 0===this._prevLng?t:this._prevLng))/360);if(this._prevLng=t,e){const t={};for(const i in this._tiles){const n=this._tiles[i];n.tileID=n.tileID.unwrapTo(n.tileID.wrap+e),t[n.tileID.key]=n}this._tiles=t;for(const t in this._timers)clearTimeout(this._timers[t]),delete this._timers[t];for(const t in this._tiles)this._setTileReloadTimer(+t,this._tiles[t])}}update(t,e,i,n){if(this.transform=t,!this._sourceLoaded||this._paused||this.transform.freezeTileCoverage)return;if(this.usedForTerrain&&!i)return;let r;if(this.updateCacheSize(t,e),"globe"!==this.transform.projection.name&&this.handleWrapJump(this.transform.center.lng),this._shadowCasterTiles={},this._coveredTiles={},this.used||this.usedForTerrain){if(this._source.tileID)r=t.getVisibleUnwrappedCoordinates(this._source.tileID).map((t=>new vd(t.canonical.z,t.wrap,t.canonical.z,t.canonical.x,t.canonical.y)));else if(0!==this.tileCoverLift){const n=t.clone();n.tileCoverLift=this.tileCoverLift,r=n.coveringTiles({tileSize:e||this._source.tileSize,minzoom:this._source.minzoom,maxzoom:this._source.maxzoom,roundZoom:this._source.roundZoom&&!i,reparseOverscaled:this._source.reparseOverscaled,isTerrainDEM:this.usedForTerrain}),this._source.minzoomt(e)))}}else r=[];if(r.length>0&&this.castsShadows&&n&&"globe"!==this.transform.projection.name&&!this.usedForTerrain&&!Jy(this._source.type)){const o=t.coveringZoomLevel({tileSize:e||this._source.tileSize,roundZoom:this._source.roundZoom&&!i}),s=Math.min(o,this._source.maxzoom),a=t.extendTileCoverForShadows(r,n,s);for(const t of a)this._shadowCasterTiles[t.key]=!0,r.push(t)}const o=this._updateRetainedTiles(r);if(Jy(this._source.type)&&0!==r.length){const t={},e={},i=Object.keys(o);for(const n of i){const i=o[n],r=this._tiles[n];if(!r||r.fadeEndTime&&r.fadeEndTimen;){r=r.scaledTo(r.overscaledZ-1);const n=this._tiles[r.key];if(n&&n.hasData()&&e[r.key]){o[t]=i.tileID;break}}}for(const e in t)o[e]||(this._coveredTiles[e]=!0,o[e]=t[e])}for(const t in o)this._tiles[t].clearFadeHold();const s=function(t,e){const i=[];for(const n in t)n in e||i.push(n);return i}(this._tiles,o);for(const t of s){const e=this._tiles[t];e.hasSymbolBuckets&&!e.holdingForFade()?e.setHoldDuration(this.map._fadeDuration):e.hasSymbolBuckets&&!e.symbolFadeFinished()||this._removeTile(+t)}this._updateLoadedParentTileCache(),this._onlySymbols&&this._source.afterUpdate&&this._source.afterUpdate()}releaseSymbolFadeTiles(){for(const t in this._tiles)this._tiles[t].holdingForFade()&&this._removeTile(+t)}_updateRetainedTiles(t){const e={};if(0===t.length)return e;const i={},n=t.reduce(((t,e)=>Math.min(t,e.overscaledZ)),1/0),r=t[0].overscaledZ,o=Math.max(r-Xy.maxOverzooming,this._source.minzoom),s=Math.max(r+Xy.maxUnderzooming,this._source.minzoom),a={};for(const i of t){const t=this._addTile(i);e[i.key]=i,t.hasData()||n=this._source.maxzoom){const t=n.children(this._source.maxzoom)[0],i=this.getTile(t);if(i&&i.hasData()){e[t.key]=t;continue}}else{const t=n.children(this._source.maxzoom);if(e[t[0].key]&&e[t[1].key]&&e[t[2].key]&&e[t[3].key])continue}let r=t.wasRequested();for(let s=n.overscaledZ-1;s>=o;--s){const o=n.scaledTo(s);if(i[o.key])break;if(i[o.key]=!0,t=this.getTile(o),!t&&r&&(t=this._addTile(o)),t&&(e[o.key]=o,r=t.wasRequested(),t.hasData()))break}}return e}_updateLoadedParentTileCache(){this._loadedParentTiles={};for(const t in this._tiles){const e=[];let i,n=this._tiles[t].tileID;for(;n.overscaledZ>0;){if(n.key in this._loadedParentTiles){i=this._loadedParentTiles[n.key];break}e.push(n.key);const t=n.scaledTo(n.overscaledZ-1);if(i=this._getLoadedTile(t),i)break;n=t}for(const t of e)this._loadedParentTiles[t]=i}}_addTile(t){let e=this._tiles[t.key];if(e)return!0!==e.isExtraShadowCaster||!!this._shadowCasterTiles[t.key]||this._reloadTile(t.key,"reloading"),e;e=this._cache.getAndRemove(t),e&&(this._setTileReloadTimer(t.key,e),e.tileID=t,this._state.initializeTileState(e,this.map?this.map.painter:null),this._cacheTimers[t.key]&&(clearTimeout(this._cacheTimers[t.key]),delete this._cacheTimers[t.key],this._setTileReloadTimer(t.key,e)));const i=Boolean(e);if(!i){const i=this.map?this.map.painter:null,n=this._source.tileSize*t.overscaleFactor();e="raster-array"===this._source.type?new Wy(t,n,this.transform.tileZoom,i,this._isRaster):new ey(t,n,this.transform.tileZoom,i,this._isRaster),this._loadTile(e,this._tileLoaded.bind(this,e,t.key,e.state))}return e?(e.uses++,this._tiles[t.key]=e,i||this._source.fire(new Pn("dataloading",{tile:e,coord:e.tileID,dataType:"source"})),e):null}_setTileReloadTimer(t,e){t in this._timers&&(clearTimeout(this._timers[t]),delete this._timers[t]);const i=e.getExpiryTimeout();i&&(this._timers[t]=setTimeout((()=>{this._reloadTile(t,"expired"),delete this._timers[t]}),i))}_removeTile(t){const e=this._tiles[t];e&&(e.uses--,delete this._tiles[t],this._timers[t]&&(clearTimeout(this._timers[t]),delete this._timers[t]),e.uses>0||(e.hasData()&&"reloading"!==e.state||"empty"===e.state?this._cache.add(e.tileID,e,e.getExpiryTimeout()):(e.aborted=!0,this._abortTile(e),this._unloadTile(e))))}clearTiles(){this._shouldReloadOnResume=!1,this._paused=!1;for(const t in this._tiles)this._removeTile(+t);this._source._clear&&this._source._clear(),this._cache.reset(),this.map&&this.usedForTerrain&&this.map.painter.terrain&&this.map.painter.terrain.resetTileLookupCache(this.id)}tilesIn(t,e,i){const n=[],r=this.transform;if(!r)return n;const o="globe"===r.projection.name,s=Ed(r.center.lng);for(const a in this._tiles){const l=this._tiles[a];if(i&&l.clearQueryDebugViz(),l.holdingForFade())continue;let c;if(o){const t=l.tileID.canonical;if(0===t.z){const e=[Math.abs(Xe(s,...Qy(t,-1))-s),Math.abs(Xe(s,...Qy(t,1))-s)];c=[0,2*e.indexOf(Math.min(...e))-1]}else{const e=[Math.abs(Xe(s,...Qy(t,-1))-s),Math.abs(Xe(s,...Qy(t,0))-s),Math.abs(Xe(s,...Qy(t,1))-s)];c=[e.indexOf(Math.min(...e))-1]}}else c=[0];for(const i of c){const o=t.containsTile(l,r,e,i);o&&n.push(o)}}return n}getShadowCasterCoordinates(){return this._getRenderableCoordinates(!1,!0)}getVisibleCoordinates(t){return this._getRenderableCoordinates(t)}_getRenderableCoordinates(t,e){const i=this.getRenderableIds(t,e).map((t=>this._tiles[t].tileID)),n="globe"===this.transform.projection.name;for(const t of i)t.projMatrix=this.transform.calculateProjMatrix(t.toUnwrapped()),t.expandedProjMatrix=n?this.transform.calculateProjMatrix(t.toUnwrapped(),!1,!0):t.projMatrix;return i}sortCoordinatesByDistance(t){const e=t.slice(),i=this.transform._camera.position,n=this.transform._camera.forward(),r={};for(const t of e){const e=1/(1r[t.key]-r[e.key])),e}hasTransition(){if(this._source.hasTransition())return!0;if(Jy(this._source.type))for(const t in this._tiles){const e=this._tiles[t];if(void 0!==e.fadeEndTime&&e.fadeEndTime>=ki.now())return!0}return!1}setFeatureState(t,e,i){this._state.updateState(t=t||"_geojsonTileLayer",e,i)}removeFeatureState(t,e,i){this._state.removeFeatureState(t=t||"_geojsonTileLayer",e,i)}getFeatureState(t,e){return this._state.getState(t=t||"_geojsonTileLayer",e)}setDependencies(t,e,i){const n=this._tiles[t];n&&n.setDependencies(e,i)}reloadTilesForDependencies(t,e){for(const i in this._tiles)this._tiles[i].hasDependency(t,e)&&this._reloadTile(+i,"reloading");this._cache.filter((i=>!i.hasDependency(t,e)))}_preloadTiles(t,e){if(!this._sourceLoaded){const i=()=>{this._sourceLoaded&&(this._source.off("data",i),this._preloadTiles(t,e))};return void this._source.on("data",i)}const i=new Map,n=Array.isArray(t)?t:[t],r=this.map.painter.terrain,o=this.usedForTerrain&&r?r.getScaledDemTileSize():this._source.tileSize;for(const t of n){const e=t.coveringTiles({tileSize:o,minzoom:this._source.minzoom,maxzoom:this._source.maxzoom,roundZoom:this._source.roundZoom&&!this.usedForTerrain,reparseOverscaled:this._source.reparseOverscaled,isTerrainDEM:this.usedForTerrain});for(const t of e)i.set(t.key,t);this.usedForTerrain&&t.updateElevation(!1)}Qe(Array.from(i.values()),((t,e)=>{const i=new ey(t,this._source.tileSize*t.overscaleFactor(),this.transform.tileZoom,this.map.painter,this._isRaster);this._loadTile(i,(t=>{"raster-dem"===this._source.type&&i.dem&&this._backfillDEM(i),e(t,i)}))}),e)}}function Ky(t,e){const i=Math.abs(2*t.wrap)-+(t.wrap0?e+2*t:t}tv.useIntegerZoom=!0;const iv=new ol({"symbol-placement":new il(sl.layout_symbol["symbol-placement"]),"symbol-spacing":new il(sl.layout_symbol["symbol-spacing"]),"symbol-avoid-edges":new il(sl.layout_symbol["symbol-avoid-edges"]),"symbol-sort-key":new nl(sl.layout_symbol["symbol-sort-key"]),"symbol-z-order":new il(sl.layout_symbol["symbol-z-order"]),"symbol-z-elevate":new il(sl.layout_symbol["symbol-z-elevate"]),"icon-allow-overlap":new il(sl.layout_symbol["icon-allow-overlap"]),"icon-ignore-placement":new il(sl.layout_symbol["icon-ignore-placement"]),"icon-optional":new il(sl.layout_symbol["icon-optional"]),"icon-rotation-alignment":new il(sl.layout_symbol["icon-rotation-alignment"]),"icon-size":new nl(sl.layout_symbol["icon-size"]),"icon-text-fit":new nl(sl.layout_symbol["icon-text-fit"]),"icon-text-fit-padding":new nl(sl.layout_symbol["icon-text-fit-padding"]),"icon-image":new nl(sl.layout_symbol["icon-image"]),"icon-rotate":new nl(sl.layout_symbol["icon-rotate"]),"icon-padding":new il(sl.layout_symbol["icon-padding"]),"icon-keep-upright":new il(sl.layout_symbol["icon-keep-upright"]),"icon-offset":new nl(sl.layout_symbol["icon-offset"]),"icon-anchor":new nl(sl.layout_symbol["icon-anchor"]),"icon-pitch-alignment":new il(sl.layout_symbol["icon-pitch-alignment"]),"text-pitch-alignment":new il(sl.layout_symbol["text-pitch-alignment"]),"text-rotation-alignment":new il(sl.layout_symbol["text-rotation-alignment"]),"text-field":new nl(sl.layout_symbol["text-field"]),"text-font":new nl(sl.layout_symbol["text-font"]),"text-size":new nl(sl.layout_symbol["text-size"]),"text-max-width":new nl(sl.layout_symbol["text-max-width"]),"text-line-height":new nl(sl.layout_symbol["text-line-height"]),"text-letter-spacing":new nl(sl.layout_symbol["text-letter-spacing"]),"text-justify":new nl(sl.layout_symbol["text-justify"]),"text-radial-offset":new nl(sl.layout_symbol["text-radial-offset"]),"text-variable-anchor":new il(sl.layout_symbol["text-variable-anchor"]),"text-anchor":new nl(sl.layout_symbol["text-anchor"]),"text-max-angle":new il(sl.layout_symbol["text-max-angle"]),"text-writing-mode":new il(sl.layout_symbol["text-writing-mode"]),"text-rotate":new nl(sl.layout_symbol["text-rotate"]),"text-padding":new il(sl.layout_symbol["text-padding"]),"text-keep-upright":new il(sl.layout_symbol["text-keep-upright"]),"text-transform":new nl(sl.layout_symbol["text-transform"]),"text-offset":new nl(sl.layout_symbol["text-offset"]),"text-allow-overlap":new il(sl.layout_symbol["text-allow-overlap"]),"text-ignore-placement":new il(sl.layout_symbol["text-ignore-placement"]),"text-optional":new il(sl.layout_symbol["text-optional"]),visibility:new il(sl.layout_symbol.visibility)});var nv={paint:new ol({"icon-opacity":new nl(sl.paint_symbol["icon-opacity"]),"icon-occlusion-opacity":new nl(sl.paint_symbol["icon-occlusion-opacity"]),"icon-emissive-strength":new nl(sl.paint_symbol["icon-emissive-strength"]),"text-emissive-strength":new nl(sl.paint_symbol["text-emissive-strength"]),"icon-color":new nl(sl.paint_symbol["icon-color"]),"icon-halo-color":new nl(sl.paint_symbol["icon-halo-color"]),"icon-halo-width":new nl(sl.paint_symbol["icon-halo-width"]),"icon-halo-blur":new nl(sl.paint_symbol["icon-halo-blur"]),"icon-translate":new il(sl.paint_symbol["icon-translate"]),"icon-translate-anchor":new il(sl.paint_symbol["icon-translate-anchor"]),"icon-image-cross-fade":new nl(sl.paint_symbol["icon-image-cross-fade"]),"text-opacity":new nl(sl.paint_symbol["text-opacity"]),"text-occlusion-opacity":new nl(sl.paint_symbol["text-occlusion-opacity"]),"text-color":new nl(sl.paint_symbol["text-color"],{runtimeType:Qn,getOverride:t=>t.textColor,hasOverride:t=>!!t.textColor}),"text-halo-color":new nl(sl.paint_symbol["text-halo-color"]),"text-halo-width":new nl(sl.paint_symbol["text-halo-width"]),"text-halo-blur":new nl(sl.paint_symbol["text-halo-blur"]),"text-translate":new il(sl.paint_symbol["text-translate"]),"text-translate-anchor":new il(sl.paint_symbol["text-translate-anchor"]),"icon-color-saturation":new il(sl.paint_symbol["icon-color-saturation"]),"icon-color-contrast":new il(sl.paint_symbol["icon-color-contrast"]),"icon-color-brightness-min":new il(sl.paint_symbol["icon-color-brightness-min"]),"icon-color-brightness-max":new il(sl.paint_symbol["icon-color-brightness-max"])}),layout:iv};class rv{constructor(t){this.type=t.property.overrides?t.property.overrides.runtimeType:Yn,this.defaultValue=t}evaluate(t){if(t.formattedSection){const e=this.defaultValue.property.overrides;if(e&&e.hasOverride(t.formattedSection))return e.getOverride(t.formattedSection)}return t.feature&&t.featureState?this.defaultValue.evaluate(t.feature,t.featureState):this.defaultValue.property.specification.default}eachChild(t){this.defaultValue.isConstant()||t(this.defaultValue.value._styleExpression.expression)}outputDefined(){return!1}serialize(){return null}}ba(rv,"FormatSectionOverride",{omit:["defaultValue"]});class ov extends Ml{constructor(e,i,n,r){super(e,nv,i,n,r),this._colorAdjustmentMatrix=t.ad.identity([]),this.hasInitialOcclusionOpacityProperties=void 0!==e.paint&&("icon-occlusion-opacity"in e.paint||"text-occlusion-opacity"in e.paint)}recalculate(t,e){super.recalculate(t,e),"auto"===this.layout.get("icon-rotation-alignment")&&(this.layout._values["icon-rotation-alignment"]="point"!==this.layout.get("symbol-placement")?"map":"viewport"),"auto"===this.layout.get("text-rotation-alignment")&&(this.layout._values["text-rotation-alignment"]="point"!==this.layout.get("symbol-placement")?"map":"viewport"),"auto"===this.layout.get("text-pitch-alignment")&&(this.layout._values["text-pitch-alignment"]=this.layout.get("text-rotation-alignment")),"auto"===this.layout.get("icon-pitch-alignment")&&(this.layout._values["icon-pitch-alignment"]=this.layout.get("icon-rotation-alignment"));const i=this.layout.get("text-writing-mode");if(i){const t=[];for(const e of i)t.indexOf(e)i in t?String(t[i]):""))}(e.properties,r)}createBucket(t){return new jg(t)}queryRadius(){return 0}queryIntersectsFeature(){return!1}_setPaintOverrides(){for(const t of nv.paint.overridableProperties){if(!ov.hasPaintOverride(this.layout,t))continue;const e=this.paint.get(t),i=new rv(e),n=new la(i,e.property.specification,this.scope,this.options);let r=null;r="constant"===e.value.kind||"source"===e.value.kind?new ua("source",n):new ha("composite",n,e.value.zoomStops,e.value._interpolationType),this.paint._values[t]=new tl(e.property,r,e.parameters)}}_handleOverridablePaintPropertyUpdate(t,e,i){return!(!this.layout||e.isDataDriven()||i.isDataDriven())&&ov.hasPaintOverride(this.layout,t)}static hasPaintOverride(t,e){const i=t.get("text-field"),n=nv.paint.properties[e];let r=!1;const o=t=>{for(const e of t)if(n.overrides&&n.overrides.hasOverride(e))return void(r=!0)};if("constant"===i.value.kind&&i.value.value instanceof pr)o(i.value.value.sections);else if("source"===i.value.kind){const t=e=>{r||(e instanceof vr&&gr(e.value)===nr?o(e.value.sections):e instanceof Tr?o(e.sections):e.eachChild(t))},e=i.value;e._styleExpression&&t(e._styleExpression.expression)}return r}getProgramIds(){const t=0!==this.paint.get("icon-opacity").constantOr(1),e=0!==this.paint.get("text-opacity").constantOr(1),i=[];return t&&i.push("symbolIcon"),e&&i.push("symbolSDF"),i}getDefaultProgramParams(t,e,i){return{config:new Wc(this,{zoom:e,lut:i}),overrideFog:!1}}}const sv=new ol({visibility:new il(sl.layout_background.visibility)});var av={paint:new ol({"background-color":new il(sl.paint_background["background-color"]),"background-pattern":new il(sl.paint_background["background-pattern"]),"background-opacity":new il(sl.paint_background["background-opacity"]),"background-emissive-strength":new il(sl.paint_background["background-emissive-strength"])}),layout:sv};const lv=new ol({visibility:new il(sl.layout_raster.visibility)});var cv={paint:new ol({"raster-opacity":new il(sl.paint_raster["raster-opacity"]),"raster-color":new rl(sl.paint_raster["raster-color"]),"raster-color-mix":new il(sl.paint_raster["raster-color-mix"]),"raster-color-range":new il(sl.paint_raster["raster-color-range"]),"raster-hue-rotate":new il(sl.paint_raster["raster-hue-rotate"]),"raster-brightness-min":new il(sl.paint_raster["raster-brightness-min"]),"raster-brightness-max":new il(sl.paint_raster["raster-brightness-max"]),"raster-saturation":new il(sl.paint_raster["raster-saturation"]),"raster-contrast":new il(sl.paint_raster["raster-contrast"]),"raster-resampling":new il(sl.paint_raster["raster-resampling"]),"raster-fade-duration":new il(sl.paint_raster["raster-fade-duration"]),"raster-emissive-strength":new il(sl.paint_raster["raster-emissive-strength"]),"raster-array-band":new il(sl.paint_raster["raster-array-band"]),"raster-elevation":new il(sl.paint_raster["raster-elevation"])}),layout:lv};function dv(e,i,n,r,o,s,a,l){const c=[e,i,1,n,r,1,o,s,1],d=[a,l,1],u=t.bC.adjoint([],c),[h,p,f]=t._.transformMat3(d,d,u);return t.bC.multiply(c,c,[h,0,0,0,p,0,0,0,f])}function uv(e,i,n,r,o,s,a,l){const c=function(e,i,n,r,o,s,a,l){const c=dv(0,0,1,0,1,1,0,1),d=dv(e,i,n,r,o,s,a,l),u=t.bC.adjoint([],c);return t.bC.multiply(d,d,u)}(e,i,n,r,o,s,a,l);return[c[2]/c[8]/uo,c[5]/c[8]/uo]}function hv(t){return[t[0],Math.min(Math.max(t[1],-Pd),Pd)]}class pv extends zn{constructor(t,e,i,n){super(),this.id=t,this.dispatcher=i,this.coordinates=e.coordinates,this.type="image",this.minzoom=0,this.maxzoom=22,this.tileSize=512,this.tiles={},this._loaded=!1,this.onNorthPole=!1,this.onSouthPole=!1,this.setEventedParent(n),this.options=e,this._dirty=!1}load(t,e){if(this._loaded=e||!1,this.fire(new Pn("dataloading",{dataType:"source"})),this.url=this.options.url,!this.url)return t&&(this.coordinates=t),this._loaded=!0,void this._finishLoading();this._imageRequest=an(this.map._requestManager.transformRequest(this.url,Ki.Image),((e,i)=>{this._imageRequest=null,this._loaded=!0,e?this.fire(new $n(e)):i&&(this.image=i instanceof HTMLImageElement?ki.getImageData(i):i,this._dirty=!0,this.width=this.image.width,this.height=this.image.height,t&&(this.coordinates=t),this._finishLoading())}))}loaded(){return this._loaded}updateImage(t){return t.url?(this._imageRequest&&t.url!==this.options.url&&(this._imageRequest.cancel(),this._imageRequest=null),this.options.url=t.url,this.load(t.coordinates,this._loaded),this):this}setTexture(t){if(!(t.handle instanceof WebGLTexture))throw new Error("The provided handle is not a WebGLTexture instance");return this.texture=new Gg(this.map.painter.context,t.handle),this.width=t.dimensions[0],this.height=t.dimensions[1],this._dirty=!1,this._loaded=!0,this._finishLoading(),this}_finishLoading(){this.map&&(this.setCoordinates(this.coordinates),this.fire(new Pn("data",{dataType:"source",sourceDataType:"metadata"})))}onAdd(t){this.map=t,this.load()}onRemove(t){this._imageRequest&&(this._imageRequest.cancel(),this._imageRequest=null),!this.texture||this.texture instanceof Gg||this.texture.destroy(),this.boundsBuffer&&(this.boundsBuffer.destroy(),this.elevatedGlobeVertexBuffer&&this.elevatedGlobeVertexBuffer.destroy(),this.elevatedGlobeIndexBuffer&&this.elevatedGlobeIndexBuffer.destroy())}setCoordinates(t){if(this.coordinates=t,this._boundsArray=void 0,this._unsupportedCoords=!1,!t.length)return this;this.onNorthPole=!1,this.onSouthPole=!1;let e=t[0][1],i=t[0][1];for(const n of t)n[1]>i&&(i=n[1]),n[1]Pd?this.onNorthPole=!0:n1&&(l-=1),new gd(s,l,Math.floor((i+r)/2*a))}(e),this.minzoom=this.maxzoom=this.tileID.z}return this.fire(new Pn("data",{dataType:"source",sourceDataType:"content"})),this}_clear(){this._boundsArray=void 0,this._unsupportedCoords=!1}_prepareData(e){for(const t in this.tiles){const e=this.tiles[t];"loaded"!==e.state&&(e.state="loaded",e.texture=this.texture)}if(this._boundsArray||this.onNorthPole||this.onSouthPole||this._unsupportedCoords)return;const i=eg(new gd(0,0,0),this.map.transform.projection),n=[i.projection.project(this.coordinates[0][0],this.coordinates[0][1]),i.projection.project(this.coordinates[1][0],this.coordinates[1][1]),i.projection.project(this.coordinates[2][0],this.coordinates[2][1]),i.projection.project(this.coordinates[3][0],this.coordinates[3][1])];if(!function(t){const e=t[1].x-t[0].x,i=t[1].y-t[0].y,n=t[2].x-t[1].x,r=t[2].y-t[1].y,o=t[3].x-t[2].x,s=t[3].y-t[2].y,a=t[0].x-t[3].x,l=t[0].y-t[3].y,c=e*r-n*i,d=n*s-o*r,u=o*l-a*s,h=a*i-e*l;return c>0&&d>0&&u>0&&h>0||c{const e=r.projection.project(t[0],t[1]);return ig(r,e)._round()}));this.perspectiveTransform=uv(o.x,o.y,s.x,s.y,a.x,a.y,l.x,l.y);const c=this._boundsArray=new Dl;c.emplaceBack(o.x,o.y,0,0),c.emplaceBack(s.x,s.y,uo,0),c.emplaceBack(l.x,l.y,0,uo),c.emplaceBack(a.x,a.y,uo,uo),this.boundsBuffer&&(this.boundsBuffer.destroy(),this.elevatedGlobeVertexBuffer&&this.elevatedGlobeVertexBuffer.destroy(),this.elevatedGlobeIndexBuffer&&this.elevatedGlobeIndexBuffer.destroy()),this.boundsBuffer=e.createVertexBuffer(c,Jg.members),this.boundsSegments=wc.simpleSegment(0,0,4,2);const d=[],u=function(t){return[hv(t[0]),hv(t[1]),hv(t[2]),hv(t[3])]}(this.coordinates),[h,p,f,m]=function(t){let e=t[0][0],i=e,n=t[0][1],r=n;for(let o=1;oi&&(i=t[o][0]),t[o][1]r&&(r=t[o][1]);return[e,n,i-e,r-n]}(u);{const r=new Dl,[o,s,a,l]=function(t){let e=t[0].x,i=e,n=t[0].y,r=n;for(let o=1;oi&&(i=t[o].x),t[o].yr&&(r=t[o].y);return[e,n,i-e,r-n]}(n),c=t=>[(t.x-o)/a,(t.y-s)/l],[u,_,g,y]=n.map(c),v=function(e,i,n,r,o,s,a,l){const c=dv(0,0,1,0,1,1,0,1),d=dv(e,i,n,r,o,s,a,l),u=t.bC.adjoint([],d);return t.bC.multiply(c,c,u)}(u[0],u[1],_[0],_[1],g[0],g[1],y[0],y[1]);this.elevatedGlobePerspectiveTransform=uv(u[0],u[1],_[0],_[1],g[0],g[1],y[0],y[1]);const x=(e,i)=>{d.push(e.lng);const n=Math.round((e.lng-h)/f*uo),o=Math.round((e.lat-p)/m*uo),s=c(i),a=t._.transformMat3([],[s[0],s[1],1],v),l=Math.round(a[0]/a[2]*uo),u=Math.round(a[1]/a[2]*uo);r.emplaceBack(n,o,l,u)},b=n[3].x-n[0].x,w=n[3].y-n[0].y,T=n[2].x-n[1].x,S=n[2].y-n[1].y;for(let t=0;t{i.emplaceBack(e,n,r);const o=d[e],s=d[n],a=d[r],l=Math.min(Math.min(o,s),a),c=Math.max(Math.max(o,s),a)-l;c>this.maxLongitudeTriangleSize&&(this.maxLongitudeTriangleSize=c),t.push(l+c/2)};for(let t=0;te));i.sort(((e,i)=>t[e]-t[i]));const n=[],r=new Kl;for(let o=0;o{o.segments.push({vertexOffset:0,primitiveOffset:t,vertexLength:e.segments[0].vertexLength,primitiveLength:i,sortKey:void 0,vaos:{}})},a=.51*this.maxLongitudeTriangleSize;if(Math.abs(i[0]-n)0){const n=function(e,i){const n=i.worldSize,r=Cd(1,0)*n*kd(i.center.lat,i.zoom)/Gu(n),o=Cd(1,i.center.lat)*n,s=t.ad.identity([]);return t.ad.rotateY(s,s,Ge(i.center.lng)),t.ad.rotateX(s,s,Ge(i.center.lat)),t.ad.translate(s,s,[0,0,ed]),t.ad.scale(s,s,[r,r,r*o]),t.ad.translate(s,s,[i.point.x-.5*n,i.point.y-.5*n,0]),t.ad.multiply(s,s,e),t.ad.multiply(s,i.globeMatrix,s)}(e,i);return function(e,i,n){const r=(e,i,n)=>{const r=t._.length(e),o=t._.length(i),s=ku(e,i,n);return t._.scale(s,s,1/t._.length(s)*Vn(r,o,n))},o=r([e[0],e[1],e[2]],[i[0],i[1],i[2]],n),s=r([e[4],e[5],e[6]],[i[4],i[5],i[6]],n),a=r([e[8],e[9],e[10]],[i[8],i[9],i[10]],n),l=ku([e[12],e[13],e[14]],[i[12],i[13],i[14]],n);return[o[0],o[1],o[2],0,s[0],s[1],s[2],0,a[0],a[1],a[2],0,l[0],l[1],l[2],1]}(o,n,r)}return o}function kv(t,e,i,n){const r=wu.projectAabbCorners(n,i);let o=Number.MAX_VALUE,s=-1;for(let t=0;tnew Ue(r[t][0],r[t][1]);let l;switch(s){case 0:case 6:l=[a(1),a(5),a(4),a(7),a(3),a(2),a(1)];break;case 1:case 7:l=[a(0),a(4),a(5),a(6),a(2),a(3),a(0)];break;case 3:case 5:l=[a(1),a(0),a(4),a(7),a(6),a(2),a(1)];break;default:l=[a(1),a(5),a(6),a(7),a(3),a(0),a(1)]}if(Yd(t,l))return o}const Dv=Ll([{name:"a_pos_3f",components:3,type:"Float32"}]),zv=Ll([{name:"a_color_3f",components:3,type:"Float32"}]),Rv=Ll([{name:"a_color_4f",components:4,type:"Float32"}]),Ov=Ll([{name:"a_uv_2f",components:2,type:"Float32"}]),Bv=Ll([{name:"a_normal_3f",components:3,type:"Float32"}]),Fv=Ll([{name:"a_normal_matrix0",components:4,type:"Float32"},{name:"a_normal_matrix1",components:4,type:"Float32"},{name:"a_normal_matrix2",components:4,type:"Float32"},{name:"a_normal_matrix3",components:4,type:"Float32"}]),Nv=Ll([{name:"a_pbr",components:4,type:"Uint16"},{name:"a_heightBasedEmissiveStrength",components:3,type:"Float32"}]);class Uv{constructor(t,e,i,n){this.message=(t?`${t}: `:"")+i,n&&(this.identifier=n),null!=e&&e.__line__&&(this.line=e.__line__)}}function jv(t,e){const i=-1===t.indexOf("://");try{return new URL(t,i&&e?"http://example.com":void 0),!0}catch(t){return!1}}class Vv{constructor(t,e){this.feature=t,this.instancedDataOffset=e,this.instancedDataCount=0,this.rotation=[0,0,0],this.scale=[1,1,1],this.translation=[0,0,0]}}class Gv{constructor(){this.instancedDataArray=new oc,this.instancesEvaluatedElevation=[],this.features=[],this.idToFeaturesIndex={}}}class Zv{constructor(t){this.zoom=t.zoom,this.canonical=t.canonical,this.layers=t.layers,this.layerIds=this.layers.map((t=>t.fqid)),this.projection=t.projection,this.index=t.index,this.hasZoomDependentProperties=this.layers[0].isZoomDependent(),this.stateDependentLayerIds=this.layers.filter((t=>t.isStateDependent())).map((t=>t.id)),this.hasPattern=!1,this.instancesPerModel={},this.validForExaggeration=0,this.maxVerticalOffset=0,this.maxScale=0,this.maxHeight=0,this.lookupDim=this.zoom>this.canonical.z?256:this.zoom>15?75:100,this.instanceCount=0,this.terrainElevationMin=0,this.terrainElevationMax=0,this.validForDEMTile={id:null,timestamp:0},this.modelUris=[],this.modelsRequested=!1,this.activeReplacements=[],this.replacementUpdateTime=0}updateFootprints(t,e){}populate(t,e,i,n){this.tileToMeter=zd(i);const r=this.layers[0]._featureFilter.needGeometry;this.lookup=new Uint8Array(this.lookupDim*this.lookupDim);for(const{feature:o,id:s,index:a,sourceLayerIndex:l}of t){const t=null!=s?s:o.properties&&o.properties.hasOwnProperty("id")?o.properties.id:void 0,c=Zd(o,r);if(!this.layers[0]._featureFilter.filter(new Ha(this.zoom),c,i))continue;const d={id:t,sourceLayerIndex:l,index:a,geometry:r?c.geometry:Gd(o,i,n),properties:o.properties,type:o.type,patterns:{}},u=this.addFeature(d,d.geometry,c);u&&e.featureIndex.insert(o,d.geometry,a,l,this.index,this.instancesPerModel[u].instancedDataArray.length,uo/32)}this.lookup=null}update(t,e,i,n){for(const e in this.instancesPerModel){const i=this.instancesPerModel[e];for(const e in t)i.idToFeaturesIndex.hasOwnProperty(e)&&(this.evaluate(i.features[i.idToFeaturesIndex[e]],t[e],i,!0),this.uploaded=!1)}this.maxHeight=0}updateZoomBasedPaintProperties(){if(!this.hasZoomDependentProperties)return!1;let e=!1;for(const i in this.instancesPerModel){const n=this.instancesPerModel[i];for(const i of n.features){const r=this.layers[0],o=i.feature,s=this.canonical,a=r.paint.get("model-rotation").evaluate(o,{},s),l=r.paint.get("model-scale").evaluate(o,{},s),c=r.paint.get("model-translation").evaluate(o,{},s);t._.exactEquals(i.rotation,a)&&t._.exactEquals(i.scale,l)&&t._.exactEquals(i.translation,c)||(this.evaluate(i,i.featureStates,n,!0),e=!0)}}return e}updateReplacement(t,e,i){if(e.updateTime===this.replacementUpdateTime)return!1;this.replacementUpdateTime=e.updateTime;const n=e.getReplacementRegionsForTile(t.toUnwrapped(),!0);if(Pp(this.activeReplacements,n))return!1;this.activeReplacements=n;let r=!1;for(const e in this.instancesPerModel){const n=this.instancesPerModel[e],o=n.instancedDataArray;for(const e of n.features){const n=e.instancedDataOffset,s=e.instancedDataCount;for(let e=0;euo?a-uo:a;const l=Math.floor(a),c=o.float32[s+1];let d=!1;for(const e of this.activeReplacements)if(!(e.orderl||l>e.max.x||e.min.y>c||c>e.max.y)&&(d=Op(Rp(l,c,t.canonical,e.footprintTileId.canonical),e),d))break;o.float32[s]=d?a+uo:a,r=r||d}}}return r}isEmpty(){for(const t in this.instancesPerModel)if(0!==this.instancesPerModel[t].instancedDataArray.length)return!1;return!0}uploadPending(){return!this.uploaded}upload(t){if(!this.uploaded)for(const e in this.instancesPerModel){const i=this.instancesPerModel[e];i.instancedDataArray.length=uo||e.y=uo)continue;const t=(this.lookupDim-1)/uo,i=this.lookupDim*(e.y*t|0)+e.x*t|0;if(this.lookup){if(0!==this.lookup[i])continue;this.lookup[i]=1}this.instanceCount++;const n=s.length;s.resize(n+1),o.instancesEvaluatedElevation.push(0),s.float32[16*n]=e.x,s.float32[16*n+1]=e.y}return a.instancedDataCount=o.instancedDataArray.length-a.instancedDataOffset,a.instancedDataCount>0&&(t.id&&(o.idToFeaturesIndex[t.id]=o.features.length),o.features.push(a),this.evaluate(a,{},o,!1)),r}getModelUris(){return this.modelUris}evaluate(t,e,i,n){const r=this.layers[0],o=t.feature,s=this.canonical,a=t.rotation=r.paint.get("model-rotation").evaluate(o,e,s),l=t.scale=r.paint.get("model-scale").evaluate(o,e,s),c=t.translation=r.paint.get("model-translation").evaluate(o,e,s),d=r.paint.get("model-color").evaluate(o,e,s);d.a=r.paint.get("model-color-mix-intensity").evaluate(o,e,s);const u=[];this.maxVerticalOffset10?this.tileToMeter:zd(s,p)),a[o+4]=c[0],a[o+5]=c[1],a[o+6]=c[2]+l,a[o+7]=u[0],a[o+8]=u[1],a[o+9]=u[2],a[o+10]=u[4],a[o+11]=u[5],a[o+12]=u[6],a[o+13]=u[8],a[o+14]=u[9],a[o+15]=u[10],i.instancesEvaluatedElevation[r]=c[2]}}}ba(Zv,"ModelBucket",{omit:["layers"]}),ba(Gv,"PerModelAttributes"),ba(Vv,"ModelFeature");const qv=new ol({visibility:new il(sl.layout_model.visibility),"model-id":new nl(sl.layout_model["model-id"])});var Hv={paint:new ol({"model-opacity":new il(sl.paint_model["model-opacity"]),"model-rotation":new nl(sl.paint_model["model-rotation"]),"model-scale":new nl(sl.paint_model["model-scale"]),"model-translation":new nl(sl.paint_model["model-translation"]),"model-color":new nl(sl.paint_model["model-color"]),"model-color-mix-intensity":new nl(sl.paint_model["model-color-mix-intensity"]),"model-type":new il(sl.paint_model["model-type"]),"model-cast-shadows":new il(sl.paint_model["model-cast-shadows"]),"model-receive-shadows":new il(sl.paint_model["model-receive-shadows"]),"model-ambient-occlusion-intensity":new il(sl.paint_model["model-ambient-occlusion-intensity"]),"model-emissive-strength":new nl(sl.paint_model["model-emissive-strength"]),"model-roughness":new nl(sl.paint_model["model-roughness"]),"model-height-based-emissive-strength-multiplier":new nl(sl.paint_model["model-height-based-emissive-strength-multiplier"]),"model-cutoff-fade-range":new il(sl.paint_model["model-cutoff-fade-range"]),"model-front-cutoff":new il(sl.paint_model["model-front-cutoff"])}),layout:qv};const Wv=64,Yv={CoordinateSpaceTile:1,CoordinateSpaceYUp:2,HasMapboxMeshFeatures:4,HasMeshoptCompression:8};function Xv(e,i,n,r,o,s,a,l,c,d=!1){const u=n.zoom,h=n.project(r),p=kd(r.lat,u),f=1/p;t.ad.identity(e),t.ad.translate(e,e,[h.x+a[0]*f,h.y+a[1]*f,a[2]]);let m=1,_=1;const g=n.worldSize;if(d){if("mercator"===n.projection.name){let e=0;n.elevation&&(e=n.elevation.getAtPointOrZero(new Rd(h.x/g,h.y/g),0));const i=t.aA.transformMat4([],[h.x,h.y,e,1],n.projMatrix)[3]/n.cameraToCenterDistance;m=i,_=i*kd(n.center.lat,u)}else if("globe"===n.projection.name){const i=$v(e,n),o=t.ad.multiply([],n.projMatrix,i),s=[0,0,0,1];t.aA.transformMat4(s,s,o);const a=s[3]/n.cameraToCenterDistance,l=Hu(u),c=n.projection.pixelsPerMeter(r.lat,g)*kd(r.lat,u),d=n.projection.pixelsPerMeter(n.center.lat,g)*kd(n.center.lat,u);m=a/Vn(c,$d(n.center.lat),l),_=a*p/c,m*=d,_*=d}}else m=f;t.ad.scale(e,e,[m,m,_]);const y=[...e],v=i.orientation,x=[];if(Lv(x,[v[0]+o[0],v[1]+o[1],v[2]+o[2]],s),t.ad.multiply(e,y,x),l&&n.elevation){let o=0;const s=[];if(c&&n.elevation){o=function(e,i,n,r,o){const s=i.elevation;if(!s)return 0;const a=wu.projectAabbCorners(n,r),l=Cd(1,o.lat)*i.worldSize,c=function(e,i){const n=[0,0,1],r=[{corners:[0,1,3,2],dotProductWithUp:0},{corners:[1,5,2,6],dotProductWithUp:0},{corners:[0,4,1,5],dotProductWithUp:0},{corners:[2,6,3,7],dotProductWithUp:0},{corners:[4,7,5,6],dotProductWithUp:0},{corners:[0,3,4,7],dotProductWithUp:0}];for(const o of r){const r=e[o.corners[0]],s=e[o.corners[1]],a=e[o.corners[2]],l=[s[0]-r[0],s[1]-r[1],i*(s[2]-r[2])],c=t._.cross(l,l,[a[0]-r[0],a[1]-r[1],i*(a[2]-r[2])]);t._.normalize(c,c),o.dotProductWithUp=t._.dot(c,n)}return r.sort(((t,e)=>t.dotProductWithUp-e.dotProductWithUp)),r[0].corners}(a,l),d=a[c[0]],u=a[c[1]],h=a[c[2]],p=a[c[3]],f=s.getAtPointOrZero(new Rd(d[0]/i.worldSize,d[1]/i.worldSize),0),m=s.getAtPointOrZero(new Rd(u[0]/i.worldSize,u[1]/i.worldSize),0),_=s.getAtPointOrZero(new Rd(h[0]/i.worldSize,h[1]/i.worldSize),0),g=s.getAtPointOrZero(new Rd(p[0]/i.worldSize,p[1]/i.worldSize),0),y=(f+g)/2,v=(m+_)/2;return y>v?m=e.gl.NEAREST_MIPMAP_NEAREST}),t.uploaded=!0,t.image=null)}function Jv(t,e,i){t.indexBuffer=e.createIndexBuffer(t.indexArray,!1,!0),t.vertexBuffer=e.createVertexBuffer(t.vertexArray,Dv.members,!1,!0),t.normalArray&&(t.normalBuffer=e.createVertexBuffer(t.normalArray,Bv.members,!1,!0)),t.texcoordArray&&(t.texcoordBuffer=e.createVertexBuffer(t.texcoordArray,Ov.members,!1,!0)),t.colorArray&&(t.colorBuffer=e.createVertexBuffer(t.colorArray,(12===t.colorArray.bytesPerElement?zv:Rv).members,!1,!0)),t.featureArray&&(t.pbrBuffer=e.createVertexBuffer(t.featureArray,Nv.members,!0)),t.segments=wc.simpleSegment(0,0,t.vertexArray.length,t.indexArray.length);const n=t.material;n.pbrMetallicRoughness.baseColorTexture&&Kv(n.pbrMetallicRoughness.baseColorTexture,e),n.pbrMetallicRoughness.metallicRoughnessTexture&&Kv(n.pbrMetallicRoughness.metallicRoughnessTexture,e),n.normalTexture&&Kv(n.normalTexture,e),n.occlusionTexture&&Kv(n.occlusionTexture,e,i),n.emissionTexture&&Kv(n.emissionTexture,e)}function Qv(t,e,i){if(t.meshes)for(const n of t.meshes)Jv(n,e,i);if(t.children)for(const n of t.children)Qv(n,e,i)}function tx(t){if(t.meshes)for(const e of t.meshes)e.indexArray.destroy(),e.vertexArray.destroy(),e.colorArray&&e.colorArray.destroy(),e.normalArray&&e.normalArray.destroy(),e.texcoordArray&&e.texcoordArray.destroy(),e.featureArray&&e.featureArray.destroy();if(t.children)for(const e of t.children)tx(e)}function ex(t){if(t.meshes)for(const i of t.meshes)i.vertexBuffer&&(i.vertexBuffer.destroy(),i.indexBuffer.destroy(),i.normalBuffer&&i.normalBuffer.destroy(),i.texcoordBuffer&&i.texcoordBuffer.destroy(),i.colorBuffer&&i.colorBuffer.destroy(),i.pbrBuffer&&i.pbrBuffer.destroy(),i.segments.destroy(),i.material&&((e=i.material).pbrMetallicRoughness.baseColorTexture&&e.pbrMetallicRoughness.baseColorTexture.gfxTexture&&e.pbrMetallicRoughness.baseColorTexture.gfxTexture.destroy(),e.pbrMetallicRoughness.metallicRoughnessTexture&&e.pbrMetallicRoughness.metallicRoughnessTexture.gfxTexture&&e.pbrMetallicRoughness.metallicRoughnessTexture.gfxTexture.destroy(),e.normalTexture&&e.normalTexture.gfxTexture&&e.normalTexture.gfxTexture.destroy(),e.emissionTexture&&e.emissionTexture.gfxTexture&&e.emissionTexture.gfxTexture.destroy(),e.occlusionTexture&&e.occlusionTexture.gfxTexture&&e.occlusionTexture.gfxTexture.destroy()));var e;if(t.children)for(const e of t.children)ex(e)}class ix{constructor(t){this._callback=t,this._triggered=!1,"undefined"!=typeof MessageChannel&&(this._channel=new MessageChannel,this._channel.port2.onmessage=()=>{this._triggered=!1,this._callback()})}trigger(){this._triggered||(this._triggered=!0,this._channel?this._channel.port1.postMessage(!0):setTimeout((()=>{this._triggered=!1,this._callback()}),0))}remove(){this._channel=void 0,this._callback=()=>{}}}class nx{constructor(){this.tasks={},this.taskQueue=[],ai(["process"],this),this.invoker=new ix(this.process),this.nextId=0}add(t,e){const i=this.nextId++,n=function({type:t,isSymbolTile:e,zoom:i}){return i=i||0,"message"===t?0:"maybePrepare"!==t||e?"parseTile"!==t||e?"parseTile"===t&&e?300-i:"maybePrepare"===t&&e?400-i:500:200-i:100-i}(e);if(0===n){try{t()}finally{}return null}return this.tasks[i]={fn:t,metadata:e,priority:n,id:i},this.taskQueue.push(i),this.invoker.trigger(),{cancel:()=>{delete this.tasks[i]}}}process(){try{if(this.taskQueue=this.taskQueue.filter((t=>!!this.tasks[t])),!this.taskQueue.length)return;const t=this.pick();if(null===t)return;const e=this.tasks[t];if(delete this.tasks[t],this.taskQueue.length&&this.invoker.trigger(),!e)return;e.fn()}finally{}}pick(){let t=null,e=1/0;for(let i=0;i{i&&delete this.callbacks[s],this.target.postMessage({id:s,type:"",targetMapId:n,sourceMapId:this.mapId})}}}receive(t){const e=t.data,i=e.id;if(i&&(!e.targetMapId||this.mapId===e.targetMapId))if(""===e.type){const t=this.cancelCallbacks[i];delete this.cancelCallbacks[i],t&&t.cancel()}else if(e.mustQueue||gi()){const t=this.callbacks[i],n=this.scheduler.add((()=>this.processTask(i,e)),t&&t.metadata||{type:"message"});n&&(this.cancelCallbacks[i]=n)}else this.processTask(i,e)}processTask(t,e){if(delete this.cancelCallbacks[t],""===e.type){const i=this.callbacks[t];delete this.callbacks[t],i&&(e.error?i(Ea(e.error)):i(null,Ea(e.data)))}else{const i=new Set,n=e.hasCallback?(e,n)=>{this.target.postMessage({id:t,type:"",sourceMapId:this.mapId,error:e?Sa(e):null,data:Sa(n,i)},i)}:t=>{},r=Ea(e.data);if(this.parent[e.type])this.parent[e.type](e.sourceMapId,r,n);else if(this.parent.getWorkerSource){const t=e.type.split(".");this.parent.getWorkerSource(e.sourceMapId,t[0],r.source,r.scope)[t[1]](r,n)}else n(new Error(`Could not find function ${e.type}`))}}remove(){this.scheduler.remove(),this.target.removeEventListener("message",this.receive,!1)}}class ox{constructor(t,e){this.workerPool=t,this.actors=[],this.currentActor=0,this.id=ni();const i=this.workerPool.acquire(this.id);for(let t=0;t{this.ready=!0}))}broadcast(t,e,i){Qe(this.actors,((i,n)=>{i.send(t,e,n)}),i=i||function(){})}getActor(){return this.currentActor=(this.currentActor+1)%this.actors.length,this.actors[this.currentActor]}remove(){this.actors.forEach((t=>{t.remove()})),this.actors=[],this.workerPool.release(this.id)}}ox.Actor=rx;var sx={workerUrl:"",workerClass:null,workerParams:void 0};function ax(){return null!=sx.workerClass?new sx.workerClass:new self.Worker(sx.workerUrl,sx.workerParams)}const lx="mapboxgl_preloaded_worker_pool";class cx{constructor(){this.active={}}acquire(t){if(!this.workers)for(this.workers=[];this.workers.length{t.terminate()})),this.workers=null)}isPreloaded(){return!!this.active[lx]}numActive(){return Object.keys(this.active).length}}let dx;function ux(){return dx||(dx=new cx),dx}cx.workerCount=2;let hx,px,fx,mx,_x,gx=null;function yx(){return gi()&&self.worker&&self.worker.dracoUrl?self.worker.dracoUrl:px||n.DRACO_URL}function vx(){if(gi()&&self.worker&&self.worker.meshoptUrl)return self.worker.meshoptUrl;if(mx)return mx;const t=new Uint8Array([0,97,115,109,1,0,0,0,1,4,1,96,0,0,3,3,2,0,0,5,3,1,0,1,12,1,0,10,22,2,12,0,65,0,65,0,65,0,252,10,0,0,11,7,0,65,0,253,15,26,11]);if("object"!=typeof WebAssembly)throw new Error("WebAssembly not supported, cannot instantiate meshoptimizer");return mx=WebAssembly.validate(t)?n.MESHOPT_SIMD_URL:n.MESHOPT_URL,mx}const xx={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},bx={5120:"DT_INT8",5121:"DT_UINT8",5122:"DT_INT16",5123:"DT_UINT16",5125:"DT_UINT32",5126:"DT_FLOAT32"},wx={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16};function Tx(t,e,i){const n=i.json.bufferViews.length,r=i.buffers.length;e.bufferView=n,i.json.bufferViews[n]={buffer:r,byteLength:t.byteLength},i.buffers[r]=t}const Sx="KHR_draco_mesh_compression";function Ex(t,e){const i=t.extensions&&t.extensions[Sx];if(!i)return;const n=new fx.Decoder,r=$x(e,i.bufferView),o=new fx.Mesh;if(!n.DecodeArrayToMesh(r,r.byteLength,o))throw new Error("Failed to decode Draco mesh");const s=e.json.accessors[t.indices],a=xx[s.componentType],l=s.count*a.BYTES_PER_ELEMENT,c=fx._malloc(l);a===Uint16Array?n.GetTrianglesUInt16Array(o,l,c):n.GetTrianglesUInt32Array(o,l,c),Tx(fx.memory.buffer.slice(c,c+l),s,e),fx._free(c);for(const r of Object.keys(i.attributes)){const s=n.GetAttributeByUniqueId(o,i.attributes[r]),a=e.json.accessors[t.attributes[r]],l=bx[a.componentType],c=a.count*wx[a.type]*xx[a.componentType].BYTES_PER_ELEMENT,d=fx._malloc(c);n.GetAttributeDataArrayForAllPoints(o,s,fx[l],c,d),Tx(fx.memory.buffer.slice(d,d+c),a,e),fx._free(d)}n.destroy(),o.destroy(),delete t.extensions[Sx]}const Mx="EXT_meshopt_compression";function Cx(t,e){if(!t.extensions||!t.extensions[Mx])return;const i=t.extensions[Mx],n=new Uint8Array(e.buffers[i.buffer],i.byteOffset||0,i.byteLength||0),r=new Uint8Array(i.count*i.byteStride);_x.decodeGltfBuffer(r,i.count,i.byteStride,n,i.mode,i.filter),t.buffer=e.buffers.length,t.byteOffset=0,e.buffers[t.buffer]=r.buffer,delete t.extensions[Mx]}const Ax=1179937895,Ix=new TextDecoder("utf8");function Lx(t,e){return new URL(t,e).href}function Px(t,e,i,n){return fetch(Lx(t.uri,n)).then((t=>t.arrayBuffer())).then((t=>{e.buffers[i]=t}))}function $x(t,e){const i=t.json.bufferViews[e];return new Uint8Array(t.buffers[i.buffer],i.byteOffset||0,i.byteLength)}function kx(t,e,i,n){if(t.uri){const r=Lx(t.uri,n);return fetch(r).then((t=>t.blob())).then((t=>createImageBitmap(t))).then((t=>{e.images[i]=t}))}if(void 0!==t.bufferView){const n=$x(e,t.bufferView),r=new Blob([n],{type:t.mimeType});return createImageBitmap(r).then((t=>{e.images[i]=t}))}}function Dx(t,e=0,i){const n={json:null,images:[],buffers:[]};if(new Uint32Array(t,e,1)[0]===Ax){const i=new Uint32Array(t,e);let r=2;const o=(i[r++]>>2)-3,s=i[r++]>>2;if(r++,n.json=JSON.parse(Ix.decode(i.subarray(r,r+s))),r+=s,r{const t=[],e=a&&a.includes(Sx),r=a&&a.includes(Mx);if(e&&t.push(function(){if(!fx)return hx||(hx=function(t){let e,i=null;function n(){e=new Uint8Array(i.buffer)}function r(){throw new Error("Unexpected Draco error.")}const o={a:{a:r,d:function(t,i,n){return e.copyWithin(t,i,i+n)},c:function(t){const r=e.length,o=Math.max(t>>>0,Math.ceil(1.2*r)),s=Math.ceil((o-r)/65536);try{return i.grow(s),n(),!0}catch(t){return!1}},b:r}};return(WebAssembly.instantiateStreaming?WebAssembly.instantiateStreaming(t,o):t.then((t=>t.arrayBuffer())).then((t=>WebAssembly.instantiate(t,o)))).then((t=>{const{Rb:r,Qb:o,P:s,T:a,X:l,Ja:c,La:d,Qa:u,Va:h,Wa:p,eb:f,jb:m,f:_,e:g,yb:y,zb:v,Ab:x,Bb:b,Db:w,Gb:T}=t.instance.exports;i=g;const S=(()=>{let t=0,i=0,n=0,s=0;return a=>{n&&(r(s),r(t),i+=n,n=t=0),t||(i+=128,t=o(i));const l=a.length+7&-8;let c=t;l>=i&&(n=l,c=s=o(l));for(let t=0;t{fx=t,hx=void 0})))}()),r&&t.push(function(){if(_x)return;const t=function(t){let e;const i=WebAssembly.instantiateStreaming(t,{}).then((t=>{e=t.instance,e.exports.__wasm_call_ctors()})),n={NONE:"",OCTAHEDRAL:"meshopt_decodeFilterOct",QUATERNION:"meshopt_decodeFilterQuat",EXPONENTIAL:"meshopt_decodeFilterExp"},r={ATTRIBUTES:"meshopt_decodeVertexBuffer",TRIANGLES:"meshopt_decodeIndexBuffer",INDICES:"meshopt_decodeIndexSequence"};return{ready:i,supported:!0,decodeGltfBuffer(t,i,o,s,a,l){!function(t,e,i,n,r,o,s){const a=t.exports.sbrk,l=n+3&-4,c=a(l*r),d=a(o.length),u=new Uint8Array(t.exports.memory.buffer);u.set(o,d);const h=e(c,n,r,d,o.length);if(0===h&&s&&s(c,l,r),i.set(u.subarray(c,c+n*r)),a(c-a(0)),0!==h)throw new Error(`Malformed buffer data: ${h}`)}(e,e.exports[r[a]],t,i,o,s,e.exports[n[l]])}}}(fetch(vx()));return t.ready.then((()=>{_x=t}))}()),o)for(let e=0;e{if(e&&s)for(const{primitives:t}of s)for(const e of t)Ex(e,n);if(r&&s&&l)for(const t of l)Cx(t,n);return n}))}))}function zx(t,e){const i=t.json.bufferViews[e.bufferView],n=xx[e.componentType];return new n(t.buffers[i.buffer],(e.byteOffset||0)+(i.byteOffset||0),e.count*(i.byteStride&&i.byteStride!==wx[e.type]*n.BYTES_PER_ELEMENT?i.byteStride/n.BYTES_PER_ELEMENT:wx[e.type]))}function Rx(t,e,i,n){const r=xx[e.componentType],o=function(t){switch(t){case Int8Array:return 1/127;case Uint8Array:return 1/255;case Int16Array:return 1/32767;case Uint16Array:return 1/65535;default:return 1}}(r),s=t.json.bufferViews[e.bufferView],a=s.byteStride?s.byteStride/r.BYTES_PER_ELEMENT:wx[e.type],l=i.float32,c=l.length/i.capacity;for(let t=0,i=0;t0){for(let r=0;r0){o.texcoordArray=new ic;const t=e.json.accessors[r.TEXCOORD_0];o.texcoordArray.resize(t.count);const i=zx(e,t);Rx(e,t,o.texcoordArray,i)}if(void 0!==r._FEATURE_ID_RGBA4444){const t=e.json.accessors[r._FEATURE_ID_RGBA4444];e.json.extensionsUsed&&e.json.extensionsUsed.includes("EXT_meshopt_compression")&&(o.featureData=zx(e,t))}void 0!==r._FEATURE_RGBA4444&&(o.featureData=new Uint32Array(zx(e,e.json.accessors[r._FEATURE_RGBA4444]).buffer));const u=t.material;return o.material=function(t,e){const{emissiveFactor:i=[0,0,0],alphaMode:n="OPAQUE",alphaCutoff:r=.5,normalTexture:o,occlusionTexture:s,emissiveTexture:a,doubleSided:l}=t,{baseColorFactor:c=[1,1,1,1],metallicFactor:d=1,roughnessFactor:u=1,baseColorTexture:h,metallicRoughnessTexture:p}=t.pbrMetallicRoughness||{},f=s?e[s.index]:void 0;if(s&&s.extensions&&s.extensions.KHR_texture_transform&&f){const t=s.extensions.KHR_texture_transform;f.offsetScale=[t.offset[0],t.offset[1],t.scale[0],t.scale[1]]}return{pbrMetallicRoughness:{baseColorFactor:new Un(...c),metallicFactor:d,roughnessFactor:u,baseColorTexture:h?e[h.index]:void 0,metallicRoughnessTexture:p?e[p.index]:void 0},doubleSided:l,emissiveFactor:i,alphaMode:n,alphaCutoff:r,normalTexture:o?e[o.index]:void 0,occlusionTexture:f,emissionTexture:a?e[a.index]:void 0,defined:void 0===t.defined}}(void 0!==u?e.json.materials[u]:{defined:!1},i),o}function Bx(e,i,n){const{matrix:r,rotation:o,translation:s,scale:a,mesh:l,extras:c,children:d}=e,u={};if(u.matrix=r||t.ad.fromRotationTranslationScale([],o||[0,0,0,1],s||[0,0,0],a||[1,1,1]),void 0!==l){u.meshes=n[l];const t=u.anchor=[0,0];for(const e of u.meshes){const{min:i,max:n}=e.aabb;t[0]+=i[0]+n[0],t[1]+=i[1]+n[1]}t[0]=Math.floor(t[0]/u.meshes.length/2),t[1]=Math.floor(t[1]/u.meshes.length/2)}if(c&&(c.id&&(u.id=c.id),c.lights&&(u.lights=function(t){if(!t.length)return[];const e=function(t){const e=atob(t),i=new Uint8Array(e.length);for(let t=0;t1&&n[n.length-1].equals(n[0])&&n.pop();let r=0;for(let t=0;t0&&n.reverse();const o=xh(n.flatMap((t=>[t.x,t.y])),[]);return 0===o.length?null:{vertices:n,indices:o}}function Ux(e,i){const n=[],r=[];let o=0;const s=[];for(const a of e){o=n.length;const e=a.vertexArray.float32,l=a.indexArray.uint16;for(let r=0;r0&&([r[t+1],r[t+2]]=[r[t+2],r[t+1]])}return{vertices:n,indices:r}}function jx(t){const e=function(t,e){const i=[],n=WebGL2RenderingContext;if(t.json.textures)for(const r of t.json.textures){const o={magFilter:n.LINEAR,minFilter:n.NEAREST,wrapS:n.REPEAT,wrapT:n.REPEAT};void 0!==r.sampler&&Object.assign(o,t.json.samplers[r.sampler]),i.push({image:e[r.source],sampler:o,uploaded:!1})}return i}(t,t.images),i=function(t,e){const i=[];for(const n of t.json.meshes){const r=[];for(const i of n.primitives)r.push(Ox(i,t,e));i.push(r)}return i}(t,e),{scenes:n,scene:r,nodes:o}=t.json,s=n?n[r||0].nodes:o,a=[];for(const e of s)a.push(Bx(o[e],t,i));return function(t,e,i){const n={},r=new Set;for(let o=0;o0){const e=Array.from(r.values()).sort(((t,e)=>t-e));for(let i=e.length-1;i>=0;i--)t.splice(e[i],1)}}(a,s,t.json.nodes),a}function Vx(t){t.heightmap=new Float32Array(4096),t.heightmap.fill(-1);const e=t.vertexArray.float32,i=t.aabb.min[0]-1,n=t.aabb.min[1]-1,r=Wv/(t.aabb.max[0]-i+2),o=Wv/(t.aabb.max[1]-n+2);for(let s=0;st.heightmap[c*Wv+l]&&(t.heightmap[c*Wv+l]=a)}}function Gx(e,i){const n={};n.indexArray=new Kl,n.indexArray.reserve(4*e.length),n.vertexArray=new Bl,n.vertexArray.reserve(10*e.length),n.colorArray=new Ol,n.vertexArray.reserve(10*e.length);let r=0;for(const o of e){const e=Math.min(10,Math.max(4,1.3*o.height))*i,s=[-o.normal[1],o.normal[0],0],a=Math.min(.29,.1*o.width/o.depth),l=o.width-2*o.depth*i*(a+.01),c=t._.scaleAndAdd([],o.pos,s,l/2),d=t._.scaleAndAdd([],o.pos,s,-l/2),u=[c[0],c[1],c[2]+o.height],h=[d[0],d[1],d[2]+o.height],p=t._.scaleAndAdd([],o.normal,s,a);t._.scale(p,p,e);const f=t._.scaleAndAdd([],o.normal,s,-a);t._.scale(f,f,e),t._.add(p,c,p),t._.add(f,d,f),c[2]+=.1,d[2]+=.1,n.vertexArray.emplaceBack(p[0],p[1],p[2]),n.vertexArray.emplaceBack(f[0],f[1],f[2]),n.vertexArray.emplaceBack(c[0],c[1],c[2]),n.vertexArray.emplaceBack(d[0],d[1],d[2]),n.vertexArray.emplaceBack(u[0],u[1],u[2]),n.vertexArray.emplaceBack(h[0],h[1],h[2]),n.vertexArray.emplaceBack(c[0],c[1],c[2]),n.vertexArray.emplaceBack(d[0],d[1],d[2]),n.vertexArray.emplaceBack(p[0],p[1],p[2]),n.vertexArray.emplaceBack(f[0],f[1],f[2]);const m=l/e/2;n.colorArray.emplaceBack(-m-a,-1,m,.8),n.colorArray.emplaceBack(m+a,-1,m,.8),n.colorArray.emplaceBack(-m,0,m,1.3),n.colorArray.emplaceBack(m,0,m,1.3),n.colorArray.emplaceBack(m+a,-.8,m,.7),n.colorArray.emplaceBack(m+a,-.8,m,.7),n.colorArray.emplaceBack(0,0,m,1.3),n.colorArray.emplaceBack(0,0,m,1.3),n.colorArray.emplaceBack(m+a,-1.2,m,.8),n.colorArray.emplaceBack(m+a,-1.2,m,.8),n.indexArray.emplaceBack(6+r,4+r,8+r),n.indexArray.emplaceBack(7+r,9+r,5+r),n.indexArray.emplaceBack(0+r,1+r,2+r),n.indexArray.emplaceBack(1+r,3+r,2+r),r+=10}const o={defined:!0,emissiveFactor:[0,0,0]},s={};return s.baseColorFactor=Un.white,o.pbrMetallicRoughness=s,n.material=o,n.aabb=new wu([1/0,1/0,1/0],[-1/0,-1/0,-1/0]),n}const Zx=new Float32Array(262144),qx=new Uint8Array(262144);function Hx(t){let e=0;if(t.meshes)for(const i of t.meshes)e=Math.max(e,i.aabb.max[2]);if(t.children)for(const i of t.children)e=Math.max(e,Hx(i));return e}function Wx(t,e,i){if(t.meshes)for(const n of t.meshes)n.aabb.min[0]!==1/0&&i.insert(e,n.aabb.min[0],n.aabb.min[1],n.aabb.max[0],n.aabb.max[1]);if(t.children)for(const n of t.children)Wx(n,e,i)}const Yx=["","wall","door","roof","window","lamp","logo"];class Xx{constructor(t){this.node=t,this.evaluatedRMEA=[[1,0,0,1],[1,0,0,1],[1,0,0,1],[1,0,0,1],[.4,1,0,1],[1,0,0,1],[1,0,0,1]],this.hiddenByReplacement=!1,this.evaluatedScale=[1,1,1],this.evaluatedColor=[],this.emissionHeightBasedParams=[],this.feature={type:"Point",id:t.id,geometry:[],properties:{height:Hx(t)}},this.aabb=this._getLocalBounds()}_getLocalBounds(){if(!this.node.meshes)return new wu([1/0,1/0,1/0],[-1/0,-1/0,-1/0]);if(!this.aabb){let t=0;const e=new wu([1/0,1/0,1/0],[-1/0,-1/0,-1/0]);for(const i of this.node.meshes)this.node.lightMeshIndex!==t&&(i.transformedAabb=wu.applyTransformFast(i.aabb,this.node.matrix),e.encapsulate(i.transformedAabb)),t++;this.aabb=e}return this.aabb}}class Kx{constructor(t,e,i,n,r,o){this.id=e,this.modelTraits|=Yv.CoordinateSpaceTile,this.uploaded=!1,this.hasPattern=!1,i&&(this.modelTraits|=Yv.HasMapboxMeshFeatures),n&&(this.modelTraits|=Yv.HasMeshoptCompression),this.zoom=-1,this.terrainExaggeration=1,this.projection={name:"mercator"},this.replacementUpdateTime=0,this.elevationReadFromZ=255,this.brightness=r,this.dirty=!0,this.needsUpload=!1,this.nodesInfo=[];for(const e of t)this.nodesInfo.push(new Xx(e)),Wx(e,o.featureIndexArray.length,o.grid),o.featureIndexArray.emplaceBack(this.nodesInfo.length-1,0,o.bucketLayerIDs.length-1,0)}updateFootprints(t,e){for(const i of this.getNodesInfo()){const n=i.node;n.footprint&&e.push({footprint:n.footprint,id:t})}}update(){console.log("Update 3D model bucket")}populate(){console.log("populate 3D model bucket")}uploadPending(){return!this.uploaded||this.needsUpload}upload(t){if(!this.needsUpload)return;const e=this.getNodesInfo();for(const i of e){const e=i.node;this.uploaded?this.updatePbrBuffer(e):Qv(e,t,!0)}for(const t of e)tx(t.node);this.uploaded=!0,this.needsUpload=!1}updatePbrBuffer(t){let e=!1;if(!t.meshes)return e;for(const i of t.meshes)i.pbrBuffer&&(i.pbrBuffer.updateData(i.featureArray),e=!0);return e}needsReEvaluation(t,e,i){const n=t.transform.projectionOptions,r=t.style.getBrightness(),o=this.brightness!==r;return!!(!this.uploaded||this.dirty||n.name!==this.projection.name||Jx(i.paint.get("model-color").value,o)||Jx(i.paint.get("model-color-mix-intensity").value,o)||Jx(i.paint.get("model-roughness").value,o)||Jx(i.paint.get("model-emissive-strength").value,o)||Jx(i.paint.get("model-height-based-emissive-strength-multiplier").value,o))&&(this.projection=n,this.brightness=r,!0)}evaluateScale(t,e){if(t.transform.zoom===this.zoom)return;this.zoom=t.transform.zoom;const i=this.getNodesInfo(),n=this.id.canonical;for(const t of i){const i=t.feature;t.evaluatedScale=e.paint.get("model-scale").evaluate(i,{},n)}}evaluate(t){const e=this.getNodesInfo();for(const i of e){if(!i.node.meshes)continue;const e=i.feature,n=i.node.meshes&&i.node.meshes[0].featureData,r=i.evaluatedColor[2],o=i.evaluatedRMEA[2],s=this.id.canonical;if(i.hasTranslucentParts=!1,n){for(let n=0;n=t)continue;const u=Zx[c],h=Math.abs(u);h>a&&(s=u,a=h,l=r,d=e)}if(a>.1){const o=1-(t+.5*Math.abs(l*d))/c;let a=e._dem.get(n,i)+s*o;const u=e._dem.get(n+l,i+d),h=e._dem.get(n-l,i-d,!0);(a-u)*(a-h)>0&&(a=(u+h)/2),Zx[r]=e._dem.set(n,i,a),qx[r]=t}}}}}s&&(e._demTile.needsDEMTextureUpload=!0,e._dem._timestamp=ki.now())}getNodesInfo(){return this.nodesInfo}destroy(){const t=this.getNodesInfo();for(const e of t)tx(e.node),ex(e.node)}isEmpty(){return!this.nodesInfo.length}updateReplacement(t,e){if(e.updateTime===this.replacementUpdateTime)return;this.replacementUpdateTime=e.updateTime;const i=e.getReplacementRegionsForTile(t.toUnwrapped()),n=this.getNodesInfo();for(let t=0;tt.footprint===e.footprint))}}getHeightAtTileCoord(e,i){const n=this.getNodesInfo(),r=[],o=[0,0,0],s=t.ad.identity([]);for(let a=0;ad.max[0]||i>d.max[1])continue;if(!0===l.node.hidden)return{height:0,maxHeight:l.feature.properties.height,hidden:!1,verticalScale:l.evaluatedScale[2]};t.ad.invert(s,l.node.matrix),o[0]=e,o[1]=i,t._.transformMat4(o,o,s);const u=(o[0]-c.aabb.min[0])/(c.aabb.max[0]-c.aabb.min[0])*Wv|0,h=Math.min(63,(o[1]-c.aabb.min[1])/(c.aabb.max[1]-c.aabb.min[1])*Wv|0)*Wv+Math.min(63,u),p=c.heightmap[h];if(!(p0)return{height:void 0,maxHeight:l.feature.properties.height,hidden:l.hiddenByReplacement,verticalScale:l.evaluatedScale[2]}}}}function Jx(t,e){return!t.isLightConstant&&e}function Qx(t,e,i,n,r,o,s,a){let l=(61440&e|(61440&e)>>4)>>8,c=(3840&e|(3840&e)>>4)>>4,d=240&e|(240&e)>>4;i[3]>0&&(l=Vn(l,255*i[0],i[3]),c=Vn(c,255*i[1],i[3]),d=Vn(d,255*i[2],i[3]));const u=l>16&65535,a=o?e>>16&65535:65535&e,l=(15&a)t.polygon)).flat());const g=f?l:null,[y,v]=function(e,i,n,r,o,s,a,l,c,d,u){return"globe"===e.projection.name?function(e,i,n,r,o,s,a,l,c,d,u){const h=[],p=[],f=e.projection.upVectorScale(u,e.center.lat,e.worldSize).metersToTile,m=[0,0,0,1],_=[0,0,0,1],g=(t,e,i,n)=>{t[0]=e,t[1]=i,t[2]=n,t[3]=1},y=Sf();n>0&&(n+=y),r+=y;for(const y of i){const i=[],v=[];for(const h of y){const p=h.x+o.x,y=h.y+o.y,x=e.projection.projectTilePoint(p,y,u),b=e.projection.upVector(u,h.x,h.y);let w=n,T=r;if(a){const t=Pf(p,y,n,r,a,l,c,d);w+=t.base,T+=t.top}0!==n?g(m,x.x+b[0]*f*w,x.y+b[1]*f*w,x.z+b[2]*f*w):g(m,x.x,x.y,x.z),g(_,x.x+b[0]*f*T,x.y+b[1]*f*T,x.z+b[2]*f*T),t._.transformMat4(m,m,s),t._.transformMat4(_,_,s),i.push(new Tp(m[0],m[1],m[2])),v.push(new Tp(_[0],_[1],_[2]))}h.push(i),p.push(v)}return[h,p]}(e,i,n,r,o,s,a,l,c,d,u):a?function(e,i,n,r,o,s,a,l,c){const d=[],u=[],h=[0,0,0,1];for(const p of e){const e=[],f=[];for(const d of p){const u=d.x+r.x,p=d.y+r.y,m=Pf(u,p,i,n,s,a,l,c);h[0]=u,h[1]=p,h[2]=m.base,h[3]=1,t.aA.transformMat4(h,h,o),h[3]=Math.max(h[3],1e-5);const _=new Tp(h[0]/h[3],h[1]/h[3],h[2]/h[3]);h[0]=u,h[1]=p,h[2]=m.top,h[3]=1,t.aA.transformMat4(h,h,o),h[3]=Math.max(h[3],1e-5);const g=new Tp(h[0]/h[3],h[1]/h[3],h[2]/h[3]);e.push(_),f.push(g)}d.push(e),u.push(f)}return[d,u]}(i,n,r,o,s,a,l,c,d):function(t,e,i,n,r){const o=[],s=[],a=r[8]*e,l=r[9]*e,c=r[10]*e,d=r[11]*e,u=r[8]*i,h=r[9]*i,p=r[10]*i,f=r[11]*i;for(const e of t){const t=[],i=[];for(const o of e){const e=o.x+n.x,s=o.y+n.y,m=r[0]*e+r[4]*s+r[12],_=r[1]*e+r[5]*s+r[13],g=r[2]*e+r[6]*s+r[14],y=r[3]*e+r[7]*s+r[15],v=m+a,x=_+l,b=g+c,w=Math.max(y+d,1e-5),T=m+u,S=_+h,E=g+p,M=Math.max(y+f,1e-5);t.push(new Tp(v/w,x/w,b/w)),i.push(new Tp(T/M,S/M,E/M))}o.push(t),s.push(i)}return[o,s]}(i,n,r,o,s)}(s,r,h,u,d,a,g,p,m,s.center.lat,e.tileID.canonical),x=e.queryGeometry;return function(t,e,i){let n=1/0;Kd(i,e)&&(n=Lf(i,e[0]));for(let r=0;r=3)for(let e=0;e>4;if(1!==n)throw new Error(`Got v${n} data when expected v1.`);const r=nb[15&i];if(!r)throw new Error("Unrecognized array type.");const[o]=new Uint16Array(t,2,1),[s]=new Uint32Array(t,4,1);return new rb(s,o,r,t)}constructor(t,e=64,i=Float64Array,n){if(isNaN(t)||t>1;return this.ids[i]=i,this.coords[this._pos++]=t,this.coords[this._pos++]=e,i}finish(){const t=this._pos>>1;if(t!==this.numItems)throw new Error(`Added ${t} items when expected ${this.numItems}.`);return ob(this.ids,this.coords,this.nodeSize,0,this.numItems-1,0),this._finished=!0,this}range(t,e,i,n){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");const{ids:r,coords:o,nodeSize:s}=this,a=[0,r.length-1,0],l=[];for(;a.length;){const c=a.pop()||0,d=a.pop()||0,u=a.pop()||0;if(d-u=t&&a=e&&c>1,p=o[2*h],f=o[2*h+1];p>=t&&p=e&&f=p:n>=f)&&(a.push(h+1),a.push(d),a.push(1-c))}return l}within(t,e,i){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");const{ids:n,coords:r,nodeSize:o}=this,s=[0,n.length-1,0],a=[],l=i*i;for(;s.length;){const c=s.pop()||0,d=s.pop()||0,u=s.pop()||0;if(d-u>1,p=r[2*h],f=r[2*h+1];cb(p,f,t,e)=p:e+i>=f)&&(s.push(h+1),s.push(d),s.push(1-c))}return a}}function ob(t,e,i,n,r,o){if(r-n>1;sb(t,e,s,n,r,o),ob(t,e,i,n,s-1,1-o),ob(t,e,i,s+1,r,1-o)}function sb(t,e,i,n,r,o){for(;r>n;){if(r-n>600){const s=r-n+1,a=i-n+1,l=Math.log(s),c=.5*Math.exp(2*l/3),d=.5*Math.sqrt(l*c*(s-c)/s)*(a-s/2s&&ab(t,e,n,r);as;)l--}e[2*n+o]===s?ab(t,e,n,l):(l++,ab(t,e,l,r)),lr&&(n+=(t[i]-r)*(t[i]-r)),e[i]0&&n[0]0&&n[1]0&&r[0]0&&r[1]0?Math.acos(i/n)*Ve:0;let o=0!==t||0!==e?Math.atan2(-e,-t)*Ve+90:0;return oNi&&(t.getActor().send("enforceCacheSizeLimit",Fi),Vi=0)},t.an=gn,t.ao=class{constructor(t){this.entries={},this.scheduler=t}request(t,e,i,n){const r=this.entries[t]=this.entries[t]||{callbacks:[]};if(r.result){const[t,i]=r.result;return this.scheduler?this.scheduler.add((()=>{n(t,i)}),e):n(t,i),()=>{}}return r.callbacks.push(n),r.cancel||(r.cancel=i(((i,n)=>{r.result=[i,n];for(const t of r.callbacks)this.scheduler?this.scheduler.add((()=>{t(i,n)}),e):t(i,n);setTimeout((()=>delete this.entries[t]),3e3)}))),()=>{r.result||(r.callbacks=r.callbacks.filter((t=>t!==n)),r.callbacks.length||(r.cancel(),delete this.entries[t]))}}},t.ap=function(t,e,i){const n=JSON.stringify(t.request);return t.data&&(this.deduped.entries[n]={result:[null,t.data]}),this.deduped.request(n,{type:"parseTile",isSymbolTile:t.isSymbolTile,zoom:t.tileZoom},(e=>{const n=en(t.request,((t,n,r,o)=>{t?e(t):n&&e(null,{vectorTile:i?void 0:new bp(new Lm(n)),rawData:n,cacheControl:r,expires:o})}));return()=>{n.cancel(),e()}}),e)},t.aq=Dc,t.ar=class extends Lc{constructor(t){super(t),this.current=Fc}set(t,e,i){if(this.fetchUniformLocation(t,e))for(let t=0;t({u_camera_to_center_distance:new $c(t),u_extrude_scale:new Uc(t),u_device_pixel_ratio:new $c(t),u_matrix:new Bc(t),u_inv_rot_matrix:new Bc(t),u_merc_center:new kc(t),u_tile_id:new Dc(t),u_zoom_transition:new $c(t),u_up_dir:new Dc(t),u_emissive_strength:new $c(t)}),t.bJ=t=>({u_matrix:new Bc(t),u_pixels_to_tile_units:new Uc(t),u_device_pixel_ratio:new $c(t),u_units_to_pixels:new kc(t),u_dash_image:new Pc(t),u_gradient_image:new Pc(t),u_image_height:new $c(t),u_texsize:new kc(t),u_tile_units_to_pixels:new $c(t),u_alpha_discard_threshold:new $c(t),u_trim_offset:new kc(t),u_trim_fade_range:new kc(t),u_trim_color:new zc(t),u_emissive_strength:new $c(t)}),t.bK=t=>({u_matrix:new Bc(t),u_texsize:new kc(t),u_pixels_to_tile_units:new Uc(t),u_device_pixel_ratio:new $c(t),u_image:new Pc(t),u_units_to_pixels:new kc(t),u_tile_units_to_pixels:new $c(t),u_alpha_discard_threshold:new $c(t),u_trim_offset:new kc(t)}),t.bL=Yl,t.bM=Hf,t.bN=Om,t.bO=jm,t.bP=G_,t.bQ=c_,t.bR=th,t.bS=(t,e,i,n,r,o)=>{const s=t.transform,a="globe"===s.projection.name;let l;if("map"===o.paint.get("circle-pitch-alignment"))if(a){const t=Zu(s.zoom,e.canonical)*s._pixelsPerMercatorPixel;l=Float32Array.from([t,0,0,t])}else l=s.calculatePixelsToTileUnitsMatrix(i);else l=new Float32Array([s.pixelsToGLUnits[0],0,0,s.pixelsToGLUnits[1]]);const c={u_camera_to_center_distance:t.transform.getCameraToCenterDistance(s.projection),u_matrix:t.translatePosMatrix(e.projMatrix,i,o.paint.get("circle-translate"),o.paint.get("circle-translate-anchor")),u_device_pixel_ratio:ki.devicePixelRatio,u_extrude_scale:l,u_inv_rot_matrix:Qu,u_merc_center:[0,0],u_tile_id:[0,0,0],u_zoom_transition:0,u_up_dir:[0,0,0],u_emissive_strength:o.paint.get("circle-emissive-strength")};if(a){c.u_inv_rot_matrix=n,c.u_merc_center=r,c.u_tile_id=[e.canonical.x,e.canonical.y,1{const s=t.transform;return{u_matrix:rm(t,e,i,n),u_texsize:e.imageAtlasTexture?e.imageAtlasTexture.size:[0,0],u_pixels_to_tile_units:s.calculatePixelsToTileUnitsMatrix(e),u_device_pixel_ratio:r,u_image:0,u_tile_units_to_pixels:nm(e,s),u_units_to_pixels:[1/s.pixelsToGLUnits[0],1/s.pixelsToGLUnits[1]],u_alpha_discard_threshold:0,u_trim_offset:o}},t.bV=(t,e,i,n,r,o,s)=>{const a=t.transform,l=a.calculatePixelsToTileUnitsMatrix(e);return{u_matrix:rm(t,e,i,n),u_pixels_to_tile_units:l,u_device_pixel_ratio:o,u_units_to_pixels:[1/a.pixelsToGLUnits[0],1/a.pixelsToGLUnits[1]],u_dash_image:0,u_gradient_image:1,u_image_height:r,u_texsize:sm(i)&&e.lineAtlasTexture?e.lineAtlasTexture.size:[0,0],u_tile_units_to_pixels:nm(e,t.transform),u_alpha_discard_threshold:0,u_trim_offset:s,u_trim_fade_range:i.paint.get("line-trim-fade-range"),u_trim_color:i.paint.get("line-trim-color").toRenderColor(i.lut).toArray01(),u_emissive_strength:i.paint.get("line-emissive-strength")}},t.bW=oi,t.bX=mh,t.bY=Sf,t.bZ=bd,t.b_=_f,t.ba=function(t,e,i){const n=Hu(i.zoom),r=t.style.map._antialias,o=e.options.extStandardDerivativesForceOff||t.terrain&&t.terrain.exaggeration()>0;return 0===n&&!r&&!o},t.bb=function(e){const i=e.pixelsPerMeter,n=i/Cd(1,e.center.lat),r=t.ad.identity(new Float64Array(16));return t.ad.translate(r,r,[e.point.x,e.point.y,0]),t.ad.scale(r,r,[n,n,i]),Float32Array.from(r)},t.bc=Ou,t.bd=function(t){const e=Pd-5;t=Xe(t,-e,e)/e*90;const i=Math.pow(Math.abs(Math.sin(Ge(t))),3);return Math.round(i*(sd.length-1))},t.be=function(e,i,n,r){const o=i.getNorth(),s=i.getSouth(),a=i.getWest(),l=i.getEast(),c=10){const e=180/r;t.bC.multiply(f,f,[e/d+1,0,0,0,e/u+1,0,-.5*e/h,.5*e/p,1])}return f[2]=c,f[5]=e.x,f[8]=e.y,f},t.bf=ju,t.bg=$u,t.bh=function(e,i,n){const r=t.ad.identity(new Float64Array(16)),o=(i/(1{}}},t.bo=Gg,t.bp=ai,t.bq=class{isDataAvailableAtPoint(t){const e=this._source();if(this.isUsingMockSource()||!e||t.y1)return!1;const i=e.getSource().maxzoom,n=11)return e;const r=n.getSource().maxzoom,o=1{const s=this.getAtTileOffset(e,o.x,o.y),a=r.upVector(e.canonical,o.x,o.y),l=r.upVectorScale(e.canonical,i,n).metersToTile;return t._.scale(a,a,s*l),a}}getForTilePoints(t,e,i,n){if(this.isUsingMockSource())return!1;const r=Xp.create(this,t,n);return!!r&&(e.forEach((t=>{t[2]=this.exaggeration()*r.getElevationAt(t[0],t[1],i)})),!0)}getMinMaxForTile(t){if(this.isUsingMockSource())return null;const e=this.findDEMTileFor(t);if(!e||!e.dem)return null;const i=e.dem.tree,n=e.tileID,r=1=0?t.slice(0,e):t},t.cV=function(t){return t.indexOf(wl)>=0},t.cW=function(t){const e=t.indexOf(wl);return e>=0?t.slice(e+1):""},t.cX=function(t){const e=[],i=t.id;return void 0===i&&e.push({message:`layers.${i}: missing required property "id"`}),void 0===t.render&&e.push({message:`layers.${i}: missing required method "render"`}),t.renderingMode&&"2d"!==t.renderingMode&&"3d"!==t.renderingMode&&e.push({message:`layers.${i}: property "renderingMode" must be either "2d" or "3d"`}),e},t.cY=function(t,e,i,n){return"custom"===t.type?new vv(t,e):new ib[t.type](t,e,i,n)},t.cZ=di,t.c_=Va,t.ca=1,t.cb=Ag,t.cc=0,t.cd=ec,t.ce=function(t,e,i,n,r){return Xe((t-e)/(i-e)*(r-n)+n,n,r)},t.cf=Ns,t.cg=kd,t.ch=class{constructor(t,e,i,n){this.context=t,this.format=n,this.size=i,this.texture=t.gl.createTexture();const[r,o,s]=this.size,{gl:a}=t;a.bindTexture(a.TEXTURE_3D,this.texture),t.pixelStoreUnpackFlipY.set(!1),t.pixelStoreUnpack.set(1),t.pixelStoreUnpackPremultiplyAlpha.set(!1);let l=this.format,c=a.UNSIGNED_BYTE;this.format===a.DEPTH_COMPONENT&&(l=a.DEPTH_COMPONENT16,c=a.UNSIGNED_SHORT),this.format===a.R8&&(n=a.RED),this.format===a.R32F&&(c=a.FLOAT,n=a.RED),a.texImage3D(a.TEXTURE_3D,0,l,r,o,s,0,n,c,e.data)}bind(t,e){const{context:i}=this,{gl:n}=i;n.bindTexture(n.TEXTURE_3D,this.texture),t!==this.minFilter&&(n.texParameteri(n.TEXTURE_3D,n.TEXTURE_MAG_FILTER,t),n.texParameteri(n.TEXTURE_3D,n.TEXTURE_MIN_FILTER,t),this.minFilter=t),e!==this.wrapS&&(n.texParameteri(n.TEXTURE_3D,n.TEXTURE_WRAP_S,e),n.texParameteri(n.TEXTURE_3D,n.TEXTURE_WRAP_T,e),this.wrapS=e)}destroy(){const{gl:t}=this.context;t.deleteTexture(this.texture),this.texture=null}},t.ci=$v,t.cj=[1,1,1],t.ck=Xp,t.cl=Yv,t.cm=ql,t.cn=ic,t.co=class{constructor(){this._updateTime=0,this._sourceIds=[],this._activeRegions=[],this._prevRegions=[],this._globalClipBounds={min:new Ue(1/0,1/0),max:new Ue(-1/0,-1/0)}}clear(){this._activeRegions.length>0&&++this._updateTime,this._activeRegions=[],this._prevRegions=[]}get updateTime(){return this._updateTime}getReplacementRegionsForTile(t,e=!1){const i=$p(new Ue(0,0),new Ue(uo,uo),t),n=[];if(e&&!Lp(i,this._globalClipBounds))return n;for(const e of this._activeRegions){if(e.hiddenByOverlap)continue;if(!Lp(i,e))continue;const r=kp(e.min,e.max,t);n.push({min:r.min,max:r.max,sourceId:this._sourceIds[e.priority],footprint:e.footprint,footprintTileId:e.tileId,order:e.order,clipMask:e.clipMask})}return n}setSources(t){this._setSources(t.map((t=>({getSourceId:()=>t.cache.id,getFootprints:()=>{const e=[];for(const i of t.cache.getVisibleCoordinates()){const n=t.cache.getTile(i).buckets[t.layer];n&&n.updateFootprints(i.toUnwrapped(),e)}return e},getOrder:()=>t.order,getClipMask:()=>t.clipMask}))))}_addSource(t){const e=t.getFootprints();if(0===e.length)return;const i=t.getOrder(),n=t.getClipMask();for(const t of e){if(!t.footprint)continue;const e=$p(t.footprint.min,t.footprint.max,t.id);this._activeRegions.push({min:e.min,max:e.max,hiddenByOverlap:!1,priority:this._sourceIds.length,tileId:t.id,footprint:t.footprint,order:i,clipMask:n})}this._sourceIds.push(t.getSourceId())}_computeReplacement(){this._activeRegions.sort(((t,e)=>t.priority-e.priority||Ap(t.min,e.min)||Ap(t.max,e.max)));let t=this._activeRegions.length!==this._prevRegions.length;if(!t){let e=0;for(;!t&&e!==this._activeRegions.length;){const i=this._activeRegions[e],n=this._prevRegions[e];t=i.priority!==n.priority||!Ip(i,n)||i.order!==n.order||i.clipMask!==n.clipMask,++e}}if(t){++this._updateTime;for(const t of this._activeRegions)t.order!==1/0&&(this._globalClipBounds.min.x=Math.min(this._globalClipBounds.min.x,t.min.x),this._globalClipBounds.min.y=Math.min(this._globalClipBounds.min.y,t.min.y),this._globalClipBounds.max.x=Math.max(this._globalClipBounds.max.x,t.max.x),this._globalClipBounds.max.y=Math.max(this._globalClipBounds.max.y,t.max.y));const t=t=>{const e=this._activeRegions;if(t>=e.length)return t;const i=e[t].priority;for(;t1){let e=0,i=t(e);for(;e!==i;){let n=e;const r=e;for(;n!==i;){const t=this._activeRegions[n];t.hiddenByOverlap=!1;for(let e=0;e=0;e--)this._addSource(t[e]);this._computeReplacement()}},t.cp=Dl,t.cq=Jg,t.cr=rc,t.cs=class{constructor(t){this._createGrid(t),this._createPoles(t)}destroy(){this._poleIndexBuffer.destroy(),this._gridBuffer.destroy(),this._gridIndexBuffer.destroy(),this._poleNorthVertexBuffer.destroy(),this._poleSouthVertexBuffer.destroy();for(const t of this._poleSegments)t.destroy();for(const t of this._gridSegments)t.withSkirts.destroy(),t.withoutSkirts.destroy()}_fillGridMeshWithLods(t,e){const i=new $l,n=new Kl,r=[],o=t+1+2,s=e[0]+1,a=e[0]+1+(1+e.length),l=(t,e,i)=>{let n=t===o-1?t-2:0===t?t:t-1;return n+=i?24575:0,[n,e]};for(let t=0;tt()))},t.dB=sx,t.dC=yx,t.dD=function(t){px=ki.resolveURL(t),gx||(gx=new ox(ux(),new zn)),gx.broadcast("setDracoUrl",px)},t.dE=vx,t.dF=function(t){mx=ki.resolveURL(t),gx||(gx=new ox(ux(),new zn)),gx.broadcast("setMeshoptUrl",mx)},t.dG=ti,t.dH=ba,t.dI=dh,t.dJ=I_,t.dK=eg,t.dL=dc,t.dM=am,t.dN=Dm,t.dO=Wf,t.dP=ci,t.dQ=E_,t.dR=jg,t.dS=function(t,e,i,n,r,o,s,a,l,c,d){t.createArrays(),t.tilePixelRatio=uo/(512*t.overscaling),t.compareText={},t.iconsNeedLinear=!1;const u=t.layers[0].layout,h=t.layers[0]._unevaluatedLayout._values,p={};if("composite"===t.textSizeData.kind){const{minZoom:e,maxZoom:i}=t.textSizeData;p.compositeTextSizes=[h["text-size"].possiblyEvaluate(new Ha(e),a),h["text-size"].possiblyEvaluate(new Ha(i),a)]}if("composite"===t.iconSizeData.kind){const{minZoom:e,maxZoom:i}=t.iconSizeData;p.compositeIconSizes=[h["icon-size"].possiblyEvaluate(new Ha(e),a),h["icon-size"].possiblyEvaluate(new Ha(i),a)]}p.layoutTextSize=h["text-size"].possiblyEvaluate(new Ha(l+1),a),p.layoutIconSize=h["icon-size"].possiblyEvaluate(new Ha(l+1),a),p.textMaxSize=h["text-size"].possiblyEvaluate(new Ha(18),a);const f="map"===u.get("text-rotation-alignment")&&"point"!==u.get("symbol-placement"),m=u.get("text-size");let _=!1;for(const e of t.features)if(e.icon&&e.icon.nameSecondary){_=!0;break}for(const o of t.features){const l=u.get("text-font").evaluate(o,{},a).join(","),h=m.evaluate(o,{},a),g=p.layoutTextSize.evaluate(o,{},a),y=(p.layoutIconSize.evaluate(o,{},a),{horizontal:{},vertical:void 0}),v=o.text;let x,b=[0,0];if(v){const n=v.toString(),s=u.get("text-letter-spacing").evaluate(o,{},a)*Om,c=u.get("text-line-height").evaluate(o,{},a)*Om,d=Aa(n)?s:0,p=u.get("text-anchor").evaluate(o,{},a),m=u.get("text-variable-anchor");if(!m){const t=u.get("text-radial-offset").evaluate(o,{},a);b=t?G_(p,[t*Om,j_]):u.get("text-offset").evaluate(o,{},a).map((t=>t*Om))}let _=f?"center":u.get("text-justify").evaluate(o,{},a);const x="point"===u.get("symbol-placement"),w=x?u.get("text-max-width").evaluate(o,{},a)*Om:1/0,T=o=>{t.allowVerticalPlacement&&Ca(n)&&(y.vertical=e_(v,e,i,r,l,w,c,p,o,d,b,Jm.vertical,!0,g,h))};if(!f&&m){const t="auto"===_?m.map((t=>Z_(t))):[_];let n=!1;for(let o=0;o=0||!Ca(n)){const t=e_(v,e,i,r,l,w,c,p,_,d,b,Jm.horizontal,!1,g,h);t&&(y.horizontal[_]=t)}T(x?"left":_)}}let w=!1;if(o.icon&&o.icon.namePrimary){const e=n[o.icon.namePrimary];e&&(x=u_(r[o.icon.namePrimary],o.icon.nameSecondary?r[o.icon.nameSecondary]:void 0,u.get("icon-offset").evaluate(o,{},a),u.get("icon-anchor").evaluate(o,{},a)),w=e.sdf,void 0===t.sdfIcons?t.sdfIcons=e.sdf:t.sdfIcons!==e.sdf&&pi("Style sheet warning: Cannot mix SDF and non-SDF icons in one buffer"),(e.pixelRatio!==t.pixelRatio||0!==u.get("icon-rotate").constantOr(1))&&(t.iconsNeedLinear=!0))}const T=X_(y.horizontal)||y.vertical;t.iconsInText||(t.iconsInText=!!T&&T.iconsInText),(T||x)&&q_(t,o,y,x,n,p,g,0,b,w,s,a,c,d,_)}o&&t.generateCollisionDebugBuffers(l,t.collisionBoxArray)},t.dT=Jf,t.dU=Yh,t.dV=bp,t.dW=Lm,t.dX=Yp,t.dY=Zy,t.dZ=wp,t.d_=cp,t.da=Wu,t.db=function(e){const i=[0,0,0],n=t.ad.identity(new Float64Array(16));return t.ad.multiply(n,e.pixelMatrix,e.globeMatrix),t._.transformMat4(i,i,n),new Ue(i[0],i[1])},t.dc=d,t.dd=c,t.de=function(t){const e=t.navigator?t.navigator.userAgent:null;return!!function(t){if(null==Ei){const e=t.navigator?t.navigator.userAgent:null;Ei=!!t.safari||!(!e||!(/\b(iPad|iPhone|iPod)\b/.test(e)||e.match("Safari")&&!e.match("Chrome")))}return Ei}(t)&&e&&(e.match("Version/15.4")||e.match("Version/15.5")||e.match(/CPU (OS|iPhone OS) (15_4|15_5) like Mac OS X/))},t.df=ni,t.dg=class{constructor(t,e,i){this._transformRequestFn=t,this._customAccessToken=e,this._silenceAuthErrors=!!i,this._createSkuToken()}_createSkuToken(){const t=function(){let t="";for(let e=0;ethis._skuTokenExpiresAt}transformRequest(t,e){return this._transformRequestFn&&this._transformRequestFn(t,e)||{url:t}}normalizeStyleURL(t,i){if(!o(t))return t;const n=un(t);return n.params.push(`sdk=js-${e}`),n.path=`/styles/v1${n.path}`,this._makeAPIURL(n,this._customAccessToken||i)}normalizeGlyphsURL(t,e){if(!o(t))return t;const i=un(t);return i.path=`/fonts/v1${i.path}`,this._makeAPIURL(i,this._customAccessToken||e)}normalizeModelURL(t,e){if(!o(t))return t;const i=un(t);return i.path=`/models/v1${i.path}`,this._makeAPIURL(i,this._customAccessToken||e)}normalizeSourceURL(t,e,i,n){if(!o(t))return t;const r=un(t);return r.path=`/v4/${r.authority}.json`,r.params.push("secure"),i&&r.params.push(`language=${i}`),n&&r.params.push(`worldview=${n}`),this._makeAPIURL(r,this._customAccessToken||e)}normalizeSpriteURL(t,e,i,n){const r=un(t);return o(t)?(r.path=`/styles/v1${r.path}/sprite${e}${i}`,this._makeAPIURL(r,this._customAccessToken||n)):(r.path+=`${e}${i}`,hn(r))}normalizeTileURL(t,e,i){if(this._isSkuTokenExpired()&&this._createSkuToken(),t&&!o(t))return t;const r=un(t);r.path=r.path.replace(/(\.(png|jpg)\d*)(?=$)/,`${e||i&&"raster"!==r.authority&&512===i?"@2x":""}${Gi.supported?".webp":"$1"}`),"raster"===r.authority?r.path=`/${n.RASTER_URL_PREFIX}${r.path}`:"rasterarrays"===r.authority?r.path=`/${n.RASTERARRAYS_URL_PREFIX}${r.path}`:"3dtiles"===r.authority?r.path=`/${n.TILES3D_URL_PREFIX}${r.path}`:(r.path=r.path.replace(/^.+\/v4\//,"/"),r.path=`/${n.TILE_URL_VERSION}${r.path}`);const s=this._customAccessToken||function(t){for(const e of t){const t=e.match(/^access_token=(.*)$/);if(t)return t[1]}return null}(r.params)||n.ACCESS_TOKEN;return n.REQUIRE_ACCESS_TOKEN&&s&&this._skuToken&&r.params.push(`sku=${this._skuToken}`),this._makeAPIURL(r,s)}canonicalizeTileURL(t,e){const i=un(t);if(!i.path.match(/^(\/v4\/|\/(raster|rasterarrays)\/v1\/)/)||!i.path.match(/\.[\w]+$/))return t;let r="mapbox://";i.path.match(/^\/raster\/v1\//)?r+=`raster/${i.path.replace(`/${n.RASTER_URL_PREFIX}/`,"")}`:i.path.match(/^\/rasterarrays\/v1\//)?r+=`rasterarrays/${i.path.replace(`/${n.RASTERARRAYS_URL_PREFIX}/`,"")}`:r+=`tiles/${i.path.replace(`/${n.TILE_URL_VERSION}/`,"")}`;let o=i.params;return e&&(o=o.filter((t=>!t.match(/^access_token=/)))),o.length&&(r+=`?${o.join("&")}`),r}canonicalizeTileset(t,e){const i=!!e&&o(e),n=[];for(const e of t.tiles||[])r(e)?n.push(this.canonicalizeTileURL(e,i)):n.push(e);return n}_makeAPIURL(t,e){const i="See https://docs.mapbox.com/api/overview/#access-tokens-and-token-scopes",r=un(n.API_URL);if(t.protocol=r.protocol,t.authority=r.authority,"http"===t.protocol){const e=t.params.indexOf("secure");e>=0&&t.params.splice(e,1)}if("/"!==r.path&&(t.path=`${r.path}${t.path}`),!n.REQUIRE_ACCESS_TOKEN)return hn(t);if(e=e||n.ACCESS_TOKEN,!this._silenceAuthErrors){if(!e)throw new Error(`An API access token is required to use Mapbox GL. ${i}`);if("s"===e[0])throw new Error(`Use a public access token (pk.*) with Mapbox GL, not a secret access token (sk.*). ${i}`)}return t.params=t.params.filter((t=>-1===t.indexOf("access_token"))),t.params.push(`access_token=${e||""}`),hn(t)}},t.dh=function(t,e){e?Mn.add(t):Mn.delete(t)},t.di=Gi,t.dj=Tn,t.dk=En,t.dl=cn,t.dm=vn,t.dn=bn,t.dp=function(t){Mn.delete(t)},t.dq=Sn,t.dr=yn,t.ds=Qe,t.dt=e,t.du=function(t,e){Fi=t,Ni=e},t.dv=function(t,e,i=!1){if(Fa===za||Fa===Ra||Fa===Oa)throw new Error("setRTLTextPlugin cannot be called multiple times.");Na=ki.resolveURL(t),Fa=za,Ba=e,ja(),i||Za()},t.dw=Ga,t.dx=function(){ux().acquire(lx)},t.dy=function(){const t=dx;t&&(t.isPreloaded()&&1===t.numActive()?(t.release(lx),dx=null):console.warn("Could not clear WebWorkers since there are active Map instances that still reference it. The pre-warmed WebWorker pool can only be cleared when all map instances have been removed with map.remove()"))},t.dz=cx,t.e=ki,t.e0=cm,t.e1=h,t.e2=en,t.e3=function(t){let e=0;if(new Uint32Array(t,0,1)[0]!==Ax){const i=new Uint32Array(t,0,7),[,,n,r,o,s]=i;e=i.byteLength+r+o+s+o,(n!==t.byteLength||e>=t.byteLength)&&pi("Invalid b3dm header information.")}return Dx(t,e)},t.e4=function(t,e){const i=jx(t);for(const t of i){for(const e of t.meshes)Vx(e);t.lights&&(t.lightMeshIndex=t.meshes.length,t.meshes.push(Gx(t.lights,e)))}return i},t.e5=Kx,t.e6=rx,t.e7=qa,t.e8=function(t){ji(),Oi&&Oi.then((e=>{e.keys().then((i=>{for(let n=0;nt.arrayBuffer())).then((e=>Dx(e,0,t)))},t.m=class extends Uv{},t.n=Er,t.o=qn,t.p=Qg,t.q=Xs,t.r=Js,t.s=Qs,t.t=ca,t.u=al,t.v=ll,t.w=pi,t.x=pa,t.y=da,t.z=qo})),n(0,(function(t){function e(t){const e=t?t.url.toString():void 0;return e?performance.getEntriesByName(e):[]}function i(t){if("number"==typeof t||"boolean"==typeof t||"string"==typeof t||null==t)return JSON.stringify(t);if(Array.isArray(t)){let e="[";for(const n of t)e+=`${i(n)},`;return`${e}]`}let e="{";for(const n of Object.keys(t).sort())e+=`${n}:${i(t[n])},`;return`${e}}`}function n(e){let n="";for(const r of t.cE)n+=`/${i(e[r])}`;return n}class r{constructor(t){this.keyCache={},this._layers={},this._layerConfigs={},t&&this.replace(t)}replace(t,e){this._layerConfigs={},this._layers={},this.update(t,[],e)}update(e,i,r){this._options=r;for(const i of e)this._layerConfigs[i.id]=i,(this._layers[i.id]=t.cY(i,this.scope,null,this._options)).compileFilter(),this.keyCache[i.id]&&delete this.keyCache[i.id];for(const t of i)delete this.keyCache[t],delete this._layerConfigs[t],delete this._layers[t];this.familiesBySource={};const o=function(t,e){const i={};for(let r=0;rthis._layers[t.id])),i=e[0];if("none"===i.visibility)continue;const n=i.source||"";let r=this.familiesBySource[n];r||(r=this.familiesBySource[n]={});const o=i.sourceLayer||"_geojsonTileLayer";let s=r[o];s||(s=r[o]=[]),s.push(e)}}}const o=1*t.dJ;class s{constructor(e){const i={},n=[];for(const t in e){const r=e[t],s=i[t]={};for(const t in r.glyphs){const e=r.glyphs[+t];if(!e||0===e.bitmap.width||0===e.bitmap.height)continue;const i=e.metrics.localGlyph?o:1,a={x:0,y:0,w:e.bitmap.width+2*i,h:e.bitmap.height+2*i};n.push(a),s[t]=a}}const{w:r,h:s}=t.j(n),a=new t.dI({width:r||1,height:s||1});for(const n in e){const r=e[n];for(const e in r.glyphs){const s=r.glyphs[+e];if(!s||0===s.bitmap.width||0===s.bitmap.height)continue;const l=i[n][e],c=s.metrics.localGlyph?o:1;t.dI.copy(s.bitmap,a,{x:0,y:0},{x:l.x+c,y:l.y+c},s.bitmap)}}this.image=a,this.positions=i}}t.dH(s,"GlyphAtlas");class a{constructor(e){this.tileID=new t.aL(e.tileID.overscaledZ,e.tileID.wrap,e.tileID.canonical.z,e.tileID.canonical.x,e.tileID.canonical.y),this.tileZoom=e.tileZoom,this.uid=e.uid,this.zoom=e.zoom,this.lut=e.lut,this.canonical=e.tileID.canonical,this.pixelRatio=e.pixelRatio,this.tileSize=e.tileSize,this.source=e.source,this.scope=e.scope,this.overscaling=this.tileID.overscaleFactor(),this.showCollisionBoxes=e.showCollisionBoxes,this.collectResourceTiming=!!e.collectResourceTiming,this.promoteId=e.promoteId,this.isSymbolTile=e.isSymbolTile,this.tileTransform=t.dK(e.tileID.canonical,e.projection),this.projection=e.projection,this.brightness=e.brightness,this.extraShadowCaster=!!e.extraShadowCaster,this.tessellationStep=e.tessellationStep}parse(e,i,n,r,o){this.status="parsing",this.data=e,this.collisionBoxArray=new t.dL;const a=new t.dM(Object.keys(e.layers).sort()),c=new t.dN(this.tileID,this.promoteId);c.bucketLayerIDs=[];const d={},u=new t.dO(256,256),h={featureIndex:c,iconDependencies:{},patternDependencies:{},glyphDependencies:{},lineAtlas:u,availableImages:n,brightness:this.brightness},p=i.familiesBySource[this.source];for(const i in p){const r=e.layers[i];if(!r)continue;let o=!1,s=!1,u=!1;for(const t of p[i])"symbol"===t[0].type?o=!0:s=!0,t[0].is3D()&&"model"!==t[0].type&&(u=!0);if(this.extraShadowCaster&&!u)continue;if(!0===this.isSymbolTile&&!o)continue;if(!1===this.isSymbolTile&&!s)continue;1===r.version&&t.w(`Vector tile source "${this.source}" layer "${i}" does not use vector tile spec v2 and therefore may have some rendering errors.`);const f=a.encode(i),m=[];for(let t=0;t=e.maxzoom||"none"!==e.visibility&&(l(t,this.zoom,h.brightness,n),(d[e.id]=e.createBucket({index:c.bucketLayerIDs.length,layers:t,zoom:this.zoom,lut:this.lut,canonical:this.canonical,pixelRatio:this.pixelRatio,overscaling:this.overscaling,collisionBoxArray:this.collisionBoxArray,sourceLayerIndex:f,sourceID:this.source,projection:this.projection.spec,tessellationStep:this.tessellationStep})).populate(m,h,this.tileID.canonical,this.tileTransform),c.bucketLayerIDs.push(t.map((t=>t.id)))))}}let f,m,_,g;u.trim();const y={type:"maybePrepare",isSymbolTile:this.isSymbolTile,zoom:this.zoom},v=()=>{if(f)return this.status="done",o(f);if(this.extraShadowCaster)this.status="done",o(null,{buckets:t.dG(d).filter((t=>!t.isEmpty())),featureIndex:c,collisionBoxArray:null,glyphAtlasImage:null,lineAtlas:null,imageAtlas:null,brightness:h.brightness,glyphMap:null,iconMap:null,glyphPositions:null});else if(m&&_&&g){const e=new s(m),i=new t.dQ(_,g,this.lut);for(const r in d){const o=d[r];o instanceof t.dR?(l(o.layers,this.zoom,h.brightness,n),t.dS(o,m,e.positions,_,i.iconPositions,this.showCollisionBoxes,n,this.tileID.canonical,this.tileZoom,this.projection,this.brightness)):o.hasPattern&&(o instanceof t.dT||o instanceof t.dU||o instanceof t.b_)&&(l(o.layers,this.zoom,h.brightness,n),o.addFeatures(h,this.tileID.canonical,i.patternPositions,n,this.tileTransform,this.brightness))}this.status="done",o(null,{buckets:t.dG(d).filter((t=>!t.isEmpty())),featureIndex:c,collisionBoxArray:this.collisionBoxArray,glyphAtlasImage:e.image,lineAtlas:u,imageAtlas:i,brightness:h.brightness})}};if(!this.extraShadowCaster){const e=t.dP(h.glyphDependencies,(t=>Object.keys(t).map(Number)));Object.keys(e).length?r.send("getGlyphs",{uid:this.uid,stacks:e,scope:this.scope},((t,e)=>{f||(f=t,m=e,v())}),void 0,!1,y):m={};const i=Object.keys(h.iconDependencies);i.length?r.send("getImages",{icons:i,source:this.source,scope:this.scope,tileID:this.tileID,type:"icons"},((t,e)=>{f||(f=t,_=e,v())}),void 0,!1,y):_={};const n=Object.keys(h.patternDependencies);n.length?r.send("getImages",{icons:n,source:this.source,scope:this.scope,tileID:this.tileID,type:"patterns"},((t,e)=>{f||(f=t,g=e,v())}),void 0,!1,y):g={}}v()}}function l(e,i,n,r){const o=new t.X(i,{brightness:n});for(const t of e)t.recalculate(o,r)}class c extends t.E{constructor(e,i,n,r,o,s){super(),this.actor=e,this.layerIndex=i,this.availableImages=n,this.loadVectorData=o||t.ap,this.loading={},this.loaded={},this.deduped=new t.ao(e.scheduler),this.isSpriteLoaded=r,this.scheduler=e.scheduler,this.brightness=s}loadTile(i,n){const r=i.uid,o=i&&i.request,s=o&&o.collectResourceTiming,l=this.loading[r]=new a(i);l.abort=this.loadVectorData(i,((a,c)=>{const d=!this.loading[r];if(delete this.loading[r],d||a||!c)return l.status="done",d||(this.loaded[r]=l),n(a);const u=c.rawData,h={};c.expires&&(h.expires=c.expires),c.cacheControl&&(h.cacheControl=c.cacheControl),l.vectorTile=c.vectorTile||new t.dV(new t.dW(u));const p=()=>{l.parse(l.vectorTile,this.layerIndex,this.availableImages,this.actor,((i,r)=>{if(i||!r)return n(i);const a={};if(s){const t=e(o);t.length>0&&(a.resourceTiming=JSON.parse(JSON.stringify(t)))}n(null,t.W({rawTileData:u.slice(0)},r,h,a))}))};this.isSpriteLoaded?p():this.once("isSpriteLoaded",(()=>{this.scheduler?this.scheduler.add(p,{type:"parseTile",isSymbolTile:i.isSymbolTile,zoom:i.tileZoom}):p()})),this.loaded=this.loaded||{},this.loaded[r]=l}))}reloadTile(e,i){const n=this.loaded,r=e.uid;if(n&&n[r]){const o=n[r];o.showCollisionBoxes=e.showCollisionBoxes,o.projection=e.projection,o.brightness=e.brightness,o.tileTransform=t.dK(e.tileID.canonical,e.projection),o.extraShadowCaster=e.extraShadowCaster,o.lut=e.lut;const s=(t,e)=>{const n=o.reloadCallback;n&&(delete o.reloadCallback,o.parse(o.vectorTile,this.layerIndex,this.availableImages,this.actor,n)),i(t,e)};"parsing"===o.status?o.reloadCallback=s:"done"===o.status&&(o.vectorTile?o.parse(o.vectorTile,this.layerIndex,this.availableImages,this.actor,s):s())}else i(null,void 0)}abortTile(t,e){const i=t.uid,n=this.loading[i];n&&(n.abort&&n.abort(),delete this.loading[i]),e()}removeTile(t,e){const i=this.loaded,n=t.uid;i&&i[n]&&delete i[n],e()}}class d{loadTile(e,i){const{uid:n,encoding:r,rawImageData:o,padding:s}=e,a=ImageBitmap&&o instanceof ImageBitmap?this.getImageData(o,s):o;i(null,new t.dX(n,a,r,s{n(null,t)}),(t=>{n(t)}))}}const h=t.dZ.prototype.toGeoJSON;let p=class{constructor(e){this._feature=e,this.extent=t.a3,this.type=e.type,this.properties=e.tags,"id"in e&&!isNaN(e.id)&&(this.id=parseInt(e.id,10))}loadGeometry(){if(1===this._feature.type){const e=[];for(const i of this._feature.geometry)e.push([new t.P(i[0],i[1])]);return e}{const e=[];for(const i of this._feature.geometry){const n=[];for(const e of i)n.push(new t.P(e[0],e[1]));e.push(n)}return e}}toGeoJSON(t,e,i){return h.call(this,t,e,i)}},f=class{constructor(e){this.layers={_geojsonTileLayer:this},this.name="_geojsonTileLayer",this.extent=t.a3,this.length=e.length,this._features=e}feature(t){return new p(this._features[t])}};const m=64/4096;class _{constructor(){this.features=new Map}clear(){this.features.clear()}load(t=[],e){for(const i of t){const t=i.id;if(null==t)continue;let n=this.features.get(t);n&&this.updateCache(n,e),i.geometry?(n=y(i),this.updateCache(n,e),this.features.set(t,n)):this.features.delete(t),this.updateCache(n,e)}}updateCache(t,e){for(const{canonical:i,uid:n}of Object.values(e)){const{z:r,x:o,y:s}=i;g(t,Math.pow(2,r),o,s)&&delete e[n]}}getTile(t,e,i){const n=Math.pow(2,t),r=[];for(const t of this.features.values())g(t,n,e,i)&&r.push(w(t,n,e,i));return{features:r}}getFeatures(){return[...this.features.values()]}}function g({minX:t,minY:e,maxX:i,maxY:n},r,o,s){return t(o-m)/r&&n>(s-m)/r}function y(t){const{id:e,geometry:i,properties:n}=t;if(!i)return;if("GeometryCollection"===i.type)throw new Error("GeometryCollection not supported in dynamic mode.");const{type:r,coordinates:o}=i,s={id:e,type:1,geometry:[],tags:n,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0},a=s.geometry;if("Point"===r)v(o,a,s);else if("MultiPoint"===r)for(const t of o)v(t,a,s);else if("LineString"===r)s.type=2,x(o,a,s);else if("MultiLineString"===r)s.type=2,b(o,a,s);else if("Polygon"===r)s.type=3,b(o,a,s,!0);else{if("MultiPolygon"!==r)throw new Error("Input data is not a valid GeoJSON object.");s.type=3;for(const t of o)b(t,a,s,!0)}return s}function v([e,i],n,r){const o=t.aj(e);let s=t.ak(i);s=s1?1:s,n.push(o,s),r.minX=Math.min(r.minX,o),r.minY=Math.min(r.minY,s),r.maxX=Math.max(r.maxX,o),r.maxY=Math.max(r.maxY,s)}function x(t,e,i,n=!1,r=!1){const o=[];for(const e of t)v(e,o,i);e.push(o),n&&function(t,e){let i=0;for(let e=0,n=t.length,r=n-2;e0===e)for(let e=0,i=t.length;e>31}function F(t,e){for(var i=t.loadGeometry(),n=t.type,r=0,o=0,s=i.length,a=0;at},V=Math.fround||(G=new Float32Array(1),t=>(G[0]=+t,G[0]));var G;const Z=3,q=5,H=6;class W{constructor(t){this.options=Object.assign(Object.create(j),t),this.trees=new Array(this.options.maxZoom+1),this.stride=this.options.reduce?7:6,this.clusterProps=[]}load(t){const{log:e,minZoom:i,maxZoom:n}=this.options;e&&console.time("total time");const r=`prepare ${t.length} points`;e&&console.time(r),this.points=t;const o=[];for(let e=0;e=i;t--){const i=+Date.now();s=this.trees[t]=this._createTree(this._cluster(s,t)),e&&console.log("z%d: %d clusters in %dms",t,s.numItems,+Date.now()-i)}return e&&console.timeEnd("total time"),this}getClusters(t,e){let i=((t[0]+180)%360+360)%360-180;const n=Math.max(-90,Math.min(90,t[1]));let r=180===t[2]?180:((t[2]+180)%360+360)%360-180;const o=Math.max(-90,Math.min(90,t[3]));if(t[2]-t[0]>=360)i=-180,r=180;else if(i>r){const t=this.getClusters([i,n,180,o],e),s=this.getClusters([-180,n,r,o],e);return t.concat(s)}const s=this.trees[this._limitZoom(e)],a=s.range(K(i),J(o),K(r),J(n)),l=s.data,c=[];for(const t of a){const e=this.stride*t;c.push(l[e+q]>1?Y(l,e,this.clusterProps):this.points[l[e+Z]])}return c}getChildren(t){const e=this._getOriginId(t),i=this._getOriginZoom(t),n="No cluster with the specified id.",r=this.trees[i];if(!r)throw new Error(n);const o=r.data;if(e*this.stride>=o.length)throw new Error(n);const s=this.options.radius/(this.options.extent*Math.pow(2,i-1)),a=r.within(o[e*this.stride],o[e*this.stride+1],s),l=[];for(const e of a){const i=e*this.stride;o[i+4]===t&&l.push(o[i+q]>1?Y(o,i,this.clusterProps):this.points[o[i+Z]])}if(0===l.length)throw new Error(n);return l}getLeaves(t,e,i){const n=[];return this._appendLeaves(n,t,e=e||10,i=i||0,0),n}getTile(t,e,i){const n=this.trees[this._limitZoom(t)],r=Math.pow(2,t),{extent:o,radius:s}=this.options,a=s/o,l=(i-a)/r,c=(i+1+a)/r,d={features:[]};return this._addTileFeatures(n.range((e-a)/r,l,(e+1+a)/r,c),n.data,e,i,r,d),0===e&&this._addTileFeatures(n.range(1-a/r,l,1,c),n.data,r,i,r,d),e===r-1&&this._addTileFeatures(n.range(0,l,a/r,c),n.data,-1,i,r,d),d.features.length?d:null}getClusterExpansionZoom(t){let e=this._getOriginZoom(t)-1;for(;e1;let l,c,d;if(a)l=X(e,t,this.clusterProps),c=e[t],d=e[t+1];else{const i=this.points[e[t+Z]];l=i.properties;const[n,r]=i.geometry.coordinates;c=K(n),d=J(r)}const u={type:1,geometry:[[Math.round(this.options.extent*(c*r-i)),Math.round(this.options.extent*(d*r-n))]],tags:l};let h;h=a||this.options.generateId?e[t+Z]:this.points[e[t+Z]].id,void 0!==h&&(u.id=h),o.features.push(u)}}_limitZoom(t){return Math.max(this.options.minZoom,Math.min(Math.floor(+t),this.options.maxZoom+1))}_cluster(t,e){const{radius:i,extent:n,reduce:r,minPoints:o}=this.options,s=i/(n*Math.pow(2,e)),a=t.data,l=[],c=this.stride;for(let i=0;ie&&(p+=a[i+q])}if(p>h&&p>=o){let t,o=n*h,s=d*h,f=-1;const m=(i/c1)for(const t of u){const i=t*c;if(!(a[i+2]>5}_getOriginZoom(t){return(t-this.points.length)%32}_map(t,e,i){if(t[e+q]>1){const n=this.clusterProps[t[e+H]];return i?Object.assign({},n):n}const n=this.points[t[e+Z]].properties,r=this.options.map(n);return i&&r===n?Object.assign({},r):r}}function Y(t,e,i){return{type:"Feature",id:t[e+Z],properties:X(t,e,i),geometry:{type:"Point",coordinates:[(n=t[e],360*(n-.5)),Q(t[e+1])]}};var n}function X(t,e,i){const n=t[e+q],r=n>=1e4?`${Math.round(n/1e3)}k`:n>=1e3?Math.round(n/100)/10+"k":n,o=t[e+H],s=-1===o?{}:Object.assign({},i[o]);return Object.assign(s,{cluster:!0,cluster_id:t[e+Z],point_count:n,point_count_abbreviated:r})}function K(t){return t/360+.5}function J(t){const e=Math.sin(t*Math.PI/180),i=.5-.25*Math.log((1+e)/(1-e))/Math.PI;return i1?1:i}function Q(t){const e=(180-360*t)*Math.PI/180;return 360*Math.atan(Math.exp(e))/Math.PI-90}function tt(t,e,i,n){let r=n;const o=e+(i-e>>1);let s,a=i-e;const l=t[e],c=t[e+1],d=t[i],u=t[i+1];for(let n=e+3;n 239?4:l>223?3:l>191?2:1;if(r+d>i)break;1===d?l=55296&&c=1114112)&&(c=null)),null===c?(c=65533,d=1):c>65535&&(c-=65536,n+=String.fromCharCode(c>>>10&1023|55296),c=56320|1023&c),n+=String.fromCharCode(c),r+=d}return n}(this.buf,e,t)},readBytes:function(){var t=this.readVarint()+this.pos,e=this.buf.subarray(this.pos,t);return this.pos=t,e},readPackedVarint:function(t,e){if(this.type!==um.Bytes)return t.push(this.readVarint(e));var i=mm(this);for(t=t||[];this.pos127;);else if(e===um.Bytes)this.pos=this.readVarint()+this.pos;else if(e===um.Fixed32)this.pos+=4;else{if(e!==um.Fixed64)throw new Error("Unimplemented type: "+e);this.pos+=8}},writeTag:function(t,e){this.writeVarint(t268435455||t=0?(i=t%4294967296|0,n=t/4294967296|0):(n=~(-t/4294967296),4294967295^(i=~(-t%4294967296))?i=i+1|0:(i=0,n=n+1|0)),t>=0x10000000000000000||t>>=7,i.buf[i.pos++]=127&t|128,t>>>=7,i.buf[i.pos++]=127&t|128,t>>>=7,i.buf[i.pos++]=127&t|128,i.buf[i.pos]=127&(t>>>=7)}(i,0,e),function(t,e){var i=(7&t)>>=3)?128:0),t&&(e.buf[e.pos++]=127&t|((t>>>=7)?128:0),t&&(e.buf[e.pos++]=127&t|((t>>>=7)?128:0),t&&(e.buf[e.pos++]=127&t|((t>>>=7)?128:0),t&&(e.buf[e.pos++]=127&t|((t>>>=7)?128:0),t&&(e.buf[e.pos++]=127&t)))))}(n,e)}(t,this):(this.realloc(4),this.buf[this.pos++]=127&t|(t>127?128:0),t>>=7)|(t>127?128:0),t>>=7)|(t>127?128:0),t>>7&127))))},writeSVarint:function(t){this.writeVarint(t55295&&n56319||o+1===e.length?(t[i++]=239,t[i++]=191,t[i++]=189):r=n;continue}if(n>6|192:(n>12|224:(t[i++]=n>>18|240,t[i++]=n>>12&63|128),t[i++]=n>>6&63|128),t[i++]=63&n|128)}return i}(this.buf,t,this.pos);var i=this.pos-e;i>=128&&gm(e,i,this),this.pos=e-1,this.writeVarint(i),this.pos+=i},writeFloat:function(t){this.realloc(4),dm.write(this.buf,t,this.pos,!0,23,4),this.pos+=4},writeDouble:function(t){this.realloc(8),dm.write(this.buf,t,this.pos,!0,52,8),this.pos+=8},writeBytes:function(t){var e=t.length;this.writeVarint(e),this.realloc(e);for(var i=0;i=128&&gm(i,n,this),this.pos=i-1,this.writeVarint(n),this.pos+=n},writeMessage:function(t,e,i){this.writeTag(t,um.Bytes),this.writeRawMessage(e,i)},writePackedVarint:function(t,e){e.length&&this.writeMessage(t,ym,e)},writePackedSVarint:function(t,e){e.length&&this.writeMessage(t,vm,e)},writePackedBoolean:function(t,e){e.length&&this.writeMessage(t,wm,e)},writePackedFloat:function(t,e){e.length&&this.writeMessage(t,xm,e)},writePackedDouble:function(t,e){e.length&&this.writeMessage(t,bm,e)},writePackedFixed32:function(t,e){e.length&&this.writeMessage(t,Tm,e)},writePackedSFixed32:function(t,e){e.length&&this.writeMessage(t,Sm,e)},writePackedFixed64:function(t,e){e.length&&this.writeMessage(t,Em,e)},writePackedSFixed64:function(t,e){e.length&&this.writeMessage(t,Mm,e)},writeBytesField:function(t,e){this.writeTag(t,um.Bytes),this.writeBytes(e)},writeFixed32Field:function(t,e){this.writeTag(t,um.Fixed32),this.writeFixed32(e)},writeSFixed32Field:function(t,e){this.writeTag(t,um.Fixed32),this.writeSFixed32(e)},writeFixed64Field:function(t,e){this.writeTag(t,um.Fixed64),this.writeFixed64(e)},writeSFixed64Field:function(t,e){this.writeTag(t,um.Fixed64),this.writeSFixed64(e)},writeVarintField:function(t,e){this.writeTag(t,um.Varint),this.writeVarint(e)},writeSVarintField:function(t,e){this.writeTag(t,um.Varint),this.writeSVarint(e)},writeStringField:function(t,e){this.writeTag(t,um.Bytes),this.writeString(e)},writeFloatField:function(t,e){this.writeTag(t,um.Fixed32),this.writeFloat(e)},writeDoubleField:function(t,e){this.writeTag(t,um.Fixed64),this.writeDouble(e)},writeBooleanField:function(t,e){this.writeVarintField(t,Boolean(e))}};var Lm=h(cm);const Pm=["id","tile","layer","source","sourceLayer","state"];class $m{constructor(t,e,i,n,r){this.type="Feature",this._vectorTileFeature=t,this._z=e,this._x=i,this._y=n,this.properties=t.properties,this.id=r}get geometry(){return void 0===this._geometry&&(this._geometry=this._vectorTileFeature.toGeoJSON(this._x,this._y,this._z).geometry),this._geometry}set geometry(t){this._geometry=t}toJSON(){const t={type:"Feature",state:void 0,geometry:this.geometry,properties:this.properties};for(const e of Pm)void 0!==this[e]&&(t[e]=this[e]);return t}}class km{constructor(){this.state={},this.stateChanges={},this.deletedStates={}}updateState(t,e,i){const n=String(e);if(this.stateChanges[t]=this.stateChanges[t]||{},this.stateChanges[t][n]=this.stateChanges[t][n]||{},ei(this.stateChanges[t][n],i),null===this.deletedStates[t]){this.deletedStates[t]={};for(const e in this.state[t])e!==n&&(this.deletedStates[t][e]=null)}else if(this.deletedStates[t]&&null===this.deletedStates[t][n]){this.deletedStates[t][n]={};for(const e in this.state[t][n])i[e]||(this.deletedStates[t][n][e]=null)}else for(const e in i)this.deletedStates[t]&&this.deletedStates[t][n]&&null===this.deletedStates[t][n][e]&&delete this.deletedStates[t][n][e]}removeFeatureState(t,e,i){if(null===this.deletedStates[t])return;const n=String(e);if(this.deletedStates[t]=this.deletedStates[t]||{},i&&void 0!==e)null!==this.deletedStates[t][n]&&(this.deletedStates[t][n]=this.deletedStates[t][n]||{},this.deletedStates[t][n][i]=null);else if(void 0!==e)if(this.stateChanges[t]&&this.stateChanges[t][n])for(i in this.deletedStates[t][n]={},this.stateChanges[t][n])this.deletedStates[t][n][i]=null;else this.deletedStates[t][n]=null;else this.deletedStates[t]=null}getState(t,e){const i=String(e),n=ei({},(this.state[t]||{})[i],(this.stateChanges[t]||{})[i]);if(null===this.deletedStates[t])return{};if(this.deletedStates[t]){const i=this.deletedStates[t][e];if(null===i)return{};for(const t in i)delete n[t]}return n}initializeTileState(t,e){t.setFeatureState(this.state,e)}coalesceChanges(t,e){const i={};for(const t in this.stateChanges){this.state[t]=this.state[t]||{};const e={};for(const i in this.stateChanges[t])this.state[t][i]||(this.state[t][i]={}),ei(this.state[t][i],this.stateChanges[t][i]),e[i]=this.state[t][i];i[t]=e}for(const t in this.deletedStates){this.state[t]=this.state[t]||{};const e={};if(null===this.deletedStates[t])for(const i in this.state[t])e[i]={},this.state[t][i]={};else for(const i in this.deletedStates[t]){if(null===this.deletedStates[t][i])this.state[t][i]={};else if(this.state[t][i])for(const e of Object.keys(this.deletedStates[t][i]))delete this.state[t][i][e];e[i]=this.state[t][i]}i[t]=i[t]||{},ei(i[t],e)}if(this.stateChanges={},this.deletedStates={},0!==Object.keys(i).length)for(const n in t)t[n].setFeatureState(i,e)}}class Dm{constructor(t,e){this.tileID=t,this.x=t.canonical.x,this.y=t.canonical.y,this.z=t.canonical.z,this.grid=new va(uo,16,0),this.featureIndexArray=new yc,this.promoteId=e,this.is3DTile=!1}insert(t,e,i,n,r,o=0,s=0){const a=this.featureIndexArray.length;this.featureIndexArray.emplaceBack(i,n,r,o);const l=this.grid;for(let t=0;t=0&&n[3]>=0&&l.insert(a,n[0],n[1],n[2],n[3])}}loadVTLayers(){if(!this.vtLayers){this.vtLayers=new bp(new Lm(this.rawTileData)).layers,this.sourceLayerCoder=new am(this.vtLayers?Object.keys(this.vtLayers).sort():["_geojsonTileLayer"]),this.vtFeatures={};for(const t in this.vtLayers)this.vtFeatures[t]=[]}return this.vtLayers}query(t,e,i,n){this.loadVTLayers();const r=t.params||{},o=dl(r.filter),s=t.tileResult,a=t.transform,l=s.bufferedTilespaceBounds,c=this.grid.query(l.min.x,l.min.y,l.max.x,l.max.y,((t,e,i,n)=>ou(s.bufferedTilespaceGeometry,t,e,i,n)));c.sort(Rm);let d=null;a.elevation&&c.length>0&&(d=Xp.create(a.elevation,this.tileID));const u={};let h;for(let l=0;l(m||(m=Gd(e,this.tileID.canonical,t.tileTransform)),i.queryIntersectsFeature(s,e,n,m,this.z,t.transform,t.pixelPosMatrix,d,r))))}return u}loadMatchingFeature(t,e,i,n,r,o,s,a,l){const{featureIndex:c,bucketIndex:d,sourceLayerIndex:u,layoutVertexArrayOffset:h}=e,p=this.bucketLayerIDs[d];if(n&&!function(t,e){for(let i=0;i=0)return!0;return!1}(n,p))return;const f=this.sourceLayerCoder.decode(u),m=this.vtLayers[f].feature(c);if(i.needGeometry){const t=Zd(m,!0);if(!i.filter(new Ha(this.tileID.overscaledZ),t,this.tileID.canonical))return}else if(!i.filter(new Ha(this.tileID.overscaledZ),m))return;const _=this.getId(m,f);for(let e=0;e{const s=e instanceof el?e.get(o):null;return s&&s.evaluate?s.evaluate(i,n,r):s}))}function Rm(t,e){return e-t}ba(Dm,"FeatureIndex",{omit:["rawTileData","sourceLayerCoder"]});var Om=24;const Bm=128;function Fm(t,e){const{expression:i}=e;if("constant"===i.kind)return{kind:"constant",layoutSize:i.evaluate(new Ha(t+1))};if("source"===i.kind)return{kind:"source"};{const{zoomStops:e,interpolationType:n}=i;let r=0;for(;r{t.text=function(t,e,i){const n=e.layout.get("text-transform").evaluate(i,{});return"uppercase"===n?t=t.toLocaleUpperCase():"lowercase"===n&&(t=t.toLocaleLowerCase()),qa.applyArabicShaping&&(t=qa.applyArabicShaping(t)),t}(t.text,e,i)})),t}const Gm={"!":"︕","#":"#",$:"$","%":"%","&":"&","(":"︵",")":"︶","*":"*","+":"+",",":"︐","-":"︲",".":"・","/":"/",":":"︓",";":"︔","":"﹀","?":"︖","@":"@","[":"﹇","\\":"\","]":"﹈","^":"^",_:"︳","`":"`","{":"︷","|":"―","}":"︸","~":"~","¢":"¢","£":"£","¥":"¥","¦":"¦","¬":"¬","¯":" ̄","–":"︲","—":"︱","‘":"﹃","’":"﹄","“":"﹁","”":"﹂","…":"︙","‧":"・","₩":"₩","、":"︑","。":"︒","〈":"︿","〉":"﹀","《":"︽","》":"︾","「":"﹁","」":"﹂","『":"﹃","』":"﹄","【":"︻","】":"︼","〔":"︹","〕":"︺","〖":"︗","〗":"︘","!":"︕","(":"︵",")":"︶",",":"︐","-":"︲",".":"・",":":"︓",";":"︔","<":"︿",">":"﹀","?":"︖","[":"﹇","]":"﹈","_":"︳","{":"︷","|":"―","}":"︸","⦅":"︵","⦆":"︶","。":"︒","「":"﹁","」":"﹂","←":"↑","→":"↓"};function Zm(t){return"︶"===t||"﹈"===t||"︸"===t||"﹄"===t||"﹂"===t||"︾"===t||"︼"===t||"︺"===t||"︘"===t||"﹀"===t||"︐"===t||"︓"===t||"︔"===t||"`"===t||" ̄"===t||"︑"===t||"︒"===t}function qm(t){return"︵"===t||"﹇"===t||"︷"===t||"﹃"===t||"﹁"===t||"︽"===t||"︻"===t||"︹"===t||"︗"===t||"︿"===t}const Hm=3;function Wm(t,e,i){e.glyphs=[],1===t&&i.readMessage(Ym,e)}function Ym(t,e,i){if(3===t){const{id:t,bitmap:n,width:r,height:o,left:s,top:a,advance:l}=i.readMessage(Xm,{});e.glyphs.push({id:t,bitmap:new dh({width:r+2*Hm,height:o+2*Hm},n),metrics:{width:r,height:o,left:s,top:a,advance:l}})}else 4===t?e.ascender=i.readSVarint():5===t&&(e.descender=i.readSVarint())}function Xm(t,e,i){1===t?e.id=i.readVarint():2===t?e.bitmap=i.readBytes():3===t?e.width=i.readVarint():4===t?e.height=i.readVarint():5===t?e.left=i.readSVarint():6===t?e.top=i.readSVarint():7===t&&(e.advance=i.readVarint())}const Km=Hm,Jm={horizontal:1,vertical:2,horizontalOnly:3};class Qm{constructor(){this.scale=1,this.fontStack="",this.imageName=null}static forText(t,e){const i=new Qm;return i.scale=t||1,i.fontStack=e,i}static forImage(t){const e=new Qm;return e.imageName=t,e}}class t_{constructor(){this.text="",this.sectionIndex=[],this.sections=[],this.imageSectionID=null}static fromFeature(t,e){const i=new t_;for(let n=0;n=0&&i>=t&&i_[this.text.charCodeAt(i)];i--)e--;this.text=this.text.substring(t,e),this.sectionIndex=this.sectionIndex.slice(t,e)}substring(t,e){const i=new t_;return i.text=this.text.substring(t,e),i.sectionIndex=this.sectionIndex.slice(t,e),i.sections=this.sections,i}toString(){return this.text}getMaxScale(){return this.sectionIndex.reduce(((t,e)=>Math.max(t,this.sections[e].scale)),0)}addTextSection(t,e){this.text+=t.text,this.sections.push(Qm.forText(t.scale,t.fontStack||e));const i=this.sections.length-1;for(let e=0;e=63743?null:++this.imageSectionID:(this.imageSectionID=57344,this.imageSectionID)}}function e_(t,e,i,n,r,o,s,a,l,c,d,u,h,p,f){const m=t_.fromFeature(t,r);u===Jm.vertical&&m.verticalizePunctuation(h);let _=[];const g=function(t,e,i,n,r,o){if(!t)return[];const s=[],a=function(t,e,i,n,r,o){let s=0;for(let i=0;i=0;let c=0;for(let i=0;i0&&o>b&&(b=o)}else{const t=i[a.fontStack];if(!t)continue;t[m]&&(S=t[m]);const n=e[a.fontStack];if(!n)continue;const o=n.glyphs[m];if(!o)continue;if(v=o.metrics,M=8203!==m?Om:0,_){const t=void 0!==n.ascender?Math.abs(n.ascender):0,e=void 0!==n.descender?Math.abs(n.descender):0,i=(t+e)*g;w-i/2;){if(s--,sn;)c-=l.shift().angleDelta;if(c>r)return!1;s++,a+=e.dist(i)}return!0}function m_(t){let e=0;for(let i=0;ic){const d=(c-l)/o,u=Vn(n.x,r.x,d),h=Vn(n.y,r.y,d),p=new p_(u,h,0,r.angleTo(n),i);return!s||f_(t,p,a,s,e)?p:void 0}l+=o}}function v_(t,e,i,n,r,o,s,a,l){const c=__(n,o,s),d=g_(n,r),u=d*s,h=0===t[0].x||t[0].x===l||0===t[0].y||t[0].y===l;return e-u=0&&g=0&&y=0&&h+c=n&&c.x>=n||(s.x>=n?s=new Ue(n,s.y+(n-s.x)/(c.x-s.x)*(c.y-s.y))._round():c.x>=n&&(c=new Ue(n,s.y+(n-s.x)/(c.x-s.x)*(c.y-s.y))._round()),s.y>=r&&c.y>=r||(s.y>=r?s=new Ue(s.x+(r-s.y)/(c.y-s.y)*(c.x-s.x),r)._round():c.y>=r&&(c=new Ue(s.x+(r-s.y)/(c.y-s.y)*(c.x-s.x),r)._round()),l&&s.equals(l[l.length-1])||(l=[s],o.push(l)),l.push(c)))))}}return o}function w_(t){let e=0,i=0;for(const n of t)e+=n.w*n.h,i=Math.max(i,n.w);t.sort(((t,e)=>e.h-t.h));const n=[{x:0,y:0,w:Math.max(Math.ceil(Math.sqrt(e/.95)),i),h:1/0}];let r=0,o=0;for(const e of t)for(let t=n.length-1;t>=0;t--){const i=n[t];if(!(e.w>i.w||e.h>i.h)){if(e.x=i.x,e.y=i.y,o=Math.max(o,e.y+e.h),r=Math.max(r,e.x+e.w),e.w===i.w&&e.h===i.h){const e=n.pop();tt.hasImage(e,i))),t.dispatchRenderCallbacks(this.haveRenderCallbacks,i);for(const n in t.getUpdatedImages(i))this.patchUpdatedImage(this.iconPositions[n],t.getImage(n,i),e),this.patchUpdatedImage(this.patternPositions[n],t.getImage(n,i),e)}patchUpdatedImage(t,e,i){if(!t||!e)return;if(t.version===e.version)return;t.version=e.version;const[n,r]=t.tl,o=!!Object.keys(this.patternPositions).length;i.update(e.data,{useMipmap:o},{x:n,y:r})}}ba(S_,"ImagePosition"),ba(E_,"ImageAtlas");const M_=1e20;function C_(t,e,i,n,r,o,s,a,l){for(let c=e;c-1);l++,o[l]=a,s[l]=c,s[l+1]=M_}for(let a=0,l=0;a{let n=this.entries[t];n||(n=this.entries[t]={glyphs:{},requests:{},ranges:{},ascender:void 0,descender:void 0});let r=n.glyphs[e];if(void 0!==r)return void i(null,{stack:t,id:e,glyph:r});if(r=this._tinySDF(n,t,e),r)return n.glyphs[e]=r,void i(null,{stack:t,id:e,glyph:r});const s=Math.floor(e/256);if(256*s>65535)return void i(new Error("glyphs > 65535 not supported"));if(n.ranges[s])return void i(null,{stack:t,id:e,glyph:r});let a=n.requests[s];a||(a=n.requests[s]=[],P_.loadGlyphRange(t,s,o,this.requestManager,((t,e)=>{if(e){n.ascender=e.ascender,n.descender=e.descender;for(const t in e.glyphs)this._doesCharSupportLocalGlyph(+t)||(n.glyphs[+t]=e.glyphs[+t]);n.ranges[s]=!0}for(const i of a)i(t,e);delete n.requests[s]}))),a.push(((n,r)=>{n?i(n):r&&i(null,{stack:t,id:e,glyph:r.glyphs[e]||null})}))}),((t,e)=>{if(t)i(t);else if(e){const t={};for(const{stack:i,id:n,glyph:r}of e)void 0===t[i]&&(t[i]={}),void 0===t[i].glyphs&&(t[i].glyphs={}),t[i].glyphs[n]=r&&{id:r.id,bitmap:r.bitmap.clone(),metrics:r.metrics},t[i].ascender=this.entries[i].ascender,t[i].descender=this.entries[i].descender;i(null,t)}}))}_doesCharSupportLocalGlyph(t){return this.localGlyphMode!==L_.none&&(this.localGlyphMode===L_.all?!!this.localFontFamily:!!this.localFontFamily&&(Ma["CJK Unified Ideographs"](t)||Ma["Hangul Syllables"](t)||Ma.Hiragana(t)||Ma.Katakana(t)||Ma["CJK Symbols and Punctuation"](t)||Ma["CJK Unified Ideographs Extension A"](t)||Ma["CJK Unified Ideographs Extension B"](t)))}_tinySDF(t,e,i){const n=this.localFontFamily;if(!n||!this._doesCharSupportLocalGlyph(i))return;let r=t.tinySDF;if(!r){let i="400";/bold/i.test(e)?i="900":/medium/i.test(e)?i="500":/light/i.test(e)&&(i="200"),r=t.tinySDF=new P_.TinySDF({fontFamily:n,fontWeight:i,fontSize:24*I_,buffer:3*I_,radius:8*I_}),r.fontWeight=i}if(this.localGlyphs[r.fontWeight][i])return this.localGlyphs[r.fontWeight][i];const o=String.fromCodePoint(i),{data:s,width:a,height:l,glyphWidth:c,glyphHeight:d,glyphLeft:u,glyphTop:h,glyphAdvance:p}=r.draw(o);return this.localGlyphs[r.fontWeight][i]={id:i,bitmap:new dh({width:a,height:l},s),metrics:{width:c/I_,height:d/I_,left:u/I_,top:h/I_-27,advance:p/I_,localGlyph:!0}}}}P_.loadGlyphRange=function(t,e,i,n,r){const o=256*e,s=o+255,a=n.transformRequest(n.normalizeGlyphsURL(i).replace("{fontstack}",t).replace("{range}",`${o}-${s}`),Ki.Glyphs);en(a,((t,e)=>{if(t)r(t);else if(e){const t={},i=function(t){return new Lm(t).readFields(Wm,{})}(e);for(const e of i.glyphs)t[e.id]=e;r(null,{glyphs:t,ascender:i.ascender,descender:i.descender})}}))},P_.TinySDF=class{constructor({fontSize:t=24,buffer:e=3,radius:i=8,cutoff:n=.25,fontFamily:r="sans-serif",fontWeight:o="normal",fontStyle:s="normal"}={}){this.buffer=e,this.cutoff=n,this.radius=i;const a=this.size=t+4*e,l=this._createCanvas(a),c=this.ctx=l.getContext("2d",{willReadFrequently:!0});c.font=`${s} ${o} ${t}px ${r}`,c.textBaseline="alphabetic",c.textAlign="left",c.fillStyle="black",this.gridOuter=new Float64Array(a*a),this.gridInner=new Float64Array(a*a),this.f=new Float64Array(a),this.z=new Float64Array(a+1),this.v=new Uint16Array(a)}_createCanvas(t){const e=document.createElement("canvas");return e.width=e.height=t,e}draw(t){const{width:e,actualBoundingBoxAscent:i,actualBoundingBoxDescent:n,actualBoundingBoxLeft:r,actualBoundingBoxRight:o}=this.ctx.measureText(t),s=Math.ceil(i),a=Math.max(0,Math.min(this.size-this.buffer,Math.ceil(o-r))),l=Math.min(this.size-this.buffer,s+Math.ceil(n)),c=a+2*this.buffer,d=l+2*this.buffer,u=Math.max(c*d,0),h=new Uint8ClampedArray(u),p={data:h,width:c,height:d,glyphWidth:a,glyphHeight:l,glyphTop:s,glyphLeft:0,glyphAdvance:e};if(0===a||0===l)return p;const{ctx:f,buffer:m,gridInner:_,gridOuter:g}=this;f.clearRect(m,m,a,l),f.fillText(t,m,m+s);const y=f.getImageData(m,m,a,l);g.fill(M_,0,u),_.fill(0,0,u);for(let t=0;t0?t*t:0,_[n]=tt+e[1]-e[0],f=u.reduce(p,0),m=h.reduce(p,0),_=a-f,g=l-m;let y=0,v=f,x=0,b=m,w=0,T=_,S=0,E=g;if(o.content&&n){const t=o.content;y=D_(u,0,t[0]),x=D_(h,0,t[1]),v=D_(u,t[0],t[2]),b=D_(h,t[1],t[3]),w=t[0]-y,S=t[1]-x,T=t[2]-t[0]-v,E=t[3]-t[1]-b}const M=(n,r,a,l)=>{const u=R_(n.stretch-y,v,c,t.left),h=O_(n.fixed-w,T,n.stretch,f),p=R_(r.stretch-x,b,d,t.top),_=O_(r.fixed-S,E,r.stretch,m),g=R_(a.stretch-y,v,c,t.left),M=O_(a.fixed-w,T,a.stretch,f),C=R_(l.stretch-x,b,d,t.top),A=O_(l.fixed-S,E,l.stretch,m),I=new Ue(u,p),L=new Ue(g,p),P=new Ue(g,C),$=new Ue(u,C),k=new Ue(h/s,_/s),D=new Ue(M/s,A/s),z=e*Math.PI/180;if(z){const t=Math.sin(z),e=Math.cos(z),i=[e,-t,t,e];I._matMult(i),L._matMult(i),$._matMult(i),P._matMult(i)}const R=n.stretch+n.fixed,O=a.stretch+a.fixed,B=r.stretch+r.fixed,F=l.stretch+l.fixed,N=t.imageSecondary;return{tl:I,tr:L,bl:$,br:P,texPrimary:{x:o.paddedRect.x+$_+R,y:o.paddedRect.y+$_+B,w:O-R,h:F-B},texSecondary:N?{x:N.paddedRect.x+$_+R,y:N.paddedRect.y+$_+B,w:O-R,h:F-B}:void 0,writingMode:void 0,glyphOffset:[0,0],sectionIndex:0,pixelOffsetTL:k,pixelOffsetBR:D,minFontScaleX:T/s/c,minFontScaleY:E/s/d,isSDF:i}};if(n&&(o.stretchX||o.stretchY)){const t=z_(u,_,f),e=z_(h,g,m);for(let i=0;io)&&(o=e.x),(!t||e.y>s)&&(s=e.y)}const l=Math.min(o-n,s-r);let c=l/2;const d=new co([],N_);if(0===l)return new Ue(n,r);for(let e=n;eu.d||!u.d)&&(u=n,i&&console.log("found best %d after %d probes",Math.round(1e4*n.d)/1e4,h)),n.max-u.dt.y!=a.y>t.y&&t.x18&&P>2&&(P>>=1),Math.max(uo/(512*P),1)*_.get("symbol-spacing")),S=_.get("text-padding")*t.tilePixelRatio,E=_.get("icon-padding")*t.tilePixelRatio,M=Ge(_.get("text-max-angle")),C="map"===_.get("text-rotation-alignment")&&"point"!==_.get("symbol-placement"),A="map"===_.get("icon-rotation-alignment")&&"point"!==_.get("symbol-placement"),I=_.get("symbol-placement"),L=T/2;var P;const $=_.get("icon-text-fit").evaluate(e,{},u),k=_.get("icon-text-fit-padding").evaluate(e,{},u),D="none"!==$;let z;!1===t.hasAnyIconTextFit&&D&&(t.hasAnyIconTextFit=!0),n&&D&&(t.allowVerticalPlacement&&i.vertical&&(z=h_(n,i.vertical,$,k,g,b)),y&&(n=h_(n,y,$,k,g,b)));const R=(s,a,m)=>{if(a.x=uo||a.y=uo)return;let _=null;if(v){const{x:t,y:e,z:i}=h.projectTilePoint(a.x,a.y,m);_={anchor:new p_(t,e,i,0,void 0),up:h.upVector(m,a.x,a.y)}}!function(t,e,i,n,r,o,s,a,l,c,d,u,h,p,f,m,_,g,y,v,x,b,w,T,S,E,M){const C=t.addToLineVertexArray(e,n);let A,I,L,P,$,k,D,z=0,R=0,O=0,B=0,F=-1,N=-1;const U={};let j=Ln("");const V=i?i.anchor:e,G="none"!==l.layout.get("icon-text-fit").evaluate(x,{},S);let Z=0,q=0;if(void 0===l._unevaluatedLayout.getValue("text-radial-offset")?[Z,q]=l.layout.get("text-offset").evaluate(x,{},S).map((t=>t*Om)):(Z=l.layout.get("text-radial-offset").evaluate(x,{},S)*Om,q=j_),t.allowVerticalPlacement&&r.vertical){const t=r.vertical;if(f)k=J_(t),a&&(D=J_(a));else{const i=l.layout.get("text-rotate").evaluate(x,{},S)+90;L=K_(c,V,e,d,u,h,t,p,i,m),a&&(P=K_(c,V,e,d,u,h,a,g,i))}}if(o){const n=l.layout.get("icon-rotate").evaluate(x,{},S),r=k_(o,n,w,G),s=a?k_(a,n,w,G):void 0;I=K_(c,V,e,d,u,h,o,g,n),z=4*r.length;const p=t.iconSizeData;let f=null;"source"===p.kind?(f=[Bm*l.layout.get("icon-size").evaluate(x,{},S)],f[0]>W_&&pi(`${t.layerIds[0]}: Value for "icon-size" is >= ${H_}. Reduce your "icon-size".`)):"composite"===p.kind&&(f=[Bm*b.compositeIconSizes[0].evaluate(x,{},S),Bm*b.compositeIconSizes[1].evaluate(x,{},S)],(f[0]>W_||f[1]>W_)&&pi(`${t.layerIds[0]}: Value for "icon-size" is >= ${H_}. Reduce your "icon-size".`)),t.addSymbols(t.icon,r,f,v,y,x,!1,i,e,C.lineStartIndex,C.lineLength,-1,T,S,E,M),F=t.icon.placedSymbolArray.length-1,s&&(R=4*s.length,t.addSymbols(t.icon,s,f,v,y,x,Jm.vertical,i,e,C.lineStartIndex,C.lineLength,-1,T,S,E,M),N=t.icon.placedSymbolArray.length-1)}for(const n in r.horizontal){const o=r.horizontal[n];A||(j=Ln(o.text),f?$=J_(o):A=K_(c,V,e,d,u,h,o,p,l.layout.get("text-rotate").evaluate(x,{},S),m));const a=1===o.positionedLines.length;if(O+=Y_(t,i,e,o,s,l,f,x,m,C,r.vertical?Jm.horizontal:Jm.horizontalOnly,a?Object.keys(r.horizontal):[n],U,F,b,T,S,E),a)break}r.vertical&&(B+=Y_(t,i,e,r.vertical,s,l,f,x,m,C,Jm.vertical,["vertical"],U,N,b,T,S,E));let H=-1;const W=(t,e)=>t?Math.max(t,e):e;H=W($,H),H=W(k,H),H=W(D,H);const Y=H>-1?1:0;t.glyphOffsetArray.length>=65535&&pi("Too many glyphs being rendered in a tile. See https://github.com/mapbox/mapbox-gl-js/issues/2907"),void 0!==x.sortKey&&t.addToSortKeyRanges(t.symbolInstances.length,x.sortKey),t.symbolInstances.emplaceBack(e.x,e.y,V.x,V.y,V.z,U.right>=0?U.right:-1,U.center>=0?U.center:-1,U.left>=0?U.left:-1,U.vertical>=0?U.vertical:-1,F,N,j,void 0!==A?A:t.collisionBoxArray.length,void 0!==A?A+1:t.collisionBoxArray.length,void 0!==L?L:t.collisionBoxArray.length,void 0!==L?L+1:t.collisionBoxArray.length,void 0!==I?I:t.collisionBoxArray.length,void 0!==I?I+1:t.collisionBoxArray.length,P||t.collisionBoxArray.length,P?P+1:t.collisionBoxArray.length,d,O,B,z,R,Y,0,Z,q,H,0,1,1,G?1:0)}(t,a,_,s,i,n,r,z,t.layers[0],t.collisionBoxArray,e.index,e.sourceLayerIndex,t.index,S,C,l,0,E,A,g,e,o,c,d,u,p,f)};if("line"===I)for(const r of b_(e.geometry,0,0,uo,uo)){const e=v_(r,T,M,i.vertical||y,n,x,w,t.overscaling,uo);for(const i of e)y&&Q_(t,y.text,L,i)||R(r,i,u)}else if("line-center"===I){for(const t of e.geometry)if(t.length>1){const e=y_(t,M,i.vertical||y,n,x,w);e&&R(t,e,u)}}else if("Polygon"===e.type)for(const t of Zh(e.geometry,0)){const e=F_(t,16);R(t[0],new p_(e.x,e.y,0,0,void 0),u)}else if("LineString"===e.type)for(const t of e.geometry)R(t,new p_(t[0].x,t[0].y,0,0,void 0),u);else if("Point"===e.type)for(const t of e.geometry)for(const e of t)R([e],new p_(e.x,e.y,0,0,void 0),u)}const H_=255,W_=H_*Bm;function Y_(t,e,i,n,r,o,s,a,l,c,d,u,h,p,f,m,_,g){const y=function(t,e,i,n,r,o,s,a){const l=[];if(0===e.positionedLines.length)return l;const c=n.layout.get("text-rotate").evaluate(o,{})*Math.PI/180,d=function(t){const e=t[0],i=t[1],n=e*i;return n>0?[e,-i]:nW_&&pi(`${t.layerIds[0]}: Value for "text-size" is >= ${H_}. Reduce your "text-size".`)):"composite"===v.kind&&(x=[Bm*f.compositeTextSizes[0].evaluate(a,{},_),Bm*f.compositeTextSizes[1].evaluate(a,{},_)],(x[0]>W_||x[1]>W_)&&pi(`${t.layerIds[0]}: Value for "text-size" is >= ${H_}. Reduce your "text-size".`)),t.addSymbols(t.text,y,x,l,s,a,d,e,i,c.lineStartIndex,c.lineLength,p,m,_,g,!1);for(const e of u)h[e]=t.text.placedSymbolArray.length-1;return 4*y.length}function X_(t){for(const e in t)return t[e];return null}function K_(t,e,i,n,r,o,s,a,l,c){let d=s.top,u=s.bottom,h=s.left,p=s.right;const f=s.collisionPadding;if(f&&(h-=f[0],d-=f[1],p+=f[2],u+=f[3]),l){const t=new Ue(h,d),e=new Ue(p,d),i=new Ue(h,u),n=new Ue(p,u),r=Ge(l);let o=new Ue(0,0);c&&(o=new Ue(c[0],c[1])),t._rotateAround(r,o),e._rotateAround(r,o),i._rotateAround(r,o),n._rotateAround(r,o),h=Math.min(t.x,e.x,i.x,n.x),p=Math.max(t.x,e.x,i.x,n.x),d=Math.min(t.y,e.y,i.y,n.y),u=Math.max(t.y,e.y,i.y,n.y)}return t.emplaceBack(e.x,e.y,e.z,i.x,i.y,h,d,p,u,a,n,r,o),t.length-1}function J_(t){t.collisionPadding&&(t.top-=t.collisionPadding[1],t.bottom+=t.collisionPadding[3]);const e=t.bottom-t.top;return e>0?Math.max(10,e):null}function Q_(t,e,i,n){const r=t.compareText;if(e in r){const t=r[e];for(let e=t.length-1;e>=0;e--)if(n.dist(t[e])v&&(x(t,c,n,r,a,l),x(c,i,a,l,o,s))}x(u,h,n,o,r,o),x(h,p,r,o,r,s),x(p,f,r,s,n,s),x(f,u,n,s,n,o),m-=v,_-=v,g+=v,y+=v;const b=1/Math.max(g-m,y-_);return{scale:b,x:m*b,y:_*b,x2:g*b,y2:y*b,projection:e}}function ig(t,{x:e,y:i},n=0){return new Ue(((e-n)*t.scale-t.x)*uo,(i*t.scale-t.y)*uo)}const ng=t.ad.identity(new Float32Array(16));class rg{constructor(t){this.spec=t,this.name=t.name,this.wrap=!1,this.requiresDraping=!1,this.supportsWorldCopies=!1,this.supportsTerrain=!1,this.supportsFog=!1,this.supportsFreeCamera=!1,this.zAxisUnit="meters",this.isReprojectedInTileSpace=!0,this.unsupportedLayers=["custom"],this.center=[0,0],this.range=[3.5,7]}project(t,e){return{x:0,y:0,z:0}}unproject(t,e){return new pd(0,0)}projectTilePoint(t,e,i){return{x:t,y:e,z:0}}locationPoint(t,e,i=!0){return t._coordinatePoint(t.locationCoordinate(e),i)}pixelsPerMeter(t,e){return Cd(1,t)*e}pixelSpaceConversion(t,e,i){return 1}farthestPixelDistance(t){return tg(t,t.pixelsPerMeter)}pointCoordinate(t,e,i,n){const r=t.horizonLineFromTop(!1),o=new Ue(e,Math.max(r,i));return t.rayIntersectionCoordinate(t.pointRayIntersection(o,n))}pointCoordinate3D(t,e,i){const n=new Ue(e,i);if(t.elevation)return t.elevation.pointCoordinate(n);{const e=this.pointCoordinate(t,n.x,n.y,0);return[e.x,e.y,e.z]}}isPointAboveHorizon(t,e){if(t.elevation&&t.elevation.visibleDemTiles.length)return!this.pointCoordinate3D(t,e.x,e.y);const i=t.horizonLineFromTop();return e.y0?epg-i&&(e=pg-i);const o=r/Math.pow(fg(e),n);let s=o*Math.sin(n*t),a=r-o*Math.cos(n*t);return s=.5*(s/Math.PI+.5),a=.5*(a/Math.PI+.5),{x:s,y:this.southernCenter?a:1-a,z:0}}unproject(t,e){t=(2*t-.5)*Math.PI,this.southernCenter&&(e=1-e),e=(2*(1-e)-.5)*Math.PI;const{n:i,f:n}=this,r=n-e,o=Math.sign(r),s=Math.sign(i)*Math.sqrt(t*t+r*r);let a=Math.atan2(t,Math.abs(r))*o;r*i1e-6&&--n>0);o=i*i;const s=Xe(Ze(t/(.8707+o*(o*(o*o*o*(.003971-.001529*o)-.013791)-.131979))),-180,180),a=Ze(i);return new pd(s,a)}}const vg=Ge(Pd);class xg extends rg{project(t,e){e=Ge(e),t=Ge(t);const i=Math.cos(e),n=2/Math.PI,r=Math.acos(i*Math.cos(t/2)),o=Math.sin(r)/r,s=.5*(t*n+2*i*Math.sin(t/2)/o)||0,a=.5*(e+Math.sin(e)/o)||0;return{x:.5*(s/Math.PI+.5),y:1-.5*(a/Math.PI+1),z:0}}unproject(t,e){let i=t=(2*t-.5)*Math.PI,n=e=(2*(1-e)-1)*Math.PI,r=25;const o=1e-6;let s=0,a=0;do{const r=Math.cos(n),o=Math.sin(n),l=2*o*r,c=o*o,d=r*r,u=Math.cos(i/2),h=Math.sin(i/2),p=2*u*h,f=h*h,m=1-d*u*u,_=m?1/m:0,g=m?Math.acos(r*u)*Math.sqrt(1/m):0,y=.5*(2*g*r*h+2*i/Math.PI)-t,v=.5*(g*o+n)-e,x=.5*_*(d*f+g*r*u*c)+1/Math.PI,b=_*(p*l/4-g*o*h),w=.125*_*(l*h-g*o*d*p),T=.5*_*(c*u+g*f*r)+.5,S=b*w-T*x;s=(v*b-y*T)/S,a=(y*w-v*x)/S,i=Xe(i-s,-Math.PI,Math.PI),n=Xe(n-a,-vg,vg)}while((Math.abs(s)>o||Math.abs(a)>o)&&--r>0);return new pd(Ze(i),Ze(n))}}class bg extends rg{constructor(t){super(t),this.center=t.center||[0,0],this.parallels=t.parallels||[0,0],this.cosPhi=Math.max(.01,Math.cos(Ge(this.parallels[0]))),this.scale=1/(2*Math.max(Math.PI*this.cosPhi,1/this.cosPhi)),this.wrap=!0,this.supportsWorldCopies=!0}project(t,e){const{scale:i,cosPhi:n}=this;return{x:Ge(t)*n*i+.5,y:-Math.sin(Ge(e))/n*i+.5,z:0}}unproject(t,e){const{scale:i,cosPhi:n}=this,r=-(e-.5)/i,o=Xe(Ze((t-.5)/i)/n,-180,180),s=Math.asin(Xe(r*n,-1,1)),a=Xe(Ze(s),-Pd,Pd);return new pd(o,a)}}class wg extends _g{constructor(t){super(t),this.requiresDraping=!0,this.supportsWorldCopies=!1,this.supportsFog=!0,this.zAxisUnit="pixels",this.unsupportedLayers=["debug"],this.range=[3,5]}projectTilePoint(e,i,n){const r=Fu(e,i,n),o=ju($u(n));return t._.transformMat4(r,r,o),{x:r[0],y:r[1],z:r[2]}}locationPoint(e,i){const n=dd(i.lat,i.lng),r=t._.normalize([],n),o=e.elevation?e.elevation.getAtPointOrZero(e.locationCoordinate(i),e._centerAltitude):e._centerAltitude,s=Cd(1,0)*uo*o;t._.scaleAndAdd(n,n,r,s);const a=t.ad.identity(new Float64Array(16));return t.ad.multiply(a,e.pixelMatrix,e.globeMatrix),t._.transformMat4(n,n,a),new Ue(n[0],n[1])}pixelsPerMeter(t,e){return Cd(1,0)*e}pixelSpaceConversion(t,e,i){const n=Cd(1,t)*e,r=Vn(Cd(1,45)*e,n,i);return this.pixelsPerMeter(t,e)/r}createTileMatrix(e,i,n){const r=Vu($u(n.canonical));return t.ad.multiply(new Float64Array(16),e.globeMatrix,r)}createInversionMatrix(e,i){const{center:n}=e,r=ju($u(i));return t.ad.rotateY(r,r,Ge(n.lng)),t.ad.rotateX(r,r,Ge(n.lat)),t.ad.scale(r,r,[e._pixelsPerMercatorPixel,e._pixelsPerMercatorPixel,1]),Float32Array.from(r)}pointCoordinate(t,e,i,n){return Iu(t,e,i,!0)||new Rd(0,0)}pointCoordinate3D(t,e,i){const n=this.pointCoordinate(t,e,i,0);return[n.x,n.y,n.z]}isPointAboveHorizon(t,e){return!Iu(t,e.x,e.y,!1)}farthestPixelDistance(e){const i=function(e,i){const n=e.cameraToCenterDistance,r=e._centerAltitude*i,o=e._camera,s=e._camera.forward(),a=t._.add([],t._.scale([],s,-n),[0,0,r]),l=e.worldSize/(2*Math.PI),c=[0,0,-l],d=e.width/e.height,u=Math.tan(e.fovAboveCenter),h=t._.scale([],o.up(),u),p=t._.scale([],o.right(),u*d),f=t._.normalize([],t._.add([],t._.add([],s,h),p)),m=[];let _;if(new mu(a,f).closestPointOnSphere(c,l,m)){const i=t._.add([],m,c),n=t._.sub([],i,a);_=Math.cos(e.fovAboveCenter)*t._.length(n)}else{const e=t._.sub([],a,c),i=t._.sub([],c,a);t._.normalize(i,i);const n=t._.length(e)-l;_=Math.sqrt(n*(n+2*l));const r=Math.acos(_/(l+n))-Math.acos(t._.dot(s,i));_*=Math.cos(r)}return 1.01*_}(e,this.pixelsPerMeter(e.center.lat,e.worldSize)),n=Hu(e.zoom);if(n>0){const t=tg(e,Cd(1,e.center.lat)*e.worldSize),r=e.worldSize/(2*Math.PI),o=Math.max(e.width,e.height)/e.worldSize*Math.PI;return Vn(i,t+r*(1-Math.cos(o)),Math.pow(n,10))}return i}upVector(t,e,i){return Fu(e,i,t,1)}upVectorScale(t){return{metersToTile:Cu(Nu($u(t)))}}}function Tg(t){const e=t.parallels,i=!!e&&Math.abs(e[0]+e[1])0&&(this.iconTransitioningVertexBuffer=t.createVertexBuffer(this.iconTransitioningVertexArray,Vf.members,!0)),this.globeExtVertexArray.length>0&&(this.globeExtVertexBuffer=t.createVertexBuffer(this.globeExtVertexArray,Ff.members,!0)),!this.zOffsetVertexBuffer&&(this.zOffsetVertexArray.length>0||r)&&(this.zOffsetVertexBuffer=t.createVertexBuffer(this.zOffsetVertexArray,jf.members,!0)),this.opacityVertexBuffer.itemSize=1),(i||n)&&this.programConfigurations.upload(t))}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy(),this.dynamicLayoutVertexBuffer.destroy(),this.opacityVertexBuffer.destroy(),this.occlusionQueryOpacityVertexBuffer.destroy(),this.iconTransitioningVertexBuffer&&this.iconTransitioningVertexBuffer.destroy(),this.globeExtVertexBuffer&&this.globeExtVertexBuffer.destroy(),this.zOffsetVertexBuffer&&this.zOffsetVertexBuffer.destroy())}}ba(Ng,"SymbolBuffers");class Ug{constructor(t,e,i){this.layoutVertexArray=new t,this.layoutAttributes=e,this.indexArray=new i,this.segments=new wc,this.collisionVertexArray=new Xl,this.collisionVertexArrayExt=new Ol}upload(t){this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,this.layoutAttributes),this.indexBuffer=t.createIndexBuffer(this.indexArray),this.collisionVertexBuffer=t.createVertexBuffer(this.collisionVertexArray,Gf.members,!0),this.collisionVertexBufferExt=t.createVertexBuffer(this.collisionVertexArrayExt,Zf.members,!0)}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.segments.destroy(),this.collisionVertexBuffer.destroy(),this.collisionVertexBufferExt.destroy())}}ba(Ug,"CollisionBuffers");class jg{constructor(e){this.queries=new Map,this.collisionBoxArray=e.collisionBoxArray,this.zoom=e.zoom,this.lut=e.lut,this.overscaling=e.overscaling,this.layers=e.layers,this.layerIds=this.layers.map((t=>t.fqid)),this.index=e.index,this.pixelRatio=e.pixelRatio,this.sourceLayerIndex=e.sourceLayerIndex,this.hasPattern=!1,this.hasRTLText=!1,this.fullyClipped=!1,this.hasAnyIconTextFit=!1,this.sortKeyRanges=[],this.collisionCircleArray=[],this.placementInvProjMatrix=t.ad.identity([]),this.placementViewportMatrix=t.ad.identity([]);const i=this.layers[0]._unevaluatedLayout._values;this.textSizeData=Fm(this.zoom,i["text-size"]),this.iconSizeData=Fm(this.zoom,i["icon-size"]);const n=this.layers[0].layout,r=n.get("symbol-sort-key"),o=n.get("symbol-z-order");this.canOverlap=n.get("text-allow-overlap")||n.get("icon-allow-overlap")||n.get("text-ignore-placement")||n.get("icon-ignore-placement"),this.sortFeaturesByKey="viewport-y"!==o&&void 0!==r.constantOr(1),this.sortFeaturesByY=("viewport-y"===o||"auto"===o&&!this.sortFeaturesByKey)&&this.canOverlap,this.writingModes=n.get("text-writing-mode").map((t=>Jm[t])),this.stateDependentLayerIds=this.layers.filter((t=>t.isStateDependent())).map((t=>t.id)),this.sourceID=e.sourceID,this.projection=e.projection,this.hasAnyZOffset=!1,this.zOffsetSortDirty=!1,this.zOffsetBuffersNeedUpload=n.get("symbol-z-elevate"),this.activeReplacements=[],this.replacementUpdateTime=0}createArrays(){this.text=new Ng(new Yc(this.layers,{zoom:this.zoom,lut:this.lut},(t=>/^text/.test(t)))),this.icon=new Ng(new Yc(this.layers,{zoom:this.zoom,lut:this.lut},(t=>/^icon/.test(t)))),this.glyphOffsetArray=new mc,this.lineVertexArray=new _c,this.symbolInstances=new fc}calculateGlyphDependencies(t,e,i,n,r){for(let i=0;i0)&&("constant"!==l.value.kind||l.value.value.length>0),h="constant"!==d.value.kind||!!d.value.value||Object.keys(d.parameters).length>0,p=s.get("symbol-sort-key");if(this.features=[],!u&&!h)return;const f=i.iconDependencies,m=i.glyphDependencies,_=i.availableImages,g=new Ha(this.zoom);for(const{feature:i,id:c,index:d,sourceLayerIndex:y}of e){const e=o._featureFilter.needGeometry,v=Zd(i,e);if(!o._featureFilter.filter(g,v,n))continue;if(e||(v.geometry=Gd(i,n,r)),a&&1!==i.type&&n.z{const o=Fu(e.x,e.y,n,1),s=Fu(r.x,r.y,n,1);return t._.dot(o,s)=0;for(const i of x.sections)if(i.image)f[i.image.namePrimary]=!0;else{const n=Ca(x.toString()),r=i.fontStack||t,o=m[r]=m[r]||{};this.calculateGlyphDependencies(i.text,o,e,this.allowVerticalPlacement,n)}}}"line"===s.get("symbol-placement")&&(this.features=function(t){const e={},i={},n=[];let r=0;function o(e){n.push(t[e]),r++}function s(t,e,r){const o=i[t];return delete i[t],i[e]=o,n[o].geometry[0].pop(),n[o].geometry[0]=n[o].geometry[0].concat(r[0]),o}function a(t,i,r){const o=e[i];return delete e[i],e[t]=o,n[o].geometry[0].shift(),n[o].geometry[0]=r[0].concat(n[o].geometry[0]),o}function l(t,e,i){const n=i?e[0][e[0].length-1]:e[0][0];return`${t}:${n.x}:${n.y}`}for(let c=0;ct.geometry))}(this.features)),this.sortFeaturesByKey&&this.features.sort(((t,e)=>t.sortKey-e.sortKey))}update(t,e,i,n,r){const o=0!==Object.keys(t).length;if(o&&!this.stateDependentLayers.length)return;const s=o?this.stateDependentLayers:this.layers;this.text.programConfigurations.updatePaintArrays(t,e,s,i,n,r),this.icon.programConfigurations.updatePaintArrays(t,e,s,i,n,r)}updateOcclusionOpacities(t,e,i){if(!e.useOcclusionQueries)return!1;const n=this;if("globe"===n.projection.name)return!1;let r=!1;n.hasTextData()&&(r=r||0!==n.text.occlusionQueryOpacityVertexArray.length),n.hasIconData()&&(r=r||0!==n.icon.occlusionQueryOpacityVertexArray.length);const o=n.layers[0].paint,s=o.get("icon-occlusion-opacity").constantOr(0),a=o.get("text-occlusion-opacity").constantOr(0);if(!n.layers[0].hasInitialOcclusionOpacityProperties||1===s&&1===a)return!1;let l=!r;for(let t=0;t.5?1:-1)*e.fadeSpeed*i*.001,r.occlusionOpacity=Xe(r.occlusionOpacity,0,1),l=l||r.occlusionOpacity!==o}if(!l)return!1;let c=0,d=0;const u=(t,e,i,n)=>{let r=0,o=0;i?(r=d,d+=n,o=d):(r=c,c+=n,o=c),o>e.occlusionQueryOpacityVertexArray.length&&e.occlusionQueryOpacityVertexArray.resize(o);const s=t.occlusionOpacity;for(let t=0;t0;if((i>0||r>0)&&(u(e,n.text,!1,i),u(e,n.text,!1,r)),s){const{placedIconSymbolIndex:t,verticalPlacedIconSymbolIndex:i}=e;t>=0&&u(e,n.icon,!0,o),i>=0&&u(e,n.icon,!0,e.numVerticalIconVertices)}}return n.hasTextData()&&n.text.occlusionQueryOpacityVertexBuffer&&(n.text.occlusionQueryOpacityVertexBuffer.length{i+=e,i>t.length&&t.resize(i);for(let r=-e;r{n+=e,n>t.length&&t.resize(n);for(let r=-e;r0;if((r>0||o>0)&&(t(this.text.zOffsetVertexArray,r,a),t(this.text.zOffsetVertexArray,o,a)),l){const{placedIconSymbolIndex:t,verticalPlacedIconSymbolIndex:i}=n;t>=0&&e(this.icon.zOffsetVertexArray,s,a),i>=0&&e(this.icon.zOffsetVertexArray,n.numVerticalIconVertices,a)}}this.text.zOffsetVertexBuffer&&this.text.zOffsetVertexBuffer.updateData(this.text.zOffsetVertexArray),this.icon.zOffsetVertexBuffer&&this.icon.zOffsetVertexBuffer.updateData(this.icon.zOffsetVertexArray)}isEmpty(){return 0===this.symbolInstances.length&&!this.hasRTLText}uploadPending(){return!this.uploaded||this.text.programConfigurations.needsUpload||this.icon.programConfigurations.needsUpload}upload(t){!this.uploaded&&this.hasDebugData()&&(this.textCollisionBox.upload(t),this.iconCollisionBox.upload(t)),this.text.upload(t,this.sortFeaturesByY,!this.uploaded,this.text.programConfigurations.needsUpload,this.zOffsetBuffersNeedUpload),this.icon.upload(t,this.sortFeaturesByY,!this.uploaded,this.icon.programConfigurations.needsUpload,this.zOffsetBuffersNeedUpload),this.uploaded=!0}destroyDebugData(){this.textCollisionBox.destroy(),this.iconCollisionBox.destroy()}getProjection(){return this.projectionInstance||(this.projectionInstance=Tg(this.projection)),this.projectionInstance}destroy(){this.text.destroy(),this.icon.destroy(),this.hasDebugData()&&this.destroyDebugData();for(const t of this.queries.values())t.destroy()}addToLineVertexArray(t,e){const i=this.lineVertexArray.length;if(void 0!==t.segment)for(const{x:t,y:i}of e)this.lineVertexArray.emplaceBack(t,i);return{lineStartIndex:i,lineLength:this.lineVertexArray.length-i}}addSymbols(t,e,i,n,r,o,s,a,l,c,d,u,h,p,f,m){const _=t.indexArray,g=t.layoutVertexArray,y=t.globeExtVertexArray,v=t.segments.prepareSegment(4*e.length,g,_,this.canOverlap?o.sortKey:void 0),x=this.glyphOffsetArray.length,b=v.vertexLength,w=this.allowVerticalPlacement&&s===Jm.vertical?Math.PI/2:0,T=o.text&&o.text.sections;for(let n=0;n=0?e.rightJustifiedTextSymbolIndex:e.centerJustifiedTextSymbolIndex>=0?e.centerJustifiedTextSymbolIndex:e.leftJustifiedTextSymbolIndex>=0?e.leftJustifiedTextSymbolIndex:e.verticalPlacedTextSymbolIndex>=0?e.verticalPlacedTextSymbolIndex:n),o=Nm(this.textSizeData,t,r)/Om;return this.tilePixelRatio*o}getSymbolInstanceIconSize(t,e,i){const n=this.icon.placedSymbolArray.get(i),r=Nm(this.iconSizeData,t,n);return this.tilePixelRatio*r}_commitDebugCollisionVertexUpdate(t,e,i,n){t.emplaceBack(e,-i,-i,n),t.emplaceBack(e,i,-i,n),t.emplaceBack(e,i,i,n),t.emplaceBack(e,-i,i,n)}_updateTextDebugCollisionBoxes(t,e,i,n,r,o){for(let s=n;s0}hasIconData(){return this.icon.segments.get().length>0}hasDebugData(){return this.textCollisionBox&&this.iconCollisionBox}hasTextCollisionBoxData(){return this.hasDebugData()&&this.textCollisionBox.segments.get().length>0}hasIconCollisionBoxData(){return this.hasDebugData()&&this.iconCollisionBox.segments.get().length>0}hasIconTextFit(){return this.hasAnyIconTextFit}addIndicesForPlacedSymbol(t,e){const i=t.placedSymbolArray.get(e),n=i.vertexStartIndex+4*i.numGlyphs;for(let e=i.vertexStartIndex;en[t]-n[e]||r[e]-r[t])),o}getSortedIndexesByZOffset(){if(!this.zOffsetSortDirty)return this.symbolInstanceIndexesSortedZOffset;if(!this.symbolInstanceIndexesSortedZOffset){this.symbolInstanceIndexesSortedZOffset=[];for(let t=0;tthis.symbolInstances.get(e).zOffset-this.symbolInstances.get(t).zOffset))}addToSortKeyRanges(t,e){const i=this.sortKeyRanges[this.sortKeyRanges.length-1];i&&i.sortKey===e?i.symbolInstanceEnd=t+1:this.sortKeyRanges.push({sortKey:e,symbolInstanceStart:t,symbolInstanceEnd:t+1})}sortFeatures(t){if(this.sortFeaturesByY&&this.sortedAngle!==t&&!(this.text.segments.get().length>1||this.icon.segments.get().length>1)){this.symbolInstanceIndexes=this.getSortedSymbolIndexes(t),this.sortedAngle=t,this.text.indexArray.clear(),this.icon.indexArray.clear(),this.featureSortOrder=[];for(const t of this.symbolInstanceIndexes){const e=this.symbolInstances.get(t);this.featureSortOrder.push(e.featureIndex);const{rightJustifiedTextSymbolIndex:i,centerJustifiedTextSymbolIndex:n,leftJustifiedTextSymbolIndex:r,verticalPlacedTextSymbolIndex:o,placedIconSymbolIndex:s,verticalPlacedIconSymbolIndex:a}=e;i>=0&&this.addIndicesForPlacedSymbol(this.text,i),n>=0&&n!==i&&this.addIndicesForPlacedSymbol(this.text,n),r>=0&&r!==n&&r!==i&&this.addIndicesForPlacedSymbol(this.text,r),o>=0&&this.addIndicesForPlacedSymbol(this.text,o),s>=0&&this.addIndicesForPlacedSymbol(this.icon,s),a>=0&&this.addIndicesForPlacedSymbol(this.icon,a)}this.text.indexBuffer&&this.text.indexBuffer.updateData(this.text.indexArray),this.icon.indexBuffer&&this.icon.indexBuffer.updateData(this.icon.indexArray)}}}ba(jg,"SymbolBucket",{omit:["layers","collisionBoxArray","features","compareText"]}),jg.addDynamicAttributes=Bg;class Vg{constructor(t,e,i,n){this.context=t,this.format=i,this.texture=t.gl.createTexture(),this.update(e,n)}update(t,e,i){const{width:n,height:r}=t,{context:o}=this,{gl:s}=o;if(s.bindTexture(s.TEXTURE_2D,this.texture),o.pixelStoreUnpackFlipY.set(!1),o.pixelStoreUnpack.set(1),o.pixelStoreUnpackPremultiplyAlpha.set(this.format===s.RGBA&&(!e||!1!==e.premultiply)),this.useMipmap=Boolean(e&&e.useMipmap),i||this.size&&this.size[0]===n&&this.size[1]===r){const{x:e,y:o}=i||{x:0,y:0};if(t instanceof HTMLImageElement||t instanceof HTMLCanvasElement||t instanceof HTMLVideoElement||t instanceof ImageData||ImageBitmap&&t instanceof ImageBitmap)s.texSubImage2D(s.TEXTURE_2D,0,e,o,s.RGBA,s.UNSIGNED_BYTE,t);else{let i=this.format,a=s.UNSIGNED_BYTE;this.format===s.R32F&&(i=s.RED,a=s.FLOAT),s.texSubImage2D(s.TEXTURE_2D,0,e,o,n,r,i,a,t.data)}}else if(this.size=[n,r],t instanceof HTMLImageElement||t instanceof HTMLCanvasElement||t instanceof HTMLVideoElement||t instanceof ImageData||ImageBitmap&&t instanceof ImageBitmap){let e=this.format;this.format===s.R8&&(e=s.RED),s.texImage2D(s.TEXTURE_2D,0,this.format,e,s.UNSIGNED_BYTE,t)}else{let e=this.format,i=this.format,o=s.UNSIGNED_BYTE,a=!1;this.format===s.DEPTH_COMPONENT&&(e=s.DEPTH_COMPONENT16,o=s.UNSIGNED_SHORT),this.format===s.DEPTH_STENCIL&&(e=s.DEPTH24_STENCIL8,o=s.UNSIGNED_INT_24_8,a=!0),this.format===s.R8&&(i=s.RED),this.format===s.R32F&&(o=s.FLOAT,i=s.RED),!this.useMipmap&&a?s.texStorage2D(s.TEXTURE_2D,1,e,n,r):s.texImage2D(s.TEXTURE_2D,0,e,n,r,0,i,o,t.data)}this.useMipmap&&s.generateMipmap(s.TEXTURE_2D)}bind(t,e,i=!1){const{context:n}=this,{gl:r}=n;r.bindTexture(r.TEXTURE_2D,this.texture),t!==this.minFilter&&(r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MAG_FILTER,t),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MIN_FILTER,this.useMipmap&&!i?t===r.NEAREST?r.NEAREST_MIPMAP_NEAREST:r.LINEAR_MIPMAP_LINEAR:t),this.minFilter=t),e!==this.wrapS&&(r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_S,e),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_T,e),this.wrapS=e)}bindExtraParam(t,e,i,n){const{context:r}=this,{gl:o}=r;o.bindTexture(o.TEXTURE_2D,this.texture),e!==this.magFilter&&(o.texParameteri(o.TEXTURE_2D,o.TEXTURE_MAG_FILTER,e),this.magFilter=e),t!==this.minFilter&&(o.texParameteri(o.TEXTURE_2D,o.TEXTURE_MIN_FILTER,this.useMipmap?t===o.NEAREST?o.NEAREST_MIPMAP_NEAREST:o.LINEAR_MIPMAP_LINEAR:t),this.minFilter=t),i!==this.wrapS&&(o.texParameteri(o.TEXTURE_2D,o.TEXTURE_WRAP_S,i),this.wrapS=i),n!==this.wrapT&&(o.texParameteri(o.TEXTURE_2D,o.TEXTURE_WRAP_T,n),this.wrapT=n)}destroy(){const{gl:t}=this.context;t.deleteTexture(this.texture),this.texture=null}}class Gg{constructor(t,e){this.context=t,this.texture=e}bind(t,e){const{context:i}=this,{gl:n}=i;n.bindTexture(n.TEXTURE_2D,this.texture),t!==this.minFilter&&(n.texParameteri(n.TEXTURE_2D,n.TEXTURE_MAG_FILTER,t),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_MIN_FILTER,t),this.minFilter=t),e!==this.wrapS&&(n.texParameteri(n.TEXTURE_2D,n.TEXTURE_WRAP_S,e),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_WRAP_T,e),this.wrapS=e)}}const Zg=32,qg=33,Hg=new Uint16Array(8184);for(let t=0;t>=1)>1;){const t=i+r>>1,l=n+o>>1;1&e?(r=i,o=n,i=s,n=a):(i=r,n=o,r=s,o=a),s=t,a=l}const l=4*t;Hg[l+0]=i,Hg[l+1]=n,Hg[l+2]=r,Hg[l+3]=o}const Wg=new Uint16Array(2178),Yg=new Uint8Array(1089),Xg=new Uint16Array(1089);function Kg(t){return 0===t?-.03125:32===t?.03125:0}var Jg=Ll([{name:"a_pos",type:"Int16",components:2},{name:"a_texture_pos",type:"Int16",components:2}]),Qg=Ll([{name:"a_index",type:"Int16",components:1}]);const ty={type:2,extent:uo,loadGeometry:()=>[[new Ue(0,0),new Ue(uo+1,0),new Ue(uo+1,uo+1),new Ue(0,uo+1),new Ue(0,0)]]};class ey{constructor(t,e,i,n,r){this.tileID=t,this.uid=ni(),this.uses=0,this.tileSize=e,this.tileZoom=i,this.buckets={},this.expirationTime=null,this.queryPadding=0,this.hasSymbolBuckets=!1,this.hasRTLText=!1,this.dependencies={},this.isRaster=r,n&&n.style&&(this._lastUpdatedBrightness=n.style.getBrightness()),this.expiredRequestCount=0,this.state="loading",n&&n.transform&&(this.projection=n.transform.projection)}registerFadeDuration(t){const e=t+this.timeAdded;ee.getLayer(t))).filter(Boolean);if(0!==t.length){n.layers=t,n.stateDependentLayerIds&&(n.stateDependentLayers=n.stateDependentLayerIds.map((e=>t.filter((t=>t.id===e))[0])));for(const e of t)i[e.fqid]=n}}return i}(t.buckets,e.style),this.hasSymbolBuckets=!1;for(const t in this.buckets){const e=this.buckets[t];if(e instanceof jg){if(this.hasSymbolBuckets=!0,!i)break;e.justReloaded=!0}}if(this.hasRTLText=!1,this.hasSymbolBuckets)for(const t in this.buckets){const e=this.buckets[t];if(e instanceof jg&&e.hasRTLText){this.hasRTLText=!0,qa.isLoading()||qa.isLoaded()||"deferred"!==Ga()||Za();break}}this.queryPadding=0;for(const t in this.buckets){const i=this.buckets[t],n=e.style.getOwnLayer(t);if(!n)continue;const r=n.queryRadius(i);this.queryPadding=Math.max(this.queryPadding,r)}t.imageAtlas&&(this.imageAtlas=t.imageAtlas),t.glyphAtlasImage&&(this.glyphAtlasImage=t.glyphAtlasImage),t.lineAtlas&&(this.lineAtlas=t.lineAtlas),this._lastUpdatedBrightness=t.brightness}else this.collisionBoxArray=new dc}unloadVectorData(){if(this.hasData()){for(const t in this.buckets)this.buckets[t].destroy();this.buckets={},this.imageAtlas&&(this.imageAtlas=null),this.lineAtlas&&(this.lineAtlas=null),this.imageAtlasTexture&&this.imageAtlasTexture.destroy(),this.glyphAtlasTexture&&this.glyphAtlasTexture.destroy(),this.lineAtlasTexture&&this.lineAtlasTexture.destroy(),this._tileBoundsBuffer&&(this._tileBoundsBuffer.destroy(),this._tileBoundsIndexBuffer.destroy(),this._tileBoundsSegments.destroy(),this._tileBoundsBuffer=null),this._tileDebugBuffer&&(this._tileDebugBuffer.destroy(),this._tileDebugSegments.destroy(),this._tileDebugBuffer=null),this._tileDebugIndexBuffer&&(this._tileDebugIndexBuffer.destroy(),this._tileDebugIndexBuffer=null),this._globeTileDebugBorderBuffer&&(this._globeTileDebugBorderBuffer.destroy(),this._globeTileDebugBorderBuffer=null),this._tileDebugTextBuffer&&(this._tileDebugTextBuffer.destroy(),this._tileDebugTextSegments.destroy(),this._tileDebugTextIndexBuffer.destroy(),this._tileDebugTextBuffer=null),this._globeTileDebugTextBuffer&&(this._globeTileDebugTextBuffer.destroy(),this._globeTileDebugTextBuffer=null),this.latestFeatureIndex=null,this.state="unloaded"}}getBucket(t){return this.buckets[t.fqid]}upload(t){for(const e in this.buckets){const i=this.buckets[e];i.uploadPending()&&i.upload(t)}const e=t.gl,i=this.imageAtlas;if(i&&!i.uploaded){const n=!!Object.keys(i.patternPositions).length;this.imageAtlasTexture=new Vg(t,i.image,e.RGBA,{useMipmap:n}),this.imageAtlas.uploaded=!0}this.glyphAtlasImage&&(this.glyphAtlasTexture=new Vg(t,this.glyphAtlasImage,e.R8),this.glyphAtlasImage=null),this.lineAtlas&&!this.lineAtlas.uploaded&&(this.lineAtlasTexture=new Vg(t,this.lineAtlas.image,e.R8),this.lineAtlas.uploaded=!0)}prepare(t,e,i){if(this.imageAtlas&&this.imageAtlasTexture&&this.imageAtlas.patchUpdatedImages(t,this.imageAtlasTexture,i),!e||!this.latestFeatureIndex||!this.latestFeatureIndex.rawTileData)return;const n=e.style.getBrightness();(this._lastUpdatedBrightness||n)&&(this._lastUpdatedBrightness&&n&&Math.abs(this._lastUpdatedBrightness-n)t)i=!1;else if(e)if(this.expirationTime=0;t--){const e=4*t,i=Hg[e+0],n=Hg[e+1],r=Hg[e+2],o=Hg[e+3],s=i+r>>1,a=n+o>>1,l=s+a-n,c=a+i-s,d=n*qg+i,u=o*qg+r,h=a*qg+s,p=Math.hypot((Wg[2*d+0]+Wg[2*u+0])/2-Wg[2*h+0],(Wg[2*d+1]+Wg[2*u+1])/2-Wg[2*h+1])>=16;Yg[h]=Yg[h]||(p?1:0),t>1)*qg+(i+l>>1)]||Yg[(o+c>>1)*qg+(r+l>>1)])}const r=new Dl,o=new Kl;let s=0;function a(t,e){const i=e*qg+t;return 0===Xg[i]&&(r.emplaceBack(Wg[2*i+0],Wg[2*i+1],t*uo/Zg,e*uo/Zg),Xg[i]=++s),Xg[i]-1}function l(t,e,i,n,r,s){const c=t+i>>1,d=e+n>>1;if(Math.abs(t-r)+Math.abs(e-s)>1&&Yg[d*qg+c])l(r,s,t,e,c,d),l(i,n,r,s,c,d);else{const l=a(t,e),c=a(i,n),d=a(r,s);o.emplaceBack(l,c,d)}}return l(0,0,Zg,Zg,Zg,0),l(Zg,Zg,0,0,0,Zg),{vertices:r,indices:o}}(this.tileID.canonical,e);n=t.vertices,r=t.indices}else{n=new Dl,r=new Kl;for(const{x:t,y:e}of i)n.emplaceBack(t,e,0,0);const t=xh(n.int16,void 0,4);for(let e=0;e0&&(a=t.ad.invert(new Float64Array(16),i.globeMatrix)),this._makeGlobeTileDebugBorderBuffer(e,r,i,o,a,s),this._makeGlobeTileDebugTextBuffer(e,r,i,o,a,s)}_globePoint(e,i,n,r,o,s,a){let l=Fu(e,i,n);if(s){const o=1.5?h=-1:u{const p=(d-t)/(h-1),f=(u-c)/(h-1),m=s.length;for(let d=0;dd*t+e;for(let t=0;t[t,this.get(t)]))}evict(t=!1){if(t||this.size>0){const t=this.first;delete this.items[t.key],0==--this.size?(this.first=null,this.last=null):(this.first=t.next,this.first.prev=null)}return this}expiresAt(t){let e;return this.has(t)&&(e=this.items[t].expiry),e}get(t){let e;if(this.has(t)){const i=this.items[t];this.ttl>0&&i.expiry0?Date.now()+this.ttl:this.ttl),this.last!==r){const t=this.last,e=r.next,i=r.prev;this.first===r&&(this.first=r.next),r.next=null,r.prev=this.last,t.next=r,null!==i&&(i.next=e),null!==e&&(e.prev=i)}}else this.max>0&&this.size===this.max&&this.evict(!0),r=this.items[t]={expiry:this.ttl>0?Date.now()+this.ttl:this.ttl,key:t,prev:this.last,next:null,value:e},1==++this.size?this.first=r:this.last.next=r;return this.last=r,this}values(t=this.keys()){return t.map((t=>this.get(t)))}}function uy(t,e){if(4!==e.length)throw new Error(`Expected data of dimension 4 but got ${e.length}.`);let i=e[3];for(let n=2;n>=1;n--){const r=1===n?1:0,o=2===n?1:0;for(let n=0;n>>1^-(1&t[e]);return t}function py(t,e){switch(e){case"uint32":return t;case"uint16":for(let e=0;e>4|(61440&i)>>8|(240&n)>4|(15&n)>6|(192&n)>>4|(192&r)>>2|192&o,t[e+1]=(48&i)>>4|(48&n)>>2|48&r|(48&o)>2|12&n|(12&r)>1|(21845&Cy)>2|(13107&Ay)>4|(3855&Ay)>8|(255&Ay)>1}var Iy=function(t,e,i){for(var n=t.length,r=0,o=new _y(e);r>l]=c}else for(s=new _y(n),r=0;r>15-t[r]);return s},Ly=new my(288);for(Cy=0;Cye&&(e=t[i]);return e},zy=function(t,e,i){var n=e/8|0;return(t[n]|t[n+1]>(7&e)&i},Ry=function(t,e){var i=e/8|0;return(t[i]|t[i+1]>(7&e)},Oy=["unexpected EOF","invalid block type","invalid length/literal","invalid distance","stream finished","no stream handler",,"no callback","invalid UTF-8 data","extra field too long","date not in range 1980-2099","filename too long","stream finishing","invalid zip data"],By=function(t,e,i){var n=new Error(e||Oy[t]);if(n.code=t,Error.captureStackTrace&&Error.captureStackTrace(n,By),!i)throw n;return n},Fy=new my(0),Ny="undefined"!=typeof TextDecoder&&new TextDecoder;try{Ny.decode(Fy,{stream:!0})}catch(t){}const Uy={gzip_data:"gzip"},jy={0:"uint32",1:"uint32",2:"uint16",3:"uint8"},Vy={uint32:1,uint16:2,uint8:4},Gy={uint32:Uint32Array,uint16:Uint16Array,uint8:Uint8Array};class Zy{constructor(t=1){this.x=NaN,this.y=NaN,this.z=NaN,this.layers={},this._cacheSize=t}getLayer(t){return this.layers[t]}getHeaderLength(t){const e=new Uint8Array(t),i=new DataView(t);if(13!==e[0])throw new fy("File is not a valid MRT.");return i.getUint32(1,!0)}parseHeader(t){const e=new Uint8Array(t),i=this.getHeaderLength(t);if(e.length= ${i} but got buffer of length ${e.length}`);const n=function(t){return t.readFields(iy,{header_length:0,x:0,y:0,z:0,layers:[]},void 0)}(new Lm(e.subarray(0,i)));if(!isNaN(this.x)&&(this.x!==n.x||this.y!==n.y||this.z!==n.z))throw new fy(`Invalid attempt to parse header ${n.z}/${n.x}/${n.y} for tile ${this.z}/${this.x}/${this.y}`);this.x=n.x,this.y=n.y,this.z=n.z;for(const t of n.layers)this.layers[t.name]=new qy(t,{cacheSize:this._cacheSize});return this}createDecodingTask(t){const e=[],i=this.getLayer(t.layerName);for(let n=0;nt.lastBlock)continue;if(i._blocksInProgress.has(n))continue;const a={layerName:i.name,firstByte:o,lastByte:s,pixelFormat:i.pixelFormat,blockIndex:n,blockShape:[r.bands.length].concat(i.bandShape),buffer:i.buffer,codec:r.codec.codec,filters:r.filters.map((t=>t.filter))};i._blocksInProgress.add(n),e.push(a)}return new Hy(e,(()=>{e.forEach((t=>i._blocksInProgress.delete(t.blockIndex)))}),((t,n)=>{if(e.forEach((t=>i._blocksInProgress.delete(t.blockIndex))),t)throw t;n.forEach((t=>{this.getLayer(t.layerName).processDecodedData(t)}))}))}}class qy{constructor({version:t,name:e,units:i,tilesize:n,pixel_format:r,buffer:o,data_index:s},a){if(this.version=t,1!==this.version)throw new fy(`Cannot parse raster layer encoded with MRT version ${t}`);this.name=e,this.units=i,this.tileSize=n,this.buffer=o,this.pixelFormat=jy[r],this.dataIndex=s,this.bandShape=[n+2*o,n+2*o,Vy[this.pixelFormat]],this._decodedBlocks=function(t=1e3,e=0,i=!1){if(isNaN(t)||t=e&&t=0}hasDataForBand(t){const{blockIndex:e}=this.getBlockForBand(t);return e>=0&&!!this._decodedBlocks.get(e.toString())}getBandView(t){const{blockIndex:e,blockBandIndex:i}=this.getBlockForBand(t),n=this._decodedBlocks.get(e.toString());if(!n)throw new fy(`Data for band ${JSON.stringify(t)} of layer "${this.name}" not decoded.`);const r=this.dataIndex[e],o=this.bandShape.reduce(((t,e)=>t*e),1),s=i*o,a=n.subarray(s,s+o);return{data:a,bytes:new Uint8Array(a.buffer).subarray(a.byteOffset,a.byteOffset+a.byteLength),tileSize:this.tileSize,buffer:this.buffer,offset:r.offset,scale:r.scale}}}class Hy{constructor(t,e,i){this.tasks=t,this._onCancel=e,this._onComplete=i,this._finalized=!1}cancel(){this._finalized||(this._onCancel(),this._finalized=!0)}complete(t,e){this._finalized||(this._onComplete(t,e),this._finalized=!0)}}Zy.performDecoding=function(t,e){return Promise.all(e.tasks.map((e=>{const{layerName:i,firstByte:n,lastByte:r,pixelFormat:o,blockShape:s,blockIndex:a,filters:l,codec:c}=e,d=new Uint8Array(t).subarray(n,r+1),u=new Uint32Array(s[0]*s[1]*s[2]);let h;if("gzip_data"!==c)throw new Error(`Unhandled codec: ${c}`);return h=function(t,e){if(!globalThis.DecompressionStream&&"gzip_data"===e)return Promise.resolve(((o=function(t){31==t[0]&&139==t[1]&&8==t[2]||By(6,"invalid gzip data");var e=t[3],i=10;4&e&&(i+=2+(t[10]|t[11]>3&1)+(e>>4&1);n>0;n-=!t[i++]);return i+(2&e)}(r=t))+8>r.length&&By(6,"invalid gzip data"),function(t,e,i){var n=t.length;if(!n||e.f&&!e.l)return i||new my(0);var r=!i,o=r||2!=e.i,s=e.i;r&&(i=new my(3*n));var a,l,c=function(t){var e=i.length;if(t>e){var n=new my(Math.max(2*e,t));n.set(i),i=n}},d=e.f||0,u=e.p||0,h=e.b||0,p=e.l,f=e.d,m=e.m,_=e.n,g=8*n;do{if(!p){d=zy(t,u,1);var y=zy(t,u+1,3);if(u+=3,!y){var v=t[(L=4+((u+7)/8|0))-4]|t[L-3]n){s&&By(0);break}o&&c(h+v),i.set(t.subarray(L,x),h),e.b=h+=v,e.p=u=8*x,e.f=d;continue}if(1==y)p=$y,f=ky,m=9,_=5;else if(2==y){var b=zy(t,u,31)+257,w=zy(t,u+10,15)+4,T=b+zy(t,u+5,31)+1;u+=14;for(var S=new my(T),E=new my(19),M=0;M>4)g){s&&By(0);break}}o&&c(h+131072);for(var R=(1>4;if((u+=15&$)>g){s&&By(0);break}if($||By(2),F264&&(N=zy(t,u,(1>4;if(U||By(3),u+=15&U,z=Ey[j],j>3){var V=vy[j];z+=Ry(t,u)&(1g){s&&By(0);break}o&&c(h+131072);var G=h+N;if(ha.length)&&(l=a.length),new my(a.subarray(0,l))):i.subarray(0,h)}(r.subarray(o,-8),{i:2},new my(((i=r)[(n=i.length)-4]|i[n-3]>>0))));var i,n,r,o;const s=Uy[e];if(!s)throw new Error(`Unhandled codec: ${e}`);const a=new globalThis.DecompressionStream(s);return new Response(new Blob([t]).stream().pipeThrough(a)).arrayBuffer().then((t=>new Uint8Array(t)))}(d,c).then((t=>(function(t,e){t.readFields(ly,e)}(new Lm(t),u),new(0,Gy[o])(u.buffer)))),h.then((t=>{for(let e=l.length-1;e>=0;e--)switch(l[e]){case"delta_filter":uy(t,s);break;case"zigzag_filter":hy(t);break;case"bitshuffle_filter":py(t,o);break;default:throw new Error(`Unhandled filter "${l[e]}"`)}return{layerName:i,blockIndex:a,data:t}})).catch((t=>{throw t}))})))};class Wy extends ey{constructor(t,e,i,n,r){super(t,e,i,n,r),this._workQueue=[],this._fetchQueue=[],this._isHeaderLoaded=!1}setTexture(t,e){const i=e.context,n=i.gl;this.texture=this.texture||e.getTileTexture(t.width),this.texture&&this.texture instanceof Vg?this.texture.update(t,{useMipmap:!1,premultiply:!1}):this.texture=new Vg(i,t,n.RGBA,{useMipmap:!1,premultiply:!1})}flushQueues(){for(;this._workQueue.length;)this._workQueue.pop()();for(;this._fetchQueue.length;)this._fetchQueue.pop()()}fetchHeader(t=16384,e){const i=this._mrt=new Zy(30),n=Object.assign({},this.requestParams,{headers:{Range:"bytes=0-"+(t-1)}});return this.entireBuffer=null,this.request=en(n,((n,r,o,s)=>{if(n)e(n);else try{const n=i.getHeaderLength(r);if(n>t)return void(this.request=this.fetchHeader(n,e));i.parseHeader(r),this._isHeaderLoaded=!0;let a=0;for(const t of Object.values(i.layers))a=Math.max(a,t.dataIndex[t.dataIndex.length-1].last_byte);r.byteLength>=a&&(this.entireBuffer=r),e(null,this.entireBuffer||r,o,s)}catch(t){e(t)}})),this.request}fetchBand(t,e,i){const n=this._mrt;if(!this._isHeaderLoaded||!n)return void i(new Error("Tile header is not ready"));const r=this.actor;if(!r)return void i(new Error("Can't fetch tile band without an actor"));let o;const s=(n,r)=>{o.complete(n,r),n?i(n):(this.updateTextureDescriptor(t,e),i(null,this.textureDescriptor&&this.textureDescriptor.img))},a=(t,e)=>{if(t)return i(t);const n=r.send("decodeRasterArray",{buffer:e,task:o},s,void 0,!0);this._workQueue.push((()=>{n&&n.cancel(),o.cancel()}))},l=n.getLayer(t);if(!l)return void i(new Error(`Unknown sourceLayer "${t}"`));if(l.hasDataForBand(e))return this.updateTextureDescriptor(t,e),void i(null,this.textureDescriptor?this.textureDescriptor.img:null);const c=l.getDataRange([e]);if(o=n.createDecodingTask(c),!o||o.tasks.length)if(this.flushQueues(),this.entireBuffer)a(null,this.entireBuffer.slice(c.firstByte,c.lastByte+1));else{const t=Object.assign({},this.requestParams,{headers:{Range:`bytes=${c.firstByte}-${c.lastByte}`}}),e=en(t,a);this._fetchQueue.push((()=>{e.cancel(),o.cancel()}))}else i(null)}updateNeeded(t,e){return(!this.textureDescriptor||this.textureDescriptor.band!==e||this.textureDescriptor.layer!==t)&&"errored"!==this.state}updateTextureDescriptor(t,e){if(!this._mrt)return;const i=this._mrt.getLayer(t);if(!i||!i.hasBand(e)||!i.hasDataForBand(e))return;const{bytes:n,tileSize:r,buffer:o,offset:s,scale:a}=i.getBandView(e),l=r+2*o,c={data:n,width:l,height:l},d=this.texture;d&&d instanceof Vg&&d.update(c,{useMipmap:!1,premultiply:!1}),this.textureDescriptor={layer:t,band:e,img:c,buffer:o,offset:s,tileSize:r,format:i.pixelFormat,mix:[a,256*a,65536*a,16777216*a]}}}class Yy{constructor(t,e){this.max=t,this.onRemove=e,this.reset()}reset(){for(const t in this.data)for(const e of this.data[t])e.timeout&&clearTimeout(e.timeout),this.onRemove(e.value);return this.data={},this.order=[],this}add(t,e,i){const n=t.wrapped().key;void 0===this.data[n]&&(this.data[n]=[]);const r={value:e,timeout:void 0};if(void 0!==i&&(r.timeout=setTimeout((()=>{this.remove(t,r)}),i)),this.data[n].push(r),this.order.push(n),this.order.length>this.max){const t=this._getAndRemoveByKey(this.order[0]);t&&this.onRemove(t)}return this}has(t){return t.wrapped().key in this.data}getAndRemove(t){return this.has(t)?this._getAndRemoveByKey(t.wrapped().key):null}_getAndRemoveByKey(t){const e=this.data[t].shift();return e.timeout&&clearTimeout(e.timeout),0===this.data[t].length&&delete this.data[t],this.order.splice(this.order.indexOf(t),1),e.value}getByKey(t){const e=this.data[t];return e?e[0].value:null}get(t){return this.has(t)?this.data[t.wrapped().key][0].value:null}remove(t,e){if(!this.has(t))return this;const i=t.wrapped().key,n=void 0===e?0:this.data[i].indexOf(e),r=this.data[i][n];return this.data[i].splice(n,1),r.timeout&&clearTimeout(r.timeout),0===this.data[i].length&&delete this.data[i],this.onRemove(r.value),this.order.splice(this.order.indexOf(i),1),this}setMaxSize(t){for(this.max=t;this.order.length>this.max;){const t=this._getAndRemoveByKey(this.order[0]);t&&this.onRemove(t)}return this}filter(t){const e=[];for(const i in this.data)for(const n of this.data[i])t(n.value)||e.push(n);for(const t of e)this.remove(t.value.tileID,t)}}class Xy extends zn{constructor(t,e,i){super(),this.id=t,this._onlySymbols=i,e.on("data",(t=>{"source"===t.dataType&&"metadata"===t.sourceDataType&&(this._sourceLoaded=!0),this._sourceLoaded&&!this._paused&&"source"===t.dataType&&"content"===t.sourceDataType&&(this.reload(),this.transform&&this.update(this.transform))})),e.on("error",(()=>{this._sourceErrored=!0})),this._source=e,this._tiles={},this._cache=new Yy(0,this._unloadTile.bind(this)),this._timers={},this._cacheTimers={},this._minTileCacheSize=e.minTileCacheSize,this._maxTileCacheSize=e.maxTileCacheSize,this._loadedParentTiles={},this.castsShadows=!1,this.tileCoverLift=0,this._coveredTiles={},this._shadowCasterTiles={},this._state=new km,this._isRaster="raster"===this._source.type||"raster-dem"===this._source.type||"raster-array"===this._source.type||"custom"===this._source.type&&"raster"===this._source._dataType}onAdd(t){this.map=t,this._minTileCacheSize=void 0===this._minTileCacheSize&&t?t._minTileCacheSize:this._minTileCacheSize,this._maxTileCacheSize=void 0===this._maxTileCacheSize&&t?t._maxTileCacheSize:this._maxTileCacheSize}loaded(){if(this._sourceErrored)return!0;if(!this._sourceLoaded)return!1;if(!this._source.loaded())return!1;for(const t in this._tiles){const e=this._tiles[t];if("errored"!==e.state&&("loaded"!==e.state||!e.bucketsLoaded()))return!1}return!0}getSource(){return this._source}pause(){this._paused=!0}resume(){if(!this._paused)return;const t=this._shouldReloadOnResume;this._paused=!1,this._shouldReloadOnResume=!1,t&&this.reload(),this.transform&&this.update(this.transform)}_loadTile(t,e){return t.isSymbolTile=this._onlySymbols,t.isExtraShadowCaster=this._shadowCasterTiles[t.tileID.key],this._source.loadTile(t,e)}_unloadTile(t){if(this._source.unloadTile)return this._source.unloadTile(t)}_abortTile(t){if(this._source.abortTile)return this._source.abortTile(t)}serialize(){return this._source.serialize()}prepare(t){this._source.prepare&&this._source.prepare(),this._state.coalesceChanges(this._tiles,this.map?this.map.painter:null);for(const e in this._tiles){const i=this._tiles[e];i.upload(t),i.prepare(this.map.style.imageManager,this.map?this.map.painter:null,this._source.scope)}}getIds(){return ti(this._tiles).map((t=>t.tileID)).sort(Ky).map((t=>t.key))}getRenderableIds(t,e){const i=[];for(const n in this._tiles)this._isIdRenderable(+n,t,e)&&i.push(this._tiles[n]);return t?i.sort(((t,e)=>{const i=t.tileID,n=e.tileID,r=new Ue(i.canonical.x,i.canonical.y)._rotate(this.transform.angle),o=new Ue(n.canonical.x,n.canonical.y)._rotate(this.transform.angle);return i.overscaledZ-n.overscaledZ||o.y-r.y||o.x-r.x})).map((t=>t.tileID.key)):i.map((t=>t.tileID)).sort(Ky).map((t=>t.key))}hasRenderableParent(t){const e=this.findLoadedParent(t,0);return!!e&&this._isIdRenderable(e.tileID.key)}_isIdRenderable(t,e,i){return this._tiles[t]&&this._tiles[t].hasData()&&!this._coveredTiles[t]&&(e||!this._tiles[t].holdingForFade())&&(i||!this._shadowCasterTiles[t])}reload(){if(this._paused)this._shouldReloadOnResume=!0;else{this._cache.reset();for(const t in this._tiles)"errored"!==this._tiles[t].state&&this._reloadTile(+t,"reloading")}}_reloadTile(t,e){const i=this._tiles[t];i&&("loading"!==i.state&&(i.state=e),this._loadTile(i,this._tileLoaded.bind(this,i,t,e)))}_tileLoaded(t,e,i,n){if(n)if(t.state="errored",404!==n.status)this._source.fire(new $n(n,{tile:t}));else{if(!(t.tileID.key in this._loadedParentTiles))return void this._source.fire(new Pn("data",{dataType:"source",sourceDataType:"error",sourceId:this._source.id}));if("raster-dem"===this._source.type&&this.usedForTerrain&&this.map.painter.terrain){const t=this.map.painter.terrain;this.update(this.transform,t.getScaledDemTileSize(),!0),t.resetTileLookupCache(this.id)}else this.update(this.transform)}else t.timeAdded=ki.now(),"expired"===i&&(t.refreshedUponExpiration=!0),this._setTileReloadTimer(e,t),"raster-dem"===this._source.type&&t.dem&&this._backfillDEM(t),this._state.initializeTileState(t,this.map?this.map.painter:null),this._source.fire(new Pn("data",{dataType:"source",tile:t,coord:t.tileID,sourceCacheId:this.id}))}_backfillDEM(t){const e=this.getRenderableIds();for(let n=0;n1||(Math.abs(i)>1&&(1===Math.abs(i+r)?i+=r:1===Math.abs(i-r)&&(i-=r)),e.dem&&t.dem&&(t.dem.backfillBorder(e.dem,i,n),t.neighboringTiles&&t.neighboringTiles[o]&&(t.neighboringTiles[o].backfilled=!0)))}}getTile(t){return this.getTileByID(t.key)}getTileByID(t){return this._tiles[t]}_retainLoadedChildren(t,e,i,n){for(const r in this._tiles){let o=this._tiles[r];if(n[r]||!o.hasData()||o.tileID.overscaledZi)continue;let s=o.tileID;for(;o&&o.tileID.overscaledZ>e+1;){const t=o.tileID.scaledTo(o.tileID.overscaledZ-1);o=this._tiles[t.key],o&&o.hasData()&&(s=t)}let a=s;for(;a.overscaledZ>e;)if(a=a.scaledTo(a.overscaledZ-1),t[a.key]){n[s.key]=s;break}}}findLoadedParent(t,e){if(t.key in this._loadedParentTiles){const i=this._loadedParentTiles[t.key];return i&&i.tileID.overscaledZ>=e?i:null}for(let i=t.overscaledZ-1;i>=e;i--){const e=t.scaledTo(i),n=this._getLoadedTile(e);if(n)return n}}_getLoadedTile(t){const e=this._tiles[t.key];return e&&e.hasData()?e:this._cache.getByKey(this._source.reparseOverscaled?t.wrapped().key:t.canonical.key)}updateCacheSize(t,e){e=e||this._source.tileSize;const i=Math.ceil(t.width/e)+1,n=Math.ceil(t.height/e)+1,r=Math.floor(i*n*5),o="number"==typeof this._minTileCacheSize?Math.max(this._minTileCacheSize,r):r,s="number"==typeof this._maxTileCacheSize?Math.min(this._maxTileCacheSize,o):o;this._cache.setMaxSize(s)}handleWrapJump(t){const e=Math.round((t-(void 0===this._prevLng?t:this._prevLng))/360);if(this._prevLng=t,e){const t={};for(const i in this._tiles){const n=this._tiles[i];n.tileID=n.tileID.unwrapTo(n.tileID.wrap+e),t[n.tileID.key]=n}this._tiles=t;for(const t in this._timers)clearTimeout(this._timers[t]),delete this._timers[t];for(const t in this._tiles)this._setTileReloadTimer(+t,this._tiles[t])}}update(t,e,i,n){if(this.transform=t,!this._sourceLoaded||this._paused||this.transform.freezeTileCoverage)return;if(this.usedForTerrain&&!i)return;let r;if(this.updateCacheSize(t,e),"globe"!==this.transform.projection.name&&this.handleWrapJump(this.transform.center.lng),this._shadowCasterTiles={},this._coveredTiles={},this.used||this.usedForTerrain){if(this._source.tileID)r=t.getVisibleUnwrappedCoordinates(this._source.tileID).map((t=>new vd(t.canonical.z,t.wrap,t.canonical.z,t.canonical.x,t.canonical.y)));else if(0!==this.tileCoverLift){const n=t.clone();n.tileCoverLift=this.tileCoverLift,r=n.coveringTiles({tileSize:e||this._source.tileSize,minzoom:this._source.minzoom,maxzoom:this._source.maxzoom,roundZoom:this._source.roundZoom&&!i,reparseOverscaled:this._source.reparseOverscaled,isTerrainDEM:this.usedForTerrain}),this._source.minzoomt(e)))}}else r=[];if(r.length>0&&this.castsShadows&&n&&"globe"!==this.transform.projection.name&&!this.usedForTerrain&&!Jy(this._source.type)){const o=t.coveringZoomLevel({tileSize:e||this._source.tileSize,roundZoom:this._source.roundZoom&&!i}),s=Math.min(o,this._source.maxzoom),a=t.extendTileCoverForShadows(r,n,s);for(const t of a)this._shadowCasterTiles[t.key]=!0,r.push(t)}const o=this._updateRetainedTiles(r);if(Jy(this._source.type)&&0!==r.length){const t={},e={},i=Object.keys(o);for(const n of i){const i=o[n],r=this._tiles[n];if(!r||r.fadeEndTime&&r.fadeEndTimen;){r=r.scaledTo(r.overscaledZ-1);const n=this._tiles[r.key];if(n&&n.hasData()&&e[r.key]){o[t]=i.tileID;break}}}for(const e in t)o[e]||(this._coveredTiles[e]=!0,o[e]=t[e])}for(const t in o)this._tiles[t].clearFadeHold();const s=function(t,e){const i=[];for(const n in t)n in e||i.push(n);return i}(this._tiles,o);for(const t of s){const e=this._tiles[t];e.hasSymbolBuckets&&!e.holdingForFade()?e.setHoldDuration(this.map._fadeDuration):e.hasSymbolBuckets&&!e.symbolFadeFinished()||this._removeTile(+t)}this._updateLoadedParentTileCache(),this._onlySymbols&&this._source.afterUpdate&&this._source.afterUpdate()}releaseSymbolFadeTiles(){for(const t in this._tiles)this._tiles[t].holdingForFade()&&this._removeTile(+t)}_updateRetainedTiles(t){const e={};if(0===t.length)return e;const i={},n=t.reduce(((t,e)=>Math.min(t,e.overscaledZ)),1/0),r=t[0].overscaledZ,o=Math.max(r-Xy.maxOverzooming,this._source.minzoom),s=Math.max(r+Xy.maxUnderzooming,this._source.minzoom),a={};for(const i of t){const t=this._addTile(i);e[i.key]=i,t.hasData()||n=this._source.maxzoom){const t=n.children(this._source.maxzoom)[0],i=this.getTile(t);if(i&&i.hasData()){e[t.key]=t;continue}}else{const t=n.children(this._source.maxzoom);if(e[t[0].key]&&e[t[1].key]&&e[t[2].key]&&e[t[3].key])continue}let r=t.wasRequested();for(let s=n.overscaledZ-1;s>=o;--s){const o=n.scaledTo(s);if(i[o.key])break;if(i[o.key]=!0,t=this.getTile(o),!t&&r&&(t=this._addTile(o)),t&&(e[o.key]=o,r=t.wasRequested(),t.hasData()))break}}return e}_updateLoadedParentTileCache(){this._loadedParentTiles={};for(const t in this._tiles){const e=[];let i,n=this._tiles[t].tileID;for(;n.overscaledZ>0;){if(n.key in this._loadedParentTiles){i=this._loadedParentTiles[n.key];break}e.push(n.key);const t=n.scaledTo(n.overscaledZ-1);if(i=this._getLoadedTile(t),i)break;n=t}for(const t of e)this._loadedParentTiles[t]=i}}_addTile(t){let e=this._tiles[t.key];if(e)return!0!==e.isExtraShadowCaster||!!this._shadowCasterTiles[t.key]||this._reloadTile(t.key,"reloading"),e;e=this._cache.getAndRemove(t),e&&(this._setTileReloadTimer(t.key,e),e.tileID=t,this._state.initializeTileState(e,this.map?this.map.painter:null),this._cacheTimers[t.key]&&(clearTimeout(this._cacheTimers[t.key]),delete this._cacheTimers[t.key],this._setTileReloadTimer(t.key,e)));const i=Boolean(e);if(!i){const i=this.map?this.map.painter:null,n=this._source.tileSize*t.overscaleFactor();e="raster-array"===this._source.type?new Wy(t,n,this.transform.tileZoom,i,this._isRaster):new ey(t,n,this.transform.tileZoom,i,this._isRaster),this._loadTile(e,this._tileLoaded.bind(this,e,t.key,e.state))}return e?(e.uses++,this._tiles[t.key]=e,i||this._source.fire(new Pn("dataloading",{tile:e,coord:e.tileID,dataType:"source"})),e):null}_setTileReloadTimer(t,e){t in this._timers&&(clearTimeout(this._timers[t]),delete this._timers[t]);const i=e.getExpiryTimeout();i&&(this._timers[t]=setTimeout((()=>{this._reloadTile(t,"expired"),delete this._timers[t]}),i))}_removeTile(t){const e=this._tiles[t];e&&(e.uses--,delete this._tiles[t],this._timers[t]&&(clearTimeout(this._timers[t]),delete this._timers[t]),e.uses>0||(e.hasData()&&"reloading"!==e.state||"empty"===e.state?this._cache.add(e.tileID,e,e.getExpiryTimeout()):(e.aborted=!0,this._abortTile(e),this._unloadTile(e))))}clearTiles(){this._shouldReloadOnResume=!1,this._paused=!1;for(const t in this._tiles)this._removeTile(+t);this._source._clear&&this._source._clear(),this._cache.reset(),this.map&&this.usedForTerrain&&this.map.painter.terrain&&this.map.painter.terrain.resetTileLookupCache(this.id)}tilesIn(t,e,i){const n=[],r=this.transform;if(!r)return n;const o="globe"===r.projection.name,s=Ed(r.center.lng);for(const a in this._tiles){const l=this._tiles[a];if(i&&l.clearQueryDebugViz(),l.holdingForFade())continue;let c;if(o){const t=l.tileID.canonical;if(0===t.z){const e=[Math.abs(Xe(s,...Qy(t,-1))-s),Math.abs(Xe(s,...Qy(t,1))-s)];c=[0,2*e.indexOf(Math.min(...e))-1]}else{const e=[Math.abs(Xe(s,...Qy(t,-1))-s),Math.abs(Xe(s,...Qy(t,0))-s),Math.abs(Xe(s,...Qy(t,1))-s)];c=[e.indexOf(Math.min(...e))-1]}}else c=[0];for(const i of c){const o=t.containsTile(l,r,e,i);o&&n.push(o)}}return n}getShadowCasterCoordinates(){return this._getRenderableCoordinates(!1,!0)}getVisibleCoordinates(t){return this._getRenderableCoordinates(t)}_getRenderableCoordinates(t,e){const i=this.getRenderableIds(t,e).map((t=>this._tiles[t].tileID)),n="globe"===this.transform.projection.name;for(const t of i)t.projMatrix=this.transform.calculateProjMatrix(t.toUnwrapped()),t.expandedProjMatrix=n?this.transform.calculateProjMatrix(t.toUnwrapped(),!1,!0):t.projMatrix;return i}sortCoordinatesByDistance(t){const e=t.slice(),i=this.transform._camera.position,n=this.transform._camera.forward(),r={};for(const t of e){const e=1/(1r[t.key]-r[e.key])),e}hasTransition(){if(this._source.hasTransition())return!0;if(Jy(this._source.type))for(const t in this._tiles){const e=this._tiles[t];if(void 0!==e.fadeEndTime&&e.fadeEndTime>=ki.now())return!0}return!1}setFeatureState(t,e,i){this._state.updateState(t=t||"_geojsonTileLayer",e,i)}removeFeatureState(t,e,i){this._state.removeFeatureState(t=t||"_geojsonTileLayer",e,i)}getFeatureState(t,e){return this._state.getState(t=t||"_geojsonTileLayer",e)}setDependencies(t,e,i){const n=this._tiles[t];n&&n.setDependencies(e,i)}reloadTilesForDependencies(t,e){for(const i in this._tiles)this._tiles[i].hasDependency(t,e)&&this._reloadTile(+i,"reloading");this._cache.filter((i=>!i.hasDependency(t,e)))}_preloadTiles(t,e){if(!this._sourceLoaded){const i=()=>{this._sourceLoaded&&(this._source.off("data",i),this._preloadTiles(t,e))};return void this._source.on("data",i)}const i=new Map,n=Array.isArray(t)?t:[t],r=this.map.painter.terrain,o=this.usedForTerrain&&r?r.getScaledDemTileSize():this._source.tileSize;for(const t of n){const e=t.coveringTiles({tileSize:o,minzoom:this._source.minzoom,maxzoom:this._source.maxzoom,roundZoom:this._source.roundZoom&&!this.usedForTerrain,reparseOverscaled:this._source.reparseOverscaled,isTerrainDEM:this.usedForTerrain});for(const t of e)i.set(t.key,t);this.usedForTerrain&&t.updateElevation(!1)}Qe(Array.from(i.values()),((t,e)=>{const i=new ey(t,this._source.tileSize*t.overscaleFactor(),this.transform.tileZoom,this.map.painter,this._isRaster);this._loadTile(i,(t=>{"raster-dem"===this._source.type&&i.dem&&this._backfillDEM(i),e(t,i)}))}),e)}}function Ky(t,e){const i=Math.abs(2*t.wrap)-+(t.wrap0?e+2*t:t}tv.useIntegerZoom=!0;const iv=new ol({"symbol-placement":new il(sl.layout_symbol["symbol-placement"]),"symbol-spacing":new il(sl.layout_symbol["symbol-spacing"]),"symbol-avoid-edges":new il(sl.layout_symbol["symbol-avoid-edges"]),"symbol-sort-key":new nl(sl.layout_symbol["symbol-sort-key"]),"symbol-z-order":new il(sl.layout_symbol["symbol-z-order"]),"symbol-z-elevate":new il(sl.layout_symbol["symbol-z-elevate"]),"icon-allow-overlap":new il(sl.layout_symbol["icon-allow-overlap"]),"icon-ignore-placement":new il(sl.layout_symbol["icon-ignore-placement"]),"icon-optional":new il(sl.layout_symbol["icon-optional"]),"icon-rotation-alignment":new il(sl.layout_symbol["icon-rotation-alignment"]),"icon-size":new nl(sl.layout_symbol["icon-size"]),"icon-text-fit":new nl(sl.layout_symbol["icon-text-fit"]),"icon-text-fit-padding":new nl(sl.layout_symbol["icon-text-fit-padding"]),"icon-image":new nl(sl.layout_symbol["icon-image"]),"icon-rotate":new nl(sl.layout_symbol["icon-rotate"]),"icon-padding":new il(sl.layout_symbol["icon-padding"]),"icon-keep-upright":new il(sl.layout_symbol["icon-keep-upright"]),"icon-offset":new nl(sl.layout_symbol["icon-offset"]),"icon-anchor":new nl(sl.layout_symbol["icon-anchor"]),"icon-pitch-alignment":new il(sl.layout_symbol["icon-pitch-alignment"]),"text-pitch-alignment":new il(sl.layout_symbol["text-pitch-alignment"]),"text-rotation-alignment":new il(sl.layout_symbol["text-rotation-alignment"]),"text-field":new nl(sl.layout_symbol["text-field"]),"text-font":new nl(sl.layout_symbol["text-font"]),"text-size":new nl(sl.layout_symbol["text-size"]),"text-max-width":new nl(sl.layout_symbol["text-max-width"]),"text-line-height":new nl(sl.layout_symbol["text-line-height"]),"text-letter-spacing":new nl(sl.layout_symbol["text-letter-spacing"]),"text-justify":new nl(sl.layout_symbol["text-justify"]),"text-radial-offset":new nl(sl.layout_symbol["text-radial-offset"]),"text-variable-anchor":new il(sl.layout_symbol["text-variable-anchor"]),"text-anchor":new nl(sl.layout_symbol["text-anchor"]),"text-max-angle":new il(sl.layout_symbol["text-max-angle"]),"text-writing-mode":new il(sl.layout_symbol["text-writing-mode"]),"text-rotate":new nl(sl.layout_symbol["text-rotate"]),"text-padding":new il(sl.layout_symbol["text-padding"]),"text-keep-upright":new il(sl.layout_symbol["text-keep-upright"]),"text-transform":new nl(sl.layout_symbol["text-transform"]),"text-offset":new nl(sl.layout_symbol["text-offset"]),"text-allow-overlap":new il(sl.layout_symbol["text-allow-overlap"]),"text-ignore-placement":new il(sl.layout_symbol["text-ignore-placement"]),"text-optional":new il(sl.layout_symbol["text-optional"]),visibility:new il(sl.layout_symbol.visibility)});var nv={paint:new ol({"icon-opacity":new nl(sl.paint_symbol["icon-opacity"]),"icon-occlusion-opacity":new nl(sl.paint_symbol["icon-occlusion-opacity"]),"icon-emissive-strength":new nl(sl.paint_symbol["icon-emissive-strength"]),"text-emissive-strength":new nl(sl.paint_symbol["text-emissive-strength"]),"icon-color":new nl(sl.paint_symbol["icon-color"]),"icon-halo-color":new nl(sl.paint_symbol["icon-halo-color"]),"icon-halo-width":new nl(sl.paint_symbol["icon-halo-width"]),"icon-halo-blur":new nl(sl.paint_symbol["icon-halo-blur"]),"icon-translate":new il(sl.paint_symbol["icon-translate"]),"icon-translate-anchor":new il(sl.paint_symbol["icon-translate-anchor"]),"icon-image-cross-fade":new nl(sl.paint_symbol["icon-image-cross-fade"]),"text-opacity":new nl(sl.paint_symbol["text-opacity"]),"text-occlusion-opacity":new nl(sl.paint_symbol["text-occlusion-opacity"]),"text-color":new nl(sl.paint_symbol["text-color"],{runtimeType:Qn,getOverride:t=>t.textColor,hasOverride:t=>!!t.textColor}),"text-halo-color":new nl(sl.paint_symbol["text-halo-color"]),"text-halo-width":new nl(sl.paint_symbol["text-halo-width"]),"text-halo-blur":new nl(sl.paint_symbol["text-halo-blur"]),"text-translate":new il(sl.paint_symbol["text-translate"]),"text-translate-anchor":new il(sl.paint_symbol["text-translate-anchor"]),"icon-color-saturation":new il(sl.paint_symbol["icon-color-saturation"]),"icon-color-contrast":new il(sl.paint_symbol["icon-color-contrast"]),"icon-color-brightness-min":new il(sl.paint_symbol["icon-color-brightness-min"]),"icon-color-brightness-max":new il(sl.paint_symbol["icon-color-brightness-max"])}),layout:iv};class rv{constructor(t){this.type=t.property.overrides?t.property.overrides.runtimeType:Yn,this.defaultValue=t}evaluate(t){if(t.formattedSection){const e=this.defaultValue.property.overrides;if(e&&e.hasOverride(t.formattedSection))return e.getOverride(t.formattedSection)}return t.feature&&t.featureState?this.defaultValue.evaluate(t.feature,t.featureState):this.defaultValue.property.specification.default}eachChild(t){this.defaultValue.isConstant()||t(this.defaultValue.value._styleExpression.expression)}outputDefined(){return!1}serialize(){return null}}ba(rv,"FormatSectionOverride",{omit:["defaultValue"]});class ov extends Ml{constructor(e,i,n,r){super(e,nv,i,n,r),this._colorAdjustmentMatrix=t.ad.identity([]),this.hasInitialOcclusionOpacityProperties=void 0!==e.paint&&("icon-occlusion-opacity"in e.paint||"text-occlusion-opacity"in e.paint)}recalculate(t,e){super.recalculate(t,e),"auto"===this.layout.get("icon-rotation-alignment")&&(this.layout._values["icon-rotation-alignment"]="point"!==this.layout.get("symbol-placement")?"map":"viewport"),"auto"===this.layout.get("text-rotation-alignment")&&(this.layout._values["text-rotation-alignment"]="point"!==this.layout.get("symbol-placement")?"map":"viewport"),"auto"===this.layout.get("text-pitch-alignment")&&(this.layout._values["text-pitch-alignment"]=this.layout.get("text-rotation-alignment")),"auto"===this.layout.get("icon-pitch-alignment")&&(this.layout._values["icon-pitch-alignment"]=this.layout.get("icon-rotation-alignment"));const i=this.layout.get("text-writing-mode");if(i){const t=[];for(const e of i)t.indexOf(e)i in t?String(t[i]):""))}(e.properties,r)}createBucket(t){return new jg(t)}queryRadius(){return 0}queryIntersectsFeature(){return!1}_setPaintOverrides(){for(const t of nv.paint.overridableProperties){if(!ov.hasPaintOverride(this.layout,t))continue;const e=this.paint.get(t),i=new rv(e),n=new la(i,e.property.specification,this.scope,this.options);let r=null;r="constant"===e.value.kind||"source"===e.value.kind?new ua("source",n):new ha("composite",n,e.value.zoomStops,e.value._interpolationType),this.paint._values[t]=new tl(e.property,r,e.parameters)}}_handleOverridablePaintPropertyUpdate(t,e,i){return!(!this.layout||e.isDataDriven()||i.isDataDriven())&&ov.hasPaintOverride(this.layout,t)}static hasPaintOverride(t,e){const i=t.get("text-field"),n=nv.paint.properties[e];let r=!1;const o=t=>{for(const e of t)if(n.overrides&&n.overrides.hasOverride(e))return void(r=!0)};if("constant"===i.value.kind&&i.value.value instanceof pr)o(i.value.value.sections);else if("source"===i.value.kind){const t=e=>{r||(e instanceof vr&&gr(e.value)===nr?o(e.value.sections):e instanceof Tr?o(e.sections):e.eachChild(t))},e=i.value;e._styleExpression&&t(e._styleExpression.expression)}return r}getProgramIds(){const t=0!==this.paint.get("icon-opacity").constantOr(1),e=0!==this.paint.get("text-opacity").constantOr(1),i=[];return t&&i.push("symbolIcon"),e&&i.push("symbolSDF"),i}getDefaultProgramParams(t,e,i){return{config:new Wc(this,{zoom:e,lut:i}),overrideFog:!1}}}const sv=new ol({visibility:new il(sl.layout_background.visibility)});var av={paint:new ol({"background-color":new il(sl.paint_background["background-color"]),"background-pattern":new il(sl.paint_background["background-pattern"]),"background-opacity":new il(sl.paint_background["background-opacity"]),"background-emissive-strength":new il(sl.paint_background["background-emissive-strength"])}),layout:sv};const lv=new ol({visibility:new il(sl.layout_raster.visibility)});var cv={paint:new ol({"raster-opacity":new il(sl.paint_raster["raster-opacity"]),"raster-color":new rl(sl.paint_raster["raster-color"]),"raster-color-mix":new il(sl.paint_raster["raster-color-mix"]),"raster-color-range":new il(sl.paint_raster["raster-color-range"]),"raster-hue-rotate":new il(sl.paint_raster["raster-hue-rotate"]),"raster-brightness-min":new il(sl.paint_raster["raster-brightness-min"]),"raster-brightness-max":new il(sl.paint_raster["raster-brightness-max"]),"raster-saturation":new il(sl.paint_raster["raster-saturation"]),"raster-contrast":new il(sl.paint_raster["raster-contrast"]),"raster-resampling":new il(sl.paint_raster["raster-resampling"]),"raster-fade-duration":new il(sl.paint_raster["raster-fade-duration"]),"raster-emissive-strength":new il(sl.paint_raster["raster-emissive-strength"]),"raster-array-band":new il(sl.paint_raster["raster-array-band"]),"raster-elevation":new il(sl.paint_raster["raster-elevation"])}),layout:lv};function dv(e,i,n,r,o,s,a,l){const c=[e,i,1,n,r,1,o,s,1],d=[a,l,1],u=t.bC.adjoint([],c),[h,p,f]=t._.transformMat3(d,d,u);return t.bC.multiply(c,c,[h,0,0,0,p,0,0,0,f])}function uv(e,i,n,r,o,s,a,l){const c=function(e,i,n,r,o,s,a,l){const c=dv(0,0,1,0,1,1,0,1),d=dv(e,i,n,r,o,s,a,l),u=t.bC.adjoint([],c);return t.bC.multiply(d,d,u)}(e,i,n,r,o,s,a,l);return[c[2]/c[8]/uo,c[5]/c[8]/uo]}function hv(t){return[t[0],Math.min(Math.max(t[1],-Pd),Pd)]}class pv extends zn{constructor(t,e,i,n){super(),this.id=t,this.dispatcher=i,this.coordinates=e.coordinates,this.type="image",this.minzoom=0,this.maxzoom=22,this.tileSize=512,this.tiles={},this._loaded=!1,this.onNorthPole=!1,this.onSouthPole=!1,this.setEventedParent(n),this.options=e,this._dirty=!1}load(t,e){if(this._loaded=e||!1,this.fire(new Pn("dataloading",{dataType:"source"})),this.url=this.options.url,!this.url)return t&&(this.coordinates=t),this._loaded=!0,void this._finishLoading();this._imageRequest=an(this.map._requestManager.transformRequest(this.url,Ki.Image),((e,i)=>{this._imageRequest=null,this._loaded=!0,e?this.fire(new $n(e)):i&&(this.image=i instanceof HTMLImageElement?ki.getImageData(i):i,this._dirty=!0,this.width=this.image.width,this.height=this.image.height,t&&(this.coordinates=t),this._finishLoading())}))}loaded(){return this._loaded}updateImage(t){return t.url?(this._imageRequest&&t.url!==this.options.url&&(this._imageRequest.cancel(),this._imageRequest=null),this.options.url=t.url,this.load(t.coordinates,this._loaded),this):this}setTexture(t){if(!(t.handle instanceof WebGLTexture))throw new Error("The provided handle is not a WebGLTexture instance");return this.texture=new Gg(this.map.painter.context,t.handle),this.width=t.dimensions[0],this.height=t.dimensions[1],this._dirty=!1,this._loaded=!0,this._finishLoading(),this}_finishLoading(){this.map&&(this.setCoordinates(this.coordinates),this.fire(new Pn("data",{dataType:"source",sourceDataType:"metadata"})))}onAdd(t){this.map=t,this.load()}onRemove(t){this._imageRequest&&(this._imageRequest.cancel(),this._imageRequest=null),!this.texture||this.texture instanceof Gg||this.texture.destroy(),this.boundsBuffer&&(this.boundsBuffer.destroy(),this.elevatedGlobeVertexBuffer&&this.elevatedGlobeVertexBuffer.destroy(),this.elevatedGlobeIndexBuffer&&this.elevatedGlobeIndexBuffer.destroy())}setCoordinates(t){if(this.coordinates=t,this._boundsArray=void 0,this._unsupportedCoords=!1,!t.length)return this;this.onNorthPole=!1,this.onSouthPole=!1;let e=t[0][1],i=t[0][1];for(const n of t)n[1]>i&&(i=n[1]),n[1]Pd?this.onNorthPole=!0:n1&&(l-=1),new gd(s,l,Math.floor((i+r)/2*a))}(e),this.minzoom=this.maxzoom=this.tileID.z}return this.fire(new Pn("data",{dataType:"source",sourceDataType:"content"})),this}_clear(){this._boundsArray=void 0,this._unsupportedCoords=!1}_prepareData(e){for(const t in this.tiles){const e=this.tiles[t];"loaded"!==e.state&&(e.state="loaded",e.texture=this.texture)}if(this._boundsArray||this.onNorthPole||this.onSouthPole||this._unsupportedCoords)return;const i=eg(new gd(0,0,0),this.map.transform.projection),n=[i.projection.project(this.coordinates[0][0],this.coordinates[0][1]),i.projection.project(this.coordinates[1][0],this.coordinates[1][1]),i.projection.project(this.coordinates[2][0],this.coordinates[2][1]),i.projection.project(this.coordinates[3][0],this.coordinates[3][1])];if(!function(t){const e=t[1].x-t[0].x,i=t[1].y-t[0].y,n=t[2].x-t[1].x,r=t[2].y-t[1].y,o=t[3].x-t[2].x,s=t[3].y-t[2].y,a=t[0].x-t[3].x,l=t[0].y-t[3].y,c=e*r-n*i,d=n*s-o*r,u=o*l-a*s,h=a*i-e*l;return c>0&&d>0&&u>0&&h>0||c{const e=r.projection.project(t[0],t[1]);return ig(r,e)._round()}));this.perspectiveTransform=uv(o.x,o.y,s.x,s.y,a.x,a.y,l.x,l.y);const c=this._boundsArray=new Dl;c.emplaceBack(o.x,o.y,0,0),c.emplaceBack(s.x,s.y,uo,0),c.emplaceBack(l.x,l.y,0,uo),c.emplaceBack(a.x,a.y,uo,uo),this.boundsBuffer&&(this.boundsBuffer.destroy(),this.elevatedGlobeVertexBuffer&&this.elevatedGlobeVertexBuffer.destroy(),this.elevatedGlobeIndexBuffer&&this.elevatedGlobeIndexBuffer.destroy()),this.boundsBuffer=e.createVertexBuffer(c,Jg.members),this.boundsSegments=wc.simpleSegment(0,0,4,2);const d=[],u=function(t){return[hv(t[0]),hv(t[1]),hv(t[2]),hv(t[3])]}(this.coordinates),[h,p,f,m]=function(t){let e=t[0][0],i=e,n=t[0][1],r=n;for(let o=1;oi&&(i=t[o][0]),t[o][1]r&&(r=t[o][1]);return[e,n,i-e,r-n]}(u);{const r=new Dl,[o,s,a,l]=function(t){let e=t[0].x,i=e,n=t[0].y,r=n;for(let o=1;oi&&(i=t[o].x),t[o].yr&&(r=t[o].y);return[e,n,i-e,r-n]}(n),c=t=>[(t.x-o)/a,(t.y-s)/l],[u,_,g,y]=n.map(c),v=function(e,i,n,r,o,s,a,l){const c=dv(0,0,1,0,1,1,0,1),d=dv(e,i,n,r,o,s,a,l),u=t.bC.adjoint([],d);return t.bC.multiply(c,c,u)}(u[0],u[1],_[0],_[1],g[0],g[1],y[0],y[1]);this.elevatedGlobePerspectiveTransform=uv(u[0],u[1],_[0],_[1],g[0],g[1],y[0],y[1]);const x=(e,i)=>{d.push(e.lng);const n=Math.round((e.lng-h)/f*uo),o=Math.round((e.lat-p)/m*uo),s=c(i),a=t._.transformMat3([],[s[0],s[1],1],v),l=Math.round(a[0]/a[2]*uo),u=Math.round(a[1]/a[2]*uo);r.emplaceBack(n,o,l,u)},b=n[3].x-n[0].x,w=n[3].y-n[0].y,T=n[2].x-n[1].x,S=n[2].y-n[1].y;for(let t=0;t{i.emplaceBack(e,n,r);const o=d[e],s=d[n],a=d[r],l=Math.min(Math.min(o,s),a),c=Math.max(Math.max(o,s),a)-l;c>this.maxLongitudeTriangleSize&&(this.maxLongitudeTriangleSize=c),t.push(l+c/2)};for(let t=0;te));i.sort(((e,i)=>t[e]-t[i]));const n=[],r=new Kl;for(let o=0;o{o.segments.push({vertexOffset:0,primitiveOffset:t,vertexLength:e.segments[0].vertexLength,primitiveLength:i,sortKey:void 0,vaos:{}})},a=.51*this.maxLongitudeTriangleSize;if(Math.abs(i[0]-n)0){const n=function(e,i){const n=i.worldSize,r=Cd(1,0)*n*kd(i.center.lat,i.zoom)/Gu(n),o=Cd(1,i.center.lat)*n,s=t.ad.identity([]);return t.ad.rotateY(s,s,Ge(i.center.lng)),t.ad.rotateX(s,s,Ge(i.center.lat)),t.ad.translate(s,s,[0,0,ed]),t.ad.scale(s,s,[r,r,r*o]),t.ad.translate(s,s,[i.point.x-.5*n,i.point.y-.5*n,0]),t.ad.multiply(s,s,e),t.ad.multiply(s,i.globeMatrix,s)}(e,i);return function(e,i,n){const r=(e,i,n)=>{const r=t._.length(e),o=t._.length(i),s=ku(e,i,n);return t._.scale(s,s,1/t._.length(s)*Vn(r,o,n))},o=r([e[0],e[1],e[2]],[i[0],i[1],i[2]],n),s=r([e[4],e[5],e[6]],[i[4],i[5],i[6]],n),a=r([e[8],e[9],e[10]],[i[8],i[9],i[10]],n),l=ku([e[12],e[13],e[14]],[i[12],i[13],i[14]],n);return[o[0],o[1],o[2],0,s[0],s[1],s[2],0,a[0],a[1],a[2],0,l[0],l[1],l[2],1]}(o,n,r)}return o}function kv(t,e,i,n){const r=wu.projectAabbCorners(n,i);let o=Number.MAX_VALUE,s=-1;for(let t=0;tnew Ue(r[t][0],r[t][1]);let l;switch(s){case 0:case 6:l=[a(1),a(5),a(4),a(7),a(3),a(2),a(1)];break;case 1:case 7:l=[a(0),a(4),a(5),a(6),a(2),a(3),a(0)];break;case 3:case 5:l=[a(1),a(0),a(4),a(7),a(6),a(2),a(1)];break;default:l=[a(1),a(5),a(6),a(7),a(3),a(0),a(1)]}if(Yd(t,l))return o}const Dv=Ll([{name:"a_pos_3f",components:3,type:"Float32"}]),zv=Ll([{name:"a_color_3f",components:3,type:"Float32"}]),Rv=Ll([{name:"a_color_4f",components:4,type:"Float32"}]),Ov=Ll([{name:"a_uv_2f",components:2,type:"Float32"}]),Bv=Ll([{name:"a_normal_3f",components:3,type:"Float32"}]),Fv=Ll([{name:"a_normal_matrix0",components:4,type:"Float32"},{name:"a_normal_matrix1",components:4,type:"Float32"},{name:"a_normal_matrix2",components:4,type:"Float32"},{name:"a_normal_matrix3",components:4,type:"Float32"}]),Nv=Ll([{name:"a_pbr",components:4,type:"Uint16"},{name:"a_heightBasedEmissiveStrength",components:3,type:"Float32"}]);class Uv{constructor(t,e,i,n){this.message=(t?`${t}: `:"")+i,n&&(this.identifier=n),null!=e&&e.__line__&&(this.line=e.__line__)}}function jv(t,e){const i=-1===t.indexOf("://");try{return new URL(t,i&&e?"http://example.com":void 0),!0}catch(t){return!1}}class Vv{constructor(t,e){this.feature=t,this.instancedDataOffset=e,this.instancedDataCount=0,this.rotation=[0,0,0],this.scale=[1,1,1],this.translation=[0,0,0]}}class Gv{constructor(){this.instancedDataArray=new oc,this.instancesEvaluatedElevation=[],this.features=[],this.idToFeaturesIndex={}}}class Zv{constructor(t){this.zoom=t.zoom,this.canonical=t.canonical,this.layers=t.layers,this.layerIds=this.layers.map((t=>t.fqid)),this.projection=t.projection,this.index=t.index,this.hasZoomDependentProperties=this.layers[0].isZoomDependent(),this.stateDependentLayerIds=this.layers.filter((t=>t.isStateDependent())).map((t=>t.id)),this.hasPattern=!1,this.instancesPerModel={},this.validForExaggeration=0,this.maxVerticalOffset=0,this.maxScale=0,this.maxHeight=0,this.lookupDim=this.zoom>this.canonical.z?256:this.zoom>15?75:100,this.instanceCount=0,this.terrainElevationMin=0,this.terrainElevationMax=0,this.validForDEMTile={id:null,timestamp:0},this.modelUris=[],this.modelsRequested=!1,this.activeReplacements=[],this.replacementUpdateTime=0}updateFootprints(t,e){}populate(t,e,i,n){this.tileToMeter=zd(i);const r=this.layers[0]._featureFilter.needGeometry;this.lookup=new Uint8Array(this.lookupDim*this.lookupDim);for(const{feature:o,id:s,index:a,sourceLayerIndex:l}of t){const t=null!=s?s:o.properties&&o.properties.hasOwnProperty("id")?o.properties.id:void 0,c=Zd(o,r);if(!this.layers[0]._featureFilter.filter(new Ha(this.zoom),c,i))continue;const d={id:t,sourceLayerIndex:l,index:a,geometry:r?c.geometry:Gd(o,i,n),properties:o.properties,type:o.type,patterns:{}},u=this.addFeature(d,d.geometry,c);u&&e.featureIndex.insert(o,d.geometry,a,l,this.index,this.instancesPerModel[u].instancedDataArray.length,uo/32)}this.lookup=null}update(t,e,i,n){for(const e in this.instancesPerModel){const i=this.instancesPerModel[e];for(const e in t)i.idToFeaturesIndex.hasOwnProperty(e)&&(this.evaluate(i.features[i.idToFeaturesIndex[e]],t[e],i,!0),this.uploaded=!1)}this.maxHeight=0}updateZoomBasedPaintProperties(){if(!this.hasZoomDependentProperties)return!1;let e=!1;for(const i in this.instancesPerModel){const n=this.instancesPerModel[i];for(const i of n.features){const r=this.layers[0],o=i.feature,s=this.canonical,a=r.paint.get("model-rotation").evaluate(o,{},s),l=r.paint.get("model-scale").evaluate(o,{},s),c=r.paint.get("model-translation").evaluate(o,{},s);t._.exactEquals(i.rotation,a)&&t._.exactEquals(i.scale,l)&&t._.exactEquals(i.translation,c)||(this.evaluate(i,i.featureStates,n,!0),e=!0)}}return e}updateReplacement(t,e,i){if(e.updateTime===this.replacementUpdateTime)return!1;this.replacementUpdateTime=e.updateTime;const n=e.getReplacementRegionsForTile(t.toUnwrapped(),!0);if(Pp(this.activeReplacements,n))return!1;this.activeReplacements=n;let r=!1;for(const e in this.instancesPerModel){const n=this.instancesPerModel[e],o=n.instancedDataArray;for(const e of n.features){const n=e.instancedDataOffset,s=e.instancedDataCount;for(let e=0;euo?a-uo:a;const l=Math.floor(a),c=o.float32[s+1];let d=!1;for(const e of this.activeReplacements)if(!(e.orderl||l>e.max.x||e.min.y>c||c>e.max.y)&&(d=Op(Rp(l,c,t.canonical,e.footprintTileId.canonical),e),d))break;o.float32[s]=d?a+uo:a,r=r||d}}}return r}isEmpty(){for(const t in this.instancesPerModel)if(0!==this.instancesPerModel[t].instancedDataArray.length)return!1;return!0}uploadPending(){return!this.uploaded}upload(t){if(!this.uploaded)for(const e in this.instancesPerModel){const i=this.instancesPerModel[e];i.instancedDataArray.length=uo||e.y=uo)continue;const t=(this.lookupDim-1)/uo,i=this.lookupDim*(e.y*t|0)+e.x*t|0;if(this.lookup){if(0!==this.lookup[i])continue;this.lookup[i]=1}this.instanceCount++;const n=s.length;s.resize(n+1),o.instancesEvaluatedElevation.push(0),s.float32[16*n]=e.x,s.float32[16*n+1]=e.y}return a.instancedDataCount=o.instancedDataArray.length-a.instancedDataOffset,a.instancedDataCount>0&&(t.id&&(o.idToFeaturesIndex[t.id]=o.features.length),o.features.push(a),this.evaluate(a,{},o,!1)),r}getModelUris(){return this.modelUris}evaluate(t,e,i,n){const r=this.layers[0],o=t.feature,s=this.canonical,a=t.rotation=r.paint.get("model-rotation").evaluate(o,e,s),l=t.scale=r.paint.get("model-scale").evaluate(o,e,s),c=t.translation=r.paint.get("model-translation").evaluate(o,e,s),d=r.paint.get("model-color").evaluate(o,e,s);d.a=r.paint.get("model-color-mix-intensity").evaluate(o,e,s);const u=[];this.maxVerticalOffset10?this.tileToMeter:zd(s,p)),a[o+4]=c[0],a[o+5]=c[1],a[o+6]=c[2]+l,a[o+7]=u[0],a[o+8]=u[1],a[o+9]=u[2],a[o+10]=u[4],a[o+11]=u[5],a[o+12]=u[6],a[o+13]=u[8],a[o+14]=u[9],a[o+15]=u[10],i.instancesEvaluatedElevation[r]=c[2]}}}ba(Zv,"ModelBucket",{omit:["layers"]}),ba(Gv,"PerModelAttributes"),ba(Vv,"ModelFeature");const qv=new ol({visibility:new il(sl.layout_model.visibility),"model-id":new nl(sl.layout_model["model-id"])});var Hv={paint:new ol({"model-opacity":new il(sl.paint_model["model-opacity"]),"model-rotation":new nl(sl.paint_model["model-rotation"]),"model-scale":new nl(sl.paint_model["model-scale"]),"model-translation":new nl(sl.paint_model["model-translation"]),"model-color":new nl(sl.paint_model["model-color"]),"model-color-mix-intensity":new nl(sl.paint_model["model-color-mix-intensity"]),"model-type":new il(sl.paint_model["model-type"]),"model-cast-shadows":new il(sl.paint_model["model-cast-shadows"]),"model-receive-shadows":new il(sl.paint_model["model-receive-shadows"]),"model-ambient-occlusion-intensity":new il(sl.paint_model["model-ambient-occlusion-intensity"]),"model-emissive-strength":new nl(sl.paint_model["model-emissive-strength"]),"model-roughness":new nl(sl.paint_model["model-roughness"]),"model-height-based-emissive-strength-multiplier":new nl(sl.paint_model["model-height-based-emissive-strength-multiplier"]),"model-cutoff-fade-range":new il(sl.paint_model["model-cutoff-fade-range"]),"model-front-cutoff":new il(sl.paint_model["model-front-cutoff"])}),layout:qv};const Wv=64,Yv={CoordinateSpaceTile:1,CoordinateSpaceYUp:2,HasMapboxMeshFeatures:4,HasMeshoptCompression:8};function Xv(e,i,n,r,o,s,a,l,c,d=!1){const u=n.zoom,h=n.project(r),p=kd(r.lat,u),f=1/p;t.ad.identity(e),t.ad.translate(e,e,[h.x+a[0]*f,h.y+a[1]*f,a[2]]);let m=1,_=1;const g=n.worldSize;if(d){if("mercator"===n.projection.name){let e=0;n.elevation&&(e=n.elevation.getAtPointOrZero(new Rd(h.x/g,h.y/g),0));const i=t.aA.transformMat4([],[h.x,h.y,e,1],n.projMatrix)[3]/n.cameraToCenterDistance;m=i,_=i*kd(n.center.lat,u)}else if("globe"===n.projection.name){const i=$v(e,n),o=t.ad.multiply([],n.projMatrix,i),s=[0,0,0,1];t.aA.transformMat4(s,s,o);const a=s[3]/n.cameraToCenterDistance,l=Hu(u),c=n.projection.pixelsPerMeter(r.lat,g)*kd(r.lat,u),d=n.projection.pixelsPerMeter(n.center.lat,g)*kd(n.center.lat,u);m=a/Vn(c,$d(n.center.lat),l),_=a*p/c,m*=d,_*=d}}else m=f;t.ad.scale(e,e,[m,m,_]);const y=[...e],v=i.orientation,x=[];if(Lv(x,[v[0]+o[0],v[1]+o[1],v[2]+o[2]],s),t.ad.multiply(e,y,x),l&&n.elevation){let o=0;const s=[];if(c&&n.elevation){o=function(e,i,n,r,o){const s=i.elevation;if(!s)return 0;const a=wu.projectAabbCorners(n,r),l=Cd(1,o.lat)*i.worldSize,c=function(e,i){const n=[0,0,1],r=[{corners:[0,1,3,2],dotProductWithUp:0},{corners:[1,5,2,6],dotProductWithUp:0},{corners:[0,4,1,5],dotProductWithUp:0},{corners:[2,6,3,7],dotProductWithUp:0},{corners:[4,7,5,6],dotProductWithUp:0},{corners:[0,3,4,7],dotProductWithUp:0}];for(const o of r){const r=e[o.corners[0]],s=e[o.corners[1]],a=e[o.corners[2]],l=[s[0]-r[0],s[1]-r[1],i*(s[2]-r[2])],c=t._.cross(l,l,[a[0]-r[0],a[1]-r[1],i*(a[2]-r[2])]);t._.normalize(c,c),o.dotProductWithUp=t._.dot(c,n)}return r.sort(((t,e)=>t.dotProductWithUp-e.dotProductWithUp)),r[0].corners}(a,l),d=a[c[0]],u=a[c[1]],h=a[c[2]],p=a[c[3]],f=s.getAtPointOrZero(new Rd(d[0]/i.worldSize,d[1]/i.worldSize),0),m=s.getAtPointOrZero(new Rd(u[0]/i.worldSize,u[1]/i.worldSize),0),_=s.getAtPointOrZero(new Rd(h[0]/i.worldSize,h[1]/i.worldSize),0),g=s.getAtPointOrZero(new Rd(p[0]/i.worldSize,p[1]/i.worldSize),0),y=(f+g)/2,v=(m+_)/2;return y>v?m=e.gl.NEAREST_MIPMAP_NEAREST}),t.uploaded=!0,t.image=null)}function Jv(t,e,i){t.indexBuffer=e.createIndexBuffer(t.indexArray,!1,!0),t.vertexBuffer=e.createVertexBuffer(t.vertexArray,Dv.members,!1,!0),t.normalArray&&(t.normalBuffer=e.createVertexBuffer(t.normalArray,Bv.members,!1,!0)),t.texcoordArray&&(t.texcoordBuffer=e.createVertexBuffer(t.texcoordArray,Ov.members,!1,!0)),t.colorArray&&(t.colorBuffer=e.createVertexBuffer(t.colorArray,(12===t.colorArray.bytesPerElement?zv:Rv).members,!1,!0)),t.featureArray&&(t.pbrBuffer=e.createVertexBuffer(t.featureArray,Nv.members,!0)),t.segments=wc.simpleSegment(0,0,t.vertexArray.length,t.indexArray.length);const n=t.material;n.pbrMetallicRoughness.baseColorTexture&&Kv(n.pbrMetallicRoughness.baseColorTexture,e),n.pbrMetallicRoughness.metallicRoughnessTexture&&Kv(n.pbrMetallicRoughness.metallicRoughnessTexture,e),n.normalTexture&&Kv(n.normalTexture,e),n.occlusionTexture&&Kv(n.occlusionTexture,e,i),n.emissionTexture&&Kv(n.emissionTexture,e)}function Qv(t,e,i){if(t.meshes)for(const n of t.meshes)Jv(n,e,i);if(t.children)for(const n of t.children)Qv(n,e,i)}function tx(t){if(t.meshes)for(const e of t.meshes)e.indexArray.destroy(),e.vertexArray.destroy(),e.colorArray&&e.colorArray.destroy(),e.normalArray&&e.normalArray.destroy(),e.texcoordArray&&e.texcoordArray.destroy(),e.featureArray&&e.featureArray.destroy();if(t.children)for(const e of t.children)tx(e)}function ex(t){if(t.meshes)for(const i of t.meshes)i.vertexBuffer&&(i.vertexBuffer.destroy(),i.indexBuffer.destroy(),i.normalBuffer&&i.normalBuffer.destroy(),i.texcoordBuffer&&i.texcoordBuffer.destroy(),i.colorBuffer&&i.colorBuffer.destroy(),i.pbrBuffer&&i.pbrBuffer.destroy(),i.segments.destroy(),i.material&&((e=i.material).pbrMetallicRoughness.baseColorTexture&&e.pbrMetallicRoughness.baseColorTexture.gfxTexture&&e.pbrMetallicRoughness.baseColorTexture.gfxTexture.destroy(),e.pbrMetallicRoughness.metallicRoughnessTexture&&e.pbrMetallicRoughness.metallicRoughnessTexture.gfxTexture&&e.pbrMetallicRoughness.metallicRoughnessTexture.gfxTexture.destroy(),e.normalTexture&&e.normalTexture.gfxTexture&&e.normalTexture.gfxTexture.destroy(),e.emissionTexture&&e.emissionTexture.gfxTexture&&e.emissionTexture.gfxTexture.destroy(),e.occlusionTexture&&e.occlusionTexture.gfxTexture&&e.occlusionTexture.gfxTexture.destroy()));var e;if(t.children)for(const e of t.children)ex(e)}class ix{constructor(t){this._callback=t,this._triggered=!1,"undefined"!=typeof MessageChannel&&(this._channel=new MessageChannel,this._channel.port2.onmessage=()=>{this._triggered=!1,this._callback()})}trigger(){this._triggered||(this._triggered=!0,this._channel?this._channel.port1.postMessage(!0):setTimeout((()=>{this._triggered=!1,this._callback()}),0))}remove(){this._channel=void 0,this._callback=()=>{}}}class nx{constructor(){this.tasks={},this.taskQueue=[],ai(["process"],this),this.invoker=new ix(this.process),this.nextId=0}add(t,e){const i=this.nextId++,n=function({type:t,isSymbolTile:e,zoom:i}){return i=i||0,"message"===t?0:"maybePrepare"!==t||e?"parseTile"!==t||e?"parseTile"===t&&e?300-i:"maybePrepare"===t&&e?400-i:500:200-i:100-i}(e);if(0===n){try{t()}finally{}return null}return this.tasks[i]={fn:t,metadata:e,priority:n,id:i},this.taskQueue.push(i),this.invoker.trigger(),{cancel:()=>{delete this.tasks[i]}}}process(){try{if(this.taskQueue=this.taskQueue.filter((t=>!!this.tasks[t])),!this.taskQueue.length)return;const t=this.pick();if(null===t)return;const e=this.tasks[t];if(delete this.tasks[t],this.taskQueue.length&&this.invoker.trigger(),!e)return;e.fn()}finally{}}pick(){let t=null,e=1/0;for(let i=0;i{i&&delete this.callbacks[s],this.target.postMessage({id:s,type:"",targetMapId:n,sourceMapId:this.mapId})}}}receive(t){const e=t.data,i=e.id;if(i&&(!e.targetMapId||this.mapId===e.targetMapId))if(""===e.type){const t=this.cancelCallbacks[i];delete this.cancelCallbacks[i],t&&t.cancel()}else if(e.mustQueue||gi()){const t=this.callbacks[i],n=this.scheduler.add((()=>this.processTask(i,e)),t&&t.metadata||{type:"message"});n&&(this.cancelCallbacks[i]=n)}else this.processTask(i,e)}processTask(t,e){if(delete this.cancelCallbacks[t],""===e.type){const i=this.callbacks[t];delete this.callbacks[t],i&&(e.error?i(Ea(e.error)):i(null,Ea(e.data)))}else{const i=new Set,n=e.hasCallback?(e,n)=>{this.target.postMessage({id:t,type:"",sourceMapId:this.mapId,error:e?Sa(e):null,data:Sa(n,i)},i)}:t=>{},r=Ea(e.data);if(this.parent[e.type])this.parent[e.type](e.sourceMapId,r,n);else if(this.parent.getWorkerSource){const t=e.type.split(".");this.parent.getWorkerSource(e.sourceMapId,t[0],r.source,r.scope)[t[1]](r,n)}else n(new Error(`Could not find function ${e.type}`))}}remove(){this.scheduler.remove(),this.target.removeEventListener("message",this.receive,!1)}}class ox{constructor(t,e){this.workerPool=t,this.actors=[],this.currentActor=0,this.id=ni();const i=this.workerPool.acquire(this.id);for(let t=0;t{this.ready=!0}))}broadcast(t,e,i){Qe(this.actors,((i,n)=>{i.send(t,e,n)}),i=i||function(){})}getActor(){return this.currentActor=(this.currentActor+1)%this.actors.length,this.actors[this.currentActor]}remove(){this.actors.forEach((t=>{t.remove()})),this.actors=[],this.workerPool.release(this.id)}}ox.Actor=rx;var sx={workerUrl:"",workerClass:null,workerParams:void 0};function ax(){return null!=sx.workerClass?new sx.workerClass:new self.Worker(sx.workerUrl,sx.workerParams)}const lx="mapboxgl_preloaded_worker_pool";class cx{constructor(){this.active={}}acquire(t){if(!this.workers)for(this.workers=[];this.workers.length{t.terminate()})),this.workers=null)}isPreloaded(){return!!this.active[lx]}numActive(){return Object.keys(this.active).length}}let dx;function ux(){return dx||(dx=new cx),dx}cx.workerCount=2;let hx,px,fx,mx,_x,gx=null;function yx(){return gi()&&self.worker&&self.worker.dracoUrl?self.worker.dracoUrl:px||n.DRACO_URL}function vx(){if(gi()&&self.worker&&self.worker.meshoptUrl)return self.worker.meshoptUrl;if(mx)return mx;const t=new Uint8Array([0,97,115,109,1,0,0,0,1,4,1,96,0,0,3,3,2,0,0,5,3,1,0,1,12,1,0,10,22,2,12,0,65,0,65,0,65,0,252,10,0,0,11,7,0,65,0,253,15,26,11]);if("object"!=typeof WebAssembly)throw new Error("WebAssembly not supported, cannot instantiate meshoptimizer");return mx=WebAssembly.validate(t)?n.MESHOPT_SIMD_URL:n.MESHOPT_URL,mx}const xx={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},bx={5120:"DT_INT8",5121:"DT_UINT8",5122:"DT_INT16",5123:"DT_UINT16",5125:"DT_UINT32",5126:"DT_FLOAT32"},wx={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16};function Tx(t,e,i){const n=i.json.bufferViews.length,r=i.buffers.length;e.bufferView=n,i.json.bufferViews[n]={buffer:r,byteLength:t.byteLength},i.buffers[r]=t}const Sx="KHR_draco_mesh_compression";function Ex(t,e){const i=t.extensions&&t.extensions[Sx];if(!i)return;const n=new fx.Decoder,r=$x(e,i.bufferView),o=new fx.Mesh;if(!n.DecodeArrayToMesh(r,r.byteLength,o))throw new Error("Failed to decode Draco mesh");const s=e.json.accessors[t.indices],a=xx[s.componentType],l=s.count*a.BYTES_PER_ELEMENT,c=fx._malloc(l);a===Uint16Array?n.GetTrianglesUInt16Array(o,l,c):n.GetTrianglesUInt32Array(o,l,c),Tx(fx.memory.buffer.slice(c,c+l),s,e),fx._free(c);for(const r of Object.keys(i.attributes)){const s=n.GetAttributeByUniqueId(o,i.attributes[r]),a=e.json.accessors[t.attributes[r]],l=bx[a.componentType],c=a.count*wx[a.type]*xx[a.componentType].BYTES_PER_ELEMENT,d=fx._malloc(c);n.GetAttributeDataArrayForAllPoints(o,s,fx[l],c,d),Tx(fx.memory.buffer.slice(d,d+c),a,e),fx._free(d)}n.destroy(),o.destroy(),delete t.extensions[Sx]}const Mx="EXT_meshopt_compression";function Cx(t,e){if(!t.extensions||!t.extensions[Mx])return;const i=t.extensions[Mx],n=new Uint8Array(e.buffers[i.buffer],i.byteOffset||0,i.byteLength||0),r=new Uint8Array(i.count*i.byteStride);_x.decodeGltfBuffer(r,i.count,i.byteStride,n,i.mode,i.filter),t.buffer=e.buffers.length,t.byteOffset=0,e.buffers[t.buffer]=r.buffer,delete t.extensions[Mx]}const Ax=1179937895,Ix=new TextDecoder("utf8");function Lx(t,e){return new URL(t,e).href}function Px(t,e,i,n){return fetch(Lx(t.uri,n)).then((t=>t.arrayBuffer())).then((t=>{e.buffers[i]=t}))}function $x(t,e){const i=t.json.bufferViews[e];return new Uint8Array(t.buffers[i.buffer],i.byteOffset||0,i.byteLength)}function kx(t,e,i,n){if(t.uri){const r=Lx(t.uri,n);return fetch(r).then((t=>t.blob())).then((t=>createImageBitmap(t))).then((t=>{e.images[i]=t}))}if(void 0!==t.bufferView){const n=$x(e,t.bufferView),r=new Blob([n],{type:t.mimeType});return createImageBitmap(r).then((t=>{e.images[i]=t}))}}function Dx(t,e=0,i){const n={json:null,images:[],buffers:[]};if(new Uint32Array(t,e,1)[0]===Ax){const i=new Uint32Array(t,e);let r=2;const o=(i[r++]>>2)-3,s=i[r++]>>2;if(r++,n.json=JSON.parse(Ix.decode(i.subarray(r,r+s))),r+=s,r{const t=[],e=a&&a.includes(Sx),r=a&&a.includes(Mx);if(e&&t.push(function(){if(!fx)return hx||(hx=function(t){let e,i=null;function n(){e=new Uint8Array(i.buffer)}function r(){throw new Error("Unexpected Draco error.")}const o={a:{a:r,d:function(t,i,n){return e.copyWithin(t,i,i+n)},c:function(t){const r=e.length,o=Math.max(t>>>0,Math.ceil(1.2*r)),s=Math.ceil((o-r)/65536);try{return i.grow(s),n(),!0}catch(t){return!1}},b:r}};return(WebAssembly.instantiateStreaming?WebAssembly.instantiateStreaming(t,o):t.then((t=>t.arrayBuffer())).then((t=>WebAssembly.instantiate(t,o)))).then((t=>{const{Rb:r,Qb:o,P:s,T:a,X:l,Ja:c,La:d,Qa:u,Va:h,Wa:p,eb:f,jb:m,f:_,e:g,yb:y,zb:v,Ab:x,Bb:b,Db:w,Gb:T}=t.instance.exports;i=g;const S=(()=>{let t=0,i=0,n=0,s=0;return a=>{n&&(r(s),r(t),i+=n,n=t=0),t||(i+=128,t=o(i));const l=a.length+7&-8;let c=t;l>=i&&(n=l,c=s=o(l));for(let t=0;t{fx=t,hx=void 0})))}()),r&&t.push(function(){if(_x)return;const t=function(t){let e;const i=WebAssembly.instantiateStreaming(t,{}).then((t=>{e=t.instance,e.exports.__wasm_call_ctors()})),n={NONE:"",OCTAHEDRAL:"meshopt_decodeFilterOct",QUATERNION:"meshopt_decodeFilterQuat",EXPONENTIAL:"meshopt_decodeFilterExp"},r={ATTRIBUTES:"meshopt_decodeVertexBuffer",TRIANGLES:"meshopt_decodeIndexBuffer",INDICES:"meshopt_decodeIndexSequence"};return{ready:i,supported:!0,decodeGltfBuffer(t,i,o,s,a,l){!function(t,e,i,n,r,o,s){const a=t.exports.sbrk,l=n+3&-4,c=a(l*r),d=a(o.length),u=new Uint8Array(t.exports.memory.buffer);u.set(o,d);const h=e(c,n,r,d,o.length);if(0===h&&s&&s(c,l,r),i.set(u.subarray(c,c+n*r)),a(c-a(0)),0!==h)throw new Error(`Malformed buffer data: ${h}`)}(e,e.exports[r[a]],t,i,o,s,e.exports[n[l]])}}}(fetch(vx()));return t.ready.then((()=>{_x=t}))}()),o)for(let e=0;e{if(e&&s)for(const{primitives:t}of s)for(const e of t)Ex(e,n);if(r&&s&&l)for(const t of l)Cx(t,n);return n}))}))}function zx(t,e){const i=t.json.bufferViews[e.bufferView],n=xx[e.componentType];return new n(t.buffers[i.buffer],(e.byteOffset||0)+(i.byteOffset||0),e.count*(i.byteStride&&i.byteStride!==wx[e.type]*n.BYTES_PER_ELEMENT?i.byteStride/n.BYTES_PER_ELEMENT:wx[e.type]))}function Rx(t,e,i,n){const r=xx[e.componentType],o=function(t){switch(t){case Int8Array:return 1/127;case Uint8Array:return 1/255;case Int16Array:return 1/32767;case Uint16Array:return 1/65535;default:return 1}}(r),s=t.json.bufferViews[e.bufferView],a=s.byteStride?s.byteStride/r.BYTES_PER_ELEMENT:wx[e.type],l=i.float32,c=l.length/i.capacity;for(let t=0,i=0;t0){for(let r=0;r0){o.texcoordArray=new ic;const t=e.json.accessors[r.TEXCOORD_0];o.texcoordArray.resize(t.count);const i=zx(e,t);Rx(e,t,o.texcoordArray,i)}if(void 0!==r._FEATURE_ID_RGBA4444){const t=e.json.accessors[r._FEATURE_ID_RGBA4444];e.json.extensionsUsed&&e.json.extensionsUsed.includes("EXT_meshopt_compression")&&(o.featureData=zx(e,t))}void 0!==r._FEATURE_RGBA4444&&(o.featureData=new Uint32Array(zx(e,e.json.accessors[r._FEATURE_RGBA4444]).buffer));const u=t.material;return o.material=function(t,e){const{emissiveFactor:i=[0,0,0],alphaMode:n="OPAQUE",alphaCutoff:r=.5,normalTexture:o,occlusionTexture:s,emissiveTexture:a,doubleSided:l}=t,{baseColorFactor:c=[1,1,1,1],metallicFactor:d=1,roughnessFactor:u=1,baseColorTexture:h,metallicRoughnessTexture:p}=t.pbrMetallicRoughness||{},f=s?e[s.index]:void 0;if(s&&s.extensions&&s.extensions.KHR_texture_transform&&f){const t=s.extensions.KHR_texture_transform;f.offsetScale=[t.offset[0],t.offset[1],t.scale[0],t.scale[1]]}return{pbrMetallicRoughness:{baseColorFactor:new Un(...c),metallicFactor:d,roughnessFactor:u,baseColorTexture:h?e[h.index]:void 0,metallicRoughnessTexture:p?e[p.index]:void 0},doubleSided:l,emissiveFactor:i,alphaMode:n,alphaCutoff:r,normalTexture:o?e[o.index]:void 0,occlusionTexture:f,emissionTexture:a?e[a.index]:void 0,defined:void 0===t.defined}}(void 0!==u?e.json.materials[u]:{defined:!1},i),o}function Bx(e,i,n){const{matrix:r,rotation:o,translation:s,scale:a,mesh:l,extras:c,children:d}=e,u={};if(u.matrix=r||t.ad.fromRotationTranslationScale([],o||[0,0,0,1],s||[0,0,0],a||[1,1,1]),void 0!==l){u.meshes=n[l];const t=u.anchor=[0,0];for(const e of u.meshes){const{min:i,max:n}=e.aabb;t[0]+=i[0]+n[0],t[1]+=i[1]+n[1]}t[0]=Math.floor(t[0]/u.meshes.length/2),t[1]=Math.floor(t[1]/u.meshes.length/2)}if(c&&(c.id&&(u.id=c.id),c.lights&&(u.lights=function(t){if(!t.length)return[];const e=function(t){const e=atob(t),i=new Uint8Array(e.length);for(let t=0;t1&&n[n.length-1].equals(n[0])&&n.pop();let r=0;for(let t=0;t0&&n.reverse();const o=xh(n.flatMap((t=>[t.x,t.y])),[]);return 0===o.length?null:{vertices:n,indices:o}}function Ux(e,i){const n=[],r=[];let o=0;const s=[];for(const a of e){o=n.length;const e=a.vertexArray.float32,l=a.indexArray.uint16;for(let r=0;r0&&([r[t+1],r[t+2]]=[r[t+2],r[t+1]])}return{vertices:n,indices:r}}function jx(t){const e=function(t,e){const i=[],n=WebGL2RenderingContext;if(t.json.textures)for(const r of t.json.textures){const o={magFilter:n.LINEAR,minFilter:n.NEAREST,wrapS:n.REPEAT,wrapT:n.REPEAT};void 0!==r.sampler&&Object.assign(o,t.json.samplers[r.sampler]),i.push({image:e[r.source],sampler:o,uploaded:!1})}return i}(t,t.images),i=function(t,e){const i=[];for(const n of t.json.meshes){const r=[];for(const i of n.primitives)r.push(Ox(i,t,e));i.push(r)}return i}(t,e),{scenes:n,scene:r,nodes:o}=t.json,s=n?n[r||0].nodes:o,a=[];for(const e of s)a.push(Bx(o[e],t,i));return function(t,e,i){const n={},r=new Set;for(let o=0;o0){const e=Array.from(r.values()).sort(((t,e)=>t-e));for(let i=e.length-1;i>=0;i--)t.splice(e[i],1)}}(a,s,t.json.nodes),a}function Vx(t){t.heightmap=new Float32Array(4096),t.heightmap.fill(-1);const e=t.vertexArray.float32,i=t.aabb.min[0]-1,n=t.aabb.min[1]-1,r=Wv/(t.aabb.max[0]-i+2),o=Wv/(t.aabb.max[1]-n+2);for(let s=0;st.heightmap[c*Wv+l]&&(t.heightmap[c*Wv+l]=a)}}function Gx(e,i){const n={};n.indexArray=new Kl,n.indexArray.reserve(4*e.length),n.vertexArray=new Bl,n.vertexArray.reserve(10*e.length),n.colorArray=new Ol,n.vertexArray.reserve(10*e.length);let r=0;for(const o of e){const e=Math.min(10,Math.max(4,1.3*o.height))*i,s=[-o.normal[1],o.normal[0],0],a=Math.min(.29,.1*o.width/o.depth),l=o.width-2*o.depth*i*(a+.01),c=t._.scaleAndAdd([],o.pos,s,l/2),d=t._.scaleAndAdd([],o.pos,s,-l/2),u=[c[0],c[1],c[2]+o.height],h=[d[0],d[1],d[2]+o.height],p=t._.scaleAndAdd([],o.normal,s,a);t._.scale(p,p,e);const f=t._.scaleAndAdd([],o.normal,s,-a);t._.scale(f,f,e),t._.add(p,c,p),t._.add(f,d,f),c[2]+=.1,d[2]+=.1,n.vertexArray.emplaceBack(p[0],p[1],p[2]),n.vertexArray.emplaceBack(f[0],f[1],f[2]),n.vertexArray.emplaceBack(c[0],c[1],c[2]),n.vertexArray.emplaceBack(d[0],d[1],d[2]),n.vertexArray.emplaceBack(u[0],u[1],u[2]),n.vertexArray.emplaceBack(h[0],h[1],h[2]),n.vertexArray.emplaceBack(c[0],c[1],c[2]),n.vertexArray.emplaceBack(d[0],d[1],d[2]),n.vertexArray.emplaceBack(p[0],p[1],p[2]),n.vertexArray.emplaceBack(f[0],f[1],f[2]);const m=l/e/2;n.colorArray.emplaceBack(-m-a,-1,m,.8),n.colorArray.emplaceBack(m+a,-1,m,.8),n.colorArray.emplaceBack(-m,0,m,1.3),n.colorArray.emplaceBack(m,0,m,1.3),n.colorArray.emplaceBack(m+a,-.8,m,.7),n.colorArray.emplaceBack(m+a,-.8,m,.7),n.colorArray.emplaceBack(0,0,m,1.3),n.colorArray.emplaceBack(0,0,m,1.3),n.colorArray.emplaceBack(m+a,-1.2,m,.8),n.colorArray.emplaceBack(m+a,-1.2,m,.8),n.indexArray.emplaceBack(6+r,4+r,8+r),n.indexArray.emplaceBack(7+r,9+r,5+r),n.indexArray.emplaceBack(0+r,1+r,2+r),n.indexArray.emplaceBack(1+r,3+r,2+r),r+=10}const o={defined:!0,emissiveFactor:[0,0,0]},s={};return s.baseColorFactor=Un.white,o.pbrMetallicRoughness=s,n.material=o,n.aabb=new wu([1/0,1/0,1/0],[-1/0,-1/0,-1/0]),n}const Zx=new Float32Array(262144),qx=new Uint8Array(262144);function Hx(t){let e=0;if(t.meshes)for(const i of t.meshes)e=Math.max(e,i.aabb.max[2]);if(t.children)for(const i of t.children)e=Math.max(e,Hx(i));return e}function Wx(t,e,i){if(t.meshes)for(const n of t.meshes)n.aabb.min[0]!==1/0&&i.insert(e,n.aabb.min[0],n.aabb.min[1],n.aabb.max[0],n.aabb.max[1]);if(t.children)for(const n of t.children)Wx(n,e,i)}const Yx=["","wall","door","roof","window","lamp","logo"];class Xx{constructor(t){this.node=t,this.evaluatedRMEA=[[1,0,0,1],[1,0,0,1],[1,0,0,1],[1,0,0,1],[.4,1,0,1],[1,0,0,1],[1,0,0,1]],this.hiddenByReplacement=!1,this.evaluatedScale=[1,1,1],this.evaluatedColor=[],this.emissionHeightBasedParams=[],this.feature={type:"Point",id:t.id,geometry:[],properties:{height:Hx(t)}},this.aabb=this._getLocalBounds()}_getLocalBounds(){if(!this.node.meshes)return new wu([1/0,1/0,1/0],[-1/0,-1/0,-1/0]);if(!this.aabb){let t=0;const e=new wu([1/0,1/0,1/0],[-1/0,-1/0,-1/0]);for(const i of this.node.meshes)this.node.lightMeshIndex!==t&&(i.transformedAabb=wu.applyTransformFast(i.aabb,this.node.matrix),e.encapsulate(i.transformedAabb)),t++;this.aabb=e}return this.aabb}}class Kx{constructor(t,e,i,n,r,o){this.id=e,this.modelTraits|=Yv.CoordinateSpaceTile,this.uploaded=!1,this.hasPattern=!1,i&&(this.modelTraits|=Yv.HasMapboxMeshFeatures),n&&(this.modelTraits|=Yv.HasMeshoptCompression),this.zoom=-1,this.terrainExaggeration=1,this.projection={name:"mercator"},this.replacementUpdateTime=0,this.elevationReadFromZ=255,this.brightness=r,this.dirty=!0,this.needsUpload=!1,this.nodesInfo=[];for(const e of t)this.nodesInfo.push(new Xx(e)),Wx(e,o.featureIndexArray.length,o.grid),o.featureIndexArray.emplaceBack(this.nodesInfo.length-1,0,o.bucketLayerIDs.length-1,0)}updateFootprints(t,e){for(const i of this.getNodesInfo()){const n=i.node;n.footprint&&e.push({footprint:n.footprint,id:t})}}update(){console.log("Update 3D model bucket")}populate(){console.log("populate 3D model bucket")}uploadPending(){return!this.uploaded||this.needsUpload}upload(t){if(!this.needsUpload)return;const e=this.getNodesInfo();for(const i of e){const e=i.node;this.uploaded?this.updatePbrBuffer(e):Qv(e,t,!0)}for(const t of e)tx(t.node);this.uploaded=!0,this.needsUpload=!1}updatePbrBuffer(t){let e=!1;if(!t.meshes)return e;for(const i of t.meshes)i.pbrBuffer&&(i.pbrBuffer.updateData(i.featureArray),e=!0);return e}needsReEvaluation(t,e,i){const n=t.transform.projectionOptions,r=t.style.getBrightness(),o=this.brightness!==r;return!!(!this.uploaded||this.dirty||n.name!==this.projection.name||Jx(i.paint.get("model-color").value,o)||Jx(i.paint.get("model-color-mix-intensity").value,o)||Jx(i.paint.get("model-roughness").value,o)||Jx(i.paint.get("model-emissive-strength").value,o)||Jx(i.paint.get("model-height-based-emissive-strength-multiplier").value,o))&&(this.projection=n,this.brightness=r,!0)}evaluateScale(t,e){if(t.transform.zoom===this.zoom)return;this.zoom=t.transform.zoom;const i=this.getNodesInfo(),n=this.id.canonical;for(const t of i){const i=t.feature;t.evaluatedScale=e.paint.get("model-scale").evaluate(i,{},n)}}evaluate(t){const e=this.getNodesInfo();for(const i of e){if(!i.node.meshes)continue;const e=i.feature,n=i.node.meshes&&i.node.meshes[0].featureData,r=i.evaluatedColor[2],o=i.evaluatedRMEA[2],s=this.id.canonical;if(i.hasTranslucentParts=!1,n){for(let n=0;n=t)continue;const u=Zx[c],h=Math.abs(u);h>a&&(s=u,a=h,l=r,d=e)}if(a>.1){const o=1-(t+.5*Math.abs(l*d))/c;let a=e._dem.get(n,i)+s*o;const u=e._dem.get(n+l,i+d),h=e._dem.get(n-l,i-d,!0);(a-u)*(a-h)>0&&(a=(u+h)/2),Zx[r]=e._dem.set(n,i,a),qx[r]=t}}}}}s&&(e._demTile.needsDEMTextureUpload=!0,e._dem._timestamp=ki.now())}getNodesInfo(){return this.nodesInfo}destroy(){const t=this.getNodesInfo();for(const e of t)tx(e.node),ex(e.node)}isEmpty(){return!this.nodesInfo.length}updateReplacement(t,e){if(e.updateTime===this.replacementUpdateTime)return;this.replacementUpdateTime=e.updateTime;const i=e.getReplacementRegionsForTile(t.toUnwrapped()),n=this.getNodesInfo();for(let t=0;tt.footprint===e.footprint))}}getHeightAtTileCoord(e,i){const n=this.getNodesInfo(),r=[],o=[0,0,0],s=t.ad.identity([]);for(let a=0;ad.max[0]||i>d.max[1])continue;if(!0===l.node.hidden)return{height:0,maxHeight:l.feature.properties.height,hidden:!1,verticalScale:l.evaluatedScale[2]};t.ad.invert(s,l.node.matrix),o[0]=e,o[1]=i,t._.transformMat4(o,o,s);const u=(o[0]-c.aabb.min[0])/(c.aabb.max[0]-c.aabb.min[0])*Wv|0,h=Math.min(63,(o[1]-c.aabb.min[1])/(c.aabb.max[1]-c.aabb.min[1])*Wv|0)*Wv+Math.min(63,u),p=c.heightmap[h];if(!(p0)return{height:void 0,maxHeight:l.feature.properties.height,hidden:l.hiddenByReplacement,verticalScale:l.evaluatedScale[2]}}}}function Jx(t,e){return!t.isLightConstant&&e}function Qx(t,e,i,n,r,o,s,a){let l=(61440&e|(61440&e)>>4)>>8,c=(3840&e|(3840&e)>>4)>>4,d=240&e|(240&e)>>4;i[3]>0&&(l=Vn(l,255*i[0],i[3]),c=Vn(c,255*i[1],i[3]),d=Vn(d,255*i[2],i[3]));const u=l>16&65535,a=o?e>>16&65535:65535&e,l=(15&a)t.polygon)).flat());const g=f?l:null,[y,v]=function(e,i,n,r,o,s,a,l,c,d,u){return"globe"===e.projection.name?function(e,i,n,r,o,s,a,l,c,d,u){const h=[],p=[],f=e.projection.upVectorScale(u,e.center.lat,e.worldSize).metersToTile,m=[0,0,0,1],_=[0,0,0,1],g=(t,e,i,n)=>{t[0]=e,t[1]=i,t[2]=n,t[3]=1},y=Sf();n>0&&(n+=y),r+=y;for(const y of i){const i=[],v=[];for(const h of y){const p=h.x+o.x,y=h.y+o.y,x=e.projection.projectTilePoint(p,y,u),b=e.projection.upVector(u,h.x,h.y);let w=n,T=r;if(a){const t=Pf(p,y,n,r,a,l,c,d);w+=t.base,T+=t.top}0!==n?g(m,x.x+b[0]*f*w,x.y+b[1]*f*w,x.z+b[2]*f*w):g(m,x.x,x.y,x.z),g(_,x.x+b[0]*f*T,x.y+b[1]*f*T,x.z+b[2]*f*T),t._.transformMat4(m,m,s),t._.transformMat4(_,_,s),i.push(new Tp(m[0],m[1],m[2])),v.push(new Tp(_[0],_[1],_[2]))}h.push(i),p.push(v)}return[h,p]}(e,i,n,r,o,s,a,l,c,d,u):a?function(e,i,n,r,o,s,a,l,c){const d=[],u=[],h=[0,0,0,1];for(const p of e){const e=[],f=[];for(const d of p){const u=d.x+r.x,p=d.y+r.y,m=Pf(u,p,i,n,s,a,l,c);h[0]=u,h[1]=p,h[2]=m.base,h[3]=1,t.aA.transformMat4(h,h,o),h[3]=Math.max(h[3],1e-5);const _=new Tp(h[0]/h[3],h[1]/h[3],h[2]/h[3]);h[0]=u,h[1]=p,h[2]=m.top,h[3]=1,t.aA.transformMat4(h,h,o),h[3]=Math.max(h[3],1e-5);const g=new Tp(h[0]/h[3],h[1]/h[3],h[2]/h[3]);e.push(_),f.push(g)}d.push(e),u.push(f)}return[d,u]}(i,n,r,o,s,a,l,c,d):function(t,e,i,n,r){const o=[],s=[],a=r[8]*e,l=r[9]*e,c=r[10]*e,d=r[11]*e,u=r[8]*i,h=r[9]*i,p=r[10]*i,f=r[11]*i;for(const e of t){const t=[],i=[];for(const o of e){const e=o.x+n.x,s=o.y+n.y,m=r[0]*e+r[4]*s+r[12],_=r[1]*e+r[5]*s+r[13],g=r[2]*e+r[6]*s+r[14],y=r[3]*e+r[7]*s+r[15],v=m+a,x=_+l,b=g+c,w=Math.max(y+d,1e-5),T=m+u,S=_+h,E=g+p,M=Math.max(y+f,1e-5);t.push(new Tp(v/w,x/w,b/w)),i.push(new Tp(T/M,S/M,E/M))}o.push(t),s.push(i)}return[o,s]}(i,n,r,o,s)}(s,r,h,u,d,a,g,p,m,s.center.lat,e.tileID.canonical),x=e.queryGeometry;return function(t,e,i){let n=1/0;Kd(i,e)&&(n=Lf(i,e[0]));for(let r=0;r=3)for(let e=0;e>4;if(1!==n)throw new Error(`Got v${n} data when expected v1.`);const r=nb[15&i];if(!r)throw new Error("Unrecognized array type.");const[o]=new Uint16Array(t,2,1),[s]=new Uint32Array(t,4,1);return new rb(s,o,r,t)}constructor(t,e=64,i=Float64Array,n){if(isNaN(t)||t>1;return this.ids[i]=i,this.coords[this._pos++]=t,this.coords[this._pos++]=e,i}finish(){const t=this._pos>>1;if(t!==this.numItems)throw new Error(`Added ${t} items when expected ${this.numItems}.`);return ob(this.ids,this.coords,this.nodeSize,0,this.numItems-1,0),this._finished=!0,this}range(t,e,i,n){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");const{ids:r,coords:o,nodeSize:s}=this,a=[0,r.length-1,0],l=[];for(;a.length;){const c=a.pop()||0,d=a.pop()||0,u=a.pop()||0;if(d-u=t&&a=e&&c>1,p=o[2*h],f=o[2*h+1];p>=t&&p=e&&f=p:n>=f)&&(a.push(h+1),a.push(d),a.push(1-c))}return l}within(t,e,i){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");const{ids:n,coords:r,nodeSize:o}=this,s=[0,n.length-1,0],a=[],l=i*i;for(;s.length;){const c=s.pop()||0,d=s.pop()||0,u=s.pop()||0;if(d-u>1,p=r[2*h],f=r[2*h+1];cb(p,f,t,e)=p:e+i>=f)&&(s.push(h+1),s.push(d),s.push(1-c))}return a}}function ob(t,e,i,n,r,o){if(r-n>1;sb(t,e,s,n,r,o),ob(t,e,i,n,s-1,1-o),ob(t,e,i,s+1,r,1-o)}function sb(t,e,i,n,r,o){for(;r>n;){if(r-n>600){const s=r-n+1,a=i-n+1,l=Math.log(s),c=.5*Math.exp(2*l/3),d=.5*Math.sqrt(l*c*(s-c)/s)*(a-s/2s&&ab(t,e,n,r);as;)l--}e[2*n+o]===s?ab(t,e,n,l):(l++,ab(t,e,l,r)),lr&&(n+=(t[i]-r)*(t[i]-r)),e[i]0&&n[0]0&&n[1]0&&r[0]0&&r[1]0?Math.acos(i/n)*Ve:0;let o=0!==t||0!==e?Math.atan2(-e,-t)*Ve+90:0;return oNi&&(t.getActor().send("enforceCacheSizeLimit",Fi),Vi=0)},t.an=gn,t.ao=class{constructor(t){this.entries={},this.scheduler=t}request(t,e,i,n){const r=this.entries[t]=this.entries[t]||{callbacks:[]};if(r.result){const[t,i]=r.result;return this.scheduler?this.scheduler.add((()=>{n(t,i)}),e):n(t,i),()=>{}}return r.callbacks.push(n),r.cancel||(r.cancel=i(((i,n)=>{r.result=[i,n];for(const t of r.callbacks)this.scheduler?this.scheduler.add((()=>{t(i,n)}),e):t(i,n);setTimeout((()=>delete this.entries[t]),3e3)}))),()=>{r.result||(r.callbacks=r.callbacks.filter((t=>t!==n)),r.callbacks.length||(r.cancel(),delete this.entries[t]))}}},t.ap=function(t,e,i){const n=JSON.stringify(t.request);return t.data&&(this.deduped.entries[n]={result:[null,t.data]}),this.deduped.request(n,{type:"parseTile",isSymbolTile:t.isSymbolTile,zoom:t.tileZoom},(e=>{const n=en(t.request,((t,n,r,o)=>{t?e(t):n&&e(null,{vectorTile:i?void 0:new bp(new Lm(n)),rawData:n,cacheControl:r,expires:o})}));return()=>{n.cancel(),e()}}),e)},t.aq=Dc,t.ar=class extends Lc{constructor(t){super(t),this.current=Fc}set(t,e,i){if(this.fetchUniformLocation(t,e))for(let t=0;t({u_camera_to_center_distance:new $c(t),u_extrude_scale:new Uc(t),u_device_pixel_ratio:new $c(t),u_matrix:new Bc(t),u_inv_rot_matrix:new Bc(t),u_merc_center:new kc(t),u_tile_id:new Dc(t),u_zoom_transition:new $c(t),u_up_dir:new Dc(t),u_emissive_strength:new $c(t)}),t.bJ=t=>({u_matrix:new Bc(t),u_pixels_to_tile_units:new Uc(t),u_device_pixel_ratio:new $c(t),u_units_to_pixels:new kc(t),u_dash_image:new Pc(t),u_gradient_image:new Pc(t),u_image_height:new $c(t),u_texsize:new kc(t),u_tile_units_to_pixels:new $c(t),u_alpha_discard_threshold:new $c(t),u_trim_offset:new kc(t),u_trim_fade_range:new kc(t),u_trim_color:new zc(t),u_emissive_strength:new $c(t)}),t.bK=t=>({u_matrix:new Bc(t),u_texsize:new kc(t),u_pixels_to_tile_units:new Uc(t),u_device_pixel_ratio:new $c(t),u_image:new Pc(t),u_units_to_pixels:new kc(t),u_tile_units_to_pixels:new $c(t),u_alpha_discard_threshold:new $c(t),u_trim_offset:new kc(t)}),t.bL=Yl,t.bM=Hf,t.bN=Om,t.bO=jm,t.bP=G_,t.bQ=c_,t.bR=th,t.bS=(t,e,i,n,r,o)=>{const s=t.transform,a="globe"===s.projection.name;let l;if("map"===o.paint.get("circle-pitch-alignment"))if(a){const t=Zu(s.zoom,e.canonical)*s._pixelsPerMercatorPixel;l=Float32Array.from([t,0,0,t])}else l=s.calculatePixelsToTileUnitsMatrix(i);else l=new Float32Array([s.pixelsToGLUnits[0],0,0,s.pixelsToGLUnits[1]]);const c={u_camera_to_center_distance:t.transform.getCameraToCenterDistance(s.projection),u_matrix:t.translatePosMatrix(e.projMatrix,i,o.paint.get("circle-translate"),o.paint.get("circle-translate-anchor")),u_device_pixel_ratio:ki.devicePixelRatio,u_extrude_scale:l,u_inv_rot_matrix:Qu,u_merc_center:[0,0],u_tile_id:[0,0,0],u_zoom_transition:0,u_up_dir:[0,0,0],u_emissive_strength:o.paint.get("circle-emissive-strength")};if(a){c.u_inv_rot_matrix=n,c.u_merc_center=r,c.u_tile_id=[e.canonical.x,e.canonical.y,1{const s=t.transform;return{u_matrix:rm(t,e,i,n),u_texsize:e.imageAtlasTexture?e.imageAtlasTexture.size:[0,0],u_pixels_to_tile_units:s.calculatePixelsToTileUnitsMatrix(e),u_device_pixel_ratio:r,u_image:0,u_tile_units_to_pixels:nm(e,s),u_units_to_pixels:[1/s.pixelsToGLUnits[0],1/s.pixelsToGLUnits[1]],u_alpha_discard_threshold:0,u_trim_offset:o}},t.bV=(t,e,i,n,r,o,s)=>{const a=t.transform,l=a.calculatePixelsToTileUnitsMatrix(e);return{u_matrix:rm(t,e,i,n),u_pixels_to_tile_units:l,u_device_pixel_ratio:o,u_units_to_pixels:[1/a.pixelsToGLUnits[0],1/a.pixelsToGLUnits[1]],u_dash_image:0,u_gradient_image:1,u_image_height:r,u_texsize:sm(i)&&e.lineAtlasTexture?e.lineAtlasTexture.size:[0,0],u_tile_units_to_pixels:nm(e,t.transform),u_alpha_discard_threshold:0,u_trim_offset:s,u_trim_fade_range:i.paint.get("line-trim-fade-range"),u_trim_color:i.paint.get("line-trim-color").toRenderColor(i.lut).toArray01(),u_emissive_strength:i.paint.get("line-emissive-strength")}},t.bW=oi,t.bX=mh,t.bY=Sf,t.bZ=bd,t.b_=_f,t.ba=function(t,e,i){const n=Hu(i.zoom),r=t.style.map._antialias,o=e.options.extStandardDerivativesForceOff||t.terrain&&t.terrain.exaggeration()>0;return 0===n&&!r&&!o},t.bb=function(e){const i=e.pixelsPerMeter,n=i/Cd(1,e.center.lat),r=t.ad.identity(new Float64Array(16));return t.ad.translate(r,r,[e.point.x,e.point.y,0]),t.ad.scale(r,r,[n,n,i]),Float32Array.from(r)},t.bc=Ou,t.bd=function(t){const e=Pd-5;t=Xe(t,-e,e)/e*90;const i=Math.pow(Math.abs(Math.sin(Ge(t))),3);return Math.round(i*(sd.length-1))},t.be=function(e,i,n,r){const o=i.getNorth(),s=i.getSouth(),a=i.getWest(),l=i.getEast(),c=10){const e=180/r;t.bC.multiply(f,f,[e/d+1,0,0,0,e/u+1,0,-.5*e/h,.5*e/p,1])}return f[2]=c,f[5]=e.x,f[8]=e.y,f},t.bf=ju,t.bg=$u,t.bh=function(e,i,n){const r=t.ad.identity(new Float64Array(16)),o=(i/(1{}}},t.bo=Gg,t.bp=ai,t.bq=class{isDataAvailableAtPoint(t){const e=this._source();if(this.isUsingMockSource()||!e||t.y1)return!1;const i=e.getSource().maxzoom,n=11)return e;const r=n.getSource().maxzoom,o=1{const s=this.getAtTileOffset(e,o.x,o.y),a=r.upVector(e.canonical,o.x,o.y),l=r.upVectorScale(e.canonical,i,n).metersToTile;return t._.scale(a,a,s*l),a}}getForTilePoints(t,e,i,n){if(this.isUsingMockSource())return!1;const r=Xp.create(this,t,n);return!!r&&(e.forEach((t=>{t[2]=this.exaggeration()*r.getElevationAt(t[0],t[1],i)})),!0)}getMinMaxForTile(t){if(this.isUsingMockSource())return null;const e=this.findDEMTileFor(t);if(!e||!e.dem)return null;const i=e.dem.tree,n=e.tileID,r=1=0?t.slice(0,e):t},t.cV=function(t){return t.indexOf(wl)>=0},t.cW=function(t){const e=t.indexOf(wl);return e>=0?t.slice(e+1):""},t.cX=function(t){const e=[],i=t.id;return void 0===i&&e.push({message:`layers.${i}: missing required property "id"`}),void 0===t.render&&e.push({message:`layers.${i}: missing required method "render"`}),t.renderingMode&&"2d"!==t.renderingMode&&"3d"!==t.renderingMode&&e.push({message:`layers.${i}: property "renderingMode" must be either "2d" or "3d"`}),e},t.cY=function(t,e,i,n){return"custom"===t.type?new vv(t,e):new ib[t.type](t,e,i,n)},t.cZ=di,t.c_=Va,t.ca=1,t.cb=Ag,t.cc=0,t.cd=ec,t.ce=function(t,e,i,n,r){return Xe((t-e)/(i-e)*(r-n)+n,n,r)},t.cf=Ns,t.cg=kd,t.ch=class{constructor(t,e,i,n){this.context=t,this.format=n,this.size=i,this.texture=t.gl.createTexture();const[r,o,s]=this.size,{gl:a}=t;a.bindTexture(a.TEXTURE_3D,this.texture),t.pixelStoreUnpackFlipY.set(!1),t.pixelStoreUnpack.set(1),t.pixelStoreUnpackPremultiplyAlpha.set(!1);let l=this.format,c=a.UNSIGNED_BYTE;this.format===a.DEPTH_COMPONENT&&(l=a.DEPTH_COMPONENT16,c=a.UNSIGNED_SHORT),this.format===a.R8&&(n=a.RED),this.format===a.R32F&&(c=a.FLOAT,n=a.RED),a.texImage3D(a.TEXTURE_3D,0,l,r,o,s,0,n,c,e.data)}bind(t,e){const{context:i}=this,{gl:n}=i;n.bindTexture(n.TEXTURE_3D,this.texture),t!==this.minFilter&&(n.texParameteri(n.TEXTURE_3D,n.TEXTURE_MAG_FILTER,t),n.texParameteri(n.TEXTURE_3D,n.TEXTURE_MIN_FILTER,t),this.minFilter=t),e!==this.wrapS&&(n.texParameteri(n.TEXTURE_3D,n.TEXTURE_WRAP_S,e),n.texParameteri(n.TEXTURE_3D,n.TEXTURE_WRAP_T,e),this.wrapS=e)}destroy(){const{gl:t}=this.context;t.deleteTexture(this.texture),this.texture=null}},t.ci=$v,t.cj=[1,1,1],t.ck=Xp,t.cl=Yv,t.cm=ql,t.cn=ic,t.co=class{constructor(){this._updateTime=0,this._sourceIds=[],this._activeRegions=[],this._prevRegions=[],this._globalClipBounds={min:new Ue(1/0,1/0),max:new Ue(-1/0,-1/0)}}clear(){this._activeRegions.length>0&&++this._updateTime,this._activeRegions=[],this._prevRegions=[]}get updateTime(){return this._updateTime}getReplacementRegionsForTile(t,e=!1){const i=$p(new Ue(0,0),new Ue(uo,uo),t),n=[];if(e&&!Lp(i,this._globalClipBounds))return n;for(const e of this._activeRegions){if(e.hiddenByOverlap)continue;if(!Lp(i,e))continue;const r=kp(e.min,e.max,t);n.push({min:r.min,max:r.max,sourceId:this._sourceIds[e.priority],footprint:e.footprint,footprintTileId:e.tileId,order:e.order,clipMask:e.clipMask})}return n}setSources(t){this._setSources(t.map((t=>({getSourceId:()=>t.cache.id,getFootprints:()=>{const e=[];for(const i of t.cache.getVisibleCoordinates()){const n=t.cache.getTile(i).buckets[t.layer];n&&n.updateFootprints(i.toUnwrapped(),e)}return e},getOrder:()=>t.order,getClipMask:()=>t.clipMask}))))}_addSource(t){const e=t.getFootprints();if(0===e.length)return;const i=t.getOrder(),n=t.getClipMask();for(const t of e){if(!t.footprint)continue;const e=$p(t.footprint.min,t.footprint.max,t.id);this._activeRegions.push({min:e.min,max:e.max,hiddenByOverlap:!1,priority:this._sourceIds.length,tileId:t.id,footprint:t.footprint,order:i,clipMask:n})}this._sourceIds.push(t.getSourceId())}_computeReplacement(){this._activeRegions.sort(((t,e)=>t.priority-e.priority||Ap(t.min,e.min)||Ap(t.max,e.max)));let t=this._activeRegions.length!==this._prevRegions.length;if(!t){let e=0;for(;!t&&e!==this._activeRegions.length;){const i=this._activeRegions[e],n=this._prevRegions[e];t=i.priority!==n.priority||!Ip(i,n)||i.order!==n.order||i.clipMask!==n.clipMask,++e}}if(t){++this._updateTime;for(const t of this._activeRegions)t.order!==1/0&&(this._globalClipBounds.min.x=Math.min(this._globalClipBounds.min.x,t.min.x),this._globalClipBounds.min.y=Math.min(this._globalClipBounds.min.y,t.min.y),this._globalClipBounds.max.x=Math.max(this._globalClipBounds.max.x,t.max.x),this._globalClipBounds.max.y=Math.max(this._globalClipBounds.max.y,t.max.y));const t=t=>{const e=this._activeRegions;if(t>=e.length)return t;const i=e[t].priority;for(;t1){let e=0,i=t(e);for(;e!==i;){let n=e;const r=e;for(;n!==i;){const t=this._activeRegions[n];t.hiddenByOverlap=!1;for(let e=0;e=0;e--)this._addSource(t[e]);this._computeReplacement()}},t.cp=Dl,t.cq=Jg,t.cr=rc,t.cs=class{constructor(t){this._createGrid(t),this._createPoles(t)}destroy(){this._poleIndexBuffer.destroy(),this._gridBuffer.destroy(),this._gridIndexBuffer.destroy(),this._poleNorthVertexBuffer.destroy(),this._poleSouthVertexBuffer.destroy();for(const t of this._poleSegments)t.destroy();for(const t of this._gridSegments)t.withSkirts.destroy(),t.withoutSkirts.destroy()}_fillGridMeshWithLods(t,e){const i=new $l,n=new Kl,r=[],o=t+1+2,s=e[0]+1,a=e[0]+1+(1+e.length),l=(t,e,i)=>{let n=t===o-1?t-2:0===t?t:t-1;return n+=i?24575:0,[n,e]};for(let t=0;tt()))},t.dB=sx,t.dC=yx,t.dD=function(t){px=ki.resolveURL(t),gx||(gx=new ox(ux(),new zn)),gx.broadcast("setDracoUrl",px)},t.dE=vx,t.dF=function(t){mx=ki.resolveURL(t),gx||(gx=new ox(ux(),new zn)),gx.broadcast("setMeshoptUrl",mx)},t.dG=ti,t.dH=ba,t.dI=dh,t.dJ=I_,t.dK=eg,t.dL=dc,t.dM=am,t.dN=Dm,t.dO=Wf,t.dP=ci,t.dQ=E_,t.dR=jg,t.dS=function(t,e,i,n,r,o,s,a,l,c,d){t.createArrays(),t.tilePixelRatio=uo/(512*t.overscaling),t.compareText={},t.iconsNeedLinear=!1;const u=t.layers[0].layout,h=t.layers[0]._unevaluatedLayout._values,p={};if("composite"===t.textSizeData.kind){const{minZoom:e,maxZoom:i}=t.textSizeData;p.compositeTextSizes=[h["text-size"].possiblyEvaluate(new Ha(e),a),h["text-size"].possiblyEvaluate(new Ha(i),a)]}if("composite"===t.iconSizeData.kind){const{minZoom:e,maxZoom:i}=t.iconSizeData;p.compositeIconSizes=[h["icon-size"].possiblyEvaluate(new Ha(e),a),h["icon-size"].possiblyEvaluate(new Ha(i),a)]}p.layoutTextSize=h["text-size"].possiblyEvaluate(new Ha(l+1),a),p.layoutIconSize=h["icon-size"].possiblyEvaluate(new Ha(l+1),a),p.textMaxSize=h["text-size"].possiblyEvaluate(new Ha(18),a);const f="map"===u.get("text-rotation-alignment")&&"point"!==u.get("symbol-placement"),m=u.get("text-size");let _=!1;for(const e of t.features)if(e.icon&&e.icon.nameSecondary){_=!0;break}for(const o of t.features){const l=u.get("text-font").evaluate(o,{},a).join(","),h=m.evaluate(o,{},a),g=p.layoutTextSize.evaluate(o,{},a),y=(p.layoutIconSize.evaluate(o,{},a),{horizontal:{},vertical:void 0}),v=o.text;let x,b=[0,0];if(v){const n=v.toString(),s=u.get("text-letter-spacing").evaluate(o,{},a)*Om,c=u.get("text-line-height").evaluate(o,{},a)*Om,d=Aa(n)?s:0,p=u.get("text-anchor").evaluate(o,{},a),m=u.get("text-variable-anchor");if(!m){const t=u.get("text-radial-offset").evaluate(o,{},a);b=t?G_(p,[t*Om,j_]):u.get("text-offset").evaluate(o,{},a).map((t=>t*Om))}let _=f?"center":u.get("text-justify").evaluate(o,{},a);const x="point"===u.get("symbol-placement"),w=x?u.get("text-max-width").evaluate(o,{},a)*Om:1/0,T=o=>{t.allowVerticalPlacement&&Ca(n)&&(y.vertical=e_(v,e,i,r,l,w,c,p,o,d,b,Jm.vertical,!0,g,h))};if(!f&&m){const t="auto"===_?m.map((t=>Z_(t))):[_];let n=!1;for(let o=0;o=0||!Ca(n)){const t=e_(v,e,i,r,l,w,c,p,_,d,b,Jm.horizontal,!1,g,h);t&&(y.horizontal[_]=t)}T(x?"left":_)}}let w=!1;if(o.icon&&o.icon.namePrimary){const e=n[o.icon.namePrimary];e&&(x=u_(r[o.icon.namePrimary],o.icon.nameSecondary?r[o.icon.nameSecondary]:void 0,u.get("icon-offset").evaluate(o,{},a),u.get("icon-anchor").evaluate(o,{},a)),w=e.sdf,void 0===t.sdfIcons?t.sdfIcons=e.sdf:t.sdfIcons!==e.sdf&&pi("Style sheet warning: Cannot mix SDF and non-SDF icons in one buffer"),(e.pixelRatio!==t.pixelRatio||0!==u.get("icon-rotate").constantOr(1))&&(t.iconsNeedLinear=!0))}const T=X_(y.horizontal)||y.vertical;t.iconsInText||(t.iconsInText=!!T&&T.iconsInText),(T||x)&&q_(t,o,y,x,n,p,g,0,b,w,s,a,c,d,_)}o&&t.generateCollisionDebugBuffers(l,t.collisionBoxArray)},t.dT=Jf,t.dU=Yh,t.dV=bp,t.dW=Lm,t.dX=Yp,t.dY=Zy,t.dZ=wp,t.d_=cp,t.da=Wu,t.db=function(e){const i=[0,0,0],n=t.ad.identity(new Float64Array(16));return t.ad.multiply(n,e.pixelMatrix,e.globeMatrix),t._.transformMat4(i,i,n),new Ue(i[0],i[1])},t.dc=d,t.dd=c,t.de=function(t){const e=t.navigator?t.navigator.userAgent:null;return!!function(t){if(null==Ei){const e=t.navigator?t.navigator.userAgent:null;Ei=!!t.safari||!(!e||!(/\b(iPad|iPhone|iPod)\b/.test(e)||e.match("Safari")&&!e.match("Chrome")))}return Ei}(t)&&e&&(e.match("Version/15.4")||e.match("Version/15.5")||e.match(/CPU (OS|iPhone OS) (15_4|15_5) like Mac OS X/))},t.df=ni,t.dg=class{constructor(t,e,i){this._transformRequestFn=t,this._customAccessToken=e,this._silenceAuthErrors=!!i,this._createSkuToken()}_createSkuToken(){const t=function(){let t="";for(let e=0;ethis._skuTokenExpiresAt}transformRequest(t,e){return this._transformRequestFn&&this._transformRequestFn(t,e)||{url:t}}normalizeStyleURL(t,i){if(!o(t))return t;const n=un(t);return n.params.push(`sdk=js-${e}`),n.path=`/styles/v1${n.path}`,this._makeAPIURL(n,this._customAccessToken||i)}normalizeGlyphsURL(t,e){if(!o(t))return t;const i=un(t);return i.path=`/fonts/v1${i.path}`,this._makeAPIURL(i,this._customAccessToken||e)}normalizeModelURL(t,e){if(!o(t))return t;const i=un(t);return i.path=`/models/v1${i.path}`,this._makeAPIURL(i,this._customAccessToken||e)}normalizeSourceURL(t,e,i,n){if(!o(t))return t;const r=un(t);return r.path=`/v4/${r.authority}.json`,r.params.push("secure"),i&&r.params.push(`language=${i}`),n&&r.params.push(`worldview=${n}`),this._makeAPIURL(r,this._customAccessToken||e)}normalizeSpriteURL(t,e,i,n){const r=un(t);return o(t)?(r.path=`/styles/v1${r.path}/sprite${e}${i}`,this._makeAPIURL(r,this._customAccessToken||n)):(r.path+=`${e}${i}`,hn(r))}normalizeTileURL(t,e,i){if(this._isSkuTokenExpired()&&this._createSkuToken(),t&&!o(t))return t;const r=un(t);r.path=r.path.replace(/(\.(png|jpg)\d*)(?=$)/,`${e||i&&"raster"!==r.authority&&512===i?"@2x":""}${Gi.supported?".webp":"$1"}`),"raster"===r.authority?r.path=`/${n.RASTER_URL_PREFIX}${r.path}`:"rasterarrays"===r.authority?r.path=`/${n.RASTERARRAYS_URL_PREFIX}${r.path}`:"3dtiles"===r.authority?r.path=`/${n.TILES3D_URL_PREFIX}${r.path}`:(r.path=r.path.replace(/^.+\/v4\//,"/"),r.path=`/${n.TILE_URL_VERSION}${r.path}`);const s=this._customAccessToken||function(t){for(const e of t){const t=e.match(/^access_token=(.*)$/);if(t)return t[1]}return null}(r.params)||n.ACCESS_TOKEN;return n.REQUIRE_ACCESS_TOKEN&&s&&this._skuToken&&r.params.push(`sku=${this._skuToken}`),this._makeAPIURL(r,s)}canonicalizeTileURL(t,e){const i=un(t);if(!i.path.match(/^(\/v4\/|\/(raster|rasterarrays)\/v1\/)/)||!i.path.match(/\.[\w]+$/))return t;let r="mapbox://";i.path.match(/^\/raster\/v1\//)?r+=`raster/${i.path.replace(`/${n.RASTER_URL_PREFIX}/`,"")}`:i.path.match(/^\/rasterarrays\/v1\//)?r+=`rasterarrays/${i.path.replace(`/${n.RASTERARRAYS_URL_PREFIX}/`,"")}`:r+=`tiles/${i.path.replace(`/${n.TILE_URL_VERSION}/`,"")}`;let o=i.params;return e&&(o=o.filter((t=>!t.match(/^access_token=/)))),o.length&&(r+=`?${o.join("&")}`),r}canonicalizeTileset(t,e){const i=!!e&&o(e),n=[];for(const e of t.tiles||[])r(e)?n.push(this.canonicalizeTileURL(e,i)):n.push(e);return n}_makeAPIURL(t,e){const i="See https://docs.mapbox.com/api/overview/#access-tokens-and-token-scopes",r=un(n.API_URL);if(t.protocol=r.protocol,t.authority=r.authority,"http"===t.protocol){const e=t.params.indexOf("secure");e>=0&&t.params.splice(e,1)}if("/"!==r.path&&(t.path=`${r.path}${t.path}`),!n.REQUIRE_ACCESS_TOKEN)return hn(t);if(e=e||n.ACCESS_TOKEN,!this._silenceAuthErrors){if(!e)throw new Error(`An API access token is required to use Mapbox GL. ${i}`);if("s"===e[0])throw new Error(`Use a public access token (pk.*) with Mapbox GL, not a secret access token (sk.*). ${i}`)}return t.params=t.params.filter((t=>-1===t.indexOf("access_token"))),t.params.push(`access_token=${e||""}`),hn(t)}},t.dh=function(t,e){e?Mn.add(t):Mn.delete(t)},t.di=Gi,t.dj=Tn,t.dk=En,t.dl=cn,t.dm=vn,t.dn=bn,t.dp=function(t){Mn.delete(t)},t.dq=Sn,t.dr=yn,t.ds=Qe,t.dt=e,t.du=function(t,e){Fi=t,Ni=e},t.dv=function(t,e,i=!1){if(Fa===za||Fa===Ra||Fa===Oa)throw new Error("setRTLTextPlugin cannot be called multiple times.");Na=ki.resolveURL(t),Fa=za,Ba=e,ja(),i||Za()},t.dw=Ga,t.dx=function(){ux().acquire(lx)},t.dy=function(){const t=dx;t&&(t.isPreloaded()&&1===t.numActive()?(t.release(lx),dx=null):console.warn("Could not clear WebWorkers since there are active Map instances that still reference it. The pre-warmed WebWorker pool can only be cleared when all map instances have been removed with map.remove()"))},t.dz=cx,t.e=ki,t.e0=cm,t.e1=h,t.e2=en,t.e3=function(t){let e=0;if(new Uint32Array(t,0,1)[0]!==Ax){const i=new Uint32Array(t,0,7),[,,n,r,o,s]=i;e=i.byteLength+r+o+s+o,(n!==t.byteLength||e>=t.byteLength)&&pi("Invalid b3dm header information.")}return Dx(t,e)},t.e4=function(t,e){const i=jx(t);for(const t of i){for(const e of t.meshes)Vx(e);t.lights&&(t.lightMeshIndex=t.meshes.length,t.meshes.push(Gx(t.lights,e)))}return i},t.e5=Kx,t.e6=rx,t.e7=qa,t.e8=function(t){ji(),Oi&&Oi.then((e=>{e.keys().then((i=>{for(let n=0;nt.arrayBuffer())).then((e=>Dx(e,0,t)))},t.m=class extends Uv{},t.n=Er,t.o=qn,t.p=Qg,t.q=Xs,t.r=Js,t.s=Qs,t.t=ca,t.u=al,t.v=ll,t.w=pi,t.x=pa,t.y=da,t.z=qo})),n(0,(function(t){function e(t){const e=t?t.url.toString():void 0;return e?performance.getEntriesByName(e):[]}function i(t){if("number"==typeof t||"boolean"==typeof t||"string"==typeof t||null==t)return JSON.stringify(t);if(Array.isArray(t)){let e="[";for(const n of t)e+=`${i(n)},`;return`${e}]`}let e="{";for(const n of Object.keys(t).sort())e+=`${n}:${i(t[n])},`;return`${e}}`}function n(e){let n="";for(const r of t.cE)n+=`/${i(e[r])}`;return n}class r{constructor(t){this.keyCache={},this._layers={},this._layerConfigs={},t&&this.replace(t)}replace(t,e){this._layerConfigs={},this._layers={},this.update(t,[],e)}update(e,i,r){this._options=r;for(const i of e)this._layerConfigs[i.id]=i,(this._layers[i.id]=t.cY(i,this.scope,null,this._options)).compileFilter(),this.keyCache[i.id]&&delete this.keyCache[i.id];for(const t of i)delete this.keyCache[t],delete this._layerConfigs[t],delete this._layers[t];this.familiesBySource={};const o=function(t,e){const i={};for(let r=0;rthis._layers[t.id])),i=e[0];if("none"===i.visibility)continue;const n=i.source||"";let r=this.familiesBySource[n];r||(r=this.familiesBySource[n]={});const o=i.sourceLayer||"_geojsonTileLayer";let s=r[o];s||(s=r[o]=[]),s.push(e)}}}const o=1*t.dJ;class s{constructor(e){const i={},n=[];for(const t in e){const r=e[t],s=i[t]={};for(const t in r.glyphs){const e=r.glyphs[+t];if(!e||0===e.bitmap.width||0===e.bitmap.height)continue;const i=e.metrics.localGlyph?o:1,a={x:0,y:0,w:e.bitmap.width+2*i,h:e.bitmap.height+2*i};n.push(a),s[t]=a}}const{w:r,h:s}=t.j(n),a=new t.dI({width:r||1,height:s||1});for(const n in e){const r=e[n];for(const e in r.glyphs){const s=r.glyphs[+e];if(!s||0===s.bitmap.width||0===s.bitmap.height)continue;const l=i[n][e],c=s.metrics.localGlyph?o:1;t.dI.copy(s.bitmap,a,{x:0,y:0},{x:l.x+c,y:l.y+c},s.bitmap)}}this.image=a,this.positions=i}}t.dH(s,"GlyphAtlas");class a{constructor(e){this.tileID=new t.aL(e.tileID.overscaledZ,e.tileID.wrap,e.tileID.canonical.z,e.tileID.canonical.x,e.tileID.canonical.y),this.tileZoom=e.tileZoom,this.uid=e.uid,this.zoom=e.zoom,this.lut=e.lut,this.canonical=e.tileID.canonical,this.pixelRatio=e.pixelRatio,this.tileSize=e.tileSize,this.source=e.source,this.scope=e.scope,this.overscaling=this.tileID.overscaleFactor(),this.showCollisionBoxes=e.showCollisionBoxes,this.collectResourceTiming=!!e.collectResourceTiming,this.promoteId=e.promoteId,this.isSymbolTile=e.isSymbolTile,this.tileTransform=t.dK(e.tileID.canonical,e.projection),this.projection=e.projection,this.brightness=e.brightness,this.extraShadowCaster=!!e.extraShadowCaster,this.tessellationStep=e.tessellationStep}parse(e,i,n,r,o){this.status="parsing",this.data=e,this.collisionBoxArray=new t.dL;const a=new t.dM(Object.keys(e.layers).sort()),c=new t.dN(this.tileID,this.promoteId);c.bucketLayerIDs=[];const d={},u=new t.dO(256,256),h={featureIndex:c,iconDependencies:{},patternDependencies:{},glyphDependencies:{},lineAtlas:u,availableImages:n,brightness:this.brightness},p=i.familiesBySource[this.source];for(const i in p){const r=e.layers[i];if(!r)continue;let o=!1,s=!1,u=!1;for(const t of p[i])"symbol"===t[0].type?o=!0:s=!0,t[0].is3D()&&"model"!==t[0].type&&(u=!0);if(this.extraShadowCaster&&!u)continue;if(!0===this.isSymbolTile&&!o)continue;if(!1===this.isSymbolTile&&!s)continue;1===r.version&&t.w(`Vector tile source "${this.source}" layer "${i}" does not use vector tile spec v2 and therefore may have some rendering errors.`);const f=a.encode(i),m=[];for(let t=0;t=e.maxzoom||"none"!==e.visibility&&(l(t,this.zoom,h.brightness,n),(d[e.id]=e.createBucket({index:c.bucketLayerIDs.length,layers:t,zoom:this.zoom,lut:this.lut,canonical:this.canonical,pixelRatio:this.pixelRatio,overscaling:this.overscaling,collisionBoxArray:this.collisionBoxArray,sourceLayerIndex:f,sourceID:this.source,projection:this.projection.spec,tessellationStep:this.tessellationStep})).populate(m,h,this.tileID.canonical,this.tileTransform),c.bucketLayerIDs.push(t.map((t=>t.id)))))}}let f,m,_,g;u.trim();const y={type:"maybePrepare",isSymbolTile:this.isSymbolTile,zoom:this.zoom},v=()=>{if(f)return this.status="done",o(f);if(this.extraShadowCaster)this.status="done",o(null,{buckets:t.dG(d).filter((t=>!t.isEmpty())),featureIndex:c,collisionBoxArray:null,glyphAtlasImage:null,lineAtlas:null,imageAtlas:null,brightness:h.brightness,glyphMap:null,iconMap:null,glyphPositions:null});else if(m&&_&&g){const e=new s(m),i=new t.dQ(_,g,this.lut);for(const r in d){const o=d[r];o instanceof t.dR?(l(o.layers,this.zoom,h.brightness,n),t.dS(o,m,e.positions,_,i.iconPositions,this.showCollisionBoxes,n,this.tileID.canonical,this.tileZoom,this.projection,this.brightness)):o.hasPattern&&(o instanceof t.dT||o instanceof t.dU||o instanceof t.b_)&&(l(o.layers,this.zoom,h.brightness,n),o.addFeatures(h,this.tileID.canonical,i.patternPositions,n,this.tileTransform,this.brightness))}this.status="done",o(null,{buckets:t.dG(d).filter((t=>!t.isEmpty())),featureIndex:c,collisionBoxArray:this.collisionBoxArray,glyphAtlasImage:e.image,lineAtlas:u,imageAtlas:i,brightness:h.brightness})}};if(!this.extraShadowCaster){const e=t.dP(h.glyphDependencies,(t=>Object.keys(t).map(Number)));Object.keys(e).length?r.send("getGlyphs",{uid:this.uid,stacks:e,scope:this.scope},((t,e)=>{f||(f=t,m=e,v())}),void 0,!1,y):m={};const i=Object.keys(h.iconDependencies);i.length?r.send("getImages",{icons:i,source:this.source,scope:this.scope,tileID:this.tileID,type:"icons"},((t,e)=>{f||(f=t,_=e,v())}),void 0,!1,y):_={};const n=Object.keys(h.patternDependencies);n.length?r.send("getImages",{icons:n,source:this.source,scope:this.scope,tileID:this.tileID,type:"patterns"},((t,e)=>{f||(f=t,g=e,v())}),void 0,!1,y):g={}}v()}}function l(e,i,n,r){const o=new t.X(i,{brightness:n});for(const t of e)t.recalculate(o,r)}class c extends t.E{constructor(e,i,n,r,o,s){super(),this.actor=e,this.layerIndex=i,this.availableImages=n,this.loadVectorData=o||t.ap,this.loading={},this.loaded={},this.deduped=new t.ao(e.scheduler),this.isSpriteLoaded=r,this.scheduler=e.scheduler,this.brightness=s}loadTile(i,n){const r=i.uid,o=i&&i.request,s=o&&o.collectResourceTiming,l=this.loading[r]=new a(i);l.abort=this.loadVectorData(i,((a,c)=>{const d=!this.loading[r];if(delete this.loading[r],d||a||!c)return l.status="done",d||(this.loaded[r]=l),n(a);const u=c.rawData,h={};c.expires&&(h.expires=c.expires),c.cacheControl&&(h.cacheControl=c.cacheControl),l.vectorTile=c.vectorTile||new t.dV(new t.dW(u));const p=()=>{l.parse(l.vectorTile,this.layerIndex,this.availableImages,this.actor,((i,r)=>{if(i||!r)return n(i);const a={};if(s){const t=e(o);t.length>0&&(a.resourceTiming=JSON.parse(JSON.stringify(t)))}n(null,t.W({rawTileData:u.slice(0)},r,h,a))}))};this.isSpriteLoaded?p():this.once("isSpriteLoaded",(()=>{this.scheduler?this.scheduler.add(p,{type:"parseTile",isSymbolTile:i.isSymbolTile,zoom:i.tileZoom}):p()})),this.loaded=this.loaded||{},this.loaded[r]=l}))}reloadTile(e,i){const n=this.loaded,r=e.uid;if(n&&n[r]){const o=n[r];o.showCollisionBoxes=e.showCollisionBoxes,o.projection=e.projection,o.brightness=e.brightness,o.tileTransform=t.dK(e.tileID.canonical,e.projection),o.extraShadowCaster=e.extraShadowCaster,o.lut=e.lut;const s=(t,e)=>{const n=o.reloadCallback;n&&(delete o.reloadCallback,o.parse(o.vectorTile,this.layerIndex,this.availableImages,this.actor,n)),i(t,e)};"parsing"===o.status?o.reloadCallback=s:"done"===o.status&&(o.vectorTile?o.parse(o.vectorTile,this.layerIndex,this.availableImages,this.actor,s):s())}else i(null,void 0)}abortTile(t,e){const i=t.uid,n=this.loading[i];n&&(n.abort&&n.abort(),delete this.loading[i]),e()}removeTile(t,e){const i=this.loaded,n=t.uid;i&&i[n]&&delete i[n],e()}}class d{loadTile(e,i){const{uid:n,encoding:r,rawImageData:o,padding:s}=e,a=ImageBitmap&&o instanceof ImageBitmap?this.getImageData(o,s):o;i(null,new t.dX(n,a,r,s{n(null,t)}),(t=>{n(t)}))}}const h=t.dZ.prototype.toGeoJSON;let p=class{constructor(e){this._feature=e,this.extent=t.a3,this.type=e.type,this.properties=e.tags,"id"in e&&!isNaN(e.id)&&(this.id=parseInt(e.id,10))}loadGeometry(){if(1===this._feature.type){const e=[];for(const i of this._feature.geometry)e.push([new t.P(i[0],i[1])]);return e}{const e=[];for(const i of this._feature.geometry){const n=[];for(const e of i)n.push(new t.P(e[0],e[1]));e.push(n)}return e}}toGeoJSON(t,e,i){return h.call(this,t,e,i)}},f=class{constructor(e){this.layers={_geojsonTileLayer:this},this.name="_geojsonTileLayer",this.extent=t.a3,this.length=e.length,this._features=e}feature(t){return new p(this._features[t])}};const m=64/4096;class _{constructor(){this.features=new Map}clear(){this.features.clear()}load(t=[],e){for(const i of t){const t=i.id;if(null==t)continue;let n=this.features.get(t);n&&this.updateCache(n,e),i.geometry?(n=y(i),this.updateCache(n,e),this.features.set(t,n)):this.features.delete(t),this.updateCache(n,e)}}updateCache(t,e){for(const{canonical:i,uid:n}of Object.values(e)){const{z:r,x:o,y:s}=i;g(t,Math.pow(2,r),o,s)&&delete e[n]}}getTile(t,e,i){const n=Math.pow(2,t),r=[];for(const t of this.features.values())g(t,n,e,i)&&r.push(w(t,n,e,i));return{features:r}}getFeatures(){return[...this.features.values()]}}function g({minX:t,minY:e,maxX:i,maxY:n},r,o,s){return t(o-m)/r&&n>(s-m)/r}function y(t){const{id:e,geometry:i,properties:n}=t;if(!i)return;if("GeometryCollection"===i.type)throw new Error("GeometryCollection not supported in dynamic mode.");const{type:r,coordinates:o}=i,s={id:e,type:1,geometry:[],tags:n,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0},a=s.geometry;if("Point"===r)v(o,a,s);else if("MultiPoint"===r)for(const t of o)v(t,a,s);else if("LineString"===r)s.type=2,x(o,a,s);else if("MultiLineString"===r)s.type=2,b(o,a,s);else if("Polygon"===r)s.type=3,b(o,a,s,!0);else{if("MultiPolygon"!==r)throw new Error("Input data is not a valid GeoJSON object.");s.type=3;for(const t of o)b(t,a,s,!0)}return s}function v([e,i],n,r){const o=t.aj(e);let s=t.ak(i);s=s1?1:s,n.push(o,s),r.minX=Math.min(r.minX,o),r.minY=Math.min(r.minY,s),r.maxX=Math.max(r.maxX,o),r.maxY=Math.max(r.maxY,s)}function x(t,e,i,n=!1,r=!1){const o=[];for(const e of t)v(e,o,i);e.push(o),n&&function(t,e){let i=0;for(let e=0,n=t.length,r=n-2;e0===e)for(let e=0,i=t.length;e>31}function F(t,e){for(var i=t.loadGeometry(),n=t.type,r=0,o=0,s=i.length,a=0;at},V=Math.fround||(G=new Float32Array(1),t=>(G[0]=+t,G[0]));var G;const Z=3,q=5,H=6;class W{constructor(t){this.options=Object.assign(Object.create(j),t),this.trees=new Array(this.options.maxZoom+1),this.stride=this.options.reduce?7:6,this.clusterProps=[]}load(t){const{log:e,minZoom:i,maxZoom:n}=this.options;e&&console.time("total time");const r=`prepare ${t.length} points`;e&&console.time(r),this.points=t;const o=[];for(let e=0;e=i;t--){const i=+Date.now();s=this.trees[t]=this._createTree(this._cluster(s,t)),e&&console.log("z%d: %d clusters in %dms",t,s.numItems,+Date.now()-i)}return e&&console.timeEnd("total time"),this}getClusters(t,e){let i=((t[0]+180)%360+360)%360-180;const n=Math.max(-90,Math.min(90,t[1]));let r=180===t[2]?180:((t[2]+180)%360+360)%360-180;const o=Math.max(-90,Math.min(90,t[3]));if(t[2]-t[0]>=360)i=-180,r=180;else if(i>r){const t=this.getClusters([i,n,180,o],e),s=this.getClusters([-180,n,r,o],e);return t.concat(s)}const s=this.trees[this._limitZoom(e)],a=s.range(K(i),J(o),K(r),J(n)),l=s.data,c=[];for(const t of a){const e=this.stride*t;c.push(l[e+q]>1?Y(l,e,this.clusterProps):this.points[l[e+Z]])}return c}getChildren(t){const e=this._getOriginId(t),i=this._getOriginZoom(t),n="No cluster with the specified id.",r=this.trees[i];if(!r)throw new Error(n);const o=r.data;if(e*this.stride>=o.length)throw new Error(n);const s=this.options.radius/(this.options.extent*Math.pow(2,i-1)),a=r.within(o[e*this.stride],o[e*this.stride+1],s),l=[];for(const e of a){const i=e*this.stride;o[i+4]===t&&l.push(o[i+q]>1?Y(o,i,this.clusterProps):this.points[o[i+Z]])}if(0===l.length)throw new Error(n);return l}getLeaves(t,e,i){const n=[];return this._appendLeaves(n,t,e=e||10,i=i||0,0),n}getTile(t,e,i){const n=this.trees[this._limitZoom(t)],r=Math.pow(2,t),{extent:o,radius:s}=this.options,a=s/o,l=(i-a)/r,c=(i+1+a)/r,d={features:[]};return this._addTileFeatures(n.range((e-a)/r,l,(e+1+a)/r,c),n.data,e,i,r,d),0===e&&this._addTileFeatures(n.range(1-a/r,l,1,c),n.data,r,i,r,d),e===r-1&&this._addTileFeatures(n.range(0,l,a/r,c),n.data,-1,i,r,d),d.features.length?d:null}getClusterExpansionZoom(t){let e=this._getOriginZoom(t)-1;for(;e1;let l,c,d;if(a)l=X(e,t,this.clusterProps),c=e[t],d=e[t+1];else{const i=this.points[e[t+Z]];l=i.properties;const[n,r]=i.geometry.coordinates;c=K(n),d=J(r)}const u={type:1,geometry:[[Math.round(this.options.extent*(c*r-i)),Math.round(this.options.extent*(d*r-n))]],tags:l};let h;h=a||this.options.generateId?e[t+Z]:this.points[e[t+Z]].id,void 0!==h&&(u.id=h),o.features.push(u)}}_limitZoom(t){return Math.max(this.options.minZoom,Math.min(Math.floor(+t),this.options.maxZoom+1))}_cluster(t,e){const{radius:i,extent:n,reduce:r,minPoints:o}=this.options,s=i/(n*Math.pow(2,e)),a=t.data,l=[],c=this.stride;for(let i=0;ie&&(p+=a[i+q])}if(p>h&&p>=o){let t,o=n*h,s=d*h,f=-1;const m=(i/c1)for(const t of u){const i=t*c;if(!(a[i+2]>5}_getOriginZoom(t){return(t-this.points.length)%32}_map(t,e,i){if(t[e+q]>1){const n=this.clusterProps[t[e+H]];return i?Object.assign({},n):n}const n=this.points[t[e+Z]].properties,r=this.options.map(n);return i&&r===n?Object.assign({},r):r}}function Y(t,e,i){return{type:"Feature",id:t[e+Z],properties:X(t,e,i),geometry:{type:"Point",coordinates:[(n=t[e],360*(n-.5)),Q(t[e+1])]}};var n}function X(t,e,i){const n=t[e+q],r=n>=1e4?`${Math.round(n/1e3)}k`:n>=1e3?Math.round(n/100)/10+"k":n,o=t[e+H],s=-1===o?{}:Object.assign({},i[o]);return Object.assign(s,{cluster:!0,cluster_id:t[e+Z],point_count:n,point_count_abbreviated:r})}function K(t){return t/360+.5}function J(t){const e=Math.sin(t*Math.PI/180),i=.5-.25*Math.log((1+e)/(1-e))/Math.PI;return i1?1:i}function Q(t){const e=(180-360*t)*Math.PI/180;return 360*Math.atan(Math.exp(e))/Math.PI-90}function tt(t,e,i,n){let r=n;const o=e+(i-e>>1);let s,a=i-e;const l=t[e],c=t[e+1],d=t[i],u=t[i+1];for(let n=e+3;n 127;);else if(e===um.Bytes)this.pos=this.readVarint()+this.pos;else if(e===um.Fixed32)this.pos+=4;else{if(e!==um.Fixed64)throw new Error("Unimplemented type: "+e);this.pos+=8}},writeTag:function(t,e){this.writeVarint(t268435455||t=0?(i=t%4294967296|0,n=t/4294967296|0):(n=~(-t/4294967296),4294967295^(i=~(-t%4294967296))?i=i+1|0:(i=0,n=n+1|0)),t>=0x10000000000000000||t>>=7,i.buf[i.pos++]=127&t|128,t>>>=7,i.buf[i.pos++]=127&t|128,t>>>=7,i.buf[i.pos++]=127&t|128,i.buf[i.pos]=127&(t>>>=7)}(i,0,e),function(t,e){var i=(7&t)>>=3)?128:0),t&&(e.buf[e.pos++]=127&t|((t>>>=7)?128:0),t&&(e.buf[e.pos++]=127&t|((t>>>=7)?128:0),t&&(e.buf[e.pos++]=127&t|((t>>>=7)?128:0),t&&(e.buf[e.pos++]=127&t|((t>>>=7)?128:0),t&&(e.buf[e.pos++]=127&t)))))}(n,e)}(t,this):(this.realloc(4),this.buf[this.pos++]=127&t|(t>127?128:0),t>>=7)|(t>127?128:0),t>>=7)|(t>127?128:0),t>>7&127))))},writeSVarint:function(t){this.writeVarint(t55295&&n56319||o+1===e.length?(t[i++]=239,t[i++]=191,t[i++]=189):r=n;continue}if(n>6|192:(n>12|224:(t[i++]=n>>18|240,t[i++]=n>>12&63|128),t[i++]=n>>6&63|128),t[i++]=63&n|128)}return i}(this.buf,t,this.pos);var i=this.pos-e;i>=128&&gm(e,i,this),this.pos=e-1,this.writeVarint(i),this.pos+=i},writeFloat:function(t){this.realloc(4),dm.write(this.buf,t,this.pos,!0,23,4),this.pos+=4},writeDouble:function(t){this.realloc(8),dm.write(this.buf,t,this.pos,!0,52,8),this.pos+=8},writeBytes:function(t){var e=t.length;this.writeVarint(e),this.realloc(e);for(var i=0;i=128&&gm(i,n,this),this.pos=i-1,this.writeVarint(n),this.pos+=n},writeMessage:function(t,e,i){this.writeTag(t,um.Bytes),this.writeRawMessage(e,i)},writePackedVarint:function(t,e){e.length&&this.writeMessage(t,ym,e)},writePackedSVarint:function(t,e){e.length&&this.writeMessage(t,vm,e)},writePackedBoolean:function(t,e){e.length&&this.writeMessage(t,wm,e)},writePackedFloat:function(t,e){e.length&&this.writeMessage(t,xm,e)},writePackedDouble:function(t,e){e.length&&this.writeMessage(t,bm,e)},writePackedFixed32:function(t,e){e.length&&this.writeMessage(t,Tm,e)},writePackedSFixed32:function(t,e){e.length&&this.writeMessage(t,Sm,e)},writePackedFixed64:function(t,e){e.length&&this.writeMessage(t,Em,e)},writePackedSFixed64:function(t,e){e.length&&this.writeMessage(t,Mm,e)},writeBytesField:function(t,e){this.writeTag(t,um.Bytes),this.writeBytes(e)},writeFixed32Field:function(t,e){this.writeTag(t,um.Fixed32),this.writeFixed32(e)},writeSFixed32Field:function(t,e){this.writeTag(t,um.Fixed32),this.writeSFixed32(e)},writeFixed64Field:function(t,e){this.writeTag(t,um.Fixed64),this.writeFixed64(e)},writeSFixed64Field:function(t,e){this.writeTag(t,um.Fixed64),this.writeSFixed64(e)},writeVarintField:function(t,e){this.writeTag(t,um.Varint),this.writeVarint(e)},writeSVarintField:function(t,e){this.writeTag(t,um.Varint),this.writeSVarint(e)},writeStringField:function(t,e){this.writeTag(t,um.Bytes),this.writeString(e)},writeFloatField:function(t,e){this.writeTag(t,um.Fixed32),this.writeFloat(e)},writeDoubleField:function(t,e){this.writeTag(t,um.Fixed64),this.writeDouble(e)},writeBooleanField:function(t,e){this.writeVarintField(t,Boolean(e))}};var Lm=h(cm);const Pm=["id","tile","layer","source","sourceLayer","state"];class $m{constructor(t,e,i,n,r){this.type="Feature",this._vectorTileFeature=t,this._z=e,this._x=i,this._y=n,this.properties=t.properties,this.id=r}get geometry(){return void 0===this._geometry&&(this._geometry=this._vectorTileFeature.toGeoJSON(this._x,this._y,this._z).geometry),this._geometry}set geometry(t){this._geometry=t}toJSON(){const t={type:"Feature",state:void 0,geometry:this.geometry,properties:this.properties};for(const e of Pm)void 0!==this[e]&&(t[e]=this[e]);return t}}class km{constructor(){this.state={},this.stateChanges={},this.deletedStates={}}updateState(t,e,i){const n=String(e);if(this.stateChanges[t]=this.stateChanges[t]||{},this.stateChanges[t][n]=this.stateChanges[t][n]||{},ei(this.stateChanges[t][n],i),null===this.deletedStates[t]){this.deletedStates[t]={};for(const e in this.state[t])e!==n&&(this.deletedStates[t][e]=null)}else if(this.deletedStates[t]&&null===this.deletedStates[t][n]){this.deletedStates[t][n]={};for(const e in this.state[t][n])i[e]||(this.deletedStates[t][n][e]=null)}else for(const e in i)this.deletedStates[t]&&this.deletedStates[t][n]&&null===this.deletedStates[t][n][e]&&delete this.deletedStates[t][n][e]}removeFeatureState(t,e,i){if(null===this.deletedStates[t])return;const n=String(e);if(this.deletedStates[t]=this.deletedStates[t]||{},i&&void 0!==e)null!==this.deletedStates[t][n]&&(this.deletedStates[t][n]=this.deletedStates[t][n]||{},this.deletedStates[t][n][i]=null);else if(void 0!==e)if(this.stateChanges[t]&&this.stateChanges[t][n])for(i in this.deletedStates[t][n]={},this.stateChanges[t][n])this.deletedStates[t][n][i]=null;else this.deletedStates[t][n]=null;else this.deletedStates[t]=null}getState(t,e){const i=String(e),n=ei({},(this.state[t]||{})[i],(this.stateChanges[t]||{})[i]);if(null===this.deletedStates[t])return{};if(this.deletedStates[t]){const i=this.deletedStates[t][e];if(null===i)return{};for(const t in i)delete n[t]}return n}initializeTileState(t,e){t.setFeatureState(this.state,e)}coalesceChanges(t,e){const i={};for(const t in this.stateChanges){this.state[t]=this.state[t]||{};const e={};for(const i in this.stateChanges[t])this.state[t][i]||(this.state[t][i]={}),ei(this.state[t][i],this.stateChanges[t][i]),e[i]=this.state[t][i];i[t]=e}for(const t in this.deletedStates){this.state[t]=this.state[t]||{};const e={};if(null===this.deletedStates[t])for(const i in this.state[t])e[i]={},this.state[t][i]={};else for(const i in this.deletedStates[t]){if(null===this.deletedStates[t][i])this.state[t][i]={};else if(this.state[t][i])for(const e of Object.keys(this.deletedStates[t][i]))delete this.state[t][i][e];e[i]=this.state[t][i]}i[t]=i[t]||{},ei(i[t],e)}if(this.stateChanges={},this.deletedStates={},0!==Object.keys(i).length)for(const n in t)t[n].setFeatureState(i,e)}}class Dm{constructor(t,e){this.tileID=t,this.x=t.canonical.x,this.y=t.canonical.y,this.z=t.canonical.z,this.grid=new va(uo,16,0),this.featureIndexArray=new yc,this.promoteId=e,this.is3DTile=!1}insert(t,e,i,n,r,o=0,s=0){const a=this.featureIndexArray.length;this.featureIndexArray.emplaceBack(i,n,r,o);const l=this.grid;for(let t=0;t=0&&n[3]>=0&&l.insert(a,n[0],n[1],n[2],n[3])}}loadVTLayers(){if(!this.vtLayers){this.vtLayers=new bp(new Lm(this.rawTileData)).layers,this.sourceLayerCoder=new am(this.vtLayers?Object.keys(this.vtLayers).sort():["_geojsonTileLayer"]),this.vtFeatures={};for(const t in this.vtLayers)this.vtFeatures[t]=[]}return this.vtLayers}query(t,e,i,n){this.loadVTLayers();const r=t.params||{},o=dl(r.filter),s=t.tileResult,a=t.transform,l=s.bufferedTilespaceBounds,c=this.grid.query(l.min.x,l.min.y,l.max.x,l.max.y,((t,e,i,n)=>ou(s.bufferedTilespaceGeometry,t,e,i,n)));c.sort(Rm);let d=null;a.elevation&&c.length>0&&(d=Xp.create(a.elevation,this.tileID));const u={};let h;for(let l=0;l(m||(m=Gd(e,this.tileID.canonical,t.tileTransform)),i.queryIntersectsFeature(s,e,n,m,this.z,t.transform,t.pixelPosMatrix,d,r))))}return u}loadMatchingFeature(t,e,i,n,r,o,s,a,l){const{featureIndex:c,bucketIndex:d,sourceLayerIndex:u,layoutVertexArrayOffset:h}=e,p=this.bucketLayerIDs[d];if(n&&!function(t,e){for(let i=0;i=0)return!0;return!1}(n,p))return;const f=this.sourceLayerCoder.decode(u),m=this.vtLayers[f].feature(c);if(i.needGeometry){const t=Zd(m,!0);if(!i.filter(new Ha(this.tileID.overscaledZ),t,this.tileID.canonical))return}else if(!i.filter(new Ha(this.tileID.overscaledZ),m))return;const _=this.getId(m,f);for(let e=0;e{const s=e instanceof el?e.get(o):null;return s&&s.evaluate?s.evaluate(i,n,r):s}))}function Rm(t,e){return e-t}ba(Dm,"FeatureIndex",{omit:["rawTileData","sourceLayerCoder"]});var Om=24;const Bm=128;function Fm(t,e){const{expression:i}=e;if("constant"===i.kind)return{kind:"constant",layoutSize:i.evaluate(new Ha(t+1))};if("source"===i.kind)return{kind:"source"};{const{zoomStops:e,interpolationType:n}=i;let r=0;for(;r{t.text=function(t,e,i){const n=e.layout.get("text-transform").evaluate(i,{});return"uppercase"===n?t=t.toLocaleUpperCase():"lowercase"===n&&(t=t.toLocaleLowerCase()),qa.applyArabicShaping&&(t=qa.applyArabicShaping(t)),t}(t.text,e,i)})),t}const Gm={"!":"︕","#":"#",$:"$","%":"%","&":"&","(":"︵",")":"︶","*":"*","+":"+",",":"︐","-":"︲",".":"・","/":"/",":":"︓",";":"︔","":"﹀","?":"︖","@":"@","[":"﹇","\\":"\","]":"﹈","^":"^",_:"︳","`":"`","{":"︷","|":"―","}":"︸","~":"~","¢":"¢","£":"£","¥":"¥","¦":"¦","¬":"¬","¯":" ̄","–":"︲","—":"︱","‘":"﹃","’":"﹄","“":"﹁","”":"﹂","…":"︙","‧":"・","₩":"₩","、":"︑","。":"︒","〈":"︿","〉":"﹀","《":"︽","》":"︾","「":"﹁","」":"﹂","『":"﹃","』":"﹄","【":"︻","】":"︼","〔":"︹","〕":"︺","〖":"︗","〗":"︘","!":"︕","(":"︵",")":"︶",",":"︐","-":"︲",".":"・",":":"︓",";":"︔","<":"︿",">":"﹀","?":"︖","[":"﹇","]":"﹈","_":"︳","{":"︷","|":"―","}":"︸","⦅":"︵","⦆":"︶","。":"︒","「":"﹁","」":"﹂","←":"↑","→":"↓"};function Zm(t){return"︶"===t||"﹈"===t||"︸"===t||"﹄"===t||"﹂"===t||"︾"===t||"︼"===t||"︺"===t||"︘"===t||"﹀"===t||"︐"===t||"︓"===t||"︔"===t||"`"===t||" ̄"===t||"︑"===t||"︒"===t}function qm(t){return"︵"===t||"﹇"===t||"︷"===t||"﹃"===t||"﹁"===t||"︽"===t||"︻"===t||"︹"===t||"︗"===t||"︿"===t}const Hm=3;function Wm(t,e,i){e.glyphs=[],1===t&&i.readMessage(Ym,e)}function Ym(t,e,i){if(3===t){const{id:t,bitmap:n,width:r,height:o,left:s,top:a,advance:l}=i.readMessage(Xm,{});e.glyphs.push({id:t,bitmap:new dh({width:r+2*Hm,height:o+2*Hm},n),metrics:{width:r,height:o,left:s,top:a,advance:l}})}else 4===t?e.ascender=i.readSVarint():5===t&&(e.descender=i.readSVarint())}function Xm(t,e,i){1===t?e.id=i.readVarint():2===t?e.bitmap=i.readBytes():3===t?e.width=i.readVarint():4===t?e.height=i.readVarint():5===t?e.left=i.readSVarint():6===t?e.top=i.readSVarint():7===t&&(e.advance=i.readVarint())}const Km=Hm,Jm={horizontal:1,vertical:2,horizontalOnly:3};class Qm{constructor(){this.scale=1,this.fontStack="",this.imageName=null}static forText(t,e){const i=new Qm;return i.scale=t||1,i.fontStack=e,i}static forImage(t){const e=new Qm;return e.imageName=t,e}}class t_{constructor(){this.text="",this.sectionIndex=[],this.sections=[],this.imageSectionID=null}static fromFeature(t,e){const i=new t_;for(let n=0;n=0&&i>=t&&i_[this.text.charCodeAt(i)];i--)e--;this.text=this.text.substring(t,e),this.sectionIndex=this.sectionIndex.slice(t,e)}substring(t,e){const i=new t_;return i.text=this.text.substring(t,e),i.sectionIndex=this.sectionIndex.slice(t,e),i.sections=this.sections,i}toString(){return this.text}getMaxScale(){return this.sectionIndex.reduce(((t,e)=>Math.max(t,this.sections[e].scale)),0)}addTextSection(t,e){this.text+=t.text,this.sections.push(Qm.forText(t.scale,t.fontStack||e));const i=this.sections.length-1;for(let e=0;e=63743?null:++this.imageSectionID:(this.imageSectionID=57344,this.imageSectionID)}}function e_(t,e,i,n,r,o,s,a,l,c,d,u,h,p,f){const m=t_.fromFeature(t,r);u===Jm.vertical&&m.verticalizePunctuation(h);let _=[];const g=function(t,e,i,n,r,o){if(!t)return[];const s=[],a=function(t,e,i,n,r,o){let s=0;for(let i=0;i=0;let c=0;for(let i=0;i0&&o>b&&(b=o)}else{const t=i[a.fontStack];if(!t)continue;t[m]&&(S=t[m]);const n=e[a.fontStack];if(!n)continue;const o=n.glyphs[m];if(!o)continue;if(v=o.metrics,M=8203!==m?Om:0,_){const t=void 0!==n.ascender?Math.abs(n.ascender):0,e=void 0!==n.descender?Math.abs(n.descender):0,i=(t+e)*g;w-i/2;){if(s--,sn;)c-=l.shift().angleDelta;if(c>r)return!1;s++,a+=e.dist(i)}return!0}function m_(t){let e=0;for(let i=0;ic){const d=(c-l)/o,u=Vn(n.x,r.x,d),h=Vn(n.y,r.y,d),p=new p_(u,h,0,r.angleTo(n),i);return!s||f_(t,p,a,s,e)?p:void 0}l+=o}}function v_(t,e,i,n,r,o,s,a,l){const c=__(n,o,s),d=g_(n,r),u=d*s,h=0===t[0].x||t[0].x===l||0===t[0].y||t[0].y===l;return e-u=0&&g=0&&y=0&&h+c=n&&c.x>=n||(s.x>=n?s=new Ue(n,s.y+(n-s.x)/(c.x-s.x)*(c.y-s.y))._round():c.x>=n&&(c=new Ue(n,s.y+(n-s.x)/(c.x-s.x)*(c.y-s.y))._round()),s.y>=r&&c.y>=r||(s.y>=r?s=new Ue(s.x+(r-s.y)/(c.y-s.y)*(c.x-s.x),r)._round():c.y>=r&&(c=new Ue(s.x+(r-s.y)/(c.y-s.y)*(c.x-s.x),r)._round()),l&&s.equals(l[l.length-1])||(l=[s],o.push(l)),l.push(c)))))}}return o}function w_(t){let e=0,i=0;for(const n of t)e+=n.w*n.h,i=Math.max(i,n.w);t.sort(((t,e)=>e.h-t.h));const n=[{x:0,y:0,w:Math.max(Math.ceil(Math.sqrt(e/.95)),i),h:1/0}];let r=0,o=0;for(const e of t)for(let t=n.length-1;t>=0;t--){const i=n[t];if(!(e.w>i.w||e.h>i.h)){if(e.x=i.x,e.y=i.y,o=Math.max(o,e.y+e.h),r=Math.max(r,e.x+e.w),e.w===i.w&&e.h===i.h){const e=n.pop();tt.hasImage(e,i))),t.dispatchRenderCallbacks(this.haveRenderCallbacks,i);for(const n in t.getUpdatedImages(i))this.patchUpdatedImage(this.iconPositions[n],t.getImage(n,i),e),this.patchUpdatedImage(this.patternPositions[n],t.getImage(n,i),e)}patchUpdatedImage(t,e,i){if(!t||!e)return;if(t.version===e.version)return;t.version=e.version;const[n,r]=t.tl,o=!!Object.keys(this.patternPositions).length;i.update(e.data,{useMipmap:o},{x:n,y:r})}}ba(S_,"ImagePosition"),ba(E_,"ImageAtlas");const M_=1e20;function C_(t,e,i,n,r,o,s,a,l){for(let c=e;c-1);l++,o[l]=a,s[l]=c,s[l+1]=M_}for(let a=0,l=0;a{let n=this.entries[t];n||(n=this.entries[t]={glyphs:{},requests:{},ranges:{},ascender:void 0,descender:void 0});let r=n.glyphs[e];if(void 0!==r)return void i(null,{stack:t,id:e,glyph:r});if(r=this._tinySDF(n,t,e),r)return n.glyphs[e]=r,void i(null,{stack:t,id:e,glyph:r});const s=Math.floor(e/256);if(256*s>65535)return void i(new Error("glyphs > 65535 not supported"));if(n.ranges[s])return void i(null,{stack:t,id:e,glyph:r});let a=n.requests[s];a||(a=n.requests[s]=[],P_.loadGlyphRange(t,s,o,this.requestManager,((t,e)=>{if(e){n.ascender=e.ascender,n.descender=e.descender;for(const t in e.glyphs)this._doesCharSupportLocalGlyph(+t)||(n.glyphs[+t]=e.glyphs[+t]);n.ranges[s]=!0}for(const i of a)i(t,e);delete n.requests[s]}))),a.push(((n,r)=>{n?i(n):r&&i(null,{stack:t,id:e,glyph:r.glyphs[e]||null})}))}),((t,e)=>{if(t)i(t);else if(e){const t={};for(const{stack:i,id:n,glyph:r}of e)void 0===t[i]&&(t[i]={}),void 0===t[i].glyphs&&(t[i].glyphs={}),t[i].glyphs[n]=r&&{id:r.id,bitmap:r.bitmap.clone(),metrics:r.metrics},t[i].ascender=this.entries[i].ascender,t[i].descender=this.entries[i].descender;i(null,t)}}))}_doesCharSupportLocalGlyph(t){return this.localGlyphMode!==L_.none&&(this.localGlyphMode===L_.all?!!this.localFontFamily:!!this.localFontFamily&&(Ma["CJK Unified Ideographs"](t)||Ma["Hangul Syllables"](t)||Ma.Hiragana(t)||Ma.Katakana(t)||Ma["CJK Symbols and Punctuation"](t)||Ma["CJK Unified Ideographs Extension A"](t)||Ma["CJK Unified Ideographs Extension B"](t)))}_tinySDF(t,e,i){const n=this.localFontFamily;if(!n||!this._doesCharSupportLocalGlyph(i))return;let r=t.tinySDF;if(!r){let i="400";/bold/i.test(e)?i="900":/medium/i.test(e)?i="500":/light/i.test(e)&&(i="200"),r=t.tinySDF=new P_.TinySDF({fontFamily:n,fontWeight:i,fontSize:24*I_,buffer:3*I_,radius:8*I_}),r.fontWeight=i}if(this.localGlyphs[r.fontWeight][i])return this.localGlyphs[r.fontWeight][i];const o=String.fromCodePoint(i),{data:s,width:a,height:l,glyphWidth:c,glyphHeight:d,glyphLeft:u,glyphTop:h,glyphAdvance:p}=r.draw(o);return this.localGlyphs[r.fontWeight][i]={id:i,bitmap:new dh({width:a,height:l},s),metrics:{width:c/I_,height:d/I_,left:u/I_,top:h/I_-27,advance:p/I_,localGlyph:!0}}}}P_.loadGlyphRange=function(t,e,i,n,r){const o=256*e,s=o+255,a=n.transformRequest(n.normalizeGlyphsURL(i).replace("{fontstack}",t).replace("{range}",`${o}-${s}`),Ki.Glyphs);en(a,((t,e)=>{if(t)r(t);else if(e){const t={},i=function(t){return new Lm(t).readFields(Wm,{})}(e);for(const e of i.glyphs)t[e.id]=e;r(null,{glyphs:t,ascender:i.ascender,descender:i.descender})}}))},P_.TinySDF=class{constructor({fontSize:t=24,buffer:e=3,radius:i=8,cutoff:n=.25,fontFamily:r="sans-serif",fontWeight:o="normal",fontStyle:s="normal"}={}){this.buffer=e,this.cutoff=n,this.radius=i;const a=this.size=t+4*e,l=this._createCanvas(a),c=this.ctx=l.getContext("2d",{willReadFrequently:!0});c.font=`${s} ${o} ${t}px ${r}`,c.textBaseline="alphabetic",c.textAlign="left",c.fillStyle="black",this.gridOuter=new Float64Array(a*a),this.gridInner=new Float64Array(a*a),this.f=new Float64Array(a),this.z=new Float64Array(a+1),this.v=new Uint16Array(a)}_createCanvas(t){const e=document.createElement("canvas");return e.width=e.height=t,e}draw(t){const{width:e,actualBoundingBoxAscent:i,actualBoundingBoxDescent:n,actualBoundingBoxLeft:r,actualBoundingBoxRight:o}=this.ctx.measureText(t),s=Math.ceil(i),a=Math.max(0,Math.min(this.size-this.buffer,Math.ceil(o-r))),l=Math.min(this.size-this.buffer,s+Math.ceil(n)),c=a+2*this.buffer,d=l+2*this.buffer,u=Math.max(c*d,0),h=new Uint8ClampedArray(u),p={data:h,width:c,height:d,glyphWidth:a,glyphHeight:l,glyphTop:s,glyphLeft:0,glyphAdvance:e};if(0===a||0===l)return p;const{ctx:f,buffer:m,gridInner:_,gridOuter:g}=this;f.clearRect(m,m,a,l),f.fillText(t,m,m+s);const y=f.getImageData(m,m,a,l);g.fill(M_,0,u),_.fill(0,0,u);for(let t=0;t0?t*t:0,_[n]=tt+e[1]-e[0],f=u.reduce(p,0),m=h.reduce(p,0),_=a-f,g=l-m;let y=0,v=f,x=0,b=m,w=0,T=_,S=0,E=g;if(o.content&&n){const t=o.content;y=D_(u,0,t[0]),x=D_(h,0,t[1]),v=D_(u,t[0],t[2]),b=D_(h,t[1],t[3]),w=t[0]-y,S=t[1]-x,T=t[2]-t[0]-v,E=t[3]-t[1]-b}const M=(n,r,a,l)=>{const u=R_(n.stretch-y,v,c,t.left),h=O_(n.fixed-w,T,n.stretch,f),p=R_(r.stretch-x,b,d,t.top),_=O_(r.fixed-S,E,r.stretch,m),g=R_(a.stretch-y,v,c,t.left),M=O_(a.fixed-w,T,a.stretch,f),C=R_(l.stretch-x,b,d,t.top),A=O_(l.fixed-S,E,l.stretch,m),I=new Ue(u,p),L=new Ue(g,p),P=new Ue(g,C),$=new Ue(u,C),k=new Ue(h/s,_/s),D=new Ue(M/s,A/s),z=e*Math.PI/180;if(z){const t=Math.sin(z),e=Math.cos(z),i=[e,-t,t,e];I._matMult(i),L._matMult(i),$._matMult(i),P._matMult(i)}const R=n.stretch+n.fixed,O=a.stretch+a.fixed,B=r.stretch+r.fixed,F=l.stretch+l.fixed,N=t.imageSecondary;return{tl:I,tr:L,bl:$,br:P,texPrimary:{x:o.paddedRect.x+$_+R,y:o.paddedRect.y+$_+B,w:O-R,h:F-B},texSecondary:N?{x:N.paddedRect.x+$_+R,y:N.paddedRect.y+$_+B,w:O-R,h:F-B}:void 0,writingMode:void 0,glyphOffset:[0,0],sectionIndex:0,pixelOffsetTL:k,pixelOffsetBR:D,minFontScaleX:T/s/c,minFontScaleY:E/s/d,isSDF:i}};if(n&&(o.stretchX||o.stretchY)){const t=z_(u,_,f),e=z_(h,g,m);for(let i=0;io)&&(o=e.x),(!t||e.y>s)&&(s=e.y)}const l=Math.min(o-n,s-r);let c=l/2;const d=new co([],N_);if(0===l)return new Ue(n,r);for(let e=n;eu.d||!u.d)&&(u=n,i&&console.log("found best %d after %d probes",Math.round(1e4*n.d)/1e4,h)),n.max-u.dt.y!=a.y>t.y&&t.x18&&P>2&&(P>>=1),Math.max(uo/(512*P),1)*_.get("symbol-spacing")),S=_.get("text-padding")*t.tilePixelRatio,E=_.get("icon-padding")*t.tilePixelRatio,M=Ge(_.get("text-max-angle")),C="map"===_.get("text-rotation-alignment")&&"point"!==_.get("symbol-placement"),A="map"===_.get("icon-rotation-alignment")&&"point"!==_.get("symbol-placement"),I=_.get("symbol-placement"),L=T/2;var P;const $=_.get("icon-text-fit").evaluate(e,{},u),k=_.get("icon-text-fit-padding").evaluate(e,{},u),D="none"!==$;let z;!1===t.hasAnyIconTextFit&&D&&(t.hasAnyIconTextFit=!0),n&&D&&(t.allowVerticalPlacement&&i.vertical&&(z=h_(n,i.vertical,$,k,g,b)),y&&(n=h_(n,y,$,k,g,b)));const R=(s,a,m)=>{if(a.x=uo||a.y=uo)return;let _=null;if(v){const{x:t,y:e,z:i}=h.projectTilePoint(a.x,a.y,m);_={anchor:new p_(t,e,i,0,void 0),up:h.upVector(m,a.x,a.y)}}!function(t,e,i,n,r,o,s,a,l,c,d,u,h,p,f,m,_,g,y,v,x,b,w,T,S,E,M){const C=t.addToLineVertexArray(e,n);let A,I,L,P,$,k,D,z=0,R=0,O=0,B=0,F=-1,N=-1;const U={};let j=Ln("");const V=i?i.anchor:e,G="none"!==l.layout.get("icon-text-fit").evaluate(x,{},S);let Z=0,q=0;if(void 0===l._unevaluatedLayout.getValue("text-radial-offset")?[Z,q]=l.layout.get("text-offset").evaluate(x,{},S).map((t=>t*Om)):(Z=l.layout.get("text-radial-offset").evaluate(x,{},S)*Om,q=j_),t.allowVerticalPlacement&&r.vertical){const t=r.vertical;if(f)k=J_(t),a&&(D=J_(a));else{const i=l.layout.get("text-rotate").evaluate(x,{},S)+90;L=K_(c,V,e,d,u,h,t,p,i,m),a&&(P=K_(c,V,e,d,u,h,a,g,i))}}if(o){const n=l.layout.get("icon-rotate").evaluate(x,{},S),r=k_(o,n,w,G),s=a?k_(a,n,w,G):void 0;I=K_(c,V,e,d,u,h,o,g,n),z=4*r.length;const p=t.iconSizeData;let f=null;"source"===p.kind?(f=[Bm*l.layout.get("icon-size").evaluate(x,{},S)],f[0]>W_&&pi(`${t.layerIds[0]}: Value for "icon-size" is >= ${H_}. Reduce your "icon-size".`)):"composite"===p.kind&&(f=[Bm*b.compositeIconSizes[0].evaluate(x,{},S),Bm*b.compositeIconSizes[1].evaluate(x,{},S)],(f[0]>W_||f[1]>W_)&&pi(`${t.layerIds[0]}: Value for "icon-size" is >= ${H_}. Reduce your "icon-size".`)),t.addSymbols(t.icon,r,f,v,y,x,!1,i,e,C.lineStartIndex,C.lineLength,-1,T,S,E,M),F=t.icon.placedSymbolArray.length-1,s&&(R=4*s.length,t.addSymbols(t.icon,s,f,v,y,x,Jm.vertical,i,e,C.lineStartIndex,C.lineLength,-1,T,S,E,M),N=t.icon.placedSymbolArray.length-1)}for(const n in r.horizontal){const o=r.horizontal[n];A||(j=Ln(o.text),f?$=J_(o):A=K_(c,V,e,d,u,h,o,p,l.layout.get("text-rotate").evaluate(x,{},S),m));const a=1===o.positionedLines.length;if(O+=Y_(t,i,e,o,s,l,f,x,m,C,r.vertical?Jm.horizontal:Jm.horizontalOnly,a?Object.keys(r.horizontal):[n],U,F,b,T,S,E),a)break}r.vertical&&(B+=Y_(t,i,e,r.vertical,s,l,f,x,m,C,Jm.vertical,["vertical"],U,N,b,T,S,E));let H=-1;const W=(t,e)=>t?Math.max(t,e):e;H=W($,H),H=W(k,H),H=W(D,H);const Y=H>-1?1:0;t.glyphOffsetArray.length>=65535&&pi("Too many glyphs being rendered in a tile. See https://github.com/mapbox/mapbox-gl-js/issues/2907"),void 0!==x.sortKey&&t.addToSortKeyRanges(t.symbolInstances.length,x.sortKey),t.symbolInstances.emplaceBack(e.x,e.y,V.x,V.y,V.z,U.right>=0?U.right:-1,U.center>=0?U.center:-1,U.left>=0?U.left:-1,U.vertical>=0?U.vertical:-1,F,N,j,void 0!==A?A:t.collisionBoxArray.length,void 0!==A?A+1:t.collisionBoxArray.length,void 0!==L?L:t.collisionBoxArray.length,void 0!==L?L+1:t.collisionBoxArray.length,void 0!==I?I:t.collisionBoxArray.length,void 0!==I?I+1:t.collisionBoxArray.length,P||t.collisionBoxArray.length,P?P+1:t.collisionBoxArray.length,d,O,B,z,R,Y,0,Z,q,H,0,1,1,G?1:0)}(t,a,_,s,i,n,r,z,t.layers[0],t.collisionBoxArray,e.index,e.sourceLayerIndex,t.index,S,C,l,0,E,A,g,e,o,c,d,u,p,f)};if("line"===I)for(const r of b_(e.geometry,0,0,uo,uo)){const e=v_(r,T,M,i.vertical||y,n,x,w,t.overscaling,uo);for(const i of e)y&&Q_(t,y.text,L,i)||R(r,i,u)}else if("line-center"===I){for(const t of e.geometry)if(t.length>1){const e=y_(t,M,i.vertical||y,n,x,w);e&&R(t,e,u)}}else if("Polygon"===e.type)for(const t of Zh(e.geometry,0)){const e=F_(t,16);R(t[0],new p_(e.x,e.y,0,0,void 0),u)}else if("LineString"===e.type)for(const t of e.geometry)R(t,new p_(t[0].x,t[0].y,0,0,void 0),u);else if("Point"===e.type)for(const t of e.geometry)for(const e of t)R([e],new p_(e.x,e.y,0,0,void 0),u)}const H_=255,W_=H_*Bm;function Y_(t,e,i,n,r,o,s,a,l,c,d,u,h,p,f,m,_,g){const y=function(t,e,i,n,r,o,s,a){const l=[];if(0===e.positionedLines.length)return l;const c=n.layout.get("text-rotate").evaluate(o,{})*Math.PI/180,d=function(t){const e=t[0],i=t[1],n=e*i;return n>0?[e,-i]:nW_&&pi(`${t.layerIds[0]}: Value for "text-size" is >= ${H_}. Reduce your "text-size".`)):"composite"===v.kind&&(x=[Bm*f.compositeTextSizes[0].evaluate(a,{},_),Bm*f.compositeTextSizes[1].evaluate(a,{},_)],(x[0]>W_||x[1]>W_)&&pi(`${t.layerIds[0]}: Value for "text-size" is >= ${H_}. Reduce your "text-size".`)),t.addSymbols(t.text,y,x,l,s,a,d,e,i,c.lineStartIndex,c.lineLength,p,m,_,g,!1);for(const e of u)h[e]=t.text.placedSymbolArray.length-1;return 4*y.length}function X_(t){for(const e in t)return t[e];return null}function K_(t,e,i,n,r,o,s,a,l,c){let d=s.top,u=s.bottom,h=s.left,p=s.right;const f=s.collisionPadding;if(f&&(h-=f[0],d-=f[1],p+=f[2],u+=f[3]),l){const t=new Ue(h,d),e=new Ue(p,d),i=new Ue(h,u),n=new Ue(p,u),r=Ge(l);let o=new Ue(0,0);c&&(o=new Ue(c[0],c[1])),t._rotateAround(r,o),e._rotateAround(r,o),i._rotateAround(r,o),n._rotateAround(r,o),h=Math.min(t.x,e.x,i.x,n.x),p=Math.max(t.x,e.x,i.x,n.x),d=Math.min(t.y,e.y,i.y,n.y),u=Math.max(t.y,e.y,i.y,n.y)}return t.emplaceBack(e.x,e.y,e.z,i.x,i.y,h,d,p,u,a,n,r,o),t.length-1}function J_(t){t.collisionPadding&&(t.top-=t.collisionPadding[1],t.bottom+=t.collisionPadding[3]);const e=t.bottom-t.top;return e>0?Math.max(10,e):null}function Q_(t,e,i,n){const r=t.compareText;if(e in r){const t=r[e];for(let e=t.length-1;e>=0;e--)if(n.dist(t[e])v&&(x(t,c,n,r,a,l),x(c,i,a,l,o,s))}x(u,h,n,o,r,o),x(h,p,r,o,r,s),x(p,f,r,s,n,s),x(f,u,n,s,n,o),m-=v,_-=v,g+=v,y+=v;const b=1/Math.max(g-m,y-_);return{scale:b,x:m*b,y:_*b,x2:g*b,y2:y*b,projection:e}}function ig(t,{x:e,y:i},n=0){return new Ue(((e-n)*t.scale-t.x)*uo,(i*t.scale-t.y)*uo)}const ng=t.ad.identity(new Float32Array(16));class rg{constructor(t){this.spec=t,this.name=t.name,this.wrap=!1,this.requiresDraping=!1,this.supportsWorldCopies=!1,this.supportsTerrain=!1,this.supportsFog=!1,this.supportsFreeCamera=!1,this.zAxisUnit="meters",this.isReprojectedInTileSpace=!0,this.unsupportedLayers=["custom"],this.center=[0,0],this.range=[3.5,7]}project(t,e){return{x:0,y:0,z:0}}unproject(t,e){return new pd(0,0)}projectTilePoint(t,e,i){return{x:t,y:e,z:0}}locationPoint(t,e,i=!0){return t._coordinatePoint(t.locationCoordinate(e),i)}pixelsPerMeter(t,e){return Cd(1,t)*e}pixelSpaceConversion(t,e,i){return 1}farthestPixelDistance(t){return tg(t,t.pixelsPerMeter)}pointCoordinate(t,e,i,n){const r=t.horizonLineFromTop(!1),o=new Ue(e,Math.max(r,i));return t.rayIntersectionCoordinate(t.pointRayIntersection(o,n))}pointCoordinate3D(t,e,i){const n=new Ue(e,i);if(t.elevation)return t.elevation.pointCoordinate(n);{const e=this.pointCoordinate(t,n.x,n.y,0);return[e.x,e.y,e.z]}}isPointAboveHorizon(t,e){if(t.elevation&&t.elevation.visibleDemTiles.length)return!this.pointCoordinate3D(t,e.x,e.y);const i=t.horizonLineFromTop();return e.y0?epg-i&&(e=pg-i);const o=r/Math.pow(fg(e),n);let s=o*Math.sin(n*t),a=r-o*Math.cos(n*t);return s=.5*(s/Math.PI+.5),a=.5*(a/Math.PI+.5),{x:s,y:this.southernCenter?a:1-a,z:0}}unproject(t,e){t=(2*t-.5)*Math.PI,this.southernCenter&&(e=1-e),e=(2*(1-e)-.5)*Math.PI;const{n:i,f:n}=this,r=n-e,o=Math.sign(r),s=Math.sign(i)*Math.sqrt(t*t+r*r);let a=Math.atan2(t,Math.abs(r))*o;r*i1e-6&&--n>0);o=i*i;const s=Xe(Ze(t/(.8707+o*(o*(o*o*o*(.003971-.001529*o)-.013791)-.131979))),-180,180),a=Ze(i);return new pd(s,a)}}const vg=Ge(Pd);class xg extends rg{project(t,e){e=Ge(e),t=Ge(t);const i=Math.cos(e),n=2/Math.PI,r=Math.acos(i*Math.cos(t/2)),o=Math.sin(r)/r,s=.5*(t*n+2*i*Math.sin(t/2)/o)||0,a=.5*(e+Math.sin(e)/o)||0;return{x:.5*(s/Math.PI+.5),y:1-.5*(a/Math.PI+1),z:0}}unproject(t,e){let i=t=(2*t-.5)*Math.PI,n=e=(2*(1-e)-1)*Math.PI,r=25;const o=1e-6;let s=0,a=0;do{const r=Math.cos(n),o=Math.sin(n),l=2*o*r,c=o*o,d=r*r,u=Math.cos(i/2),h=Math.sin(i/2),p=2*u*h,f=h*h,m=1-d*u*u,_=m?1/m:0,g=m?Math.acos(r*u)*Math.sqrt(1/m):0,y=.5*(2*g*r*h+2*i/Math.PI)-t,v=.5*(g*o+n)-e,x=.5*_*(d*f+g*r*u*c)+1/Math.PI,b=_*(p*l/4-g*o*h),w=.125*_*(l*h-g*o*d*p),T=.5*_*(c*u+g*f*r)+.5,S=b*w-T*x;s=(v*b-y*T)/S,a=(y*w-v*x)/S,i=Xe(i-s,-Math.PI,Math.PI),n=Xe(n-a,-vg,vg)}while((Math.abs(s)>o||Math.abs(a)>o)&&--r>0);return new pd(Ze(i),Ze(n))}}class bg extends rg{constructor(t){super(t),this.center=t.center||[0,0],this.parallels=t.parallels||[0,0],this.cosPhi=Math.max(.01,Math.cos(Ge(this.parallels[0]))),this.scale=1/(2*Math.max(Math.PI*this.cosPhi,1/this.cosPhi)),this.wrap=!0,this.supportsWorldCopies=!0}project(t,e){const{scale:i,cosPhi:n}=this;return{x:Ge(t)*n*i+.5,y:-Math.sin(Ge(e))/n*i+.5,z:0}}unproject(t,e){const{scale:i,cosPhi:n}=this,r=-(e-.5)/i,o=Xe(Ze((t-.5)/i)/n,-180,180),s=Math.asin(Xe(r*n,-1,1)),a=Xe(Ze(s),-Pd,Pd);return new pd(o,a)}}class wg extends _g{constructor(t){super(t),this.requiresDraping=!0,this.supportsWorldCopies=!1,this.supportsFog=!0,this.zAxisUnit="pixels",this.unsupportedLayers=["debug"],this.range=[3,5]}projectTilePoint(e,i,n){const r=Fu(e,i,n),o=ju($u(n));return t._.transformMat4(r,r,o),{x:r[0],y:r[1],z:r[2]}}locationPoint(e,i){const n=dd(i.lat,i.lng),r=t._.normalize([],n),o=e.elevation?e.elevation.getAtPointOrZero(e.locationCoordinate(i),e._centerAltitude):e._centerAltitude,s=Cd(1,0)*uo*o;t._.scaleAndAdd(n,n,r,s);const a=t.ad.identity(new Float64Array(16));return t.ad.multiply(a,e.pixelMatrix,e.globeMatrix),t._.transformMat4(n,n,a),new Ue(n[0],n[1])}pixelsPerMeter(t,e){return Cd(1,0)*e}pixelSpaceConversion(t,e,i){const n=Cd(1,t)*e,r=Vn(Cd(1,45)*e,n,i);return this.pixelsPerMeter(t,e)/r}createTileMatrix(e,i,n){const r=Vu($u(n.canonical));return t.ad.multiply(new Float64Array(16),e.globeMatrix,r)}createInversionMatrix(e,i){const{center:n}=e,r=ju($u(i));return t.ad.rotateY(r,r,Ge(n.lng)),t.ad.rotateX(r,r,Ge(n.lat)),t.ad.scale(r,r,[e._pixelsPerMercatorPixel,e._pixelsPerMercatorPixel,1]),Float32Array.from(r)}pointCoordinate(t,e,i,n){return Iu(t,e,i,!0)||new Rd(0,0)}pointCoordinate3D(t,e,i){const n=this.pointCoordinate(t,e,i,0);return[n.x,n.y,n.z]}isPointAboveHorizon(t,e){return!Iu(t,e.x,e.y,!1)}farthestPixelDistance(e){const i=function(e,i){const n=e.cameraToCenterDistance,r=e._centerAltitude*i,o=e._camera,s=e._camera.forward(),a=t._.add([],t._.scale([],s,-n),[0,0,r]),l=e.worldSize/(2*Math.PI),c=[0,0,-l],d=e.width/e.height,u=Math.tan(e.fovAboveCenter),h=t._.scale([],o.up(),u),p=t._.scale([],o.right(),u*d),f=t._.normalize([],t._.add([],t._.add([],s,h),p)),m=[];let _;if(new mu(a,f).closestPointOnSphere(c,l,m)){const i=t._.add([],m,c),n=t._.sub([],i,a);_=Math.cos(e.fovAboveCenter)*t._.length(n)}else{const e=t._.sub([],a,c),i=t._.sub([],c,a);t._.normalize(i,i);const n=t._.length(e)-l;_=Math.sqrt(n*(n+2*l));const r=Math.acos(_/(l+n))-Math.acos(t._.dot(s,i));_*=Math.cos(r)}return 1.01*_}(e,this.pixelsPerMeter(e.center.lat,e.worldSize)),n=Hu(e.zoom);if(n>0){const t=tg(e,Cd(1,e.center.lat)*e.worldSize),r=e.worldSize/(2*Math.PI),o=Math.max(e.width,e.height)/e.worldSize*Math.PI;return Vn(i,t+r*(1-Math.cos(o)),Math.pow(n,10))}return i}upVector(t,e,i){return Fu(e,i,t,1)}upVectorScale(t){return{metersToTile:Cu(Nu($u(t)))}}}function Tg(t){const e=t.parallels,i=!!e&&Math.abs(e[0]+e[1])0&&(this.iconTransitioningVertexBuffer=t.createVertexBuffer(this.iconTransitioningVertexArray,Vf.members,!0)),this.globeExtVertexArray.length>0&&(this.globeExtVertexBuffer=t.createVertexBuffer(this.globeExtVertexArray,Ff.members,!0)),!this.zOffsetVertexBuffer&&(this.zOffsetVertexArray.length>0||r)&&(this.zOffsetVertexBuffer=t.createVertexBuffer(this.zOffsetVertexArray,jf.members,!0)),this.opacityVertexBuffer.itemSize=1),(i||n)&&this.programConfigurations.upload(t))}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy(),this.dynamicLayoutVertexBuffer.destroy(),this.opacityVertexBuffer.destroy(),this.occlusionQueryOpacityVertexBuffer.destroy(),this.iconTransitioningVertexBuffer&&this.iconTransitioningVertexBuffer.destroy(),this.globeExtVertexBuffer&&this.globeExtVertexBuffer.destroy(),this.zOffsetVertexBuffer&&this.zOffsetVertexBuffer.destroy())}}ba(Ng,"SymbolBuffers");class Ug{constructor(t,e,i){this.layoutVertexArray=new t,this.layoutAttributes=e,this.indexArray=new i,this.segments=new wc,this.collisionVertexArray=new Xl,this.collisionVertexArrayExt=new Ol}upload(t){this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,this.layoutAttributes),this.indexBuffer=t.createIndexBuffer(this.indexArray),this.collisionVertexBuffer=t.createVertexBuffer(this.collisionVertexArray,Gf.members,!0),this.collisionVertexBufferExt=t.createVertexBuffer(this.collisionVertexArrayExt,Zf.members,!0)}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.segments.destroy(),this.collisionVertexBuffer.destroy(),this.collisionVertexBufferExt.destroy())}}ba(Ug,"CollisionBuffers");class jg{constructor(e){this.queries=new Map,this.collisionBoxArray=e.collisionBoxArray,this.zoom=e.zoom,this.lut=e.lut,this.overscaling=e.overscaling,this.layers=e.layers,this.layerIds=this.layers.map((t=>t.fqid)),this.index=e.index,this.pixelRatio=e.pixelRatio,this.sourceLayerIndex=e.sourceLayerIndex,this.hasPattern=!1,this.hasRTLText=!1,this.fullyClipped=!1,this.hasAnyIconTextFit=!1,this.sortKeyRanges=[],this.collisionCircleArray=[],this.placementInvProjMatrix=t.ad.identity([]),this.placementViewportMatrix=t.ad.identity([]);const i=this.layers[0]._unevaluatedLayout._values;this.textSizeData=Fm(this.zoom,i["text-size"]),this.iconSizeData=Fm(this.zoom,i["icon-size"]);const n=this.layers[0].layout,r=n.get("symbol-sort-key"),o=n.get("symbol-z-order");this.canOverlap=n.get("text-allow-overlap")||n.get("icon-allow-overlap")||n.get("text-ignore-placement")||n.get("icon-ignore-placement"),this.sortFeaturesByKey="viewport-y"!==o&&void 0!==r.constantOr(1),this.sortFeaturesByY=("viewport-y"===o||"auto"===o&&!this.sortFeaturesByKey)&&this.canOverlap,this.writingModes=n.get("text-writing-mode").map((t=>Jm[t])),this.stateDependentLayerIds=this.layers.filter((t=>t.isStateDependent())).map((t=>t.id)),this.sourceID=e.sourceID,this.projection=e.projection,this.hasAnyZOffset=!1,this.zOffsetSortDirty=!1,this.zOffsetBuffersNeedUpload=n.get("symbol-z-elevate"),this.activeReplacements=[],this.replacementUpdateTime=0}createArrays(){this.text=new Ng(new Yc(this.layers,{zoom:this.zoom,lut:this.lut},(t=>/^text/.test(t)))),this.icon=new Ng(new Yc(this.layers,{zoom:this.zoom,lut:this.lut},(t=>/^icon/.test(t)))),this.glyphOffsetArray=new mc,this.lineVertexArray=new _c,this.symbolInstances=new fc}calculateGlyphDependencies(t,e,i,n,r){for(let i=0;i0)&&("constant"!==l.value.kind||l.value.value.length>0),h="constant"!==d.value.kind||!!d.value.value||Object.keys(d.parameters).length>0,p=s.get("symbol-sort-key");if(this.features=[],!u&&!h)return;const f=i.iconDependencies,m=i.glyphDependencies,_=i.availableImages,g=new Ha(this.zoom);for(const{feature:i,id:c,index:d,sourceLayerIndex:y}of e){const e=o._featureFilter.needGeometry,v=Zd(i,e);if(!o._featureFilter.filter(g,v,n))continue;if(e||(v.geometry=Gd(i,n,r)),a&&1!==i.type&&n.z{const o=Fu(e.x,e.y,n,1),s=Fu(r.x,r.y,n,1);return t._.dot(o,s)=0;for(const i of x.sections)if(i.image)f[i.image.namePrimary]=!0;else{const n=Ca(x.toString()),r=i.fontStack||t,o=m[r]=m[r]||{};this.calculateGlyphDependencies(i.text,o,e,this.allowVerticalPlacement,n)}}}"line"===s.get("symbol-placement")&&(this.features=function(t){const e={},i={},n=[];let r=0;function o(e){n.push(t[e]),r++}function s(t,e,r){const o=i[t];return delete i[t],i[e]=o,n[o].geometry[0].pop(),n[o].geometry[0]=n[o].geometry[0].concat(r[0]),o}function a(t,i,r){const o=e[i];return delete e[i],e[t]=o,n[o].geometry[0].shift(),n[o].geometry[0]=r[0].concat(n[o].geometry[0]),o}function l(t,e,i){const n=i?e[0][e[0].length-1]:e[0][0];return`${t}:${n.x}:${n.y}`}for(let c=0;ct.geometry))}(this.features)),this.sortFeaturesByKey&&this.features.sort(((t,e)=>t.sortKey-e.sortKey))}update(t,e,i,n,r){const o=0!==Object.keys(t).length;if(o&&!this.stateDependentLayers.length)return;const s=o?this.stateDependentLayers:this.layers;this.text.programConfigurations.updatePaintArrays(t,e,s,i,n,r),this.icon.programConfigurations.updatePaintArrays(t,e,s,i,n,r)}updateOcclusionOpacities(t,e,i){if(!e.useOcclusionQueries)return!1;const n=this;if("globe"===n.projection.name)return!1;let r=!1;n.hasTextData()&&(r=r||0!==n.text.occlusionQueryOpacityVertexArray.length),n.hasIconData()&&(r=r||0!==n.icon.occlusionQueryOpacityVertexArray.length);const o=n.layers[0].paint,s=o.get("icon-occlusion-opacity").constantOr(0),a=o.get("text-occlusion-opacity").constantOr(0);if(!n.layers[0].hasInitialOcclusionOpacityProperties||1===s&&1===a)return!1;let l=!r;for(let t=0;t.5?1:-1)*e.fadeSpeed*i*.001,r.occlusionOpacity=Xe(r.occlusionOpacity,0,1),l=l||r.occlusionOpacity!==o}if(!l)return!1;let c=0,d=0;const u=(t,e,i,n)=>{let r=0,o=0;i?(r=d,d+=n,o=d):(r=c,c+=n,o=c),o>e.occlusionQueryOpacityVertexArray.length&&e.occlusionQueryOpacityVertexArray.resize(o);const s=t.occlusionOpacity;for(let t=0;t0;if((i>0||r>0)&&(u(e,n.text,!1,i),u(e,n.text,!1,r)),s){const{placedIconSymbolIndex:t,verticalPlacedIconSymbolIndex:i}=e;t>=0&&u(e,n.icon,!0,o),i>=0&&u(e,n.icon,!0,e.numVerticalIconVertices)}}return n.hasTextData()&&n.text.occlusionQueryOpacityVertexBuffer&&(n.text.occlusionQueryOpacityVertexBuffer.length{i+=e,i>t.length&&t.resize(i);for(let r=-e;r{n+=e,n>t.length&&t.resize(n);for(let r=-e;r0;if((r>0||o>0)&&(t(this.text.zOffsetVertexArray,r,a),t(this.text.zOffsetVertexArray,o,a)),l){const{placedIconSymbolIndex:t,verticalPlacedIconSymbolIndex:i}=n;t>=0&&e(this.icon.zOffsetVertexArray,s,a),i>=0&&e(this.icon.zOffsetVertexArray,n.numVerticalIconVertices,a)}}this.text.zOffsetVertexBuffer&&this.text.zOffsetVertexBuffer.updateData(this.text.zOffsetVertexArray),this.icon.zOffsetVertexBuffer&&this.icon.zOffsetVertexBuffer.updateData(this.icon.zOffsetVertexArray)}isEmpty(){return 0===this.symbolInstances.length&&!this.hasRTLText}uploadPending(){return!this.uploaded||this.text.programConfigurations.needsUpload||this.icon.programConfigurations.needsUpload}upload(t){!this.uploaded&&this.hasDebugData()&&(this.textCollisionBox.upload(t),this.iconCollisionBox.upload(t)),this.text.upload(t,this.sortFeaturesByY,!this.uploaded,this.text.programConfigurations.needsUpload,this.zOffsetBuffersNeedUpload),this.icon.upload(t,this.sortFeaturesByY,!this.uploaded,this.icon.programConfigurations.needsUpload,this.zOffsetBuffersNeedUpload),this.uploaded=!0}destroyDebugData(){this.textCollisionBox.destroy(),this.iconCollisionBox.destroy()}getProjection(){return this.projectionInstance||(this.projectionInstance=Tg(this.projection)),this.projectionInstance}destroy(){this.text.destroy(),this.icon.destroy(),this.hasDebugData()&&this.destroyDebugData();for(const t of this.queries.values())t.destroy()}addToLineVertexArray(t,e){const i=this.lineVertexArray.length;if(void 0!==t.segment)for(const{x:t,y:i}of e)this.lineVertexArray.emplaceBack(t,i);return{lineStartIndex:i,lineLength:this.lineVertexArray.length-i}}addSymbols(t,e,i,n,r,o,s,a,l,c,d,u,h,p,f,m){const _=t.indexArray,g=t.layoutVertexArray,y=t.globeExtVertexArray,v=t.segments.prepareSegment(4*e.length,g,_,this.canOverlap?o.sortKey:void 0),x=this.glyphOffsetArray.length,b=v.vertexLength,w=this.allowVerticalPlacement&&s===Jm.vertical?Math.PI/2:0,T=o.text&&o.text.sections;for(let n=0;n=0?e.rightJustifiedTextSymbolIndex:e.centerJustifiedTextSymbolIndex>=0?e.centerJustifiedTextSymbolIndex:e.leftJustifiedTextSymbolIndex>=0?e.leftJustifiedTextSymbolIndex:e.verticalPlacedTextSymbolIndex>=0?e.verticalPlacedTextSymbolIndex:n),o=Nm(this.textSizeData,t,r)/Om;return this.tilePixelRatio*o}getSymbolInstanceIconSize(t,e,i){const n=this.icon.placedSymbolArray.get(i),r=Nm(this.iconSizeData,t,n);return this.tilePixelRatio*r}_commitDebugCollisionVertexUpdate(t,e,i,n){t.emplaceBack(e,-i,-i,n),t.emplaceBack(e,i,-i,n),t.emplaceBack(e,i,i,n),t.emplaceBack(e,-i,i,n)}_updateTextDebugCollisionBoxes(t,e,i,n,r,o){for(let s=n;s0}hasIconData(){return this.icon.segments.get().length>0}hasDebugData(){return this.textCollisionBox&&this.iconCollisionBox}hasTextCollisionBoxData(){return this.hasDebugData()&&this.textCollisionBox.segments.get().length>0}hasIconCollisionBoxData(){return this.hasDebugData()&&this.iconCollisionBox.segments.get().length>0}hasIconTextFit(){return this.hasAnyIconTextFit}addIndicesForPlacedSymbol(t,e){const i=t.placedSymbolArray.get(e),n=i.vertexStartIndex+4*i.numGlyphs;for(let e=i.vertexStartIndex;en[t]-n[e]||r[e]-r[t])),o}getSortedIndexesByZOffset(){if(!this.zOffsetSortDirty)return this.symbolInstanceIndexesSortedZOffset;if(!this.symbolInstanceIndexesSortedZOffset){this.symbolInstanceIndexesSortedZOffset=[];for(let t=0;tthis.symbolInstances.get(e).zOffset-this.symbolInstances.get(t).zOffset))}addToSortKeyRanges(t,e){const i=this.sortKeyRanges[this.sortKeyRanges.length-1];i&&i.sortKey===e?i.symbolInstanceEnd=t+1:this.sortKeyRanges.push({sortKey:e,symbolInstanceStart:t,symbolInstanceEnd:t+1})}sortFeatures(t){if(this.sortFeaturesByY&&this.sortedAngle!==t&&!(this.text.segments.get().length>1||this.icon.segments.get().length>1)){this.symbolInstanceIndexes=this.getSortedSymbolIndexes(t),this.sortedAngle=t,this.text.indexArray.clear(),this.icon.indexArray.clear(),this.featureSortOrder=[];for(const t of this.symbolInstanceIndexes){const e=this.symbolInstances.get(t);this.featureSortOrder.push(e.featureIndex);const{rightJustifiedTextSymbolIndex:i,centerJustifiedTextSymbolIndex:n,leftJustifiedTextSymbolIndex:r,verticalPlacedTextSymbolIndex:o,placedIconSymbolIndex:s,verticalPlacedIconSymbolIndex:a}=e;i>=0&&this.addIndicesForPlacedSymbol(this.text,i),n>=0&&n!==i&&this.addIndicesForPlacedSymbol(this.text,n),r>=0&&r!==n&&r!==i&&this.addIndicesForPlacedSymbol(this.text,r),o>=0&&this.addIndicesForPlacedSymbol(this.text,o),s>=0&&this.addIndicesForPlacedSymbol(this.icon,s),a>=0&&this.addIndicesForPlacedSymbol(this.icon,a)}this.text.indexBuffer&&this.text.indexBuffer.updateData(this.text.indexArray),this.icon.indexBuffer&&this.icon.indexBuffer.updateData(this.icon.indexArray)}}}ba(jg,"SymbolBucket",{omit:["layers","collisionBoxArray","features","compareText"]}),jg.addDynamicAttributes=Bg;class Vg{constructor(t,e,i,n){this.context=t,this.format=i,this.texture=t.gl.createTexture(),this.update(e,n)}update(t,e,i){const{width:n,height:r}=t,{context:o}=this,{gl:s}=o;if(s.bindTexture(s.TEXTURE_2D,this.texture),o.pixelStoreUnpackFlipY.set(!1),o.pixelStoreUnpack.set(1),o.pixelStoreUnpackPremultiplyAlpha.set(this.format===s.RGBA&&(!e||!1!==e.premultiply)),this.useMipmap=Boolean(e&&e.useMipmap),i||this.size&&this.size[0]===n&&this.size[1]===r){const{x:e,y:o}=i||{x:0,y:0};if(t instanceof HTMLImageElement||t instanceof HTMLCanvasElement||t instanceof HTMLVideoElement||t instanceof ImageData||ImageBitmap&&t instanceof ImageBitmap)s.texSubImage2D(s.TEXTURE_2D,0,e,o,s.RGBA,s.UNSIGNED_BYTE,t);else{let i=this.format,a=s.UNSIGNED_BYTE;this.format===s.R32F&&(i=s.RED,a=s.FLOAT),s.texSubImage2D(s.TEXTURE_2D,0,e,o,n,r,i,a,t.data)}}else if(this.size=[n,r],t instanceof HTMLImageElement||t instanceof HTMLCanvasElement||t instanceof HTMLVideoElement||t instanceof ImageData||ImageBitmap&&t instanceof ImageBitmap){let e=this.format;this.format===s.R8&&(e=s.RED),s.texImage2D(s.TEXTURE_2D,0,this.format,e,s.UNSIGNED_BYTE,t)}else{let e=this.format,i=this.format,o=s.UNSIGNED_BYTE,a=!1;this.format===s.DEPTH_COMPONENT&&(e=s.DEPTH_COMPONENT16,o=s.UNSIGNED_SHORT),this.format===s.DEPTH_STENCIL&&(e=s.DEPTH24_STENCIL8,o=s.UNSIGNED_INT_24_8,a=!0),this.format===s.R8&&(i=s.RED),this.format===s.R32F&&(o=s.FLOAT,i=s.RED),!this.useMipmap&&a?s.texStorage2D(s.TEXTURE_2D,1,e,n,r):s.texImage2D(s.TEXTURE_2D,0,e,n,r,0,i,o,t.data)}this.useMipmap&&s.generateMipmap(s.TEXTURE_2D)}bind(t,e,i=!1){const{context:n}=this,{gl:r}=n;r.bindTexture(r.TEXTURE_2D,this.texture),t!==this.minFilter&&(r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MAG_FILTER,t),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MIN_FILTER,this.useMipmap&&!i?t===r.NEAREST?r.NEAREST_MIPMAP_NEAREST:r.LINEAR_MIPMAP_LINEAR:t),this.minFilter=t),e!==this.wrapS&&(r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_S,e),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_T,e),this.wrapS=e)}bindExtraParam(t,e,i,n){const{context:r}=this,{gl:o}=r;o.bindTexture(o.TEXTURE_2D,this.texture),e!==this.magFilter&&(o.texParameteri(o.TEXTURE_2D,o.TEXTURE_MAG_FILTER,e),this.magFilter=e),t!==this.minFilter&&(o.texParameteri(o.TEXTURE_2D,o.TEXTURE_MIN_FILTER,this.useMipmap?t===o.NEAREST?o.NEAREST_MIPMAP_NEAREST:o.LINEAR_MIPMAP_LINEAR:t),this.minFilter=t),i!==this.wrapS&&(o.texParameteri(o.TEXTURE_2D,o.TEXTURE_WRAP_S,i),this.wrapS=i),n!==this.wrapT&&(o.texParameteri(o.TEXTURE_2D,o.TEXTURE_WRAP_T,n),this.wrapT=n)}destroy(){const{gl:t}=this.context;t.deleteTexture(this.texture),this.texture=null}}class Gg{constructor(t,e){this.context=t,this.texture=e}bind(t,e){const{context:i}=this,{gl:n}=i;n.bindTexture(n.TEXTURE_2D,this.texture),t!==this.minFilter&&(n.texParameteri(n.TEXTURE_2D,n.TEXTURE_MAG_FILTER,t),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_MIN_FILTER,t),this.minFilter=t),e!==this.wrapS&&(n.texParameteri(n.TEXTURE_2D,n.TEXTURE_WRAP_S,e),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_WRAP_T,e),this.wrapS=e)}}const Zg=32,qg=33,Hg=new Uint16Array(8184);for(let t=0;t>=1)>1;){const t=i+r>>1,l=n+o>>1;1&e?(r=i,o=n,i=s,n=a):(i=r,n=o,r=s,o=a),s=t,a=l}const l=4*t;Hg[l+0]=i,Hg[l+1]=n,Hg[l+2]=r,Hg[l+3]=o}const Wg=new Uint16Array(2178),Yg=new Uint8Array(1089),Xg=new Uint16Array(1089);function Kg(t){return 0===t?-.03125:32===t?.03125:0}var Jg=Ll([{name:"a_pos",type:"Int16",components:2},{name:"a_texture_pos",type:"Int16",components:2}]),Qg=Ll([{name:"a_index",type:"Int16",components:1}]);const ty={type:2,extent:uo,loadGeometry:()=>[[new Ue(0,0),new Ue(uo+1,0),new Ue(uo+1,uo+1),new Ue(0,uo+1),new Ue(0,0)]]};class ey{constructor(t,e,i,n,r){this.tileID=t,this.uid=ni(),this.uses=0,this.tileSize=e,this.tileZoom=i,this.buckets={},this.expirationTime=null,this.queryPadding=0,this.hasSymbolBuckets=!1,this.hasRTLText=!1,this.dependencies={},this.isRaster=r,n&&n.style&&(this._lastUpdatedBrightness=n.style.getBrightness()),this.expiredRequestCount=0,this.state="loading",n&&n.transform&&(this.projection=n.transform.projection)}registerFadeDuration(t){const e=t+this.timeAdded;ee.getLayer(t))).filter(Boolean);if(0!==t.length){n.layers=t,n.stateDependentLayerIds&&(n.stateDependentLayers=n.stateDependentLayerIds.map((e=>t.filter((t=>t.id===e))[0])));for(const e of t)i[e.fqid]=n}}return i}(t.buckets,e.style),this.hasSymbolBuckets=!1;for(const t in this.buckets){const e=this.buckets[t];if(e instanceof jg){if(this.hasSymbolBuckets=!0,!i)break;e.justReloaded=!0}}if(this.hasRTLText=!1,this.hasSymbolBuckets)for(const t in this.buckets){const e=this.buckets[t];if(e instanceof jg&&e.hasRTLText){this.hasRTLText=!0,qa.isLoading()||qa.isLoaded()||"deferred"!==Ga()||Za();break}}this.queryPadding=0;for(const t in this.buckets){const i=this.buckets[t],n=e.style.getOwnLayer(t);if(!n)continue;const r=n.queryRadius(i);this.queryPadding=Math.max(this.queryPadding,r)}t.imageAtlas&&(this.imageAtlas=t.imageAtlas),t.glyphAtlasImage&&(this.glyphAtlasImage=t.glyphAtlasImage),t.lineAtlas&&(this.lineAtlas=t.lineAtlas),this._lastUpdatedBrightness=t.brightness}else this.collisionBoxArray=new dc}unloadVectorData(){if(this.hasData()){for(const t in this.buckets)this.buckets[t].destroy();this.buckets={},this.imageAtlas&&(this.imageAtlas=null),this.lineAtlas&&(this.lineAtlas=null),this.imageAtlasTexture&&this.imageAtlasTexture.destroy(),this.glyphAtlasTexture&&this.glyphAtlasTexture.destroy(),this.lineAtlasTexture&&this.lineAtlasTexture.destroy(),this._tileBoundsBuffer&&(this._tileBoundsBuffer.destroy(),this._tileBoundsIndexBuffer.destroy(),this._tileBoundsSegments.destroy(),this._tileBoundsBuffer=null),this._tileDebugBuffer&&(this._tileDebugBuffer.destroy(),this._tileDebugSegments.destroy(),this._tileDebugBuffer=null),this._tileDebugIndexBuffer&&(this._tileDebugIndexBuffer.destroy(),this._tileDebugIndexBuffer=null),this._globeTileDebugBorderBuffer&&(this._globeTileDebugBorderBuffer.destroy(),this._globeTileDebugBorderBuffer=null),this._tileDebugTextBuffer&&(this._tileDebugTextBuffer.destroy(),this._tileDebugTextSegments.destroy(),this._tileDebugTextIndexBuffer.destroy(),this._tileDebugTextBuffer=null),this._globeTileDebugTextBuffer&&(this._globeTileDebugTextBuffer.destroy(),this._globeTileDebugTextBuffer=null),this.latestFeatureIndex=null,this.state="unloaded"}}getBucket(t){return this.buckets[t.fqid]}upload(t){for(const e in this.buckets){const i=this.buckets[e];i.uploadPending()&&i.upload(t)}const e=t.gl,i=this.imageAtlas;if(i&&!i.uploaded){const n=!!Object.keys(i.patternPositions).length;this.imageAtlasTexture=new Vg(t,i.image,e.RGBA,{useMipmap:n}),this.imageAtlas.uploaded=!0}this.glyphAtlasImage&&(this.glyphAtlasTexture=new Vg(t,this.glyphAtlasImage,e.R8),this.glyphAtlasImage=null),this.lineAtlas&&!this.lineAtlas.uploaded&&(this.lineAtlasTexture=new Vg(t,this.lineAtlas.image,e.R8),this.lineAtlas.uploaded=!0)}prepare(t,e,i){if(this.imageAtlas&&this.imageAtlasTexture&&this.imageAtlas.patchUpdatedImages(t,this.imageAtlasTexture,i),!e||!this.latestFeatureIndex||!this.latestFeatureIndex.rawTileData)return;const n=e.style.getBrightness();(this._lastUpdatedBrightness||n)&&(this._lastUpdatedBrightness&&n&&Math.abs(this._lastUpdatedBrightness-n)t)i=!1;else if(e)if(this.expirationTime=0;t--){const e=4*t,i=Hg[e+0],n=Hg[e+1],r=Hg[e+2],o=Hg[e+3],s=i+r>>1,a=n+o>>1,l=s+a-n,c=a+i-s,d=n*qg+i,u=o*qg+r,h=a*qg+s,p=Math.hypot((Wg[2*d+0]+Wg[2*u+0])/2-Wg[2*h+0],(Wg[2*d+1]+Wg[2*u+1])/2-Wg[2*h+1])>=16;Yg[h]=Yg[h]||(p?1:0),t>1)*qg+(i+l>>1)]||Yg[(o+c>>1)*qg+(r+l>>1)])}const r=new Dl,o=new Kl;let s=0;function a(t,e){const i=e*qg+t;return 0===Xg[i]&&(r.emplaceBack(Wg[2*i+0],Wg[2*i+1],t*uo/Zg,e*uo/Zg),Xg[i]=++s),Xg[i]-1}function l(t,e,i,n,r,s){const c=t+i>>1,d=e+n>>1;if(Math.abs(t-r)+Math.abs(e-s)>1&&Yg[d*qg+c])l(r,s,t,e,c,d),l(i,n,r,s,c,d);else{const l=a(t,e),c=a(i,n),d=a(r,s);o.emplaceBack(l,c,d)}}return l(0,0,Zg,Zg,Zg,0),l(Zg,Zg,0,0,0,Zg),{vertices:r,indices:o}}(this.tileID.canonical,e);n=t.vertices,r=t.indices}else{n=new Dl,r=new Kl;for(const{x:t,y:e}of i)n.emplaceBack(t,e,0,0);const t=xh(n.int16,void 0,4);for(let e=0;e0&&(a=t.ad.invert(new Float64Array(16),i.globeMatrix)),this._makeGlobeTileDebugBorderBuffer(e,r,i,o,a,s),this._makeGlobeTileDebugTextBuffer(e,r,i,o,a,s)}_globePoint(e,i,n,r,o,s,a){let l=Fu(e,i,n);if(s){const o=1.5?h=-1:u{const p=(d-t)/(h-1),f=(u-c)/(h-1),m=s.length;for(let d=0;dd*t+e;for(let t=0;t[t,this.get(t)]))}evict(t=!1){if(t||this.size>0){const t=this.first;delete this.items[t.key],0==--this.size?(this.first=null,this.last=null):(this.first=t.next,this.first.prev=null)}return this}expiresAt(t){let e;return this.has(t)&&(e=this.items[t].expiry),e}get(t){let e;if(this.has(t)){const i=this.items[t];this.ttl>0&&i.expiry0?Date.now()+this.ttl:this.ttl),this.last!==r){const t=this.last,e=r.next,i=r.prev;this.first===r&&(this.first=r.next),r.next=null,r.prev=this.last,t.next=r,null!==i&&(i.next=e),null!==e&&(e.prev=i)}}else this.max>0&&this.size===this.max&&this.evict(!0),r=this.items[t]={expiry:this.ttl>0?Date.now()+this.ttl:this.ttl,key:t,prev:this.last,next:null,value:e},1==++this.size?this.first=r:this.last.next=r;return this.last=r,this}values(t=this.keys()){return t.map((t=>this.get(t)))}}function uy(t,e){if(4!==e.length)throw new Error(`Expected data of dimension 4 but got ${e.length}.`);let i=e[3];for(let n=2;n>=1;n--){const r=1===n?1:0,o=2===n?1:0;for(let n=0;n>>1^-(1&t[e]);return t}function py(t,e){switch(e){case"uint32":return t;case"uint16":for(let e=0;e>4|(61440&i)>>8|(240&n)>4|(15&n)>6|(192&n)>>4|(192&r)>>2|192&o,t[e+1]=(48&i)>>4|(48&n)>>2|48&r|(48&o)>2|12&n|(12&r)>1|(21845&Cy)>2|(13107&Ay)>4|(3855&Ay)>8|(255&Ay)>1}var Iy=function(t,e,i){for(var n=t.length,r=0,o=new _y(e);r>l]=c}else for(s=new _y(n),r=0;r>15-t[r]);return s},Ly=new my(288);for(Cy=0;Cye&&(e=t[i]);return e},zy=function(t,e,i){var n=e/8|0;return(t[n]|t[n+1]>(7&e)&i},Ry=function(t,e){var i=e/8|0;return(t[i]|t[i+1]>(7&e)},Oy=["unexpected EOF","invalid block type","invalid length/literal","invalid distance","stream finished","no stream handler",,"no callback","invalid UTF-8 data","extra field too long","date not in range 1980-2099","filename too long","stream finishing","invalid zip data"],By=function(t,e,i){var n=new Error(e||Oy[t]);if(n.code=t,Error.captureStackTrace&&Error.captureStackTrace(n,By),!i)throw n;return n},Fy=new my(0),Ny="undefined"!=typeof TextDecoder&&new TextDecoder;try{Ny.decode(Fy,{stream:!0})}catch(t){}const Uy={gzip_data:"gzip"},jy={0:"uint32",1:"uint32",2:"uint16",3:"uint8"},Vy={uint32:1,uint16:2,uint8:4},Gy={uint32:Uint32Array,uint16:Uint16Array,uint8:Uint8Array};class Zy{constructor(t=1){this.x=NaN,this.y=NaN,this.z=NaN,this.layers={},this._cacheSize=t}getLayer(t){return this.layers[t]}getHeaderLength(t){const e=new Uint8Array(t),i=new DataView(t);if(13!==e[0])throw new fy("File is not a valid MRT.");return i.getUint32(1,!0)}parseHeader(t){const e=new Uint8Array(t),i=this.getHeaderLength(t);if(e.length= ${i} but got buffer of length ${e.length}`);const n=function(t){return t.readFields(iy,{header_length:0,x:0,y:0,z:0,layers:[]},void 0)}(new Lm(e.subarray(0,i)));if(!isNaN(this.x)&&(this.x!==n.x||this.y!==n.y||this.z!==n.z))throw new fy(`Invalid attempt to parse header ${n.z}/${n.x}/${n.y} for tile ${this.z}/${this.x}/${this.y}`);this.x=n.x,this.y=n.y,this.z=n.z;for(const t of n.layers)this.layers[t.name]=new qy(t,{cacheSize:this._cacheSize});return this}createDecodingTask(t){const e=[],i=this.getLayer(t.layerName);for(let n=0;nt.lastBlock)continue;if(i._blocksInProgress.has(n))continue;const a={layerName:i.name,firstByte:o,lastByte:s,pixelFormat:i.pixelFormat,blockIndex:n,blockShape:[r.bands.length].concat(i.bandShape),buffer:i.buffer,codec:r.codec.codec,filters:r.filters.map((t=>t.filter))};i._blocksInProgress.add(n),e.push(a)}return new Hy(e,(()=>{e.forEach((t=>i._blocksInProgress.delete(t.blockIndex)))}),((t,n)=>{if(e.forEach((t=>i._blocksInProgress.delete(t.blockIndex))),t)throw t;n.forEach((t=>{this.getLayer(t.layerName).processDecodedData(t)}))}))}}class qy{constructor({version:t,name:e,units:i,tilesize:n,pixel_format:r,buffer:o,data_index:s},a){if(this.version=t,1!==this.version)throw new fy(`Cannot parse raster layer encoded with MRT version ${t}`);this.name=e,this.units=i,this.tileSize=n,this.buffer=o,this.pixelFormat=jy[r],this.dataIndex=s,this.bandShape=[n+2*o,n+2*o,Vy[this.pixelFormat]],this._decodedBlocks=function(t=1e3,e=0,i=!1){if(isNaN(t)||t=e&&t=0}hasDataForBand(t){const{blockIndex:e}=this.getBlockForBand(t);return e>=0&&!!this._decodedBlocks.get(e.toString())}getBandView(t){const{blockIndex:e,blockBandIndex:i}=this.getBlockForBand(t),n=this._decodedBlocks.get(e.toString());if(!n)throw new fy(`Data for band ${JSON.stringify(t)} of layer "${this.name}" not decoded.`);const r=this.dataIndex[e],o=this.bandShape.reduce(((t,e)=>t*e),1),s=i*o,a=n.subarray(s,s+o);return{data:a,bytes:new Uint8Array(a.buffer).subarray(a.byteOffset,a.byteOffset+a.byteLength),tileSize:this.tileSize,buffer:this.buffer,offset:r.offset,scale:r.scale}}}class Hy{constructor(t,e,i){this.tasks=t,this._onCancel=e,this._onComplete=i,this._finalized=!1}cancel(){this._finalized||(this._onCancel(),this._finalized=!0)}complete(t,e){this._finalized||(this._onComplete(t,e),this._finalized=!0)}}Zy.performDecoding=function(t,e){return Promise.all(e.tasks.map((e=>{const{layerName:i,firstByte:n,lastByte:r,pixelFormat:o,blockShape:s,blockIndex:a,filters:l,codec:c}=e,d=new Uint8Array(t).subarray(n,r+1),u=new Uint32Array(s[0]*s[1]*s[2]);let h;if("gzip_data"!==c)throw new Error(`Unhandled codec: ${c}`);return h=function(t,e){if(!globalThis.DecompressionStream&&"gzip_data"===e)return Promise.resolve(((o=function(t){31==t[0]&&139==t[1]&&8==t[2]||By(6,"invalid gzip data");var e=t[3],i=10;4&e&&(i+=2+(t[10]|t[11]>3&1)+(e>>4&1);n>0;n-=!t[i++]);return i+(2&e)}(r=t))+8>r.length&&By(6,"invalid gzip data"),function(t,e,i){var n=t.length;if(!n||e.f&&!e.l)return i||new my(0);var r=!i,o=r||2!=e.i,s=e.i;r&&(i=new my(3*n));var a,l,c=function(t){var e=i.length;if(t>e){var n=new my(Math.max(2*e,t));n.set(i),i=n}},d=e.f||0,u=e.p||0,h=e.b||0,p=e.l,f=e.d,m=e.m,_=e.n,g=8*n;do{if(!p){d=zy(t,u,1);var y=zy(t,u+1,3);if(u+=3,!y){var v=t[(L=4+((u+7)/8|0))-4]|t[L-3]n){s&&By(0);break}o&&c(h+v),i.set(t.subarray(L,x),h),e.b=h+=v,e.p=u=8*x,e.f=d;continue}if(1==y)p=$y,f=ky,m=9,_=5;else if(2==y){var b=zy(t,u,31)+257,w=zy(t,u+10,15)+4,T=b+zy(t,u+5,31)+1;u+=14;for(var S=new my(T),E=new my(19),M=0;M>4)g){s&&By(0);break}}o&&c(h+131072);for(var R=(1>4;if((u+=15&$)>g){s&&By(0);break}if($||By(2),F264&&(N=zy(t,u,(1>4;if(U||By(3),u+=15&U,z=Ey[j],j>3){var V=vy[j];z+=Ry(t,u)&(1g){s&&By(0);break}o&&c(h+131072);var G=h+N;if(ha.length)&&(l=a.length),new my(a.subarray(0,l))):i.subarray(0,h)}(r.subarray(o,-8),{i:2},new my(((i=r)[(n=i.length)-4]|i[n-3]>>0))));var i,n,r,o;const s=Uy[e];if(!s)throw new Error(`Unhandled codec: ${e}`);const a=new globalThis.DecompressionStream(s);return new Response(new Blob([t]).stream().pipeThrough(a)).arrayBuffer().then((t=>new Uint8Array(t)))}(d,c).then((t=>(function(t,e){t.readFields(ly,e)}(new Lm(t),u),new(0,Gy[o])(u.buffer)))),h.then((t=>{for(let e=l.length-1;e>=0;e--)switch(l[e]){case"delta_filter":uy(t,s);break;case"zigzag_filter":hy(t);break;case"bitshuffle_filter":py(t,o);break;default:throw new Error(`Unhandled filter "${l[e]}"`)}return{layerName:i,blockIndex:a,data:t}})).catch((t=>{throw t}))})))};class Wy extends ey{constructor(t,e,i,n,r){super(t,e,i,n,r),this._workQueue=[],this._fetchQueue=[],this._isHeaderLoaded=!1}setTexture(t,e){const i=e.context,n=i.gl;this.texture=this.texture||e.getTileTexture(t.width),this.texture&&this.texture instanceof Vg?this.texture.update(t,{useMipmap:!1,premultiply:!1}):this.texture=new Vg(i,t,n.RGBA,{useMipmap:!1,premultiply:!1})}flushQueues(){for(;this._workQueue.length;)this._workQueue.pop()();for(;this._fetchQueue.length;)this._fetchQueue.pop()()}fetchHeader(t=16384,e){const i=this._mrt=new Zy(30),n=Object.assign({},this.requestParams,{headers:{Range:"bytes=0-"+(t-1)}});return this.entireBuffer=null,this.request=en(n,((n,r,o,s)=>{if(n)e(n);else try{const n=i.getHeaderLength(r);if(n>t)return void(this.request=this.fetchHeader(n,e));i.parseHeader(r),this._isHeaderLoaded=!0;let a=0;for(const t of Object.values(i.layers))a=Math.max(a,t.dataIndex[t.dataIndex.length-1].last_byte);r.byteLength>=a&&(this.entireBuffer=r),e(null,this.entireBuffer||r,o,s)}catch(t){e(t)}})),this.request}fetchBand(t,e,i){const n=this._mrt;if(!this._isHeaderLoaded||!n)return void i(new Error("Tile header is not ready"));const r=this.actor;if(!r)return void i(new Error("Can't fetch tile band without an actor"));let o;const s=(n,r)=>{o.complete(n,r),n?i(n):(this.updateTextureDescriptor(t,e),i(null,this.textureDescriptor&&this.textureDescriptor.img))},a=(t,e)=>{if(t)return i(t);const n=r.send("decodeRasterArray",{buffer:e,task:o},s,void 0,!0);this._workQueue.push((()=>{n&&n.cancel(),o.cancel()}))},l=n.getLayer(t);if(!l)return void i(new Error(`Unknown sourceLayer "${t}"`));if(l.hasDataForBand(e))return this.updateTextureDescriptor(t,e),void i(null,this.textureDescriptor?this.textureDescriptor.img:null);const c=l.getDataRange([e]);if(o=n.createDecodingTask(c),!o||o.tasks.length)if(this.flushQueues(),this.entireBuffer)a(null,this.entireBuffer.slice(c.firstByte,c.lastByte+1));else{const t=Object.assign({},this.requestParams,{headers:{Range:`bytes=${c.firstByte}-${c.lastByte}`}}),e=en(t,a);this._fetchQueue.push((()=>{e.cancel(),o.cancel()}))}else i(null)}updateNeeded(t,e){return(!this.textureDescriptor||this.textureDescriptor.band!==e||this.textureDescriptor.layer!==t)&&"errored"!==this.state}updateTextureDescriptor(t,e){if(!this._mrt)return;const i=this._mrt.getLayer(t);if(!i||!i.hasBand(e)||!i.hasDataForBand(e))return;const{bytes:n,tileSize:r,buffer:o,offset:s,scale:a}=i.getBandView(e),l=r+2*o,c={data:n,width:l,height:l},d=this.texture;d&&d instanceof Vg&&d.update(c,{useMipmap:!1,premultiply:!1}),this.textureDescriptor={layer:t,band:e,img:c,buffer:o,offset:s,tileSize:r,format:i.pixelFormat,mix:[a,256*a,65536*a,16777216*a]}}}class Yy{constructor(t,e){this.max=t,this.onRemove=e,this.reset()}reset(){for(const t in this.data)for(const e of this.data[t])e.timeout&&clearTimeout(e.timeout),this.onRemove(e.value);return this.data={},this.order=[],this}add(t,e,i){const n=t.wrapped().key;void 0===this.data[n]&&(this.data[n]=[]);const r={value:e,timeout:void 0};if(void 0!==i&&(r.timeout=setTimeout((()=>{this.remove(t,r)}),i)),this.data[n].push(r),this.order.push(n),this.order.length>this.max){const t=this._getAndRemoveByKey(this.order[0]);t&&this.onRemove(t)}return this}has(t){return t.wrapped().key in this.data}getAndRemove(t){return this.has(t)?this._getAndRemoveByKey(t.wrapped().key):null}_getAndRemoveByKey(t){const e=this.data[t].shift();return e.timeout&&clearTimeout(e.timeout),0===this.data[t].length&&delete this.data[t],this.order.splice(this.order.indexOf(t),1),e.value}getByKey(t){const e=this.data[t];return e?e[0].value:null}get(t){return this.has(t)?this.data[t.wrapped().key][0].value:null}remove(t,e){if(!this.has(t))return this;const i=t.wrapped().key,n=void 0===e?0:this.data[i].indexOf(e),r=this.data[i][n];return this.data[i].splice(n,1),r.timeout&&clearTimeout(r.timeout),0===this.data[i].length&&delete this.data[i],this.onRemove(r.value),this.order.splice(this.order.indexOf(i),1),this}setMaxSize(t){for(this.max=t;this.order.length>this.max;){const t=this._getAndRemoveByKey(this.order[0]);t&&this.onRemove(t)}return this}filter(t){const e=[];for(const i in this.data)for(const n of this.data[i])t(n.value)||e.push(n);for(const t of e)this.remove(t.value.tileID,t)}}class Xy extends zn{constructor(t,e,i){super(),this.id=t,this._onlySymbols=i,e.on("data",(t=>{"source"===t.dataType&&"metadata"===t.sourceDataType&&(this._sourceLoaded=!0),this._sourceLoaded&&!this._paused&&"source"===t.dataType&&"content"===t.sourceDataType&&(this.reload(),this.transform&&this.update(this.transform))})),e.on("error",(()=>{this._sourceErrored=!0})),this._source=e,this._tiles={},this._cache=new Yy(0,this._unloadTile.bind(this)),this._timers={},this._cacheTimers={},this._minTileCacheSize=e.minTileCacheSize,this._maxTileCacheSize=e.maxTileCacheSize,this._loadedParentTiles={},this.castsShadows=!1,this.tileCoverLift=0,this._coveredTiles={},this._shadowCasterTiles={},this._state=new km,this._isRaster="raster"===this._source.type||"raster-dem"===this._source.type||"raster-array"===this._source.type||"custom"===this._source.type&&"raster"===this._source._dataType}onAdd(t){this.map=t,this._minTileCacheSize=void 0===this._minTileCacheSize&&t?t._minTileCacheSize:this._minTileCacheSize,this._maxTileCacheSize=void 0===this._maxTileCacheSize&&t?t._maxTileCacheSize:this._maxTileCacheSize}loaded(){if(this._sourceErrored)return!0;if(!this._sourceLoaded)return!1;if(!this._source.loaded())return!1;for(const t in this._tiles){const e=this._tiles[t];if("errored"!==e.state&&("loaded"!==e.state||!e.bucketsLoaded()))return!1}return!0}getSource(){return this._source}pause(){this._paused=!0}resume(){if(!this._paused)return;const t=this._shouldReloadOnResume;this._paused=!1,this._shouldReloadOnResume=!1,t&&this.reload(),this.transform&&this.update(this.transform)}_loadTile(t,e){return t.isSymbolTile=this._onlySymbols,t.isExtraShadowCaster=this._shadowCasterTiles[t.tileID.key],this._source.loadTile(t,e)}_unloadTile(t){if(this._source.unloadTile)return this._source.unloadTile(t)}_abortTile(t){if(this._source.abortTile)return this._source.abortTile(t)}serialize(){return this._source.serialize()}prepare(t){this._source.prepare&&this._source.prepare(),this._state.coalesceChanges(this._tiles,this.map?this.map.painter:null);for(const e in this._tiles){const i=this._tiles[e];i.upload(t),i.prepare(this.map.style.imageManager,this.map?this.map.painter:null,this._source.scope)}}getIds(){return ti(this._tiles).map((t=>t.tileID)).sort(Ky).map((t=>t.key))}getRenderableIds(t,e){const i=[];for(const n in this._tiles)this._isIdRenderable(+n,t,e)&&i.push(this._tiles[n]);return t?i.sort(((t,e)=>{const i=t.tileID,n=e.tileID,r=new Ue(i.canonical.x,i.canonical.y)._rotate(this.transform.angle),o=new Ue(n.canonical.x,n.canonical.y)._rotate(this.transform.angle);return i.overscaledZ-n.overscaledZ||o.y-r.y||o.x-r.x})).map((t=>t.tileID.key)):i.map((t=>t.tileID)).sort(Ky).map((t=>t.key))}hasRenderableParent(t){const e=this.findLoadedParent(t,0);return!!e&&this._isIdRenderable(e.tileID.key)}_isIdRenderable(t,e,i){return this._tiles[t]&&this._tiles[t].hasData()&&!this._coveredTiles[t]&&(e||!this._tiles[t].holdingForFade())&&(i||!this._shadowCasterTiles[t])}reload(){if(this._paused)this._shouldReloadOnResume=!0;else{this._cache.reset();for(const t in this._tiles)"errored"!==this._tiles[t].state&&this._reloadTile(+t,"reloading")}}_reloadTile(t,e){const i=this._tiles[t];i&&("loading"!==i.state&&(i.state=e),this._loadTile(i,this._tileLoaded.bind(this,i,t,e)))}_tileLoaded(t,e,i,n){if(n)if(t.state="errored",404!==n.status)this._source.fire(new $n(n,{tile:t}));else{if(!(t.tileID.key in this._loadedParentTiles))return void this._source.fire(new Pn("data",{dataType:"source",sourceDataType:"error",sourceId:this._source.id}));if("raster-dem"===this._source.type&&this.usedForTerrain&&this.map.painter.terrain){const t=this.map.painter.terrain;this.update(this.transform,t.getScaledDemTileSize(),!0),t.resetTileLookupCache(this.id)}else this.update(this.transform)}else t.timeAdded=ki.now(),"expired"===i&&(t.refreshedUponExpiration=!0),this._setTileReloadTimer(e,t),"raster-dem"===this._source.type&&t.dem&&this._backfillDEM(t),this._state.initializeTileState(t,this.map?this.map.painter:null),this._source.fire(new Pn("data",{dataType:"source",tile:t,coord:t.tileID,sourceCacheId:this.id}))}_backfillDEM(t){const e=this.getRenderableIds();for(let n=0;n1||(Math.abs(i)>1&&(1===Math.abs(i+r)?i+=r:1===Math.abs(i-r)&&(i-=r)),e.dem&&t.dem&&(t.dem.backfillBorder(e.dem,i,n),t.neighboringTiles&&t.neighboringTiles[o]&&(t.neighboringTiles[o].backfilled=!0)))}}getTile(t){return this.getTileByID(t.key)}getTileByID(t){return this._tiles[t]}_retainLoadedChildren(t,e,i,n){for(const r in this._tiles){let o=this._tiles[r];if(n[r]||!o.hasData()||o.tileID.overscaledZi)continue;let s=o.tileID;for(;o&&o.tileID.overscaledZ>e+1;){const t=o.tileID.scaledTo(o.tileID.overscaledZ-1);o=this._tiles[t.key],o&&o.hasData()&&(s=t)}let a=s;for(;a.overscaledZ>e;)if(a=a.scaledTo(a.overscaledZ-1),t[a.key]){n[s.key]=s;break}}}findLoadedParent(t,e){if(t.key in this._loadedParentTiles){const i=this._loadedParentTiles[t.key];return i&&i.tileID.overscaledZ>=e?i:null}for(let i=t.overscaledZ-1;i>=e;i--){const e=t.scaledTo(i),n=this._getLoadedTile(e);if(n)return n}}_getLoadedTile(t){const e=this._tiles[t.key];return e&&e.hasData()?e:this._cache.getByKey(this._source.reparseOverscaled?t.wrapped().key:t.canonical.key)}updateCacheSize(t,e){e=e||this._source.tileSize;const i=Math.ceil(t.width/e)+1,n=Math.ceil(t.height/e)+1,r=Math.floor(i*n*5),o="number"==typeof this._minTileCacheSize?Math.max(this._minTileCacheSize,r):r,s="number"==typeof this._maxTileCacheSize?Math.min(this._maxTileCacheSize,o):o;this._cache.setMaxSize(s)}handleWrapJump(t){const e=Math.round((t-(void 0===this._prevLng?t:this._prevLng))/360);if(this._prevLng=t,e){const t={};for(const i in this._tiles){const n=this._tiles[i];n.tileID=n.tileID.unwrapTo(n.tileID.wrap+e),t[n.tileID.key]=n}this._tiles=t;for(const t in this._timers)clearTimeout(this._timers[t]),delete this._timers[t];for(const t in this._tiles)this._setTileReloadTimer(+t,this._tiles[t])}}update(t,e,i,n){if(this.transform=t,!this._sourceLoaded||this._paused||this.transform.freezeTileCoverage)return;if(this.usedForTerrain&&!i)return;let r;if(this.updateCacheSize(t,e),"globe"!==this.transform.projection.name&&this.handleWrapJump(this.transform.center.lng),this._shadowCasterTiles={},this._coveredTiles={},this.used||this.usedForTerrain){if(this._source.tileID)r=t.getVisibleUnwrappedCoordinates(this._source.tileID).map((t=>new vd(t.canonical.z,t.wrap,t.canonical.z,t.canonical.x,t.canonical.y)));else if(0!==this.tileCoverLift){const n=t.clone();n.tileCoverLift=this.tileCoverLift,r=n.coveringTiles({tileSize:e||this._source.tileSize,minzoom:this._source.minzoom,maxzoom:this._source.maxzoom,roundZoom:this._source.roundZoom&&!i,reparseOverscaled:this._source.reparseOverscaled,isTerrainDEM:this.usedForTerrain}),this._source.minzoomt(e)))}}else r=[];if(r.length>0&&this.castsShadows&&n&&"globe"!==this.transform.projection.name&&!this.usedForTerrain&&!Jy(this._source.type)){const o=t.coveringZoomLevel({tileSize:e||this._source.tileSize,roundZoom:this._source.roundZoom&&!i}),s=Math.min(o,this._source.maxzoom),a=t.extendTileCoverForShadows(r,n,s);for(const t of a)this._shadowCasterTiles[t.key]=!0,r.push(t)}const o=this._updateRetainedTiles(r);if(Jy(this._source.type)&&0!==r.length){const t={},e={},i=Object.keys(o);for(const n of i){const i=o[n],r=this._tiles[n];if(!r||r.fadeEndTime&&r.fadeEndTimen;){r=r.scaledTo(r.overscaledZ-1);const n=this._tiles[r.key];if(n&&n.hasData()&&e[r.key]){o[t]=i.tileID;break}}}for(const e in t)o[e]||(this._coveredTiles[e]=!0,o[e]=t[e])}for(const t in o)this._tiles[t].clearFadeHold();const s=function(t,e){const i=[];for(const n in t)n in e||i.push(n);return i}(this._tiles,o);for(const t of s){const e=this._tiles[t];e.hasSymbolBuckets&&!e.holdingForFade()?e.setHoldDuration(this.map._fadeDuration):e.hasSymbolBuckets&&!e.symbolFadeFinished()||this._removeTile(+t)}this._updateLoadedParentTileCache(),this._onlySymbols&&this._source.afterUpdate&&this._source.afterUpdate()}releaseSymbolFadeTiles(){for(const t in this._tiles)this._tiles[t].holdingForFade()&&this._removeTile(+t)}_updateRetainedTiles(t){const e={};if(0===t.length)return e;const i={},n=t.reduce(((t,e)=>Math.min(t,e.overscaledZ)),1/0),r=t[0].overscaledZ,o=Math.max(r-Xy.maxOverzooming,this._source.minzoom),s=Math.max(r+Xy.maxUnderzooming,this._source.minzoom),a={};for(const i of t){const t=this._addTile(i);e[i.key]=i,t.hasData()||n=this._source.maxzoom){const t=n.children(this._source.maxzoom)[0],i=this.getTile(t);if(i&&i.hasData()){e[t.key]=t;continue}}else{const t=n.children(this._source.maxzoom);if(e[t[0].key]&&e[t[1].key]&&e[t[2].key]&&e[t[3].key])continue}let r=t.wasRequested();for(let s=n.overscaledZ-1;s>=o;--s){const o=n.scaledTo(s);if(i[o.key])break;if(i[o.key]=!0,t=this.getTile(o),!t&&r&&(t=this._addTile(o)),t&&(e[o.key]=o,r=t.wasRequested(),t.hasData()))break}}return e}_updateLoadedParentTileCache(){this._loadedParentTiles={};for(const t in this._tiles){const e=[];let i,n=this._tiles[t].tileID;for(;n.overscaledZ>0;){if(n.key in this._loadedParentTiles){i=this._loadedParentTiles[n.key];break}e.push(n.key);const t=n.scaledTo(n.overscaledZ-1);if(i=this._getLoadedTile(t),i)break;n=t}for(const t of e)this._loadedParentTiles[t]=i}}_addTile(t){let e=this._tiles[t.key];if(e)return!0!==e.isExtraShadowCaster||!!this._shadowCasterTiles[t.key]||this._reloadTile(t.key,"reloading"),e;e=this._cache.getAndRemove(t),e&&(this._setTileReloadTimer(t.key,e),e.tileID=t,this._state.initializeTileState(e,this.map?this.map.painter:null),this._cacheTimers[t.key]&&(clearTimeout(this._cacheTimers[t.key]),delete this._cacheTimers[t.key],this._setTileReloadTimer(t.key,e)));const i=Boolean(e);if(!i){const i=this.map?this.map.painter:null,n=this._source.tileSize*t.overscaleFactor();e="raster-array"===this._source.type?new Wy(t,n,this.transform.tileZoom,i,this._isRaster):new ey(t,n,this.transform.tileZoom,i,this._isRaster),this._loadTile(e,this._tileLoaded.bind(this,e,t.key,e.state))}return e?(e.uses++,this._tiles[t.key]=e,i||this._source.fire(new Pn("dataloading",{tile:e,coord:e.tileID,dataType:"source"})),e):null}_setTileReloadTimer(t,e){t in this._timers&&(clearTimeout(this._timers[t]),delete this._timers[t]);const i=e.getExpiryTimeout();i&&(this._timers[t]=setTimeout((()=>{this._reloadTile(t,"expired"),delete this._timers[t]}),i))}_removeTile(t){const e=this._tiles[t];e&&(e.uses--,delete this._tiles[t],this._timers[t]&&(clearTimeout(this._timers[t]),delete this._timers[t]),e.uses>0||(e.hasData()&&"reloading"!==e.state||"empty"===e.state?this._cache.add(e.tileID,e,e.getExpiryTimeout()):(e.aborted=!0,this._abortTile(e),this._unloadTile(e))))}clearTiles(){this._shouldReloadOnResume=!1,this._paused=!1;for(const t in this._tiles)this._removeTile(+t);this._source._clear&&this._source._clear(),this._cache.reset(),this.map&&this.usedForTerrain&&this.map.painter.terrain&&this.map.painter.terrain.resetTileLookupCache(this.id)}tilesIn(t,e,i){const n=[],r=this.transform;if(!r)return n;const o="globe"===r.projection.name,s=Ed(r.center.lng);for(const a in this._tiles){const l=this._tiles[a];if(i&&l.clearQueryDebugViz(),l.holdingForFade())continue;let c;if(o){const t=l.tileID.canonical;if(0===t.z){const e=[Math.abs(Xe(s,...Qy(t,-1))-s),Math.abs(Xe(s,...Qy(t,1))-s)];c=[0,2*e.indexOf(Math.min(...e))-1]}else{const e=[Math.abs(Xe(s,...Qy(t,-1))-s),Math.abs(Xe(s,...Qy(t,0))-s),Math.abs(Xe(s,...Qy(t,1))-s)];c=[e.indexOf(Math.min(...e))-1]}}else c=[0];for(const i of c){const o=t.containsTile(l,r,e,i);o&&n.push(o)}}return n}getShadowCasterCoordinates(){return this._getRenderableCoordinates(!1,!0)}getVisibleCoordinates(t){return this._getRenderableCoordinates(t)}_getRenderableCoordinates(t,e){const i=this.getRenderableIds(t,e).map((t=>this._tiles[t].tileID)),n="globe"===this.transform.projection.name;for(const t of i)t.projMatrix=this.transform.calculateProjMatrix(t.toUnwrapped()),t.expandedProjMatrix=n?this.transform.calculateProjMatrix(t.toUnwrapped(),!1,!0):t.projMatrix;return i}sortCoordinatesByDistance(t){const e=t.slice(),i=this.transform._camera.position,n=this.transform._camera.forward(),r={};for(const t of e){const e=1/(1r[t.key]-r[e.key])),e}hasTransition(){if(this._source.hasTransition())return!0;if(Jy(this._source.type))for(const t in this._tiles){const e=this._tiles[t];if(void 0!==e.fadeEndTime&&e.fadeEndTime>=ki.now())return!0}return!1}setFeatureState(t,e,i){this._state.updateState(t=t||"_geojsonTileLayer",e,i)}removeFeatureState(t,e,i){this._state.removeFeatureState(t=t||"_geojsonTileLayer",e,i)}getFeatureState(t,e){return this._state.getState(t=t||"_geojsonTileLayer",e)}setDependencies(t,e,i){const n=this._tiles[t];n&&n.setDependencies(e,i)}reloadTilesForDependencies(t,e){for(const i in this._tiles)this._tiles[i].hasDependency(t,e)&&this._reloadTile(+i,"reloading");this._cache.filter((i=>!i.hasDependency(t,e)))}_preloadTiles(t,e){if(!this._sourceLoaded){const i=()=>{this._sourceLoaded&&(this._source.off("data",i),this._preloadTiles(t,e))};return void this._source.on("data",i)}const i=new Map,n=Array.isArray(t)?t:[t],r=this.map.painter.terrain,o=this.usedForTerrain&&r?r.getScaledDemTileSize():this._source.tileSize;for(const t of n){const e=t.coveringTiles({tileSize:o,minzoom:this._source.minzoom,maxzoom:this._source.maxzoom,roundZoom:this._source.roundZoom&&!this.usedForTerrain,reparseOverscaled:this._source.reparseOverscaled,isTerrainDEM:this.usedForTerrain});for(const t of e)i.set(t.key,t);this.usedForTerrain&&t.updateElevation(!1)}Qe(Array.from(i.values()),((t,e)=>{const i=new ey(t,this._source.tileSize*t.overscaleFactor(),this.transform.tileZoom,this.map.painter,this._isRaster);this._loadTile(i,(t=>{"raster-dem"===this._source.type&&i.dem&&this._backfillDEM(i),e(t,i)}))}),e)}}function Ky(t,e){const i=Math.abs(2*t.wrap)-+(t.wrap0?e+2*t:t}tv.useIntegerZoom=!0;const iv=new ol({"symbol-placement":new il(sl.layout_symbol["symbol-placement"]),"symbol-spacing":new il(sl.layout_symbol["symbol-spacing"]),"symbol-avoid-edges":new il(sl.layout_symbol["symbol-avoid-edges"]),"symbol-sort-key":new nl(sl.layout_symbol["symbol-sort-key"]),"symbol-z-order":new il(sl.layout_symbol["symbol-z-order"]),"symbol-z-elevate":new il(sl.layout_symbol["symbol-z-elevate"]),"icon-allow-overlap":new il(sl.layout_symbol["icon-allow-overlap"]),"icon-ignore-placement":new il(sl.layout_symbol["icon-ignore-placement"]),"icon-optional":new il(sl.layout_symbol["icon-optional"]),"icon-rotation-alignment":new il(sl.layout_symbol["icon-rotation-alignment"]),"icon-size":new nl(sl.layout_symbol["icon-size"]),"icon-text-fit":new nl(sl.layout_symbol["icon-text-fit"]),"icon-text-fit-padding":new nl(sl.layout_symbol["icon-text-fit-padding"]),"icon-image":new nl(sl.layout_symbol["icon-image"]),"icon-rotate":new nl(sl.layout_symbol["icon-rotate"]),"icon-padding":new il(sl.layout_symbol["icon-padding"]),"icon-keep-upright":new il(sl.layout_symbol["icon-keep-upright"]),"icon-offset":new nl(sl.layout_symbol["icon-offset"]),"icon-anchor":new nl(sl.layout_symbol["icon-anchor"]),"icon-pitch-alignment":new il(sl.layout_symbol["icon-pitch-alignment"]),"text-pitch-alignment":new il(sl.layout_symbol["text-pitch-alignment"]),"text-rotation-alignment":new il(sl.layout_symbol["text-rotation-alignment"]),"text-field":new nl(sl.layout_symbol["text-field"]),"text-font":new nl(sl.layout_symbol["text-font"]),"text-size":new nl(sl.layout_symbol["text-size"]),"text-max-width":new nl(sl.layout_symbol["text-max-width"]),"text-line-height":new nl(sl.layout_symbol["text-line-height"]),"text-letter-spacing":new nl(sl.layout_symbol["text-letter-spacing"]),"text-justify":new nl(sl.layout_symbol["text-justify"]),"text-radial-offset":new nl(sl.layout_symbol["text-radial-offset"]),"text-variable-anchor":new il(sl.layout_symbol["text-variable-anchor"]),"text-anchor":new nl(sl.layout_symbol["text-anchor"]),"text-max-angle":new il(sl.layout_symbol["text-max-angle"]),"text-writing-mode":new il(sl.layout_symbol["text-writing-mode"]),"text-rotate":new nl(sl.layout_symbol["text-rotate"]),"text-padding":new il(sl.layout_symbol["text-padding"]),"text-keep-upright":new il(sl.layout_symbol["text-keep-upright"]),"text-transform":new nl(sl.layout_symbol["text-transform"]),"text-offset":new nl(sl.layout_symbol["text-offset"]),"text-allow-overlap":new il(sl.layout_symbol["text-allow-overlap"]),"text-ignore-placement":new il(sl.layout_symbol["text-ignore-placement"]),"text-optional":new il(sl.layout_symbol["text-optional"]),visibility:new il(sl.layout_symbol.visibility)});var nv={paint:new ol({"icon-opacity":new nl(sl.paint_symbol["icon-opacity"]),"icon-occlusion-opacity":new nl(sl.paint_symbol["icon-occlusion-opacity"]),"icon-emissive-strength":new nl(sl.paint_symbol["icon-emissive-strength"]),"text-emissive-strength":new nl(sl.paint_symbol["text-emissive-strength"]),"icon-color":new nl(sl.paint_symbol["icon-color"]),"icon-halo-color":new nl(sl.paint_symbol["icon-halo-color"]),"icon-halo-width":new nl(sl.paint_symbol["icon-halo-width"]),"icon-halo-blur":new nl(sl.paint_symbol["icon-halo-blur"]),"icon-translate":new il(sl.paint_symbol["icon-translate"]),"icon-translate-anchor":new il(sl.paint_symbol["icon-translate-anchor"]),"icon-image-cross-fade":new nl(sl.paint_symbol["icon-image-cross-fade"]),"text-opacity":new nl(sl.paint_symbol["text-opacity"]),"text-occlusion-opacity":new nl(sl.paint_symbol["text-occlusion-opacity"]),"text-color":new nl(sl.paint_symbol["text-color"],{runtimeType:Qn,getOverride:t=>t.textColor,hasOverride:t=>!!t.textColor}),"text-halo-color":new nl(sl.paint_symbol["text-halo-color"]),"text-halo-width":new nl(sl.paint_symbol["text-halo-width"]),"text-halo-blur":new nl(sl.paint_symbol["text-halo-blur"]),"text-translate":new il(sl.paint_symbol["text-translate"]),"text-translate-anchor":new il(sl.paint_symbol["text-translate-anchor"]),"icon-color-saturation":new il(sl.paint_symbol["icon-color-saturation"]),"icon-color-contrast":new il(sl.paint_symbol["icon-color-contrast"]),"icon-color-brightness-min":new il(sl.paint_symbol["icon-color-brightness-min"]),"icon-color-brightness-max":new il(sl.paint_symbol["icon-color-brightness-max"])}),layout:iv};class rv{constructor(t){this.type=t.property.overrides?t.property.overrides.runtimeType:Yn,this.defaultValue=t}evaluate(t){if(t.formattedSection){const e=this.defaultValue.property.overrides;if(e&&e.hasOverride(t.formattedSection))return e.getOverride(t.formattedSection)}return t.feature&&t.featureState?this.defaultValue.evaluate(t.feature,t.featureState):this.defaultValue.property.specification.default}eachChild(t){this.defaultValue.isConstant()||t(this.defaultValue.value._styleExpression.expression)}outputDefined(){return!1}serialize(){return null}}ba(rv,"FormatSectionOverride",{omit:["defaultValue"]});class ov extends Ml{constructor(e,i,n,r){super(e,nv,i,n,r),this._colorAdjustmentMatrix=t.ad.identity([]),this.hasInitialOcclusionOpacityProperties=void 0!==e.paint&&("icon-occlusion-opacity"in e.paint||"text-occlusion-opacity"in e.paint)}recalculate(t,e){super.recalculate(t,e),"auto"===this.layout.get("icon-rotation-alignment")&&(this.layout._values["icon-rotation-alignment"]="point"!==this.layout.get("symbol-placement")?"map":"viewport"),"auto"===this.layout.get("text-rotation-alignment")&&(this.layout._values["text-rotation-alignment"]="point"!==this.layout.get("symbol-placement")?"map":"viewport"),"auto"===this.layout.get("text-pitch-alignment")&&(this.layout._values["text-pitch-alignment"]=this.layout.get("text-rotation-alignment")),"auto"===this.layout.get("icon-pitch-alignment")&&(this.layout._values["icon-pitch-alignment"]=this.layout.get("icon-rotation-alignment"));const i=this.layout.get("text-writing-mode");if(i){const t=[];for(const e of i)t.indexOf(e)i in t?String(t[i]):""))}(e.properties,r)}createBucket(t){return new jg(t)}queryRadius(){return 0}queryIntersectsFeature(){return!1}_setPaintOverrides(){for(const t of nv.paint.overridableProperties){if(!ov.hasPaintOverride(this.layout,t))continue;const e=this.paint.get(t),i=new rv(e),n=new la(i,e.property.specification,this.scope,this.options);let r=null;r="constant"===e.value.kind||"source"===e.value.kind?new ua("source",n):new ha("composite",n,e.value.zoomStops,e.value._interpolationType),this.paint._values[t]=new tl(e.property,r,e.parameters)}}_handleOverridablePaintPropertyUpdate(t,e,i){return!(!this.layout||e.isDataDriven()||i.isDataDriven())&&ov.hasPaintOverride(this.layout,t)}static hasPaintOverride(t,e){const i=t.get("text-field"),n=nv.paint.properties[e];let r=!1;const o=t=>{for(const e of t)if(n.overrides&&n.overrides.hasOverride(e))return void(r=!0)};if("constant"===i.value.kind&&i.value.value instanceof pr)o(i.value.value.sections);else if("source"===i.value.kind){const t=e=>{r||(e instanceof vr&&gr(e.value)===nr?o(e.value.sections):e instanceof Tr?o(e.sections):e.eachChild(t))},e=i.value;e._styleExpression&&t(e._styleExpression.expression)}return r}getProgramIds(){const t=0!==this.paint.get("icon-opacity").constantOr(1),e=0!==this.paint.get("text-opacity").constantOr(1),i=[];return t&&i.push("symbolIcon"),e&&i.push("symbolSDF"),i}getDefaultProgramParams(t,e,i){return{config:new Wc(this,{zoom:e,lut:i}),overrideFog:!1}}}const sv=new ol({visibility:new il(sl.layout_background.visibility)});var av={paint:new ol({"background-color":new il(sl.paint_background["background-color"]),"background-pattern":new il(sl.paint_background["background-pattern"]),"background-opacity":new il(sl.paint_background["background-opacity"]),"background-emissive-strength":new il(sl.paint_background["background-emissive-strength"])}),layout:sv};const lv=new ol({visibility:new il(sl.layout_raster.visibility)});var cv={paint:new ol({"raster-opacity":new il(sl.paint_raster["raster-opacity"]),"raster-color":new rl(sl.paint_raster["raster-color"]),"raster-color-mix":new il(sl.paint_raster["raster-color-mix"]),"raster-color-range":new il(sl.paint_raster["raster-color-range"]),"raster-hue-rotate":new il(sl.paint_raster["raster-hue-rotate"]),"raster-brightness-min":new il(sl.paint_raster["raster-brightness-min"]),"raster-brightness-max":new il(sl.paint_raster["raster-brightness-max"]),"raster-saturation":new il(sl.paint_raster["raster-saturation"]),"raster-contrast":new il(sl.paint_raster["raster-contrast"]),"raster-resampling":new il(sl.paint_raster["raster-resampling"]),"raster-fade-duration":new il(sl.paint_raster["raster-fade-duration"]),"raster-emissive-strength":new il(sl.paint_raster["raster-emissive-strength"]),"raster-array-band":new il(sl.paint_raster["raster-array-band"]),"raster-elevation":new il(sl.paint_raster["raster-elevation"])}),layout:lv};function dv(e,i,n,r,o,s,a,l){const c=[e,i,1,n,r,1,o,s,1],d=[a,l,1],u=t.bC.adjoint([],c),[h,p,f]=t._.transformMat3(d,d,u);return t.bC.multiply(c,c,[h,0,0,0,p,0,0,0,f])}function uv(e,i,n,r,o,s,a,l){const c=function(e,i,n,r,o,s,a,l){const c=dv(0,0,1,0,1,1,0,1),d=dv(e,i,n,r,o,s,a,l),u=t.bC.adjoint([],c);return t.bC.multiply(d,d,u)}(e,i,n,r,o,s,a,l);return[c[2]/c[8]/uo,c[5]/c[8]/uo]}function hv(t){return[t[0],Math.min(Math.max(t[1],-Pd),Pd)]}class pv extends zn{constructor(t,e,i,n){super(),this.id=t,this.dispatcher=i,this.coordinates=e.coordinates,this.type="image",this.minzoom=0,this.maxzoom=22,this.tileSize=512,this.tiles={},this._loaded=!1,this.onNorthPole=!1,this.onSouthPole=!1,this.setEventedParent(n),this.options=e,this._dirty=!1}load(t,e){if(this._loaded=e||!1,this.fire(new Pn("dataloading",{dataType:"source"})),this.url=this.options.url,!this.url)return t&&(this.coordinates=t),this._loaded=!0,void this._finishLoading();this._imageRequest=an(this.map._requestManager.transformRequest(this.url,Ki.Image),((e,i)=>{this._imageRequest=null,this._loaded=!0,e?this.fire(new $n(e)):i&&(this.image=i instanceof HTMLImageElement?ki.getImageData(i):i,this._dirty=!0,this.width=this.image.width,this.height=this.image.height,t&&(this.coordinates=t),this._finishLoading())}))}loaded(){return this._loaded}updateImage(t){return t.url?(this._imageRequest&&t.url!==this.options.url&&(this._imageRequest.cancel(),this._imageRequest=null),this.options.url=t.url,this.load(t.coordinates,this._loaded),this):this}setTexture(t){if(!(t.handle instanceof WebGLTexture))throw new Error("The provided handle is not a WebGLTexture instance");return this.texture=new Gg(this.map.painter.context,t.handle),this.width=t.dimensions[0],this.height=t.dimensions[1],this._dirty=!1,this._loaded=!0,this._finishLoading(),this}_finishLoading(){this.map&&(this.setCoordinates(this.coordinates),this.fire(new Pn("data",{dataType:"source",sourceDataType:"metadata"})))}onAdd(t){this.map=t,this.load()}onRemove(t){this._imageRequest&&(this._imageRequest.cancel(),this._imageRequest=null),!this.texture||this.texture instanceof Gg||this.texture.destroy(),this.boundsBuffer&&(this.boundsBuffer.destroy(),this.elevatedGlobeVertexBuffer&&this.elevatedGlobeVertexBuffer.destroy(),this.elevatedGlobeIndexBuffer&&this.elevatedGlobeIndexBuffer.destroy())}setCoordinates(t){if(this.coordinates=t,this._boundsArray=void 0,this._unsupportedCoords=!1,!t.length)return this;this.onNorthPole=!1,this.onSouthPole=!1;let e=t[0][1],i=t[0][1];for(const n of t)n[1]>i&&(i=n[1]),n[1]Pd?this.onNorthPole=!0:n1&&(l-=1),new gd(s,l,Math.floor((i+r)/2*a))}(e),this.minzoom=this.maxzoom=this.tileID.z}return this.fire(new Pn("data",{dataType:"source",sourceDataType:"content"})),this}_clear(){this._boundsArray=void 0,this._unsupportedCoords=!1}_prepareData(e){for(const t in this.tiles){const e=this.tiles[t];"loaded"!==e.state&&(e.state="loaded",e.texture=this.texture)}if(this._boundsArray||this.onNorthPole||this.onSouthPole||this._unsupportedCoords)return;const i=eg(new gd(0,0,0),this.map.transform.projection),n=[i.projection.project(this.coordinates[0][0],this.coordinates[0][1]),i.projection.project(this.coordinates[1][0],this.coordinates[1][1]),i.projection.project(this.coordinates[2][0],this.coordinates[2][1]),i.projection.project(this.coordinates[3][0],this.coordinates[3][1])];if(!function(t){const e=t[1].x-t[0].x,i=t[1].y-t[0].y,n=t[2].x-t[1].x,r=t[2].y-t[1].y,o=t[3].x-t[2].x,s=t[3].y-t[2].y,a=t[0].x-t[3].x,l=t[0].y-t[3].y,c=e*r-n*i,d=n*s-o*r,u=o*l-a*s,h=a*i-e*l;return c>0&&d>0&&u>0&&h>0||c{const e=r.projection.project(t[0],t[1]);return ig(r,e)._round()}));this.perspectiveTransform=uv(o.x,o.y,s.x,s.y,a.x,a.y,l.x,l.y);const c=this._boundsArray=new Dl;c.emplaceBack(o.x,o.y,0,0),c.emplaceBack(s.x,s.y,uo,0),c.emplaceBack(l.x,l.y,0,uo),c.emplaceBack(a.x,a.y,uo,uo),this.boundsBuffer&&(this.boundsBuffer.destroy(),this.elevatedGlobeVertexBuffer&&this.elevatedGlobeVertexBuffer.destroy(),this.elevatedGlobeIndexBuffer&&this.elevatedGlobeIndexBuffer.destroy()),this.boundsBuffer=e.createVertexBuffer(c,Jg.members),this.boundsSegments=wc.simpleSegment(0,0,4,2);const d=[],u=function(t){return[hv(t[0]),hv(t[1]),hv(t[2]),hv(t[3])]}(this.coordinates),[h,p,f,m]=function(t){let e=t[0][0],i=e,n=t[0][1],r=n;for(let o=1;oi&&(i=t[o][0]),t[o][1]r&&(r=t[o][1]);return[e,n,i-e,r-n]}(u);{const r=new Dl,[o,s,a,l]=function(t){let e=t[0].x,i=e,n=t[0].y,r=n;for(let o=1;oi&&(i=t[o].x),t[o].yr&&(r=t[o].y);return[e,n,i-e,r-n]}(n),c=t=>[(t.x-o)/a,(t.y-s)/l],[u,_,g,y]=n.map(c),v=function(e,i,n,r,o,s,a,l){const c=dv(0,0,1,0,1,1,0,1),d=dv(e,i,n,r,o,s,a,l),u=t.bC.adjoint([],d);return t.bC.multiply(c,c,u)}(u[0],u[1],_[0],_[1],g[0],g[1],y[0],y[1]);this.elevatedGlobePerspectiveTransform=uv(u[0],u[1],_[0],_[1],g[0],g[1],y[0],y[1]);const x=(e,i)=>{d.push(e.lng);const n=Math.round((e.lng-h)/f*uo),o=Math.round((e.lat-p)/m*uo),s=c(i),a=t._.transformMat3([],[s[0],s[1],1],v),l=Math.round(a[0]/a[2]*uo),u=Math.round(a[1]/a[2]*uo);r.emplaceBack(n,o,l,u)},b=n[3].x-n[0].x,w=n[3].y-n[0].y,T=n[2].x-n[1].x,S=n[2].y-n[1].y;for(let t=0;t{i.emplaceBack(e,n,r);const o=d[e],s=d[n],a=d[r],l=Math.min(Math.min(o,s),a),c=Math.max(Math.max(o,s),a)-l;c>this.maxLongitudeTriangleSize&&(this.maxLongitudeTriangleSize=c),t.push(l+c/2)};for(let t=0;te));i.sort(((e,i)=>t[e]-t[i]));const n=[],r=new Kl;for(let o=0;o{o.segments.push({vertexOffset:0,primitiveOffset:t,vertexLength:e.segments[0].vertexLength,primitiveLength:i,sortKey:void 0,vaos:{}})},a=.51*this.maxLongitudeTriangleSize;if(Math.abs(i[0]-n)0){const n=function(e,i){const n=i.worldSize,r=Cd(1,0)*n*kd(i.center.lat,i.zoom)/Gu(n),o=Cd(1,i.center.lat)*n,s=t.ad.identity([]);return t.ad.rotateY(s,s,Ge(i.center.lng)),t.ad.rotateX(s,s,Ge(i.center.lat)),t.ad.translate(s,s,[0,0,ed]),t.ad.scale(s,s,[r,r,r*o]),t.ad.translate(s,s,[i.point.x-.5*n,i.point.y-.5*n,0]),t.ad.multiply(s,s,e),t.ad.multiply(s,i.globeMatrix,s)}(e,i);return function(e,i,n){const r=(e,i,n)=>{const r=t._.length(e),o=t._.length(i),s=ku(e,i,n);return t._.scale(s,s,1/t._.length(s)*Vn(r,o,n))},o=r([e[0],e[1],e[2]],[i[0],i[1],i[2]],n),s=r([e[4],e[5],e[6]],[i[4],i[5],i[6]],n),a=r([e[8],e[9],e[10]],[i[8],i[9],i[10]],n),l=ku([e[12],e[13],e[14]],[i[12],i[13],i[14]],n);return[o[0],o[1],o[2],0,s[0],s[1],s[2],0,a[0],a[1],a[2],0,l[0],l[1],l[2],1]}(o,n,r)}return o}function kv(t,e,i,n){const r=wu.projectAabbCorners(n,i);let o=Number.MAX_VALUE,s=-1;for(let t=0;tnew Ue(r[t][0],r[t][1]);let l;switch(s){case 0:case 6:l=[a(1),a(5),a(4),a(7),a(3),a(2),a(1)];break;case 1:case 7:l=[a(0),a(4),a(5),a(6),a(2),a(3),a(0)];break;case 3:case 5:l=[a(1),a(0),a(4),a(7),a(6),a(2),a(1)];break;default:l=[a(1),a(5),a(6),a(7),a(3),a(0),a(1)]}if(Yd(t,l))return o}const Dv=Ll([{name:"a_pos_3f",components:3,type:"Float32"}]),zv=Ll([{name:"a_color_3f",components:3,type:"Float32"}]),Rv=Ll([{name:"a_color_4f",components:4,type:"Float32"}]),Ov=Ll([{name:"a_uv_2f",components:2,type:"Float32"}]),Bv=Ll([{name:"a_normal_3f",components:3,type:"Float32"}]),Fv=Ll([{name:"a_normal_matrix0",components:4,type:"Float32"},{name:"a_normal_matrix1",components:4,type:"Float32"},{name:"a_normal_matrix2",components:4,type:"Float32"},{name:"a_normal_matrix3",components:4,type:"Float32"}]),Nv=Ll([{name:"a_pbr",components:4,type:"Uint16"},{name:"a_heightBasedEmissiveStrength",components:3,type:"Float32"}]);class Uv{constructor(t,e,i,n){this.message=(t?`${t}: `:"")+i,n&&(this.identifier=n),null!=e&&e.__line__&&(this.line=e.__line__)}}function jv(t,e){const i=-1===t.indexOf("://");try{return new URL(t,i&&e?"http://example.com":void 0),!0}catch(t){return!1}}class Vv{constructor(t,e){this.feature=t,this.instancedDataOffset=e,this.instancedDataCount=0,this.rotation=[0,0,0],this.scale=[1,1,1],this.translation=[0,0,0]}}class Gv{constructor(){this.instancedDataArray=new oc,this.instancesEvaluatedElevation=[],this.features=[],this.idToFeaturesIndex={}}}class Zv{constructor(t){this.zoom=t.zoom,this.canonical=t.canonical,this.layers=t.layers,this.layerIds=this.layers.map((t=>t.fqid)),this.projection=t.projection,this.index=t.index,this.hasZoomDependentProperties=this.layers[0].isZoomDependent(),this.stateDependentLayerIds=this.layers.filter((t=>t.isStateDependent())).map((t=>t.id)),this.hasPattern=!1,this.instancesPerModel={},this.validForExaggeration=0,this.maxVerticalOffset=0,this.maxScale=0,this.maxHeight=0,this.lookupDim=this.zoom>this.canonical.z?256:this.zoom>15?75:100,this.instanceCount=0,this.terrainElevationMin=0,this.terrainElevationMax=0,this.validForDEMTile={id:null,timestamp:0},this.modelUris=[],this.modelsRequested=!1,this.activeReplacements=[],this.replacementUpdateTime=0}updateFootprints(t,e){}populate(t,e,i,n){this.tileToMeter=zd(i);const r=this.layers[0]._featureFilter.needGeometry;this.lookup=new Uint8Array(this.lookupDim*this.lookupDim);for(const{feature:o,id:s,index:a,sourceLayerIndex:l}of t){const t=null!=s?s:o.properties&&o.properties.hasOwnProperty("id")?o.properties.id:void 0,c=Zd(o,r);if(!this.layers[0]._featureFilter.filter(new Ha(this.zoom),c,i))continue;const d={id:t,sourceLayerIndex:l,index:a,geometry:r?c.geometry:Gd(o,i,n),properties:o.properties,type:o.type,patterns:{}},u=this.addFeature(d,d.geometry,c);u&&e.featureIndex.insert(o,d.geometry,a,l,this.index,this.instancesPerModel[u].instancedDataArray.length,uo/32)}this.lookup=null}update(t,e,i,n){for(const e in this.instancesPerModel){const i=this.instancesPerModel[e];for(const e in t)i.idToFeaturesIndex.hasOwnProperty(e)&&(this.evaluate(i.features[i.idToFeaturesIndex[e]],t[e],i,!0),this.uploaded=!1)}this.maxHeight=0}updateZoomBasedPaintProperties(){if(!this.hasZoomDependentProperties)return!1;let e=!1;for(const i in this.instancesPerModel){const n=this.instancesPerModel[i];for(const i of n.features){const r=this.layers[0],o=i.feature,s=this.canonical,a=r.paint.get("model-rotation").evaluate(o,{},s),l=r.paint.get("model-scale").evaluate(o,{},s),c=r.paint.get("model-translation").evaluate(o,{},s);t._.exactEquals(i.rotation,a)&&t._.exactEquals(i.scale,l)&&t._.exactEquals(i.translation,c)||(this.evaluate(i,i.featureStates,n,!0),e=!0)}}return e}updateReplacement(t,e,i){if(e.updateTime===this.replacementUpdateTime)return!1;this.replacementUpdateTime=e.updateTime;const n=e.getReplacementRegionsForTile(t.toUnwrapped(),!0);if(Pp(this.activeReplacements,n))return!1;this.activeReplacements=n;let r=!1;for(const e in this.instancesPerModel){const n=this.instancesPerModel[e],o=n.instancedDataArray;for(const e of n.features){const n=e.instancedDataOffset,s=e.instancedDataCount;for(let e=0;euo?a-uo:a;const l=Math.floor(a),c=o.float32[s+1];let d=!1;for(const e of this.activeReplacements)if(!(e.orderl||l>e.max.x||e.min.y>c||c>e.max.y)&&(d=Op(Rp(l,c,t.canonical,e.footprintTileId.canonical),e),d))break;o.float32[s]=d?a+uo:a,r=r||d}}}return r}isEmpty(){for(const t in this.instancesPerModel)if(0!==this.instancesPerModel[t].instancedDataArray.length)return!1;return!0}uploadPending(){return!this.uploaded}upload(t){if(!this.uploaded)for(const e in this.instancesPerModel){const i=this.instancesPerModel[e];i.instancedDataArray.length=uo||e.y=uo)continue;const t=(this.lookupDim-1)/uo,i=this.lookupDim*(e.y*t|0)+e.x*t|0;if(this.lookup){if(0!==this.lookup[i])continue;this.lookup[i]=1}this.instanceCount++;const n=s.length;s.resize(n+1),o.instancesEvaluatedElevation.push(0),s.float32[16*n]=e.x,s.float32[16*n+1]=e.y}return a.instancedDataCount=o.instancedDataArray.length-a.instancedDataOffset,a.instancedDataCount>0&&(t.id&&(o.idToFeaturesIndex[t.id]=o.features.length),o.features.push(a),this.evaluate(a,{},o,!1)),r}getModelUris(){return this.modelUris}evaluate(t,e,i,n){const r=this.layers[0],o=t.feature,s=this.canonical,a=t.rotation=r.paint.get("model-rotation").evaluate(o,e,s),l=t.scale=r.paint.get("model-scale").evaluate(o,e,s),c=t.translation=r.paint.get("model-translation").evaluate(o,e,s),d=r.paint.get("model-color").evaluate(o,e,s);d.a=r.paint.get("model-color-mix-intensity").evaluate(o,e,s);const u=[];this.maxVerticalOffset10?this.tileToMeter:zd(s,p)),a[o+4]=c[0],a[o+5]=c[1],a[o+6]=c[2]+l,a[o+7]=u[0],a[o+8]=u[1],a[o+9]=u[2],a[o+10]=u[4],a[o+11]=u[5],a[o+12]=u[6],a[o+13]=u[8],a[o+14]=u[9],a[o+15]=u[10],i.instancesEvaluatedElevation[r]=c[2]}}}ba(Zv,"ModelBucket",{omit:["layers"]}),ba(Gv,"PerModelAttributes"),ba(Vv,"ModelFeature");const qv=new ol({visibility:new il(sl.layout_model.visibility),"model-id":new nl(sl.layout_model["model-id"])});var Hv={paint:new ol({"model-opacity":new il(sl.paint_model["model-opacity"]),"model-rotation":new nl(sl.paint_model["model-rotation"]),"model-scale":new nl(sl.paint_model["model-scale"]),"model-translation":new nl(sl.paint_model["model-translation"]),"model-color":new nl(sl.paint_model["model-color"]),"model-color-mix-intensity":new nl(sl.paint_model["model-color-mix-intensity"]),"model-type":new il(sl.paint_model["model-type"]),"model-cast-shadows":new il(sl.paint_model["model-cast-shadows"]),"model-receive-shadows":new il(sl.paint_model["model-receive-shadows"]),"model-ambient-occlusion-intensity":new il(sl.paint_model["model-ambient-occlusion-intensity"]),"model-emissive-strength":new nl(sl.paint_model["model-emissive-strength"]),"model-roughness":new nl(sl.paint_model["model-roughness"]),"model-height-based-emissive-strength-multiplier":new nl(sl.paint_model["model-height-based-emissive-strength-multiplier"]),"model-cutoff-fade-range":new il(sl.paint_model["model-cutoff-fade-range"]),"model-front-cutoff":new il(sl.paint_model["model-front-cutoff"])}),layout:qv};const Wv=64,Yv={CoordinateSpaceTile:1,CoordinateSpaceYUp:2,HasMapboxMeshFeatures:4,HasMeshoptCompression:8};function Xv(e,i,n,r,o,s,a,l,c,d=!1){const u=n.zoom,h=n.project(r),p=kd(r.lat,u),f=1/p;t.ad.identity(e),t.ad.translate(e,e,[h.x+a[0]*f,h.y+a[1]*f,a[2]]);let m=1,_=1;const g=n.worldSize;if(d){if("mercator"===n.projection.name){let e=0;n.elevation&&(e=n.elevation.getAtPointOrZero(new Rd(h.x/g,h.y/g),0));const i=t.aA.transformMat4([],[h.x,h.y,e,1],n.projMatrix)[3]/n.cameraToCenterDistance;m=i,_=i*kd(n.center.lat,u)}else if("globe"===n.projection.name){const i=$v(e,n),o=t.ad.multiply([],n.projMatrix,i),s=[0,0,0,1];t.aA.transformMat4(s,s,o);const a=s[3]/n.cameraToCenterDistance,l=Hu(u),c=n.projection.pixelsPerMeter(r.lat,g)*kd(r.lat,u),d=n.projection.pixelsPerMeter(n.center.lat,g)*kd(n.center.lat,u);m=a/Vn(c,$d(n.center.lat),l),_=a*p/c,m*=d,_*=d}}else m=f;t.ad.scale(e,e,[m,m,_]);const y=[...e],v=i.orientation,x=[];if(Lv(x,[v[0]+o[0],v[1]+o[1],v[2]+o[2]],s),t.ad.multiply(e,y,x),l&&n.elevation){let o=0;const s=[];if(c&&n.elevation){o=function(e,i,n,r,o){const s=i.elevation;if(!s)return 0;const a=wu.projectAabbCorners(n,r),l=Cd(1,o.lat)*i.worldSize,c=function(e,i){const n=[0,0,1],r=[{corners:[0,1,3,2],dotProductWithUp:0},{corners:[1,5,2,6],dotProductWithUp:0},{corners:[0,4,1,5],dotProductWithUp:0},{corners:[2,6,3,7],dotProductWithUp:0},{corners:[4,7,5,6],dotProductWithUp:0},{corners:[0,3,4,7],dotProductWithUp:0}];for(const o of r){const r=e[o.corners[0]],s=e[o.corners[1]],a=e[o.corners[2]],l=[s[0]-r[0],s[1]-r[1],i*(s[2]-r[2])],c=t._.cross(l,l,[a[0]-r[0],a[1]-r[1],i*(a[2]-r[2])]);t._.normalize(c,c),o.dotProductWithUp=t._.dot(c,n)}return r.sort(((t,e)=>t.dotProductWithUp-e.dotProductWithUp)),r[0].corners}(a,l),d=a[c[0]],u=a[c[1]],h=a[c[2]],p=a[c[3]],f=s.getAtPointOrZero(new Rd(d[0]/i.worldSize,d[1]/i.worldSize),0),m=s.getAtPointOrZero(new Rd(u[0]/i.worldSize,u[1]/i.worldSize),0),_=s.getAtPointOrZero(new Rd(h[0]/i.worldSize,h[1]/i.worldSize),0),g=s.getAtPointOrZero(new Rd(p[0]/i.worldSize,p[1]/i.worldSize),0),y=(f+g)/2,v=(m+_)/2;return y>v?m=e.gl.NEAREST_MIPMAP_NEAREST}),t.uploaded=!0,t.image=null)}function Jv(t,e,i){t.indexBuffer=e.createIndexBuffer(t.indexArray,!1,!0),t.vertexBuffer=e.createVertexBuffer(t.vertexArray,Dv.members,!1,!0),t.normalArray&&(t.normalBuffer=e.createVertexBuffer(t.normalArray,Bv.members,!1,!0)),t.texcoordArray&&(t.texcoordBuffer=e.createVertexBuffer(t.texcoordArray,Ov.members,!1,!0)),t.colorArray&&(t.colorBuffer=e.createVertexBuffer(t.colorArray,(12===t.colorArray.bytesPerElement?zv:Rv).members,!1,!0)),t.featureArray&&(t.pbrBuffer=e.createVertexBuffer(t.featureArray,Nv.members,!0)),t.segments=wc.simpleSegment(0,0,t.vertexArray.length,t.indexArray.length);const n=t.material;n.pbrMetallicRoughness.baseColorTexture&&Kv(n.pbrMetallicRoughness.baseColorTexture,e),n.pbrMetallicRoughness.metallicRoughnessTexture&&Kv(n.pbrMetallicRoughness.metallicRoughnessTexture,e),n.normalTexture&&Kv(n.normalTexture,e),n.occlusionTexture&&Kv(n.occlusionTexture,e,i),n.emissionTexture&&Kv(n.emissionTexture,e)}function Qv(t,e,i){if(t.meshes)for(const n of t.meshes)Jv(n,e,i);if(t.children)for(const n of t.children)Qv(n,e,i)}function tx(t){if(t.meshes)for(const e of t.meshes)e.indexArray.destroy(),e.vertexArray.destroy(),e.colorArray&&e.colorArray.destroy(),e.normalArray&&e.normalArray.destroy(),e.texcoordArray&&e.texcoordArray.destroy(),e.featureArray&&e.featureArray.destroy();if(t.children)for(const e of t.children)tx(e)}function ex(t){if(t.meshes)for(const i of t.meshes)i.vertexBuffer&&(i.vertexBuffer.destroy(),i.indexBuffer.destroy(),i.normalBuffer&&i.normalBuffer.destroy(),i.texcoordBuffer&&i.texcoordBuffer.destroy(),i.colorBuffer&&i.colorBuffer.destroy(),i.pbrBuffer&&i.pbrBuffer.destroy(),i.segments.destroy(),i.material&&((e=i.material).pbrMetallicRoughness.baseColorTexture&&e.pbrMetallicRoughness.baseColorTexture.gfxTexture&&e.pbrMetallicRoughness.baseColorTexture.gfxTexture.destroy(),e.pbrMetallicRoughness.metallicRoughnessTexture&&e.pbrMetallicRoughness.metallicRoughnessTexture.gfxTexture&&e.pbrMetallicRoughness.metallicRoughnessTexture.gfxTexture.destroy(),e.normalTexture&&e.normalTexture.gfxTexture&&e.normalTexture.gfxTexture.destroy(),e.emissionTexture&&e.emissionTexture.gfxTexture&&e.emissionTexture.gfxTexture.destroy(),e.occlusionTexture&&e.occlusionTexture.gfxTexture&&e.occlusionTexture.gfxTexture.destroy()));var e;if(t.children)for(const e of t.children)ex(e)}class ix{constructor(t){this._callback=t,this._triggered=!1,"undefined"!=typeof MessageChannel&&(this._channel=new MessageChannel,this._channel.port2.onmessage=()=>{this._triggered=!1,this._callback()})}trigger(){this._triggered||(this._triggered=!0,this._channel?this._channel.port1.postMessage(!0):setTimeout((()=>{this._triggered=!1,this._callback()}),0))}remove(){this._channel=void 0,this._callback=()=>{}}}class nx{constructor(){this.tasks={},this.taskQueue=[],ai(["process"],this),this.invoker=new ix(this.process),this.nextId=0}add(t,e){const i=this.nextId++,n=function({type:t,isSymbolTile:e,zoom:i}){return i=i||0,"message"===t?0:"maybePrepare"!==t||e?"parseTile"!==t||e?"parseTile"===t&&e?300-i:"maybePrepare"===t&&e?400-i:500:200-i:100-i}(e);if(0===n){try{t()}finally{}return null}return this.tasks[i]={fn:t,metadata:e,priority:n,id:i},this.taskQueue.push(i),this.invoker.trigger(),{cancel:()=>{delete this.tasks[i]}}}process(){try{if(this.taskQueue=this.taskQueue.filter((t=>!!this.tasks[t])),!this.taskQueue.length)return;const t=this.pick();if(null===t)return;const e=this.tasks[t];if(delete this.tasks[t],this.taskQueue.length&&this.invoker.trigger(),!e)return;e.fn()}finally{}}pick(){let t=null,e=1/0;for(let i=0;i{i&&delete this.callbacks[s],this.target.postMessage({id:s,type:"",targetMapId:n,sourceMapId:this.mapId})}}}receive(t){const e=t.data,i=e.id;if(i&&(!e.targetMapId||this.mapId===e.targetMapId))if(""===e.type){const t=this.cancelCallbacks[i];delete this.cancelCallbacks[i],t&&t.cancel()}else if(e.mustQueue||gi()){const t=this.callbacks[i],n=this.scheduler.add((()=>this.processTask(i,e)),t&&t.metadata||{type:"message"});n&&(this.cancelCallbacks[i]=n)}else this.processTask(i,e)}processTask(t,e){if(delete this.cancelCallbacks[t],""===e.type){const i=this.callbacks[t];delete this.callbacks[t],i&&(e.error?i(Ea(e.error)):i(null,Ea(e.data)))}else{const i=new Set,n=e.hasCallback?(e,n)=>{this.target.postMessage({id:t,type:"",sourceMapId:this.mapId,error:e?Sa(e):null,data:Sa(n,i)},i)}:t=>{},r=Ea(e.data);if(this.parent[e.type])this.parent[e.type](e.sourceMapId,r,n);else if(this.parent.getWorkerSource){const t=e.type.split(".");this.parent.getWorkerSource(e.sourceMapId,t[0],r.source,r.scope)[t[1]](r,n)}else n(new Error(`Could not find function ${e.type}`))}}remove(){this.scheduler.remove(),this.target.removeEventListener("message",this.receive,!1)}}class ox{constructor(t,e){this.workerPool=t,this.actors=[],this.currentActor=0,this.id=ni();const i=this.workerPool.acquire(this.id);for(let t=0;t{this.ready=!0}))}broadcast(t,e,i){Qe(this.actors,((i,n)=>{i.send(t,e,n)}),i=i||function(){})}getActor(){return this.currentActor=(this.currentActor+1)%this.actors.length,this.actors[this.currentActor]}remove(){this.actors.forEach((t=>{t.remove()})),this.actors=[],this.workerPool.release(this.id)}}ox.Actor=rx;var sx={workerUrl:"",workerClass:null,workerParams:void 0};function ax(){return null!=sx.workerClass?new sx.workerClass:new self.Worker(sx.workerUrl,sx.workerParams)}const lx="mapboxgl_preloaded_worker_pool";class cx{constructor(){this.active={}}acquire(t){if(!this.workers)for(this.workers=[];this.workers.length{t.terminate()})),this.workers=null)}isPreloaded(){return!!this.active[lx]}numActive(){return Object.keys(this.active).length}}let dx;function ux(){return dx||(dx=new cx),dx}cx.workerCount=2;let hx,px,fx,mx,_x,gx=null;function yx(){return gi()&&self.worker&&self.worker.dracoUrl?self.worker.dracoUrl:px||n.DRACO_URL}function vx(){if(gi()&&self.worker&&self.worker.meshoptUrl)return self.worker.meshoptUrl;if(mx)return mx;const t=new Uint8Array([0,97,115,109,1,0,0,0,1,4,1,96,0,0,3,3,2,0,0,5,3,1,0,1,12,1,0,10,22,2,12,0,65,0,65,0,65,0,252,10,0,0,11,7,0,65,0,253,15,26,11]);if("object"!=typeof WebAssembly)throw new Error("WebAssembly not supported, cannot instantiate meshoptimizer");return mx=WebAssembly.validate(t)?n.MESHOPT_SIMD_URL:n.MESHOPT_URL,mx}const xx={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},bx={5120:"DT_INT8",5121:"DT_UINT8",5122:"DT_INT16",5123:"DT_UINT16",5125:"DT_UINT32",5126:"DT_FLOAT32"},wx={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16};function Tx(t,e,i){const n=i.json.bufferViews.length,r=i.buffers.length;e.bufferView=n,i.json.bufferViews[n]={buffer:r,byteLength:t.byteLength},i.buffers[r]=t}const Sx="KHR_draco_mesh_compression";function Ex(t,e){const i=t.extensions&&t.extensions[Sx];if(!i)return;const n=new fx.Decoder,r=$x(e,i.bufferView),o=new fx.Mesh;if(!n.DecodeArrayToMesh(r,r.byteLength,o))throw new Error("Failed to decode Draco mesh");const s=e.json.accessors[t.indices],a=xx[s.componentType],l=s.count*a.BYTES_PER_ELEMENT,c=fx._malloc(l);a===Uint16Array?n.GetTrianglesUInt16Array(o,l,c):n.GetTrianglesUInt32Array(o,l,c),Tx(fx.memory.buffer.slice(c,c+l),s,e),fx._free(c);for(const r of Object.keys(i.attributes)){const s=n.GetAttributeByUniqueId(o,i.attributes[r]),a=e.json.accessors[t.attributes[r]],l=bx[a.componentType],c=a.count*wx[a.type]*xx[a.componentType].BYTES_PER_ELEMENT,d=fx._malloc(c);n.GetAttributeDataArrayForAllPoints(o,s,fx[l],c,d),Tx(fx.memory.buffer.slice(d,d+c),a,e),fx._free(d)}n.destroy(),o.destroy(),delete t.extensions[Sx]}const Mx="EXT_meshopt_compression";function Cx(t,e){if(!t.extensions||!t.extensions[Mx])return;const i=t.extensions[Mx],n=new Uint8Array(e.buffers[i.buffer],i.byteOffset||0,i.byteLength||0),r=new Uint8Array(i.count*i.byteStride);_x.decodeGltfBuffer(r,i.count,i.byteStride,n,i.mode,i.filter),t.buffer=e.buffers.length,t.byteOffset=0,e.buffers[t.buffer]=r.buffer,delete t.extensions[Mx]}const Ax=1179937895,Ix=new TextDecoder("utf8");function Lx(t,e){return new URL(t,e).href}function Px(t,e,i,n){return fetch(Lx(t.uri,n)).then((t=>t.arrayBuffer())).then((t=>{e.buffers[i]=t}))}function $x(t,e){const i=t.json.bufferViews[e];return new Uint8Array(t.buffers[i.buffer],i.byteOffset||0,i.byteLength)}function kx(t,e,i,n){if(t.uri){const r=Lx(t.uri,n);return fetch(r).then((t=>t.blob())).then((t=>createImageBitmap(t))).then((t=>{e.images[i]=t}))}if(void 0!==t.bufferView){const n=$x(e,t.bufferView),r=new Blob([n],{type:t.mimeType});return createImageBitmap(r).then((t=>{e.images[i]=t}))}}function Dx(t,e=0,i){const n={json:null,images:[],buffers:[]};if(new Uint32Array(t,e,1)[0]===Ax){const i=new Uint32Array(t,e);let r=2;const o=(i[r++]>>2)-3,s=i[r++]>>2;if(r++,n.json=JSON.parse(Ix.decode(i.subarray(r,r+s))),r+=s,r{const t=[],e=a&&a.includes(Sx),r=a&&a.includes(Mx);if(e&&t.push(function(){if(!fx)return hx||(hx=function(t){let e,i=null;function n(){e=new Uint8Array(i.buffer)}function r(){throw new Error("Unexpected Draco error.")}const o={a:{a:r,d:function(t,i,n){return e.copyWithin(t,i,i+n)},c:function(t){const r=e.length,o=Math.max(t>>>0,Math.ceil(1.2*r)),s=Math.ceil((o-r)/65536);try{return i.grow(s),n(),!0}catch(t){return!1}},b:r}};return(WebAssembly.instantiateStreaming?WebAssembly.instantiateStreaming(t,o):t.then((t=>t.arrayBuffer())).then((t=>WebAssembly.instantiate(t,o)))).then((t=>{const{Rb:r,Qb:o,P:s,T:a,X:l,Ja:c,La:d,Qa:u,Va:h,Wa:p,eb:f,jb:m,f:_,e:g,yb:y,zb:v,Ab:x,Bb:b,Db:w,Gb:T}=t.instance.exports;i=g;const S=(()=>{let t=0,i=0,n=0,s=0;return a=>{n&&(r(s),r(t),i+=n,n=t=0),t||(i+=128,t=o(i));const l=a.length+7&-8;let c=t;l>=i&&(n=l,c=s=o(l));for(let t=0;t{fx=t,hx=void 0})))}()),r&&t.push(function(){if(_x)return;const t=function(t){let e;const i=WebAssembly.instantiateStreaming(t,{}).then((t=>{e=t.instance,e.exports.__wasm_call_ctors()})),n={NONE:"",OCTAHEDRAL:"meshopt_decodeFilterOct",QUATERNION:"meshopt_decodeFilterQuat",EXPONENTIAL:"meshopt_decodeFilterExp"},r={ATTRIBUTES:"meshopt_decodeVertexBuffer",TRIANGLES:"meshopt_decodeIndexBuffer",INDICES:"meshopt_decodeIndexSequence"};return{ready:i,supported:!0,decodeGltfBuffer(t,i,o,s,a,l){!function(t,e,i,n,r,o,s){const a=t.exports.sbrk,l=n+3&-4,c=a(l*r),d=a(o.length),u=new Uint8Array(t.exports.memory.buffer);u.set(o,d);const h=e(c,n,r,d,o.length);if(0===h&&s&&s(c,l,r),i.set(u.subarray(c,c+n*r)),a(c-a(0)),0!==h)throw new Error(`Malformed buffer data: ${h}`)}(e,e.exports[r[a]],t,i,o,s,e.exports[n[l]])}}}(fetch(vx()));return t.ready.then((()=>{_x=t}))}()),o)for(let e=0;e{if(e&&s)for(const{primitives:t}of s)for(const e of t)Ex(e,n);if(r&&s&&l)for(const t of l)Cx(t,n);return n}))}))}function zx(t,e){const i=t.json.bufferViews[e.bufferView],n=xx[e.componentType];return new n(t.buffers[i.buffer],(e.byteOffset||0)+(i.byteOffset||0),e.count*(i.byteStride&&i.byteStride!==wx[e.type]*n.BYTES_PER_ELEMENT?i.byteStride/n.BYTES_PER_ELEMENT:wx[e.type]))}function Rx(t,e,i,n){const r=xx[e.componentType],o=function(t){switch(t){case Int8Array:return 1/127;case Uint8Array:return 1/255;case Int16Array:return 1/32767;case Uint16Array:return 1/65535;default:return 1}}(r),s=t.json.bufferViews[e.bufferView],a=s.byteStride?s.byteStride/r.BYTES_PER_ELEMENT:wx[e.type],l=i.float32,c=l.length/i.capacity;for(let t=0,i=0;t0){for(let r=0;r0){o.texcoordArray=new ic;const t=e.json.accessors[r.TEXCOORD_0];o.texcoordArray.resize(t.count);const i=zx(e,t);Rx(e,t,o.texcoordArray,i)}if(void 0!==r._FEATURE_ID_RGBA4444){const t=e.json.accessors[r._FEATURE_ID_RGBA4444];e.json.extensionsUsed&&e.json.extensionsUsed.includes("EXT_meshopt_compression")&&(o.featureData=zx(e,t))}void 0!==r._FEATURE_RGBA4444&&(o.featureData=new Uint32Array(zx(e,e.json.accessors[r._FEATURE_RGBA4444]).buffer));const u=t.material;return o.material=function(t,e){const{emissiveFactor:i=[0,0,0],alphaMode:n="OPAQUE",alphaCutoff:r=.5,normalTexture:o,occlusionTexture:s,emissiveTexture:a,doubleSided:l}=t,{baseColorFactor:c=[1,1,1,1],metallicFactor:d=1,roughnessFactor:u=1,baseColorTexture:h,metallicRoughnessTexture:p}=t.pbrMetallicRoughness||{},f=s?e[s.index]:void 0;if(s&&s.extensions&&s.extensions.KHR_texture_transform&&f){const t=s.extensions.KHR_texture_transform;f.offsetScale=[t.offset[0],t.offset[1],t.scale[0],t.scale[1]]}return{pbrMetallicRoughness:{baseColorFactor:new Un(...c),metallicFactor:d,roughnessFactor:u,baseColorTexture:h?e[h.index]:void 0,metallicRoughnessTexture:p?e[p.index]:void 0},doubleSided:l,emissiveFactor:i,alphaMode:n,alphaCutoff:r,normalTexture:o?e[o.index]:void 0,occlusionTexture:f,emissionTexture:a?e[a.index]:void 0,defined:void 0===t.defined}}(void 0!==u?e.json.materials[u]:{defined:!1},i),o}function Bx(e,i,n){const{matrix:r,rotation:o,translation:s,scale:a,mesh:l,extras:c,children:d}=e,u={};if(u.matrix=r||t.ad.fromRotationTranslationScale([],o||[0,0,0,1],s||[0,0,0],a||[1,1,1]),void 0!==l){u.meshes=n[l];const t=u.anchor=[0,0];for(const e of u.meshes){const{min:i,max:n}=e.aabb;t[0]+=i[0]+n[0],t[1]+=i[1]+n[1]}t[0]=Math.floor(t[0]/u.meshes.length/2),t[1]=Math.floor(t[1]/u.meshes.length/2)}if(c&&(c.id&&(u.id=c.id),c.lights&&(u.lights=function(t){if(!t.length)return[];const e=function(t){const e=atob(t),i=new Uint8Array(e.length);for(let t=0;t1&&n[n.length-1].equals(n[0])&&n.pop();let r=0;for(let t=0;t0&&n.reverse();const o=xh(n.flatMap((t=>[t.x,t.y])),[]);return 0===o.length?null:{vertices:n,indices:o}}function Ux(e,i){const n=[],r=[];let o=0;const s=[];for(const a of e){o=n.length;const e=a.vertexArray.float32,l=a.indexArray.uint16;for(let r=0;r0&&([r[t+1],r[t+2]]=[r[t+2],r[t+1]])}return{vertices:n,indices:r}}function jx(t){const e=function(t,e){const i=[],n=WebGL2RenderingContext;if(t.json.textures)for(const r of t.json.textures){const o={magFilter:n.LINEAR,minFilter:n.NEAREST,wrapS:n.REPEAT,wrapT:n.REPEAT};void 0!==r.sampler&&Object.assign(o,t.json.samplers[r.sampler]),i.push({image:e[r.source],sampler:o,uploaded:!1})}return i}(t,t.images),i=function(t,e){const i=[];for(const n of t.json.meshes){const r=[];for(const i of n.primitives)r.push(Ox(i,t,e));i.push(r)}return i}(t,e),{scenes:n,scene:r,nodes:o}=t.json,s=n?n[r||0].nodes:o,a=[];for(const e of s)a.push(Bx(o[e],t,i));return function(t,e,i){const n={},r=new Set;for(let o=0;o0){const e=Array.from(r.values()).sort(((t,e)=>t-e));for(let i=e.length-1;i>=0;i--)t.splice(e[i],1)}}(a,s,t.json.nodes),a}function Vx(t){t.heightmap=new Float32Array(4096),t.heightmap.fill(-1);const e=t.vertexArray.float32,i=t.aabb.min[0]-1,n=t.aabb.min[1]-1,r=Wv/(t.aabb.max[0]-i+2),o=Wv/(t.aabb.max[1]-n+2);for(let s=0;st.heightmap[c*Wv+l]&&(t.heightmap[c*Wv+l]=a)}}function Gx(e,i){const n={};n.indexArray=new Kl,n.indexArray.reserve(4*e.length),n.vertexArray=new Bl,n.vertexArray.reserve(10*e.length),n.colorArray=new Ol,n.vertexArray.reserve(10*e.length);let r=0;for(const o of e){const e=Math.min(10,Math.max(4,1.3*o.height))*i,s=[-o.normal[1],o.normal[0],0],a=Math.min(.29,.1*o.width/o.depth),l=o.width-2*o.depth*i*(a+.01),c=t._.scaleAndAdd([],o.pos,s,l/2),d=t._.scaleAndAdd([],o.pos,s,-l/2),u=[c[0],c[1],c[2]+o.height],h=[d[0],d[1],d[2]+o.height],p=t._.scaleAndAdd([],o.normal,s,a);t._.scale(p,p,e);const f=t._.scaleAndAdd([],o.normal,s,-a);t._.scale(f,f,e),t._.add(p,c,p),t._.add(f,d,f),c[2]+=.1,d[2]+=.1,n.vertexArray.emplaceBack(p[0],p[1],p[2]),n.vertexArray.emplaceBack(f[0],f[1],f[2]),n.vertexArray.emplaceBack(c[0],c[1],c[2]),n.vertexArray.emplaceBack(d[0],d[1],d[2]),n.vertexArray.emplaceBack(u[0],u[1],u[2]),n.vertexArray.emplaceBack(h[0],h[1],h[2]),n.vertexArray.emplaceBack(c[0],c[1],c[2]),n.vertexArray.emplaceBack(d[0],d[1],d[2]),n.vertexArray.emplaceBack(p[0],p[1],p[2]),n.vertexArray.emplaceBack(f[0],f[1],f[2]);const m=l/e/2;n.colorArray.emplaceBack(-m-a,-1,m,.8),n.colorArray.emplaceBack(m+a,-1,m,.8),n.colorArray.emplaceBack(-m,0,m,1.3),n.colorArray.emplaceBack(m,0,m,1.3),n.colorArray.emplaceBack(m+a,-.8,m,.7),n.colorArray.emplaceBack(m+a,-.8,m,.7),n.colorArray.emplaceBack(0,0,m,1.3),n.colorArray.emplaceBack(0,0,m,1.3),n.colorArray.emplaceBack(m+a,-1.2,m,.8),n.colorArray.emplaceBack(m+a,-1.2,m,.8),n.indexArray.emplaceBack(6+r,4+r,8+r),n.indexArray.emplaceBack(7+r,9+r,5+r),n.indexArray.emplaceBack(0+r,1+r,2+r),n.indexArray.emplaceBack(1+r,3+r,2+r),r+=10}const o={defined:!0,emissiveFactor:[0,0,0]},s={};return s.baseColorFactor=Un.white,o.pbrMetallicRoughness=s,n.material=o,n.aabb=new wu([1/0,1/0,1/0],[-1/0,-1/0,-1/0]),n}const Zx=new Float32Array(262144),qx=new Uint8Array(262144);function Hx(t){let e=0;if(t.meshes)for(const i of t.meshes)e=Math.max(e,i.aabb.max[2]);if(t.children)for(const i of t.children)e=Math.max(e,Hx(i));return e}function Wx(t,e,i){if(t.meshes)for(const n of t.meshes)n.aabb.min[0]!==1/0&&i.insert(e,n.aabb.min[0],n.aabb.min[1],n.aabb.max[0],n.aabb.max[1]);if(t.children)for(const n of t.children)Wx(n,e,i)}const Yx=["","wall","door","roof","window","lamp","logo"];class Xx{constructor(t){this.node=t,this.evaluatedRMEA=[[1,0,0,1],[1,0,0,1],[1,0,0,1],[1,0,0,1],[.4,1,0,1],[1,0,0,1],[1,0,0,1]],this.hiddenByReplacement=!1,this.evaluatedScale=[1,1,1],this.evaluatedColor=[],this.emissionHeightBasedParams=[],this.feature={type:"Point",id:t.id,geometry:[],properties:{height:Hx(t)}},this.aabb=this._getLocalBounds()}_getLocalBounds(){if(!this.node.meshes)return new wu([1/0,1/0,1/0],[-1/0,-1/0,-1/0]);if(!this.aabb){let t=0;const e=new wu([1/0,1/0,1/0],[-1/0,-1/0,-1/0]);for(const i of this.node.meshes)this.node.lightMeshIndex!==t&&(i.transformedAabb=wu.applyTransformFast(i.aabb,this.node.matrix),e.encapsulate(i.transformedAabb)),t++;this.aabb=e}return this.aabb}}class Kx{constructor(t,e,i,n,r,o){this.id=e,this.modelTraits|=Yv.CoordinateSpaceTile,this.uploaded=!1,this.hasPattern=!1,i&&(this.modelTraits|=Yv.HasMapboxMeshFeatures),n&&(this.modelTraits|=Yv.HasMeshoptCompression),this.zoom=-1,this.terrainExaggeration=1,this.projection={name:"mercator"},this.replacementUpdateTime=0,this.elevationReadFromZ=255,this.brightness=r,this.dirty=!0,this.needsUpload=!1,this.nodesInfo=[];for(const e of t)this.nodesInfo.push(new Xx(e)),Wx(e,o.featureIndexArray.length,o.grid),o.featureIndexArray.emplaceBack(this.nodesInfo.length-1,0,o.bucketLayerIDs.length-1,0)}updateFootprints(t,e){for(const i of this.getNodesInfo()){const n=i.node;n.footprint&&e.push({footprint:n.footprint,id:t})}}update(){console.log("Update 3D model bucket")}populate(){console.log("populate 3D model bucket")}uploadPending(){return!this.uploaded||this.needsUpload}upload(t){if(!this.needsUpload)return;const e=this.getNodesInfo();for(const i of e){const e=i.node;this.uploaded?this.updatePbrBuffer(e):Qv(e,t,!0)}for(const t of e)tx(t.node);this.uploaded=!0,this.needsUpload=!1}updatePbrBuffer(t){let e=!1;if(!t.meshes)return e;for(const i of t.meshes)i.pbrBuffer&&(i.pbrBuffer.updateData(i.featureArray),e=!0);return e}needsReEvaluation(t,e,i){const n=t.transform.projectionOptions,r=t.style.getBrightness(),o=this.brightness!==r;return!!(!this.uploaded||this.dirty||n.name!==this.projection.name||Jx(i.paint.get("model-color").value,o)||Jx(i.paint.get("model-color-mix-intensity").value,o)||Jx(i.paint.get("model-roughness").value,o)||Jx(i.paint.get("model-emissive-strength").value,o)||Jx(i.paint.get("model-height-based-emissive-strength-multiplier").value,o))&&(this.projection=n,this.brightness=r,!0)}evaluateScale(t,e){if(t.transform.zoom===this.zoom)return;this.zoom=t.transform.zoom;const i=this.getNodesInfo(),n=this.id.canonical;for(const t of i){const i=t.feature;t.evaluatedScale=e.paint.get("model-scale").evaluate(i,{},n)}}evaluate(t){const e=this.getNodesInfo();for(const i of e){if(!i.node.meshes)continue;const e=i.feature,n=i.node.meshes&&i.node.meshes[0].featureData,r=i.evaluatedColor[2],o=i.evaluatedRMEA[2],s=this.id.canonical;if(i.hasTranslucentParts=!1,n){for(let n=0;n=t)continue;const u=Zx[c],h=Math.abs(u);h>a&&(s=u,a=h,l=r,d=e)}if(a>.1){const o=1-(t+.5*Math.abs(l*d))/c;let a=e._dem.get(n,i)+s*o;const u=e._dem.get(n+l,i+d),h=e._dem.get(n-l,i-d,!0);(a-u)*(a-h)>0&&(a=(u+h)/2),Zx[r]=e._dem.set(n,i,a),qx[r]=t}}}}}s&&(e._demTile.needsDEMTextureUpload=!0,e._dem._timestamp=ki.now())}getNodesInfo(){return this.nodesInfo}destroy(){const t=this.getNodesInfo();for(const e of t)tx(e.node),ex(e.node)}isEmpty(){return!this.nodesInfo.length}updateReplacement(t,e){if(e.updateTime===this.replacementUpdateTime)return;this.replacementUpdateTime=e.updateTime;const i=e.getReplacementRegionsForTile(t.toUnwrapped()),n=this.getNodesInfo();for(let t=0;tt.footprint===e.footprint))}}getHeightAtTileCoord(e,i){const n=this.getNodesInfo(),r=[],o=[0,0,0],s=t.ad.identity([]);for(let a=0;ad.max[0]||i>d.max[1])continue;if(!0===l.node.hidden)return{height:0,maxHeight:l.feature.properties.height,hidden:!1,verticalScale:l.evaluatedScale[2]};t.ad.invert(s,l.node.matrix),o[0]=e,o[1]=i,t._.transformMat4(o,o,s);const u=(o[0]-c.aabb.min[0])/(c.aabb.max[0]-c.aabb.min[0])*Wv|0,h=Math.min(63,(o[1]-c.aabb.min[1])/(c.aabb.max[1]-c.aabb.min[1])*Wv|0)*Wv+Math.min(63,u),p=c.heightmap[h];if(!(p0)return{height:void 0,maxHeight:l.feature.properties.height,hidden:l.hiddenByReplacement,verticalScale:l.evaluatedScale[2]}}}}function Jx(t,e){return!t.isLightConstant&&e}function Qx(t,e,i,n,r,o,s,a){let l=(61440&e|(61440&e)>>4)>>8,c=(3840&e|(3840&e)>>4)>>4,d=240&e|(240&e)>>4;i[3]>0&&(l=Vn(l,255*i[0],i[3]),c=Vn(c,255*i[1],i[3]),d=Vn(d,255*i[2],i[3]));const u=l>16&65535,a=o?e>>16&65535:65535&e,l=(15&a)t.polygon)).flat());const g=f?l:null,[y,v]=function(e,i,n,r,o,s,a,l,c,d,u){return"globe"===e.projection.name?function(e,i,n,r,o,s,a,l,c,d,u){const h=[],p=[],f=e.projection.upVectorScale(u,e.center.lat,e.worldSize).metersToTile,m=[0,0,0,1],_=[0,0,0,1],g=(t,e,i,n)=>{t[0]=e,t[1]=i,t[2]=n,t[3]=1},y=Sf();n>0&&(n+=y),r+=y;for(const y of i){const i=[],v=[];for(const h of y){const p=h.x+o.x,y=h.y+o.y,x=e.projection.projectTilePoint(p,y,u),b=e.projection.upVector(u,h.x,h.y);let w=n,T=r;if(a){const t=Pf(p,y,n,r,a,l,c,d);w+=t.base,T+=t.top}0!==n?g(m,x.x+b[0]*f*w,x.y+b[1]*f*w,x.z+b[2]*f*w):g(m,x.x,x.y,x.z),g(_,x.x+b[0]*f*T,x.y+b[1]*f*T,x.z+b[2]*f*T),t._.transformMat4(m,m,s),t._.transformMat4(_,_,s),i.push(new Tp(m[0],m[1],m[2])),v.push(new Tp(_[0],_[1],_[2]))}h.push(i),p.push(v)}return[h,p]}(e,i,n,r,o,s,a,l,c,d,u):a?function(e,i,n,r,o,s,a,l,c){const d=[],u=[],h=[0,0,0,1];for(const p of e){const e=[],f=[];for(const d of p){const u=d.x+r.x,p=d.y+r.y,m=Pf(u,p,i,n,s,a,l,c);h[0]=u,h[1]=p,h[2]=m.base,h[3]=1,t.aA.transformMat4(h,h,o),h[3]=Math.max(h[3],1e-5);const _=new Tp(h[0]/h[3],h[1]/h[3],h[2]/h[3]);h[0]=u,h[1]=p,h[2]=m.top,h[3]=1,t.aA.transformMat4(h,h,o),h[3]=Math.max(h[3],1e-5);const g=new Tp(h[0]/h[3],h[1]/h[3],h[2]/h[3]);e.push(_),f.push(g)}d.push(e),u.push(f)}return[d,u]}(i,n,r,o,s,a,l,c,d):function(t,e,i,n,r){const o=[],s=[],a=r[8]*e,l=r[9]*e,c=r[10]*e,d=r[11]*e,u=r[8]*i,h=r[9]*i,p=r[10]*i,f=r[11]*i;for(const e of t){const t=[],i=[];for(const o of e){const e=o.x+n.x,s=o.y+n.y,m=r[0]*e+r[4]*s+r[12],_=r[1]*e+r[5]*s+r[13],g=r[2]*e+r[6]*s+r[14],y=r[3]*e+r[7]*s+r[15],v=m+a,x=_+l,b=g+c,w=Math.max(y+d,1e-5),T=m+u,S=_+h,E=g+p,M=Math.max(y+f,1e-5);t.push(new Tp(v/w,x/w,b/w)),i.push(new Tp(T/M,S/M,E/M))}o.push(t),s.push(i)}return[o,s]}(i,n,r,o,s)}(s,r,h,u,d,a,g,p,m,s.center.lat,e.tileID.canonical),x=e.queryGeometry;return function(t,e,i){let n=1/0;Kd(i,e)&&(n=Lf(i,e[0]));for(let r=0;r=3)for(let e=0;e>4;if(1!==n)throw new Error(`Got v${n} data when expected v1.`);const r=nb[15&i];if(!r)throw new Error("Unrecognized array type.");const[o]=new Uint16Array(t,2,1),[s]=new Uint32Array(t,4,1);return new rb(s,o,r,t)}constructor(t,e=64,i=Float64Array,n){if(isNaN(t)||t>1;return this.ids[i]=i,this.coords[this._pos++]=t,this.coords[this._pos++]=e,i}finish(){const t=this._pos>>1;if(t!==this.numItems)throw new Error(`Added ${t} items when expected ${this.numItems}.`);return ob(this.ids,this.coords,this.nodeSize,0,this.numItems-1,0),this._finished=!0,this}range(t,e,i,n){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");const{ids:r,coords:o,nodeSize:s}=this,a=[0,r.length-1,0],l=[];for(;a.length;){const c=a.pop()||0,d=a.pop()||0,u=a.pop()||0;if(d-u=t&&a=e&&c>1,p=o[2*h],f=o[2*h+1];p>=t&&p=e&&f=p:n>=f)&&(a.push(h+1),a.push(d),a.push(1-c))}return l}within(t,e,i){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");const{ids:n,coords:r,nodeSize:o}=this,s=[0,n.length-1,0],a=[],l=i*i;for(;s.length;){const c=s.pop()||0,d=s.pop()||0,u=s.pop()||0;if(d-u>1,p=r[2*h],f=r[2*h+1];cb(p,f,t,e)=p:e+i>=f)&&(s.push(h+1),s.push(d),s.push(1-c))}return a}}function ob(t,e,i,n,r,o){if(r-n>1;sb(t,e,s,n,r,o),ob(t,e,i,n,s-1,1-o),ob(t,e,i,s+1,r,1-o)}function sb(t,e,i,n,r,o){for(;r>n;){if(r-n>600){const s=r-n+1,a=i-n+1,l=Math.log(s),c=.5*Math.exp(2*l/3),d=.5*Math.sqrt(l*c*(s-c)/s)*(a-s/2s&&ab(t,e,n,r);as;)l--}e[2*n+o]===s?ab(t,e,n,l):(l++,ab(t,e,l,r)),lr&&(n+=(t[i]-r)*(t[i]-r)),e[i]0&&n[0]0&&n[1]0&&r[0]0&&r[1]0?Math.acos(i/n)*Ve:0;let o=0!==t||0!==e?Math.atan2(-e,-t)*Ve+90:0;return oNi&&(t.getActor().send("enforceCacheSizeLimit",Fi),Vi=0)},t.an=gn,t.ao=class{constructor(t){this.entries={},this.scheduler=t}request(t,e,i,n){const r=this.entries[t]=this.entries[t]||{callbacks:[]};if(r.result){const[t,i]=r.result;return this.scheduler?this.scheduler.add((()=>{n(t,i)}),e):n(t,i),()=>{}}return r.callbacks.push(n),r.cancel||(r.cancel=i(((i,n)=>{r.result=[i,n];for(const t of r.callbacks)this.scheduler?this.scheduler.add((()=>{t(i,n)}),e):t(i,n);setTimeout((()=>delete this.entries[t]),3e3)}))),()=>{r.result||(r.callbacks=r.callbacks.filter((t=>t!==n)),r.callbacks.length||(r.cancel(),delete this.entries[t]))}}},t.ap=function(t,e,i){const n=JSON.stringify(t.request);return t.data&&(this.deduped.entries[n]={result:[null,t.data]}),this.deduped.request(n,{type:"parseTile",isSymbolTile:t.isSymbolTile,zoom:t.tileZoom},(e=>{const n=en(t.request,((t,n,r,o)=>{t?e(t):n&&e(null,{vectorTile:i?void 0:new bp(new Lm(n)),rawData:n,cacheControl:r,expires:o})}));return()=>{n.cancel(),e()}}),e)},t.aq=Dc,t.ar=class extends Lc{constructor(t){super(t),this.current=Fc}set(t,e,i){if(this.fetchUniformLocation(t,e))for(let t=0;t({u_camera_to_center_distance:new $c(t),u_extrude_scale:new Uc(t),u_device_pixel_ratio:new $c(t),u_matrix:new Bc(t),u_inv_rot_matrix:new Bc(t),u_merc_center:new kc(t),u_tile_id:new Dc(t),u_zoom_transition:new $c(t),u_up_dir:new Dc(t),u_emissive_strength:new $c(t)}),t.bJ=t=>({u_matrix:new Bc(t),u_pixels_to_tile_units:new Uc(t),u_device_pixel_ratio:new $c(t),u_units_to_pixels:new kc(t),u_dash_image:new Pc(t),u_gradient_image:new Pc(t),u_image_height:new $c(t),u_texsize:new kc(t),u_tile_units_to_pixels:new $c(t),u_alpha_discard_threshold:new $c(t),u_trim_offset:new kc(t),u_trim_fade_range:new kc(t),u_trim_color:new zc(t),u_emissive_strength:new $c(t)}),t.bK=t=>({u_matrix:new Bc(t),u_texsize:new kc(t),u_pixels_to_tile_units:new Uc(t),u_device_pixel_ratio:new $c(t),u_image:new Pc(t),u_units_to_pixels:new kc(t),u_tile_units_to_pixels:new $c(t),u_alpha_discard_threshold:new $c(t),u_trim_offset:new kc(t)}),t.bL=Yl,t.bM=Hf,t.bN=Om,t.bO=jm,t.bP=G_,t.bQ=c_,t.bR=th,t.bS=(t,e,i,n,r,o)=>{const s=t.transform,a="globe"===s.projection.name;let l;if("map"===o.paint.get("circle-pitch-alignment"))if(a){const t=Zu(s.zoom,e.canonical)*s._pixelsPerMercatorPixel;l=Float32Array.from([t,0,0,t])}else l=s.calculatePixelsToTileUnitsMatrix(i);else l=new Float32Array([s.pixelsToGLUnits[0],0,0,s.pixelsToGLUnits[1]]);const c={u_camera_to_center_distance:t.transform.getCameraToCenterDistance(s.projection),u_matrix:t.translatePosMatrix(e.projMatrix,i,o.paint.get("circle-translate"),o.paint.get("circle-translate-anchor")),u_device_pixel_ratio:ki.devicePixelRatio,u_extrude_scale:l,u_inv_rot_matrix:Qu,u_merc_center:[0,0],u_tile_id:[0,0,0],u_zoom_transition:0,u_up_dir:[0,0,0],u_emissive_strength:o.paint.get("circle-emissive-strength")};if(a){c.u_inv_rot_matrix=n,c.u_merc_center=r,c.u_tile_id=[e.canonical.x,e.canonical.y,1{const s=t.transform;return{u_matrix:rm(t,e,i,n),u_texsize:e.imageAtlasTexture?e.imageAtlasTexture.size:[0,0],u_pixels_to_tile_units:s.calculatePixelsToTileUnitsMatrix(e),u_device_pixel_ratio:r,u_image:0,u_tile_units_to_pixels:nm(e,s),u_units_to_pixels:[1/s.pixelsToGLUnits[0],1/s.pixelsToGLUnits[1]],u_alpha_discard_threshold:0,u_trim_offset:o}},t.bV=(t,e,i,n,r,o,s)=>{const a=t.transform,l=a.calculatePixelsToTileUnitsMatrix(e);return{u_matrix:rm(t,e,i,n),u_pixels_to_tile_units:l,u_device_pixel_ratio:o,u_units_to_pixels:[1/a.pixelsToGLUnits[0],1/a.pixelsToGLUnits[1]],u_dash_image:0,u_gradient_image:1,u_image_height:r,u_texsize:sm(i)&&e.lineAtlasTexture?e.lineAtlasTexture.size:[0,0],u_tile_units_to_pixels:nm(e,t.transform),u_alpha_discard_threshold:0,u_trim_offset:s,u_trim_fade_range:i.paint.get("line-trim-fade-range"),u_trim_color:i.paint.get("line-trim-color").toRenderColor(i.lut).toArray01(),u_emissive_strength:i.paint.get("line-emissive-strength")}},t.bW=oi,t.bX=mh,t.bY=Sf,t.bZ=bd,t.b_=_f,t.ba=function(t,e,i){const n=Hu(i.zoom),r=t.style.map._antialias,o=e.options.extStandardDerivativesForceOff||t.terrain&&t.terrain.exaggeration()>0;return 0===n&&!r&&!o},t.bb=function(e){const i=e.pixelsPerMeter,n=i/Cd(1,e.center.lat),r=t.ad.identity(new Float64Array(16));return t.ad.translate(r,r,[e.point.x,e.point.y,0]),t.ad.scale(r,r,[n,n,i]),Float32Array.from(r)},t.bc=Ou,t.bd=function(t){const e=Pd-5;t=Xe(t,-e,e)/e*90;const i=Math.pow(Math.abs(Math.sin(Ge(t))),3);return Math.round(i*(sd.length-1))},t.be=function(e,i,n,r){const o=i.getNorth(),s=i.getSouth(),a=i.getWest(),l=i.getEast(),c=10){const e=180/r;t.bC.multiply(f,f,[e/d+1,0,0,0,e/u+1,0,-.5*e/h,.5*e/p,1])}return f[2]=c,f[5]=e.x,f[8]=e.y,f},t.bf=ju,t.bg=$u,t.bh=function(e,i,n){const r=t.ad.identity(new Float64Array(16)),o=(i/(1{}}},t.bo=Gg,t.bp=ai,t.bq=class{isDataAvailableAtPoint(t){const e=this._source();if(this.isUsingMockSource()||!e||t.y1)return!1;const i=e.getSource().maxzoom,n=11)return e;const r=n.getSource().maxzoom,o=1{const s=this.getAtTileOffset(e,o.x,o.y),a=r.upVector(e.canonical,o.x,o.y),l=r.upVectorScale(e.canonical,i,n).metersToTile;return t._.scale(a,a,s*l),a}}getForTilePoints(t,e,i,n){if(this.isUsingMockSource())return!1;const r=Xp.create(this,t,n);return!!r&&(e.forEach((t=>{t[2]=this.exaggeration()*r.getElevationAt(t[0],t[1],i)})),!0)}getMinMaxForTile(t){if(this.isUsingMockSource())return null;const e=this.findDEMTileFor(t);if(!e||!e.dem)return null;const i=e.dem.tree,n=e.tileID,r=1=0?t.slice(0,e):t},t.cV=function(t){return t.indexOf(wl)>=0},t.cW=function(t){const e=t.indexOf(wl);return e>=0?t.slice(e+1):""},t.cX=function(t){const e=[],i=t.id;return void 0===i&&e.push({message:`layers.${i}: missing required property "id"`}),void 0===t.render&&e.push({message:`layers.${i}: missing required method "render"`}),t.renderingMode&&"2d"!==t.renderingMode&&"3d"!==t.renderingMode&&e.push({message:`layers.${i}: property "renderingMode" must be either "2d" or "3d"`}),e},t.cY=function(t,e,i,n){return"custom"===t.type?new vv(t,e):new ib[t.type](t,e,i,n)},t.cZ=di,t.c_=Va,t.ca=1,t.cb=Ag,t.cc=0,t.cd=ec,t.ce=function(t,e,i,n,r){return Xe((t-e)/(i-e)*(r-n)+n,n,r)},t.cf=Ns,t.cg=kd,t.ch=class{constructor(t,e,i,n){this.context=t,this.format=n,this.size=i,this.texture=t.gl.createTexture();const[r,o,s]=this.size,{gl:a}=t;a.bindTexture(a.TEXTURE_3D,this.texture),t.pixelStoreUnpackFlipY.set(!1),t.pixelStoreUnpack.set(1),t.pixelStoreUnpackPremultiplyAlpha.set(!1);let l=this.format,c=a.UNSIGNED_BYTE;this.format===a.DEPTH_COMPONENT&&(l=a.DEPTH_COMPONENT16,c=a.UNSIGNED_SHORT),this.format===a.R8&&(n=a.RED),this.format===a.R32F&&(c=a.FLOAT,n=a.RED),a.texImage3D(a.TEXTURE_3D,0,l,r,o,s,0,n,c,e.data)}bind(t,e){const{context:i}=this,{gl:n}=i;n.bindTexture(n.TEXTURE_3D,this.texture),t!==this.minFilter&&(n.texParameteri(n.TEXTURE_3D,n.TEXTURE_MAG_FILTER,t),n.texParameteri(n.TEXTURE_3D,n.TEXTURE_MIN_FILTER,t),this.minFilter=t),e!==this.wrapS&&(n.texParameteri(n.TEXTURE_3D,n.TEXTURE_WRAP_S,e),n.texParameteri(n.TEXTURE_3D,n.TEXTURE_WRAP_T,e),this.wrapS=e)}destroy(){const{gl:t}=this.context;t.deleteTexture(this.texture),this.texture=null}},t.ci=$v,t.cj=[1,1,1],t.ck=Xp,t.cl=Yv,t.cm=ql,t.cn=ic,t.co=class{constructor(){this._updateTime=0,this._sourceIds=[],this._activeRegions=[],this._prevRegions=[],this._globalClipBounds={min:new Ue(1/0,1/0),max:new Ue(-1/0,-1/0)}}clear(){this._activeRegions.length>0&&++this._updateTime,this._activeRegions=[],this._prevRegions=[]}get updateTime(){return this._updateTime}getReplacementRegionsForTile(t,e=!1){const i=$p(new Ue(0,0),new Ue(uo,uo),t),n=[];if(e&&!Lp(i,this._globalClipBounds))return n;for(const e of this._activeRegions){if(e.hiddenByOverlap)continue;if(!Lp(i,e))continue;const r=kp(e.min,e.max,t);n.push({min:r.min,max:r.max,sourceId:this._sourceIds[e.priority],footprint:e.footprint,footprintTileId:e.tileId,order:e.order,clipMask:e.clipMask})}return n}setSources(t){this._setSources(t.map((t=>({getSourceId:()=>t.cache.id,getFootprints:()=>{const e=[];for(const i of t.cache.getVisibleCoordinates()){const n=t.cache.getTile(i).buckets[t.layer];n&&n.updateFootprints(i.toUnwrapped(),e)}return e},getOrder:()=>t.order,getClipMask:()=>t.clipMask}))))}_addSource(t){const e=t.getFootprints();if(0===e.length)return;const i=t.getOrder(),n=t.getClipMask();for(const t of e){if(!t.footprint)continue;const e=$p(t.footprint.min,t.footprint.max,t.id);this._activeRegions.push({min:e.min,max:e.max,hiddenByOverlap:!1,priority:this._sourceIds.length,tileId:t.id,footprint:t.footprint,order:i,clipMask:n})}this._sourceIds.push(t.getSourceId())}_computeReplacement(){this._activeRegions.sort(((t,e)=>t.priority-e.priority||Ap(t.min,e.min)||Ap(t.max,e.max)));let t=this._activeRegions.length!==this._prevRegions.length;if(!t){let e=0;for(;!t&&e!==this._activeRegions.length;){const i=this._activeRegions[e],n=this._prevRegions[e];t=i.priority!==n.priority||!Ip(i,n)||i.order!==n.order||i.clipMask!==n.clipMask,++e}}if(t){++this._updateTime;for(const t of this._activeRegions)t.order!==1/0&&(this._globalClipBounds.min.x=Math.min(this._globalClipBounds.min.x,t.min.x),this._globalClipBounds.min.y=Math.min(this._globalClipBounds.min.y,t.min.y),this._globalClipBounds.max.x=Math.max(this._globalClipBounds.max.x,t.max.x),this._globalClipBounds.max.y=Math.max(this._globalClipBounds.max.y,t.max.y));const t=t=>{const e=this._activeRegions;if(t>=e.length)return t;const i=e[t].priority;for(;t1){let e=0,i=t(e);for(;e!==i;){let n=e;const r=e;for(;n!==i;){const t=this._activeRegions[n];t.hiddenByOverlap=!1;for(let e=0;e=0;e--)this._addSource(t[e]);this._computeReplacement()}},t.cp=Dl,t.cq=Jg,t.cr=rc,t.cs=class{constructor(t){this._createGrid(t),this._createPoles(t)}destroy(){this._poleIndexBuffer.destroy(),this._gridBuffer.destroy(),this._gridIndexBuffer.destroy(),this._poleNorthVertexBuffer.destroy(),this._poleSouthVertexBuffer.destroy();for(const t of this._poleSegments)t.destroy();for(const t of this._gridSegments)t.withSkirts.destroy(),t.withoutSkirts.destroy()}_fillGridMeshWithLods(t,e){const i=new $l,n=new Kl,r=[],o=t+1+2,s=e[0]+1,a=e[0]+1+(1+e.length),l=(t,e,i)=>{let n=t===o-1?t-2:0===t?t:t-1;return n+=i?24575:0,[n,e]};for(let t=0;tt()))},t.dB=sx,t.dC=yx,t.dD=function(t){px=ki.resolveURL(t),gx||(gx=new ox(ux(),new zn)),gx.broadcast("setDracoUrl",px)},t.dE=vx,t.dF=function(t){mx=ki.resolveURL(t),gx||(gx=new ox(ux(),new zn)),gx.broadcast("setMeshoptUrl",mx)},t.dG=ti,t.dH=ba,t.dI=dh,t.dJ=I_,t.dK=eg,t.dL=dc,t.dM=am,t.dN=Dm,t.dO=Wf,t.dP=ci,t.dQ=E_,t.dR=jg,t.dS=function(t,e,i,n,r,o,s,a,l,c,d){t.createArrays(),t.tilePixelRatio=uo/(512*t.overscaling),t.compareText={},t.iconsNeedLinear=!1;const u=t.layers[0].layout,h=t.layers[0]._unevaluatedLayout._values,p={};if("composite"===t.textSizeData.kind){const{minZoom:e,maxZoom:i}=t.textSizeData;p.compositeTextSizes=[h["text-size"].possiblyEvaluate(new Ha(e),a),h["text-size"].possiblyEvaluate(new Ha(i),a)]}if("composite"===t.iconSizeData.kind){const{minZoom:e,maxZoom:i}=t.iconSizeData;p.compositeIconSizes=[h["icon-size"].possiblyEvaluate(new Ha(e),a),h["icon-size"].possiblyEvaluate(new Ha(i),a)]}p.layoutTextSize=h["text-size"].possiblyEvaluate(new Ha(l+1),a),p.layoutIconSize=h["icon-size"].possiblyEvaluate(new Ha(l+1),a),p.textMaxSize=h["text-size"].possiblyEvaluate(new Ha(18),a);const f="map"===u.get("text-rotation-alignment")&&"point"!==u.get("symbol-placement"),m=u.get("text-size");let _=!1;for(const e of t.features)if(e.icon&&e.icon.nameSecondary){_=!0;break}for(const o of t.features){const l=u.get("text-font").evaluate(o,{},a).join(","),h=m.evaluate(o,{},a),g=p.layoutTextSize.evaluate(o,{},a),y=(p.layoutIconSize.evaluate(o,{},a),{horizontal:{},vertical:void 0}),v=o.text;let x,b=[0,0];if(v){const n=v.toString(),s=u.get("text-letter-spacing").evaluate(o,{},a)*Om,c=u.get("text-line-height").evaluate(o,{},a)*Om,d=Aa(n)?s:0,p=u.get("text-anchor").evaluate(o,{},a),m=u.get("text-variable-anchor");if(!m){const t=u.get("text-radial-offset").evaluate(o,{},a);b=t?G_(p,[t*Om,j_]):u.get("text-offset").evaluate(o,{},a).map((t=>t*Om))}let _=f?"center":u.get("text-justify").evaluate(o,{},a);const x="point"===u.get("symbol-placement"),w=x?u.get("text-max-width").evaluate(o,{},a)*Om:1/0,T=o=>{t.allowVerticalPlacement&&Ca(n)&&(y.vertical=e_(v,e,i,r,l,w,c,p,o,d,b,Jm.vertical,!0,g,h))};if(!f&&m){const t="auto"===_?m.map((t=>Z_(t))):[_];let n=!1;for(let o=0;o=0||!Ca(n)){const t=e_(v,e,i,r,l,w,c,p,_,d,b,Jm.horizontal,!1,g,h);t&&(y.horizontal[_]=t)}T(x?"left":_)}}let w=!1;if(o.icon&&o.icon.namePrimary){const e=n[o.icon.namePrimary];e&&(x=u_(r[o.icon.namePrimary],o.icon.nameSecondary?r[o.icon.nameSecondary]:void 0,u.get("icon-offset").evaluate(o,{},a),u.get("icon-anchor").evaluate(o,{},a)),w=e.sdf,void 0===t.sdfIcons?t.sdfIcons=e.sdf:t.sdfIcons!==e.sdf&&pi("Style sheet warning: Cannot mix SDF and non-SDF icons in one buffer"),(e.pixelRatio!==t.pixelRatio||0!==u.get("icon-rotate").constantOr(1))&&(t.iconsNeedLinear=!0))}const T=X_(y.horizontal)||y.vertical;t.iconsInText||(t.iconsInText=!!T&&T.iconsInText),(T||x)&&q_(t,o,y,x,n,p,g,0,b,w,s,a,c,d,_)}o&&t.generateCollisionDebugBuffers(l,t.collisionBoxArray)},t.dT=Jf,t.dU=Yh,t.dV=bp,t.dW=Lm,t.dX=Yp,t.dY=Zy,t.dZ=wp,t.d_=cp,t.da=Wu,t.db=function(e){const i=[0,0,0],n=t.ad.identity(new Float64Array(16));return t.ad.multiply(n,e.pixelMatrix,e.globeMatrix),t._.transformMat4(i,i,n),new Ue(i[0],i[1])},t.dc=d,t.dd=c,t.de=function(t){const e=t.navigator?t.navigator.userAgent:null;return!!function(t){if(null==Ei){const e=t.navigator?t.navigator.userAgent:null;Ei=!!t.safari||!(!e||!(/\b(iPad|iPhone|iPod)\b/.test(e)||e.match("Safari")&&!e.match("Chrome")))}return Ei}(t)&&e&&(e.match("Version/15.4")||e.match("Version/15.5")||e.match(/CPU (OS|iPhone OS) (15_4|15_5) like Mac OS X/))},t.df=ni,t.dg=class{constructor(t,e,i){this._transformRequestFn=t,this._customAccessToken=e,this._silenceAuthErrors=!!i,this._createSkuToken()}_createSkuToken(){const t=function(){let t="";for(let e=0;ethis._skuTokenExpiresAt}transformRequest(t,e){return this._transformRequestFn&&this._transformRequestFn(t,e)||{url:t}}normalizeStyleURL(t,i){if(!o(t))return t;const n=un(t);return n.params.push(`sdk=js-${e}`),n.path=`/styles/v1${n.path}`,this._makeAPIURL(n,this._customAccessToken||i)}normalizeGlyphsURL(t,e){if(!o(t))return t;const i=un(t);return i.path=`/fonts/v1${i.path}`,this._makeAPIURL(i,this._customAccessToken||e)}normalizeModelURL(t,e){if(!o(t))return t;const i=un(t);return i.path=`/models/v1${i.path}`,this._makeAPIURL(i,this._customAccessToken||e)}normalizeSourceURL(t,e,i,n){if(!o(t))return t;const r=un(t);return r.path=`/v4/${r.authority}.json`,r.params.push("secure"),i&&r.params.push(`language=${i}`),n&&r.params.push(`worldview=${n}`),this._makeAPIURL(r,this._customAccessToken||e)}normalizeSpriteURL(t,e,i,n){const r=un(t);return o(t)?(r.path=`/styles/v1${r.path}/sprite${e}${i}`,this._makeAPIURL(r,this._customAccessToken||n)):(r.path+=`${e}${i}`,hn(r))}normalizeTileURL(t,e,i){if(this._isSkuTokenExpired()&&this._createSkuToken(),t&&!o(t))return t;const r=un(t);r.path=r.path.replace(/(\.(png|jpg)\d*)(?=$)/,`${e||i&&"raster"!==r.authority&&512===i?"@2x":""}${Gi.supported?".webp":"$1"}`),"raster"===r.authority?r.path=`/${n.RASTER_URL_PREFIX}${r.path}`:"rasterarrays"===r.authority?r.path=`/${n.RASTERARRAYS_URL_PREFIX}${r.path}`:"3dtiles"===r.authority?r.path=`/${n.TILES3D_URL_PREFIX}${r.path}`:(r.path=r.path.replace(/^.+\/v4\//,"/"),r.path=`/${n.TILE_URL_VERSION}${r.path}`);const s=this._customAccessToken||function(t){for(const e of t){const t=e.match(/^access_token=(.*)$/);if(t)return t[1]}return null}(r.params)||n.ACCESS_TOKEN;return n.REQUIRE_ACCESS_TOKEN&&s&&this._skuToken&&r.params.push(`sku=${this._skuToken}`),this._makeAPIURL(r,s)}canonicalizeTileURL(t,e){const i=un(t);if(!i.path.match(/^(\/v4\/|\/(raster|rasterarrays)\/v1\/)/)||!i.path.match(/\.[\w]+$/))return t;let r="mapbox://";i.path.match(/^\/raster\/v1\//)?r+=`raster/${i.path.replace(`/${n.RASTER_URL_PREFIX}/`,"")}`:i.path.match(/^\/rasterarrays\/v1\//)?r+=`rasterarrays/${i.path.replace(`/${n.RASTERARRAYS_URL_PREFIX}/`,"")}`:r+=`tiles/${i.path.replace(`/${n.TILE_URL_VERSION}/`,"")}`;let o=i.params;return e&&(o=o.filter((t=>!t.match(/^access_token=/)))),o.length&&(r+=`?${o.join("&")}`),r}canonicalizeTileset(t,e){const i=!!e&&o(e),n=[];for(const e of t.tiles||[])r(e)?n.push(this.canonicalizeTileURL(e,i)):n.push(e);return n}_makeAPIURL(t,e){const i="See https://docs.mapbox.com/api/overview/#access-tokens-and-token-scopes",r=un(n.API_URL);if(t.protocol=r.protocol,t.authority=r.authority,"http"===t.protocol){const e=t.params.indexOf("secure");e>=0&&t.params.splice(e,1)}if("/"!==r.path&&(t.path=`${r.path}${t.path}`),!n.REQUIRE_ACCESS_TOKEN)return hn(t);if(e=e||n.ACCESS_TOKEN,!this._silenceAuthErrors){if(!e)throw new Error(`An API access token is required to use Mapbox GL. ${i}`);if("s"===e[0])throw new Error(`Use a public access token (pk.*) with Mapbox GL, not a secret access token (sk.*). ${i}`)}return t.params=t.params.filter((t=>-1===t.indexOf("access_token"))),t.params.push(`access_token=${e||""}`),hn(t)}},t.dh=function(t,e){e?Mn.add(t):Mn.delete(t)},t.di=Gi,t.dj=Tn,t.dk=En,t.dl=cn,t.dm=vn,t.dn=bn,t.dp=function(t){Mn.delete(t)},t.dq=Sn,t.dr=yn,t.ds=Qe,t.dt=e,t.du=function(t,e){Fi=t,Ni=e},t.dv=function(t,e,i=!1){if(Fa===za||Fa===Ra||Fa===Oa)throw new Error("setRTLTextPlugin cannot be called multiple times.");Na=ki.resolveURL(t),Fa=za,Ba=e,ja(),i||Za()},t.dw=Ga,t.dx=function(){ux().acquire(lx)},t.dy=function(){const t=dx;t&&(t.isPreloaded()&&1===t.numActive()?(t.release(lx),dx=null):console.warn("Could not clear WebWorkers since there are active Map instances that still reference it. The pre-warmed WebWorker pool can only be cleared when all map instances have been removed with map.remove()"))},t.dz=cx,t.e=ki,t.e0=cm,t.e1=h,t.e2=en,t.e3=function(t){let e=0;if(new Uint32Array(t,0,1)[0]!==Ax){const i=new Uint32Array(t,0,7),[,,n,r,o,s]=i;e=i.byteLength+r+o+s+o,(n!==t.byteLength||e>=t.byteLength)&&pi("Invalid b3dm header information.")}return Dx(t,e)},t.e4=function(t,e){const i=jx(t);for(const t of i){for(const e of t.meshes)Vx(e);t.lights&&(t.lightMeshIndex=t.meshes.length,t.meshes.push(Gx(t.lights,e)))}return i},t.e5=Kx,t.e6=rx,t.e7=qa,t.e8=function(t){ji(),Oi&&Oi.then((e=>{e.keys().then((i=>{for(let n=0;nt.arrayBuffer())).then((e=>Dx(e,0,t)))},t.m=class extends Uv{},t.n=Er,t.o=qn,t.p=Qg,t.q=Xs,t.r=Js,t.s=Qs,t.t=ca,t.u=al,t.v=ll,t.w=pi,t.x=pa,t.y=da,t.z=qo})),n(0,(function(t){function e(t){const e=t?t.url.toString():void 0;return e?performance.getEntriesByName(e):[]}function i(t){if("number"==typeof t||"boolean"==typeof t||"string"==typeof t||null==t)return JSON.stringify(t);if(Array.isArray(t)){let e="[";for(const n of t)e+=`${i(n)},`;return`${e}]`}let e="{";for(const n of Object.keys(t).sort())e+=`${n}:${i(t[n])},`;return`${e}}`}function n(e){let n="";for(const r of t.cE)n+=`/${i(e[r])}`;return n}class r{constructor(t){this.keyCache={},this._layers={},this._layerConfigs={},t&&this.replace(t)}replace(t,e){this._layerConfigs={},this._layers={},this.update(t,[],e)}update(e,i,r){this._options=r;for(const i of e)this._layerConfigs[i.id]=i,(this._layers[i.id]=t.cY(i,this.scope,null,this._options)).compileFilter(),this.keyCache[i.id]&&delete this.keyCache[i.id];for(const t of i)delete this.keyCache[t],delete this._layerConfigs[t],delete this._layers[t];this.familiesBySource={};const o=function(t,e){const i={};for(let r=0;rthis._layers[t.id])),i=e[0];if("none"===i.visibility)continue;const n=i.source||"";let r=this.familiesBySource[n];r||(r=this.familiesBySource[n]={});const o=i.sourceLayer||"_geojsonTileLayer";let s=r[o];s||(s=r[o]=[]),s.push(e)}}}const o=1*t.dJ;class s{constructor(e){const i={},n=[];for(const t in e){const r=e[t],s=i[t]={};for(const t in r.glyphs){const e=r.glyphs[+t];if(!e||0===e.bitmap.width||0===e.bitmap.height)continue;const i=e.metrics.localGlyph?o:1,a={x:0,y:0,w:e.bitmap.width+2*i,h:e.bitmap.height+2*i};n.push(a),s[t]=a}}const{w:r,h:s}=t.j(n),a=new t.dI({width:r||1,height:s||1});for(const n in e){const r=e[n];for(const e in r.glyphs){const s=r.glyphs[+e];if(!s||0===s.bitmap.width||0===s.bitmap.height)continue;const l=i[n][e],c=s.metrics.localGlyph?o:1;t.dI.copy(s.bitmap,a,{x:0,y:0},{x:l.x+c,y:l.y+c},s.bitmap)}}this.image=a,this.positions=i}}t.dH(s,"GlyphAtlas");class a{constructor(e){this.tileID=new t.aL(e.tileID.overscaledZ,e.tileID.wrap,e.tileID.canonical.z,e.tileID.canonical.x,e.tileID.canonical.y),this.tileZoom=e.tileZoom,this.uid=e.uid,this.zoom=e.zoom,this.lut=e.lut,this.canonical=e.tileID.canonical,this.pixelRatio=e.pixelRatio,this.tileSize=e.tileSize,this.source=e.source,this.scope=e.scope,this.overscaling=this.tileID.overscaleFactor(),this.showCollisionBoxes=e.showCollisionBoxes,this.collectResourceTiming=!!e.collectResourceTiming,this.promoteId=e.promoteId,this.isSymbolTile=e.isSymbolTile,this.tileTransform=t.dK(e.tileID.canonical,e.projection),this.projection=e.projection,this.brightness=e.brightness,this.extraShadowCaster=!!e.extraShadowCaster,this.tessellationStep=e.tessellationStep}parse(e,i,n,r,o){this.status="parsing",this.data=e,this.collisionBoxArray=new t.dL;const a=new t.dM(Object.keys(e.layers).sort()),c=new t.dN(this.tileID,this.promoteId);c.bucketLayerIDs=[];const d={},u=new t.dO(256,256),h={featureIndex:c,iconDependencies:{},patternDependencies:{},glyphDependencies:{},lineAtlas:u,availableImages:n,brightness:this.brightness},p=i.familiesBySource[this.source];for(const i in p){const r=e.layers[i];if(!r)continue;let o=!1,s=!1,u=!1;for(const t of p[i])"symbol"===t[0].type?o=!0:s=!0,t[0].is3D()&&"model"!==t[0].type&&(u=!0);if(this.extraShadowCaster&&!u)continue;if(!0===this.isSymbolTile&&!o)continue;if(!1===this.isSymbolTile&&!s)continue;1===r.version&&t.w(`Vector tile source "${this.source}" layer "${i}" does not use vector tile spec v2 and therefore may have some rendering errors.`);const f=a.encode(i),m=[];for(let t=0;t=e.maxzoom||"none"!==e.visibility&&(l(t,this.zoom,h.brightness,n),(d[e.id]=e.createBucket({index:c.bucketLayerIDs.length,layers:t,zoom:this.zoom,lut:this.lut,canonical:this.canonical,pixelRatio:this.pixelRatio,overscaling:this.overscaling,collisionBoxArray:this.collisionBoxArray,sourceLayerIndex:f,sourceID:this.source,projection:this.projection.spec,tessellationStep:this.tessellationStep})).populate(m,h,this.tileID.canonical,this.tileTransform),c.bucketLayerIDs.push(t.map((t=>t.id)))))}}let f,m,_,g;u.trim();const y={type:"maybePrepare",isSymbolTile:this.isSymbolTile,zoom:this.zoom},v=()=>{if(f)return this.status="done",o(f);if(this.extraShadowCaster)this.status="done",o(null,{buckets:t.dG(d).filter((t=>!t.isEmpty())),featureIndex:c,collisionBoxArray:null,glyphAtlasImage:null,lineAtlas:null,imageAtlas:null,brightness:h.brightness,glyphMap:null,iconMap:null,glyphPositions:null});else if(m&&_&&g){const e=new s(m),i=new t.dQ(_,g,this.lut);for(const r in d){const o=d[r];o instanceof t.dR?(l(o.layers,this.zoom,h.brightness,n),t.dS(o,m,e.positions,_,i.iconPositions,this.showCollisionBoxes,n,this.tileID.canonical,this.tileZoom,this.projection,this.brightness)):o.hasPattern&&(o instanceof t.dT||o instanceof t.dU||o instanceof t.b_)&&(l(o.layers,this.zoom,h.brightness,n),o.addFeatures(h,this.tileID.canonical,i.patternPositions,n,this.tileTransform,this.brightness))}this.status="done",o(null,{buckets:t.dG(d).filter((t=>!t.isEmpty())),featureIndex:c,collisionBoxArray:this.collisionBoxArray,glyphAtlasImage:e.image,lineAtlas:u,imageAtlas:i,brightness:h.brightness})}};if(!this.extraShadowCaster){const e=t.dP(h.glyphDependencies,(t=>Object.keys(t).map(Number)));Object.keys(e).length?r.send("getGlyphs",{uid:this.uid,stacks:e,scope:this.scope},((t,e)=>{f||(f=t,m=e,v())}),void 0,!1,y):m={};const i=Object.keys(h.iconDependencies);i.length?r.send("getImages",{icons:i,source:this.source,scope:this.scope,tileID:this.tileID,type:"icons"},((t,e)=>{f||(f=t,_=e,v())}),void 0,!1,y):_={};const n=Object.keys(h.patternDependencies);n.length?r.send("getImages",{icons:n,source:this.source,scope:this.scope,tileID:this.tileID,type:"patterns"},((t,e)=>{f||(f=t,g=e,v())}),void 0,!1,y):g={}}v()}}function l(e,i,n,r){const o=new t.X(i,{brightness:n});for(const t of e)t.recalculate(o,r)}class c extends t.E{constructor(e,i,n,r,o,s){super(),this.actor=e,this.layerIndex=i,this.availableImages=n,this.loadVectorData=o||t.ap,this.loading={},this.loaded={},this.deduped=new t.ao(e.scheduler),this.isSpriteLoaded=r,this.scheduler=e.scheduler,this.brightness=s}loadTile(i,n){const r=i.uid,o=i&&i.request,s=o&&o.collectResourceTiming,l=this.loading[r]=new a(i);l.abort=this.loadVectorData(i,((a,c)=>{const d=!this.loading[r];if(delete this.loading[r],d||a||!c)return l.status="done",d||(this.loaded[r]=l),n(a);const u=c.rawData,h={};c.expires&&(h.expires=c.expires),c.cacheControl&&(h.cacheControl=c.cacheControl),l.vectorTile=c.vectorTile||new t.dV(new t.dW(u));const p=()=>{l.parse(l.vectorTile,this.layerIndex,this.availableImages,this.actor,((i,r)=>{if(i||!r)return n(i);const a={};if(s){const t=e(o);t.length>0&&(a.resourceTiming=JSON.parse(JSON.stringify(t)))}n(null,t.W({rawTileData:u.slice(0)},r,h,a))}))};this.isSpriteLoaded?p():this.once("isSpriteLoaded",(()=>{this.scheduler?this.scheduler.add(p,{type:"parseTile",isSymbolTile:i.isSymbolTile,zoom:i.tileZoom}):p()})),this.loaded=this.loaded||{},this.loaded[r]=l}))}reloadTile(e,i){const n=this.loaded,r=e.uid;if(n&&n[r]){const o=n[r];o.showCollisionBoxes=e.showCollisionBoxes,o.projection=e.projection,o.brightness=e.brightness,o.tileTransform=t.dK(e.tileID.canonical,e.projection),o.extraShadowCaster=e.extraShadowCaster,o.lut=e.lut;const s=(t,e)=>{const n=o.reloadCallback;n&&(delete o.reloadCallback,o.parse(o.vectorTile,this.layerIndex,this.availableImages,this.actor,n)),i(t,e)};"parsing"===o.status?o.reloadCallback=s:"done"===o.status&&(o.vectorTile?o.parse(o.vectorTile,this.layerIndex,this.availableImages,this.actor,s):s())}else i(null,void 0)}abortTile(t,e){const i=t.uid,n=this.loading[i];n&&(n.abort&&n.abort(),delete this.loading[i]),e()}removeTile(t,e){const i=this.loaded,n=t.uid;i&&i[n]&&delete i[n],e()}}class d{loadTile(e,i){const{uid:n,encoding:r,rawImageData:o,padding:s}=e,a=ImageBitmap&&o instanceof ImageBitmap?this.getImageData(o,s):o;i(null,new t.dX(n,a,r,s{n(null,t)}),(t=>{n(t)}))}}const h=t.dZ.prototype.toGeoJSON;let p=class{constructor(e){this._feature=e,this.extent=t.a3,this.type=e.type,this.properties=e.tags,"id"in e&&!isNaN(e.id)&&(this.id=parseInt(e.id,10))}loadGeometry(){if(1===this._feature.type){const e=[];for(const i of this._feature.geometry)e.push([new t.P(i[0],i[1])]);return e}{const e=[];for(const i of this._feature.geometry){const n=[];for(const e of i)n.push(new t.P(e[0],e[1]));e.push(n)}return e}}toGeoJSON(t,e,i){return h.call(this,t,e,i)}},f=class{constructor(e){this.layers={_geojsonTileLayer:this},this.name="_geojsonTileLayer",this.extent=t.a3,this.length=e.length,this._features=e}feature(t){return new p(this._features[t])}};const m=64/4096;class _{constructor(){this.features=new Map}clear(){this.features.clear()}load(t=[],e){for(const i of t){const t=i.id;if(null==t)continue;let n=this.features.get(t);n&&this.updateCache(n,e),i.geometry?(n=y(i),this.updateCache(n,e),this.features.set(t,n)):this.features.delete(t),this.updateCache(n,e)}}updateCache(t,e){for(const{canonical:i,uid:n}of Object.values(e)){const{z:r,x:o,y:s}=i;g(t,Math.pow(2,r),o,s)&&delete e[n]}}getTile(t,e,i){const n=Math.pow(2,t),r=[];for(const t of this.features.values())g(t,n,e,i)&&r.push(w(t,n,e,i));return{features:r}}getFeatures(){return[...this.features.values()]}}function g({minX:t,minY:e,maxX:i,maxY:n},r,o,s){return t(o-m)/r&&n>(s-m)/r}function y(t){const{id:e,geometry:i,properties:n}=t;if(!i)return;if("GeometryCollection"===i.type)throw new Error("GeometryCollection not supported in dynamic mode.");const{type:r,coordinates:o}=i,s={id:e,type:1,geometry:[],tags:n,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0},a=s.geometry;if("Point"===r)v(o,a,s);else if("MultiPoint"===r)for(const t of o)v(t,a,s);else if("LineString"===r)s.type=2,x(o,a,s);else if("MultiLineString"===r)s.type=2,b(o,a,s);else if("Polygon"===r)s.type=3,b(o,a,s,!0);else{if("MultiPolygon"!==r)throw new Error("Input data is not a valid GeoJSON object.");s.type=3;for(const t of o)b(t,a,s,!0)}return s}function v([e,i],n,r){const o=t.aj(e);let s=t.ak(i);s=s1?1:s,n.push(o,s),r.minX=Math.min(r.minX,o),r.minY=Math.min(r.minY,s),r.maxX=Math.max(r.maxX,o),r.maxY=Math.max(r.maxY,s)}function x(t,e,i,n=!1,r=!1){const o=[];for(const e of t)v(e,o,i);e.push(o),n&&function(t,e){let i=0;for(let e=0,n=t.length,r=n-2;e0===e)for(let e=0,i=t.length;e>31}function F(t,e){for(var i=t.loadGeometry(),n=t.type,r=0,o=0,s=i.length,a=0;at},V=Math.fround||(G=new Float32Array(1),t=>(G[0]=+t,G[0]));var G;const Z=3,q=5,H=6;class W{constructor(t){this.options=Object.assign(Object.create(j),t),this.trees=new Array(this.options.maxZoom+1),this.stride=this.options.reduce?7:6,this.clusterProps=[]}load(t){const{log:e,minZoom:i,maxZoom:n}=this.options;e&&console.time("total time");const r=`prepare ${t.length} points`;e&&console.time(r),this.points=t;const o=[];for(let e=0;e=i;t--){const i=+Date.now();s=this.trees[t]=this._createTree(this._cluster(s,t)),e&&console.log("z%d: %d clusters in %dms",t,s.numItems,+Date.now()-i)}return e&&console.timeEnd("total time"),this}getClusters(t,e){let i=((t[0]+180)%360+360)%360-180;const n=Math.max(-90,Math.min(90,t[1]));let r=180===t[2]?180:((t[2]+180)%360+360)%360-180;const o=Math.max(-90,Math.min(90,t[3]));if(t[2]-t[0]>=360)i=-180,r=180;else if(i>r){const t=this.getClusters([i,n,180,o],e),s=this.getClusters([-180,n,r,o],e);return t.concat(s)}const s=this.trees[this._limitZoom(e)],a=s.range(K(i),J(o),K(r),J(n)),l=s.data,c=[];for(const t of a){const e=this.stride*t;c.push(l[e+q]>1?Y(l,e,this.clusterProps):this.points[l[e+Z]])}return c}getChildren(t){const e=this._getOriginId(t),i=this._getOriginZoom(t),n="No cluster with the specified id.",r=this.trees[i];if(!r)throw new Error(n);const o=r.data;if(e*this.stride>=o.length)throw new Error(n);const s=this.options.radius/(this.options.extent*Math.pow(2,i-1)),a=r.within(o[e*this.stride],o[e*this.stride+1],s),l=[];for(const e of a){const i=e*this.stride;o[i+4]===t&&l.push(o[i+q]>1?Y(o,i,this.clusterProps):this.points[o[i+Z]])}if(0===l.length)throw new Error(n);return l}getLeaves(t,e,i){const n=[];return this._appendLeaves(n,t,e=e||10,i=i||0,0),n}getTile(t,e,i){const n=this.trees[this._limitZoom(t)],r=Math.pow(2,t),{extent:o,radius:s}=this.options,a=s/o,l=(i-a)/r,c=(i+1+a)/r,d={features:[]};return this._addTileFeatures(n.range((e-a)/r,l,(e+1+a)/r,c),n.data,e,i,r,d),0===e&&this._addTileFeatures(n.range(1-a/r,l,1,c),n.data,r,i,r,d),e===r-1&&this._addTileFeatures(n.range(0,l,a/r,c),n.data,-1,i,r,d),d.features.length?d:null}getClusterExpansionZoom(t){let e=this._getOriginZoom(t)-1;for(;e1;let l,c,d;if(a)l=X(e,t,this.clusterProps),c=e[t],d=e[t+1];else{const i=this.points[e[t+Z]];l=i.properties;const[n,r]=i.geometry.coordinates;c=K(n),d=J(r)}const u={type:1,geometry:[[Math.round(this.options.extent*(c*r-i)),Math.round(this.options.extent*(d*r-n))]],tags:l};let h;h=a||this.options.generateId?e[t+Z]:this.points[e[t+Z]].id,void 0!==h&&(u.id=h),o.features.push(u)}}_limitZoom(t){return Math.max(this.options.minZoom,Math.min(Math.floor(+t),this.options.maxZoom+1))}_cluster(t,e){const{radius:i,extent:n,reduce:r,minPoints:o}=this.options,s=i/(n*Math.pow(2,e)),a=t.data,l=[],c=this.stride;for(let i=0;ie&&(p+=a[i+q])}if(p>h&&p>=o){let t,o=n*h,s=d*h,f=-1;const m=(i/c1)for(const t of u){const i=t*c;if(!(a[i+2]>5}_getOriginZoom(t){return(t-this.points.length)%32}_map(t,e,i){if(t[e+q]>1){const n=this.clusterProps[t[e+H]];return i?Object.assign({},n):n}const n=this.points[t[e+Z]].properties,r=this.options.map(n);return i&&r===n?Object.assign({},r):r}}function Y(t,e,i){return{type:"Feature",id:t[e+Z],properties:X(t,e,i),geometry:{type:"Point",coordinates:[(n=t[e],360*(n-.5)),Q(t[e+1])]}};var n}function X(t,e,i){const n=t[e+q],r=n>=1e4?`${Math.round(n/1e3)}k`:n>=1e3?Math.round(n/100)/10+"k":n,o=t[e+H],s=-1===o?{}:Object.assign({},i[o]);return Object.assign(s,{cluster:!0,cluster_id:t[e+Z],point_count:n,point_count_abbreviated:r})}function K(t){return t/360+.5}function J(t){const e=Math.sin(t*Math.PI/180),i=.5-.25*Math.log((1+e)/(1-e))/Math.PI;return i1?1:i}function Q(t){const e=(180-360*t)*Math.PI/180;return 360*Math.atan(Math.exp(e))/Math.PI-90}function tt(t,e,i,n){let r=n;const o=e+(i-e>>1);let s,a=i-e;const l=t[e],c=t[e+1],d=t[i],u=t[i+1];for(let n=e+3;n -i/2;){if(s--,sn;)c-=l.shift().angleDelta;if(c>r)return!1;s++,a+=e.dist(i)}return!0}function m_(t){let e=0;for(let i=0;ic){const d=(c-l)/o,u=Vn(n.x,r.x,d),h=Vn(n.y,r.y,d),p=new p_(u,h,0,r.angleTo(n),i);return!s||f_(t,p,a,s,e)?p:void 0}l+=o}}function v_(t,e,i,n,r,o,s,a,l){const c=__(n,o,s),d=g_(n,r),u=d*s,h=0===t[0].x||t[0].x===l||0===t[0].y||t[0].y===l;return e-u=0&&g=0&&y=0&&h+c=n&&c.x>=n||(s.x>=n?s=new Ue(n,s.y+(n-s.x)/(c.x-s.x)*(c.y-s.y))._round():c.x>=n&&(c=new Ue(n,s.y+(n-s.x)/(c.x-s.x)*(c.y-s.y))._round()),s.y>=r&&c.y>=r||(s.y>=r?s=new Ue(s.x+(r-s.y)/(c.y-s.y)*(c.x-s.x),r)._round():c.y>=r&&(c=new Ue(s.x+(r-s.y)/(c.y-s.y)*(c.x-s.x),r)._round()),l&&s.equals(l[l.length-1])||(l=[s],o.push(l)),l.push(c)))))}}return o}function w_(t){let e=0,i=0;for(const n of t)e+=n.w*n.h,i=Math.max(i,n.w);t.sort(((t,e)=>e.h-t.h));const n=[{x:0,y:0,w:Math.max(Math.ceil(Math.sqrt(e/.95)),i),h:1/0}];let r=0,o=0;for(const e of t)for(let t=n.length-1;t>=0;t--){const i=n[t];if(!(e.w>i.w||e.h>i.h)){if(e.x=i.x,e.y=i.y,o=Math.max(o,e.y+e.h),r=Math.max(r,e.x+e.w),e.w===i.w&&e.h===i.h){const e=n.pop();tt.hasImage(e,i))),t.dispatchRenderCallbacks(this.haveRenderCallbacks,i);for(const n in t.getUpdatedImages(i))this.patchUpdatedImage(this.iconPositions[n],t.getImage(n,i),e),this.patchUpdatedImage(this.patternPositions[n],t.getImage(n,i),e)}patchUpdatedImage(t,e,i){if(!t||!e)return;if(t.version===e.version)return;t.version=e.version;const[n,r]=t.tl,o=!!Object.keys(this.patternPositions).length;i.update(e.data,{useMipmap:o},{x:n,y:r})}}ba(S_,"ImagePosition"),ba(E_,"ImageAtlas");const M_=1e20;function C_(t,e,i,n,r,o,s,a,l){for(let c=e;c-1);l++,o[l]=a,s[l]=c,s[l+1]=M_}for(let a=0,l=0;a{let n=this.entries[t];n||(n=this.entries[t]={glyphs:{},requests:{},ranges:{},ascender:void 0,descender:void 0});let r=n.glyphs[e];if(void 0!==r)return void i(null,{stack:t,id:e,glyph:r});if(r=this._tinySDF(n,t,e),r)return n.glyphs[e]=r,void i(null,{stack:t,id:e,glyph:r});const s=Math.floor(e/256);if(256*s>65535)return void i(new Error("glyphs > 65535 not supported"));if(n.ranges[s])return void i(null,{stack:t,id:e,glyph:r});let a=n.requests[s];a||(a=n.requests[s]=[],P_.loadGlyphRange(t,s,o,this.requestManager,((t,e)=>{if(e){n.ascender=e.ascender,n.descender=e.descender;for(const t in e.glyphs)this._doesCharSupportLocalGlyph(+t)||(n.glyphs[+t]=e.glyphs[+t]);n.ranges[s]=!0}for(const i of a)i(t,e);delete n.requests[s]}))),a.push(((n,r)=>{n?i(n):r&&i(null,{stack:t,id:e,glyph:r.glyphs[e]||null})}))}),((t,e)=>{if(t)i(t);else if(e){const t={};for(const{stack:i,id:n,glyph:r}of e)void 0===t[i]&&(t[i]={}),void 0===t[i].glyphs&&(t[i].glyphs={}),t[i].glyphs[n]=r&&{id:r.id,bitmap:r.bitmap.clone(),metrics:r.metrics},t[i].ascender=this.entries[i].ascender,t[i].descender=this.entries[i].descender;i(null,t)}}))}_doesCharSupportLocalGlyph(t){return this.localGlyphMode!==L_.none&&(this.localGlyphMode===L_.all?!!this.localFontFamily:!!this.localFontFamily&&(Ma["CJK Unified Ideographs"](t)||Ma["Hangul Syllables"](t)||Ma.Hiragana(t)||Ma.Katakana(t)||Ma["CJK Symbols and Punctuation"](t)||Ma["CJK Unified Ideographs Extension A"](t)||Ma["CJK Unified Ideographs Extension B"](t)))}_tinySDF(t,e,i){const n=this.localFontFamily;if(!n||!this._doesCharSupportLocalGlyph(i))return;let r=t.tinySDF;if(!r){let i="400";/bold/i.test(e)?i="900":/medium/i.test(e)?i="500":/light/i.test(e)&&(i="200"),r=t.tinySDF=new P_.TinySDF({fontFamily:n,fontWeight:i,fontSize:24*I_,buffer:3*I_,radius:8*I_}),r.fontWeight=i}if(this.localGlyphs[r.fontWeight][i])return this.localGlyphs[r.fontWeight][i];const o=String.fromCodePoint(i),{data:s,width:a,height:l,glyphWidth:c,glyphHeight:d,glyphLeft:u,glyphTop:h,glyphAdvance:p}=r.draw(o);return this.localGlyphs[r.fontWeight][i]={id:i,bitmap:new dh({width:a,height:l},s),metrics:{width:c/I_,height:d/I_,left:u/I_,top:h/I_-27,advance:p/I_,localGlyph:!0}}}}P_.loadGlyphRange=function(t,e,i,n,r){const o=256*e,s=o+255,a=n.transformRequest(n.normalizeGlyphsURL(i).replace("{fontstack}",t).replace("{range}",`${o}-${s}`),Ki.Glyphs);en(a,((t,e)=>{if(t)r(t);else if(e){const t={},i=function(t){return new Lm(t).readFields(Wm,{})}(e);for(const e of i.glyphs)t[e.id]=e;r(null,{glyphs:t,ascender:i.ascender,descender:i.descender})}}))},P_.TinySDF=class{constructor({fontSize:t=24,buffer:e=3,radius:i=8,cutoff:n=.25,fontFamily:r="sans-serif",fontWeight:o="normal",fontStyle:s="normal"}={}){this.buffer=e,this.cutoff=n,this.radius=i;const a=this.size=t+4*e,l=this._createCanvas(a),c=this.ctx=l.getContext("2d",{willReadFrequently:!0});c.font=`${s} ${o} ${t}px ${r}`,c.textBaseline="alphabetic",c.textAlign="left",c.fillStyle="black",this.gridOuter=new Float64Array(a*a),this.gridInner=new Float64Array(a*a),this.f=new Float64Array(a),this.z=new Float64Array(a+1),this.v=new Uint16Array(a)}_createCanvas(t){const e=document.createElement("canvas");return e.width=e.height=t,e}draw(t){const{width:e,actualBoundingBoxAscent:i,actualBoundingBoxDescent:n,actualBoundingBoxLeft:r,actualBoundingBoxRight:o}=this.ctx.measureText(t),s=Math.ceil(i),a=Math.max(0,Math.min(this.size-this.buffer,Math.ceil(o-r))),l=Math.min(this.size-this.buffer,s+Math.ceil(n)),c=a+2*this.buffer,d=l+2*this.buffer,u=Math.max(c*d,0),h=new Uint8ClampedArray(u),p={data:h,width:c,height:d,glyphWidth:a,glyphHeight:l,glyphTop:s,glyphLeft:0,glyphAdvance:e};if(0===a||0===l)return p;const{ctx:f,buffer:m,gridInner:_,gridOuter:g}=this;f.clearRect(m,m,a,l),f.fillText(t,m,m+s);const y=f.getImageData(m,m,a,l);g.fill(M_,0,u),_.fill(0,0,u);for(let t=0;t0?t*t:0,_[n]=tt+e[1]-e[0],f=u.reduce(p,0),m=h.reduce(p,0),_=a-f,g=l-m;let y=0,v=f,x=0,b=m,w=0,T=_,S=0,E=g;if(o.content&&n){const t=o.content;y=D_(u,0,t[0]),x=D_(h,0,t[1]),v=D_(u,t[0],t[2]),b=D_(h,t[1],t[3]),w=t[0]-y,S=t[1]-x,T=t[2]-t[0]-v,E=t[3]-t[1]-b}const M=(n,r,a,l)=>{const u=R_(n.stretch-y,v,c,t.left),h=O_(n.fixed-w,T,n.stretch,f),p=R_(r.stretch-x,b,d,t.top),_=O_(r.fixed-S,E,r.stretch,m),g=R_(a.stretch-y,v,c,t.left),M=O_(a.fixed-w,T,a.stretch,f),C=R_(l.stretch-x,b,d,t.top),A=O_(l.fixed-S,E,l.stretch,m),I=new Ue(u,p),L=new Ue(g,p),P=new Ue(g,C),$=new Ue(u,C),k=new Ue(h/s,_/s),D=new Ue(M/s,A/s),z=e*Math.PI/180;if(z){const t=Math.sin(z),e=Math.cos(z),i=[e,-t,t,e];I._matMult(i),L._matMult(i),$._matMult(i),P._matMult(i)}const R=n.stretch+n.fixed,O=a.stretch+a.fixed,B=r.stretch+r.fixed,F=l.stretch+l.fixed,N=t.imageSecondary;return{tl:I,tr:L,bl:$,br:P,texPrimary:{x:o.paddedRect.x+$_+R,y:o.paddedRect.y+$_+B,w:O-R,h:F-B},texSecondary:N?{x:N.paddedRect.x+$_+R,y:N.paddedRect.y+$_+B,w:O-R,h:F-B}:void 0,writingMode:void 0,glyphOffset:[0,0],sectionIndex:0,pixelOffsetTL:k,pixelOffsetBR:D,minFontScaleX:T/s/c,minFontScaleY:E/s/d,isSDF:i}};if(n&&(o.stretchX||o.stretchY)){const t=z_(u,_,f),e=z_(h,g,m);for(let i=0;io)&&(o=e.x),(!t||e.y>s)&&(s=e.y)}const l=Math.min(o-n,s-r);let c=l/2;const d=new co([],N_);if(0===l)return new Ue(n,r);for(let e=n;eu.d||!u.d)&&(u=n,i&&console.log("found best %d after %d probes",Math.round(1e4*n.d)/1e4,h)),n.max-u.dt.y!=a.y>t.y&&t.x18&&P>2&&(P>>=1),Math.max(uo/(512*P),1)*_.get("symbol-spacing")),S=_.get("text-padding")*t.tilePixelRatio,E=_.get("icon-padding")*t.tilePixelRatio,M=Ge(_.get("text-max-angle")),C="map"===_.get("text-rotation-alignment")&&"point"!==_.get("symbol-placement"),A="map"===_.get("icon-rotation-alignment")&&"point"!==_.get("symbol-placement"),I=_.get("symbol-placement"),L=T/2;var P;const $=_.get("icon-text-fit").evaluate(e,{},u),k=_.get("icon-text-fit-padding").evaluate(e,{},u),D="none"!==$;let z;!1===t.hasAnyIconTextFit&&D&&(t.hasAnyIconTextFit=!0),n&&D&&(t.allowVerticalPlacement&&i.vertical&&(z=h_(n,i.vertical,$,k,g,b)),y&&(n=h_(n,y,$,k,g,b)));const R=(s,a,m)=>{if(a.x=uo||a.y=uo)return;let _=null;if(v){const{x:t,y:e,z:i}=h.projectTilePoint(a.x,a.y,m);_={anchor:new p_(t,e,i,0,void 0),up:h.upVector(m,a.x,a.y)}}!function(t,e,i,n,r,o,s,a,l,c,d,u,h,p,f,m,_,g,y,v,x,b,w,T,S,E,M){const C=t.addToLineVertexArray(e,n);let A,I,L,P,$,k,D,z=0,R=0,O=0,B=0,F=-1,N=-1;const U={};let j=Ln("");const V=i?i.anchor:e,G="none"!==l.layout.get("icon-text-fit").evaluate(x,{},S);let Z=0,q=0;if(void 0===l._unevaluatedLayout.getValue("text-radial-offset")?[Z,q]=l.layout.get("text-offset").evaluate(x,{},S).map((t=>t*Om)):(Z=l.layout.get("text-radial-offset").evaluate(x,{},S)*Om,q=j_),t.allowVerticalPlacement&&r.vertical){const t=r.vertical;if(f)k=J_(t),a&&(D=J_(a));else{const i=l.layout.get("text-rotate").evaluate(x,{},S)+90;L=K_(c,V,e,d,u,h,t,p,i,m),a&&(P=K_(c,V,e,d,u,h,a,g,i))}}if(o){const n=l.layout.get("icon-rotate").evaluate(x,{},S),r=k_(o,n,w,G),s=a?k_(a,n,w,G):void 0;I=K_(c,V,e,d,u,h,o,g,n),z=4*r.length;const p=t.iconSizeData;let f=null;"source"===p.kind?(f=[Bm*l.layout.get("icon-size").evaluate(x,{},S)],f[0]>W_&&pi(`${t.layerIds[0]}: Value for "icon-size" is >= ${H_}. Reduce your "icon-size".`)):"composite"===p.kind&&(f=[Bm*b.compositeIconSizes[0].evaluate(x,{},S),Bm*b.compositeIconSizes[1].evaluate(x,{},S)],(f[0]>W_||f[1]>W_)&&pi(`${t.layerIds[0]}: Value for "icon-size" is >= ${H_}. Reduce your "icon-size".`)),t.addSymbols(t.icon,r,f,v,y,x,!1,i,e,C.lineStartIndex,C.lineLength,-1,T,S,E,M),F=t.icon.placedSymbolArray.length-1,s&&(R=4*s.length,t.addSymbols(t.icon,s,f,v,y,x,Jm.vertical,i,e,C.lineStartIndex,C.lineLength,-1,T,S,E,M),N=t.icon.placedSymbolArray.length-1)}for(const n in r.horizontal){const o=r.horizontal[n];A||(j=Ln(o.text),f?$=J_(o):A=K_(c,V,e,d,u,h,o,p,l.layout.get("text-rotate").evaluate(x,{},S),m));const a=1===o.positionedLines.length;if(O+=Y_(t,i,e,o,s,l,f,x,m,C,r.vertical?Jm.horizontal:Jm.horizontalOnly,a?Object.keys(r.horizontal):[n],U,F,b,T,S,E),a)break}r.vertical&&(B+=Y_(t,i,e,r.vertical,s,l,f,x,m,C,Jm.vertical,["vertical"],U,N,b,T,S,E));let H=-1;const W=(t,e)=>t?Math.max(t,e):e;H=W($,H),H=W(k,H),H=W(D,H);const Y=H>-1?1:0;t.glyphOffsetArray.length>=65535&&pi("Too many glyphs being rendered in a tile. See https://github.com/mapbox/mapbox-gl-js/issues/2907"),void 0!==x.sortKey&&t.addToSortKeyRanges(t.symbolInstances.length,x.sortKey),t.symbolInstances.emplaceBack(e.x,e.y,V.x,V.y,V.z,U.right>=0?U.right:-1,U.center>=0?U.center:-1,U.left>=0?U.left:-1,U.vertical>=0?U.vertical:-1,F,N,j,void 0!==A?A:t.collisionBoxArray.length,void 0!==A?A+1:t.collisionBoxArray.length,void 0!==L?L:t.collisionBoxArray.length,void 0!==L?L+1:t.collisionBoxArray.length,void 0!==I?I:t.collisionBoxArray.length,void 0!==I?I+1:t.collisionBoxArray.length,P||t.collisionBoxArray.length,P?P+1:t.collisionBoxArray.length,d,O,B,z,R,Y,0,Z,q,H,0,1,1,G?1:0)}(t,a,_,s,i,n,r,z,t.layers[0],t.collisionBoxArray,e.index,e.sourceLayerIndex,t.index,S,C,l,0,E,A,g,e,o,c,d,u,p,f)};if("line"===I)for(const r of b_(e.geometry,0,0,uo,uo)){const e=v_(r,T,M,i.vertical||y,n,x,w,t.overscaling,uo);for(const i of e)y&&Q_(t,y.text,L,i)||R(r,i,u)}else if("line-center"===I){for(const t of e.geometry)if(t.length>1){const e=y_(t,M,i.vertical||y,n,x,w);e&&R(t,e,u)}}else if("Polygon"===e.type)for(const t of Zh(e.geometry,0)){const e=F_(t,16);R(t[0],new p_(e.x,e.y,0,0,void 0),u)}else if("LineString"===e.type)for(const t of e.geometry)R(t,new p_(t[0].x,t[0].y,0,0,void 0),u);else if("Point"===e.type)for(const t of e.geometry)for(const e of t)R([e],new p_(e.x,e.y,0,0,void 0),u)}const H_=255,W_=H_*Bm;function Y_(t,e,i,n,r,o,s,a,l,c,d,u,h,p,f,m,_,g){const y=function(t,e,i,n,r,o,s,a){const l=[];if(0===e.positionedLines.length)return l;const c=n.layout.get("text-rotate").evaluate(o,{})*Math.PI/180,d=function(t){const e=t[0],i=t[1],n=e*i;return n>0?[e,-i]:nW_&&pi(`${t.layerIds[0]}: Value for "text-size" is >= ${H_}. Reduce your "text-size".`)):"composite"===v.kind&&(x=[Bm*f.compositeTextSizes[0].evaluate(a,{},_),Bm*f.compositeTextSizes[1].evaluate(a,{},_)],(x[0]>W_||x[1]>W_)&&pi(`${t.layerIds[0]}: Value for "text-size" is >= ${H_}. Reduce your "text-size".`)),t.addSymbols(t.text,y,x,l,s,a,d,e,i,c.lineStartIndex,c.lineLength,p,m,_,g,!1);for(const e of u)h[e]=t.text.placedSymbolArray.length-1;return 4*y.length}function X_(t){for(const e in t)return t[e];return null}function K_(t,e,i,n,r,o,s,a,l,c){let d=s.top,u=s.bottom,h=s.left,p=s.right;const f=s.collisionPadding;if(f&&(h-=f[0],d-=f[1],p+=f[2],u+=f[3]),l){const t=new Ue(h,d),e=new Ue(p,d),i=new Ue(h,u),n=new Ue(p,u),r=Ge(l);let o=new Ue(0,0);c&&(o=new Ue(c[0],c[1])),t._rotateAround(r,o),e._rotateAround(r,o),i._rotateAround(r,o),n._rotateAround(r,o),h=Math.min(t.x,e.x,i.x,n.x),p=Math.max(t.x,e.x,i.x,n.x),d=Math.min(t.y,e.y,i.y,n.y),u=Math.max(t.y,e.y,i.y,n.y)}return t.emplaceBack(e.x,e.y,e.z,i.x,i.y,h,d,p,u,a,n,r,o),t.length-1}function J_(t){t.collisionPadding&&(t.top-=t.collisionPadding[1],t.bottom+=t.collisionPadding[3]);const e=t.bottom-t.top;return e>0?Math.max(10,e):null}function Q_(t,e,i,n){const r=t.compareText;if(e in r){const t=r[e];for(let e=t.length-1;e>=0;e--)if(n.dist(t[e])v&&(x(t,c,n,r,a,l),x(c,i,a,l,o,s))}x(u,h,n,o,r,o),x(h,p,r,o,r,s),x(p,f,r,s,n,s),x(f,u,n,s,n,o),m-=v,_-=v,g+=v,y+=v;const b=1/Math.max(g-m,y-_);return{scale:b,x:m*b,y:_*b,x2:g*b,y2:y*b,projection:e}}function ig(t,{x:e,y:i},n=0){return new Ue(((e-n)*t.scale-t.x)*uo,(i*t.scale-t.y)*uo)}const ng=t.ad.identity(new Float32Array(16));class rg{constructor(t){this.spec=t,this.name=t.name,this.wrap=!1,this.requiresDraping=!1,this.supportsWorldCopies=!1,this.supportsTerrain=!1,this.supportsFog=!1,this.supportsFreeCamera=!1,this.zAxisUnit="meters",this.isReprojectedInTileSpace=!0,this.unsupportedLayers=["custom"],this.center=[0,0],this.range=[3.5,7]}project(t,e){return{x:0,y:0,z:0}}unproject(t,e){return new pd(0,0)}projectTilePoint(t,e,i){return{x:t,y:e,z:0}}locationPoint(t,e,i=!0){return t._coordinatePoint(t.locationCoordinate(e),i)}pixelsPerMeter(t,e){return Cd(1,t)*e}pixelSpaceConversion(t,e,i){return 1}farthestPixelDistance(t){return tg(t,t.pixelsPerMeter)}pointCoordinate(t,e,i,n){const r=t.horizonLineFromTop(!1),o=new Ue(e,Math.max(r,i));return t.rayIntersectionCoordinate(t.pointRayIntersection(o,n))}pointCoordinate3D(t,e,i){const n=new Ue(e,i);if(t.elevation)return t.elevation.pointCoordinate(n);{const e=this.pointCoordinate(t,n.x,n.y,0);return[e.x,e.y,e.z]}}isPointAboveHorizon(t,e){if(t.elevation&&t.elevation.visibleDemTiles.length)return!this.pointCoordinate3D(t,e.x,e.y);const i=t.horizonLineFromTop();return e.y0?epg-i&&(e=pg-i);const o=r/Math.pow(fg(e),n);let s=o*Math.sin(n*t),a=r-o*Math.cos(n*t);return s=.5*(s/Math.PI+.5),a=.5*(a/Math.PI+.5),{x:s,y:this.southernCenter?a:1-a,z:0}}unproject(t,e){t=(2*t-.5)*Math.PI,this.southernCenter&&(e=1-e),e=(2*(1-e)-.5)*Math.PI;const{n:i,f:n}=this,r=n-e,o=Math.sign(r),s=Math.sign(i)*Math.sqrt(t*t+r*r);let a=Math.atan2(t,Math.abs(r))*o;r*i1e-6&&--n>0);o=i*i;const s=Xe(Ze(t/(.8707+o*(o*(o*o*o*(.003971-.001529*o)-.013791)-.131979))),-180,180),a=Ze(i);return new pd(s,a)}}const vg=Ge(Pd);class xg extends rg{project(t,e){e=Ge(e),t=Ge(t);const i=Math.cos(e),n=2/Math.PI,r=Math.acos(i*Math.cos(t/2)),o=Math.sin(r)/r,s=.5*(t*n+2*i*Math.sin(t/2)/o)||0,a=.5*(e+Math.sin(e)/o)||0;return{x:.5*(s/Math.PI+.5),y:1-.5*(a/Math.PI+1),z:0}}unproject(t,e){let i=t=(2*t-.5)*Math.PI,n=e=(2*(1-e)-1)*Math.PI,r=25;const o=1e-6;let s=0,a=0;do{const r=Math.cos(n),o=Math.sin(n),l=2*o*r,c=o*o,d=r*r,u=Math.cos(i/2),h=Math.sin(i/2),p=2*u*h,f=h*h,m=1-d*u*u,_=m?1/m:0,g=m?Math.acos(r*u)*Math.sqrt(1/m):0,y=.5*(2*g*r*h+2*i/Math.PI)-t,v=.5*(g*o+n)-e,x=.5*_*(d*f+g*r*u*c)+1/Math.PI,b=_*(p*l/4-g*o*h),w=.125*_*(l*h-g*o*d*p),T=.5*_*(c*u+g*f*r)+.5,S=b*w-T*x;s=(v*b-y*T)/S,a=(y*w-v*x)/S,i=Xe(i-s,-Math.PI,Math.PI),n=Xe(n-a,-vg,vg)}while((Math.abs(s)>o||Math.abs(a)>o)&&--r>0);return new pd(Ze(i),Ze(n))}}class bg extends rg{constructor(t){super(t),this.center=t.center||[0,0],this.parallels=t.parallels||[0,0],this.cosPhi=Math.max(.01,Math.cos(Ge(this.parallels[0]))),this.scale=1/(2*Math.max(Math.PI*this.cosPhi,1/this.cosPhi)),this.wrap=!0,this.supportsWorldCopies=!0}project(t,e){const{scale:i,cosPhi:n}=this;return{x:Ge(t)*n*i+.5,y:-Math.sin(Ge(e))/n*i+.5,z:0}}unproject(t,e){const{scale:i,cosPhi:n}=this,r=-(e-.5)/i,o=Xe(Ze((t-.5)/i)/n,-180,180),s=Math.asin(Xe(r*n,-1,1)),a=Xe(Ze(s),-Pd,Pd);return new pd(o,a)}}class wg extends _g{constructor(t){super(t),this.requiresDraping=!0,this.supportsWorldCopies=!1,this.supportsFog=!0,this.zAxisUnit="pixels",this.unsupportedLayers=["debug"],this.range=[3,5]}projectTilePoint(e,i,n){const r=Fu(e,i,n),o=ju($u(n));return t._.transformMat4(r,r,o),{x:r[0],y:r[1],z:r[2]}}locationPoint(e,i){const n=dd(i.lat,i.lng),r=t._.normalize([],n),o=e.elevation?e.elevation.getAtPointOrZero(e.locationCoordinate(i),e._centerAltitude):e._centerAltitude,s=Cd(1,0)*uo*o;t._.scaleAndAdd(n,n,r,s);const a=t.ad.identity(new Float64Array(16));return t.ad.multiply(a,e.pixelMatrix,e.globeMatrix),t._.transformMat4(n,n,a),new Ue(n[0],n[1])}pixelsPerMeter(t,e){return Cd(1,0)*e}pixelSpaceConversion(t,e,i){const n=Cd(1,t)*e,r=Vn(Cd(1,45)*e,n,i);return this.pixelsPerMeter(t,e)/r}createTileMatrix(e,i,n){const r=Vu($u(n.canonical));return t.ad.multiply(new Float64Array(16),e.globeMatrix,r)}createInversionMatrix(e,i){const{center:n}=e,r=ju($u(i));return t.ad.rotateY(r,r,Ge(n.lng)),t.ad.rotateX(r,r,Ge(n.lat)),t.ad.scale(r,r,[e._pixelsPerMercatorPixel,e._pixelsPerMercatorPixel,1]),Float32Array.from(r)}pointCoordinate(t,e,i,n){return Iu(t,e,i,!0)||new Rd(0,0)}pointCoordinate3D(t,e,i){const n=this.pointCoordinate(t,e,i,0);return[n.x,n.y,n.z]}isPointAboveHorizon(t,e){return!Iu(t,e.x,e.y,!1)}farthestPixelDistance(e){const i=function(e,i){const n=e.cameraToCenterDistance,r=e._centerAltitude*i,o=e._camera,s=e._camera.forward(),a=t._.add([],t._.scale([],s,-n),[0,0,r]),l=e.worldSize/(2*Math.PI),c=[0,0,-l],d=e.width/e.height,u=Math.tan(e.fovAboveCenter),h=t._.scale([],o.up(),u),p=t._.scale([],o.right(),u*d),f=t._.normalize([],t._.add([],t._.add([],s,h),p)),m=[];let _;if(new mu(a,f).closestPointOnSphere(c,l,m)){const i=t._.add([],m,c),n=t._.sub([],i,a);_=Math.cos(e.fovAboveCenter)*t._.length(n)}else{const e=t._.sub([],a,c),i=t._.sub([],c,a);t._.normalize(i,i);const n=t._.length(e)-l;_=Math.sqrt(n*(n+2*l));const r=Math.acos(_/(l+n))-Math.acos(t._.dot(s,i));_*=Math.cos(r)}return 1.01*_}(e,this.pixelsPerMeter(e.center.lat,e.worldSize)),n=Hu(e.zoom);if(n>0){const t=tg(e,Cd(1,e.center.lat)*e.worldSize),r=e.worldSize/(2*Math.PI),o=Math.max(e.width,e.height)/e.worldSize*Math.PI;return Vn(i,t+r*(1-Math.cos(o)),Math.pow(n,10))}return i}upVector(t,e,i){return Fu(e,i,t,1)}upVectorScale(t){return{metersToTile:Cu(Nu($u(t)))}}}function Tg(t){const e=t.parallels,i=!!e&&Math.abs(e[0]+e[1])0&&(this.iconTransitioningVertexBuffer=t.createVertexBuffer(this.iconTransitioningVertexArray,Vf.members,!0)),this.globeExtVertexArray.length>0&&(this.globeExtVertexBuffer=t.createVertexBuffer(this.globeExtVertexArray,Ff.members,!0)),!this.zOffsetVertexBuffer&&(this.zOffsetVertexArray.length>0||r)&&(this.zOffsetVertexBuffer=t.createVertexBuffer(this.zOffsetVertexArray,jf.members,!0)),this.opacityVertexBuffer.itemSize=1),(i||n)&&this.programConfigurations.upload(t))}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy(),this.dynamicLayoutVertexBuffer.destroy(),this.opacityVertexBuffer.destroy(),this.occlusionQueryOpacityVertexBuffer.destroy(),this.iconTransitioningVertexBuffer&&this.iconTransitioningVertexBuffer.destroy(),this.globeExtVertexBuffer&&this.globeExtVertexBuffer.destroy(),this.zOffsetVertexBuffer&&this.zOffsetVertexBuffer.destroy())}}ba(Ng,"SymbolBuffers");class Ug{constructor(t,e,i){this.layoutVertexArray=new t,this.layoutAttributes=e,this.indexArray=new i,this.segments=new wc,this.collisionVertexArray=new Xl,this.collisionVertexArrayExt=new Ol}upload(t){this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,this.layoutAttributes),this.indexBuffer=t.createIndexBuffer(this.indexArray),this.collisionVertexBuffer=t.createVertexBuffer(this.collisionVertexArray,Gf.members,!0),this.collisionVertexBufferExt=t.createVertexBuffer(this.collisionVertexArrayExt,Zf.members,!0)}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.segments.destroy(),this.collisionVertexBuffer.destroy(),this.collisionVertexBufferExt.destroy())}}ba(Ug,"CollisionBuffers");class jg{constructor(e){this.queries=new Map,this.collisionBoxArray=e.collisionBoxArray,this.zoom=e.zoom,this.lut=e.lut,this.overscaling=e.overscaling,this.layers=e.layers,this.layerIds=this.layers.map((t=>t.fqid)),this.index=e.index,this.pixelRatio=e.pixelRatio,this.sourceLayerIndex=e.sourceLayerIndex,this.hasPattern=!1,this.hasRTLText=!1,this.fullyClipped=!1,this.hasAnyIconTextFit=!1,this.sortKeyRanges=[],this.collisionCircleArray=[],this.placementInvProjMatrix=t.ad.identity([]),this.placementViewportMatrix=t.ad.identity([]);const i=this.layers[0]._unevaluatedLayout._values;this.textSizeData=Fm(this.zoom,i["text-size"]),this.iconSizeData=Fm(this.zoom,i["icon-size"]);const n=this.layers[0].layout,r=n.get("symbol-sort-key"),o=n.get("symbol-z-order");this.canOverlap=n.get("text-allow-overlap")||n.get("icon-allow-overlap")||n.get("text-ignore-placement")||n.get("icon-ignore-placement"),this.sortFeaturesByKey="viewport-y"!==o&&void 0!==r.constantOr(1),this.sortFeaturesByY=("viewport-y"===o||"auto"===o&&!this.sortFeaturesByKey)&&this.canOverlap,this.writingModes=n.get("text-writing-mode").map((t=>Jm[t])),this.stateDependentLayerIds=this.layers.filter((t=>t.isStateDependent())).map((t=>t.id)),this.sourceID=e.sourceID,this.projection=e.projection,this.hasAnyZOffset=!1,this.zOffsetSortDirty=!1,this.zOffsetBuffersNeedUpload=n.get("symbol-z-elevate"),this.activeReplacements=[],this.replacementUpdateTime=0}createArrays(){this.text=new Ng(new Yc(this.layers,{zoom:this.zoom,lut:this.lut},(t=>/^text/.test(t)))),this.icon=new Ng(new Yc(this.layers,{zoom:this.zoom,lut:this.lut},(t=>/^icon/.test(t)))),this.glyphOffsetArray=new mc,this.lineVertexArray=new _c,this.symbolInstances=new fc}calculateGlyphDependencies(t,e,i,n,r){for(let i=0;i0)&&("constant"!==l.value.kind||l.value.value.length>0),h="constant"!==d.value.kind||!!d.value.value||Object.keys(d.parameters).length>0,p=s.get("symbol-sort-key");if(this.features=[],!u&&!h)return;const f=i.iconDependencies,m=i.glyphDependencies,_=i.availableImages,g=new Ha(this.zoom);for(const{feature:i,id:c,index:d,sourceLayerIndex:y}of e){const e=o._featureFilter.needGeometry,v=Zd(i,e);if(!o._featureFilter.filter(g,v,n))continue;if(e||(v.geometry=Gd(i,n,r)),a&&1!==i.type&&n.z{const o=Fu(e.x,e.y,n,1),s=Fu(r.x,r.y,n,1);return t._.dot(o,s)=0;for(const i of x.sections)if(i.image)f[i.image.namePrimary]=!0;else{const n=Ca(x.toString()),r=i.fontStack||t,o=m[r]=m[r]||{};this.calculateGlyphDependencies(i.text,o,e,this.allowVerticalPlacement,n)}}}"line"===s.get("symbol-placement")&&(this.features=function(t){const e={},i={},n=[];let r=0;function o(e){n.push(t[e]),r++}function s(t,e,r){const o=i[t];return delete i[t],i[e]=o,n[o].geometry[0].pop(),n[o].geometry[0]=n[o].geometry[0].concat(r[0]),o}function a(t,i,r){const o=e[i];return delete e[i],e[t]=o,n[o].geometry[0].shift(),n[o].geometry[0]=r[0].concat(n[o].geometry[0]),o}function l(t,e,i){const n=i?e[0][e[0].length-1]:e[0][0];return`${t}:${n.x}:${n.y}`}for(let c=0;ct.geometry))}(this.features)),this.sortFeaturesByKey&&this.features.sort(((t,e)=>t.sortKey-e.sortKey))}update(t,e,i,n,r){const o=0!==Object.keys(t).length;if(o&&!this.stateDependentLayers.length)return;const s=o?this.stateDependentLayers:this.layers;this.text.programConfigurations.updatePaintArrays(t,e,s,i,n,r),this.icon.programConfigurations.updatePaintArrays(t,e,s,i,n,r)}updateOcclusionOpacities(t,e,i){if(!e.useOcclusionQueries)return!1;const n=this;if("globe"===n.projection.name)return!1;let r=!1;n.hasTextData()&&(r=r||0!==n.text.occlusionQueryOpacityVertexArray.length),n.hasIconData()&&(r=r||0!==n.icon.occlusionQueryOpacityVertexArray.length);const o=n.layers[0].paint,s=o.get("icon-occlusion-opacity").constantOr(0),a=o.get("text-occlusion-opacity").constantOr(0);if(!n.layers[0].hasInitialOcclusionOpacityProperties||1===s&&1===a)return!1;let l=!r;for(let t=0;t.5?1:-1)*e.fadeSpeed*i*.001,r.occlusionOpacity=Xe(r.occlusionOpacity,0,1),l=l||r.occlusionOpacity!==o}if(!l)return!1;let c=0,d=0;const u=(t,e,i,n)=>{let r=0,o=0;i?(r=d,d+=n,o=d):(r=c,c+=n,o=c),o>e.occlusionQueryOpacityVertexArray.length&&e.occlusionQueryOpacityVertexArray.resize(o);const s=t.occlusionOpacity;for(let t=0;t0;if((i>0||r>0)&&(u(e,n.text,!1,i),u(e,n.text,!1,r)),s){const{placedIconSymbolIndex:t,verticalPlacedIconSymbolIndex:i}=e;t>=0&&u(e,n.icon,!0,o),i>=0&&u(e,n.icon,!0,e.numVerticalIconVertices)}}return n.hasTextData()&&n.text.occlusionQueryOpacityVertexBuffer&&(n.text.occlusionQueryOpacityVertexBuffer.length{i+=e,i>t.length&&t.resize(i);for(let r=-e;r{n+=e,n>t.length&&t.resize(n);for(let r=-e;r0;if((r>0||o>0)&&(t(this.text.zOffsetVertexArray,r,a),t(this.text.zOffsetVertexArray,o,a)),l){const{placedIconSymbolIndex:t,verticalPlacedIconSymbolIndex:i}=n;t>=0&&e(this.icon.zOffsetVertexArray,s,a),i>=0&&e(this.icon.zOffsetVertexArray,n.numVerticalIconVertices,a)}}this.text.zOffsetVertexBuffer&&this.text.zOffsetVertexBuffer.updateData(this.text.zOffsetVertexArray),this.icon.zOffsetVertexBuffer&&this.icon.zOffsetVertexBuffer.updateData(this.icon.zOffsetVertexArray)}isEmpty(){return 0===this.symbolInstances.length&&!this.hasRTLText}uploadPending(){return!this.uploaded||this.text.programConfigurations.needsUpload||this.icon.programConfigurations.needsUpload}upload(t){!this.uploaded&&this.hasDebugData()&&(this.textCollisionBox.upload(t),this.iconCollisionBox.upload(t)),this.text.upload(t,this.sortFeaturesByY,!this.uploaded,this.text.programConfigurations.needsUpload,this.zOffsetBuffersNeedUpload),this.icon.upload(t,this.sortFeaturesByY,!this.uploaded,this.icon.programConfigurations.needsUpload,this.zOffsetBuffersNeedUpload),this.uploaded=!0}destroyDebugData(){this.textCollisionBox.destroy(),this.iconCollisionBox.destroy()}getProjection(){return this.projectionInstance||(this.projectionInstance=Tg(this.projection)),this.projectionInstance}destroy(){this.text.destroy(),this.icon.destroy(),this.hasDebugData()&&this.destroyDebugData();for(const t of this.queries.values())t.destroy()}addToLineVertexArray(t,e){const i=this.lineVertexArray.length;if(void 0!==t.segment)for(const{x:t,y:i}of e)this.lineVertexArray.emplaceBack(t,i);return{lineStartIndex:i,lineLength:this.lineVertexArray.length-i}}addSymbols(t,e,i,n,r,o,s,a,l,c,d,u,h,p,f,m){const _=t.indexArray,g=t.layoutVertexArray,y=t.globeExtVertexArray,v=t.segments.prepareSegment(4*e.length,g,_,this.canOverlap?o.sortKey:void 0),x=this.glyphOffsetArray.length,b=v.vertexLength,w=this.allowVerticalPlacement&&s===Jm.vertical?Math.PI/2:0,T=o.text&&o.text.sections;for(let n=0;n=0?e.rightJustifiedTextSymbolIndex:e.centerJustifiedTextSymbolIndex>=0?e.centerJustifiedTextSymbolIndex:e.leftJustifiedTextSymbolIndex>=0?e.leftJustifiedTextSymbolIndex:e.verticalPlacedTextSymbolIndex>=0?e.verticalPlacedTextSymbolIndex:n),o=Nm(this.textSizeData,t,r)/Om;return this.tilePixelRatio*o}getSymbolInstanceIconSize(t,e,i){const n=this.icon.placedSymbolArray.get(i),r=Nm(this.iconSizeData,t,n);return this.tilePixelRatio*r}_commitDebugCollisionVertexUpdate(t,e,i,n){t.emplaceBack(e,-i,-i,n),t.emplaceBack(e,i,-i,n),t.emplaceBack(e,i,i,n),t.emplaceBack(e,-i,i,n)}_updateTextDebugCollisionBoxes(t,e,i,n,r,o){for(let s=n;s0}hasIconData(){return this.icon.segments.get().length>0}hasDebugData(){return this.textCollisionBox&&this.iconCollisionBox}hasTextCollisionBoxData(){return this.hasDebugData()&&this.textCollisionBox.segments.get().length>0}hasIconCollisionBoxData(){return this.hasDebugData()&&this.iconCollisionBox.segments.get().length>0}hasIconTextFit(){return this.hasAnyIconTextFit}addIndicesForPlacedSymbol(t,e){const i=t.placedSymbolArray.get(e),n=i.vertexStartIndex+4*i.numGlyphs;for(let e=i.vertexStartIndex;en[t]-n[e]||r[e]-r[t])),o}getSortedIndexesByZOffset(){if(!this.zOffsetSortDirty)return this.symbolInstanceIndexesSortedZOffset;if(!this.symbolInstanceIndexesSortedZOffset){this.symbolInstanceIndexesSortedZOffset=[];for(let t=0;tthis.symbolInstances.get(e).zOffset-this.symbolInstances.get(t).zOffset))}addToSortKeyRanges(t,e){const i=this.sortKeyRanges[this.sortKeyRanges.length-1];i&&i.sortKey===e?i.symbolInstanceEnd=t+1:this.sortKeyRanges.push({sortKey:e,symbolInstanceStart:t,symbolInstanceEnd:t+1})}sortFeatures(t){if(this.sortFeaturesByY&&this.sortedAngle!==t&&!(this.text.segments.get().length>1||this.icon.segments.get().length>1)){this.symbolInstanceIndexes=this.getSortedSymbolIndexes(t),this.sortedAngle=t,this.text.indexArray.clear(),this.icon.indexArray.clear(),this.featureSortOrder=[];for(const t of this.symbolInstanceIndexes){const e=this.symbolInstances.get(t);this.featureSortOrder.push(e.featureIndex);const{rightJustifiedTextSymbolIndex:i,centerJustifiedTextSymbolIndex:n,leftJustifiedTextSymbolIndex:r,verticalPlacedTextSymbolIndex:o,placedIconSymbolIndex:s,verticalPlacedIconSymbolIndex:a}=e;i>=0&&this.addIndicesForPlacedSymbol(this.text,i),n>=0&&n!==i&&this.addIndicesForPlacedSymbol(this.text,n),r>=0&&r!==n&&r!==i&&this.addIndicesForPlacedSymbol(this.text,r),o>=0&&this.addIndicesForPlacedSymbol(this.text,o),s>=0&&this.addIndicesForPlacedSymbol(this.icon,s),a>=0&&this.addIndicesForPlacedSymbol(this.icon,a)}this.text.indexBuffer&&this.text.indexBuffer.updateData(this.text.indexArray),this.icon.indexBuffer&&this.icon.indexBuffer.updateData(this.icon.indexArray)}}}ba(jg,"SymbolBucket",{omit:["layers","collisionBoxArray","features","compareText"]}),jg.addDynamicAttributes=Bg;class Vg{constructor(t,e,i,n){this.context=t,this.format=i,this.texture=t.gl.createTexture(),this.update(e,n)}update(t,e,i){const{width:n,height:r}=t,{context:o}=this,{gl:s}=o;if(s.bindTexture(s.TEXTURE_2D,this.texture),o.pixelStoreUnpackFlipY.set(!1),o.pixelStoreUnpack.set(1),o.pixelStoreUnpackPremultiplyAlpha.set(this.format===s.RGBA&&(!e||!1!==e.premultiply)),this.useMipmap=Boolean(e&&e.useMipmap),i||this.size&&this.size[0]===n&&this.size[1]===r){const{x:e,y:o}=i||{x:0,y:0};if(t instanceof HTMLImageElement||t instanceof HTMLCanvasElement||t instanceof HTMLVideoElement||t instanceof ImageData||ImageBitmap&&t instanceof ImageBitmap)s.texSubImage2D(s.TEXTURE_2D,0,e,o,s.RGBA,s.UNSIGNED_BYTE,t);else{let i=this.format,a=s.UNSIGNED_BYTE;this.format===s.R32F&&(i=s.RED,a=s.FLOAT),s.texSubImage2D(s.TEXTURE_2D,0,e,o,n,r,i,a,t.data)}}else if(this.size=[n,r],t instanceof HTMLImageElement||t instanceof HTMLCanvasElement||t instanceof HTMLVideoElement||t instanceof ImageData||ImageBitmap&&t instanceof ImageBitmap){let e=this.format;this.format===s.R8&&(e=s.RED),s.texImage2D(s.TEXTURE_2D,0,this.format,e,s.UNSIGNED_BYTE,t)}else{let e=this.format,i=this.format,o=s.UNSIGNED_BYTE,a=!1;this.format===s.DEPTH_COMPONENT&&(e=s.DEPTH_COMPONENT16,o=s.UNSIGNED_SHORT),this.format===s.DEPTH_STENCIL&&(e=s.DEPTH24_STENCIL8,o=s.UNSIGNED_INT_24_8,a=!0),this.format===s.R8&&(i=s.RED),this.format===s.R32F&&(o=s.FLOAT,i=s.RED),!this.useMipmap&&a?s.texStorage2D(s.TEXTURE_2D,1,e,n,r):s.texImage2D(s.TEXTURE_2D,0,e,n,r,0,i,o,t.data)}this.useMipmap&&s.generateMipmap(s.TEXTURE_2D)}bind(t,e,i=!1){const{context:n}=this,{gl:r}=n;r.bindTexture(r.TEXTURE_2D,this.texture),t!==this.minFilter&&(r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MAG_FILTER,t),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MIN_FILTER,this.useMipmap&&!i?t===r.NEAREST?r.NEAREST_MIPMAP_NEAREST:r.LINEAR_MIPMAP_LINEAR:t),this.minFilter=t),e!==this.wrapS&&(r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_S,e),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_T,e),this.wrapS=e)}bindExtraParam(t,e,i,n){const{context:r}=this,{gl:o}=r;o.bindTexture(o.TEXTURE_2D,this.texture),e!==this.magFilter&&(o.texParameteri(o.TEXTURE_2D,o.TEXTURE_MAG_FILTER,e),this.magFilter=e),t!==this.minFilter&&(o.texParameteri(o.TEXTURE_2D,o.TEXTURE_MIN_FILTER,this.useMipmap?t===o.NEAREST?o.NEAREST_MIPMAP_NEAREST:o.LINEAR_MIPMAP_LINEAR:t),this.minFilter=t),i!==this.wrapS&&(o.texParameteri(o.TEXTURE_2D,o.TEXTURE_WRAP_S,i),this.wrapS=i),n!==this.wrapT&&(o.texParameteri(o.TEXTURE_2D,o.TEXTURE_WRAP_T,n),this.wrapT=n)}destroy(){const{gl:t}=this.context;t.deleteTexture(this.texture),this.texture=null}}class Gg{constructor(t,e){this.context=t,this.texture=e}bind(t,e){const{context:i}=this,{gl:n}=i;n.bindTexture(n.TEXTURE_2D,this.texture),t!==this.minFilter&&(n.texParameteri(n.TEXTURE_2D,n.TEXTURE_MAG_FILTER,t),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_MIN_FILTER,t),this.minFilter=t),e!==this.wrapS&&(n.texParameteri(n.TEXTURE_2D,n.TEXTURE_WRAP_S,e),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_WRAP_T,e),this.wrapS=e)}}const Zg=32,qg=33,Hg=new Uint16Array(8184);for(let t=0;t>=1)>1;){const t=i+r>>1,l=n+o>>1;1&e?(r=i,o=n,i=s,n=a):(i=r,n=o,r=s,o=a),s=t,a=l}const l=4*t;Hg[l+0]=i,Hg[l+1]=n,Hg[l+2]=r,Hg[l+3]=o}const Wg=new Uint16Array(2178),Yg=new Uint8Array(1089),Xg=new Uint16Array(1089);function Kg(t){return 0===t?-.03125:32===t?.03125:0}var Jg=Ll([{name:"a_pos",type:"Int16",components:2},{name:"a_texture_pos",type:"Int16",components:2}]),Qg=Ll([{name:"a_index",type:"Int16",components:1}]);const ty={type:2,extent:uo,loadGeometry:()=>[[new Ue(0,0),new Ue(uo+1,0),new Ue(uo+1,uo+1),new Ue(0,uo+1),new Ue(0,0)]]};class ey{constructor(t,e,i,n,r){this.tileID=t,this.uid=ni(),this.uses=0,this.tileSize=e,this.tileZoom=i,this.buckets={},this.expirationTime=null,this.queryPadding=0,this.hasSymbolBuckets=!1,this.hasRTLText=!1,this.dependencies={},this.isRaster=r,n&&n.style&&(this._lastUpdatedBrightness=n.style.getBrightness()),this.expiredRequestCount=0,this.state="loading",n&&n.transform&&(this.projection=n.transform.projection)}registerFadeDuration(t){const e=t+this.timeAdded;ee.getLayer(t))).filter(Boolean);if(0!==t.length){n.layers=t,n.stateDependentLayerIds&&(n.stateDependentLayers=n.stateDependentLayerIds.map((e=>t.filter((t=>t.id===e))[0])));for(const e of t)i[e.fqid]=n}}return i}(t.buckets,e.style),this.hasSymbolBuckets=!1;for(const t in this.buckets){const e=this.buckets[t];if(e instanceof jg){if(this.hasSymbolBuckets=!0,!i)break;e.justReloaded=!0}}if(this.hasRTLText=!1,this.hasSymbolBuckets)for(const t in this.buckets){const e=this.buckets[t];if(e instanceof jg&&e.hasRTLText){this.hasRTLText=!0,qa.isLoading()||qa.isLoaded()||"deferred"!==Ga()||Za();break}}this.queryPadding=0;for(const t in this.buckets){const i=this.buckets[t],n=e.style.getOwnLayer(t);if(!n)continue;const r=n.queryRadius(i);this.queryPadding=Math.max(this.queryPadding,r)}t.imageAtlas&&(this.imageAtlas=t.imageAtlas),t.glyphAtlasImage&&(this.glyphAtlasImage=t.glyphAtlasImage),t.lineAtlas&&(this.lineAtlas=t.lineAtlas),this._lastUpdatedBrightness=t.brightness}else this.collisionBoxArray=new dc}unloadVectorData(){if(this.hasData()){for(const t in this.buckets)this.buckets[t].destroy();this.buckets={},this.imageAtlas&&(this.imageAtlas=null),this.lineAtlas&&(this.lineAtlas=null),this.imageAtlasTexture&&this.imageAtlasTexture.destroy(),this.glyphAtlasTexture&&this.glyphAtlasTexture.destroy(),this.lineAtlasTexture&&this.lineAtlasTexture.destroy(),this._tileBoundsBuffer&&(this._tileBoundsBuffer.destroy(),this._tileBoundsIndexBuffer.destroy(),this._tileBoundsSegments.destroy(),this._tileBoundsBuffer=null),this._tileDebugBuffer&&(this._tileDebugBuffer.destroy(),this._tileDebugSegments.destroy(),this._tileDebugBuffer=null),this._tileDebugIndexBuffer&&(this._tileDebugIndexBuffer.destroy(),this._tileDebugIndexBuffer=null),this._globeTileDebugBorderBuffer&&(this._globeTileDebugBorderBuffer.destroy(),this._globeTileDebugBorderBuffer=null),this._tileDebugTextBuffer&&(this._tileDebugTextBuffer.destroy(),this._tileDebugTextSegments.destroy(),this._tileDebugTextIndexBuffer.destroy(),this._tileDebugTextBuffer=null),this._globeTileDebugTextBuffer&&(this._globeTileDebugTextBuffer.destroy(),this._globeTileDebugTextBuffer=null),this.latestFeatureIndex=null,this.state="unloaded"}}getBucket(t){return this.buckets[t.fqid]}upload(t){for(const e in this.buckets){const i=this.buckets[e];i.uploadPending()&&i.upload(t)}const e=t.gl,i=this.imageAtlas;if(i&&!i.uploaded){const n=!!Object.keys(i.patternPositions).length;this.imageAtlasTexture=new Vg(t,i.image,e.RGBA,{useMipmap:n}),this.imageAtlas.uploaded=!0}this.glyphAtlasImage&&(this.glyphAtlasTexture=new Vg(t,this.glyphAtlasImage,e.R8),this.glyphAtlasImage=null),this.lineAtlas&&!this.lineAtlas.uploaded&&(this.lineAtlasTexture=new Vg(t,this.lineAtlas.image,e.R8),this.lineAtlas.uploaded=!0)}prepare(t,e,i){if(this.imageAtlas&&this.imageAtlasTexture&&this.imageAtlas.patchUpdatedImages(t,this.imageAtlasTexture,i),!e||!this.latestFeatureIndex||!this.latestFeatureIndex.rawTileData)return;const n=e.style.getBrightness();(this._lastUpdatedBrightness||n)&&(this._lastUpdatedBrightness&&n&&Math.abs(this._lastUpdatedBrightness-n)t)i=!1;else if(e)if(this.expirationTime=0;t--){const e=4*t,i=Hg[e+0],n=Hg[e+1],r=Hg[e+2],o=Hg[e+3],s=i+r>>1,a=n+o>>1,l=s+a-n,c=a+i-s,d=n*qg+i,u=o*qg+r,h=a*qg+s,p=Math.hypot((Wg[2*d+0]+Wg[2*u+0])/2-Wg[2*h+0],(Wg[2*d+1]+Wg[2*u+1])/2-Wg[2*h+1])>=16;Yg[h]=Yg[h]||(p?1:0),t>1)*qg+(i+l>>1)]||Yg[(o+c>>1)*qg+(r+l>>1)])}const r=new Dl,o=new Kl;let s=0;function a(t,e){const i=e*qg+t;return 0===Xg[i]&&(r.emplaceBack(Wg[2*i+0],Wg[2*i+1],t*uo/Zg,e*uo/Zg),Xg[i]=++s),Xg[i]-1}function l(t,e,i,n,r,s){const c=t+i>>1,d=e+n>>1;if(Math.abs(t-r)+Math.abs(e-s)>1&&Yg[d*qg+c])l(r,s,t,e,c,d),l(i,n,r,s,c,d);else{const l=a(t,e),c=a(i,n),d=a(r,s);o.emplaceBack(l,c,d)}}return l(0,0,Zg,Zg,Zg,0),l(Zg,Zg,0,0,0,Zg),{vertices:r,indices:o}}(this.tileID.canonical,e);n=t.vertices,r=t.indices}else{n=new Dl,r=new Kl;for(const{x:t,y:e}of i)n.emplaceBack(t,e,0,0);const t=xh(n.int16,void 0,4);for(let e=0;e0&&(a=t.ad.invert(new Float64Array(16),i.globeMatrix)),this._makeGlobeTileDebugBorderBuffer(e,r,i,o,a,s),this._makeGlobeTileDebugTextBuffer(e,r,i,o,a,s)}_globePoint(e,i,n,r,o,s,a){let l=Fu(e,i,n);if(s){const o=1.5?h=-1:u{const p=(d-t)/(h-1),f=(u-c)/(h-1),m=s.length;for(let d=0;dd*t+e;for(let t=0;t[t,this.get(t)]))}evict(t=!1){if(t||this.size>0){const t=this.first;delete this.items[t.key],0==--this.size?(this.first=null,this.last=null):(this.first=t.next,this.first.prev=null)}return this}expiresAt(t){let e;return this.has(t)&&(e=this.items[t].expiry),e}get(t){let e;if(this.has(t)){const i=this.items[t];this.ttl>0&&i.expiry0?Date.now()+this.ttl:this.ttl),this.last!==r){const t=this.last,e=r.next,i=r.prev;this.first===r&&(this.first=r.next),r.next=null,r.prev=this.last,t.next=r,null!==i&&(i.next=e),null!==e&&(e.prev=i)}}else this.max>0&&this.size===this.max&&this.evict(!0),r=this.items[t]={expiry:this.ttl>0?Date.now()+this.ttl:this.ttl,key:t,prev:this.last,next:null,value:e},1==++this.size?this.first=r:this.last.next=r;return this.last=r,this}values(t=this.keys()){return t.map((t=>this.get(t)))}}function uy(t,e){if(4!==e.length)throw new Error(`Expected data of dimension 4 but got ${e.length}.`);let i=e[3];for(let n=2;n>=1;n--){const r=1===n?1:0,o=2===n?1:0;for(let n=0;n>>1^-(1&t[e]);return t}function py(t,e){switch(e){case"uint32":return t;case"uint16":for(let e=0;e>4|(61440&i)>>8|(240&n)>4|(15&n)>6|(192&n)>>4|(192&r)>>2|192&o,t[e+1]=(48&i)>>4|(48&n)>>2|48&r|(48&o)>2|12&n|(12&r)>1|(21845&Cy)>2|(13107&Ay)>4|(3855&Ay)>8|(255&Ay)>1}var Iy=function(t,e,i){for(var n=t.length,r=0,o=new _y(e);r>l]=c}else for(s=new _y(n),r=0;r>15-t[r]);return s},Ly=new my(288);for(Cy=0;Cye&&(e=t[i]);return e},zy=function(t,e,i){var n=e/8|0;return(t[n]|t[n+1]>(7&e)&i},Ry=function(t,e){var i=e/8|0;return(t[i]|t[i+1]>(7&e)},Oy=["unexpected EOF","invalid block type","invalid length/literal","invalid distance","stream finished","no stream handler",,"no callback","invalid UTF-8 data","extra field too long","date not in range 1980-2099","filename too long","stream finishing","invalid zip data"],By=function(t,e,i){var n=new Error(e||Oy[t]);if(n.code=t,Error.captureStackTrace&&Error.captureStackTrace(n,By),!i)throw n;return n},Fy=new my(0),Ny="undefined"!=typeof TextDecoder&&new TextDecoder;try{Ny.decode(Fy,{stream:!0})}catch(t){}const Uy={gzip_data:"gzip"},jy={0:"uint32",1:"uint32",2:"uint16",3:"uint8"},Vy={uint32:1,uint16:2,uint8:4},Gy={uint32:Uint32Array,uint16:Uint16Array,uint8:Uint8Array};class Zy{constructor(t=1){this.x=NaN,this.y=NaN,this.z=NaN,this.layers={},this._cacheSize=t}getLayer(t){return this.layers[t]}getHeaderLength(t){const e=new Uint8Array(t),i=new DataView(t);if(13!==e[0])throw new fy("File is not a valid MRT.");return i.getUint32(1,!0)}parseHeader(t){const e=new Uint8Array(t),i=this.getHeaderLength(t);if(e.length= ${i} but got buffer of length ${e.length}`);const n=function(t){return t.readFields(iy,{header_length:0,x:0,y:0,z:0,layers:[]},void 0)}(new Lm(e.subarray(0,i)));if(!isNaN(this.x)&&(this.x!==n.x||this.y!==n.y||this.z!==n.z))throw new fy(`Invalid attempt to parse header ${n.z}/${n.x}/${n.y} for tile ${this.z}/${this.x}/${this.y}`);this.x=n.x,this.y=n.y,this.z=n.z;for(const t of n.layers)this.layers[t.name]=new qy(t,{cacheSize:this._cacheSize});return this}createDecodingTask(t){const e=[],i=this.getLayer(t.layerName);for(let n=0;nt.lastBlock)continue;if(i._blocksInProgress.has(n))continue;const a={layerName:i.name,firstByte:o,lastByte:s,pixelFormat:i.pixelFormat,blockIndex:n,blockShape:[r.bands.length].concat(i.bandShape),buffer:i.buffer,codec:r.codec.codec,filters:r.filters.map((t=>t.filter))};i._blocksInProgress.add(n),e.push(a)}return new Hy(e,(()=>{e.forEach((t=>i._blocksInProgress.delete(t.blockIndex)))}),((t,n)=>{if(e.forEach((t=>i._blocksInProgress.delete(t.blockIndex))),t)throw t;n.forEach((t=>{this.getLayer(t.layerName).processDecodedData(t)}))}))}}class qy{constructor({version:t,name:e,units:i,tilesize:n,pixel_format:r,buffer:o,data_index:s},a){if(this.version=t,1!==this.version)throw new fy(`Cannot parse raster layer encoded with MRT version ${t}`);this.name=e,this.units=i,this.tileSize=n,this.buffer=o,this.pixelFormat=jy[r],this.dataIndex=s,this.bandShape=[n+2*o,n+2*o,Vy[this.pixelFormat]],this._decodedBlocks=function(t=1e3,e=0,i=!1){if(isNaN(t)||t=e&&t=0}hasDataForBand(t){const{blockIndex:e}=this.getBlockForBand(t);return e>=0&&!!this._decodedBlocks.get(e.toString())}getBandView(t){const{blockIndex:e,blockBandIndex:i}=this.getBlockForBand(t),n=this._decodedBlocks.get(e.toString());if(!n)throw new fy(`Data for band ${JSON.stringify(t)} of layer "${this.name}" not decoded.`);const r=this.dataIndex[e],o=this.bandShape.reduce(((t,e)=>t*e),1),s=i*o,a=n.subarray(s,s+o);return{data:a,bytes:new Uint8Array(a.buffer).subarray(a.byteOffset,a.byteOffset+a.byteLength),tileSize:this.tileSize,buffer:this.buffer,offset:r.offset,scale:r.scale}}}class Hy{constructor(t,e,i){this.tasks=t,this._onCancel=e,this._onComplete=i,this._finalized=!1}cancel(){this._finalized||(this._onCancel(),this._finalized=!0)}complete(t,e){this._finalized||(this._onComplete(t,e),this._finalized=!0)}}Zy.performDecoding=function(t,e){return Promise.all(e.tasks.map((e=>{const{layerName:i,firstByte:n,lastByte:r,pixelFormat:o,blockShape:s,blockIndex:a,filters:l,codec:c}=e,d=new Uint8Array(t).subarray(n,r+1),u=new Uint32Array(s[0]*s[1]*s[2]);let h;if("gzip_data"!==c)throw new Error(`Unhandled codec: ${c}`);return h=function(t,e){if(!globalThis.DecompressionStream&&"gzip_data"===e)return Promise.resolve(((o=function(t){31==t[0]&&139==t[1]&&8==t[2]||By(6,"invalid gzip data");var e=t[3],i=10;4&e&&(i+=2+(t[10]|t[11]>3&1)+(e>>4&1);n>0;n-=!t[i++]);return i+(2&e)}(r=t))+8>r.length&&By(6,"invalid gzip data"),function(t,e,i){var n=t.length;if(!n||e.f&&!e.l)return i||new my(0);var r=!i,o=r||2!=e.i,s=e.i;r&&(i=new my(3*n));var a,l,c=function(t){var e=i.length;if(t>e){var n=new my(Math.max(2*e,t));n.set(i),i=n}},d=e.f||0,u=e.p||0,h=e.b||0,p=e.l,f=e.d,m=e.m,_=e.n,g=8*n;do{if(!p){d=zy(t,u,1);var y=zy(t,u+1,3);if(u+=3,!y){var v=t[(L=4+((u+7)/8|0))-4]|t[L-3]n){s&&By(0);break}o&&c(h+v),i.set(t.subarray(L,x),h),e.b=h+=v,e.p=u=8*x,e.f=d;continue}if(1==y)p=$y,f=ky,m=9,_=5;else if(2==y){var b=zy(t,u,31)+257,w=zy(t,u+10,15)+4,T=b+zy(t,u+5,31)+1;u+=14;for(var S=new my(T),E=new my(19),M=0;M>4)g){s&&By(0);break}}o&&c(h+131072);for(var R=(1>4;if((u+=15&$)>g){s&&By(0);break}if($||By(2),F264&&(N=zy(t,u,(1>4;if(U||By(3),u+=15&U,z=Ey[j],j>3){var V=vy[j];z+=Ry(t,u)&(1g){s&&By(0);break}o&&c(h+131072);var G=h+N;if(ha.length)&&(l=a.length),new my(a.subarray(0,l))):i.subarray(0,h)}(r.subarray(o,-8),{i:2},new my(((i=r)[(n=i.length)-4]|i[n-3]>>0))));var i,n,r,o;const s=Uy[e];if(!s)throw new Error(`Unhandled codec: ${e}`);const a=new globalThis.DecompressionStream(s);return new Response(new Blob([t]).stream().pipeThrough(a)).arrayBuffer().then((t=>new Uint8Array(t)))}(d,c).then((t=>(function(t,e){t.readFields(ly,e)}(new Lm(t),u),new(0,Gy[o])(u.buffer)))),h.then((t=>{for(let e=l.length-1;e>=0;e--)switch(l[e]){case"delta_filter":uy(t,s);break;case"zigzag_filter":hy(t);break;case"bitshuffle_filter":py(t,o);break;default:throw new Error(`Unhandled filter "${l[e]}"`)}return{layerName:i,blockIndex:a,data:t}})).catch((t=>{throw t}))})))};class Wy extends ey{constructor(t,e,i,n,r){super(t,e,i,n,r),this._workQueue=[],this._fetchQueue=[],this._isHeaderLoaded=!1}setTexture(t,e){const i=e.context,n=i.gl;this.texture=this.texture||e.getTileTexture(t.width),this.texture&&this.texture instanceof Vg?this.texture.update(t,{useMipmap:!1,premultiply:!1}):this.texture=new Vg(i,t,n.RGBA,{useMipmap:!1,premultiply:!1})}flushQueues(){for(;this._workQueue.length;)this._workQueue.pop()();for(;this._fetchQueue.length;)this._fetchQueue.pop()()}fetchHeader(t=16384,e){const i=this._mrt=new Zy(30),n=Object.assign({},this.requestParams,{headers:{Range:"bytes=0-"+(t-1)}});return this.entireBuffer=null,this.request=en(n,((n,r,o,s)=>{if(n)e(n);else try{const n=i.getHeaderLength(r);if(n>t)return void(this.request=this.fetchHeader(n,e));i.parseHeader(r),this._isHeaderLoaded=!0;let a=0;for(const t of Object.values(i.layers))a=Math.max(a,t.dataIndex[t.dataIndex.length-1].last_byte);r.byteLength>=a&&(this.entireBuffer=r),e(null,this.entireBuffer||r,o,s)}catch(t){e(t)}})),this.request}fetchBand(t,e,i){const n=this._mrt;if(!this._isHeaderLoaded||!n)return void i(new Error("Tile header is not ready"));const r=this.actor;if(!r)return void i(new Error("Can't fetch tile band without an actor"));let o;const s=(n,r)=>{o.complete(n,r),n?i(n):(this.updateTextureDescriptor(t,e),i(null,this.textureDescriptor&&this.textureDescriptor.img))},a=(t,e)=>{if(t)return i(t);const n=r.send("decodeRasterArray",{buffer:e,task:o},s,void 0,!0);this._workQueue.push((()=>{n&&n.cancel(),o.cancel()}))},l=n.getLayer(t);if(!l)return void i(new Error(`Unknown sourceLayer "${t}"`));if(l.hasDataForBand(e))return this.updateTextureDescriptor(t,e),void i(null,this.textureDescriptor?this.textureDescriptor.img:null);const c=l.getDataRange([e]);if(o=n.createDecodingTask(c),!o||o.tasks.length)if(this.flushQueues(),this.entireBuffer)a(null,this.entireBuffer.slice(c.firstByte,c.lastByte+1));else{const t=Object.assign({},this.requestParams,{headers:{Range:`bytes=${c.firstByte}-${c.lastByte}`}}),e=en(t,a);this._fetchQueue.push((()=>{e.cancel(),o.cancel()}))}else i(null)}updateNeeded(t,e){return(!this.textureDescriptor||this.textureDescriptor.band!==e||this.textureDescriptor.layer!==t)&&"errored"!==this.state}updateTextureDescriptor(t,e){if(!this._mrt)return;const i=this._mrt.getLayer(t);if(!i||!i.hasBand(e)||!i.hasDataForBand(e))return;const{bytes:n,tileSize:r,buffer:o,offset:s,scale:a}=i.getBandView(e),l=r+2*o,c={data:n,width:l,height:l},d=this.texture;d&&d instanceof Vg&&d.update(c,{useMipmap:!1,premultiply:!1}),this.textureDescriptor={layer:t,band:e,img:c,buffer:o,offset:s,tileSize:r,format:i.pixelFormat,mix:[a,256*a,65536*a,16777216*a]}}}class Yy{constructor(t,e){this.max=t,this.onRemove=e,this.reset()}reset(){for(const t in this.data)for(const e of this.data[t])e.timeout&&clearTimeout(e.timeout),this.onRemove(e.value);return this.data={},this.order=[],this}add(t,e,i){const n=t.wrapped().key;void 0===this.data[n]&&(this.data[n]=[]);const r={value:e,timeout:void 0};if(void 0!==i&&(r.timeout=setTimeout((()=>{this.remove(t,r)}),i)),this.data[n].push(r),this.order.push(n),this.order.length>this.max){const t=this._getAndRemoveByKey(this.order[0]);t&&this.onRemove(t)}return this}has(t){return t.wrapped().key in this.data}getAndRemove(t){return this.has(t)?this._getAndRemoveByKey(t.wrapped().key):null}_getAndRemoveByKey(t){const e=this.data[t].shift();return e.timeout&&clearTimeout(e.timeout),0===this.data[t].length&&delete this.data[t],this.order.splice(this.order.indexOf(t),1),e.value}getByKey(t){const e=this.data[t];return e?e[0].value:null}get(t){return this.has(t)?this.data[t.wrapped().key][0].value:null}remove(t,e){if(!this.has(t))return this;const i=t.wrapped().key,n=void 0===e?0:this.data[i].indexOf(e),r=this.data[i][n];return this.data[i].splice(n,1),r.timeout&&clearTimeout(r.timeout),0===this.data[i].length&&delete this.data[i],this.onRemove(r.value),this.order.splice(this.order.indexOf(i),1),this}setMaxSize(t){for(this.max=t;this.order.length>this.max;){const t=this._getAndRemoveByKey(this.order[0]);t&&this.onRemove(t)}return this}filter(t){const e=[];for(const i in this.data)for(const n of this.data[i])t(n.value)||e.push(n);for(const t of e)this.remove(t.value.tileID,t)}}class Xy extends zn{constructor(t,e,i){super(),this.id=t,this._onlySymbols=i,e.on("data",(t=>{"source"===t.dataType&&"metadata"===t.sourceDataType&&(this._sourceLoaded=!0),this._sourceLoaded&&!this._paused&&"source"===t.dataType&&"content"===t.sourceDataType&&(this.reload(),this.transform&&this.update(this.transform))})),e.on("error",(()=>{this._sourceErrored=!0})),this._source=e,this._tiles={},this._cache=new Yy(0,this._unloadTile.bind(this)),this._timers={},this._cacheTimers={},this._minTileCacheSize=e.minTileCacheSize,this._maxTileCacheSize=e.maxTileCacheSize,this._loadedParentTiles={},this.castsShadows=!1,this.tileCoverLift=0,this._coveredTiles={},this._shadowCasterTiles={},this._state=new km,this._isRaster="raster"===this._source.type||"raster-dem"===this._source.type||"raster-array"===this._source.type||"custom"===this._source.type&&"raster"===this._source._dataType}onAdd(t){this.map=t,this._minTileCacheSize=void 0===this._minTileCacheSize&&t?t._minTileCacheSize:this._minTileCacheSize,this._maxTileCacheSize=void 0===this._maxTileCacheSize&&t?t._maxTileCacheSize:this._maxTileCacheSize}loaded(){if(this._sourceErrored)return!0;if(!this._sourceLoaded)return!1;if(!this._source.loaded())return!1;for(const t in this._tiles){const e=this._tiles[t];if("errored"!==e.state&&("loaded"!==e.state||!e.bucketsLoaded()))return!1}return!0}getSource(){return this._source}pause(){this._paused=!0}resume(){if(!this._paused)return;const t=this._shouldReloadOnResume;this._paused=!1,this._shouldReloadOnResume=!1,t&&this.reload(),this.transform&&this.update(this.transform)}_loadTile(t,e){return t.isSymbolTile=this._onlySymbols,t.isExtraShadowCaster=this._shadowCasterTiles[t.tileID.key],this._source.loadTile(t,e)}_unloadTile(t){if(this._source.unloadTile)return this._source.unloadTile(t)}_abortTile(t){if(this._source.abortTile)return this._source.abortTile(t)}serialize(){return this._source.serialize()}prepare(t){this._source.prepare&&this._source.prepare(),this._state.coalesceChanges(this._tiles,this.map?this.map.painter:null);for(const e in this._tiles){const i=this._tiles[e];i.upload(t),i.prepare(this.map.style.imageManager,this.map?this.map.painter:null,this._source.scope)}}getIds(){return ti(this._tiles).map((t=>t.tileID)).sort(Ky).map((t=>t.key))}getRenderableIds(t,e){const i=[];for(const n in this._tiles)this._isIdRenderable(+n,t,e)&&i.push(this._tiles[n]);return t?i.sort(((t,e)=>{const i=t.tileID,n=e.tileID,r=new Ue(i.canonical.x,i.canonical.y)._rotate(this.transform.angle),o=new Ue(n.canonical.x,n.canonical.y)._rotate(this.transform.angle);return i.overscaledZ-n.overscaledZ||o.y-r.y||o.x-r.x})).map((t=>t.tileID.key)):i.map((t=>t.tileID)).sort(Ky).map((t=>t.key))}hasRenderableParent(t){const e=this.findLoadedParent(t,0);return!!e&&this._isIdRenderable(e.tileID.key)}_isIdRenderable(t,e,i){return this._tiles[t]&&this._tiles[t].hasData()&&!this._coveredTiles[t]&&(e||!this._tiles[t].holdingForFade())&&(i||!this._shadowCasterTiles[t])}reload(){if(this._paused)this._shouldReloadOnResume=!0;else{this._cache.reset();for(const t in this._tiles)"errored"!==this._tiles[t].state&&this._reloadTile(+t,"reloading")}}_reloadTile(t,e){const i=this._tiles[t];i&&("loading"!==i.state&&(i.state=e),this._loadTile(i,this._tileLoaded.bind(this,i,t,e)))}_tileLoaded(t,e,i,n){if(n)if(t.state="errored",404!==n.status)this._source.fire(new $n(n,{tile:t}));else{if(!(t.tileID.key in this._loadedParentTiles))return void this._source.fire(new Pn("data",{dataType:"source",sourceDataType:"error",sourceId:this._source.id}));if("raster-dem"===this._source.type&&this.usedForTerrain&&this.map.painter.terrain){const t=this.map.painter.terrain;this.update(this.transform,t.getScaledDemTileSize(),!0),t.resetTileLookupCache(this.id)}else this.update(this.transform)}else t.timeAdded=ki.now(),"expired"===i&&(t.refreshedUponExpiration=!0),this._setTileReloadTimer(e,t),"raster-dem"===this._source.type&&t.dem&&this._backfillDEM(t),this._state.initializeTileState(t,this.map?this.map.painter:null),this._source.fire(new Pn("data",{dataType:"source",tile:t,coord:t.tileID,sourceCacheId:this.id}))}_backfillDEM(t){const e=this.getRenderableIds();for(let n=0;n1||(Math.abs(i)>1&&(1===Math.abs(i+r)?i+=r:1===Math.abs(i-r)&&(i-=r)),e.dem&&t.dem&&(t.dem.backfillBorder(e.dem,i,n),t.neighboringTiles&&t.neighboringTiles[o]&&(t.neighboringTiles[o].backfilled=!0)))}}getTile(t){return this.getTileByID(t.key)}getTileByID(t){return this._tiles[t]}_retainLoadedChildren(t,e,i,n){for(const r in this._tiles){let o=this._tiles[r];if(n[r]||!o.hasData()||o.tileID.overscaledZi)continue;let s=o.tileID;for(;o&&o.tileID.overscaledZ>e+1;){const t=o.tileID.scaledTo(o.tileID.overscaledZ-1);o=this._tiles[t.key],o&&o.hasData()&&(s=t)}let a=s;for(;a.overscaledZ>e;)if(a=a.scaledTo(a.overscaledZ-1),t[a.key]){n[s.key]=s;break}}}findLoadedParent(t,e){if(t.key in this._loadedParentTiles){const i=this._loadedParentTiles[t.key];return i&&i.tileID.overscaledZ>=e?i:null}for(let i=t.overscaledZ-1;i>=e;i--){const e=t.scaledTo(i),n=this._getLoadedTile(e);if(n)return n}}_getLoadedTile(t){const e=this._tiles[t.key];return e&&e.hasData()?e:this._cache.getByKey(this._source.reparseOverscaled?t.wrapped().key:t.canonical.key)}updateCacheSize(t,e){e=e||this._source.tileSize;const i=Math.ceil(t.width/e)+1,n=Math.ceil(t.height/e)+1,r=Math.floor(i*n*5),o="number"==typeof this._minTileCacheSize?Math.max(this._minTileCacheSize,r):r,s="number"==typeof this._maxTileCacheSize?Math.min(this._maxTileCacheSize,o):o;this._cache.setMaxSize(s)}handleWrapJump(t){const e=Math.round((t-(void 0===this._prevLng?t:this._prevLng))/360);if(this._prevLng=t,e){const t={};for(const i in this._tiles){const n=this._tiles[i];n.tileID=n.tileID.unwrapTo(n.tileID.wrap+e),t[n.tileID.key]=n}this._tiles=t;for(const t in this._timers)clearTimeout(this._timers[t]),delete this._timers[t];for(const t in this._tiles)this._setTileReloadTimer(+t,this._tiles[t])}}update(t,e,i,n){if(this.transform=t,!this._sourceLoaded||this._paused||this.transform.freezeTileCoverage)return;if(this.usedForTerrain&&!i)return;let r;if(this.updateCacheSize(t,e),"globe"!==this.transform.projection.name&&this.handleWrapJump(this.transform.center.lng),this._shadowCasterTiles={},this._coveredTiles={},this.used||this.usedForTerrain){if(this._source.tileID)r=t.getVisibleUnwrappedCoordinates(this._source.tileID).map((t=>new vd(t.canonical.z,t.wrap,t.canonical.z,t.canonical.x,t.canonical.y)));else if(0!==this.tileCoverLift){const n=t.clone();n.tileCoverLift=this.tileCoverLift,r=n.coveringTiles({tileSize:e||this._source.tileSize,minzoom:this._source.minzoom,maxzoom:this._source.maxzoom,roundZoom:this._source.roundZoom&&!i,reparseOverscaled:this._source.reparseOverscaled,isTerrainDEM:this.usedForTerrain}),this._source.minzoomt(e)))}}else r=[];if(r.length>0&&this.castsShadows&&n&&"globe"!==this.transform.projection.name&&!this.usedForTerrain&&!Jy(this._source.type)){const o=t.coveringZoomLevel({tileSize:e||this._source.tileSize,roundZoom:this._source.roundZoom&&!i}),s=Math.min(o,this._source.maxzoom),a=t.extendTileCoverForShadows(r,n,s);for(const t of a)this._shadowCasterTiles[t.key]=!0,r.push(t)}const o=this._updateRetainedTiles(r);if(Jy(this._source.type)&&0!==r.length){const t={},e={},i=Object.keys(o);for(const n of i){const i=o[n],r=this._tiles[n];if(!r||r.fadeEndTime&&r.fadeEndTimen;){r=r.scaledTo(r.overscaledZ-1);const n=this._tiles[r.key];if(n&&n.hasData()&&e[r.key]){o[t]=i.tileID;break}}}for(const e in t)o[e]||(this._coveredTiles[e]=!0,o[e]=t[e])}for(const t in o)this._tiles[t].clearFadeHold();const s=function(t,e){const i=[];for(const n in t)n in e||i.push(n);return i}(this._tiles,o);for(const t of s){const e=this._tiles[t];e.hasSymbolBuckets&&!e.holdingForFade()?e.setHoldDuration(this.map._fadeDuration):e.hasSymbolBuckets&&!e.symbolFadeFinished()||this._removeTile(+t)}this._updateLoadedParentTileCache(),this._onlySymbols&&this._source.afterUpdate&&this._source.afterUpdate()}releaseSymbolFadeTiles(){for(const t in this._tiles)this._tiles[t].holdingForFade()&&this._removeTile(+t)}_updateRetainedTiles(t){const e={};if(0===t.length)return e;const i={},n=t.reduce(((t,e)=>Math.min(t,e.overscaledZ)),1/0),r=t[0].overscaledZ,o=Math.max(r-Xy.maxOverzooming,this._source.minzoom),s=Math.max(r+Xy.maxUnderzooming,this._source.minzoom),a={};for(const i of t){const t=this._addTile(i);e[i.key]=i,t.hasData()||n=this._source.maxzoom){const t=n.children(this._source.maxzoom)[0],i=this.getTile(t);if(i&&i.hasData()){e[t.key]=t;continue}}else{const t=n.children(this._source.maxzoom);if(e[t[0].key]&&e[t[1].key]&&e[t[2].key]&&e[t[3].key])continue}let r=t.wasRequested();for(let s=n.overscaledZ-1;s>=o;--s){const o=n.scaledTo(s);if(i[o.key])break;if(i[o.key]=!0,t=this.getTile(o),!t&&r&&(t=this._addTile(o)),t&&(e[o.key]=o,r=t.wasRequested(),t.hasData()))break}}return e}_updateLoadedParentTileCache(){this._loadedParentTiles={};for(const t in this._tiles){const e=[];let i,n=this._tiles[t].tileID;for(;n.overscaledZ>0;){if(n.key in this._loadedParentTiles){i=this._loadedParentTiles[n.key];break}e.push(n.key);const t=n.scaledTo(n.overscaledZ-1);if(i=this._getLoadedTile(t),i)break;n=t}for(const t of e)this._loadedParentTiles[t]=i}}_addTile(t){let e=this._tiles[t.key];if(e)return!0!==e.isExtraShadowCaster||!!this._shadowCasterTiles[t.key]||this._reloadTile(t.key,"reloading"),e;e=this._cache.getAndRemove(t),e&&(this._setTileReloadTimer(t.key,e),e.tileID=t,this._state.initializeTileState(e,this.map?this.map.painter:null),this._cacheTimers[t.key]&&(clearTimeout(this._cacheTimers[t.key]),delete this._cacheTimers[t.key],this._setTileReloadTimer(t.key,e)));const i=Boolean(e);if(!i){const i=this.map?this.map.painter:null,n=this._source.tileSize*t.overscaleFactor();e="raster-array"===this._source.type?new Wy(t,n,this.transform.tileZoom,i,this._isRaster):new ey(t,n,this.transform.tileZoom,i,this._isRaster),this._loadTile(e,this._tileLoaded.bind(this,e,t.key,e.state))}return e?(e.uses++,this._tiles[t.key]=e,i||this._source.fire(new Pn("dataloading",{tile:e,coord:e.tileID,dataType:"source"})),e):null}_setTileReloadTimer(t,e){t in this._timers&&(clearTimeout(this._timers[t]),delete this._timers[t]);const i=e.getExpiryTimeout();i&&(this._timers[t]=setTimeout((()=>{this._reloadTile(t,"expired"),delete this._timers[t]}),i))}_removeTile(t){const e=this._tiles[t];e&&(e.uses--,delete this._tiles[t],this._timers[t]&&(clearTimeout(this._timers[t]),delete this._timers[t]),e.uses>0||(e.hasData()&&"reloading"!==e.state||"empty"===e.state?this._cache.add(e.tileID,e,e.getExpiryTimeout()):(e.aborted=!0,this._abortTile(e),this._unloadTile(e))))}clearTiles(){this._shouldReloadOnResume=!1,this._paused=!1;for(const t in this._tiles)this._removeTile(+t);this._source._clear&&this._source._clear(),this._cache.reset(),this.map&&this.usedForTerrain&&this.map.painter.terrain&&this.map.painter.terrain.resetTileLookupCache(this.id)}tilesIn(t,e,i){const n=[],r=this.transform;if(!r)return n;const o="globe"===r.projection.name,s=Ed(r.center.lng);for(const a in this._tiles){const l=this._tiles[a];if(i&&l.clearQueryDebugViz(),l.holdingForFade())continue;let c;if(o){const t=l.tileID.canonical;if(0===t.z){const e=[Math.abs(Xe(s,...Qy(t,-1))-s),Math.abs(Xe(s,...Qy(t,1))-s)];c=[0,2*e.indexOf(Math.min(...e))-1]}else{const e=[Math.abs(Xe(s,...Qy(t,-1))-s),Math.abs(Xe(s,...Qy(t,0))-s),Math.abs(Xe(s,...Qy(t,1))-s)];c=[e.indexOf(Math.min(...e))-1]}}else c=[0];for(const i of c){const o=t.containsTile(l,r,e,i);o&&n.push(o)}}return n}getShadowCasterCoordinates(){return this._getRenderableCoordinates(!1,!0)}getVisibleCoordinates(t){return this._getRenderableCoordinates(t)}_getRenderableCoordinates(t,e){const i=this.getRenderableIds(t,e).map((t=>this._tiles[t].tileID)),n="globe"===this.transform.projection.name;for(const t of i)t.projMatrix=this.transform.calculateProjMatrix(t.toUnwrapped()),t.expandedProjMatrix=n?this.transform.calculateProjMatrix(t.toUnwrapped(),!1,!0):t.projMatrix;return i}sortCoordinatesByDistance(t){const e=t.slice(),i=this.transform._camera.position,n=this.transform._camera.forward(),r={};for(const t of e){const e=1/(1r[t.key]-r[e.key])),e}hasTransition(){if(this._source.hasTransition())return!0;if(Jy(this._source.type))for(const t in this._tiles){const e=this._tiles[t];if(void 0!==e.fadeEndTime&&e.fadeEndTime>=ki.now())return!0}return!1}setFeatureState(t,e,i){this._state.updateState(t=t||"_geojsonTileLayer",e,i)}removeFeatureState(t,e,i){this._state.removeFeatureState(t=t||"_geojsonTileLayer",e,i)}getFeatureState(t,e){return this._state.getState(t=t||"_geojsonTileLayer",e)}setDependencies(t,e,i){const n=this._tiles[t];n&&n.setDependencies(e,i)}reloadTilesForDependencies(t,e){for(const i in this._tiles)this._tiles[i].hasDependency(t,e)&&this._reloadTile(+i,"reloading");this._cache.filter((i=>!i.hasDependency(t,e)))}_preloadTiles(t,e){if(!this._sourceLoaded){const i=()=>{this._sourceLoaded&&(this._source.off("data",i),this._preloadTiles(t,e))};return void this._source.on("data",i)}const i=new Map,n=Array.isArray(t)?t:[t],r=this.map.painter.terrain,o=this.usedForTerrain&&r?r.getScaledDemTileSize():this._source.tileSize;for(const t of n){const e=t.coveringTiles({tileSize:o,minzoom:this._source.minzoom,maxzoom:this._source.maxzoom,roundZoom:this._source.roundZoom&&!this.usedForTerrain,reparseOverscaled:this._source.reparseOverscaled,isTerrainDEM:this.usedForTerrain});for(const t of e)i.set(t.key,t);this.usedForTerrain&&t.updateElevation(!1)}Qe(Array.from(i.values()),((t,e)=>{const i=new ey(t,this._source.tileSize*t.overscaleFactor(),this.transform.tileZoom,this.map.painter,this._isRaster);this._loadTile(i,(t=>{"raster-dem"===this._source.type&&i.dem&&this._backfillDEM(i),e(t,i)}))}),e)}}function Ky(t,e){const i=Math.abs(2*t.wrap)-+(t.wrap0?e+2*t:t}tv.useIntegerZoom=!0;const iv=new ol({"symbol-placement":new il(sl.layout_symbol["symbol-placement"]),"symbol-spacing":new il(sl.layout_symbol["symbol-spacing"]),"symbol-avoid-edges":new il(sl.layout_symbol["symbol-avoid-edges"]),"symbol-sort-key":new nl(sl.layout_symbol["symbol-sort-key"]),"symbol-z-order":new il(sl.layout_symbol["symbol-z-order"]),"symbol-z-elevate":new il(sl.layout_symbol["symbol-z-elevate"]),"icon-allow-overlap":new il(sl.layout_symbol["icon-allow-overlap"]),"icon-ignore-placement":new il(sl.layout_symbol["icon-ignore-placement"]),"icon-optional":new il(sl.layout_symbol["icon-optional"]),"icon-rotation-alignment":new il(sl.layout_symbol["icon-rotation-alignment"]),"icon-size":new nl(sl.layout_symbol["icon-size"]),"icon-text-fit":new nl(sl.layout_symbol["icon-text-fit"]),"icon-text-fit-padding":new nl(sl.layout_symbol["icon-text-fit-padding"]),"icon-image":new nl(sl.layout_symbol["icon-image"]),"icon-rotate":new nl(sl.layout_symbol["icon-rotate"]),"icon-padding":new il(sl.layout_symbol["icon-padding"]),"icon-keep-upright":new il(sl.layout_symbol["icon-keep-upright"]),"icon-offset":new nl(sl.layout_symbol["icon-offset"]),"icon-anchor":new nl(sl.layout_symbol["icon-anchor"]),"icon-pitch-alignment":new il(sl.layout_symbol["icon-pitch-alignment"]),"text-pitch-alignment":new il(sl.layout_symbol["text-pitch-alignment"]),"text-rotation-alignment":new il(sl.layout_symbol["text-rotation-alignment"]),"text-field":new nl(sl.layout_symbol["text-field"]),"text-font":new nl(sl.layout_symbol["text-font"]),"text-size":new nl(sl.layout_symbol["text-size"]),"text-max-width":new nl(sl.layout_symbol["text-max-width"]),"text-line-height":new nl(sl.layout_symbol["text-line-height"]),"text-letter-spacing":new nl(sl.layout_symbol["text-letter-spacing"]),"text-justify":new nl(sl.layout_symbol["text-justify"]),"text-radial-offset":new nl(sl.layout_symbol["text-radial-offset"]),"text-variable-anchor":new il(sl.layout_symbol["text-variable-anchor"]),"text-anchor":new nl(sl.layout_symbol["text-anchor"]),"text-max-angle":new il(sl.layout_symbol["text-max-angle"]),"text-writing-mode":new il(sl.layout_symbol["text-writing-mode"]),"text-rotate":new nl(sl.layout_symbol["text-rotate"]),"text-padding":new il(sl.layout_symbol["text-padding"]),"text-keep-upright":new il(sl.layout_symbol["text-keep-upright"]),"text-transform":new nl(sl.layout_symbol["text-transform"]),"text-offset":new nl(sl.layout_symbol["text-offset"]),"text-allow-overlap":new il(sl.layout_symbol["text-allow-overlap"]),"text-ignore-placement":new il(sl.layout_symbol["text-ignore-placement"]),"text-optional":new il(sl.layout_symbol["text-optional"]),visibility:new il(sl.layout_symbol.visibility)});var nv={paint:new ol({"icon-opacity":new nl(sl.paint_symbol["icon-opacity"]),"icon-occlusion-opacity":new nl(sl.paint_symbol["icon-occlusion-opacity"]),"icon-emissive-strength":new nl(sl.paint_symbol["icon-emissive-strength"]),"text-emissive-strength":new nl(sl.paint_symbol["text-emissive-strength"]),"icon-color":new nl(sl.paint_symbol["icon-color"]),"icon-halo-color":new nl(sl.paint_symbol["icon-halo-color"]),"icon-halo-width":new nl(sl.paint_symbol["icon-halo-width"]),"icon-halo-blur":new nl(sl.paint_symbol["icon-halo-blur"]),"icon-translate":new il(sl.paint_symbol["icon-translate"]),"icon-translate-anchor":new il(sl.paint_symbol["icon-translate-anchor"]),"icon-image-cross-fade":new nl(sl.paint_symbol["icon-image-cross-fade"]),"text-opacity":new nl(sl.paint_symbol["text-opacity"]),"text-occlusion-opacity":new nl(sl.paint_symbol["text-occlusion-opacity"]),"text-color":new nl(sl.paint_symbol["text-color"],{runtimeType:Qn,getOverride:t=>t.textColor,hasOverride:t=>!!t.textColor}),"text-halo-color":new nl(sl.paint_symbol["text-halo-color"]),"text-halo-width":new nl(sl.paint_symbol["text-halo-width"]),"text-halo-blur":new nl(sl.paint_symbol["text-halo-blur"]),"text-translate":new il(sl.paint_symbol["text-translate"]),"text-translate-anchor":new il(sl.paint_symbol["text-translate-anchor"]),"icon-color-saturation":new il(sl.paint_symbol["icon-color-saturation"]),"icon-color-contrast":new il(sl.paint_symbol["icon-color-contrast"]),"icon-color-brightness-min":new il(sl.paint_symbol["icon-color-brightness-min"]),"icon-color-brightness-max":new il(sl.paint_symbol["icon-color-brightness-max"])}),layout:iv};class rv{constructor(t){this.type=t.property.overrides?t.property.overrides.runtimeType:Yn,this.defaultValue=t}evaluate(t){if(t.formattedSection){const e=this.defaultValue.property.overrides;if(e&&e.hasOverride(t.formattedSection))return e.getOverride(t.formattedSection)}return t.feature&&t.featureState?this.defaultValue.evaluate(t.feature,t.featureState):this.defaultValue.property.specification.default}eachChild(t){this.defaultValue.isConstant()||t(this.defaultValue.value._styleExpression.expression)}outputDefined(){return!1}serialize(){return null}}ba(rv,"FormatSectionOverride",{omit:["defaultValue"]});class ov extends Ml{constructor(e,i,n,r){super(e,nv,i,n,r),this._colorAdjustmentMatrix=t.ad.identity([]),this.hasInitialOcclusionOpacityProperties=void 0!==e.paint&&("icon-occlusion-opacity"in e.paint||"text-occlusion-opacity"in e.paint)}recalculate(t,e){super.recalculate(t,e),"auto"===this.layout.get("icon-rotation-alignment")&&(this.layout._values["icon-rotation-alignment"]="point"!==this.layout.get("symbol-placement")?"map":"viewport"),"auto"===this.layout.get("text-rotation-alignment")&&(this.layout._values["text-rotation-alignment"]="point"!==this.layout.get("symbol-placement")?"map":"viewport"),"auto"===this.layout.get("text-pitch-alignment")&&(this.layout._values["text-pitch-alignment"]=this.layout.get("text-rotation-alignment")),"auto"===this.layout.get("icon-pitch-alignment")&&(this.layout._values["icon-pitch-alignment"]=this.layout.get("icon-rotation-alignment"));const i=this.layout.get("text-writing-mode");if(i){const t=[];for(const e of i)t.indexOf(e)i in t?String(t[i]):""))}(e.properties,r)}createBucket(t){return new jg(t)}queryRadius(){return 0}queryIntersectsFeature(){return!1}_setPaintOverrides(){for(const t of nv.paint.overridableProperties){if(!ov.hasPaintOverride(this.layout,t))continue;const e=this.paint.get(t),i=new rv(e),n=new la(i,e.property.specification,this.scope,this.options);let r=null;r="constant"===e.value.kind||"source"===e.value.kind?new ua("source",n):new ha("composite",n,e.value.zoomStops,e.value._interpolationType),this.paint._values[t]=new tl(e.property,r,e.parameters)}}_handleOverridablePaintPropertyUpdate(t,e,i){return!(!this.layout||e.isDataDriven()||i.isDataDriven())&&ov.hasPaintOverride(this.layout,t)}static hasPaintOverride(t,e){const i=t.get("text-field"),n=nv.paint.properties[e];let r=!1;const o=t=>{for(const e of t)if(n.overrides&&n.overrides.hasOverride(e))return void(r=!0)};if("constant"===i.value.kind&&i.value.value instanceof pr)o(i.value.value.sections);else if("source"===i.value.kind){const t=e=>{r||(e instanceof vr&&gr(e.value)===nr?o(e.value.sections):e instanceof Tr?o(e.sections):e.eachChild(t))},e=i.value;e._styleExpression&&t(e._styleExpression.expression)}return r}getProgramIds(){const t=0!==this.paint.get("icon-opacity").constantOr(1),e=0!==this.paint.get("text-opacity").constantOr(1),i=[];return t&&i.push("symbolIcon"),e&&i.push("symbolSDF"),i}getDefaultProgramParams(t,e,i){return{config:new Wc(this,{zoom:e,lut:i}),overrideFog:!1}}}const sv=new ol({visibility:new il(sl.layout_background.visibility)});var av={paint:new ol({"background-color":new il(sl.paint_background["background-color"]),"background-pattern":new il(sl.paint_background["background-pattern"]),"background-opacity":new il(sl.paint_background["background-opacity"]),"background-emissive-strength":new il(sl.paint_background["background-emissive-strength"])}),layout:sv};const lv=new ol({visibility:new il(sl.layout_raster.visibility)});var cv={paint:new ol({"raster-opacity":new il(sl.paint_raster["raster-opacity"]),"raster-color":new rl(sl.paint_raster["raster-color"]),"raster-color-mix":new il(sl.paint_raster["raster-color-mix"]),"raster-color-range":new il(sl.paint_raster["raster-color-range"]),"raster-hue-rotate":new il(sl.paint_raster["raster-hue-rotate"]),"raster-brightness-min":new il(sl.paint_raster["raster-brightness-min"]),"raster-brightness-max":new il(sl.paint_raster["raster-brightness-max"]),"raster-saturation":new il(sl.paint_raster["raster-saturation"]),"raster-contrast":new il(sl.paint_raster["raster-contrast"]),"raster-resampling":new il(sl.paint_raster["raster-resampling"]),"raster-fade-duration":new il(sl.paint_raster["raster-fade-duration"]),"raster-emissive-strength":new il(sl.paint_raster["raster-emissive-strength"]),"raster-array-band":new il(sl.paint_raster["raster-array-band"]),"raster-elevation":new il(sl.paint_raster["raster-elevation"])}),layout:lv};function dv(e,i,n,r,o,s,a,l){const c=[e,i,1,n,r,1,o,s,1],d=[a,l,1],u=t.bC.adjoint([],c),[h,p,f]=t._.transformMat3(d,d,u);return t.bC.multiply(c,c,[h,0,0,0,p,0,0,0,f])}function uv(e,i,n,r,o,s,a,l){const c=function(e,i,n,r,o,s,a,l){const c=dv(0,0,1,0,1,1,0,1),d=dv(e,i,n,r,o,s,a,l),u=t.bC.adjoint([],c);return t.bC.multiply(d,d,u)}(e,i,n,r,o,s,a,l);return[c[2]/c[8]/uo,c[5]/c[8]/uo]}function hv(t){return[t[0],Math.min(Math.max(t[1],-Pd),Pd)]}class pv extends zn{constructor(t,e,i,n){super(),this.id=t,this.dispatcher=i,this.coordinates=e.coordinates,this.type="image",this.minzoom=0,this.maxzoom=22,this.tileSize=512,this.tiles={},this._loaded=!1,this.onNorthPole=!1,this.onSouthPole=!1,this.setEventedParent(n),this.options=e,this._dirty=!1}load(t,e){if(this._loaded=e||!1,this.fire(new Pn("dataloading",{dataType:"source"})),this.url=this.options.url,!this.url)return t&&(this.coordinates=t),this._loaded=!0,void this._finishLoading();this._imageRequest=an(this.map._requestManager.transformRequest(this.url,Ki.Image),((e,i)=>{this._imageRequest=null,this._loaded=!0,e?this.fire(new $n(e)):i&&(this.image=i instanceof HTMLImageElement?ki.getImageData(i):i,this._dirty=!0,this.width=this.image.width,this.height=this.image.height,t&&(this.coordinates=t),this._finishLoading())}))}loaded(){return this._loaded}updateImage(t){return t.url?(this._imageRequest&&t.url!==this.options.url&&(this._imageRequest.cancel(),this._imageRequest=null),this.options.url=t.url,this.load(t.coordinates,this._loaded),this):this}setTexture(t){if(!(t.handle instanceof WebGLTexture))throw new Error("The provided handle is not a WebGLTexture instance");return this.texture=new Gg(this.map.painter.context,t.handle),this.width=t.dimensions[0],this.height=t.dimensions[1],this._dirty=!1,this._loaded=!0,this._finishLoading(),this}_finishLoading(){this.map&&(this.setCoordinates(this.coordinates),this.fire(new Pn("data",{dataType:"source",sourceDataType:"metadata"})))}onAdd(t){this.map=t,this.load()}onRemove(t){this._imageRequest&&(this._imageRequest.cancel(),this._imageRequest=null),!this.texture||this.texture instanceof Gg||this.texture.destroy(),this.boundsBuffer&&(this.boundsBuffer.destroy(),this.elevatedGlobeVertexBuffer&&this.elevatedGlobeVertexBuffer.destroy(),this.elevatedGlobeIndexBuffer&&this.elevatedGlobeIndexBuffer.destroy())}setCoordinates(t){if(this.coordinates=t,this._boundsArray=void 0,this._unsupportedCoords=!1,!t.length)return this;this.onNorthPole=!1,this.onSouthPole=!1;let e=t[0][1],i=t[0][1];for(const n of t)n[1]>i&&(i=n[1]),n[1]Pd?this.onNorthPole=!0:n1&&(l-=1),new gd(s,l,Math.floor((i+r)/2*a))}(e),this.minzoom=this.maxzoom=this.tileID.z}return this.fire(new Pn("data",{dataType:"source",sourceDataType:"content"})),this}_clear(){this._boundsArray=void 0,this._unsupportedCoords=!1}_prepareData(e){for(const t in this.tiles){const e=this.tiles[t];"loaded"!==e.state&&(e.state="loaded",e.texture=this.texture)}if(this._boundsArray||this.onNorthPole||this.onSouthPole||this._unsupportedCoords)return;const i=eg(new gd(0,0,0),this.map.transform.projection),n=[i.projection.project(this.coordinates[0][0],this.coordinates[0][1]),i.projection.project(this.coordinates[1][0],this.coordinates[1][1]),i.projection.project(this.coordinates[2][0],this.coordinates[2][1]),i.projection.project(this.coordinates[3][0],this.coordinates[3][1])];if(!function(t){const e=t[1].x-t[0].x,i=t[1].y-t[0].y,n=t[2].x-t[1].x,r=t[2].y-t[1].y,o=t[3].x-t[2].x,s=t[3].y-t[2].y,a=t[0].x-t[3].x,l=t[0].y-t[3].y,c=e*r-n*i,d=n*s-o*r,u=o*l-a*s,h=a*i-e*l;return c>0&&d>0&&u>0&&h>0||c{const e=r.projection.project(t[0],t[1]);return ig(r,e)._round()}));this.perspectiveTransform=uv(o.x,o.y,s.x,s.y,a.x,a.y,l.x,l.y);const c=this._boundsArray=new Dl;c.emplaceBack(o.x,o.y,0,0),c.emplaceBack(s.x,s.y,uo,0),c.emplaceBack(l.x,l.y,0,uo),c.emplaceBack(a.x,a.y,uo,uo),this.boundsBuffer&&(this.boundsBuffer.destroy(),this.elevatedGlobeVertexBuffer&&this.elevatedGlobeVertexBuffer.destroy(),this.elevatedGlobeIndexBuffer&&this.elevatedGlobeIndexBuffer.destroy()),this.boundsBuffer=e.createVertexBuffer(c,Jg.members),this.boundsSegments=wc.simpleSegment(0,0,4,2);const d=[],u=function(t){return[hv(t[0]),hv(t[1]),hv(t[2]),hv(t[3])]}(this.coordinates),[h,p,f,m]=function(t){let e=t[0][0],i=e,n=t[0][1],r=n;for(let o=1;oi&&(i=t[o][0]),t[o][1]r&&(r=t[o][1]);return[e,n,i-e,r-n]}(u);{const r=new Dl,[o,s,a,l]=function(t){let e=t[0].x,i=e,n=t[0].y,r=n;for(let o=1;oi&&(i=t[o].x),t[o].yr&&(r=t[o].y);return[e,n,i-e,r-n]}(n),c=t=>[(t.x-o)/a,(t.y-s)/l],[u,_,g,y]=n.map(c),v=function(e,i,n,r,o,s,a,l){const c=dv(0,0,1,0,1,1,0,1),d=dv(e,i,n,r,o,s,a,l),u=t.bC.adjoint([],d);return t.bC.multiply(c,c,u)}(u[0],u[1],_[0],_[1],g[0],g[1],y[0],y[1]);this.elevatedGlobePerspectiveTransform=uv(u[0],u[1],_[0],_[1],g[0],g[1],y[0],y[1]);const x=(e,i)=>{d.push(e.lng);const n=Math.round((e.lng-h)/f*uo),o=Math.round((e.lat-p)/m*uo),s=c(i),a=t._.transformMat3([],[s[0],s[1],1],v),l=Math.round(a[0]/a[2]*uo),u=Math.round(a[1]/a[2]*uo);r.emplaceBack(n,o,l,u)},b=n[3].x-n[0].x,w=n[3].y-n[0].y,T=n[2].x-n[1].x,S=n[2].y-n[1].y;for(let t=0;t{i.emplaceBack(e,n,r);const o=d[e],s=d[n],a=d[r],l=Math.min(Math.min(o,s),a),c=Math.max(Math.max(o,s),a)-l;c>this.maxLongitudeTriangleSize&&(this.maxLongitudeTriangleSize=c),t.push(l+c/2)};for(let t=0;te));i.sort(((e,i)=>t[e]-t[i]));const n=[],r=new Kl;for(let o=0;o{o.segments.push({vertexOffset:0,primitiveOffset:t,vertexLength:e.segments[0].vertexLength,primitiveLength:i,sortKey:void 0,vaos:{}})},a=.51*this.maxLongitudeTriangleSize;if(Math.abs(i[0]-n)0){const n=function(e,i){const n=i.worldSize,r=Cd(1,0)*n*kd(i.center.lat,i.zoom)/Gu(n),o=Cd(1,i.center.lat)*n,s=t.ad.identity([]);return t.ad.rotateY(s,s,Ge(i.center.lng)),t.ad.rotateX(s,s,Ge(i.center.lat)),t.ad.translate(s,s,[0,0,ed]),t.ad.scale(s,s,[r,r,r*o]),t.ad.translate(s,s,[i.point.x-.5*n,i.point.y-.5*n,0]),t.ad.multiply(s,s,e),t.ad.multiply(s,i.globeMatrix,s)}(e,i);return function(e,i,n){const r=(e,i,n)=>{const r=t._.length(e),o=t._.length(i),s=ku(e,i,n);return t._.scale(s,s,1/t._.length(s)*Vn(r,o,n))},o=r([e[0],e[1],e[2]],[i[0],i[1],i[2]],n),s=r([e[4],e[5],e[6]],[i[4],i[5],i[6]],n),a=r([e[8],e[9],e[10]],[i[8],i[9],i[10]],n),l=ku([e[12],e[13],e[14]],[i[12],i[13],i[14]],n);return[o[0],o[1],o[2],0,s[0],s[1],s[2],0,a[0],a[1],a[2],0,l[0],l[1],l[2],1]}(o,n,r)}return o}function kv(t,e,i,n){const r=wu.projectAabbCorners(n,i);let o=Number.MAX_VALUE,s=-1;for(let t=0;tnew Ue(r[t][0],r[t][1]);let l;switch(s){case 0:case 6:l=[a(1),a(5),a(4),a(7),a(3),a(2),a(1)];break;case 1:case 7:l=[a(0),a(4),a(5),a(6),a(2),a(3),a(0)];break;case 3:case 5:l=[a(1),a(0),a(4),a(7),a(6),a(2),a(1)];break;default:l=[a(1),a(5),a(6),a(7),a(3),a(0),a(1)]}if(Yd(t,l))return o}const Dv=Ll([{name:"a_pos_3f",components:3,type:"Float32"}]),zv=Ll([{name:"a_color_3f",components:3,type:"Float32"}]),Rv=Ll([{name:"a_color_4f",components:4,type:"Float32"}]),Ov=Ll([{name:"a_uv_2f",components:2,type:"Float32"}]),Bv=Ll([{name:"a_normal_3f",components:3,type:"Float32"}]),Fv=Ll([{name:"a_normal_matrix0",components:4,type:"Float32"},{name:"a_normal_matrix1",components:4,type:"Float32"},{name:"a_normal_matrix2",components:4,type:"Float32"},{name:"a_normal_matrix3",components:4,type:"Float32"}]),Nv=Ll([{name:"a_pbr",components:4,type:"Uint16"},{name:"a_heightBasedEmissiveStrength",components:3,type:"Float32"}]);class Uv{constructor(t,e,i,n){this.message=(t?`${t}: `:"")+i,n&&(this.identifier=n),null!=e&&e.__line__&&(this.line=e.__line__)}}function jv(t,e){const i=-1===t.indexOf("://");try{return new URL(t,i&&e?"http://example.com":void 0),!0}catch(t){return!1}}class Vv{constructor(t,e){this.feature=t,this.instancedDataOffset=e,this.instancedDataCount=0,this.rotation=[0,0,0],this.scale=[1,1,1],this.translation=[0,0,0]}}class Gv{constructor(){this.instancedDataArray=new oc,this.instancesEvaluatedElevation=[],this.features=[],this.idToFeaturesIndex={}}}class Zv{constructor(t){this.zoom=t.zoom,this.canonical=t.canonical,this.layers=t.layers,this.layerIds=this.layers.map((t=>t.fqid)),this.projection=t.projection,this.index=t.index,this.hasZoomDependentProperties=this.layers[0].isZoomDependent(),this.stateDependentLayerIds=this.layers.filter((t=>t.isStateDependent())).map((t=>t.id)),this.hasPattern=!1,this.instancesPerModel={},this.validForExaggeration=0,this.maxVerticalOffset=0,this.maxScale=0,this.maxHeight=0,this.lookupDim=this.zoom>this.canonical.z?256:this.zoom>15?75:100,this.instanceCount=0,this.terrainElevationMin=0,this.terrainElevationMax=0,this.validForDEMTile={id:null,timestamp:0},this.modelUris=[],this.modelsRequested=!1,this.activeReplacements=[],this.replacementUpdateTime=0}updateFootprints(t,e){}populate(t,e,i,n){this.tileToMeter=zd(i);const r=this.layers[0]._featureFilter.needGeometry;this.lookup=new Uint8Array(this.lookupDim*this.lookupDim);for(const{feature:o,id:s,index:a,sourceLayerIndex:l}of t){const t=null!=s?s:o.properties&&o.properties.hasOwnProperty("id")?o.properties.id:void 0,c=Zd(o,r);if(!this.layers[0]._featureFilter.filter(new Ha(this.zoom),c,i))continue;const d={id:t,sourceLayerIndex:l,index:a,geometry:r?c.geometry:Gd(o,i,n),properties:o.properties,type:o.type,patterns:{}},u=this.addFeature(d,d.geometry,c);u&&e.featureIndex.insert(o,d.geometry,a,l,this.index,this.instancesPerModel[u].instancedDataArray.length,uo/32)}this.lookup=null}update(t,e,i,n){for(const e in this.instancesPerModel){const i=this.instancesPerModel[e];for(const e in t)i.idToFeaturesIndex.hasOwnProperty(e)&&(this.evaluate(i.features[i.idToFeaturesIndex[e]],t[e],i,!0),this.uploaded=!1)}this.maxHeight=0}updateZoomBasedPaintProperties(){if(!this.hasZoomDependentProperties)return!1;let e=!1;for(const i in this.instancesPerModel){const n=this.instancesPerModel[i];for(const i of n.features){const r=this.layers[0],o=i.feature,s=this.canonical,a=r.paint.get("model-rotation").evaluate(o,{},s),l=r.paint.get("model-scale").evaluate(o,{},s),c=r.paint.get("model-translation").evaluate(o,{},s);t._.exactEquals(i.rotation,a)&&t._.exactEquals(i.scale,l)&&t._.exactEquals(i.translation,c)||(this.evaluate(i,i.featureStates,n,!0),e=!0)}}return e}updateReplacement(t,e,i){if(e.updateTime===this.replacementUpdateTime)return!1;this.replacementUpdateTime=e.updateTime;const n=e.getReplacementRegionsForTile(t.toUnwrapped(),!0);if(Pp(this.activeReplacements,n))return!1;this.activeReplacements=n;let r=!1;for(const e in this.instancesPerModel){const n=this.instancesPerModel[e],o=n.instancedDataArray;for(const e of n.features){const n=e.instancedDataOffset,s=e.instancedDataCount;for(let e=0;euo?a-uo:a;const l=Math.floor(a),c=o.float32[s+1];let d=!1;for(const e of this.activeReplacements)if(!(e.orderl||l>e.max.x||e.min.y>c||c>e.max.y)&&(d=Op(Rp(l,c,t.canonical,e.footprintTileId.canonical),e),d))break;o.float32[s]=d?a+uo:a,r=r||d}}}return r}isEmpty(){for(const t in this.instancesPerModel)if(0!==this.instancesPerModel[t].instancedDataArray.length)return!1;return!0}uploadPending(){return!this.uploaded}upload(t){if(!this.uploaded)for(const e in this.instancesPerModel){const i=this.instancesPerModel[e];i.instancedDataArray.length=uo||e.y=uo)continue;const t=(this.lookupDim-1)/uo,i=this.lookupDim*(e.y*t|0)+e.x*t|0;if(this.lookup){if(0!==this.lookup[i])continue;this.lookup[i]=1}this.instanceCount++;const n=s.length;s.resize(n+1),o.instancesEvaluatedElevation.push(0),s.float32[16*n]=e.x,s.float32[16*n+1]=e.y}return a.instancedDataCount=o.instancedDataArray.length-a.instancedDataOffset,a.instancedDataCount>0&&(t.id&&(o.idToFeaturesIndex[t.id]=o.features.length),o.features.push(a),this.evaluate(a,{},o,!1)),r}getModelUris(){return this.modelUris}evaluate(t,e,i,n){const r=this.layers[0],o=t.feature,s=this.canonical,a=t.rotation=r.paint.get("model-rotation").evaluate(o,e,s),l=t.scale=r.paint.get("model-scale").evaluate(o,e,s),c=t.translation=r.paint.get("model-translation").evaluate(o,e,s),d=r.paint.get("model-color").evaluate(o,e,s);d.a=r.paint.get("model-color-mix-intensity").evaluate(o,e,s);const u=[];this.maxVerticalOffset10?this.tileToMeter:zd(s,p)),a[o+4]=c[0],a[o+5]=c[1],a[o+6]=c[2]+l,a[o+7]=u[0],a[o+8]=u[1],a[o+9]=u[2],a[o+10]=u[4],a[o+11]=u[5],a[o+12]=u[6],a[o+13]=u[8],a[o+14]=u[9],a[o+15]=u[10],i.instancesEvaluatedElevation[r]=c[2]}}}ba(Zv,"ModelBucket",{omit:["layers"]}),ba(Gv,"PerModelAttributes"),ba(Vv,"ModelFeature");const qv=new ol({visibility:new il(sl.layout_model.visibility),"model-id":new nl(sl.layout_model["model-id"])});var Hv={paint:new ol({"model-opacity":new il(sl.paint_model["model-opacity"]),"model-rotation":new nl(sl.paint_model["model-rotation"]),"model-scale":new nl(sl.paint_model["model-scale"]),"model-translation":new nl(sl.paint_model["model-translation"]),"model-color":new nl(sl.paint_model["model-color"]),"model-color-mix-intensity":new nl(sl.paint_model["model-color-mix-intensity"]),"model-type":new il(sl.paint_model["model-type"]),"model-cast-shadows":new il(sl.paint_model["model-cast-shadows"]),"model-receive-shadows":new il(sl.paint_model["model-receive-shadows"]),"model-ambient-occlusion-intensity":new il(sl.paint_model["model-ambient-occlusion-intensity"]),"model-emissive-strength":new nl(sl.paint_model["model-emissive-strength"]),"model-roughness":new nl(sl.paint_model["model-roughness"]),"model-height-based-emissive-strength-multiplier":new nl(sl.paint_model["model-height-based-emissive-strength-multiplier"]),"model-cutoff-fade-range":new il(sl.paint_model["model-cutoff-fade-range"]),"model-front-cutoff":new il(sl.paint_model["model-front-cutoff"])}),layout:qv};const Wv=64,Yv={CoordinateSpaceTile:1,CoordinateSpaceYUp:2,HasMapboxMeshFeatures:4,HasMeshoptCompression:8};function Xv(e,i,n,r,o,s,a,l,c,d=!1){const u=n.zoom,h=n.project(r),p=kd(r.lat,u),f=1/p;t.ad.identity(e),t.ad.translate(e,e,[h.x+a[0]*f,h.y+a[1]*f,a[2]]);let m=1,_=1;const g=n.worldSize;if(d){if("mercator"===n.projection.name){let e=0;n.elevation&&(e=n.elevation.getAtPointOrZero(new Rd(h.x/g,h.y/g),0));const i=t.aA.transformMat4([],[h.x,h.y,e,1],n.projMatrix)[3]/n.cameraToCenterDistance;m=i,_=i*kd(n.center.lat,u)}else if("globe"===n.projection.name){const i=$v(e,n),o=t.ad.multiply([],n.projMatrix,i),s=[0,0,0,1];t.aA.transformMat4(s,s,o);const a=s[3]/n.cameraToCenterDistance,l=Hu(u),c=n.projection.pixelsPerMeter(r.lat,g)*kd(r.lat,u),d=n.projection.pixelsPerMeter(n.center.lat,g)*kd(n.center.lat,u);m=a/Vn(c,$d(n.center.lat),l),_=a*p/c,m*=d,_*=d}}else m=f;t.ad.scale(e,e,[m,m,_]);const y=[...e],v=i.orientation,x=[];if(Lv(x,[v[0]+o[0],v[1]+o[1],v[2]+o[2]],s),t.ad.multiply(e,y,x),l&&n.elevation){let o=0;const s=[];if(c&&n.elevation){o=function(e,i,n,r,o){const s=i.elevation;if(!s)return 0;const a=wu.projectAabbCorners(n,r),l=Cd(1,o.lat)*i.worldSize,c=function(e,i){const n=[0,0,1],r=[{corners:[0,1,3,2],dotProductWithUp:0},{corners:[1,5,2,6],dotProductWithUp:0},{corners:[0,4,1,5],dotProductWithUp:0},{corners:[2,6,3,7],dotProductWithUp:0},{corners:[4,7,5,6],dotProductWithUp:0},{corners:[0,3,4,7],dotProductWithUp:0}];for(const o of r){const r=e[o.corners[0]],s=e[o.corners[1]],a=e[o.corners[2]],l=[s[0]-r[0],s[1]-r[1],i*(s[2]-r[2])],c=t._.cross(l,l,[a[0]-r[0],a[1]-r[1],i*(a[2]-r[2])]);t._.normalize(c,c),o.dotProductWithUp=t._.dot(c,n)}return r.sort(((t,e)=>t.dotProductWithUp-e.dotProductWithUp)),r[0].corners}(a,l),d=a[c[0]],u=a[c[1]],h=a[c[2]],p=a[c[3]],f=s.getAtPointOrZero(new Rd(d[0]/i.worldSize,d[1]/i.worldSize),0),m=s.getAtPointOrZero(new Rd(u[0]/i.worldSize,u[1]/i.worldSize),0),_=s.getAtPointOrZero(new Rd(h[0]/i.worldSize,h[1]/i.worldSize),0),g=s.getAtPointOrZero(new Rd(p[0]/i.worldSize,p[1]/i.worldSize),0),y=(f+g)/2,v=(m+_)/2;return y>v?m=e.gl.NEAREST_MIPMAP_NEAREST}),t.uploaded=!0,t.image=null)}function Jv(t,e,i){t.indexBuffer=e.createIndexBuffer(t.indexArray,!1,!0),t.vertexBuffer=e.createVertexBuffer(t.vertexArray,Dv.members,!1,!0),t.normalArray&&(t.normalBuffer=e.createVertexBuffer(t.normalArray,Bv.members,!1,!0)),t.texcoordArray&&(t.texcoordBuffer=e.createVertexBuffer(t.texcoordArray,Ov.members,!1,!0)),t.colorArray&&(t.colorBuffer=e.createVertexBuffer(t.colorArray,(12===t.colorArray.bytesPerElement?zv:Rv).members,!1,!0)),t.featureArray&&(t.pbrBuffer=e.createVertexBuffer(t.featureArray,Nv.members,!0)),t.segments=wc.simpleSegment(0,0,t.vertexArray.length,t.indexArray.length);const n=t.material;n.pbrMetallicRoughness.baseColorTexture&&Kv(n.pbrMetallicRoughness.baseColorTexture,e),n.pbrMetallicRoughness.metallicRoughnessTexture&&Kv(n.pbrMetallicRoughness.metallicRoughnessTexture,e),n.normalTexture&&Kv(n.normalTexture,e),n.occlusionTexture&&Kv(n.occlusionTexture,e,i),n.emissionTexture&&Kv(n.emissionTexture,e)}function Qv(t,e,i){if(t.meshes)for(const n of t.meshes)Jv(n,e,i);if(t.children)for(const n of t.children)Qv(n,e,i)}function tx(t){if(t.meshes)for(const e of t.meshes)e.indexArray.destroy(),e.vertexArray.destroy(),e.colorArray&&e.colorArray.destroy(),e.normalArray&&e.normalArray.destroy(),e.texcoordArray&&e.texcoordArray.destroy(),e.featureArray&&e.featureArray.destroy();if(t.children)for(const e of t.children)tx(e)}function ex(t){if(t.meshes)for(const i of t.meshes)i.vertexBuffer&&(i.vertexBuffer.destroy(),i.indexBuffer.destroy(),i.normalBuffer&&i.normalBuffer.destroy(),i.texcoordBuffer&&i.texcoordBuffer.destroy(),i.colorBuffer&&i.colorBuffer.destroy(),i.pbrBuffer&&i.pbrBuffer.destroy(),i.segments.destroy(),i.material&&((e=i.material).pbrMetallicRoughness.baseColorTexture&&e.pbrMetallicRoughness.baseColorTexture.gfxTexture&&e.pbrMetallicRoughness.baseColorTexture.gfxTexture.destroy(),e.pbrMetallicRoughness.metallicRoughnessTexture&&e.pbrMetallicRoughness.metallicRoughnessTexture.gfxTexture&&e.pbrMetallicRoughness.metallicRoughnessTexture.gfxTexture.destroy(),e.normalTexture&&e.normalTexture.gfxTexture&&e.normalTexture.gfxTexture.destroy(),e.emissionTexture&&e.emissionTexture.gfxTexture&&e.emissionTexture.gfxTexture.destroy(),e.occlusionTexture&&e.occlusionTexture.gfxTexture&&e.occlusionTexture.gfxTexture.destroy()));var e;if(t.children)for(const e of t.children)ex(e)}class ix{constructor(t){this._callback=t,this._triggered=!1,"undefined"!=typeof MessageChannel&&(this._channel=new MessageChannel,this._channel.port2.onmessage=()=>{this._triggered=!1,this._callback()})}trigger(){this._triggered||(this._triggered=!0,this._channel?this._channel.port1.postMessage(!0):setTimeout((()=>{this._triggered=!1,this._callback()}),0))}remove(){this._channel=void 0,this._callback=()=>{}}}class nx{constructor(){this.tasks={},this.taskQueue=[],ai(["process"],this),this.invoker=new ix(this.process),this.nextId=0}add(t,e){const i=this.nextId++,n=function({type:t,isSymbolTile:e,zoom:i}){return i=i||0,"message"===t?0:"maybePrepare"!==t||e?"parseTile"!==t||e?"parseTile"===t&&e?300-i:"maybePrepare"===t&&e?400-i:500:200-i:100-i}(e);if(0===n){try{t()}finally{}return null}return this.tasks[i]={fn:t,metadata:e,priority:n,id:i},this.taskQueue.push(i),this.invoker.trigger(),{cancel:()=>{delete this.tasks[i]}}}process(){try{if(this.taskQueue=this.taskQueue.filter((t=>!!this.tasks[t])),!this.taskQueue.length)return;const t=this.pick();if(null===t)return;const e=this.tasks[t];if(delete this.tasks[t],this.taskQueue.length&&this.invoker.trigger(),!e)return;e.fn()}finally{}}pick(){let t=null,e=1/0;for(let i=0;i{i&&delete this.callbacks[s],this.target.postMessage({id:s,type:"",targetMapId:n,sourceMapId:this.mapId})}}}receive(t){const e=t.data,i=e.id;if(i&&(!e.targetMapId||this.mapId===e.targetMapId))if(""===e.type){const t=this.cancelCallbacks[i];delete this.cancelCallbacks[i],t&&t.cancel()}else if(e.mustQueue||gi()){const t=this.callbacks[i],n=this.scheduler.add((()=>this.processTask(i,e)),t&&t.metadata||{type:"message"});n&&(this.cancelCallbacks[i]=n)}else this.processTask(i,e)}processTask(t,e){if(delete this.cancelCallbacks[t],""===e.type){const i=this.callbacks[t];delete this.callbacks[t],i&&(e.error?i(Ea(e.error)):i(null,Ea(e.data)))}else{const i=new Set,n=e.hasCallback?(e,n)=>{this.target.postMessage({id:t,type:"",sourceMapId:this.mapId,error:e?Sa(e):null,data:Sa(n,i)},i)}:t=>{},r=Ea(e.data);if(this.parent[e.type])this.parent[e.type](e.sourceMapId,r,n);else if(this.parent.getWorkerSource){const t=e.type.split(".");this.parent.getWorkerSource(e.sourceMapId,t[0],r.source,r.scope)[t[1]](r,n)}else n(new Error(`Could not find function ${e.type}`))}}remove(){this.scheduler.remove(),this.target.removeEventListener("message",this.receive,!1)}}class ox{constructor(t,e){this.workerPool=t,this.actors=[],this.currentActor=0,this.id=ni();const i=this.workerPool.acquire(this.id);for(let t=0;t{this.ready=!0}))}broadcast(t,e,i){Qe(this.actors,((i,n)=>{i.send(t,e,n)}),i=i||function(){})}getActor(){return this.currentActor=(this.currentActor+1)%this.actors.length,this.actors[this.currentActor]}remove(){this.actors.forEach((t=>{t.remove()})),this.actors=[],this.workerPool.release(this.id)}}ox.Actor=rx;var sx={workerUrl:"",workerClass:null,workerParams:void 0};function ax(){return null!=sx.workerClass?new sx.workerClass:new self.Worker(sx.workerUrl,sx.workerParams)}const lx="mapboxgl_preloaded_worker_pool";class cx{constructor(){this.active={}}acquire(t){if(!this.workers)for(this.workers=[];this.workers.length{t.terminate()})),this.workers=null)}isPreloaded(){return!!this.active[lx]}numActive(){return Object.keys(this.active).length}}let dx;function ux(){return dx||(dx=new cx),dx}cx.workerCount=2;let hx,px,fx,mx,_x,gx=null;function yx(){return gi()&&self.worker&&self.worker.dracoUrl?self.worker.dracoUrl:px||n.DRACO_URL}function vx(){if(gi()&&self.worker&&self.worker.meshoptUrl)return self.worker.meshoptUrl;if(mx)return mx;const t=new Uint8Array([0,97,115,109,1,0,0,0,1,4,1,96,0,0,3,3,2,0,0,5,3,1,0,1,12,1,0,10,22,2,12,0,65,0,65,0,65,0,252,10,0,0,11,7,0,65,0,253,15,26,11]);if("object"!=typeof WebAssembly)throw new Error("WebAssembly not supported, cannot instantiate meshoptimizer");return mx=WebAssembly.validate(t)?n.MESHOPT_SIMD_URL:n.MESHOPT_URL,mx}const xx={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},bx={5120:"DT_INT8",5121:"DT_UINT8",5122:"DT_INT16",5123:"DT_UINT16",5125:"DT_UINT32",5126:"DT_FLOAT32"},wx={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16};function Tx(t,e,i){const n=i.json.bufferViews.length,r=i.buffers.length;e.bufferView=n,i.json.bufferViews[n]={buffer:r,byteLength:t.byteLength},i.buffers[r]=t}const Sx="KHR_draco_mesh_compression";function Ex(t,e){const i=t.extensions&&t.extensions[Sx];if(!i)return;const n=new fx.Decoder,r=$x(e,i.bufferView),o=new fx.Mesh;if(!n.DecodeArrayToMesh(r,r.byteLength,o))throw new Error("Failed to decode Draco mesh");const s=e.json.accessors[t.indices],a=xx[s.componentType],l=s.count*a.BYTES_PER_ELEMENT,c=fx._malloc(l);a===Uint16Array?n.GetTrianglesUInt16Array(o,l,c):n.GetTrianglesUInt32Array(o,l,c),Tx(fx.memory.buffer.slice(c,c+l),s,e),fx._free(c);for(const r of Object.keys(i.attributes)){const s=n.GetAttributeByUniqueId(o,i.attributes[r]),a=e.json.accessors[t.attributes[r]],l=bx[a.componentType],c=a.count*wx[a.type]*xx[a.componentType].BYTES_PER_ELEMENT,d=fx._malloc(c);n.GetAttributeDataArrayForAllPoints(o,s,fx[l],c,d),Tx(fx.memory.buffer.slice(d,d+c),a,e),fx._free(d)}n.destroy(),o.destroy(),delete t.extensions[Sx]}const Mx="EXT_meshopt_compression";function Cx(t,e){if(!t.extensions||!t.extensions[Mx])return;const i=t.extensions[Mx],n=new Uint8Array(e.buffers[i.buffer],i.byteOffset||0,i.byteLength||0),r=new Uint8Array(i.count*i.byteStride);_x.decodeGltfBuffer(r,i.count,i.byteStride,n,i.mode,i.filter),t.buffer=e.buffers.length,t.byteOffset=0,e.buffers[t.buffer]=r.buffer,delete t.extensions[Mx]}const Ax=1179937895,Ix=new TextDecoder("utf8");function Lx(t,e){return new URL(t,e).href}function Px(t,e,i,n){return fetch(Lx(t.uri,n)).then((t=>t.arrayBuffer())).then((t=>{e.buffers[i]=t}))}function $x(t,e){const i=t.json.bufferViews[e];return new Uint8Array(t.buffers[i.buffer],i.byteOffset||0,i.byteLength)}function kx(t,e,i,n){if(t.uri){const r=Lx(t.uri,n);return fetch(r).then((t=>t.blob())).then((t=>createImageBitmap(t))).then((t=>{e.images[i]=t}))}if(void 0!==t.bufferView){const n=$x(e,t.bufferView),r=new Blob([n],{type:t.mimeType});return createImageBitmap(r).then((t=>{e.images[i]=t}))}}function Dx(t,e=0,i){const n={json:null,images:[],buffers:[]};if(new Uint32Array(t,e,1)[0]===Ax){const i=new Uint32Array(t,e);let r=2;const o=(i[r++]>>2)-3,s=i[r++]>>2;if(r++,n.json=JSON.parse(Ix.decode(i.subarray(r,r+s))),r+=s,r{const t=[],e=a&&a.includes(Sx),r=a&&a.includes(Mx);if(e&&t.push(function(){if(!fx)return hx||(hx=function(t){let e,i=null;function n(){e=new Uint8Array(i.buffer)}function r(){throw new Error("Unexpected Draco error.")}const o={a:{a:r,d:function(t,i,n){return e.copyWithin(t,i,i+n)},c:function(t){const r=e.length,o=Math.max(t>>>0,Math.ceil(1.2*r)),s=Math.ceil((o-r)/65536);try{return i.grow(s),n(),!0}catch(t){return!1}},b:r}};return(WebAssembly.instantiateStreaming?WebAssembly.instantiateStreaming(t,o):t.then((t=>t.arrayBuffer())).then((t=>WebAssembly.instantiate(t,o)))).then((t=>{const{Rb:r,Qb:o,P:s,T:a,X:l,Ja:c,La:d,Qa:u,Va:h,Wa:p,eb:f,jb:m,f:_,e:g,yb:y,zb:v,Ab:x,Bb:b,Db:w,Gb:T}=t.instance.exports;i=g;const S=(()=>{let t=0,i=0,n=0,s=0;return a=>{n&&(r(s),r(t),i+=n,n=t=0),t||(i+=128,t=o(i));const l=a.length+7&-8;let c=t;l>=i&&(n=l,c=s=o(l));for(let t=0;t{fx=t,hx=void 0})))}()),r&&t.push(function(){if(_x)return;const t=function(t){let e;const i=WebAssembly.instantiateStreaming(t,{}).then((t=>{e=t.instance,e.exports.__wasm_call_ctors()})),n={NONE:"",OCTAHEDRAL:"meshopt_decodeFilterOct",QUATERNION:"meshopt_decodeFilterQuat",EXPONENTIAL:"meshopt_decodeFilterExp"},r={ATTRIBUTES:"meshopt_decodeVertexBuffer",TRIANGLES:"meshopt_decodeIndexBuffer",INDICES:"meshopt_decodeIndexSequence"};return{ready:i,supported:!0,decodeGltfBuffer(t,i,o,s,a,l){!function(t,e,i,n,r,o,s){const a=t.exports.sbrk,l=n+3&-4,c=a(l*r),d=a(o.length),u=new Uint8Array(t.exports.memory.buffer);u.set(o,d);const h=e(c,n,r,d,o.length);if(0===h&&s&&s(c,l,r),i.set(u.subarray(c,c+n*r)),a(c-a(0)),0!==h)throw new Error(`Malformed buffer data: ${h}`)}(e,e.exports[r[a]],t,i,o,s,e.exports[n[l]])}}}(fetch(vx()));return t.ready.then((()=>{_x=t}))}()),o)for(let e=0;e{if(e&&s)for(const{primitives:t}of s)for(const e of t)Ex(e,n);if(r&&s&&l)for(const t of l)Cx(t,n);return n}))}))}function zx(t,e){const i=t.json.bufferViews[e.bufferView],n=xx[e.componentType];return new n(t.buffers[i.buffer],(e.byteOffset||0)+(i.byteOffset||0),e.count*(i.byteStride&&i.byteStride!==wx[e.type]*n.BYTES_PER_ELEMENT?i.byteStride/n.BYTES_PER_ELEMENT:wx[e.type]))}function Rx(t,e,i,n){const r=xx[e.componentType],o=function(t){switch(t){case Int8Array:return 1/127;case Uint8Array:return 1/255;case Int16Array:return 1/32767;case Uint16Array:return 1/65535;default:return 1}}(r),s=t.json.bufferViews[e.bufferView],a=s.byteStride?s.byteStride/r.BYTES_PER_ELEMENT:wx[e.type],l=i.float32,c=l.length/i.capacity;for(let t=0,i=0;t0){for(let r=0;r0){o.texcoordArray=new ic;const t=e.json.accessors[r.TEXCOORD_0];o.texcoordArray.resize(t.count);const i=zx(e,t);Rx(e,t,o.texcoordArray,i)}if(void 0!==r._FEATURE_ID_RGBA4444){const t=e.json.accessors[r._FEATURE_ID_RGBA4444];e.json.extensionsUsed&&e.json.extensionsUsed.includes("EXT_meshopt_compression")&&(o.featureData=zx(e,t))}void 0!==r._FEATURE_RGBA4444&&(o.featureData=new Uint32Array(zx(e,e.json.accessors[r._FEATURE_RGBA4444]).buffer));const u=t.material;return o.material=function(t,e){const{emissiveFactor:i=[0,0,0],alphaMode:n="OPAQUE",alphaCutoff:r=.5,normalTexture:o,occlusionTexture:s,emissiveTexture:a,doubleSided:l}=t,{baseColorFactor:c=[1,1,1,1],metallicFactor:d=1,roughnessFactor:u=1,baseColorTexture:h,metallicRoughnessTexture:p}=t.pbrMetallicRoughness||{},f=s?e[s.index]:void 0;if(s&&s.extensions&&s.extensions.KHR_texture_transform&&f){const t=s.extensions.KHR_texture_transform;f.offsetScale=[t.offset[0],t.offset[1],t.scale[0],t.scale[1]]}return{pbrMetallicRoughness:{baseColorFactor:new Un(...c),metallicFactor:d,roughnessFactor:u,baseColorTexture:h?e[h.index]:void 0,metallicRoughnessTexture:p?e[p.index]:void 0},doubleSided:l,emissiveFactor:i,alphaMode:n,alphaCutoff:r,normalTexture:o?e[o.index]:void 0,occlusionTexture:f,emissionTexture:a?e[a.index]:void 0,defined:void 0===t.defined}}(void 0!==u?e.json.materials[u]:{defined:!1},i),o}function Bx(e,i,n){const{matrix:r,rotation:o,translation:s,scale:a,mesh:l,extras:c,children:d}=e,u={};if(u.matrix=r||t.ad.fromRotationTranslationScale([],o||[0,0,0,1],s||[0,0,0],a||[1,1,1]),void 0!==l){u.meshes=n[l];const t=u.anchor=[0,0];for(const e of u.meshes){const{min:i,max:n}=e.aabb;t[0]+=i[0]+n[0],t[1]+=i[1]+n[1]}t[0]=Math.floor(t[0]/u.meshes.length/2),t[1]=Math.floor(t[1]/u.meshes.length/2)}if(c&&(c.id&&(u.id=c.id),c.lights&&(u.lights=function(t){if(!t.length)return[];const e=function(t){const e=atob(t),i=new Uint8Array(e.length);for(let t=0;t1&&n[n.length-1].equals(n[0])&&n.pop();let r=0;for(let t=0;t0&&n.reverse();const o=xh(n.flatMap((t=>[t.x,t.y])),[]);return 0===o.length?null:{vertices:n,indices:o}}function Ux(e,i){const n=[],r=[];let o=0;const s=[];for(const a of e){o=n.length;const e=a.vertexArray.float32,l=a.indexArray.uint16;for(let r=0;r0&&([r[t+1],r[t+2]]=[r[t+2],r[t+1]])}return{vertices:n,indices:r}}function jx(t){const e=function(t,e){const i=[],n=WebGL2RenderingContext;if(t.json.textures)for(const r of t.json.textures){const o={magFilter:n.LINEAR,minFilter:n.NEAREST,wrapS:n.REPEAT,wrapT:n.REPEAT};void 0!==r.sampler&&Object.assign(o,t.json.samplers[r.sampler]),i.push({image:e[r.source],sampler:o,uploaded:!1})}return i}(t,t.images),i=function(t,e){const i=[];for(const n of t.json.meshes){const r=[];for(const i of n.primitives)r.push(Ox(i,t,e));i.push(r)}return i}(t,e),{scenes:n,scene:r,nodes:o}=t.json,s=n?n[r||0].nodes:o,a=[];for(const e of s)a.push(Bx(o[e],t,i));return function(t,e,i){const n={},r=new Set;for(let o=0;o0){const e=Array.from(r.values()).sort(((t,e)=>t-e));for(let i=e.length-1;i>=0;i--)t.splice(e[i],1)}}(a,s,t.json.nodes),a}function Vx(t){t.heightmap=new Float32Array(4096),t.heightmap.fill(-1);const e=t.vertexArray.float32,i=t.aabb.min[0]-1,n=t.aabb.min[1]-1,r=Wv/(t.aabb.max[0]-i+2),o=Wv/(t.aabb.max[1]-n+2);for(let s=0;st.heightmap[c*Wv+l]&&(t.heightmap[c*Wv+l]=a)}}function Gx(e,i){const n={};n.indexArray=new Kl,n.indexArray.reserve(4*e.length),n.vertexArray=new Bl,n.vertexArray.reserve(10*e.length),n.colorArray=new Ol,n.vertexArray.reserve(10*e.length);let r=0;for(const o of e){const e=Math.min(10,Math.max(4,1.3*o.height))*i,s=[-o.normal[1],o.normal[0],0],a=Math.min(.29,.1*o.width/o.depth),l=o.width-2*o.depth*i*(a+.01),c=t._.scaleAndAdd([],o.pos,s,l/2),d=t._.scaleAndAdd([],o.pos,s,-l/2),u=[c[0],c[1],c[2]+o.height],h=[d[0],d[1],d[2]+o.height],p=t._.scaleAndAdd([],o.normal,s,a);t._.scale(p,p,e);const f=t._.scaleAndAdd([],o.normal,s,-a);t._.scale(f,f,e),t._.add(p,c,p),t._.add(f,d,f),c[2]+=.1,d[2]+=.1,n.vertexArray.emplaceBack(p[0],p[1],p[2]),n.vertexArray.emplaceBack(f[0],f[1],f[2]),n.vertexArray.emplaceBack(c[0],c[1],c[2]),n.vertexArray.emplaceBack(d[0],d[1],d[2]),n.vertexArray.emplaceBack(u[0],u[1],u[2]),n.vertexArray.emplaceBack(h[0],h[1],h[2]),n.vertexArray.emplaceBack(c[0],c[1],c[2]),n.vertexArray.emplaceBack(d[0],d[1],d[2]),n.vertexArray.emplaceBack(p[0],p[1],p[2]),n.vertexArray.emplaceBack(f[0],f[1],f[2]);const m=l/e/2;n.colorArray.emplaceBack(-m-a,-1,m,.8),n.colorArray.emplaceBack(m+a,-1,m,.8),n.colorArray.emplaceBack(-m,0,m,1.3),n.colorArray.emplaceBack(m,0,m,1.3),n.colorArray.emplaceBack(m+a,-.8,m,.7),n.colorArray.emplaceBack(m+a,-.8,m,.7),n.colorArray.emplaceBack(0,0,m,1.3),n.colorArray.emplaceBack(0,0,m,1.3),n.colorArray.emplaceBack(m+a,-1.2,m,.8),n.colorArray.emplaceBack(m+a,-1.2,m,.8),n.indexArray.emplaceBack(6+r,4+r,8+r),n.indexArray.emplaceBack(7+r,9+r,5+r),n.indexArray.emplaceBack(0+r,1+r,2+r),n.indexArray.emplaceBack(1+r,3+r,2+r),r+=10}const o={defined:!0,emissiveFactor:[0,0,0]},s={};return s.baseColorFactor=Un.white,o.pbrMetallicRoughness=s,n.material=o,n.aabb=new wu([1/0,1/0,1/0],[-1/0,-1/0,-1/0]),n}const Zx=new Float32Array(262144),qx=new Uint8Array(262144);function Hx(t){let e=0;if(t.meshes)for(const i of t.meshes)e=Math.max(e,i.aabb.max[2]);if(t.children)for(const i of t.children)e=Math.max(e,Hx(i));return e}function Wx(t,e,i){if(t.meshes)for(const n of t.meshes)n.aabb.min[0]!==1/0&&i.insert(e,n.aabb.min[0],n.aabb.min[1],n.aabb.max[0],n.aabb.max[1]);if(t.children)for(const n of t.children)Wx(n,e,i)}const Yx=["","wall","door","roof","window","lamp","logo"];class Xx{constructor(t){this.node=t,this.evaluatedRMEA=[[1,0,0,1],[1,0,0,1],[1,0,0,1],[1,0,0,1],[.4,1,0,1],[1,0,0,1],[1,0,0,1]],this.hiddenByReplacement=!1,this.evaluatedScale=[1,1,1],this.evaluatedColor=[],this.emissionHeightBasedParams=[],this.feature={type:"Point",id:t.id,geometry:[],properties:{height:Hx(t)}},this.aabb=this._getLocalBounds()}_getLocalBounds(){if(!this.node.meshes)return new wu([1/0,1/0,1/0],[-1/0,-1/0,-1/0]);if(!this.aabb){let t=0;const e=new wu([1/0,1/0,1/0],[-1/0,-1/0,-1/0]);for(const i of this.node.meshes)this.node.lightMeshIndex!==t&&(i.transformedAabb=wu.applyTransformFast(i.aabb,this.node.matrix),e.encapsulate(i.transformedAabb)),t++;this.aabb=e}return this.aabb}}class Kx{constructor(t,e,i,n,r,o){this.id=e,this.modelTraits|=Yv.CoordinateSpaceTile,this.uploaded=!1,this.hasPattern=!1,i&&(this.modelTraits|=Yv.HasMapboxMeshFeatures),n&&(this.modelTraits|=Yv.HasMeshoptCompression),this.zoom=-1,this.terrainExaggeration=1,this.projection={name:"mercator"},this.replacementUpdateTime=0,this.elevationReadFromZ=255,this.brightness=r,this.dirty=!0,this.needsUpload=!1,this.nodesInfo=[];for(const e of t)this.nodesInfo.push(new Xx(e)),Wx(e,o.featureIndexArray.length,o.grid),o.featureIndexArray.emplaceBack(this.nodesInfo.length-1,0,o.bucketLayerIDs.length-1,0)}updateFootprints(t,e){for(const i of this.getNodesInfo()){const n=i.node;n.footprint&&e.push({footprint:n.footprint,id:t})}}update(){console.log("Update 3D model bucket")}populate(){console.log("populate 3D model bucket")}uploadPending(){return!this.uploaded||this.needsUpload}upload(t){if(!this.needsUpload)return;const e=this.getNodesInfo();for(const i of e){const e=i.node;this.uploaded?this.updatePbrBuffer(e):Qv(e,t,!0)}for(const t of e)tx(t.node);this.uploaded=!0,this.needsUpload=!1}updatePbrBuffer(t){let e=!1;if(!t.meshes)return e;for(const i of t.meshes)i.pbrBuffer&&(i.pbrBuffer.updateData(i.featureArray),e=!0);return e}needsReEvaluation(t,e,i){const n=t.transform.projectionOptions,r=t.style.getBrightness(),o=this.brightness!==r;return!!(!this.uploaded||this.dirty||n.name!==this.projection.name||Jx(i.paint.get("model-color").value,o)||Jx(i.paint.get("model-color-mix-intensity").value,o)||Jx(i.paint.get("model-roughness").value,o)||Jx(i.paint.get("model-emissive-strength").value,o)||Jx(i.paint.get("model-height-based-emissive-strength-multiplier").value,o))&&(this.projection=n,this.brightness=r,!0)}evaluateScale(t,e){if(t.transform.zoom===this.zoom)return;this.zoom=t.transform.zoom;const i=this.getNodesInfo(),n=this.id.canonical;for(const t of i){const i=t.feature;t.evaluatedScale=e.paint.get("model-scale").evaluate(i,{},n)}}evaluate(t){const e=this.getNodesInfo();for(const i of e){if(!i.node.meshes)continue;const e=i.feature,n=i.node.meshes&&i.node.meshes[0].featureData,r=i.evaluatedColor[2],o=i.evaluatedRMEA[2],s=this.id.canonical;if(i.hasTranslucentParts=!1,n){for(let n=0;n=t)continue;const u=Zx[c],h=Math.abs(u);h>a&&(s=u,a=h,l=r,d=e)}if(a>.1){const o=1-(t+.5*Math.abs(l*d))/c;let a=e._dem.get(n,i)+s*o;const u=e._dem.get(n+l,i+d),h=e._dem.get(n-l,i-d,!0);(a-u)*(a-h)>0&&(a=(u+h)/2),Zx[r]=e._dem.set(n,i,a),qx[r]=t}}}}}s&&(e._demTile.needsDEMTextureUpload=!0,e._dem._timestamp=ki.now())}getNodesInfo(){return this.nodesInfo}destroy(){const t=this.getNodesInfo();for(const e of t)tx(e.node),ex(e.node)}isEmpty(){return!this.nodesInfo.length}updateReplacement(t,e){if(e.updateTime===this.replacementUpdateTime)return;this.replacementUpdateTime=e.updateTime;const i=e.getReplacementRegionsForTile(t.toUnwrapped()),n=this.getNodesInfo();for(let t=0;tt.footprint===e.footprint))}}getHeightAtTileCoord(e,i){const n=this.getNodesInfo(),r=[],o=[0,0,0],s=t.ad.identity([]);for(let a=0;ad.max[0]||i>d.max[1])continue;if(!0===l.node.hidden)return{height:0,maxHeight:l.feature.properties.height,hidden:!1,verticalScale:l.evaluatedScale[2]};t.ad.invert(s,l.node.matrix),o[0]=e,o[1]=i,t._.transformMat4(o,o,s);const u=(o[0]-c.aabb.min[0])/(c.aabb.max[0]-c.aabb.min[0])*Wv|0,h=Math.min(63,(o[1]-c.aabb.min[1])/(c.aabb.max[1]-c.aabb.min[1])*Wv|0)*Wv+Math.min(63,u),p=c.heightmap[h];if(!(p0)return{height:void 0,maxHeight:l.feature.properties.height,hidden:l.hiddenByReplacement,verticalScale:l.evaluatedScale[2]}}}}function Jx(t,e){return!t.isLightConstant&&e}function Qx(t,e,i,n,r,o,s,a){let l=(61440&e|(61440&e)>>4)>>8,c=(3840&e|(3840&e)>>4)>>4,d=240&e|(240&e)>>4;i[3]>0&&(l=Vn(l,255*i[0],i[3]),c=Vn(c,255*i[1],i[3]),d=Vn(d,255*i[2],i[3]));const u=l>16&65535,a=o?e>>16&65535:65535&e,l=(15&a)t.polygon)).flat());const g=f?l:null,[y,v]=function(e,i,n,r,o,s,a,l,c,d,u){return"globe"===e.projection.name?function(e,i,n,r,o,s,a,l,c,d,u){const h=[],p=[],f=e.projection.upVectorScale(u,e.center.lat,e.worldSize).metersToTile,m=[0,0,0,1],_=[0,0,0,1],g=(t,e,i,n)=>{t[0]=e,t[1]=i,t[2]=n,t[3]=1},y=Sf();n>0&&(n+=y),r+=y;for(const y of i){const i=[],v=[];for(const h of y){const p=h.x+o.x,y=h.y+o.y,x=e.projection.projectTilePoint(p,y,u),b=e.projection.upVector(u,h.x,h.y);let w=n,T=r;if(a){const t=Pf(p,y,n,r,a,l,c,d);w+=t.base,T+=t.top}0!==n?g(m,x.x+b[0]*f*w,x.y+b[1]*f*w,x.z+b[2]*f*w):g(m,x.x,x.y,x.z),g(_,x.x+b[0]*f*T,x.y+b[1]*f*T,x.z+b[2]*f*T),t._.transformMat4(m,m,s),t._.transformMat4(_,_,s),i.push(new Tp(m[0],m[1],m[2])),v.push(new Tp(_[0],_[1],_[2]))}h.push(i),p.push(v)}return[h,p]}(e,i,n,r,o,s,a,l,c,d,u):a?function(e,i,n,r,o,s,a,l,c){const d=[],u=[],h=[0,0,0,1];for(const p of e){const e=[],f=[];for(const d of p){const u=d.x+r.x,p=d.y+r.y,m=Pf(u,p,i,n,s,a,l,c);h[0]=u,h[1]=p,h[2]=m.base,h[3]=1,t.aA.transformMat4(h,h,o),h[3]=Math.max(h[3],1e-5);const _=new Tp(h[0]/h[3],h[1]/h[3],h[2]/h[3]);h[0]=u,h[1]=p,h[2]=m.top,h[3]=1,t.aA.transformMat4(h,h,o),h[3]=Math.max(h[3],1e-5);const g=new Tp(h[0]/h[3],h[1]/h[3],h[2]/h[3]);e.push(_),f.push(g)}d.push(e),u.push(f)}return[d,u]}(i,n,r,o,s,a,l,c,d):function(t,e,i,n,r){const o=[],s=[],a=r[8]*e,l=r[9]*e,c=r[10]*e,d=r[11]*e,u=r[8]*i,h=r[9]*i,p=r[10]*i,f=r[11]*i;for(const e of t){const t=[],i=[];for(const o of e){const e=o.x+n.x,s=o.y+n.y,m=r[0]*e+r[4]*s+r[12],_=r[1]*e+r[5]*s+r[13],g=r[2]*e+r[6]*s+r[14],y=r[3]*e+r[7]*s+r[15],v=m+a,x=_+l,b=g+c,w=Math.max(y+d,1e-5),T=m+u,S=_+h,E=g+p,M=Math.max(y+f,1e-5);t.push(new Tp(v/w,x/w,b/w)),i.push(new Tp(T/M,S/M,E/M))}o.push(t),s.push(i)}return[o,s]}(i,n,r,o,s)}(s,r,h,u,d,a,g,p,m,s.center.lat,e.tileID.canonical),x=e.queryGeometry;return function(t,e,i){let n=1/0;Kd(i,e)&&(n=Lf(i,e[0]));for(let r=0;r=3)for(let e=0;e>4;if(1!==n)throw new Error(`Got v${n} data when expected v1.`);const r=nb[15&i];if(!r)throw new Error("Unrecognized array type.");const[o]=new Uint16Array(t,2,1),[s]=new Uint32Array(t,4,1);return new rb(s,o,r,t)}constructor(t,e=64,i=Float64Array,n){if(isNaN(t)||t>1;return this.ids[i]=i,this.coords[this._pos++]=t,this.coords[this._pos++]=e,i}finish(){const t=this._pos>>1;if(t!==this.numItems)throw new Error(`Added ${t} items when expected ${this.numItems}.`);return ob(this.ids,this.coords,this.nodeSize,0,this.numItems-1,0),this._finished=!0,this}range(t,e,i,n){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");const{ids:r,coords:o,nodeSize:s}=this,a=[0,r.length-1,0],l=[];for(;a.length;){const c=a.pop()||0,d=a.pop()||0,u=a.pop()||0;if(d-u=t&&a=e&&c>1,p=o[2*h],f=o[2*h+1];p>=t&&p=e&&f=p:n>=f)&&(a.push(h+1),a.push(d),a.push(1-c))}return l}within(t,e,i){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");const{ids:n,coords:r,nodeSize:o}=this,s=[0,n.length-1,0],a=[],l=i*i;for(;s.length;){const c=s.pop()||0,d=s.pop()||0,u=s.pop()||0;if(d-u>1,p=r[2*h],f=r[2*h+1];cb(p,f,t,e)=p:e+i>=f)&&(s.push(h+1),s.push(d),s.push(1-c))}return a}}function ob(t,e,i,n,r,o){if(r-n>1;sb(t,e,s,n,r,o),ob(t,e,i,n,s-1,1-o),ob(t,e,i,s+1,r,1-o)}function sb(t,e,i,n,r,o){for(;r>n;){if(r-n>600){const s=r-n+1,a=i-n+1,l=Math.log(s),c=.5*Math.exp(2*l/3),d=.5*Math.sqrt(l*c*(s-c)/s)*(a-s/2s&&ab(t,e,n,r);as;)l--}e[2*n+o]===s?ab(t,e,n,l):(l++,ab(t,e,l,r)),lr&&(n+=(t[i]-r)*(t[i]-r)),e[i]0&&n[0]0&&n[1]0&&r[0]0&&r[1]0?Math.acos(i/n)*Ve:0;let o=0!==t||0!==e?Math.atan2(-e,-t)*Ve+90:0;return oNi&&(t.getActor().send("enforceCacheSizeLimit",Fi),Vi=0)},t.an=gn,t.ao=class{constructor(t){this.entries={},this.scheduler=t}request(t,e,i,n){const r=this.entries[t]=this.entries[t]||{callbacks:[]};if(r.result){const[t,i]=r.result;return this.scheduler?this.scheduler.add((()=>{n(t,i)}),e):n(t,i),()=>{}}return r.callbacks.push(n),r.cancel||(r.cancel=i(((i,n)=>{r.result=[i,n];for(const t of r.callbacks)this.scheduler?this.scheduler.add((()=>{t(i,n)}),e):t(i,n);setTimeout((()=>delete this.entries[t]),3e3)}))),()=>{r.result||(r.callbacks=r.callbacks.filter((t=>t!==n)),r.callbacks.length||(r.cancel(),delete this.entries[t]))}}},t.ap=function(t,e,i){const n=JSON.stringify(t.request);return t.data&&(this.deduped.entries[n]={result:[null,t.data]}),this.deduped.request(n,{type:"parseTile",isSymbolTile:t.isSymbolTile,zoom:t.tileZoom},(e=>{const n=en(t.request,((t,n,r,o)=>{t?e(t):n&&e(null,{vectorTile:i?void 0:new bp(new Lm(n)),rawData:n,cacheControl:r,expires:o})}));return()=>{n.cancel(),e()}}),e)},t.aq=Dc,t.ar=class extends Lc{constructor(t){super(t),this.current=Fc}set(t,e,i){if(this.fetchUniformLocation(t,e))for(let t=0;t({u_camera_to_center_distance:new $c(t),u_extrude_scale:new Uc(t),u_device_pixel_ratio:new $c(t),u_matrix:new Bc(t),u_inv_rot_matrix:new Bc(t),u_merc_center:new kc(t),u_tile_id:new Dc(t),u_zoom_transition:new $c(t),u_up_dir:new Dc(t),u_emissive_strength:new $c(t)}),t.bJ=t=>({u_matrix:new Bc(t),u_pixels_to_tile_units:new Uc(t),u_device_pixel_ratio:new $c(t),u_units_to_pixels:new kc(t),u_dash_image:new Pc(t),u_gradient_image:new Pc(t),u_image_height:new $c(t),u_texsize:new kc(t),u_tile_units_to_pixels:new $c(t),u_alpha_discard_threshold:new $c(t),u_trim_offset:new kc(t),u_trim_fade_range:new kc(t),u_trim_color:new zc(t),u_emissive_strength:new $c(t)}),t.bK=t=>({u_matrix:new Bc(t),u_texsize:new kc(t),u_pixels_to_tile_units:new Uc(t),u_device_pixel_ratio:new $c(t),u_image:new Pc(t),u_units_to_pixels:new kc(t),u_tile_units_to_pixels:new $c(t),u_alpha_discard_threshold:new $c(t),u_trim_offset:new kc(t)}),t.bL=Yl,t.bM=Hf,t.bN=Om,t.bO=jm,t.bP=G_,t.bQ=c_,t.bR=th,t.bS=(t,e,i,n,r,o)=>{const s=t.transform,a="globe"===s.projection.name;let l;if("map"===o.paint.get("circle-pitch-alignment"))if(a){const t=Zu(s.zoom,e.canonical)*s._pixelsPerMercatorPixel;l=Float32Array.from([t,0,0,t])}else l=s.calculatePixelsToTileUnitsMatrix(i);else l=new Float32Array([s.pixelsToGLUnits[0],0,0,s.pixelsToGLUnits[1]]);const c={u_camera_to_center_distance:t.transform.getCameraToCenterDistance(s.projection),u_matrix:t.translatePosMatrix(e.projMatrix,i,o.paint.get("circle-translate"),o.paint.get("circle-translate-anchor")),u_device_pixel_ratio:ki.devicePixelRatio,u_extrude_scale:l,u_inv_rot_matrix:Qu,u_merc_center:[0,0],u_tile_id:[0,0,0],u_zoom_transition:0,u_up_dir:[0,0,0],u_emissive_strength:o.paint.get("circle-emissive-strength")};if(a){c.u_inv_rot_matrix=n,c.u_merc_center=r,c.u_tile_id=[e.canonical.x,e.canonical.y,1{const s=t.transform;return{u_matrix:rm(t,e,i,n),u_texsize:e.imageAtlasTexture?e.imageAtlasTexture.size:[0,0],u_pixels_to_tile_units:s.calculatePixelsToTileUnitsMatrix(e),u_device_pixel_ratio:r,u_image:0,u_tile_units_to_pixels:nm(e,s),u_units_to_pixels:[1/s.pixelsToGLUnits[0],1/s.pixelsToGLUnits[1]],u_alpha_discard_threshold:0,u_trim_offset:o}},t.bV=(t,e,i,n,r,o,s)=>{const a=t.transform,l=a.calculatePixelsToTileUnitsMatrix(e);return{u_matrix:rm(t,e,i,n),u_pixels_to_tile_units:l,u_device_pixel_ratio:o,u_units_to_pixels:[1/a.pixelsToGLUnits[0],1/a.pixelsToGLUnits[1]],u_dash_image:0,u_gradient_image:1,u_image_height:r,u_texsize:sm(i)&&e.lineAtlasTexture?e.lineAtlasTexture.size:[0,0],u_tile_units_to_pixels:nm(e,t.transform),u_alpha_discard_threshold:0,u_trim_offset:s,u_trim_fade_range:i.paint.get("line-trim-fade-range"),u_trim_color:i.paint.get("line-trim-color").toRenderColor(i.lut).toArray01(),u_emissive_strength:i.paint.get("line-emissive-strength")}},t.bW=oi,t.bX=mh,t.bY=Sf,t.bZ=bd,t.b_=_f,t.ba=function(t,e,i){const n=Hu(i.zoom),r=t.style.map._antialias,o=e.options.extStandardDerivativesForceOff||t.terrain&&t.terrain.exaggeration()>0;return 0===n&&!r&&!o},t.bb=function(e){const i=e.pixelsPerMeter,n=i/Cd(1,e.center.lat),r=t.ad.identity(new Float64Array(16));return t.ad.translate(r,r,[e.point.x,e.point.y,0]),t.ad.scale(r,r,[n,n,i]),Float32Array.from(r)},t.bc=Ou,t.bd=function(t){const e=Pd-5;t=Xe(t,-e,e)/e*90;const i=Math.pow(Math.abs(Math.sin(Ge(t))),3);return Math.round(i*(sd.length-1))},t.be=function(e,i,n,r){const o=i.getNorth(),s=i.getSouth(),a=i.getWest(),l=i.getEast(),c=10){const e=180/r;t.bC.multiply(f,f,[e/d+1,0,0,0,e/u+1,0,-.5*e/h,.5*e/p,1])}return f[2]=c,f[5]=e.x,f[8]=e.y,f},t.bf=ju,t.bg=$u,t.bh=function(e,i,n){const r=t.ad.identity(new Float64Array(16)),o=(i/(1{}}},t.bo=Gg,t.bp=ai,t.bq=class{isDataAvailableAtPoint(t){const e=this._source();if(this.isUsingMockSource()||!e||t.y1)return!1;const i=e.getSource().maxzoom,n=11)return e;const r=n.getSource().maxzoom,o=1{const s=this.getAtTileOffset(e,o.x,o.y),a=r.upVector(e.canonical,o.x,o.y),l=r.upVectorScale(e.canonical,i,n).metersToTile;return t._.scale(a,a,s*l),a}}getForTilePoints(t,e,i,n){if(this.isUsingMockSource())return!1;const r=Xp.create(this,t,n);return!!r&&(e.forEach((t=>{t[2]=this.exaggeration()*r.getElevationAt(t[0],t[1],i)})),!0)}getMinMaxForTile(t){if(this.isUsingMockSource())return null;const e=this.findDEMTileFor(t);if(!e||!e.dem)return null;const i=e.dem.tree,n=e.tileID,r=1=0?t.slice(0,e):t},t.cV=function(t){return t.indexOf(wl)>=0},t.cW=function(t){const e=t.indexOf(wl);return e>=0?t.slice(e+1):""},t.cX=function(t){const e=[],i=t.id;return void 0===i&&e.push({message:`layers.${i}: missing required property "id"`}),void 0===t.render&&e.push({message:`layers.${i}: missing required method "render"`}),t.renderingMode&&"2d"!==t.renderingMode&&"3d"!==t.renderingMode&&e.push({message:`layers.${i}: property "renderingMode" must be either "2d" or "3d"`}),e},t.cY=function(t,e,i,n){return"custom"===t.type?new vv(t,e):new ib[t.type](t,e,i,n)},t.cZ=di,t.c_=Va,t.ca=1,t.cb=Ag,t.cc=0,t.cd=ec,t.ce=function(t,e,i,n,r){return Xe((t-e)/(i-e)*(r-n)+n,n,r)},t.cf=Ns,t.cg=kd,t.ch=class{constructor(t,e,i,n){this.context=t,this.format=n,this.size=i,this.texture=t.gl.createTexture();const[r,o,s]=this.size,{gl:a}=t;a.bindTexture(a.TEXTURE_3D,this.texture),t.pixelStoreUnpackFlipY.set(!1),t.pixelStoreUnpack.set(1),t.pixelStoreUnpackPremultiplyAlpha.set(!1);let l=this.format,c=a.UNSIGNED_BYTE;this.format===a.DEPTH_COMPONENT&&(l=a.DEPTH_COMPONENT16,c=a.UNSIGNED_SHORT),this.format===a.R8&&(n=a.RED),this.format===a.R32F&&(c=a.FLOAT,n=a.RED),a.texImage3D(a.TEXTURE_3D,0,l,r,o,s,0,n,c,e.data)}bind(t,e){const{context:i}=this,{gl:n}=i;n.bindTexture(n.TEXTURE_3D,this.texture),t!==this.minFilter&&(n.texParameteri(n.TEXTURE_3D,n.TEXTURE_MAG_FILTER,t),n.texParameteri(n.TEXTURE_3D,n.TEXTURE_MIN_FILTER,t),this.minFilter=t),e!==this.wrapS&&(n.texParameteri(n.TEXTURE_3D,n.TEXTURE_WRAP_S,e),n.texParameteri(n.TEXTURE_3D,n.TEXTURE_WRAP_T,e),this.wrapS=e)}destroy(){const{gl:t}=this.context;t.deleteTexture(this.texture),this.texture=null}},t.ci=$v,t.cj=[1,1,1],t.ck=Xp,t.cl=Yv,t.cm=ql,t.cn=ic,t.co=class{constructor(){this._updateTime=0,this._sourceIds=[],this._activeRegions=[],this._prevRegions=[],this._globalClipBounds={min:new Ue(1/0,1/0),max:new Ue(-1/0,-1/0)}}clear(){this._activeRegions.length>0&&++this._updateTime,this._activeRegions=[],this._prevRegions=[]}get updateTime(){return this._updateTime}getReplacementRegionsForTile(t,e=!1){const i=$p(new Ue(0,0),new Ue(uo,uo),t),n=[];if(e&&!Lp(i,this._globalClipBounds))return n;for(const e of this._activeRegions){if(e.hiddenByOverlap)continue;if(!Lp(i,e))continue;const r=kp(e.min,e.max,t);n.push({min:r.min,max:r.max,sourceId:this._sourceIds[e.priority],footprint:e.footprint,footprintTileId:e.tileId,order:e.order,clipMask:e.clipMask})}return n}setSources(t){this._setSources(t.map((t=>({getSourceId:()=>t.cache.id,getFootprints:()=>{const e=[];for(const i of t.cache.getVisibleCoordinates()){const n=t.cache.getTile(i).buckets[t.layer];n&&n.updateFootprints(i.toUnwrapped(),e)}return e},getOrder:()=>t.order,getClipMask:()=>t.clipMask}))))}_addSource(t){const e=t.getFootprints();if(0===e.length)return;const i=t.getOrder(),n=t.getClipMask();for(const t of e){if(!t.footprint)continue;const e=$p(t.footprint.min,t.footprint.max,t.id);this._activeRegions.push({min:e.min,max:e.max,hiddenByOverlap:!1,priority:this._sourceIds.length,tileId:t.id,footprint:t.footprint,order:i,clipMask:n})}this._sourceIds.push(t.getSourceId())}_computeReplacement(){this._activeRegions.sort(((t,e)=>t.priority-e.priority||Ap(t.min,e.min)||Ap(t.max,e.max)));let t=this._activeRegions.length!==this._prevRegions.length;if(!t){let e=0;for(;!t&&e!==this._activeRegions.length;){const i=this._activeRegions[e],n=this._prevRegions[e];t=i.priority!==n.priority||!Ip(i,n)||i.order!==n.order||i.clipMask!==n.clipMask,++e}}if(t){++this._updateTime;for(const t of this._activeRegions)t.order!==1/0&&(this._globalClipBounds.min.x=Math.min(this._globalClipBounds.min.x,t.min.x),this._globalClipBounds.min.y=Math.min(this._globalClipBounds.min.y,t.min.y),this._globalClipBounds.max.x=Math.max(this._globalClipBounds.max.x,t.max.x),this._globalClipBounds.max.y=Math.max(this._globalClipBounds.max.y,t.max.y));const t=t=>{const e=this._activeRegions;if(t>=e.length)return t;const i=e[t].priority;for(;t1){let e=0,i=t(e);for(;e!==i;){let n=e;const r=e;for(;n!==i;){const t=this._activeRegions[n];t.hiddenByOverlap=!1;for(let e=0;e=0;e--)this._addSource(t[e]);this._computeReplacement()}},t.cp=Dl,t.cq=Jg,t.cr=rc,t.cs=class{constructor(t){this._createGrid(t),this._createPoles(t)}destroy(){this._poleIndexBuffer.destroy(),this._gridBuffer.destroy(),this._gridIndexBuffer.destroy(),this._poleNorthVertexBuffer.destroy(),this._poleSouthVertexBuffer.destroy();for(const t of this._poleSegments)t.destroy();for(const t of this._gridSegments)t.withSkirts.destroy(),t.withoutSkirts.destroy()}_fillGridMeshWithLods(t,e){const i=new $l,n=new Kl,r=[],o=t+1+2,s=e[0]+1,a=e[0]+1+(1+e.length),l=(t,e,i)=>{let n=t===o-1?t-2:0===t?t:t-1;return n+=i?24575:0,[n,e]};for(let t=0;tt()))},t.dB=sx,t.dC=yx,t.dD=function(t){px=ki.resolveURL(t),gx||(gx=new ox(ux(),new zn)),gx.broadcast("setDracoUrl",px)},t.dE=vx,t.dF=function(t){mx=ki.resolveURL(t),gx||(gx=new ox(ux(),new zn)),gx.broadcast("setMeshoptUrl",mx)},t.dG=ti,t.dH=ba,t.dI=dh,t.dJ=I_,t.dK=eg,t.dL=dc,t.dM=am,t.dN=Dm,t.dO=Wf,t.dP=ci,t.dQ=E_,t.dR=jg,t.dS=function(t,e,i,n,r,o,s,a,l,c,d){t.createArrays(),t.tilePixelRatio=uo/(512*t.overscaling),t.compareText={},t.iconsNeedLinear=!1;const u=t.layers[0].layout,h=t.layers[0]._unevaluatedLayout._values,p={};if("composite"===t.textSizeData.kind){const{minZoom:e,maxZoom:i}=t.textSizeData;p.compositeTextSizes=[h["text-size"].possiblyEvaluate(new Ha(e),a),h["text-size"].possiblyEvaluate(new Ha(i),a)]}if("composite"===t.iconSizeData.kind){const{minZoom:e,maxZoom:i}=t.iconSizeData;p.compositeIconSizes=[h["icon-size"].possiblyEvaluate(new Ha(e),a),h["icon-size"].possiblyEvaluate(new Ha(i),a)]}p.layoutTextSize=h["text-size"].possiblyEvaluate(new Ha(l+1),a),p.layoutIconSize=h["icon-size"].possiblyEvaluate(new Ha(l+1),a),p.textMaxSize=h["text-size"].possiblyEvaluate(new Ha(18),a);const f="map"===u.get("text-rotation-alignment")&&"point"!==u.get("symbol-placement"),m=u.get("text-size");let _=!1;for(const e of t.features)if(e.icon&&e.icon.nameSecondary){_=!0;break}for(const o of t.features){const l=u.get("text-font").evaluate(o,{},a).join(","),h=m.evaluate(o,{},a),g=p.layoutTextSize.evaluate(o,{},a),y=(p.layoutIconSize.evaluate(o,{},a),{horizontal:{},vertical:void 0}),v=o.text;let x,b=[0,0];if(v){const n=v.toString(),s=u.get("text-letter-spacing").evaluate(o,{},a)*Om,c=u.get("text-line-height").evaluate(o,{},a)*Om,d=Aa(n)?s:0,p=u.get("text-anchor").evaluate(o,{},a),m=u.get("text-variable-anchor");if(!m){const t=u.get("text-radial-offset").evaluate(o,{},a);b=t?G_(p,[t*Om,j_]):u.get("text-offset").evaluate(o,{},a).map((t=>t*Om))}let _=f?"center":u.get("text-justify").evaluate(o,{},a);const x="point"===u.get("symbol-placement"),w=x?u.get("text-max-width").evaluate(o,{},a)*Om:1/0,T=o=>{t.allowVerticalPlacement&&Ca(n)&&(y.vertical=e_(v,e,i,r,l,w,c,p,o,d,b,Jm.vertical,!0,g,h))};if(!f&&m){const t="auto"===_?m.map((t=>Z_(t))):[_];let n=!1;for(let o=0;o=0||!Ca(n)){const t=e_(v,e,i,r,l,w,c,p,_,d,b,Jm.horizontal,!1,g,h);t&&(y.horizontal[_]=t)}T(x?"left":_)}}let w=!1;if(o.icon&&o.icon.namePrimary){const e=n[o.icon.namePrimary];e&&(x=u_(r[o.icon.namePrimary],o.icon.nameSecondary?r[o.icon.nameSecondary]:void 0,u.get("icon-offset").evaluate(o,{},a),u.get("icon-anchor").evaluate(o,{},a)),w=e.sdf,void 0===t.sdfIcons?t.sdfIcons=e.sdf:t.sdfIcons!==e.sdf&&pi("Style sheet warning: Cannot mix SDF and non-SDF icons in one buffer"),(e.pixelRatio!==t.pixelRatio||0!==u.get("icon-rotate").constantOr(1))&&(t.iconsNeedLinear=!0))}const T=X_(y.horizontal)||y.vertical;t.iconsInText||(t.iconsInText=!!T&&T.iconsInText),(T||x)&&q_(t,o,y,x,n,p,g,0,b,w,s,a,c,d,_)}o&&t.generateCollisionDebugBuffers(l,t.collisionBoxArray)},t.dT=Jf,t.dU=Yh,t.dV=bp,t.dW=Lm,t.dX=Yp,t.dY=Zy,t.dZ=wp,t.d_=cp,t.da=Wu,t.db=function(e){const i=[0,0,0],n=t.ad.identity(new Float64Array(16));return t.ad.multiply(n,e.pixelMatrix,e.globeMatrix),t._.transformMat4(i,i,n),new Ue(i[0],i[1])},t.dc=d,t.dd=c,t.de=function(t){const e=t.navigator?t.navigator.userAgent:null;return!!function(t){if(null==Ei){const e=t.navigator?t.navigator.userAgent:null;Ei=!!t.safari||!(!e||!(/\b(iPad|iPhone|iPod)\b/.test(e)||e.match("Safari")&&!e.match("Chrome")))}return Ei}(t)&&e&&(e.match("Version/15.4")||e.match("Version/15.5")||e.match(/CPU (OS|iPhone OS) (15_4|15_5) like Mac OS X/))},t.df=ni,t.dg=class{constructor(t,e,i){this._transformRequestFn=t,this._customAccessToken=e,this._silenceAuthErrors=!!i,this._createSkuToken()}_createSkuToken(){const t=function(){let t="";for(let e=0;ethis._skuTokenExpiresAt}transformRequest(t,e){return this._transformRequestFn&&this._transformRequestFn(t,e)||{url:t}}normalizeStyleURL(t,i){if(!o(t))return t;const n=un(t);return n.params.push(`sdk=js-${e}`),n.path=`/styles/v1${n.path}`,this._makeAPIURL(n,this._customAccessToken||i)}normalizeGlyphsURL(t,e){if(!o(t))return t;const i=un(t);return i.path=`/fonts/v1${i.path}`,this._makeAPIURL(i,this._customAccessToken||e)}normalizeModelURL(t,e){if(!o(t))return t;const i=un(t);return i.path=`/models/v1${i.path}`,this._makeAPIURL(i,this._customAccessToken||e)}normalizeSourceURL(t,e,i,n){if(!o(t))return t;const r=un(t);return r.path=`/v4/${r.authority}.json`,r.params.push("secure"),i&&r.params.push(`language=${i}`),n&&r.params.push(`worldview=${n}`),this._makeAPIURL(r,this._customAccessToken||e)}normalizeSpriteURL(t,e,i,n){const r=un(t);return o(t)?(r.path=`/styles/v1${r.path}/sprite${e}${i}`,this._makeAPIURL(r,this._customAccessToken||n)):(r.path+=`${e}${i}`,hn(r))}normalizeTileURL(t,e,i){if(this._isSkuTokenExpired()&&this._createSkuToken(),t&&!o(t))return t;const r=un(t);r.path=r.path.replace(/(\.(png|jpg)\d*)(?=$)/,`${e||i&&"raster"!==r.authority&&512===i?"@2x":""}${Gi.supported?".webp":"$1"}`),"raster"===r.authority?r.path=`/${n.RASTER_URL_PREFIX}${r.path}`:"rasterarrays"===r.authority?r.path=`/${n.RASTERARRAYS_URL_PREFIX}${r.path}`:"3dtiles"===r.authority?r.path=`/${n.TILES3D_URL_PREFIX}${r.path}`:(r.path=r.path.replace(/^.+\/v4\//,"/"),r.path=`/${n.TILE_URL_VERSION}${r.path}`);const s=this._customAccessToken||function(t){for(const e of t){const t=e.match(/^access_token=(.*)$/);if(t)return t[1]}return null}(r.params)||n.ACCESS_TOKEN;return n.REQUIRE_ACCESS_TOKEN&&s&&this._skuToken&&r.params.push(`sku=${this._skuToken}`),this._makeAPIURL(r,s)}canonicalizeTileURL(t,e){const i=un(t);if(!i.path.match(/^(\/v4\/|\/(raster|rasterarrays)\/v1\/)/)||!i.path.match(/\.[\w]+$/))return t;let r="mapbox://";i.path.match(/^\/raster\/v1\//)?r+=`raster/${i.path.replace(`/${n.RASTER_URL_PREFIX}/`,"")}`:i.path.match(/^\/rasterarrays\/v1\//)?r+=`rasterarrays/${i.path.replace(`/${n.RASTERARRAYS_URL_PREFIX}/`,"")}`:r+=`tiles/${i.path.replace(`/${n.TILE_URL_VERSION}/`,"")}`;let o=i.params;return e&&(o=o.filter((t=>!t.match(/^access_token=/)))),o.length&&(r+=`?${o.join("&")}`),r}canonicalizeTileset(t,e){const i=!!e&&o(e),n=[];for(const e of t.tiles||[])r(e)?n.push(this.canonicalizeTileURL(e,i)):n.push(e);return n}_makeAPIURL(t,e){const i="See https://docs.mapbox.com/api/overview/#access-tokens-and-token-scopes",r=un(n.API_URL);if(t.protocol=r.protocol,t.authority=r.authority,"http"===t.protocol){const e=t.params.indexOf("secure");e>=0&&t.params.splice(e,1)}if("/"!==r.path&&(t.path=`${r.path}${t.path}`),!n.REQUIRE_ACCESS_TOKEN)return hn(t);if(e=e||n.ACCESS_TOKEN,!this._silenceAuthErrors){if(!e)throw new Error(`An API access token is required to use Mapbox GL. ${i}`);if("s"===e[0])throw new Error(`Use a public access token (pk.*) with Mapbox GL, not a secret access token (sk.*). ${i}`)}return t.params=t.params.filter((t=>-1===t.indexOf("access_token"))),t.params.push(`access_token=${e||""}`),hn(t)}},t.dh=function(t,e){e?Mn.add(t):Mn.delete(t)},t.di=Gi,t.dj=Tn,t.dk=En,t.dl=cn,t.dm=vn,t.dn=bn,t.dp=function(t){Mn.delete(t)},t.dq=Sn,t.dr=yn,t.ds=Qe,t.dt=e,t.du=function(t,e){Fi=t,Ni=e},t.dv=function(t,e,i=!1){if(Fa===za||Fa===Ra||Fa===Oa)throw new Error("setRTLTextPlugin cannot be called multiple times.");Na=ki.resolveURL(t),Fa=za,Ba=e,ja(),i||Za()},t.dw=Ga,t.dx=function(){ux().acquire(lx)},t.dy=function(){const t=dx;t&&(t.isPreloaded()&&1===t.numActive()?(t.release(lx),dx=null):console.warn("Could not clear WebWorkers since there are active Map instances that still reference it. The pre-warmed WebWorker pool can only be cleared when all map instances have been removed with map.remove()"))},t.dz=cx,t.e=ki,t.e0=cm,t.e1=h,t.e2=en,t.e3=function(t){let e=0;if(new Uint32Array(t,0,1)[0]!==Ax){const i=new Uint32Array(t,0,7),[,,n,r,o,s]=i;e=i.byteLength+r+o+s+o,(n!==t.byteLength||e>=t.byteLength)&&pi("Invalid b3dm header information.")}return Dx(t,e)},t.e4=function(t,e){const i=jx(t);for(const t of i){for(const e of t.meshes)Vx(e);t.lights&&(t.lightMeshIndex=t.meshes.length,t.meshes.push(Gx(t.lights,e)))}return i},t.e5=Kx,t.e6=rx,t.e7=qa,t.e8=function(t){ji(),Oi&&Oi.then((e=>{e.keys().then((i=>{for(let n=0;nt.arrayBuffer())).then((e=>Dx(e,0,t)))},t.m=class extends Uv{},t.n=Er,t.o=qn,t.p=Qg,t.q=Xs,t.r=Js,t.s=Qs,t.t=ca,t.u=al,t.v=ll,t.w=pi,t.x=pa,t.y=da,t.z=qo})),n(0,(function(t){function e(t){const e=t?t.url.toString():void 0;return e?performance.getEntriesByName(e):[]}function i(t){if("number"==typeof t||"boolean"==typeof t||"string"==typeof t||null==t)return JSON.stringify(t);if(Array.isArray(t)){let e="[";for(const n of t)e+=`${i(n)},`;return`${e}]`}let e="{";for(const n of Object.keys(t).sort())e+=`${n}:${i(t[n])},`;return`${e}}`}function n(e){let n="";for(const r of t.cE)n+=`/${i(e[r])}`;return n}class r{constructor(t){this.keyCache={},this._layers={},this._layerConfigs={},t&&this.replace(t)}replace(t,e){this._layerConfigs={},this._layers={},this.update(t,[],e)}update(e,i,r){this._options=r;for(const i of e)this._layerConfigs[i.id]=i,(this._layers[i.id]=t.cY(i,this.scope,null,this._options)).compileFilter(),this.keyCache[i.id]&&delete this.keyCache[i.id];for(const t of i)delete this.keyCache[t],delete this._layerConfigs[t],delete this._layers[t];this.familiesBySource={};const o=function(t,e){const i={};for(let r=0;rthis._layers[t.id])),i=e[0];if("none"===i.visibility)continue;const n=i.source||"";let r=this.familiesBySource[n];r||(r=this.familiesBySource[n]={});const o=i.sourceLayer||"_geojsonTileLayer";let s=r[o];s||(s=r[o]=[]),s.push(e)}}}const o=1*t.dJ;class s{constructor(e){const i={},n=[];for(const t in e){const r=e[t],s=i[t]={};for(const t in r.glyphs){const e=r.glyphs[+t];if(!e||0===e.bitmap.width||0===e.bitmap.height)continue;const i=e.metrics.localGlyph?o:1,a={x:0,y:0,w:e.bitmap.width+2*i,h:e.bitmap.height+2*i};n.push(a),s[t]=a}}const{w:r,h:s}=t.j(n),a=new t.dI({width:r||1,height:s||1});for(const n in e){const r=e[n];for(const e in r.glyphs){const s=r.glyphs[+e];if(!s||0===s.bitmap.width||0===s.bitmap.height)continue;const l=i[n][e],c=s.metrics.localGlyph?o:1;t.dI.copy(s.bitmap,a,{x:0,y:0},{x:l.x+c,y:l.y+c},s.bitmap)}}this.image=a,this.positions=i}}t.dH(s,"GlyphAtlas");class a{constructor(e){this.tileID=new t.aL(e.tileID.overscaledZ,e.tileID.wrap,e.tileID.canonical.z,e.tileID.canonical.x,e.tileID.canonical.y),this.tileZoom=e.tileZoom,this.uid=e.uid,this.zoom=e.zoom,this.lut=e.lut,this.canonical=e.tileID.canonical,this.pixelRatio=e.pixelRatio,this.tileSize=e.tileSize,this.source=e.source,this.scope=e.scope,this.overscaling=this.tileID.overscaleFactor(),this.showCollisionBoxes=e.showCollisionBoxes,this.collectResourceTiming=!!e.collectResourceTiming,this.promoteId=e.promoteId,this.isSymbolTile=e.isSymbolTile,this.tileTransform=t.dK(e.tileID.canonical,e.projection),this.projection=e.projection,this.brightness=e.brightness,this.extraShadowCaster=!!e.extraShadowCaster,this.tessellationStep=e.tessellationStep}parse(e,i,n,r,o){this.status="parsing",this.data=e,this.collisionBoxArray=new t.dL;const a=new t.dM(Object.keys(e.layers).sort()),c=new t.dN(this.tileID,this.promoteId);c.bucketLayerIDs=[];const d={},u=new t.dO(256,256),h={featureIndex:c,iconDependencies:{},patternDependencies:{},glyphDependencies:{},lineAtlas:u,availableImages:n,brightness:this.brightness},p=i.familiesBySource[this.source];for(const i in p){const r=e.layers[i];if(!r)continue;let o=!1,s=!1,u=!1;for(const t of p[i])"symbol"===t[0].type?o=!0:s=!0,t[0].is3D()&&"model"!==t[0].type&&(u=!0);if(this.extraShadowCaster&&!u)continue;if(!0===this.isSymbolTile&&!o)continue;if(!1===this.isSymbolTile&&!s)continue;1===r.version&&t.w(`Vector tile source "${this.source}" layer "${i}" does not use vector tile spec v2 and therefore may have some rendering errors.`);const f=a.encode(i),m=[];for(let t=0;t=e.maxzoom||"none"!==e.visibility&&(l(t,this.zoom,h.brightness,n),(d[e.id]=e.createBucket({index:c.bucketLayerIDs.length,layers:t,zoom:this.zoom,lut:this.lut,canonical:this.canonical,pixelRatio:this.pixelRatio,overscaling:this.overscaling,collisionBoxArray:this.collisionBoxArray,sourceLayerIndex:f,sourceID:this.source,projection:this.projection.spec,tessellationStep:this.tessellationStep})).populate(m,h,this.tileID.canonical,this.tileTransform),c.bucketLayerIDs.push(t.map((t=>t.id)))))}}let f,m,_,g;u.trim();const y={type:"maybePrepare",isSymbolTile:this.isSymbolTile,zoom:this.zoom},v=()=>{if(f)return this.status="done",o(f);if(this.extraShadowCaster)this.status="done",o(null,{buckets:t.dG(d).filter((t=>!t.isEmpty())),featureIndex:c,collisionBoxArray:null,glyphAtlasImage:null,lineAtlas:null,imageAtlas:null,brightness:h.brightness,glyphMap:null,iconMap:null,glyphPositions:null});else if(m&&_&&g){const e=new s(m),i=new t.dQ(_,g,this.lut);for(const r in d){const o=d[r];o instanceof t.dR?(l(o.layers,this.zoom,h.brightness,n),t.dS(o,m,e.positions,_,i.iconPositions,this.showCollisionBoxes,n,this.tileID.canonical,this.tileZoom,this.projection,this.brightness)):o.hasPattern&&(o instanceof t.dT||o instanceof t.dU||o instanceof t.b_)&&(l(o.layers,this.zoom,h.brightness,n),o.addFeatures(h,this.tileID.canonical,i.patternPositions,n,this.tileTransform,this.brightness))}this.status="done",o(null,{buckets:t.dG(d).filter((t=>!t.isEmpty())),featureIndex:c,collisionBoxArray:this.collisionBoxArray,glyphAtlasImage:e.image,lineAtlas:u,imageAtlas:i,brightness:h.brightness})}};if(!this.extraShadowCaster){const e=t.dP(h.glyphDependencies,(t=>Object.keys(t).map(Number)));Object.keys(e).length?r.send("getGlyphs",{uid:this.uid,stacks:e,scope:this.scope},((t,e)=>{f||(f=t,m=e,v())}),void 0,!1,y):m={};const i=Object.keys(h.iconDependencies);i.length?r.send("getImages",{icons:i,source:this.source,scope:this.scope,tileID:this.tileID,type:"icons"},((t,e)=>{f||(f=t,_=e,v())}),void 0,!1,y):_={};const n=Object.keys(h.patternDependencies);n.length?r.send("getImages",{icons:n,source:this.source,scope:this.scope,tileID:this.tileID,type:"patterns"},((t,e)=>{f||(f=t,g=e,v())}),void 0,!1,y):g={}}v()}}function l(e,i,n,r){const o=new t.X(i,{brightness:n});for(const t of e)t.recalculate(o,r)}class c extends t.E{constructor(e,i,n,r,o,s){super(),this.actor=e,this.layerIndex=i,this.availableImages=n,this.loadVectorData=o||t.ap,this.loading={},this.loaded={},this.deduped=new t.ao(e.scheduler),this.isSpriteLoaded=r,this.scheduler=e.scheduler,this.brightness=s}loadTile(i,n){const r=i.uid,o=i&&i.request,s=o&&o.collectResourceTiming,l=this.loading[r]=new a(i);l.abort=this.loadVectorData(i,((a,c)=>{const d=!this.loading[r];if(delete this.loading[r],d||a||!c)return l.status="done",d||(this.loaded[r]=l),n(a);const u=c.rawData,h={};c.expires&&(h.expires=c.expires),c.cacheControl&&(h.cacheControl=c.cacheControl),l.vectorTile=c.vectorTile||new t.dV(new t.dW(u));const p=()=>{l.parse(l.vectorTile,this.layerIndex,this.availableImages,this.actor,((i,r)=>{if(i||!r)return n(i);const a={};if(s){const t=e(o);t.length>0&&(a.resourceTiming=JSON.parse(JSON.stringify(t)))}n(null,t.W({rawTileData:u.slice(0)},r,h,a))}))};this.isSpriteLoaded?p():this.once("isSpriteLoaded",(()=>{this.scheduler?this.scheduler.add(p,{type:"parseTile",isSymbolTile:i.isSymbolTile,zoom:i.tileZoom}):p()})),this.loaded=this.loaded||{},this.loaded[r]=l}))}reloadTile(e,i){const n=this.loaded,r=e.uid;if(n&&n[r]){const o=n[r];o.showCollisionBoxes=e.showCollisionBoxes,o.projection=e.projection,o.brightness=e.brightness,o.tileTransform=t.dK(e.tileID.canonical,e.projection),o.extraShadowCaster=e.extraShadowCaster,o.lut=e.lut;const s=(t,e)=>{const n=o.reloadCallback;n&&(delete o.reloadCallback,o.parse(o.vectorTile,this.layerIndex,this.availableImages,this.actor,n)),i(t,e)};"parsing"===o.status?o.reloadCallback=s:"done"===o.status&&(o.vectorTile?o.parse(o.vectorTile,this.layerIndex,this.availableImages,this.actor,s):s())}else i(null,void 0)}abortTile(t,e){const i=t.uid,n=this.loading[i];n&&(n.abort&&n.abort(),delete this.loading[i]),e()}removeTile(t,e){const i=this.loaded,n=t.uid;i&&i[n]&&delete i[n],e()}}class d{loadTile(e,i){const{uid:n,encoding:r,rawImageData:o,padding:s}=e,a=ImageBitmap&&o instanceof ImageBitmap?this.getImageData(o,s):o;i(null,new t.dX(n,a,r,s{n(null,t)}),(t=>{n(t)}))}}const h=t.dZ.prototype.toGeoJSON;let p=class{constructor(e){this._feature=e,this.extent=t.a3,this.type=e.type,this.properties=e.tags,"id"in e&&!isNaN(e.id)&&(this.id=parseInt(e.id,10))}loadGeometry(){if(1===this._feature.type){const e=[];for(const i of this._feature.geometry)e.push([new t.P(i[0],i[1])]);return e}{const e=[];for(const i of this._feature.geometry){const n=[];for(const e of i)n.push(new t.P(e[0],e[1]));e.push(n)}return e}}toGeoJSON(t,e,i){return h.call(this,t,e,i)}},f=class{constructor(e){this.layers={_geojsonTileLayer:this},this.name="_geojsonTileLayer",this.extent=t.a3,this.length=e.length,this._features=e}feature(t){return new p(this._features[t])}};const m=64/4096;class _{constructor(){this.features=new Map}clear(){this.features.clear()}load(t=[],e){for(const i of t){const t=i.id;if(null==t)continue;let n=this.features.get(t);n&&this.updateCache(n,e),i.geometry?(n=y(i),this.updateCache(n,e),this.features.set(t,n)):this.features.delete(t),this.updateCache(n,e)}}updateCache(t,e){for(const{canonical:i,uid:n}of Object.values(e)){const{z:r,x:o,y:s}=i;g(t,Math.pow(2,r),o,s)&&delete e[n]}}getTile(t,e,i){const n=Math.pow(2,t),r=[];for(const t of this.features.values())g(t,n,e,i)&&r.push(w(t,n,e,i));return{features:r}}getFeatures(){return[...this.features.values()]}}function g({minX:t,minY:e,maxX:i,maxY:n},r,o,s){return t(o-m)/r&&n>(s-m)/r}function y(t){const{id:e,geometry:i,properties:n}=t;if(!i)return;if("GeometryCollection"===i.type)throw new Error("GeometryCollection not supported in dynamic mode.");const{type:r,coordinates:o}=i,s={id:e,type:1,geometry:[],tags:n,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0},a=s.geometry;if("Point"===r)v(o,a,s);else if("MultiPoint"===r)for(const t of o)v(t,a,s);else if("LineString"===r)s.type=2,x(o,a,s);else if("MultiLineString"===r)s.type=2,b(o,a,s);else if("Polygon"===r)s.type=3,b(o,a,s,!0);else{if("MultiPolygon"!==r)throw new Error("Input data is not a valid GeoJSON object.");s.type=3;for(const t of o)b(t,a,s,!0)}return s}function v([e,i],n,r){const o=t.aj(e);let s=t.ak(i);s=s1?1:s,n.push(o,s),r.minX=Math.min(r.minX,o),r.minY=Math.min(r.minY,s),r.maxX=Math.max(r.maxX,o),r.maxY=Math.max(r.maxY,s)}function x(t,e,i,n=!1,r=!1){const o=[];for(const e of t)v(e,o,i);e.push(o),n&&function(t,e){let i=0;for(let e=0,n=t.length,r=n-2;e0===e)for(let e=0,i=t.length;e>31}function F(t,e){for(var i=t.loadGeometry(),n=t.type,r=0,o=0,s=i.length,a=0;at},V=Math.fround||(G=new Float32Array(1),t=>(G[0]=+t,G[0]));var G;const Z=3,q=5,H=6;class W{constructor(t){this.options=Object.assign(Object.create(j),t),this.trees=new Array(this.options.maxZoom+1),this.stride=this.options.reduce?7:6,this.clusterProps=[]}load(t){const{log:e,minZoom:i,maxZoom:n}=this.options;e&&console.time("total time");const r=`prepare ${t.length} points`;e&&console.time(r),this.points=t;const o=[];for(let e=0;e=i;t--){const i=+Date.now();s=this.trees[t]=this._createTree(this._cluster(s,t)),e&&console.log("z%d: %d clusters in %dms",t,s.numItems,+Date.now()-i)}return e&&console.timeEnd("total time"),this}getClusters(t,e){let i=((t[0]+180)%360+360)%360-180;const n=Math.max(-90,Math.min(90,t[1]));let r=180===t[2]?180:((t[2]+180)%360+360)%360-180;const o=Math.max(-90,Math.min(90,t[3]));if(t[2]-t[0]>=360)i=-180,r=180;else if(i>r){const t=this.getClusters([i,n,180,o],e),s=this.getClusters([-180,n,r,o],e);return t.concat(s)}const s=this.trees[this._limitZoom(e)],a=s.range(K(i),J(o),K(r),J(n)),l=s.data,c=[];for(const t of a){const e=this.stride*t;c.push(l[e+q]>1?Y(l,e,this.clusterProps):this.points[l[e+Z]])}return c}getChildren(t){const e=this._getOriginId(t),i=this._getOriginZoom(t),n="No cluster with the specified id.",r=this.trees[i];if(!r)throw new Error(n);const o=r.data;if(e*this.stride>=o.length)throw new Error(n);const s=this.options.radius/(this.options.extent*Math.pow(2,i-1)),a=r.within(o[e*this.stride],o[e*this.stride+1],s),l=[];for(const e of a){const i=e*this.stride;o[i+4]===t&&l.push(o[i+q]>1?Y(o,i,this.clusterProps):this.points[o[i+Z]])}if(0===l.length)throw new Error(n);return l}getLeaves(t,e,i){const n=[];return this._appendLeaves(n,t,e=e||10,i=i||0,0),n}getTile(t,e,i){const n=this.trees[this._limitZoom(t)],r=Math.pow(2,t),{extent:o,radius:s}=this.options,a=s/o,l=(i-a)/r,c=(i+1+a)/r,d={features:[]};return this._addTileFeatures(n.range((e-a)/r,l,(e+1+a)/r,c),n.data,e,i,r,d),0===e&&this._addTileFeatures(n.range(1-a/r,l,1,c),n.data,r,i,r,d),e===r-1&&this._addTileFeatures(n.range(0,l,a/r,c),n.data,-1,i,r,d),d.features.length?d:null}getClusterExpansionZoom(t){let e=this._getOriginZoom(t)-1;for(;e1;let l,c,d;if(a)l=X(e,t,this.clusterProps),c=e[t],d=e[t+1];else{const i=this.points[e[t+Z]];l=i.properties;const[n,r]=i.geometry.coordinates;c=K(n),d=J(r)}const u={type:1,geometry:[[Math.round(this.options.extent*(c*r-i)),Math.round(this.options.extent*(d*r-n))]],tags:l};let h;h=a||this.options.generateId?e[t+Z]:this.points[e[t+Z]].id,void 0!==h&&(u.id=h),o.features.push(u)}}_limitZoom(t){return Math.max(this.options.minZoom,Math.min(Math.floor(+t),this.options.maxZoom+1))}_cluster(t,e){const{radius:i,extent:n,reduce:r,minPoints:o}=this.options,s=i/(n*Math.pow(2,e)),a=t.data,l=[],c=this.stride;for(let i=0;ie&&(p+=a[i+q])}if(p>h&&p>=o){let t,o=n*h,s=d*h,f=-1;const m=(i/c1)for(const t of u){const i=t*c;if(!(a[i+2]>5}_getOriginZoom(t){return(t-this.points.length)%32}_map(t,e,i){if(t[e+q]>1){const n=this.clusterProps[t[e+H]];return i?Object.assign({},n):n}const n=this.points[t[e+Z]].properties,r=this.options.map(n);return i&&r===n?Object.assign({},r):r}}function Y(t,e,i){return{type:"Feature",id:t[e+Z],properties:X(t,e,i),geometry:{type:"Point",coordinates:[(n=t[e],360*(n-.5)),Q(t[e+1])]}};var n}function X(t,e,i){const n=t[e+q],r=n>=1e4?`${Math.round(n/1e3)}k`:n>=1e3?Math.round(n/100)/10+"k":n,o=t[e+H],s=-1===o?{}:Object.assign({},i[o]);return Object.assign(s,{cluster:!0,cluster_id:t[e+Z],point_count:n,point_count_abbreviated:r})}function K(t){return t/360+.5}function J(t){const e=Math.sin(t*Math.PI/180),i=.5-.25*Math.log((1+e)/(1-e))/Math.PI;return i1?1:i}function Q(t){const e=(180-360*t)*Math.PI/180;return 360*Math.atan(Math.exp(e))/Math.PI-90}function tt(t,e,i,n){let r=n;const o=e+(i-e>>1);let s,a=i-e;const l=t[e],c=t[e+1],d=t[i],u=t[i+1];for(let n=e+3;n v&&(x(t,c,n,r,a,l),x(c,i,a,l,o,s))}x(u,h,n,o,r,o),x(h,p,r,o,r,s),x(p,f,r,s,n,s),x(f,u,n,s,n,o),m-=v,_-=v,g+=v,y+=v;const b=1/Math.max(g-m,y-_);return{scale:b,x:m*b,y:_*b,x2:g*b,y2:y*b,projection:e}}function ig(t,{x:e,y:i},n=0){return new Ue(((e-n)*t.scale-t.x)*uo,(i*t.scale-t.y)*uo)}const ng=t.ad.identity(new Float32Array(16));class rg{constructor(t){this.spec=t,this.name=t.name,this.wrap=!1,this.requiresDraping=!1,this.supportsWorldCopies=!1,this.supportsTerrain=!1,this.supportsFog=!1,this.supportsFreeCamera=!1,this.zAxisUnit="meters",this.isReprojectedInTileSpace=!0,this.unsupportedLayers=["custom"],this.center=[0,0],this.range=[3.5,7]}project(t,e){return{x:0,y:0,z:0}}unproject(t,e){return new pd(0,0)}projectTilePoint(t,e,i){return{x:t,y:e,z:0}}locationPoint(t,e,i=!0){return t._coordinatePoint(t.locationCoordinate(e),i)}pixelsPerMeter(t,e){return Cd(1,t)*e}pixelSpaceConversion(t,e,i){return 1}farthestPixelDistance(t){return tg(t,t.pixelsPerMeter)}pointCoordinate(t,e,i,n){const r=t.horizonLineFromTop(!1),o=new Ue(e,Math.max(r,i));return t.rayIntersectionCoordinate(t.pointRayIntersection(o,n))}pointCoordinate3D(t,e,i){const n=new Ue(e,i);if(t.elevation)return t.elevation.pointCoordinate(n);{const e=this.pointCoordinate(t,n.x,n.y,0);return[e.x,e.y,e.z]}}isPointAboveHorizon(t,e){if(t.elevation&&t.elevation.visibleDemTiles.length)return!this.pointCoordinate3D(t,e.x,e.y);const i=t.horizonLineFromTop();return e.y0?epg-i&&(e=pg-i);const o=r/Math.pow(fg(e),n);let s=o*Math.sin(n*t),a=r-o*Math.cos(n*t);return s=.5*(s/Math.PI+.5),a=.5*(a/Math.PI+.5),{x:s,y:this.southernCenter?a:1-a,z:0}}unproject(t,e){t=(2*t-.5)*Math.PI,this.southernCenter&&(e=1-e),e=(2*(1-e)-.5)*Math.PI;const{n:i,f:n}=this,r=n-e,o=Math.sign(r),s=Math.sign(i)*Math.sqrt(t*t+r*r);let a=Math.atan2(t,Math.abs(r))*o;r*i1e-6&&--n>0);o=i*i;const s=Xe(Ze(t/(.8707+o*(o*(o*o*o*(.003971-.001529*o)-.013791)-.131979))),-180,180),a=Ze(i);return new pd(s,a)}}const vg=Ge(Pd);class xg extends rg{project(t,e){e=Ge(e),t=Ge(t);const i=Math.cos(e),n=2/Math.PI,r=Math.acos(i*Math.cos(t/2)),o=Math.sin(r)/r,s=.5*(t*n+2*i*Math.sin(t/2)/o)||0,a=.5*(e+Math.sin(e)/o)||0;return{x:.5*(s/Math.PI+.5),y:1-.5*(a/Math.PI+1),z:0}}unproject(t,e){let i=t=(2*t-.5)*Math.PI,n=e=(2*(1-e)-1)*Math.PI,r=25;const o=1e-6;let s=0,a=0;do{const r=Math.cos(n),o=Math.sin(n),l=2*o*r,c=o*o,d=r*r,u=Math.cos(i/2),h=Math.sin(i/2),p=2*u*h,f=h*h,m=1-d*u*u,_=m?1/m:0,g=m?Math.acos(r*u)*Math.sqrt(1/m):0,y=.5*(2*g*r*h+2*i/Math.PI)-t,v=.5*(g*o+n)-e,x=.5*_*(d*f+g*r*u*c)+1/Math.PI,b=_*(p*l/4-g*o*h),w=.125*_*(l*h-g*o*d*p),T=.5*_*(c*u+g*f*r)+.5,S=b*w-T*x;s=(v*b-y*T)/S,a=(y*w-v*x)/S,i=Xe(i-s,-Math.PI,Math.PI),n=Xe(n-a,-vg,vg)}while((Math.abs(s)>o||Math.abs(a)>o)&&--r>0);return new pd(Ze(i),Ze(n))}}class bg extends rg{constructor(t){super(t),this.center=t.center||[0,0],this.parallels=t.parallels||[0,0],this.cosPhi=Math.max(.01,Math.cos(Ge(this.parallels[0]))),this.scale=1/(2*Math.max(Math.PI*this.cosPhi,1/this.cosPhi)),this.wrap=!0,this.supportsWorldCopies=!0}project(t,e){const{scale:i,cosPhi:n}=this;return{x:Ge(t)*n*i+.5,y:-Math.sin(Ge(e))/n*i+.5,z:0}}unproject(t,e){const{scale:i,cosPhi:n}=this,r=-(e-.5)/i,o=Xe(Ze((t-.5)/i)/n,-180,180),s=Math.asin(Xe(r*n,-1,1)),a=Xe(Ze(s),-Pd,Pd);return new pd(o,a)}}class wg extends _g{constructor(t){super(t),this.requiresDraping=!0,this.supportsWorldCopies=!1,this.supportsFog=!0,this.zAxisUnit="pixels",this.unsupportedLayers=["debug"],this.range=[3,5]}projectTilePoint(e,i,n){const r=Fu(e,i,n),o=ju($u(n));return t._.transformMat4(r,r,o),{x:r[0],y:r[1],z:r[2]}}locationPoint(e,i){const n=dd(i.lat,i.lng),r=t._.normalize([],n),o=e.elevation?e.elevation.getAtPointOrZero(e.locationCoordinate(i),e._centerAltitude):e._centerAltitude,s=Cd(1,0)*uo*o;t._.scaleAndAdd(n,n,r,s);const a=t.ad.identity(new Float64Array(16));return t.ad.multiply(a,e.pixelMatrix,e.globeMatrix),t._.transformMat4(n,n,a),new Ue(n[0],n[1])}pixelsPerMeter(t,e){return Cd(1,0)*e}pixelSpaceConversion(t,e,i){const n=Cd(1,t)*e,r=Vn(Cd(1,45)*e,n,i);return this.pixelsPerMeter(t,e)/r}createTileMatrix(e,i,n){const r=Vu($u(n.canonical));return t.ad.multiply(new Float64Array(16),e.globeMatrix,r)}createInversionMatrix(e,i){const{center:n}=e,r=ju($u(i));return t.ad.rotateY(r,r,Ge(n.lng)),t.ad.rotateX(r,r,Ge(n.lat)),t.ad.scale(r,r,[e._pixelsPerMercatorPixel,e._pixelsPerMercatorPixel,1]),Float32Array.from(r)}pointCoordinate(t,e,i,n){return Iu(t,e,i,!0)||new Rd(0,0)}pointCoordinate3D(t,e,i){const n=this.pointCoordinate(t,e,i,0);return[n.x,n.y,n.z]}isPointAboveHorizon(t,e){return!Iu(t,e.x,e.y,!1)}farthestPixelDistance(e){const i=function(e,i){const n=e.cameraToCenterDistance,r=e._centerAltitude*i,o=e._camera,s=e._camera.forward(),a=t._.add([],t._.scale([],s,-n),[0,0,r]),l=e.worldSize/(2*Math.PI),c=[0,0,-l],d=e.width/e.height,u=Math.tan(e.fovAboveCenter),h=t._.scale([],o.up(),u),p=t._.scale([],o.right(),u*d),f=t._.normalize([],t._.add([],t._.add([],s,h),p)),m=[];let _;if(new mu(a,f).closestPointOnSphere(c,l,m)){const i=t._.add([],m,c),n=t._.sub([],i,a);_=Math.cos(e.fovAboveCenter)*t._.length(n)}else{const e=t._.sub([],a,c),i=t._.sub([],c,a);t._.normalize(i,i);const n=t._.length(e)-l;_=Math.sqrt(n*(n+2*l));const r=Math.acos(_/(l+n))-Math.acos(t._.dot(s,i));_*=Math.cos(r)}return 1.01*_}(e,this.pixelsPerMeter(e.center.lat,e.worldSize)),n=Hu(e.zoom);if(n>0){const t=tg(e,Cd(1,e.center.lat)*e.worldSize),r=e.worldSize/(2*Math.PI),o=Math.max(e.width,e.height)/e.worldSize*Math.PI;return Vn(i,t+r*(1-Math.cos(o)),Math.pow(n,10))}return i}upVector(t,e,i){return Fu(e,i,t,1)}upVectorScale(t){return{metersToTile:Cu(Nu($u(t)))}}}function Tg(t){const e=t.parallels,i=!!e&&Math.abs(e[0]+e[1])0&&(this.iconTransitioningVertexBuffer=t.createVertexBuffer(this.iconTransitioningVertexArray,Vf.members,!0)),this.globeExtVertexArray.length>0&&(this.globeExtVertexBuffer=t.createVertexBuffer(this.globeExtVertexArray,Ff.members,!0)),!this.zOffsetVertexBuffer&&(this.zOffsetVertexArray.length>0||r)&&(this.zOffsetVertexBuffer=t.createVertexBuffer(this.zOffsetVertexArray,jf.members,!0)),this.opacityVertexBuffer.itemSize=1),(i||n)&&this.programConfigurations.upload(t))}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy(),this.dynamicLayoutVertexBuffer.destroy(),this.opacityVertexBuffer.destroy(),this.occlusionQueryOpacityVertexBuffer.destroy(),this.iconTransitioningVertexBuffer&&this.iconTransitioningVertexBuffer.destroy(),this.globeExtVertexBuffer&&this.globeExtVertexBuffer.destroy(),this.zOffsetVertexBuffer&&this.zOffsetVertexBuffer.destroy())}}ba(Ng,"SymbolBuffers");class Ug{constructor(t,e,i){this.layoutVertexArray=new t,this.layoutAttributes=e,this.indexArray=new i,this.segments=new wc,this.collisionVertexArray=new Xl,this.collisionVertexArrayExt=new Ol}upload(t){this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,this.layoutAttributes),this.indexBuffer=t.createIndexBuffer(this.indexArray),this.collisionVertexBuffer=t.createVertexBuffer(this.collisionVertexArray,Gf.members,!0),this.collisionVertexBufferExt=t.createVertexBuffer(this.collisionVertexArrayExt,Zf.members,!0)}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.segments.destroy(),this.collisionVertexBuffer.destroy(),this.collisionVertexBufferExt.destroy())}}ba(Ug,"CollisionBuffers");class jg{constructor(e){this.queries=new Map,this.collisionBoxArray=e.collisionBoxArray,this.zoom=e.zoom,this.lut=e.lut,this.overscaling=e.overscaling,this.layers=e.layers,this.layerIds=this.layers.map((t=>t.fqid)),this.index=e.index,this.pixelRatio=e.pixelRatio,this.sourceLayerIndex=e.sourceLayerIndex,this.hasPattern=!1,this.hasRTLText=!1,this.fullyClipped=!1,this.hasAnyIconTextFit=!1,this.sortKeyRanges=[],this.collisionCircleArray=[],this.placementInvProjMatrix=t.ad.identity([]),this.placementViewportMatrix=t.ad.identity([]);const i=this.layers[0]._unevaluatedLayout._values;this.textSizeData=Fm(this.zoom,i["text-size"]),this.iconSizeData=Fm(this.zoom,i["icon-size"]);const n=this.layers[0].layout,r=n.get("symbol-sort-key"),o=n.get("symbol-z-order");this.canOverlap=n.get("text-allow-overlap")||n.get("icon-allow-overlap")||n.get("text-ignore-placement")||n.get("icon-ignore-placement"),this.sortFeaturesByKey="viewport-y"!==o&&void 0!==r.constantOr(1),this.sortFeaturesByY=("viewport-y"===o||"auto"===o&&!this.sortFeaturesByKey)&&this.canOverlap,this.writingModes=n.get("text-writing-mode").map((t=>Jm[t])),this.stateDependentLayerIds=this.layers.filter((t=>t.isStateDependent())).map((t=>t.id)),this.sourceID=e.sourceID,this.projection=e.projection,this.hasAnyZOffset=!1,this.zOffsetSortDirty=!1,this.zOffsetBuffersNeedUpload=n.get("symbol-z-elevate"),this.activeReplacements=[],this.replacementUpdateTime=0}createArrays(){this.text=new Ng(new Yc(this.layers,{zoom:this.zoom,lut:this.lut},(t=>/^text/.test(t)))),this.icon=new Ng(new Yc(this.layers,{zoom:this.zoom,lut:this.lut},(t=>/^icon/.test(t)))),this.glyphOffsetArray=new mc,this.lineVertexArray=new _c,this.symbolInstances=new fc}calculateGlyphDependencies(t,e,i,n,r){for(let i=0;i0)&&("constant"!==l.value.kind||l.value.value.length>0),h="constant"!==d.value.kind||!!d.value.value||Object.keys(d.parameters).length>0,p=s.get("symbol-sort-key");if(this.features=[],!u&&!h)return;const f=i.iconDependencies,m=i.glyphDependencies,_=i.availableImages,g=new Ha(this.zoom);for(const{feature:i,id:c,index:d,sourceLayerIndex:y}of e){const e=o._featureFilter.needGeometry,v=Zd(i,e);if(!o._featureFilter.filter(g,v,n))continue;if(e||(v.geometry=Gd(i,n,r)),a&&1!==i.type&&n.z{const o=Fu(e.x,e.y,n,1),s=Fu(r.x,r.y,n,1);return t._.dot(o,s)=0;for(const i of x.sections)if(i.image)f[i.image.namePrimary]=!0;else{const n=Ca(x.toString()),r=i.fontStack||t,o=m[r]=m[r]||{};this.calculateGlyphDependencies(i.text,o,e,this.allowVerticalPlacement,n)}}}"line"===s.get("symbol-placement")&&(this.features=function(t){const e={},i={},n=[];let r=0;function o(e){n.push(t[e]),r++}function s(t,e,r){const o=i[t];return delete i[t],i[e]=o,n[o].geometry[0].pop(),n[o].geometry[0]=n[o].geometry[0].concat(r[0]),o}function a(t,i,r){const o=e[i];return delete e[i],e[t]=o,n[o].geometry[0].shift(),n[o].geometry[0]=r[0].concat(n[o].geometry[0]),o}function l(t,e,i){const n=i?e[0][e[0].length-1]:e[0][0];return`${t}:${n.x}:${n.y}`}for(let c=0;ct.geometry))}(this.features)),this.sortFeaturesByKey&&this.features.sort(((t,e)=>t.sortKey-e.sortKey))}update(t,e,i,n,r){const o=0!==Object.keys(t).length;if(o&&!this.stateDependentLayers.length)return;const s=o?this.stateDependentLayers:this.layers;this.text.programConfigurations.updatePaintArrays(t,e,s,i,n,r),this.icon.programConfigurations.updatePaintArrays(t,e,s,i,n,r)}updateOcclusionOpacities(t,e,i){if(!e.useOcclusionQueries)return!1;const n=this;if("globe"===n.projection.name)return!1;let r=!1;n.hasTextData()&&(r=r||0!==n.text.occlusionQueryOpacityVertexArray.length),n.hasIconData()&&(r=r||0!==n.icon.occlusionQueryOpacityVertexArray.length);const o=n.layers[0].paint,s=o.get("icon-occlusion-opacity").constantOr(0),a=o.get("text-occlusion-opacity").constantOr(0);if(!n.layers[0].hasInitialOcclusionOpacityProperties||1===s&&1===a)return!1;let l=!r;for(let t=0;t.5?1:-1)*e.fadeSpeed*i*.001,r.occlusionOpacity=Xe(r.occlusionOpacity,0,1),l=l||r.occlusionOpacity!==o}if(!l)return!1;let c=0,d=0;const u=(t,e,i,n)=>{let r=0,o=0;i?(r=d,d+=n,o=d):(r=c,c+=n,o=c),o>e.occlusionQueryOpacityVertexArray.length&&e.occlusionQueryOpacityVertexArray.resize(o);const s=t.occlusionOpacity;for(let t=0;t0;if((i>0||r>0)&&(u(e,n.text,!1,i),u(e,n.text,!1,r)),s){const{placedIconSymbolIndex:t,verticalPlacedIconSymbolIndex:i}=e;t>=0&&u(e,n.icon,!0,o),i>=0&&u(e,n.icon,!0,e.numVerticalIconVertices)}}return n.hasTextData()&&n.text.occlusionQueryOpacityVertexBuffer&&(n.text.occlusionQueryOpacityVertexBuffer.length{i+=e,i>t.length&&t.resize(i);for(let r=-e;r{n+=e,n>t.length&&t.resize(n);for(let r=-e;r0;if((r>0||o>0)&&(t(this.text.zOffsetVertexArray,r,a),t(this.text.zOffsetVertexArray,o,a)),l){const{placedIconSymbolIndex:t,verticalPlacedIconSymbolIndex:i}=n;t>=0&&e(this.icon.zOffsetVertexArray,s,a),i>=0&&e(this.icon.zOffsetVertexArray,n.numVerticalIconVertices,a)}}this.text.zOffsetVertexBuffer&&this.text.zOffsetVertexBuffer.updateData(this.text.zOffsetVertexArray),this.icon.zOffsetVertexBuffer&&this.icon.zOffsetVertexBuffer.updateData(this.icon.zOffsetVertexArray)}isEmpty(){return 0===this.symbolInstances.length&&!this.hasRTLText}uploadPending(){return!this.uploaded||this.text.programConfigurations.needsUpload||this.icon.programConfigurations.needsUpload}upload(t){!this.uploaded&&this.hasDebugData()&&(this.textCollisionBox.upload(t),this.iconCollisionBox.upload(t)),this.text.upload(t,this.sortFeaturesByY,!this.uploaded,this.text.programConfigurations.needsUpload,this.zOffsetBuffersNeedUpload),this.icon.upload(t,this.sortFeaturesByY,!this.uploaded,this.icon.programConfigurations.needsUpload,this.zOffsetBuffersNeedUpload),this.uploaded=!0}destroyDebugData(){this.textCollisionBox.destroy(),this.iconCollisionBox.destroy()}getProjection(){return this.projectionInstance||(this.projectionInstance=Tg(this.projection)),this.projectionInstance}destroy(){this.text.destroy(),this.icon.destroy(),this.hasDebugData()&&this.destroyDebugData();for(const t of this.queries.values())t.destroy()}addToLineVertexArray(t,e){const i=this.lineVertexArray.length;if(void 0!==t.segment)for(const{x:t,y:i}of e)this.lineVertexArray.emplaceBack(t,i);return{lineStartIndex:i,lineLength:this.lineVertexArray.length-i}}addSymbols(t,e,i,n,r,o,s,a,l,c,d,u,h,p,f,m){const _=t.indexArray,g=t.layoutVertexArray,y=t.globeExtVertexArray,v=t.segments.prepareSegment(4*e.length,g,_,this.canOverlap?o.sortKey:void 0),x=this.glyphOffsetArray.length,b=v.vertexLength,w=this.allowVerticalPlacement&&s===Jm.vertical?Math.PI/2:0,T=o.text&&o.text.sections;for(let n=0;n=0?e.rightJustifiedTextSymbolIndex:e.centerJustifiedTextSymbolIndex>=0?e.centerJustifiedTextSymbolIndex:e.leftJustifiedTextSymbolIndex>=0?e.leftJustifiedTextSymbolIndex:e.verticalPlacedTextSymbolIndex>=0?e.verticalPlacedTextSymbolIndex:n),o=Nm(this.textSizeData,t,r)/Om;return this.tilePixelRatio*o}getSymbolInstanceIconSize(t,e,i){const n=this.icon.placedSymbolArray.get(i),r=Nm(this.iconSizeData,t,n);return this.tilePixelRatio*r}_commitDebugCollisionVertexUpdate(t,e,i,n){t.emplaceBack(e,-i,-i,n),t.emplaceBack(e,i,-i,n),t.emplaceBack(e,i,i,n),t.emplaceBack(e,-i,i,n)}_updateTextDebugCollisionBoxes(t,e,i,n,r,o){for(let s=n;s0}hasIconData(){return this.icon.segments.get().length>0}hasDebugData(){return this.textCollisionBox&&this.iconCollisionBox}hasTextCollisionBoxData(){return this.hasDebugData()&&this.textCollisionBox.segments.get().length>0}hasIconCollisionBoxData(){return this.hasDebugData()&&this.iconCollisionBox.segments.get().length>0}hasIconTextFit(){return this.hasAnyIconTextFit}addIndicesForPlacedSymbol(t,e){const i=t.placedSymbolArray.get(e),n=i.vertexStartIndex+4*i.numGlyphs;for(let e=i.vertexStartIndex;en[t]-n[e]||r[e]-r[t])),o}getSortedIndexesByZOffset(){if(!this.zOffsetSortDirty)return this.symbolInstanceIndexesSortedZOffset;if(!this.symbolInstanceIndexesSortedZOffset){this.symbolInstanceIndexesSortedZOffset=[];for(let t=0;tthis.symbolInstances.get(e).zOffset-this.symbolInstances.get(t).zOffset))}addToSortKeyRanges(t,e){const i=this.sortKeyRanges[this.sortKeyRanges.length-1];i&&i.sortKey===e?i.symbolInstanceEnd=t+1:this.sortKeyRanges.push({sortKey:e,symbolInstanceStart:t,symbolInstanceEnd:t+1})}sortFeatures(t){if(this.sortFeaturesByY&&this.sortedAngle!==t&&!(this.text.segments.get().length>1||this.icon.segments.get().length>1)){this.symbolInstanceIndexes=this.getSortedSymbolIndexes(t),this.sortedAngle=t,this.text.indexArray.clear(),this.icon.indexArray.clear(),this.featureSortOrder=[];for(const t of this.symbolInstanceIndexes){const e=this.symbolInstances.get(t);this.featureSortOrder.push(e.featureIndex);const{rightJustifiedTextSymbolIndex:i,centerJustifiedTextSymbolIndex:n,leftJustifiedTextSymbolIndex:r,verticalPlacedTextSymbolIndex:o,placedIconSymbolIndex:s,verticalPlacedIconSymbolIndex:a}=e;i>=0&&this.addIndicesForPlacedSymbol(this.text,i),n>=0&&n!==i&&this.addIndicesForPlacedSymbol(this.text,n),r>=0&&r!==n&&r!==i&&this.addIndicesForPlacedSymbol(this.text,r),o>=0&&this.addIndicesForPlacedSymbol(this.text,o),s>=0&&this.addIndicesForPlacedSymbol(this.icon,s),a>=0&&this.addIndicesForPlacedSymbol(this.icon,a)}this.text.indexBuffer&&this.text.indexBuffer.updateData(this.text.indexArray),this.icon.indexBuffer&&this.icon.indexBuffer.updateData(this.icon.indexArray)}}}ba(jg,"SymbolBucket",{omit:["layers","collisionBoxArray","features","compareText"]}),jg.addDynamicAttributes=Bg;class Vg{constructor(t,e,i,n){this.context=t,this.format=i,this.texture=t.gl.createTexture(),this.update(e,n)}update(t,e,i){const{width:n,height:r}=t,{context:o}=this,{gl:s}=o;if(s.bindTexture(s.TEXTURE_2D,this.texture),o.pixelStoreUnpackFlipY.set(!1),o.pixelStoreUnpack.set(1),o.pixelStoreUnpackPremultiplyAlpha.set(this.format===s.RGBA&&(!e||!1!==e.premultiply)),this.useMipmap=Boolean(e&&e.useMipmap),i||this.size&&this.size[0]===n&&this.size[1]===r){const{x:e,y:o}=i||{x:0,y:0};if(t instanceof HTMLImageElement||t instanceof HTMLCanvasElement||t instanceof HTMLVideoElement||t instanceof ImageData||ImageBitmap&&t instanceof ImageBitmap)s.texSubImage2D(s.TEXTURE_2D,0,e,o,s.RGBA,s.UNSIGNED_BYTE,t);else{let i=this.format,a=s.UNSIGNED_BYTE;this.format===s.R32F&&(i=s.RED,a=s.FLOAT),s.texSubImage2D(s.TEXTURE_2D,0,e,o,n,r,i,a,t.data)}}else if(this.size=[n,r],t instanceof HTMLImageElement||t instanceof HTMLCanvasElement||t instanceof HTMLVideoElement||t instanceof ImageData||ImageBitmap&&t instanceof ImageBitmap){let e=this.format;this.format===s.R8&&(e=s.RED),s.texImage2D(s.TEXTURE_2D,0,this.format,e,s.UNSIGNED_BYTE,t)}else{let e=this.format,i=this.format,o=s.UNSIGNED_BYTE,a=!1;this.format===s.DEPTH_COMPONENT&&(e=s.DEPTH_COMPONENT16,o=s.UNSIGNED_SHORT),this.format===s.DEPTH_STENCIL&&(e=s.DEPTH24_STENCIL8,o=s.UNSIGNED_INT_24_8,a=!0),this.format===s.R8&&(i=s.RED),this.format===s.R32F&&(o=s.FLOAT,i=s.RED),!this.useMipmap&&a?s.texStorage2D(s.TEXTURE_2D,1,e,n,r):s.texImage2D(s.TEXTURE_2D,0,e,n,r,0,i,o,t.data)}this.useMipmap&&s.generateMipmap(s.TEXTURE_2D)}bind(t,e,i=!1){const{context:n}=this,{gl:r}=n;r.bindTexture(r.TEXTURE_2D,this.texture),t!==this.minFilter&&(r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MAG_FILTER,t),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MIN_FILTER,this.useMipmap&&!i?t===r.NEAREST?r.NEAREST_MIPMAP_NEAREST:r.LINEAR_MIPMAP_LINEAR:t),this.minFilter=t),e!==this.wrapS&&(r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_S,e),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_T,e),this.wrapS=e)}bindExtraParam(t,e,i,n){const{context:r}=this,{gl:o}=r;o.bindTexture(o.TEXTURE_2D,this.texture),e!==this.magFilter&&(o.texParameteri(o.TEXTURE_2D,o.TEXTURE_MAG_FILTER,e),this.magFilter=e),t!==this.minFilter&&(o.texParameteri(o.TEXTURE_2D,o.TEXTURE_MIN_FILTER,this.useMipmap?t===o.NEAREST?o.NEAREST_MIPMAP_NEAREST:o.LINEAR_MIPMAP_LINEAR:t),this.minFilter=t),i!==this.wrapS&&(o.texParameteri(o.TEXTURE_2D,o.TEXTURE_WRAP_S,i),this.wrapS=i),n!==this.wrapT&&(o.texParameteri(o.TEXTURE_2D,o.TEXTURE_WRAP_T,n),this.wrapT=n)}destroy(){const{gl:t}=this.context;t.deleteTexture(this.texture),this.texture=null}}class Gg{constructor(t,e){this.context=t,this.texture=e}bind(t,e){const{context:i}=this,{gl:n}=i;n.bindTexture(n.TEXTURE_2D,this.texture),t!==this.minFilter&&(n.texParameteri(n.TEXTURE_2D,n.TEXTURE_MAG_FILTER,t),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_MIN_FILTER,t),this.minFilter=t),e!==this.wrapS&&(n.texParameteri(n.TEXTURE_2D,n.TEXTURE_WRAP_S,e),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_WRAP_T,e),this.wrapS=e)}}const Zg=32,qg=33,Hg=new Uint16Array(8184);for(let t=0;t>=1)>1;){const t=i+r>>1,l=n+o>>1;1&e?(r=i,o=n,i=s,n=a):(i=r,n=o,r=s,o=a),s=t,a=l}const l=4*t;Hg[l+0]=i,Hg[l+1]=n,Hg[l+2]=r,Hg[l+3]=o}const Wg=new Uint16Array(2178),Yg=new Uint8Array(1089),Xg=new Uint16Array(1089);function Kg(t){return 0===t?-.03125:32===t?.03125:0}var Jg=Ll([{name:"a_pos",type:"Int16",components:2},{name:"a_texture_pos",type:"Int16",components:2}]),Qg=Ll([{name:"a_index",type:"Int16",components:1}]);const ty={type:2,extent:uo,loadGeometry:()=>[[new Ue(0,0),new Ue(uo+1,0),new Ue(uo+1,uo+1),new Ue(0,uo+1),new Ue(0,0)]]};class ey{constructor(t,e,i,n,r){this.tileID=t,this.uid=ni(),this.uses=0,this.tileSize=e,this.tileZoom=i,this.buckets={},this.expirationTime=null,this.queryPadding=0,this.hasSymbolBuckets=!1,this.hasRTLText=!1,this.dependencies={},this.isRaster=r,n&&n.style&&(this._lastUpdatedBrightness=n.style.getBrightness()),this.expiredRequestCount=0,this.state="loading",n&&n.transform&&(this.projection=n.transform.projection)}registerFadeDuration(t){const e=t+this.timeAdded;ee.getLayer(t))).filter(Boolean);if(0!==t.length){n.layers=t,n.stateDependentLayerIds&&(n.stateDependentLayers=n.stateDependentLayerIds.map((e=>t.filter((t=>t.id===e))[0])));for(const e of t)i[e.fqid]=n}}return i}(t.buckets,e.style),this.hasSymbolBuckets=!1;for(const t in this.buckets){const e=this.buckets[t];if(e instanceof jg){if(this.hasSymbolBuckets=!0,!i)break;e.justReloaded=!0}}if(this.hasRTLText=!1,this.hasSymbolBuckets)for(const t in this.buckets){const e=this.buckets[t];if(e instanceof jg&&e.hasRTLText){this.hasRTLText=!0,qa.isLoading()||qa.isLoaded()||"deferred"!==Ga()||Za();break}}this.queryPadding=0;for(const t in this.buckets){const i=this.buckets[t],n=e.style.getOwnLayer(t);if(!n)continue;const r=n.queryRadius(i);this.queryPadding=Math.max(this.queryPadding,r)}t.imageAtlas&&(this.imageAtlas=t.imageAtlas),t.glyphAtlasImage&&(this.glyphAtlasImage=t.glyphAtlasImage),t.lineAtlas&&(this.lineAtlas=t.lineAtlas),this._lastUpdatedBrightness=t.brightness}else this.collisionBoxArray=new dc}unloadVectorData(){if(this.hasData()){for(const t in this.buckets)this.buckets[t].destroy();this.buckets={},this.imageAtlas&&(this.imageAtlas=null),this.lineAtlas&&(this.lineAtlas=null),this.imageAtlasTexture&&this.imageAtlasTexture.destroy(),this.glyphAtlasTexture&&this.glyphAtlasTexture.destroy(),this.lineAtlasTexture&&this.lineAtlasTexture.destroy(),this._tileBoundsBuffer&&(this._tileBoundsBuffer.destroy(),this._tileBoundsIndexBuffer.destroy(),this._tileBoundsSegments.destroy(),this._tileBoundsBuffer=null),this._tileDebugBuffer&&(this._tileDebugBuffer.destroy(),this._tileDebugSegments.destroy(),this._tileDebugBuffer=null),this._tileDebugIndexBuffer&&(this._tileDebugIndexBuffer.destroy(),this._tileDebugIndexBuffer=null),this._globeTileDebugBorderBuffer&&(this._globeTileDebugBorderBuffer.destroy(),this._globeTileDebugBorderBuffer=null),this._tileDebugTextBuffer&&(this._tileDebugTextBuffer.destroy(),this._tileDebugTextSegments.destroy(),this._tileDebugTextIndexBuffer.destroy(),this._tileDebugTextBuffer=null),this._globeTileDebugTextBuffer&&(this._globeTileDebugTextBuffer.destroy(),this._globeTileDebugTextBuffer=null),this.latestFeatureIndex=null,this.state="unloaded"}}getBucket(t){return this.buckets[t.fqid]}upload(t){for(const e in this.buckets){const i=this.buckets[e];i.uploadPending()&&i.upload(t)}const e=t.gl,i=this.imageAtlas;if(i&&!i.uploaded){const n=!!Object.keys(i.patternPositions).length;this.imageAtlasTexture=new Vg(t,i.image,e.RGBA,{useMipmap:n}),this.imageAtlas.uploaded=!0}this.glyphAtlasImage&&(this.glyphAtlasTexture=new Vg(t,this.glyphAtlasImage,e.R8),this.glyphAtlasImage=null),this.lineAtlas&&!this.lineAtlas.uploaded&&(this.lineAtlasTexture=new Vg(t,this.lineAtlas.image,e.R8),this.lineAtlas.uploaded=!0)}prepare(t,e,i){if(this.imageAtlas&&this.imageAtlasTexture&&this.imageAtlas.patchUpdatedImages(t,this.imageAtlasTexture,i),!e||!this.latestFeatureIndex||!this.latestFeatureIndex.rawTileData)return;const n=e.style.getBrightness();(this._lastUpdatedBrightness||n)&&(this._lastUpdatedBrightness&&n&&Math.abs(this._lastUpdatedBrightness-n)t)i=!1;else if(e)if(this.expirationTime=0;t--){const e=4*t,i=Hg[e+0],n=Hg[e+1],r=Hg[e+2],o=Hg[e+3],s=i+r>>1,a=n+o>>1,l=s+a-n,c=a+i-s,d=n*qg+i,u=o*qg+r,h=a*qg+s,p=Math.hypot((Wg[2*d+0]+Wg[2*u+0])/2-Wg[2*h+0],(Wg[2*d+1]+Wg[2*u+1])/2-Wg[2*h+1])>=16;Yg[h]=Yg[h]||(p?1:0),t>1)*qg+(i+l>>1)]||Yg[(o+c>>1)*qg+(r+l>>1)])}const r=new Dl,o=new Kl;let s=0;function a(t,e){const i=e*qg+t;return 0===Xg[i]&&(r.emplaceBack(Wg[2*i+0],Wg[2*i+1],t*uo/Zg,e*uo/Zg),Xg[i]=++s),Xg[i]-1}function l(t,e,i,n,r,s){const c=t+i>>1,d=e+n>>1;if(Math.abs(t-r)+Math.abs(e-s)>1&&Yg[d*qg+c])l(r,s,t,e,c,d),l(i,n,r,s,c,d);else{const l=a(t,e),c=a(i,n),d=a(r,s);o.emplaceBack(l,c,d)}}return l(0,0,Zg,Zg,Zg,0),l(Zg,Zg,0,0,0,Zg),{vertices:r,indices:o}}(this.tileID.canonical,e);n=t.vertices,r=t.indices}else{n=new Dl,r=new Kl;for(const{x:t,y:e}of i)n.emplaceBack(t,e,0,0);const t=xh(n.int16,void 0,4);for(let e=0;e0&&(a=t.ad.invert(new Float64Array(16),i.globeMatrix)),this._makeGlobeTileDebugBorderBuffer(e,r,i,o,a,s),this._makeGlobeTileDebugTextBuffer(e,r,i,o,a,s)}_globePoint(e,i,n,r,o,s,a){let l=Fu(e,i,n);if(s){const o=1.5?h=-1:u{const p=(d-t)/(h-1),f=(u-c)/(h-1),m=s.length;for(let d=0;dd*t+e;for(let t=0;t[t,this.get(t)]))}evict(t=!1){if(t||this.size>0){const t=this.first;delete this.items[t.key],0==--this.size?(this.first=null,this.last=null):(this.first=t.next,this.first.prev=null)}return this}expiresAt(t){let e;return this.has(t)&&(e=this.items[t].expiry),e}get(t){let e;if(this.has(t)){const i=this.items[t];this.ttl>0&&i.expiry0?Date.now()+this.ttl:this.ttl),this.last!==r){const t=this.last,e=r.next,i=r.prev;this.first===r&&(this.first=r.next),r.next=null,r.prev=this.last,t.next=r,null!==i&&(i.next=e),null!==e&&(e.prev=i)}}else this.max>0&&this.size===this.max&&this.evict(!0),r=this.items[t]={expiry:this.ttl>0?Date.now()+this.ttl:this.ttl,key:t,prev:this.last,next:null,value:e},1==++this.size?this.first=r:this.last.next=r;return this.last=r,this}values(t=this.keys()){return t.map((t=>this.get(t)))}}function uy(t,e){if(4!==e.length)throw new Error(`Expected data of dimension 4 but got ${e.length}.`);let i=e[3];for(let n=2;n>=1;n--){const r=1===n?1:0,o=2===n?1:0;for(let n=0;n>>1^-(1&t[e]);return t}function py(t,e){switch(e){case"uint32":return t;case"uint16":for(let e=0;e>4|(61440&i)>>8|(240&n)>4|(15&n)>6|(192&n)>>4|(192&r)>>2|192&o,t[e+1]=(48&i)>>4|(48&n)>>2|48&r|(48&o)>2|12&n|(12&r)>1|(21845&Cy)>2|(13107&Ay)>4|(3855&Ay)>8|(255&Ay)>1}var Iy=function(t,e,i){for(var n=t.length,r=0,o=new _y(e);r>l]=c}else for(s=new _y(n),r=0;r>15-t[r]);return s},Ly=new my(288);for(Cy=0;Cye&&(e=t[i]);return e},zy=function(t,e,i){var n=e/8|0;return(t[n]|t[n+1]>(7&e)&i},Ry=function(t,e){var i=e/8|0;return(t[i]|t[i+1]>(7&e)},Oy=["unexpected EOF","invalid block type","invalid length/literal","invalid distance","stream finished","no stream handler",,"no callback","invalid UTF-8 data","extra field too long","date not in range 1980-2099","filename too long","stream finishing","invalid zip data"],By=function(t,e,i){var n=new Error(e||Oy[t]);if(n.code=t,Error.captureStackTrace&&Error.captureStackTrace(n,By),!i)throw n;return n},Fy=new my(0),Ny="undefined"!=typeof TextDecoder&&new TextDecoder;try{Ny.decode(Fy,{stream:!0})}catch(t){}const Uy={gzip_data:"gzip"},jy={0:"uint32",1:"uint32",2:"uint16",3:"uint8"},Vy={uint32:1,uint16:2,uint8:4},Gy={uint32:Uint32Array,uint16:Uint16Array,uint8:Uint8Array};class Zy{constructor(t=1){this.x=NaN,this.y=NaN,this.z=NaN,this.layers={},this._cacheSize=t}getLayer(t){return this.layers[t]}getHeaderLength(t){const e=new Uint8Array(t),i=new DataView(t);if(13!==e[0])throw new fy("File is not a valid MRT.");return i.getUint32(1,!0)}parseHeader(t){const e=new Uint8Array(t),i=this.getHeaderLength(t);if(e.length= ${i} but got buffer of length ${e.length}`);const n=function(t){return t.readFields(iy,{header_length:0,x:0,y:0,z:0,layers:[]},void 0)}(new Lm(e.subarray(0,i)));if(!isNaN(this.x)&&(this.x!==n.x||this.y!==n.y||this.z!==n.z))throw new fy(`Invalid attempt to parse header ${n.z}/${n.x}/${n.y} for tile ${this.z}/${this.x}/${this.y}`);this.x=n.x,this.y=n.y,this.z=n.z;for(const t of n.layers)this.layers[t.name]=new qy(t,{cacheSize:this._cacheSize});return this}createDecodingTask(t){const e=[],i=this.getLayer(t.layerName);for(let n=0;nt.lastBlock)continue;if(i._blocksInProgress.has(n))continue;const a={layerName:i.name,firstByte:o,lastByte:s,pixelFormat:i.pixelFormat,blockIndex:n,blockShape:[r.bands.length].concat(i.bandShape),buffer:i.buffer,codec:r.codec.codec,filters:r.filters.map((t=>t.filter))};i._blocksInProgress.add(n),e.push(a)}return new Hy(e,(()=>{e.forEach((t=>i._blocksInProgress.delete(t.blockIndex)))}),((t,n)=>{if(e.forEach((t=>i._blocksInProgress.delete(t.blockIndex))),t)throw t;n.forEach((t=>{this.getLayer(t.layerName).processDecodedData(t)}))}))}}class qy{constructor({version:t,name:e,units:i,tilesize:n,pixel_format:r,buffer:o,data_index:s},a){if(this.version=t,1!==this.version)throw new fy(`Cannot parse raster layer encoded with MRT version ${t}`);this.name=e,this.units=i,this.tileSize=n,this.buffer=o,this.pixelFormat=jy[r],this.dataIndex=s,this.bandShape=[n+2*o,n+2*o,Vy[this.pixelFormat]],this._decodedBlocks=function(t=1e3,e=0,i=!1){if(isNaN(t)||t=e&&t=0}hasDataForBand(t){const{blockIndex:e}=this.getBlockForBand(t);return e>=0&&!!this._decodedBlocks.get(e.toString())}getBandView(t){const{blockIndex:e,blockBandIndex:i}=this.getBlockForBand(t),n=this._decodedBlocks.get(e.toString());if(!n)throw new fy(`Data for band ${JSON.stringify(t)} of layer "${this.name}" not decoded.`);const r=this.dataIndex[e],o=this.bandShape.reduce(((t,e)=>t*e),1),s=i*o,a=n.subarray(s,s+o);return{data:a,bytes:new Uint8Array(a.buffer).subarray(a.byteOffset,a.byteOffset+a.byteLength),tileSize:this.tileSize,buffer:this.buffer,offset:r.offset,scale:r.scale}}}class Hy{constructor(t,e,i){this.tasks=t,this._onCancel=e,this._onComplete=i,this._finalized=!1}cancel(){this._finalized||(this._onCancel(),this._finalized=!0)}complete(t,e){this._finalized||(this._onComplete(t,e),this._finalized=!0)}}Zy.performDecoding=function(t,e){return Promise.all(e.tasks.map((e=>{const{layerName:i,firstByte:n,lastByte:r,pixelFormat:o,blockShape:s,blockIndex:a,filters:l,codec:c}=e,d=new Uint8Array(t).subarray(n,r+1),u=new Uint32Array(s[0]*s[1]*s[2]);let h;if("gzip_data"!==c)throw new Error(`Unhandled codec: ${c}`);return h=function(t,e){if(!globalThis.DecompressionStream&&"gzip_data"===e)return Promise.resolve(((o=function(t){31==t[0]&&139==t[1]&&8==t[2]||By(6,"invalid gzip data");var e=t[3],i=10;4&e&&(i+=2+(t[10]|t[11]>3&1)+(e>>4&1);n>0;n-=!t[i++]);return i+(2&e)}(r=t))+8>r.length&&By(6,"invalid gzip data"),function(t,e,i){var n=t.length;if(!n||e.f&&!e.l)return i||new my(0);var r=!i,o=r||2!=e.i,s=e.i;r&&(i=new my(3*n));var a,l,c=function(t){var e=i.length;if(t>e){var n=new my(Math.max(2*e,t));n.set(i),i=n}},d=e.f||0,u=e.p||0,h=e.b||0,p=e.l,f=e.d,m=e.m,_=e.n,g=8*n;do{if(!p){d=zy(t,u,1);var y=zy(t,u+1,3);if(u+=3,!y){var v=t[(L=4+((u+7)/8|0))-4]|t[L-3]n){s&&By(0);break}o&&c(h+v),i.set(t.subarray(L,x),h),e.b=h+=v,e.p=u=8*x,e.f=d;continue}if(1==y)p=$y,f=ky,m=9,_=5;else if(2==y){var b=zy(t,u,31)+257,w=zy(t,u+10,15)+4,T=b+zy(t,u+5,31)+1;u+=14;for(var S=new my(T),E=new my(19),M=0;M>4)g){s&&By(0);break}}o&&c(h+131072);for(var R=(1>4;if((u+=15&$)>g){s&&By(0);break}if($||By(2),F264&&(N=zy(t,u,(1>4;if(U||By(3),u+=15&U,z=Ey[j],j>3){var V=vy[j];z+=Ry(t,u)&(1g){s&&By(0);break}o&&c(h+131072);var G=h+N;if(ha.length)&&(l=a.length),new my(a.subarray(0,l))):i.subarray(0,h)}(r.subarray(o,-8),{i:2},new my(((i=r)[(n=i.length)-4]|i[n-3]>>0))));var i,n,r,o;const s=Uy[e];if(!s)throw new Error(`Unhandled codec: ${e}`);const a=new globalThis.DecompressionStream(s);return new Response(new Blob([t]).stream().pipeThrough(a)).arrayBuffer().then((t=>new Uint8Array(t)))}(d,c).then((t=>(function(t,e){t.readFields(ly,e)}(new Lm(t),u),new(0,Gy[o])(u.buffer)))),h.then((t=>{for(let e=l.length-1;e>=0;e--)switch(l[e]){case"delta_filter":uy(t,s);break;case"zigzag_filter":hy(t);break;case"bitshuffle_filter":py(t,o);break;default:throw new Error(`Unhandled filter "${l[e]}"`)}return{layerName:i,blockIndex:a,data:t}})).catch((t=>{throw t}))})))};class Wy extends ey{constructor(t,e,i,n,r){super(t,e,i,n,r),this._workQueue=[],this._fetchQueue=[],this._isHeaderLoaded=!1}setTexture(t,e){const i=e.context,n=i.gl;this.texture=this.texture||e.getTileTexture(t.width),this.texture&&this.texture instanceof Vg?this.texture.update(t,{useMipmap:!1,premultiply:!1}):this.texture=new Vg(i,t,n.RGBA,{useMipmap:!1,premultiply:!1})}flushQueues(){for(;this._workQueue.length;)this._workQueue.pop()();for(;this._fetchQueue.length;)this._fetchQueue.pop()()}fetchHeader(t=16384,e){const i=this._mrt=new Zy(30),n=Object.assign({},this.requestParams,{headers:{Range:"bytes=0-"+(t-1)}});return this.entireBuffer=null,this.request=en(n,((n,r,o,s)=>{if(n)e(n);else try{const n=i.getHeaderLength(r);if(n>t)return void(this.request=this.fetchHeader(n,e));i.parseHeader(r),this._isHeaderLoaded=!0;let a=0;for(const t of Object.values(i.layers))a=Math.max(a,t.dataIndex[t.dataIndex.length-1].last_byte);r.byteLength>=a&&(this.entireBuffer=r),e(null,this.entireBuffer||r,o,s)}catch(t){e(t)}})),this.request}fetchBand(t,e,i){const n=this._mrt;if(!this._isHeaderLoaded||!n)return void i(new Error("Tile header is not ready"));const r=this.actor;if(!r)return void i(new Error("Can't fetch tile band without an actor"));let o;const s=(n,r)=>{o.complete(n,r),n?i(n):(this.updateTextureDescriptor(t,e),i(null,this.textureDescriptor&&this.textureDescriptor.img))},a=(t,e)=>{if(t)return i(t);const n=r.send("decodeRasterArray",{buffer:e,task:o},s,void 0,!0);this._workQueue.push((()=>{n&&n.cancel(),o.cancel()}))},l=n.getLayer(t);if(!l)return void i(new Error(`Unknown sourceLayer "${t}"`));if(l.hasDataForBand(e))return this.updateTextureDescriptor(t,e),void i(null,this.textureDescriptor?this.textureDescriptor.img:null);const c=l.getDataRange([e]);if(o=n.createDecodingTask(c),!o||o.tasks.length)if(this.flushQueues(),this.entireBuffer)a(null,this.entireBuffer.slice(c.firstByte,c.lastByte+1));else{const t=Object.assign({},this.requestParams,{headers:{Range:`bytes=${c.firstByte}-${c.lastByte}`}}),e=en(t,a);this._fetchQueue.push((()=>{e.cancel(),o.cancel()}))}else i(null)}updateNeeded(t,e){return(!this.textureDescriptor||this.textureDescriptor.band!==e||this.textureDescriptor.layer!==t)&&"errored"!==this.state}updateTextureDescriptor(t,e){if(!this._mrt)return;const i=this._mrt.getLayer(t);if(!i||!i.hasBand(e)||!i.hasDataForBand(e))return;const{bytes:n,tileSize:r,buffer:o,offset:s,scale:a}=i.getBandView(e),l=r+2*o,c={data:n,width:l,height:l},d=this.texture;d&&d instanceof Vg&&d.update(c,{useMipmap:!1,premultiply:!1}),this.textureDescriptor={layer:t,band:e,img:c,buffer:o,offset:s,tileSize:r,format:i.pixelFormat,mix:[a,256*a,65536*a,16777216*a]}}}class Yy{constructor(t,e){this.max=t,this.onRemove=e,this.reset()}reset(){for(const t in this.data)for(const e of this.data[t])e.timeout&&clearTimeout(e.timeout),this.onRemove(e.value);return this.data={},this.order=[],this}add(t,e,i){const n=t.wrapped().key;void 0===this.data[n]&&(this.data[n]=[]);const r={value:e,timeout:void 0};if(void 0!==i&&(r.timeout=setTimeout((()=>{this.remove(t,r)}),i)),this.data[n].push(r),this.order.push(n),this.order.length>this.max){const t=this._getAndRemoveByKey(this.order[0]);t&&this.onRemove(t)}return this}has(t){return t.wrapped().key in this.data}getAndRemove(t){return this.has(t)?this._getAndRemoveByKey(t.wrapped().key):null}_getAndRemoveByKey(t){const e=this.data[t].shift();return e.timeout&&clearTimeout(e.timeout),0===this.data[t].length&&delete this.data[t],this.order.splice(this.order.indexOf(t),1),e.value}getByKey(t){const e=this.data[t];return e?e[0].value:null}get(t){return this.has(t)?this.data[t.wrapped().key][0].value:null}remove(t,e){if(!this.has(t))return this;const i=t.wrapped().key,n=void 0===e?0:this.data[i].indexOf(e),r=this.data[i][n];return this.data[i].splice(n,1),r.timeout&&clearTimeout(r.timeout),0===this.data[i].length&&delete this.data[i],this.onRemove(r.value),this.order.splice(this.order.indexOf(i),1),this}setMaxSize(t){for(this.max=t;this.order.length>this.max;){const t=this._getAndRemoveByKey(this.order[0]);t&&this.onRemove(t)}return this}filter(t){const e=[];for(const i in this.data)for(const n of this.data[i])t(n.value)||e.push(n);for(const t of e)this.remove(t.value.tileID,t)}}class Xy extends zn{constructor(t,e,i){super(),this.id=t,this._onlySymbols=i,e.on("data",(t=>{"source"===t.dataType&&"metadata"===t.sourceDataType&&(this._sourceLoaded=!0),this._sourceLoaded&&!this._paused&&"source"===t.dataType&&"content"===t.sourceDataType&&(this.reload(),this.transform&&this.update(this.transform))})),e.on("error",(()=>{this._sourceErrored=!0})),this._source=e,this._tiles={},this._cache=new Yy(0,this._unloadTile.bind(this)),this._timers={},this._cacheTimers={},this._minTileCacheSize=e.minTileCacheSize,this._maxTileCacheSize=e.maxTileCacheSize,this._loadedParentTiles={},this.castsShadows=!1,this.tileCoverLift=0,this._coveredTiles={},this._shadowCasterTiles={},this._state=new km,this._isRaster="raster"===this._source.type||"raster-dem"===this._source.type||"raster-array"===this._source.type||"custom"===this._source.type&&"raster"===this._source._dataType}onAdd(t){this.map=t,this._minTileCacheSize=void 0===this._minTileCacheSize&&t?t._minTileCacheSize:this._minTileCacheSize,this._maxTileCacheSize=void 0===this._maxTileCacheSize&&t?t._maxTileCacheSize:this._maxTileCacheSize}loaded(){if(this._sourceErrored)return!0;if(!this._sourceLoaded)return!1;if(!this._source.loaded())return!1;for(const t in this._tiles){const e=this._tiles[t];if("errored"!==e.state&&("loaded"!==e.state||!e.bucketsLoaded()))return!1}return!0}getSource(){return this._source}pause(){this._paused=!0}resume(){if(!this._paused)return;const t=this._shouldReloadOnResume;this._paused=!1,this._shouldReloadOnResume=!1,t&&this.reload(),this.transform&&this.update(this.transform)}_loadTile(t,e){return t.isSymbolTile=this._onlySymbols,t.isExtraShadowCaster=this._shadowCasterTiles[t.tileID.key],this._source.loadTile(t,e)}_unloadTile(t){if(this._source.unloadTile)return this._source.unloadTile(t)}_abortTile(t){if(this._source.abortTile)return this._source.abortTile(t)}serialize(){return this._source.serialize()}prepare(t){this._source.prepare&&this._source.prepare(),this._state.coalesceChanges(this._tiles,this.map?this.map.painter:null);for(const e in this._tiles){const i=this._tiles[e];i.upload(t),i.prepare(this.map.style.imageManager,this.map?this.map.painter:null,this._source.scope)}}getIds(){return ti(this._tiles).map((t=>t.tileID)).sort(Ky).map((t=>t.key))}getRenderableIds(t,e){const i=[];for(const n in this._tiles)this._isIdRenderable(+n,t,e)&&i.push(this._tiles[n]);return t?i.sort(((t,e)=>{const i=t.tileID,n=e.tileID,r=new Ue(i.canonical.x,i.canonical.y)._rotate(this.transform.angle),o=new Ue(n.canonical.x,n.canonical.y)._rotate(this.transform.angle);return i.overscaledZ-n.overscaledZ||o.y-r.y||o.x-r.x})).map((t=>t.tileID.key)):i.map((t=>t.tileID)).sort(Ky).map((t=>t.key))}hasRenderableParent(t){const e=this.findLoadedParent(t,0);return!!e&&this._isIdRenderable(e.tileID.key)}_isIdRenderable(t,e,i){return this._tiles[t]&&this._tiles[t].hasData()&&!this._coveredTiles[t]&&(e||!this._tiles[t].holdingForFade())&&(i||!this._shadowCasterTiles[t])}reload(){if(this._paused)this._shouldReloadOnResume=!0;else{this._cache.reset();for(const t in this._tiles)"errored"!==this._tiles[t].state&&this._reloadTile(+t,"reloading")}}_reloadTile(t,e){const i=this._tiles[t];i&&("loading"!==i.state&&(i.state=e),this._loadTile(i,this._tileLoaded.bind(this,i,t,e)))}_tileLoaded(t,e,i,n){if(n)if(t.state="errored",404!==n.status)this._source.fire(new $n(n,{tile:t}));else{if(!(t.tileID.key in this._loadedParentTiles))return void this._source.fire(new Pn("data",{dataType:"source",sourceDataType:"error",sourceId:this._source.id}));if("raster-dem"===this._source.type&&this.usedForTerrain&&this.map.painter.terrain){const t=this.map.painter.terrain;this.update(this.transform,t.getScaledDemTileSize(),!0),t.resetTileLookupCache(this.id)}else this.update(this.transform)}else t.timeAdded=ki.now(),"expired"===i&&(t.refreshedUponExpiration=!0),this._setTileReloadTimer(e,t),"raster-dem"===this._source.type&&t.dem&&this._backfillDEM(t),this._state.initializeTileState(t,this.map?this.map.painter:null),this._source.fire(new Pn("data",{dataType:"source",tile:t,coord:t.tileID,sourceCacheId:this.id}))}_backfillDEM(t){const e=this.getRenderableIds();for(let n=0;n1||(Math.abs(i)>1&&(1===Math.abs(i+r)?i+=r:1===Math.abs(i-r)&&(i-=r)),e.dem&&t.dem&&(t.dem.backfillBorder(e.dem,i,n),t.neighboringTiles&&t.neighboringTiles[o]&&(t.neighboringTiles[o].backfilled=!0)))}}getTile(t){return this.getTileByID(t.key)}getTileByID(t){return this._tiles[t]}_retainLoadedChildren(t,e,i,n){for(const r in this._tiles){let o=this._tiles[r];if(n[r]||!o.hasData()||o.tileID.overscaledZi)continue;let s=o.tileID;for(;o&&o.tileID.overscaledZ>e+1;){const t=o.tileID.scaledTo(o.tileID.overscaledZ-1);o=this._tiles[t.key],o&&o.hasData()&&(s=t)}let a=s;for(;a.overscaledZ>e;)if(a=a.scaledTo(a.overscaledZ-1),t[a.key]){n[s.key]=s;break}}}findLoadedParent(t,e){if(t.key in this._loadedParentTiles){const i=this._loadedParentTiles[t.key];return i&&i.tileID.overscaledZ>=e?i:null}for(let i=t.overscaledZ-1;i>=e;i--){const e=t.scaledTo(i),n=this._getLoadedTile(e);if(n)return n}}_getLoadedTile(t){const e=this._tiles[t.key];return e&&e.hasData()?e:this._cache.getByKey(this._source.reparseOverscaled?t.wrapped().key:t.canonical.key)}updateCacheSize(t,e){e=e||this._source.tileSize;const i=Math.ceil(t.width/e)+1,n=Math.ceil(t.height/e)+1,r=Math.floor(i*n*5),o="number"==typeof this._minTileCacheSize?Math.max(this._minTileCacheSize,r):r,s="number"==typeof this._maxTileCacheSize?Math.min(this._maxTileCacheSize,o):o;this._cache.setMaxSize(s)}handleWrapJump(t){const e=Math.round((t-(void 0===this._prevLng?t:this._prevLng))/360);if(this._prevLng=t,e){const t={};for(const i in this._tiles){const n=this._tiles[i];n.tileID=n.tileID.unwrapTo(n.tileID.wrap+e),t[n.tileID.key]=n}this._tiles=t;for(const t in this._timers)clearTimeout(this._timers[t]),delete this._timers[t];for(const t in this._tiles)this._setTileReloadTimer(+t,this._tiles[t])}}update(t,e,i,n){if(this.transform=t,!this._sourceLoaded||this._paused||this.transform.freezeTileCoverage)return;if(this.usedForTerrain&&!i)return;let r;if(this.updateCacheSize(t,e),"globe"!==this.transform.projection.name&&this.handleWrapJump(this.transform.center.lng),this._shadowCasterTiles={},this._coveredTiles={},this.used||this.usedForTerrain){if(this._source.tileID)r=t.getVisibleUnwrappedCoordinates(this._source.tileID).map((t=>new vd(t.canonical.z,t.wrap,t.canonical.z,t.canonical.x,t.canonical.y)));else if(0!==this.tileCoverLift){const n=t.clone();n.tileCoverLift=this.tileCoverLift,r=n.coveringTiles({tileSize:e||this._source.tileSize,minzoom:this._source.minzoom,maxzoom:this._source.maxzoom,roundZoom:this._source.roundZoom&&!i,reparseOverscaled:this._source.reparseOverscaled,isTerrainDEM:this.usedForTerrain}),this._source.minzoomt(e)))}}else r=[];if(r.length>0&&this.castsShadows&&n&&"globe"!==this.transform.projection.name&&!this.usedForTerrain&&!Jy(this._source.type)){const o=t.coveringZoomLevel({tileSize:e||this._source.tileSize,roundZoom:this._source.roundZoom&&!i}),s=Math.min(o,this._source.maxzoom),a=t.extendTileCoverForShadows(r,n,s);for(const t of a)this._shadowCasterTiles[t.key]=!0,r.push(t)}const o=this._updateRetainedTiles(r);if(Jy(this._source.type)&&0!==r.length){const t={},e={},i=Object.keys(o);for(const n of i){const i=o[n],r=this._tiles[n];if(!r||r.fadeEndTime&&r.fadeEndTimen;){r=r.scaledTo(r.overscaledZ-1);const n=this._tiles[r.key];if(n&&n.hasData()&&e[r.key]){o[t]=i.tileID;break}}}for(const e in t)o[e]||(this._coveredTiles[e]=!0,o[e]=t[e])}for(const t in o)this._tiles[t].clearFadeHold();const s=function(t,e){const i=[];for(const n in t)n in e||i.push(n);return i}(this._tiles,o);for(const t of s){const e=this._tiles[t];e.hasSymbolBuckets&&!e.holdingForFade()?e.setHoldDuration(this.map._fadeDuration):e.hasSymbolBuckets&&!e.symbolFadeFinished()||this._removeTile(+t)}this._updateLoadedParentTileCache(),this._onlySymbols&&this._source.afterUpdate&&this._source.afterUpdate()}releaseSymbolFadeTiles(){for(const t in this._tiles)this._tiles[t].holdingForFade()&&this._removeTile(+t)}_updateRetainedTiles(t){const e={};if(0===t.length)return e;const i={},n=t.reduce(((t,e)=>Math.min(t,e.overscaledZ)),1/0),r=t[0].overscaledZ,o=Math.max(r-Xy.maxOverzooming,this._source.minzoom),s=Math.max(r+Xy.maxUnderzooming,this._source.minzoom),a={};for(const i of t){const t=this._addTile(i);e[i.key]=i,t.hasData()||n=this._source.maxzoom){const t=n.children(this._source.maxzoom)[0],i=this.getTile(t);if(i&&i.hasData()){e[t.key]=t;continue}}else{const t=n.children(this._source.maxzoom);if(e[t[0].key]&&e[t[1].key]&&e[t[2].key]&&e[t[3].key])continue}let r=t.wasRequested();for(let s=n.overscaledZ-1;s>=o;--s){const o=n.scaledTo(s);if(i[o.key])break;if(i[o.key]=!0,t=this.getTile(o),!t&&r&&(t=this._addTile(o)),t&&(e[o.key]=o,r=t.wasRequested(),t.hasData()))break}}return e}_updateLoadedParentTileCache(){this._loadedParentTiles={};for(const t in this._tiles){const e=[];let i,n=this._tiles[t].tileID;for(;n.overscaledZ>0;){if(n.key in this._loadedParentTiles){i=this._loadedParentTiles[n.key];break}e.push(n.key);const t=n.scaledTo(n.overscaledZ-1);if(i=this._getLoadedTile(t),i)break;n=t}for(const t of e)this._loadedParentTiles[t]=i}}_addTile(t){let e=this._tiles[t.key];if(e)return!0!==e.isExtraShadowCaster||!!this._shadowCasterTiles[t.key]||this._reloadTile(t.key,"reloading"),e;e=this._cache.getAndRemove(t),e&&(this._setTileReloadTimer(t.key,e),e.tileID=t,this._state.initializeTileState(e,this.map?this.map.painter:null),this._cacheTimers[t.key]&&(clearTimeout(this._cacheTimers[t.key]),delete this._cacheTimers[t.key],this._setTileReloadTimer(t.key,e)));const i=Boolean(e);if(!i){const i=this.map?this.map.painter:null,n=this._source.tileSize*t.overscaleFactor();e="raster-array"===this._source.type?new Wy(t,n,this.transform.tileZoom,i,this._isRaster):new ey(t,n,this.transform.tileZoom,i,this._isRaster),this._loadTile(e,this._tileLoaded.bind(this,e,t.key,e.state))}return e?(e.uses++,this._tiles[t.key]=e,i||this._source.fire(new Pn("dataloading",{tile:e,coord:e.tileID,dataType:"source"})),e):null}_setTileReloadTimer(t,e){t in this._timers&&(clearTimeout(this._timers[t]),delete this._timers[t]);const i=e.getExpiryTimeout();i&&(this._timers[t]=setTimeout((()=>{this._reloadTile(t,"expired"),delete this._timers[t]}),i))}_removeTile(t){const e=this._tiles[t];e&&(e.uses--,delete this._tiles[t],this._timers[t]&&(clearTimeout(this._timers[t]),delete this._timers[t]),e.uses>0||(e.hasData()&&"reloading"!==e.state||"empty"===e.state?this._cache.add(e.tileID,e,e.getExpiryTimeout()):(e.aborted=!0,this._abortTile(e),this._unloadTile(e))))}clearTiles(){this._shouldReloadOnResume=!1,this._paused=!1;for(const t in this._tiles)this._removeTile(+t);this._source._clear&&this._source._clear(),this._cache.reset(),this.map&&this.usedForTerrain&&this.map.painter.terrain&&this.map.painter.terrain.resetTileLookupCache(this.id)}tilesIn(t,e,i){const n=[],r=this.transform;if(!r)return n;const o="globe"===r.projection.name,s=Ed(r.center.lng);for(const a in this._tiles){const l=this._tiles[a];if(i&&l.clearQueryDebugViz(),l.holdingForFade())continue;let c;if(o){const t=l.tileID.canonical;if(0===t.z){const e=[Math.abs(Xe(s,...Qy(t,-1))-s),Math.abs(Xe(s,...Qy(t,1))-s)];c=[0,2*e.indexOf(Math.min(...e))-1]}else{const e=[Math.abs(Xe(s,...Qy(t,-1))-s),Math.abs(Xe(s,...Qy(t,0))-s),Math.abs(Xe(s,...Qy(t,1))-s)];c=[e.indexOf(Math.min(...e))-1]}}else c=[0];for(const i of c){const o=t.containsTile(l,r,e,i);o&&n.push(o)}}return n}getShadowCasterCoordinates(){return this._getRenderableCoordinates(!1,!0)}getVisibleCoordinates(t){return this._getRenderableCoordinates(t)}_getRenderableCoordinates(t,e){const i=this.getRenderableIds(t,e).map((t=>this._tiles[t].tileID)),n="globe"===this.transform.projection.name;for(const t of i)t.projMatrix=this.transform.calculateProjMatrix(t.toUnwrapped()),t.expandedProjMatrix=n?this.transform.calculateProjMatrix(t.toUnwrapped(),!1,!0):t.projMatrix;return i}sortCoordinatesByDistance(t){const e=t.slice(),i=this.transform._camera.position,n=this.transform._camera.forward(),r={};for(const t of e){const e=1/(1r[t.key]-r[e.key])),e}hasTransition(){if(this._source.hasTransition())return!0;if(Jy(this._source.type))for(const t in this._tiles){const e=this._tiles[t];if(void 0!==e.fadeEndTime&&e.fadeEndTime>=ki.now())return!0}return!1}setFeatureState(t,e,i){this._state.updateState(t=t||"_geojsonTileLayer",e,i)}removeFeatureState(t,e,i){this._state.removeFeatureState(t=t||"_geojsonTileLayer",e,i)}getFeatureState(t,e){return this._state.getState(t=t||"_geojsonTileLayer",e)}setDependencies(t,e,i){const n=this._tiles[t];n&&n.setDependencies(e,i)}reloadTilesForDependencies(t,e){for(const i in this._tiles)this._tiles[i].hasDependency(t,e)&&this._reloadTile(+i,"reloading");this._cache.filter((i=>!i.hasDependency(t,e)))}_preloadTiles(t,e){if(!this._sourceLoaded){const i=()=>{this._sourceLoaded&&(this._source.off("data",i),this._preloadTiles(t,e))};return void this._source.on("data",i)}const i=new Map,n=Array.isArray(t)?t:[t],r=this.map.painter.terrain,o=this.usedForTerrain&&r?r.getScaledDemTileSize():this._source.tileSize;for(const t of n){const e=t.coveringTiles({tileSize:o,minzoom:this._source.minzoom,maxzoom:this._source.maxzoom,roundZoom:this._source.roundZoom&&!this.usedForTerrain,reparseOverscaled:this._source.reparseOverscaled,isTerrainDEM:this.usedForTerrain});for(const t of e)i.set(t.key,t);this.usedForTerrain&&t.updateElevation(!1)}Qe(Array.from(i.values()),((t,e)=>{const i=new ey(t,this._source.tileSize*t.overscaleFactor(),this.transform.tileZoom,this.map.painter,this._isRaster);this._loadTile(i,(t=>{"raster-dem"===this._source.type&&i.dem&&this._backfillDEM(i),e(t,i)}))}),e)}}function Ky(t,e){const i=Math.abs(2*t.wrap)-+(t.wrap0?e+2*t:t}tv.useIntegerZoom=!0;const iv=new ol({"symbol-placement":new il(sl.layout_symbol["symbol-placement"]),"symbol-spacing":new il(sl.layout_symbol["symbol-spacing"]),"symbol-avoid-edges":new il(sl.layout_symbol["symbol-avoid-edges"]),"symbol-sort-key":new nl(sl.layout_symbol["symbol-sort-key"]),"symbol-z-order":new il(sl.layout_symbol["symbol-z-order"]),"symbol-z-elevate":new il(sl.layout_symbol["symbol-z-elevate"]),"icon-allow-overlap":new il(sl.layout_symbol["icon-allow-overlap"]),"icon-ignore-placement":new il(sl.layout_symbol["icon-ignore-placement"]),"icon-optional":new il(sl.layout_symbol["icon-optional"]),"icon-rotation-alignment":new il(sl.layout_symbol["icon-rotation-alignment"]),"icon-size":new nl(sl.layout_symbol["icon-size"]),"icon-text-fit":new nl(sl.layout_symbol["icon-text-fit"]),"icon-text-fit-padding":new nl(sl.layout_symbol["icon-text-fit-padding"]),"icon-image":new nl(sl.layout_symbol["icon-image"]),"icon-rotate":new nl(sl.layout_symbol["icon-rotate"]),"icon-padding":new il(sl.layout_symbol["icon-padding"]),"icon-keep-upright":new il(sl.layout_symbol["icon-keep-upright"]),"icon-offset":new nl(sl.layout_symbol["icon-offset"]),"icon-anchor":new nl(sl.layout_symbol["icon-anchor"]),"icon-pitch-alignment":new il(sl.layout_symbol["icon-pitch-alignment"]),"text-pitch-alignment":new il(sl.layout_symbol["text-pitch-alignment"]),"text-rotation-alignment":new il(sl.layout_symbol["text-rotation-alignment"]),"text-field":new nl(sl.layout_symbol["text-field"]),"text-font":new nl(sl.layout_symbol["text-font"]),"text-size":new nl(sl.layout_symbol["text-size"]),"text-max-width":new nl(sl.layout_symbol["text-max-width"]),"text-line-height":new nl(sl.layout_symbol["text-line-height"]),"text-letter-spacing":new nl(sl.layout_symbol["text-letter-spacing"]),"text-justify":new nl(sl.layout_symbol["text-justify"]),"text-radial-offset":new nl(sl.layout_symbol["text-radial-offset"]),"text-variable-anchor":new il(sl.layout_symbol["text-variable-anchor"]),"text-anchor":new nl(sl.layout_symbol["text-anchor"]),"text-max-angle":new il(sl.layout_symbol["text-max-angle"]),"text-writing-mode":new il(sl.layout_symbol["text-writing-mode"]),"text-rotate":new nl(sl.layout_symbol["text-rotate"]),"text-padding":new il(sl.layout_symbol["text-padding"]),"text-keep-upright":new il(sl.layout_symbol["text-keep-upright"]),"text-transform":new nl(sl.layout_symbol["text-transform"]),"text-offset":new nl(sl.layout_symbol["text-offset"]),"text-allow-overlap":new il(sl.layout_symbol["text-allow-overlap"]),"text-ignore-placement":new il(sl.layout_symbol["text-ignore-placement"]),"text-optional":new il(sl.layout_symbol["text-optional"]),visibility:new il(sl.layout_symbol.visibility)});var nv={paint:new ol({"icon-opacity":new nl(sl.paint_symbol["icon-opacity"]),"icon-occlusion-opacity":new nl(sl.paint_symbol["icon-occlusion-opacity"]),"icon-emissive-strength":new nl(sl.paint_symbol["icon-emissive-strength"]),"text-emissive-strength":new nl(sl.paint_symbol["text-emissive-strength"]),"icon-color":new nl(sl.paint_symbol["icon-color"]),"icon-halo-color":new nl(sl.paint_symbol["icon-halo-color"]),"icon-halo-width":new nl(sl.paint_symbol["icon-halo-width"]),"icon-halo-blur":new nl(sl.paint_symbol["icon-halo-blur"]),"icon-translate":new il(sl.paint_symbol["icon-translate"]),"icon-translate-anchor":new il(sl.paint_symbol["icon-translate-anchor"]),"icon-image-cross-fade":new nl(sl.paint_symbol["icon-image-cross-fade"]),"text-opacity":new nl(sl.paint_symbol["text-opacity"]),"text-occlusion-opacity":new nl(sl.paint_symbol["text-occlusion-opacity"]),"text-color":new nl(sl.paint_symbol["text-color"],{runtimeType:Qn,getOverride:t=>t.textColor,hasOverride:t=>!!t.textColor}),"text-halo-color":new nl(sl.paint_symbol["text-halo-color"]),"text-halo-width":new nl(sl.paint_symbol["text-halo-width"]),"text-halo-blur":new nl(sl.paint_symbol["text-halo-blur"]),"text-translate":new il(sl.paint_symbol["text-translate"]),"text-translate-anchor":new il(sl.paint_symbol["text-translate-anchor"]),"icon-color-saturation":new il(sl.paint_symbol["icon-color-saturation"]),"icon-color-contrast":new il(sl.paint_symbol["icon-color-contrast"]),"icon-color-brightness-min":new il(sl.paint_symbol["icon-color-brightness-min"]),"icon-color-brightness-max":new il(sl.paint_symbol["icon-color-brightness-max"])}),layout:iv};class rv{constructor(t){this.type=t.property.overrides?t.property.overrides.runtimeType:Yn,this.defaultValue=t}evaluate(t){if(t.formattedSection){const e=this.defaultValue.property.overrides;if(e&&e.hasOverride(t.formattedSection))return e.getOverride(t.formattedSection)}return t.feature&&t.featureState?this.defaultValue.evaluate(t.feature,t.featureState):this.defaultValue.property.specification.default}eachChild(t){this.defaultValue.isConstant()||t(this.defaultValue.value._styleExpression.expression)}outputDefined(){return!1}serialize(){return null}}ba(rv,"FormatSectionOverride",{omit:["defaultValue"]});class ov extends Ml{constructor(e,i,n,r){super(e,nv,i,n,r),this._colorAdjustmentMatrix=t.ad.identity([]),this.hasInitialOcclusionOpacityProperties=void 0!==e.paint&&("icon-occlusion-opacity"in e.paint||"text-occlusion-opacity"in e.paint)}recalculate(t,e){super.recalculate(t,e),"auto"===this.layout.get("icon-rotation-alignment")&&(this.layout._values["icon-rotation-alignment"]="point"!==this.layout.get("symbol-placement")?"map":"viewport"),"auto"===this.layout.get("text-rotation-alignment")&&(this.layout._values["text-rotation-alignment"]="point"!==this.layout.get("symbol-placement")?"map":"viewport"),"auto"===this.layout.get("text-pitch-alignment")&&(this.layout._values["text-pitch-alignment"]=this.layout.get("text-rotation-alignment")),"auto"===this.layout.get("icon-pitch-alignment")&&(this.layout._values["icon-pitch-alignment"]=this.layout.get("icon-rotation-alignment"));const i=this.layout.get("text-writing-mode");if(i){const t=[];for(const e of i)t.indexOf(e)i in t?String(t[i]):""))}(e.properties,r)}createBucket(t){return new jg(t)}queryRadius(){return 0}queryIntersectsFeature(){return!1}_setPaintOverrides(){for(const t of nv.paint.overridableProperties){if(!ov.hasPaintOverride(this.layout,t))continue;const e=this.paint.get(t),i=new rv(e),n=new la(i,e.property.specification,this.scope,this.options);let r=null;r="constant"===e.value.kind||"source"===e.value.kind?new ua("source",n):new ha("composite",n,e.value.zoomStops,e.value._interpolationType),this.paint._values[t]=new tl(e.property,r,e.parameters)}}_handleOverridablePaintPropertyUpdate(t,e,i){return!(!this.layout||e.isDataDriven()||i.isDataDriven())&&ov.hasPaintOverride(this.layout,t)}static hasPaintOverride(t,e){const i=t.get("text-field"),n=nv.paint.properties[e];let r=!1;const o=t=>{for(const e of t)if(n.overrides&&n.overrides.hasOverride(e))return void(r=!0)};if("constant"===i.value.kind&&i.value.value instanceof pr)o(i.value.value.sections);else if("source"===i.value.kind){const t=e=>{r||(e instanceof vr&&gr(e.value)===nr?o(e.value.sections):e instanceof Tr?o(e.sections):e.eachChild(t))},e=i.value;e._styleExpression&&t(e._styleExpression.expression)}return r}getProgramIds(){const t=0!==this.paint.get("icon-opacity").constantOr(1),e=0!==this.paint.get("text-opacity").constantOr(1),i=[];return t&&i.push("symbolIcon"),e&&i.push("symbolSDF"),i}getDefaultProgramParams(t,e,i){return{config:new Wc(this,{zoom:e,lut:i}),overrideFog:!1}}}const sv=new ol({visibility:new il(sl.layout_background.visibility)});var av={paint:new ol({"background-color":new il(sl.paint_background["background-color"]),"background-pattern":new il(sl.paint_background["background-pattern"]),"background-opacity":new il(sl.paint_background["background-opacity"]),"background-emissive-strength":new il(sl.paint_background["background-emissive-strength"])}),layout:sv};const lv=new ol({visibility:new il(sl.layout_raster.visibility)});var cv={paint:new ol({"raster-opacity":new il(sl.paint_raster["raster-opacity"]),"raster-color":new rl(sl.paint_raster["raster-color"]),"raster-color-mix":new il(sl.paint_raster["raster-color-mix"]),"raster-color-range":new il(sl.paint_raster["raster-color-range"]),"raster-hue-rotate":new il(sl.paint_raster["raster-hue-rotate"]),"raster-brightness-min":new il(sl.paint_raster["raster-brightness-min"]),"raster-brightness-max":new il(sl.paint_raster["raster-brightness-max"]),"raster-saturation":new il(sl.paint_raster["raster-saturation"]),"raster-contrast":new il(sl.paint_raster["raster-contrast"]),"raster-resampling":new il(sl.paint_raster["raster-resampling"]),"raster-fade-duration":new il(sl.paint_raster["raster-fade-duration"]),"raster-emissive-strength":new il(sl.paint_raster["raster-emissive-strength"]),"raster-array-band":new il(sl.paint_raster["raster-array-band"]),"raster-elevation":new il(sl.paint_raster["raster-elevation"])}),layout:lv};function dv(e,i,n,r,o,s,a,l){const c=[e,i,1,n,r,1,o,s,1],d=[a,l,1],u=t.bC.adjoint([],c),[h,p,f]=t._.transformMat3(d,d,u);return t.bC.multiply(c,c,[h,0,0,0,p,0,0,0,f])}function uv(e,i,n,r,o,s,a,l){const c=function(e,i,n,r,o,s,a,l){const c=dv(0,0,1,0,1,1,0,1),d=dv(e,i,n,r,o,s,a,l),u=t.bC.adjoint([],c);return t.bC.multiply(d,d,u)}(e,i,n,r,o,s,a,l);return[c[2]/c[8]/uo,c[5]/c[8]/uo]}function hv(t){return[t[0],Math.min(Math.max(t[1],-Pd),Pd)]}class pv extends zn{constructor(t,e,i,n){super(),this.id=t,this.dispatcher=i,this.coordinates=e.coordinates,this.type="image",this.minzoom=0,this.maxzoom=22,this.tileSize=512,this.tiles={},this._loaded=!1,this.onNorthPole=!1,this.onSouthPole=!1,this.setEventedParent(n),this.options=e,this._dirty=!1}load(t,e){if(this._loaded=e||!1,this.fire(new Pn("dataloading",{dataType:"source"})),this.url=this.options.url,!this.url)return t&&(this.coordinates=t),this._loaded=!0,void this._finishLoading();this._imageRequest=an(this.map._requestManager.transformRequest(this.url,Ki.Image),((e,i)=>{this._imageRequest=null,this._loaded=!0,e?this.fire(new $n(e)):i&&(this.image=i instanceof HTMLImageElement?ki.getImageData(i):i,this._dirty=!0,this.width=this.image.width,this.height=this.image.height,t&&(this.coordinates=t),this._finishLoading())}))}loaded(){return this._loaded}updateImage(t){return t.url?(this._imageRequest&&t.url!==this.options.url&&(this._imageRequest.cancel(),this._imageRequest=null),this.options.url=t.url,this.load(t.coordinates,this._loaded),this):this}setTexture(t){if(!(t.handle instanceof WebGLTexture))throw new Error("The provided handle is not a WebGLTexture instance");return this.texture=new Gg(this.map.painter.context,t.handle),this.width=t.dimensions[0],this.height=t.dimensions[1],this._dirty=!1,this._loaded=!0,this._finishLoading(),this}_finishLoading(){this.map&&(this.setCoordinates(this.coordinates),this.fire(new Pn("data",{dataType:"source",sourceDataType:"metadata"})))}onAdd(t){this.map=t,this.load()}onRemove(t){this._imageRequest&&(this._imageRequest.cancel(),this._imageRequest=null),!this.texture||this.texture instanceof Gg||this.texture.destroy(),this.boundsBuffer&&(this.boundsBuffer.destroy(),this.elevatedGlobeVertexBuffer&&this.elevatedGlobeVertexBuffer.destroy(),this.elevatedGlobeIndexBuffer&&this.elevatedGlobeIndexBuffer.destroy())}setCoordinates(t){if(this.coordinates=t,this._boundsArray=void 0,this._unsupportedCoords=!1,!t.length)return this;this.onNorthPole=!1,this.onSouthPole=!1;let e=t[0][1],i=t[0][1];for(const n of t)n[1]>i&&(i=n[1]),n[1]Pd?this.onNorthPole=!0:n1&&(l-=1),new gd(s,l,Math.floor((i+r)/2*a))}(e),this.minzoom=this.maxzoom=this.tileID.z}return this.fire(new Pn("data",{dataType:"source",sourceDataType:"content"})),this}_clear(){this._boundsArray=void 0,this._unsupportedCoords=!1}_prepareData(e){for(const t in this.tiles){const e=this.tiles[t];"loaded"!==e.state&&(e.state="loaded",e.texture=this.texture)}if(this._boundsArray||this.onNorthPole||this.onSouthPole||this._unsupportedCoords)return;const i=eg(new gd(0,0,0),this.map.transform.projection),n=[i.projection.project(this.coordinates[0][0],this.coordinates[0][1]),i.projection.project(this.coordinates[1][0],this.coordinates[1][1]),i.projection.project(this.coordinates[2][0],this.coordinates[2][1]),i.projection.project(this.coordinates[3][0],this.coordinates[3][1])];if(!function(t){const e=t[1].x-t[0].x,i=t[1].y-t[0].y,n=t[2].x-t[1].x,r=t[2].y-t[1].y,o=t[3].x-t[2].x,s=t[3].y-t[2].y,a=t[0].x-t[3].x,l=t[0].y-t[3].y,c=e*r-n*i,d=n*s-o*r,u=o*l-a*s,h=a*i-e*l;return c>0&&d>0&&u>0&&h>0||c{const e=r.projection.project(t[0],t[1]);return ig(r,e)._round()}));this.perspectiveTransform=uv(o.x,o.y,s.x,s.y,a.x,a.y,l.x,l.y);const c=this._boundsArray=new Dl;c.emplaceBack(o.x,o.y,0,0),c.emplaceBack(s.x,s.y,uo,0),c.emplaceBack(l.x,l.y,0,uo),c.emplaceBack(a.x,a.y,uo,uo),this.boundsBuffer&&(this.boundsBuffer.destroy(),this.elevatedGlobeVertexBuffer&&this.elevatedGlobeVertexBuffer.destroy(),this.elevatedGlobeIndexBuffer&&this.elevatedGlobeIndexBuffer.destroy()),this.boundsBuffer=e.createVertexBuffer(c,Jg.members),this.boundsSegments=wc.simpleSegment(0,0,4,2);const d=[],u=function(t){return[hv(t[0]),hv(t[1]),hv(t[2]),hv(t[3])]}(this.coordinates),[h,p,f,m]=function(t){let e=t[0][0],i=e,n=t[0][1],r=n;for(let o=1;oi&&(i=t[o][0]),t[o][1]r&&(r=t[o][1]);return[e,n,i-e,r-n]}(u);{const r=new Dl,[o,s,a,l]=function(t){let e=t[0].x,i=e,n=t[0].y,r=n;for(let o=1;oi&&(i=t[o].x),t[o].yr&&(r=t[o].y);return[e,n,i-e,r-n]}(n),c=t=>[(t.x-o)/a,(t.y-s)/l],[u,_,g,y]=n.map(c),v=function(e,i,n,r,o,s,a,l){const c=dv(0,0,1,0,1,1,0,1),d=dv(e,i,n,r,o,s,a,l),u=t.bC.adjoint([],d);return t.bC.multiply(c,c,u)}(u[0],u[1],_[0],_[1],g[0],g[1],y[0],y[1]);this.elevatedGlobePerspectiveTransform=uv(u[0],u[1],_[0],_[1],g[0],g[1],y[0],y[1]);const x=(e,i)=>{d.push(e.lng);const n=Math.round((e.lng-h)/f*uo),o=Math.round((e.lat-p)/m*uo),s=c(i),a=t._.transformMat3([],[s[0],s[1],1],v),l=Math.round(a[0]/a[2]*uo),u=Math.round(a[1]/a[2]*uo);r.emplaceBack(n,o,l,u)},b=n[3].x-n[0].x,w=n[3].y-n[0].y,T=n[2].x-n[1].x,S=n[2].y-n[1].y;for(let t=0;t{i.emplaceBack(e,n,r);const o=d[e],s=d[n],a=d[r],l=Math.min(Math.min(o,s),a),c=Math.max(Math.max(o,s),a)-l;c>this.maxLongitudeTriangleSize&&(this.maxLongitudeTriangleSize=c),t.push(l+c/2)};for(let t=0;te));i.sort(((e,i)=>t[e]-t[i]));const n=[],r=new Kl;for(let o=0;o{o.segments.push({vertexOffset:0,primitiveOffset:t,vertexLength:e.segments[0].vertexLength,primitiveLength:i,sortKey:void 0,vaos:{}})},a=.51*this.maxLongitudeTriangleSize;if(Math.abs(i[0]-n)0){const n=function(e,i){const n=i.worldSize,r=Cd(1,0)*n*kd(i.center.lat,i.zoom)/Gu(n),o=Cd(1,i.center.lat)*n,s=t.ad.identity([]);return t.ad.rotateY(s,s,Ge(i.center.lng)),t.ad.rotateX(s,s,Ge(i.center.lat)),t.ad.translate(s,s,[0,0,ed]),t.ad.scale(s,s,[r,r,r*o]),t.ad.translate(s,s,[i.point.x-.5*n,i.point.y-.5*n,0]),t.ad.multiply(s,s,e),t.ad.multiply(s,i.globeMatrix,s)}(e,i);return function(e,i,n){const r=(e,i,n)=>{const r=t._.length(e),o=t._.length(i),s=ku(e,i,n);return t._.scale(s,s,1/t._.length(s)*Vn(r,o,n))},o=r([e[0],e[1],e[2]],[i[0],i[1],i[2]],n),s=r([e[4],e[5],e[6]],[i[4],i[5],i[6]],n),a=r([e[8],e[9],e[10]],[i[8],i[9],i[10]],n),l=ku([e[12],e[13],e[14]],[i[12],i[13],i[14]],n);return[o[0],o[1],o[2],0,s[0],s[1],s[2],0,a[0],a[1],a[2],0,l[0],l[1],l[2],1]}(o,n,r)}return o}function kv(t,e,i,n){const r=wu.projectAabbCorners(n,i);let o=Number.MAX_VALUE,s=-1;for(let t=0;tnew Ue(r[t][0],r[t][1]);let l;switch(s){case 0:case 6:l=[a(1),a(5),a(4),a(7),a(3),a(2),a(1)];break;case 1:case 7:l=[a(0),a(4),a(5),a(6),a(2),a(3),a(0)];break;case 3:case 5:l=[a(1),a(0),a(4),a(7),a(6),a(2),a(1)];break;default:l=[a(1),a(5),a(6),a(7),a(3),a(0),a(1)]}if(Yd(t,l))return o}const Dv=Ll([{name:"a_pos_3f",components:3,type:"Float32"}]),zv=Ll([{name:"a_color_3f",components:3,type:"Float32"}]),Rv=Ll([{name:"a_color_4f",components:4,type:"Float32"}]),Ov=Ll([{name:"a_uv_2f",components:2,type:"Float32"}]),Bv=Ll([{name:"a_normal_3f",components:3,type:"Float32"}]),Fv=Ll([{name:"a_normal_matrix0",components:4,type:"Float32"},{name:"a_normal_matrix1",components:4,type:"Float32"},{name:"a_normal_matrix2",components:4,type:"Float32"},{name:"a_normal_matrix3",components:4,type:"Float32"}]),Nv=Ll([{name:"a_pbr",components:4,type:"Uint16"},{name:"a_heightBasedEmissiveStrength",components:3,type:"Float32"}]);class Uv{constructor(t,e,i,n){this.message=(t?`${t}: `:"")+i,n&&(this.identifier=n),null!=e&&e.__line__&&(this.line=e.__line__)}}function jv(t,e){const i=-1===t.indexOf("://");try{return new URL(t,i&&e?"http://example.com":void 0),!0}catch(t){return!1}}class Vv{constructor(t,e){this.feature=t,this.instancedDataOffset=e,this.instancedDataCount=0,this.rotation=[0,0,0],this.scale=[1,1,1],this.translation=[0,0,0]}}class Gv{constructor(){this.instancedDataArray=new oc,this.instancesEvaluatedElevation=[],this.features=[],this.idToFeaturesIndex={}}}class Zv{constructor(t){this.zoom=t.zoom,this.canonical=t.canonical,this.layers=t.layers,this.layerIds=this.layers.map((t=>t.fqid)),this.projection=t.projection,this.index=t.index,this.hasZoomDependentProperties=this.layers[0].isZoomDependent(),this.stateDependentLayerIds=this.layers.filter((t=>t.isStateDependent())).map((t=>t.id)),this.hasPattern=!1,this.instancesPerModel={},this.validForExaggeration=0,this.maxVerticalOffset=0,this.maxScale=0,this.maxHeight=0,this.lookupDim=this.zoom>this.canonical.z?256:this.zoom>15?75:100,this.instanceCount=0,this.terrainElevationMin=0,this.terrainElevationMax=0,this.validForDEMTile={id:null,timestamp:0},this.modelUris=[],this.modelsRequested=!1,this.activeReplacements=[],this.replacementUpdateTime=0}updateFootprints(t,e){}populate(t,e,i,n){this.tileToMeter=zd(i);const r=this.layers[0]._featureFilter.needGeometry;this.lookup=new Uint8Array(this.lookupDim*this.lookupDim);for(const{feature:o,id:s,index:a,sourceLayerIndex:l}of t){const t=null!=s?s:o.properties&&o.properties.hasOwnProperty("id")?o.properties.id:void 0,c=Zd(o,r);if(!this.layers[0]._featureFilter.filter(new Ha(this.zoom),c,i))continue;const d={id:t,sourceLayerIndex:l,index:a,geometry:r?c.geometry:Gd(o,i,n),properties:o.properties,type:o.type,patterns:{}},u=this.addFeature(d,d.geometry,c);u&&e.featureIndex.insert(o,d.geometry,a,l,this.index,this.instancesPerModel[u].instancedDataArray.length,uo/32)}this.lookup=null}update(t,e,i,n){for(const e in this.instancesPerModel){const i=this.instancesPerModel[e];for(const e in t)i.idToFeaturesIndex.hasOwnProperty(e)&&(this.evaluate(i.features[i.idToFeaturesIndex[e]],t[e],i,!0),this.uploaded=!1)}this.maxHeight=0}updateZoomBasedPaintProperties(){if(!this.hasZoomDependentProperties)return!1;let e=!1;for(const i in this.instancesPerModel){const n=this.instancesPerModel[i];for(const i of n.features){const r=this.layers[0],o=i.feature,s=this.canonical,a=r.paint.get("model-rotation").evaluate(o,{},s),l=r.paint.get("model-scale").evaluate(o,{},s),c=r.paint.get("model-translation").evaluate(o,{},s);t._.exactEquals(i.rotation,a)&&t._.exactEquals(i.scale,l)&&t._.exactEquals(i.translation,c)||(this.evaluate(i,i.featureStates,n,!0),e=!0)}}return e}updateReplacement(t,e,i){if(e.updateTime===this.replacementUpdateTime)return!1;this.replacementUpdateTime=e.updateTime;const n=e.getReplacementRegionsForTile(t.toUnwrapped(),!0);if(Pp(this.activeReplacements,n))return!1;this.activeReplacements=n;let r=!1;for(const e in this.instancesPerModel){const n=this.instancesPerModel[e],o=n.instancedDataArray;for(const e of n.features){const n=e.instancedDataOffset,s=e.instancedDataCount;for(let e=0;euo?a-uo:a;const l=Math.floor(a),c=o.float32[s+1];let d=!1;for(const e of this.activeReplacements)if(!(e.orderl||l>e.max.x||e.min.y>c||c>e.max.y)&&(d=Op(Rp(l,c,t.canonical,e.footprintTileId.canonical),e),d))break;o.float32[s]=d?a+uo:a,r=r||d}}}return r}isEmpty(){for(const t in this.instancesPerModel)if(0!==this.instancesPerModel[t].instancedDataArray.length)return!1;return!0}uploadPending(){return!this.uploaded}upload(t){if(!this.uploaded)for(const e in this.instancesPerModel){const i=this.instancesPerModel[e];i.instancedDataArray.length=uo||e.y=uo)continue;const t=(this.lookupDim-1)/uo,i=this.lookupDim*(e.y*t|0)+e.x*t|0;if(this.lookup){if(0!==this.lookup[i])continue;this.lookup[i]=1}this.instanceCount++;const n=s.length;s.resize(n+1),o.instancesEvaluatedElevation.push(0),s.float32[16*n]=e.x,s.float32[16*n+1]=e.y}return a.instancedDataCount=o.instancedDataArray.length-a.instancedDataOffset,a.instancedDataCount>0&&(t.id&&(o.idToFeaturesIndex[t.id]=o.features.length),o.features.push(a),this.evaluate(a,{},o,!1)),r}getModelUris(){return this.modelUris}evaluate(t,e,i,n){const r=this.layers[0],o=t.feature,s=this.canonical,a=t.rotation=r.paint.get("model-rotation").evaluate(o,e,s),l=t.scale=r.paint.get("model-scale").evaluate(o,e,s),c=t.translation=r.paint.get("model-translation").evaluate(o,e,s),d=r.paint.get("model-color").evaluate(o,e,s);d.a=r.paint.get("model-color-mix-intensity").evaluate(o,e,s);const u=[];this.maxVerticalOffset10?this.tileToMeter:zd(s,p)),a[o+4]=c[0],a[o+5]=c[1],a[o+6]=c[2]+l,a[o+7]=u[0],a[o+8]=u[1],a[o+9]=u[2],a[o+10]=u[4],a[o+11]=u[5],a[o+12]=u[6],a[o+13]=u[8],a[o+14]=u[9],a[o+15]=u[10],i.instancesEvaluatedElevation[r]=c[2]}}}ba(Zv,"ModelBucket",{omit:["layers"]}),ba(Gv,"PerModelAttributes"),ba(Vv,"ModelFeature");const qv=new ol({visibility:new il(sl.layout_model.visibility),"model-id":new nl(sl.layout_model["model-id"])});var Hv={paint:new ol({"model-opacity":new il(sl.paint_model["model-opacity"]),"model-rotation":new nl(sl.paint_model["model-rotation"]),"model-scale":new nl(sl.paint_model["model-scale"]),"model-translation":new nl(sl.paint_model["model-translation"]),"model-color":new nl(sl.paint_model["model-color"]),"model-color-mix-intensity":new nl(sl.paint_model["model-color-mix-intensity"]),"model-type":new il(sl.paint_model["model-type"]),"model-cast-shadows":new il(sl.paint_model["model-cast-shadows"]),"model-receive-shadows":new il(sl.paint_model["model-receive-shadows"]),"model-ambient-occlusion-intensity":new il(sl.paint_model["model-ambient-occlusion-intensity"]),"model-emissive-strength":new nl(sl.paint_model["model-emissive-strength"]),"model-roughness":new nl(sl.paint_model["model-roughness"]),"model-height-based-emissive-strength-multiplier":new nl(sl.paint_model["model-height-based-emissive-strength-multiplier"]),"model-cutoff-fade-range":new il(sl.paint_model["model-cutoff-fade-range"]),"model-front-cutoff":new il(sl.paint_model["model-front-cutoff"])}),layout:qv};const Wv=64,Yv={CoordinateSpaceTile:1,CoordinateSpaceYUp:2,HasMapboxMeshFeatures:4,HasMeshoptCompression:8};function Xv(e,i,n,r,o,s,a,l,c,d=!1){const u=n.zoom,h=n.project(r),p=kd(r.lat,u),f=1/p;t.ad.identity(e),t.ad.translate(e,e,[h.x+a[0]*f,h.y+a[1]*f,a[2]]);let m=1,_=1;const g=n.worldSize;if(d){if("mercator"===n.projection.name){let e=0;n.elevation&&(e=n.elevation.getAtPointOrZero(new Rd(h.x/g,h.y/g),0));const i=t.aA.transformMat4([],[h.x,h.y,e,1],n.projMatrix)[3]/n.cameraToCenterDistance;m=i,_=i*kd(n.center.lat,u)}else if("globe"===n.projection.name){const i=$v(e,n),o=t.ad.multiply([],n.projMatrix,i),s=[0,0,0,1];t.aA.transformMat4(s,s,o);const a=s[3]/n.cameraToCenterDistance,l=Hu(u),c=n.projection.pixelsPerMeter(r.lat,g)*kd(r.lat,u),d=n.projection.pixelsPerMeter(n.center.lat,g)*kd(n.center.lat,u);m=a/Vn(c,$d(n.center.lat),l),_=a*p/c,m*=d,_*=d}}else m=f;t.ad.scale(e,e,[m,m,_]);const y=[...e],v=i.orientation,x=[];if(Lv(x,[v[0]+o[0],v[1]+o[1],v[2]+o[2]],s),t.ad.multiply(e,y,x),l&&n.elevation){let o=0;const s=[];if(c&&n.elevation){o=function(e,i,n,r,o){const s=i.elevation;if(!s)return 0;const a=wu.projectAabbCorners(n,r),l=Cd(1,o.lat)*i.worldSize,c=function(e,i){const n=[0,0,1],r=[{corners:[0,1,3,2],dotProductWithUp:0},{corners:[1,5,2,6],dotProductWithUp:0},{corners:[0,4,1,5],dotProductWithUp:0},{corners:[2,6,3,7],dotProductWithUp:0},{corners:[4,7,5,6],dotProductWithUp:0},{corners:[0,3,4,7],dotProductWithUp:0}];for(const o of r){const r=e[o.corners[0]],s=e[o.corners[1]],a=e[o.corners[2]],l=[s[0]-r[0],s[1]-r[1],i*(s[2]-r[2])],c=t._.cross(l,l,[a[0]-r[0],a[1]-r[1],i*(a[2]-r[2])]);t._.normalize(c,c),o.dotProductWithUp=t._.dot(c,n)}return r.sort(((t,e)=>t.dotProductWithUp-e.dotProductWithUp)),r[0].corners}(a,l),d=a[c[0]],u=a[c[1]],h=a[c[2]],p=a[c[3]],f=s.getAtPointOrZero(new Rd(d[0]/i.worldSize,d[1]/i.worldSize),0),m=s.getAtPointOrZero(new Rd(u[0]/i.worldSize,u[1]/i.worldSize),0),_=s.getAtPointOrZero(new Rd(h[0]/i.worldSize,h[1]/i.worldSize),0),g=s.getAtPointOrZero(new Rd(p[0]/i.worldSize,p[1]/i.worldSize),0),y=(f+g)/2,v=(m+_)/2;return y>v?m=e.gl.NEAREST_MIPMAP_NEAREST}),t.uploaded=!0,t.image=null)}function Jv(t,e,i){t.indexBuffer=e.createIndexBuffer(t.indexArray,!1,!0),t.vertexBuffer=e.createVertexBuffer(t.vertexArray,Dv.members,!1,!0),t.normalArray&&(t.normalBuffer=e.createVertexBuffer(t.normalArray,Bv.members,!1,!0)),t.texcoordArray&&(t.texcoordBuffer=e.createVertexBuffer(t.texcoordArray,Ov.members,!1,!0)),t.colorArray&&(t.colorBuffer=e.createVertexBuffer(t.colorArray,(12===t.colorArray.bytesPerElement?zv:Rv).members,!1,!0)),t.featureArray&&(t.pbrBuffer=e.createVertexBuffer(t.featureArray,Nv.members,!0)),t.segments=wc.simpleSegment(0,0,t.vertexArray.length,t.indexArray.length);const n=t.material;n.pbrMetallicRoughness.baseColorTexture&&Kv(n.pbrMetallicRoughness.baseColorTexture,e),n.pbrMetallicRoughness.metallicRoughnessTexture&&Kv(n.pbrMetallicRoughness.metallicRoughnessTexture,e),n.normalTexture&&Kv(n.normalTexture,e),n.occlusionTexture&&Kv(n.occlusionTexture,e,i),n.emissionTexture&&Kv(n.emissionTexture,e)}function Qv(t,e,i){if(t.meshes)for(const n of t.meshes)Jv(n,e,i);if(t.children)for(const n of t.children)Qv(n,e,i)}function tx(t){if(t.meshes)for(const e of t.meshes)e.indexArray.destroy(),e.vertexArray.destroy(),e.colorArray&&e.colorArray.destroy(),e.normalArray&&e.normalArray.destroy(),e.texcoordArray&&e.texcoordArray.destroy(),e.featureArray&&e.featureArray.destroy();if(t.children)for(const e of t.children)tx(e)}function ex(t){if(t.meshes)for(const i of t.meshes)i.vertexBuffer&&(i.vertexBuffer.destroy(),i.indexBuffer.destroy(),i.normalBuffer&&i.normalBuffer.destroy(),i.texcoordBuffer&&i.texcoordBuffer.destroy(),i.colorBuffer&&i.colorBuffer.destroy(),i.pbrBuffer&&i.pbrBuffer.destroy(),i.segments.destroy(),i.material&&((e=i.material).pbrMetallicRoughness.baseColorTexture&&e.pbrMetallicRoughness.baseColorTexture.gfxTexture&&e.pbrMetallicRoughness.baseColorTexture.gfxTexture.destroy(),e.pbrMetallicRoughness.metallicRoughnessTexture&&e.pbrMetallicRoughness.metallicRoughnessTexture.gfxTexture&&e.pbrMetallicRoughness.metallicRoughnessTexture.gfxTexture.destroy(),e.normalTexture&&e.normalTexture.gfxTexture&&e.normalTexture.gfxTexture.destroy(),e.emissionTexture&&e.emissionTexture.gfxTexture&&e.emissionTexture.gfxTexture.destroy(),e.occlusionTexture&&e.occlusionTexture.gfxTexture&&e.occlusionTexture.gfxTexture.destroy()));var e;if(t.children)for(const e of t.children)ex(e)}class ix{constructor(t){this._callback=t,this._triggered=!1,"undefined"!=typeof MessageChannel&&(this._channel=new MessageChannel,this._channel.port2.onmessage=()=>{this._triggered=!1,this._callback()})}trigger(){this._triggered||(this._triggered=!0,this._channel?this._channel.port1.postMessage(!0):setTimeout((()=>{this._triggered=!1,this._callback()}),0))}remove(){this._channel=void 0,this._callback=()=>{}}}class nx{constructor(){this.tasks={},this.taskQueue=[],ai(["process"],this),this.invoker=new ix(this.process),this.nextId=0}add(t,e){const i=this.nextId++,n=function({type:t,isSymbolTile:e,zoom:i}){return i=i||0,"message"===t?0:"maybePrepare"!==t||e?"parseTile"!==t||e?"parseTile"===t&&e?300-i:"maybePrepare"===t&&e?400-i:500:200-i:100-i}(e);if(0===n){try{t()}finally{}return null}return this.tasks[i]={fn:t,metadata:e,priority:n,id:i},this.taskQueue.push(i),this.invoker.trigger(),{cancel:()=>{delete this.tasks[i]}}}process(){try{if(this.taskQueue=this.taskQueue.filter((t=>!!this.tasks[t])),!this.taskQueue.length)return;const t=this.pick();if(null===t)return;const e=this.tasks[t];if(delete this.tasks[t],this.taskQueue.length&&this.invoker.trigger(),!e)return;e.fn()}finally{}}pick(){let t=null,e=1/0;for(let i=0;i{i&&delete this.callbacks[s],this.target.postMessage({id:s,type:"",targetMapId:n,sourceMapId:this.mapId})}}}receive(t){const e=t.data,i=e.id;if(i&&(!e.targetMapId||this.mapId===e.targetMapId))if(""===e.type){const t=this.cancelCallbacks[i];delete this.cancelCallbacks[i],t&&t.cancel()}else if(e.mustQueue||gi()){const t=this.callbacks[i],n=this.scheduler.add((()=>this.processTask(i,e)),t&&t.metadata||{type:"message"});n&&(this.cancelCallbacks[i]=n)}else this.processTask(i,e)}processTask(t,e){if(delete this.cancelCallbacks[t],""===e.type){const i=this.callbacks[t];delete this.callbacks[t],i&&(e.error?i(Ea(e.error)):i(null,Ea(e.data)))}else{const i=new Set,n=e.hasCallback?(e,n)=>{this.target.postMessage({id:t,type:"",sourceMapId:this.mapId,error:e?Sa(e):null,data:Sa(n,i)},i)}:t=>{},r=Ea(e.data);if(this.parent[e.type])this.parent[e.type](e.sourceMapId,r,n);else if(this.parent.getWorkerSource){const t=e.type.split(".");this.parent.getWorkerSource(e.sourceMapId,t[0],r.source,r.scope)[t[1]](r,n)}else n(new Error(`Could not find function ${e.type}`))}}remove(){this.scheduler.remove(),this.target.removeEventListener("message",this.receive,!1)}}class ox{constructor(t,e){this.workerPool=t,this.actors=[],this.currentActor=0,this.id=ni();const i=this.workerPool.acquire(this.id);for(let t=0;t{this.ready=!0}))}broadcast(t,e,i){Qe(this.actors,((i,n)=>{i.send(t,e,n)}),i=i||function(){})}getActor(){return this.currentActor=(this.currentActor+1)%this.actors.length,this.actors[this.currentActor]}remove(){this.actors.forEach((t=>{t.remove()})),this.actors=[],this.workerPool.release(this.id)}}ox.Actor=rx;var sx={workerUrl:"",workerClass:null,workerParams:void 0};function ax(){return null!=sx.workerClass?new sx.workerClass:new self.Worker(sx.workerUrl,sx.workerParams)}const lx="mapboxgl_preloaded_worker_pool";class cx{constructor(){this.active={}}acquire(t){if(!this.workers)for(this.workers=[];this.workers.length{t.terminate()})),this.workers=null)}isPreloaded(){return!!this.active[lx]}numActive(){return Object.keys(this.active).length}}let dx;function ux(){return dx||(dx=new cx),dx}cx.workerCount=2;let hx,px,fx,mx,_x,gx=null;function yx(){return gi()&&self.worker&&self.worker.dracoUrl?self.worker.dracoUrl:px||n.DRACO_URL}function vx(){if(gi()&&self.worker&&self.worker.meshoptUrl)return self.worker.meshoptUrl;if(mx)return mx;const t=new Uint8Array([0,97,115,109,1,0,0,0,1,4,1,96,0,0,3,3,2,0,0,5,3,1,0,1,12,1,0,10,22,2,12,0,65,0,65,0,65,0,252,10,0,0,11,7,0,65,0,253,15,26,11]);if("object"!=typeof WebAssembly)throw new Error("WebAssembly not supported, cannot instantiate meshoptimizer");return mx=WebAssembly.validate(t)?n.MESHOPT_SIMD_URL:n.MESHOPT_URL,mx}const xx={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},bx={5120:"DT_INT8",5121:"DT_UINT8",5122:"DT_INT16",5123:"DT_UINT16",5125:"DT_UINT32",5126:"DT_FLOAT32"},wx={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16};function Tx(t,e,i){const n=i.json.bufferViews.length,r=i.buffers.length;e.bufferView=n,i.json.bufferViews[n]={buffer:r,byteLength:t.byteLength},i.buffers[r]=t}const Sx="KHR_draco_mesh_compression";function Ex(t,e){const i=t.extensions&&t.extensions[Sx];if(!i)return;const n=new fx.Decoder,r=$x(e,i.bufferView),o=new fx.Mesh;if(!n.DecodeArrayToMesh(r,r.byteLength,o))throw new Error("Failed to decode Draco mesh");const s=e.json.accessors[t.indices],a=xx[s.componentType],l=s.count*a.BYTES_PER_ELEMENT,c=fx._malloc(l);a===Uint16Array?n.GetTrianglesUInt16Array(o,l,c):n.GetTrianglesUInt32Array(o,l,c),Tx(fx.memory.buffer.slice(c,c+l),s,e),fx._free(c);for(const r of Object.keys(i.attributes)){const s=n.GetAttributeByUniqueId(o,i.attributes[r]),a=e.json.accessors[t.attributes[r]],l=bx[a.componentType],c=a.count*wx[a.type]*xx[a.componentType].BYTES_PER_ELEMENT,d=fx._malloc(c);n.GetAttributeDataArrayForAllPoints(o,s,fx[l],c,d),Tx(fx.memory.buffer.slice(d,d+c),a,e),fx._free(d)}n.destroy(),o.destroy(),delete t.extensions[Sx]}const Mx="EXT_meshopt_compression";function Cx(t,e){if(!t.extensions||!t.extensions[Mx])return;const i=t.extensions[Mx],n=new Uint8Array(e.buffers[i.buffer],i.byteOffset||0,i.byteLength||0),r=new Uint8Array(i.count*i.byteStride);_x.decodeGltfBuffer(r,i.count,i.byteStride,n,i.mode,i.filter),t.buffer=e.buffers.length,t.byteOffset=0,e.buffers[t.buffer]=r.buffer,delete t.extensions[Mx]}const Ax=1179937895,Ix=new TextDecoder("utf8");function Lx(t,e){return new URL(t,e).href}function Px(t,e,i,n){return fetch(Lx(t.uri,n)).then((t=>t.arrayBuffer())).then((t=>{e.buffers[i]=t}))}function $x(t,e){const i=t.json.bufferViews[e];return new Uint8Array(t.buffers[i.buffer],i.byteOffset||0,i.byteLength)}function kx(t,e,i,n){if(t.uri){const r=Lx(t.uri,n);return fetch(r).then((t=>t.blob())).then((t=>createImageBitmap(t))).then((t=>{e.images[i]=t}))}if(void 0!==t.bufferView){const n=$x(e,t.bufferView),r=new Blob([n],{type:t.mimeType});return createImageBitmap(r).then((t=>{e.images[i]=t}))}}function Dx(t,e=0,i){const n={json:null,images:[],buffers:[]};if(new Uint32Array(t,e,1)[0]===Ax){const i=new Uint32Array(t,e);let r=2;const o=(i[r++]>>2)-3,s=i[r++]>>2;if(r++,n.json=JSON.parse(Ix.decode(i.subarray(r,r+s))),r+=s,r{const t=[],e=a&&a.includes(Sx),r=a&&a.includes(Mx);if(e&&t.push(function(){if(!fx)return hx||(hx=function(t){let e,i=null;function n(){e=new Uint8Array(i.buffer)}function r(){throw new Error("Unexpected Draco error.")}const o={a:{a:r,d:function(t,i,n){return e.copyWithin(t,i,i+n)},c:function(t){const r=e.length,o=Math.max(t>>>0,Math.ceil(1.2*r)),s=Math.ceil((o-r)/65536);try{return i.grow(s),n(),!0}catch(t){return!1}},b:r}};return(WebAssembly.instantiateStreaming?WebAssembly.instantiateStreaming(t,o):t.then((t=>t.arrayBuffer())).then((t=>WebAssembly.instantiate(t,o)))).then((t=>{const{Rb:r,Qb:o,P:s,T:a,X:l,Ja:c,La:d,Qa:u,Va:h,Wa:p,eb:f,jb:m,f:_,e:g,yb:y,zb:v,Ab:x,Bb:b,Db:w,Gb:T}=t.instance.exports;i=g;const S=(()=>{let t=0,i=0,n=0,s=0;return a=>{n&&(r(s),r(t),i+=n,n=t=0),t||(i+=128,t=o(i));const l=a.length+7&-8;let c=t;l>=i&&(n=l,c=s=o(l));for(let t=0;t{fx=t,hx=void 0})))}()),r&&t.push(function(){if(_x)return;const t=function(t){let e;const i=WebAssembly.instantiateStreaming(t,{}).then((t=>{e=t.instance,e.exports.__wasm_call_ctors()})),n={NONE:"",OCTAHEDRAL:"meshopt_decodeFilterOct",QUATERNION:"meshopt_decodeFilterQuat",EXPONENTIAL:"meshopt_decodeFilterExp"},r={ATTRIBUTES:"meshopt_decodeVertexBuffer",TRIANGLES:"meshopt_decodeIndexBuffer",INDICES:"meshopt_decodeIndexSequence"};return{ready:i,supported:!0,decodeGltfBuffer(t,i,o,s,a,l){!function(t,e,i,n,r,o,s){const a=t.exports.sbrk,l=n+3&-4,c=a(l*r),d=a(o.length),u=new Uint8Array(t.exports.memory.buffer);u.set(o,d);const h=e(c,n,r,d,o.length);if(0===h&&s&&s(c,l,r),i.set(u.subarray(c,c+n*r)),a(c-a(0)),0!==h)throw new Error(`Malformed buffer data: ${h}`)}(e,e.exports[r[a]],t,i,o,s,e.exports[n[l]])}}}(fetch(vx()));return t.ready.then((()=>{_x=t}))}()),o)for(let e=0;e{if(e&&s)for(const{primitives:t}of s)for(const e of t)Ex(e,n);if(r&&s&&l)for(const t of l)Cx(t,n);return n}))}))}function zx(t,e){const i=t.json.bufferViews[e.bufferView],n=xx[e.componentType];return new n(t.buffers[i.buffer],(e.byteOffset||0)+(i.byteOffset||0),e.count*(i.byteStride&&i.byteStride!==wx[e.type]*n.BYTES_PER_ELEMENT?i.byteStride/n.BYTES_PER_ELEMENT:wx[e.type]))}function Rx(t,e,i,n){const r=xx[e.componentType],o=function(t){switch(t){case Int8Array:return 1/127;case Uint8Array:return 1/255;case Int16Array:return 1/32767;case Uint16Array:return 1/65535;default:return 1}}(r),s=t.json.bufferViews[e.bufferView],a=s.byteStride?s.byteStride/r.BYTES_PER_ELEMENT:wx[e.type],l=i.float32,c=l.length/i.capacity;for(let t=0,i=0;t0){for(let r=0;r0){o.texcoordArray=new ic;const t=e.json.accessors[r.TEXCOORD_0];o.texcoordArray.resize(t.count);const i=zx(e,t);Rx(e,t,o.texcoordArray,i)}if(void 0!==r._FEATURE_ID_RGBA4444){const t=e.json.accessors[r._FEATURE_ID_RGBA4444];e.json.extensionsUsed&&e.json.extensionsUsed.includes("EXT_meshopt_compression")&&(o.featureData=zx(e,t))}void 0!==r._FEATURE_RGBA4444&&(o.featureData=new Uint32Array(zx(e,e.json.accessors[r._FEATURE_RGBA4444]).buffer));const u=t.material;return o.material=function(t,e){const{emissiveFactor:i=[0,0,0],alphaMode:n="OPAQUE",alphaCutoff:r=.5,normalTexture:o,occlusionTexture:s,emissiveTexture:a,doubleSided:l}=t,{baseColorFactor:c=[1,1,1,1],metallicFactor:d=1,roughnessFactor:u=1,baseColorTexture:h,metallicRoughnessTexture:p}=t.pbrMetallicRoughness||{},f=s?e[s.index]:void 0;if(s&&s.extensions&&s.extensions.KHR_texture_transform&&f){const t=s.extensions.KHR_texture_transform;f.offsetScale=[t.offset[0],t.offset[1],t.scale[0],t.scale[1]]}return{pbrMetallicRoughness:{baseColorFactor:new Un(...c),metallicFactor:d,roughnessFactor:u,baseColorTexture:h?e[h.index]:void 0,metallicRoughnessTexture:p?e[p.index]:void 0},doubleSided:l,emissiveFactor:i,alphaMode:n,alphaCutoff:r,normalTexture:o?e[o.index]:void 0,occlusionTexture:f,emissionTexture:a?e[a.index]:void 0,defined:void 0===t.defined}}(void 0!==u?e.json.materials[u]:{defined:!1},i),o}function Bx(e,i,n){const{matrix:r,rotation:o,translation:s,scale:a,mesh:l,extras:c,children:d}=e,u={};if(u.matrix=r||t.ad.fromRotationTranslationScale([],o||[0,0,0,1],s||[0,0,0],a||[1,1,1]),void 0!==l){u.meshes=n[l];const t=u.anchor=[0,0];for(const e of u.meshes){const{min:i,max:n}=e.aabb;t[0]+=i[0]+n[0],t[1]+=i[1]+n[1]}t[0]=Math.floor(t[0]/u.meshes.length/2),t[1]=Math.floor(t[1]/u.meshes.length/2)}if(c&&(c.id&&(u.id=c.id),c.lights&&(u.lights=function(t){if(!t.length)return[];const e=function(t){const e=atob(t),i=new Uint8Array(e.length);for(let t=0;t1&&n[n.length-1].equals(n[0])&&n.pop();let r=0;for(let t=0;t0&&n.reverse();const o=xh(n.flatMap((t=>[t.x,t.y])),[]);return 0===o.length?null:{vertices:n,indices:o}}function Ux(e,i){const n=[],r=[];let o=0;const s=[];for(const a of e){o=n.length;const e=a.vertexArray.float32,l=a.indexArray.uint16;for(let r=0;r0&&([r[t+1],r[t+2]]=[r[t+2],r[t+1]])}return{vertices:n,indices:r}}function jx(t){const e=function(t,e){const i=[],n=WebGL2RenderingContext;if(t.json.textures)for(const r of t.json.textures){const o={magFilter:n.LINEAR,minFilter:n.NEAREST,wrapS:n.REPEAT,wrapT:n.REPEAT};void 0!==r.sampler&&Object.assign(o,t.json.samplers[r.sampler]),i.push({image:e[r.source],sampler:o,uploaded:!1})}return i}(t,t.images),i=function(t,e){const i=[];for(const n of t.json.meshes){const r=[];for(const i of n.primitives)r.push(Ox(i,t,e));i.push(r)}return i}(t,e),{scenes:n,scene:r,nodes:o}=t.json,s=n?n[r||0].nodes:o,a=[];for(const e of s)a.push(Bx(o[e],t,i));return function(t,e,i){const n={},r=new Set;for(let o=0;o0){const e=Array.from(r.values()).sort(((t,e)=>t-e));for(let i=e.length-1;i>=0;i--)t.splice(e[i],1)}}(a,s,t.json.nodes),a}function Vx(t){t.heightmap=new Float32Array(4096),t.heightmap.fill(-1);const e=t.vertexArray.float32,i=t.aabb.min[0]-1,n=t.aabb.min[1]-1,r=Wv/(t.aabb.max[0]-i+2),o=Wv/(t.aabb.max[1]-n+2);for(let s=0;st.heightmap[c*Wv+l]&&(t.heightmap[c*Wv+l]=a)}}function Gx(e,i){const n={};n.indexArray=new Kl,n.indexArray.reserve(4*e.length),n.vertexArray=new Bl,n.vertexArray.reserve(10*e.length),n.colorArray=new Ol,n.vertexArray.reserve(10*e.length);let r=0;for(const o of e){const e=Math.min(10,Math.max(4,1.3*o.height))*i,s=[-o.normal[1],o.normal[0],0],a=Math.min(.29,.1*o.width/o.depth),l=o.width-2*o.depth*i*(a+.01),c=t._.scaleAndAdd([],o.pos,s,l/2),d=t._.scaleAndAdd([],o.pos,s,-l/2),u=[c[0],c[1],c[2]+o.height],h=[d[0],d[1],d[2]+o.height],p=t._.scaleAndAdd([],o.normal,s,a);t._.scale(p,p,e);const f=t._.scaleAndAdd([],o.normal,s,-a);t._.scale(f,f,e),t._.add(p,c,p),t._.add(f,d,f),c[2]+=.1,d[2]+=.1,n.vertexArray.emplaceBack(p[0],p[1],p[2]),n.vertexArray.emplaceBack(f[0],f[1],f[2]),n.vertexArray.emplaceBack(c[0],c[1],c[2]),n.vertexArray.emplaceBack(d[0],d[1],d[2]),n.vertexArray.emplaceBack(u[0],u[1],u[2]),n.vertexArray.emplaceBack(h[0],h[1],h[2]),n.vertexArray.emplaceBack(c[0],c[1],c[2]),n.vertexArray.emplaceBack(d[0],d[1],d[2]),n.vertexArray.emplaceBack(p[0],p[1],p[2]),n.vertexArray.emplaceBack(f[0],f[1],f[2]);const m=l/e/2;n.colorArray.emplaceBack(-m-a,-1,m,.8),n.colorArray.emplaceBack(m+a,-1,m,.8),n.colorArray.emplaceBack(-m,0,m,1.3),n.colorArray.emplaceBack(m,0,m,1.3),n.colorArray.emplaceBack(m+a,-.8,m,.7),n.colorArray.emplaceBack(m+a,-.8,m,.7),n.colorArray.emplaceBack(0,0,m,1.3),n.colorArray.emplaceBack(0,0,m,1.3),n.colorArray.emplaceBack(m+a,-1.2,m,.8),n.colorArray.emplaceBack(m+a,-1.2,m,.8),n.indexArray.emplaceBack(6+r,4+r,8+r),n.indexArray.emplaceBack(7+r,9+r,5+r),n.indexArray.emplaceBack(0+r,1+r,2+r),n.indexArray.emplaceBack(1+r,3+r,2+r),r+=10}const o={defined:!0,emissiveFactor:[0,0,0]},s={};return s.baseColorFactor=Un.white,o.pbrMetallicRoughness=s,n.material=o,n.aabb=new wu([1/0,1/0,1/0],[-1/0,-1/0,-1/0]),n}const Zx=new Float32Array(262144),qx=new Uint8Array(262144);function Hx(t){let e=0;if(t.meshes)for(const i of t.meshes)e=Math.max(e,i.aabb.max[2]);if(t.children)for(const i of t.children)e=Math.max(e,Hx(i));return e}function Wx(t,e,i){if(t.meshes)for(const n of t.meshes)n.aabb.min[0]!==1/0&&i.insert(e,n.aabb.min[0],n.aabb.min[1],n.aabb.max[0],n.aabb.max[1]);if(t.children)for(const n of t.children)Wx(n,e,i)}const Yx=["","wall","door","roof","window","lamp","logo"];class Xx{constructor(t){this.node=t,this.evaluatedRMEA=[[1,0,0,1],[1,0,0,1],[1,0,0,1],[1,0,0,1],[.4,1,0,1],[1,0,0,1],[1,0,0,1]],this.hiddenByReplacement=!1,this.evaluatedScale=[1,1,1],this.evaluatedColor=[],this.emissionHeightBasedParams=[],this.feature={type:"Point",id:t.id,geometry:[],properties:{height:Hx(t)}},this.aabb=this._getLocalBounds()}_getLocalBounds(){if(!this.node.meshes)return new wu([1/0,1/0,1/0],[-1/0,-1/0,-1/0]);if(!this.aabb){let t=0;const e=new wu([1/0,1/0,1/0],[-1/0,-1/0,-1/0]);for(const i of this.node.meshes)this.node.lightMeshIndex!==t&&(i.transformedAabb=wu.applyTransformFast(i.aabb,this.node.matrix),e.encapsulate(i.transformedAabb)),t++;this.aabb=e}return this.aabb}}class Kx{constructor(t,e,i,n,r,o){this.id=e,this.modelTraits|=Yv.CoordinateSpaceTile,this.uploaded=!1,this.hasPattern=!1,i&&(this.modelTraits|=Yv.HasMapboxMeshFeatures),n&&(this.modelTraits|=Yv.HasMeshoptCompression),this.zoom=-1,this.terrainExaggeration=1,this.projection={name:"mercator"},this.replacementUpdateTime=0,this.elevationReadFromZ=255,this.brightness=r,this.dirty=!0,this.needsUpload=!1,this.nodesInfo=[];for(const e of t)this.nodesInfo.push(new Xx(e)),Wx(e,o.featureIndexArray.length,o.grid),o.featureIndexArray.emplaceBack(this.nodesInfo.length-1,0,o.bucketLayerIDs.length-1,0)}updateFootprints(t,e){for(const i of this.getNodesInfo()){const n=i.node;n.footprint&&e.push({footprint:n.footprint,id:t})}}update(){console.log("Update 3D model bucket")}populate(){console.log("populate 3D model bucket")}uploadPending(){return!this.uploaded||this.needsUpload}upload(t){if(!this.needsUpload)return;const e=this.getNodesInfo();for(const i of e){const e=i.node;this.uploaded?this.updatePbrBuffer(e):Qv(e,t,!0)}for(const t of e)tx(t.node);this.uploaded=!0,this.needsUpload=!1}updatePbrBuffer(t){let e=!1;if(!t.meshes)return e;for(const i of t.meshes)i.pbrBuffer&&(i.pbrBuffer.updateData(i.featureArray),e=!0);return e}needsReEvaluation(t,e,i){const n=t.transform.projectionOptions,r=t.style.getBrightness(),o=this.brightness!==r;return!!(!this.uploaded||this.dirty||n.name!==this.projection.name||Jx(i.paint.get("model-color").value,o)||Jx(i.paint.get("model-color-mix-intensity").value,o)||Jx(i.paint.get("model-roughness").value,o)||Jx(i.paint.get("model-emissive-strength").value,o)||Jx(i.paint.get("model-height-based-emissive-strength-multiplier").value,o))&&(this.projection=n,this.brightness=r,!0)}evaluateScale(t,e){if(t.transform.zoom===this.zoom)return;this.zoom=t.transform.zoom;const i=this.getNodesInfo(),n=this.id.canonical;for(const t of i){const i=t.feature;t.evaluatedScale=e.paint.get("model-scale").evaluate(i,{},n)}}evaluate(t){const e=this.getNodesInfo();for(const i of e){if(!i.node.meshes)continue;const e=i.feature,n=i.node.meshes&&i.node.meshes[0].featureData,r=i.evaluatedColor[2],o=i.evaluatedRMEA[2],s=this.id.canonical;if(i.hasTranslucentParts=!1,n){for(let n=0;n=t)continue;const u=Zx[c],h=Math.abs(u);h>a&&(s=u,a=h,l=r,d=e)}if(a>.1){const o=1-(t+.5*Math.abs(l*d))/c;let a=e._dem.get(n,i)+s*o;const u=e._dem.get(n+l,i+d),h=e._dem.get(n-l,i-d,!0);(a-u)*(a-h)>0&&(a=(u+h)/2),Zx[r]=e._dem.set(n,i,a),qx[r]=t}}}}}s&&(e._demTile.needsDEMTextureUpload=!0,e._dem._timestamp=ki.now())}getNodesInfo(){return this.nodesInfo}destroy(){const t=this.getNodesInfo();for(const e of t)tx(e.node),ex(e.node)}isEmpty(){return!this.nodesInfo.length}updateReplacement(t,e){if(e.updateTime===this.replacementUpdateTime)return;this.replacementUpdateTime=e.updateTime;const i=e.getReplacementRegionsForTile(t.toUnwrapped()),n=this.getNodesInfo();for(let t=0;tt.footprint===e.footprint))}}getHeightAtTileCoord(e,i){const n=this.getNodesInfo(),r=[],o=[0,0,0],s=t.ad.identity([]);for(let a=0;ad.max[0]||i>d.max[1])continue;if(!0===l.node.hidden)return{height:0,maxHeight:l.feature.properties.height,hidden:!1,verticalScale:l.evaluatedScale[2]};t.ad.invert(s,l.node.matrix),o[0]=e,o[1]=i,t._.transformMat4(o,o,s);const u=(o[0]-c.aabb.min[0])/(c.aabb.max[0]-c.aabb.min[0])*Wv|0,h=Math.min(63,(o[1]-c.aabb.min[1])/(c.aabb.max[1]-c.aabb.min[1])*Wv|0)*Wv+Math.min(63,u),p=c.heightmap[h];if(!(p0)return{height:void 0,maxHeight:l.feature.properties.height,hidden:l.hiddenByReplacement,verticalScale:l.evaluatedScale[2]}}}}function Jx(t,e){return!t.isLightConstant&&e}function Qx(t,e,i,n,r,o,s,a){let l=(61440&e|(61440&e)>>4)>>8,c=(3840&e|(3840&e)>>4)>>4,d=240&e|(240&e)>>4;i[3]>0&&(l=Vn(l,255*i[0],i[3]),c=Vn(c,255*i[1],i[3]),d=Vn(d,255*i[2],i[3]));const u=l>16&65535,a=o?e>>16&65535:65535&e,l=(15&a)t.polygon)).flat());const g=f?l:null,[y,v]=function(e,i,n,r,o,s,a,l,c,d,u){return"globe"===e.projection.name?function(e,i,n,r,o,s,a,l,c,d,u){const h=[],p=[],f=e.projection.upVectorScale(u,e.center.lat,e.worldSize).metersToTile,m=[0,0,0,1],_=[0,0,0,1],g=(t,e,i,n)=>{t[0]=e,t[1]=i,t[2]=n,t[3]=1},y=Sf();n>0&&(n+=y),r+=y;for(const y of i){const i=[],v=[];for(const h of y){const p=h.x+o.x,y=h.y+o.y,x=e.projection.projectTilePoint(p,y,u),b=e.projection.upVector(u,h.x,h.y);let w=n,T=r;if(a){const t=Pf(p,y,n,r,a,l,c,d);w+=t.base,T+=t.top}0!==n?g(m,x.x+b[0]*f*w,x.y+b[1]*f*w,x.z+b[2]*f*w):g(m,x.x,x.y,x.z),g(_,x.x+b[0]*f*T,x.y+b[1]*f*T,x.z+b[2]*f*T),t._.transformMat4(m,m,s),t._.transformMat4(_,_,s),i.push(new Tp(m[0],m[1],m[2])),v.push(new Tp(_[0],_[1],_[2]))}h.push(i),p.push(v)}return[h,p]}(e,i,n,r,o,s,a,l,c,d,u):a?function(e,i,n,r,o,s,a,l,c){const d=[],u=[],h=[0,0,0,1];for(const p of e){const e=[],f=[];for(const d of p){const u=d.x+r.x,p=d.y+r.y,m=Pf(u,p,i,n,s,a,l,c);h[0]=u,h[1]=p,h[2]=m.base,h[3]=1,t.aA.transformMat4(h,h,o),h[3]=Math.max(h[3],1e-5);const _=new Tp(h[0]/h[3],h[1]/h[3],h[2]/h[3]);h[0]=u,h[1]=p,h[2]=m.top,h[3]=1,t.aA.transformMat4(h,h,o),h[3]=Math.max(h[3],1e-5);const g=new Tp(h[0]/h[3],h[1]/h[3],h[2]/h[3]);e.push(_),f.push(g)}d.push(e),u.push(f)}return[d,u]}(i,n,r,o,s,a,l,c,d):function(t,e,i,n,r){const o=[],s=[],a=r[8]*e,l=r[9]*e,c=r[10]*e,d=r[11]*e,u=r[8]*i,h=r[9]*i,p=r[10]*i,f=r[11]*i;for(const e of t){const t=[],i=[];for(const o of e){const e=o.x+n.x,s=o.y+n.y,m=r[0]*e+r[4]*s+r[12],_=r[1]*e+r[5]*s+r[13],g=r[2]*e+r[6]*s+r[14],y=r[3]*e+r[7]*s+r[15],v=m+a,x=_+l,b=g+c,w=Math.max(y+d,1e-5),T=m+u,S=_+h,E=g+p,M=Math.max(y+f,1e-5);t.push(new Tp(v/w,x/w,b/w)),i.push(new Tp(T/M,S/M,E/M))}o.push(t),s.push(i)}return[o,s]}(i,n,r,o,s)}(s,r,h,u,d,a,g,p,m,s.center.lat,e.tileID.canonical),x=e.queryGeometry;return function(t,e,i){let n=1/0;Kd(i,e)&&(n=Lf(i,e[0]));for(let r=0;r=3)for(let e=0;e>4;if(1!==n)throw new Error(`Got v${n} data when expected v1.`);const r=nb[15&i];if(!r)throw new Error("Unrecognized array type.");const[o]=new Uint16Array(t,2,1),[s]=new Uint32Array(t,4,1);return new rb(s,o,r,t)}constructor(t,e=64,i=Float64Array,n){if(isNaN(t)||t>1;return this.ids[i]=i,this.coords[this._pos++]=t,this.coords[this._pos++]=e,i}finish(){const t=this._pos>>1;if(t!==this.numItems)throw new Error(`Added ${t} items when expected ${this.numItems}.`);return ob(this.ids,this.coords,this.nodeSize,0,this.numItems-1,0),this._finished=!0,this}range(t,e,i,n){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");const{ids:r,coords:o,nodeSize:s}=this,a=[0,r.length-1,0],l=[];for(;a.length;){const c=a.pop()||0,d=a.pop()||0,u=a.pop()||0;if(d-u=t&&a=e&&c>1,p=o[2*h],f=o[2*h+1];p>=t&&p=e&&f=p:n>=f)&&(a.push(h+1),a.push(d),a.push(1-c))}return l}within(t,e,i){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");const{ids:n,coords:r,nodeSize:o}=this,s=[0,n.length-1,0],a=[],l=i*i;for(;s.length;){const c=s.pop()||0,d=s.pop()||0,u=s.pop()||0;if(d-u>1,p=r[2*h],f=r[2*h+1];cb(p,f,t,e)=p:e+i>=f)&&(s.push(h+1),s.push(d),s.push(1-c))}return a}}function ob(t,e,i,n,r,o){if(r-n>1;sb(t,e,s,n,r,o),ob(t,e,i,n,s-1,1-o),ob(t,e,i,s+1,r,1-o)}function sb(t,e,i,n,r,o){for(;r>n;){if(r-n>600){const s=r-n+1,a=i-n+1,l=Math.log(s),c=.5*Math.exp(2*l/3),d=.5*Math.sqrt(l*c*(s-c)/s)*(a-s/2s&&ab(t,e,n,r);as;)l--}e[2*n+o]===s?ab(t,e,n,l):(l++,ab(t,e,l,r)),lr&&(n+=(t[i]-r)*(t[i]-r)),e[i]0&&n[0]0&&n[1]0&&r[0]0&&r[1]0?Math.acos(i/n)*Ve:0;let o=0!==t||0!==e?Math.atan2(-e,-t)*Ve+90:0;return oNi&&(t.getActor().send("enforceCacheSizeLimit",Fi),Vi=0)},t.an=gn,t.ao=class{constructor(t){this.entries={},this.scheduler=t}request(t,e,i,n){const r=this.entries[t]=this.entries[t]||{callbacks:[]};if(r.result){const[t,i]=r.result;return this.scheduler?this.scheduler.add((()=>{n(t,i)}),e):n(t,i),()=>{}}return r.callbacks.push(n),r.cancel||(r.cancel=i(((i,n)=>{r.result=[i,n];for(const t of r.callbacks)this.scheduler?this.scheduler.add((()=>{t(i,n)}),e):t(i,n);setTimeout((()=>delete this.entries[t]),3e3)}))),()=>{r.result||(r.callbacks=r.callbacks.filter((t=>t!==n)),r.callbacks.length||(r.cancel(),delete this.entries[t]))}}},t.ap=function(t,e,i){const n=JSON.stringify(t.request);return t.data&&(this.deduped.entries[n]={result:[null,t.data]}),this.deduped.request(n,{type:"parseTile",isSymbolTile:t.isSymbolTile,zoom:t.tileZoom},(e=>{const n=en(t.request,((t,n,r,o)=>{t?e(t):n&&e(null,{vectorTile:i?void 0:new bp(new Lm(n)),rawData:n,cacheControl:r,expires:o})}));return()=>{n.cancel(),e()}}),e)},t.aq=Dc,t.ar=class extends Lc{constructor(t){super(t),this.current=Fc}set(t,e,i){if(this.fetchUniformLocation(t,e))for(let t=0;t({u_camera_to_center_distance:new $c(t),u_extrude_scale:new Uc(t),u_device_pixel_ratio:new $c(t),u_matrix:new Bc(t),u_inv_rot_matrix:new Bc(t),u_merc_center:new kc(t),u_tile_id:new Dc(t),u_zoom_transition:new $c(t),u_up_dir:new Dc(t),u_emissive_strength:new $c(t)}),t.bJ=t=>({u_matrix:new Bc(t),u_pixels_to_tile_units:new Uc(t),u_device_pixel_ratio:new $c(t),u_units_to_pixels:new kc(t),u_dash_image:new Pc(t),u_gradient_image:new Pc(t),u_image_height:new $c(t),u_texsize:new kc(t),u_tile_units_to_pixels:new $c(t),u_alpha_discard_threshold:new $c(t),u_trim_offset:new kc(t),u_trim_fade_range:new kc(t),u_trim_color:new zc(t),u_emissive_strength:new $c(t)}),t.bK=t=>({u_matrix:new Bc(t),u_texsize:new kc(t),u_pixels_to_tile_units:new Uc(t),u_device_pixel_ratio:new $c(t),u_image:new Pc(t),u_units_to_pixels:new kc(t),u_tile_units_to_pixels:new $c(t),u_alpha_discard_threshold:new $c(t),u_trim_offset:new kc(t)}),t.bL=Yl,t.bM=Hf,t.bN=Om,t.bO=jm,t.bP=G_,t.bQ=c_,t.bR=th,t.bS=(t,e,i,n,r,o)=>{const s=t.transform,a="globe"===s.projection.name;let l;if("map"===o.paint.get("circle-pitch-alignment"))if(a){const t=Zu(s.zoom,e.canonical)*s._pixelsPerMercatorPixel;l=Float32Array.from([t,0,0,t])}else l=s.calculatePixelsToTileUnitsMatrix(i);else l=new Float32Array([s.pixelsToGLUnits[0],0,0,s.pixelsToGLUnits[1]]);const c={u_camera_to_center_distance:t.transform.getCameraToCenterDistance(s.projection),u_matrix:t.translatePosMatrix(e.projMatrix,i,o.paint.get("circle-translate"),o.paint.get("circle-translate-anchor")),u_device_pixel_ratio:ki.devicePixelRatio,u_extrude_scale:l,u_inv_rot_matrix:Qu,u_merc_center:[0,0],u_tile_id:[0,0,0],u_zoom_transition:0,u_up_dir:[0,0,0],u_emissive_strength:o.paint.get("circle-emissive-strength")};if(a){c.u_inv_rot_matrix=n,c.u_merc_center=r,c.u_tile_id=[e.canonical.x,e.canonical.y,1{const s=t.transform;return{u_matrix:rm(t,e,i,n),u_texsize:e.imageAtlasTexture?e.imageAtlasTexture.size:[0,0],u_pixels_to_tile_units:s.calculatePixelsToTileUnitsMatrix(e),u_device_pixel_ratio:r,u_image:0,u_tile_units_to_pixels:nm(e,s),u_units_to_pixels:[1/s.pixelsToGLUnits[0],1/s.pixelsToGLUnits[1]],u_alpha_discard_threshold:0,u_trim_offset:o}},t.bV=(t,e,i,n,r,o,s)=>{const a=t.transform,l=a.calculatePixelsToTileUnitsMatrix(e);return{u_matrix:rm(t,e,i,n),u_pixels_to_tile_units:l,u_device_pixel_ratio:o,u_units_to_pixels:[1/a.pixelsToGLUnits[0],1/a.pixelsToGLUnits[1]],u_dash_image:0,u_gradient_image:1,u_image_height:r,u_texsize:sm(i)&&e.lineAtlasTexture?e.lineAtlasTexture.size:[0,0],u_tile_units_to_pixels:nm(e,t.transform),u_alpha_discard_threshold:0,u_trim_offset:s,u_trim_fade_range:i.paint.get("line-trim-fade-range"),u_trim_color:i.paint.get("line-trim-color").toRenderColor(i.lut).toArray01(),u_emissive_strength:i.paint.get("line-emissive-strength")}},t.bW=oi,t.bX=mh,t.bY=Sf,t.bZ=bd,t.b_=_f,t.ba=function(t,e,i){const n=Hu(i.zoom),r=t.style.map._antialias,o=e.options.extStandardDerivativesForceOff||t.terrain&&t.terrain.exaggeration()>0;return 0===n&&!r&&!o},t.bb=function(e){const i=e.pixelsPerMeter,n=i/Cd(1,e.center.lat),r=t.ad.identity(new Float64Array(16));return t.ad.translate(r,r,[e.point.x,e.point.y,0]),t.ad.scale(r,r,[n,n,i]),Float32Array.from(r)},t.bc=Ou,t.bd=function(t){const e=Pd-5;t=Xe(t,-e,e)/e*90;const i=Math.pow(Math.abs(Math.sin(Ge(t))),3);return Math.round(i*(sd.length-1))},t.be=function(e,i,n,r){const o=i.getNorth(),s=i.getSouth(),a=i.getWest(),l=i.getEast(),c=10){const e=180/r;t.bC.multiply(f,f,[e/d+1,0,0,0,e/u+1,0,-.5*e/h,.5*e/p,1])}return f[2]=c,f[5]=e.x,f[8]=e.y,f},t.bf=ju,t.bg=$u,t.bh=function(e,i,n){const r=t.ad.identity(new Float64Array(16)),o=(i/(1{}}},t.bo=Gg,t.bp=ai,t.bq=class{isDataAvailableAtPoint(t){const e=this._source();if(this.isUsingMockSource()||!e||t.y1)return!1;const i=e.getSource().maxzoom,n=11)return e;const r=n.getSource().maxzoom,o=1{const s=this.getAtTileOffset(e,o.x,o.y),a=r.upVector(e.canonical,o.x,o.y),l=r.upVectorScale(e.canonical,i,n).metersToTile;return t._.scale(a,a,s*l),a}}getForTilePoints(t,e,i,n){if(this.isUsingMockSource())return!1;const r=Xp.create(this,t,n);return!!r&&(e.forEach((t=>{t[2]=this.exaggeration()*r.getElevationAt(t[0],t[1],i)})),!0)}getMinMaxForTile(t){if(this.isUsingMockSource())return null;const e=this.findDEMTileFor(t);if(!e||!e.dem)return null;const i=e.dem.tree,n=e.tileID,r=1=0?t.slice(0,e):t},t.cV=function(t){return t.indexOf(wl)>=0},t.cW=function(t){const e=t.indexOf(wl);return e>=0?t.slice(e+1):""},t.cX=function(t){const e=[],i=t.id;return void 0===i&&e.push({message:`layers.${i}: missing required property "id"`}),void 0===t.render&&e.push({message:`layers.${i}: missing required method "render"`}),t.renderingMode&&"2d"!==t.renderingMode&&"3d"!==t.renderingMode&&e.push({message:`layers.${i}: property "renderingMode" must be either "2d" or "3d"`}),e},t.cY=function(t,e,i,n){return"custom"===t.type?new vv(t,e):new ib[t.type](t,e,i,n)},t.cZ=di,t.c_=Va,t.ca=1,t.cb=Ag,t.cc=0,t.cd=ec,t.ce=function(t,e,i,n,r){return Xe((t-e)/(i-e)*(r-n)+n,n,r)},t.cf=Ns,t.cg=kd,t.ch=class{constructor(t,e,i,n){this.context=t,this.format=n,this.size=i,this.texture=t.gl.createTexture();const[r,o,s]=this.size,{gl:a}=t;a.bindTexture(a.TEXTURE_3D,this.texture),t.pixelStoreUnpackFlipY.set(!1),t.pixelStoreUnpack.set(1),t.pixelStoreUnpackPremultiplyAlpha.set(!1);let l=this.format,c=a.UNSIGNED_BYTE;this.format===a.DEPTH_COMPONENT&&(l=a.DEPTH_COMPONENT16,c=a.UNSIGNED_SHORT),this.format===a.R8&&(n=a.RED),this.format===a.R32F&&(c=a.FLOAT,n=a.RED),a.texImage3D(a.TEXTURE_3D,0,l,r,o,s,0,n,c,e.data)}bind(t,e){const{context:i}=this,{gl:n}=i;n.bindTexture(n.TEXTURE_3D,this.texture),t!==this.minFilter&&(n.texParameteri(n.TEXTURE_3D,n.TEXTURE_MAG_FILTER,t),n.texParameteri(n.TEXTURE_3D,n.TEXTURE_MIN_FILTER,t),this.minFilter=t),e!==this.wrapS&&(n.texParameteri(n.TEXTURE_3D,n.TEXTURE_WRAP_S,e),n.texParameteri(n.TEXTURE_3D,n.TEXTURE_WRAP_T,e),this.wrapS=e)}destroy(){const{gl:t}=this.context;t.deleteTexture(this.texture),this.texture=null}},t.ci=$v,t.cj=[1,1,1],t.ck=Xp,t.cl=Yv,t.cm=ql,t.cn=ic,t.co=class{constructor(){this._updateTime=0,this._sourceIds=[],this._activeRegions=[],this._prevRegions=[],this._globalClipBounds={min:new Ue(1/0,1/0),max:new Ue(-1/0,-1/0)}}clear(){this._activeRegions.length>0&&++this._updateTime,this._activeRegions=[],this._prevRegions=[]}get updateTime(){return this._updateTime}getReplacementRegionsForTile(t,e=!1){const i=$p(new Ue(0,0),new Ue(uo,uo),t),n=[];if(e&&!Lp(i,this._globalClipBounds))return n;for(const e of this._activeRegions){if(e.hiddenByOverlap)continue;if(!Lp(i,e))continue;const r=kp(e.min,e.max,t);n.push({min:r.min,max:r.max,sourceId:this._sourceIds[e.priority],footprint:e.footprint,footprintTileId:e.tileId,order:e.order,clipMask:e.clipMask})}return n}setSources(t){this._setSources(t.map((t=>({getSourceId:()=>t.cache.id,getFootprints:()=>{const e=[];for(const i of t.cache.getVisibleCoordinates()){const n=t.cache.getTile(i).buckets[t.layer];n&&n.updateFootprints(i.toUnwrapped(),e)}return e},getOrder:()=>t.order,getClipMask:()=>t.clipMask}))))}_addSource(t){const e=t.getFootprints();if(0===e.length)return;const i=t.getOrder(),n=t.getClipMask();for(const t of e){if(!t.footprint)continue;const e=$p(t.footprint.min,t.footprint.max,t.id);this._activeRegions.push({min:e.min,max:e.max,hiddenByOverlap:!1,priority:this._sourceIds.length,tileId:t.id,footprint:t.footprint,order:i,clipMask:n})}this._sourceIds.push(t.getSourceId())}_computeReplacement(){this._activeRegions.sort(((t,e)=>t.priority-e.priority||Ap(t.min,e.min)||Ap(t.max,e.max)));let t=this._activeRegions.length!==this._prevRegions.length;if(!t){let e=0;for(;!t&&e!==this._activeRegions.length;){const i=this._activeRegions[e],n=this._prevRegions[e];t=i.priority!==n.priority||!Ip(i,n)||i.order!==n.order||i.clipMask!==n.clipMask,++e}}if(t){++this._updateTime;for(const t of this._activeRegions)t.order!==1/0&&(this._globalClipBounds.min.x=Math.min(this._globalClipBounds.min.x,t.min.x),this._globalClipBounds.min.y=Math.min(this._globalClipBounds.min.y,t.min.y),this._globalClipBounds.max.x=Math.max(this._globalClipBounds.max.x,t.max.x),this._globalClipBounds.max.y=Math.max(this._globalClipBounds.max.y,t.max.y));const t=t=>{const e=this._activeRegions;if(t>=e.length)return t;const i=e[t].priority;for(;t1){let e=0,i=t(e);for(;e!==i;){let n=e;const r=e;for(;n!==i;){const t=this._activeRegions[n];t.hiddenByOverlap=!1;for(let e=0;e=0;e--)this._addSource(t[e]);this._computeReplacement()}},t.cp=Dl,t.cq=Jg,t.cr=rc,t.cs=class{constructor(t){this._createGrid(t),this._createPoles(t)}destroy(){this._poleIndexBuffer.destroy(),this._gridBuffer.destroy(),this._gridIndexBuffer.destroy(),this._poleNorthVertexBuffer.destroy(),this._poleSouthVertexBuffer.destroy();for(const t of this._poleSegments)t.destroy();for(const t of this._gridSegments)t.withSkirts.destroy(),t.withoutSkirts.destroy()}_fillGridMeshWithLods(t,e){const i=new $l,n=new Kl,r=[],o=t+1+2,s=e[0]+1,a=e[0]+1+(1+e.length),l=(t,e,i)=>{let n=t===o-1?t-2:0===t?t:t-1;return n+=i?24575:0,[n,e]};for(let t=0;tt()))},t.dB=sx,t.dC=yx,t.dD=function(t){px=ki.resolveURL(t),gx||(gx=new ox(ux(),new zn)),gx.broadcast("setDracoUrl",px)},t.dE=vx,t.dF=function(t){mx=ki.resolveURL(t),gx||(gx=new ox(ux(),new zn)),gx.broadcast("setMeshoptUrl",mx)},t.dG=ti,t.dH=ba,t.dI=dh,t.dJ=I_,t.dK=eg,t.dL=dc,t.dM=am,t.dN=Dm,t.dO=Wf,t.dP=ci,t.dQ=E_,t.dR=jg,t.dS=function(t,e,i,n,r,o,s,a,l,c,d){t.createArrays(),t.tilePixelRatio=uo/(512*t.overscaling),t.compareText={},t.iconsNeedLinear=!1;const u=t.layers[0].layout,h=t.layers[0]._unevaluatedLayout._values,p={};if("composite"===t.textSizeData.kind){const{minZoom:e,maxZoom:i}=t.textSizeData;p.compositeTextSizes=[h["text-size"].possiblyEvaluate(new Ha(e),a),h["text-size"].possiblyEvaluate(new Ha(i),a)]}if("composite"===t.iconSizeData.kind){const{minZoom:e,maxZoom:i}=t.iconSizeData;p.compositeIconSizes=[h["icon-size"].possiblyEvaluate(new Ha(e),a),h["icon-size"].possiblyEvaluate(new Ha(i),a)]}p.layoutTextSize=h["text-size"].possiblyEvaluate(new Ha(l+1),a),p.layoutIconSize=h["icon-size"].possiblyEvaluate(new Ha(l+1),a),p.textMaxSize=h["text-size"].possiblyEvaluate(new Ha(18),a);const f="map"===u.get("text-rotation-alignment")&&"point"!==u.get("symbol-placement"),m=u.get("text-size");let _=!1;for(const e of t.features)if(e.icon&&e.icon.nameSecondary){_=!0;break}for(const o of t.features){const l=u.get("text-font").evaluate(o,{},a).join(","),h=m.evaluate(o,{},a),g=p.layoutTextSize.evaluate(o,{},a),y=(p.layoutIconSize.evaluate(o,{},a),{horizontal:{},vertical:void 0}),v=o.text;let x,b=[0,0];if(v){const n=v.toString(),s=u.get("text-letter-spacing").evaluate(o,{},a)*Om,c=u.get("text-line-height").evaluate(o,{},a)*Om,d=Aa(n)?s:0,p=u.get("text-anchor").evaluate(o,{},a),m=u.get("text-variable-anchor");if(!m){const t=u.get("text-radial-offset").evaluate(o,{},a);b=t?G_(p,[t*Om,j_]):u.get("text-offset").evaluate(o,{},a).map((t=>t*Om))}let _=f?"center":u.get("text-justify").evaluate(o,{},a);const x="point"===u.get("symbol-placement"),w=x?u.get("text-max-width").evaluate(o,{},a)*Om:1/0,T=o=>{t.allowVerticalPlacement&&Ca(n)&&(y.vertical=e_(v,e,i,r,l,w,c,p,o,d,b,Jm.vertical,!0,g,h))};if(!f&&m){const t="auto"===_?m.map((t=>Z_(t))):[_];let n=!1;for(let o=0;o=0||!Ca(n)){const t=e_(v,e,i,r,l,w,c,p,_,d,b,Jm.horizontal,!1,g,h);t&&(y.horizontal[_]=t)}T(x?"left":_)}}let w=!1;if(o.icon&&o.icon.namePrimary){const e=n[o.icon.namePrimary];e&&(x=u_(r[o.icon.namePrimary],o.icon.nameSecondary?r[o.icon.nameSecondary]:void 0,u.get("icon-offset").evaluate(o,{},a),u.get("icon-anchor").evaluate(o,{},a)),w=e.sdf,void 0===t.sdfIcons?t.sdfIcons=e.sdf:t.sdfIcons!==e.sdf&&pi("Style sheet warning: Cannot mix SDF and non-SDF icons in one buffer"),(e.pixelRatio!==t.pixelRatio||0!==u.get("icon-rotate").constantOr(1))&&(t.iconsNeedLinear=!0))}const T=X_(y.horizontal)||y.vertical;t.iconsInText||(t.iconsInText=!!T&&T.iconsInText),(T||x)&&q_(t,o,y,x,n,p,g,0,b,w,s,a,c,d,_)}o&&t.generateCollisionDebugBuffers(l,t.collisionBoxArray)},t.dT=Jf,t.dU=Yh,t.dV=bp,t.dW=Lm,t.dX=Yp,t.dY=Zy,t.dZ=wp,t.d_=cp,t.da=Wu,t.db=function(e){const i=[0,0,0],n=t.ad.identity(new Float64Array(16));return t.ad.multiply(n,e.pixelMatrix,e.globeMatrix),t._.transformMat4(i,i,n),new Ue(i[0],i[1])},t.dc=d,t.dd=c,t.de=function(t){const e=t.navigator?t.navigator.userAgent:null;return!!function(t){if(null==Ei){const e=t.navigator?t.navigator.userAgent:null;Ei=!!t.safari||!(!e||!(/\b(iPad|iPhone|iPod)\b/.test(e)||e.match("Safari")&&!e.match("Chrome")))}return Ei}(t)&&e&&(e.match("Version/15.4")||e.match("Version/15.5")||e.match(/CPU (OS|iPhone OS) (15_4|15_5) like Mac OS X/))},t.df=ni,t.dg=class{constructor(t,e,i){this._transformRequestFn=t,this._customAccessToken=e,this._silenceAuthErrors=!!i,this._createSkuToken()}_createSkuToken(){const t=function(){let t="";for(let e=0;ethis._skuTokenExpiresAt}transformRequest(t,e){return this._transformRequestFn&&this._transformRequestFn(t,e)||{url:t}}normalizeStyleURL(t,i){if(!o(t))return t;const n=un(t);return n.params.push(`sdk=js-${e}`),n.path=`/styles/v1${n.path}`,this._makeAPIURL(n,this._customAccessToken||i)}normalizeGlyphsURL(t,e){if(!o(t))return t;const i=un(t);return i.path=`/fonts/v1${i.path}`,this._makeAPIURL(i,this._customAccessToken||e)}normalizeModelURL(t,e){if(!o(t))return t;const i=un(t);return i.path=`/models/v1${i.path}`,this._makeAPIURL(i,this._customAccessToken||e)}normalizeSourceURL(t,e,i,n){if(!o(t))return t;const r=un(t);return r.path=`/v4/${r.authority}.json`,r.params.push("secure"),i&&r.params.push(`language=${i}`),n&&r.params.push(`worldview=${n}`),this._makeAPIURL(r,this._customAccessToken||e)}normalizeSpriteURL(t,e,i,n){const r=un(t);return o(t)?(r.path=`/styles/v1${r.path}/sprite${e}${i}`,this._makeAPIURL(r,this._customAccessToken||n)):(r.path+=`${e}${i}`,hn(r))}normalizeTileURL(t,e,i){if(this._isSkuTokenExpired()&&this._createSkuToken(),t&&!o(t))return t;const r=un(t);r.path=r.path.replace(/(\.(png|jpg)\d*)(?=$)/,`${e||i&&"raster"!==r.authority&&512===i?"@2x":""}${Gi.supported?".webp":"$1"}`),"raster"===r.authority?r.path=`/${n.RASTER_URL_PREFIX}${r.path}`:"rasterarrays"===r.authority?r.path=`/${n.RASTERARRAYS_URL_PREFIX}${r.path}`:"3dtiles"===r.authority?r.path=`/${n.TILES3D_URL_PREFIX}${r.path}`:(r.path=r.path.replace(/^.+\/v4\//,"/"),r.path=`/${n.TILE_URL_VERSION}${r.path}`);const s=this._customAccessToken||function(t){for(const e of t){const t=e.match(/^access_token=(.*)$/);if(t)return t[1]}return null}(r.params)||n.ACCESS_TOKEN;return n.REQUIRE_ACCESS_TOKEN&&s&&this._skuToken&&r.params.push(`sku=${this._skuToken}`),this._makeAPIURL(r,s)}canonicalizeTileURL(t,e){const i=un(t);if(!i.path.match(/^(\/v4\/|\/(raster|rasterarrays)\/v1\/)/)||!i.path.match(/\.[\w]+$/))return t;let r="mapbox://";i.path.match(/^\/raster\/v1\//)?r+=`raster/${i.path.replace(`/${n.RASTER_URL_PREFIX}/`,"")}`:i.path.match(/^\/rasterarrays\/v1\//)?r+=`rasterarrays/${i.path.replace(`/${n.RASTERARRAYS_URL_PREFIX}/`,"")}`:r+=`tiles/${i.path.replace(`/${n.TILE_URL_VERSION}/`,"")}`;let o=i.params;return e&&(o=o.filter((t=>!t.match(/^access_token=/)))),o.length&&(r+=`?${o.join("&")}`),r}canonicalizeTileset(t,e){const i=!!e&&o(e),n=[];for(const e of t.tiles||[])r(e)?n.push(this.canonicalizeTileURL(e,i)):n.push(e);return n}_makeAPIURL(t,e){const i="See https://docs.mapbox.com/api/overview/#access-tokens-and-token-scopes",r=un(n.API_URL);if(t.protocol=r.protocol,t.authority=r.authority,"http"===t.protocol){const e=t.params.indexOf("secure");e>=0&&t.params.splice(e,1)}if("/"!==r.path&&(t.path=`${r.path}${t.path}`),!n.REQUIRE_ACCESS_TOKEN)return hn(t);if(e=e||n.ACCESS_TOKEN,!this._silenceAuthErrors){if(!e)throw new Error(`An API access token is required to use Mapbox GL. ${i}`);if("s"===e[0])throw new Error(`Use a public access token (pk.*) with Mapbox GL, not a secret access token (sk.*). ${i}`)}return t.params=t.params.filter((t=>-1===t.indexOf("access_token"))),t.params.push(`access_token=${e||""}`),hn(t)}},t.dh=function(t,e){e?Mn.add(t):Mn.delete(t)},t.di=Gi,t.dj=Tn,t.dk=En,t.dl=cn,t.dm=vn,t.dn=bn,t.dp=function(t){Mn.delete(t)},t.dq=Sn,t.dr=yn,t.ds=Qe,t.dt=e,t.du=function(t,e){Fi=t,Ni=e},t.dv=function(t,e,i=!1){if(Fa===za||Fa===Ra||Fa===Oa)throw new Error("setRTLTextPlugin cannot be called multiple times.");Na=ki.resolveURL(t),Fa=za,Ba=e,ja(),i||Za()},t.dw=Ga,t.dx=function(){ux().acquire(lx)},t.dy=function(){const t=dx;t&&(t.isPreloaded()&&1===t.numActive()?(t.release(lx),dx=null):console.warn("Could not clear WebWorkers since there are active Map instances that still reference it. The pre-warmed WebWorker pool can only be cleared when all map instances have been removed with map.remove()"))},t.dz=cx,t.e=ki,t.e0=cm,t.e1=h,t.e2=en,t.e3=function(t){let e=0;if(new Uint32Array(t,0,1)[0]!==Ax){const i=new Uint32Array(t,0,7),[,,n,r,o,s]=i;e=i.byteLength+r+o+s+o,(n!==t.byteLength||e>=t.byteLength)&&pi("Invalid b3dm header information.")}return Dx(t,e)},t.e4=function(t,e){const i=jx(t);for(const t of i){for(const e of t.meshes)Vx(e);t.lights&&(t.lightMeshIndex=t.meshes.length,t.meshes.push(Gx(t.lights,e)))}return i},t.e5=Kx,t.e6=rx,t.e7=qa,t.e8=function(t){ji(),Oi&&Oi.then((e=>{e.keys().then((i=>{for(let n=0;nt.arrayBuffer())).then((e=>Dx(e,0,t)))},t.m=class extends Uv{},t.n=Er,t.o=qn,t.p=Qg,t.q=Xs,t.r=Js,t.s=Qs,t.t=ca,t.u=al,t.v=ll,t.w=pi,t.x=pa,t.y=da,t.z=qo})),n(0,(function(t){function e(t){const e=t?t.url.toString():void 0;return e?performance.getEntriesByName(e):[]}function i(t){if("number"==typeof t||"boolean"==typeof t||"string"==typeof t||null==t)return JSON.stringify(t);if(Array.isArray(t)){let e="[";for(const n of t)e+=`${i(n)},`;return`${e}]`}let e="{";for(const n of Object.keys(t).sort())e+=`${n}:${i(t[n])},`;return`${e}}`}function n(e){let n="";for(const r of t.cE)n+=`/${i(e[r])}`;return n}class r{constructor(t){this.keyCache={},this._layers={},this._layerConfigs={},t&&this.replace(t)}replace(t,e){this._layerConfigs={},this._layers={},this.update(t,[],e)}update(e,i,r){this._options=r;for(const i of e)this._layerConfigs[i.id]=i,(this._layers[i.id]=t.cY(i,this.scope,null,this._options)).compileFilter(),this.keyCache[i.id]&&delete this.keyCache[i.id];for(const t of i)delete this.keyCache[t],delete this._layerConfigs[t],delete this._layers[t];this.familiesBySource={};const o=function(t,e){const i={};for(let r=0;rthis._layers[t.id])),i=e[0];if("none"===i.visibility)continue;const n=i.source||"";let r=this.familiesBySource[n];r||(r=this.familiesBySource[n]={});const o=i.sourceLayer||"_geojsonTileLayer";let s=r[o];s||(s=r[o]=[]),s.push(e)}}}const o=1*t.dJ;class s{constructor(e){const i={},n=[];for(const t in e){const r=e[t],s=i[t]={};for(const t in r.glyphs){const e=r.glyphs[+t];if(!e||0===e.bitmap.width||0===e.bitmap.height)continue;const i=e.metrics.localGlyph?o:1,a={x:0,y:0,w:e.bitmap.width+2*i,h:e.bitmap.height+2*i};n.push(a),s[t]=a}}const{w:r,h:s}=t.j(n),a=new t.dI({width:r||1,height:s||1});for(const n in e){const r=e[n];for(const e in r.glyphs){const s=r.glyphs[+e];if(!s||0===s.bitmap.width||0===s.bitmap.height)continue;const l=i[n][e],c=s.metrics.localGlyph?o:1;t.dI.copy(s.bitmap,a,{x:0,y:0},{x:l.x+c,y:l.y+c},s.bitmap)}}this.image=a,this.positions=i}}t.dH(s,"GlyphAtlas");class a{constructor(e){this.tileID=new t.aL(e.tileID.overscaledZ,e.tileID.wrap,e.tileID.canonical.z,e.tileID.canonical.x,e.tileID.canonical.y),this.tileZoom=e.tileZoom,this.uid=e.uid,this.zoom=e.zoom,this.lut=e.lut,this.canonical=e.tileID.canonical,this.pixelRatio=e.pixelRatio,this.tileSize=e.tileSize,this.source=e.source,this.scope=e.scope,this.overscaling=this.tileID.overscaleFactor(),this.showCollisionBoxes=e.showCollisionBoxes,this.collectResourceTiming=!!e.collectResourceTiming,this.promoteId=e.promoteId,this.isSymbolTile=e.isSymbolTile,this.tileTransform=t.dK(e.tileID.canonical,e.projection),this.projection=e.projection,this.brightness=e.brightness,this.extraShadowCaster=!!e.extraShadowCaster,this.tessellationStep=e.tessellationStep}parse(e,i,n,r,o){this.status="parsing",this.data=e,this.collisionBoxArray=new t.dL;const a=new t.dM(Object.keys(e.layers).sort()),c=new t.dN(this.tileID,this.promoteId);c.bucketLayerIDs=[];const d={},u=new t.dO(256,256),h={featureIndex:c,iconDependencies:{},patternDependencies:{},glyphDependencies:{},lineAtlas:u,availableImages:n,brightness:this.brightness},p=i.familiesBySource[this.source];for(const i in p){const r=e.layers[i];if(!r)continue;let o=!1,s=!1,u=!1;for(const t of p[i])"symbol"===t[0].type?o=!0:s=!0,t[0].is3D()&&"model"!==t[0].type&&(u=!0);if(this.extraShadowCaster&&!u)continue;if(!0===this.isSymbolTile&&!o)continue;if(!1===this.isSymbolTile&&!s)continue;1===r.version&&t.w(`Vector tile source "${this.source}" layer "${i}" does not use vector tile spec v2 and therefore may have some rendering errors.`);const f=a.encode(i),m=[];for(let t=0;t=e.maxzoom||"none"!==e.visibility&&(l(t,this.zoom,h.brightness,n),(d[e.id]=e.createBucket({index:c.bucketLayerIDs.length,layers:t,zoom:this.zoom,lut:this.lut,canonical:this.canonical,pixelRatio:this.pixelRatio,overscaling:this.overscaling,collisionBoxArray:this.collisionBoxArray,sourceLayerIndex:f,sourceID:this.source,projection:this.projection.spec,tessellationStep:this.tessellationStep})).populate(m,h,this.tileID.canonical,this.tileTransform),c.bucketLayerIDs.push(t.map((t=>t.id)))))}}let f,m,_,g;u.trim();const y={type:"maybePrepare",isSymbolTile:this.isSymbolTile,zoom:this.zoom},v=()=>{if(f)return this.status="done",o(f);if(this.extraShadowCaster)this.status="done",o(null,{buckets:t.dG(d).filter((t=>!t.isEmpty())),featureIndex:c,collisionBoxArray:null,glyphAtlasImage:null,lineAtlas:null,imageAtlas:null,brightness:h.brightness,glyphMap:null,iconMap:null,glyphPositions:null});else if(m&&_&&g){const e=new s(m),i=new t.dQ(_,g,this.lut);for(const r in d){const o=d[r];o instanceof t.dR?(l(o.layers,this.zoom,h.brightness,n),t.dS(o,m,e.positions,_,i.iconPositions,this.showCollisionBoxes,n,this.tileID.canonical,this.tileZoom,this.projection,this.brightness)):o.hasPattern&&(o instanceof t.dT||o instanceof t.dU||o instanceof t.b_)&&(l(o.layers,this.zoom,h.brightness,n),o.addFeatures(h,this.tileID.canonical,i.patternPositions,n,this.tileTransform,this.brightness))}this.status="done",o(null,{buckets:t.dG(d).filter((t=>!t.isEmpty())),featureIndex:c,collisionBoxArray:this.collisionBoxArray,glyphAtlasImage:e.image,lineAtlas:u,imageAtlas:i,brightness:h.brightness})}};if(!this.extraShadowCaster){const e=t.dP(h.glyphDependencies,(t=>Object.keys(t).map(Number)));Object.keys(e).length?r.send("getGlyphs",{uid:this.uid,stacks:e,scope:this.scope},((t,e)=>{f||(f=t,m=e,v())}),void 0,!1,y):m={};const i=Object.keys(h.iconDependencies);i.length?r.send("getImages",{icons:i,source:this.source,scope:this.scope,tileID:this.tileID,type:"icons"},((t,e)=>{f||(f=t,_=e,v())}),void 0,!1,y):_={};const n=Object.keys(h.patternDependencies);n.length?r.send("getImages",{icons:n,source:this.source,scope:this.scope,tileID:this.tileID,type:"patterns"},((t,e)=>{f||(f=t,g=e,v())}),void 0,!1,y):g={}}v()}}function l(e,i,n,r){const o=new t.X(i,{brightness:n});for(const t of e)t.recalculate(o,r)}class c extends t.E{constructor(e,i,n,r,o,s){super(),this.actor=e,this.layerIndex=i,this.availableImages=n,this.loadVectorData=o||t.ap,this.loading={},this.loaded={},this.deduped=new t.ao(e.scheduler),this.isSpriteLoaded=r,this.scheduler=e.scheduler,this.brightness=s}loadTile(i,n){const r=i.uid,o=i&&i.request,s=o&&o.collectResourceTiming,l=this.loading[r]=new a(i);l.abort=this.loadVectorData(i,((a,c)=>{const d=!this.loading[r];if(delete this.loading[r],d||a||!c)return l.status="done",d||(this.loaded[r]=l),n(a);const u=c.rawData,h={};c.expires&&(h.expires=c.expires),c.cacheControl&&(h.cacheControl=c.cacheControl),l.vectorTile=c.vectorTile||new t.dV(new t.dW(u));const p=()=>{l.parse(l.vectorTile,this.layerIndex,this.availableImages,this.actor,((i,r)=>{if(i||!r)return n(i);const a={};if(s){const t=e(o);t.length>0&&(a.resourceTiming=JSON.parse(JSON.stringify(t)))}n(null,t.W({rawTileData:u.slice(0)},r,h,a))}))};this.isSpriteLoaded?p():this.once("isSpriteLoaded",(()=>{this.scheduler?this.scheduler.add(p,{type:"parseTile",isSymbolTile:i.isSymbolTile,zoom:i.tileZoom}):p()})),this.loaded=this.loaded||{},this.loaded[r]=l}))}reloadTile(e,i){const n=this.loaded,r=e.uid;if(n&&n[r]){const o=n[r];o.showCollisionBoxes=e.showCollisionBoxes,o.projection=e.projection,o.brightness=e.brightness,o.tileTransform=t.dK(e.tileID.canonical,e.projection),o.extraShadowCaster=e.extraShadowCaster,o.lut=e.lut;const s=(t,e)=>{const n=o.reloadCallback;n&&(delete o.reloadCallback,o.parse(o.vectorTile,this.layerIndex,this.availableImages,this.actor,n)),i(t,e)};"parsing"===o.status?o.reloadCallback=s:"done"===o.status&&(o.vectorTile?o.parse(o.vectorTile,this.layerIndex,this.availableImages,this.actor,s):s())}else i(null,void 0)}abortTile(t,e){const i=t.uid,n=this.loading[i];n&&(n.abort&&n.abort(),delete this.loading[i]),e()}removeTile(t,e){const i=this.loaded,n=t.uid;i&&i[n]&&delete i[n],e()}}class d{loadTile(e,i){const{uid:n,encoding:r,rawImageData:o,padding:s}=e,a=ImageBitmap&&o instanceof ImageBitmap?this.getImageData(o,s):o;i(null,new t.dX(n,a,r,s{n(null,t)}),(t=>{n(t)}))}}const h=t.dZ.prototype.toGeoJSON;let p=class{constructor(e){this._feature=e,this.extent=t.a3,this.type=e.type,this.properties=e.tags,"id"in e&&!isNaN(e.id)&&(this.id=parseInt(e.id,10))}loadGeometry(){if(1===this._feature.type){const e=[];for(const i of this._feature.geometry)e.push([new t.P(i[0],i[1])]);return e}{const e=[];for(const i of this._feature.geometry){const n=[];for(const e of i)n.push(new t.P(e[0],e[1]));e.push(n)}return e}}toGeoJSON(t,e,i){return h.call(this,t,e,i)}},f=class{constructor(e){this.layers={_geojsonTileLayer:this},this.name="_geojsonTileLayer",this.extent=t.a3,this.length=e.length,this._features=e}feature(t){return new p(this._features[t])}};const m=64/4096;class _{constructor(){this.features=new Map}clear(){this.features.clear()}load(t=[],e){for(const i of t){const t=i.id;if(null==t)continue;let n=this.features.get(t);n&&this.updateCache(n,e),i.geometry?(n=y(i),this.updateCache(n,e),this.features.set(t,n)):this.features.delete(t),this.updateCache(n,e)}}updateCache(t,e){for(const{canonical:i,uid:n}of Object.values(e)){const{z:r,x:o,y:s}=i;g(t,Math.pow(2,r),o,s)&&delete e[n]}}getTile(t,e,i){const n=Math.pow(2,t),r=[];for(const t of this.features.values())g(t,n,e,i)&&r.push(w(t,n,e,i));return{features:r}}getFeatures(){return[...this.features.values()]}}function g({minX:t,minY:e,maxX:i,maxY:n},r,o,s){return t(o-m)/r&&n>(s-m)/r}function y(t){const{id:e,geometry:i,properties:n}=t;if(!i)return;if("GeometryCollection"===i.type)throw new Error("GeometryCollection not supported in dynamic mode.");const{type:r,coordinates:o}=i,s={id:e,type:1,geometry:[],tags:n,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0},a=s.geometry;if("Point"===r)v(o,a,s);else if("MultiPoint"===r)for(const t of o)v(t,a,s);else if("LineString"===r)s.type=2,x(o,a,s);else if("MultiLineString"===r)s.type=2,b(o,a,s);else if("Polygon"===r)s.type=3,b(o,a,s,!0);else{if("MultiPolygon"!==r)throw new Error("Input data is not a valid GeoJSON object.");s.type=3;for(const t of o)b(t,a,s,!0)}return s}function v([e,i],n,r){const o=t.aj(e);let s=t.ak(i);s=s1?1:s,n.push(o,s),r.minX=Math.min(r.minX,o),r.minY=Math.min(r.minY,s),r.maxX=Math.max(r.maxX,o),r.maxY=Math.max(r.maxY,s)}function x(t,e,i,n=!1,r=!1){const o=[];for(const e of t)v(e,o,i);e.push(o),n&&function(t,e){let i=0;for(let e=0,n=t.length,r=n-2;e0===e)for(let e=0,i=t.length;e>31}function F(t,e){for(var i=t.loadGeometry(),n=t.type,r=0,o=0,s=i.length,a=0;at},V=Math.fround||(G=new Float32Array(1),t=>(G[0]=+t,G[0]));var G;const Z=3,q=5,H=6;class W{constructor(t){this.options=Object.assign(Object.create(j),t),this.trees=new Array(this.options.maxZoom+1),this.stride=this.options.reduce?7:6,this.clusterProps=[]}load(t){const{log:e,minZoom:i,maxZoom:n}=this.options;e&&console.time("total time");const r=`prepare ${t.length} points`;e&&console.time(r),this.points=t;const o=[];for(let e=0;e=i;t--){const i=+Date.now();s=this.trees[t]=this._createTree(this._cluster(s,t)),e&&console.log("z%d: %d clusters in %dms",t,s.numItems,+Date.now()-i)}return e&&console.timeEnd("total time"),this}getClusters(t,e){let i=((t[0]+180)%360+360)%360-180;const n=Math.max(-90,Math.min(90,t[1]));let r=180===t[2]?180:((t[2]+180)%360+360)%360-180;const o=Math.max(-90,Math.min(90,t[3]));if(t[2]-t[0]>=360)i=-180,r=180;else if(i>r){const t=this.getClusters([i,n,180,o],e),s=this.getClusters([-180,n,r,o],e);return t.concat(s)}const s=this.trees[this._limitZoom(e)],a=s.range(K(i),J(o),K(r),J(n)),l=s.data,c=[];for(const t of a){const e=this.stride*t;c.push(l[e+q]>1?Y(l,e,this.clusterProps):this.points[l[e+Z]])}return c}getChildren(t){const e=this._getOriginId(t),i=this._getOriginZoom(t),n="No cluster with the specified id.",r=this.trees[i];if(!r)throw new Error(n);const o=r.data;if(e*this.stride>=o.length)throw new Error(n);const s=this.options.radius/(this.options.extent*Math.pow(2,i-1)),a=r.within(o[e*this.stride],o[e*this.stride+1],s),l=[];for(const e of a){const i=e*this.stride;o[i+4]===t&&l.push(o[i+q]>1?Y(o,i,this.clusterProps):this.points[o[i+Z]])}if(0===l.length)throw new Error(n);return l}getLeaves(t,e,i){const n=[];return this._appendLeaves(n,t,e=e||10,i=i||0,0),n}getTile(t,e,i){const n=this.trees[this._limitZoom(t)],r=Math.pow(2,t),{extent:o,radius:s}=this.options,a=s/o,l=(i-a)/r,c=(i+1+a)/r,d={features:[]};return this._addTileFeatures(n.range((e-a)/r,l,(e+1+a)/r,c),n.data,e,i,r,d),0===e&&this._addTileFeatures(n.range(1-a/r,l,1,c),n.data,r,i,r,d),e===r-1&&this._addTileFeatures(n.range(0,l,a/r,c),n.data,-1,i,r,d),d.features.length?d:null}getClusterExpansionZoom(t){let e=this._getOriginZoom(t)-1;for(;e1;let l,c,d;if(a)l=X(e,t,this.clusterProps),c=e[t],d=e[t+1];else{const i=this.points[e[t+Z]];l=i.properties;const[n,r]=i.geometry.coordinates;c=K(n),d=J(r)}const u={type:1,geometry:[[Math.round(this.options.extent*(c*r-i)),Math.round(this.options.extent*(d*r-n))]],tags:l};let h;h=a||this.options.generateId?e[t+Z]:this.points[e[t+Z]].id,void 0!==h&&(u.id=h),o.features.push(u)}}_limitZoom(t){return Math.max(this.options.minZoom,Math.min(Math.floor(+t),this.options.maxZoom+1))}_cluster(t,e){const{radius:i,extent:n,reduce:r,minPoints:o}=this.options,s=i/(n*Math.pow(2,e)),a=t.data,l=[],c=this.stride;for(let i=0;ie&&(p+=a[i+q])}if(p>h&&p>=o){let t,o=n*h,s=d*h,f=-1;const m=(i/c1)for(const t of u){const i=t*c;if(!(a[i+2]>5}_getOriginZoom(t){return(t-this.points.length)%32}_map(t,e,i){if(t[e+q]>1){const n=this.clusterProps[t[e+H]];return i?Object.assign({},n):n}const n=this.points[t[e+Z]].properties,r=this.options.map(n);return i&&r===n?Object.assign({},r):r}}function Y(t,e,i){return{type:"Feature",id:t[e+Z],properties:X(t,e,i),geometry:{type:"Point",coordinates:[(n=t[e],360*(n-.5)),Q(t[e+1])]}};var n}function X(t,e,i){const n=t[e+q],r=n>=1e4?`${Math.round(n/1e3)}k`:n>=1e3?Math.round(n/100)/10+"k":n,o=t[e+H],s=-1===o?{}:Object.assign({},i[o]);return Object.assign(s,{cluster:!0,cluster_id:t[e+Z],point_count:n,point_count_abbreviated:r})}function K(t){return t/360+.5}function J(t){const e=Math.sin(t*Math.PI/180),i=.5-.25*Math.log((1+e)/(1-e))/Math.PI;return i1?1:i}function Q(t){const e=(180-360*t)*Math.PI/180;return 360*Math.atan(Math.exp(e))/Math.PI-90}function tt(t,e,i,n){let r=n;const o=e+(i-e>>1);let s,a=i-e;const l=t[e],c=t[e+1],d=t[i],u=t[i+1];for(let n=e+3;n 0?epg-i&&(e=pg-i);const o=r/Math.pow(fg(e),n);let s=o*Math.sin(n*t),a=r-o*Math.cos(n*t);return s=.5*(s/Math.PI+.5),a=.5*(a/Math.PI+.5),{x:s,y:this.southernCenter?a:1-a,z:0}}unproject(t,e){t=(2*t-.5)*Math.PI,this.southernCenter&&(e=1-e),e=(2*(1-e)-.5)*Math.PI;const{n:i,f:n}=this,r=n-e,o=Math.sign(r),s=Math.sign(i)*Math.sqrt(t*t+r*r);let a=Math.atan2(t,Math.abs(r))*o;r*i1e-6&&--n>0);o=i*i;const s=Xe(Ze(t/(.8707+o*(o*(o*o*o*(.003971-.001529*o)-.013791)-.131979))),-180,180),a=Ze(i);return new pd(s,a)}}const vg=Ge(Pd);class xg extends rg{project(t,e){e=Ge(e),t=Ge(t);const i=Math.cos(e),n=2/Math.PI,r=Math.acos(i*Math.cos(t/2)),o=Math.sin(r)/r,s=.5*(t*n+2*i*Math.sin(t/2)/o)||0,a=.5*(e+Math.sin(e)/o)||0;return{x:.5*(s/Math.PI+.5),y:1-.5*(a/Math.PI+1),z:0}}unproject(t,e){let i=t=(2*t-.5)*Math.PI,n=e=(2*(1-e)-1)*Math.PI,r=25;const o=1e-6;let s=0,a=0;do{const r=Math.cos(n),o=Math.sin(n),l=2*o*r,c=o*o,d=r*r,u=Math.cos(i/2),h=Math.sin(i/2),p=2*u*h,f=h*h,m=1-d*u*u,_=m?1/m:0,g=m?Math.acos(r*u)*Math.sqrt(1/m):0,y=.5*(2*g*r*h+2*i/Math.PI)-t,v=.5*(g*o+n)-e,x=.5*_*(d*f+g*r*u*c)+1/Math.PI,b=_*(p*l/4-g*o*h),w=.125*_*(l*h-g*o*d*p),T=.5*_*(c*u+g*f*r)+.5,S=b*w-T*x;s=(v*b-y*T)/S,a=(y*w-v*x)/S,i=Xe(i-s,-Math.PI,Math.PI),n=Xe(n-a,-vg,vg)}while((Math.abs(s)>o||Math.abs(a)>o)&&--r>0);return new pd(Ze(i),Ze(n))}}class bg extends rg{constructor(t){super(t),this.center=t.center||[0,0],this.parallels=t.parallels||[0,0],this.cosPhi=Math.max(.01,Math.cos(Ge(this.parallels[0]))),this.scale=1/(2*Math.max(Math.PI*this.cosPhi,1/this.cosPhi)),this.wrap=!0,this.supportsWorldCopies=!0}project(t,e){const{scale:i,cosPhi:n}=this;return{x:Ge(t)*n*i+.5,y:-Math.sin(Ge(e))/n*i+.5,z:0}}unproject(t,e){const{scale:i,cosPhi:n}=this,r=-(e-.5)/i,o=Xe(Ze((t-.5)/i)/n,-180,180),s=Math.asin(Xe(r*n,-1,1)),a=Xe(Ze(s),-Pd,Pd);return new pd(o,a)}}class wg extends _g{constructor(t){super(t),this.requiresDraping=!0,this.supportsWorldCopies=!1,this.supportsFog=!0,this.zAxisUnit="pixels",this.unsupportedLayers=["debug"],this.range=[3,5]}projectTilePoint(e,i,n){const r=Fu(e,i,n),o=ju($u(n));return t._.transformMat4(r,r,o),{x:r[0],y:r[1],z:r[2]}}locationPoint(e,i){const n=dd(i.lat,i.lng),r=t._.normalize([],n),o=e.elevation?e.elevation.getAtPointOrZero(e.locationCoordinate(i),e._centerAltitude):e._centerAltitude,s=Cd(1,0)*uo*o;t._.scaleAndAdd(n,n,r,s);const a=t.ad.identity(new Float64Array(16));return t.ad.multiply(a,e.pixelMatrix,e.globeMatrix),t._.transformMat4(n,n,a),new Ue(n[0],n[1])}pixelsPerMeter(t,e){return Cd(1,0)*e}pixelSpaceConversion(t,e,i){const n=Cd(1,t)*e,r=Vn(Cd(1,45)*e,n,i);return this.pixelsPerMeter(t,e)/r}createTileMatrix(e,i,n){const r=Vu($u(n.canonical));return t.ad.multiply(new Float64Array(16),e.globeMatrix,r)}createInversionMatrix(e,i){const{center:n}=e,r=ju($u(i));return t.ad.rotateY(r,r,Ge(n.lng)),t.ad.rotateX(r,r,Ge(n.lat)),t.ad.scale(r,r,[e._pixelsPerMercatorPixel,e._pixelsPerMercatorPixel,1]),Float32Array.from(r)}pointCoordinate(t,e,i,n){return Iu(t,e,i,!0)||new Rd(0,0)}pointCoordinate3D(t,e,i){const n=this.pointCoordinate(t,e,i,0);return[n.x,n.y,n.z]}isPointAboveHorizon(t,e){return!Iu(t,e.x,e.y,!1)}farthestPixelDistance(e){const i=function(e,i){const n=e.cameraToCenterDistance,r=e._centerAltitude*i,o=e._camera,s=e._camera.forward(),a=t._.add([],t._.scale([],s,-n),[0,0,r]),l=e.worldSize/(2*Math.PI),c=[0,0,-l],d=e.width/e.height,u=Math.tan(e.fovAboveCenter),h=t._.scale([],o.up(),u),p=t._.scale([],o.right(),u*d),f=t._.normalize([],t._.add([],t._.add([],s,h),p)),m=[];let _;if(new mu(a,f).closestPointOnSphere(c,l,m)){const i=t._.add([],m,c),n=t._.sub([],i,a);_=Math.cos(e.fovAboveCenter)*t._.length(n)}else{const e=t._.sub([],a,c),i=t._.sub([],c,a);t._.normalize(i,i);const n=t._.length(e)-l;_=Math.sqrt(n*(n+2*l));const r=Math.acos(_/(l+n))-Math.acos(t._.dot(s,i));_*=Math.cos(r)}return 1.01*_}(e,this.pixelsPerMeter(e.center.lat,e.worldSize)),n=Hu(e.zoom);if(n>0){const t=tg(e,Cd(1,e.center.lat)*e.worldSize),r=e.worldSize/(2*Math.PI),o=Math.max(e.width,e.height)/e.worldSize*Math.PI;return Vn(i,t+r*(1-Math.cos(o)),Math.pow(n,10))}return i}upVector(t,e,i){return Fu(e,i,t,1)}upVectorScale(t){return{metersToTile:Cu(Nu($u(t)))}}}function Tg(t){const e=t.parallels,i=!!e&&Math.abs(e[0]+e[1])0&&(this.iconTransitioningVertexBuffer=t.createVertexBuffer(this.iconTransitioningVertexArray,Vf.members,!0)),this.globeExtVertexArray.length>0&&(this.globeExtVertexBuffer=t.createVertexBuffer(this.globeExtVertexArray,Ff.members,!0)),!this.zOffsetVertexBuffer&&(this.zOffsetVertexArray.length>0||r)&&(this.zOffsetVertexBuffer=t.createVertexBuffer(this.zOffsetVertexArray,jf.members,!0)),this.opacityVertexBuffer.itemSize=1),(i||n)&&this.programConfigurations.upload(t))}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy(),this.dynamicLayoutVertexBuffer.destroy(),this.opacityVertexBuffer.destroy(),this.occlusionQueryOpacityVertexBuffer.destroy(),this.iconTransitioningVertexBuffer&&this.iconTransitioningVertexBuffer.destroy(),this.globeExtVertexBuffer&&this.globeExtVertexBuffer.destroy(),this.zOffsetVertexBuffer&&this.zOffsetVertexBuffer.destroy())}}ba(Ng,"SymbolBuffers");class Ug{constructor(t,e,i){this.layoutVertexArray=new t,this.layoutAttributes=e,this.indexArray=new i,this.segments=new wc,this.collisionVertexArray=new Xl,this.collisionVertexArrayExt=new Ol}upload(t){this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,this.layoutAttributes),this.indexBuffer=t.createIndexBuffer(this.indexArray),this.collisionVertexBuffer=t.createVertexBuffer(this.collisionVertexArray,Gf.members,!0),this.collisionVertexBufferExt=t.createVertexBuffer(this.collisionVertexArrayExt,Zf.members,!0)}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.segments.destroy(),this.collisionVertexBuffer.destroy(),this.collisionVertexBufferExt.destroy())}}ba(Ug,"CollisionBuffers");class jg{constructor(e){this.queries=new Map,this.collisionBoxArray=e.collisionBoxArray,this.zoom=e.zoom,this.lut=e.lut,this.overscaling=e.overscaling,this.layers=e.layers,this.layerIds=this.layers.map((t=>t.fqid)),this.index=e.index,this.pixelRatio=e.pixelRatio,this.sourceLayerIndex=e.sourceLayerIndex,this.hasPattern=!1,this.hasRTLText=!1,this.fullyClipped=!1,this.hasAnyIconTextFit=!1,this.sortKeyRanges=[],this.collisionCircleArray=[],this.placementInvProjMatrix=t.ad.identity([]),this.placementViewportMatrix=t.ad.identity([]);const i=this.layers[0]._unevaluatedLayout._values;this.textSizeData=Fm(this.zoom,i["text-size"]),this.iconSizeData=Fm(this.zoom,i["icon-size"]);const n=this.layers[0].layout,r=n.get("symbol-sort-key"),o=n.get("symbol-z-order");this.canOverlap=n.get("text-allow-overlap")||n.get("icon-allow-overlap")||n.get("text-ignore-placement")||n.get("icon-ignore-placement"),this.sortFeaturesByKey="viewport-y"!==o&&void 0!==r.constantOr(1),this.sortFeaturesByY=("viewport-y"===o||"auto"===o&&!this.sortFeaturesByKey)&&this.canOverlap,this.writingModes=n.get("text-writing-mode").map((t=>Jm[t])),this.stateDependentLayerIds=this.layers.filter((t=>t.isStateDependent())).map((t=>t.id)),this.sourceID=e.sourceID,this.projection=e.projection,this.hasAnyZOffset=!1,this.zOffsetSortDirty=!1,this.zOffsetBuffersNeedUpload=n.get("symbol-z-elevate"),this.activeReplacements=[],this.replacementUpdateTime=0}createArrays(){this.text=new Ng(new Yc(this.layers,{zoom:this.zoom,lut:this.lut},(t=>/^text/.test(t)))),this.icon=new Ng(new Yc(this.layers,{zoom:this.zoom,lut:this.lut},(t=>/^icon/.test(t)))),this.glyphOffsetArray=new mc,this.lineVertexArray=new _c,this.symbolInstances=new fc}calculateGlyphDependencies(t,e,i,n,r){for(let i=0;i0)&&("constant"!==l.value.kind||l.value.value.length>0),h="constant"!==d.value.kind||!!d.value.value||Object.keys(d.parameters).length>0,p=s.get("symbol-sort-key");if(this.features=[],!u&&!h)return;const f=i.iconDependencies,m=i.glyphDependencies,_=i.availableImages,g=new Ha(this.zoom);for(const{feature:i,id:c,index:d,sourceLayerIndex:y}of e){const e=o._featureFilter.needGeometry,v=Zd(i,e);if(!o._featureFilter.filter(g,v,n))continue;if(e||(v.geometry=Gd(i,n,r)),a&&1!==i.type&&n.z{const o=Fu(e.x,e.y,n,1),s=Fu(r.x,r.y,n,1);return t._.dot(o,s)=0;for(const i of x.sections)if(i.image)f[i.image.namePrimary]=!0;else{const n=Ca(x.toString()),r=i.fontStack||t,o=m[r]=m[r]||{};this.calculateGlyphDependencies(i.text,o,e,this.allowVerticalPlacement,n)}}}"line"===s.get("symbol-placement")&&(this.features=function(t){const e={},i={},n=[];let r=0;function o(e){n.push(t[e]),r++}function s(t,e,r){const o=i[t];return delete i[t],i[e]=o,n[o].geometry[0].pop(),n[o].geometry[0]=n[o].geometry[0].concat(r[0]),o}function a(t,i,r){const o=e[i];return delete e[i],e[t]=o,n[o].geometry[0].shift(),n[o].geometry[0]=r[0].concat(n[o].geometry[0]),o}function l(t,e,i){const n=i?e[0][e[0].length-1]:e[0][0];return`${t}:${n.x}:${n.y}`}for(let c=0;ct.geometry))}(this.features)),this.sortFeaturesByKey&&this.features.sort(((t,e)=>t.sortKey-e.sortKey))}update(t,e,i,n,r){const o=0!==Object.keys(t).length;if(o&&!this.stateDependentLayers.length)return;const s=o?this.stateDependentLayers:this.layers;this.text.programConfigurations.updatePaintArrays(t,e,s,i,n,r),this.icon.programConfigurations.updatePaintArrays(t,e,s,i,n,r)}updateOcclusionOpacities(t,e,i){if(!e.useOcclusionQueries)return!1;const n=this;if("globe"===n.projection.name)return!1;let r=!1;n.hasTextData()&&(r=r||0!==n.text.occlusionQueryOpacityVertexArray.length),n.hasIconData()&&(r=r||0!==n.icon.occlusionQueryOpacityVertexArray.length);const o=n.layers[0].paint,s=o.get("icon-occlusion-opacity").constantOr(0),a=o.get("text-occlusion-opacity").constantOr(0);if(!n.layers[0].hasInitialOcclusionOpacityProperties||1===s&&1===a)return!1;let l=!r;for(let t=0;t.5?1:-1)*e.fadeSpeed*i*.001,r.occlusionOpacity=Xe(r.occlusionOpacity,0,1),l=l||r.occlusionOpacity!==o}if(!l)return!1;let c=0,d=0;const u=(t,e,i,n)=>{let r=0,o=0;i?(r=d,d+=n,o=d):(r=c,c+=n,o=c),o>e.occlusionQueryOpacityVertexArray.length&&e.occlusionQueryOpacityVertexArray.resize(o);const s=t.occlusionOpacity;for(let t=0;t0;if((i>0||r>0)&&(u(e,n.text,!1,i),u(e,n.text,!1,r)),s){const{placedIconSymbolIndex:t,verticalPlacedIconSymbolIndex:i}=e;t>=0&&u(e,n.icon,!0,o),i>=0&&u(e,n.icon,!0,e.numVerticalIconVertices)}}return n.hasTextData()&&n.text.occlusionQueryOpacityVertexBuffer&&(n.text.occlusionQueryOpacityVertexBuffer.length{i+=e,i>t.length&&t.resize(i);for(let r=-e;r{n+=e,n>t.length&&t.resize(n);for(let r=-e;r0;if((r>0||o>0)&&(t(this.text.zOffsetVertexArray,r,a),t(this.text.zOffsetVertexArray,o,a)),l){const{placedIconSymbolIndex:t,verticalPlacedIconSymbolIndex:i}=n;t>=0&&e(this.icon.zOffsetVertexArray,s,a),i>=0&&e(this.icon.zOffsetVertexArray,n.numVerticalIconVertices,a)}}this.text.zOffsetVertexBuffer&&this.text.zOffsetVertexBuffer.updateData(this.text.zOffsetVertexArray),this.icon.zOffsetVertexBuffer&&this.icon.zOffsetVertexBuffer.updateData(this.icon.zOffsetVertexArray)}isEmpty(){return 0===this.symbolInstances.length&&!this.hasRTLText}uploadPending(){return!this.uploaded||this.text.programConfigurations.needsUpload||this.icon.programConfigurations.needsUpload}upload(t){!this.uploaded&&this.hasDebugData()&&(this.textCollisionBox.upload(t),this.iconCollisionBox.upload(t)),this.text.upload(t,this.sortFeaturesByY,!this.uploaded,this.text.programConfigurations.needsUpload,this.zOffsetBuffersNeedUpload),this.icon.upload(t,this.sortFeaturesByY,!this.uploaded,this.icon.programConfigurations.needsUpload,this.zOffsetBuffersNeedUpload),this.uploaded=!0}destroyDebugData(){this.textCollisionBox.destroy(),this.iconCollisionBox.destroy()}getProjection(){return this.projectionInstance||(this.projectionInstance=Tg(this.projection)),this.projectionInstance}destroy(){this.text.destroy(),this.icon.destroy(),this.hasDebugData()&&this.destroyDebugData();for(const t of this.queries.values())t.destroy()}addToLineVertexArray(t,e){const i=this.lineVertexArray.length;if(void 0!==t.segment)for(const{x:t,y:i}of e)this.lineVertexArray.emplaceBack(t,i);return{lineStartIndex:i,lineLength:this.lineVertexArray.length-i}}addSymbols(t,e,i,n,r,o,s,a,l,c,d,u,h,p,f,m){const _=t.indexArray,g=t.layoutVertexArray,y=t.globeExtVertexArray,v=t.segments.prepareSegment(4*e.length,g,_,this.canOverlap?o.sortKey:void 0),x=this.glyphOffsetArray.length,b=v.vertexLength,w=this.allowVerticalPlacement&&s===Jm.vertical?Math.PI/2:0,T=o.text&&o.text.sections;for(let n=0;n=0?e.rightJustifiedTextSymbolIndex:e.centerJustifiedTextSymbolIndex>=0?e.centerJustifiedTextSymbolIndex:e.leftJustifiedTextSymbolIndex>=0?e.leftJustifiedTextSymbolIndex:e.verticalPlacedTextSymbolIndex>=0?e.verticalPlacedTextSymbolIndex:n),o=Nm(this.textSizeData,t,r)/Om;return this.tilePixelRatio*o}getSymbolInstanceIconSize(t,e,i){const n=this.icon.placedSymbolArray.get(i),r=Nm(this.iconSizeData,t,n);return this.tilePixelRatio*r}_commitDebugCollisionVertexUpdate(t,e,i,n){t.emplaceBack(e,-i,-i,n),t.emplaceBack(e,i,-i,n),t.emplaceBack(e,i,i,n),t.emplaceBack(e,-i,i,n)}_updateTextDebugCollisionBoxes(t,e,i,n,r,o){for(let s=n;s0}hasIconData(){return this.icon.segments.get().length>0}hasDebugData(){return this.textCollisionBox&&this.iconCollisionBox}hasTextCollisionBoxData(){return this.hasDebugData()&&this.textCollisionBox.segments.get().length>0}hasIconCollisionBoxData(){return this.hasDebugData()&&this.iconCollisionBox.segments.get().length>0}hasIconTextFit(){return this.hasAnyIconTextFit}addIndicesForPlacedSymbol(t,e){const i=t.placedSymbolArray.get(e),n=i.vertexStartIndex+4*i.numGlyphs;for(let e=i.vertexStartIndex;en[t]-n[e]||r[e]-r[t])),o}getSortedIndexesByZOffset(){if(!this.zOffsetSortDirty)return this.symbolInstanceIndexesSortedZOffset;if(!this.symbolInstanceIndexesSortedZOffset){this.symbolInstanceIndexesSortedZOffset=[];for(let t=0;tthis.symbolInstances.get(e).zOffset-this.symbolInstances.get(t).zOffset))}addToSortKeyRanges(t,e){const i=this.sortKeyRanges[this.sortKeyRanges.length-1];i&&i.sortKey===e?i.symbolInstanceEnd=t+1:this.sortKeyRanges.push({sortKey:e,symbolInstanceStart:t,symbolInstanceEnd:t+1})}sortFeatures(t){if(this.sortFeaturesByY&&this.sortedAngle!==t&&!(this.text.segments.get().length>1||this.icon.segments.get().length>1)){this.symbolInstanceIndexes=this.getSortedSymbolIndexes(t),this.sortedAngle=t,this.text.indexArray.clear(),this.icon.indexArray.clear(),this.featureSortOrder=[];for(const t of this.symbolInstanceIndexes){const e=this.symbolInstances.get(t);this.featureSortOrder.push(e.featureIndex);const{rightJustifiedTextSymbolIndex:i,centerJustifiedTextSymbolIndex:n,leftJustifiedTextSymbolIndex:r,verticalPlacedTextSymbolIndex:o,placedIconSymbolIndex:s,verticalPlacedIconSymbolIndex:a}=e;i>=0&&this.addIndicesForPlacedSymbol(this.text,i),n>=0&&n!==i&&this.addIndicesForPlacedSymbol(this.text,n),r>=0&&r!==n&&r!==i&&this.addIndicesForPlacedSymbol(this.text,r),o>=0&&this.addIndicesForPlacedSymbol(this.text,o),s>=0&&this.addIndicesForPlacedSymbol(this.icon,s),a>=0&&this.addIndicesForPlacedSymbol(this.icon,a)}this.text.indexBuffer&&this.text.indexBuffer.updateData(this.text.indexArray),this.icon.indexBuffer&&this.icon.indexBuffer.updateData(this.icon.indexArray)}}}ba(jg,"SymbolBucket",{omit:["layers","collisionBoxArray","features","compareText"]}),jg.addDynamicAttributes=Bg;class Vg{constructor(t,e,i,n){this.context=t,this.format=i,this.texture=t.gl.createTexture(),this.update(e,n)}update(t,e,i){const{width:n,height:r}=t,{context:o}=this,{gl:s}=o;if(s.bindTexture(s.TEXTURE_2D,this.texture),o.pixelStoreUnpackFlipY.set(!1),o.pixelStoreUnpack.set(1),o.pixelStoreUnpackPremultiplyAlpha.set(this.format===s.RGBA&&(!e||!1!==e.premultiply)),this.useMipmap=Boolean(e&&e.useMipmap),i||this.size&&this.size[0]===n&&this.size[1]===r){const{x:e,y:o}=i||{x:0,y:0};if(t instanceof HTMLImageElement||t instanceof HTMLCanvasElement||t instanceof HTMLVideoElement||t instanceof ImageData||ImageBitmap&&t instanceof ImageBitmap)s.texSubImage2D(s.TEXTURE_2D,0,e,o,s.RGBA,s.UNSIGNED_BYTE,t);else{let i=this.format,a=s.UNSIGNED_BYTE;this.format===s.R32F&&(i=s.RED,a=s.FLOAT),s.texSubImage2D(s.TEXTURE_2D,0,e,o,n,r,i,a,t.data)}}else if(this.size=[n,r],t instanceof HTMLImageElement||t instanceof HTMLCanvasElement||t instanceof HTMLVideoElement||t instanceof ImageData||ImageBitmap&&t instanceof ImageBitmap){let e=this.format;this.format===s.R8&&(e=s.RED),s.texImage2D(s.TEXTURE_2D,0,this.format,e,s.UNSIGNED_BYTE,t)}else{let e=this.format,i=this.format,o=s.UNSIGNED_BYTE,a=!1;this.format===s.DEPTH_COMPONENT&&(e=s.DEPTH_COMPONENT16,o=s.UNSIGNED_SHORT),this.format===s.DEPTH_STENCIL&&(e=s.DEPTH24_STENCIL8,o=s.UNSIGNED_INT_24_8,a=!0),this.format===s.R8&&(i=s.RED),this.format===s.R32F&&(o=s.FLOAT,i=s.RED),!this.useMipmap&&a?s.texStorage2D(s.TEXTURE_2D,1,e,n,r):s.texImage2D(s.TEXTURE_2D,0,e,n,r,0,i,o,t.data)}this.useMipmap&&s.generateMipmap(s.TEXTURE_2D)}bind(t,e,i=!1){const{context:n}=this,{gl:r}=n;r.bindTexture(r.TEXTURE_2D,this.texture),t!==this.minFilter&&(r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MAG_FILTER,t),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MIN_FILTER,this.useMipmap&&!i?t===r.NEAREST?r.NEAREST_MIPMAP_NEAREST:r.LINEAR_MIPMAP_LINEAR:t),this.minFilter=t),e!==this.wrapS&&(r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_S,e),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_T,e),this.wrapS=e)}bindExtraParam(t,e,i,n){const{context:r}=this,{gl:o}=r;o.bindTexture(o.TEXTURE_2D,this.texture),e!==this.magFilter&&(o.texParameteri(o.TEXTURE_2D,o.TEXTURE_MAG_FILTER,e),this.magFilter=e),t!==this.minFilter&&(o.texParameteri(o.TEXTURE_2D,o.TEXTURE_MIN_FILTER,this.useMipmap?t===o.NEAREST?o.NEAREST_MIPMAP_NEAREST:o.LINEAR_MIPMAP_LINEAR:t),this.minFilter=t),i!==this.wrapS&&(o.texParameteri(o.TEXTURE_2D,o.TEXTURE_WRAP_S,i),this.wrapS=i),n!==this.wrapT&&(o.texParameteri(o.TEXTURE_2D,o.TEXTURE_WRAP_T,n),this.wrapT=n)}destroy(){const{gl:t}=this.context;t.deleteTexture(this.texture),this.texture=null}}class Gg{constructor(t,e){this.context=t,this.texture=e}bind(t,e){const{context:i}=this,{gl:n}=i;n.bindTexture(n.TEXTURE_2D,this.texture),t!==this.minFilter&&(n.texParameteri(n.TEXTURE_2D,n.TEXTURE_MAG_FILTER,t),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_MIN_FILTER,t),this.minFilter=t),e!==this.wrapS&&(n.texParameteri(n.TEXTURE_2D,n.TEXTURE_WRAP_S,e),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_WRAP_T,e),this.wrapS=e)}}const Zg=32,qg=33,Hg=new Uint16Array(8184);for(let t=0;t>=1)>1;){const t=i+r>>1,l=n+o>>1;1&e?(r=i,o=n,i=s,n=a):(i=r,n=o,r=s,o=a),s=t,a=l}const l=4*t;Hg[l+0]=i,Hg[l+1]=n,Hg[l+2]=r,Hg[l+3]=o}const Wg=new Uint16Array(2178),Yg=new Uint8Array(1089),Xg=new Uint16Array(1089);function Kg(t){return 0===t?-.03125:32===t?.03125:0}var Jg=Ll([{name:"a_pos",type:"Int16",components:2},{name:"a_texture_pos",type:"Int16",components:2}]),Qg=Ll([{name:"a_index",type:"Int16",components:1}]);const ty={type:2,extent:uo,loadGeometry:()=>[[new Ue(0,0),new Ue(uo+1,0),new Ue(uo+1,uo+1),new Ue(0,uo+1),new Ue(0,0)]]};class ey{constructor(t,e,i,n,r){this.tileID=t,this.uid=ni(),this.uses=0,this.tileSize=e,this.tileZoom=i,this.buckets={},this.expirationTime=null,this.queryPadding=0,this.hasSymbolBuckets=!1,this.hasRTLText=!1,this.dependencies={},this.isRaster=r,n&&n.style&&(this._lastUpdatedBrightness=n.style.getBrightness()),this.expiredRequestCount=0,this.state="loading",n&&n.transform&&(this.projection=n.transform.projection)}registerFadeDuration(t){const e=t+this.timeAdded;ee.getLayer(t))).filter(Boolean);if(0!==t.length){n.layers=t,n.stateDependentLayerIds&&(n.stateDependentLayers=n.stateDependentLayerIds.map((e=>t.filter((t=>t.id===e))[0])));for(const e of t)i[e.fqid]=n}}return i}(t.buckets,e.style),this.hasSymbolBuckets=!1;for(const t in this.buckets){const e=this.buckets[t];if(e instanceof jg){if(this.hasSymbolBuckets=!0,!i)break;e.justReloaded=!0}}if(this.hasRTLText=!1,this.hasSymbolBuckets)for(const t in this.buckets){const e=this.buckets[t];if(e instanceof jg&&e.hasRTLText){this.hasRTLText=!0,qa.isLoading()||qa.isLoaded()||"deferred"!==Ga()||Za();break}}this.queryPadding=0;for(const t in this.buckets){const i=this.buckets[t],n=e.style.getOwnLayer(t);if(!n)continue;const r=n.queryRadius(i);this.queryPadding=Math.max(this.queryPadding,r)}t.imageAtlas&&(this.imageAtlas=t.imageAtlas),t.glyphAtlasImage&&(this.glyphAtlasImage=t.glyphAtlasImage),t.lineAtlas&&(this.lineAtlas=t.lineAtlas),this._lastUpdatedBrightness=t.brightness}else this.collisionBoxArray=new dc}unloadVectorData(){if(this.hasData()){for(const t in this.buckets)this.buckets[t].destroy();this.buckets={},this.imageAtlas&&(this.imageAtlas=null),this.lineAtlas&&(this.lineAtlas=null),this.imageAtlasTexture&&this.imageAtlasTexture.destroy(),this.glyphAtlasTexture&&this.glyphAtlasTexture.destroy(),this.lineAtlasTexture&&this.lineAtlasTexture.destroy(),this._tileBoundsBuffer&&(this._tileBoundsBuffer.destroy(),this._tileBoundsIndexBuffer.destroy(),this._tileBoundsSegments.destroy(),this._tileBoundsBuffer=null),this._tileDebugBuffer&&(this._tileDebugBuffer.destroy(),this._tileDebugSegments.destroy(),this._tileDebugBuffer=null),this._tileDebugIndexBuffer&&(this._tileDebugIndexBuffer.destroy(),this._tileDebugIndexBuffer=null),this._globeTileDebugBorderBuffer&&(this._globeTileDebugBorderBuffer.destroy(),this._globeTileDebugBorderBuffer=null),this._tileDebugTextBuffer&&(this._tileDebugTextBuffer.destroy(),this._tileDebugTextSegments.destroy(),this._tileDebugTextIndexBuffer.destroy(),this._tileDebugTextBuffer=null),this._globeTileDebugTextBuffer&&(this._globeTileDebugTextBuffer.destroy(),this._globeTileDebugTextBuffer=null),this.latestFeatureIndex=null,this.state="unloaded"}}getBucket(t){return this.buckets[t.fqid]}upload(t){for(const e in this.buckets){const i=this.buckets[e];i.uploadPending()&&i.upload(t)}const e=t.gl,i=this.imageAtlas;if(i&&!i.uploaded){const n=!!Object.keys(i.patternPositions).length;this.imageAtlasTexture=new Vg(t,i.image,e.RGBA,{useMipmap:n}),this.imageAtlas.uploaded=!0}this.glyphAtlasImage&&(this.glyphAtlasTexture=new Vg(t,this.glyphAtlasImage,e.R8),this.glyphAtlasImage=null),this.lineAtlas&&!this.lineAtlas.uploaded&&(this.lineAtlasTexture=new Vg(t,this.lineAtlas.image,e.R8),this.lineAtlas.uploaded=!0)}prepare(t,e,i){if(this.imageAtlas&&this.imageAtlasTexture&&this.imageAtlas.patchUpdatedImages(t,this.imageAtlasTexture,i),!e||!this.latestFeatureIndex||!this.latestFeatureIndex.rawTileData)return;const n=e.style.getBrightness();(this._lastUpdatedBrightness||n)&&(this._lastUpdatedBrightness&&n&&Math.abs(this._lastUpdatedBrightness-n)t)i=!1;else if(e)if(this.expirationTime=0;t--){const e=4*t,i=Hg[e+0],n=Hg[e+1],r=Hg[e+2],o=Hg[e+3],s=i+r>>1,a=n+o>>1,l=s+a-n,c=a+i-s,d=n*qg+i,u=o*qg+r,h=a*qg+s,p=Math.hypot((Wg[2*d+0]+Wg[2*u+0])/2-Wg[2*h+0],(Wg[2*d+1]+Wg[2*u+1])/2-Wg[2*h+1])>=16;Yg[h]=Yg[h]||(p?1:0),t>1)*qg+(i+l>>1)]||Yg[(o+c>>1)*qg+(r+l>>1)])}const r=new Dl,o=new Kl;let s=0;function a(t,e){const i=e*qg+t;return 0===Xg[i]&&(r.emplaceBack(Wg[2*i+0],Wg[2*i+1],t*uo/Zg,e*uo/Zg),Xg[i]=++s),Xg[i]-1}function l(t,e,i,n,r,s){const c=t+i>>1,d=e+n>>1;if(Math.abs(t-r)+Math.abs(e-s)>1&&Yg[d*qg+c])l(r,s,t,e,c,d),l(i,n,r,s,c,d);else{const l=a(t,e),c=a(i,n),d=a(r,s);o.emplaceBack(l,c,d)}}return l(0,0,Zg,Zg,Zg,0),l(Zg,Zg,0,0,0,Zg),{vertices:r,indices:o}}(this.tileID.canonical,e);n=t.vertices,r=t.indices}else{n=new Dl,r=new Kl;for(const{x:t,y:e}of i)n.emplaceBack(t,e,0,0);const t=xh(n.int16,void 0,4);for(let e=0;e0&&(a=t.ad.invert(new Float64Array(16),i.globeMatrix)),this._makeGlobeTileDebugBorderBuffer(e,r,i,o,a,s),this._makeGlobeTileDebugTextBuffer(e,r,i,o,a,s)}_globePoint(e,i,n,r,o,s,a){let l=Fu(e,i,n);if(s){const o=1.5?h=-1:u{const p=(d-t)/(h-1),f=(u-c)/(h-1),m=s.length;for(let d=0;dd*t+e;for(let t=0;t[t,this.get(t)]))}evict(t=!1){if(t||this.size>0){const t=this.first;delete this.items[t.key],0==--this.size?(this.first=null,this.last=null):(this.first=t.next,this.first.prev=null)}return this}expiresAt(t){let e;return this.has(t)&&(e=this.items[t].expiry),e}get(t){let e;if(this.has(t)){const i=this.items[t];this.ttl>0&&i.expiry0?Date.now()+this.ttl:this.ttl),this.last!==r){const t=this.last,e=r.next,i=r.prev;this.first===r&&(this.first=r.next),r.next=null,r.prev=this.last,t.next=r,null!==i&&(i.next=e),null!==e&&(e.prev=i)}}else this.max>0&&this.size===this.max&&this.evict(!0),r=this.items[t]={expiry:this.ttl>0?Date.now()+this.ttl:this.ttl,key:t,prev:this.last,next:null,value:e},1==++this.size?this.first=r:this.last.next=r;return this.last=r,this}values(t=this.keys()){return t.map((t=>this.get(t)))}}function uy(t,e){if(4!==e.length)throw new Error(`Expected data of dimension 4 but got ${e.length}.`);let i=e[3];for(let n=2;n>=1;n--){const r=1===n?1:0,o=2===n?1:0;for(let n=0;n>>1^-(1&t[e]);return t}function py(t,e){switch(e){case"uint32":return t;case"uint16":for(let e=0;e>4|(61440&i)>>8|(240&n)>4|(15&n)>6|(192&n)>>4|(192&r)>>2|192&o,t[e+1]=(48&i)>>4|(48&n)>>2|48&r|(48&o)>2|12&n|(12&r)>1|(21845&Cy)>2|(13107&Ay)>4|(3855&Ay)>8|(255&Ay)>1}var Iy=function(t,e,i){for(var n=t.length,r=0,o=new _y(e);r>l]=c}else for(s=new _y(n),r=0;r>15-t[r]);return s},Ly=new my(288);for(Cy=0;Cye&&(e=t[i]);return e},zy=function(t,e,i){var n=e/8|0;return(t[n]|t[n+1]>(7&e)&i},Ry=function(t,e){var i=e/8|0;return(t[i]|t[i+1]>(7&e)},Oy=["unexpected EOF","invalid block type","invalid length/literal","invalid distance","stream finished","no stream handler",,"no callback","invalid UTF-8 data","extra field too long","date not in range 1980-2099","filename too long","stream finishing","invalid zip data"],By=function(t,e,i){var n=new Error(e||Oy[t]);if(n.code=t,Error.captureStackTrace&&Error.captureStackTrace(n,By),!i)throw n;return n},Fy=new my(0),Ny="undefined"!=typeof TextDecoder&&new TextDecoder;try{Ny.decode(Fy,{stream:!0})}catch(t){}const Uy={gzip_data:"gzip"},jy={0:"uint32",1:"uint32",2:"uint16",3:"uint8"},Vy={uint32:1,uint16:2,uint8:4},Gy={uint32:Uint32Array,uint16:Uint16Array,uint8:Uint8Array};class Zy{constructor(t=1){this.x=NaN,this.y=NaN,this.z=NaN,this.layers={},this._cacheSize=t}getLayer(t){return this.layers[t]}getHeaderLength(t){const e=new Uint8Array(t),i=new DataView(t);if(13!==e[0])throw new fy("File is not a valid MRT.");return i.getUint32(1,!0)}parseHeader(t){const e=new Uint8Array(t),i=this.getHeaderLength(t);if(e.length= ${i} but got buffer of length ${e.length}`);const n=function(t){return t.readFields(iy,{header_length:0,x:0,y:0,z:0,layers:[]},void 0)}(new Lm(e.subarray(0,i)));if(!isNaN(this.x)&&(this.x!==n.x||this.y!==n.y||this.z!==n.z))throw new fy(`Invalid attempt to parse header ${n.z}/${n.x}/${n.y} for tile ${this.z}/${this.x}/${this.y}`);this.x=n.x,this.y=n.y,this.z=n.z;for(const t of n.layers)this.layers[t.name]=new qy(t,{cacheSize:this._cacheSize});return this}createDecodingTask(t){const e=[],i=this.getLayer(t.layerName);for(let n=0;nt.lastBlock)continue;if(i._blocksInProgress.has(n))continue;const a={layerName:i.name,firstByte:o,lastByte:s,pixelFormat:i.pixelFormat,blockIndex:n,blockShape:[r.bands.length].concat(i.bandShape),buffer:i.buffer,codec:r.codec.codec,filters:r.filters.map((t=>t.filter))};i._blocksInProgress.add(n),e.push(a)}return new Hy(e,(()=>{e.forEach((t=>i._blocksInProgress.delete(t.blockIndex)))}),((t,n)=>{if(e.forEach((t=>i._blocksInProgress.delete(t.blockIndex))),t)throw t;n.forEach((t=>{this.getLayer(t.layerName).processDecodedData(t)}))}))}}class qy{constructor({version:t,name:e,units:i,tilesize:n,pixel_format:r,buffer:o,data_index:s},a){if(this.version=t,1!==this.version)throw new fy(`Cannot parse raster layer encoded with MRT version ${t}`);this.name=e,this.units=i,this.tileSize=n,this.buffer=o,this.pixelFormat=jy[r],this.dataIndex=s,this.bandShape=[n+2*o,n+2*o,Vy[this.pixelFormat]],this._decodedBlocks=function(t=1e3,e=0,i=!1){if(isNaN(t)||t=e&&t=0}hasDataForBand(t){const{blockIndex:e}=this.getBlockForBand(t);return e>=0&&!!this._decodedBlocks.get(e.toString())}getBandView(t){const{blockIndex:e,blockBandIndex:i}=this.getBlockForBand(t),n=this._decodedBlocks.get(e.toString());if(!n)throw new fy(`Data for band ${JSON.stringify(t)} of layer "${this.name}" not decoded.`);const r=this.dataIndex[e],o=this.bandShape.reduce(((t,e)=>t*e),1),s=i*o,a=n.subarray(s,s+o);return{data:a,bytes:new Uint8Array(a.buffer).subarray(a.byteOffset,a.byteOffset+a.byteLength),tileSize:this.tileSize,buffer:this.buffer,offset:r.offset,scale:r.scale}}}class Hy{constructor(t,e,i){this.tasks=t,this._onCancel=e,this._onComplete=i,this._finalized=!1}cancel(){this._finalized||(this._onCancel(),this._finalized=!0)}complete(t,e){this._finalized||(this._onComplete(t,e),this._finalized=!0)}}Zy.performDecoding=function(t,e){return Promise.all(e.tasks.map((e=>{const{layerName:i,firstByte:n,lastByte:r,pixelFormat:o,blockShape:s,blockIndex:a,filters:l,codec:c}=e,d=new Uint8Array(t).subarray(n,r+1),u=new Uint32Array(s[0]*s[1]*s[2]);let h;if("gzip_data"!==c)throw new Error(`Unhandled codec: ${c}`);return h=function(t,e){if(!globalThis.DecompressionStream&&"gzip_data"===e)return Promise.resolve(((o=function(t){31==t[0]&&139==t[1]&&8==t[2]||By(6,"invalid gzip data");var e=t[3],i=10;4&e&&(i+=2+(t[10]|t[11]>3&1)+(e>>4&1);n>0;n-=!t[i++]);return i+(2&e)}(r=t))+8>r.length&&By(6,"invalid gzip data"),function(t,e,i){var n=t.length;if(!n||e.f&&!e.l)return i||new my(0);var r=!i,o=r||2!=e.i,s=e.i;r&&(i=new my(3*n));var a,l,c=function(t){var e=i.length;if(t>e){var n=new my(Math.max(2*e,t));n.set(i),i=n}},d=e.f||0,u=e.p||0,h=e.b||0,p=e.l,f=e.d,m=e.m,_=e.n,g=8*n;do{if(!p){d=zy(t,u,1);var y=zy(t,u+1,3);if(u+=3,!y){var v=t[(L=4+((u+7)/8|0))-4]|t[L-3]n){s&&By(0);break}o&&c(h+v),i.set(t.subarray(L,x),h),e.b=h+=v,e.p=u=8*x,e.f=d;continue}if(1==y)p=$y,f=ky,m=9,_=5;else if(2==y){var b=zy(t,u,31)+257,w=zy(t,u+10,15)+4,T=b+zy(t,u+5,31)+1;u+=14;for(var S=new my(T),E=new my(19),M=0;M>4)g){s&&By(0);break}}o&&c(h+131072);for(var R=(1>4;if((u+=15&$)>g){s&&By(0);break}if($||By(2),F264&&(N=zy(t,u,(1>4;if(U||By(3),u+=15&U,z=Ey[j],j>3){var V=vy[j];z+=Ry(t,u)&(1g){s&&By(0);break}o&&c(h+131072);var G=h+N;if(ha.length)&&(l=a.length),new my(a.subarray(0,l))):i.subarray(0,h)}(r.subarray(o,-8),{i:2},new my(((i=r)[(n=i.length)-4]|i[n-3]>>0))));var i,n,r,o;const s=Uy[e];if(!s)throw new Error(`Unhandled codec: ${e}`);const a=new globalThis.DecompressionStream(s);return new Response(new Blob([t]).stream().pipeThrough(a)).arrayBuffer().then((t=>new Uint8Array(t)))}(d,c).then((t=>(function(t,e){t.readFields(ly,e)}(new Lm(t),u),new(0,Gy[o])(u.buffer)))),h.then((t=>{for(let e=l.length-1;e>=0;e--)switch(l[e]){case"delta_filter":uy(t,s);break;case"zigzag_filter":hy(t);break;case"bitshuffle_filter":py(t,o);break;default:throw new Error(`Unhandled filter "${l[e]}"`)}return{layerName:i,blockIndex:a,data:t}})).catch((t=>{throw t}))})))};class Wy extends ey{constructor(t,e,i,n,r){super(t,e,i,n,r),this._workQueue=[],this._fetchQueue=[],this._isHeaderLoaded=!1}setTexture(t,e){const i=e.context,n=i.gl;this.texture=this.texture||e.getTileTexture(t.width),this.texture&&this.texture instanceof Vg?this.texture.update(t,{useMipmap:!1,premultiply:!1}):this.texture=new Vg(i,t,n.RGBA,{useMipmap:!1,premultiply:!1})}flushQueues(){for(;this._workQueue.length;)this._workQueue.pop()();for(;this._fetchQueue.length;)this._fetchQueue.pop()()}fetchHeader(t=16384,e){const i=this._mrt=new Zy(30),n=Object.assign({},this.requestParams,{headers:{Range:"bytes=0-"+(t-1)}});return this.entireBuffer=null,this.request=en(n,((n,r,o,s)=>{if(n)e(n);else try{const n=i.getHeaderLength(r);if(n>t)return void(this.request=this.fetchHeader(n,e));i.parseHeader(r),this._isHeaderLoaded=!0;let a=0;for(const t of Object.values(i.layers))a=Math.max(a,t.dataIndex[t.dataIndex.length-1].last_byte);r.byteLength>=a&&(this.entireBuffer=r),e(null,this.entireBuffer||r,o,s)}catch(t){e(t)}})),this.request}fetchBand(t,e,i){const n=this._mrt;if(!this._isHeaderLoaded||!n)return void i(new Error("Tile header is not ready"));const r=this.actor;if(!r)return void i(new Error("Can't fetch tile band without an actor"));let o;const s=(n,r)=>{o.complete(n,r),n?i(n):(this.updateTextureDescriptor(t,e),i(null,this.textureDescriptor&&this.textureDescriptor.img))},a=(t,e)=>{if(t)return i(t);const n=r.send("decodeRasterArray",{buffer:e,task:o},s,void 0,!0);this._workQueue.push((()=>{n&&n.cancel(),o.cancel()}))},l=n.getLayer(t);if(!l)return void i(new Error(`Unknown sourceLayer "${t}"`));if(l.hasDataForBand(e))return this.updateTextureDescriptor(t,e),void i(null,this.textureDescriptor?this.textureDescriptor.img:null);const c=l.getDataRange([e]);if(o=n.createDecodingTask(c),!o||o.tasks.length)if(this.flushQueues(),this.entireBuffer)a(null,this.entireBuffer.slice(c.firstByte,c.lastByte+1));else{const t=Object.assign({},this.requestParams,{headers:{Range:`bytes=${c.firstByte}-${c.lastByte}`}}),e=en(t,a);this._fetchQueue.push((()=>{e.cancel(),o.cancel()}))}else i(null)}updateNeeded(t,e){return(!this.textureDescriptor||this.textureDescriptor.band!==e||this.textureDescriptor.layer!==t)&&"errored"!==this.state}updateTextureDescriptor(t,e){if(!this._mrt)return;const i=this._mrt.getLayer(t);if(!i||!i.hasBand(e)||!i.hasDataForBand(e))return;const{bytes:n,tileSize:r,buffer:o,offset:s,scale:a}=i.getBandView(e),l=r+2*o,c={data:n,width:l,height:l},d=this.texture;d&&d instanceof Vg&&d.update(c,{useMipmap:!1,premultiply:!1}),this.textureDescriptor={layer:t,band:e,img:c,buffer:o,offset:s,tileSize:r,format:i.pixelFormat,mix:[a,256*a,65536*a,16777216*a]}}}class Yy{constructor(t,e){this.max=t,this.onRemove=e,this.reset()}reset(){for(const t in this.data)for(const e of this.data[t])e.timeout&&clearTimeout(e.timeout),this.onRemove(e.value);return this.data={},this.order=[],this}add(t,e,i){const n=t.wrapped().key;void 0===this.data[n]&&(this.data[n]=[]);const r={value:e,timeout:void 0};if(void 0!==i&&(r.timeout=setTimeout((()=>{this.remove(t,r)}),i)),this.data[n].push(r),this.order.push(n),this.order.length>this.max){const t=this._getAndRemoveByKey(this.order[0]);t&&this.onRemove(t)}return this}has(t){return t.wrapped().key in this.data}getAndRemove(t){return this.has(t)?this._getAndRemoveByKey(t.wrapped().key):null}_getAndRemoveByKey(t){const e=this.data[t].shift();return e.timeout&&clearTimeout(e.timeout),0===this.data[t].length&&delete this.data[t],this.order.splice(this.order.indexOf(t),1),e.value}getByKey(t){const e=this.data[t];return e?e[0].value:null}get(t){return this.has(t)?this.data[t.wrapped().key][0].value:null}remove(t,e){if(!this.has(t))return this;const i=t.wrapped().key,n=void 0===e?0:this.data[i].indexOf(e),r=this.data[i][n];return this.data[i].splice(n,1),r.timeout&&clearTimeout(r.timeout),0===this.data[i].length&&delete this.data[i],this.onRemove(r.value),this.order.splice(this.order.indexOf(i),1),this}setMaxSize(t){for(this.max=t;this.order.length>this.max;){const t=this._getAndRemoveByKey(this.order[0]);t&&this.onRemove(t)}return this}filter(t){const e=[];for(const i in this.data)for(const n of this.data[i])t(n.value)||e.push(n);for(const t of e)this.remove(t.value.tileID,t)}}class Xy extends zn{constructor(t,e,i){super(),this.id=t,this._onlySymbols=i,e.on("data",(t=>{"source"===t.dataType&&"metadata"===t.sourceDataType&&(this._sourceLoaded=!0),this._sourceLoaded&&!this._paused&&"source"===t.dataType&&"content"===t.sourceDataType&&(this.reload(),this.transform&&this.update(this.transform))})),e.on("error",(()=>{this._sourceErrored=!0})),this._source=e,this._tiles={},this._cache=new Yy(0,this._unloadTile.bind(this)),this._timers={},this._cacheTimers={},this._minTileCacheSize=e.minTileCacheSize,this._maxTileCacheSize=e.maxTileCacheSize,this._loadedParentTiles={},this.castsShadows=!1,this.tileCoverLift=0,this._coveredTiles={},this._shadowCasterTiles={},this._state=new km,this._isRaster="raster"===this._source.type||"raster-dem"===this._source.type||"raster-array"===this._source.type||"custom"===this._source.type&&"raster"===this._source._dataType}onAdd(t){this.map=t,this._minTileCacheSize=void 0===this._minTileCacheSize&&t?t._minTileCacheSize:this._minTileCacheSize,this._maxTileCacheSize=void 0===this._maxTileCacheSize&&t?t._maxTileCacheSize:this._maxTileCacheSize}loaded(){if(this._sourceErrored)return!0;if(!this._sourceLoaded)return!1;if(!this._source.loaded())return!1;for(const t in this._tiles){const e=this._tiles[t];if("errored"!==e.state&&("loaded"!==e.state||!e.bucketsLoaded()))return!1}return!0}getSource(){return this._source}pause(){this._paused=!0}resume(){if(!this._paused)return;const t=this._shouldReloadOnResume;this._paused=!1,this._shouldReloadOnResume=!1,t&&this.reload(),this.transform&&this.update(this.transform)}_loadTile(t,e){return t.isSymbolTile=this._onlySymbols,t.isExtraShadowCaster=this._shadowCasterTiles[t.tileID.key],this._source.loadTile(t,e)}_unloadTile(t){if(this._source.unloadTile)return this._source.unloadTile(t)}_abortTile(t){if(this._source.abortTile)return this._source.abortTile(t)}serialize(){return this._source.serialize()}prepare(t){this._source.prepare&&this._source.prepare(),this._state.coalesceChanges(this._tiles,this.map?this.map.painter:null);for(const e in this._tiles){const i=this._tiles[e];i.upload(t),i.prepare(this.map.style.imageManager,this.map?this.map.painter:null,this._source.scope)}}getIds(){return ti(this._tiles).map((t=>t.tileID)).sort(Ky).map((t=>t.key))}getRenderableIds(t,e){const i=[];for(const n in this._tiles)this._isIdRenderable(+n,t,e)&&i.push(this._tiles[n]);return t?i.sort(((t,e)=>{const i=t.tileID,n=e.tileID,r=new Ue(i.canonical.x,i.canonical.y)._rotate(this.transform.angle),o=new Ue(n.canonical.x,n.canonical.y)._rotate(this.transform.angle);return i.overscaledZ-n.overscaledZ||o.y-r.y||o.x-r.x})).map((t=>t.tileID.key)):i.map((t=>t.tileID)).sort(Ky).map((t=>t.key))}hasRenderableParent(t){const e=this.findLoadedParent(t,0);return!!e&&this._isIdRenderable(e.tileID.key)}_isIdRenderable(t,e,i){return this._tiles[t]&&this._tiles[t].hasData()&&!this._coveredTiles[t]&&(e||!this._tiles[t].holdingForFade())&&(i||!this._shadowCasterTiles[t])}reload(){if(this._paused)this._shouldReloadOnResume=!0;else{this._cache.reset();for(const t in this._tiles)"errored"!==this._tiles[t].state&&this._reloadTile(+t,"reloading")}}_reloadTile(t,e){const i=this._tiles[t];i&&("loading"!==i.state&&(i.state=e),this._loadTile(i,this._tileLoaded.bind(this,i,t,e)))}_tileLoaded(t,e,i,n){if(n)if(t.state="errored",404!==n.status)this._source.fire(new $n(n,{tile:t}));else{if(!(t.tileID.key in this._loadedParentTiles))return void this._source.fire(new Pn("data",{dataType:"source",sourceDataType:"error",sourceId:this._source.id}));if("raster-dem"===this._source.type&&this.usedForTerrain&&this.map.painter.terrain){const t=this.map.painter.terrain;this.update(this.transform,t.getScaledDemTileSize(),!0),t.resetTileLookupCache(this.id)}else this.update(this.transform)}else t.timeAdded=ki.now(),"expired"===i&&(t.refreshedUponExpiration=!0),this._setTileReloadTimer(e,t),"raster-dem"===this._source.type&&t.dem&&this._backfillDEM(t),this._state.initializeTileState(t,this.map?this.map.painter:null),this._source.fire(new Pn("data",{dataType:"source",tile:t,coord:t.tileID,sourceCacheId:this.id}))}_backfillDEM(t){const e=this.getRenderableIds();for(let n=0;n1||(Math.abs(i)>1&&(1===Math.abs(i+r)?i+=r:1===Math.abs(i-r)&&(i-=r)),e.dem&&t.dem&&(t.dem.backfillBorder(e.dem,i,n),t.neighboringTiles&&t.neighboringTiles[o]&&(t.neighboringTiles[o].backfilled=!0)))}}getTile(t){return this.getTileByID(t.key)}getTileByID(t){return this._tiles[t]}_retainLoadedChildren(t,e,i,n){for(const r in this._tiles){let o=this._tiles[r];if(n[r]||!o.hasData()||o.tileID.overscaledZi)continue;let s=o.tileID;for(;o&&o.tileID.overscaledZ>e+1;){const t=o.tileID.scaledTo(o.tileID.overscaledZ-1);o=this._tiles[t.key],o&&o.hasData()&&(s=t)}let a=s;for(;a.overscaledZ>e;)if(a=a.scaledTo(a.overscaledZ-1),t[a.key]){n[s.key]=s;break}}}findLoadedParent(t,e){if(t.key in this._loadedParentTiles){const i=this._loadedParentTiles[t.key];return i&&i.tileID.overscaledZ>=e?i:null}for(let i=t.overscaledZ-1;i>=e;i--){const e=t.scaledTo(i),n=this._getLoadedTile(e);if(n)return n}}_getLoadedTile(t){const e=this._tiles[t.key];return e&&e.hasData()?e:this._cache.getByKey(this._source.reparseOverscaled?t.wrapped().key:t.canonical.key)}updateCacheSize(t,e){e=e||this._source.tileSize;const i=Math.ceil(t.width/e)+1,n=Math.ceil(t.height/e)+1,r=Math.floor(i*n*5),o="number"==typeof this._minTileCacheSize?Math.max(this._minTileCacheSize,r):r,s="number"==typeof this._maxTileCacheSize?Math.min(this._maxTileCacheSize,o):o;this._cache.setMaxSize(s)}handleWrapJump(t){const e=Math.round((t-(void 0===this._prevLng?t:this._prevLng))/360);if(this._prevLng=t,e){const t={};for(const i in this._tiles){const n=this._tiles[i];n.tileID=n.tileID.unwrapTo(n.tileID.wrap+e),t[n.tileID.key]=n}this._tiles=t;for(const t in this._timers)clearTimeout(this._timers[t]),delete this._timers[t];for(const t in this._tiles)this._setTileReloadTimer(+t,this._tiles[t])}}update(t,e,i,n){if(this.transform=t,!this._sourceLoaded||this._paused||this.transform.freezeTileCoverage)return;if(this.usedForTerrain&&!i)return;let r;if(this.updateCacheSize(t,e),"globe"!==this.transform.projection.name&&this.handleWrapJump(this.transform.center.lng),this._shadowCasterTiles={},this._coveredTiles={},this.used||this.usedForTerrain){if(this._source.tileID)r=t.getVisibleUnwrappedCoordinates(this._source.tileID).map((t=>new vd(t.canonical.z,t.wrap,t.canonical.z,t.canonical.x,t.canonical.y)));else if(0!==this.tileCoverLift){const n=t.clone();n.tileCoverLift=this.tileCoverLift,r=n.coveringTiles({tileSize:e||this._source.tileSize,minzoom:this._source.minzoom,maxzoom:this._source.maxzoom,roundZoom:this._source.roundZoom&&!i,reparseOverscaled:this._source.reparseOverscaled,isTerrainDEM:this.usedForTerrain}),this._source.minzoomt(e)))}}else r=[];if(r.length>0&&this.castsShadows&&n&&"globe"!==this.transform.projection.name&&!this.usedForTerrain&&!Jy(this._source.type)){const o=t.coveringZoomLevel({tileSize:e||this._source.tileSize,roundZoom:this._source.roundZoom&&!i}),s=Math.min(o,this._source.maxzoom),a=t.extendTileCoverForShadows(r,n,s);for(const t of a)this._shadowCasterTiles[t.key]=!0,r.push(t)}const o=this._updateRetainedTiles(r);if(Jy(this._source.type)&&0!==r.length){const t={},e={},i=Object.keys(o);for(const n of i){const i=o[n],r=this._tiles[n];if(!r||r.fadeEndTime&&r.fadeEndTimen;){r=r.scaledTo(r.overscaledZ-1);const n=this._tiles[r.key];if(n&&n.hasData()&&e[r.key]){o[t]=i.tileID;break}}}for(const e in t)o[e]||(this._coveredTiles[e]=!0,o[e]=t[e])}for(const t in o)this._tiles[t].clearFadeHold();const s=function(t,e){const i=[];for(const n in t)n in e||i.push(n);return i}(this._tiles,o);for(const t of s){const e=this._tiles[t];e.hasSymbolBuckets&&!e.holdingForFade()?e.setHoldDuration(this.map._fadeDuration):e.hasSymbolBuckets&&!e.symbolFadeFinished()||this._removeTile(+t)}this._updateLoadedParentTileCache(),this._onlySymbols&&this._source.afterUpdate&&this._source.afterUpdate()}releaseSymbolFadeTiles(){for(const t in this._tiles)this._tiles[t].holdingForFade()&&this._removeTile(+t)}_updateRetainedTiles(t){const e={};if(0===t.length)return e;const i={},n=t.reduce(((t,e)=>Math.min(t,e.overscaledZ)),1/0),r=t[0].overscaledZ,o=Math.max(r-Xy.maxOverzooming,this._source.minzoom),s=Math.max(r+Xy.maxUnderzooming,this._source.minzoom),a={};for(const i of t){const t=this._addTile(i);e[i.key]=i,t.hasData()||n=this._source.maxzoom){const t=n.children(this._source.maxzoom)[0],i=this.getTile(t);if(i&&i.hasData()){e[t.key]=t;continue}}else{const t=n.children(this._source.maxzoom);if(e[t[0].key]&&e[t[1].key]&&e[t[2].key]&&e[t[3].key])continue}let r=t.wasRequested();for(let s=n.overscaledZ-1;s>=o;--s){const o=n.scaledTo(s);if(i[o.key])break;if(i[o.key]=!0,t=this.getTile(o),!t&&r&&(t=this._addTile(o)),t&&(e[o.key]=o,r=t.wasRequested(),t.hasData()))break}}return e}_updateLoadedParentTileCache(){this._loadedParentTiles={};for(const t in this._tiles){const e=[];let i,n=this._tiles[t].tileID;for(;n.overscaledZ>0;){if(n.key in this._loadedParentTiles){i=this._loadedParentTiles[n.key];break}e.push(n.key);const t=n.scaledTo(n.overscaledZ-1);if(i=this._getLoadedTile(t),i)break;n=t}for(const t of e)this._loadedParentTiles[t]=i}}_addTile(t){let e=this._tiles[t.key];if(e)return!0!==e.isExtraShadowCaster||!!this._shadowCasterTiles[t.key]||this._reloadTile(t.key,"reloading"),e;e=this._cache.getAndRemove(t),e&&(this._setTileReloadTimer(t.key,e),e.tileID=t,this._state.initializeTileState(e,this.map?this.map.painter:null),this._cacheTimers[t.key]&&(clearTimeout(this._cacheTimers[t.key]),delete this._cacheTimers[t.key],this._setTileReloadTimer(t.key,e)));const i=Boolean(e);if(!i){const i=this.map?this.map.painter:null,n=this._source.tileSize*t.overscaleFactor();e="raster-array"===this._source.type?new Wy(t,n,this.transform.tileZoom,i,this._isRaster):new ey(t,n,this.transform.tileZoom,i,this._isRaster),this._loadTile(e,this._tileLoaded.bind(this,e,t.key,e.state))}return e?(e.uses++,this._tiles[t.key]=e,i||this._source.fire(new Pn("dataloading",{tile:e,coord:e.tileID,dataType:"source"})),e):null}_setTileReloadTimer(t,e){t in this._timers&&(clearTimeout(this._timers[t]),delete this._timers[t]);const i=e.getExpiryTimeout();i&&(this._timers[t]=setTimeout((()=>{this._reloadTile(t,"expired"),delete this._timers[t]}),i))}_removeTile(t){const e=this._tiles[t];e&&(e.uses--,delete this._tiles[t],this._timers[t]&&(clearTimeout(this._timers[t]),delete this._timers[t]),e.uses>0||(e.hasData()&&"reloading"!==e.state||"empty"===e.state?this._cache.add(e.tileID,e,e.getExpiryTimeout()):(e.aborted=!0,this._abortTile(e),this._unloadTile(e))))}clearTiles(){this._shouldReloadOnResume=!1,this._paused=!1;for(const t in this._tiles)this._removeTile(+t);this._source._clear&&this._source._clear(),this._cache.reset(),this.map&&this.usedForTerrain&&this.map.painter.terrain&&this.map.painter.terrain.resetTileLookupCache(this.id)}tilesIn(t,e,i){const n=[],r=this.transform;if(!r)return n;const o="globe"===r.projection.name,s=Ed(r.center.lng);for(const a in this._tiles){const l=this._tiles[a];if(i&&l.clearQueryDebugViz(),l.holdingForFade())continue;let c;if(o){const t=l.tileID.canonical;if(0===t.z){const e=[Math.abs(Xe(s,...Qy(t,-1))-s),Math.abs(Xe(s,...Qy(t,1))-s)];c=[0,2*e.indexOf(Math.min(...e))-1]}else{const e=[Math.abs(Xe(s,...Qy(t,-1))-s),Math.abs(Xe(s,...Qy(t,0))-s),Math.abs(Xe(s,...Qy(t,1))-s)];c=[e.indexOf(Math.min(...e))-1]}}else c=[0];for(const i of c){const o=t.containsTile(l,r,e,i);o&&n.push(o)}}return n}getShadowCasterCoordinates(){return this._getRenderableCoordinates(!1,!0)}getVisibleCoordinates(t){return this._getRenderableCoordinates(t)}_getRenderableCoordinates(t,e){const i=this.getRenderableIds(t,e).map((t=>this._tiles[t].tileID)),n="globe"===this.transform.projection.name;for(const t of i)t.projMatrix=this.transform.calculateProjMatrix(t.toUnwrapped()),t.expandedProjMatrix=n?this.transform.calculateProjMatrix(t.toUnwrapped(),!1,!0):t.projMatrix;return i}sortCoordinatesByDistance(t){const e=t.slice(),i=this.transform._camera.position,n=this.transform._camera.forward(),r={};for(const t of e){const e=1/(1r[t.key]-r[e.key])),e}hasTransition(){if(this._source.hasTransition())return!0;if(Jy(this._source.type))for(const t in this._tiles){const e=this._tiles[t];if(void 0!==e.fadeEndTime&&e.fadeEndTime>=ki.now())return!0}return!1}setFeatureState(t,e,i){this._state.updateState(t=t||"_geojsonTileLayer",e,i)}removeFeatureState(t,e,i){this._state.removeFeatureState(t=t||"_geojsonTileLayer",e,i)}getFeatureState(t,e){return this._state.getState(t=t||"_geojsonTileLayer",e)}setDependencies(t,e,i){const n=this._tiles[t];n&&n.setDependencies(e,i)}reloadTilesForDependencies(t,e){for(const i in this._tiles)this._tiles[i].hasDependency(t,e)&&this._reloadTile(+i,"reloading");this._cache.filter((i=>!i.hasDependency(t,e)))}_preloadTiles(t,e){if(!this._sourceLoaded){const i=()=>{this._sourceLoaded&&(this._source.off("data",i),this._preloadTiles(t,e))};return void this._source.on("data",i)}const i=new Map,n=Array.isArray(t)?t:[t],r=this.map.painter.terrain,o=this.usedForTerrain&&r?r.getScaledDemTileSize():this._source.tileSize;for(const t of n){const e=t.coveringTiles({tileSize:o,minzoom:this._source.minzoom,maxzoom:this._source.maxzoom,roundZoom:this._source.roundZoom&&!this.usedForTerrain,reparseOverscaled:this._source.reparseOverscaled,isTerrainDEM:this.usedForTerrain});for(const t of e)i.set(t.key,t);this.usedForTerrain&&t.updateElevation(!1)}Qe(Array.from(i.values()),((t,e)=>{const i=new ey(t,this._source.tileSize*t.overscaleFactor(),this.transform.tileZoom,this.map.painter,this._isRaster);this._loadTile(i,(t=>{"raster-dem"===this._source.type&&i.dem&&this._backfillDEM(i),e(t,i)}))}),e)}}function Ky(t,e){const i=Math.abs(2*t.wrap)-+(t.wrap0?e+2*t:t}tv.useIntegerZoom=!0;const iv=new ol({"symbol-placement":new il(sl.layout_symbol["symbol-placement"]),"symbol-spacing":new il(sl.layout_symbol["symbol-spacing"]),"symbol-avoid-edges":new il(sl.layout_symbol["symbol-avoid-edges"]),"symbol-sort-key":new nl(sl.layout_symbol["symbol-sort-key"]),"symbol-z-order":new il(sl.layout_symbol["symbol-z-order"]),"symbol-z-elevate":new il(sl.layout_symbol["symbol-z-elevate"]),"icon-allow-overlap":new il(sl.layout_symbol["icon-allow-overlap"]),"icon-ignore-placement":new il(sl.layout_symbol["icon-ignore-placement"]),"icon-optional":new il(sl.layout_symbol["icon-optional"]),"icon-rotation-alignment":new il(sl.layout_symbol["icon-rotation-alignment"]),"icon-size":new nl(sl.layout_symbol["icon-size"]),"icon-text-fit":new nl(sl.layout_symbol["icon-text-fit"]),"icon-text-fit-padding":new nl(sl.layout_symbol["icon-text-fit-padding"]),"icon-image":new nl(sl.layout_symbol["icon-image"]),"icon-rotate":new nl(sl.layout_symbol["icon-rotate"]),"icon-padding":new il(sl.layout_symbol["icon-padding"]),"icon-keep-upright":new il(sl.layout_symbol["icon-keep-upright"]),"icon-offset":new nl(sl.layout_symbol["icon-offset"]),"icon-anchor":new nl(sl.layout_symbol["icon-anchor"]),"icon-pitch-alignment":new il(sl.layout_symbol["icon-pitch-alignment"]),"text-pitch-alignment":new il(sl.layout_symbol["text-pitch-alignment"]),"text-rotation-alignment":new il(sl.layout_symbol["text-rotation-alignment"]),"text-field":new nl(sl.layout_symbol["text-field"]),"text-font":new nl(sl.layout_symbol["text-font"]),"text-size":new nl(sl.layout_symbol["text-size"]),"text-max-width":new nl(sl.layout_symbol["text-max-width"]),"text-line-height":new nl(sl.layout_symbol["text-line-height"]),"text-letter-spacing":new nl(sl.layout_symbol["text-letter-spacing"]),"text-justify":new nl(sl.layout_symbol["text-justify"]),"text-radial-offset":new nl(sl.layout_symbol["text-radial-offset"]),"text-variable-anchor":new il(sl.layout_symbol["text-variable-anchor"]),"text-anchor":new nl(sl.layout_symbol["text-anchor"]),"text-max-angle":new il(sl.layout_symbol["text-max-angle"]),"text-writing-mode":new il(sl.layout_symbol["text-writing-mode"]),"text-rotate":new nl(sl.layout_symbol["text-rotate"]),"text-padding":new il(sl.layout_symbol["text-padding"]),"text-keep-upright":new il(sl.layout_symbol["text-keep-upright"]),"text-transform":new nl(sl.layout_symbol["text-transform"]),"text-offset":new nl(sl.layout_symbol["text-offset"]),"text-allow-overlap":new il(sl.layout_symbol["text-allow-overlap"]),"text-ignore-placement":new il(sl.layout_symbol["text-ignore-placement"]),"text-optional":new il(sl.layout_symbol["text-optional"]),visibility:new il(sl.layout_symbol.visibility)});var nv={paint:new ol({"icon-opacity":new nl(sl.paint_symbol["icon-opacity"]),"icon-occlusion-opacity":new nl(sl.paint_symbol["icon-occlusion-opacity"]),"icon-emissive-strength":new nl(sl.paint_symbol["icon-emissive-strength"]),"text-emissive-strength":new nl(sl.paint_symbol["text-emissive-strength"]),"icon-color":new nl(sl.paint_symbol["icon-color"]),"icon-halo-color":new nl(sl.paint_symbol["icon-halo-color"]),"icon-halo-width":new nl(sl.paint_symbol["icon-halo-width"]),"icon-halo-blur":new nl(sl.paint_symbol["icon-halo-blur"]),"icon-translate":new il(sl.paint_symbol["icon-translate"]),"icon-translate-anchor":new il(sl.paint_symbol["icon-translate-anchor"]),"icon-image-cross-fade":new nl(sl.paint_symbol["icon-image-cross-fade"]),"text-opacity":new nl(sl.paint_symbol["text-opacity"]),"text-occlusion-opacity":new nl(sl.paint_symbol["text-occlusion-opacity"]),"text-color":new nl(sl.paint_symbol["text-color"],{runtimeType:Qn,getOverride:t=>t.textColor,hasOverride:t=>!!t.textColor}),"text-halo-color":new nl(sl.paint_symbol["text-halo-color"]),"text-halo-width":new nl(sl.paint_symbol["text-halo-width"]),"text-halo-blur":new nl(sl.paint_symbol["text-halo-blur"]),"text-translate":new il(sl.paint_symbol["text-translate"]),"text-translate-anchor":new il(sl.paint_symbol["text-translate-anchor"]),"icon-color-saturation":new il(sl.paint_symbol["icon-color-saturation"]),"icon-color-contrast":new il(sl.paint_symbol["icon-color-contrast"]),"icon-color-brightness-min":new il(sl.paint_symbol["icon-color-brightness-min"]),"icon-color-brightness-max":new il(sl.paint_symbol["icon-color-brightness-max"])}),layout:iv};class rv{constructor(t){this.type=t.property.overrides?t.property.overrides.runtimeType:Yn,this.defaultValue=t}evaluate(t){if(t.formattedSection){const e=this.defaultValue.property.overrides;if(e&&e.hasOverride(t.formattedSection))return e.getOverride(t.formattedSection)}return t.feature&&t.featureState?this.defaultValue.evaluate(t.feature,t.featureState):this.defaultValue.property.specification.default}eachChild(t){this.defaultValue.isConstant()||t(this.defaultValue.value._styleExpression.expression)}outputDefined(){return!1}serialize(){return null}}ba(rv,"FormatSectionOverride",{omit:["defaultValue"]});class ov extends Ml{constructor(e,i,n,r){super(e,nv,i,n,r),this._colorAdjustmentMatrix=t.ad.identity([]),this.hasInitialOcclusionOpacityProperties=void 0!==e.paint&&("icon-occlusion-opacity"in e.paint||"text-occlusion-opacity"in e.paint)}recalculate(t,e){super.recalculate(t,e),"auto"===this.layout.get("icon-rotation-alignment")&&(this.layout._values["icon-rotation-alignment"]="point"!==this.layout.get("symbol-placement")?"map":"viewport"),"auto"===this.layout.get("text-rotation-alignment")&&(this.layout._values["text-rotation-alignment"]="point"!==this.layout.get("symbol-placement")?"map":"viewport"),"auto"===this.layout.get("text-pitch-alignment")&&(this.layout._values["text-pitch-alignment"]=this.layout.get("text-rotation-alignment")),"auto"===this.layout.get("icon-pitch-alignment")&&(this.layout._values["icon-pitch-alignment"]=this.layout.get("icon-rotation-alignment"));const i=this.layout.get("text-writing-mode");if(i){const t=[];for(const e of i)t.indexOf(e)i in t?String(t[i]):""))}(e.properties,r)}createBucket(t){return new jg(t)}queryRadius(){return 0}queryIntersectsFeature(){return!1}_setPaintOverrides(){for(const t of nv.paint.overridableProperties){if(!ov.hasPaintOverride(this.layout,t))continue;const e=this.paint.get(t),i=new rv(e),n=new la(i,e.property.specification,this.scope,this.options);let r=null;r="constant"===e.value.kind||"source"===e.value.kind?new ua("source",n):new ha("composite",n,e.value.zoomStops,e.value._interpolationType),this.paint._values[t]=new tl(e.property,r,e.parameters)}}_handleOverridablePaintPropertyUpdate(t,e,i){return!(!this.layout||e.isDataDriven()||i.isDataDriven())&&ov.hasPaintOverride(this.layout,t)}static hasPaintOverride(t,e){const i=t.get("text-field"),n=nv.paint.properties[e];let r=!1;const o=t=>{for(const e of t)if(n.overrides&&n.overrides.hasOverride(e))return void(r=!0)};if("constant"===i.value.kind&&i.value.value instanceof pr)o(i.value.value.sections);else if("source"===i.value.kind){const t=e=>{r||(e instanceof vr&&gr(e.value)===nr?o(e.value.sections):e instanceof Tr?o(e.sections):e.eachChild(t))},e=i.value;e._styleExpression&&t(e._styleExpression.expression)}return r}getProgramIds(){const t=0!==this.paint.get("icon-opacity").constantOr(1),e=0!==this.paint.get("text-opacity").constantOr(1),i=[];return t&&i.push("symbolIcon"),e&&i.push("symbolSDF"),i}getDefaultProgramParams(t,e,i){return{config:new Wc(this,{zoom:e,lut:i}),overrideFog:!1}}}const sv=new ol({visibility:new il(sl.layout_background.visibility)});var av={paint:new ol({"background-color":new il(sl.paint_background["background-color"]),"background-pattern":new il(sl.paint_background["background-pattern"]),"background-opacity":new il(sl.paint_background["background-opacity"]),"background-emissive-strength":new il(sl.paint_background["background-emissive-strength"])}),layout:sv};const lv=new ol({visibility:new il(sl.layout_raster.visibility)});var cv={paint:new ol({"raster-opacity":new il(sl.paint_raster["raster-opacity"]),"raster-color":new rl(sl.paint_raster["raster-color"]),"raster-color-mix":new il(sl.paint_raster["raster-color-mix"]),"raster-color-range":new il(sl.paint_raster["raster-color-range"]),"raster-hue-rotate":new il(sl.paint_raster["raster-hue-rotate"]),"raster-brightness-min":new il(sl.paint_raster["raster-brightness-min"]),"raster-brightness-max":new il(sl.paint_raster["raster-brightness-max"]),"raster-saturation":new il(sl.paint_raster["raster-saturation"]),"raster-contrast":new il(sl.paint_raster["raster-contrast"]),"raster-resampling":new il(sl.paint_raster["raster-resampling"]),"raster-fade-duration":new il(sl.paint_raster["raster-fade-duration"]),"raster-emissive-strength":new il(sl.paint_raster["raster-emissive-strength"]),"raster-array-band":new il(sl.paint_raster["raster-array-band"]),"raster-elevation":new il(sl.paint_raster["raster-elevation"])}),layout:lv};function dv(e,i,n,r,o,s,a,l){const c=[e,i,1,n,r,1,o,s,1],d=[a,l,1],u=t.bC.adjoint([],c),[h,p,f]=t._.transformMat3(d,d,u);return t.bC.multiply(c,c,[h,0,0,0,p,0,0,0,f])}function uv(e,i,n,r,o,s,a,l){const c=function(e,i,n,r,o,s,a,l){const c=dv(0,0,1,0,1,1,0,1),d=dv(e,i,n,r,o,s,a,l),u=t.bC.adjoint([],c);return t.bC.multiply(d,d,u)}(e,i,n,r,o,s,a,l);return[c[2]/c[8]/uo,c[5]/c[8]/uo]}function hv(t){return[t[0],Math.min(Math.max(t[1],-Pd),Pd)]}class pv extends zn{constructor(t,e,i,n){super(),this.id=t,this.dispatcher=i,this.coordinates=e.coordinates,this.type="image",this.minzoom=0,this.maxzoom=22,this.tileSize=512,this.tiles={},this._loaded=!1,this.onNorthPole=!1,this.onSouthPole=!1,this.setEventedParent(n),this.options=e,this._dirty=!1}load(t,e){if(this._loaded=e||!1,this.fire(new Pn("dataloading",{dataType:"source"})),this.url=this.options.url,!this.url)return t&&(this.coordinates=t),this._loaded=!0,void this._finishLoading();this._imageRequest=an(this.map._requestManager.transformRequest(this.url,Ki.Image),((e,i)=>{this._imageRequest=null,this._loaded=!0,e?this.fire(new $n(e)):i&&(this.image=i instanceof HTMLImageElement?ki.getImageData(i):i,this._dirty=!0,this.width=this.image.width,this.height=this.image.height,t&&(this.coordinates=t),this._finishLoading())}))}loaded(){return this._loaded}updateImage(t){return t.url?(this._imageRequest&&t.url!==this.options.url&&(this._imageRequest.cancel(),this._imageRequest=null),this.options.url=t.url,this.load(t.coordinates,this._loaded),this):this}setTexture(t){if(!(t.handle instanceof WebGLTexture))throw new Error("The provided handle is not a WebGLTexture instance");return this.texture=new Gg(this.map.painter.context,t.handle),this.width=t.dimensions[0],this.height=t.dimensions[1],this._dirty=!1,this._loaded=!0,this._finishLoading(),this}_finishLoading(){this.map&&(this.setCoordinates(this.coordinates),this.fire(new Pn("data",{dataType:"source",sourceDataType:"metadata"})))}onAdd(t){this.map=t,this.load()}onRemove(t){this._imageRequest&&(this._imageRequest.cancel(),this._imageRequest=null),!this.texture||this.texture instanceof Gg||this.texture.destroy(),this.boundsBuffer&&(this.boundsBuffer.destroy(),this.elevatedGlobeVertexBuffer&&this.elevatedGlobeVertexBuffer.destroy(),this.elevatedGlobeIndexBuffer&&this.elevatedGlobeIndexBuffer.destroy())}setCoordinates(t){if(this.coordinates=t,this._boundsArray=void 0,this._unsupportedCoords=!1,!t.length)return this;this.onNorthPole=!1,this.onSouthPole=!1;let e=t[0][1],i=t[0][1];for(const n of t)n[1]>i&&(i=n[1]),n[1]Pd?this.onNorthPole=!0:n1&&(l-=1),new gd(s,l,Math.floor((i+r)/2*a))}(e),this.minzoom=this.maxzoom=this.tileID.z}return this.fire(new Pn("data",{dataType:"source",sourceDataType:"content"})),this}_clear(){this._boundsArray=void 0,this._unsupportedCoords=!1}_prepareData(e){for(const t in this.tiles){const e=this.tiles[t];"loaded"!==e.state&&(e.state="loaded",e.texture=this.texture)}if(this._boundsArray||this.onNorthPole||this.onSouthPole||this._unsupportedCoords)return;const i=eg(new gd(0,0,0),this.map.transform.projection),n=[i.projection.project(this.coordinates[0][0],this.coordinates[0][1]),i.projection.project(this.coordinates[1][0],this.coordinates[1][1]),i.projection.project(this.coordinates[2][0],this.coordinates[2][1]),i.projection.project(this.coordinates[3][0],this.coordinates[3][1])];if(!function(t){const e=t[1].x-t[0].x,i=t[1].y-t[0].y,n=t[2].x-t[1].x,r=t[2].y-t[1].y,o=t[3].x-t[2].x,s=t[3].y-t[2].y,a=t[0].x-t[3].x,l=t[0].y-t[3].y,c=e*r-n*i,d=n*s-o*r,u=o*l-a*s,h=a*i-e*l;return c>0&&d>0&&u>0&&h>0||c{const e=r.projection.project(t[0],t[1]);return ig(r,e)._round()}));this.perspectiveTransform=uv(o.x,o.y,s.x,s.y,a.x,a.y,l.x,l.y);const c=this._boundsArray=new Dl;c.emplaceBack(o.x,o.y,0,0),c.emplaceBack(s.x,s.y,uo,0),c.emplaceBack(l.x,l.y,0,uo),c.emplaceBack(a.x,a.y,uo,uo),this.boundsBuffer&&(this.boundsBuffer.destroy(),this.elevatedGlobeVertexBuffer&&this.elevatedGlobeVertexBuffer.destroy(),this.elevatedGlobeIndexBuffer&&this.elevatedGlobeIndexBuffer.destroy()),this.boundsBuffer=e.createVertexBuffer(c,Jg.members),this.boundsSegments=wc.simpleSegment(0,0,4,2);const d=[],u=function(t){return[hv(t[0]),hv(t[1]),hv(t[2]),hv(t[3])]}(this.coordinates),[h,p,f,m]=function(t){let e=t[0][0],i=e,n=t[0][1],r=n;for(let o=1;oi&&(i=t[o][0]),t[o][1]r&&(r=t[o][1]);return[e,n,i-e,r-n]}(u);{const r=new Dl,[o,s,a,l]=function(t){let e=t[0].x,i=e,n=t[0].y,r=n;for(let o=1;oi&&(i=t[o].x),t[o].yr&&(r=t[o].y);return[e,n,i-e,r-n]}(n),c=t=>[(t.x-o)/a,(t.y-s)/l],[u,_,g,y]=n.map(c),v=function(e,i,n,r,o,s,a,l){const c=dv(0,0,1,0,1,1,0,1),d=dv(e,i,n,r,o,s,a,l),u=t.bC.adjoint([],d);return t.bC.multiply(c,c,u)}(u[0],u[1],_[0],_[1],g[0],g[1],y[0],y[1]);this.elevatedGlobePerspectiveTransform=uv(u[0],u[1],_[0],_[1],g[0],g[1],y[0],y[1]);const x=(e,i)=>{d.push(e.lng);const n=Math.round((e.lng-h)/f*uo),o=Math.round((e.lat-p)/m*uo),s=c(i),a=t._.transformMat3([],[s[0],s[1],1],v),l=Math.round(a[0]/a[2]*uo),u=Math.round(a[1]/a[2]*uo);r.emplaceBack(n,o,l,u)},b=n[3].x-n[0].x,w=n[3].y-n[0].y,T=n[2].x-n[1].x,S=n[2].y-n[1].y;for(let t=0;t{i.emplaceBack(e,n,r);const o=d[e],s=d[n],a=d[r],l=Math.min(Math.min(o,s),a),c=Math.max(Math.max(o,s),a)-l;c>this.maxLongitudeTriangleSize&&(this.maxLongitudeTriangleSize=c),t.push(l+c/2)};for(let t=0;te));i.sort(((e,i)=>t[e]-t[i]));const n=[],r=new Kl;for(let o=0;o{o.segments.push({vertexOffset:0,primitiveOffset:t,vertexLength:e.segments[0].vertexLength,primitiveLength:i,sortKey:void 0,vaos:{}})},a=.51*this.maxLongitudeTriangleSize;if(Math.abs(i[0]-n)0){const n=function(e,i){const n=i.worldSize,r=Cd(1,0)*n*kd(i.center.lat,i.zoom)/Gu(n),o=Cd(1,i.center.lat)*n,s=t.ad.identity([]);return t.ad.rotateY(s,s,Ge(i.center.lng)),t.ad.rotateX(s,s,Ge(i.center.lat)),t.ad.translate(s,s,[0,0,ed]),t.ad.scale(s,s,[r,r,r*o]),t.ad.translate(s,s,[i.point.x-.5*n,i.point.y-.5*n,0]),t.ad.multiply(s,s,e),t.ad.multiply(s,i.globeMatrix,s)}(e,i);return function(e,i,n){const r=(e,i,n)=>{const r=t._.length(e),o=t._.length(i),s=ku(e,i,n);return t._.scale(s,s,1/t._.length(s)*Vn(r,o,n))},o=r([e[0],e[1],e[2]],[i[0],i[1],i[2]],n),s=r([e[4],e[5],e[6]],[i[4],i[5],i[6]],n),a=r([e[8],e[9],e[10]],[i[8],i[9],i[10]],n),l=ku([e[12],e[13],e[14]],[i[12],i[13],i[14]],n);return[o[0],o[1],o[2],0,s[0],s[1],s[2],0,a[0],a[1],a[2],0,l[0],l[1],l[2],1]}(o,n,r)}return o}function kv(t,e,i,n){const r=wu.projectAabbCorners(n,i);let o=Number.MAX_VALUE,s=-1;for(let t=0;tnew Ue(r[t][0],r[t][1]);let l;switch(s){case 0:case 6:l=[a(1),a(5),a(4),a(7),a(3),a(2),a(1)];break;case 1:case 7:l=[a(0),a(4),a(5),a(6),a(2),a(3),a(0)];break;case 3:case 5:l=[a(1),a(0),a(4),a(7),a(6),a(2),a(1)];break;default:l=[a(1),a(5),a(6),a(7),a(3),a(0),a(1)]}if(Yd(t,l))return o}const Dv=Ll([{name:"a_pos_3f",components:3,type:"Float32"}]),zv=Ll([{name:"a_color_3f",components:3,type:"Float32"}]),Rv=Ll([{name:"a_color_4f",components:4,type:"Float32"}]),Ov=Ll([{name:"a_uv_2f",components:2,type:"Float32"}]),Bv=Ll([{name:"a_normal_3f",components:3,type:"Float32"}]),Fv=Ll([{name:"a_normal_matrix0",components:4,type:"Float32"},{name:"a_normal_matrix1",components:4,type:"Float32"},{name:"a_normal_matrix2",components:4,type:"Float32"},{name:"a_normal_matrix3",components:4,type:"Float32"}]),Nv=Ll([{name:"a_pbr",components:4,type:"Uint16"},{name:"a_heightBasedEmissiveStrength",components:3,type:"Float32"}]);class Uv{constructor(t,e,i,n){this.message=(t?`${t}: `:"")+i,n&&(this.identifier=n),null!=e&&e.__line__&&(this.line=e.__line__)}}function jv(t,e){const i=-1===t.indexOf("://");try{return new URL(t,i&&e?"http://example.com":void 0),!0}catch(t){return!1}}class Vv{constructor(t,e){this.feature=t,this.instancedDataOffset=e,this.instancedDataCount=0,this.rotation=[0,0,0],this.scale=[1,1,1],this.translation=[0,0,0]}}class Gv{constructor(){this.instancedDataArray=new oc,this.instancesEvaluatedElevation=[],this.features=[],this.idToFeaturesIndex={}}}class Zv{constructor(t){this.zoom=t.zoom,this.canonical=t.canonical,this.layers=t.layers,this.layerIds=this.layers.map((t=>t.fqid)),this.projection=t.projection,this.index=t.index,this.hasZoomDependentProperties=this.layers[0].isZoomDependent(),this.stateDependentLayerIds=this.layers.filter((t=>t.isStateDependent())).map((t=>t.id)),this.hasPattern=!1,this.instancesPerModel={},this.validForExaggeration=0,this.maxVerticalOffset=0,this.maxScale=0,this.maxHeight=0,this.lookupDim=this.zoom>this.canonical.z?256:this.zoom>15?75:100,this.instanceCount=0,this.terrainElevationMin=0,this.terrainElevationMax=0,this.validForDEMTile={id:null,timestamp:0},this.modelUris=[],this.modelsRequested=!1,this.activeReplacements=[],this.replacementUpdateTime=0}updateFootprints(t,e){}populate(t,e,i,n){this.tileToMeter=zd(i);const r=this.layers[0]._featureFilter.needGeometry;this.lookup=new Uint8Array(this.lookupDim*this.lookupDim);for(const{feature:o,id:s,index:a,sourceLayerIndex:l}of t){const t=null!=s?s:o.properties&&o.properties.hasOwnProperty("id")?o.properties.id:void 0,c=Zd(o,r);if(!this.layers[0]._featureFilter.filter(new Ha(this.zoom),c,i))continue;const d={id:t,sourceLayerIndex:l,index:a,geometry:r?c.geometry:Gd(o,i,n),properties:o.properties,type:o.type,patterns:{}},u=this.addFeature(d,d.geometry,c);u&&e.featureIndex.insert(o,d.geometry,a,l,this.index,this.instancesPerModel[u].instancedDataArray.length,uo/32)}this.lookup=null}update(t,e,i,n){for(const e in this.instancesPerModel){const i=this.instancesPerModel[e];for(const e in t)i.idToFeaturesIndex.hasOwnProperty(e)&&(this.evaluate(i.features[i.idToFeaturesIndex[e]],t[e],i,!0),this.uploaded=!1)}this.maxHeight=0}updateZoomBasedPaintProperties(){if(!this.hasZoomDependentProperties)return!1;let e=!1;for(const i in this.instancesPerModel){const n=this.instancesPerModel[i];for(const i of n.features){const r=this.layers[0],o=i.feature,s=this.canonical,a=r.paint.get("model-rotation").evaluate(o,{},s),l=r.paint.get("model-scale").evaluate(o,{},s),c=r.paint.get("model-translation").evaluate(o,{},s);t._.exactEquals(i.rotation,a)&&t._.exactEquals(i.scale,l)&&t._.exactEquals(i.translation,c)||(this.evaluate(i,i.featureStates,n,!0),e=!0)}}return e}updateReplacement(t,e,i){if(e.updateTime===this.replacementUpdateTime)return!1;this.replacementUpdateTime=e.updateTime;const n=e.getReplacementRegionsForTile(t.toUnwrapped(),!0);if(Pp(this.activeReplacements,n))return!1;this.activeReplacements=n;let r=!1;for(const e in this.instancesPerModel){const n=this.instancesPerModel[e],o=n.instancedDataArray;for(const e of n.features){const n=e.instancedDataOffset,s=e.instancedDataCount;for(let e=0;euo?a-uo:a;const l=Math.floor(a),c=o.float32[s+1];let d=!1;for(const e of this.activeReplacements)if(!(e.orderl||l>e.max.x||e.min.y>c||c>e.max.y)&&(d=Op(Rp(l,c,t.canonical,e.footprintTileId.canonical),e),d))break;o.float32[s]=d?a+uo:a,r=r||d}}}return r}isEmpty(){for(const t in this.instancesPerModel)if(0!==this.instancesPerModel[t].instancedDataArray.length)return!1;return!0}uploadPending(){return!this.uploaded}upload(t){if(!this.uploaded)for(const e in this.instancesPerModel){const i=this.instancesPerModel[e];i.instancedDataArray.length=uo||e.y=uo)continue;const t=(this.lookupDim-1)/uo,i=this.lookupDim*(e.y*t|0)+e.x*t|0;if(this.lookup){if(0!==this.lookup[i])continue;this.lookup[i]=1}this.instanceCount++;const n=s.length;s.resize(n+1),o.instancesEvaluatedElevation.push(0),s.float32[16*n]=e.x,s.float32[16*n+1]=e.y}return a.instancedDataCount=o.instancedDataArray.length-a.instancedDataOffset,a.instancedDataCount>0&&(t.id&&(o.idToFeaturesIndex[t.id]=o.features.length),o.features.push(a),this.evaluate(a,{},o,!1)),r}getModelUris(){return this.modelUris}evaluate(t,e,i,n){const r=this.layers[0],o=t.feature,s=this.canonical,a=t.rotation=r.paint.get("model-rotation").evaluate(o,e,s),l=t.scale=r.paint.get("model-scale").evaluate(o,e,s),c=t.translation=r.paint.get("model-translation").evaluate(o,e,s),d=r.paint.get("model-color").evaluate(o,e,s);d.a=r.paint.get("model-color-mix-intensity").evaluate(o,e,s);const u=[];this.maxVerticalOffset10?this.tileToMeter:zd(s,p)),a[o+4]=c[0],a[o+5]=c[1],a[o+6]=c[2]+l,a[o+7]=u[0],a[o+8]=u[1],a[o+9]=u[2],a[o+10]=u[4],a[o+11]=u[5],a[o+12]=u[6],a[o+13]=u[8],a[o+14]=u[9],a[o+15]=u[10],i.instancesEvaluatedElevation[r]=c[2]}}}ba(Zv,"ModelBucket",{omit:["layers"]}),ba(Gv,"PerModelAttributes"),ba(Vv,"ModelFeature");const qv=new ol({visibility:new il(sl.layout_model.visibility),"model-id":new nl(sl.layout_model["model-id"])});var Hv={paint:new ol({"model-opacity":new il(sl.paint_model["model-opacity"]),"model-rotation":new nl(sl.paint_model["model-rotation"]),"model-scale":new nl(sl.paint_model["model-scale"]),"model-translation":new nl(sl.paint_model["model-translation"]),"model-color":new nl(sl.paint_model["model-color"]),"model-color-mix-intensity":new nl(sl.paint_model["model-color-mix-intensity"]),"model-type":new il(sl.paint_model["model-type"]),"model-cast-shadows":new il(sl.paint_model["model-cast-shadows"]),"model-receive-shadows":new il(sl.paint_model["model-receive-shadows"]),"model-ambient-occlusion-intensity":new il(sl.paint_model["model-ambient-occlusion-intensity"]),"model-emissive-strength":new nl(sl.paint_model["model-emissive-strength"]),"model-roughness":new nl(sl.paint_model["model-roughness"]),"model-height-based-emissive-strength-multiplier":new nl(sl.paint_model["model-height-based-emissive-strength-multiplier"]),"model-cutoff-fade-range":new il(sl.paint_model["model-cutoff-fade-range"]),"model-front-cutoff":new il(sl.paint_model["model-front-cutoff"])}),layout:qv};const Wv=64,Yv={CoordinateSpaceTile:1,CoordinateSpaceYUp:2,HasMapboxMeshFeatures:4,HasMeshoptCompression:8};function Xv(e,i,n,r,o,s,a,l,c,d=!1){const u=n.zoom,h=n.project(r),p=kd(r.lat,u),f=1/p;t.ad.identity(e),t.ad.translate(e,e,[h.x+a[0]*f,h.y+a[1]*f,a[2]]);let m=1,_=1;const g=n.worldSize;if(d){if("mercator"===n.projection.name){let e=0;n.elevation&&(e=n.elevation.getAtPointOrZero(new Rd(h.x/g,h.y/g),0));const i=t.aA.transformMat4([],[h.x,h.y,e,1],n.projMatrix)[3]/n.cameraToCenterDistance;m=i,_=i*kd(n.center.lat,u)}else if("globe"===n.projection.name){const i=$v(e,n),o=t.ad.multiply([],n.projMatrix,i),s=[0,0,0,1];t.aA.transformMat4(s,s,o);const a=s[3]/n.cameraToCenterDistance,l=Hu(u),c=n.projection.pixelsPerMeter(r.lat,g)*kd(r.lat,u),d=n.projection.pixelsPerMeter(n.center.lat,g)*kd(n.center.lat,u);m=a/Vn(c,$d(n.center.lat),l),_=a*p/c,m*=d,_*=d}}else m=f;t.ad.scale(e,e,[m,m,_]);const y=[...e],v=i.orientation,x=[];if(Lv(x,[v[0]+o[0],v[1]+o[1],v[2]+o[2]],s),t.ad.multiply(e,y,x),l&&n.elevation){let o=0;const s=[];if(c&&n.elevation){o=function(e,i,n,r,o){const s=i.elevation;if(!s)return 0;const a=wu.projectAabbCorners(n,r),l=Cd(1,o.lat)*i.worldSize,c=function(e,i){const n=[0,0,1],r=[{corners:[0,1,3,2],dotProductWithUp:0},{corners:[1,5,2,6],dotProductWithUp:0},{corners:[0,4,1,5],dotProductWithUp:0},{corners:[2,6,3,7],dotProductWithUp:0},{corners:[4,7,5,6],dotProductWithUp:0},{corners:[0,3,4,7],dotProductWithUp:0}];for(const o of r){const r=e[o.corners[0]],s=e[o.corners[1]],a=e[o.corners[2]],l=[s[0]-r[0],s[1]-r[1],i*(s[2]-r[2])],c=t._.cross(l,l,[a[0]-r[0],a[1]-r[1],i*(a[2]-r[2])]);t._.normalize(c,c),o.dotProductWithUp=t._.dot(c,n)}return r.sort(((t,e)=>t.dotProductWithUp-e.dotProductWithUp)),r[0].corners}(a,l),d=a[c[0]],u=a[c[1]],h=a[c[2]],p=a[c[3]],f=s.getAtPointOrZero(new Rd(d[0]/i.worldSize,d[1]/i.worldSize),0),m=s.getAtPointOrZero(new Rd(u[0]/i.worldSize,u[1]/i.worldSize),0),_=s.getAtPointOrZero(new Rd(h[0]/i.worldSize,h[1]/i.worldSize),0),g=s.getAtPointOrZero(new Rd(p[0]/i.worldSize,p[1]/i.worldSize),0),y=(f+g)/2,v=(m+_)/2;return y>v?m=e.gl.NEAREST_MIPMAP_NEAREST}),t.uploaded=!0,t.image=null)}function Jv(t,e,i){t.indexBuffer=e.createIndexBuffer(t.indexArray,!1,!0),t.vertexBuffer=e.createVertexBuffer(t.vertexArray,Dv.members,!1,!0),t.normalArray&&(t.normalBuffer=e.createVertexBuffer(t.normalArray,Bv.members,!1,!0)),t.texcoordArray&&(t.texcoordBuffer=e.createVertexBuffer(t.texcoordArray,Ov.members,!1,!0)),t.colorArray&&(t.colorBuffer=e.createVertexBuffer(t.colorArray,(12===t.colorArray.bytesPerElement?zv:Rv).members,!1,!0)),t.featureArray&&(t.pbrBuffer=e.createVertexBuffer(t.featureArray,Nv.members,!0)),t.segments=wc.simpleSegment(0,0,t.vertexArray.length,t.indexArray.length);const n=t.material;n.pbrMetallicRoughness.baseColorTexture&&Kv(n.pbrMetallicRoughness.baseColorTexture,e),n.pbrMetallicRoughness.metallicRoughnessTexture&&Kv(n.pbrMetallicRoughness.metallicRoughnessTexture,e),n.normalTexture&&Kv(n.normalTexture,e),n.occlusionTexture&&Kv(n.occlusionTexture,e,i),n.emissionTexture&&Kv(n.emissionTexture,e)}function Qv(t,e,i){if(t.meshes)for(const n of t.meshes)Jv(n,e,i);if(t.children)for(const n of t.children)Qv(n,e,i)}function tx(t){if(t.meshes)for(const e of t.meshes)e.indexArray.destroy(),e.vertexArray.destroy(),e.colorArray&&e.colorArray.destroy(),e.normalArray&&e.normalArray.destroy(),e.texcoordArray&&e.texcoordArray.destroy(),e.featureArray&&e.featureArray.destroy();if(t.children)for(const e of t.children)tx(e)}function ex(t){if(t.meshes)for(const i of t.meshes)i.vertexBuffer&&(i.vertexBuffer.destroy(),i.indexBuffer.destroy(),i.normalBuffer&&i.normalBuffer.destroy(),i.texcoordBuffer&&i.texcoordBuffer.destroy(),i.colorBuffer&&i.colorBuffer.destroy(),i.pbrBuffer&&i.pbrBuffer.destroy(),i.segments.destroy(),i.material&&((e=i.material).pbrMetallicRoughness.baseColorTexture&&e.pbrMetallicRoughness.baseColorTexture.gfxTexture&&e.pbrMetallicRoughness.baseColorTexture.gfxTexture.destroy(),e.pbrMetallicRoughness.metallicRoughnessTexture&&e.pbrMetallicRoughness.metallicRoughnessTexture.gfxTexture&&e.pbrMetallicRoughness.metallicRoughnessTexture.gfxTexture.destroy(),e.normalTexture&&e.normalTexture.gfxTexture&&e.normalTexture.gfxTexture.destroy(),e.emissionTexture&&e.emissionTexture.gfxTexture&&e.emissionTexture.gfxTexture.destroy(),e.occlusionTexture&&e.occlusionTexture.gfxTexture&&e.occlusionTexture.gfxTexture.destroy()));var e;if(t.children)for(const e of t.children)ex(e)}class ix{constructor(t){this._callback=t,this._triggered=!1,"undefined"!=typeof MessageChannel&&(this._channel=new MessageChannel,this._channel.port2.onmessage=()=>{this._triggered=!1,this._callback()})}trigger(){this._triggered||(this._triggered=!0,this._channel?this._channel.port1.postMessage(!0):setTimeout((()=>{this._triggered=!1,this._callback()}),0))}remove(){this._channel=void 0,this._callback=()=>{}}}class nx{constructor(){this.tasks={},this.taskQueue=[],ai(["process"],this),this.invoker=new ix(this.process),this.nextId=0}add(t,e){const i=this.nextId++,n=function({type:t,isSymbolTile:e,zoom:i}){return i=i||0,"message"===t?0:"maybePrepare"!==t||e?"parseTile"!==t||e?"parseTile"===t&&e?300-i:"maybePrepare"===t&&e?400-i:500:200-i:100-i}(e);if(0===n){try{t()}finally{}return null}return this.tasks[i]={fn:t,metadata:e,priority:n,id:i},this.taskQueue.push(i),this.invoker.trigger(),{cancel:()=>{delete this.tasks[i]}}}process(){try{if(this.taskQueue=this.taskQueue.filter((t=>!!this.tasks[t])),!this.taskQueue.length)return;const t=this.pick();if(null===t)return;const e=this.tasks[t];if(delete this.tasks[t],this.taskQueue.length&&this.invoker.trigger(),!e)return;e.fn()}finally{}}pick(){let t=null,e=1/0;for(let i=0;i{i&&delete this.callbacks[s],this.target.postMessage({id:s,type:"",targetMapId:n,sourceMapId:this.mapId})}}}receive(t){const e=t.data,i=e.id;if(i&&(!e.targetMapId||this.mapId===e.targetMapId))if(""===e.type){const t=this.cancelCallbacks[i];delete this.cancelCallbacks[i],t&&t.cancel()}else if(e.mustQueue||gi()){const t=this.callbacks[i],n=this.scheduler.add((()=>this.processTask(i,e)),t&&t.metadata||{type:"message"});n&&(this.cancelCallbacks[i]=n)}else this.processTask(i,e)}processTask(t,e){if(delete this.cancelCallbacks[t],""===e.type){const i=this.callbacks[t];delete this.callbacks[t],i&&(e.error?i(Ea(e.error)):i(null,Ea(e.data)))}else{const i=new Set,n=e.hasCallback?(e,n)=>{this.target.postMessage({id:t,type:"",sourceMapId:this.mapId,error:e?Sa(e):null,data:Sa(n,i)},i)}:t=>{},r=Ea(e.data);if(this.parent[e.type])this.parent[e.type](e.sourceMapId,r,n);else if(this.parent.getWorkerSource){const t=e.type.split(".");this.parent.getWorkerSource(e.sourceMapId,t[0],r.source,r.scope)[t[1]](r,n)}else n(new Error(`Could not find function ${e.type}`))}}remove(){this.scheduler.remove(),this.target.removeEventListener("message",this.receive,!1)}}class ox{constructor(t,e){this.workerPool=t,this.actors=[],this.currentActor=0,this.id=ni();const i=this.workerPool.acquire(this.id);for(let t=0;t{this.ready=!0}))}broadcast(t,e,i){Qe(this.actors,((i,n)=>{i.send(t,e,n)}),i=i||function(){})}getActor(){return this.currentActor=(this.currentActor+1)%this.actors.length,this.actors[this.currentActor]}remove(){this.actors.forEach((t=>{t.remove()})),this.actors=[],this.workerPool.release(this.id)}}ox.Actor=rx;var sx={workerUrl:"",workerClass:null,workerParams:void 0};function ax(){return null!=sx.workerClass?new sx.workerClass:new self.Worker(sx.workerUrl,sx.workerParams)}const lx="mapboxgl_preloaded_worker_pool";class cx{constructor(){this.active={}}acquire(t){if(!this.workers)for(this.workers=[];this.workers.length{t.terminate()})),this.workers=null)}isPreloaded(){return!!this.active[lx]}numActive(){return Object.keys(this.active).length}}let dx;function ux(){return dx||(dx=new cx),dx}cx.workerCount=2;let hx,px,fx,mx,_x,gx=null;function yx(){return gi()&&self.worker&&self.worker.dracoUrl?self.worker.dracoUrl:px||n.DRACO_URL}function vx(){if(gi()&&self.worker&&self.worker.meshoptUrl)return self.worker.meshoptUrl;if(mx)return mx;const t=new Uint8Array([0,97,115,109,1,0,0,0,1,4,1,96,0,0,3,3,2,0,0,5,3,1,0,1,12,1,0,10,22,2,12,0,65,0,65,0,65,0,252,10,0,0,11,7,0,65,0,253,15,26,11]);if("object"!=typeof WebAssembly)throw new Error("WebAssembly not supported, cannot instantiate meshoptimizer");return mx=WebAssembly.validate(t)?n.MESHOPT_SIMD_URL:n.MESHOPT_URL,mx}const xx={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},bx={5120:"DT_INT8",5121:"DT_UINT8",5122:"DT_INT16",5123:"DT_UINT16",5125:"DT_UINT32",5126:"DT_FLOAT32"},wx={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16};function Tx(t,e,i){const n=i.json.bufferViews.length,r=i.buffers.length;e.bufferView=n,i.json.bufferViews[n]={buffer:r,byteLength:t.byteLength},i.buffers[r]=t}const Sx="KHR_draco_mesh_compression";function Ex(t,e){const i=t.extensions&&t.extensions[Sx];if(!i)return;const n=new fx.Decoder,r=$x(e,i.bufferView),o=new fx.Mesh;if(!n.DecodeArrayToMesh(r,r.byteLength,o))throw new Error("Failed to decode Draco mesh");const s=e.json.accessors[t.indices],a=xx[s.componentType],l=s.count*a.BYTES_PER_ELEMENT,c=fx._malloc(l);a===Uint16Array?n.GetTrianglesUInt16Array(o,l,c):n.GetTrianglesUInt32Array(o,l,c),Tx(fx.memory.buffer.slice(c,c+l),s,e),fx._free(c);for(const r of Object.keys(i.attributes)){const s=n.GetAttributeByUniqueId(o,i.attributes[r]),a=e.json.accessors[t.attributes[r]],l=bx[a.componentType],c=a.count*wx[a.type]*xx[a.componentType].BYTES_PER_ELEMENT,d=fx._malloc(c);n.GetAttributeDataArrayForAllPoints(o,s,fx[l],c,d),Tx(fx.memory.buffer.slice(d,d+c),a,e),fx._free(d)}n.destroy(),o.destroy(),delete t.extensions[Sx]}const Mx="EXT_meshopt_compression";function Cx(t,e){if(!t.extensions||!t.extensions[Mx])return;const i=t.extensions[Mx],n=new Uint8Array(e.buffers[i.buffer],i.byteOffset||0,i.byteLength||0),r=new Uint8Array(i.count*i.byteStride);_x.decodeGltfBuffer(r,i.count,i.byteStride,n,i.mode,i.filter),t.buffer=e.buffers.length,t.byteOffset=0,e.buffers[t.buffer]=r.buffer,delete t.extensions[Mx]}const Ax=1179937895,Ix=new TextDecoder("utf8");function Lx(t,e){return new URL(t,e).href}function Px(t,e,i,n){return fetch(Lx(t.uri,n)).then((t=>t.arrayBuffer())).then((t=>{e.buffers[i]=t}))}function $x(t,e){const i=t.json.bufferViews[e];return new Uint8Array(t.buffers[i.buffer],i.byteOffset||0,i.byteLength)}function kx(t,e,i,n){if(t.uri){const r=Lx(t.uri,n);return fetch(r).then((t=>t.blob())).then((t=>createImageBitmap(t))).then((t=>{e.images[i]=t}))}if(void 0!==t.bufferView){const n=$x(e,t.bufferView),r=new Blob([n],{type:t.mimeType});return createImageBitmap(r).then((t=>{e.images[i]=t}))}}function Dx(t,e=0,i){const n={json:null,images:[],buffers:[]};if(new Uint32Array(t,e,1)[0]===Ax){const i=new Uint32Array(t,e);let r=2;const o=(i[r++]>>2)-3,s=i[r++]>>2;if(r++,n.json=JSON.parse(Ix.decode(i.subarray(r,r+s))),r+=s,r{const t=[],e=a&&a.includes(Sx),r=a&&a.includes(Mx);if(e&&t.push(function(){if(!fx)return hx||(hx=function(t){let e,i=null;function n(){e=new Uint8Array(i.buffer)}function r(){throw new Error("Unexpected Draco error.")}const o={a:{a:r,d:function(t,i,n){return e.copyWithin(t,i,i+n)},c:function(t){const r=e.length,o=Math.max(t>>>0,Math.ceil(1.2*r)),s=Math.ceil((o-r)/65536);try{return i.grow(s),n(),!0}catch(t){return!1}},b:r}};return(WebAssembly.instantiateStreaming?WebAssembly.instantiateStreaming(t,o):t.then((t=>t.arrayBuffer())).then((t=>WebAssembly.instantiate(t,o)))).then((t=>{const{Rb:r,Qb:o,P:s,T:a,X:l,Ja:c,La:d,Qa:u,Va:h,Wa:p,eb:f,jb:m,f:_,e:g,yb:y,zb:v,Ab:x,Bb:b,Db:w,Gb:T}=t.instance.exports;i=g;const S=(()=>{let t=0,i=0,n=0,s=0;return a=>{n&&(r(s),r(t),i+=n,n=t=0),t||(i+=128,t=o(i));const l=a.length+7&-8;let c=t;l>=i&&(n=l,c=s=o(l));for(let t=0;t{fx=t,hx=void 0})))}()),r&&t.push(function(){if(_x)return;const t=function(t){let e;const i=WebAssembly.instantiateStreaming(t,{}).then((t=>{e=t.instance,e.exports.__wasm_call_ctors()})),n={NONE:"",OCTAHEDRAL:"meshopt_decodeFilterOct",QUATERNION:"meshopt_decodeFilterQuat",EXPONENTIAL:"meshopt_decodeFilterExp"},r={ATTRIBUTES:"meshopt_decodeVertexBuffer",TRIANGLES:"meshopt_decodeIndexBuffer",INDICES:"meshopt_decodeIndexSequence"};return{ready:i,supported:!0,decodeGltfBuffer(t,i,o,s,a,l){!function(t,e,i,n,r,o,s){const a=t.exports.sbrk,l=n+3&-4,c=a(l*r),d=a(o.length),u=new Uint8Array(t.exports.memory.buffer);u.set(o,d);const h=e(c,n,r,d,o.length);if(0===h&&s&&s(c,l,r),i.set(u.subarray(c,c+n*r)),a(c-a(0)),0!==h)throw new Error(`Malformed buffer data: ${h}`)}(e,e.exports[r[a]],t,i,o,s,e.exports[n[l]])}}}(fetch(vx()));return t.ready.then((()=>{_x=t}))}()),o)for(let e=0;e{if(e&&s)for(const{primitives:t}of s)for(const e of t)Ex(e,n);if(r&&s&&l)for(const t of l)Cx(t,n);return n}))}))}function zx(t,e){const i=t.json.bufferViews[e.bufferView],n=xx[e.componentType];return new n(t.buffers[i.buffer],(e.byteOffset||0)+(i.byteOffset||0),e.count*(i.byteStride&&i.byteStride!==wx[e.type]*n.BYTES_PER_ELEMENT?i.byteStride/n.BYTES_PER_ELEMENT:wx[e.type]))}function Rx(t,e,i,n){const r=xx[e.componentType],o=function(t){switch(t){case Int8Array:return 1/127;case Uint8Array:return 1/255;case Int16Array:return 1/32767;case Uint16Array:return 1/65535;default:return 1}}(r),s=t.json.bufferViews[e.bufferView],a=s.byteStride?s.byteStride/r.BYTES_PER_ELEMENT:wx[e.type],l=i.float32,c=l.length/i.capacity;for(let t=0,i=0;t0){for(let r=0;r0){o.texcoordArray=new ic;const t=e.json.accessors[r.TEXCOORD_0];o.texcoordArray.resize(t.count);const i=zx(e,t);Rx(e,t,o.texcoordArray,i)}if(void 0!==r._FEATURE_ID_RGBA4444){const t=e.json.accessors[r._FEATURE_ID_RGBA4444];e.json.extensionsUsed&&e.json.extensionsUsed.includes("EXT_meshopt_compression")&&(o.featureData=zx(e,t))}void 0!==r._FEATURE_RGBA4444&&(o.featureData=new Uint32Array(zx(e,e.json.accessors[r._FEATURE_RGBA4444]).buffer));const u=t.material;return o.material=function(t,e){const{emissiveFactor:i=[0,0,0],alphaMode:n="OPAQUE",alphaCutoff:r=.5,normalTexture:o,occlusionTexture:s,emissiveTexture:a,doubleSided:l}=t,{baseColorFactor:c=[1,1,1,1],metallicFactor:d=1,roughnessFactor:u=1,baseColorTexture:h,metallicRoughnessTexture:p}=t.pbrMetallicRoughness||{},f=s?e[s.index]:void 0;if(s&&s.extensions&&s.extensions.KHR_texture_transform&&f){const t=s.extensions.KHR_texture_transform;f.offsetScale=[t.offset[0],t.offset[1],t.scale[0],t.scale[1]]}return{pbrMetallicRoughness:{baseColorFactor:new Un(...c),metallicFactor:d,roughnessFactor:u,baseColorTexture:h?e[h.index]:void 0,metallicRoughnessTexture:p?e[p.index]:void 0},doubleSided:l,emissiveFactor:i,alphaMode:n,alphaCutoff:r,normalTexture:o?e[o.index]:void 0,occlusionTexture:f,emissionTexture:a?e[a.index]:void 0,defined:void 0===t.defined}}(void 0!==u?e.json.materials[u]:{defined:!1},i),o}function Bx(e,i,n){const{matrix:r,rotation:o,translation:s,scale:a,mesh:l,extras:c,children:d}=e,u={};if(u.matrix=r||t.ad.fromRotationTranslationScale([],o||[0,0,0,1],s||[0,0,0],a||[1,1,1]),void 0!==l){u.meshes=n[l];const t=u.anchor=[0,0];for(const e of u.meshes){const{min:i,max:n}=e.aabb;t[0]+=i[0]+n[0],t[1]+=i[1]+n[1]}t[0]=Math.floor(t[0]/u.meshes.length/2),t[1]=Math.floor(t[1]/u.meshes.length/2)}if(c&&(c.id&&(u.id=c.id),c.lights&&(u.lights=function(t){if(!t.length)return[];const e=function(t){const e=atob(t),i=new Uint8Array(e.length);for(let t=0;t1&&n[n.length-1].equals(n[0])&&n.pop();let r=0;for(let t=0;t0&&n.reverse();const o=xh(n.flatMap((t=>[t.x,t.y])),[]);return 0===o.length?null:{vertices:n,indices:o}}function Ux(e,i){const n=[],r=[];let o=0;const s=[];for(const a of e){o=n.length;const e=a.vertexArray.float32,l=a.indexArray.uint16;for(let r=0;r0&&([r[t+1],r[t+2]]=[r[t+2],r[t+1]])}return{vertices:n,indices:r}}function jx(t){const e=function(t,e){const i=[],n=WebGL2RenderingContext;if(t.json.textures)for(const r of t.json.textures){const o={magFilter:n.LINEAR,minFilter:n.NEAREST,wrapS:n.REPEAT,wrapT:n.REPEAT};void 0!==r.sampler&&Object.assign(o,t.json.samplers[r.sampler]),i.push({image:e[r.source],sampler:o,uploaded:!1})}return i}(t,t.images),i=function(t,e){const i=[];for(const n of t.json.meshes){const r=[];for(const i of n.primitives)r.push(Ox(i,t,e));i.push(r)}return i}(t,e),{scenes:n,scene:r,nodes:o}=t.json,s=n?n[r||0].nodes:o,a=[];for(const e of s)a.push(Bx(o[e],t,i));return function(t,e,i){const n={},r=new Set;for(let o=0;o0){const e=Array.from(r.values()).sort(((t,e)=>t-e));for(let i=e.length-1;i>=0;i--)t.splice(e[i],1)}}(a,s,t.json.nodes),a}function Vx(t){t.heightmap=new Float32Array(4096),t.heightmap.fill(-1);const e=t.vertexArray.float32,i=t.aabb.min[0]-1,n=t.aabb.min[1]-1,r=Wv/(t.aabb.max[0]-i+2),o=Wv/(t.aabb.max[1]-n+2);for(let s=0;st.heightmap[c*Wv+l]&&(t.heightmap[c*Wv+l]=a)}}function Gx(e,i){const n={};n.indexArray=new Kl,n.indexArray.reserve(4*e.length),n.vertexArray=new Bl,n.vertexArray.reserve(10*e.length),n.colorArray=new Ol,n.vertexArray.reserve(10*e.length);let r=0;for(const o of e){const e=Math.min(10,Math.max(4,1.3*o.height))*i,s=[-o.normal[1],o.normal[0],0],a=Math.min(.29,.1*o.width/o.depth),l=o.width-2*o.depth*i*(a+.01),c=t._.scaleAndAdd([],o.pos,s,l/2),d=t._.scaleAndAdd([],o.pos,s,-l/2),u=[c[0],c[1],c[2]+o.height],h=[d[0],d[1],d[2]+o.height],p=t._.scaleAndAdd([],o.normal,s,a);t._.scale(p,p,e);const f=t._.scaleAndAdd([],o.normal,s,-a);t._.scale(f,f,e),t._.add(p,c,p),t._.add(f,d,f),c[2]+=.1,d[2]+=.1,n.vertexArray.emplaceBack(p[0],p[1],p[2]),n.vertexArray.emplaceBack(f[0],f[1],f[2]),n.vertexArray.emplaceBack(c[0],c[1],c[2]),n.vertexArray.emplaceBack(d[0],d[1],d[2]),n.vertexArray.emplaceBack(u[0],u[1],u[2]),n.vertexArray.emplaceBack(h[0],h[1],h[2]),n.vertexArray.emplaceBack(c[0],c[1],c[2]),n.vertexArray.emplaceBack(d[0],d[1],d[2]),n.vertexArray.emplaceBack(p[0],p[1],p[2]),n.vertexArray.emplaceBack(f[0],f[1],f[2]);const m=l/e/2;n.colorArray.emplaceBack(-m-a,-1,m,.8),n.colorArray.emplaceBack(m+a,-1,m,.8),n.colorArray.emplaceBack(-m,0,m,1.3),n.colorArray.emplaceBack(m,0,m,1.3),n.colorArray.emplaceBack(m+a,-.8,m,.7),n.colorArray.emplaceBack(m+a,-.8,m,.7),n.colorArray.emplaceBack(0,0,m,1.3),n.colorArray.emplaceBack(0,0,m,1.3),n.colorArray.emplaceBack(m+a,-1.2,m,.8),n.colorArray.emplaceBack(m+a,-1.2,m,.8),n.indexArray.emplaceBack(6+r,4+r,8+r),n.indexArray.emplaceBack(7+r,9+r,5+r),n.indexArray.emplaceBack(0+r,1+r,2+r),n.indexArray.emplaceBack(1+r,3+r,2+r),r+=10}const o={defined:!0,emissiveFactor:[0,0,0]},s={};return s.baseColorFactor=Un.white,o.pbrMetallicRoughness=s,n.material=o,n.aabb=new wu([1/0,1/0,1/0],[-1/0,-1/0,-1/0]),n}const Zx=new Float32Array(262144),qx=new Uint8Array(262144);function Hx(t){let e=0;if(t.meshes)for(const i of t.meshes)e=Math.max(e,i.aabb.max[2]);if(t.children)for(const i of t.children)e=Math.max(e,Hx(i));return e}function Wx(t,e,i){if(t.meshes)for(const n of t.meshes)n.aabb.min[0]!==1/0&&i.insert(e,n.aabb.min[0],n.aabb.min[1],n.aabb.max[0],n.aabb.max[1]);if(t.children)for(const n of t.children)Wx(n,e,i)}const Yx=["","wall","door","roof","window","lamp","logo"];class Xx{constructor(t){this.node=t,this.evaluatedRMEA=[[1,0,0,1],[1,0,0,1],[1,0,0,1],[1,0,0,1],[.4,1,0,1],[1,0,0,1],[1,0,0,1]],this.hiddenByReplacement=!1,this.evaluatedScale=[1,1,1],this.evaluatedColor=[],this.emissionHeightBasedParams=[],this.feature={type:"Point",id:t.id,geometry:[],properties:{height:Hx(t)}},this.aabb=this._getLocalBounds()}_getLocalBounds(){if(!this.node.meshes)return new wu([1/0,1/0,1/0],[-1/0,-1/0,-1/0]);if(!this.aabb){let t=0;const e=new wu([1/0,1/0,1/0],[-1/0,-1/0,-1/0]);for(const i of this.node.meshes)this.node.lightMeshIndex!==t&&(i.transformedAabb=wu.applyTransformFast(i.aabb,this.node.matrix),e.encapsulate(i.transformedAabb)),t++;this.aabb=e}return this.aabb}}class Kx{constructor(t,e,i,n,r,o){this.id=e,this.modelTraits|=Yv.CoordinateSpaceTile,this.uploaded=!1,this.hasPattern=!1,i&&(this.modelTraits|=Yv.HasMapboxMeshFeatures),n&&(this.modelTraits|=Yv.HasMeshoptCompression),this.zoom=-1,this.terrainExaggeration=1,this.projection={name:"mercator"},this.replacementUpdateTime=0,this.elevationReadFromZ=255,this.brightness=r,this.dirty=!0,this.needsUpload=!1,this.nodesInfo=[];for(const e of t)this.nodesInfo.push(new Xx(e)),Wx(e,o.featureIndexArray.length,o.grid),o.featureIndexArray.emplaceBack(this.nodesInfo.length-1,0,o.bucketLayerIDs.length-1,0)}updateFootprints(t,e){for(const i of this.getNodesInfo()){const n=i.node;n.footprint&&e.push({footprint:n.footprint,id:t})}}update(){console.log("Update 3D model bucket")}populate(){console.log("populate 3D model bucket")}uploadPending(){return!this.uploaded||this.needsUpload}upload(t){if(!this.needsUpload)return;const e=this.getNodesInfo();for(const i of e){const e=i.node;this.uploaded?this.updatePbrBuffer(e):Qv(e,t,!0)}for(const t of e)tx(t.node);this.uploaded=!0,this.needsUpload=!1}updatePbrBuffer(t){let e=!1;if(!t.meshes)return e;for(const i of t.meshes)i.pbrBuffer&&(i.pbrBuffer.updateData(i.featureArray),e=!0);return e}needsReEvaluation(t,e,i){const n=t.transform.projectionOptions,r=t.style.getBrightness(),o=this.brightness!==r;return!!(!this.uploaded||this.dirty||n.name!==this.projection.name||Jx(i.paint.get("model-color").value,o)||Jx(i.paint.get("model-color-mix-intensity").value,o)||Jx(i.paint.get("model-roughness").value,o)||Jx(i.paint.get("model-emissive-strength").value,o)||Jx(i.paint.get("model-height-based-emissive-strength-multiplier").value,o))&&(this.projection=n,this.brightness=r,!0)}evaluateScale(t,e){if(t.transform.zoom===this.zoom)return;this.zoom=t.transform.zoom;const i=this.getNodesInfo(),n=this.id.canonical;for(const t of i){const i=t.feature;t.evaluatedScale=e.paint.get("model-scale").evaluate(i,{},n)}}evaluate(t){const e=this.getNodesInfo();for(const i of e){if(!i.node.meshes)continue;const e=i.feature,n=i.node.meshes&&i.node.meshes[0].featureData,r=i.evaluatedColor[2],o=i.evaluatedRMEA[2],s=this.id.canonical;if(i.hasTranslucentParts=!1,n){for(let n=0;n=t)continue;const u=Zx[c],h=Math.abs(u);h>a&&(s=u,a=h,l=r,d=e)}if(a>.1){const o=1-(t+.5*Math.abs(l*d))/c;let a=e._dem.get(n,i)+s*o;const u=e._dem.get(n+l,i+d),h=e._dem.get(n-l,i-d,!0);(a-u)*(a-h)>0&&(a=(u+h)/2),Zx[r]=e._dem.set(n,i,a),qx[r]=t}}}}}s&&(e._demTile.needsDEMTextureUpload=!0,e._dem._timestamp=ki.now())}getNodesInfo(){return this.nodesInfo}destroy(){const t=this.getNodesInfo();for(const e of t)tx(e.node),ex(e.node)}isEmpty(){return!this.nodesInfo.length}updateReplacement(t,e){if(e.updateTime===this.replacementUpdateTime)return;this.replacementUpdateTime=e.updateTime;const i=e.getReplacementRegionsForTile(t.toUnwrapped()),n=this.getNodesInfo();for(let t=0;tt.footprint===e.footprint))}}getHeightAtTileCoord(e,i){const n=this.getNodesInfo(),r=[],o=[0,0,0],s=t.ad.identity([]);for(let a=0;ad.max[0]||i>d.max[1])continue;if(!0===l.node.hidden)return{height:0,maxHeight:l.feature.properties.height,hidden:!1,verticalScale:l.evaluatedScale[2]};t.ad.invert(s,l.node.matrix),o[0]=e,o[1]=i,t._.transformMat4(o,o,s);const u=(o[0]-c.aabb.min[0])/(c.aabb.max[0]-c.aabb.min[0])*Wv|0,h=Math.min(63,(o[1]-c.aabb.min[1])/(c.aabb.max[1]-c.aabb.min[1])*Wv|0)*Wv+Math.min(63,u),p=c.heightmap[h];if(!(p0)return{height:void 0,maxHeight:l.feature.properties.height,hidden:l.hiddenByReplacement,verticalScale:l.evaluatedScale[2]}}}}function Jx(t,e){return!t.isLightConstant&&e}function Qx(t,e,i,n,r,o,s,a){let l=(61440&e|(61440&e)>>4)>>8,c=(3840&e|(3840&e)>>4)>>4,d=240&e|(240&e)>>4;i[3]>0&&(l=Vn(l,255*i[0],i[3]),c=Vn(c,255*i[1],i[3]),d=Vn(d,255*i[2],i[3]));const u=l>16&65535,a=o?e>>16&65535:65535&e,l=(15&a)t.polygon)).flat());const g=f?l:null,[y,v]=function(e,i,n,r,o,s,a,l,c,d,u){return"globe"===e.projection.name?function(e,i,n,r,o,s,a,l,c,d,u){const h=[],p=[],f=e.projection.upVectorScale(u,e.center.lat,e.worldSize).metersToTile,m=[0,0,0,1],_=[0,0,0,1],g=(t,e,i,n)=>{t[0]=e,t[1]=i,t[2]=n,t[3]=1},y=Sf();n>0&&(n+=y),r+=y;for(const y of i){const i=[],v=[];for(const h of y){const p=h.x+o.x,y=h.y+o.y,x=e.projection.projectTilePoint(p,y,u),b=e.projection.upVector(u,h.x,h.y);let w=n,T=r;if(a){const t=Pf(p,y,n,r,a,l,c,d);w+=t.base,T+=t.top}0!==n?g(m,x.x+b[0]*f*w,x.y+b[1]*f*w,x.z+b[2]*f*w):g(m,x.x,x.y,x.z),g(_,x.x+b[0]*f*T,x.y+b[1]*f*T,x.z+b[2]*f*T),t._.transformMat4(m,m,s),t._.transformMat4(_,_,s),i.push(new Tp(m[0],m[1],m[2])),v.push(new Tp(_[0],_[1],_[2]))}h.push(i),p.push(v)}return[h,p]}(e,i,n,r,o,s,a,l,c,d,u):a?function(e,i,n,r,o,s,a,l,c){const d=[],u=[],h=[0,0,0,1];for(const p of e){const e=[],f=[];for(const d of p){const u=d.x+r.x,p=d.y+r.y,m=Pf(u,p,i,n,s,a,l,c);h[0]=u,h[1]=p,h[2]=m.base,h[3]=1,t.aA.transformMat4(h,h,o),h[3]=Math.max(h[3],1e-5);const _=new Tp(h[0]/h[3],h[1]/h[3],h[2]/h[3]);h[0]=u,h[1]=p,h[2]=m.top,h[3]=1,t.aA.transformMat4(h,h,o),h[3]=Math.max(h[3],1e-5);const g=new Tp(h[0]/h[3],h[1]/h[3],h[2]/h[3]);e.push(_),f.push(g)}d.push(e),u.push(f)}return[d,u]}(i,n,r,o,s,a,l,c,d):function(t,e,i,n,r){const o=[],s=[],a=r[8]*e,l=r[9]*e,c=r[10]*e,d=r[11]*e,u=r[8]*i,h=r[9]*i,p=r[10]*i,f=r[11]*i;for(const e of t){const t=[],i=[];for(const o of e){const e=o.x+n.x,s=o.y+n.y,m=r[0]*e+r[4]*s+r[12],_=r[1]*e+r[5]*s+r[13],g=r[2]*e+r[6]*s+r[14],y=r[3]*e+r[7]*s+r[15],v=m+a,x=_+l,b=g+c,w=Math.max(y+d,1e-5),T=m+u,S=_+h,E=g+p,M=Math.max(y+f,1e-5);t.push(new Tp(v/w,x/w,b/w)),i.push(new Tp(T/M,S/M,E/M))}o.push(t),s.push(i)}return[o,s]}(i,n,r,o,s)}(s,r,h,u,d,a,g,p,m,s.center.lat,e.tileID.canonical),x=e.queryGeometry;return function(t,e,i){let n=1/0;Kd(i,e)&&(n=Lf(i,e[0]));for(let r=0;r=3)for(let e=0;e>4;if(1!==n)throw new Error(`Got v${n} data when expected v1.`);const r=nb[15&i];if(!r)throw new Error("Unrecognized array type.");const[o]=new Uint16Array(t,2,1),[s]=new Uint32Array(t,4,1);return new rb(s,o,r,t)}constructor(t,e=64,i=Float64Array,n){if(isNaN(t)||t>1;return this.ids[i]=i,this.coords[this._pos++]=t,this.coords[this._pos++]=e,i}finish(){const t=this._pos>>1;if(t!==this.numItems)throw new Error(`Added ${t} items when expected ${this.numItems}.`);return ob(this.ids,this.coords,this.nodeSize,0,this.numItems-1,0),this._finished=!0,this}range(t,e,i,n){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");const{ids:r,coords:o,nodeSize:s}=this,a=[0,r.length-1,0],l=[];for(;a.length;){const c=a.pop()||0,d=a.pop()||0,u=a.pop()||0;if(d-u=t&&a=e&&c>1,p=o[2*h],f=o[2*h+1];p>=t&&p=e&&f=p:n>=f)&&(a.push(h+1),a.push(d),a.push(1-c))}return l}within(t,e,i){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");const{ids:n,coords:r,nodeSize:o}=this,s=[0,n.length-1,0],a=[],l=i*i;for(;s.length;){const c=s.pop()||0,d=s.pop()||0,u=s.pop()||0;if(d-u>1,p=r[2*h],f=r[2*h+1];cb(p,f,t,e)=p:e+i>=f)&&(s.push(h+1),s.push(d),s.push(1-c))}return a}}function ob(t,e,i,n,r,o){if(r-n>1;sb(t,e,s,n,r,o),ob(t,e,i,n,s-1,1-o),ob(t,e,i,s+1,r,1-o)}function sb(t,e,i,n,r,o){for(;r>n;){if(r-n>600){const s=r-n+1,a=i-n+1,l=Math.log(s),c=.5*Math.exp(2*l/3),d=.5*Math.sqrt(l*c*(s-c)/s)*(a-s/2s&&ab(t,e,n,r);as;)l--}e[2*n+o]===s?ab(t,e,n,l):(l++,ab(t,e,l,r)),lr&&(n+=(t[i]-r)*(t[i]-r)),e[i]0&&n[0]0&&n[1]0&&r[0]0&&r[1]0?Math.acos(i/n)*Ve:0;let o=0!==t||0!==e?Math.atan2(-e,-t)*Ve+90:0;return oNi&&(t.getActor().send("enforceCacheSizeLimit",Fi),Vi=0)},t.an=gn,t.ao=class{constructor(t){this.entries={},this.scheduler=t}request(t,e,i,n){const r=this.entries[t]=this.entries[t]||{callbacks:[]};if(r.result){const[t,i]=r.result;return this.scheduler?this.scheduler.add((()=>{n(t,i)}),e):n(t,i),()=>{}}return r.callbacks.push(n),r.cancel||(r.cancel=i(((i,n)=>{r.result=[i,n];for(const t of r.callbacks)this.scheduler?this.scheduler.add((()=>{t(i,n)}),e):t(i,n);setTimeout((()=>delete this.entries[t]),3e3)}))),()=>{r.result||(r.callbacks=r.callbacks.filter((t=>t!==n)),r.callbacks.length||(r.cancel(),delete this.entries[t]))}}},t.ap=function(t,e,i){const n=JSON.stringify(t.request);return t.data&&(this.deduped.entries[n]={result:[null,t.data]}),this.deduped.request(n,{type:"parseTile",isSymbolTile:t.isSymbolTile,zoom:t.tileZoom},(e=>{const n=en(t.request,((t,n,r,o)=>{t?e(t):n&&e(null,{vectorTile:i?void 0:new bp(new Lm(n)),rawData:n,cacheControl:r,expires:o})}));return()=>{n.cancel(),e()}}),e)},t.aq=Dc,t.ar=class extends Lc{constructor(t){super(t),this.current=Fc}set(t,e,i){if(this.fetchUniformLocation(t,e))for(let t=0;t({u_camera_to_center_distance:new $c(t),u_extrude_scale:new Uc(t),u_device_pixel_ratio:new $c(t),u_matrix:new Bc(t),u_inv_rot_matrix:new Bc(t),u_merc_center:new kc(t),u_tile_id:new Dc(t),u_zoom_transition:new $c(t),u_up_dir:new Dc(t),u_emissive_strength:new $c(t)}),t.bJ=t=>({u_matrix:new Bc(t),u_pixels_to_tile_units:new Uc(t),u_device_pixel_ratio:new $c(t),u_units_to_pixels:new kc(t),u_dash_image:new Pc(t),u_gradient_image:new Pc(t),u_image_height:new $c(t),u_texsize:new kc(t),u_tile_units_to_pixels:new $c(t),u_alpha_discard_threshold:new $c(t),u_trim_offset:new kc(t),u_trim_fade_range:new kc(t),u_trim_color:new zc(t),u_emissive_strength:new $c(t)}),t.bK=t=>({u_matrix:new Bc(t),u_texsize:new kc(t),u_pixels_to_tile_units:new Uc(t),u_device_pixel_ratio:new $c(t),u_image:new Pc(t),u_units_to_pixels:new kc(t),u_tile_units_to_pixels:new $c(t),u_alpha_discard_threshold:new $c(t),u_trim_offset:new kc(t)}),t.bL=Yl,t.bM=Hf,t.bN=Om,t.bO=jm,t.bP=G_,t.bQ=c_,t.bR=th,t.bS=(t,e,i,n,r,o)=>{const s=t.transform,a="globe"===s.projection.name;let l;if("map"===o.paint.get("circle-pitch-alignment"))if(a){const t=Zu(s.zoom,e.canonical)*s._pixelsPerMercatorPixel;l=Float32Array.from([t,0,0,t])}else l=s.calculatePixelsToTileUnitsMatrix(i);else l=new Float32Array([s.pixelsToGLUnits[0],0,0,s.pixelsToGLUnits[1]]);const c={u_camera_to_center_distance:t.transform.getCameraToCenterDistance(s.projection),u_matrix:t.translatePosMatrix(e.projMatrix,i,o.paint.get("circle-translate"),o.paint.get("circle-translate-anchor")),u_device_pixel_ratio:ki.devicePixelRatio,u_extrude_scale:l,u_inv_rot_matrix:Qu,u_merc_center:[0,0],u_tile_id:[0,0,0],u_zoom_transition:0,u_up_dir:[0,0,0],u_emissive_strength:o.paint.get("circle-emissive-strength")};if(a){c.u_inv_rot_matrix=n,c.u_merc_center=r,c.u_tile_id=[e.canonical.x,e.canonical.y,1{const s=t.transform;return{u_matrix:rm(t,e,i,n),u_texsize:e.imageAtlasTexture?e.imageAtlasTexture.size:[0,0],u_pixels_to_tile_units:s.calculatePixelsToTileUnitsMatrix(e),u_device_pixel_ratio:r,u_image:0,u_tile_units_to_pixels:nm(e,s),u_units_to_pixels:[1/s.pixelsToGLUnits[0],1/s.pixelsToGLUnits[1]],u_alpha_discard_threshold:0,u_trim_offset:o}},t.bV=(t,e,i,n,r,o,s)=>{const a=t.transform,l=a.calculatePixelsToTileUnitsMatrix(e);return{u_matrix:rm(t,e,i,n),u_pixels_to_tile_units:l,u_device_pixel_ratio:o,u_units_to_pixels:[1/a.pixelsToGLUnits[0],1/a.pixelsToGLUnits[1]],u_dash_image:0,u_gradient_image:1,u_image_height:r,u_texsize:sm(i)&&e.lineAtlasTexture?e.lineAtlasTexture.size:[0,0],u_tile_units_to_pixels:nm(e,t.transform),u_alpha_discard_threshold:0,u_trim_offset:s,u_trim_fade_range:i.paint.get("line-trim-fade-range"),u_trim_color:i.paint.get("line-trim-color").toRenderColor(i.lut).toArray01(),u_emissive_strength:i.paint.get("line-emissive-strength")}},t.bW=oi,t.bX=mh,t.bY=Sf,t.bZ=bd,t.b_=_f,t.ba=function(t,e,i){const n=Hu(i.zoom),r=t.style.map._antialias,o=e.options.extStandardDerivativesForceOff||t.terrain&&t.terrain.exaggeration()>0;return 0===n&&!r&&!o},t.bb=function(e){const i=e.pixelsPerMeter,n=i/Cd(1,e.center.lat),r=t.ad.identity(new Float64Array(16));return t.ad.translate(r,r,[e.point.x,e.point.y,0]),t.ad.scale(r,r,[n,n,i]),Float32Array.from(r)},t.bc=Ou,t.bd=function(t){const e=Pd-5;t=Xe(t,-e,e)/e*90;const i=Math.pow(Math.abs(Math.sin(Ge(t))),3);return Math.round(i*(sd.length-1))},t.be=function(e,i,n,r){const o=i.getNorth(),s=i.getSouth(),a=i.getWest(),l=i.getEast(),c=10){const e=180/r;t.bC.multiply(f,f,[e/d+1,0,0,0,e/u+1,0,-.5*e/h,.5*e/p,1])}return f[2]=c,f[5]=e.x,f[8]=e.y,f},t.bf=ju,t.bg=$u,t.bh=function(e,i,n){const r=t.ad.identity(new Float64Array(16)),o=(i/(1{}}},t.bo=Gg,t.bp=ai,t.bq=class{isDataAvailableAtPoint(t){const e=this._source();if(this.isUsingMockSource()||!e||t.y1)return!1;const i=e.getSource().maxzoom,n=11)return e;const r=n.getSource().maxzoom,o=1{const s=this.getAtTileOffset(e,o.x,o.y),a=r.upVector(e.canonical,o.x,o.y),l=r.upVectorScale(e.canonical,i,n).metersToTile;return t._.scale(a,a,s*l),a}}getForTilePoints(t,e,i,n){if(this.isUsingMockSource())return!1;const r=Xp.create(this,t,n);return!!r&&(e.forEach((t=>{t[2]=this.exaggeration()*r.getElevationAt(t[0],t[1],i)})),!0)}getMinMaxForTile(t){if(this.isUsingMockSource())return null;const e=this.findDEMTileFor(t);if(!e||!e.dem)return null;const i=e.dem.tree,n=e.tileID,r=1=0?t.slice(0,e):t},t.cV=function(t){return t.indexOf(wl)>=0},t.cW=function(t){const e=t.indexOf(wl);return e>=0?t.slice(e+1):""},t.cX=function(t){const e=[],i=t.id;return void 0===i&&e.push({message:`layers.${i}: missing required property "id"`}),void 0===t.render&&e.push({message:`layers.${i}: missing required method "render"`}),t.renderingMode&&"2d"!==t.renderingMode&&"3d"!==t.renderingMode&&e.push({message:`layers.${i}: property "renderingMode" must be either "2d" or "3d"`}),e},t.cY=function(t,e,i,n){return"custom"===t.type?new vv(t,e):new ib[t.type](t,e,i,n)},t.cZ=di,t.c_=Va,t.ca=1,t.cb=Ag,t.cc=0,t.cd=ec,t.ce=function(t,e,i,n,r){return Xe((t-e)/(i-e)*(r-n)+n,n,r)},t.cf=Ns,t.cg=kd,t.ch=class{constructor(t,e,i,n){this.context=t,this.format=n,this.size=i,this.texture=t.gl.createTexture();const[r,o,s]=this.size,{gl:a}=t;a.bindTexture(a.TEXTURE_3D,this.texture),t.pixelStoreUnpackFlipY.set(!1),t.pixelStoreUnpack.set(1),t.pixelStoreUnpackPremultiplyAlpha.set(!1);let l=this.format,c=a.UNSIGNED_BYTE;this.format===a.DEPTH_COMPONENT&&(l=a.DEPTH_COMPONENT16,c=a.UNSIGNED_SHORT),this.format===a.R8&&(n=a.RED),this.format===a.R32F&&(c=a.FLOAT,n=a.RED),a.texImage3D(a.TEXTURE_3D,0,l,r,o,s,0,n,c,e.data)}bind(t,e){const{context:i}=this,{gl:n}=i;n.bindTexture(n.TEXTURE_3D,this.texture),t!==this.minFilter&&(n.texParameteri(n.TEXTURE_3D,n.TEXTURE_MAG_FILTER,t),n.texParameteri(n.TEXTURE_3D,n.TEXTURE_MIN_FILTER,t),this.minFilter=t),e!==this.wrapS&&(n.texParameteri(n.TEXTURE_3D,n.TEXTURE_WRAP_S,e),n.texParameteri(n.TEXTURE_3D,n.TEXTURE_WRAP_T,e),this.wrapS=e)}destroy(){const{gl:t}=this.context;t.deleteTexture(this.texture),this.texture=null}},t.ci=$v,t.cj=[1,1,1],t.ck=Xp,t.cl=Yv,t.cm=ql,t.cn=ic,t.co=class{constructor(){this._updateTime=0,this._sourceIds=[],this._activeRegions=[],this._prevRegions=[],this._globalClipBounds={min:new Ue(1/0,1/0),max:new Ue(-1/0,-1/0)}}clear(){this._activeRegions.length>0&&++this._updateTime,this._activeRegions=[],this._prevRegions=[]}get updateTime(){return this._updateTime}getReplacementRegionsForTile(t,e=!1){const i=$p(new Ue(0,0),new Ue(uo,uo),t),n=[];if(e&&!Lp(i,this._globalClipBounds))return n;for(const e of this._activeRegions){if(e.hiddenByOverlap)continue;if(!Lp(i,e))continue;const r=kp(e.min,e.max,t);n.push({min:r.min,max:r.max,sourceId:this._sourceIds[e.priority],footprint:e.footprint,footprintTileId:e.tileId,order:e.order,clipMask:e.clipMask})}return n}setSources(t){this._setSources(t.map((t=>({getSourceId:()=>t.cache.id,getFootprints:()=>{const e=[];for(const i of t.cache.getVisibleCoordinates()){const n=t.cache.getTile(i).buckets[t.layer];n&&n.updateFootprints(i.toUnwrapped(),e)}return e},getOrder:()=>t.order,getClipMask:()=>t.clipMask}))))}_addSource(t){const e=t.getFootprints();if(0===e.length)return;const i=t.getOrder(),n=t.getClipMask();for(const t of e){if(!t.footprint)continue;const e=$p(t.footprint.min,t.footprint.max,t.id);this._activeRegions.push({min:e.min,max:e.max,hiddenByOverlap:!1,priority:this._sourceIds.length,tileId:t.id,footprint:t.footprint,order:i,clipMask:n})}this._sourceIds.push(t.getSourceId())}_computeReplacement(){this._activeRegions.sort(((t,e)=>t.priority-e.priority||Ap(t.min,e.min)||Ap(t.max,e.max)));let t=this._activeRegions.length!==this._prevRegions.length;if(!t){let e=0;for(;!t&&e!==this._activeRegions.length;){const i=this._activeRegions[e],n=this._prevRegions[e];t=i.priority!==n.priority||!Ip(i,n)||i.order!==n.order||i.clipMask!==n.clipMask,++e}}if(t){++this._updateTime;for(const t of this._activeRegions)t.order!==1/0&&(this._globalClipBounds.min.x=Math.min(this._globalClipBounds.min.x,t.min.x),this._globalClipBounds.min.y=Math.min(this._globalClipBounds.min.y,t.min.y),this._globalClipBounds.max.x=Math.max(this._globalClipBounds.max.x,t.max.x),this._globalClipBounds.max.y=Math.max(this._globalClipBounds.max.y,t.max.y));const t=t=>{const e=this._activeRegions;if(t>=e.length)return t;const i=e[t].priority;for(;t1){let e=0,i=t(e);for(;e!==i;){let n=e;const r=e;for(;n!==i;){const t=this._activeRegions[n];t.hiddenByOverlap=!1;for(let e=0;e=0;e--)this._addSource(t[e]);this._computeReplacement()}},t.cp=Dl,t.cq=Jg,t.cr=rc,t.cs=class{constructor(t){this._createGrid(t),this._createPoles(t)}destroy(){this._poleIndexBuffer.destroy(),this._gridBuffer.destroy(),this._gridIndexBuffer.destroy(),this._poleNorthVertexBuffer.destroy(),this._poleSouthVertexBuffer.destroy();for(const t of this._poleSegments)t.destroy();for(const t of this._gridSegments)t.withSkirts.destroy(),t.withoutSkirts.destroy()}_fillGridMeshWithLods(t,e){const i=new $l,n=new Kl,r=[],o=t+1+2,s=e[0]+1,a=e[0]+1+(1+e.length),l=(t,e,i)=>{let n=t===o-1?t-2:0===t?t:t-1;return n+=i?24575:0,[n,e]};for(let t=0;tt()))},t.dB=sx,t.dC=yx,t.dD=function(t){px=ki.resolveURL(t),gx||(gx=new ox(ux(),new zn)),gx.broadcast("setDracoUrl",px)},t.dE=vx,t.dF=function(t){mx=ki.resolveURL(t),gx||(gx=new ox(ux(),new zn)),gx.broadcast("setMeshoptUrl",mx)},t.dG=ti,t.dH=ba,t.dI=dh,t.dJ=I_,t.dK=eg,t.dL=dc,t.dM=am,t.dN=Dm,t.dO=Wf,t.dP=ci,t.dQ=E_,t.dR=jg,t.dS=function(t,e,i,n,r,o,s,a,l,c,d){t.createArrays(),t.tilePixelRatio=uo/(512*t.overscaling),t.compareText={},t.iconsNeedLinear=!1;const u=t.layers[0].layout,h=t.layers[0]._unevaluatedLayout._values,p={};if("composite"===t.textSizeData.kind){const{minZoom:e,maxZoom:i}=t.textSizeData;p.compositeTextSizes=[h["text-size"].possiblyEvaluate(new Ha(e),a),h["text-size"].possiblyEvaluate(new Ha(i),a)]}if("composite"===t.iconSizeData.kind){const{minZoom:e,maxZoom:i}=t.iconSizeData;p.compositeIconSizes=[h["icon-size"].possiblyEvaluate(new Ha(e),a),h["icon-size"].possiblyEvaluate(new Ha(i),a)]}p.layoutTextSize=h["text-size"].possiblyEvaluate(new Ha(l+1),a),p.layoutIconSize=h["icon-size"].possiblyEvaluate(new Ha(l+1),a),p.textMaxSize=h["text-size"].possiblyEvaluate(new Ha(18),a);const f="map"===u.get("text-rotation-alignment")&&"point"!==u.get("symbol-placement"),m=u.get("text-size");let _=!1;for(const e of t.features)if(e.icon&&e.icon.nameSecondary){_=!0;break}for(const o of t.features){const l=u.get("text-font").evaluate(o,{},a).join(","),h=m.evaluate(o,{},a),g=p.layoutTextSize.evaluate(o,{},a),y=(p.layoutIconSize.evaluate(o,{},a),{horizontal:{},vertical:void 0}),v=o.text;let x,b=[0,0];if(v){const n=v.toString(),s=u.get("text-letter-spacing").evaluate(o,{},a)*Om,c=u.get("text-line-height").evaluate(o,{},a)*Om,d=Aa(n)?s:0,p=u.get("text-anchor").evaluate(o,{},a),m=u.get("text-variable-anchor");if(!m){const t=u.get("text-radial-offset").evaluate(o,{},a);b=t?G_(p,[t*Om,j_]):u.get("text-offset").evaluate(o,{},a).map((t=>t*Om))}let _=f?"center":u.get("text-justify").evaluate(o,{},a);const x="point"===u.get("symbol-placement"),w=x?u.get("text-max-width").evaluate(o,{},a)*Om:1/0,T=o=>{t.allowVerticalPlacement&&Ca(n)&&(y.vertical=e_(v,e,i,r,l,w,c,p,o,d,b,Jm.vertical,!0,g,h))};if(!f&&m){const t="auto"===_?m.map((t=>Z_(t))):[_];let n=!1;for(let o=0;o=0||!Ca(n)){const t=e_(v,e,i,r,l,w,c,p,_,d,b,Jm.horizontal,!1,g,h);t&&(y.horizontal[_]=t)}T(x?"left":_)}}let w=!1;if(o.icon&&o.icon.namePrimary){const e=n[o.icon.namePrimary];e&&(x=u_(r[o.icon.namePrimary],o.icon.nameSecondary?r[o.icon.nameSecondary]:void 0,u.get("icon-offset").evaluate(o,{},a),u.get("icon-anchor").evaluate(o,{},a)),w=e.sdf,void 0===t.sdfIcons?t.sdfIcons=e.sdf:t.sdfIcons!==e.sdf&&pi("Style sheet warning: Cannot mix SDF and non-SDF icons in one buffer"),(e.pixelRatio!==t.pixelRatio||0!==u.get("icon-rotate").constantOr(1))&&(t.iconsNeedLinear=!0))}const T=X_(y.horizontal)||y.vertical;t.iconsInText||(t.iconsInText=!!T&&T.iconsInText),(T||x)&&q_(t,o,y,x,n,p,g,0,b,w,s,a,c,d,_)}o&&t.generateCollisionDebugBuffers(l,t.collisionBoxArray)},t.dT=Jf,t.dU=Yh,t.dV=bp,t.dW=Lm,t.dX=Yp,t.dY=Zy,t.dZ=wp,t.d_=cp,t.da=Wu,t.db=function(e){const i=[0,0,0],n=t.ad.identity(new Float64Array(16));return t.ad.multiply(n,e.pixelMatrix,e.globeMatrix),t._.transformMat4(i,i,n),new Ue(i[0],i[1])},t.dc=d,t.dd=c,t.de=function(t){const e=t.navigator?t.navigator.userAgent:null;return!!function(t){if(null==Ei){const e=t.navigator?t.navigator.userAgent:null;Ei=!!t.safari||!(!e||!(/\b(iPad|iPhone|iPod)\b/.test(e)||e.match("Safari")&&!e.match("Chrome")))}return Ei}(t)&&e&&(e.match("Version/15.4")||e.match("Version/15.5")||e.match(/CPU (OS|iPhone OS) (15_4|15_5) like Mac OS X/))},t.df=ni,t.dg=class{constructor(t,e,i){this._transformRequestFn=t,this._customAccessToken=e,this._silenceAuthErrors=!!i,this._createSkuToken()}_createSkuToken(){const t=function(){let t="";for(let e=0;ethis._skuTokenExpiresAt}transformRequest(t,e){return this._transformRequestFn&&this._transformRequestFn(t,e)||{url:t}}normalizeStyleURL(t,i){if(!o(t))return t;const n=un(t);return n.params.push(`sdk=js-${e}`),n.path=`/styles/v1${n.path}`,this._makeAPIURL(n,this._customAccessToken||i)}normalizeGlyphsURL(t,e){if(!o(t))return t;const i=un(t);return i.path=`/fonts/v1${i.path}`,this._makeAPIURL(i,this._customAccessToken||e)}normalizeModelURL(t,e){if(!o(t))return t;const i=un(t);return i.path=`/models/v1${i.path}`,this._makeAPIURL(i,this._customAccessToken||e)}normalizeSourceURL(t,e,i,n){if(!o(t))return t;const r=un(t);return r.path=`/v4/${r.authority}.json`,r.params.push("secure"),i&&r.params.push(`language=${i}`),n&&r.params.push(`worldview=${n}`),this._makeAPIURL(r,this._customAccessToken||e)}normalizeSpriteURL(t,e,i,n){const r=un(t);return o(t)?(r.path=`/styles/v1${r.path}/sprite${e}${i}`,this._makeAPIURL(r,this._customAccessToken||n)):(r.path+=`${e}${i}`,hn(r))}normalizeTileURL(t,e,i){if(this._isSkuTokenExpired()&&this._createSkuToken(),t&&!o(t))return t;const r=un(t);r.path=r.path.replace(/(\.(png|jpg)\d*)(?=$)/,`${e||i&&"raster"!==r.authority&&512===i?"@2x":""}${Gi.supported?".webp":"$1"}`),"raster"===r.authority?r.path=`/${n.RASTER_URL_PREFIX}${r.path}`:"rasterarrays"===r.authority?r.path=`/${n.RASTERARRAYS_URL_PREFIX}${r.path}`:"3dtiles"===r.authority?r.path=`/${n.TILES3D_URL_PREFIX}${r.path}`:(r.path=r.path.replace(/^.+\/v4\//,"/"),r.path=`/${n.TILE_URL_VERSION}${r.path}`);const s=this._customAccessToken||function(t){for(const e of t){const t=e.match(/^access_token=(.*)$/);if(t)return t[1]}return null}(r.params)||n.ACCESS_TOKEN;return n.REQUIRE_ACCESS_TOKEN&&s&&this._skuToken&&r.params.push(`sku=${this._skuToken}`),this._makeAPIURL(r,s)}canonicalizeTileURL(t,e){const i=un(t);if(!i.path.match(/^(\/v4\/|\/(raster|rasterarrays)\/v1\/)/)||!i.path.match(/\.[\w]+$/))return t;let r="mapbox://";i.path.match(/^\/raster\/v1\//)?r+=`raster/${i.path.replace(`/${n.RASTER_URL_PREFIX}/`,"")}`:i.path.match(/^\/rasterarrays\/v1\//)?r+=`rasterarrays/${i.path.replace(`/${n.RASTERARRAYS_URL_PREFIX}/`,"")}`:r+=`tiles/${i.path.replace(`/${n.TILE_URL_VERSION}/`,"")}`;let o=i.params;return e&&(o=o.filter((t=>!t.match(/^access_token=/)))),o.length&&(r+=`?${o.join("&")}`),r}canonicalizeTileset(t,e){const i=!!e&&o(e),n=[];for(const e of t.tiles||[])r(e)?n.push(this.canonicalizeTileURL(e,i)):n.push(e);return n}_makeAPIURL(t,e){const i="See https://docs.mapbox.com/api/overview/#access-tokens-and-token-scopes",r=un(n.API_URL);if(t.protocol=r.protocol,t.authority=r.authority,"http"===t.protocol){const e=t.params.indexOf("secure");e>=0&&t.params.splice(e,1)}if("/"!==r.path&&(t.path=`${r.path}${t.path}`),!n.REQUIRE_ACCESS_TOKEN)return hn(t);if(e=e||n.ACCESS_TOKEN,!this._silenceAuthErrors){if(!e)throw new Error(`An API access token is required to use Mapbox GL. ${i}`);if("s"===e[0])throw new Error(`Use a public access token (pk.*) with Mapbox GL, not a secret access token (sk.*). ${i}`)}return t.params=t.params.filter((t=>-1===t.indexOf("access_token"))),t.params.push(`access_token=${e||""}`),hn(t)}},t.dh=function(t,e){e?Mn.add(t):Mn.delete(t)},t.di=Gi,t.dj=Tn,t.dk=En,t.dl=cn,t.dm=vn,t.dn=bn,t.dp=function(t){Mn.delete(t)},t.dq=Sn,t.dr=yn,t.ds=Qe,t.dt=e,t.du=function(t,e){Fi=t,Ni=e},t.dv=function(t,e,i=!1){if(Fa===za||Fa===Ra||Fa===Oa)throw new Error("setRTLTextPlugin cannot be called multiple times.");Na=ki.resolveURL(t),Fa=za,Ba=e,ja(),i||Za()},t.dw=Ga,t.dx=function(){ux().acquire(lx)},t.dy=function(){const t=dx;t&&(t.isPreloaded()&&1===t.numActive()?(t.release(lx),dx=null):console.warn("Could not clear WebWorkers since there are active Map instances that still reference it. The pre-warmed WebWorker pool can only be cleared when all map instances have been removed with map.remove()"))},t.dz=cx,t.e=ki,t.e0=cm,t.e1=h,t.e2=en,t.e3=function(t){let e=0;if(new Uint32Array(t,0,1)[0]!==Ax){const i=new Uint32Array(t,0,7),[,,n,r,o,s]=i;e=i.byteLength+r+o+s+o,(n!==t.byteLength||e>=t.byteLength)&&pi("Invalid b3dm header information.")}return Dx(t,e)},t.e4=function(t,e){const i=jx(t);for(const t of i){for(const e of t.meshes)Vx(e);t.lights&&(t.lightMeshIndex=t.meshes.length,t.meshes.push(Gx(t.lights,e)))}return i},t.e5=Kx,t.e6=rx,t.e7=qa,t.e8=function(t){ji(),Oi&&Oi.then((e=>{e.keys().then((i=>{for(let n=0;nt.arrayBuffer())).then((e=>Dx(e,0,t)))},t.m=class extends Uv{},t.n=Er,t.o=qn,t.p=Qg,t.q=Xs,t.r=Js,t.s=Qs,t.t=ca,t.u=al,t.v=ll,t.w=pi,t.x=pa,t.y=da,t.z=qo})),n(0,(function(t){function e(t){const e=t?t.url.toString():void 0;return e?performance.getEntriesByName(e):[]}function i(t){if("number"==typeof t||"boolean"==typeof t||"string"==typeof t||null==t)return JSON.stringify(t);if(Array.isArray(t)){let e="[";for(const n of t)e+=`${i(n)},`;return`${e}]`}let e="{";for(const n of Object.keys(t).sort())e+=`${n}:${i(t[n])},`;return`${e}}`}function n(e){let n="";for(const r of t.cE)n+=`/${i(e[r])}`;return n}class r{constructor(t){this.keyCache={},this._layers={},this._layerConfigs={},t&&this.replace(t)}replace(t,e){this._layerConfigs={},this._layers={},this.update(t,[],e)}update(e,i,r){this._options=r;for(const i of e)this._layerConfigs[i.id]=i,(this._layers[i.id]=t.cY(i,this.scope,null,this._options)).compileFilter(),this.keyCache[i.id]&&delete this.keyCache[i.id];for(const t of i)delete this.keyCache[t],delete this._layerConfigs[t],delete this._layers[t];this.familiesBySource={};const o=function(t,e){const i={};for(let r=0;rthis._layers[t.id])),i=e[0];if("none"===i.visibility)continue;const n=i.source||"";let r=this.familiesBySource[n];r||(r=this.familiesBySource[n]={});const o=i.sourceLayer||"_geojsonTileLayer";let s=r[o];s||(s=r[o]=[]),s.push(e)}}}const o=1*t.dJ;class s{constructor(e){const i={},n=[];for(const t in e){const r=e[t],s=i[t]={};for(const t in r.glyphs){const e=r.glyphs[+t];if(!e||0===e.bitmap.width||0===e.bitmap.height)continue;const i=e.metrics.localGlyph?o:1,a={x:0,y:0,w:e.bitmap.width+2*i,h:e.bitmap.height+2*i};n.push(a),s[t]=a}}const{w:r,h:s}=t.j(n),a=new t.dI({width:r||1,height:s||1});for(const n in e){const r=e[n];for(const e in r.glyphs){const s=r.glyphs[+e];if(!s||0===s.bitmap.width||0===s.bitmap.height)continue;const l=i[n][e],c=s.metrics.localGlyph?o:1;t.dI.copy(s.bitmap,a,{x:0,y:0},{x:l.x+c,y:l.y+c},s.bitmap)}}this.image=a,this.positions=i}}t.dH(s,"GlyphAtlas");class a{constructor(e){this.tileID=new t.aL(e.tileID.overscaledZ,e.tileID.wrap,e.tileID.canonical.z,e.tileID.canonical.x,e.tileID.canonical.y),this.tileZoom=e.tileZoom,this.uid=e.uid,this.zoom=e.zoom,this.lut=e.lut,this.canonical=e.tileID.canonical,this.pixelRatio=e.pixelRatio,this.tileSize=e.tileSize,this.source=e.source,this.scope=e.scope,this.overscaling=this.tileID.overscaleFactor(),this.showCollisionBoxes=e.showCollisionBoxes,this.collectResourceTiming=!!e.collectResourceTiming,this.promoteId=e.promoteId,this.isSymbolTile=e.isSymbolTile,this.tileTransform=t.dK(e.tileID.canonical,e.projection),this.projection=e.projection,this.brightness=e.brightness,this.extraShadowCaster=!!e.extraShadowCaster,this.tessellationStep=e.tessellationStep}parse(e,i,n,r,o){this.status="parsing",this.data=e,this.collisionBoxArray=new t.dL;const a=new t.dM(Object.keys(e.layers).sort()),c=new t.dN(this.tileID,this.promoteId);c.bucketLayerIDs=[];const d={},u=new t.dO(256,256),h={featureIndex:c,iconDependencies:{},patternDependencies:{},glyphDependencies:{},lineAtlas:u,availableImages:n,brightness:this.brightness},p=i.familiesBySource[this.source];for(const i in p){const r=e.layers[i];if(!r)continue;let o=!1,s=!1,u=!1;for(const t of p[i])"symbol"===t[0].type?o=!0:s=!0,t[0].is3D()&&"model"!==t[0].type&&(u=!0);if(this.extraShadowCaster&&!u)continue;if(!0===this.isSymbolTile&&!o)continue;if(!1===this.isSymbolTile&&!s)continue;1===r.version&&t.w(`Vector tile source "${this.source}" layer "${i}" does not use vector tile spec v2 and therefore may have some rendering errors.`);const f=a.encode(i),m=[];for(let t=0;t=e.maxzoom||"none"!==e.visibility&&(l(t,this.zoom,h.brightness,n),(d[e.id]=e.createBucket({index:c.bucketLayerIDs.length,layers:t,zoom:this.zoom,lut:this.lut,canonical:this.canonical,pixelRatio:this.pixelRatio,overscaling:this.overscaling,collisionBoxArray:this.collisionBoxArray,sourceLayerIndex:f,sourceID:this.source,projection:this.projection.spec,tessellationStep:this.tessellationStep})).populate(m,h,this.tileID.canonical,this.tileTransform),c.bucketLayerIDs.push(t.map((t=>t.id)))))}}let f,m,_,g;u.trim();const y={type:"maybePrepare",isSymbolTile:this.isSymbolTile,zoom:this.zoom},v=()=>{if(f)return this.status="done",o(f);if(this.extraShadowCaster)this.status="done",o(null,{buckets:t.dG(d).filter((t=>!t.isEmpty())),featureIndex:c,collisionBoxArray:null,glyphAtlasImage:null,lineAtlas:null,imageAtlas:null,brightness:h.brightness,glyphMap:null,iconMap:null,glyphPositions:null});else if(m&&_&&g){const e=new s(m),i=new t.dQ(_,g,this.lut);for(const r in d){const o=d[r];o instanceof t.dR?(l(o.layers,this.zoom,h.brightness,n),t.dS(o,m,e.positions,_,i.iconPositions,this.showCollisionBoxes,n,this.tileID.canonical,this.tileZoom,this.projection,this.brightness)):o.hasPattern&&(o instanceof t.dT||o instanceof t.dU||o instanceof t.b_)&&(l(o.layers,this.zoom,h.brightness,n),o.addFeatures(h,this.tileID.canonical,i.patternPositions,n,this.tileTransform,this.brightness))}this.status="done",o(null,{buckets:t.dG(d).filter((t=>!t.isEmpty())),featureIndex:c,collisionBoxArray:this.collisionBoxArray,glyphAtlasImage:e.image,lineAtlas:u,imageAtlas:i,brightness:h.brightness})}};if(!this.extraShadowCaster){const e=t.dP(h.glyphDependencies,(t=>Object.keys(t).map(Number)));Object.keys(e).length?r.send("getGlyphs",{uid:this.uid,stacks:e,scope:this.scope},((t,e)=>{f||(f=t,m=e,v())}),void 0,!1,y):m={};const i=Object.keys(h.iconDependencies);i.length?r.send("getImages",{icons:i,source:this.source,scope:this.scope,tileID:this.tileID,type:"icons"},((t,e)=>{f||(f=t,_=e,v())}),void 0,!1,y):_={};const n=Object.keys(h.patternDependencies);n.length?r.send("getImages",{icons:n,source:this.source,scope:this.scope,tileID:this.tileID,type:"patterns"},((t,e)=>{f||(f=t,g=e,v())}),void 0,!1,y):g={}}v()}}function l(e,i,n,r){const o=new t.X(i,{brightness:n});for(const t of e)t.recalculate(o,r)}class c extends t.E{constructor(e,i,n,r,o,s){super(),this.actor=e,this.layerIndex=i,this.availableImages=n,this.loadVectorData=o||t.ap,this.loading={},this.loaded={},this.deduped=new t.ao(e.scheduler),this.isSpriteLoaded=r,this.scheduler=e.scheduler,this.brightness=s}loadTile(i,n){const r=i.uid,o=i&&i.request,s=o&&o.collectResourceTiming,l=this.loading[r]=new a(i);l.abort=this.loadVectorData(i,((a,c)=>{const d=!this.loading[r];if(delete this.loading[r],d||a||!c)return l.status="done",d||(this.loaded[r]=l),n(a);const u=c.rawData,h={};c.expires&&(h.expires=c.expires),c.cacheControl&&(h.cacheControl=c.cacheControl),l.vectorTile=c.vectorTile||new t.dV(new t.dW(u));const p=()=>{l.parse(l.vectorTile,this.layerIndex,this.availableImages,this.actor,((i,r)=>{if(i||!r)return n(i);const a={};if(s){const t=e(o);t.length>0&&(a.resourceTiming=JSON.parse(JSON.stringify(t)))}n(null,t.W({rawTileData:u.slice(0)},r,h,a))}))};this.isSpriteLoaded?p():this.once("isSpriteLoaded",(()=>{this.scheduler?this.scheduler.add(p,{type:"parseTile",isSymbolTile:i.isSymbolTile,zoom:i.tileZoom}):p()})),this.loaded=this.loaded||{},this.loaded[r]=l}))}reloadTile(e,i){const n=this.loaded,r=e.uid;if(n&&n[r]){const o=n[r];o.showCollisionBoxes=e.showCollisionBoxes,o.projection=e.projection,o.brightness=e.brightness,o.tileTransform=t.dK(e.tileID.canonical,e.projection),o.extraShadowCaster=e.extraShadowCaster,o.lut=e.lut;const s=(t,e)=>{const n=o.reloadCallback;n&&(delete o.reloadCallback,o.parse(o.vectorTile,this.layerIndex,this.availableImages,this.actor,n)),i(t,e)};"parsing"===o.status?o.reloadCallback=s:"done"===o.status&&(o.vectorTile?o.parse(o.vectorTile,this.layerIndex,this.availableImages,this.actor,s):s())}else i(null,void 0)}abortTile(t,e){const i=t.uid,n=this.loading[i];n&&(n.abort&&n.abort(),delete this.loading[i]),e()}removeTile(t,e){const i=this.loaded,n=t.uid;i&&i[n]&&delete i[n],e()}}class d{loadTile(e,i){const{uid:n,encoding:r,rawImageData:o,padding:s}=e,a=ImageBitmap&&o instanceof ImageBitmap?this.getImageData(o,s):o;i(null,new t.dX(n,a,r,s{n(null,t)}),(t=>{n(t)}))}}const h=t.dZ.prototype.toGeoJSON;let p=class{constructor(e){this._feature=e,this.extent=t.a3,this.type=e.type,this.properties=e.tags,"id"in e&&!isNaN(e.id)&&(this.id=parseInt(e.id,10))}loadGeometry(){if(1===this._feature.type){const e=[];for(const i of this._feature.geometry)e.push([new t.P(i[0],i[1])]);return e}{const e=[];for(const i of this._feature.geometry){const n=[];for(const e of i)n.push(new t.P(e[0],e[1]));e.push(n)}return e}}toGeoJSON(t,e,i){return h.call(this,t,e,i)}},f=class{constructor(e){this.layers={_geojsonTileLayer:this},this.name="_geojsonTileLayer",this.extent=t.a3,this.length=e.length,this._features=e}feature(t){return new p(this._features[t])}};const m=64/4096;class _{constructor(){this.features=new Map}clear(){this.features.clear()}load(t=[],e){for(const i of t){const t=i.id;if(null==t)continue;let n=this.features.get(t);n&&this.updateCache(n,e),i.geometry?(n=y(i),this.updateCache(n,e),this.features.set(t,n)):this.features.delete(t),this.updateCache(n,e)}}updateCache(t,e){for(const{canonical:i,uid:n}of Object.values(e)){const{z:r,x:o,y:s}=i;g(t,Math.pow(2,r),o,s)&&delete e[n]}}getTile(t,e,i){const n=Math.pow(2,t),r=[];for(const t of this.features.values())g(t,n,e,i)&&r.push(w(t,n,e,i));return{features:r}}getFeatures(){return[...this.features.values()]}}function g({minX:t,minY:e,maxX:i,maxY:n},r,o,s){return t(o-m)/r&&n>(s-m)/r}function y(t){const{id:e,geometry:i,properties:n}=t;if(!i)return;if("GeometryCollection"===i.type)throw new Error("GeometryCollection not supported in dynamic mode.");const{type:r,coordinates:o}=i,s={id:e,type:1,geometry:[],tags:n,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0},a=s.geometry;if("Point"===r)v(o,a,s);else if("MultiPoint"===r)for(const t of o)v(t,a,s);else if("LineString"===r)s.type=2,x(o,a,s);else if("MultiLineString"===r)s.type=2,b(o,a,s);else if("Polygon"===r)s.type=3,b(o,a,s,!0);else{if("MultiPolygon"!==r)throw new Error("Input data is not a valid GeoJSON object.");s.type=3;for(const t of o)b(t,a,s,!0)}return s}function v([e,i],n,r){const o=t.aj(e);let s=t.ak(i);s=s1?1:s,n.push(o,s),r.minX=Math.min(r.minX,o),r.minY=Math.min(r.minY,s),r.maxX=Math.max(r.maxX,o),r.maxY=Math.max(r.maxY,s)}function x(t,e,i,n=!1,r=!1){const o=[];for(const e of t)v(e,o,i);e.push(o),n&&function(t,e){let i=0;for(let e=0,n=t.length,r=n-2;e0===e)for(let e=0,i=t.length;e>31}function F(t,e){for(var i=t.loadGeometry(),n=t.type,r=0,o=0,s=i.length,a=0;at},V=Math.fround||(G=new Float32Array(1),t=>(G[0]=+t,G[0]));var G;const Z=3,q=5,H=6;class W{constructor(t){this.options=Object.assign(Object.create(j),t),this.trees=new Array(this.options.maxZoom+1),this.stride=this.options.reduce?7:6,this.clusterProps=[]}load(t){const{log:e,minZoom:i,maxZoom:n}=this.options;e&&console.time("total time");const r=`prepare ${t.length} points`;e&&console.time(r),this.points=t;const o=[];for(let e=0;e=i;t--){const i=+Date.now();s=this.trees[t]=this._createTree(this._cluster(s,t)),e&&console.log("z%d: %d clusters in %dms",t,s.numItems,+Date.now()-i)}return e&&console.timeEnd("total time"),this}getClusters(t,e){let i=((t[0]+180)%360+360)%360-180;const n=Math.max(-90,Math.min(90,t[1]));let r=180===t[2]?180:((t[2]+180)%360+360)%360-180;const o=Math.max(-90,Math.min(90,t[3]));if(t[2]-t[0]>=360)i=-180,r=180;else if(i>r){const t=this.getClusters([i,n,180,o],e),s=this.getClusters([-180,n,r,o],e);return t.concat(s)}const s=this.trees[this._limitZoom(e)],a=s.range(K(i),J(o),K(r),J(n)),l=s.data,c=[];for(const t of a){const e=this.stride*t;c.push(l[e+q]>1?Y(l,e,this.clusterProps):this.points[l[e+Z]])}return c}getChildren(t){const e=this._getOriginId(t),i=this._getOriginZoom(t),n="No cluster with the specified id.",r=this.trees[i];if(!r)throw new Error(n);const o=r.data;if(e*this.stride>=o.length)throw new Error(n);const s=this.options.radius/(this.options.extent*Math.pow(2,i-1)),a=r.within(o[e*this.stride],o[e*this.stride+1],s),l=[];for(const e of a){const i=e*this.stride;o[i+4]===t&&l.push(o[i+q]>1?Y(o,i,this.clusterProps):this.points[o[i+Z]])}if(0===l.length)throw new Error(n);return l}getLeaves(t,e,i){const n=[];return this._appendLeaves(n,t,e=e||10,i=i||0,0),n}getTile(t,e,i){const n=this.trees[this._limitZoom(t)],r=Math.pow(2,t),{extent:o,radius:s}=this.options,a=s/o,l=(i-a)/r,c=(i+1+a)/r,d={features:[]};return this._addTileFeatures(n.range((e-a)/r,l,(e+1+a)/r,c),n.data,e,i,r,d),0===e&&this._addTileFeatures(n.range(1-a/r,l,1,c),n.data,r,i,r,d),e===r-1&&this._addTileFeatures(n.range(0,l,a/r,c),n.data,-1,i,r,d),d.features.length?d:null}getClusterExpansionZoom(t){let e=this._getOriginZoom(t)-1;for(;e1;let l,c,d;if(a)l=X(e,t,this.clusterProps),c=e[t],d=e[t+1];else{const i=this.points[e[t+Z]];l=i.properties;const[n,r]=i.geometry.coordinates;c=K(n),d=J(r)}const u={type:1,geometry:[[Math.round(this.options.extent*(c*r-i)),Math.round(this.options.extent*(d*r-n))]],tags:l};let h;h=a||this.options.generateId?e[t+Z]:this.points[e[t+Z]].id,void 0!==h&&(u.id=h),o.features.push(u)}}_limitZoom(t){return Math.max(this.options.minZoom,Math.min(Math.floor(+t),this.options.maxZoom+1))}_cluster(t,e){const{radius:i,extent:n,reduce:r,minPoints:o}=this.options,s=i/(n*Math.pow(2,e)),a=t.data,l=[],c=this.stride;for(let i=0;ie&&(p+=a[i+q])}if(p>h&&p>=o){let t,o=n*h,s=d*h,f=-1;const m=(i/c1)for(const t of u){const i=t*c;if(!(a[i+2]>5}_getOriginZoom(t){return(t-this.points.length)%32}_map(t,e,i){if(t[e+q]>1){const n=this.clusterProps[t[e+H]];return i?Object.assign({},n):n}const n=this.points[t[e+Z]].properties,r=this.options.map(n);return i&&r===n?Object.assign({},r):r}}function Y(t,e,i){return{type:"Feature",id:t[e+Z],properties:X(t,e,i),geometry:{type:"Point",coordinates:[(n=t[e],360*(n-.5)),Q(t[e+1])]}};var n}function X(t,e,i){const n=t[e+q],r=n>=1e4?`${Math.round(n/1e3)}k`:n>=1e3?Math.round(n/100)/10+"k":n,o=t[e+H],s=-1===o?{}:Object.assign({},i[o]);return Object.assign(s,{cluster:!0,cluster_id:t[e+Z],point_count:n,point_count_abbreviated:r})}function K(t){return t/360+.5}function J(t){const e=Math.sin(t*Math.PI/180),i=.5-.25*Math.log((1+e)/(1-e))/Math.PI;return i1?1:i}function Q(t){const e=(180-360*t)*Math.PI/180;return 360*Math.atan(Math.exp(e))/Math.PI-90}function tt(t,e,i,n){let r=n;const o=e+(i-e>>1);let s,a=i-e;const l=t[e],c=t[e+1],d=t[i],u=t[i+1];for(let n=e+3;n =0;for(const i of x.sections)if(i.image)f[i.image.namePrimary]=!0;else{const n=Ca(x.toString()),r=i.fontStack||t,o=m[r]=m[r]||{};this.calculateGlyphDependencies(i.text,o,e,this.allowVerticalPlacement,n)}}}"line"===s.get("symbol-placement")&&(this.features=function(t){const e={},i={},n=[];let r=0;function o(e){n.push(t[e]),r++}function s(t,e,r){const o=i[t];return delete i[t],i[e]=o,n[o].geometry[0].pop(),n[o].geometry[0]=n[o].geometry[0].concat(r[0]),o}function a(t,i,r){const o=e[i];return delete e[i],e[t]=o,n[o].geometry[0].shift(),n[o].geometry[0]=r[0].concat(n[o].geometry[0]),o}function l(t,e,i){const n=i?e[0][e[0].length-1]:e[0][0];return`${t}:${n.x}:${n.y}`}for(let c=0;ct.geometry))}(this.features)),this.sortFeaturesByKey&&this.features.sort(((t,e)=>t.sortKey-e.sortKey))}update(t,e,i,n,r){const o=0!==Object.keys(t).length;if(o&&!this.stateDependentLayers.length)return;const s=o?this.stateDependentLayers:this.layers;this.text.programConfigurations.updatePaintArrays(t,e,s,i,n,r),this.icon.programConfigurations.updatePaintArrays(t,e,s,i,n,r)}updateOcclusionOpacities(t,e,i){if(!e.useOcclusionQueries)return!1;const n=this;if("globe"===n.projection.name)return!1;let r=!1;n.hasTextData()&&(r=r||0!==n.text.occlusionQueryOpacityVertexArray.length),n.hasIconData()&&(r=r||0!==n.icon.occlusionQueryOpacityVertexArray.length);const o=n.layers[0].paint,s=o.get("icon-occlusion-opacity").constantOr(0),a=o.get("text-occlusion-opacity").constantOr(0);if(!n.layers[0].hasInitialOcclusionOpacityProperties||1===s&&1===a)return!1;let l=!r;for(let t=0;t.5?1:-1)*e.fadeSpeed*i*.001,r.occlusionOpacity=Xe(r.occlusionOpacity,0,1),l=l||r.occlusionOpacity!==o}if(!l)return!1;let c=0,d=0;const u=(t,e,i,n)=>{let r=0,o=0;i?(r=d,d+=n,o=d):(r=c,c+=n,o=c),o>e.occlusionQueryOpacityVertexArray.length&&e.occlusionQueryOpacityVertexArray.resize(o);const s=t.occlusionOpacity;for(let t=0;t0;if((i>0||r>0)&&(u(e,n.text,!1,i),u(e,n.text,!1,r)),s){const{placedIconSymbolIndex:t,verticalPlacedIconSymbolIndex:i}=e;t>=0&&u(e,n.icon,!0,o),i>=0&&u(e,n.icon,!0,e.numVerticalIconVertices)}}return n.hasTextData()&&n.text.occlusionQueryOpacityVertexBuffer&&(n.text.occlusionQueryOpacityVertexBuffer.length{i+=e,i>t.length&&t.resize(i);for(let r=-e;r{n+=e,n>t.length&&t.resize(n);for(let r=-e;r0;if((r>0||o>0)&&(t(this.text.zOffsetVertexArray,r,a),t(this.text.zOffsetVertexArray,o,a)),l){const{placedIconSymbolIndex:t,verticalPlacedIconSymbolIndex:i}=n;t>=0&&e(this.icon.zOffsetVertexArray,s,a),i>=0&&e(this.icon.zOffsetVertexArray,n.numVerticalIconVertices,a)}}this.text.zOffsetVertexBuffer&&this.text.zOffsetVertexBuffer.updateData(this.text.zOffsetVertexArray),this.icon.zOffsetVertexBuffer&&this.icon.zOffsetVertexBuffer.updateData(this.icon.zOffsetVertexArray)}isEmpty(){return 0===this.symbolInstances.length&&!this.hasRTLText}uploadPending(){return!this.uploaded||this.text.programConfigurations.needsUpload||this.icon.programConfigurations.needsUpload}upload(t){!this.uploaded&&this.hasDebugData()&&(this.textCollisionBox.upload(t),this.iconCollisionBox.upload(t)),this.text.upload(t,this.sortFeaturesByY,!this.uploaded,this.text.programConfigurations.needsUpload,this.zOffsetBuffersNeedUpload),this.icon.upload(t,this.sortFeaturesByY,!this.uploaded,this.icon.programConfigurations.needsUpload,this.zOffsetBuffersNeedUpload),this.uploaded=!0}destroyDebugData(){this.textCollisionBox.destroy(),this.iconCollisionBox.destroy()}getProjection(){return this.projectionInstance||(this.projectionInstance=Tg(this.projection)),this.projectionInstance}destroy(){this.text.destroy(),this.icon.destroy(),this.hasDebugData()&&this.destroyDebugData();for(const t of this.queries.values())t.destroy()}addToLineVertexArray(t,e){const i=this.lineVertexArray.length;if(void 0!==t.segment)for(const{x:t,y:i}of e)this.lineVertexArray.emplaceBack(t,i);return{lineStartIndex:i,lineLength:this.lineVertexArray.length-i}}addSymbols(t,e,i,n,r,o,s,a,l,c,d,u,h,p,f,m){const _=t.indexArray,g=t.layoutVertexArray,y=t.globeExtVertexArray,v=t.segments.prepareSegment(4*e.length,g,_,this.canOverlap?o.sortKey:void 0),x=this.glyphOffsetArray.length,b=v.vertexLength,w=this.allowVerticalPlacement&&s===Jm.vertical?Math.PI/2:0,T=o.text&&o.text.sections;for(let n=0;n=0?e.rightJustifiedTextSymbolIndex:e.centerJustifiedTextSymbolIndex>=0?e.centerJustifiedTextSymbolIndex:e.leftJustifiedTextSymbolIndex>=0?e.leftJustifiedTextSymbolIndex:e.verticalPlacedTextSymbolIndex>=0?e.verticalPlacedTextSymbolIndex:n),o=Nm(this.textSizeData,t,r)/Om;return this.tilePixelRatio*o}getSymbolInstanceIconSize(t,e,i){const n=this.icon.placedSymbolArray.get(i),r=Nm(this.iconSizeData,t,n);return this.tilePixelRatio*r}_commitDebugCollisionVertexUpdate(t,e,i,n){t.emplaceBack(e,-i,-i,n),t.emplaceBack(e,i,-i,n),t.emplaceBack(e,i,i,n),t.emplaceBack(e,-i,i,n)}_updateTextDebugCollisionBoxes(t,e,i,n,r,o){for(let s=n;s0}hasIconData(){return this.icon.segments.get().length>0}hasDebugData(){return this.textCollisionBox&&this.iconCollisionBox}hasTextCollisionBoxData(){return this.hasDebugData()&&this.textCollisionBox.segments.get().length>0}hasIconCollisionBoxData(){return this.hasDebugData()&&this.iconCollisionBox.segments.get().length>0}hasIconTextFit(){return this.hasAnyIconTextFit}addIndicesForPlacedSymbol(t,e){const i=t.placedSymbolArray.get(e),n=i.vertexStartIndex+4*i.numGlyphs;for(let e=i.vertexStartIndex;en[t]-n[e]||r[e]-r[t])),o}getSortedIndexesByZOffset(){if(!this.zOffsetSortDirty)return this.symbolInstanceIndexesSortedZOffset;if(!this.symbolInstanceIndexesSortedZOffset){this.symbolInstanceIndexesSortedZOffset=[];for(let t=0;tthis.symbolInstances.get(e).zOffset-this.symbolInstances.get(t).zOffset))}addToSortKeyRanges(t,e){const i=this.sortKeyRanges[this.sortKeyRanges.length-1];i&&i.sortKey===e?i.symbolInstanceEnd=t+1:this.sortKeyRanges.push({sortKey:e,symbolInstanceStart:t,symbolInstanceEnd:t+1})}sortFeatures(t){if(this.sortFeaturesByY&&this.sortedAngle!==t&&!(this.text.segments.get().length>1||this.icon.segments.get().length>1)){this.symbolInstanceIndexes=this.getSortedSymbolIndexes(t),this.sortedAngle=t,this.text.indexArray.clear(),this.icon.indexArray.clear(),this.featureSortOrder=[];for(const t of this.symbolInstanceIndexes){const e=this.symbolInstances.get(t);this.featureSortOrder.push(e.featureIndex);const{rightJustifiedTextSymbolIndex:i,centerJustifiedTextSymbolIndex:n,leftJustifiedTextSymbolIndex:r,verticalPlacedTextSymbolIndex:o,placedIconSymbolIndex:s,verticalPlacedIconSymbolIndex:a}=e;i>=0&&this.addIndicesForPlacedSymbol(this.text,i),n>=0&&n!==i&&this.addIndicesForPlacedSymbol(this.text,n),r>=0&&r!==n&&r!==i&&this.addIndicesForPlacedSymbol(this.text,r),o>=0&&this.addIndicesForPlacedSymbol(this.text,o),s>=0&&this.addIndicesForPlacedSymbol(this.icon,s),a>=0&&this.addIndicesForPlacedSymbol(this.icon,a)}this.text.indexBuffer&&this.text.indexBuffer.updateData(this.text.indexArray),this.icon.indexBuffer&&this.icon.indexBuffer.updateData(this.icon.indexArray)}}}ba(jg,"SymbolBucket",{omit:["layers","collisionBoxArray","features","compareText"]}),jg.addDynamicAttributes=Bg;class Vg{constructor(t,e,i,n){this.context=t,this.format=i,this.texture=t.gl.createTexture(),this.update(e,n)}update(t,e,i){const{width:n,height:r}=t,{context:o}=this,{gl:s}=o;if(s.bindTexture(s.TEXTURE_2D,this.texture),o.pixelStoreUnpackFlipY.set(!1),o.pixelStoreUnpack.set(1),o.pixelStoreUnpackPremultiplyAlpha.set(this.format===s.RGBA&&(!e||!1!==e.premultiply)),this.useMipmap=Boolean(e&&e.useMipmap),i||this.size&&this.size[0]===n&&this.size[1]===r){const{x:e,y:o}=i||{x:0,y:0};if(t instanceof HTMLImageElement||t instanceof HTMLCanvasElement||t instanceof HTMLVideoElement||t instanceof ImageData||ImageBitmap&&t instanceof ImageBitmap)s.texSubImage2D(s.TEXTURE_2D,0,e,o,s.RGBA,s.UNSIGNED_BYTE,t);else{let i=this.format,a=s.UNSIGNED_BYTE;this.format===s.R32F&&(i=s.RED,a=s.FLOAT),s.texSubImage2D(s.TEXTURE_2D,0,e,o,n,r,i,a,t.data)}}else if(this.size=[n,r],t instanceof HTMLImageElement||t instanceof HTMLCanvasElement||t instanceof HTMLVideoElement||t instanceof ImageData||ImageBitmap&&t instanceof ImageBitmap){let e=this.format;this.format===s.R8&&(e=s.RED),s.texImage2D(s.TEXTURE_2D,0,this.format,e,s.UNSIGNED_BYTE,t)}else{let e=this.format,i=this.format,o=s.UNSIGNED_BYTE,a=!1;this.format===s.DEPTH_COMPONENT&&(e=s.DEPTH_COMPONENT16,o=s.UNSIGNED_SHORT),this.format===s.DEPTH_STENCIL&&(e=s.DEPTH24_STENCIL8,o=s.UNSIGNED_INT_24_8,a=!0),this.format===s.R8&&(i=s.RED),this.format===s.R32F&&(o=s.FLOAT,i=s.RED),!this.useMipmap&&a?s.texStorage2D(s.TEXTURE_2D,1,e,n,r):s.texImage2D(s.TEXTURE_2D,0,e,n,r,0,i,o,t.data)}this.useMipmap&&s.generateMipmap(s.TEXTURE_2D)}bind(t,e,i=!1){const{context:n}=this,{gl:r}=n;r.bindTexture(r.TEXTURE_2D,this.texture),t!==this.minFilter&&(r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MAG_FILTER,t),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MIN_FILTER,this.useMipmap&&!i?t===r.NEAREST?r.NEAREST_MIPMAP_NEAREST:r.LINEAR_MIPMAP_LINEAR:t),this.minFilter=t),e!==this.wrapS&&(r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_S,e),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_T,e),this.wrapS=e)}bindExtraParam(t,e,i,n){const{context:r}=this,{gl:o}=r;o.bindTexture(o.TEXTURE_2D,this.texture),e!==this.magFilter&&(o.texParameteri(o.TEXTURE_2D,o.TEXTURE_MAG_FILTER,e),this.magFilter=e),t!==this.minFilter&&(o.texParameteri(o.TEXTURE_2D,o.TEXTURE_MIN_FILTER,this.useMipmap?t===o.NEAREST?o.NEAREST_MIPMAP_NEAREST:o.LINEAR_MIPMAP_LINEAR:t),this.minFilter=t),i!==this.wrapS&&(o.texParameteri(o.TEXTURE_2D,o.TEXTURE_WRAP_S,i),this.wrapS=i),n!==this.wrapT&&(o.texParameteri(o.TEXTURE_2D,o.TEXTURE_WRAP_T,n),this.wrapT=n)}destroy(){const{gl:t}=this.context;t.deleteTexture(this.texture),this.texture=null}}class Gg{constructor(t,e){this.context=t,this.texture=e}bind(t,e){const{context:i}=this,{gl:n}=i;n.bindTexture(n.TEXTURE_2D,this.texture),t!==this.minFilter&&(n.texParameteri(n.TEXTURE_2D,n.TEXTURE_MAG_FILTER,t),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_MIN_FILTER,t),this.minFilter=t),e!==this.wrapS&&(n.texParameteri(n.TEXTURE_2D,n.TEXTURE_WRAP_S,e),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_WRAP_T,e),this.wrapS=e)}}const Zg=32,qg=33,Hg=new Uint16Array(8184);for(let t=0;t>=1)>1;){const t=i+r>>1,l=n+o>>1;1&e?(r=i,o=n,i=s,n=a):(i=r,n=o,r=s,o=a),s=t,a=l}const l=4*t;Hg[l+0]=i,Hg[l+1]=n,Hg[l+2]=r,Hg[l+3]=o}const Wg=new Uint16Array(2178),Yg=new Uint8Array(1089),Xg=new Uint16Array(1089);function Kg(t){return 0===t?-.03125:32===t?.03125:0}var Jg=Ll([{name:"a_pos",type:"Int16",components:2},{name:"a_texture_pos",type:"Int16",components:2}]),Qg=Ll([{name:"a_index",type:"Int16",components:1}]);const ty={type:2,extent:uo,loadGeometry:()=>[[new Ue(0,0),new Ue(uo+1,0),new Ue(uo+1,uo+1),new Ue(0,uo+1),new Ue(0,0)]]};class ey{constructor(t,e,i,n,r){this.tileID=t,this.uid=ni(),this.uses=0,this.tileSize=e,this.tileZoom=i,this.buckets={},this.expirationTime=null,this.queryPadding=0,this.hasSymbolBuckets=!1,this.hasRTLText=!1,this.dependencies={},this.isRaster=r,n&&n.style&&(this._lastUpdatedBrightness=n.style.getBrightness()),this.expiredRequestCount=0,this.state="loading",n&&n.transform&&(this.projection=n.transform.projection)}registerFadeDuration(t){const e=t+this.timeAdded;ee.getLayer(t))).filter(Boolean);if(0!==t.length){n.layers=t,n.stateDependentLayerIds&&(n.stateDependentLayers=n.stateDependentLayerIds.map((e=>t.filter((t=>t.id===e))[0])));for(const e of t)i[e.fqid]=n}}return i}(t.buckets,e.style),this.hasSymbolBuckets=!1;for(const t in this.buckets){const e=this.buckets[t];if(e instanceof jg){if(this.hasSymbolBuckets=!0,!i)break;e.justReloaded=!0}}if(this.hasRTLText=!1,this.hasSymbolBuckets)for(const t in this.buckets){const e=this.buckets[t];if(e instanceof jg&&e.hasRTLText){this.hasRTLText=!0,qa.isLoading()||qa.isLoaded()||"deferred"!==Ga()||Za();break}}this.queryPadding=0;for(const t in this.buckets){const i=this.buckets[t],n=e.style.getOwnLayer(t);if(!n)continue;const r=n.queryRadius(i);this.queryPadding=Math.max(this.queryPadding,r)}t.imageAtlas&&(this.imageAtlas=t.imageAtlas),t.glyphAtlasImage&&(this.glyphAtlasImage=t.glyphAtlasImage),t.lineAtlas&&(this.lineAtlas=t.lineAtlas),this._lastUpdatedBrightness=t.brightness}else this.collisionBoxArray=new dc}unloadVectorData(){if(this.hasData()){for(const t in this.buckets)this.buckets[t].destroy();this.buckets={},this.imageAtlas&&(this.imageAtlas=null),this.lineAtlas&&(this.lineAtlas=null),this.imageAtlasTexture&&this.imageAtlasTexture.destroy(),this.glyphAtlasTexture&&this.glyphAtlasTexture.destroy(),this.lineAtlasTexture&&this.lineAtlasTexture.destroy(),this._tileBoundsBuffer&&(this._tileBoundsBuffer.destroy(),this._tileBoundsIndexBuffer.destroy(),this._tileBoundsSegments.destroy(),this._tileBoundsBuffer=null),this._tileDebugBuffer&&(this._tileDebugBuffer.destroy(),this._tileDebugSegments.destroy(),this._tileDebugBuffer=null),this._tileDebugIndexBuffer&&(this._tileDebugIndexBuffer.destroy(),this._tileDebugIndexBuffer=null),this._globeTileDebugBorderBuffer&&(this._globeTileDebugBorderBuffer.destroy(),this._globeTileDebugBorderBuffer=null),this._tileDebugTextBuffer&&(this._tileDebugTextBuffer.destroy(),this._tileDebugTextSegments.destroy(),this._tileDebugTextIndexBuffer.destroy(),this._tileDebugTextBuffer=null),this._globeTileDebugTextBuffer&&(this._globeTileDebugTextBuffer.destroy(),this._globeTileDebugTextBuffer=null),this.latestFeatureIndex=null,this.state="unloaded"}}getBucket(t){return this.buckets[t.fqid]}upload(t){for(const e in this.buckets){const i=this.buckets[e];i.uploadPending()&&i.upload(t)}const e=t.gl,i=this.imageAtlas;if(i&&!i.uploaded){const n=!!Object.keys(i.patternPositions).length;this.imageAtlasTexture=new Vg(t,i.image,e.RGBA,{useMipmap:n}),this.imageAtlas.uploaded=!0}this.glyphAtlasImage&&(this.glyphAtlasTexture=new Vg(t,this.glyphAtlasImage,e.R8),this.glyphAtlasImage=null),this.lineAtlas&&!this.lineAtlas.uploaded&&(this.lineAtlasTexture=new Vg(t,this.lineAtlas.image,e.R8),this.lineAtlas.uploaded=!0)}prepare(t,e,i){if(this.imageAtlas&&this.imageAtlasTexture&&this.imageAtlas.patchUpdatedImages(t,this.imageAtlasTexture,i),!e||!this.latestFeatureIndex||!this.latestFeatureIndex.rawTileData)return;const n=e.style.getBrightness();(this._lastUpdatedBrightness||n)&&(this._lastUpdatedBrightness&&n&&Math.abs(this._lastUpdatedBrightness-n)t)i=!1;else if(e)if(this.expirationTime=0;t--){const e=4*t,i=Hg[e+0],n=Hg[e+1],r=Hg[e+2],o=Hg[e+3],s=i+r>>1,a=n+o>>1,l=s+a-n,c=a+i-s,d=n*qg+i,u=o*qg+r,h=a*qg+s,p=Math.hypot((Wg[2*d+0]+Wg[2*u+0])/2-Wg[2*h+0],(Wg[2*d+1]+Wg[2*u+1])/2-Wg[2*h+1])>=16;Yg[h]=Yg[h]||(p?1:0),t>1)*qg+(i+l>>1)]||Yg[(o+c>>1)*qg+(r+l>>1)])}const r=new Dl,o=new Kl;let s=0;function a(t,e){const i=e*qg+t;return 0===Xg[i]&&(r.emplaceBack(Wg[2*i+0],Wg[2*i+1],t*uo/Zg,e*uo/Zg),Xg[i]=++s),Xg[i]-1}function l(t,e,i,n,r,s){const c=t+i>>1,d=e+n>>1;if(Math.abs(t-r)+Math.abs(e-s)>1&&Yg[d*qg+c])l(r,s,t,e,c,d),l(i,n,r,s,c,d);else{const l=a(t,e),c=a(i,n),d=a(r,s);o.emplaceBack(l,c,d)}}return l(0,0,Zg,Zg,Zg,0),l(Zg,Zg,0,0,0,Zg),{vertices:r,indices:o}}(this.tileID.canonical,e);n=t.vertices,r=t.indices}else{n=new Dl,r=new Kl;for(const{x:t,y:e}of i)n.emplaceBack(t,e,0,0);const t=xh(n.int16,void 0,4);for(let e=0;e0&&(a=t.ad.invert(new Float64Array(16),i.globeMatrix)),this._makeGlobeTileDebugBorderBuffer(e,r,i,o,a,s),this._makeGlobeTileDebugTextBuffer(e,r,i,o,a,s)}_globePoint(e,i,n,r,o,s,a){let l=Fu(e,i,n);if(s){const o=1.5?h=-1:u{const p=(d-t)/(h-1),f=(u-c)/(h-1),m=s.length;for(let d=0;dd*t+e;for(let t=0;t[t,this.get(t)]))}evict(t=!1){if(t||this.size>0){const t=this.first;delete this.items[t.key],0==--this.size?(this.first=null,this.last=null):(this.first=t.next,this.first.prev=null)}return this}expiresAt(t){let e;return this.has(t)&&(e=this.items[t].expiry),e}get(t){let e;if(this.has(t)){const i=this.items[t];this.ttl>0&&i.expiry0?Date.now()+this.ttl:this.ttl),this.last!==r){const t=this.last,e=r.next,i=r.prev;this.first===r&&(this.first=r.next),r.next=null,r.prev=this.last,t.next=r,null!==i&&(i.next=e),null!==e&&(e.prev=i)}}else this.max>0&&this.size===this.max&&this.evict(!0),r=this.items[t]={expiry:this.ttl>0?Date.now()+this.ttl:this.ttl,key:t,prev:this.last,next:null,value:e},1==++this.size?this.first=r:this.last.next=r;return this.last=r,this}values(t=this.keys()){return t.map((t=>this.get(t)))}}function uy(t,e){if(4!==e.length)throw new Error(`Expected data of dimension 4 but got ${e.length}.`);let i=e[3];for(let n=2;n>=1;n--){const r=1===n?1:0,o=2===n?1:0;for(let n=0;n>>1^-(1&t[e]);return t}function py(t,e){switch(e){case"uint32":return t;case"uint16":for(let e=0;e>4|(61440&i)>>8|(240&n)>4|(15&n)>6|(192&n)>>4|(192&r)>>2|192&o,t[e+1]=(48&i)>>4|(48&n)>>2|48&r|(48&o)>2|12&n|(12&r)>1|(21845&Cy)>2|(13107&Ay)>4|(3855&Ay)>8|(255&Ay)>1}var Iy=function(t,e,i){for(var n=t.length,r=0,o=new _y(e);r>l]=c}else for(s=new _y(n),r=0;r>15-t[r]);return s},Ly=new my(288);for(Cy=0;Cye&&(e=t[i]);return e},zy=function(t,e,i){var n=e/8|0;return(t[n]|t[n+1]>(7&e)&i},Ry=function(t,e){var i=e/8|0;return(t[i]|t[i+1]>(7&e)},Oy=["unexpected EOF","invalid block type","invalid length/literal","invalid distance","stream finished","no stream handler",,"no callback","invalid UTF-8 data","extra field too long","date not in range 1980-2099","filename too long","stream finishing","invalid zip data"],By=function(t,e,i){var n=new Error(e||Oy[t]);if(n.code=t,Error.captureStackTrace&&Error.captureStackTrace(n,By),!i)throw n;return n},Fy=new my(0),Ny="undefined"!=typeof TextDecoder&&new TextDecoder;try{Ny.decode(Fy,{stream:!0})}catch(t){}const Uy={gzip_data:"gzip"},jy={0:"uint32",1:"uint32",2:"uint16",3:"uint8"},Vy={uint32:1,uint16:2,uint8:4},Gy={uint32:Uint32Array,uint16:Uint16Array,uint8:Uint8Array};class Zy{constructor(t=1){this.x=NaN,this.y=NaN,this.z=NaN,this.layers={},this._cacheSize=t}getLayer(t){return this.layers[t]}getHeaderLength(t){const e=new Uint8Array(t),i=new DataView(t);if(13!==e[0])throw new fy("File is not a valid MRT.");return i.getUint32(1,!0)}parseHeader(t){const e=new Uint8Array(t),i=this.getHeaderLength(t);if(e.length= ${i} but got buffer of length ${e.length}`);const n=function(t){return t.readFields(iy,{header_length:0,x:0,y:0,z:0,layers:[]},void 0)}(new Lm(e.subarray(0,i)));if(!isNaN(this.x)&&(this.x!==n.x||this.y!==n.y||this.z!==n.z))throw new fy(`Invalid attempt to parse header ${n.z}/${n.x}/${n.y} for tile ${this.z}/${this.x}/${this.y}`);this.x=n.x,this.y=n.y,this.z=n.z;for(const t of n.layers)this.layers[t.name]=new qy(t,{cacheSize:this._cacheSize});return this}createDecodingTask(t){const e=[],i=this.getLayer(t.layerName);for(let n=0;nt.lastBlock)continue;if(i._blocksInProgress.has(n))continue;const a={layerName:i.name,firstByte:o,lastByte:s,pixelFormat:i.pixelFormat,blockIndex:n,blockShape:[r.bands.length].concat(i.bandShape),buffer:i.buffer,codec:r.codec.codec,filters:r.filters.map((t=>t.filter))};i._blocksInProgress.add(n),e.push(a)}return new Hy(e,(()=>{e.forEach((t=>i._blocksInProgress.delete(t.blockIndex)))}),((t,n)=>{if(e.forEach((t=>i._blocksInProgress.delete(t.blockIndex))),t)throw t;n.forEach((t=>{this.getLayer(t.layerName).processDecodedData(t)}))}))}}class qy{constructor({version:t,name:e,units:i,tilesize:n,pixel_format:r,buffer:o,data_index:s},a){if(this.version=t,1!==this.version)throw new fy(`Cannot parse raster layer encoded with MRT version ${t}`);this.name=e,this.units=i,this.tileSize=n,this.buffer=o,this.pixelFormat=jy[r],this.dataIndex=s,this.bandShape=[n+2*o,n+2*o,Vy[this.pixelFormat]],this._decodedBlocks=function(t=1e3,e=0,i=!1){if(isNaN(t)||t=e&&t=0}hasDataForBand(t){const{blockIndex:e}=this.getBlockForBand(t);return e>=0&&!!this._decodedBlocks.get(e.toString())}getBandView(t){const{blockIndex:e,blockBandIndex:i}=this.getBlockForBand(t),n=this._decodedBlocks.get(e.toString());if(!n)throw new fy(`Data for band ${JSON.stringify(t)} of layer "${this.name}" not decoded.`);const r=this.dataIndex[e],o=this.bandShape.reduce(((t,e)=>t*e),1),s=i*o,a=n.subarray(s,s+o);return{data:a,bytes:new Uint8Array(a.buffer).subarray(a.byteOffset,a.byteOffset+a.byteLength),tileSize:this.tileSize,buffer:this.buffer,offset:r.offset,scale:r.scale}}}class Hy{constructor(t,e,i){this.tasks=t,this._onCancel=e,this._onComplete=i,this._finalized=!1}cancel(){this._finalized||(this._onCancel(),this._finalized=!0)}complete(t,e){this._finalized||(this._onComplete(t,e),this._finalized=!0)}}Zy.performDecoding=function(t,e){return Promise.all(e.tasks.map((e=>{const{layerName:i,firstByte:n,lastByte:r,pixelFormat:o,blockShape:s,blockIndex:a,filters:l,codec:c}=e,d=new Uint8Array(t).subarray(n,r+1),u=new Uint32Array(s[0]*s[1]*s[2]);let h;if("gzip_data"!==c)throw new Error(`Unhandled codec: ${c}`);return h=function(t,e){if(!globalThis.DecompressionStream&&"gzip_data"===e)return Promise.resolve(((o=function(t){31==t[0]&&139==t[1]&&8==t[2]||By(6,"invalid gzip data");var e=t[3],i=10;4&e&&(i+=2+(t[10]|t[11]>3&1)+(e>>4&1);n>0;n-=!t[i++]);return i+(2&e)}(r=t))+8>r.length&&By(6,"invalid gzip data"),function(t,e,i){var n=t.length;if(!n||e.f&&!e.l)return i||new my(0);var r=!i,o=r||2!=e.i,s=e.i;r&&(i=new my(3*n));var a,l,c=function(t){var e=i.length;if(t>e){var n=new my(Math.max(2*e,t));n.set(i),i=n}},d=e.f||0,u=e.p||0,h=e.b||0,p=e.l,f=e.d,m=e.m,_=e.n,g=8*n;do{if(!p){d=zy(t,u,1);var y=zy(t,u+1,3);if(u+=3,!y){var v=t[(L=4+((u+7)/8|0))-4]|t[L-3]n){s&&By(0);break}o&&c(h+v),i.set(t.subarray(L,x),h),e.b=h+=v,e.p=u=8*x,e.f=d;continue}if(1==y)p=$y,f=ky,m=9,_=5;else if(2==y){var b=zy(t,u,31)+257,w=zy(t,u+10,15)+4,T=b+zy(t,u+5,31)+1;u+=14;for(var S=new my(T),E=new my(19),M=0;M>4)g){s&&By(0);break}}o&&c(h+131072);for(var R=(1>4;if((u+=15&$)>g){s&&By(0);break}if($||By(2),F264&&(N=zy(t,u,(1>4;if(U||By(3),u+=15&U,z=Ey[j],j>3){var V=vy[j];z+=Ry(t,u)&(1g){s&&By(0);break}o&&c(h+131072);var G=h+N;if(ha.length)&&(l=a.length),new my(a.subarray(0,l))):i.subarray(0,h)}(r.subarray(o,-8),{i:2},new my(((i=r)[(n=i.length)-4]|i[n-3]>>0))));var i,n,r,o;const s=Uy[e];if(!s)throw new Error(`Unhandled codec: ${e}`);const a=new globalThis.DecompressionStream(s);return new Response(new Blob([t]).stream().pipeThrough(a)).arrayBuffer().then((t=>new Uint8Array(t)))}(d,c).then((t=>(function(t,e){t.readFields(ly,e)}(new Lm(t),u),new(0,Gy[o])(u.buffer)))),h.then((t=>{for(let e=l.length-1;e>=0;e--)switch(l[e]){case"delta_filter":uy(t,s);break;case"zigzag_filter":hy(t);break;case"bitshuffle_filter":py(t,o);break;default:throw new Error(`Unhandled filter "${l[e]}"`)}return{layerName:i,blockIndex:a,data:t}})).catch((t=>{throw t}))})))};class Wy extends ey{constructor(t,e,i,n,r){super(t,e,i,n,r),this._workQueue=[],this._fetchQueue=[],this._isHeaderLoaded=!1}setTexture(t,e){const i=e.context,n=i.gl;this.texture=this.texture||e.getTileTexture(t.width),this.texture&&this.texture instanceof Vg?this.texture.update(t,{useMipmap:!1,premultiply:!1}):this.texture=new Vg(i,t,n.RGBA,{useMipmap:!1,premultiply:!1})}flushQueues(){for(;this._workQueue.length;)this._workQueue.pop()();for(;this._fetchQueue.length;)this._fetchQueue.pop()()}fetchHeader(t=16384,e){const i=this._mrt=new Zy(30),n=Object.assign({},this.requestParams,{headers:{Range:"bytes=0-"+(t-1)}});return this.entireBuffer=null,this.request=en(n,((n,r,o,s)=>{if(n)e(n);else try{const n=i.getHeaderLength(r);if(n>t)return void(this.request=this.fetchHeader(n,e));i.parseHeader(r),this._isHeaderLoaded=!0;let a=0;for(const t of Object.values(i.layers))a=Math.max(a,t.dataIndex[t.dataIndex.length-1].last_byte);r.byteLength>=a&&(this.entireBuffer=r),e(null,this.entireBuffer||r,o,s)}catch(t){e(t)}})),this.request}fetchBand(t,e,i){const n=this._mrt;if(!this._isHeaderLoaded||!n)return void i(new Error("Tile header is not ready"));const r=this.actor;if(!r)return void i(new Error("Can't fetch tile band without an actor"));let o;const s=(n,r)=>{o.complete(n,r),n?i(n):(this.updateTextureDescriptor(t,e),i(null,this.textureDescriptor&&this.textureDescriptor.img))},a=(t,e)=>{if(t)return i(t);const n=r.send("decodeRasterArray",{buffer:e,task:o},s,void 0,!0);this._workQueue.push((()=>{n&&n.cancel(),o.cancel()}))},l=n.getLayer(t);if(!l)return void i(new Error(`Unknown sourceLayer "${t}"`));if(l.hasDataForBand(e))return this.updateTextureDescriptor(t,e),void i(null,this.textureDescriptor?this.textureDescriptor.img:null);const c=l.getDataRange([e]);if(o=n.createDecodingTask(c),!o||o.tasks.length)if(this.flushQueues(),this.entireBuffer)a(null,this.entireBuffer.slice(c.firstByte,c.lastByte+1));else{const t=Object.assign({},this.requestParams,{headers:{Range:`bytes=${c.firstByte}-${c.lastByte}`}}),e=en(t,a);this._fetchQueue.push((()=>{e.cancel(),o.cancel()}))}else i(null)}updateNeeded(t,e){return(!this.textureDescriptor||this.textureDescriptor.band!==e||this.textureDescriptor.layer!==t)&&"errored"!==this.state}updateTextureDescriptor(t,e){if(!this._mrt)return;const i=this._mrt.getLayer(t);if(!i||!i.hasBand(e)||!i.hasDataForBand(e))return;const{bytes:n,tileSize:r,buffer:o,offset:s,scale:a}=i.getBandView(e),l=r+2*o,c={data:n,width:l,height:l},d=this.texture;d&&d instanceof Vg&&d.update(c,{useMipmap:!1,premultiply:!1}),this.textureDescriptor={layer:t,band:e,img:c,buffer:o,offset:s,tileSize:r,format:i.pixelFormat,mix:[a,256*a,65536*a,16777216*a]}}}class Yy{constructor(t,e){this.max=t,this.onRemove=e,this.reset()}reset(){for(const t in this.data)for(const e of this.data[t])e.timeout&&clearTimeout(e.timeout),this.onRemove(e.value);return this.data={},this.order=[],this}add(t,e,i){const n=t.wrapped().key;void 0===this.data[n]&&(this.data[n]=[]);const r={value:e,timeout:void 0};if(void 0!==i&&(r.timeout=setTimeout((()=>{this.remove(t,r)}),i)),this.data[n].push(r),this.order.push(n),this.order.length>this.max){const t=this._getAndRemoveByKey(this.order[0]);t&&this.onRemove(t)}return this}has(t){return t.wrapped().key in this.data}getAndRemove(t){return this.has(t)?this._getAndRemoveByKey(t.wrapped().key):null}_getAndRemoveByKey(t){const e=this.data[t].shift();return e.timeout&&clearTimeout(e.timeout),0===this.data[t].length&&delete this.data[t],this.order.splice(this.order.indexOf(t),1),e.value}getByKey(t){const e=this.data[t];return e?e[0].value:null}get(t){return this.has(t)?this.data[t.wrapped().key][0].value:null}remove(t,e){if(!this.has(t))return this;const i=t.wrapped().key,n=void 0===e?0:this.data[i].indexOf(e),r=this.data[i][n];return this.data[i].splice(n,1),r.timeout&&clearTimeout(r.timeout),0===this.data[i].length&&delete this.data[i],this.onRemove(r.value),this.order.splice(this.order.indexOf(i),1),this}setMaxSize(t){for(this.max=t;this.order.length>this.max;){const t=this._getAndRemoveByKey(this.order[0]);t&&this.onRemove(t)}return this}filter(t){const e=[];for(const i in this.data)for(const n of this.data[i])t(n.value)||e.push(n);for(const t of e)this.remove(t.value.tileID,t)}}class Xy extends zn{constructor(t,e,i){super(),this.id=t,this._onlySymbols=i,e.on("data",(t=>{"source"===t.dataType&&"metadata"===t.sourceDataType&&(this._sourceLoaded=!0),this._sourceLoaded&&!this._paused&&"source"===t.dataType&&"content"===t.sourceDataType&&(this.reload(),this.transform&&this.update(this.transform))})),e.on("error",(()=>{this._sourceErrored=!0})),this._source=e,this._tiles={},this._cache=new Yy(0,this._unloadTile.bind(this)),this._timers={},this._cacheTimers={},this._minTileCacheSize=e.minTileCacheSize,this._maxTileCacheSize=e.maxTileCacheSize,this._loadedParentTiles={},this.castsShadows=!1,this.tileCoverLift=0,this._coveredTiles={},this._shadowCasterTiles={},this._state=new km,this._isRaster="raster"===this._source.type||"raster-dem"===this._source.type||"raster-array"===this._source.type||"custom"===this._source.type&&"raster"===this._source._dataType}onAdd(t){this.map=t,this._minTileCacheSize=void 0===this._minTileCacheSize&&t?t._minTileCacheSize:this._minTileCacheSize,this._maxTileCacheSize=void 0===this._maxTileCacheSize&&t?t._maxTileCacheSize:this._maxTileCacheSize}loaded(){if(this._sourceErrored)return!0;if(!this._sourceLoaded)return!1;if(!this._source.loaded())return!1;for(const t in this._tiles){const e=this._tiles[t];if("errored"!==e.state&&("loaded"!==e.state||!e.bucketsLoaded()))return!1}return!0}getSource(){return this._source}pause(){this._paused=!0}resume(){if(!this._paused)return;const t=this._shouldReloadOnResume;this._paused=!1,this._shouldReloadOnResume=!1,t&&this.reload(),this.transform&&this.update(this.transform)}_loadTile(t,e){return t.isSymbolTile=this._onlySymbols,t.isExtraShadowCaster=this._shadowCasterTiles[t.tileID.key],this._source.loadTile(t,e)}_unloadTile(t){if(this._source.unloadTile)return this._source.unloadTile(t)}_abortTile(t){if(this._source.abortTile)return this._source.abortTile(t)}serialize(){return this._source.serialize()}prepare(t){this._source.prepare&&this._source.prepare(),this._state.coalesceChanges(this._tiles,this.map?this.map.painter:null);for(const e in this._tiles){const i=this._tiles[e];i.upload(t),i.prepare(this.map.style.imageManager,this.map?this.map.painter:null,this._source.scope)}}getIds(){return ti(this._tiles).map((t=>t.tileID)).sort(Ky).map((t=>t.key))}getRenderableIds(t,e){const i=[];for(const n in this._tiles)this._isIdRenderable(+n,t,e)&&i.push(this._tiles[n]);return t?i.sort(((t,e)=>{const i=t.tileID,n=e.tileID,r=new Ue(i.canonical.x,i.canonical.y)._rotate(this.transform.angle),o=new Ue(n.canonical.x,n.canonical.y)._rotate(this.transform.angle);return i.overscaledZ-n.overscaledZ||o.y-r.y||o.x-r.x})).map((t=>t.tileID.key)):i.map((t=>t.tileID)).sort(Ky).map((t=>t.key))}hasRenderableParent(t){const e=this.findLoadedParent(t,0);return!!e&&this._isIdRenderable(e.tileID.key)}_isIdRenderable(t,e,i){return this._tiles[t]&&this._tiles[t].hasData()&&!this._coveredTiles[t]&&(e||!this._tiles[t].holdingForFade())&&(i||!this._shadowCasterTiles[t])}reload(){if(this._paused)this._shouldReloadOnResume=!0;else{this._cache.reset();for(const t in this._tiles)"errored"!==this._tiles[t].state&&this._reloadTile(+t,"reloading")}}_reloadTile(t,e){const i=this._tiles[t];i&&("loading"!==i.state&&(i.state=e),this._loadTile(i,this._tileLoaded.bind(this,i,t,e)))}_tileLoaded(t,e,i,n){if(n)if(t.state="errored",404!==n.status)this._source.fire(new $n(n,{tile:t}));else{if(!(t.tileID.key in this._loadedParentTiles))return void this._source.fire(new Pn("data",{dataType:"source",sourceDataType:"error",sourceId:this._source.id}));if("raster-dem"===this._source.type&&this.usedForTerrain&&this.map.painter.terrain){const t=this.map.painter.terrain;this.update(this.transform,t.getScaledDemTileSize(),!0),t.resetTileLookupCache(this.id)}else this.update(this.transform)}else t.timeAdded=ki.now(),"expired"===i&&(t.refreshedUponExpiration=!0),this._setTileReloadTimer(e,t),"raster-dem"===this._source.type&&t.dem&&this._backfillDEM(t),this._state.initializeTileState(t,this.map?this.map.painter:null),this._source.fire(new Pn("data",{dataType:"source",tile:t,coord:t.tileID,sourceCacheId:this.id}))}_backfillDEM(t){const e=this.getRenderableIds();for(let n=0;n1||(Math.abs(i)>1&&(1===Math.abs(i+r)?i+=r:1===Math.abs(i-r)&&(i-=r)),e.dem&&t.dem&&(t.dem.backfillBorder(e.dem,i,n),t.neighboringTiles&&t.neighboringTiles[o]&&(t.neighboringTiles[o].backfilled=!0)))}}getTile(t){return this.getTileByID(t.key)}getTileByID(t){return this._tiles[t]}_retainLoadedChildren(t,e,i,n){for(const r in this._tiles){let o=this._tiles[r];if(n[r]||!o.hasData()||o.tileID.overscaledZi)continue;let s=o.tileID;for(;o&&o.tileID.overscaledZ>e+1;){const t=o.tileID.scaledTo(o.tileID.overscaledZ-1);o=this._tiles[t.key],o&&o.hasData()&&(s=t)}let a=s;for(;a.overscaledZ>e;)if(a=a.scaledTo(a.overscaledZ-1),t[a.key]){n[s.key]=s;break}}}findLoadedParent(t,e){if(t.key in this._loadedParentTiles){const i=this._loadedParentTiles[t.key];return i&&i.tileID.overscaledZ>=e?i:null}for(let i=t.overscaledZ-1;i>=e;i--){const e=t.scaledTo(i),n=this._getLoadedTile(e);if(n)return n}}_getLoadedTile(t){const e=this._tiles[t.key];return e&&e.hasData()?e:this._cache.getByKey(this._source.reparseOverscaled?t.wrapped().key:t.canonical.key)}updateCacheSize(t,e){e=e||this._source.tileSize;const i=Math.ceil(t.width/e)+1,n=Math.ceil(t.height/e)+1,r=Math.floor(i*n*5),o="number"==typeof this._minTileCacheSize?Math.max(this._minTileCacheSize,r):r,s="number"==typeof this._maxTileCacheSize?Math.min(this._maxTileCacheSize,o):o;this._cache.setMaxSize(s)}handleWrapJump(t){const e=Math.round((t-(void 0===this._prevLng?t:this._prevLng))/360);if(this._prevLng=t,e){const t={};for(const i in this._tiles){const n=this._tiles[i];n.tileID=n.tileID.unwrapTo(n.tileID.wrap+e),t[n.tileID.key]=n}this._tiles=t;for(const t in this._timers)clearTimeout(this._timers[t]),delete this._timers[t];for(const t in this._tiles)this._setTileReloadTimer(+t,this._tiles[t])}}update(t,e,i,n){if(this.transform=t,!this._sourceLoaded||this._paused||this.transform.freezeTileCoverage)return;if(this.usedForTerrain&&!i)return;let r;if(this.updateCacheSize(t,e),"globe"!==this.transform.projection.name&&this.handleWrapJump(this.transform.center.lng),this._shadowCasterTiles={},this._coveredTiles={},this.used||this.usedForTerrain){if(this._source.tileID)r=t.getVisibleUnwrappedCoordinates(this._source.tileID).map((t=>new vd(t.canonical.z,t.wrap,t.canonical.z,t.canonical.x,t.canonical.y)));else if(0!==this.tileCoverLift){const n=t.clone();n.tileCoverLift=this.tileCoverLift,r=n.coveringTiles({tileSize:e||this._source.tileSize,minzoom:this._source.minzoom,maxzoom:this._source.maxzoom,roundZoom:this._source.roundZoom&&!i,reparseOverscaled:this._source.reparseOverscaled,isTerrainDEM:this.usedForTerrain}),this._source.minzoomt(e)))}}else r=[];if(r.length>0&&this.castsShadows&&n&&"globe"!==this.transform.projection.name&&!this.usedForTerrain&&!Jy(this._source.type)){const o=t.coveringZoomLevel({tileSize:e||this._source.tileSize,roundZoom:this._source.roundZoom&&!i}),s=Math.min(o,this._source.maxzoom),a=t.extendTileCoverForShadows(r,n,s);for(const t of a)this._shadowCasterTiles[t.key]=!0,r.push(t)}const o=this._updateRetainedTiles(r);if(Jy(this._source.type)&&0!==r.length){const t={},e={},i=Object.keys(o);for(const n of i){const i=o[n],r=this._tiles[n];if(!r||r.fadeEndTime&&r.fadeEndTimen;){r=r.scaledTo(r.overscaledZ-1);const n=this._tiles[r.key];if(n&&n.hasData()&&e[r.key]){o[t]=i.tileID;break}}}for(const e in t)o[e]||(this._coveredTiles[e]=!0,o[e]=t[e])}for(const t in o)this._tiles[t].clearFadeHold();const s=function(t,e){const i=[];for(const n in t)n in e||i.push(n);return i}(this._tiles,o);for(const t of s){const e=this._tiles[t];e.hasSymbolBuckets&&!e.holdingForFade()?e.setHoldDuration(this.map._fadeDuration):e.hasSymbolBuckets&&!e.symbolFadeFinished()||this._removeTile(+t)}this._updateLoadedParentTileCache(),this._onlySymbols&&this._source.afterUpdate&&this._source.afterUpdate()}releaseSymbolFadeTiles(){for(const t in this._tiles)this._tiles[t].holdingForFade()&&this._removeTile(+t)}_updateRetainedTiles(t){const e={};if(0===t.length)return e;const i={},n=t.reduce(((t,e)=>Math.min(t,e.overscaledZ)),1/0),r=t[0].overscaledZ,o=Math.max(r-Xy.maxOverzooming,this._source.minzoom),s=Math.max(r+Xy.maxUnderzooming,this._source.minzoom),a={};for(const i of t){const t=this._addTile(i);e[i.key]=i,t.hasData()||n=this._source.maxzoom){const t=n.children(this._source.maxzoom)[0],i=this.getTile(t);if(i&&i.hasData()){e[t.key]=t;continue}}else{const t=n.children(this._source.maxzoom);if(e[t[0].key]&&e[t[1].key]&&e[t[2].key]&&e[t[3].key])continue}let r=t.wasRequested();for(let s=n.overscaledZ-1;s>=o;--s){const o=n.scaledTo(s);if(i[o.key])break;if(i[o.key]=!0,t=this.getTile(o),!t&&r&&(t=this._addTile(o)),t&&(e[o.key]=o,r=t.wasRequested(),t.hasData()))break}}return e}_updateLoadedParentTileCache(){this._loadedParentTiles={};for(const t in this._tiles){const e=[];let i,n=this._tiles[t].tileID;for(;n.overscaledZ>0;){if(n.key in this._loadedParentTiles){i=this._loadedParentTiles[n.key];break}e.push(n.key);const t=n.scaledTo(n.overscaledZ-1);if(i=this._getLoadedTile(t),i)break;n=t}for(const t of e)this._loadedParentTiles[t]=i}}_addTile(t){let e=this._tiles[t.key];if(e)return!0!==e.isExtraShadowCaster||!!this._shadowCasterTiles[t.key]||this._reloadTile(t.key,"reloading"),e;e=this._cache.getAndRemove(t),e&&(this._setTileReloadTimer(t.key,e),e.tileID=t,this._state.initializeTileState(e,this.map?this.map.painter:null),this._cacheTimers[t.key]&&(clearTimeout(this._cacheTimers[t.key]),delete this._cacheTimers[t.key],this._setTileReloadTimer(t.key,e)));const i=Boolean(e);if(!i){const i=this.map?this.map.painter:null,n=this._source.tileSize*t.overscaleFactor();e="raster-array"===this._source.type?new Wy(t,n,this.transform.tileZoom,i,this._isRaster):new ey(t,n,this.transform.tileZoom,i,this._isRaster),this._loadTile(e,this._tileLoaded.bind(this,e,t.key,e.state))}return e?(e.uses++,this._tiles[t.key]=e,i||this._source.fire(new Pn("dataloading",{tile:e,coord:e.tileID,dataType:"source"})),e):null}_setTileReloadTimer(t,e){t in this._timers&&(clearTimeout(this._timers[t]),delete this._timers[t]);const i=e.getExpiryTimeout();i&&(this._timers[t]=setTimeout((()=>{this._reloadTile(t,"expired"),delete this._timers[t]}),i))}_removeTile(t){const e=this._tiles[t];e&&(e.uses--,delete this._tiles[t],this._timers[t]&&(clearTimeout(this._timers[t]),delete this._timers[t]),e.uses>0||(e.hasData()&&"reloading"!==e.state||"empty"===e.state?this._cache.add(e.tileID,e,e.getExpiryTimeout()):(e.aborted=!0,this._abortTile(e),this._unloadTile(e))))}clearTiles(){this._shouldReloadOnResume=!1,this._paused=!1;for(const t in this._tiles)this._removeTile(+t);this._source._clear&&this._source._clear(),this._cache.reset(),this.map&&this.usedForTerrain&&this.map.painter.terrain&&this.map.painter.terrain.resetTileLookupCache(this.id)}tilesIn(t,e,i){const n=[],r=this.transform;if(!r)return n;const o="globe"===r.projection.name,s=Ed(r.center.lng);for(const a in this._tiles){const l=this._tiles[a];if(i&&l.clearQueryDebugViz(),l.holdingForFade())continue;let c;if(o){const t=l.tileID.canonical;if(0===t.z){const e=[Math.abs(Xe(s,...Qy(t,-1))-s),Math.abs(Xe(s,...Qy(t,1))-s)];c=[0,2*e.indexOf(Math.min(...e))-1]}else{const e=[Math.abs(Xe(s,...Qy(t,-1))-s),Math.abs(Xe(s,...Qy(t,0))-s),Math.abs(Xe(s,...Qy(t,1))-s)];c=[e.indexOf(Math.min(...e))-1]}}else c=[0];for(const i of c){const o=t.containsTile(l,r,e,i);o&&n.push(o)}}return n}getShadowCasterCoordinates(){return this._getRenderableCoordinates(!1,!0)}getVisibleCoordinates(t){return this._getRenderableCoordinates(t)}_getRenderableCoordinates(t,e){const i=this.getRenderableIds(t,e).map((t=>this._tiles[t].tileID)),n="globe"===this.transform.projection.name;for(const t of i)t.projMatrix=this.transform.calculateProjMatrix(t.toUnwrapped()),t.expandedProjMatrix=n?this.transform.calculateProjMatrix(t.toUnwrapped(),!1,!0):t.projMatrix;return i}sortCoordinatesByDistance(t){const e=t.slice(),i=this.transform._camera.position,n=this.transform._camera.forward(),r={};for(const t of e){const e=1/(1r[t.key]-r[e.key])),e}hasTransition(){if(this._source.hasTransition())return!0;if(Jy(this._source.type))for(const t in this._tiles){const e=this._tiles[t];if(void 0!==e.fadeEndTime&&e.fadeEndTime>=ki.now())return!0}return!1}setFeatureState(t,e,i){this._state.updateState(t=t||"_geojsonTileLayer",e,i)}removeFeatureState(t,e,i){this._state.removeFeatureState(t=t||"_geojsonTileLayer",e,i)}getFeatureState(t,e){return this._state.getState(t=t||"_geojsonTileLayer",e)}setDependencies(t,e,i){const n=this._tiles[t];n&&n.setDependencies(e,i)}reloadTilesForDependencies(t,e){for(const i in this._tiles)this._tiles[i].hasDependency(t,e)&&this._reloadTile(+i,"reloading");this._cache.filter((i=>!i.hasDependency(t,e)))}_preloadTiles(t,e){if(!this._sourceLoaded){const i=()=>{this._sourceLoaded&&(this._source.off("data",i),this._preloadTiles(t,e))};return void this._source.on("data",i)}const i=new Map,n=Array.isArray(t)?t:[t],r=this.map.painter.terrain,o=this.usedForTerrain&&r?r.getScaledDemTileSize():this._source.tileSize;for(const t of n){const e=t.coveringTiles({tileSize:o,minzoom:this._source.minzoom,maxzoom:this._source.maxzoom,roundZoom:this._source.roundZoom&&!this.usedForTerrain,reparseOverscaled:this._source.reparseOverscaled,isTerrainDEM:this.usedForTerrain});for(const t of e)i.set(t.key,t);this.usedForTerrain&&t.updateElevation(!1)}Qe(Array.from(i.values()),((t,e)=>{const i=new ey(t,this._source.tileSize*t.overscaleFactor(),this.transform.tileZoom,this.map.painter,this._isRaster);this._loadTile(i,(t=>{"raster-dem"===this._source.type&&i.dem&&this._backfillDEM(i),e(t,i)}))}),e)}}function Ky(t,e){const i=Math.abs(2*t.wrap)-+(t.wrap0?e+2*t:t}tv.useIntegerZoom=!0;const iv=new ol({"symbol-placement":new il(sl.layout_symbol["symbol-placement"]),"symbol-spacing":new il(sl.layout_symbol["symbol-spacing"]),"symbol-avoid-edges":new il(sl.layout_symbol["symbol-avoid-edges"]),"symbol-sort-key":new nl(sl.layout_symbol["symbol-sort-key"]),"symbol-z-order":new il(sl.layout_symbol["symbol-z-order"]),"symbol-z-elevate":new il(sl.layout_symbol["symbol-z-elevate"]),"icon-allow-overlap":new il(sl.layout_symbol["icon-allow-overlap"]),"icon-ignore-placement":new il(sl.layout_symbol["icon-ignore-placement"]),"icon-optional":new il(sl.layout_symbol["icon-optional"]),"icon-rotation-alignment":new il(sl.layout_symbol["icon-rotation-alignment"]),"icon-size":new nl(sl.layout_symbol["icon-size"]),"icon-text-fit":new nl(sl.layout_symbol["icon-text-fit"]),"icon-text-fit-padding":new nl(sl.layout_symbol["icon-text-fit-padding"]),"icon-image":new nl(sl.layout_symbol["icon-image"]),"icon-rotate":new nl(sl.layout_symbol["icon-rotate"]),"icon-padding":new il(sl.layout_symbol["icon-padding"]),"icon-keep-upright":new il(sl.layout_symbol["icon-keep-upright"]),"icon-offset":new nl(sl.layout_symbol["icon-offset"]),"icon-anchor":new nl(sl.layout_symbol["icon-anchor"]),"icon-pitch-alignment":new il(sl.layout_symbol["icon-pitch-alignment"]),"text-pitch-alignment":new il(sl.layout_symbol["text-pitch-alignment"]),"text-rotation-alignment":new il(sl.layout_symbol["text-rotation-alignment"]),"text-field":new nl(sl.layout_symbol["text-field"]),"text-font":new nl(sl.layout_symbol["text-font"]),"text-size":new nl(sl.layout_symbol["text-size"]),"text-max-width":new nl(sl.layout_symbol["text-max-width"]),"text-line-height":new nl(sl.layout_symbol["text-line-height"]),"text-letter-spacing":new nl(sl.layout_symbol["text-letter-spacing"]),"text-justify":new nl(sl.layout_symbol["text-justify"]),"text-radial-offset":new nl(sl.layout_symbol["text-radial-offset"]),"text-variable-anchor":new il(sl.layout_symbol["text-variable-anchor"]),"text-anchor":new nl(sl.layout_symbol["text-anchor"]),"text-max-angle":new il(sl.layout_symbol["text-max-angle"]),"text-writing-mode":new il(sl.layout_symbol["text-writing-mode"]),"text-rotate":new nl(sl.layout_symbol["text-rotate"]),"text-padding":new il(sl.layout_symbol["text-padding"]),"text-keep-upright":new il(sl.layout_symbol["text-keep-upright"]),"text-transform":new nl(sl.layout_symbol["text-transform"]),"text-offset":new nl(sl.layout_symbol["text-offset"]),"text-allow-overlap":new il(sl.layout_symbol["text-allow-overlap"]),"text-ignore-placement":new il(sl.layout_symbol["text-ignore-placement"]),"text-optional":new il(sl.layout_symbol["text-optional"]),visibility:new il(sl.layout_symbol.visibility)});var nv={paint:new ol({"icon-opacity":new nl(sl.paint_symbol["icon-opacity"]),"icon-occlusion-opacity":new nl(sl.paint_symbol["icon-occlusion-opacity"]),"icon-emissive-strength":new nl(sl.paint_symbol["icon-emissive-strength"]),"text-emissive-strength":new nl(sl.paint_symbol["text-emissive-strength"]),"icon-color":new nl(sl.paint_symbol["icon-color"]),"icon-halo-color":new nl(sl.paint_symbol["icon-halo-color"]),"icon-halo-width":new nl(sl.paint_symbol["icon-halo-width"]),"icon-halo-blur":new nl(sl.paint_symbol["icon-halo-blur"]),"icon-translate":new il(sl.paint_symbol["icon-translate"]),"icon-translate-anchor":new il(sl.paint_symbol["icon-translate-anchor"]),"icon-image-cross-fade":new nl(sl.paint_symbol["icon-image-cross-fade"]),"text-opacity":new nl(sl.paint_symbol["text-opacity"]),"text-occlusion-opacity":new nl(sl.paint_symbol["text-occlusion-opacity"]),"text-color":new nl(sl.paint_symbol["text-color"],{runtimeType:Qn,getOverride:t=>t.textColor,hasOverride:t=>!!t.textColor}),"text-halo-color":new nl(sl.paint_symbol["text-halo-color"]),"text-halo-width":new nl(sl.paint_symbol["text-halo-width"]),"text-halo-blur":new nl(sl.paint_symbol["text-halo-blur"]),"text-translate":new il(sl.paint_symbol["text-translate"]),"text-translate-anchor":new il(sl.paint_symbol["text-translate-anchor"]),"icon-color-saturation":new il(sl.paint_symbol["icon-color-saturation"]),"icon-color-contrast":new il(sl.paint_symbol["icon-color-contrast"]),"icon-color-brightness-min":new il(sl.paint_symbol["icon-color-brightness-min"]),"icon-color-brightness-max":new il(sl.paint_symbol["icon-color-brightness-max"])}),layout:iv};class rv{constructor(t){this.type=t.property.overrides?t.property.overrides.runtimeType:Yn,this.defaultValue=t}evaluate(t){if(t.formattedSection){const e=this.defaultValue.property.overrides;if(e&&e.hasOverride(t.formattedSection))return e.getOverride(t.formattedSection)}return t.feature&&t.featureState?this.defaultValue.evaluate(t.feature,t.featureState):this.defaultValue.property.specification.default}eachChild(t){this.defaultValue.isConstant()||t(this.defaultValue.value._styleExpression.expression)}outputDefined(){return!1}serialize(){return null}}ba(rv,"FormatSectionOverride",{omit:["defaultValue"]});class ov extends Ml{constructor(e,i,n,r){super(e,nv,i,n,r),this._colorAdjustmentMatrix=t.ad.identity([]),this.hasInitialOcclusionOpacityProperties=void 0!==e.paint&&("icon-occlusion-opacity"in e.paint||"text-occlusion-opacity"in e.paint)}recalculate(t,e){super.recalculate(t,e),"auto"===this.layout.get("icon-rotation-alignment")&&(this.layout._values["icon-rotation-alignment"]="point"!==this.layout.get("symbol-placement")?"map":"viewport"),"auto"===this.layout.get("text-rotation-alignment")&&(this.layout._values["text-rotation-alignment"]="point"!==this.layout.get("symbol-placement")?"map":"viewport"),"auto"===this.layout.get("text-pitch-alignment")&&(this.layout._values["text-pitch-alignment"]=this.layout.get("text-rotation-alignment")),"auto"===this.layout.get("icon-pitch-alignment")&&(this.layout._values["icon-pitch-alignment"]=this.layout.get("icon-rotation-alignment"));const i=this.layout.get("text-writing-mode");if(i){const t=[];for(const e of i)t.indexOf(e)i in t?String(t[i]):""))}(e.properties,r)}createBucket(t){return new jg(t)}queryRadius(){return 0}queryIntersectsFeature(){return!1}_setPaintOverrides(){for(const t of nv.paint.overridableProperties){if(!ov.hasPaintOverride(this.layout,t))continue;const e=this.paint.get(t),i=new rv(e),n=new la(i,e.property.specification,this.scope,this.options);let r=null;r="constant"===e.value.kind||"source"===e.value.kind?new ua("source",n):new ha("composite",n,e.value.zoomStops,e.value._interpolationType),this.paint._values[t]=new tl(e.property,r,e.parameters)}}_handleOverridablePaintPropertyUpdate(t,e,i){return!(!this.layout||e.isDataDriven()||i.isDataDriven())&&ov.hasPaintOverride(this.layout,t)}static hasPaintOverride(t,e){const i=t.get("text-field"),n=nv.paint.properties[e];let r=!1;const o=t=>{for(const e of t)if(n.overrides&&n.overrides.hasOverride(e))return void(r=!0)};if("constant"===i.value.kind&&i.value.value instanceof pr)o(i.value.value.sections);else if("source"===i.value.kind){const t=e=>{r||(e instanceof vr&&gr(e.value)===nr?o(e.value.sections):e instanceof Tr?o(e.sections):e.eachChild(t))},e=i.value;e._styleExpression&&t(e._styleExpression.expression)}return r}getProgramIds(){const t=0!==this.paint.get("icon-opacity").constantOr(1),e=0!==this.paint.get("text-opacity").constantOr(1),i=[];return t&&i.push("symbolIcon"),e&&i.push("symbolSDF"),i}getDefaultProgramParams(t,e,i){return{config:new Wc(this,{zoom:e,lut:i}),overrideFog:!1}}}const sv=new ol({visibility:new il(sl.layout_background.visibility)});var av={paint:new ol({"background-color":new il(sl.paint_background["background-color"]),"background-pattern":new il(sl.paint_background["background-pattern"]),"background-opacity":new il(sl.paint_background["background-opacity"]),"background-emissive-strength":new il(sl.paint_background["background-emissive-strength"])}),layout:sv};const lv=new ol({visibility:new il(sl.layout_raster.visibility)});var cv={paint:new ol({"raster-opacity":new il(sl.paint_raster["raster-opacity"]),"raster-color":new rl(sl.paint_raster["raster-color"]),"raster-color-mix":new il(sl.paint_raster["raster-color-mix"]),"raster-color-range":new il(sl.paint_raster["raster-color-range"]),"raster-hue-rotate":new il(sl.paint_raster["raster-hue-rotate"]),"raster-brightness-min":new il(sl.paint_raster["raster-brightness-min"]),"raster-brightness-max":new il(sl.paint_raster["raster-brightness-max"]),"raster-saturation":new il(sl.paint_raster["raster-saturation"]),"raster-contrast":new il(sl.paint_raster["raster-contrast"]),"raster-resampling":new il(sl.paint_raster["raster-resampling"]),"raster-fade-duration":new il(sl.paint_raster["raster-fade-duration"]),"raster-emissive-strength":new il(sl.paint_raster["raster-emissive-strength"]),"raster-array-band":new il(sl.paint_raster["raster-array-band"]),"raster-elevation":new il(sl.paint_raster["raster-elevation"])}),layout:lv};function dv(e,i,n,r,o,s,a,l){const c=[e,i,1,n,r,1,o,s,1],d=[a,l,1],u=t.bC.adjoint([],c),[h,p,f]=t._.transformMat3(d,d,u);return t.bC.multiply(c,c,[h,0,0,0,p,0,0,0,f])}function uv(e,i,n,r,o,s,a,l){const c=function(e,i,n,r,o,s,a,l){const c=dv(0,0,1,0,1,1,0,1),d=dv(e,i,n,r,o,s,a,l),u=t.bC.adjoint([],c);return t.bC.multiply(d,d,u)}(e,i,n,r,o,s,a,l);return[c[2]/c[8]/uo,c[5]/c[8]/uo]}function hv(t){return[t[0],Math.min(Math.max(t[1],-Pd),Pd)]}class pv extends zn{constructor(t,e,i,n){super(),this.id=t,this.dispatcher=i,this.coordinates=e.coordinates,this.type="image",this.minzoom=0,this.maxzoom=22,this.tileSize=512,this.tiles={},this._loaded=!1,this.onNorthPole=!1,this.onSouthPole=!1,this.setEventedParent(n),this.options=e,this._dirty=!1}load(t,e){if(this._loaded=e||!1,this.fire(new Pn("dataloading",{dataType:"source"})),this.url=this.options.url,!this.url)return t&&(this.coordinates=t),this._loaded=!0,void this._finishLoading();this._imageRequest=an(this.map._requestManager.transformRequest(this.url,Ki.Image),((e,i)=>{this._imageRequest=null,this._loaded=!0,e?this.fire(new $n(e)):i&&(this.image=i instanceof HTMLImageElement?ki.getImageData(i):i,this._dirty=!0,this.width=this.image.width,this.height=this.image.height,t&&(this.coordinates=t),this._finishLoading())}))}loaded(){return this._loaded}updateImage(t){return t.url?(this._imageRequest&&t.url!==this.options.url&&(this._imageRequest.cancel(),this._imageRequest=null),this.options.url=t.url,this.load(t.coordinates,this._loaded),this):this}setTexture(t){if(!(t.handle instanceof WebGLTexture))throw new Error("The provided handle is not a WebGLTexture instance");return this.texture=new Gg(this.map.painter.context,t.handle),this.width=t.dimensions[0],this.height=t.dimensions[1],this._dirty=!1,this._loaded=!0,this._finishLoading(),this}_finishLoading(){this.map&&(this.setCoordinates(this.coordinates),this.fire(new Pn("data",{dataType:"source",sourceDataType:"metadata"})))}onAdd(t){this.map=t,this.load()}onRemove(t){this._imageRequest&&(this._imageRequest.cancel(),this._imageRequest=null),!this.texture||this.texture instanceof Gg||this.texture.destroy(),this.boundsBuffer&&(this.boundsBuffer.destroy(),this.elevatedGlobeVertexBuffer&&this.elevatedGlobeVertexBuffer.destroy(),this.elevatedGlobeIndexBuffer&&this.elevatedGlobeIndexBuffer.destroy())}setCoordinates(t){if(this.coordinates=t,this._boundsArray=void 0,this._unsupportedCoords=!1,!t.length)return this;this.onNorthPole=!1,this.onSouthPole=!1;let e=t[0][1],i=t[0][1];for(const n of t)n[1]>i&&(i=n[1]),n[1]Pd?this.onNorthPole=!0:n1&&(l-=1),new gd(s,l,Math.floor((i+r)/2*a))}(e),this.minzoom=this.maxzoom=this.tileID.z}return this.fire(new Pn("data",{dataType:"source",sourceDataType:"content"})),this}_clear(){this._boundsArray=void 0,this._unsupportedCoords=!1}_prepareData(e){for(const t in this.tiles){const e=this.tiles[t];"loaded"!==e.state&&(e.state="loaded",e.texture=this.texture)}if(this._boundsArray||this.onNorthPole||this.onSouthPole||this._unsupportedCoords)return;const i=eg(new gd(0,0,0),this.map.transform.projection),n=[i.projection.project(this.coordinates[0][0],this.coordinates[0][1]),i.projection.project(this.coordinates[1][0],this.coordinates[1][1]),i.projection.project(this.coordinates[2][0],this.coordinates[2][1]),i.projection.project(this.coordinates[3][0],this.coordinates[3][1])];if(!function(t){const e=t[1].x-t[0].x,i=t[1].y-t[0].y,n=t[2].x-t[1].x,r=t[2].y-t[1].y,o=t[3].x-t[2].x,s=t[3].y-t[2].y,a=t[0].x-t[3].x,l=t[0].y-t[3].y,c=e*r-n*i,d=n*s-o*r,u=o*l-a*s,h=a*i-e*l;return c>0&&d>0&&u>0&&h>0||c{const e=r.projection.project(t[0],t[1]);return ig(r,e)._round()}));this.perspectiveTransform=uv(o.x,o.y,s.x,s.y,a.x,a.y,l.x,l.y);const c=this._boundsArray=new Dl;c.emplaceBack(o.x,o.y,0,0),c.emplaceBack(s.x,s.y,uo,0),c.emplaceBack(l.x,l.y,0,uo),c.emplaceBack(a.x,a.y,uo,uo),this.boundsBuffer&&(this.boundsBuffer.destroy(),this.elevatedGlobeVertexBuffer&&this.elevatedGlobeVertexBuffer.destroy(),this.elevatedGlobeIndexBuffer&&this.elevatedGlobeIndexBuffer.destroy()),this.boundsBuffer=e.createVertexBuffer(c,Jg.members),this.boundsSegments=wc.simpleSegment(0,0,4,2);const d=[],u=function(t){return[hv(t[0]),hv(t[1]),hv(t[2]),hv(t[3])]}(this.coordinates),[h,p,f,m]=function(t){let e=t[0][0],i=e,n=t[0][1],r=n;for(let o=1;oi&&(i=t[o][0]),t[o][1]r&&(r=t[o][1]);return[e,n,i-e,r-n]}(u);{const r=new Dl,[o,s,a,l]=function(t){let e=t[0].x,i=e,n=t[0].y,r=n;for(let o=1;oi&&(i=t[o].x),t[o].yr&&(r=t[o].y);return[e,n,i-e,r-n]}(n),c=t=>[(t.x-o)/a,(t.y-s)/l],[u,_,g,y]=n.map(c),v=function(e,i,n,r,o,s,a,l){const c=dv(0,0,1,0,1,1,0,1),d=dv(e,i,n,r,o,s,a,l),u=t.bC.adjoint([],d);return t.bC.multiply(c,c,u)}(u[0],u[1],_[0],_[1],g[0],g[1],y[0],y[1]);this.elevatedGlobePerspectiveTransform=uv(u[0],u[1],_[0],_[1],g[0],g[1],y[0],y[1]);const x=(e,i)=>{d.push(e.lng);const n=Math.round((e.lng-h)/f*uo),o=Math.round((e.lat-p)/m*uo),s=c(i),a=t._.transformMat3([],[s[0],s[1],1],v),l=Math.round(a[0]/a[2]*uo),u=Math.round(a[1]/a[2]*uo);r.emplaceBack(n,o,l,u)},b=n[3].x-n[0].x,w=n[3].y-n[0].y,T=n[2].x-n[1].x,S=n[2].y-n[1].y;for(let t=0;t{i.emplaceBack(e,n,r);const o=d[e],s=d[n],a=d[r],l=Math.min(Math.min(o,s),a),c=Math.max(Math.max(o,s),a)-l;c>this.maxLongitudeTriangleSize&&(this.maxLongitudeTriangleSize=c),t.push(l+c/2)};for(let t=0;te));i.sort(((e,i)=>t[e]-t[i]));const n=[],r=new Kl;for(let o=0;o{o.segments.push({vertexOffset:0,primitiveOffset:t,vertexLength:e.segments[0].vertexLength,primitiveLength:i,sortKey:void 0,vaos:{}})},a=.51*this.maxLongitudeTriangleSize;if(Math.abs(i[0]-n)0){const n=function(e,i){const n=i.worldSize,r=Cd(1,0)*n*kd(i.center.lat,i.zoom)/Gu(n),o=Cd(1,i.center.lat)*n,s=t.ad.identity([]);return t.ad.rotateY(s,s,Ge(i.center.lng)),t.ad.rotateX(s,s,Ge(i.center.lat)),t.ad.translate(s,s,[0,0,ed]),t.ad.scale(s,s,[r,r,r*o]),t.ad.translate(s,s,[i.point.x-.5*n,i.point.y-.5*n,0]),t.ad.multiply(s,s,e),t.ad.multiply(s,i.globeMatrix,s)}(e,i);return function(e,i,n){const r=(e,i,n)=>{const r=t._.length(e),o=t._.length(i),s=ku(e,i,n);return t._.scale(s,s,1/t._.length(s)*Vn(r,o,n))},o=r([e[0],e[1],e[2]],[i[0],i[1],i[2]],n),s=r([e[4],e[5],e[6]],[i[4],i[5],i[6]],n),a=r([e[8],e[9],e[10]],[i[8],i[9],i[10]],n),l=ku([e[12],e[13],e[14]],[i[12],i[13],i[14]],n);return[o[0],o[1],o[2],0,s[0],s[1],s[2],0,a[0],a[1],a[2],0,l[0],l[1],l[2],1]}(o,n,r)}return o}function kv(t,e,i,n){const r=wu.projectAabbCorners(n,i);let o=Number.MAX_VALUE,s=-1;for(let t=0;tnew Ue(r[t][0],r[t][1]);let l;switch(s){case 0:case 6:l=[a(1),a(5),a(4),a(7),a(3),a(2),a(1)];break;case 1:case 7:l=[a(0),a(4),a(5),a(6),a(2),a(3),a(0)];break;case 3:case 5:l=[a(1),a(0),a(4),a(7),a(6),a(2),a(1)];break;default:l=[a(1),a(5),a(6),a(7),a(3),a(0),a(1)]}if(Yd(t,l))return o}const Dv=Ll([{name:"a_pos_3f",components:3,type:"Float32"}]),zv=Ll([{name:"a_color_3f",components:3,type:"Float32"}]),Rv=Ll([{name:"a_color_4f",components:4,type:"Float32"}]),Ov=Ll([{name:"a_uv_2f",components:2,type:"Float32"}]),Bv=Ll([{name:"a_normal_3f",components:3,type:"Float32"}]),Fv=Ll([{name:"a_normal_matrix0",components:4,type:"Float32"},{name:"a_normal_matrix1",components:4,type:"Float32"},{name:"a_normal_matrix2",components:4,type:"Float32"},{name:"a_normal_matrix3",components:4,type:"Float32"}]),Nv=Ll([{name:"a_pbr",components:4,type:"Uint16"},{name:"a_heightBasedEmissiveStrength",components:3,type:"Float32"}]);class Uv{constructor(t,e,i,n){this.message=(t?`${t}: `:"")+i,n&&(this.identifier=n),null!=e&&e.__line__&&(this.line=e.__line__)}}function jv(t,e){const i=-1===t.indexOf("://");try{return new URL(t,i&&e?"http://example.com":void 0),!0}catch(t){return!1}}class Vv{constructor(t,e){this.feature=t,this.instancedDataOffset=e,this.instancedDataCount=0,this.rotation=[0,0,0],this.scale=[1,1,1],this.translation=[0,0,0]}}class Gv{constructor(){this.instancedDataArray=new oc,this.instancesEvaluatedElevation=[],this.features=[],this.idToFeaturesIndex={}}}class Zv{constructor(t){this.zoom=t.zoom,this.canonical=t.canonical,this.layers=t.layers,this.layerIds=this.layers.map((t=>t.fqid)),this.projection=t.projection,this.index=t.index,this.hasZoomDependentProperties=this.layers[0].isZoomDependent(),this.stateDependentLayerIds=this.layers.filter((t=>t.isStateDependent())).map((t=>t.id)),this.hasPattern=!1,this.instancesPerModel={},this.validForExaggeration=0,this.maxVerticalOffset=0,this.maxScale=0,this.maxHeight=0,this.lookupDim=this.zoom>this.canonical.z?256:this.zoom>15?75:100,this.instanceCount=0,this.terrainElevationMin=0,this.terrainElevationMax=0,this.validForDEMTile={id:null,timestamp:0},this.modelUris=[],this.modelsRequested=!1,this.activeReplacements=[],this.replacementUpdateTime=0}updateFootprints(t,e){}populate(t,e,i,n){this.tileToMeter=zd(i);const r=this.layers[0]._featureFilter.needGeometry;this.lookup=new Uint8Array(this.lookupDim*this.lookupDim);for(const{feature:o,id:s,index:a,sourceLayerIndex:l}of t){const t=null!=s?s:o.properties&&o.properties.hasOwnProperty("id")?o.properties.id:void 0,c=Zd(o,r);if(!this.layers[0]._featureFilter.filter(new Ha(this.zoom),c,i))continue;const d={id:t,sourceLayerIndex:l,index:a,geometry:r?c.geometry:Gd(o,i,n),properties:o.properties,type:o.type,patterns:{}},u=this.addFeature(d,d.geometry,c);u&&e.featureIndex.insert(o,d.geometry,a,l,this.index,this.instancesPerModel[u].instancedDataArray.length,uo/32)}this.lookup=null}update(t,e,i,n){for(const e in this.instancesPerModel){const i=this.instancesPerModel[e];for(const e in t)i.idToFeaturesIndex.hasOwnProperty(e)&&(this.evaluate(i.features[i.idToFeaturesIndex[e]],t[e],i,!0),this.uploaded=!1)}this.maxHeight=0}updateZoomBasedPaintProperties(){if(!this.hasZoomDependentProperties)return!1;let e=!1;for(const i in this.instancesPerModel){const n=this.instancesPerModel[i];for(const i of n.features){const r=this.layers[0],o=i.feature,s=this.canonical,a=r.paint.get("model-rotation").evaluate(o,{},s),l=r.paint.get("model-scale").evaluate(o,{},s),c=r.paint.get("model-translation").evaluate(o,{},s);t._.exactEquals(i.rotation,a)&&t._.exactEquals(i.scale,l)&&t._.exactEquals(i.translation,c)||(this.evaluate(i,i.featureStates,n,!0),e=!0)}}return e}updateReplacement(t,e,i){if(e.updateTime===this.replacementUpdateTime)return!1;this.replacementUpdateTime=e.updateTime;const n=e.getReplacementRegionsForTile(t.toUnwrapped(),!0);if(Pp(this.activeReplacements,n))return!1;this.activeReplacements=n;let r=!1;for(const e in this.instancesPerModel){const n=this.instancesPerModel[e],o=n.instancedDataArray;for(const e of n.features){const n=e.instancedDataOffset,s=e.instancedDataCount;for(let e=0;euo?a-uo:a;const l=Math.floor(a),c=o.float32[s+1];let d=!1;for(const e of this.activeReplacements)if(!(e.orderl||l>e.max.x||e.min.y>c||c>e.max.y)&&(d=Op(Rp(l,c,t.canonical,e.footprintTileId.canonical),e),d))break;o.float32[s]=d?a+uo:a,r=r||d}}}return r}isEmpty(){for(const t in this.instancesPerModel)if(0!==this.instancesPerModel[t].instancedDataArray.length)return!1;return!0}uploadPending(){return!this.uploaded}upload(t){if(!this.uploaded)for(const e in this.instancesPerModel){const i=this.instancesPerModel[e];i.instancedDataArray.length=uo||e.y=uo)continue;const t=(this.lookupDim-1)/uo,i=this.lookupDim*(e.y*t|0)+e.x*t|0;if(this.lookup){if(0!==this.lookup[i])continue;this.lookup[i]=1}this.instanceCount++;const n=s.length;s.resize(n+1),o.instancesEvaluatedElevation.push(0),s.float32[16*n]=e.x,s.float32[16*n+1]=e.y}return a.instancedDataCount=o.instancedDataArray.length-a.instancedDataOffset,a.instancedDataCount>0&&(t.id&&(o.idToFeaturesIndex[t.id]=o.features.length),o.features.push(a),this.evaluate(a,{},o,!1)),r}getModelUris(){return this.modelUris}evaluate(t,e,i,n){const r=this.layers[0],o=t.feature,s=this.canonical,a=t.rotation=r.paint.get("model-rotation").evaluate(o,e,s),l=t.scale=r.paint.get("model-scale").evaluate(o,e,s),c=t.translation=r.paint.get("model-translation").evaluate(o,e,s),d=r.paint.get("model-color").evaluate(o,e,s);d.a=r.paint.get("model-color-mix-intensity").evaluate(o,e,s);const u=[];this.maxVerticalOffset10?this.tileToMeter:zd(s,p)),a[o+4]=c[0],a[o+5]=c[1],a[o+6]=c[2]+l,a[o+7]=u[0],a[o+8]=u[1],a[o+9]=u[2],a[o+10]=u[4],a[o+11]=u[5],a[o+12]=u[6],a[o+13]=u[8],a[o+14]=u[9],a[o+15]=u[10],i.instancesEvaluatedElevation[r]=c[2]}}}ba(Zv,"ModelBucket",{omit:["layers"]}),ba(Gv,"PerModelAttributes"),ba(Vv,"ModelFeature");const qv=new ol({visibility:new il(sl.layout_model.visibility),"model-id":new nl(sl.layout_model["model-id"])});var Hv={paint:new ol({"model-opacity":new il(sl.paint_model["model-opacity"]),"model-rotation":new nl(sl.paint_model["model-rotation"]),"model-scale":new nl(sl.paint_model["model-scale"]),"model-translation":new nl(sl.paint_model["model-translation"]),"model-color":new nl(sl.paint_model["model-color"]),"model-color-mix-intensity":new nl(sl.paint_model["model-color-mix-intensity"]),"model-type":new il(sl.paint_model["model-type"]),"model-cast-shadows":new il(sl.paint_model["model-cast-shadows"]),"model-receive-shadows":new il(sl.paint_model["model-receive-shadows"]),"model-ambient-occlusion-intensity":new il(sl.paint_model["model-ambient-occlusion-intensity"]),"model-emissive-strength":new nl(sl.paint_model["model-emissive-strength"]),"model-roughness":new nl(sl.paint_model["model-roughness"]),"model-height-based-emissive-strength-multiplier":new nl(sl.paint_model["model-height-based-emissive-strength-multiplier"]),"model-cutoff-fade-range":new il(sl.paint_model["model-cutoff-fade-range"]),"model-front-cutoff":new il(sl.paint_model["model-front-cutoff"])}),layout:qv};const Wv=64,Yv={CoordinateSpaceTile:1,CoordinateSpaceYUp:2,HasMapboxMeshFeatures:4,HasMeshoptCompression:8};function Xv(e,i,n,r,o,s,a,l,c,d=!1){const u=n.zoom,h=n.project(r),p=kd(r.lat,u),f=1/p;t.ad.identity(e),t.ad.translate(e,e,[h.x+a[0]*f,h.y+a[1]*f,a[2]]);let m=1,_=1;const g=n.worldSize;if(d){if("mercator"===n.projection.name){let e=0;n.elevation&&(e=n.elevation.getAtPointOrZero(new Rd(h.x/g,h.y/g),0));const i=t.aA.transformMat4([],[h.x,h.y,e,1],n.projMatrix)[3]/n.cameraToCenterDistance;m=i,_=i*kd(n.center.lat,u)}else if("globe"===n.projection.name){const i=$v(e,n),o=t.ad.multiply([],n.projMatrix,i),s=[0,0,0,1];t.aA.transformMat4(s,s,o);const a=s[3]/n.cameraToCenterDistance,l=Hu(u),c=n.projection.pixelsPerMeter(r.lat,g)*kd(r.lat,u),d=n.projection.pixelsPerMeter(n.center.lat,g)*kd(n.center.lat,u);m=a/Vn(c,$d(n.center.lat),l),_=a*p/c,m*=d,_*=d}}else m=f;t.ad.scale(e,e,[m,m,_]);const y=[...e],v=i.orientation,x=[];if(Lv(x,[v[0]+o[0],v[1]+o[1],v[2]+o[2]],s),t.ad.multiply(e,y,x),l&&n.elevation){let o=0;const s=[];if(c&&n.elevation){o=function(e,i,n,r,o){const s=i.elevation;if(!s)return 0;const a=wu.projectAabbCorners(n,r),l=Cd(1,o.lat)*i.worldSize,c=function(e,i){const n=[0,0,1],r=[{corners:[0,1,3,2],dotProductWithUp:0},{corners:[1,5,2,6],dotProductWithUp:0},{corners:[0,4,1,5],dotProductWithUp:0},{corners:[2,6,3,7],dotProductWithUp:0},{corners:[4,7,5,6],dotProductWithUp:0},{corners:[0,3,4,7],dotProductWithUp:0}];for(const o of r){const r=e[o.corners[0]],s=e[o.corners[1]],a=e[o.corners[2]],l=[s[0]-r[0],s[1]-r[1],i*(s[2]-r[2])],c=t._.cross(l,l,[a[0]-r[0],a[1]-r[1],i*(a[2]-r[2])]);t._.normalize(c,c),o.dotProductWithUp=t._.dot(c,n)}return r.sort(((t,e)=>t.dotProductWithUp-e.dotProductWithUp)),r[0].corners}(a,l),d=a[c[0]],u=a[c[1]],h=a[c[2]],p=a[c[3]],f=s.getAtPointOrZero(new Rd(d[0]/i.worldSize,d[1]/i.worldSize),0),m=s.getAtPointOrZero(new Rd(u[0]/i.worldSize,u[1]/i.worldSize),0),_=s.getAtPointOrZero(new Rd(h[0]/i.worldSize,h[1]/i.worldSize),0),g=s.getAtPointOrZero(new Rd(p[0]/i.worldSize,p[1]/i.worldSize),0),y=(f+g)/2,v=(m+_)/2;return y>v?m=e.gl.NEAREST_MIPMAP_NEAREST}),t.uploaded=!0,t.image=null)}function Jv(t,e,i){t.indexBuffer=e.createIndexBuffer(t.indexArray,!1,!0),t.vertexBuffer=e.createVertexBuffer(t.vertexArray,Dv.members,!1,!0),t.normalArray&&(t.normalBuffer=e.createVertexBuffer(t.normalArray,Bv.members,!1,!0)),t.texcoordArray&&(t.texcoordBuffer=e.createVertexBuffer(t.texcoordArray,Ov.members,!1,!0)),t.colorArray&&(t.colorBuffer=e.createVertexBuffer(t.colorArray,(12===t.colorArray.bytesPerElement?zv:Rv).members,!1,!0)),t.featureArray&&(t.pbrBuffer=e.createVertexBuffer(t.featureArray,Nv.members,!0)),t.segments=wc.simpleSegment(0,0,t.vertexArray.length,t.indexArray.length);const n=t.material;n.pbrMetallicRoughness.baseColorTexture&&Kv(n.pbrMetallicRoughness.baseColorTexture,e),n.pbrMetallicRoughness.metallicRoughnessTexture&&Kv(n.pbrMetallicRoughness.metallicRoughnessTexture,e),n.normalTexture&&Kv(n.normalTexture,e),n.occlusionTexture&&Kv(n.occlusionTexture,e,i),n.emissionTexture&&Kv(n.emissionTexture,e)}function Qv(t,e,i){if(t.meshes)for(const n of t.meshes)Jv(n,e,i);if(t.children)for(const n of t.children)Qv(n,e,i)}function tx(t){if(t.meshes)for(const e of t.meshes)e.indexArray.destroy(),e.vertexArray.destroy(),e.colorArray&&e.colorArray.destroy(),e.normalArray&&e.normalArray.destroy(),e.texcoordArray&&e.texcoordArray.destroy(),e.featureArray&&e.featureArray.destroy();if(t.children)for(const e of t.children)tx(e)}function ex(t){if(t.meshes)for(const i of t.meshes)i.vertexBuffer&&(i.vertexBuffer.destroy(),i.indexBuffer.destroy(),i.normalBuffer&&i.normalBuffer.destroy(),i.texcoordBuffer&&i.texcoordBuffer.destroy(),i.colorBuffer&&i.colorBuffer.destroy(),i.pbrBuffer&&i.pbrBuffer.destroy(),i.segments.destroy(),i.material&&((e=i.material).pbrMetallicRoughness.baseColorTexture&&e.pbrMetallicRoughness.baseColorTexture.gfxTexture&&e.pbrMetallicRoughness.baseColorTexture.gfxTexture.destroy(),e.pbrMetallicRoughness.metallicRoughnessTexture&&e.pbrMetallicRoughness.metallicRoughnessTexture.gfxTexture&&e.pbrMetallicRoughness.metallicRoughnessTexture.gfxTexture.destroy(),e.normalTexture&&e.normalTexture.gfxTexture&&e.normalTexture.gfxTexture.destroy(),e.emissionTexture&&e.emissionTexture.gfxTexture&&e.emissionTexture.gfxTexture.destroy(),e.occlusionTexture&&e.occlusionTexture.gfxTexture&&e.occlusionTexture.gfxTexture.destroy()));var e;if(t.children)for(const e of t.children)ex(e)}class ix{constructor(t){this._callback=t,this._triggered=!1,"undefined"!=typeof MessageChannel&&(this._channel=new MessageChannel,this._channel.port2.onmessage=()=>{this._triggered=!1,this._callback()})}trigger(){this._triggered||(this._triggered=!0,this._channel?this._channel.port1.postMessage(!0):setTimeout((()=>{this._triggered=!1,this._callback()}),0))}remove(){this._channel=void 0,this._callback=()=>{}}}class nx{constructor(){this.tasks={},this.taskQueue=[],ai(["process"],this),this.invoker=new ix(this.process),this.nextId=0}add(t,e){const i=this.nextId++,n=function({type:t,isSymbolTile:e,zoom:i}){return i=i||0,"message"===t?0:"maybePrepare"!==t||e?"parseTile"!==t||e?"parseTile"===t&&e?300-i:"maybePrepare"===t&&e?400-i:500:200-i:100-i}(e);if(0===n){try{t()}finally{}return null}return this.tasks[i]={fn:t,metadata:e,priority:n,id:i},this.taskQueue.push(i),this.invoker.trigger(),{cancel:()=>{delete this.tasks[i]}}}process(){try{if(this.taskQueue=this.taskQueue.filter((t=>!!this.tasks[t])),!this.taskQueue.length)return;const t=this.pick();if(null===t)return;const e=this.tasks[t];if(delete this.tasks[t],this.taskQueue.length&&this.invoker.trigger(),!e)return;e.fn()}finally{}}pick(){let t=null,e=1/0;for(let i=0;i{i&&delete this.callbacks[s],this.target.postMessage({id:s,type:"",targetMapId:n,sourceMapId:this.mapId})}}}receive(t){const e=t.data,i=e.id;if(i&&(!e.targetMapId||this.mapId===e.targetMapId))if(""===e.type){const t=this.cancelCallbacks[i];delete this.cancelCallbacks[i],t&&t.cancel()}else if(e.mustQueue||gi()){const t=this.callbacks[i],n=this.scheduler.add((()=>this.processTask(i,e)),t&&t.metadata||{type:"message"});n&&(this.cancelCallbacks[i]=n)}else this.processTask(i,e)}processTask(t,e){if(delete this.cancelCallbacks[t],""===e.type){const i=this.callbacks[t];delete this.callbacks[t],i&&(e.error?i(Ea(e.error)):i(null,Ea(e.data)))}else{const i=new Set,n=e.hasCallback?(e,n)=>{this.target.postMessage({id:t,type:"",sourceMapId:this.mapId,error:e?Sa(e):null,data:Sa(n,i)},i)}:t=>{},r=Ea(e.data);if(this.parent[e.type])this.parent[e.type](e.sourceMapId,r,n);else if(this.parent.getWorkerSource){const t=e.type.split(".");this.parent.getWorkerSource(e.sourceMapId,t[0],r.source,r.scope)[t[1]](r,n)}else n(new Error(`Could not find function ${e.type}`))}}remove(){this.scheduler.remove(),this.target.removeEventListener("message",this.receive,!1)}}class ox{constructor(t,e){this.workerPool=t,this.actors=[],this.currentActor=0,this.id=ni();const i=this.workerPool.acquire(this.id);for(let t=0;t{this.ready=!0}))}broadcast(t,e,i){Qe(this.actors,((i,n)=>{i.send(t,e,n)}),i=i||function(){})}getActor(){return this.currentActor=(this.currentActor+1)%this.actors.length,this.actors[this.currentActor]}remove(){this.actors.forEach((t=>{t.remove()})),this.actors=[],this.workerPool.release(this.id)}}ox.Actor=rx;var sx={workerUrl:"",workerClass:null,workerParams:void 0};function ax(){return null!=sx.workerClass?new sx.workerClass:new self.Worker(sx.workerUrl,sx.workerParams)}const lx="mapboxgl_preloaded_worker_pool";class cx{constructor(){this.active={}}acquire(t){if(!this.workers)for(this.workers=[];this.workers.length{t.terminate()})),this.workers=null)}isPreloaded(){return!!this.active[lx]}numActive(){return Object.keys(this.active).length}}let dx;function ux(){return dx||(dx=new cx),dx}cx.workerCount=2;let hx,px,fx,mx,_x,gx=null;function yx(){return gi()&&self.worker&&self.worker.dracoUrl?self.worker.dracoUrl:px||n.DRACO_URL}function vx(){if(gi()&&self.worker&&self.worker.meshoptUrl)return self.worker.meshoptUrl;if(mx)return mx;const t=new Uint8Array([0,97,115,109,1,0,0,0,1,4,1,96,0,0,3,3,2,0,0,5,3,1,0,1,12,1,0,10,22,2,12,0,65,0,65,0,65,0,252,10,0,0,11,7,0,65,0,253,15,26,11]);if("object"!=typeof WebAssembly)throw new Error("WebAssembly not supported, cannot instantiate meshoptimizer");return mx=WebAssembly.validate(t)?n.MESHOPT_SIMD_URL:n.MESHOPT_URL,mx}const xx={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},bx={5120:"DT_INT8",5121:"DT_UINT8",5122:"DT_INT16",5123:"DT_UINT16",5125:"DT_UINT32",5126:"DT_FLOAT32"},wx={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16};function Tx(t,e,i){const n=i.json.bufferViews.length,r=i.buffers.length;e.bufferView=n,i.json.bufferViews[n]={buffer:r,byteLength:t.byteLength},i.buffers[r]=t}const Sx="KHR_draco_mesh_compression";function Ex(t,e){const i=t.extensions&&t.extensions[Sx];if(!i)return;const n=new fx.Decoder,r=$x(e,i.bufferView),o=new fx.Mesh;if(!n.DecodeArrayToMesh(r,r.byteLength,o))throw new Error("Failed to decode Draco mesh");const s=e.json.accessors[t.indices],a=xx[s.componentType],l=s.count*a.BYTES_PER_ELEMENT,c=fx._malloc(l);a===Uint16Array?n.GetTrianglesUInt16Array(o,l,c):n.GetTrianglesUInt32Array(o,l,c),Tx(fx.memory.buffer.slice(c,c+l),s,e),fx._free(c);for(const r of Object.keys(i.attributes)){const s=n.GetAttributeByUniqueId(o,i.attributes[r]),a=e.json.accessors[t.attributes[r]],l=bx[a.componentType],c=a.count*wx[a.type]*xx[a.componentType].BYTES_PER_ELEMENT,d=fx._malloc(c);n.GetAttributeDataArrayForAllPoints(o,s,fx[l],c,d),Tx(fx.memory.buffer.slice(d,d+c),a,e),fx._free(d)}n.destroy(),o.destroy(),delete t.extensions[Sx]}const Mx="EXT_meshopt_compression";function Cx(t,e){if(!t.extensions||!t.extensions[Mx])return;const i=t.extensions[Mx],n=new Uint8Array(e.buffers[i.buffer],i.byteOffset||0,i.byteLength||0),r=new Uint8Array(i.count*i.byteStride);_x.decodeGltfBuffer(r,i.count,i.byteStride,n,i.mode,i.filter),t.buffer=e.buffers.length,t.byteOffset=0,e.buffers[t.buffer]=r.buffer,delete t.extensions[Mx]}const Ax=1179937895,Ix=new TextDecoder("utf8");function Lx(t,e){return new URL(t,e).href}function Px(t,e,i,n){return fetch(Lx(t.uri,n)).then((t=>t.arrayBuffer())).then((t=>{e.buffers[i]=t}))}function $x(t,e){const i=t.json.bufferViews[e];return new Uint8Array(t.buffers[i.buffer],i.byteOffset||0,i.byteLength)}function kx(t,e,i,n){if(t.uri){const r=Lx(t.uri,n);return fetch(r).then((t=>t.blob())).then((t=>createImageBitmap(t))).then((t=>{e.images[i]=t}))}if(void 0!==t.bufferView){const n=$x(e,t.bufferView),r=new Blob([n],{type:t.mimeType});return createImageBitmap(r).then((t=>{e.images[i]=t}))}}function Dx(t,e=0,i){const n={json:null,images:[],buffers:[]};if(new Uint32Array(t,e,1)[0]===Ax){const i=new Uint32Array(t,e);let r=2;const o=(i[r++]>>2)-3,s=i[r++]>>2;if(r++,n.json=JSON.parse(Ix.decode(i.subarray(r,r+s))),r+=s,r{const t=[],e=a&&a.includes(Sx),r=a&&a.includes(Mx);if(e&&t.push(function(){if(!fx)return hx||(hx=function(t){let e,i=null;function n(){e=new Uint8Array(i.buffer)}function r(){throw new Error("Unexpected Draco error.")}const o={a:{a:r,d:function(t,i,n){return e.copyWithin(t,i,i+n)},c:function(t){const r=e.length,o=Math.max(t>>>0,Math.ceil(1.2*r)),s=Math.ceil((o-r)/65536);try{return i.grow(s),n(),!0}catch(t){return!1}},b:r}};return(WebAssembly.instantiateStreaming?WebAssembly.instantiateStreaming(t,o):t.then((t=>t.arrayBuffer())).then((t=>WebAssembly.instantiate(t,o)))).then((t=>{const{Rb:r,Qb:o,P:s,T:a,X:l,Ja:c,La:d,Qa:u,Va:h,Wa:p,eb:f,jb:m,f:_,e:g,yb:y,zb:v,Ab:x,Bb:b,Db:w,Gb:T}=t.instance.exports;i=g;const S=(()=>{let t=0,i=0,n=0,s=0;return a=>{n&&(r(s),r(t),i+=n,n=t=0),t||(i+=128,t=o(i));const l=a.length+7&-8;let c=t;l>=i&&(n=l,c=s=o(l));for(let t=0;t{fx=t,hx=void 0})))}()),r&&t.push(function(){if(_x)return;const t=function(t){let e;const i=WebAssembly.instantiateStreaming(t,{}).then((t=>{e=t.instance,e.exports.__wasm_call_ctors()})),n={NONE:"",OCTAHEDRAL:"meshopt_decodeFilterOct",QUATERNION:"meshopt_decodeFilterQuat",EXPONENTIAL:"meshopt_decodeFilterExp"},r={ATTRIBUTES:"meshopt_decodeVertexBuffer",TRIANGLES:"meshopt_decodeIndexBuffer",INDICES:"meshopt_decodeIndexSequence"};return{ready:i,supported:!0,decodeGltfBuffer(t,i,o,s,a,l){!function(t,e,i,n,r,o,s){const a=t.exports.sbrk,l=n+3&-4,c=a(l*r),d=a(o.length),u=new Uint8Array(t.exports.memory.buffer);u.set(o,d);const h=e(c,n,r,d,o.length);if(0===h&&s&&s(c,l,r),i.set(u.subarray(c,c+n*r)),a(c-a(0)),0!==h)throw new Error(`Malformed buffer data: ${h}`)}(e,e.exports[r[a]],t,i,o,s,e.exports[n[l]])}}}(fetch(vx()));return t.ready.then((()=>{_x=t}))}()),o)for(let e=0;e{if(e&&s)for(const{primitives:t}of s)for(const e of t)Ex(e,n);if(r&&s&&l)for(const t of l)Cx(t,n);return n}))}))}function zx(t,e){const i=t.json.bufferViews[e.bufferView],n=xx[e.componentType];return new n(t.buffers[i.buffer],(e.byteOffset||0)+(i.byteOffset||0),e.count*(i.byteStride&&i.byteStride!==wx[e.type]*n.BYTES_PER_ELEMENT?i.byteStride/n.BYTES_PER_ELEMENT:wx[e.type]))}function Rx(t,e,i,n){const r=xx[e.componentType],o=function(t){switch(t){case Int8Array:return 1/127;case Uint8Array:return 1/255;case Int16Array:return 1/32767;case Uint16Array:return 1/65535;default:return 1}}(r),s=t.json.bufferViews[e.bufferView],a=s.byteStride?s.byteStride/r.BYTES_PER_ELEMENT:wx[e.type],l=i.float32,c=l.length/i.capacity;for(let t=0,i=0;t0){for(let r=0;r0){o.texcoordArray=new ic;const t=e.json.accessors[r.TEXCOORD_0];o.texcoordArray.resize(t.count);const i=zx(e,t);Rx(e,t,o.texcoordArray,i)}if(void 0!==r._FEATURE_ID_RGBA4444){const t=e.json.accessors[r._FEATURE_ID_RGBA4444];e.json.extensionsUsed&&e.json.extensionsUsed.includes("EXT_meshopt_compression")&&(o.featureData=zx(e,t))}void 0!==r._FEATURE_RGBA4444&&(o.featureData=new Uint32Array(zx(e,e.json.accessors[r._FEATURE_RGBA4444]).buffer));const u=t.material;return o.material=function(t,e){const{emissiveFactor:i=[0,0,0],alphaMode:n="OPAQUE",alphaCutoff:r=.5,normalTexture:o,occlusionTexture:s,emissiveTexture:a,doubleSided:l}=t,{baseColorFactor:c=[1,1,1,1],metallicFactor:d=1,roughnessFactor:u=1,baseColorTexture:h,metallicRoughnessTexture:p}=t.pbrMetallicRoughness||{},f=s?e[s.index]:void 0;if(s&&s.extensions&&s.extensions.KHR_texture_transform&&f){const t=s.extensions.KHR_texture_transform;f.offsetScale=[t.offset[0],t.offset[1],t.scale[0],t.scale[1]]}return{pbrMetallicRoughness:{baseColorFactor:new Un(...c),metallicFactor:d,roughnessFactor:u,baseColorTexture:h?e[h.index]:void 0,metallicRoughnessTexture:p?e[p.index]:void 0},doubleSided:l,emissiveFactor:i,alphaMode:n,alphaCutoff:r,normalTexture:o?e[o.index]:void 0,occlusionTexture:f,emissionTexture:a?e[a.index]:void 0,defined:void 0===t.defined}}(void 0!==u?e.json.materials[u]:{defined:!1},i),o}function Bx(e,i,n){const{matrix:r,rotation:o,translation:s,scale:a,mesh:l,extras:c,children:d}=e,u={};if(u.matrix=r||t.ad.fromRotationTranslationScale([],o||[0,0,0,1],s||[0,0,0],a||[1,1,1]),void 0!==l){u.meshes=n[l];const t=u.anchor=[0,0];for(const e of u.meshes){const{min:i,max:n}=e.aabb;t[0]+=i[0]+n[0],t[1]+=i[1]+n[1]}t[0]=Math.floor(t[0]/u.meshes.length/2),t[1]=Math.floor(t[1]/u.meshes.length/2)}if(c&&(c.id&&(u.id=c.id),c.lights&&(u.lights=function(t){if(!t.length)return[];const e=function(t){const e=atob(t),i=new Uint8Array(e.length);for(let t=0;t1&&n[n.length-1].equals(n[0])&&n.pop();let r=0;for(let t=0;t0&&n.reverse();const o=xh(n.flatMap((t=>[t.x,t.y])),[]);return 0===o.length?null:{vertices:n,indices:o}}function Ux(e,i){const n=[],r=[];let o=0;const s=[];for(const a of e){o=n.length;const e=a.vertexArray.float32,l=a.indexArray.uint16;for(let r=0;r0&&([r[t+1],r[t+2]]=[r[t+2],r[t+1]])}return{vertices:n,indices:r}}function jx(t){const e=function(t,e){const i=[],n=WebGL2RenderingContext;if(t.json.textures)for(const r of t.json.textures){const o={magFilter:n.LINEAR,minFilter:n.NEAREST,wrapS:n.REPEAT,wrapT:n.REPEAT};void 0!==r.sampler&&Object.assign(o,t.json.samplers[r.sampler]),i.push({image:e[r.source],sampler:o,uploaded:!1})}return i}(t,t.images),i=function(t,e){const i=[];for(const n of t.json.meshes){const r=[];for(const i of n.primitives)r.push(Ox(i,t,e));i.push(r)}return i}(t,e),{scenes:n,scene:r,nodes:o}=t.json,s=n?n[r||0].nodes:o,a=[];for(const e of s)a.push(Bx(o[e],t,i));return function(t,e,i){const n={},r=new Set;for(let o=0;o0){const e=Array.from(r.values()).sort(((t,e)=>t-e));for(let i=e.length-1;i>=0;i--)t.splice(e[i],1)}}(a,s,t.json.nodes),a}function Vx(t){t.heightmap=new Float32Array(4096),t.heightmap.fill(-1);const e=t.vertexArray.float32,i=t.aabb.min[0]-1,n=t.aabb.min[1]-1,r=Wv/(t.aabb.max[0]-i+2),o=Wv/(t.aabb.max[1]-n+2);for(let s=0;st.heightmap[c*Wv+l]&&(t.heightmap[c*Wv+l]=a)}}function Gx(e,i){const n={};n.indexArray=new Kl,n.indexArray.reserve(4*e.length),n.vertexArray=new Bl,n.vertexArray.reserve(10*e.length),n.colorArray=new Ol,n.vertexArray.reserve(10*e.length);let r=0;for(const o of e){const e=Math.min(10,Math.max(4,1.3*o.height))*i,s=[-o.normal[1],o.normal[0],0],a=Math.min(.29,.1*o.width/o.depth),l=o.width-2*o.depth*i*(a+.01),c=t._.scaleAndAdd([],o.pos,s,l/2),d=t._.scaleAndAdd([],o.pos,s,-l/2),u=[c[0],c[1],c[2]+o.height],h=[d[0],d[1],d[2]+o.height],p=t._.scaleAndAdd([],o.normal,s,a);t._.scale(p,p,e);const f=t._.scaleAndAdd([],o.normal,s,-a);t._.scale(f,f,e),t._.add(p,c,p),t._.add(f,d,f),c[2]+=.1,d[2]+=.1,n.vertexArray.emplaceBack(p[0],p[1],p[2]),n.vertexArray.emplaceBack(f[0],f[1],f[2]),n.vertexArray.emplaceBack(c[0],c[1],c[2]),n.vertexArray.emplaceBack(d[0],d[1],d[2]),n.vertexArray.emplaceBack(u[0],u[1],u[2]),n.vertexArray.emplaceBack(h[0],h[1],h[2]),n.vertexArray.emplaceBack(c[0],c[1],c[2]),n.vertexArray.emplaceBack(d[0],d[1],d[2]),n.vertexArray.emplaceBack(p[0],p[1],p[2]),n.vertexArray.emplaceBack(f[0],f[1],f[2]);const m=l/e/2;n.colorArray.emplaceBack(-m-a,-1,m,.8),n.colorArray.emplaceBack(m+a,-1,m,.8),n.colorArray.emplaceBack(-m,0,m,1.3),n.colorArray.emplaceBack(m,0,m,1.3),n.colorArray.emplaceBack(m+a,-.8,m,.7),n.colorArray.emplaceBack(m+a,-.8,m,.7),n.colorArray.emplaceBack(0,0,m,1.3),n.colorArray.emplaceBack(0,0,m,1.3),n.colorArray.emplaceBack(m+a,-1.2,m,.8),n.colorArray.emplaceBack(m+a,-1.2,m,.8),n.indexArray.emplaceBack(6+r,4+r,8+r),n.indexArray.emplaceBack(7+r,9+r,5+r),n.indexArray.emplaceBack(0+r,1+r,2+r),n.indexArray.emplaceBack(1+r,3+r,2+r),r+=10}const o={defined:!0,emissiveFactor:[0,0,0]},s={};return s.baseColorFactor=Un.white,o.pbrMetallicRoughness=s,n.material=o,n.aabb=new wu([1/0,1/0,1/0],[-1/0,-1/0,-1/0]),n}const Zx=new Float32Array(262144),qx=new Uint8Array(262144);function Hx(t){let e=0;if(t.meshes)for(const i of t.meshes)e=Math.max(e,i.aabb.max[2]);if(t.children)for(const i of t.children)e=Math.max(e,Hx(i));return e}function Wx(t,e,i){if(t.meshes)for(const n of t.meshes)n.aabb.min[0]!==1/0&&i.insert(e,n.aabb.min[0],n.aabb.min[1],n.aabb.max[0],n.aabb.max[1]);if(t.children)for(const n of t.children)Wx(n,e,i)}const Yx=["","wall","door","roof","window","lamp","logo"];class Xx{constructor(t){this.node=t,this.evaluatedRMEA=[[1,0,0,1],[1,0,0,1],[1,0,0,1],[1,0,0,1],[.4,1,0,1],[1,0,0,1],[1,0,0,1]],this.hiddenByReplacement=!1,this.evaluatedScale=[1,1,1],this.evaluatedColor=[],this.emissionHeightBasedParams=[],this.feature={type:"Point",id:t.id,geometry:[],properties:{height:Hx(t)}},this.aabb=this._getLocalBounds()}_getLocalBounds(){if(!this.node.meshes)return new wu([1/0,1/0,1/0],[-1/0,-1/0,-1/0]);if(!this.aabb){let t=0;const e=new wu([1/0,1/0,1/0],[-1/0,-1/0,-1/0]);for(const i of this.node.meshes)this.node.lightMeshIndex!==t&&(i.transformedAabb=wu.applyTransformFast(i.aabb,this.node.matrix),e.encapsulate(i.transformedAabb)),t++;this.aabb=e}return this.aabb}}class Kx{constructor(t,e,i,n,r,o){this.id=e,this.modelTraits|=Yv.CoordinateSpaceTile,this.uploaded=!1,this.hasPattern=!1,i&&(this.modelTraits|=Yv.HasMapboxMeshFeatures),n&&(this.modelTraits|=Yv.HasMeshoptCompression),this.zoom=-1,this.terrainExaggeration=1,this.projection={name:"mercator"},this.replacementUpdateTime=0,this.elevationReadFromZ=255,this.brightness=r,this.dirty=!0,this.needsUpload=!1,this.nodesInfo=[];for(const e of t)this.nodesInfo.push(new Xx(e)),Wx(e,o.featureIndexArray.length,o.grid),o.featureIndexArray.emplaceBack(this.nodesInfo.length-1,0,o.bucketLayerIDs.length-1,0)}updateFootprints(t,e){for(const i of this.getNodesInfo()){const n=i.node;n.footprint&&e.push({footprint:n.footprint,id:t})}}update(){console.log("Update 3D model bucket")}populate(){console.log("populate 3D model bucket")}uploadPending(){return!this.uploaded||this.needsUpload}upload(t){if(!this.needsUpload)return;const e=this.getNodesInfo();for(const i of e){const e=i.node;this.uploaded?this.updatePbrBuffer(e):Qv(e,t,!0)}for(const t of e)tx(t.node);this.uploaded=!0,this.needsUpload=!1}updatePbrBuffer(t){let e=!1;if(!t.meshes)return e;for(const i of t.meshes)i.pbrBuffer&&(i.pbrBuffer.updateData(i.featureArray),e=!0);return e}needsReEvaluation(t,e,i){const n=t.transform.projectionOptions,r=t.style.getBrightness(),o=this.brightness!==r;return!!(!this.uploaded||this.dirty||n.name!==this.projection.name||Jx(i.paint.get("model-color").value,o)||Jx(i.paint.get("model-color-mix-intensity").value,o)||Jx(i.paint.get("model-roughness").value,o)||Jx(i.paint.get("model-emissive-strength").value,o)||Jx(i.paint.get("model-height-based-emissive-strength-multiplier").value,o))&&(this.projection=n,this.brightness=r,!0)}evaluateScale(t,e){if(t.transform.zoom===this.zoom)return;this.zoom=t.transform.zoom;const i=this.getNodesInfo(),n=this.id.canonical;for(const t of i){const i=t.feature;t.evaluatedScale=e.paint.get("model-scale").evaluate(i,{},n)}}evaluate(t){const e=this.getNodesInfo();for(const i of e){if(!i.node.meshes)continue;const e=i.feature,n=i.node.meshes&&i.node.meshes[0].featureData,r=i.evaluatedColor[2],o=i.evaluatedRMEA[2],s=this.id.canonical;if(i.hasTranslucentParts=!1,n){for(let n=0;n=t)continue;const u=Zx[c],h=Math.abs(u);h>a&&(s=u,a=h,l=r,d=e)}if(a>.1){const o=1-(t+.5*Math.abs(l*d))/c;let a=e._dem.get(n,i)+s*o;const u=e._dem.get(n+l,i+d),h=e._dem.get(n-l,i-d,!0);(a-u)*(a-h)>0&&(a=(u+h)/2),Zx[r]=e._dem.set(n,i,a),qx[r]=t}}}}}s&&(e._demTile.needsDEMTextureUpload=!0,e._dem._timestamp=ki.now())}getNodesInfo(){return this.nodesInfo}destroy(){const t=this.getNodesInfo();for(const e of t)tx(e.node),ex(e.node)}isEmpty(){return!this.nodesInfo.length}updateReplacement(t,e){if(e.updateTime===this.replacementUpdateTime)return;this.replacementUpdateTime=e.updateTime;const i=e.getReplacementRegionsForTile(t.toUnwrapped()),n=this.getNodesInfo();for(let t=0;tt.footprint===e.footprint))}}getHeightAtTileCoord(e,i){const n=this.getNodesInfo(),r=[],o=[0,0,0],s=t.ad.identity([]);for(let a=0;ad.max[0]||i>d.max[1])continue;if(!0===l.node.hidden)return{height:0,maxHeight:l.feature.properties.height,hidden:!1,verticalScale:l.evaluatedScale[2]};t.ad.invert(s,l.node.matrix),o[0]=e,o[1]=i,t._.transformMat4(o,o,s);const u=(o[0]-c.aabb.min[0])/(c.aabb.max[0]-c.aabb.min[0])*Wv|0,h=Math.min(63,(o[1]-c.aabb.min[1])/(c.aabb.max[1]-c.aabb.min[1])*Wv|0)*Wv+Math.min(63,u),p=c.heightmap[h];if(!(p0)return{height:void 0,maxHeight:l.feature.properties.height,hidden:l.hiddenByReplacement,verticalScale:l.evaluatedScale[2]}}}}function Jx(t,e){return!t.isLightConstant&&e}function Qx(t,e,i,n,r,o,s,a){let l=(61440&e|(61440&e)>>4)>>8,c=(3840&e|(3840&e)>>4)>>4,d=240&e|(240&e)>>4;i[3]>0&&(l=Vn(l,255*i[0],i[3]),c=Vn(c,255*i[1],i[3]),d=Vn(d,255*i[2],i[3]));const u=l>16&65535,a=o?e>>16&65535:65535&e,l=(15&a)t.polygon)).flat());const g=f?l:null,[y,v]=function(e,i,n,r,o,s,a,l,c,d,u){return"globe"===e.projection.name?function(e,i,n,r,o,s,a,l,c,d,u){const h=[],p=[],f=e.projection.upVectorScale(u,e.center.lat,e.worldSize).metersToTile,m=[0,0,0,1],_=[0,0,0,1],g=(t,e,i,n)=>{t[0]=e,t[1]=i,t[2]=n,t[3]=1},y=Sf();n>0&&(n+=y),r+=y;for(const y of i){const i=[],v=[];for(const h of y){const p=h.x+o.x,y=h.y+o.y,x=e.projection.projectTilePoint(p,y,u),b=e.projection.upVector(u,h.x,h.y);let w=n,T=r;if(a){const t=Pf(p,y,n,r,a,l,c,d);w+=t.base,T+=t.top}0!==n?g(m,x.x+b[0]*f*w,x.y+b[1]*f*w,x.z+b[2]*f*w):g(m,x.x,x.y,x.z),g(_,x.x+b[0]*f*T,x.y+b[1]*f*T,x.z+b[2]*f*T),t._.transformMat4(m,m,s),t._.transformMat4(_,_,s),i.push(new Tp(m[0],m[1],m[2])),v.push(new Tp(_[0],_[1],_[2]))}h.push(i),p.push(v)}return[h,p]}(e,i,n,r,o,s,a,l,c,d,u):a?function(e,i,n,r,o,s,a,l,c){const d=[],u=[],h=[0,0,0,1];for(const p of e){const e=[],f=[];for(const d of p){const u=d.x+r.x,p=d.y+r.y,m=Pf(u,p,i,n,s,a,l,c);h[0]=u,h[1]=p,h[2]=m.base,h[3]=1,t.aA.transformMat4(h,h,o),h[3]=Math.max(h[3],1e-5);const _=new Tp(h[0]/h[3],h[1]/h[3],h[2]/h[3]);h[0]=u,h[1]=p,h[2]=m.top,h[3]=1,t.aA.transformMat4(h,h,o),h[3]=Math.max(h[3],1e-5);const g=new Tp(h[0]/h[3],h[1]/h[3],h[2]/h[3]);e.push(_),f.push(g)}d.push(e),u.push(f)}return[d,u]}(i,n,r,o,s,a,l,c,d):function(t,e,i,n,r){const o=[],s=[],a=r[8]*e,l=r[9]*e,c=r[10]*e,d=r[11]*e,u=r[8]*i,h=r[9]*i,p=r[10]*i,f=r[11]*i;for(const e of t){const t=[],i=[];for(const o of e){const e=o.x+n.x,s=o.y+n.y,m=r[0]*e+r[4]*s+r[12],_=r[1]*e+r[5]*s+r[13],g=r[2]*e+r[6]*s+r[14],y=r[3]*e+r[7]*s+r[15],v=m+a,x=_+l,b=g+c,w=Math.max(y+d,1e-5),T=m+u,S=_+h,E=g+p,M=Math.max(y+f,1e-5);t.push(new Tp(v/w,x/w,b/w)),i.push(new Tp(T/M,S/M,E/M))}o.push(t),s.push(i)}return[o,s]}(i,n,r,o,s)}(s,r,h,u,d,a,g,p,m,s.center.lat,e.tileID.canonical),x=e.queryGeometry;return function(t,e,i){let n=1/0;Kd(i,e)&&(n=Lf(i,e[0]));for(let r=0;r=3)for(let e=0;e>4;if(1!==n)throw new Error(`Got v${n} data when expected v1.`);const r=nb[15&i];if(!r)throw new Error("Unrecognized array type.");const[o]=new Uint16Array(t,2,1),[s]=new Uint32Array(t,4,1);return new rb(s,o,r,t)}constructor(t,e=64,i=Float64Array,n){if(isNaN(t)||t>1;return this.ids[i]=i,this.coords[this._pos++]=t,this.coords[this._pos++]=e,i}finish(){const t=this._pos>>1;if(t!==this.numItems)throw new Error(`Added ${t} items when expected ${this.numItems}.`);return ob(this.ids,this.coords,this.nodeSize,0,this.numItems-1,0),this._finished=!0,this}range(t,e,i,n){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");const{ids:r,coords:o,nodeSize:s}=this,a=[0,r.length-1,0],l=[];for(;a.length;){const c=a.pop()||0,d=a.pop()||0,u=a.pop()||0;if(d-u=t&&a=e&&c>1,p=o[2*h],f=o[2*h+1];p>=t&&p=e&&f=p:n>=f)&&(a.push(h+1),a.push(d),a.push(1-c))}return l}within(t,e,i){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");const{ids:n,coords:r,nodeSize:o}=this,s=[0,n.length-1,0],a=[],l=i*i;for(;s.length;){const c=s.pop()||0,d=s.pop()||0,u=s.pop()||0;if(d-u>1,p=r[2*h],f=r[2*h+1];cb(p,f,t,e)=p:e+i>=f)&&(s.push(h+1),s.push(d),s.push(1-c))}return a}}function ob(t,e,i,n,r,o){if(r-n>1;sb(t,e,s,n,r,o),ob(t,e,i,n,s-1,1-o),ob(t,e,i,s+1,r,1-o)}function sb(t,e,i,n,r,o){for(;r>n;){if(r-n>600){const s=r-n+1,a=i-n+1,l=Math.log(s),c=.5*Math.exp(2*l/3),d=.5*Math.sqrt(l*c*(s-c)/s)*(a-s/2s&&ab(t,e,n,r);as;)l--}e[2*n+o]===s?ab(t,e,n,l):(l++,ab(t,e,l,r)),lr&&(n+=(t[i]-r)*(t[i]-r)),e[i]0&&n[0]0&&n[1]0&&r[0]0&&r[1]0?Math.acos(i/n)*Ve:0;let o=0!==t||0!==e?Math.atan2(-e,-t)*Ve+90:0;return oNi&&(t.getActor().send("enforceCacheSizeLimit",Fi),Vi=0)},t.an=gn,t.ao=class{constructor(t){this.entries={},this.scheduler=t}request(t,e,i,n){const r=this.entries[t]=this.entries[t]||{callbacks:[]};if(r.result){const[t,i]=r.result;return this.scheduler?this.scheduler.add((()=>{n(t,i)}),e):n(t,i),()=>{}}return r.callbacks.push(n),r.cancel||(r.cancel=i(((i,n)=>{r.result=[i,n];for(const t of r.callbacks)this.scheduler?this.scheduler.add((()=>{t(i,n)}),e):t(i,n);setTimeout((()=>delete this.entries[t]),3e3)}))),()=>{r.result||(r.callbacks=r.callbacks.filter((t=>t!==n)),r.callbacks.length||(r.cancel(),delete this.entries[t]))}}},t.ap=function(t,e,i){const n=JSON.stringify(t.request);return t.data&&(this.deduped.entries[n]={result:[null,t.data]}),this.deduped.request(n,{type:"parseTile",isSymbolTile:t.isSymbolTile,zoom:t.tileZoom},(e=>{const n=en(t.request,((t,n,r,o)=>{t?e(t):n&&e(null,{vectorTile:i?void 0:new bp(new Lm(n)),rawData:n,cacheControl:r,expires:o})}));return()=>{n.cancel(),e()}}),e)},t.aq=Dc,t.ar=class extends Lc{constructor(t){super(t),this.current=Fc}set(t,e,i){if(this.fetchUniformLocation(t,e))for(let t=0;t({u_camera_to_center_distance:new $c(t),u_extrude_scale:new Uc(t),u_device_pixel_ratio:new $c(t),u_matrix:new Bc(t),u_inv_rot_matrix:new Bc(t),u_merc_center:new kc(t),u_tile_id:new Dc(t),u_zoom_transition:new $c(t),u_up_dir:new Dc(t),u_emissive_strength:new $c(t)}),t.bJ=t=>({u_matrix:new Bc(t),u_pixels_to_tile_units:new Uc(t),u_device_pixel_ratio:new $c(t),u_units_to_pixels:new kc(t),u_dash_image:new Pc(t),u_gradient_image:new Pc(t),u_image_height:new $c(t),u_texsize:new kc(t),u_tile_units_to_pixels:new $c(t),u_alpha_discard_threshold:new $c(t),u_trim_offset:new kc(t),u_trim_fade_range:new kc(t),u_trim_color:new zc(t),u_emissive_strength:new $c(t)}),t.bK=t=>({u_matrix:new Bc(t),u_texsize:new kc(t),u_pixels_to_tile_units:new Uc(t),u_device_pixel_ratio:new $c(t),u_image:new Pc(t),u_units_to_pixels:new kc(t),u_tile_units_to_pixels:new $c(t),u_alpha_discard_threshold:new $c(t),u_trim_offset:new kc(t)}),t.bL=Yl,t.bM=Hf,t.bN=Om,t.bO=jm,t.bP=G_,t.bQ=c_,t.bR=th,t.bS=(t,e,i,n,r,o)=>{const s=t.transform,a="globe"===s.projection.name;let l;if("map"===o.paint.get("circle-pitch-alignment"))if(a){const t=Zu(s.zoom,e.canonical)*s._pixelsPerMercatorPixel;l=Float32Array.from([t,0,0,t])}else l=s.calculatePixelsToTileUnitsMatrix(i);else l=new Float32Array([s.pixelsToGLUnits[0],0,0,s.pixelsToGLUnits[1]]);const c={u_camera_to_center_distance:t.transform.getCameraToCenterDistance(s.projection),u_matrix:t.translatePosMatrix(e.projMatrix,i,o.paint.get("circle-translate"),o.paint.get("circle-translate-anchor")),u_device_pixel_ratio:ki.devicePixelRatio,u_extrude_scale:l,u_inv_rot_matrix:Qu,u_merc_center:[0,0],u_tile_id:[0,0,0],u_zoom_transition:0,u_up_dir:[0,0,0],u_emissive_strength:o.paint.get("circle-emissive-strength")};if(a){c.u_inv_rot_matrix=n,c.u_merc_center=r,c.u_tile_id=[e.canonical.x,e.canonical.y,1{const s=t.transform;return{u_matrix:rm(t,e,i,n),u_texsize:e.imageAtlasTexture?e.imageAtlasTexture.size:[0,0],u_pixels_to_tile_units:s.calculatePixelsToTileUnitsMatrix(e),u_device_pixel_ratio:r,u_image:0,u_tile_units_to_pixels:nm(e,s),u_units_to_pixels:[1/s.pixelsToGLUnits[0],1/s.pixelsToGLUnits[1]],u_alpha_discard_threshold:0,u_trim_offset:o}},t.bV=(t,e,i,n,r,o,s)=>{const a=t.transform,l=a.calculatePixelsToTileUnitsMatrix(e);return{u_matrix:rm(t,e,i,n),u_pixels_to_tile_units:l,u_device_pixel_ratio:o,u_units_to_pixels:[1/a.pixelsToGLUnits[0],1/a.pixelsToGLUnits[1]],u_dash_image:0,u_gradient_image:1,u_image_height:r,u_texsize:sm(i)&&e.lineAtlasTexture?e.lineAtlasTexture.size:[0,0],u_tile_units_to_pixels:nm(e,t.transform),u_alpha_discard_threshold:0,u_trim_offset:s,u_trim_fade_range:i.paint.get("line-trim-fade-range"),u_trim_color:i.paint.get("line-trim-color").toRenderColor(i.lut).toArray01(),u_emissive_strength:i.paint.get("line-emissive-strength")}},t.bW=oi,t.bX=mh,t.bY=Sf,t.bZ=bd,t.b_=_f,t.ba=function(t,e,i){const n=Hu(i.zoom),r=t.style.map._antialias,o=e.options.extStandardDerivativesForceOff||t.terrain&&t.terrain.exaggeration()>0;return 0===n&&!r&&!o},t.bb=function(e){const i=e.pixelsPerMeter,n=i/Cd(1,e.center.lat),r=t.ad.identity(new Float64Array(16));return t.ad.translate(r,r,[e.point.x,e.point.y,0]),t.ad.scale(r,r,[n,n,i]),Float32Array.from(r)},t.bc=Ou,t.bd=function(t){const e=Pd-5;t=Xe(t,-e,e)/e*90;const i=Math.pow(Math.abs(Math.sin(Ge(t))),3);return Math.round(i*(sd.length-1))},t.be=function(e,i,n,r){const o=i.getNorth(),s=i.getSouth(),a=i.getWest(),l=i.getEast(),c=10){const e=180/r;t.bC.multiply(f,f,[e/d+1,0,0,0,e/u+1,0,-.5*e/h,.5*e/p,1])}return f[2]=c,f[5]=e.x,f[8]=e.y,f},t.bf=ju,t.bg=$u,t.bh=function(e,i,n){const r=t.ad.identity(new Float64Array(16)),o=(i/(1{}}},t.bo=Gg,t.bp=ai,t.bq=class{isDataAvailableAtPoint(t){const e=this._source();if(this.isUsingMockSource()||!e||t.y1)return!1;const i=e.getSource().maxzoom,n=11)return e;const r=n.getSource().maxzoom,o=1{const s=this.getAtTileOffset(e,o.x,o.y),a=r.upVector(e.canonical,o.x,o.y),l=r.upVectorScale(e.canonical,i,n).metersToTile;return t._.scale(a,a,s*l),a}}getForTilePoints(t,e,i,n){if(this.isUsingMockSource())return!1;const r=Xp.create(this,t,n);return!!r&&(e.forEach((t=>{t[2]=this.exaggeration()*r.getElevationAt(t[0],t[1],i)})),!0)}getMinMaxForTile(t){if(this.isUsingMockSource())return null;const e=this.findDEMTileFor(t);if(!e||!e.dem)return null;const i=e.dem.tree,n=e.tileID,r=1=0?t.slice(0,e):t},t.cV=function(t){return t.indexOf(wl)>=0},t.cW=function(t){const e=t.indexOf(wl);return e>=0?t.slice(e+1):""},t.cX=function(t){const e=[],i=t.id;return void 0===i&&e.push({message:`layers.${i}: missing required property "id"`}),void 0===t.render&&e.push({message:`layers.${i}: missing required method "render"`}),t.renderingMode&&"2d"!==t.renderingMode&&"3d"!==t.renderingMode&&e.push({message:`layers.${i}: property "renderingMode" must be either "2d" or "3d"`}),e},t.cY=function(t,e,i,n){return"custom"===t.type?new vv(t,e):new ib[t.type](t,e,i,n)},t.cZ=di,t.c_=Va,t.ca=1,t.cb=Ag,t.cc=0,t.cd=ec,t.ce=function(t,e,i,n,r){return Xe((t-e)/(i-e)*(r-n)+n,n,r)},t.cf=Ns,t.cg=kd,t.ch=class{constructor(t,e,i,n){this.context=t,this.format=n,this.size=i,this.texture=t.gl.createTexture();const[r,o,s]=this.size,{gl:a}=t;a.bindTexture(a.TEXTURE_3D,this.texture),t.pixelStoreUnpackFlipY.set(!1),t.pixelStoreUnpack.set(1),t.pixelStoreUnpackPremultiplyAlpha.set(!1);let l=this.format,c=a.UNSIGNED_BYTE;this.format===a.DEPTH_COMPONENT&&(l=a.DEPTH_COMPONENT16,c=a.UNSIGNED_SHORT),this.format===a.R8&&(n=a.RED),this.format===a.R32F&&(c=a.FLOAT,n=a.RED),a.texImage3D(a.TEXTURE_3D,0,l,r,o,s,0,n,c,e.data)}bind(t,e){const{context:i}=this,{gl:n}=i;n.bindTexture(n.TEXTURE_3D,this.texture),t!==this.minFilter&&(n.texParameteri(n.TEXTURE_3D,n.TEXTURE_MAG_FILTER,t),n.texParameteri(n.TEXTURE_3D,n.TEXTURE_MIN_FILTER,t),this.minFilter=t),e!==this.wrapS&&(n.texParameteri(n.TEXTURE_3D,n.TEXTURE_WRAP_S,e),n.texParameteri(n.TEXTURE_3D,n.TEXTURE_WRAP_T,e),this.wrapS=e)}destroy(){const{gl:t}=this.context;t.deleteTexture(this.texture),this.texture=null}},t.ci=$v,t.cj=[1,1,1],t.ck=Xp,t.cl=Yv,t.cm=ql,t.cn=ic,t.co=class{constructor(){this._updateTime=0,this._sourceIds=[],this._activeRegions=[],this._prevRegions=[],this._globalClipBounds={min:new Ue(1/0,1/0),max:new Ue(-1/0,-1/0)}}clear(){this._activeRegions.length>0&&++this._updateTime,this._activeRegions=[],this._prevRegions=[]}get updateTime(){return this._updateTime}getReplacementRegionsForTile(t,e=!1){const i=$p(new Ue(0,0),new Ue(uo,uo),t),n=[];if(e&&!Lp(i,this._globalClipBounds))return n;for(const e of this._activeRegions){if(e.hiddenByOverlap)continue;if(!Lp(i,e))continue;const r=kp(e.min,e.max,t);n.push({min:r.min,max:r.max,sourceId:this._sourceIds[e.priority],footprint:e.footprint,footprintTileId:e.tileId,order:e.order,clipMask:e.clipMask})}return n}setSources(t){this._setSources(t.map((t=>({getSourceId:()=>t.cache.id,getFootprints:()=>{const e=[];for(const i of t.cache.getVisibleCoordinates()){const n=t.cache.getTile(i).buckets[t.layer];n&&n.updateFootprints(i.toUnwrapped(),e)}return e},getOrder:()=>t.order,getClipMask:()=>t.clipMask}))))}_addSource(t){const e=t.getFootprints();if(0===e.length)return;const i=t.getOrder(),n=t.getClipMask();for(const t of e){if(!t.footprint)continue;const e=$p(t.footprint.min,t.footprint.max,t.id);this._activeRegions.push({min:e.min,max:e.max,hiddenByOverlap:!1,priority:this._sourceIds.length,tileId:t.id,footprint:t.footprint,order:i,clipMask:n})}this._sourceIds.push(t.getSourceId())}_computeReplacement(){this._activeRegions.sort(((t,e)=>t.priority-e.priority||Ap(t.min,e.min)||Ap(t.max,e.max)));let t=this._activeRegions.length!==this._prevRegions.length;if(!t){let e=0;for(;!t&&e!==this._activeRegions.length;){const i=this._activeRegions[e],n=this._prevRegions[e];t=i.priority!==n.priority||!Ip(i,n)||i.order!==n.order||i.clipMask!==n.clipMask,++e}}if(t){++this._updateTime;for(const t of this._activeRegions)t.order!==1/0&&(this._globalClipBounds.min.x=Math.min(this._globalClipBounds.min.x,t.min.x),this._globalClipBounds.min.y=Math.min(this._globalClipBounds.min.y,t.min.y),this._globalClipBounds.max.x=Math.max(this._globalClipBounds.max.x,t.max.x),this._globalClipBounds.max.y=Math.max(this._globalClipBounds.max.y,t.max.y));const t=t=>{const e=this._activeRegions;if(t>=e.length)return t;const i=e[t].priority;for(;t1){let e=0,i=t(e);for(;e!==i;){let n=e;const r=e;for(;n!==i;){const t=this._activeRegions[n];t.hiddenByOverlap=!1;for(let e=0;e=0;e--)this._addSource(t[e]);this._computeReplacement()}},t.cp=Dl,t.cq=Jg,t.cr=rc,t.cs=class{constructor(t){this._createGrid(t),this._createPoles(t)}destroy(){this._poleIndexBuffer.destroy(),this._gridBuffer.destroy(),this._gridIndexBuffer.destroy(),this._poleNorthVertexBuffer.destroy(),this._poleSouthVertexBuffer.destroy();for(const t of this._poleSegments)t.destroy();for(const t of this._gridSegments)t.withSkirts.destroy(),t.withoutSkirts.destroy()}_fillGridMeshWithLods(t,e){const i=new $l,n=new Kl,r=[],o=t+1+2,s=e[0]+1,a=e[0]+1+(1+e.length),l=(t,e,i)=>{let n=t===o-1?t-2:0===t?t:t-1;return n+=i?24575:0,[n,e]};for(let t=0;tt()))},t.dB=sx,t.dC=yx,t.dD=function(t){px=ki.resolveURL(t),gx||(gx=new ox(ux(),new zn)),gx.broadcast("setDracoUrl",px)},t.dE=vx,t.dF=function(t){mx=ki.resolveURL(t),gx||(gx=new ox(ux(),new zn)),gx.broadcast("setMeshoptUrl",mx)},t.dG=ti,t.dH=ba,t.dI=dh,t.dJ=I_,t.dK=eg,t.dL=dc,t.dM=am,t.dN=Dm,t.dO=Wf,t.dP=ci,t.dQ=E_,t.dR=jg,t.dS=function(t,e,i,n,r,o,s,a,l,c,d){t.createArrays(),t.tilePixelRatio=uo/(512*t.overscaling),t.compareText={},t.iconsNeedLinear=!1;const u=t.layers[0].layout,h=t.layers[0]._unevaluatedLayout._values,p={};if("composite"===t.textSizeData.kind){const{minZoom:e,maxZoom:i}=t.textSizeData;p.compositeTextSizes=[h["text-size"].possiblyEvaluate(new Ha(e),a),h["text-size"].possiblyEvaluate(new Ha(i),a)]}if("composite"===t.iconSizeData.kind){const{minZoom:e,maxZoom:i}=t.iconSizeData;p.compositeIconSizes=[h["icon-size"].possiblyEvaluate(new Ha(e),a),h["icon-size"].possiblyEvaluate(new Ha(i),a)]}p.layoutTextSize=h["text-size"].possiblyEvaluate(new Ha(l+1),a),p.layoutIconSize=h["icon-size"].possiblyEvaluate(new Ha(l+1),a),p.textMaxSize=h["text-size"].possiblyEvaluate(new Ha(18),a);const f="map"===u.get("text-rotation-alignment")&&"point"!==u.get("symbol-placement"),m=u.get("text-size");let _=!1;for(const e of t.features)if(e.icon&&e.icon.nameSecondary){_=!0;break}for(const o of t.features){const l=u.get("text-font").evaluate(o,{},a).join(","),h=m.evaluate(o,{},a),g=p.layoutTextSize.evaluate(o,{},a),y=(p.layoutIconSize.evaluate(o,{},a),{horizontal:{},vertical:void 0}),v=o.text;let x,b=[0,0];if(v){const n=v.toString(),s=u.get("text-letter-spacing").evaluate(o,{},a)*Om,c=u.get("text-line-height").evaluate(o,{},a)*Om,d=Aa(n)?s:0,p=u.get("text-anchor").evaluate(o,{},a),m=u.get("text-variable-anchor");if(!m){const t=u.get("text-radial-offset").evaluate(o,{},a);b=t?G_(p,[t*Om,j_]):u.get("text-offset").evaluate(o,{},a).map((t=>t*Om))}let _=f?"center":u.get("text-justify").evaluate(o,{},a);const x="point"===u.get("symbol-placement"),w=x?u.get("text-max-width").evaluate(o,{},a)*Om:1/0,T=o=>{t.allowVerticalPlacement&&Ca(n)&&(y.vertical=e_(v,e,i,r,l,w,c,p,o,d,b,Jm.vertical,!0,g,h))};if(!f&&m){const t="auto"===_?m.map((t=>Z_(t))):[_];let n=!1;for(let o=0;o=0||!Ca(n)){const t=e_(v,e,i,r,l,w,c,p,_,d,b,Jm.horizontal,!1,g,h);t&&(y.horizontal[_]=t)}T(x?"left":_)}}let w=!1;if(o.icon&&o.icon.namePrimary){const e=n[o.icon.namePrimary];e&&(x=u_(r[o.icon.namePrimary],o.icon.nameSecondary?r[o.icon.nameSecondary]:void 0,u.get("icon-offset").evaluate(o,{},a),u.get("icon-anchor").evaluate(o,{},a)),w=e.sdf,void 0===t.sdfIcons?t.sdfIcons=e.sdf:t.sdfIcons!==e.sdf&&pi("Style sheet warning: Cannot mix SDF and non-SDF icons in one buffer"),(e.pixelRatio!==t.pixelRatio||0!==u.get("icon-rotate").constantOr(1))&&(t.iconsNeedLinear=!0))}const T=X_(y.horizontal)||y.vertical;t.iconsInText||(t.iconsInText=!!T&&T.iconsInText),(T||x)&&q_(t,o,y,x,n,p,g,0,b,w,s,a,c,d,_)}o&&t.generateCollisionDebugBuffers(l,t.collisionBoxArray)},t.dT=Jf,t.dU=Yh,t.dV=bp,t.dW=Lm,t.dX=Yp,t.dY=Zy,t.dZ=wp,t.d_=cp,t.da=Wu,t.db=function(e){const i=[0,0,0],n=t.ad.identity(new Float64Array(16));return t.ad.multiply(n,e.pixelMatrix,e.globeMatrix),t._.transformMat4(i,i,n),new Ue(i[0],i[1])},t.dc=d,t.dd=c,t.de=function(t){const e=t.navigator?t.navigator.userAgent:null;return!!function(t){if(null==Ei){const e=t.navigator?t.navigator.userAgent:null;Ei=!!t.safari||!(!e||!(/\b(iPad|iPhone|iPod)\b/.test(e)||e.match("Safari")&&!e.match("Chrome")))}return Ei}(t)&&e&&(e.match("Version/15.4")||e.match("Version/15.5")||e.match(/CPU (OS|iPhone OS) (15_4|15_5) like Mac OS X/))},t.df=ni,t.dg=class{constructor(t,e,i){this._transformRequestFn=t,this._customAccessToken=e,this._silenceAuthErrors=!!i,this._createSkuToken()}_createSkuToken(){const t=function(){let t="";for(let e=0;ethis._skuTokenExpiresAt}transformRequest(t,e){return this._transformRequestFn&&this._transformRequestFn(t,e)||{url:t}}normalizeStyleURL(t,i){if(!o(t))return t;const n=un(t);return n.params.push(`sdk=js-${e}`),n.path=`/styles/v1${n.path}`,this._makeAPIURL(n,this._customAccessToken||i)}normalizeGlyphsURL(t,e){if(!o(t))return t;const i=un(t);return i.path=`/fonts/v1${i.path}`,this._makeAPIURL(i,this._customAccessToken||e)}normalizeModelURL(t,e){if(!o(t))return t;const i=un(t);return i.path=`/models/v1${i.path}`,this._makeAPIURL(i,this._customAccessToken||e)}normalizeSourceURL(t,e,i,n){if(!o(t))return t;const r=un(t);return r.path=`/v4/${r.authority}.json`,r.params.push("secure"),i&&r.params.push(`language=${i}`),n&&r.params.push(`worldview=${n}`),this._makeAPIURL(r,this._customAccessToken||e)}normalizeSpriteURL(t,e,i,n){const r=un(t);return o(t)?(r.path=`/styles/v1${r.path}/sprite${e}${i}`,this._makeAPIURL(r,this._customAccessToken||n)):(r.path+=`${e}${i}`,hn(r))}normalizeTileURL(t,e,i){if(this._isSkuTokenExpired()&&this._createSkuToken(),t&&!o(t))return t;const r=un(t);r.path=r.path.replace(/(\.(png|jpg)\d*)(?=$)/,`${e||i&&"raster"!==r.authority&&512===i?"@2x":""}${Gi.supported?".webp":"$1"}`),"raster"===r.authority?r.path=`/${n.RASTER_URL_PREFIX}${r.path}`:"rasterarrays"===r.authority?r.path=`/${n.RASTERARRAYS_URL_PREFIX}${r.path}`:"3dtiles"===r.authority?r.path=`/${n.TILES3D_URL_PREFIX}${r.path}`:(r.path=r.path.replace(/^.+\/v4\//,"/"),r.path=`/${n.TILE_URL_VERSION}${r.path}`);const s=this._customAccessToken||function(t){for(const e of t){const t=e.match(/^access_token=(.*)$/);if(t)return t[1]}return null}(r.params)||n.ACCESS_TOKEN;return n.REQUIRE_ACCESS_TOKEN&&s&&this._skuToken&&r.params.push(`sku=${this._skuToken}`),this._makeAPIURL(r,s)}canonicalizeTileURL(t,e){const i=un(t);if(!i.path.match(/^(\/v4\/|\/(raster|rasterarrays)\/v1\/)/)||!i.path.match(/\.[\w]+$/))return t;let r="mapbox://";i.path.match(/^\/raster\/v1\//)?r+=`raster/${i.path.replace(`/${n.RASTER_URL_PREFIX}/`,"")}`:i.path.match(/^\/rasterarrays\/v1\//)?r+=`rasterarrays/${i.path.replace(`/${n.RASTERARRAYS_URL_PREFIX}/`,"")}`:r+=`tiles/${i.path.replace(`/${n.TILE_URL_VERSION}/`,"")}`;let o=i.params;return e&&(o=o.filter((t=>!t.match(/^access_token=/)))),o.length&&(r+=`?${o.join("&")}`),r}canonicalizeTileset(t,e){const i=!!e&&o(e),n=[];for(const e of t.tiles||[])r(e)?n.push(this.canonicalizeTileURL(e,i)):n.push(e);return n}_makeAPIURL(t,e){const i="See https://docs.mapbox.com/api/overview/#access-tokens-and-token-scopes",r=un(n.API_URL);if(t.protocol=r.protocol,t.authority=r.authority,"http"===t.protocol){const e=t.params.indexOf("secure");e>=0&&t.params.splice(e,1)}if("/"!==r.path&&(t.path=`${r.path}${t.path}`),!n.REQUIRE_ACCESS_TOKEN)return hn(t);if(e=e||n.ACCESS_TOKEN,!this._silenceAuthErrors){if(!e)throw new Error(`An API access token is required to use Mapbox GL. ${i}`);if("s"===e[0])throw new Error(`Use a public access token (pk.*) with Mapbox GL, not a secret access token (sk.*). ${i}`)}return t.params=t.params.filter((t=>-1===t.indexOf("access_token"))),t.params.push(`access_token=${e||""}`),hn(t)}},t.dh=function(t,e){e?Mn.add(t):Mn.delete(t)},t.di=Gi,t.dj=Tn,t.dk=En,t.dl=cn,t.dm=vn,t.dn=bn,t.dp=function(t){Mn.delete(t)},t.dq=Sn,t.dr=yn,t.ds=Qe,t.dt=e,t.du=function(t,e){Fi=t,Ni=e},t.dv=function(t,e,i=!1){if(Fa===za||Fa===Ra||Fa===Oa)throw new Error("setRTLTextPlugin cannot be called multiple times.");Na=ki.resolveURL(t),Fa=za,Ba=e,ja(),i||Za()},t.dw=Ga,t.dx=function(){ux().acquire(lx)},t.dy=function(){const t=dx;t&&(t.isPreloaded()&&1===t.numActive()?(t.release(lx),dx=null):console.warn("Could not clear WebWorkers since there are active Map instances that still reference it. The pre-warmed WebWorker pool can only be cleared when all map instances have been removed with map.remove()"))},t.dz=cx,t.e=ki,t.e0=cm,t.e1=h,t.e2=en,t.e3=function(t){let e=0;if(new Uint32Array(t,0,1)[0]!==Ax){const i=new Uint32Array(t,0,7),[,,n,r,o,s]=i;e=i.byteLength+r+o+s+o,(n!==t.byteLength||e>=t.byteLength)&&pi("Invalid b3dm header information.")}return Dx(t,e)},t.e4=function(t,e){const i=jx(t);for(const t of i){for(const e of t.meshes)Vx(e);t.lights&&(t.lightMeshIndex=t.meshes.length,t.meshes.push(Gx(t.lights,e)))}return i},t.e5=Kx,t.e6=rx,t.e7=qa,t.e8=function(t){ji(),Oi&&Oi.then((e=>{e.keys().then((i=>{for(let n=0;nt.arrayBuffer())).then((e=>Dx(e,0,t)))},t.m=class extends Uv{},t.n=Er,t.o=qn,t.p=Qg,t.q=Xs,t.r=Js,t.s=Qs,t.t=ca,t.u=al,t.v=ll,t.w=pi,t.x=pa,t.y=da,t.z=qo})),n(0,(function(t){function e(t){const e=t?t.url.toString():void 0;return e?performance.getEntriesByName(e):[]}function i(t){if("number"==typeof t||"boolean"==typeof t||"string"==typeof t||null==t)return JSON.stringify(t);if(Array.isArray(t)){let e="[";for(const n of t)e+=`${i(n)},`;return`${e}]`}let e="{";for(const n of Object.keys(t).sort())e+=`${n}:${i(t[n])},`;return`${e}}`}function n(e){let n="";for(const r of t.cE)n+=`/${i(e[r])}`;return n}class r{constructor(t){this.keyCache={},this._layers={},this._layerConfigs={},t&&this.replace(t)}replace(t,e){this._layerConfigs={},this._layers={},this.update(t,[],e)}update(e,i,r){this._options=r;for(const i of e)this._layerConfigs[i.id]=i,(this._layers[i.id]=t.cY(i,this.scope,null,this._options)).compileFilter(),this.keyCache[i.id]&&delete this.keyCache[i.id];for(const t of i)delete this.keyCache[t],delete this._layerConfigs[t],delete this._layers[t];this.familiesBySource={};const o=function(t,e){const i={};for(let r=0;rthis._layers[t.id])),i=e[0];if("none"===i.visibility)continue;const n=i.source||"";let r=this.familiesBySource[n];r||(r=this.familiesBySource[n]={});const o=i.sourceLayer||"_geojsonTileLayer";let s=r[o];s||(s=r[o]=[]),s.push(e)}}}const o=1*t.dJ;class s{constructor(e){const i={},n=[];for(const t in e){const r=e[t],s=i[t]={};for(const t in r.glyphs){const e=r.glyphs[+t];if(!e||0===e.bitmap.width||0===e.bitmap.height)continue;const i=e.metrics.localGlyph?o:1,a={x:0,y:0,w:e.bitmap.width+2*i,h:e.bitmap.height+2*i};n.push(a),s[t]=a}}const{w:r,h:s}=t.j(n),a=new t.dI({width:r||1,height:s||1});for(const n in e){const r=e[n];for(const e in r.glyphs){const s=r.glyphs[+e];if(!s||0===s.bitmap.width||0===s.bitmap.height)continue;const l=i[n][e],c=s.metrics.localGlyph?o:1;t.dI.copy(s.bitmap,a,{x:0,y:0},{x:l.x+c,y:l.y+c},s.bitmap)}}this.image=a,this.positions=i}}t.dH(s,"GlyphAtlas");class a{constructor(e){this.tileID=new t.aL(e.tileID.overscaledZ,e.tileID.wrap,e.tileID.canonical.z,e.tileID.canonical.x,e.tileID.canonical.y),this.tileZoom=e.tileZoom,this.uid=e.uid,this.zoom=e.zoom,this.lut=e.lut,this.canonical=e.tileID.canonical,this.pixelRatio=e.pixelRatio,this.tileSize=e.tileSize,this.source=e.source,this.scope=e.scope,this.overscaling=this.tileID.overscaleFactor(),this.showCollisionBoxes=e.showCollisionBoxes,this.collectResourceTiming=!!e.collectResourceTiming,this.promoteId=e.promoteId,this.isSymbolTile=e.isSymbolTile,this.tileTransform=t.dK(e.tileID.canonical,e.projection),this.projection=e.projection,this.brightness=e.brightness,this.extraShadowCaster=!!e.extraShadowCaster,this.tessellationStep=e.tessellationStep}parse(e,i,n,r,o){this.status="parsing",this.data=e,this.collisionBoxArray=new t.dL;const a=new t.dM(Object.keys(e.layers).sort()),c=new t.dN(this.tileID,this.promoteId);c.bucketLayerIDs=[];const d={},u=new t.dO(256,256),h={featureIndex:c,iconDependencies:{},patternDependencies:{},glyphDependencies:{},lineAtlas:u,availableImages:n,brightness:this.brightness},p=i.familiesBySource[this.source];for(const i in p){const r=e.layers[i];if(!r)continue;let o=!1,s=!1,u=!1;for(const t of p[i])"symbol"===t[0].type?o=!0:s=!0,t[0].is3D()&&"model"!==t[0].type&&(u=!0);if(this.extraShadowCaster&&!u)continue;if(!0===this.isSymbolTile&&!o)continue;if(!1===this.isSymbolTile&&!s)continue;1===r.version&&t.w(`Vector tile source "${this.source}" layer "${i}" does not use vector tile spec v2 and therefore may have some rendering errors.`);const f=a.encode(i),m=[];for(let t=0;t=e.maxzoom||"none"!==e.visibility&&(l(t,this.zoom,h.brightness,n),(d[e.id]=e.createBucket({index:c.bucketLayerIDs.length,layers:t,zoom:this.zoom,lut:this.lut,canonical:this.canonical,pixelRatio:this.pixelRatio,overscaling:this.overscaling,collisionBoxArray:this.collisionBoxArray,sourceLayerIndex:f,sourceID:this.source,projection:this.projection.spec,tessellationStep:this.tessellationStep})).populate(m,h,this.tileID.canonical,this.tileTransform),c.bucketLayerIDs.push(t.map((t=>t.id)))))}}let f,m,_,g;u.trim();const y={type:"maybePrepare",isSymbolTile:this.isSymbolTile,zoom:this.zoom},v=()=>{if(f)return this.status="done",o(f);if(this.extraShadowCaster)this.status="done",o(null,{buckets:t.dG(d).filter((t=>!t.isEmpty())),featureIndex:c,collisionBoxArray:null,glyphAtlasImage:null,lineAtlas:null,imageAtlas:null,brightness:h.brightness,glyphMap:null,iconMap:null,glyphPositions:null});else if(m&&_&&g){const e=new s(m),i=new t.dQ(_,g,this.lut);for(const r in d){const o=d[r];o instanceof t.dR?(l(o.layers,this.zoom,h.brightness,n),t.dS(o,m,e.positions,_,i.iconPositions,this.showCollisionBoxes,n,this.tileID.canonical,this.tileZoom,this.projection,this.brightness)):o.hasPattern&&(o instanceof t.dT||o instanceof t.dU||o instanceof t.b_)&&(l(o.layers,this.zoom,h.brightness,n),o.addFeatures(h,this.tileID.canonical,i.patternPositions,n,this.tileTransform,this.brightness))}this.status="done",o(null,{buckets:t.dG(d).filter((t=>!t.isEmpty())),featureIndex:c,collisionBoxArray:this.collisionBoxArray,glyphAtlasImage:e.image,lineAtlas:u,imageAtlas:i,brightness:h.brightness})}};if(!this.extraShadowCaster){const e=t.dP(h.glyphDependencies,(t=>Object.keys(t).map(Number)));Object.keys(e).length?r.send("getGlyphs",{uid:this.uid,stacks:e,scope:this.scope},((t,e)=>{f||(f=t,m=e,v())}),void 0,!1,y):m={};const i=Object.keys(h.iconDependencies);i.length?r.send("getImages",{icons:i,source:this.source,scope:this.scope,tileID:this.tileID,type:"icons"},((t,e)=>{f||(f=t,_=e,v())}),void 0,!1,y):_={};const n=Object.keys(h.patternDependencies);n.length?r.send("getImages",{icons:n,source:this.source,scope:this.scope,tileID:this.tileID,type:"patterns"},((t,e)=>{f||(f=t,g=e,v())}),void 0,!1,y):g={}}v()}}function l(e,i,n,r){const o=new t.X(i,{brightness:n});for(const t of e)t.recalculate(o,r)}class c extends t.E{constructor(e,i,n,r,o,s){super(),this.actor=e,this.layerIndex=i,this.availableImages=n,this.loadVectorData=o||t.ap,this.loading={},this.loaded={},this.deduped=new t.ao(e.scheduler),this.isSpriteLoaded=r,this.scheduler=e.scheduler,this.brightness=s}loadTile(i,n){const r=i.uid,o=i&&i.request,s=o&&o.collectResourceTiming,l=this.loading[r]=new a(i);l.abort=this.loadVectorData(i,((a,c)=>{const d=!this.loading[r];if(delete this.loading[r],d||a||!c)return l.status="done",d||(this.loaded[r]=l),n(a);const u=c.rawData,h={};c.expires&&(h.expires=c.expires),c.cacheControl&&(h.cacheControl=c.cacheControl),l.vectorTile=c.vectorTile||new t.dV(new t.dW(u));const p=()=>{l.parse(l.vectorTile,this.layerIndex,this.availableImages,this.actor,((i,r)=>{if(i||!r)return n(i);const a={};if(s){const t=e(o);t.length>0&&(a.resourceTiming=JSON.parse(JSON.stringify(t)))}n(null,t.W({rawTileData:u.slice(0)},r,h,a))}))};this.isSpriteLoaded?p():this.once("isSpriteLoaded",(()=>{this.scheduler?this.scheduler.add(p,{type:"parseTile",isSymbolTile:i.isSymbolTile,zoom:i.tileZoom}):p()})),this.loaded=this.loaded||{},this.loaded[r]=l}))}reloadTile(e,i){const n=this.loaded,r=e.uid;if(n&&n[r]){const o=n[r];o.showCollisionBoxes=e.showCollisionBoxes,o.projection=e.projection,o.brightness=e.brightness,o.tileTransform=t.dK(e.tileID.canonical,e.projection),o.extraShadowCaster=e.extraShadowCaster,o.lut=e.lut;const s=(t,e)=>{const n=o.reloadCallback;n&&(delete o.reloadCallback,o.parse(o.vectorTile,this.layerIndex,this.availableImages,this.actor,n)),i(t,e)};"parsing"===o.status?o.reloadCallback=s:"done"===o.status&&(o.vectorTile?o.parse(o.vectorTile,this.layerIndex,this.availableImages,this.actor,s):s())}else i(null,void 0)}abortTile(t,e){const i=t.uid,n=this.loading[i];n&&(n.abort&&n.abort(),delete this.loading[i]),e()}removeTile(t,e){const i=this.loaded,n=t.uid;i&&i[n]&&delete i[n],e()}}class d{loadTile(e,i){const{uid:n,encoding:r,rawImageData:o,padding:s}=e,a=ImageBitmap&&o instanceof ImageBitmap?this.getImageData(o,s):o;i(null,new t.dX(n,a,r,s{n(null,t)}),(t=>{n(t)}))}}const h=t.dZ.prototype.toGeoJSON;let p=class{constructor(e){this._feature=e,this.extent=t.a3,this.type=e.type,this.properties=e.tags,"id"in e&&!isNaN(e.id)&&(this.id=parseInt(e.id,10))}loadGeometry(){if(1===this._feature.type){const e=[];for(const i of this._feature.geometry)e.push([new t.P(i[0],i[1])]);return e}{const e=[];for(const i of this._feature.geometry){const n=[];for(const e of i)n.push(new t.P(e[0],e[1]));e.push(n)}return e}}toGeoJSON(t,e,i){return h.call(this,t,e,i)}},f=class{constructor(e){this.layers={_geojsonTileLayer:this},this.name="_geojsonTileLayer",this.extent=t.a3,this.length=e.length,this._features=e}feature(t){return new p(this._features[t])}};const m=64/4096;class _{constructor(){this.features=new Map}clear(){this.features.clear()}load(t=[],e){for(const i of t){const t=i.id;if(null==t)continue;let n=this.features.get(t);n&&this.updateCache(n,e),i.geometry?(n=y(i),this.updateCache(n,e),this.features.set(t,n)):this.features.delete(t),this.updateCache(n,e)}}updateCache(t,e){for(const{canonical:i,uid:n}of Object.values(e)){const{z:r,x:o,y:s}=i;g(t,Math.pow(2,r),o,s)&&delete e[n]}}getTile(t,e,i){const n=Math.pow(2,t),r=[];for(const t of this.features.values())g(t,n,e,i)&&r.push(w(t,n,e,i));return{features:r}}getFeatures(){return[...this.features.values()]}}function g({minX:t,minY:e,maxX:i,maxY:n},r,o,s){return t(o-m)/r&&n>(s-m)/r}function y(t){const{id:e,geometry:i,properties:n}=t;if(!i)return;if("GeometryCollection"===i.type)throw new Error("GeometryCollection not supported in dynamic mode.");const{type:r,coordinates:o}=i,s={id:e,type:1,geometry:[],tags:n,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0},a=s.geometry;if("Point"===r)v(o,a,s);else if("MultiPoint"===r)for(const t of o)v(t,a,s);else if("LineString"===r)s.type=2,x(o,a,s);else if("MultiLineString"===r)s.type=2,b(o,a,s);else if("Polygon"===r)s.type=3,b(o,a,s,!0);else{if("MultiPolygon"!==r)throw new Error("Input data is not a valid GeoJSON object.");s.type=3;for(const t of o)b(t,a,s,!0)}return s}function v([e,i],n,r){const o=t.aj(e);let s=t.ak(i);s=s1?1:s,n.push(o,s),r.minX=Math.min(r.minX,o),r.minY=Math.min(r.minY,s),r.maxX=Math.max(r.maxX,o),r.maxY=Math.max(r.maxY,s)}function x(t,e,i,n=!1,r=!1){const o=[];for(const e of t)v(e,o,i);e.push(o),n&&function(t,e){let i=0;for(let e=0,n=t.length,r=n-2;e0===e)for(let e=0,i=t.length;e>31}function F(t,e){for(var i=t.loadGeometry(),n=t.type,r=0,o=0,s=i.length,a=0;at},V=Math.fround||(G=new Float32Array(1),t=>(G[0]=+t,G[0]));var G;const Z=3,q=5,H=6;class W{constructor(t){this.options=Object.assign(Object.create(j),t),this.trees=new Array(this.options.maxZoom+1),this.stride=this.options.reduce?7:6,this.clusterProps=[]}load(t){const{log:e,minZoom:i,maxZoom:n}=this.options;e&&console.time("total time");const r=`prepare ${t.length} points`;e&&console.time(r),this.points=t;const o=[];for(let e=0;e=i;t--){const i=+Date.now();s=this.trees[t]=this._createTree(this._cluster(s,t)),e&&console.log("z%d: %d clusters in %dms",t,s.numItems,+Date.now()-i)}return e&&console.timeEnd("total time"),this}getClusters(t,e){let i=((t[0]+180)%360+360)%360-180;const n=Math.max(-90,Math.min(90,t[1]));let r=180===t[2]?180:((t[2]+180)%360+360)%360-180;const o=Math.max(-90,Math.min(90,t[3]));if(t[2]-t[0]>=360)i=-180,r=180;else if(i>r){const t=this.getClusters([i,n,180,o],e),s=this.getClusters([-180,n,r,o],e);return t.concat(s)}const s=this.trees[this._limitZoom(e)],a=s.range(K(i),J(o),K(r),J(n)),l=s.data,c=[];for(const t of a){const e=this.stride*t;c.push(l[e+q]>1?Y(l,e,this.clusterProps):this.points[l[e+Z]])}return c}getChildren(t){const e=this._getOriginId(t),i=this._getOriginZoom(t),n="No cluster with the specified id.",r=this.trees[i];if(!r)throw new Error(n);const o=r.data;if(e*this.stride>=o.length)throw new Error(n);const s=this.options.radius/(this.options.extent*Math.pow(2,i-1)),a=r.within(o[e*this.stride],o[e*this.stride+1],s),l=[];for(const e of a){const i=e*this.stride;o[i+4]===t&&l.push(o[i+q]>1?Y(o,i,this.clusterProps):this.points[o[i+Z]])}if(0===l.length)throw new Error(n);return l}getLeaves(t,e,i){const n=[];return this._appendLeaves(n,t,e=e||10,i=i||0,0),n}getTile(t,e,i){const n=this.trees[this._limitZoom(t)],r=Math.pow(2,t),{extent:o,radius:s}=this.options,a=s/o,l=(i-a)/r,c=(i+1+a)/r,d={features:[]};return this._addTileFeatures(n.range((e-a)/r,l,(e+1+a)/r,c),n.data,e,i,r,d),0===e&&this._addTileFeatures(n.range(1-a/r,l,1,c),n.data,r,i,r,d),e===r-1&&this._addTileFeatures(n.range(0,l,a/r,c),n.data,-1,i,r,d),d.features.length?d:null}getClusterExpansionZoom(t){let e=this._getOriginZoom(t)-1;for(;e1;let l,c,d;if(a)l=X(e,t,this.clusterProps),c=e[t],d=e[t+1];else{const i=this.points[e[t+Z]];l=i.properties;const[n,r]=i.geometry.coordinates;c=K(n),d=J(r)}const u={type:1,geometry:[[Math.round(this.options.extent*(c*r-i)),Math.round(this.options.extent*(d*r-n))]],tags:l};let h;h=a||this.options.generateId?e[t+Z]:this.points[e[t+Z]].id,void 0!==h&&(u.id=h),o.features.push(u)}}_limitZoom(t){return Math.max(this.options.minZoom,Math.min(Math.floor(+t),this.options.maxZoom+1))}_cluster(t,e){const{radius:i,extent:n,reduce:r,minPoints:o}=this.options,s=i/(n*Math.pow(2,e)),a=t.data,l=[],c=this.stride;for(let i=0;ie&&(p+=a[i+q])}if(p>h&&p>=o){let t,o=n*h,s=d*h,f=-1;const m=(i/c1)for(const t of u){const i=t*c;if(!(a[i+2]>5}_getOriginZoom(t){return(t-this.points.length)%32}_map(t,e,i){if(t[e+q]>1){const n=this.clusterProps[t[e+H]];return i?Object.assign({},n):n}const n=this.points[t[e+Z]].properties,r=this.options.map(n);return i&&r===n?Object.assign({},r):r}}function Y(t,e,i){return{type:"Feature",id:t[e+Z],properties:X(t,e,i),geometry:{type:"Point",coordinates:[(n=t[e],360*(n-.5)),Q(t[e+1])]}};var n}function X(t,e,i){const n=t[e+q],r=n>=1e4?`${Math.round(n/1e3)}k`:n>=1e3?Math.round(n/100)/10+"k":n,o=t[e+H],s=-1===o?{}:Object.assign({},i[o]);return Object.assign(s,{cluster:!0,cluster_id:t[e+Z],point_count:n,point_count_abbreviated:r})}function K(t){return t/360+.5}function J(t){const e=Math.sin(t*Math.PI/180),i=.5-.25*Math.log((1+e)/(1-e))/Math.PI;return i1?1:i}function Q(t){const e=(180-360*t)*Math.PI/180;return 360*Math.atan(Math.exp(e))/Math.PI-90}function tt(t,e,i,n){let r=n;const o=e+(i-e>>1);let s,a=i-e;const l=t[e],c=t[e+1],d=t[i],u=t[i+1];for(let n=e+3;n = ${i} but got buffer of length ${e.length}`);const n=function(t){return t.readFields(iy,{header_length:0,x:0,y:0,z:0,layers:[]},void 0)}(new Lm(e.subarray(0,i)));if(!isNaN(this.x)&&(this.x!==n.x||this.y!==n.y||this.z!==n.z))throw new fy(`Invalid attempt to parse header ${n.z}/${n.x}/${n.y} for tile ${this.z}/${this.x}/${this.y}`);this.x=n.x,this.y=n.y,this.z=n.z;for(const t of n.layers)this.layers[t.name]=new qy(t,{cacheSize:this._cacheSize});return this}createDecodingTask(t){const e=[],i=this.getLayer(t.layerName);for(let n=0;nt.lastBlock)continue;if(i._blocksInProgress.has(n))continue;const a={layerName:i.name,firstByte:o,lastByte:s,pixelFormat:i.pixelFormat,blockIndex:n,blockShape:[r.bands.length].concat(i.bandShape),buffer:i.buffer,codec:r.codec.codec,filters:r.filters.map((t=>t.filter))};i._blocksInProgress.add(n),e.push(a)}return new Hy(e,(()=>{e.forEach((t=>i._blocksInProgress.delete(t.blockIndex)))}),((t,n)=>{if(e.forEach((t=>i._blocksInProgress.delete(t.blockIndex))),t)throw t;n.forEach((t=>{this.getLayer(t.layerName).processDecodedData(t)}))}))}}class qy{constructor({version:t,name:e,units:i,tilesize:n,pixel_format:r,buffer:o,data_index:s},a){if(this.version=t,1!==this.version)throw new fy(`Cannot parse raster layer encoded with MRT version ${t}`);this.name=e,this.units=i,this.tileSize=n,this.buffer=o,this.pixelFormat=jy[r],this.dataIndex=s,this.bandShape=[n+2*o,n+2*o,Vy[this.pixelFormat]],this._decodedBlocks=function(t=1e3,e=0,i=!1){if(isNaN(t)||t=e&&t=0}hasDataForBand(t){const{blockIndex:e}=this.getBlockForBand(t);return e>=0&&!!this._decodedBlocks.get(e.toString())}getBandView(t){const{blockIndex:e,blockBandIndex:i}=this.getBlockForBand(t),n=this._decodedBlocks.get(e.toString());if(!n)throw new fy(`Data for band ${JSON.stringify(t)} of layer "${this.name}" not decoded.`);const r=this.dataIndex[e],o=this.bandShape.reduce(((t,e)=>t*e),1),s=i*o,a=n.subarray(s,s+o);return{data:a,bytes:new Uint8Array(a.buffer).subarray(a.byteOffset,a.byteOffset+a.byteLength),tileSize:this.tileSize,buffer:this.buffer,offset:r.offset,scale:r.scale}}}class Hy{constructor(t,e,i){this.tasks=t,this._onCancel=e,this._onComplete=i,this._finalized=!1}cancel(){this._finalized||(this._onCancel(),this._finalized=!0)}complete(t,e){this._finalized||(this._onComplete(t,e),this._finalized=!0)}}Zy.performDecoding=function(t,e){return Promise.all(e.tasks.map((e=>{const{layerName:i,firstByte:n,lastByte:r,pixelFormat:o,blockShape:s,blockIndex:a,filters:l,codec:c}=e,d=new Uint8Array(t).subarray(n,r+1),u=new Uint32Array(s[0]*s[1]*s[2]);let h;if("gzip_data"!==c)throw new Error(`Unhandled codec: ${c}`);return h=function(t,e){if(!globalThis.DecompressionStream&&"gzip_data"===e)return Promise.resolve(((o=function(t){31==t[0]&&139==t[1]&&8==t[2]||By(6,"invalid gzip data");var e=t[3],i=10;4&e&&(i+=2+(t[10]|t[11]>3&1)+(e>>4&1);n>0;n-=!t[i++]);return i+(2&e)}(r=t))+8>r.length&&By(6,"invalid gzip data"),function(t,e,i){var n=t.length;if(!n||e.f&&!e.l)return i||new my(0);var r=!i,o=r||2!=e.i,s=e.i;r&&(i=new my(3*n));var a,l,c=function(t){var e=i.length;if(t>e){var n=new my(Math.max(2*e,t));n.set(i),i=n}},d=e.f||0,u=e.p||0,h=e.b||0,p=e.l,f=e.d,m=e.m,_=e.n,g=8*n;do{if(!p){d=zy(t,u,1);var y=zy(t,u+1,3);if(u+=3,!y){var v=t[(L=4+((u+7)/8|0))-4]|t[L-3]n){s&&By(0);break}o&&c(h+v),i.set(t.subarray(L,x),h),e.b=h+=v,e.p=u=8*x,e.f=d;continue}if(1==y)p=$y,f=ky,m=9,_=5;else if(2==y){var b=zy(t,u,31)+257,w=zy(t,u+10,15)+4,T=b+zy(t,u+5,31)+1;u+=14;for(var S=new my(T),E=new my(19),M=0;M>4)g){s&&By(0);break}}o&&c(h+131072);for(var R=(1>4;if((u+=15&$)>g){s&&By(0);break}if($||By(2),F264&&(N=zy(t,u,(1>4;if(U||By(3),u+=15&U,z=Ey[j],j>3){var V=vy[j];z+=Ry(t,u)&(1g){s&&By(0);break}o&&c(h+131072);var G=h+N;if(ha.length)&&(l=a.length),new my(a.subarray(0,l))):i.subarray(0,h)}(r.subarray(o,-8),{i:2},new my(((i=r)[(n=i.length)-4]|i[n-3]>>0))));var i,n,r,o;const s=Uy[e];if(!s)throw new Error(`Unhandled codec: ${e}`);const a=new globalThis.DecompressionStream(s);return new Response(new Blob([t]).stream().pipeThrough(a)).arrayBuffer().then((t=>new Uint8Array(t)))}(d,c).then((t=>(function(t,e){t.readFields(ly,e)}(new Lm(t),u),new(0,Gy[o])(u.buffer)))),h.then((t=>{for(let e=l.length-1;e>=0;e--)switch(l[e]){case"delta_filter":uy(t,s);break;case"zigzag_filter":hy(t);break;case"bitshuffle_filter":py(t,o);break;default:throw new Error(`Unhandled filter "${l[e]}"`)}return{layerName:i,blockIndex:a,data:t}})).catch((t=>{throw t}))})))};class Wy extends ey{constructor(t,e,i,n,r){super(t,e,i,n,r),this._workQueue=[],this._fetchQueue=[],this._isHeaderLoaded=!1}setTexture(t,e){const i=e.context,n=i.gl;this.texture=this.texture||e.getTileTexture(t.width),this.texture&&this.texture instanceof Vg?this.texture.update(t,{useMipmap:!1,premultiply:!1}):this.texture=new Vg(i,t,n.RGBA,{useMipmap:!1,premultiply:!1})}flushQueues(){for(;this._workQueue.length;)this._workQueue.pop()();for(;this._fetchQueue.length;)this._fetchQueue.pop()()}fetchHeader(t=16384,e){const i=this._mrt=new Zy(30),n=Object.assign({},this.requestParams,{headers:{Range:"bytes=0-"+(t-1)}});return this.entireBuffer=null,this.request=en(n,((n,r,o,s)=>{if(n)e(n);else try{const n=i.getHeaderLength(r);if(n>t)return void(this.request=this.fetchHeader(n,e));i.parseHeader(r),this._isHeaderLoaded=!0;let a=0;for(const t of Object.values(i.layers))a=Math.max(a,t.dataIndex[t.dataIndex.length-1].last_byte);r.byteLength>=a&&(this.entireBuffer=r),e(null,this.entireBuffer||r,o,s)}catch(t){e(t)}})),this.request}fetchBand(t,e,i){const n=this._mrt;if(!this._isHeaderLoaded||!n)return void i(new Error("Tile header is not ready"));const r=this.actor;if(!r)return void i(new Error("Can't fetch tile band without an actor"));let o;const s=(n,r)=>{o.complete(n,r),n?i(n):(this.updateTextureDescriptor(t,e),i(null,this.textureDescriptor&&this.textureDescriptor.img))},a=(t,e)=>{if(t)return i(t);const n=r.send("decodeRasterArray",{buffer:e,task:o},s,void 0,!0);this._workQueue.push((()=>{n&&n.cancel(),o.cancel()}))},l=n.getLayer(t);if(!l)return void i(new Error(`Unknown sourceLayer "${t}"`));if(l.hasDataForBand(e))return this.updateTextureDescriptor(t,e),void i(null,this.textureDescriptor?this.textureDescriptor.img:null);const c=l.getDataRange([e]);if(o=n.createDecodingTask(c),!o||o.tasks.length)if(this.flushQueues(),this.entireBuffer)a(null,this.entireBuffer.slice(c.firstByte,c.lastByte+1));else{const t=Object.assign({},this.requestParams,{headers:{Range:`bytes=${c.firstByte}-${c.lastByte}`}}),e=en(t,a);this._fetchQueue.push((()=>{e.cancel(),o.cancel()}))}else i(null)}updateNeeded(t,e){return(!this.textureDescriptor||this.textureDescriptor.band!==e||this.textureDescriptor.layer!==t)&&"errored"!==this.state}updateTextureDescriptor(t,e){if(!this._mrt)return;const i=this._mrt.getLayer(t);if(!i||!i.hasBand(e)||!i.hasDataForBand(e))return;const{bytes:n,tileSize:r,buffer:o,offset:s,scale:a}=i.getBandView(e),l=r+2*o,c={data:n,width:l,height:l},d=this.texture;d&&d instanceof Vg&&d.update(c,{useMipmap:!1,premultiply:!1}),this.textureDescriptor={layer:t,band:e,img:c,buffer:o,offset:s,tileSize:r,format:i.pixelFormat,mix:[a,256*a,65536*a,16777216*a]}}}class Yy{constructor(t,e){this.max=t,this.onRemove=e,this.reset()}reset(){for(const t in this.data)for(const e of this.data[t])e.timeout&&clearTimeout(e.timeout),this.onRemove(e.value);return this.data={},this.order=[],this}add(t,e,i){const n=t.wrapped().key;void 0===this.data[n]&&(this.data[n]=[]);const r={value:e,timeout:void 0};if(void 0!==i&&(r.timeout=setTimeout((()=>{this.remove(t,r)}),i)),this.data[n].push(r),this.order.push(n),this.order.length>this.max){const t=this._getAndRemoveByKey(this.order[0]);t&&this.onRemove(t)}return this}has(t){return t.wrapped().key in this.data}getAndRemove(t){return this.has(t)?this._getAndRemoveByKey(t.wrapped().key):null}_getAndRemoveByKey(t){const e=this.data[t].shift();return e.timeout&&clearTimeout(e.timeout),0===this.data[t].length&&delete this.data[t],this.order.splice(this.order.indexOf(t),1),e.value}getByKey(t){const e=this.data[t];return e?e[0].value:null}get(t){return this.has(t)?this.data[t.wrapped().key][0].value:null}remove(t,e){if(!this.has(t))return this;const i=t.wrapped().key,n=void 0===e?0:this.data[i].indexOf(e),r=this.data[i][n];return this.data[i].splice(n,1),r.timeout&&clearTimeout(r.timeout),0===this.data[i].length&&delete this.data[i],this.onRemove(r.value),this.order.splice(this.order.indexOf(i),1),this}setMaxSize(t){for(this.max=t;this.order.length>this.max;){const t=this._getAndRemoveByKey(this.order[0]);t&&this.onRemove(t)}return this}filter(t){const e=[];for(const i in this.data)for(const n of this.data[i])t(n.value)||e.push(n);for(const t of e)this.remove(t.value.tileID,t)}}class Xy extends zn{constructor(t,e,i){super(),this.id=t,this._onlySymbols=i,e.on("data",(t=>{"source"===t.dataType&&"metadata"===t.sourceDataType&&(this._sourceLoaded=!0),this._sourceLoaded&&!this._paused&&"source"===t.dataType&&"content"===t.sourceDataType&&(this.reload(),this.transform&&this.update(this.transform))})),e.on("error",(()=>{this._sourceErrored=!0})),this._source=e,this._tiles={},this._cache=new Yy(0,this._unloadTile.bind(this)),this._timers={},this._cacheTimers={},this._minTileCacheSize=e.minTileCacheSize,this._maxTileCacheSize=e.maxTileCacheSize,this._loadedParentTiles={},this.castsShadows=!1,this.tileCoverLift=0,this._coveredTiles={},this._shadowCasterTiles={},this._state=new km,this._isRaster="raster"===this._source.type||"raster-dem"===this._source.type||"raster-array"===this._source.type||"custom"===this._source.type&&"raster"===this._source._dataType}onAdd(t){this.map=t,this._minTileCacheSize=void 0===this._minTileCacheSize&&t?t._minTileCacheSize:this._minTileCacheSize,this._maxTileCacheSize=void 0===this._maxTileCacheSize&&t?t._maxTileCacheSize:this._maxTileCacheSize}loaded(){if(this._sourceErrored)return!0;if(!this._sourceLoaded)return!1;if(!this._source.loaded())return!1;for(const t in this._tiles){const e=this._tiles[t];if("errored"!==e.state&&("loaded"!==e.state||!e.bucketsLoaded()))return!1}return!0}getSource(){return this._source}pause(){this._paused=!0}resume(){if(!this._paused)return;const t=this._shouldReloadOnResume;this._paused=!1,this._shouldReloadOnResume=!1,t&&this.reload(),this.transform&&this.update(this.transform)}_loadTile(t,e){return t.isSymbolTile=this._onlySymbols,t.isExtraShadowCaster=this._shadowCasterTiles[t.tileID.key],this._source.loadTile(t,e)}_unloadTile(t){if(this._source.unloadTile)return this._source.unloadTile(t)}_abortTile(t){if(this._source.abortTile)return this._source.abortTile(t)}serialize(){return this._source.serialize()}prepare(t){this._source.prepare&&this._source.prepare(),this._state.coalesceChanges(this._tiles,this.map?this.map.painter:null);for(const e in this._tiles){const i=this._tiles[e];i.upload(t),i.prepare(this.map.style.imageManager,this.map?this.map.painter:null,this._source.scope)}}getIds(){return ti(this._tiles).map((t=>t.tileID)).sort(Ky).map((t=>t.key))}getRenderableIds(t,e){const i=[];for(const n in this._tiles)this._isIdRenderable(+n,t,e)&&i.push(this._tiles[n]);return t?i.sort(((t,e)=>{const i=t.tileID,n=e.tileID,r=new Ue(i.canonical.x,i.canonical.y)._rotate(this.transform.angle),o=new Ue(n.canonical.x,n.canonical.y)._rotate(this.transform.angle);return i.overscaledZ-n.overscaledZ||o.y-r.y||o.x-r.x})).map((t=>t.tileID.key)):i.map((t=>t.tileID)).sort(Ky).map((t=>t.key))}hasRenderableParent(t){const e=this.findLoadedParent(t,0);return!!e&&this._isIdRenderable(e.tileID.key)}_isIdRenderable(t,e,i){return this._tiles[t]&&this._tiles[t].hasData()&&!this._coveredTiles[t]&&(e||!this._tiles[t].holdingForFade())&&(i||!this._shadowCasterTiles[t])}reload(){if(this._paused)this._shouldReloadOnResume=!0;else{this._cache.reset();for(const t in this._tiles)"errored"!==this._tiles[t].state&&this._reloadTile(+t,"reloading")}}_reloadTile(t,e){const i=this._tiles[t];i&&("loading"!==i.state&&(i.state=e),this._loadTile(i,this._tileLoaded.bind(this,i,t,e)))}_tileLoaded(t,e,i,n){if(n)if(t.state="errored",404!==n.status)this._source.fire(new $n(n,{tile:t}));else{if(!(t.tileID.key in this._loadedParentTiles))return void this._source.fire(new Pn("data",{dataType:"source",sourceDataType:"error",sourceId:this._source.id}));if("raster-dem"===this._source.type&&this.usedForTerrain&&this.map.painter.terrain){const t=this.map.painter.terrain;this.update(this.transform,t.getScaledDemTileSize(),!0),t.resetTileLookupCache(this.id)}else this.update(this.transform)}else t.timeAdded=ki.now(),"expired"===i&&(t.refreshedUponExpiration=!0),this._setTileReloadTimer(e,t),"raster-dem"===this._source.type&&t.dem&&this._backfillDEM(t),this._state.initializeTileState(t,this.map?this.map.painter:null),this._source.fire(new Pn("data",{dataType:"source",tile:t,coord:t.tileID,sourceCacheId:this.id}))}_backfillDEM(t){const e=this.getRenderableIds();for(let n=0;n1||(Math.abs(i)>1&&(1===Math.abs(i+r)?i+=r:1===Math.abs(i-r)&&(i-=r)),e.dem&&t.dem&&(t.dem.backfillBorder(e.dem,i,n),t.neighboringTiles&&t.neighboringTiles[o]&&(t.neighboringTiles[o].backfilled=!0)))}}getTile(t){return this.getTileByID(t.key)}getTileByID(t){return this._tiles[t]}_retainLoadedChildren(t,e,i,n){for(const r in this._tiles){let o=this._tiles[r];if(n[r]||!o.hasData()||o.tileID.overscaledZi)continue;let s=o.tileID;for(;o&&o.tileID.overscaledZ>e+1;){const t=o.tileID.scaledTo(o.tileID.overscaledZ-1);o=this._tiles[t.key],o&&o.hasData()&&(s=t)}let a=s;for(;a.overscaledZ>e;)if(a=a.scaledTo(a.overscaledZ-1),t[a.key]){n[s.key]=s;break}}}findLoadedParent(t,e){if(t.key in this._loadedParentTiles){const i=this._loadedParentTiles[t.key];return i&&i.tileID.overscaledZ>=e?i:null}for(let i=t.overscaledZ-1;i>=e;i--){const e=t.scaledTo(i),n=this._getLoadedTile(e);if(n)return n}}_getLoadedTile(t){const e=this._tiles[t.key];return e&&e.hasData()?e:this._cache.getByKey(this._source.reparseOverscaled?t.wrapped().key:t.canonical.key)}updateCacheSize(t,e){e=e||this._source.tileSize;const i=Math.ceil(t.width/e)+1,n=Math.ceil(t.height/e)+1,r=Math.floor(i*n*5),o="number"==typeof this._minTileCacheSize?Math.max(this._minTileCacheSize,r):r,s="number"==typeof this._maxTileCacheSize?Math.min(this._maxTileCacheSize,o):o;this._cache.setMaxSize(s)}handleWrapJump(t){const e=Math.round((t-(void 0===this._prevLng?t:this._prevLng))/360);if(this._prevLng=t,e){const t={};for(const i in this._tiles){const n=this._tiles[i];n.tileID=n.tileID.unwrapTo(n.tileID.wrap+e),t[n.tileID.key]=n}this._tiles=t;for(const t in this._timers)clearTimeout(this._timers[t]),delete this._timers[t];for(const t in this._tiles)this._setTileReloadTimer(+t,this._tiles[t])}}update(t,e,i,n){if(this.transform=t,!this._sourceLoaded||this._paused||this.transform.freezeTileCoverage)return;if(this.usedForTerrain&&!i)return;let r;if(this.updateCacheSize(t,e),"globe"!==this.transform.projection.name&&this.handleWrapJump(this.transform.center.lng),this._shadowCasterTiles={},this._coveredTiles={},this.used||this.usedForTerrain){if(this._source.tileID)r=t.getVisibleUnwrappedCoordinates(this._source.tileID).map((t=>new vd(t.canonical.z,t.wrap,t.canonical.z,t.canonical.x,t.canonical.y)));else if(0!==this.tileCoverLift){const n=t.clone();n.tileCoverLift=this.tileCoverLift,r=n.coveringTiles({tileSize:e||this._source.tileSize,minzoom:this._source.minzoom,maxzoom:this._source.maxzoom,roundZoom:this._source.roundZoom&&!i,reparseOverscaled:this._source.reparseOverscaled,isTerrainDEM:this.usedForTerrain}),this._source.minzoomt(e)))}}else r=[];if(r.length>0&&this.castsShadows&&n&&"globe"!==this.transform.projection.name&&!this.usedForTerrain&&!Jy(this._source.type)){const o=t.coveringZoomLevel({tileSize:e||this._source.tileSize,roundZoom:this._source.roundZoom&&!i}),s=Math.min(o,this._source.maxzoom),a=t.extendTileCoverForShadows(r,n,s);for(const t of a)this._shadowCasterTiles[t.key]=!0,r.push(t)}const o=this._updateRetainedTiles(r);if(Jy(this._source.type)&&0!==r.length){const t={},e={},i=Object.keys(o);for(const n of i){const i=o[n],r=this._tiles[n];if(!r||r.fadeEndTime&&r.fadeEndTimen;){r=r.scaledTo(r.overscaledZ-1);const n=this._tiles[r.key];if(n&&n.hasData()&&e[r.key]){o[t]=i.tileID;break}}}for(const e in t)o[e]||(this._coveredTiles[e]=!0,o[e]=t[e])}for(const t in o)this._tiles[t].clearFadeHold();const s=function(t,e){const i=[];for(const n in t)n in e||i.push(n);return i}(this._tiles,o);for(const t of s){const e=this._tiles[t];e.hasSymbolBuckets&&!e.holdingForFade()?e.setHoldDuration(this.map._fadeDuration):e.hasSymbolBuckets&&!e.symbolFadeFinished()||this._removeTile(+t)}this._updateLoadedParentTileCache(),this._onlySymbols&&this._source.afterUpdate&&this._source.afterUpdate()}releaseSymbolFadeTiles(){for(const t in this._tiles)this._tiles[t].holdingForFade()&&this._removeTile(+t)}_updateRetainedTiles(t){const e={};if(0===t.length)return e;const i={},n=t.reduce(((t,e)=>Math.min(t,e.overscaledZ)),1/0),r=t[0].overscaledZ,o=Math.max(r-Xy.maxOverzooming,this._source.minzoom),s=Math.max(r+Xy.maxUnderzooming,this._source.minzoom),a={};for(const i of t){const t=this._addTile(i);e[i.key]=i,t.hasData()||n=this._source.maxzoom){const t=n.children(this._source.maxzoom)[0],i=this.getTile(t);if(i&&i.hasData()){e[t.key]=t;continue}}else{const t=n.children(this._source.maxzoom);if(e[t[0].key]&&e[t[1].key]&&e[t[2].key]&&e[t[3].key])continue}let r=t.wasRequested();for(let s=n.overscaledZ-1;s>=o;--s){const o=n.scaledTo(s);if(i[o.key])break;if(i[o.key]=!0,t=this.getTile(o),!t&&r&&(t=this._addTile(o)),t&&(e[o.key]=o,r=t.wasRequested(),t.hasData()))break}}return e}_updateLoadedParentTileCache(){this._loadedParentTiles={};for(const t in this._tiles){const e=[];let i,n=this._tiles[t].tileID;for(;n.overscaledZ>0;){if(n.key in this._loadedParentTiles){i=this._loadedParentTiles[n.key];break}e.push(n.key);const t=n.scaledTo(n.overscaledZ-1);if(i=this._getLoadedTile(t),i)break;n=t}for(const t of e)this._loadedParentTiles[t]=i}}_addTile(t){let e=this._tiles[t.key];if(e)return!0!==e.isExtraShadowCaster||!!this._shadowCasterTiles[t.key]||this._reloadTile(t.key,"reloading"),e;e=this._cache.getAndRemove(t),e&&(this._setTileReloadTimer(t.key,e),e.tileID=t,this._state.initializeTileState(e,this.map?this.map.painter:null),this._cacheTimers[t.key]&&(clearTimeout(this._cacheTimers[t.key]),delete this._cacheTimers[t.key],this._setTileReloadTimer(t.key,e)));const i=Boolean(e);if(!i){const i=this.map?this.map.painter:null,n=this._source.tileSize*t.overscaleFactor();e="raster-array"===this._source.type?new Wy(t,n,this.transform.tileZoom,i,this._isRaster):new ey(t,n,this.transform.tileZoom,i,this._isRaster),this._loadTile(e,this._tileLoaded.bind(this,e,t.key,e.state))}return e?(e.uses++,this._tiles[t.key]=e,i||this._source.fire(new Pn("dataloading",{tile:e,coord:e.tileID,dataType:"source"})),e):null}_setTileReloadTimer(t,e){t in this._timers&&(clearTimeout(this._timers[t]),delete this._timers[t]);const i=e.getExpiryTimeout();i&&(this._timers[t]=setTimeout((()=>{this._reloadTile(t,"expired"),delete this._timers[t]}),i))}_removeTile(t){const e=this._tiles[t];e&&(e.uses--,delete this._tiles[t],this._timers[t]&&(clearTimeout(this._timers[t]),delete this._timers[t]),e.uses>0||(e.hasData()&&"reloading"!==e.state||"empty"===e.state?this._cache.add(e.tileID,e,e.getExpiryTimeout()):(e.aborted=!0,this._abortTile(e),this._unloadTile(e))))}clearTiles(){this._shouldReloadOnResume=!1,this._paused=!1;for(const t in this._tiles)this._removeTile(+t);this._source._clear&&this._source._clear(),this._cache.reset(),this.map&&this.usedForTerrain&&this.map.painter.terrain&&this.map.painter.terrain.resetTileLookupCache(this.id)}tilesIn(t,e,i){const n=[],r=this.transform;if(!r)return n;const o="globe"===r.projection.name,s=Ed(r.center.lng);for(const a in this._tiles){const l=this._tiles[a];if(i&&l.clearQueryDebugViz(),l.holdingForFade())continue;let c;if(o){const t=l.tileID.canonical;if(0===t.z){const e=[Math.abs(Xe(s,...Qy(t,-1))-s),Math.abs(Xe(s,...Qy(t,1))-s)];c=[0,2*e.indexOf(Math.min(...e))-1]}else{const e=[Math.abs(Xe(s,...Qy(t,-1))-s),Math.abs(Xe(s,...Qy(t,0))-s),Math.abs(Xe(s,...Qy(t,1))-s)];c=[e.indexOf(Math.min(...e))-1]}}else c=[0];for(const i of c){const o=t.containsTile(l,r,e,i);o&&n.push(o)}}return n}getShadowCasterCoordinates(){return this._getRenderableCoordinates(!1,!0)}getVisibleCoordinates(t){return this._getRenderableCoordinates(t)}_getRenderableCoordinates(t,e){const i=this.getRenderableIds(t,e).map((t=>this._tiles[t].tileID)),n="globe"===this.transform.projection.name;for(const t of i)t.projMatrix=this.transform.calculateProjMatrix(t.toUnwrapped()),t.expandedProjMatrix=n?this.transform.calculateProjMatrix(t.toUnwrapped(),!1,!0):t.projMatrix;return i}sortCoordinatesByDistance(t){const e=t.slice(),i=this.transform._camera.position,n=this.transform._camera.forward(),r={};for(const t of e){const e=1/(1r[t.key]-r[e.key])),e}hasTransition(){if(this._source.hasTransition())return!0;if(Jy(this._source.type))for(const t in this._tiles){const e=this._tiles[t];if(void 0!==e.fadeEndTime&&e.fadeEndTime>=ki.now())return!0}return!1}setFeatureState(t,e,i){this._state.updateState(t=t||"_geojsonTileLayer",e,i)}removeFeatureState(t,e,i){this._state.removeFeatureState(t=t||"_geojsonTileLayer",e,i)}getFeatureState(t,e){return this._state.getState(t=t||"_geojsonTileLayer",e)}setDependencies(t,e,i){const n=this._tiles[t];n&&n.setDependencies(e,i)}reloadTilesForDependencies(t,e){for(const i in this._tiles)this._tiles[i].hasDependency(t,e)&&this._reloadTile(+i,"reloading");this._cache.filter((i=>!i.hasDependency(t,e)))}_preloadTiles(t,e){if(!this._sourceLoaded){const i=()=>{this._sourceLoaded&&(this._source.off("data",i),this._preloadTiles(t,e))};return void this._source.on("data",i)}const i=new Map,n=Array.isArray(t)?t:[t],r=this.map.painter.terrain,o=this.usedForTerrain&&r?r.getScaledDemTileSize():this._source.tileSize;for(const t of n){const e=t.coveringTiles({tileSize:o,minzoom:this._source.minzoom,maxzoom:this._source.maxzoom,roundZoom:this._source.roundZoom&&!this.usedForTerrain,reparseOverscaled:this._source.reparseOverscaled,isTerrainDEM:this.usedForTerrain});for(const t of e)i.set(t.key,t);this.usedForTerrain&&t.updateElevation(!1)}Qe(Array.from(i.values()),((t,e)=>{const i=new ey(t,this._source.tileSize*t.overscaleFactor(),this.transform.tileZoom,this.map.painter,this._isRaster);this._loadTile(i,(t=>{"raster-dem"===this._source.type&&i.dem&&this._backfillDEM(i),e(t,i)}))}),e)}}function Ky(t,e){const i=Math.abs(2*t.wrap)-+(t.wrap0?e+2*t:t}tv.useIntegerZoom=!0;const iv=new ol({"symbol-placement":new il(sl.layout_symbol["symbol-placement"]),"symbol-spacing":new il(sl.layout_symbol["symbol-spacing"]),"symbol-avoid-edges":new il(sl.layout_symbol["symbol-avoid-edges"]),"symbol-sort-key":new nl(sl.layout_symbol["symbol-sort-key"]),"symbol-z-order":new il(sl.layout_symbol["symbol-z-order"]),"symbol-z-elevate":new il(sl.layout_symbol["symbol-z-elevate"]),"icon-allow-overlap":new il(sl.layout_symbol["icon-allow-overlap"]),"icon-ignore-placement":new il(sl.layout_symbol["icon-ignore-placement"]),"icon-optional":new il(sl.layout_symbol["icon-optional"]),"icon-rotation-alignment":new il(sl.layout_symbol["icon-rotation-alignment"]),"icon-size":new nl(sl.layout_symbol["icon-size"]),"icon-text-fit":new nl(sl.layout_symbol["icon-text-fit"]),"icon-text-fit-padding":new nl(sl.layout_symbol["icon-text-fit-padding"]),"icon-image":new nl(sl.layout_symbol["icon-image"]),"icon-rotate":new nl(sl.layout_symbol["icon-rotate"]),"icon-padding":new il(sl.layout_symbol["icon-padding"]),"icon-keep-upright":new il(sl.layout_symbol["icon-keep-upright"]),"icon-offset":new nl(sl.layout_symbol["icon-offset"]),"icon-anchor":new nl(sl.layout_symbol["icon-anchor"]),"icon-pitch-alignment":new il(sl.layout_symbol["icon-pitch-alignment"]),"text-pitch-alignment":new il(sl.layout_symbol["text-pitch-alignment"]),"text-rotation-alignment":new il(sl.layout_symbol["text-rotation-alignment"]),"text-field":new nl(sl.layout_symbol["text-field"]),"text-font":new nl(sl.layout_symbol["text-font"]),"text-size":new nl(sl.layout_symbol["text-size"]),"text-max-width":new nl(sl.layout_symbol["text-max-width"]),"text-line-height":new nl(sl.layout_symbol["text-line-height"]),"text-letter-spacing":new nl(sl.layout_symbol["text-letter-spacing"]),"text-justify":new nl(sl.layout_symbol["text-justify"]),"text-radial-offset":new nl(sl.layout_symbol["text-radial-offset"]),"text-variable-anchor":new il(sl.layout_symbol["text-variable-anchor"]),"text-anchor":new nl(sl.layout_symbol["text-anchor"]),"text-max-angle":new il(sl.layout_symbol["text-max-angle"]),"text-writing-mode":new il(sl.layout_symbol["text-writing-mode"]),"text-rotate":new nl(sl.layout_symbol["text-rotate"]),"text-padding":new il(sl.layout_symbol["text-padding"]),"text-keep-upright":new il(sl.layout_symbol["text-keep-upright"]),"text-transform":new nl(sl.layout_symbol["text-transform"]),"text-offset":new nl(sl.layout_symbol["text-offset"]),"text-allow-overlap":new il(sl.layout_symbol["text-allow-overlap"]),"text-ignore-placement":new il(sl.layout_symbol["text-ignore-placement"]),"text-optional":new il(sl.layout_symbol["text-optional"]),visibility:new il(sl.layout_symbol.visibility)});var nv={paint:new ol({"icon-opacity":new nl(sl.paint_symbol["icon-opacity"]),"icon-occlusion-opacity":new nl(sl.paint_symbol["icon-occlusion-opacity"]),"icon-emissive-strength":new nl(sl.paint_symbol["icon-emissive-strength"]),"text-emissive-strength":new nl(sl.paint_symbol["text-emissive-strength"]),"icon-color":new nl(sl.paint_symbol["icon-color"]),"icon-halo-color":new nl(sl.paint_symbol["icon-halo-color"]),"icon-halo-width":new nl(sl.paint_symbol["icon-halo-width"]),"icon-halo-blur":new nl(sl.paint_symbol["icon-halo-blur"]),"icon-translate":new il(sl.paint_symbol["icon-translate"]),"icon-translate-anchor":new il(sl.paint_symbol["icon-translate-anchor"]),"icon-image-cross-fade":new nl(sl.paint_symbol["icon-image-cross-fade"]),"text-opacity":new nl(sl.paint_symbol["text-opacity"]),"text-occlusion-opacity":new nl(sl.paint_symbol["text-occlusion-opacity"]),"text-color":new nl(sl.paint_symbol["text-color"],{runtimeType:Qn,getOverride:t=>t.textColor,hasOverride:t=>!!t.textColor}),"text-halo-color":new nl(sl.paint_symbol["text-halo-color"]),"text-halo-width":new nl(sl.paint_symbol["text-halo-width"]),"text-halo-blur":new nl(sl.paint_symbol["text-halo-blur"]),"text-translate":new il(sl.paint_symbol["text-translate"]),"text-translate-anchor":new il(sl.paint_symbol["text-translate-anchor"]),"icon-color-saturation":new il(sl.paint_symbol["icon-color-saturation"]),"icon-color-contrast":new il(sl.paint_symbol["icon-color-contrast"]),"icon-color-brightness-min":new il(sl.paint_symbol["icon-color-brightness-min"]),"icon-color-brightness-max":new il(sl.paint_symbol["icon-color-brightness-max"])}),layout:iv};class rv{constructor(t){this.type=t.property.overrides?t.property.overrides.runtimeType:Yn,this.defaultValue=t}evaluate(t){if(t.formattedSection){const e=this.defaultValue.property.overrides;if(e&&e.hasOverride(t.formattedSection))return e.getOverride(t.formattedSection)}return t.feature&&t.featureState?this.defaultValue.evaluate(t.feature,t.featureState):this.defaultValue.property.specification.default}eachChild(t){this.defaultValue.isConstant()||t(this.defaultValue.value._styleExpression.expression)}outputDefined(){return!1}serialize(){return null}}ba(rv,"FormatSectionOverride",{omit:["defaultValue"]});class ov extends Ml{constructor(e,i,n,r){super(e,nv,i,n,r),this._colorAdjustmentMatrix=t.ad.identity([]),this.hasInitialOcclusionOpacityProperties=void 0!==e.paint&&("icon-occlusion-opacity"in e.paint||"text-occlusion-opacity"in e.paint)}recalculate(t,e){super.recalculate(t,e),"auto"===this.layout.get("icon-rotation-alignment")&&(this.layout._values["icon-rotation-alignment"]="point"!==this.layout.get("symbol-placement")?"map":"viewport"),"auto"===this.layout.get("text-rotation-alignment")&&(this.layout._values["text-rotation-alignment"]="point"!==this.layout.get("symbol-placement")?"map":"viewport"),"auto"===this.layout.get("text-pitch-alignment")&&(this.layout._values["text-pitch-alignment"]=this.layout.get("text-rotation-alignment")),"auto"===this.layout.get("icon-pitch-alignment")&&(this.layout._values["icon-pitch-alignment"]=this.layout.get("icon-rotation-alignment"));const i=this.layout.get("text-writing-mode");if(i){const t=[];for(const e of i)t.indexOf(e)i in t?String(t[i]):""))}(e.properties,r)}createBucket(t){return new jg(t)}queryRadius(){return 0}queryIntersectsFeature(){return!1}_setPaintOverrides(){for(const t of nv.paint.overridableProperties){if(!ov.hasPaintOverride(this.layout,t))continue;const e=this.paint.get(t),i=new rv(e),n=new la(i,e.property.specification,this.scope,this.options);let r=null;r="constant"===e.value.kind||"source"===e.value.kind?new ua("source",n):new ha("composite",n,e.value.zoomStops,e.value._interpolationType),this.paint._values[t]=new tl(e.property,r,e.parameters)}}_handleOverridablePaintPropertyUpdate(t,e,i){return!(!this.layout||e.isDataDriven()||i.isDataDriven())&&ov.hasPaintOverride(this.layout,t)}static hasPaintOverride(t,e){const i=t.get("text-field"),n=nv.paint.properties[e];let r=!1;const o=t=>{for(const e of t)if(n.overrides&&n.overrides.hasOverride(e))return void(r=!0)};if("constant"===i.value.kind&&i.value.value instanceof pr)o(i.value.value.sections);else if("source"===i.value.kind){const t=e=>{r||(e instanceof vr&&gr(e.value)===nr?o(e.value.sections):e instanceof Tr?o(e.sections):e.eachChild(t))},e=i.value;e._styleExpression&&t(e._styleExpression.expression)}return r}getProgramIds(){const t=0!==this.paint.get("icon-opacity").constantOr(1),e=0!==this.paint.get("text-opacity").constantOr(1),i=[];return t&&i.push("symbolIcon"),e&&i.push("symbolSDF"),i}getDefaultProgramParams(t,e,i){return{config:new Wc(this,{zoom:e,lut:i}),overrideFog:!1}}}const sv=new ol({visibility:new il(sl.layout_background.visibility)});var av={paint:new ol({"background-color":new il(sl.paint_background["background-color"]),"background-pattern":new il(sl.paint_background["background-pattern"]),"background-opacity":new il(sl.paint_background["background-opacity"]),"background-emissive-strength":new il(sl.paint_background["background-emissive-strength"])}),layout:sv};const lv=new ol({visibility:new il(sl.layout_raster.visibility)});var cv={paint:new ol({"raster-opacity":new il(sl.paint_raster["raster-opacity"]),"raster-color":new rl(sl.paint_raster["raster-color"]),"raster-color-mix":new il(sl.paint_raster["raster-color-mix"]),"raster-color-range":new il(sl.paint_raster["raster-color-range"]),"raster-hue-rotate":new il(sl.paint_raster["raster-hue-rotate"]),"raster-brightness-min":new il(sl.paint_raster["raster-brightness-min"]),"raster-brightness-max":new il(sl.paint_raster["raster-brightness-max"]),"raster-saturation":new il(sl.paint_raster["raster-saturation"]),"raster-contrast":new il(sl.paint_raster["raster-contrast"]),"raster-resampling":new il(sl.paint_raster["raster-resampling"]),"raster-fade-duration":new il(sl.paint_raster["raster-fade-duration"]),"raster-emissive-strength":new il(sl.paint_raster["raster-emissive-strength"]),"raster-array-band":new il(sl.paint_raster["raster-array-band"]),"raster-elevation":new il(sl.paint_raster["raster-elevation"])}),layout:lv};function dv(e,i,n,r,o,s,a,l){const c=[e,i,1,n,r,1,o,s,1],d=[a,l,1],u=t.bC.adjoint([],c),[h,p,f]=t._.transformMat3(d,d,u);return t.bC.multiply(c,c,[h,0,0,0,p,0,0,0,f])}function uv(e,i,n,r,o,s,a,l){const c=function(e,i,n,r,o,s,a,l){const c=dv(0,0,1,0,1,1,0,1),d=dv(e,i,n,r,o,s,a,l),u=t.bC.adjoint([],c);return t.bC.multiply(d,d,u)}(e,i,n,r,o,s,a,l);return[c[2]/c[8]/uo,c[5]/c[8]/uo]}function hv(t){return[t[0],Math.min(Math.max(t[1],-Pd),Pd)]}class pv extends zn{constructor(t,e,i,n){super(),this.id=t,this.dispatcher=i,this.coordinates=e.coordinates,this.type="image",this.minzoom=0,this.maxzoom=22,this.tileSize=512,this.tiles={},this._loaded=!1,this.onNorthPole=!1,this.onSouthPole=!1,this.setEventedParent(n),this.options=e,this._dirty=!1}load(t,e){if(this._loaded=e||!1,this.fire(new Pn("dataloading",{dataType:"source"})),this.url=this.options.url,!this.url)return t&&(this.coordinates=t),this._loaded=!0,void this._finishLoading();this._imageRequest=an(this.map._requestManager.transformRequest(this.url,Ki.Image),((e,i)=>{this._imageRequest=null,this._loaded=!0,e?this.fire(new $n(e)):i&&(this.image=i instanceof HTMLImageElement?ki.getImageData(i):i,this._dirty=!0,this.width=this.image.width,this.height=this.image.height,t&&(this.coordinates=t),this._finishLoading())}))}loaded(){return this._loaded}updateImage(t){return t.url?(this._imageRequest&&t.url!==this.options.url&&(this._imageRequest.cancel(),this._imageRequest=null),this.options.url=t.url,this.load(t.coordinates,this._loaded),this):this}setTexture(t){if(!(t.handle instanceof WebGLTexture))throw new Error("The provided handle is not a WebGLTexture instance");return this.texture=new Gg(this.map.painter.context,t.handle),this.width=t.dimensions[0],this.height=t.dimensions[1],this._dirty=!1,this._loaded=!0,this._finishLoading(),this}_finishLoading(){this.map&&(this.setCoordinates(this.coordinates),this.fire(new Pn("data",{dataType:"source",sourceDataType:"metadata"})))}onAdd(t){this.map=t,this.load()}onRemove(t){this._imageRequest&&(this._imageRequest.cancel(),this._imageRequest=null),!this.texture||this.texture instanceof Gg||this.texture.destroy(),this.boundsBuffer&&(this.boundsBuffer.destroy(),this.elevatedGlobeVertexBuffer&&this.elevatedGlobeVertexBuffer.destroy(),this.elevatedGlobeIndexBuffer&&this.elevatedGlobeIndexBuffer.destroy())}setCoordinates(t){if(this.coordinates=t,this._boundsArray=void 0,this._unsupportedCoords=!1,!t.length)return this;this.onNorthPole=!1,this.onSouthPole=!1;let e=t[0][1],i=t[0][1];for(const n of t)n[1]>i&&(i=n[1]),n[1]Pd?this.onNorthPole=!0:n1&&(l-=1),new gd(s,l,Math.floor((i+r)/2*a))}(e),this.minzoom=this.maxzoom=this.tileID.z}return this.fire(new Pn("data",{dataType:"source",sourceDataType:"content"})),this}_clear(){this._boundsArray=void 0,this._unsupportedCoords=!1}_prepareData(e){for(const t in this.tiles){const e=this.tiles[t];"loaded"!==e.state&&(e.state="loaded",e.texture=this.texture)}if(this._boundsArray||this.onNorthPole||this.onSouthPole||this._unsupportedCoords)return;const i=eg(new gd(0,0,0),this.map.transform.projection),n=[i.projection.project(this.coordinates[0][0],this.coordinates[0][1]),i.projection.project(this.coordinates[1][0],this.coordinates[1][1]),i.projection.project(this.coordinates[2][0],this.coordinates[2][1]),i.projection.project(this.coordinates[3][0],this.coordinates[3][1])];if(!function(t){const e=t[1].x-t[0].x,i=t[1].y-t[0].y,n=t[2].x-t[1].x,r=t[2].y-t[1].y,o=t[3].x-t[2].x,s=t[3].y-t[2].y,a=t[0].x-t[3].x,l=t[0].y-t[3].y,c=e*r-n*i,d=n*s-o*r,u=o*l-a*s,h=a*i-e*l;return c>0&&d>0&&u>0&&h>0||c{const e=r.projection.project(t[0],t[1]);return ig(r,e)._round()}));this.perspectiveTransform=uv(o.x,o.y,s.x,s.y,a.x,a.y,l.x,l.y);const c=this._boundsArray=new Dl;c.emplaceBack(o.x,o.y,0,0),c.emplaceBack(s.x,s.y,uo,0),c.emplaceBack(l.x,l.y,0,uo),c.emplaceBack(a.x,a.y,uo,uo),this.boundsBuffer&&(this.boundsBuffer.destroy(),this.elevatedGlobeVertexBuffer&&this.elevatedGlobeVertexBuffer.destroy(),this.elevatedGlobeIndexBuffer&&this.elevatedGlobeIndexBuffer.destroy()),this.boundsBuffer=e.createVertexBuffer(c,Jg.members),this.boundsSegments=wc.simpleSegment(0,0,4,2);const d=[],u=function(t){return[hv(t[0]),hv(t[1]),hv(t[2]),hv(t[3])]}(this.coordinates),[h,p,f,m]=function(t){let e=t[0][0],i=e,n=t[0][1],r=n;for(let o=1;oi&&(i=t[o][0]),t[o][1]r&&(r=t[o][1]);return[e,n,i-e,r-n]}(u);{const r=new Dl,[o,s,a,l]=function(t){let e=t[0].x,i=e,n=t[0].y,r=n;for(let o=1;oi&&(i=t[o].x),t[o].yr&&(r=t[o].y);return[e,n,i-e,r-n]}(n),c=t=>[(t.x-o)/a,(t.y-s)/l],[u,_,g,y]=n.map(c),v=function(e,i,n,r,o,s,a,l){const c=dv(0,0,1,0,1,1,0,1),d=dv(e,i,n,r,o,s,a,l),u=t.bC.adjoint([],d);return t.bC.multiply(c,c,u)}(u[0],u[1],_[0],_[1],g[0],g[1],y[0],y[1]);this.elevatedGlobePerspectiveTransform=uv(u[0],u[1],_[0],_[1],g[0],g[1],y[0],y[1]);const x=(e,i)=>{d.push(e.lng);const n=Math.round((e.lng-h)/f*uo),o=Math.round((e.lat-p)/m*uo),s=c(i),a=t._.transformMat3([],[s[0],s[1],1],v),l=Math.round(a[0]/a[2]*uo),u=Math.round(a[1]/a[2]*uo);r.emplaceBack(n,o,l,u)},b=n[3].x-n[0].x,w=n[3].y-n[0].y,T=n[2].x-n[1].x,S=n[2].y-n[1].y;for(let t=0;t{i.emplaceBack(e,n,r);const o=d[e],s=d[n],a=d[r],l=Math.min(Math.min(o,s),a),c=Math.max(Math.max(o,s),a)-l;c>this.maxLongitudeTriangleSize&&(this.maxLongitudeTriangleSize=c),t.push(l+c/2)};for(let t=0;te));i.sort(((e,i)=>t[e]-t[i]));const n=[],r=new Kl;for(let o=0;o{o.segments.push({vertexOffset:0,primitiveOffset:t,vertexLength:e.segments[0].vertexLength,primitiveLength:i,sortKey:void 0,vaos:{}})},a=.51*this.maxLongitudeTriangleSize;if(Math.abs(i[0]-n)0){const n=function(e,i){const n=i.worldSize,r=Cd(1,0)*n*kd(i.center.lat,i.zoom)/Gu(n),o=Cd(1,i.center.lat)*n,s=t.ad.identity([]);return t.ad.rotateY(s,s,Ge(i.center.lng)),t.ad.rotateX(s,s,Ge(i.center.lat)),t.ad.translate(s,s,[0,0,ed]),t.ad.scale(s,s,[r,r,r*o]),t.ad.translate(s,s,[i.point.x-.5*n,i.point.y-.5*n,0]),t.ad.multiply(s,s,e),t.ad.multiply(s,i.globeMatrix,s)}(e,i);return function(e,i,n){const r=(e,i,n)=>{const r=t._.length(e),o=t._.length(i),s=ku(e,i,n);return t._.scale(s,s,1/t._.length(s)*Vn(r,o,n))},o=r([e[0],e[1],e[2]],[i[0],i[1],i[2]],n),s=r([e[4],e[5],e[6]],[i[4],i[5],i[6]],n),a=r([e[8],e[9],e[10]],[i[8],i[9],i[10]],n),l=ku([e[12],e[13],e[14]],[i[12],i[13],i[14]],n);return[o[0],o[1],o[2],0,s[0],s[1],s[2],0,a[0],a[1],a[2],0,l[0],l[1],l[2],1]}(o,n,r)}return o}function kv(t,e,i,n){const r=wu.projectAabbCorners(n,i);let o=Number.MAX_VALUE,s=-1;for(let t=0;tnew Ue(r[t][0],r[t][1]);let l;switch(s){case 0:case 6:l=[a(1),a(5),a(4),a(7),a(3),a(2),a(1)];break;case 1:case 7:l=[a(0),a(4),a(5),a(6),a(2),a(3),a(0)];break;case 3:case 5:l=[a(1),a(0),a(4),a(7),a(6),a(2),a(1)];break;default:l=[a(1),a(5),a(6),a(7),a(3),a(0),a(1)]}if(Yd(t,l))return o}const Dv=Ll([{name:"a_pos_3f",components:3,type:"Float32"}]),zv=Ll([{name:"a_color_3f",components:3,type:"Float32"}]),Rv=Ll([{name:"a_color_4f",components:4,type:"Float32"}]),Ov=Ll([{name:"a_uv_2f",components:2,type:"Float32"}]),Bv=Ll([{name:"a_normal_3f",components:3,type:"Float32"}]),Fv=Ll([{name:"a_normal_matrix0",components:4,type:"Float32"},{name:"a_normal_matrix1",components:4,type:"Float32"},{name:"a_normal_matrix2",components:4,type:"Float32"},{name:"a_normal_matrix3",components:4,type:"Float32"}]),Nv=Ll([{name:"a_pbr",components:4,type:"Uint16"},{name:"a_heightBasedEmissiveStrength",components:3,type:"Float32"}]);class Uv{constructor(t,e,i,n){this.message=(t?`${t}: `:"")+i,n&&(this.identifier=n),null!=e&&e.__line__&&(this.line=e.__line__)}}function jv(t,e){const i=-1===t.indexOf("://");try{return new URL(t,i&&e?"http://example.com":void 0),!0}catch(t){return!1}}class Vv{constructor(t,e){this.feature=t,this.instancedDataOffset=e,this.instancedDataCount=0,this.rotation=[0,0,0],this.scale=[1,1,1],this.translation=[0,0,0]}}class Gv{constructor(){this.instancedDataArray=new oc,this.instancesEvaluatedElevation=[],this.features=[],this.idToFeaturesIndex={}}}class Zv{constructor(t){this.zoom=t.zoom,this.canonical=t.canonical,this.layers=t.layers,this.layerIds=this.layers.map((t=>t.fqid)),this.projection=t.projection,this.index=t.index,this.hasZoomDependentProperties=this.layers[0].isZoomDependent(),this.stateDependentLayerIds=this.layers.filter((t=>t.isStateDependent())).map((t=>t.id)),this.hasPattern=!1,this.instancesPerModel={},this.validForExaggeration=0,this.maxVerticalOffset=0,this.maxScale=0,this.maxHeight=0,this.lookupDim=this.zoom>this.canonical.z?256:this.zoom>15?75:100,this.instanceCount=0,this.terrainElevationMin=0,this.terrainElevationMax=0,this.validForDEMTile={id:null,timestamp:0},this.modelUris=[],this.modelsRequested=!1,this.activeReplacements=[],this.replacementUpdateTime=0}updateFootprints(t,e){}populate(t,e,i,n){this.tileToMeter=zd(i);const r=this.layers[0]._featureFilter.needGeometry;this.lookup=new Uint8Array(this.lookupDim*this.lookupDim);for(const{feature:o,id:s,index:a,sourceLayerIndex:l}of t){const t=null!=s?s:o.properties&&o.properties.hasOwnProperty("id")?o.properties.id:void 0,c=Zd(o,r);if(!this.layers[0]._featureFilter.filter(new Ha(this.zoom),c,i))continue;const d={id:t,sourceLayerIndex:l,index:a,geometry:r?c.geometry:Gd(o,i,n),properties:o.properties,type:o.type,patterns:{}},u=this.addFeature(d,d.geometry,c);u&&e.featureIndex.insert(o,d.geometry,a,l,this.index,this.instancesPerModel[u].instancedDataArray.length,uo/32)}this.lookup=null}update(t,e,i,n){for(const e in this.instancesPerModel){const i=this.instancesPerModel[e];for(const e in t)i.idToFeaturesIndex.hasOwnProperty(e)&&(this.evaluate(i.features[i.idToFeaturesIndex[e]],t[e],i,!0),this.uploaded=!1)}this.maxHeight=0}updateZoomBasedPaintProperties(){if(!this.hasZoomDependentProperties)return!1;let e=!1;for(const i in this.instancesPerModel){const n=this.instancesPerModel[i];for(const i of n.features){const r=this.layers[0],o=i.feature,s=this.canonical,a=r.paint.get("model-rotation").evaluate(o,{},s),l=r.paint.get("model-scale").evaluate(o,{},s),c=r.paint.get("model-translation").evaluate(o,{},s);t._.exactEquals(i.rotation,a)&&t._.exactEquals(i.scale,l)&&t._.exactEquals(i.translation,c)||(this.evaluate(i,i.featureStates,n,!0),e=!0)}}return e}updateReplacement(t,e,i){if(e.updateTime===this.replacementUpdateTime)return!1;this.replacementUpdateTime=e.updateTime;const n=e.getReplacementRegionsForTile(t.toUnwrapped(),!0);if(Pp(this.activeReplacements,n))return!1;this.activeReplacements=n;let r=!1;for(const e in this.instancesPerModel){const n=this.instancesPerModel[e],o=n.instancedDataArray;for(const e of n.features){const n=e.instancedDataOffset,s=e.instancedDataCount;for(let e=0;euo?a-uo:a;const l=Math.floor(a),c=o.float32[s+1];let d=!1;for(const e of this.activeReplacements)if(!(e.orderl||l>e.max.x||e.min.y>c||c>e.max.y)&&(d=Op(Rp(l,c,t.canonical,e.footprintTileId.canonical),e),d))break;o.float32[s]=d?a+uo:a,r=r||d}}}return r}isEmpty(){for(const t in this.instancesPerModel)if(0!==this.instancesPerModel[t].instancedDataArray.length)return!1;return!0}uploadPending(){return!this.uploaded}upload(t){if(!this.uploaded)for(const e in this.instancesPerModel){const i=this.instancesPerModel[e];i.instancedDataArray.length=uo||e.y=uo)continue;const t=(this.lookupDim-1)/uo,i=this.lookupDim*(e.y*t|0)+e.x*t|0;if(this.lookup){if(0!==this.lookup[i])continue;this.lookup[i]=1}this.instanceCount++;const n=s.length;s.resize(n+1),o.instancesEvaluatedElevation.push(0),s.float32[16*n]=e.x,s.float32[16*n+1]=e.y}return a.instancedDataCount=o.instancedDataArray.length-a.instancedDataOffset,a.instancedDataCount>0&&(t.id&&(o.idToFeaturesIndex[t.id]=o.features.length),o.features.push(a),this.evaluate(a,{},o,!1)),r}getModelUris(){return this.modelUris}evaluate(t,e,i,n){const r=this.layers[0],o=t.feature,s=this.canonical,a=t.rotation=r.paint.get("model-rotation").evaluate(o,e,s),l=t.scale=r.paint.get("model-scale").evaluate(o,e,s),c=t.translation=r.paint.get("model-translation").evaluate(o,e,s),d=r.paint.get("model-color").evaluate(o,e,s);d.a=r.paint.get("model-color-mix-intensity").evaluate(o,e,s);const u=[];this.maxVerticalOffset10?this.tileToMeter:zd(s,p)),a[o+4]=c[0],a[o+5]=c[1],a[o+6]=c[2]+l,a[o+7]=u[0],a[o+8]=u[1],a[o+9]=u[2],a[o+10]=u[4],a[o+11]=u[5],a[o+12]=u[6],a[o+13]=u[8],a[o+14]=u[9],a[o+15]=u[10],i.instancesEvaluatedElevation[r]=c[2]}}}ba(Zv,"ModelBucket",{omit:["layers"]}),ba(Gv,"PerModelAttributes"),ba(Vv,"ModelFeature");const qv=new ol({visibility:new il(sl.layout_model.visibility),"model-id":new nl(sl.layout_model["model-id"])});var Hv={paint:new ol({"model-opacity":new il(sl.paint_model["model-opacity"]),"model-rotation":new nl(sl.paint_model["model-rotation"]),"model-scale":new nl(sl.paint_model["model-scale"]),"model-translation":new nl(sl.paint_model["model-translation"]),"model-color":new nl(sl.paint_model["model-color"]),"model-color-mix-intensity":new nl(sl.paint_model["model-color-mix-intensity"]),"model-type":new il(sl.paint_model["model-type"]),"model-cast-shadows":new il(sl.paint_model["model-cast-shadows"]),"model-receive-shadows":new il(sl.paint_model["model-receive-shadows"]),"model-ambient-occlusion-intensity":new il(sl.paint_model["model-ambient-occlusion-intensity"]),"model-emissive-strength":new nl(sl.paint_model["model-emissive-strength"]),"model-roughness":new nl(sl.paint_model["model-roughness"]),"model-height-based-emissive-strength-multiplier":new nl(sl.paint_model["model-height-based-emissive-strength-multiplier"]),"model-cutoff-fade-range":new il(sl.paint_model["model-cutoff-fade-range"]),"model-front-cutoff":new il(sl.paint_model["model-front-cutoff"])}),layout:qv};const Wv=64,Yv={CoordinateSpaceTile:1,CoordinateSpaceYUp:2,HasMapboxMeshFeatures:4,HasMeshoptCompression:8};function Xv(e,i,n,r,o,s,a,l,c,d=!1){const u=n.zoom,h=n.project(r),p=kd(r.lat,u),f=1/p;t.ad.identity(e),t.ad.translate(e,e,[h.x+a[0]*f,h.y+a[1]*f,a[2]]);let m=1,_=1;const g=n.worldSize;if(d){if("mercator"===n.projection.name){let e=0;n.elevation&&(e=n.elevation.getAtPointOrZero(new Rd(h.x/g,h.y/g),0));const i=t.aA.transformMat4([],[h.x,h.y,e,1],n.projMatrix)[3]/n.cameraToCenterDistance;m=i,_=i*kd(n.center.lat,u)}else if("globe"===n.projection.name){const i=$v(e,n),o=t.ad.multiply([],n.projMatrix,i),s=[0,0,0,1];t.aA.transformMat4(s,s,o);const a=s[3]/n.cameraToCenterDistance,l=Hu(u),c=n.projection.pixelsPerMeter(r.lat,g)*kd(r.lat,u),d=n.projection.pixelsPerMeter(n.center.lat,g)*kd(n.center.lat,u);m=a/Vn(c,$d(n.center.lat),l),_=a*p/c,m*=d,_*=d}}else m=f;t.ad.scale(e,e,[m,m,_]);const y=[...e],v=i.orientation,x=[];if(Lv(x,[v[0]+o[0],v[1]+o[1],v[2]+o[2]],s),t.ad.multiply(e,y,x),l&&n.elevation){let o=0;const s=[];if(c&&n.elevation){o=function(e,i,n,r,o){const s=i.elevation;if(!s)return 0;const a=wu.projectAabbCorners(n,r),l=Cd(1,o.lat)*i.worldSize,c=function(e,i){const n=[0,0,1],r=[{corners:[0,1,3,2],dotProductWithUp:0},{corners:[1,5,2,6],dotProductWithUp:0},{corners:[0,4,1,5],dotProductWithUp:0},{corners:[2,6,3,7],dotProductWithUp:0},{corners:[4,7,5,6],dotProductWithUp:0},{corners:[0,3,4,7],dotProductWithUp:0}];for(const o of r){const r=e[o.corners[0]],s=e[o.corners[1]],a=e[o.corners[2]],l=[s[0]-r[0],s[1]-r[1],i*(s[2]-r[2])],c=t._.cross(l,l,[a[0]-r[0],a[1]-r[1],i*(a[2]-r[2])]);t._.normalize(c,c),o.dotProductWithUp=t._.dot(c,n)}return r.sort(((t,e)=>t.dotProductWithUp-e.dotProductWithUp)),r[0].corners}(a,l),d=a[c[0]],u=a[c[1]],h=a[c[2]],p=a[c[3]],f=s.getAtPointOrZero(new Rd(d[0]/i.worldSize,d[1]/i.worldSize),0),m=s.getAtPointOrZero(new Rd(u[0]/i.worldSize,u[1]/i.worldSize),0),_=s.getAtPointOrZero(new Rd(h[0]/i.worldSize,h[1]/i.worldSize),0),g=s.getAtPointOrZero(new Rd(p[0]/i.worldSize,p[1]/i.worldSize),0),y=(f+g)/2,v=(m+_)/2;return y>v?m=e.gl.NEAREST_MIPMAP_NEAREST}),t.uploaded=!0,t.image=null)}function Jv(t,e,i){t.indexBuffer=e.createIndexBuffer(t.indexArray,!1,!0),t.vertexBuffer=e.createVertexBuffer(t.vertexArray,Dv.members,!1,!0),t.normalArray&&(t.normalBuffer=e.createVertexBuffer(t.normalArray,Bv.members,!1,!0)),t.texcoordArray&&(t.texcoordBuffer=e.createVertexBuffer(t.texcoordArray,Ov.members,!1,!0)),t.colorArray&&(t.colorBuffer=e.createVertexBuffer(t.colorArray,(12===t.colorArray.bytesPerElement?zv:Rv).members,!1,!0)),t.featureArray&&(t.pbrBuffer=e.createVertexBuffer(t.featureArray,Nv.members,!0)),t.segments=wc.simpleSegment(0,0,t.vertexArray.length,t.indexArray.length);const n=t.material;n.pbrMetallicRoughness.baseColorTexture&&Kv(n.pbrMetallicRoughness.baseColorTexture,e),n.pbrMetallicRoughness.metallicRoughnessTexture&&Kv(n.pbrMetallicRoughness.metallicRoughnessTexture,e),n.normalTexture&&Kv(n.normalTexture,e),n.occlusionTexture&&Kv(n.occlusionTexture,e,i),n.emissionTexture&&Kv(n.emissionTexture,e)}function Qv(t,e,i){if(t.meshes)for(const n of t.meshes)Jv(n,e,i);if(t.children)for(const n of t.children)Qv(n,e,i)}function tx(t){if(t.meshes)for(const e of t.meshes)e.indexArray.destroy(),e.vertexArray.destroy(),e.colorArray&&e.colorArray.destroy(),e.normalArray&&e.normalArray.destroy(),e.texcoordArray&&e.texcoordArray.destroy(),e.featureArray&&e.featureArray.destroy();if(t.children)for(const e of t.children)tx(e)}function ex(t){if(t.meshes)for(const i of t.meshes)i.vertexBuffer&&(i.vertexBuffer.destroy(),i.indexBuffer.destroy(),i.normalBuffer&&i.normalBuffer.destroy(),i.texcoordBuffer&&i.texcoordBuffer.destroy(),i.colorBuffer&&i.colorBuffer.destroy(),i.pbrBuffer&&i.pbrBuffer.destroy(),i.segments.destroy(),i.material&&((e=i.material).pbrMetallicRoughness.baseColorTexture&&e.pbrMetallicRoughness.baseColorTexture.gfxTexture&&e.pbrMetallicRoughness.baseColorTexture.gfxTexture.destroy(),e.pbrMetallicRoughness.metallicRoughnessTexture&&e.pbrMetallicRoughness.metallicRoughnessTexture.gfxTexture&&e.pbrMetallicRoughness.metallicRoughnessTexture.gfxTexture.destroy(),e.normalTexture&&e.normalTexture.gfxTexture&&e.normalTexture.gfxTexture.destroy(),e.emissionTexture&&e.emissionTexture.gfxTexture&&e.emissionTexture.gfxTexture.destroy(),e.occlusionTexture&&e.occlusionTexture.gfxTexture&&e.occlusionTexture.gfxTexture.destroy()));var e;if(t.children)for(const e of t.children)ex(e)}class ix{constructor(t){this._callback=t,this._triggered=!1,"undefined"!=typeof MessageChannel&&(this._channel=new MessageChannel,this._channel.port2.onmessage=()=>{this._triggered=!1,this._callback()})}trigger(){this._triggered||(this._triggered=!0,this._channel?this._channel.port1.postMessage(!0):setTimeout((()=>{this._triggered=!1,this._callback()}),0))}remove(){this._channel=void 0,this._callback=()=>{}}}class nx{constructor(){this.tasks={},this.taskQueue=[],ai(["process"],this),this.invoker=new ix(this.process),this.nextId=0}add(t,e){const i=this.nextId++,n=function({type:t,isSymbolTile:e,zoom:i}){return i=i||0,"message"===t?0:"maybePrepare"!==t||e?"parseTile"!==t||e?"parseTile"===t&&e?300-i:"maybePrepare"===t&&e?400-i:500:200-i:100-i}(e);if(0===n){try{t()}finally{}return null}return this.tasks[i]={fn:t,metadata:e,priority:n,id:i},this.taskQueue.push(i),this.invoker.trigger(),{cancel:()=>{delete this.tasks[i]}}}process(){try{if(this.taskQueue=this.taskQueue.filter((t=>!!this.tasks[t])),!this.taskQueue.length)return;const t=this.pick();if(null===t)return;const e=this.tasks[t];if(delete this.tasks[t],this.taskQueue.length&&this.invoker.trigger(),!e)return;e.fn()}finally{}}pick(){let t=null,e=1/0;for(let i=0;i{i&&delete this.callbacks[s],this.target.postMessage({id:s,type:"",targetMapId:n,sourceMapId:this.mapId})}}}receive(t){const e=t.data,i=e.id;if(i&&(!e.targetMapId||this.mapId===e.targetMapId))if(""===e.type){const t=this.cancelCallbacks[i];delete this.cancelCallbacks[i],t&&t.cancel()}else if(e.mustQueue||gi()){const t=this.callbacks[i],n=this.scheduler.add((()=>this.processTask(i,e)),t&&t.metadata||{type:"message"});n&&(this.cancelCallbacks[i]=n)}else this.processTask(i,e)}processTask(t,e){if(delete this.cancelCallbacks[t],""===e.type){const i=this.callbacks[t];delete this.callbacks[t],i&&(e.error?i(Ea(e.error)):i(null,Ea(e.data)))}else{const i=new Set,n=e.hasCallback?(e,n)=>{this.target.postMessage({id:t,type:"",sourceMapId:this.mapId,error:e?Sa(e):null,data:Sa(n,i)},i)}:t=>{},r=Ea(e.data);if(this.parent[e.type])this.parent[e.type](e.sourceMapId,r,n);else if(this.parent.getWorkerSource){const t=e.type.split(".");this.parent.getWorkerSource(e.sourceMapId,t[0],r.source,r.scope)[t[1]](r,n)}else n(new Error(`Could not find function ${e.type}`))}}remove(){this.scheduler.remove(),this.target.removeEventListener("message",this.receive,!1)}}class ox{constructor(t,e){this.workerPool=t,this.actors=[],this.currentActor=0,this.id=ni();const i=this.workerPool.acquire(this.id);for(let t=0;t{this.ready=!0}))}broadcast(t,e,i){Qe(this.actors,((i,n)=>{i.send(t,e,n)}),i=i||function(){})}getActor(){return this.currentActor=(this.currentActor+1)%this.actors.length,this.actors[this.currentActor]}remove(){this.actors.forEach((t=>{t.remove()})),this.actors=[],this.workerPool.release(this.id)}}ox.Actor=rx;var sx={workerUrl:"",workerClass:null,workerParams:void 0};function ax(){return null!=sx.workerClass?new sx.workerClass:new self.Worker(sx.workerUrl,sx.workerParams)}const lx="mapboxgl_preloaded_worker_pool";class cx{constructor(){this.active={}}acquire(t){if(!this.workers)for(this.workers=[];this.workers.length{t.terminate()})),this.workers=null)}isPreloaded(){return!!this.active[lx]}numActive(){return Object.keys(this.active).length}}let dx;function ux(){return dx||(dx=new cx),dx}cx.workerCount=2;let hx,px,fx,mx,_x,gx=null;function yx(){return gi()&&self.worker&&self.worker.dracoUrl?self.worker.dracoUrl:px||n.DRACO_URL}function vx(){if(gi()&&self.worker&&self.worker.meshoptUrl)return self.worker.meshoptUrl;if(mx)return mx;const t=new Uint8Array([0,97,115,109,1,0,0,0,1,4,1,96,0,0,3,3,2,0,0,5,3,1,0,1,12,1,0,10,22,2,12,0,65,0,65,0,65,0,252,10,0,0,11,7,0,65,0,253,15,26,11]);if("object"!=typeof WebAssembly)throw new Error("WebAssembly not supported, cannot instantiate meshoptimizer");return mx=WebAssembly.validate(t)?n.MESHOPT_SIMD_URL:n.MESHOPT_URL,mx}const xx={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},bx={5120:"DT_INT8",5121:"DT_UINT8",5122:"DT_INT16",5123:"DT_UINT16",5125:"DT_UINT32",5126:"DT_FLOAT32"},wx={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16};function Tx(t,e,i){const n=i.json.bufferViews.length,r=i.buffers.length;e.bufferView=n,i.json.bufferViews[n]={buffer:r,byteLength:t.byteLength},i.buffers[r]=t}const Sx="KHR_draco_mesh_compression";function Ex(t,e){const i=t.extensions&&t.extensions[Sx];if(!i)return;const n=new fx.Decoder,r=$x(e,i.bufferView),o=new fx.Mesh;if(!n.DecodeArrayToMesh(r,r.byteLength,o))throw new Error("Failed to decode Draco mesh");const s=e.json.accessors[t.indices],a=xx[s.componentType],l=s.count*a.BYTES_PER_ELEMENT,c=fx._malloc(l);a===Uint16Array?n.GetTrianglesUInt16Array(o,l,c):n.GetTrianglesUInt32Array(o,l,c),Tx(fx.memory.buffer.slice(c,c+l),s,e),fx._free(c);for(const r of Object.keys(i.attributes)){const s=n.GetAttributeByUniqueId(o,i.attributes[r]),a=e.json.accessors[t.attributes[r]],l=bx[a.componentType],c=a.count*wx[a.type]*xx[a.componentType].BYTES_PER_ELEMENT,d=fx._malloc(c);n.GetAttributeDataArrayForAllPoints(o,s,fx[l],c,d),Tx(fx.memory.buffer.slice(d,d+c),a,e),fx._free(d)}n.destroy(),o.destroy(),delete t.extensions[Sx]}const Mx="EXT_meshopt_compression";function Cx(t,e){if(!t.extensions||!t.extensions[Mx])return;const i=t.extensions[Mx],n=new Uint8Array(e.buffers[i.buffer],i.byteOffset||0,i.byteLength||0),r=new Uint8Array(i.count*i.byteStride);_x.decodeGltfBuffer(r,i.count,i.byteStride,n,i.mode,i.filter),t.buffer=e.buffers.length,t.byteOffset=0,e.buffers[t.buffer]=r.buffer,delete t.extensions[Mx]}const Ax=1179937895,Ix=new TextDecoder("utf8");function Lx(t,e){return new URL(t,e).href}function Px(t,e,i,n){return fetch(Lx(t.uri,n)).then((t=>t.arrayBuffer())).then((t=>{e.buffers[i]=t}))}function $x(t,e){const i=t.json.bufferViews[e];return new Uint8Array(t.buffers[i.buffer],i.byteOffset||0,i.byteLength)}function kx(t,e,i,n){if(t.uri){const r=Lx(t.uri,n);return fetch(r).then((t=>t.blob())).then((t=>createImageBitmap(t))).then((t=>{e.images[i]=t}))}if(void 0!==t.bufferView){const n=$x(e,t.bufferView),r=new Blob([n],{type:t.mimeType});return createImageBitmap(r).then((t=>{e.images[i]=t}))}}function Dx(t,e=0,i){const n={json:null,images:[],buffers:[]};if(new Uint32Array(t,e,1)[0]===Ax){const i=new Uint32Array(t,e);let r=2;const o=(i[r++]>>2)-3,s=i[r++]>>2;if(r++,n.json=JSON.parse(Ix.decode(i.subarray(r,r+s))),r+=s,r{const t=[],e=a&&a.includes(Sx),r=a&&a.includes(Mx);if(e&&t.push(function(){if(!fx)return hx||(hx=function(t){let e,i=null;function n(){e=new Uint8Array(i.buffer)}function r(){throw new Error("Unexpected Draco error.")}const o={a:{a:r,d:function(t,i,n){return e.copyWithin(t,i,i+n)},c:function(t){const r=e.length,o=Math.max(t>>>0,Math.ceil(1.2*r)),s=Math.ceil((o-r)/65536);try{return i.grow(s),n(),!0}catch(t){return!1}},b:r}};return(WebAssembly.instantiateStreaming?WebAssembly.instantiateStreaming(t,o):t.then((t=>t.arrayBuffer())).then((t=>WebAssembly.instantiate(t,o)))).then((t=>{const{Rb:r,Qb:o,P:s,T:a,X:l,Ja:c,La:d,Qa:u,Va:h,Wa:p,eb:f,jb:m,f:_,e:g,yb:y,zb:v,Ab:x,Bb:b,Db:w,Gb:T}=t.instance.exports;i=g;const S=(()=>{let t=0,i=0,n=0,s=0;return a=>{n&&(r(s),r(t),i+=n,n=t=0),t||(i+=128,t=o(i));const l=a.length+7&-8;let c=t;l>=i&&(n=l,c=s=o(l));for(let t=0;t{fx=t,hx=void 0})))}()),r&&t.push(function(){if(_x)return;const t=function(t){let e;const i=WebAssembly.instantiateStreaming(t,{}).then((t=>{e=t.instance,e.exports.__wasm_call_ctors()})),n={NONE:"",OCTAHEDRAL:"meshopt_decodeFilterOct",QUATERNION:"meshopt_decodeFilterQuat",EXPONENTIAL:"meshopt_decodeFilterExp"},r={ATTRIBUTES:"meshopt_decodeVertexBuffer",TRIANGLES:"meshopt_decodeIndexBuffer",INDICES:"meshopt_decodeIndexSequence"};return{ready:i,supported:!0,decodeGltfBuffer(t,i,o,s,a,l){!function(t,e,i,n,r,o,s){const a=t.exports.sbrk,l=n+3&-4,c=a(l*r),d=a(o.length),u=new Uint8Array(t.exports.memory.buffer);u.set(o,d);const h=e(c,n,r,d,o.length);if(0===h&&s&&s(c,l,r),i.set(u.subarray(c,c+n*r)),a(c-a(0)),0!==h)throw new Error(`Malformed buffer data: ${h}`)}(e,e.exports[r[a]],t,i,o,s,e.exports[n[l]])}}}(fetch(vx()));return t.ready.then((()=>{_x=t}))}()),o)for(let e=0;e{if(e&&s)for(const{primitives:t}of s)for(const e of t)Ex(e,n);if(r&&s&&l)for(const t of l)Cx(t,n);return n}))}))}function zx(t,e){const i=t.json.bufferViews[e.bufferView],n=xx[e.componentType];return new n(t.buffers[i.buffer],(e.byteOffset||0)+(i.byteOffset||0),e.count*(i.byteStride&&i.byteStride!==wx[e.type]*n.BYTES_PER_ELEMENT?i.byteStride/n.BYTES_PER_ELEMENT:wx[e.type]))}function Rx(t,e,i,n){const r=xx[e.componentType],o=function(t){switch(t){case Int8Array:return 1/127;case Uint8Array:return 1/255;case Int16Array:return 1/32767;case Uint16Array:return 1/65535;default:return 1}}(r),s=t.json.bufferViews[e.bufferView],a=s.byteStride?s.byteStride/r.BYTES_PER_ELEMENT:wx[e.type],l=i.float32,c=l.length/i.capacity;for(let t=0,i=0;t0){for(let r=0;r0){o.texcoordArray=new ic;const t=e.json.accessors[r.TEXCOORD_0];o.texcoordArray.resize(t.count);const i=zx(e,t);Rx(e,t,o.texcoordArray,i)}if(void 0!==r._FEATURE_ID_RGBA4444){const t=e.json.accessors[r._FEATURE_ID_RGBA4444];e.json.extensionsUsed&&e.json.extensionsUsed.includes("EXT_meshopt_compression")&&(o.featureData=zx(e,t))}void 0!==r._FEATURE_RGBA4444&&(o.featureData=new Uint32Array(zx(e,e.json.accessors[r._FEATURE_RGBA4444]).buffer));const u=t.material;return o.material=function(t,e){const{emissiveFactor:i=[0,0,0],alphaMode:n="OPAQUE",alphaCutoff:r=.5,normalTexture:o,occlusionTexture:s,emissiveTexture:a,doubleSided:l}=t,{baseColorFactor:c=[1,1,1,1],metallicFactor:d=1,roughnessFactor:u=1,baseColorTexture:h,metallicRoughnessTexture:p}=t.pbrMetallicRoughness||{},f=s?e[s.index]:void 0;if(s&&s.extensions&&s.extensions.KHR_texture_transform&&f){const t=s.extensions.KHR_texture_transform;f.offsetScale=[t.offset[0],t.offset[1],t.scale[0],t.scale[1]]}return{pbrMetallicRoughness:{baseColorFactor:new Un(...c),metallicFactor:d,roughnessFactor:u,baseColorTexture:h?e[h.index]:void 0,metallicRoughnessTexture:p?e[p.index]:void 0},doubleSided:l,emissiveFactor:i,alphaMode:n,alphaCutoff:r,normalTexture:o?e[o.index]:void 0,occlusionTexture:f,emissionTexture:a?e[a.index]:void 0,defined:void 0===t.defined}}(void 0!==u?e.json.materials[u]:{defined:!1},i),o}function Bx(e,i,n){const{matrix:r,rotation:o,translation:s,scale:a,mesh:l,extras:c,children:d}=e,u={};if(u.matrix=r||t.ad.fromRotationTranslationScale([],o||[0,0,0,1],s||[0,0,0],a||[1,1,1]),void 0!==l){u.meshes=n[l];const t=u.anchor=[0,0];for(const e of u.meshes){const{min:i,max:n}=e.aabb;t[0]+=i[0]+n[0],t[1]+=i[1]+n[1]}t[0]=Math.floor(t[0]/u.meshes.length/2),t[1]=Math.floor(t[1]/u.meshes.length/2)}if(c&&(c.id&&(u.id=c.id),c.lights&&(u.lights=function(t){if(!t.length)return[];const e=function(t){const e=atob(t),i=new Uint8Array(e.length);for(let t=0;t1&&n[n.length-1].equals(n[0])&&n.pop();let r=0;for(let t=0;t0&&n.reverse();const o=xh(n.flatMap((t=>[t.x,t.y])),[]);return 0===o.length?null:{vertices:n,indices:o}}function Ux(e,i){const n=[],r=[];let o=0;const s=[];for(const a of e){o=n.length;const e=a.vertexArray.float32,l=a.indexArray.uint16;for(let r=0;r0&&([r[t+1],r[t+2]]=[r[t+2],r[t+1]])}return{vertices:n,indices:r}}function jx(t){const e=function(t,e){const i=[],n=WebGL2RenderingContext;if(t.json.textures)for(const r of t.json.textures){const o={magFilter:n.LINEAR,minFilter:n.NEAREST,wrapS:n.REPEAT,wrapT:n.REPEAT};void 0!==r.sampler&&Object.assign(o,t.json.samplers[r.sampler]),i.push({image:e[r.source],sampler:o,uploaded:!1})}return i}(t,t.images),i=function(t,e){const i=[];for(const n of t.json.meshes){const r=[];for(const i of n.primitives)r.push(Ox(i,t,e));i.push(r)}return i}(t,e),{scenes:n,scene:r,nodes:o}=t.json,s=n?n[r||0].nodes:o,a=[];for(const e of s)a.push(Bx(o[e],t,i));return function(t,e,i){const n={},r=new Set;for(let o=0;o0){const e=Array.from(r.values()).sort(((t,e)=>t-e));for(let i=e.length-1;i>=0;i--)t.splice(e[i],1)}}(a,s,t.json.nodes),a}function Vx(t){t.heightmap=new Float32Array(4096),t.heightmap.fill(-1);const e=t.vertexArray.float32,i=t.aabb.min[0]-1,n=t.aabb.min[1]-1,r=Wv/(t.aabb.max[0]-i+2),o=Wv/(t.aabb.max[1]-n+2);for(let s=0;st.heightmap[c*Wv+l]&&(t.heightmap[c*Wv+l]=a)}}function Gx(e,i){const n={};n.indexArray=new Kl,n.indexArray.reserve(4*e.length),n.vertexArray=new Bl,n.vertexArray.reserve(10*e.length),n.colorArray=new Ol,n.vertexArray.reserve(10*e.length);let r=0;for(const o of e){const e=Math.min(10,Math.max(4,1.3*o.height))*i,s=[-o.normal[1],o.normal[0],0],a=Math.min(.29,.1*o.width/o.depth),l=o.width-2*o.depth*i*(a+.01),c=t._.scaleAndAdd([],o.pos,s,l/2),d=t._.scaleAndAdd([],o.pos,s,-l/2),u=[c[0],c[1],c[2]+o.height],h=[d[0],d[1],d[2]+o.height],p=t._.scaleAndAdd([],o.normal,s,a);t._.scale(p,p,e);const f=t._.scaleAndAdd([],o.normal,s,-a);t._.scale(f,f,e),t._.add(p,c,p),t._.add(f,d,f),c[2]+=.1,d[2]+=.1,n.vertexArray.emplaceBack(p[0],p[1],p[2]),n.vertexArray.emplaceBack(f[0],f[1],f[2]),n.vertexArray.emplaceBack(c[0],c[1],c[2]),n.vertexArray.emplaceBack(d[0],d[1],d[2]),n.vertexArray.emplaceBack(u[0],u[1],u[2]),n.vertexArray.emplaceBack(h[0],h[1],h[2]),n.vertexArray.emplaceBack(c[0],c[1],c[2]),n.vertexArray.emplaceBack(d[0],d[1],d[2]),n.vertexArray.emplaceBack(p[0],p[1],p[2]),n.vertexArray.emplaceBack(f[0],f[1],f[2]);const m=l/e/2;n.colorArray.emplaceBack(-m-a,-1,m,.8),n.colorArray.emplaceBack(m+a,-1,m,.8),n.colorArray.emplaceBack(-m,0,m,1.3),n.colorArray.emplaceBack(m,0,m,1.3),n.colorArray.emplaceBack(m+a,-.8,m,.7),n.colorArray.emplaceBack(m+a,-.8,m,.7),n.colorArray.emplaceBack(0,0,m,1.3),n.colorArray.emplaceBack(0,0,m,1.3),n.colorArray.emplaceBack(m+a,-1.2,m,.8),n.colorArray.emplaceBack(m+a,-1.2,m,.8),n.indexArray.emplaceBack(6+r,4+r,8+r),n.indexArray.emplaceBack(7+r,9+r,5+r),n.indexArray.emplaceBack(0+r,1+r,2+r),n.indexArray.emplaceBack(1+r,3+r,2+r),r+=10}const o={defined:!0,emissiveFactor:[0,0,0]},s={};return s.baseColorFactor=Un.white,o.pbrMetallicRoughness=s,n.material=o,n.aabb=new wu([1/0,1/0,1/0],[-1/0,-1/0,-1/0]),n}const Zx=new Float32Array(262144),qx=new Uint8Array(262144);function Hx(t){let e=0;if(t.meshes)for(const i of t.meshes)e=Math.max(e,i.aabb.max[2]);if(t.children)for(const i of t.children)e=Math.max(e,Hx(i));return e}function Wx(t,e,i){if(t.meshes)for(const n of t.meshes)n.aabb.min[0]!==1/0&&i.insert(e,n.aabb.min[0],n.aabb.min[1],n.aabb.max[0],n.aabb.max[1]);if(t.children)for(const n of t.children)Wx(n,e,i)}const Yx=["","wall","door","roof","window","lamp","logo"];class Xx{constructor(t){this.node=t,this.evaluatedRMEA=[[1,0,0,1],[1,0,0,1],[1,0,0,1],[1,0,0,1],[.4,1,0,1],[1,0,0,1],[1,0,0,1]],this.hiddenByReplacement=!1,this.evaluatedScale=[1,1,1],this.evaluatedColor=[],this.emissionHeightBasedParams=[],this.feature={type:"Point",id:t.id,geometry:[],properties:{height:Hx(t)}},this.aabb=this._getLocalBounds()}_getLocalBounds(){if(!this.node.meshes)return new wu([1/0,1/0,1/0],[-1/0,-1/0,-1/0]);if(!this.aabb){let t=0;const e=new wu([1/0,1/0,1/0],[-1/0,-1/0,-1/0]);for(const i of this.node.meshes)this.node.lightMeshIndex!==t&&(i.transformedAabb=wu.applyTransformFast(i.aabb,this.node.matrix),e.encapsulate(i.transformedAabb)),t++;this.aabb=e}return this.aabb}}class Kx{constructor(t,e,i,n,r,o){this.id=e,this.modelTraits|=Yv.CoordinateSpaceTile,this.uploaded=!1,this.hasPattern=!1,i&&(this.modelTraits|=Yv.HasMapboxMeshFeatures),n&&(this.modelTraits|=Yv.HasMeshoptCompression),this.zoom=-1,this.terrainExaggeration=1,this.projection={name:"mercator"},this.replacementUpdateTime=0,this.elevationReadFromZ=255,this.brightness=r,this.dirty=!0,this.needsUpload=!1,this.nodesInfo=[];for(const e of t)this.nodesInfo.push(new Xx(e)),Wx(e,o.featureIndexArray.length,o.grid),o.featureIndexArray.emplaceBack(this.nodesInfo.length-1,0,o.bucketLayerIDs.length-1,0)}updateFootprints(t,e){for(const i of this.getNodesInfo()){const n=i.node;n.footprint&&e.push({footprint:n.footprint,id:t})}}update(){console.log("Update 3D model bucket")}populate(){console.log("populate 3D model bucket")}uploadPending(){return!this.uploaded||this.needsUpload}upload(t){if(!this.needsUpload)return;const e=this.getNodesInfo();for(const i of e){const e=i.node;this.uploaded?this.updatePbrBuffer(e):Qv(e,t,!0)}for(const t of e)tx(t.node);this.uploaded=!0,this.needsUpload=!1}updatePbrBuffer(t){let e=!1;if(!t.meshes)return e;for(const i of t.meshes)i.pbrBuffer&&(i.pbrBuffer.updateData(i.featureArray),e=!0);return e}needsReEvaluation(t,e,i){const n=t.transform.projectionOptions,r=t.style.getBrightness(),o=this.brightness!==r;return!!(!this.uploaded||this.dirty||n.name!==this.projection.name||Jx(i.paint.get("model-color").value,o)||Jx(i.paint.get("model-color-mix-intensity").value,o)||Jx(i.paint.get("model-roughness").value,o)||Jx(i.paint.get("model-emissive-strength").value,o)||Jx(i.paint.get("model-height-based-emissive-strength-multiplier").value,o))&&(this.projection=n,this.brightness=r,!0)}evaluateScale(t,e){if(t.transform.zoom===this.zoom)return;this.zoom=t.transform.zoom;const i=this.getNodesInfo(),n=this.id.canonical;for(const t of i){const i=t.feature;t.evaluatedScale=e.paint.get("model-scale").evaluate(i,{},n)}}evaluate(t){const e=this.getNodesInfo();for(const i of e){if(!i.node.meshes)continue;const e=i.feature,n=i.node.meshes&&i.node.meshes[0].featureData,r=i.evaluatedColor[2],o=i.evaluatedRMEA[2],s=this.id.canonical;if(i.hasTranslucentParts=!1,n){for(let n=0;n=t)continue;const u=Zx[c],h=Math.abs(u);h>a&&(s=u,a=h,l=r,d=e)}if(a>.1){const o=1-(t+.5*Math.abs(l*d))/c;let a=e._dem.get(n,i)+s*o;const u=e._dem.get(n+l,i+d),h=e._dem.get(n-l,i-d,!0);(a-u)*(a-h)>0&&(a=(u+h)/2),Zx[r]=e._dem.set(n,i,a),qx[r]=t}}}}}s&&(e._demTile.needsDEMTextureUpload=!0,e._dem._timestamp=ki.now())}getNodesInfo(){return this.nodesInfo}destroy(){const t=this.getNodesInfo();for(const e of t)tx(e.node),ex(e.node)}isEmpty(){return!this.nodesInfo.length}updateReplacement(t,e){if(e.updateTime===this.replacementUpdateTime)return;this.replacementUpdateTime=e.updateTime;const i=e.getReplacementRegionsForTile(t.toUnwrapped()),n=this.getNodesInfo();for(let t=0;tt.footprint===e.footprint))}}getHeightAtTileCoord(e,i){const n=this.getNodesInfo(),r=[],o=[0,0,0],s=t.ad.identity([]);for(let a=0;ad.max[0]||i>d.max[1])continue;if(!0===l.node.hidden)return{height:0,maxHeight:l.feature.properties.height,hidden:!1,verticalScale:l.evaluatedScale[2]};t.ad.invert(s,l.node.matrix),o[0]=e,o[1]=i,t._.transformMat4(o,o,s);const u=(o[0]-c.aabb.min[0])/(c.aabb.max[0]-c.aabb.min[0])*Wv|0,h=Math.min(63,(o[1]-c.aabb.min[1])/(c.aabb.max[1]-c.aabb.min[1])*Wv|0)*Wv+Math.min(63,u),p=c.heightmap[h];if(!(p0)return{height:void 0,maxHeight:l.feature.properties.height,hidden:l.hiddenByReplacement,verticalScale:l.evaluatedScale[2]}}}}function Jx(t,e){return!t.isLightConstant&&e}function Qx(t,e,i,n,r,o,s,a){let l=(61440&e|(61440&e)>>4)>>8,c=(3840&e|(3840&e)>>4)>>4,d=240&e|(240&e)>>4;i[3]>0&&(l=Vn(l,255*i[0],i[3]),c=Vn(c,255*i[1],i[3]),d=Vn(d,255*i[2],i[3]));const u=l>16&65535,a=o?e>>16&65535:65535&e,l=(15&a)t.polygon)).flat());const g=f?l:null,[y,v]=function(e,i,n,r,o,s,a,l,c,d,u){return"globe"===e.projection.name?function(e,i,n,r,o,s,a,l,c,d,u){const h=[],p=[],f=e.projection.upVectorScale(u,e.center.lat,e.worldSize).metersToTile,m=[0,0,0,1],_=[0,0,0,1],g=(t,e,i,n)=>{t[0]=e,t[1]=i,t[2]=n,t[3]=1},y=Sf();n>0&&(n+=y),r+=y;for(const y of i){const i=[],v=[];for(const h of y){const p=h.x+o.x,y=h.y+o.y,x=e.projection.projectTilePoint(p,y,u),b=e.projection.upVector(u,h.x,h.y);let w=n,T=r;if(a){const t=Pf(p,y,n,r,a,l,c,d);w+=t.base,T+=t.top}0!==n?g(m,x.x+b[0]*f*w,x.y+b[1]*f*w,x.z+b[2]*f*w):g(m,x.x,x.y,x.z),g(_,x.x+b[0]*f*T,x.y+b[1]*f*T,x.z+b[2]*f*T),t._.transformMat4(m,m,s),t._.transformMat4(_,_,s),i.push(new Tp(m[0],m[1],m[2])),v.push(new Tp(_[0],_[1],_[2]))}h.push(i),p.push(v)}return[h,p]}(e,i,n,r,o,s,a,l,c,d,u):a?function(e,i,n,r,o,s,a,l,c){const d=[],u=[],h=[0,0,0,1];for(const p of e){const e=[],f=[];for(const d of p){const u=d.x+r.x,p=d.y+r.y,m=Pf(u,p,i,n,s,a,l,c);h[0]=u,h[1]=p,h[2]=m.base,h[3]=1,t.aA.transformMat4(h,h,o),h[3]=Math.max(h[3],1e-5);const _=new Tp(h[0]/h[3],h[1]/h[3],h[2]/h[3]);h[0]=u,h[1]=p,h[2]=m.top,h[3]=1,t.aA.transformMat4(h,h,o),h[3]=Math.max(h[3],1e-5);const g=new Tp(h[0]/h[3],h[1]/h[3],h[2]/h[3]);e.push(_),f.push(g)}d.push(e),u.push(f)}return[d,u]}(i,n,r,o,s,a,l,c,d):function(t,e,i,n,r){const o=[],s=[],a=r[8]*e,l=r[9]*e,c=r[10]*e,d=r[11]*e,u=r[8]*i,h=r[9]*i,p=r[10]*i,f=r[11]*i;for(const e of t){const t=[],i=[];for(const o of e){const e=o.x+n.x,s=o.y+n.y,m=r[0]*e+r[4]*s+r[12],_=r[1]*e+r[5]*s+r[13],g=r[2]*e+r[6]*s+r[14],y=r[3]*e+r[7]*s+r[15],v=m+a,x=_+l,b=g+c,w=Math.max(y+d,1e-5),T=m+u,S=_+h,E=g+p,M=Math.max(y+f,1e-5);t.push(new Tp(v/w,x/w,b/w)),i.push(new Tp(T/M,S/M,E/M))}o.push(t),s.push(i)}return[o,s]}(i,n,r,o,s)}(s,r,h,u,d,a,g,p,m,s.center.lat,e.tileID.canonical),x=e.queryGeometry;return function(t,e,i){let n=1/0;Kd(i,e)&&(n=Lf(i,e[0]));for(let r=0;r=3)for(let e=0;e>4;if(1!==n)throw new Error(`Got v${n} data when expected v1.`);const r=nb[15&i];if(!r)throw new Error("Unrecognized array type.");const[o]=new Uint16Array(t,2,1),[s]=new Uint32Array(t,4,1);return new rb(s,o,r,t)}constructor(t,e=64,i=Float64Array,n){if(isNaN(t)||t>1;return this.ids[i]=i,this.coords[this._pos++]=t,this.coords[this._pos++]=e,i}finish(){const t=this._pos>>1;if(t!==this.numItems)throw new Error(`Added ${t} items when expected ${this.numItems}.`);return ob(this.ids,this.coords,this.nodeSize,0,this.numItems-1,0),this._finished=!0,this}range(t,e,i,n){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");const{ids:r,coords:o,nodeSize:s}=this,a=[0,r.length-1,0],l=[];for(;a.length;){const c=a.pop()||0,d=a.pop()||0,u=a.pop()||0;if(d-u=t&&a=e&&c>1,p=o[2*h],f=o[2*h+1];p>=t&&p=e&&f=p:n>=f)&&(a.push(h+1),a.push(d),a.push(1-c))}return l}within(t,e,i){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");const{ids:n,coords:r,nodeSize:o}=this,s=[0,n.length-1,0],a=[],l=i*i;for(;s.length;){const c=s.pop()||0,d=s.pop()||0,u=s.pop()||0;if(d-u>1,p=r[2*h],f=r[2*h+1];cb(p,f,t,e)=p:e+i>=f)&&(s.push(h+1),s.push(d),s.push(1-c))}return a}}function ob(t,e,i,n,r,o){if(r-n>1;sb(t,e,s,n,r,o),ob(t,e,i,n,s-1,1-o),ob(t,e,i,s+1,r,1-o)}function sb(t,e,i,n,r,o){for(;r>n;){if(r-n>600){const s=r-n+1,a=i-n+1,l=Math.log(s),c=.5*Math.exp(2*l/3),d=.5*Math.sqrt(l*c*(s-c)/s)*(a-s/2s&&ab(t,e,n,r);as;)l--}e[2*n+o]===s?ab(t,e,n,l):(l++,ab(t,e,l,r)),lr&&(n+=(t[i]-r)*(t[i]-r)),e[i]0&&n[0]0&&n[1]0&&r[0]0&&r[1]0?Math.acos(i/n)*Ve:0;let o=0!==t||0!==e?Math.atan2(-e,-t)*Ve+90:0;return oNi&&(t.getActor().send("enforceCacheSizeLimit",Fi),Vi=0)},t.an=gn,t.ao=class{constructor(t){this.entries={},this.scheduler=t}request(t,e,i,n){const r=this.entries[t]=this.entries[t]||{callbacks:[]};if(r.result){const[t,i]=r.result;return this.scheduler?this.scheduler.add((()=>{n(t,i)}),e):n(t,i),()=>{}}return r.callbacks.push(n),r.cancel||(r.cancel=i(((i,n)=>{r.result=[i,n];for(const t of r.callbacks)this.scheduler?this.scheduler.add((()=>{t(i,n)}),e):t(i,n);setTimeout((()=>delete this.entries[t]),3e3)}))),()=>{r.result||(r.callbacks=r.callbacks.filter((t=>t!==n)),r.callbacks.length||(r.cancel(),delete this.entries[t]))}}},t.ap=function(t,e,i){const n=JSON.stringify(t.request);return t.data&&(this.deduped.entries[n]={result:[null,t.data]}),this.deduped.request(n,{type:"parseTile",isSymbolTile:t.isSymbolTile,zoom:t.tileZoom},(e=>{const n=en(t.request,((t,n,r,o)=>{t?e(t):n&&e(null,{vectorTile:i?void 0:new bp(new Lm(n)),rawData:n,cacheControl:r,expires:o})}));return()=>{n.cancel(),e()}}),e)},t.aq=Dc,t.ar=class extends Lc{constructor(t){super(t),this.current=Fc}set(t,e,i){if(this.fetchUniformLocation(t,e))for(let t=0;t({u_camera_to_center_distance:new $c(t),u_extrude_scale:new Uc(t),u_device_pixel_ratio:new $c(t),u_matrix:new Bc(t),u_inv_rot_matrix:new Bc(t),u_merc_center:new kc(t),u_tile_id:new Dc(t),u_zoom_transition:new $c(t),u_up_dir:new Dc(t),u_emissive_strength:new $c(t)}),t.bJ=t=>({u_matrix:new Bc(t),u_pixels_to_tile_units:new Uc(t),u_device_pixel_ratio:new $c(t),u_units_to_pixels:new kc(t),u_dash_image:new Pc(t),u_gradient_image:new Pc(t),u_image_height:new $c(t),u_texsize:new kc(t),u_tile_units_to_pixels:new $c(t),u_alpha_discard_threshold:new $c(t),u_trim_offset:new kc(t),u_trim_fade_range:new kc(t),u_trim_color:new zc(t),u_emissive_strength:new $c(t)}),t.bK=t=>({u_matrix:new Bc(t),u_texsize:new kc(t),u_pixels_to_tile_units:new Uc(t),u_device_pixel_ratio:new $c(t),u_image:new Pc(t),u_units_to_pixels:new kc(t),u_tile_units_to_pixels:new $c(t),u_alpha_discard_threshold:new $c(t),u_trim_offset:new kc(t)}),t.bL=Yl,t.bM=Hf,t.bN=Om,t.bO=jm,t.bP=G_,t.bQ=c_,t.bR=th,t.bS=(t,e,i,n,r,o)=>{const s=t.transform,a="globe"===s.projection.name;let l;if("map"===o.paint.get("circle-pitch-alignment"))if(a){const t=Zu(s.zoom,e.canonical)*s._pixelsPerMercatorPixel;l=Float32Array.from([t,0,0,t])}else l=s.calculatePixelsToTileUnitsMatrix(i);else l=new Float32Array([s.pixelsToGLUnits[0],0,0,s.pixelsToGLUnits[1]]);const c={u_camera_to_center_distance:t.transform.getCameraToCenterDistance(s.projection),u_matrix:t.translatePosMatrix(e.projMatrix,i,o.paint.get("circle-translate"),o.paint.get("circle-translate-anchor")),u_device_pixel_ratio:ki.devicePixelRatio,u_extrude_scale:l,u_inv_rot_matrix:Qu,u_merc_center:[0,0],u_tile_id:[0,0,0],u_zoom_transition:0,u_up_dir:[0,0,0],u_emissive_strength:o.paint.get("circle-emissive-strength")};if(a){c.u_inv_rot_matrix=n,c.u_merc_center=r,c.u_tile_id=[e.canonical.x,e.canonical.y,1{const s=t.transform;return{u_matrix:rm(t,e,i,n),u_texsize:e.imageAtlasTexture?e.imageAtlasTexture.size:[0,0],u_pixels_to_tile_units:s.calculatePixelsToTileUnitsMatrix(e),u_device_pixel_ratio:r,u_image:0,u_tile_units_to_pixels:nm(e,s),u_units_to_pixels:[1/s.pixelsToGLUnits[0],1/s.pixelsToGLUnits[1]],u_alpha_discard_threshold:0,u_trim_offset:o}},t.bV=(t,e,i,n,r,o,s)=>{const a=t.transform,l=a.calculatePixelsToTileUnitsMatrix(e);return{u_matrix:rm(t,e,i,n),u_pixels_to_tile_units:l,u_device_pixel_ratio:o,u_units_to_pixels:[1/a.pixelsToGLUnits[0],1/a.pixelsToGLUnits[1]],u_dash_image:0,u_gradient_image:1,u_image_height:r,u_texsize:sm(i)&&e.lineAtlasTexture?e.lineAtlasTexture.size:[0,0],u_tile_units_to_pixels:nm(e,t.transform),u_alpha_discard_threshold:0,u_trim_offset:s,u_trim_fade_range:i.paint.get("line-trim-fade-range"),u_trim_color:i.paint.get("line-trim-color").toRenderColor(i.lut).toArray01(),u_emissive_strength:i.paint.get("line-emissive-strength")}},t.bW=oi,t.bX=mh,t.bY=Sf,t.bZ=bd,t.b_=_f,t.ba=function(t,e,i){const n=Hu(i.zoom),r=t.style.map._antialias,o=e.options.extStandardDerivativesForceOff||t.terrain&&t.terrain.exaggeration()>0;return 0===n&&!r&&!o},t.bb=function(e){const i=e.pixelsPerMeter,n=i/Cd(1,e.center.lat),r=t.ad.identity(new Float64Array(16));return t.ad.translate(r,r,[e.point.x,e.point.y,0]),t.ad.scale(r,r,[n,n,i]),Float32Array.from(r)},t.bc=Ou,t.bd=function(t){const e=Pd-5;t=Xe(t,-e,e)/e*90;const i=Math.pow(Math.abs(Math.sin(Ge(t))),3);return Math.round(i*(sd.length-1))},t.be=function(e,i,n,r){const o=i.getNorth(),s=i.getSouth(),a=i.getWest(),l=i.getEast(),c=10){const e=180/r;t.bC.multiply(f,f,[e/d+1,0,0,0,e/u+1,0,-.5*e/h,.5*e/p,1])}return f[2]=c,f[5]=e.x,f[8]=e.y,f},t.bf=ju,t.bg=$u,t.bh=function(e,i,n){const r=t.ad.identity(new Float64Array(16)),o=(i/(1{}}},t.bo=Gg,t.bp=ai,t.bq=class{isDataAvailableAtPoint(t){const e=this._source();if(this.isUsingMockSource()||!e||t.y1)return!1;const i=e.getSource().maxzoom,n=11)return e;const r=n.getSource().maxzoom,o=1{const s=this.getAtTileOffset(e,o.x,o.y),a=r.upVector(e.canonical,o.x,o.y),l=r.upVectorScale(e.canonical,i,n).metersToTile;return t._.scale(a,a,s*l),a}}getForTilePoints(t,e,i,n){if(this.isUsingMockSource())return!1;const r=Xp.create(this,t,n);return!!r&&(e.forEach((t=>{t[2]=this.exaggeration()*r.getElevationAt(t[0],t[1],i)})),!0)}getMinMaxForTile(t){if(this.isUsingMockSource())return null;const e=this.findDEMTileFor(t);if(!e||!e.dem)return null;const i=e.dem.tree,n=e.tileID,r=1=0?t.slice(0,e):t},t.cV=function(t){return t.indexOf(wl)>=0},t.cW=function(t){const e=t.indexOf(wl);return e>=0?t.slice(e+1):""},t.cX=function(t){const e=[],i=t.id;return void 0===i&&e.push({message:`layers.${i}: missing required property "id"`}),void 0===t.render&&e.push({message:`layers.${i}: missing required method "render"`}),t.renderingMode&&"2d"!==t.renderingMode&&"3d"!==t.renderingMode&&e.push({message:`layers.${i}: property "renderingMode" must be either "2d" or "3d"`}),e},t.cY=function(t,e,i,n){return"custom"===t.type?new vv(t,e):new ib[t.type](t,e,i,n)},t.cZ=di,t.c_=Va,t.ca=1,t.cb=Ag,t.cc=0,t.cd=ec,t.ce=function(t,e,i,n,r){return Xe((t-e)/(i-e)*(r-n)+n,n,r)},t.cf=Ns,t.cg=kd,t.ch=class{constructor(t,e,i,n){this.context=t,this.format=n,this.size=i,this.texture=t.gl.createTexture();const[r,o,s]=this.size,{gl:a}=t;a.bindTexture(a.TEXTURE_3D,this.texture),t.pixelStoreUnpackFlipY.set(!1),t.pixelStoreUnpack.set(1),t.pixelStoreUnpackPremultiplyAlpha.set(!1);let l=this.format,c=a.UNSIGNED_BYTE;this.format===a.DEPTH_COMPONENT&&(l=a.DEPTH_COMPONENT16,c=a.UNSIGNED_SHORT),this.format===a.R8&&(n=a.RED),this.format===a.R32F&&(c=a.FLOAT,n=a.RED),a.texImage3D(a.TEXTURE_3D,0,l,r,o,s,0,n,c,e.data)}bind(t,e){const{context:i}=this,{gl:n}=i;n.bindTexture(n.TEXTURE_3D,this.texture),t!==this.minFilter&&(n.texParameteri(n.TEXTURE_3D,n.TEXTURE_MAG_FILTER,t),n.texParameteri(n.TEXTURE_3D,n.TEXTURE_MIN_FILTER,t),this.minFilter=t),e!==this.wrapS&&(n.texParameteri(n.TEXTURE_3D,n.TEXTURE_WRAP_S,e),n.texParameteri(n.TEXTURE_3D,n.TEXTURE_WRAP_T,e),this.wrapS=e)}destroy(){const{gl:t}=this.context;t.deleteTexture(this.texture),this.texture=null}},t.ci=$v,t.cj=[1,1,1],t.ck=Xp,t.cl=Yv,t.cm=ql,t.cn=ic,t.co=class{constructor(){this._updateTime=0,this._sourceIds=[],this._activeRegions=[],this._prevRegions=[],this._globalClipBounds={min:new Ue(1/0,1/0),max:new Ue(-1/0,-1/0)}}clear(){this._activeRegions.length>0&&++this._updateTime,this._activeRegions=[],this._prevRegions=[]}get updateTime(){return this._updateTime}getReplacementRegionsForTile(t,e=!1){const i=$p(new Ue(0,0),new Ue(uo,uo),t),n=[];if(e&&!Lp(i,this._globalClipBounds))return n;for(const e of this._activeRegions){if(e.hiddenByOverlap)continue;if(!Lp(i,e))continue;const r=kp(e.min,e.max,t);n.push({min:r.min,max:r.max,sourceId:this._sourceIds[e.priority],footprint:e.footprint,footprintTileId:e.tileId,order:e.order,clipMask:e.clipMask})}return n}setSources(t){this._setSources(t.map((t=>({getSourceId:()=>t.cache.id,getFootprints:()=>{const e=[];for(const i of t.cache.getVisibleCoordinates()){const n=t.cache.getTile(i).buckets[t.layer];n&&n.updateFootprints(i.toUnwrapped(),e)}return e},getOrder:()=>t.order,getClipMask:()=>t.clipMask}))))}_addSource(t){const e=t.getFootprints();if(0===e.length)return;const i=t.getOrder(),n=t.getClipMask();for(const t of e){if(!t.footprint)continue;const e=$p(t.footprint.min,t.footprint.max,t.id);this._activeRegions.push({min:e.min,max:e.max,hiddenByOverlap:!1,priority:this._sourceIds.length,tileId:t.id,footprint:t.footprint,order:i,clipMask:n})}this._sourceIds.push(t.getSourceId())}_computeReplacement(){this._activeRegions.sort(((t,e)=>t.priority-e.priority||Ap(t.min,e.min)||Ap(t.max,e.max)));let t=this._activeRegions.length!==this._prevRegions.length;if(!t){let e=0;for(;!t&&e!==this._activeRegions.length;){const i=this._activeRegions[e],n=this._prevRegions[e];t=i.priority!==n.priority||!Ip(i,n)||i.order!==n.order||i.clipMask!==n.clipMask,++e}}if(t){++this._updateTime;for(const t of this._activeRegions)t.order!==1/0&&(this._globalClipBounds.min.x=Math.min(this._globalClipBounds.min.x,t.min.x),this._globalClipBounds.min.y=Math.min(this._globalClipBounds.min.y,t.min.y),this._globalClipBounds.max.x=Math.max(this._globalClipBounds.max.x,t.max.x),this._globalClipBounds.max.y=Math.max(this._globalClipBounds.max.y,t.max.y));const t=t=>{const e=this._activeRegions;if(t>=e.length)return t;const i=e[t].priority;for(;t1){let e=0,i=t(e);for(;e!==i;){let n=e;const r=e;for(;n!==i;){const t=this._activeRegions[n];t.hiddenByOverlap=!1;for(let e=0;e=0;e--)this._addSource(t[e]);this._computeReplacement()}},t.cp=Dl,t.cq=Jg,t.cr=rc,t.cs=class{constructor(t){this._createGrid(t),this._createPoles(t)}destroy(){this._poleIndexBuffer.destroy(),this._gridBuffer.destroy(),this._gridIndexBuffer.destroy(),this._poleNorthVertexBuffer.destroy(),this._poleSouthVertexBuffer.destroy();for(const t of this._poleSegments)t.destroy();for(const t of this._gridSegments)t.withSkirts.destroy(),t.withoutSkirts.destroy()}_fillGridMeshWithLods(t,e){const i=new $l,n=new Kl,r=[],o=t+1+2,s=e[0]+1,a=e[0]+1+(1+e.length),l=(t,e,i)=>{let n=t===o-1?t-2:0===t?t:t-1;return n+=i?24575:0,[n,e]};for(let t=0;tt()))},t.dB=sx,t.dC=yx,t.dD=function(t){px=ki.resolveURL(t),gx||(gx=new ox(ux(),new zn)),gx.broadcast("setDracoUrl",px)},t.dE=vx,t.dF=function(t){mx=ki.resolveURL(t),gx||(gx=new ox(ux(),new zn)),gx.broadcast("setMeshoptUrl",mx)},t.dG=ti,t.dH=ba,t.dI=dh,t.dJ=I_,t.dK=eg,t.dL=dc,t.dM=am,t.dN=Dm,t.dO=Wf,t.dP=ci,t.dQ=E_,t.dR=jg,t.dS=function(t,e,i,n,r,o,s,a,l,c,d){t.createArrays(),t.tilePixelRatio=uo/(512*t.overscaling),t.compareText={},t.iconsNeedLinear=!1;const u=t.layers[0].layout,h=t.layers[0]._unevaluatedLayout._values,p={};if("composite"===t.textSizeData.kind){const{minZoom:e,maxZoom:i}=t.textSizeData;p.compositeTextSizes=[h["text-size"].possiblyEvaluate(new Ha(e),a),h["text-size"].possiblyEvaluate(new Ha(i),a)]}if("composite"===t.iconSizeData.kind){const{minZoom:e,maxZoom:i}=t.iconSizeData;p.compositeIconSizes=[h["icon-size"].possiblyEvaluate(new Ha(e),a),h["icon-size"].possiblyEvaluate(new Ha(i),a)]}p.layoutTextSize=h["text-size"].possiblyEvaluate(new Ha(l+1),a),p.layoutIconSize=h["icon-size"].possiblyEvaluate(new Ha(l+1),a),p.textMaxSize=h["text-size"].possiblyEvaluate(new Ha(18),a);const f="map"===u.get("text-rotation-alignment")&&"point"!==u.get("symbol-placement"),m=u.get("text-size");let _=!1;for(const e of t.features)if(e.icon&&e.icon.nameSecondary){_=!0;break}for(const o of t.features){const l=u.get("text-font").evaluate(o,{},a).join(","),h=m.evaluate(o,{},a),g=p.layoutTextSize.evaluate(o,{},a),y=(p.layoutIconSize.evaluate(o,{},a),{horizontal:{},vertical:void 0}),v=o.text;let x,b=[0,0];if(v){const n=v.toString(),s=u.get("text-letter-spacing").evaluate(o,{},a)*Om,c=u.get("text-line-height").evaluate(o,{},a)*Om,d=Aa(n)?s:0,p=u.get("text-anchor").evaluate(o,{},a),m=u.get("text-variable-anchor");if(!m){const t=u.get("text-radial-offset").evaluate(o,{},a);b=t?G_(p,[t*Om,j_]):u.get("text-offset").evaluate(o,{},a).map((t=>t*Om))}let _=f?"center":u.get("text-justify").evaluate(o,{},a);const x="point"===u.get("symbol-placement"),w=x?u.get("text-max-width").evaluate(o,{},a)*Om:1/0,T=o=>{t.allowVerticalPlacement&&Ca(n)&&(y.vertical=e_(v,e,i,r,l,w,c,p,o,d,b,Jm.vertical,!0,g,h))};if(!f&&m){const t="auto"===_?m.map((t=>Z_(t))):[_];let n=!1;for(let o=0;o=0||!Ca(n)){const t=e_(v,e,i,r,l,w,c,p,_,d,b,Jm.horizontal,!1,g,h);t&&(y.horizontal[_]=t)}T(x?"left":_)}}let w=!1;if(o.icon&&o.icon.namePrimary){const e=n[o.icon.namePrimary];e&&(x=u_(r[o.icon.namePrimary],o.icon.nameSecondary?r[o.icon.nameSecondary]:void 0,u.get("icon-offset").evaluate(o,{},a),u.get("icon-anchor").evaluate(o,{},a)),w=e.sdf,void 0===t.sdfIcons?t.sdfIcons=e.sdf:t.sdfIcons!==e.sdf&&pi("Style sheet warning: Cannot mix SDF and non-SDF icons in one buffer"),(e.pixelRatio!==t.pixelRatio||0!==u.get("icon-rotate").constantOr(1))&&(t.iconsNeedLinear=!0))}const T=X_(y.horizontal)||y.vertical;t.iconsInText||(t.iconsInText=!!T&&T.iconsInText),(T||x)&&q_(t,o,y,x,n,p,g,0,b,w,s,a,c,d,_)}o&&t.generateCollisionDebugBuffers(l,t.collisionBoxArray)},t.dT=Jf,t.dU=Yh,t.dV=bp,t.dW=Lm,t.dX=Yp,t.dY=Zy,t.dZ=wp,t.d_=cp,t.da=Wu,t.db=function(e){const i=[0,0,0],n=t.ad.identity(new Float64Array(16));return t.ad.multiply(n,e.pixelMatrix,e.globeMatrix),t._.transformMat4(i,i,n),new Ue(i[0],i[1])},t.dc=d,t.dd=c,t.de=function(t){const e=t.navigator?t.navigator.userAgent:null;return!!function(t){if(null==Ei){const e=t.navigator?t.navigator.userAgent:null;Ei=!!t.safari||!(!e||!(/\b(iPad|iPhone|iPod)\b/.test(e)||e.match("Safari")&&!e.match("Chrome")))}return Ei}(t)&&e&&(e.match("Version/15.4")||e.match("Version/15.5")||e.match(/CPU (OS|iPhone OS) (15_4|15_5) like Mac OS X/))},t.df=ni,t.dg=class{constructor(t,e,i){this._transformRequestFn=t,this._customAccessToken=e,this._silenceAuthErrors=!!i,this._createSkuToken()}_createSkuToken(){const t=function(){let t="";for(let e=0;ethis._skuTokenExpiresAt}transformRequest(t,e){return this._transformRequestFn&&this._transformRequestFn(t,e)||{url:t}}normalizeStyleURL(t,i){if(!o(t))return t;const n=un(t);return n.params.push(`sdk=js-${e}`),n.path=`/styles/v1${n.path}`,this._makeAPIURL(n,this._customAccessToken||i)}normalizeGlyphsURL(t,e){if(!o(t))return t;const i=un(t);return i.path=`/fonts/v1${i.path}`,this._makeAPIURL(i,this._customAccessToken||e)}normalizeModelURL(t,e){if(!o(t))return t;const i=un(t);return i.path=`/models/v1${i.path}`,this._makeAPIURL(i,this._customAccessToken||e)}normalizeSourceURL(t,e,i,n){if(!o(t))return t;const r=un(t);return r.path=`/v4/${r.authority}.json`,r.params.push("secure"),i&&r.params.push(`language=${i}`),n&&r.params.push(`worldview=${n}`),this._makeAPIURL(r,this._customAccessToken||e)}normalizeSpriteURL(t,e,i,n){const r=un(t);return o(t)?(r.path=`/styles/v1${r.path}/sprite${e}${i}`,this._makeAPIURL(r,this._customAccessToken||n)):(r.path+=`${e}${i}`,hn(r))}normalizeTileURL(t,e,i){if(this._isSkuTokenExpired()&&this._createSkuToken(),t&&!o(t))return t;const r=un(t);r.path=r.path.replace(/(\.(png|jpg)\d*)(?=$)/,`${e||i&&"raster"!==r.authority&&512===i?"@2x":""}${Gi.supported?".webp":"$1"}`),"raster"===r.authority?r.path=`/${n.RASTER_URL_PREFIX}${r.path}`:"rasterarrays"===r.authority?r.path=`/${n.RASTERARRAYS_URL_PREFIX}${r.path}`:"3dtiles"===r.authority?r.path=`/${n.TILES3D_URL_PREFIX}${r.path}`:(r.path=r.path.replace(/^.+\/v4\//,"/"),r.path=`/${n.TILE_URL_VERSION}${r.path}`);const s=this._customAccessToken||function(t){for(const e of t){const t=e.match(/^access_token=(.*)$/);if(t)return t[1]}return null}(r.params)||n.ACCESS_TOKEN;return n.REQUIRE_ACCESS_TOKEN&&s&&this._skuToken&&r.params.push(`sku=${this._skuToken}`),this._makeAPIURL(r,s)}canonicalizeTileURL(t,e){const i=un(t);if(!i.path.match(/^(\/v4\/|\/(raster|rasterarrays)\/v1\/)/)||!i.path.match(/\.[\w]+$/))return t;let r="mapbox://";i.path.match(/^\/raster\/v1\//)?r+=`raster/${i.path.replace(`/${n.RASTER_URL_PREFIX}/`,"")}`:i.path.match(/^\/rasterarrays\/v1\//)?r+=`rasterarrays/${i.path.replace(`/${n.RASTERARRAYS_URL_PREFIX}/`,"")}`:r+=`tiles/${i.path.replace(`/${n.TILE_URL_VERSION}/`,"")}`;let o=i.params;return e&&(o=o.filter((t=>!t.match(/^access_token=/)))),o.length&&(r+=`?${o.join("&")}`),r}canonicalizeTileset(t,e){const i=!!e&&o(e),n=[];for(const e of t.tiles||[])r(e)?n.push(this.canonicalizeTileURL(e,i)):n.push(e);return n}_makeAPIURL(t,e){const i="See https://docs.mapbox.com/api/overview/#access-tokens-and-token-scopes",r=un(n.API_URL);if(t.protocol=r.protocol,t.authority=r.authority,"http"===t.protocol){const e=t.params.indexOf("secure");e>=0&&t.params.splice(e,1)}if("/"!==r.path&&(t.path=`${r.path}${t.path}`),!n.REQUIRE_ACCESS_TOKEN)return hn(t);if(e=e||n.ACCESS_TOKEN,!this._silenceAuthErrors){if(!e)throw new Error(`An API access token is required to use Mapbox GL. ${i}`);if("s"===e[0])throw new Error(`Use a public access token (pk.*) with Mapbox GL, not a secret access token (sk.*). ${i}`)}return t.params=t.params.filter((t=>-1===t.indexOf("access_token"))),t.params.push(`access_token=${e||""}`),hn(t)}},t.dh=function(t,e){e?Mn.add(t):Mn.delete(t)},t.di=Gi,t.dj=Tn,t.dk=En,t.dl=cn,t.dm=vn,t.dn=bn,t.dp=function(t){Mn.delete(t)},t.dq=Sn,t.dr=yn,t.ds=Qe,t.dt=e,t.du=function(t,e){Fi=t,Ni=e},t.dv=function(t,e,i=!1){if(Fa===za||Fa===Ra||Fa===Oa)throw new Error("setRTLTextPlugin cannot be called multiple times.");Na=ki.resolveURL(t),Fa=za,Ba=e,ja(),i||Za()},t.dw=Ga,t.dx=function(){ux().acquire(lx)},t.dy=function(){const t=dx;t&&(t.isPreloaded()&&1===t.numActive()?(t.release(lx),dx=null):console.warn("Could not clear WebWorkers since there are active Map instances that still reference it. The pre-warmed WebWorker pool can only be cleared when all map instances have been removed with map.remove()"))},t.dz=cx,t.e=ki,t.e0=cm,t.e1=h,t.e2=en,t.e3=function(t){let e=0;if(new Uint32Array(t,0,1)[0]!==Ax){const i=new Uint32Array(t,0,7),[,,n,r,o,s]=i;e=i.byteLength+r+o+s+o,(n!==t.byteLength||e>=t.byteLength)&&pi("Invalid b3dm header information.")}return Dx(t,e)},t.e4=function(t,e){const i=jx(t);for(const t of i){for(const e of t.meshes)Vx(e);t.lights&&(t.lightMeshIndex=t.meshes.length,t.meshes.push(Gx(t.lights,e)))}return i},t.e5=Kx,t.e6=rx,t.e7=qa,t.e8=function(t){ji(),Oi&&Oi.then((e=>{e.keys().then((i=>{for(let n=0;nt.arrayBuffer())).then((e=>Dx(e,0,t)))},t.m=class extends Uv{},t.n=Er,t.o=qn,t.p=Qg,t.q=Xs,t.r=Js,t.s=Qs,t.t=ca,t.u=al,t.v=ll,t.w=pi,t.x=pa,t.y=da,t.z=qo})),n(0,(function(t){function e(t){const e=t?t.url.toString():void 0;return e?performance.getEntriesByName(e):[]}function i(t){if("number"==typeof t||"boolean"==typeof t||"string"==typeof t||null==t)return JSON.stringify(t);if(Array.isArray(t)){let e="[";for(const n of t)e+=`${i(n)},`;return`${e}]`}let e="{";for(const n of Object.keys(t).sort())e+=`${n}:${i(t[n])},`;return`${e}}`}function n(e){let n="";for(const r of t.cE)n+=`/${i(e[r])}`;return n}class r{constructor(t){this.keyCache={},this._layers={},this._layerConfigs={},t&&this.replace(t)}replace(t,e){this._layerConfigs={},this._layers={},this.update(t,[],e)}update(e,i,r){this._options=r;for(const i of e)this._layerConfigs[i.id]=i,(this._layers[i.id]=t.cY(i,this.scope,null,this._options)).compileFilter(),this.keyCache[i.id]&&delete this.keyCache[i.id];for(const t of i)delete this.keyCache[t],delete this._layerConfigs[t],delete this._layers[t];this.familiesBySource={};const o=function(t,e){const i={};for(let r=0;rthis._layers[t.id])),i=e[0];if("none"===i.visibility)continue;const n=i.source||"";let r=this.familiesBySource[n];r||(r=this.familiesBySource[n]={});const o=i.sourceLayer||"_geojsonTileLayer";let s=r[o];s||(s=r[o]=[]),s.push(e)}}}const o=1*t.dJ;class s{constructor(e){const i={},n=[];for(const t in e){const r=e[t],s=i[t]={};for(const t in r.glyphs){const e=r.glyphs[+t];if(!e||0===e.bitmap.width||0===e.bitmap.height)continue;const i=e.metrics.localGlyph?o:1,a={x:0,y:0,w:e.bitmap.width+2*i,h:e.bitmap.height+2*i};n.push(a),s[t]=a}}const{w:r,h:s}=t.j(n),a=new t.dI({width:r||1,height:s||1});for(const n in e){const r=e[n];for(const e in r.glyphs){const s=r.glyphs[+e];if(!s||0===s.bitmap.width||0===s.bitmap.height)continue;const l=i[n][e],c=s.metrics.localGlyph?o:1;t.dI.copy(s.bitmap,a,{x:0,y:0},{x:l.x+c,y:l.y+c},s.bitmap)}}this.image=a,this.positions=i}}t.dH(s,"GlyphAtlas");class a{constructor(e){this.tileID=new t.aL(e.tileID.overscaledZ,e.tileID.wrap,e.tileID.canonical.z,e.tileID.canonical.x,e.tileID.canonical.y),this.tileZoom=e.tileZoom,this.uid=e.uid,this.zoom=e.zoom,this.lut=e.lut,this.canonical=e.tileID.canonical,this.pixelRatio=e.pixelRatio,this.tileSize=e.tileSize,this.source=e.source,this.scope=e.scope,this.overscaling=this.tileID.overscaleFactor(),this.showCollisionBoxes=e.showCollisionBoxes,this.collectResourceTiming=!!e.collectResourceTiming,this.promoteId=e.promoteId,this.isSymbolTile=e.isSymbolTile,this.tileTransform=t.dK(e.tileID.canonical,e.projection),this.projection=e.projection,this.brightness=e.brightness,this.extraShadowCaster=!!e.extraShadowCaster,this.tessellationStep=e.tessellationStep}parse(e,i,n,r,o){this.status="parsing",this.data=e,this.collisionBoxArray=new t.dL;const a=new t.dM(Object.keys(e.layers).sort()),c=new t.dN(this.tileID,this.promoteId);c.bucketLayerIDs=[];const d={},u=new t.dO(256,256),h={featureIndex:c,iconDependencies:{},patternDependencies:{},glyphDependencies:{},lineAtlas:u,availableImages:n,brightness:this.brightness},p=i.familiesBySource[this.source];for(const i in p){const r=e.layers[i];if(!r)continue;let o=!1,s=!1,u=!1;for(const t of p[i])"symbol"===t[0].type?o=!0:s=!0,t[0].is3D()&&"model"!==t[0].type&&(u=!0);if(this.extraShadowCaster&&!u)continue;if(!0===this.isSymbolTile&&!o)continue;if(!1===this.isSymbolTile&&!s)continue;1===r.version&&t.w(`Vector tile source "${this.source}" layer "${i}" does not use vector tile spec v2 and therefore may have some rendering errors.`);const f=a.encode(i),m=[];for(let t=0;t=e.maxzoom||"none"!==e.visibility&&(l(t,this.zoom,h.brightness,n),(d[e.id]=e.createBucket({index:c.bucketLayerIDs.length,layers:t,zoom:this.zoom,lut:this.lut,canonical:this.canonical,pixelRatio:this.pixelRatio,overscaling:this.overscaling,collisionBoxArray:this.collisionBoxArray,sourceLayerIndex:f,sourceID:this.source,projection:this.projection.spec,tessellationStep:this.tessellationStep})).populate(m,h,this.tileID.canonical,this.tileTransform),c.bucketLayerIDs.push(t.map((t=>t.id)))))}}let f,m,_,g;u.trim();const y={type:"maybePrepare",isSymbolTile:this.isSymbolTile,zoom:this.zoom},v=()=>{if(f)return this.status="done",o(f);if(this.extraShadowCaster)this.status="done",o(null,{buckets:t.dG(d).filter((t=>!t.isEmpty())),featureIndex:c,collisionBoxArray:null,glyphAtlasImage:null,lineAtlas:null,imageAtlas:null,brightness:h.brightness,glyphMap:null,iconMap:null,glyphPositions:null});else if(m&&_&&g){const e=new s(m),i=new t.dQ(_,g,this.lut);for(const r in d){const o=d[r];o instanceof t.dR?(l(o.layers,this.zoom,h.brightness,n),t.dS(o,m,e.positions,_,i.iconPositions,this.showCollisionBoxes,n,this.tileID.canonical,this.tileZoom,this.projection,this.brightness)):o.hasPattern&&(o instanceof t.dT||o instanceof t.dU||o instanceof t.b_)&&(l(o.layers,this.zoom,h.brightness,n),o.addFeatures(h,this.tileID.canonical,i.patternPositions,n,this.tileTransform,this.brightness))}this.status="done",o(null,{buckets:t.dG(d).filter((t=>!t.isEmpty())),featureIndex:c,collisionBoxArray:this.collisionBoxArray,glyphAtlasImage:e.image,lineAtlas:u,imageAtlas:i,brightness:h.brightness})}};if(!this.extraShadowCaster){const e=t.dP(h.glyphDependencies,(t=>Object.keys(t).map(Number)));Object.keys(e).length?r.send("getGlyphs",{uid:this.uid,stacks:e,scope:this.scope},((t,e)=>{f||(f=t,m=e,v())}),void 0,!1,y):m={};const i=Object.keys(h.iconDependencies);i.length?r.send("getImages",{icons:i,source:this.source,scope:this.scope,tileID:this.tileID,type:"icons"},((t,e)=>{f||(f=t,_=e,v())}),void 0,!1,y):_={};const n=Object.keys(h.patternDependencies);n.length?r.send("getImages",{icons:n,source:this.source,scope:this.scope,tileID:this.tileID,type:"patterns"},((t,e)=>{f||(f=t,g=e,v())}),void 0,!1,y):g={}}v()}}function l(e,i,n,r){const o=new t.X(i,{brightness:n});for(const t of e)t.recalculate(o,r)}class c extends t.E{constructor(e,i,n,r,o,s){super(),this.actor=e,this.layerIndex=i,this.availableImages=n,this.loadVectorData=o||t.ap,this.loading={},this.loaded={},this.deduped=new t.ao(e.scheduler),this.isSpriteLoaded=r,this.scheduler=e.scheduler,this.brightness=s}loadTile(i,n){const r=i.uid,o=i&&i.request,s=o&&o.collectResourceTiming,l=this.loading[r]=new a(i);l.abort=this.loadVectorData(i,((a,c)=>{const d=!this.loading[r];if(delete this.loading[r],d||a||!c)return l.status="done",d||(this.loaded[r]=l),n(a);const u=c.rawData,h={};c.expires&&(h.expires=c.expires),c.cacheControl&&(h.cacheControl=c.cacheControl),l.vectorTile=c.vectorTile||new t.dV(new t.dW(u));const p=()=>{l.parse(l.vectorTile,this.layerIndex,this.availableImages,this.actor,((i,r)=>{if(i||!r)return n(i);const a={};if(s){const t=e(o);t.length>0&&(a.resourceTiming=JSON.parse(JSON.stringify(t)))}n(null,t.W({rawTileData:u.slice(0)},r,h,a))}))};this.isSpriteLoaded?p():this.once("isSpriteLoaded",(()=>{this.scheduler?this.scheduler.add(p,{type:"parseTile",isSymbolTile:i.isSymbolTile,zoom:i.tileZoom}):p()})),this.loaded=this.loaded||{},this.loaded[r]=l}))}reloadTile(e,i){const n=this.loaded,r=e.uid;if(n&&n[r]){const o=n[r];o.showCollisionBoxes=e.showCollisionBoxes,o.projection=e.projection,o.brightness=e.brightness,o.tileTransform=t.dK(e.tileID.canonical,e.projection),o.extraShadowCaster=e.extraShadowCaster,o.lut=e.lut;const s=(t,e)=>{const n=o.reloadCallback;n&&(delete o.reloadCallback,o.parse(o.vectorTile,this.layerIndex,this.availableImages,this.actor,n)),i(t,e)};"parsing"===o.status?o.reloadCallback=s:"done"===o.status&&(o.vectorTile?o.parse(o.vectorTile,this.layerIndex,this.availableImages,this.actor,s):s())}else i(null,void 0)}abortTile(t,e){const i=t.uid,n=this.loading[i];n&&(n.abort&&n.abort(),delete this.loading[i]),e()}removeTile(t,e){const i=this.loaded,n=t.uid;i&&i[n]&&delete i[n],e()}}class d{loadTile(e,i){const{uid:n,encoding:r,rawImageData:o,padding:s}=e,a=ImageBitmap&&o instanceof ImageBitmap?this.getImageData(o,s):o;i(null,new t.dX(n,a,r,s{n(null,t)}),(t=>{n(t)}))}}const h=t.dZ.prototype.toGeoJSON;let p=class{constructor(e){this._feature=e,this.extent=t.a3,this.type=e.type,this.properties=e.tags,"id"in e&&!isNaN(e.id)&&(this.id=parseInt(e.id,10))}loadGeometry(){if(1===this._feature.type){const e=[];for(const i of this._feature.geometry)e.push([new t.P(i[0],i[1])]);return e}{const e=[];for(const i of this._feature.geometry){const n=[];for(const e of i)n.push(new t.P(e[0],e[1]));e.push(n)}return e}}toGeoJSON(t,e,i){return h.call(this,t,e,i)}},f=class{constructor(e){this.layers={_geojsonTileLayer:this},this.name="_geojsonTileLayer",this.extent=t.a3,this.length=e.length,this._features=e}feature(t){return new p(this._features[t])}};const m=64/4096;class _{constructor(){this.features=new Map}clear(){this.features.clear()}load(t=[],e){for(const i of t){const t=i.id;if(null==t)continue;let n=this.features.get(t);n&&this.updateCache(n,e),i.geometry?(n=y(i),this.updateCache(n,e),this.features.set(t,n)):this.features.delete(t),this.updateCache(n,e)}}updateCache(t,e){for(const{canonical:i,uid:n}of Object.values(e)){const{z:r,x:o,y:s}=i;g(t,Math.pow(2,r),o,s)&&delete e[n]}}getTile(t,e,i){const n=Math.pow(2,t),r=[];for(const t of this.features.values())g(t,n,e,i)&&r.push(w(t,n,e,i));return{features:r}}getFeatures(){return[...this.features.values()]}}function g({minX:t,minY:e,maxX:i,maxY:n},r,o,s){return t(o-m)/r&&n>(s-m)/r}function y(t){const{id:e,geometry:i,properties:n}=t;if(!i)return;if("GeometryCollection"===i.type)throw new Error("GeometryCollection not supported in dynamic mode.");const{type:r,coordinates:o}=i,s={id:e,type:1,geometry:[],tags:n,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0},a=s.geometry;if("Point"===r)v(o,a,s);else if("MultiPoint"===r)for(const t of o)v(t,a,s);else if("LineString"===r)s.type=2,x(o,a,s);else if("MultiLineString"===r)s.type=2,b(o,a,s);else if("Polygon"===r)s.type=3,b(o,a,s,!0);else{if("MultiPolygon"!==r)throw new Error("Input data is not a valid GeoJSON object.");s.type=3;for(const t of o)b(t,a,s,!0)}return s}function v([e,i],n,r){const o=t.aj(e);let s=t.ak(i);s=s1?1:s,n.push(o,s),r.minX=Math.min(r.minX,o),r.minY=Math.min(r.minY,s),r.maxX=Math.max(r.maxX,o),r.maxY=Math.max(r.maxY,s)}function x(t,e,i,n=!1,r=!1){const o=[];for(const e of t)v(e,o,i);e.push(o),n&&function(t,e){let i=0;for(let e=0,n=t.length,r=n-2;e0===e)for(let e=0,i=t.length;e>31}function F(t,e){for(var i=t.loadGeometry(),n=t.type,r=0,o=0,s=i.length,a=0;at},V=Math.fround||(G=new Float32Array(1),t=>(G[0]=+t,G[0]));var G;const Z=3,q=5,H=6;class W{constructor(t){this.options=Object.assign(Object.create(j),t),this.trees=new Array(this.options.maxZoom+1),this.stride=this.options.reduce?7:6,this.clusterProps=[]}load(t){const{log:e,minZoom:i,maxZoom:n}=this.options;e&&console.time("total time");const r=`prepare ${t.length} points`;e&&console.time(r),this.points=t;const o=[];for(let e=0;e=i;t--){const i=+Date.now();s=this.trees[t]=this._createTree(this._cluster(s,t)),e&&console.log("z%d: %d clusters in %dms",t,s.numItems,+Date.now()-i)}return e&&console.timeEnd("total time"),this}getClusters(t,e){let i=((t[0]+180)%360+360)%360-180;const n=Math.max(-90,Math.min(90,t[1]));let r=180===t[2]?180:((t[2]+180)%360+360)%360-180;const o=Math.max(-90,Math.min(90,t[3]));if(t[2]-t[0]>=360)i=-180,r=180;else if(i>r){const t=this.getClusters([i,n,180,o],e),s=this.getClusters([-180,n,r,o],e);return t.concat(s)}const s=this.trees[this._limitZoom(e)],a=s.range(K(i),J(o),K(r),J(n)),l=s.data,c=[];for(const t of a){const e=this.stride*t;c.push(l[e+q]>1?Y(l,e,this.clusterProps):this.points[l[e+Z]])}return c}getChildren(t){const e=this._getOriginId(t),i=this._getOriginZoom(t),n="No cluster with the specified id.",r=this.trees[i];if(!r)throw new Error(n);const o=r.data;if(e*this.stride>=o.length)throw new Error(n);const s=this.options.radius/(this.options.extent*Math.pow(2,i-1)),a=r.within(o[e*this.stride],o[e*this.stride+1],s),l=[];for(const e of a){const i=e*this.stride;o[i+4]===t&&l.push(o[i+q]>1?Y(o,i,this.clusterProps):this.points[o[i+Z]])}if(0===l.length)throw new Error(n);return l}getLeaves(t,e,i){const n=[];return this._appendLeaves(n,t,e=e||10,i=i||0,0),n}getTile(t,e,i){const n=this.trees[this._limitZoom(t)],r=Math.pow(2,t),{extent:o,radius:s}=this.options,a=s/o,l=(i-a)/r,c=(i+1+a)/r,d={features:[]};return this._addTileFeatures(n.range((e-a)/r,l,(e+1+a)/r,c),n.data,e,i,r,d),0===e&&this._addTileFeatures(n.range(1-a/r,l,1,c),n.data,r,i,r,d),e===r-1&&this._addTileFeatures(n.range(0,l,a/r,c),n.data,-1,i,r,d),d.features.length?d:null}getClusterExpansionZoom(t){let e=this._getOriginZoom(t)-1;for(;e1;let l,c,d;if(a)l=X(e,t,this.clusterProps),c=e[t],d=e[t+1];else{const i=this.points[e[t+Z]];l=i.properties;const[n,r]=i.geometry.coordinates;c=K(n),d=J(r)}const u={type:1,geometry:[[Math.round(this.options.extent*(c*r-i)),Math.round(this.options.extent*(d*r-n))]],tags:l};let h;h=a||this.options.generateId?e[t+Z]:this.points[e[t+Z]].id,void 0!==h&&(u.id=h),o.features.push(u)}}_limitZoom(t){return Math.max(this.options.minZoom,Math.min(Math.floor(+t),this.options.maxZoom+1))}_cluster(t,e){const{radius:i,extent:n,reduce:r,minPoints:o}=this.options,s=i/(n*Math.pow(2,e)),a=t.data,l=[],c=this.stride;for(let i=0;ie&&(p+=a[i+q])}if(p>h&&p>=o){let t,o=n*h,s=d*h,f=-1;const m=(i/c1)for(const t of u){const i=t*c;if(!(a[i+2]>5}_getOriginZoom(t){return(t-this.points.length)%32}_map(t,e,i){if(t[e+q]>1){const n=this.clusterProps[t[e+H]];return i?Object.assign({},n):n}const n=this.points[t[e+Z]].properties,r=this.options.map(n);return i&&r===n?Object.assign({},r):r}}function Y(t,e,i){return{type:"Feature",id:t[e+Z],properties:X(t,e,i),geometry:{type:"Point",coordinates:[(n=t[e],360*(n-.5)),Q(t[e+1])]}};var n}function X(t,e,i){const n=t[e+q],r=n>=1e4?`${Math.round(n/1e3)}k`:n>=1e3?Math.round(n/100)/10+"k":n,o=t[e+H],s=-1===o?{}:Object.assign({},i[o]);return Object.assign(s,{cluster:!0,cluster_id:t[e+Z],point_count:n,point_count_abbreviated:r})}function K(t){return t/360+.5}function J(t){const e=Math.sin(t*Math.PI/180),i=.5-.25*Math.log((1+e)/(1-e))/Math.PI;return i1?1:i}function Q(t){const e=(180-360*t)*Math.PI/180;return 360*Math.atan(Math.exp(e))/Math.PI-90}function tt(t,e,i,n){let r=n;const o=e+(i-e>>1);let s,a=i-e;const l=t[e],c=t[e+1],d=t[i],u=t[i+1];for(let n=e+3;n l||l>e.max.x||e.min.y>c||c>e.max.y)&&(d=Op(Rp(l,c,t.canonical,e.footprintTileId.canonical),e),d))break;o.float32[s]=d?a+uo:a,r=r||d}}}return r}isEmpty(){for(const t in this.instancesPerModel)if(0!==this.instancesPerModel[t].instancedDataArray.length)return!1;return!0}uploadPending(){return!this.uploaded}upload(t){if(!this.uploaded)for(const e in this.instancesPerModel){const i=this.instancesPerModel[e];i.instancedDataArray.length=uo||e.y=uo)continue;const t=(this.lookupDim-1)/uo,i=this.lookupDim*(e.y*t|0)+e.x*t|0;if(this.lookup){if(0!==this.lookup[i])continue;this.lookup[i]=1}this.instanceCount++;const n=s.length;s.resize(n+1),o.instancesEvaluatedElevation.push(0),s.float32[16*n]=e.x,s.float32[16*n+1]=e.y}return a.instancedDataCount=o.instancedDataArray.length-a.instancedDataOffset,a.instancedDataCount>0&&(t.id&&(o.idToFeaturesIndex[t.id]=o.features.length),o.features.push(a),this.evaluate(a,{},o,!1)),r}getModelUris(){return this.modelUris}evaluate(t,e,i,n){const r=this.layers[0],o=t.feature,s=this.canonical,a=t.rotation=r.paint.get("model-rotation").evaluate(o,e,s),l=t.scale=r.paint.get("model-scale").evaluate(o,e,s),c=t.translation=r.paint.get("model-translation").evaluate(o,e,s),d=r.paint.get("model-color").evaluate(o,e,s);d.a=r.paint.get("model-color-mix-intensity").evaluate(o,e,s);const u=[];this.maxVerticalOffset10?this.tileToMeter:zd(s,p)),a[o+4]=c[0],a[o+5]=c[1],a[o+6]=c[2]+l,a[o+7]=u[0],a[o+8]=u[1],a[o+9]=u[2],a[o+10]=u[4],a[o+11]=u[5],a[o+12]=u[6],a[o+13]=u[8],a[o+14]=u[9],a[o+15]=u[10],i.instancesEvaluatedElevation[r]=c[2]}}}ba(Zv,"ModelBucket",{omit:["layers"]}),ba(Gv,"PerModelAttributes"),ba(Vv,"ModelFeature");const qv=new ol({visibility:new il(sl.layout_model.visibility),"model-id":new nl(sl.layout_model["model-id"])});var Hv={paint:new ol({"model-opacity":new il(sl.paint_model["model-opacity"]),"model-rotation":new nl(sl.paint_model["model-rotation"]),"model-scale":new nl(sl.paint_model["model-scale"]),"model-translation":new nl(sl.paint_model["model-translation"]),"model-color":new nl(sl.paint_model["model-color"]),"model-color-mix-intensity":new nl(sl.paint_model["model-color-mix-intensity"]),"model-type":new il(sl.paint_model["model-type"]),"model-cast-shadows":new il(sl.paint_model["model-cast-shadows"]),"model-receive-shadows":new il(sl.paint_model["model-receive-shadows"]),"model-ambient-occlusion-intensity":new il(sl.paint_model["model-ambient-occlusion-intensity"]),"model-emissive-strength":new nl(sl.paint_model["model-emissive-strength"]),"model-roughness":new nl(sl.paint_model["model-roughness"]),"model-height-based-emissive-strength-multiplier":new nl(sl.paint_model["model-height-based-emissive-strength-multiplier"]),"model-cutoff-fade-range":new il(sl.paint_model["model-cutoff-fade-range"]),"model-front-cutoff":new il(sl.paint_model["model-front-cutoff"])}),layout:qv};const Wv=64,Yv={CoordinateSpaceTile:1,CoordinateSpaceYUp:2,HasMapboxMeshFeatures:4,HasMeshoptCompression:8};function Xv(e,i,n,r,o,s,a,l,c,d=!1){const u=n.zoom,h=n.project(r),p=kd(r.lat,u),f=1/p;t.ad.identity(e),t.ad.translate(e,e,[h.x+a[0]*f,h.y+a[1]*f,a[2]]);let m=1,_=1;const g=n.worldSize;if(d){if("mercator"===n.projection.name){let e=0;n.elevation&&(e=n.elevation.getAtPointOrZero(new Rd(h.x/g,h.y/g),0));const i=t.aA.transformMat4([],[h.x,h.y,e,1],n.projMatrix)[3]/n.cameraToCenterDistance;m=i,_=i*kd(n.center.lat,u)}else if("globe"===n.projection.name){const i=$v(e,n),o=t.ad.multiply([],n.projMatrix,i),s=[0,0,0,1];t.aA.transformMat4(s,s,o);const a=s[3]/n.cameraToCenterDistance,l=Hu(u),c=n.projection.pixelsPerMeter(r.lat,g)*kd(r.lat,u),d=n.projection.pixelsPerMeter(n.center.lat,g)*kd(n.center.lat,u);m=a/Vn(c,$d(n.center.lat),l),_=a*p/c,m*=d,_*=d}}else m=f;t.ad.scale(e,e,[m,m,_]);const y=[...e],v=i.orientation,x=[];if(Lv(x,[v[0]+o[0],v[1]+o[1],v[2]+o[2]],s),t.ad.multiply(e,y,x),l&&n.elevation){let o=0;const s=[];if(c&&n.elevation){o=function(e,i,n,r,o){const s=i.elevation;if(!s)return 0;const a=wu.projectAabbCorners(n,r),l=Cd(1,o.lat)*i.worldSize,c=function(e,i){const n=[0,0,1],r=[{corners:[0,1,3,2],dotProductWithUp:0},{corners:[1,5,2,6],dotProductWithUp:0},{corners:[0,4,1,5],dotProductWithUp:0},{corners:[2,6,3,7],dotProductWithUp:0},{corners:[4,7,5,6],dotProductWithUp:0},{corners:[0,3,4,7],dotProductWithUp:0}];for(const o of r){const r=e[o.corners[0]],s=e[o.corners[1]],a=e[o.corners[2]],l=[s[0]-r[0],s[1]-r[1],i*(s[2]-r[2])],c=t._.cross(l,l,[a[0]-r[0],a[1]-r[1],i*(a[2]-r[2])]);t._.normalize(c,c),o.dotProductWithUp=t._.dot(c,n)}return r.sort(((t,e)=>t.dotProductWithUp-e.dotProductWithUp)),r[0].corners}(a,l),d=a[c[0]],u=a[c[1]],h=a[c[2]],p=a[c[3]],f=s.getAtPointOrZero(new Rd(d[0]/i.worldSize,d[1]/i.worldSize),0),m=s.getAtPointOrZero(new Rd(u[0]/i.worldSize,u[1]/i.worldSize),0),_=s.getAtPointOrZero(new Rd(h[0]/i.worldSize,h[1]/i.worldSize),0),g=s.getAtPointOrZero(new Rd(p[0]/i.worldSize,p[1]/i.worldSize),0),y=(f+g)/2,v=(m+_)/2;return y>v?m=e.gl.NEAREST_MIPMAP_NEAREST}),t.uploaded=!0,t.image=null)}function Jv(t,e,i){t.indexBuffer=e.createIndexBuffer(t.indexArray,!1,!0),t.vertexBuffer=e.createVertexBuffer(t.vertexArray,Dv.members,!1,!0),t.normalArray&&(t.normalBuffer=e.createVertexBuffer(t.normalArray,Bv.members,!1,!0)),t.texcoordArray&&(t.texcoordBuffer=e.createVertexBuffer(t.texcoordArray,Ov.members,!1,!0)),t.colorArray&&(t.colorBuffer=e.createVertexBuffer(t.colorArray,(12===t.colorArray.bytesPerElement?zv:Rv).members,!1,!0)),t.featureArray&&(t.pbrBuffer=e.createVertexBuffer(t.featureArray,Nv.members,!0)),t.segments=wc.simpleSegment(0,0,t.vertexArray.length,t.indexArray.length);const n=t.material;n.pbrMetallicRoughness.baseColorTexture&&Kv(n.pbrMetallicRoughness.baseColorTexture,e),n.pbrMetallicRoughness.metallicRoughnessTexture&&Kv(n.pbrMetallicRoughness.metallicRoughnessTexture,e),n.normalTexture&&Kv(n.normalTexture,e),n.occlusionTexture&&Kv(n.occlusionTexture,e,i),n.emissionTexture&&Kv(n.emissionTexture,e)}function Qv(t,e,i){if(t.meshes)for(const n of t.meshes)Jv(n,e,i);if(t.children)for(const n of t.children)Qv(n,e,i)}function tx(t){if(t.meshes)for(const e of t.meshes)e.indexArray.destroy(),e.vertexArray.destroy(),e.colorArray&&e.colorArray.destroy(),e.normalArray&&e.normalArray.destroy(),e.texcoordArray&&e.texcoordArray.destroy(),e.featureArray&&e.featureArray.destroy();if(t.children)for(const e of t.children)tx(e)}function ex(t){if(t.meshes)for(const i of t.meshes)i.vertexBuffer&&(i.vertexBuffer.destroy(),i.indexBuffer.destroy(),i.normalBuffer&&i.normalBuffer.destroy(),i.texcoordBuffer&&i.texcoordBuffer.destroy(),i.colorBuffer&&i.colorBuffer.destroy(),i.pbrBuffer&&i.pbrBuffer.destroy(),i.segments.destroy(),i.material&&((e=i.material).pbrMetallicRoughness.baseColorTexture&&e.pbrMetallicRoughness.baseColorTexture.gfxTexture&&e.pbrMetallicRoughness.baseColorTexture.gfxTexture.destroy(),e.pbrMetallicRoughness.metallicRoughnessTexture&&e.pbrMetallicRoughness.metallicRoughnessTexture.gfxTexture&&e.pbrMetallicRoughness.metallicRoughnessTexture.gfxTexture.destroy(),e.normalTexture&&e.normalTexture.gfxTexture&&e.normalTexture.gfxTexture.destroy(),e.emissionTexture&&e.emissionTexture.gfxTexture&&e.emissionTexture.gfxTexture.destroy(),e.occlusionTexture&&e.occlusionTexture.gfxTexture&&e.occlusionTexture.gfxTexture.destroy()));var e;if(t.children)for(const e of t.children)ex(e)}class ix{constructor(t){this._callback=t,this._triggered=!1,"undefined"!=typeof MessageChannel&&(this._channel=new MessageChannel,this._channel.port2.onmessage=()=>{this._triggered=!1,this._callback()})}trigger(){this._triggered||(this._triggered=!0,this._channel?this._channel.port1.postMessage(!0):setTimeout((()=>{this._triggered=!1,this._callback()}),0))}remove(){this._channel=void 0,this._callback=()=>{}}}class nx{constructor(){this.tasks={},this.taskQueue=[],ai(["process"],this),this.invoker=new ix(this.process),this.nextId=0}add(t,e){const i=this.nextId++,n=function({type:t,isSymbolTile:e,zoom:i}){return i=i||0,"message"===t?0:"maybePrepare"!==t||e?"parseTile"!==t||e?"parseTile"===t&&e?300-i:"maybePrepare"===t&&e?400-i:500:200-i:100-i}(e);if(0===n){try{t()}finally{}return null}return this.tasks[i]={fn:t,metadata:e,priority:n,id:i},this.taskQueue.push(i),this.invoker.trigger(),{cancel:()=>{delete this.tasks[i]}}}process(){try{if(this.taskQueue=this.taskQueue.filter((t=>!!this.tasks[t])),!this.taskQueue.length)return;const t=this.pick();if(null===t)return;const e=this.tasks[t];if(delete this.tasks[t],this.taskQueue.length&&this.invoker.trigger(),!e)return;e.fn()}finally{}}pick(){let t=null,e=1/0;for(let i=0;i{i&&delete this.callbacks[s],this.target.postMessage({id:s,type:"",targetMapId:n,sourceMapId:this.mapId})}}}receive(t){const e=t.data,i=e.id;if(i&&(!e.targetMapId||this.mapId===e.targetMapId))if(""===e.type){const t=this.cancelCallbacks[i];delete this.cancelCallbacks[i],t&&t.cancel()}else if(e.mustQueue||gi()){const t=this.callbacks[i],n=this.scheduler.add((()=>this.processTask(i,e)),t&&t.metadata||{type:"message"});n&&(this.cancelCallbacks[i]=n)}else this.processTask(i,e)}processTask(t,e){if(delete this.cancelCallbacks[t],""===e.type){const i=this.callbacks[t];delete this.callbacks[t],i&&(e.error?i(Ea(e.error)):i(null,Ea(e.data)))}else{const i=new Set,n=e.hasCallback?(e,n)=>{this.target.postMessage({id:t,type:"",sourceMapId:this.mapId,error:e?Sa(e):null,data:Sa(n,i)},i)}:t=>{},r=Ea(e.data);if(this.parent[e.type])this.parent[e.type](e.sourceMapId,r,n);else if(this.parent.getWorkerSource){const t=e.type.split(".");this.parent.getWorkerSource(e.sourceMapId,t[0],r.source,r.scope)[t[1]](r,n)}else n(new Error(`Could not find function ${e.type}`))}}remove(){this.scheduler.remove(),this.target.removeEventListener("message",this.receive,!1)}}class ox{constructor(t,e){this.workerPool=t,this.actors=[],this.currentActor=0,this.id=ni();const i=this.workerPool.acquire(this.id);for(let t=0;t{this.ready=!0}))}broadcast(t,e,i){Qe(this.actors,((i,n)=>{i.send(t,e,n)}),i=i||function(){})}getActor(){return this.currentActor=(this.currentActor+1)%this.actors.length,this.actors[this.currentActor]}remove(){this.actors.forEach((t=>{t.remove()})),this.actors=[],this.workerPool.release(this.id)}}ox.Actor=rx;var sx={workerUrl:"",workerClass:null,workerParams:void 0};function ax(){return null!=sx.workerClass?new sx.workerClass:new self.Worker(sx.workerUrl,sx.workerParams)}const lx="mapboxgl_preloaded_worker_pool";class cx{constructor(){this.active={}}acquire(t){if(!this.workers)for(this.workers=[];this.workers.length{t.terminate()})),this.workers=null)}isPreloaded(){return!!this.active[lx]}numActive(){return Object.keys(this.active).length}}let dx;function ux(){return dx||(dx=new cx),dx}cx.workerCount=2;let hx,px,fx,mx,_x,gx=null;function yx(){return gi()&&self.worker&&self.worker.dracoUrl?self.worker.dracoUrl:px||n.DRACO_URL}function vx(){if(gi()&&self.worker&&self.worker.meshoptUrl)return self.worker.meshoptUrl;if(mx)return mx;const t=new Uint8Array([0,97,115,109,1,0,0,0,1,4,1,96,0,0,3,3,2,0,0,5,3,1,0,1,12,1,0,10,22,2,12,0,65,0,65,0,65,0,252,10,0,0,11,7,0,65,0,253,15,26,11]);if("object"!=typeof WebAssembly)throw new Error("WebAssembly not supported, cannot instantiate meshoptimizer");return mx=WebAssembly.validate(t)?n.MESHOPT_SIMD_URL:n.MESHOPT_URL,mx}const xx={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},bx={5120:"DT_INT8",5121:"DT_UINT8",5122:"DT_INT16",5123:"DT_UINT16",5125:"DT_UINT32",5126:"DT_FLOAT32"},wx={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16};function Tx(t,e,i){const n=i.json.bufferViews.length,r=i.buffers.length;e.bufferView=n,i.json.bufferViews[n]={buffer:r,byteLength:t.byteLength},i.buffers[r]=t}const Sx="KHR_draco_mesh_compression";function Ex(t,e){const i=t.extensions&&t.extensions[Sx];if(!i)return;const n=new fx.Decoder,r=$x(e,i.bufferView),o=new fx.Mesh;if(!n.DecodeArrayToMesh(r,r.byteLength,o))throw new Error("Failed to decode Draco mesh");const s=e.json.accessors[t.indices],a=xx[s.componentType],l=s.count*a.BYTES_PER_ELEMENT,c=fx._malloc(l);a===Uint16Array?n.GetTrianglesUInt16Array(o,l,c):n.GetTrianglesUInt32Array(o,l,c),Tx(fx.memory.buffer.slice(c,c+l),s,e),fx._free(c);for(const r of Object.keys(i.attributes)){const s=n.GetAttributeByUniqueId(o,i.attributes[r]),a=e.json.accessors[t.attributes[r]],l=bx[a.componentType],c=a.count*wx[a.type]*xx[a.componentType].BYTES_PER_ELEMENT,d=fx._malloc(c);n.GetAttributeDataArrayForAllPoints(o,s,fx[l],c,d),Tx(fx.memory.buffer.slice(d,d+c),a,e),fx._free(d)}n.destroy(),o.destroy(),delete t.extensions[Sx]}const Mx="EXT_meshopt_compression";function Cx(t,e){if(!t.extensions||!t.extensions[Mx])return;const i=t.extensions[Mx],n=new Uint8Array(e.buffers[i.buffer],i.byteOffset||0,i.byteLength||0),r=new Uint8Array(i.count*i.byteStride);_x.decodeGltfBuffer(r,i.count,i.byteStride,n,i.mode,i.filter),t.buffer=e.buffers.length,t.byteOffset=0,e.buffers[t.buffer]=r.buffer,delete t.extensions[Mx]}const Ax=1179937895,Ix=new TextDecoder("utf8");function Lx(t,e){return new URL(t,e).href}function Px(t,e,i,n){return fetch(Lx(t.uri,n)).then((t=>t.arrayBuffer())).then((t=>{e.buffers[i]=t}))}function $x(t,e){const i=t.json.bufferViews[e];return new Uint8Array(t.buffers[i.buffer],i.byteOffset||0,i.byteLength)}function kx(t,e,i,n){if(t.uri){const r=Lx(t.uri,n);return fetch(r).then((t=>t.blob())).then((t=>createImageBitmap(t))).then((t=>{e.images[i]=t}))}if(void 0!==t.bufferView){const n=$x(e,t.bufferView),r=new Blob([n],{type:t.mimeType});return createImageBitmap(r).then((t=>{e.images[i]=t}))}}function Dx(t,e=0,i){const n={json:null,images:[],buffers:[]};if(new Uint32Array(t,e,1)[0]===Ax){const i=new Uint32Array(t,e);let r=2;const o=(i[r++]>>2)-3,s=i[r++]>>2;if(r++,n.json=JSON.parse(Ix.decode(i.subarray(r,r+s))),r+=s,r{const t=[],e=a&&a.includes(Sx),r=a&&a.includes(Mx);if(e&&t.push(function(){if(!fx)return hx||(hx=function(t){let e,i=null;function n(){e=new Uint8Array(i.buffer)}function r(){throw new Error("Unexpected Draco error.")}const o={a:{a:r,d:function(t,i,n){return e.copyWithin(t,i,i+n)},c:function(t){const r=e.length,o=Math.max(t>>>0,Math.ceil(1.2*r)),s=Math.ceil((o-r)/65536);try{return i.grow(s),n(),!0}catch(t){return!1}},b:r}};return(WebAssembly.instantiateStreaming?WebAssembly.instantiateStreaming(t,o):t.then((t=>t.arrayBuffer())).then((t=>WebAssembly.instantiate(t,o)))).then((t=>{const{Rb:r,Qb:o,P:s,T:a,X:l,Ja:c,La:d,Qa:u,Va:h,Wa:p,eb:f,jb:m,f:_,e:g,yb:y,zb:v,Ab:x,Bb:b,Db:w,Gb:T}=t.instance.exports;i=g;const S=(()=>{let t=0,i=0,n=0,s=0;return a=>{n&&(r(s),r(t),i+=n,n=t=0),t||(i+=128,t=o(i));const l=a.length+7&-8;let c=t;l>=i&&(n=l,c=s=o(l));for(let t=0;t{fx=t,hx=void 0})))}()),r&&t.push(function(){if(_x)return;const t=function(t){let e;const i=WebAssembly.instantiateStreaming(t,{}).then((t=>{e=t.instance,e.exports.__wasm_call_ctors()})),n={NONE:"",OCTAHEDRAL:"meshopt_decodeFilterOct",QUATERNION:"meshopt_decodeFilterQuat",EXPONENTIAL:"meshopt_decodeFilterExp"},r={ATTRIBUTES:"meshopt_decodeVertexBuffer",TRIANGLES:"meshopt_decodeIndexBuffer",INDICES:"meshopt_decodeIndexSequence"};return{ready:i,supported:!0,decodeGltfBuffer(t,i,o,s,a,l){!function(t,e,i,n,r,o,s){const a=t.exports.sbrk,l=n+3&-4,c=a(l*r),d=a(o.length),u=new Uint8Array(t.exports.memory.buffer);u.set(o,d);const h=e(c,n,r,d,o.length);if(0===h&&s&&s(c,l,r),i.set(u.subarray(c,c+n*r)),a(c-a(0)),0!==h)throw new Error(`Malformed buffer data: ${h}`)}(e,e.exports[r[a]],t,i,o,s,e.exports[n[l]])}}}(fetch(vx()));return t.ready.then((()=>{_x=t}))}()),o)for(let e=0;e{if(e&&s)for(const{primitives:t}of s)for(const e of t)Ex(e,n);if(r&&s&&l)for(const t of l)Cx(t,n);return n}))}))}function zx(t,e){const i=t.json.bufferViews[e.bufferView],n=xx[e.componentType];return new n(t.buffers[i.buffer],(e.byteOffset||0)+(i.byteOffset||0),e.count*(i.byteStride&&i.byteStride!==wx[e.type]*n.BYTES_PER_ELEMENT?i.byteStride/n.BYTES_PER_ELEMENT:wx[e.type]))}function Rx(t,e,i,n){const r=xx[e.componentType],o=function(t){switch(t){case Int8Array:return 1/127;case Uint8Array:return 1/255;case Int16Array:return 1/32767;case Uint16Array:return 1/65535;default:return 1}}(r),s=t.json.bufferViews[e.bufferView],a=s.byteStride?s.byteStride/r.BYTES_PER_ELEMENT:wx[e.type],l=i.float32,c=l.length/i.capacity;for(let t=0,i=0;t0){for(let r=0;r0){o.texcoordArray=new ic;const t=e.json.accessors[r.TEXCOORD_0];o.texcoordArray.resize(t.count);const i=zx(e,t);Rx(e,t,o.texcoordArray,i)}if(void 0!==r._FEATURE_ID_RGBA4444){const t=e.json.accessors[r._FEATURE_ID_RGBA4444];e.json.extensionsUsed&&e.json.extensionsUsed.includes("EXT_meshopt_compression")&&(o.featureData=zx(e,t))}void 0!==r._FEATURE_RGBA4444&&(o.featureData=new Uint32Array(zx(e,e.json.accessors[r._FEATURE_RGBA4444]).buffer));const u=t.material;return o.material=function(t,e){const{emissiveFactor:i=[0,0,0],alphaMode:n="OPAQUE",alphaCutoff:r=.5,normalTexture:o,occlusionTexture:s,emissiveTexture:a,doubleSided:l}=t,{baseColorFactor:c=[1,1,1,1],metallicFactor:d=1,roughnessFactor:u=1,baseColorTexture:h,metallicRoughnessTexture:p}=t.pbrMetallicRoughness||{},f=s?e[s.index]:void 0;if(s&&s.extensions&&s.extensions.KHR_texture_transform&&f){const t=s.extensions.KHR_texture_transform;f.offsetScale=[t.offset[0],t.offset[1],t.scale[0],t.scale[1]]}return{pbrMetallicRoughness:{baseColorFactor:new Un(...c),metallicFactor:d,roughnessFactor:u,baseColorTexture:h?e[h.index]:void 0,metallicRoughnessTexture:p?e[p.index]:void 0},doubleSided:l,emissiveFactor:i,alphaMode:n,alphaCutoff:r,normalTexture:o?e[o.index]:void 0,occlusionTexture:f,emissionTexture:a?e[a.index]:void 0,defined:void 0===t.defined}}(void 0!==u?e.json.materials[u]:{defined:!1},i),o}function Bx(e,i,n){const{matrix:r,rotation:o,translation:s,scale:a,mesh:l,extras:c,children:d}=e,u={};if(u.matrix=r||t.ad.fromRotationTranslationScale([],o||[0,0,0,1],s||[0,0,0],a||[1,1,1]),void 0!==l){u.meshes=n[l];const t=u.anchor=[0,0];for(const e of u.meshes){const{min:i,max:n}=e.aabb;t[0]+=i[0]+n[0],t[1]+=i[1]+n[1]}t[0]=Math.floor(t[0]/u.meshes.length/2),t[1]=Math.floor(t[1]/u.meshes.length/2)}if(c&&(c.id&&(u.id=c.id),c.lights&&(u.lights=function(t){if(!t.length)return[];const e=function(t){const e=atob(t),i=new Uint8Array(e.length);for(let t=0;t1&&n[n.length-1].equals(n[0])&&n.pop();let r=0;for(let t=0;t0&&n.reverse();const o=xh(n.flatMap((t=>[t.x,t.y])),[]);return 0===o.length?null:{vertices:n,indices:o}}function Ux(e,i){const n=[],r=[];let o=0;const s=[];for(const a of e){o=n.length;const e=a.vertexArray.float32,l=a.indexArray.uint16;for(let r=0;r0&&([r[t+1],r[t+2]]=[r[t+2],r[t+1]])}return{vertices:n,indices:r}}function jx(t){const e=function(t,e){const i=[],n=WebGL2RenderingContext;if(t.json.textures)for(const r of t.json.textures){const o={magFilter:n.LINEAR,minFilter:n.NEAREST,wrapS:n.REPEAT,wrapT:n.REPEAT};void 0!==r.sampler&&Object.assign(o,t.json.samplers[r.sampler]),i.push({image:e[r.source],sampler:o,uploaded:!1})}return i}(t,t.images),i=function(t,e){const i=[];for(const n of t.json.meshes){const r=[];for(const i of n.primitives)r.push(Ox(i,t,e));i.push(r)}return i}(t,e),{scenes:n,scene:r,nodes:o}=t.json,s=n?n[r||0].nodes:o,a=[];for(const e of s)a.push(Bx(o[e],t,i));return function(t,e,i){const n={},r=new Set;for(let o=0;o0){const e=Array.from(r.values()).sort(((t,e)=>t-e));for(let i=e.length-1;i>=0;i--)t.splice(e[i],1)}}(a,s,t.json.nodes),a}function Vx(t){t.heightmap=new Float32Array(4096),t.heightmap.fill(-1);const e=t.vertexArray.float32,i=t.aabb.min[0]-1,n=t.aabb.min[1]-1,r=Wv/(t.aabb.max[0]-i+2),o=Wv/(t.aabb.max[1]-n+2);for(let s=0;st.heightmap[c*Wv+l]&&(t.heightmap[c*Wv+l]=a)}}function Gx(e,i){const n={};n.indexArray=new Kl,n.indexArray.reserve(4*e.length),n.vertexArray=new Bl,n.vertexArray.reserve(10*e.length),n.colorArray=new Ol,n.vertexArray.reserve(10*e.length);let r=0;for(const o of e){const e=Math.min(10,Math.max(4,1.3*o.height))*i,s=[-o.normal[1],o.normal[0],0],a=Math.min(.29,.1*o.width/o.depth),l=o.width-2*o.depth*i*(a+.01),c=t._.scaleAndAdd([],o.pos,s,l/2),d=t._.scaleAndAdd([],o.pos,s,-l/2),u=[c[0],c[1],c[2]+o.height],h=[d[0],d[1],d[2]+o.height],p=t._.scaleAndAdd([],o.normal,s,a);t._.scale(p,p,e);const f=t._.scaleAndAdd([],o.normal,s,-a);t._.scale(f,f,e),t._.add(p,c,p),t._.add(f,d,f),c[2]+=.1,d[2]+=.1,n.vertexArray.emplaceBack(p[0],p[1],p[2]),n.vertexArray.emplaceBack(f[0],f[1],f[2]),n.vertexArray.emplaceBack(c[0],c[1],c[2]),n.vertexArray.emplaceBack(d[0],d[1],d[2]),n.vertexArray.emplaceBack(u[0],u[1],u[2]),n.vertexArray.emplaceBack(h[0],h[1],h[2]),n.vertexArray.emplaceBack(c[0],c[1],c[2]),n.vertexArray.emplaceBack(d[0],d[1],d[2]),n.vertexArray.emplaceBack(p[0],p[1],p[2]),n.vertexArray.emplaceBack(f[0],f[1],f[2]);const m=l/e/2;n.colorArray.emplaceBack(-m-a,-1,m,.8),n.colorArray.emplaceBack(m+a,-1,m,.8),n.colorArray.emplaceBack(-m,0,m,1.3),n.colorArray.emplaceBack(m,0,m,1.3),n.colorArray.emplaceBack(m+a,-.8,m,.7),n.colorArray.emplaceBack(m+a,-.8,m,.7),n.colorArray.emplaceBack(0,0,m,1.3),n.colorArray.emplaceBack(0,0,m,1.3),n.colorArray.emplaceBack(m+a,-1.2,m,.8),n.colorArray.emplaceBack(m+a,-1.2,m,.8),n.indexArray.emplaceBack(6+r,4+r,8+r),n.indexArray.emplaceBack(7+r,9+r,5+r),n.indexArray.emplaceBack(0+r,1+r,2+r),n.indexArray.emplaceBack(1+r,3+r,2+r),r+=10}const o={defined:!0,emissiveFactor:[0,0,0]},s={};return s.baseColorFactor=Un.white,o.pbrMetallicRoughness=s,n.material=o,n.aabb=new wu([1/0,1/0,1/0],[-1/0,-1/0,-1/0]),n}const Zx=new Float32Array(262144),qx=new Uint8Array(262144);function Hx(t){let e=0;if(t.meshes)for(const i of t.meshes)e=Math.max(e,i.aabb.max[2]);if(t.children)for(const i of t.children)e=Math.max(e,Hx(i));return e}function Wx(t,e,i){if(t.meshes)for(const n of t.meshes)n.aabb.min[0]!==1/0&&i.insert(e,n.aabb.min[0],n.aabb.min[1],n.aabb.max[0],n.aabb.max[1]);if(t.children)for(const n of t.children)Wx(n,e,i)}const Yx=["","wall","door","roof","window","lamp","logo"];class Xx{constructor(t){this.node=t,this.evaluatedRMEA=[[1,0,0,1],[1,0,0,1],[1,0,0,1],[1,0,0,1],[.4,1,0,1],[1,0,0,1],[1,0,0,1]],this.hiddenByReplacement=!1,this.evaluatedScale=[1,1,1],this.evaluatedColor=[],this.emissionHeightBasedParams=[],this.feature={type:"Point",id:t.id,geometry:[],properties:{height:Hx(t)}},this.aabb=this._getLocalBounds()}_getLocalBounds(){if(!this.node.meshes)return new wu([1/0,1/0,1/0],[-1/0,-1/0,-1/0]);if(!this.aabb){let t=0;const e=new wu([1/0,1/0,1/0],[-1/0,-1/0,-1/0]);for(const i of this.node.meshes)this.node.lightMeshIndex!==t&&(i.transformedAabb=wu.applyTransformFast(i.aabb,this.node.matrix),e.encapsulate(i.transformedAabb)),t++;this.aabb=e}return this.aabb}}class Kx{constructor(t,e,i,n,r,o){this.id=e,this.modelTraits|=Yv.CoordinateSpaceTile,this.uploaded=!1,this.hasPattern=!1,i&&(this.modelTraits|=Yv.HasMapboxMeshFeatures),n&&(this.modelTraits|=Yv.HasMeshoptCompression),this.zoom=-1,this.terrainExaggeration=1,this.projection={name:"mercator"},this.replacementUpdateTime=0,this.elevationReadFromZ=255,this.brightness=r,this.dirty=!0,this.needsUpload=!1,this.nodesInfo=[];for(const e of t)this.nodesInfo.push(new Xx(e)),Wx(e,o.featureIndexArray.length,o.grid),o.featureIndexArray.emplaceBack(this.nodesInfo.length-1,0,o.bucketLayerIDs.length-1,0)}updateFootprints(t,e){for(const i of this.getNodesInfo()){const n=i.node;n.footprint&&e.push({footprint:n.footprint,id:t})}}update(){console.log("Update 3D model bucket")}populate(){console.log("populate 3D model bucket")}uploadPending(){return!this.uploaded||this.needsUpload}upload(t){if(!this.needsUpload)return;const e=this.getNodesInfo();for(const i of e){const e=i.node;this.uploaded?this.updatePbrBuffer(e):Qv(e,t,!0)}for(const t of e)tx(t.node);this.uploaded=!0,this.needsUpload=!1}updatePbrBuffer(t){let e=!1;if(!t.meshes)return e;for(const i of t.meshes)i.pbrBuffer&&(i.pbrBuffer.updateData(i.featureArray),e=!0);return e}needsReEvaluation(t,e,i){const n=t.transform.projectionOptions,r=t.style.getBrightness(),o=this.brightness!==r;return!!(!this.uploaded||this.dirty||n.name!==this.projection.name||Jx(i.paint.get("model-color").value,o)||Jx(i.paint.get("model-color-mix-intensity").value,o)||Jx(i.paint.get("model-roughness").value,o)||Jx(i.paint.get("model-emissive-strength").value,o)||Jx(i.paint.get("model-height-based-emissive-strength-multiplier").value,o))&&(this.projection=n,this.brightness=r,!0)}evaluateScale(t,e){if(t.transform.zoom===this.zoom)return;this.zoom=t.transform.zoom;const i=this.getNodesInfo(),n=this.id.canonical;for(const t of i){const i=t.feature;t.evaluatedScale=e.paint.get("model-scale").evaluate(i,{},n)}}evaluate(t){const e=this.getNodesInfo();for(const i of e){if(!i.node.meshes)continue;const e=i.feature,n=i.node.meshes&&i.node.meshes[0].featureData,r=i.evaluatedColor[2],o=i.evaluatedRMEA[2],s=this.id.canonical;if(i.hasTranslucentParts=!1,n){for(let n=0;n=t)continue;const u=Zx[c],h=Math.abs(u);h>a&&(s=u,a=h,l=r,d=e)}if(a>.1){const o=1-(t+.5*Math.abs(l*d))/c;let a=e._dem.get(n,i)+s*o;const u=e._dem.get(n+l,i+d),h=e._dem.get(n-l,i-d,!0);(a-u)*(a-h)>0&&(a=(u+h)/2),Zx[r]=e._dem.set(n,i,a),qx[r]=t}}}}}s&&(e._demTile.needsDEMTextureUpload=!0,e._dem._timestamp=ki.now())}getNodesInfo(){return this.nodesInfo}destroy(){const t=this.getNodesInfo();for(const e of t)tx(e.node),ex(e.node)}isEmpty(){return!this.nodesInfo.length}updateReplacement(t,e){if(e.updateTime===this.replacementUpdateTime)return;this.replacementUpdateTime=e.updateTime;const i=e.getReplacementRegionsForTile(t.toUnwrapped()),n=this.getNodesInfo();for(let t=0;tt.footprint===e.footprint))}}getHeightAtTileCoord(e,i){const n=this.getNodesInfo(),r=[],o=[0,0,0],s=t.ad.identity([]);for(let a=0;ad.max[0]||i>d.max[1])continue;if(!0===l.node.hidden)return{height:0,maxHeight:l.feature.properties.height,hidden:!1,verticalScale:l.evaluatedScale[2]};t.ad.invert(s,l.node.matrix),o[0]=e,o[1]=i,t._.transformMat4(o,o,s);const u=(o[0]-c.aabb.min[0])/(c.aabb.max[0]-c.aabb.min[0])*Wv|0,h=Math.min(63,(o[1]-c.aabb.min[1])/(c.aabb.max[1]-c.aabb.min[1])*Wv|0)*Wv+Math.min(63,u),p=c.heightmap[h];if(!(p0)return{height:void 0,maxHeight:l.feature.properties.height,hidden:l.hiddenByReplacement,verticalScale:l.evaluatedScale[2]}}}}function Jx(t,e){return!t.isLightConstant&&e}function Qx(t,e,i,n,r,o,s,a){let l=(61440&e|(61440&e)>>4)>>8,c=(3840&e|(3840&e)>>4)>>4,d=240&e|(240&e)>>4;i[3]>0&&(l=Vn(l,255*i[0],i[3]),c=Vn(c,255*i[1],i[3]),d=Vn(d,255*i[2],i[3]));const u=l>16&65535,a=o?e>>16&65535:65535&e,l=(15&a)t.polygon)).flat());const g=f?l:null,[y,v]=function(e,i,n,r,o,s,a,l,c,d,u){return"globe"===e.projection.name?function(e,i,n,r,o,s,a,l,c,d,u){const h=[],p=[],f=e.projection.upVectorScale(u,e.center.lat,e.worldSize).metersToTile,m=[0,0,0,1],_=[0,0,0,1],g=(t,e,i,n)=>{t[0]=e,t[1]=i,t[2]=n,t[3]=1},y=Sf();n>0&&(n+=y),r+=y;for(const y of i){const i=[],v=[];for(const h of y){const p=h.x+o.x,y=h.y+o.y,x=e.projection.projectTilePoint(p,y,u),b=e.projection.upVector(u,h.x,h.y);let w=n,T=r;if(a){const t=Pf(p,y,n,r,a,l,c,d);w+=t.base,T+=t.top}0!==n?g(m,x.x+b[0]*f*w,x.y+b[1]*f*w,x.z+b[2]*f*w):g(m,x.x,x.y,x.z),g(_,x.x+b[0]*f*T,x.y+b[1]*f*T,x.z+b[2]*f*T),t._.transformMat4(m,m,s),t._.transformMat4(_,_,s),i.push(new Tp(m[0],m[1],m[2])),v.push(new Tp(_[0],_[1],_[2]))}h.push(i),p.push(v)}return[h,p]}(e,i,n,r,o,s,a,l,c,d,u):a?function(e,i,n,r,o,s,a,l,c){const d=[],u=[],h=[0,0,0,1];for(const p of e){const e=[],f=[];for(const d of p){const u=d.x+r.x,p=d.y+r.y,m=Pf(u,p,i,n,s,a,l,c);h[0]=u,h[1]=p,h[2]=m.base,h[3]=1,t.aA.transformMat4(h,h,o),h[3]=Math.max(h[3],1e-5);const _=new Tp(h[0]/h[3],h[1]/h[3],h[2]/h[3]);h[0]=u,h[1]=p,h[2]=m.top,h[3]=1,t.aA.transformMat4(h,h,o),h[3]=Math.max(h[3],1e-5);const g=new Tp(h[0]/h[3],h[1]/h[3],h[2]/h[3]);e.push(_),f.push(g)}d.push(e),u.push(f)}return[d,u]}(i,n,r,o,s,a,l,c,d):function(t,e,i,n,r){const o=[],s=[],a=r[8]*e,l=r[9]*e,c=r[10]*e,d=r[11]*e,u=r[8]*i,h=r[9]*i,p=r[10]*i,f=r[11]*i;for(const e of t){const t=[],i=[];for(const o of e){const e=o.x+n.x,s=o.y+n.y,m=r[0]*e+r[4]*s+r[12],_=r[1]*e+r[5]*s+r[13],g=r[2]*e+r[6]*s+r[14],y=r[3]*e+r[7]*s+r[15],v=m+a,x=_+l,b=g+c,w=Math.max(y+d,1e-5),T=m+u,S=_+h,E=g+p,M=Math.max(y+f,1e-5);t.push(new Tp(v/w,x/w,b/w)),i.push(new Tp(T/M,S/M,E/M))}o.push(t),s.push(i)}return[o,s]}(i,n,r,o,s)}(s,r,h,u,d,a,g,p,m,s.center.lat,e.tileID.canonical),x=e.queryGeometry;return function(t,e,i){let n=1/0;Kd(i,e)&&(n=Lf(i,e[0]));for(let r=0;r=3)for(let e=0;e>4;if(1!==n)throw new Error(`Got v${n} data when expected v1.`);const r=nb[15&i];if(!r)throw new Error("Unrecognized array type.");const[o]=new Uint16Array(t,2,1),[s]=new Uint32Array(t,4,1);return new rb(s,o,r,t)}constructor(t,e=64,i=Float64Array,n){if(isNaN(t)||t>1;return this.ids[i]=i,this.coords[this._pos++]=t,this.coords[this._pos++]=e,i}finish(){const t=this._pos>>1;if(t!==this.numItems)throw new Error(`Added ${t} items when expected ${this.numItems}.`);return ob(this.ids,this.coords,this.nodeSize,0,this.numItems-1,0),this._finished=!0,this}range(t,e,i,n){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");const{ids:r,coords:o,nodeSize:s}=this,a=[0,r.length-1,0],l=[];for(;a.length;){const c=a.pop()||0,d=a.pop()||0,u=a.pop()||0;if(d-u=t&&a=e&&c>1,p=o[2*h],f=o[2*h+1];p>=t&&p=e&&f=p:n>=f)&&(a.push(h+1),a.push(d),a.push(1-c))}return l}within(t,e,i){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");const{ids:n,coords:r,nodeSize:o}=this,s=[0,n.length-1,0],a=[],l=i*i;for(;s.length;){const c=s.pop()||0,d=s.pop()||0,u=s.pop()||0;if(d-u>1,p=r[2*h],f=r[2*h+1];cb(p,f,t,e)=p:e+i>=f)&&(s.push(h+1),s.push(d),s.push(1-c))}return a}}function ob(t,e,i,n,r,o){if(r-n>1;sb(t,e,s,n,r,o),ob(t,e,i,n,s-1,1-o),ob(t,e,i,s+1,r,1-o)}function sb(t,e,i,n,r,o){for(;r>n;){if(r-n>600){const s=r-n+1,a=i-n+1,l=Math.log(s),c=.5*Math.exp(2*l/3),d=.5*Math.sqrt(l*c*(s-c)/s)*(a-s/2s&&ab(t,e,n,r);as;)l--}e[2*n+o]===s?ab(t,e,n,l):(l++,ab(t,e,l,r)),lr&&(n+=(t[i]-r)*(t[i]-r)),e[i]0&&n[0]0&&n[1]0&&r[0]0&&r[1]0?Math.acos(i/n)*Ve:0;let o=0!==t||0!==e?Math.atan2(-e,-t)*Ve+90:0;return oNi&&(t.getActor().send("enforceCacheSizeLimit",Fi),Vi=0)},t.an=gn,t.ao=class{constructor(t){this.entries={},this.scheduler=t}request(t,e,i,n){const r=this.entries[t]=this.entries[t]||{callbacks:[]};if(r.result){const[t,i]=r.result;return this.scheduler?this.scheduler.add((()=>{n(t,i)}),e):n(t,i),()=>{}}return r.callbacks.push(n),r.cancel||(r.cancel=i(((i,n)=>{r.result=[i,n];for(const t of r.callbacks)this.scheduler?this.scheduler.add((()=>{t(i,n)}),e):t(i,n);setTimeout((()=>delete this.entries[t]),3e3)}))),()=>{r.result||(r.callbacks=r.callbacks.filter((t=>t!==n)),r.callbacks.length||(r.cancel(),delete this.entries[t]))}}},t.ap=function(t,e,i){const n=JSON.stringify(t.request);return t.data&&(this.deduped.entries[n]={result:[null,t.data]}),this.deduped.request(n,{type:"parseTile",isSymbolTile:t.isSymbolTile,zoom:t.tileZoom},(e=>{const n=en(t.request,((t,n,r,o)=>{t?e(t):n&&e(null,{vectorTile:i?void 0:new bp(new Lm(n)),rawData:n,cacheControl:r,expires:o})}));return()=>{n.cancel(),e()}}),e)},t.aq=Dc,t.ar=class extends Lc{constructor(t){super(t),this.current=Fc}set(t,e,i){if(this.fetchUniformLocation(t,e))for(let t=0;t({u_camera_to_center_distance:new $c(t),u_extrude_scale:new Uc(t),u_device_pixel_ratio:new $c(t),u_matrix:new Bc(t),u_inv_rot_matrix:new Bc(t),u_merc_center:new kc(t),u_tile_id:new Dc(t),u_zoom_transition:new $c(t),u_up_dir:new Dc(t),u_emissive_strength:new $c(t)}),t.bJ=t=>({u_matrix:new Bc(t),u_pixels_to_tile_units:new Uc(t),u_device_pixel_ratio:new $c(t),u_units_to_pixels:new kc(t),u_dash_image:new Pc(t),u_gradient_image:new Pc(t),u_image_height:new $c(t),u_texsize:new kc(t),u_tile_units_to_pixels:new $c(t),u_alpha_discard_threshold:new $c(t),u_trim_offset:new kc(t),u_trim_fade_range:new kc(t),u_trim_color:new zc(t),u_emissive_strength:new $c(t)}),t.bK=t=>({u_matrix:new Bc(t),u_texsize:new kc(t),u_pixels_to_tile_units:new Uc(t),u_device_pixel_ratio:new $c(t),u_image:new Pc(t),u_units_to_pixels:new kc(t),u_tile_units_to_pixels:new $c(t),u_alpha_discard_threshold:new $c(t),u_trim_offset:new kc(t)}),t.bL=Yl,t.bM=Hf,t.bN=Om,t.bO=jm,t.bP=G_,t.bQ=c_,t.bR=th,t.bS=(t,e,i,n,r,o)=>{const s=t.transform,a="globe"===s.projection.name;let l;if("map"===o.paint.get("circle-pitch-alignment"))if(a){const t=Zu(s.zoom,e.canonical)*s._pixelsPerMercatorPixel;l=Float32Array.from([t,0,0,t])}else l=s.calculatePixelsToTileUnitsMatrix(i);else l=new Float32Array([s.pixelsToGLUnits[0],0,0,s.pixelsToGLUnits[1]]);const c={u_camera_to_center_distance:t.transform.getCameraToCenterDistance(s.projection),u_matrix:t.translatePosMatrix(e.projMatrix,i,o.paint.get("circle-translate"),o.paint.get("circle-translate-anchor")),u_device_pixel_ratio:ki.devicePixelRatio,u_extrude_scale:l,u_inv_rot_matrix:Qu,u_merc_center:[0,0],u_tile_id:[0,0,0],u_zoom_transition:0,u_up_dir:[0,0,0],u_emissive_strength:o.paint.get("circle-emissive-strength")};if(a){c.u_inv_rot_matrix=n,c.u_merc_center=r,c.u_tile_id=[e.canonical.x,e.canonical.y,1{const s=t.transform;return{u_matrix:rm(t,e,i,n),u_texsize:e.imageAtlasTexture?e.imageAtlasTexture.size:[0,0],u_pixels_to_tile_units:s.calculatePixelsToTileUnitsMatrix(e),u_device_pixel_ratio:r,u_image:0,u_tile_units_to_pixels:nm(e,s),u_units_to_pixels:[1/s.pixelsToGLUnits[0],1/s.pixelsToGLUnits[1]],u_alpha_discard_threshold:0,u_trim_offset:o}},t.bV=(t,e,i,n,r,o,s)=>{const a=t.transform,l=a.calculatePixelsToTileUnitsMatrix(e);return{u_matrix:rm(t,e,i,n),u_pixels_to_tile_units:l,u_device_pixel_ratio:o,u_units_to_pixels:[1/a.pixelsToGLUnits[0],1/a.pixelsToGLUnits[1]],u_dash_image:0,u_gradient_image:1,u_image_height:r,u_texsize:sm(i)&&e.lineAtlasTexture?e.lineAtlasTexture.size:[0,0],u_tile_units_to_pixels:nm(e,t.transform),u_alpha_discard_threshold:0,u_trim_offset:s,u_trim_fade_range:i.paint.get("line-trim-fade-range"),u_trim_color:i.paint.get("line-trim-color").toRenderColor(i.lut).toArray01(),u_emissive_strength:i.paint.get("line-emissive-strength")}},t.bW=oi,t.bX=mh,t.bY=Sf,t.bZ=bd,t.b_=_f,t.ba=function(t,e,i){const n=Hu(i.zoom),r=t.style.map._antialias,o=e.options.extStandardDerivativesForceOff||t.terrain&&t.terrain.exaggeration()>0;return 0===n&&!r&&!o},t.bb=function(e){const i=e.pixelsPerMeter,n=i/Cd(1,e.center.lat),r=t.ad.identity(new Float64Array(16));return t.ad.translate(r,r,[e.point.x,e.point.y,0]),t.ad.scale(r,r,[n,n,i]),Float32Array.from(r)},t.bc=Ou,t.bd=function(t){const e=Pd-5;t=Xe(t,-e,e)/e*90;const i=Math.pow(Math.abs(Math.sin(Ge(t))),3);return Math.round(i*(sd.length-1))},t.be=function(e,i,n,r){const o=i.getNorth(),s=i.getSouth(),a=i.getWest(),l=i.getEast(),c=10){const e=180/r;t.bC.multiply(f,f,[e/d+1,0,0,0,e/u+1,0,-.5*e/h,.5*e/p,1])}return f[2]=c,f[5]=e.x,f[8]=e.y,f},t.bf=ju,t.bg=$u,t.bh=function(e,i,n){const r=t.ad.identity(new Float64Array(16)),o=(i/(1{}}},t.bo=Gg,t.bp=ai,t.bq=class{isDataAvailableAtPoint(t){const e=this._source();if(this.isUsingMockSource()||!e||t.y1)return!1;const i=e.getSource().maxzoom,n=11)return e;const r=n.getSource().maxzoom,o=1{const s=this.getAtTileOffset(e,o.x,o.y),a=r.upVector(e.canonical,o.x,o.y),l=r.upVectorScale(e.canonical,i,n).metersToTile;return t._.scale(a,a,s*l),a}}getForTilePoints(t,e,i,n){if(this.isUsingMockSource())return!1;const r=Xp.create(this,t,n);return!!r&&(e.forEach((t=>{t[2]=this.exaggeration()*r.getElevationAt(t[0],t[1],i)})),!0)}getMinMaxForTile(t){if(this.isUsingMockSource())return null;const e=this.findDEMTileFor(t);if(!e||!e.dem)return null;const i=e.dem.tree,n=e.tileID,r=1=0?t.slice(0,e):t},t.cV=function(t){return t.indexOf(wl)>=0},t.cW=function(t){const e=t.indexOf(wl);return e>=0?t.slice(e+1):""},t.cX=function(t){const e=[],i=t.id;return void 0===i&&e.push({message:`layers.${i}: missing required property "id"`}),void 0===t.render&&e.push({message:`layers.${i}: missing required method "render"`}),t.renderingMode&&"2d"!==t.renderingMode&&"3d"!==t.renderingMode&&e.push({message:`layers.${i}: property "renderingMode" must be either "2d" or "3d"`}),e},t.cY=function(t,e,i,n){return"custom"===t.type?new vv(t,e):new ib[t.type](t,e,i,n)},t.cZ=di,t.c_=Va,t.ca=1,t.cb=Ag,t.cc=0,t.cd=ec,t.ce=function(t,e,i,n,r){return Xe((t-e)/(i-e)*(r-n)+n,n,r)},t.cf=Ns,t.cg=kd,t.ch=class{constructor(t,e,i,n){this.context=t,this.format=n,this.size=i,this.texture=t.gl.createTexture();const[r,o,s]=this.size,{gl:a}=t;a.bindTexture(a.TEXTURE_3D,this.texture),t.pixelStoreUnpackFlipY.set(!1),t.pixelStoreUnpack.set(1),t.pixelStoreUnpackPremultiplyAlpha.set(!1);let l=this.format,c=a.UNSIGNED_BYTE;this.format===a.DEPTH_COMPONENT&&(l=a.DEPTH_COMPONENT16,c=a.UNSIGNED_SHORT),this.format===a.R8&&(n=a.RED),this.format===a.R32F&&(c=a.FLOAT,n=a.RED),a.texImage3D(a.TEXTURE_3D,0,l,r,o,s,0,n,c,e.data)}bind(t,e){const{context:i}=this,{gl:n}=i;n.bindTexture(n.TEXTURE_3D,this.texture),t!==this.minFilter&&(n.texParameteri(n.TEXTURE_3D,n.TEXTURE_MAG_FILTER,t),n.texParameteri(n.TEXTURE_3D,n.TEXTURE_MIN_FILTER,t),this.minFilter=t),e!==this.wrapS&&(n.texParameteri(n.TEXTURE_3D,n.TEXTURE_WRAP_S,e),n.texParameteri(n.TEXTURE_3D,n.TEXTURE_WRAP_T,e),this.wrapS=e)}destroy(){const{gl:t}=this.context;t.deleteTexture(this.texture),this.texture=null}},t.ci=$v,t.cj=[1,1,1],t.ck=Xp,t.cl=Yv,t.cm=ql,t.cn=ic,t.co=class{constructor(){this._updateTime=0,this._sourceIds=[],this._activeRegions=[],this._prevRegions=[],this._globalClipBounds={min:new Ue(1/0,1/0),max:new Ue(-1/0,-1/0)}}clear(){this._activeRegions.length>0&&++this._updateTime,this._activeRegions=[],this._prevRegions=[]}get updateTime(){return this._updateTime}getReplacementRegionsForTile(t,e=!1){const i=$p(new Ue(0,0),new Ue(uo,uo),t),n=[];if(e&&!Lp(i,this._globalClipBounds))return n;for(const e of this._activeRegions){if(e.hiddenByOverlap)continue;if(!Lp(i,e))continue;const r=kp(e.min,e.max,t);n.push({min:r.min,max:r.max,sourceId:this._sourceIds[e.priority],footprint:e.footprint,footprintTileId:e.tileId,order:e.order,clipMask:e.clipMask})}return n}setSources(t){this._setSources(t.map((t=>({getSourceId:()=>t.cache.id,getFootprints:()=>{const e=[];for(const i of t.cache.getVisibleCoordinates()){const n=t.cache.getTile(i).buckets[t.layer];n&&n.updateFootprints(i.toUnwrapped(),e)}return e},getOrder:()=>t.order,getClipMask:()=>t.clipMask}))))}_addSource(t){const e=t.getFootprints();if(0===e.length)return;const i=t.getOrder(),n=t.getClipMask();for(const t of e){if(!t.footprint)continue;const e=$p(t.footprint.min,t.footprint.max,t.id);this._activeRegions.push({min:e.min,max:e.max,hiddenByOverlap:!1,priority:this._sourceIds.length,tileId:t.id,footprint:t.footprint,order:i,clipMask:n})}this._sourceIds.push(t.getSourceId())}_computeReplacement(){this._activeRegions.sort(((t,e)=>t.priority-e.priority||Ap(t.min,e.min)||Ap(t.max,e.max)));let t=this._activeRegions.length!==this._prevRegions.length;if(!t){let e=0;for(;!t&&e!==this._activeRegions.length;){const i=this._activeRegions[e],n=this._prevRegions[e];t=i.priority!==n.priority||!Ip(i,n)||i.order!==n.order||i.clipMask!==n.clipMask,++e}}if(t){++this._updateTime;for(const t of this._activeRegions)t.order!==1/0&&(this._globalClipBounds.min.x=Math.min(this._globalClipBounds.min.x,t.min.x),this._globalClipBounds.min.y=Math.min(this._globalClipBounds.min.y,t.min.y),this._globalClipBounds.max.x=Math.max(this._globalClipBounds.max.x,t.max.x),this._globalClipBounds.max.y=Math.max(this._globalClipBounds.max.y,t.max.y));const t=t=>{const e=this._activeRegions;if(t>=e.length)return t;const i=e[t].priority;for(;t1){let e=0,i=t(e);for(;e!==i;){let n=e;const r=e;for(;n!==i;){const t=this._activeRegions[n];t.hiddenByOverlap=!1;for(let e=0;e=0;e--)this._addSource(t[e]);this._computeReplacement()}},t.cp=Dl,t.cq=Jg,t.cr=rc,t.cs=class{constructor(t){this._createGrid(t),this._createPoles(t)}destroy(){this._poleIndexBuffer.destroy(),this._gridBuffer.destroy(),this._gridIndexBuffer.destroy(),this._poleNorthVertexBuffer.destroy(),this._poleSouthVertexBuffer.destroy();for(const t of this._poleSegments)t.destroy();for(const t of this._gridSegments)t.withSkirts.destroy(),t.withoutSkirts.destroy()}_fillGridMeshWithLods(t,e){const i=new $l,n=new Kl,r=[],o=t+1+2,s=e[0]+1,a=e[0]+1+(1+e.length),l=(t,e,i)=>{let n=t===o-1?t-2:0===t?t:t-1;return n+=i?24575:0,[n,e]};for(let t=0;tt()))},t.dB=sx,t.dC=yx,t.dD=function(t){px=ki.resolveURL(t),gx||(gx=new ox(ux(),new zn)),gx.broadcast("setDracoUrl",px)},t.dE=vx,t.dF=function(t){mx=ki.resolveURL(t),gx||(gx=new ox(ux(),new zn)),gx.broadcast("setMeshoptUrl",mx)},t.dG=ti,t.dH=ba,t.dI=dh,t.dJ=I_,t.dK=eg,t.dL=dc,t.dM=am,t.dN=Dm,t.dO=Wf,t.dP=ci,t.dQ=E_,t.dR=jg,t.dS=function(t,e,i,n,r,o,s,a,l,c,d){t.createArrays(),t.tilePixelRatio=uo/(512*t.overscaling),t.compareText={},t.iconsNeedLinear=!1;const u=t.layers[0].layout,h=t.layers[0]._unevaluatedLayout._values,p={};if("composite"===t.textSizeData.kind){const{minZoom:e,maxZoom:i}=t.textSizeData;p.compositeTextSizes=[h["text-size"].possiblyEvaluate(new Ha(e),a),h["text-size"].possiblyEvaluate(new Ha(i),a)]}if("composite"===t.iconSizeData.kind){const{minZoom:e,maxZoom:i}=t.iconSizeData;p.compositeIconSizes=[h["icon-size"].possiblyEvaluate(new Ha(e),a),h["icon-size"].possiblyEvaluate(new Ha(i),a)]}p.layoutTextSize=h["text-size"].possiblyEvaluate(new Ha(l+1),a),p.layoutIconSize=h["icon-size"].possiblyEvaluate(new Ha(l+1),a),p.textMaxSize=h["text-size"].possiblyEvaluate(new Ha(18),a);const f="map"===u.get("text-rotation-alignment")&&"point"!==u.get("symbol-placement"),m=u.get("text-size");let _=!1;for(const e of t.features)if(e.icon&&e.icon.nameSecondary){_=!0;break}for(const o of t.features){const l=u.get("text-font").evaluate(o,{},a).join(","),h=m.evaluate(o,{},a),g=p.layoutTextSize.evaluate(o,{},a),y=(p.layoutIconSize.evaluate(o,{},a),{horizontal:{},vertical:void 0}),v=o.text;let x,b=[0,0];if(v){const n=v.toString(),s=u.get("text-letter-spacing").evaluate(o,{},a)*Om,c=u.get("text-line-height").evaluate(o,{},a)*Om,d=Aa(n)?s:0,p=u.get("text-anchor").evaluate(o,{},a),m=u.get("text-variable-anchor");if(!m){const t=u.get("text-radial-offset").evaluate(o,{},a);b=t?G_(p,[t*Om,j_]):u.get("text-offset").evaluate(o,{},a).map((t=>t*Om))}let _=f?"center":u.get("text-justify").evaluate(o,{},a);const x="point"===u.get("symbol-placement"),w=x?u.get("text-max-width").evaluate(o,{},a)*Om:1/0,T=o=>{t.allowVerticalPlacement&&Ca(n)&&(y.vertical=e_(v,e,i,r,l,w,c,p,o,d,b,Jm.vertical,!0,g,h))};if(!f&&m){const t="auto"===_?m.map((t=>Z_(t))):[_];let n=!1;for(let o=0;o=0||!Ca(n)){const t=e_(v,e,i,r,l,w,c,p,_,d,b,Jm.horizontal,!1,g,h);t&&(y.horizontal[_]=t)}T(x?"left":_)}}let w=!1;if(o.icon&&o.icon.namePrimary){const e=n[o.icon.namePrimary];e&&(x=u_(r[o.icon.namePrimary],o.icon.nameSecondary?r[o.icon.nameSecondary]:void 0,u.get("icon-offset").evaluate(o,{},a),u.get("icon-anchor").evaluate(o,{},a)),w=e.sdf,void 0===t.sdfIcons?t.sdfIcons=e.sdf:t.sdfIcons!==e.sdf&&pi("Style sheet warning: Cannot mix SDF and non-SDF icons in one buffer"),(e.pixelRatio!==t.pixelRatio||0!==u.get("icon-rotate").constantOr(1))&&(t.iconsNeedLinear=!0))}const T=X_(y.horizontal)||y.vertical;t.iconsInText||(t.iconsInText=!!T&&T.iconsInText),(T||x)&&q_(t,o,y,x,n,p,g,0,b,w,s,a,c,d,_)}o&&t.generateCollisionDebugBuffers(l,t.collisionBoxArray)},t.dT=Jf,t.dU=Yh,t.dV=bp,t.dW=Lm,t.dX=Yp,t.dY=Zy,t.dZ=wp,t.d_=cp,t.da=Wu,t.db=function(e){const i=[0,0,0],n=t.ad.identity(new Float64Array(16));return t.ad.multiply(n,e.pixelMatrix,e.globeMatrix),t._.transformMat4(i,i,n),new Ue(i[0],i[1])},t.dc=d,t.dd=c,t.de=function(t){const e=t.navigator?t.navigator.userAgent:null;return!!function(t){if(null==Ei){const e=t.navigator?t.navigator.userAgent:null;Ei=!!t.safari||!(!e||!(/\b(iPad|iPhone|iPod)\b/.test(e)||e.match("Safari")&&!e.match("Chrome")))}return Ei}(t)&&e&&(e.match("Version/15.4")||e.match("Version/15.5")||e.match(/CPU (OS|iPhone OS) (15_4|15_5) like Mac OS X/))},t.df=ni,t.dg=class{constructor(t,e,i){this._transformRequestFn=t,this._customAccessToken=e,this._silenceAuthErrors=!!i,this._createSkuToken()}_createSkuToken(){const t=function(){let t="";for(let e=0;ethis._skuTokenExpiresAt}transformRequest(t,e){return this._transformRequestFn&&this._transformRequestFn(t,e)||{url:t}}normalizeStyleURL(t,i){if(!o(t))return t;const n=un(t);return n.params.push(`sdk=js-${e}`),n.path=`/styles/v1${n.path}`,this._makeAPIURL(n,this._customAccessToken||i)}normalizeGlyphsURL(t,e){if(!o(t))return t;const i=un(t);return i.path=`/fonts/v1${i.path}`,this._makeAPIURL(i,this._customAccessToken||e)}normalizeModelURL(t,e){if(!o(t))return t;const i=un(t);return i.path=`/models/v1${i.path}`,this._makeAPIURL(i,this._customAccessToken||e)}normalizeSourceURL(t,e,i,n){if(!o(t))return t;const r=un(t);return r.path=`/v4/${r.authority}.json`,r.params.push("secure"),i&&r.params.push(`language=${i}`),n&&r.params.push(`worldview=${n}`),this._makeAPIURL(r,this._customAccessToken||e)}normalizeSpriteURL(t,e,i,n){const r=un(t);return o(t)?(r.path=`/styles/v1${r.path}/sprite${e}${i}`,this._makeAPIURL(r,this._customAccessToken||n)):(r.path+=`${e}${i}`,hn(r))}normalizeTileURL(t,e,i){if(this._isSkuTokenExpired()&&this._createSkuToken(),t&&!o(t))return t;const r=un(t);r.path=r.path.replace(/(\.(png|jpg)\d*)(?=$)/,`${e||i&&"raster"!==r.authority&&512===i?"@2x":""}${Gi.supported?".webp":"$1"}`),"raster"===r.authority?r.path=`/${n.RASTER_URL_PREFIX}${r.path}`:"rasterarrays"===r.authority?r.path=`/${n.RASTERARRAYS_URL_PREFIX}${r.path}`:"3dtiles"===r.authority?r.path=`/${n.TILES3D_URL_PREFIX}${r.path}`:(r.path=r.path.replace(/^.+\/v4\//,"/"),r.path=`/${n.TILE_URL_VERSION}${r.path}`);const s=this._customAccessToken||function(t){for(const e of t){const t=e.match(/^access_token=(.*)$/);if(t)return t[1]}return null}(r.params)||n.ACCESS_TOKEN;return n.REQUIRE_ACCESS_TOKEN&&s&&this._skuToken&&r.params.push(`sku=${this._skuToken}`),this._makeAPIURL(r,s)}canonicalizeTileURL(t,e){const i=un(t);if(!i.path.match(/^(\/v4\/|\/(raster|rasterarrays)\/v1\/)/)||!i.path.match(/\.[\w]+$/))return t;let r="mapbox://";i.path.match(/^\/raster\/v1\//)?r+=`raster/${i.path.replace(`/${n.RASTER_URL_PREFIX}/`,"")}`:i.path.match(/^\/rasterarrays\/v1\//)?r+=`rasterarrays/${i.path.replace(`/${n.RASTERARRAYS_URL_PREFIX}/`,"")}`:r+=`tiles/${i.path.replace(`/${n.TILE_URL_VERSION}/`,"")}`;let o=i.params;return e&&(o=o.filter((t=>!t.match(/^access_token=/)))),o.length&&(r+=`?${o.join("&")}`),r}canonicalizeTileset(t,e){const i=!!e&&o(e),n=[];for(const e of t.tiles||[])r(e)?n.push(this.canonicalizeTileURL(e,i)):n.push(e);return n}_makeAPIURL(t,e){const i="See https://docs.mapbox.com/api/overview/#access-tokens-and-token-scopes",r=un(n.API_URL);if(t.protocol=r.protocol,t.authority=r.authority,"http"===t.protocol){const e=t.params.indexOf("secure");e>=0&&t.params.splice(e,1)}if("/"!==r.path&&(t.path=`${r.path}${t.path}`),!n.REQUIRE_ACCESS_TOKEN)return hn(t);if(e=e||n.ACCESS_TOKEN,!this._silenceAuthErrors){if(!e)throw new Error(`An API access token is required to use Mapbox GL. ${i}`);if("s"===e[0])throw new Error(`Use a public access token (pk.*) with Mapbox GL, not a secret access token (sk.*). ${i}`)}return t.params=t.params.filter((t=>-1===t.indexOf("access_token"))),t.params.push(`access_token=${e||""}`),hn(t)}},t.dh=function(t,e){e?Mn.add(t):Mn.delete(t)},t.di=Gi,t.dj=Tn,t.dk=En,t.dl=cn,t.dm=vn,t.dn=bn,t.dp=function(t){Mn.delete(t)},t.dq=Sn,t.dr=yn,t.ds=Qe,t.dt=e,t.du=function(t,e){Fi=t,Ni=e},t.dv=function(t,e,i=!1){if(Fa===za||Fa===Ra||Fa===Oa)throw new Error("setRTLTextPlugin cannot be called multiple times.");Na=ki.resolveURL(t),Fa=za,Ba=e,ja(),i||Za()},t.dw=Ga,t.dx=function(){ux().acquire(lx)},t.dy=function(){const t=dx;t&&(t.isPreloaded()&&1===t.numActive()?(t.release(lx),dx=null):console.warn("Could not clear WebWorkers since there are active Map instances that still reference it. The pre-warmed WebWorker pool can only be cleared when all map instances have been removed with map.remove()"))},t.dz=cx,t.e=ki,t.e0=cm,t.e1=h,t.e2=en,t.e3=function(t){let e=0;if(new Uint32Array(t,0,1)[0]!==Ax){const i=new Uint32Array(t,0,7),[,,n,r,o,s]=i;e=i.byteLength+r+o+s+o,(n!==t.byteLength||e>=t.byteLength)&&pi("Invalid b3dm header information.")}return Dx(t,e)},t.e4=function(t,e){const i=jx(t);for(const t of i){for(const e of t.meshes)Vx(e);t.lights&&(t.lightMeshIndex=t.meshes.length,t.meshes.push(Gx(t.lights,e)))}return i},t.e5=Kx,t.e6=rx,t.e7=qa,t.e8=function(t){ji(),Oi&&Oi.then((e=>{e.keys().then((i=>{for(let n=0;nt.arrayBuffer())).then((e=>Dx(e,0,t)))},t.m=class extends Uv{},t.n=Er,t.o=qn,t.p=Qg,t.q=Xs,t.r=Js,t.s=Qs,t.t=ca,t.u=al,t.v=ll,t.w=pi,t.x=pa,t.y=da,t.z=qo})),n(0,(function(t){function e(t){const e=t?t.url.toString():void 0;return e?performance.getEntriesByName(e):[]}function i(t){if("number"==typeof t||"boolean"==typeof t||"string"==typeof t||null==t)return JSON.stringify(t);if(Array.isArray(t)){let e="[";for(const n of t)e+=`${i(n)},`;return`${e}]`}let e="{";for(const n of Object.keys(t).sort())e+=`${n}:${i(t[n])},`;return`${e}}`}function n(e){let n="";for(const r of t.cE)n+=`/${i(e[r])}`;return n}class r{constructor(t){this.keyCache={},this._layers={},this._layerConfigs={},t&&this.replace(t)}replace(t,e){this._layerConfigs={},this._layers={},this.update(t,[],e)}update(e,i,r){this._options=r;for(const i of e)this._layerConfigs[i.id]=i,(this._layers[i.id]=t.cY(i,this.scope,null,this._options)).compileFilter(),this.keyCache[i.id]&&delete this.keyCache[i.id];for(const t of i)delete this.keyCache[t],delete this._layerConfigs[t],delete this._layers[t];this.familiesBySource={};const o=function(t,e){const i={};for(let r=0;rthis._layers[t.id])),i=e[0];if("none"===i.visibility)continue;const n=i.source||"";let r=this.familiesBySource[n];r||(r=this.familiesBySource[n]={});const o=i.sourceLayer||"_geojsonTileLayer";let s=r[o];s||(s=r[o]=[]),s.push(e)}}}const o=1*t.dJ;class s{constructor(e){const i={},n=[];for(const t in e){const r=e[t],s=i[t]={};for(const t in r.glyphs){const e=r.glyphs[+t];if(!e||0===e.bitmap.width||0===e.bitmap.height)continue;const i=e.metrics.localGlyph?o:1,a={x:0,y:0,w:e.bitmap.width+2*i,h:e.bitmap.height+2*i};n.push(a),s[t]=a}}const{w:r,h:s}=t.j(n),a=new t.dI({width:r||1,height:s||1});for(const n in e){const r=e[n];for(const e in r.glyphs){const s=r.glyphs[+e];if(!s||0===s.bitmap.width||0===s.bitmap.height)continue;const l=i[n][e],c=s.metrics.localGlyph?o:1;t.dI.copy(s.bitmap,a,{x:0,y:0},{x:l.x+c,y:l.y+c},s.bitmap)}}this.image=a,this.positions=i}}t.dH(s,"GlyphAtlas");class a{constructor(e){this.tileID=new t.aL(e.tileID.overscaledZ,e.tileID.wrap,e.tileID.canonical.z,e.tileID.canonical.x,e.tileID.canonical.y),this.tileZoom=e.tileZoom,this.uid=e.uid,this.zoom=e.zoom,this.lut=e.lut,this.canonical=e.tileID.canonical,this.pixelRatio=e.pixelRatio,this.tileSize=e.tileSize,this.source=e.source,this.scope=e.scope,this.overscaling=this.tileID.overscaleFactor(),this.showCollisionBoxes=e.showCollisionBoxes,this.collectResourceTiming=!!e.collectResourceTiming,this.promoteId=e.promoteId,this.isSymbolTile=e.isSymbolTile,this.tileTransform=t.dK(e.tileID.canonical,e.projection),this.projection=e.projection,this.brightness=e.brightness,this.extraShadowCaster=!!e.extraShadowCaster,this.tessellationStep=e.tessellationStep}parse(e,i,n,r,o){this.status="parsing",this.data=e,this.collisionBoxArray=new t.dL;const a=new t.dM(Object.keys(e.layers).sort()),c=new t.dN(this.tileID,this.promoteId);c.bucketLayerIDs=[];const d={},u=new t.dO(256,256),h={featureIndex:c,iconDependencies:{},patternDependencies:{},glyphDependencies:{},lineAtlas:u,availableImages:n,brightness:this.brightness},p=i.familiesBySource[this.source];for(const i in p){const r=e.layers[i];if(!r)continue;let o=!1,s=!1,u=!1;for(const t of p[i])"symbol"===t[0].type?o=!0:s=!0,t[0].is3D()&&"model"!==t[0].type&&(u=!0);if(this.extraShadowCaster&&!u)continue;if(!0===this.isSymbolTile&&!o)continue;if(!1===this.isSymbolTile&&!s)continue;1===r.version&&t.w(`Vector tile source "${this.source}" layer "${i}" does not use vector tile spec v2 and therefore may have some rendering errors.`);const f=a.encode(i),m=[];for(let t=0;t=e.maxzoom||"none"!==e.visibility&&(l(t,this.zoom,h.brightness,n),(d[e.id]=e.createBucket({index:c.bucketLayerIDs.length,layers:t,zoom:this.zoom,lut:this.lut,canonical:this.canonical,pixelRatio:this.pixelRatio,overscaling:this.overscaling,collisionBoxArray:this.collisionBoxArray,sourceLayerIndex:f,sourceID:this.source,projection:this.projection.spec,tessellationStep:this.tessellationStep})).populate(m,h,this.tileID.canonical,this.tileTransform),c.bucketLayerIDs.push(t.map((t=>t.id)))))}}let f,m,_,g;u.trim();const y={type:"maybePrepare",isSymbolTile:this.isSymbolTile,zoom:this.zoom},v=()=>{if(f)return this.status="done",o(f);if(this.extraShadowCaster)this.status="done",o(null,{buckets:t.dG(d).filter((t=>!t.isEmpty())),featureIndex:c,collisionBoxArray:null,glyphAtlasImage:null,lineAtlas:null,imageAtlas:null,brightness:h.brightness,glyphMap:null,iconMap:null,glyphPositions:null});else if(m&&_&&g){const e=new s(m),i=new t.dQ(_,g,this.lut);for(const r in d){const o=d[r];o instanceof t.dR?(l(o.layers,this.zoom,h.brightness,n),t.dS(o,m,e.positions,_,i.iconPositions,this.showCollisionBoxes,n,this.tileID.canonical,this.tileZoom,this.projection,this.brightness)):o.hasPattern&&(o instanceof t.dT||o instanceof t.dU||o instanceof t.b_)&&(l(o.layers,this.zoom,h.brightness,n),o.addFeatures(h,this.tileID.canonical,i.patternPositions,n,this.tileTransform,this.brightness))}this.status="done",o(null,{buckets:t.dG(d).filter((t=>!t.isEmpty())),featureIndex:c,collisionBoxArray:this.collisionBoxArray,glyphAtlasImage:e.image,lineAtlas:u,imageAtlas:i,brightness:h.brightness})}};if(!this.extraShadowCaster){const e=t.dP(h.glyphDependencies,(t=>Object.keys(t).map(Number)));Object.keys(e).length?r.send("getGlyphs",{uid:this.uid,stacks:e,scope:this.scope},((t,e)=>{f||(f=t,m=e,v())}),void 0,!1,y):m={};const i=Object.keys(h.iconDependencies);i.length?r.send("getImages",{icons:i,source:this.source,scope:this.scope,tileID:this.tileID,type:"icons"},((t,e)=>{f||(f=t,_=e,v())}),void 0,!1,y):_={};const n=Object.keys(h.patternDependencies);n.length?r.send("getImages",{icons:n,source:this.source,scope:this.scope,tileID:this.tileID,type:"patterns"},((t,e)=>{f||(f=t,g=e,v())}),void 0,!1,y):g={}}v()}}function l(e,i,n,r){const o=new t.X(i,{brightness:n});for(const t of e)t.recalculate(o,r)}class c extends t.E{constructor(e,i,n,r,o,s){super(),this.actor=e,this.layerIndex=i,this.availableImages=n,this.loadVectorData=o||t.ap,this.loading={},this.loaded={},this.deduped=new t.ao(e.scheduler),this.isSpriteLoaded=r,this.scheduler=e.scheduler,this.brightness=s}loadTile(i,n){const r=i.uid,o=i&&i.request,s=o&&o.collectResourceTiming,l=this.loading[r]=new a(i);l.abort=this.loadVectorData(i,((a,c)=>{const d=!this.loading[r];if(delete this.loading[r],d||a||!c)return l.status="done",d||(this.loaded[r]=l),n(a);const u=c.rawData,h={};c.expires&&(h.expires=c.expires),c.cacheControl&&(h.cacheControl=c.cacheControl),l.vectorTile=c.vectorTile||new t.dV(new t.dW(u));const p=()=>{l.parse(l.vectorTile,this.layerIndex,this.availableImages,this.actor,((i,r)=>{if(i||!r)return n(i);const a={};if(s){const t=e(o);t.length>0&&(a.resourceTiming=JSON.parse(JSON.stringify(t)))}n(null,t.W({rawTileData:u.slice(0)},r,h,a))}))};this.isSpriteLoaded?p():this.once("isSpriteLoaded",(()=>{this.scheduler?this.scheduler.add(p,{type:"parseTile",isSymbolTile:i.isSymbolTile,zoom:i.tileZoom}):p()})),this.loaded=this.loaded||{},this.loaded[r]=l}))}reloadTile(e,i){const n=this.loaded,r=e.uid;if(n&&n[r]){const o=n[r];o.showCollisionBoxes=e.showCollisionBoxes,o.projection=e.projection,o.brightness=e.brightness,o.tileTransform=t.dK(e.tileID.canonical,e.projection),o.extraShadowCaster=e.extraShadowCaster,o.lut=e.lut;const s=(t,e)=>{const n=o.reloadCallback;n&&(delete o.reloadCallback,o.parse(o.vectorTile,this.layerIndex,this.availableImages,this.actor,n)),i(t,e)};"parsing"===o.status?o.reloadCallback=s:"done"===o.status&&(o.vectorTile?o.parse(o.vectorTile,this.layerIndex,this.availableImages,this.actor,s):s())}else i(null,void 0)}abortTile(t,e){const i=t.uid,n=this.loading[i];n&&(n.abort&&n.abort(),delete this.loading[i]),e()}removeTile(t,e){const i=this.loaded,n=t.uid;i&&i[n]&&delete i[n],e()}}class d{loadTile(e,i){const{uid:n,encoding:r,rawImageData:o,padding:s}=e,a=ImageBitmap&&o instanceof ImageBitmap?this.getImageData(o,s):o;i(null,new t.dX(n,a,r,s{n(null,t)}),(t=>{n(t)}))}}const h=t.dZ.prototype.toGeoJSON;let p=class{constructor(e){this._feature=e,this.extent=t.a3,this.type=e.type,this.properties=e.tags,"id"in e&&!isNaN(e.id)&&(this.id=parseInt(e.id,10))}loadGeometry(){if(1===this._feature.type){const e=[];for(const i of this._feature.geometry)e.push([new t.P(i[0],i[1])]);return e}{const e=[];for(const i of this._feature.geometry){const n=[];for(const e of i)n.push(new t.P(e[0],e[1]));e.push(n)}return e}}toGeoJSON(t,e,i){return h.call(this,t,e,i)}},f=class{constructor(e){this.layers={_geojsonTileLayer:this},this.name="_geojsonTileLayer",this.extent=t.a3,this.length=e.length,this._features=e}feature(t){return new p(this._features[t])}};const m=64/4096;class _{constructor(){this.features=new Map}clear(){this.features.clear()}load(t=[],e){for(const i of t){const t=i.id;if(null==t)continue;let n=this.features.get(t);n&&this.updateCache(n,e),i.geometry?(n=y(i),this.updateCache(n,e),this.features.set(t,n)):this.features.delete(t),this.updateCache(n,e)}}updateCache(t,e){for(const{canonical:i,uid:n}of Object.values(e)){const{z:r,x:o,y:s}=i;g(t,Math.pow(2,r),o,s)&&delete e[n]}}getTile(t,e,i){const n=Math.pow(2,t),r=[];for(const t of this.features.values())g(t,n,e,i)&&r.push(w(t,n,e,i));return{features:r}}getFeatures(){return[...this.features.values()]}}function g({minX:t,minY:e,maxX:i,maxY:n},r,o,s){return t(o-m)/r&&n>(s-m)/r}function y(t){const{id:e,geometry:i,properties:n}=t;if(!i)return;if("GeometryCollection"===i.type)throw new Error("GeometryCollection not supported in dynamic mode.");const{type:r,coordinates:o}=i,s={id:e,type:1,geometry:[],tags:n,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0},a=s.geometry;if("Point"===r)v(o,a,s);else if("MultiPoint"===r)for(const t of o)v(t,a,s);else if("LineString"===r)s.type=2,x(o,a,s);else if("MultiLineString"===r)s.type=2,b(o,a,s);else if("Polygon"===r)s.type=3,b(o,a,s,!0);else{if("MultiPolygon"!==r)throw new Error("Input data is not a valid GeoJSON object.");s.type=3;for(const t of o)b(t,a,s,!0)}return s}function v([e,i],n,r){const o=t.aj(e);let s=t.ak(i);s=s1?1:s,n.push(o,s),r.minX=Math.min(r.minX,o),r.minY=Math.min(r.minY,s),r.maxX=Math.max(r.maxX,o),r.maxY=Math.max(r.maxY,s)}function x(t,e,i,n=!1,r=!1){const o=[];for(const e of t)v(e,o,i);e.push(o),n&&function(t,e){let i=0;for(let e=0,n=t.length,r=n-2;e0===e)for(let e=0,i=t.length;e>31}function F(t,e){for(var i=t.loadGeometry(),n=t.type,r=0,o=0,s=i.length,a=0;at},V=Math.fround||(G=new Float32Array(1),t=>(G[0]=+t,G[0]));var G;const Z=3,q=5,H=6;class W{constructor(t){this.options=Object.assign(Object.create(j),t),this.trees=new Array(this.options.maxZoom+1),this.stride=this.options.reduce?7:6,this.clusterProps=[]}load(t){const{log:e,minZoom:i,maxZoom:n}=this.options;e&&console.time("total time");const r=`prepare ${t.length} points`;e&&console.time(r),this.points=t;const o=[];for(let e=0;e=i;t--){const i=+Date.now();s=this.trees[t]=this._createTree(this._cluster(s,t)),e&&console.log("z%d: %d clusters in %dms",t,s.numItems,+Date.now()-i)}return e&&console.timeEnd("total time"),this}getClusters(t,e){let i=((t[0]+180)%360+360)%360-180;const n=Math.max(-90,Math.min(90,t[1]));let r=180===t[2]?180:((t[2]+180)%360+360)%360-180;const o=Math.max(-90,Math.min(90,t[3]));if(t[2]-t[0]>=360)i=-180,r=180;else if(i>r){const t=this.getClusters([i,n,180,o],e),s=this.getClusters([-180,n,r,o],e);return t.concat(s)}const s=this.trees[this._limitZoom(e)],a=s.range(K(i),J(o),K(r),J(n)),l=s.data,c=[];for(const t of a){const e=this.stride*t;c.push(l[e+q]>1?Y(l,e,this.clusterProps):this.points[l[e+Z]])}return c}getChildren(t){const e=this._getOriginId(t),i=this._getOriginZoom(t),n="No cluster with the specified id.",r=this.trees[i];if(!r)throw new Error(n);const o=r.data;if(e*this.stride>=o.length)throw new Error(n);const s=this.options.radius/(this.options.extent*Math.pow(2,i-1)),a=r.within(o[e*this.stride],o[e*this.stride+1],s),l=[];for(const e of a){const i=e*this.stride;o[i+4]===t&&l.push(o[i+q]>1?Y(o,i,this.clusterProps):this.points[o[i+Z]])}if(0===l.length)throw new Error(n);return l}getLeaves(t,e,i){const n=[];return this._appendLeaves(n,t,e=e||10,i=i||0,0),n}getTile(t,e,i){const n=this.trees[this._limitZoom(t)],r=Math.pow(2,t),{extent:o,radius:s}=this.options,a=s/o,l=(i-a)/r,c=(i+1+a)/r,d={features:[]};return this._addTileFeatures(n.range((e-a)/r,l,(e+1+a)/r,c),n.data,e,i,r,d),0===e&&this._addTileFeatures(n.range(1-a/r,l,1,c),n.data,r,i,r,d),e===r-1&&this._addTileFeatures(n.range(0,l,a/r,c),n.data,-1,i,r,d),d.features.length?d:null}getClusterExpansionZoom(t){let e=this._getOriginZoom(t)-1;for(;e1;let l,c,d;if(a)l=X(e,t,this.clusterProps),c=e[t],d=e[t+1];else{const i=this.points[e[t+Z]];l=i.properties;const[n,r]=i.geometry.coordinates;c=K(n),d=J(r)}const u={type:1,geometry:[[Math.round(this.options.extent*(c*r-i)),Math.round(this.options.extent*(d*r-n))]],tags:l};let h;h=a||this.options.generateId?e[t+Z]:this.points[e[t+Z]].id,void 0!==h&&(u.id=h),o.features.push(u)}}_limitZoom(t){return Math.max(this.options.minZoom,Math.min(Math.floor(+t),this.options.maxZoom+1))}_cluster(t,e){const{radius:i,extent:n,reduce:r,minPoints:o}=this.options,s=i/(n*Math.pow(2,e)),a=t.data,l=[],c=this.stride;for(let i=0;ie&&(p+=a[i+q])}if(p>h&&p>=o){let t,o=n*h,s=d*h,f=-1;const m=(i/c1)for(const t of u){const i=t*c;if(!(a[i+2]>5}_getOriginZoom(t){return(t-this.points.length)%32}_map(t,e,i){if(t[e+q]>1){const n=this.clusterProps[t[e+H]];return i?Object.assign({},n):n}const n=this.points[t[e+Z]].properties,r=this.options.map(n);return i&&r===n?Object.assign({},r):r}}function Y(t,e,i){return{type:"Feature",id:t[e+Z],properties:X(t,e,i),geometry:{type:"Point",coordinates:[(n=t[e],360*(n-.5)),Q(t[e+1])]}};var n}function X(t,e,i){const n=t[e+q],r=n>=1e4?`${Math.round(n/1e3)}k`:n>=1e3?Math.round(n/100)/10+"k":n,o=t[e+H],s=-1===o?{}:Object.assign({},i[o]);return Object.assign(s,{cluster:!0,cluster_id:t[e+Z],point_count:n,point_count_abbreviated:r})}function K(t){return t/360+.5}function J(t){const e=Math.sin(t*Math.PI/180),i=.5-.25*Math.log((1+e)/(1-e))/Math.PI;return i1?1:i}function Q(t){const e=(180-360*t)*Math.PI/180;return 360*Math.atan(Math.exp(e))/Math.PI-90}function tt(t,e,i,n){let r=n;const o=e+(i-e>>1);let s,a=i-e;const l=t[e],c=t[e+1],d=t[i],u=t[i+1];for(let n=e+3;n >31}function F(t,e){for(var i=t.loadGeometry(),n=t.type,r=0,o=0,s=i.length,a=0;at},V=Math.fround||(G=new Float32Array(1),t=>(G[0]=+t,G[0]));var G;const Z=3,q=5,H=6;class W{constructor(t){this.options=Object.assign(Object.create(j),t),this.trees=new Array(this.options.maxZoom+1),this.stride=this.options.reduce?7:6,this.clusterProps=[]}load(t){const{log:e,minZoom:i,maxZoom:n}=this.options;e&&console.time("total time");const r=`prepare ${t.length} points`;e&&console.time(r),this.points=t;const o=[];for(let e=0;e=i;t--){const i=+Date.now();s=this.trees[t]=this._createTree(this._cluster(s,t)),e&&console.log("z%d: %d clusters in %dms",t,s.numItems,+Date.now()-i)}return e&&console.timeEnd("total time"),this}getClusters(t,e){let i=((t[0]+180)%360+360)%360-180;const n=Math.max(-90,Math.min(90,t[1]));let r=180===t[2]?180:((t[2]+180)%360+360)%360-180;const o=Math.max(-90,Math.min(90,t[3]));if(t[2]-t[0]>=360)i=-180,r=180;else if(i>r){const t=this.getClusters([i,n,180,o],e),s=this.getClusters([-180,n,r,o],e);return t.concat(s)}const s=this.trees[this._limitZoom(e)],a=s.range(K(i),J(o),K(r),J(n)),l=s.data,c=[];for(const t of a){const e=this.stride*t;c.push(l[e+q]>1?Y(l,e,this.clusterProps):this.points[l[e+Z]])}return c}getChildren(t){const e=this._getOriginId(t),i=this._getOriginZoom(t),n="No cluster with the specified id.",r=this.trees[i];if(!r)throw new Error(n);const o=r.data;if(e*this.stride>=o.length)throw new Error(n);const s=this.options.radius/(this.options.extent*Math.pow(2,i-1)),a=r.within(o[e*this.stride],o[e*this.stride+1],s),l=[];for(const e of a){const i=e*this.stride;o[i+4]===t&&l.push(o[i+q]>1?Y(o,i,this.clusterProps):this.points[o[i+Z]])}if(0===l.length)throw new Error(n);return l}getLeaves(t,e,i){const n=[];return this._appendLeaves(n,t,e=e||10,i=i||0,0),n}getTile(t,e,i){const n=this.trees[this._limitZoom(t)],r=Math.pow(2,t),{extent:o,radius:s}=this.options,a=s/o,l=(i-a)/r,c=(i+1+a)/r,d={features:[]};return this._addTileFeatures(n.range((e-a)/r,l,(e+1+a)/r,c),n.data,e,i,r,d),0===e&&this._addTileFeatures(n.range(1-a/r,l,1,c),n.data,r,i,r,d),e===r-1&&this._addTileFeatures(n.range(0,l,a/r,c),n.data,-1,i,r,d),d.features.length?d:null}getClusterExpansionZoom(t){let e=this._getOriginZoom(t)-1;for(;e1;let l,c,d;if(a)l=X(e,t,this.clusterProps),c=e[t],d=e[t+1];else{const i=this.points[e[t+Z]];l=i.properties;const[n,r]=i.geometry.coordinates;c=K(n),d=J(r)}const u={type:1,geometry:[[Math.round(this.options.extent*(c*r-i)),Math.round(this.options.extent*(d*r-n))]],tags:l};let h;h=a||this.options.generateId?e[t+Z]:this.points[e[t+Z]].id,void 0!==h&&(u.id=h),o.features.push(u)}}_limitZoom(t){return Math.max(this.options.minZoom,Math.min(Math.floor(+t),this.options.maxZoom+1))}_cluster(t,e){const{radius:i,extent:n,reduce:r,minPoints:o}=this.options,s=i/(n*Math.pow(2,e)),a=t.data,l=[],c=this.stride;for(let i=0;ie&&(p+=a[i+q])}if(p>h&&p>=o){let t,o=n*h,s=d*h,f=-1;const m=(i/c1)for(const t of u){const i=t*c;if(!(a[i+2]>5}_getOriginZoom(t){return(t-this.points.length)%32}_map(t,e,i){if(t[e+q]>1){const n=this.clusterProps[t[e+H]];return i?Object.assign({},n):n}const n=this.points[t[e+Z]].properties,r=this.options.map(n);return i&&r===n?Object.assign({},r):r}}function Y(t,e,i){return{type:"Feature",id:t[e+Z],properties:X(t,e,i),geometry:{type:"Point",coordinates:[(n=t[e],360*(n-.5)),Q(t[e+1])]}};var n}function X(t,e,i){const n=t[e+q],r=n>=1e4?`${Math.round(n/1e3)}k`:n>=1e3?Math.round(n/100)/10+"k":n,o=t[e+H],s=-1===o?{}:Object.assign({},i[o]);return Object.assign(s,{cluster:!0,cluster_id:t[e+Z],point_count:n,point_count_abbreviated:r})}function K(t){return t/360+.5}function J(t){const e=Math.sin(t*Math.PI/180),i=.5-.25*Math.log((1+e)/(1-e))/Math.PI;return i1?1:i}function Q(t){const e=(180-360*t)*Math.PI/180;return 360*Math.atan(Math.exp(e))/Math.PI-90}function tt(t,e,i,n){let r=n;const o=e+(i-e>>1);let s,a=i-e;const l=t[e],c=t[e+1],d=t[i],u=t[i+1];for(let n=e+3;n
| <STRONG> (7) | Kto i jak przetwarza Twoje dane? Odbiorcy danych: Kontakt: Okres przechowywania: Pouczenie o prawach: Prawo do skargi: Prawo do sprzeciwu:
|
HTML headings and emphasis tags are the most basic forms to indicate important content.
Tips:
1. use your keywords in the headings and make sure the first level heading (<H1>) includes the most important keywords.
2. never duplicate the title tag content in the heading tags.
3. for more effective SEO, use only one <H1> tag per page |