diff --git a/app/javascript/maplibre/map.js b/app/javascript/maplibre/map.js index 609dd568..a34043fd 100644 --- a/app/javascript/maplibre/map.js +++ b/app/javascript/maplibre/map.js @@ -95,23 +95,6 @@ export async function initializeMap (divId = 'maplibre-map') { if (!!mapProperties.description?.trim()) { dom.showElements('#description-modal') } - // after basemap style is ready/changed, init source layers + - // load geojson data - map.on('style.load', () => { - console.log('Basemap style loaded (style.load)') - addGeoJSONSource('geojson-source', false) - addGeoJSONSource('km-marker-source', false) - loadLayers() - demSource.setupMaplibre(maplibregl) - if (mapProperties.terrain) { addTerrain() } - if (mapProperties.hillshade) { addHillshade() } - if (mapProperties.globe) { addGlobe() } - if (mapProperties.contours) { addContours() } - initializeViewStyles('geojson-source') - // initializeMapStyles('geojson-source') - initializeKmMarkerStyles() - }) - map.on('styleimagemissing', loadImage) map.on('geojson.load', (_e) => { @@ -120,9 +103,6 @@ export async function initializeMap (divId = 'maplibre-map') { // NOTE: map 'load' can happen before 'geojson.load' when loading features is slow map.once('load', async function (_e) { - // on first map load, re-sort layers late, when all map, - // view + edit layers are added - sortLayers() // trigger map fade-in dom.animateElement('.map', 'fade-in', 250) initCtrlTooltips() @@ -494,6 +474,22 @@ export function destroyFeature (featureId) { } } +// after basemap style is ready/changed, init source layers + +// load geojson data +function initializeStyles() { + console.log('Initializing sources and layer styles after basemap load/change') + addGeoJSONSource('geojson-source', false) + addGeoJSONSource('km-marker-source', false) + loadLayers() + demSource.setupMaplibre(maplibregl) + if (mapProperties.terrain) { addTerrain() } + if (mapProperties.hillshade) { addHillshade() } + if (mapProperties.globe) { addGlobe() } + if (mapProperties.contours) { addContours() } + initializeViewStyles('geojson-source') + initializeKmMarkerStyles() +} + export function setBackgroundMapLayer (mapName = mapProperties.base_map, force = false) { if (backgroundMapLayer === mapName && backgroundTerrain === mapProperties.terrain && @@ -504,6 +500,7 @@ export function setBackgroundMapLayer (mapName = mapProperties.base_map, force = if (basemap) { map.once('style.load', () => { status('Loaded base map ' + mapName) + initializeStyles() // re-sort layers after basemap style change sortLayers() }) @@ -513,10 +510,7 @@ export function setBackgroundMapLayer (mapName = mapProperties.base_map, force = backgroundContours = mapProperties.contours backgroundGlobe = mapProperties.globe setStyleDefaultFont(basemap.font || defaultFont) - map.setStyle(basemap.style, - // adding 'diff: false' so that 'style.load' gets triggered (https://github.com/maplibre/maplibre-gl-js/issues/2587) - // which will trigger loadLayers() - { diff: false, strictMode: true }) + map.setStyle(basemap.style, { diff: true, strictMode: true }) } else { console.error('Base map ' + mapName + ' not available!') } @@ -540,7 +534,7 @@ export function sortLayers () { layer.paint['fill-extrusion-opacity'] = 0.8 }) - // console.log('Sorting layers', layers) + console.log('Sorting layers', layers) const editLayer = functions.reduceArray(layers, (e) => (e.id.startsWith('gl-draw-'))) const userSymbols = functions.reduceArray(layers, (e) => (e.id.startsWith('symbols-layer') || e.id.startsWith('symbols-border-layer'))) const userLabels = functions.reduceArray(layers, (e) => e.id.startsWith('text-layer') || e.id.startsWith('cluster_labels')) diff --git a/app/javascript/maplibre/overpass/overpass.js b/app/javascript/maplibre/overpass/overpass.js index abf22cc1..8beb573d 100644 --- a/app/javascript/maplibre/overpass/overpass.js +++ b/app/javascript/maplibre/overpass/overpass.js @@ -30,7 +30,7 @@ export function initializeOverpassLayers(id = null) { loadOverpassLayer(layer.id).then(() => { if (id) { initLayersModal() } }) } }) - sortLayers() + if (initLayers.length) { sortLayers() } } export function loadOverpassLayer(id) { diff --git a/config/importmap.rb b/config/importmap.rb index ea7ae7a8..bd3d53d5 100644 --- a/config/importmap.rb +++ b/config/importmap.rb @@ -27,7 +27,7 @@ under: "mapbox-gl-draw-paint-mode", preload: false # https://github.com/maplibre/maplibre-gl-js -pin "maplibre-gl", preload: false # @5.15.0 +pin "maplibre-gl", preload: false # @5.16.0 # https://github.com/maplibre/maplibre-gl-geocoder pin "maplibre-gl-geocoder", to: "maplibre-gl-geocoder.js", preload: false # https://github.com/GIScience/openrouteservice-js?tab=readme-ov-file diff --git a/vendor/javascript/maplibre-gl.js b/vendor/javascript/maplibre-gl.js index e7081da8..641e5c9f 100644 --- a/vendor/javascript/maplibre-gl.js +++ b/vendor/javascript/maplibre-gl.js @@ -1,6 +1,6 @@ var e=typeof globalThis!=="undefined"?globalThis:typeof self!=="undefined"?self:global;var s={}; /** * MapLibre GL JS - * @license 3-Clause BSD. Full text of license: https://github.com/maplibre/maplibre-gl-js/blob/v5.15.0/LICENSE.txt - */(function(e,l){s=l()})(0,(function(){var s={};var l={};function c(e,c,d){l[e]=d;if(e==="index"){var p="var sharedModule = {}; ("+l.shared+")(sharedModule); ("+l.worker+")(sharedModule);";var f={};l.shared(f);l.index(s,f);typeof window!=="undefined"&&s.setWorkerUrl(window.URL.createObjectURL(new Blob([p],{type:"text/javascript"})));return s}}c("shared",["exports"],(function(s){function l(e,s,l,c){return new(l||(l=Promise))((function(d,p){function f(e){try{_(c.next(e))}catch(e){p(e)}}function m(e){try{_(c.throw(e))}catch(e){p(e)}}function _(e){var s;e.done?d(e.value):(s=e.value,s instanceof l?s:new l((function(e){e(s)}))).then(f,m)}_((c=c.apply(e,s||[])).next())}))}function c(s,l){(this||e).x=s,(this||e).y=l}function d(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var p,f;"function"==typeof SuppressedError&&SuppressedError,c.prototype={clone(){return new c((this||e).x,(this||e).y)},add(e){return this.clone()._add(e)},sub(e){return this.clone()._sub(e)},multByPoint(e){return this.clone()._multByPoint(e)},divByPoint(e){return this.clone()._divByPoint(e)},mult(e){return this.clone()._mult(e)},div(e){return this.clone()._div(e)},rotate(e){return this.clone()._rotate(e)},rotateAround(e,s){return this.clone()._rotateAround(e,s)},matMult(e){return this.clone()._matMult(e)},unit(){return this.clone()._unit()},perp(){return this.clone()._perp()},round(){return this.clone()._round()},mag(){return Math.sqrt((this||e).x*(this||e).x+(this||e).y*(this||e).y)},equals(s){return(this||e).x===s.x&&(this||e).y===s.y},dist(e){return Math.sqrt(this.distSqr(e))},distSqr(s){const l=s.x-(this||e).x,c=s.y-(this||e).y;return l*l+c*c},angle(){return Math.atan2((this||e).y,(this||e).x)},angleTo(s){return Math.atan2((this||e).y-s.y,(this||e).x-s.x)},angleWith(e){return this.angleWithSep(e.x,e.y)},angleWithSep(s,l){return Math.atan2((this||e).x*l-(this||e).y*s,(this||e).x*s+(this||e).y*l)},_matMult(s){const l=s[2]*(this||e).x+s[3]*(this||e).y;return(this||e).x=s[0]*(this||e).x+s[1]*(this||e).y,(this||e).y=l,this||e},_add(s){return(this||e).x+=s.x,(this||e).y+=s.y,this||e},_sub(s){return(this||e).x-=s.x,(this||e).y-=s.y,this||e},_mult(s){return(this||e).x*=s,(this||e).y*=s,this||e},_div(s){return(this||e).x/=s,(this||e).y/=s,this||e},_multByPoint(s){return(this||e).x*=s.x,(this||e).y*=s.y,this||e},_divByPoint(s){return(this||e).x/=s.x,(this||e).y/=s.y,this||e},_unit(){return this._div(this.mag()),this||e},_perp(){const s=(this||e).y;return(this||e).y=(this||e).x,(this||e).x=-s,this||e},_rotate(s){const l=Math.cos(s),c=Math.sin(s),d=c*(this||e).x+l*(this||e).y;return(this||e).x=l*(this||e).x-c*(this||e).y,(this||e).y=d,this||e},_rotateAround(s,l){const c=Math.cos(s),d=Math.sin(s),p=l.y+d*((this||e).x-l.x)+c*((this||e).y-l.y);return(this||e).x=l.x+c*((this||e).x-l.x)-d*((this||e).y-l.y),(this||e).y=p,this||e},_round(){return(this||e).x=Math.round((this||e).x),(this||e).y=Math.round((this||e).y),this||e},constructor:c},c.convert=function(e){if(e instanceof c)return e;if(Array.isArray(e))return new c(+e[0],+e[1]);if(void 0!==e.x&&void 0!==e.y)return new c(+e.x,+e.y);throw new Error("Expected [x, y] or {x, y} point format")};var m=function(){if(f)return p;function s(s,l,c,d){(this||e).cx=3*s,(this||e).bx=3*(c-s)-(this||e).cx,(this||e).ax=1-(this||e).cx-(this||e).bx,(this||e).cy=3*l,(this||e).by=3*(d-l)-(this||e).cy,(this||e).ay=1-(this||e).cy-(this||e).by,(this||e).p1x=s,(this||e).p1y=l,(this||e).p2x=c,(this||e).p2y=d}return f=1,p=s,s.prototype={sampleCurveX:function(s){return(((this||e).ax*s+(this||e).bx)*s+(this||e).cx)*s},sampleCurveY:function(s){return(((this||e).ay*s+(this||e).by)*s+(this||e).cy)*s},sampleCurveDerivativeX:function(s){return(3*(this||e).ax*s+2*(this||e).bx)*s+(this||e).cx},solveCurveX:function(e,s){if(void 0===s&&(s=1e-6),e<0)return 0;if(e>1)return 1;for(var l=e,c=0;c<8;c++){var d=this.sampleCurveX(l)-e;if(Math.abs(d)d?f=l:m=l,l=.5*(m-f)+f;return l},solve:function(e,s){return this.sampleCurveY(this.solveCurveX(e,s))}},p}(),_=d(m);let g,y;function b(){return null==g&&(g="undefined"!=typeof OffscreenCanvas&&new OffscreenCanvas(1,1).getContext("2d")&&"function"==typeof createImageBitmap),g}function T(){if(null==y&&(y=!1,b())){const e=5,s=new OffscreenCanvas(e,e).getContext("2d",{willReadFrequently:!0});if(s){for(let l=0;l4&&void 0!==arguments[4]?arguments[4]:"zyx",p=Math.PI/360;s*=p,c*=p,l*=p;var f=Math.sin(s),m=Math.cos(s),_=Math.sin(l),g=Math.cos(l),y=Math.sin(c),b=Math.cos(c);switch(d){case"xyz":e[0]=f*g*b+m*_*y,e[1]=m*_*b-f*g*y,e[2]=m*g*y+f*_*b,e[3]=m*g*b-f*_*y;break;case"xzy":e[0]=f*g*b-m*_*y,e[1]=m*_*b-f*g*y,e[2]=m*g*y+f*_*b,e[3]=m*g*b+f*_*y;break;case"yxz":e[0]=f*g*b+m*_*y,e[1]=m*_*b-f*g*y,e[2]=m*g*y-f*_*b,e[3]=m*g*b+f*_*y;break;case"yzx":e[0]=f*g*b+m*_*y,e[1]=m*_*b+f*g*y,e[2]=m*g*y-f*_*b,e[3]=m*g*b-f*_*y;break;case"zxy":e[0]=f*g*b-m*_*y,e[1]=m*_*b+f*g*y,e[2]=m*g*y+f*_*b,e[3]=m*g*b-f*_*y;break;case"zyx":e[0]=f*g*b-m*_*y,e[1]=m*_*b+f*g*y,e[2]=m*g*y-f*_*b,e[3]=m*g*b+f*_*y;break;default:throw new Error("Unknown angle order "+d)}return e}function J(){var e=new S(2);return S!=Float32Array&&(e[0]=0,e[1]=0),e}function re(e,s){var l=new S(2);return l[0]=e,l[1]=s,l}z(),G=new S(4),S!=Float32Array&&(G[0]=0,G[1]=0,G[2]=0,G[3]=0),z(),F(1,0,0),F(0,1,0),Z(),Z(),I(),J();const se=8192;function oe(e,s,l){return s*(se/(e.tileSize*Math.pow(2,l-e.tileID.overscaledZ)))}function le(e,s){return(e%s+s)%s}function ce(e,s,l){return e*(1-l)+s*l}function he(e){if(e<=0)return 0;if(e>=1)return 1;const s=e*e,l=s*e;return 4*(e<.5?l:3*(e-s)+l-.75)}function ue(e,s,l,c){const d=new _(e,s,l,c);return e=>d.solve(e)}const pe=ue(.25,.1,.25,1);function fe(e,s,l){return Math.min(l,Math.max(s,e))}function me(e,s,l){const c=l-s,d=((e-s)%c+c)%c+s;return d===s?l:d}function ge(e,...s){for(const l of s)for(const s in l)e[s]=l[s];return e}let ye=1;function xe(s,l,c){const d={};for(const c in s)d[c]=l.call(this||e,s[c],c,s);return d}function ve(s,l,c){const d={};for(const c in s)l.call(this||e,s[c],c,s)&&(d[c]=s[c]);return d}function be(e){return Array.isArray(e)?e.map(be):"object"==typeof e&&e?xe(e,be):e}const we={};function Se(e){we[e]||("undefined"!=typeof console&&console.warn(e),we[e]=!0)}function Me(e,s,l){return(l.y-e.y)*(s.x-e.x)>(s.y-e.y)*(l.x-e.x)}function Ee(e){return"undefined"!=typeof WorkerGlobalScope&&void 0!==e&&e instanceof WorkerGlobalScope}let Ce=null;function Ae(e){return"undefined"!=typeof ImageBitmap&&e instanceof ImageBitmap}const Ne="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAC0lEQVQYV2NgAAIAAAUAAarVyFEAAAAASUVORK5CYII=";function Ge(s,c,d,p,f){return l(this||e,void 0,void 0,(function*(){if("undefined"==typeof VideoFrame)throw new Error("VideoFrame not supported");const e=new VideoFrame(s,{timestamp:0});try{const l=null==e?void 0:e.format;if(!l||!l.startsWith("BGR")&&!l.startsWith("RGB"))throw new Error(`Unrecognized format ${l}`);const m=l.startsWith("BGR"),_=new Uint8ClampedArray(p*f*4);if(yield e.copyTo(_,function(e,s,l,c,d){const p=4*Math.max(-s,0),f=(Math.max(0,l)-l)*c*4+p,m=4*c,_=Math.max(0,s),g=Math.max(0,l);return{rect:{x:_,y:g,width:Math.min(e.width,s+c)-_,height:Math.min(e.height,l+d)-g},layout:[{offset:f,stride:m}]}}(s,c,d,p,f)),m)for(let e=0;e<_.length;e+=4){const s=_[e];_[e]=_[e+2],_[e+2]=s}return _}finally{e.close()}}))}let Ue,qe;function $e(e,s,l,c){return e.addEventListener(s,l,c),{unsubscribe:()=>{e.removeEventListener(s,l,c)}}}function He(e){return e*Math.PI/180}function Ye(e){return e/Math.PI*180}const et={touchstart:!0,touchmove:!0,touchmoveWindow:!0,touchend:!0,touchcancel:!0},tt={dblclick:!0,click:!0,mouseover:!0,mouseout:!0,mousedown:!0,mousemove:!0,mousemoveWindow:!0,mouseup:!0,mouseupWindow:!0,contextmenu:!0,wheel:!0},it="AbortError";class st extends Error{constructor(e=it){super(e instanceof Error?e.message:e),this.name=it,e instanceof Error&&e.stack&&(this.stack=e.stack)}}function rt(e){return e.name===it}const ot={MAX_PARALLEL_IMAGE_REQUESTS:16,MAX_PARALLEL_IMAGE_REQUESTS_PER_FRAME:8,MAX_TILE_CACHE_ZOOM_LEVELS:5,REGISTERED_PROTOCOLS:{},WORKER_URL:""};function at(e){return ot.REGISTERED_PROTOCOLS[e.substring(0,e.indexOf("://"))]}const ft="global-dispatcher";class ct extends Error{constructor(e,s,l,c){super(`AJAXError: ${s} (${e}): ${l}`),this.status=e,this.statusText=s,this.url=l,this.body=c}}const _t=()=>Ee(self)?self.worker&&self.worker.referrer:("blob:"===window.location.protocol?window.parent:window).location.href,yt=function(s,c){if(/:\/\//.test(s.url)&&!/^https?:|^file:/.test(s.url)){const e=at(s.url);if(e)return e(s,c);if(Ee(self)&&self.worker&&self.worker.actor)return self.worker.actor.sendAsync({type:"GR",data:s,targetMapId:ft},c)}if(!(/^file:/.test(d=s.url)||/^file:/.test(_t())&&!/^\w+:/.test(d))){if(fetch&&Request&&AbortController&&Object.prototype.hasOwnProperty.call(Request.prototype,"signal"))return function(s,c){return l(this||e,void 0,void 0,(function*(){const e=new Request(s.url,{method:s.method||"GET",body:s.body,credentials:s.credentials,headers:s.headers,cache:s.cache,referrer:_t(),signal:c.signal});let l,d;"json"!==s.type||e.headers.has("Accept")||e.headers.set("Accept","application/json");try{l=yield fetch(e)}catch(e){if(rt(e))throw e;throw new ct(0,e.message,s.url,new Blob)}if(!l.ok){const e=yield l.blob();throw new ct(l.status,l.statusText,s.url,e)}d="arrayBuffer"===s.type||"image"===s.type?l.arrayBuffer():"json"===s.type?l.json():l.text();const p=yield d;return c.signal.throwIfAborted(),{data:p,cacheControl:l.headers.get("Cache-Control"),expires:l.headers.get("Expires")}}))}(s,c);if(Ee(self)&&self.worker&&self.worker.actor)return self.worker.actor.sendAsync({type:"GR",data:s,mustQueue:!0,targetMapId:ft},c)}var d;return function(e,s){return new Promise(((l,c)=>{var d;const p=new XMLHttpRequest;p.open(e.method||"GET",e.url,!0),"arrayBuffer"!==e.type&&"image"!==e.type||(p.responseType="arraybuffer");for(const s in e.headers)p.setRequestHeader(s,e.headers[s]);"json"===e.type&&(p.responseType="text",(null===(d=e.headers)||void 0===d?void 0:d.Accept)||p.setRequestHeader("Accept","application/json")),p.withCredentials="include"===e.credentials,p.onerror=()=>{c(new Error(p.statusText))},p.onload=()=>{if(!s.signal.aborted)if((p.status>=200&&p.status<300||0===p.status)&&null!==p.response){let s=p.response;if("json"===e.type)try{s=JSON.parse(p.response)}catch(e){return void c(e)}l({data:s,cacheControl:p.getResponseHeader("Cache-Control"),expires:p.getResponseHeader("Expires")})}else{const s=new Blob([p.response],{type:p.getResponseHeader("Content-Type")});c(new ct(p.status,p.statusText,e.url,s))}},s.signal.addEventListener("abort",(()=>{p.abort(),c(new st(s.signal.reason))})),p.send(e.body)}))}(s,c)};function vt(e){if(!e||e.indexOf("://")<=0||0===e.indexOf("data:image/")||0===e.indexOf("blob:"))return!0;const s=new URL(e),l=window.location;return s.protocol===l.protocol&&s.host===l.host}function bt(e,s,l){l[e]&&-1!==l[e].indexOf(s)||(l[e]=l[e]||[],l[e].push(s))}function wt(e,s,l){if(l&&l[e]){const c=l[e].indexOf(s);-1!==c&&l[e].splice(c,1)}}class mt{constructor(e,s={}){ge(this,s),this.type=e}}class gt extends mt{constructor(e,s={}){super("error",ge({error:e},s))}}class xt{on(e,s){return this._listeners=this._listeners||{},bt(e,s,this._listeners),{unsubscribe:()=>{this.off(e,s)}}}off(e,s){return wt(e,s,this._listeners),wt(e,s,this._oneTimeListeners),this}once(e,s){return s?(this._oneTimeListeners=this._oneTimeListeners||{},bt(e,s,this._oneTimeListeners),this):new Promise((s=>this.once(e,s)))}fire(e,s){"string"==typeof e&&(e=new mt(e,s||{}));const l=e.type;if(this.listens(l)){e.target=this;const s=this._listeners&&this._listeners[l]?this._listeners[l].slice():[];for(const l of s)l.call(this,e);const c=this._oneTimeListeners&&this._oneTimeListeners[l]?this._oneTimeListeners[l].slice():[];for(const s of c)wt(l,s,this._oneTimeListeners),s.call(this,e);const d=this._eventedParent;d&&(ge(e,"function"==typeof this._eventedParentData?this._eventedParentData():this._eventedParentData),d.fire(e))}else e instanceof gt&&console.error(e.error);return this}listens(e){return this._listeners&&this._listeners[e]&&this._listeners[e].length>0||this._oneTimeListeners&&this._oneTimeListeners[e]&&this._oneTimeListeners[e].length>0||this._eventedParent&&this._eventedParent.listens(e)}setEventedParent(e,s){return this._eventedParent=e,this._eventedParentData=s,this}}var Tt={$version:8,$root:{version:{required:!0,type:"enum",values:[8]},name:{type:"string"},metadata:{type:"*"},center:{type:"array",value:"number",length:2},centerAltitude:{type:"number"},zoom:{type:"number"},bearing:{type:"number",default:0,period:360,units:"degrees"},pitch:{type:"number",default:0,units:"degrees"},roll:{type:"number",default:0,units:"degrees"},state:{type:"state",default:{}},light:{type:"light"},sky:{type:"sky"},projection:{type:"projection"},terrain:{type:"terrain"},sources:{required:!0,type:"sources"},sprite:{type:"sprite"},glyphs:{type:"string"},"font-faces":{type:"fontFaces"},transition:{type:"transition"},layers:{required:!0,type:"array",value:"layer"}},sources:{"*":{type:"source"}},source:["source_vector","source_raster","source_raster_dem","source_geojson","source_video","source_image"],source_vector:{type:{required:!0,type:"enum",values:{vector:{}}},url:{type:"string"},tiles:{type:"array",value:"string"},bounds:{type:"array",value:"number",length:4,default:[-180,-85.051129,180,85.051129]},scheme:{type:"enum",values:{xyz:{},tms:{}},default:"xyz"},minzoom:{type:"number",default:0},maxzoom:{type:"number",default:22},attribution:{type:"string"},promoteId:{type:"promoteId"},volatile:{type:"boolean",default:!1},encoding:{type:"enum",values:{mvt:{},mlt:{}},default:"mvt"},"*":{type:"*"}},source_raster:{type:{required:!0,type:"enum",values:{raster:{}}},url:{type:"string"},tiles:{type:"array",value:"string"},bounds:{type:"array",value:"number",length:4,default:[-180,-85.051129,180,85.051129]},minzoom:{type:"number",default:0},maxzoom:{type:"number",default:22},tileSize:{type:"number",default:512,units:"pixels"},scheme:{type:"enum",values:{xyz:{},tms:{}},default:"xyz"},attribution:{type:"string"},volatile:{type:"boolean",default:!1},"*":{type:"*"}},source_raster_dem:{type:{required:!0,type:"enum",values:{"raster-dem":{}}},url:{type:"string"},tiles:{type:"array",value:"string"},bounds:{type:"array",value:"number",length:4,default:[-180,-85.051129,180,85.051129]},minzoom:{type:"number",default:0},maxzoom:{type:"number",default:22},tileSize:{type:"number",default:512,units:"pixels"},attribution:{type:"string"},encoding:{type:"enum",values:{terrarium:{},mapbox:{},custom:{}},default:"mapbox"},redFactor:{type:"number",default:1},blueFactor:{type:"number",default:1},greenFactor:{type:"number",default:1},baseShift:{type:"number",default:0},volatile:{type:"boolean",default:!1},"*":{type:"*"}},source_geojson:{type:{required:!0,type:"enum",values:{geojson:{}}},data:{required:!0,type:"*"},maxzoom:{type:"number",default:18},attribution:{type:"string"},buffer:{type:"number",default:128,maximum:512,minimum:0},filter:{type:"filter"},tolerance:{type:"number",default:.375},cluster:{type:"boolean",default:!1},clusterRadius:{type:"number",default:50,minimum:0},clusterMaxZoom:{type:"number"},clusterMinPoints:{type:"number"},clusterProperties:{type:"*"},lineMetrics:{type:"boolean",default:!1},generateId:{type:"boolean",default:!1},promoteId:{type:"promoteId"}},source_video:{type:{required:!0,type:"enum",values:{video:{}}},urls:{required:!0,type:"array",value:"string"},coordinates:{required:!0,type:"array",length:4,value:{type:"array",length:2,value:"number"}}},source_image:{type:{required:!0,type:"enum",values:{image:{}}},url:{required:!0,type:"string"},coordinates:{required:!0,type:"array",length:4,value:{type:"array",length:2,value:"number"}}},layer:{id:{type:"string",required:!0},type:{type:"enum",values:{fill:{},line:{},symbol:{},circle:{},heatmap:{},"fill-extrusion":{},raster:{},hillshade:{},"color-relief":{},background:{}},required:!0},metadata:{type:"*"},source:{type:"string"},"source-layer":{type:"string"},minzoom:{type:"number",minimum:0,maximum:24},maxzoom:{type:"number",minimum:0,maximum:24},filter:{type:"filter"},layout:{type:"layout"},paint:{type:"paint"}},layout:["layout_fill","layout_line","layout_circle","layout_heatmap","layout_fill-extrusion","layout_symbol","layout_raster","layout_hillshade","layout_color-relief","layout_background"],layout_background:{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible",expression:{interpolated:!1,parameters:["global-state"]},"property-type":"data-constant"}},layout_fill:{"fill-sort-key":{type:"number",expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},visibility:{type:"enum",values:{visible:{},none:{}},default:"visible",expression:{interpolated:!1,parameters:["global-state"]},"property-type":"data-constant"}},layout_circle:{"circle-sort-key":{type:"number",expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},visibility:{type:"enum",values:{visible:{},none:{}},default:"visible",expression:{interpolated:!1,parameters:["global-state"]},"property-type":"data-constant"}},layout_heatmap:{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible",expression:{interpolated:!1,parameters:["global-state"]},"property-type":"data-constant"}},"layout_fill-extrusion":{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible",expression:{interpolated:!1,parameters:["global-state"]},"property-type":"data-constant"}},layout_line:{"line-cap":{type:"enum",values:{butt:{},round:{},square:{}},default:"butt",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"line-join":{type:"enum",values:{bevel:{},round:{},miter:{}},default:"miter",expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"line-miter-limit":{type:"number",default:2,requires:[{"line-join":"miter"}],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"line-round-limit":{type:"number",default:1.05,requires:[{"line-join":"round"}],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"line-sort-key":{type:"number",expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},visibility:{type:"enum",values:{visible:{},none:{}},default:"visible",expression:{interpolated:!1,parameters:["global-state"]},"property-type":"data-constant"}},layout_symbol:{"symbol-placement":{type:"enum",values:{point:{},line:{},"line-center":{}},default:"point",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"symbol-spacing":{type:"number",default:250,minimum:1,units:"pixels",requires:[{"symbol-placement":"line"}],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"symbol-avoid-edges":{type:"boolean",default:!1,expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"symbol-sort-key":{type:"number",expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"symbol-z-order":{type:"enum",values:{auto:{},"viewport-y":{},source:{}},default:"auto",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-allow-overlap":{type:"boolean",default:!1,requires:["icon-image",{"!":"icon-overlap"}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-overlap":{type:"enum",values:{never:{},always:{},cooperative:{}},requires:["icon-image"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-ignore-placement":{type:"boolean",default:!1,requires:["icon-image"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-optional":{type:"boolean",default:!1,requires:["icon-image","text-field"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-rotation-alignment":{type:"enum",values:{map:{},viewport:{},auto:{}},default:"auto",requires:["icon-image"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-size":{type:"number",default:1,minimum:0,units:"factor of the original icon size",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"icon-text-fit":{type:"enum",values:{none:{},width:{},height:{},both:{}},default:"none",requires:["icon-image","text-field"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-text-fit-padding":{type:"array",value:"number",length:4,default:[0,0,0,0],units:"pixels",requires:["icon-image","text-field",{"icon-text-fit":["both","width","height"]}],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"icon-image":{type:"resolvedImage",tokens:!0,expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"icon-rotate":{type:"number",default:0,period:360,units:"degrees",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"icon-padding":{type:"padding",default:[2],units:"pixels",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"icon-keep-upright":{type:"boolean",default:!1,requires:["icon-image",{"icon-rotation-alignment":"map"},{"symbol-placement":["line","line-center"]}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-offset":{type:"array",value:"number",length:2,default:[0,0],requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"icon-anchor":{type:"enum",values:{center:{},left:{},right:{},top:{},bottom:{},"top-left":{},"top-right":{},"bottom-left":{},"bottom-right":{}},default:"center",requires:["icon-image"],expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"icon-pitch-alignment":{type:"enum",values:{map:{},viewport:{},auto:{}},default:"auto",requires:["icon-image"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-pitch-alignment":{type:"enum",values:{map:{},viewport:{},auto:{}},default:"auto",requires:["text-field"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-rotation-alignment":{type:"enum",values:{map:{},viewport:{},"viewport-glyph":{},auto:{}},default:"auto",requires:["text-field"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-field":{type:"formatted",default:"",tokens:!0,expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-font":{type:"array",value:"string",default:["Open Sans Regular","Arial Unicode MS Regular"],requires:["text-field"],expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-size":{type:"number",default:16,minimum:0,units:"pixels",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-max-width":{type:"number",default:10,minimum:0,units:"ems",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-line-height":{type:"number",default:1.2,units:"ems",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"text-letter-spacing":{type:"number",default:0,units:"ems",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-justify":{type:"enum",values:{auto:{},left:{},center:{},right:{}},default:"center",requires:["text-field"],expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-radial-offset":{type:"number",units:"ems",default:0,requires:["text-field"],"property-type":"data-driven",expression:{interpolated:!0,parameters:["zoom","feature"]}},"text-variable-anchor":{type:"array",value:"enum",values:{center:{},left:{},right:{},top:{},bottom:{},"top-left":{},"top-right":{},"bottom-left":{},"bottom-right":{}},requires:["text-field",{"symbol-placement":["point"]}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-variable-anchor-offset":{type:"variableAnchorOffsetCollection",requires:["text-field",{"symbol-placement":["point"]}],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-anchor":{type:"enum",values:{center:{},left:{},right:{},top:{},bottom:{},"top-left":{},"top-right":{},"bottom-left":{},"bottom-right":{}},default:"center",requires:["text-field",{"!":"text-variable-anchor"}],expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-max-angle":{type:"number",default:45,units:"degrees",requires:["text-field",{"symbol-placement":["line","line-center"]}],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"text-writing-mode":{type:"array",value:"enum",values:{horizontal:{},vertical:{}},requires:["text-field",{"symbol-placement":["point"]}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-rotate":{type:"number",default:0,period:360,units:"degrees",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-padding":{type:"number",default:2,minimum:0,units:"pixels",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"text-keep-upright":{type:"boolean",default:!0,requires:["text-field",{"text-rotation-alignment":"map"},{"symbol-placement":["line","line-center"]}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-transform":{type:"enum",values:{none:{},uppercase:{},lowercase:{}},default:"none",requires:["text-field"],expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-offset":{type:"array",value:"number",units:"ems",length:2,default:[0,0],requires:["text-field",{"!":"text-radial-offset"}],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-allow-overlap":{type:"boolean",default:!1,requires:["text-field",{"!":"text-overlap"}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-overlap":{type:"enum",values:{never:{},always:{},cooperative:{}},requires:["text-field"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-ignore-placement":{type:"boolean",default:!1,requires:["text-field"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-optional":{type:"boolean",default:!1,requires:["text-field","icon-image"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},visibility:{type:"enum",values:{visible:{},none:{}},default:"visible",expression:{interpolated:!1,parameters:["global-state"]},"property-type":"data-constant"}},layout_raster:{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible",expression:{interpolated:!1,parameters:["global-state"]},"property-type":"data-constant"}},layout_hillshade:{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible",expression:{interpolated:!1,parameters:["global-state"]},"property-type":"data-constant"}},"layout_color-relief":{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible",expression:{interpolated:!1,parameters:["global-state"]},"property-type":"data-constant"}},filter:{type:"boolean",expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},filter_operator:{type:"enum",values:{"==":{},"!=":{},">":{},">=":{},"<":{},"<=":{},in:{},"!in":{},all:{},any:{},none:{},has:{},"!has":{}}},geometry_type:{type:"enum",values:{Point:{},LineString:{},Polygon:{}}},function:{expression:{type:"expression"},stops:{type:"array",value:"function_stop"},base:{type:"number",default:1,minimum:0},property:{type:"string",default:"$zoom"},type:{type:"enum",values:{identity:{},exponential:{},interval:{},categorical:{}},default:"exponential"},colorSpace:{type:"enum",values:{rgb:{},lab:{},hcl:{}},default:"rgb"},default:{type:"*",required:!1}},function_stop:{type:"array",minimum:0,maximum:24,value:["number","color"],length:2},expression:{type:"array",value:"expression_name",minimum:1},light:{anchor:{type:"enum",default:"viewport",values:{map:{},viewport:{}},"property-type":"data-constant",transition:!1,expression:{interpolated:!1,parameters:["zoom"]}},position:{type:"array",default:[1.15,210,30],length:3,value:"number","property-type":"data-constant",transition:!0,expression:{interpolated:!0,parameters:["zoom"]}},color:{type:"color","property-type":"data-constant",default:"#ffffff",expression:{interpolated:!0,parameters:["zoom"]},transition:!0},intensity:{type:"number","property-type":"data-constant",default:.5,minimum:0,maximum:1,expression:{interpolated:!0,parameters:["zoom"]},transition:!0}},sky:{"sky-color":{type:"color","property-type":"data-constant",default:"#88C6FC",expression:{interpolated:!0,parameters:["zoom"]},transition:!0},"horizon-color":{type:"color","property-type":"data-constant",default:"#ffffff",expression:{interpolated:!0,parameters:["zoom"]},transition:!0},"fog-color":{type:"color","property-type":"data-constant",default:"#ffffff",expression:{interpolated:!0,parameters:["zoom"]},transition:!0},"fog-ground-blend":{type:"number","property-type":"data-constant",default:.5,minimum:0,maximum:1,expression:{interpolated:!0,parameters:["zoom"]},transition:!0},"horizon-fog-blend":{type:"number","property-type":"data-constant",default:.8,minimum:0,maximum:1,expression:{interpolated:!0,parameters:["zoom"]},transition:!0},"sky-horizon-blend":{type:"number","property-type":"data-constant",default:.8,minimum:0,maximum:1,expression:{interpolated:!0,parameters:["zoom"]},transition:!0},"atmosphere-blend":{type:"number","property-type":"data-constant",default:.8,minimum:0,maximum:1,expression:{interpolated:!0,parameters:["zoom"]},transition:!0}},terrain:{source:{type:"string",required:!0},exaggeration:{type:"number",minimum:0,default:1}},projection:{type:{type:"projectionDefinition",default:"mercator","property-type":"data-constant",transition:!1,expression:{interpolated:!0,parameters:["zoom"]}}},paint:["paint_fill","paint_line","paint_circle","paint_heatmap","paint_fill-extrusion","paint_symbol","paint_raster","paint_hillshade","paint_color-relief","paint_background"],paint_fill:{"fill-antialias":{type:"boolean",default:!0,expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"fill-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-color":{type:"color",default:"#000000",transition:!0,requires:[{"!":"fill-pattern"}],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-outline-color":{type:"color",transition:!0,requires:[{"!":"fill-pattern"},{"fill-antialias":!0}],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"fill-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["fill-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"fill-pattern":{type:"resolvedImage",transition:!0,expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"cross-faded-data-driven"}},"paint_fill-extrusion":{"fill-extrusion-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"fill-extrusion-color":{type:"color",default:"#000000",transition:!0,requires:[{"!":"fill-extrusion-pattern"}],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-extrusion-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"fill-extrusion-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["fill-extrusion-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"fill-extrusion-pattern":{type:"resolvedImage",transition:!0,expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"cross-faded-data-driven"},"fill-extrusion-height":{type:"number",default:0,minimum:0,units:"meters",transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-extrusion-base":{type:"number",default:0,minimum:0,units:"meters",transition:!0,requires:["fill-extrusion-height"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-extrusion-vertical-gradient":{type:"boolean",default:!0,transition:!1,expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"}},paint_line:{"line-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-color":{type:"color",default:"#000000",transition:!0,requires:[{"!":"line-pattern"}],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"line-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["line-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"line-width":{type:"number",default:1,minimum:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-gap-width":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-offset":{type:"number",default:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-blur":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-dasharray":{type:"array",value:"number",minimum:0,transition:!0,units:"line widths",requires:[{"!":"line-pattern"}],expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"cross-faded-data-driven"},"line-pattern":{type:"resolvedImage",transition:!0,expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"cross-faded-data-driven"},"line-gradient":{type:"color",transition:!1,requires:[{"!":"line-dasharray"},{"!":"line-pattern"},{source:"geojson",has:{lineMetrics:!0}}],expression:{interpolated:!0,parameters:["line-progress"]},"property-type":"color-ramp"}},paint_circle:{"circle-radius":{type:"number",default:5,minimum:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-color":{type:"color",default:"#000000",transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-blur":{type:"number",default:0,transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"circle-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["circle-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"circle-pitch-scale":{type:"enum",values:{map:{},viewport:{}},default:"map",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"circle-pitch-alignment":{type:"enum",values:{map:{},viewport:{}},default:"viewport",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"circle-stroke-width":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-stroke-color":{type:"color",default:"#000000",transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-stroke-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"}},paint_heatmap:{"heatmap-radius":{type:"number",default:30,minimum:1,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"heatmap-weight":{type:"number",default:1,minimum:0,transition:!1,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"heatmap-intensity":{type:"number",default:1,minimum:0,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"heatmap-color":{type:"color",default:["interpolate",["linear"],["heatmap-density"],0,"rgba(0, 0, 255, 0)",.1,"royalblue",.3,"cyan",.5,"lime",.7,"yellow",1,"red"],transition:!1,expression:{interpolated:!0,parameters:["heatmap-density"]},"property-type":"color-ramp"},"heatmap-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"}},paint_symbol:{"icon-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-color":{type:"color",default:"#000000",transition:!0,requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-halo-color":{type:"color",default:"rgba(0, 0, 0, 0)",transition:!0,requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-halo-width":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-halo-blur":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"icon-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["icon-image","icon-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-color":{type:"color",default:"#000000",transition:!0,overridable:!0,requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-halo-color":{type:"color",default:"rgba(0, 0, 0, 0)",transition:!0,requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-halo-width":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-halo-blur":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"text-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["text-field","text-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"}},paint_raster:{"raster-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-hue-rotate":{type:"number",default:0,period:360,transition:!0,units:"degrees",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-brightness-min":{type:"number",default:0,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-brightness-max":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-saturation":{type:"number",default:0,minimum:-1,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-contrast":{type:"number",default:0,minimum:-1,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-resampling":{type:"enum",values:{linear:{},nearest:{}},default:"linear",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"raster-fade-duration":{type:"number",default:300,minimum:0,transition:!1,units:"milliseconds",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"}},paint_hillshade:{"hillshade-illumination-direction":{type:"numberArray",default:335,minimum:0,maximum:359,transition:!1,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-illumination-altitude":{type:"numberArray",default:45,minimum:0,maximum:90,transition:!1,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-illumination-anchor":{type:"enum",values:{map:{},viewport:{}},default:"viewport",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-exaggeration":{type:"number",default:.5,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-shadow-color":{type:"colorArray",default:"#000000",transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-highlight-color":{type:"colorArray",default:"#FFFFFF",transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-accent-color":{type:"color",default:"#000000",transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-method":{type:"enum",values:{standard:{},basic:{},combined:{},igor:{},multidirectional:{}},default:"standard",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"}},"paint_color-relief":{"color-relief-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"color-relief-color":{type:"color",transition:!1,expression:{interpolated:!0,parameters:["elevation"]},"property-type":"color-ramp"}},paint_background:{"background-color":{type:"color",default:"#000000",transition:!0,requires:[{"!":"background-pattern"}],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"background-pattern":{type:"resolvedImage",transition:!0,expression:{interpolated:!1,parameters:["zoom"]},"property-type":"cross-faded"},"background-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"}},transition:{duration:{type:"number",default:300,minimum:0,units:"milliseconds"},delay:{type:"number",default:0,minimum:0,units:"milliseconds"}},"property-type":{"data-driven":{type:"property-type"},"cross-faded":{type:"property-type"},"cross-faded-data-driven":{type:"property-type"},"color-ramp":{type:"property-type"},"data-constant":{type:"property-type"},constant:{type:"property-type"}},promoteId:{"*":{type:"string"}},interpolation:{type:"array",value:"interpolation_name",minimum:1},interpolation_name:{type:"enum",values:{linear:{syntax:{overloads:[{parameters:[],"output-type":"interpolation"}],parameters:[]}},exponential:{syntax:{overloads:[{parameters:["base"],"output-type":"interpolation"}],parameters:[{name:"base",type:"number literal"}]}},"cubic-bezier":{syntax:{overloads:[{parameters:["x1","y1","x2","y2"],"output-type":"interpolation"}],parameters:[{name:"x1",type:"number literal"},{name:"y1",type:"number literal"},{name:"x2",type:"number literal"},{name:"y2",type:"number literal"}]}}}}};const Mt=["type","source","source-layer","minzoom","maxzoom","filter","layout"];function At(e,s){const l={};for(const s in e)"ref"!==s&&(l[s]=e[s]);return Mt.forEach((e=>{e in s&&(l[e]=s[e])})),l}function Lt(e,s){if(Array.isArray(e)){if(!Array.isArray(s)||e.length!==s.length)return!1;for(let l=0;l`:"value"===e.itemType.kind?"array":`array<${s}>`}return e.kind}const Ai=[ni,li,ci,ui,pi,fi,yi,mi,Ei(_i),xi,bi,vi,wi,Ii];function Li(e,s){if("error"===s.kind)return null;if("array"===e.kind){if("array"===s.kind&&(0===s.N&&"value"===s.itemType.kind||!Li(e.itemType,s.itemType))&&("number"!=typeof e.N||e.N===s.N))return null}else{if(e.kind===s.kind)return null;if("value"===e.kind)for(const e of Ai)if(!Li(e,s))return null}return`Expected ${Ci(e)} but found ${Ci(s)} instead.`}function Fi(e,s){return s.some((s=>s.kind===e.kind))}function Oi(e,s){return s.some((s=>"null"===s?null===e:"array"===s?Array.isArray(e):"object"===s?e&&!Array.isArray(e)&&"object"==typeof e:s===typeof e))}function Vi(e,s){return"array"===e.kind&&"array"===s.kind?e.itemType.kind===s.itemType.kind&&"number"==typeof e.N:e.kind===s.kind}const ji=.96422,Ni=.82521,Gi=4/29,Ui=6/29,qi=3*Ui*Ui,$i=Ui*Ui*Ui,Wi=Math.PI/180,Hi=180/Math.PI;function Xi(e){return(e%=360)<0&&(e+=360),e}function Yi([e,s,l,c]){let d,p;const f=Qi((.2225045*(e=Ki(e))+.7168786*(s=Ki(s))+.0606169*(l=Ki(l)))/1);e===s&&s===l?d=p=f:(d=Qi((.4360747*e+.3850649*s+.1430804*l)/ji),p=Qi((.0139322*e+.0971045*s+.7141733*l)/Ni));const m=116*f-16;return[m<0?0:m,500*(d-f),200*(f-p),c]}function Ki(e){return e<=.04045?e/12.92:Math.pow((e+.055)/1.055,2.4)}function Qi(e){return e>$i?Math.pow(e,1/3):e/qi+Gi}function Ji([e,s,l,c]){let d=(e+16)/116,p=isNaN(s)?d:d+s/500,f=isNaN(l)?d:d-l/200;return d=1*cr(d),p=ji*cr(p),f=Ni*cr(f),[lr(3.1338561*p-1.6168667*d-.4906146*f),lr(-.9787684*p+1.9161415*d+.033454*f),lr(.0719453*p-.2289914*d+1.4052427*f),c]}function lr(e){return(e=e<=.00304?12.92*e:1.055*Math.pow(e,1/2.4)-.055)<0?0:e>1?1:e}function cr(e){return e>Ui?e*e*e:qi*(e-Gi)}const hr=Object.hasOwn||function(e,s){return Object.prototype.hasOwnProperty.call(e,s)};function ur(e,s){return hr(e,s)?e[s]:void 0}function dr(e){return parseInt(e.padEnd(2,e),16)/255}function pr(e,s){return _r(s?e/100:e,0,1)}function _r(e,s,l){return Math.min(Math.max(s,e),l)}function gr(e){return!e.some(Number.isNaN)}const yr={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]};function xr(e,s,l){return e+l*(s-e)}function vr(e,s,l){return e.map(((e,c)=>xr(e,s[c],l)))}class Te{constructor(e,s,l,c=1,d=!0){this.r=e,this.g=s,this.b=l,this.a=c,d||(this.r*=c,this.g*=c,this.b*=c,c||this.overwriteGetter("rgb",[e,s,l,c]))}static parse(e){if(e instanceof Te)return e;if("string"!=typeof e)return;const s=function(e){if("transparent"===(e=e.toLowerCase().trim()))return[0,0,0,0];const s=ur(yr,e);if(s){const[e,l,c]=s;return[e/255,l/255,c/255,1]}if(e.startsWith("#")&&/^#(?:[0-9a-f]{3,4}|[0-9a-f]{6}|[0-9a-f]{8})$/.test(e)){const s=e.length<6?1:2;let l=1;return[dr(e.slice(l,l+=s)),dr(e.slice(l,l+=s)),dr(e.slice(l,l+=s)),dr(e.slice(l,l+s)||"ff")]}if(e.startsWith("rgb")){const s=e.match(/^rgba?\(\s*([\de.+-]+)(%)?(?:\s+|\s*(,)\s*)([\de.+-]+)(%)?(?:\s+|\s*(,)\s*)([\de.+-]+)(%)?(?:\s*([,\/])\s*([\de.+-]+)(%)?)?\s*\)$/);if(s){const[e,l,c,d,p,f,m,_,g,y,b,T]=s,P=[d||" ",m||" ",y].join("");if(" "===P||" /"===P||",,"===P||",,,"===P){const e=[c,f,g].join(""),s="%%%"===e?100:""===e?255:0;if(s){const e=[_r(+l/s,0,1),_r(+p/s,0,1),_r(+_/s,0,1),b?pr(+b,T):1];if(gr(e))return e}}return}}const l=e.match(/^hsla?\(\s*([\de.+-]+)(?:deg)?(?:\s+|\s*(,)\s*)([\de.+-]+)%(?:\s+|\s*(,)\s*)([\de.+-]+)%(?:\s*([,\/])\s*([\de.+-]+)(%)?)?\s*\)$/);if(l){const[e,s,c,d,p,f,m,_,g]=l,y=[c||" ",p||" ",m].join("");if(" "===y||" /"===y||",,"===y||",,,"===y){const e=[+s,_r(+d,0,100),_r(+f,0,100),_?pr(+_,g):1];if(gr(e))return function([e,s,l,c]){function d(c){const d=(c+e/30)%12,p=s*Math.min(l,1-l);return l-p*Math.max(-1,Math.min(d-3,9-d,1))}return e=Xi(e),s/=100,l/=100,[d(0),d(8),d(4),c]}(e)}}}(e);return s?new Te(...s,!1):void 0}get rgb(){const{r:e,g:s,b:l,a:c}=this,d=c||1/0;return this.overwriteGetter("rgb",[e/d,s/d,l/d,c])}get hcl(){return this.overwriteGetter("hcl",function(e){const[s,l,c,d]=Yi(e),p=Math.sqrt(l*l+c*c);return[Math.round(1e4*p)?Xi(Math.atan2(c,l)*Hi):NaN,p,s,d]}(this.rgb))}get lab(){return this.overwriteGetter("lab",Yi(this.rgb))}overwriteGetter(e,s){return Object.defineProperty(this,e,{value:s}),s}toString(){const[e,s,l,c]=this.rgb;return`rgba(${[e,s,l].map((e=>Math.round(255*e))).join(",")},${c})`}static interpolate(e,s,l,c="rgb"){switch(c){case"rgb":{const[c,d,p,f]=vr(e.rgb,s.rgb,l);return new Te(c,d,p,f,!1)}case"hcl":{const[c,d,p,f]=e.hcl,[m,_,g,y]=s.hcl;let b,T;if(isNaN(c)||isNaN(m))isNaN(c)?isNaN(m)?b=NaN:(b=m,1!==p&&0!==p||(T=_)):(b=c,1!==g&&0!==g||(T=d));else{let e=m-c;m>c&&e>180?e-=360:m180&&(e+=360),b=c+l*e}const[P,S,I,C]=function([e,s,l,c]){return e=isNaN(e)?0:e*Wi,Ji([l,Math.cos(e)*s,Math.sin(e)*s,c])}([b,null!=T?T:xr(d,_,l),xr(p,g,l),xr(f,y,l)]);return new Te(P,S,I,C,!1)}case"lab":{const[c,d,p,f]=Ji(vr(e.lab,s.lab,l));return new Te(c,d,p,f,!1)}}}}Te.black=new Te(0,0,0,1),Te.white=new Te(1,1,1,1),Te.transparent=new Te(0,0,0,0),Te.red=new Te(1,0,0,1);class Ie{constructor(e,s,l){this.sensitivity=e?s?"variant":"case":s?"accent":"base",this.locale=l,this.collator=new Intl.Collator(this.locale?this.locale:[],{sensitivity:this.sensitivity,usage:"search"})}compare(e,s){return this.collator.compare(e,s)}resolvedLocale(){return new Intl.Collator(this.locale?this.locale:[]).resolvedOptions().locale}}const br=["bottom","center","top"];class Fe{constructor(e,s,l,c,d,p){this.text=e,this.image=s,this.scale=l,this.fontStack=c,this.textColor=d,this.verticalAlign=p}}class De{constructor(e){this.sections=e}static fromString(e){return new De([new Fe(e,null,null,null,null,null)])}isEmpty(){return 0===this.sections.length||!this.sections.some((e=>0!==e.text.length||e.image&&0!==e.image.name.length))}static factory(e){return e instanceof De?e:De.fromString(e)}toString(){return 0===this.sections.length?"":this.sections.map((e=>e.text)).join("")}}class ze{constructor(e){this.values=e.slice()}static parse(e){if(e instanceof ze)return e;if("number"==typeof e)return new ze([e,e,e,e]);if(Array.isArray(e)&&!(e.length<1||e.length>4)){for(const s of e)if("number"!=typeof s)return;switch(e.length){case 1:e=[e[0],e[0],e[0],e[0]];break;case 2:e=[e[0],e[1],e[0],e[1]];break;case 3:e=[e[0],e[1],e[2],e[1]]}return new ze(e)}}toString(){return JSON.stringify(this.values)}static interpolate(e,s,l){return new ze(vr(e.values,s.values,l))}}class Pe{constructor(e){this.values=e.slice()}static parse(e){if(e instanceof Pe)return e;if("number"==typeof e)return new Pe([e]);if(Array.isArray(e)){for(const s of e)if("number"!=typeof s)return;return new Pe(e)}}toString(){return JSON.stringify(this.values)}static interpolate(e,s,l){return new Pe(vr(e.values,s.values,l))}}class Be{constructor(e){this.values=e.slice()}static parse(e){if(e instanceof Be)return e;if("string"==typeof e){const s=Te.parse(e);if(!s)return;return new Be([s])}if(!Array.isArray(e))return;const s=[];for(const l of e){if("string"!=typeof l)return;const e=Te.parse(l);if(!e)return;s.push(e)}return new Be(s)}toString(){return JSON.stringify(this.values)}static interpolate(e,s,l,c="rgb"){const d=[];if(e.values.length!=s.values.length)throw new Error(`colorArray: Arrays have mismatched length (${e.values.length} vs. ${s.values.length}), cannot interpolate.`);for(let p=0;p=0&&e<=255&&"number"==typeof s&&s>=0&&s<=255&&"number"==typeof l&&l>=0&&l<=255?void 0===c||"number"==typeof c&&c>=0&&c<=1?null:`Invalid rgba value [${[e,s,l,c].join(", ")}]: 'a' must be between 0 and 1.`:`Invalid rgba value [${("number"==typeof c?[e,s,l,c]:[e,s,l]).join(", ")}]: 'r', 'g', and 'b' must be between 0 and 255.`}function Sr(e){if(null===e||"string"==typeof e||"boolean"==typeof e||"number"==typeof e||e instanceof Re||e instanceof Te||e instanceof Ie||e instanceof De||e instanceof ze||e instanceof Pe||e instanceof Be||e instanceof Le||e instanceof Oe)return!0;if(Array.isArray(e)){for(const s of e)if(!Sr(s))return!1;return!0}if("object"==typeof e){for(const s in e)if(!Sr(e[s]))return!1;return!0}return!1}function Cr(e){if(null===e)return ni;if("string"==typeof e)return ci;if("boolean"==typeof e)return ui;if("number"==typeof e)return li;if(e instanceof Te)return pi;if(e instanceof Re)return fi;if(e instanceof Ie)return gi;if(e instanceof De)return yi;if(e instanceof ze)return xi;if(e instanceof Pe)return bi;if(e instanceof Be)return vi;if(e instanceof Le)return Ii;if(e instanceof Oe)return wi;if(Array.isArray(e)){const s=e.length;let l;for(const s of e){const e=Cr(s);if(l){if(l===e)continue;l=_i;break}l=e}return Ei(l||_i,s)}return mi}function Ar(e){const s=typeof e;return null===e?"":"string"===s||"number"===s||"boolean"===s?String(e):e instanceof Te||e instanceof Re||e instanceof De||e instanceof ze||e instanceof Pe||e instanceof Be||e instanceof Le||e instanceof Oe?e.toString():JSON.stringify(e)}class je{constructor(e,s){this.type=e,this.value=s}static parse(e,s){if(2!==e.length)return s.error(`'literal' expression requires exactly one argument, but found ${e.length-1} instead.`);if(!Sr(e[1]))return s.error("invalid value");const l=e[1];let c=Cr(l);const d=s.expectedType;return"array"!==c.kind||0!==c.N||!d||"array"!==d.kind||"number"==typeof d.N&&0!==d.N||(c=d),new je(c,l)}evaluate(){return this.value}eachChild(){}outputDefined(){return!0}}const Dr={string:ci,number:li,boolean:ui,object:mi};class Xe{constructor(e,s){this.type=e,this.args=s}static parse(e,s){if(e.length<2)return s.error("Expected at least one argument.");let l,c=1;const d=e[0];if("array"===d){let d,p;if(e.length>2){const l=e[1];if("string"!=typeof l||!(l in Dr)||"object"===l)return s.error('The item type argument of "array" must be one of string, number, boolean',1);d=Dr[l],c++}else d=_i;if(e.length>3){if(null!==e[2]&&("number"!=typeof e[2]||e[2]<0||e[2]!==Math.floor(e[2])))return s.error('The length argument to "array" must be a positive integer literal',2);p=e[2],c++}l=Ei(d,p)}else{if(!Dr[d])throw new Error(`Types doesn't contain name = ${d}`);l=Dr[d]}const p=[];for(;ce.outputDefined()))}}const zr={"to-boolean":ui,"to-color":pi,"to-number":li,"to-string":ci};class Ze{constructor(e,s){this.type=e,this.args=s}static parse(e,s){if(e.length<2)return s.error("Expected at least one argument.");const l=e[0];if(!zr[l])throw new Error(`Can't parse ${l} as it is not part of the known types`);if(("to-boolean"===l||"to-string"===l)&&2!==e.length)return s.error("Expected one argument.");const c=zr[l],d=[];for(let l=1;l4?`Invalid rgba value ${JSON.stringify(s)}: expected an array containing either three or four numeric values.`:Pr(s[0],s[1],s[2],s[3]),!l))return new Te(s[0]/255,s[1]/255,s[2]/255,s[3])}throw new Ve(l||`Could not parse color from value '${"string"==typeof s?s:JSON.stringify(s)}'`)}case"padding":{let s;for(const l of this.args){s=l.evaluate(e);const c=ze.parse(s);if(c)return c}throw new Ve(`Could not parse padding from value '${"string"==typeof s?s:JSON.stringify(s)}'`)}case"numberArray":{let s;for(const l of this.args){s=l.evaluate(e);const c=Pe.parse(s);if(c)return c}throw new Ve(`Could not parse numberArray from value '${"string"==typeof s?s:JSON.stringify(s)}'`)}case"colorArray":{let s;for(const l of this.args){s=l.evaluate(e);const c=Be.parse(s);if(c)return c}throw new Ve(`Could not parse colorArray from value '${"string"==typeof s?s:JSON.stringify(s)}'`)}case"variableAnchorOffsetCollection":{let s;for(const l of this.args){s=l.evaluate(e);const c=Le.parse(s);if(c)return c}throw new Ve(`Could not parse variableAnchorOffsetCollection from value '${"string"==typeof s?s:JSON.stringify(s)}'`)}case"number":{let s=null;for(const l of this.args){if(s=l.evaluate(e),null===s)return 0;const c=Number(s);if(!isNaN(c))return c}throw new Ve(`Could not convert ${JSON.stringify(s)} to number.`)}case"formatted":return De.fromString(Ar(this.args[0].evaluate(e)));case"resolvedImage":return Oe.fromString(Ar(this.args[0].evaluate(e)));case"projectionDefinition":return this.args[0].evaluate(e);default:return Ar(this.args[0].evaluate(e))}}eachChild(e){this.args.forEach(e)}outputDefined(){return this.args.every((e=>e.outputDefined()))}}const kr=["Unknown","Point","LineString","Polygon"];class Ke{constructor(){this.globals=null,this.feature=null,this.featureState=null,this.formattedSection=null,this._parseColorCache=new Map,this.availableImages=null,this.canonical=null}id(){return this.feature&&"id"in this.feature?this.feature.id:null}geometryType(){return this.feature?"number"==typeof this.feature.type?kr[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||{}}parseColor(e){let s=this._parseColorCache.get(e);return s||(s=Te.parse(e),this._parseColorCache.set(e,s)),s}}class We{constructor(e,s,l=[],c,d=new Bt,p=[]){this.registry=e,this.path=l,this.key=l.map((e=>`[${e}]`)).join(""),this.scope=d,this.errors=p,this.expectedType=c,this._isConstant=s}parse(e,s,l,c,d={}){return s?this.concat(s,l,c)._parse(e,d):this._parse(e,d)}_parse(e,s){function l(e,s,l){return"assert"===l?new Xe(s,[e]):"coerce"===l?new Ze(s,[e]):e}if(null!==e&&"string"!=typeof e&&"boolean"!=typeof e&&"number"!=typeof e||(e=["literal",e]),Array.isArray(e)){if(0===e.length)return this.error('Expected an array with at least one element. If you wanted a literal array, use ["literal", []].');const c=e[0];if("string"!=typeof c)return this.error(`Expression name must be a string, but found ${typeof c} instead. If you wanted a literal array, use ["literal", [...]].`,0),null;const d=this.registry[c];if(d){let c=d.parse(e,this);if(!c)return null;if(this.expectedType){const e=this.expectedType,d=c.type;if("string"!==e.kind&&"number"!==e.kind&&"boolean"!==e.kind&&"object"!==e.kind&&"array"!==e.kind||"value"!==d.kind){if("projectionDefinition"===e.kind&&["string","array"].includes(d.kind)||["color","formatted","resolvedImage"].includes(e.kind)&&["value","string"].includes(d.kind)||["padding","numberArray"].includes(e.kind)&&["value","number","array"].includes(d.kind)||"colorArray"===e.kind&&["value","string","array"].includes(d.kind)||"variableAnchorOffsetCollection"===e.kind&&["value","array"].includes(d.kind))c=l(c,e,s.typeAnnotation||"coerce");else if(this.checkSubtype(e,d))return null}else c=l(c,e,s.typeAnnotation||"assert")}if(!(c instanceof je)&&"resolvedImage"!==c.type.kind&&this._isConstant(c)){const s=new Ke;try{c=new je(c.type,c.evaluate(s))}catch(e){return this.error(e.message),null}}return c}return this.error(`Unknown expression "${c}". If you wanted a literal array, use ["literal", [...]].`,0)}return this.error(void 0===e?"'undefined' value invalid. Use null instead.":"object"==typeof e?'Bare objects invalid. Use ["literal", {...}] instead.':`Expected an array, but found ${typeof e} instead.`)}concat(e,s,l){const c="number"==typeof e?this.path.concat(e):this.path,d=l?this.scope.concat(l):this.scope;return new We(this.registry,this._isConstant,c,s||null,d,this.errors)}error(e,...s){const l=`${this.key}${s.map((e=>`[${e}]`)).join("")}`;this.errors.push(new Pt(l,e))}checkSubtype(e,s){const l=Li(e,s);return l&&this.error(l),l}}class Je{constructor(e,s){this.type=s.type,this.bindings=[].concat(e),this.result=s}evaluate(e){return this.result.evaluate(e)}eachChild(e){for(const s of this.bindings)e(s[1]);e(this.result)}static parse(e,s){if(e.length<4)return s.error(`Expected at least 3 arguments, but found ${e.length-1} instead.`);const l=[];for(let c=1;c=l.length)throw new Ve(`Array index out of bounds: ${s} > ${l.length-1}.`);if(s!==Math.floor(s))throw new Ve(`Array index must be an integer, but found ${s} instead.`);return l[s]}eachChild(e){e(this.index),e(this.input)}outputDefined(){return!1}}class er{constructor(e,s){this.type=ui,this.needle=e,this.haystack=s}static parse(e,s){if(3!==e.length)return s.error(`Expected 2 arguments, but found ${e.length-1} instead.`);const l=s.parse(e[1],1,_i),c=s.parse(e[2],2,_i);return l&&c?Fi(l.type,[ui,ci,li,ni,_i])?new er(l,c):s.error(`Expected first argument to be of type boolean, string, number or null, but found ${Ci(l.type)} instead`):null}evaluate(e){const s=this.needle.evaluate(e),l=this.haystack.evaluate(e);if(!l)return!1;if(!Oi(s,["boolean","string","number","null"]))throw new Ve(`Expected first argument to be of type boolean, string, number or null, but found ${Ci(Cr(s))} instead.`);if(!Oi(l,["string","array"]))throw new Ve(`Expected second argument to be of type array or string, but found ${Ci(Cr(l))} instead.`);return l.indexOf(s)>=0}eachChild(e){e(this.needle),e(this.haystack)}outputDefined(){return!0}}class rr{constructor(e,s,l){this.type=li,this.needle=e,this.haystack=s,this.fromIndex=l}static parse(e,s){if(e.length<=2||e.length>=5)return s.error(`Expected 2 or 3 arguments, but found ${e.length-1} instead.`);const l=s.parse(e[1],1,_i),c=s.parse(e[2],2,_i);if(!l||!c)return null;if(!Fi(l.type,[ui,ci,li,ni,_i]))return s.error(`Expected first argument to be of type boolean, string, number or null, but found ${Ci(l.type)} instead`);if(4===e.length){const d=s.parse(e[3],3,li);return d?new rr(l,c,d):null}return new rr(l,c)}evaluate(e){const s=this.needle.evaluate(e),l=this.haystack.evaluate(e);if(!Oi(s,["boolean","string","number","null"]))throw new Ve(`Expected first argument to be of type boolean, string, number or null, but found ${Ci(Cr(s))} instead.`);let c;if(this.fromIndex&&(c=this.fromIndex.evaluate(e)),Oi(l,["string"])){const e=l.indexOf(s,c);return-1===e?-1:[...l.slice(0,e)].length}if(Oi(l,["array"]))return l.indexOf(s,c);throw new Ve(`Expected second argument to be of type array or string, but found ${Ci(Cr(l))} instead.`)}eachChild(e){e(this.needle),e(this.haystack),this.fromIndex&&e(this.fromIndex)}outputDefined(){return!1}}class nr{constructor(e,s,l,c,d,p){this.inputType=e,this.type=s,this.input=l,this.cases=c,this.outputs=d,this.otherwise=p}static parse(e,s){if(e.length<5)return s.error(`Expected at least 4 arguments, but found only ${e.length-1}.`);if(e.length%2!=1)return s.error("Expected an even number of arguments.");let l,c;s.expectedType&&"value"!==s.expectedType.kind&&(c=s.expectedType);const d={},p=[];for(let f=2;fNumber.MAX_SAFE_INTEGER)return g.error(`Branch labels must be integers no larger than ${Number.MAX_SAFE_INTEGER}.`);if("number"==typeof e&&Math.floor(e)!==e)return g.error("Numeric branch labels must be integer values.");if(l){if(g.checkSubtype(l,Cr(e)))return null}else l=Cr(e);if(void 0!==d[String(e)])return g.error("Branch labels must be unique.");d[String(e)]=p.length}const y=s.parse(_,f,c);if(!y)return null;c=c||y.type,p.push(y)}const f=s.parse(e[1],1,_i);if(!f)return null;const m=s.parse(e[e.length-1],e.length-1,c);return m?"value"!==f.type.kind&&s.concat(1).checkSubtype(l,f.type)?null:new nr(l,c,f,d,p,m):null}evaluate(e){const s=this.input.evaluate(e);return(Cr(s)===this.inputType&&this.outputs[this.cases[s]]||this.otherwise).evaluate(e)}eachChild(e){e(this.input),this.outputs.forEach(e),e(this.otherwise)}outputDefined(){return this.outputs.every((e=>e.outputDefined()))&&this.otherwise.outputDefined()}}class ir{constructor(e,s,l){this.type=e,this.branches=s,this.otherwise=l}static parse(e,s){if(e.length<4)return s.error(`Expected at least 3 arguments, but found only ${e.length-1}.`);if(e.length%2!=0)return s.error("Expected an odd number of arguments.");let l;s.expectedType&&"value"!==s.expectedType.kind&&(l=s.expectedType);const c=[];for(let d=1;ds.outputDefined()))&&this.otherwise.outputDefined()}}class sr{constructor(e,s,l,c){this.type=e,this.input=s,this.beginIndex=l,this.endIndex=c}static parse(e,s){if(e.length<=2||e.length>=5)return s.error(`Expected 2 or 3 arguments, but found ${e.length-1} instead.`);const l=s.parse(e[1],1,_i),c=s.parse(e[2],2,li);if(!l||!c)return null;if(!Fi(l.type,[Ei(_i),ci,_i]))return s.error(`Expected first argument to be of type array or string, but found ${Ci(l.type)} instead`);if(4===e.length){const d=s.parse(e[3],3,li);return d?new sr(l.type,l,c,d):null}return new sr(l.type,l,c)}evaluate(e){const s=this.input.evaluate(e),l=this.beginIndex.evaluate(e);let c;if(this.endIndex&&(c=this.endIndex.evaluate(e)),Oi(s,["string"]))return[...s].slice(l,c).join("");if(Oi(s,["array"]))return s.slice(l,c);throw new Ve(`Expected first argument to be of type array or string, but found ${Ci(Cr(s))} instead.`)}eachChild(e){e(this.input),e(this.beginIndex),this.endIndex&&e(this.endIndex)}outputDefined(){return!1}}function Rr(e,s){const l=e.length-1;let c,d,p=0,f=l,m=0;for(;p<=f;)if(m=Math.floor((p+f)/2),c=e[m],d=e[m+1],c<=s){if(m===l||ss))throw new Ve("Input is not a number.");f=m-1}return 0}class or{constructor(e,s,l){this.type=e,this.input=s,this.labels=[],this.outputs=[];for(const[e,s]of l)this.labels.push(e),this.outputs.push(s)}static parse(e,s){if(e.length-1<4)return s.error(`Expected at least 4 arguments, but found only ${e.length-1}.`);if((e.length-1)%2!=0)return s.error("Expected an even number of arguments.");const l=s.parse(e[1],1,li);if(!l)return null;const c=[];let d=null;s.expectedType&&"value"!==s.expectedType.kind&&(d=s.expectedType);for(let l=1;l=p)return s.error('Input/output pairs for "step" expressions must be arranged with input values in strictly ascending order.',m);const g=s.parse(f,_,d);if(!g)return null;d=d||g.type,c.push([p,g])}return new or(d,l,c)}evaluate(e){const s=this.labels,l=this.outputs;if(1===s.length)return l[0].evaluate(e);const c=this.input.evaluate(e);if(c<=s[0])return l[0].evaluate(e);const d=s.length;return c>=s[d-1]?l[d-1].evaluate(e):l[Rr(s,c)].evaluate(e)}eachChild(e){e(this.input);for(const s of this.outputs)e(s)}outputDefined(){return this.outputs.every((e=>e.outputDefined()))}}function Lr(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Br,Or,Vr=function(){if(Or)return Br;function s(s,l,c,d){(this||e).cx=3*s,(this||e).bx=3*(c-s)-(this||e).cx,(this||e).ax=1-(this||e).cx-(this||e).bx,(this||e).cy=3*l,(this||e).by=3*(d-l)-(this||e).cy,(this||e).ay=1-(this||e).cy-(this||e).by,(this||e).p1x=s,(this||e).p1y=l,(this||e).p2x=c,(this||e).p2y=d}return Or=1,Br=s,s.prototype={sampleCurveX:function(s){return(((this||e).ax*s+(this||e).bx)*s+(this||e).cx)*s},sampleCurveY:function(s){return(((this||e).ay*s+(this||e).by)*s+(this||e).cy)*s},sampleCurveDerivativeX:function(s){return(3*(this||e).ax*s+2*(this||e).bx)*s+(this||e).cx},solveCurveX:function(e,s){if(void 0===s&&(s=1e-6),e<0)return 0;if(e>1)return 1;for(var l=e,c=0;c<8;c++){var d=this.sampleCurveX(l)-e;if(Math.abs(d)d?f=l:m=l,l=.5*(m-f)+f;return l},solve:function(e,s){return this.sampleCurveY(this.solveCurveX(e,s))}},Br}(),jr=Lr(Vr);class fr{constructor(e,s,l,c,d){this.type=e,this.operator=s,this.interpolation=l,this.input=c,this.labels=[],this.outputs=[];for(const[e,s]of d)this.labels.push(e),this.outputs.push(s)}static interpolationFactor(e,s,l,c){let d=0;if("exponential"===e.name)d=Nr(s,e.base,l,c);else if("linear"===e.name)d=Nr(s,1,l,c);else if("cubic-bezier"===e.name){const p=e.controlPoints;d=new jr(p[0],p[1],p[2],p[3]).solve(Nr(s,1,l,c))}return d}static parse(e,s){let[l,c,d,...p]=e;if(!Array.isArray(c)||0===c.length)return s.error("Expected an interpolation type expression.",1);if("linear"===c[0])c={name:"linear"};else if("exponential"===c[0]){const e=c[1];if("number"!=typeof e)return s.error("Exponential interpolation requires a numeric base.",1,1);c={name:"exponential",base:e}}else{if("cubic-bezier"!==c[0])return s.error(`Unknown interpolation type ${String(c[0])}`,1,0);{const e=c.slice(1);if(4!==e.length||e.some((e=>"number"!=typeof e||e<0||e>1)))return s.error("Cubic bezier interpolation requires four numeric arguments with values between 0 and 1.",1);c={name:"cubic-bezier",controlPoints:e}}}if(e.length-1<4)return s.error(`Expected at least 4 arguments, but found only ${e.length-1}.`);if((e.length-1)%2!=0)return s.error("Expected an even number of arguments.");if(d=s.parse(d,2,li),!d)return null;const f=[];let m=null;"interpolate-hcl"!==l&&"interpolate-lab"!==l||s.expectedType==vi?s.expectedType&&"value"!==s.expectedType.kind&&(m=s.expectedType):m=pi;for(let e=0;e=l)return s.error('Input/output pairs for "interpolate" expressions must be arranged with input values in strictly ascending order.',d);const g=s.parse(c,_,m);if(!g)return null;m=m||g.type,f.push([l,g])}return Vi(m,li)||Vi(m,fi)||Vi(m,pi)||Vi(m,xi)||Vi(m,bi)||Vi(m,vi)||Vi(m,Ii)||Vi(m,Ei(li))?new fr(m,l,c,d,f):s.error(`Type ${Ci(m)} is not interpolatable.`)}evaluate(e){const s=this.labels,l=this.outputs;if(1===s.length)return l[0].evaluate(e);const c=this.input.evaluate(e);if(c<=s[0])return l[0].evaluate(e);const d=s.length;if(c>=s[d-1])return l[d-1].evaluate(e);const p=Rr(s,c),f=fr.interpolationFactor(this.interpolation,c,s[p],s[p+1]),m=l[p].evaluate(e),_=l[p+1].evaluate(e);switch(this.operator){case"interpolate":switch(this.type.kind){case"number":return xr(m,_,f);case"color":return Te.interpolate(m,_,f);case"padding":return ze.interpolate(m,_,f);case"colorArray":return Be.interpolate(m,_,f);case"numberArray":return Pe.interpolate(m,_,f);case"variableAnchorOffsetCollection":return Le.interpolate(m,_,f);case"array":return vr(m,_,f);case"projectionDefinition":return Re.interpolate(m,_,f)}case"interpolate-hcl":switch(this.type.kind){case"color":return Te.interpolate(m,_,f,"hcl");case"colorArray":return Be.interpolate(m,_,f,"hcl")}case"interpolate-lab":switch(this.type.kind){case"color":return Te.interpolate(m,_,f,"lab");case"colorArray":return Be.interpolate(m,_,f,"lab")}}}eachChild(e){e(this.input);for(const s of this.outputs)e(s)}outputDefined(){return this.outputs.every((e=>e.outputDefined()))}}function Nr(e,s,l,c){const d=c-l,p=e-l;return 0===d?0:1===s?p/d:(Math.pow(s,p)-1)/(Math.pow(s,d)-1)}const Gr={color:Te.interpolate,number:xr,padding:ze.interpolate,numberArray:Pe.interpolate,colorArray:Be.interpolate,variableAnchorOffsetCollection:Le.interpolate,array:vr};class mr{constructor(e,s){this.type=e,this.args=s}static parse(e,s){if(e.length<2)return s.error("Expected at least one argument.");let l=null;const c=s.expectedType;c&&"value"!==c.kind&&(l=c);const d=[];for(const c of e.slice(1)){const e=s.parse(c,1+d.length,l,void 0,{typeAnnotation:"omit"});if(!e)return null;l=l||e.type,d.push(e)}if(!l)throw new Error("No output type");const p=c&&d.some((e=>Li(c,e.type)));return new mr(p?_i:l,d)}evaluate(e){let s,l=null,c=0;for(const d of this.args)if(c++,l=d.evaluate(e),l&&l instanceof Oe&&!l.available&&(s||(s=l.name),l=null,c===this.args.length&&(l=s)),null!==l)break;return l}eachChild(e){this.args.forEach(e)}outputDefined(){return this.args.every((e=>e.outputDefined()))}}function Ur(e,s){return"=="===e||"!="===e?"boolean"===s.kind||"string"===s.kind||"number"===s.kind||"null"===s.kind||"value"===s.kind:"string"===s.kind||"number"===s.kind||"value"===s.kind}function Zr(e,s,l,c){return 0===c.compare(s,l)}function Wr(e,s,l){const c="=="!==e&&"!="!==e;return class i{constructor(e,s,l){this.type=ui,this.lhs=e,this.rhs=s,this.collator=l,this.hasUntypedArgument="value"===e.type.kind||"value"===s.type.kind}static parse(e,s){if(3!==e.length&&4!==e.length)return s.error("Expected two or three arguments.");const l=e[0];let d=s.parse(e[1],1,_i);if(!d)return null;if(!Ur(l,d.type))return s.concat(1).error(`"${l}" comparisons are not supported for type '${Ci(d.type)}'.`);let p=s.parse(e[2],2,_i);if(!p)return null;if(!Ur(l,p.type))return s.concat(2).error(`"${l}" comparisons are not supported for type '${Ci(p.type)}'.`);if(d.type.kind!==p.type.kind&&"value"!==d.type.kind&&"value"!==p.type.kind)return s.error(`Cannot compare types '${Ci(d.type)}' and '${Ci(p.type)}'.`);c&&("value"===d.type.kind&&"value"!==p.type.kind?d=new Xe(p.type,[d]):"value"!==d.type.kind&&"value"===p.type.kind&&(p=new Xe(d.type,[p])));let f=null;if(4===e.length){if("string"!==d.type.kind&&"string"!==p.type.kind&&"value"!==d.type.kind&&"value"!==p.type.kind)return s.error("Cannot use collator to compare non-string types.");if(f=s.parse(e[3],3,gi),!f)return null}return new i(d,p,f)}evaluate(d){const p=this.lhs.evaluate(d),f=this.rhs.evaluate(d);if(c&&this.hasUntypedArgument){const s=Cr(p),l=Cr(f);if(s.kind!==l.kind||"string"!==s.kind&&"number"!==s.kind)throw new Ve(`Expected arguments for "${e}" to be (string, string) or (number, number), but found (${s.kind}, ${l.kind}) instead.`)}if(this.collator&&!c&&this.hasUntypedArgument){const e=Cr(p),l=Cr(f);if("string"!==e.kind||"string"!==l.kind)return s(d,p,f)}return this.collator?l(d,p,f,this.collator.evaluate(d)):s(d,p,f)}eachChild(e){e(this.lhs),e(this.rhs),this.collator&&e(this.collator)}outputDefined(){return!0}}}const Xr=Wr("==",(function(e,s,l){return s===l}),Zr),Yr=Wr("!=",(function(e,s,l){return s!==l}),(function(e,s,l,c){return!Zr(0,s,l,c)})),Kr=Wr("<",(function(e,s,l){return s",(function(e,s,l){return s>l}),(function(e,s,l,c){return c.compare(s,l)>0})),Jr=Wr("<=",(function(e,s,l){return s<=l}),(function(e,s,l,c){return c.compare(s,l)<=0})),en=Wr(">=",(function(e,s,l){return s>=l}),(function(e,s,l,c){return c.compare(s,l)>=0}));class Er{constructor(e,s,l){this.type=gi,this.locale=l,this.caseSensitive=e,this.diacriticSensitive=s}static parse(e,s){if(2!==e.length)return s.error("Expected one argument.");const l=e[1];if("object"!=typeof l||Array.isArray(l))return s.error("Collator options argument must be an object.");const c=s.parse(void 0!==l["case-sensitive"]&&l["case-sensitive"],1,ui);if(!c)return null;const d=s.parse(void 0!==l["diacritic-sensitive"]&&l["diacritic-sensitive"],1,ui);if(!d)return null;let p=null;return l.locale&&(p=s.parse(l.locale,1,ci),!p)?null:new Er(c,d,p)}evaluate(e){return new Ie(this.caseSensitive.evaluate(e),this.diacriticSensitive.evaluate(e),this.locale?this.locale.evaluate(e):null)}eachChild(e){e(this.caseSensitive),e(this.diacriticSensitive),this.locale&&e(this.locale)}outputDefined(){return!1}}class Tr{constructor(e,s,l,c,d){this.type=ci,this.number=e,this.locale=s,this.currency=l,this.minFractionDigits=c,this.maxFractionDigits=d}static parse(e,s){if(3!==e.length)return s.error("Expected two arguments.");const l=s.parse(e[1],1,li);if(!l)return null;const c=e[2];if("object"!=typeof c||Array.isArray(c))return s.error("NumberFormat options argument must be an object.");let d=null;if(c.locale&&(d=s.parse(c.locale,1,ci),!d))return null;let p=null;if(c.currency&&(p=s.parse(c.currency,1,ci),!p))return null;let f=null;if(c["min-fraction-digits"]&&(f=s.parse(c["min-fraction-digits"],1,li),!f))return null;let m=null;return c["max-fraction-digits"]&&(m=s.parse(c["max-fraction-digits"],1,li),!m)?null:new Tr(l,d,p,f,m)}evaluate(e){return new Intl.NumberFormat(this.locale?this.locale.evaluate(e):[],{style:this.currency?"currency":"decimal",currency:this.currency?this.currency.evaluate(e):void 0,minimumFractionDigits:this.minFractionDigits?this.minFractionDigits.evaluate(e):void 0,maximumFractionDigits:this.maxFractionDigits?this.maxFractionDigits.evaluate(e):void 0}).format(this.number.evaluate(e))}eachChild(e){e(this.number),this.locale&&e(this.locale),this.currency&&e(this.currency),this.minFractionDigits&&e(this.minFractionDigits),this.maxFractionDigits&&e(this.maxFractionDigits)}outputDefined(){return!1}}class Ir{constructor(e){this.type=yi,this.sections=e}static parse(e,s){if(e.length<2)return s.error("Expected at least one argument.");const l=e[1];if(!Array.isArray(l)&&"object"==typeof l)return s.error("First argument must be an image or text section.");const c=[];let d=!1;for(let l=1;l<=e.length-1;++l){const p=e[l];if(d&&"object"==typeof p&&!Array.isArray(p)){d=!1;let e=null;if(p["font-scale"]&&(e=s.parse(p["font-scale"],1,li),!e))return null;let l=null;if(p["text-font"]&&(l=s.parse(p["text-font"],1,Ei(ci)),!l))return null;let f=null;if(p["text-color"]&&(f=s.parse(p["text-color"],1,pi),!f))return null;let m=null;if(p["vertical-align"]){if("string"==typeof p["vertical-align"]&&!br.includes(p["vertical-align"]))return s.error(`'vertical-align' must be one of: 'bottom', 'center', 'top' but found '${p["vertical-align"]}' instead.`);if(m=s.parse(p["vertical-align"],1,ci),!m)return null}const _=c[c.length-1];_.scale=e,_.font=l,_.textColor=f,_.verticalAlign=m}else{const p=s.parse(e[l],1,_i);if(!p)return null;const f=p.type.kind;if("string"!==f&&"value"!==f&&"null"!==f&&"resolvedImage"!==f)return s.error("Formatted text type must be 'string', 'value', 'image' or 'null'.");d=!0,c.push({content:p,scale:null,font:null,textColor:null,verticalAlign:null})}}return new Ir(c)}evaluate(e){return new De(this.sections.map((s=>{const l=s.content.evaluate(e);return Cr(l)===wi?new Fe("",l,null,null,null,s.verticalAlign?s.verticalAlign.evaluate(e):null):new Fe(Ar(l),null,s.scale?s.scale.evaluate(e):null,s.font?s.font.evaluate(e).join(","):null,s.textColor?s.textColor.evaluate(e):null,s.verticalAlign?s.verticalAlign.evaluate(e):null)})))}eachChild(e){for(const s of this.sections)e(s.content),s.scale&&e(s.scale),s.font&&e(s.font),s.textColor&&e(s.textColor),s.verticalAlign&&e(s.verticalAlign)}outputDefined(){return!1}}class Mr{constructor(e){this.type=wi,this.input=e}static parse(e,s){if(2!==e.length)return s.error("Expected two arguments.");const l=s.parse(e[1],1,ci);return l?new Mr(l):s.error("No image name provided.")}evaluate(e){const s=this.input.evaluate(e),l=Oe.fromString(s);return l&&e.availableImages&&(l.available=e.availableImages.indexOf(s)>-1),l}eachChild(e){e(this.input)}outputDefined(){return!1}}class Fr{constructor(e){this.type=li,this.input=e}static parse(e,s){if(2!==e.length)return s.error(`Expected 1 argument, but found ${e.length-1} instead.`);const l=s.parse(e[1],1);return l?"array"!==l.type.kind&&"string"!==l.type.kind&&"value"!==l.type.kind?s.error(`Expected argument of type string or array, but found ${Ci(l.type)} instead.`):new Fr(l):null}evaluate(e){const s=this.input.evaluate(e);if("string"==typeof s)return[...s].length;if(Array.isArray(s))return s.length;throw new Ve(`Expected value to be of type string or array, but found ${Ci(Cr(s))} instead.`)}eachChild(e){e(this.input)}outputDefined(){return!1}}const tn=8192;function rn(e,s){const l=(180+e[0])/360,c=(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+e[1]*Math.PI/360)))/360,d=Math.pow(2,s.z);return[Math.round(l*d*tn),Math.round(c*d*tn)]}function nn(e,s){const l=Math.pow(2,s.z);return[(d=(e[0]/tn+s.x)/l,360*d-180),(c=(e[1]/tn+s.y)/l,360/Math.PI*Math.atan(Math.exp((180-360*c)*Math.PI/180))-90)];var c,d}function sn(e,s){e[0]=Math.min(e[0],s[0]),e[1]=Math.min(e[1],s[1]),e[2]=Math.max(e[2],s[0]),e[3]=Math.max(e[3],s[1])}function an(e,s){return!(e[0]<=s[0]||e[2]>=s[2]||e[1]<=s[1]||e[3]>=s[3])}function ln(e,s,l){const c=e[0]-s[0],d=e[1]-s[1],p=e[0]-l[0],f=e[1]-l[1];return c*f-p*d==0&&c*p<=0&&d*f<=0}function cn(e,s,l,c){return 0!=(d=[c[0]-l[0],c[1]-l[1]])[0]*(p=[s[0]-e[0],s[1]-e[1]])[1]-d[1]*p[0]&&!(!mn(e,s,l,c)||!mn(l,c,e,s));var d,p}function hn(e,s,l){for(const c of l)for(let l=0;l(d=e)[1]!=(f=m[s+1])[1]>d[1]&&d[0]<(f[0]-p[0])*(d[1]-p[1])/(f[1]-p[1])+p[0]&&(c=!c)}var d,p,f;return c}function dn(e,s){for(const l of s)if(un(e,l))return!0;return!1}function pn(e,s){for(const l of e)if(!un(l,s))return!1;for(let l=0;l0&&m<0||f<0&&m>0}function _n(e,s,l){const c=[];for(let d=0;dl[2]){const s=.5*c;let d=e[0]-l[0]>s?-c:l[0]-e[0]>s?c:0;0===d&&(d=e[0]-l[2]>s?-c:l[2]-e[0]>s?c:0),e[0]+=d}sn(s,e)}function xn(e,s,l,c){const d=Math.pow(2,c.z)*tn,p=[c.x*tn,c.y*tn],f=[];for(const c of e)for(const e of c){const c=[e.x+p[0],e.y+p[1]];yn(c,s,l,d),f.push(c)}return f}function vn(e,s,l,c){const d=Math.pow(2,c.z)*tn,p=[c.x*tn,c.y*tn],f=[];for(const l of e){const e=[];for(const c of l){const l=[c.x+p[0],c.y+p[1]];sn(s,l),e.push(l)}f.push(e)}if(s[2]-s[0]<=d/2){(m=s)[0]=m[1]=1/0,m[2]=m[3]=-1/0;for(const e of f)for(const c of e)yn(c,s,l,d)}var m;return f}class Hr{constructor(e,s){this.type=ui,this.geojson=e,this.geometries=s}static parse(e,s){if(2!==e.length)return s.error(`'within' expression requires exactly one argument, but found ${e.length-1} instead.`);if(Sr(e[1])){const s=e[1];if("FeatureCollection"===s.type){const e=[];for(const l of s.features){const{type:s,coordinates:c}=l.geometry;"Polygon"===s&&e.push(c),"MultiPolygon"===s&&e.push(...c)}if(e.length)return new Hr(s,{type:"MultiPolygon",coordinates:e})}else if("Feature"===s.type){const e=s.geometry.type;if("Polygon"===e||"MultiPolygon"===e)return new Hr(s,s.geometry)}else if("Polygon"===s.type||"MultiPolygon"===s.type)return new Hr(s,s)}return s.error("'within' expression requires valid geojson object that contains polygon geometry type.")}evaluate(e){if(null!=e.geometry()&&null!=e.canonicalID()){if("Point"===e.geometryType())return function(e,s){const l=[1/0,1/0,-1/0,-1/0],c=[1/0,1/0,-1/0,-1/0],d=e.canonicalID();if("Polygon"===s.type){const p=_n(s.coordinates,c,d),f=xn(e.geometry(),l,c,d);if(!an(l,c))return!1;for(const e of f)if(!un(e,p))return!1}if("MultiPolygon"===s.type){const p=gn(s.coordinates,c,d),f=xn(e.geometry(),l,c,d);if(!an(l,c))return!1;for(const e of f)if(!dn(e,p))return!1}return!0}(e,this.geometries);if("LineString"===e.geometryType())return function(e,s){const l=[1/0,1/0,-1/0,-1/0],c=[1/0,1/0,-1/0,-1/0],d=e.canonicalID();if("Polygon"===s.type){const p=_n(s.coordinates,c,d),f=vn(e.geometry(),l,c,d);if(!an(l,c))return!1;for(const e of f)if(!pn(e,p))return!1}if("MultiPolygon"===s.type){const p=gn(s.coordinates,c,d),f=vn(e.geometry(),l,c,d);if(!an(l,c))return!1;for(const e of f)if(!fn(e,p))return!1}return!0}(e,this.geometries)}return!1}eachChild(){}outputDefined(){return!0}}let bn=class{constructor(e=[],s=(e,s)=>es?1:0){if(this.data=e,this.length=this.data.length,this.compare=s,this.length>0)for(let e=(this.length>>1)-1;e>=0;e--)this._down(e)}push(e){this.data.push(e),this._up(this.length++)}pop(){if(0===this.length)return;const e=this.data[0],s=this.data.pop();return--this.length>0&&(this.data[0]=s,this._down(0)),e}peek(){return this.data[0]}_up(e){const{data:s,compare:l}=this,c=s[e];for(;e>0;){const d=e-1>>1,p=s[d];if(l(c,p)>=0)break;s[e]=p,e=d}s[e]=c}_down(e){const{data:s,compare:l}=this,c=this.length>>1,d=s[e];for(;e=0)break;s[e]=s[c],e=c}s[e]=d}};function wn(e,s,l=0,c=e.length-1,d=Pn){for(;c>l;){if(c-l>600){const p=c-l+1,f=s-l+1,m=Math.log(p),_=.5*Math.exp(2*m/3),g=.5*Math.sqrt(m*_*(p-_)/p)*(f-p/2<0?-1:1);wn(e,s,Math.max(l,Math.floor(s-f*_/p+g)),Math.min(c,Math.floor(s+(p-f)*_/p+g)),d)}const p=e[s];let f=l,m=c;for(Tn(e,l,s),d(e[c],p)>0&&Tn(e,l,c);f0;)m--}0===d(e[l],p)?Tn(e,l,m):(m++,Tn(e,m,c)),m<=s&&(l=m+1),s<=m&&(c=m-1)}}function Tn(e,s,l){const c=e[s];e[s]=e[l],e[l]=c}function Pn(e,s){return es?1:0}function Sn(e,s){if(e.length<=1)return[e];const l=[];let c,d;for(const s of e){const e=En(s);0!==e&&(s.area=Math.abs(e),void 0===d&&(d=e<0),d===e<0?(c&&l.push(c),c=[s]):c.push(s))}if(c&&l.push(c),s>1)for(let e=0;e1?(_=e[m+1][0],g=e[m+1][1]):T>0&&(_+=y/this.kx*T,g+=b/this.ky*T)),y=this.wrap(s[0]-_)*this.kx,b=(s[1]-g)*this.ky;const P=y*y+b*b;P180;)e-=360;return e}}function kn(e,s){return s[0]-e[0]}function Rn(e){return e[1]-e[0]+1}function Ln(e,s){return e[1]>=e[0]&&e[1]e[1])return[null,null];const l=Rn(e);if(s){if(2===l)return[e,null];const s=Math.floor(l/2);return[[e[0],e[0]+s],[e[0]+s,e[1]]]}if(1===l)return[e,null];const c=Math.floor(l/2)-1;return[[e[0],e[0]+c],[e[0]+c+1,e[1]]]}function On(e,s){if(!Ln(s,e.length))return[1/0,1/0,-1/0,-1/0];const l=[1/0,1/0,-1/0,-1/0];for(let c=s[0];c<=s[1];++c)sn(l,e[c]);return l}function Vn(e){const s=[1/0,1/0,-1/0,-1/0];for(const l of e)for(const e of l)sn(s,e);return s}function jn(e){return e[0]!==-1/0&&e[1]!==-1/0&&e[2]!==1/0&&e[3]!==1/0}function Nn(e,s,l){if(!jn(e)||!jn(s))return NaN;let c=0,d=0;return e[2]s[2]&&(c=e[0]-s[2]),e[1]>s[3]&&(d=e[1]-s[3]),e[3]=c)return c;if(an(d,p)){if(Hn(e,s))return 0}else if(Hn(s,e))return 0;let f=1/0;for(const c of e)for(let e=0,d=c.length,p=d-1;e0;){const d=f.pop();if(d[0]>=p)continue;const _=d[1],g=s?50:100;if(Rn(_)<=g){if(!Ln(_,e.length))return NaN;if(s){const s=Wn(e,_,l,c);if(isNaN(s)||0===s)return s;p=Math.min(p,s)}else for(let s=_[0];s<=_[1];++s){const d=$n(e[s],l,c);if(p=Math.min(p,d),0===p)return 0}}else{const l=Bn(_,s);Yn(f,p,c,e,m,l[0]),Yn(f,p,c,e,m,l[1])}}return p}function Jn(e,s,l,c,d,p=1/0){let f=Math.min(p,d.distance(e[0],l[0]));if(0===f)return f;const m=new bn([[0,[0,e.length-1],[0,l.length-1]]],kn);for(;m.length>0;){const p=m.pop();if(p[0]>=f)continue;const _=p[1],g=p[2],y=s?50:100,b=c?50:100;if(Rn(_)<=y&&Rn(g)<=b){if(!Ln(_,e.length)&&Ln(g,l.length))return NaN;let p;if(s&&c)p=qn(e,_,l,g,d),f=Math.min(f,p);else if(s&&!c){const s=e.slice(_[0],_[1]+1);for(let e=g[0];e<=g[1];++e)if(p=Gn(l[e],s,d),f=Math.min(f,p),0===f)return f}else if(!s&&c){const s=l.slice(g[0],g[1]+1);for(let l=_[0];l<=_[1];++l)if(p=Gn(e[l],s,d),f=Math.min(f,p),0===f)return f}else p=Zn(e,_,l,g,d),f=Math.min(f,p)}else{const p=Bn(_,s),y=Bn(g,c);Kn(m,f,d,e,l,p[0],y[0]),Kn(m,f,d,e,l,p[0],y[1]),Kn(m,f,d,e,l,p[1],y[0]),Kn(m,f,d,e,l,p[1],y[1])}}return f}function es(e){return"MultiPolygon"===e.type?e.coordinates.map((e=>({type:"Polygon",coordinates:e}))):"MultiLineString"===e.type?e.coordinates.map((e=>({type:"LineString",coordinates:e}))):"MultiPoint"===e.type?e.coordinates.map((e=>({type:"Point",coordinates:e}))):[e]}class Mn{constructor(e,s){this.type=li,this.geojson=e,this.geometries=s}static parse(e,s){if(2!==e.length)return s.error(`'distance' expression requires exactly one argument, but found ${e.length-1} instead.`);if(Sr(e[1])){const s=e[1];if("FeatureCollection"===s.type)return new Mn(s,s.features.map((e=>es(e.geometry))).flat());if("Feature"===s.type)return new Mn(s,es(s.geometry));if("type"in s&&"coordinates"in s)return new Mn(s,es(s))}return s.error("'distance' expression requires valid geojson object that contains polygon geometry type.")}evaluate(e){if(null!=e.geometry()&&null!=e.canonicalID()){if("Point"===e.geometryType())return function(e,s){const l=e.geometry(),c=l.flat().map((s=>nn([s.x,s.y],e.canonical)));if(0===l.length)return NaN;const d=new on(c[0][1]);let p=1/0;for(const e of s){switch(e.type){case"Point":p=Math.min(p,Jn(c,!1,[e.coordinates],!1,d,p));break;case"LineString":p=Math.min(p,Jn(c,!1,e.coordinates,!0,d,p));break;case"Polygon":p=Math.min(p,Qn(c,!1,e.coordinates,d,p))}if(0===p)return p}return p}(e,this.geometries);if("LineString"===e.geometryType())return function(e,s){const l=e.geometry(),c=l.flat().map((s=>nn([s.x,s.y],e.canonical)));if(0===l.length)return NaN;const d=new on(c[0][1]);let p=1/0;for(const e of s){switch(e.type){case"Point":p=Math.min(p,Jn(c,!0,[e.coordinates],!1,d,p));break;case"LineString":p=Math.min(p,Jn(c,!0,e.coordinates,!0,d,p));break;case"Polygon":p=Math.min(p,Qn(c,!0,e.coordinates,d,p))}if(0===p)return p}return p}(e,this.geometries);if("Polygon"===e.geometryType())return function(e,s){const l=e.geometry();if(0===l.length||0===l[0].length)return NaN;const c=Sn(l,0).map((s=>s.map((s=>s.map((s=>nn([s.x,s.y],e.canonical))))))),d=new on(c[0][0][0][1]);let p=1/0;for(const e of s)for(const s of c){switch(e.type){case"Point":p=Math.min(p,Qn([e.coordinates],!1,s,d,p));break;case"LineString":p=Math.min(p,Qn(e.coordinates,!0,s,d,p));break;case"Polygon":p=Math.min(p,Xn(s,e.coordinates,d,p))}if(0===p)return p}return p}(e,this.geometries)}return NaN}eachChild(){}outputDefined(){return!0}}class Fn{constructor(e){this.type=_i,this.key=e}static parse(e,s){if(2!==e.length)return s.error(`Expected 1 argument, but found ${e.length-1} instead.`);const l=e[1];return null==l?s.error("Global state property must be defined."):"string"!=typeof l?s.error(`Global state property must be string, but found ${typeof e[1]} instead.`):new Fn(l)}evaluate(e){var s;const l=null===(s=e.globals)||void 0===s?void 0:s.globalState;return l&&0!==Object.keys(l).length?ur(l,this.key):null}eachChild(){}outputDefined(){return!1}}const ns={"==":Xr,"!=":Yr,">":Qr,"<":Kr,">=":en,"<=":Jr,array:Xe,at:tr,boolean:Xe,case:ir,coalesce:mr,collator:Er,format:Ir,image:Mr,in:er,"index-of":rr,interpolate:fr,"interpolate-hcl":fr,"interpolate-lab":fr,length:Fr,let:Je,literal:je,match:nr,number:Xe,"number-format":Tr,object:Xe,slice:sr,step:or,string:Xe,"to-boolean":Ze,"to-color":Ze,"to-number":Ze,"to-string":Ze,var:Qe,within:Hr,distance:Mn,"global-state":Fn};class zn{constructor(e,s,l,c){this.name=e,this.type=s,this._evaluate=l,this.args=c}evaluate(e){return this._evaluate(e,this.args)}eachChild(e){this.args.forEach(e)}outputDefined(){return!1}static parse(e,s){const l=e[0],c=zn.definitions[l];if(!c)return s.error(`Unknown expression "${l}". If you wanted a literal array, use ["literal", [...]].`,0);const d=Array.isArray(c)?c[0]:c.type,p=Array.isArray(c)?[[c[1],c[2]]]:c.overloads,f=p.filter((([s])=>!Array.isArray(s)||s.length===e.length-1));let m=null;for(const[c,p]of f){m=new We(s.registry,ps,s.path,null,s.scope);const f=[];let _=!1;for(let s=1;s{return s=e,Array.isArray(s)?`(${s.map(Ci).join(", ")})`:`(${Ci(s.type)}...)`;var s})).join(" | "),c=[];for(let l=1;l{l=s?l&&ps(e):l&&e instanceof je})),!!l&&fs(e)&&gs(e,["zoom","heatmap-density","elevation","line-progress","accumulated","is-supported-script"])}function fs(e){if(e instanceof zn){if("get"===e.name&&1===e.args.length)return!1;if("feature-state"===e.name)return!1;if("has"===e.name&&1===e.args.length)return!1;if("properties"===e.name||"geometry-type"===e.name||"id"===e.name)return!1;if(/^filter-/.test(e.name))return!1}if(e instanceof Hr)return!1;if(e instanceof Mn)return!1;let s=!0;return e.eachChild((e=>{s&&!fs(e)&&(s=!1)})),s}function _s(e){if(e instanceof zn&&"feature-state"===e.name)return!1;let s=!0;return e.eachChild((e=>{s&&!_s(e)&&(s=!1)})),s}function gs(e,s){if(e instanceof zn&&s.indexOf(e.name)>=0)return!1;let l=!0;return e.eachChild((e=>{l&&!gs(e,s)&&(l=!1)})),l}function ys(e){return{result:"success",value:e}}function vs(e){return{result:"error",value:e}}function bs(e){return"data-driven"===e["property-type"]||"cross-faded-data-driven"===e["property-type"]}function ws(e){return!!e.expression&&e.expression.parameters.indexOf("zoom")>-1}function Ts(e){return!!e.expression&&e.expression.interpolated}function Ss(e){return e instanceof Number?"number":e instanceof String?"string":e instanceof Boolean?"boolean":Array.isArray(e)?"array":null===e?"null":typeof e}function Ms(e){return"object"==typeof e&&null!==e&&!Array.isArray(e)&&Cr(e)===mi}function Is(e){return e}function Es(e,s){const l=e.stops&&"object"==typeof e.stops[0][0],c=l||!(l||void 0!==e.property),d=e.type||(Ts(s)?"exponential":"interval"),p=function(e){switch(e.type){case"color":return Te.parse;case"padding":return ze.parse;case"numberArray":return Pe.parse;case"colorArray":return Be.parse;default:return null}}(s);if(p&&((e=ri({},e)).stops&&(e.stops=e.stops.map((e=>[e[0],p(e[1])]))),e.default=p(e.default?e.default:s.default)),e.colorSpace&&"rgb"!==(f=e.colorSpace)&&"hcl"!==f&&"lab"!==f)throw new Error(`Unknown color space: "${e.colorSpace}"`);var f;const m=function(e){switch(e){case"exponential":return ks;case"interval":return zs;case"categorical":return Ds;case"identity":return Fs;default:throw new Error(`Unknown function type "${e}"`)}}(d);let _,g;if("categorical"===d){_=Object.create(null);for(const s of e.stops)_[s[0]]=s[1];g=typeof e.stops[0][0]}if(l){const l={},c=[];for(let s=0;se[0])),evaluate:({zoom:l},c)=>ks({stops:d,base:e.base},s,l).evaluate(l,c)}}if(c){const l="exponential"===d?{name:"exponential",base:void 0!==e.base?e.base:1}:null;return{kind:"camera",interpolationType:l,interpolationFactor:fr.interpolationFactor.bind(void 0,l),zoomStops:e.stops.map((e=>e[0])),evaluate:({zoom:l})=>m(e,s,l,_,g)}}return{kind:"source",evaluate(l,c){const d=c&&c.properties?c.properties[e.property]:void 0;return void 0===d?As(e.default,s.default):m(e,s,d,_,g)}}}function As(e,s,l){return void 0!==e?e:void 0!==s?s:void 0!==l?l:void 0}function Ds(e,s,l,c,d){return As(typeof l===d?c[l]:void 0,e.default,s.default)}function zs(e,s,l){if("number"!==Ss(l))return As(e.default,s.default);const c=e.stops.length;if(1===c)return e.stops[0][1];if(l<=e.stops[0][0])return e.stops[0][1];if(l>=e.stops[c-1][0])return e.stops[c-1][1];const d=Rr(e.stops.map((e=>e[0])),l);return e.stops[d][1]}function ks(e,s,l){const c=void 0!==e.base?e.base:1;if("number"!==Ss(l))return As(e.default,s.default);const d=e.stops.length;if(1===d)return e.stops[0][1];if(l<=e.stops[0][0])return e.stops[0][1];if(l>=e.stops[d-1][0])return e.stops[d-1][1];const p=Rr(e.stops.map((e=>e[0])),l),f=function(e,s,l,c){const d=c-l,p=e-l;return 0===d?0:1===s?p/d:(Math.pow(s,p)-1)/(Math.pow(s,d)-1)}(l,c,e.stops[p][0],e.stops[p+1][0]),m=e.stops[p][1],_=e.stops[p+1][1],g=Gr[s.type]||Is;return"function"==typeof m.evaluate?{evaluate(...s){const l=m.evaluate.apply(void 0,s),c=_.evaluate.apply(void 0,s);if(void 0!==l&&void 0!==c)return g(l,c,f,e.colorSpace)}}:g(m,_,f,e.colorSpace)}function Fs(e,s,l){switch(s.type){case"color":l=Te.parse(l);break;case"formatted":l=De.fromString(l.toString());break;case"resolvedImage":l=Oe.fromString(l.toString());break;case"padding":l=ze.parse(l);break;case"colorArray":l=Be.parse(l);break;case"numberArray":l=Pe.parse(l);break;default:Ss(l)===s.type||"enum"===s.type&&s.values[l]||(l=void 0)}return As(l,e.default,s.default)}zn.register(ns,{error:[{kind:"error"},[ci],(e,[s])=>{throw new Ve(s.evaluate(e))}],typeof:[ci,[_i],(e,[s])=>Ci(Cr(s.evaluate(e)))],"to-rgba":[Ei(li,4),[pi],(e,[s])=>{const[l,c,d,p]=s.evaluate(e).rgb;return[255*l,255*c,255*d,p]}],rgb:[pi,[li,li,li],ss],rgba:[pi,[li,li,li,li],ss],has:{type:ui,overloads:[[[ci],(e,[s])=>ls(s.evaluate(e),e.properties())],[[ci,mi],(e,[s,l])=>ls(s.evaluate(e),l.evaluate(e))]]},get:{type:_i,overloads:[[[ci],(e,[s])=>us(s.evaluate(e),e.properties())],[[ci,mi],(e,[s,l])=>us(s.evaluate(e),l.evaluate(e))]]},"feature-state":[_i,[ci],(e,[s])=>us(s.evaluate(e),e.featureState||{})],properties:[mi,[],e=>e.properties()],"geometry-type":[ci,[],e=>e.geometryType()],id:[_i,[],e=>e.id()],zoom:[li,[],e=>e.globals.zoom],"heatmap-density":[li,[],e=>e.globals.heatmapDensity||0],elevation:[li,[],e=>e.globals.elevation||0],"line-progress":[li,[],e=>e.globals.lineProgress||0],accumulated:[_i,[],e=>void 0===e.globals.accumulated?null:e.globals.accumulated],"+":[li,ds(li),(e,s)=>{let l=0;for(const c of s)l+=c.evaluate(e);return l}],"*":[li,ds(li),(e,s)=>{let l=1;for(const c of s)l*=c.evaluate(e);return l}],"-":{type:li,overloads:[[[li,li],(e,[s,l])=>s.evaluate(e)-l.evaluate(e)],[[li],(e,[s])=>-s.evaluate(e)]]},"/":[li,[li,li],(e,[s,l])=>s.evaluate(e)/l.evaluate(e)],"%":[li,[li,li],(e,[s,l])=>s.evaluate(e)%l.evaluate(e)],ln2:[li,[],()=>Math.LN2],pi:[li,[],()=>Math.PI],e:[li,[],()=>Math.E],"^":[li,[li,li],(e,[s,l])=>Math.pow(s.evaluate(e),l.evaluate(e))],sqrt:[li,[li],(e,[s])=>Math.sqrt(s.evaluate(e))],log10:[li,[li],(e,[s])=>Math.log(s.evaluate(e))/Math.LN10],ln:[li,[li],(e,[s])=>Math.log(s.evaluate(e))],log2:[li,[li],(e,[s])=>Math.log(s.evaluate(e))/Math.LN2],sin:[li,[li],(e,[s])=>Math.sin(s.evaluate(e))],cos:[li,[li],(e,[s])=>Math.cos(s.evaluate(e))],tan:[li,[li],(e,[s])=>Math.tan(s.evaluate(e))],asin:[li,[li],(e,[s])=>Math.asin(s.evaluate(e))],acos:[li,[li],(e,[s])=>Math.acos(s.evaluate(e))],atan:[li,[li],(e,[s])=>Math.atan(s.evaluate(e))],min:[li,ds(li),(e,s)=>Math.min(...s.map((s=>s.evaluate(e))))],max:[li,ds(li),(e,s)=>Math.max(...s.map((s=>s.evaluate(e))))],abs:[li,[li],(e,[s])=>Math.abs(s.evaluate(e))],round:[li,[li],(e,[s])=>{const l=s.evaluate(e);return l<0?-Math.round(-l):Math.round(l)}],floor:[li,[li],(e,[s])=>Math.floor(s.evaluate(e))],ceil:[li,[li],(e,[s])=>Math.ceil(s.evaluate(e))],"filter-==":[ui,[ci,_i],(e,[s,l])=>e.properties()[s.value]===l.value],"filter-id-==":[ui,[_i],(e,[s])=>e.id()===s.value],"filter-type-==":[ui,[ci],(e,[s])=>e.geometryType()===s.value],"filter-<":[ui,[ci,_i],(e,[s,l])=>{const c=e.properties()[s.value],d=l.value;return typeof c==typeof d&&c{const l=e.id(),c=s.value;return typeof l==typeof c&&l":[ui,[ci,_i],(e,[s,l])=>{const c=e.properties()[s.value],d=l.value;return typeof c==typeof d&&c>d}],"filter-id->":[ui,[_i],(e,[s])=>{const l=e.id(),c=s.value;return typeof l==typeof c&&l>c}],"filter-<=":[ui,[ci,_i],(e,[s,l])=>{const c=e.properties()[s.value],d=l.value;return typeof c==typeof d&&c<=d}],"filter-id-<=":[ui,[_i],(e,[s])=>{const l=e.id(),c=s.value;return typeof l==typeof c&&l<=c}],"filter->=":[ui,[ci,_i],(e,[s,l])=>{const c=e.properties()[s.value],d=l.value;return typeof c==typeof d&&c>=d}],"filter-id->=":[ui,[_i],(e,[s])=>{const l=e.id(),c=s.value;return typeof l==typeof c&&l>=c}],"filter-has":[ui,[_i],(e,[s])=>s.value in e.properties()],"filter-has-id":[ui,[],e=>null!==e.id()&&void 0!==e.id()],"filter-type-in":[ui,[Ei(ci)],(e,[s])=>s.value.indexOf(e.geometryType())>=0],"filter-id-in":[ui,[Ei(_i)],(e,[s])=>s.value.indexOf(e.id())>=0],"filter-in-small":[ui,[ci,Ei(_i)],(e,[s,l])=>l.value.indexOf(e.properties()[s.value])>=0],"filter-in-large":[ui,[ci,Ei(_i)],(e,[s,l])=>function(e,s,l,c){for(;l<=c;){const d=l+c>>1;if(s[d]===e)return!0;s[d]>e?c=d-1:l=d+1}return!1}(e.properties()[s.value],l.value,0,l.value.length-1)],all:{type:ui,overloads:[[[ui,ui],(e,[s,l])=>s.evaluate(e)&&l.evaluate(e)],[ds(ui),(e,s)=>{for(const l of s)if(!l.evaluate(e))return!1;return!0}]]},any:{type:ui,overloads:[[[ui,ui],(e,[s,l])=>s.evaluate(e)||l.evaluate(e)],[ds(ui),(e,s)=>{for(const l of s)if(l.evaluate(e))return!0;return!1}]]},"!":[ui,[ui],(e,[s])=>!s.evaluate(e)],"is-supported-script":[ui,[ci],(e,[s])=>{const l=e.globals&&e.globals.isSupportedScript;return!l||l(s.evaluate(e))}],upcase:[ci,[ci],(e,[s])=>s.evaluate(e).toUpperCase()],downcase:[ci,[ci],(e,[s])=>s.evaluate(e).toLowerCase()],concat:[ci,ds(_i),(e,s)=>s.map((s=>Ar(s.evaluate(e)))).join("")],"resolved-locale":[ci,[gi],(e,[s])=>s.evaluate(e).resolvedLocale()]});class ei{constructor(e,s,l){this.expression=e,this._warningHistory={},this._evaluator=new Ke,this._defaultValue=s?function(e){if("color"===e.type&&Ms(e.default))return new Te(0,0,0,0);switch(e.type){case"color":return Te.parse(e.default)||null;case"padding":return ze.parse(e.default)||null;case"numberArray":return Pe.parse(e.default)||null;case"colorArray":return Be.parse(e.default)||null;case"variableAnchorOffsetCollection":return Le.parse(e.default)||null;case"projectionDefinition":return Re.parse(e.default)||null;default:return void 0===e.default?null:e.default}}(s):null,this._enumValues=s&&"enum"===s.type?s.values:null,this._globalState=l}evaluateWithoutErrorHandling(e,s,l,c,d,p){return this._globalState&&(e=fo(e,this._globalState)),this._evaluator.globals=e,this._evaluator.feature=s,this._evaluator.featureState=l,this._evaluator.canonical=c,this._evaluator.availableImages=d||null,this._evaluator.formattedSection=p,this.expression.evaluate(this._evaluator)}evaluate(e,s,l,c,d,p){this._globalState&&(e=fo(e,this._globalState)),this._evaluator.globals=e,this._evaluator.feature=s||null,this._evaluator.featureState=l||null,this._evaluator.canonical=c,this._evaluator.availableImages=d||null,this._evaluator.formattedSection=p||null;try{const e=this.expression.evaluate(this._evaluator);if(null==e||"number"==typeof e&&e!=e)return this._defaultValue;if(this._enumValues&&!(e in this._enumValues))throw new Ve(`Expected value to be one of ${Object.keys(this._enumValues).map((e=>JSON.stringify(e))).join(", ")}, but found ${JSON.stringify(e)} instead.`);return e}catch(e){return this._warningHistory[e.message]||(this._warningHistory[e.message]=!0,"undefined"!=typeof console&&console.warn(e.message)),this._defaultValue}}}function Bs(e){return Array.isArray(e)&&e.length>0&&"string"==typeof e[0]&&e[0]in ns}function Vs(e,s,l){const c=new We(ns,ps,[],s?function(e){const s={color:pi,string:ci,number:li,enum:ci,boolean:ui,formatted:yi,padding:xi,numberArray:bi,colorArray:vi,projectionDefinition:fi,resolvedImage:wi,variableAnchorOffsetCollection:Ii};return"array"===e.type?Ei(s[e.value]||_i,e.length):s[e.type]}(s):void 0),d=c.parse(e,void 0,void 0,void 0,s&&"string"===s.type?{typeAnnotation:"coerce"}:void 0);return d?ys(new ei(d,s,l)):vs(c.errors)}class ii{constructor(e,s,l){this.kind=e,this._styleExpression=s,this.isStateDependent="constant"!==e&&!_s(s.expression),this.globalStateRefs=ho(s.expression),this._globalState=l}evaluateWithoutErrorHandling(e,s,l,c,d,p){return this._globalState&&(e=fo(e,this._globalState)),this._styleExpression.evaluateWithoutErrorHandling(e,s,l,c,d,p)}evaluate(e,s,l,c,d,p){return this._globalState&&(e=fo(e,this._globalState)),this._styleExpression.evaluate(e,s,l,c,d,p)}}class si{constructor(e,s,l,c,d){this.kind=e,this.zoomStops=l,this._styleExpression=s,this.isStateDependent="camera"!==e&&!_s(s.expression),this.globalStateRefs=ho(s.expression),this.interpolationType=c,this._globalState=d}evaluateWithoutErrorHandling(e,s,l,c,d,p){return this._globalState&&(e=fo(e,this._globalState)),this._styleExpression.evaluateWithoutErrorHandling(e,s,l,c,d,p)}evaluate(e,s,l,c,d,p){return this._globalState&&(e=fo(e,this._globalState)),this._styleExpression.evaluate(e,s,l,c,d,p)}interpolationFactor(e,s,l){return this.interpolationType?fr.interpolationFactor(this.interpolationType,e,s,l):0}}function Ws(e,s,l){const c=Vs(e,s,l);if("error"===c.result)return c;const d=c.value.expression,p=fs(d);if(!p&&!bs(s))return vs([new Pt("","data expressions not supported")]);const f=gs(d,["zoom"]);if(!f&&!ws(s))return vs([new Pt("","zoom expressions not supported")]);const m=Js(d);return m||f?m instanceof Pt?vs([m]):m instanceof fr&&!Ts(s)?vs([new Pt("",'"interpolate" expressions cannot be used with this property')]):ys(m?new si(p?"camera":"composite",c.value,m.labels,m instanceof fr?m.interpolation:void 0,l):new ii(p?"constant":"source",c.value,l)):vs([new Pt("",'"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression.')])}class oi{constructor(e,s){this._parameters=e,this._specification=s,ri(this,Es(this._parameters,this._specification))}static deserialize(e){return new oi(e._parameters,e._specification)}static serialize(e){return{_parameters:e._parameters,_specification:e._specification}}}function Js(e){let s=null;if(e instanceof Je)s=Js(e.result);else if(e instanceof mr){for(const l of e.args)if(s=Js(l),s)break}else(e instanceof or||e instanceof fr)&&e.input instanceof zn&&"zoom"===e.input.name&&(s=e);return s instanceof Pt||e.eachChild((e=>{const l=Js(e);l instanceof Pt?s=l:!s&&l?s=new Pt("",'"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression.'):s&&l&&s!==l&&(s=new Pt("",'Only one zoom-based "step" or "interpolate" subexpression may be used in an expression.'))})),s}function ho(e,s=new Set){return e instanceof Fn&&s.add(e.key),e.eachChild((e=>{ho(e,s)})),s}function fo(e,s){const{zoom:l,heatmapDensity:c,elevation:d,lineProgress:p,isSupportedScript:f,accumulated:m}=null!=e?e:{};return{zoom:l,heatmapDensity:c,elevation:d,lineProgress:p,isSupportedScript:f,accumulated:m,globalState:s}}function vo(e){if(!0===e||!1===e)return!0;if(!Array.isArray(e)||0===e.length)return!1;switch(e[0]){case"has":return e.length>=2&&"$id"!==e[1]&&"$type"!==e[1];case"in":return e.length>=3&&("string"!=typeof e[1]||Array.isArray(e[2]));case"!in":case"!has":case"none":return!1;case"==":case"!=":case">":case">=":case"<":case"<=":return 3!==e.length||Array.isArray(e[1])||Array.isArray(e[2]);case"any":case"all":for(const s of e.slice(1))if(!vo(s)&&"boolean"!=typeof s)return!1;return!0;default:return!0}}const Eo={type:"boolean",default:!1,transition:!1,"property-type":"data-driven",expression:{interpolated:!1,parameters:["zoom","feature"]}};function Co(e,s){if(null==e)return{filter:()=>!0,needGeometry:!1,getGlobalStateRefs:()=>new Set};vo(e)||(e=Lo(e));const l=Vs(e,Eo,s);if("error"===l.result)throw new Error(l.value.map((e=>`${e.key}: ${e.message}`)).join(", "));return{filter:(e,s,c)=>l.value.evaluate(e,s,{},c),needGeometry:Ro(e),getGlobalStateRefs:()=>ho(l.value.expression)}}function ko(e,s){return es?1:0}function Ro(e){if(!Array.isArray(e))return!1;if("within"===e[0]||"distance"===e[0])return!0;for(let s=1;s"===s||"<="===s||">="===s?qo(e[1],e[2],s):"any"===s?(l=e.slice(1),["any"].concat(l.map(Lo))):"all"===s?["all"].concat(e.slice(1).map(Lo)):"none"===s?["all"].concat(e.slice(1).map(Lo).map(ta)):"in"===s?$o(e[1],e.slice(2)):"!in"===s?ta($o(e[1],e.slice(2))):"has"===s?Ko(e[1]):"!has"!==s||ta(Ko(e[1]));var l}function qo(e,s,l){switch(e){case"$type":return[`filter-type-${l}`,s];case"$id":return[`filter-id-${l}`,s];default:return[`filter-${l}`,e,s]}}function $o(e,s){if(0===s.length)return!1;switch(e){case"$type":return["filter-type-in",["literal",s]];case"$id":return["filter-id-in",["literal",s]];default:return s.length>200&&!s.some((e=>typeof e!=typeof s[0]))?["filter-in-large",e,["literal",s.sort(ko)]]:["filter-in-small",e,["literal",s]]}}function Ko(e){switch(e){case"$type":return!0;case"$id":return["filter-has-id"];default:return["filter-has",e]}}function ta(e){return["!",e]}function ia(e){const s=typeof e;if("number"===s||"boolean"===s||"string"===s||null==e)return JSON.stringify(e);if(Array.isArray(e)){let s="[";for(const l of e)s+=`${ia(l)},`;return`${s}]`}const l=Object.keys(e).sort();let c="{";for(let s=0;sc.maximum?[new Dt(s,l,`${l} is greater than the maximum value ${c.maximum}`)]:[]}function ol(e){const s=e.valueSpec,l=tl(e.value.type);let c,d,p,f={};const m="categorical"!==l&&void 0===e.value.property,_=!m,g="array"===Ss(e.value.stops)&&"array"===Ss(e.value.stops[0])&&"object"===Ss(e.value.stops[0][0]),y=rl({key:e.key,value:e.value,valueSpec:e.styleSpec.function,validateSpec:e.validateSpec,style:e.style,styleSpec:e.styleSpec,objectElementValidators:{stops:function(e){if("identity"===l)return[new Dt(e.key,e.value,'identity function may not have a "stops" property')];let s=[];const c=e.value;return s=s.concat(nl({key:e.key,value:c,valueSpec:e.valueSpec,validateSpec:e.validateSpec,style:e.style,styleSpec:e.styleSpec,arrayElementValidator:b})),"array"===Ss(c)&&0===c.length&&s.push(new Dt(e.key,c,"array must have at least one stop")),s},default:function(e){return e.validateSpec({key:e.key,value:e.value,valueSpec:s,validateSpec:e.validateSpec,style:e.style,styleSpec:e.styleSpec})}}});return"identity"===l&&m&&y.push(new Dt(e.key,e.value,'missing required property "property"')),"identity"===l||e.value.stops||y.push(new Dt(e.key,e.value,'missing required property "stops"')),"exponential"===l&&e.valueSpec.expression&&!Ts(e.valueSpec)&&y.push(new Dt(e.key,e.value,"exponential functions not supported")),e.styleSpec.$version>=8&&(_&&!bs(e.valueSpec)?y.push(new Dt(e.key,e.value,"property functions not supported")):m&&!ws(e.valueSpec)&&y.push(new Dt(e.key,e.value,"zoom functions not supported"))),"categorical"!==l&&!g||void 0!==e.value.property||y.push(new Dt(e.key,e.value,'"property" property is required')),y;function b(e){let l=[];const c=e.value,m=e.key;if("array"!==Ss(c))return[new Dt(m,c,`array expected, ${Ss(c)} found`)];if(2!==c.length)return[new Dt(m,c,`array length 2 expected, length ${c.length} found`)];if(g){if("object"!==Ss(c[0]))return[new Dt(m,c,`object expected, ${Ss(c[0])} found`)];if(void 0===c[0].zoom)return[new Dt(m,c,"object stop key must have zoom")];if(void 0===c[0].value)return[new Dt(m,c,"object stop key must have value")];if(p&&p>tl(c[0].zoom))return[new Dt(m,c[0].zoom,"stop zoom values must appear in ascending order")];tl(c[0].zoom)!==p&&(p=tl(c[0].zoom),d=void 0,f={}),l=l.concat(rl({key:`${m}[0]`,value:c[0],valueSpec:{zoom:{}},validateSpec:e.validateSpec,style:e.style,styleSpec:e.styleSpec,objectElementValidators:{zoom:sl,value:T}}))}else l=l.concat(T({key:`${m}[0]`,value:c[0],validateSpec:e.validateSpec,style:e.style,styleSpec:e.styleSpec},c));return Bs(il(c[1]))?l.concat([new Dt(`${m}[1]`,c[1],"expressions are not allowed in function stops.")]):l.concat(e.validateSpec({key:`${m}[1]`,value:c[1],valueSpec:s,validateSpec:e.validateSpec,style:e.style,styleSpec:e.styleSpec}))}function T(e,p){const m=Ss(e.value),_=tl(e.value),g=null!==e.value?e.value:p;if(c){if(m!==c)return[new Dt(e.key,g,`${m} stop domain type must match previous stop domain type ${c}`)]}else c=m;if("number"!==m&&"string"!==m&&"boolean"!==m)return[new Dt(e.key,g,"stop domain value must be a number, string, or boolean")];if("number"!==m&&"categorical"!==l){let c=`number expected, ${m} found`;return bs(s)&&void 0===l&&(c+='\nIf you intended to use a categorical function, specify `"type": "categorical"`.'),[new Dt(e.key,g,c)]}return"categorical"!==l||"number"!==m||isFinite(_)&&Math.floor(_)===_?"categorical"!==l&&"number"===m&&void 0!==d&&_new Dt(`${e.key}${s.key}`,e.value,s.message)));const l=s.value.expression||s.value._styleExpression.expression;if("property"===e.expressionContext&&"text-font"===e.propertyKey&&!l.outputDefined())return[new Dt(e.key,e.value,`Invalid data expression for "${e.propertyKey}". Output values must be contained as literals within the expression.`)];if("property"===e.expressionContext&&"layout"===e.propertyType&&!_s(l))return[new Dt(e.key,e.value,'"feature-state" data expressions are not supported with layout properties.')];if("filter"===e.expressionContext&&!_s(l))return[new Dt(e.key,e.value,'"feature-state" data expressions are not supported with filters.')];if(e.expressionContext&&0===e.expressionContext.indexOf("cluster")){if(!gs(l,["zoom","feature-state"]))return[new Dt(e.key,e.value,'"zoom" and "feature-state" expressions are not supported with cluster properties.')];if("cluster-initial"===e.expressionContext&&!fs(l))return[new Dt(e.key,e.value,"Feature data expressions are not supported with initial expression part of cluster properties.")]}return[]}function ll(e){const s=e.key,l=e.value,c=Ss(l);return"string"!==c?[new Dt(s,l,`color expected, ${c} found`)]:Te.parse(String(l))?[]:[new Dt(s,l,`color expected, "${l}" found`)]}function cl(e){const s=e.key,l=e.value,c=e.valueSpec,d=[];return Array.isArray(c.values)?-1===c.values.indexOf(tl(l))&&d.push(new Dt(s,l,`expected one of [${c.values.join(", ")}], ${JSON.stringify(l)} found`)):-1===Object.keys(c.values).indexOf(tl(l))&&d.push(new Dt(s,l,`expected one of [${Object.keys(c.values).join(", ")}], ${JSON.stringify(l)} found`)),d}function hl(e){return vo(il(e.value))?al(ri({},e,{expressionContext:"filter",valueSpec:{value:"boolean"}})):ul(e)}function ul(e){const s=e.value,l=e.key;if("array"!==Ss(s))return[new Dt(l,s,`array expected, ${Ss(s)} found`)];const c=e.styleSpec;let d,p=[];if(s.length<1)return[new Dt(l,s,"filter array must have at least 1 element")];switch(p=p.concat(cl({key:`${l}[0]`,value:s[0],valueSpec:c.filter_operator,style:e.style,styleSpec:e.styleSpec})),tl(s[0])){case"<":case"<=":case">":case">=":s.length>=2&&"$type"===tl(s[1])&&p.push(new Dt(l,s,`"$type" cannot be use with operator "${s[0]}"`));case"==":case"!=":3!==s.length&&p.push(new Dt(l,s,`filter array for operator "${s[0]}" must have 3 elements`));case"in":case"!in":s.length>=2&&(d=Ss(s[1]),"string"!==d&&p.push(new Dt(`${l}[1]`,s[1],`string expected, ${d} found`)));for(let f=2;f{e in l&&s.push(new Dt(c,l[e],`"${e}" is prohibited for ref layers`))})),d.layers.forEach((s=>{tl(s.id)===m&&(e=s)})),e?e.ref?s.push(new Dt(c,l.ref,"ref cannot reference another ref layer")):f=tl(e.type):s.push(new Dt(c,l.ref,`ref layer "${m}" not found`))}else if("background"!==f)if(l.source){const e=d.sources&&d.sources[l.source],p=e&&tl(e.type);e?"vector"===p&&"raster"===f?s.push(new Dt(c,l.source,`layer "${l.id}" requires a raster source`)):"raster-dem"!==p&&"hillshade"===f||"raster-dem"!==p&&"color-relief"===f?s.push(new Dt(c,l.source,`layer "${l.id}" requires a raster-dem source`)):"raster"===p&&"raster"!==f?s.push(new Dt(c,l.source,`layer "${l.id}" requires a vector source`)):"vector"!==p||l["source-layer"]?"raster-dem"===p&&"hillshade"!==f&&"color-relief"!==f?s.push(new Dt(c,l.source,"raster-dem source can only be used with layer type 'hillshade' or 'color-relief'.")):"line"!==f||!l.paint||!l.paint["line-gradient"]||"geojson"===p&&e.lineMetrics||s.push(new Dt(c,l,`layer "${l.id}" specifies a line-gradient, which requires a GeoJSON source with \`lineMetrics\` enabled.`)):s.push(new Dt(c,l,`layer "${l.id}" must specify a "source-layer"`)):s.push(new Dt(c,l.source,`source "${l.source}" not found`))}else s.push(new Dt(c,l,'missing required property "source"'));return s=s.concat(rl({key:c,value:l,valueSpec:p.layer,style:e.style,styleSpec:e.styleSpec,validateSpec:e.validateSpec,objectElementValidators:{"*":()=>[],type:()=>e.validateSpec({key:`${c}.type`,value:l.type,valueSpec:p.layer.type,style:e.style,styleSpec:e.styleSpec,validateSpec:e.validateSpec,object:l,objectKey:"type"}),filter:hl,layout:e=>rl({layer:l,key:e.key,value:e.value,style:e.style,styleSpec:e.styleSpec,validateSpec:e.validateSpec,objectElementValidators:{"*":e=>fl(ri({layerType:f},e))}}),paint:e=>rl({layer:l,key:e.key,value:e.value,style:e.style,styleSpec:e.styleSpec,validateSpec:e.validateSpec,objectElementValidators:{"*":e=>pl(ri({layerType:f},e))}})}})),s}function xl(e){const s=e.value,l=e.key,c=Ss(s);return"string"!==c?[new Dt(l,s,`string expected, ${c} found`)]:[]}const vl={promoteId:function({key:e,value:s}){if("string"===Ss(s))return xl({key:e,value:s});{const l=[];for(const c in s)l.push(...xl({key:`${e}.${c}`,value:s[c]}));return l}}};function bl(e){const s=e.value,l=e.key,c=e.styleSpec,d=e.style,p=e.validateSpec;if(!s.type)return[new Dt(l,s,'"type" is required')];const f=tl(s.type);let m;switch(f){case"vector":case"raster":return m=rl({key:l,value:s,valueSpec:c[`source_${f.replace("-","_")}`],style:e.style,styleSpec:c,objectElementValidators:vl,validateSpec:p}),m;case"raster-dem":return m=function(e){var s;const l=null!==(s=e.sourceName)&&void 0!==s?s:"",c=e.value,d=e.styleSpec,p=d.source_raster_dem,f=e.style;let m=[];const _=Ss(c);if(void 0===c)return m;if("object"!==_)return m.push(new Dt("source_raster_dem",c,`object expected, ${_} found`)),m;const g="custom"===tl(c.encoding),y=["redFactor","greenFactor","blueFactor","baseShift"],b=e.value.encoding?`"${e.value.encoding}"`:"Default";for(const s in c)!g&&y.includes(s)?m.push(new Dt(s,c[s],`In "${l}": "${s}" is only valid when "encoding" is set to "custom". ${b} encoding found`)):p[s]?m=m.concat(e.validateSpec({key:s,value:c[s],valueSpec:p[s],validateSpec:e.validateSpec,style:f,styleSpec:d})):m.push(new Dt(s,c[s],`unknown property "${s}"`));return m}({sourceName:l,value:s,style:e.style,styleSpec:c,validateSpec:p}),m;case"geojson":if(m=rl({key:l,value:s,valueSpec:c.source_geojson,style:d,styleSpec:c,validateSpec:p,objectElementValidators:vl}),s.cluster)for(const e in s.clusterProperties){const[c,d]=s.clusterProperties[e],p="string"==typeof c?[c,["accumulated"],["get",e]]:c;m.push(...al({key:`${l}.${e}.map`,value:d,expressionContext:"cluster-map"})),m.push(...al({key:`${l}.${e}.reduce`,value:p,expressionContext:"cluster-reduce"}))}return m;case"video":return rl({key:l,value:s,valueSpec:c.source_video,style:d,validateSpec:p,styleSpec:c});case"image":return rl({key:l,value:s,valueSpec:c.source_image,style:d,validateSpec:p,styleSpec:c});case"canvas":return[new Dt(l,null,"Please use runtime APIs to add canvas sources, rather than including them in stylesheets.","source.canvas")];default:return cl({key:`${l}.type`,value:s.type,valueSpec:{values:["vector","raster","raster-dem","geojson","video","image"]}})}}function wl(e){const s=e.value,l=e.styleSpec,c=l.light,d=e.style;let p=[];const f=Ss(s);if(void 0===s)return p;if("object"!==f)return p=p.concat([new Dt("light",s,`object expected, ${f} found`)]),p;for(const f in s){const m=f.match(/^(.*)-transition$/);p=p.concat(m&&c[m[1]]&&c[m[1]].transition?e.validateSpec({key:f,value:s[f],valueSpec:l.transition,validateSpec:e.validateSpec,style:d,styleSpec:l}):c[f]?e.validateSpec({key:f,value:s[f],valueSpec:c[f],validateSpec:e.validateSpec,style:d,styleSpec:l}):[new Dt(f,s[f],`unknown property "${f}"`)])}return p}function Tl(e){const s=e.value,l=e.styleSpec,c=l.sky,d=e.style,p=Ss(s);if(void 0===s)return[];if("object"!==p)return[new Dt("sky",s,`object expected, ${p} found`)];let f=[];for(const p in s)f=f.concat(c[p]?e.validateSpec({key:p,value:s[p],valueSpec:c[p],style:d,styleSpec:l}):[new Dt(p,s[p],`unknown property "${p}"`)]);return f}function Il(e){const s=e.value,l=e.styleSpec,c=l.terrain,d=e.style;let p=[];const f=Ss(s);if(void 0===s)return p;if("object"!==f)return p=p.concat([new Dt("terrain",s,`object expected, ${f} found`)]),p;for(const f in s)p=p.concat(c[f]?e.validateSpec({key:f,value:s[f],valueSpec:c[f],validateSpec:e.validateSpec,style:d,styleSpec:l}):[new Dt(f,s[f],`unknown property "${f}"`)]);return p}function Cl(e){let s=[];const l=e.value,c=e.key;if(Array.isArray(l)){const d=[],p=[];for(const f in l)l[f].id&&d.includes(l[f].id)&&s.push(new Dt(c,l,`all the sprites' ids must be unique, but ${l[f].id} is duplicated`)),d.push(l[f].id),l[f].url&&p.includes(l[f].url)&&s.push(new Dt(c,l,`all the sprites' URLs must be unique, but ${l[f].url} is duplicated`)),p.push(l[f].url),s=s.concat(rl({key:`${c}[${f}]`,value:l[f],valueSpec:{id:{type:"string",required:!0},url:{type:"string",required:!0}},validateSpec:e.validateSpec}));return s}return xl({key:c,value:l})}function Al(e){return Boolean(e)&&e.constructor===Object}function Dl(e){return Al(e.value)?[]:[new Dt(e.key,e.value,`object expected, ${Ss(e.value)} found`)]}const kl={"*":()=>[],array:nl,boolean:function(e){const s=e.value,l=e.key,c=Ss(s);return"boolean"!==c?[new Dt(l,s,`boolean expected, ${c} found`)]:[]},number:sl,color:ll,constants:el,enum:cl,filter:hl,function:ol,layer:gl,object:rl,source:bl,light:wl,sky:Tl,terrain:Il,projection:function(e){const s=e.value,l=e.styleSpec,c=l.projection,d=e.style,p=Ss(s);if(void 0===s)return[];if("object"!==p)return[new Dt("projection",s,`object expected, ${p} found`)];let f=[];for(const p in s)f=f.concat(c[p]?e.validateSpec({key:p,value:s[p],valueSpec:c[p],style:d,styleSpec:l}):[new Dt(p,s[p],`unknown property "${p}"`)]);return f},projectionDefinition:function(e){const s=e.key;let l=e.value;l=l instanceof String?l.valueOf():l;const c=Ss(l);return"array"!==c||function(e){return Array.isArray(e)&&3===e.length&&"string"==typeof e[0]&&"string"==typeof e[1]&&"number"==typeof e[2]}(l)||function(e){return!!["interpolate","step","literal"].includes(e[0])}(l)?["array","string"].includes(c)?[]:[new Dt(s,l,`projection expected, invalid type "${c}" found`)]:[new Dt(s,l,`projection expected, invalid array ${JSON.stringify(l)} found`)]},string:xl,formatted:function(e){return 0===xl(e).length?[]:al(e)},resolvedImage:function(e){return 0===xl(e).length?[]:al(e)},padding:function(e){const s=e.key,l=e.value;if("array"===Ss(l)){if(l.length<1||l.length>4)return[new Dt(s,l,`padding requires 1 to 4 values; ${l.length} values found`)];const c={type:"number"};let d=[];for(let p=0;p[]}})),e.constants&&(l=l.concat(el({key:"constants",value:e.constants}))),Ol(l)}function Bl(e){return function(s){return e(Object.assign({},s,{validateSpec:Rl}))}}function Ol(e){return[].concat(e).sort(((e,s)=>e.line-s.line))}function jl(s){return function(...l){return Ol(s.apply(this||e,l))}}Fl.source=jl(Bl(bl)),Fl.sprite=jl(Bl(Cl)),Fl.glyphs=jl(Bl(Ll)),Fl.light=jl(Bl(wl)),Fl.sky=jl(Bl(Tl)),Fl.terrain=jl(Bl(Il)),Fl.state=jl(Bl(Dl)),Fl.layer=jl(Bl(gl)),Fl.filter=jl(Bl(hl)),Fl.paintProperty=jl(Bl(pl)),Fl.layoutProperty=jl(Bl(fl));const Nl={type:"enum","property-type":"data-constant",expression:{interpolated:!1,parameters:["global-state"]},values:{visible:{},none:{}},transition:!1,default:"visible"};class rs{constructor(e,s){this._globalState=s,this.setValue(e)}evaluate(){var e;return null!==(e=this._literalValue)&&void 0!==e?e:this._compiledValue.evaluate({})}setValue(e){if(null==e||"visible"===e||"none"===e)return this._literalValue="none"===e?"none":"visible",this._compiledValue=void 0,void(this._globalStateRefs=new Set);const s=Vs(e,Nl,this._globalState);if("error"===s.result)throw this._literalValue="visible",this._compiledValue=void 0,new Error(s.value.map((e=>`${e.key}: ${e.message}`)).join(", "));this._literalValue=void 0,this._compiledValue=s.value,this._globalStateRefs=ho(s.value.expression)}getGlobalStateRefs(){return this._globalStateRefs}}const Gl=Tt,Ul=Fl,ql=Ul.light,Zl=Ul.sky,$l=Ul.paintProperty,Wl=Ul.layoutProperty;function Hl(e,s){let l=!1;if(s&&s.length)for(const c of s)e.fire(new gt(new Error(c.message))),l=!0;return l}class cs{constructor(e,s,l){const c=this.cells=[];if(e instanceof ArrayBuffer){this.arrayBuffer=e;const d=new Int32Array(this.arrayBuffer);e=d[0],this.d=(s=d[1])+2*(l=d[2]);for(let e=0;e=g[_+0]&&c>=g[_+1])?(f[b]=!0,p.push(d[b])):f[b]=!1}}}}_forEachCell(e,s,l,c,d,p,f,m){const _=this._convertToCellCoord(e),g=this._convertToCellCoord(s),y=this._convertToCellCoord(l),b=this._convertToCellCoord(c);for(let T=_;T<=y;T++)for(let _=g;_<=b;_++){const g=this.d*_+T;if((!m||m(this._convertFromCellCoord(T),this._convertFromCellCoord(_),this._convertFromCellCoord(T+1),this._convertFromCellCoord(_+1)))&&d.call(this,e,s,l,c,g,p,f,m))return}}_convertFromCellCoord(e){return(e-this.padding)/this.scale}_convertToCellCoord(e){return Math.max(0,Math.min(this.d-1,Math.floor(e*this.scale)+this.padding))}toArrayBuffer(){if(this.arrayBuffer)return this.arrayBuffer;const e=this.cells,s=3+this.cells.length+1+1;let l=0;for(let e=0;e=0)continue;const p=e[c];d[c]=Xl[l].shallow.indexOf(c)>=0?p:ec(p,s)}e instanceof Error&&(d.message=e.message)}if(d.$name)throw new Error("$name property is reserved for worker serialization logic.");return"Object"!==l&&(d.$name=l),d}function rc(e){if(Jl(e))return e;if(Array.isArray(e))return e.map(rc);if("object"!=typeof e)throw new Error("can't deserialize object of type "+typeof e);const s=Ql(e)||"Object";if(!Xl[s])throw new Error(`can't deserialize unregistered class ${s}`);const{klass:l}=Xl[s];if(!l)throw new Error(`can't deserialize unregistered class ${s}`);if(l.deserialize)return l.deserialize(e);const c=Object.create(l.prototype);for(const l of Object.keys(e)){if("$name"===l)continue;const d=e[l];c[l]=Xl[s].shallow.indexOf(l)>=0?d:rc(d)}return c}class xs{constructor(){this.first=!0}update(e,s){const l=Math.floor(e);return this.first?(this.first=!1,this.lastIntegerZoom=l,this.lastIntegerZoomTime=0,this.lastZoom=e,this.lastFloorZoom=l,!0):(this.lastFloorZoom>l?(this.lastIntegerZoom=l+1,this.lastIntegerZoomTime=s):this.lastFloorZoom{try{return new RegExp(`\\p{sc=${e}}`,"u").source}catch(e){return null}})).filter((e=>e));return new RegExp(s.join("|"),"u")}const uc=hc(["Arab","Dupl","Mong","Ougr","Syrc"]);function dc(e){return!uc.test(String.fromCodePoint(e))}function pc(e){return!(sc(e)||(s=e,/[\xA7\xA9\xAE\xB1\xBC-\xBE\xD7\xF7\u2016\u2020\u2021\u2030\u2031\u203B\u203C\u2042\u2047-\u2049\u2051\u2100-\u218F\u221E\u2234\u2235\u2300-\u2307\u230C-\u231F\u2324-\u2328\u232B\u237D-\u239A\u23BE-\u23CD\u23CF\u23D1-\u23DB\u23E2-\u2422\u2424-\u24FF\u25A0-\u2619\u2620-\u2767\u2776-\u2793\u2B12-\u2B2F\u2B50-\u2B59\u2BB8-\u2BEB\u3000-\u303F\u30A0-\u30FF\uE000-\uF8FF\uFE30-\uFE6F\uFF00-\uFFEF\uFFFC\uFFFD]|[\uDB80-\uDBFF][\uDC00-\uDFFF]/gim.test(String.fromCodePoint(s))));var s}const fc=hc(["Adlm","Arab","Armi","Avst","Chrs","Cprt","Egyp","Elym","Gara","Hatr","Hebr","Hung","Khar","Lydi","Mand","Mani","Mend","Merc","Mero","Narb","Nbat","Nkoo","Orkh","Palm","Phli","Phlp","Phnx","Prti","Rohg","Samr","Sarb","Sogo","Syrc","Thaa","Todr","Yezi"]);function mc(e){return fc.test(String.fromCodePoint(e))}function _c(e,s){return!(!s&&mc(e)||/[\u0900-\u0DFF\u0F00-\u109F\u1780-\u17FF]/gim.test(String.fromCodePoint(e)))}function gc(e){for(const s of e)if(mc(s.codePointAt(0)))return!0;return!1}const yc=new class{constructor(){this.TIMEOUT=5e3,this.applyArabicShaping=null,this.processBidirectionalText=null,this.processStyledBidirectionalText=null,this.pluginStatus="unavailable",this.pluginURL=null,this.loadScriptResolve=()=>{}}setState(e){this.pluginStatus=e.pluginStatus,this.pluginURL=e.pluginURL}getState(){return{pluginStatus:this.pluginStatus,pluginURL:this.pluginURL}}setMethods(e){if(yc.isParsed())throw new Error("RTL text plugin already registered.");this.applyArabicShaping=e.applyArabicShaping,this.processBidirectionalText=e.processBidirectionalText,this.processStyledBidirectionalText=e.processStyledBidirectionalText,this.loadScriptResolve()}isParsed(){return null!=this.applyArabicShaping&&null!=this.processBidirectionalText&&null!=this.processStyledBidirectionalText}getRTLTextPluginStatus(){return this.pluginStatus}syncState(e,s){return l(this,void 0,void 0,(function*(){if(this.isParsed())return this.getState();if("loading"!==e.pluginStatus)return this.setState(e),e;const l=e.pluginURL,c=new Promise((e=>{this.loadScriptResolve=e}));s(l);const d=new Promise((e=>setTimeout((()=>e()),this.TIMEOUT)));if(yield Promise.race([c,d]),this.isParsed()){const e={pluginStatus:"loaded",pluginURL:l};return this.setState(e),e}throw this.setState({pluginStatus:"error",pluginURL:""}),new Error(`RTL Text Plugin failed to import scripts from ${l}`)}))}};class Ps{constructor(e,s){this.isSupportedScript=xc,this.zoom=e,s?(this.now=s.now||0,this.fadeDuration=s.fadeDuration||0,this.zoomHistory=s.zoomHistory||new xs,this.transition=s.transition||{}):(this.now=0,this.fadeDuration=0,this.zoomHistory=new xs,this.transition={})}crossFadingFactor(){return 0===this.fadeDuration?1:Math.min((this.now-this.zoomHistory.lastIntegerZoomTime)/this.fadeDuration,1)}getCrossfadeParameters(){const e=this.zoom,s=e-Math.floor(e),l=this.crossFadingFactor();return e>this.zoomHistory.lastIntegerZoom?{fromScale:2,toScale:1,t:s+(1-s)*l}:{fromScale:.5,toScale:1,t:1-(1-l)*s}}}function xc(e){return function(e,s){for(const l of e)if(!_c(l.codePointAt(0),s))return!1;return!0}(e,"loaded"===yc.getRTLTextPluginStatus())}const vc="-transition";class Cs{constructor(e,s,l){this.property=e,this.value=s,this.expression=function(e,s,l){if(Ms(e))return new oi(e,s);if(Bs(e)){const c=Ws(e,s,l);if("error"===c.result)throw new Error(c.value.map((e=>`${e.key}: ${e.message}`)).join(", "));return c.value}{let l=e;return"color"===s.type&&"string"==typeof e?l=Te.parse(e):"padding"!==s.type||"number"!=typeof e&&!Array.isArray(e)?"numberArray"!==s.type||"number"!=typeof e&&!Array.isArray(e)?"colorArray"!==s.type||"string"!=typeof e&&!Array.isArray(e)?"variableAnchorOffsetCollection"===s.type&&Array.isArray(e)?l=Le.parse(e):"projectionDefinition"===s.type&&"string"==typeof e&&(l=Re.parse(e)):l=Be.parse(e):l=Pe.parse(e):l=ze.parse(e),{globalStateRefs:new Set,_globalState:null,kind:"constant",evaluate:()=>l}}}(void 0===s?e.specification.default:s,e.specification,l)}isDataDriven(){return"source"===this.expression.kind||"composite"===this.expression.kind}getGlobalStateRefs(){return this.expression.globalStateRefs||new Set}possiblyEvaluate(e,s,l){return this.property.possiblyEvaluate(this,e,s,l)}}class Ls{constructor(e,s){this.property=e,this.value=new Cs(e,void 0,s)}transitioned(e,s){return new Rs(this.property,this.value,s,ge({},e.transition,this.transition),e.now)}untransitioned(){return new Rs(this.property,this.value,null,{},0)}}class Os{constructor(e,s){this._properties=e,this._values=Object.create(e.defaultTransitionablePropertyValues),this._globalState=s}getValue(e){return be(this._values[e].value.value)}setValue(e,s){Object.prototype.hasOwnProperty.call(this._values,e)||(this._values[e]=new Ls(this._values[e].property,this._globalState)),this._values[e].value=new Cs(this._values[e].property,null===s?void 0:be(s),this._globalState)}getTransition(e){return be(this._values[e].transition)}setTransition(e,s){Object.prototype.hasOwnProperty.call(this._values,e)||(this._values[e]=new Ls(this._values[e].property,this._globalState)),this._values[e].transition=be(s)||void 0}serialize(){const e={};for(const s of Object.keys(this._values)){const l=this.getValue(s);void 0!==l&&(e[s]=l);const c=this.getTransition(s);void 0!==c&&(e[`${s}${vc}`]=c)}return e}transitioned(e,s){const l=new Ns(this._properties);for(const c of Object.keys(this._values))l._values[c]=this._values[c].transitioned(e,s._values[c]);return l}untransitioned(){const e=new Ns(this._properties);for(const s of Object.keys(this._values))e._values[s]=this._values[s].untransitioned();return e}}class Rs{constructor(e,s,l,c,d){this.property=e,this.value=s,this.begin=d+c.delay||0,this.end=this.begin+c.duration||0,e.specification.transition&&(c.delay||c.duration)&&(this.prior=l)}possiblyEvaluate(e,s,l){const c=e.now||0,d=this.value.possiblyEvaluate(e,s,l),p=this.prior;if(p){if(c>this.end)return this.prior=null,d;if(this.value.isDataDriven())return this.prior=null,d;if(cc.zoomHistory.lastIntegerZoom?{from:e,to:s}:{from:l,to:s}}interpolate(e){return e}}class Ys{constructor(e){this.specification=e}possiblyEvaluate(e,s,l,c){if(void 0!==e.value){if("constant"===e.expression.kind){const d=e.expression.evaluate(s,null,{},l,c);return this._calculate(d,d,d,s)}return this._calculate(e.expression.evaluate(new Ps(Math.floor(s.zoom-1),s)),e.expression.evaluate(new Ps(Math.floor(s.zoom),s)),e.expression.evaluate(new Ps(Math.floor(s.zoom+1),s)),s)}}_calculate(e,s,l,c){return c.zoom>c.zoomHistory.lastIntegerZoom?{from:e,to:s}:{from:l,to:s}}interpolate(e){return e}}class Zs{constructor(e){this.specification=e}possiblyEvaluate(e,s,l,c){return!!e.expression.evaluate(s,null,{},l,c)}interpolate(){return!1}}class Hs{constructor(e){this.properties=e,this.defaultPropertyValues={},this.defaultTransitionablePropertyValues={},this.defaultTransitioningPropertyValues={},this.defaultPossiblyEvaluatedValues={},this.overridableProperties=[];for(const s in e){const l=e[s];l.specification.overridable&&this.overridableProperties.push(s);const c=this.defaultPropertyValues[s]=new Cs(l,void 0,void 0),d=this.defaultTransitionablePropertyValues[s]=new Ls(l,void 0);this.defaultTransitioningPropertyValues[s]=d.untransitioned(),this.defaultPossiblyEvaluatedValues[s]=c.possiblyEvaluate({})}}}Yl("DataDrivenProperty",Gs),Yl("DataConstantProperty",js),Yl("CrossFadedDataDrivenProperty",Xs),Yl("CrossFadedProperty",Ys),Yl("ColorRampProperty",Zs);class Ks extends xt{constructor(e,s,l){if(super(),this.id=e.id,this.type=e.type,this._globalState=l,this._featureFilter={filter:()=>!0,needGeometry:!1,getGlobalStateRefs:()=>new Set},"custom"!==e.type&&(this.metadata=e.metadata,this.minzoom=e.minzoom,this.maxzoom=e.maxzoom,this._visibilityExpression=function(e,s){return new rs(e,s)}(this.visibility,l),"background"!==e.type&&(this.source=e.source,this.sourceLayer=e["source-layer"],this.filter=e.filter,this._featureFilter=Co(e.filter,l)),s.layout&&(this._unevaluatedLayout=new $s(s.layout,l)),s.paint)){this._transitionablePaint=new Os(s.paint,l);for(const s in e.paint)this.setPaintProperty(s,e.paint[s],{validate:!1});for(const s in e.layout)this.setLayoutProperty(s,e.layout[s],{validate:!1});this._transitioningPaint=this._transitionablePaint.untransitioned(),this.paint=new qs(s.paint)}}setFilter(e){this.filter=e,this._featureFilter=Co(e,this._globalState)}getCrossfadeParameters(){return this._crossfadeParameters}getLayoutProperty(e){return"visibility"===e?this.visibility:this._unevaluatedLayout.getValue(e)}getLayoutAffectingGlobalStateRefs(){const e=new Set;for(const s of this._visibilityExpression.getGlobalStateRefs())e.add(s);if(this._unevaluatedLayout)for(const s in this._unevaluatedLayout._values){const l=this._unevaluatedLayout._values[s];for(const s of l.getGlobalStateRefs())e.add(s)}for(const s of this._featureFilter.getGlobalStateRefs())e.add(s);return e}getPaintAffectingGlobalStateRefs(){var e;const s=new globalThis.Map;if(this._transitionablePaint)for(const l in this._transitionablePaint._values){const c=this._transitionablePaint._values[l].value;for(const d of c.getGlobalStateRefs()){const p=null!==(e=s.get(d))&&void 0!==e?e:[];p.push({name:l,value:c.value}),s.set(d,p)}}return s}getVisibilityAffectingGlobalStateRefs(){return this._visibilityExpression.getGlobalStateRefs()}setLayoutProperty(e,s,l={}){if(null==s||!this._validate(Wl,`layers.${this.id}.layout.${e}`,e,s,l))return"visibility"===e?(this.visibility=s,this._visibilityExpression.setValue(s),void this.recalculateVisibility()):void this._unevaluatedLayout.setValue(e,s)}getPaintProperty(e){return e.endsWith(vc)?this._transitionablePaint.getTransition(e.slice(0,-11)):this._transitionablePaint.getValue(e)}setPaintProperty(e,s,l={}){if(null!=s&&this._validate($l,`layers.${this.id}.paint.${e}`,e,s,l))return!1;if(e.endsWith(vc))return this._transitionablePaint.setTransition(e.slice(0,-11),s||void 0),!1;{const l=this._transitionablePaint._values[e],c="cross-faded-data-driven"===l.property.specification["property-type"],d=l.value.isDataDriven(),p=l.value;this._transitionablePaint.setValue(e,s),this._handleSpecialPaintPropertyUpdate(e);const f=this._transitionablePaint._values[e].value;return f.isDataDriven()||d||c||this._handleOverridablePaintPropertyUpdate(e,p,f)}}_handleSpecialPaintPropertyUpdate(e){}_handleOverridablePaintPropertyUpdate(e,s,l){return!1}isHidden(e=this.minzoom,s=!1){return!!(this.minzoom&&e<(s?Math.floor(this.minzoom):this.minzoom))||!!(this.maxzoom&&e>=this.maxzoom)||"none"===this._evaluatedVisibility}updateTransitions(e){this._transitioningPaint=this._transitionablePaint.transitioned(e,this._transitioningPaint)}hasTransition(){return this._transitioningPaint.hasTransition()}recalculateVisibility(){this._evaluatedVisibility=this._visibilityExpression.evaluate()}recalculate(e,s){e.getCrossfadeParameters&&(this._crossfadeParameters=e.getCrossfadeParameters()),this._unevaluatedLayout&&(this.layout=this._unevaluatedLayout.possiblyEvaluate(e,void 0,s)),this.paint=this._transitioningPaint.possiblyEvaluate(e,void 0,s)}serialize(){const e={id:this.id,type:this.type,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()};return this.visibility&&(e.layout=e.layout||{},e.layout.visibility=this.visibility),ve(e,((e,s)=>!(void 0===e||"layout"===s&&!Object.keys(e).length||"paint"===s&&!Object.keys(e).length)))}_validate(e,s,l,c,d={}){return(!d||!1!==d.validate)&&Hl(this,e.call(Ul,{key:s,layerType:this.type,objectKey:l,value:c,styleSpec:Tt,style:{glyphs:!0,sprite:!0}}))}is3D(){return!1}isTileClipped(){return!1}hasOffscreenPass(){return!1}resize(){}isStateDependent(){for(const e in this.paint._values){const s=this.paint.get(e);if(s instanceof Us&&bs(s.property.specification)&&("source"===s.value.kind||"composite"===s.value.kind)&&s.value.isStateDependent)return!0}return!1}}let bc;var wc={get paint(){return bc=bc||new Hs({"raster-opacity":new js(Tt.paint_raster["raster-opacity"]),"raster-hue-rotate":new js(Tt.paint_raster["raster-hue-rotate"]),"raster-brightness-min":new js(Tt.paint_raster["raster-brightness-min"]),"raster-brightness-max":new js(Tt.paint_raster["raster-brightness-max"]),"raster-saturation":new js(Tt.paint_raster["raster-saturation"]),"raster-contrast":new js(Tt.paint_raster["raster-contrast"]),"raster-resampling":new js(Tt.paint_raster["raster-resampling"]),"raster-fade-duration":new js(Tt.paint_raster["raster-fade-duration"])})}};class Qs extends Ks{constructor(e,s){super(e,wc,s)}}const Pc={Int8:Int8Array,Uint8:Uint8Array,Int16:Int16Array,Uint16:Uint16Array,Int32:Int32Array,Uint32:Uint32Array,Float32:Float32Array};class ea{constructor(e,s){this._structArray=e,this._pos1=s*this.size,this._pos2=this._pos1/2,this._pos4=this._pos1/4,this._pos8=this._pos1/8}}class ra{constructor(){this.isTransferred=!1,this.capacity=-1,this.resize(0)}static serialize(e,s){return e._trim(),s&&(e.isTransferred=!0,s.push(e.arrayBuffer)),{length:e.length,arrayBuffer:e.arrayBuffer}}static deserialize(e){const s=Object.create(this.prototype);return s.arrayBuffer=e.arrayBuffer,s.length=e.length,s.capacity=e.arrayBuffer.byteLength/s.bytesPerElement,s._refreshViews(),s}_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(e){this.reserve(e),this.length=e}reserve(e){if(e>this.capacity){this.capacity=Math.max(e,Math.floor(5*this.capacity),128),this.arrayBuffer=new ArrayBuffer(this.capacity*this.bytesPerElement);const s=this.uint8;this._refreshViews(),s&&this.uint8.set(s)}}_refreshViews(){throw new Error("_refreshViews() must be implemented by each concrete StructArray layout")}}function Mc(e,s=1){let l=0,c=0;return{members:e.map((e=>{const d=Pc[e.type].BYTES_PER_ELEMENT,p=l=Ic(l,Math.max(s,d)),f=e.components||1;return c=Math.max(c,d),l+=d*f,{name:e.name,type:e.type,components:f,offset:p}})),size:Ic(l,Math.max(c,s)),alignment:s}}function Ic(e,s){return Math.ceil(e/s)*s}class sa extends ra{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,s){const l=this.length;return this.resize(l+1),this.emplace(l,e,s)}emplace(e,s,l){const c=2*e;return this.int16[c+0]=s,this.int16[c+1]=l,e}}sa.prototype.bytesPerElement=4,Yl("StructArrayLayout2i4",sa);class aa extends ra{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,s,l){const c=this.length;return this.resize(c+1),this.emplace(c,e,s,l)}emplace(e,s,l,c){const d=3*e;return this.int16[d+0]=s,this.int16[d+1]=l,this.int16[d+2]=c,e}}aa.prototype.bytesPerElement=6,Yl("StructArrayLayout3i6",aa);class oa extends ra{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,s,l,c){const d=this.length;return this.resize(d+1),this.emplace(d,e,s,l,c)}emplace(e,s,l,c,d){const p=4*e;return this.int16[p+0]=s,this.int16[p+1]=l,this.int16[p+2]=c,this.int16[p+3]=d,e}}oa.prototype.bytesPerElement=8,Yl("StructArrayLayout4i8",oa);class la extends ra{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,s,l,c,d,p){const f=this.length;return this.resize(f+1),this.emplace(f,e,s,l,c,d,p)}emplace(e,s,l,c,d,p,f){const m=6*e;return this.int16[m+0]=s,this.int16[m+1]=l,this.int16[m+2]=c,this.int16[m+3]=d,this.int16[m+4]=p,this.int16[m+5]=f,e}}la.prototype.bytesPerElement=12,Yl("StructArrayLayout2i4i12",la);class ua extends ra{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,s,l,c,d,p){const f=this.length;return this.resize(f+1),this.emplace(f,e,s,l,c,d,p)}emplace(e,s,l,c,d,p,f){const m=4*e,_=8*e;return this.int16[m+0]=s,this.int16[m+1]=l,this.uint8[_+4]=c,this.uint8[_+5]=d,this.uint8[_+6]=p,this.uint8[_+7]=f,e}}ua.prototype.bytesPerElement=8,Yl("StructArrayLayout2i4ub8",ua);class ca extends ra{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,s){const l=this.length;return this.resize(l+1),this.emplace(l,e,s)}emplace(e,s,l){const c=2*e;return this.float32[c+0]=s,this.float32[c+1]=l,e}}ca.prototype.bytesPerElement=8,Yl("StructArrayLayout2f8",ca);class ha extends ra{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,s,l,c,d,p,f,m,_,g){const y=this.length;return this.resize(y+1),this.emplace(y,e,s,l,c,d,p,f,m,_,g)}emplace(e,s,l,c,d,p,f,m,_,g,y){const b=10*e;return this.uint16[b+0]=s,this.uint16[b+1]=l,this.uint16[b+2]=c,this.uint16[b+3]=d,this.uint16[b+4]=p,this.uint16[b+5]=f,this.uint16[b+6]=m,this.uint16[b+7]=_,this.uint16[b+8]=g,this.uint16[b+9]=y,e}}ha.prototype.bytesPerElement=20,Yl("StructArrayLayout10ui20",ha);class pa extends ra{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,s,l,c,d,p,f,m){const _=this.length;return this.resize(_+1),this.emplace(_,e,s,l,c,d,p,f,m)}emplace(e,s,l,c,d,p,f,m,_){const g=8*e;return this.uint16[g+0]=s,this.uint16[g+1]=l,this.uint16[g+2]=c,this.uint16[g+3]=d,this.uint16[g+4]=p,this.uint16[g+5]=f,this.uint16[g+6]=m,this.uint16[g+7]=_,e}}pa.prototype.bytesPerElement=16,Yl("StructArrayLayout8ui16",pa);class fa extends ra{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,s,l,c,d,p,f,m,_,g,y,b){const T=this.length;return this.resize(T+1),this.emplace(T,e,s,l,c,d,p,f,m,_,g,y,b)}emplace(e,s,l,c,d,p,f,m,_,g,y,b,T){const P=12*e;return this.int16[P+0]=s,this.int16[P+1]=l,this.int16[P+2]=c,this.int16[P+3]=d,this.uint16[P+4]=p,this.uint16[P+5]=f,this.uint16[P+6]=m,this.uint16[P+7]=_,this.int16[P+8]=g,this.int16[P+9]=y,this.int16[P+10]=b,this.int16[P+11]=T,e}}fa.prototype.bytesPerElement=24,Yl("StructArrayLayout4i4ui4i24",fa);class da extends ra{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,s,l){const c=this.length;return this.resize(c+1),this.emplace(c,e,s,l)}emplace(e,s,l,c){const d=3*e;return this.float32[d+0]=s,this.float32[d+1]=l,this.float32[d+2]=c,e}}da.prototype.bytesPerElement=12,Yl("StructArrayLayout3f12",da);class ya extends ra{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer)}emplaceBack(e){const s=this.length;return this.resize(s+1),this.emplace(s,e)}emplace(e,s){return this.uint32[1*e+0]=s,e}}ya.prototype.bytesPerElement=4,Yl("StructArrayLayout1ul4",ya);class ma extends ra{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,s,l,c,d,p,f,m,_){const g=this.length;return this.resize(g+1),this.emplace(g,e,s,l,c,d,p,f,m,_)}emplace(e,s,l,c,d,p,f,m,_,g){const y=10*e,b=5*e;return this.int16[y+0]=s,this.int16[y+1]=l,this.int16[y+2]=c,this.int16[y+3]=d,this.int16[y+4]=p,this.int16[y+5]=f,this.uint32[b+3]=m,this.uint16[y+8]=_,this.uint16[y+9]=g,e}}ma.prototype.bytesPerElement=20,Yl("StructArrayLayout6i1ul2ui20",ma);class ga extends ra{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,s,l,c,d,p){const f=this.length;return this.resize(f+1),this.emplace(f,e,s,l,c,d,p)}emplace(e,s,l,c,d,p,f){const m=6*e;return this.int16[m+0]=s,this.int16[m+1]=l,this.int16[m+2]=c,this.int16[m+3]=d,this.int16[m+4]=p,this.int16[m+5]=f,e}}ga.prototype.bytesPerElement=12,Yl("StructArrayLayout2i2i2i12",ga);class xa extends ra{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,s,l,c,d){const p=this.length;return this.resize(p+1),this.emplace(p,e,s,l,c,d)}emplace(e,s,l,c,d,p){const f=4*e,m=8*e;return this.float32[f+0]=s,this.float32[f+1]=l,this.float32[f+2]=c,this.int16[m+6]=d,this.int16[m+7]=p,e}}xa.prototype.bytesPerElement=16,Yl("StructArrayLayout2f1f2i16",xa);class va extends ra{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,s,l,c,d,p){const f=this.length;return this.resize(f+1),this.emplace(f,e,s,l,c,d,p)}emplace(e,s,l,c,d,p,f){const m=16*e,_=4*e,g=8*e;return this.uint8[m+0]=s,this.uint8[m+1]=l,this.float32[_+1]=c,this.float32[_+2]=d,this.int16[g+6]=p,this.int16[g+7]=f,e}}va.prototype.bytesPerElement=16,Yl("StructArrayLayout2ub2f2i16",va);class ba extends ra{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,s,l){const c=this.length;return this.resize(c+1),this.emplace(c,e,s,l)}emplace(e,s,l,c){const d=3*e;return this.uint16[d+0]=s,this.uint16[d+1]=l,this.uint16[d+2]=c,e}}ba.prototype.bytesPerElement=6,Yl("StructArrayLayout3ui6",ba);class wa extends ra{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,s,l,c,d,p,f,m,_,g,y,b,T,P,S,I,C){const z=this.length;return this.resize(z+1),this.emplace(z,e,s,l,c,d,p,f,m,_,g,y,b,T,P,S,I,C)}emplace(e,s,l,c,d,p,f,m,_,g,y,b,T,P,S,I,C,z){const L=24*e,F=12*e,B=48*e;return this.int16[L+0]=s,this.int16[L+1]=l,this.uint16[L+2]=c,this.uint16[L+3]=d,this.uint32[F+2]=p,this.uint32[F+3]=f,this.uint32[F+4]=m,this.uint16[L+10]=_,this.uint16[L+11]=g,this.uint16[L+12]=y,this.float32[F+7]=b,this.float32[F+8]=T,this.uint8[B+36]=P,this.uint8[B+37]=S,this.uint8[B+38]=I,this.uint32[F+10]=C,this.int16[L+22]=z,e}}wa.prototype.bytesPerElement=48,Yl("StructArrayLayout2i2ui3ul3ui2f3ub1ul1i48",wa);class _a extends ra{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,s,l,c,d,p,f,m,_,g,y,b,T,P,S,I,C,z,L,F,B,O,j,G,U,q,Z,W){const J=this.length;return this.resize(J+1),this.emplace(J,e,s,l,c,d,p,f,m,_,g,y,b,T,P,S,I,C,z,L,F,B,O,j,G,U,q,Z,W)}emplace(e,s,l,c,d,p,f,m,_,g,y,b,T,P,S,I,C,z,L,F,B,O,j,G,U,q,Z,W,J){const re=32*e,se=16*e;return this.int16[re+0]=s,this.int16[re+1]=l,this.int16[re+2]=c,this.int16[re+3]=d,this.int16[re+4]=p,this.int16[re+5]=f,this.int16[re+6]=m,this.int16[re+7]=_,this.uint16[re+8]=g,this.uint16[re+9]=y,this.uint16[re+10]=b,this.uint16[re+11]=T,this.uint16[re+12]=P,this.uint16[re+13]=S,this.uint16[re+14]=I,this.uint16[re+15]=C,this.uint16[re+16]=z,this.uint16[re+17]=L,this.uint16[re+18]=F,this.uint16[re+19]=B,this.uint16[re+20]=O,this.uint16[re+21]=j,this.uint16[re+22]=G,this.uint32[se+12]=U,this.float32[se+13]=q,this.float32[se+14]=Z,this.uint16[re+30]=W,this.uint16[re+31]=J,e}}_a.prototype.bytesPerElement=64,Yl("StructArrayLayout8i15ui1ul2f2ui64",_a);class Sa extends ra{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e){const s=this.length;return this.resize(s+1),this.emplace(s,e)}emplace(e,s){return this.float32[1*e+0]=s,e}}Sa.prototype.bytesPerElement=4,Yl("StructArrayLayout1f4",Sa);class Aa extends ra{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,s,l){const c=this.length;return this.resize(c+1),this.emplace(c,e,s,l)}emplace(e,s,l,c){const d=3*e;return this.uint16[6*e+0]=s,this.float32[d+1]=l,this.float32[d+2]=c,e}}Aa.prototype.bytesPerElement=12,Yl("StructArrayLayout1ui2f12",Aa);class ka extends ra{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,s,l){const c=this.length;return this.resize(c+1),this.emplace(c,e,s,l)}emplace(e,s,l,c){const d=4*e;return this.uint32[2*e+0]=s,this.uint16[d+2]=l,this.uint16[d+3]=c,e}}ka.prototype.bytesPerElement=8,Yl("StructArrayLayout1ul2ui8",ka);class Ea extends ra{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,s){const l=this.length;return this.resize(l+1),this.emplace(l,e,s)}emplace(e,s,l){const c=2*e;return this.uint16[c+0]=s,this.uint16[c+1]=l,e}}Ea.prototype.bytesPerElement=4,Yl("StructArrayLayout2ui4",Ea);class Ta extends ra{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e){const s=this.length;return this.resize(s+1),this.emplace(s,e)}emplace(e,s){return this.uint16[1*e+0]=s,e}}Ta.prototype.bytesPerElement=2,Yl("StructArrayLayout1ui2",Ta);class Ia extends ra{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,s,l,c){const d=this.length;return this.resize(d+1),this.emplace(d,e,s,l,c)}emplace(e,s,l,c,d){const p=4*e;return this.float32[p+0]=s,this.float32[p+1]=l,this.float32[p+2]=c,this.float32[p+3]=d,e}}Ia.prototype.bytesPerElement=16,Yl("StructArrayLayout4f16",Ia);class Ma extends ea{get anchorPointX(){return this._structArray.int16[this._pos2+0]}get anchorPointY(){return this._structArray.int16[this._pos2+1]}get x1(){return this._structArray.int16[this._pos2+2]}get y1(){return this._structArray.int16[this._pos2+3]}get x2(){return this._structArray.int16[this._pos2+4]}get y2(){return this._structArray.int16[this._pos2+5]}get featureIndex(){return this._structArray.uint32[this._pos4+3]}get sourceLayerIndex(){return this._structArray.uint16[this._pos2+8]}get bucketIndex(){return this._structArray.uint16[this._pos2+9]}get anchorPoint(){return new c(this.anchorPointX,this.anchorPointY)}}Ma.prototype.size=20;class Fa extends ma{get(e){return new Ma(this,e)}}Yl("CollisionBoxArray",Fa);class Da extends ea{get anchorX(){return this._structArray.int16[this._pos2+0]}get anchorY(){return this._structArray.int16[this._pos2+1]}get glyphStartIndex(){return this._structArray.uint16[this._pos2+2]}get numGlyphs(){return this._structArray.uint16[this._pos2+3]}get vertexStartIndex(){return this._structArray.uint32[this._pos4+2]}get lineStartIndex(){return this._structArray.uint32[this._pos4+3]}get lineLength(){return this._structArray.uint32[this._pos4+4]}get segment(){return this._structArray.uint16[this._pos2+10]}get lowerSize(){return this._structArray.uint16[this._pos2+11]}get upperSize(){return this._structArray.uint16[this._pos2+12]}get lineOffsetX(){return this._structArray.float32[this._pos4+7]}get lineOffsetY(){return this._structArray.float32[this._pos4+8]}get writingMode(){return this._structArray.uint8[this._pos1+36]}get placedOrientation(){return this._structArray.uint8[this._pos1+37]}set placedOrientation(e){this._structArray.uint8[this._pos1+37]=e}get hidden(){return this._structArray.uint8[this._pos1+38]}set hidden(e){this._structArray.uint8[this._pos1+38]=e}get crossTileID(){return this._structArray.uint32[this._pos4+10]}set crossTileID(e){this._structArray.uint32[this._pos4+10]=e}get associatedIconIndex(){return this._structArray.int16[this._pos2+22]}}Da.prototype.size=48;class za extends wa{get(e){return new Da(this,e)}}Yl("PlacedSymbolArray",za);class Pa extends ea{get anchorX(){return this._structArray.int16[this._pos2+0]}get anchorY(){return this._structArray.int16[this._pos2+1]}get rightJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+2]}get centerJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+3]}get leftJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+4]}get verticalPlacedTextSymbolIndex(){return this._structArray.int16[this._pos2+5]}get placedIconSymbolIndex(){return this._structArray.int16[this._pos2+6]}get verticalPlacedIconSymbolIndex(){return this._structArray.int16[this._pos2+7]}get key(){return this._structArray.uint16[this._pos2+8]}get textBoxStartIndex(){return this._structArray.uint16[this._pos2+9]}get textBoxEndIndex(){return this._structArray.uint16[this._pos2+10]}get verticalTextBoxStartIndex(){return this._structArray.uint16[this._pos2+11]}get verticalTextBoxEndIndex(){return this._structArray.uint16[this._pos2+12]}get iconBoxStartIndex(){return this._structArray.uint16[this._pos2+13]}get iconBoxEndIndex(){return this._structArray.uint16[this._pos2+14]}get verticalIconBoxStartIndex(){return this._structArray.uint16[this._pos2+15]}get verticalIconBoxEndIndex(){return this._structArray.uint16[this._pos2+16]}get featureIndex(){return this._structArray.uint16[this._pos2+17]}get numHorizontalGlyphVertices(){return this._structArray.uint16[this._pos2+18]}get numVerticalGlyphVertices(){return this._structArray.uint16[this._pos2+19]}get numIconVertices(){return this._structArray.uint16[this._pos2+20]}get numVerticalIconVertices(){return this._structArray.uint16[this._pos2+21]}get useRuntimeCollisionCircles(){return this._structArray.uint16[this._pos2+22]}get crossTileID(){return this._structArray.uint32[this._pos4+12]}set crossTileID(e){this._structArray.uint32[this._pos4+12]=e}get textBoxScale(){return this._structArray.float32[this._pos4+13]}get collisionCircleDiameter(){return this._structArray.float32[this._pos4+14]}get textAnchorOffsetStartIndex(){return this._structArray.uint16[this._pos2+30]}get textAnchorOffsetEndIndex(){return this._structArray.uint16[this._pos2+31]}}Pa.prototype.size=64;class Ba extends _a{get(e){return new Pa(this,e)}}Yl("SymbolInstanceArray",Ba);class Va extends Sa{getoffsetX(e){return this.float32[1*e+0]}}Yl("GlyphOffsetArray",Va);class Ca extends aa{getx(e){return this.int16[3*e+0]}gety(e){return this.int16[3*e+1]}gettileUnitDistanceFromAnchor(e){return this.int16[3*e+2]}}Yl("SymbolLineVertexArray",Ca);class La extends ea{get textAnchor(){return this._structArray.uint16[this._pos2+0]}get textOffset0(){return this._structArray.float32[this._pos4+1]}get textOffset1(){return this._structArray.float32[this._pos4+2]}}La.prototype.size=12;class Oa extends Aa{get(e){return new La(this,e)}}Yl("TextAnchorOffsetArray",Oa);class Ra extends ea{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]}}Ra.prototype.size=8;class Na extends ka{get(e){return new Ra(this,e)}}Yl("FeatureIndexArray",Na);class $a extends sa{}class Ua extends sa{}class qa extends sa{}class ja extends la{}class Ga extends ua{}class Xa extends ca{}class Ya extends ha{}class Za extends pa{}class Ha extends fa{}class Ka extends da{}class Wa extends ya{}class Ja extends ga{}class Qa extends va{}class to extends ba{}class eo extends Ea{}const Ec=Mc([{name:"a_pos",components:2,type:"Int16"}],4),{members:Cc}=Ec;class io{constructor(e=[]){this._forceNewSegmentOnNextPrepare=!1,this.segments=e}prepareSegment(e,s,l,c){const d=this.segments[this.segments.length-1];return e>io.MAX_VERTEX_ARRAY_LENGTH&&Se(`Max vertices per segment is ${io.MAX_VERTEX_ARRAY_LENGTH}: bucket requested ${e}. Consider using the \`fillLargeMeshArrays\` function if you require meshes with more than ${io.MAX_VERTEX_ARRAY_LENGTH} vertices.`),this._forceNewSegmentOnNextPrepare||!d||d.vertexLength+e>io.MAX_VERTEX_ARRAY_LENGTH||d.sortKey!==c?this.createNewSegment(s,l,c):d}createNewSegment(e,s,l){const c={vertexOffset:e.length,primitiveOffset:s.length,vertexLength:0,primitiveLength:0,vaos:{}};return void 0!==l&&(c.sortKey=l),this._forceNewSegmentOnNextPrepare=!1,this.segments.push(c),c}getOrCreateLatestSegment(e,s,l){return this.prepareSegment(0,e,s,l)}forceNewSegmentOnNextPrepare(){this._forceNewSegmentOnNextPrepare=!0}get(){return this.segments}destroy(){for(const e of this.segments)for(const s in e.vaos)e.vaos[s].destroy()}static simpleSegment(e,s,l,c){return new io([{vertexOffset:e,primitiveOffset:s,vertexLength:l,primitiveLength:c,vaos:{},sortKey:0}])}}function Ac(e,s){return 256*(e=fe(Math.floor(e),0,255))+fe(Math.floor(s),0,255)}io.MAX_VERTEX_ARRAY_LENGTH=Math.pow(2,16)-1,Yl("SegmentVector",io);const Dc=Mc([{name:"a_pattern_from",components:4,type:"Uint16"},{name:"a_pattern_to",components:4,type:"Uint16"},{name:"a_pixel_ratio_from",components:1,type:"Uint16"},{name:"a_pixel_ratio_to",components:1,type:"Uint16"}]),zc=Mc([{name:"a_dasharray_from",components:4,type:"Uint16"},{name:"a_dasharray_to",components:4,type:"Uint16"}]);var kc,Rc,Lc,Fc={exports:{}},Bc={exports:{}},Oc={exports:{}},Vc=function(){if(Lc)return Fc.exports;Lc=1;var e=(kc||(kc=1,Bc.exports=function(e,s){var l,c,d,p,f,m,_,g;for(c=e.length-(l=3&e.length),d=s,f=3432918353,m=461845907,g=0;g>>16)*f&65535)<<16)&4294967295)<<15|_>>>17))*m+(((_>>>16)*m&65535)<<16)&4294967295)<<13|d>>>19))+((5*(d>>>16)&65535)<<16)&4294967295))+((58964+(p>>>16)&65535)<<16);switch(_=0,l){case 3:_^=(255&e.charCodeAt(g+2))<<16;case 2:_^=(255&e.charCodeAt(g+1))<<8;case 1:d^=_=(65535&(_=(_=(65535&(_^=255&e.charCodeAt(g)))*f+(((_>>>16)*f&65535)<<16)&4294967295)<<15|_>>>17))*m+(((_>>>16)*m&65535)<<16)&4294967295}return d^=e.length,d=2246822507*(65535&(d^=d>>>16))+((2246822507*(d>>>16)&65535)<<16)&4294967295,d=3266489909*(65535&(d^=d>>>13))+((3266489909*(d>>>16)&65535)<<16)&4294967295,(d^=d>>>16)>>>0}),Bc.exports),s=(Rc||(Rc=1,Oc.exports=function(e,s){for(var l,c=e.length,d=s^c,p=0;c>=4;)l=1540483477*(65535&(l=255&e.charCodeAt(p)|(255&e.charCodeAt(++p))<<8|(255&e.charCodeAt(++p))<<16|(255&e.charCodeAt(++p))<<24))+((1540483477*(l>>>16)&65535)<<16),d=1540483477*(65535&d)+((1540483477*(d>>>16)&65535)<<16)^(l=1540483477*(65535&(l^=l>>>24))+((1540483477*(l>>>16)&65535)<<16)),c-=4,++p;switch(c){case 3:d^=(255&e.charCodeAt(p+2))<<16;case 2:d^=(255&e.charCodeAt(p+1))<<8;case 1:d=1540483477*(65535&(d^=255&e.charCodeAt(p)))+((1540483477*(d>>>16)&65535)<<16)}return d=1540483477*(65535&(d^=d>>>13))+((1540483477*(d>>>16)&65535)<<16),(d^=d>>>15)>>>0}),Oc.exports);return Fc.exports=e,Fc.exports.murmur3=e,Fc.exports.murmur2=s,Fc.exports}(),Nc=d(Vc);class go{constructor(){this.ids=[],this.positions=[],this.indexed=!1}add(e,s,l,c){this.ids.push(Gc(e)),this.positions.push(s,l,c)}getPositions(e){if(!this.indexed)throw new Error("Trying to get index, but feature positions are not indexed");const s=Gc(e);let l=0,c=this.ids.length-1;for(;l>1;this.ids[e]>=s?c=e:l=e+1}const d=[];for(;this.ids[l]===s;)d.push({index:this.positions[3*l],start:this.positions[3*l+1],end:this.positions[3*l+2]}),l++;return d}static serialize(e,s){const l=new Float64Array(e.ids),c=new Uint32Array(e.positions);return Uc(l,c,0,l.length-1),s&&s.push(l.buffer,c.buffer),{ids:l,positions:c}}static deserialize(e){const s=new go;return s.ids=e.ids,s.positions=e.positions,s.indexed=!0,s}}function Gc(e){const s=+e;return!isNaN(s)&&s<=Number.MAX_SAFE_INTEGER?s:Nc(String(e))}function Uc(e,s,l,c){for(;l>1];let p=l-1,f=c+1;for(;;){do{p++}while(e[p]d);if(p>=f)break;Zc(e,p,f),Zc(s,3*p,3*f),Zc(s,3*p+1,3*f+1),Zc(s,3*p+2,3*f+2)}f-l`u_${e}`)),this.type=l}setUniform(e,s,l){e.set(l.constantOr(this.value))}getBinding(e,s,l){return"color"===this.type?new Ao(e,s):new _o(e,s)}}class Io{constructor(e,s){this.uniformNames=s.map((e=>`u_${e}`)),this.patternFrom=null,this.patternTo=null,this.pixelRatioFrom=1,this.pixelRatioTo=1}setConstantPatternPositions(e,s){this.pixelRatioFrom=s.pixelRatio,this.pixelRatioTo=e.pixelRatio,this.patternFrom=s.tlbr,this.patternTo=e.tlbr}setConstantDashPositions(e,s){this.dashTo=[0,e.y,e.height,e.width],this.dashFrom=[0,s.y,s.height,s.width]}setUniform(e,s,l,c){let d=null;"u_pattern_to"===c?d=this.patternTo:"u_pattern_from"===c?d=this.patternFrom:"u_dasharray_to"===c?d=this.dashTo:"u_dasharray_from"===c?d=this.dashFrom:"u_pixel_ratio_to"===c?d=this.pixelRatioTo:"u_pixel_ratio_from"===c&&(d=this.pixelRatioFrom),null!==d&&e.set(d)}getBinding(e,s,l){return"u_pattern"===l.substr(0,9)||"u_dasharray_"===l.substr(0,12)?new So(e,s):new _o(e,s)}}class Mo{constructor(e,s,l,c){this.expression=e,this.type=l,this.maxValue=0,this.paintVertexAttributes=s.map((e=>({name:`a_${e}`,type:"Float32",components:"color"===l?2:1,offset:0}))),this.paintVertexArray=new c}populatePaintArray(e,s,l){const c=this.paintVertexArray.length,d=this.expression.evaluate(new Ps(0,l),s,{},l.canonical,[],l.formattedSection);this.paintVertexArray.resize(e),this._setPaintValue(c,e,d)}updatePaintArray(e,s,l,c,d){const p=this.expression.evaluate(new Ps(0,d),l,c);this._setPaintValue(e,s,p)}_setPaintValue(e,s,l){if("color"===this.type){const c=Wc(l);for(let l=e;l`u_${e}_t`)),this.type=l,this.useIntegerZoom=c,this.zoom=d,this.maxValue=0,this.paintVertexAttributes=s.map((e=>({name:`a_${e}`,type:"Float32",components:"color"===l?4:2,offset:0}))),this.paintVertexArray=new p}populatePaintArray(e,s,l){const c=this.expression.evaluate(new Ps(this.zoom,l),s,{},l.canonical,[],l.formattedSection),d=this.expression.evaluate(new Ps(this.zoom+1,l),s,{},l.canonical,[],l.formattedSection),p=this.paintVertexArray.length;this.paintVertexArray.resize(e),this._setPaintValue(p,e,c,d)}updatePaintArray(e,s,l,c,d){const p=this.expression.evaluate(new Ps(this.zoom,d),l,c),f=this.expression.evaluate(new Ps(this.zoom+1,d),l,c);this._setPaintValue(e,s,p,f)}_setPaintValue(e,s,l,c){if("color"===this.type){const d=Wc(l),p=Wc(c);for(let l=e;l`#define HAS_UNIFORM_${e}`)))}return e}getBinderAttributes(){const e=[];for(const s in this.binders){const l=this.binders[s];if(l instanceof Mo||l instanceof Fo)for(let s=0;s!0){this.programConfigurations={};for(const c of e)this.programConfigurations[c.id]=new Bo(c,s,l);this.needsUpload=!1,this._featureMap=new go,this._bufferOffset=0}populatePaintArrays(e,s,l,c){for(const l in this.programConfigurations)this.programConfigurations[l].populatePaintArrays(e,s,c);void 0!==s.id&&this._featureMap.add(s.id,l,this._bufferOffset,e),this._bufferOffset=e,this.needsUpload=!0}updatePaintArrays(e,s,l,c){for(const d of l)this.needsUpload=this.programConfigurations[d.id].updatePaintArrays(e,this._featureMap,s,d,c)||this.needsUpload}get(e){return this.programConfigurations[e]}upload(e){if(this.needsUpload){for(const s in this.programConfigurations)this.programConfigurations[s].upload(e);this.needsUpload=!1}}destroy(){for(const e in this.programConfigurations)this.programConfigurations[e].destroy()}}function Hc(e,s){return{"text-opacity":["opacity"],"icon-opacity":["opacity"],"text-color":["fill_color"],"icon-color":["fill_color"],"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-dasharray":["dasharray_to","dasharray_from"],"line-pattern":["pattern_to","pattern_from","pixel_ratio_to","pixel_ratio_from"],"fill-pattern":["pattern_to","pattern_from","pixel_ratio_to","pixel_ratio_from"],"fill-extrusion-pattern":["pattern_to","pattern_from","pixel_ratio_to","pixel_ratio_from"]}[e]||[e.replace(`${s}-`,"").replace(/-/g,"_")]}function Xc(e,s,l){const c={color:{source:ca,composite:Ia},number:{source:Sa,composite:ca}},d=function(e){return{"line-pattern":{source:Ya,composite:Ya},"fill-pattern":{source:Ya,composite:Ya},"fill-extrusion-pattern":{source:Ya,composite:Ya},"line-dasharray":{source:Za,composite:Za}}[e]}(e);return d&&d[l]||c[s][l]}Yl("ConstantBinder",To),Yl("CrossFadedConstantBinder",Io),Yl("SourceExpressionBinder",Mo),Yl("CrossFadedPatternBinder",zo),Yl("CrossFadedDasharrayBinder",Po),Yl("CompositeExpressionBinder",Fo),Yl("ProgramConfiguration",Bo,{omit:["_buffers"]}),Yl("ProgramConfigurationSet",Vo);const Yc=Math.pow(2,14)-1,Kc=-Yc-1;function Qc(e){const s=se/e.extent,l=e.loadGeometry();for(let e=0;el.x+1||pl.y+1)&&Se("Geometry exceeds allowed extent, reduce your vector tile buffer size")}}return l}function Jc(e,s){return{type:e.type,id:e.id,properties:e.properties,geometry:s?Qc(e):[]}}const eh=-32768;function th(e,s,l,c,d){e.emplaceBack(eh+8*s+c,eh+8*l+d)}class jo{constructor(e){this.zoom=e.zoom,this.overscaling=e.overscaling,this.layers=e.layers,this.layerIds=this.layers.map((e=>e.id)),this.index=e.index,this.hasDependencies=!1,this.layoutVertexArray=new Ua,this.indexArray=new to,this.segments=new io,this.programConfigurations=new Vo(e.layers,e.zoom),this.stateDependentLayerIds=this.layers.filter((e=>e.isStateDependent())).map((e=>e.id))}populate(e,s,l){const c=this.layers[0],d=[];let p=null,f=!1,m="heatmap"===c.type;if("circle"===c.type){const e=c;p=e.layout.get("circle-sort-key"),f=!p.isConstant(),m=m||"map"===e.paint.get("circle-pitch-alignment")}const _=m?s.subdivisionGranularity.circle:1;for(const{feature:s,id:c,index:m,sourceLayerIndex:_}of e){const e=this.layers[0]._featureFilter.needGeometry,g=Jc(s,e);if(!this.layers[0]._featureFilter.filter(new Ps(this.zoom),g,l))continue;const y=f?p.evaluate(g,{},l):void 0,b={id:c,properties:s.properties,type:s.type,sourceLayerIndex:_,index:m,geometry:e?g.geometry:Qc(s),patterns:{},sortKey:y};d.push(b)}f&&d.sort(((e,s)=>e.sortKey-s.sortKey));for(const c of d){const{geometry:d,index:p,sourceLayerIndex:f}=c,m=e[p].feature;this.addFeature(c,d,p,l,_),s.featureIndex.insert(m,d,p,f,this.index)}}update(e,s,l){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(e,s,this.stateDependentLayers,{imagePositions:l})}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(e){this.uploaded||(this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,Cc),this.indexBuffer=e.createIndexBuffer(this.indexArray)),this.programConfigurations.upload(e),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy())}addFeature(e,s,l,c,d=1){let p;switch(d){case 1:p=[0,7];break;case 3:p=[0,2,5,7];break;case 5:p=[0,1,3,4,6,7];break;case 7:p=[0,1,2,3,4,5,6,7];break;default:throw new Error(`Invalid circle bucket granularity: ${d}; valid values are 1, 3, 5, 7.`)}const f=p.length;for(const l of s)for(const s of l){const l=s.x,c=s.y;if(l<0||l>=se||c<0||c>=se)continue;const d=this.segments.prepareSegment(f*f,this.layoutVertexArray,this.indexArray,e.sortKey),m=d.vertexLength;for(let e=0;e1){if(oh(e,s))return!0;for(let c=0;c1?l:l.sub(s)._mult(d)._add(s))}function uh(e,s){let l,c,d,p=!1;for(let f=0;fs.y!=d.y>s.y&&s.x<(d.x-c.x)*(s.y-c.y)/(d.y-c.y)+c.x&&(p=!p)}return p}function dh(e,s){let l=!1;for(let c=0,d=e.length-1;cs.y!=f.y>s.y&&s.x<(f.x-p.x)*(s.y-p.y)/(f.y-p.y)+p.x&&(l=!l)}return l}function mh(e,s,l){const c=l[0],d=l[2];if(e.xd.x&&s.x>d.x||e.yd.y&&s.y>d.y)return!1;const p=Me(e,s,l[0]);return p!==Me(e,s,l[1])||p!==Me(e,s,l[2])||p!==Me(e,s,l[3])}function yh(e,s,l){const c=s.paint.get(e).value;return"constant"===c.kind?c.value:l.programConfigurations.get(s.id).getMaxValue(e)}function vh(e){return Math.sqrt(e[0]*e[0]+e[1]*e[1])}function bh(e,s,l,d,p){if(!s[0]&&!s[1])return e;const f=c.convert(s)._mult(p);"viewport"===l&&f._rotate(-d);const m=[];for(let s=0;sDh(e,s,l,c)))}(_,d,f,m),P=g),Ah({queryGeometry:T,size:P,transform:d,unwrappedTileID:f,getElevation:m,pitchAlignment:b,pitchScale:y},c)}}class ml extends jo{}let Bh;Yl("HeatmapBucket",ml,{omit:["layers"]});var Nh={get paint(){return Bh=Bh||new Hs({"heatmap-radius":new Gs(Tt.paint_heatmap["heatmap-radius"]),"heatmap-weight":new Gs(Tt.paint_heatmap["heatmap-weight"]),"heatmap-intensity":new js(Tt.paint_heatmap["heatmap-intensity"]),"heatmap-color":new Zs(Tt.paint_heatmap["heatmap-color"]),"heatmap-opacity":new js(Tt.paint_heatmap["heatmap-opacity"])})}};function Uh(e,{width:s,height:l},c,d){if(d){if(d instanceof Uint8ClampedArray)d=new Uint8Array(d.buffer);else if(d.length!==s*l*c)throw new RangeError(`mismatched image size. expected: ${d.length} but got: ${s*l*c}`)}else d=new Uint8Array(s*l*c);return e.width=s,e.height=l,e.data=d,e}function qh(e,{width:s,height:l},c){if(s===e.width&&l===e.height)return;const d=Uh({},{width:s,height:l},c);$h(e,d,{x:0,y:0},{x:0,y:0},{width:Math.min(e.width,s),height:Math.min(e.height,l)},c),e.width=s,e.height=l,e.data=d.data}function $h(e,s,l,c,d,p){if(0===d.width||0===d.height)return s;if(d.width>e.width||d.height>e.height||l.x>e.width-d.width||l.y>e.height-d.height)throw new RangeError("out of range source coordinates for image copy");if(d.width>s.width||d.height>s.height||c.x>s.width-d.width||c.y>s.height-d.height)throw new RangeError("out of range destination coordinates for image copy");const f=e.data,m=s.data;if(f===m)throw new Error("srcData equals dstData, so image is already copied");for(let _=0;_{s[e.evaluationKey]=f;const m=e.expression.evaluate(s);d.setPixel(c/4/l,p/4,m)};if(e.clips)for(let s=0,d=0;sthis.max&&(this.max=l),l=this.dim+1||s<-1||s>=this.dim+1)throw new RangeError(`Out of range source coordinates for DEM data. x: ${e}, y: ${s}, dim: ${this.dim}`);return(s+1)*this.stride+(e+1)}unpack(e,s,l){return e*this.redFactor+s*this.greenFactor+l*this.blueFactor-this.baseShift}pack(e){return ou(e,this.getUnpackVector())}getPixels(){return new Sl({width:this.stride,height:this.stride},new Uint8Array(this.data.buffer))}backfillBorder(e,s,l){if(this.dim!==e.dim)throw new Error("dem dimension mismatch");let c=s*this.dim,d=s*this.dim+this.dim,p=l*this.dim,f=l*this.dim+this.dim;switch(s){case-1:c=d-1;break;case 1:d=c+1}switch(l){case-1:p=f-1;break;case 1:f=p+1}const m=-s*this.dim,_=-l*this.dim;for(let s=p;s0)for(let d=s;d=s;d-=c)p=Uu(d/c|0,e[d],e[d+1],p);return p&&Lu(p,p.next)&&(qu(p),p=p.next),p}function fu(e,s){if(!e)return e;s||(s=e);let l,c=e;do{if(l=!1,c.steiner||!Lu(c,c.next)&&0!==zu(c.prev,c,c.next))c=c.next;else{if(qu(c),c=s=c.prev,c===c.next)break;l=!0}}while(l||c!==s);return s}function mu(e,s,l,c,d,p,f){if(!e)return;!f&&p&&function(e,s,l,c){let d=e;do{0===d.z&&(d.z=Iu(d.x,d.y,s,l,c)),d.prevZ=d.prev,d.nextZ=d.next,d=d.next}while(d!==e);d.prevZ.nextZ=null,d.prevZ=null,function(e){let s,l=1;do{let c,d=e;e=null;let p=null;for(s=0;d;){s++;let f=d,m=0;for(let e=0;e0||_>0&&f;)0!==m&&(0===_||!f||d.z<=f.z)?(c=d,d=d.nextZ,m--):(c=f,f=f.nextZ,_--),p?p.nextZ=c:e=c,c.prevZ=p,p=c;d=f}p.nextZ=null,l*=2}while(s>1)}(d)}(e,c,d,p);let m=e;for(;e.prev!==e.next;){const _=e.prev,g=e.next;if(p?gu(e,c,d,p):_u(e))s.push(_.i,e.i,g.i),qu(e),e=g.next,m=g.next;else if((e=g)===m){f?1===f?mu(e=xu(fu(e),s),s,l,c,d,p,2):2===f&&vu(e,s,l,c,d,p):mu(fu(e),s,l,c,d,p,1);break}}}function _u(e){const s=e.prev,l=e,c=e.next;if(zu(s,l,c)>=0)return!1;const d=s.x,p=l.x,f=c.x,m=s.y,_=l.y,g=c.y,y=Math.min(d,p,f),b=Math.min(m,_,g),T=Math.max(d,p,f),P=Math.max(m,_,g);let S=c.next;for(;S!==s;){if(S.x>=y&&S.x<=T&&S.y>=b&&S.y<=P&&Au(d,m,p,_,f,g,S.x,S.y)&&zu(S.prev,S,S.next)>=0)return!1;S=S.next}return!0}function gu(e,s,l,c){const d=e.prev,p=e,f=e.next;if(zu(d,p,f)>=0)return!1;const m=d.x,_=p.x,g=f.x,y=d.y,b=p.y,T=f.y,P=Math.min(m,_,g),S=Math.min(y,b,T),I=Math.max(m,_,g),C=Math.max(y,b,T),z=Iu(P,S,s,l,c),L=Iu(I,C,s,l,c);let F=e.prevZ,B=e.nextZ;for(;F&&F.z>=z&&B&&B.z<=L;){if(F.x>=P&&F.x<=I&&F.y>=S&&F.y<=C&&F!==d&&F!==f&&Au(m,y,_,b,g,T,F.x,F.y)&&zu(F.prev,F,F.next)>=0)return!1;if(F=F.prevZ,B.x>=P&&B.x<=I&&B.y>=S&&B.y<=C&&B!==d&&B!==f&&Au(m,y,_,b,g,T,B.x,B.y)&&zu(B.prev,B,B.next)>=0)return!1;B=B.nextZ}for(;F&&F.z>=z;){if(F.x>=P&&F.x<=I&&F.y>=S&&F.y<=C&&F!==d&&F!==f&&Au(m,y,_,b,g,T,F.x,F.y)&&zu(F.prev,F,F.next)>=0)return!1;F=F.prevZ}for(;B&&B.z<=L;){if(B.x>=P&&B.x<=I&&B.y>=S&&B.y<=C&&B!==d&&B!==f&&Au(m,y,_,b,g,T,B.x,B.y)&&zu(B.prev,B,B.next)>=0)return!1;B=B.nextZ}return!0}function xu(e,s){let l=e;do{const c=l.prev,d=l.next.next;!Lu(c,d)&&Fu(c,l,l.next,d)&&ju(c,d)&&ju(d,c)&&(s.push(c.i,l.i,d.i),qu(l),qu(l.next),l=e=d),l=l.next}while(l!==e);return fu(l)}function vu(e,s,l,c,d,p){let f=e;do{let e=f.next.next;for(;e!==f.prev;){if(f.i!==e.i&&Du(f,e)){let m=Nu(f,e);return f=fu(f,f.next),m=fu(m,m.next),mu(f,s,l,c,d,p,0),void mu(m,s,l,c,d,p,0)}e=e.next}f=f.next}while(f!==e)}function bu(e,s){let l=e.x-s.x;return 0===l&&(l=e.y-s.y,0===l)&&(l=(e.next.y-e.y)/(e.next.x-e.x)-(s.next.y-s.y)/(s.next.x-s.x)),l}function Tu(e,s){const l=function(e,s){let l=s;const c=e.x,d=e.y;let p,f=-1/0;if(Lu(e,l))return l;do{if(Lu(e,l.next))return l.next;if(d<=l.y&&d>=l.next.y&&l.next.y!==l.y){const e=l.x+(d-l.y)*(l.next.x-l.x)/(l.next.y-l.y);if(e<=c&&e>f&&(f=e,p=l.x=l.x&&l.x>=_&&c!==l.x&&Cu(dp.x||l.x===p.x&&Su(p,l)))&&(p=l,y=s)}l=l.next}while(l!==m);return p}(e,s);if(!l)return s;const c=Nu(l,e);return fu(c,c.next),fu(l,l.next)}function Su(e,s){return zu(e.prev,e,s.prev)<0&&zu(s.next,e,e.next)<0}function Iu(e,s,l,c,d){return(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=(e-l)*d|0)|e<<8))|e<<4))|e<<2))|e<<1))|(s=1431655765&((s=858993459&((s=252645135&((s=16711935&((s=(s-c)*d|0)|s<<8))|s<<4))|s<<2))|s<<1))<<1}function Eu(e){let s=e,l=e;do{(s.x=(e-f)*(p-m)&&(e-f)*(c-m)>=(l-f)*(s-m)&&(l-f)*(p-m)>=(d-f)*(c-m)}function Au(e,s,l,c,d,p,f,m){return!(e===f&&s===m)&&Cu(e,s,l,c,d,p,f,m)}function Du(e,s){return e.next.i!==s.i&&e.prev.i!==s.i&&!function(e,s){let l=e;do{if(l.i!==e.i&&l.next.i!==e.i&&l.i!==s.i&&l.next.i!==s.i&&Fu(l,l.next,e,s))return!0;l=l.next}while(l!==e);return!1}(e,s)&&(ju(e,s)&&ju(s,e)&&function(e,s){let l=e,c=!1;const d=(e.x+s.x)/2,p=(e.y+s.y)/2;do{l.y>p!=l.next.y>p&&l.next.y!==l.y&&d<(l.next.x-l.x)*(p-l.y)/(l.next.y-l.y)+l.x&&(c=!c),l=l.next}while(l!==e);return c}(e,s)&&(zu(e.prev,e,s.prev)||zu(e,s.prev,s))||Lu(e,s)&&zu(e.prev,e,e.next)>0&&zu(s.prev,s,s.next)>0)}function zu(e,s,l){return(s.y-e.y)*(l.x-s.x)-(s.x-e.x)*(l.y-s.y)}function Lu(e,s){return e.x===s.x&&e.y===s.y}function Fu(e,s,l,c){const d=Ou(zu(e,s,l)),p=Ou(zu(e,s,c)),f=Ou(zu(l,c,e)),m=Ou(zu(l,c,s));return d!==p&&f!==m||!(0!==d||!Bu(e,l,s))||!(0!==p||!Bu(e,c,s))||!(0!==f||!Bu(l,e,c))||!(0!==m||!Bu(l,s,c))}function Bu(e,s,l){return s.x<=Math.max(e.x,l.x)&&s.x>=Math.min(e.x,l.x)&&s.y<=Math.max(e.y,l.y)&&s.y>=Math.min(e.y,l.y)}function Ou(e){return e>0?1:e<0?-1:0}function ju(e,s){return zu(e.prev,e,e.next)<0?zu(e,s,e.next)>=0&&zu(e,e.prev,s)>=0:zu(e,s,e.prev)<0||zu(e,e.next,s)<0}function Nu(e,s){const l=Zu(e.i,e.x,e.y),c=Zu(s.i,s.x,s.y),d=e.next,p=s.prev;return e.next=s,s.prev=e,l.next=d,d.prev=l,c.next=l,l.prev=c,p.next=c,c.prev=p,c}function Uu(e,s,l,c){const d=Zu(e,s,l);return c?(d.next=c.next,d.prev=c,c.next.prev=d,c.next=d):(d.prev=d,d.next=d),d}function qu(e){e.next.prev=e.prev,e.prev.next=e.next,e.prevZ&&(e.prevZ.nextZ=e.nextZ),e.nextZ&&(e.nextZ.prevZ=e.prevZ)}function Zu(e,s,l){return{i:e,x:s,y:l,prev:null,next:null,z:0,prevZ:null,nextZ:null,steiner:!1}}class hu{constructor(e,s){if(s>e)throw new Error("Min granularity must not be greater than base granularity.");this._baseZoomGranularity=e,this._minGranularity=s}getGranularityForZoomLevel(e){return Math.max(Math.floor(this._baseZoomGranularity/(1<32767||s>32767)throw new Error("Vertex coordinates are out of signed 16 bit integer range.");const l=0|Math.round(e),c=0|Math.round(s),d=this._getKey(l,c);if(this._vertexDictionary.has(d))return this._vertexDictionary.get(d);const p=this._vertexBuffer.length/2;return this._vertexDictionary.set(d,p),this._vertexBuffer.push(l,c),p}_subdivideTrianglesScanline(e){if(this._granularity<2)return function(e,s){const l=[];for(let c=0;c0?(l.push(d),l.push(f),l.push(p)):(l.push(d),l.push(p),l.push(f))}return l}(this._vertexBuffer,e);const s=[],l=e.length;for(let c=0;c=1||F<=0)||I&&(md)){g>=c&&g<=d&&p.push(l[(e+1)%3]);continue}!I&&L>0&&p.push(this._vertexToIndex(f+T*L,m+P*L));const B=f+T*Math.max(L,0),O=f+T*Math.min(F,1);S||this._generateIntraEdgeVertices(p,f,m,_,g,B,O),!I&&F<1&&p.push(this._vertexToIndex(f+T*F,m+P*F)),(I||g>=c&&g<=d)&&p.push(l[(e+1)%3]),!I&&(g<=c||g>=d)&&this._generateInterEdgeVertices(p,f,m,_,g,y,b,O,c,d)}return p}_generateIntraEdgeVertices(e,s,l,c,d,p,f){const m=c-s,_=d-l,g=0===_,y=g?Math.min(s,c):Math.min(p,f),b=g?Math.max(s,c):Math.max(p,f),T=Math.floor(y/this._granularityCellSize)+1,P=Math.ceil(b/this._granularityCellSize)-1;if(g?s=T;c--){const d=c*this._granularityCellSize;e.push(this._vertexToIndex(d,l+_*(d-s)/m))}}_generateInterEdgeVertices(e,s,l,c,d,p,f,m,_,g){const y=d-l,b=p-c,T=f-d,P=(_-d)/T,S=(g-d)/T,I=Math.min(P,S),C=Math.max(P,S),z=c+b*I;let L=Math.floor(Math.min(z,m)/this._granularityCellSize)+1,F=Math.ceil(Math.max(z,m)/this._granularityCellSize)-1,B=m=1||C<=0){const e=l-f,c=p+(s-p)*Math.min((_-f)/e,(g-f)/e);L=Math.floor(Math.min(c,m)/this._granularityCellSize)+1,F=Math.ceil(Math.max(c,m)/this._granularityCellSize)-1,B=m0?g:_;if(B)for(let s=L;s<=F;s++)e.push(this._vertexToIndex(s*this._granularityCellSize,j));else for(let s=F;s>=L;s--)e.push(this._vertexToIndex(s*this._granularityCellSize,j))}_generateOutline(e){const s=[];for(const l of e){const e=Xu(l,this._granularity,!0),c=this._pointArrayToIndices(e),d=[];for(let e=1;ed!=(p===$u)?(e.push(s),e.push(l),e.push(this._vertexToIndex(c,p)),e.push(l),e.push(this._vertexToIndex(d,p)),e.push(this._vertexToIndex(c,p))):(e.push(l),e.push(s),e.push(this._vertexToIndex(c,p)),e.push(this._vertexToIndex(d,p)),e.push(l),e.push(this._vertexToIndex(c,p)))}_fillPoles(e,s,l){const c=this._vertexBuffer,d=se,p=e.length;for(let f=2;f80*l){m=e[0],_=e[1];let s=m,c=_;for(let p=l;ps&&(s=l),d>c&&(c=d)}g=Math.max(s-m,c-_),g=0!==g?32767/g:0}return mu(p,f,l,m,_,g,0),f}(l,c),s=this._convertIndices(l,e);d=this._subdivideTrianglesScanline(s)}catch(e){console.error(e)}let p=[];return s&&(p=this._generateOutline(e)),this._ensureNoPoleVertices(),this._handlePoles(d),{verticesFlattened:this._vertexBuffer,indicesTriangles:d,indicesLineList:p}}_convertIndices(e,s){const l=[];for(let c=0;c0?(Math.floor(L/m)+1)*m:(Math.ceil(L/m)-1)*m,s=I>0?(Math.floor(F/m)+1)*m:(Math.ceil(F/m)-1)*m,l=Math.abs(L-e),d=Math.abs(F-s),p=Math.abs(L-y),f=Math.abs(F-b),g=T?l/C:Number.POSITIVE_INFINITY,B=P?d/z:Number.POSITIVE_INFINITY;if((p<=l||!T)&&(f<=d||!P))break;if(g=0?f-1:p-1,d=(m+1)%p,_=e[2*s[c]],g=e[2*s[d]],y=e[2*s[f]],b=e[2*s[f]+1],T=e[2*s[m]+1];let P=!1;if(_g)P=!1;else{const l=T-b,p=-(e[2*s[m]]-y),f=b((g-y)*l+(e[2*s[d]+1]-b)*p)*f&&(P=!0)}if(P){const e=s[c],d=s[f],_=s[m];e!==d&&e!==_&&d!==_&&l.push(_,d,e),f--,f<0&&(f=p-1)}else{const e=s[d],c=s[f],_=s[m];e!==c&&e!==_&&c!==_&&l.push(_,c,e),m++,m>=p&&(m=0)}if(c===d)break}}function Ku(e,s,l,c,d,p,f,m,_){const g=d.length/2,y=f&&m&&_;if(gio.MAX_VERTEX_ARRAY_LENGTH&&(g=e.createNewSegment(s,l),_=m.count,I=!0,C=!0,z=!0,y=0);const L=Qu(f,c,p,m,T,I,g),F=Qu(f,c,p,m,P,C,g),B=Qu(f,c,p,m,S,z,g);l.emplaceBack(y+L-_,y+F-_,y+B-_),g.primitiveLength++}}(s,l,c,d,p,e),y&&function(e,s,l,c,d,p){const f=[];for(let e=0;eio.MAX_VERTEX_ARRAY_LENGTH&&(g=e.createNewSegment(s,l),_=m.count,S=!0,I=!0,y=0);const C=Qu(f,c,p,m,d,S,g),z=Qu(f,c,p,m,b,I,g);l.emplaceBack(y+C-_,y+z-_),g.primitiveLength++}}}(f,l,m,d,_,e),s.forceNewSegmentOnNextPrepare(),null==f||f.forceNewSegmentOnNextPrepare()}function Qu(e,s,l,c,d,p,f){if(p){const p=c.count;return l(s[2*d],s[2*d+1]),e[d]=c.count,c.count++,f.vertexLength++,p}return e[d]}class wu{constructor(e){this.zoom=e.zoom,this.overscaling=e.overscaling,this.layers=e.layers,this.layerIds=this.layers.map((e=>e.id)),this.index=e.index,this.hasDependencies=!1,this.patternFeatures=[],this.layoutVertexArray=new qa,this.indexArray=new to,this.indexArray2=new eo,this.programConfigurations=new Vo(e.layers,e.zoom),this.segments=new io,this.segments2=new io,this.stateDependentLayerIds=this.layers.filter((e=>e.isStateDependent())).map((e=>e.id))}populate(e,s,l){this.hasDependencies=cu("fill",this.layers,s);const c=this.layers[0].layout.get("fill-sort-key"),d=!c.isConstant(),p=[];for(const{feature:f,id:m,index:_,sourceLayerIndex:g}of e){const e=this.layers[0]._featureFilter.needGeometry,y=Jc(f,e);if(!this.layers[0]._featureFilter.filter(new Ps(this.zoom),y,l))continue;const b=d?c.evaluate(y,{},l,s.availableImages):void 0,T={id:m,properties:f.properties,type:f.type,sourceLayerIndex:g,index:_,geometry:e?y.geometry:Qc(f),patterns:{},sortKey:b};p.push(T)}d&&p.sort(((e,s)=>e.sortKey-s.sortKey));for(const c of p){const{geometry:d,index:p,sourceLayerIndex:f}=c;if(this.hasDependencies){const e=uu("fill",this.layers,c,{zoom:this.zoom},s);this.patternFeatures.push(e)}else this.addFeature(c,d,p,l,{},s.subdivisionGranularity);s.featureIndex.insert(e[p].feature,d,p,f,this.index)}}update(e,s,l){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(e,s,this.stateDependentLayers,{imagePositions:l})}addFeatures(e,s,l){for(const c of this.patternFeatures)this.addFeature(c,c.geometry,c.index,s,l,e.subdivisionGranularity)}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(e){this.uploaded||(this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,lu),this.indexBuffer=e.createIndexBuffer(this.indexArray),this.indexBuffer2=e.createIndexBuffer(this.indexArray2)),this.programConfigurations.upload(e),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(e,s,l,c,d,p){for(const e of Sn(s,500)){const s=Hu(e,c,p.fill.getGranularityForZoomLevel(c.z)),l=this.layoutVertexArray;Ku(((e,s)=>{l.emplaceBack(e,s)}),this.segments,this.layoutVertexArray,this.indexArray,s.verticesFlattened,s.indicesTriangles,this.segments2,this.indexArray2,s.indicesLineList)}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,e,l,{imagePositions:d,canonical:c})}}let Ju,ed;Yl("FillBucket",wu,{omit:["layers","patternFeatures"]});var td={get paint(){return ed=ed||new Hs({"fill-antialias":new js(Tt.paint_fill["fill-antialias"]),"fill-opacity":new Gs(Tt.paint_fill["fill-opacity"]),"fill-color":new Gs(Tt.paint_fill["fill-color"]),"fill-outline-color":new Gs(Tt.paint_fill["fill-outline-color"]),"fill-translate":new js(Tt.paint_fill["fill-translate"]),"fill-translate-anchor":new js(Tt.paint_fill["fill-translate-anchor"]),"fill-pattern":new Xs(Tt.paint_fill["fill-pattern"])})},get layout(){return Ju=Ju||new Hs({"fill-sort-key":new Gs(Tt.layout_fill["fill-sort-key"])})}};class ku extends Ks{constructor(e,s){super(e,td,s)}recalculate(e,s){super.recalculate(e,s);const l=this.paint._values["fill-outline-color"];"constant"===l.value.kind&&void 0===l.value.value&&(this.paint._values["fill-outline-color"]=this.paint._values["fill-color"])}createBucket(e){return new wu(e)}queryRadius(){return vh(this.paint.get("fill-translate"))}queryIntersectsFeature({queryGeometry:e,geometry:s,transform:l,pixelsToTileUnits:c}){return nh(bh(e,this.paint.get("fill-translate"),this.paint.get("fill-translate-anchor"),-l.bearingInRadians,c),s)}isTileClipped(){return!0}}const id=Mc([{name:"a_pos",components:2,type:"Int16"},{name:"a_normal_ed",components:4,type:"Int16"}],4),rd=Mc([{name:"a_centroid",components:2,type:"Int16"}],4),{members:nd}=id;class Mu{constructor(e,s,l,c,d){this.properties={},this.extent=l,this.type=0,this.id=void 0,this._pbf=e,this._geometry=-1,this._keys=c,this._values=d,e.readFields(sd,this,s)}loadGeometry(){const e=this._pbf;e.pos=this._geometry;const s=e.readVarint()+e.pos,l=[];let d,p=1,f=0,m=0,_=0;for(;e.pos>3}if(f--,1===p||2===p)m+=e.readSVarint(),_+=e.readSVarint(),1===p&&(d&&l.push(d),d=[]),d&&d.push(new c(m,_));else{if(7!==p)throw new Error(`unknown command ${p}`);d&&d.push(d[0].clone())}}return d&&l.push(d),l}bbox(){const e=this._pbf;e.pos=this._geometry;const s=e.readVarint()+e.pos;let l=1,c=0,d=0,p=0,f=1/0,m=-1/0,_=1/0,g=-1/0;for(;e.pos>3}if(c--,1===l||2===l)d+=e.readSVarint(),p+=e.readSVarint(),dm&&(m=d),p<_&&(_=p),p>g&&(g=p);else if(7!==l)throw new Error(`unknown command ${l}`)}return[f,_,m,g]}toGeoJSON(e,s,l){const c=this.extent*Math.pow(2,l),d=this.extent*e,p=this.extent*s,f=this.loadGeometry();function m(e){return[360*(e.x+d)/c-180,360/Math.PI*Math.atan(Math.exp((1-2*(e.y+p)/c)*Math.PI))-90]}function _(e){return e.map(m)}let g;if(1===this.type){const e=[];for(const s of f)e.push(s[0]);const s=_(e);g=1===e.length?{type:"Point",coordinates:s[0]}:{type:"MultiPoint",coordinates:s}}else if(2===this.type){const e=f.map(_);g=1===e.length?{type:"LineString",coordinates:e[0]}:{type:"MultiLineString",coordinates:e}}else{if(3!==this.type)throw new Error("unknown feature type");{const e=od(f),s=[];for(const l of e)s.push(l.map(_));g=1===s.length?{type:"Polygon",coordinates:s[0]}:{type:"MultiPolygon",coordinates:s}}}const y={type:"Feature",geometry:g,properties:this.properties};return null!=this.id&&(y.id=this.id),y}}function sd(e,s,l){1===e?s.id=l.readVarint():2===e?function(e,s){const l=e.readVarint()+e.pos;for(;e.pos=this._features.length)throw new Error("feature index out of bounds");this._pbf.pos=this._features[e];const s=this._pbf.readVarint()+this._pbf.pos;return new Mu(this._pbf,s,this.extent,this._keys,this._values)}}function cd(e,s,l){15===e?s.version=l.readVarint():1===e?s.name=l.readString():5===e?s.extent=l.readVarint():2===e?s._features.push(l.pos):3===e?s._keys.push(l.readString()):4===e&&s._values.push(function(e){let s=null;const l=e.readVarint()+e.pos;for(;e.pos>3;s=1===l?e.readString():2===l?e.readFloat():3===l?e.readDouble():4===l?e.readVarint64():5===l?e.readVarint():6===l?e.readSVarint():7===l?e.readBoolean():null}if(null==s)throw new Error("unknown feature value");return s}(l))}class Vu{constructor(e,s){this.layers=e.readFields(hd,{},s)}}function hd(e,s,l){if(3===e){const e=new Pu(l,l.readVarint()+l.pos);e.length&&(s[e.name]=e)}}const dd=Math.pow(2,13);function pd(e,s,l,c,d,p,f,m){e.emplaceBack(s,l,2*Math.floor(c*dd)+f,d*dd*2,p*dd*2,Math.round(m))}class Ru{constructor(e){this.zoom=e.zoom,this.overscaling=e.overscaling,this.layers=e.layers,this.layerIds=this.layers.map((e=>e.id)),this.index=e.index,this.hasDependencies=!1,this.layoutVertexArray=new ja,this.centroidVertexArray=new $a,this.indexArray=new to,this.programConfigurations=new Vo(e.layers,e.zoom),this.segments=new io,this.stateDependentLayerIds=this.layers.filter((e=>e.isStateDependent())).map((e=>e.id))}populate(e,s,l){this.features=[],this.hasDependencies=cu("fill-extrusion",this.layers,s);for(const{feature:c,id:d,index:p,sourceLayerIndex:f}of e){const e=this.layers[0]._featureFilter.needGeometry,m=Jc(c,e);if(!this.layers[0]._featureFilter.filter(new Ps(this.zoom),m,l))continue;const _={id:d,sourceLayerIndex:f,index:p,geometry:e?m.geometry:Qc(c),properties:c.properties,type:c.type,patterns:{}};this.hasDependencies?this.features.push(uu("fill-extrusion",this.layers,_,{zoom:this.zoom},s)):this.addFeature(_,_.geometry,p,l,{},s.subdivisionGranularity),s.featureIndex.insert(c,_.geometry,p,f,this.index,!0)}}addFeatures(e,s,l){for(const c of this.features){const{geometry:d}=c;this.addFeature(c,d,c.index,s,l,e.subdivisionGranularity)}}update(e,s,l){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(e,s,this.stateDependentLayers,{imagePositions:l})}isEmpty(){return 0===this.layoutVertexArray.length&&0===this.centroidVertexArray.length}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(e){this.uploaded||(this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,nd),this.centroidVertexBuffer=e.createVertexBuffer(this.centroidVertexArray,rd.members,!0),this.indexBuffer=e.createIndexBuffer(this.indexArray)),this.programConfigurations.upload(e),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy(),this.centroidVertexBuffer.destroy())}addFeature(e,s,l,c,d,p){for(const l of Sn(s,500)){const s={x:0,y:0,sampleCount:0},d=this.layoutVertexArray.length;this.processPolygon(s,c,e,l,p);const f=this.layoutVertexArray.length-d,m=Math.floor(s.x/s.sampleCount),_=Math.floor(s.y/s.sampleCount);for(let e=0;e{pd(g,e,s,0,0,1,1,0)}),this.segments,this.layoutVertexArray,this.indexArray,_.verticesFlattened,_.indicesTriangles)}_generateSideFaces(e,s){let l=0;for(let c=1;cio.MAX_VERTEX_ARRAY_LENGTH&&(s.segment=this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray));const f=d.sub(p)._perp()._unit(),m=p.dist(d);l+m>32768&&(l=0),pd(this.layoutVertexArray,d.x,d.y,f.x,f.y,0,0,l),pd(this.layoutVertexArray,d.x,d.y,f.x,f.y,0,1,l),l+=m,pd(this.layoutVertexArray,p.x,p.y,f.x,f.y,0,0,l),pd(this.layoutVertexArray,p.x,p.y,f.x,f.y,0,1,l);const _=s.segment.vertexLength;this.indexArray.emplaceBack(_,_+2,_+1),this.indexArray.emplaceBack(_+1,_+2,_+3),s.segment.vertexLength+=4,s.segment.primitiveLength+=2}}}function fd(e,s){for(let l=0;lse)||e.y===s.y&&(e.y<0||e.y>se)}function _d(e){return e.every((e=>e.x<0))||e.every((e=>e.x>se))||e.every((e=>e.y<0))||e.every((e=>e.y>se))}let gd;Yl("FillExtrusionBucket",Ru,{omit:["layers","features"]});var yd={get paint(){return gd=gd||new Hs({"fill-extrusion-opacity":new js(Tt["paint_fill-extrusion"]["fill-extrusion-opacity"]),"fill-extrusion-color":new Gs(Tt["paint_fill-extrusion"]["fill-extrusion-color"]),"fill-extrusion-translate":new js(Tt["paint_fill-extrusion"]["fill-extrusion-translate"]),"fill-extrusion-translate-anchor":new js(Tt["paint_fill-extrusion"]["fill-extrusion-translate-anchor"]),"fill-extrusion-pattern":new Xs(Tt["paint_fill-extrusion"]["fill-extrusion-pattern"]),"fill-extrusion-height":new Gs(Tt["paint_fill-extrusion"]["fill-extrusion-height"]),"fill-extrusion-base":new Gs(Tt["paint_fill-extrusion"]["fill-extrusion-base"]),"fill-extrusion-vertical-gradient":new js(Tt["paint_fill-extrusion"]["fill-extrusion-vertical-gradient"])})}};class Gu extends Ks{constructor(e,s){super(e,yd,s)}createBucket(e){return new Ru(e)}queryRadius(){return vh(this.paint.get("fill-extrusion-translate"))}is3D(){return!0}queryIntersectsFeature({queryGeometry:e,feature:s,featureState:l,geometry:d,transform:p,pixelsToTileUnits:f,pixelPosMatrix:m}){const _=bh(e,this.paint.get("fill-extrusion-translate"),this.paint.get("fill-extrusion-translate-anchor"),-p.bearingInRadians,f),g=this.paint.get("fill-extrusion-height").evaluate(s,l),y=this.paint.get("fill-extrusion-base").evaluate(s,l),b=function(e,s){const l=[];for(const d of e){const e=[d.x,d.y,0,1];q(e,e,s),l.push(new c(e[0]/e[3],e[1]/e[3]))}return l}(_,m),T=function(e,s,l,d){const p=[],f=[],m=d[8]*s,_=d[9]*s,g=d[10]*s,y=d[11]*s,b=d[8]*l,T=d[9]*l,P=d[10]*l,S=d[11]*l;for(const s of e){const e=[],l=[];for(const p of s){const s=p.x,f=p.y,I=d[0]*s+d[4]*f+d[12],C=d[1]*s+d[5]*f+d[13],z=d[2]*s+d[6]*f+d[14],L=d[3]*s+d[7]*f+d[15],F=z+g,B=L+y,O=I+b,j=C+T,G=z+P,U=L+S,q=new c((I+m)/B,(C+_)/B);q.z=F/B,e.push(q);const Z=new c(O/U,j/U);Z.z=G/U,l.push(Z)}p.push(e),f.push(l)}return[p,f]}(d,y,g,m);return function(e,s,l){let c=1/0;nh(l,s)&&(c=vd(l,s[0]));for(let d=0;de.id)),this.index=e.index,this.hasDependencies=!1,this.patternFeatures=[],this.lineClipsArray=[],this.gradients={},this.layers.forEach((e=>{this.gradients[e.id]={}})),this.layoutVertexArray=new Ga,this.layoutVertexArray2=new Xa,this.indexArray=new to,this.programConfigurations=new Vo(e.layers,e.zoom),this.segments=new io,this.maxLineLength=0,this.stateDependentLayerIds=this.layers.filter((e=>e.isStateDependent())).map((e=>e.id))}populate(e,s,l){this.hasDependencies=cu("line",this.layers,s)||this.hasLineDasharray(this.layers);const c=this.layers[0].layout.get("line-sort-key"),d=!c.isConstant(),p=[];for(const{feature:s,id:f,index:m,sourceLayerIndex:_}of e){const e=this.layers[0]._featureFilter.needGeometry,g=Jc(s,e);if(!this.layers[0]._featureFilter.filter(new Ps(this.zoom),g,l))continue;const y=d?c.evaluate(g,{},l):void 0,b={id:f,properties:s.properties,type:s.type,sourceLayerIndex:_,index:m,geometry:e?g.geometry:Qc(s),patterns:{},dashes:{},sortKey:y};p.push(b)}d&&p.sort(((e,s)=>e.sortKey-s.sortKey));for(const c of p){const{geometry:d,index:p,sourceLayerIndex:f}=c;this.hasDependencies?(cu("line",this.layers,s)?uu("line",this.layers,c,{zoom:this.zoom},s):this.hasLineDasharray(this.layers)&&this.addLineDashDependencies(this.layers,c,this.zoom,s),this.patternFeatures.push(c)):this.addFeature(c,d,p,l,{},{},s.subdivisionGranularity),s.featureIndex.insert(e[p].feature,d,p,f,this.index)}}update(e,s,l,c){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(e,s,this.stateDependentLayers,{imagePositions:l,dashPositions:c})}addFeatures(e,s,l,c){for(const d of this.patternFeatures)this.addFeature(d,d.geometry,d.index,s,l,c,e.subdivisionGranularity)}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(e){this.uploaded||(0!==this.layoutVertexArray2.length&&(this.layoutVertexBuffer2=e.createVertexBuffer(this.layoutVertexArray2,Pd)),this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,wd),this.indexBuffer=e.createIndexBuffer(this.indexArray)),this.programConfigurations.upload(e),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy())}lineFeatureClips(e){if(e.properties&&Object.prototype.hasOwnProperty.call(e.properties,"mapbox_clip_start")&&Object.prototype.hasOwnProperty.call(e.properties,"mapbox_clip_end"))return{start:+e.properties.mapbox_clip_start,end:+e.properties.mapbox_clip_end}}addFeature(e,s,l,c,d,p,f){const m=this.layers[0].layout,_=m.get("line-join").evaluate(e,{}),g=m.get("line-cap"),y=m.get("line-miter-limit"),b=m.get("line-round-limit");this.lineClips=this.lineFeatureClips(e);for(const l of s)this.addLine(l,e,_,g,y,b,c,f);this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,e,l,{imagePositions:d,dashPositions:p,canonical:c})}addLine(e,s,l,c,d,p,f,m){if(this.distance=0,this.scaledDistance=0,this.totalDistance=0,e=Xu(e,f?m.line.getGranularityForZoomLevel(f.z):1),this.lineClips){this.lineClipsArray.push(this.lineClips);for(let s=0;s=2&&e[g-1].equals(e[g-2]);)g--;let y=0;for(;y0;if(O&&s>y){const e=P.dist(S);if(e>2*b){const s=P.sub(P.sub(S)._mult(b/e)._round());this.updateDistance(S,s),this.addCurrentVertex(s,C,0,0,T),S=s}}const G=S&&I;let U=G?l:_?"butt":c;if(G&&"round"===U&&(Fd&&(U="bevel"),"bevel"===U&&(F>2&&(U="flipbevel"),F100)f=z.mult(-1);else{const e=F*C.add(z).mag()/C.sub(z).mag();f._perp()._mult(e*(j?-1:1))}this.addCurrentVertex(P,f,0,0,T),this.addCurrentVertex(P,f.mult(-1),0,0,T)}else if("bevel"===U||"fakeround"===U){const e=-Math.sqrt(F*F-1),s=j?e:0,l=j?0:e;if(S&&this.addCurrentVertex(P,C,s,l,T),"fakeround"===U){const e=Math.round(180*B/Math.PI/20);for(let s=1;s2*b){const s=P.add(I.sub(P)._mult(b/e)._round());this.updateDistance(P,s),this.addCurrentVertex(s,z,0,0,T),P=s}}}}addCurrentVertex(e,s,l,c,d,p=!1){const f=s.y*c-s.x,m=-s.y-s.x*c;this.addHalfVertex(e,s.x+s.y*l,s.y-s.x*l,p,!1,l,d),this.addHalfVertex(e,f,m,p,!0,-c,d),this.distance>Id/2&&0===this.totalDistance&&(this.distance=0,this.updateScaledDistance(),this.addCurrentVertex(e,s,l,c,d,p))}addHalfVertex({x:e,y:s},l,c,d,p,f,m){const _=.5*(this.lineClips?this.scaledDistance*(Id-1):this.scaledDistance);this.layoutVertexArray.emplaceBack((e<<1)+(d?1:0),(s<<1)+(p?1:0),Math.round(63*l)+128,Math.round(63*c)+128,1+(0===f?0:f<0?-1:1)|(63&_)<<2,_>>6),this.lineClips&&this.layoutVertexArray2.emplaceBack((this.scaledDistance-this.lineClips.start)/(this.lineClips.end-this.lineClips.start),this.lineClipsArray.length);const g=m.vertexLength++;this.e1>=0&&this.e2>=0&&(this.indexArray.emplaceBack(this.e1,g,this.e2),m.primitiveLength++),p?this.e2=g:this.e1=g}updateScaledDistance(){this.scaledDistance=this.lineClips?this.lineClips.start+(this.lineClips.end-this.lineClips.start)*this.distance/this.totalDistance:this.distance}updateDistance(e,s){this.distance+=e.dist(s),this.updateScaledDistance()}hasLineDasharray(e){for(const s of e){const e=s.paint.get("line-dasharray");if(e&&!e.isConstant())return!0}return!1}addLineDashDependencies(e,s,l,c){for(const d of e){const e=d.paint.get("line-dasharray");if(!e||"constant"===e.value.kind)continue;const p="round"===d.layout.get("line-cap"),f={dasharray:e.value.evaluate({zoom:l-1},s,{}),round:p},m={dasharray:e.value.evaluate({zoom:l},s,{}),round:p},_={dasharray:e.value.evaluate({zoom:l+1},s,{}),round:p},g=`${f.dasharray.join(",")},${f.round}`,y=`${m.dasharray.join(",")},${m.round}`,b=`${_.dasharray.join(",")},${_.round}`;c.dashDependencies[g]=f,c.dashDependencies[y]=m,c.dashDependencies[b]=_,s.dashes[d.id]={min:g,mid:y,max:b}}}}let Ed,Cd;Yl("LineBucket",tc,{omit:["layers","patternFeatures"]});var Ad={get paint(){return Cd=Cd||new Hs({"line-opacity":new Gs(Tt.paint_line["line-opacity"]),"line-color":new Gs(Tt.paint_line["line-color"]),"line-translate":new js(Tt.paint_line["line-translate"]),"line-translate-anchor":new js(Tt.paint_line["line-translate-anchor"]),"line-width":new Gs(Tt.paint_line["line-width"]),"line-gap-width":new Gs(Tt.paint_line["line-gap-width"]),"line-offset":new Gs(Tt.paint_line["line-offset"]),"line-blur":new Gs(Tt.paint_line["line-blur"]),"line-dasharray":new Xs(Tt.paint_line["line-dasharray"]),"line-pattern":new Xs(Tt.paint_line["line-pattern"]),"line-gradient":new Zs(Tt.paint_line["line-gradient"])})},get layout(){return Ed=Ed||new Hs({"line-cap":new js(Tt.layout_line["line-cap"]),"line-join":new Gs(Tt.layout_line["line-join"]),"line-miter-limit":new js(Tt.layout_line["line-miter-limit"]),"line-round-limit":new js(Tt.layout_line["line-round-limit"]),"line-sort-key":new Gs(Tt.layout_line["line-sort-key"])})}};class ic extends Gs{possiblyEvaluate(e,s){return s=new Ps(Math.floor(s.zoom),{now:s.now,fadeDuration:s.fadeDuration,zoomHistory:s.zoomHistory,transition:s.transition}),super.possiblyEvaluate(e,s)}evaluate(e,s,l,c){return s=ge({},s,{zoom:Math.floor(s.zoom)}),super.evaluate(e,s,l,c)}}let Dd;class ac extends Ks{constructor(e,s){super(e,Ad,s),this.gradientVersion=0,Dd||(Dd=new ic(Ad.paint.properties["line-width"].specification),Dd.useIntegerZoom=!0)}_handleSpecialPaintPropertyUpdate(e){if("line-gradient"===e){const e=this.gradientExpression();this.stepInterpolant=!!function(e){return void 0!==e._styleExpression}(e)&&e._styleExpression.expression instanceof or,this.gradientVersion=(this.gradientVersion+1)%Number.MAX_SAFE_INTEGER}}gradientExpression(){return this._transitionablePaint._values["line-gradient"].value.expression}recalculate(e,s){super.recalculate(e,s),this.paint._values["line-floorwidth"]=Dd.possiblyEvaluate(this._transitioningPaint._values["line-width"].value,e)}createBucket(e){return new tc(e)}queryRadius(e){const s=e,l=zd(yh("line-width",this,s),yh("line-gap-width",this,s)),c=yh("line-offset",this,s);return l/2+Math.abs(c)+vh(this.paint.get("line-translate"))}queryIntersectsFeature({queryGeometry:e,feature:s,featureState:l,geometry:d,transform:p,pixelsToTileUnits:f}){const m=bh(e,this.paint.get("line-translate"),this.paint.get("line-translate-anchor"),-p.bearingInRadians,f),_=f/2*zd(this.paint.get("line-width").evaluate(s,l),this.paint.get("line-gap-width").evaluate(s,l)),g=this.paint.get("line-offset").evaluate(s,l);return g&&(d=function(e,s){const l=[];for(let d=0;d=3)for(let s=0;s0?s+2*e:e}const kd=Mc([{name:"a_pos_offset",components:4,type:"Int16"},{name:"a_data",components:4,type:"Uint16"},{name:"a_pixeloffset",components:4,type:"Int16"}],4),Rd=Mc([{name:"a_projected_pos",components:3,type:"Float32"}],4);Mc([{name:"a_fade_opacity",components:1,type:"Uint32"}],4);const Ld=Mc([{name:"a_placed",components:2,type:"Uint8"},{name:"a_shift",components:2,type:"Float32"},{name:"a_box_real",components:2,type:"Int16"}]);Mc([{type:"Int16",name:"anchorPointX"},{type:"Int16",name:"anchorPointY"},{type:"Int16",name:"x1"},{type:"Int16",name:"y1"},{type:"Int16",name:"x2"},{type:"Int16",name:"y2"},{type:"Uint32",name:"featureIndex"},{type:"Uint16",name:"sourceLayerIndex"},{type:"Uint16",name:"bucketIndex"}]);const Fd=Mc([{name:"a_pos",components:2,type:"Int16"},{name:"a_anchor_pos",components:2,type:"Int16"},{name:"a_extrude",components:2,type:"Int16"}],4),Bd=Mc([{name:"a_pos",components:2,type:"Float32"},{name:"a_radius",components:1,type:"Float32"},{name:"a_flags",components:2,type:"Int16"}],4);function Od(e,s,l){return e.sections.forEach((e=>{e.text=function(e,s,l){const c=s.layout.get("text-transform").evaluate(l,{});return"uppercase"===c?e=e.toLocaleUpperCase():"lowercase"===c&&(e=e.toLocaleLowerCase()),yc.applyArabicShaping&&(e=yc.applyArabicShaping(e)),e}(e.text,s,l)})),e}Mc([{name:"triangle",components:3,type:"Uint16"}]),Mc([{type:"Int16",name:"anchorX"},{type:"Int16",name:"anchorY"},{type:"Uint16",name:"glyphStartIndex"},{type:"Uint16",name:"numGlyphs"},{type:"Uint32",name:"vertexStartIndex"},{type:"Uint32",name:"lineStartIndex"},{type:"Uint32",name:"lineLength"},{type:"Uint16",name:"segment"},{type:"Uint16",name:"lowerSize"},{type:"Uint16",name:"upperSize"},{type:"Float32",name:"lineOffsetX"},{type:"Float32",name:"lineOffsetY"},{type:"Uint8",name:"writingMode"},{type:"Uint8",name:"placedOrientation"},{type:"Uint8",name:"hidden"},{type:"Uint32",name:"crossTileID"},{type:"Int16",name:"associatedIconIndex"}]),Mc([{type:"Int16",name:"anchorX"},{type:"Int16",name:"anchorY"},{type:"Int16",name:"rightJustifiedTextSymbolIndex"},{type:"Int16",name:"centerJustifiedTextSymbolIndex"},{type:"Int16",name:"leftJustifiedTextSymbolIndex"},{type:"Int16",name:"verticalPlacedTextSymbolIndex"},{type:"Int16",name:"placedIconSymbolIndex"},{type:"Int16",name:"verticalPlacedIconSymbolIndex"},{type:"Uint16",name:"key"},{type:"Uint16",name:"textBoxStartIndex"},{type:"Uint16",name:"textBoxEndIndex"},{type:"Uint16",name:"verticalTextBoxStartIndex"},{type:"Uint16",name:"verticalTextBoxEndIndex"},{type:"Uint16",name:"iconBoxStartIndex"},{type:"Uint16",name:"iconBoxEndIndex"},{type:"Uint16",name:"verticalIconBoxStartIndex"},{type:"Uint16",name:"verticalIconBoxEndIndex"},{type:"Uint16",name:"featureIndex"},{type:"Uint16",name:"numHorizontalGlyphVertices"},{type:"Uint16",name:"numVerticalGlyphVertices"},{type:"Uint16",name:"numIconVertices"},{type:"Uint16",name:"numVerticalIconVertices"},{type:"Uint16",name:"useRuntimeCollisionCircles"},{type:"Uint32",name:"crossTileID"},{type:"Float32",name:"textBoxScale"},{type:"Float32",name:"collisionCircleDiameter"},{type:"Uint16",name:"textAnchorOffsetStartIndex"},{type:"Uint16",name:"textAnchorOffsetEndIndex"}]),Mc([{type:"Float32",name:"offsetX"}]),Mc([{type:"Int16",name:"x"},{type:"Int16",name:"y"},{type:"Int16",name:"tileUnitDistanceFromAnchor"}]),Mc([{type:"Uint16",name:"textAnchor"},{type:"Float32",components:2,name:"textOffset"}]);var Vd=24;const jd={"!":"︕","#":"#",$:"$","%":"%","&":"&","(":"︵",")":"︶","*":"*","+":"+",",":"︐","-":"︲",".":"・","/":"/",":":"︓",";":"︔","<":"︿","=":"=",">":"﹀","?":"︖","@":"@","[":"﹇","\\":"\","]":"﹈","^":"^",_:"︳","`":"`","{":"︷","|":"―","}":"︸","~":"~","¢":"¢","£":"£","¥":"¥","¦":"¦","¬":"¬","¯":" ̄","–":"︲","—":"︱","‘":"﹃","’":"﹄","“":"﹁","”":"﹂","…":"︙","⋯":"︙","‧":"・","₩":"₩","、":"︑","。":"︒","〈":"︿","〉":"﹀","《":"︽","》":"︾","「":"﹁","」":"﹂","『":"﹃","』":"﹄","【":"︻","】":"︼","〔":"︹","〕":"︺","〖":"︗","〗":"︘","!":"︕","(":"︵",")":"︶",",":"︐","-":"︲",".":"・",":":"︓",";":"︔","<":"︿",">":"﹀","?":"︖","[":"﹇","]":"﹈","_":"︳","{":"︷","|":"―","}":"︸","⦅":"︵","⦆":"︶","。":"︒","「":"﹁","」":"﹂"},Nd={10:!0,32:!0,38:!0,41:!0,43:!0,45:!0,47:!0,173:!0,183:!0,8203:!0,8208:!0,8211:!0,8231:!0},Gd={40:!0};function Ud(e,s,l,c,d,p){if("fontStack"in s){const c=l[s.fontStack],p=c&&c[e];return p?p.metrics.advance*s.scale+d:0}{const e=c[s.imageName];return e?e.displaySize[0]*s.scale*Vd/p+d:0}}function qd(e,s,l,c){const d=Math.pow(e-s,2);return c?eMath.max(e,this.sections[s].scale)),0)}getMaxImageSize(e){let s=0,l=0;for(let c=0;cl)))}addImageSection(e){const s=e.image?e.image.name:"";if(0===s.length)return void Se("Can't add FormattedSection with an empty image.");const l=this.getNextImageSectionCharCode();l?(this.text+=String.fromCharCode(l),this.sections.push({scale:1,verticalAlign:e.verticalAlign||"bottom",imageName:s}),this.sectionIndex.push(this.sections.length-1)):Se("Reached maximum number of images 6401")}getNextImageSectionCharCode(){return this.imageSectionID?this.imageSectionID>=63743?null:++this.imageSectionID:(this.imageSectionID=57344,this.imageSectionID)}determineLineBreaks(e,s,l,c,d){const p=[],f=this.determineAverageLineWidth(e,s,l,c,d),m=this.hasZeroWidthSpaces();let _=0,g=0;const y=this.text[Symbol.iterator]();let b=y.next();const T=this.text[Symbol.iterator]();T.next();let P=T.next();const S=this.text[Symbol.iterator]();S.next(),S.next();let I=S.next();for(;!b.done;){const s=this.getSection(g),C=b.value.codePointAt(0);if(oc(C)||(_+=Ud(C,s,l,c,e,d)),!P.done){const e=nc(C),l=P.value.codePointAt(0);(Nd[C]||e||"imageName"in s||!I.done&&Gd[l])&&p.push($d(g+1,_,f,p,Zd(C,l,e&&m),!1))}g++,b=y.next(),P=T.next(),I=S.next()}return Wd($d(this.length(),_,f,p,0,!0))}determineAverageLineWidth(e,s,l,c,d){let p=0,f=0;for(const s of this.text){const m=this.getSection(f);p+=Ud(s.codePointAt(0),m,l,c,e,d),f++}return p/Math.max(1,Math.ceil(p/s))}}const Hd=4294967296,Xd=1/Hd,Yd="undefined"==typeof TextDecoder?null:new TextDecoder("utf-8");class Tc{constructor(e=new Uint8Array(16)){this.buf=ArrayBuffer.isView(e)?e:new Uint8Array(e),this.dataView=new DataView(this.buf.buffer),this.pos=0,this.type=0,this.length=this.buf.length}readFields(e,s,l=this.length){for(;this.pos>3,d=this.pos;this.type=7&l,e(c,s,this),this.pos===d&&this.skip(l)}return s}readMessage(e,s){return this.readFields(e,s,this.readVarint()+this.pos)}readFixed32(){const e=this.dataView.getUint32(this.pos,!0);return this.pos+=4,e}readSFixed32(){const e=this.dataView.getInt32(this.pos,!0);return this.pos+=4,e}readFixed64(){const e=this.dataView.getUint32(this.pos,!0)+this.dataView.getUint32(this.pos+4,!0)*Hd;return this.pos+=8,e}readSFixed64(){const e=this.dataView.getUint32(this.pos,!0)+this.dataView.getInt32(this.pos+4,!0)*Hd;return this.pos+=8,e}readFloat(){const e=this.dataView.getFloat32(this.pos,!0);return this.pos+=4,e}readDouble(){const e=this.dataView.getFloat64(this.pos,!0);return this.pos+=8,e}readVarint(e){const s=this.buf;let l,c;return c=s[this.pos++],l=127&c,c<128?l:(c=s[this.pos++],l|=(127&c)<<7,c<128?l:(c=s[this.pos++],l|=(127&c)<<14,c<128?l:(c=s[this.pos++],l|=(127&c)<<21,c<128?l:(c=s[this.pos],l|=(15&c)<<28,function(e,s,l){const c=l.buf;let d,p;if(p=c[l.pos++],d=(112&p)>>4,p<128)return Kd(e,d,s);if(p=c[l.pos++],d|=(127&p)<<3,p<128)return Kd(e,d,s);if(p=c[l.pos++],d|=(127&p)<<10,p<128)return Kd(e,d,s);if(p=c[l.pos++],d|=(127&p)<<17,p<128)return Kd(e,d,s);if(p=c[l.pos++],d|=(127&p)<<24,p<128)return Kd(e,d,s);if(p=c[l.pos++],d|=(1&p)<<31,p<128)return Kd(e,d,s);throw new Error("Expected varint not more than 10 bytes")}(l,e,this)))))}readVarint64(){return this.readVarint(!0)}readSVarint(){const e=this.readVarint();return e%2==1?(e+1)/-2:e/2}readBoolean(){return Boolean(this.readVarint())}readString(){const e=this.readVarint()+this.pos,s=this.pos;return this.pos=e,e-s>=12&&Yd?Yd.decode(this.buf.subarray(s,e)):function(e,s,l){let c="",d=s;for(;d239?4:s>223?3:s>191?2:1;if(d+g>l)break;1===g?s<128&&(_=s):2===g?(p=e[d+1],128==(192&p)&&(_=(31&s)<<6|63&p,_<=127&&(_=null))):3===g?(p=e[d+1],f=e[d+2],128==(192&p)&&128==(192&f)&&(_=(15&s)<<12|(63&p)<<6|63&f,(_<=2047||_>=55296&&_<=57343)&&(_=null))):4===g&&(p=e[d+1],f=e[d+2],m=e[d+3],128==(192&p)&&128==(192&f)&&128==(192&m)&&(_=(15&s)<<18|(63&p)<<12|(63&f)<<6|63&m,(_<=65535||_>=1114112)&&(_=null))),null===_?(_=65533,g=1):_>65535&&(_-=65536,c+=String.fromCharCode(_>>>10&1023|55296),_=56320|1023&_),c+=String.fromCharCode(_),d+=g}return c}(this.buf,s,e)}readBytes(){const e=this.readVarint()+this.pos,s=this.buf.subarray(this.pos,e);return this.pos=e,s}readPackedVarint(e=[],s){const l=this.readPackedEnd();for(;this.pos127;);else if(2===s)this.pos=this.readVarint()+this.pos;else if(5===s)this.pos+=4;else{if(1!==s)throw new Error(`Unimplemented type: ${s}`);this.pos+=8}}writeTag(e,s){this.writeVarint(e<<3|s)}realloc(e){let s=this.length||16;for(;s268435455||e<0?function(e,s){let l,c;if(e>=0?(l=e%4294967296|0,c=e/4294967296|0):(l=~(-e%4294967296),c=~(-e/4294967296),4294967295^l?l=l+1|0:(l=0,c=c+1|0)),e>=0x10000000000000000||e<-0x10000000000000000)throw new Error("Given varint doesn't fit into 10 bytes");s.realloc(10),function(e,s,l){l.buf[l.pos++]=127&e|128,e>>>=7,l.buf[l.pos++]=127&e|128,e>>>=7,l.buf[l.pos++]=127&e|128,e>>>=7,l.buf[l.pos++]=127&e|128,l.buf[l.pos]=127&(e>>>=7)}(l,0,s),function(e,s){const l=(7&e)<<4;s.buf[s.pos++]|=l|((e>>>=3)?128:0),e&&(s.buf[s.pos++]=127&e|((e>>>=7)?128:0),e&&(s.buf[s.pos++]=127&e|((e>>>=7)?128:0),e&&(s.buf[s.pos++]=127&e|((e>>>=7)?128:0),e&&(s.buf[s.pos++]=127&e|((e>>>=7)?128:0),e&&(s.buf[s.pos++]=127&e)))))}(c,s)}(e,this):(this.realloc(4),this.buf[this.pos++]=127&e|(e>127?128:0),e<=127||(this.buf[this.pos++]=127&(e>>>=7)|(e>127?128:0),e<=127||(this.buf[this.pos++]=127&(e>>>=7)|(e>127?128:0),e<=127||(this.buf[this.pos++]=e>>>7&127))))}writeSVarint(e){this.writeVarint(e<0?2*-e-1:2*e)}writeBoolean(e){this.writeVarint(+e)}writeString(e){e=String(e),this.realloc(4*e.length),this.pos++;const s=this.pos;this.pos=function(e,s,l){for(let c,d,p=0;p55295&&c<57344){if(!d){c>56319||p+1===s.length?(e[l++]=239,e[l++]=191,e[l++]=189):d=c;continue}if(c<56320){e[l++]=239,e[l++]=191,e[l++]=189,d=c;continue}c=d-55296<<10|c-56320|65536,d=null}else d&&(e[l++]=239,e[l++]=191,e[l++]=189,d=null);c<128?e[l++]=c:(c<2048?e[l++]=c>>6|192:(c<65536?e[l++]=c>>12|224:(e[l++]=c>>18|240,e[l++]=c>>12&63|128),e[l++]=c>>6&63|128),e[l++]=63&c|128)}return l}(this.buf,e,this.pos);const l=this.pos-s;l>=128&&Qd(s,l,this),this.pos=s-1,this.writeVarint(l),this.pos+=l}writeFloat(e){this.realloc(4),this.dataView.setFloat32(this.pos,e,!0),this.pos+=4}writeDouble(e){this.realloc(8),this.dataView.setFloat64(this.pos,e,!0),this.pos+=8}writeBytes(e){const s=e.length;this.writeVarint(s),this.realloc(s);for(let l=0;l=128&&Qd(l,c,this),this.pos=l-1,this.writeVarint(c),this.pos+=c}writeMessage(e,s,l){this.writeTag(e,2),this.writeRawMessage(s,l)}writePackedVarint(e,s){s.length&&this.writeMessage(e,Jd,s)}writePackedSVarint(e,s){s.length&&this.writeMessage(e,ip,s)}writePackedBoolean(e,s){s.length&&this.writeMessage(e,sp,s)}writePackedFloat(e,s){s.length&&this.writeMessage(e,rp,s)}writePackedDouble(e,s){s.length&&this.writeMessage(e,np,s)}writePackedFixed32(e,s){s.length&&this.writeMessage(e,op,s)}writePackedSFixed32(e,s){s.length&&this.writeMessage(e,ap,s)}writePackedFixed64(e,s){s.length&&this.writeMessage(e,lp,s)}writePackedSFixed64(e,s){s.length&&this.writeMessage(e,cp,s)}writeBytesField(e,s){this.writeTag(e,2),this.writeBytes(s)}writeFixed32Field(e,s){this.writeTag(e,5),this.writeFixed32(s)}writeSFixed32Field(e,s){this.writeTag(e,5),this.writeSFixed32(s)}writeFixed64Field(e,s){this.writeTag(e,1),this.writeFixed64(s)}writeSFixed64Field(e,s){this.writeTag(e,1),this.writeSFixed64(s)}writeVarintField(e,s){this.writeTag(e,0),this.writeVarint(s)}writeSVarintField(e,s){this.writeTag(e,0),this.writeSVarint(s)}writeStringField(e,s){this.writeTag(e,2),this.writeString(s)}writeFloatField(e,s){this.writeTag(e,5),this.writeFloat(s)}writeDoubleField(e,s){this.writeTag(e,1),this.writeDouble(s)}writeBooleanField(e,s){this.writeVarintField(e,+s)}}function Kd(e,s,l){return l?4294967296*s+(e>>>0):4294967296*(s>>>0)+(e>>>0)}function Qd(e,s,l){const c=s<=16383?1:s<=2097151?2:s<=268435455?3:Math.floor(Math.log(s)/(7*Math.LN2));l.realloc(c);for(let s=l.pos-1;s>=e;s--)l.buf[s+c]=l.buf[s]}function Jd(e,s){for(let l=0;ls.h-e.h));const c=[{x:0,y:0,w:Math.max(Math.ceil(Math.sqrt(s/.95)),l),h:1/0}];let d=0,p=0;for(const s of e)for(let e=c.length-1;e>=0;e--){const l=c[e];if(!(s.w>l.w||s.h>l.h)){if(s.x=l.x,s.y=l.y,p=Math.max(p,s.y+s.h),d=Math.max(d,s.x+s.w),s.w===l.w&&s.h===l.h){const s=c.pop();s&&eC.toCodeUnitIndex(e)));const e=F(C.toString(),L);for(const s of e){const e=[...s].map((()=>0));z.push(new Sc(s,C.sections,e))}}else if(B){z=[],L=L.map((e=>C.toCodeUnitIndex(e)));let e=0;const s=[];for(const l of C.text)s.push(...Array(l.length).fill(C.sectionIndex[e])),e++;const l=B(C.text,s,L);for(const e of l){const s=[];let l="";for(const c of e[0])s.push(e[1][l.length]),l+=c;z.push(new Sc(e[0],C.sections,s))}}else z=function(e,s){const l=[];let c=0;for(const d of s)l.push(e.substring(c,d)),c=d;return cg){const e=Math.ceil(p/g);d*=e/f,f=e}return{x1:c,y1:d,x2:c+p,y2:d+f}}function Sp(e,s,l,c,d,p){const f=e.image;let m;if(f.content){const e=f.content,s=f.pixelRatio||1;m=[e[0]/s,e[1]/s,f.displaySize[0]-e[2]/s,f.displaySize[1]-e[3]/s]}const _=s.left*p,g=s.right*p;let y,b,T,P;"width"===l||"both"===l?(P=d[0]+_-c[3],b=d[0]+g+c[1]):(P=d[0]+(_+g-f.displaySize[0])/2,b=P+f.displaySize[0]);const S=s.top*p,I=s.bottom*p;return"height"===l||"both"===l?(y=d[1]+S-c[0],T=d[1]+I+c[2]):(y=d[1]+(S+I-f.displaySize[1])/2,T=y+f.displaySize[1]),{image:f,top:y,right:b,bottom:T,left:P,collisionPadding:m}}Yl("ImagePosition",qc),Yl("ImageAtlas",jc),s.az=void 0,(fp=s.az||(s.az={}))[fp.none=0]="none",fp[fp.horizontal=1]="horizontal",fp[fp.vertical=2]="vertical",fp[fp.horizontalOnly=3]="horizontalOnly";const Mp=128,Ip=32640;function Cp(e,s){const{expression:l}=s;if("constant"===l.kind)return{kind:"constant",layoutSize:l.evaluate(new Ps(e+1))};if("source"===l.kind)return{kind:"source"};{const{zoomStops:s,interpolationType:c}=l;let d=0;for(;de.id)),this.index=e.index,this.pixelRatio=e.pixelRatio,this.sourceLayerIndex=e.sourceLayerIndex,this.hasDependencies=!1,this.hasRTLText=!1,this.sortKeyRanges=[],this.collisionCircleArray=[];const l=this.layers[0]._unevaluatedLayout._values;this.textSizeData=Cp(this.zoom,l["text-size"]),this.iconSizeData=Cp(this.zoom,l["icon-size"]);const c=this.layers[0].layout,d=c.get("symbol-sort-key"),p=c.get("symbol-z-order");this.canOverlap="never"!==Dp(c,"text-overlap","text-allow-overlap")||"never"!==Dp(c,"icon-overlap","icon-allow-overlap")||c.get("text-ignore-placement")||c.get("icon-ignore-placement"),this.sortFeaturesByKey="viewport-y"!==p&&!d.isConstant(),this.sortFeaturesByY=("viewport-y"===p||"auto"===p&&!this.sortFeaturesByKey)&&this.canOverlap,"point"===c.get("symbol-placement")&&(this.writingModes=c.get("text-writing-mode").map((e=>s.az[e]))),this.stateDependentLayerIds=this.layers.filter((e=>e.isStateDependent())).map((e=>e.id)),this.sourceID=e.sourceID}createArrays(){this.text=new hh(new Vo(this.layers,this.zoom,(e=>/^text/.test(e)))),this.icon=new hh(new Vo(this.layers,this.zoom,(e=>/^icon/.test(e)))),this.glyphOffsetArray=new Va,this.lineVertexArray=new Ca,this.symbolInstances=new Ba,this.textAnchorOffsets=new Oa}calculateGlyphDependencies(e,s,l,c,d){for(const p of e)if(s[p.codePointAt(0)]=!0,(l||c)&&d){const e=jd[p];e&&(s[e.codePointAt(0)]=!0)}}populate(e,l,c){const d=this.layers[0],p=d.layout,f=p.get("text-font"),m=p.get("text-field"),_=p.get("icon-image"),g=("constant"!==m.value.kind||m.value.value instanceof De&&!m.value.value.isEmpty()||m.value.value.toString().length>0)&&("constant"!==f.value.kind||f.value.value.length>0),y="constant"!==_.value.kind||!!_.value.value||Object.keys(_.parameters).length>0,b=p.get("symbol-sort-key");if(this.features=[],!g&&!y)return;const T=l.iconDependencies,P=l.glyphDependencies,S=l.availableImages,I=new Ps(this.zoom);for(const{feature:l,id:m,index:_,sourceLayerIndex:C}of e){const e=d._featureFilter.needGeometry,z=Jc(l,e);if(!d._featureFilter.filter(I,z,c))continue;let L,F;if(e||(z.geometry=Qc(l)),g){const e=d.getValueAndResolveTokens("text-field",z,c,S),s=De.factory(e),l=this.hasRTLText=this.hasRTLText||Bp(s);(!l||"unavailable"===yc.getRTLTextPluginStatus()||l&&yc.isParsed())&&(L=Od(s,d,z))}if(y){const e=d.getValueAndResolveTokens("icon-image",z,c,S);F=e instanceof Oe?e:Oe.fromString(e)}if(!L&&!F)continue;const B=this.sortFeaturesByKey?b.evaluate(z,{},c):void 0;if(this.features.push({id:m,text:L,icon:F,index:_,sourceLayerIndex:C,geometry:z.geometry,properties:l.properties,type:Mu.types[l.type],sortKey:B}),F&&(T[F.name]=!0),L){const e=f.evaluate(z,{},c).join(","),l="viewport"!==p.get("text-rotation-alignment")&&"point"!==p.get("symbol-placement");this.allowVerticalPlacement=this.writingModes&&this.writingModes.indexOf(s.az.vertical)>=0;for(const s of L.sections)if(s.image)T[s.image.name]=!0;else{const c=lc(L.toString()),d=s.fontStack||e,p=P[d]=P[d]||{};this.calculateGlyphDependencies(s.text,p,l,this.allowVerticalPlacement,c)}}}"line"===p.get("symbol-placement")&&(this.features=function(e){const s={},l={},c=[];let d=0;function p(s){c.push(e[s]),d++}function f(e,s,d){const p=l[e];return delete l[e],l[s]=p,c[p].geometry[0].pop(),c[p].geometry[0]=c[p].geometry[0].concat(d[0]),p}function m(e,l,d){const p=s[l];return delete s[l],s[e]=p,c[p].geometry[0].shift(),c[p].geometry[0]=d[0].concat(c[p].geometry[0]),p}function _(e,s,l){const c=l?s[0][s[0].length-1]:s[0][0];return`${e}:${c.x}:${c.y}`}for(let g=0;ge.geometry))}(this.features)),this.sortFeaturesByKey&&this.features.sort(((e,s)=>e.sortKey-s.sortKey))}update(e,s,l){this.stateDependentLayers.length&&(this.text.programConfigurations.updatePaintArrays(e,s,this.layers,{imagePositions:l}),this.icon.programConfigurations.updatePaintArrays(e,s,this.layers,{imagePositions:l}))}isEmpty(){return 0===this.symbolInstances.length&&!this.hasRTLText}uploadPending(){return!this.uploaded||this.text.programConfigurations.needsUpload||this.icon.programConfigurations.needsUpload}upload(e){!this.uploaded&&this.hasDebugData()&&(this.textCollisionBox.upload(e),this.iconCollisionBox.upload(e)),this.text.upload(e,this.sortFeaturesByY,!this.uploaded,this.text.programConfigurations.needsUpload),this.icon.upload(e,this.sortFeaturesByY,!this.uploaded,this.icon.programConfigurations.needsUpload),this.uploaded=!0}destroyDebugData(){this.textCollisionBox.destroy(),this.iconCollisionBox.destroy()}destroy(){this.text.destroy(),this.icon.destroy(),this.hasDebugData()&&this.destroyDebugData()}addToLineVertexArray(e,s){const l=this.lineVertexArray.length;if(void 0!==e.segment){let l=e.dist(s[e.segment+1]),c=e.dist(s[e.segment]);const d={};for(let c=e.segment+1;c=0;l--)d[l]={x:s[l].x,y:s[l].y,tileUnitDistanceFromAnchor:c},l>0&&(c+=s[l-1].dist(s[l]));for(let e=0;e0}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}addIndicesForPlacedSymbol(e,s){const l=e.placedSymbolArray.get(s),c=l.vertexStartIndex+4*l.numGlyphs;for(let s=l.vertexStartIndex;sc[e]-c[s]||d[s]-d[e])),p}addToSortKeyRanges(e,s){const l=this.sortKeyRanges[this.sortKeyRanges.length-1];l&&l.sortKey===s?l.symbolInstanceEnd=e+1:this.sortKeyRanges.push({sortKey:s,symbolInstanceStart:e,symbolInstanceEnd:e+1})}sortFeatures(e){if(this.sortFeaturesByY&&this.sortedAngle!==e&&!(this.text.segments.get().length>1||this.icon.segments.get().length>1)){this.symbolInstanceIndexes=this.getSortedSymbolIndexes(e),this.sortedAngle=e,this.text.indexArray.clear(),this.icon.indexArray.clear(),this.featureSortOrder=[];for(const e of this.symbolInstanceIndexes){const s=this.symbolInstances.get(e);this.featureSortOrder.push(s.featureIndex),[s.rightJustifiedTextSymbolIndex,s.centerJustifiedTextSymbolIndex,s.leftJustifiedTextSymbolIndex].forEach(((e,s,l)=>{e>=0&&l.indexOf(e)===s&&this.addIndicesForPlacedSymbol(this.text,e)})),s.verticalPlacedTextSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.text,s.verticalPlacedTextSymbolIndex),s.placedIconSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.icon,s.placedIconSymbolIndex),s.verticalPlacedIconSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.icon,s.verticalPlacedIconSymbolIndex)}this.text.indexBuffer&&this.text.indexBuffer.updateData(this.text.indexArray),this.icon.indexBuffer&&this.icon.indexBuffer.updateData(this.icon.indexArray)}}}let Vp,jp;Yl("SymbolBucket",fh,{omit:["layers","collisionBoxArray","features","compareText"]}),fh.MAX_GLYPHS=65535,fh.addDynamicAttributes=Fp;var Np={get paint(){return jp=jp||new Hs({"icon-opacity":new Gs(Tt.paint_symbol["icon-opacity"]),"icon-color":new Gs(Tt.paint_symbol["icon-color"]),"icon-halo-color":new Gs(Tt.paint_symbol["icon-halo-color"]),"icon-halo-width":new Gs(Tt.paint_symbol["icon-halo-width"]),"icon-halo-blur":new Gs(Tt.paint_symbol["icon-halo-blur"]),"icon-translate":new js(Tt.paint_symbol["icon-translate"]),"icon-translate-anchor":new js(Tt.paint_symbol["icon-translate-anchor"]),"text-opacity":new Gs(Tt.paint_symbol["text-opacity"]),"text-color":new Gs(Tt.paint_symbol["text-color"],{runtimeType:pi,getOverride:e=>e.textColor,hasOverride:e=>!!e.textColor}),"text-halo-color":new Gs(Tt.paint_symbol["text-halo-color"]),"text-halo-width":new Gs(Tt.paint_symbol["text-halo-width"]),"text-halo-blur":new Gs(Tt.paint_symbol["text-halo-blur"]),"text-translate":new js(Tt.paint_symbol["text-translate"]),"text-translate-anchor":new js(Tt.paint_symbol["text-translate-anchor"])})},get layout(){return Vp=Vp||new Hs({"symbol-placement":new js(Tt.layout_symbol["symbol-placement"]),"symbol-spacing":new js(Tt.layout_symbol["symbol-spacing"]),"symbol-avoid-edges":new js(Tt.layout_symbol["symbol-avoid-edges"]),"symbol-sort-key":new Gs(Tt.layout_symbol["symbol-sort-key"]),"symbol-z-order":new js(Tt.layout_symbol["symbol-z-order"]),"icon-allow-overlap":new js(Tt.layout_symbol["icon-allow-overlap"]),"icon-overlap":new js(Tt.layout_symbol["icon-overlap"]),"icon-ignore-placement":new js(Tt.layout_symbol["icon-ignore-placement"]),"icon-optional":new js(Tt.layout_symbol["icon-optional"]),"icon-rotation-alignment":new js(Tt.layout_symbol["icon-rotation-alignment"]),"icon-size":new Gs(Tt.layout_symbol["icon-size"]),"icon-text-fit":new js(Tt.layout_symbol["icon-text-fit"]),"icon-text-fit-padding":new js(Tt.layout_symbol["icon-text-fit-padding"]),"icon-image":new Gs(Tt.layout_symbol["icon-image"]),"icon-rotate":new Gs(Tt.layout_symbol["icon-rotate"]),"icon-padding":new Gs(Tt.layout_symbol["icon-padding"]),"icon-keep-upright":new js(Tt.layout_symbol["icon-keep-upright"]),"icon-offset":new Gs(Tt.layout_symbol["icon-offset"]),"icon-anchor":new Gs(Tt.layout_symbol["icon-anchor"]),"icon-pitch-alignment":new js(Tt.layout_symbol["icon-pitch-alignment"]),"text-pitch-alignment":new js(Tt.layout_symbol["text-pitch-alignment"]),"text-rotation-alignment":new js(Tt.layout_symbol["text-rotation-alignment"]),"text-field":new Gs(Tt.layout_symbol["text-field"]),"text-font":new Gs(Tt.layout_symbol["text-font"]),"text-size":new Gs(Tt.layout_symbol["text-size"]),"text-max-width":new Gs(Tt.layout_symbol["text-max-width"]),"text-line-height":new js(Tt.layout_symbol["text-line-height"]),"text-letter-spacing":new Gs(Tt.layout_symbol["text-letter-spacing"]),"text-justify":new Gs(Tt.layout_symbol["text-justify"]),"text-radial-offset":new Gs(Tt.layout_symbol["text-radial-offset"]),"text-variable-anchor":new js(Tt.layout_symbol["text-variable-anchor"]),"text-variable-anchor-offset":new Gs(Tt.layout_symbol["text-variable-anchor-offset"]),"text-anchor":new Gs(Tt.layout_symbol["text-anchor"]),"text-max-angle":new js(Tt.layout_symbol["text-max-angle"]),"text-writing-mode":new js(Tt.layout_symbol["text-writing-mode"]),"text-rotate":new Gs(Tt.layout_symbol["text-rotate"]),"text-padding":new js(Tt.layout_symbol["text-padding"]),"text-keep-upright":new js(Tt.layout_symbol["text-keep-upright"]),"text-transform":new Gs(Tt.layout_symbol["text-transform"]),"text-offset":new Gs(Tt.layout_symbol["text-offset"]),"text-allow-overlap":new js(Tt.layout_symbol["text-allow-overlap"]),"text-overlap":new js(Tt.layout_symbol["text-overlap"]),"text-ignore-placement":new js(Tt.layout_symbol["text-ignore-placement"]),"text-optional":new js(Tt.layout_symbol["text-optional"])})}};class gh{constructor(e){if(void 0===e.property.overrides)throw new Error("overrides must be provided to instantiate FormatSectionOverride class");this.type=e.property.overrides?e.property.overrides.runtimeType:ni,this.defaultValue=e}evaluate(e){if(e.formattedSection){const s=this.defaultValue.property.overrides;if(s&&s.hasOverride(e.formattedSection))return s.getOverride(e.formattedSection)}return e.feature&&e.featureState?this.defaultValue.evaluate(e.feature,e.featureState):this.defaultValue.property.specification.default}eachChild(e){this.defaultValue.isConstant()||e(this.defaultValue.value._styleExpression.expression)}outputDefined(){return!1}serialize(){return null}}Yl("FormatSectionOverride",gh,{omit:["defaultValue"]});class xh extends Ks{constructor(e,s){super(e,Np,s)}recalculate(e,s){if(super.recalculate(e,s),"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"]="map"===this.layout.get("text-rotation-alignment")?"map":"viewport"),"auto"===this.layout.get("icon-pitch-alignment")&&(this.layout._values["icon-pitch-alignment"]=this.layout.get("icon-rotation-alignment")),"point"===this.layout.get("symbol-placement")){const e=this.layout.get("text-writing-mode");if(e){const s=[];for(const l of e)s.indexOf(l)<0&&s.push(l);this.layout._values["text-writing-mode"]=s}else this.layout._values["text-writing-mode"]=["horizontal"]}this._setPaintOverrides()}getValueAndResolveTokens(e,s,l,c){const d=this.layout.get(e).evaluate(s,{},l,c),p=this._unevaluatedLayout._values[e];return p.isDataDriven()||Bs(p.value)||!d?d:function(e,s){return s.replace(/{([^{}]+)}/g,((s,l)=>e&&l in e?String(e[l]):""))}(s.properties,d)}createBucket(e){return new fh(e)}queryRadius(){return 0}queryIntersectsFeature(){throw new Error("Should take a different path in FeatureIndex")}_setPaintOverrides(){for(const e of Np.paint.overridableProperties){if(!xh.hasPaintOverride(this.layout,e))continue;const s=this.paint.get(e),l=new gh(s),c=new ei(l,s.property.specification);let d=null;d="constant"===s.value.kind||"source"===s.value.kind?new ii("source",c):new si("composite",c,s.value.zoomStops),this.paint._values[e]=new Us(s.property,d,s.parameters)}}_handleOverridablePaintPropertyUpdate(e,s,l){return!(!this.layout||s.isDataDriven()||l.isDataDriven())&&xh.hasPaintOverride(this.layout,e)}static hasPaintOverride(e,s){const l=e.get("text-field"),c=Np.paint.properties[s];let d=!1;const p=e=>{for(const s of e)if(c.overrides&&c.overrides.hasOverride(s))return void(d=!0)};if("constant"===l.value.kind&&l.value.value instanceof De)p(l.value.value.sections);else if("source"===l.value.kind||"composite"===l.value.kind){const e=s=>{d||(s instanceof je&&Cr(s.value)===yi?p(s.value.sections):s instanceof Ir?p(s.sections):s.eachChild(e))},s=l.value;s._styleExpression&&e(s._styleExpression.expression)}return d}}let Gp;var qp={get paint(){return Gp=Gp||new Hs({"background-color":new js(Tt.paint_background["background-color"]),"background-pattern":new Ys(Tt.paint_background["background-pattern"]),"background-opacity":new js(Tt.paint_background["background-opacity"])})}};class wh extends Ks{constructor(e,s){super(e,qp,s)}}class _h extends Ks{constructor(e,s){super(e,{},s),this.onAdd=e=>{this.implementation.onAdd&&this.implementation.onAdd(e,e.painter.context.gl)},this.onRemove=e=>{this.implementation.onRemove&&this.implementation.onRemove(e,e.painter.context.gl)},this.implementation=e}is3D(){return"3d"===this.implementation.renderingMode}hasOffscreenPass(){return void 0!==this.implementation.prerender}recalculate(){}updateTransitions(){}hasTransition(){return!1}serialize(){throw new Error("Custom layers cannot be serialized")}}class Sh{constructor(e){this._methodToThrottle=e,this._triggered=!1,"undefined"!=typeof MessageChannel&&(this._channel=new MessageChannel,this._channel.port2.onmessage=()=>{this._triggered=!1,this._methodToThrottle()})}trigger(){this._triggered||(this._triggered=!0,this._channel?this._channel.port1.postMessage(!0):setTimeout((()=>{this._triggered=!1,this._methodToThrottle()}),0))}remove(){delete this._channel,this._methodToThrottle=()=>{}}}const Zp={once:!0},$p=6371008.8;class Eh{constructor(e,s){if(isNaN(e)||isNaN(s))throw new Error(`Invalid LngLat object: (${e}, ${s})`);if(this.lng=+e,this.lat=+s,this.lat>90||this.lat<-90)throw new Error("Invalid LngLat latitude value: must be between -90 and 90")}wrap(){return new Eh(me(this.lng,-180,180),this.lat)}toArray(){return[this.lng,this.lat]}toString(){return`LngLat(${this.lng}, ${this.lat})`}distanceTo(e){const s=Math.PI/180,l=this.lat*s,c=e.lat*s,d=Math.sin(l)*Math.sin(c)+Math.cos(l)*Math.cos(c)*Math.cos((e.lng-this.lng)*s);return $p*Math.acos(Math.min(d,1))}static convert(e){if(e instanceof Eh)return e;if(Array.isArray(e)&&(2===e.length||3===e.length))return new Eh(Number(e[0]),Number(e[1]));if(!Array.isArray(e)&&"object"==typeof e&&null!==e)return new Eh(Number("lng"in e?e.lng:e.lon),Number(e.lat));throw new Error("`LngLatLike` argument must be specified as a LngLat instance, an object {lng: , lat: }, an object {lon: , lat: }, or an array of [, ]")}}const Hp=2*Math.PI*$p;function Xp(e){return Hp*Math.cos(e*Math.PI/180)}function Yp(e){return(180+e)/360}function tf(e){return(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+e*Math.PI/360)))/360}function rf(e,s){return e/Xp(s)}function sf(e){return 360*e-180}function of(e){return 360/Math.PI*Math.atan(Math.exp((180-360*e)*Math.PI/180))-90}function af(e,s){return e*Xp(of(s))}class Vh{constructor(e,s,l=0){this.x=+e,this.y=+s,this.z=+l}static fromLngLat(e,s=0){const l=Eh.convert(e);return new Vh(Yp(l.lng),tf(l.lat),rf(s,l.lat))}toLngLat(){return new Eh(sf(this.x),of(this.y))}toAltitude(){return af(this.z,this.y)}meterInMercatorCoordinateUnits(){return 1/Hp*(e=of(this.y),1/Math.cos(e*Math.PI/180));var e}}function hf(e,s,l){var c=2*Math.PI*6378137/256/Math.pow(2,l);return[e*c-2*Math.PI*6378137/2,s*c-2*Math.PI*6378137/2]}class Lh{constructor(e,s,l){if(!function(e,s,l){return!(e<0||e>25||l<0||l>=Math.pow(2,e)||s<0||s>=Math.pow(2,e))}(e,s,l))throw new Error(`x=${s}, y=${l}, z=${e} outside of bounds. 0<=x<${Math.pow(2,e)}, 0<=y<${Math.pow(2,e)} 0<=z<=25 `);this.z=e,this.x=s,this.y=l,this.key=df(0,e,e,s,l)}equals(e){return this.z===e.z&&this.x===e.x&&this.y===e.y}url(e,s,l){const c=function(e,s,l){var c=hf(256*e,256*(s=Math.pow(2,l)-s-1),l),d=hf(256*(e+1),256*(s+1),l);return c[0]+","+c[1]+","+d[0]+","+d[1]}(this.x,this.y,this.z),d=function(e,s,l){let c,d="";for(let p=e;p>0;p--)c=1<1?"@2x":"").replace(/{quadkey}/g,d).replace(/{bbox-epsg-3857}/g,c)}isChildOf(e){const s=this.z-e.z;return s>0&&e.x===this.x>>s&&e.y===this.y>>s}getTilePoint(e){const s=Math.pow(2,this.z);return new c((e.x*s-this.x)*se,(e.y*s-this.y)*se)}toString(){return`${this.z}/${this.x}/${this.y}`}}class Oh{constructor(e,s){this.wrap=e,this.canonical=s,this.key=df(e,s.z,s.z,s.x,s.y)}}class Rh{constructor(e,s,l,c,d){if(this.terrainRttPosMatrix32f=null,e= z; overscaledZ = ${e}; z = ${l}`);this.overscaledZ=e,this.wrap=s,this.canonical=new Lh(l,+c,+d),this.key=df(s,e,l,c,d)}clone(){return new Rh(this.overscaledZ,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y)}equals(e){return this.overscaledZ===e.overscaledZ&&this.wrap===e.wrap&&this.canonical.equals(e.canonical)}scaledTo(e){if(e>this.overscaledZ)throw new Error(`targetZ > this.overscaledZ; targetZ = ${e}; overscaledZ = ${this.overscaledZ}`);const s=this.canonical.z-e;return e>this.canonical.z?new Rh(e,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y):new Rh(e,this.wrap,e,this.canonical.x>>s,this.canonical.y>>s)}isOverscaled(){return this.overscaledZ>this.canonical.z}calculateScaledKey(e,s){if(e>this.overscaledZ)throw new Error(`targetZ > this.overscaledZ; targetZ = ${e}; overscaledZ = ${this.overscaledZ}`);const l=this.canonical.z-e;return e>this.canonical.z?df(this.wrap*+s,e,this.canonical.z,this.canonical.x,this.canonical.y):df(this.wrap*+s,e,e,this.canonical.x>>l,this.canonical.y>>l)}isChildOf(e){if(e.wrap!==this.wrap)return!1;if(this.overscaledZ-e.overscaledZ<=0)return!1;if(0===e.overscaledZ)return this.overscaledZ>0;const s=this.canonical.z-e.canonical.z;return!(s<0)&&e.canonical.x===this.canonical.x>>s&&e.canonical.y===this.canonical.y>>s}children(e){if(this.overscaledZ>=e)return[new Rh(this.overscaledZ+1,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y)];const s=this.canonical.z+1,l=2*this.canonical.x,c=2*this.canonical.y;return[new Rh(s,this.wrap,s,l,c),new Rh(s,this.wrap,s,l+1,c),new Rh(s,this.wrap,s,l,c+1),new Rh(s,this.wrap,s,l+1,c+1)]}isLessThan(e){return this.wrape.wrap)&&(this.overscaledZe.overscaledZ)&&(this.canonical.xe.canonical.x)&&this.canonical.ye.key===l));s>-1&&e.addOrUpdateProperties.splice(s,1)}return(e.removeAllProperties||s.removeAllProperties)&&(l.removeAllProperties=!0),(e.removeProperties||s.removeProperties)&&(l.removeProperties=[...e.removeProperties||[],...s.removeProperties||[]]),(e.addOrUpdateProperties||s.addOrUpdateProperties)&&(l.addOrUpdateProperties=[...e.addOrUpdateProperties||[],...s.addOrUpdateProperties||[]]),(e.newGeometry||s.newGeometry)&&(l.newGeometry=s.newGeometry||e.newGeometry),l}function _f(e){var s,l;if(!e)return{};const c={};return c.removeAll=e.removeAll,c.remove=new Set(e.remove||[]),c.add=new Map(null===(s=e.add)||void 0===s?void 0:s.map((e=>[e.id,e]))),c.update=new Map(null===(l=e.update)||void 0===l?void 0:l.map((e=>[e.id,e]))),c}Yl("CanonicalTileID",Lh),Yl("OverscaledTileID",Rh,{omit:["terrainRttPosMatrix32f"]});class jh{constructor(){this.minX=1/0,this.maxX=-1/0,this.minY=1/0,this.maxY=-1/0}extend(e){return this.minX=Math.min(this.minX,e.x),this.minY=Math.min(this.minY,e.y),this.maxX=Math.max(this.maxX,e.x),this.maxY=Math.max(this.maxY,e.y),this}expandBy(e){return this.minX-=e,this.minY-=e,this.maxX+=e,this.maxY+=e,(this.minX>this.maxX||this.minY>this.maxY)&&(this.minX=1/0,this.maxX=-1/0,this.minY=1/0,this.maxY=-1/0),this}shrinkBy(e){return this.expandBy(-e)}map(e){const s=new jh;return s.extend(e(new c(this.minX,this.minY))),s.extend(e(new c(this.maxX,this.minY))),s.extend(e(new c(this.minX,this.maxY))),s.extend(e(new c(this.maxX,this.maxY))),s}static fromPoints(e){const s=new jh;for(const l of e)s.extend(l);return s}contains(e){return e.x>=this.minX&&e.x<=this.maxX&&e.y>=this.minY&&e.y<=this.maxY}empty(){return this.minX>this.maxX}width(){return this.maxX-this.minX}height(){return this.maxY-this.minY}covers(e){return!this.empty()&&!e.empty()&&e.minX>=this.minX&&e.maxX<=this.maxX&&e.minY>=this.minY&&e.maxY<=this.maxY}intersects(e){return!this.empty()&&!e.empty()&&e.minX<=this.maxX&&e.maxX>=this.minX&&e.minY<=this.maxY&&e.maxY>=this.minY}}class Gh{constructor(e){this._stringToNumber={},this._numberToString=[];for(let s=0;s=this._numberToString.length)throw new Error(`Out of bounds. Index requested n=${e} can't be >= this._numberToString.length ${this._numberToString.length}`);return this._numberToString[e]}}class Xh{constructor(e,s,l,c,d){this.type="Feature",this._vectorTileFeature=e,this._x=l,this._y=c,this._z=s,this.properties=e.properties,this.id=d}projectPoint(e,s,l,c){return[360*(e.x+s)/c-180,360/Math.PI*Math.atan(Math.exp((1-2*(e.y+l)/c)*Math.PI))-90]}projectLine(e,s,l,c){return e.map((e=>this.projectPoint(e,s,l,c)))}get geometry(){if(this._geometry)return this._geometry;const e=this._vectorTileFeature,s=e.extent*Math.pow(2,this._z),l=e.extent*this._x,c=e.extent*this._y,d=e.loadGeometry();switch(e.type){case 1:{const e=[];for(const s of d)e.push(s[0]);const p=this.projectLine(e,l,c,s);this._geometry=1===e.length?{type:"Point",coordinates:p[0]}:{type:"MultiPoint",coordinates:p};break}case 2:{const e=d.map((e=>this.projectLine(e,l,c,s)));this._geometry=1===e.length?{type:"LineString",coordinates:e[0]}:{type:"MultiLineString",coordinates:e};break}case 3:{const e=od(d),p=[];for(const d of e)p.push(d.map((e=>this.projectLine(e,l,c,s))));this._geometry=1===p.length?{type:"Polygon",coordinates:p[0]}:{type:"MultiPolygon",coordinates:p};break}default:throw new Error(`unknown feature type: ${e.type}`)}return this._geometry}set geometry(e){this._geometry=e}toJSON(){const e={geometry:this.geometry};for(const s in this)"_geometry"!==s&&"_vectorTileFeature"!==s&&"_x"!==s&&"_y"!==s&&"_z"!==s&&(e[s]=this[s]);return e}}class Yh{_name;dataBuffer;nullabilityBuffer;_size;constructor(e,s,l){this._name=e,this.dataBuffer=s,"number"==typeof l?this._size=l:(this.nullabilityBuffer=l,this._size=l.size())}getValue(e){return this.nullabilityBuffer&&!this.nullabilityBuffer.get(e)?null:this.getValueFromBuffer(e)}has(e){return this.nullabilityBuffer&&this.nullabilityBuffer.get(e)||!this.nullabilityBuffer}get name(){return this._name}get size(){return this._size}}class Zh extends Yh{}class Hh extends Zh{getValueFromBuffer(e){return this.dataBuffer[e]}}class Kh extends Zh{getValueFromBuffer(e){return this.dataBuffer[e]}}class Wh extends Yh{delta;constructor(e,s,l,c){super(e,s,c),this.delta=l}}class Jh extends Wh{constructor(e,s,l,c){super(e,Int32Array.of(s),l,c)}getValueFromBuffer(e){return this.dataBuffer[0]+e*this.delta}}class Qh extends Yh{constructor(e,s,l){super(e,Int32Array.of(s),l)}getValueFromBuffer(e){return this.dataBuffer[0]}}class tp{_name;_geometryVector;_idVector;_propertyVectors;_extent;propertyVectorsMap;constructor(e,s,l,c,d=4096){this._name=e,this._geometryVector=s,this._idVector=l,this._propertyVectors=c,this._extent=d}get name(){return this._name}get idVector(){return this._idVector}get geometryVector(){return this._geometryVector}get propertyVectors(){return this._propertyVectors}getPropertyVector(e){return this.propertyVectorsMap||(this.propertyVectorsMap=new Map(this._propertyVectors.map((e=>[e.name,e])))),this.propertyVectorsMap.get(e)}*[Symbol.iterator](){const e=this.geometryVector[Symbol.iterator]();let s=0;for(;s>4,d<128)return 4294967296*c+(e>>>0);if(d=s[l.get()],l.increment(),c|=(127&d)<<3,d<128)return 4294967296*c+(e>>>0);if(d=s[l.get()],l.increment(),c|=(127&d)<<10,d<128)return 4294967296*c+(e>>>0);if(d=s[l.get()],l.increment(),c|=(127&d)<<17,d<128)return 4294967296*c+(e>>>0);if(d=s[l.get()],l.increment(),c|=(127&d)<<24,d<128)return 4294967296*c+(e>>>0);if(d=s[l.get()],l.increment(),c|=(1&d)<<31,d<128)return 4294967296*c+(e>>>0);throw new Error("Expected varint not more than 10 bytes")}(l,e,s)))))}function Bf(e,s,l,c){throw new Error("FastPFor is not implemented yet.")}function Of(e){return e>>>1^-(1&e)}function Vf(e){return e>>1n^-(1n&e)}function jf(e,s){let l=0n,c=0,d=s.get();for(;d=64)throw new Error("Varint too long")}return s.set(d),l}function Gf(e,s,l){const c=new Int32Array(l);let d=0;for(let l=0;l=4)for(let c=e[0];l>>1^-(1&e[0]),e[1]=e[1]>>>1^-(1&e[1]);const s=e.length/4*4;let l=2;if(s>=4)for(;l>>1^-(1&s))+e[l-2],e[l+1]=(c>>>1^-(1&c))+e[l-1],e[l+2]=(d>>>1^-(1&d))+e[l],e[l+3]=(p>>>1^-(1&p))+e[l+1]}for(;l!=e.length;l+=2)e[l]=(e[l]>>>1^-(1&e[l]))+e[l-2],e[l+1]=(e[l+1]>>>1^-(1&e[l+1]))+e[l-1]}!function(e){e.NONE="NONE",e.DELTA="DELTA",e.COMPONENTWISE_DELTA="COMPONENTWISE_DELTA",e.RLE="RLE",e.MORTON="MORTON",e.PDE="PDE"}(vf||(vf={})),function(e){e.NONE="NONE",e.FAST_PFOR="FAST_PFOR",e.VARINT="VARINT",e.ALP="ALP"}(bf||(bf={})),function(e){e.PRESENT="PRESENT",e.DATA="DATA",e.OFFSET="OFFSET",e.LENGTH="LENGTH"}(wf||(wf={}));class Ap{_dictionaryType;_offsetType;_lengthType;constructor(e,s,l){this._dictionaryType=e,this._offsetType=s,this._lengthType=l}get dictionaryType(){return this._dictionaryType}get offsetType(){return this._offsetType}get lengthType(){return this._lengthType}}function Wf(e,s){const l=function(e,s){const l=e[s.get()],c=Object.values(wf)[l>>4];let d=null;switch(c){case wf.DATA:d=new Ap(Object.values(Tf)[15&l]);break;case wf.OFFSET:d=new Ap(null,Object.values(Pf)[15&l]);break;case wf.LENGTH:d=new Ap(null,null,Object.values(Sf)[15&l])}s.increment();const p=e[s.get()],f=Object.values(vf)[p>>5],m=Object.values(vf)[p>>2&7],_=Object.values(bf)[3&p];s.increment();const g=kf(e,s,2),y=g[0];return{physicalStreamType:c,logicalStreamType:d,logicalLevelTechnique1:f,logicalLevelTechnique2:m,physicalLevelTechnique:_,numValues:y,byteLength:g[1],decompressedCount:y}}(e,s);return l.logicalLevelTechnique1===vf.MORTON?function(e,s,l){const c=kf(s,l,2);return{physicalStreamType:e.physicalStreamType,logicalStreamType:e.logicalStreamType,logicalLevelTechnique1:e.logicalLevelTechnique1,logicalLevelTechnique2:e.logicalLevelTechnique2,physicalLevelTechnique:e.physicalLevelTechnique,numValues:e.numValues,byteLength:e.byteLength,decompressedCount:e.decompressedCount,numBits:c[0],coordinateShift:c[1]}}(l,e,s):vf.RLE!==l.logicalLevelTechnique1&&vf.RLE!==l.logicalLevelTechnique2||bf.NONE===l.physicalLevelTechnique?l:function(e,s,l){const c=kf(s,l,2);return{physicalStreamType:e.physicalStreamType,logicalStreamType:e.logicalStreamType,logicalLevelTechnique1:e.logicalLevelTechnique1,logicalLevelTechnique2:e.logicalLevelTechnique2,physicalLevelTechnique:e.physicalLevelTechnique,numValues:e.numValues,byteLength:e.byteLength,decompressedCount:c[1],runs:c[0],numRleValues:c[1]}}(l,e,s)}!function(e){e.NONE="NONE",e.SINGLE="SINGLE",e.SHARED="SHARED",e.VERTEX="VERTEX",e.MORTON="MORTON",e.FSST="FSST"}(Tf||(Tf={})),function(e){e.VERTEX="VERTEX",e.INDEX="INDEX",e.STRING="STRING",e.KEY="KEY"}(Pf||(Pf={})),function(e){e.VAR_BINARY="VAR_BINARY",e.GEOMETRIES="GEOMETRIES",e.PARTS="PARTS",e.RINGS="RINGS",e.TRIANGLES="TRIANGLES",e.SYMBOL="SYMBOL",e.DICTIONARY="DICTIONARY"}(Sf||(Sf={})),function(e){e[e.FLAT=0]="FLAT",e[e.CONST=1]="CONST",e[e.SEQUENCE=2]="SEQUENCE",e[e.DICTIONARY=3]="DICTIONARY",e[e.FSST_DICTIONARY=4]="FSST_DICTIONARY"}(Ef||(Ef={}));class Ep{values;_size;constructor(e,s){this.values=e,this._size=s}get(e){const s=Math.floor(e/8);return 1==(this.values[s]>>e%8&1)}set(e,s){const l=Math.floor(e/8);this.values[l]=this.values[l]|(s?1:0)<>e%8&1}size(){return this._size}getBuffer(){return this.values}}function Xf(e,s,l,c,d){return function(e,s,l){switch(s.logicalLevelTechnique1){case vf.DELTA:return s.logicalLevelTechnique2===vf.RLE?function(e,s,l){const c=new Int32Array(l);let d=0,p=0;for(let l=0;l>>1^-(1&e[0]);const s=e.length/4*4;let l=1;if(s>=4)for(;l>>1^-(1&s))+e[l-1],e[l+1]=(c>>>1^-(1&c))+e[l],e[l+2]=(d>>>1^-(1&d))+e[l+1],e[l+3]=(p>>>1^-(1&p))+e[l+2]}for(;l!=e.length;++l)e[l]=(e[l]>>>1^-(1&e[l]))+e[l-1]}(e),e);case vf.RLE:return function(e,s,l){return l?function(e,s,l){const c=new Int32Array(l);let d=0;for(let l=0;l>>1^-(1&f),c.fill(f,d,d+p),d+=p}return c}(e,s.runs,s.numRleValues):Gf(e,s.runs,s.numRleValues)}(e,s,l);case vf.MORTON:return Zf(e),e;case vf.COMPONENTWISE_DELTA:return $f(e),e;case vf.NONE:return l&&function(e){for(let s=0;s>>1^-(1&l)}}(e),e;default:throw new Error(`The specified Logical level technique is not supported: ${s.logicalLevelTechnique1}`)}}(Kf(e,s,l),l,c)}function Yf(e,s,l){return function(e,s){if(s.logicalLevelTechnique1===vf.DELTA&&s.logicalLevelTechnique2===vf.NONE){const s=function(e){const s=new Int32Array(e.length+1);s[0]=0,s[1]=Of(e[0]);let l=s[1],c=2;for(;c!=s.length;++c){const d=e[c-1];l+=d>>>1^-(1&d),s[c]=s[c-1]+l}return s}(e);return s}if(s.logicalLevelTechnique1===vf.RLE&&s.logicalLevelTechnique2===vf.NONE){const l=function(e,s,l){const c=new Int32Array(l+1);c[0]=0;let d=1,p=c[0];for(let l=0;l>>1^-(1&m);for(let e=d;e>1n^-(1n&e[0]);const s=e.length/4*4;let l=1;if(s>=4)for(;l>1n^-(1n&s))+e[l-1],e[l+1]=(c>>1n^-(1n&c))+e[l],e[l+2]=(d>>1n^-(1n&d))+e[l+1],e[l+3]=(p>>1n^-(1n&p))+e[l+2]}for(;l!=e.length;++l)e[l]=(e[l]>>1n^-(1n&e[l]))+e[l-1]}(e),e);case vf.RLE:return function(e,s,l){return l?function(e,s,l){const c=new BigInt64Array(l);let d=0;for(let l=0;l>1n^-(1n&f),c.fill(f,d,d+p),d+=p}return c}(e,s.runs,s.numRleValues):Uf(e,s.runs,s.numRleValues)}(e,s,l);case vf.NONE:return l&&function(e){for(let s=0;s>1n^-(1n&l)}}(e),e;default:throw new Error(`The specified Logical level technique is not supported: ${s.logicalLevelTechnique1}`)}}(Rf(e,s,l.numValues),l,c)}function im(e,s,l,c){const d=Rf(e,s,l.numValues);if(1===d.length){const e=d[0];return c?Vf(e):e}return c?function(e){return Vf(e[1])}(d):function(e){return e[1]}(d)}function rm(e,s,l,c,d){return function(e,s,l,c){switch(s.logicalLevelTechnique1){case vf.DELTA:return s.logicalLevelTechnique2===vf.RLE&&(e=Gf(e,s.runs,s.numRleValues)),function(e,s){const l=new Int32Array(e.size());let c=0;e.get(0)?(l[0]=e.get(0)?s[0]>>>1^-(1&s[0]):0,c=1):l[0]=0;let d=1;for(;d!=l.length;++d)l[d]=e.get(d)?l[d-1]+(s[c]>>>1^-(1&s[c++])):l[d-1];return l}(c,e);case vf.RLE:return function(e,s,l,c){const d=s;return l?function(e,s,l){const c=new Int32Array(e.size());let d=0;for(let p=0;p>>1^-(1&m);for(let s=d;s>>1^-(1&e)}else l[d]=0;return l}(c,e):function(e,s){const l=new Int32Array(e.size());let c=0,d=0;for(;d!=l.length;++d)l[d]=e.get(d)?s[c++]:0;return l}(c,e),e;default:throw new Error("The specified Logical level technique is not supported")}}(l.physicalLevelTechnique===bf.FAST_PFOR?Bf():kf(e,s,l.numValues),l,c,d)}function nm(e,s,l,c){const d=e.logicalLevelTechnique1;if(d===vf.RLE)return 1===e.runs?Ef.CONST:Ef.FLAT;const p=s instanceof Ep?s.size():s;if(d===vf.DELTA&&e.logicalLevelTechnique2===vf.RLE){const s=e.runs,d=2;if(e.numRleValues!==p)return Ef.FLAT;if(1===s)return Ef.SEQUENCE;if(2===s){const s=c.get();let p;if(e.physicalLevelTechnique===bf.VARINT)p=kf(l,c,4);else{const e=c.get();p=new Int32Array(l.buffer,l.byteOffset+e,4)}if(c.set(s),p[2]===d&&p[3]===d)return Ef.SEQUENCE}}return 1===e.numValues?Ef.CONST:Ef.FLAT}class Lp extends Zh{getValueFromBuffer(e){return this.dataBuffer[e]}}class Op extends Wh{constructor(e,s,l,c){super(e,BigInt64Array.of(s),l,c)}getValueFromBuffer(e){return this.dataBuffer[0]+BigInt(e)*this.delta}}class Rp{_geometryOffsets;_partOffsets;_ringOffsets;constructor(e,s,l){this._geometryOffsets=e,this._partOffsets=s,this._ringOffsets=l}get geometryOffsets(){return this._geometryOffsets}get partOffsets(){return this._partOffsets}get ringOffsets(){return this._ringOffsets}}function sm(e,s,l){return{x:om(e,s)-l,y:om(e>>1,s)-l}}function om(e,s){let l=0;for(let c=0;c>c;return l}!function(e){e[e.POINT=0]="POINT",e[e.LINESTRING=1]="LINESTRING",e[e.POLYGON=2]="POLYGON",e[e.MULTIPOINT=3]="MULTIPOINT",e[e.MULTILINESTRING=4]="MULTILINESTRING",e[e.MULTIPOLYGON=5]="MULTIPOLYGON"}(Cf||(Cf={})),function(e){e[e.POINT=0]="POINT",e[e.LINESTRING=1]="LINESTRING",e[e.POLYGON=2]="POLYGON"}(Af||(Af={})),function(e){e[e.MORTON=0]="MORTON",e[e.VEC_2=1]="VEC_2",e[e.VEC_3=2]="VEC_3"}(zf||(zf={}));class Up{createPoint(e){return[[e]]}createMultiPoint(e){return e.map((e=>[e]))}createLineString(e){return[e]}createMultiLineString(e){return e}createPolygon(e,s){return[e].concat(s)}createMultiPolygon(e){return e.flat()}}function am(e){const s=new Array(e.numGeometries);let l=1,d=1,p=1,f=0;const m=new Up;let _=0,g=0;const y=e.mortonSettings,b=e.topologyVector,T=b.geometryOffsets,P=b.partOffsets,S=b.ringOffsets,I=e.vertexOffsets,C=e.containsPolygonGeometry(),z=e.vertexBuffer;for(let b=0;b0&&s.push(s[0]),b.push(s)}e[s]=b,p&&g++}break;case Cf.MULTIPOLYGON:{const y=p[g]-p[g-1];g++;const b=[];for(let e=0;e0&&s.push(s[0]),b.push(s)}}e[s]=b}}return e}[Symbol.iterator](){return null}}function fm(e,s,l,c,d,p){return new ef(e,s,l,c,d,p)}class ef extends Qp{_numGeometries;_geometryType;constructor(e,s,l,c,d,p){super(l,c,d,p),this._numGeometries=e,this._geometryType=s}geometryType(e){return this._geometryType}get numGeometries(){return this._numGeometries}containsSingleGeometryType(){return!0}}function mm(e,s,l,c,d){return new nf(e,s,l,c,d)}class nf extends Qp{_geometryTypes;constructor(e,s,l,c,d){super(s,l,c,d),this._geometryTypes=e}geometryType(e){return this._geometryTypes[e]}get numGeometries(){return this._geometryTypes.length}containsSingleGeometryType(){return!1}}function _m(e,s,l,c,d){const p=Wf(e,l);let f=null,m=null,_=null,g=null,y=null,b=null,T=null,P=null;if(nm(p,c,e,l)===Ef.CONST){const d=Qf(e,l,p,!1);for(let c=0;cl?s[p++]:1);return c}function ym(e,s,l,c){const d=new Int32Array(s[s.length-1]+1);let p=0;d[0]=p;let f=1,m=0;for(let _=0;_=12?bm.decode(e.subarray(s,l)):function(e,s,l){let c="",d=s;for(;d239?4:s>223?3:s>191?2:1;if(d+g>l)break;1===g?s<128&&(_=s):2===g?(p=e[d+1],128==(192&p)&&(_=(31&s)<<6|63&p,_<=127&&(_=null))):3===g?(p=e[d+1],f=e[d+2],128==(192&p)&&128==(192&f)&&(_=(15&s)<<12|(63&p)<<6|63&f,(_<=2047||_>=55296&&_<=57343)&&(_=null))):4===g&&(p=e[d+1],f=e[d+2],m=e[d+3],128==(192&p)&&128==(192&f)&&128==(192&m)&&(_=(15&s)<<18|(63&p)<<12|(63&f)<<6|63&m,(_<=65535||_>=1114112)&&(_=null))),null===_?(_=65533,g=1):_>65535&&(_-=65536,c+=String.fromCharCode(_>>>10&1023|55296),_=56320|1023&_),c+=String.fromCharCode(_),d+=g}return c}(e,s,l)}class yf extends Yh{offsetBuffer;constructor(e,s,l,c){super(e,l,c),this.offsetBuffer=s}}class mf extends yf{textEncoder;constructor(e,s,l,c){super(e,s,l,c??s.length-1),this.textEncoder=new TextEncoder}getValueFromBuffer(e){return wm(this.dataBuffer,this.offsetBuffer[e],this.offsetBuffer[e+1])}}class gf extends yf{indexBuffer;textEncoder;constructor(e,s,l,c,d){super(e,l,c,d??s.length),this.indexBuffer=s,this.indexBuffer=s,this.textEncoder=new TextEncoder}getValueFromBuffer(e){const s=this.indexBuffer[e];return wm(this.dataBuffer,this.offsetBuffer[s],this.offsetBuffer[s+1])}}class xf extends yf{indexBuffer;symbolOffsetBuffer;symbolTableBuffer;textEncoder;symbolLengthBuffer;lengthBuffer;decodedDictionary;constructor(e,s,l,c,d,p,f){super(e,l,c,f),this.indexBuffer=s,this.symbolOffsetBuffer=d,this.symbolTableBuffer=p,this.textEncoder=new TextEncoder}getValueFromBuffer(e){null==this.decodedDictionary&&(null==this.symbolLengthBuffer&&(this.symbolLengthBuffer=this.offsetToLengthBuffer(this.symbolOffsetBuffer),this.lengthBuffer=this.offsetToLengthBuffer(this.offsetBuffer)),this.decodedDictionary=function(e,s,l){const c=[],d=new Array(s.length).fill(0);for(let e=1;e>1n^-(1n&s[0]):0n,c=1):l[0]=0n;let d=1;for(;d!=l.length;++d)l[d]=e.get(d)?l[d-1]+(s[c]>>1n^-(1n&s[c++])):l[d-1];return l}(c,e);case vf.RLE:return function(e,s,l,c){const d=s;return l?function(e,s,l){const c=new BigInt64Array(e.size());let d=0;for(let p=0;p>1n^-(1n&m);for(let s=d;s>1n^-(1n&e)}else l[d]=0n;return l}(c,e):function(e,s){const l=new BigInt64Array(e.size());let c=0,d=0;for(;d!=l.length;++d)l[d]=e.get(d)?s[c++]:0n;return l}(c,e),e;default:throw new Error("The specified Logical level technique is not supported")}}(Rf(e,s,l.numValues),l,c,d)}(e,s,p,m,c):tm(e,s,p,m);return new Lp(l.name,d,c)}if(f===Ef.SEQUENCE){const c=em(e,s,p);return new Op(l.name,c[0],c[1],p.numRleValues)}{const d=im(e,s,p,m);return new cf(l.name,d,c)}}(s,l,p,_,d);case 7:return function(e,s,l,c){const d=Wf(e,s),p=Pm(c)?function(e,s,l,c){const d=s.get(),p=d+c*Float32Array.BYTES_PER_ELEMENT,f=new Uint8Array(e.subarray(d,p)).buffer,m=new Float32Array(f);s.set(p);const _=l.size(),g=new Float32Array(_);let y=0;for(let e=0;e<_;e++)g[e]=l.get(e)?m[y++]:0;return g}(e,s,c,d.numValues):function(e,s,l){const c=s.get(),d=c+l*Float32Array.BYTES_PER_ELEMENT,p=new Uint8Array(e.subarray(c,d)).buffer,f=new Float32Array(p);return s.set(d),f}(e,s,d.numValues);return new uf(l.name,p,c)}(s,l,p,_);case 8:return function(e,s,l,c){const d=Wf(e,s),p=Pm(c)?function(e,s,l,c){const d=s.get(),p=d+c*Float64Array.BYTES_PER_ELEMENT,f=new Uint8Array(e.subarray(d,p)).buffer,m=new Float64Array(f);s.set(p);const _=l.size(),g=new Float64Array(_);let y=0;for(let e=0;e<_;e++)g[e]=l.get(e)?m[y++]:0;return g}(e,s,c,d.numValues):function(e,s,l){const c=s.get(),d=c+l*Float64Array.BYTES_PER_ELEMENT,p=new Uint8Array(e.subarray(c,d)).buffer,f=new Float64Array(p);return s.set(d),f}(e,s,d.numValues);return new Kh(l.name,p,c)}(s,l,p,_);default:throw new Error(`The specified data type for the field is currently not supported: ${d}`)}}(c,e,s,d,l.scalarType,l):1!=c?null:function(e,s,l,c){let d=null,p=null,f=null,m=null,_=!1;for(;!_;){const l=Wf(e,s);switch(l.physicalStreamType){case wf.LENGTH:Sf.DICTIONARY===l.logicalStreamType.lengthType?d=Yf(e,s,l):f=Yf(e,s,l);break;case wf.DATA:Tf.SINGLE===l.logicalStreamType.dictionaryType||Tf.SHARED===l.logicalStreamType.dictionaryType?(p=e.subarray(s.get(),s.get()+l.byteLength),_=!0):m=e.subarray(s.get(),s.get()+l.byteLength),s.add(l.byteLength)}}const g=l.complexType.children,y=[];let b=0;for(const _ of g){const g=kf(e,s,1)[0];if(0==g)continue;const T=`${l.name}${"default"===_.name?"":":"+_.name}`;if(2!==g||"scalarField"!==_.type||9!==_.scalarField.physicalType)throw new Error("Currently only optional string fields are implemented for a struct.");const P=Wf(e,s),S=xm(e,P.numValues,s),I=Wf(e,s),C=I.decompressedCount!==c?rm(e,s,I,!1,new Ep(S,P.numValues)):Xf(e,s,I,!1);y[b++]=m?new xf(T,C,d,p,f,m,new Ep(S,P.numValues)):new gf(T,C,d,p,new Ep(S,P.numValues))}return y}(e,s,l,d)}function Pm(e){return e instanceof Ep}function Sm(e){if("id"===e.name)return!1;if("scalarType"===e.type){const s=e.scalarType;if("physicalType"===s.type)switch(s.physicalType){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:case 8:default:return!1;case 9:return!0}else if("logicalType"===s.type)return!1}else if("complexType"===e.type){const s=e.complexType;if("physicalType"===s.type)switch(s.physicalType){case 0:case 1:return!0;default:return!1}}return console.warn("Unexpected column type in hasStreamCount",e),!1}const Mm=new TextDecoder;function Im(e,s){const l=kf(e,s,1)[0];if(0===l)return"";const c=s.get(),d=e.subarray(c,c+l);return s.add(l),Mm.decode(d)}function Em(e,s){const l=kf(e,s,1)[0]>>>0,c=!!(4&l),d=!!(2&l),p=kf(e,s,1)[0]>>>0,f={};if(1&l&&(f.nullable=!0),d){const d={};if(c?(d.type="logicalType",d.logicalType=p):(d.type="physicalType",d.physicalType=p),8&l){const l=kf(e,s,1)[0]>>>0;d.children=new Array(l);for(let c=0;c>>0,c=function(e){switch(e){case 0:case 1:case 2:case 3:{const s={};s.nullable=!!(1&e),s.columnScope=0;const l={};return l.physicalType=e>1?6:4,l.type="physicalType",s.scalarType=l,s.type="scalarType",s}case 4:{const e={nullable:!1,columnScope:0},s={type:"physicalType",physicalType:0};return e.type="complexType",e.complexType=s,e}case 30:{const e={nullable:!1,columnScope:0},s={type:"physicalType",physicalType:1};return e.type="complexType",e.complexType=s,e}default:return function(e){let s=null;switch(e){case 10:case 11:s=0;break;case 12:case 13:s=1;break;case 14:case 15:s=2;break;case 16:case 17:s=3;break;case 18:case 19:s=4;break;case 20:case 21:s=5;break;case 22:case 23:s=6;break;case 24:case 25:s=7;break;case 26:case 27:s=8;break;case 28:case 29:s=9;break;default:return null}const l={};l.nullable=!!(1&e),l.columnScope=0;const c={type:"physicalType"};return c.physicalType=s,l.type="scalarType",l.scalarType=c,l}(e)}}(l);if(!c)throw new Error(`Unsupported column type code: ${l}`);if(function(e){return e>=10}(l)?c.name=Im(e,s):l>=0&&l<=3?c.name="id":4===l&&(c.name="geometry"),function(e){return 30===e}(l)){const l=kf(e,s,1)[0]>>>0,d=c.complexType;d.children=new Array(l);for(let c=0;c>>0,p=kf(e,s,1)[0]>>>0;c.columns=new Array(p);for(let l=0;l=4)for(;l>>0,p=c.get()+s;if(p>e.length)throw new Error(`Block overruns tile: ${p} > ${e.length}`);if(1!=kf(e,c,1)[0]>>>0){c.set(p);continue}const f=Am(e,c),m=f[1],_=f[0].featureTables[0];let g=null,y=null;const b=[];let T=0;for(const s of _.columns){const d=s.name;if("id"===d){let p=null;if(s.nullable){const s=Wf(e,c),l=c.get(),d=xm(e,s.numValues,c);c.set(l+s.byteLength),p=new Ep(d,s.numValues)}const f=Wf(e,c);T=f.decompressedCount,g=Dm(e,s,c,d,f,p??T,l)}else if("geometry"===d){const s=kf(e,c,1)[0];if(0===T){const s=c.get();T=Wf(e,c).decompressedCount,c.set(s)}y=_m(e,s,c,T)}else{const l=Sm(s)?kf(e,c,1)[0]:1;if(0===l&&"scalarType"===s.type)continue;const d=Tm(e,c,s,l,T);if(d)if(Array.isArray(d))for(const e of d)b.push(e);else b.push(d)}}const P=new tp(_.name,y,g,b,m);d.push(P),c.set(p)}return d}(new Uint8Array(e));this.layers=s.reduce(((e,s)=>Object.assign(Object.assign({},e),{[s.name]:new Mf(s)})),{})}}class Df{constructor(e,s){this.feature=e,this.type=e.type,this.properties=e.tags?e.tags:{},this.extent=s,"id"in e&&("string"==typeof e.id?this.id=parseInt(e.id,10):"number"!=typeof e.id||isNaN(e.id)||(this.id=e.id))}loadGeometry(){const e=[],s=1===this.feature.type?[this.feature.geometry]:this.feature.geometry;for(const l of s){const s=[];for(const e of l)s.push(new c(e[0],e[1]));e.push(s)}return e}}const zm="_geojsonTileLayer";function km(e,s){s.writeVarintField(15,e.version||1),s.writeStringField(1,e.name||""),s.writeVarintField(5,e.extent||4096);const l={keys:[],values:[],keycache:{},valuecache:{}};for(let c=0;c>31}function Om(e,s){const l=e.loadGeometry(),c=e.type;let d=0,p=0;for(const f of l){let l=1;1===c&&(l=f.length),s.writeVarint(Fm(1,l));const m=3===c?f.length-1:f.length;for(let e=0;e=0&&c[3]>=0&&m.insert(f,c[0],c[1],c[2],c[3])}}loadVTLayers(){return this.vtLayers||(this.vtLayers="mlt"!==this.encoding?new Vu(new Tc(this.rawTileData)).layers:new Ff(this.rawTileData).layers,this.sourceLayerCoder=new Gh(this.vtLayers?Object.keys(this.vtLayers).sort():[zm])),this.vtLayers}query(e,s,l,d){this.loadVTLayers();const p=e.params,f=se/e.tileSize/e.scale,m=Co(p.filter,p.globalState),_=e.queryGeometry,g=e.queryPadding*f,y=jh.fromPoints(_),b=this.grid.query(y.minX-g,y.minY-g,y.maxX+g,y.maxY+g),T=jh.fromPoints(e.cameraQueryGeometry).expandBy(g),P=this.grid3D.query(T.minX,T.minY,T.maxX,T.maxY,((s,l,d,p)=>function(e,s,l,d,p){for(const c of e)if(s<=c.x&&l<=c.y&&d>=c.x&&p>=c.y)return!0;const f=[new c(s,l),new c(s,p),new c(d,p),new c(d,l)];if(e.length>2)for(const s of f)if(dh(e,s))return!0;for(let s=0;s(T||(T=Qc(s)),l.queryIntersectsFeature({queryGeometry:_,feature:s,featureState:c,geometry:T,zoom:this.z,transform:e.transform,pixelsToTileUnits:f,pixelPosMatrix:e.pixelPosMatrix,unwrappedTileID:this.tileID.toUnwrapped(),getElevation:e.getElevation}))))}return S}loadMatchingFeature(e,s,l,c,d,p,f,m,_,g,y){const b=this.bucketLayerIDs[s];if(p&&!b.some((e=>p.has(e))))return;const T=this.sourceLayerCoder.decode(l),P=this.vtLayers[T].feature(c);if(d.needGeometry){const e=Jc(P,!0);if(!d.filter(new Ps(this.tileID.overscaledZ),e,this.tileID.canonical))return}else if(!d.filter(new Ps(this.tileID.overscaledZ),P))return;const S=this.getId(P,T);for(let s=0;s{const f=s instanceof qs?s.get(p):null;return f&&f.evaluate?f.evaluate(l,c,d):f}))}function Nm(e,s){return s-e}function Gm(e,s,l,d,p){const f=[];for(let m=0;m=d&&y.x>=d||(m.x>=d?m=new c(d,m.y+(d-m.x)/(y.x-m.x)*(y.y-m.y))._round():y.x>=d&&(y=new c(d,m.y+(d-m.x)/(y.x-m.x)*(y.y-m.y))._round()),m.y>=p&&y.y>=p||(m.y>=p?m=new c(m.x+(p-m.y)/(y.y-m.y)*(y.x-m.x),p)._round():y.y>=p&&(y=new c(m.x+(p-m.y)/(y.y-m.y)*(y.x-m.x),p)._round()),g&&m.equals(g[g.length-1])||(g=[m],f.push(g)),g.push(y)))))}}return f}function Um(e,s,l,c,d){switch(s){case 1:return function(e,s,l,c){const d=[];for(const p of e)for(const e of p){const p=0===c?e.x:e.y;p>=s&&p<=l&&d.push([e])}return d}(e,l,c,d);case 2:return Zm(e,l,c,d,!1);case 3:return Zm(e,l,c,d,!0)}return[]}function qm(e,s,l,d,p){const f=0===d?$m:Wm;let m=[];const _=[];for(let c=0;cs&&m.push(f(g,y,s)):b>l?T=s&&(m.push(f(g,y,s)),P=!0),T>l&&b<=l&&(m.push(f(g,y,l)),P=!0),!p&&P&&(_.push(m),m=[])}const g=e.length-1,y=0===d?e[g].x:e[g].y;return y>=s&&y<=l&&m.push(e[g]),p&&m.length>0&&!m[0].equals(m[m.length-1])&&m.push(new c(m[0].x,m[0].y)),m.length>0&&_.push(m),_}function Zm(e,s,l,c,d){const p=[];for(const f of e){const e=qm(f,s,l,c,d);e.length>0&&p.push(...e)}return p}function $m(e,s,l){return new c(l,e.y+(l-e.x)/(s.x-e.x)*(s.y-e.y))}function Wm(e,s,l){return new c(e.x+(l-e.y)/(s.y-e.y)*(s.x-e.x),l)}Yl("FeatureIndex",Nf,{omit:["rawTileData","sourceLayerCoder"]});class Hf extends c{constructor(e,s,l,c){super(e,s),this.angle=l,void 0!==c&&(this.segment=c)}clone(){return new Hf(this.x,this.y,this.angle,this.segment)}}function Hm(e,s,l,c,d){if(void 0===s.segment||0===l)return!0;let p=s,f=s.segment+1,m=0;for(;m>-l/2;){if(f--,f<0)return!1;m-=e[f].dist(p),p=e[f]}m+=e[f].dist(e[f+1]),f++;const _=[];let g=0;for(;mc;)g-=_.shift().angleDelta;if(g>d)return!1;f++,m+=s.dist(l)}return!0}function Xm(e){let s=0;for(let l=0;lg){const y=(g-_)/p,b=Gr.number(c.x,d.x,y),T=Gr.number(c.y,d.y,y),P=new Hf(b,T,d.angleTo(c),l);return P._round(),!f||Hm(e,P,m,f,s)?P:void 0}_+=p}}function Jm(e,s,l,c,d,p,f,m,_){const g=Ym(c,p,f),y=Km(c,d),b=y*f,T=0===e[0].x||e[0].x===_||0===e[0].y||e[0].y===_;return s-b=0&&z<_&&L>=0&&L<_&&T-g>=0&&T+g<=y){const l=new Hf(z,L,I,s);l._round(),c&&!Hm(e,l,p,c,d)||P.push(l)}}b+=S}return m||P.length||f||(P=e_(e,b/2,l,c,d,p,f,!0,_)),P}function t_(e,s,l,d){const p=[],f=e.image,m=f.pixelRatio,_=f.paddedRect.w-2,g=f.paddedRect.h-2;let y={x1:e.left,y1:e.top,x2:e.right,y2:e.bottom};const b=f.stretchX||[[0,_]],T=f.stretchY||[[0,g]],P=(e,s)=>e+s[1]-s[0],S=b.reduce(P,0),I=T.reduce(P,0),C=_-S,z=g-I;let L=0,F=S,B=0,O=I,j=0,G=C,U=0,q=z;if(f.content&&d){const s=f.content,l=s[2]-s[0],c=s[3]-s[1];(f.textFitWidth||f.textFitHeight)&&(y=Pp(e)),L=i_(b,0,s[0]),B=i_(T,0,s[1]),F=i_(b,s[0],s[2]),O=i_(T,s[1],s[3]),j=s[0]-L,U=s[1]-B,G=l-F,q=c-O}const Z=y.x1,W=y.y1,J=y.x2-Z,re=y.y2-W,se=(e,d,p,_)=>{const g=n_(e.stretch-L,F,J,Z),y=s_(e.fixed-j,G,e.stretch,S),b=n_(d.stretch-B,O,re,W),T=s_(d.fixed-U,q,d.stretch,I),P=n_(p.stretch-L,F,J,Z),C=s_(p.fixed-j,G,p.stretch,S),z=n_(_.stretch-B,O,re,W),se=s_(_.fixed-U,q,_.stretch,I),oe=new c(g,b),le=new c(P,b),ce=new c(P,z),he=new c(g,z),ue=new c(y/m,T/m),pe=new c(C/m,se/m),fe=s*Math.PI/180;if(fe){const e=Math.sin(fe),s=Math.cos(fe),l=[s,-e,e,s];oe._matMult(l),le._matMult(l),he._matMult(l),ce._matMult(l)}const me=e.stretch+e.fixed,ge=d.stretch+d.fixed;return{tl:oe,tr:le,bl:he,br:ce,tex:{x:f.paddedRect.x+1+me,y:f.paddedRect.y+1+ge,w:p.stretch+p.fixed-me,h:_.stretch+_.fixed-ge},writingMode:void 0,glyphOffset:[0,0],sectionIndex:0,pixelOffsetTL:ue,pixelOffsetBR:pe,minFontScaleX:G/m/J,minFontScaleY:q/m/re,isSDF:l}};if(d&&(f.stretchX||f.stretchY)){const e=r_(b,C,S),s=r_(T,z,I);for(let l=0;l0&&(c=Math.max(10,c),this.circleDiameter=c)}else{const g=(null===(b=f.image)||void 0===b?void 0:b.content)&&(f.image.textFitWidth||f.image.textFitHeight)?Pp(f):{x1:f.left,y1:f.top,x2:f.right,y2:f.bottom};g.y1=g.y1*m-_[0],g.y2=g.y2*m+_[2],g.x1=g.x1*m-_[3],g.x2=g.x2*m+_[1];const T=f.collisionPadding;if(T&&(g.x1-=T[0]*m,g.y1-=T[1]*m,g.x2+=T[2]*m,g.y2+=T[3]*m),y){const e=new c(g.x1,g.y1),s=new c(g.x2,g.y1),l=new c(g.x1,g.y2),d=new c(g.x2,g.y2),p=y*Math.PI/180;e._rotate(p),s._rotate(p),l._rotate(p),d._rotate(p),g.x1=Math.min(e.x,s.x,l.x,d.x),g.x2=Math.max(e.x,s.x,l.x,d.x),g.y1=Math.min(e.y,s.y,l.y,d.y),g.y2=Math.max(e.y,s.y,l.y,d.y)}e.emplaceBack(s.x,s.y,g.x1,g.y1,g.x2,g.y2,l,d,p)}this.boxEndIndex=e.length}}class ud{constructor(e=[],s=(e,s)=>es?1:0){if(this.data=e,this.length=this.data.length,this.compare=s,this.length>0)for(let e=(this.length>>1)-1;e>=0;e--)this._down(e)}push(e){this.data.push(e),this._up(this.length++)}pop(){if(0===this.length)return;const e=this.data[0],s=this.data.pop();return--this.length>0&&(this.data[0]=s,this._down(0)),e}peek(){return this.data[0]}_up(e){const{data:s,compare:l}=this,c=s[e];for(;e>0;){const d=e-1>>1,p=s[d];if(l(c,p)>=0)break;s[e]=p,e=d}s[e]=c}_down(e){const{data:s,compare:l}=this,c=this.length>>1,d=s[e];for(;e=0)break;s[e]=s[c],e=c}s[e]=d}}function o_(e,s=1,l=!1){const d=jh.fromPoints(e[0]),p=Math.min(d.width(),d.height());let f=p/2;const m=new ud([],a_),{minX:_,minY:g,maxX:y,maxY:b}=d;if(0===p)return new c(_,g);for(let s=_;sT.d||!T.d)&&(T=c,l&&console.log("found best %d after %d probes",Math.round(1e4*c.d)/1e4,P)),c.max-T.d<=s||(f=c.h/2,m.push(new l_(c.p.x-f,c.p.y-f,f,e)),m.push(new l_(c.p.x+f,c.p.y-f,f,e)),m.push(new l_(c.p.x-f,c.p.y+f,f,e)),m.push(new l_(c.p.x+f,c.p.y+f,f,e)),P+=4)}return l&&(console.log(`num probes: ${P}`),console.log(`best distance: ${T.d}`)),T.p}function a_(e,s){return s.max-e.max}function l_(s,l,d,p){(this||e).p=new c(s,l),(this||e).h=d,(this||e).d=function(e,s){let l=!1,c=1/0;for(let d=0;de.y!=m.y>e.y&&e.x<(m.x-d.x)*(e.y-d.y)/(m.y-d.y)+d.x&&(l=!l),c=Math.min(c,ch(e,d,m))}}return(l?1:-1)*Math.sqrt(c)}((this||e).p,p),(this||e).max=(this||e).d+(this||e).h*Math.SQRT2}var c_;s.aP=void 0,(c_=s.aP||(s.aP={}))[c_.center=1]="center",c_[c_.left=2]="left",c_[c_.right=3]="right",c_[c_.top=4]="top",c_[c_.bottom=5]="bottom",c_[c_["top-left"]=6]="top-left",c_[c_["top-right"]=7]="top-right",c_[c_["bottom-left"]=8]="bottom-left",c_[c_["bottom-right"]=9]="bottom-right";const h_=Number.POSITIVE_INFINITY;function u_(e,s){return s[1]!==h_?function(e,s,l){let c=0,d=0;switch(s=Math.abs(s),l=Math.abs(l),e){case"top-right":case"top-left":case"top":d=l-7;break;case"bottom-right":case"bottom-left":case"bottom":d=7-l}switch(e){case"top-right":case"bottom-right":case"right":c=-s;break;case"top-left":case"bottom-left":case"left":c=s}return[c,d]}(e,s[0],s[1]):function(e,s){let l=0,c=0;s<0&&(s=0);const d=s/Math.SQRT2;switch(e){case"top-right":case"top-left":c=d-7;break;case"bottom-right":case"bottom-left":c=7-d;break;case"bottom":c=7-s;break;case"top":c=s-7}switch(e){case"top-right":case"bottom-right":l=-d;break;case"top-left":case"bottom-left":l=d;break;case"left":l=s;break;case"right":l=-s}return[l,c]}(e,s[0])}function d_(e,s,l){var c;const d=e.layout,p=null===(c=d.get("text-variable-anchor-offset"))||void 0===c?void 0:c.evaluate(s,{},l);if(p){const e=p.values,s=[];for(let l=0;le*Vd));c.startsWith("top")?d[1]-=7:c.startsWith("bottom")&&(d[1]+=7),s[l+1]=d}return new Le(s)}const f=d.get("text-variable-anchor");if(f){let c;c=void 0!==e._unevaluatedLayout.getValue("text-radial-offset")?[d.get("text-radial-offset").evaluate(s,{},l)*Vd,h_]:d.get("text-offset").evaluate(s,{},l).map((e=>e*Vd));const p=[];for(const e of f)p.push(e,u_(e,c));return new Le(p)}return null}function p_(e){switch(e){case"right":case"top-right":case"bottom-right":return"right";case"left":case"top-left":case"bottom-left":return"left"}return"center"}function f_(e,l,c,d,p,f,m,_,g,y,b,T){let P=f.textMaxSize.evaluate(l,{});void 0===P&&(P=m);const S=e.layers[0].layout,I=S.get("icon-offset").evaluate(l,{},b),C=__(c.horizontal),z=m/24,L=e.tilePixelRatio*z,F=e.tilePixelRatio*P/24,B=e.tilePixelRatio*_,O=e.tilePixelRatio*S.get("symbol-spacing"),j=S.get("text-padding")*e.tilePixelRatio,G=function(e,s,l,c=1){const d=e.get("icon-padding").evaluate(s,{},l),p=d&&d.values;return[p[0]*c,p[1]*c,p[2]*c,p[3]*c]}(S,l,b,e.tilePixelRatio),U=S.get("text-max-angle")/180*Math.PI,q="viewport"!==S.get("text-rotation-alignment")&&"point"!==S.get("symbol-placement"),Z="map"===S.get("icon-rotation-alignment")&&"point"!==S.get("symbol-placement"),W=S.get("symbol-placement"),J=O/2,re=S.get("icon-text-fit");let oe;d&&"none"!==re&&(e.allowVerticalPlacement&&c.vertical&&(oe=Sp(d,c.vertical,re,S.get("icon-text-fit-padding"),I,z)),C&&(d=Sp(d,C,re,S.get("icon-text-fit-padding"),I,z)));const le=b?T.line.getGranularityForZoomLevel(b.z):1,ce=(_,T)=>{T.x<0||T.x>=se||T.y<0||T.y>=se||function(e,l,c,d,p,f,m,_,g,y,b,T,P,S,I,C,z,L,F,B,O,j,G,U,q){const Z=e.addToLineVertexArray(l,c);let W,J,re,se,oe=0,le=0,ce=0,he=0,ue=-1,pe=-1;const fe={};let me=Nc("");if(e.allowVerticalPlacement&&d.vertical){const e=_.layout.get("text-rotate").evaluate(O,{},U)+90;re=new ld(g,l,y,b,T,d.vertical,P,S,I,e),m&&(se=new ld(g,l,y,b,T,m,z,L,I,e))}if(p){const c=_.layout.get("icon-rotate").evaluate(O,{}),d="none"!==_.layout.get("icon-text-fit"),f=t_(p,c,G,d),P=m?t_(m,c,G,d):void 0;J=new ld(g,l,y,b,T,p,z,L,!1,c),oe=4*f.length;const S=e.iconSizeData;let I=null;"source"===S.kind?(I=[Mp*_.layout.get("icon-size").evaluate(O,{})],I[0]>Ip&&Se(`${e.layerIds[0]}: Value for "icon-size" is >= 255. Reduce your "icon-size".`)):"composite"===S.kind&&(I=[Mp*j.compositeIconSizes[0].evaluate(O,{},U),Mp*j.compositeIconSizes[1].evaluate(O,{},U)],(I[0]>Ip||I[1]>Ip)&&Se(`${e.layerIds[0]}: Value for "icon-size" is >= 255. Reduce your "icon-size".`)),e.addSymbols(e.icon,f,I,B,F,O,s.az.none,l,Z.lineStartIndex,Z.lineLength,-1,U),ue=e.icon.placedSymbolArray.length-1,P&&(le=4*P.length,e.addSymbols(e.icon,P,I,B,F,O,s.az.vertical,l,Z.lineStartIndex,Z.lineLength,-1,U),pe=e.icon.placedSymbolArray.length-1)}const ge=Object.keys(d.horizontal);for(const c of ge){const p=d.horizontal[c];if(!W){me=Nc(p.text);const e=_.layout.get("text-rotate").evaluate(O,{},U);W=new ld(g,l,y,b,T,p,P,S,I,e)}const m=1===p.positionedLines.length;if(ce+=m_(e,l,p,f,_,I,O,C,Z,d.vertical?s.az.horizontal:s.az.horizontalOnly,m?ge:[c],fe,ue,j,U),m)break}d.vertical&&(he+=m_(e,l,d.vertical,f,_,I,O,C,Z,s.az.vertical,["vertical"],fe,pe,j,U));const ye=W?W.boxStartIndex:e.collisionBoxArray.length,xe=W?W.boxEndIndex:e.collisionBoxArray.length,ve=re?re.boxStartIndex:e.collisionBoxArray.length,be=re?re.boxEndIndex:e.collisionBoxArray.length,we=J?J.boxStartIndex:e.collisionBoxArray.length,Me=J?J.boxEndIndex:e.collisionBoxArray.length,Ee=se?se.boxStartIndex:e.collisionBoxArray.length,Ce=se?se.boxEndIndex:e.collisionBoxArray.length;let Ae=-1;const Ne=(e,s)=>e&&e.circleDiameter?Math.max(e.circleDiameter,s):s;Ae=Ne(W,Ae),Ae=Ne(re,Ae),Ae=Ne(J,Ae),Ae=Ne(se,Ae);const Ge=Ae>-1?1:0;Ge&&(Ae*=q/Vd),e.glyphOffsetArray.length>=fh.MAX_GLYPHS&&Se("Too many glyphs being rendered in a tile. See https://github.com/mapbox/mapbox-gl-js/issues/2907"),void 0!==O.sortKey&&e.addToSortKeyRanges(e.symbolInstances.length,O.sortKey);const Ue=d_(_,O,U),[qe,$e]=function(e,l){const c=e.length,d=null==l?void 0:l.values;if((null==d?void 0:d.length)>0)for(let l=0;l=0?fe.right:-1,fe.center>=0?fe.center:-1,fe.left>=0?fe.left:-1,fe.vertical||-1,ue,pe,me,ye,xe,ve,be,we,Me,Ee,Ce,y,ce,he,oe,le,Ge,0,P,Ae,qe,$e)}(e,T,_,c,d,p,oe,e.layers[0],e.collisionBoxArray,l.index,l.sourceLayerIndex,e.index,L,[j,j,j,j],q,g,B,G,Z,I,l,f,y,b,m)};if("line"===W)for(const s of Gm(l.geometry,0,0,se,se)){const l=Xu(s,le),p=Jm(l,O,U,c.vertical||C,d,24,F,e.overscaling,se);for(const s of p)C&&g_(e,C.text,J,s)||ce(l,s)}else if("line-center"===W){for(const e of l.geometry)if(e.length>1){const s=Xu(e,le),l=Qm(s,U,c.vertical||C,d,24,F);l&&ce(s,l)}}else if("Polygon"===l.type)for(const e of Sn(l.geometry,0)){const s=o_(e,16);ce(Xu(e[0],le,!0),new Hf(s.x,s.y,0))}else if("LineString"===l.type)for(const e of l.geometry){const s=Xu(e,le);ce(s,new Hf(s[0].x,s[0].y,0))}else if("Point"===l.type)for(const e of l.geometry)for(const s of e)ce([s],new Hf(s.x,s.y,0))}function m_(e,s,l,d,p,f,m,_,g,y,b,T,P,S,I){const C=function(e,s,l,d,p,f,m,_){const g=d.layout.get("text-rotate").evaluate(f,{})*Math.PI/180,y=[];for(const e of s.positionedLines)for(const d of e.positionedGlyphs){if(!d.rect)continue;const f=d.rect||{};let b=4,T=!0,P=1,S=0;const I=(p||_)&&d.vertical,C=d.metrics.advance*d.scale/2;if(_&&s.verticalizable&&(S=e.lineOffset/2-(d.imageName?-(Vd-d.metrics.width*d.scale)/2:(d.scale-1)*Vd)),d.imageName){const e=m[d.imageName];T=e.sdf,P=e.pixelRatio,b=1/P}const z=p?[d.x+C,d.y]:[0,0];let L=p?[0,0]:[d.x+C+l[0],d.y+l[1]-S],F=[0,0];I&&(F=L,L=[0,0]);const B=d.metrics.isDoubleResolution?2:1,O=(d.metrics.left-b)*d.scale-C+L[0],j=(-d.metrics.top-b)*d.scale+L[1],G=O+f.w/B*d.scale/P,U=j+f.h/B*d.scale/P,q=new c(O,j),Z=new c(G,j),W=new c(O,U),J=new c(G,U);if(I){const e=new c(-C,C- -17),s=-Math.PI/2,l=12-C,p=new c(22-l,-(d.imageName?l:0)),f=new c(...F);q._rotateAround(s,e)._add(p)._add(f),Z._rotateAround(s,e)._add(p)._add(f),W._rotateAround(s,e)._add(p)._add(f),J._rotateAround(s,e)._add(p)._add(f)}if(g){const e=Math.sin(g),s=Math.cos(g),l=[s,-e,e,s];q._matMult(l),Z._matMult(l),W._matMult(l),J._matMult(l)}const re=new c(0,0),se=new c(0,0);y.push({tl:q,tr:Z,bl:W,br:J,tex:f,writingMode:s.writingMode,glyphOffset:z,sectionIndex:d.sectionIndex,isSDF:T,pixelOffsetTL:re,pixelOffsetBR:se,minFontScaleX:0,minFontScaleY:0})}return y}(0,l,_,p,f,m,d,e.allowVerticalPlacement),z=e.textSizeData;let L=null;"source"===z.kind?(L=[Mp*p.layout.get("text-size").evaluate(m,{})],L[0]>Ip&&Se(`${e.layerIds[0]}: Value for "text-size" is >= 255. Reduce your "text-size".`)):"composite"===z.kind&&(L=[Mp*S.compositeTextSizes[0].evaluate(m,{},I),Mp*S.compositeTextSizes[1].evaluate(m,{},I)],(L[0]>Ip||L[1]>Ip)&&Se(`${e.layerIds[0]}: Value for "text-size" is >= 255. Reduce your "text-size".`)),e.addSymbols(e.text,C,L,_,f,m,y,s,g.lineStartIndex,g.lineLength,P,I);for(const s of b)T[s]=e.text.placedSymbolArray.length-1;return 4*C.length}function __(e){for(const s in e)return e[s];return null}function g_(e,s,l,c){const d=e.compareText;if(s in d){const e=d[s];for(let s=e.length-1;s>=0;s--)if(c.dist(e[s])>4;if(1!==c)throw new Error(`Got v${c} data when expected v1.`);const d=y_[15&l];if(!d)throw new Error("Unrecognized array type.");const[p]=new Uint16Array(e,2,1),[f]=new Uint32Array(e,4,1);return new Sd(f,p,d,e)}constructor(e,s=64,l=Float64Array,c){if(isNaN(e)||e<0)throw new Error(`Unpexpected numItems value: ${e}.`);this.numItems=+e,this.nodeSize=Math.min(Math.max(+s,2),65535),this.ArrayType=l,this.IndexArrayType=e<65536?Uint16Array:Uint32Array;const d=y_.indexOf(this.ArrayType),p=2*e*this.ArrayType.BYTES_PER_ELEMENT,f=e*this.IndexArrayType.BYTES_PER_ELEMENT,m=(8-f%8)%8;if(d<0)throw new Error(`Unexpected typed array class: ${l}.`);c&&c instanceof ArrayBuffer?(this.data=c,this.ids=new this.IndexArrayType(this.data,8,e),this.coords=new this.ArrayType(this.data,8+f+m,2*e),this._pos=2*e,this._finished=!0):(this.data=new ArrayBuffer(8+p+f+m),this.ids=new this.IndexArrayType(this.data,8,e),this.coords=new this.ArrayType(this.data,8+f+m,2*e),this._pos=0,this._finished=!1,new Uint8Array(this.data,0,2).set([219,16+d]),new Uint16Array(this.data,2,1)[0]=s,new Uint32Array(this.data,4,1)[0]=e)}add(e,s){const l=this._pos>>1;return this.ids[l]=l,this.coords[this._pos++]=e,this.coords[this._pos++]=s,l}finish(){const e=this._pos>>1;if(e!==this.numItems)throw new Error(`Added ${e} items when expected ${this.numItems}.`);return x_(this.ids,this.coords,this.nodeSize,0,this.numItems-1,0),this._finished=!0,this}range(e,s,l,c){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");const{ids:d,coords:p,nodeSize:f}=this,m=[0,d.length-1,0],_=[];for(;m.length;){const g=m.pop()||0,y=m.pop()||0,b=m.pop()||0;if(y-b<=f){for(let f=b;f<=y;f++){const m=p[2*f],g=p[2*f+1];m>=e&&m<=l&&g>=s&&g<=c&&_.push(d[f])}continue}const T=b+y>>1,P=p[2*T],S=p[2*T+1];P>=e&&P<=l&&S>=s&&S<=c&&_.push(d[T]),(0===g?e<=P:s<=S)&&(m.push(b),m.push(T-1),m.push(1-g)),(0===g?l>=P:c>=S)&&(m.push(T+1),m.push(y),m.push(1-g))}return _}within(e,s,l){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");const{ids:c,coords:d,nodeSize:p}=this,f=[0,c.length-1,0],m=[],_=l*l;for(;f.length;){const g=f.pop()||0,y=f.pop()||0,b=f.pop()||0;if(y-b<=p){for(let l=b;l<=y;l++)T_(d[2*l],d[2*l+1],e,s)<=_&&m.push(c[l]);continue}const T=b+y>>1,P=d[2*T],S=d[2*T+1];T_(P,S,e,s)<=_&&m.push(c[T]),(0===g?e-l<=P:s-l<=S)&&(f.push(b),f.push(T-1),f.push(1-g)),(0===g?e+l>=P:s+l>=S)&&(f.push(T+1),f.push(y),f.push(1-g))}return m}}function x_(e,s,l,c,d,p){if(d-c<=l)return;const f=c+d>>1;v_(e,s,f,c,d,p),x_(e,s,l,c,f-1,1-p),x_(e,s,l,f+1,d,1-p)}function v_(e,s,l,c,d,p){for(;d>c;){if(d-c>600){const f=d-c+1,m=l-c+1,_=Math.log(f),g=.5*Math.exp(2*_/3),y=.5*Math.sqrt(_*g*(f-g)/f)*(m-f/2<0?-1:1);v_(e,s,l,Math.max(c,Math.floor(l-m*g/f+y)),Math.min(d,Math.floor(l+(f-m)*g/f+y)),p)}const f=s[2*l+p];let m=c,_=d;for(b_(e,s,c,l),s[2*d+p]>f&&b_(e,s,c,d);m<_;){for(b_(e,s,m,_),m++,_--;s[2*m+p]f;)_--}s[2*c+p]===f?b_(e,s,c,_):(_++,b_(e,s,_,d)),_<=l&&(c=_+1),l<=_&&(d=_-1)}}function b_(e,s,l,c){w_(e,l,c),w_(s,2*l,2*c),w_(s,2*l+1,2*c+1)}function w_(e,s,l){const c=e[s];e[s]=e[l],e[l]=c}function T_(e,s,l,c){const d=e-l,p=s-c;return d*d+p*p}var P_;s.cH=void 0,(P_=s.cH||(s.cH={})).create="create",P_.load="load",P_.fullLoad="fullLoad";let S_=null,M_=[];const I_=1e3/60,E_="loadTime",C_="fullLoadTime",A_={mark(e){performance.mark(e)},frame(e){const s=e;null!=S_&&M_.push(s-S_),S_=s},clearMetrics(){S_=null,M_=[],performance.clearMeasures(E_),performance.clearMeasures(C_);for(const e in s.cH)performance.clearMarks(s.cH[e])},getPerformanceMetrics(){performance.measure(E_,s.cH.create,s.cH.load),performance.measure(C_,s.cH.create,s.cH.fullLoad);const e=performance.getEntriesByName(E_)[0].duration,l=performance.getEntriesByName(C_)[0].duration,c=M_.length,d=1/(M_.reduce(((e,s)=>e+s),0)/c/1e3),p=M_.filter((e=>e>I_)).reduce(((e,s)=>e+(s-I_)/I_),0);return{loadTime:e,fullLoadTime:l,fps:d,percentDroppedFrames:p/(c+p)*100,totalFrames:c}}};s.$=b,s.A=S,s.B=Hl,s.C=Ul,s.D=js,s.E=xt,s.F=function([e,s,l]){return s+=90,s*=Math.PI/180,l*=Math.PI/180,{x:e*Math.cos(s)*Math.sin(l),y:e*Math.sin(s)*Math.sin(l),z:e*Math.cos(l)}},s.G=Gr,s.H=Ps,s.I=qc,s.J=Zl,s.K=function(e){if(null==Ce){const s=e.navigator?e.navigator.userAgent:null;Ce=!!e.safari||!(!s||!(/\b(iPad|iPhone|iPod)\b/.test(s)||s.match("Safari")&&!s.match("Chrome")))}return Ce},s.L=class{constructor(e,s){this.target=e,this.mapId=s,this.resolveRejects={},this.tasks={},this.taskQueue=[],this.abortControllers={},this.messageHandlers={},this.invoker=new Sh((()=>this.process())),this.subscription=$e(this.target,"message",(e=>this.receive(e)),!1),this.globalScope=Ee(self)?e:window}registerMessageHandler(e,s){this.messageHandlers[e]=s}unregisterMessageHandler(e){delete this.messageHandlers[e]}sendAsync(e,s){return new Promise(((l,c)=>{const d=Math.round(1e18*Math.random()).toString(36).substring(0,10),p=s?$e(s.signal,"abort",(()=>{null==p||p.unsubscribe(),delete this.resolveRejects[d];const s={id:d,type:"",origin:location.origin,targetMapId:e.targetMapId,sourceMapId:this.mapId};this.target.postMessage(s)}),Zp):null;this.resolveRejects[d]={resolve:e=>{null==p||p.unsubscribe(),l(e)},reject:e=>{null==p||p.unsubscribe(),c(e)}};const f=[],m=Object.assign(Object.assign({},e),{id:d,sourceMapId:this.mapId,origin:location.origin,data:ec(e.data,f)});this.target.postMessage(m,{transfer:f})}))}receive(e){const s=e.data,l=s.id;if(!("file://"!==s.origin&&"file://"!==location.origin&&"resource://android"!==s.origin&&"resource://android"!==location.origin&&s.origin!==location.origin||s.targetMapId&&this.mapId!==s.targetMapId)){if(""===s.type){delete this.tasks[l];const e=this.abortControllers[l];return delete this.abortControllers[l],void(e&&e.abort())}if(Ee(self)||s.mustQueue)return this.tasks[l]=s,this.taskQueue.push(l),void this.invoker.trigger();this.processTask(l,s)}}process(){if(0===this.taskQueue.length)return;const e=this.taskQueue.shift(),s=this.tasks[e];delete this.tasks[e],this.taskQueue.length>0&&this.invoker.trigger(),s&&this.processTask(e,s)}processTask(e,s){return l(this,void 0,void 0,(function*(){if(""===s.type){const l=this.resolveRejects[e];if(delete this.resolveRejects[e],!l)return;return void(s.error?l.reject(rc(s.error)):l.resolve(rc(s.data)))}if(!this.messageHandlers[s.type])return void this.completeTask(e,new Error(`Could not find a registered handler for ${s.type}, map ID: ${this.mapId}, available handlers: ${Object.keys(this.messageHandlers).join(", ")}`));const l=rc(s.data),c=new AbortController;this.abortControllers[e]=c;try{const d=yield this.messageHandlers[s.type](s.sourceMapId,l,c);this.completeTask(e,null,d)}catch(l){this.completeTask(e,l)}}))}completeTask(e,s,l){const c=[];delete this.abortControllers[e];const d={id:e,type:"",sourceMapId:this.mapId,origin:location.origin,error:s?ec(s):null,data:ec(l,c)};this.target.postMessage(d,{transfer:c})}remove(){this.invoker.remove(),this.subscription.unsubscribe()}},s.M=ft,s.N=function(){var e=new S(16);return S!=Float32Array&&(e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[11]=0,e[12]=0,e[13]=0,e[14]=0),e[0]=1,e[5]=1,e[10]=1,e[15]=1,e},s.O=function(e,s,l){var c,d,p,f,m,_,g,y,b,T,P,S,I=l[0],C=l[1],z=l[2];return s===e?(e[12]=s[0]*I+s[4]*C+s[8]*z+s[12],e[13]=s[1]*I+s[5]*C+s[9]*z+s[13],e[14]=s[2]*I+s[6]*C+s[10]*z+s[14],e[15]=s[3]*I+s[7]*C+s[11]*z+s[15]):(d=s[1],p=s[2],f=s[3],m=s[4],_=s[5],g=s[6],y=s[7],b=s[8],T=s[9],P=s[10],S=s[11],e[0]=c=s[0],e[1]=d,e[2]=p,e[3]=f,e[4]=m,e[5]=_,e[6]=g,e[7]=y,e[8]=b,e[9]=T,e[10]=P,e[11]=S,e[12]=c*I+m*C+b*z+s[12],e[13]=d*I+_*C+T*z+s[13],e[14]=p*I+g*C+P*z+s[14],e[15]=f*I+y*C+S*z+s[15]),e},s.P=c,s.Q=function(e,s,l){var c=l[0],d=l[1],p=l[2];return e[0]=s[0]*c,e[1]=s[1]*c,e[2]=s[2]*c,e[3]=s[3]*c,e[4]=s[4]*d,e[5]=s[5]*d,e[6]=s[6]*d,e[7]=s[7]*d,e[8]=s[8]*p,e[9]=s[9]*p,e[10]=s[10]*p,e[11]=s[11]*p,e[12]=s[12],e[13]=s[13],e[14]=s[14],e[15]=s[15],e},s.R=Sl,s.S=function(e,s,l){var c=s[0],d=s[1],p=s[2],f=s[3],m=s[4],_=s[5],g=s[6],y=s[7],b=s[8],T=s[9],P=s[10],S=s[11],I=s[12],C=s[13],z=s[14],L=s[15],F=l[0],B=l[1],O=l[2],j=l[3];return e[0]=F*c+B*m+O*b+j*I,e[1]=F*d+B*_+O*T+j*C,e[2]=F*p+B*g+O*P+j*z,e[3]=F*f+B*y+O*S+j*L,e[4]=(F=l[4])*c+(B=l[5])*m+(O=l[6])*b+(j=l[7])*I,e[5]=F*d+B*_+O*T+j*C,e[6]=F*p+B*g+O*P+j*z,e[7]=F*f+B*y+O*S+j*L,e[8]=(F=l[8])*c+(B=l[9])*m+(O=l[10])*b+(j=l[11])*I,e[9]=F*d+B*_+O*T+j*C,e[10]=F*p+B*g+O*P+j*z,e[11]=F*f+B*y+O*S+j*L,e[12]=(F=l[12])*c+(B=l[13])*m+(O=l[14])*b+(j=l[15])*I,e[13]=F*d+B*_+O*T+j*C,e[14]=F*p+B*g+O*P+j*z,e[15]=F*f+B*y+O*S+j*L,e},s.T=zl,s.U=function(e,s){const l={};for(let c=0;c0||(null===(d=l.addOrUpdateProperties)||void 0===d?void 0:d.length)>0;if(!f&&!m)continue;p.push(s.geometry);const _=Object.assign({},s);if(e.set(l.id,_),f&&(p.push(l.newGeometry),_.geometry=l.newGeometry),m){if(_.properties=l.removeAllProperties?{}:Object.assign({},_.properties||{}),l.removeProperties)for(const e of l.removeProperties)delete _.properties[e];if(l.addOrUpdateProperties)for(const{key:e,value:s}of l.addOrUpdateProperties)_.properties[e]=s}}return p},s.a9=Vh,s.aA=function(e,{uSize:s,uSizeT:l},{lowerSize:c,upperSize:d}){return"source"===e.kind?c/Mp:"composite"===e.kind?Gr.number(c/Mp,d/Mp,l):s},s.aB=function(e,s){var l=s[0],c=s[1],d=s[2],p=s[3],f=s[4],m=s[5],_=s[6],g=s[7],y=s[8],b=s[9],T=s[10],P=s[11],S=s[12],I=s[13],C=s[14],z=s[15],L=l*m-c*f,F=l*_-d*f,B=l*g-p*f,O=c*_-d*m,j=c*g-p*m,G=d*g-p*_,U=y*I-b*S,q=y*C-T*S,Z=y*z-P*S,W=b*C-T*I,J=b*z-P*I,re=T*z-P*C,se=L*re-F*J+B*W+O*Z-j*q+G*U;return se?(e[0]=(m*re-_*J+g*W)*(se=1/se),e[1]=(d*J-c*re-p*W)*se,e[2]=(I*G-C*j+z*O)*se,e[3]=(T*j-b*G-P*O)*se,e[4]=(_*Z-f*re-g*q)*se,e[5]=(l*re-d*Z+p*q)*se,e[6]=(C*B-S*G-z*F)*se,e[7]=(y*G-T*B+P*F)*se,e[8]=(f*J-m*Z+g*U)*se,e[9]=(c*Z-l*J-p*U)*se,e[10]=(S*j-I*B+z*L)*se,e[11]=(b*B-y*j-P*L)*se,e[12]=(m*q-f*W-_*U)*se,e[13]=(l*W-c*q+d*U)*se,e[14]=(I*F-S*O-C*L)*se,e[15]=(y*O-b*F+T*L)*se,e):null},s.aC=J,s.aD=function(e){var s=e[0],l=e[1];return Math.sqrt(s*s+l*l)},s.aE=function(e){return e[0]=0,e[1]=0,e},s.aF=function(e,s,l){return e[0]=s[0]*l,e[1]=s[1]*l,e},s.aG=Fp,s.aH=q,s.aI=function(e,s,l,d){const p=s.y-e.y,f=s.x-e.x,m=d.y-l.y,_=d.x-l.x,g=m*f-_*p;if(0===g)return null;const y=(_*(e.y-l.y)-m*(e.x-l.x))/g;return new c(e.x+y*f,e.y+y*p)},s.aJ=Gm,s.aK=ih,s.aL=function(e){let s=1/0,l=1/0,c=-1/0,d=-1/0;for(const p of e)s=Math.min(s,p.x),l=Math.min(l,p.y),c=Math.max(c,p.x),d=Math.max(d,p.y);return[s,l,c,d]},s.aM=Vd,s.aN=oe,s.aO=function(e,s,l,c,d=!1){if(!l[0]&&!l[1])return[0,0];const p=d?"map"===c?-e.bearingInRadians:0:"viewport"===c?e.bearingInRadians:0;if(p){const e=Math.sin(p),s=Math.cos(p);l=[l[0]*s-l[1]*e,l[0]*e+l[1]*s]}return[d?l[0]:oe(s,l[0],e.zoom),d?l[1]:oe(s,l[1],e.zoom)]},s.aQ=Dp,s.aR=p_,s.aS=_p,s.aT=Sd,s.aU=Mc,s.aV=pu,s.aW=$a,s.aX=io,s.aY=to,s.aZ=Ye,s.a_=af,s.aa=jh,s.ab=25,s.ac=Lh,s.ad=e=>{const s=window.document.createElement("video");return s.muted=!0,new Promise((l=>{s.onloadstart=()=>{l(s)};for(const l of e){const e=window.document.createElement("source");vt(l)||(s.crossOrigin="Anonymous"),e.src=l,s.appendChild(e)}}))},s.ae=Dt,s.af=function(){return ye++},s.ag=Fa,s.ah=fh,s.ai=zm,s.aj=Co,s.ak=Jc,s.al=Xh,s.am=function(e){const s={};if(e.replace(/(?:^|(?:\s*\,\s*))([^\x00-\x20\(\)<>@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)(?:\=(?:([^\x00-\x20\(\)<>@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)|(?:\"((?:[^"\\]|\\.)*)\")))?/g,((e,l,c,d)=>{const p=c||d;return s[l]=!p||p.toLowerCase(),""})),s["max-age"]){const e=parseInt(s["max-age"],10);isNaN(e)?delete s["max-age"]:s["max-age"]=e}return s},s.an=fe,s.ao=85.051129,s.ap=He,s.aq=function(e){return Math.pow(2,e)},s.ar=C,s.as=rf,s.at=function(e){return Math.log(e)/Math.LN2},s.au=function(e){var s=e[0],l=e[1];return s*s+l*l},s.av=function(e){if(!e.length)return new Set;const s=Math.max(...e.map((e=>e.canonical.z)));let l=1/0,c=-1/0,d=1/0,p=-1/0;const f=[];for(const m of e){const{x:e,y:_,z:g}=m.canonical,y=Math.pow(2,s-g),b=e*y,T=_*y;f.push({id:m,x:b,y:T}),bc&&(c=b),Tp&&(p=T)}const m=new Set;for(const e of f)e.x!==l&&e.x!==c&&e.y!==d&&e.y!==p||m.add(e.id);return m},s.aw=function(e,s){const l=Math.abs(2*e.wrap)-+(e.wrap<0),c=Math.abs(2*s.wrap)-+(s.wrap<0);return e.overscaledZ-s.overscaledZ||c-l||s.canonical.y-e.canonical.y||s.canonical.x-e.canonical.x},s.ax=class{constructor(e,s){this.max=e,this.onRemove=s,this.reset()}reset(){for(const e in this.data)for(const s of this.data[e])s.timeout&&clearTimeout(s.timeout),this.onRemove(s.value);return this.data={},this.order=[],this}add(e,s,l){const c=e.wrapped().key;void 0===this.data[c]&&(this.data[c]=[]);const d={value:s,timeout:void 0};if(void 0!==l&&(d.timeout=setTimeout((()=>{this.remove(e,d)}),l)),this.data[c].push(d),this.order.push(c),this.order.length>this.max){const e=this._getAndRemoveByKey(this.order[0]);e&&this.onRemove(e)}return this}has(e){return e.wrapped().key in this.data}getAndRemove(e){return this.has(e)?this._getAndRemoveByKey(e.wrapped().key):null}_getAndRemoveByKey(e){const s=this.data[e].shift();return s.timeout&&clearTimeout(s.timeout),0===this.data[e].length&&delete this.data[e],this.order.splice(this.order.indexOf(e),1),s.value}getByKey(e){const s=this.data[e];return s?s[0].value:null}get(e){return this.has(e)?this.data[e.wrapped().key][0].value:null}remove(e,s){if(!this.has(e))return this;const l=e.wrapped().key,c=void 0===s?0:this.data[l].indexOf(s),d=this.data[l][c];return this.data[l].splice(c,1),d.timeout&&clearTimeout(d.timeout),0===this.data[l].length&&delete this.data[l],this.onRemove(d.value),this.order.splice(this.order.indexOf(l),1),this}setMaxSize(e){for(this.max=e;this.order.length>this.max;){const e=this._getAndRemoveByKey(this.order[0]);e&&this.onRemove(e)}return this}filter(e){const s=[];for(const l in this.data)for(const c of this.data[l])e(c.value)||s.push(c);for(const e of s)this.remove(e.value.tileID,e)}},s.ay=function(e,s){let l=0,c=0;if("constant"===e.kind)c=e.layoutSize;else if("source"!==e.kind){const{interpolationType:d,minZoom:p,maxZoom:f}=e,m=d?fe(fr.interpolationFactor(d,s,p,f),0,1):0;"camera"===e.kind?c=Gr.number(e.minSize,e.maxSize,m):l=m}return{uSizeT:l,uSize:c}},s.b=Ae,s.b$=Ao,s.b0=B,s.b1=function(e){var s=new S(3);return s[0]=e[0],s[1]=e[1],s[2]=e[2],s},s.b2=function(e,s,l){return e[0]=s[0]-l[0],e[1]=s[1]-l[1],e[2]=s[2]-l[2],e},s.b3=function(e,s){var l=s[0],c=s[1],d=s[2],p=l*l+c*c+d*d;return p>0&&(p=1/Math.sqrt(p)),e[0]=s[0]*p,e[1]=s[1]*p,e[2]=s[2]*p,e},s.b4=j,s.b5=function(e,s){return e[0]*s[0]+e[1]*s[1]+e[2]*s[2]},s.b6=function(e,s,l){return e[0]=s[0]*l[0],e[1]=s[1]*l[1],e[2]=s[2]*l[2],e[3]=s[3]*l[3],e},s.b7=L,s.b8=function(e,s,l){const c=s[0]*l[0]+s[1]*l[1]+s[2]*l[2];return 0===c?null:(-(e[0]*l[0]+e[1]*l[1]+e[2]*l[2])-l[3])/c},s.b9=U,s.bA=function(e,s,l,c){return e[0]=s[0]+l[0]*c,e[1]=s[1]+l[1]*c,e[2]=s[2]+l[2]*c,e},s.bB=W,s.bC=function(e,s,l){var c=l[0],d=l[1],p=l[2],f=l[3],m=s[0],_=s[1],g=s[2],y=d*g-p*_,b=p*m-c*g,T=c*_-d*m;return e[0]=m+f*(y+=y)+d*(T+=T)-p*(b+=b),e[1]=_+f*b+p*y-c*T,e[2]=g+f*T+c*b-d*y,e},s.bD=function(e,s,l){const c=function(e){var s=e[3],l=e[4],c=e[5],d=e[6],p=e[7],f=e[8];return e[0]*(f*l-c*p)+e[1]*(-f*s+c*d)+e[2]*(p*s-l*d)}([e[0],e[1],e[2],s[0],s[1],s[2],l[0],l[1],l[2]]);if(0===c)return null;const d=j([],[s[0],s[1],s[2]],[l[0],l[1],l[2]]),p=j([],[l[0],l[1],l[2]],[e[0],e[1],e[2]]),f=j([],[e[0],e[1],e[2]],[s[0],s[1],s[2]]),m=O([],d,-e[3]);return B(m,m,O([],p,-s[3])),B(m,m,O([],f,-l[3])),O(m,m,1/c),m},s.bE=$p,s.bF=function(){return new Float64Array(4)},s.bG=function(e,s,l,c){var d=[],p=[];return d[0]=s[0]-l[0],d[1]=s[1]-l[1],d[2]=s[2]-l[2],p[0]=d[0]*Math.cos(c)-d[1]*Math.sin(c),p[1]=d[0]*Math.sin(c)+d[1]*Math.cos(c),p[2]=d[2],e[0]=p[0]+l[0],e[1]=p[1]+l[1],e[2]=p[2]+l[2],e},s.bH=function(e,s,l,c){var d=[],p=[];return d[0]=s[0]-l[0],d[1]=s[1]-l[1],d[2]=s[2]-l[2],p[0]=d[0],p[1]=d[1]*Math.cos(c)-d[2]*Math.sin(c),p[2]=d[1]*Math.sin(c)+d[2]*Math.cos(c),e[0]=p[0]+l[0],e[1]=p[1]+l[1],e[2]=p[2]+l[2],e},s.bI=function(e,s,l,c){var d=[],p=[];return d[0]=s[0]-l[0],d[1]=s[1]-l[1],d[2]=s[2]-l[2],p[0]=d[2]*Math.sin(c)+d[0]*Math.cos(c),p[1]=d[1],p[2]=d[2]*Math.cos(c)-d[0]*Math.sin(c),e[0]=p[0]+l[0],e[1]=p[1]+l[1],e[2]=p[2]+l[2],e},s.bJ=function(e,s,l){var c=Math.sin(l),d=Math.cos(l),p=s[0],f=s[1],m=s[2],_=s[3],g=s[8],y=s[9],b=s[10],T=s[11];return s!==e&&(e[4]=s[4],e[5]=s[5],e[6]=s[6],e[7]=s[7],e[12]=s[12],e[13]=s[13],e[14]=s[14],e[15]=s[15]),e[0]=p*d-g*c,e[1]=f*d-y*c,e[2]=m*d-b*c,e[3]=_*d-T*c,e[8]=p*c+g*d,e[9]=f*c+y*d,e[10]=m*c+b*d,e[11]=_*c+T*d,e},s.bK=function(e,s){const l=le(e,360),c=le(s,360),d=c-l,p=c>l?d-360:d+360;return Math.abs(d)0?f:-f},s.bN=function(e,s){const l=le(e,2*Math.PI),c=le(s,2*Math.PI);return Math.min(Math.abs(l-c),Math.abs(l-c+2*Math.PI),Math.abs(l-c-2*Math.PI))},s.bO=function(){const e={},s=Tt.$version;for(const l in Tt.$root){const c=Tt.$root[l];if(c.required){let d=null;d="version"===l?s:"array"===c.type?[]:{},null!=d&&(e[l]=d)}}return e},s.bP=_t,s.bQ=xs,s.bR=function e(s,l){if(Array.isArray(s)){if(!Array.isArray(l)||s.length!==l.length)return!1;for(let c=0;c"raster"===e.type,s.bV=be,s.bW=function(e,s){if(!e)return[{command:"setStyle",args:[s]}];let l=[];try{if(!Lt(e.version,s.version))return[{command:"setStyle",args:[s]}];Lt(e.center,s.center)||l.push({command:"setCenter",args:[s.center]}),Lt(e.state,s.state)||l.push({command:"setGlobalState",args:[s.state]}),Lt(e.centerAltitude,s.centerAltitude)||l.push({command:"setCenterAltitude",args:[s.centerAltitude]}),Lt(e.zoom,s.zoom)||l.push({command:"setZoom",args:[s.zoom]}),Lt(e.bearing,s.bearing)||l.push({command:"setBearing",args:[s.bearing]}),Lt(e.pitch,s.pitch)||l.push({command:"setPitch",args:[s.pitch]}),Lt(e.roll,s.roll)||l.push({command:"setRoll",args:[s.roll]}),Lt(e.sprite,s.sprite)||l.push({command:"setSprite",args:[s.sprite]}),Lt(e.glyphs,s.glyphs)||l.push({command:"setGlyphs",args:[s.glyphs]}),Lt(e.transition,s.transition)||l.push({command:"setTransition",args:[s.transition]}),Lt(e.light,s.light)||l.push({command:"setLight",args:[s.light]}),Lt(e.terrain,s.terrain)||l.push({command:"setTerrain",args:[s.terrain]}),Lt(e.sky,s.sky)||l.push({command:"setSky",args:[s.sky]}),Lt(e.projection,s.projection)||l.push({command:"setProjection",args:[s.projection]});const c={},d=[];!function(e,s,l,c){let d;for(d in s=s||{},e=e||{})Object.prototype.hasOwnProperty.call(e,d)&&(Object.prototype.hasOwnProperty.call(s,d)||Gt(d,l,c));for(d in s)Object.prototype.hasOwnProperty.call(s,d)&&(Object.prototype.hasOwnProperty.call(e,d)?Lt(e[d],s[d])||("geojson"===e[d].type&&"geojson"===s[d].type&&Ht(e,s,d)?Ft(l,{command:"setGeoJSONSourceData",args:[d,s[d].data]}):Zt(d,s,l,c)):Ot(d,s,l))}(e.sources,s.sources,d,c);const p=[];e.layers&&e.layers.forEach((e=>{"source"in e&&c[e.source]?l.push({command:"removeLayer",args:[e.id]}):p.push(e)})),l=l.concat(d),function(e,s,l){s=s||[];const c=(e=e||[]).map(Kt),d=s.map(Kt),p=e.reduce(Jt,{}),f=s.reduce(Jt,{}),m=c.slice(),_=Object.create(null);let g,y,b,T,P;for(let e=0,s=0;eP?(d=Math.acos(p),f=Math.sin(d),m=Math.sin((1-c)*d)/f,_=Math.sin(c*d)/f):(m=1-c,_=c),e[0]=m*g+_*S,e[1]=m*y+_*I,e[2]=m*b+_*C,e[3]=m*T+_*z,e},s.bn=function(e){const s=new Float64Array(9);!function(e,s){var l=s[0],c=s[1],d=s[2],p=s[3],f=l+l,m=c+c,_=d+d,g=l*f,y=c*f,b=c*m,T=d*f,P=d*m,S=d*_,I=p*f,C=p*m,z=p*_;e[0]=1-b-S,e[3]=y-z,e[6]=T+C,e[1]=y+z,e[4]=1-g-S,e[7]=P-I,e[2]=T-C,e[5]=P+I,e[8]=1-g-b}(s,e);const l=Ye(-Math.asin(fe(s[2],-1,1)));let c,d;return Math.hypot(s[5],s[8])<.001?(c=0,d=-Ye(Math.atan2(s[3],s[4]))):(c=Ye(0===s[5]&&0===s[8]?0:Math.atan2(s[5],s[8])),d=Ye(0===s[1]&&0===s[0]?0:Math.atan2(s[1],s[0]))),{roll:c,pitch:l+90,bearing:d}},s.bo=function(e,s){return e.roll==s.roll&&e.pitch==s.pitch&&e.bearing==s.bearing},s.bp=Te,s.bq=_o,s.br=$u,s.bs=Wu,s.bt=hu,s.bu=ce,s.bv=he,s.bw=Re,s.bx=function(e,s,l,c,d){return ce(c,d,fe((e-s)/(l-s),0,1))},s.by=le,s.bz=function(){return new Float64Array(3)},s.c=ot,s.c$=function(s,c,d,p,f){return l(this||e,void 0,void 0,(function*(){if(T())try{return yield Ge(s,c,d,p,f)}catch(e){}return function(e,s,l,c,d){const p=e.width,f=e.height;Ue&&qe||(Ue=new OffscreenCanvas(p,f),qe=Ue.getContext("2d",{willReadFrequently:!0})),Ue.width=p,Ue.height=f,qe.drawImage(e,0,0,p,f);const m=qe.getImageData(s,l,c,d);return qe.clearRect(0,0,p,f),m.data}(s,c,d,p,f)}))},s.c0=class extends wo{constructor(e,s){super(e,s),this.current=$c}set(e){if(e[12]!==this.current[12]||e[0]!==this.current[0])return this.current=e,void this.gl.uniformMatrix4fv(this.location,!1,e);for(let s=1;s<16;s++)if(e[s]!==this.current[s]){this.current=e,this.gl.uniformMatrix4fv(this.location,!1,e);break}}},s.c1=So,s.c2=class extends wo{constructor(e,s){super(e,s),this.current=[0,0,0]}set(e){e[0]===this.current[0]&&e[1]===this.current[1]&&e[2]===this.current[2]||(this.current=e,this.gl.uniform3f(this.location,e[0],e[1],e[2]))}},s.c3=class extends wo{constructor(e,s){super(e,s),this.current=[0,0]}set(e){e[0]===this.current[0]&&e[1]===this.current[1]||(this.current=e,this.gl.uniform2f(this.location,e[0],e[1]))}},s.c4=I,s.c5=function(e,s){var l=Math.sin(s),c=Math.cos(s);return e[0]=c,e[1]=l,e[2]=0,e[3]=-l,e[4]=c,e[5]=0,e[6]=0,e[7]=0,e[8]=1,e},s.c6=function(e,s,l){var c=s[0],d=s[1],p=s[2];return e[0]=c*l[0]+d*l[3]+p*l[6],e[1]=c*l[1]+d*l[4]+p*l[7],e[2]=c*l[2]+d*l[5]+p*l[8],e},s.c7=function(e,s,l,c,d,p,f){var m=1/(s-l),_=1/(c-d),g=1/(p-f);return e[0]=-2*m,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=-2*_,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=2*g,e[11]=0,e[12]=(s+l)*m,e[13]=(d+c)*_,e[14]=(f+p)*g,e[15]=1,e},s.c8=class extends wo{constructor(e,s){super(e,s),this.current=new Array}set(e){if(e!=this.current){this.current=e;const s=new Float32Array(4*e.length);for(let l=0;l25||c<0||c>=1||l<0||l>=1)},s.cE=function(e,s){return e[0]=s[0],e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=s[1],e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=s[2],e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e},s.cF=class extends aa{},s.cG=A_,s.cI=ct,s.cJ=function(e,s){ot.REGISTERED_PROTOCOLS[e]=s},s.cK=function(e){delete ot.REGISTERED_PROTOCOLS[e]},s.cL=function(e,s){const l={};for(let c=0;ce*Vd))}let F=m?"center":c.get("text-justify").evaluate(d,{},e.canonical);const B="point"===c.get("symbol-placement")?c.get("text-max-width").evaluate(d,{},e.canonical)*Vd:1/0,O=()=>{e.bucket.allowVerticalPlacement&&lc(p)&&(S.vertical=mp(I,e.glyphMap,e.glyphPositions,e.imagePositions,y,B,f,C,"left",P,z,s.az.vertical,!0,T,b))};if(!m&&L){const l=new Set;if("auto"===F)for(let e=0;e=this.maxEntries){const e=this.map.keys().next().value;this.map.delete(e)}this.map.set(e,s)}clear(){this.map.clear()}},s.cX=Vu,s.cY=Tc,s.cZ=Ff,s.c_=class{constructor(e){this._marks={start:[e.url,"start"].join("#"),end:[e.url,"end"].join("#"),measure:e.url.toString()},performance.mark(this._marks.start)}finish(){performance.mark(this._marks.end);let e=performance.getEntriesByName(this._marks.measure);return 0===e.length&&(performance.measure(this._marks.measure,this._marks.start,this._marks.end),e=performance.getEntriesByName(this._marks.measure),performance.clearMarks(this._marks.start),performance.clearMarks(this._marks.end),performance.clearMeasures(this._marks.measure)),e}},s.ca=class extends xa{},s.cb=Bd,s.cc=class extends ba{},s.cd=tu,s.ce=function(e){return e<=1?1:Math.pow(2,Math.ceil(Math.log(e)/Math.LN2))},s.cf=eu,s.cg=function(e,s,l){var c=s[0],d=s[1],p=s[2],f=l[3]*c+l[7]*d+l[11]*p+l[15];return e[0]=(l[0]*c+l[4]*d+l[8]*p+l[12])/(f=f||1),e[1]=(l[1]*c+l[5]*d+l[9]*p+l[13])/f,e[2]=(l[2]*c+l[6]*d+l[10]*p+l[14])/f,e},s.ch=class extends oa{},s.ci=class extends Ta{},s.cj=function(e,s){return e[0]===s[0]&&e[1]===s[1]&&e[2]===s[2]&&e[3]===s[3]&&e[4]===s[4]&&e[5]===s[5]&&e[6]===s[6]&&e[7]===s[7]&&e[8]===s[8]&&e[9]===s[9]&&e[10]===s[10]&&e[11]===s[11]&&e[12]===s[12]&&e[13]===s[13]&&e[14]===s[14]&&e[15]===s[15]},s.ck=function(e,s){var l=e[0],c=e[1],d=e[2],p=e[3],f=e[4],m=e[5],_=e[6],g=e[7],y=e[8],b=e[9],T=e[10],S=e[11],I=e[12],C=e[13],z=e[14],L=e[15],F=s[0],B=s[1],O=s[2],j=s[3],G=s[4],U=s[5],q=s[6],Z=s[7],W=s[8],J=s[9],re=s[10],se=s[11],oe=s[12],le=s[13],ce=s[14],he=s[15];return Math.abs(l-F)<=P*Math.max(1,Math.abs(l),Math.abs(F))&&Math.abs(c-B)<=P*Math.max(1,Math.abs(c),Math.abs(B))&&Math.abs(d-O)<=P*Math.max(1,Math.abs(d),Math.abs(O))&&Math.abs(p-j)<=P*Math.max(1,Math.abs(p),Math.abs(j))&&Math.abs(f-G)<=P*Math.max(1,Math.abs(f),Math.abs(G))&&Math.abs(m-U)<=P*Math.max(1,Math.abs(m),Math.abs(U))&&Math.abs(_-q)<=P*Math.max(1,Math.abs(_),Math.abs(q))&&Math.abs(g-Z)<=P*Math.max(1,Math.abs(g),Math.abs(Z))&&Math.abs(y-W)<=P*Math.max(1,Math.abs(y),Math.abs(W))&&Math.abs(b-J)<=P*Math.max(1,Math.abs(b),Math.abs(J))&&Math.abs(T-re)<=P*Math.max(1,Math.abs(T),Math.abs(re))&&Math.abs(S-se)<=P*Math.max(1,Math.abs(S),Math.abs(se))&&Math.abs(I-oe)<=P*Math.max(1,Math.abs(I),Math.abs(oe))&&Math.abs(C-le)<=P*Math.max(1,Math.abs(C),Math.abs(le))&&Math.abs(z-ce)<=P*Math.max(1,Math.abs(z),Math.abs(ce))&&Math.abs(L-he)<=P*Math.max(1,Math.abs(L),Math.abs(he))},s.cl=function(e,s){return e[0]=s[0],e[1]=s[1],e[2]=s[2],e[3]=s[3],e[4]=s[4],e[5]=s[5],e[6]=s[6],e[7]=s[7],e[8]=s[8],e[9]=s[9],e[10]=s[10],e[11]=s[11],e[12]=s[12],e[13]=s[13],e[14]=s[14],e[15]=s[15],e},s.cm=e=>"symbol"===e.type,s.cn=e=>"circle"===e.type,s.co=e=>"heatmap"===e.type,s.cp=e=>"line"===e.type,s.cq=e=>"fill"===e.type,s.cr=e=>"fill-extrusion"===e.type,s.cs=e=>"hillshade"===e.type,s.ct=e=>"color-relief"===e.type,s.cu=e=>"background"===e.type,s.cv=e=>"custom"===e.type,s.cw=ue,s.cx=function(e,s,l){const c=re(s.x-l.x,s.y-l.y),d=re(e.x-l.x,e.y-l.y),p=Math.atan2(c[0]*d[1]-c[1]*d[0],function(e,s){return e[0]*s[0]+e[1]*s[1]}(c,d));return Ye(p)},s.cy=pe,s.cz=function(e,s){return tt[s]&&(e instanceof MouseEvent||e instanceof WheelEvent)},s.d=vt,s.d0=Pl,s.d1=d,s.d2=class{constructor(e,s){this.layers={[zm]:this},this.name=zm,this.version=s?s.version:1,this.extent=s?s.extent:4096,this.length=e.length,this.features=e}feature(e){return new Df(this.features[e],this.extent)}},s.d3=Vs,s.d4=yc,s.e=ge,s.f=e=>l(void 0,void 0,void 0,(function*(){if(0===e.byteLength)return createImageBitmap(new ImageData(1,1));const s=new Blob([new Uint8Array(e)],{type:"image/png"});try{return createImageBitmap(s)}catch(e){throw new Error(`Could not load image because of ${e.message}. Please make sure to use a supported image type such as PNG or JPEG. Note that SVGs are not supported.`)}})),s.g=at,s.h=e=>new Promise(((s,l)=>{const c=new Image;c.onload=()=>{s(c),URL.revokeObjectURL(c.src),c.onload=null,window.requestAnimationFrame((()=>{c.src=Ne}))},c.onerror=()=>l(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 d=new Blob([new Uint8Array(e)],{type:"image/png"});c.src=e.byteLength?URL.createObjectURL(d):Ne})),s.i=Ee,s.j=(e,s)=>yt(ge(e,{type:"json"}),s),s.k=gt,s.l=mt,s.m=yt,s.n=(e,s)=>yt(ge(e,{type:"arrayBuffer"}),s),s.o=function(e){return new Tc(e).readFields(hp,[])},s.p=pp,s.q=function(e){return/[\u02EA\u02EB\u1100-\u11FF\u2E80-\u2FDF\u3000-\u30FF\u3105-\u312F\u3131-\u318E\u31A0-\u4DBF\u4E00-\uA48C\uA490-\uA4C6\uA960-\uA97C\uAC00-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFE10-\uFE1F\uFE30-\uFE4F\uFF00-\uFFEF]|\uD81B[\uDFE0-\uDFFF]|[\uD81C-\uD822\uD840-\uD868\uD86A-\uD86D\uD86F-\uD872\uD874-\uD879\uD880-\uD883\uD885-\uD88C][\uDC00-\uDFFF]|\uD823[\uDC00-\uDCD5\uDCFF-\uDD1E\uDD80-\uDDF2]|\uD82B[\uDFF0-\uDFFF]|\uD82C[\uDC00-\uDEFB]|\uD83C[\uDE00-\uDEFF]|\uD869[\uDC00-\uDEDF\uDF00-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEAD\uDEB0-\uDFFF]|\uD87A[\uDC00-\uDFE0\uDFF0-\uDFFF]|\uD87B[\uDC00-\uDE5D]|\uD87E[\uDC00-\uDE1D]|\uD884[\uDC00-\uDF4A\uDF50-\uDFFF]|\uD88D[\uDC00-\uDC79]/gim.test(String.fromCodePoint(e))},s.r=_l,s.s=$e,s.t=Hs,s.u=Tt,s.v=Gl,s.w=Se,s.x=Os,s.y=ql,s.z=vc}));c("worker",["./shared"],(function(e){class t{constructor(e,s){this.keyCache={},e&&this.replace(e,s)}replace(e,s){this._layerConfigs={},this._layers={},this.update(e,[],s)}update(s,l,c){for(const l of s){this._layerConfigs[l.id]=l;const s=this._layers[l.id]=e.bT(l,c);s._featureFilter=e.aj(s.filter,c),this.keyCache[l.id]&&delete this.keyCache[l.id]}for(const e of l)delete this.keyCache[e],delete this._layerConfigs[e],delete this._layers[e];this.familiesBySource={};const d=e.cL(Object.values(this._layerConfigs),this.keyCache);for(const s of d){const l=s.map((e=>this._layers[e.id])),c=l[0];if(c.isHidden())continue;const d=c.source||"";let p=this.familiesBySource[d];p||(p=this.familiesBySource[d]={});const f=c.sourceLayer||e.ai;let m=p[f];m||(m=p[f]=[]),m.push(l)}}}class o{constructor(s){const l={},c=[];for(const e in s){const d=s[e],p=l[e]={};for(const e in d){const s=d[+e];if(!s||0===s.bitmap.width||0===s.bitmap.height)continue;const l={x:0,y:0,w:s.bitmap.width+2,h:s.bitmap.height+2};c.push(l),p[e]={rect:l,metrics:s.metrics}}}const{w:d,h:p}=e.p(c),f=new e.r({width:d||1,height:p||1});for(const c in s){const d=s[c];for(const s in d){const p=d[+s];if(!p||0===p.bitmap.width||0===p.bitmap.height)continue;const m=l[c][s].rect;e.r.copy(p.bitmap,f,{x:0,y:0},{x:m.x+1,y:m.y+1},p.bitmap)}}this.image=f,this.positions=l}}e.cM("GlyphAtlas",o);class i{constructor(s){this.tileID=new e.a2(s.tileID.overscaledZ,s.tileID.wrap,s.tileID.canonical.z,s.tileID.canonical.x,s.tileID.canonical.y),this.uid=s.uid,this.zoom=s.zoom,this.pixelRatio=s.pixelRatio,this.tileSize=s.tileSize,this.source=s.source,this.overscaling=this.tileID.overscaleFactor(),this.showCollisionBoxes=s.showCollisionBoxes,this.collectResourceTiming=!!s.collectResourceTiming,this.returnDependencies=!!s.returnDependencies,this.promoteId=s.promoteId,this.inFlightDependencies=[]}parse(l,c,d,p,f){return e._(this,void 0,void 0,(function*(){this.status="parsing",this.data=l,this.collisionBoxArray=new e.ag;const m=new e.cN(Object.keys(l.layers).sort()),_=new e.cO(this.tileID,this.promoteId);_.bucketLayerIDs=[];const g={},y={featureIndex:_,iconDependencies:{},patternDependencies:{},glyphDependencies:{},dashDependencies:{},availableImages:d,subdivisionGranularity:f},b=c.familiesBySource[this.source];for(const c in b){const p=l.layers[c];if(!p)continue;1===p.version&&e.w(`Vector tile source "${this.source}" layer "${c}" does not use vector tile spec v2 and therefore may have some rendering errors.`);const f=m.encode(c),T=[];for(let e=0;ee.id))))}}const T=e.bY(y.glyphDependencies,(e=>Object.keys(e).map(Number)));this.inFlightDependencies.forEach((e=>null==e?void 0:e.abort())),this.inFlightDependencies=[];let P=Promise.resolve({});if(Object.keys(T).length){const e=new AbortController;this.inFlightDependencies.push(e),P=p.sendAsync({type:"GG",data:{stacks:T,source:this.source,tileID:this.tileID,type:"glyphs"}},e)}const S=Object.keys(y.iconDependencies);let I=Promise.resolve({});if(S.length){const e=new AbortController;this.inFlightDependencies.push(e),I=p.sendAsync({type:"GI",data:{icons:S,source:this.source,tileID:this.tileID,type:"icons"}},e)}const C=Object.keys(y.patternDependencies);let z=Promise.resolve({});if(C.length){const e=new AbortController;this.inFlightDependencies.push(e),z=p.sendAsync({type:"GI",data:{icons:C,source:this.source,tileID:this.tileID,type:"patterns"}},e)}const L=y.dashDependencies;let F=Promise.resolve({});if(Object.keys(L).length){const e=new AbortController;this.inFlightDependencies.push(e),F=p.sendAsync({type:"GDA",data:{dashes:L}},e)}const[B,O,j,G]=yield Promise.all([P,I,z,F]),U=new o(B),q=new e.cP(O,j);for(const l in g){const c=g[l];c instanceof e.ah?(s(c.layers,this.zoom,d),e.cQ({bucket:c,glyphMap:B,glyphPositions:U.positions,imageMap:O,imagePositions:q.iconPositions,showCollisionBoxes:this.showCollisionBoxes,canonical:this.tileID.canonical,subdivisionGranularity:y.subdivisionGranularity})):c.hasDependencies&&(c instanceof e.cR||c instanceof e.cS||c instanceof e.cT)&&(s(c.layers,this.zoom,d),c.addFeatures(y,this.tileID.canonical,q.patternPositions,G))}return this.status="done",{buckets:Object.values(g).filter((e=>!e.isEmpty())),featureIndex:_,collisionBoxArray:this.collisionBoxArray,glyphAtlasImage:U.image,imageAtlas:q,dashPositions:G,glyphMap:this.returnDependencies?B:null,iconMap:this.returnDependencies?O:null,glyphPositions:this.returnDependencies?U.positions:null}}))}}function s(s,l,c){const d=new e.H(l);for(const e of s)e.recalculate(d,c)}class n{constructor(e,s,l,c,d){this.type=e,this.properties=l||{},this.extent=d,this.pointsArray=s,this.id=c}loadGeometry(){return this.pointsArray.map((s=>s.map((s=>new e.P(s.x,s.y)))))}}class r{constructor(e,s,l){this.version=2,this._myFeatures=e,this.name=s,this.length=e.length,this.extent=l}feature(e){return this._myFeatures[e]}}class a{constructor(){this.layers={}}addLayer(e){this.layers[e.name]=e}}function l(s){let l=e.cU(s);return 0===l.byteOffset&&l.byteLength===l.buffer.byteLength||(l=new Uint8Array(l)),{vectorTile:s,rawData:l.buffer}}function c(s,l,c){const{extent:d}=s,p=Math.pow(2,c.z-l.z),f=(c.x-l.x*p)*d,m=(c.y-l.y*p)*d,_=[];for(let l=0;l0&&y.addLayer(p)}const T=l(y);return this.overzoomedTileResultCache.set(_,T),T}reloadTile(s){return e._(this,void 0,void 0,(function*(){const l=s.uid;if(!this.loaded||!this.loaded[l])throw new Error("Should not be trying to reload a tile that was never loaded or has been removed");const c=this.loaded[l];if(c.showCollisionBoxes=s.showCollisionBoxes,"parsing"===c.status){const d=yield c.parse(c.vectorTile,this.layerIndex,this.availableImages,this.actor,s.subdivisionGranularity);let p;if(this.fetching[l]){const{rawTileData:c,cacheControl:f,resourceTiming:m}=this.fetching[l];delete this.fetching[l],p=e.e({rawTileData:c.slice(0),encoding:s.encoding},d,f,m)}else p=d;return p}if("done"===c.status&&c.vectorTile)return c.parse(c.vectorTile,this.layerIndex,this.availableImages,this.actor,s.subdivisionGranularity)}))}abortTile(s){return e._(this,void 0,void 0,(function*(){const e=this.loading,l=s.uid;e&&e[l]&&e[l].abort&&(e[l].abort.abort(),delete e[l])}))}removeTile(s){return e._(this,void 0,void 0,(function*(){this.loaded&&this.loaded[s.uid]&&delete this.loaded[s.uid]}))}}class u{constructor(){this.loaded={}}loadTile(s){return e._(this,void 0,void 0,(function*(){const{uid:l,encoding:c,rawImageData:d,redFactor:p,greenFactor:f,blueFactor:m,baseShift:_}=s,g=d.width+2,y=d.height+2,b=e.b(d)?new e.R({width:g,height:y},yield e.c$(d,-1,-1,g,y)):d,T=new e.d0(l,b,c,p,f,m,_);return this.loaded=this.loaded||{},this.loaded[l]=T,T}))}removeTile(e){const s=this.loaded,l=e.uid;s&&s[l]&&delete s[l]}}var d,p,f=function(){if(p)return d;function e(e,l){if(0!==e.length){s(e[0],l);for(var c=1;c=Math.abs(m)?l-_+m:m-_+l,l=_}l+c>=0!=!!s&&e.reverse()}return p=1,d=function s(l,c){var d,p=l&&l.type;if("FeatureCollection"===p)for(d=0;de},g=Math.fround||(y=new Float32Array(1),e=>(y[0]=+e,y[0]));var y;class x{constructor(e){this.options=Object.assign(Object.create(_),e),this.trees=new Array(this.options.maxZoom+1),this.stride=this.options.reduce?7:6,this.clusterProps=[]}load(e){const{log:s,minZoom:l,maxZoom:c}=this.options;s&&console.time("total time");const d=`prepare ${e.length} points`;s&&console.time(d),this.points=e;const p=[];for(let s=0;s=l;e--){const l=+Date.now();f=this.trees[e]=this._createTree(this._cluster(f,e)),s&&console.log("z%d: %d clusters in %dms",e,f.numItems,+Date.now()-l)}return s&&console.timeEnd("total time"),this}getClusters(e,s){let l=((e[0]+180)%360+360)%360-180;const c=Math.max(-90,Math.min(90,e[1]));let d=180===e[2]?180:((e[2]+180)%360+360)%360-180;const p=Math.max(-90,Math.min(90,e[3]));if(e[2]-e[0]>=360)l=-180,d=180;else if(l>d){const e=this.getClusters([l,c,180,p],s),f=this.getClusters([-180,c,d,p],s);return e.concat(f)}const f=this.trees[this._limitZoom(s)],m=f.range(P(l),S(p),P(d),S(c)),_=f.data,g=[];for(const e of m){const s=this.stride*e;g.push(_[s+5]>1?b(_,s,this.clusterProps):this.points[_[s+3]])}return g}getChildren(e){const s=this._getOriginId(e),l=this._getOriginZoom(e),c="No cluster with the specified id.",d=this.trees[l];if(!d)throw new Error(c);const p=d.data;if(s*this.stride>=p.length)throw new Error(c);const f=this.options.radius/(this.options.extent*Math.pow(2,l-1)),m=d.within(p[s*this.stride],p[s*this.stride+1],f),_=[];for(const s of m){const l=s*this.stride;p[l+4]===e&&_.push(p[l+5]>1?b(p,l,this.clusterProps):this.points[p[l+3]])}if(0===_.length)throw new Error(c);return _}getLeaves(e,s,l){const c=[];return this._appendLeaves(c,e,s=s||10,l=l||0,0),c}getTile(e,s,l){const c=this.trees[this._limitZoom(e)],d=Math.pow(2,e),{extent:p,radius:f}=this.options,m=f/p,_=(l-m)/d,g=(l+1+m)/d,y={features:[]};return this._addTileFeatures(c.range((s-m)/d,_,(s+1+m)/d,g),c.data,s,l,d,y),0===s&&this._addTileFeatures(c.range(1-m/d,_,1,g),c.data,d,l,d,y),s===d-1&&this._addTileFeatures(c.range(0,_,m/d,g),c.data,-1,l,d,y),y.features.length?y:null}getClusterExpansionZoom(e){let s=this._getOriginZoom(e)-1;for(;s<=this.options.maxZoom;){const l=this.getChildren(e);if(s++,1!==l.length)break;e=l[0].properties.cluster_id}return s}_appendLeaves(e,s,l,c,d){const p=this.getChildren(s);for(const s of p){const p=s.properties;if(p&&p.cluster?d+p.point_count<=c?d+=p.point_count:d=this._appendLeaves(e,p.cluster_id,l,c,d):d1;let _,g,y;if(m)_=T(s,e,this.clusterProps),g=s[e],y=s[e+1];else{const l=this.points[s[e+3]];_=l.properties;const[c,d]=l.geometry.coordinates;g=P(c),y=S(d)}const b={type:1,geometry:[[Math.round(this.options.extent*(g*d-l)),Math.round(this.options.extent*(y*d-c))]],tags:_};let I;I=m||this.options.generateId?s[e+3]:this.points[s[e+3]].id,void 0!==I&&(b.id=I),p.features.push(b)}}_limitZoom(e){return Math.max(this.options.minZoom,Math.min(Math.floor(+e),this.options.maxZoom+1))}_cluster(e,s){const{radius:l,extent:c,reduce:d,minPoints:p}=this.options,f=l/(c*Math.pow(2,s)),m=e.data,_=[],g=this.stride;for(let l=0;ls&&(P+=m[l+5])}if(P>T&&P>=p){let e,p=c*T,f=y*T,S=-1;const I=(l/g<<5)+(s+1)+this.points.length;for(const c of b){const _=c*g;if(m[_+2]<=s)continue;m[_+2]=s;const y=m[_+5];p+=m[_]*y,f+=m[_+1]*y,m[_+4]=I,d&&(e||(e=this._map(m,l,!0),S=this.clusterProps.length,this.clusterProps.push(e)),d(e,this._map(m,_)))}m[l+4]=I,_.push(p/P,f/P,1/0,I,-1,P),d&&_.push(S)}else{for(let e=0;e1)for(const e of b){const l=e*g;if(!(m[l+2]<=s)){m[l+2]=s;for(let e=0;e>5}_getOriginZoom(e){return(e-this.points.length)%32}_map(e,s,l){if(e[s+5]>1){const c=this.clusterProps[e[s+6]];return l?Object.assign({},c):c}const c=this.points[e[s+3]].properties,d=this.options.map(c);return l&&d===c?Object.assign({},d):d}}function b(e,s,l){return{type:"Feature",id:e[s+3],properties:T(e,s,l),geometry:{type:"Point",coordinates:[(c=e[s],360*(c-.5)),I(e[s+1])]}};var c}function T(e,s,l){const c=e[s+5],d=c>=1e4?`${Math.round(c/1e3)}k`:c>=1e3?Math.round(c/100)/10+"k":c,p=e[s+6],f=-1===p?{}:Object.assign({},l[p]);return Object.assign(f,{cluster:!0,cluster_id:e[s+3],point_count:c,point_count_abbreviated:d})}function P(e){return e/360+.5}function S(e){const s=Math.sin(e*Math.PI/180),l=.5-.25*Math.log((1+s)/(1-s))/Math.PI;return l<0?0:l>1?1:l}function I(e){const s=(180-360*e)*Math.PI/180;return 360*Math.atan(Math.exp(s))/Math.PI-90}function C(e,s,l,c){let d=c;const p=s+(l-s>>1);let f,m=l-s;const _=e[s],g=e[s+1],y=e[l],b=e[l+1];for(let c=s+3;cd)f=c,d=s;else if(s===d){const e=Math.abs(c-p);ec&&(f-s>3&&C(e,s,f,c),e[f+2]=d,l-f>3&&C(e,f,l,c))}function z(e,s,l,c,d,p){let f=d-l,m=p-c;if(0!==f||0!==m){const _=((e-l)*f+(s-c)*m)/(f*f+m*m);_>1?(l=d,c=p):_>0&&(l+=f*_,c+=m*_)}return f=e-l,m=s-c,f*f+m*m}function L(e,s,l,c){const d={id:null==e?null:e,type:s,geometry:l,tags:c,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0};if("Point"===s||"MultiPoint"===s||"LineString"===s)F(d,l);else if("Polygon"===s)F(d,l[0]);else if("MultiLineString"===s)for(const e of l)F(d,e);else if("MultiPolygon"===s)for(const e of l)F(d,e[0]);return d}function F(e,s){for(let l=0;l0&&(f+=c?(d*_-m*p)/2:Math.sqrt(Math.pow(m-d,2)+Math.pow(_-p,2))),d=m,p=_}const m=s.length-3;s[2]=1,C(s,0,m,l),s[m+2]=1,s.size=Math.abs(f),s.start=0,s.end=s.size}function G(e,s,l,c){for(let d=0;d1?1:l}function Z(e,s,l,c,d,p,f,m){if(c/=s,p>=(l/=s)&&f=c)return null;const _=[];for(const s of e){const e=s.geometry;let p=s.type;const f=0===d?s.minX:s.minY,g=0===d?s.maxX:s.maxY;if(f>=l&&g=c)continue;let y=[];if("Point"===p||"MultiPoint"===p)W(e,y,l,c,d);else if("LineString"===p)J(e,y,l,c,d,!1,m.lineMetrics);else if("MultiLineString"===p)se(e,y,l,c,d,!1);else if("Polygon"===p)se(e,y,l,c,d,!0);else if("MultiPolygon"===p)for(const s of e){const e=[];se(s,e,l,c,d,!0),e.length&&y.push(e)}if(y.length){if(m.lineMetrics&&"LineString"===p){for(const e of y)_.push(L(s.id,p,e,s.tags));continue}"LineString"!==p&&"MultiLineString"!==p||(1===y.length?(p="LineString",y=y[0]):p="MultiLineString"),"Point"!==p&&"MultiPoint"!==p||(p=3===y.length?"Point":"MultiPoint"),_.push(L(s.id,p,y,s.tags))}}return _.length?_:null}function W(e,s,l,c,d){for(let p=0;p=l&&f<=c&&oe(s,e[p],e[p+1],e[p+2])}}function J(e,s,l,c,d,p,f){let m=re(e);const _=0===d?le:ce;let g,y,b=e.start;for(let T=0;Tl&&(y=_(m,P,S,C,z,l),f&&(m.start=b+g*y)):L>c?F=l&&(y=_(m,P,S,C,z,l),B=!0),F>c&&L<=c&&(y=_(m,P,S,C,z,c),B=!0),!p&&B&&(f&&(m.end=b+g*y),s.push(m),m=re(e)),f&&(b+=g)}let T=e.length-3;const P=e[T],S=e[T+1],I=0===d?P:S;I>=l&&I<=c&&oe(m,P,S,e[T+2]),T=m.length-3,p&&T>=3&&(m[T]!==m[0]||m[T+1]!==m[1])&&oe(m,m[0],m[1],m[2]),m.length&&s.push(m)}function re(e){const s=[];return s.size=e.size,s.start=e.start,s.end=e.end,s}function se(e,s,l,c,d,p){for(const f of e)J(f,s,l,c,d,p,!1)}function oe(e,s,l,c){e.push(s,l,c)}function le(e,s,l,c,d,p){const f=(p-s)/(c-s);return oe(e,p,l+(d-l)*f,1),f}function ce(e,s,l,c,d,p){const f=(p-l)/(d-l);return oe(e,s+(c-s)*f,p,1),f}function he(e,s){const l=[];for(let c=0;c0&&s.size<(d?f:c))return void(l.numPoints+=s.length/3);const m=[];for(let e=0;ef)&&(l.numSimplified++,m.push(s[e],s[e+1])),l.numPoints++;d&&function(e,s){let l=0;for(let s=0,c=e.length,d=c-2;s0===s)for(let s=0,l=e.length;s24)throw new Error("maxZoom should be in the 0-24 range");if(s.promoteId&&s.generateId)throw new Error("promoteId and generateId cannot be used together.");let c=function(e,s){const l=[];if("FeatureCollection"===e.type)for(let c=0;c1&&console.time("creation"),T=this.tiles[b]=me(e,s,l,c,_),this.tileCoords.push({z:s,x:l,y:c}),g)){g>1&&(console.log("tile z%d-%d-%d (features: %d, points: %d, simplified: %d)",s,l,c,T.numFeatures,T.numPoints,T.numSimplified),console.timeEnd("creation"));const e=`z${s}`;this.stats[e]=(this.stats[e]||0)+1,this.total++}if(T.source=e,null==d){if(s===_.indexMaxZoom||T.numPoints<=_.indexMaxPoints)continue}else{if(s===_.maxZoom||s===d)continue;if(null!=d){const e=d-s;if(l!==p>>e||c!==f>>e)continue}}if(T.source=null,0===e.length)continue;g>1&&console.time("clipping");const P=.5*_.buffer/_.extent,S=.5-P,I=.5+P,C=1+P;let z=null,L=null,F=null,B=null,O=Z(e,y,l-P,l+I,0,T.minX,T.maxX,_),j=Z(e,y,l+S,l+C,0,T.minX,T.maxX,_);e=null,O&&(z=Z(O,y,c-P,c+I,1,T.minY,T.maxY,_),L=Z(O,y,c+S,c+C,1,T.minY,T.maxY,_),O=null),j&&(F=Z(j,y,c-P,c+I,1,T.minY,T.maxY,_),B=Z(j,y,c+S,c+C,1,T.minY,T.maxY,_),j=null),g>1&&console.timeEnd("clipping"),m.push(z||[],s+1,2*l,2*c),m.push(L||[],s+1,2*l,2*c+1),m.push(F||[],s+1,2*l+1,2*c),m.push(B||[],s+1,2*l+1,2*c+1)}}getTile(e,s,l){e=+e,s=+s,l=+l;const c=this.options,{extent:d,debug:p}=c;if(e<0||e>24)return null;const f=1<1&&console.log("drilling down to z%d-%d-%d",e,s,l);let _,g=e,y=s,b=l;for(;!_&&g>0;)g--,y>>=1,b>>=1,_=this.tiles[ve(g,y,b)];return _&&_.source?(p>1&&(console.log("found parent tile z%d-%d-%d",g,y,b),console.time("drilling down")),this.splitTile(_.source,g,y,b,e,s,l),p>1&&console.timeEnd("drilling down"),this.tiles[m]?pe(this.tiles[m],d):null):null}}function ve(e,s,l){return 32*((1<`${e.key}: ${e.message}`)).join(", "));const d=s.features.filter((e=>c.value.evaluate({zoom:0},e)));return this._toFeatureCollection(d)}_toFeatureCollection(e){return{type:"FeatureCollection",features:e}}removeSource(s){return e._(this,void 0,void 0,(function*(){this._pendingRequest&&this._pendingRequest.abort()}))}getClusterExpansionZoom(e){return this._geoJSONIndex.getClusterExpansionZoom(e.clusterId)}getClusterChildren(e){return this._geoJSONIndex.getChildren(e.clusterId)}getClusterLeaves(e){return this._geoJSONIndex.getLeaves(e.clusterId,e.limit,e.offset)}}function be(s,l){return l.cluster?new x(function({superclusterOptions:s,clusterProperties:l}){if(!l||!s)return s;const c={},d={},p={accumulated:null,zoom:0},f={properties:null},m=Object.keys(l);for(const s of m){const[p,f]=l[s],m=e.d3(f),_=e.d3("string"==typeof p?[p,["accumulated"],["get",s]]:p);c[s]=m.value,d[s]=_.value}return s.map=e=>{f.properties=e;const s={};for(const e of m)s[e]=c[e].evaluate(p,f);return s},s.reduce=(e,s)=>{f.properties=s;for(const s of m)p.accumulated=e[s],e[s]=d[s].evaluate(p,f)},s}(l)).load(s.features):function(e,s){return new V(e,s)}(s,l.geojsonVtOptions)}class te{constructor(s){this.self=s,this.actor=new e.L(s),this.layerIndexes={},this.availableImages={},this.workerSources={},this.demWorkerSources={},this.externalWorkerSourceTypes={},this.globalStates=new Map,this.self.registerWorkerSource=(e,s)=>{if(this.externalWorkerSourceTypes[e])throw new Error(`Worker source with name "${e}" already registered.`);this.externalWorkerSourceTypes[e]=s},this.self.addProtocol=e.cJ,this.self.removeProtocol=e.cK,this.self.registerRTLTextPlugin=s=>{e.d4.setMethods(s)},this.actor.registerMessageHandler("LDT",((e,s)=>this._getDEMWorkerSource(e,s.source).loadTile(s))),this.actor.registerMessageHandler("RDT",((s,l)=>e._(this,void 0,void 0,(function*(){this._getDEMWorkerSource(s,l.source).removeTile(l)})))),this.actor.registerMessageHandler("GCEZ",((s,l)=>e._(this,void 0,void 0,(function*(){return this._getWorkerSource(s,l.type,l.source).getClusterExpansionZoom(l)})))),this.actor.registerMessageHandler("GCC",((s,l)=>e._(this,void 0,void 0,(function*(){return this._getWorkerSource(s,l.type,l.source).getClusterChildren(l)})))),this.actor.registerMessageHandler("GCL",((s,l)=>e._(this,void 0,void 0,(function*(){return this._getWorkerSource(s,l.type,l.source).getClusterLeaves(l)})))),this.actor.registerMessageHandler("LD",((e,s)=>this._getWorkerSource(e,s.type,s.source).loadData(s))),this.actor.registerMessageHandler("GD",((e,s)=>this._getWorkerSource(e,s.type,s.source).getData())),this.actor.registerMessageHandler("LT",((e,s)=>this._getWorkerSource(e,s.type,s.source).loadTile(s))),this.actor.registerMessageHandler("RT",((e,s)=>this._getWorkerSource(e,s.type,s.source).reloadTile(s))),this.actor.registerMessageHandler("AT",((e,s)=>this._getWorkerSource(e,s.type,s.source).abortTile(s))),this.actor.registerMessageHandler("RMT",((e,s)=>this._getWorkerSource(e,s.type,s.source).removeTile(s))),this.actor.registerMessageHandler("RS",((s,l)=>e._(this,void 0,void 0,(function*(){if(!this.workerSources[s]||!this.workerSources[s][l.type]||!this.workerSources[s][l.type][l.source])return;const e=this.workerSources[s][l.type][l.source];delete this.workerSources[s][l.type][l.source],void 0!==e.removeSource&&e.removeSource(l)})))),this.actor.registerMessageHandler("RM",(s=>e._(this,void 0,void 0,(function*(){delete this.layerIndexes[s],delete this.availableImages[s],delete this.workerSources[s],delete this.demWorkerSources[s],this.globalStates.delete(s)})))),this.actor.registerMessageHandler("SR",((s,l)=>e._(this,void 0,void 0,(function*(){this.referrer=l})))),this.actor.registerMessageHandler("SRPS",((e,s)=>this._syncRTLPluginState(e,s))),this.actor.registerMessageHandler("IS",((s,l)=>e._(this,void 0,void 0,(function*(){this.self.importScripts(l)})))),this.actor.registerMessageHandler("SI",((e,s)=>this._setImages(e,s))),this.actor.registerMessageHandler("UL",((s,l)=>e._(this,void 0,void 0,(function*(){this._getLayerIndex(s).update(l.layers,l.removedIds,this._getGlobalState(s))})))),this.actor.registerMessageHandler("UGS",((s,l)=>e._(this,void 0,void 0,(function*(){const e=this._getGlobalState(s);for(const s in l)e[s]=l[s]})))),this.actor.registerMessageHandler("SL",((s,l)=>e._(this,void 0,void 0,(function*(){this._getLayerIndex(s).replace(l,this._getGlobalState(s))}))))}_getGlobalState(e){let s=this.globalStates.get(e);return s||(s={},this.globalStates.set(e,s)),s}_setImages(s,l){return e._(this,void 0,void 0,(function*(){this.availableImages[s]=l;for(const e in this.workerSources[s]){const c=this.workerSources[s][e];for(const e in c)c[e].availableImages=l}}))}_syncRTLPluginState(s,l){return e._(this,void 0,void 0,(function*(){return yield e.d4.syncState(l,this.self.importScripts)}))}_getAvailableImages(e){let s=this.availableImages[e];return s||(s=[]),s}_getLayerIndex(e){let s=this.layerIndexes[e];return s||(s=this.layerIndexes[e]=new t),s}_getWorkerSource(e,s,l){if(this.workerSources[e]||(this.workerSources[e]={}),this.workerSources[e][s]||(this.workerSources[e][s]={}),!this.workerSources[e][s][l]){const c={sendAsync:(s,l)=>(s.targetMapId=e,this.actor.sendAsync(s,l))};switch(s){case"vector":this.workerSources[e][s][l]=new h(c,this._getLayerIndex(e),this._getAvailableImages(e));break;case"geojson":this.workerSources[e][s][l]=new Q(c,this._getLayerIndex(e),this._getAvailableImages(e));break;default:this.workerSources[e][s][l]=new this.externalWorkerSourceTypes[s](c,this._getLayerIndex(e),this._getAvailableImages(e))}}return this.workerSources[e][s][l]}_getDEMWorkerSource(e,s){return this.demWorkerSources[e]||(this.demWorkerSources[e]={}),this.demWorkerSources[e][s]||(this.demWorkerSources[e][s]=new u),this.demWorkerSources[e][s]}}return e.i(self)&&(self.worker=new te(self)),te}));c("index",["exports","./shared"],(function(s,l){var c="5.15.0";function d(){var e=new l.A(4);return l.A!=Float32Array&&(e[1]=0,e[2]=0),e[0]=1,e[3]=1,e}let p,f,m;const _={frame(e,s,c){const d=requestAnimationFrame((e=>{p(),s(e)})),{unsubscribe:p}=l.s(e.signal,"abort",(()=>{p(),cancelAnimationFrame(d),c(new l.a(e.signal.reason))}),!1)},frameAsync(e){return new Promise(((s,l)=>{this.frame(e,s,l)}))},getImageData(e,s=0){return this.getImageCanvasContext(e).getImageData(-s,-s,e.width+2*s,e.height+2*s)},getImageCanvasContext(e){const s=window.document.createElement("canvas"),l=s.getContext("2d",{willReadFrequently:!0});if(!l)throw new Error("failed to create canvas 2d context");return s.width=e.width,s.height=e.height,l.drawImage(e,0,0,e.width,e.height),l},resolveURL:e=>(p||(p=document.createElement("a")),p.href=e,p.href),hardwareConcurrency:"undefined"!=typeof navigator&&navigator.hardwareConcurrency||4,get prefersReducedMotion(){return void 0!==m?m:!!matchMedia&&(null==f&&(f=matchMedia("(prefers-reduced-motion: reduce)")),f.matches)},set prefersReducedMotion(e){m=e}},g=new class{constructor(){this._realTime="undefined"!=typeof performance&&performance&&performance.now?performance.now.bind(performance):Date.now.bind(Date),this._frozenAt=null}getCurrentTime(){return null!==this._frozenAt?this._frozenAt:this._realTime()}setNow(e){this._frozenAt=e}restoreNow(){this._frozenAt=null}isFrozen(){return null!==this._frozenAt}};function y(){return g.getCurrentTime()}class h{static testProp(e){if(!h.docStyle)return e[0];for(let s=0;s{window.removeEventListener("click",h.suppressClickInternal,!0)}),0)}static getScale(e){const s=e.getBoundingClientRect();return{x:s.width/e.offsetWidth||1,y:s.height/e.offsetHeight||1,boundingClientRect:s}}static getPoint(e,s,c){const d=s.boundingClientRect;return new l.P((c.clientX-d.left)/s.x-e.clientLeft,(c.clientY-d.top)/s.y-e.clientTop)}static mousePos(e,s){const l=h.getScale(e);return h.getPoint(e,l,s)}static touchPos(e,s){const l=[],c=h.getScale(e);for(let d=0;d{T&&C(T),T=null,I=!0},P.onerror=()=>{S=!0,T=null},P.src="data:image/webp;base64,UklGRh4AAABXRUJQVlA4TBEAAAAvAQAAAAfQ//73v/+BiOh/AAA="),function(s){let c,d,p,f;s.resetRequestQueue=()=>{c=[],d=0,p=0,f={}},s.addThrottleControl=e=>{const s=p++;return f[s]=e,s},s.removeThrottleControl=e=>{delete f[e],_()},s.getImage=(e,s,d=!0)=>new Promise(((p,f)=>{b.supported&&(e.headers||(e.headers={}),e.headers.accept="image/webp,*/*"),l.e(e,{type:"image"}),c.push({abortController:s,requestParameters:e,supportImageRefresh:d,state:"queued",onError:e=>{f(e)},onSuccess:e=>{p(e)}}),_()}));const m=s=>l._(this||e,void 0,void 0,(function*(){s.state="running";const{requestParameters:e,supportImageRefresh:c,onError:p,onSuccess:f,abortController:m}=s,y=!1===c&&!l.i(self)&&!l.g(e.url)&&(!e.headers||Object.keys(e.headers).reduce(((e,s)=>e&&"accept"===s),!0));d++;const b=y?g(e,m):l.m(e,m);try{const e=yield b;delete s.abortController,s.state="completed",e.data instanceof HTMLImageElement||l.b(e.data)?f(e):e.data&&f({data:yield(T=e.data,"function"==typeof createImageBitmap?l.f(T):l.h(T)),cacheControl:e.cacheControl,expires:e.expires})}catch(e){delete s.abortController,p(e)}finally{d--,_()}var T})),_=()=>{const e=(()=>{for(const e of Object.keys(f))if(f[e]())return!0;return!1})()?l.c.MAX_PARALLEL_IMAGE_REQUESTS_PER_FRAME:l.c.MAX_PARALLEL_IMAGE_REQUESTS;for(let s=d;s0;s++){const e=c.shift();e.abortController.signal.aborted?s--:m(e)}},g=(e,s)=>new Promise(((c,d)=>{const p=new Image,f=e.url,m=e.credentials;m&&"include"===m?p.crossOrigin="use-credentials":(m&&"same-origin"===m||!l.d(f))&&(p.crossOrigin="anonymous"),s.signal.addEventListener("abort",(()=>{p.src="",d(new l.a(s.signal.reason))})),p.fetchPriority="high",p.onload=()=>{p.onerror=p.onload=null,c({data:p})},p.onerror=()=>{p.onerror=p.onload=null,s.signal.aborted||d(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."))},p.src=f}))}(z||(z={})),z.resetRequestQueue();class v{constructor(e){this._transformRequestFn=null!=e?e:null}transformRequest(e,s){return this._transformRequestFn&&this._transformRequestFn(e,s)||{url:e}}setTransformRequest(e){this._transformRequestFn=e}}function L(e){const s=[];if("string"==typeof e)s.push({id:"default",url:e});else if(e&&e.length>0){const l=[];for(const{id:c,url:d}of e){const e=`${c}${d}`;-1===l.indexOf(e)&&(l.push(e),s.push({id:c,url:d}))}}return s}function F(e,s,l){try{const c=new URL(e);return c.pathname+=`${s}${l}`,c.toString()}catch(s){throw new Error(`Invalid sprite URL "${e}", must be absolute. Modify style specification directly or use TransformStyleFunction to correct the issue dynamically`)}}function B(e){const{userImage:s}=e;return!!(s&&s.render&&s.render())&&(e.data.replace(new Uint8Array(s.data.buffer)),!0)}class w extends l.E{constructor(){super(),this.images={},this.updatedImages={},this.callbackDispatchedThisFrame={},this.loaded=!1,this.requestors=[],this.patterns={},this.atlasImage=new l.R({width:1,height:1}),this.dirty=!0}destroy(){this.atlasTexture&&(this.atlasTexture.destroy(),this.atlasTexture=null);for(const e of Object.keys(this.images))this.removeImage(e);this.patterns={},this.atlasImage=new l.R({width:1,height:1}),this.dirty=!0}isLoaded(){return this.loaded}setLoaded(e){if(this.loaded!==e&&(this.loaded=e,e)){for(const{ids:e,promiseResolve:s}of this.requestors)s(this._getImagesForIds(e));this.requestors=[]}}getImage(e){const s=this.images[e];if(s&&!s.data&&s.spriteData){const e=s.spriteData;s.data=new l.R({width:e.width,height:e.height},e.context.getImageData(e.x,e.y,e.width,e.height).data),s.spriteData=null}return s}addImage(e,s){if(this.images[e])throw new Error(`Image id ${e} already exist, use updateImage instead`);this._validate(e,s)&&(this.images[e]=s)}_validate(e,s){let c=!0;const d=s.data||s.spriteData;return this._validateStretch(s.stretchX,d&&d.width)||(this.fire(new l.k(new Error(`Image "${e}" has invalid "stretchX" value`))),c=!1),this._validateStretch(s.stretchY,d&&d.height)||(this.fire(new l.k(new Error(`Image "${e}" has invalid "stretchY" value`))),c=!1),this._validateContent(s.content,s)||(this.fire(new l.k(new Error(`Image "${e}" has invalid "content" value`))),c=!1),c}_validateStretch(e,s){if(!e)return!0;let l=0;for(const c of e){if(c[0]{let c=!0;if(!this.isLoaded())for(const s of e)this.images[s]||(c=!1);this.isLoaded()||c?s(this._getImagesForIds(e)):this.requestors.push({ids:e,promiseResolve:s})}))}_getImagesForIds(e){const s={};for(const c of e){let e=this.getImage(c);e||(this.fire(new l.l("styleimagemissing",{id:c})),e=this.getImage(c)),e?s[c]={data:e.data.clone(),pixelRatio:e.pixelRatio,sdf:e.sdf,version:e.version,stretchX:e.stretchX,stretchY:e.stretchY,content:e.content,textFitWidth:e.textFitWidth,textFitHeight:e.textFitHeight,hasRenderCallback:Boolean(e.userImage&&e.userImage.render)}:l.w(`Image "${c}" could not be loaded. Please make sure you have added the image with map.addImage() or a "sprite" property in your style. You can provide missing images by listening for the "styleimagemissing" map event.`)}return s}getPixelSize(){const{width:e,height:s}=this.atlasImage;return{width:e,height:s}}getPattern(e){const s=this.patterns[e],c=this.getImage(e);if(!c)return null;if(s&&s.position.version===c.version)return s.position;if(s)s.position.version=c.version;else{const s={w:c.data.width+2,h:c.data.height+2,x:0,y:0},d=new l.I(s,c);this.patterns[e]={bin:s,position:d}}return this._updatePatternAtlas(),this.patterns[e].position}bind(e){const s=e.gl;this.atlasTexture?this.dirty&&(this.atlasTexture.update(this.atlasImage),this.dirty=!1):this.atlasTexture=new l.T(e,this.atlasImage,s.RGBA),this.atlasTexture.bind(s.LINEAR,s.CLAMP_TO_EDGE)}_updatePatternAtlas(){const e=[];for(const s in this.patterns)e.push(this.patterns[s].bin);const{w:s,h:c}=l.p(e),d=this.atlasImage;d.resize({width:s||1,height:c||1});for(const e in this.patterns){const{bin:s}=this.patterns[e],c=s.x+1,p=s.y+1,f=this.getImage(e).data,m=f.width,_=f.height;l.R.copy(f,d,{x:0,y:0},{x:c,y:p},{width:m,height:_}),l.R.copy(f,d,{x:0,y:_-1},{x:c,y:p-1},{width:m,height:1}),l.R.copy(f,d,{x:0,y:0},{x:c,y:p+_},{width:m,height:1}),l.R.copy(f,d,{x:m-1,y:0},{x:c-1,y:p},{width:1,height:_}),l.R.copy(f,d,{x:0,y:0},{x:c+m,y:p},{width:1,height:_})}this.dirty=!0}beginFrame(){this.callbackDispatchedThisFrame={}}dispatchRenderCallbacks(e){for(const s of e){if(this.callbackDispatchedThisFrame[s])continue;this.callbackDispatchedThisFrame[s]=!0;const e=this.getImage(s);e||l.w(`Image with ID: "${s}" was not found`),B(e)&&this.updateImage(s,e)}}cloneImages(){const e={};for(const s in this.images){const l=this.images[s];e[s]=Object.assign(Object.assign({},l),{data:l.data?l.data.clone():null})}return e}}const O=1e20;function j(e,s,l,c,d,p,f,m,_){for(let g=s;g-1);_++,p[_]=m,f[_]=g,f[_+1]=O}for(let m=0,_=0;m/[-\w]+/.test(e)?e:`'${CSS.escape(e)}'`)).join(",");return new M.TinySDF({fontSize:48,buffer:6,radius:16,cutoff:.25,fontFamily:l,fontWeight:this._fontWeight(s[0]),fontStyle:this._fontStyle(s[0]),lang:this.lang})}_fontStyle(e){return/italic/i.test(e)?"italic":/oblique/i.test(e)?"oblique":"normal"}_fontWeight(e){const s={thin:100,hairline:100,"extra light":200,"ultra light":200,light:300,normal:400,regular:400,medium:500,semibold:600,demibold:600,bold:700,"extra bold":800,"ultra bold":800,black:900,heavy:900,"extra black":950,"ultra black":950};let l;for(const[c,d]of Object.entries(s))new RegExp(`\\b${c}\\b`,"i").test(e)&&(l=`${d}`);return l}destroy(){for(const e in this.entries){const s=this.entries[e];s.tinySDF&&(s.tinySDF=null),s.ideographTinySDF&&(s.ideographTinySDF=null),s.glyphs={},s.requests={},s.ranges={}}this.entries={}}}M.loadGlyphRange=function(s,c,d,p){return l._(this||e,void 0,void 0,(function*(){const e=256*c,f=e+255,m=p.transformRequest(d.replace("{fontstack}",s).replace("{range}",`${e}-${f}`),"Glyphs"),_=yield l.n(m,new AbortController);if(!_||!_.data)throw new Error(`Could not load glyph range. range: ${c}, ${e}-${f}`);const g={};for(const e of l.o(_.data))g[e.id]=e;return g}))},M.TinySDF=class{constructor({fontSize:e=24,buffer:s=3,radius:l=8,cutoff:c=.25,fontFamily:d="sans-serif",fontWeight:p="normal",fontStyle:f="normal",lang:m=null}={}){this.buffer=s,this.cutoff=c,this.radius=l,this.lang=m;const _=this.size=e+4*s,g=this._createCanvas(_),y=this.ctx=g.getContext("2d",{willReadFrequently:!0});y.font=`${f} ${p} ${e}px ${d}`,y.textBaseline="alphabetic",y.textAlign="left",y.fillStyle="black",this.gridOuter=new Float64Array(_*_),this.gridInner=new Float64Array(_*_),this.f=new Float64Array(_),this.z=new Float64Array(_+1),this.v=new Uint16Array(_)}_createCanvas(e){const s=document.createElement("canvas");return s.width=s.height=e,s}draw(e){const{width:s,actualBoundingBoxAscent:l,actualBoundingBoxDescent:c,actualBoundingBoxLeft:d,actualBoundingBoxRight:p}=this.ctx.measureText(e),f=Math.ceil(l),m=Math.max(0,Math.min(this.size-this.buffer,Math.ceil(p-d))),_=Math.min(this.size-this.buffer,f+Math.ceil(c)),g=m+2*this.buffer,y=_+2*this.buffer,b=Math.max(g*y,0),T=new Uint8ClampedArray(b),P={data:T,width:g,height:y,glyphWidth:m,glyphHeight:_,glyphTop:f,glyphLeft:0,glyphAdvance:s};if(0===m||0===_)return P;const{ctx:S,buffer:I,gridInner:C,gridOuter:z}=this;this.lang&&(S.lang=this.lang),S.clearRect(I,I,m,_),S.fillText(e,I,I+f);const L=S.getImageData(I,I,m,_);z.fill(O,0,b),C.fill(0,0,b);for(let e=0;e<_;e++)for(let s=0;s0?e*e:0,C[c]=e<0?e*e:0}}j(z,0,0,g,y,g,this.f,this.v,this.z),j(C,I,I,m,_,g,this.f,this.v,this.z);for(let e=0;e1&&(f=e[++p]);const _=Math.abs(m-f.left),g=Math.abs(m-f.right),y=Math.min(_,g);let b;const T=s/l*(c+1);if(f.isDash){const e=c-Math.abs(T);b=Math.sqrt(y*y+e*e)}else b=c-Math.sqrt(y*y+T*T);this.data[d+m]=Math.max(0,Math.min(255,b+128))}}}addRegularDash(e){for(let s=e.length-1;s>=0;--s){const l=e[s],c=e[s+1];l.zeroLength?e.splice(s,1):c&&c.isDash===l.isDash&&(c.left=l.left,e.splice(s,1))}const s=e[0],l=e[e.length-1];s.isDash===l.isDash&&(s.left=l.left-this.width,l.right=s.right+this.width);const c=this.width*this.nextRow;let d=0,p=e[d];for(let s=0;s1&&(p=e[++d]);const l=Math.abs(s-p.left),f=Math.abs(s-p.right),m=Math.min(l,f);this.data[c+s]=Math.max(0,Math.min(255,(p.isDash?m:-m)+128))}}addDash(e,s){const c=s?7:0,d=2*c+1;if(this.nextRow+d>this.height)return l.w("LineAtlas out of space"),null;let p=0;for(let s=0;s{e.terminate()})),this.workers=null)}isPreloaded(){return!!this.active[W]}numActive(){return Object.keys(this.active).length}}const J=Math.floor(_.hardwareConcurrency/2);let re,se;function oe(){return re||(re=new k),re}k.workerCount=l.K(globalThis)?Math.max(Math.min(J,3),1):1;class N{constructor(e,s){this.workerPool=e,this.actors=[],this.currentActor=0,this.id=s;const c=this.workerPool.acquire(s);for(let e=0;e{e.remove()})),this.actors=[],e&&this.workerPool.release(this.id)}registerMessageHandler(e,s){for(const l of this.actors)l.registerMessageHandler(e,s)}unregisterMessageHandler(e){for(const s of this.actors)s.unregisterMessageHandler(e)}}function le(){return se||(se=new N(oe(),l.M),se.registerMessageHandler("GR",((e,s,c)=>l.m(s,c)))),se}function ce(e,s){const c=l.N();return l.O(c,c,[1,1,0]),l.Q(c,c,[.5*e.width,.5*e.height,1]),e.calculatePosMatrix?l.S(c,c,e.calculatePosMatrix(s.toUnwrapped())):c}function he(e,s,l,c,d,p,f){var m;const _=function(e,s,l){if(e)for(const c of e){const e=s[c];if(e&&e.source===l&&"fill-extrusion"===e.type)return!0}else for(const e in s){const c=s[e];if(c.source===l&&"fill-extrusion"===c.type)return!0}return!1}(null!==(m=null==d?void 0:d.layers)&&void 0!==m?m:null,s,e.id),g=p.maxPitchScaleFactor(),y=e.tilesIn(c,g,_);y.sort(ue);const b=[];for(const c of y)b.push({wrappedTileID:c.tileID.wrapped().key,queryResults:c.tile.queryRenderedFeatures(s,l,e.getState(),c.queryGeometry,c.cameraQueryGeometry,c.scale,d,p,g,ce(p,c.tileID),f?(e,s)=>f(c.tileID,e,s):void 0)});return function(e,s){for(const l in e)for(const c of e[l])pe(c,s);return e}(function(e){const s={},l={};for(const c of e){const e=c.queryResults,d=c.wrappedTileID,p=l[d]=l[d]||{};for(const l in e){const c=e[l],d=p[l]=p[l]||{},f=s[l]=s[l]||[];for(const e of c)d[e.featureIndex]||(d[e.featureIndex]=!0,f.push(e))}}return s}(b),e)}function ue(e,s){const l=e.tileID,c=s.tileID;return l.overscaledZ-c.overscaledZ||l.canonical.y-c.canonical.y||l.wrap-c.wrap||l.canonical.x-c.canonical.x}function pe(e,s){const l=e.feature,c=s.getFeatureState(l.layer["source-layer"],l.id);l.source=l.layer.source,l.layer["source-layer"]&&(l.sourceLayer=l.layer["source-layer"]),l.state=c}function fe(s,c,d){return l._(this||e,void 0,void 0,(function*(){let e=s;if(s.url?e=(yield l.j(c.transformRequest(s.url,"Source"),d)).data:yield _.frameAsync(d),!e)return null;const p=l.U(l.e(e,s),["tiles","minzoom","maxzoom","attribution","bounds","scheme","tileSize","encoding"]);return"vector_layers"in e&&e.vector_layers&&(p.vectorLayerIds=e.vector_layers.map((e=>e.id))),p}))}class ${constructor(e,s){e&&(s?this.setSouthWest(e).setNorthEast(s):Array.isArray(e)&&(4===e.length?this.setSouthWest([e[0],e[1]]).setNorthEast([e[2],e[3]]):this.setSouthWest(e[0]).setNorthEast(e[1])))}setNorthEast(e){return this._ne=e instanceof l.V?new l.V(e.lng,e.lat):l.V.convert(e),this}setSouthWest(e){return this._sw=e instanceof l.V?new l.V(e.lng,e.lat):l.V.convert(e),this}extend(e){const s=this._sw,c=this._ne;let d,p;if(e instanceof l.V)d=e,p=e;else{if(!(e instanceof $))return Array.isArray(e)?4===e.length||e.every(Array.isArray)?this.extend($.convert(e)):this.extend(l.V.convert(e)):e&&("lng"in e||"lon"in e)&&"lat"in e?this.extend(l.V.convert(e)):this;if(d=e._sw,p=e._ne,!d||!p)return this}return s||c?(s.lng=Math.min(d.lng,s.lng),s.lat=Math.min(d.lat,s.lat),c.lng=Math.max(p.lng,c.lng),c.lat=Math.max(p.lat,c.lat)):(this._sw=new l.V(d.lng,d.lat),this._ne=new l.V(p.lng,p.lat)),this}getCenter(){return new l.V((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 l.V(this.getWest(),this.getNorth())}getSouthEast(){return new l.V(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(e){const{lng:s,lat:c}=l.V.convert(e);let d=this._sw.lng<=s&&s<=this._ne.lng;return this._sw.lng>this._ne.lng&&(d=this._sw.lng>=s&&s>=this._ne.lng),this._sw.lat<=c&&c<=this._ne.lat&&d}intersects(e){if(!((e=$.convert(e)).getNorth()>=this.getSouth()&&e.getSouth()<=this.getNorth()))return!1;const s=Math.abs(this.getEast()-this.getWest()),c=Math.abs(e.getEast()-e.getWest());if(s>=360||c>=360)return!0;const d=l.W(this.getWest(),-180,180),p=l.W(this.getEast(),-180,180),f=l.W(e.getWest(),-180,180),m=l.W(e.getEast(),-180,180),_=d>=p,g=f>=m;return!(!_||!g)||(_?m>=d||f<=p:g?p>=f||d<=m:f<=p&&m>=d)}static convert(e){return e instanceof $?e:e?new $(e):e}static fromLngLat(e,s=0){const c=360*s/40075017,d=c/Math.cos(Math.PI/180*e.lat);return new $(new l.V(e.lng-d,e.lat-c),new l.V(e.lng+d,e.lat+c))}adjustAntiMeridian(){const e=new l.V(this._sw.lng,this._sw.lat),s=new l.V(this._ne.lng,this._ne.lat);return new $(e,e.lng>s.lng?new l.V(s.lng+360,s.lat):s)}}class H{constructor(e,s,l){this.bounds=$.convert(this.validateBounds(e)),this.minzoom=s||0,this.maxzoom=l||24}validateBounds(e){return Array.isArray(e)&&4===e.length?[Math.max(-180,e[0]),Math.max(-90,e[1]),Math.min(180,e[2]),Math.min(90,e[3])]:[-180,-90,180,90]}contains(e){const s=Math.pow(2,e.z),c=Math.floor(l.Y(this.bounds.getWest())*s),d=Math.floor(l.X(this.bounds.getNorth())*s),p=Math.ceil(l.Y(this.bounds.getEast())*s),f=Math.ceil(l.X(this.bounds.getSouth())*s);return e.x>=c&&e.x=d&&e.y{this._options.tiles=e})),this}setUrl(e){return this.setSourceProperty((()=>{this.url=e,this._options.url=e})),this}onRemove(){this._tileJSONRequest&&(this._tileJSONRequest.abort(),this._tileJSONRequest=null)}serialize(){return l.e({},this._options)}loadTile(e){return l._(this,void 0,void 0,(function*(){const s=e.tileID.canonical.url(this.tiles,this.map.getPixelRatio(),this.scheme),l={request:this.map._requestManager.transformRequest(s,"Tile"),uid:e.uid,tileID:e.tileID,zoom:e.tileID.overscaledZ,tileSize:this.tileSize*e.tileID.overscaleFactor(),type:this.type,source:this.id,pixelRatio:this.map.getPixelRatio(),showCollisionBoxes:this.map.showCollisionBoxes,promoteId:this.promoteId,subdivisionGranularity:this.map.style.projection.subdivisionGranularity,encoding:this.encoding,overzoomParameters:this._getOverzoomParameters(e)};l.request.collectResourceTiming=this._collectResourceTiming;let c="RT";if(e.actor&&"expired"!==e.state){if("loading"===e.state)return new Promise(((s,l)=>{e.reloadPromise={resolve:s,reject:l}}))}else e.actor=this.dispatcher.getActor(),c="LT";e.abortController=new AbortController;try{const s=yield e.actor.sendAsync({type:c,data:l},e.abortController);if(delete e.abortController,e.aborted)return;this._afterTileLoadWorkerResponse(e,s)}catch(s){if(delete e.abortController,e.aborted)return;if(s&&404!==s.status)throw s;this._afterTileLoadWorkerResponse(e,null)}}))}_getOverzoomParameters(e){if(e.tileID.canonical.z<=this.maxzoom)return;if(void 0===this.map._zoomLevelsToOverscale)return;const s=e.tileID.scaledTo(this.maxzoom).canonical,l=s.url(this.tiles,this.map.getPixelRatio(),this.scheme);return{maxZoomTileID:s,overzoomRequest:this.map._requestManager.transformRequest(l,"Tile")}}_afterTileLoadWorkerResponse(e,s){if(s&&s.resourceTiming&&(e.resourceTiming=s.resourceTiming),s&&this.map._refreshExpiredTiles&&e.setExpiryData(s),e.loadVectorData(s,this.map.painter),e.reloadPromise){const s=e.reloadPromise;e.reloadPromise=null,this.loadTile(e).then(s.resolve).catch(s.reject)}}abortTile(e){return l._(this,void 0,void 0,(function*(){e.abortController&&(e.abortController.abort(),delete e.abortController),e.actor&&(yield e.actor.sendAsync({type:"AT",data:{uid:e.uid,type:this.type,source:this.id}}))}))}unloadTile(e){return l._(this,void 0,void 0,(function*(){e.unloadVectorData(),e.actor&&(yield e.actor.sendAsync({type:"RMT",data:{uid:e.uid,type:this.type,source:this.id}}))}))}hasTransition(){return!1}}class K extends l.E{constructor(e,s,c,d){super(),this.id=e,this.dispatcher=c,this.setEventedParent(d),this.type="raster",this.minzoom=0,this.maxzoom=22,this.roundZoom=!0,this.scheme="xyz",this.tileSize=512,this._loaded=!1,this._options=l.e({type:"raster"},s),l.e(this,l.U(s,["url","scheme","tileSize"]))}load(){return l._(this,arguments,void 0,(function*(e=!1){this._loaded=!1,this.fire(new l.l("dataloading",{dataType:"source"})),this._tileJSONRequest=new AbortController;try{const s=yield fe(this._options,this.map._requestManager,this._tileJSONRequest);this._tileJSONRequest=null,this._loaded=!0,s&&(l.e(this,s),s.bounds&&(this.tileBounds=new H(s.bounds,this.minzoom,this.maxzoom)),this.fire(new l.l("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new l.l("data",{dataType:"source",sourceDataType:"content",sourceDataChanged:e})))}catch(e){this._tileJSONRequest=null,this._loaded=!0,l.Z(e)||this.fire(new l.k(e))}}))}loaded(){return this._loaded}onAdd(e){this.map=e,this.load()}onRemove(){this._tileJSONRequest&&(this._tileJSONRequest.abort(),this._tileJSONRequest=null)}setSourceProperty(e){this._tileJSONRequest&&(this._tileJSONRequest.abort(),this._tileJSONRequest=null),e(),this.load(!0)}setTiles(e){return this.setSourceProperty((()=>{this._options.tiles=e})),this}setUrl(e){return this.setSourceProperty((()=>{this.url=e,this._options.url=e})),this}serialize(){return l.e({},this._options)}hasTile(e){return!this.tileBounds||this.tileBounds.contains(e.canonical)}loadTile(e){return l._(this,void 0,void 0,(function*(){const s=e.tileID.canonical.url(this.tiles,this.map.getPixelRatio(),this.scheme);e.abortController=new AbortController;try{const c=yield z.getImage(this.map._requestManager.transformRequest(s,"Tile"),e.abortController,this.map._refreshExpiredTiles);if(delete e.abortController,e.aborted)return void(e.state="unloaded");if(c&&c.data){this.map._refreshExpiredTiles&&(c.cacheControl||c.expires)&&e.setExpiryData({cacheControl:c.cacheControl,expires:c.expires});const s=this.map.painter.context,d=s.gl,p=c.data;e.texture=this.map.painter.getTileTexture(p.width),e.texture?e.texture.update(p,{useMipmap:!0}):(e.texture=new l.T(s,p,d.RGBA,{useMipmap:!0}),e.texture.bind(d.LINEAR,d.CLAMP_TO_EDGE,d.LINEAR_MIPMAP_NEAREST)),e.state="loaded"}}catch(s){if(delete e.abortController,e.aborted)e.state="unloaded";else if(s)throw e.state="errored",s}}))}abortTile(e){return l._(this,void 0,void 0,(function*(){e.abortController&&(e.abortController.abort(),delete e.abortController)}))}unloadTile(e){return l._(this,void 0,void 0,(function*(){e.texture&&this.map.painter.saveTileTexture(e.texture)}))}hasTransition(){return!1}}class Y extends K{constructor(e,s,c,d){super(e,s,c,d),this.type="raster-dem",this.maxzoom=22,this._options=l.e({type:"raster-dem"},s),this.encoding=s.encoding||"mapbox",this.redFactor=s.redFactor,this.greenFactor=s.greenFactor,this.blueFactor=s.blueFactor,this.baseShift=s.baseShift}loadTile(e){return l._(this,void 0,void 0,(function*(){const s=e.tileID.canonical.url(this.tiles,this.map.getPixelRatio(),this.scheme),c=this.map._requestManager.transformRequest(s,"Tile");e.neighboringTiles=this._getNeighboringTiles(e.tileID),e.abortController=new AbortController;try{const s=yield z.getImage(c,e.abortController,this.map._refreshExpiredTiles);if(delete e.abortController,e.aborted)return void(e.state="unloaded");if(s&&s.data){const c=s.data;this.map._refreshExpiredTiles&&(s.cacheControl||s.expires)&&e.setExpiryData({cacheControl:s.cacheControl,expires:s.expires});const d=l.b(c)&&l.$()?c:yield this.readImageNow(c),p={type:this.type,uid:e.uid,source:this.id,rawImageData:d,encoding:this.encoding,redFactor:this.redFactor,greenFactor:this.greenFactor,blueFactor:this.blueFactor,baseShift:this.baseShift};if(!e.actor||"expired"===e.state){e.actor=this.dispatcher.getActor();const s=yield e.actor.sendAsync({type:"LDT",data:p});e.dem=s,e.needsHillshadePrepare=!0,e.needsTerrainPrepare=!0,e.state="loaded"}}}catch(s){if(delete e.abortController,e.aborted)e.state="unloaded";else if(s)throw e.state="errored",s}}))}readImageNow(e){return l._(this,void 0,void 0,(function*(){if("undefined"!=typeof VideoFrame&&l.a0()){const s=e.width+2,c=e.height+2;try{return new l.R({width:s,height:c},yield l.a1(e,-1,-1,s,c))}catch(e){}}return _.getImageData(e,1)}))}_getNeighboringTiles(e){const s=e.canonical,c=Math.pow(2,s.z),d=(s.x-1+c)%c,p=0===s.x?e.wrap-1:e.wrap,f=(s.x+1+c)%c,m=s.x+1===c?e.wrap+1:e.wrap,_={};return _[new l.a2(e.overscaledZ,p,s.z,d,s.y).key]={backfilled:!1},_[new l.a2(e.overscaledZ,m,s.z,f,s.y).key]={backfilled:!1},s.y>0&&(_[new l.a2(e.overscaledZ,p,s.z,d,s.y-1).key]={backfilled:!1},_[new l.a2(e.overscaledZ,e.wrap,s.z,s.x,s.y-1).key]={backfilled:!1},_[new l.a2(e.overscaledZ,m,s.z,f,s.y-1).key]={backfilled:!1}),s.y+1e.coordinates)).flat(1/0):e.coordinates.flat(1/0)}function ge(e){const s=new $;let l;switch(e.type){case"FeatureCollection":l=e.features.map((e=>me(e.geometry))).flat(1/0);break;case"Feature":l=me(e.geometry);break;default:l=me(e)}if(0==l.length)return s;for(let e=0;e0&&l.e(m,{resourceTiming:f}),this.fire(new l.l("data",Object.assign(Object.assign({},m),{sourceDataType:"metadata"}))),this.fire(new l.l("data",Object.assign(Object.assign({},m),{sourceDataType:"content",shouldReloadTileOptions:p})))}catch(e){if(this._isUpdatingWorker=!1,this._removed)return void this.fire(new l.l("dataabort",{dataType:"source"}));this.fire(new l.k(e))}finally{this._hasPendingWorkerUpdate()&&this._updateWorkerData()}}))}_applyDiffToSource(e){if(!e)return;const s="string"==typeof this.promoteId?this.promoteId:void 0;if(!this._data.url&&!this._data.updateable){const e=l.a7(this._data.geojson,s);if(!e)throw new Error(`GeoJSONSource "${this.id}": GeoJSON data is not compatible with updateData`);this._data={updateable:e}}if(!this._data.updateable)return;const c=l.a8(this._data.updateable,e,s);return e.removeAll||this._options.cluster?void 0:c}_getShouldReloadTileOptions(e){if(e)return{affectedBounds:e.filter(Boolean).map((e=>ge(e)))}}shouldReloadTile(e,{affectedBounds:s}){if("loading"===e.state)return!0;if("unloaded"===e.state)return!1;const{buffer:c,extent:d}=this.workerOptions.geojsonVtOptions,p=function({x:e,y:s,z:c},d=0){const p=l.a3((e-d)/Math.pow(2,c)),f=l.a4((s+1+d)/Math.pow(2,c)),m=l.a3((e+1+d)/Math.pow(2,c)),_=l.a4((s-d)/Math.pow(2,c));return new $([p,f],[m,_])}(e.tileID.canonical,c/d);for(const e of s)if(p.intersects(e))return!0;return!1}loaded(){return!this._isUpdatingWorker&&!this._hasPendingWorkerUpdate()}loadTile(e){return l._(this,void 0,void 0,(function*(){const s=e.actor?"RT":"LT";e.actor=this.actor;const l={type:this.type,uid:e.uid,tileID:e.tileID,zoom:e.tileID.overscaledZ,maxZoom:this.maxzoom,tileSize:this.tileSize,source:this.id,pixelRatio:this.map.getPixelRatio(),showCollisionBoxes:this.map.showCollisionBoxes,promoteId:this.promoteId,subdivisionGranularity:this.map.style.projection.subdivisionGranularity};e.abortController=new AbortController;const c=yield this.actor.sendAsync({type:s,data:l},e.abortController);delete e.abortController,e.unloadVectorData(),e.aborted||e.loadVectorData(c,this.map.painter,"RT"===s)}))}abortTile(e){return l._(this,void 0,void 0,(function*(){e.abortController&&(e.abortController.abort(),delete e.abortController),e.aborted=!0}))}unloadTile(e){return l._(this,void 0,void 0,(function*(){e.unloadVectorData(),yield this.actor.sendAsync({type:"RMT",data:{uid:e.uid,type:this.type,source:this.id}})}))}onRemove(){this._removed=!0,this.actor.sendAsync({type:"RS",data:{type:this.type,source:this.id}})}serialize(){return l.e({},this._options,{type:this.type,data:this._data.updateable?{type:"FeatureCollection",features:Array.from(this._data.updateable.values())}:this._data.url||this._data.geojson})}hasTransition(){return!1}}class te extends l.E{constructor(e,s,l,c){super(),this.flippedWindingOrder=!1,this.id=e,this.dispatcher=l,this.coordinates=s.coordinates,this.type="image",this.minzoom=0,this.maxzoom=22,this.tileSize=512,this.tiles={},this._loaded=!1,this.setEventedParent(c),this.options=s}load(e){return l._(this,void 0,void 0,(function*(){this._loaded=!1,this.fire(new l.l("dataloading",{dataType:"source"})),this.url=this.options.url,this._request=new AbortController;try{const s=yield z.getImage(this.map._requestManager.transformRequest(this.url,"Image"),this._request);this._request=null,this._loaded=!0,s&&s.data&&(this.image=s.data,e&&(this.coordinates=e),this._finishLoading())}catch(e){this._request=null,this._loaded=!0,l.Z(e)||this.fire(new l.k(e))}}))}loaded(){return this._loaded}updateImage(e){return e.url?(this._request&&(this._request.abort(),this._request=null),this.options.url=e.url,this.load(e.coordinates).finally((()=>{this.texture=null})),this):this}_finishLoading(){this.map&&(this.setCoordinates(this.coordinates),this.fire(new l.l("data",{dataType:"source",sourceDataType:"metadata"})))}onAdd(e){this.map=e,this.load()}onRemove(){this._request&&(this._request.abort(),this._request=null)}setCoordinates(e){this.coordinates=e;const s=e.map(l.a9.fromLngLat);var c;return this.tileID=function(e){const s=l.aa.fromPoints(e),c=s.width(),d=s.height(),p=Math.max(c,d),f=Math.max(0,Math.floor(-Math.log(p)/Math.LN2)),m=Math.pow(2,f);return new l.ac(f,Math.floor((s.minX+s.maxX)/2*m),Math.floor((s.minY+s.maxY)/2*m))}(s),this.terrainTileRanges=this._getOverlappingTileRanges(s),this.minzoom=this.maxzoom=this.tileID.z,this.tileCoords=s.map((e=>this.tileID.getTilePoint(e)._round())),this.flippedWindingOrder=((c=this.tileCoords)[1].x-c[0].x)*(c[2].y-c[0].y)-(c[1].y-c[0].y)*(c[2].x-c[0].x)<0,this.fire(new l.l("data",{dataType:"source",sourceDataType:"content"})),this}prepare(){if(0===Object.keys(this.tiles).length||!this.image)return;const e=this.map.painter.context,s=e.gl;this.texture||(this.texture=new l.T(e,this.image,s.RGBA),this.texture.bind(s.LINEAR,s.CLAMP_TO_EDGE));let c=!1;for(const e in this.tiles){const s=this.tiles[e];"loaded"!==s.state&&(s.state="loaded",s.texture=this.texture,c=!0)}c&&this.fire(new l.l("data",{dataType:"source",sourceDataType:"idle",sourceId:this.id}))}loadTile(e){return l._(this,void 0,void 0,(function*(){this.tileID&&this.tileID.equals(e.tileID.canonical)?(this.tiles[String(e.tileID.wrap)]=e,e.buckets={}):e.state="errored"}))}serialize(){return{type:"image",url:this.options.url,coordinates:this.coordinates}}hasTransition(){return!1}_getOverlappingTileRanges(e){const{minX:s,minY:c,maxX:d,maxY:p}=l.aa.fromPoints(e),f={};for(let e=0;e<=l.ab;e++){const l=Math.pow(2,e),m=Math.floor(s*l),_=Math.floor(c*l),g=Math.floor(d*l),y=Math.floor(p*l);f[e]={minTileX:m,minTileY:_,maxTileX:g,maxTileY:y}}return f}}class ie extends te{constructor(e,s,l,c){super(e,s,l,c),this.roundZoom=!0,this.type="video",this.options=s}load(){return l._(this,void 0,void 0,(function*(){this._loaded=!1;const e=this.options;this.urls=[];for(const s of e.urls)this.urls.push(this.map._requestManager.transformRequest(s,"Source").url);try{const e=yield l.ad(this.urls);if(this._loaded=!0,!e)return;this.video=e,this.video.loop=!0,this.video.addEventListener("playing",(()=>{this.map.triggerRepaint()})),this.map&&this.video.play(),this._finishLoading()}catch(e){this.fire(new l.k(e))}}))}pause(){this.video&&this.video.pause()}play(){this.video&&this.video.play()}seek(e){if(this.video){const s=this.video.seekable;es.end(0)?this.fire(new l.k(new l.ae(`sources.${this.id}`,null,`Playback for this video can be set only between the ${s.start(0)} and ${s.end(0)}-second mark.`))):this.video.currentTime=e}}getVideo(){return this.video}onAdd(e){this.map||(this.map=e,this.load(),this.video&&(this.video.play(),this.setCoordinates(this.coordinates)))}prepare(){if(0===Object.keys(this.tiles).length||this.video.readyState<2)return;const e=this.map.painter.context,s=e.gl;this.texture?this.video.paused||(this.texture.bind(s.LINEAR,s.CLAMP_TO_EDGE),s.texSubImage2D(s.TEXTURE_2D,0,0,0,s.RGBA,s.UNSIGNED_BYTE,this.video)):(this.texture=new l.T(e,this.video,s.RGBA),this.texture.bind(s.LINEAR,s.CLAMP_TO_EDGE));let c=!1;for(const e in this.tiles){const s=this.tiles[e];"loaded"!==s.state&&(s.state="loaded",s.texture=this.texture,c=!0)}c&&this.fire(new l.l("data",{dataType:"source",sourceDataType:"idle",sourceId:this.id}))}serialize(){return{type:"video",urls:this.urls,coordinates:this.coordinates}}hasTransition(){return this.video&&!this.video.paused}}class ae extends te{constructor(e,s,c,d){super(e,s,c,d),s.coordinates?Array.isArray(s.coordinates)&&4===s.coordinates.length&&!s.coordinates.some((e=>!Array.isArray(e)||2!==e.length||e.some((e=>"number"!=typeof e))))||this.fire(new l.k(new l.ae(`sources.${e}`,null,'"coordinates" property must be an array of 4 longitude/latitude array pairs'))):this.fire(new l.k(new l.ae(`sources.${e}`,null,'missing required property "coordinates"'))),s.animate&&"boolean"!=typeof s.animate&&this.fire(new l.k(new l.ae(`sources.${e}`,null,'optional "animate" property must be a boolean value'))),s.canvas?"string"==typeof s.canvas||s.canvas instanceof HTMLCanvasElement||this.fire(new l.k(new l.ae(`sources.${e}`,null,'"canvas" must be either a string representing the ID of the canvas element from which to read, or an HTMLCanvasElement instance'))):this.fire(new l.k(new l.ae(`sources.${e}`,null,'missing required property "canvas"'))),this.options=s,this.animate=void 0===s.animate||s.animate}load(){return l._(this,void 0,void 0,(function*(){this._loaded=!0,this.canvas||(this.canvas=this.options.canvas instanceof HTMLCanvasElement?this.options.canvas:document.getElementById(this.options.canvas)),this.width=this.canvas.width,this.height=this.canvas.height,this._hasInvalidDimensions()?this.fire(new l.k(new Error("Canvas dimensions cannot be less than or equal to zero."))):(this.play=function(){this._playing=!0,this.map.triggerRepaint()},this.pause=function(){this._playing&&(this.prepare(),this._playing=!1)},this._finishLoading())}))}getCanvas(){return this.canvas}onAdd(e){this.map=e,this.load(),this.canvas&&this.animate&&this.play()}onRemove(){this.pause()}prepare(){let e=!1;if(this.canvas.width!==this.width&&(this.width=this.canvas.width,e=!0),this.canvas.height!==this.height&&(this.height=this.canvas.height,e=!0),this._hasInvalidDimensions())return;if(0===Object.keys(this.tiles).length)return;const s=this.map.painter.context,c=s.gl;this.texture?(e||this._playing)&&this.texture.update(this.canvas,{premultiply:!0}):(this.texture=new l.T(s,this.canvas,c.RGBA,{premultiply:!0}),this.texture.bind(c.LINEAR,c.CLAMP_TO_EDGE));let d=!1;for(const e in this.tiles){const s=this.tiles[e];"loaded"!==s.state&&(s.state="loaded",s.texture=this.texture,d=!0)}d&&this.fire(new l.l("data",{dataType:"source",sourceDataType:"idle",sourceId:this.id}))}serialize(){return{type:"canvas",animate:this.animate,canvas:this.options.canvas,coordinates:this.coordinates}}hasTransition(){return this._playing}_hasInvalidDimensions(){for(const e of[this.canvas.width,this.canvas.height])if(isNaN(e)||e<=0)return!0;return!1}}const ye={},xe=e=>{switch(e){case"geojson":return ee;case"image":return te;case"raster":return K;case"raster-dem":return Y;case"vector":return X;case"video":return ie;case"canvas":return ae}return ye[e]},ve="RTLPluginLoaded";class ne extends l.E{constructor(){super(...arguments),this.status="unavailable",this.url=null,this.dispatcher=le()}_syncState(e){return this.status=e,this.dispatcher.broadcast("SRPS",{pluginStatus:e,pluginURL:this.url}).catch((e=>{throw this.status="error",e}))}getRTLTextPluginStatus(){return this.status}clearRTLTextPlugin(){this.status="unavailable",this.url=null}setRTLTextPlugin(e){return l._(this,arguments,void 0,(function*(e,s=!1){if(this.url)throw new Error("setRTLTextPlugin cannot be called multiple times.");if(this.url=_.resolveURL(e),!this.url)throw new Error(`requested url ${e} is invalid`);if("unavailable"===this.status){if(!s)return this._requestImport();this.status="deferred",this._syncState(this.status)}else if("requested"===this.status)return this._requestImport()}))}_requestImport(){return l._(this,void 0,void 0,(function*(){yield this._syncState("loading"),this.status="loaded",this.fire(new l.l(ve))}))}lazyLoad(){"unavailable"===this.status?this.status="requested":"deferred"===this.status&&this._requestImport()}}let be=null;function we(){return be||(be=new ne),be}var Se,Me;!function(e){e[e.Base=0]="Base",e[e.Parent=1]="Parent"}(Se||(Se={})),function(e){e[e.Departing=0]="Departing",e[e.Incoming=1]="Incoming"}(Me||(Me={}));class de{constructor(e,s){this.timeAdded=0,this.fadeEndTime=0,this.fadeOpacity=1,this.tileID=e,this.uid=l.af(),this.uses=0,this.tileSize=s,this.buckets={},this.expirationTime=null,this.queryPadding=0,this.hasSymbolBuckets=!1,this.hasRTLText=!1,this.dependencies={},this.rtt=[],this.rttCoords={},this.expiredRequestCount=0,this.state="loading"}isRenderable(e){return this.hasData()&&(!this.fadeEndTime||this.fadeOpacity>0)&&(e||!this.holdingForSymbolFade())}setCrossFadeLogic({fadingRole:e,fadingDirection:s,fadingParentID:l,fadeEndTime:c}){this.resetFadeLogic(),this.fadingRole=e,this.fadingDirection=s,this.fadingParentID=l,this.fadeEndTime=c}setSelfFadeLogic(e){this.resetFadeLogic(),this.selfFading=!0,this.fadeEndTime=e}resetFadeLogic(){this.fadingRole=null,this.fadingDirection=null,this.fadingParentID=null,this.selfFading=!1,this.timeAdded=y(),this.fadeEndTime=0,this.fadeOpacity=1}wasRequested(){return"errored"===this.state||"loaded"===this.state||"reloading"===this.state}clearTextures(e){this.demTexture&&e.saveTileTexture(this.demTexture),this.demTexture=null}loadVectorData(e,s,c){if(this.hasData()&&this.unloadVectorData(),this.state="loaded",e){e.featureIndex&&(this.latestFeatureIndex=e.featureIndex,e.rawTileData?(this.latestRawTileData=e.rawTileData,this.latestFeatureIndex.rawTileData=e.rawTileData,this.latestFeatureIndex.encoding=e.encoding):this.latestRawTileData&&(this.latestFeatureIndex.rawTileData=this.latestRawTileData,this.latestFeatureIndex.encoding=this.latestEncoding)),this.collisionBoxArray=e.collisionBoxArray,this.buckets=function(e,s){const l={};if(!s)return l;for(const c of e){const e=c.layerIds.map((e=>s.getLayer(e))).filter(Boolean);if(0!==e.length){c.layers=e,c.stateDependentLayerIds&&(c.stateDependentLayers=c.stateDependentLayerIds.map((s=>e.filter((e=>e.id===s))[0])));for(const s of e)l[s.id]=c}}return l}(e.buckets,null==s?void 0:s.style),this.hasSymbolBuckets=!1;for(const e in this.buckets){const s=this.buckets[e];if(s instanceof l.ah){if(this.hasSymbolBuckets=!0,!c)break;s.justReloaded=!0}}if(this.hasRTLText=!1,this.hasSymbolBuckets)for(const e in this.buckets){const s=this.buckets[e];if(s instanceof l.ah&&s.hasRTLText){this.hasRTLText=!0,we().lazyLoad();break}}this.queryPadding=0;for(const e in this.buckets){const l=this.buckets[e];this.queryPadding=Math.max(this.queryPadding,s.style.getLayer(e).queryRadius(l))}e.imageAtlas&&(this.imageAtlas=e.imageAtlas),e.glyphAtlasImage&&(this.glyphAtlasImage=e.glyphAtlasImage),this.dashPositions=e.dashPositions}else this.collisionBoxArray=new l.ag}unloadVectorData(){for(const e in this.buckets)this.buckets[e].destroy();this.buckets={},this.imageAtlasTexture&&this.imageAtlasTexture.destroy(),this.imageAtlas&&(this.imageAtlas=null),this.glyphAtlasTexture&&this.glyphAtlasTexture.destroy(),this.dashPositions&&(this.dashPositions=null),this.latestFeatureIndex=null,this.state="unloaded"}getBucket(e){return this.buckets[e.id]}upload(e){for(const s in this.buckets){const l=this.buckets[s];l.uploadPending()&&l.upload(e)}const s=e.gl;this.imageAtlas&&!this.imageAtlas.uploaded&&(this.imageAtlasTexture=new l.T(e,this.imageAtlas.image,s.RGBA),this.imageAtlas.uploaded=!0),this.glyphAtlasImage&&(this.glyphAtlasTexture=new l.T(e,this.glyphAtlasImage,s.ALPHA),this.glyphAtlasImage=null)}prepare(e){this.imageAtlas&&this.imageAtlas.patchUpdatedImages(e,this.imageAtlasTexture)}queryRenderedFeatures(e,s,l,c,d,p,f,m,_,g,y){return this.latestFeatureIndex&&this.latestFeatureIndex.rawTileData?this.latestFeatureIndex.query({queryGeometry:c,cameraQueryGeometry:d,scale:p,tileSize:this.tileSize,pixelPosMatrix:g,transform:m,params:f,queryPadding:this.queryPadding*_,getElevation:y},e,s,l):{}}querySourceFeatures(e,s){const c=this.latestFeatureIndex;if(!c||!c.rawTileData)return;const d=c.loadVTLayers(),p=s&&s.sourceLayer?s.sourceLayer:"",f=d[l.ai]||d[p];if(!f)return;const m=l.aj(null==s?void 0:s.filter,null==s?void 0:s.globalState),{z:_,x:g,y:y}=this.tileID.canonical,b={z:_,x:g,y:y};for(let s=0;se)l=!1;else if(s)if(this.expirationTime({zoom:0,x:0,y:0,wrap:e,fullyVisible:!1}),B=[],O=[];if(e.renderWorldCopies&&m.allowWorldCopies())for(let e=1;e<=3;e++)B.push(F(-e)),B.push(F(e));for(B.push(F(0));B.length>0;){const P=B.pop(),C=P.x,F=P.y;let j=P.fullyVisible;const G={x:C,y:F,z:P.zoom},U=m.getTileBoundingVolume(G,P.wrap,e.elevation,s);if(!j){const e=$e(c,U,d);if(0===e)continue;j=2===e}const q=m.distanceToTile2d(p.x,p.y,G,U);let Z=g;_&&(Z=(s.calculateTileZoom||et)(e.zoom+l.at(e.tileSize/s.tileSize),q,z,L,e.fov)),Z=(s.roundZoom?Math.round:Math.floor)(Z),Z=Math.max(0,Z);const W=Math.min(Z,b);if(P.wrap=m.getWrap(f,G,P.wrap),P.zoom>=W){if(P.zoom>1),wrap:P.wrap,fullyVisible:j})}return O.sort(((e,s)=>e.distanceSq-s.distanceSq)).map((e=>e.tileID))}const rt=l.aa.fromPoints([new l.P(0,0),new l.P(l.a5,l.a5)]);function ot(e){return"raster"===e||"image"===e||"video"===e}function at(e,s,l,c,d,p,f){if(!s.hasData())return!1;const{tileID:m,fadingRole:_,fadingDirection:g,fadingParentID:y}=s;if(_===Se.Base&&g===Me.Incoming&&y)return l[y.key]=y,!0;const b=Math.max(m.overscaledZ-d,p);for(let d=m.overscaledZ-1;d>=b;d--){const p=m.scaledTo(d),_=e.getLoadedTile(p);if(_)return s.setCrossFadeLogic({fadingRole:Se.Base,fadingDirection:Me.Incoming,fadingParentID:_.tileID,fadeEndTime:c+f}),_.setCrossFadeLogic({fadingRole:Se.Parent,fadingDirection:Me.Departing,fadeEndTime:c+f}),l[p.key]=p,!0}return!1}function ft(e,s,l,c,d,p){if(!s.hasData())return!1;const f=s.tileID.children(d);let m=_t(e,s,f,l,c,d,p);if(m)return!0;for(const _ of f)_t(e,s,_.children(d),l,c,d,p)&&(m=!0);return m}function _t(e,s,l,c,d,p,f){if(l[0].overscaledZ>=p)return!1;let m=!1;for(const p of l){const l=e.getLoadedTile(p);if(!l)continue;const{fadingRole:_,fadingDirection:g,fadingParentID:y}=l;_===Se.Base&&g===Me.Departing&&y||(l.setCrossFadeLogic({fadingRole:Se.Base,fadingDirection:Me.Departing,fadingParentID:s.tileID,fadeEndTime:d+f}),s.setCrossFadeLogic({fadingRole:Se.Parent,fadingDirection:Me.Incoming,fadeEndTime:d+f})),c[p.key]=p,m=!0}return m}function yt(e,s,l,c){const d=e.tileID;return!!e.selfFading||!e.hasData()&&!!s.has(d)&&(e.setSelfFadeLogic(l+c),!0)}function vt(e,s){var l;e.needsHillshadePrepare=!0,e.needsTerrainPrepare=!0;let c=s.tileID.canonical.x-e.tileID.canonical.x;const d=s.tileID.canonical.y-e.tileID.canonical.y,p=Math.pow(2,e.tileID.canonical.z),f=s.tileID.key;0===c&&0===d||Math.abs(d)>1||(Math.abs(c)>1&&(1===Math.abs(c+p)?c+=p:1===Math.abs(c-p)&&(c-=p)),s.dem&&e.dem&&(e.dem.backfillBorder(s.dem,c,d),(null===(l=e.neighboringTiles)||void 0===l?void 0:l[f])&&(e.neighboringTiles[f].backfilled=!0)))}class Le{constructor(){this._tiles={}}handleWrapJump(e){const s={};for(const l in this._tiles){const c=this._tiles[l];c.tileID=c.tileID.unwrapTo(c.tileID.wrap+e),s[c.tileID.key]=c}this._tiles=s}setFeatureState(e,s){for(const l in this._tiles)this._tiles[l].setFeatureState(e,s)}getAllTiles(){return Object.values(this._tiles)}getAllIds(e=!1){return e?Object.values(this._tiles).map((e=>e.tileID)).sort(l.aw).map((e=>e.key)):Object.keys(this._tiles)}getTileById(e){return this._tiles[e]}setTile(e,s){this._tiles[e]=s}deleteTileById(e){delete this._tiles[e]}getLoadedTile(e){const s=this.getTileById(e.key);return(null==s?void 0:s.hasData())?s:null}isIdRenderable(e,s=!1){var l;return null===(l=this.getTileById(e))||void 0===l?void 0:l.isRenderable(s)}getRenderableIds(e=0,s){const c=[];for(const e of this.getAllIds())this.isIdRenderable(e,s)&&c.push(this.getTileById(e));return s?c.sort(((s,c)=>{const d=s.tileID,p=c.tileID,f=new l.P(d.canonical.x,d.canonical.y)._rotate(-e),m=new l.P(p.canonical.x,p.canonical.y)._rotate(-e);return d.overscaledZ-p.overscaledZ||m.y-f.y||m.x-f.x})).map((e=>e.tileID.key)):c.map((e=>e.tileID)).sort(l.aw).map((e=>e.key))}}class ke extends l.E{constructor(e,s,c){super(),this.id=e,this.dispatcher=c,this.on("data",(e=>this._dataHandler(e))),this.on("dataloading",(()=>{this._sourceErrored=!1})),this.on("error",(()=>{this._sourceErrored=this._source.loaded()})),this._source=((e,s,l,c)=>{const d=new(xe(s.type))(e,s,l,c);if(d.id!==e)throw new Error(`Expected Source id to be ${e} instead of ${d.id}`);return d})(e,s,c,this),this._inViewTiles=new Le,this._outOfViewCache=new l.ax(0,(e=>this._unloadTile(e))),this._timers={},this._maxTileCacheSize=null,this._maxTileCacheZoomLevels=null,this._rasterFadeDuration=0,this._maxFadingAncestorLevels=5,this._state=new _e,this._didEmitContent=!1,this._updated=!1}onAdd(e){this.map=e,this._maxTileCacheSize=e?e._maxTileCacheSize:null,this._maxTileCacheZoomLevels=e?e._maxTileCacheZoomLevels:null,this._source&&this._source.onAdd&&this._source.onAdd(e)}onRemove(e){for(const e of this._inViewTiles.getAllTiles())e.unloadVectorData();this.clearTiles(),this._source&&this._source.onRemove&&this._source.onRemove(e),this._inViewTiles=new Le}loaded(){if(this._sourceErrored)return!0;if(!this._sourceLoaded)return!1;if(!this._source.loaded())return!1;if(!(void 0===this.used&&void 0===this.usedForTerrain||this.used||this.usedForTerrain))return!0;if(!this._updated)return!1;for(const e of this._inViewTiles.getAllTiles())if("loaded"!==e.state&&"errored"!==e.state)return!1;return!0}getSource(){return this._source}getState(){return this._state}pause(){this._paused=!0}resume(){if(!this._paused)return;const e=this._shouldReloadOnResume;this._paused=!1,this._shouldReloadOnResume=!1,e&&this.reload(),this.transform&&this.update(this.transform,this.terrain)}_loadTile(e,s,c){return l._(this,void 0,void 0,(function*(){try{yield this._source.loadTile(e),this._tileLoaded(e,s,c)}catch(s){e.state="errored",404!==s.status?this._source.fire(new l.k(s,{tile:e})):this.update(this.transform,this.terrain)}}))}_unloadTile(e){this._source.unloadTile&&this._source.unloadTile(e)}_abortTile(e){this._source.abortTile&&this._source.abortTile(e),this._source.fire(new l.l("dataabort",{tile:e,coord:e.tileID,dataType:"source"}))}serialize(){return this._source.serialize()}prepare(e){this._source.prepare&&this._source.prepare(),this._state.coalesceChanges(this._inViewTiles,this.map?this.map.painter:null);for(const s of this._inViewTiles.getAllTiles())s.upload(e),s.prepare(this.map.style.imageManager)}getIds(){return this._inViewTiles.getAllIds(!0)}getRenderableIds(e){var s;return this._inViewTiles.getRenderableIds(null===(s=this.transform)||void 0===s?void 0:s.bearingInRadians,e)}hasRenderableParent(e){const s=e.overscaledZ-1;if(s>=this._source.minzoom){const l=this.getLoadedTile(e.scaledTo(s));if(l)return this._inViewTiles.isIdRenderable(l.tileID.key)}return!1}reload(e,s=void 0){if(this._paused)this._shouldReloadOnResume=!0;else{this._outOfViewCache.reset();for(const l of this._inViewTiles.getAllIds()){const c=this._inViewTiles.getTileById(l);s&&!this._source.shouldReloadTile(c,s)||(e?this._reloadTile(l,"expired"):"errored"!==c.state&&this._reloadTile(l,"reloading"))}}}_reloadTile(e,s){return l._(this,void 0,void 0,(function*(){const l=this._inViewTiles.getTileById(e);l&&("loading"!==l.state&&(l.state=s),yield this._loadTile(l,e,s))}))}_tileLoaded(e,s,c){e.timeAdded=y(),e.selfFading&&(e.fadeEndTime=e.timeAdded+this._rasterFadeDuration),"expired"===c&&(e.refreshedUponExpiration=!0),this._setTileReloadTimer(s,e),"raster-dem"===this.getSource().type&&e.dem&&function(e,s){var l,c;const d=s.getRenderableIds();for(const p of d){if(!e.neighboringTiles||!e.neighboringTiles[p])continue;const d=s.getTileById(p);e.neighboringTiles[p].backfilled||vt(e,d),(null===(c=null===(l=d.neighboringTiles)||void 0===l?void 0:l[e.tileID.key])||void 0===c?void 0:c.backfilled)||vt(d,e)}}(e,this._inViewTiles),this._state.initializeTileState(e,this.map?this.map.painter:null),e.aborted||this._source.fire(new l.l("data",{dataType:"source",tile:e,coord:e.tileID}))}getTile(e){return this.getTileByID(e.key)}getTileByID(e){return this._inViewTiles.getTileById(e)}_retainLoadedChildren(e,s){const l=this._getLoadedDescendents(s),c=new Set;for(const d of s){const s=l[d.key];if(!(null==s?void 0:s.length)){c.add(d);continue}const p=d.overscaledZ+ke.maxOverzooming,f=s.filter((e=>e.tileID.overscaledZ<=p));if(!f.length){c.add(d);continue}const m=Math.min(...f.map((e=>e.tileID.overscaledZ))),_=f.filter((e=>e.tileID.overscaledZ===m)).map((e=>e.tileID));for(const s of _)e[s.key]=s;this._areDescendentsComplete(_,m,d.overscaledZ)||c.add(d)}return c}_getLoadedDescendents(e){var s;const l={};for(const c of this._inViewTiles.getAllTiles().filter((e=>e.hasData())))for(const d of e)c.tileID.isChildOf(d)&&(l[s=d.key]||(l[s]=[])).push(c);return l}_areDescendentsComplete(e,s,l){return 1===e.length&&e[0].isOverscaled()?e[0].overscaledZ===s:Math.pow(4,s-l)===e.length}getLoadedTile(e){return this._inViewTiles.getLoadedTile(e)}updateCacheSize(e){const s=Math.ceil(e.width/this._source.tileSize)+1,c=Math.ceil(e.height/this._source.tileSize)+1,d=Math.floor(s*c*(null===this._maxTileCacheZoomLevels?l.c.MAX_TILE_CACHE_ZOOM_LEVELS:this._maxTileCacheZoomLevels)),p="number"==typeof this._maxTileCacheSize?Math.min(this._maxTileCacheSize,d):d;this._outOfViewCache.setMaxSize(p)}handleWrapJump(e){const s=Math.round((e-(void 0===this._prevLng?e:this._prevLng))/360);this._prevLng=e,s&&(this._inViewTiles.handleWrapJump(s),this._resetTileReloadTimers())}update(e,s){if(!this._sourceLoaded||this._paused)return;let c;this.transform=e,this.terrain=s,this.updateCacheSize(e),this.handleWrapJump(this.transform.center.lng),this.used||this.usedForTerrain?this._source.tileID?c=e.getVisibleUnwrappedCoordinates(this._source.tileID).map((e=>new l.a2(e.canonical.z,e.wrap,e.canonical.z,e.canonical.x,e.canonical.y))):(c=it(e,{tileSize:this.usedForTerrain?this.tileSize:this._source.tileSize,minzoom:this._source.minzoom,maxzoom:"vector"===this._source.type&&void 0!==this.map._zoomLevelsToOverscale?e.maxZoom-this.map._zoomLevelsToOverscale:this._source.maxzoom,roundZoom:!this.usedForTerrain&&this._source.roundZoom,reparseOverscaled:this._source.reparseOverscaled,terrain:s,calculateTileZoom:this._source.calculateTileZoom}),this._source.hasTile&&(c=c.filter((e=>this._source.hasTile(e))))):c=[],this.usedForTerrain&&(c=this._addTerrainIdealTiles(c));const d=0===c.length&&!this._updated&&this._didEmitContent;this._updated=!0,d&&this.fire(new l.l("data",{sourceDataType:"idle",dataType:"source",sourceId:this.id}));const p=tt(e,this._source),f=this._updateRetainedTiles(c,p),m=ot(this._source.type);m&&this._rasterFadeDuration>0&&!s&&function(e,s,c,d,p,f,m){const _=y(),g=l.av(s);for(const l of s){const s=e.getTileById(l.key);s.fadingDirection!==Me.Departing&&0!==s.fadeOpacity||s.resetFadeLogic(),at(e,s,c,_,d,p,m)||ft(e,s,c,_,f,m)||yt(s,g,_,m)||s.resetFadeLogic()}}(this._inViewTiles,c,f,this._maxFadingAncestorLevels,this._source.minzoom,this._source.maxzoom,this._rasterFadeDuration),m?this._cleanUpRasterTiles(f):this._cleanUpVectorTiles(f)}_cleanUpRasterTiles(e){for(const s of this._inViewTiles.getAllIds())e[s]||this._removeTile(s)}_cleanUpVectorTiles(e){for(const s of this._inViewTiles.getAllIds()){const l=this._inViewTiles.getTileById(s);e[s]?l.clearSymbolFadeHold():l.hasSymbolBuckets?l.holdingForSymbolFade()?l.symbolFadeFinished()&&this._removeTile(s):l.setSymbolHoldDuration(this.map._fadeDuration):this._removeTile(s)}}_addTerrainIdealTiles(e){const s=[];for(const l of e)if(l.canonical.z>this._source.minzoom){const e=l.scaledTo(l.canonical.z-1);s.push(e);const c=l.scaledTo(Math.max(this._source.minzoom,Math.min(l.canonical.z,5)));s.push(c)}return e.concat(s)}releaseSymbolFadeTiles(){for(const e of this._inViewTiles.getAllIds())this._inViewTiles.getTileById(e).holdingForSymbolFade()&&this._removeTile(e)}_updateRetainedTiles(e,s){var l;const c=new Set;for(const s of e)this._addTile(s).hasData()||c.add(s);const d=e.reduce(((e,s)=>(e[s.key]=s,e)),{}),p=this._retainLoadedChildren(d,c),f={},m=Math.max(s-ke.maxUnderzooming,this._source.minzoom);for(const e of p){let s=this._inViewTiles.getTileById(e.key),c=null==s?void 0:s.wasRequested();for(let p=e.overscaledZ-1;p>=m;--p){const m=e.scaledTo(p);if(f[m.key])break;if(f[m.key]=!0,s=this.getTile(m),!s&&c&&(s=this._addTile(m)),s){const e=s.hasData();if((e||!(null===(l=this.map)||void 0===l?void 0:l.cancelPendingTileRequestsWhileZooming)||c)&&(d[m.key]=m),c=s.wasRequested(),e)break}}}return d}_addTile(e){let s=this._inViewTiles.getTileById(e.key);if(s)return s;s=this._outOfViewCache.getAndRemove(e),s&&(s.resetFadeLogic(),this._setTileReloadTimer(e.key,s),s.tileID=e,this._state.initializeTileState(s,this.map?this.map.painter:null));const c=s;return s||(s=new de(e,this._source.tileSize*e.overscaleFactor()),this._loadTile(s,e.key,s.state)),s.uses++,this._inViewTiles.setTile(e.key,s),c||this._source.fire(new l.l("dataloading",{tile:s,coord:s.tileID,dataType:"source"})),s}_setTileReloadTimer(e,s){this._clearTileReloadTimer(e);const l=s.getExpiryTimeout();l&&(this._timers[e]=setTimeout((()=>{this._reloadTile(e,"expired"),delete this._timers[e]}),l))}_clearTileReloadTimer(e){const s=this._timers[e];s&&(clearTimeout(s),delete this._timers[e])}_resetTileReloadTimers(){for(const e in this._timers)clearTimeout(this._timers[e]),delete this._timers[e];for(const e of this._inViewTiles.getAllIds()){const s=this._inViewTiles.getTileById(e);this._setTileReloadTimer(e,s)}}refreshTiles(e){for(const s of this._inViewTiles.getAllIds()){const l=this._inViewTiles.getTileById(s);(this._inViewTiles.isIdRenderable(s)||"errored"==l.state)&&e.some((e=>e.equals(l.tileID.canonical)))&&this._reloadTile(s,"expired")}}_removeTile(e){const s=this._inViewTiles.getTileById(e);s&&(s.uses--,this._inViewTiles.deleteTileById(e),this._clearTileReloadTimer(e),s.uses>0||(s.hasData()&&"reloading"!==s.state?this._outOfViewCache.add(s.tileID,s,s.getExpiryTimeout()):(s.aborted=!0,this._abortTile(s),this._unloadTile(s))))}_dataHandler(e){"source"===e.dataType&&("metadata"!==e.sourceDataType?"content"===e.sourceDataType&&this._sourceLoaded&&!this._paused&&(this.reload(e.sourceDataChanged,e.shouldReloadTileOptions),this.transform&&this.update(this.transform,this.terrain),this._didEmitContent=!0):this._sourceLoaded=!0)}clearTiles(){this._shouldReloadOnResume=!1,this._paused=!1;for(const e of this._inViewTiles.getAllIds())this._removeTile(e);this._outOfViewCache.reset()}tilesIn(e,s,c){const d=[],p=this.transform;if(!p)return d;const f=p.getCoveringTilesDetailsProvider().allowWorldCopies(),m=c?p.getCameraQueryGeometry(e):e,_=e=>p.screenPointToMercatorCoordinate(e,this.terrain),g=this.transformBbox(e,_,!f),y=this.transformBbox(m,_,!f),b=this.getIds(),T=l.aa.fromPoints(y);for(let e=0;ee.getTilePoint(new l.a9(s.x,s.y))));if(s.expandBy(P),s.intersects(rt)){const s=g.map((s=>e.getTilePoint(s))),l=y.map((s=>e.getTilePoint(s)));d.push({tile:c,tileID:f?e:e.unwrapTo(0),queryGeometry:s,cameraQueryGeometry:l,scale:_})}}}return d}transformBbox(e,s,c){let d=e.map(s);if(c){const c=l.aa.fromPoints(e);c.shrinkBy(.001*Math.min(c.width(),c.height()));const p=c.map(s);l.aa.fromPoints(d).covers(p)||(d=d.map((e=>e.x>.5?new l.a9(e.x-1,e.y,e.z):e)))}return d}getVisibleCoordinates(e){const s=this.getRenderableIds(e).map((e=>this._inViewTiles.getTileById(e).tileID));return this.transform&&this.transform.populateCache(s),s}hasTransition(){return!!this._source.hasTransition()||!(!ot(this._source.type)||!function(e,s){if(s<=0)return!1;const l=y();for(const s of e.getAllTiles())if(s.fadeEndTime>=l)return!0;return!1}(this._inViewTiles,this._rasterFadeDuration))}setRasterFadeDuration(e){this._rasterFadeDuration=e}setFeatureState(e,s,c){this._state.updateState(e=e||l.ai,s,c)}removeFeatureState(e,s,c){this._state.removeFeatureState(e=e||l.ai,s,c)}getFeatureState(e,s){return this._state.getState(e=e||l.ai,s)}setDependencies(e,s,l){const c=this._inViewTiles.getTileById(e);c&&c.setDependencies(s,l)}reloadTilesForDependencies(e,s){for(const l of this._inViewTiles.getAllIds())this._inViewTiles.getTileById(l).hasDependency(e,s)&&this._reloadTile(l,"reloading");this._outOfViewCache.filter((l=>!l.hasDependency(e,s)))}areTilesLoaded(){for(const e of this._inViewTiles.getAllTiles())if("loaded"!==e.state&&"errored"!==e.state)return!1;return!0}}ke.maxUnderzooming=10,ke.maxOverzooming=3;class Fe{constructor(e,s){this.reset(e,s)}reset(e,s){this.points=e||[],this._distances=[0];for(let e=1;e0?(d-f)/m:0;return this.points[p].mult(1-_).add(this.points[s].mult(_))}}function bt(e,s){let l=!0;return"always"===e||"never"!==e&&"never"!==s||(l=!1),l}class Oe{constructor(e,s,l){const c=this.boxCells=[],d=this.circleCells=[];this.xCellCount=Math.ceil(e/l),this.yCellCount=Math.ceil(s/l);for(let e=0;ethis.width||c<0||s>this.height)return[];const m=[];if(e<=0&&s<=0&&this.width<=l&&this.height<=c){if(d)return[{key:null,x1:e,y1:s,x2:l,y2:c}];for(let e=0;e0}hitTestCircle(e,s,l,c,d){const p=e-l,f=e+l,m=s-l,_=s+l;if(f<0||p>this.width||_<0||m>this.height)return!1;const g=[];return this._forEachCell(p,m,f,_,this._queryCellCircle,g,{hitTest:!0,overlapMode:c,circle:{x:e,y:s,radius:l},seenUids:{box:{},circle:{}}},d),g.length>0}_queryCell(e,s,l,c,d,p,f,m){const{seenUids:_,hitTest:g,overlapMode:y}=f,b=this.boxCells[d];if(null!==b){const d=this.bboxes;for(const f of b)if(!_.box[f]){_.box[f]=!0;const b=4*f,T=this.boxKeys[f];if(e<=d[b+2]&&s<=d[b+3]&&l>=d[b+0]&&c>=d[b+1]&&(!m||m(T))&&(!g||!bt(y,T.overlapMode))&&(p.push({key:T,x1:d[b],y1:d[b+1],x2:d[b+2],y2:d[b+3]}),g))return!0}}const T=this.circleCells[d];if(null!==T){const d=this.circles;for(const f of T)if(!_.circle[f]){_.circle[f]=!0;const b=3*f,T=this.circleKeys[f];if(this._circleAndRectCollide(d[b],d[b+1],d[b+2],e,s,l,c)&&(!m||m(T))&&(!g||!bt(y,T.overlapMode))){const e=d[b],s=d[b+1],l=d[b+2];if(p.push({key:T,x1:e-l,y1:s-l,x2:e+l,y2:s+l}),g)return!0}}}return!1}_queryCellCircle(e,s,l,c,d,p,f,m){const{circle:_,seenUids:g,overlapMode:y}=f,b=this.boxCells[d];if(null!==b){const e=this.bboxes;for(const s of b)if(!g.box[s]){g.box[s]=!0;const l=4*s,c=this.boxKeys[s];if(this._circleAndRectCollide(_.x,_.y,_.radius,e[l+0],e[l+1],e[l+2],e[l+3])&&(!m||m(c))&&!bt(y,c.overlapMode))return p.push(!0),!0}}const T=this.circleCells[d];if(null!==T){const e=this.circles;for(const s of T)if(!g.circle[s]){g.circle[s]=!0;const l=3*s,c=this.circleKeys[s];if(this._circlesCollide(e[l],e[l+1],e[l+2],_.x,_.y,_.radius)&&(!m||m(c))&&!bt(y,c.overlapMode))return p.push(!0),!0}}}_forEachCell(e,s,l,c,d,p,f,m){const _=this._convertToXCellCoord(e),g=this._convertToYCellCoord(s),y=this._convertToXCellCoord(l),b=this._convertToYCellCoord(c);for(let T=_;T<=y;T++)for(let _=g;_<=b;_++)if(d.call(this,e,s,l,c,this.xCellCount*_+T,p,f,m))return}_convertToXCellCoord(e){return Math.max(0,Math.min(this.xCellCount-1,Math.floor(e*this.xScale)))}_convertToYCellCoord(e){return Math.max(0,Math.min(this.yCellCount-1,Math.floor(e*this.yScale)))}_circlesCollide(e,s,l,c,d,p){const f=c-e,m=d-s,_=l+p;return _*_>f*f+m*m}_circleAndRectCollide(e,s,l,c,d,p,f){const m=(p-c)/2,_=Math.abs(e-(c+m));if(_>m+l)return!1;const g=(f-d)/2,y=Math.abs(s-(d+g));if(y>g+l)return!1;if(_<=m||y<=g)return!0;const b=_-m,T=y-g;return b*b+T*T<=l*l}}function wt(e,s,c){const p=l.N();if(!e){const{vecSouth:e,vecEast:l}=Mt(s),c=d();c[0]=l[0],c[1]=l[1],c[2]=e[0],c[3]=e[1],f=c,(T=(_=(m=c)[0])*(b=m[3])-(y=m[2])*(g=m[1]))&&(f[0]=b*(T=1/T),f[1]=-g*T,f[2]=-y*T,f[3]=_*T),p[0]=c[0],p[1]=c[1],p[4]=c[2],p[5]=c[3]}var f,m,_,g,y,b,T;return l.Q(p,p,[1/c,1/c,1]),p}function Tt(e,s,c,d){if(e){const e=l.N();if(!s){const{vecSouth:s,vecEast:l}=Mt(c);e[0]=l[0],e[1]=l[1],e[4]=s[0],e[5]=s[1]}return l.Q(e,e,[d,d,1]),e}return c.pixelsToClipSpaceMatrix}function Mt(e){const s=Math.cos(e.rollInRadians),c=Math.sin(e.rollInRadians),d=Math.cos(e.pitchInRadians),p=Math.cos(e.bearingInRadians),f=Math.sin(e.bearingInRadians),m=l.aC();m[0]=-p*d*c-f*s,m[1]=-f*d*c+p*s;const _=l.aD(m);_<1e-9?l.aE(m):l.aF(m,m,1/_);const g=l.aC();g[0]=p*d*s-f*c,g[1]=f*d*s+p*c;const y=l.aD(g);return y<1e-9?l.aE(g):l.aF(g,g,1/y),{vecEast:g,vecSouth:m}}function At(e,s,c,d){let p;d?(p=[e,s,d(e,s),1],l.aH(p,p,c)):(p=[e,s,0,1],mi(p,p,c));const f=p[3];return{point:new l.P(p[0]/f,p[1]/f),signedDistanceFromCamera:f,isOccluded:!1}}function Lt(e,s){return.5+e/s*.5}function Ft(e,s){return e.x>=-s[0]&&e.x<=s[0]&&e.y>=-s[1]&&e.y<=s[1]}function Ot(e,s,c,d,p,f,m,_,g,y,b,T,P){const S=c?e.textSizeData:e.iconSizeData,I=l.ay(S,s.transform.zoom),C=[256/s.width*2+1,256/s.height*2+1],z=c?e.text.dynamicLayoutVertexArray:e.icon.dynamicLayoutVertexArray;z.clear();const L=e.lineVertexArray,F=c?e.text.placedSymbolArray:e.icon.placedSymbolArray,B=s.transform.width/s.transform.height;let O=!1;for(let c=0;cMath.abs(c.x-s.x)*d?{useVertical:!0}:(e===l.az.vertical?s.yc.x)?{needsFlipping:!0}:null}function Ht(e){const{projectionContext:s,pitchedLabelPlaneMatrixInverse:c,symbol:d,fontSize:p,flip:f,keepUpright:m,glyphOffsetArray:_,dynamicLayoutVertexArray:g,aspectRatio:y,rotateToLine:b}=e,T=p/24,P=d.lineOffsetX*T,S=d.lineOffsetY*T;let I;if(d.numGlyphs>1){const e=d.glyphStartIndex+d.numGlyphs,l=d.lineStartIndex,p=d.lineStartIndex+d.lineLength,g=Gt(T,_,P,S,f,d,b,s);if(!g)return{notEnoughRoom:!0};const C=ri(g.first.point.x,g.first.point.y,s,c),z=ri(g.last.point.x,g.last.point.y,s,c);if(m&&!f){const e=Zt(d.writingMode,C,z,y);if(e)return e}I=[g.first];for(let c=d.glyphStartIndex+1;c0?m.point:Xt(s.tileAnchorPoint,f,e,1,s),g=ri(e.x,e.y,s,c),b=ri(_.x,_.y,s,c),T=Zt(d.writingMode,g,b,y);if(T)return T}const e=ui(T*_.getoffsetX(d.glyphStartIndex),P,S,f,d.segment,d.lineStartIndex,d.lineStartIndex+d.lineLength,s,b);if(!e||s.projectionCache.anyProjectionOccluded)return{notEnoughRoom:!0};I=[e]}for(const e of I)l.aG(g,e.point,e.angle);return{}}function Xt(e,s,l,c,d){const p=e.add(e.sub(s)._unit()),f=Jt(p.x,p.y,d).point,m=l.sub(f);return l.add(m._mult(c/m.mag()))}function Kt(e,s,c){const d=s.projectionCache;if(d.projections[e])return d.projections[e];const p=new l.P(s.lineVertexArray.getx(e),s.lineVertexArray.gety(e)),f=Jt(p.x,p.y,s);if(f.signedDistanceFromCamera>0)return d.projections[e]=f.point,d.anyProjectionOccluded=d.anyProjectionOccluded||f.isOccluded,f.point;const m=e-c.direction;return Xt(0===c.distanceFromAnchor?s.tileAnchorPoint:new l.P(s.lineVertexArray.getx(m),s.lineVertexArray.gety(m)),p,c.previousVertex,c.absOffsetX-c.distanceFromAnchor+1,s)}function Jt(e,s,l){const c=e+l.translation[0],d=s+l.translation[1];let p;return l.pitchWithMap?(p=At(c,d,l.pitchedLabelPlaneMatrix,l.getElevation),p.isOccluded=!1):(p=l.transform.projectTileCoordinates(c,d,l.unwrappedTileID,l.getElevation),p.point.x=(.5*p.point.x+.5)*l.width,p.point.y=(.5*-p.point.y+.5)*l.height),p}function ri(e,s,c,d){if(c.pitchWithMap){const p=[e,s,0,1];return l.aH(p,p,d),c.transform.projectTileCoordinates(p[0]/p[3],p[1]/p[3],c.unwrappedTileID,c.getElevation).point}return{x:e/c.width*2-1,y:1-s/c.height*2}}function ni(e,s,l){return l.transform.projectTileCoordinates(e,s,l.unwrappedTileID,l.getElevation)}function li(e,s,l){return e._unit()._perp()._mult(s*l)}function ci(e,s,c,d,p,f,m,_,g){if(_.projectionCache.offsets[e])return _.projectionCache.offsets[e];const y=c.add(s);if(e+g.direction=p)return _.projectionCache.offsets[e]=y,y;const b=Kt(e+g.direction,_,g),T=li(b.sub(c),m,g.direction),P=c.add(T),S=b.add(T);return _.projectionCache.offsets[e]=l.aI(f,y,P,S)||y,_.projectionCache.offsets[e]}function ui(e,s,l,c,d,p,f,m,_){const g=c?e-s:e+s;let y=g>0?1:-1,b=0;c&&(y*=-1,b=Math.PI),y<0&&(b+=Math.PI);let T,P=y>0?p+d:p+d+1;m.projectionCache.cachedAnchorPoint?T=m.projectionCache.cachedAnchorPoint:(T=Jt(m.tileAnchorPoint.x,m.tileAnchorPoint.y,m).point,m.projectionCache.cachedAnchorPoint=T);let S,I,C=T,z=T,L=0,F=0;const B=Math.abs(g),O=[];let j;for(;L+F<=B;){if(P+=y,P=f)return null;L+=F,z=C,I=S;const e={absOffsetX:B,direction:y,distanceFromAnchor:L,previousVertex:z};if(C=Kt(P,m,e),0===l)O.push(z),j=C.sub(z);else{let s;const c=C.sub(z);s=0===c.mag()?li(Kt(P+y,m,e).sub(C),l,y):li(c,l,y),I||(I=z.add(s)),S=ci(P,s,C,p,f,I,l,m,e),O.push(I),j=S.sub(I)}F=j.mag()}const G=j._mult((B-L)/F)._add(I||z),U=b+Math.atan2(C.y-z.y,C.x-z.x);return O.push(G),{point:G,angle:_?U:0,path:O}}const pi=new Float32Array([-1/0,-1/0,0,-1/0,-1/0,0,-1/0,-1/0,0,-1/0,-1/0,0]);function fi(e,s){for(let l=0;l=1;e--)P.push(f.path[e]);for(let e=1;ee.signedDistanceFromCamera<=0))?[]:e.map((e=>e.point))}let C=[];if(P.length>0){const e=P[0].clone(),s=P[0].clone();for(let l=1;l=c.x&&s.x<=d.x&&e.y>=c.y&&s.y<=d.y?[P]:s.xd.x||s.yd.y?[]:l.aJ([P],c.x,c.y,d.x,d.y)}for(const l of C){p.reset(l,.25*s);let c=0;c=p.length<=.5*s?1:Math.ceil(p.paddedLength/S)+1;for(let l=0;l{const l=At(e.x,e.y,c,s.getElevation),d=s.transform.projectTileCoordinates(l.point.x,l.point.y,s.unwrappedTileID,s.getElevation);return d.point.x=(.5*d.point.x+.5)*s.width,d.point.y=(.5*-d.point.y+.5)*s.height,d}))}(e,s);return function(e){let s=0,l=0,c=0,d=0;for(let p=0;pl&&(l=d,s=c));return e.slice(s,s+l)}(c)}queryRenderedSymbols(e){if(0===e.length||0===this.grid.keysLength()&&0===this.ignoredGrid.keysLength())return{};const s=[],c=new l.aa;for(const d of e){const e=new l.P(d.x+_i,d.y+_i);c.extend(e),s.push(e)}const{minX:d,minY:p,maxX:f,maxY:m}=c,_=this.grid.query(d,p,f,m).concat(this.ignoredGrid.query(d,p,f,m)),g={},y={};for(const e of _){const c=e.key;if(void 0===g[c.bucketInstanceId]&&(g[c.bucketInstanceId]={}),g[c.bucketInstanceId][c.featureIndex])continue;const d=[new l.P(e.x1,e.y1),new l.P(e.x2,e.y1),new l.P(e.x2,e.y2),new l.P(e.x1,e.y2)];l.aK(s,d)&&(g[c.bucketInstanceId][c.featureIndex]=!0,void 0===y[c.bucketInstanceId]&&(y[c.bucketInstanceId]=[]),y[c.bucketInstanceId].push(c.featureIndex))}return y}insertCollisionBox(e,s,l,c,d,p){(l?this.ignoredGrid:this.grid).insert({bucketInstanceId:c,featureIndex:d,collisionGroupID:p,overlapMode:s},e[0],e[1],e[2],e[3])}insertCollisionCircles(e,s,l,c,d,p){const f=l?this.ignoredGrid:this.grid,m={bucketInstanceId:c,featureIndex:d,collisionGroupID:p,overlapMode:s};for(let s=0;s=this.screenRightBoundary||c<_i||s>this.screenBottomBoundary}isInsideGrid(e,s,l,c){return l>=0&&e=0&&sthis.projectAndGetPerspectiveRatio(e.x,e.y,d,g,b)));re=e.some((e=>!e.isOccluded)),J=e.map((e=>new l.P(e.x,e.y)))}else re=!0;return{box:l.aL(J),allPointsOccluded:!re}}}class lt{constructor(e,s,l,c){this.opacity=e?Math.max(0,Math.min(1,e.opacity+(e.placed?s:-s))):c&&l?1:0,this.placed=l}isHidden(){return 0===this.opacity&&!this.placed}}class ct{constructor(e,s,l,c,d){this.text=new lt(e?e.text:null,s,l,d),this.icon=new lt(e?e.icon:null,s,c,d)}isHidden(){return this.text.isHidden()&&this.icon.isHidden()}}class ht{constructor(e,s,l){this.text=e,this.icon=s,this.skipFade=l}}class ut{constructor(e,s,l,c,d){this.bucketInstanceId=e,this.featureIndex=s,this.sourceLayerIndex=l,this.bucketIndex=c,this.tileID=d}}class dt{constructor(e){this.crossSourceCollisions=e,this.maxGroupID=0,this.collisionGroups={}}get(e){if(this.crossSourceCollisions)return{ID:0,predicate:null};if(!this.collisionGroups[e]){const s=++this.maxGroupID;this.collisionGroups[e]={ID:s,predicate:e=>e.collisionGroupID===s}}return this.collisionGroups[e]}}function gi(e,s,c,d,p){const{horizontalAlign:f,verticalAlign:m}=l.aS(e);return new l.P(-(f-.5)*s+d[0]*p,-(m-.5)*c+d[1]*p)}class pt{constructor(e,s,l,c,d){this.transform=e.clone(),this.terrain=s,this.collisionIndex=new nt(this.transform),this.placements={},this.opacities={},this.variableOffsets={},this.stale=!1,this.commitTime=0,this.fadeDuration=l,this.retainedQueryData={},this.collisionGroups=new dt(c),this.collisionCircleArrays={},this.collisionBoxArrays=new Map,this.prevPlacement=d,d&&(d.prevPlacement=void 0),this.placedOrientations={}}_getTerrainElevationFunc(e){const s=this.terrain;return s?(l,c)=>s.getElevation(e,l,c):null}getBucketParts(e,s,c,d){const p=c.getBucket(s),f=c.latestFeatureIndex;if(!p||!f||s.id!==p.layerIds[0])return;const m=c.collisionBoxArray,_=p.layers[0].layout,g=p.layers[0].paint,y=Math.pow(2,this.transform.zoom-c.tileID.overscaledZ),b=c.tileSize/l.a5,T=c.tileID.toUnwrapped(),P="map"===_.get("text-rotation-alignment"),S=l.aN(c,1,this.transform.zoom),I=l.aO(this.collisionIndex.transform,c,g.get("text-translate"),g.get("text-translate-anchor")),C=l.aO(this.collisionIndex.transform,c,g.get("icon-translate"),g.get("icon-translate-anchor")),z=wt(P,this.transform,S);this.retainedQueryData[p.bucketInstanceId]=new ut(p.bucketInstanceId,f,p.sourceLayerIndex,p.index,c.tileID);const L={bucket:p,layout:_,translationText:I,translationIcon:C,unwrappedTileID:T,pitchedLabelPlaneMatrix:z,scale:y,textPixelRatio:b,holdingForFade:c.holdingForSymbolFade(),collisionBoxArray:m,partiallyEvaluatedTextSize:l.ay(p.textSizeData,this.transform.zoom),collisionGroup:this.collisionGroups.get(p.sourceID)};if(d)for(const s of p.sortKeyRanges){const{sortKey:l,symbolInstanceStart:c,symbolInstanceEnd:d}=s;e.push({sortKey:l,symbolInstanceStart:c,symbolInstanceEnd:d,parameters:L})}else e.push({symbolInstanceStart:0,symbolInstanceEnd:p.symbolInstances.length,parameters:L})}attemptAnchorPlacement(e,s,c,d,p,f,m,_,g,y,b,T,P,S,I,C,z,L,F,B){const O=l.aP[e.textAnchor],j=[e.textOffset0,e.textOffset1],G=gi(O,c,d,j,p),U=this.collisionIndex.placeCollisionBox(s,T,_,g,y,m,f,C,b.predicate,F,G,B);if((!L||this.collisionIndex.placeCollisionBox(L,T,_,g,y,m,f,z,b.predicate,F,G,B).placeable)&&U.placeable){let e;if(this.prevPlacement&&this.prevPlacement.variableOffsets[P.crossTileID]&&this.prevPlacement.placements[P.crossTileID]&&this.prevPlacement.placements[P.crossTileID].text&&(e=this.prevPlacement.variableOffsets[P.crossTileID].anchor),0===P.crossTileID)throw new Error("symbolInstance.crossTileID can't be 0");return this.variableOffsets[P.crossTileID]={textOffset:j,width:c,height:d,anchor:O,textBoxScale:p,prevAnchor:e},this.markUsedJustification(S,O,P,I),S.allowVerticalPlacement&&(this.markUsedOrientation(S,I,P),this.placedOrientations[P.crossTileID]=I),{shift:G,placedGlyphBoxes:U}}}placeLayerBucketPart(e,s,c){const{bucket:d,layout:p,translationText:f,translationIcon:m,unwrappedTileID:_,pitchedLabelPlaneMatrix:g,textPixelRatio:y,holdingForFade:b,collisionBoxArray:T,partiallyEvaluatedTextSize:P,collisionGroup:S}=e.parameters,I=p.get("text-optional"),C=p.get("icon-optional"),z=l.aQ(p,"text-overlap","text-allow-overlap"),L="always"===z,F=l.aQ(p,"icon-overlap","icon-allow-overlap"),B="always"===F,O="map"===p.get("text-rotation-alignment"),j="map"===p.get("text-pitch-alignment"),G="none"!==p.get("icon-text-fit"),U="viewport-y"===p.get("symbol-z-order"),q=L&&(B||!d.hasIconData()||C),Z=B&&(L||!d.hasTextData()||I);!d.collisionArrays&&T&&d.deserializeCollisionBoxes(T);const W=this.retainedQueryData[d.bucketInstanceId].tileID,J=this._getTerrainElevationFunc(W),re=this.transform.getFastPathSimpleProjectionMatrix(W),se=(e,T,B)=>{var U,se;if(s[e.crossTileID])return;if(b)return void(this.placements[e.crossTileID]=new ht(!1,!1,!1));let oe=!1,le=!1,ce=!0,he=null,ue={box:null,placeable:!1,offscreen:null,occluded:!1},pe={placeable:!1},fe=null,me=null,ge=null,ye=0,xe=0,ve=0;T.textFeatureIndex?ye=T.textFeatureIndex:e.useRuntimeCollisionCircles&&(ye=e.featureIndex),T.verticalTextFeatureIndex&&(xe=T.verticalTextFeatureIndex);const be=T.textBox;if(be){const s=s=>{let c=l.az.horizontal;if(d.allowVerticalPlacement&&!s&&this.prevPlacement){const s=this.prevPlacement.placedOrientations[e.crossTileID];s&&(this.placedOrientations[e.crossTileID]=s,c=s,this.markUsedOrientation(d,c,e))}return c},p=(s,c)=>{if(d.allowVerticalPlacement&&e.numVerticalGlyphVertices>0&&T.verticalTextBox){for(const e of d.writingModes)if(e===l.az.vertical?(ue=c(),pe=ue):ue=s(),ue&&ue.placeable)break}else ue=s()},g=e.textAnchorOffsetStartIndex,b=e.textAnchorOffsetEndIndex;if(b===g){const c=(s,l)=>{const c=this.collisionIndex.placeCollisionBox(s,z,y,W,_,j,O,f,S.predicate,J,void 0,re);return c&&c.placeable&&(this.markUsedOrientation(d,l,e),this.placedOrientations[e.crossTileID]=l),c};p((()=>c(be,l.az.horizontal)),(()=>{const s=T.verticalTextBox;return d.allowVerticalPlacement&&e.numVerticalGlyphVertices>0&&s?c(s,l.az.vertical):{box:null,offscreen:null}})),s(ue&&ue.placeable)}else{let P=l.aP[null===(se=null===(U=this.prevPlacement)||void 0===U?void 0:U.variableOffsets[e.crossTileID])||void 0===se?void 0:se.anchor];const I=(s,l,p)=>{const T=s.x2-s.x1,I=s.y2-s.y1,C=e.textBoxScale,L=G&&"never"===F?l:null;let B=null,U="never"===z?1:2,q="never";P&&U++;for(let l=0;lI(be,T.iconBox,l.az.horizontal)),(()=>{const s=T.verticalTextBox;return d.allowVerticalPlacement&&(!ue||!ue.placeable)&&e.numVerticalGlyphVertices>0&&s?I(s,T.verticalIconBox,l.az.vertical):{box:null,occluded:!0,offscreen:null}})),ue&&(oe=ue.placeable,ce=ue.offscreen);const C=s(ue&&ue.placeable);if(!oe&&this.prevPlacement){const s=this.prevPlacement.variableOffsets[e.crossTileID];s&&(this.variableOffsets[e.crossTileID]=s,this.markUsedJustification(d,s.anchor,e,C))}}}if(fe=ue,oe=fe&&fe.placeable,ce=fe&&fe.offscreen,e.useRuntimeCollisionCircles&&e.centerJustifiedTextSymbolIndex>=0){const s=d.text.placedSymbolArray.get(e.centerJustifiedTextSymbolIndex),m=l.aA(d.textSizeData,P,s),y=p.get("text-padding");me=this.collisionIndex.placeCollisionCircles(z,s,d.lineVertexArray,d.glyphOffsetArray,m,_,g,c,j,S.predicate,e.collisionCircleDiameter,y,f,J),me.circles.length&&me.collisionDetected&&!c&&l.w("Collisions detected, but collision boxes are not shown"),oe=L||me.circles.length>0&&!me.collisionDetected,ce=ce&&me.offscreen}if(T.iconFeatureIndex&&(ve=T.iconFeatureIndex),T.iconBox){const e=e=>this.collisionIndex.placeCollisionBox(e,F,y,W,_,j,O,m,S.predicate,J,G&&he?he:void 0,re);pe&&pe.placeable&&T.verticalIconBox?(ge=e(T.verticalIconBox),le=ge.placeable):(ge=e(T.iconBox),le=ge.placeable),ce=ce&&ge.offscreen}const we=I||0===e.numHorizontalGlyphVertices&&0===e.numVerticalGlyphVertices,Se=C||0===e.numIconVertices;we||Se?Se?we||(le=le&&oe):oe=le&&oe:le=oe=le&&oe;const Me=le&&ge.placeable;if(oe&&fe.placeable&&this.collisionIndex.insertCollisionBox(fe.box,z,p.get("text-ignore-placement"),d.bucketInstanceId,pe&&pe.placeable&&xe?xe:ye,S.ID),Me&&this.collisionIndex.insertCollisionBox(ge.box,F,p.get("icon-ignore-placement"),d.bucketInstanceId,ve,S.ID),me&&oe&&this.collisionIndex.insertCollisionCircles(me.circles,z,p.get("text-ignore-placement"),d.bucketInstanceId,ye,S.ID),c&&this.storeCollisionData(d.bucketInstanceId,B,T,fe,ge,me),0===e.crossTileID)throw new Error("symbolInstance.crossTileID can't be 0");if(0===d.bucketInstanceId)throw new Error("bucket.bucketInstanceId can't be 0");this.placements[e.crossTileID]=new ht((oe||q)&&!(null==fe?void 0:fe.occluded),(le||Z)&&!(null==ge?void 0:ge.occluded),ce||d.justReloaded),s[e.crossTileID]=!0};if(U){if(0!==e.symbolInstanceStart)throw new Error("bucket.bucketInstanceId should be 0");const s=d.getSortedSymbolIndexes(-this.transform.bearingInRadians);for(let e=s.length-1;e>=0;--e){const l=s[e];se(d.symbolInstances.get(l),d.collisionArrays[l],l)}}else for(let s=e.symbolInstanceStart;s=0&&(e.text.placedSymbolArray.get(s).crossTileID=p>=0&&s!==p?0:c.crossTileID)}markUsedOrientation(e,s,c){const d=s===l.az.horizontal||s===l.az.horizontalOnly?s:0,p=s===l.az.vertical?s:0,f=[c.leftJustifiedTextSymbolIndex,c.centerJustifiedTextSymbolIndex,c.rightJustifiedTextSymbolIndex];for(const s of f)e.text.placedSymbolArray.get(s).placedOrientation=d;c.verticalPlacedTextSymbolIndex&&(e.text.placedSymbolArray.get(c.verticalPlacedTextSymbolIndex).placedOrientation=p)}commit(e){this.commitTime=e,this.zoomAtLastRecencyCheck=this.transform.zoom;const s=this.prevPlacement;let l=!1;this.prevZoomAdjustment=s?s.zoomAdjustment(this.transform.zoom):0;const c=s?s.symbolFadeChange(e):1,d=s?s.opacities:{},p=s?s.variableOffsets:{},f=s?s.placedOrientations:{};for(const e in this.placements){const s=this.placements[e],p=d[e];p?(this.opacities[e]=new ct(p,c,s.text,s.icon),l=l||s.text!==p.text.placed||s.icon!==p.icon.placed):(this.opacities[e]=new ct(null,c,s.text,s.icon,s.skipFade),l=l||s.text||s.icon)}for(const e in d){const s=d[e];if(!this.opacities[e]){const d=new ct(s,c,!1,!1);d.isHidden()||(this.opacities[e]=d,l=l||s.text.placed||s.icon.placed)}}for(const e in p)this.variableOffsets[e]||!this.opacities[e]||this.opacities[e].isHidden()||(this.variableOffsets[e]=p[e]);for(const e in f)this.placedOrientations[e]||!this.opacities[e]||this.opacities[e].isHidden()||(this.placedOrientations[e]=f[e]);if(s&&void 0===s.lastPlacementChangeTime)throw new Error("Last placement time for previous placement is not defined");l?this.lastPlacementChangeTime=e:"number"!=typeof this.lastPlacementChangeTime&&(this.lastPlacementChangeTime=s?s.lastPlacementChangeTime:e)}updateLayerOpacities(e,s){const l={};for(const c of s){const s=c.getBucket(e);s&&c.latestFeatureIndex&&e.id===s.layerIds[0]&&this.updateBucketOpacities(s,c.tileID,l,c.collisionBoxArray)}}updateBucketOpacities(e,s,c,d){e.hasTextData()&&(e.text.opacityVertexArray.clear(),e.text.hasVisibleVertices=!1),e.hasIconData()&&(e.icon.opacityVertexArray.clear(),e.icon.hasVisibleVertices=!1),e.hasIconCollisionBoxData()&&e.iconCollisionBox.collisionVertexArray.clear(),e.hasTextCollisionBoxData()&&e.textCollisionBox.collisionVertexArray.clear();const p=e.layers[0],f=p.layout,m=new ct(null,0,!1,!1,!0),_=f.get("text-allow-overlap"),g=f.get("icon-allow-overlap"),y=p._unevaluatedLayout.hasValue("text-variable-anchor")||p._unevaluatedLayout.hasValue("text-variable-anchor-offset"),b="map"===f.get("text-rotation-alignment"),T="map"===f.get("text-pitch-alignment"),P="none"!==f.get("icon-text-fit"),S=new ct(null,0,_&&(g||!e.hasIconData()||f.get("icon-optional")),g&&(_||!e.hasTextData()||f.get("text-optional")),!0);!e.collisionArrays&&d&&(e.hasIconCollisionBoxData()||e.hasTextCollisionBoxData())&&e.deserializeCollisionBoxes(d);const I=(e,s,l)=>{for(let c=0;c0,L=this.placedOrientations[d.crossTileID],F=L===l.az.vertical,B=L===l.az.horizontal||L===l.az.horizontalOnly;if(p>0||f>0){const s=Ai(g.text);I(e.text,p,F?Li:s),I(e.text,f,B?Li:s);const l=g.text.isHidden();[d.rightJustifiedTextSymbolIndex,d.centerJustifiedTextSymbolIndex,d.leftJustifiedTextSymbolIndex].forEach((s=>{s>=0&&(e.text.placedSymbolArray.get(s).hidden=l||F?1:0)})),d.verticalPlacedTextSymbolIndex>=0&&(e.text.placedSymbolArray.get(d.verticalPlacedTextSymbolIndex).hidden=l||B?1:0);const c=this.variableOffsets[d.crossTileID];c&&this.markUsedJustification(e,c.anchor,d,L);const m=this.placedOrientations[d.crossTileID];m&&(this.markUsedJustification(e,"left",d,m),this.markUsedOrientation(e,m,d))}if(z){const s=Ai(g.icon),l=!(P&&d.verticalPlacedIconSymbolIndex&&F);d.placedIconSymbolIndex>=0&&(I(e.icon,d.numIconVertices,l?s:Li),e.icon.placedSymbolArray.get(d.placedIconSymbolIndex).hidden=g.icon.isHidden()),d.verticalPlacedIconSymbolIndex>=0&&(I(e.icon,d.numVerticalIconVertices,l?Li:s),e.icon.placedSymbolArray.get(d.verticalPlacedIconSymbolIndex).hidden=g.icon.isHidden())}const O=C&&C.has(s)?C.get(s):{text:null,icon:null};if(e.hasIconCollisionBoxData()||e.hasTextCollisionBoxData()){const c=e.collisionArrays[s];if(c){let s=new l.P(0,0);if(c.textBox||c.verticalTextBox){let l=!0;if(y){const e=this.variableOffsets[_];e?(s=gi(e.anchor,e.width,e.height,e.textOffset,e.textBoxScale),b&&s._rotate(T?-this.transform.bearingInRadians:this.transform.bearingInRadians)):l=!1}if(c.textBox||c.verticalTextBox){let d;c.textBox&&(d=F),c.verticalTextBox&&(d=B),yi(e.textCollisionBox.collisionVertexArray,g.text.placed,!l||d,O.text,s.x,s.y)}}if(c.iconBox||c.verticalIconBox){const l=Boolean(!B&&c.verticalIconBox);let d;c.iconBox&&(d=l),c.verticalIconBox&&(d=!l),yi(e.iconCollisionBox.collisionVertexArray,g.icon.placed,d,O.icon,P?s.x:0,P?s.y:0)}}}}if(e.sortFeatures(-this.transform.bearingInRadians),this.retainedQueryData[e.bucketInstanceId]&&(this.retainedQueryData[e.bucketInstanceId].featureSortOrder=e.featureSortOrder),e.hasTextData()&&e.text.opacityVertexBuffer&&e.text.opacityVertexBuffer.updateData(e.text.opacityVertexArray),e.hasIconData()&&e.icon.opacityVertexBuffer&&e.icon.opacityVertexBuffer.updateData(e.icon.opacityVertexArray),e.hasIconCollisionBoxData()&&e.iconCollisionBox.collisionVertexBuffer&&e.iconCollisionBox.collisionVertexBuffer.updateData(e.iconCollisionBox.collisionVertexArray),e.hasTextCollisionBoxData()&&e.textCollisionBox.collisionVertexBuffer&&e.textCollisionBox.collisionVertexBuffer.updateData(e.textCollisionBox.collisionVertexArray),e.text.opacityVertexArray.length!==e.text.layoutVertexArray.length/4)throw new Error(`bucket.text.opacityVertexArray.length (= ${e.text.opacityVertexArray.length}) !== bucket.text.layoutVertexArray.length (= ${e.text.layoutVertexArray.length}) / 4`);if(e.icon.opacityVertexArray.length!==e.icon.layoutVertexArray.length/4)throw new Error(`bucket.icon.opacityVertexArray.length (= ${e.icon.opacityVertexArray.length}) !== bucket.icon.layoutVertexArray.length (= ${e.icon.layoutVertexArray.length}) / 4`);e.bucketInstanceId in this.collisionCircleArrays&&(e.collisionCircleArray=this.collisionCircleArrays[e.bucketInstanceId],delete this.collisionCircleArrays[e.bucketInstanceId])}symbolFadeChange(e){return 0===this.fadeDuration?1:(e-this.commitTime)/this.fadeDuration+this.prevZoomAdjustment}zoomAdjustment(e){return Math.max(0,(this.transform.zoom-e)/1.5)}hasTransitions(e){return this.stale||e-this.lastPlacementChangeTimee}setStale(){this.stale=!0}}function yi(e,s,l,c,d,p){c&&0!==c.length||(c=[0,0,0,0]);const f=c[0]-_i,m=c[1]-_i,_=c[2]-_i,g=c[3]-_i;e.emplaceBack(s?1:0,l?1:0,d||0,p||0,f,m),e.emplaceBack(s?1:0,l?1:0,d||0,p||0,_,m),e.emplaceBack(s?1:0,l?1:0,d||0,p||0,_,g),e.emplaceBack(s?1:0,l?1:0,d||0,p||0,f,g)}const xi=Math.pow(2,25),vi=Math.pow(2,24),bi=Math.pow(2,17),wi=Math.pow(2,16),Ii=Math.pow(2,9),Ei=Math.pow(2,8),Ci=Math.pow(2,1);function Ai(e){if(0===e.opacity&&!e.placed)return 0;if(1===e.opacity&&e.placed)return 4294967295;const s=e.placed?1:0,l=Math.floor(127*e.opacity);return l*xi+s*vi+l*bi+s*wi+l*Ii+s*Ei+l*Ci+s}const Li=0;class Ct{constructor(e){this._sortAcrossTiles="viewport-y"!==e.layout.get("symbol-z-order")&&!e.layout.get("symbol-sort-key").isConstant(),this._currentTileIndex=0,this._currentPartIndex=0,this._seenCrossTileIDs={},this._bucketParts=[]}continuePlacement(e,s,l,c,d){const p=this._bucketParts;for(;this._currentTileIndexe.sortKey-s.sortKey)));this._currentPartIndex!this._forceFullPlacement&&y()-c>2;for(;this._currentPlacementIndex>=0;){const c=s[e[this._currentPlacementIndex]],p=this.placement.collisionIndex.transform.zoom;if("symbol"===c.type&&(!c.minzoom||c.minzoom<=p)&&(!c.maxzoom||c.maxzoom>p)){if(this._inProgressLayer||(this._inProgressLayer=new Ct(c)),this._inProgressLayer.continuePlacement(l[c.source],this.placement,this._showCollisionBoxes,c,d))return;delete this._inProgressLayer}this._currentPlacementIndex--}this._done=!0}commit(e){return this.placement.commit(e),this.placement}}const Fi=512/l.a5/2;class Et{constructor(e,s,c){this.tileID=e,this.bucketInstanceId=c,this._symbolsByKey={};const d=new Map;for(let e=0;e({x:Math.floor(e.anchorX*Fi),y:Math.floor(e.anchorY*Fi)}))),crossTileIDs:s.map((e=>e.crossTileID))};if(c.positions.length>128){const e=new l.aT(c.positions.length,16,Uint16Array);for(const{x:s,y:l}of c.positions)e.add(s,l);e.finish(),delete c.positions,c.index=e}this._symbolsByKey[e]=c}}getScaledCoordinates(e,s){const{x:c,y:d,z:p}=this.tileID.canonical,{x:f,y:m,z:_}=s.canonical,g=Fi/Math.pow(2,_-p),y=(m*l.a5+e.anchorY)*g,b=d*l.a5*Fi;return{x:Math.floor((f*l.a5+e.anchorX)*g-c*l.a5*Fi),y:Math.floor(y-b)}}findMatches(e,s,l){const c=this.tileID.canonical.ze))}}class St{constructor(){this.maxCrossTileID=0}generate(){return++this.maxCrossTileID}}class Rt{constructor(){this.indexes={},this.usedCrossTileIDs={},this.lng=0}handleWrapJump(e){const s=Math.round((e-this.lng)/360);if(0!==s)for(const e in this.indexes){const l=this.indexes[e],c={};for(const e in l){const d=l[e];d.tileID=d.tileID.unwrapTo(d.tileID.wrap+s),c[d.tileID.key]=d}this.indexes[e]=c}this.lng=e}addBucket(e,s,l){if(this.indexes[e.overscaledZ]&&this.indexes[e.overscaledZ][e.key]){if(this.indexes[e.overscaledZ][e.key].bucketInstanceId===s.bucketInstanceId)return!1;this.removeBucketCrossTileIDs(e.overscaledZ,this.indexes[e.overscaledZ][e.key])}for(let e=0;ee.overscaledZ)for(const l in d){const p=d[l];p.tileID.isChildOf(e)&&p.findMatches(s.symbolInstances,e,c)}else{const p=d[e.scaledTo(Number(l)).key];p&&p.findMatches(s.symbolInstances,e,c)}}for(let e=0;e{s[e]=!0}));for(const e in this.layerIndexes)s[e]||delete this.layerIndexes[e]}}var Oi="void main() {fragColor=vec4(1.0);}";const Vi={prelude:ji("#ifdef GL_ES\nprecision mediump float;\n#else\n#if !defined(lowp)\n#define lowp\n#endif\n#if !defined(mediump)\n#define mediump\n#endif\n#if !defined(highp)\n#define highp\n#endif\n#endif\nout highp vec4 fragColor;","#ifdef GL_ES\nprecision highp float;\n#else\n#if !defined(lowp)\n#define lowp\n#endif\n#if !defined(mediump)\n#define mediump\n#endif\n#if !defined(highp)\n#define highp\n#endif\n#endif\nvec2 unpack_float(const float packedValue) {int packedIntValue=int(packedValue);int v0=packedIntValue/256;return vec2(v0,packedIntValue-v0*256);}vec2 unpack_opacity(const float packedOpacity) {int intOpacity=int(packedOpacity)/2;return vec2(float(intOpacity)/127.0,mod(packedOpacity,2.0));}vec4 decode_color(const vec2 encodedColor) {return vec4(unpack_float(encodedColor[0])/255.0,unpack_float(encodedColor[1])/255.0\n);}float unpack_mix_vec2(const vec2 packedValue,const float t) {return mix(packedValue[0],packedValue[1],t);}vec4 unpack_mix_color(const vec4 packedColors,const float t) {vec4 minColor=decode_color(vec2(packedColors[0],packedColors[1]));vec4 maxColor=decode_color(vec2(packedColors[2],packedColors[3]));return mix(minColor,maxColor,t);}vec2 get_pattern_pos(const vec2 pixel_coord_upper,const vec2 pixel_coord_lower,const vec2 pattern_size,const float tile_units_to_pixels,const vec2 pos) {vec2 offset=mod(mod(mod(pixel_coord_upper,pattern_size)*256.0,pattern_size)*256.0+pixel_coord_lower,pattern_size);return (tile_units_to_pixels*pos+offset)/pattern_size;}mat3 rotationMatrixFromAxisAngle(vec3 u,float angle) {float c=cos(angle);float s=sin(angle);float c2=1.0-c;return mat3(u.x*u.x*c2+ c,u.x*u.y*c2-u.z*s,u.x*u.z*c2+u.y*s,u.y*u.x*c2+u.z*s,u.y*u.y*c2+ c,u.y*u.z*c2-u.x*s,u.z*u.x*c2-u.y*s,u.z*u.y*c2+u.x*s,u.z*u.z*c2+ c\n);}\n#ifdef TERRAIN3D\nuniform sampler2D u_terrain;uniform float u_terrain_dim;uniform mat4 u_terrain_matrix;uniform vec4 u_terrain_unpack;uniform float u_terrain_exaggeration;uniform highp sampler2D u_depth;\n#endif\nconst highp vec4 bitSh=vec4(256.*256.*256.,256.*256.,256.,1.);const highp vec4 bitShifts=vec4(1.)/bitSh;highp float unpack(highp vec4 color) {return dot(color,bitShifts);}highp float depthOpacity(vec3 frag) {\n#ifdef TERRAIN3D\nhighp float d=unpack(texture(u_depth,frag.xy*0.5+0.5))+0.0001-frag.z;return 1.0-max(0.0,min(1.0,-d*500.0));\n#else\nreturn 1.0;\n#endif\n}float calculate_visibility(vec4 pos) {\n#ifdef TERRAIN3D\nvec3 frag=pos.xyz/pos.w;highp float d=depthOpacity(frag);if (d > 0.95) return 1.0;return (d+depthOpacity(frag+vec3(0.0,0.01,0.0)))/2.0;\n#else\nreturn 1.0;\n#endif\n}float ele(vec2 pos) {\n#ifdef TERRAIN3D\nvec4 rgb=(texture(u_terrain,pos)*255.0)*u_terrain_unpack;return rgb.r+rgb.g+rgb.b-u_terrain_unpack.a;\n#else\nreturn 0.0;\n#endif\n}float get_elevation(vec2 pos) {\n#ifdef TERRAIN3D\n#ifdef GLOBE\nif ((pos.y <-32767.5) || (pos.y > 32766.5)) {return 0.0;}\n#endif\nvec2 coord=(u_terrain_matrix*vec4(pos,0.0,1.0)).xy*u_terrain_dim+1.0;vec2 f=fract(coord);vec2 c=(floor(coord)+0.5)/(u_terrain_dim+2.0);float d=1.0/(u_terrain_dim+2.0);float tl=ele(c);float tr=ele(c+vec2(d,0.0));float bl=ele(c+vec2(0.0,d));float br=ele(c+vec2(d,d));float elevation=mix(mix(tl,tr,f.x),mix(bl,br,f.x),f.y);return elevation*u_terrain_exaggeration;\n#else\nreturn 0.0;\n#endif\n}const float PI=3.141592653589793;uniform mat4 u_projection_matrix;"),projectionMercator:ji("","float projectLineThickness(float tileY) {return 1.0;}float projectCircleRadius(float tileY) {return 1.0;}vec4 projectTile(vec2 p) {vec4 result=u_projection_matrix*vec4(p,0.0,1.0);return result;}vec4 projectTile(vec2 p,vec2 rawPos) {vec4 result=u_projection_matrix*vec4(p,0.0,1.0);if (rawPos.y <-32767.5 || rawPos.y > 32766.5) {result.z=-10000000.0;}return result;}vec4 projectTileWithElevation(vec2 posInTile,float elevation) {return u_projection_matrix*vec4(posInTile,elevation,1.0);}vec4 projectTileFor3D(vec2 posInTile,float elevation) {return projectTileWithElevation(posInTile,elevation);}"),projectionGlobe:ji("","#define GLOBE_RADIUS 6371008.8\nuniform highp vec4 u_projection_tile_mercator_coords;uniform highp vec4 u_projection_clipping_plane;uniform highp float u_projection_transition;uniform mat4 u_projection_fallback_matrix;vec3 globeRotateVector(vec3 vec,vec2 angles) {vec3 axisRight=vec3(vec.z,0.0,-vec.x);vec3 axisUp=cross(axisRight,vec);axisRight=normalize(axisRight);axisUp=normalize(axisUp);vec2 t=tan(angles);return normalize(vec+axisRight*t.x+axisUp*t.y);}mat3 globeGetRotationMatrix(vec3 spherePos) {vec3 axisRight=vec3(spherePos.z,0.0,-spherePos.x);vec3 axisDown=cross(axisRight,spherePos);axisRight=normalize(axisRight);axisDown=normalize(axisDown);return mat3(axisRight,axisDown,spherePos\n);}float circumferenceRatioAtTileY(float tileY) {float mercator_pos_y=u_projection_tile_mercator_coords.y+u_projection_tile_mercator_coords.w*tileY;float spherical_y=2.0*atan(exp(PI-(mercator_pos_y*PI*2.0)))-PI*0.5;return cos(spherical_y);}float projectLineThickness(float tileY) {float thickness=1.0/circumferenceRatioAtTileY(tileY); \nif (u_projection_transition < 0.999) {return mix(1.0,thickness,u_projection_transition);} else {return thickness;}}vec3 projectToSphere(vec2 translatedPos,vec2 rawPos) {vec2 mercator_pos=u_projection_tile_mercator_coords.xy+u_projection_tile_mercator_coords.zw*translatedPos;vec2 spherical;spherical.x=mercator_pos.x*PI*2.0+PI;spherical.y=2.0*atan(exp(PI-(mercator_pos.y*PI*2.0)))-PI*0.5;float len=cos(spherical.y);vec3 pos=vec3(sin(spherical.x)*len,sin(spherical.y),cos(spherical.x)*len\n);if (rawPos.y <-32767.5) {pos=vec3(0.0,1.0,0.0);}if (rawPos.y > 32766.5) {pos=vec3(0.0,-1.0,0.0);}return pos;}vec3 projectToSphere(vec2 posInTile) {return projectToSphere(posInTile,vec2(0.0,0.0));}float globeComputeClippingZ(vec3 spherePos) {return (1.0-(dot(spherePos,u_projection_clipping_plane.xyz)+u_projection_clipping_plane.w));}vec4 interpolateProjection(vec2 posInTile,vec3 spherePos,float elevation) {vec3 elevatedPos=spherePos*(1.0+elevation/GLOBE_RADIUS);vec4 globePosition=u_projection_matrix*vec4(elevatedPos,1.0);globePosition.z=globeComputeClippingZ(elevatedPos)*globePosition.w;if (u_projection_transition > 0.999) {return globePosition;}vec4 flatPosition=u_projection_fallback_matrix*vec4(posInTile,elevation,1.0);const float z_globeness_threshold=0.2;vec4 result=globePosition;result.z=mix(0.0,globePosition.z,clamp((u_projection_transition-z_globeness_threshold)/(1.0-z_globeness_threshold),0.0,1.0));result.xyw=mix(flatPosition.xyw,globePosition.xyw,u_projection_transition);if ((posInTile.y <-32767.5) || (posInTile.y > 32766.5)) {result=globePosition;const float poles_hidden_anim_percentage=0.02;result.z=mix(globePosition.z,100.0,pow(max((1.0-u_projection_transition)/poles_hidden_anim_percentage,0.0),8.0));}return result;}vec4 interpolateProjectionFor3D(vec2 posInTile,vec3 spherePos,float elevation) {vec3 elevatedPos=spherePos*(1.0+elevation/GLOBE_RADIUS);vec4 globePosition=u_projection_matrix*vec4(elevatedPos,1.0);if (u_projection_transition > 0.999) {return globePosition;}vec4 fallbackPosition=u_projection_fallback_matrix*vec4(posInTile,elevation,1.0);return mix(fallbackPosition,globePosition,u_projection_transition);}vec4 projectTile(vec2 posInTile) {return interpolateProjection(posInTile,projectToSphere(posInTile),0.0);}vec4 projectTile(vec2 posInTile,vec2 rawPos) {return interpolateProjection(posInTile,projectToSphere(posInTile,rawPos),0.0);}vec4 projectTileWithElevation(vec2 posInTile,float elevation) {return interpolateProjection(posInTile,projectToSphere(posInTile),elevation);}vec4 projectTileFor3D(vec2 posInTile,float elevation) {vec3 spherePos=projectToSphere(posInTile,posInTile);return interpolateProjectionFor3D(posInTile,spherePos,elevation);}"),background:ji("uniform vec4 u_color;uniform float u_opacity;void main() {fragColor=u_color*u_opacity;\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","in vec2 a_pos;void main() {gl_Position=projectTile(a_pos);}"),backgroundPattern:ji("uniform vec2 u_pattern_tl_a;uniform vec2 u_pattern_br_a;uniform vec2 u_pattern_tl_b;uniform vec2 u_pattern_br_b;uniform vec2 u_texsize;uniform float u_mix;uniform float u_opacity;uniform sampler2D u_image;in vec2 v_pos_a;in vec2 v_pos_b;void main() {vec2 imagecoord=mod(v_pos_a,1.0);vec2 pos=mix(u_pattern_tl_a/u_texsize,u_pattern_br_a/u_texsize,imagecoord);vec4 color1=texture(u_image,pos);vec2 imagecoord_b=mod(v_pos_b,1.0);vec2 pos2=mix(u_pattern_tl_b/u_texsize,u_pattern_br_b/u_texsize,imagecoord_b);vec4 color2=texture(u_image,pos2);fragColor=mix(color1,color2,u_mix)*u_opacity;\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","uniform vec2 u_pattern_size_a;uniform vec2 u_pattern_size_b;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform float u_scale_a;uniform float u_scale_b;uniform float u_tile_units_to_pixels;in vec2 a_pos;out vec2 v_pos_a;out vec2 v_pos_b;void main() {gl_Position=projectTile(a_pos);v_pos_a=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,u_scale_a*u_pattern_size_a,u_tile_units_to_pixels,a_pos);v_pos_b=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,u_scale_b*u_pattern_size_b,u_tile_units_to_pixels,a_pos);}"),circle:ji("in vec3 v_data;in float v_visibility;\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define mediump float radius\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define highp vec4 stroke_color\n#pragma mapbox: define mediump float stroke_width\n#pragma mapbox: define lowp float stroke_opacity\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize mediump float radius\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize highp vec4 stroke_color\n#pragma mapbox: initialize mediump float stroke_width\n#pragma mapbox: initialize lowp float stroke_opacity\nvec2 extrude=v_data.xy;float extrude_length=length(extrude);float antialiased_blur=v_data.z;float opacity_t=smoothstep(0.0,antialiased_blur,extrude_length-1.0);float color_t=stroke_width < 0.01 ? 0.0 : smoothstep(antialiased_blur,0.0,extrude_length-radius/(radius+stroke_width));fragColor=v_visibility*opacity_t*mix(color*opacity,stroke_color*stroke_opacity,color_t);const float epsilon=0.5/255.0;if (fragColor.r < epsilon && fragColor.g < epsilon && fragColor.b < epsilon && fragColor.a < epsilon) {discard;}\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","uniform bool u_scale_with_map;uniform bool u_pitch_with_map;uniform vec2 u_extrude_scale;uniform highp float u_globe_extrude_scale;uniform lowp float u_device_pixel_ratio;uniform highp float u_camera_to_center_distance;uniform vec2 u_translate;in vec2 a_pos;out vec3 v_data;out float v_visibility;\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define mediump float radius\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define highp vec4 stroke_color\n#pragma mapbox: define mediump float stroke_width\n#pragma mapbox: define lowp float stroke_opacity\nvoid main(void) {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize mediump float radius\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize highp vec4 stroke_color\n#pragma mapbox: initialize mediump float stroke_width\n#pragma mapbox: initialize lowp float stroke_opacity\nvec2 pos_raw=a_pos+32768.0;vec2 extrude=vec2(mod(pos_raw,8.0)/7.0*2.0-1.0);vec2 circle_center=floor(pos_raw/8.0)+u_translate;float ele=get_elevation(circle_center);v_visibility=calculate_visibility(projectTileWithElevation(circle_center,ele));if (u_pitch_with_map) {\n#ifdef GLOBE\nvec3 center_vector=projectToSphere(circle_center);\n#endif\nfloat angle_scale=u_globe_extrude_scale;vec2 corner_position=circle_center;if (u_scale_with_map) {angle_scale*=(radius+stroke_width);corner_position+=extrude*u_extrude_scale*(radius+stroke_width);} else {\n#ifdef GLOBE\nvec4 projected_center=interpolateProjection(circle_center,center_vector,ele);\n#else\nvec4 projected_center=projectTileWithElevation(circle_center,ele);\n#endif\ncorner_position+=extrude*u_extrude_scale*(radius+stroke_width)*(projected_center.w/u_camera_to_center_distance);angle_scale*=(radius+stroke_width)*(projected_center.w/u_camera_to_center_distance);}\n#ifdef GLOBE\nvec2 angles=extrude*angle_scale;vec3 corner_vector=globeRotateVector(center_vector,angles);gl_Position=interpolateProjection(corner_position,corner_vector,ele);\n#else\ngl_Position=projectTileWithElevation(corner_position,ele);\n#endif\n} else {gl_Position=projectTileWithElevation(circle_center,ele);if (gl_Position.z/gl_Position.w > 1.0) {gl_Position.xy=vec2(10000.0);}if (u_scale_with_map) {gl_Position.xy+=extrude*(radius+stroke_width)*u_extrude_scale*u_camera_to_center_distance;} else {gl_Position.xy+=extrude*(radius+stroke_width)*u_extrude_scale*gl_Position.w;}}float antialiasblur=-max(1.0/u_device_pixel_ratio/(radius+stroke_width),blur);v_data=vec3(extrude.x,extrude.y,antialiasblur);}"),clippingMask:ji(Oi,"in vec2 a_pos;void main() {gl_Position=projectTile(a_pos);}"),heatmap:ji("uniform highp float u_intensity;in vec2 v_extrude;\n#pragma mapbox: define highp float weight\n#define GAUSS_COEF 0.3989422804014327\nvoid main() {\n#pragma mapbox: initialize highp float weight\nfloat d=-0.5*3.0*3.0*dot(v_extrude,v_extrude);float val=weight*u_intensity*GAUSS_COEF*exp(d);fragColor=vec4(val,1.0,1.0,1.0);\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","uniform float u_extrude_scale;uniform float u_opacity;uniform float u_intensity;uniform highp float u_globe_extrude_scale;in vec2 a_pos;out vec2 v_extrude;\n#pragma mapbox: define highp float weight\n#pragma mapbox: define mediump float radius\nconst highp float ZERO=1.0/255.0/16.0;\n#define GAUSS_COEF 0.3989422804014327\nvoid main(void) {\n#pragma mapbox: initialize highp float weight\n#pragma mapbox: initialize mediump float radius\nvec2 pos_raw=a_pos+32768.0;vec2 unscaled_extrude=vec2(mod(pos_raw,8.0)/7.0*2.0-1.0);float S=sqrt(-2.0*log(ZERO/weight/u_intensity/GAUSS_COEF))/3.0;v_extrude=S*unscaled_extrude;vec2 extrude=v_extrude*radius*u_extrude_scale;vec2 circle_center=floor(pos_raw/8.0);\n#ifdef GLOBE\nvec2 angles=v_extrude*radius*u_globe_extrude_scale;vec3 center_vector=projectToSphere(circle_center);vec3 corner_vector=globeRotateVector(center_vector,angles);gl_Position=interpolateProjection(circle_center+extrude,corner_vector,0.0);\n#else\ngl_Position=projectTileFor3D(circle_center+extrude,get_elevation(circle_center));\n#endif\n}"),heatmapTexture:ji("uniform sampler2D u_image;uniform sampler2D u_color_ramp;uniform float u_opacity;in vec2 v_pos;void main() {float t=texture(u_image,v_pos).r;vec4 color=texture(u_color_ramp,vec2(t,0.5));fragColor=color*u_opacity;\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(0.0);\n#endif\n}","uniform mat4 u_matrix;uniform vec2 u_world;in vec2 a_pos;out vec2 v_pos;void main() {gl_Position=u_matrix*vec4(a_pos*u_world,0,1);v_pos.x=a_pos.x;v_pos.y=1.0-a_pos.y;}"),collisionBox:ji("in float v_placed;in float v_notUsed;void main() {float alpha=0.5;fragColor=vec4(1.0,0.0,0.0,1.0)*alpha;if (v_placed > 0.5) {fragColor=vec4(0.0,0.0,1.0,0.5)*alpha;}if (v_notUsed > 0.5) {fragColor*=.1;}}","in vec2 a_anchor_pos;in vec2 a_placed;in vec2 a_box_real;uniform vec2 u_pixel_extrude_scale;out float v_placed;out float v_notUsed;void main() {gl_Position=projectTileWithElevation(a_anchor_pos,get_elevation(a_anchor_pos));gl_Position.xy=((a_box_real+0.5)*u_pixel_extrude_scale*2.0-1.0)*vec2(1.0,-1.0)*gl_Position.w;if (gl_Position.z/gl_Position.w < 1.1) {gl_Position.z=0.5;}v_placed=a_placed.x;v_notUsed=a_placed.y;}"),collisionCircle:ji("in float v_radius;in vec2 v_extrude;in float v_collision;void main() {float alpha=0.5;float stroke_radius=0.9;float distance_to_center=length(v_extrude);float distance_to_edge=abs(distance_to_center-v_radius);float opacity_t=smoothstep(-stroke_radius,0.0,-distance_to_edge);vec4 color=mix(vec4(0.0,0.0,1.0,0.5),vec4(1.0,0.0,0.0,1.0),v_collision);fragColor=color*alpha*opacity_t;}","in vec2 a_pos;in float a_radius;in vec2 a_flags;uniform vec2 u_viewport_size;out float v_radius;out vec2 v_extrude;out float v_collision;void main() {float radius=a_radius;float collision=a_flags.x;float vertexIdx=a_flags.y;vec2 quadVertexOffset=vec2(mix(-1.0,1.0,float(vertexIdx >=2.0)),mix(-1.0,1.0,float(vertexIdx >=1.0 && vertexIdx <=2.0)));vec2 quadVertexExtent=quadVertexOffset*radius;float padding_factor=1.2;v_radius=radius;v_extrude=quadVertexExtent*padding_factor;v_collision=collision;gl_Position=vec4((a_pos/u_viewport_size*2.0-1.0)*vec2(1.0,-1.0),0.0,1.0)+vec4(quadVertexExtent*padding_factor/u_viewport_size*2.0,0.0,0.0);}"),colorRelief:ji("#ifdef GL_ES\nprecision highp float;\n#endif\nuniform sampler2D u_image;uniform vec4 u_unpack;uniform sampler2D u_elevation_stops;uniform sampler2D u_color_stops;uniform int u_color_ramp_size;uniform float u_opacity;in vec2 v_pos;float getElevation(vec2 coord) {vec4 data=texture(u_image,coord)*255.0;data.a=-1.0;return dot(data,u_unpack);}float getElevationStop(int stop) {float x=(float(stop)+0.5)/float(u_color_ramp_size);vec4 data=texture(u_elevation_stops,vec2(x,0))*255.0;data.a=-1.0;return dot(data,u_unpack);}void main() {float el=getElevation(v_pos);int r=(u_color_ramp_size-1);int l=0;float el_l=getElevationStop(l);float el_r=getElevationStop(r);while(r-l > 1){int m=(r+l)/2;float el_m=getElevationStop(m);if(el < el_m){r=m;el_r=el_m;}else\n{l=m;el_l=el_m;}}float x=(float(l)+(el-el_l)/(el_r-el_l)+0.5)/float(u_color_ramp_size);fragColor=u_opacity*texture(u_color_stops,vec2(x,0));\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","uniform vec2 u_dimension;in vec2 a_pos;out vec2 v_pos;void main() {gl_Position=projectTile(a_pos,a_pos);highp vec2 epsilon=1.0/u_dimension;float scale=(u_dimension.x-2.0)/u_dimension.x;v_pos=(a_pos/8192.0)*scale+epsilon;if (a_pos.y <-32767.5) {v_pos.y=0.0;}if (a_pos.y > 32766.5) {v_pos.y=1.0;}}"),debug:ji("uniform highp vec4 u_color;uniform sampler2D u_overlay;in vec2 v_uv;void main() {vec4 overlay_color=texture(u_overlay,v_uv);fragColor=mix(u_color,overlay_color,overlay_color.a);}","in vec2 a_pos;out vec2 v_uv;uniform float u_overlay_scale;void main() {v_uv=a_pos/8192.0;gl_Position=projectTileWithElevation(a_pos*u_overlay_scale,get_elevation(a_pos));}"),depth:ji(Oi,"in vec2 a_pos;void main() {\n#ifdef GLOBE\ngl_Position=projectTileFor3D(a_pos,0.0);\n#else\ngl_Position=u_projection_matrix*vec4(a_pos,0.0,1.0);\n#endif\n}"),fill:ji("#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize lowp float opacity\nfragColor=color*opacity;\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","uniform vec2 u_fill_translate;in vec2 a_pos;\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize lowp float opacity\ngl_Position=projectTile(a_pos+u_fill_translate,a_pos);}"),fillOutline:ji("in vec2 v_pos;\n#ifdef GLOBE\nin float v_depth;\n#endif\n#pragma mapbox: define highp vec4 outline_color\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize highp vec4 outline_color\n#pragma mapbox: initialize lowp float opacity\nfloat dist=length(v_pos-gl_FragCoord.xy);float alpha=1.0-smoothstep(0.0,1.0,dist);fragColor=outline_color*(alpha*opacity);\n#ifdef GLOBE\nif (v_depth > 1.0) {discard;}\n#endif\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","uniform vec2 u_world;uniform vec2 u_fill_translate;in vec2 a_pos;out vec2 v_pos;\n#ifdef GLOBE\nout float v_depth;\n#endif\n#pragma mapbox: define highp vec4 outline_color\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize highp vec4 outline_color\n#pragma mapbox: initialize lowp float opacity\ngl_Position=projectTile(a_pos+u_fill_translate,a_pos);v_pos=(gl_Position.xy/gl_Position.w+1.0)/2.0*u_world;\n#ifdef GLOBE\nv_depth=gl_Position.z/gl_Position.w;\n#endif\n}"),fillOutlinePattern:ji("uniform vec2 u_texsize;uniform sampler2D u_image;uniform float u_fade;in vec2 v_pos_a;in vec2 v_pos_b;in vec2 v_pos;\n#ifdef GLOBE\nin float v_depth;\n#endif\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;vec2 imagecoord=mod(v_pos_a,1.0);vec2 pos=mix(pattern_tl_a/u_texsize,pattern_br_a/u_texsize,imagecoord);vec4 color1=texture(u_image,pos);vec2 imagecoord_b=mod(v_pos_b,1.0);vec2 pos2=mix(pattern_tl_b/u_texsize,pattern_br_b/u_texsize,imagecoord_b);vec4 color2=texture(u_image,pos2);float dist=length(v_pos-gl_FragCoord.xy);float alpha=1.0-smoothstep(0.0,1.0,dist);fragColor=mix(color1,color2,u_fade)*alpha*opacity;\n#ifdef GLOBE\nif (v_depth > 1.0) {discard;}\n#endif\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","uniform vec2 u_world;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform vec3 u_scale;uniform vec2 u_fill_translate;in vec2 a_pos;out vec2 v_pos_a;out vec2 v_pos_b;out vec2 v_pos;\n#ifdef GLOBE\nout float v_depth;\n#endif\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\n#pragma mapbox: define lowp float pixel_ratio_from\n#pragma mapbox: define lowp float pixel_ratio_to\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\n#pragma mapbox: initialize lowp float pixel_ratio_from\n#pragma mapbox: initialize lowp float pixel_ratio_to\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;float tileRatio=u_scale.x;float fromScale=u_scale.y;float toScale=u_scale.z;gl_Position=projectTile(a_pos+u_fill_translate,a_pos);vec2 display_size_a=(pattern_br_a-pattern_tl_a)/pixel_ratio_from;vec2 display_size_b=(pattern_br_b-pattern_tl_b)/pixel_ratio_to;v_pos_a=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,fromScale*display_size_a,tileRatio,a_pos);v_pos_b=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,toScale*display_size_b,tileRatio,a_pos);v_pos=(gl_Position.xy/gl_Position.w+1.0)/2.0*u_world;\n#ifdef GLOBE\nv_depth=gl_Position.z/gl_Position.w;\n#endif\n}"),fillPattern:ji("#ifdef GL_ES\nprecision highp float;\n#endif\nuniform vec2 u_texsize;uniform float u_fade;uniform sampler2D u_image;in vec2 v_pos_a;in vec2 v_pos_b;\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;vec2 imagecoord=mod(v_pos_a,1.0);vec2 pos=mix(pattern_tl_a/u_texsize,pattern_br_a/u_texsize,imagecoord);vec4 color1=texture(u_image,pos);vec2 imagecoord_b=mod(v_pos_b,1.0);vec2 pos2=mix(pattern_tl_b/u_texsize,pattern_br_b/u_texsize,imagecoord_b);vec4 color2=texture(u_image,pos2);fragColor=mix(color1,color2,u_fade)*opacity;\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform vec3 u_scale;uniform vec2 u_fill_translate;in vec2 a_pos;out vec2 v_pos_a;out vec2 v_pos_b;\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\n#pragma mapbox: define lowp float pixel_ratio_from\n#pragma mapbox: define lowp float pixel_ratio_to\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\n#pragma mapbox: initialize lowp float pixel_ratio_from\n#pragma mapbox: initialize lowp float pixel_ratio_to\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;float tileZoomRatio=u_scale.x;float fromScale=u_scale.y;float toScale=u_scale.z;vec2 display_size_a=(pattern_br_a-pattern_tl_a)/pixel_ratio_from;vec2 display_size_b=(pattern_br_b-pattern_tl_b)/pixel_ratio_to;gl_Position=projectTile(a_pos+u_fill_translate,a_pos);v_pos_a=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,fromScale*display_size_a,tileZoomRatio,a_pos);v_pos_b=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,toScale*display_size_b,tileZoomRatio,a_pos);}"),fillExtrusion:ji("in vec4 v_color;void main() {fragColor=v_color;\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","uniform vec3 u_lightcolor;uniform lowp vec3 u_lightpos;uniform lowp vec3 u_lightpos_globe;uniform lowp float u_lightintensity;uniform float u_vertical_gradient;uniform lowp float u_opacity;uniform vec2 u_fill_translate;in vec2 a_pos;in vec4 a_normal_ed;\n#ifdef TERRAIN3D\nin vec2 a_centroid;\n#endif\nout vec4 v_color;\n#pragma mapbox: define highp float base\n#pragma mapbox: define highp float height\n#pragma mapbox: define highp vec4 color\nvoid main() {\n#pragma mapbox: initialize highp float base\n#pragma mapbox: initialize highp float height\n#pragma mapbox: initialize highp vec4 color\nvec3 normal=a_normal_ed.xyz;\n#ifdef TERRAIN3D\nfloat height_terrain3d_offset=get_elevation(a_centroid);float base_terrain3d_offset=height_terrain3d_offset-(base > 0.0 ? 0.0 : 10.0);\n#else\nfloat height_terrain3d_offset=0.0;float base_terrain3d_offset=0.0;\n#endif\nbase=max(0.0,base)+base_terrain3d_offset;height=max(0.0,height)+height_terrain3d_offset;float t=mod(normal.x,2.0);float elevation=t > 0.0 ? height : base;vec2 posInTile=a_pos+u_fill_translate;\n#ifdef GLOBE\nvec3 spherePos=projectToSphere(posInTile,a_pos);gl_Position=interpolateProjectionFor3D(posInTile,spherePos,elevation);\n#else\ngl_Position=u_projection_matrix*vec4(posInTile,elevation,1.0);\n#endif\nfloat colorvalue=color.r*0.2126+color.g*0.7152+color.b*0.0722;v_color=vec4(0.0,0.0,0.0,1.0);vec4 ambientlight=vec4(0.03,0.03,0.03,1.0);color+=ambientlight;vec3 normalForLighting=normal/16384.0;float directional=clamp(dot(normalForLighting,u_lightpos),0.0,1.0);\n#ifdef GLOBE\nmat3 rotMatrix=globeGetRotationMatrix(spherePos);normalForLighting=rotMatrix*normalForLighting;directional=mix(directional,clamp(dot(normalForLighting,u_lightpos_globe),0.0,1.0),u_projection_transition);\n#endif\ndirectional=mix((1.0-u_lightintensity),max((1.0-colorvalue+u_lightintensity),1.0),directional);if (normal.y !=0.0) {directional*=((1.0-u_vertical_gradient)+(u_vertical_gradient*clamp((t+base)*pow(height/150.0,0.5),mix(0.7,0.98,1.0-u_lightintensity),1.0)));}v_color.r+=clamp(color.r*directional*u_lightcolor.r,mix(0.0,0.3,1.0-u_lightcolor.r),1.0);v_color.g+=clamp(color.g*directional*u_lightcolor.g,mix(0.0,0.3,1.0-u_lightcolor.g),1.0);v_color.b+=clamp(color.b*directional*u_lightcolor.b,mix(0.0,0.3,1.0-u_lightcolor.b),1.0);v_color*=u_opacity;}"),fillExtrusionPattern:ji("uniform vec2 u_texsize;uniform float u_fade;uniform sampler2D u_image;in vec2 v_pos_a;in vec2 v_pos_b;in vec4 v_lighting;\n#pragma mapbox: define lowp float base\n#pragma mapbox: define lowp float height\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\n#pragma mapbox: define lowp float pixel_ratio_from\n#pragma mapbox: define lowp float pixel_ratio_to\nvoid main() {\n#pragma mapbox: initialize lowp float base\n#pragma mapbox: initialize lowp float height\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\n#pragma mapbox: initialize lowp float pixel_ratio_from\n#pragma mapbox: initialize lowp float pixel_ratio_to\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;vec2 imagecoord=mod(v_pos_a,1.0);vec2 pos=mix(pattern_tl_a/u_texsize,pattern_br_a/u_texsize,imagecoord);vec4 color1=texture(u_image,pos);vec2 imagecoord_b=mod(v_pos_b,1.0);vec2 pos2=mix(pattern_tl_b/u_texsize,pattern_br_b/u_texsize,imagecoord_b);vec4 color2=texture(u_image,pos2);vec4 mixedColor=mix(color1,color2,u_fade);fragColor=mixedColor*v_lighting;\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform float u_height_factor;uniform vec3 u_scale;uniform float u_vertical_gradient;uniform lowp float u_opacity;uniform vec2 u_fill_translate;uniform vec3 u_lightcolor;uniform lowp vec3 u_lightpos;uniform lowp vec3 u_lightpos_globe;uniform lowp float u_lightintensity;in vec2 a_pos;in vec4 a_normal_ed;\n#ifdef TERRAIN3D\nin vec2 a_centroid;\n#endif\n#ifdef GLOBE\nout vec3 v_sphere_pos;\n#endif\nout vec2 v_pos_a;out vec2 v_pos_b;out vec4 v_lighting;\n#pragma mapbox: define lowp float base\n#pragma mapbox: define lowp float height\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\n#pragma mapbox: define lowp float pixel_ratio_from\n#pragma mapbox: define lowp float pixel_ratio_to\nvoid main() {\n#pragma mapbox: initialize lowp float base\n#pragma mapbox: initialize lowp float height\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\n#pragma mapbox: initialize lowp float pixel_ratio_from\n#pragma mapbox: initialize lowp float pixel_ratio_to\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;float tileRatio=u_scale.x;float fromScale=u_scale.y;float toScale=u_scale.z;vec3 normal=a_normal_ed.xyz;float edgedistance=a_normal_ed.w;vec2 display_size_a=(pattern_br_a-pattern_tl_a)/pixel_ratio_from;vec2 display_size_b=(pattern_br_b-pattern_tl_b)/pixel_ratio_to;\n#ifdef TERRAIN3D\nfloat height_terrain3d_offset=get_elevation(a_centroid);float base_terrain3d_offset=height_terrain3d_offset-(base > 0.0 ? 0.0 : 10.0);\n#else\nfloat height_terrain3d_offset=0.0;float base_terrain3d_offset=0.0;\n#endif\nbase=max(0.0,base)+base_terrain3d_offset;height=max(0.0,height)+height_terrain3d_offset;float t=mod(normal.x,2.0);float elevation=t > 0.0 ? height : base;vec2 posInTile=a_pos+u_fill_translate;\n#ifdef GLOBE\nvec3 spherePos=projectToSphere(posInTile,a_pos);vec3 elevatedPos=spherePos*(1.0+elevation/GLOBE_RADIUS);v_sphere_pos=elevatedPos;gl_Position=interpolateProjectionFor3D(posInTile,spherePos,elevation);\n#else\ngl_Position=u_projection_matrix*vec4(posInTile,elevation,1.0);\n#endif\nvec2 pos=normal.x==1.0 && normal.y==0.0 && normal.z==16384.0\n? a_pos\n: vec2(edgedistance,elevation*u_height_factor);v_pos_a=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,fromScale*display_size_a,tileRatio,pos);v_pos_b=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,toScale*display_size_b,tileRatio,pos);v_lighting=vec4(0.0,0.0,0.0,1.0);float directional=clamp(dot(normal/16383.0,u_lightpos),0.0,1.0);directional=mix((1.0-u_lightintensity),max((0.5+u_lightintensity),1.0),directional);if (normal.y !=0.0) {directional*=((1.0-u_vertical_gradient)+(u_vertical_gradient*clamp((t+base)*pow(height/150.0,0.5),mix(0.7,0.98,1.0-u_lightintensity),1.0)));}v_lighting.rgb+=clamp(directional*u_lightcolor,mix(vec3(0.0),vec3(0.3),1.0-u_lightcolor),vec3(1.0));v_lighting*=u_opacity;}"),hillshadePrepare:ji("#ifdef GL_ES\nprecision highp float;\n#endif\nuniform sampler2D u_image;in vec2 v_pos;uniform vec2 u_dimension;uniform float u_zoom;uniform vec4 u_unpack;float getElevation(vec2 coord,float bias) {vec4 data=texture(u_image,coord)*255.0;data.a=-1.0;return dot(data,u_unpack);}void main() {vec2 epsilon=1.0/u_dimension;float tileSize=u_dimension.x-2.0;float a=getElevation(v_pos+vec2(-epsilon.x,-epsilon.y),0.0);float b=getElevation(v_pos+vec2(0,-epsilon.y),0.0);float c=getElevation(v_pos+vec2(epsilon.x,-epsilon.y),0.0);float d=getElevation(v_pos+vec2(-epsilon.x,0),0.0);float e=getElevation(v_pos,0.0);float f=getElevation(v_pos+vec2(epsilon.x,0),0.0);float g=getElevation(v_pos+vec2(-epsilon.x,epsilon.y),0.0);float h=getElevation(v_pos+vec2(0,epsilon.y),0.0);float i=getElevation(v_pos+vec2(epsilon.x,epsilon.y),0.0);float exaggerationFactor=u_zoom < 2.0 ? 0.4 : u_zoom < 4.5 ? 0.35 : 0.3;float exaggeration=u_zoom < 15.0 ? (u_zoom-15.0)*exaggerationFactor : 0.0;vec2 deriv=vec2((c+f+f+i)-(a+d+d+g),(g+h+h+i)-(a+b+b+c))*tileSize/pow(2.0,exaggeration+(28.2562-u_zoom));fragColor=clamp(vec4(deriv.x/8.0+0.5,deriv.y/8.0+0.5,1.0,1.0),0.0,1.0);\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","uniform mat4 u_matrix;uniform vec2 u_dimension;in vec2 a_pos;in vec2 a_texture_pos;out vec2 v_pos;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);highp vec2 epsilon=1.0/u_dimension;float scale=(u_dimension.x-2.0)/u_dimension.x;v_pos=(a_texture_pos/8192.0)*scale+epsilon;}"),hillshade:ji("uniform sampler2D u_image;in vec2 v_pos;uniform vec2 u_latrange;uniform float u_exaggeration;uniform vec4 u_accent;uniform int u_method;uniform float u_altitudes[NUM_ILLUMINATION_SOURCES];uniform float u_azimuths[NUM_ILLUMINATION_SOURCES];uniform vec4 u_shadows[NUM_ILLUMINATION_SOURCES];uniform vec4 u_highlights[NUM_ILLUMINATION_SOURCES];\n#define PI 3.141592653589793\n#define STANDARD 0\n#define COMBINED 1\n#define IGOR 2\n#define MULTIDIRECTIONAL 3\n#define BASIC 4\nfloat get_aspect(vec2 deriv){return deriv.x !=0.0 ? atan(deriv.y,-deriv.x) : PI/2.0*(deriv.y > 0.0 ? 1.0 :-1.0);}void igor_hillshade(vec2 deriv){deriv=deriv*u_exaggeration*2.0;float aspect=get_aspect(deriv);float azimuth=u_azimuths[0]+PI;float slope_stength=atan(length(deriv))*2.0/PI;float aspect_strength=1.0-abs(mod((aspect+azimuth)/PI+0.5,2.0)-1.0);float shadow_strength=slope_stength*aspect_strength;float highlight_strength=slope_stength*(1.0-aspect_strength);fragColor=u_shadows[0]*shadow_strength+u_highlights[0]*highlight_strength;}void standard_hillshade(vec2 deriv){float azimuth=u_azimuths[0]+PI;float slope=atan(0.625*length(deriv));float aspect=get_aspect(deriv);float intensity=u_exaggeration;float base=1.875-intensity*1.75;float maxValue=0.5*PI;float scaledSlope=intensity !=0.5 ? ((pow(base,slope)-1.0)/(pow(base,maxValue)-1.0))*maxValue : slope;float accent=cos(scaledSlope);vec4 accent_color=(1.0-accent)*u_accent*clamp(intensity*2.0,0.0,1.0);float shade=abs(mod((aspect+azimuth)/PI+0.5,2.0)-1.0);vec4 shade_color=mix(u_shadows[0],u_highlights[0],shade)*sin(scaledSlope)*clamp(intensity*2.0,0.0,1.0);fragColor=accent_color*(1.0-shade_color.a)+shade_color;}void basic_hillshade(vec2 deriv){deriv=deriv*u_exaggeration*2.0;float azimuth=u_azimuths[0]+PI;float cos_az=cos(azimuth);float sin_az=sin(azimuth);float cos_alt=cos(u_altitudes[0]);float sin_alt=sin(u_altitudes[0]);float cang=(sin_alt-(deriv.y*cos_az*cos_alt-deriv.x*sin_az*cos_alt))/sqrt(1.0+dot(deriv,deriv));float shade=clamp(cang,0.0,1.0);if(shade > 0.5){fragColor=u_highlights[0]*(2.0*shade-1.0);}else\n{fragColor=u_shadows[0]*(1.0-2.0*shade);}}void multidirectional_hillshade(vec2 deriv){deriv=deriv*u_exaggeration*2.0;fragColor=vec4(0,0,0,0);for(int i=0; i < NUM_ILLUMINATION_SOURCES; i++){float cos_alt=cos(u_altitudes[i]);float sin_alt=sin(u_altitudes[i]);float cos_az=-cos(u_azimuths[i]);float sin_az=-sin(u_azimuths[i]);float cang=(sin_alt-(deriv.y*cos_az*cos_alt-deriv.x*sin_az*cos_alt))/sqrt(1.0+dot(deriv,deriv));float shade=clamp(cang,0.0,1.0);if(shade > 0.5){fragColor+=u_highlights[i]*(2.0*shade-1.0)/float(NUM_ILLUMINATION_SOURCES);}else\n{fragColor+=u_shadows[i]*(1.0-2.0*shade)/float(NUM_ILLUMINATION_SOURCES);}}}void combined_hillshade(vec2 deriv){deriv=deriv*u_exaggeration*2.0;float azimuth=u_azimuths[0]+PI;float cos_az=cos(azimuth);float sin_az=sin(azimuth);float cos_alt=cos(u_altitudes[0]);float sin_alt=sin(u_altitudes[0]);float cang=acos((sin_alt-(deriv.y*cos_az*cos_alt-deriv.x*sin_az*cos_alt))/sqrt(1.0+dot(deriv,deriv)));cang=clamp(cang,0.0,PI/2.0);float shade=cang*atan(length(deriv))*4.0/PI/PI;float highlight=(PI/2.0-cang)*atan(length(deriv))*4.0/PI/PI;fragColor=u_shadows[0]*shade+u_highlights[0]*highlight;}void main() {vec4 pixel=texture(u_image,v_pos);float scaleFactor=cos(radians((u_latrange[0]-u_latrange[1])*(1.0-v_pos.y)+u_latrange[1]));vec2 deriv=((pixel.rg*8.0)-4.0)/scaleFactor;if (u_method==BASIC) {basic_hillshade(deriv);} else if (u_method==COMBINED) {combined_hillshade(deriv);} else if (u_method==IGOR) {igor_hillshade(deriv);} else if (u_method==MULTIDIRECTIONAL) {multidirectional_hillshade(deriv);} else if (u_method==STANDARD) {standard_hillshade(deriv);} else {standard_hillshade(deriv);}\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","uniform mat4 u_matrix;in vec2 a_pos;out vec2 v_pos;void main() {gl_Position=projectTile(a_pos,a_pos);v_pos=a_pos/8192.0;if (a_pos.y <-32767.5) {v_pos.y=0.0;}if (a_pos.y > 32766.5) {v_pos.y=1.0;}}"),line:ji("uniform lowp float u_device_pixel_ratio;in vec2 v_width2;in vec2 v_normal;in float v_gamma_scale;\n#ifdef GLOBE\nin float v_depth;\n#endif\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\nfloat dist=length(v_normal)*v_width2.s;float blur2=(blur+1.0/u_device_pixel_ratio)*v_gamma_scale;float alpha=clamp(min(dist-(v_width2.t-blur2),v_width2.s-dist)/blur2,0.0,1.0);fragColor=color*(alpha*opacity);\n#ifdef GLOBE\nif (v_depth > 1.0) {discard;}\n#endif\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","\n#define scale 0.015873016\nin vec2 a_pos_normal;in vec4 a_data;uniform vec2 u_translation;uniform mediump float u_ratio;uniform vec2 u_units_to_pixels;uniform lowp float u_device_pixel_ratio;out vec2 v_normal;out vec2 v_width2;out float v_gamma_scale;out highp float v_linesofar;\n#ifdef GLOBE\nout float v_depth;\n#endif\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define mediump float gapwidth\n#pragma mapbox: define lowp float offset\n#pragma mapbox: define mediump float width\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump float gapwidth\n#pragma mapbox: initialize lowp float offset\n#pragma mapbox: initialize mediump float width\nfloat ANTIALIASING=1.0/u_device_pixel_ratio/2.0;vec2 a_extrude=a_data.xy-128.0;float a_direction=mod(a_data.z,4.0)-1.0;v_linesofar=(floor(a_data.z/4.0)+a_data.w*64.0)*2.0;vec2 pos=floor(a_pos_normal*0.5);mediump vec2 normal=a_pos_normal-2.0*pos;normal.y=normal.y*2.0-1.0;v_normal=normal;gapwidth=gapwidth/2.0;float halfwidth=width/2.0;offset=-1.0*offset;float inset=gapwidth+(gapwidth > 0.0 ? ANTIALIASING : 0.0);float outset=gapwidth+halfwidth*(gapwidth > 0.0 ? 2.0 : 1.0)+(halfwidth==0.0 ? 0.0 : ANTIALIASING);mediump vec2 dist=outset*a_extrude*scale;mediump float u=0.5*a_direction;mediump float t=1.0-abs(u);mediump vec2 offset2=offset*a_extrude*scale*normal.y*mat2(t,-u,u,t);float adjustedThickness=projectLineThickness(pos.y);vec4 projected_no_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation);vec4 projected_with_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation+dist/u_ratio*adjustedThickness);gl_Position=projected_with_extrude;\n#ifdef GLOBE\nv_depth=gl_Position.z/gl_Position.w;\n#endif\n#ifdef TERRAIN3D\nv_gamma_scale=1.0;\n#else\nfloat extrude_length_without_perspective=length(dist);float extrude_length_with_perspective=length((projected_with_extrude.xy-projected_no_extrude.xy)/projected_with_extrude.w*u_units_to_pixels);v_gamma_scale=extrude_length_without_perspective/extrude_length_with_perspective;\n#endif\nv_width2=vec2(outset,inset);}"),lineGradient:ji("uniform lowp float u_device_pixel_ratio;uniform sampler2D u_image;in vec2 v_width2;in vec2 v_normal;in float v_gamma_scale;in highp vec2 v_uv;\n#ifdef GLOBE\nin float v_depth;\n#endif\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\nfloat dist=length(v_normal)*v_width2.s;float blur2=(blur+1.0/u_device_pixel_ratio)*v_gamma_scale;float alpha=clamp(min(dist-(v_width2.t-blur2),v_width2.s-dist)/blur2,0.0,1.0);vec4 color=texture(u_image,v_uv);fragColor=color*(alpha*opacity);\n#ifdef GLOBE\nif (v_depth > 1.0) {discard;}\n#endif\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","\n#define scale 0.015873016\nin vec2 a_pos_normal;in vec4 a_data;in float a_uv_x;in float a_split_index;uniform vec2 u_translation;uniform mediump float u_ratio;uniform lowp float u_device_pixel_ratio;uniform vec2 u_units_to_pixels;uniform float u_image_height;out vec2 v_normal;out vec2 v_width2;out float v_gamma_scale;out highp vec2 v_uv;\n#ifdef GLOBE\nout float v_depth;\n#endif\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define mediump float gapwidth\n#pragma mapbox: define lowp float offset\n#pragma mapbox: define mediump float width\nvoid main() {\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump float gapwidth\n#pragma mapbox: initialize lowp float offset\n#pragma mapbox: initialize mediump float width\nfloat ANTIALIASING=1.0/u_device_pixel_ratio/2.0;vec2 a_extrude=a_data.xy-128.0;float a_direction=mod(a_data.z,4.0)-1.0;highp float texel_height=1.0/u_image_height;highp float half_texel_height=0.5*texel_height;v_uv=vec2(a_uv_x,a_split_index*texel_height-half_texel_height);vec2 pos=floor(a_pos_normal*0.5);mediump vec2 normal=a_pos_normal-2.0*pos;normal.y=normal.y*2.0-1.0;v_normal=normal;gapwidth=gapwidth/2.0;float halfwidth=width/2.0;offset=-1.0*offset;float inset=gapwidth+(gapwidth > 0.0 ? ANTIALIASING : 0.0);float outset=gapwidth+halfwidth*(gapwidth > 0.0 ? 2.0 : 1.0)+(halfwidth==0.0 ? 0.0 : ANTIALIASING);mediump vec2 dist=outset*a_extrude*scale;mediump float u=0.5*a_direction;mediump float t=1.0-abs(u);mediump vec2 offset2=offset*a_extrude*scale*normal.y*mat2(t,-u,u,t);float adjustedThickness=projectLineThickness(pos.y);vec4 projected_no_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation);vec4 projected_with_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation+dist/u_ratio*adjustedThickness);gl_Position=projected_with_extrude;\n#ifdef GLOBE\nv_depth=gl_Position.z/gl_Position.w;\n#endif\n#ifdef TERRAIN3D\nv_gamma_scale=1.0;\n#else\nfloat extrude_length_without_perspective=length(dist);float extrude_length_with_perspective=length((projected_with_extrude.xy-projected_no_extrude.xy)/projected_with_extrude.w*u_units_to_pixels);v_gamma_scale=extrude_length_without_perspective/extrude_length_with_perspective;\n#endif\nv_width2=vec2(outset,inset);}"),linePattern:ji("#ifdef GL_ES\nprecision highp float;\n#endif\nuniform lowp float u_device_pixel_ratio;uniform vec2 u_texsize;uniform float u_fade;uniform mediump vec3 u_scale;uniform sampler2D u_image;in vec2 v_normal;in vec2 v_width2;in float v_linesofar;in float v_gamma_scale;in float v_width;\n#ifdef GLOBE\nin float v_depth;\n#endif\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\n#pragma mapbox: define lowp float pixel_ratio_from\n#pragma mapbox: define lowp float pixel_ratio_to\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\n#pragma mapbox: initialize lowp float pixel_ratio_from\n#pragma mapbox: initialize lowp float pixel_ratio_to\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;float tileZoomRatio=u_scale.x;float fromScale=u_scale.y;float toScale=u_scale.z;vec2 display_size_a=(pattern_br_a-pattern_tl_a)/pixel_ratio_from;vec2 display_size_b=(pattern_br_b-pattern_tl_b)/pixel_ratio_to;vec2 pattern_size_a=vec2(display_size_a.x*fromScale/tileZoomRatio,display_size_a.y);vec2 pattern_size_b=vec2(display_size_b.x*toScale/tileZoomRatio,display_size_b.y);float aspect_a=display_size_a.y/v_width;float aspect_b=display_size_b.y/v_width;float dist=length(v_normal)*v_width2.s;float blur2=(blur+1.0/u_device_pixel_ratio)*v_gamma_scale;float alpha=clamp(min(dist-(v_width2.t-blur2),v_width2.s-dist)/blur2,0.0,1.0);float x_a=mod(v_linesofar/pattern_size_a.x*aspect_a,1.0);float x_b=mod(v_linesofar/pattern_size_b.x*aspect_b,1.0);float y=0.5*v_normal.y+0.5;vec2 texel_size=1.0/u_texsize;vec2 pos_a=mix(pattern_tl_a*texel_size-texel_size,pattern_br_a*texel_size+texel_size,vec2(x_a,y));vec2 pos_b=mix(pattern_tl_b*texel_size-texel_size,pattern_br_b*texel_size+texel_size,vec2(x_b,y));vec4 color=mix(texture(u_image,pos_a),texture(u_image,pos_b),u_fade);fragColor=color*alpha*opacity;\n#ifdef GLOBE\nif (v_depth > 1.0) {discard;}\n#endif\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","\n#define scale 0.015873016\n#define LINE_DISTANCE_SCALE 2.0\nin vec2 a_pos_normal;in vec4 a_data;uniform vec2 u_translation;uniform vec2 u_units_to_pixels;uniform mediump float u_ratio;uniform lowp float u_device_pixel_ratio;out vec2 v_normal;out vec2 v_width2;out float v_linesofar;out float v_gamma_scale;out float v_width;\n#ifdef GLOBE\nout float v_depth;\n#endif\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp float offset\n#pragma mapbox: define mediump float gapwidth\n#pragma mapbox: define mediump float width\n#pragma mapbox: define lowp float floorwidth\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\n#pragma mapbox: define lowp float pixel_ratio_from\n#pragma mapbox: define lowp float pixel_ratio_to\nvoid main() {\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize lowp float offset\n#pragma mapbox: initialize mediump float gapwidth\n#pragma mapbox: initialize mediump float width\n#pragma mapbox: initialize lowp float floorwidth\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\n#pragma mapbox: initialize lowp float pixel_ratio_from\n#pragma mapbox: initialize lowp float pixel_ratio_to\nfloat ANTIALIASING=1.0/u_device_pixel_ratio/2.0;vec2 a_extrude=a_data.xy-128.0;float a_direction=mod(a_data.z,4.0)-1.0;float a_linesofar=(floor(a_data.z/4.0)+a_data.w*64.0)*LINE_DISTANCE_SCALE;vec2 pos=floor(a_pos_normal*0.5);mediump vec2 normal=a_pos_normal-2.0*pos;normal.y=normal.y*2.0-1.0;v_normal=normal;gapwidth=gapwidth/2.0;float halfwidth=width/2.0;offset=-1.0*offset;float inset=gapwidth+(gapwidth > 0.0 ? ANTIALIASING : 0.0);float outset=gapwidth+halfwidth*(gapwidth > 0.0 ? 2.0 : 1.0)+(halfwidth==0.0 ? 0.0 : ANTIALIASING);mediump vec2 dist=outset*a_extrude*scale;mediump float u=0.5*a_direction;mediump float t=1.0-abs(u);mediump vec2 offset2=offset*a_extrude*scale*normal.y*mat2(t,-u,u,t);float adjustedThickness=projectLineThickness(pos.y);vec4 projected_no_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation);vec4 projected_with_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation+dist/u_ratio*adjustedThickness);gl_Position=projected_with_extrude;\n#ifdef GLOBE\nv_depth=gl_Position.z/gl_Position.w;\n#endif\n#ifdef TERRAIN3D\nv_gamma_scale=1.0;\n#else\nfloat extrude_length_without_perspective=length(dist);float extrude_length_with_perspective=length((projected_with_extrude.xy-projected_no_extrude.xy)/projected_with_extrude.w*u_units_to_pixels);v_gamma_scale=extrude_length_without_perspective/extrude_length_with_perspective;\n#endif\nv_linesofar=a_linesofar;v_width2=vec2(outset,inset);v_width=floorwidth;}"),lineSDF:ji("uniform lowp float u_device_pixel_ratio;uniform lowp float u_lineatlas_width;uniform sampler2D u_image;uniform float u_mix;in vec2 v_normal;in vec2 v_width2;in vec2 v_tex_a;in vec2 v_tex_b;in float v_gamma_scale;\n#ifdef GLOBE\nin float v_depth;\n#endif\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define mediump float width\n#pragma mapbox: define lowp float floorwidth\n#pragma mapbox: define mediump vec4 dasharray_from\n#pragma mapbox: define mediump vec4 dasharray_to\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump float width\n#pragma mapbox: initialize lowp float floorwidth\n#pragma mapbox: initialize mediump vec4 dasharray_from\n#pragma mapbox: initialize mediump vec4 dasharray_to\nfloat dist=length(v_normal)*v_width2.s;float blur2=(blur+1.0/u_device_pixel_ratio)*v_gamma_scale;float alpha=clamp(min(dist-(v_width2.t-blur2),v_width2.s-dist)/blur2,0.0,1.0);float sdfdist_a=texture(u_image,v_tex_a).a;float sdfdist_b=texture(u_image,v_tex_b).a;float sdfdist=mix(sdfdist_a,sdfdist_b,u_mix);float sdfgamma=(u_lineatlas_width/256.0/u_device_pixel_ratio)/min(dasharray_from.w,dasharray_to.w);alpha*=smoothstep(0.5-sdfgamma/floorwidth,0.5+sdfgamma/floorwidth,sdfdist);fragColor=color*(alpha*opacity);\n#ifdef GLOBE\nif (v_depth > 1.0) {discard;}\n#endif\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","\n#define scale 0.015873016\n#define LINE_DISTANCE_SCALE 2.0\nin vec2 a_pos_normal;in vec4 a_data;uniform vec2 u_translation;uniform mediump float u_ratio;uniform lowp float u_device_pixel_ratio;uniform vec2 u_units_to_pixels;uniform float u_tileratio;uniform float u_crossfade_from;uniform float u_crossfade_to;uniform float u_lineatlas_height;out vec2 v_normal;out vec2 v_width2;out vec2 v_tex_a;out vec2 v_tex_b;out float v_gamma_scale;\n#ifdef GLOBE\nout float v_depth;\n#endif\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define mediump float gapwidth\n#pragma mapbox: define lowp float offset\n#pragma mapbox: define mediump float width\n#pragma mapbox: define lowp float floorwidth\n#pragma mapbox: define mediump vec4 dasharray_from\n#pragma mapbox: define mediump vec4 dasharray_to\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump float gapwidth\n#pragma mapbox: initialize lowp float offset\n#pragma mapbox: initialize mediump float width\n#pragma mapbox: initialize lowp float floorwidth\n#pragma mapbox: initialize mediump vec4 dasharray_from\n#pragma mapbox: initialize mediump vec4 dasharray_to\nfloat ANTIALIASING=1.0/u_device_pixel_ratio/2.0;vec2 a_extrude=a_data.xy-128.0;float a_direction=mod(a_data.z,4.0)-1.0;float a_linesofar=(floor(a_data.z/4.0)+a_data.w*64.0)*LINE_DISTANCE_SCALE;vec2 pos=floor(a_pos_normal*0.5);mediump vec2 normal=a_pos_normal-2.0*pos;normal.y=normal.y*2.0-1.0;v_normal=normal;gapwidth=gapwidth/2.0;float halfwidth=width/2.0;offset=-1.0*offset;float inset=gapwidth+(gapwidth > 0.0 ? ANTIALIASING : 0.0);float outset=gapwidth+halfwidth*(gapwidth > 0.0 ? 2.0 : 1.0)+(halfwidth==0.0 ? 0.0 : ANTIALIASING);mediump vec2 dist=outset*a_extrude*scale;mediump float u=0.5*a_direction;mediump float t=1.0-abs(u);mediump vec2 offset2=offset*a_extrude*scale*normal.y*mat2(t,-u,u,t);float adjustedThickness=projectLineThickness(pos.y);vec4 projected_no_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation);vec4 projected_with_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation+dist/u_ratio*adjustedThickness);gl_Position=projected_with_extrude;\n#ifdef GLOBE\nv_depth=gl_Position.z/gl_Position.w;\n#endif\n#ifdef TERRAIN3D\nv_gamma_scale=1.0;\n#else\nfloat extrude_length_without_perspective=length(dist);float extrude_length_with_perspective=length((projected_with_extrude.xy-projected_no_extrude.xy)/projected_with_extrude.w*u_units_to_pixels);v_gamma_scale=extrude_length_without_perspective/extrude_length_with_perspective;\n#endif\nfloat u_patternscale_a_x=u_tileratio/dasharray_from.w/u_crossfade_from;float u_patternscale_a_y=-dasharray_from.z/2.0/u_lineatlas_height;float u_patternscale_b_x=u_tileratio/dasharray_to.w/u_crossfade_to;float u_patternscale_b_y=-dasharray_to.z/2.0/u_lineatlas_height;v_tex_a=vec2(a_linesofar*u_patternscale_a_x/floorwidth,normal.y*u_patternscale_a_y+(float(dasharray_from.y)+0.5)/u_lineatlas_height);v_tex_b=vec2(a_linesofar*u_patternscale_b_x/floorwidth,normal.y*u_patternscale_b_y+(float(dasharray_to.y)+0.5)/u_lineatlas_height);v_width2=vec2(outset,inset);}"),lineGradientSDF:ji("uniform lowp float u_device_pixel_ratio;uniform sampler2D u_image;uniform sampler2D u_image_dash;uniform float u_mix;uniform lowp float u_lineatlas_width;in vec2 v_normal;in vec2 v_width2;in vec2 v_tex_a;in vec2 v_tex_b;in float v_gamma_scale;in highp vec2 v_uv;\n#ifdef GLOBE\nin float v_depth;\n#endif\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define mediump float width\n#pragma mapbox: define lowp float floorwidth\n#pragma mapbox: define mediump vec4 dasharray_from\n#pragma mapbox: define mediump vec4 dasharray_to\nvoid main() {\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump float width\n#pragma mapbox: initialize lowp float floorwidth\n#pragma mapbox: initialize mediump vec4 dasharray_from\n#pragma mapbox: initialize mediump vec4 dasharray_to\nfloat dist=length(v_normal)*v_width2.s;float blur2=(blur+1.0/u_device_pixel_ratio)*v_gamma_scale;float alpha=clamp(min(dist-(v_width2.t-blur2),v_width2.s-dist)/blur2,0.0,1.0);vec4 color=texture(u_image,v_uv);float sdfdist_a=texture(u_image_dash,v_tex_a).a;float sdfdist_b=texture(u_image_dash,v_tex_b).a;float sdfdist=mix(sdfdist_a,sdfdist_b,u_mix);float sdfgamma=(u_lineatlas_width/256.0)/min(dasharray_from.w,dasharray_to.w);float dash_alpha=smoothstep(0.5-sdfgamma/floorwidth,0.5+sdfgamma/floorwidth,sdfdist);fragColor=color*(alpha*dash_alpha*opacity);\n#ifdef GLOBE\nif (v_depth > 1.0) {discard;}\n#endif\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","\n#define scale 0.015873016\n#define LINE_DISTANCE_SCALE 2.0\nin vec2 a_pos_normal;in vec4 a_data;in float a_uv_x;in float a_split_index;uniform vec2 u_translation;uniform mediump float u_ratio;uniform lowp float u_device_pixel_ratio;uniform vec2 u_units_to_pixels;uniform float u_image_height;uniform float u_tileratio;uniform float u_crossfade_from;uniform float u_crossfade_to;uniform float u_lineatlas_height;out vec2 v_normal;out vec2 v_width2;out float v_gamma_scale;out highp vec2 v_uv;out vec2 v_tex_a;out vec2 v_tex_b;\n#ifdef GLOBE\nout float v_depth;\n#endif\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define mediump float gapwidth\n#pragma mapbox: define lowp float offset\n#pragma mapbox: define mediump float width\n#pragma mapbox: define lowp float floorwidth\n#pragma mapbox: define mediump vec4 dasharray_from\n#pragma mapbox: define mediump vec4 dasharray_to\nvoid main() {\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump float gapwidth\n#pragma mapbox: initialize lowp float offset\n#pragma mapbox: initialize mediump float width\n#pragma mapbox: initialize lowp float floorwidth\n#pragma mapbox: initialize mediump vec4 dasharray_from\n#pragma mapbox: initialize mediump vec4 dasharray_to\nfloat ANTIALIASING=1.0/u_device_pixel_ratio/2.0;vec2 a_extrude=a_data.xy-128.0;float a_direction=mod(a_data.z,4.0)-1.0;float a_linesofar=(floor(a_data.z/4.0)+a_data.w*64.0)*LINE_DISTANCE_SCALE;float texel_height=1.0/u_image_height;float half_texel_height=0.5*texel_height;v_uv=vec2(a_uv_x,a_split_index*texel_height-half_texel_height);vec2 pos=floor(a_pos_normal*0.5);mediump vec2 normal=a_pos_normal-2.0*pos;normal.y=normal.y*2.0-1.0;v_normal=normal;gapwidth=gapwidth/2.0;float halfwidth=width/2.0;offset=-1.0*offset;float inset=gapwidth+(gapwidth > 0.0 ? ANTIALIASING : 0.0);float outset=gapwidth+halfwidth*(gapwidth > 0.0 ? 2.0 : 1.0)+(halfwidth==0.0 ? 0.0 : ANTIALIASING);mediump vec2 dist=outset*a_extrude*scale;mediump float u=0.5*a_direction;mediump float t=1.0-abs(u);mediump vec2 offset2=offset*a_extrude*scale*normal.y*mat2(t,-u,u,t);float adjustedThickness=projectLineThickness(pos.y);vec4 projected_no_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation);vec4 projected_with_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation+dist/u_ratio*adjustedThickness);gl_Position=projected_with_extrude;\n#ifdef GLOBE\nv_depth=gl_Position.z/gl_Position.w;\n#endif\n#ifdef TERRAIN3D\nv_gamma_scale=1.0;\n#else\nfloat extrude_length_without_perspective=length(dist);float extrude_length_with_perspective=length((projected_with_extrude.xy-projected_no_extrude.xy)/projected_with_extrude.w*u_units_to_pixels);v_gamma_scale=extrude_length_without_perspective/extrude_length_with_perspective;\n#endif\nfloat u_patternscale_a_x=u_tileratio/dasharray_from.w/u_crossfade_from;float u_patternscale_a_y=-dasharray_from.z/2.0/u_lineatlas_height;float u_patternscale_b_x=u_tileratio/dasharray_to.w/u_crossfade_to;float u_patternscale_b_y=-dasharray_to.z/2.0/u_lineatlas_height;v_tex_a=vec2(a_linesofar*u_patternscale_a_x/floorwidth,normal.y*u_patternscale_a_y+(float(dasharray_from.y)+0.5)/u_lineatlas_height);v_tex_b=vec2(a_linesofar*u_patternscale_b_x/floorwidth,normal.y*u_patternscale_b_y+(float(dasharray_to.y)+0.5)/u_lineatlas_height);v_width2=vec2(outset,inset);}"),raster:ji("uniform float u_fade_t;uniform float u_opacity;uniform sampler2D u_image0;uniform sampler2D u_image1;in vec2 v_pos0;in vec2 v_pos1;uniform float u_brightness_low;uniform float u_brightness_high;uniform float u_saturation_factor;uniform float u_contrast_factor;uniform vec3 u_spin_weights;void main() {vec4 color0=texture(u_image0,v_pos0);vec4 color1=texture(u_image1,v_pos1);if (color0.a > 0.0) {color0.rgb=color0.rgb/color0.a;}if (color1.a > 0.0) {color1.rgb=color1.rgb/color1.a;}vec4 color=mix(color0,color1,u_fade_t);color.a*=u_opacity;vec3 rgb=color.rgb;rgb=vec3(dot(rgb,u_spin_weights.xyz),dot(rgb,u_spin_weights.zxy),dot(rgb,u_spin_weights.yzx));float average=(color.r+color.g+color.b)/3.0;rgb+=(average-rgb)*u_saturation_factor;rgb=(rgb-0.5)*u_contrast_factor+0.5;vec3 u_high_vec=vec3(u_brightness_low,u_brightness_low,u_brightness_low);vec3 u_low_vec=vec3(u_brightness_high,u_brightness_high,u_brightness_high);fragColor=vec4(mix(u_high_vec,u_low_vec,rgb)*color.a,color.a);\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","uniform vec2 u_tl_parent;uniform float u_scale_parent;uniform float u_buffer_scale;uniform vec4 u_coords_top;uniform vec4 u_coords_bottom;in vec2 a_pos;out vec2 v_pos0;out vec2 v_pos1;void main() {vec2 fractionalPos=a_pos/8192.0;vec2 position=mix(mix(u_coords_top.xy,u_coords_top.zw,fractionalPos.x),mix(u_coords_bottom.xy,u_coords_bottom.zw,fractionalPos.x),fractionalPos.y);gl_Position=projectTile(position,position);v_pos0=((fractionalPos-0.5)/u_buffer_scale)+0.5;\n#ifdef GLOBE\nif (a_pos.y <-32767.5) {v_pos0.y=0.0;}if (a_pos.y > 32766.5) {v_pos0.y=1.0;}\n#endif\nv_pos1=(v_pos0*u_scale_parent)+u_tl_parent;}"),symbolIcon:ji("uniform sampler2D u_texture;in vec2 v_tex;in float v_fade_opacity;\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\nlowp float alpha=opacity*v_fade_opacity;fragColor=texture(u_texture,v_tex)*alpha;\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","in vec4 a_pos_offset;in vec4 a_data;in vec4 a_pixeloffset;in vec3 a_projected_pos;in float a_fade_opacity;uniform bool u_is_size_zoom_constant;uniform bool u_is_size_feature_constant;uniform highp float u_size_t;uniform highp float u_size;uniform highp float u_camera_to_center_distance;uniform highp float u_pitch;uniform bool u_rotate_symbol;uniform highp float u_aspect_ratio;uniform float u_fade_change;uniform mat4 u_label_plane_matrix;uniform mat4 u_coord_matrix;uniform bool u_is_text;uniform bool u_pitch_with_map;uniform vec2 u_texsize;uniform bool u_is_along_line;uniform bool u_is_variable_anchor;uniform vec2 u_translation;uniform float u_pitched_scale;out vec2 v_tex;out float v_fade_opacity;\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\nvec2 a_pos=a_pos_offset.xy;vec2 a_offset=a_pos_offset.zw;vec2 a_tex=a_data.xy;vec2 a_size=a_data.zw;float a_size_min=floor(a_size[0]*0.5);vec2 a_pxoffset=a_pixeloffset.xy;vec2 a_minFontScale=a_pixeloffset.zw/256.0;float ele=get_elevation(a_pos);highp float segment_angle=-a_projected_pos[2];float size;if (!u_is_size_zoom_constant && !u_is_size_feature_constant) {size=mix(a_size_min,a_size[1],u_size_t)/128.0;} else if (u_is_size_zoom_constant && !u_is_size_feature_constant) {size=a_size_min/128.0;} else {size=u_size;}vec2 translated_a_pos=a_pos+u_translation;vec4 projectedPoint=projectTileWithElevation(translated_a_pos,ele);highp float camera_to_anchor_distance=projectedPoint.w;highp float distance_ratio=u_pitch_with_map ?\ncamera_to_anchor_distance/u_camera_to_center_distance :\nu_camera_to_center_distance/camera_to_anchor_distance;highp float perspective_ratio=clamp(0.5+0.5*distance_ratio,0.0,4.0);size*=perspective_ratio;float fontScale=u_is_text ? size/24.0 : size;highp float symbol_rotation=0.0;if (u_rotate_symbol) {vec4 offsetProjectedPoint=projectTileWithElevation(translated_a_pos+vec2(1,0),ele);vec2 a=projectedPoint.xy/projectedPoint.w;vec2 b=offsetProjectedPoint.xy/offsetProjectedPoint.w;symbol_rotation=atan((b.y-a.y)/u_aspect_ratio,b.x-a.x);}highp float angle_sin=sin(segment_angle+symbol_rotation);highp float angle_cos=cos(segment_angle+symbol_rotation);mat2 rotation_matrix=mat2(angle_cos,-1.0*angle_sin,angle_sin,angle_cos);vec4 projected_pos;if (u_is_along_line || u_is_variable_anchor) {projected_pos=vec4(a_projected_pos.xy,ele,1.0);} else if (u_pitch_with_map) {projected_pos=u_label_plane_matrix*vec4(a_projected_pos.xy+u_translation,ele,1.0);} else {projected_pos=u_label_plane_matrix*projectTileWithElevation(a_projected_pos.xy+u_translation,ele);}float z=float(u_pitch_with_map)*projected_pos.z/projected_pos.w;float projectionScaling=1.0;\n#ifdef GLOBE\nif(u_pitch_with_map) {float anchor_pos_tile_y=(u_coord_matrix*vec4(projected_pos.xy/projected_pos.w,z,1.0)).y;projectionScaling=mix(projectionScaling,1.0/circumferenceRatioAtTileY(anchor_pos_tile_y)*u_pitched_scale,u_projection_transition);}\n#endif\nvec4 finalPos=u_coord_matrix*vec4(projected_pos.xy/projected_pos.w+rotation_matrix*(a_offset/32.0*max(a_minFontScale,fontScale)+a_pxoffset/16.0)*projectionScaling,z,1.0);if(u_pitch_with_map) {finalPos=projectTileWithElevation(finalPos.xy,finalPos.z);}gl_Position=finalPos;v_tex=a_tex/u_texsize;vec2 fade_opacity=unpack_opacity(a_fade_opacity);float fade_change=fade_opacity[1] > 0.5 ? u_fade_change :-u_fade_change;float visibility=calculate_visibility(projectedPoint);v_fade_opacity=max(0.0,min(visibility,fade_opacity[0]+fade_change));}"),symbolSDF:ji("#define SDF_PX 8.0\nuniform bool u_is_halo;uniform sampler2D u_texture;uniform highp float u_gamma_scale;uniform lowp float u_device_pixel_ratio;uniform bool u_is_text;in vec2 v_data0;in vec3 v_data1;\n#pragma mapbox: define highp vec4 fill_color\n#pragma mapbox: define highp vec4 halo_color\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp float halo_width\n#pragma mapbox: define lowp float halo_blur\nvoid main() {\n#pragma mapbox: initialize highp vec4 fill_color\n#pragma mapbox: initialize highp vec4 halo_color\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize lowp float halo_width\n#pragma mapbox: initialize lowp float halo_blur\nfloat EDGE_GAMMA=0.105/u_device_pixel_ratio;vec2 tex=v_data0.xy;float gamma_scale=v_data1.x;float size=v_data1.y;float fade_opacity=v_data1[2];float fontScale=u_is_text ? size/24.0 : size;lowp vec4 color=fill_color;highp float gamma=EDGE_GAMMA/(fontScale*u_gamma_scale);lowp float inner_edge=(256.0-64.0)/256.0;if (u_is_halo) {color=halo_color;gamma=(halo_blur*1.19/SDF_PX+EDGE_GAMMA)/(fontScale*u_gamma_scale);inner_edge=inner_edge+gamma*gamma_scale;}lowp float dist=texture(u_texture,tex).a;highp float gamma_scaled=gamma*gamma_scale;highp float alpha=smoothstep(inner_edge-gamma_scaled,inner_edge+gamma_scaled,dist);if (u_is_halo) {lowp float halo_edge=(6.0-halo_width/fontScale)/SDF_PX;alpha=min(smoothstep(halo_edge-gamma_scaled,halo_edge+gamma_scaled,dist),1.0-alpha);}fragColor=color*(alpha*opacity*fade_opacity);\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","in vec4 a_pos_offset;in vec4 a_data;in vec4 a_pixeloffset;in vec3 a_projected_pos;in float a_fade_opacity;uniform bool u_is_size_zoom_constant;uniform bool u_is_size_feature_constant;uniform highp float u_size_t;uniform highp float u_size;uniform mat4 u_label_plane_matrix;uniform mat4 u_coord_matrix;uniform bool u_is_text;uniform bool u_pitch_with_map;uniform bool u_is_along_line;uniform bool u_is_variable_anchor;uniform highp float u_pitch;uniform bool u_rotate_symbol;uniform highp float u_aspect_ratio;uniform highp float u_camera_to_center_distance;uniform float u_fade_change;uniform vec2 u_texsize;uniform vec2 u_translation;uniform float u_pitched_scale;out vec2 v_data0;out vec3 v_data1;\n#pragma mapbox: define highp vec4 fill_color\n#pragma mapbox: define highp vec4 halo_color\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp float halo_width\n#pragma mapbox: define lowp float halo_blur\nvoid main() {\n#pragma mapbox: initialize highp vec4 fill_color\n#pragma mapbox: initialize highp vec4 halo_color\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize lowp float halo_width\n#pragma mapbox: initialize lowp float halo_blur\nvec2 a_pos=a_pos_offset.xy;vec2 a_offset=a_pos_offset.zw;vec2 a_tex=a_data.xy;vec2 a_size=a_data.zw;float a_size_min=floor(a_size[0]*0.5);vec2 a_pxoffset=a_pixeloffset.xy;float ele=get_elevation(a_pos);highp float segment_angle=-a_projected_pos[2];float size;if (!u_is_size_zoom_constant && !u_is_size_feature_constant) {size=mix(a_size_min,a_size[1],u_size_t)/128.0;} else if (u_is_size_zoom_constant && !u_is_size_feature_constant) {size=a_size_min/128.0;} else {size=u_size;}vec2 translated_a_pos=a_pos+u_translation;vec4 projectedPoint=projectTileWithElevation(translated_a_pos,ele);highp float camera_to_anchor_distance=projectedPoint.w;highp float distance_ratio=u_pitch_with_map ?\ncamera_to_anchor_distance/u_camera_to_center_distance :\nu_camera_to_center_distance/camera_to_anchor_distance;highp float perspective_ratio=clamp(0.5+0.5*distance_ratio,0.0,4.0);size*=perspective_ratio;float fontScale=u_is_text ? size/24.0 : size;highp float symbol_rotation=0.0;if (u_rotate_symbol) {vec4 offsetProjectedPoint=projectTileWithElevation(translated_a_pos+vec2(1,0),ele);vec2 a=projectedPoint.xy/projectedPoint.w;vec2 b=offsetProjectedPoint.xy/offsetProjectedPoint.w;symbol_rotation=atan((b.y-a.y)/u_aspect_ratio,b.x-a.x);}highp float angle_sin=sin(segment_angle+symbol_rotation);highp float angle_cos=cos(segment_angle+symbol_rotation);mat2 rotation_matrix=mat2(angle_cos,-1.0*angle_sin,angle_sin,angle_cos);vec4 projected_pos;if (u_is_along_line || u_is_variable_anchor) {projected_pos=vec4(a_projected_pos.xy,ele,1.0);} else if (u_pitch_with_map) {projected_pos=u_label_plane_matrix*vec4(a_projected_pos.xy+u_translation,ele,1.0);} else {projected_pos=u_label_plane_matrix*projectTileWithElevation(a_projected_pos.xy+u_translation,ele);}float z=float(u_pitch_with_map)*projected_pos.z/projected_pos.w;float projectionScaling=1.0;\n#ifdef GLOBE\nif(u_pitch_with_map) {float anchor_pos_tile_y=(u_coord_matrix*vec4(projected_pos.xy/projected_pos.w,z,1.0)).y;projectionScaling=mix(projectionScaling,1.0/circumferenceRatioAtTileY(anchor_pos_tile_y)*u_pitched_scale,u_projection_transition);}\n#endif\nvec4 finalPos=u_coord_matrix*vec4(projected_pos.xy/projected_pos.w+rotation_matrix*(a_offset/32.0*fontScale+a_pxoffset)*projectionScaling,z,1.0);if(u_pitch_with_map) {finalPos=projectTileWithElevation(finalPos.xy,finalPos.z);}float gamma_scale=finalPos.w;gl_Position=finalPos;vec2 fade_opacity=unpack_opacity(a_fade_opacity);float visibility=calculate_visibility(projectedPoint);float fade_change=fade_opacity[1] > 0.5 ? u_fade_change :-u_fade_change;float interpolated_fade_opacity=max(0.0,min(visibility,fade_opacity[0]+fade_change));v_data0=a_tex/u_texsize;v_data1=vec3(gamma_scale,size,interpolated_fade_opacity);}"),symbolTextAndIcon:ji("#define SDF_PX 8.0\n#define SDF 1.0\n#define ICON 0.0\nuniform bool u_is_halo;uniform sampler2D u_texture;uniform sampler2D u_texture_icon;uniform highp float u_gamma_scale;uniform lowp float u_device_pixel_ratio;in vec4 v_data0;in vec4 v_data1;\n#pragma mapbox: define highp vec4 fill_color\n#pragma mapbox: define highp vec4 halo_color\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp float halo_width\n#pragma mapbox: define lowp float halo_blur\nvoid main() {\n#pragma mapbox: initialize highp vec4 fill_color\n#pragma mapbox: initialize highp vec4 halo_color\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize lowp float halo_width\n#pragma mapbox: initialize lowp float halo_blur\nfloat fade_opacity=v_data1[2];if (v_data1.w==ICON) {vec2 tex_icon=v_data0.zw;lowp float alpha=opacity*fade_opacity;fragColor=texture(u_texture_icon,tex_icon)*alpha;\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\nreturn;}vec2 tex=v_data0.xy;float EDGE_GAMMA=0.105/u_device_pixel_ratio;float gamma_scale=v_data1.x;float size=v_data1.y;float fontScale=size/24.0;lowp vec4 color=fill_color;highp float gamma=EDGE_GAMMA/(fontScale*u_gamma_scale);lowp float buff=(256.0-64.0)/256.0;if (u_is_halo) {color=halo_color;gamma=(halo_blur*1.19/SDF_PX+EDGE_GAMMA)/(fontScale*u_gamma_scale);buff=(6.0-halo_width/fontScale)/SDF_PX;}lowp float dist=texture(u_texture,tex).a;highp float gamma_scaled=gamma*gamma_scale;highp float alpha=smoothstep(buff-gamma_scaled,buff+gamma_scaled,dist);fragColor=color*(alpha*opacity*fade_opacity);\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","in vec4 a_pos_offset;in vec4 a_data;in vec3 a_projected_pos;in float a_fade_opacity;uniform bool u_is_size_zoom_constant;uniform bool u_is_size_feature_constant;uniform highp float u_size_t;uniform highp float u_size;uniform mat4 u_label_plane_matrix;uniform mat4 u_coord_matrix;uniform bool u_is_text;uniform bool u_pitch_with_map;uniform highp float u_pitch;uniform bool u_rotate_symbol;uniform highp float u_aspect_ratio;uniform highp float u_camera_to_center_distance;uniform float u_fade_change;uniform vec2 u_texsize;uniform vec2 u_texsize_icon;uniform bool u_is_along_line;uniform bool u_is_variable_anchor;uniform vec2 u_translation;uniform float u_pitched_scale;out vec4 v_data0;out vec4 v_data1;\n#pragma mapbox: define highp vec4 fill_color\n#pragma mapbox: define highp vec4 halo_color\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp float halo_width\n#pragma mapbox: define lowp float halo_blur\nvoid main() {\n#pragma mapbox: initialize highp vec4 fill_color\n#pragma mapbox: initialize highp vec4 halo_color\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize lowp float halo_width\n#pragma mapbox: initialize lowp float halo_blur\nvec2 a_pos=a_pos_offset.xy;vec2 a_offset=a_pos_offset.zw;vec2 a_tex=a_data.xy;vec2 a_size=a_data.zw;float a_size_min=floor(a_size[0]*0.5);float is_sdf=a_size[0]-2.0*a_size_min;float ele=get_elevation(a_pos);highp float segment_angle=-a_projected_pos[2];float size;if (!u_is_size_zoom_constant && !u_is_size_feature_constant) {size=mix(a_size_min,a_size[1],u_size_t)/128.0;} else if (u_is_size_zoom_constant && !u_is_size_feature_constant) {size=a_size_min/128.0;} else {size=u_size;}vec2 translated_a_pos=a_pos+u_translation;vec4 projectedPoint=projectTileWithElevation(translated_a_pos,ele);highp float camera_to_anchor_distance=projectedPoint.w;highp float distance_ratio=u_pitch_with_map ?\ncamera_to_anchor_distance/u_camera_to_center_distance :\nu_camera_to_center_distance/camera_to_anchor_distance;highp float perspective_ratio=clamp(0.5+0.5*distance_ratio,0.0,4.0);size*=perspective_ratio;float fontScale=size/24.0;highp float symbol_rotation=0.0;if (u_rotate_symbol) {vec4 offsetProjectedPoint=projectTileWithElevation(translated_a_pos+vec2(1,0),ele);vec2 a=projectedPoint.xy/projectedPoint.w;vec2 b=offsetProjectedPoint.xy/offsetProjectedPoint.w;symbol_rotation=atan((b.y-a.y)/u_aspect_ratio,b.x-a.x);}highp float angle_sin=sin(segment_angle+symbol_rotation);highp float angle_cos=cos(segment_angle+symbol_rotation);mat2 rotation_matrix=mat2(angle_cos,-1.0*angle_sin,angle_sin,angle_cos);vec4 projected_pos;if (u_is_along_line || u_is_variable_anchor) {projected_pos=vec4(a_projected_pos.xy,ele,1.0);} else if (u_pitch_with_map) {projected_pos=u_label_plane_matrix*vec4(a_projected_pos.xy+u_translation,ele,1.0);} else {projected_pos=u_label_plane_matrix*projectTileWithElevation(a_projected_pos.xy+u_translation,ele);}float z=float(u_pitch_with_map)*projected_pos.z/projected_pos.w;float projectionScaling=1.0;\n#ifdef GLOBE\nif(u_pitch_with_map && !u_is_along_line) {float anchor_pos_tile_y=(u_coord_matrix*vec4(projected_pos.xy/projected_pos.w,z,1.0)).y;projectionScaling=mix(projectionScaling,1.0/circumferenceRatioAtTileY(anchor_pos_tile_y)*u_pitched_scale,u_projection_transition);}\n#endif\nvec4 finalPos=u_coord_matrix*vec4(projected_pos.xy/projected_pos.w+rotation_matrix*(a_offset/32.0*fontScale)*projectionScaling,z,1.0);if(u_pitch_with_map) {finalPos=projectTileWithElevation(finalPos.xy,finalPos.z);}float gamma_scale=finalPos.w;gl_Position=finalPos;vec2 fade_opacity=unpack_opacity(a_fade_opacity);float visibility=calculate_visibility(projectedPoint);float fade_change=fade_opacity[1] > 0.5 ? u_fade_change :-u_fade_change;float interpolated_fade_opacity=max(0.0,min(visibility,fade_opacity[0]+fade_change));v_data0.xy=a_tex/u_texsize;v_data0.zw=a_tex/u_texsize_icon;v_data1=vec4(gamma_scale,size,interpolated_fade_opacity,is_sdf);}"),terrain:ji("uniform sampler2D u_texture;uniform vec4 u_fog_color;uniform vec4 u_horizon_color;uniform float u_fog_ground_blend;uniform float u_fog_ground_blend_opacity;uniform float u_horizon_fog_blend;uniform bool u_is_globe_mode;in vec2 v_texture_pos;in float v_fog_depth;const float gamma=2.2;vec4 gammaToLinear(vec4 color) {return pow(color,vec4(gamma));}vec4 linearToGamma(vec4 color) {return pow(color,vec4(1.0/gamma));}void main() {vec4 surface_color=texture(u_texture,vec2(v_texture_pos.x,1.0-v_texture_pos.y));if (!u_is_globe_mode && v_fog_depth > u_fog_ground_blend) {vec4 surface_color_linear=gammaToLinear(surface_color);float blend_color=smoothstep(0.0,1.0,max((v_fog_depth-u_horizon_fog_blend)/(1.0-u_horizon_fog_blend),0.0));vec4 fog_horizon_color_linear=mix(gammaToLinear(u_fog_color),gammaToLinear(u_horizon_color),blend_color);float factor_fog=max(v_fog_depth-u_fog_ground_blend,0.0)/(1.0-u_fog_ground_blend);fragColor=linearToGamma(mix(surface_color_linear,fog_horizon_color_linear,pow(factor_fog,2.0)*u_fog_ground_blend_opacity));} else {fragColor=surface_color;}}","in vec3 a_pos3d;uniform mat4 u_fog_matrix;uniform float u_ele_delta;out vec2 v_texture_pos;out float v_fog_depth;void main() {float ele=get_elevation(a_pos3d.xy);float ele_delta=a_pos3d.z==1.0 ? u_ele_delta : 0.0;v_texture_pos=a_pos3d.xy/8192.0;gl_Position=projectTileFor3D(a_pos3d.xy,get_elevation(a_pos3d.xy)-ele_delta);vec4 pos=u_fog_matrix*vec4(a_pos3d.xy,ele,1.0);v_fog_depth=pos.z/pos.w*0.5+0.5;}"),terrainDepth:ji("in float v_depth;const highp vec4 bitSh=vec4(256.*256.*256.,256.*256.,256.,1.);const highp vec4 bitMsk=vec4(0.,vec3(1./256.0));highp vec4 pack(highp float value) {highp vec4 comp=fract(value*bitSh);comp-=comp.xxyz*bitMsk;return comp;}void main() {fragColor=pack(v_depth);}","in vec3 a_pos3d;uniform float u_ele_delta;out float v_depth;void main() {float ele=get_elevation(a_pos3d.xy);float ele_delta=a_pos3d.z==1.0 ? u_ele_delta : 0.0;gl_Position=projectTileFor3D(a_pos3d.xy,ele-ele_delta);v_depth=gl_Position.z/gl_Position.w;}"),terrainCoords:ji("precision mediump float;uniform sampler2D u_texture;uniform float u_terrain_coords_id;in vec2 v_texture_pos;void main() {vec4 rgba=texture(u_texture,v_texture_pos);fragColor=vec4(rgba.r,rgba.g,rgba.b,u_terrain_coords_id);}","in vec3 a_pos3d;uniform float u_ele_delta;out vec2 v_texture_pos;void main() {float ele=get_elevation(a_pos3d.xy);float ele_delta=a_pos3d.z==1.0 ? u_ele_delta : 0.0;v_texture_pos=a_pos3d.xy/8192.0;gl_Position=projectTileFor3D(a_pos3d.xy,ele-ele_delta);}"),projectionErrorMeasurement:ji("in vec4 v_output_error_encoded;void main() {fragColor=v_output_error_encoded;}","in vec2 a_pos;uniform highp float u_input;uniform highp float u_output_expected;out vec4 v_output_error_encoded;void main() {float real_output=2.0*atan(exp(PI-(u_input*PI*2.0)))-PI*0.5;float error=real_output-u_output_expected;float abs_error=abs(error)*128.0;v_output_error_encoded.x=min(floor(abs_error*256.0),255.0)/255.0;abs_error-=v_output_error_encoded.x;v_output_error_encoded.y=min(floor(abs_error*65536.0),255.0)/255.0;abs_error-=v_output_error_encoded.x/255.0;v_output_error_encoded.z=min(floor(abs_error*16777216.0),255.0)/255.0;v_output_error_encoded.w=error >=0.0 ? 1.0 : 0.0;gl_Position=vec4(a_pos,0.0,1.0);}"),atmosphere:ji("in vec3 view_direction;uniform vec3 u_sun_pos;uniform vec3 u_globe_position;uniform float u_globe_radius;uniform float u_atmosphere_blend;/**Shader use from https:*Made some change to adapt to MapLibre Globe geometry*/const float PI=3.141592653589793;const int iSteps=5;const int jSteps=3;/*radius of the planet*/const float EARTH_RADIUS=6371e3;/*radius of the atmosphere*/const float ATMOS_RADIUS=6471e3;vec2 rsi(vec3 r0,vec3 rd,float sr) {float a=dot(rd,rd);float b=2.0*dot(rd,r0);float c=dot(r0,r0)-(sr*sr);float d=(b*b)-4.0*a*c;if (d < 0.0) return vec2(1e5,-1e5);return vec2((-b-sqrt(d))/(2.0*a),(-b+sqrt(d))/(2.0*a));}vec4 atmosphere(vec3 r,vec3 r0,vec3 pSun,float iSun,float rPlanet,float rAtmos,vec3 kRlh,float kMie,float shRlh,float shMie,float g) {pSun=normalize(pSun);r=normalize(r);vec2 p=rsi(r0,r,rAtmos);if (p.x > p.y) {return vec4(0.0,0.0,0.0,1.0);}if (p.x < 0.0) {p.x=0.0;}vec3 pos=r0+r*p.x;vec2 p2=rsi(r0,r,rPlanet);if (p2.x <=p2.y && p2.x > 0.0) {p.y=min(p.y,p2.x);}float iStepSize=(p.y-p.x)/float(iSteps);float iTime=p.x+iStepSize*0.5;vec3 totalRlh=vec3(0,0,0);vec3 totalMie=vec3(0,0,0);float iOdRlh=0.0;float iOdMie=0.0;float mu=dot(r,pSun);float mumu=mu*mu;float gg=g*g;float pRlh=3.0/(16.0*PI)*(1.0+mumu);float pMie=3.0/(8.0*PI)*((1.0-gg)*(mumu+1.0))/(pow(1.0+gg-2.0*mu*g,1.5)*(2.0+gg));for (int i=0; i < iSteps; i++) {vec3 iPos=r0+r*iTime;float iHeight=length(iPos)-rPlanet;float odStepRlh=exp(-iHeight/shRlh)*iStepSize;float odStepMie=exp(-iHeight/shMie)*iStepSize;iOdRlh+=odStepRlh;iOdMie+=odStepMie;float jStepSize=rsi(iPos,pSun,rAtmos).y/float(jSteps);float jTime=jStepSize*0.5;float jOdRlh=0.0;float jOdMie=0.0;for (int j=0; j < jSteps; j++) {vec3 jPos=iPos+pSun*jTime;float jHeight=length(jPos)-rPlanet;jOdRlh+=exp(-jHeight/shRlh)*jStepSize;jOdMie+=exp(-jHeight/shMie)*jStepSize;jTime+=jStepSize;}vec3 attn=exp(-(kMie*(iOdMie+jOdMie)+kRlh*(iOdRlh+jOdRlh)));totalRlh+=odStepRlh*attn;totalMie+=odStepMie*attn;iTime+=iStepSize;}float opacity=exp(-(length(kRlh)*length(totalRlh)+kMie*length(totalMie)));vec3 color=iSun*(pRlh*kRlh*totalRlh+pMie*kMie*totalMie);return vec4(color,opacity);}void main() {vec3 scale_camera_pos=-u_globe_position*EARTH_RADIUS/u_globe_radius;vec4 color=atmosphere(normalize(view_direction),scale_camera_pos,u_sun_pos,22.0,EARTH_RADIUS,ATMOS_RADIUS,vec3(5.5e-6,13.0e-6,22.4e-6),21e-6,8e3,1.2e3,0.758\n);color.rgb=1.0-exp(-1.0*color.rgb);color=pow(color,vec4(1.0/2.2));fragColor=vec4(color.rgb,1.0-color.a)*u_atmosphere_blend;}","in vec2 a_pos;uniform mat4 u_inv_proj_matrix;out vec3 view_direction;void main() {view_direction=(u_inv_proj_matrix*vec4(a_pos,0.0,1.0)).xyz;gl_Position=vec4(a_pos,0.0,1.0);}"),sky:ji("uniform vec4 u_sky_color;uniform vec4 u_horizon_color;uniform vec2 u_horizon;uniform vec2 u_horizon_normal;uniform float u_sky_horizon_blend;uniform float u_sky_blend;void main() {float x=gl_FragCoord.x;float y=gl_FragCoord.y;float blend=(y-u_horizon.y)*u_horizon_normal.y+(x-u_horizon.x)*u_horizon_normal.x;if (blend > 0.0) {if (blend < u_sky_horizon_blend) {fragColor=mix(u_sky_color,u_horizon_color,pow(1.0-blend/u_sky_horizon_blend,2.0));} else {fragColor=u_sky_color;}}fragColor=mix(fragColor,vec4(vec3(0.0),0.0),u_sky_blend);}","in vec2 a_pos;void main() {gl_Position=vec4(a_pos,1.0,1.0);}")};function ji(e,s){const l=/#pragma mapbox: ([\w]+) ([\w]+) ([\w]+) ([\w]+)/g,c=s.match(/in ([\w]+) ([\w]+)/g),d=e.match(/uniform ([\w]+) ([\w]+)([\s]*)([\w]*)/g),p=s.match(/uniform ([\w]+) ([\w]+)([\s]*)([\w]*)/g),f=p?p.concat(d):d,m={};return{fragmentSource:e=e.replace(l,((e,s,l,c,d)=>(m[d]=!0,"define"===s?`\n#ifndef HAS_UNIFORM_u_${d}\nin ${l} ${c} ${d};\n#else\nuniform ${l} ${c} u_${d};\n#endif\n`:`\n#ifdef HAS_UNIFORM_u_${d}\n ${l} ${c} ${d} = u_${d};\n#endif\n`))),vertexSource:s=s.replace(l,((e,s,l,c,d)=>{const p="float"===c?"vec2":"vec4",f=d.match(/color/)?"color":p;return m[d]?"define"===s?`\n#ifndef HAS_UNIFORM_u_${d}\nuniform lowp float u_${d}_t;\nin ${l} ${p} a_${d};\nout ${l} ${c} ${d};\n#else\nuniform ${l} ${c} u_${d};\n#endif\n`:"vec4"===f?`\n#ifndef HAS_UNIFORM_u_${d}\n ${d} = a_${d};\n#else\n ${l} ${c} ${d} = u_${d};\n#endif\n`:`\n#ifndef HAS_UNIFORM_u_${d}\n ${d} = unpack_mix_${f}(a_${d}, u_${d}_t);\n#else\n ${l} ${c} ${d} = u_${d};\n#endif\n`:"define"===s?`\n#ifndef HAS_UNIFORM_u_${d}\nuniform lowp float u_${d}_t;\nin ${l} ${p} a_${d};\n#else\nuniform ${l} ${c} u_${d};\n#endif\n`:"vec4"===f?`\n#ifndef HAS_UNIFORM_u_${d}\n ${l} ${c} ${d} = a_${d};\n#else\n ${l} ${c} ${d} = u_${d};\n#endif\n`:`\n#ifndef HAS_UNIFORM_u_${d}\n ${l} ${c} ${d} = unpack_mix_${f}(a_${d}, u_${d}_t);\n#else\n ${l} ${c} ${d} = u_${d};\n#endif\n`})),staticAttributes:c,staticUniforms:f}}class kt{constructor(e,s,l){this.vertexBuffer=e,this.indexBuffer=s,this.segments=l}destroy(){this.vertexBuffer.destroy(),this.indexBuffer.destroy(),this.segments.destroy(),this.vertexBuffer=null,this.indexBuffer=null,this.segments=null}}var Ni=l.aU([{name:"a_pos",type:"Int16",components:2}]);const Gi="#define PROJECTION_MERCATOR",Ui="mercator";class jt{constructor(){this._cachedMesh=null}get name(){return"mercator"}get useSubdivision(){return!1}get shaderVariantName(){return Ui}get shaderDefine(){return Gi}get shaderPreludeCode(){return Vi.projectionMercator}get vertexShaderPreludeCode(){return Vi.projectionMercator.vertexSource}get subdivisionGranularity(){return l.aV.noSubdivision}get useGlobeControls(){return!1}get transitionState(){return 0}get latitudeErrorCorrectionRadians(){return 0}destroy(){}updateGPUdependent(e){}getMeshFromTileID(e,s,c,d,p){if(this._cachedMesh)return this._cachedMesh;const f=new l.aW;f.emplaceBack(0,0),f.emplaceBack(l.a5,0),f.emplaceBack(0,l.a5),f.emplaceBack(l.a5,l.a5);const m=e.createVertexBuffer(f,Ni.members),_=l.aX.simpleSegment(0,0,4,2),g=new l.aY;g.emplaceBack(1,0,2),g.emplaceBack(1,2,3);const y=e.createIndexBuffer(g);return this._cachedMesh=new kt(m,y,_),this._cachedMesh}recalculate(){}hasTransition(){return!1}setErrorQueryLatitudeDegrees(e){}}class Nt{constructor(e=0,s=0,l=0,c=0){if(isNaN(e)||e<0||isNaN(s)||s<0||isNaN(l)||l<0||isNaN(c)||c<0)throw new Error("Invalid value for edge-insets, top, bottom, left and right must all be numbers");this.top=e,this.bottom=s,this.left=l,this.right=c}interpolate(e,s,c){return null!=s.top&&null!=e.top&&(this.top=l.G.number(e.top,s.top,c)),null!=s.bottom&&null!=e.bottom&&(this.bottom=l.G.number(e.bottom,s.bottom,c)),null!=s.left&&null!=e.left&&(this.left=l.G.number(e.left,s.left,c)),null!=s.right&&null!=e.right&&(this.right=l.G.number(e.right,s.right,c)),this}getCenter(e,s){const c=l.an((this.left+e-this.right)/2,0,e),d=l.an((this.top+s-this.bottom)/2,0,s);return new l.P(c,d)}equals(e){return this.top===e.top&&this.bottom===e.bottom&&this.left===e.left&&this.right===e.right}clone(){return new Nt(this.top,this.bottom,this.left,this.right)}toJSON(){return{top:this.top,bottom:this.bottom,left:this.left,right:this.right}}}function qi(e,s){if(!e.renderWorldCopies||e.lngRange)return;const l=s.lng-e.center.lng;s.lng+=l>180?-360:l<-180?360:0}function $i(e){return Math.max(0,Math.floor(e))}class Ut{constructor(e,s){var c;this.applyConstrain=(e,s)=>null!==this._constrainOverride?this._constrainOverride(e,s):this._callbacks.defaultConstrain(e,s),this._callbacks=e,this._tileSize=512,this._renderWorldCopies=void 0===(null==s?void 0:s.renderWorldCopies)||!!(null==s?void 0:s.renderWorldCopies),this._minZoom=(null==s?void 0:s.minZoom)||0,this._maxZoom=(null==s?void 0:s.maxZoom)||22,this._minPitch=null==(null==s?void 0:s.minPitch)?0:null==s?void 0:s.minPitch,this._maxPitch=null==(null==s?void 0:s.maxPitch)?60:null==s?void 0:s.maxPitch,this._constrainOverride=null!==(c=null==s?void 0:s.constrainOverride)&&void 0!==c?c:null,this.setMaxBounds(),this._width=0,this._height=0,this._center=new l.V(0,0),this._elevation=0,this._zoom=0,this._tileZoom=$i(this._zoom),this._scale=l.aq(this._zoom),this._bearingInRadians=0,this._fovInRadians=.6435011087932844,this._pitchInRadians=0,this._rollInRadians=0,this._unmodified=!0,this._edgeInsets=new Nt,this._minElevationForCurrentTile=0,this._autoCalculateNearFarZ=!0}apply(e,s,c){this._constrainOverride=e.constrainOverride,this._latRange=e.latRange,this._lngRange=e.lngRange,this._width=e.width,this._height=e.height,this._center=e.center,this._elevation=e.elevation,this._minElevationForCurrentTile=e.minElevationForCurrentTile,this._zoom=e.zoom,this._tileZoom=$i(this._zoom),this._scale=l.aq(this._zoom),this._bearingInRadians=e.bearingInRadians,this._fovInRadians=e.fovInRadians,this._pitchInRadians=e.pitchInRadians,this._rollInRadians=e.rollInRadians,this._unmodified=e.unmodified,this._edgeInsets=new Nt(e.padding.top,e.padding.bottom,e.padding.left,e.padding.right),this._minZoom=e.minZoom,this._maxZoom=e.maxZoom,this._minPitch=e.minPitch,this._maxPitch=e.maxPitch,this._renderWorldCopies=e.renderWorldCopies,this._cameraToCenterDistance=e.cameraToCenterDistance,this._nearZ=e.nearZ,this._farZ=e.farZ,this._autoCalculateNearFarZ=!c&&e.autoCalculateNearFarZ,s&&this.constrainInternal(),this._calcMatrices()}get pixelsToClipSpaceMatrix(){return this._pixelsToClipSpaceMatrix}get clipSpaceToPixelsMatrix(){return this._clipSpaceToPixelsMatrix}get minElevationForCurrentTile(){return this._minElevationForCurrentTile}setMinElevationForCurrentTile(e){this._minElevationForCurrentTile=e}get tileSize(){return this._tileSize}get tileZoom(){return this._tileZoom}get scale(){return this._scale}get width(){return this._width}get height(){return this._height}get bearingInRadians(){return this._bearingInRadians}get lngRange(){return this._lngRange}get latRange(){return this._latRange}get pixelsToGLUnits(){return this._pixelsToGLUnits}get minZoom(){return this._minZoom}setMinZoom(e){this._minZoom!==e&&(this._minZoom=e,this.setZoom(this.applyConstrain(this._center,this.zoom).zoom))}get maxZoom(){return this._maxZoom}setMaxZoom(e){this._maxZoom!==e&&(this._maxZoom=e,this.setZoom(this.applyConstrain(this._center,this.zoom).zoom))}get minPitch(){return this._minPitch}setMinPitch(e){this._minPitch!==e&&(this._minPitch=e,this.setPitch(Math.max(this.pitch,e)))}get maxPitch(){return this._maxPitch}setMaxPitch(e){this._maxPitch!==e&&(this._maxPitch=e,this.setPitch(Math.min(this.pitch,e)))}get renderWorldCopies(){return this._renderWorldCopies}setRenderWorldCopies(e){void 0===e?e=!0:null===e&&(e=!1),this._renderWorldCopies=e}get constrainOverride(){return this._constrainOverride}setConstrainOverride(e){void 0===e&&(e=null),this._constrainOverride!==e&&(this._constrainOverride=e,this.constrainInternal(),this._calcMatrices())}get worldSize(){return this._tileSize*this._scale}get centerOffset(){return this.centerPoint._sub(this.size._div(2))}get size(){return new l.P(this._width,this._height)}get bearing(){return this._bearingInRadians/Math.PI*180}setBearing(e){const s=l.W(e,-180,180)*Math.PI/180;var c,p,f,m,_,g,y,b,T;this._bearingInRadians!==s&&(this._unmodified=!1,this._bearingInRadians=s,this._calcMatrices(),this._rotationMatrix=d(),c=this._rotationMatrix,f=-this._bearingInRadians,m=(p=this._rotationMatrix)[0],_=p[1],g=p[2],y=p[3],b=Math.sin(f),T=Math.cos(f),c[0]=m*T+g*b,c[1]=_*T+y*b,c[2]=m*-b+g*T,c[3]=_*-b+y*T)}get rotationMatrix(){return this._rotationMatrix}get pitchInRadians(){return this._pitchInRadians}get pitch(){return this._pitchInRadians/Math.PI*180}setPitch(e){const s=l.an(e,this.minPitch,this.maxPitch)/180*Math.PI;this._pitchInRadians!==s&&(this._unmodified=!1,this._pitchInRadians=s,this._calcMatrices())}get rollInRadians(){return this._rollInRadians}get roll(){return this._rollInRadians/Math.PI*180}setRoll(e){const s=e/180*Math.PI;this._rollInRadians!==s&&(this._unmodified=!1,this._rollInRadians=s,this._calcMatrices())}get fovInRadians(){return this._fovInRadians}get fov(){return l.aZ(this._fovInRadians)}setFov(e){e=l.an(e,.1,150),this.fov!==e&&(this._unmodified=!1,this._fovInRadians=l.ap(e),this._calcMatrices())}get zoom(){return this._zoom}setZoom(e){const s=this.applyConstrain(this._center,e).zoom;this._zoom!==s&&(this._unmodified=!1,this._zoom=s,this._tileZoom=Math.max(0,Math.floor(s)),this._scale=l.aq(s),this.constrainInternal(),this._calcMatrices())}get center(){return this._center}setCenter(e){e.lat===this._center.lat&&e.lng===this._center.lng||(this._unmodified=!1,this._center=e,this.constrainInternal(),this._calcMatrices())}get elevation(){return this._elevation}setElevation(e){e!==this._elevation&&(this._elevation=e,this.constrainInternal(),this._calcMatrices())}get padding(){return this._edgeInsets.toJSON()}setPadding(e){this._edgeInsets.equals(e)||(this._unmodified=!1,this._edgeInsets.interpolate(this._edgeInsets,e,1),this._calcMatrices())}get centerPoint(){return this._edgeInsets.getCenter(this._width,this._height)}get pixelsPerMeter(){return this._pixelPerMeter}get unmodified(){return this._unmodified}get cameraToCenterDistance(){return this._cameraToCenterDistance}get nearZ(){return this._nearZ}get farZ(){return this._farZ}get autoCalculateNearFarZ(){return this._autoCalculateNearFarZ}overrideNearFarZ(e,s){this._autoCalculateNearFarZ=!1,this._nearZ=e,this._farZ=s,this._calcMatrices()}clearNearFarZOverride(){this._autoCalculateNearFarZ=!0,this._calcMatrices()}isPaddingEqual(e){return this._edgeInsets.equals(e)}interpolatePadding(e,s,l){this._unmodified=!1,this._edgeInsets.interpolate(e,s,l),this.constrainInternal(),this._calcMatrices()}resize(e,s,l=!0){this._width=e,this._height=s,l&&this.constrainInternal(),this._calcMatrices()}getMaxBounds(){return this._latRange&&2===this._latRange.length&&this._lngRange&&2===this._lngRange.length?new $([this._lngRange[0],this._latRange[0]],[this._lngRange[1],this._latRange[1]]):null}setMaxBounds(e){e?(this._lngRange=[e.getWest(),e.getEast()],this._latRange=[e.getSouth(),e.getNorth()],this.constrainInternal()):(this._lngRange=null,this._latRange=[-l.ao,l.ao])}getCameraQueryGeometry(e,s){if(1===s.length)return[s[0],e];{const{minX:c,minY:d,maxX:p,maxY:f}=l.aa.fromPoints(s).extend(e);return[new l.P(c,d),new l.P(p,d),new l.P(p,f),new l.P(c,f),new l.P(c,d)]}}constrainInternal(){if(!this.center||!this._width||!this._height||this._constraining)return;this._constraining=!0;const e=this._unmodified,{center:s,zoom:l}=this.applyConstrain(this.center,this.zoom);this.setCenter(s),this.setZoom(l),this._unmodified=e,this._constraining=!1}_calcMatrices(){if(this._width&&this._height){this._pixelsToGLUnits=[2/this._width,-2/this._height];let e=l.ar(new Float64Array(16));l.Q(e,e,[this._width/2,-this._height/2,1]),l.O(e,e,[1,-1,0]),this._clipSpaceToPixelsMatrix=e,e=l.ar(new Float64Array(16)),l.Q(e,e,[1,-1,1]),l.O(e,e,[-1,-1,0]),l.Q(e,e,[2/this._width,2/this._height,1]),this._pixelsToClipSpaceMatrix=e,this._cameraToCenterDistance=.5/Math.tan(this.fovInRadians/2)*this._height}this._callbacks.calcMatrices()}calculateCenterFromCameraLngLatAlt(e,s,c,d){const p=void 0!==c?c:this.bearing,f=d=void 0!==d?d:this.pitch,{distanceToCenter:m,clampedElevation:_}=this._distanceToCenterFromAltElevationPitch(s,this.elevation,f),{x:g,y:y}=qe(f,p),b=l.a9.fromLngLat(e,s);let T,P,S=l.a_(1,b.y),I=0;do{if(I+=1,I>10)break;P=m/S,T=new l.a9(b.x+g*P,b.y+y*P),S=1/T.meterInMercatorCoordinateUnits()}while(Math.abs(m-P*S)>1e-12);return{center:T.toLngLat(),elevation:_,zoom:l.at(this.height/2/Math.tan(this.fovInRadians/2)/P/this.tileSize)}}recalculateZoomAndCenter(e){if(this.elevation-e==0)return;const s=1/this.worldSize,c=l.as(1,this.center.lat)*this.worldSize,d=l.a9.fromLngLat(this.center,this.elevation),p=d.x/s,f=d.y/s,m=d.z/s,_=this.pitch,g=this.bearing,{x:y,y:b,z:T}=qe(_,g),P=this.cameraToCenterDistance,S=p+P*-y,I=f+P*-b,C=m+P*T,{distanceToCenter:z,clampedElevation:L}=this._distanceToCenterFromAltElevationPitch(C/c,e,_),F=z*c,B=new l.a9((S+y*F)*s,(I+b*F)*s,0).toLngLat(),O=l.as(1,B.lat),j=l.at(this.height/2/Math.tan(this.fovInRadians/2)/z/O/this.tileSize);this._elevation=L,this._center=B,this.setZoom(j)}_distanceToCenterFromAltElevationPitch(e,s,c){const d=-Math.cos(l.ap(c)),p=e-s;let f,m=s;return d*p>=0||Math.abs(d)<.1?(f=1e4,m=e+f*d):f=-p/d,{distanceToCenter:f,clampedElevation:m}}getCameraPoint(){const e=Math.tan(this.pitchInRadians)*(this.cameraToCenterDistance||1);return this.centerPoint.add(new l.P(e*Math.sin(this.rollInRadians),e*Math.cos(this.rollInRadians)))}getCameraAltitude(){return Math.cos(this.pitchInRadians)*this._cameraToCenterDistance/this._pixelPerMeter+this.elevation}getCameraLngLat(){const e=l.as(1,this.center.lat)*this.worldSize;return Ue(this.center,this.elevation,this.pitch,this.bearing,this.cameraToCenterDistance/e).toLngLat()}getMercatorTileCoordinates(e){if(!e)return[0,0,1,1];const s=e.canonical.z>=0?1<this.max[0]||e.aabb.min[1]>this.max[1]||e.aabb.min[2]>this.max[2]||e.aabb.max[0]0?(s+=e[c]*this.min[c],l+=e[c]*this.max[c]):(l+=e[c]*this.min[c],s+=e[c]*this.max[c]);return s>=0?2:l<0?0:1}}class qt{distanceToTile2d(e,s,l,c){const d=c.distanceX([e,s]),p=c.distanceY([e,s]);return Math.hypot(d,p)}getWrap(e,s,l){return l}getTileBoundingVolume(e,s,c,d){var p,f;let m=0,_=0;if(null==d?void 0:d.terrain){const g=new l.a2(e.z,s,e.z,e.x,e.y),y=d.terrain.getMinMaxElevation(g);m=null!==(p=y.minElevation)&&void 0!==p?p:Math.min(0,c),_=null!==(f=y.maxElevation)&&void 0!==f?f:Math.max(0,c)}const g=1<d}allowWorldCopies(){return!0}prepareNextFrame(){}}class Wt{constructor(e,s,l){this.points=e,this.planes=s,this.aabb=l}static fromInvProjectionMatrix(e,s=1,c=0,d,p){const f=p?[[6,5,4],[0,1,2],[0,3,7],[2,1,5],[3,2,6],[0,4,5]]:[[0,1,2],[6,5,4],[0,3,7],[2,1,5],[3,2,6],[0,4,5]],m=Math.pow(2,c),_=[[-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((c=>function(e,s,c,d){const p=l.aH([],e,s),f=1/p[3]/c*d;return l.b6(p,p,[f,f,1/p[3],f])}(c,e,s,m)));d&&function(e,s,c,d){const p=d?4:0,f=d?0:4;let m=0;const _=[],g=[];for(let s=0;s<4;s++){const c=l.b2([],e[s+f],e[s+p]),d=l.b7(c);l.a$(c,c,1/d),_.push(d),g.push(c)}for(let s=0;s<4;s++){const d=l.b8(e[s+p],g[s],c);m=null!==d&&d>=0?Math.max(m,d):Math.max(m,_[s])}const y=function(e,s){const c=l.b2([],e[s[0]],e[s[1]]),d=l.b2([],e[s[2]],e[s[1]]),p=[0,0,0,0];return l.b3(p,l.b4([],c,d)),p[3]=-l.b5(p,e[s[0]]),p}(e,s),b=function(e,s){const c=l.b9(e),d=l.ba([],e,1/c),p=l.b2([],s,l.a$([],d,l.b5(s,d))),f=l.b9(p);if(f>0){const e=Math.sqrt(1-d[3]*d[3]),c=l.a$([],d,-d[3]),m=l.b0([],c,l.a$([],p,e/f));return l.bb(s,m)}return null}(c,y);if(null!==b){const e=b/l.b5(g[0],y);m=Math.min(m,e)}for(let s=0;s<4;s++){const l=Math.min(m,_[s]);e[s+f]=[e[s+p][0]+g[s][0]*l,e[s+p][1]+g[s][1]*l,e[s+p][2]+g[s][2]*l,1]}}(_,f[0],d,p);const g=f.map((e=>{const s=l.b2([],_[e[0]],_[e[1]]),c=l.b2([],_[e[2]],_[e[1]]),d=l.b3([],l.b4([],s,c)),p=-l.b5(d,_[e[1]]);return d.concat(p)})),y=[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY],b=[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY];for(const e of _)for(let s=0;s<3;s++)y[s]=Math.min(y[s],e[s]),b[s]=Math.max(b[s],e[s]);return new Wt(_,g,new Vt(y,b))}}class $t{get pixelsToClipSpaceMatrix(){return this._helper.pixelsToClipSpaceMatrix}get clipSpaceToPixelsMatrix(){return this._helper.clipSpaceToPixelsMatrix}get pixelsToGLUnits(){return this._helper.pixelsToGLUnits}get centerOffset(){return this._helper.centerOffset}get size(){return this._helper.size}get rotationMatrix(){return this._helper.rotationMatrix}get centerPoint(){return this._helper.centerPoint}get pixelsPerMeter(){return this._helper.pixelsPerMeter}setMinZoom(e){this._helper.setMinZoom(e)}setMaxZoom(e){this._helper.setMaxZoom(e)}setMinPitch(e){this._helper.setMinPitch(e)}setMaxPitch(e){this._helper.setMaxPitch(e)}setRenderWorldCopies(e){this._helper.setRenderWorldCopies(e)}setBearing(e){this._helper.setBearing(e)}setPitch(e){this._helper.setPitch(e)}setRoll(e){this._helper.setRoll(e)}setFov(e){this._helper.setFov(e)}setZoom(e){this._helper.setZoom(e)}setCenter(e){this._helper.setCenter(e)}setElevation(e){this._helper.setElevation(e)}setMinElevationForCurrentTile(e){this._helper.setMinElevationForCurrentTile(e)}setPadding(e){this._helper.setPadding(e)}interpolatePadding(e,s,l){return this._helper.interpolatePadding(e,s,l)}isPaddingEqual(e){return this._helper.isPaddingEqual(e)}resize(e,s,l=!0){this._helper.resize(e,s,l)}getMaxBounds(){return this._helper.getMaxBounds()}setMaxBounds(e){this._helper.setMaxBounds(e)}setConstrainOverride(e){this._helper.setConstrainOverride(e)}overrideNearFarZ(e,s){this._helper.overrideNearFarZ(e,s)}clearNearFarZOverride(){this._helper.clearNearFarZOverride()}getCameraQueryGeometry(e){return this._helper.getCameraQueryGeometry(this.getCameraPoint(),e)}get tileSize(){return this._helper.tileSize}get tileZoom(){return this._helper.tileZoom}get scale(){return this._helper.scale}get worldSize(){return this._helper.worldSize}get width(){return this._helper.width}get height(){return this._helper.height}get lngRange(){return this._helper.lngRange}get latRange(){return this._helper.latRange}get minZoom(){return this._helper.minZoom}get maxZoom(){return this._helper.maxZoom}get zoom(){return this._helper.zoom}get center(){return this._helper.center}get minPitch(){return this._helper.minPitch}get maxPitch(){return this._helper.maxPitch}get pitch(){return this._helper.pitch}get pitchInRadians(){return this._helper.pitchInRadians}get roll(){return this._helper.roll}get rollInRadians(){return this._helper.rollInRadians}get bearing(){return this._helper.bearing}get bearingInRadians(){return this._helper.bearingInRadians}get fov(){return this._helper.fov}get fovInRadians(){return this._helper.fovInRadians}get elevation(){return this._helper.elevation}get minElevationForCurrentTile(){return this._helper.minElevationForCurrentTile}get padding(){return this._helper.padding}get unmodified(){return this._helper.unmodified}get renderWorldCopies(){return this._helper.renderWorldCopies}get cameraToCenterDistance(){return this._helper.cameraToCenterDistance}get constrainOverride(){return this._helper.constrainOverride}get nearZ(){return this._helper.nearZ}get farZ(){return this._helper.farZ}get autoCalculateNearFarZ(){return this._helper.autoCalculateNearFarZ}setTransitionState(e,s){}constructor(e){this._posMatrixCache=new Map,this._alignedPosMatrixCache=new Map,this._fogMatrixCacheF32=new Map,this.defaultConstrain=(e,s)=>{s=l.an(+s,this.minZoom,this.maxZoom);const c={center:new l.V(e.lng,e.lat),zoom:s};let d=this._helper._lngRange;if(!this._helper._renderWorldCopies&&null===d){const e=180-1e-10;d=[-e,e]}const p=this.tileSize*l.aq(c.zoom);let f=0,m=p,_=0,g=p,y=0,b=0;const{x:T,y:P}=this.size;if(this._helper._latRange){const e=this._helper._latRange;f=l.X(e[1])*p,m=l.X(e[0])*p,m-fm&&(z=m-e)}if(d){const e=(_+g)/2;let s=S;this._helper._renderWorldCopies&&(s=l.W(S,e-p/2,e+p/2));const c=T/2;s-c<_&&(C=_+c),s+c>g&&(C=g-c)}if(void 0!==C||void 0!==z){const e=new l.P(null!=C?C:S,null!=z?z:I);c.center=Ae(p,e).wrap()}return c},this.applyConstrain=(e,s)=>this._helper.applyConstrain(e,s),this._helper=new Ut({calcMatrices:()=>{this._calcMatrices()},defaultConstrain:(e,s)=>this.defaultConstrain(e,s)},e),this._coveringTilesDetailsProvider=new qt}clone(){const e=new $t;return e.apply(this),e}apply(e,s,l){this._helper.apply(e,s,l)}get cameraPosition(){return this._cameraPosition}get projectionMatrix(){return this._projectionMatrix}get modelViewProjectionMatrix(){return this._viewProjMatrix}get inverseProjectionMatrix(){return this._invProjMatrix}get mercatorMatrix(){return this._mercatorMatrix}getVisibleUnwrappedCoordinates(e){const s=[new l.bc(0,e)];if(this._helper._renderWorldCopies){const c=this.screenPointToMercatorCoordinate(new l.P(0,0)),d=this.screenPointToMercatorCoordinate(new l.P(this._helper._width,0)),p=this.screenPointToMercatorCoordinate(new l.P(this._helper._width,this._helper._height)),f=this.screenPointToMercatorCoordinate(new l.P(0,this._helper._height)),m=Math.floor(Math.min(c.x,d.x,p.x,f.x)),_=Math.floor(Math.max(c.x,d.x,p.x,f.x)),g=1;for(let c=m-g;c<=_+g;c++)0!==c&&s.push(new l.bc(c,e))}return s}getCameraFrustum(){return Wt.fromInvProjectionMatrix(this._invViewProjMatrix,this.worldSize)}getClippingPlane(){return null}getCoveringTilesDetailsProvider(){return this._coveringTilesDetailsProvider}recalculateZoomAndCenter(e){const s=this.screenPointToLocation(this.centerPoint,e),l=e?e.getElevationForLngLatZoom(s,this._helper._tileZoom):0;this._helper.recalculateZoomAndCenter(l)}setLocationAtPoint(e,s){const c=l.as(this.elevation,this.center.lat),d=this.screenPointToMercatorCoordinateAtZ(s,c),p=this.screenPointToMercatorCoordinateAtZ(this.centerPoint,c),f=l.a9.fromLngLat(e),m=new l.a9(f.x-(d.x-p.x),f.y-(d.y-p.y));this.setCenter(null==m?void 0:m.toLngLat()),this._helper._renderWorldCopies&&this.setCenter(this.center.wrap())}locationToScreenPoint(e,s){return s?this.coordinatePoint(l.a9.fromLngLat(e),s.getElevationForLngLat(e,this),this._pixelMatrix3D):this.coordinatePoint(l.a9.fromLngLat(e))}screenPointToLocation(e,s){var l;return null===(l=this.screenPointToMercatorCoordinate(e,s))||void 0===l?void 0:l.toLngLat()}screenPointToMercatorCoordinate(e,s){if(s){const l=s.pointCoordinate(e);if(null!=l)return l}return this.screenPointToMercatorCoordinateAtZ(e)}screenPointToMercatorCoordinateAtZ(e,s){const c=s||0,d=[e.x,e.y,0,1],p=[e.x,e.y,1,1];l.aH(d,d,this._pixelMatrixInverse),l.aH(p,p,this._pixelMatrixInverse);const f=d[3],m=p[3],_=d[1]/f,g=p[1]/m,y=d[2]/f,b=p[2]/m,T=y===b?0:(c-y)/(b-y);return new l.a9(l.G.number(d[0]/f,p[0]/m,T)/this.worldSize,l.G.number(_,g,T)/this.worldSize,c)}coordinatePoint(e,s=0,c=this._pixelMatrix){const d=[e.x*this.worldSize,e.y*this.worldSize,s,1];return l.aH(d,d,c),new l.P(d[0]/d[3],d[1]/d[3])}getBounds(){const e=Math.max(0,this._helper._height/2-Ne(this));return(new $).extend(this.screenPointToLocation(new l.P(0,e))).extend(this.screenPointToLocation(new l.P(this._helper._width,e))).extend(this.screenPointToLocation(new l.P(this._helper._width,this._helper._height))).extend(this.screenPointToLocation(new l.P(0,this._helper._height)))}isPointOnMapSurface(e,s){return s?null!=s.pointCoordinate(e):e.y>this.height/2-Ne(this)}calculatePosMatrix(e,s=!1,c){var d;const p=null!==(d=e.key)&&void 0!==d?d:l.bd(e.wrap,e.canonical.z,e.canonical.z,e.canonical.x,e.canonical.y),f=s?this._alignedPosMatrixCache:this._posMatrixCache;if(f.has(p)){const e=f.get(p);return c?e.f32:e.f64}const m=Ge(e,this.worldSize);l.S(m,s?this._alignedProjMatrix:this._viewProjMatrix,m);const _={f64:m,f32:new Float32Array(m)};return f.set(p,_),c?_.f32:_.f64}calculateFogMatrix(e){const s=e.key,c=this._fogMatrixCacheF32;if(c.has(s))return c.get(s);const d=Ge(e,this.worldSize);return l.S(d,this._fogMatrix,d),c.set(s,new Float32Array(d)),c.get(s)}calculateCenterFromCameraLngLatAlt(e,s,l,c){return this._helper.calculateCenterFromCameraLngLatAlt(e,s,l,c)}_calculateNearFarZIfNeeded(e,s,c){if(!this._helper.autoCalculateNearFarZ)return;const d=Math.min(this.elevation,this.minElevationForCurrentTile,this.getCameraAltitude()-100),p=e-d*this._helper._pixelPerMeter/Math.cos(s),f=d<0?p:e,m=Math.PI/2+this.pitchInRadians,_=l.ap(this.fov)*(Math.abs(Math.cos(l.ap(this.roll)))*this.height+Math.abs(Math.sin(l.ap(this.roll)))*this.width)/this.height*(.5+c.y/this.height),g=Math.sin(_)*f/Math.sin(l.an(Math.PI-m-_,.01,Math.PI-.01)),y=Ne(this),b=Math.atan(y/this._helper.cameraToCenterDistance),T=l.ap(.75),P=b>T?2*b*(.5+c.y/(2*y)):T,S=Math.sin(P)*f/Math.sin(l.an(Math.PI-m-P,.01,Math.PI-.01)),I=Math.min(g,S);this._helper._farZ=1.01*(Math.cos(Math.PI/2-s)*I+f),this._helper._nearZ=this._helper._height/50}_calcMatrices(){if(!this._helper._height)return;const e=this.centerOffset,s=Ce(this.worldSize,this.center),c=s.x,d=s.y;this._helper._pixelPerMeter=l.as(1,this.center.lat)*this.worldSize;const p=l.ap(Math.min(this.pitch,Ee)),f=Math.max(this._helper.cameraToCenterDistance/2,this._helper.cameraToCenterDistance+this._helper._elevation*this._helper._pixelPerMeter/Math.cos(p));let m;this._calculateNearFarZIfNeeded(f,p,e),m=new Float64Array(16),l.be(m,this.fovInRadians,this._helper._width/this._helper._height,this._helper._nearZ,this._helper._farZ),this._invProjMatrix=new Float64Array(16),l.aB(this._invProjMatrix,m),m[8]=2*-e.x/this._helper._width,m[9]=2*e.y/this._helper._height,this._projectionMatrix=l.bf(m),l.Q(m,m,[1,-1,1]),l.O(m,m,[0,0,-this._helper.cameraToCenterDistance]),l.bg(m,m,-this.rollInRadians),l.bh(m,m,this.pitchInRadians),l.bg(m,m,-this.bearingInRadians),l.O(m,m,[-c,-d,0]),this._mercatorMatrix=l.Q([],m,[this.worldSize,this.worldSize,this.worldSize]),l.Q(m,m,[1,1,this._helper._pixelPerMeter]),this._pixelMatrix=l.S(new Float64Array(16),this.clipSpaceToPixelsMatrix,m),l.O(m,m,[0,0,-this.elevation]),this._viewProjMatrix=m,this._invViewProjMatrix=l.aB([],m);const _=[0,0,-1,1];l.aH(_,_,this._invViewProjMatrix),this._cameraPosition=[_[0]/_[3],_[1]/_[3],_[2]/_[3]],this._fogMatrix=new Float64Array(16),l.be(this._fogMatrix,this.fovInRadians,this.width/this.height,f,this._helper._farZ),this._fogMatrix[8]=2*-e.x/this.width,this._fogMatrix[9]=2*e.y/this.height,l.Q(this._fogMatrix,this._fogMatrix,[1,-1,1]),l.O(this._fogMatrix,this._fogMatrix,[0,0,-this.cameraToCenterDistance]),l.bg(this._fogMatrix,this._fogMatrix,-this.rollInRadians),l.bh(this._fogMatrix,this._fogMatrix,this.pitchInRadians),l.bg(this._fogMatrix,this._fogMatrix,-this.bearingInRadians),l.O(this._fogMatrix,this._fogMatrix,[-c,-d,0]),l.Q(this._fogMatrix,this._fogMatrix,[1,1,this._helper._pixelPerMeter]),l.O(this._fogMatrix,this._fogMatrix,[0,0,-this.elevation]),this._pixelMatrix3D=l.S(new Float64Array(16),this.clipSpaceToPixelsMatrix,m);const g=this._helper._width%2/2,y=this._helper._height%2/2,b=Math.cos(this.bearingInRadians),T=Math.sin(-this.bearingInRadians),P=c-Math.round(c)+b*g+T*y,S=d-Math.round(d)+b*y+T*g,I=new Float64Array(m);if(l.O(I,I,[P>.5?P-1:P,S>.5?S-1:S,0]),this._alignedProjMatrix=I,m=l.aB(new Float64Array(16),this._pixelMatrix),!m)throw new Error("failed to invert matrix");this._pixelMatrixInverse=m,this._clearMatrixCaches()}_clearMatrixCaches(){this._posMatrixCache.clear(),this._alignedPosMatrixCache.clear(),this._fogMatrixCacheF32.clear()}maxPitchScaleFactor(){if(!this._pixelMatrixInverse)return 1;const e=this.screenPointToMercatorCoordinate(new l.P(0,0)),s=[e.x*this.worldSize,e.y*this.worldSize,0,1];return l.aH(s,s,this._pixelMatrix)[3]/this._helper.cameraToCenterDistance}getCameraPoint(){return this._helper.getCameraPoint()}getCameraAltitude(){return this._helper.getCameraAltitude()}getCameraLngLat(){const e=l.as(1,this.center.lat)*this.worldSize;return Ue(this.center,this.elevation,this.pitch,this.bearing,this._helper.cameraToCenterDistance/e).toLngLat()}lngLatToCameraDepth(e,s){const c=l.a9.fromLngLat(e),d=[c.x*this.worldSize,c.y*this.worldSize,s,1];return l.aH(d,d,this._viewProjMatrix),d[2]/d[3]}getProjectionData(e){const{overscaledTileID:s,aligned:c,applyTerrainMatrix:d}=e,p=this._helper.getMercatorTileCoordinates(s),f=s?this.calculatePosMatrix(s,c,!0):null;let m;return m=s&&s.terrainRttPosMatrix32f&&d?s.terrainRttPosMatrix32f:f||l.bi(),{mainMatrix:m,tileMercatorCoords:p,clippingPlane:[0,0,0,0],projectionTransition:0,fallbackMatrix:m}}isLocationOccluded(e){return!1}getPixelScale(){return 1}getCircleRadiusCorrection(){return 1}getPitchedTextCorrection(e,s,l){return 1}transformLightDirection(e){return l.b1(e)}getRayDirectionFromPixel(e){throw new Error("Not implemented.")}projectTileCoordinates(e,s,c,d){const p=this.calculatePosMatrix(c);let f;d?(f=[e,s,d(e,s),1],l.aH(f,f,p)):(f=[e,s,0,1],mi(f,f,p));const m=f[3];return{point:new l.P(f[0]/m,f[1]/m),signedDistanceFromCamera:m,isOccluded:!1}}populateCache(e){for(const s of e)this.calculatePosMatrix(s)}getMatrixForModel(e,s){const c=l.a9.fromLngLat(e,s),d=c.meterInMercatorCoordinateUnits(),p=l.bj();return l.O(p,p,[c.x,c.y,c.z]),l.bg(p,p,Math.PI),l.bh(p,p,Math.PI/2),l.Q(p,p,[-d,d,d]),p}getProjectionDataForCustomLayer(e=!0){const s=new l.a2(0,0,0,0,0),c=this.getProjectionData({overscaledTileID:s,applyGlobeMatrix:e}),d=Ge(s,this.worldSize);l.S(d,this._viewProjMatrix,d),c.tileMercatorCoords=[0,0,1,1];const p=[l.a5,l.a5,this.worldSize/this._helper.pixelsPerMeter],f=l.bk();return l.Q(f,d,p),c.fallbackMatrix=f,c.mainMatrix=f,c}getFastPathSimpleProjectionMatrix(e){return this.calculatePosMatrix(e)}}function Wi(){l.w("Map cannot fit within canvas with the given bounds, padding, and/or offset.")}function Hi(e){if(e.useSlerp)if(e.k<1){const s=l.bl(e.startEulerAngles.roll,e.startEulerAngles.pitch,e.startEulerAngles.bearing),c=l.bl(e.endEulerAngles.roll,e.endEulerAngles.pitch,e.endEulerAngles.bearing),d=new Float64Array(4);l.bm(d,s,c,e.k);const p=l.bn(d);e.tr.setRoll(p.roll),e.tr.setPitch(p.pitch),e.tr.setBearing(p.bearing)}else e.tr.setRoll(e.endEulerAngles.roll),e.tr.setPitch(e.endEulerAngles.pitch),e.tr.setBearing(e.endEulerAngles.bearing);else e.tr.setRoll(l.G.number(e.startEulerAngles.roll,e.endEulerAngles.roll,e.k)),e.tr.setPitch(l.G.number(e.startEulerAngles.pitch,e.endEulerAngles.pitch,e.k)),e.tr.setBearing(l.G.number(e.startEulerAngles.bearing,e.endEulerAngles.bearing,e.k))}function Xi(e,s,c,d,p){const f=p.padding,m=Ce(p.worldSize,c.getNorthWest()),_=Ce(p.worldSize,c.getNorthEast()),g=Ce(p.worldSize,c.getSouthEast()),y=Ce(p.worldSize,c.getSouthWest()),b=l.ap(-d),T=m.rotate(b),P=_.rotate(b),S=g.rotate(b),I=y.rotate(b),C=new l.P(Math.max(T.x,P.x,I.x,S.x),Math.max(T.y,P.y,I.y,S.y)),z=new l.P(Math.min(T.x,P.x,I.x,S.x),Math.min(T.y,P.y,I.y,S.y)),L=C.sub(z),F=(p.width-(f.left+f.right+s.left+s.right))/L.x,B=(p.height-(f.top+f.bottom+s.top+s.bottom))/L.y;if(B<0||F<0)return void Wi();const O=Math.min(l.at(p.scale*Math.min(F,B)),e.maxZoom),j=l.P.convert(e.offset),G=new l.P((s.left-s.right)/2,(s.top-s.bottom)/2).rotate(l.ap(d)),U=j.add(G).mult(p.scale/l.aq(O));return{center:Ae(p.worldSize,m.add(g).div(2).sub(U)),zoom:O,bearing:d}}class Yt{get useGlobeControls(){return!1}handlePanInertia(e,s){const l=e.mag(),c=Math.abs(Ne(s));return{easingOffset:e.mult(Math.min(.75*c/l,1)),easingCenter:s.center}}handleMapControlsRollPitchBearingZoom(e,s){e.bearingDelta&&s.setBearing(s.bearing+e.bearingDelta),e.pitchDelta&&s.setPitch(s.pitch+e.pitchDelta),e.rollDelta&&s.setRoll(s.roll+e.rollDelta),e.zoomDelta&&s.setZoom(s.zoom+e.zoomDelta)}handleMapControlsPan(e,s,l){e.around.distSqr(s.centerPoint)<.01||s.setLocationAtPoint(l,e.around)}cameraForBoxAndBearing(e,s,l,c,d){return Xi(e,s,l,c,d)}handleJumpToCenterZoom(e,s){e.zoom!==(void 0!==s.zoom?+s.zoom:e.zoom)&&e.setZoom(+s.zoom),void 0!==s.center&&e.setCenter(l.V.convert(s.center))}handleEaseTo(e,s){const c=e.zoom,d=e.padding,p={roll:e.roll,pitch:e.pitch,bearing:e.bearing},f={roll:void 0===s.roll?e.roll:s.roll,pitch:void 0===s.pitch?e.pitch:s.pitch,bearing:void 0===s.bearing?e.bearing:s.bearing},m=void 0!==s.zoom,_=!e.isPaddingEqual(s.padding);let g=!1;const y=m?+s.zoom:e.zoom;let b=e.centerPoint.add(s.offsetAsPoint);const T=e.screenPointToLocation(b),{center:P,zoom:S}=e.applyConstrain(l.V.convert(s.center||T),null!=y?y:c);qi(e,P);const I=Ce(e.worldSize,T),C=Ce(e.worldSize,P).sub(I),z=l.aq(S-c);return g=S!==c,{easeFunc:m=>{if(g&&e.setZoom(l.G.number(c,S,m)),l.bo(p,f)||Hi({startEulerAngles:p,endEulerAngles:f,tr:e,k:m,useSlerp:p.roll!=f.roll}),_&&(e.interpolatePadding(d,s.padding,m),b=e.centerPoint.add(s.offsetAsPoint)),s.around)e.setLocationAtPoint(s.around,s.aroundPoint);else{const s=l.aq(e.zoom-c),d=S>c?Math.min(2,z):Math.max(.5,z),p=Math.pow(d,1-m),f=Ae(e.worldSize,I.add(C.mult(m*p)).mult(s));e.setLocationAtPoint(e.renderWorldCopies?f.wrap():f,b)}},isZooming:g,elevationCenter:P}}handleFlyTo(e,s){const c=void 0!==s.zoom,d=e.zoom,p=e.applyConstrain(l.V.convert(s.center||s.locationAtOffset),c?+s.zoom:d),f=p.center,m=p.zoom;qi(e,f);const _=Ce(e.worldSize,s.locationAtOffset),g=Ce(e.worldSize,f).sub(_),y=g.mag(),b=l.aq(m-d);let T;if(void 0!==s.minZoom){const c=Math.min(+s.minZoom,d,m),p=e.applyConstrain(f,c).zoom;T=l.aq(p-d)}return{easeFunc:(s,c,p,y)=>{e.setZoom(1===s?m:d+l.at(c));const b=1===s?f:Ae(e.worldSize,_.add(g.mult(p)).mult(c));e.setLocationAtPoint(e.renderWorldCopies?b.wrap():b,y)},scaleOfZoom:b,targetCenter:f,scaleOfMinZoom:T,pixelPathLength:y}}}class Qt{constructor(e,s,l){this.blendFunction=e,this.blendColor=s,this.mask=l}}Qt.Replace=[1,0],Qt.disabled=new Qt(Qt.Replace,l.bp.transparent,[!1,!1,!1,!1]),Qt.unblended=new Qt(Qt.Replace,l.bp.transparent,[!0,!0,!0,!0]),Qt.alphaBlended=new Qt([1,771],l.bp.transparent,[!0,!0,!0,!0]);const Yi=2305;class ei{constructor(e,s,l){this.enable=e,this.mode=s,this.frontFace=l}}ei.disabled=new ei(!1,1029,Yi),ei.backCCW=new ei(!0,1029,Yi),ei.frontCCW=new ei(!0,1028,Yi);class ti{constructor(e,s,l){this.func=e,this.mask=s,this.range=l}}ti.ReadOnly=!1,ti.ReadWrite=!0,ti.disabled=new ti(519,ti.ReadOnly,[0,1]);const Ki=7680;class ai{constructor(e,s,l,c,d,p){this.test=e,this.ref=s,this.mask=l,this.fail=c,this.depthFail=d,this.pass=p}}ai.disabled=new ai({func:519,mask:0},0,0,Ki,Ki,Ki);const Qi=new WeakMap;function Ji(e){var s;if(Qi.has(e))return Qi.get(e);{const l=null===(s=e.getParameter(e.VERSION))||void 0===s?void 0:s.startsWith("WebGL 2.0");return Qi.set(e,l),l}}class si{get awaitingQuery(){return!!this._readbackQueue}constructor(e){this._readbackWaitFrames=4,this._measureWaitFrames=6,this._texWidth=1,this._texHeight=1,this._measuredError=0,this._updateCount=0,this._lastReadbackFrame=-1e3,this._readbackQueue=null,this._cachedRenderContext=e;const s=e.context,c=s.gl;this._texFormat=c.RGBA,this._texType=c.UNSIGNED_BYTE;const d=new l.aW;d.emplaceBack(-1,-1),d.emplaceBack(2,-1),d.emplaceBack(-1,2);const p=new l.aY;p.emplaceBack(0,1,2),this._fullscreenTriangle=new kt(s.createVertexBuffer(d,Ni.members),s.createIndexBuffer(p),l.aX.simpleSegment(0,0,d.length,p.length)),this._resultBuffer=new Uint8Array(4),s.activeTexture.set(c.TEXTURE1);const f=c.createTexture();c.bindTexture(c.TEXTURE_2D,f),c.texParameteri(c.TEXTURE_2D,c.TEXTURE_WRAP_S,c.CLAMP_TO_EDGE),c.texParameteri(c.TEXTURE_2D,c.TEXTURE_WRAP_T,c.CLAMP_TO_EDGE),c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MIN_FILTER,c.NEAREST),c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MAG_FILTER,c.NEAREST),c.texImage2D(c.TEXTURE_2D,0,this._texFormat,this._texWidth,this._texHeight,0,this._texFormat,this._texType,null),this._fbo=s.createFramebuffer(this._texWidth,this._texHeight,!1,!1),this._fbo.colorAttachment.set(f),Ji(c)&&(this._pbo=c.createBuffer(),c.bindBuffer(c.PIXEL_PACK_BUFFER,this._pbo),c.bufferData(c.PIXEL_PACK_BUFFER,4,c.STREAM_READ),c.bindBuffer(c.PIXEL_PACK_BUFFER,null))}destroy(){const e=this._cachedRenderContext.context.gl;this._fullscreenTriangle.destroy(),this._fbo.destroy(),e.deleteBuffer(this._pbo),this._fullscreenTriangle=null,this._fbo=null,this._pbo=null,this._resultBuffer=null}updateErrorLoop(e,s){const l=this._updateCount;return this._readbackQueue?l>=this._readbackQueue.frameNumberIssued+this._readbackWaitFrames&&this._tryReadback():l>=this._lastReadbackFrame+this._measureWaitFrames&&this._renderErrorTexture(e,s),this._updateCount++,this._measuredError}_bindFramebuffer(){const e=this._cachedRenderContext.context,s=e.gl;e.activeTexture.set(s.TEXTURE1),s.bindTexture(s.TEXTURE_2D,this._fbo.colorAttachment.get()),e.bindFramebuffer.set(this._fbo.framebuffer)}_renderErrorTexture(e,s){const c=this._cachedRenderContext.context,d=c.gl;if(this._bindFramebuffer(),c.viewport.set([0,0,this._texWidth,this._texHeight]),c.clear({color:l.bp.transparent}),this._cachedRenderContext.useProgram("projectionErrorMeasurement").draw(c,d.TRIANGLES,ti.disabled,ai.disabled,Qt.unblended,ei.disabled,((e,s)=>({u_input:e,u_output_expected:s}))(e,s),null,null,"$clipping",this._fullscreenTriangle.vertexBuffer,this._fullscreenTriangle.indexBuffer,this._fullscreenTriangle.segments),this._pbo&&Ji(d)){d.bindBuffer(d.PIXEL_PACK_BUFFER,this._pbo),d.readBuffer(d.COLOR_ATTACHMENT0),d.readPixels(0,0,this._texWidth,this._texHeight,this._texFormat,this._texType,0),d.bindBuffer(d.PIXEL_PACK_BUFFER,null);const e=d.fenceSync(d.SYNC_GPU_COMMANDS_COMPLETE,0);d.flush(),this._readbackQueue={frameNumberIssued:this._updateCount,sync:e}}else this._readbackQueue={frameNumberIssued:this._updateCount,sync:null}}_tryReadback(){const e=this._cachedRenderContext.context.gl;if(this._pbo&&this._readbackQueue&&Ji(e)){const s=e.clientWaitSync(this._readbackQueue.sync,0,0);if(s===e.WAIT_FAILED)return l.w("WebGL2 clientWaitSync failed."),this._readbackQueue=null,void(this._lastReadbackFrame=this._updateCount);if(s===e.TIMEOUT_EXPIRED)return;e.bindBuffer(e.PIXEL_PACK_BUFFER,this._pbo),e.getBufferSubData(e.PIXEL_PACK_BUFFER,0,this._resultBuffer,0,4),e.bindBuffer(e.PIXEL_PACK_BUFFER,null)}else this._bindFramebuffer(),e.readPixels(0,0,this._texWidth,this._texHeight,this._texFormat,this._texType,this._resultBuffer);this._readbackQueue=null,this._measuredError=si._parseRGBA8float(this._resultBuffer),this._lastReadbackFrame=this._updateCount}static _parseRGBA8float(e){let s=0;return s+=e[0]/256,s+=e[1]/65536,s+=e[2]/16777216,e[3]<127&&(s=-s),s/128}}const lr=l.a5/128;function cr(e,s){const c=void 0!==e.granularity?Math.max(e.granularity,1):1,d=c+(e.generateBorders?2:0),p=c+(e.extendToNorthPole||e.generateBorders?1:0)+(e.extendToSouthPole||e.generateBorders?1:0),f=d+1,m=p+1,_=e.generateBorders?-1:0,g=e.generateBorders||e.extendToNorthPole?-1:0,y=c+(e.generateBorders?1:0),b=c+(e.generateBorders||e.extendToSouthPole?1:0),T=f*m,P=d*p*6,S=f*m>65536;if(S&&"16bit"===s)throw new Error("Granularity is too large and meshes would not fit inside 16 bit vertex indices.");const I=S||"32bit"===s,C=new Int16Array(2*T);let z=0;for(let s=g;s<=b;s++)for(let d=_;d<=y;d++){let p=d/c*l.a5;-1===d&&(p=-lr),d===c+1&&(p=l.a5+lr);let f=s/c*l.a5;-1===s&&(f=e.extendToNorthPole?l.br:-lr),s===c+1&&(f=e.extendToSouthPole?l.bs:l.a5+lr),C[z++]=p,C[z++]=f}const L=I?new Uint32Array(P):new Uint16Array(P);let F=0;for(let e=0;e0}get latitudeErrorCorrectionRadians(){return this._verticalPerspectiveProjection.latitudeErrorCorrectionRadians}get currentProjection(){return this.useGlobeRendering?this._verticalPerspectiveProjection:this._mercatorProjection}get name(){return"globe"}get useSubdivision(){return this.currentProjection.useSubdivision}get shaderVariantName(){return this.currentProjection.shaderVariantName}get shaderDefine(){return this.currentProjection.shaderDefine}get shaderPreludeCode(){return this.currentProjection.shaderPreludeCode}get vertexShaderPreludeCode(){return this.currentProjection.vertexShaderPreludeCode}get subdivisionGranularity(){return this.currentProjection.subdivisionGranularity}get useGlobeControls(){return this.transitionState>0}destroy(){this._mercatorProjection.destroy(),this._verticalPerspectiveProjection.destroy()}updateGPUdependent(e){this._mercatorProjection.updateGPUdependent(e),this._verticalPerspectiveProjection.updateGPUdependent(e)}getMeshFromTileID(e,s,l,c,d){return this.currentProjection.getMeshFromTileID(e,s,l,c,d)}setProjection(e){this._transitionable.setValue("type",(null==e?void 0:e.type)||"mercator")}updateTransitions(e){this._transitioning=this._transitionable.transitioned(e,this._transitioning)}hasTransition(){return this._transitioning.hasTransition()||this.currentProjection.hasTransition()}recalculate(e){this.properties=this._transitioning.possiblyEvaluate(e)}setErrorQueryLatitudeDegrees(e){this._verticalPerspectiveProjection.setErrorQueryLatitudeDegrees(e),this._mercatorProjection.setErrorQueryLatitudeDegrees(e)}}function dr(e){const s=gr(e.worldSize,e.center.lat);return 2*Math.PI*s}function pr(e,s,c,d,p){const f=1/(1<1e-6){const d=e[0]/c,p=Math.acos(e[2]/c),f=(d>0?p:-p)/Math.PI*180;return new l.V(l.W(f,-180,180),s)}return new l.V(0,s)}function xr(e){return Math.cos(e*Math.PI/180)}function vr(e,s){const c=xr(e),d=xr(s);return l.at(d/c)}function br(e,s){const c=e.rotate(s.bearingInRadians),d=s.zoom+vr(s.center.lat,0),p=l.bu(1/xr(s.center.lat),1/xr(Math.min(Math.abs(s.center.lat),60)),l.bx(d,7,3,0,1)),f=360/dr({worldSize:s.worldSize,center:{lat:s.center.lat}});return new l.V(s.center.lng-c.x*f*p,l.an(s.center.lat+c.y*f,-l.ao,l.ao))}function wr(e){const s=.5*e,l=Math.sin(s),c=Math.cos(s);return Math.log(l+c)-Math.log(c-l)}function Pr(e,s,c,d){const p=e.lat+c*d;if(Math.abs(c)>1){const f=(Math.sign(e.lat+c)!==Math.sign(e.lat)?-Math.abs(e.lat):Math.abs(e.lat))*Math.PI/180,m=Math.abs(e.lat+c)*Math.PI/180,_=wr(f+d*(m-f)),g=wr(f),y=wr(m);return new l.V(e.lng+s*((_-g)/(y-g)),p)}return new l.V(e.lng+s*d,p)}class Ti{constructor(e){this._cachePrevious=new Map,this._cache=new Map,this._hadAnyChanges=!1,this._boundingVolumeFactory=e}swapBuffers(){if(!this._hadAnyChanges)return;const e=this._cachePrevious;this._cachePrevious=this._cache,this._cache=e,this._cache.clear(),this._hadAnyChanges=!1}getTileBoundingVolume(e,s,l,c){const d=`${e.z}_${e.x}_${e.y}_${(null==c?void 0:c.terrain)?"t":""}`,p=this._cache.get(d);if(p)return p;const f=this._cachePrevious.get(d);if(f)return this._cache.set(d,f),f;const m=this._boundingVolumeFactory(e,s,l,c);return this._cache.set(d,m),this._hadAnyChanges=!0,m}}class Pi{constructor(e,s,l,c){this.min=l,this.max=c,this.points=e,this.planes=s}static fromAabb(e,s){const l=[];for(let c=0;c<8;c++)l.push([1&~c?e[0]:s[0],1==(c>>1&1)?s[1]:e[1],1==(c>>2&1)?s[2]:e[2]]);return new Pi(l,[[-1,0,0,s[0]],[1,0,0,-e[0]],[0,-1,0,s[1]],[0,1,0,-e[1]],[0,0,-1,s[2]],[0,0,1,-e[2]]],e,s)}static fromCenterSizeAngles(e,s,c){const d=l.bB([],c[0],c[1],c[2]),p=l.bC([],[s[0],0,0],d),f=l.bC([],[0,s[1],0],d),m=l.bC([],[0,0,s[2]],d),_=[...e],g=[...e];for(let s=0;s<8;s++)for(let l=0;l<3;l++){const c=e[l]+p[l]*(1&~s?-1:1)+f[l]*(1==(s>>1&1)?1:-1)+m[l]*(1==(s>>2&1)?1:-1);_[l]=Math.min(_[l],c),g[l]=Math.max(g[l],c)}const y=[];for(let s=0;s<8;s++){const c=[...e];l.b0(c,c,l.a$([],p,1&~s?-1:1)),l.b0(c,c,l.a$([],f,1==(s>>1&1)?1:-1)),l.b0(c,c,l.a$([],m,1==(s>>2&1)?1:-1)),y.push(c)}return new Pi(y,[[...p,-l.b5(p,y[0])],[...f,-l.b5(f,y[0])],[...m,-l.b5(m,y[0])],[-p[0],-p[1],-p[2],-l.b5(p,y[7])],[-f[0],-f[1],-f[2],-l.b5(f,y[7])],[-m[0],-m[1],-m[2],-l.b5(m,y[7])]],_,g)}intersectsFrustum(e){let s=!0;const l=this.points.length,c=this.planes.length,d=e.planes.length,p=e.points.length;for(let c=0;c=0&&p++}if(0===p)return 0;p=0&&c++}if(0===c)return 0}return 1}intersectsPlane(e){const s=this.points.length;let l=0;for(let c=0;c=0&&l++}return l===s?2:0===l?0:1}}function Sr(e,s,l){const c=e-s;return c<0?-c:Math.max(0,c-l)}function Cr(e,s,l,c,d){const p=e-l;let f;return f=p<0?Math.min(-p,1+p-d):p>1?Math.min(Math.max(p-d,0),1-p):0,Math.max(f,Sr(s,c,d))}class Mi{constructor(){this._boundingVolumeCache=new Ti(this._computeTileBoundingVolume)}prepareNextFrame(){this._boundingVolumeCache.swapBuffers()}distanceToTile2d(e,s,l,c){const d=1<4}allowWorldCopies(){return!1}getTileBoundingVolume(e,s,l,c){return this._boundingVolumeCache.getTileBoundingVolume(e,s,l,c)}_computeTileBoundingVolume(e,s,c,d){var p,f;let m=0,_=0;if(null==d?void 0:d.terrain){const g=new l.a2(e.z,s,e.z,e.x,e.y),y=d.terrain.getMinMaxElevation(g);m=null!==(p=y.minElevation)&&void 0!==p?p:Math.min(0,c),_=null!==(f=y.maxElevation)&&void 0!==f?f:Math.max(0,c)}if(m/=l.bE,_/=l.bE,m+=1,_+=1,e.z<=0)return Pi.fromAabb([-_,-_,-_],[_,_,_]);if(1===e.z)return Pi.fromAabb([0===e.x?-_:0,0===e.y?0:-_,-_],[0===e.x?0:_,0===e.y?_:0,_]);{const s=[pr(0,0,e.x,e.y,e.z),pr(l.a5,0,e.x,e.y,e.z),pr(l.a5,l.a5,e.x,e.y,e.z),pr(0,l.a5,e.x,e.y,e.z)],c=[];for(const e of s)c.push(l.a$([],e,_));if(_!==m)for(const e of s)c.push(l.a$([],e,m));0===e.y&&c.push([0,1,0]),e.y===(1<=(1<{const c=l.an(e.lat,-l.ao,l.ao),d=l.an(+s,this.minZoom+vr(0,c),this.maxZoom);return{center:new l.V(e.lng,c),zoom:d}},this.applyConstrain=(e,s)=>this._helper.applyConstrain(e,s),this._helper=new Ut({calcMatrices:()=>{this._calcMatrices()},defaultConstrain:(e,s)=>this.defaultConstrain(e,s)},e),this._coveringTilesDetailsProvider=new Mi}clone(){const e=new Si;return e.apply(this),e}apply(e,s){this._globeLatitudeErrorCorrectionRadians=s||0,this._helper.apply(e)}get projectionMatrix(){return this._projectionMatrix}get modelViewProjectionMatrix(){return this._globeViewProjMatrixNoCorrection}get inverseProjectionMatrix(){return this._globeProjMatrixInverted}get cameraPosition(){const e=l.bz();return e[0]=this._cameraPosition[0],e[1]=this._cameraPosition[1],e[2]=this._cameraPosition[2],e}get cameraToCenterDistance(){return this._helper.cameraToCenterDistance}getProjectionData(e){const{overscaledTileID:s,applyGlobeMatrix:l}=e,c=this._helper.getMercatorTileCoordinates(s);return{mainMatrix:this._globeViewProjMatrix32f,tileMercatorCoords:c,clippingPlane:this._cachedClippingPlane,projectionTransition:l?1:0,fallbackMatrix:this._globeViewProjMatrix32f}}_computeClippingPlane(e){const s=this.pitchInRadians,c=this.cameraToCenterDistance/e,d=Math.sin(s)*c,p=Math.cos(s)*c+1,f=1/Math.sqrt(d*d+p*p)*1;let m=-d,_=p;const g=Math.sqrt(m*m+_*_);m/=g,_/=g;const y=[0,m,_];l.bG(y,y,[0,0,0],-this.bearingInRadians),l.bH(y,y,[0,0,0],-1*this.center.lat*Math.PI/180),l.bI(y,y,[0,0,0],this.center.lng*Math.PI/180);const b=1/l.b7(y);return l.a$(y,y,b),[...y,-f*b]}isLocationOccluded(e){return!this.isSurfacePointVisible(_r(e))}transformLightDirection(e){const s=this._helper._center.lng*Math.PI/180,c=this._helper._center.lat*Math.PI/180,d=Math.cos(c),p=[Math.sin(s)*d,Math.sin(c),Math.cos(s)*d],f=[p[2],0,-p[0]],m=[0,0,0];l.b4(m,f,p),l.b3(f,f),l.b3(m,m);const _=[0,0,0];return l.b3(_,[f[0]*e[0]+m[0]*e[1]+p[0]*e[2],f[1]*e[0]+m[1]*e[1]+p[1]*e[2],f[2]*e[0]+m[2]*e[1]+p[2]*e[2]]),_}getPixelScale(){return 1/Math.cos(this._helper._center.lat*Math.PI/180)}getCircleRadiusCorrection(){return Math.cos(this._helper._center.lat*Math.PI/180)}getPitchedTextCorrection(e,s,c){const d=function(e,s,c){const d=1/(1<p&&(p=s),c<_&&(_=c),c>m&&(m=c)}const y=[g.lng+f,g.lat+_,g.lng+p,g.lat+m];return this.isSurfacePointOnScreen([0,1,0])&&(y[3]=90,y[0]=-180,y[2]=180),this.isSurfacePointOnScreen([0,-1,0])&&(y[1]=-90,y[0]=-180,y[2]=180),new $(y)}calculateCenterFromCameraLngLatAlt(e,s,l,c){return this._helper.calculateCenterFromCameraLngLatAlt(e,s,l,c)}setLocationAtPoint(e,s){const c=_r(this.unprojectScreenPoint(s)),d=_r(e),p=l.bz();l.bL(p);const f=l.bz();l.bI(f,c,p,-this.center.lng*Math.PI/180),l.bH(f,f,p,this.center.lat*Math.PI/180);const m=d[0]*d[0]+d[2]*d[2],_=f[0]*f[0];if(m<_)return;const g=Math.sqrt(m-_),y=-g,b=l.bM(d[0],d[2],f[0],g),T=l.bM(d[0],d[2],f[0],y),P=l.bz();l.bI(P,d,p,-b);const S=l.bM(P[1],P[2],f[1],f[2]),I=l.bz();l.bI(I,d,p,-T);const C=l.bM(I[1],I[2],f[1],f[2]),z=.5*Math.PI,L=S>=-z&&S<=z,F=C>=-z&&C<=z;let B,O;if(L&&F){const e=this.center.lng*Math.PI/180,s=this.center.lat*Math.PI/180;l.bN(b,e)+l.bN(S,s)=0}isSurfacePointOnScreen(e){if(!this.isSurfacePointVisible(e))return!1;const s=l.bF();return l.aH(s,[...e,1],this._globeViewProjMatrixNoCorrection),s[0]/=s[3],s[1]/=s[3],s[2]/=s[3],s[0]>-1&&s[0]<1&&s[1]>-1&&s[1]<1&&s[2]>-1&&s[2]<1}rayPlanetIntersection(e,s){const c=l.b5(e,s),d=l.bz(),p=l.bz();l.a$(p,s,c),l.b2(d,e,p);const f=1-l.b5(d,d);if(f<0)return null;const m=l.b5(e,e)-1,_=-c+(c<0?1:-1)*Math.sqrt(f),g=m/_,y=_;return{tMin:Math.min(g,y),tMax:Math.max(g,y)}}unprojectScreenPoint(e){const s=this._cameraPosition,c=this.getRayDirectionFromPixel(e),d=this.rayPlanetIntersection(s,c);if(d){const e=l.bz();l.b0(e,s,[c[0]*d.tMin,c[1]*d.tMin,c[2]*d.tMin]);const p=l.bz();return l.b3(p,e),yr(p)}const p=this._cachedClippingPlane,f=p[0]*c[0]+p[1]*c[1]+p[2]*c[2],m=-l.bb(p,s)/f,_=l.bz();if(m>0)l.b0(_,s,[c[0]*m,c[1]*m,c[2]*m]);else{const e=l.bz();l.b0(e,s,[2*c[0],2*c[1],2*c[2]]);const d=l.bb(this._cachedClippingPlane,e);l.b2(_,e,[this._cachedClippingPlane[0]*d,this._cachedClippingPlane[1]*d,this._cachedClippingPlane[2]*d])}const g=function(e){const s=l.bz();return s[0]=e[0]*-e[3],s[1]=e[1]*-e[3],s[2]=e[2]*-e[3],{center:s,radius:Math.sqrt(1-e[3]*e[3])}}(p);return yr(function(e,s,c){const d=l.bz();l.b2(d,c,e);const p=l.bz();return l.bA(p,e,d,s/l.b9(d)),p}(g.center,g.radius,_))}getMatrixForModel(e,s){const c=l.V.convert(e),d=1/l.bE,p=l.bj();return l.bJ(p,p,c.lng/180*Math.PI),l.bh(p,p,-c.lat/180*Math.PI),l.O(p,p,[0,0,1+s/l.bE]),l.bh(p,p,.5*Math.PI),l.Q(p,p,[d,d,d]),p}getProjectionDataForCustomLayer(e=!0){const s=this.getProjectionData({overscaledTileID:new l.a2(0,0,0,0,0),applyGlobeMatrix:e});return s.tileMercatorCoords=[0,0,1,1],s}getFastPathSimpleProjectionMatrix(e){}}class Ri{get pixelsToClipSpaceMatrix(){return this._helper.pixelsToClipSpaceMatrix}get clipSpaceToPixelsMatrix(){return this._helper.clipSpaceToPixelsMatrix}get pixelsToGLUnits(){return this._helper.pixelsToGLUnits}get centerOffset(){return this._helper.centerOffset}get size(){return this._helper.size}get rotationMatrix(){return this._helper.rotationMatrix}get centerPoint(){return this._helper.centerPoint}get pixelsPerMeter(){return this._helper.pixelsPerMeter}setMinZoom(e){this._helper.setMinZoom(e)}setMaxZoom(e){this._helper.setMaxZoom(e)}setMinPitch(e){this._helper.setMinPitch(e)}setMaxPitch(e){this._helper.setMaxPitch(e)}setRenderWorldCopies(e){this._helper.setRenderWorldCopies(e)}setBearing(e){this._helper.setBearing(e)}setPitch(e){this._helper.setPitch(e)}setRoll(e){this._helper.setRoll(e)}setFov(e){this._helper.setFov(e)}setZoom(e){this._helper.setZoom(e)}setCenter(e){this._helper.setCenter(e)}setElevation(e){this._helper.setElevation(e)}setMinElevationForCurrentTile(e){this._helper.setMinElevationForCurrentTile(e)}setPadding(e){this._helper.setPadding(e)}interpolatePadding(e,s,l){return this._helper.interpolatePadding(e,s,l)}isPaddingEqual(e){return this._helper.isPaddingEqual(e)}resize(e,s,l=!0){this._helper.resize(e,s,l)}getMaxBounds(){return this._helper.getMaxBounds()}setMaxBounds(e){this._helper.setMaxBounds(e)}setConstrainOverride(e){this._helper.setConstrainOverride(e)}overrideNearFarZ(e,s){this._helper.overrideNearFarZ(e,s)}clearNearFarZOverride(){this._helper.clearNearFarZOverride()}getCameraQueryGeometry(e){return this._helper.getCameraQueryGeometry(this.getCameraPoint(),e)}get tileSize(){return this._helper.tileSize}get tileZoom(){return this._helper.tileZoom}get scale(){return this._helper.scale}get worldSize(){return this._helper.worldSize}get width(){return this._helper.width}get height(){return this._helper.height}get lngRange(){return this._helper.lngRange}get latRange(){return this._helper.latRange}get minZoom(){return this._helper.minZoom}get maxZoom(){return this._helper.maxZoom}get zoom(){return this._helper.zoom}get center(){return this._helper.center}get minPitch(){return this._helper.minPitch}get maxPitch(){return this._helper.maxPitch}get pitch(){return this._helper.pitch}get pitchInRadians(){return this._helper.pitchInRadians}get roll(){return this._helper.roll}get rollInRadians(){return this._helper.rollInRadians}get bearing(){return this._helper.bearing}get bearingInRadians(){return this._helper.bearingInRadians}get fov(){return this._helper.fov}get fovInRadians(){return this._helper.fovInRadians}get elevation(){return this._helper.elevation}get minElevationForCurrentTile(){return this._helper.minElevationForCurrentTile}get padding(){return this._helper.padding}get unmodified(){return this._helper.unmodified}get renderWorldCopies(){return this._helper.renderWorldCopies}get cameraToCenterDistance(){return this._helper.cameraToCenterDistance}get constrainOverride(){return this._helper.constrainOverride}get nearZ(){return this._helper.nearZ}get farZ(){return this._helper.farZ}get autoCalculateNearFarZ(){return this._helper.autoCalculateNearFarZ}get isGlobeRendering(){return this._globeness>0}setTransitionState(e,s){this._globeness=e,this._globeLatitudeErrorCorrectionRadians=s,this._calcMatrices(),this._verticalPerspectiveTransform.getCoveringTilesDetailsProvider().prepareNextFrame(),this._mercatorTransform.getCoveringTilesDetailsProvider().prepareNextFrame()}get currentTransform(){return this.isGlobeRendering?this._verticalPerspectiveTransform:this._mercatorTransform}constructor(e){this._globeLatitudeErrorCorrectionRadians=0,this._globeness=1,this.defaultConstrain=(e,s)=>this.currentTransform.defaultConstrain(e,s),this.applyConstrain=(e,s)=>this._helper.applyConstrain(e,s),this._helper=new Ut({calcMatrices:()=>{this._calcMatrices()},defaultConstrain:(e,s)=>this.defaultConstrain(e,s)},e),this._globeness=1,this._mercatorTransform=new $t,this._verticalPerspectiveTransform=new Si}clone(){const e=new Ri;return e._globeness=this._globeness,e._globeLatitudeErrorCorrectionRadians=this._globeLatitudeErrorCorrectionRadians,e.apply(this),e}apply(e){this._helper.apply(e),this._mercatorTransform.apply(this),this._verticalPerspectiveTransform.apply(this,this._globeLatitudeErrorCorrectionRadians)}get projectionMatrix(){return this.currentTransform.projectionMatrix}get modelViewProjectionMatrix(){return this.currentTransform.modelViewProjectionMatrix}get inverseProjectionMatrix(){return this.currentTransform.inverseProjectionMatrix}get cameraPosition(){return this.currentTransform.cameraPosition}getProjectionData(e){const s=this._mercatorTransform.getProjectionData(e),l=this._verticalPerspectiveTransform.getProjectionData(e);return{mainMatrix:this.isGlobeRendering?l.mainMatrix:s.mainMatrix,clippingPlane:l.clippingPlane,tileMercatorCoords:l.tileMercatorCoords,projectionTransition:e.applyGlobeMatrix?this._globeness:0,fallbackMatrix:s.fallbackMatrix}}isLocationOccluded(e){return this.currentTransform.isLocationOccluded(e)}transformLightDirection(e){return this.currentTransform.transformLightDirection(e)}getPixelScale(){return l.bu(this._mercatorTransform.getPixelScale(),this._verticalPerspectiveTransform.getPixelScale(),this._globeness)}getCircleRadiusCorrection(){return l.bu(this._mercatorTransform.getCircleRadiusCorrection(),this._verticalPerspectiveTransform.getCircleRadiusCorrection(),this._globeness)}getPitchedTextCorrection(e,s,c){const d=this._mercatorTransform.getPitchedTextCorrection(e,s,c),p=this._verticalPerspectiveTransform.getPitchedTextCorrection(e,s,c);return l.bu(d,p,this._globeness)}projectTileCoordinates(e,s,l,c){return this.currentTransform.projectTileCoordinates(e,s,l,c)}_calcMatrices(){this._helper._width&&this._helper._height&&(this._verticalPerspectiveTransform.apply(this,this._globeLatitudeErrorCorrectionRadians),this._helper._nearZ=this._verticalPerspectiveTransform.nearZ,this._helper._farZ=this._verticalPerspectiveTransform.farZ,this._mercatorTransform.apply(this,!0,this.isGlobeRendering),this._helper._nearZ=this._mercatorTransform.nearZ,this._helper._farZ=this._mercatorTransform.farZ)}calculateFogMatrix(e){return this.currentTransform.calculateFogMatrix(e)}getVisibleUnwrappedCoordinates(e){return this.currentTransform.getVisibleUnwrappedCoordinates(e)}getCameraFrustum(){return this.currentTransform.getCameraFrustum()}getClippingPlane(){return this.currentTransform.getClippingPlane()}getCoveringTilesDetailsProvider(){return this.currentTransform.getCoveringTilesDetailsProvider()}recalculateZoomAndCenter(e){this._mercatorTransform.recalculateZoomAndCenter(e),this._verticalPerspectiveTransform.recalculateZoomAndCenter(e)}maxPitchScaleFactor(){return this._mercatorTransform.maxPitchScaleFactor()}getCameraPoint(){return this._helper.getCameraPoint()}getCameraAltitude(){return this._helper.getCameraAltitude()}getCameraLngLat(){return this._helper.getCameraLngLat()}lngLatToCameraDepth(e,s){return this.currentTransform.lngLatToCameraDepth(e,s)}populateCache(e){this._mercatorTransform.populateCache(e),this._verticalPerspectiveTransform.populateCache(e)}getBounds(){return this.currentTransform.getBounds()}calculateCenterFromCameraLngLatAlt(e,s,l,c){return this._helper.calculateCenterFromCameraLngLatAlt(e,s,l,c)}setLocationAtPoint(e,s){if(!this.isGlobeRendering)return this._mercatorTransform.setLocationAtPoint(e,s),void this.apply(this._mercatorTransform);this._verticalPerspectiveTransform.setLocationAtPoint(e,s),this.apply(this._verticalPerspectiveTransform)}locationToScreenPoint(e,s){return this.currentTransform.locationToScreenPoint(e,s)}screenPointToMercatorCoordinate(e,s){return this.currentTransform.screenPointToMercatorCoordinate(e,s)}screenPointToLocation(e,s){return this.currentTransform.screenPointToLocation(e,s)}isPointOnMapSurface(e,s){return this.currentTransform.isPointOnMapSurface(e,s)}getRayDirectionFromPixel(e){return this._verticalPerspectiveTransform.getRayDirectionFromPixel(e)}getMatrixForModel(e,s){return this.currentTransform.getMatrixForModel(e,s)}getProjectionDataForCustomLayer(e=!0){const s=this._mercatorTransform.getProjectionDataForCustomLayer(e);if(!this.isGlobeRendering)return s;const l=this._verticalPerspectiveTransform.getProjectionDataForCustomLayer(e);return l.fallbackMatrix=s.mainMatrix,l}getFastPathSimpleProjectionMatrix(e){return this.currentTransform.getFastPathSimpleProjectionMatrix(e)}}class zi{get useGlobeControls(){return!0}handlePanInertia(e,s){const c=br(e,s);return Math.abs(c.lng-s.center.lng)>180&&(c.lng=s.center.lng+179.5*Math.sign(c.lng-s.center.lng)),{easingCenter:c,easingOffset:new l.P(0,0)}}handleMapControlsRollPitchBearingZoom(e,s){const c=e.around,d=s.screenPointToLocation(c);e.bearingDelta&&s.setBearing(s.bearing+e.bearingDelta),e.pitchDelta&&s.setPitch(s.pitch+e.pitchDelta),e.rollDelta&&s.setRoll(s.roll+e.rollDelta);const p=s.zoom;e.zoomDelta&&s.setZoom(s.zoom+e.zoomDelta);const f=s.zoom-p;if(0===f)return;const m=l.bK(s.center.lng,d.lng),_=m/(Math.abs(m/180)+1),g=l.bK(s.center.lat,d.lat),y=s.getRayDirectionFromPixel(c),b=s.cameraPosition,T=-1*l.b5(b,y),P=l.bz();l.b0(P,b,[y[0]*T,y[1]*T,y[2]*T]);const S=l.b7(P)-1,I=Math.exp(.5*-Math.max(S-.3,0)),C=gr(s.worldSize,s.center.lat)/Math.min(s.width,s.height),z=l.bx(C,.9,.5,1,.25),L=(1-l.aq(-f))*Math.min(I,z),F=s.center.lat,B=s.zoom,O=new l.V(s.center.lng+_*L,l.an(s.center.lat+g*L,-l.ao,l.ao));s.setLocationAtPoint(d,c);const j=s.center,G=l.bx(Math.abs(m),45,85,0,1),U=l.bx(C,.75,.35,0,1),q=Math.pow(Math.max(G,U),.25),Z=l.bK(j.lng,O.lng),W=l.bK(j.lat,O.lat);s.setCenter(new l.V(j.lng+Z*q,j.lat+W*q).wrap()),s.setZoom(B+vr(F,s.center.lat))}handleMapControlsPan(e,s,l){if(!e.panDelta)return;const c=s.center.lat,d=s.zoom;s.setCenter(br(e.panDelta,s).wrap()),s.setZoom(d+vr(c,s.center.lat))}cameraForBoxAndBearing(e,s,c,d,p){const f=Xi(e,s,c,d,p),m=s.left/p.width*2-1,_=(p.width-s.right)/p.width*2-1,g=s.top/p.height*-2+1,y=(p.height-s.bottom)/p.height*-2+1,b=l.bK(c.getWest(),c.getEast())<0,T=b?c.getEast():c.getWest(),P=b?c.getWest():c.getEast(),S=Math.max(c.getNorth(),c.getSouth()),I=Math.min(c.getNorth(),c.getSouth()),C=T+.5*l.bK(T,P),z=S+.5*l.bK(S,I),L=p.clone();L.setCenter(f.center),L.setBearing(f.bearing),L.setPitch(0),L.setRoll(0),L.setZoom(f.zoom);const F=L.modelViewProjectionMatrix,B=[_r(c.getNorthWest()),_r(c.getNorthEast()),_r(c.getSouthWest()),_r(c.getSouthEast()),_r(new l.V(P,z)),_r(new l.V(T,z)),_r(new l.V(C,S)),_r(new l.V(C,I))],O=_r(f.center);let j=Number.POSITIVE_INFINITY;for(const e of B)m<0&&(j=zi.getLesserNonNegativeNonNull(j,zi.solveVectorScale(e,O,F,"x",m))),_>0&&(j=zi.getLesserNonNegativeNonNull(j,zi.solveVectorScale(e,O,F,"x",_))),g>0&&(j=zi.getLesserNonNegativeNonNull(j,zi.solveVectorScale(e,O,F,"y",g))),y<0&&(j=zi.getLesserNonNegativeNonNull(j,zi.solveVectorScale(e,O,F,"y",y)));if(Number.isFinite(j)&&0!==j)return f.zoom=L.zoom+l.at(j),f;Wi()}handleJumpToCenterZoom(e,s){const c=e.center.lat,d=e.applyConstrain(s.center?l.V.convert(s.center):e.center,e.zoom).center;e.setCenter(d.wrap());const p=void 0!==s.zoom?+s.zoom:e.zoom+vr(c,d.lat);e.zoom!==p&&e.setZoom(p)}handleEaseTo(e,s){const c=e.zoom,d=e.center,p=e.padding,f={roll:e.roll,pitch:e.pitch,bearing:e.bearing},m={roll:void 0===s.roll?e.roll:s.roll,pitch:void 0===s.pitch?e.pitch:s.pitch,bearing:void 0===s.bearing?e.bearing:s.bearing},_=void 0!==s.zoom,g=!e.isPaddingEqual(s.padding);let y=!1;const b=s.center?l.V.convert(s.center):d,T=e.applyConstrain(b,c).center;qi(e,T);const P=e.clone();P.setCenter(T),P.setZoom(_?+s.zoom:c+vr(d.lat,b.lat)),P.setBearing(s.bearing);const S=new l.P(l.an(e.centerPoint.x+s.offsetAsPoint.x,0,e.width),l.an(e.centerPoint.y+s.offsetAsPoint.y,0,e.height));P.setLocationAtPoint(T,S);const I=(s.offset&&s.offsetAsPoint.mag())>0?P.center:T,C=_?+s.zoom:c+vr(d.lat,I.lat),z=c+vr(d.lat,0),L=C+vr(I.lat,0),F=l.bK(d.lng,I.lng),B=l.bK(d.lat,I.lat),O=l.aq(L-z);return y=C!==c,{easeFunc:c=>{if(l.bo(f,m)||Hi({startEulerAngles:f,endEulerAngles:m,tr:e,k:c,useSlerp:f.roll!=m.roll}),g&&e.interpolatePadding(p,s.padding,c),s.around)l.w("Easing around a point is not supported under globe projection."),e.setLocationAtPoint(s.around,s.aroundPoint);else{const s=L>z?Math.min(2,O):Math.max(.5,O),l=Math.pow(s,1-c),p=Pr(d,F,B,c*l);e.setCenter(p.wrap())}if(y){const s=l.G.number(z,L,c)+vr(0,e.center.lat);e.setZoom(s)}},isZooming:y,elevationCenter:I}}handleFlyTo(e,s){const c=void 0!==s.zoom,d=e.center,p=e.zoom,f=e.padding,m=!e.isPaddingEqual(s.padding),_=e.applyConstrain(l.V.convert(s.center||s.locationAtOffset),p).center,g=c?+s.zoom:e.zoom+vr(e.center.lat,_.lat),y=e.clone();y.setCenter(_),y.setZoom(g),y.setBearing(s.bearing);const b=new l.P(l.an(e.centerPoint.x+s.offsetAsPoint.x,0,e.width),l.an(e.centerPoint.y+s.offsetAsPoint.y,0,e.height));y.setLocationAtPoint(_,b);const T=y.center;qi(e,T);const P=function(e,s,c){const d=_r(s),p=_r(c),f=l.b5(d,p),m=Math.acos(f),_=dr(e);return m/(2*Math.PI)*_}(e,d,T),S=p+vr(d.lat,0),I=g+vr(T.lat,0),C=l.aq(I-S);let z;if("number"==typeof s.minZoom){const c=+s.minZoom+vr(T.lat,0),d=Math.min(c,S,I)+vr(0,T.lat),p=e.applyConstrain(T,d).zoom+vr(T.lat,0);z=l.aq(p-S)}const L=l.bK(d.lng,T.lng),F=l.bK(d.lat,T.lat);return{easeFunc:(c,p,_,y)=>{const b=Pr(d,L,F,_);m&&e.interpolatePadding(f,s.padding,c);const P=1===c?T:b;e.setCenter(P.wrap());const I=S+l.at(p);e.setZoom(1===c?g:I+vr(0,P.lat))},scaleOfZoom:C,targetCenter:T,scaleOfMinZoom:z,pixelPathLength:P}}static solveVectorScale(e,s,l,c,d){const p="x"===c?[l[0],l[4],l[8],l[12]]:[l[1],l[5],l[9],l[13]],f=[l[3],l[7],l[11],l[15]],m=e[0]*p[0]+e[1]*p[1]+e[2]*p[2],_=e[0]*f[0]+e[1]*f[1]+e[2]*f[2],g=s[0]*p[0]+s[1]*p[1]+s[2]*p[2],y=s[0]*f[0]+s[1]*f[1]+s[2]*f[2];return g+d*_===m+d*y||f[3]*(m-g)+p[3]*(y-_)+m*y==g*_?null:(g+p[3]-d*y-d*f[3])/(g-m-d*y+d*_)}static getLesserNonNegativeNonNull(e,s){return null!==s&&s>=0&&sl.B(e,s&&s.filter((e=>"source.canvas"!==e.identifier))),zr=l.bO();class ki extends l.E{constructor(e,s={}){var c,d;super(),this._rtlPluginLoaded=()=>{for(const e in this.tileManagers){const s=this.tileManagers[e].getSource().type;"vector"!==s&&"geojson"!==s||this.tileManagers[e].reload()}},this.map=e,this.dispatcher=new N(oe(),e._getMapId()),this.dispatcher.registerMessageHandler("GG",((e,s)=>this.getGlyphs(e,s))),this.dispatcher.registerMessageHandler("GI",((e,s)=>this.getImages(e,s))),this.dispatcher.registerMessageHandler("GDA",((e,s)=>this.getDashes(e,s))),this.imageManager=new w,this.imageManager.setEventedParent(this);const p=(null===(c=e._container)||void 0===c?void 0:c.lang)||"undefined"!=typeof document&&(null===(d=document.documentElement)||void 0===d?void 0:d.lang)||void 0;this.glyphManager=new M(e._requestManager,s.localIdeographFontFamily,p),this.lineAtlas=new A(256,512),this.crossTileSymbolIndex=new zt,this._setInitialValues(),this._resetUpdates(),this.dispatcher.broadcast("SR",l.bP()),we().on(ve,this._rtlPluginLoaded),this.on("data",(e=>{if("source"!==e.dataType||"metadata"!==e.sourceDataType)return;const s=this.tileManagers[e.sourceId];if(!s)return;const l=s.getSource();if(l&&l.vectorLayerIds)for(const e in this._layers){const s=this._layers[e];s.source===l.id&&this._validateLayer(s)}}))}_setInitialValues(){var e;this._spritesImagesIds={},this._layers={},this._order=[],this.tileManagers={},this.zoomHistory=new l.bQ,this._availableImages=[],this._globalState={},this._serializedLayers={},this.stylesheet=null,this.light=null,this.sky=null,this.projection&&(this.projection.destroy(),delete this.projection),this._loaded=!1,this._changed=!1,this._updatedLayers={},this._updatedSources={},this._changedImages={},this._glyphsDidChange=!1,this._updatedPaintProps={},this._layerOrderChanged=!1,this.crossTileSymbolIndex=new((null===(e=this.crossTileSymbolIndex)||void 0===e?void 0:e.constructor)||Object),this.pauseablePlacement=void 0,this.placement=void 0,this.z=0}setGlobalStateProperty(e,s){var c,d,p;this._checkLoaded();const f=null===s?null!==(p=null===(d=null===(c=this.stylesheet.state)||void 0===c?void 0:c[e])||void 0===d?void 0:d.default)&&void 0!==p?p:null:s;if(l.bR(f,this._globalState[e]))return this;this._globalState[e]=f,this._applyGlobalStateChanges([e])}getGlobalState(){return this._globalState}setGlobalState(e){this._checkLoaded();const s=[];for(const c in e)!l.bR(this._globalState[c],e[c].default)&&(s.push(c),this._globalState[c]=e[c].default);this._applyGlobalStateChanges(s)}_applyGlobalStateChanges(e){if(0===e.length)return;const s=new Set,l={};for(const c of e){l[c]=this._globalState[c];for(const e in this._layers){const l=this._layers[e],d=l.getLayoutAffectingGlobalStateRefs(),p=l.getPaintAffectingGlobalStateRefs(),f=l.getVisibilityAffectingGlobalStateRefs();if(d.has(c)&&s.add(l.source),p.has(c))for(const{name:e,value:s}of p.get(c))this._updatePaintProperty(l,e,s);(null==f?void 0:f.has(c))&&(l.recalculateVisibility(),this._updateLayer(l))}}this.dispatcher.broadcast("UGS",l);for(const e in this.tileManagers)s.has(e)&&(this._reloadSource(e),this._changed=!0)}loadURL(e,s={},c){this.fire(new l.l("dataloading",{dataType:"style"})),s.validate="boolean"!=typeof s.validate||s.validate;const d=this.map._requestManager.transformRequest(e,"Style");this._loadStyleRequest=new AbortController;const p=this._loadStyleRequest;l.j(d,this._loadStyleRequest).then((e=>{this._loadStyleRequest=null,this._load(e.data,s,c)})).catch((e=>{this._loadStyleRequest=null,e&&!p.signal.aborted&&this.fire(new l.k(e))}))}loadJSON(e,s={},c){this.fire(new l.l("dataloading",{dataType:"style"})),this._frameRequest=new AbortController,_.frameAsync(this._frameRequest).then((()=>{this._frameRequest=null,s.validate=!1!==s.validate,this._load(e,s,c)})).catch((()=>{}))}loadEmpty(){this.fire(new l.l("dataloading",{dataType:"style"})),this._load(zr,{validate:!1})}_load(e,s,c){var d,p;let f=s.transformStyle?s.transformStyle(c,e):e;if(!s.validate||!Dr(this,l.C(f))){f=Object.assign({},f),this._loaded=!0,this.stylesheet=f;for(const e in f.sources)this.addSource(e,f.sources[e],{validate:!1});f.sprite?this._loadSprite(f.sprite):this.imageManager.setLoaded(!0),this.glyphManager.setURL(f.glyphs),this._createLayers(),this.light=new R(this.stylesheet.light),this._setProjectionInternal((null===(d=this.stylesheet.projection)||void 0===d?void 0:d.type)||"mercator"),this.sky=new D(this.stylesheet.sky),this.map.setTerrain(null!==(p=this.stylesheet.terrain)&&void 0!==p?p:null),this.fire(new l.l("data",{dataType:"style"})),this.fire(new l.l("style.load"))}}_createLayers(){var e,s,c;const d=l.bS(this.stylesheet.layers);this.setGlobalState(null!==(e=this.stylesheet.state)&&void 0!==e?e:null),this.dispatcher.broadcast("SL",d),this._order=d.map((e=>e.id)),this._layers={},this._serializedLayers=null;for(const e of d){const d=l.bT(e,this._globalState);if(d.setEventedParent(this,{layer:{id:e.id}}),this._layers[e.id]=d,l.bU(d)&&this.tileManagers[d.source]){const l=null!==(c=null===(s=e.paint)||void 0===s?void 0:s["raster-fade-duration"])&&void 0!==c?c:d.paint.get("raster-fade-duration");this.tileManagers[d.source].setRasterFadeDuration(l)}}}_loadSprite(e,s=!1,c=void 0){this.imageManager.setLoaded(!1);const d=new AbortController;let p;this._spriteRequest=d,function(e,s,c,d){return l._(this,void 0,void 0,(function*(){const p=L(e),f=c>1?"@2x":"",m={},g={};for(const{id:e,url:c}of p){const p=s.transformRequest(F(c,f,".json"),"SpriteJSON");m[e]=l.j(p,d);const _=s.transformRequest(F(c,f,".png"),"SpriteImage");g[e]=z.getImage(_,d)}return yield Promise.all([...Object.values(m),...Object.values(g)]),function(e,s){return l._(this,void 0,void 0,(function*(){const l={};for(const c in e){l[c]={};const d=_.getImageCanvasContext((yield s[c]).data),p=(yield e[c]).data;for(const e in p){const{width:s,height:f,x:m,y:_,sdf:g,pixelRatio:y,stretchX:b,stretchY:T,content:P,textFitWidth:S,textFitHeight:I}=p[e];l[c][e]={data:null,pixelRatio:y,sdf:g,stretchX:b,stretchY:T,content:P,textFitWidth:S,textFitHeight:I,spriteData:{width:s,height:f,x:m,y:_,context:d}}}}return l}))}(m,g)}))}(e,this.map._requestManager,this.map.getPixelRatio(),this._spriteRequest).then((e=>{if(this._spriteRequest=null,e)for(const l in e){this._spritesImagesIds[l]=[];const c=this._spritesImagesIds[l]?this._spritesImagesIds[l].filter((s=>!(s in e))):[];for(const e of c)this.imageManager.removeImage(e),this._changedImages[e]=!0;for(const c in e[l]){const d="default"===l?c:`${l}:${c}`;this._spritesImagesIds[l].push(d),d in this.imageManager.images?this.imageManager.updateImage(d,e[l][c],!1):this.imageManager.addImage(d,e[l][c]),s&&(this._changedImages[d]=!0)}}})).catch((e=>{this._spriteRequest=null,p=e,d.signal.aborted||this.fire(new l.k(p))})).finally((()=>{this.imageManager.setLoaded(!0),this._availableImages=this.imageManager.listImages(),s&&(this._changed=!0),this.dispatcher.broadcast("SI",this._availableImages),this.fire(new l.l("data",{dataType:"style"})),c&&c(p)}))}_unloadSprite(){for(const e of Object.values(this._spritesImagesIds).flat())this.imageManager.removeImage(e),this._changedImages[e]=!0;this._spritesImagesIds={},this._availableImages=this.imageManager.listImages(),this._changed=!0,this.dispatcher.broadcast("SI",this._availableImages),this.fire(new l.l("data",{dataType:"style"}))}_validateLayer(e){const s=this.tileManagers[e.source];if(!s)return;const c=e.sourceLayer;if(!c)return;const d=s.getSource();("geojson"===d.type||d.vectorLayerIds&&-1===d.vectorLayerIds.indexOf(c))&&this.fire(new l.k(new Error(`Source layer "${c}" does not exist on source "${d.id}" as specified by style layer "${e.id}".`)))}loaded(){if(!this._loaded)return!1;if(Object.keys(this._updatedSources).length)return!1;for(const e in this.tileManagers)if(!this.tileManagers[e].loaded())return!1;return!!this.imageManager.isLoaded()}_serializeByIds(e,s=!1){const c=this._serializedAllLayers();if(!e||0===e.length)return Object.values(s?l.bV(c):c);const d=[];for(const p of e)if(c[p]){const e=s?l.bV(c[p]):c[p];d.push(e)}return d}_serializedAllLayers(){let e=this._serializedLayers;if(e)return e;e=this._serializedLayers={};const s=Object.keys(this._layers);for(const l of s){const s=this._layers[l];"custom"!==s.type&&(e[l]=s.serialize())}return e}hasTransitions(){var e,s,l;if(null===(e=this.light)||void 0===e?void 0:e.hasTransition())return!0;if(null===(s=this.sky)||void 0===s?void 0:s.hasTransition())return!0;if(null===(l=this.projection)||void 0===l?void 0:l.hasTransition())return!0;for(const e in this.tileManagers)if(this.tileManagers[e].hasTransition())return!0;for(const e in this._layers)if(this._layers[e].hasTransition())return!0;return!1}_checkLoaded(){if(!this._loaded)throw new Error("Style is not done loading.")}update(e){if(!this._loaded)return;const s=this._changed;if(s){const s=Object.keys(this._updatedLayers),l=Object.keys(this._removedLayers);(s.length||l.length)&&this._updateWorkerLayers(s,l);for(const e in this._updatedSources){const s=this._updatedSources[e];if("reload"===s)this._reloadSource(e);else{if("clear"!==s)throw new Error(`Invalid action ${s}`);this._clearSource(e)}}this._updateTilesForChangedImages(),this._updateTilesForChangedGlyphs();for(const s in this._updatedPaintProps)this._layers[s].updateTransitions(e);this.light.updateTransitions(e),this.sky.updateTransitions(e),this._resetUpdates()}const c={};for(const e in this.tileManagers){const s=this.tileManagers[e];c[e]=s.used,s.used=!1}for(const s of this._order){const l=this._layers[s];l.recalculate(e,this._availableImages),!l.isHidden(e.zoom)&&l.source&&(this.tileManagers[l.source].used=!0)}for(const e in c){const s=this.tileManagers[e];!!c[e]!=!!s.used&&s.fire(new l.l("data",{sourceDataType:"visibility",dataType:"source",sourceId:e}))}this.light.recalculate(e),this.sky.recalculate(e),this.projection.recalculate(e),this.z=e.zoom,s&&this.fire(new l.l("data",{dataType:"style"}))}_updateTilesForChangedImages(){const e=Object.keys(this._changedImages);if(e.length){for(const s in this.tileManagers)this.tileManagers[s].reloadTilesForDependencies(["icons","patterns"],e);this._changedImages={}}}_updateTilesForChangedGlyphs(){if(this._glyphsDidChange){for(const e in this.tileManagers)this.tileManagers[e].reloadTilesForDependencies(["glyphs"],[""]);this._glyphsDidChange=!1}}_updateWorkerLayers(e,s){this.dispatcher.broadcast("UL",{layers:this._serializeByIds(e,!1),removedIds:s})}_resetUpdates(){this._changed=!1,this._updatedLayers={},this._removedLayers={},this._updatedSources={},this._updatedPaintProps={},this._changedImages={},this._glyphsDidChange=!1}setState(e,s={}){var c;this._checkLoaded();const d=this.serialize();if(e=s.transformStyle?s.transformStyle(d,e):e,(null===(c=s.validate)||void 0===c||c)&&Dr(this,l.C(e)))return!1;(e=l.bV(e)).layers=l.bS(e.layers);const p=l.bW(d,e),f=this._getOperationsToPerform(p);if(f.unimplemented.length>0)throw new Error(`Unimplemented: ${f.unimplemented.join(", ")}.`);if(0===f.operations.length)return!1;for(const e of f.operations)e();return this.stylesheet=e,this._serializedLayers=null,!0}_getOperationsToPerform(e){const s=[],l=[];for(const c of e)switch(c.command){case"setCenter":case"setZoom":case"setBearing":case"setPitch":case"setRoll":continue;case"addLayer":s.push((()=>this.addLayer.apply(this,c.args)));break;case"removeLayer":s.push((()=>this.removeLayer.apply(this,c.args)));break;case"setPaintProperty":s.push((()=>this.setPaintProperty.apply(this,c.args)));break;case"setLayoutProperty":s.push((()=>this.setLayoutProperty.apply(this,c.args)));break;case"setFilter":s.push((()=>this.setFilter.apply(this,c.args)));break;case"addSource":s.push((()=>this.addSource.apply(this,c.args)));break;case"removeSource":s.push((()=>this.removeSource.apply(this,c.args)));break;case"setLayerZoomRange":s.push((()=>this.setLayerZoomRange.apply(this,c.args)));break;case"setLight":s.push((()=>this.setLight.apply(this,c.args)));break;case"setGeoJSONSourceData":s.push((()=>this.setGeoJSONSourceData.apply(this,c.args)));break;case"setGlyphs":s.push((()=>this.setGlyphs.apply(this,c.args)));break;case"setSprite":s.push((()=>this.setSprite.apply(this,c.args)));break;case"setTerrain":s.push((()=>this.map.setTerrain.apply(this,c.args)));break;case"setSky":s.push((()=>this.setSky.apply(this,c.args)));break;case"setProjection":this.setProjection.apply(this,c.args);break;case"setGlobalState":s.push((()=>this.setGlobalState.apply(this,c.args)));break;case"setTransition":s.push((()=>{}));break;default:l.push(c.command)}return{operations:s,unimplemented:l}}addImage(e,s){if(this.getImage(e))return this.fire(new l.k(new Error(`An image named "${e}" already exists.`)));this.imageManager.addImage(e,s),this._afterImageUpdated(e)}updateImage(e,s){this.imageManager.updateImage(e,s)}getImage(e){return this.imageManager.getImage(e)}removeImage(e){if(!this.getImage(e))return this.fire(new l.k(new Error(`An image named "${e}" does not exist.`)));this.imageManager.removeImage(e),this._afterImageUpdated(e)}_afterImageUpdated(e){this._availableImages=this.imageManager.listImages(),this._changedImages[e]=!0,this._changed=!0,this.dispatcher.broadcast("SI",this._availableImages),this.fire(new l.l("data",{dataType:"style"}))}listImages(){return this._checkLoaded(),this.imageManager.listImages()}addSource(e,s,c={}){if(this._checkLoaded(),void 0!==this.tileManagers[e])throw new Error(`Source "${e}" already exists.`);if(!s.type)throw new Error(`The type property must be defined, but only the following properties were given: ${Object.keys(s).join(", ")}.`);if(["vector","raster","geojson","video","image"].indexOf(s.type)>=0&&this._validate(l.C.source,`sources.${e}`,s,null,c))return;this.map&&this.map._collectResourceTiming&&(s.collectResourceTiming=!0);const d=this.tileManagers[e]=new ke(e,s,this.dispatcher);d.style=this,d.setEventedParent(this,(()=>({isSourceLoaded:d.loaded(),source:d.serialize(),sourceId:e}))),d.onAdd(this.map),this._changed=!0}removeSource(e){if(this._checkLoaded(),void 0===this.tileManagers[e])throw new Error("There is no source with this ID");for(const s in this._layers)if(this._layers[s].source===e)return this.fire(new l.k(new Error(`Source "${e}" cannot be removed while layer "${s}" is using it.`)));const s=this.tileManagers[e];delete this.tileManagers[e],delete this._updatedSources[e],s.fire(new l.l("data",{sourceDataType:"metadata",dataType:"source",sourceId:e})),s.setEventedParent(null),s.onRemove(this.map),this._changed=!0}setGeoJSONSourceData(e,s){if(this._checkLoaded(),void 0===this.tileManagers[e])throw new Error(`There is no source with this ID=${e}`);const l=this.tileManagers[e].getSource();if("geojson"!==l.type)throw new Error(`geojsonSource.type is ${l.type}, which is !== 'geojson`);l.setData(s),this._changed=!0}getSource(e){return this.tileManagers[e]&&this.tileManagers[e].getSource()}addLayer(e,s,c={}){this._checkLoaded();const d=e.id;if(this.getLayer(d))return void this.fire(new l.k(new Error(`Layer "${d}" already exists on this map.`)));let p;if("custom"===e.type){if(Dr(this,l.bX(e)))return;p=l.bT(e,this._globalState)}else{if("source"in e&&"object"==typeof e.source&&(this.addSource(d,e.source),e=l.bV(e),e=l.e(e,{source:d})),this._validate(l.C.layer,`layers.${d}`,e,{arrayIndex:-1},c))return;p=l.bT(e,this._globalState),this._validateLayer(p),p.setEventedParent(this,{layer:{id:d}})}const f=s?this._order.indexOf(s):this._order.length;if(s&&-1===f)this.fire(new l.k(new Error(`Cannot add layer "${d}" before non-existing layer "${s}".`)));else{if(this._order.splice(f,0,d),this._layerOrderChanged=!0,this._layers[d]=p,this._removedLayers[d]&&p.source&&"custom"!==p.type){const e=this._removedLayers[d];delete this._removedLayers[d],e.type!==p.type?this._updatedSources[p.source]="clear":(this._updatedSources[p.source]="reload",this.tileManagers[p.source].pause())}this._updateLayer(p),p.onAdd&&p.onAdd(this.map)}}moveLayer(e,s){if(this._checkLoaded(),this._changed=!0,!this._layers[e])return void this.fire(new l.k(new Error(`The layer '${e}' does not exist in the map's style and cannot be moved.`)));if(e===s)return;const c=this._order.indexOf(e);this._order.splice(c,1);const d=s?this._order.indexOf(s):this._order.length;s&&-1===d?this.fire(new l.k(new Error(`Cannot move layer "${e}" before non-existing layer "${s}".`))):(this._order.splice(d,0,e),this._layerOrderChanged=!0)}removeLayer(e){this._checkLoaded();const s=this._layers[e];if(!s)return void this.fire(new l.k(new Error(`Cannot remove non-existing layer "${e}".`)));s.setEventedParent(null);const c=this._order.indexOf(e);this._order.splice(c,1),this._layerOrderChanged=!0,this._changed=!0,this._removedLayers[e]=s,delete this._layers[e],this._serializedLayers&&delete this._serializedLayers[e],delete this._updatedLayers[e],delete this._updatedPaintProps[e],s.onRemove&&s.onRemove(this.map)}getLayer(e){return this._layers[e]}getLayersOrder(){return[...this._order]}hasLayer(e){return e in this._layers}setLayerZoomRange(e,s,c){this._checkLoaded();const d=this.getLayer(e);d?d.minzoom===s&&d.maxzoom===c||(null!=s&&(d.minzoom=s),null!=c&&(d.maxzoom=c),this._updateLayer(d)):this.fire(new l.k(new Error(`Cannot set the zoom range of non-existing layer "${e}".`)))}setFilter(e,s,c={}){this._checkLoaded();const d=this.getLayer(e);if(d){if(!l.bR(d.filter,s))return null==s?(d.setFilter(void 0),void this._updateLayer(d)):void(this._validate(l.C.filter,`layers.${d.id}.filter`,s,null,c)||(d.setFilter(l.bV(s)),this._updateLayer(d)))}else this.fire(new l.k(new Error(`Cannot filter non-existing layer "${e}".`)))}getFilter(e){return l.bV(this.getLayer(e).filter)}setLayoutProperty(e,s,c,d={}){this._checkLoaded();const p=this.getLayer(e);p?l.bR(p.getLayoutProperty(s),c)||(p.setLayoutProperty(s,c,d),this._updateLayer(p)):this.fire(new l.k(new Error(`Cannot style non-existing layer "${e}".`)))}getLayoutProperty(e,s){const c=this.getLayer(e);if(c)return c.getLayoutProperty(s);this.fire(new l.k(new Error(`Cannot get style of non-existing layer "${e}".`)))}setPaintProperty(e,s,c,d={}){this._checkLoaded();const p=this.getLayer(e);p?l.bR(p.getPaintProperty(s),c)||this._updatePaintProperty(p,s,c,d):this.fire(new l.k(new Error(`Cannot style non-existing layer "${e}".`)))}_updatePaintProperty(e,s,c,d={}){e.setPaintProperty(s,c,d)&&this._updateLayer(e),l.bU(e)&&"raster-fade-duration"===s&&this.tileManagers[e.source].setRasterFadeDuration(c),this._changed=!0,this._updatedPaintProps[e.id]=!0,this._serializedLayers=null}getPaintProperty(e,s){return this.getLayer(e).getPaintProperty(s)}setFeatureState(e,s){this._checkLoaded();const c=e.source,d=e.sourceLayer,p=this.tileManagers[c];if(void 0===p)return void this.fire(new l.k(new Error(`The source '${c}' does not exist in the map's style.`)));const f=p.getSource().type;"geojson"===f&&d?this.fire(new l.k(new Error("GeoJSON sources cannot have a sourceLayer parameter."))):"vector"!==f||d?(void 0===e.id&&this.fire(new l.k(new Error("The feature id parameter must be provided."))),p.setFeatureState(d,e.id,s)):this.fire(new l.k(new Error("The sourceLayer parameter must be provided for vector source types.")))}removeFeatureState(e,s){this._checkLoaded();const c=e.source,d=this.tileManagers[c];if(void 0===d)return void this.fire(new l.k(new Error(`The source '${c}' does not exist in the map's style.`)));const p=d.getSource().type,f="vector"===p?e.sourceLayer:void 0;"vector"!==p||f?s&&"string"!=typeof e.id&&"number"!=typeof e.id?this.fire(new l.k(new Error("A feature id is required to remove its specific state property."))):d.removeFeatureState(f,e.id,s):this.fire(new l.k(new Error("The sourceLayer parameter must be provided for vector source types.")))}getFeatureState(e){this._checkLoaded();const s=e.source,c=e.sourceLayer,d=this.tileManagers[s];if(void 0!==d)return"vector"!==d.getSource().type||c?(void 0===e.id&&this.fire(new l.k(new Error("The feature id parameter must be provided."))),d.getFeatureState(c,e.id)):void this.fire(new l.k(new Error("The sourceLayer parameter must be provided for vector source types.")));this.fire(new l.k(new Error(`The source '${s}' does not exist in the map's style.`)))}getTransition(){return l.e({duration:300,delay:0},this.stylesheet&&this.stylesheet.transition)}serialize(){if(!this._loaded)return;const e=l.bY(this.tileManagers,(e=>e.serialize())),s=this._serializeByIds(this._order,!0),c=this.map.getTerrain()||void 0,d=this.stylesheet;return l.bZ({version:d.version,name:d.name,metadata:d.metadata,light:d.light,sky:d.sky,center:d.center,zoom:d.zoom,bearing:d.bearing,pitch:d.pitch,sprite:d.sprite,glyphs:d.glyphs,transition:d.transition,projection:d.projection,sources:e,layers:s,terrain:c},(e=>void 0!==e))}_updateLayer(e){this._updatedLayers[e.id]=!0,e.source&&!this._updatedSources[e.source]&&"raster"!==this.tileManagers[e.source].getSource().type&&(this._updatedSources[e.source]="reload",this.tileManagers[e.source].pause()),this._serializedLayers=null,this._changed=!0}_flattenAndSortRenderedFeatures(e){const s=e=>"fill-extrusion"===this._layers[e].type,l={},c=[];for(let d=this._order.length-1;d>=0;d--){const p=this._order[d];if(s(p)){l[p]=d;for(const s of e){const e=s[p];if(e)for(const s of e)c.push(s)}}}c.sort(((e,s)=>s.intersectionZ-e.intersectionZ));const d=[];for(let p=this._order.length-1;p>=0;p--){const f=this._order[p];if(s(f))for(let e=c.length-1;e>=0;e--){const s=c[e].feature;if(l[s.layer.id]this.map.terrain.getElevation(e,s,l):void 0));return this.placement&&p.push(function(e,s,l,c,d,p,f){const m={},_=p.queryRenderedSymbols(c),g=[];for(const e of Object.keys(_).map(Number))g.push(f[e]);g.sort(ue);for(const l of g){const c=l.featureIndex.lookupSymbolFeatures(_[l.bucketInstanceId],s,l.bucketIndex,l.sourceLayerIndex,{filterSpec:d.filter,globalState:d.globalState},d.layers,d.availableImages,e);for(const e in c){const s=m[e]=m[e]||[],d=c[e];d.sort(((e,s)=>{const c=l.featureSortOrder;if(c){const l=c.indexOf(e.featureIndex);return c.indexOf(s.featureIndex)-l}return s.featureIndex-e.featureIndex}));for(const e of d)s.push(e)}}return function(e,s,l){for(const c in e)for(const d of e[c])pe(d,l[s[c].source]);return e}(m,e,l)}(this._layers,f,this.tileManagers,e,_,this.placement.collisionIndex,this.placement.retainedQueryData)),this._flattenAndSortRenderedFeatures(p)}querySourceFeatures(e,s){(null==s?void 0:s.filter)&&this._validate(l.C.filter,"querySourceFeatures.filter",s.filter,null,s);const c=this.tileManagers[e];return c?function(e,s){const l=e.getRenderableIds().map((s=>e.getTileByID(s))),c=[],d={};for(let e=0;ee.getTileByID(s))).sort(((e,s)=>s.tileID.overscaledZ-e.tileID.overscaledZ||(e.tileID.isLessThan(s.tileID)?-1:1)))}const c=this.crossTileSymbolIndex.addLayer(l,m[l.source],e.center.lng);p=p||c}if(this.crossTileSymbolIndex.pruneUnusedLayers(this._order),((d=d||this._layerOrderChanged||0===l)||!this.pauseablePlacement||this.pauseablePlacement.isDone()&&!this.placement.stillRecent(y(),e.zoom))&&(this.pauseablePlacement=new It(e,this.map.terrain,this._order,d,s,l,c,this.placement),this._layerOrderChanged=!1),this.pauseablePlacement.isDone()?this.placement.setStale():(this.pauseablePlacement.continuePlacement(this._order,this._layers,m),this.pauseablePlacement.isDone()&&(this.placement=this.pauseablePlacement.commit(y()),f=!0),p&&this.pauseablePlacement.placement.setStale()),f||p)for(const e of this._order){const s=this._layers[e];"symbol"===s.type&&this.placement.updateLayerOpacities(s,m[s.source])}return!this.pauseablePlacement.isDone()||this.placement.hasTransitions(y())}_releaseSymbolFadeTiles(){for(const e in this.tileManagers)this.tileManagers[e].releaseSymbolFadeTiles()}getImages(e,s){return l._(this,void 0,void 0,(function*(){const e=yield this.imageManager.getImages(s.icons);this._updateTilesForChangedImages();const l=this.tileManagers[s.source];return l&&l.setDependencies(s.tileID.key,s.type,s.icons),e}))}getGlyphs(e,s){return l._(this,void 0,void 0,(function*(){const e=yield this.glyphManager.getGlyphs(s.stacks),l=this.tileManagers[s.source];return l&&l.setDependencies(s.tileID.key,s.type,[""]),e}))}getGlyphsUrl(){return this.stylesheet.glyphs||null}setGlyphs(e,s={}){this._checkLoaded(),e&&this._validate(l.C.glyphs,"glyphs",e,null,s)||(this._glyphsDidChange=!0,this.stylesheet.glyphs=e,this.glyphManager.entries={},this.glyphManager.setURL(e))}getDashes(e,s){return l._(this,void 0,void 0,(function*(){const e={};for(const[l,c]of Object.entries(s.dashes))e[l]=this.lineAtlas.getDash(c.dasharray,c.round);return e}))}addSprite(e,s,c={},d){this._checkLoaded();const p=[{id:e,url:s}],f=[...L(this.stylesheet.sprite),...p];this._validate(l.C.sprite,"sprite",f,null,c)||(this.stylesheet.sprite=f,this._loadSprite(p,!0,d))}removeSprite(e){this._checkLoaded();const s=L(this.stylesheet.sprite);if(s.find((s=>s.id===e))){if(this._spritesImagesIds[e])for(const s of this._spritesImagesIds[e])this.imageManager.removeImage(s),this._changedImages[s]=!0;s.splice(s.findIndex((s=>s.id===e)),1),this.stylesheet.sprite=s.length>0?s:void 0,delete this._spritesImagesIds[e],this._availableImages=this.imageManager.listImages(),this._changed=!0,this.dispatcher.broadcast("SI",this._availableImages),this.fire(new l.l("data",{dataType:"style"}))}else this.fire(new l.k(new Error(`Sprite "${e}" doesn't exists on this map.`)))}getSprite(){return L(this.stylesheet.sprite)}setSprite(e,s={},c){this._checkLoaded(),e&&this._validate(l.C.sprite,"sprite",e,null,s)||(this.stylesheet.sprite=e,e?this._loadSprite(e,!0,c):(this._unloadSprite(),c&&c(null)))}destroy(){this._frameRequest&&(this._frameRequest.abort(),this._frameRequest=null),this._loadStyleRequest&&(this._loadStyleRequest.abort(),this._loadStyleRequest=null),this._spriteRequest&&(this._spriteRequest.abort(),this._spriteRequest=null);for(const e in this.tileManagers){const s=this.tileManagers[e];s.setEventedParent(null),s.onRemove(this.map)}this.tileManagers={},this.imageManager&&(this.imageManager.setEventedParent(null),this.imageManager.destroy(),this._availableImages=[],this._spritesImagesIds={}),this.glyphManager&&this.glyphManager.destroy();for(const e in this._layers){const s=this._layers[e];s.setEventedParent(null),s.onRemove&&s.onRemove(this.map)}this._setInitialValues(),this.setEventedParent(null),this.dispatcher.unregisterMessageHandler("GG"),this.dispatcher.unregisterMessageHandler("GI"),this.dispatcher.unregisterMessageHandler("GDA"),this.dispatcher.remove(!0),this._listeners={},this._oneTimeListeners={}}}var kr=l.aU([{name:"a_pos",type:"Int16",components:2},{name:"a_texture_pos",type:"Int16",components:2}]);class Bi{constructor(){this.boundProgram=null,this.boundLayoutVertexBuffer=null,this.boundPaintVertexBuffers=[],this.boundIndexBuffer=null,this.boundVertexOffset=null,this.boundDynamicVertexBuffer=null,this.vao=null}bind(e,s,l,c,d,p,f,m,_){this.context=e;let g=this.boundPaintVertexBuffers.length!==c.length;for(let e=0;!g&&e({u_texture:0,u_ele_delta:e,u_fog_matrix:s,u_fog_color:c?c.properties.get("fog-color"):l.bp.white,u_fog_ground_blend:c?c.properties.get("fog-ground-blend"):1,u_fog_ground_blend_opacity:p?0:c?c.calculateFogBlendOpacity(d):0,u_horizon_color:c?c.properties.get("horizon-color"):l.bp.white,u_horizon_fog_blend:c?c.properties.get("horizon-fog-blend"):1,u_is_globe_mode:p?1:0}),Lr={mainMatrix:"u_projection_matrix",tileMercatorCoords:"u_projection_tile_mercator_coords",clippingPlane:"u_projection_clipping_plane",projectionTransition:"u_projection_transition",fallbackMatrix:"u_projection_fallback_matrix"};function Br(e){const s=[];for(let l=0;l({u_depth:new l.b_(e,s.u_depth),u_terrain:new l.b_(e,s.u_terrain),u_terrain_dim:new l.bq(e,s.u_terrain_dim),u_terrain_matrix:new l.c0(e,s.u_terrain_matrix),u_terrain_unpack:new l.c1(e,s.u_terrain_unpack),u_terrain_exaggeration:new l.bq(e,s.u_terrain_exaggeration)}))(e,q),this.projectionUniforms=((e,s)=>({u_projection_matrix:new l.c0(e,s.u_projection_matrix),u_projection_tile_mercator_coords:new l.c1(e,s.u_projection_tile_mercator_coords),u_projection_clipping_plane:new l.c1(e,s.u_projection_clipping_plane),u_projection_transition:new l.bq(e,s.u_projection_transition),u_projection_fallback_matrix:new l.c0(e,s.u_projection_fallback_matrix)}))(e,q),this.binderUniforms=c?c.getUniforms(e,q):[]}draw(e,s,l,c,d,p,f,m,_,g,y,b,T,P,S,I,C,z,L){const F=e.gl;if(this.failedToCreate)return;if(e.program.set(this.program),e.setDepthMode(l),e.setStencilMode(c),e.setColorMode(d),e.setCullFace(p),m){e.activeTexture.set(F.TEXTURE2),F.bindTexture(F.TEXTURE_2D,m.depthTexture),e.activeTexture.set(F.TEXTURE3),F.bindTexture(F.TEXTURE_2D,m.texture);for(const e in this.terrainUniforms)this.terrainUniforms[e].set(m[e])}if(_)for(const e in _)this.projectionUniforms[Lr[e]].set(_[e]);if(f)for(const e in this.fixedUniforms)this.fixedUniforms[e].set(f[e]);I&&I.setUniforms(e,this.binderUniforms,P,{zoom:S});let B=0;switch(s){case F.LINES:B=2;break;case F.TRIANGLES:B=3;break;case F.LINE_STRIP:B=1}for(const l of T.get()){const c=l.vaos||(l.vaos={});(c[g]||(c[g]=new Bi)).bind(e,this,y,I?I.getPaintVertexBuffers():[],b,l.vertexOffset,C,z,L),F.drawElements(s,l.primitiveLength*B,F.UNSIGNED_SHORT,l.primitiveOffset*B*2)}}}function Or(e,s,c){const d=1/l.aN(c,1,s.transform.tileZoom),p=Math.pow(2,c.tileID.overscaledZ),f=c.tileSize*Math.pow(2,s.transform.tileZoom)/p,m=f*(c.tileID.canonical.x+c.tileID.wrap*p),_=f*c.tileID.canonical.y;return{u_image:0,u_texsize:c.imageAtlasTexture.size,u_scale:[d,e.fromScale,e.toScale],u_fade:e.t,u_pixel_coord_upper:[m>>16,_>>16],u_pixel_coord_lower:[65535&m,65535&_]}}const Vr=(e,s,c,d)=>{const p=e.style.light,f=p.properties.get("position"),m=[f.x,f.y,f.z],_=l.c4();"viewport"===p.properties.get("anchor")&&l.c5(_,e.transform.bearingInRadians),l.c6(m,m,_);const g=e.transform.transformLightDirection(m),y=p.properties.get("color");return{u_lightpos:m,u_lightpos_globe:g,u_lightintensity:p.properties.get("intensity"),u_lightcolor:[y.r,y.g,y.b],u_vertical_gradient:+s,u_opacity:c,u_fill_translate:d}},jr=(e,s,c,d,p,f,m)=>l.e(Vr(e,s,c,d),Or(f,e,m),{u_height_factor:-Math.pow(2,p.overscaledZ)/m.tileSize/8}),Nr=(e,s,c,d)=>l.e(Or(s,e,c),{u_fill_translate:d}),Gr=(e,s)=>({u_world:e,u_fill_translate:s}),Ur=(e,s,c,d,p)=>l.e(Nr(e,s,c,p),{u_world:d}),Zr=(e,s,c,d,p)=>{const f=e.transform;let m,_,g=0;if("map"===c.paint.get("circle-pitch-alignment")){const e=l.aN(s,1,f.zoom);m=!0,_=[e,e],g=e/(l.a5*Math.pow(2,s.tileID.overscaledZ))*2*Math.PI*p}else m=!1,_=f.pixelsToGLUnits;return{u_camera_to_center_distance:f.cameraToCenterDistance,u_scale_with_map:+("map"===c.paint.get("circle-pitch-scale")),u_pitch_with_map:+m,u_device_pixel_ratio:e.pixelRatio,u_extrude_scale:_,u_globe_extrude_scale:g,u_translate:d}},Wr=e=>({u_pixel_extrude_scale:[1/e.width,1/e.height]}),Xr=e=>({u_viewport_size:[e.width,e.height]}),Yr=(e,s=1)=>({u_color:e,u_overlay:0,u_overlay_scale:s}),Kr=(e,s,c,d)=>{const p=l.aN(e,1,s)/(l.a5*Math.pow(2,e.tileID.overscaledZ))*2*Math.PI*d;return{u_extrude_scale:l.aN(e,1,s),u_intensity:c,u_globe_extrude_scale:p}},Qr=(e,s,c,d)=>{const p=l.N();l.c7(p,0,e.width,e.height,0,0,1);const f=e.context.gl;return{u_matrix:p,u_world:[f.drawingBufferWidth,f.drawingBufferHeight],u_image:c,u_color_ramp:d,u_opacity:s.paint.get("heatmap-opacity")}},Jr=(e,s,l)=>{const c=l.paint.get("hillshade-accent-color");let d;switch(l.paint.get("hillshade-method")){case"basic":d=4;break;case"combined":d=1;break;case"igor":d=2;break;case"multidirectional":d=3;break;default:d=0}const p=l.getIlluminationProperties();for(let s=0;s{const c=s.stride,d=l.N();return l.c7(d,0,l.a5,-l.a5,0,0,1),l.O(d,d,[0,-l.a5,0]),{u_matrix:d,u_image:1,u_dimension:[c,c],u_zoom:e.overscaledZ,u_unpack:s.getUnpackVector()}};function tn(e,s){const c=Math.pow(2,s.canonical.z),d=s.canonical.y;return[new l.a9(0,d/c).toLngLat().lat,new l.a9(0,(d+1)/c).toLngLat().lat]}const rn=(e,s,l=0)=>({u_image:0,u_unpack:s.getUnpackVector(),u_dimension:[s.stride,s.stride],u_elevation_stops:1,u_color_stops:4,u_color_ramp_size:l,u_opacity:e.paint.get("color-relief-opacity")}),nn=(e,s,c,d)=>{const p=e.transform;return{u_translation:un(e,s,c),u_ratio:d/l.aN(s,1,p.zoom),u_device_pixel_ratio:e.pixelRatio,u_units_to_pixels:[1/p.pixelsToGLUnits[0],1/p.pixelsToGLUnits[1]]}},sn=(e,s,c,d,p)=>l.e(nn(e,s,c,d),{u_image:0,u_image_height:p}),an=(e,s,c,d,p)=>{const f=e.transform,m=hn(s,f);return{u_translation:un(e,s,c),u_texsize:s.imageAtlasTexture.size,u_ratio:d/l.aN(s,1,f.zoom),u_device_pixel_ratio:e.pixelRatio,u_image:0,u_scale:[m,p.fromScale,p.toScale],u_fade:p.t,u_units_to_pixels:[1/f.pixelsToGLUnits[0],1/f.pixelsToGLUnits[1]]}},ln=(e,s,c,d,p)=>{const f=hn(s,e.transform);return l.e(nn(e,s,c,d),{u_tileratio:f,u_crossfade_from:p.fromScale,u_crossfade_to:p.toScale,u_image:0,u_mix:p.t,u_lineatlas_width:e.lineAtlas.width,u_lineatlas_height:e.lineAtlas.height})},cn=(e,s,c,d,p,f)=>{const m=hn(s,e.transform);return l.e(nn(e,s,c,d),{u_image:0,u_image_height:f,u_tileratio:m,u_crossfade_from:p.fromScale,u_crossfade_to:p.toScale,u_image_dash:1,u_mix:p.t,u_lineatlas_width:e.lineAtlas.width,u_lineatlas_height:e.lineAtlas.height})};function hn(e,s){return 1/l.aN(e,1,s.tileZoom)}function un(e,s,c){return l.aO(e.transform,s,c.paint.get("line-translate"),c.paint.get("line-translate-anchor"))}const dn=(e,s,l,c,d)=>{return{u_tl_parent:e,u_scale_parent:s,u_buffer_scale:1,u_fade_t:l.mix,u_opacity:l.opacity*c.paint.get("raster-opacity"),u_image0:0,u_image1:1,u_brightness_low:c.paint.get("raster-brightness-min"),u_brightness_high:c.paint.get("raster-brightness-max"),u_saturation_factor:(f=c.paint.get("raster-saturation"),f>0?1-1/(1.001-f):-f),u_contrast_factor:(p=c.paint.get("raster-contrast"),p>0?1/(1-p):1+p),u_spin_weights:pn(c.paint.get("raster-hue-rotate")),u_coords_top:[d[0].x,d[0].y,d[1].x,d[1].y],u_coords_bottom:[d[3].x,d[3].y,d[2].x,d[2].y]};var p,f};function pn(e){e*=Math.PI/180;const s=Math.sin(e),l=Math.cos(e);return[(2*l+1)/3,(-Math.sqrt(3)*s-l+1)/3,(Math.sqrt(3)*s-l+1)/3]}const fn=(e,s,l,c,d,p,f,m,_,g,y,b,T)=>{const P=f.transform;return{u_is_size_zoom_constant:+("constant"===e||"source"===e),u_is_size_feature_constant:+("constant"===e||"camera"===e),u_size_t:s?s.uSizeT:0,u_size:s?s.uSize:0,u_camera_to_center_distance:P.cameraToCenterDistance,u_pitch:P.pitch/360*2*Math.PI,u_rotate_symbol:+l,u_aspect_ratio:P.width/P.height,u_fade_change:f.options.fadeDuration?f.symbolFadeChange:1,u_label_plane_matrix:m,u_coord_matrix:_,u_is_text:+y,u_pitch_with_map:+c,u_is_along_line:d,u_is_variable_anchor:p,u_texsize:b,u_texture:0,u_translation:g,u_pitched_scale:T}},mn=(e,s,c,d,p,f,m,_,g,y,b,T,P,S)=>{const I=m.transform;return l.e(fn(e,s,c,d,p,f,m,_,g,y,b,T,S),{u_gamma_scale:d?Math.cos(I.pitch*Math.PI/180)*I.cameraToCenterDistance:1,u_device_pixel_ratio:m.pixelRatio,u_is_halo:1})},_n=(e,s,c,d,p,f,m,_,g,y,b,T,P)=>l.e(mn(e,s,c,d,p,f,m,_,g,y,!0,b,0,P),{u_texsize_icon:T,u_texture_icon:1}),gn=(e,s)=>({u_opacity:e,u_color:s}),yn=(e,s,c,d,p)=>l.e(function(e,s,c,d){const p=c.imageManager.getPattern(e.from.toString()),f=c.imageManager.getPattern(e.to.toString()),{width:m,height:_}=c.imageManager.getPixelSize(),g=Math.pow(2,d.tileID.overscaledZ),y=d.tileSize*Math.pow(2,c.transform.tileZoom)/g,b=y*(d.tileID.canonical.x+d.tileID.wrap*g),T=y*d.tileID.canonical.y;return{u_image:0,u_pattern_tl_a:p.tl,u_pattern_br_a:p.br,u_pattern_tl_b:f.tl,u_pattern_br_b:f.br,u_texsize:[m,_],u_mix:s.t,u_pattern_size_a:p.displaySize,u_pattern_size_b:f.displaySize,u_scale_a:s.fromScale,u_scale_b:s.toScale,u_tile_units_to_pixels:1/l.aN(d,1,c.transform.tileZoom),u_pixel_coord_upper:[b>>16,T>>16],u_pixel_coord_lower:[65535&b,65535&T]}}(c,p,s,d),{u_opacity:e}),xn=(e,s)=>{},vn={fillExtrusion:(e,s)=>({u_lightpos:new l.c2(e,s.u_lightpos),u_lightpos_globe:new l.c2(e,s.u_lightpos_globe),u_lightintensity:new l.bq(e,s.u_lightintensity),u_lightcolor:new l.c2(e,s.u_lightcolor),u_vertical_gradient:new l.bq(e,s.u_vertical_gradient),u_opacity:new l.bq(e,s.u_opacity),u_fill_translate:new l.c3(e,s.u_fill_translate)}),fillExtrusionPattern:(e,s)=>({u_lightpos:new l.c2(e,s.u_lightpos),u_lightpos_globe:new l.c2(e,s.u_lightpos_globe),u_lightintensity:new l.bq(e,s.u_lightintensity),u_lightcolor:new l.c2(e,s.u_lightcolor),u_vertical_gradient:new l.bq(e,s.u_vertical_gradient),u_height_factor:new l.bq(e,s.u_height_factor),u_opacity:new l.bq(e,s.u_opacity),u_fill_translate:new l.c3(e,s.u_fill_translate),u_image:new l.b_(e,s.u_image),u_texsize:new l.c3(e,s.u_texsize),u_pixel_coord_upper:new l.c3(e,s.u_pixel_coord_upper),u_pixel_coord_lower:new l.c3(e,s.u_pixel_coord_lower),u_scale:new l.c2(e,s.u_scale),u_fade:new l.bq(e,s.u_fade)}),fill:(e,s)=>({u_fill_translate:new l.c3(e,s.u_fill_translate)}),fillPattern:(e,s)=>({u_image:new l.b_(e,s.u_image),u_texsize:new l.c3(e,s.u_texsize),u_pixel_coord_upper:new l.c3(e,s.u_pixel_coord_upper),u_pixel_coord_lower:new l.c3(e,s.u_pixel_coord_lower),u_scale:new l.c2(e,s.u_scale),u_fade:new l.bq(e,s.u_fade),u_fill_translate:new l.c3(e,s.u_fill_translate)}),fillOutline:(e,s)=>({u_world:new l.c3(e,s.u_world),u_fill_translate:new l.c3(e,s.u_fill_translate)}),fillOutlinePattern:(e,s)=>({u_world:new l.c3(e,s.u_world),u_image:new l.b_(e,s.u_image),u_texsize:new l.c3(e,s.u_texsize),u_pixel_coord_upper:new l.c3(e,s.u_pixel_coord_upper),u_pixel_coord_lower:new l.c3(e,s.u_pixel_coord_lower),u_scale:new l.c2(e,s.u_scale),u_fade:new l.bq(e,s.u_fade),u_fill_translate:new l.c3(e,s.u_fill_translate)}),circle:(e,s)=>({u_camera_to_center_distance:new l.bq(e,s.u_camera_to_center_distance),u_scale_with_map:new l.b_(e,s.u_scale_with_map),u_pitch_with_map:new l.b_(e,s.u_pitch_with_map),u_extrude_scale:new l.c3(e,s.u_extrude_scale),u_device_pixel_ratio:new l.bq(e,s.u_device_pixel_ratio),u_globe_extrude_scale:new l.bq(e,s.u_globe_extrude_scale),u_translate:new l.c3(e,s.u_translate)}),collisionBox:(e,s)=>({u_pixel_extrude_scale:new l.c3(e,s.u_pixel_extrude_scale)}),collisionCircle:(e,s)=>({u_viewport_size:new l.c3(e,s.u_viewport_size)}),debug:(e,s)=>({u_color:new l.b$(e,s.u_color),u_overlay:new l.b_(e,s.u_overlay),u_overlay_scale:new l.bq(e,s.u_overlay_scale)}),depth:xn,clippingMask:xn,heatmap:(e,s)=>({u_extrude_scale:new l.bq(e,s.u_extrude_scale),u_intensity:new l.bq(e,s.u_intensity),u_globe_extrude_scale:new l.bq(e,s.u_globe_extrude_scale)}),heatmapTexture:(e,s)=>({u_matrix:new l.c0(e,s.u_matrix),u_world:new l.c3(e,s.u_world),u_image:new l.b_(e,s.u_image),u_color_ramp:new l.b_(e,s.u_color_ramp),u_opacity:new l.bq(e,s.u_opacity)}),hillshade:(e,s)=>({u_image:new l.b_(e,s.u_image),u_latrange:new l.c3(e,s.u_latrange),u_exaggeration:new l.bq(e,s.u_exaggeration),u_altitudes:new l.c9(e,s.u_altitudes),u_azimuths:new l.c9(e,s.u_azimuths),u_accent:new l.b$(e,s.u_accent),u_method:new l.b_(e,s.u_method),u_shadows:new l.c8(e,s.u_shadows),u_highlights:new l.c8(e,s.u_highlights)}),hillshadePrepare:(e,s)=>({u_matrix:new l.c0(e,s.u_matrix),u_image:new l.b_(e,s.u_image),u_dimension:new l.c3(e,s.u_dimension),u_zoom:new l.bq(e,s.u_zoom),u_unpack:new l.c1(e,s.u_unpack)}),colorRelief:(e,s)=>({u_image:new l.b_(e,s.u_image),u_unpack:new l.c1(e,s.u_unpack),u_dimension:new l.c3(e,s.u_dimension),u_elevation_stops:new l.b_(e,s.u_elevation_stops),u_color_stops:new l.b_(e,s.u_color_stops),u_color_ramp_size:new l.b_(e,s.u_color_ramp_size),u_opacity:new l.bq(e,s.u_opacity)}),line:(e,s)=>({u_translation:new l.c3(e,s.u_translation),u_ratio:new l.bq(e,s.u_ratio),u_device_pixel_ratio:new l.bq(e,s.u_device_pixel_ratio),u_units_to_pixels:new l.c3(e,s.u_units_to_pixels)}),lineGradient:(e,s)=>({u_translation:new l.c3(e,s.u_translation),u_ratio:new l.bq(e,s.u_ratio),u_device_pixel_ratio:new l.bq(e,s.u_device_pixel_ratio),u_units_to_pixels:new l.c3(e,s.u_units_to_pixels),u_image:new l.b_(e,s.u_image),u_image_height:new l.bq(e,s.u_image_height)}),linePattern:(e,s)=>({u_translation:new l.c3(e,s.u_translation),u_texsize:new l.c3(e,s.u_texsize),u_ratio:new l.bq(e,s.u_ratio),u_device_pixel_ratio:new l.bq(e,s.u_device_pixel_ratio),u_image:new l.b_(e,s.u_image),u_units_to_pixels:new l.c3(e,s.u_units_to_pixels),u_scale:new l.c2(e,s.u_scale),u_fade:new l.bq(e,s.u_fade)}),lineSDF:(e,s)=>({u_translation:new l.c3(e,s.u_translation),u_ratio:new l.bq(e,s.u_ratio),u_device_pixel_ratio:new l.bq(e,s.u_device_pixel_ratio),u_units_to_pixels:new l.c3(e,s.u_units_to_pixels),u_image:new l.b_(e,s.u_image),u_mix:new l.bq(e,s.u_mix),u_tileratio:new l.bq(e,s.u_tileratio),u_crossfade_from:new l.bq(e,s.u_crossfade_from),u_crossfade_to:new l.bq(e,s.u_crossfade_to),u_lineatlas_width:new l.bq(e,s.u_lineatlas_width),u_lineatlas_height:new l.bq(e,s.u_lineatlas_height)}),lineGradientSDF:(e,s)=>({u_translation:new l.c3(e,s.u_translation),u_ratio:new l.bq(e,s.u_ratio),u_device_pixel_ratio:new l.bq(e,s.u_device_pixel_ratio),u_units_to_pixels:new l.c3(e,s.u_units_to_pixels),u_image:new l.b_(e,s.u_image),u_image_height:new l.bq(e,s.u_image_height),u_tileratio:new l.bq(e,s.u_tileratio),u_crossfade_from:new l.bq(e,s.u_crossfade_from),u_crossfade_to:new l.bq(e,s.u_crossfade_to),u_image_dash:new l.b_(e,s.u_image_dash),u_mix:new l.bq(e,s.u_mix),u_lineatlas_width:new l.bq(e,s.u_lineatlas_width),u_lineatlas_height:new l.bq(e,s.u_lineatlas_height)}),raster:(e,s)=>({u_tl_parent:new l.c3(e,s.u_tl_parent),u_scale_parent:new l.bq(e,s.u_scale_parent),u_buffer_scale:new l.bq(e,s.u_buffer_scale),u_fade_t:new l.bq(e,s.u_fade_t),u_opacity:new l.bq(e,s.u_opacity),u_image0:new l.b_(e,s.u_image0),u_image1:new l.b_(e,s.u_image1),u_brightness_low:new l.bq(e,s.u_brightness_low),u_brightness_high:new l.bq(e,s.u_brightness_high),u_saturation_factor:new l.bq(e,s.u_saturation_factor),u_contrast_factor:new l.bq(e,s.u_contrast_factor),u_spin_weights:new l.c2(e,s.u_spin_weights),u_coords_top:new l.c1(e,s.u_coords_top),u_coords_bottom:new l.c1(e,s.u_coords_bottom)}),symbolIcon:(e,s)=>({u_is_size_zoom_constant:new l.b_(e,s.u_is_size_zoom_constant),u_is_size_feature_constant:new l.b_(e,s.u_is_size_feature_constant),u_size_t:new l.bq(e,s.u_size_t),u_size:new l.bq(e,s.u_size),u_camera_to_center_distance:new l.bq(e,s.u_camera_to_center_distance),u_pitch:new l.bq(e,s.u_pitch),u_rotate_symbol:new l.b_(e,s.u_rotate_symbol),u_aspect_ratio:new l.bq(e,s.u_aspect_ratio),u_fade_change:new l.bq(e,s.u_fade_change),u_label_plane_matrix:new l.c0(e,s.u_label_plane_matrix),u_coord_matrix:new l.c0(e,s.u_coord_matrix),u_is_text:new l.b_(e,s.u_is_text),u_pitch_with_map:new l.b_(e,s.u_pitch_with_map),u_is_along_line:new l.b_(e,s.u_is_along_line),u_is_variable_anchor:new l.b_(e,s.u_is_variable_anchor),u_texsize:new l.c3(e,s.u_texsize),u_texture:new l.b_(e,s.u_texture),u_translation:new l.c3(e,s.u_translation),u_pitched_scale:new l.bq(e,s.u_pitched_scale)}),symbolSDF:(e,s)=>({u_is_size_zoom_constant:new l.b_(e,s.u_is_size_zoom_constant),u_is_size_feature_constant:new l.b_(e,s.u_is_size_feature_constant),u_size_t:new l.bq(e,s.u_size_t),u_size:new l.bq(e,s.u_size),u_camera_to_center_distance:new l.bq(e,s.u_camera_to_center_distance),u_pitch:new l.bq(e,s.u_pitch),u_rotate_symbol:new l.b_(e,s.u_rotate_symbol),u_aspect_ratio:new l.bq(e,s.u_aspect_ratio),u_fade_change:new l.bq(e,s.u_fade_change),u_label_plane_matrix:new l.c0(e,s.u_label_plane_matrix),u_coord_matrix:new l.c0(e,s.u_coord_matrix),u_is_text:new l.b_(e,s.u_is_text),u_pitch_with_map:new l.b_(e,s.u_pitch_with_map),u_is_along_line:new l.b_(e,s.u_is_along_line),u_is_variable_anchor:new l.b_(e,s.u_is_variable_anchor),u_texsize:new l.c3(e,s.u_texsize),u_texture:new l.b_(e,s.u_texture),u_gamma_scale:new l.bq(e,s.u_gamma_scale),u_device_pixel_ratio:new l.bq(e,s.u_device_pixel_ratio),u_is_halo:new l.b_(e,s.u_is_halo),u_translation:new l.c3(e,s.u_translation),u_pitched_scale:new l.bq(e,s.u_pitched_scale)}),symbolTextAndIcon:(e,s)=>({u_is_size_zoom_constant:new l.b_(e,s.u_is_size_zoom_constant),u_is_size_feature_constant:new l.b_(e,s.u_is_size_feature_constant),u_size_t:new l.bq(e,s.u_size_t),u_size:new l.bq(e,s.u_size),u_camera_to_center_distance:new l.bq(e,s.u_camera_to_center_distance),u_pitch:new l.bq(e,s.u_pitch),u_rotate_symbol:new l.b_(e,s.u_rotate_symbol),u_aspect_ratio:new l.bq(e,s.u_aspect_ratio),u_fade_change:new l.bq(e,s.u_fade_change),u_label_plane_matrix:new l.c0(e,s.u_label_plane_matrix),u_coord_matrix:new l.c0(e,s.u_coord_matrix),u_is_text:new l.b_(e,s.u_is_text),u_pitch_with_map:new l.b_(e,s.u_pitch_with_map),u_is_along_line:new l.b_(e,s.u_is_along_line),u_is_variable_anchor:new l.b_(e,s.u_is_variable_anchor),u_texsize:new l.c3(e,s.u_texsize),u_texsize_icon:new l.c3(e,s.u_texsize_icon),u_texture:new l.b_(e,s.u_texture),u_texture_icon:new l.b_(e,s.u_texture_icon),u_gamma_scale:new l.bq(e,s.u_gamma_scale),u_device_pixel_ratio:new l.bq(e,s.u_device_pixel_ratio),u_is_halo:new l.b_(e,s.u_is_halo),u_translation:new l.c3(e,s.u_translation),u_pitched_scale:new l.bq(e,s.u_pitched_scale)}),background:(e,s)=>({u_opacity:new l.bq(e,s.u_opacity),u_color:new l.b$(e,s.u_color)}),backgroundPattern:(e,s)=>({u_opacity:new l.bq(e,s.u_opacity),u_image:new l.b_(e,s.u_image),u_pattern_tl_a:new l.c3(e,s.u_pattern_tl_a),u_pattern_br_a:new l.c3(e,s.u_pattern_br_a),u_pattern_tl_b:new l.c3(e,s.u_pattern_tl_b),u_pattern_br_b:new l.c3(e,s.u_pattern_br_b),u_texsize:new l.c3(e,s.u_texsize),u_mix:new l.bq(e,s.u_mix),u_pattern_size_a:new l.c3(e,s.u_pattern_size_a),u_pattern_size_b:new l.c3(e,s.u_pattern_size_b),u_scale_a:new l.bq(e,s.u_scale_a),u_scale_b:new l.bq(e,s.u_scale_b),u_pixel_coord_upper:new l.c3(e,s.u_pixel_coord_upper),u_pixel_coord_lower:new l.c3(e,s.u_pixel_coord_lower),u_tile_units_to_pixels:new l.bq(e,s.u_tile_units_to_pixels)}),terrain:(e,s)=>({u_texture:new l.b_(e,s.u_texture),u_ele_delta:new l.bq(e,s.u_ele_delta),u_fog_matrix:new l.c0(e,s.u_fog_matrix),u_fog_color:new l.b$(e,s.u_fog_color),u_fog_ground_blend:new l.bq(e,s.u_fog_ground_blend),u_fog_ground_blend_opacity:new l.bq(e,s.u_fog_ground_blend_opacity),u_horizon_color:new l.b$(e,s.u_horizon_color),u_horizon_fog_blend:new l.bq(e,s.u_horizon_fog_blend),u_is_globe_mode:new l.bq(e,s.u_is_globe_mode)}),terrainDepth:(e,s)=>({u_ele_delta:new l.bq(e,s.u_ele_delta)}),terrainCoords:(e,s)=>({u_texture:new l.b_(e,s.u_texture),u_terrain_coords_id:new l.bq(e,s.u_terrain_coords_id),u_ele_delta:new l.bq(e,s.u_ele_delta)}),projectionErrorMeasurement:(e,s)=>({u_input:new l.bq(e,s.u_input),u_output_expected:new l.bq(e,s.u_output_expected)}),atmosphere:(e,s)=>({u_sun_pos:new l.c2(e,s.u_sun_pos),u_atmosphere_blend:new l.bq(e,s.u_atmosphere_blend),u_globe_position:new l.c2(e,s.u_globe_position),u_globe_radius:new l.bq(e,s.u_globe_radius),u_inv_proj_matrix:new l.c0(e,s.u_inv_proj_matrix)}),sky:(e,s)=>({u_sky_color:new l.b$(e,s.u_sky_color),u_horizon_color:new l.b$(e,s.u_horizon_color),u_horizon:new l.c3(e,s.u_horizon),u_horizon_normal:new l.c3(e,s.u_horizon_normal),u_sky_horizon_blend:new l.bq(e,s.u_sky_horizon_blend),u_sky_blend:new l.bq(e,s.u_sky_blend)})};class ba{constructor(e,s,l){this.context=e;const c=e.gl;this.buffer=c.createBuffer(),this.dynamicDraw=Boolean(l),this.context.unbindVAO(),e.bindElementBuffer.set(this.buffer),c.bufferData(c.ELEMENT_ARRAY_BUFFER,s.arrayBuffer,this.dynamicDraw?c.DYNAMIC_DRAW:c.STATIC_DRAW),this.dynamicDraw||delete s.arrayBuffer}bind(){this.context.bindElementBuffer.set(this.buffer)}updateData(e){const s=this.context.gl;if(!this.dynamicDraw)throw new Error("Attempted to update data while not in dynamic mode.");this.context.unbindVAO(),this.bind(),s.bufferSubData(s.ELEMENT_ARRAY_BUFFER,0,e.arrayBuffer)}destroy(){this.buffer&&(this.context.gl.deleteBuffer(this.buffer),delete this.buffer)}}const bn={Int8:"BYTE",Uint8:"UNSIGNED_BYTE",Int16:"SHORT",Uint16:"UNSIGNED_SHORT",Int32:"INT",Uint32:"UNSIGNED_INT",Float32:"FLOAT"};class wa{constructor(e,s,l,c){this.length=s.length,this.attributes=l,this.itemSize=s.bytesPerElement,this.dynamicDraw=c,this.context=e;const d=e.gl;this.buffer=d.createBuffer(),e.bindVertexBuffer.set(this.buffer),d.bufferData(d.ARRAY_BUFFER,s.arrayBuffer,this.dynamicDraw?d.DYNAMIC_DRAW:d.STATIC_DRAW),this.dynamicDraw||delete s.arrayBuffer}bind(){this.context.bindVertexBuffer.set(this.buffer)}updateData(e){if(e.length!==this.length)throw new Error(`Length of new data is ${e.length}, which doesn't match current length of ${this.length}`);const s=this.context.gl;this.bind(),s.bufferSubData(s.ARRAY_BUFFER,0,e.arrayBuffer)}enableAttributes(e,s){for(let l=0;l0&&(y.push({circleArray:C,circleOffset:T,coord:P}),b+=C.length/4,T=b),I&&g.draw(f,_.LINES,ti.disabled,ai.disabled,e.colorModeForRenderPass(),ei.disabled,Wr(e.transform),e.style.map.terrain&&e.style.map.terrain.getTerrainData(P),m.getProjectionData({overscaledTileID:P,applyGlobeMatrix:!0,applyTerrainMatrix:!0}),c.id,I.layoutVertexBuffer,I.indexBuffer,I.segments,null,e.transform.zoom,null,null,I.collisionVertexBuffer)}if(!p||!y.length)return;const P=e.useProgram("collisionCircle"),S=new l.ca;S.resize(4*b),S._trim();let I=0;for(const e of y)for(let s=0;s=0&&(C[z.associatedIconIndex]={shiftedAnchor:J,angle:re})}else fi(z.numGlyphs,S)}if(g){I.clear();const s=e.icon.placedSymbolArray;for(let e=0;ee.style.map.terrain.getElevation(_,s,l):null,l="map"===c.layout.get("text-rotation-alignment");Ot(g,e,p,me,ge,L,y,l,_.toUnwrapped(),C.width,C.height,xe,s)}const Se=p&&U||we,Me=F||Se?Sn:L?me:e.transform.clipSpaceToPixelsMatrix,Ee=S&&0!==c.paint.get(p?"text-halo-width":"icon-halo-width").constantOr(1);let Ce;Ce=S?g.iconsInText?_n(G.kind,re,B,L,F,Se,e,Me,ye,xe,oe,ue,Z):mn(G.kind,re,B,L,F,Se,e,Me,ye,xe,p,oe,0,Z):fn(G.kind,re,B,L,F,Se,e,Me,ye,xe,p,oe,Z);const Ae={program:J,buffers:b,uniformValues:Ce,projectionData:ve,atlasTexture:le,atlasTextureIcon:pe,atlasInterpolation:ce,atlasInterpolationIcon:he,isSDF:S,hasHalo:Ee};if(O&&g.canOverlap){j=!0;const e=b.segments.get();for(const s of e)q.push({segments:new l.aX([s]),sortKey:s.sortKey,state:Ae,terrainData:se})}else q.push({segments:b.segments,sortKey:0,state:Ae,terrainData:se})}j&&q.sort(((e,s)=>e.sortKey-s.sortKey));for(const s of q){const l=s.state;if(S.activeTexture.set(I.TEXTURE0),l.atlasTexture.bind(l.atlasInterpolation,I.CLAMP_TO_EDGE),l.atlasTextureIcon&&(S.activeTexture.set(I.TEXTURE1),l.atlasTextureIcon&&l.atlasTextureIcon.bind(l.atlasInterpolationIcon,I.CLAMP_TO_EDGE)),l.isSDF){const d=l.uniformValues;l.hasHalo&&(d.u_is_halo=1,kn(l.buffers,s.segments,c,e,l.program,G,b,T,d,l.projectionData,s.terrainData)),d.u_is_halo=0}kn(l.buffers,s.segments,c,e,l.program,G,b,T,l.uniformValues,l.projectionData,s.terrainData)}}function kn(e,s,l,c,d,p,f,m,_,g,y){const b=c.context;d.draw(b,b.gl.TRIANGLES,p,f,m,ei.backCCW,_,y,g,l.id,e.layoutVertexBuffer,e.indexBuffer,s,l.paint,c.transform.zoom,e.programConfigurations.get(l.id),e.dynamicLayoutVertexBuffer,e.opacityVertexBuffer)}function Rn(e,s,c,d,p){const f=e.context,m=f.gl,_=ai.disabled,g=new Qt([m.ONE,m.ONE],l.bp.transparent,[!0,!0,!0,!0]),y=s.getBucket(c);if(!y)return;const b=d.key;let T=c.heatmapFbos.get(b);T||(T=Bn(f,s.tileSize,s.tileSize),c.heatmapFbos.set(b,T)),f.bindFramebuffer.set(T.framebuffer),f.viewport.set([0,0,s.tileSize,s.tileSize]),f.clear({color:l.bp.transparent});const P=y.programConfigurations.get(c.id),S=e.useProgram("heatmap",P,!p),I=e.transform.getProjectionData({overscaledTileID:s.tileID,applyGlobeMatrix:!0,applyTerrainMatrix:!0}),C=e.style.map.terrain.getTerrainData(d);S.draw(f,m.TRIANGLES,ti.disabled,_,g,ei.disabled,Kr(s,e.transform.zoom,c.paint.get("heatmap-intensity"),1),C,I,c.id,y.layoutVertexBuffer,y.indexBuffer,y.segments,c.paint,e.transform.zoom,P)}function Ln(e,s,l,c,d){const p=e.context,f=p.gl,m=e.transform;p.setColorMode(e.colorModeForRenderPass());const _=On(p,s),g=l.key,y=s.heatmapFbos.get(g);if(!y)return;p.activeTexture.set(f.TEXTURE0),f.bindTexture(f.TEXTURE_2D,y.colorAttachment.get()),p.activeTexture.set(f.TEXTURE1),_.bind(f.LINEAR,f.CLAMP_TO_EDGE);const b=m.getProjectionData({overscaledTileID:l,applyTerrainMatrix:d,applyGlobeMatrix:!c});e.useProgram("heatmapTexture").draw(p,f.TRIANGLES,ti.disabled,ai.disabled,e.colorModeForRenderPass(),ei.disabled,Qr(e,s,0,1),null,b,s.id,e.rasterBoundsBuffer,e.quadTriangleIndexBuffer,e.rasterBoundsSegments,s.paint,m.zoom),y.destroy(),s.heatmapFbos.delete(g)}function Bn(e,s,l){var c,d;const p=e.gl,f=p.createTexture();p.bindTexture(p.TEXTURE_2D,f),p.texParameteri(p.TEXTURE_2D,p.TEXTURE_WRAP_S,p.CLAMP_TO_EDGE),p.texParameteri(p.TEXTURE_2D,p.TEXTURE_WRAP_T,p.CLAMP_TO_EDGE),p.texParameteri(p.TEXTURE_2D,p.TEXTURE_MIN_FILTER,p.LINEAR),p.texParameteri(p.TEXTURE_2D,p.TEXTURE_MAG_FILTER,p.LINEAR);const m=null!==(c=e.HALF_FLOAT)&&void 0!==c?c:p.UNSIGNED_BYTE,_=null!==(d=e.RGBA16F)&&void 0!==d?d:p.RGBA;p.texImage2D(p.TEXTURE_2D,0,_,s,l,0,p.RGBA,m,null);const g=e.createFramebuffer(s,l,!1,!1);return g.colorAttachment.set(f),g}function On(e,s){return s.colorRampTexture||(s.colorRampTexture=new l.T(e,s.colorRamp,e.gl.RGBA)),s.colorRampTexture}function Vn(e,s,c,d,p,f,m,_){let g=256;if(p.stepInterpolant){const d=s.getSource().maxzoom,p=m.canonical.z===d?Math.ceil(1<20&&T.texParameterf(T.TEXTURE_2D,b.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,b.extTextureFilterAnisotropicMax);const re=e.style.map.terrain&&e.style.map.terrain.getTerrainData(j),se=S.getProjectionData({overscaledTileID:j,aligned:z,applyGlobeMatrix:!g,applyTerrainMatrix:!0}),oe=dn(W,Z,J.fadeMix,l,m),le=I.getMeshFromTileID(b,j.canonical,p,f,"raster");P.draw(b,T.TRIANGLES,c,d?d[j.overscaledZ]:ai.disabled,C,_?ei.frontCCW:ei.backCCW,oe,re,se,l.id,le.vertexBuffer,le.indexBuffer,le.segments)}}function Kn(e,s,c,d){const p={parentTile:null,parentScaleBy:1,parentTopLeft:[0,0],fadeValues:{tileOpacity:1,parentTileOpacity:1,fadeMix:{opacity:1,mix:0}}};if(0===c||d)return p;if(e.fadingParentID){const d=s.getLoadedTile(e.fadingParentID);if(!d)return p;const f=Math.pow(2,d.tileID.overscaledZ-e.tileID.overscaledZ),m=[e.tileID.canonical.x*f%1,e.tileID.canonical.y*f%1],_=function(e,s,c){const d=y(),p=(d-s.timeAdded)/c,f=e.fadingDirection===Me.Incoming,m=l.an((d-e.timeAdded)/c,0,1),_=l.an(1-p,0,1),g=f?m:_;return{tileOpacity:g,parentTileOpacity:f?_:m,fadeMix:{opacity:1,mix:1-g}}}(e,d,c);return{parentTile:d,parentScaleBy:f,parentTopLeft:m,fadeValues:_}}if(e.selfFading){const s=function(e,s){const c=(y()-e.timeAdded)/s,d=l.an(c,0,1);return{tileOpacity:d,fadeMix:{opacity:d,mix:0}}}(e,c);return{parentTile:null,parentScaleBy:1,parentTopLeft:[0,0],fadeValues:s}}return p}const Qn=new l.bp(1,0,0,1),Jn=new l.bp(0,1,0,1),es=new l.bp(0,0,1,1),ns=new l.bp(1,0,1,1),ss=new l.bp(0,1,1,1);function ls(e,s,l,c){ds(e,0,s+l/2,e.transform.width,l,c)}function us(e,s,l,c){ds(e,s-l/2,0,l,e.transform.height,c)}function ds(e,s,l,c,d,p){const f=e.context,m=f.gl;m.enable(m.SCISSOR_TEST),m.scissor(s*e.pixelRatio,l*e.pixelRatio,c*e.pixelRatio,d*e.pixelRatio),f.clear({color:p}),m.disable(m.SCISSOR_TEST)}function ps(e,s,c){const d=e.context,p=d.gl,f=e.useProgram("debug"),m=ti.disabled,_=ai.disabled,g=e.colorModeForRenderPass(),y="$debug",b=e.style.map.terrain&&e.style.map.terrain.getTerrainData(c);d.activeTexture.set(p.TEXTURE0);const T=s.getTileByID(c.key).latestRawTileData,P=Math.floor((T&&T.byteLength||0)/1024),S=s.getTile(c).tileSize,I=512/Math.min(S,512)*(c.overscaledZ/e.transform.zoom)*.5;let C=c.canonical.toString();c.overscaledZ!==c.canonical.z&&(C+=` => ${c.overscaledZ}`),function(e,s){e.initDebugOverlayCanvas();const l=e.debugOverlayCanvas,c=e.context.gl,d=e.debugOverlayCanvas.getContext("2d");d.clearRect(0,0,l.width,l.height),d.shadowColor="white",d.shadowBlur=2,d.lineWidth=1.5,d.strokeStyle="white",d.textBaseline="top",d.font="bold 36px Open Sans, sans-serif",d.fillText(s,5,5),d.strokeText(s,5,5),e.debugOverlayTexture.update(l),e.debugOverlayTexture.bind(c.LINEAR,c.CLAMP_TO_EDGE)}(e,`${C} ${P}kB`);const z=e.transform.getProjectionData({overscaledTileID:c,applyGlobeMatrix:!0,applyTerrainMatrix:!0});f.draw(d,p.TRIANGLES,m,_,Qt.alphaBlended,ei.disabled,Yr(l.bp.transparent,I),null,z,y,e.debugBuffer,e.quadTriangleIndexBuffer,e.debugSegments),f.draw(d,p.LINE_STRIP,m,_,g,ei.disabled,Yr(l.bp.red),b,z,y,e.debugBuffer,e.tileBorderIndexBuffer,e.debugSegments)}function fs(e,s,l,c){const{isRenderingGlobe:d}=c,p=e.context,f=p.gl,m=e.transform,_=e.colorModeForRenderPass(),g=e.getDepthModeFor3D(),y=e.useProgram("terrain");p.bindFramebuffer.set(null),p.viewport.set([0,0,e.width,e.height]);for(const c of l){const l=s.getTerrainMesh(c.tileID),b=e.renderToTexture.getTexture(c),T=s.getTerrainData(c.tileID);p.activeTexture.set(f.TEXTURE0),f.bindTexture(f.TEXTURE_2D,b.texture);const P=s.getMeshFrameDelta(m.zoom),S=m.calculateFogMatrix(c.tileID.toUnwrapped()),I=Rr(P,S,e.style.sky,m.pitch,d),C=m.getProjectionData({overscaledTileID:c.tileID,applyTerrainMatrix:!1,applyGlobeMatrix:!0});y.draw(p,f.TRIANGLES,g,ai.disabled,_,ei.backCCW,I,T,C,"terrain",l.vertexBuffer,l.indexBuffer,l.segments)}}function _s(e,s){if(!s.mesh){const c=new l.aW;c.emplaceBack(-1,-1),c.emplaceBack(1,-1),c.emplaceBack(1,1),c.emplaceBack(-1,1);const d=new l.aY;d.emplaceBack(0,1,2),d.emplaceBack(0,2,3),s.mesh=new kt(e.createVertexBuffer(c,Ni.members),e.createIndexBuffer(d),l.aX.simpleSegment(0,0,c.length,d.length))}return s.mesh}class qr{constructor(e,s){this.context=new nr(e),this.transform=s,this._tileTextures={},this.terrainFacilitator={dirty:!0,matrix:l.ar(new Float64Array(16)),renderTime:0},this.setup(),this.numSublayers=ke.maxOverzooming+ke.maxUnderzooming+1,this.depthEpsilon=1/Math.pow(2,16),this.crossTileSymbolIndex=new zt}resize(e,s,l){if(this.width=Math.floor(e*l),this.height=Math.floor(s*l),this.pixelRatio=l,this.context.viewport.set([0,0,this.width,this.height]),this.style)for(const e of this.style._order)this.style._layers[e].resize()}setup(){const e=this.context,s=new l.aW;s.emplaceBack(0,0),s.emplaceBack(l.a5,0),s.emplaceBack(0,l.a5),s.emplaceBack(l.a5,l.a5),this.tileExtentBuffer=e.createVertexBuffer(s,Ni.members),this.tileExtentSegments=l.aX.simpleSegment(0,0,4,2);const c=new l.aW;c.emplaceBack(0,0),c.emplaceBack(l.a5,0),c.emplaceBack(0,l.a5),c.emplaceBack(l.a5,l.a5),this.debugBuffer=e.createVertexBuffer(c,Ni.members),this.debugSegments=l.aX.simpleSegment(0,0,4,5);const d=new l.ch;d.emplaceBack(0,0,0,0),d.emplaceBack(l.a5,0,l.a5,0),d.emplaceBack(0,l.a5,0,l.a5),d.emplaceBack(l.a5,l.a5,l.a5,l.a5),this.rasterBoundsBuffer=e.createVertexBuffer(d,kr.members),this.rasterBoundsSegments=l.aX.simpleSegment(0,0,4,2);const p=new l.aW;p.emplaceBack(0,0),p.emplaceBack(l.a5,0),p.emplaceBack(0,l.a5),p.emplaceBack(l.a5,l.a5),this.rasterBoundsBufferPosOnly=e.createVertexBuffer(p,Ni.members),this.rasterBoundsSegmentsPosOnly=l.aX.simpleSegment(0,0,4,5);const f=new l.aW;f.emplaceBack(0,0),f.emplaceBack(1,0),f.emplaceBack(0,1),f.emplaceBack(1,1),this.viewportBuffer=e.createVertexBuffer(f,Ni.members),this.viewportSegments=l.aX.simpleSegment(0,0,4,2);const m=new l.ci;m.emplaceBack(0),m.emplaceBack(1),m.emplaceBack(3),m.emplaceBack(2),m.emplaceBack(0),this.tileBorderIndexBuffer=e.createIndexBuffer(m);const _=new l.aY;_.emplaceBack(1,0,2),_.emplaceBack(1,2,3),this.quadTriangleIndexBuffer=e.createIndexBuffer(_);const g=this.context.gl;this.stencilClearMode=new ai({func:g.ALWAYS,mask:0},0,255,g.ZERO,g.ZERO,g.ZERO),this.tileExtentMesh=new kt(this.tileExtentBuffer,this.quadTriangleIndexBuffer,this.tileExtentSegments)}clearStencil(){const e=this.context,s=e.gl;this.nextStencilID=1,this.currentStencilSource=void 0;const c=l.N();l.c7(c,0,this.width,this.height,0,0,1),l.Q(c,c,[s.drawingBufferWidth,s.drawingBufferHeight,0]);const d={mainMatrix:c,tileMercatorCoords:[0,0,1,1],clippingPlane:[0,0,0,0],projectionTransition:0,fallbackMatrix:c};this.useProgram("clippingMask",null,!0).draw(e,s.TRIANGLES,ti.disabled,this.stencilClearMode,Qt.disabled,ei.disabled,null,null,d,"$clipping",this.viewportBuffer,this.quadTriangleIndexBuffer,this.viewportSegments)}_renderTileClippingMasks(e,s,l){if(this.currentStencilSource===e.source||!e.isTileClipped()||!s||!s.length)return;this.currentStencilSource=e.source,this.nextStencilID+s.length>256&&this.clearStencil();const c=this.context;c.setColorMode(Qt.disabled),c.setDepthMode(ti.disabled);const d={};for(const e of s)d[e.key]=this.nextStencilID++;this._renderTileMasks(d,s,l,!0),this._renderTileMasks(d,s,l,!1),this._tileClippingMaskIDs=d}_renderTileMasks(e,s,l,c){const d=this.context,p=d.gl,f=this.style.projection,m=this.transform,_=this.useProgram("clippingMask");for(const g of s){const s=e[g.key],y=this.style.map.terrain&&this.style.map.terrain.getTerrainData(g),b=f.getMeshFromTileID(this.context,g.canonical,c,!0,"stencil"),T=m.getProjectionData({overscaledTileID:g,applyGlobeMatrix:!l,applyTerrainMatrix:!0});_.draw(d,p.TRIANGLES,ti.disabled,new ai({func:p.ALWAYS,mask:0},s,255,p.KEEP,p.KEEP,p.REPLACE),Qt.disabled,l?ei.disabled:ei.backCCW,null,y,T,"$clipping",b.vertexBuffer,b.indexBuffer,b.segments)}}_renderTilesDepthBuffer(){const e=this.context,s=e.gl,l=this.style.projection,c=this.transform,d=this.useProgram("depth"),p=this.getDepthModeFor3D(),f=it(c,{tileSize:c.tileSize});for(const m of f){const f=this.style.map.terrain&&this.style.map.terrain.getTerrainData(m),_=l.getMeshFromTileID(this.context,m.canonical,!0,!0,"raster"),g=c.getProjectionData({overscaledTileID:m,applyGlobeMatrix:!0,applyTerrainMatrix:!0});d.draw(e,s.TRIANGLES,p,ai.disabled,Qt.disabled,ei.backCCW,null,f,g,"$clipping",_.vertexBuffer,_.indexBuffer,_.segments)}}stencilModeFor3D(){this.currentStencilSource=void 0,this.nextStencilID+1>256&&this.clearStencil();const e=this.nextStencilID++,s=this.context.gl;return new ai({func:s.NOTEQUAL,mask:255},e,255,s.KEEP,s.KEEP,s.REPLACE)}stencilModeForClipping(e){const s=this.context.gl;return new ai({func:s.EQUAL,mask:255},this._tileClippingMaskIDs[e.key],0,s.KEEP,s.KEEP,s.REPLACE)}getStencilConfigForOverlapAndUpdateStencilID(e){const s=this.context.gl,l=e.sort(((e,s)=>s.overscaledZ-e.overscaledZ)),c=l[l.length-1].overscaledZ,d=l[0].overscaledZ-c+1;if(d>1){this.currentStencilSource=void 0,this.nextStencilID+d>256&&this.clearStencil();const e={};for(let l=0;ls.overscaledZ-e.overscaledZ)),c=l[l.length-1].overscaledZ,d=l[0].overscaledZ-c+1;if(this.clearStencil(),d>1){const e={},p={};for(let l=0;l0};for(const e in f){const s=f[e];s.used&&s.prepare(this.context),m[e]=s.getVisibleCoordinates(!1),_[e]=m[e].slice().reverse(),g[e]=s.getVisibleCoordinates(!0).reverse()}this.opaquePassCutoff=1/0;for(let e=0;ethis.useProgram(e)}),this.context.viewport.set([0,0,this.width,this.height]),this.context.bindFramebuffer.set(null),this.context.clear({color:s.showOverdrawInspector?l.bp.black:l.bp.transparent,depth:1}),this.clearStencil(),this.style.sky&&function(e,s){const l=e.context,c=l.gl,d=((e,s,l)=>{const c=Math.cos(s.rollInRadians),d=Math.sin(s.rollInRadians),p=Ne(s),f=s.getProjectionData({overscaledTileID:null,applyGlobeMatrix:!0,applyTerrainMatrix:!0}).projectionTransition;return{u_sky_color:e.properties.get("sky-color"),u_horizon_color:e.properties.get("horizon-color"),u_horizon:[(s.width/2-p*d)*l,(s.height/2+p*c)*l],u_horizon_normal:[-d,c],u_sky_horizon_blend:e.properties.get("sky-horizon-blend")*s.height/2*l,u_sky_blend:f}})(s,e.style.map.transform,e.pixelRatio),p=new ti(c.LEQUAL,ti.ReadWrite,[0,1]),f=ai.disabled,m=e.colorModeForRenderPass(),_=e.useProgram("sky"),g=_s(l,s);_.draw(l,c.TRIANGLES,p,f,m,ei.disabled,d,null,void 0,"sky",g.vertexBuffer,g.indexBuffer,g.segments)}(this,this.style.sky),this._showOverdrawInspector=s.showOverdrawInspector,this.depthRangeFor3D=[0,1-(e._order.length+2)*this.numSublayers*this.depthEpsilon],!this.renderToTexture)for(this.renderPass="opaque",this.currentLayer=p.length-1;this.currentLayer>=0;this.currentLayer--){const e=this.style._layers[p[this.currentLayer]],s=f[e.source],l=m[e.source];this._renderTileClippingMasks(e,l,!1),this.renderLayer(this,s,e,l,b)}this.renderPass="translucent";let T=!1;for(this.currentLayer=0;this.currentLayer({u_sun_pos:e,u_atmosphere_blend:s,u_globe_position:l,u_globe_radius:c,u_inv_proj_matrix:d}))(g,b,[S[0],S[1],S[2]],T,P),C=_s(d,s);f.draw(d,p.TRIANGLES,m,ai.disabled,Qt.alphaBlended,ei.disabled,I,null,null,"atmosphere",C.vertexBuffer,C.indexBuffer,C.segments)}(this,this.style.sky,this.style.light),this.options.showTileBoundaries){const e=function(e,s){let l=null;const c=Object.values(e._layers).flatMap((l=>l.source&&!l.isHidden(s)?[e.tileManagers[l.source]]:[])),d=c.filter((e=>"vector"===e.getSource().type)),p=c.filter((e=>"vector"!==e.getSource().type)),f=e=>{(!l||l.getSource().maxzoomf(e))),l||p.forEach((e=>f(e))),l}(this.style,this.transform.zoom);e&&function(e,s,l){for(let c=0;cb.getElevation(p,e,s):null;Cn(f,T,P,g,y,C,s,S,z,l.aO(y,e,m,_),p.toUnwrapped(),c)}}}(d,e,c,s,c.layout.get("text-rotation-alignment"),c.layout.get("text-pitch-alignment"),c.paint.get("text-translate"),c.paint.get("text-translate-anchor"),p),0!==c.paint.get("icon-opacity").constantOr(1)&&Dn(e,s,c,d,!1,c.paint.get("icon-translate"),c.paint.get("icon-translate-anchor"),c.layout.get("icon-rotation-alignment"),c.layout.get("icon-pitch-alignment"),c.layout.get("icon-keep-upright"),_,g,m),0!==c.paint.get("text-opacity").constantOr(1)&&Dn(e,s,c,d,!0,c.paint.get("text-translate"),c.paint.get("text-translate-anchor"),c.layout.get("text-rotation-alignment"),c.layout.get("text-pitch-alignment"),c.layout.get("text-keep-upright"),_,g,m),s.map.showCollisionBoxes&&(Pn(e,s,c,d,!0),Pn(e,s,c,d,!1))}(e,s,c,d,this.style.placement.variableOffsets,p):l.cn(c)?function(e,s,c,d,p){if("translucent"!==e.renderPass)return;const{isRenderingToTexture:f}=p,m=c.paint.get("circle-opacity"),_=c.paint.get("circle-stroke-width"),g=c.paint.get("circle-stroke-opacity"),y=!c.layout.get("circle-sort-key").isConstant();if(0===m.constantOr(1)&&(0===_.constantOr(1)||0===g.constantOr(1)))return;const b=e.context,T=b.gl,P=e.transform,S=e.getDepthModeForSublayer(0,ti.ReadOnly),I=ai.disabled,C=e.colorModeForRenderPass(),z=[],L=P.getCircleRadiusCorrection();for(let p=0;pe.sortKey-s.sortKey));for(const s of z){const{programConfiguration:l,program:d,layoutVertexBuffer:p,indexBuffer:f,uniformValues:m,terrainData:_,projectionData:g}=s.state;d.draw(b,T.TRIANGLES,S,I,C,ei.backCCW,m,_,g,c.id,p,f,s.segments,c.paint,e.transform.zoom,l)}}(e,s,c,d,p):l.co(c)?function(e,s,c,d,p){if(0===c.paint.get("heatmap-opacity"))return;const f=e.context,{isRenderingToTexture:m,isRenderingGlobe:_}=p;if(e.style.map.terrain){for(const l of d){const d=s.getTile(l);s.hasRenderableParent(l)||("offscreen"===e.renderPass?Rn(e,d,c,l,_):"translucent"===e.renderPass&&Ln(e,c,l,m,_))}f.viewport.set([0,0,e.width,e.height])}else"offscreen"===e.renderPass?function(e,s,c,d){const p=e.context,f=p.gl,m=e.transform,_=ai.disabled,g=new Qt([f.ONE,f.ONE],l.bp.transparent,[!0,!0,!0,!0]);(function(e,s,c){const d=e.gl;e.activeTexture.set(d.TEXTURE1),e.viewport.set([0,0,s.width/4,s.height/4]);let p=c.heatmapFbos.get(l.cd);p?(d.bindTexture(d.TEXTURE_2D,p.colorAttachment.get()),e.bindFramebuffer.set(p.framebuffer)):(p=Bn(e,s.width/4,s.height/4),c.heatmapFbos.set(l.cd,p))})(p,e,c),p.clear({color:l.bp.transparent});for(let l=0;l0?s.pop():null}isPatternMissing(e){if(!e)return!1;if(!e.from||!e.to)return!0;const s=this.imageManager.getPattern(e.from.toString()),l=this.imageManager.getPattern(e.to.toString());return!s||!l}useProgram(e,s,l=!1,c=[]){this.cache=this.cache||{};const d=!!this.style.map.terrain,p=this.style.projection,f=l?Vi.projectionMercator:p.shaderPreludeCode,m=l?Gi:p.shaderDefine,_=e+(s?s.cacheKey:"")+`/${l?Ui:p.shaderVariantName}`+(this._showOverdrawInspector?"/overdraw":"")+(d?"/terrain":"")+(c?`/${c.join("/")}`:"");return this.cache[_]||(this.cache[_]=new Zi(this.context,Vi[e],s,vn[e],this._showOverdrawInspector,d,f,m,c)),this.cache[_]}setCustomLayerDefaults(){this.context.unbindVAO(),this.context.cullFace.setDefault(),this.context.activeTexture.setDefault(),this.context.pixelStoreUnpack.setDefault(),this.context.pixelStoreUnpackPremultiplyAlpha.setDefault(),this.context.pixelStoreUnpackFlipY.setDefault()}setBaseState(){const e=this.context.gl;this.context.cullFace.set(!1),this.context.viewport.set([0,0,this.width,this.height]),this.context.blendEquation.set(e.FUNC_ADD)}initDebugOverlayCanvas(){null==this.debugOverlayCanvas&&(this.debugOverlayCanvas=document.createElement("canvas"),this.debugOverlayCanvas.width=512,this.debugOverlayCanvas.height=512,this.debugOverlayTexture=new l.T(this.context,this.debugOverlayCanvas,this.context.gl.RGBA))}destroy(){var e,s;if(this._tileTextures){for(const e in this._tileTextures){const s=this._tileTextures[e];if(s)for(const e of s)e.destroy()}this._tileTextures={}}if(this.tileExtentBuffer&&this.tileExtentBuffer.destroy(),this.debugBuffer&&this.debugBuffer.destroy(),this.rasterBoundsBuffer&&this.rasterBoundsBuffer.destroy(),this.rasterBoundsBufferPosOnly&&this.rasterBoundsBufferPosOnly.destroy(),this.viewportBuffer&&this.viewportBuffer.destroy(),this.tileBorderIndexBuffer&&this.tileBorderIndexBuffer.destroy(),this.quadTriangleIndexBuffer&&this.quadTriangleIndexBuffer.destroy(),this.tileExtentMesh&&(null===(e=this.tileExtentMesh.vertexBuffer)||void 0===e||e.destroy()),this.tileExtentMesh&&(null===(s=this.tileExtentMesh.indexBuffer)||void 0===s||s.destroy()),this.debugOverlayTexture&&this.debugOverlayTexture.destroy(),this.cache){for(const e in this.cache){const s=this.cache[e];s&&s.program&&this.context.gl.deleteProgram(s.program)}this.cache={}}this.context&&this.context.setDefault()}overLimit(){const{drawingBufferWidth:e,drawingBufferHeight:s}=this.context.gl;return this.width!==e||this.height!==s}}function gs(s,l){let c,d=!1,p=null,f=null;const m=()=>{p=null,d&&(s.apply(f,c),p=setTimeout(m,l),d=!1)};return(...s)=>(d=!0,f=this||e,c=s,p||m(),p)}class $r{constructor(e){this._getCurrentHash=()=>{const e=window.location.hash.replace("#","");if(this._hashName){let s;return e.split("&").map((e=>e.split("="))).forEach((e=>{e[0]===this._hashName&&(s=e)})),(s&&s[1]||"").split("/")}return e.split("/")},this._onHashChange=()=>{const e=this._getCurrentHash();if(!this._isValidHash(e))return!1;const s=this._map.dragRotate.isEnabled()&&this._map.touchZoomRotate.isEnabled()?+(e[3]||0):this._map.getBearing();return this._map.jumpTo({center:[+e[2],+e[1]],zoom:+e[0],bearing:s,pitch:+(e[4]||0)}),!0},this._updateHashUnthrottled=()=>{const e=window.location.href.replace(/(#.*)?$/,this.getHashString());window.history.replaceState(window.history.state,null,e)},this._removeHash=()=>{const e=this._getCurrentHash();if(0===e.length)return;const s=e.join("/");let l=s;l.split("&").length>0&&(l=l.split("&")[0]),this._hashName&&(l=`${this._hashName}=${s}`);let c=window.location.hash.replace(l,"");c.startsWith("#&")?c=c.slice(0,1)+c.slice(2):"#"===c&&(c="");let d=window.location.href.replace(/(#.+)?$/,c);d=d.replace("&&","&"),window.history.replaceState(window.history.state,null,d)},this._updateHash=gs(this._updateHashUnthrottled,300),this._hashName=e&&encodeURIComponent(e)}addTo(e){return this._map=e,addEventListener("hashchange",this._onHashChange,!1),this._map.on("moveend",this._updateHash),this}remove(){return removeEventListener("hashchange",this._onHashChange,!1),this._map.off("moveend",this._updateHash),clearTimeout(this._updateHash()),this._removeHash(),delete this._map,this}getHashString(e){const s=this._map.getCenter(),l=Math.round(100*this._map.getZoom())/100,c=Math.ceil((l*Math.LN2+Math.log(512/360/.5))/Math.LN10),d=Math.pow(10,c),p=Math.round(s.lng*d)/d,f=Math.round(s.lat*d)/d,m=this._map.getBearing(),_=this._map.getPitch();let g="";if(g+=e?`/${p}/${f}/${l}`:`${l}/${f}/${p}`,(m||_)&&(g+="/"+Math.round(10*m)/10),_&&(g+=`/${Math.round(_)}`),this._hashName){const e=this._hashName;let s=!1;const l=window.location.hash.slice(1).split("&").map((l=>{const c=l.split("=")[0];return c===e?(s=!0,`${c}=${g}`):l})).filter((e=>e));return s||l.push(`${e}=${g}`),`#${l.join("&")}`}return`#${g}`}_isValidHash(e){if(e.length<3||e.some(isNaN))return!1;try{new l.V(+e[2],+e[1])}catch(e){return!1}const s=+e[0],c=+(e[3]||0),d=+(e[4]||0);return s>=this._map.getMinZoom()&&s<=this._map.getMaxZoom()&&c>=-180&&c<=180&&d>=this._map.getMinPitch()&&d<=this._map.getMaxPitch()}}const ys={linearity:.3,easing:l.cw(0,0,.3,1)},vs=l.e({deceleration:2500,maxSpeed:1400},ys),bs=l.e({deceleration:20,maxSpeed:1400},ys),ws=l.e({deceleration:1e3,maxSpeed:360},ys),Ts=l.e({deceleration:1e3,maxSpeed:90},ys),Ss=l.e({deceleration:1e3,maxSpeed:360},ys);class eo{constructor(e){this._map=e,this.clear()}clear(){this._inertiaBuffer=[]}record(e){this._drainInertiaBuffer(),this._inertiaBuffer.push({time:y(),settings:e})}_drainInertiaBuffer(){const e=this._inertiaBuffer,s=y();for(;e.length>0&&s-e[0].time>160;)e.shift()}_onMoveEnd(e){if(this._drainInertiaBuffer(),this._inertiaBuffer.length<2)return;const s={zoom:0,bearing:0,pitch:0,roll:0,pan:new l.P(0,0),pinchAround:void 0,around:void 0};for(const{settings:e}of this._inertiaBuffer)s.zoom+=e.zoomDelta||0,s.bearing+=e.bearingDelta||0,s.pitch+=e.pitchDelta||0,s.roll+=e.rollDelta||0,e.panDelta&&s.pan._add(e.panDelta),e.around&&(s.around=e.around),e.pinchAround&&(s.pinchAround=e.pinchAround);const c=this._inertiaBuffer[this._inertiaBuffer.length-1].time-this._inertiaBuffer[0].time,d={};if(s.pan.mag()){const p=Is(s.pan.mag(),c,l.e({},vs,e||{})),f=s.pan.mult(p.amount/s.pan.mag()),m=this._map.cameraHelper.handlePanInertia(f,this._map.transform);d.center=m.easingCenter,d.offset=m.easingOffset,Ms(d,p)}if(s.zoom){const e=Is(s.zoom,c,bs);d.zoom=this._map.transform.zoom+e.amount,Ms(d,e)}if(s.bearing){const e=Is(s.bearing,c,ws);d.bearing=this._map.transform.bearing+l.an(e.amount,-179,179),Ms(d,e)}if(s.pitch){const e=Is(s.pitch,c,Ts);d.pitch=this._map.transform.pitch+e.amount,Ms(d,e)}if(s.roll){const e=Is(s.roll,c,Ss);d.roll=this._map.transform.roll+l.an(e.amount,-179,179),Ms(d,e)}if(d.zoom||d.bearing){const e=void 0===s.pinchAround?s.around:s.pinchAround;d.around=e?this._map.unproject(e):this._map.getCenter()}return this.clear(),l.e(d,{noMoveStart:!0})}}function Ms(e,s){(!e.duration||e.durations.unproject(e))),m=p.reduce(((e,s,l,c)=>e.add(s.div(c.length))),new l.P(0,0));super(e,{points:p,point:m,lngLats:f,lngLat:s.unproject(m),originalEvent:c}),this._defaultPrevented=!1}}class oo extends l.l{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(e,s,l){super(e,{originalEvent:l}),this._defaultPrevented=!1}}class so{constructor(e,s){this._map=e,this._clickTolerance=s.clickTolerance}reset(){delete this._mousedownPos}wheel(e){return this._firePreventable(new oo(e.type,this._map,e))}mousedown(e,s){return this._mousedownPos=s,this._firePreventable(new ao(e.type,this._map,e))}mouseup(e){this._map.fire(new ao(e.type,this._map,e))}click(e,s){this._mousedownPos&&this._mousedownPos.dist(s)>=this._clickTolerance||this._map.fire(new ao(e.type,this._map,e))}dblclick(e){return this._firePreventable(new ao(e.type,this._map,e))}mouseover(e){this._map.fire(new ao(e.type,this._map,e))}mouseout(e){this._map.fire(new ao(e.type,this._map,e))}touchstart(e){return this._firePreventable(new ro(e.type,this._map,e))}touchmove(e){this._map.fire(new ro(e.type,this._map,e))}touchend(e){this._map.fire(new ro(e.type,this._map,e))}touchcancel(e){this._map.fire(new ro(e.type,this._map,e))}_firePreventable(e){if(this._map.fire(e),e.defaultPrevented)return{}}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}}class no{constructor(e){this._map=e}reset(){this._delayContextMenu=!1,this._ignoreContextMenu=!0,delete this._contextMenuEvent}mousemove(e){this._map.fire(new ao(e.type,this._map,e))}mousedown(){this._delayContextMenu=!0,this._ignoreContextMenu=!1}mouseup(){this._delayContextMenu=!1,this._contextMenuEvent&&(this._map.fire(new ao("contextmenu",this._map,this._contextMenuEvent)),delete this._contextMenuEvent)}contextmenu(e){this._delayContextMenu?this._contextMenuEvent=e:this._ignoreContextMenu||this._map.fire(new ao(e.type,this._map,e)),this._map.listens("contextmenu")&&e.preventDefault()}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}}class lo{constructor(e){this._map=e}get transform(){return this._map._requestedCameraState||this._map.transform}get center(){return{lng:this.transform.center.lng,lat:this.transform.center.lat}}get zoom(){return this.transform.zoom}get pitch(){return this.transform.pitch}get bearing(){return this.transform.bearing}unproject(e){return this.transform.screenPointToLocation(l.P.convert(e),this._map.terrain)}}class co{constructor(e,s){this._map=e,this._tr=new lo(e),this._el=e.getCanvasContainer(),this._container=e.getContainer(),this._clickTolerance=s.clickTolerance||1}isEnabled(){return!!this._enabled}isActive(){return!!this._active}enable(){this.isEnabled()||(this._enabled=!0)}disable(){this.isEnabled()&&(this._enabled=!1)}mousedown(e,s){this.isEnabled()&&e.shiftKey&&0===e.button&&(h.disableDrag(),this._startPos=this._lastPos=s,this._active=!0)}mousemoveWindow(e,s){if(!this._active)return;const l=s;if(this._lastPos.equals(l)||!this._box&&l.dist(this._startPos)e.fitScreenCoordinates(c,d,this._tr.bearing,{linear:!0})};this._fireEvent("boxzoomcancel",e)}keydown(e){this._active&&27===e.keyCode&&(this.reset(),this._fireEvent("boxzoomcancel",e))}reset(){this._active=!1,this._container.classList.remove("maplibregl-crosshair"),this._box&&(h.remove(this._box),this._box=null),h.enableDrag(),delete this._startPos,delete this._lastPos}_fireEvent(e,s){return this._map.fire(new l.l(e,{originalEvent:s}))}}function Es(e,s){if(e.length!==s.length)throw new Error(`The number of touches and points are not equal - touches ${e.length}, points ${s.length}`);const l={};for(let c=0;cthis.numTouches)&&(this.aborted=!0),this.aborted||(void 0===this.startTime&&(this.startTime=e.timeStamp),c.length===this.numTouches&&(this.centroid=function(e){const s=new l.P(0,0);for(const l of e)s._add(l);return s.div(e.length)}(s),this.touches=Es(c,s)))}touchmove(e,s,l){if(this.aborted||!this.centroid)return;const c=Es(l,s);for(const e in this.touches){const s=c[e];(!s||s.dist(this.touches[e])>30)&&(this.aborted=!0)}}touchend(e,s,l){if((!this.centroid||e.timeStamp-this.startTime>500)&&(this.aborted=!0),0===l.length){const e=!this.aborted&&this.centroid;if(this.reset(),e)return e}}}class _o{constructor(e){this.singleTap=new uo(e),this.numTaps=e.numTaps,this.reset()}reset(){this.lastTime=1/0,delete this.lastTap,this.count=0,this.singleTap.reset()}touchstart(e,s,l){this.singleTap.touchstart(e,s,l)}touchmove(e,s,l){this.singleTap.touchmove(e,s,l)}touchend(e,s,l){const c=this.singleTap.touchend(e,s,l);if(c){const s=e.timeStamp-this.lastTime<500,l=!this.lastTap||this.lastTap.dist(c)<30;if(s&&l||this.reset(),this.count++,this.lastTime=e.timeStamp,this.lastTap=c,this.count===this.numTaps)return this.reset(),c}}}class po{constructor(e){this._tr=new lo(e),this._zoomIn=new _o({numTouches:1,numTaps:2}),this._zoomOut=new _o({numTouches:2,numTaps:1}),this.reset()}reset(){this._active=!1,this._zoomIn.reset(),this._zoomOut.reset()}touchstart(e,s,l){this._zoomIn.touchstart(e,s,l),this._zoomOut.touchstart(e,s,l)}touchmove(e,s,l){this._zoomIn.touchmove(e,s,l),this._zoomOut.touchmove(e,s,l)}touchend(e,s,l){const c=this._zoomIn.touchend(e,s,l),d=this._zoomOut.touchend(e,s,l),p=this._tr;return c?(this._active=!0,e.preventDefault(),setTimeout((()=>this.reset()),0),{cameraAnimation:s=>s.easeTo({duration:300,zoom:p.zoom+1,around:p.unproject(c)},{originalEvent:e})}):d?(this._active=!0,e.preventDefault(),setTimeout((()=>this.reset()),0),{cameraAnimation:s=>s.easeTo({duration:300,zoom:p.zoom-1,around:p.unproject(d)},{originalEvent:e})}):void 0}touchcancel(){this.reset()}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class mo{constructor(e){this._enabled=!!e.enable,this._moveStateManager=e.moveStateManager,this._clickTolerance=e.clickTolerance||1,this._moveFunction=e.move,this._activateOnStart=!!e.activateOnStart,e.assignEvents(this),this.reset()}reset(e){this._active=!1,this._moved=!1,delete this._lastPoint,this._moveStateManager.endMove(e)}_move(...e){const s=this._moveFunction(...e);if(s.bearingDelta||s.pitchDelta||s.rollDelta||s.around||s.panDelta)return this._active=!0,s}dragStart(e,s){this.isEnabled()&&!this._lastPoint&&this._moveStateManager.isValidStartEvent(e)&&(this._moveStateManager.startMove(e),this._lastPoint=Array.isArray(s)?s[0]:s,this._activateOnStart&&this._lastPoint&&(this._active=!0))}dragMove(e,s){if(!this.isEnabled())return;const l=this._lastPoint;if(!l)return;if(e.preventDefault(),!this._moveStateManager.isValidMoveEvent(e))return void this.reset(e);const c=Array.isArray(s)?s[0]:s;return!this._moved&&c.dist(l)!0}),s=new bo){this.mouseMoveStateManager=e,this.oneFingerTouchMoveStateManager=s}_executeRelevantHandler(e,s,l){return e instanceof MouseEvent?s(e):"undefined"!=typeof TouchEvent&&e instanceof TouchEvent?l(e):void 0}startMove(e){this._executeRelevantHandler(e,(e=>this.mouseMoveStateManager.startMove(e)),(e=>this.oneFingerTouchMoveStateManager.startMove(e)))}endMove(e){this._executeRelevantHandler(e,(e=>this.mouseMoveStateManager.endMove(e)),(e=>this.oneFingerTouchMoveStateManager.endMove(e)))}isValidStartEvent(e){return this._executeRelevantHandler(e,(e=>this.mouseMoveStateManager.isValidStartEvent(e)),(e=>this.oneFingerTouchMoveStateManager.isValidStartEvent(e)))}isValidMoveEvent(e){return this._executeRelevantHandler(e,(e=>this.mouseMoveStateManager.isValidMoveEvent(e)),(e=>this.oneFingerTouchMoveStateManager.isValidMoveEvent(e)))}isValidEndEvent(e){return this._executeRelevantHandler(e,(e=>this.mouseMoveStateManager.isValidEndEvent(e)),(e=>this.oneFingerTouchMoveStateManager.isValidEndEvent(e)))}}const ks=e=>{e.mousedown=e.dragStart,e.mousemoveWindow=e.dragMove,e.mouseup=e.dragEnd,e.contextmenu=e=>{e.preventDefault()}};class To{constructor(e,s){this._clickTolerance=e.clickTolerance||1,this._map=s,this.reset()}reset(){this._active=!1,this._touches={},this._sum=new l.P(0,0)}_shouldBePrevented(e){return e<(this._map.cooperativeGestures.isEnabled()?2:1)}touchstart(e,s,l){return this._calculateTransform(e,s,l)}touchmove(e,s,l){if(this._active){if(!this._shouldBePrevented(l.length))return e.preventDefault(),this._calculateTransform(e,s,l);this._map.cooperativeGestures.notifyGestureBlocked("touch_pan",e)}}touchend(e,s,l){this._calculateTransform(e,s,l),this._active&&this._shouldBePrevented(l.length)&&this.reset()}touchcancel(){this.reset()}_calculateTransform(e,s,c){c.length>0&&(this._active=!0);const d=Es(c,s),p=new l.P(0,0),f=new l.P(0,0);let m=0;for(const e in d){const s=d[e],l=this._touches[e];l&&(p._add(s),f._add(s.sub(l)),m++,d[e]=s)}if(this._touches=d,this._shouldBePrevented(m)||!f.mag())return;const _=f.div(m);return this._sum._add(_),this._sum.mag()Math.abs(e.x)}class zo extends Po{constructor(e){super(),this._currentTouchCount=0,this._map=e}reset(){super.reset(),this._valid=void 0,delete this._firstMove,delete this._lastPoints}touchstart(e,s,l){super.touchstart(e,s,l),this._currentTouchCount=l.length}_start(e){this._lastPoints=e,Ws(e[0].sub(e[1]))&&(this._valid=!1)}_move(e,s,l){if(this._map.cooperativeGestures.isEnabled()&&this._currentTouchCount<3)return;const c=e[0].sub(this._lastPoints[0]),d=e[1].sub(this._lastPoints[1]);return this._valid=this.gestureBeginsVertically(c,d,l.timeStamp),this._valid?(this._lastPoints=e,this._active=!0,{pitchDelta:(c.y+d.y)/2*-.5}):void 0}gestureBeginsVertically(e,s,l){if(void 0!==this._valid)return this._valid;const c=e.mag()>=2,d=s.mag()>=2;if(!c&&!d)return;if(!c||!d)return void 0===this._firstMove&&(this._firstMove=l),l-this._firstMove<100&&void 0;const p=e.y>0==s.y>0;return Ws(e)&&Ws(s)&&p}}const Js={panStep:100,bearingStep:15,pitchStep:10};class Ao{constructor(e){this._tr=new lo(e);const s=Js;this._panStep=s.panStep,this._bearingStep=s.bearingStep,this._pitchStep=s.pitchStep,this._rotationDisabled=!1}reset(){this._active=!1}keydown(e){if(e.altKey||e.ctrlKey||e.metaKey)return;let s=0,l=0,c=0,d=0,p=0;switch(e.keyCode){case 61:case 107:case 171:case 187:s=1;break;case 189:case 109:case 173:s=-1;break;case 37:e.shiftKey?l=-1:(e.preventDefault(),d=-1);break;case 39:e.shiftKey?l=1:(e.preventDefault(),d=1);break;case 38:e.shiftKey?c=1:(e.preventDefault(),p=-1);break;case 40:e.shiftKey?c=-1:(e.preventDefault(),p=1);break;default:return}return this._rotationDisabled&&(l=0,c=0),{cameraAnimation:f=>{const m=this._tr;f.easeTo({duration:300,easeId:"keyboardHandler",easing:ho,zoom:s?Math.round(m.zoom)+s*(e.shiftKey?2:1):m.zoom,bearing:m.bearing+l*this._bearingStep,pitch:m.pitch+c*this._pitchStep,offset:[-d*this._panStep,-p*this._panStep],center:m.center},{originalEvent:e})}}}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}disableRotation(){this._rotationDisabled=!0}enableRotation(){this._rotationDisabled=!1}}function ho(e){return e*(2-e)}const fo=4.000244140625,vo=1/450;class Bo{constructor(e,s){this._onTimeout=e=>{this._type="wheel",this._delta-=this._lastValue,this._active||this._start(e)},this._map=e,this._tr=new lo(e),this._triggerRenderFrame=s,this._delta=0,this._defaultZoomRate=.01,this._wheelZoomRate=vo}setZoomRate(e){this._defaultZoomRate=e}setWheelZoomRate(e){this._wheelZoomRate=e}isEnabled(){return!!this._enabled}isActive(){return!!this._active||void 0!==this._finishTimeout}isZooming(){return!!this._zooming}enable(e){this.isEnabled()||(this._enabled=!0,this._aroundCenter=!!e&&"center"===e.around)}disable(){this.isEnabled()&&(this._enabled=!1)}_shouldBePrevented(e){return!!this._map.cooperativeGestures.isEnabled()&&!(e.ctrlKey||this._map.cooperativeGestures.isBypassed(e))}wheel(e){if(!this.isEnabled())return;if(this._shouldBePrevented(e))return void this._map.cooperativeGestures.notifyGestureBlocked("wheel_zoom",e);let s=e.deltaMode===WheelEvent.DOM_DELTA_LINE?40*e.deltaY:e.deltaY;const l=y(),c=l-(this._lastWheelEventTime||0);this._lastWheelEventTime=l,0!==s&&s%fo==0?this._type="wheel":0!==s&&Math.abs(s)<4?this._type="trackpad":c>400?(this._type=null,this._lastValue=s,this._timeout=setTimeout(this._onTimeout,40,e)):this._type||(this._type=Math.abs(c*s)<200?"trackpad":"wheel",this._timeout&&(clearTimeout(this._timeout),this._timeout=null,s+=this._lastValue)),e.shiftKey&&s&&(s/=4),this._type&&(this._lastWheelEvent=e,this._delta-=s,this._active||this._start(e)),e.preventDefault()}_start(e){if(!this._delta)return;this._frameId&&(this._frameId=null),this._active=!0,this.isZooming()||(this._zooming=!0),this._finishTimeout&&(clearTimeout(this._finishTimeout),delete this._finishTimeout);const s=h.mousePos(this._map.getCanvas(),e),c=this._tr;this._aroundPoint=this._aroundCenter?c.transform.locationToScreenPoint(l.V.convert(c.center)):s,this._frameId||(this._frameId=!0,this._triggerRenderFrame())}renderFrame(){if(!this._frameId)return;if(this._frameId=null,!this.isActive())return;const e=this._tr.transform;if("number"==typeof this._lastExpectedZoom){const s=e.zoom-this._lastExpectedZoom;"number"==typeof this._startZoom&&(this._startZoom+=s),"number"==typeof this._targetZoom&&(this._targetZoom+=s)}if(0!==this._delta){const s="wheel"===this._type&&Math.abs(this._delta)>fo?this._wheelZoomRate:this._defaultZoomRate;let c=2/(1+Math.exp(-Math.abs(this._delta*s)));this._delta<0&&0!==c&&(c=1/c);const d="number"!=typeof this._targetZoom?e.scale:l.aq(this._targetZoom);this._targetZoom=e.applyConstrain(e.getCameraLngLat(),l.at(d*c)).zoom,"wheel"===this._type&&(this._startZoom=e.zoom,this._easing=this._smoothOutEasing(200)),this._delta=0}const s="number"!=typeof this._targetZoom?e.zoom:this._targetZoom,c=this._startZoom,d=this._easing;let p,f=!1;if("wheel"===this._type&&c&&d){const e=y()-this._lastWheelEventTime,m=Math.min((e+5)/200,1),_=d(m);p=l.G.number(c,s,_),m<1?this._frameId||(this._frameId=!0):f=!0}else p=s,f=!0;return this._active=!0,f&&(this._active=!1,this._finishTimeout=setTimeout((()=>{this._zooming=!1,this._triggerRenderFrame(),delete this._targetZoom,delete this._lastExpectedZoom,delete this._finishTimeout}),200)),this._lastExpectedZoom=p,{noInertia:!0,needsRenderFrame:!f,zoomDelta:p-e.zoom,around:this._aroundPoint,originalEvent:this._lastWheelEvent}}_smoothOutEasing(e){let s=l.cy;if(this._prevEase){const e=this._prevEase,c=(y()-e.start)/e.duration,d=e.easing(c+.01)-e.easing(c),p=.27/Math.sqrt(d*d+1e-4)*.01,f=Math.sqrt(.0729-p*p);s=l.cw(p,f,.25,1)}return this._prevEase={start:y(),duration:e,easing:s},s}reset(){this._active=!1,this._zooming=!1,delete this._targetZoom,delete this._lastExpectedZoom,this._finishTimeout&&(clearTimeout(this._finishTimeout),delete this._finishTimeout)}}class Oo{constructor(e,s){this._clickZoom=e,this._tapZoom=s}enable(){this._clickZoom.enable(),this._tapZoom.enable()}disable(){this._clickZoom.disable(),this._tapZoom.disable()}isEnabled(){return this._clickZoom.isEnabled()&&this._tapZoom.isEnabled()}isActive(){return this._clickZoom.isActive()||this._tapZoom.isActive()}}class jo{constructor(e){this._tr=new lo(e),this.reset()}reset(){this._active=!1}dblclick(e,s){return e.preventDefault(),{cameraAnimation:l=>{l.easeTo({duration:300,zoom:this._tr.zoom+(e.shiftKey?-1:1),around:this._tr.unproject(s)},{originalEvent:e})}}}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class No{constructor(){this._tap=new _o({numTouches:1,numTaps:1}),this.reset()}reset(){this._active=!1,delete this._swipePoint,delete this._swipeTouch,delete this._tapTime,delete this._tapPoint,this._tap.reset()}touchstart(e,s,l){if(!this._swipePoint)if(this._tapTime){const c=s[0],d=e.timeStamp-this._tapTime<500,p=this._tapPoint.dist(c)<30;d&&p?l.length>0&&(this._swipePoint=c,this._swipeTouch=l[0].identifier):this.reset()}else this._tap.touchstart(e,s,l)}touchmove(e,s,l){if(this._tapTime){if(this._swipePoint){if(l[0].identifier!==this._swipeTouch)return;const c=s[0],d=c.y-this._swipePoint.y;return this._swipePoint=c,e.preventDefault(),this._active=!0,{zoomDelta:d/128}}}else this._tap.touchmove(e,s,l)}touchend(e,s,l){if(this._tapTime)this._swipePoint&&0===l.length&&this.reset();else{const c=this._tap.touchend(e,s,l);c&&(this._tapTime=e.timeStamp,this._tapPoint=c)}}touchcancel(){this.reset()}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class Zo{constructor(e,s,l){this._el=e,this._mousePan=s,this._touchPan=l}enable(e){this._inertiaOptions=e||{},this._mousePan.enable(),this._touchPan.enable(),this._el.classList.add("maplibregl-touch-drag-pan")}disable(){this._mousePan.disable(),this._touchPan.disable(),this._el.classList.remove("maplibregl-touch-drag-pan")}isEnabled(){return this._mousePan.isEnabled()&&this._touchPan.isEnabled()}isActive(){return this._mousePan.isActive()||this._touchPan.isActive()}}class Go{constructor(e,s,l,c){this._pitchWithRotate=e.pitchWithRotate,this._rollEnabled=e.rollEnabled,this._mouseRotate=s,this._mousePitch=l,this._mouseRoll=c}enable(){this._mouseRotate.enable(),this._pitchWithRotate&&this._mousePitch.enable(),this._rollEnabled&&this._mouseRoll.enable()}disable(){this._mouseRotate.disable(),this._mousePitch.disable(),this._mouseRoll.disable()}isEnabled(){return this._mouseRotate.isEnabled()&&(!this._pitchWithRotate||this._mousePitch.isEnabled())&&(!this._rollEnabled||this._mouseRoll.isEnabled())}isActive(){return this._mouseRotate.isActive()||this._mousePitch.isActive()||this._mouseRoll.isActive()}}class Uo{constructor(e,s,l,c){this._el=e,this._touchZoom=s,this._touchRotate=l,this._tapDragZoom=c,this._rotationDisabled=!1,this._enabled=!0}enable(e){this._touchZoom.enable(e),this._rotationDisabled||this._touchRotate.enable(e),this._tapDragZoom.enable(),this._el.classList.add("maplibregl-touch-zoom-rotate")}disable(){this._touchZoom.disable(),this._touchRotate.disable(),this._tapDragZoom.disable(),this._el.classList.remove("maplibregl-touch-zoom-rotate")}isEnabled(){return this._touchZoom.isEnabled()&&(this._rotationDisabled||this._touchRotate.isEnabled())&&this._tapDragZoom.isEnabled()}isActive(){return this._touchZoom.isActive()||this._touchRotate.isActive()||this._tapDragZoom.isActive()}disableRotation(){this._rotationDisabled=!0,this._touchRotate.disable()}enableRotation(){this._rotationDisabled=!1,this._touchZoom.isEnabled()&&this._touchRotate.enable()}}class Vo{constructor(e,s){this._bypassKey=-1!==navigator.userAgent.indexOf("Mac")?"metaKey":"ctrlKey",this._map=e,this._options=s,this._enabled=!1}isActive(){return!1}reset(){}_setupUI(){if(this._container)return;const e=this._map.getCanvasContainer();e.classList.add("maplibregl-cooperative-gestures"),this._container=h.create("div","maplibregl-cooperative-gesture-screen",e);let s=this._map._getUIString("CooperativeGesturesHandler.WindowsHelpText");"metaKey"===this._bypassKey&&(s=this._map._getUIString("CooperativeGesturesHandler.MacHelpText"));const l=this._map._getUIString("CooperativeGesturesHandler.MobileHelpText"),c=document.createElement("div");c.className="maplibregl-desktop-message",c.textContent=s,this._container.appendChild(c);const d=document.createElement("div");d.className="maplibregl-mobile-message",d.textContent=l,this._container.appendChild(d),this._container.setAttribute("aria-hidden","true")}_destroyUI(){this._container&&(h.remove(this._container),this._map.getCanvasContainer().classList.remove("maplibregl-cooperative-gestures")),delete this._container}enable(){this._setupUI(),this._enabled=!0}disable(){this._enabled=!1,this._destroyUI()}isEnabled(){return this._enabled}isBypassed(e){return e[this._bypassKey]}notifyGestureBlocked(e,s){this._enabled&&(this._map.fire(new l.l("cooperativegestureprevented",{gestureType:e,originalEvent:s})),this._container.classList.add("maplibregl-show"),setTimeout((()=>{this._container.classList.remove("maplibregl-show")}),100))}}const Eo=e=>e.zoom||e.drag||e.roll||e.pitch||e.rotate;class Wo extends l.l{}function Co(e){return e.panDelta&&e.panDelta.mag()||e.zoomDelta||e.bearingDelta||e.pitchDelta||e.rollDelta}class Ho{constructor(e,s){this.handleWindowEvent=e=>{this.handleEvent(e,`${e.type}Window`)},this.handleEvent=(e,s)=>{if("blur"===e.type)return void this.stop(!0);this._updatingCamera=!0;const c="renderFrame"===e.type?void 0:e,d={needsRenderFrame:!1},p={},f={};for(const{handlerName:m,handler:_,allowed:g}of this._handlers){if(!_.isEnabled())continue;let y;if(this._blockedByActive(f,g,m))_.reset();else if(_[s||e.type]){if(l.cz(e,s||e.type)){const l=h.mousePos(this._map.getCanvas(),e);y=_[s||e.type](e,l)}else if(l.cA(e,s||e.type)){const l=this._getMapTouches(e.touches),c=h.touchPos(this._map.getCanvas(),l);y=_[s||e.type](e,c,l)}else l.cB(s||e.type)||(y=_[s||e.type](e));this.mergeHandlerResult(d,p,y,m,c),y&&y.needsRenderFrame&&this._triggerRenderFrame()}(y||_.isActive())&&(f[m]=_)}const m={};for(const e in this._previousActiveHandlers)f[e]||(m[e]=c);this._previousActiveHandlers=f,(Object.keys(m).length||Co(d))&&(this._changes.push([d,p,m]),this._triggerRenderFrame()),(Object.keys(f).length||Co(d))&&this._map._stop(!0),this._updatingCamera=!1;const{cameraAnimation:_}=d;_&&(this._inertia.clear(),this._fireEvents({},{},!0),this._changes=[],_(this._map))},this._map=e,this._el=this._map.getCanvasContainer(),this._handlers=[],this._handlersById={},this._changes=[],this._inertia=new eo(e),this._bearingSnap=s.bearingSnap,this._previousActiveHandlers={},this._eventsInProgress={},this._addDefaultHandlers(s);const c=this._el;this._listeners=[[c,"touchstart",{passive:!0}],[c,"touchmove",{passive:!1}],[c,"touchend",void 0],[c,"touchcancel",void 0],[c,"mousedown",void 0],[c,"mousemove",void 0],[c,"mouseup",void 0],[document,"mousemove",{capture:!0}],[document,"mouseup",void 0],[c,"mouseover",void 0],[c,"mouseout",void 0],[c,"dblclick",void 0],[c,"click",void 0],[c,"keydown",{capture:!1}],[c,"keyup",void 0],[c,"wheel",{passive:!1}],[c,"contextmenu",void 0],[window,"blur",void 0]];for(const[e,s,l]of this._listeners)h.addEventListener(e,s,e===document?this.handleWindowEvent:this.handleEvent,l)}destroy(){for(const[e,s,l]of this._listeners)h.removeEventListener(e,s,e===document?this.handleWindowEvent:this.handleEvent,l)}_addDefaultHandlers(e){const s=this._map,c=s.getCanvasContainer();this._add("mapEvent",new so(s,e));const d=s.boxZoom=new co(s,e);this._add("boxZoom",d),e.interactive&&e.boxZoom&&d.enable();const p=s.cooperativeGestures=new Vo(s,e.cooperativeGestures);this._add("cooperativeGestures",p),e.cooperativeGestures&&p.enable();const f=new po(s),m=new jo(s);s.doubleClickZoom=new Oo(m,f),this._add("tapZoom",f),this._add("clickZoom",m),e.interactive&&e.doubleClickZoom&&s.doubleClickZoom.enable();const _=new No;this._add("tapDragZoom",_);const g=s.touchPitch=new zo(s);this._add("touchPitch",g),e.interactive&&e.touchPitch&&s.touchPitch.enable(e.touchPitch);const y=()=>s.project(s.getCenter()),b=function({enable:e,clickTolerance:s,aroundCenter:c=!0,minPixelCenterThreshold:d=100,rotateDegreesPerPixelMoved:p=.8},f){const m=new xo({checkCorrectEvent:e=>0===h.mouseButton(e)&&e.ctrlKey||2===h.mouseButton(e)&&!e.ctrlKey});return new mo({clickTolerance:s,move:(e,s)=>{const m=f();if(c&&Math.abs(m.y-e.y)>d)return{bearingDelta:l.cx(new l.P(e.x,s.y),s,m)};let _=(s.x-e.x)*p;return c&&s.y0===h.mouseButton(e)&&e.ctrlKey||2===h.mouseButton(e)});return new mo({clickTolerance:s,move:(e,s)=>({pitchDelta:(s.y-e.y)*l}),moveStateManager:c,enable:e,assignEvents:ks})}(e),P=function({enable:e,clickTolerance:s,rollDegreesPerPixelMoved:l=.3},c){const d=new xo({checkCorrectEvent:e=>2===h.mouseButton(e)&&e.ctrlKey});return new mo({clickTolerance:s,move:(e,s)=>{const d=c();let p=(s.x-e.x)*l;return s.y0===h.mouseButton(e)&&!e.ctrlKey});return new mo({clickTolerance:s,move:(e,s)=>({around:s,panDelta:s.sub(e)}),activateOnStart:!0,moveStateManager:l,enable:e,assignEvents:ks})}(e),I=new To(e,s);s.dragPan=new Zo(c,S,I),this._add("mousePan",S),this._add("touchPan",I,["touchZoom","touchRotate"]),e.interactive&&e.dragPan&&s.dragPan.enable(e.dragPan);const C=new So,z=new Mo;s.touchZoomRotate=new Uo(c,z,C,_),this._add("touchRotate",C,["touchPan","touchZoom"]),this._add("touchZoom",z,["touchPan","touchRotate"]),e.interactive&&e.touchZoomRotate&&s.touchZoomRotate.enable(e.touchZoomRotate),this._add("blockableMapEvent",new no(s));const L=s.scrollZoom=new Bo(s,(()=>this._triggerRenderFrame()));this._add("scrollZoom",L,["mousePan"]),e.interactive&&e.scrollZoom&&s.scrollZoom.enable(e.scrollZoom);const F=s.keyboard=new Ao(s);this._add("keyboard",F),e.interactive&&e.keyboard&&s.keyboard.enable()}_add(e,s,l){this._handlers.push({handlerName:e,handler:s,allowed:l}),this._handlersById[e]=s}stop(e){if(!this._updatingCamera){for(const{handler:e}of this._handlers)e.reset();this._inertia.clear(),this._fireEvents({},{},e),this._changes=[]}}isActive(){for(const{handler:e}of this._handlers)if(e.isActive())return!0;return!1}isZooming(){return!!this._eventsInProgress.zoom||this._map.scrollZoom.isZooming()}isRotating(){return!!this._eventsInProgress.rotate}isMoving(){return Boolean(Eo(this._eventsInProgress))||this.isZooming()}_blockedByActive(e,s,l){for(const c in e)if(c!==l&&(!s||s.indexOf(c)<0))return!0;return!1}_getMapTouches(e){const s=[];for(const l of e)this._el.contains(l.target)&&s.push(l);return s}mergeHandlerResult(e,s,c,d,p){if(!c)return;l.e(e,c);const f={handlerName:d,originalEvent:c.originalEvent||p};void 0!==c.zoomDelta&&(s.zoom=f),void 0!==c.panDelta&&(s.drag=f),void 0!==c.rollDelta&&(s.roll=f),void 0!==c.pitchDelta&&(s.pitch=f),void 0!==c.bearingDelta&&(s.rotate=f)}_applyChanges(){const e={},s={},c={};for(const[d,p,f]of this._changes)d.panDelta&&(e.panDelta=(e.panDelta||new l.P(0,0))._add(d.panDelta)),d.zoomDelta&&(e.zoomDelta=(e.zoomDelta||0)+d.zoomDelta),d.bearingDelta&&(e.bearingDelta=(e.bearingDelta||0)+d.bearingDelta),d.pitchDelta&&(e.pitchDelta=(e.pitchDelta||0)+d.pitchDelta),d.rollDelta&&(e.rollDelta=(e.rollDelta||0)+d.rollDelta),void 0!==d.around&&(e.around=d.around),void 0!==d.pinchAround&&(e.pinchAround=d.pinchAround),d.noInertia&&(e.noInertia=d.noInertia),l.e(s,p),l.e(c,f);this._updateMapTransform(e,s,c),this._changes=[]}_updateMapTransform(e,s,l){const c=this._map,d=c._getTransformForUpdate(),p=c.terrain;if(!(Co(e)||p&&this._terrainMovement))return this._fireEvents(s,l,!0);c._stop(!0);let{panDelta:f,zoomDelta:m,bearingDelta:_,pitchDelta:g,rollDelta:y,around:b,pinchAround:T}=e;void 0!==T&&(b=T),b=b||c.transform.centerPoint,p&&!d.isPointOnMapSurface(b)&&(b=d.centerPoint);const P={panDelta:f,zoomDelta:m,rollDelta:y,pitchDelta:g,bearingDelta:_,around:b};this._map.cameraHelper.useGlobeControls&&!d.isPointOnMapSurface(b)&&(b=d.centerPoint);const S=b.distSqr(d.centerPoint)<.01?d.center:d.screenPointToLocation(f?b.sub(f):b);this._handleMapControls({terrain:p,tr:d,deltasForHelper:P,preZoomAroundLoc:S,combinedEventsInProgress:s,panDelta:f}),c._applyUpdatedTransform(d),this._map._update(),e.noInertia||this._inertia.record(e),this._fireEvents(s,l,!0)}_handleMapControls({terrain:e,tr:s,deltasForHelper:l,preZoomAroundLoc:c,combinedEventsInProgress:d,panDelta:p}){const f=this._map.cameraHelper;if(f.handleMapControlsRollPitchBearingZoom(l,s),e)return f.useGlobeControls?(this._terrainMovement||!d.drag&&!d.zoom||(this._terrainMovement=!0,this._map._elevationFreeze=!0),void f.handleMapControlsPan(l,s,c)):this._terrainMovement||!d.drag&&!d.zoom?void(d.drag&&this._terrainMovement&&p?s.setCenter(s.screenPointToLocation(s.centerPoint.sub(p))):f.handleMapControlsPan(l,s,c)):(this._terrainMovement=!0,this._map._elevationFreeze=!0,void f.handleMapControlsPan(l,s,c));f.handleMapControlsPan(l,s,c)}_fireEvents(e,s,c){const d=Eo(this._eventsInProgress),p=Eo(e),f={};for(const s in e){const{originalEvent:l}=e[s];this._eventsInProgress[s]||(f[`${s}start`]=l),this._eventsInProgress[s]=e[s]}!d&&p&&this._fireEvent("movestart",p.originalEvent);for(const e in f)this._fireEvent(e,f[e]);p&&this._fireEvent("move",p.originalEvent);for(const s in e){const{originalEvent:l}=e[s];this._fireEvent(s,l)}const m={};let g;for(const e in this._eventsInProgress){const{handlerName:l,originalEvent:c}=this._eventsInProgress[e];this._handlersById[l].isActive()||(delete this._eventsInProgress[e],g=s[l]||c,m[`${e}end`]=g)}for(const e in m)this._fireEvent(e,m[e]);const y=Eo(this._eventsInProgress),b=(d||p)&&!y;if(b&&this._terrainMovement){this._map._elevationFreeze=!1,this._terrainMovement=!1;const e=this._map._getTransformForUpdate();this._map.getCenterClampedToGround()&&e.recalculateZoomAndCenter(this._map.terrain),this._map._applyUpdatedTransform(e)}if(c&&b){this._updatingCamera=!0;const e=this._inertia._onMoveEnd(this._map.dragPan._inertiaOptions),s=e=>0!==e&&-this._bearingSnap{delete this._frameId,this.handleEvent(new Wo("renderFrame",{timeStamp:e})),this._applyChanges()}))}_triggerRenderFrame(){void 0===this._frameId&&(this._frameId=this._requestFrame())}}class Xo extends l.E{constructor(e,s,l){super(),this._renderFrameCallback=()=>{const e=Math.min((y()-this._easeStart)/this._easeOptions.duration,1);this._onEaseFrame(this._easeOptions.easing(e)),e<1&&this._easeFrameId?this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback):this.stop()},this._moving=!1,this._zooming=!1,this.transform=e,this._bearingSnap=l.bearingSnap,this.cameraHelper=s,this.on("moveend",(()=>{delete this._requestedCameraState}))}migrateProjection(e,s){e.apply(this.transform),this.transform=e,this.cameraHelper=s}getCenter(){return new l.V(this.transform.center.lng,this.transform.center.lat)}setCenter(e,s){return this.jumpTo({center:e},s)}getCenterElevation(){return this.transform.elevation}setCenterElevation(e,s){return this.jumpTo({elevation:e},s),this}getCenterClampedToGround(){return this._centerClampedToGround}setCenterClampedToGround(e){this._centerClampedToGround=e}panBy(e,s,c){return e=l.P.convert(e).mult(-1),this.panTo(this.transform.center,l.e({offset:e},s),c)}panTo(e,s,c){return this.easeTo(l.e({center:e},s),c)}getZoom(){return this.transform.zoom}setZoom(e,s){return this.jumpTo({zoom:e},s),this}zoomTo(e,s,c){return this.easeTo(l.e({zoom:e},s),c)}zoomIn(e,s){return this.zoomTo(this.getZoom()+1,e,s),this}zoomOut(e,s){return this.zoomTo(this.getZoom()-1,e,s),this}getVerticalFieldOfView(){return this.transform.fov}setVerticalFieldOfView(e,s){return e!=this.transform.fov&&(this.transform.setFov(e),this.fire(new l.l("movestart",s)).fire(new l.l("move",s)).fire(new l.l("moveend",s))),this}getBearing(){return this.transform.bearing}setBearing(e,s){return this.jumpTo({bearing:e},s),this}getPadding(){return this.transform.padding}setPadding(e,s){return this.jumpTo({padding:e},s),this}rotateTo(e,s,c){return this.easeTo(l.e({bearing:e},s),c)}resetNorth(e,s){return this.rotateTo(0,l.e({duration:1e3},e),s),this}resetNorthPitch(e,s){return this.easeTo(l.e({bearing:0,pitch:0,roll:0,duration:1e3},e),s),this}snapToNorth(e,s){return Math.abs(this.getBearing()){C.easeFunc(l),this.terrain&&!e.freezeElevation&&this._updateElevation(l),this._applyUpdatedTransform(c),this._fireMoveEvents(s)}),(l=>{this.terrain&&e.freezeElevation&&this._finalizeElevation(),this._afterEase(s,l)}),e),this}_prepareEase(e,s,c={}){this._moving=!0,s||c.moving||this.fire(new l.l("movestart",e)),this._zooming&&!c.zooming&&this.fire(new l.l("zoomstart",e)),this._rotating&&!c.rotating&&this.fire(new l.l("rotatestart",e)),this._pitching&&!c.pitching&&this.fire(new l.l("pitchstart",e)),this._rolling&&!c.rolling&&this.fire(new l.l("rollstart",e))}_prepareElevation(e){this._elevationCenter=e,this._elevationStart=this.transform.elevation,this._elevationTarget=this.terrain.getElevationForLngLatZoom(e,this.transform.tileZoom),this._elevationFreeze=!0}_updateElevation(e){void 0!==this._elevationStart&&void 0!==this._elevationCenter||this._prepareElevation(this.transform.center),this.transform.setMinElevationForCurrentTile(this.terrain.getMinTileElevationForLngLatZoom(this._elevationCenter,this.transform.tileZoom));const s=this.terrain.getElevationForLngLatZoom(this._elevationCenter,this.transform.tileZoom);if(e<1&&s!==this._elevationTarget){const l=this._elevationTarget-this._elevationStart;this._elevationStart+=e*(l-(s-(l*e+this._elevationStart))/(1-e)),this._elevationTarget=s}this.transform.setElevation(l.G.number(this._elevationStart,this._elevationTarget,e))}_finalizeElevation(){this._elevationFreeze=!1,this.getCenterClampedToGround()&&this.transform.recalculateZoomAndCenter(this.terrain)}_getTransformForUpdate(){return this.transformCameraUpdate||this.terrain?(this._requestedCameraState||(this._requestedCameraState=this.transform.clone()),this._requestedCameraState):this.transform}_elevateCameraIfInsideTerrain(e){if(!this.terrain&&e.elevation>=0&&e.pitch<=90)return{};const s=e.getCameraLngLat(),l=e.getCameraAltitude(),c=this.terrain?this.terrain.getElevationForLngLatZoom(s,e.zoom):0;if(lthis._elevateCameraIfInsideTerrain(e))),this.transformCameraUpdate&&s.push((e=>this.transformCameraUpdate(e))),!s.length)return;const l=e.clone();for(const e of s){const s=l.clone(),{center:c,zoom:d,roll:p,pitch:f,bearing:m,elevation:_}=e(s);c&&s.setCenter(c),void 0!==_&&s.setElevation(_),void 0!==d&&s.setZoom(d),void 0!==p&&s.setRoll(p),void 0!==f&&s.setPitch(f),void 0!==m&&s.setBearing(m),l.apply(s)}this.transform.apply(l)}_fireMoveEvents(e){this.fire(new l.l("move",e)),this._zooming&&this.fire(new l.l("zoom",e)),this._rotating&&this.fire(new l.l("rotate",e)),this._pitching&&this.fire(new l.l("pitch",e)),this._rolling&&this.fire(new l.l("roll",e))}_afterEase(e,s){if(this._easeId&&s&&this._easeId===s)return;delete this._easeId;const c=this._zooming,d=this._rotating,p=this._pitching,f=this._rolling;this._moving=!1,this._zooming=!1,this._rotating=!1,this._pitching=!1,this._rolling=!1,this._padding=!1,c&&this.fire(new l.l("zoomend",e)),d&&this.fire(new l.l("rotateend",e)),p&&this.fire(new l.l("pitchend",e)),f&&this.fire(new l.l("rollend",e)),this.fire(new l.l("moveend",e))}flyTo(e,s){if(!e.essential&&_.prefersReducedMotion){const c=l.U(e,["center","zoom","bearing","pitch","roll","elevation","padding"]);return this.jumpTo(c,s)}this.stop(),e=l.e({offset:[0,0],speed:1.2,curve:1.42,easing:l.cy},e);const c=this._getTransformForUpdate(),d=c.bearing,p=c.pitch,f=c.roll,m=c.padding,g="bearing"in e?this._normalizeBearing(e.bearing,d):d,y="pitch"in e?+e.pitch:p,b="roll"in e?this._normalizeBearing(e.roll,f):f,T="padding"in e?e.padding:c.padding,P=l.P.convert(e.offset);let S=c.centerPoint.add(P);const I=c.screenPointToLocation(S),C=this.cameraHelper.handleFlyTo(c,{bearing:g,pitch:y,roll:b,padding:T,locationAtOffset:I,offsetAsPoint:P,center:e.center,minZoom:e.minZoom,zoom:e.zoom});let z=e.curve;const L=Math.max(c.width,c.height),F=L/C.scaleOfZoom,B=C.pixelPathLength;"number"==typeof C.scaleOfMinZoom&&(z=Math.sqrt(L/C.scaleOfMinZoom/B*2));const O=z*z;function j(e){const s=(F*F-L*L+(e?-1:1)*O*O*B*B)/(2*(e?F:L)*O*B);return Math.log(Math.sqrt(s*s+1)-s)}function G(e){return(Math.exp(e)-Math.exp(-e))/2}function U(e){return(Math.exp(e)+Math.exp(-e))/2}const q=j(!1);let Z=function(e){return U(q)/U(q+z*e)},W=function(e){return L*((U(q)*(G(s=q+z*e)/U(s))-G(q))/O)/B;var s},J=(j(!0)-q)/z;if(Math.abs(B)<2e-6||!isFinite(J)){if(Math.abs(L-F)<1e-6)return this.easeTo(e,s);const l=F0,Z=e=>Math.exp(l*z*e)}return e.duration="duration"in e?+e.duration:1e3*J/("screenSpeed"in e?+e.screenSpeed/z:+e.speed),e.maxDuration&&e.duration>e.maxDuration&&(e.duration=0),this._zooming=!0,this._rotating=d!==g,this._pitching=y!==p,this._rolling=b!==f,this._padding=!c.isPaddingEqual(T),this._prepareEase(s,!1),this.terrain&&this._prepareElevation(C.targetCenter),this._ease((_=>{const I=_*J,z=1/Z(I),L=W(I);this._rotating&&c.setBearing(l.G.number(d,g,_)),this._pitching&&c.setPitch(l.G.number(p,y,_)),this._rolling&&c.setRoll(l.G.number(f,b,_)),this._padding&&(c.interpolatePadding(m,T,_),S=c.centerPoint.add(P)),C.easeFunc(_,z,L,S),this.terrain&&!e.freezeElevation&&this._updateElevation(_),this._applyUpdatedTransform(c),this._fireMoveEvents(s)}),(()=>{this.terrain&&e.freezeElevation&&this._finalizeElevation(),this._afterEase(s)}),e),this}isEasing(){return!!this._easeFrameId}stop(){return this._stop()}_stop(e,s){var l;if(this._easeFrameId&&(this._cancelRenderFrame(this._easeFrameId),delete this._easeFrameId,delete this._onEaseFrame),this._onEaseEnd){const e=this._onEaseEnd;delete this._onEaseEnd,e.call(this,s)}return e||null===(l=this.handlers)||void 0===l||l.stop(!1),this}_ease(e,s,l){!1===l.animate||0===l.duration?(e(1),s()):(this._easeStart=y(),this._easeOptions=l,this._onEaseFrame=e,this._onEaseEnd=s,this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback))}_normalizeBearing(e,s){e=l.W(e,-180,180);const c=Math.abs(e-s);return Math.abs(e-360-s)MapLibre'};class Yo{constructor(e=ko){this._toggleAttribution=()=>{this._container.classList.contains("maplibregl-compact")&&(this._container.classList.contains("maplibregl-compact-show")?(this._container.setAttribute("open",""),this._container.classList.remove("maplibregl-compact-show")):(this._container.classList.add("maplibregl-compact-show"),this._container.removeAttribute("open")))},this._updateData=e=>{!e||"metadata"!==e.sourceDataType&&"visibility"!==e.sourceDataType&&"style"!==e.dataType&&"terrain"!==e.type||this._updateAttributions()},this._updateCompact=()=>{this._map.getCanvasContainer().offsetWidth<=640||this._compact?!1===this._compact?this._container.setAttribute("open",""):this._container.classList.contains("maplibregl-compact")||this._container.classList.contains("maplibregl-attrib-empty")||(this._container.setAttribute("open",""),this._container.classList.add("maplibregl-compact","maplibregl-compact-show")):(this._container.setAttribute("open",""),this._container.classList.contains("maplibregl-compact")&&this._container.classList.remove("maplibregl-compact","maplibregl-compact-show"))},this._updateCompactMinimize=()=>{this._container.classList.contains("maplibregl-compact")&&this._container.classList.contains("maplibregl-compact-show")&&this._container.classList.remove("maplibregl-compact-show")},this.options=e}getDefaultPosition(){return"bottom-right"}onAdd(e){return this._map=e,this._compact=this.options.compact,this._container=h.create("details","maplibregl-ctrl maplibregl-ctrl-attrib"),this._compactButton=h.create("summary","maplibregl-ctrl-attrib-button",this._container),this._compactButton.addEventListener("click",this._toggleAttribution),this._setElementTitle(this._compactButton,"ToggleAttribution"),this._innerContainer=h.create("div","maplibregl-ctrl-attrib-inner",this._container),this._updateAttributions(),this._updateCompact(),this._map.on("styledata",this._updateData),this._map.on("sourcedata",this._updateData),this._map.on("terrain",this._updateData),this._map.on("resize",this._updateCompact),this._map.on("drag",this._updateCompactMinimize),this._container}onRemove(){h.remove(this._container),this._map.off("styledata",this._updateData),this._map.off("sourcedata",this._updateData),this._map.off("terrain",this._updateData),this._map.off("resize",this._updateCompact),this._map.off("drag",this._updateCompactMinimize),this._map=void 0,this._compact=void 0,this._attribHTML=void 0}_setElementTitle(e,s){const l=this._map._getUIString(`AttributionControl.${s}`);e.title=l,e.setAttribute("aria-label",l)}_updateAttributions(){if(!this._map.style)return;let e=[];if(this.options.customAttribution&&(Array.isArray(this.options.customAttribution)?e=e.concat(this.options.customAttribution.map((e=>"string"!=typeof e?"":e))):"string"==typeof this.options.customAttribution&&e.push(this.options.customAttribution)),this._map.style.stylesheet){const e=this._map.style.stylesheet;this.styleOwner=e.owner,this.styleId=e.id}const s=this._map.style.tileManagers;for(const l in s){const c=s[l];if(c.used||c.usedForTerrain){const s=c.getSource();s.attribution&&e.indexOf(s.attribution)<0&&e.push(s.attribution)}}e=e.filter((e=>String(e).trim())),e.sort(((e,s)=>e.length-s.length)),e=e.filter(((s,l)=>{for(let c=l+1;c=0)return!1;return!0}));const l=e.join(" | ");l!==this._attribHTML&&(this._attribHTML=l,e.length?(this._innerContainer.innerHTML=h.sanitize(l),this._container.classList.remove("maplibregl-attrib-empty")):this._container.classList.add("maplibregl-attrib-empty"),this._updateCompact(),this._editLink=null)}}class Qo{constructor(e={}){this._updateCompact=()=>{const e=this._container.children;if(e.length){const s=e[0];this._map.getCanvasContainer().offsetWidth<=640||this._compact?!1!==this._compact&&s.classList.add("maplibregl-compact"):s.classList.remove("maplibregl-compact")}},this.options=e}getDefaultPosition(){return"bottom-left"}onAdd(e){this._map=e,this._compact=this.options&&this.options.compact,this._container=h.create("div","maplibregl-ctrl");const s=h.create("a","maplibregl-ctrl-logo");return s.target="_blank",s.rel="noopener nofollow",s.href="https://maplibre.org/",s.setAttribute("aria-label",this._map._getUIString("LogoControl.Title")),s.setAttribute("rel","noopener nofollow"),this._container.appendChild(s),this._container.style.display="block",this._map.on("resize",this._updateCompact),this._updateCompact(),this._container}onRemove(){h.remove(this._container),this._map.off("resize",this._updateCompact),this._map=void 0,this._compact=void 0}}class Jo{constructor(){this._queue=[],this._id=0,this._cleared=!1,this._currentlyRunning=!1}add(e){const s=++this._id;return this._queue.push({callback:e,id:s,cancelled:!1}),s}remove(e){const s=this._currentlyRunning,l=s?this._queue.concat(s):this._queue;for(const s of l)if(s.id===e)return void(s.cancelled=!0)}run(e=0){if(this._currentlyRunning)throw new Error("Attempting to run(), but is already running.");const s=this._currentlyRunning=this._queue;this._queue=[];for(const l of s)if(!l.cancelled&&(l.callback(e),this._cleared))break;this._cleared=!1,this._currentlyRunning=!1}clear(){this._currentlyRunning&&(this._cleared=!0),this._queue=[]}}var Ro=l.aU([{name:"a_pos3d",type:"Int16",components:3}]);class ts extends l.E{constructor(e){super(),this._lastTilesetChange=y(),this.tileManager=e,this._tiles={},this._renderableTilesKeys=[],this._sourceTileCache={},this.minzoom=0,this.maxzoom=22,this.deltaZoom=1,this.tileSize=e._source.tileSize*2**this.deltaZoom,e.usedForTerrain=!0,e.tileSize=this.tileSize}destruct(){this.tileManager.usedForTerrain=!1,this.tileManager.tileSize=null}getSource(){return this.tileManager._source}update(e,s){this.tileManager.update(e,s),this._renderableTilesKeys=[];const c={};for(const d of it(e,{tileSize:this.tileSize,minzoom:this.minzoom,maxzoom:this.maxzoom,reparseOverscaled:!1,terrain:s,calculateTileZoom:this.tileManager._source.calculateTileZoom}))c[d.key]=!0,this._renderableTilesKeys.push(d.key),this._tiles[d.key]||(d.terrainRttPosMatrix32f=new Float64Array(16),l.c7(d.terrainRttPosMatrix32f,0,l.a5,l.a5,0,0,1),this._tiles[d.key]=new de(d,this.tileSize),this._lastTilesetChange=y());for(const e in this._tiles)c[e]||delete this._tiles[e]}freeRtt(e){for(const s in this._tiles){const l=this._tiles[s];(!e||l.tileID.equals(e)||l.tileID.isChildOf(e)||e.isChildOf(l.tileID))&&(l.rtt=[])}}getRenderableTiles(){return this._renderableTilesKeys.map((e=>this.getTileByID(e)))}getTileByID(e){return this._tiles[e]}getTerrainCoords(e,s){return s?this._getTerrainCoordsForTileRanges(e,s):this._getTerrainCoordsForRegularTile(e)}_getTerrainCoordsForRegularTile(e){const s={};for(const c of this._renderableTilesKeys){const d=this._tiles[c].tileID,p=e.clone(),f=l.bk();if(d.canonical.equals(e.canonical))l.c7(f,0,l.a5,l.a5,0,0,1);else if(d.canonical.isChildOf(e.canonical)){const s=d.canonical.z-e.canonical.z,c=d.canonical.x-(d.canonical.x>>s<>s<>s;l.c7(f,0,m,m,0,0,1),l.O(f,f,[-c*m,-p*m,0])}else{if(!e.canonical.isChildOf(d.canonical))continue;{const s=e.canonical.z-d.canonical.z,c=e.canonical.x-(e.canonical.x>>s<>s<>s;l.c7(f,0,l.a5,l.a5,0,0,1),l.O(f,f,[c*m,p*m,0]),l.Q(f,f,[1/2**s,1/2**s,0])}}p.terrainRttPosMatrix32f=new Float32Array(f),s[c]=p}return s}_getTerrainCoordsForTileRanges(e,s){const c={};for(const d of this._renderableTilesKeys){const p=this._tiles[d].tileID;if(!this._isWithinTileRanges(p,s))continue;const f=e.clone(),m=l.bk();if(p.canonical.z===e.canonical.z){const s=e.canonical.x-p.canonical.x,c=e.canonical.y-p.canonical.y;l.c7(m,0,l.a5,l.a5,0,0,1),l.O(m,m,[s*l.a5,c*l.a5,0])}else if(p.canonical.z>e.canonical.z){const s=p.canonical.z-e.canonical.z,c=p.canonical.x-(p.canonical.x>>s<>s<>s),_=e.canonical.y-(p.canonical.y>>s),g=l.a5>>s;l.c7(m,0,g,g,0,0,1),l.O(m,m,[-c*g+f*l.a5,-d*g+_*l.a5,0])}else{const s=e.canonical.z-p.canonical.z,c=e.canonical.x-(e.canonical.x>>s<>s<>s)-p.canonical.x,_=(e.canonical.y>>s)-p.canonical.y,g=l.a5<l.maxzoom&&(c=l.maxzoom),c=l.minzoom&&!(null==d?void 0:d.dem);)d=this.findTileInCaches(e.scaledTo(c--).key);return d}findTileInCaches(e){let s=this.tileManager.getTileByID(e);return s||(s=this.tileManager._outOfViewCache.getByKey(e),s)}anyTilesAfterTime(e=Date.now()){return this._lastTilesetChange>=e}_isWithinTileRanges(e,s){return s[e.canonical.z]&&e.canonical.x>=s[e.canonical.z].minTileX&&e.canonical.x<=s[e.canonical.z].maxTileX&&e.canonical.y>=s[e.canonical.z].minTileY&&e.canonical.y<=s[e.canonical.z].maxTileY}}class is{constructor(e,s,l){this._meshCache={},this.painter=e,this.tileManager=new ts(s),this.options=l,this.exaggeration="number"==typeof l.exaggeration?l.exaggeration:1,this.qualityFactor=2,this.meshSize=128,this._demMatrixCache={},this.coordsIndex=[],this._coordsTextureSize=1024}getDEMElevation(e,s,c,d=l.a5){var p;if(!(s>=0&&s=0&&cc&&(c=Math.min(e.canonical.z,this.tileManager.maxzoom));return this.getElevationForLngLatZoom(e,c)}getElevation(e,s,c,d=l.a5){return this.getDEMElevation(e,s,c,d)*this.exaggeration}getTerrainData(e){if(!this._emptyDemTexture){const e=this.painter.context,s=new l.R({width:1,height:1},new Uint8Array(4));this._emptyDepthTexture=new l.T(e,s,e.gl.RGBA,{premultiply:!1}),this._emptyDemUnpack=[0,0,0,0],this._emptyDemTexture=new l.T(e,new l.R({width:1,height:1}),e.gl.RGBA,{premultiply:!1}),this._emptyDemTexture.bind(e.gl.NEAREST,e.gl.CLAMP_TO_EDGE),this._emptyDemMatrix=l.ar([])}const s=this.tileManager.getSourceTile(e,!0);if(s&&s.dem&&(!s.demTexture||s.needsTerrainPrepare)){const e=this.painter.context;s.demTexture=this.painter.getTileTexture(s.dem.stride),s.demTexture?s.demTexture.update(s.dem.getPixels(),{premultiply:!1}):s.demTexture=new l.T(e,s.dem.getPixels(),e.gl.RGBA,{premultiply:!1}),s.demTexture.bind(e.gl.NEAREST,e.gl.CLAMP_TO_EDGE),s.needsTerrainPrepare=!1}const c=s&&s.toString()+s.tileID.key+e.key;if(c&&!this._demMatrixCache[c]){const c=this.tileManager.getSource().maxzoom;let d=e.canonical.z-s.tileID.canonical.z;e.overscaledZ>e.canonical.z&&(e.canonical.z>=c?d=e.canonical.z-c:l.w("cannot calculate elevation if elevation maxzoom > source.maxzoom"));const p=e.canonical.x-(e.canonical.x>>d<>d<>8<<4|e>>8,s[l+3]=0;const c=new l.R({width:this._coordsTextureSize,height:this._coordsTextureSize},new Uint8Array(s.buffer)),d=new l.T(e,c,e.gl.RGBA,{premultiply:!1});return d.bind(e.gl.NEAREST,e.gl.CLAMP_TO_EDGE),this._coordsTexture=d,d}pointCoordinate(e){this.painter.maybeDrawDepthAndCoords(!0);const s=new Uint8Array(4),c=this.painter.context,d=c.gl,p=Math.round(e.x*this.painter.pixelRatio/devicePixelRatio),f=Math.round(e.y*this.painter.pixelRatio/devicePixelRatio),m=Math.round(this.painter.height/devicePixelRatio);c.bindFramebuffer.set(this.getFramebuffer("coords").framebuffer),d.readPixels(p,m-f-1,1,1,d.RGBA,d.UNSIGNED_BYTE,s),c.bindFramebuffer.set(null);const _=s[0]+(s[2]>>4<<8),g=s[1]+((15&s[2])<<8),y=this.coordsIndex[255-s[3]],b=y&&this.tileManager.getTileByID(y);if(!b)return null;const T=this._coordsTextureSize,P=(1<0,d=c&&0===e.canonical.y,p=c&&e.canonical.y===(1<e.id!==s)),this._recentlyUsed.push(e.id)}stampObject(e){e.stamp=++this._stamp}getOrCreateFreeObject(){for(const e of this._recentlyUsed)if(!this._objects[e].inUse)return this._objects[e];if(this._objects.length>=this._size)throw new Error("No free RenderPool available, call freeAllObjects() required!");const e=this._createObject(this._objects.length);return this._objects.push(e),e}freeObject(e){e.inUse=!1}freeAllObjects(){for(const e of this._objects)this.freeObject(e)}isFull(){return!(this._objects.length!e.inUse))}}const Lo={background:!0,fill:!0,line:!0,raster:!0,hillshade:!0,"color-relief":!0};class os{constructor(e,s){this.painter=e,this.terrain=s,this.pool=new as(e.context,30,s.tileManager.tileSize*s.qualityFactor)}destruct(){this.pool.destruct()}getTexture(e){return this.pool.getObjectForId(e.rtt[this._stacks.length-1].id).texture}prepareForRender(e,s){this._stacks=[],this._prevType=null,this._rttTiles=[],this._renderableTiles=this.terrain.tileManager.getRenderableTiles(),this._renderableLayerIds=e._order.filter((l=>!e._layers[l].isHidden(s))),this._coordsAscending={};for(const s in e.tileManagers){this._coordsAscending[s]={};const l=e.tileManagers[s].getVisibleCoordinates(),c=e.tileManagers[s].getSource(),d=c instanceof te?c.terrainTileRanges:null;for(const e of l){const l=this.terrain.tileManager.getTerrainCoords(e,d);for(const e in l)this._coordsAscending[s][e]||(this._coordsAscending[s][e]=[]),this._coordsAscending[s][e].push(l[e])}}this._coordsAscendingStr={};for(const s of e._order){const l=e._layers[s],c=l.source;if(Lo[l.type]&&!this._coordsAscendingStr[c]){this._coordsAscendingStr[c]={};for(const e in this._coordsAscending[c])this._coordsAscendingStr[c][e]=this._coordsAscending[c][e].map((e=>e.key)).sort().join()}}for(const e of this._renderableTiles)for(const s in this._coordsAscendingStr){const l=this._coordsAscendingStr[s][e.tileID.key];l&&l!==e.rttCoords[s]&&(e.rtt=[])}}renderLayer(e,s){if(e.isHidden(this.painter.transform.zoom))return!1;const c=Object.assign(Object.assign({},s),{isRenderingToTexture:!0}),d=e.type,p=this.painter,f=this._renderableLayerIds[this._renderableLayerIds.length-1]===e.id;if(Lo[d]&&(this._prevType&&Lo[this._prevType]||this._stacks.push([]),this._prevType=d,this._stacks[this._stacks.length-1].push(e.id),!f))return!0;if(Lo[this._prevType]||Lo[d]&&f){this._prevType=d;const e=this._stacks.length-1,s=this._stacks[e]||[];for(const d of this._renderableTiles){if(this.pool.isFull()&&(fs(this.painter,this.terrain,this._rttTiles,c),this._rttTiles=[],this.pool.freeAllObjects()),this._rttTiles.push(d),d.rtt[e]){const s=this.pool.getObjectForId(d.rtt[e].id);if(s.stamp===d.rtt[e].stamp){this.pool.useObject(s);continue}}const f=this.pool.getOrCreateFreeObject();this.pool.useObject(f),this.pool.stampObject(f),d.rtt[e]={id:f.id,stamp:f.stamp},p.context.bindFramebuffer.set(f.fbo.framebuffer),p.context.clear({color:l.bp.transparent,stencil:0}),p.currentStencilSource=void 0;for(let e=0;e{this.startMove(e,h.mousePos(this.element,e)),h.addEventListener(window,"mousemove",this.mousemove),h.addEventListener(window,"mouseup",this.mouseup)},this.mousemove=e=>{this.move(e,h.mousePos(this.element,e))},this.mouseup=e=>{this._rotatePitchHandler.dragEnd(e),this.offTemp()},this.touchstart=e=>{1!==e.targetTouches.length?this.reset():(this._startPos=this._lastPos=h.touchPos(this.element,e.targetTouches)[0],this.startMove(e,this._startPos),h.addEventListener(window,"touchmove",this.touchmove,{passive:!1}),h.addEventListener(window,"touchend",this.touchend))},this.touchmove=e=>{1!==e.targetTouches.length?this.reset():(this._lastPos=h.touchPos(this.element,e.targetTouches)[0],this.move(e,this._lastPos))},this.touchend=e=>{0===e.targetTouches.length&&this._startPos&&this._lastPos&&this._startPos.dist(this._lastPos){this._rotatePitchHandler.reset(),delete this._startPos,delete this._lastPos,this.offTemp()},this._clickTolerance=10,this.element=s;const d=new yo;this._rotatePitchHandler=new mo({clickTolerance:3,move:(e,d)=>{const p=s.getBoundingClientRect(),f=new l.P((p.bottom-p.top)/2,(p.right-p.left)/2);return{bearingDelta:l.cx(new l.P(e.x,d.y),d,f),pitchDelta:c?-.5*(d.y-e.y):void 0}},moveStateManager:d,enable:!0,assignEvents:()=>{}}),this.map=e,h.addEventListener(s,"mousedown",this.mousedown),h.addEventListener(s,"touchstart",this.touchstart,{passive:!1}),h.addEventListener(s,"touchcancel",this.reset)}startMove(e,s){this._rotatePitchHandler.dragStart(e,s),h.disableDrag()}move(e,s){const l=this.map,{bearingDelta:c,pitchDelta:d}=this._rotatePitchHandler.dragMove(e,s)||{};c&&l.setBearing(l.getBearing()+c),d&&l.setPitch(l.getPitch()+d)}off(){const e=this.element;h.removeEventListener(e,"mousedown",this.mousedown),h.removeEventListener(e,"touchstart",this.touchstart,{passive:!1}),h.removeEventListener(window,"touchmove",this.touchmove,{passive:!1}),h.removeEventListener(window,"touchend",this.touchend),h.removeEventListener(e,"touchcancel",this.reset),this.offTemp()}offTemp(){h.enableDrag(),h.removeEventListener(window,"mousemove",this.mousemove),h.removeEventListener(window,"mouseup",this.mouseup),h.removeEventListener(window,"touchmove",this.touchmove,{passive:!1}),h.removeEventListener(window,"touchend",this.touchend)}}let ia;function na(e,s,c,d=!1){if(d||!c.getCoveringTilesDetailsProvider().allowWorldCopies())return null==e?void 0:e.wrap();const p=new l.V(e.lng,e.lat);if(e=new l.V(e.lng,e.lat),s){const d=new l.V(e.lng-360,e.lat),p=new l.V(e.lng+360,e.lat),f=c.locationToScreenPoint(e).distSqr(s);c.locationToScreenPoint(d).distSqr(s)180;){const s=c.locationToScreenPoint(e);if(s.x>=0&&s.y>=0&&s.x<=c.width&&s.y<=c.height)break;e.lng>c.center.lng?e.lng-=360:e.lng+=360}return e.lng!==p.lng&&c.isPointOnMapSurface(c.locationToScreenPoint(e))?e:p}const el={center:"translate(-50%,-50%)",top:"translate(-50%,0)","top-left":"translate(0,0)","top-right":"translate(-100%,0)",bottom:"translate(-50%,-100%)","bottom-left":"translate(0,-100%)","bottom-right":"translate(-100%,-100%)",left:"translate(0,-50%)",right:"translate(-100%,-50%)"};function tl(e,s,l){const c=e.classList;for(const e in el)c.remove(`maplibregl-${l}-anchor-${e}`);c.add(`maplibregl-${l}-anchor-${s}`)}class ms extends l.E{constructor(e){if(super(),this._onKeyPress=e=>{const s=e.code,l=e.charCode||e.keyCode;"Space"!==s&&"Enter"!==s&&32!==l&&13!==l||this.togglePopup()},this._onMapClick=e=>{const s=e.originalEvent.target,l=this._element;this._popup&&(s===l||l.contains(s))&&this.togglePopup()},this._update=e=>{if(!this._map)return;const s=this._map.loaded()&&!this._map.isMoving();("terrain"===(null==e?void 0:e.type)||"render"===(null==e?void 0:e.type)&&!s)&&this._map.once("render",this._update),this._lngLat=na(this._lngLat,this._flatPos,this._map.transform),this._flatPos=this._pos=this._map.project(this._lngLat)._add(this._offset),this._map.terrain&&(this._flatPos=this._map.transform.locationToScreenPoint(this._lngLat)._add(this._offset));let l="";"viewport"===this._rotationAlignment||"auto"===this._rotationAlignment?l=`rotateZ(${this._rotation}deg)`:"map"===this._rotationAlignment&&(l=`rotateZ(${this._rotation-this._map.getBearing()}deg)`);let c="";"viewport"===this._pitchAlignment||"auto"===this._pitchAlignment?c="rotateX(0deg)":"map"===this._pitchAlignment&&(c=`rotateX(${this._map.getPitch()}deg)`),this._subpixelPositioning||e&&"moveend"!==e.type||(this._pos=this._pos.round()),h.setTransform(this._element,`${el[this._anchor]} translate(${this._pos.x}px, ${this._pos.y}px) ${c} ${l}`),_.frameAsync(new AbortController).then((()=>{this._updateOpacity(e&&"moveend"===e.type)})).catch((()=>{}))},this._onMove=e=>{if(!this._isDragging){const s=this._clickTolerance||this._map._clickTolerance;this._isDragging=e.point.dist(this._pointerdownPos)>=s}this._isDragging&&(this._pos=e.point.sub(this._positionDelta),this._lngLat=this._map.unproject(this._pos),this.setLngLat(this._lngLat),this._element.style.pointerEvents="none","pending"===this._state&&(this._state="active",this.fire(new l.l("dragstart"))),this.fire(new l.l("drag")))},this._onUp=()=>{this._element.style.pointerEvents="auto",this._positionDelta=null,this._pointerdownPos=null,this._isDragging=!1,this._map.off("mousemove",this._onMove),this._map.off("touchmove",this._onMove),"active"===this._state&&this.fire(new l.l("dragend")),this._state="inactive"},this._addDragHandler=e=>{this._element.contains(e.originalEvent.target)&&(e.preventDefault(),this._positionDelta=e.point.sub(this._pos).add(this._offset),this._pointerdownPos=e.point,this._state="pending",this._map.on("mousemove",this._onMove),this._map.on("touchmove",this._onMove),this._map.once("mouseup",this._onUp),this._map.once("touchend",this._onUp))},this._anchor=e&&e.anchor||"center",this._color=e&&e.color||"#3FB1CE",this._scale=e&&e.scale||1,this._draggable=e&&e.draggable||!1,this._clickTolerance=e&&e.clickTolerance||0,this._subpixelPositioning=e&&e.subpixelPositioning||!1,this._isDragging=!1,this._state="inactive",this._rotation=e&&e.rotation||0,this._rotationAlignment=e&&e.rotationAlignment||"auto",this._pitchAlignment=e&&e.pitchAlignment&&"auto"!==e.pitchAlignment?e.pitchAlignment:this._rotationAlignment,this.setOpacity(null==e?void 0:e.opacity,null==e?void 0:e.opacityWhenCovered),e&&e.element)this._element=e.element,this._offset=l.P.convert(e&&e.offset||[0,0]);else{this._defaultMarker=!0,this._element=h.create("div");const s=h.createNS("http://www.w3.org/2000/svg","svg"),c=41,d=27;s.setAttributeNS(null,"display","block"),s.setAttributeNS(null,"height",`${c}px`),s.setAttributeNS(null,"width",`${d}px`),s.setAttributeNS(null,"viewBox",`0 0 ${d} ${c}`);const p=h.createNS("http://www.w3.org/2000/svg","g");p.setAttributeNS(null,"stroke","none"),p.setAttributeNS(null,"stroke-width","1"),p.setAttributeNS(null,"fill","none"),p.setAttributeNS(null,"fill-rule","evenodd");const f=h.createNS("http://www.w3.org/2000/svg","g");f.setAttributeNS(null,"fill-rule","nonzero");const m=h.createNS("http://www.w3.org/2000/svg","g");m.setAttributeNS(null,"transform","translate(3.0, 29.0)"),m.setAttributeNS(null,"fill","#000000");const _=[{rx:"10.5",ry:"5.25002273"},{rx:"10.5",ry:"5.25002273"},{rx:"9.5",ry:"4.77275007"},{rx:"8.5",ry:"4.29549936"},{rx:"7.5",ry:"3.81822308"},{rx:"6.5",ry:"3.34094679"},{rx:"5.5",ry:"2.86367051"},{rx:"4.5",ry:"2.38636864"}];for(const e of _){const s=h.createNS("http://www.w3.org/2000/svg","ellipse");s.setAttributeNS(null,"opacity","0.04"),s.setAttributeNS(null,"cx","10.5"),s.setAttributeNS(null,"cy","5.80029008"),s.setAttributeNS(null,"rx",e.rx),s.setAttributeNS(null,"ry",e.ry),m.appendChild(s)}const g=h.createNS("http://www.w3.org/2000/svg","g");g.setAttributeNS(null,"fill",this._color);const y=h.createNS("http://www.w3.org/2000/svg","path");y.setAttributeNS(null,"d","M27,13.5 C27,19.074644 20.250001,27.000002 14.75,34.500002 C14.016665,35.500004 12.983335,35.500004 12.25,34.500002 C6.7499993,27.000002 0,19.222562 0,13.5 C0,6.0441559 6.0441559,0 13.5,0 C20.955844,0 27,6.0441559 27,13.5 Z"),g.appendChild(y);const b=h.createNS("http://www.w3.org/2000/svg","g");b.setAttributeNS(null,"opacity","0.25"),b.setAttributeNS(null,"fill","#000000");const T=h.createNS("http://www.w3.org/2000/svg","path");T.setAttributeNS(null,"d","M13.5,0 C6.0441559,0 0,6.0441559 0,13.5 C0,19.222562 6.7499993,27 12.25,34.5 C13,35.522727 14.016664,35.500004 14.75,34.5 C20.250001,27 27,19.074644 27,13.5 C27,6.0441559 20.955844,0 13.5,0 Z M13.5,1 C20.415404,1 26,6.584596 26,13.5 C26,15.898657 24.495584,19.181431 22.220703,22.738281 C19.945823,26.295132 16.705119,30.142167 13.943359,33.908203 C13.743445,34.180814 13.612715,34.322738 13.5,34.441406 C13.387285,34.322738 13.256555,34.180814 13.056641,33.908203 C10.284481,30.127985 7.4148684,26.314159 5.015625,22.773438 C2.6163816,19.232715 1,15.953538 1,13.5 C1,6.584596 6.584596,1 13.5,1 Z"),b.appendChild(T);const P=h.createNS("http://www.w3.org/2000/svg","g");P.setAttributeNS(null,"transform","translate(6.0, 7.0)"),P.setAttributeNS(null,"fill","#FFFFFF");const S=h.createNS("http://www.w3.org/2000/svg","g");S.setAttributeNS(null,"transform","translate(8.0, 8.0)");const I=h.createNS("http://www.w3.org/2000/svg","circle");I.setAttributeNS(null,"fill","#000000"),I.setAttributeNS(null,"opacity","0.25"),I.setAttributeNS(null,"cx","5.5"),I.setAttributeNS(null,"cy","5.5"),I.setAttributeNS(null,"r","5.4999962");const C=h.createNS("http://www.w3.org/2000/svg","circle");C.setAttributeNS(null,"fill","#FFFFFF"),C.setAttributeNS(null,"cx","5.5"),C.setAttributeNS(null,"cy","5.5"),C.setAttributeNS(null,"r","5.4999962"),S.appendChild(I),S.appendChild(C),f.appendChild(m),f.appendChild(g),f.appendChild(b),f.appendChild(P),f.appendChild(S),s.appendChild(f),s.setAttributeNS(null,"height",c*this._scale+"px"),s.setAttributeNS(null,"width",d*this._scale+"px"),this._element.appendChild(s),this._offset=l.P.convert(e&&e.offset||[0,-14])}if(this._element.classList.add("maplibregl-marker"),this._element.addEventListener("dragstart",(e=>{e.preventDefault()})),this._element.addEventListener("mousedown",(e=>{e.preventDefault()})),tl(this._element,this._anchor,"marker"),e&&e.className)for(const s of e.className.split(" "))this._element.classList.add(s);this._popup=null}addTo(e){return this.remove(),this._map=e,this._element.hasAttribute("aria-label")||this._element.setAttribute("aria-label",e._getUIString("Marker.Title")),this._element.hasAttribute("role")||this._element.setAttribute("role","button"),e.getCanvasContainer().appendChild(this._element),e.on("move",this._update),e.on("moveend",this._update),e.on("terrain",this._update),e.on("projectiontransition",this._update),this.setDraggable(this._draggable),this._update(),this._map.on("click",this._onMapClick),this}remove(){return this._opacityTimeout&&(clearTimeout(this._opacityTimeout),delete this._opacityTimeout),this._map&&(this._map.off("click",this._onMapClick),this._map.off("move",this._update),this._map.off("moveend",this._update),this._map.off("terrain",this._update),this._map.off("projectiontransition",this._update),this._map.off("mousedown",this._addDragHandler),this._map.off("touchstart",this._addDragHandler),this._map.off("mouseup",this._onUp),this._map.off("touchend",this._onUp),this._map.off("mousemove",this._onMove),this._map.off("touchmove",this._onMove),delete this._map),h.remove(this._element),this._popup&&this._popup.remove(),this}getLngLat(){return this._lngLat}setLngLat(e){return this._lngLat=l.V.convert(e),this._pos=null,this._popup&&this._popup.setLngLat(this._lngLat),this._update(),this}getElement(){return this._element}setPopup(e){if(this._popup&&(this._popup.remove(),this._popup=null,this._element.removeEventListener("keypress",this._onKeyPress),this._originalTabIndex||this._element.removeAttribute("tabindex")),e){if(!("offset"in e.options)){const s=38.1,l=13.5,c=Math.abs(l)/Math.SQRT2;e.options.offset=this._defaultMarker?{top:[0,0],"top-left":[0,0],"top-right":[0,0],bottom:[0,-s],"bottom-left":[c,-1*(s-l+c)],"bottom-right":[-c,-1*(s-l+c)],left:[l,-1*(s-l)],right:[-l,-1*(s-l)]}:this._offset}this._popup=e,this._originalTabIndex=this._element.getAttribute("tabindex"),this._originalTabIndex||this._element.setAttribute("tabindex","0"),this._element.addEventListener("keypress",this._onKeyPress)}return this}setSubpixelPositioning(e){return this._subpixelPositioning=e,this}getPopup(){return this._popup}togglePopup(){const e=this._popup;return this._element.style.opacity===this._opacityWhenCovered?this:e?(e.isOpen()?e.remove():(e.setLngLat(this._lngLat),e.addTo(this._map)),this):this}_updateOpacity(e=!1){var s,c;const d=null===(s=this._map)||void 0===s?void 0:s.terrain,p=this._map.transform.isLocationOccluded(this._lngLat);if(!d||p){const e=p?this._opacityWhenCovered:this._opacity;return void(this._element.style.opacity!==e&&(this._element.style.opacity=e))}if(e)this._opacityTimeout=null;else{if(this._opacityTimeout)return;this._opacityTimeout=setTimeout((()=>{this._opacityTimeout=null}),100)}const f=this._map,m=f.terrain.depthAtPoint(this._pos),_=f.terrain.getElevationForLngLat(this._lngLat,f.transform);if(f.transform.lngLatToCameraDepth(this._lngLat,_)-m<.006)return void(this._element.style.opacity=this._opacity);const g=-this._offset.y/f.transform.pixelsPerMeter,y=Math.sin(f.getPitch()*Math.PI/180)*g,b=f.terrain.depthAtPoint(new l.P(this._pos.x,this._pos.y-this._offset.y)),T=f.transform.lngLatToCameraDepth(this._lngLat,_+y)-b>.006;(null===(c=this._popup)||void 0===c?void 0:c.isOpen())&&T&&this._popup.remove(),this._element.style.opacity=T?this._opacityWhenCovered:this._opacity}getOffset(){return this._offset}setOffset(e){return this._offset=l.P.convert(e),this._update(),this}addClassName(e){this._element.classList.add(e)}removeClassName(e){this._element.classList.remove(e)}toggleClassName(e){return this._element.classList.toggle(e)}setDraggable(e){return this._draggable=!!e,this._map&&(e?(this._map.on("mousedown",this._addDragHandler),this._map.on("touchstart",this._addDragHandler)):(this._map.off("mousedown",this._addDragHandler),this._map.off("touchstart",this._addDragHandler))),this}isDraggable(){return this._draggable}setRotation(e){return this._rotation=e||0,this._update(),this}getRotation(){return this._rotation}setRotationAlignment(e){return this._rotationAlignment=e||"auto",this._update(),this}getRotationAlignment(){return this._rotationAlignment}setPitchAlignment(e){return this._pitchAlignment=e&&"auto"!==e?e:this._rotationAlignment,this._update(),this}getPitchAlignment(){return this._pitchAlignment}setOpacity(e,s){return(void 0===this._opacity||void 0===e&&void 0===s)&&(this._opacity="1",this._opacityWhenCovered="0.2"),void 0!==e&&(this._opacity=e),void 0!==s&&(this._opacityWhenCovered=s),this._map&&this._updateOpacity(!0),this}}const il={positionOptions:{enableHighAccuracy:!1,maximumAge:0,timeout:6e3},fitBoundsOptions:{maxZoom:15},trackUserLocation:!1,showAccuracyCircle:!0,showUserLocation:!0};let rl=0,nl=!1;const sl={maxWidth:100,unit:"metric"};function ol(e,s,l){const c=l&&l.maxWidth||100,d=e._container.clientHeight/2,p=e._container.clientWidth/2,f=e.unproject([p-c/2,d]),m=e.unproject([p+c/2,d]),_=Math.round(e.project(m).x-e.project(f).x),g=Math.min(c,_,e._container.clientWidth),y=f.distanceTo(m);if(l&&"imperial"===l.unit){const l=3.2808*y;l>5280?al(s,g,l/5280,e._getUIString("ScaleControl.Miles")):al(s,g,l,e._getUIString("ScaleControl.Feet"))}else l&&"nautical"===l.unit?al(s,g,y/1852,e._getUIString("ScaleControl.NauticalMiles")):y>=1e3?al(s,g,y/1e3,e._getUIString("ScaleControl.Kilometers")):al(s,g,y,e._getUIString("ScaleControl.Meters"))}function al(e,s,l,c){const d=function(e){const s=Math.pow(10,`${Math.floor(e)}`.length-1);let l=e/s;return l=l>=10?10:l>=5?5:l>=3?3:l>=2?2:l>=1?1:function(e){const s=Math.pow(10,Math.ceil(-Math.log(e)/Math.LN10));return Math.round(e*s)/s}(l),s*l}(l);e.style.width=s*(d/l)+"px",e.innerHTML=`${d} ${c}`}const ll={closeButton:!0,closeOnClick:!0,focusAfterOpen:!0,className:"",maxWidth:"240px",subpixelPositioning:!1,locationOccludedOpacity:void 0},cl=["a[href]","[tabindex]:not([tabindex='-1'])","[contenteditable]:not([contenteditable='false'])","button:not([disabled])","input:not([disabled])","select:not([disabled])","textarea:not([disabled])"].join(", ");function hl(e){if(e){if("number"==typeof e){const s=Math.round(Math.abs(e)/Math.SQRT2);return{center:new l.P(0,0),top:new l.P(0,e),"top-left":new l.P(s,s),"top-right":new l.P(-s,s),bottom:new l.P(0,-e),"bottom-left":new l.P(s,-s),"bottom-right":new l.P(-s,-s),left:new l.P(e,0),right:new l.P(-e,0)}}if(e instanceof l.P||Array.isArray(e)){const s=l.P.convert(e);return{center:s,top:s,"top-left":s,"top-right":s,bottom:s,"bottom-left":s,"bottom-right":s,left:s,right:s}}return{center:l.P.convert(e.center||[0,0]),top:l.P.convert(e.top||[0,0]),"top-left":l.P.convert(e["top-left"]||[0,0]),"top-right":l.P.convert(e["top-right"]||[0,0]),bottom:l.P.convert(e.bottom||[0,0]),"bottom-left":l.P.convert(e["bottom-left"]||[0,0]),"bottom-right":l.P.convert(e["bottom-right"]||[0,0]),left:l.P.convert(e.left||[0,0]),right:l.P.convert(e.right||[0,0])}}return hl(new l.P(0,0))}const ul=c;s.AJAXError=l.cI,s.Event=l.l,s.Evented=l.E,s.LngLat=l.V,s.MercatorCoordinate=l.a9,s.Point=l.P,s.addProtocol=l.cJ,s.config=l.c,s.removeProtocol=l.cK,s.AttributionControl=Yo,s.BoxZoomHandler=co,s.CanvasSource=ae,s.CooperativeGesturesHandler=Vo,s.DoubleClickZoomHandler=Oo,s.DragPanHandler=Zo,s.DragRotateHandler=Go,s.EdgeInsets=Nt,s.FullscreenControl=class extends l.E{constructor(e={}){super(),this._onFullscreenChange=()=>{var e;let s=window.document.fullscreenElement||window.document.mozFullScreenElement||window.document.webkitFullscreenElement||window.document.msFullscreenElement;for(;null===(e=null==s?void 0:s.shadowRoot)||void 0===e?void 0:e.fullscreenElement;)s=s.shadowRoot.fullscreenElement;s===this._container!==this._fullscreen&&this._handleFullscreenChange()},this._onClickFullscreen=()=>{this._isFullscreen()?this._exitFullscreen():this._requestFullscreen()},this._fullscreen=!1,e&&e.container&&(e.container instanceof HTMLElement?this._container=e.container:l.w("Full screen control 'container' must be a DOM element.")),"onfullscreenchange"in document?this._fullscreenchange="fullscreenchange":"onmozfullscreenchange"in document?this._fullscreenchange="mozfullscreenchange":"onwebkitfullscreenchange"in document?this._fullscreenchange="webkitfullscreenchange":"onmsfullscreenchange"in document&&(this._fullscreenchange="MSFullscreenChange")}onAdd(e){return this._map=e,this._container||(this._container=this._map.getContainer()),this._controlContainer=h.create("div","maplibregl-ctrl maplibregl-ctrl-group"),this._setupUI(),this._controlContainer}onRemove(){h.remove(this._controlContainer),this._map=null,window.document.removeEventListener(this._fullscreenchange,this._onFullscreenChange)}_setupUI(){const e=this._fullscreenButton=h.create("button","maplibregl-ctrl-fullscreen",this._controlContainer);h.create("span","maplibregl-ctrl-icon",e).setAttribute("aria-hidden","true"),e.type="button",this._updateTitle(),this._fullscreenButton.addEventListener("click",this._onClickFullscreen),window.document.addEventListener(this._fullscreenchange,this._onFullscreenChange)}_updateTitle(){const e=this._getTitle();this._fullscreenButton.setAttribute("aria-label",e),this._fullscreenButton.title=e}_getTitle(){return this._map._getUIString(this._isFullscreen()?"FullscreenControl.Exit":"FullscreenControl.Enter")}_isFullscreen(){return this._fullscreen}_handleFullscreenChange(){this._fullscreen=!this._fullscreen,this._fullscreenButton.classList.toggle("maplibregl-ctrl-shrink"),this._fullscreenButton.classList.toggle("maplibregl-ctrl-fullscreen"),this._updateTitle(),this._fullscreen?(this.fire(new l.l("fullscreenstart")),this._prevCooperativeGesturesEnabled=this._map.cooperativeGestures.isEnabled(),this._map.cooperativeGestures.disable()):(this.fire(new l.l("fullscreenend")),this._prevCooperativeGesturesEnabled&&this._map.cooperativeGestures.enable())}_exitFullscreen(){window.document.exitFullscreen?window.document.exitFullscreen():window.document.mozCancelFullScreen?window.document.mozCancelFullScreen():window.document.msExitFullscreen?window.document.msExitFullscreen():window.document.webkitCancelFullScreen?window.document.webkitCancelFullScreen():this._togglePseudoFullScreen()}_requestFullscreen(){this._container.requestFullscreen?this._container.requestFullscreen():this._container.mozRequestFullScreen?this._container.mozRequestFullScreen():this._container.msRequestFullscreen?this._container.msRequestFullscreen():this._container.webkitRequestFullscreen?this._container.webkitRequestFullscreen():this._togglePseudoFullScreen()}_togglePseudoFullScreen(){this._container.classList.toggle("maplibregl-pseudo-fullscreen"),this._handleFullscreenChange(),this._map.resize()}},s.GeoJSONSource=ee,s.GeolocateControl=class extends l.E{constructor(e){super(),this._onSuccess=e=>{if(this._map){if(this._isOutOfMapMaxBounds(e))return this._setErrorState(),this.fire(new l.l("outofmaxbounds",e)),this._updateMarker(),void this._finish();if(this.options.trackUserLocation)switch(this._lastKnownPosition=e,this._watchState){case"WAITING_ACTIVE":case"ACTIVE_LOCK":case"ACTIVE_ERROR":this._watchState="ACTIVE_LOCK",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active-error"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-active");break;case"BACKGROUND":case"BACKGROUND_ERROR":this._watchState="BACKGROUND",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background-error"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-background");break;default:throw new Error(`Unexpected watchState ${this._watchState}`)}this.options.showUserLocation&&"OFF"!==this._watchState&&this._updateMarker(e),this.options.trackUserLocation&&"ACTIVE_LOCK"!==this._watchState||this._updateCamera(e),this.options.showUserLocation&&this._dotElement.classList.remove("maplibregl-user-location-dot-stale"),this.fire(new l.l("geolocate",e)),this._finish()}},this._updateCamera=e=>{const s=new l.V(e.coords.longitude,e.coords.latitude),c=e.coords.accuracy,d=this._map.getBearing(),p=l.e({bearing:d},this.options.fitBoundsOptions),f=$.fromLngLat(s,c);this._map.fitBounds(f,p,{geolocateSource:!0})},this._updateMarker=e=>{if(e){const s=new l.V(e.coords.longitude,e.coords.latitude);this._accuracyCircleMarker.setLngLat(s).addTo(this._map),this._userLocationDotMarker.setLngLat(s).addTo(this._map),this._accuracy=e.coords.accuracy,this._updateCircleRadiusIfNeeded()}else this._userLocationDotMarker.remove(),this._accuracyCircleMarker.remove()},this._onUpdate=()=>{this._updateCircleRadiusIfNeeded()},this._onError=e=>{if(this._map){if(1===e.code){this._watchState="OFF",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active-error"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background-error"),this._geolocateButton.disabled=!0;const e=this._map._getUIString("GeolocateControl.LocationNotAvailable");this._geolocateButton.title=e,this._geolocateButton.setAttribute("aria-label",e),void 0!==this._geolocationWatchID&&this._clearWatch()}else{if(3===e.code&&nl)return;this._setErrorState()}"OFF"!==this._watchState&&this.options.showUserLocation&&this._dotElement.classList.add("maplibregl-user-location-dot-stale"),this.fire(new l.l("error",e)),this._finish()}},this._finish=()=>{this._timeoutId&&clearTimeout(this._timeoutId),this._timeoutId=void 0},this._setupUI=()=>{this._map&&(this._container.addEventListener("contextmenu",(e=>e.preventDefault())),this._geolocateButton=h.create("button","maplibregl-ctrl-geolocate",this._container),h.create("span","maplibregl-ctrl-icon",this._geolocateButton).setAttribute("aria-hidden","true"),this._geolocateButton.type="button",this._geolocateButton.disabled=!0)},this._finishSetupUI=e=>{if(this._map){if(!1===e){l.w("Geolocation support is not available so the GeolocateControl will be disabled.");const e=this._map._getUIString("GeolocateControl.LocationNotAvailable");this._geolocateButton.disabled=!0,this._geolocateButton.title=e,this._geolocateButton.setAttribute("aria-label",e)}else{const e=this._map._getUIString("GeolocateControl.FindMyLocation");this._geolocateButton.disabled=!1,this._geolocateButton.title=e,this._geolocateButton.setAttribute("aria-label",e)}this.options.trackUserLocation&&(this._geolocateButton.setAttribute("aria-pressed","false"),this._watchState="OFF"),this.options.showUserLocation&&(this._dotElement=h.create("div","maplibregl-user-location-dot"),this._userLocationDotMarker=new ms({element:this._dotElement}),this._circleElement=h.create("div","maplibregl-user-location-accuracy-circle"),this._accuracyCircleMarker=new ms({element:this._circleElement,pitchAlignment:"map"}),this.options.trackUserLocation&&(this._watchState="OFF"),this._map.on("zoom",this._onUpdate),this._map.on("move",this._onUpdate),this._map.on("rotate",this._onUpdate),this._map.on("pitch",this._onUpdate)),this._geolocateButton.addEventListener("click",(()=>this.trigger())),this._setup=!0,this.options.trackUserLocation&&this._map.on("movestart",(e=>{const s=(null==e?void 0:e[0])instanceof ResizeObserverEntry;e.geolocateSource||"ACTIVE_LOCK"!==this._watchState||s||this._map.isZooming()||(this._watchState="BACKGROUND",this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active"),this.fire(new l.l("trackuserlocationend")),this.fire(new l.l("userlocationlostfocus")))}))}},this.options=l.e({},il,e)}onAdd(e){return this._map=e,this._container=h.create("div","maplibregl-ctrl maplibregl-ctrl-group"),this._setupUI(),function(){return l._(this,arguments,void 0,(function*(e=!1){if(void 0!==ia&&!e)return ia;if(void 0===window.navigator.permissions)return ia=!!window.navigator.geolocation,ia;try{const e=yield window.navigator.permissions.query({name:"geolocation"});ia="denied"!==e.state}catch(e){ia=!!window.navigator.geolocation}return ia}))}().then((e=>this._finishSetupUI(e))),this._container}onRemove(){void 0!==this._geolocationWatchID&&(window.navigator.geolocation.clearWatch(this._geolocationWatchID),this._geolocationWatchID=void 0),this.options.showUserLocation&&this._userLocationDotMarker&&this._userLocationDotMarker.remove(),this.options.showAccuracyCircle&&this._accuracyCircleMarker&&this._accuracyCircleMarker.remove(),h.remove(this._container),this._map.off("zoom",this._onUpdate),this._map.off("move",this._onUpdate),this._map.off("rotate",this._onUpdate),this._map.off("pitch",this._onUpdate),this._map=void 0,rl=0,nl=!1}_isOutOfMapMaxBounds(e){const s=this._map.getMaxBounds(),l=e.coords;return s&&(l.longitudes.getEast()||l.latitudes.getNorth())}_setErrorState(){switch(this._watchState){case"WAITING_ACTIVE":this._watchState="ACTIVE_ERROR",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-active-error");break;case"ACTIVE_LOCK":this._watchState="ACTIVE_ERROR",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-active-error"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-waiting");break;case"BACKGROUND":this._watchState="BACKGROUND_ERROR",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-background-error"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-waiting");break;case"ACTIVE_ERROR":case"BACKGROUND_ERROR":case"OFF":case void 0:break;default:throw new Error(`Unexpected watchState ${this._watchState}`)}}_updateCircleRadiusIfNeeded(){const e=this._userLocationDotMarker.getLngLat();if(!(this.options.showUserLocation&&this.options.showAccuracyCircle&&this._accuracy&&e))return;const s=this._map.project(e),l=this._map.unproject([s.x+100,s.y]),c=e.distanceTo(l)/100,d=2*this._accuracy/c;this._circleElement.style.width=`${d.toFixed(2)}px`,this._circleElement.style.height=`${d.toFixed(2)}px`}trigger(){if(!this._setup)return l.w("Geolocate control triggered before added to a map"),!1;if(this.options.trackUserLocation){switch(this._watchState){case"OFF":this._watchState="WAITING_ACTIVE",this.fire(new l.l("trackuserlocationstart"));break;case"WAITING_ACTIVE":case"ACTIVE_LOCK":case"ACTIVE_ERROR":case"BACKGROUND_ERROR":rl--,nl=!1,this._watchState="OFF",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active-error"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background-error"),this.fire(new l.l("trackuserlocationend"));break;case"BACKGROUND":this._watchState="ACTIVE_LOCK",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background"),this._lastKnownPosition&&this._updateCamera(this._lastKnownPosition),this.fire(new l.l("trackuserlocationstart")),this.fire(new l.l("userlocationfocus"));break;default:throw new Error(`Unexpected watchState ${this._watchState}`)}switch(this._watchState){case"WAITING_ACTIVE":this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-active");break;case"ACTIVE_LOCK":this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-active");break;case"OFF":break;default:throw new Error(`Unexpected watchState ${this._watchState}`)}if("OFF"===this._watchState&&void 0!==this._geolocationWatchID)this._clearWatch();else if(void 0===this._geolocationWatchID){let e;this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.setAttribute("aria-pressed","true"),rl++,rl>1?(e={maximumAge:6e5,timeout:0},nl=!0):(e=this.options.positionOptions,nl=!1),this._geolocationWatchID=window.navigator.geolocation.watchPosition(this._onSuccess,this._onError,e)}}else window.navigator.geolocation.getCurrentPosition(this._onSuccess,this._onError,this.options.positionOptions),this._timeoutId=setTimeout(this._finish,1e4);return!0}_clearWatch(){window.navigator.geolocation.clearWatch(this._geolocationWatchID),this._geolocationWatchID=void 0,this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.setAttribute("aria-pressed","false"),this.options.showUserLocation&&this._updateMarker(null)}},s.GlobeControl=class{constructor(){this._toggleProjection=()=>{var e;const s=null===(e=this._map.getProjection())||void 0===e?void 0:e.type;this._map.setProjection("mercator"!==s&&s?{type:"mercator"}:{type:"globe"}),this._updateGlobeIcon()},this._updateGlobeIcon=()=>{var e;this._globeButton.classList.remove("maplibregl-ctrl-globe"),this._globeButton.classList.remove("maplibregl-ctrl-globe-enabled"),"globe"===(null===(e=this._map.getProjection())||void 0===e?void 0:e.type)?(this._globeButton.classList.add("maplibregl-ctrl-globe-enabled"),this._globeButton.title=this._map._getUIString("GlobeControl.Disable")):(this._globeButton.classList.add("maplibregl-ctrl-globe"),this._globeButton.title=this._map._getUIString("GlobeControl.Enable"))}}onAdd(e){return this._map=e,this._container=h.create("div","maplibregl-ctrl maplibregl-ctrl-group"),this._globeButton=h.create("button","maplibregl-ctrl-globe",this._container),h.create("span","maplibregl-ctrl-icon",this._globeButton).setAttribute("aria-hidden","true"),this._globeButton.type="button",this._globeButton.addEventListener("click",this._toggleProjection),this._updateGlobeIcon(),this._map.on("styledata",this._updateGlobeIcon),this._container}onRemove(){h.remove(this._container),this._map.off("styledata",this._updateGlobeIcon),this._globeButton.removeEventListener("click",this._toggleProjection),this._map=void 0}},s.Hash=$r,s.ImageSource=te,s.KeyboardHandler=Ao,s.LngLatBounds=$,s.LogoControl=Qo,s.Map=class extends Xo{constructor(e){var s,c;l.cG.mark(l.cH.create);const d=Object.assign(Object.assign(Object.assign({},Ko),e),{canvasContextAttributes:Object.assign(Object.assign({},Ko.canvasContextAttributes),e.canvasContextAttributes)});if(null!=d.minZoom&&null!=d.maxZoom&&d.minZoom>d.maxZoom)throw new Error("maxZoom must be greater than or equal to minZoom");if(null!=d.minPitch&&null!=d.maxPitch&&d.minPitch>d.maxPitch)throw new Error("maxPitch must be greater than or equal to minPitch");if(null!=d.minPitch&&d.minPitch<0)throw new Error("minPitch must be greater than or equal to 0");if(null!=d.maxPitch&&d.maxPitch>180)throw new Error("maxPitch must be less than or equal to 180");const p=new $t,f=new Yt;if(void 0!==d.minZoom&&p.setMinZoom(d.minZoom),void 0!==d.maxZoom&&p.setMaxZoom(d.maxZoom),void 0!==d.minPitch&&p.setMinPitch(d.minPitch),void 0!==d.maxPitch&&p.setMaxPitch(d.maxPitch),void 0!==d.renderWorldCopies&&p.setRenderWorldCopies(d.renderWorldCopies),null!==d.transformConstrain&&p.setConstrainOverride(d.transformConstrain),super(p,f,{bearingSnap:d.bearingSnap}),this._idleTriggered=!1,this._crossFadingFactor=1,this._renderTaskQueue=new Jo,this._controls=[],this._mapId=l.af(),this._lostContextStyle={style:null,images:null},this._contextLost=e=>{e.preventDefault(),this._frameRequest&&(this._frameRequest.abort(),this._frameRequest=null),this.painter.destroy();for(const e of Object.values(this.style._layers))if("custom"===e.type&&console.warn(`Custom layer with id '${e.id}' cannot be restored after WebGL context loss. You will need to re-add it manually after context restoration.`),e._listeners)for(const[s]of Object.entries(e._listeners))console.warn(`Custom layer with id '${e.id}' had event listeners for event '${s}' which cannot be restored after WebGL context loss. You will need to re-add them manually after context restoration.`);this._lostContextStyle=this._getStyleAndImages(),this.style.destroy(),this.style=null,this.fire(new l.l("webglcontextlost",{originalEvent:e}))},this._contextRestored=e=>{this._lostContextStyle.style&&this.setStyle(this._lostContextStyle.style,{diff:!1}),this._lostContextStyle.images&&(this.style.imageManager.images=this._lostContextStyle.images),this._setupPainter(),this.resize(),this._update(),this.fire(new l.l("webglcontextrestored",{originalEvent:e}))},this._onMapScroll=e=>{if(e.target===this._container)return this._container.scrollTop=0,this._container.scrollLeft=0,!1},this._onWindowOnline=()=>{this._update()},this._interactive=d.interactive,this._maxTileCacheSize=d.maxTileCacheSize,this._maxTileCacheZoomLevels=d.maxTileCacheZoomLevels,this._canvasContextAttributes=Object.assign({},d.canvasContextAttributes),this._trackResize=!0===d.trackResize,this._bearingSnap=d.bearingSnap,this._centerClampedToGround=d.centerClampedToGround,this._refreshExpiredTiles=!0===d.refreshExpiredTiles,this._fadeDuration=d.fadeDuration,this._crossSourceCollisions=!0===d.crossSourceCollisions,this._collectResourceTiming=!0===d.collectResourceTiming,this._locale=Object.assign(Object.assign({},qo),d.locale),this._clickTolerance=d.clickTolerance,this._overridePixelRatio=d.pixelRatio,this._maxCanvasSize=d.maxCanvasSize,this._zoomLevelsToOverscale=d.experimentalZoomLevelsToOverscale,this.transformCameraUpdate=d.transformCameraUpdate,this.transformConstrain=d.transformConstrain,this.cancelPendingTileRequestsWhileZooming=!0===d.cancelPendingTileRequestsWhileZooming,void 0!==d.reduceMotion&&(_.prefersReducedMotion=d.reduceMotion),this._imageQueueHandle=z.addThrottleControl((()=>this.isMoving())),this._requestManager=new v(d.transformRequest),"string"==typeof d.container){if(this._container=document.getElementById(d.container),!this._container)throw new Error(`Container '${d.container}' not found.`)}else{if(!(d.container instanceof HTMLElement))throw new Error("Invalid type: 'container' must be a String or HTMLElement.");this._container=d.container}if(d.maxBounds&&this.setMaxBounds(d.maxBounds),this._setupContainer(),this._setupPainter(),this.on("move",(()=>this._update(!1))),this.on("moveend",(()=>this._update(!1))),this.on("zoom",(()=>this._update(!0))),this.on("terrain",(()=>{this.painter.terrainFacilitator.dirty=!0,this._update(!0)})),this.once("idle",(()=>{this._idleTriggered=!0})),"undefined"!=typeof window){addEventListener("online",this._onWindowOnline,!1);let e=!1;const s=gs((e=>{this._trackResize&&!this._removed&&(this.resize(e),this.redraw())}),50);this._resizeObserver=new ResizeObserver((l=>{e?s(l):e=!0})),this._resizeObserver.observe(this._container)}this.handlers=new Ho(this,d),this._hash=d.hash&&new $r("string"==typeof d.hash&&d.hash||void 0).addTo(this),this._hash&&this._hash._onHashChange()||(this.jumpTo({center:d.center,elevation:d.elevation,zoom:d.zoom,bearing:d.bearing,pitch:d.pitch,roll:d.roll}),d.bounds&&(this.resize(),this.fitBounds(d.bounds,l.e({},d.fitBoundsOptions,{duration:0}))));const m="string"==typeof d.style||!("globe"===(null===(c=null===(s=d.style)||void 0===s?void 0:s.projection)||void 0===c?void 0:c.type));this.resize(null,m),this._localIdeographFontFamily=d.localIdeographFontFamily,this._validateStyle=d.validateStyle,d.style&&this.setStyle(d.style,{localIdeographFontFamily:d.localIdeographFontFamily}),d.attributionControl&&this.addControl(new Yo("boolean"==typeof d.attributionControl?void 0:d.attributionControl)),d.maplibreLogo&&this.addControl(new Qo,d.logoPosition),this.on("style.load",(()=>{if(m||this._resizeTransform(),this.transform.unmodified){const e=l.U(this.style.stylesheet,["center","zoom","bearing","pitch","roll"]);this.jumpTo(e)}})),this.on("data",(e=>{this._update("style"===e.dataType),this.fire(new l.l(`${e.dataType}data`,e))})),this.on("dataloading",(e=>{this.fire(new l.l(`${e.dataType}dataloading`,e))})),this.on("dataabort",(e=>{this.fire(new l.l("sourcedataabort",e))}))}_getMapId(){return this._mapId}setGlobalStateProperty(e,s){return this.style.setGlobalStateProperty(e,s),this._update(!0)}getGlobalState(){return this.style.getGlobalState()}addControl(e,s){if(void 0===s&&(s=e.getDefaultPosition?e.getDefaultPosition():"top-right"),!e||!e.onAdd)return this.fire(new l.k(new Error("Invalid argument to map.addControl(). Argument must be a control with onAdd and onRemove methods.")));const c=e.onAdd(this);this._controls.push(e);const d=this._controlPositions[s];return-1!==s.indexOf("bottom")?d.insertBefore(c,d.firstChild):d.appendChild(c),this}removeControl(e){if(!e||!e.onRemove)return this.fire(new l.k(new Error("Invalid argument to map.removeControl(). Argument must be a control with onAdd and onRemove methods.")));const s=this._controls.indexOf(e);return s>-1&&this._controls.splice(s,1),e.onRemove(this),this}hasControl(e){return this._controls.indexOf(e)>-1}coveringTiles(e){return it(this.transform,e)}calculateCameraOptionsFromTo(e,s,l,c){return null==c&&this.terrain&&(c=this.terrain.getElevationForLngLat(l,this.transform)),super.calculateCameraOptionsFromTo(e,s,l,c)}resize(e,s=!0){const[c,d]=this._containerDimensions(),p=this._getClampedPixelRatio(c,d);if(this._resizeCanvas(c,d,p),this.painter.resize(c,d,p),this.painter.overLimit()){const e=this.painter.context.gl;this._maxCanvasSize=[e.drawingBufferWidth,e.drawingBufferHeight];const s=this._getClampedPixelRatio(c,d);this._resizeCanvas(c,d,s),this.painter.resize(c,d,s)}this._resizeTransform(s);const f=!this._moving;return f&&(this.stop(),this.fire(new l.l("movestart",e)).fire(new l.l("move",e))),this.fire(new l.l("resize",e)),f&&this.fire(new l.l("moveend",e)),this}_resizeTransform(e=!0){var s;const[l,c]=this._containerDimensions();this.transform.resize(l,c,e),null===(s=this._requestedCameraState)||void 0===s||s.resize(l,c,e)}_getClampedPixelRatio(e,s){const{0:l,1:c}=this._maxCanvasSize,d=this.getPixelRatio(),p=e*d,f=s*d;return Math.min(p>l?l/p:1,f>c?c/f:1)*d}getPixelRatio(){var e;return null!==(e=this._overridePixelRatio)&&void 0!==e?e:devicePixelRatio}setPixelRatio(e){this._overridePixelRatio=e,this.resize()}getBounds(){return this.transform.getBounds()}getMaxBounds(){return this.transform.getMaxBounds()}setMaxBounds(e){return this.transform.setMaxBounds($.convert(e)),this._update()}setMinZoom(e){if((e=null==e?-2:e)>=-2&&e<=this.transform.maxZoom){const s=this._getTransformForUpdate();return s.setMinZoom(e),this._applyUpdatedTransform(s),this._update(),this}throw new Error("minZoom must be between -2 and the current maxZoom, inclusive")}getMinZoom(){return this.transform.minZoom}setMaxZoom(e){if((e=null==e?22:e)>=this.transform.minZoom){const s=this._getTransformForUpdate();return s.setMaxZoom(e),this._applyUpdatedTransform(s),this._update(),this}throw new Error("maxZoom must be greater than the current minZoom")}getMaxZoom(){return this.transform.maxZoom}setMinPitch(e){if((e=null==e?0:e)<0)throw new Error("minPitch must be greater than or equal to 0");if(e>=0&&e<=this.transform.maxPitch)return this.transform.setMinPitch(e),this._update(),this.getPitch()180)throw new Error("maxPitch must be less than or equal to 180");if(e>=this.transform.minPitch)return this.transform.setMaxPitch(e),this._update(),this.getPitch()>e&&this.setPitch(e),this;throw new Error("maxPitch must be greater than the current minPitch")}getMaxPitch(){return this.transform.maxPitch}getRenderWorldCopies(){return this.transform.renderWorldCopies}setRenderWorldCopies(e){return this.transform.setRenderWorldCopies(e),this._update()}setTransformConstrain(e){return this.transform.setConstrainOverride(e),this._update()}project(e){return this.transform.locationToScreenPoint(l.V.convert(e),this.style&&this.terrain)}unproject(e){return this.transform.screenPointToLocation(l.P.convert(e),this.terrain)}isMoving(){var e;return this._moving||(null===(e=this.handlers)||void 0===e?void 0:e.isMoving())}isZooming(){var e;return this._zooming||(null===(e=this.handlers)||void 0===e?void 0:e.isZooming())}isRotating(){var e;return this._rotating||(null===(e=this.handlers)||void 0===e?void 0:e.isRotating())}_createDelegatedListener(e,s,l){if("mouseenter"===e||"mouseover"===e){let c=!1;const d=d=>{const p=s.filter((e=>this.getLayer(e))),f=0!==p.length?this.queryRenderedFeatures(d.point,{layers:p}):[];f.length?c||(c=!0,l.call(this,new ao(e,this,d.originalEvent,{features:f}))):c=!1};return{layers:s,listener:l,delegates:{mousemove:d,mouseout:()=>{c=!1}}}}if("mouseleave"===e||"mouseout"===e){let c=!1;const d=d=>{const p=s.filter((e=>this.getLayer(e)));(0!==p.length?this.queryRenderedFeatures(d.point,{layers:p}):[]).length?c=!0:c&&(c=!1,l.call(this,new ao(e,this,d.originalEvent)))},p=s=>{c&&(c=!1,l.call(this,new ao(e,this,s.originalEvent)))};return{layers:s,listener:l,delegates:{mousemove:d,mouseout:p}}}{const c=e=>{const c=s.filter((e=>this.getLayer(e))),d=0!==c.length?this.queryRenderedFeatures(e.point,{layers:c}):[];d.length&&(e.features=d,l.call(this,e),delete e.features)};return{layers:s,listener:l,delegates:{[e]:c}}}}_saveDelegatedListener(e,s){this._delegatedListeners=this._delegatedListeners||{},this._delegatedListeners[e]=this._delegatedListeners[e]||[],this._delegatedListeners[e].push(s)}_removeDelegatedListener(e,s,l){if(!this._delegatedListeners||!this._delegatedListeners[e])return;const c=this._delegatedListeners[e];for(let e=0;es.includes(e)))){for(const e in d.delegates)this.off(e,d.delegates[e]);return void c.splice(e,1)}}}on(e,s,l){if(void 0===l)return super.on(e,s);const c="string"==typeof s?[s]:s,d=this._createDelegatedListener(e,c,l);this._saveDelegatedListener(e,d);for(const e in d.delegates)this.on(e,d.delegates[e]);return{unsubscribe:()=>{this._removeDelegatedListener(e,c,l)}}}once(e,s,l){if(void 0===l)return super.once(e,s);const c="string"==typeof s?[s]:s,d=this._createDelegatedListener(e,c,l);for(const s in d.delegates){const p=d.delegates[s];d.delegates[s]=(...s)=>{this._removeDelegatedListener(e,c,l),p(...s)}}this._saveDelegatedListener(e,d);for(const e in d.delegates)this.once(e,d.delegates[e]);return this}off(e,s,l){return void 0===l?super.off(e,s):(this._removeDelegatedListener(e,"string"==typeof s?[s]:s,l),this)}queryRenderedFeatures(e,s){if(!this.style)return[];let c;const d=e instanceof l.P||Array.isArray(e),p=d?e:[[0,0],[this.transform.width,this.transform.height]];if(s=s||(d?{}:e)||{},p instanceof l.P||"number"==typeof p[0])c=[l.P.convert(p)];else{const e=l.P.convert(p[0]),s=l.P.convert(p[1]);c=[e,new l.P(s.x,e.y),s,new l.P(e.x,s.y),e]}return this.style.queryRenderedFeatures(c,s,this.transform)}querySourceFeatures(e,s){return this.style.querySourceFeatures(e,s)}setStyle(e,s){return!1!==(s=l.e({},{localIdeographFontFamily:this._localIdeographFontFamily,validate:this._validateStyle},s)).diff&&s.localIdeographFontFamily===this._localIdeographFontFamily&&this.style&&e?(this._diffStyle(e,s),this):(this._localIdeographFontFamily=s.localIdeographFontFamily,this._updateStyle(e,s))}setTransformRequest(e){return this._requestManager.setTransformRequest(e),this}_getUIString(e){const s=this._locale[e];if(null==s)throw new Error(`Missing UI string '${e}'`);return s}_updateStyle(e,s){var l,c;if(s.transformStyle&&this.style&&!this.style._loaded)return void this.style.once("style.load",(()=>this._updateStyle(e,s)));const d=this.style&&s.transformStyle?this.style.serialize():void 0;return this.style&&(this.style.setEventedParent(null),this.style._remove(!e)),e?(this.style=new ki(this,s||{}),this.style.setEventedParent(this,{style:this.style}),"string"==typeof e?this.style.loadURL(e,s,d):this.style.loadJSON(e,s,d),this):(null===(c=null===(l=this.style)||void 0===l?void 0:l.projection)||void 0===c||c.destroy(),delete this.style,this)}_lazyInitEmptyStyle(){this.style||(this.style=new ki(this,{}),this.style.setEventedParent(this,{style:this.style}),this.style.loadEmpty())}_diffStyle(e,s){if("string"==typeof e){const c=this._requestManager.transformRequest(e,"Style");l.j(c,new AbortController).then((e=>{this._updateDiff(e.data,s)})).catch((e=>{e&&this.fire(new l.k(e))}))}else"object"==typeof e&&this._updateDiff(e,s)}_updateDiff(e,s){try{this.style.setState(e,s)&&this._update(!0)}catch(c){l.w(`Unable to perform style diff: ${c.message||c.error||c}. Rebuilding the style from scratch.`),this._updateStyle(e,s)}}getStyle(){if(this.style)return this.style.serialize()}_getStyleAndImages(){return this.style?{style:this.style.serialize(),images:this.style.imageManager.cloneImages()}:{style:null,images:{}}}isStyleLoaded(){return this.style?this.style.loaded():l.w("There is no style added to the map.")}addSource(e,s){return this._lazyInitEmptyStyle(),this.style.addSource(e,s),this._update(!0)}isSourceLoaded(e){const s=this.style&&this.style.tileManagers[e];if(void 0!==s)return s.loaded();this.fire(new l.k(new Error(`There is no tile manager with ID '${e}'`)))}setTerrain(e){if(this.style._checkLoaded(),this._terrainDataCallback&&this.style.off("data",this._terrainDataCallback),e){const s=this.style.tileManagers[e.source];if(!s)throw new Error(`cannot load terrain, because there exists no source with ID: ${e.source}`);null===this.terrain&&s.reload();for(const s in this.style._layers){const c=this.style._layers[s];"hillshade"===c.type&&c.source===e.source&&l.w("You are using the same source for a hillshade layer and for 3D terrain. Please consider using two separate sources to improve rendering quality."),"color-relief"===c.type&&c.source===e.source&&l.w("You are using the same source for a color-relief layer and for 3D terrain. Please consider using two separate sources to improve rendering quality.")}this.terrain=new is(this.painter,s,e),this.painter.renderToTexture=new os(this.painter,this.terrain),this.transform.setMinElevationForCurrentTile(this.terrain.getMinTileElevationForLngLatZoom(this.transform.center,this.transform.tileZoom)),this.transform.setElevation(this.terrain.getElevationForLngLatZoom(this.transform.center,this.transform.tileZoom)),this._terrainDataCallback=s=>{var l;"style"===s.dataType?this.terrain.tileManager.freeRtt():"source"===s.dataType&&s.tile&&(s.sourceId!==e.source||this._elevationFreeze||(this.transform.setMinElevationForCurrentTile(this.terrain.getMinTileElevationForLngLatZoom(this.transform.center,this.transform.tileZoom)),this._centerClampedToGround&&this.transform.setElevation(this.terrain.getElevationForLngLatZoom(this.transform.center,this.transform.tileZoom))),"image"===(null===(l=s.source)||void 0===l?void 0:l.type)?this.terrain.tileManager.freeRtt():this.terrain.tileManager.freeRtt(s.tile.tileID))},this.style.on("data",this._terrainDataCallback)}else this.terrain&&this.terrain.tileManager.destruct(),this.terrain=null,this.painter.renderToTexture&&this.painter.renderToTexture.destruct(),this.painter.renderToTexture=null,this.transform.setMinElevationForCurrentTile(0),this._centerClampedToGround&&this.transform.setElevation(0);return this.fire(new l.l("terrain",{terrain:e})),this}getTerrain(){var e,s;return null!==(s=null===(e=this.terrain)||void 0===e?void 0:e.options)&&void 0!==s?s:null}areTilesLoaded(){const e=this.style&&this.style.tileManagers;for(const s of Object.values(e))if(!s.areTilesLoaded())return!1;return!0}removeSource(e){return this.style.removeSource(e),this._update(!0)}getSource(e){return this.style.getSource(e)}setSourceTileLodParams(e,s,l){if(l){const c=this.getSource(l);if(!c)throw new Error(`There is no source with ID "${l}", cannot set LOD parameters`);c.calculateTileZoom=Ye(Math.max(1,e),Math.max(1,s))}else for(const l in this.style.tileManagers)this.style.tileManagers[l].getSource().calculateTileZoom=Ye(Math.max(1,e),Math.max(1,s));return this._update(!0),this}refreshTiles(e,s){const c=this.style.tileManagers[e];if(!c)throw new Error(`There is no tile manager with ID "${e}", cannot refresh tile`);void 0===s?c.reload(!0):c.refreshTiles(s.map((e=>new l.ac(e.z,e.x,e.y))))}addImage(e,s,c={}){const{pixelRatio:d=1,sdf:p=!1,stretchX:f,stretchY:m,content:g,textFitWidth:y,textFitHeight:b}=c;if(this._lazyInitEmptyStyle(),!(s instanceof HTMLImageElement||l.b(s))){if(void 0===s.width||void 0===s.height)return this.fire(new l.k(new Error("Invalid arguments to map.addImage(). The second argument must be an `HTMLImageElement`, `ImageData`, `ImageBitmap`, or object with `width`, `height`, and `data` properties with the same format as `ImageData`")));{const{width:c,height:_,data:T}=s,P=s;return this.style.addImage(e,{data:new l.R({width:c,height:_},new Uint8Array(T)),pixelRatio:d,stretchX:f,stretchY:m,content:g,textFitWidth:y,textFitHeight:b,sdf:p,version:0,userImage:P}),P.onAdd&&P.onAdd(this,e),this}}{const{width:c,height:T,data:P}=_.getImageData(s);this.style.addImage(e,{data:new l.R({width:c,height:T},P),pixelRatio:d,stretchX:f,stretchY:m,content:g,textFitWidth:y,textFitHeight:b,sdf:p,version:0})}}updateImage(e,s){const c=this.style.getImage(e);if(!c)return this.fire(new l.k(new Error("The map has no image with that id. If you are adding a new image use `map.addImage(...)` instead.")));const d=s instanceof HTMLImageElement||l.b(s)?_.getImageData(s):s,{width:p,height:f,data:m}=d;if(void 0===p||void 0===f)return this.fire(new l.k(new Error("Invalid arguments to map.updateImage(). The second argument must be an `HTMLImageElement`, `ImageData`, `ImageBitmap`, or object with `width`, `height`, and `data` properties with the same format as `ImageData`")));if(p!==c.data.width||f!==c.data.height)return this.fire(new l.k(new Error("The width and height of the updated image must be that same as the previous version of the image")));const g=!(s instanceof HTMLImageElement||l.b(s));return c.data.replace(m,g),this.style.updateImage(e,c),this}getImage(e){return this.style.getImage(e)}hasImage(e){return e?!!this.style.getImage(e):(this.fire(new l.k(new Error("Missing required image id"))),!1)}removeImage(e){this.style.removeImage(e)}loadImage(e){return z.getImage(this._requestManager.transformRequest(e,"Image"),new AbortController)}listImages(){return this.style.listImages()}addLayer(e,s){return this._lazyInitEmptyStyle(),this.style.addLayer(e,s),this._update(!0)}moveLayer(e,s){return this.style.moveLayer(e,s),this._update(!0)}removeLayer(e){return this.style.removeLayer(e),this._update(!0)}getLayer(e){return this.style.getLayer(e)}getLayersOrder(){return this.style.getLayersOrder()}setLayerZoomRange(e,s,l){return this.style.setLayerZoomRange(e,s,l),this._update(!0)}setFilter(e,s,l={}){return this.style.setFilter(e,s,l),this._update(!0)}getFilter(e){return this.style.getFilter(e)}setPaintProperty(e,s,l,c={}){return this.style.setPaintProperty(e,s,l,c),this._update(!0)}getPaintProperty(e,s){return this.style.getPaintProperty(e,s)}setLayoutProperty(e,s,l,c={}){return this.style.setLayoutProperty(e,s,l,c),this._update(!0)}getLayoutProperty(e,s){return this.style.getLayoutProperty(e,s)}setGlyphs(e,s={}){return this._lazyInitEmptyStyle(),this.style.setGlyphs(e,s),this._update(!0)}getGlyphs(){return this.style.getGlyphsUrl()}addSprite(e,s,l={}){return this._lazyInitEmptyStyle(),this.style.addSprite(e,s,l,(e=>{e||this._update(!0)})),this}removeSprite(e){return this._lazyInitEmptyStyle(),this.style.removeSprite(e),this._update(!0)}getSprite(){return this.style.getSprite()}setSprite(e,s={}){return this._lazyInitEmptyStyle(),this.style.setSprite(e,s,(e=>{e||this._update(!0)})),this}setLight(e,s={}){return this._lazyInitEmptyStyle(),this.style.setLight(e,s),this._update(!0)}getLight(){return this.style.getLight()}setSky(e,s={}){return this._lazyInitEmptyStyle(),this.style.setSky(e,s),this._update(!0)}getSky(){return this.style.getSky()}setFeatureState(e,s){return this.style.setFeatureState(e,s),this._update()}removeFeatureState(e,s){return this.style.removeFeatureState(e,s),this._update()}getFeatureState(e){return this.style.getFeatureState(e)}getContainer(){return this._container}getCanvasContainer(){return this._canvasContainer}getCanvas(){return this._canvas}_containerDimensions(){let e=0,s=0;return this._container&&(e=this._container.clientWidth||400,s=this._container.clientHeight||300),[e,s]}_setupContainer(){const e=this._container;e.classList.add("maplibregl-map");const s=this._canvasContainer=h.create("div","maplibregl-canvas-container",e);this._interactive&&s.classList.add("maplibregl-interactive"),this._canvas=h.create("canvas","maplibregl-canvas",s),this._canvas.addEventListener("webglcontextlost",this._contextLost,!1),this._canvas.addEventListener("webglcontextrestored",this._contextRestored,!1),this._canvas.setAttribute("tabindex",this._interactive?"0":"-1"),this._canvas.setAttribute("aria-label",this._getUIString("Map.Title")),this._canvas.setAttribute("role","region");const l=this._containerDimensions(),c=this._getClampedPixelRatio(l[0],l[1]);this._resizeCanvas(l[0],l[1],c);const d=this._controlContainer=h.create("div","maplibregl-control-container",e),p=this._controlPositions={};["top-left","top-right","bottom-left","bottom-right"].forEach((e=>{p[e]=h.create("div",`maplibregl-ctrl-${e} `,d)})),this._container.addEventListener("scroll",this._onMapScroll,!1)}_resizeCanvas(e,s,l){this._canvas.width=Math.floor(l*e),this._canvas.height=Math.floor(l*s),this._canvas.style.width=`${e}px`,this._canvas.style.height=`${s}px`}_setupPainter(){const e=Object.assign(Object.assign({},this._canvasContextAttributes),{alpha:!0,depth:!0,stencil:!0,premultipliedAlpha:!0});let s=null;this._canvas.addEventListener("webglcontextcreationerror",(l=>{s={requestedAttributes:e},l&&(s.statusMessage=l.statusMessage,s.type=l.type)}),{once:!0});let l=null;if(l=this._canvasContextAttributes.contextType?this._canvas.getContext(this._canvasContextAttributes.contextType,e):this._canvas.getContext("webgl2",e)||this._canvas.getContext("webgl",e),!l){const e="Failed to initialize WebGL";throw s?(s.message=e,new Error(JSON.stringify(s))):new Error(e)}this.painter=new qr(l,this.transform),b.testSupport(l)}migrateProjection(e,s){super.migrateProjection(e,s),this.painter.transform=e,this.fire(new l.l("projectiontransition",{newProjection:this.style.projection.name}))}loaded(){return!this._styleDirty&&!this._sourcesDirty&&!!this.style&&this.style.loaded()}_update(e){return this.style&&this.style._loaded?(this._styleDirty=this._styleDirty||e,this._sourcesDirty=!0,this.triggerRepaint(),this):this}_requestRenderFrame(e){return this._update(),this._renderTaskQueue.add(e)}_cancelRenderFrame(e){this._renderTaskQueue.remove(e)}_render(e){var s,c,d,p,f;const m=this._idleTriggered?this._fadeDuration:0,_=(null===(s=this.style.projection)||void 0===s?void 0:s.transitionState)>0;if(this.painter.context.setDirty(),this.painter.setBaseState(),this._renderTaskQueue.run(e),this._removed)return;let g=!1;if(this.style&&this._styleDirty){this._styleDirty=!1;const e=this.transform.zoom,s=y();this.style.zoomHistory.update(e,s);const c=new l.H(e,{now:s,fadeDuration:m,zoomHistory:this.style.zoomHistory,transition:this.style.getTransition()}),d=c.crossFadingFactor();1===d&&d===this._crossFadingFactor||(g=!0,this._crossFadingFactor=d),this.style.update(c)}const b=(null===(c=this.style.projection)||void 0===c?void 0:c.transitionState)>0!==_;null===(d=this.style.projection)||void 0===d||d.setErrorQueryLatitudeDegrees(this.transform.center.lat),this.transform.setTransitionState(null===(p=this.style.projection)||void 0===p?void 0:p.transitionState,null===(f=this.style.projection)||void 0===f?void 0:f.latitudeErrorCorrectionRadians),this.style&&(this._sourcesDirty||b)&&(this._sourcesDirty=!1,this.style._updateSources(this.transform)),this.terrain?(this.terrain.tileManager.update(this.transform,this.terrain),this.transform.setMinElevationForCurrentTile(this.terrain.getMinTileElevationForLngLatZoom(this.transform.center,this.transform.tileZoom)),!this._elevationFreeze&&this._centerClampedToGround&&this.transform.setElevation(this.terrain.getElevationForLngLatZoom(this.transform.center,this.transform.tileZoom))):(this.transform.setMinElevationForCurrentTile(0),this._centerClampedToGround&&this.transform.setElevation(0)),this._placementDirty=this.style&&this.style._updatePlacement(this.transform,this.showCollisionBoxes,m,this._crossSourceCollisions,b),this.painter.render(this.style,{showTileBoundaries:this.showTileBoundaries,showOverdrawInspector:this._showOverdrawInspector,rotating:this.isRotating(),zooming:this.isZooming(),moving:this.isMoving(),fadeDuration:m,showPadding:this.showPadding}),this.fire(new l.l("render")),this.loaded()&&!this._loaded&&(this._loaded=!0,l.cG.mark(l.cH.load),this.fire(new l.l("load"))),this.style&&(this.style.hasTransitions()||g)&&(this._styleDirty=!0),this.style&&!this._placementDirty&&this.style._releaseSymbolFadeTiles();const T=this._sourcesDirty||this._styleDirty||this._placementDirty;return T||this._repaint?this.triggerRepaint():!this.isMoving()&&this.loaded()&&this.fire(new l.l("idle")),!this._loaded||this._fullyLoaded||T||(this._fullyLoaded=!0,l.cG.mark(l.cH.fullLoad)),this}redraw(){return this.style&&(this._frameRequest&&(this._frameRequest.abort(),this._frameRequest=null),this._render(0)),this}remove(){var e;this._hash&&this._hash.remove();for(const e of this._controls)e.onRemove(this);this._controls=[],this._frameRequest&&(this._frameRequest.abort(),this._frameRequest=null),this._renderTaskQueue.clear(),this.painter.destroy(),this.handlers.destroy(),delete this.handlers,this.setStyle(null),"undefined"!=typeof window&&removeEventListener("online",this._onWindowOnline,!1),z.removeThrottleControl(this._imageQueueHandle),null===(e=this._resizeObserver)||void 0===e||e.disconnect();const s=this.painter.context.gl.getExtension("WEBGL_lose_context");(null==s?void 0:s.loseContext)&&s.loseContext(),this._canvas.removeEventListener("webglcontextrestored",this._contextRestored,!1),this._canvas.removeEventListener("webglcontextlost",this._contextLost,!1),h.remove(this._canvasContainer),h.remove(this._controlContainer),this._container.removeEventListener("scroll",this._onMapScroll,!1),this._container.classList.remove("maplibregl-map"),l.cG.clearMetrics(),this._removed=!0,this.fire(new l.l("remove"))}triggerRepaint(){this.style&&!this._frameRequest&&(this._frameRequest=new AbortController,_.frame(this._frameRequest,(e=>{l.cG.frame(e),this._frameRequest=null;try{this._render(e)}catch(e){if(!l.Z(e)&&!function(e){return e.message===wn}(e))throw e}}),(()=>{})))}get showTileBoundaries(){return!!this._showTileBoundaries}set showTileBoundaries(e){this._showTileBoundaries!==e&&(this._showTileBoundaries=e,this._update())}get showPadding(){return!!this._showPadding}set showPadding(e){this._showPadding!==e&&(this._showPadding=e,this._update())}get showCollisionBoxes(){return!!this._showCollisionBoxes}set showCollisionBoxes(e){this._showCollisionBoxes!==e&&(this._showCollisionBoxes=e,e?this.style._generateCollisionBoxes():this._update())}get showOverdrawInspector(){return!!this._showOverdrawInspector}set showOverdrawInspector(e){this._showOverdrawInspector!==e&&(this._showOverdrawInspector=e,this._update())}get repaint(){return!!this._repaint}set repaint(e){this._repaint!==e&&(this._repaint=e,this.triggerRepaint())}get vertices(){return!!this._vertices}set vertices(e){this._vertices=e,this._update()}get version(){return $o}getCameraTargetElevation(){return this.transform.elevation}getProjection(){return this.style.getProjection()}setProjection(e){return this._lazyInitEmptyStyle(),this.style.setProjection(e),this._update(!0)}},s.MapMouseEvent=ao,s.MapTouchEvent=ro,s.MapWheelEvent=oo,s.Marker=ms,s.NavigationControl=class{constructor(e){this._updateZoomButtons=()=>{const e=this._map.getZoom(),s=e===this._map.getMaxZoom(),l=e===this._map.getMinZoom();this._zoomInButton.disabled=s,this._zoomOutButton.disabled=l,this._zoomInButton.setAttribute("aria-disabled",s.toString()),this._zoomOutButton.setAttribute("aria-disabled",l.toString())},this._rotateCompassArrow=()=>{this._compassIcon.style.transform=this.options.visualizePitch&&this.options.visualizeRoll?`scale(${1/Math.pow(Math.cos(this._map.transform.pitchInRadians),.5)}) rotateZ(${-this._map.transform.roll}deg) rotateX(${this._map.transform.pitch}deg) rotateZ(${-this._map.transform.bearing}deg)`:this.options.visualizePitch?`scale(${1/Math.pow(Math.cos(this._map.transform.pitchInRadians),.5)}) rotateX(${this._map.transform.pitch}deg) rotateZ(${-this._map.transform.bearing}deg)`:this.options.visualizeRoll?`rotate(${-this._map.transform.bearing-this._map.transform.roll}deg)`:`rotate(${-this._map.transform.bearing}deg)`},this._setButtonTitle=(e,s)=>{const l=this._map._getUIString(`NavigationControl.${s}`);e.title=l,e.setAttribute("aria-label",l)},this.options=l.e({},ta,e),this._container=h.create("div","maplibregl-ctrl maplibregl-ctrl-group"),this._container.addEventListener("contextmenu",(e=>e.preventDefault())),this.options.showZoom&&(this._zoomInButton=this._createButton("maplibregl-ctrl-zoom-in",(e=>this._map.zoomIn({},{originalEvent:e}))),h.create("span","maplibregl-ctrl-icon",this._zoomInButton).setAttribute("aria-hidden","true"),this._zoomOutButton=this._createButton("maplibregl-ctrl-zoom-out",(e=>this._map.zoomOut({},{originalEvent:e}))),h.create("span","maplibregl-ctrl-icon",this._zoomOutButton).setAttribute("aria-hidden","true")),this.options.showCompass&&(this._compass=this._createButton("maplibregl-ctrl-compass",(e=>{this.options.visualizePitch?this._map.resetNorthPitch({},{originalEvent:e}):this._map.resetNorth({},{originalEvent:e})})),this._compassIcon=h.create("span","maplibregl-ctrl-icon",this._compass),this._compassIcon.setAttribute("aria-hidden","true"))}onAdd(e){return this._map=e,this.options.showZoom&&(this._setButtonTitle(this._zoomInButton,"ZoomIn"),this._setButtonTitle(this._zoomOutButton,"ZoomOut"),this._map.on("zoom",this._updateZoomButtons),this._updateZoomButtons()),this.options.showCompass&&(this._setButtonTitle(this._compass,"ResetBearing"),this.options.visualizePitch&&this._map.on("pitch",this._rotateCompassArrow),this.options.visualizeRoll&&this._map.on("roll",this._rotateCompassArrow),this._map.on("rotate",this._rotateCompassArrow),this._rotateCompassArrow(),this._handler=new hs(this._map,this._compass,this.options.visualizePitch)),this._container}onRemove(){h.remove(this._container),this.options.showZoom&&this._map.off("zoom",this._updateZoomButtons),this.options.showCompass&&(this.options.visualizePitch&&this._map.off("pitch",this._rotateCompassArrow),this.options.visualizeRoll&&this._map.off("roll",this._rotateCompassArrow),this._map.off("rotate",this._rotateCompassArrow),this._handler.off(),delete this._handler),delete this._map}_createButton(e,s){const l=h.create("button",e,this._container);return l.type="button",l.addEventListener("click",s),l}},s.Popup=class extends l.E{constructor(e){super(),this._updateOpacity=()=>{void 0!==this.options.locationOccludedOpacity&&(this._container.style.opacity=this._map.transform.isLocationOccluded(this.getLngLat())?`${this.options.locationOccludedOpacity}`:"")},this.remove=()=>(this._content&&h.remove(this._content),this._container&&(h.remove(this._container),delete this._container),this._map&&(this._map.off("move",this._update),this._map.off("move",this._onClose),this._map.off("click",this._onClose),this._map.off("remove",this.remove),this._map.off("mousemove",this._onMouseMove),this._map.off("mouseup",this._onMouseUp),this._map.off("drag",this._onDrag),this._map._canvasContainer.classList.remove("maplibregl-track-pointer"),delete this._map,this.fire(new l.l("close"))),this),this._onMouseUp=e=>{this._update(e.point)},this._onMouseMove=e=>{this._update(e.point)},this._onDrag=e=>{this._update(e.point)},this._update=e=>{if(!this._map||!this._lngLat&&!this._trackPointer||!this._content)return;if(!this._container){if(this._container=h.create("div","maplibregl-popup",this._map.getContainer()),this._tip=h.create("div","maplibregl-popup-tip",this._container),this._container.appendChild(this._content),this.options.className)for(const e of this.options.className.split(" "))this._container.classList.add(e);this._closeButton&&this._closeButton.setAttribute("aria-label",this._map._getUIString("Popup.Close")),this._trackPointer&&this._container.classList.add("maplibregl-popup-track-pointer")}if(this.options.maxWidth&&this._container.style.maxWidth!==this.options.maxWidth&&(this._container.style.maxWidth=this.options.maxWidth),this._lngLat=na(this._lngLat,this._flatPos,this._map.transform,this._trackPointer),this._trackPointer&&!e)return;const s=this._flatPos=this._pos=this._trackPointer&&e?e:this._map.project(this._lngLat);this._map.terrain&&(this._flatPos=this._trackPointer&&e?e:this._map.transform.locationToScreenPoint(this._lngLat));let l=this.options.anchor;const c=hl(this.options.offset);if(!l){const e=this._container.offsetWidth,d=this._container.offsetHeight;let p;p=s.y+c.bottom.ythis._map.transform.height-d?["bottom"]:[],s.xthis._map.transform.width-e/2&&p.push("right"),l=0===p.length?"bottom":p.join("-")}let d=s.add(c[l]);this.options.subpixelPositioning||(d=d.round()),h.setTransform(this._container,`${el[l]} translate(${d.x}px,${d.y}px)`),tl(this._container,l,"popup"),this._updateOpacity()},this._onClose=()=>{this.remove()},this.options=l.e(Object.create(ll),e)}addTo(e){return this._map&&this.remove(),this._map=e,this.options.closeOnClick&&this._map.on("click",this._onClose),this.options.closeOnMove&&this._map.on("move",this._onClose),this._map.on("remove",this.remove),this._update(),this._focusFirstElement(),this._trackPointer?(this._map.on("mousemove",this._onMouseMove),this._map.on("mouseup",this._onMouseUp),this._container&&this._container.classList.add("maplibregl-popup-track-pointer"),this._map._canvasContainer.classList.add("maplibregl-track-pointer")):this._map.on("move",this._update),this.fire(new l.l("open")),this}isOpen(){return!!this._map}getLngLat(){return this._lngLat}setLngLat(e){return this._lngLat=l.V.convert(e),this._pos=null,this._flatPos=null,this._trackPointer=!1,this._update(),this._map&&(this._map.on("move",this._update),this._map.off("mousemove",this._onMouseMove),this._container&&this._container.classList.remove("maplibregl-popup-track-pointer"),this._map._canvasContainer.classList.remove("maplibregl-track-pointer")),this}trackPointer(){return this._trackPointer=!0,this._pos=null,this._flatPos=null,this._update(),this._map&&(this._map.off("move",this._update),this._map.on("mousemove",this._onMouseMove),this._map.on("drag",this._onDrag),this._container&&this._container.classList.add("maplibregl-popup-track-pointer"),this._map._canvasContainer.classList.add("maplibregl-track-pointer")),this}getElement(){return this._container}setText(e){return this.setDOMContent(document.createTextNode(e))}setHTML(e){const s=document.createDocumentFragment(),l=document.createElement("body");let c;for(l.innerHTML=e;c=l.firstChild,c;)s.appendChild(c);return this.setDOMContent(s)}getMaxWidth(){var e;return null===(e=this._container)||void 0===e?void 0:e.style.maxWidth}setMaxWidth(e){return this.options.maxWidth=e,this._update(),this}setDOMContent(e){if(this._content)for(;this._content.hasChildNodes();)this._content.firstChild&&this._content.removeChild(this._content.firstChild);else this._content=h.create("div","maplibregl-popup-content",this._container);return this._content.appendChild(e),this._createCloseButton(),this._update(),this._focusFirstElement(),this}addClassName(e){return this._container&&this._container.classList.add(e),this}removeClassName(e){return this._container&&this._container.classList.remove(e),this}setOffset(e){return this.options.offset=e,this._update(),this}toggleClassName(e){if(this._container)return this._container.classList.toggle(e)}setSubpixelPositioning(e){this.options.subpixelPositioning=e}_createCloseButton(){this.options.closeButton&&(this._closeButton=h.create("button","maplibregl-popup-close-button",this._content),this._closeButton.type="button",this._closeButton.innerHTML="×",this._closeButton.addEventListener("click",this._onClose))}_focusFirstElement(){if(!this.options.focusAfterOpen||!this._container)return;const e=this._container.querySelector(cl);e&&e.focus()}},s.RasterDEMTileSource=Y,s.RasterTileSource=K,s.ScaleControl=class{constructor(e){this._onMove=()=>{ol(this._map,this._container,this.options)},this.setUnit=e=>{this.options.unit=e,ol(this._map,this._container,this.options)},this.options=Object.assign(Object.assign({},sl),e)}getDefaultPosition(){return"bottom-left"}onAdd(e){return this._map=e,this._container=h.create("div","maplibregl-ctrl maplibregl-ctrl-scale",e.getContainer()),this._map.on("move",this._onMove),this._onMove(),this._container}onRemove(){h.remove(this._container),this._map.off("move",this._onMove),this._map=void 0}},s.ScrollZoomHandler=Bo,s.Style=ki,s.TerrainControl=class{constructor(e){this._toggleTerrain=()=>{this._map.getTerrain()?this._map.setTerrain(null):this._map.setTerrain(this.options),this._updateTerrainIcon()},this._updateTerrainIcon=()=>{this._terrainButton.classList.remove("maplibregl-ctrl-terrain"),this._terrainButton.classList.remove("maplibregl-ctrl-terrain-enabled"),this._map.terrain?(this._terrainButton.classList.add("maplibregl-ctrl-terrain-enabled"),this._terrainButton.title=this._map._getUIString("TerrainControl.Disable")):(this._terrainButton.classList.add("maplibregl-ctrl-terrain"),this._terrainButton.title=this._map._getUIString("TerrainControl.Enable"))},this.options=e}onAdd(e){return this._map=e,this._container=h.create("div","maplibregl-ctrl maplibregl-ctrl-group"),this._terrainButton=h.create("button","maplibregl-ctrl-terrain",this._container),h.create("span","maplibregl-ctrl-icon",this._terrainButton).setAttribute("aria-hidden","true"),this._terrainButton.type="button",this._terrainButton.addEventListener("click",this._toggleTerrain),this._updateTerrainIcon(),this._map.on("terrain",this._updateTerrainIcon),this._container}onRemove(){h.remove(this._container),this._map.off("terrain",this._updateTerrainIcon),this._map=void 0}},s.TwoFingersTouchPitchHandler=zo,s.TwoFingersTouchRotateHandler=So,s.TwoFingersTouchZoomHandler=Mo,s.TwoFingersTouchZoomRotateHandler=Uo,s.VectorTileSource=X,s.VideoSource=ie,s.addSourceType=(e,s)=>l._(void 0,void 0,void 0,(function*(){if(xe(e))throw new Error(`A source type called "${e}" already exists.`);((e,s)=>{ye[e]=s})(e,s)})),s.clearPrewarmedResources=function(){const e=re;e&&(e.isPreloaded()&&1===e.numActive()?(e.release(W),re=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()"))},s.createTileMesh=cr,s.getMaxParallelImageRequests=function(){return l.c.MAX_PARALLEL_IMAGE_REQUESTS},s.getRTLTextPluginStatus=function(){return we().getRTLTextPluginStatus()},s.getVersion=function(){return ul},s.getWorkerCount=function(){return k.workerCount},s.getWorkerUrl=function(){return l.c.WORKER_URL},s.importScriptInWorkers=function(e){return le().broadcast("IS",e)},s.isTimeFrozen=function(){return g.isFrozen()},s.now=y,s.prewarm=function(){oe().acquire(W)},s.restoreNow=function(){g.restoreNow()},s.setMaxParallelImageRequests=function(e){l.c.MAX_PARALLEL_IMAGE_REQUESTS=e},s.setNow=function(e){g.setNow(e)},s.setRTLTextPlugin=function(e,s){return we().setRTLTextPlugin(e,s)},s.setWorkerCount=function(e){k.workerCount=e},s.setWorkerUrl=function(e){l.c.WORKER_URL=e}}));var d=s;return d}));var l=s;export{l as default}; + * @license 3-Clause BSD. Full text of license: https://github.com/maplibre/maplibre-gl-js/blob/v5.16.0/LICENSE.txt + */(function(e,l){s=l()})(0,(function(){var s={};var l={};function c(e,c,d){l[e]=d;if(e==="index"){var p="var sharedModule = {}; ("+l.shared+")(sharedModule); ("+l.worker+")(sharedModule);";var f={};l.shared(f);l.index(s,f);typeof window!=="undefined"&&s.setWorkerUrl(window.URL.createObjectURL(new Blob([p],{type:"text/javascript"})));return s}}c("shared",["exports"],(function(s){function l(e,s,l,c){return new(l||(l=Promise))((function(d,p){function f(e){try{_(c.next(e))}catch(e){p(e)}}function m(e){try{_(c.throw(e))}catch(e){p(e)}}function _(e){var s;e.done?d(e.value):(s=e.value,s instanceof l?s:new l((function(e){e(s)}))).then(f,m)}_((c=c.apply(e,s||[])).next())}))}function c(s,l){(this||e).x=s,(this||e).y=l}function d(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var p,f;"function"==typeof SuppressedError&&SuppressedError,c.prototype={clone(){return new c((this||e).x,(this||e).y)},add(e){return this.clone()._add(e)},sub(e){return this.clone()._sub(e)},multByPoint(e){return this.clone()._multByPoint(e)},divByPoint(e){return this.clone()._divByPoint(e)},mult(e){return this.clone()._mult(e)},div(e){return this.clone()._div(e)},rotate(e){return this.clone()._rotate(e)},rotateAround(e,s){return this.clone()._rotateAround(e,s)},matMult(e){return this.clone()._matMult(e)},unit(){return this.clone()._unit()},perp(){return this.clone()._perp()},round(){return this.clone()._round()},mag(){return Math.sqrt((this||e).x*(this||e).x+(this||e).y*(this||e).y)},equals(s){return(this||e).x===s.x&&(this||e).y===s.y},dist(e){return Math.sqrt(this.distSqr(e))},distSqr(s){const l=s.x-(this||e).x,c=s.y-(this||e).y;return l*l+c*c},angle(){return Math.atan2((this||e).y,(this||e).x)},angleTo(s){return Math.atan2((this||e).y-s.y,(this||e).x-s.x)},angleWith(e){return this.angleWithSep(e.x,e.y)},angleWithSep(s,l){return Math.atan2((this||e).x*l-(this||e).y*s,(this||e).x*s+(this||e).y*l)},_matMult(s){const l=s[2]*(this||e).x+s[3]*(this||e).y;return(this||e).x=s[0]*(this||e).x+s[1]*(this||e).y,(this||e).y=l,this||e},_add(s){return(this||e).x+=s.x,(this||e).y+=s.y,this||e},_sub(s){return(this||e).x-=s.x,(this||e).y-=s.y,this||e},_mult(s){return(this||e).x*=s,(this||e).y*=s,this||e},_div(s){return(this||e).x/=s,(this||e).y/=s,this||e},_multByPoint(s){return(this||e).x*=s.x,(this||e).y*=s.y,this||e},_divByPoint(s){return(this||e).x/=s.x,(this||e).y/=s.y,this||e},_unit(){return this._div(this.mag()),this||e},_perp(){const s=(this||e).y;return(this||e).y=(this||e).x,(this||e).x=-s,this||e},_rotate(s){const l=Math.cos(s),c=Math.sin(s),d=c*(this||e).x+l*(this||e).y;return(this||e).x=l*(this||e).x-c*(this||e).y,(this||e).y=d,this||e},_rotateAround(s,l){const c=Math.cos(s),d=Math.sin(s),p=l.y+d*((this||e).x-l.x)+c*((this||e).y-l.y);return(this||e).x=l.x+c*((this||e).x-l.x)-d*((this||e).y-l.y),(this||e).y=p,this||e},_round(){return(this||e).x=Math.round((this||e).x),(this||e).y=Math.round((this||e).y),this||e},constructor:c},c.convert=function(e){if(e instanceof c)return e;if(Array.isArray(e))return new c(+e[0],+e[1]);if(void 0!==e.x&&void 0!==e.y)return new c(+e.x,+e.y);throw new Error("Expected [x, y] or {x, y} point format")};var m=function(){if(f)return p;function s(s,l,c,d){(this||e).cx=3*s,(this||e).bx=3*(c-s)-(this||e).cx,(this||e).ax=1-(this||e).cx-(this||e).bx,(this||e).cy=3*l,(this||e).by=3*(d-l)-(this||e).cy,(this||e).ay=1-(this||e).cy-(this||e).by,(this||e).p1x=s,(this||e).p1y=l,(this||e).p2x=c,(this||e).p2y=d}return f=1,p=s,s.prototype={sampleCurveX:function(s){return(((this||e).ax*s+(this||e).bx)*s+(this||e).cx)*s},sampleCurveY:function(s){return(((this||e).ay*s+(this||e).by)*s+(this||e).cy)*s},sampleCurveDerivativeX:function(s){return(3*(this||e).ax*s+2*(this||e).bx)*s+(this||e).cx},solveCurveX:function(e,s){if(void 0===s&&(s=1e-6),e<0)return 0;if(e>1)return 1;for(var l=e,c=0;c<8;c++){var d=this.sampleCurveX(l)-e;if(Math.abs(d)d?f=l:m=l,l=.5*(m-f)+f;return l},solve:function(e,s){return this.sampleCurveY(this.solveCurveX(e,s))}},p}(),_=d(m);let g,y;function b(){return null==g&&(g="undefined"!=typeof OffscreenCanvas&&new OffscreenCanvas(1,1).getContext("2d")&&"function"==typeof createImageBitmap),g}function T(){if(null==y&&(y=!1,b())){const e=5,s=new OffscreenCanvas(e,e).getContext("2d",{willReadFrequently:!0});if(s){for(let l=0;l4&&void 0!==arguments[4]?arguments[4]:"zyx",p=Math.PI/360;s*=p,c*=p,l*=p;var f=Math.sin(s),m=Math.cos(s),_=Math.sin(l),g=Math.cos(l),y=Math.sin(c),b=Math.cos(c);switch(d){case"xyz":e[0]=f*g*b+m*_*y,e[1]=m*_*b-f*g*y,e[2]=m*g*y+f*_*b,e[3]=m*g*b-f*_*y;break;case"xzy":e[0]=f*g*b-m*_*y,e[1]=m*_*b-f*g*y,e[2]=m*g*y+f*_*b,e[3]=m*g*b+f*_*y;break;case"yxz":e[0]=f*g*b+m*_*y,e[1]=m*_*b-f*g*y,e[2]=m*g*y-f*_*b,e[3]=m*g*b+f*_*y;break;case"yzx":e[0]=f*g*b+m*_*y,e[1]=m*_*b+f*g*y,e[2]=m*g*y-f*_*b,e[3]=m*g*b-f*_*y;break;case"zxy":e[0]=f*g*b-m*_*y,e[1]=m*_*b+f*g*y,e[2]=m*g*y+f*_*b,e[3]=m*g*b-f*_*y;break;case"zyx":e[0]=f*g*b-m*_*y,e[1]=m*_*b+f*g*y,e[2]=m*g*y-f*_*b,e[3]=m*g*b+f*_*y;break;default:throw new Error("Unknown angle order "+d)}return e}function J(){var e=new S(2);return S!=Float32Array&&(e[0]=0,e[1]=0),e}function re(e,s){var l=new S(2);return l[0]=e,l[1]=s,l}R(),G=new S(4),S!=Float32Array&&(G[0]=0,G[1]=0,G[2]=0,G[3]=0),R(),F(1,0,0),F(0,1,0),Z(),Z(),I(),J();const se=8192;function oe(e,s,l){return s*(se/(e.tileSize*Math.pow(2,l-e.tileID.overscaledZ)))}function le(e,s){return(e%s+s)%s}function ce(e,s,l){return e*(1-l)+s*l}function he(e){if(e<=0)return 0;if(e>=1)return 1;const s=e*e,l=s*e;return 4*(e<.5?l:3*(e-s)+l-.75)}function ue(e,s,l,c){const d=new _(e,s,l,c);return e=>d.solve(e)}const pe=ue(.25,.1,.25,1);function fe(e,s,l){return Math.min(l,Math.max(s,e))}function me(e,s,l){const c=l-s,d=((e-s)%c+c)%c+s;return d===s?l:d}function ge(e,...s){for(const l of s)for(const s in l)e[s]=l[s];return e}let ye=1;function xe(s,l,c){const d={};for(const c in s)d[c]=l.call(this||e,s[c],c,s);return d}function ve(s,l,c){const d={};for(const c in s)l.call(this||e,s[c],c,s)&&(d[c]=s[c]);return d}function be(e){return Array.isArray(e)?e.map(be):"object"==typeof e&&e?xe(e,be):e}const we={};function Se(e){we[e]||("undefined"!=typeof console&&console.warn(e),we[e]=!0)}function Me(e,s,l){return(l.y-e.y)*(s.x-e.x)>(s.y-e.y)*(l.x-e.x)}function Ee(e){return"undefined"!=typeof WorkerGlobalScope&&void 0!==e&&e instanceof WorkerGlobalScope}let Ce=null;function Ae(e){return"undefined"!=typeof ImageBitmap&&e instanceof ImageBitmap}const Ne="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAC0lEQVQYV2NgAAIAAAUAAarVyFEAAAAASUVORK5CYII=";function Ge(s,c,d,p,f){return l(this||e,void 0,void 0,(function*(){if("undefined"==typeof VideoFrame)throw new Error("VideoFrame not supported");const e=new VideoFrame(s,{timestamp:0});try{const l=null==e?void 0:e.format;if(!l||!l.startsWith("BGR")&&!l.startsWith("RGB"))throw new Error(`Unrecognized format ${l}`);const m=l.startsWith("BGR"),_=new Uint8ClampedArray(p*f*4);if(yield e.copyTo(_,function(e,s,l,c,d){const p=4*Math.max(-s,0),f=(Math.max(0,l)-l)*c*4+p,m=4*c,_=Math.max(0,s),g=Math.max(0,l);return{rect:{x:_,y:g,width:Math.min(e.width,s+c)-_,height:Math.min(e.height,l+d)-g},layout:[{offset:f,stride:m}]}}(s,c,d,p,f)),m)for(let e=0;e<_.length;e+=4){const s=_[e];_[e]=_[e+2],_[e+2]=s}return _}finally{e.close()}}))}let Ue,qe;function $e(e,s,l,c){return e.addEventListener(s,l,c),{unsubscribe:()=>{e.removeEventListener(s,l,c)}}}function He(e){return e*Math.PI/180}function Ye(e){return e/Math.PI*180}const et={touchstart:!0,touchmove:!0,touchmoveWindow:!0,touchend:!0,touchcancel:!0},tt={dblclick:!0,click:!0,mouseover:!0,mouseout:!0,mousedown:!0,mousemove:!0,mousemoveWindow:!0,mouseup:!0,mouseupWindow:!0,contextmenu:!0,wheel:!0},it="AbortError";class st extends Error{constructor(e=it){super(e instanceof Error?e.message:e),this.name=it,e instanceof Error&&e.stack&&(this.stack=e.stack)}}function rt(e){return e.name===it}const ot={MAX_PARALLEL_IMAGE_REQUESTS:16,MAX_PARALLEL_IMAGE_REQUESTS_PER_FRAME:8,MAX_TILE_CACHE_ZOOM_LEVELS:5,REGISTERED_PROTOCOLS:{},WORKER_URL:""};function at(e){return ot.REGISTERED_PROTOCOLS[e.substring(0,e.indexOf("://"))]}const ft="global-dispatcher";class ct extends Error{constructor(e,s,l,c){super(`AJAXError: ${s} (${e}): ${l}`),this.status=e,this.statusText=s,this.url=l,this.body=c}}const _t=()=>Ee(self)?self.worker&&self.worker.referrer:("blob:"===window.location.protocol?window.parent:window).location.href,yt=function(s,c){if(/:\/\//.test(s.url)&&!/^https?:|^file:/.test(s.url)){const e=at(s.url);if(e)return e(s,c);if(Ee(self)&&self.worker&&self.worker.actor)return self.worker.actor.sendAsync({type:"GR",data:s,targetMapId:ft},c)}if(!(/^file:/.test(d=s.url)||/^file:/.test(_t())&&!/^\w+:/.test(d))){if(fetch&&Request&&AbortController&&Object.prototype.hasOwnProperty.call(Request.prototype,"signal"))return function(s,c){return l(this||e,void 0,void 0,(function*(){const e=new Request(s.url,{method:s.method||"GET",body:s.body,credentials:s.credentials,headers:s.headers,cache:s.cache,referrer:_t(),signal:c.signal});let l,d;"json"!==s.type||e.headers.has("Accept")||e.headers.set("Accept","application/json");try{l=yield fetch(e)}catch(e){if(rt(e))throw e;throw new ct(0,e.message,s.url,new Blob)}if(!l.ok){const e=yield l.blob();throw new ct(l.status,l.statusText,s.url,e)}d="arrayBuffer"===s.type||"image"===s.type?l.arrayBuffer():"json"===s.type?l.json():l.text();const p=yield d;return c.signal.throwIfAborted(),{data:p,cacheControl:l.headers.get("Cache-Control"),expires:l.headers.get("Expires")}}))}(s,c);if(Ee(self)&&self.worker&&self.worker.actor)return self.worker.actor.sendAsync({type:"GR",data:s,mustQueue:!0,targetMapId:ft},c)}var d;return function(e,s){return new Promise(((l,c)=>{var d;const p=new XMLHttpRequest;p.open(e.method||"GET",e.url,!0),"arrayBuffer"!==e.type&&"image"!==e.type||(p.responseType="arraybuffer");for(const s in e.headers)p.setRequestHeader(s,e.headers[s]);"json"===e.type&&(p.responseType="text",(null===(d=e.headers)||void 0===d?void 0:d.Accept)||p.setRequestHeader("Accept","application/json")),p.withCredentials="include"===e.credentials,p.onerror=()=>{c(new Error(p.statusText))},p.onload=()=>{if(!s.signal.aborted)if((p.status>=200&&p.status<300||0===p.status)&&null!==p.response){let s=p.response;if("json"===e.type)try{s=JSON.parse(p.response)}catch(e){return void c(e)}l({data:s,cacheControl:p.getResponseHeader("Cache-Control"),expires:p.getResponseHeader("Expires")})}else{const s=new Blob([p.response],{type:p.getResponseHeader("Content-Type")});c(new ct(p.status,p.statusText,e.url,s))}},s.signal.addEventListener("abort",(()=>{p.abort(),c(new st(s.signal.reason))})),p.send(e.body)}))}(s,c)};function vt(e){if(!e||e.indexOf("://")<=0||0===e.indexOf("data:image/")||0===e.indexOf("blob:"))return!0;const s=new URL(e),l=window.location;return s.protocol===l.protocol&&s.host===l.host}function bt(e,s,l){l[e]&&-1!==l[e].indexOf(s)||(l[e]=l[e]||[],l[e].push(s))}function wt(e,s,l){if(l&&l[e]){const c=l[e].indexOf(s);-1!==c&&l[e].splice(c,1)}}class mt{constructor(e,s={}){ge(this,s),this.type=e}}class gt extends mt{constructor(e,s={}){super("error",ge({error:e},s))}}class xt{on(e,s){return this._listeners=this._listeners||{},bt(e,s,this._listeners),{unsubscribe:()=>{this.off(e,s)}}}off(e,s){return wt(e,s,this._listeners),wt(e,s,this._oneTimeListeners),this}once(e,s){return s?(this._oneTimeListeners=this._oneTimeListeners||{},bt(e,s,this._oneTimeListeners),this):new Promise((s=>this.once(e,s)))}fire(e,s){"string"==typeof e&&(e=new mt(e,s||{}));const l=e.type;if(this.listens(l)){e.target=this;const s=this._listeners&&this._listeners[l]?this._listeners[l].slice():[];for(const l of s)l.call(this,e);const c=this._oneTimeListeners&&this._oneTimeListeners[l]?this._oneTimeListeners[l].slice():[];for(const s of c)wt(l,s,this._oneTimeListeners),s.call(this,e);const d=this._eventedParent;d&&(ge(e,"function"==typeof this._eventedParentData?this._eventedParentData():this._eventedParentData),d.fire(e))}else e instanceof gt&&console.error(e.error);return this}listens(e){return this._listeners&&this._listeners[e]&&this._listeners[e].length>0||this._oneTimeListeners&&this._oneTimeListeners[e]&&this._oneTimeListeners[e].length>0||this._eventedParent&&this._eventedParent.listens(e)}setEventedParent(e,s){return this._eventedParent=e,this._eventedParentData=s,this}}var Tt={$version:8,$root:{version:{required:!0,type:"enum",values:[8]},name:{type:"string"},metadata:{type:"*"},center:{type:"array",value:"number",length:2},centerAltitude:{type:"number"},zoom:{type:"number"},bearing:{type:"number",default:0,period:360,units:"degrees"},pitch:{type:"number",default:0,units:"degrees"},roll:{type:"number",default:0,units:"degrees"},state:{type:"state",default:{}},light:{type:"light"},sky:{type:"sky"},projection:{type:"projection"},terrain:{type:"terrain"},sources:{required:!0,type:"sources"},sprite:{type:"sprite"},glyphs:{type:"string"},"font-faces":{type:"fontFaces"},transition:{type:"transition"},layers:{required:!0,type:"array",value:"layer"}},sources:{"*":{type:"source"}},source:["source_vector","source_raster","source_raster_dem","source_geojson","source_video","source_image"],source_vector:{type:{required:!0,type:"enum",values:{vector:{}}},url:{type:"string"},tiles:{type:"array",value:"string"},bounds:{type:"array",value:"number",length:4,default:[-180,-85.051129,180,85.051129]},scheme:{type:"enum",values:{xyz:{},tms:{}},default:"xyz"},minzoom:{type:"number",default:0},maxzoom:{type:"number",default:22},attribution:{type:"string"},promoteId:{type:"promoteId"},volatile:{type:"boolean",default:!1},encoding:{type:"enum",values:{mvt:{},mlt:{}},default:"mvt"},"*":{type:"*"}},source_raster:{type:{required:!0,type:"enum",values:{raster:{}}},url:{type:"string"},tiles:{type:"array",value:"string"},bounds:{type:"array",value:"number",length:4,default:[-180,-85.051129,180,85.051129]},minzoom:{type:"number",default:0},maxzoom:{type:"number",default:22},tileSize:{type:"number",default:512,units:"pixels"},scheme:{type:"enum",values:{xyz:{},tms:{}},default:"xyz"},attribution:{type:"string"},volatile:{type:"boolean",default:!1},"*":{type:"*"}},source_raster_dem:{type:{required:!0,type:"enum",values:{"raster-dem":{}}},url:{type:"string"},tiles:{type:"array",value:"string"},bounds:{type:"array",value:"number",length:4,default:[-180,-85.051129,180,85.051129]},minzoom:{type:"number",default:0},maxzoom:{type:"number",default:22},tileSize:{type:"number",default:512,units:"pixels"},attribution:{type:"string"},encoding:{type:"enum",values:{terrarium:{},mapbox:{},custom:{}},default:"mapbox"},redFactor:{type:"number",default:1},blueFactor:{type:"number",default:1},greenFactor:{type:"number",default:1},baseShift:{type:"number",default:0},volatile:{type:"boolean",default:!1},"*":{type:"*"}},source_geojson:{type:{required:!0,type:"enum",values:{geojson:{}}},data:{required:!0,type:"*"},maxzoom:{type:"number",default:18},attribution:{type:"string"},buffer:{type:"number",default:128,maximum:512,minimum:0},filter:{type:"filter"},tolerance:{type:"number",default:.375},cluster:{type:"boolean",default:!1},clusterRadius:{type:"number",default:50,minimum:0},clusterMaxZoom:{type:"number"},clusterMinPoints:{type:"number"},clusterProperties:{type:"*"},lineMetrics:{type:"boolean",default:!1},generateId:{type:"boolean",default:!1},promoteId:{type:"promoteId"}},source_video:{type:{required:!0,type:"enum",values:{video:{}}},urls:{required:!0,type:"array",value:"string"},coordinates:{required:!0,type:"array",length:4,value:{type:"array",length:2,value:"number"}}},source_image:{type:{required:!0,type:"enum",values:{image:{}}},url:{required:!0,type:"string"},coordinates:{required:!0,type:"array",length:4,value:{type:"array",length:2,value:"number"}}},layer:{id:{type:"string",required:!0},type:{type:"enum",values:{fill:{},line:{},symbol:{},circle:{},heatmap:{},"fill-extrusion":{},raster:{},hillshade:{},"color-relief":{},background:{}},required:!0},metadata:{type:"*"},source:{type:"string"},"source-layer":{type:"string"},minzoom:{type:"number",minimum:0,maximum:24},maxzoom:{type:"number",minimum:0,maximum:24},filter:{type:"filter"},layout:{type:"layout"},paint:{type:"paint"}},layout:["layout_fill","layout_line","layout_circle","layout_heatmap","layout_fill-extrusion","layout_symbol","layout_raster","layout_hillshade","layout_color-relief","layout_background"],layout_background:{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible",expression:{interpolated:!1,parameters:["global-state"]},"property-type":"data-constant"}},layout_fill:{"fill-sort-key":{type:"number",expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},visibility:{type:"enum",values:{visible:{},none:{}},default:"visible",expression:{interpolated:!1,parameters:["global-state"]},"property-type":"data-constant"}},layout_circle:{"circle-sort-key":{type:"number",expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},visibility:{type:"enum",values:{visible:{},none:{}},default:"visible",expression:{interpolated:!1,parameters:["global-state"]},"property-type":"data-constant"}},layout_heatmap:{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible",expression:{interpolated:!1,parameters:["global-state"]},"property-type":"data-constant"}},"layout_fill-extrusion":{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible",expression:{interpolated:!1,parameters:["global-state"]},"property-type":"data-constant"}},layout_line:{"line-cap":{type:"enum",values:{butt:{},round:{},square:{}},default:"butt",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"line-join":{type:"enum",values:{bevel:{},round:{},miter:{}},default:"miter",expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"line-miter-limit":{type:"number",default:2,requires:[{"line-join":"miter"}],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"line-round-limit":{type:"number",default:1.05,requires:[{"line-join":"round"}],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"line-sort-key":{type:"number",expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},visibility:{type:"enum",values:{visible:{},none:{}},default:"visible",expression:{interpolated:!1,parameters:["global-state"]},"property-type":"data-constant"}},layout_symbol:{"symbol-placement":{type:"enum",values:{point:{},line:{},"line-center":{}},default:"point",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"symbol-spacing":{type:"number",default:250,minimum:1,units:"pixels",requires:[{"symbol-placement":"line"}],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"symbol-avoid-edges":{type:"boolean",default:!1,expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"symbol-sort-key":{type:"number",expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"symbol-z-order":{type:"enum",values:{auto:{},"viewport-y":{},source:{}},default:"auto",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-allow-overlap":{type:"boolean",default:!1,requires:["icon-image",{"!":"icon-overlap"}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-overlap":{type:"enum",values:{never:{},always:{},cooperative:{}},requires:["icon-image"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-ignore-placement":{type:"boolean",default:!1,requires:["icon-image"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-optional":{type:"boolean",default:!1,requires:["icon-image","text-field"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-rotation-alignment":{type:"enum",values:{map:{},viewport:{},auto:{}},default:"auto",requires:["icon-image"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-size":{type:"number",default:1,minimum:0,units:"factor of the original icon size",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"icon-text-fit":{type:"enum",values:{none:{},width:{},height:{},both:{}},default:"none",requires:["icon-image","text-field"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-text-fit-padding":{type:"array",value:"number",length:4,default:[0,0,0,0],units:"pixels",requires:["icon-image","text-field",{"icon-text-fit":["both","width","height"]}],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"icon-image":{type:"resolvedImage",tokens:!0,expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"icon-rotate":{type:"number",default:0,period:360,units:"degrees",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"icon-padding":{type:"padding",default:[2],units:"pixels",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"icon-keep-upright":{type:"boolean",default:!1,requires:["icon-image",{"icon-rotation-alignment":"map"},{"symbol-placement":["line","line-center"]}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-offset":{type:"array",value:"number",length:2,default:[0,0],requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"icon-anchor":{type:"enum",values:{center:{},left:{},right:{},top:{},bottom:{},"top-left":{},"top-right":{},"bottom-left":{},"bottom-right":{}},default:"center",requires:["icon-image"],expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"icon-pitch-alignment":{type:"enum",values:{map:{},viewport:{},auto:{}},default:"auto",requires:["icon-image"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-pitch-alignment":{type:"enum",values:{map:{},viewport:{},auto:{}},default:"auto",requires:["text-field"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-rotation-alignment":{type:"enum",values:{map:{},viewport:{},"viewport-glyph":{},auto:{}},default:"auto",requires:["text-field"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-field":{type:"formatted",default:"",tokens:!0,expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-font":{type:"array",value:"string",default:["Open Sans Regular","Arial Unicode MS Regular"],requires:["text-field"],expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-size":{type:"number",default:16,minimum:0,units:"pixels",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-max-width":{type:"number",default:10,minimum:0,units:"ems",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-line-height":{type:"number",default:1.2,units:"ems",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"text-letter-spacing":{type:"number",default:0,units:"ems",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-justify":{type:"enum",values:{auto:{},left:{},center:{},right:{}},default:"center",requires:["text-field"],expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-radial-offset":{type:"number",units:"ems",default:0,requires:["text-field"],"property-type":"data-driven",expression:{interpolated:!0,parameters:["zoom","feature"]}},"text-variable-anchor":{type:"array",value:"enum",values:{center:{},left:{},right:{},top:{},bottom:{},"top-left":{},"top-right":{},"bottom-left":{},"bottom-right":{}},requires:["text-field",{"symbol-placement":["point"]}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-variable-anchor-offset":{type:"variableAnchorOffsetCollection",requires:["text-field",{"symbol-placement":["point"]}],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-anchor":{type:"enum",values:{center:{},left:{},right:{},top:{},bottom:{},"top-left":{},"top-right":{},"bottom-left":{},"bottom-right":{}},default:"center",requires:["text-field",{"!":"text-variable-anchor"}],expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-max-angle":{type:"number",default:45,units:"degrees",requires:["text-field",{"symbol-placement":["line","line-center"]}],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"text-writing-mode":{type:"array",value:"enum",values:{horizontal:{},vertical:{}},requires:["text-field",{"symbol-placement":["point"]}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-rotate":{type:"number",default:0,period:360,units:"degrees",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-padding":{type:"number",default:2,minimum:0,units:"pixels",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"text-keep-upright":{type:"boolean",default:!0,requires:["text-field",{"text-rotation-alignment":"map"},{"symbol-placement":["line","line-center"]}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-transform":{type:"enum",values:{none:{},uppercase:{},lowercase:{}},default:"none",requires:["text-field"],expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-offset":{type:"array",value:"number",units:"ems",length:2,default:[0,0],requires:["text-field",{"!":"text-radial-offset"}],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-allow-overlap":{type:"boolean",default:!1,requires:["text-field",{"!":"text-overlap"}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-overlap":{type:"enum",values:{never:{},always:{},cooperative:{}},requires:["text-field"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-ignore-placement":{type:"boolean",default:!1,requires:["text-field"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-optional":{type:"boolean",default:!1,requires:["text-field","icon-image"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},visibility:{type:"enum",values:{visible:{},none:{}},default:"visible",expression:{interpolated:!1,parameters:["global-state"]},"property-type":"data-constant"}},layout_raster:{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible",expression:{interpolated:!1,parameters:["global-state"]},"property-type":"data-constant"}},layout_hillshade:{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible",expression:{interpolated:!1,parameters:["global-state"]},"property-type":"data-constant"}},"layout_color-relief":{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible",expression:{interpolated:!1,parameters:["global-state"]},"property-type":"data-constant"}},filter:{type:"boolean",expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},filter_operator:{type:"enum",values:{"==":{},"!=":{},">":{},">=":{},"<":{},"<=":{},in:{},"!in":{},all:{},any:{},none:{},has:{},"!has":{}}},geometry_type:{type:"enum",values:{Point:{},LineString:{},Polygon:{}}},function:{expression:{type:"expression"},stops:{type:"array",value:"function_stop"},base:{type:"number",default:1,minimum:0},property:{type:"string",default:"$zoom"},type:{type:"enum",values:{identity:{},exponential:{},interval:{},categorical:{}},default:"exponential"},colorSpace:{type:"enum",values:{rgb:{},lab:{},hcl:{}},default:"rgb"},default:{type:"*",required:!1}},function_stop:{type:"array",minimum:0,maximum:24,value:["number","color"],length:2},expression:{type:"array",value:"expression_name",minimum:1},light:{anchor:{type:"enum",default:"viewport",values:{map:{},viewport:{}},"property-type":"data-constant",transition:!1,expression:{interpolated:!1,parameters:["zoom"]}},position:{type:"array",default:[1.15,210,30],length:3,value:"number","property-type":"data-constant",transition:!0,expression:{interpolated:!0,parameters:["zoom"]}},color:{type:"color","property-type":"data-constant",default:"#ffffff",expression:{interpolated:!0,parameters:["zoom"]},transition:!0},intensity:{type:"number","property-type":"data-constant",default:.5,minimum:0,maximum:1,expression:{interpolated:!0,parameters:["zoom"]},transition:!0}},sky:{"sky-color":{type:"color","property-type":"data-constant",default:"#88C6FC",expression:{interpolated:!0,parameters:["zoom"]},transition:!0},"horizon-color":{type:"color","property-type":"data-constant",default:"#ffffff",expression:{interpolated:!0,parameters:["zoom"]},transition:!0},"fog-color":{type:"color","property-type":"data-constant",default:"#ffffff",expression:{interpolated:!0,parameters:["zoom"]},transition:!0},"fog-ground-blend":{type:"number","property-type":"data-constant",default:.5,minimum:0,maximum:1,expression:{interpolated:!0,parameters:["zoom"]},transition:!0},"horizon-fog-blend":{type:"number","property-type":"data-constant",default:.8,minimum:0,maximum:1,expression:{interpolated:!0,parameters:["zoom"]},transition:!0},"sky-horizon-blend":{type:"number","property-type":"data-constant",default:.8,minimum:0,maximum:1,expression:{interpolated:!0,parameters:["zoom"]},transition:!0},"atmosphere-blend":{type:"number","property-type":"data-constant",default:.8,minimum:0,maximum:1,expression:{interpolated:!0,parameters:["zoom"]},transition:!0}},terrain:{source:{type:"string",required:!0},exaggeration:{type:"number",minimum:0,default:1}},projection:{type:{type:"projectionDefinition",default:"mercator","property-type":"data-constant",transition:!1,expression:{interpolated:!0,parameters:["zoom"]}}},paint:["paint_fill","paint_line","paint_circle","paint_heatmap","paint_fill-extrusion","paint_symbol","paint_raster","paint_hillshade","paint_color-relief","paint_background"],paint_fill:{"fill-antialias":{type:"boolean",default:!0,expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"fill-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-color":{type:"color",default:"#000000",transition:!0,requires:[{"!":"fill-pattern"}],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-outline-color":{type:"color",transition:!0,requires:[{"!":"fill-pattern"},{"fill-antialias":!0}],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"fill-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["fill-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"fill-pattern":{type:"resolvedImage",transition:!0,expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"cross-faded-data-driven"}},"paint_fill-extrusion":{"fill-extrusion-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"fill-extrusion-color":{type:"color",default:"#000000",transition:!0,requires:[{"!":"fill-extrusion-pattern"}],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-extrusion-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"fill-extrusion-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["fill-extrusion-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"fill-extrusion-pattern":{type:"resolvedImage",transition:!0,expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"cross-faded-data-driven"},"fill-extrusion-height":{type:"number",default:0,minimum:0,units:"meters",transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-extrusion-base":{type:"number",default:0,minimum:0,units:"meters",transition:!0,requires:["fill-extrusion-height"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-extrusion-vertical-gradient":{type:"boolean",default:!0,transition:!1,expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"}},paint_line:{"line-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-color":{type:"color",default:"#000000",transition:!0,requires:[{"!":"line-pattern"}],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"line-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["line-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"line-width":{type:"number",default:1,minimum:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-gap-width":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-offset":{type:"number",default:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-blur":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-dasharray":{type:"array",value:"number",minimum:0,transition:!0,units:"line widths",requires:[{"!":"line-pattern"}],expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"cross-faded-data-driven"},"line-pattern":{type:"resolvedImage",transition:!0,expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"cross-faded-data-driven"},"line-gradient":{type:"color",transition:!1,requires:[{"!":"line-dasharray"},{"!":"line-pattern"},{source:"geojson",has:{lineMetrics:!0}}],expression:{interpolated:!0,parameters:["line-progress"]},"property-type":"color-ramp"}},paint_circle:{"circle-radius":{type:"number",default:5,minimum:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-color":{type:"color",default:"#000000",transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-blur":{type:"number",default:0,transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"circle-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["circle-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"circle-pitch-scale":{type:"enum",values:{map:{},viewport:{}},default:"map",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"circle-pitch-alignment":{type:"enum",values:{map:{},viewport:{}},default:"viewport",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"circle-stroke-width":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-stroke-color":{type:"color",default:"#000000",transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-stroke-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"}},paint_heatmap:{"heatmap-radius":{type:"number",default:30,minimum:1,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"heatmap-weight":{type:"number",default:1,minimum:0,transition:!1,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"heatmap-intensity":{type:"number",default:1,minimum:0,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"heatmap-color":{type:"color",default:["interpolate",["linear"],["heatmap-density"],0,"rgba(0, 0, 255, 0)",.1,"royalblue",.3,"cyan",.5,"lime",.7,"yellow",1,"red"],transition:!1,expression:{interpolated:!0,parameters:["heatmap-density"]},"property-type":"color-ramp"},"heatmap-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"}},paint_symbol:{"icon-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-color":{type:"color",default:"#000000",transition:!0,requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-halo-color":{type:"color",default:"rgba(0, 0, 0, 0)",transition:!0,requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-halo-width":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-halo-blur":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"icon-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["icon-image","icon-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-color":{type:"color",default:"#000000",transition:!0,overridable:!0,requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-halo-color":{type:"color",default:"rgba(0, 0, 0, 0)",transition:!0,requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-halo-width":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-halo-blur":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"text-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["text-field","text-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"}},paint_raster:{"raster-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-hue-rotate":{type:"number",default:0,period:360,transition:!0,units:"degrees",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-brightness-min":{type:"number",default:0,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-brightness-max":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-saturation":{type:"number",default:0,minimum:-1,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-contrast":{type:"number",default:0,minimum:-1,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-resampling":{type:"enum",values:{linear:{},nearest:{}},default:"linear",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"raster-fade-duration":{type:"number",default:300,minimum:0,transition:!1,units:"milliseconds",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"}},paint_hillshade:{"hillshade-illumination-direction":{type:"numberArray",default:335,minimum:0,maximum:359,transition:!1,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-illumination-altitude":{type:"numberArray",default:45,minimum:0,maximum:90,transition:!1,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-illumination-anchor":{type:"enum",values:{map:{},viewport:{}},default:"viewport",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-exaggeration":{type:"number",default:.5,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-shadow-color":{type:"colorArray",default:"#000000",transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-highlight-color":{type:"colorArray",default:"#FFFFFF",transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-accent-color":{type:"color",default:"#000000",transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-method":{type:"enum",values:{standard:{},basic:{},combined:{},igor:{},multidirectional:{}},default:"standard",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"}},"paint_color-relief":{"color-relief-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"color-relief-color":{type:"color",transition:!1,expression:{interpolated:!0,parameters:["elevation"]},"property-type":"color-ramp"}},paint_background:{"background-color":{type:"color",default:"#000000",transition:!0,requires:[{"!":"background-pattern"}],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"background-pattern":{type:"resolvedImage",transition:!0,expression:{interpolated:!1,parameters:["zoom"]},"property-type":"cross-faded"},"background-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"}},transition:{duration:{type:"number",default:300,minimum:0,units:"milliseconds"},delay:{type:"number",default:0,minimum:0,units:"milliseconds"}},"property-type":{"data-driven":{type:"property-type"},"cross-faded":{type:"property-type"},"cross-faded-data-driven":{type:"property-type"},"color-ramp":{type:"property-type"},"data-constant":{type:"property-type"},constant:{type:"property-type"}},promoteId:{"*":{type:"string"}},interpolation:{type:"array",value:"interpolation_name",minimum:1},interpolation_name:{type:"enum",values:{linear:{syntax:{overloads:[{parameters:[],"output-type":"interpolation"}],parameters:[]}},exponential:{syntax:{overloads:[{parameters:["base"],"output-type":"interpolation"}],parameters:[{name:"base",type:"number literal"}]}},"cubic-bezier":{syntax:{overloads:[{parameters:["x1","y1","x2","y2"],"output-type":"interpolation"}],parameters:[{name:"x1",type:"number literal"},{name:"y1",type:"number literal"},{name:"x2",type:"number literal"},{name:"y2",type:"number literal"}]}}}}};const Mt=["type","source","source-layer","minzoom","maxzoom","filter","layout"];function At(e,s){const l={};for(const s in e)"ref"!==s&&(l[s]=e[s]);return Mt.forEach((e=>{e in s&&(l[e]=s[e])})),l}function Lt(e,s){if(Array.isArray(e)){if(!Array.isArray(s)||e.length!==s.length)return!1;for(let l=0;l`:"value"===e.itemType.kind?"array":`array<${s}>`}return e.kind}const Ai=[ni,li,ci,ui,pi,fi,yi,mi,Ei(_i),xi,bi,vi,wi,Ii];function Li(e,s){if("error"===s.kind)return null;if("array"===e.kind){if("array"===s.kind&&(0===s.N&&"value"===s.itemType.kind||!Li(e.itemType,s.itemType))&&("number"!=typeof e.N||e.N===s.N))return null}else{if(e.kind===s.kind)return null;if("value"===e.kind)for(const e of Ai)if(!Li(e,s))return null}return`Expected ${Ci(e)} but found ${Ci(s)} instead.`}function Fi(e,s){return s.some((s=>s.kind===e.kind))}function Oi(e,s){return s.some((s=>"null"===s?null===e:"array"===s?Array.isArray(e):"object"===s?e&&!Array.isArray(e)&&"object"==typeof e:s===typeof e))}function Vi(e,s){return"array"===e.kind&&"array"===s.kind?e.itemType.kind===s.itemType.kind&&"number"==typeof e.N:e.kind===s.kind}const ji=.96422,Ni=.82521,Gi=4/29,Ui=6/29,qi=3*Ui*Ui,$i=Ui*Ui*Ui,Wi=Math.PI/180,Hi=180/Math.PI;function Xi(e){return(e%=360)<0&&(e+=360),e}function Yi([e,s,l,c]){let d,p;const f=Qi((.2225045*(e=Ki(e))+.7168786*(s=Ki(s))+.0606169*(l=Ki(l)))/1);e===s&&s===l?d=p=f:(d=Qi((.4360747*e+.3850649*s+.1430804*l)/ji),p=Qi((.0139322*e+.0971045*s+.7141733*l)/Ni));const m=116*f-16;return[m<0?0:m,500*(d-f),200*(f-p),c]}function Ki(e){return e<=.04045?e/12.92:Math.pow((e+.055)/1.055,2.4)}function Qi(e){return e>$i?Math.pow(e,1/3):e/qi+Gi}function Ji([e,s,l,c]){let d=(e+16)/116,p=isNaN(s)?d:d+s/500,f=isNaN(l)?d:d-l/200;return d=1*cr(d),p=ji*cr(p),f=Ni*cr(f),[lr(3.1338561*p-1.6168667*d-.4906146*f),lr(-.9787684*p+1.9161415*d+.033454*f),lr(.0719453*p-.2289914*d+1.4052427*f),c]}function lr(e){return(e=e<=.00304?12.92*e:1.055*Math.pow(e,1/2.4)-.055)<0?0:e>1?1:e}function cr(e){return e>Ui?e*e*e:qi*(e-Gi)}const hr=Object.hasOwn||function(e,s){return Object.prototype.hasOwnProperty.call(e,s)};function ur(e,s){return hr(e,s)?e[s]:void 0}function dr(e){return parseInt(e.padEnd(2,e),16)/255}function pr(e,s){return _r(s?e/100:e,0,1)}function _r(e,s,l){return Math.min(Math.max(s,e),l)}function gr(e){return!e.some(Number.isNaN)}const yr={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]};function xr(e,s,l){return e+l*(s-e)}function vr(e,s,l){return e.map(((e,c)=>xr(e,s[c],l)))}class Te{constructor(e,s,l,c=1,d=!0){this.r=e,this.g=s,this.b=l,this.a=c,d||(this.r*=c,this.g*=c,this.b*=c,c||this.overwriteGetter("rgb",[e,s,l,c]))}static parse(e){if(e instanceof Te)return e;if("string"!=typeof e)return;const s=function(e){if("transparent"===(e=e.toLowerCase().trim()))return[0,0,0,0];const s=ur(yr,e);if(s){const[e,l,c]=s;return[e/255,l/255,c/255,1]}if(e.startsWith("#")&&/^#(?:[0-9a-f]{3,4}|[0-9a-f]{6}|[0-9a-f]{8})$/.test(e)){const s=e.length<6?1:2;let l=1;return[dr(e.slice(l,l+=s)),dr(e.slice(l,l+=s)),dr(e.slice(l,l+=s)),dr(e.slice(l,l+s)||"ff")]}if(e.startsWith("rgb")){const s=e.match(/^rgba?\(\s*([\de.+-]+)(%)?(?:\s+|\s*(,)\s*)([\de.+-]+)(%)?(?:\s+|\s*(,)\s*)([\de.+-]+)(%)?(?:\s*([,\/])\s*([\de.+-]+)(%)?)?\s*\)$/);if(s){const[e,l,c,d,p,f,m,_,g,y,b,T]=s,P=[d||" ",m||" ",y].join("");if(" "===P||" /"===P||",,"===P||",,,"===P){const e=[c,f,g].join(""),s="%%%"===e?100:""===e?255:0;if(s){const e=[_r(+l/s,0,1),_r(+p/s,0,1),_r(+_/s,0,1),b?pr(+b,T):1];if(gr(e))return e}}return}}const l=e.match(/^hsla?\(\s*([\de.+-]+)(?:deg)?(?:\s+|\s*(,)\s*)([\de.+-]+)%(?:\s+|\s*(,)\s*)([\de.+-]+)%(?:\s*([,\/])\s*([\de.+-]+)(%)?)?\s*\)$/);if(l){const[e,s,c,d,p,f,m,_,g]=l,y=[c||" ",p||" ",m].join("");if(" "===y||" /"===y||",,"===y||",,,"===y){const e=[+s,_r(+d,0,100),_r(+f,0,100),_?pr(+_,g):1];if(gr(e))return function([e,s,l,c]){function d(c){const d=(c+e/30)%12,p=s*Math.min(l,1-l);return l-p*Math.max(-1,Math.min(d-3,9-d,1))}return e=Xi(e),s/=100,l/=100,[d(0),d(8),d(4),c]}(e)}}}(e);return s?new Te(...s,!1):void 0}get rgb(){const{r:e,g:s,b:l,a:c}=this,d=c||1/0;return this.overwriteGetter("rgb",[e/d,s/d,l/d,c])}get hcl(){return this.overwriteGetter("hcl",function(e){const[s,l,c,d]=Yi(e),p=Math.sqrt(l*l+c*c);return[Math.round(1e4*p)?Xi(Math.atan2(c,l)*Hi):NaN,p,s,d]}(this.rgb))}get lab(){return this.overwriteGetter("lab",Yi(this.rgb))}overwriteGetter(e,s){return Object.defineProperty(this,e,{value:s}),s}toString(){const[e,s,l,c]=this.rgb;return`rgba(${[e,s,l].map((e=>Math.round(255*e))).join(",")},${c})`}static interpolate(e,s,l,c="rgb"){switch(c){case"rgb":{const[c,d,p,f]=vr(e.rgb,s.rgb,l);return new Te(c,d,p,f,!1)}case"hcl":{const[c,d,p,f]=e.hcl,[m,_,g,y]=s.hcl;let b,T;if(isNaN(c)||isNaN(m))isNaN(c)?isNaN(m)?b=NaN:(b=m,1!==p&&0!==p||(T=_)):(b=c,1!==g&&0!==g||(T=d));else{let e=m-c;m>c&&e>180?e-=360:m180&&(e+=360),b=c+l*e}const[P,S,I,C]=function([e,s,l,c]){return e=isNaN(e)?0:e*Wi,Ji([l,Math.cos(e)*s,Math.sin(e)*s,c])}([b,null!=T?T:xr(d,_,l),xr(p,g,l),xr(f,y,l)]);return new Te(P,S,I,C,!1)}case"lab":{const[c,d,p,f]=Ji(vr(e.lab,s.lab,l));return new Te(c,d,p,f,!1)}}}}Te.black=new Te(0,0,0,1),Te.white=new Te(1,1,1,1),Te.transparent=new Te(0,0,0,0),Te.red=new Te(1,0,0,1);class Ie{constructor(e,s,l){this.sensitivity=e?s?"variant":"case":s?"accent":"base",this.locale=l,this.collator=new Intl.Collator(this.locale?this.locale:[],{sensitivity:this.sensitivity,usage:"search"})}compare(e,s){return this.collator.compare(e,s)}resolvedLocale(){return new Intl.Collator(this.locale?this.locale:[]).resolvedOptions().locale}}const br=["bottom","center","top"];class Fe{constructor(e,s,l,c,d,p){this.text=e,this.image=s,this.scale=l,this.fontStack=c,this.textColor=d,this.verticalAlign=p}}class De{constructor(e){this.sections=e}static fromString(e){return new De([new Fe(e,null,null,null,null,null)])}isEmpty(){return 0===this.sections.length||!this.sections.some((e=>0!==e.text.length||e.image&&0!==e.image.name.length))}static factory(e){return e instanceof De?e:De.fromString(e)}toString(){return 0===this.sections.length?"":this.sections.map((e=>e.text)).join("")}}class ze{constructor(e){this.values=e.slice()}static parse(e){if(e instanceof ze)return e;if("number"==typeof e)return new ze([e,e,e,e]);if(Array.isArray(e)&&!(e.length<1||e.length>4)){for(const s of e)if("number"!=typeof s)return;switch(e.length){case 1:e=[e[0],e[0],e[0],e[0]];break;case 2:e=[e[0],e[1],e[0],e[1]];break;case 3:e=[e[0],e[1],e[2],e[1]]}return new ze(e)}}toString(){return JSON.stringify(this.values)}static interpolate(e,s,l){return new ze(vr(e.values,s.values,l))}}class Pe{constructor(e){this.values=e.slice()}static parse(e){if(e instanceof Pe)return e;if("number"==typeof e)return new Pe([e]);if(Array.isArray(e)){for(const s of e)if("number"!=typeof s)return;return new Pe(e)}}toString(){return JSON.stringify(this.values)}static interpolate(e,s,l){return new Pe(vr(e.values,s.values,l))}}class Be{constructor(e){this.values=e.slice()}static parse(e){if(e instanceof Be)return e;if("string"==typeof e){const s=Te.parse(e);if(!s)return;return new Be([s])}if(!Array.isArray(e))return;const s=[];for(const l of e){if("string"!=typeof l)return;const e=Te.parse(l);if(!e)return;s.push(e)}return new Be(s)}toString(){return JSON.stringify(this.values)}static interpolate(e,s,l,c="rgb"){const d=[];if(e.values.length!=s.values.length)throw new Error(`colorArray: Arrays have mismatched length (${e.values.length} vs. ${s.values.length}), cannot interpolate.`);for(let p=0;p=0&&e<=255&&"number"==typeof s&&s>=0&&s<=255&&"number"==typeof l&&l>=0&&l<=255?void 0===c||"number"==typeof c&&c>=0&&c<=1?null:`Invalid rgba value [${[e,s,l,c].join(", ")}]: 'a' must be between 0 and 1.`:`Invalid rgba value [${("number"==typeof c?[e,s,l,c]:[e,s,l]).join(", ")}]: 'r', 'g', and 'b' must be between 0 and 255.`}function Sr(e){if(null===e||"string"==typeof e||"boolean"==typeof e||"number"==typeof e||e instanceof Re||e instanceof Te||e instanceof Ie||e instanceof De||e instanceof ze||e instanceof Pe||e instanceof Be||e instanceof Le||e instanceof Oe)return!0;if(Array.isArray(e)){for(const s of e)if(!Sr(s))return!1;return!0}if("object"==typeof e){for(const s in e)if(!Sr(e[s]))return!1;return!0}return!1}function Cr(e){if(null===e)return ni;if("string"==typeof e)return ci;if("boolean"==typeof e)return ui;if("number"==typeof e)return li;if(e instanceof Te)return pi;if(e instanceof Re)return fi;if(e instanceof Ie)return gi;if(e instanceof De)return yi;if(e instanceof ze)return xi;if(e instanceof Pe)return bi;if(e instanceof Be)return vi;if(e instanceof Le)return Ii;if(e instanceof Oe)return wi;if(Array.isArray(e)){const s=e.length;let l;for(const s of e){const e=Cr(s);if(l){if(l===e)continue;l=_i;break}l=e}return Ei(l||_i,s)}return mi}function Ar(e){const s=typeof e;return null===e?"":"string"===s||"number"===s||"boolean"===s?String(e):e instanceof Te||e instanceof Re||e instanceof De||e instanceof ze||e instanceof Pe||e instanceof Be||e instanceof Le||e instanceof Oe?e.toString():JSON.stringify(e)}class je{constructor(e,s){this.type=e,this.value=s}static parse(e,s){if(2!==e.length)return s.error(`'literal' expression requires exactly one argument, but found ${e.length-1} instead.`);if(!Sr(e[1]))return s.error("invalid value");const l=e[1];let c=Cr(l);const d=s.expectedType;return"array"!==c.kind||0!==c.N||!d||"array"!==d.kind||"number"==typeof d.N&&0!==d.N||(c=d),new je(c,l)}evaluate(){return this.value}eachChild(){}outputDefined(){return!0}}const Dr={string:ci,number:li,boolean:ui,object:mi};class Xe{constructor(e,s){this.type=e,this.args=s}static parse(e,s){if(e.length<2)return s.error("Expected at least one argument.");let l,c=1;const d=e[0];if("array"===d){let d,p;if(e.length>2){const l=e[1];if("string"!=typeof l||!(l in Dr)||"object"===l)return s.error('The item type argument of "array" must be one of string, number, boolean',1);d=Dr[l],c++}else d=_i;if(e.length>3){if(null!==e[2]&&("number"!=typeof e[2]||e[2]<0||e[2]!==Math.floor(e[2])))return s.error('The length argument to "array" must be a positive integer literal',2);p=e[2],c++}l=Ei(d,p)}else{if(!Dr[d])throw new Error(`Types doesn't contain name = ${d}`);l=Dr[d]}const p=[];for(;ce.outputDefined()))}}const zr={"to-boolean":ui,"to-color":pi,"to-number":li,"to-string":ci};class Ze{constructor(e,s){this.type=e,this.args=s}static parse(e,s){if(e.length<2)return s.error("Expected at least one argument.");const l=e[0];if(!zr[l])throw new Error(`Can't parse ${l} as it is not part of the known types`);if(("to-boolean"===l||"to-string"===l)&&2!==e.length)return s.error("Expected one argument.");const c=zr[l],d=[];for(let l=1;l4?`Invalid rgba value ${JSON.stringify(s)}: expected an array containing either three or four numeric values.`:Pr(s[0],s[1],s[2],s[3]),!l))return new Te(s[0]/255,s[1]/255,s[2]/255,s[3])}throw new Ve(l||`Could not parse color from value '${"string"==typeof s?s:JSON.stringify(s)}'`)}case"padding":{let s;for(const l of this.args){s=l.evaluate(e);const c=ze.parse(s);if(c)return c}throw new Ve(`Could not parse padding from value '${"string"==typeof s?s:JSON.stringify(s)}'`)}case"numberArray":{let s;for(const l of this.args){s=l.evaluate(e);const c=Pe.parse(s);if(c)return c}throw new Ve(`Could not parse numberArray from value '${"string"==typeof s?s:JSON.stringify(s)}'`)}case"colorArray":{let s;for(const l of this.args){s=l.evaluate(e);const c=Be.parse(s);if(c)return c}throw new Ve(`Could not parse colorArray from value '${"string"==typeof s?s:JSON.stringify(s)}'`)}case"variableAnchorOffsetCollection":{let s;for(const l of this.args){s=l.evaluate(e);const c=Le.parse(s);if(c)return c}throw new Ve(`Could not parse variableAnchorOffsetCollection from value '${"string"==typeof s?s:JSON.stringify(s)}'`)}case"number":{let s=null;for(const l of this.args){if(s=l.evaluate(e),null===s)return 0;const c=Number(s);if(!isNaN(c))return c}throw new Ve(`Could not convert ${JSON.stringify(s)} to number.`)}case"formatted":return De.fromString(Ar(this.args[0].evaluate(e)));case"resolvedImage":return Oe.fromString(Ar(this.args[0].evaluate(e)));case"projectionDefinition":return this.args[0].evaluate(e);default:return Ar(this.args[0].evaluate(e))}}eachChild(e){this.args.forEach(e)}outputDefined(){return this.args.every((e=>e.outputDefined()))}}const kr=["Unknown","Point","LineString","Polygon"];class Ke{constructor(){this.globals=null,this.feature=null,this.featureState=null,this.formattedSection=null,this._parseColorCache=new Map,this.availableImages=null,this.canonical=null}id(){return this.feature&&"id"in this.feature?this.feature.id:null}geometryType(){return this.feature?"number"==typeof this.feature.type?kr[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||{}}parseColor(e){let s=this._parseColorCache.get(e);return s||(s=Te.parse(e),this._parseColorCache.set(e,s)),s}}class We{constructor(e,s,l=[],c,d=new Bt,p=[]){this.registry=e,this.path=l,this.key=l.map((e=>`[${e}]`)).join(""),this.scope=d,this.errors=p,this.expectedType=c,this._isConstant=s}parse(e,s,l,c,d={}){return s?this.concat(s,l,c)._parse(e,d):this._parse(e,d)}_parse(e,s){function l(e,s,l){return"assert"===l?new Xe(s,[e]):"coerce"===l?new Ze(s,[e]):e}if(null!==e&&"string"!=typeof e&&"boolean"!=typeof e&&"number"!=typeof e||(e=["literal",e]),Array.isArray(e)){if(0===e.length)return this.error('Expected an array with at least one element. If you wanted a literal array, use ["literal", []].');const c=e[0];if("string"!=typeof c)return this.error(`Expression name must be a string, but found ${typeof c} instead. If you wanted a literal array, use ["literal", [...]].`,0),null;const d=this.registry[c];if(d){let c=d.parse(e,this);if(!c)return null;if(this.expectedType){const e=this.expectedType,d=c.type;if("string"!==e.kind&&"number"!==e.kind&&"boolean"!==e.kind&&"object"!==e.kind&&"array"!==e.kind||"value"!==d.kind){if("projectionDefinition"===e.kind&&["string","array"].includes(d.kind)||["color","formatted","resolvedImage"].includes(e.kind)&&["value","string"].includes(d.kind)||["padding","numberArray"].includes(e.kind)&&["value","number","array"].includes(d.kind)||"colorArray"===e.kind&&["value","string","array"].includes(d.kind)||"variableAnchorOffsetCollection"===e.kind&&["value","array"].includes(d.kind))c=l(c,e,s.typeAnnotation||"coerce");else if(this.checkSubtype(e,d))return null}else c=l(c,e,s.typeAnnotation||"assert")}if(!(c instanceof je)&&"resolvedImage"!==c.type.kind&&this._isConstant(c)){const s=new Ke;try{c=new je(c.type,c.evaluate(s))}catch(e){return this.error(e.message),null}}return c}return this.error(`Unknown expression "${c}". If you wanted a literal array, use ["literal", [...]].`,0)}return this.error(void 0===e?"'undefined' value invalid. Use null instead.":"object"==typeof e?'Bare objects invalid. Use ["literal", {...}] instead.':`Expected an array, but found ${typeof e} instead.`)}concat(e,s,l){const c="number"==typeof e?this.path.concat(e):this.path,d=l?this.scope.concat(l):this.scope;return new We(this.registry,this._isConstant,c,s||null,d,this.errors)}error(e,...s){const l=`${this.key}${s.map((e=>`[${e}]`)).join("")}`;this.errors.push(new Pt(l,e))}checkSubtype(e,s){const l=Li(e,s);return l&&this.error(l),l}}class Je{constructor(e,s){this.type=s.type,this.bindings=[].concat(e),this.result=s}evaluate(e){return this.result.evaluate(e)}eachChild(e){for(const s of this.bindings)e(s[1]);e(this.result)}static parse(e,s){if(e.length<4)return s.error(`Expected at least 3 arguments, but found ${e.length-1} instead.`);const l=[];for(let c=1;c=l.length)throw new Ve(`Array index out of bounds: ${s} > ${l.length-1}.`);if(s!==Math.floor(s))throw new Ve(`Array index must be an integer, but found ${s} instead.`);return l[s]}eachChild(e){e(this.index),e(this.input)}outputDefined(){return!1}}class er{constructor(e,s){this.type=ui,this.needle=e,this.haystack=s}static parse(e,s){if(3!==e.length)return s.error(`Expected 2 arguments, but found ${e.length-1} instead.`);const l=s.parse(e[1],1,_i),c=s.parse(e[2],2,_i);return l&&c?Fi(l.type,[ui,ci,li,ni,_i])?new er(l,c):s.error(`Expected first argument to be of type boolean, string, number or null, but found ${Ci(l.type)} instead`):null}evaluate(e){const s=this.needle.evaluate(e),l=this.haystack.evaluate(e);if(!l)return!1;if(!Oi(s,["boolean","string","number","null"]))throw new Ve(`Expected first argument to be of type boolean, string, number or null, but found ${Ci(Cr(s))} instead.`);if(!Oi(l,["string","array"]))throw new Ve(`Expected second argument to be of type array or string, but found ${Ci(Cr(l))} instead.`);return l.indexOf(s)>=0}eachChild(e){e(this.needle),e(this.haystack)}outputDefined(){return!0}}class rr{constructor(e,s,l){this.type=li,this.needle=e,this.haystack=s,this.fromIndex=l}static parse(e,s){if(e.length<=2||e.length>=5)return s.error(`Expected 2 or 3 arguments, but found ${e.length-1} instead.`);const l=s.parse(e[1],1,_i),c=s.parse(e[2],2,_i);if(!l||!c)return null;if(!Fi(l.type,[ui,ci,li,ni,_i]))return s.error(`Expected first argument to be of type boolean, string, number or null, but found ${Ci(l.type)} instead`);if(4===e.length){const d=s.parse(e[3],3,li);return d?new rr(l,c,d):null}return new rr(l,c)}evaluate(e){const s=this.needle.evaluate(e),l=this.haystack.evaluate(e);if(!Oi(s,["boolean","string","number","null"]))throw new Ve(`Expected first argument to be of type boolean, string, number or null, but found ${Ci(Cr(s))} instead.`);let c;if(this.fromIndex&&(c=this.fromIndex.evaluate(e)),Oi(l,["string"])){const e=l.indexOf(s,c);return-1===e?-1:[...l.slice(0,e)].length}if(Oi(l,["array"]))return l.indexOf(s,c);throw new Ve(`Expected second argument to be of type array or string, but found ${Ci(Cr(l))} instead.`)}eachChild(e){e(this.needle),e(this.haystack),this.fromIndex&&e(this.fromIndex)}outputDefined(){return!1}}class nr{constructor(e,s,l,c,d,p){this.inputType=e,this.type=s,this.input=l,this.cases=c,this.outputs=d,this.otherwise=p}static parse(e,s){if(e.length<5)return s.error(`Expected at least 4 arguments, but found only ${e.length-1}.`);if(e.length%2!=1)return s.error("Expected an even number of arguments.");let l,c;s.expectedType&&"value"!==s.expectedType.kind&&(c=s.expectedType);const d={},p=[];for(let f=2;fNumber.MAX_SAFE_INTEGER)return g.error(`Branch labels must be integers no larger than ${Number.MAX_SAFE_INTEGER}.`);if("number"==typeof e&&Math.floor(e)!==e)return g.error("Numeric branch labels must be integer values.");if(l){if(g.checkSubtype(l,Cr(e)))return null}else l=Cr(e);if(void 0!==d[String(e)])return g.error("Branch labels must be unique.");d[String(e)]=p.length}const y=s.parse(_,f,c);if(!y)return null;c=c||y.type,p.push(y)}const f=s.parse(e[1],1,_i);if(!f)return null;const m=s.parse(e[e.length-1],e.length-1,c);return m?"value"!==f.type.kind&&s.concat(1).checkSubtype(l,f.type)?null:new nr(l,c,f,d,p,m):null}evaluate(e){const s=this.input.evaluate(e);return(Cr(s)===this.inputType&&this.outputs[this.cases[s]]||this.otherwise).evaluate(e)}eachChild(e){e(this.input),this.outputs.forEach(e),e(this.otherwise)}outputDefined(){return this.outputs.every((e=>e.outputDefined()))&&this.otherwise.outputDefined()}}class ir{constructor(e,s,l){this.type=e,this.branches=s,this.otherwise=l}static parse(e,s){if(e.length<4)return s.error(`Expected at least 3 arguments, but found only ${e.length-1}.`);if(e.length%2!=0)return s.error("Expected an odd number of arguments.");let l;s.expectedType&&"value"!==s.expectedType.kind&&(l=s.expectedType);const c=[];for(let d=1;ds.outputDefined()))&&this.otherwise.outputDefined()}}class sr{constructor(e,s,l,c){this.type=e,this.input=s,this.beginIndex=l,this.endIndex=c}static parse(e,s){if(e.length<=2||e.length>=5)return s.error(`Expected 2 or 3 arguments, but found ${e.length-1} instead.`);const l=s.parse(e[1],1,_i),c=s.parse(e[2],2,li);if(!l||!c)return null;if(!Fi(l.type,[Ei(_i),ci,_i]))return s.error(`Expected first argument to be of type array or string, but found ${Ci(l.type)} instead`);if(4===e.length){const d=s.parse(e[3],3,li);return d?new sr(l.type,l,c,d):null}return new sr(l.type,l,c)}evaluate(e){const s=this.input.evaluate(e),l=this.beginIndex.evaluate(e);let c;if(this.endIndex&&(c=this.endIndex.evaluate(e)),Oi(s,["string"]))return[...s].slice(l,c).join("");if(Oi(s,["array"]))return s.slice(l,c);throw new Ve(`Expected first argument to be of type array or string, but found ${Ci(Cr(s))} instead.`)}eachChild(e){e(this.input),e(this.beginIndex),this.endIndex&&e(this.endIndex)}outputDefined(){return!1}}function Rr(e,s){const l=e.length-1;let c,d,p=0,f=l,m=0;for(;p<=f;)if(m=Math.floor((p+f)/2),c=e[m],d=e[m+1],c<=s){if(m===l||ss))throw new Ve("Input is not a number.");f=m-1}return 0}class or{constructor(e,s,l){this.type=e,this.input=s,this.labels=[],this.outputs=[];for(const[e,s]of l)this.labels.push(e),this.outputs.push(s)}static parse(e,s){if(e.length-1<4)return s.error(`Expected at least 4 arguments, but found only ${e.length-1}.`);if((e.length-1)%2!=0)return s.error("Expected an even number of arguments.");const l=s.parse(e[1],1,li);if(!l)return null;const c=[];let d=null;s.expectedType&&"value"!==s.expectedType.kind&&(d=s.expectedType);for(let l=1;l=p)return s.error('Input/output pairs for "step" expressions must be arranged with input values in strictly ascending order.',m);const g=s.parse(f,_,d);if(!g)return null;d=d||g.type,c.push([p,g])}return new or(d,l,c)}evaluate(e){const s=this.labels,l=this.outputs;if(1===s.length)return l[0].evaluate(e);const c=this.input.evaluate(e);if(c<=s[0])return l[0].evaluate(e);const d=s.length;return c>=s[d-1]?l[d-1].evaluate(e):l[Rr(s,c)].evaluate(e)}eachChild(e){e(this.input);for(const s of this.outputs)e(s)}outputDefined(){return this.outputs.every((e=>e.outputDefined()))}}function Lr(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Br,Or,Vr=function(){if(Or)return Br;function s(s,l,c,d){(this||e).cx=3*s,(this||e).bx=3*(c-s)-(this||e).cx,(this||e).ax=1-(this||e).cx-(this||e).bx,(this||e).cy=3*l,(this||e).by=3*(d-l)-(this||e).cy,(this||e).ay=1-(this||e).cy-(this||e).by,(this||e).p1x=s,(this||e).p1y=l,(this||e).p2x=c,(this||e).p2y=d}return Or=1,Br=s,s.prototype={sampleCurveX:function(s){return(((this||e).ax*s+(this||e).bx)*s+(this||e).cx)*s},sampleCurveY:function(s){return(((this||e).ay*s+(this||e).by)*s+(this||e).cy)*s},sampleCurveDerivativeX:function(s){return(3*(this||e).ax*s+2*(this||e).bx)*s+(this||e).cx},solveCurveX:function(e,s){if(void 0===s&&(s=1e-6),e<0)return 0;if(e>1)return 1;for(var l=e,c=0;c<8;c++){var d=this.sampleCurveX(l)-e;if(Math.abs(d)d?f=l:m=l,l=.5*(m-f)+f;return l},solve:function(e,s){return this.sampleCurveY(this.solveCurveX(e,s))}},Br}(),jr=Lr(Vr);class fr{constructor(e,s,l,c,d){this.type=e,this.operator=s,this.interpolation=l,this.input=c,this.labels=[],this.outputs=[];for(const[e,s]of d)this.labels.push(e),this.outputs.push(s)}static interpolationFactor(e,s,l,c){let d=0;if("exponential"===e.name)d=Nr(s,e.base,l,c);else if("linear"===e.name)d=Nr(s,1,l,c);else if("cubic-bezier"===e.name){const p=e.controlPoints;d=new jr(p[0],p[1],p[2],p[3]).solve(Nr(s,1,l,c))}return d}static parse(e,s){let[l,c,d,...p]=e;if(!Array.isArray(c)||0===c.length)return s.error("Expected an interpolation type expression.",1);if("linear"===c[0])c={name:"linear"};else if("exponential"===c[0]){const e=c[1];if("number"!=typeof e)return s.error("Exponential interpolation requires a numeric base.",1,1);c={name:"exponential",base:e}}else{if("cubic-bezier"!==c[0])return s.error(`Unknown interpolation type ${String(c[0])}`,1,0);{const e=c.slice(1);if(4!==e.length||e.some((e=>"number"!=typeof e||e<0||e>1)))return s.error("Cubic bezier interpolation requires four numeric arguments with values between 0 and 1.",1);c={name:"cubic-bezier",controlPoints:e}}}if(e.length-1<4)return s.error(`Expected at least 4 arguments, but found only ${e.length-1}.`);if((e.length-1)%2!=0)return s.error("Expected an even number of arguments.");if(d=s.parse(d,2,li),!d)return null;const f=[];let m=null;"interpolate-hcl"!==l&&"interpolate-lab"!==l||s.expectedType==vi?s.expectedType&&"value"!==s.expectedType.kind&&(m=s.expectedType):m=pi;for(let e=0;e=l)return s.error('Input/output pairs for "interpolate" expressions must be arranged with input values in strictly ascending order.',d);const g=s.parse(c,_,m);if(!g)return null;m=m||g.type,f.push([l,g])}return Vi(m,li)||Vi(m,fi)||Vi(m,pi)||Vi(m,xi)||Vi(m,bi)||Vi(m,vi)||Vi(m,Ii)||Vi(m,Ei(li))?new fr(m,l,c,d,f):s.error(`Type ${Ci(m)} is not interpolatable.`)}evaluate(e){const s=this.labels,l=this.outputs;if(1===s.length)return l[0].evaluate(e);const c=this.input.evaluate(e);if(c<=s[0])return l[0].evaluate(e);const d=s.length;if(c>=s[d-1])return l[d-1].evaluate(e);const p=Rr(s,c),f=fr.interpolationFactor(this.interpolation,c,s[p],s[p+1]),m=l[p].evaluate(e),_=l[p+1].evaluate(e);switch(this.operator){case"interpolate":switch(this.type.kind){case"number":return xr(m,_,f);case"color":return Te.interpolate(m,_,f);case"padding":return ze.interpolate(m,_,f);case"colorArray":return Be.interpolate(m,_,f);case"numberArray":return Pe.interpolate(m,_,f);case"variableAnchorOffsetCollection":return Le.interpolate(m,_,f);case"array":return vr(m,_,f);case"projectionDefinition":return Re.interpolate(m,_,f)}case"interpolate-hcl":switch(this.type.kind){case"color":return Te.interpolate(m,_,f,"hcl");case"colorArray":return Be.interpolate(m,_,f,"hcl")}case"interpolate-lab":switch(this.type.kind){case"color":return Te.interpolate(m,_,f,"lab");case"colorArray":return Be.interpolate(m,_,f,"lab")}}}eachChild(e){e(this.input);for(const s of this.outputs)e(s)}outputDefined(){return this.outputs.every((e=>e.outputDefined()))}}function Nr(e,s,l,c){const d=c-l,p=e-l;return 0===d?0:1===s?p/d:(Math.pow(s,p)-1)/(Math.pow(s,d)-1)}const Gr={color:Te.interpolate,number:xr,padding:ze.interpolate,numberArray:Pe.interpolate,colorArray:Be.interpolate,variableAnchorOffsetCollection:Le.interpolate,array:vr};class mr{constructor(e,s){this.type=e,this.args=s}static parse(e,s){if(e.length<2)return s.error("Expected at least one argument.");let l=null;const c=s.expectedType;c&&"value"!==c.kind&&(l=c);const d=[];for(const c of e.slice(1)){const e=s.parse(c,1+d.length,l,void 0,{typeAnnotation:"omit"});if(!e)return null;l=l||e.type,d.push(e)}if(!l)throw new Error("No output type");const p=c&&d.some((e=>Li(c,e.type)));return new mr(p?_i:l,d)}evaluate(e){let s,l=null,c=0;for(const d of this.args)if(c++,l=d.evaluate(e),l&&l instanceof Oe&&!l.available&&(s||(s=l.name),l=null,c===this.args.length&&(l=s)),null!==l)break;return l}eachChild(e){this.args.forEach(e)}outputDefined(){return this.args.every((e=>e.outputDefined()))}}function Ur(e,s){return"=="===e||"!="===e?"boolean"===s.kind||"string"===s.kind||"number"===s.kind||"null"===s.kind||"value"===s.kind:"string"===s.kind||"number"===s.kind||"value"===s.kind}function Zr(e,s,l,c){return 0===c.compare(s,l)}function Wr(e,s,l){const c="=="!==e&&"!="!==e;return class i{constructor(e,s,l){this.type=ui,this.lhs=e,this.rhs=s,this.collator=l,this.hasUntypedArgument="value"===e.type.kind||"value"===s.type.kind}static parse(e,s){if(3!==e.length&&4!==e.length)return s.error("Expected two or three arguments.");const l=e[0];let d=s.parse(e[1],1,_i);if(!d)return null;if(!Ur(l,d.type))return s.concat(1).error(`"${l}" comparisons are not supported for type '${Ci(d.type)}'.`);let p=s.parse(e[2],2,_i);if(!p)return null;if(!Ur(l,p.type))return s.concat(2).error(`"${l}" comparisons are not supported for type '${Ci(p.type)}'.`);if(d.type.kind!==p.type.kind&&"value"!==d.type.kind&&"value"!==p.type.kind)return s.error(`Cannot compare types '${Ci(d.type)}' and '${Ci(p.type)}'.`);c&&("value"===d.type.kind&&"value"!==p.type.kind?d=new Xe(p.type,[d]):"value"!==d.type.kind&&"value"===p.type.kind&&(p=new Xe(d.type,[p])));let f=null;if(4===e.length){if("string"!==d.type.kind&&"string"!==p.type.kind&&"value"!==d.type.kind&&"value"!==p.type.kind)return s.error("Cannot use collator to compare non-string types.");if(f=s.parse(e[3],3,gi),!f)return null}return new i(d,p,f)}evaluate(d){const p=this.lhs.evaluate(d),f=this.rhs.evaluate(d);if(c&&this.hasUntypedArgument){const s=Cr(p),l=Cr(f);if(s.kind!==l.kind||"string"!==s.kind&&"number"!==s.kind)throw new Ve(`Expected arguments for "${e}" to be (string, string) or (number, number), but found (${s.kind}, ${l.kind}) instead.`)}if(this.collator&&!c&&this.hasUntypedArgument){const e=Cr(p),l=Cr(f);if("string"!==e.kind||"string"!==l.kind)return s(d,p,f)}return this.collator?l(d,p,f,this.collator.evaluate(d)):s(d,p,f)}eachChild(e){e(this.lhs),e(this.rhs),this.collator&&e(this.collator)}outputDefined(){return!0}}}const Xr=Wr("==",(function(e,s,l){return s===l}),Zr),Yr=Wr("!=",(function(e,s,l){return s!==l}),(function(e,s,l,c){return!Zr(0,s,l,c)})),Kr=Wr("<",(function(e,s,l){return s",(function(e,s,l){return s>l}),(function(e,s,l,c){return c.compare(s,l)>0})),Jr=Wr("<=",(function(e,s,l){return s<=l}),(function(e,s,l,c){return c.compare(s,l)<=0})),en=Wr(">=",(function(e,s,l){return s>=l}),(function(e,s,l,c){return c.compare(s,l)>=0}));class Er{constructor(e,s,l){this.type=gi,this.locale=l,this.caseSensitive=e,this.diacriticSensitive=s}static parse(e,s){if(2!==e.length)return s.error("Expected one argument.");const l=e[1];if("object"!=typeof l||Array.isArray(l))return s.error("Collator options argument must be an object.");const c=s.parse(void 0!==l["case-sensitive"]&&l["case-sensitive"],1,ui);if(!c)return null;const d=s.parse(void 0!==l["diacritic-sensitive"]&&l["diacritic-sensitive"],1,ui);if(!d)return null;let p=null;return l.locale&&(p=s.parse(l.locale,1,ci),!p)?null:new Er(c,d,p)}evaluate(e){return new Ie(this.caseSensitive.evaluate(e),this.diacriticSensitive.evaluate(e),this.locale?this.locale.evaluate(e):null)}eachChild(e){e(this.caseSensitive),e(this.diacriticSensitive),this.locale&&e(this.locale)}outputDefined(){return!1}}class Tr{constructor(e,s,l,c,d){this.type=ci,this.number=e,this.locale=s,this.currency=l,this.minFractionDigits=c,this.maxFractionDigits=d}static parse(e,s){if(3!==e.length)return s.error("Expected two arguments.");const l=s.parse(e[1],1,li);if(!l)return null;const c=e[2];if("object"!=typeof c||Array.isArray(c))return s.error("NumberFormat options argument must be an object.");let d=null;if(c.locale&&(d=s.parse(c.locale,1,ci),!d))return null;let p=null;if(c.currency&&(p=s.parse(c.currency,1,ci),!p))return null;let f=null;if(c["min-fraction-digits"]&&(f=s.parse(c["min-fraction-digits"],1,li),!f))return null;let m=null;return c["max-fraction-digits"]&&(m=s.parse(c["max-fraction-digits"],1,li),!m)?null:new Tr(l,d,p,f,m)}evaluate(e){return new Intl.NumberFormat(this.locale?this.locale.evaluate(e):[],{style:this.currency?"currency":"decimal",currency:this.currency?this.currency.evaluate(e):void 0,minimumFractionDigits:this.minFractionDigits?this.minFractionDigits.evaluate(e):void 0,maximumFractionDigits:this.maxFractionDigits?this.maxFractionDigits.evaluate(e):void 0}).format(this.number.evaluate(e))}eachChild(e){e(this.number),this.locale&&e(this.locale),this.currency&&e(this.currency),this.minFractionDigits&&e(this.minFractionDigits),this.maxFractionDigits&&e(this.maxFractionDigits)}outputDefined(){return!1}}class Ir{constructor(e){this.type=yi,this.sections=e}static parse(e,s){if(e.length<2)return s.error("Expected at least one argument.");const l=e[1];if(!Array.isArray(l)&&"object"==typeof l)return s.error("First argument must be an image or text section.");const c=[];let d=!1;for(let l=1;l<=e.length-1;++l){const p=e[l];if(d&&"object"==typeof p&&!Array.isArray(p)){d=!1;let e=null;if(p["font-scale"]&&(e=s.parse(p["font-scale"],1,li),!e))return null;let l=null;if(p["text-font"]&&(l=s.parse(p["text-font"],1,Ei(ci)),!l))return null;let f=null;if(p["text-color"]&&(f=s.parse(p["text-color"],1,pi),!f))return null;let m=null;if(p["vertical-align"]){if("string"==typeof p["vertical-align"]&&!br.includes(p["vertical-align"]))return s.error(`'vertical-align' must be one of: 'bottom', 'center', 'top' but found '${p["vertical-align"]}' instead.`);if(m=s.parse(p["vertical-align"],1,ci),!m)return null}const _=c[c.length-1];_.scale=e,_.font=l,_.textColor=f,_.verticalAlign=m}else{const p=s.parse(e[l],1,_i);if(!p)return null;const f=p.type.kind;if("string"!==f&&"value"!==f&&"null"!==f&&"resolvedImage"!==f)return s.error("Formatted text type must be 'string', 'value', 'image' or 'null'.");d=!0,c.push({content:p,scale:null,font:null,textColor:null,verticalAlign:null})}}return new Ir(c)}evaluate(e){return new De(this.sections.map((s=>{const l=s.content.evaluate(e);return Cr(l)===wi?new Fe("",l,null,null,null,s.verticalAlign?s.verticalAlign.evaluate(e):null):new Fe(Ar(l),null,s.scale?s.scale.evaluate(e):null,s.font?s.font.evaluate(e).join(","):null,s.textColor?s.textColor.evaluate(e):null,s.verticalAlign?s.verticalAlign.evaluate(e):null)})))}eachChild(e){for(const s of this.sections)e(s.content),s.scale&&e(s.scale),s.font&&e(s.font),s.textColor&&e(s.textColor),s.verticalAlign&&e(s.verticalAlign)}outputDefined(){return!1}}class Mr{constructor(e){this.type=wi,this.input=e}static parse(e,s){if(2!==e.length)return s.error("Expected two arguments.");const l=s.parse(e[1],1,ci);return l?new Mr(l):s.error("No image name provided.")}evaluate(e){const s=this.input.evaluate(e),l=Oe.fromString(s);return l&&e.availableImages&&(l.available=e.availableImages.indexOf(s)>-1),l}eachChild(e){e(this.input)}outputDefined(){return!1}}class Fr{constructor(e){this.type=li,this.input=e}static parse(e,s){if(2!==e.length)return s.error(`Expected 1 argument, but found ${e.length-1} instead.`);const l=s.parse(e[1],1);return l?"array"!==l.type.kind&&"string"!==l.type.kind&&"value"!==l.type.kind?s.error(`Expected argument of type string or array, but found ${Ci(l.type)} instead.`):new Fr(l):null}evaluate(e){const s=this.input.evaluate(e);if("string"==typeof s)return[...s].length;if(Array.isArray(s))return s.length;throw new Ve(`Expected value to be of type string or array, but found ${Ci(Cr(s))} instead.`)}eachChild(e){e(this.input)}outputDefined(){return!1}}const tn=8192;function rn(e,s){const l=(180+e[0])/360,c=(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+e[1]*Math.PI/360)))/360,d=Math.pow(2,s.z);return[Math.round(l*d*tn),Math.round(c*d*tn)]}function nn(e,s){const l=Math.pow(2,s.z);return[(d=(e[0]/tn+s.x)/l,360*d-180),(c=(e[1]/tn+s.y)/l,360/Math.PI*Math.atan(Math.exp((180-360*c)*Math.PI/180))-90)];var c,d}function sn(e,s){e[0]=Math.min(e[0],s[0]),e[1]=Math.min(e[1],s[1]),e[2]=Math.max(e[2],s[0]),e[3]=Math.max(e[3],s[1])}function an(e,s){return!(e[0]<=s[0]||e[2]>=s[2]||e[1]<=s[1]||e[3]>=s[3])}function ln(e,s,l){const c=e[0]-s[0],d=e[1]-s[1],p=e[0]-l[0],f=e[1]-l[1];return c*f-p*d==0&&c*p<=0&&d*f<=0}function cn(e,s,l,c){return 0!=(d=[c[0]-l[0],c[1]-l[1]])[0]*(p=[s[0]-e[0],s[1]-e[1]])[1]-d[1]*p[0]&&!(!mn(e,s,l,c)||!mn(l,c,e,s));var d,p}function hn(e,s,l){for(const c of l)for(let l=0;l(d=e)[1]!=(f=m[s+1])[1]>d[1]&&d[0]<(f[0]-p[0])*(d[1]-p[1])/(f[1]-p[1])+p[0]&&(c=!c)}var d,p,f;return c}function dn(e,s){for(const l of s)if(un(e,l))return!0;return!1}function pn(e,s){for(const l of e)if(!un(l,s))return!1;for(let l=0;l0&&m<0||f<0&&m>0}function _n(e,s,l){const c=[];for(let d=0;dl[2]){const s=.5*c;let d=e[0]-l[0]>s?-c:l[0]-e[0]>s?c:0;0===d&&(d=e[0]-l[2]>s?-c:l[2]-e[0]>s?c:0),e[0]+=d}sn(s,e)}function xn(e,s,l,c){const d=Math.pow(2,c.z)*tn,p=[c.x*tn,c.y*tn],f=[];for(const c of e)for(const e of c){const c=[e.x+p[0],e.y+p[1]];yn(c,s,l,d),f.push(c)}return f}function vn(e,s,l,c){const d=Math.pow(2,c.z)*tn,p=[c.x*tn,c.y*tn],f=[];for(const l of e){const e=[];for(const c of l){const l=[c.x+p[0],c.y+p[1]];sn(s,l),e.push(l)}f.push(e)}if(s[2]-s[0]<=d/2){(m=s)[0]=m[1]=1/0,m[2]=m[3]=-1/0;for(const e of f)for(const c of e)yn(c,s,l,d)}var m;return f}class Hr{constructor(e,s){this.type=ui,this.geojson=e,this.geometries=s}static parse(e,s){if(2!==e.length)return s.error(`'within' expression requires exactly one argument, but found ${e.length-1} instead.`);if(Sr(e[1])){const s=e[1];if("FeatureCollection"===s.type){const e=[];for(const l of s.features){const{type:s,coordinates:c}=l.geometry;"Polygon"===s&&e.push(c),"MultiPolygon"===s&&e.push(...c)}if(e.length)return new Hr(s,{type:"MultiPolygon",coordinates:e})}else if("Feature"===s.type){const e=s.geometry.type;if("Polygon"===e||"MultiPolygon"===e)return new Hr(s,s.geometry)}else if("Polygon"===s.type||"MultiPolygon"===s.type)return new Hr(s,s)}return s.error("'within' expression requires valid geojson object that contains polygon geometry type.")}evaluate(e){if(null!=e.geometry()&&null!=e.canonicalID()){if("Point"===e.geometryType())return function(e,s){const l=[1/0,1/0,-1/0,-1/0],c=[1/0,1/0,-1/0,-1/0],d=e.canonicalID();if("Polygon"===s.type){const p=_n(s.coordinates,c,d),f=xn(e.geometry(),l,c,d);if(!an(l,c))return!1;for(const e of f)if(!un(e,p))return!1}if("MultiPolygon"===s.type){const p=gn(s.coordinates,c,d),f=xn(e.geometry(),l,c,d);if(!an(l,c))return!1;for(const e of f)if(!dn(e,p))return!1}return!0}(e,this.geometries);if("LineString"===e.geometryType())return function(e,s){const l=[1/0,1/0,-1/0,-1/0],c=[1/0,1/0,-1/0,-1/0],d=e.canonicalID();if("Polygon"===s.type){const p=_n(s.coordinates,c,d),f=vn(e.geometry(),l,c,d);if(!an(l,c))return!1;for(const e of f)if(!pn(e,p))return!1}if("MultiPolygon"===s.type){const p=gn(s.coordinates,c,d),f=vn(e.geometry(),l,c,d);if(!an(l,c))return!1;for(const e of f)if(!fn(e,p))return!1}return!0}(e,this.geometries)}return!1}eachChild(){}outputDefined(){return!0}}let bn=class{constructor(e=[],s=(e,s)=>es?1:0){if(this.data=e,this.length=this.data.length,this.compare=s,this.length>0)for(let e=(this.length>>1)-1;e>=0;e--)this._down(e)}push(e){this.data.push(e),this._up(this.length++)}pop(){if(0===this.length)return;const e=this.data[0],s=this.data.pop();return--this.length>0&&(this.data[0]=s,this._down(0)),e}peek(){return this.data[0]}_up(e){const{data:s,compare:l}=this,c=s[e];for(;e>0;){const d=e-1>>1,p=s[d];if(l(c,p)>=0)break;s[e]=p,e=d}s[e]=c}_down(e){const{data:s,compare:l}=this,c=this.length>>1,d=s[e];for(;e=0)break;s[e]=s[c],e=c}s[e]=d}};function wn(e,s,l=0,c=e.length-1,d=Pn){for(;c>l;){if(c-l>600){const p=c-l+1,f=s-l+1,m=Math.log(p),_=.5*Math.exp(2*m/3),g=.5*Math.sqrt(m*_*(p-_)/p)*(f-p/2<0?-1:1);wn(e,s,Math.max(l,Math.floor(s-f*_/p+g)),Math.min(c,Math.floor(s+(p-f)*_/p+g)),d)}const p=e[s];let f=l,m=c;for(Tn(e,l,s),d(e[c],p)>0&&Tn(e,l,c);f0;)m--}0===d(e[l],p)?Tn(e,l,m):(m++,Tn(e,m,c)),m<=s&&(l=m+1),s<=m&&(c=m-1)}}function Tn(e,s,l){const c=e[s];e[s]=e[l],e[l]=c}function Pn(e,s){return es?1:0}function Sn(e,s){if(e.length<=1)return[e];const l=[];let c,d;for(const s of e){const e=En(s);0!==e&&(s.area=Math.abs(e),void 0===d&&(d=e<0),d===e<0?(c&&l.push(c),c=[s]):c.push(s))}if(c&&l.push(c),s>1)for(let e=0;e1?(_=e[m+1][0],g=e[m+1][1]):T>0&&(_+=y/this.kx*T,g+=b/this.ky*T)),y=this.wrap(s[0]-_)*this.kx,b=(s[1]-g)*this.ky;const P=y*y+b*b;P180;)e-=360;return e}}function kn(e,s){return s[0]-e[0]}function Rn(e){return e[1]-e[0]+1}function Ln(e,s){return e[1]>=e[0]&&e[1]e[1])return[null,null];const l=Rn(e);if(s){if(2===l)return[e,null];const s=Math.floor(l/2);return[[e[0],e[0]+s],[e[0]+s,e[1]]]}if(1===l)return[e,null];const c=Math.floor(l/2)-1;return[[e[0],e[0]+c],[e[0]+c+1,e[1]]]}function On(e,s){if(!Ln(s,e.length))return[1/0,1/0,-1/0,-1/0];const l=[1/0,1/0,-1/0,-1/0];for(let c=s[0];c<=s[1];++c)sn(l,e[c]);return l}function Vn(e){const s=[1/0,1/0,-1/0,-1/0];for(const l of e)for(const e of l)sn(s,e);return s}function jn(e){return e[0]!==-1/0&&e[1]!==-1/0&&e[2]!==1/0&&e[3]!==1/0}function Nn(e,s,l){if(!jn(e)||!jn(s))return NaN;let c=0,d=0;return e[2]s[2]&&(c=e[0]-s[2]),e[1]>s[3]&&(d=e[1]-s[3]),e[3]=c)return c;if(an(d,p)){if(Hn(e,s))return 0}else if(Hn(s,e))return 0;let f=1/0;for(const c of e)for(let e=0,d=c.length,p=d-1;e0;){const d=f.pop();if(d[0]>=p)continue;const _=d[1],g=s?50:100;if(Rn(_)<=g){if(!Ln(_,e.length))return NaN;if(s){const s=Wn(e,_,l,c);if(isNaN(s)||0===s)return s;p=Math.min(p,s)}else for(let s=_[0];s<=_[1];++s){const d=$n(e[s],l,c);if(p=Math.min(p,d),0===p)return 0}}else{const l=Bn(_,s);Yn(f,p,c,e,m,l[0]),Yn(f,p,c,e,m,l[1])}}return p}function Jn(e,s,l,c,d,p=1/0){let f=Math.min(p,d.distance(e[0],l[0]));if(0===f)return f;const m=new bn([[0,[0,e.length-1],[0,l.length-1]]],kn);for(;m.length>0;){const p=m.pop();if(p[0]>=f)continue;const _=p[1],g=p[2],y=s?50:100,b=c?50:100;if(Rn(_)<=y&&Rn(g)<=b){if(!Ln(_,e.length)&&Ln(g,l.length))return NaN;let p;if(s&&c)p=qn(e,_,l,g,d),f=Math.min(f,p);else if(s&&!c){const s=e.slice(_[0],_[1]+1);for(let e=g[0];e<=g[1];++e)if(p=Gn(l[e],s,d),f=Math.min(f,p),0===f)return f}else if(!s&&c){const s=l.slice(g[0],g[1]+1);for(let l=_[0];l<=_[1];++l)if(p=Gn(e[l],s,d),f=Math.min(f,p),0===f)return f}else p=Zn(e,_,l,g,d),f=Math.min(f,p)}else{const p=Bn(_,s),y=Bn(g,c);Kn(m,f,d,e,l,p[0],y[0]),Kn(m,f,d,e,l,p[0],y[1]),Kn(m,f,d,e,l,p[1],y[0]),Kn(m,f,d,e,l,p[1],y[1])}}return f}function es(e){return"MultiPolygon"===e.type?e.coordinates.map((e=>({type:"Polygon",coordinates:e}))):"MultiLineString"===e.type?e.coordinates.map((e=>({type:"LineString",coordinates:e}))):"MultiPoint"===e.type?e.coordinates.map((e=>({type:"Point",coordinates:e}))):[e]}class Mn{constructor(e,s){this.type=li,this.geojson=e,this.geometries=s}static parse(e,s){if(2!==e.length)return s.error(`'distance' expression requires exactly one argument, but found ${e.length-1} instead.`);if(Sr(e[1])){const s=e[1];if("FeatureCollection"===s.type)return new Mn(s,s.features.map((e=>es(e.geometry))).flat());if("Feature"===s.type)return new Mn(s,es(s.geometry));if("type"in s&&"coordinates"in s)return new Mn(s,es(s))}return s.error("'distance' expression requires valid geojson object that contains polygon geometry type.")}evaluate(e){if(null!=e.geometry()&&null!=e.canonicalID()){if("Point"===e.geometryType())return function(e,s){const l=e.geometry(),c=l.flat().map((s=>nn([s.x,s.y],e.canonical)));if(0===l.length)return NaN;const d=new on(c[0][1]);let p=1/0;for(const e of s){switch(e.type){case"Point":p=Math.min(p,Jn(c,!1,[e.coordinates],!1,d,p));break;case"LineString":p=Math.min(p,Jn(c,!1,e.coordinates,!0,d,p));break;case"Polygon":p=Math.min(p,Qn(c,!1,e.coordinates,d,p))}if(0===p)return p}return p}(e,this.geometries);if("LineString"===e.geometryType())return function(e,s){const l=e.geometry(),c=l.flat().map((s=>nn([s.x,s.y],e.canonical)));if(0===l.length)return NaN;const d=new on(c[0][1]);let p=1/0;for(const e of s){switch(e.type){case"Point":p=Math.min(p,Jn(c,!0,[e.coordinates],!1,d,p));break;case"LineString":p=Math.min(p,Jn(c,!0,e.coordinates,!0,d,p));break;case"Polygon":p=Math.min(p,Qn(c,!0,e.coordinates,d,p))}if(0===p)return p}return p}(e,this.geometries);if("Polygon"===e.geometryType())return function(e,s){const l=e.geometry();if(0===l.length||0===l[0].length)return NaN;const c=Sn(l,0).map((s=>s.map((s=>s.map((s=>nn([s.x,s.y],e.canonical))))))),d=new on(c[0][0][0][1]);let p=1/0;for(const e of s)for(const s of c){switch(e.type){case"Point":p=Math.min(p,Qn([e.coordinates],!1,s,d,p));break;case"LineString":p=Math.min(p,Qn(e.coordinates,!0,s,d,p));break;case"Polygon":p=Math.min(p,Xn(s,e.coordinates,d,p))}if(0===p)return p}return p}(e,this.geometries)}return NaN}eachChild(){}outputDefined(){return!0}}class Fn{constructor(e){this.type=_i,this.key=e}static parse(e,s){if(2!==e.length)return s.error(`Expected 1 argument, but found ${e.length-1} instead.`);const l=e[1];return null==l?s.error("Global state property must be defined."):"string"!=typeof l?s.error(`Global state property must be string, but found ${typeof e[1]} instead.`):new Fn(l)}evaluate(e){var s;const l=null===(s=e.globals)||void 0===s?void 0:s.globalState;return l&&0!==Object.keys(l).length?ur(l,this.key):null}eachChild(){}outputDefined(){return!1}}const ns={"==":Xr,"!=":Yr,">":Qr,"<":Kr,">=":en,"<=":Jr,array:Xe,at:tr,boolean:Xe,case:ir,coalesce:mr,collator:Er,format:Ir,image:Mr,in:er,"index-of":rr,interpolate:fr,"interpolate-hcl":fr,"interpolate-lab":fr,length:Fr,let:Je,literal:je,match:nr,number:Xe,"number-format":Tr,object:Xe,slice:sr,step:or,string:Xe,"to-boolean":Ze,"to-color":Ze,"to-number":Ze,"to-string":Ze,var:Qe,within:Hr,distance:Mn,"global-state":Fn};class zn{constructor(e,s,l,c){this.name=e,this.type=s,this._evaluate=l,this.args=c}evaluate(e){return this._evaluate(e,this.args)}eachChild(e){this.args.forEach(e)}outputDefined(){return!1}static parse(e,s){const l=e[0],c=zn.definitions[l];if(!c)return s.error(`Unknown expression "${l}". If you wanted a literal array, use ["literal", [...]].`,0);const d=Array.isArray(c)?c[0]:c.type,p=Array.isArray(c)?[[c[1],c[2]]]:c.overloads,f=p.filter((([s])=>!Array.isArray(s)||s.length===e.length-1));let m=null;for(const[c,p]of f){m=new We(s.registry,ps,s.path,null,s.scope);const f=[];let _=!1;for(let s=1;s{return s=e,Array.isArray(s)?`(${s.map(Ci).join(", ")})`:`(${Ci(s.type)}...)`;var s})).join(" | "),c=[];for(let l=1;l{l=s?l&&ps(e):l&&e instanceof je})),!!l&&fs(e)&&gs(e,["zoom","heatmap-density","elevation","line-progress","accumulated","is-supported-script"])}function fs(e){if(e instanceof zn){if("get"===e.name&&1===e.args.length)return!1;if("feature-state"===e.name)return!1;if("has"===e.name&&1===e.args.length)return!1;if("properties"===e.name||"geometry-type"===e.name||"id"===e.name)return!1;if(/^filter-/.test(e.name))return!1}if(e instanceof Hr)return!1;if(e instanceof Mn)return!1;let s=!0;return e.eachChild((e=>{s&&!fs(e)&&(s=!1)})),s}function _s(e){if(e instanceof zn&&"feature-state"===e.name)return!1;let s=!0;return e.eachChild((e=>{s&&!_s(e)&&(s=!1)})),s}function gs(e,s){if(e instanceof zn&&s.indexOf(e.name)>=0)return!1;let l=!0;return e.eachChild((e=>{l&&!gs(e,s)&&(l=!1)})),l}function ys(e){return{result:"success",value:e}}function vs(e){return{result:"error",value:e}}function bs(e){return"data-driven"===e["property-type"]||"cross-faded-data-driven"===e["property-type"]}function ws(e){return!!e.expression&&e.expression.parameters.indexOf("zoom")>-1}function Ts(e){return!!e.expression&&e.expression.interpolated}function Ss(e){return e instanceof Number?"number":e instanceof String?"string":e instanceof Boolean?"boolean":Array.isArray(e)?"array":null===e?"null":typeof e}function Ms(e){return"object"==typeof e&&null!==e&&!Array.isArray(e)&&Cr(e)===mi}function Is(e){return e}function Es(e,s){const l=e.stops&&"object"==typeof e.stops[0][0],c=l||!(l||void 0!==e.property),d=e.type||(Ts(s)?"exponential":"interval"),p=function(e){switch(e.type){case"color":return Te.parse;case"padding":return ze.parse;case"numberArray":return Pe.parse;case"colorArray":return Be.parse;default:return null}}(s);if(p&&((e=ri({},e)).stops&&(e.stops=e.stops.map((e=>[e[0],p(e[1])]))),e.default=p(e.default?e.default:s.default)),e.colorSpace&&"rgb"!==(f=e.colorSpace)&&"hcl"!==f&&"lab"!==f)throw new Error(`Unknown color space: "${e.colorSpace}"`);var f;const m=function(e){switch(e){case"exponential":return ks;case"interval":return zs;case"categorical":return Ds;case"identity":return Fs;default:throw new Error(`Unknown function type "${e}"`)}}(d);let _,g;if("categorical"===d){_=Object.create(null);for(const s of e.stops)_[s[0]]=s[1];g=typeof e.stops[0][0]}if(l){const l={},c=[];for(let s=0;se[0])),evaluate:({zoom:l},c)=>ks({stops:d,base:e.base},s,l).evaluate(l,c)}}if(c){const l="exponential"===d?{name:"exponential",base:void 0!==e.base?e.base:1}:null;return{kind:"camera",interpolationType:l,interpolationFactor:fr.interpolationFactor.bind(void 0,l),zoomStops:e.stops.map((e=>e[0])),evaluate:({zoom:l})=>m(e,s,l,_,g)}}return{kind:"source",evaluate(l,c){const d=c&&c.properties?c.properties[e.property]:void 0;return void 0===d?As(e.default,s.default):m(e,s,d,_,g)}}}function As(e,s,l){return void 0!==e?e:void 0!==s?s:void 0!==l?l:void 0}function Ds(e,s,l,c,d){return As(typeof l===d?c[l]:void 0,e.default,s.default)}function zs(e,s,l){if("number"!==Ss(l))return As(e.default,s.default);const c=e.stops.length;if(1===c)return e.stops[0][1];if(l<=e.stops[0][0])return e.stops[0][1];if(l>=e.stops[c-1][0])return e.stops[c-1][1];const d=Rr(e.stops.map((e=>e[0])),l);return e.stops[d][1]}function ks(e,s,l){const c=void 0!==e.base?e.base:1;if("number"!==Ss(l))return As(e.default,s.default);const d=e.stops.length;if(1===d)return e.stops[0][1];if(l<=e.stops[0][0])return e.stops[0][1];if(l>=e.stops[d-1][0])return e.stops[d-1][1];const p=Rr(e.stops.map((e=>e[0])),l),f=function(e,s,l,c){const d=c-l,p=e-l;return 0===d?0:1===s?p/d:(Math.pow(s,p)-1)/(Math.pow(s,d)-1)}(l,c,e.stops[p][0],e.stops[p+1][0]),m=e.stops[p][1],_=e.stops[p+1][1],g=Gr[s.type]||Is;return"function"==typeof m.evaluate?{evaluate(...s){const l=m.evaluate.apply(void 0,s),c=_.evaluate.apply(void 0,s);if(void 0!==l&&void 0!==c)return g(l,c,f,e.colorSpace)}}:g(m,_,f,e.colorSpace)}function Fs(e,s,l){switch(s.type){case"color":l=Te.parse(l);break;case"formatted":l=De.fromString(l.toString());break;case"resolvedImage":l=Oe.fromString(l.toString());break;case"padding":l=ze.parse(l);break;case"colorArray":l=Be.parse(l);break;case"numberArray":l=Pe.parse(l);break;default:Ss(l)===s.type||"enum"===s.type&&s.values[l]||(l=void 0)}return As(l,e.default,s.default)}zn.register(ns,{error:[{kind:"error"},[ci],(e,[s])=>{throw new Ve(s.evaluate(e))}],typeof:[ci,[_i],(e,[s])=>Ci(Cr(s.evaluate(e)))],"to-rgba":[Ei(li,4),[pi],(e,[s])=>{const[l,c,d,p]=s.evaluate(e).rgb;return[255*l,255*c,255*d,p]}],rgb:[pi,[li,li,li],ss],rgba:[pi,[li,li,li,li],ss],has:{type:ui,overloads:[[[ci],(e,[s])=>ls(s.evaluate(e),e.properties())],[[ci,mi],(e,[s,l])=>ls(s.evaluate(e),l.evaluate(e))]]},get:{type:_i,overloads:[[[ci],(e,[s])=>us(s.evaluate(e),e.properties())],[[ci,mi],(e,[s,l])=>us(s.evaluate(e),l.evaluate(e))]]},"feature-state":[_i,[ci],(e,[s])=>us(s.evaluate(e),e.featureState||{})],properties:[mi,[],e=>e.properties()],"geometry-type":[ci,[],e=>e.geometryType()],id:[_i,[],e=>e.id()],zoom:[li,[],e=>e.globals.zoom],"heatmap-density":[li,[],e=>e.globals.heatmapDensity||0],elevation:[li,[],e=>e.globals.elevation||0],"line-progress":[li,[],e=>e.globals.lineProgress||0],accumulated:[_i,[],e=>void 0===e.globals.accumulated?null:e.globals.accumulated],"+":[li,ds(li),(e,s)=>{let l=0;for(const c of s)l+=c.evaluate(e);return l}],"*":[li,ds(li),(e,s)=>{let l=1;for(const c of s)l*=c.evaluate(e);return l}],"-":{type:li,overloads:[[[li,li],(e,[s,l])=>s.evaluate(e)-l.evaluate(e)],[[li],(e,[s])=>-s.evaluate(e)]]},"/":[li,[li,li],(e,[s,l])=>s.evaluate(e)/l.evaluate(e)],"%":[li,[li,li],(e,[s,l])=>s.evaluate(e)%l.evaluate(e)],ln2:[li,[],()=>Math.LN2],pi:[li,[],()=>Math.PI],e:[li,[],()=>Math.E],"^":[li,[li,li],(e,[s,l])=>Math.pow(s.evaluate(e),l.evaluate(e))],sqrt:[li,[li],(e,[s])=>Math.sqrt(s.evaluate(e))],log10:[li,[li],(e,[s])=>Math.log(s.evaluate(e))/Math.LN10],ln:[li,[li],(e,[s])=>Math.log(s.evaluate(e))],log2:[li,[li],(e,[s])=>Math.log(s.evaluate(e))/Math.LN2],sin:[li,[li],(e,[s])=>Math.sin(s.evaluate(e))],cos:[li,[li],(e,[s])=>Math.cos(s.evaluate(e))],tan:[li,[li],(e,[s])=>Math.tan(s.evaluate(e))],asin:[li,[li],(e,[s])=>Math.asin(s.evaluate(e))],acos:[li,[li],(e,[s])=>Math.acos(s.evaluate(e))],atan:[li,[li],(e,[s])=>Math.atan(s.evaluate(e))],min:[li,ds(li),(e,s)=>Math.min(...s.map((s=>s.evaluate(e))))],max:[li,ds(li),(e,s)=>Math.max(...s.map((s=>s.evaluate(e))))],abs:[li,[li],(e,[s])=>Math.abs(s.evaluate(e))],round:[li,[li],(e,[s])=>{const l=s.evaluate(e);return l<0?-Math.round(-l):Math.round(l)}],floor:[li,[li],(e,[s])=>Math.floor(s.evaluate(e))],ceil:[li,[li],(e,[s])=>Math.ceil(s.evaluate(e))],"filter-==":[ui,[ci,_i],(e,[s,l])=>e.properties()[s.value]===l.value],"filter-id-==":[ui,[_i],(e,[s])=>e.id()===s.value],"filter-type-==":[ui,[ci],(e,[s])=>e.geometryType()===s.value],"filter-<":[ui,[ci,_i],(e,[s,l])=>{const c=e.properties()[s.value],d=l.value;return typeof c==typeof d&&c{const l=e.id(),c=s.value;return typeof l==typeof c&&l":[ui,[ci,_i],(e,[s,l])=>{const c=e.properties()[s.value],d=l.value;return typeof c==typeof d&&c>d}],"filter-id->":[ui,[_i],(e,[s])=>{const l=e.id(),c=s.value;return typeof l==typeof c&&l>c}],"filter-<=":[ui,[ci,_i],(e,[s,l])=>{const c=e.properties()[s.value],d=l.value;return typeof c==typeof d&&c<=d}],"filter-id-<=":[ui,[_i],(e,[s])=>{const l=e.id(),c=s.value;return typeof l==typeof c&&l<=c}],"filter->=":[ui,[ci,_i],(e,[s,l])=>{const c=e.properties()[s.value],d=l.value;return typeof c==typeof d&&c>=d}],"filter-id->=":[ui,[_i],(e,[s])=>{const l=e.id(),c=s.value;return typeof l==typeof c&&l>=c}],"filter-has":[ui,[_i],(e,[s])=>s.value in e.properties()],"filter-has-id":[ui,[],e=>null!==e.id()&&void 0!==e.id()],"filter-type-in":[ui,[Ei(ci)],(e,[s])=>s.value.indexOf(e.geometryType())>=0],"filter-id-in":[ui,[Ei(_i)],(e,[s])=>s.value.indexOf(e.id())>=0],"filter-in-small":[ui,[ci,Ei(_i)],(e,[s,l])=>l.value.indexOf(e.properties()[s.value])>=0],"filter-in-large":[ui,[ci,Ei(_i)],(e,[s,l])=>function(e,s,l,c){for(;l<=c;){const d=l+c>>1;if(s[d]===e)return!0;s[d]>e?c=d-1:l=d+1}return!1}(e.properties()[s.value],l.value,0,l.value.length-1)],all:{type:ui,overloads:[[[ui,ui],(e,[s,l])=>s.evaluate(e)&&l.evaluate(e)],[ds(ui),(e,s)=>{for(const l of s)if(!l.evaluate(e))return!1;return!0}]]},any:{type:ui,overloads:[[[ui,ui],(e,[s,l])=>s.evaluate(e)||l.evaluate(e)],[ds(ui),(e,s)=>{for(const l of s)if(l.evaluate(e))return!0;return!1}]]},"!":[ui,[ui],(e,[s])=>!s.evaluate(e)],"is-supported-script":[ui,[ci],(e,[s])=>{const l=e.globals&&e.globals.isSupportedScript;return!l||l(s.evaluate(e))}],upcase:[ci,[ci],(e,[s])=>s.evaluate(e).toUpperCase()],downcase:[ci,[ci],(e,[s])=>s.evaluate(e).toLowerCase()],concat:[ci,ds(_i),(e,s)=>s.map((s=>Ar(s.evaluate(e)))).join("")],"resolved-locale":[ci,[gi],(e,[s])=>s.evaluate(e).resolvedLocale()]});class ei{constructor(e,s,l){this.expression=e,this._warningHistory={},this._evaluator=new Ke,this._defaultValue=s?function(e){if("color"===e.type&&Ms(e.default))return new Te(0,0,0,0);switch(e.type){case"color":return Te.parse(e.default)||null;case"padding":return ze.parse(e.default)||null;case"numberArray":return Pe.parse(e.default)||null;case"colorArray":return Be.parse(e.default)||null;case"variableAnchorOffsetCollection":return Le.parse(e.default)||null;case"projectionDefinition":return Re.parse(e.default)||null;default:return void 0===e.default?null:e.default}}(s):null,this._enumValues=s&&"enum"===s.type?s.values:null,this._globalState=l}evaluateWithoutErrorHandling(e,s,l,c,d,p){return this._globalState&&(e=fo(e,this._globalState)),this._evaluator.globals=e,this._evaluator.feature=s,this._evaluator.featureState=l,this._evaluator.canonical=c,this._evaluator.availableImages=d||null,this._evaluator.formattedSection=p,this.expression.evaluate(this._evaluator)}evaluate(e,s,l,c,d,p){this._globalState&&(e=fo(e,this._globalState)),this._evaluator.globals=e,this._evaluator.feature=s||null,this._evaluator.featureState=l||null,this._evaluator.canonical=c,this._evaluator.availableImages=d||null,this._evaluator.formattedSection=p||null;try{const e=this.expression.evaluate(this._evaluator);if(null==e||"number"==typeof e&&e!=e)return this._defaultValue;if(this._enumValues&&!(e in this._enumValues))throw new Ve(`Expected value to be one of ${Object.keys(this._enumValues).map((e=>JSON.stringify(e))).join(", ")}, but found ${JSON.stringify(e)} instead.`);return e}catch(e){return this._warningHistory[e.message]||(this._warningHistory[e.message]=!0,"undefined"!=typeof console&&console.warn(e.message)),this._defaultValue}}}function Bs(e){return Array.isArray(e)&&e.length>0&&"string"==typeof e[0]&&e[0]in ns}function Vs(e,s,l){const c=new We(ns,ps,[],s?function(e){const s={color:pi,string:ci,number:li,enum:ci,boolean:ui,formatted:yi,padding:xi,numberArray:bi,colorArray:vi,projectionDefinition:fi,resolvedImage:wi,variableAnchorOffsetCollection:Ii};return"array"===e.type?Ei(s[e.value]||_i,e.length):s[e.type]}(s):void 0),d=c.parse(e,void 0,void 0,void 0,s&&"string"===s.type?{typeAnnotation:"coerce"}:void 0);return d?ys(new ei(d,s,l)):vs(c.errors)}class ii{constructor(e,s,l){this.kind=e,this._styleExpression=s,this.isStateDependent="constant"!==e&&!_s(s.expression),this.globalStateRefs=ho(s.expression),this._globalState=l}evaluateWithoutErrorHandling(e,s,l,c,d,p){return this._globalState&&(e=fo(e,this._globalState)),this._styleExpression.evaluateWithoutErrorHandling(e,s,l,c,d,p)}evaluate(e,s,l,c,d,p){return this._globalState&&(e=fo(e,this._globalState)),this._styleExpression.evaluate(e,s,l,c,d,p)}}class si{constructor(e,s,l,c,d){this.kind=e,this.zoomStops=l,this._styleExpression=s,this.isStateDependent="camera"!==e&&!_s(s.expression),this.globalStateRefs=ho(s.expression),this.interpolationType=c,this._globalState=d}evaluateWithoutErrorHandling(e,s,l,c,d,p){return this._globalState&&(e=fo(e,this._globalState)),this._styleExpression.evaluateWithoutErrorHandling(e,s,l,c,d,p)}evaluate(e,s,l,c,d,p){return this._globalState&&(e=fo(e,this._globalState)),this._styleExpression.evaluate(e,s,l,c,d,p)}interpolationFactor(e,s,l){return this.interpolationType?fr.interpolationFactor(this.interpolationType,e,s,l):0}}function Ws(e,s,l){const c=Vs(e,s,l);if("error"===c.result)return c;const d=c.value.expression,p=fs(d);if(!p&&!bs(s))return vs([new Pt("","data expressions not supported")]);const f=gs(d,["zoom"]);if(!f&&!ws(s))return vs([new Pt("","zoom expressions not supported")]);const m=Js(d);return m||f?m instanceof Pt?vs([m]):m instanceof fr&&!Ts(s)?vs([new Pt("",'"interpolate" expressions cannot be used with this property')]):ys(m?new si(p?"camera":"composite",c.value,m.labels,m instanceof fr?m.interpolation:void 0,l):new ii(p?"constant":"source",c.value,l)):vs([new Pt("",'"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression.')])}class oi{constructor(e,s){this._parameters=e,this._specification=s,ri(this,Es(this._parameters,this._specification))}static deserialize(e){return new oi(e._parameters,e._specification)}static serialize(e){return{_parameters:e._parameters,_specification:e._specification}}}function Js(e){let s=null;if(e instanceof Je)s=Js(e.result);else if(e instanceof mr){for(const l of e.args)if(s=Js(l),s)break}else(e instanceof or||e instanceof fr)&&e.input instanceof zn&&"zoom"===e.input.name&&(s=e);return s instanceof Pt||e.eachChild((e=>{const l=Js(e);l instanceof Pt?s=l:!s&&l?s=new Pt("",'"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression.'):s&&l&&s!==l&&(s=new Pt("",'Only one zoom-based "step" or "interpolate" subexpression may be used in an expression.'))})),s}function ho(e,s=new Set){return e instanceof Fn&&s.add(e.key),e.eachChild((e=>{ho(e,s)})),s}function fo(e,s){const{zoom:l,heatmapDensity:c,elevation:d,lineProgress:p,isSupportedScript:f,accumulated:m}=null!=e?e:{};return{zoom:l,heatmapDensity:c,elevation:d,lineProgress:p,isSupportedScript:f,accumulated:m,globalState:s}}function vo(e){if(!0===e||!1===e)return!0;if(!Array.isArray(e)||0===e.length)return!1;switch(e[0]){case"has":return e.length>=2&&"$id"!==e[1]&&"$type"!==e[1];case"in":return e.length>=3&&("string"!=typeof e[1]||Array.isArray(e[2]));case"!in":case"!has":case"none":return!1;case"==":case"!=":case">":case">=":case"<":case"<=":return 3!==e.length||Array.isArray(e[1])||Array.isArray(e[2]);case"any":case"all":for(const s of e.slice(1))if(!vo(s)&&"boolean"!=typeof s)return!1;return!0;default:return!0}}const Eo={type:"boolean",default:!1,transition:!1,"property-type":"data-driven",expression:{interpolated:!1,parameters:["zoom","feature"]}};function Co(e,s){if(null==e)return{filter:()=>!0,needGeometry:!1,getGlobalStateRefs:()=>new Set};vo(e)||(e=qo(e));const l=Vs(e,Eo,s);if("error"===l.result)throw new Error(l.value.map((e=>`${e.key}: ${e.message}`)).join(", "));return{filter:(e,s,c)=>l.value.evaluate(e,s,{},c),needGeometry:Lo(e),getGlobalStateRefs:()=>ho(l.value.expression)}}function ko(e,s){return es?1:0}function Lo(e){if(!Array.isArray(e))return!1;if("within"===e[0]||"distance"===e[0])return!0;for(let s=1;s"===s||"<="===s||">="===s?$o(e[1],e[2],s):"any"===s?(l=e.slice(1),["any"].concat(l.map(qo))):"all"===s?["all"].concat(e.slice(1).map(qo)):"none"===s?["all"].concat(e.slice(1).map(qo).map(ia)):"in"===s?Ko(e[1],e.slice(2)):"!in"===s?ia(Ko(e[1],e.slice(2))):"has"===s?ta(e[1]):"!has"!==s||ia(ta(e[1]));var l}function $o(e,s,l){switch(e){case"$type":return[`filter-type-${l}`,s];case"$id":return[`filter-id-${l}`,s];default:return[`filter-${l}`,e,s]}}function Ko(e,s){if(0===s.length)return!1;switch(e){case"$type":return["filter-type-in",["literal",s]];case"$id":return["filter-id-in",["literal",s]];default:return s.length>200&&!s.some((e=>typeof e!=typeof s[0]))?["filter-in-large",e,["literal",s.sort(ko)]]:["filter-in-small",e,["literal",s]]}}function ta(e){switch(e){case"$type":return!0;case"$id":return["filter-has-id"];default:return["filter-has",e]}}function ia(e){return["!",e]}function na(e){const s=typeof e;if("number"===s||"boolean"===s||"string"===s||null==e)return JSON.stringify(e);if(Array.isArray(e)){let s="[";for(const l of e)s+=`${na(l)},`;return`${s}]`}const l=Object.keys(e).sort();let c="{";for(let s=0;sc.maximum?[new Dt(s,l,`${l} is greater than the maximum value ${c.maximum}`)]:[]}function al(e){const s=e.valueSpec,l=il(e.value.type);let c,d,p,f={};const m="categorical"!==l&&void 0===e.value.property,_=!m,g="array"===Ss(e.value.stops)&&"array"===Ss(e.value.stops[0])&&"object"===Ss(e.value.stops[0][0]),y=nl({key:e.key,value:e.value,valueSpec:e.styleSpec.function,validateSpec:e.validateSpec,style:e.style,styleSpec:e.styleSpec,objectElementValidators:{stops:function(e){if("identity"===l)return[new Dt(e.key,e.value,'identity function may not have a "stops" property')];let s=[];const c=e.value;return s=s.concat(sl({key:e.key,value:c,valueSpec:e.valueSpec,validateSpec:e.validateSpec,style:e.style,styleSpec:e.styleSpec,arrayElementValidator:b})),"array"===Ss(c)&&0===c.length&&s.push(new Dt(e.key,c,"array must have at least one stop")),s},default:function(e){return e.validateSpec({key:e.key,value:e.value,valueSpec:s,validateSpec:e.validateSpec,style:e.style,styleSpec:e.styleSpec})}}});return"identity"===l&&m&&y.push(new Dt(e.key,e.value,'missing required property "property"')),"identity"===l||e.value.stops||y.push(new Dt(e.key,e.value,'missing required property "stops"')),"exponential"===l&&e.valueSpec.expression&&!Ts(e.valueSpec)&&y.push(new Dt(e.key,e.value,"exponential functions not supported")),e.styleSpec.$version>=8&&(_&&!bs(e.valueSpec)?y.push(new Dt(e.key,e.value,"property functions not supported")):m&&!ws(e.valueSpec)&&y.push(new Dt(e.key,e.value,"zoom functions not supported"))),"categorical"!==l&&!g||void 0!==e.value.property||y.push(new Dt(e.key,e.value,'"property" property is required')),y;function b(e){let l=[];const c=e.value,m=e.key;if("array"!==Ss(c))return[new Dt(m,c,`array expected, ${Ss(c)} found`)];if(2!==c.length)return[new Dt(m,c,`array length 2 expected, length ${c.length} found`)];if(g){if("object"!==Ss(c[0]))return[new Dt(m,c,`object expected, ${Ss(c[0])} found`)];if(void 0===c[0].zoom)return[new Dt(m,c,"object stop key must have zoom")];if(void 0===c[0].value)return[new Dt(m,c,"object stop key must have value")];if(p&&p>il(c[0].zoom))return[new Dt(m,c[0].zoom,"stop zoom values must appear in ascending order")];il(c[0].zoom)!==p&&(p=il(c[0].zoom),d=void 0,f={}),l=l.concat(nl({key:`${m}[0]`,value:c[0],valueSpec:{zoom:{}},validateSpec:e.validateSpec,style:e.style,styleSpec:e.styleSpec,objectElementValidators:{zoom:ol,value:T}}))}else l=l.concat(T({key:`${m}[0]`,value:c[0],validateSpec:e.validateSpec,style:e.style,styleSpec:e.styleSpec},c));return Bs(rl(c[1]))?l.concat([new Dt(`${m}[1]`,c[1],"expressions are not allowed in function stops.")]):l.concat(e.validateSpec({key:`${m}[1]`,value:c[1],valueSpec:s,validateSpec:e.validateSpec,style:e.style,styleSpec:e.styleSpec}))}function T(e,p){const m=Ss(e.value),_=il(e.value),g=null!==e.value?e.value:p;if(c){if(m!==c)return[new Dt(e.key,g,`${m} stop domain type must match previous stop domain type ${c}`)]}else c=m;if("number"!==m&&"string"!==m&&"boolean"!==m)return[new Dt(e.key,g,"stop domain value must be a number, string, or boolean")];if("number"!==m&&"categorical"!==l){let c=`number expected, ${m} found`;return bs(s)&&void 0===l&&(c+='\nIf you intended to use a categorical function, specify `"type": "categorical"`.'),[new Dt(e.key,g,c)]}return"categorical"!==l||"number"!==m||isFinite(_)&&Math.floor(_)===_?"categorical"!==l&&"number"===m&&void 0!==d&&_new Dt(`${e.key}${s.key}`,e.value,s.message)));const l=s.value.expression||s.value._styleExpression.expression;if("property"===e.expressionContext&&"text-font"===e.propertyKey&&!l.outputDefined())return[new Dt(e.key,e.value,`Invalid data expression for "${e.propertyKey}". Output values must be contained as literals within the expression.`)];if("property"===e.expressionContext&&"layout"===e.propertyType&&!_s(l))return[new Dt(e.key,e.value,'"feature-state" data expressions are not supported with layout properties.')];if("filter"===e.expressionContext&&!_s(l))return[new Dt(e.key,e.value,'"feature-state" data expressions are not supported with filters.')];if(e.expressionContext&&0===e.expressionContext.indexOf("cluster")){if(!gs(l,["zoom","feature-state"]))return[new Dt(e.key,e.value,'"zoom" and "feature-state" expressions are not supported with cluster properties.')];if("cluster-initial"===e.expressionContext&&!fs(l))return[new Dt(e.key,e.value,"Feature data expressions are not supported with initial expression part of cluster properties.")]}return[]}function cl(e){const s=e.key,l=e.value,c=Ss(l);return"string"!==c?[new Dt(s,l,`color expected, ${c} found`)]:Te.parse(String(l))?[]:[new Dt(s,l,`color expected, "${l}" found`)]}function hl(e){const s=e.key,l=e.value,c=e.valueSpec,d=[];return Array.isArray(c.values)?-1===c.values.indexOf(il(l))&&d.push(new Dt(s,l,`expected one of [${c.values.join(", ")}], ${JSON.stringify(l)} found`)):-1===Object.keys(c.values).indexOf(il(l))&&d.push(new Dt(s,l,`expected one of [${Object.keys(c.values).join(", ")}], ${JSON.stringify(l)} found`)),d}function ul(e){return vo(rl(e.value))?ll(ri({},e,{expressionContext:"filter",valueSpec:{value:"boolean"}})):dl(e)}function dl(e){const s=e.value,l=e.key;if("array"!==Ss(s))return[new Dt(l,s,`array expected, ${Ss(s)} found`)];const c=e.styleSpec;let d,p=[];if(s.length<1)return[new Dt(l,s,"filter array must have at least 1 element")];switch(p=p.concat(hl({key:`${l}[0]`,value:s[0],valueSpec:c.filter_operator,style:e.style,styleSpec:e.styleSpec})),il(s[0])){case"<":case"<=":case">":case">=":s.length>=2&&"$type"===il(s[1])&&p.push(new Dt(l,s,`"$type" cannot be use with operator "${s[0]}"`));case"==":case"!=":3!==s.length&&p.push(new Dt(l,s,`filter array for operator "${s[0]}" must have 3 elements`));case"in":case"!in":s.length>=2&&(d=Ss(s[1]),"string"!==d&&p.push(new Dt(`${l}[1]`,s[1],`string expected, ${d} found`)));for(let f=2;f{e in l&&s.push(new Dt(c,l[e],`"${e}" is prohibited for ref layers`))})),d.layers.forEach((s=>{il(s.id)===m&&(e=s)})),e?e.ref?s.push(new Dt(c,l.ref,"ref cannot reference another ref layer")):f=il(e.type):s.push(new Dt(c,l.ref,`ref layer "${m}" not found`))}else if("background"!==f)if(l.source){const e=d.sources&&d.sources[l.source],p=e&&il(e.type);e?"vector"===p&&"raster"===f?s.push(new Dt(c,l.source,`layer "${l.id}" requires a raster source`)):"raster-dem"!==p&&"hillshade"===f||"raster-dem"!==p&&"color-relief"===f?s.push(new Dt(c,l.source,`layer "${l.id}" requires a raster-dem source`)):"raster"===p&&"raster"!==f?s.push(new Dt(c,l.source,`layer "${l.id}" requires a vector source`)):"vector"!==p||l["source-layer"]?"raster-dem"===p&&"hillshade"!==f&&"color-relief"!==f?s.push(new Dt(c,l.source,"raster-dem source can only be used with layer type 'hillshade' or 'color-relief'.")):"line"!==f||!l.paint||!l.paint["line-gradient"]||"geojson"===p&&e.lineMetrics||s.push(new Dt(c,l,`layer "${l.id}" specifies a line-gradient, which requires a GeoJSON source with \`lineMetrics\` enabled.`)):s.push(new Dt(c,l,`layer "${l.id}" must specify a "source-layer"`)):s.push(new Dt(c,l.source,`source "${l.source}" not found`))}else s.push(new Dt(c,l,'missing required property "source"'));return s=s.concat(nl({key:c,value:l,valueSpec:p.layer,style:e.style,styleSpec:e.styleSpec,validateSpec:e.validateSpec,objectElementValidators:{"*":()=>[],type:()=>e.validateSpec({key:`${c}.type`,value:l.type,valueSpec:p.layer.type,style:e.style,styleSpec:e.styleSpec,validateSpec:e.validateSpec,object:l,objectKey:"type"}),filter:ul,layout:e=>nl({layer:l,key:e.key,value:e.value,style:e.style,styleSpec:e.styleSpec,validateSpec:e.validateSpec,objectElementValidators:{"*":e=>gl(ri({layerType:f},e))}}),paint:e=>nl({layer:l,key:e.key,value:e.value,style:e.style,styleSpec:e.styleSpec,validateSpec:e.validateSpec,objectElementValidators:{"*":e=>fl(ri({layerType:f},e))}})}})),s}function vl(e){const s=e.value,l=e.key,c=Ss(s);return"string"!==c?[new Dt(l,s,`string expected, ${c} found`)]:[]}const bl={promoteId:function({key:e,value:s}){if("string"===Ss(s))return vl({key:e,value:s});{const l=[];for(const c in s)l.push(...vl({key:`${e}.${c}`,value:s[c]}));return l}}};function wl(e){const s=e.value,l=e.key,c=e.styleSpec,d=e.style,p=e.validateSpec;if(!s.type)return[new Dt(l,s,'"type" is required')];const f=il(s.type);let m;switch(f){case"vector":case"raster":return m=nl({key:l,value:s,valueSpec:c[`source_${f.replace("-","_")}`],style:e.style,styleSpec:c,objectElementValidators:bl,validateSpec:p}),m;case"raster-dem":return m=function(e){var s;const l=null!==(s=e.sourceName)&&void 0!==s?s:"",c=e.value,d=e.styleSpec,p=d.source_raster_dem,f=e.style;let m=[];const _=Ss(c);if(void 0===c)return m;if("object"!==_)return m.push(new Dt("source_raster_dem",c,`object expected, ${_} found`)),m;const g="custom"===il(c.encoding),y=["redFactor","greenFactor","blueFactor","baseShift"],b=e.value.encoding?`"${e.value.encoding}"`:"Default";for(const s in c)!g&&y.includes(s)?m.push(new Dt(s,c[s],`In "${l}": "${s}" is only valid when "encoding" is set to "custom". ${b} encoding found`)):p[s]?m=m.concat(e.validateSpec({key:s,value:c[s],valueSpec:p[s],validateSpec:e.validateSpec,style:f,styleSpec:d})):m.push(new Dt(s,c[s],`unknown property "${s}"`));return m}({sourceName:l,value:s,style:e.style,styleSpec:c,validateSpec:p}),m;case"geojson":if(m=nl({key:l,value:s,valueSpec:c.source_geojson,style:d,styleSpec:c,validateSpec:p,objectElementValidators:bl}),s.cluster)for(const e in s.clusterProperties){const[c,d]=s.clusterProperties[e],p="string"==typeof c?[c,["accumulated"],["get",e]]:c;m.push(...ll({key:`${l}.${e}.map`,value:d,expressionContext:"cluster-map"})),m.push(...ll({key:`${l}.${e}.reduce`,value:p,expressionContext:"cluster-reduce"}))}return m;case"video":return nl({key:l,value:s,valueSpec:c.source_video,style:d,validateSpec:p,styleSpec:c});case"image":return nl({key:l,value:s,valueSpec:c.source_image,style:d,validateSpec:p,styleSpec:c});case"canvas":return[new Dt(l,null,"Please use runtime APIs to add canvas sources, rather than including them in stylesheets.","source.canvas")];default:return hl({key:`${l}.type`,value:s.type,valueSpec:{values:["vector","raster","raster-dem","geojson","video","image"]}})}}function Tl(e){const s=e.value,l=e.styleSpec,c=l.light,d=e.style;let p=[];const f=Ss(s);if(void 0===s)return p;if("object"!==f)return p=p.concat([new Dt("light",s,`object expected, ${f} found`)]),p;for(const f in s){const m=f.match(/^(.*)-transition$/);p=p.concat(m&&c[m[1]]&&c[m[1]].transition?e.validateSpec({key:f,value:s[f],valueSpec:l.transition,validateSpec:e.validateSpec,style:d,styleSpec:l}):c[f]?e.validateSpec({key:f,value:s[f],valueSpec:c[f],validateSpec:e.validateSpec,style:d,styleSpec:l}):[new Dt(f,s[f],`unknown property "${f}"`)])}return p}function Il(e){const s=e.value,l=e.styleSpec,c=l.sky,d=e.style,p=Ss(s);if(void 0===s)return[];if("object"!==p)return[new Dt("sky",s,`object expected, ${p} found`)];let f=[];for(const p in s)f=f.concat(c[p]?e.validateSpec({key:p,value:s[p],valueSpec:c[p],style:d,styleSpec:l}):[new Dt(p,s[p],`unknown property "${p}"`)]);return f}function Cl(e){const s=e.value,l=e.styleSpec,c=l.terrain,d=e.style;let p=[];const f=Ss(s);if(void 0===s)return p;if("object"!==f)return p=p.concat([new Dt("terrain",s,`object expected, ${f} found`)]),p;for(const f in s)p=p.concat(c[f]?e.validateSpec({key:f,value:s[f],valueSpec:c[f],validateSpec:e.validateSpec,style:d,styleSpec:l}):[new Dt(f,s[f],`unknown property "${f}"`)]);return p}function Al(e){let s=[];const l=e.value,c=e.key;if(Array.isArray(l)){const d=[],p=[];for(const f in l)l[f].id&&d.includes(l[f].id)&&s.push(new Dt(c,l,`all the sprites' ids must be unique, but ${l[f].id} is duplicated`)),d.push(l[f].id),l[f].url&&p.includes(l[f].url)&&s.push(new Dt(c,l,`all the sprites' URLs must be unique, but ${l[f].url} is duplicated`)),p.push(l[f].url),s=s.concat(nl({key:`${c}[${f}]`,value:l[f],valueSpec:{id:{type:"string",required:!0},url:{type:"string",required:!0}},validateSpec:e.validateSpec}));return s}return vl({key:c,value:l})}function Dl(e){return Boolean(e)&&e.constructor===Object}function kl(e){return Dl(e.value)?[]:[new Dt(e.key,e.value,`object expected, ${Ss(e.value)} found`)]}const Rl={"*":()=>[],array:sl,boolean:function(e){const s=e.value,l=e.key,c=Ss(s);return"boolean"!==c?[new Dt(l,s,`boolean expected, ${c} found`)]:[]},number:ol,color:cl,constants:tl,enum:hl,filter:ul,function:al,layer:xl,object:nl,source:wl,light:Tl,sky:Il,terrain:Cl,projection:function(e){const s=e.value,l=e.styleSpec,c=l.projection,d=e.style,p=Ss(s);if(void 0===s)return[];if("object"!==p)return[new Dt("projection",s,`object expected, ${p} found`)];let f=[];for(const p in s)f=f.concat(c[p]?e.validateSpec({key:p,value:s[p],valueSpec:c[p],style:d,styleSpec:l}):[new Dt(p,s[p],`unknown property "${p}"`)]);return f},projectionDefinition:function(e){const s=e.key;let l=e.value;l=l instanceof String?l.valueOf():l;const c=Ss(l);return"array"!==c||function(e){return Array.isArray(e)&&3===e.length&&"string"==typeof e[0]&&"string"==typeof e[1]&&"number"==typeof e[2]}(l)||function(e){return!!["interpolate","step","literal"].includes(e[0])}(l)?["array","string"].includes(c)?[]:[new Dt(s,l,`projection expected, invalid type "${c}" found`)]:[new Dt(s,l,`projection expected, invalid array ${JSON.stringify(l)} found`)]},string:vl,formatted:function(e){return 0===vl(e).length?[]:ll(e)},resolvedImage:function(e){return 0===vl(e).length?[]:ll(e)},padding:function(e){const s=e.key,l=e.value;if("array"===Ss(l)){if(l.length<1||l.length>4)return[new Dt(s,l,`padding requires 1 to 4 values; ${l.length} values found`)];const c={type:"number"};let d=[];for(let p=0;p[]}})),e.constants&&(l=l.concat(tl({key:"constants",value:e.constants}))),jl(l)}function Ol(e){return function(s){return e(Object.assign({},s,{validateSpec:Ll}))}}function jl(e){return[].concat(e).sort(((e,s)=>e.line-s.line))}function Nl(s){return function(...l){return jl(s.apply(this||e,l))}}Bl.source=Nl(Ol(wl)),Bl.sprite=Nl(Ol(Al)),Bl.glyphs=Nl(Ol(Fl)),Bl.light=Nl(Ol(Tl)),Bl.sky=Nl(Ol(Il)),Bl.terrain=Nl(Ol(Cl)),Bl.state=Nl(Ol(kl)),Bl.layer=Nl(Ol(xl)),Bl.filter=Nl(Ol(ul)),Bl.paintProperty=Nl(Ol(fl)),Bl.layoutProperty=Nl(Ol(gl));const Gl={type:"enum","property-type":"data-constant",expression:{interpolated:!1,parameters:["global-state"]},values:{visible:{},none:{}},transition:!1,default:"visible"};class rs{constructor(e,s){this._globalState=s,this.setValue(e)}evaluate(){var e;return null!==(e=this._literalValue)&&void 0!==e?e:this._compiledValue.evaluate({})}setValue(e){if(null==e||"visible"===e||"none"===e)return this._literalValue="none"===e?"none":"visible",this._compiledValue=void 0,void(this._globalStateRefs=new Set);const s=Vs(e,Gl,this._globalState);if("error"===s.result)throw this._literalValue="visible",this._compiledValue=void 0,new Error(s.value.map((e=>`${e.key}: ${e.message}`)).join(", "));this._literalValue=void 0,this._compiledValue=s.value,this._globalStateRefs=ho(s.value.expression)}getGlobalStateRefs(){return this._globalStateRefs}}const Ul=Tt,ql=Bl,Zl=ql.light,$l=ql.sky,Wl=ql.paintProperty,Hl=ql.layoutProperty;function Xl(e,s){let l=!1;if(s&&s.length)for(const c of s)e.fire(new gt(new Error(c.message))),l=!0;return l}class cs{constructor(e,s,l){const c=this.cells=[];if(e instanceof ArrayBuffer){this.arrayBuffer=e;const d=new Int32Array(this.arrayBuffer);e=d[0],this.d=(s=d[1])+2*(l=d[2]);for(let e=0;e=g[_+0]&&c>=g[_+1])?(f[b]=!0,p.push(d[b])):f[b]=!1}}}}_forEachCell(e,s,l,c,d,p,f,m){const _=this._convertToCellCoord(e),g=this._convertToCellCoord(s),y=this._convertToCellCoord(l),b=this._convertToCellCoord(c);for(let T=_;T<=y;T++)for(let _=g;_<=b;_++){const g=this.d*_+T;if((!m||m(this._convertFromCellCoord(T),this._convertFromCellCoord(_),this._convertFromCellCoord(T+1),this._convertFromCellCoord(_+1)))&&d.call(this,e,s,l,c,g,p,f,m))return}}_convertFromCellCoord(e){return(e-this.padding)/this.scale}_convertToCellCoord(e){return Math.max(0,Math.min(this.d-1,Math.floor(e*this.scale)+this.padding))}toArrayBuffer(){if(this.arrayBuffer)return this.arrayBuffer;const e=this.cells,s=3+this.cells.length+1+1;let l=0;for(let e=0;e=0)continue;const p=e[c];d[c]=Yl[l].shallow.indexOf(c)>=0?p:rc(p,s)}e instanceof Error&&(d.message=e.message)}if(d.$name)throw new Error("$name property is reserved for worker serialization logic.");return"Object"!==l&&(d.$name=l),d}function nc(e){if(ec(e))return e;if(Array.isArray(e))return e.map(nc);if("object"!=typeof e)throw new Error("can't deserialize object of type "+typeof e);const s=Jl(e)||"Object";if(!Yl[s])throw new Error(`can't deserialize unregistered class ${s}`);const{klass:l}=Yl[s];if(!l)throw new Error(`can't deserialize unregistered class ${s}`);if(l.deserialize)return l.deserialize(e);const c=Object.create(l.prototype);for(const l of Object.keys(e)){if("$name"===l)continue;const d=e[l];c[l]=Yl[s].shallow.indexOf(l)>=0?d:nc(d)}return c}class xs{constructor(){this.first=!0}update(e,s){const l=Math.floor(e);return this.first?(this.first=!1,this.lastIntegerZoom=l,this.lastIntegerZoomTime=0,this.lastZoom=e,this.lastFloorZoom=l,!0):(this.lastFloorZoom>l?(this.lastIntegerZoom=l+1,this.lastIntegerZoomTime=s):this.lastFloorZoom{try{return new RegExp(`\\p{sc=${e}}`,"u").source}catch(e){return null}})).filter((e=>e));return new RegExp(s.join("|"),"u")}const dc=uc(["Arab","Dupl","Mong","Ougr","Syrc"]);function pc(e){return!dc.test(String.fromCodePoint(e))}function fc(e){return!(oc(e)||(s=e,/[\xA7\xA9\xAE\xB1\xBC-\xBE\xD7\xF7\u2016\u2020\u2021\u2030\u2031\u203B\u203C\u2042\u2047-\u2049\u2051\u2100-\u218F\u221E\u2234\u2235\u2300-\u2307\u230C-\u231F\u2324-\u2328\u232B\u237D-\u239A\u23BE-\u23CD\u23CF\u23D1-\u23DB\u23E2-\u2422\u2424-\u24FF\u25A0-\u2619\u2620-\u2767\u2776-\u2793\u2B12-\u2B2F\u2B50-\u2B59\u2BB8-\u2BEB\u3000-\u303F\u30A0-\u30FF\uE000-\uF8FF\uFE30-\uFE6F\uFF00-\uFFEF\uFFFC\uFFFD]|[\uDB80-\uDBFF][\uDC00-\uDFFF]/gim.test(String.fromCodePoint(s))));var s}const mc=uc(["Adlm","Arab","Armi","Avst","Chrs","Cprt","Egyp","Elym","Gara","Hatr","Hebr","Hung","Khar","Lydi","Mand","Mani","Mend","Merc","Mero","Narb","Nbat","Nkoo","Orkh","Palm","Phli","Phlp","Phnx","Prti","Rohg","Samr","Sarb","Sogo","Syrc","Thaa","Todr","Yezi"]);function _c(e){return mc.test(String.fromCodePoint(e))}function gc(e,s){return!(!s&&_c(e)||/[\u0900-\u0DFF\u0F00-\u109F\u1780-\u17FF]/gim.test(String.fromCodePoint(e)))}function yc(e){for(const s of e)if(_c(s.codePointAt(0)))return!0;return!1}const xc=new class{constructor(){this.TIMEOUT=5e3,this.applyArabicShaping=null,this.processBidirectionalText=null,this.processStyledBidirectionalText=null,this.pluginStatus="unavailable",this.pluginURL=null,this.loadScriptResolve=()=>{}}setState(e){this.pluginStatus=e.pluginStatus,this.pluginURL=e.pluginURL}getState(){return{pluginStatus:this.pluginStatus,pluginURL:this.pluginURL}}setMethods(e){if(xc.isParsed())throw new Error("RTL text plugin already registered.");this.applyArabicShaping=e.applyArabicShaping,this.processBidirectionalText=e.processBidirectionalText,this.processStyledBidirectionalText=e.processStyledBidirectionalText,this.loadScriptResolve()}isParsed(){return null!=this.applyArabicShaping&&null!=this.processBidirectionalText&&null!=this.processStyledBidirectionalText}getRTLTextPluginStatus(){return this.pluginStatus}syncState(e,s){return l(this,void 0,void 0,(function*(){if(this.isParsed())return this.getState();if("loading"!==e.pluginStatus)return this.setState(e),e;const l=e.pluginURL,c=new Promise((e=>{this.loadScriptResolve=e}));s(l);const d=new Promise((e=>setTimeout((()=>e()),this.TIMEOUT)));if(yield Promise.race([c,d]),this.isParsed()){const e={pluginStatus:"loaded",pluginURL:l};return this.setState(e),e}throw this.setState({pluginStatus:"error",pluginURL:""}),new Error(`RTL Text Plugin failed to import scripts from ${l}`)}))}};class Ps{constructor(e,s){this.isSupportedScript=vc,this.zoom=e,s?(this.now=s.now||0,this.fadeDuration=s.fadeDuration||0,this.zoomHistory=s.zoomHistory||new xs,this.transition=s.transition||{}):(this.now=0,this.fadeDuration=0,this.zoomHistory=new xs,this.transition={})}crossFadingFactor(){return 0===this.fadeDuration?1:Math.min((this.now-this.zoomHistory.lastIntegerZoomTime)/this.fadeDuration,1)}getCrossfadeParameters(){const e=this.zoom,s=e-Math.floor(e),l=this.crossFadingFactor();return e>this.zoomHistory.lastIntegerZoom?{fromScale:2,toScale:1,t:s+(1-s)*l}:{fromScale:.5,toScale:1,t:1-(1-l)*s}}}function vc(e){return function(e,s){for(const l of e)if(!gc(l.codePointAt(0),s))return!1;return!0}(e,"loaded"===xc.getRTLTextPluginStatus())}const bc="-transition";class Cs{constructor(e,s,l){this.property=e,this.value=s,this.expression=function(e,s,l){if(Ms(e))return new oi(e,s);if(Bs(e)){const c=Ws(e,s,l);if("error"===c.result)throw new Error(c.value.map((e=>`${e.key}: ${e.message}`)).join(", "));return c.value}{let l=e;return"color"===s.type&&"string"==typeof e?l=Te.parse(e):"padding"!==s.type||"number"!=typeof e&&!Array.isArray(e)?"numberArray"!==s.type||"number"!=typeof e&&!Array.isArray(e)?"colorArray"!==s.type||"string"!=typeof e&&!Array.isArray(e)?"variableAnchorOffsetCollection"===s.type&&Array.isArray(e)?l=Le.parse(e):"projectionDefinition"===s.type&&"string"==typeof e&&(l=Re.parse(e)):l=Be.parse(e):l=Pe.parse(e):l=ze.parse(e),{globalStateRefs:new Set,_globalState:null,kind:"constant",evaluate:()=>l}}}(void 0===s?e.specification.default:s,e.specification,l)}isDataDriven(){return"source"===this.expression.kind||"composite"===this.expression.kind}getGlobalStateRefs(){return this.expression.globalStateRefs||new Set}possiblyEvaluate(e,s,l){return this.property.possiblyEvaluate(this,e,s,l)}}class Ls{constructor(e,s){this.property=e,this.value=new Cs(e,void 0,s)}transitioned(e,s){return new Rs(this.property,this.value,s,ge({},e.transition,this.transition),e.now)}untransitioned(){return new Rs(this.property,this.value,null,{},0)}}class Os{constructor(e,s){this._properties=e,this._values=Object.create(e.defaultTransitionablePropertyValues),this._globalState=s}getValue(e){return be(this._values[e].value.value)}setValue(e,s){Object.prototype.hasOwnProperty.call(this._values,e)||(this._values[e]=new Ls(this._values[e].property,this._globalState)),this._values[e].value=new Cs(this._values[e].property,null===s?void 0:be(s),this._globalState)}getTransition(e){return be(this._values[e].transition)}setTransition(e,s){Object.prototype.hasOwnProperty.call(this._values,e)||(this._values[e]=new Ls(this._values[e].property,this._globalState)),this._values[e].transition=be(s)||void 0}serialize(){const e={};for(const s of Object.keys(this._values)){const l=this.getValue(s);void 0!==l&&(e[s]=l);const c=this.getTransition(s);void 0!==c&&(e[`${s}${bc}`]=c)}return e}transitioned(e,s){const l=new Ns(this._properties);for(const c of Object.keys(this._values))l._values[c]=this._values[c].transitioned(e,s._values[c]);return l}untransitioned(){const e=new Ns(this._properties);for(const s of Object.keys(this._values))e._values[s]=this._values[s].untransitioned();return e}}class Rs{constructor(e,s,l,c,d){this.property=e,this.value=s,this.begin=d+c.delay||0,this.end=this.begin+c.duration||0,e.specification.transition&&(c.delay||c.duration)&&(this.prior=l)}possiblyEvaluate(e,s,l){const c=e.now||0,d=this.value.possiblyEvaluate(e,s,l),p=this.prior;if(p){if(c>this.end)return this.prior=null,d;if(this.value.isDataDriven())return this.prior=null,d;if(cc.zoomHistory.lastIntegerZoom?{from:e,to:s}:{from:l,to:s}}interpolate(e){return e}}class Ys{constructor(e){this.specification=e}possiblyEvaluate(e,s,l,c){if(void 0!==e.value){if("constant"===e.expression.kind){const d=e.expression.evaluate(s,null,{},l,c);return this._calculate(d,d,d,s)}return this._calculate(e.expression.evaluate(new Ps(Math.floor(s.zoom-1),s)),e.expression.evaluate(new Ps(Math.floor(s.zoom),s)),e.expression.evaluate(new Ps(Math.floor(s.zoom+1),s)),s)}}_calculate(e,s,l,c){return c.zoom>c.zoomHistory.lastIntegerZoom?{from:e,to:s}:{from:l,to:s}}interpolate(e){return e}}class Zs{constructor(e){this.specification=e}possiblyEvaluate(e,s,l,c){return!!e.expression.evaluate(s,null,{},l,c)}interpolate(){return!1}}class Hs{constructor(e){this.properties=e,this.defaultPropertyValues={},this.defaultTransitionablePropertyValues={},this.defaultTransitioningPropertyValues={},this.defaultPossiblyEvaluatedValues={},this.overridableProperties=[];for(const s in e){const l=e[s];l.specification.overridable&&this.overridableProperties.push(s);const c=this.defaultPropertyValues[s]=new Cs(l,void 0,void 0),d=this.defaultTransitionablePropertyValues[s]=new Ls(l,void 0);this.defaultTransitioningPropertyValues[s]=d.untransitioned(),this.defaultPossiblyEvaluatedValues[s]=c.possiblyEvaluate({})}}}Kl("DataDrivenProperty",Gs),Kl("DataConstantProperty",js),Kl("CrossFadedDataDrivenProperty",Xs),Kl("CrossFadedProperty",Ys),Kl("ColorRampProperty",Zs);class Ks extends xt{constructor(e,s,l){if(super(),this.id=e.id,this.type=e.type,this._globalState=l,this._featureFilter={filter:()=>!0,needGeometry:!1,getGlobalStateRefs:()=>new Set},this._visibilityExpression=function(e,s){return new rs(e,s)}(this.visibility,l),"custom"!==e.type&&(this.metadata=e.metadata,this.minzoom=e.minzoom,this.maxzoom=e.maxzoom,"background"!==e.type&&(this.source=e.source,this.sourceLayer=e["source-layer"],this.filter=e.filter,this._featureFilter=Co(e.filter,l)),s.layout&&(this._unevaluatedLayout=new $s(s.layout,l)),s.paint)){this._transitionablePaint=new Os(s.paint,l);for(const s in e.paint)this.setPaintProperty(s,e.paint[s],{validate:!1});for(const s in e.layout)this.setLayoutProperty(s,e.layout[s],{validate:!1});this._transitioningPaint=this._transitionablePaint.untransitioned(),this.paint=new qs(s.paint)}}setFilter(e){this.filter=e,this._featureFilter=Co(e,this._globalState)}getCrossfadeParameters(){return this._crossfadeParameters}getLayoutProperty(e){return"visibility"===e?this.visibility:this._unevaluatedLayout.getValue(e)}getLayoutAffectingGlobalStateRefs(){const e=new Set;for(const s of this._visibilityExpression.getGlobalStateRefs())e.add(s);if(this._unevaluatedLayout)for(const s in this._unevaluatedLayout._values){const l=this._unevaluatedLayout._values[s];for(const s of l.getGlobalStateRefs())e.add(s)}for(const s of this._featureFilter.getGlobalStateRefs())e.add(s);return e}getPaintAffectingGlobalStateRefs(){var e;const s=new globalThis.Map;if(this._transitionablePaint)for(const l in this._transitionablePaint._values){const c=this._transitionablePaint._values[l].value;for(const d of c.getGlobalStateRefs()){const p=null!==(e=s.get(d))&&void 0!==e?e:[];p.push({name:l,value:c.value}),s.set(d,p)}}return s}getVisibilityAffectingGlobalStateRefs(){return this._visibilityExpression.getGlobalStateRefs()}setLayoutProperty(e,s,l={}){if(null==s||!this._validate(Hl,`layers.${this.id}.layout.${e}`,e,s,l))return"visibility"===e?(this.visibility=s,this._visibilityExpression.setValue(s),void this.recalculateVisibility()):void this._unevaluatedLayout.setValue(e,s)}getPaintProperty(e){return e.endsWith(bc)?this._transitionablePaint.getTransition(e.slice(0,-11)):this._transitionablePaint.getValue(e)}setPaintProperty(e,s,l={}){if(null!=s&&this._validate(Wl,`layers.${this.id}.paint.${e}`,e,s,l))return!1;if(e.endsWith(bc))return this._transitionablePaint.setTransition(e.slice(0,-11),s||void 0),!1;{const l=this._transitionablePaint._values[e],c="cross-faded-data-driven"===l.property.specification["property-type"],d=l.value.isDataDriven(),p=l.value;this._transitionablePaint.setValue(e,s),this._handleSpecialPaintPropertyUpdate(e);const f=this._transitionablePaint._values[e].value;return f.isDataDriven()||d||c||this._handleOverridablePaintPropertyUpdate(e,p,f)}}_handleSpecialPaintPropertyUpdate(e){}_handleOverridablePaintPropertyUpdate(e,s,l){return!1}isHidden(e=this.minzoom,s=!1){return!!(this.minzoom&&e<(s?Math.floor(this.minzoom):this.minzoom))||!!(this.maxzoom&&e>=this.maxzoom)||"none"===this._evaluatedVisibility}updateTransitions(e){this._transitioningPaint=this._transitionablePaint.transitioned(e,this._transitioningPaint)}hasTransition(){return this._transitioningPaint.hasTransition()}recalculateVisibility(){this._evaluatedVisibility=this._visibilityExpression.evaluate()}recalculate(e,s){e.getCrossfadeParameters&&(this._crossfadeParameters=e.getCrossfadeParameters()),this._unevaluatedLayout&&(this.layout=this._unevaluatedLayout.possiblyEvaluate(e,void 0,s)),this.paint=this._transitioningPaint.possiblyEvaluate(e,void 0,s)}serialize(){const e={id:this.id,type:this.type,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()};return this.visibility&&(e.layout=e.layout||{},e.layout.visibility=this.visibility),ve(e,((e,s)=>!(void 0===e||"layout"===s&&!Object.keys(e).length||"paint"===s&&!Object.keys(e).length)))}_validate(e,s,l,c,d={}){return(!d||!1!==d.validate)&&Xl(this,e.call(ql,{key:s,layerType:this.type,objectKey:l,value:c,styleSpec:Tt,style:{glyphs:!0,sprite:!0}}))}is3D(){return!1}isTileClipped(){return!1}hasOffscreenPass(){return!1}resize(){}isStateDependent(){for(const e in this.paint._values){const s=this.paint.get(e);if(s instanceof Us&&bs(s.property.specification)&&("source"===s.value.kind||"composite"===s.value.kind)&&s.value.isStateDependent)return!0}return!1}}let wc;var Pc={get paint(){return wc=wc||new Hs({"raster-opacity":new js(Tt.paint_raster["raster-opacity"]),"raster-hue-rotate":new js(Tt.paint_raster["raster-hue-rotate"]),"raster-brightness-min":new js(Tt.paint_raster["raster-brightness-min"]),"raster-brightness-max":new js(Tt.paint_raster["raster-brightness-max"]),"raster-saturation":new js(Tt.paint_raster["raster-saturation"]),"raster-contrast":new js(Tt.paint_raster["raster-contrast"]),"raster-resampling":new js(Tt.paint_raster["raster-resampling"]),"raster-fade-duration":new js(Tt.paint_raster["raster-fade-duration"])})}};class Qs extends Ks{constructor(e,s){super(e,Pc,s)}}const Mc={Int8:Int8Array,Uint8:Uint8Array,Int16:Int16Array,Uint16:Uint16Array,Int32:Int32Array,Uint32:Uint32Array,Float32:Float32Array};class ea{constructor(e,s){this._structArray=e,this._pos1=s*this.size,this._pos2=this._pos1/2,this._pos4=this._pos1/4,this._pos8=this._pos1/8}}class ra{constructor(){this.isTransferred=!1,this.capacity=-1,this.resize(0)}static serialize(e,s){return e._trim(),s&&(e.isTransferred=!0,s.push(e.arrayBuffer)),{length:e.length,arrayBuffer:e.arrayBuffer}}static deserialize(e){const s=Object.create(this.prototype);return s.arrayBuffer=e.arrayBuffer,s.length=e.length,s.capacity=e.arrayBuffer.byteLength/s.bytesPerElement,s._refreshViews(),s}_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(e){this.reserve(e),this.length=e}reserve(e){if(e>this.capacity){this.capacity=Math.max(e,Math.floor(5*this.capacity),128),this.arrayBuffer=new ArrayBuffer(this.capacity*this.bytesPerElement);const s=this.uint8;this._refreshViews(),s&&this.uint8.set(s)}}_refreshViews(){throw new Error("_refreshViews() must be implemented by each concrete StructArray layout")}}function Ic(e,s=1){let l=0,c=0;return{members:e.map((e=>{const d=Mc[e.type].BYTES_PER_ELEMENT,p=l=Ec(l,Math.max(s,d)),f=e.components||1;return c=Math.max(c,d),l+=d*f,{name:e.name,type:e.type,components:f,offset:p}})),size:Ec(l,Math.max(c,s)),alignment:s}}function Ec(e,s){return Math.ceil(e/s)*s}class sa extends ra{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,s){const l=this.length;return this.resize(l+1),this.emplace(l,e,s)}emplace(e,s,l){const c=2*e;return this.int16[c+0]=s,this.int16[c+1]=l,e}}sa.prototype.bytesPerElement=4,Kl("StructArrayLayout2i4",sa);class aa extends ra{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,s,l){const c=this.length;return this.resize(c+1),this.emplace(c,e,s,l)}emplace(e,s,l,c){const d=3*e;return this.int16[d+0]=s,this.int16[d+1]=l,this.int16[d+2]=c,e}}aa.prototype.bytesPerElement=6,Kl("StructArrayLayout3i6",aa);class oa extends ra{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,s,l,c){const d=this.length;return this.resize(d+1),this.emplace(d,e,s,l,c)}emplace(e,s,l,c,d){const p=4*e;return this.int16[p+0]=s,this.int16[p+1]=l,this.int16[p+2]=c,this.int16[p+3]=d,e}}oa.prototype.bytesPerElement=8,Kl("StructArrayLayout4i8",oa);class la extends ra{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,s,l,c,d,p){const f=this.length;return this.resize(f+1),this.emplace(f,e,s,l,c,d,p)}emplace(e,s,l,c,d,p,f){const m=6*e;return this.int16[m+0]=s,this.int16[m+1]=l,this.int16[m+2]=c,this.int16[m+3]=d,this.int16[m+4]=p,this.int16[m+5]=f,e}}la.prototype.bytesPerElement=12,Kl("StructArrayLayout2i4i12",la);class ua extends ra{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,s,l,c,d,p){const f=this.length;return this.resize(f+1),this.emplace(f,e,s,l,c,d,p)}emplace(e,s,l,c,d,p,f){const m=4*e,_=8*e;return this.int16[m+0]=s,this.int16[m+1]=l,this.uint8[_+4]=c,this.uint8[_+5]=d,this.uint8[_+6]=p,this.uint8[_+7]=f,e}}ua.prototype.bytesPerElement=8,Kl("StructArrayLayout2i4ub8",ua);class ca extends ra{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,s){const l=this.length;return this.resize(l+1),this.emplace(l,e,s)}emplace(e,s,l){const c=2*e;return this.float32[c+0]=s,this.float32[c+1]=l,e}}ca.prototype.bytesPerElement=8,Kl("StructArrayLayout2f8",ca);class ha extends ra{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,s,l,c,d,p,f,m,_,g){const y=this.length;return this.resize(y+1),this.emplace(y,e,s,l,c,d,p,f,m,_,g)}emplace(e,s,l,c,d,p,f,m,_,g,y){const b=10*e;return this.uint16[b+0]=s,this.uint16[b+1]=l,this.uint16[b+2]=c,this.uint16[b+3]=d,this.uint16[b+4]=p,this.uint16[b+5]=f,this.uint16[b+6]=m,this.uint16[b+7]=_,this.uint16[b+8]=g,this.uint16[b+9]=y,e}}ha.prototype.bytesPerElement=20,Kl("StructArrayLayout10ui20",ha);class pa extends ra{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,s,l,c,d,p,f,m){const _=this.length;return this.resize(_+1),this.emplace(_,e,s,l,c,d,p,f,m)}emplace(e,s,l,c,d,p,f,m,_){const g=8*e;return this.uint16[g+0]=s,this.uint16[g+1]=l,this.uint16[g+2]=c,this.uint16[g+3]=d,this.uint16[g+4]=p,this.uint16[g+5]=f,this.uint16[g+6]=m,this.uint16[g+7]=_,e}}pa.prototype.bytesPerElement=16,Kl("StructArrayLayout8ui16",pa);class fa extends ra{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,s,l,c,d,p,f,m,_,g,y,b){const T=this.length;return this.resize(T+1),this.emplace(T,e,s,l,c,d,p,f,m,_,g,y,b)}emplace(e,s,l,c,d,p,f,m,_,g,y,b,T){const P=12*e;return this.int16[P+0]=s,this.int16[P+1]=l,this.int16[P+2]=c,this.int16[P+3]=d,this.uint16[P+4]=p,this.uint16[P+5]=f,this.uint16[P+6]=m,this.uint16[P+7]=_,this.int16[P+8]=g,this.int16[P+9]=y,this.int16[P+10]=b,this.int16[P+11]=T,e}}fa.prototype.bytesPerElement=24,Kl("StructArrayLayout4i4ui4i24",fa);class da extends ra{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,s,l){const c=this.length;return this.resize(c+1),this.emplace(c,e,s,l)}emplace(e,s,l,c){const d=3*e;return this.float32[d+0]=s,this.float32[d+1]=l,this.float32[d+2]=c,e}}da.prototype.bytesPerElement=12,Kl("StructArrayLayout3f12",da);class ya extends ra{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer)}emplaceBack(e){const s=this.length;return this.resize(s+1),this.emplace(s,e)}emplace(e,s){return this.uint32[1*e+0]=s,e}}ya.prototype.bytesPerElement=4,Kl("StructArrayLayout1ul4",ya);class ma extends ra{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,s,l,c,d,p,f,m,_){const g=this.length;return this.resize(g+1),this.emplace(g,e,s,l,c,d,p,f,m,_)}emplace(e,s,l,c,d,p,f,m,_,g){const y=10*e,b=5*e;return this.int16[y+0]=s,this.int16[y+1]=l,this.int16[y+2]=c,this.int16[y+3]=d,this.int16[y+4]=p,this.int16[y+5]=f,this.uint32[b+3]=m,this.uint16[y+8]=_,this.uint16[y+9]=g,e}}ma.prototype.bytesPerElement=20,Kl("StructArrayLayout6i1ul2ui20",ma);class ga extends ra{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,s,l,c,d,p){const f=this.length;return this.resize(f+1),this.emplace(f,e,s,l,c,d,p)}emplace(e,s,l,c,d,p,f){const m=6*e;return this.int16[m+0]=s,this.int16[m+1]=l,this.int16[m+2]=c,this.int16[m+3]=d,this.int16[m+4]=p,this.int16[m+5]=f,e}}ga.prototype.bytesPerElement=12,Kl("StructArrayLayout2i2i2i12",ga);class xa extends ra{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,s,l,c,d){const p=this.length;return this.resize(p+1),this.emplace(p,e,s,l,c,d)}emplace(e,s,l,c,d,p){const f=4*e,m=8*e;return this.float32[f+0]=s,this.float32[f+1]=l,this.float32[f+2]=c,this.int16[m+6]=d,this.int16[m+7]=p,e}}xa.prototype.bytesPerElement=16,Kl("StructArrayLayout2f1f2i16",xa);class va extends ra{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,s,l,c,d,p){const f=this.length;return this.resize(f+1),this.emplace(f,e,s,l,c,d,p)}emplace(e,s,l,c,d,p,f){const m=16*e,_=4*e,g=8*e;return this.uint8[m+0]=s,this.uint8[m+1]=l,this.float32[_+1]=c,this.float32[_+2]=d,this.int16[g+6]=p,this.int16[g+7]=f,e}}va.prototype.bytesPerElement=16,Kl("StructArrayLayout2ub2f2i16",va);class ba extends ra{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,s,l){const c=this.length;return this.resize(c+1),this.emplace(c,e,s,l)}emplace(e,s,l,c){const d=3*e;return this.uint16[d+0]=s,this.uint16[d+1]=l,this.uint16[d+2]=c,e}}ba.prototype.bytesPerElement=6,Kl("StructArrayLayout3ui6",ba);class wa extends ra{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,s,l,c,d,p,f,m,_,g,y,b,T,P,S,I,C){const R=this.length;return this.resize(R+1),this.emplace(R,e,s,l,c,d,p,f,m,_,g,y,b,T,P,S,I,C)}emplace(e,s,l,c,d,p,f,m,_,g,y,b,T,P,S,I,C,R){const L=24*e,F=12*e,B=48*e;return this.int16[L+0]=s,this.int16[L+1]=l,this.uint16[L+2]=c,this.uint16[L+3]=d,this.uint32[F+2]=p,this.uint32[F+3]=f,this.uint32[F+4]=m,this.uint16[L+10]=_,this.uint16[L+11]=g,this.uint16[L+12]=y,this.float32[F+7]=b,this.float32[F+8]=T,this.uint8[B+36]=P,this.uint8[B+37]=S,this.uint8[B+38]=I,this.uint32[F+10]=C,this.int16[L+22]=R,e}}wa.prototype.bytesPerElement=48,Kl("StructArrayLayout2i2ui3ul3ui2f3ub1ul1i48",wa);class _a extends ra{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,s,l,c,d,p,f,m,_,g,y,b,T,P,S,I,C,R,L,F,B,O,j,G,U,q,Z,W){const J=this.length;return this.resize(J+1),this.emplace(J,e,s,l,c,d,p,f,m,_,g,y,b,T,P,S,I,C,R,L,F,B,O,j,G,U,q,Z,W)}emplace(e,s,l,c,d,p,f,m,_,g,y,b,T,P,S,I,C,R,L,F,B,O,j,G,U,q,Z,W,J){const re=32*e,se=16*e;return this.int16[re+0]=s,this.int16[re+1]=l,this.int16[re+2]=c,this.int16[re+3]=d,this.int16[re+4]=p,this.int16[re+5]=f,this.int16[re+6]=m,this.int16[re+7]=_,this.uint16[re+8]=g,this.uint16[re+9]=y,this.uint16[re+10]=b,this.uint16[re+11]=T,this.uint16[re+12]=P,this.uint16[re+13]=S,this.uint16[re+14]=I,this.uint16[re+15]=C,this.uint16[re+16]=R,this.uint16[re+17]=L,this.uint16[re+18]=F,this.uint16[re+19]=B,this.uint16[re+20]=O,this.uint16[re+21]=j,this.uint16[re+22]=G,this.uint32[se+12]=U,this.float32[se+13]=q,this.float32[se+14]=Z,this.uint16[re+30]=W,this.uint16[re+31]=J,e}}_a.prototype.bytesPerElement=64,Kl("StructArrayLayout8i15ui1ul2f2ui64",_a);class Sa extends ra{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e){const s=this.length;return this.resize(s+1),this.emplace(s,e)}emplace(e,s){return this.float32[1*e+0]=s,e}}Sa.prototype.bytesPerElement=4,Kl("StructArrayLayout1f4",Sa);class Aa extends ra{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,s,l){const c=this.length;return this.resize(c+1),this.emplace(c,e,s,l)}emplace(e,s,l,c){const d=3*e;return this.uint16[6*e+0]=s,this.float32[d+1]=l,this.float32[d+2]=c,e}}Aa.prototype.bytesPerElement=12,Kl("StructArrayLayout1ui2f12",Aa);class ka extends ra{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,s,l){const c=this.length;return this.resize(c+1),this.emplace(c,e,s,l)}emplace(e,s,l,c){const d=4*e;return this.uint32[2*e+0]=s,this.uint16[d+2]=l,this.uint16[d+3]=c,e}}ka.prototype.bytesPerElement=8,Kl("StructArrayLayout1ul2ui8",ka);class Ea extends ra{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,s){const l=this.length;return this.resize(l+1),this.emplace(l,e,s)}emplace(e,s,l){const c=2*e;return this.uint16[c+0]=s,this.uint16[c+1]=l,e}}Ea.prototype.bytesPerElement=4,Kl("StructArrayLayout2ui4",Ea);class Ta extends ra{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e){const s=this.length;return this.resize(s+1),this.emplace(s,e)}emplace(e,s){return this.uint16[1*e+0]=s,e}}Ta.prototype.bytesPerElement=2,Kl("StructArrayLayout1ui2",Ta);class Ia extends ra{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,s,l,c){const d=this.length;return this.resize(d+1),this.emplace(d,e,s,l,c)}emplace(e,s,l,c,d){const p=4*e;return this.float32[p+0]=s,this.float32[p+1]=l,this.float32[p+2]=c,this.float32[p+3]=d,e}}Ia.prototype.bytesPerElement=16,Kl("StructArrayLayout4f16",Ia);class Ma extends ea{get anchorPointX(){return this._structArray.int16[this._pos2+0]}get anchorPointY(){return this._structArray.int16[this._pos2+1]}get x1(){return this._structArray.int16[this._pos2+2]}get y1(){return this._structArray.int16[this._pos2+3]}get x2(){return this._structArray.int16[this._pos2+4]}get y2(){return this._structArray.int16[this._pos2+5]}get featureIndex(){return this._structArray.uint32[this._pos4+3]}get sourceLayerIndex(){return this._structArray.uint16[this._pos2+8]}get bucketIndex(){return this._structArray.uint16[this._pos2+9]}get anchorPoint(){return new c(this.anchorPointX,this.anchorPointY)}}Ma.prototype.size=20;class Fa extends ma{get(e){return new Ma(this,e)}}Kl("CollisionBoxArray",Fa);class Da extends ea{get anchorX(){return this._structArray.int16[this._pos2+0]}get anchorY(){return this._structArray.int16[this._pos2+1]}get glyphStartIndex(){return this._structArray.uint16[this._pos2+2]}get numGlyphs(){return this._structArray.uint16[this._pos2+3]}get vertexStartIndex(){return this._structArray.uint32[this._pos4+2]}get lineStartIndex(){return this._structArray.uint32[this._pos4+3]}get lineLength(){return this._structArray.uint32[this._pos4+4]}get segment(){return this._structArray.uint16[this._pos2+10]}get lowerSize(){return this._structArray.uint16[this._pos2+11]}get upperSize(){return this._structArray.uint16[this._pos2+12]}get lineOffsetX(){return this._structArray.float32[this._pos4+7]}get lineOffsetY(){return this._structArray.float32[this._pos4+8]}get writingMode(){return this._structArray.uint8[this._pos1+36]}get placedOrientation(){return this._structArray.uint8[this._pos1+37]}set placedOrientation(e){this._structArray.uint8[this._pos1+37]=e}get hidden(){return this._structArray.uint8[this._pos1+38]}set hidden(e){this._structArray.uint8[this._pos1+38]=e}get crossTileID(){return this._structArray.uint32[this._pos4+10]}set crossTileID(e){this._structArray.uint32[this._pos4+10]=e}get associatedIconIndex(){return this._structArray.int16[this._pos2+22]}}Da.prototype.size=48;class za extends wa{get(e){return new Da(this,e)}}Kl("PlacedSymbolArray",za);class Pa extends ea{get anchorX(){return this._structArray.int16[this._pos2+0]}get anchorY(){return this._structArray.int16[this._pos2+1]}get rightJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+2]}get centerJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+3]}get leftJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+4]}get verticalPlacedTextSymbolIndex(){return this._structArray.int16[this._pos2+5]}get placedIconSymbolIndex(){return this._structArray.int16[this._pos2+6]}get verticalPlacedIconSymbolIndex(){return this._structArray.int16[this._pos2+7]}get key(){return this._structArray.uint16[this._pos2+8]}get textBoxStartIndex(){return this._structArray.uint16[this._pos2+9]}get textBoxEndIndex(){return this._structArray.uint16[this._pos2+10]}get verticalTextBoxStartIndex(){return this._structArray.uint16[this._pos2+11]}get verticalTextBoxEndIndex(){return this._structArray.uint16[this._pos2+12]}get iconBoxStartIndex(){return this._structArray.uint16[this._pos2+13]}get iconBoxEndIndex(){return this._structArray.uint16[this._pos2+14]}get verticalIconBoxStartIndex(){return this._structArray.uint16[this._pos2+15]}get verticalIconBoxEndIndex(){return this._structArray.uint16[this._pos2+16]}get featureIndex(){return this._structArray.uint16[this._pos2+17]}get numHorizontalGlyphVertices(){return this._structArray.uint16[this._pos2+18]}get numVerticalGlyphVertices(){return this._structArray.uint16[this._pos2+19]}get numIconVertices(){return this._structArray.uint16[this._pos2+20]}get numVerticalIconVertices(){return this._structArray.uint16[this._pos2+21]}get useRuntimeCollisionCircles(){return this._structArray.uint16[this._pos2+22]}get crossTileID(){return this._structArray.uint32[this._pos4+12]}set crossTileID(e){this._structArray.uint32[this._pos4+12]=e}get textBoxScale(){return this._structArray.float32[this._pos4+13]}get collisionCircleDiameter(){return this._structArray.float32[this._pos4+14]}get textAnchorOffsetStartIndex(){return this._structArray.uint16[this._pos2+30]}get textAnchorOffsetEndIndex(){return this._structArray.uint16[this._pos2+31]}}Pa.prototype.size=64;class Ba extends _a{get(e){return new Pa(this,e)}}Kl("SymbolInstanceArray",Ba);class Va extends Sa{getoffsetX(e){return this.float32[1*e+0]}}Kl("GlyphOffsetArray",Va);class Ca extends aa{getx(e){return this.int16[3*e+0]}gety(e){return this.int16[3*e+1]}gettileUnitDistanceFromAnchor(e){return this.int16[3*e+2]}}Kl("SymbolLineVertexArray",Ca);class La extends ea{get textAnchor(){return this._structArray.uint16[this._pos2+0]}get textOffset0(){return this._structArray.float32[this._pos4+1]}get textOffset1(){return this._structArray.float32[this._pos4+2]}}La.prototype.size=12;class Oa extends Aa{get(e){return new La(this,e)}}Kl("TextAnchorOffsetArray",Oa);class Ra extends ea{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]}}Ra.prototype.size=8;class Na extends ka{get(e){return new Ra(this,e)}}Kl("FeatureIndexArray",Na);class $a extends sa{}class Ua extends sa{}class qa extends sa{}class ja extends la{}class Ga extends ua{}class Xa extends ca{}class Ya extends ha{}class Za extends pa{}class Ha extends fa{}class Ka extends da{}class Wa extends ya{}class Ja extends ga{}class Qa extends va{}class to extends ba{}class eo extends Ea{}const Cc=Ic([{name:"a_pos",components:2,type:"Int16"}],4),{members:Ac}=Cc;class io{constructor(e=[]){this._forceNewSegmentOnNextPrepare=!1,this.segments=e}prepareSegment(e,s,l,c){const d=this.segments[this.segments.length-1];return e>io.MAX_VERTEX_ARRAY_LENGTH&&Se(`Max vertices per segment is ${io.MAX_VERTEX_ARRAY_LENGTH}: bucket requested ${e}. Consider using the \`fillLargeMeshArrays\` function if you require meshes with more than ${io.MAX_VERTEX_ARRAY_LENGTH} vertices.`),this._forceNewSegmentOnNextPrepare||!d||d.vertexLength+e>io.MAX_VERTEX_ARRAY_LENGTH||d.sortKey!==c?this.createNewSegment(s,l,c):d}createNewSegment(e,s,l){const c={vertexOffset:e.length,primitiveOffset:s.length,vertexLength:0,primitiveLength:0,vaos:{}};return void 0!==l&&(c.sortKey=l),this._forceNewSegmentOnNextPrepare=!1,this.segments.push(c),c}getOrCreateLatestSegment(e,s,l){return this.prepareSegment(0,e,s,l)}forceNewSegmentOnNextPrepare(){this._forceNewSegmentOnNextPrepare=!0}get(){return this.segments}destroy(){for(const e of this.segments)for(const s in e.vaos)e.vaos[s].destroy()}static simpleSegment(e,s,l,c){return new io([{vertexOffset:e,primitiveOffset:s,vertexLength:l,primitiveLength:c,vaos:{},sortKey:0}])}}function Dc(e,s){return 256*(e=fe(Math.floor(e),0,255))+fe(Math.floor(s),0,255)}io.MAX_VERTEX_ARRAY_LENGTH=Math.pow(2,16)-1,Kl("SegmentVector",io);const zc=Ic([{name:"a_pattern_from",components:4,type:"Uint16"},{name:"a_pattern_to",components:4,type:"Uint16"},{name:"a_pixel_ratio_from",components:1,type:"Uint16"},{name:"a_pixel_ratio_to",components:1,type:"Uint16"}]),kc=Ic([{name:"a_dasharray_from",components:4,type:"Uint16"},{name:"a_dasharray_to",components:4,type:"Uint16"}]);var Rc,Lc,Fc,Bc={exports:{}},Oc={exports:{}},Vc={exports:{}},Nc=function(){if(Fc)return Bc.exports;Fc=1;var e=(Rc||(Rc=1,Oc.exports=function(e,s){var l,c,d,p,f,m,_,g;for(c=e.length-(l=3&e.length),d=s,f=3432918353,m=461845907,g=0;g>>16)*f&65535)<<16)&4294967295)<<15|_>>>17))*m+(((_>>>16)*m&65535)<<16)&4294967295)<<13|d>>>19))+((5*(d>>>16)&65535)<<16)&4294967295))+((58964+(p>>>16)&65535)<<16);switch(_=0,l){case 3:_^=(255&e.charCodeAt(g+2))<<16;case 2:_^=(255&e.charCodeAt(g+1))<<8;case 1:d^=_=(65535&(_=(_=(65535&(_^=255&e.charCodeAt(g)))*f+(((_>>>16)*f&65535)<<16)&4294967295)<<15|_>>>17))*m+(((_>>>16)*m&65535)<<16)&4294967295}return d^=e.length,d=2246822507*(65535&(d^=d>>>16))+((2246822507*(d>>>16)&65535)<<16)&4294967295,d=3266489909*(65535&(d^=d>>>13))+((3266489909*(d>>>16)&65535)<<16)&4294967295,(d^=d>>>16)>>>0}),Oc.exports),s=(Lc||(Lc=1,Vc.exports=function(e,s){for(var l,c=e.length,d=s^c,p=0;c>=4;)l=1540483477*(65535&(l=255&e.charCodeAt(p)|(255&e.charCodeAt(++p))<<8|(255&e.charCodeAt(++p))<<16|(255&e.charCodeAt(++p))<<24))+((1540483477*(l>>>16)&65535)<<16),d=1540483477*(65535&d)+((1540483477*(d>>>16)&65535)<<16)^(l=1540483477*(65535&(l^=l>>>24))+((1540483477*(l>>>16)&65535)<<16)),c-=4,++p;switch(c){case 3:d^=(255&e.charCodeAt(p+2))<<16;case 2:d^=(255&e.charCodeAt(p+1))<<8;case 1:d=1540483477*(65535&(d^=255&e.charCodeAt(p)))+((1540483477*(d>>>16)&65535)<<16)}return d=1540483477*(65535&(d^=d>>>13))+((1540483477*(d>>>16)&65535)<<16),(d^=d>>>15)>>>0}),Vc.exports);return Bc.exports=e,Bc.exports.murmur3=e,Bc.exports.murmur2=s,Bc.exports}(),Gc=d(Nc);class go{constructor(){this.ids=[],this.positions=[],this.indexed=!1}add(e,s,l,c){this.ids.push(Uc(e)),this.positions.push(s,l,c)}getPositions(e){if(!this.indexed)throw new Error("Trying to get index, but feature positions are not indexed");const s=Uc(e);let l=0,c=this.ids.length-1;for(;l>1;this.ids[e]>=s?c=e:l=e+1}const d=[];for(;this.ids[l]===s;)d.push({index:this.positions[3*l],start:this.positions[3*l+1],end:this.positions[3*l+2]}),l++;return d}static serialize(e,s){const l=new Float64Array(e.ids),c=new Uint32Array(e.positions);return Zc(l,c,0,l.length-1),s&&s.push(l.buffer,c.buffer),{ids:l,positions:c}}static deserialize(e){const s=new go;return s.ids=e.ids,s.positions=e.positions,s.indexed=!0,s}}function Uc(e){const s=+e;return!isNaN(s)&&s<=Number.MAX_SAFE_INTEGER?s:Gc(String(e))}function Zc(e,s,l,c){for(;l>1];let p=l-1,f=c+1;for(;;){do{p++}while(e[p]d);if(p>=f)break;$c(e,p,f),$c(s,3*p,3*f),$c(s,3*p+1,3*f+1),$c(s,3*p+2,3*f+2)}f-l`u_${e}`)),this.type=l}setUniform(e,s,l){e.set(l.constantOr(this.value))}getBinding(e,s,l){return"color"===this.type?new Ao(e,s):new _o(e,s)}}class Io{constructor(e,s){this.uniformNames=s.map((e=>`u_${e}`)),this.patternFrom=null,this.patternTo=null,this.pixelRatioFrom=1,this.pixelRatioTo=1}setConstantPatternPositions(e,s){this.pixelRatioFrom=s.pixelRatio,this.pixelRatioTo=e.pixelRatio,this.patternFrom=s.tlbr,this.patternTo=e.tlbr}setConstantDashPositions(e,s){this.dashTo=[0,e.y,e.height,e.width],this.dashFrom=[0,s.y,s.height,s.width]}setUniform(e,s,l,c){let d=null;"u_pattern_to"===c?d=this.patternTo:"u_pattern_from"===c?d=this.patternFrom:"u_dasharray_to"===c?d=this.dashTo:"u_dasharray_from"===c?d=this.dashFrom:"u_pixel_ratio_to"===c?d=this.pixelRatioTo:"u_pixel_ratio_from"===c&&(d=this.pixelRatioFrom),null!==d&&e.set(d)}getBinding(e,s,l){return"u_pattern"===l.substr(0,9)||"u_dasharray_"===l.substr(0,12)?new So(e,s):new _o(e,s)}}class Mo{constructor(e,s,l,c){this.expression=e,this.type=l,this.maxValue=0,this.paintVertexAttributes=s.map((e=>({name:`a_${e}`,type:"Float32",components:"color"===l?2:1,offset:0}))),this.paintVertexArray=new c}populatePaintArray(e,s,l){const c=this.paintVertexArray.length,d=this.expression.evaluate(new Ps(0,l),s,{},l.canonical,[],l.formattedSection);this.paintVertexArray.resize(e),this._setPaintValue(c,e,d)}updatePaintArray(e,s,l,c,d){const p=this.expression.evaluate(new Ps(0,d),l,c);this._setPaintValue(e,s,p)}_setPaintValue(e,s,l){if("color"===this.type){const c=Hc(l);for(let l=e;l`u_${e}_t`)),this.type=l,this.useIntegerZoom=c,this.zoom=d,this.maxValue=0,this.paintVertexAttributes=s.map((e=>({name:`a_${e}`,type:"Float32",components:"color"===l?4:2,offset:0}))),this.paintVertexArray=new p}populatePaintArray(e,s,l){const c=this.expression.evaluate(new Ps(this.zoom,l),s,{},l.canonical,[],l.formattedSection),d=this.expression.evaluate(new Ps(this.zoom+1,l),s,{},l.canonical,[],l.formattedSection),p=this.paintVertexArray.length;this.paintVertexArray.resize(e),this._setPaintValue(p,e,c,d)}updatePaintArray(e,s,l,c,d){const p=this.expression.evaluate(new Ps(this.zoom,d),l,c),f=this.expression.evaluate(new Ps(this.zoom+1,d),l,c);this._setPaintValue(e,s,p,f)}_setPaintValue(e,s,l,c){if("color"===this.type){const d=Hc(l),p=Hc(c);for(let l=e;l`#define HAS_UNIFORM_${e}`)))}return e}getBinderAttributes(){const e=[];for(const s in this.binders){const l=this.binders[s];if(l instanceof Mo||l instanceof Fo)for(let s=0;s!0){this.programConfigurations={};for(const c of e)this.programConfigurations[c.id]=new Bo(c,s,l);this.needsUpload=!1,this._featureMap=new go,this._bufferOffset=0}populatePaintArrays(e,s,l,c){for(const l in this.programConfigurations)this.programConfigurations[l].populatePaintArrays(e,s,c);void 0!==s.id&&this._featureMap.add(s.id,l,this._bufferOffset,e),this._bufferOffset=e,this.needsUpload=!0}updatePaintArrays(e,s,l,c){for(const d of l)this.needsUpload=this.programConfigurations[d.id].updatePaintArrays(e,this._featureMap,s,d,c)||this.needsUpload}get(e){return this.programConfigurations[e]}upload(e){if(this.needsUpload){for(const s in this.programConfigurations)this.programConfigurations[s].upload(e);this.needsUpload=!1}}destroy(){for(const e in this.programConfigurations)this.programConfigurations[e].destroy()}}function Xc(e,s){return{"text-opacity":["opacity"],"icon-opacity":["opacity"],"text-color":["fill_color"],"icon-color":["fill_color"],"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-dasharray":["dasharray_to","dasharray_from"],"line-pattern":["pattern_to","pattern_from","pixel_ratio_to","pixel_ratio_from"],"fill-pattern":["pattern_to","pattern_from","pixel_ratio_to","pixel_ratio_from"],"fill-extrusion-pattern":["pattern_to","pattern_from","pixel_ratio_to","pixel_ratio_from"]}[e]||[e.replace(`${s}-`,"").replace(/-/g,"_")]}function Yc(e,s,l){const c={color:{source:ca,composite:Ia},number:{source:Sa,composite:ca}},d=function(e){return{"line-pattern":{source:Ya,composite:Ya},"fill-pattern":{source:Ya,composite:Ya},"fill-extrusion-pattern":{source:Ya,composite:Ya},"line-dasharray":{source:Za,composite:Za}}[e]}(e);return d&&d[l]||c[s][l]}Kl("ConstantBinder",To),Kl("CrossFadedConstantBinder",Io),Kl("SourceExpressionBinder",Mo),Kl("CrossFadedPatternBinder",zo),Kl("CrossFadedDasharrayBinder",Po),Kl("CompositeExpressionBinder",Fo),Kl("ProgramConfiguration",Bo,{omit:["_buffers"]}),Kl("ProgramConfigurationSet",Vo);const Kc=Math.pow(2,14)-1,Qc=-Kc-1;function Jc(e){const s=se/e.extent,l=e.loadGeometry();for(let e=0;el.x+1||pl.y+1)&&Se("Geometry exceeds allowed extent, reduce your vector tile buffer size")}}return l}function eh(e,s){return{type:e.type,id:e.id,properties:e.properties,geometry:s?Jc(e):[]}}const th=-32768;function ih(e,s,l,c,d){e.emplaceBack(th+8*s+c,th+8*l+d)}class jo{constructor(e){this.zoom=e.zoom,this.overscaling=e.overscaling,this.layers=e.layers,this.layerIds=this.layers.map((e=>e.id)),this.index=e.index,this.hasDependencies=!1,this.layoutVertexArray=new Ua,this.indexArray=new to,this.segments=new io,this.programConfigurations=new Vo(e.layers,e.zoom),this.stateDependentLayerIds=this.layers.filter((e=>e.isStateDependent())).map((e=>e.id))}populate(e,s,l){const c=this.layers[0],d=[];let p=null,f=!1,m="heatmap"===c.type;if("circle"===c.type){const e=c;p=e.layout.get("circle-sort-key"),f=!p.isConstant(),m=m||"map"===e.paint.get("circle-pitch-alignment")}const _=m?s.subdivisionGranularity.circle:1;for(const{feature:s,id:c,index:m,sourceLayerIndex:_}of e){const e=this.layers[0]._featureFilter.needGeometry,g=eh(s,e);if(!this.layers[0]._featureFilter.filter(new Ps(this.zoom),g,l))continue;const y=f?p.evaluate(g,{},l):void 0,b={id:c,properties:s.properties,type:s.type,sourceLayerIndex:_,index:m,geometry:e?g.geometry:Jc(s),patterns:{},sortKey:y};d.push(b)}f&&d.sort(((e,s)=>e.sortKey-s.sortKey));for(const c of d){const{geometry:d,index:p,sourceLayerIndex:f}=c,m=e[p].feature;this.addFeature(c,d,p,l,_),s.featureIndex.insert(m,d,p,f,this.index)}}update(e,s,l){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(e,s,this.stateDependentLayers,{imagePositions:l})}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(e){this.uploaded||(this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,Ac),this.indexBuffer=e.createIndexBuffer(this.indexArray)),this.programConfigurations.upload(e),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy())}addFeature(e,s,l,c,d=1){let p;switch(d){case 1:p=[0,7];break;case 3:p=[0,2,5,7];break;case 5:p=[0,1,3,4,6,7];break;case 7:p=[0,1,2,3,4,5,6,7];break;default:throw new Error(`Invalid circle bucket granularity: ${d}; valid values are 1, 3, 5, 7.`)}const f=p.length;for(const l of s)for(const s of l){const l=s.x,c=s.y;if(l<0||l>=se||c<0||c>=se)continue;const d=this.segments.prepareSegment(f*f,this.layoutVertexArray,this.indexArray,e.sortKey),m=d.vertexLength;for(let e=0;e1){if(ah(e,s))return!0;for(let c=0;c1?l:l.sub(s)._mult(d)._add(s))}function dh(e,s){let l,c,d,p=!1;for(let f=0;fs.y!=d.y>s.y&&s.x<(d.x-c.x)*(s.y-c.y)/(d.y-c.y)+c.x&&(p=!p)}return p}function mh(e,s){let l=!1;for(let c=0,d=e.length-1;cs.y!=f.y>s.y&&s.x<(f.x-p.x)*(s.y-p.y)/(f.y-p.y)+p.x&&(l=!l)}return l}function yh(e,s,l){const c=l[0],d=l[2];if(e.xd.x&&s.x>d.x||e.yd.y&&s.y>d.y)return!1;const p=Me(e,s,l[0]);return p!==Me(e,s,l[1])||p!==Me(e,s,l[2])||p!==Me(e,s,l[3])}function vh(e,s,l){const c=s.paint.get(e).value;return"constant"===c.kind?c.value:l.programConfigurations.get(s.id).getMaxValue(e)}function bh(e){return Math.sqrt(e[0]*e[0]+e[1]*e[1])}function Th(e,s,l,d,p){if(!s[0]&&!s[1])return e;const f=c.convert(s)._mult(p);"viewport"===l&&f._rotate(-d);const m=[];for(let s=0;szh(e,s,l,c)))}(_,d,f,m),P=g),Dh({queryGeometry:T,size:P,transform:d,unwrappedTileID:f,getElevation:m,pitchAlignment:b,pitchScale:y},c)}}class ml extends jo{}let Nh;Kl("HeatmapBucket",ml,{omit:["layers"]});var Uh={get paint(){return Nh=Nh||new Hs({"heatmap-radius":new Gs(Tt.paint_heatmap["heatmap-radius"]),"heatmap-weight":new Gs(Tt.paint_heatmap["heatmap-weight"]),"heatmap-intensity":new js(Tt.paint_heatmap["heatmap-intensity"]),"heatmap-color":new Zs(Tt.paint_heatmap["heatmap-color"]),"heatmap-opacity":new js(Tt.paint_heatmap["heatmap-opacity"])})}};function qh(e,{width:s,height:l},c,d){if(d){if(d instanceof Uint8ClampedArray)d=new Uint8Array(d.buffer);else if(d.length!==s*l*c)throw new RangeError(`mismatched image size. expected: ${d.length} but got: ${s*l*c}`)}else d=new Uint8Array(s*l*c);return e.width=s,e.height=l,e.data=d,e}function $h(e,{width:s,height:l},c){if(s===e.width&&l===e.height)return;const d=qh({},{width:s,height:l},c);eu(e,d,{x:0,y:0},{x:0,y:0},{width:Math.min(e.width,s),height:Math.min(e.height,l)},c),e.width=s,e.height=l,e.data=d.data}function eu(e,s,l,c,d,p){if(0===d.width||0===d.height)return s;if(d.width>e.width||d.height>e.height||l.x>e.width-d.width||l.y>e.height-d.height)throw new RangeError("out of range source coordinates for image copy");if(d.width>s.width||d.height>s.height||c.x>s.width-d.width||c.y>s.height-d.height)throw new RangeError("out of range destination coordinates for image copy");const f=e.data,m=s.data;if(f===m)throw new Error("srcData equals dstData, so image is already copied");for(let _=0;_{s[e.evaluationKey]=f;const m=e.expression.evaluate(s);d.setPixel(c/4/l,p/4,m)};if(e.clips)for(let s=0,d=0;sthis.max&&(this.max=l),l=this.dim+1||s<-1||s>=this.dim+1)throw new RangeError(`Out of range source coordinates for DEM data. x: ${e}, y: ${s}, dim: ${this.dim}`);return(s+1)*this.stride+(e+1)}unpack(e,s,l){return e*this.redFactor+s*this.greenFactor+l*this.blueFactor-this.baseShift}pack(e){return au(e,this.getUnpackVector())}getPixels(){return new Sl({width:this.stride,height:this.stride},new Uint8Array(this.data.buffer))}backfillBorder(e,s,l){if(this.dim!==e.dim)throw new Error("dem dimension mismatch");let c=s*this.dim,d=s*this.dim+this.dim,p=l*this.dim,f=l*this.dim+this.dim;switch(s){case-1:c=d-1;break;case 1:d=c+1}switch(l){case-1:p=f-1;break;case 1:f=p+1}const m=-s*this.dim,_=-l*this.dim;for(let s=p;s0)for(let d=s;d=s;d-=c)p=qu(d/c|0,e[d],e[d+1],p);return p&&Fu(p,p.next)&&(Zu(p),p=p.next),p}function mu(e,s){if(!e)return e;s||(s=e);let l,c=e;do{if(l=!1,c.steiner||!Fu(c,c.next)&&0!==Lu(c.prev,c,c.next))c=c.next;else{if(Zu(c),c=s=c.prev,c===c.next)break;l=!0}}while(l||c!==s);return s}function _u(e,s,l,c,d,p,f){if(!e)return;!f&&p&&function(e,s,l,c){let d=e;do{0===d.z&&(d.z=Eu(d.x,d.y,s,l,c)),d.prevZ=d.prev,d.nextZ=d.next,d=d.next}while(d!==e);d.prevZ.nextZ=null,d.prevZ=null,function(e){let s,l=1;do{let c,d=e;e=null;let p=null;for(s=0;d;){s++;let f=d,m=0;for(let e=0;e0||_>0&&f;)0!==m&&(0===_||!f||d.z<=f.z)?(c=d,d=d.nextZ,m--):(c=f,f=f.nextZ,_--),p?p.nextZ=c:e=c,c.prevZ=p,p=c;d=f}p.nextZ=null,l*=2}while(s>1)}(d)}(e,c,d,p);let m=e;for(;e.prev!==e.next;){const _=e.prev,g=e.next;if(p?xu(e,c,d,p):gu(e))s.push(_.i,e.i,g.i),Zu(e),e=g.next,m=g.next;else if((e=g)===m){f?1===f?_u(e=vu(mu(e),s),s,l,c,d,p,2):2===f&&bu(e,s,l,c,d,p):_u(mu(e),s,l,c,d,p,1);break}}}function gu(e){const s=e.prev,l=e,c=e.next;if(Lu(s,l,c)>=0)return!1;const d=s.x,p=l.x,f=c.x,m=s.y,_=l.y,g=c.y,y=Math.min(d,p,f),b=Math.min(m,_,g),T=Math.max(d,p,f),P=Math.max(m,_,g);let S=c.next;for(;S!==s;){if(S.x>=y&&S.x<=T&&S.y>=b&&S.y<=P&&Du(d,m,p,_,f,g,S.x,S.y)&&Lu(S.prev,S,S.next)>=0)return!1;S=S.next}return!0}function xu(e,s,l,c){const d=e.prev,p=e,f=e.next;if(Lu(d,p,f)>=0)return!1;const m=d.x,_=p.x,g=f.x,y=d.y,b=p.y,T=f.y,P=Math.min(m,_,g),S=Math.min(y,b,T),I=Math.max(m,_,g),C=Math.max(y,b,T),R=Eu(P,S,s,l,c),L=Eu(I,C,s,l,c);let F=e.prevZ,B=e.nextZ;for(;F&&F.z>=R&&B&&B.z<=L;){if(F.x>=P&&F.x<=I&&F.y>=S&&F.y<=C&&F!==d&&F!==f&&Du(m,y,_,b,g,T,F.x,F.y)&&Lu(F.prev,F,F.next)>=0)return!1;if(F=F.prevZ,B.x>=P&&B.x<=I&&B.y>=S&&B.y<=C&&B!==d&&B!==f&&Du(m,y,_,b,g,T,B.x,B.y)&&Lu(B.prev,B,B.next)>=0)return!1;B=B.nextZ}for(;F&&F.z>=R;){if(F.x>=P&&F.x<=I&&F.y>=S&&F.y<=C&&F!==d&&F!==f&&Du(m,y,_,b,g,T,F.x,F.y)&&Lu(F.prev,F,F.next)>=0)return!1;F=F.prevZ}for(;B&&B.z<=L;){if(B.x>=P&&B.x<=I&&B.y>=S&&B.y<=C&&B!==d&&B!==f&&Du(m,y,_,b,g,T,B.x,B.y)&&Lu(B.prev,B,B.next)>=0)return!1;B=B.nextZ}return!0}function vu(e,s){let l=e;do{const c=l.prev,d=l.next.next;!Fu(c,d)&&Bu(c,l,l.next,d)&&Nu(c,d)&&Nu(d,c)&&(s.push(c.i,l.i,d.i),Zu(l),Zu(l.next),l=e=d),l=l.next}while(l!==e);return mu(l)}function bu(e,s,l,c,d,p){let f=e;do{let e=f.next.next;for(;e!==f.prev;){if(f.i!==e.i&&zu(f,e)){let m=Uu(f,e);return f=mu(f,f.next),m=mu(m,m.next),_u(f,s,l,c,d,p,0),void _u(m,s,l,c,d,p,0)}e=e.next}f=f.next}while(f!==e)}function Tu(e,s){let l=e.x-s.x;return 0===l&&(l=e.y-s.y,0===l)&&(l=(e.next.y-e.y)/(e.next.x-e.x)-(s.next.y-s.y)/(s.next.x-s.x)),l}function Su(e,s){const l=function(e,s){let l=s;const c=e.x,d=e.y;let p,f=-1/0;if(Fu(e,l))return l;do{if(Fu(e,l.next))return l.next;if(d<=l.y&&d>=l.next.y&&l.next.y!==l.y){const e=l.x+(d-l.y)*(l.next.x-l.x)/(l.next.y-l.y);if(e<=c&&e>f&&(f=e,p=l.x=l.x&&l.x>=_&&c!==l.x&&Au(dp.x||l.x===p.x&&Iu(p,l)))&&(p=l,y=s)}l=l.next}while(l!==m);return p}(e,s);if(!l)return s;const c=Uu(l,e);return mu(c,c.next),mu(l,l.next)}function Iu(e,s){return Lu(e.prev,e,s.prev)<0&&Lu(s.next,e,e.next)<0}function Eu(e,s,l,c,d){return(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=(e-l)*d|0)|e<<8))|e<<4))|e<<2))|e<<1))|(s=1431655765&((s=858993459&((s=252645135&((s=16711935&((s=(s-c)*d|0)|s<<8))|s<<4))|s<<2))|s<<1))<<1}function Cu(e){let s=e,l=e;do{(s.x=(e-f)*(p-m)&&(e-f)*(c-m)>=(l-f)*(s-m)&&(l-f)*(p-m)>=(d-f)*(c-m)}function Du(e,s,l,c,d,p,f,m){return!(e===f&&s===m)&&Au(e,s,l,c,d,p,f,m)}function zu(e,s){return e.next.i!==s.i&&e.prev.i!==s.i&&!function(e,s){let l=e;do{if(l.i!==e.i&&l.next.i!==e.i&&l.i!==s.i&&l.next.i!==s.i&&Bu(l,l.next,e,s))return!0;l=l.next}while(l!==e);return!1}(e,s)&&(Nu(e,s)&&Nu(s,e)&&function(e,s){let l=e,c=!1;const d=(e.x+s.x)/2,p=(e.y+s.y)/2;do{l.y>p!=l.next.y>p&&l.next.y!==l.y&&d<(l.next.x-l.x)*(p-l.y)/(l.next.y-l.y)+l.x&&(c=!c),l=l.next}while(l!==e);return c}(e,s)&&(Lu(e.prev,e,s.prev)||Lu(e,s.prev,s))||Fu(e,s)&&Lu(e.prev,e,e.next)>0&&Lu(s.prev,s,s.next)>0)}function Lu(e,s,l){return(s.y-e.y)*(l.x-s.x)-(s.x-e.x)*(l.y-s.y)}function Fu(e,s){return e.x===s.x&&e.y===s.y}function Bu(e,s,l,c){const d=ju(Lu(e,s,l)),p=ju(Lu(e,s,c)),f=ju(Lu(l,c,e)),m=ju(Lu(l,c,s));return d!==p&&f!==m||!(0!==d||!Ou(e,l,s))||!(0!==p||!Ou(e,c,s))||!(0!==f||!Ou(l,e,c))||!(0!==m||!Ou(l,s,c))}function Ou(e,s,l){return s.x<=Math.max(e.x,l.x)&&s.x>=Math.min(e.x,l.x)&&s.y<=Math.max(e.y,l.y)&&s.y>=Math.min(e.y,l.y)}function ju(e){return e>0?1:e<0?-1:0}function Nu(e,s){return Lu(e.prev,e,e.next)<0?Lu(e,s,e.next)>=0&&Lu(e,e.prev,s)>=0:Lu(e,s,e.prev)<0||Lu(e,e.next,s)<0}function Uu(e,s){const l=$u(e.i,e.x,e.y),c=$u(s.i,s.x,s.y),d=e.next,p=s.prev;return e.next=s,s.prev=e,l.next=d,d.prev=l,c.next=l,l.prev=c,p.next=c,c.prev=p,c}function qu(e,s,l,c){const d=$u(e,s,l);return c?(d.next=c.next,d.prev=c,c.next.prev=d,c.next=d):(d.prev=d,d.next=d),d}function Zu(e){e.next.prev=e.prev,e.prev.next=e.next,e.prevZ&&(e.prevZ.nextZ=e.nextZ),e.nextZ&&(e.nextZ.prevZ=e.prevZ)}function $u(e,s,l){return{i:e,x:s,y:l,prev:null,next:null,z:0,prevZ:null,nextZ:null,steiner:!1}}class hu{constructor(e,s){if(s>e)throw new Error("Min granularity must not be greater than base granularity.");this._baseZoomGranularity=e,this._minGranularity=s}getGranularityForZoomLevel(e){return Math.max(Math.floor(this._baseZoomGranularity/(1<32767||s>32767)throw new Error("Vertex coordinates are out of signed 16 bit integer range.");const l=0|Math.round(e),c=0|Math.round(s),d=this._getKey(l,c);if(this._vertexDictionary.has(d))return this._vertexDictionary.get(d);const p=this._vertexBuffer.length/2;return this._vertexDictionary.set(d,p),this._vertexBuffer.push(l,c),p}_subdivideTrianglesScanline(e){if(this._granularity<2)return function(e,s){const l=[];for(let c=0;c0?(l.push(d),l.push(f),l.push(p)):(l.push(d),l.push(p),l.push(f))}return l}(this._vertexBuffer,e);const s=[],l=e.length;for(let c=0;c=1||F<=0)||I&&(md)){g>=c&&g<=d&&p.push(l[(e+1)%3]);continue}!I&&L>0&&p.push(this._vertexToIndex(f+T*L,m+P*L));const B=f+T*Math.max(L,0),O=f+T*Math.min(F,1);S||this._generateIntraEdgeVertices(p,f,m,_,g,B,O),!I&&F<1&&p.push(this._vertexToIndex(f+T*F,m+P*F)),(I||g>=c&&g<=d)&&p.push(l[(e+1)%3]),!I&&(g<=c||g>=d)&&this._generateInterEdgeVertices(p,f,m,_,g,y,b,O,c,d)}return p}_generateIntraEdgeVertices(e,s,l,c,d,p,f){const m=c-s,_=d-l,g=0===_,y=g?Math.min(s,c):Math.min(p,f),b=g?Math.max(s,c):Math.max(p,f),T=Math.floor(y/this._granularityCellSize)+1,P=Math.ceil(b/this._granularityCellSize)-1;if(g?s=T;c--){const d=c*this._granularityCellSize;e.push(this._vertexToIndex(d,l+_*(d-s)/m))}}_generateInterEdgeVertices(e,s,l,c,d,p,f,m,_,g){const y=d-l,b=p-c,T=f-d,P=(_-d)/T,S=(g-d)/T,I=Math.min(P,S),C=Math.max(P,S),R=c+b*I;let L=Math.floor(Math.min(R,m)/this._granularityCellSize)+1,F=Math.ceil(Math.max(R,m)/this._granularityCellSize)-1,B=m=1||C<=0){const e=l-f,c=p+(s-p)*Math.min((_-f)/e,(g-f)/e);L=Math.floor(Math.min(c,m)/this._granularityCellSize)+1,F=Math.ceil(Math.max(c,m)/this._granularityCellSize)-1,B=m0?g:_;if(B)for(let s=L;s<=F;s++)e.push(this._vertexToIndex(s*this._granularityCellSize,j));else for(let s=F;s>=L;s--)e.push(this._vertexToIndex(s*this._granularityCellSize,j))}_generateOutline(e){const s=[];for(const l of e){const e=Yu(l,this._granularity,!0),c=this._pointArrayToIndices(e),d=[];for(let e=1;ed!=(p===Wu)?(e.push(s),e.push(l),e.push(this._vertexToIndex(c,p)),e.push(l),e.push(this._vertexToIndex(d,p)),e.push(this._vertexToIndex(c,p))):(e.push(l),e.push(s),e.push(this._vertexToIndex(c,p)),e.push(this._vertexToIndex(d,p)),e.push(l),e.push(this._vertexToIndex(c,p)))}_fillPoles(e,s,l){const c=this._vertexBuffer,d=se,p=e.length;for(let f=2;f80*l){m=e[0],_=e[1];let s=m,c=_;for(let p=l;ps&&(s=l),d>c&&(c=d)}g=Math.max(s-m,c-_),g=0!==g?32767/g:0}return _u(p,f,l,m,_,g,0),f}(l,c),s=this._convertIndices(l,e);d=this._subdivideTrianglesScanline(s)}catch(e){console.error(e)}let p=[];return s&&(p=this._generateOutline(e)),this._ensureNoPoleVertices(),this._handlePoles(d),{verticesFlattened:this._vertexBuffer,indicesTriangles:d,indicesLineList:p}}_convertIndices(e,s){const l=[];for(let c=0;c0?(Math.floor(L/m)+1)*m:(Math.ceil(L/m)-1)*m,s=I>0?(Math.floor(F/m)+1)*m:(Math.ceil(F/m)-1)*m,l=Math.abs(L-e),d=Math.abs(F-s),p=Math.abs(L-y),f=Math.abs(F-b),g=T?l/C:Number.POSITIVE_INFINITY,B=P?d/R:Number.POSITIVE_INFINITY;if((p<=l||!T)&&(f<=d||!P))break;if(g=0?f-1:p-1,d=(m+1)%p,_=e[2*s[c]],g=e[2*s[d]],y=e[2*s[f]],b=e[2*s[f]+1],T=e[2*s[m]+1];let P=!1;if(_g)P=!1;else{const l=T-b,p=-(e[2*s[m]]-y),f=b((g-y)*l+(e[2*s[d]+1]-b)*p)*f&&(P=!0)}if(P){const e=s[c],d=s[f],_=s[m];e!==d&&e!==_&&d!==_&&l.push(_,d,e),f--,f<0&&(f=p-1)}else{const e=s[d],c=s[f],_=s[m];e!==c&&e!==_&&c!==_&&l.push(_,c,e),m++,m>=p&&(m=0)}if(c===d)break}}function Qu(e,s,l,c,d,p,f,m,_){const g=d.length/2,y=f&&m&&_;if(gio.MAX_VERTEX_ARRAY_LENGTH&&(g=e.createNewSegment(s,l),_=m.count,I=!0,C=!0,R=!0,y=0);const L=Ju(f,c,p,m,T,I,g),F=Ju(f,c,p,m,P,C,g),B=Ju(f,c,p,m,S,R,g);l.emplaceBack(y+L-_,y+F-_,y+B-_),g.primitiveLength++}}(s,l,c,d,p,e),y&&function(e,s,l,c,d,p){const f=[];for(let e=0;eio.MAX_VERTEX_ARRAY_LENGTH&&(g=e.createNewSegment(s,l),_=m.count,S=!0,I=!0,y=0);const C=Ju(f,c,p,m,d,S,g),R=Ju(f,c,p,m,b,I,g);l.emplaceBack(y+C-_,y+R-_),g.primitiveLength++}}}(f,l,m,d,_,e),s.forceNewSegmentOnNextPrepare(),null==f||f.forceNewSegmentOnNextPrepare()}function Ju(e,s,l,c,d,p,f){if(p){const p=c.count;return l(s[2*d],s[2*d+1]),e[d]=c.count,c.count++,f.vertexLength++,p}return e[d]}class wu{constructor(e){this.zoom=e.zoom,this.overscaling=e.overscaling,this.layers=e.layers,this.layerIds=this.layers.map((e=>e.id)),this.index=e.index,this.hasDependencies=!1,this.patternFeatures=[],this.layoutVertexArray=new qa,this.indexArray=new to,this.indexArray2=new eo,this.programConfigurations=new Vo(e.layers,e.zoom),this.segments=new io,this.segments2=new io,this.stateDependentLayerIds=this.layers.filter((e=>e.isStateDependent())).map((e=>e.id))}populate(e,s,l){this.hasDependencies=uu("fill",this.layers,s);const c=this.layers[0].layout.get("fill-sort-key"),d=!c.isConstant(),p=[];for(const{feature:f,id:m,index:_,sourceLayerIndex:g}of e){const e=this.layers[0]._featureFilter.needGeometry,y=eh(f,e);if(!this.layers[0]._featureFilter.filter(new Ps(this.zoom),y,l))continue;const b=d?c.evaluate(y,{},l,s.availableImages):void 0,T={id:m,properties:f.properties,type:f.type,sourceLayerIndex:g,index:_,geometry:e?y.geometry:Jc(f),patterns:{},sortKey:b};p.push(T)}d&&p.sort(((e,s)=>e.sortKey-s.sortKey));for(const c of p){const{geometry:d,index:p,sourceLayerIndex:f}=c;if(this.hasDependencies){const e=du("fill",this.layers,c,{zoom:this.zoom},s);this.patternFeatures.push(e)}else this.addFeature(c,d,p,l,{},s.subdivisionGranularity);s.featureIndex.insert(e[p].feature,d,p,f,this.index)}}update(e,s,l){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(e,s,this.stateDependentLayers,{imagePositions:l})}addFeatures(e,s,l){for(const c of this.patternFeatures)this.addFeature(c,c.geometry,c.index,s,l,e.subdivisionGranularity)}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(e){this.uploaded||(this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,cu),this.indexBuffer=e.createIndexBuffer(this.indexArray),this.indexBuffer2=e.createIndexBuffer(this.indexArray2)),this.programConfigurations.upload(e),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(e,s,l,c,d,p){for(const e of Sn(s,500)){const s=Xu(e,c,p.fill.getGranularityForZoomLevel(c.z)),l=this.layoutVertexArray;Qu(((e,s)=>{l.emplaceBack(e,s)}),this.segments,this.layoutVertexArray,this.indexArray,s.verticesFlattened,s.indicesTriangles,this.segments2,this.indexArray2,s.indicesLineList)}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,e,l,{imagePositions:d,canonical:c})}}let ed,td;Kl("FillBucket",wu,{omit:["layers","patternFeatures"]});var id={get paint(){return td=td||new Hs({"fill-antialias":new js(Tt.paint_fill["fill-antialias"]),"fill-opacity":new Gs(Tt.paint_fill["fill-opacity"]),"fill-color":new Gs(Tt.paint_fill["fill-color"]),"fill-outline-color":new Gs(Tt.paint_fill["fill-outline-color"]),"fill-translate":new js(Tt.paint_fill["fill-translate"]),"fill-translate-anchor":new js(Tt.paint_fill["fill-translate-anchor"]),"fill-pattern":new Xs(Tt.paint_fill["fill-pattern"])})},get layout(){return ed=ed||new Hs({"fill-sort-key":new Gs(Tt.layout_fill["fill-sort-key"])})}};class ku extends Ks{constructor(e,s){super(e,id,s)}recalculate(e,s){super.recalculate(e,s);const l=this.paint._values["fill-outline-color"];"constant"===l.value.kind&&void 0===l.value.value&&(this.paint._values["fill-outline-color"]=this.paint._values["fill-color"])}createBucket(e){return new wu(e)}queryRadius(){return bh(this.paint.get("fill-translate"))}queryIntersectsFeature({queryGeometry:e,geometry:s,transform:l,pixelsToTileUnits:c}){return sh(Th(e,this.paint.get("fill-translate"),this.paint.get("fill-translate-anchor"),-l.bearingInRadians,c),s)}isTileClipped(){return!0}}const rd=Ic([{name:"a_pos",components:2,type:"Int16"},{name:"a_normal_ed",components:4,type:"Int16"}],4),nd=Ic([{name:"a_centroid",components:2,type:"Int16"}],4),{members:sd}=rd;class Mu{constructor(e,s,l,c,d){this.properties={},this.extent=l,this.type=0,this.id=void 0,this._pbf=e,this._geometry=-1,this._keys=c,this._values=d,e.readFields(od,this,s)}loadGeometry(){const e=this._pbf;e.pos=this._geometry;const s=e.readVarint()+e.pos,l=[];let d,p=1,f=0,m=0,_=0;for(;e.pos>3}if(f--,1===p||2===p)m+=e.readSVarint(),_+=e.readSVarint(),1===p&&(d&&l.push(d),d=[]),d&&d.push(new c(m,_));else{if(7!==p)throw new Error(`unknown command ${p}`);d&&d.push(d[0].clone())}}return d&&l.push(d),l}bbox(){const e=this._pbf;e.pos=this._geometry;const s=e.readVarint()+e.pos;let l=1,c=0,d=0,p=0,f=1/0,m=-1/0,_=1/0,g=-1/0;for(;e.pos>3}if(c--,1===l||2===l)d+=e.readSVarint(),p+=e.readSVarint(),dm&&(m=d),p<_&&(_=p),p>g&&(g=p);else if(7!==l)throw new Error(`unknown command ${l}`)}return[f,_,m,g]}toGeoJSON(e,s,l){const c=this.extent*Math.pow(2,l),d=this.extent*e,p=this.extent*s,f=this.loadGeometry();function m(e){return[360*(e.x+d)/c-180,360/Math.PI*Math.atan(Math.exp((1-2*(e.y+p)/c)*Math.PI))-90]}function _(e){return e.map(m)}let g;if(1===this.type){const e=[];for(const s of f)e.push(s[0]);const s=_(e);g=1===e.length?{type:"Point",coordinates:s[0]}:{type:"MultiPoint",coordinates:s}}else if(2===this.type){const e=f.map(_);g=1===e.length?{type:"LineString",coordinates:e[0]}:{type:"MultiLineString",coordinates:e}}else{if(3!==this.type)throw new Error("unknown feature type");{const e=ad(f),s=[];for(const l of e)s.push(l.map(_));g=1===s.length?{type:"Polygon",coordinates:s[0]}:{type:"MultiPolygon",coordinates:s}}}const y={type:"Feature",geometry:g,properties:this.properties};return null!=this.id&&(y.id=this.id),y}}function od(e,s,l){1===e?s.id=l.readVarint():2===e?function(e,s){const l=e.readVarint()+e.pos;for(;e.pos=this._features.length)throw new Error("feature index out of bounds");this._pbf.pos=this._features[e];const s=this._pbf.readVarint()+this._pbf.pos;return new Mu(this._pbf,s,this.extent,this._keys,this._values)}}function hd(e,s,l){15===e?s.version=l.readVarint():1===e?s.name=l.readString():5===e?s.extent=l.readVarint():2===e?s._features.push(l.pos):3===e?s._keys.push(l.readString()):4===e&&s._values.push(function(e){let s=null;const l=e.readVarint()+e.pos;for(;e.pos>3;s=1===l?e.readString():2===l?e.readFloat():3===l?e.readDouble():4===l?e.readVarint64():5===l?e.readVarint():6===l?e.readSVarint():7===l?e.readBoolean():null}if(null==s)throw new Error("unknown feature value");return s}(l))}class Vu{constructor(e,s){this.layers=e.readFields(dd,{},s)}}function dd(e,s,l){if(3===e){const e=new Pu(l,l.readVarint()+l.pos);e.length&&(s[e.name]=e)}}const pd=Math.pow(2,13);function fd(e,s,l,c,d,p,f,m){e.emplaceBack(s,l,2*Math.floor(c*pd)+f,d*pd*2,p*pd*2,Math.round(m))}class Ru{constructor(e){this.zoom=e.zoom,this.overscaling=e.overscaling,this.layers=e.layers,this.layerIds=this.layers.map((e=>e.id)),this.index=e.index,this.hasDependencies=!1,this.layoutVertexArray=new ja,this.centroidVertexArray=new $a,this.indexArray=new to,this.programConfigurations=new Vo(e.layers,e.zoom),this.segments=new io,this.stateDependentLayerIds=this.layers.filter((e=>e.isStateDependent())).map((e=>e.id))}populate(e,s,l){this.features=[],this.hasDependencies=uu("fill-extrusion",this.layers,s);for(const{feature:c,id:d,index:p,sourceLayerIndex:f}of e){const e=this.layers[0]._featureFilter.needGeometry,m=eh(c,e);if(!this.layers[0]._featureFilter.filter(new Ps(this.zoom),m,l))continue;const _={id:d,sourceLayerIndex:f,index:p,geometry:e?m.geometry:Jc(c),properties:c.properties,type:c.type,patterns:{}};this.hasDependencies?this.features.push(du("fill-extrusion",this.layers,_,{zoom:this.zoom},s)):this.addFeature(_,_.geometry,p,l,{},s.subdivisionGranularity),s.featureIndex.insert(c,_.geometry,p,f,this.index,!0)}}addFeatures(e,s,l){for(const c of this.features){const{geometry:d}=c;this.addFeature(c,d,c.index,s,l,e.subdivisionGranularity)}}update(e,s,l){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(e,s,this.stateDependentLayers,{imagePositions:l})}isEmpty(){return 0===this.layoutVertexArray.length&&0===this.centroidVertexArray.length}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(e){this.uploaded||(this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,sd),this.centroidVertexBuffer=e.createVertexBuffer(this.centroidVertexArray,nd.members,!0),this.indexBuffer=e.createIndexBuffer(this.indexArray)),this.programConfigurations.upload(e),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy(),this.centroidVertexBuffer.destroy())}addFeature(e,s,l,c,d,p){for(const l of Sn(s,500)){const s={x:0,y:0,sampleCount:0},d=this.layoutVertexArray.length;this.processPolygon(s,c,e,l,p);const f=this.layoutVertexArray.length-d,m=Math.floor(s.x/s.sampleCount),_=Math.floor(s.y/s.sampleCount);for(let e=0;e{fd(g,e,s,0,0,1,1,0)}),this.segments,this.layoutVertexArray,this.indexArray,_.verticesFlattened,_.indicesTriangles)}_generateSideFaces(e,s){let l=0;for(let c=1;cio.MAX_VERTEX_ARRAY_LENGTH&&(s.segment=this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray));const f=d.sub(p)._perp()._unit(),m=p.dist(d);l+m>32768&&(l=0),fd(this.layoutVertexArray,d.x,d.y,f.x,f.y,0,0,l),fd(this.layoutVertexArray,d.x,d.y,f.x,f.y,0,1,l),l+=m,fd(this.layoutVertexArray,p.x,p.y,f.x,f.y,0,0,l),fd(this.layoutVertexArray,p.x,p.y,f.x,f.y,0,1,l);const _=s.segment.vertexLength;this.indexArray.emplaceBack(_,_+2,_+1),this.indexArray.emplaceBack(_+1,_+2,_+3),s.segment.vertexLength+=4,s.segment.primitiveLength+=2}}}function md(e,s){for(let l=0;lse)||e.y===s.y&&(e.y<0||e.y>se)}function gd(e){return e.every((e=>e.x<0))||e.every((e=>e.x>se))||e.every((e=>e.y<0))||e.every((e=>e.y>se))}let yd;Kl("FillExtrusionBucket",Ru,{omit:["layers","features"]});var xd={get paint(){return yd=yd||new Hs({"fill-extrusion-opacity":new js(Tt["paint_fill-extrusion"]["fill-extrusion-opacity"]),"fill-extrusion-color":new Gs(Tt["paint_fill-extrusion"]["fill-extrusion-color"]),"fill-extrusion-translate":new js(Tt["paint_fill-extrusion"]["fill-extrusion-translate"]),"fill-extrusion-translate-anchor":new js(Tt["paint_fill-extrusion"]["fill-extrusion-translate-anchor"]),"fill-extrusion-pattern":new Xs(Tt["paint_fill-extrusion"]["fill-extrusion-pattern"]),"fill-extrusion-height":new Gs(Tt["paint_fill-extrusion"]["fill-extrusion-height"]),"fill-extrusion-base":new Gs(Tt["paint_fill-extrusion"]["fill-extrusion-base"]),"fill-extrusion-vertical-gradient":new js(Tt["paint_fill-extrusion"]["fill-extrusion-vertical-gradient"])})}};class Gu extends Ks{constructor(e,s){super(e,xd,s)}createBucket(e){return new Ru(e)}queryRadius(){return bh(this.paint.get("fill-extrusion-translate"))}is3D(){return!0}queryIntersectsFeature({queryGeometry:e,feature:s,featureState:l,geometry:d,transform:p,pixelsToTileUnits:f,pixelPosMatrix:m}){const _=Th(e,this.paint.get("fill-extrusion-translate"),this.paint.get("fill-extrusion-translate-anchor"),-p.bearingInRadians,f),g=this.paint.get("fill-extrusion-height").evaluate(s,l),y=this.paint.get("fill-extrusion-base").evaluate(s,l),b=function(e,s){const l=[];for(const d of e){const e=[d.x,d.y,0,1];q(e,e,s),l.push(new c(e[0]/e[3],e[1]/e[3]))}return l}(_,m),T=function(e,s,l,d){const p=[],f=[],m=d[8]*s,_=d[9]*s,g=d[10]*s,y=d[11]*s,b=d[8]*l,T=d[9]*l,P=d[10]*l,S=d[11]*l;for(const s of e){const e=[],l=[];for(const p of s){const s=p.x,f=p.y,I=d[0]*s+d[4]*f+d[12],C=d[1]*s+d[5]*f+d[13],R=d[2]*s+d[6]*f+d[14],L=d[3]*s+d[7]*f+d[15],F=R+g,B=L+y,O=I+b,j=C+T,G=R+P,U=L+S,q=new c((I+m)/B,(C+_)/B);q.z=F/B,e.push(q);const Z=new c(O/U,j/U);Z.z=G/U,l.push(Z)}p.push(e),f.push(l)}return[p,f]}(d,y,g,m);return function(e,s,l){let c=1/0;sh(l,s)&&(c=bd(l,s[0]));for(let d=0;de.id)),this.index=e.index,this.hasDependencies=!1,this.patternFeatures=[],this.lineClipsArray=[],this.gradients={},this.layers.forEach((e=>{this.gradients[e.id]={}})),this.layoutVertexArray=new Ga,this.layoutVertexArray2=new Xa,this.indexArray=new to,this.programConfigurations=new Vo(e.layers,e.zoom),this.segments=new io,this.maxLineLength=0,this.stateDependentLayerIds=this.layers.filter((e=>e.isStateDependent())).map((e=>e.id))}populate(e,s,l){this.hasDependencies=uu("line",this.layers,s)||this.hasLineDasharray(this.layers);const c=this.layers[0].layout.get("line-sort-key"),d=!c.isConstant(),p=[];for(const{feature:s,id:f,index:m,sourceLayerIndex:_}of e){const e=this.layers[0]._featureFilter.needGeometry,g=eh(s,e);if(!this.layers[0]._featureFilter.filter(new Ps(this.zoom),g,l))continue;const y=d?c.evaluate(g,{},l):void 0,b={id:f,properties:s.properties,type:s.type,sourceLayerIndex:_,index:m,geometry:e?g.geometry:Jc(s),patterns:{},dashes:{},sortKey:y};p.push(b)}d&&p.sort(((e,s)=>e.sortKey-s.sortKey));for(const c of p){const{geometry:d,index:p,sourceLayerIndex:f}=c;this.hasDependencies?(uu("line",this.layers,s)?du("line",this.layers,c,{zoom:this.zoom},s):this.hasLineDasharray(this.layers)&&this.addLineDashDependencies(this.layers,c,this.zoom,s),this.patternFeatures.push(c)):this.addFeature(c,d,p,l,{},{},s.subdivisionGranularity),s.featureIndex.insert(e[p].feature,d,p,f,this.index)}}update(e,s,l,c){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(e,s,this.stateDependentLayers,{imagePositions:l,dashPositions:c})}addFeatures(e,s,l,c){for(const d of this.patternFeatures)this.addFeature(d,d.geometry,d.index,s,l,c,e.subdivisionGranularity)}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(e){this.uploaded||(0!==this.layoutVertexArray2.length&&(this.layoutVertexBuffer2=e.createVertexBuffer(this.layoutVertexArray2,Md)),this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,Td),this.indexBuffer=e.createIndexBuffer(this.indexArray)),this.programConfigurations.upload(e),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy())}lineFeatureClips(e){if(e.properties&&Object.prototype.hasOwnProperty.call(e.properties,"mapbox_clip_start")&&Object.prototype.hasOwnProperty.call(e.properties,"mapbox_clip_end"))return{start:+e.properties.mapbox_clip_start,end:+e.properties.mapbox_clip_end}}addFeature(e,s,l,c,d,p,f){const m=this.layers[0].layout,_=m.get("line-join").evaluate(e,{}),g=m.get("line-cap"),y=m.get("line-miter-limit"),b=m.get("line-round-limit");this.lineClips=this.lineFeatureClips(e);for(const l of s)this.addLine(l,e,_,g,y,b,c,f);this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,e,l,{imagePositions:d,dashPositions:p,canonical:c})}addLine(e,s,l,c,d,p,f,m){if(this.distance=0,this.scaledDistance=0,this.totalDistance=0,e=Yu(e,f?m.line.getGranularityForZoomLevel(f.z):1),this.lineClips){this.lineClipsArray.push(this.lineClips);for(let s=0;s=2&&e[g-1].equals(e[g-2]);)g--;let y=0;for(;y0;if(O&&s>y){const e=P.dist(S);if(e>2*b){const s=P.sub(P.sub(S)._mult(b/e)._round());this.updateDistance(S,s),this.addCurrentVertex(s,C,0,0,T),S=s}}const G=S&&I;let U=G?l:_?"butt":c;if(G&&"round"===U&&(Fd&&(U="bevel"),"bevel"===U&&(F>2&&(U="flipbevel"),F100)f=R.mult(-1);else{const e=F*C.add(R).mag()/C.sub(R).mag();f._perp()._mult(e*(j?-1:1))}this.addCurrentVertex(P,f,0,0,T),this.addCurrentVertex(P,f.mult(-1),0,0,T)}else if("bevel"===U||"fakeround"===U){const e=-Math.sqrt(F*F-1),s=j?e:0,l=j?0:e;if(S&&this.addCurrentVertex(P,C,s,l,T),"fakeround"===U){const e=Math.round(180*B/Math.PI/20);for(let s=1;s2*b){const s=P.add(I.sub(P)._mult(b/e)._round());this.updateDistance(P,s),this.addCurrentVertex(s,R,0,0,T),P=s}}}}addCurrentVertex(e,s,l,c,d,p=!1){const f=s.y*c-s.x,m=-s.y-s.x*c;this.addHalfVertex(e,s.x+s.y*l,s.y-s.x*l,p,!1,l,d),this.addHalfVertex(e,f,m,p,!0,-c,d),this.distance>Ed/2&&0===this.totalDistance&&(this.distance=0,this.updateScaledDistance(),this.addCurrentVertex(e,s,l,c,d,p))}addHalfVertex({x:e,y:s},l,c,d,p,f,m){const _=.5*(this.lineClips?this.scaledDistance*(Ed-1):this.scaledDistance);this.layoutVertexArray.emplaceBack((e<<1)+(d?1:0),(s<<1)+(p?1:0),Math.round(63*l)+128,Math.round(63*c)+128,1+(0===f?0:f<0?-1:1)|(63&_)<<2,_>>6),this.lineClips&&this.layoutVertexArray2.emplaceBack((this.scaledDistance-this.lineClips.start)/(this.lineClips.end-this.lineClips.start),this.lineClipsArray.length);const g=m.vertexLength++;this.e1>=0&&this.e2>=0&&(this.indexArray.emplaceBack(this.e1,g,this.e2),m.primitiveLength++),p?this.e2=g:this.e1=g}updateScaledDistance(){this.scaledDistance=this.lineClips?this.lineClips.start+(this.lineClips.end-this.lineClips.start)*this.distance/this.totalDistance:this.distance}updateDistance(e,s){this.distance+=e.dist(s),this.updateScaledDistance()}hasLineDasharray(e){for(const s of e){const e=s.paint.get("line-dasharray");if(e&&!e.isConstant())return!0}return!1}addLineDashDependencies(e,s,l,c){for(const d of e){const e=d.paint.get("line-dasharray");if(!e||"constant"===e.value.kind)continue;const p="round"===d.layout.get("line-cap"),f={dasharray:e.value.evaluate({zoom:l-1},s,{}),round:p},m={dasharray:e.value.evaluate({zoom:l},s,{}),round:p},_={dasharray:e.value.evaluate({zoom:l+1},s,{}),round:p},g=`${f.dasharray.join(",")},${f.round}`,y=`${m.dasharray.join(",")},${m.round}`,b=`${_.dasharray.join(",")},${_.round}`;c.dashDependencies[g]=f,c.dashDependencies[y]=m,c.dashDependencies[b]=_,s.dashes[d.id]={min:g,mid:y,max:b}}}}let Cd,Ad;Kl("LineBucket",tc,{omit:["layers","patternFeatures"]});var Dd={get paint(){return Ad=Ad||new Hs({"line-opacity":new Gs(Tt.paint_line["line-opacity"]),"line-color":new Gs(Tt.paint_line["line-color"]),"line-translate":new js(Tt.paint_line["line-translate"]),"line-translate-anchor":new js(Tt.paint_line["line-translate-anchor"]),"line-width":new Gs(Tt.paint_line["line-width"]),"line-gap-width":new Gs(Tt.paint_line["line-gap-width"]),"line-offset":new Gs(Tt.paint_line["line-offset"]),"line-blur":new Gs(Tt.paint_line["line-blur"]),"line-dasharray":new Xs(Tt.paint_line["line-dasharray"]),"line-pattern":new Xs(Tt.paint_line["line-pattern"]),"line-gradient":new Zs(Tt.paint_line["line-gradient"])})},get layout(){return Cd=Cd||new Hs({"line-cap":new js(Tt.layout_line["line-cap"]),"line-join":new Gs(Tt.layout_line["line-join"]),"line-miter-limit":new js(Tt.layout_line["line-miter-limit"]),"line-round-limit":new js(Tt.layout_line["line-round-limit"]),"line-sort-key":new Gs(Tt.layout_line["line-sort-key"])})}};class ic extends Gs{possiblyEvaluate(e,s){return s=new Ps(Math.floor(s.zoom),{now:s.now,fadeDuration:s.fadeDuration,zoomHistory:s.zoomHistory,transition:s.transition}),super.possiblyEvaluate(e,s)}evaluate(e,s,l,c){return s=ge({},s,{zoom:Math.floor(s.zoom)}),super.evaluate(e,s,l,c)}}let zd;class ac extends Ks{constructor(e,s){super(e,Dd,s),this.gradientVersion=0,zd||(zd=new ic(Dd.paint.properties["line-width"].specification),zd.useIntegerZoom=!0)}_handleSpecialPaintPropertyUpdate(e){if("line-gradient"===e){const e=this.gradientExpression();this.stepInterpolant=!!function(e){return void 0!==e._styleExpression}(e)&&e._styleExpression.expression instanceof or,this.gradientVersion=(this.gradientVersion+1)%Number.MAX_SAFE_INTEGER}}gradientExpression(){return this._transitionablePaint._values["line-gradient"].value.expression}recalculate(e,s){super.recalculate(e,s),this.paint._values["line-floorwidth"]=zd.possiblyEvaluate(this._transitioningPaint._values["line-width"].value,e)}createBucket(e){return new tc(e)}queryRadius(e){const s=e,l=kd(vh("line-width",this,s),vh("line-gap-width",this,s)),c=vh("line-offset",this,s);return l/2+Math.abs(c)+bh(this.paint.get("line-translate"))}queryIntersectsFeature({queryGeometry:e,feature:s,featureState:l,geometry:d,transform:p,pixelsToTileUnits:f}){const m=Th(e,this.paint.get("line-translate"),this.paint.get("line-translate-anchor"),-p.bearingInRadians,f),_=f/2*kd(this.paint.get("line-width").evaluate(s,l),this.paint.get("line-gap-width").evaluate(s,l)),g=this.paint.get("line-offset").evaluate(s,l);return g&&(d=function(e,s){const l=[];for(let d=0;d=3)for(let s=0;s0?s+2*e:e}const Rd=Ic([{name:"a_pos_offset",components:4,type:"Int16"},{name:"a_data",components:4,type:"Uint16"},{name:"a_pixeloffset",components:4,type:"Int16"}],4),Ld=Ic([{name:"a_projected_pos",components:3,type:"Float32"}],4);Ic([{name:"a_fade_opacity",components:1,type:"Uint32"}],4);const Fd=Ic([{name:"a_placed",components:2,type:"Uint8"},{name:"a_shift",components:2,type:"Float32"},{name:"a_box_real",components:2,type:"Int16"}]);Ic([{type:"Int16",name:"anchorPointX"},{type:"Int16",name:"anchorPointY"},{type:"Int16",name:"x1"},{type:"Int16",name:"y1"},{type:"Int16",name:"x2"},{type:"Int16",name:"y2"},{type:"Uint32",name:"featureIndex"},{type:"Uint16",name:"sourceLayerIndex"},{type:"Uint16",name:"bucketIndex"}]);const Bd=Ic([{name:"a_pos",components:2,type:"Int16"},{name:"a_anchor_pos",components:2,type:"Int16"},{name:"a_extrude",components:2,type:"Int16"}],4),Od=Ic([{name:"a_pos",components:2,type:"Float32"},{name:"a_radius",components:1,type:"Float32"},{name:"a_flags",components:2,type:"Int16"}],4);function Vd(e,s,l){return e.sections.forEach((e=>{e.text=function(e,s,l){const c=s.layout.get("text-transform").evaluate(l,{});return"uppercase"===c?e=e.toLocaleUpperCase():"lowercase"===c&&(e=e.toLocaleLowerCase()),xc.applyArabicShaping&&(e=xc.applyArabicShaping(e)),e}(e.text,s,l)})),e}Ic([{name:"triangle",components:3,type:"Uint16"}]),Ic([{type:"Int16",name:"anchorX"},{type:"Int16",name:"anchorY"},{type:"Uint16",name:"glyphStartIndex"},{type:"Uint16",name:"numGlyphs"},{type:"Uint32",name:"vertexStartIndex"},{type:"Uint32",name:"lineStartIndex"},{type:"Uint32",name:"lineLength"},{type:"Uint16",name:"segment"},{type:"Uint16",name:"lowerSize"},{type:"Uint16",name:"upperSize"},{type:"Float32",name:"lineOffsetX"},{type:"Float32",name:"lineOffsetY"},{type:"Uint8",name:"writingMode"},{type:"Uint8",name:"placedOrientation"},{type:"Uint8",name:"hidden"},{type:"Uint32",name:"crossTileID"},{type:"Int16",name:"associatedIconIndex"}]),Ic([{type:"Int16",name:"anchorX"},{type:"Int16",name:"anchorY"},{type:"Int16",name:"rightJustifiedTextSymbolIndex"},{type:"Int16",name:"centerJustifiedTextSymbolIndex"},{type:"Int16",name:"leftJustifiedTextSymbolIndex"},{type:"Int16",name:"verticalPlacedTextSymbolIndex"},{type:"Int16",name:"placedIconSymbolIndex"},{type:"Int16",name:"verticalPlacedIconSymbolIndex"},{type:"Uint16",name:"key"},{type:"Uint16",name:"textBoxStartIndex"},{type:"Uint16",name:"textBoxEndIndex"},{type:"Uint16",name:"verticalTextBoxStartIndex"},{type:"Uint16",name:"verticalTextBoxEndIndex"},{type:"Uint16",name:"iconBoxStartIndex"},{type:"Uint16",name:"iconBoxEndIndex"},{type:"Uint16",name:"verticalIconBoxStartIndex"},{type:"Uint16",name:"verticalIconBoxEndIndex"},{type:"Uint16",name:"featureIndex"},{type:"Uint16",name:"numHorizontalGlyphVertices"},{type:"Uint16",name:"numVerticalGlyphVertices"},{type:"Uint16",name:"numIconVertices"},{type:"Uint16",name:"numVerticalIconVertices"},{type:"Uint16",name:"useRuntimeCollisionCircles"},{type:"Uint32",name:"crossTileID"},{type:"Float32",name:"textBoxScale"},{type:"Float32",name:"collisionCircleDiameter"},{type:"Uint16",name:"textAnchorOffsetStartIndex"},{type:"Uint16",name:"textAnchorOffsetEndIndex"}]),Ic([{type:"Float32",name:"offsetX"}]),Ic([{type:"Int16",name:"x"},{type:"Int16",name:"y"},{type:"Int16",name:"tileUnitDistanceFromAnchor"}]),Ic([{type:"Uint16",name:"textAnchor"},{type:"Float32",components:2,name:"textOffset"}]);var jd=24;const Nd={"!":"︕","#":"#",$:"$","%":"%","&":"&","(":"︵",")":"︶","*":"*","+":"+",",":"︐","-":"︲",".":"・","/":"/",":":"︓",";":"︔","<":"︿","=":"=",">":"﹀","?":"︖","@":"@","[":"﹇","\\":"\","]":"﹈","^":"^",_:"︳","`":"`","{":"︷","|":"―","}":"︸","~":"~","¢":"¢","£":"£","¥":"¥","¦":"¦","¬":"¬","¯":" ̄","–":"︲","—":"︱","‘":"﹃","’":"﹄","“":"﹁","”":"﹂","…":"︙","⋯":"︙","‧":"・","₩":"₩","、":"︑","。":"︒","〈":"︿","〉":"﹀","《":"︽","》":"︾","「":"﹁","」":"﹂","『":"﹃","』":"﹄","【":"︻","】":"︼","〔":"︹","〕":"︺","〖":"︗","〗":"︘","!":"︕","(":"︵",")":"︶",",":"︐","-":"︲",".":"・",":":"︓",";":"︔","<":"︿",">":"﹀","?":"︖","[":"﹇","]":"﹈","_":"︳","{":"︷","|":"―","}":"︸","⦅":"︵","⦆":"︶","。":"︒","「":"﹁","」":"﹂"},Gd={10:!0,32:!0,38:!0,41:!0,43:!0,45:!0,47:!0,173:!0,183:!0,8203:!0,8208:!0,8211:!0,8231:!0},Ud={40:!0};function qd(e,s,l,c,d,p){if("fontStack"in s){const c=l[s.fontStack],p=c&&c[e];return p?p.metrics.advance*s.scale+d:0}{const e=c[s.imageName];return e?e.displaySize[0]*s.scale*jd/p+d:0}}function Zd(e,s,l,c){const d=Math.pow(e-s,2);return c?eMath.max(e,this.sections[s].scale)),0)}getMaxImageSize(e){let s=0,l=0;for(let c=0;cl)))}addImageSection(e){const s=e.image?e.image.name:"";if(0===s.length)return void Se("Can't add FormattedSection with an empty image.");const l=this.getNextImageSectionCharCode();l?(this.text+=String.fromCharCode(l),this.sections.push({scale:1,verticalAlign:e.verticalAlign||"bottom",imageName:s}),this.sectionIndex.push(this.sections.length-1)):Se("Reached maximum number of images 6401")}getNextImageSectionCharCode(){return this.imageSectionID?this.imageSectionID>=63743?null:++this.imageSectionID:(this.imageSectionID=57344,this.imageSectionID)}determineLineBreaks(e,s,l,c,d){const p=[],f=this.determineAverageLineWidth(e,s,l,c,d),m=this.hasZeroWidthSpaces();let _=0,g=0;const y=this.text[Symbol.iterator]();let b=y.next();const T=this.text[Symbol.iterator]();T.next();let P=T.next();const S=this.text[Symbol.iterator]();S.next(),S.next();let I=S.next();for(;!b.done;){const s=this.getSection(g),C=b.value.codePointAt(0);if(lc(C)||(_+=qd(C,s,l,c,e,d)),!P.done){const e=sc(C),l=P.value.codePointAt(0);(Gd[C]||e||"imageName"in s||!I.done&&Ud[l])&&p.push(Wd(g+1,_,f,p,$d(C,l,e&&m),!1))}g++,b=y.next(),P=T.next(),I=S.next()}return Hd(Wd(this.length(),_,f,p,0,!0))}determineAverageLineWidth(e,s,l,c,d){let p=0,f=0;for(const s of this.text){const m=this.getSection(f);p+=qd(s.codePointAt(0),m,l,c,e,d),f++}return p/Math.max(1,Math.ceil(p/s))}}const Xd=4294967296,Yd=1/Xd,Kd="undefined"==typeof TextDecoder?null:new TextDecoder("utf-8");class Tc{constructor(e=new Uint8Array(16)){this.buf=ArrayBuffer.isView(e)?e:new Uint8Array(e),this.dataView=new DataView(this.buf.buffer),this.pos=0,this.type=0,this.length=this.buf.length}readFields(e,s,l=this.length){for(;this.pos>3,d=this.pos;this.type=7&l,e(c,s,this),this.pos===d&&this.skip(l)}return s}readMessage(e,s){return this.readFields(e,s,this.readVarint()+this.pos)}readFixed32(){const e=this.dataView.getUint32(this.pos,!0);return this.pos+=4,e}readSFixed32(){const e=this.dataView.getInt32(this.pos,!0);return this.pos+=4,e}readFixed64(){const e=this.dataView.getUint32(this.pos,!0)+this.dataView.getUint32(this.pos+4,!0)*Xd;return this.pos+=8,e}readSFixed64(){const e=this.dataView.getUint32(this.pos,!0)+this.dataView.getInt32(this.pos+4,!0)*Xd;return this.pos+=8,e}readFloat(){const e=this.dataView.getFloat32(this.pos,!0);return this.pos+=4,e}readDouble(){const e=this.dataView.getFloat64(this.pos,!0);return this.pos+=8,e}readVarint(e){const s=this.buf;let l,c;return c=s[this.pos++],l=127&c,c<128?l:(c=s[this.pos++],l|=(127&c)<<7,c<128?l:(c=s[this.pos++],l|=(127&c)<<14,c<128?l:(c=s[this.pos++],l|=(127&c)<<21,c<128?l:(c=s[this.pos],l|=(15&c)<<28,function(e,s,l){const c=l.buf;let d,p;if(p=c[l.pos++],d=(112&p)>>4,p<128)return Qd(e,d,s);if(p=c[l.pos++],d|=(127&p)<<3,p<128)return Qd(e,d,s);if(p=c[l.pos++],d|=(127&p)<<10,p<128)return Qd(e,d,s);if(p=c[l.pos++],d|=(127&p)<<17,p<128)return Qd(e,d,s);if(p=c[l.pos++],d|=(127&p)<<24,p<128)return Qd(e,d,s);if(p=c[l.pos++],d|=(1&p)<<31,p<128)return Qd(e,d,s);throw new Error("Expected varint not more than 10 bytes")}(l,e,this)))))}readVarint64(){return this.readVarint(!0)}readSVarint(){const e=this.readVarint();return e%2==1?(e+1)/-2:e/2}readBoolean(){return Boolean(this.readVarint())}readString(){const e=this.readVarint()+this.pos,s=this.pos;return this.pos=e,e-s>=12&&Kd?Kd.decode(this.buf.subarray(s,e)):function(e,s,l){let c="",d=s;for(;d239?4:s>223?3:s>191?2:1;if(d+g>l)break;1===g?s<128&&(_=s):2===g?(p=e[d+1],128==(192&p)&&(_=(31&s)<<6|63&p,_<=127&&(_=null))):3===g?(p=e[d+1],f=e[d+2],128==(192&p)&&128==(192&f)&&(_=(15&s)<<12|(63&p)<<6|63&f,(_<=2047||_>=55296&&_<=57343)&&(_=null))):4===g&&(p=e[d+1],f=e[d+2],m=e[d+3],128==(192&p)&&128==(192&f)&&128==(192&m)&&(_=(15&s)<<18|(63&p)<<12|(63&f)<<6|63&m,(_<=65535||_>=1114112)&&(_=null))),null===_?(_=65533,g=1):_>65535&&(_-=65536,c+=String.fromCharCode(_>>>10&1023|55296),_=56320|1023&_),c+=String.fromCharCode(_),d+=g}return c}(this.buf,s,e)}readBytes(){const e=this.readVarint()+this.pos,s=this.buf.subarray(this.pos,e);return this.pos=e,s}readPackedVarint(e=[],s){const l=this.readPackedEnd();for(;this.pos127;);else if(2===s)this.pos=this.readVarint()+this.pos;else if(5===s)this.pos+=4;else{if(1!==s)throw new Error(`Unimplemented type: ${s}`);this.pos+=8}}writeTag(e,s){this.writeVarint(e<<3|s)}realloc(e){let s=this.length||16;for(;s268435455||e<0?function(e,s){let l,c;if(e>=0?(l=e%4294967296|0,c=e/4294967296|0):(l=~(-e%4294967296),c=~(-e/4294967296),4294967295^l?l=l+1|0:(l=0,c=c+1|0)),e>=0x10000000000000000||e<-0x10000000000000000)throw new Error("Given varint doesn't fit into 10 bytes");s.realloc(10),function(e,s,l){l.buf[l.pos++]=127&e|128,e>>>=7,l.buf[l.pos++]=127&e|128,e>>>=7,l.buf[l.pos++]=127&e|128,e>>>=7,l.buf[l.pos++]=127&e|128,l.buf[l.pos]=127&(e>>>=7)}(l,0,s),function(e,s){const l=(7&e)<<4;s.buf[s.pos++]|=l|((e>>>=3)?128:0),e&&(s.buf[s.pos++]=127&e|((e>>>=7)?128:0),e&&(s.buf[s.pos++]=127&e|((e>>>=7)?128:0),e&&(s.buf[s.pos++]=127&e|((e>>>=7)?128:0),e&&(s.buf[s.pos++]=127&e|((e>>>=7)?128:0),e&&(s.buf[s.pos++]=127&e)))))}(c,s)}(e,this):(this.realloc(4),this.buf[this.pos++]=127&e|(e>127?128:0),e<=127||(this.buf[this.pos++]=127&(e>>>=7)|(e>127?128:0),e<=127||(this.buf[this.pos++]=127&(e>>>=7)|(e>127?128:0),e<=127||(this.buf[this.pos++]=e>>>7&127))))}writeSVarint(e){this.writeVarint(e<0?2*-e-1:2*e)}writeBoolean(e){this.writeVarint(+e)}writeString(e){e=String(e),this.realloc(4*e.length),this.pos++;const s=this.pos;this.pos=function(e,s,l){for(let c,d,p=0;p55295&&c<57344){if(!d){c>56319||p+1===s.length?(e[l++]=239,e[l++]=191,e[l++]=189):d=c;continue}if(c<56320){e[l++]=239,e[l++]=191,e[l++]=189,d=c;continue}c=d-55296<<10|c-56320|65536,d=null}else d&&(e[l++]=239,e[l++]=191,e[l++]=189,d=null);c<128?e[l++]=c:(c<2048?e[l++]=c>>6|192:(c<65536?e[l++]=c>>12|224:(e[l++]=c>>18|240,e[l++]=c>>12&63|128),e[l++]=c>>6&63|128),e[l++]=63&c|128)}return l}(this.buf,e,this.pos);const l=this.pos-s;l>=128&&Jd(s,l,this),this.pos=s-1,this.writeVarint(l),this.pos+=l}writeFloat(e){this.realloc(4),this.dataView.setFloat32(this.pos,e,!0),this.pos+=4}writeDouble(e){this.realloc(8),this.dataView.setFloat64(this.pos,e,!0),this.pos+=8}writeBytes(e){const s=e.length;this.writeVarint(s),this.realloc(s);for(let l=0;l=128&&Jd(l,c,this),this.pos=l-1,this.writeVarint(c),this.pos+=c}writeMessage(e,s,l){this.writeTag(e,2),this.writeRawMessage(s,l)}writePackedVarint(e,s){s.length&&this.writeMessage(e,ip,s)}writePackedSVarint(e,s){s.length&&this.writeMessage(e,rp,s)}writePackedBoolean(e,s){s.length&&this.writeMessage(e,op,s)}writePackedFloat(e,s){s.length&&this.writeMessage(e,np,s)}writePackedDouble(e,s){s.length&&this.writeMessage(e,sp,s)}writePackedFixed32(e,s){s.length&&this.writeMessage(e,ap,s)}writePackedSFixed32(e,s){s.length&&this.writeMessage(e,lp,s)}writePackedFixed64(e,s){s.length&&this.writeMessage(e,cp,s)}writePackedSFixed64(e,s){s.length&&this.writeMessage(e,hp,s)}writeBytesField(e,s){this.writeTag(e,2),this.writeBytes(s)}writeFixed32Field(e,s){this.writeTag(e,5),this.writeFixed32(s)}writeSFixed32Field(e,s){this.writeTag(e,5),this.writeSFixed32(s)}writeFixed64Field(e,s){this.writeTag(e,1),this.writeFixed64(s)}writeSFixed64Field(e,s){this.writeTag(e,1),this.writeSFixed64(s)}writeVarintField(e,s){this.writeTag(e,0),this.writeVarint(s)}writeSVarintField(e,s){this.writeTag(e,0),this.writeSVarint(s)}writeStringField(e,s){this.writeTag(e,2),this.writeString(s)}writeFloatField(e,s){this.writeTag(e,5),this.writeFloat(s)}writeDoubleField(e,s){this.writeTag(e,1),this.writeDouble(s)}writeBooleanField(e,s){this.writeVarintField(e,+s)}}function Qd(e,s,l){return l?4294967296*s+(e>>>0):4294967296*(s>>>0)+(e>>>0)}function Jd(e,s,l){const c=s<=16383?1:s<=2097151?2:s<=268435455?3:Math.floor(Math.log(s)/(7*Math.LN2));l.realloc(c);for(let s=l.pos-1;s>=e;s--)l.buf[s+c]=l.buf[s]}function ip(e,s){for(let l=0;ls.h-e.h));const c=[{x:0,y:0,w:Math.max(Math.ceil(Math.sqrt(s/.95)),l),h:1/0}];let d=0,p=0;for(const s of e)for(let e=c.length-1;e>=0;e--){const l=c[e];if(!(s.w>l.w||s.h>l.h)){if(s.x=l.x,s.y=l.y,p=Math.max(p,s.y+s.h),d=Math.max(d,s.x+s.w),s.w===l.w&&s.h===l.h){const s=c.pop();s&&eC.toCodeUnitIndex(e)));const e=F(C.toString(),L);for(const s of e){const e=[...s].map((()=>0));R.push(new Sc(s,C.sections,e))}}else if(B){R=[],L=L.map((e=>C.toCodeUnitIndex(e)));let e=0;const s=[];for(const l of C.text)s.push(...Array(l.length).fill(C.sectionIndex[e])),e++;const l=B(C.text,s,L);for(const e of l){const s=[];let l="";for(const c of e[0])s.push(e[1][l.length]),l+=c;R.push(new Sc(e[0],C.sections,s))}}else R=function(e,s){const l=[];let c=0;for(const d of s)l.push(e.substring(c,d)),c=d;return cg){const e=Math.ceil(p/g);d*=e/f,f=e}return{x1:c,y1:d,x2:c+p,y2:d+f}}function Mp(e,s,l,c,d,p){const f=e.image;let m;if(f.content){const e=f.content,s=f.pixelRatio||1;m=[e[0]/s,e[1]/s,f.displaySize[0]-e[2]/s,f.displaySize[1]-e[3]/s]}const _=s.left*p,g=s.right*p;let y,b,T,P;"width"===l||"both"===l?(P=d[0]+_-c[3],b=d[0]+g+c[1]):(P=d[0]+(_+g-f.displaySize[0])/2,b=P+f.displaySize[0]);const S=s.top*p,I=s.bottom*p;return"height"===l||"both"===l?(y=d[1]+S-c[0],T=d[1]+I+c[2]):(y=d[1]+(S+I-f.displaySize[1])/2,T=y+f.displaySize[1]),{image:f,top:y,right:b,bottom:T,left:P,collisionPadding:m}}Kl("ImagePosition",qc),Kl("ImageAtlas",jc),s.az=void 0,(mp=s.az||(s.az={}))[mp.none=0]="none",mp[mp.horizontal=1]="horizontal",mp[mp.vertical=2]="vertical",mp[mp.horizontalOnly=3]="horizontalOnly";const Ip=128,Cp=32640;function Dp(e,s){const{expression:l}=s;if("constant"===l.kind)return{kind:"constant",layoutSize:l.evaluate(new Ps(e+1))};if("source"===l.kind)return{kind:"source"};{const{zoomStops:s,interpolationType:c}=l;let d=0;for(;de.id)),this.index=e.index,this.pixelRatio=e.pixelRatio,this.sourceLayerIndex=e.sourceLayerIndex,this.hasDependencies=!1,this.hasRTLText=!1,this.sortKeyRanges=[],this.collisionCircleArray=[];const l=this.layers[0]._unevaluatedLayout._values;this.textSizeData=Dp(this.zoom,l["text-size"]),this.iconSizeData=Dp(this.zoom,l["icon-size"]);const c=this.layers[0].layout,d=c.get("symbol-sort-key"),p=c.get("symbol-z-order");this.canOverlap="never"!==zp(c,"text-overlap","text-allow-overlap")||"never"!==zp(c,"icon-overlap","icon-allow-overlap")||c.get("text-ignore-placement")||c.get("icon-ignore-placement"),this.sortFeaturesByKey="viewport-y"!==p&&!d.isConstant(),this.sortFeaturesByY=("viewport-y"===p||"auto"===p&&!this.sortFeaturesByKey)&&this.canOverlap,"point"===c.get("symbol-placement")&&(this.writingModes=c.get("text-writing-mode").map((e=>s.az[e]))),this.stateDependentLayerIds=this.layers.filter((e=>e.isStateDependent())).map((e=>e.id)),this.sourceID=e.sourceID}createArrays(){this.text=new hh(new Vo(this.layers,this.zoom,(e=>/^text/.test(e)))),this.icon=new hh(new Vo(this.layers,this.zoom,(e=>/^icon/.test(e)))),this.glyphOffsetArray=new Va,this.lineVertexArray=new Ca,this.symbolInstances=new Ba,this.textAnchorOffsets=new Oa}calculateGlyphDependencies(e,s,l,c,d){for(const p of e)if(s[p.codePointAt(0)]=!0,(l||c)&&d){const e=Nd[p];e&&(s[e.codePointAt(0)]=!0)}}populate(e,l,c){const d=this.layers[0],p=d.layout,f=p.get("text-font"),m=p.get("text-field"),_=p.get("icon-image"),g=("constant"!==m.value.kind||m.value.value instanceof De&&!m.value.value.isEmpty()||m.value.value.toString().length>0)&&("constant"!==f.value.kind||f.value.value.length>0),y="constant"!==_.value.kind||!!_.value.value||Object.keys(_.parameters).length>0,b=p.get("symbol-sort-key");if(this.features=[],!g&&!y)return;const T=l.iconDependencies,P=l.glyphDependencies,S=l.availableImages,I=new Ps(this.zoom);for(const{feature:l,id:m,index:_,sourceLayerIndex:C}of e){const e=d._featureFilter.needGeometry,R=eh(l,e);if(!d._featureFilter.filter(I,R,c))continue;let L,F;if(e||(R.geometry=Jc(l)),g){const e=d.getValueAndResolveTokens("text-field",R,c,S),s=De.factory(e),l=this.hasRTLText=this.hasRTLText||Vp(s);(!l||"unavailable"===xc.getRTLTextPluginStatus()||l&&xc.isParsed())&&(L=Vd(s,d,R))}if(y){const e=d.getValueAndResolveTokens("icon-image",R,c,S);F=e instanceof Oe?e:Oe.fromString(e)}if(!L&&!F)continue;const B=this.sortFeaturesByKey?b.evaluate(R,{},c):void 0;if(this.features.push({id:m,text:L,icon:F,index:_,sourceLayerIndex:C,geometry:R.geometry,properties:l.properties,type:Mu.types[l.type],sortKey:B}),F&&(T[F.name]=!0),L){const e=f.evaluate(R,{},c).join(","),l="viewport"!==p.get("text-rotation-alignment")&&"point"!==p.get("symbol-placement");this.allowVerticalPlacement=this.writingModes&&this.writingModes.indexOf(s.az.vertical)>=0;for(const s of L.sections)if(s.image)T[s.image.name]=!0;else{const c=cc(L.toString()),d=s.fontStack||e,p=P[d]=P[d]||{};this.calculateGlyphDependencies(s.text,p,l,this.allowVerticalPlacement,c)}}}"line"===p.get("symbol-placement")&&(this.features=function(e){const s={},l={},c=[];let d=0;function p(s){c.push(e[s]),d++}function f(e,s,d){const p=l[e];return delete l[e],l[s]=p,c[p].geometry[0].pop(),c[p].geometry[0]=c[p].geometry[0].concat(d[0]),p}function m(e,l,d){const p=s[l];return delete s[l],s[e]=p,c[p].geometry[0].shift(),c[p].geometry[0]=d[0].concat(c[p].geometry[0]),p}function _(e,s,l){const c=l?s[0][s[0].length-1]:s[0][0];return`${e}:${c.x}:${c.y}`}for(let g=0;ge.geometry))}(this.features)),this.sortFeaturesByKey&&this.features.sort(((e,s)=>e.sortKey-s.sortKey))}update(e,s,l){this.stateDependentLayers.length&&(this.text.programConfigurations.updatePaintArrays(e,s,this.layers,{imagePositions:l}),this.icon.programConfigurations.updatePaintArrays(e,s,this.layers,{imagePositions:l}))}isEmpty(){return 0===this.symbolInstances.length&&!this.hasRTLText}uploadPending(){return!this.uploaded||this.text.programConfigurations.needsUpload||this.icon.programConfigurations.needsUpload}upload(e){!this.uploaded&&this.hasDebugData()&&(this.textCollisionBox.upload(e),this.iconCollisionBox.upload(e)),this.text.upload(e,this.sortFeaturesByY,!this.uploaded,this.text.programConfigurations.needsUpload),this.icon.upload(e,this.sortFeaturesByY,!this.uploaded,this.icon.programConfigurations.needsUpload),this.uploaded=!0}destroyDebugData(){this.textCollisionBox.destroy(),this.iconCollisionBox.destroy()}destroy(){this.text.destroy(),this.icon.destroy(),this.hasDebugData()&&this.destroyDebugData()}addToLineVertexArray(e,s){const l=this.lineVertexArray.length;if(void 0!==e.segment){let l=e.dist(s[e.segment+1]),c=e.dist(s[e.segment]);const d={};for(let c=e.segment+1;c=0;l--)d[l]={x:s[l].x,y:s[l].y,tileUnitDistanceFromAnchor:c},l>0&&(c+=s[l-1].dist(s[l]));for(let e=0;e0}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}addIndicesForPlacedSymbol(e,s){const l=e.placedSymbolArray.get(s),c=l.vertexStartIndex+4*l.numGlyphs;for(let s=l.vertexStartIndex;sc[e]-c[s]||d[s]-d[e])),p}addToSortKeyRanges(e,s){const l=this.sortKeyRanges[this.sortKeyRanges.length-1];l&&l.sortKey===s?l.symbolInstanceEnd=e+1:this.sortKeyRanges.push({sortKey:s,symbolInstanceStart:e,symbolInstanceEnd:e+1})}sortFeatures(e){if(this.sortFeaturesByY&&this.sortedAngle!==e&&!(this.text.segments.get().length>1||this.icon.segments.get().length>1)){this.symbolInstanceIndexes=this.getSortedSymbolIndexes(e),this.sortedAngle=e,this.text.indexArray.clear(),this.icon.indexArray.clear(),this.featureSortOrder=[];for(const e of this.symbolInstanceIndexes){const s=this.symbolInstances.get(e);this.featureSortOrder.push(s.featureIndex),[s.rightJustifiedTextSymbolIndex,s.centerJustifiedTextSymbolIndex,s.leftJustifiedTextSymbolIndex].forEach(((e,s,l)=>{e>=0&&l.indexOf(e)===s&&this.addIndicesForPlacedSymbol(this.text,e)})),s.verticalPlacedTextSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.text,s.verticalPlacedTextSymbolIndex),s.placedIconSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.icon,s.placedIconSymbolIndex),s.verticalPlacedIconSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.icon,s.verticalPlacedIconSymbolIndex)}this.text.indexBuffer&&this.text.indexBuffer.updateData(this.text.indexArray),this.icon.indexBuffer&&this.icon.indexBuffer.updateData(this.icon.indexArray)}}}let jp,Np;Kl("SymbolBucket",fh,{omit:["layers","collisionBoxArray","features","compareText"]}),fh.MAX_GLYPHS=65535,fh.addDynamicAttributes=Bp;var Gp={get paint(){return Np=Np||new Hs({"icon-opacity":new Gs(Tt.paint_symbol["icon-opacity"]),"icon-color":new Gs(Tt.paint_symbol["icon-color"]),"icon-halo-color":new Gs(Tt.paint_symbol["icon-halo-color"]),"icon-halo-width":new Gs(Tt.paint_symbol["icon-halo-width"]),"icon-halo-blur":new Gs(Tt.paint_symbol["icon-halo-blur"]),"icon-translate":new js(Tt.paint_symbol["icon-translate"]),"icon-translate-anchor":new js(Tt.paint_symbol["icon-translate-anchor"]),"text-opacity":new Gs(Tt.paint_symbol["text-opacity"]),"text-color":new Gs(Tt.paint_symbol["text-color"],{runtimeType:pi,getOverride:e=>e.textColor,hasOverride:e=>!!e.textColor}),"text-halo-color":new Gs(Tt.paint_symbol["text-halo-color"]),"text-halo-width":new Gs(Tt.paint_symbol["text-halo-width"]),"text-halo-blur":new Gs(Tt.paint_symbol["text-halo-blur"]),"text-translate":new js(Tt.paint_symbol["text-translate"]),"text-translate-anchor":new js(Tt.paint_symbol["text-translate-anchor"])})},get layout(){return jp=jp||new Hs({"symbol-placement":new js(Tt.layout_symbol["symbol-placement"]),"symbol-spacing":new js(Tt.layout_symbol["symbol-spacing"]),"symbol-avoid-edges":new js(Tt.layout_symbol["symbol-avoid-edges"]),"symbol-sort-key":new Gs(Tt.layout_symbol["symbol-sort-key"]),"symbol-z-order":new js(Tt.layout_symbol["symbol-z-order"]),"icon-allow-overlap":new js(Tt.layout_symbol["icon-allow-overlap"]),"icon-overlap":new js(Tt.layout_symbol["icon-overlap"]),"icon-ignore-placement":new js(Tt.layout_symbol["icon-ignore-placement"]),"icon-optional":new js(Tt.layout_symbol["icon-optional"]),"icon-rotation-alignment":new js(Tt.layout_symbol["icon-rotation-alignment"]),"icon-size":new Gs(Tt.layout_symbol["icon-size"]),"icon-text-fit":new js(Tt.layout_symbol["icon-text-fit"]),"icon-text-fit-padding":new js(Tt.layout_symbol["icon-text-fit-padding"]),"icon-image":new Gs(Tt.layout_symbol["icon-image"]),"icon-rotate":new Gs(Tt.layout_symbol["icon-rotate"]),"icon-padding":new Gs(Tt.layout_symbol["icon-padding"]),"icon-keep-upright":new js(Tt.layout_symbol["icon-keep-upright"]),"icon-offset":new Gs(Tt.layout_symbol["icon-offset"]),"icon-anchor":new Gs(Tt.layout_symbol["icon-anchor"]),"icon-pitch-alignment":new js(Tt.layout_symbol["icon-pitch-alignment"]),"text-pitch-alignment":new js(Tt.layout_symbol["text-pitch-alignment"]),"text-rotation-alignment":new js(Tt.layout_symbol["text-rotation-alignment"]),"text-field":new Gs(Tt.layout_symbol["text-field"]),"text-font":new Gs(Tt.layout_symbol["text-font"]),"text-size":new Gs(Tt.layout_symbol["text-size"]),"text-max-width":new Gs(Tt.layout_symbol["text-max-width"]),"text-line-height":new js(Tt.layout_symbol["text-line-height"]),"text-letter-spacing":new Gs(Tt.layout_symbol["text-letter-spacing"]),"text-justify":new Gs(Tt.layout_symbol["text-justify"]),"text-radial-offset":new Gs(Tt.layout_symbol["text-radial-offset"]),"text-variable-anchor":new js(Tt.layout_symbol["text-variable-anchor"]),"text-variable-anchor-offset":new Gs(Tt.layout_symbol["text-variable-anchor-offset"]),"text-anchor":new Gs(Tt.layout_symbol["text-anchor"]),"text-max-angle":new js(Tt.layout_symbol["text-max-angle"]),"text-writing-mode":new js(Tt.layout_symbol["text-writing-mode"]),"text-rotate":new Gs(Tt.layout_symbol["text-rotate"]),"text-padding":new js(Tt.layout_symbol["text-padding"]),"text-keep-upright":new js(Tt.layout_symbol["text-keep-upright"]),"text-transform":new Gs(Tt.layout_symbol["text-transform"]),"text-offset":new Gs(Tt.layout_symbol["text-offset"]),"text-allow-overlap":new js(Tt.layout_symbol["text-allow-overlap"]),"text-overlap":new js(Tt.layout_symbol["text-overlap"]),"text-ignore-placement":new js(Tt.layout_symbol["text-ignore-placement"]),"text-optional":new js(Tt.layout_symbol["text-optional"])})}};class gh{constructor(e){if(void 0===e.property.overrides)throw new Error("overrides must be provided to instantiate FormatSectionOverride class");this.type=e.property.overrides?e.property.overrides.runtimeType:ni,this.defaultValue=e}evaluate(e){if(e.formattedSection){const s=this.defaultValue.property.overrides;if(s&&s.hasOverride(e.formattedSection))return s.getOverride(e.formattedSection)}return e.feature&&e.featureState?this.defaultValue.evaluate(e.feature,e.featureState):this.defaultValue.property.specification.default}eachChild(e){this.defaultValue.isConstant()||e(this.defaultValue.value._styleExpression.expression)}outputDefined(){return!1}serialize(){return null}}Kl("FormatSectionOverride",gh,{omit:["defaultValue"]});class xh extends Ks{constructor(e,s){super(e,Gp,s)}recalculate(e,s){if(super.recalculate(e,s),"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"]="map"===this.layout.get("text-rotation-alignment")?"map":"viewport"),"auto"===this.layout.get("icon-pitch-alignment")&&(this.layout._values["icon-pitch-alignment"]=this.layout.get("icon-rotation-alignment")),"point"===this.layout.get("symbol-placement")){const e=this.layout.get("text-writing-mode");if(e){const s=[];for(const l of e)s.indexOf(l)<0&&s.push(l);this.layout._values["text-writing-mode"]=s}else this.layout._values["text-writing-mode"]=["horizontal"]}this._setPaintOverrides()}getValueAndResolveTokens(e,s,l,c){const d=this.layout.get(e).evaluate(s,{},l,c),p=this._unevaluatedLayout._values[e];return p.isDataDriven()||Bs(p.value)||!d?d:function(e,s){return s.replace(/{([^{}]+)}/g,((s,l)=>e&&l in e?String(e[l]):""))}(s.properties,d)}createBucket(e){return new fh(e)}queryRadius(){return 0}queryIntersectsFeature(){throw new Error("Should take a different path in FeatureIndex")}_setPaintOverrides(){for(const e of Gp.paint.overridableProperties){if(!xh.hasPaintOverride(this.layout,e))continue;const s=this.paint.get(e),l=new gh(s),c=new ei(l,s.property.specification);let d=null;d="constant"===s.value.kind||"source"===s.value.kind?new ii("source",c):new si("composite",c,s.value.zoomStops),this.paint._values[e]=new Us(s.property,d,s.parameters)}}_handleOverridablePaintPropertyUpdate(e,s,l){return!(!this.layout||s.isDataDriven()||l.isDataDriven())&&xh.hasPaintOverride(this.layout,e)}static hasPaintOverride(e,s){const l=e.get("text-field"),c=Gp.paint.properties[s];let d=!1;const p=e=>{for(const s of e)if(c.overrides&&c.overrides.hasOverride(s))return void(d=!0)};if("constant"===l.value.kind&&l.value.value instanceof De)p(l.value.value.sections);else if("source"===l.value.kind||"composite"===l.value.kind){const e=s=>{d||(s instanceof je&&Cr(s.value)===yi?p(s.value.sections):s instanceof Ir?p(s.sections):s.eachChild(e))},s=l.value;s._styleExpression&&e(s._styleExpression.expression)}return d}}let qp;var Zp={get paint(){return qp=qp||new Hs({"background-color":new js(Tt.paint_background["background-color"]),"background-pattern":new Ys(Tt.paint_background["background-pattern"]),"background-opacity":new js(Tt.paint_background["background-opacity"])})}};class wh extends Ks{constructor(e,s){super(e,Zp,s)}}class _h extends Ks{constructor(e,s){super(e,{},s),this.onAdd=e=>{this.implementation.onAdd&&this.implementation.onAdd(e,e.painter.context.gl)},this.onRemove=e=>{this.implementation.onRemove&&this.implementation.onRemove(e,e.painter.context.gl)},this.implementation=e}is3D(){return"3d"===this.implementation.renderingMode}hasOffscreenPass(){return void 0!==this.implementation.prerender}recalculate(){}updateTransitions(){}hasTransition(){return!1}serialize(){throw new Error("Custom layers cannot be serialized")}}class Sh{constructor(e){this._methodToThrottle=e,this._triggered=!1,"undefined"!=typeof MessageChannel&&(this._channel=new MessageChannel,this._channel.port2.onmessage=()=>{this._triggered=!1,this._methodToThrottle()})}trigger(){this._triggered||(this._triggered=!0,this._channel?this._channel.port1.postMessage(!0):setTimeout((()=>{this._triggered=!1,this._methodToThrottle()}),0))}remove(){delete this._channel,this._methodToThrottle=()=>{}}}const $p={once:!0},Hp=6371008.8;class Eh{constructor(e,s){if(isNaN(e)||isNaN(s))throw new Error(`Invalid LngLat object: (${e}, ${s})`);if(this.lng=+e,this.lat=+s,this.lat>90||this.lat<-90)throw new Error("Invalid LngLat latitude value: must be between -90 and 90")}wrap(){return new Eh(me(this.lng,-180,180),this.lat)}toArray(){return[this.lng,this.lat]}toString(){return`LngLat(${this.lng}, ${this.lat})`}distanceTo(e){const s=Math.PI/180,l=this.lat*s,c=e.lat*s,d=Math.sin(l)*Math.sin(c)+Math.cos(l)*Math.cos(c)*Math.cos((e.lng-this.lng)*s);return Hp*Math.acos(Math.min(d,1))}static convert(e){if(e instanceof Eh)return e;if(Array.isArray(e)&&(2===e.length||3===e.length))return new Eh(Number(e[0]),Number(e[1]));if(!Array.isArray(e)&&"object"==typeof e&&null!==e)return new Eh(Number("lng"in e?e.lng:e.lon),Number(e.lat));throw new Error("`LngLatLike` argument must be specified as a LngLat instance, an object {lng: , lat: }, an object {lon: , lat: }, or an array of [, ]")}}const Xp=2*Math.PI*Hp;function Yp(e){return Xp*Math.cos(e*Math.PI/180)}function tf(e){return(180+e)/360}function rf(e){return(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+e*Math.PI/360)))/360}function sf(e,s){return e/Yp(s)}function of(e){return 360*e-180}function af(e){return 360/Math.PI*Math.atan(Math.exp((180-360*e)*Math.PI/180))-90}function hf(e,s){return e*Yp(af(s))}class Vh{constructor(e,s,l=0){this.x=+e,this.y=+s,this.z=+l}static fromLngLat(e,s=0){const l=Eh.convert(e);return new Vh(tf(l.lng),rf(l.lat),sf(s,l.lat))}toLngLat(){return new Eh(of(this.x),af(this.y))}toAltitude(){return hf(this.z,this.y)}meterInMercatorCoordinateUnits(){return 1/Xp*(e=af(this.y),1/Math.cos(e*Math.PI/180));var e}}function df(e,s,l){var c=2*Math.PI*6378137/256/Math.pow(2,l);return[e*c-2*Math.PI*6378137/2,s*c-2*Math.PI*6378137/2]}class Lh{constructor(e,s,l){if(!function(e,s,l){return!(e<0||e>25||l<0||l>=Math.pow(2,e)||s<0||s>=Math.pow(2,e))}(e,s,l))throw new Error(`x=${s}, y=${l}, z=${e} outside of bounds. 0<=x<${Math.pow(2,e)}, 0<=y<${Math.pow(2,e)} 0<=z<=25 `);this.z=e,this.x=s,this.y=l,this.key=pf(0,e,e,s,l)}equals(e){return this.z===e.z&&this.x===e.x&&this.y===e.y}url(e,s,l){const c=function(e,s,l){var c=df(256*e,256*(s=Math.pow(2,l)-s-1),l),d=df(256*(e+1),256*(s+1),l);return c[0]+","+c[1]+","+d[0]+","+d[1]}(this.x,this.y,this.z),d=function(e,s,l){let c,d="";for(let p=e;p>0;p--)c=1<1?"@2x":"").replace(/{quadkey}/g,d).replace(/{bbox-epsg-3857}/g,c)}isChildOf(e){const s=this.z-e.z;return s>0&&e.x===this.x>>s&&e.y===this.y>>s}getTilePoint(e){const s=Math.pow(2,this.z);return new c((e.x*s-this.x)*se,(e.y*s-this.y)*se)}toString(){return`${this.z}/${this.x}/${this.y}`}}class Oh{constructor(e,s){this.wrap=e,this.canonical=s,this.key=pf(e,s.z,s.z,s.x,s.y)}}class Rh{constructor(e,s,l,c,d){if(this.terrainRttPosMatrix32f=null,e= z; overscaledZ = ${e}; z = ${l}`);this.overscaledZ=e,this.wrap=s,this.canonical=new Lh(l,+c,+d),this.key=pf(s,e,l,c,d)}clone(){return new Rh(this.overscaledZ,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y)}equals(e){return this.overscaledZ===e.overscaledZ&&this.wrap===e.wrap&&this.canonical.equals(e.canonical)}scaledTo(e){if(e>this.overscaledZ)throw new Error(`targetZ > this.overscaledZ; targetZ = ${e}; overscaledZ = ${this.overscaledZ}`);const s=this.canonical.z-e;return e>this.canonical.z?new Rh(e,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y):new Rh(e,this.wrap,e,this.canonical.x>>s,this.canonical.y>>s)}isOverscaled(){return this.overscaledZ>this.canonical.z}calculateScaledKey(e,s){if(e>this.overscaledZ)throw new Error(`targetZ > this.overscaledZ; targetZ = ${e}; overscaledZ = ${this.overscaledZ}`);const l=this.canonical.z-e;return e>this.canonical.z?pf(this.wrap*+s,e,this.canonical.z,this.canonical.x,this.canonical.y):pf(this.wrap*+s,e,e,this.canonical.x>>l,this.canonical.y>>l)}isChildOf(e){if(e.wrap!==this.wrap)return!1;if(this.overscaledZ-e.overscaledZ<=0)return!1;if(0===e.overscaledZ)return this.overscaledZ>0;const s=this.canonical.z-e.canonical.z;return!(s<0)&&e.canonical.x===this.canonical.x>>s&&e.canonical.y===this.canonical.y>>s}children(e){if(this.overscaledZ>=e)return[new Rh(this.overscaledZ+1,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y)];const s=this.canonical.z+1,l=2*this.canonical.x,c=2*this.canonical.y;return[new Rh(s,this.wrap,s,l,c),new Rh(s,this.wrap,s,l+1,c),new Rh(s,this.wrap,s,l,c+1),new Rh(s,this.wrap,s,l+1,c+1)]}isLessThan(e){return this.wrape.wrap)&&(this.overscaledZe.overscaledZ)&&(this.canonical.xe.canonical.x)&&this.canonical.ye.key===l));s>-1&&e.addOrUpdateProperties.splice(s,1)}return(e.removeAllProperties||s.removeAllProperties)&&(l.removeAllProperties=!0),(e.removeProperties||s.removeProperties)&&(l.removeProperties=[...e.removeProperties||[],...s.removeProperties||[]]),(e.addOrUpdateProperties||s.addOrUpdateProperties)&&(l.addOrUpdateProperties=[...e.addOrUpdateProperties||[],...s.addOrUpdateProperties||[]]),(e.newGeometry||s.newGeometry)&&(l.newGeometry=s.newGeometry||e.newGeometry),l}function vf(e){var s,l;if(!e)return{};const c={};return c.removeAll=e.removeAll,c.remove=new Set(e.remove||[]),c.add=new Map(null===(s=e.add)||void 0===s?void 0:s.map((e=>[e.id,e]))),c.update=new Map(null===(l=e.update)||void 0===l?void 0:l.map((e=>[e.id,e]))),c}Kl("CanonicalTileID",Lh),Kl("OverscaledTileID",Rh,{omit:["terrainRttPosMatrix32f"]});class jh{constructor(){this.minX=1/0,this.maxX=-1/0,this.minY=1/0,this.maxY=-1/0}extend(e){return this.minX=Math.min(this.minX,e.x),this.minY=Math.min(this.minY,e.y),this.maxX=Math.max(this.maxX,e.x),this.maxY=Math.max(this.maxY,e.y),this}expandBy(e){return this.minX-=e,this.minY-=e,this.maxX+=e,this.maxY+=e,(this.minX>this.maxX||this.minY>this.maxY)&&(this.minX=1/0,this.maxX=-1/0,this.minY=1/0,this.maxY=-1/0),this}shrinkBy(e){return this.expandBy(-e)}map(e){const s=new jh;return s.extend(e(new c(this.minX,this.minY))),s.extend(e(new c(this.maxX,this.minY))),s.extend(e(new c(this.minX,this.maxY))),s.extend(e(new c(this.maxX,this.maxY))),s}static fromPoints(e){const s=new jh;for(const l of e)s.extend(l);return s}contains(e){return e.x>=this.minX&&e.x<=this.maxX&&e.y>=this.minY&&e.y<=this.maxY}empty(){return this.minX>this.maxX}width(){return this.maxX-this.minX}height(){return this.maxY-this.minY}covers(e){return!this.empty()&&!e.empty()&&e.minX>=this.minX&&e.maxX<=this.maxX&&e.minY>=this.minY&&e.maxY<=this.maxY}intersects(e){return!this.empty()&&!e.empty()&&e.minX<=this.maxX&&e.maxX>=this.minX&&e.minY<=this.maxY&&e.maxY>=this.minY}}class Gh{constructor(e){this._stringToNumber={},this._numberToString=[];for(let s=0;s=this._numberToString.length)throw new Error(`Out of bounds. Index requested n=${e} can't be >= this._numberToString.length ${this._numberToString.length}`);return this._numberToString[e]}}class Xh{constructor(e,s,l,c,d){this.type="Feature",this._vectorTileFeature=e,this._x=l,this._y=c,this._z=s,this.properties=e.properties,this.id=d}projectPoint(e,s,l,c){return[360*(e.x+s)/c-180,360/Math.PI*Math.atan(Math.exp((1-2*(e.y+l)/c)*Math.PI))-90]}projectLine(e,s,l,c){return e.map((e=>this.projectPoint(e,s,l,c)))}get geometry(){if(this._geometry)return this._geometry;const e=this._vectorTileFeature,s=e.extent*Math.pow(2,this._z),l=e.extent*this._x,c=e.extent*this._y,d=e.loadGeometry();switch(e.type){case 1:{const e=[];for(const s of d)e.push(s[0]);const p=this.projectLine(e,l,c,s);this._geometry=1===e.length?{type:"Point",coordinates:p[0]}:{type:"MultiPoint",coordinates:p};break}case 2:{const e=d.map((e=>this.projectLine(e,l,c,s)));this._geometry=1===e.length?{type:"LineString",coordinates:e[0]}:{type:"MultiLineString",coordinates:e};break}case 3:{const e=ad(d),p=[];for(const d of e)p.push(d.map((e=>this.projectLine(e,l,c,s))));this._geometry=1===p.length?{type:"Polygon",coordinates:p[0]}:{type:"MultiPolygon",coordinates:p};break}default:throw new Error(`unknown feature type: ${e.type}`)}return this._geometry}set geometry(e){this._geometry=e}toJSON(){const e={geometry:this.geometry};for(const s in this)"_geometry"!==s&&"_vectorTileFeature"!==s&&"_x"!==s&&"_y"!==s&&"_z"!==s&&(e[s]=this[s]);return e}}class Yh{_name;dataBuffer;nullabilityBuffer;_size;constructor(e,s,l){this._name=e,this.dataBuffer=s,"number"==typeof l?this._size=l:(this.nullabilityBuffer=l,this._size=l.size())}getValue(e){return this.nullabilityBuffer&&!this.nullabilityBuffer.get(e)?null:this.getValueFromBuffer(e)}has(e){return this.nullabilityBuffer&&this.nullabilityBuffer.get(e)||!this.nullabilityBuffer}get name(){return this._name}get size(){return this._size}}class Zh extends Yh{}class Hh extends Zh{getValueFromBuffer(e){return this.dataBuffer[e]}}class Kh extends Zh{getValueFromBuffer(e){return this.dataBuffer[e]}}class Wh extends Yh{delta;constructor(e,s,l,c){super(e,s,c),this.delta=l}}class Jh extends Wh{constructor(e,s,l,c){super(e,Int32Array.of(s),l,c)}getValueFromBuffer(e){return this.dataBuffer[0]+e*this.delta}}class Qh extends Yh{constructor(e,s,l){super(e,Int32Array.of(s),l)}getValueFromBuffer(e){return this.dataBuffer[0]}}class tp{_name;_geometryVector;_idVector;_propertyVectors;_extent;propertyVectorsMap;constructor(e,s,l,c,d=4096){this._name=e,this._geometryVector=s,this._idVector=l,this._propertyVectors=c,this._extent=d}get name(){return this._name}get idVector(){return this._idVector}get geometryVector(){return this._geometryVector}get propertyVectors(){return this._propertyVectors}getPropertyVector(e){return this.propertyVectorsMap||(this.propertyVectorsMap=new Map(this._propertyVectors.map((e=>[e.name,e])))),this.propertyVectorsMap.get(e)}*[Symbol.iterator](){const e=this.geometryVector[Symbol.iterator]();let s=0;for(;s>4,d<128)return 4294967296*c+(e>>>0);if(d=s[l.get()],l.increment(),c|=(127&d)<<3,d<128)return 4294967296*c+(e>>>0);if(d=s[l.get()],l.increment(),c|=(127&d)<<10,d<128)return 4294967296*c+(e>>>0);if(d=s[l.get()],l.increment(),c|=(127&d)<<17,d<128)return 4294967296*c+(e>>>0);if(d=s[l.get()],l.increment(),c|=(127&d)<<24,d<128)return 4294967296*c+(e>>>0);if(d=s[l.get()],l.increment(),c|=(1&d)<<31,d<128)return 4294967296*c+(e>>>0);throw new Error("Expected varint not more than 10 bytes")}(l,e,s)))))}function Of(e,s,l,c){throw new Error("FastPFor is not implemented yet.")}function Vf(e){return e>>>1^-(1&e)}function jf(e){return e>>1n^-(1n&e)}function Gf(e,s){let l=0n,c=0,d=s.get();for(;d=64)throw new Error("Varint too long")}return s.set(d),l}function Uf(e,s,l){const c=new Int32Array(l);let d=0;for(let l=0;l=4)for(let c=e[0];l>>1^-(1&e[0]),e[1]=e[1]>>>1^-(1&e[1]);const s=e.length/4*4;let l=2;if(s>=4)for(;l>>1^-(1&s))+e[l-2],e[l+1]=(c>>>1^-(1&c))+e[l-1],e[l+2]=(d>>>1^-(1&d))+e[l],e[l+3]=(p>>>1^-(1&p))+e[l+1]}for(;l!=e.length;l+=2)e[l]=(e[l]>>>1^-(1&e[l]))+e[l-2],e[l+1]=(e[l+1]>>>1^-(1&e[l+1]))+e[l-1]}!function(e){e.NONE="NONE",e.DELTA="DELTA",e.COMPONENTWISE_DELTA="COMPONENTWISE_DELTA",e.RLE="RLE",e.MORTON="MORTON",e.PDE="PDE"}(bf||(bf={})),function(e){e.NONE="NONE",e.FAST_PFOR="FAST_PFOR",e.VARINT="VARINT",e.ALP="ALP"}(wf||(wf={})),function(e){e.PRESENT="PRESENT",e.DATA="DATA",e.OFFSET="OFFSET",e.LENGTH="LENGTH"}(Tf||(Tf={}));class Ap{_dictionaryType;_offsetType;_lengthType;constructor(e,s,l){this._dictionaryType=e,this._offsetType=s,this._lengthType=l}get dictionaryType(){return this._dictionaryType}get offsetType(){return this._offsetType}get lengthType(){return this._lengthType}}function Xf(e,s){const l=function(e,s){const l=e[s.get()],c=Object.values(Tf)[l>>4];let d=null;switch(c){case Tf.DATA:d=new Ap(Object.values(Pf)[15&l]);break;case Tf.OFFSET:d=new Ap(null,Object.values(Sf)[15&l]);break;case Tf.LENGTH:d=new Ap(null,null,Object.values(Ef)[15&l])}s.increment();const p=e[s.get()],f=Object.values(bf)[p>>5],m=Object.values(bf)[p>>2&7],_=Object.values(wf)[3&p];s.increment();const g=Rf(e,s,2),y=g[0];return{physicalStreamType:c,logicalStreamType:d,logicalLevelTechnique1:f,logicalLevelTechnique2:m,physicalLevelTechnique:_,numValues:y,byteLength:g[1],decompressedCount:y}}(e,s);return l.logicalLevelTechnique1===bf.MORTON?function(e,s,l){const c=Rf(s,l,2);return{physicalStreamType:e.physicalStreamType,logicalStreamType:e.logicalStreamType,logicalLevelTechnique1:e.logicalLevelTechnique1,logicalLevelTechnique2:e.logicalLevelTechnique2,physicalLevelTechnique:e.physicalLevelTechnique,numValues:e.numValues,byteLength:e.byteLength,decompressedCount:e.decompressedCount,numBits:c[0],coordinateShift:c[1]}}(l,e,s):bf.RLE!==l.logicalLevelTechnique1&&bf.RLE!==l.logicalLevelTechnique2||wf.NONE===l.physicalLevelTechnique?l:function(e,s,l){const c=Rf(s,l,2);return{physicalStreamType:e.physicalStreamType,logicalStreamType:e.logicalStreamType,logicalLevelTechnique1:e.logicalLevelTechnique1,logicalLevelTechnique2:e.logicalLevelTechnique2,physicalLevelTechnique:e.physicalLevelTechnique,numValues:e.numValues,byteLength:e.byteLength,decompressedCount:c[1],runs:c[0],numRleValues:c[1]}}(l,e,s)}!function(e){e.NONE="NONE",e.SINGLE="SINGLE",e.SHARED="SHARED",e.VERTEX="VERTEX",e.MORTON="MORTON",e.FSST="FSST"}(Pf||(Pf={})),function(e){e.VERTEX="VERTEX",e.INDEX="INDEX",e.STRING="STRING",e.KEY="KEY"}(Sf||(Sf={})),function(e){e.VAR_BINARY="VAR_BINARY",e.GEOMETRIES="GEOMETRIES",e.PARTS="PARTS",e.RINGS="RINGS",e.TRIANGLES="TRIANGLES",e.SYMBOL="SYMBOL",e.DICTIONARY="DICTIONARY"}(Ef||(Ef={})),function(e){e[e.FLAT=0]="FLAT",e[e.CONST=1]="CONST",e[e.SEQUENCE=2]="SEQUENCE",e[e.DICTIONARY=3]="DICTIONARY",e[e.FSST_DICTIONARY=4]="FSST_DICTIONARY"}(Cf||(Cf={}));class Ep{values;_size;constructor(e,s){this.values=e,this._size=s}get(e){const s=Math.floor(e/8);return 1==(this.values[s]>>e%8&1)}set(e,s){const l=Math.floor(e/8);this.values[l]=this.values[l]|(s?1:0)<>e%8&1}size(){return this._size}getBuffer(){return this.values}}function Yf(e,s,l,c,d){return function(e,s,l){switch(s.logicalLevelTechnique1){case bf.DELTA:return s.logicalLevelTechnique2===bf.RLE?function(e,s,l){const c=new Int32Array(l);let d=0,p=0;for(let l=0;l>>1^-(1&e[0]);const s=e.length/4*4;let l=1;if(s>=4)for(;l>>1^-(1&s))+e[l-1],e[l+1]=(c>>>1^-(1&c))+e[l],e[l+2]=(d>>>1^-(1&d))+e[l+1],e[l+3]=(p>>>1^-(1&p))+e[l+2]}for(;l!=e.length;++l)e[l]=(e[l]>>>1^-(1&e[l]))+e[l-1]}(e),e);case bf.RLE:return function(e,s,l){return l?function(e,s,l){const c=new Int32Array(l);let d=0;for(let l=0;l>>1^-(1&f),c.fill(f,d,d+p),d+=p}return c}(e,s.runs,s.numRleValues):Uf(e,s.runs,s.numRleValues)}(e,s,l);case bf.MORTON:return $f(e),e;case bf.COMPONENTWISE_DELTA:return Wf(e),e;case bf.NONE:return l&&function(e){for(let s=0;s>>1^-(1&l)}}(e),e;default:throw new Error(`The specified Logical level technique is not supported: ${s.logicalLevelTechnique1}`)}}(Qf(e,s,l),l,c)}function Kf(e,s,l){return function(e,s){if(s.logicalLevelTechnique1===bf.DELTA&&s.logicalLevelTechnique2===bf.NONE){const s=function(e){const s=new Int32Array(e.length+1);s[0]=0,s[1]=Vf(e[0]);let l=s[1],c=2;for(;c!=s.length;++c){const d=e[c-1];l+=d>>>1^-(1&d),s[c]=s[c-1]+l}return s}(e);return s}if(s.logicalLevelTechnique1===bf.RLE&&s.logicalLevelTechnique2===bf.NONE){const l=function(e,s,l){const c=new Int32Array(l+1);c[0]=0;let d=1,p=c[0];for(let l=0;l>>1^-(1&m);for(let e=d;e>1n^-(1n&e[0]);const s=e.length/4*4;let l=1;if(s>=4)for(;l>1n^-(1n&s))+e[l-1],e[l+1]=(c>>1n^-(1n&c))+e[l],e[l+2]=(d>>1n^-(1n&d))+e[l+1],e[l+3]=(p>>1n^-(1n&p))+e[l+2]}for(;l!=e.length;++l)e[l]=(e[l]>>1n^-(1n&e[l]))+e[l-1]}(e),e);case bf.RLE:return function(e,s,l){return l?function(e,s,l){const c=new BigInt64Array(l);let d=0;for(let l=0;l>1n^-(1n&f),c.fill(f,d,d+p),d+=p}return c}(e,s.runs,s.numRleValues):qf(e,s.runs,s.numRleValues)}(e,s,l);case bf.NONE:return l&&function(e){for(let s=0;s>1n^-(1n&l)}}(e),e;default:throw new Error(`The specified Logical level technique is not supported: ${s.logicalLevelTechnique1}`)}}(Lf(e,s,l.numValues),l,c)}function rm(e,s,l,c){const d=Lf(e,s,l.numValues);if(1===d.length){const e=d[0];return c?jf(e):e}return c?function(e){return jf(e[1])}(d):function(e){return e[1]}(d)}function nm(e,s,l,c,d){return function(e,s,l,c){switch(s.logicalLevelTechnique1){case bf.DELTA:return s.logicalLevelTechnique2===bf.RLE&&(e=Uf(e,s.runs,s.numRleValues)),function(e,s){const l=new Int32Array(e.size());let c=0;e.get(0)?(l[0]=e.get(0)?s[0]>>>1^-(1&s[0]):0,c=1):l[0]=0;let d=1;for(;d!=l.length;++d)l[d]=e.get(d)?l[d-1]+(s[c]>>>1^-(1&s[c++])):l[d-1];return l}(c,e);case bf.RLE:return function(e,s,l,c){const d=s;return l?function(e,s,l){const c=new Int32Array(e.size());let d=0;for(let p=0;p>>1^-(1&m);for(let s=d;s>>1^-(1&e)}else l[d]=0;return l}(c,e):function(e,s){const l=new Int32Array(e.size());let c=0,d=0;for(;d!=l.length;++d)l[d]=e.get(d)?s[c++]:0;return l}(c,e),e;default:throw new Error("The specified Logical level technique is not supported")}}(l.physicalLevelTechnique===wf.FAST_PFOR?Of():Rf(e,s,l.numValues),l,c,d)}function sm(e,s,l,c){const d=e.logicalLevelTechnique1;if(d===bf.RLE)return 1===e.runs?Cf.CONST:Cf.FLAT;const p=s instanceof Ep?s.size():s;if(d===bf.DELTA&&e.logicalLevelTechnique2===bf.RLE){const s=e.runs,d=2;if(e.numRleValues!==p)return Cf.FLAT;if(1===s)return Cf.SEQUENCE;if(2===s){const s=c.get();let p;if(e.physicalLevelTechnique===wf.VARINT)p=Rf(l,c,4);else{const e=c.get();p=new Int32Array(l.buffer,l.byteOffset+e,4)}if(c.set(s),p[2]===d&&p[3]===d)return Cf.SEQUENCE}}return 1===e.numValues?Cf.CONST:Cf.FLAT}class Lp extends Zh{getValueFromBuffer(e){return this.dataBuffer[e]}}class Op extends Wh{constructor(e,s,l,c){super(e,BigInt64Array.of(s),l,c)}getValueFromBuffer(e){return this.dataBuffer[0]+BigInt(e)*this.delta}}class Rp{_geometryOffsets;_partOffsets;_ringOffsets;constructor(e,s,l){this._geometryOffsets=e,this._partOffsets=s,this._ringOffsets=l}get geometryOffsets(){return this._geometryOffsets}get partOffsets(){return this._partOffsets}get ringOffsets(){return this._ringOffsets}}function om(e,s,l){return{x:am(e,s)-l,y:am(e>>1,s)-l}}function am(e,s){let l=0;for(let c=0;c>c;return l}!function(e){e[e.POINT=0]="POINT",e[e.LINESTRING=1]="LINESTRING",e[e.POLYGON=2]="POLYGON",e[e.MULTIPOINT=3]="MULTIPOINT",e[e.MULTILINESTRING=4]="MULTILINESTRING",e[e.MULTIPOLYGON=5]="MULTIPOLYGON"}(Af||(Af={})),function(e){e[e.POINT=0]="POINT",e[e.LINESTRING=1]="LINESTRING",e[e.POLYGON=2]="POLYGON"}(zf||(zf={})),function(e){e[e.MORTON=0]="MORTON",e[e.VEC_2=1]="VEC_2",e[e.VEC_3=2]="VEC_3"}(kf||(kf={}));class Up{createPoint(e){return[[e]]}createMultiPoint(e){return e.map((e=>[e]))}createLineString(e){return[e]}createMultiLineString(e){return e}createPolygon(e,s){return[e].concat(s)}createMultiPolygon(e){return e.flat()}}function lm(e){const s=new Array(e.numGeometries);let l=1,d=1,p=1,f=0;const m=new Up;let _=0,g=0;const y=e.mortonSettings,b=e.topologyVector,T=b.geometryOffsets,P=b.partOffsets,S=b.ringOffsets,I=e.vertexOffsets,C=e.containsPolygonGeometry(),R=e.vertexBuffer;for(let b=0;b0&&s.push(s[0]),b.push(s)}e[s]=b,p&&g++}break;case Af.MULTIPOLYGON:{const y=p[g]-p[g-1];g++;const b=[];for(let e=0;e0&&s.push(s[0]),b.push(s)}}e[s]=b}}return e}[Symbol.iterator](){return null}}function mm(e,s,l,c,d,p){return new ef(e,s,l,c,d,p)}class ef extends Qp{_numGeometries;_geometryType;constructor(e,s,l,c,d,p){super(l,c,d,p),this._numGeometries=e,this._geometryType=s}geometryType(e){return this._geometryType}get numGeometries(){return this._numGeometries}containsSingleGeometryType(){return!0}}function _m(e,s,l,c,d){return new nf(e,s,l,c,d)}class nf extends Qp{_geometryTypes;constructor(e,s,l,c,d){super(s,l,c,d),this._geometryTypes=e}geometryType(e){return this._geometryTypes[e]}get numGeometries(){return this._geometryTypes.length}containsSingleGeometryType(){return!1}}function gm(e,s,l,c,d){const p=Xf(e,l);let f=null,m=null,_=null,g=null,y=null,b=null,T=null,P=null;if(sm(p,c,e,l)===Cf.CONST){const d=Jf(e,l,p,!1);for(let c=0;cl?s[p++]:1);return c}function xm(e,s,l,c){const d=new Int32Array(s[s.length-1]+1);let p=0;d[0]=p;let f=1,m=0;for(let _=0;_=12?wm.decode(e.subarray(s,l)):function(e,s,l){let c="",d=s;for(;d239?4:s>223?3:s>191?2:1;if(d+g>l)break;1===g?s<128&&(_=s):2===g?(p=e[d+1],128==(192&p)&&(_=(31&s)<<6|63&p,_<=127&&(_=null))):3===g?(p=e[d+1],f=e[d+2],128==(192&p)&&128==(192&f)&&(_=(15&s)<<12|(63&p)<<6|63&f,(_<=2047||_>=55296&&_<=57343)&&(_=null))):4===g&&(p=e[d+1],f=e[d+2],m=e[d+3],128==(192&p)&&128==(192&f)&&128==(192&m)&&(_=(15&s)<<18|(63&p)<<12|(63&f)<<6|63&m,(_<=65535||_>=1114112)&&(_=null))),null===_?(_=65533,g=1):_>65535&&(_-=65536,c+=String.fromCharCode(_>>>10&1023|55296),_=56320|1023&_),c+=String.fromCharCode(_),d+=g}return c}(e,s,l)}class yf extends Yh{offsetBuffer;constructor(e,s,l,c){super(e,l,c),this.offsetBuffer=s}}class mf extends yf{textEncoder;constructor(e,s,l,c){super(e,s,l,c??s.length-1),this.textEncoder=new TextEncoder}getValueFromBuffer(e){return Tm(this.dataBuffer,this.offsetBuffer[e],this.offsetBuffer[e+1])}}class gf extends yf{indexBuffer;textEncoder;constructor(e,s,l,c,d){super(e,l,c,d??s.length),this.indexBuffer=s,this.indexBuffer=s,this.textEncoder=new TextEncoder}getValueFromBuffer(e){const s=this.indexBuffer[e];return Tm(this.dataBuffer,this.offsetBuffer[s],this.offsetBuffer[s+1])}}class xf extends yf{indexBuffer;symbolOffsetBuffer;symbolTableBuffer;textEncoder;symbolLengthBuffer;lengthBuffer;decodedDictionary;constructor(e,s,l,c,d,p,f){super(e,l,c,f),this.indexBuffer=s,this.symbolOffsetBuffer=d,this.symbolTableBuffer=p,this.textEncoder=new TextEncoder}getValueFromBuffer(e){null==this.decodedDictionary&&(null==this.symbolLengthBuffer&&(this.symbolLengthBuffer=this.offsetToLengthBuffer(this.symbolOffsetBuffer),this.lengthBuffer=this.offsetToLengthBuffer(this.offsetBuffer)),this.decodedDictionary=function(e,s,l){const c=[],d=new Array(s.length).fill(0);for(let e=1;e>1n^-(1n&s[0]):0n,c=1):l[0]=0n;let d=1;for(;d!=l.length;++d)l[d]=e.get(d)?l[d-1]+(s[c]>>1n^-(1n&s[c++])):l[d-1];return l}(c,e);case bf.RLE:return function(e,s,l,c){const d=s;return l?function(e,s,l){const c=new BigInt64Array(e.size());let d=0;for(let p=0;p>1n^-(1n&m);for(let s=d;s>1n^-(1n&e)}else l[d]=0n;return l}(c,e):function(e,s){const l=new BigInt64Array(e.size());let c=0,d=0;for(;d!=l.length;++d)l[d]=e.get(d)?s[c++]:0n;return l}(c,e),e;default:throw new Error("The specified Logical level technique is not supported")}}(Lf(e,s,l.numValues),l,c,d)}(e,s,p,m,c):im(e,s,p,m);return new Lp(l.name,d,c)}if(f===Cf.SEQUENCE){const c=tm(e,s,p);return new Op(l.name,c[0],c[1],p.numRleValues)}{const d=rm(e,s,p,m);return new cf(l.name,d,c)}}(s,l,p,_,d);case 7:return function(e,s,l,c){const d=Xf(e,s),p=Sm(c)?function(e,s,l,c){const d=s.get(),p=d+c*Float32Array.BYTES_PER_ELEMENT,f=new Uint8Array(e.subarray(d,p)).buffer,m=new Float32Array(f);s.set(p);const _=l.size(),g=new Float32Array(_);let y=0;for(let e=0;e<_;e++)g[e]=l.get(e)?m[y++]:0;return g}(e,s,c,d.numValues):function(e,s,l){const c=s.get(),d=c+l*Float32Array.BYTES_PER_ELEMENT,p=new Uint8Array(e.subarray(c,d)).buffer,f=new Float32Array(p);return s.set(d),f}(e,s,d.numValues);return new uf(l.name,p,c)}(s,l,p,_);case 8:return function(e,s,l,c){const d=Xf(e,s),p=Sm(c)?function(e,s,l,c){const d=s.get(),p=d+c*Float64Array.BYTES_PER_ELEMENT,f=new Uint8Array(e.subarray(d,p)).buffer,m=new Float64Array(f);s.set(p);const _=l.size(),g=new Float64Array(_);let y=0;for(let e=0;e<_;e++)g[e]=l.get(e)?m[y++]:0;return g}(e,s,c,d.numValues):function(e,s,l){const c=s.get(),d=c+l*Float64Array.BYTES_PER_ELEMENT,p=new Uint8Array(e.subarray(c,d)).buffer,f=new Float64Array(p);return s.set(d),f}(e,s,d.numValues);return new Kh(l.name,p,c)}(s,l,p,_);default:throw new Error(`The specified data type for the field is currently not supported: ${d}`)}}(c,e,s,d,l.scalarType,l):1!=c?null:function(e,s,l,c){let d=null,p=null,f=null,m=null,_=!1;for(;!_;){const l=Xf(e,s);switch(l.physicalStreamType){case Tf.LENGTH:Ef.DICTIONARY===l.logicalStreamType.lengthType?d=Kf(e,s,l):f=Kf(e,s,l);break;case Tf.DATA:Pf.SINGLE===l.logicalStreamType.dictionaryType||Pf.SHARED===l.logicalStreamType.dictionaryType?(p=e.subarray(s.get(),s.get()+l.byteLength),_=!0):m=e.subarray(s.get(),s.get()+l.byteLength),s.add(l.byteLength)}}const g=l.complexType.children,y=[];let b=0;for(const _ of g){const g=Rf(e,s,1)[0];if(0==g)continue;const T=`${l.name}${"default"===_.name?"":":"+_.name}`;if(2!==g||"scalarField"!==_.type||9!==_.scalarField.physicalType)throw new Error("Currently only optional string fields are implemented for a struct.");const P=Xf(e,s),S=vm(e,P.numValues,s),I=Xf(e,s),C=I.decompressedCount!==c?nm(e,s,I,!1,new Ep(S,P.numValues)):Yf(e,s,I,!1);y[b++]=m?new xf(T,C,d,p,f,m,new Ep(S,P.numValues)):new gf(T,C,d,p,new Ep(S,P.numValues))}return y}(e,s,l,d)}function Sm(e){return e instanceof Ep}function Mm(e){if("id"===e.name)return!1;if("scalarType"===e.type){const s=e.scalarType;if("physicalType"===s.type)switch(s.physicalType){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:case 8:default:return!1;case 9:return!0}else if("logicalType"===s.type)return!1}else if("complexType"===e.type){const s=e.complexType;if("physicalType"===s.type)switch(s.physicalType){case 0:case 1:return!0;default:return!1}}return console.warn("Unexpected column type in hasStreamCount",e),!1}const Im=new TextDecoder;function Em(e,s){const l=Rf(e,s,1)[0];if(0===l)return"";const c=s.get(),d=e.subarray(c,c+l);return s.add(l),Im.decode(d)}function Cm(e,s){const l=Rf(e,s,1)[0]>>>0,c=!!(4&l),d=!!(2&l),p=Rf(e,s,1)[0]>>>0,f={};if(1&l&&(f.nullable=!0),d){const d={};if(c?(d.type="logicalType",d.logicalType=p):(d.type="physicalType",d.physicalType=p),8&l){const l=Rf(e,s,1)[0]>>>0;d.children=new Array(l);for(let c=0;c>>0,c=function(e){switch(e){case 0:case 1:case 2:case 3:{const s={};s.nullable=!!(1&e),s.columnScope=0;const l={};return l.physicalType=e>1?6:4,l.type="physicalType",s.scalarType=l,s.type="scalarType",s}case 4:{const e={nullable:!1,columnScope:0},s={type:"physicalType",physicalType:0};return e.type="complexType",e.complexType=s,e}case 30:{const e={nullable:!1,columnScope:0},s={type:"physicalType",physicalType:1};return e.type="complexType",e.complexType=s,e}default:return function(e){let s=null;switch(e){case 10:case 11:s=0;break;case 12:case 13:s=1;break;case 14:case 15:s=2;break;case 16:case 17:s=3;break;case 18:case 19:s=4;break;case 20:case 21:s=5;break;case 22:case 23:s=6;break;case 24:case 25:s=7;break;case 26:case 27:s=8;break;case 28:case 29:s=9;break;default:return null}const l={};l.nullable=!!(1&e),l.columnScope=0;const c={type:"physicalType"};return c.physicalType=s,l.type="scalarType",l.scalarType=c,l}(e)}}(l);if(!c)throw new Error(`Unsupported column type code: ${l}`);if(function(e){return e>=10}(l)?c.name=Em(e,s):l>=0&&l<=3?c.name="id":4===l&&(c.name="geometry"),function(e){return 30===e}(l)){const l=Rf(e,s,1)[0]>>>0,d=c.complexType;d.children=new Array(l);for(let c=0;c>>0,p=Rf(e,s,1)[0]>>>0;c.columns=new Array(p);for(let l=0;l=4)for(;l>>0,p=c.get()+s;if(p>e.length)throw new Error(`Block overruns tile: ${p} > ${e.length}`);if(1!=Rf(e,c,1)[0]>>>0){c.set(p);continue}const f=Dm(e,c),m=f[1],_=f[0].featureTables[0];let g=null,y=null;const b=[];let T=0;for(const s of _.columns){const d=s.name;if("id"===d){let p=null;if(s.nullable){const s=Xf(e,c),l=c.get(),d=vm(e,s.numValues,c);c.set(l+s.byteLength),p=new Ep(d,s.numValues)}const f=Xf(e,c);T=f.decompressedCount,g=zm(e,s,c,d,f,p??T,l)}else if("geometry"===d){const s=Rf(e,c,1)[0];if(0===T){const s=c.get();T=Xf(e,c).decompressedCount,c.set(s)}y=gm(e,s,c,T)}else{const l=Mm(s)?Rf(e,c,1)[0]:1;if(0===l&&"scalarType"===s.type)continue;const d=Pm(e,c,s,l,T);if(d)if(Array.isArray(d))for(const e of d)b.push(e);else b.push(d)}}const P=new tp(_.name,y,g,b,m);d.push(P),c.set(p)}return d}(new Uint8Array(e));this.layers=s.reduce(((e,s)=>Object.assign(Object.assign({},e),{[s.name]:new Mf(s)})),{})}}class Df{constructor(e,s){this.feature=e,this.type=e.type,this.properties=e.tags?e.tags:{},this.extent=s,"id"in e&&("string"==typeof e.id?this.id=parseInt(e.id,10):"number"!=typeof e.id||isNaN(e.id)||(this.id=e.id))}loadGeometry(){const e=[],s=1===this.feature.type?[this.feature.geometry]:this.feature.geometry;for(const l of s){const s=[];for(const e of l)s.push(new c(e[0],e[1]));e.push(s)}return e}}const km="_geojsonTileLayer";function Rm(e,s){s.writeVarintField(15,e.version||1),s.writeStringField(1,e.name||""),s.writeVarintField(5,e.extent||4096);const l={keys:[],values:[],keycache:{},valuecache:{}};for(let c=0;c>31}function Vm(e,s){const l=e.loadGeometry(),c=e.type;let d=0,p=0;for(const f of l){let l=1;1===c&&(l=f.length),s.writeVarint(Bm(1,l));const m=3===c?f.length-1:f.length;for(let e=0;e=0&&c[3]>=0&&m.insert(f,c[0],c[1],c[2],c[3])}}loadVTLayers(){return this.vtLayers||(this.vtLayers="mlt"!==this.encoding?new Vu(new Tc(this.rawTileData)).layers:new Ff(this.rawTileData).layers,this.sourceLayerCoder=new Gh(this.vtLayers?Object.keys(this.vtLayers).sort():[km])),this.vtLayers}query(e,s,l,d){this.loadVTLayers();const p=e.params,f=se/e.tileSize/e.scale,m=Co(p.filter,p.globalState),_=e.queryGeometry,g=e.queryPadding*f,y=jh.fromPoints(_),b=this.grid.query(y.minX-g,y.minY-g,y.maxX+g,y.maxY+g),T=jh.fromPoints(e.cameraQueryGeometry).expandBy(g),P=this.grid3D.query(T.minX,T.minY,T.maxX,T.maxY,((s,l,d,p)=>function(e,s,l,d,p){for(const c of e)if(s<=c.x&&l<=c.y&&d>=c.x&&p>=c.y)return!0;const f=[new c(s,l),new c(s,p),new c(d,p),new c(d,l)];if(e.length>2)for(const s of f)if(mh(e,s))return!0;for(let s=0;s(T||(T=Jc(s)),l.queryIntersectsFeature({queryGeometry:_,feature:s,featureState:c,geometry:T,zoom:this.z,transform:e.transform,pixelsToTileUnits:f,pixelPosMatrix:e.pixelPosMatrix,unwrappedTileID:this.tileID.toUnwrapped(),getElevation:e.getElevation}))))}return S}loadMatchingFeature(e,s,l,c,d,p,f,m,_,g,y){const b=this.bucketLayerIDs[s];if(p&&!b.some((e=>p.has(e))))return;const T=this.sourceLayerCoder.decode(l),P=this.vtLayers[T].feature(c);if(d.needGeometry){const e=eh(P,!0);if(!d.filter(new Ps(this.tileID.overscaledZ),e,this.tileID.canonical))return}else if(!d.filter(new Ps(this.tileID.overscaledZ),P))return;const S=this.getId(P,T);for(let s=0;s{const f=s instanceof qs?s.get(p):null;return f&&f.evaluate?f.evaluate(l,c,d):f}))}function Gm(e,s){return s-e}function Um(e,s,l,d,p){const f=[];for(let m=0;m=d&&y.x>=d||(m.x>=d?m=new c(d,m.y+(d-m.x)/(y.x-m.x)*(y.y-m.y))._round():y.x>=d&&(y=new c(d,m.y+(d-m.x)/(y.x-m.x)*(y.y-m.y))._round()),m.y>=p&&y.y>=p||(m.y>=p?m=new c(m.x+(p-m.y)/(y.y-m.y)*(y.x-m.x),p)._round():y.y>=p&&(y=new c(m.x+(p-m.y)/(y.y-m.y)*(y.x-m.x),p)._round()),g&&m.equals(g[g.length-1])||(g=[m],f.push(g)),g.push(y)))))}}return f}function qm(e,s,l,c,d){switch(s){case 1:return function(e,s,l,c){const d=[];for(const p of e)for(const e of p){const p=0===c?e.x:e.y;p>=s&&p<=l&&d.push([e])}return d}(e,l,c,d);case 2:return $m(e,l,c,d,!1);case 3:return $m(e,l,c,d,!0)}return[]}function Zm(e,s,l,d,p){const f=0===d?Wm:Hm;let m=[];const _=[];for(let c=0;cs&&m.push(f(g,y,s)):b>l?T=s&&(m.push(f(g,y,s)),P=!0),T>l&&b<=l&&(m.push(f(g,y,l)),P=!0),!p&&P&&(_.push(m),m=[])}const g=e.length-1,y=0===d?e[g].x:e[g].y;return y>=s&&y<=l&&m.push(e[g]),p&&m.length>0&&!m[0].equals(m[m.length-1])&&m.push(new c(m[0].x,m[0].y)),m.length>0&&_.push(m),_}function $m(e,s,l,c,d){const p=[];for(const f of e){const e=Zm(f,s,l,c,d);e.length>0&&p.push(...e)}return p}function Wm(e,s,l){return new c(l,e.y+(l-e.x)/(s.x-e.x)*(s.y-e.y))}function Hm(e,s,l){return new c(e.x+(l-e.y)/(s.y-e.y)*(s.x-e.x),l)}Kl("FeatureIndex",Nf,{omit:["rawTileData","sourceLayerCoder"]});class Hf extends c{constructor(e,s,l,c){super(e,s),this.angle=l,void 0!==c&&(this.segment=c)}clone(){return new Hf(this.x,this.y,this.angle,this.segment)}}function Xm(e,s,l,c,d){if(void 0===s.segment||0===l)return!0;let p=s,f=s.segment+1,m=0;for(;m>-l/2;){if(f--,f<0)return!1;m-=e[f].dist(p),p=e[f]}m+=e[f].dist(e[f+1]),f++;const _=[];let g=0;for(;mc;)g-=_.shift().angleDelta;if(g>d)return!1;f++,m+=s.dist(l)}return!0}function Ym(e){let s=0;for(let l=0;lg){const y=(g-_)/p,b=Gr.number(c.x,d.x,y),T=Gr.number(c.y,d.y,y),P=new Hf(b,T,d.angleTo(c),l);return P._round(),!f||Xm(e,P,m,f,s)?P:void 0}_+=p}}function e_(e,s,l,c,d,p,f,m,_){const g=Km(c,p,f),y=Qm(c,d),b=y*f,T=0===e[0].x||e[0].x===_||0===e[0].y||e[0].y===_;return s-b=0&&R<_&&L>=0&&L<_&&T-g>=0&&T+g<=y){const l=new Hf(R,L,I,s);l._round(),c&&!Xm(e,l,p,c,d)||P.push(l)}}b+=S}return m||P.length||f||(P=t_(e,b/2,l,c,d,p,f,!0,_)),P}function i_(e,s,l,d){const p=[],f=e.image,m=f.pixelRatio,_=f.paddedRect.w-2,g=f.paddedRect.h-2;let y={x1:e.left,y1:e.top,x2:e.right,y2:e.bottom};const b=f.stretchX||[[0,_]],T=f.stretchY||[[0,g]],P=(e,s)=>e+s[1]-s[0],S=b.reduce(P,0),I=T.reduce(P,0),C=_-S,R=g-I;let L=0,F=S,B=0,O=I,j=0,G=C,U=0,q=R;if(f.content&&d){const s=f.content,l=s[2]-s[0],c=s[3]-s[1];(f.textFitWidth||f.textFitHeight)&&(y=Sp(e)),L=r_(b,0,s[0]),B=r_(T,0,s[1]),F=r_(b,s[0],s[2]),O=r_(T,s[1],s[3]),j=s[0]-L,U=s[1]-B,G=l-F,q=c-O}const Z=y.x1,W=y.y1,J=y.x2-Z,re=y.y2-W,se=(e,d,p,_)=>{const g=s_(e.stretch-L,F,J,Z),y=o_(e.fixed-j,G,e.stretch,S),b=s_(d.stretch-B,O,re,W),T=o_(d.fixed-U,q,d.stretch,I),P=s_(p.stretch-L,F,J,Z),C=o_(p.fixed-j,G,p.stretch,S),R=s_(_.stretch-B,O,re,W),se=o_(_.fixed-U,q,_.stretch,I),oe=new c(g,b),le=new c(P,b),ce=new c(P,R),he=new c(g,R),ue=new c(y/m,T/m),pe=new c(C/m,se/m),fe=s*Math.PI/180;if(fe){const e=Math.sin(fe),s=Math.cos(fe),l=[s,-e,e,s];oe._matMult(l),le._matMult(l),he._matMult(l),ce._matMult(l)}const me=e.stretch+e.fixed,ge=d.stretch+d.fixed;return{tl:oe,tr:le,bl:he,br:ce,tex:{x:f.paddedRect.x+1+me,y:f.paddedRect.y+1+ge,w:p.stretch+p.fixed-me,h:_.stretch+_.fixed-ge},writingMode:void 0,glyphOffset:[0,0],sectionIndex:0,pixelOffsetTL:ue,pixelOffsetBR:pe,minFontScaleX:G/m/J,minFontScaleY:q/m/re,isSDF:l}};if(d&&(f.stretchX||f.stretchY)){const e=n_(b,C,S),s=n_(T,R,I);for(let l=0;l0&&(c=Math.max(10,c),this.circleDiameter=c)}else{const g=(null===(b=f.image)||void 0===b?void 0:b.content)&&(f.image.textFitWidth||f.image.textFitHeight)?Sp(f):{x1:f.left,y1:f.top,x2:f.right,y2:f.bottom};g.y1=g.y1*m-_[0],g.y2=g.y2*m+_[2],g.x1=g.x1*m-_[3],g.x2=g.x2*m+_[1];const T=f.collisionPadding;if(T&&(g.x1-=T[0]*m,g.y1-=T[1]*m,g.x2+=T[2]*m,g.y2+=T[3]*m),y){const e=new c(g.x1,g.y1),s=new c(g.x2,g.y1),l=new c(g.x1,g.y2),d=new c(g.x2,g.y2),p=y*Math.PI/180;e._rotate(p),s._rotate(p),l._rotate(p),d._rotate(p),g.x1=Math.min(e.x,s.x,l.x,d.x),g.x2=Math.max(e.x,s.x,l.x,d.x),g.y1=Math.min(e.y,s.y,l.y,d.y),g.y2=Math.max(e.y,s.y,l.y,d.y)}e.emplaceBack(s.x,s.y,g.x1,g.y1,g.x2,g.y2,l,d,p)}this.boxEndIndex=e.length}}class ud{constructor(e=[],s=(e,s)=>es?1:0){if(this.data=e,this.length=this.data.length,this.compare=s,this.length>0)for(let e=(this.length>>1)-1;e>=0;e--)this._down(e)}push(e){this.data.push(e),this._up(this.length++)}pop(){if(0===this.length)return;const e=this.data[0],s=this.data.pop();return--this.length>0&&(this.data[0]=s,this._down(0)),e}peek(){return this.data[0]}_up(e){const{data:s,compare:l}=this,c=s[e];for(;e>0;){const d=e-1>>1,p=s[d];if(l(c,p)>=0)break;s[e]=p,e=d}s[e]=c}_down(e){const{data:s,compare:l}=this,c=this.length>>1,d=s[e];for(;e=0)break;s[e]=s[c],e=c}s[e]=d}}function a_(e,s=1,l=!1){const d=jh.fromPoints(e[0]),p=Math.min(d.width(),d.height());let f=p/2;const m=new ud([],l_),{minX:_,minY:g,maxX:y,maxY:b}=d;if(0===p)return new c(_,g);for(let s=_;sT.d||!T.d)&&(T=c,l&&console.log("found best %d after %d probes",Math.round(1e4*c.d)/1e4,P)),c.max-T.d<=s||(f=c.h/2,m.push(new c_(c.p.x-f,c.p.y-f,f,e)),m.push(new c_(c.p.x+f,c.p.y-f,f,e)),m.push(new c_(c.p.x-f,c.p.y+f,f,e)),m.push(new c_(c.p.x+f,c.p.y+f,f,e)),P+=4)}return l&&(console.log(`num probes: ${P}`),console.log(`best distance: ${T.d}`)),T.p}function l_(e,s){return s.max-e.max}function c_(s,l,d,p){(this||e).p=new c(s,l),(this||e).h=d,(this||e).d=function(e,s){let l=!1,c=1/0;for(let d=0;de.y!=m.y>e.y&&e.x<(m.x-d.x)*(e.y-d.y)/(m.y-d.y)+d.x&&(l=!l),c=Math.min(c,uh(e,d,m))}}return(l?1:-1)*Math.sqrt(c)}((this||e).p,p),(this||e).max=(this||e).d+(this||e).h*Math.SQRT2}var h_;s.aP=void 0,(h_=s.aP||(s.aP={}))[h_.center=1]="center",h_[h_.left=2]="left",h_[h_.right=3]="right",h_[h_.top=4]="top",h_[h_.bottom=5]="bottom",h_[h_["top-left"]=6]="top-left",h_[h_["top-right"]=7]="top-right",h_[h_["bottom-left"]=8]="bottom-left",h_[h_["bottom-right"]=9]="bottom-right";const u_=Number.POSITIVE_INFINITY;function d_(e,s){return s[1]!==u_?function(e,s,l){let c=0,d=0;switch(s=Math.abs(s),l=Math.abs(l),e){case"top-right":case"top-left":case"top":d=l-7;break;case"bottom-right":case"bottom-left":case"bottom":d=7-l}switch(e){case"top-right":case"bottom-right":case"right":c=-s;break;case"top-left":case"bottom-left":case"left":c=s}return[c,d]}(e,s[0],s[1]):function(e,s){let l=0,c=0;s<0&&(s=0);const d=s/Math.SQRT2;switch(e){case"top-right":case"top-left":c=d-7;break;case"bottom-right":case"bottom-left":c=7-d;break;case"bottom":c=7-s;break;case"top":c=s-7}switch(e){case"top-right":case"bottom-right":l=-d;break;case"top-left":case"bottom-left":l=d;break;case"left":l=s;break;case"right":l=-s}return[l,c]}(e,s[0])}function p_(e,s,l){var c;const d=e.layout,p=null===(c=d.get("text-variable-anchor-offset"))||void 0===c?void 0:c.evaluate(s,{},l);if(p){const e=p.values,s=[];for(let l=0;le*jd));c.startsWith("top")?d[1]-=7:c.startsWith("bottom")&&(d[1]+=7),s[l+1]=d}return new Le(s)}const f=d.get("text-variable-anchor");if(f){let c;c=void 0!==e._unevaluatedLayout.getValue("text-radial-offset")?[d.get("text-radial-offset").evaluate(s,{},l)*jd,u_]:d.get("text-offset").evaluate(s,{},l).map((e=>e*jd));const p=[];for(const e of f)p.push(e,d_(e,c));return new Le(p)}return null}function f_(e){switch(e){case"right":case"top-right":case"bottom-right":return"right";case"left":case"top-left":case"bottom-left":return"left"}return"center"}function m_(e,l,c,d,p,f,m,_,g,y,b,T){let P=f.textMaxSize.evaluate(l,{});void 0===P&&(P=m);const S=e.layers[0].layout,I=S.get("icon-offset").evaluate(l,{},b),C=g_(c.horizontal),R=m/24,L=e.tilePixelRatio*R,F=e.tilePixelRatio*P/24,B=e.tilePixelRatio*_,O=e.tilePixelRatio*S.get("symbol-spacing"),j=S.get("text-padding")*e.tilePixelRatio,G=function(e,s,l,c=1){const d=e.get("icon-padding").evaluate(s,{},l),p=d&&d.values;return[p[0]*c,p[1]*c,p[2]*c,p[3]*c]}(S,l,b,e.tilePixelRatio),U=S.get("text-max-angle")/180*Math.PI,q="viewport"!==S.get("text-rotation-alignment")&&"point"!==S.get("symbol-placement"),Z="map"===S.get("icon-rotation-alignment")&&"point"!==S.get("symbol-placement"),W=S.get("symbol-placement"),J=O/2,re=S.get("icon-text-fit");let oe;d&&"none"!==re&&(e.allowVerticalPlacement&&c.vertical&&(oe=Mp(d,c.vertical,re,S.get("icon-text-fit-padding"),I,R)),C&&(d=Mp(d,C,re,S.get("icon-text-fit-padding"),I,R)));const le=b?T.line.getGranularityForZoomLevel(b.z):1,ce=(_,T)=>{T.x<0||T.x>=se||T.y<0||T.y>=se||function(e,l,c,d,p,f,m,_,g,y,b,T,P,S,I,C,R,L,F,B,O,j,G,U,q){const Z=e.addToLineVertexArray(l,c);let W,J,re,se,oe=0,le=0,ce=0,he=0,ue=-1,pe=-1;const fe={};let me=Gc("");if(e.allowVerticalPlacement&&d.vertical){const e=_.layout.get("text-rotate").evaluate(O,{},U)+90;re=new ld(g,l,y,b,T,d.vertical,P,S,I,e),m&&(se=new ld(g,l,y,b,T,m,R,L,I,e))}if(p){const c=_.layout.get("icon-rotate").evaluate(O,{}),d="none"!==_.layout.get("icon-text-fit"),f=i_(p,c,G,d),P=m?i_(m,c,G,d):void 0;J=new ld(g,l,y,b,T,p,R,L,!1,c),oe=4*f.length;const S=e.iconSizeData;let I=null;"source"===S.kind?(I=[Ip*_.layout.get("icon-size").evaluate(O,{})],I[0]>Cp&&Se(`${e.layerIds[0]}: Value for "icon-size" is >= 255. Reduce your "icon-size".`)):"composite"===S.kind&&(I=[Ip*j.compositeIconSizes[0].evaluate(O,{},U),Ip*j.compositeIconSizes[1].evaluate(O,{},U)],(I[0]>Cp||I[1]>Cp)&&Se(`${e.layerIds[0]}: Value for "icon-size" is >= 255. Reduce your "icon-size".`)),e.addSymbols(e.icon,f,I,B,F,O,s.az.none,l,Z.lineStartIndex,Z.lineLength,-1,U),ue=e.icon.placedSymbolArray.length-1,P&&(le=4*P.length,e.addSymbols(e.icon,P,I,B,F,O,s.az.vertical,l,Z.lineStartIndex,Z.lineLength,-1,U),pe=e.icon.placedSymbolArray.length-1)}const ge=Object.keys(d.horizontal);for(const c of ge){const p=d.horizontal[c];if(!W){me=Gc(p.text);const e=_.layout.get("text-rotate").evaluate(O,{},U);W=new ld(g,l,y,b,T,p,P,S,I,e)}const m=1===p.positionedLines.length;if(ce+=__(e,l,p,f,_,I,O,C,Z,d.vertical?s.az.horizontal:s.az.horizontalOnly,m?ge:[c],fe,ue,j,U),m)break}d.vertical&&(he+=__(e,l,d.vertical,f,_,I,O,C,Z,s.az.vertical,["vertical"],fe,pe,j,U));const ye=W?W.boxStartIndex:e.collisionBoxArray.length,xe=W?W.boxEndIndex:e.collisionBoxArray.length,ve=re?re.boxStartIndex:e.collisionBoxArray.length,be=re?re.boxEndIndex:e.collisionBoxArray.length,we=J?J.boxStartIndex:e.collisionBoxArray.length,Me=J?J.boxEndIndex:e.collisionBoxArray.length,Ee=se?se.boxStartIndex:e.collisionBoxArray.length,Ce=se?se.boxEndIndex:e.collisionBoxArray.length;let Ae=-1;const Ne=(e,s)=>e&&e.circleDiameter?Math.max(e.circleDiameter,s):s;Ae=Ne(W,Ae),Ae=Ne(re,Ae),Ae=Ne(J,Ae),Ae=Ne(se,Ae);const Ge=Ae>-1?1:0;Ge&&(Ae*=q/jd),e.glyphOffsetArray.length>=fh.MAX_GLYPHS&&Se("Too many glyphs being rendered in a tile. See https://github.com/mapbox/mapbox-gl-js/issues/2907"),void 0!==O.sortKey&&e.addToSortKeyRanges(e.symbolInstances.length,O.sortKey);const Ue=p_(_,O,U),[qe,$e]=function(e,l){const c=e.length,d=null==l?void 0:l.values;if((null==d?void 0:d.length)>0)for(let l=0;l=0?fe.right:-1,fe.center>=0?fe.center:-1,fe.left>=0?fe.left:-1,fe.vertical||-1,ue,pe,me,ye,xe,ve,be,we,Me,Ee,Ce,y,ce,he,oe,le,Ge,0,P,Ae,qe,$e)}(e,T,_,c,d,p,oe,e.layers[0],e.collisionBoxArray,l.index,l.sourceLayerIndex,e.index,L,[j,j,j,j],q,g,B,G,Z,I,l,f,y,b,m)};if("line"===W)for(const s of Um(l.geometry,0,0,se,se)){const l=Yu(s,le),p=e_(l,O,U,c.vertical||C,d,24,F,e.overscaling,se);for(const s of p)C&&y_(e,C.text,J,s)||ce(l,s)}else if("line-center"===W){for(const e of l.geometry)if(e.length>1){const s=Yu(e,le),l=Jm(s,U,c.vertical||C,d,24,F);l&&ce(s,l)}}else if("Polygon"===l.type)for(const e of Sn(l.geometry,0)){const s=a_(e,16);ce(Yu(e[0],le,!0),new Hf(s.x,s.y,0))}else if("LineString"===l.type)for(const e of l.geometry){const s=Yu(e,le);ce(s,new Hf(s[0].x,s[0].y,0))}else if("Point"===l.type)for(const e of l.geometry)for(const s of e)ce([s],new Hf(s.x,s.y,0))}function __(e,s,l,d,p,f,m,_,g,y,b,T,P,S,I){const C=function(e,s,l,d,p,f,m,_){const g=d.layout.get("text-rotate").evaluate(f,{})*Math.PI/180,y=[];for(const e of s.positionedLines)for(const d of e.positionedGlyphs){if(!d.rect)continue;const f=d.rect||{};let b=4,T=!0,P=1,S=0;const I=(p||_)&&d.vertical,C=d.metrics.advance*d.scale/2;if(_&&s.verticalizable&&(S=e.lineOffset/2-(d.imageName?-(jd-d.metrics.width*d.scale)/2:(d.scale-1)*jd)),d.imageName){const e=m[d.imageName];T=e.sdf,P=e.pixelRatio,b=1/P}const R=p?[d.x+C,d.y]:[0,0];let L=p?[0,0]:[d.x+C+l[0],d.y+l[1]-S],F=[0,0];I&&(F=L,L=[0,0]);const B=d.metrics.isDoubleResolution?2:1,O=(d.metrics.left-b)*d.scale-C+L[0],j=(-d.metrics.top-b)*d.scale+L[1],G=O+f.w/B*d.scale/P,U=j+f.h/B*d.scale/P,q=new c(O,j),Z=new c(G,j),W=new c(O,U),J=new c(G,U);if(I){const e=new c(-C,C- -17),s=-Math.PI/2,l=12-C,p=new c(22-l,-(d.imageName?l:0)),f=new c(...F);q._rotateAround(s,e)._add(p)._add(f),Z._rotateAround(s,e)._add(p)._add(f),W._rotateAround(s,e)._add(p)._add(f),J._rotateAround(s,e)._add(p)._add(f)}if(g){const e=Math.sin(g),s=Math.cos(g),l=[s,-e,e,s];q._matMult(l),Z._matMult(l),W._matMult(l),J._matMult(l)}const re=new c(0,0),se=new c(0,0);y.push({tl:q,tr:Z,bl:W,br:J,tex:f,writingMode:s.writingMode,glyphOffset:R,sectionIndex:d.sectionIndex,isSDF:T,pixelOffsetTL:re,pixelOffsetBR:se,minFontScaleX:0,minFontScaleY:0})}return y}(0,l,_,p,f,m,d,e.allowVerticalPlacement),R=e.textSizeData;let L=null;"source"===R.kind?(L=[Ip*p.layout.get("text-size").evaluate(m,{})],L[0]>Cp&&Se(`${e.layerIds[0]}: Value for "text-size" is >= 255. Reduce your "text-size".`)):"composite"===R.kind&&(L=[Ip*S.compositeTextSizes[0].evaluate(m,{},I),Ip*S.compositeTextSizes[1].evaluate(m,{},I)],(L[0]>Cp||L[1]>Cp)&&Se(`${e.layerIds[0]}: Value for "text-size" is >= 255. Reduce your "text-size".`)),e.addSymbols(e.text,C,L,_,f,m,y,s,g.lineStartIndex,g.lineLength,P,I);for(const s of b)T[s]=e.text.placedSymbolArray.length-1;return 4*C.length}function g_(e){for(const s in e)return e[s];return null}function y_(e,s,l,c){const d=e.compareText;if(s in d){const e=d[s];for(let s=e.length-1;s>=0;s--)if(c.dist(e[s])>4;if(1!==c)throw new Error(`Got v${c} data when expected v1.`);const d=x_[15&l];if(!d)throw new Error("Unrecognized array type.");const[p]=new Uint16Array(e,2,1),[f]=new Uint32Array(e,4,1);return new Sd(f,p,d,e)}constructor(e,s=64,l=Float64Array,c){if(isNaN(e)||e<0)throw new Error(`Unpexpected numItems value: ${e}.`);this.numItems=+e,this.nodeSize=Math.min(Math.max(+s,2),65535),this.ArrayType=l,this.IndexArrayType=e<65536?Uint16Array:Uint32Array;const d=x_.indexOf(this.ArrayType),p=2*e*this.ArrayType.BYTES_PER_ELEMENT,f=e*this.IndexArrayType.BYTES_PER_ELEMENT,m=(8-f%8)%8;if(d<0)throw new Error(`Unexpected typed array class: ${l}.`);c&&c instanceof ArrayBuffer?(this.data=c,this.ids=new this.IndexArrayType(this.data,8,e),this.coords=new this.ArrayType(this.data,8+f+m,2*e),this._pos=2*e,this._finished=!0):(this.data=new ArrayBuffer(8+p+f+m),this.ids=new this.IndexArrayType(this.data,8,e),this.coords=new this.ArrayType(this.data,8+f+m,2*e),this._pos=0,this._finished=!1,new Uint8Array(this.data,0,2).set([219,16+d]),new Uint16Array(this.data,2,1)[0]=s,new Uint32Array(this.data,4,1)[0]=e)}add(e,s){const l=this._pos>>1;return this.ids[l]=l,this.coords[this._pos++]=e,this.coords[this._pos++]=s,l}finish(){const e=this._pos>>1;if(e!==this.numItems)throw new Error(`Added ${e} items when expected ${this.numItems}.`);return v_(this.ids,this.coords,this.nodeSize,0,this.numItems-1,0),this._finished=!0,this}range(e,s,l,c){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");const{ids:d,coords:p,nodeSize:f}=this,m=[0,d.length-1,0],_=[];for(;m.length;){const g=m.pop()||0,y=m.pop()||0,b=m.pop()||0;if(y-b<=f){for(let f=b;f<=y;f++){const m=p[2*f],g=p[2*f+1];m>=e&&m<=l&&g>=s&&g<=c&&_.push(d[f])}continue}const T=b+y>>1,P=p[2*T],S=p[2*T+1];P>=e&&P<=l&&S>=s&&S<=c&&_.push(d[T]),(0===g?e<=P:s<=S)&&(m.push(b),m.push(T-1),m.push(1-g)),(0===g?l>=P:c>=S)&&(m.push(T+1),m.push(y),m.push(1-g))}return _}within(e,s,l){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");const{ids:c,coords:d,nodeSize:p}=this,f=[0,c.length-1,0],m=[],_=l*l;for(;f.length;){const g=f.pop()||0,y=f.pop()||0,b=f.pop()||0;if(y-b<=p){for(let l=b;l<=y;l++)P_(d[2*l],d[2*l+1],e,s)<=_&&m.push(c[l]);continue}const T=b+y>>1,P=d[2*T],S=d[2*T+1];P_(P,S,e,s)<=_&&m.push(c[T]),(0===g?e-l<=P:s-l<=S)&&(f.push(b),f.push(T-1),f.push(1-g)),(0===g?e+l>=P:s+l>=S)&&(f.push(T+1),f.push(y),f.push(1-g))}return m}}function v_(e,s,l,c,d,p){if(d-c<=l)return;const f=c+d>>1;b_(e,s,f,c,d,p),v_(e,s,l,c,f-1,1-p),v_(e,s,l,f+1,d,1-p)}function b_(e,s,l,c,d,p){for(;d>c;){if(d-c>600){const f=d-c+1,m=l-c+1,_=Math.log(f),g=.5*Math.exp(2*_/3),y=.5*Math.sqrt(_*g*(f-g)/f)*(m-f/2<0?-1:1);b_(e,s,l,Math.max(c,Math.floor(l-m*g/f+y)),Math.min(d,Math.floor(l+(f-m)*g/f+y)),p)}const f=s[2*l+p];let m=c,_=d;for(w_(e,s,c,l),s[2*d+p]>f&&w_(e,s,c,d);m<_;){for(w_(e,s,m,_),m++,_--;s[2*m+p]f;)_--}s[2*c+p]===f?w_(e,s,c,_):(_++,w_(e,s,_,d)),_<=l&&(c=_+1),l<=_&&(d=_-1)}}function w_(e,s,l,c){T_(e,l,c),T_(s,2*l,2*c),T_(s,2*l+1,2*c+1)}function T_(e,s,l){const c=e[s];e[s]=e[l],e[l]=c}function P_(e,s,l,c){const d=e-l,p=s-c;return d*d+p*p}var S_;s.cH=void 0,(S_=s.cH||(s.cH={})).create="create",S_.load="load",S_.fullLoad="fullLoad";let M_=null,I_=[];const E_=1e3/60,C_="loadTime",A_="fullLoadTime",D_={mark(e){performance.mark(e)},frame(e){const s=e;null!=M_&&I_.push(s-M_),M_=s},clearMetrics(){M_=null,I_=[],performance.clearMeasures(C_),performance.clearMeasures(A_);for(const e in s.cH)performance.clearMarks(s.cH[e])},getPerformanceMetrics(){performance.measure(C_,s.cH.create,s.cH.load),performance.measure(A_,s.cH.create,s.cH.fullLoad);const e=performance.getEntriesByName(C_)[0].duration,l=performance.getEntriesByName(A_)[0].duration,c=I_.length,d=1/(I_.reduce(((e,s)=>e+s),0)/c/1e3),p=I_.filter((e=>e>E_)).reduce(((e,s)=>e+(s-E_)/E_),0);return{loadTime:e,fullLoadTime:l,fps:d,percentDroppedFrames:p/(c+p)*100,totalFrames:c}}};s.$=b,s.A=S,s.B=Xl,s.C=ql,s.D=js,s.E=xt,s.F=function([e,s,l]){return s+=90,s*=Math.PI/180,l*=Math.PI/180,{x:e*Math.cos(s)*Math.sin(l),y:e*Math.sin(s)*Math.sin(l),z:e*Math.cos(l)}},s.G=Gr,s.H=Ps,s.I=qc,s.J=$l,s.K=function(e){if(null==Ce){const s=e.navigator?e.navigator.userAgent:null;Ce=!!e.safari||!(!s||!(/\b(iPad|iPhone|iPod)\b/.test(s)||s.match("Safari")&&!s.match("Chrome")))}return Ce},s.L=class{constructor(e,s){this.target=e,this.mapId=s,this.resolveRejects={},this.tasks={},this.taskQueue=[],this.abortControllers={},this.messageHandlers={},this.invoker=new Sh((()=>this.process())),this.subscription=$e(this.target,"message",(e=>this.receive(e)),!1),this.globalScope=Ee(self)?e:window}registerMessageHandler(e,s){this.messageHandlers[e]=s}unregisterMessageHandler(e){delete this.messageHandlers[e]}sendAsync(e,s){return new Promise(((l,c)=>{const d=Math.round(1e18*Math.random()).toString(36).substring(0,10),p=s?$e(s.signal,"abort",(()=>{null==p||p.unsubscribe(),delete this.resolveRejects[d];const s={id:d,type:"",origin:location.origin,targetMapId:e.targetMapId,sourceMapId:this.mapId};this.target.postMessage(s)}),$p):null;this.resolveRejects[d]={resolve:e=>{null==p||p.unsubscribe(),l(e)},reject:e=>{null==p||p.unsubscribe(),c(e)}};const f=[],m=Object.assign(Object.assign({},e),{id:d,sourceMapId:this.mapId,origin:location.origin,data:rc(e.data,f)});this.target.postMessage(m,{transfer:f})}))}receive(e){const s=e.data,l=s.id;if(!("file://"!==s.origin&&"file://"!==location.origin&&"resource://android"!==s.origin&&"resource://android"!==location.origin&&s.origin!==location.origin||s.targetMapId&&this.mapId!==s.targetMapId)){if(""===s.type){delete this.tasks[l];const e=this.abortControllers[l];return delete this.abortControllers[l],void(e&&e.abort())}if(Ee(self)||s.mustQueue)return this.tasks[l]=s,this.taskQueue.push(l),void this.invoker.trigger();this.processTask(l,s)}}process(){if(0===this.taskQueue.length)return;const e=this.taskQueue.shift(),s=this.tasks[e];delete this.tasks[e],this.taskQueue.length>0&&this.invoker.trigger(),s&&this.processTask(e,s)}processTask(e,s){return l(this,void 0,void 0,(function*(){if(""===s.type){const l=this.resolveRejects[e];if(delete this.resolveRejects[e],!l)return;return void(s.error?l.reject(nc(s.error)):l.resolve(nc(s.data)))}if(!this.messageHandlers[s.type])return void this.completeTask(e,new Error(`Could not find a registered handler for ${s.type}, map ID: ${this.mapId}, available handlers: ${Object.keys(this.messageHandlers).join(", ")}`));const l=nc(s.data),c=new AbortController;this.abortControllers[e]=c;try{const d=yield this.messageHandlers[s.type](s.sourceMapId,l,c);this.completeTask(e,null,d)}catch(l){this.completeTask(e,l)}}))}completeTask(e,s,l){const c=[];delete this.abortControllers[e];const d={id:e,type:"",sourceMapId:this.mapId,origin:location.origin,error:s?rc(s):null,data:rc(l,c)};this.target.postMessage(d,{transfer:c})}remove(){this.invoker.remove(),this.subscription.unsubscribe()}},s.M=ft,s.N=function(){var e=new S(16);return S!=Float32Array&&(e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[11]=0,e[12]=0,e[13]=0,e[14]=0),e[0]=1,e[5]=1,e[10]=1,e[15]=1,e},s.O=function(e,s,l){var c,d,p,f,m,_,g,y,b,T,P,S,I=l[0],C=l[1],R=l[2];return s===e?(e[12]=s[0]*I+s[4]*C+s[8]*R+s[12],e[13]=s[1]*I+s[5]*C+s[9]*R+s[13],e[14]=s[2]*I+s[6]*C+s[10]*R+s[14],e[15]=s[3]*I+s[7]*C+s[11]*R+s[15]):(d=s[1],p=s[2],f=s[3],m=s[4],_=s[5],g=s[6],y=s[7],b=s[8],T=s[9],P=s[10],S=s[11],e[0]=c=s[0],e[1]=d,e[2]=p,e[3]=f,e[4]=m,e[5]=_,e[6]=g,e[7]=y,e[8]=b,e[9]=T,e[10]=P,e[11]=S,e[12]=c*I+m*C+b*R+s[12],e[13]=d*I+_*C+T*R+s[13],e[14]=p*I+g*C+P*R+s[14],e[15]=f*I+y*C+S*R+s[15]),e},s.P=c,s.Q=function(e,s,l){var c=l[0],d=l[1],p=l[2];return e[0]=s[0]*c,e[1]=s[1]*c,e[2]=s[2]*c,e[3]=s[3]*c,e[4]=s[4]*d,e[5]=s[5]*d,e[6]=s[6]*d,e[7]=s[7]*d,e[8]=s[8]*p,e[9]=s[9]*p,e[10]=s[10]*p,e[11]=s[11]*p,e[12]=s[12],e[13]=s[13],e[14]=s[14],e[15]=s[15],e},s.R=Sl,s.S=function(e,s,l){var c=s[0],d=s[1],p=s[2],f=s[3],m=s[4],_=s[5],g=s[6],y=s[7],b=s[8],T=s[9],P=s[10],S=s[11],I=s[12],C=s[13],R=s[14],L=s[15],F=l[0],B=l[1],O=l[2],j=l[3];return e[0]=F*c+B*m+O*b+j*I,e[1]=F*d+B*_+O*T+j*C,e[2]=F*p+B*g+O*P+j*R,e[3]=F*f+B*y+O*S+j*L,e[4]=(F=l[4])*c+(B=l[5])*m+(O=l[6])*b+(j=l[7])*I,e[5]=F*d+B*_+O*T+j*C,e[6]=F*p+B*g+O*P+j*R,e[7]=F*f+B*y+O*S+j*L,e[8]=(F=l[8])*c+(B=l[9])*m+(O=l[10])*b+(j=l[11])*I,e[9]=F*d+B*_+O*T+j*C,e[10]=F*p+B*g+O*P+j*R,e[11]=F*f+B*y+O*S+j*L,e[12]=(F=l[12])*c+(B=l[13])*m+(O=l[14])*b+(j=l[15])*I,e[13]=F*d+B*_+O*T+j*C,e[14]=F*p+B*g+O*P+j*R,e[15]=F*f+B*y+O*S+j*L,e},s.T=zl,s.U=function(e,s){const l={};for(let c=0;c0||(null===(d=l.addOrUpdateProperties)||void 0===d?void 0:d.length)>0;if(!f&&!m)continue;p.push(s.geometry);const _=Object.assign({},s);if(e.set(l.id,_),f&&(p.push(l.newGeometry),_.geometry=l.newGeometry),m){if(_.properties=l.removeAllProperties?{}:Object.assign({},_.properties||{}),l.removeProperties)for(const e of l.removeProperties)delete _.properties[e];if(l.addOrUpdateProperties)for(const{key:e,value:s}of l.addOrUpdateProperties)_.properties[e]=s}}return p},s.a9=Vh,s.aA=function(e,{uSize:s,uSizeT:l},{lowerSize:c,upperSize:d}){return"source"===e.kind?c/Ip:"composite"===e.kind?Gr.number(c/Ip,d/Ip,l):s},s.aB=function(e,s){var l=s[0],c=s[1],d=s[2],p=s[3],f=s[4],m=s[5],_=s[6],g=s[7],y=s[8],b=s[9],T=s[10],P=s[11],S=s[12],I=s[13],C=s[14],R=s[15],L=l*m-c*f,F=l*_-d*f,B=l*g-p*f,O=c*_-d*m,j=c*g-p*m,G=d*g-p*_,U=y*I-b*S,q=y*C-T*S,Z=y*R-P*S,W=b*C-T*I,J=b*R-P*I,re=T*R-P*C,se=L*re-F*J+B*W+O*Z-j*q+G*U;return se?(e[0]=(m*re-_*J+g*W)*(se=1/se),e[1]=(d*J-c*re-p*W)*se,e[2]=(I*G-C*j+R*O)*se,e[3]=(T*j-b*G-P*O)*se,e[4]=(_*Z-f*re-g*q)*se,e[5]=(l*re-d*Z+p*q)*se,e[6]=(C*B-S*G-R*F)*se,e[7]=(y*G-T*B+P*F)*se,e[8]=(f*J-m*Z+g*U)*se,e[9]=(c*Z-l*J-p*U)*se,e[10]=(S*j-I*B+R*L)*se,e[11]=(b*B-y*j-P*L)*se,e[12]=(m*q-f*W-_*U)*se,e[13]=(l*W-c*q+d*U)*se,e[14]=(I*F-S*O-C*L)*se,e[15]=(y*O-b*F+T*L)*se,e):null},s.aC=J,s.aD=function(e){var s=e[0],l=e[1];return Math.sqrt(s*s+l*l)},s.aE=function(e){return e[0]=0,e[1]=0,e},s.aF=function(e,s,l){return e[0]=s[0]*l,e[1]=s[1]*l,e},s.aG=Bp,s.aH=q,s.aI=function(e,s,l,d){const p=s.y-e.y,f=s.x-e.x,m=d.y-l.y,_=d.x-l.x,g=m*f-_*p;if(0===g)return null;const y=(_*(e.y-l.y)-m*(e.x-l.x))/g;return new c(e.x+y*f,e.y+y*p)},s.aJ=Um,s.aK=rh,s.aL=function(e){let s=1/0,l=1/0,c=-1/0,d=-1/0;for(const p of e)s=Math.min(s,p.x),l=Math.min(l,p.y),c=Math.max(c,p.x),d=Math.max(d,p.y);return[s,l,c,d]},s.aM=jd,s.aN=oe,s.aO=function(e,s,l,c,d=!1){if(!l[0]&&!l[1])return[0,0];const p=d?"map"===c?-e.bearingInRadians:0:"viewport"===c?e.bearingInRadians:0;if(p){const e=Math.sin(p),s=Math.cos(p);l=[l[0]*s-l[1]*e,l[0]*e+l[1]*s]}return[d?l[0]:oe(s,l[0],e.zoom),d?l[1]:oe(s,l[1],e.zoom)]},s.aQ=zp,s.aR=f_,s.aS=gp,s.aT=Sd,s.aU=Ic,s.aV=pu,s.aW=$a,s.aX=io,s.aY=to,s.aZ=Ye,s.a_=hf,s.aa=jh,s.ab=25,s.ac=Lh,s.ad=e=>{const s=window.document.createElement("video");return s.muted=!0,new Promise((l=>{s.onloadstart=()=>{l(s)};for(const l of e){const e=window.document.createElement("source");vt(l)||(s.crossOrigin="Anonymous"),e.src=l,s.appendChild(e)}}))},s.ae=Dt,s.af=function(){return ye++},s.ag=Fa,s.ah=fh,s.ai=km,s.aj=Co,s.ak=eh,s.al=Xh,s.am=function(e){const s={};if(e.replace(/(?:^|(?:\s*\,\s*))([^\x00-\x20\(\)<>@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)(?:\=(?:([^\x00-\x20\(\)<>@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)|(?:\"((?:[^"\\]|\\.)*)\")))?/g,((e,l,c,d)=>{const p=c||d;return s[l]=!p||p.toLowerCase(),""})),s["max-age"]){const e=parseInt(s["max-age"],10);isNaN(e)?delete s["max-age"]:s["max-age"]=e}return s},s.an=fe,s.ao=85.051129,s.ap=He,s.aq=function(e){return Math.pow(2,e)},s.ar=C,s.as=sf,s.at=function(e){return Math.log(e)/Math.LN2},s.au=function(e){var s=e[0],l=e[1];return s*s+l*l},s.av=function(e){if(!e.length)return new Set;const s=Math.max(...e.map((e=>e.canonical.z)));let l=1/0,c=-1/0,d=1/0,p=-1/0;const f=[];for(const m of e){const{x:e,y:_,z:g}=m.canonical,y=Math.pow(2,s-g),b=e*y,T=_*y;f.push({id:m,x:b,y:T}),bc&&(c=b),Tp&&(p=T)}const m=new Set;for(const e of f)e.x!==l&&e.x!==c&&e.y!==d&&e.y!==p||m.add(e.id);return m},s.aw=function(e,s){const l=Math.abs(2*e.wrap)-+(e.wrap<0),c=Math.abs(2*s.wrap)-+(s.wrap<0);return e.overscaledZ-s.overscaledZ||c-l||s.canonical.y-e.canonical.y||s.canonical.x-e.canonical.x},s.ax=class{constructor(e,s){this.max=e,this.onRemove=s,this.reset()}reset(){for(const e in this.data)for(const s of this.data[e])s.timeout&&clearTimeout(s.timeout),this.onRemove(s.value);return this.data={},this.order=[],this}add(e,s,l){const c=e.wrapped().key;void 0===this.data[c]&&(this.data[c]=[]);const d={value:s,timeout:void 0};if(void 0!==l&&(d.timeout=setTimeout((()=>{this.remove(e,d)}),l)),this.data[c].push(d),this.order.push(c),this.order.length>this.max){const e=this._getAndRemoveByKey(this.order[0]);e&&this.onRemove(e)}return this}has(e){return e.wrapped().key in this.data}getAndRemove(e){return this.has(e)?this._getAndRemoveByKey(e.wrapped().key):null}_getAndRemoveByKey(e){const s=this.data[e].shift();return s.timeout&&clearTimeout(s.timeout),0===this.data[e].length&&delete this.data[e],this.order.splice(this.order.indexOf(e),1),s.value}getByKey(e){const s=this.data[e];return s?s[0].value:null}get(e){return this.has(e)?this.data[e.wrapped().key][0].value:null}remove(e,s){if(!this.has(e))return this;const l=e.wrapped().key,c=void 0===s?0:this.data[l].indexOf(s),d=this.data[l][c];return this.data[l].splice(c,1),d.timeout&&clearTimeout(d.timeout),0===this.data[l].length&&delete this.data[l],this.onRemove(d.value),this.order.splice(this.order.indexOf(l),1),this}setMaxSize(e){for(this.max=e;this.order.length>this.max;){const e=this._getAndRemoveByKey(this.order[0]);e&&this.onRemove(e)}return this}filter(e){const s=[];for(const l in this.data)for(const c of this.data[l])e(c.value)||s.push(c);for(const e of s)this.remove(e.value.tileID,e)}},s.ay=function(e,s){let l=0,c=0;if("constant"===e.kind)c=e.layoutSize;else if("source"!==e.kind){const{interpolationType:d,minZoom:p,maxZoom:f}=e,m=d?fe(fr.interpolationFactor(d,s,p,f),0,1):0;"camera"===e.kind?c=Gr.number(e.minSize,e.maxSize,m):l=m}return{uSizeT:l,uSize:c}},s.b=Ae,s.b$=Ao,s.b0=B,s.b1=function(e){var s=new S(3);return s[0]=e[0],s[1]=e[1],s[2]=e[2],s},s.b2=function(e,s,l){return e[0]=s[0]-l[0],e[1]=s[1]-l[1],e[2]=s[2]-l[2],e},s.b3=function(e,s){var l=s[0],c=s[1],d=s[2],p=l*l+c*c+d*d;return p>0&&(p=1/Math.sqrt(p)),e[0]=s[0]*p,e[1]=s[1]*p,e[2]=s[2]*p,e},s.b4=j,s.b5=function(e,s){return e[0]*s[0]+e[1]*s[1]+e[2]*s[2]},s.b6=function(e,s,l){return e[0]=s[0]*l[0],e[1]=s[1]*l[1],e[2]=s[2]*l[2],e[3]=s[3]*l[3],e},s.b7=L,s.b8=function(e,s,l){const c=s[0]*l[0]+s[1]*l[1]+s[2]*l[2];return 0===c?null:(-(e[0]*l[0]+e[1]*l[1]+e[2]*l[2])-l[3])/c},s.b9=U,s.bA=function(e,s,l,c){return e[0]=s[0]+l[0]*c,e[1]=s[1]+l[1]*c,e[2]=s[2]+l[2]*c,e},s.bB=W,s.bC=function(e,s,l){var c=l[0],d=l[1],p=l[2],f=l[3],m=s[0],_=s[1],g=s[2],y=d*g-p*_,b=p*m-c*g,T=c*_-d*m;return e[0]=m+f*(y+=y)+d*(T+=T)-p*(b+=b),e[1]=_+f*b+p*y-c*T,e[2]=g+f*T+c*b-d*y,e},s.bD=function(e,s,l){const c=function(e){var s=e[3],l=e[4],c=e[5],d=e[6],p=e[7],f=e[8];return e[0]*(f*l-c*p)+e[1]*(-f*s+c*d)+e[2]*(p*s-l*d)}([e[0],e[1],e[2],s[0],s[1],s[2],l[0],l[1],l[2]]);if(0===c)return null;const d=j([],[s[0],s[1],s[2]],[l[0],l[1],l[2]]),p=j([],[l[0],l[1],l[2]],[e[0],e[1],e[2]]),f=j([],[e[0],e[1],e[2]],[s[0],s[1],s[2]]),m=O([],d,-e[3]);return B(m,m,O([],p,-s[3])),B(m,m,O([],f,-l[3])),O(m,m,1/c),m},s.bE=Hp,s.bF=function(){return new Float64Array(4)},s.bG=function(e,s,l,c){var d=[],p=[];return d[0]=s[0]-l[0],d[1]=s[1]-l[1],d[2]=s[2]-l[2],p[0]=d[0]*Math.cos(c)-d[1]*Math.sin(c),p[1]=d[0]*Math.sin(c)+d[1]*Math.cos(c),p[2]=d[2],e[0]=p[0]+l[0],e[1]=p[1]+l[1],e[2]=p[2]+l[2],e},s.bH=function(e,s,l,c){var d=[],p=[];return d[0]=s[0]-l[0],d[1]=s[1]-l[1],d[2]=s[2]-l[2],p[0]=d[0],p[1]=d[1]*Math.cos(c)-d[2]*Math.sin(c),p[2]=d[1]*Math.sin(c)+d[2]*Math.cos(c),e[0]=p[0]+l[0],e[1]=p[1]+l[1],e[2]=p[2]+l[2],e},s.bI=function(e,s,l,c){var d=[],p=[];return d[0]=s[0]-l[0],d[1]=s[1]-l[1],d[2]=s[2]-l[2],p[0]=d[2]*Math.sin(c)+d[0]*Math.cos(c),p[1]=d[1],p[2]=d[2]*Math.cos(c)-d[0]*Math.sin(c),e[0]=p[0]+l[0],e[1]=p[1]+l[1],e[2]=p[2]+l[2],e},s.bJ=function(e,s,l){var c=Math.sin(l),d=Math.cos(l),p=s[0],f=s[1],m=s[2],_=s[3],g=s[8],y=s[9],b=s[10],T=s[11];return s!==e&&(e[4]=s[4],e[5]=s[5],e[6]=s[6],e[7]=s[7],e[12]=s[12],e[13]=s[13],e[14]=s[14],e[15]=s[15]),e[0]=p*d-g*c,e[1]=f*d-y*c,e[2]=m*d-b*c,e[3]=_*d-T*c,e[8]=p*c+g*d,e[9]=f*c+y*d,e[10]=m*c+b*d,e[11]=_*c+T*d,e},s.bK=function(e,s){const l=le(e,360),c=le(s,360),d=c-l,p=c>l?d-360:d+360;return Math.abs(d)0?f:-f},s.bN=function(e,s){const l=le(e,2*Math.PI),c=le(s,2*Math.PI);return Math.min(Math.abs(l-c),Math.abs(l-c+2*Math.PI),Math.abs(l-c-2*Math.PI))},s.bO=function(){const e={},s=Tt.$version;for(const l in Tt.$root){const c=Tt.$root[l];if(c.required){let d=null;d="version"===l?s:"array"===c.type?[]:{},null!=d&&(e[l]=d)}}return e},s.bP=_t,s.bQ=xs,s.bR=function e(s,l){if(Array.isArray(s)){if(!Array.isArray(l)||s.length!==l.length)return!1;for(let c=0;c"raster"===e.type,s.bV=be,s.bW=function(e,s){if(!e)return[{command:"setStyle",args:[s]}];let l=[];try{if(!Lt(e.version,s.version))return[{command:"setStyle",args:[s]}];Lt(e.center,s.center)||l.push({command:"setCenter",args:[s.center]}),Lt(e.state,s.state)||l.push({command:"setGlobalState",args:[s.state]}),Lt(e.centerAltitude,s.centerAltitude)||l.push({command:"setCenterAltitude",args:[s.centerAltitude]}),Lt(e.zoom,s.zoom)||l.push({command:"setZoom",args:[s.zoom]}),Lt(e.bearing,s.bearing)||l.push({command:"setBearing",args:[s.bearing]}),Lt(e.pitch,s.pitch)||l.push({command:"setPitch",args:[s.pitch]}),Lt(e.roll,s.roll)||l.push({command:"setRoll",args:[s.roll]}),Lt(e.sprite,s.sprite)||l.push({command:"setSprite",args:[s.sprite]}),Lt(e.glyphs,s.glyphs)||l.push({command:"setGlyphs",args:[s.glyphs]}),Lt(e.transition,s.transition)||l.push({command:"setTransition",args:[s.transition]}),Lt(e.light,s.light)||l.push({command:"setLight",args:[s.light]}),Lt(e.terrain,s.terrain)||l.push({command:"setTerrain",args:[s.terrain]}),Lt(e.sky,s.sky)||l.push({command:"setSky",args:[s.sky]}),Lt(e.projection,s.projection)||l.push({command:"setProjection",args:[s.projection]});const c={},d=[];!function(e,s,l,c){let d;for(d in s=s||{},e=e||{})Object.prototype.hasOwnProperty.call(e,d)&&(Object.prototype.hasOwnProperty.call(s,d)||Gt(d,l,c));for(d in s)Object.prototype.hasOwnProperty.call(s,d)&&(Object.prototype.hasOwnProperty.call(e,d)?Lt(e[d],s[d])||("geojson"===e[d].type&&"geojson"===s[d].type&&Ht(e,s,d)?Ft(l,{command:"setGeoJSONSourceData",args:[d,s[d].data]}):Zt(d,s,l,c)):Ot(d,s,l))}(e.sources,s.sources,d,c);const p=[];e.layers&&e.layers.forEach((e=>{"source"in e&&c[e.source]?l.push({command:"removeLayer",args:[e.id]}):p.push(e)})),l=l.concat(d),function(e,s,l){s=s||[];const c=(e=e||[]).map(Kt),d=s.map(Kt),p=e.reduce(Jt,{}),f=s.reduce(Jt,{}),m=c.slice(),_=Object.create(null);let g,y,b,T,P;for(let e=0,s=0;eP?(d=Math.acos(p),f=Math.sin(d),m=Math.sin((1-c)*d)/f,_=Math.sin(c*d)/f):(m=1-c,_=c),e[0]=m*g+_*S,e[1]=m*y+_*I,e[2]=m*b+_*C,e[3]=m*T+_*R,e},s.bn=function(e){const s=new Float64Array(9);!function(e,s){var l=s[0],c=s[1],d=s[2],p=s[3],f=l+l,m=c+c,_=d+d,g=l*f,y=c*f,b=c*m,T=d*f,P=d*m,S=d*_,I=p*f,C=p*m,R=p*_;e[0]=1-b-S,e[3]=y-R,e[6]=T+C,e[1]=y+R,e[4]=1-g-S,e[7]=P-I,e[2]=T-C,e[5]=P+I,e[8]=1-g-b}(s,e);const l=Ye(-Math.asin(fe(s[2],-1,1)));let c,d;return Math.hypot(s[5],s[8])<.001?(c=0,d=-Ye(Math.atan2(s[3],s[4]))):(c=Ye(0===s[5]&&0===s[8]?0:Math.atan2(s[5],s[8])),d=Ye(0===s[1]&&0===s[0]?0:Math.atan2(s[1],s[0]))),{roll:c,pitch:l+90,bearing:d}},s.bo=function(e,s){return e.roll==s.roll&&e.pitch==s.pitch&&e.bearing==s.bearing},s.bp=Te,s.bq=_o,s.br=Wu,s.bs=Hu,s.bt=hu,s.bu=ce,s.bv=he,s.bw=Re,s.bx=function(e,s,l,c,d){return ce(c,d,fe((e-s)/(l-s),0,1))},s.by=le,s.bz=function(){return new Float64Array(3)},s.c=ot,s.c$=function(s,c,d,p,f){return l(this||e,void 0,void 0,(function*(){if(T())try{return yield Ge(s,c,d,p,f)}catch(e){}return function(e,s,l,c,d){const p=e.width,f=e.height;Ue&&qe||(Ue=new OffscreenCanvas(p,f),qe=Ue.getContext("2d",{willReadFrequently:!0})),Ue.width=p,Ue.height=f,qe.drawImage(e,0,0,p,f);const m=qe.getImageData(s,l,c,d);return qe.clearRect(0,0,p,f),m.data}(s,c,d,p,f)}))},s.c0=class extends wo{constructor(e,s){super(e,s),this.current=Wc}set(e){if(e[12]!==this.current[12]||e[0]!==this.current[0])return this.current=e,void this.gl.uniformMatrix4fv(this.location,!1,e);for(let s=1;s<16;s++)if(e[s]!==this.current[s]){this.current=e,this.gl.uniformMatrix4fv(this.location,!1,e);break}}},s.c1=So,s.c2=class extends wo{constructor(e,s){super(e,s),this.current=[0,0,0]}set(e){e[0]===this.current[0]&&e[1]===this.current[1]&&e[2]===this.current[2]||(this.current=e,this.gl.uniform3f(this.location,e[0],e[1],e[2]))}},s.c3=class extends wo{constructor(e,s){super(e,s),this.current=[0,0]}set(e){e[0]===this.current[0]&&e[1]===this.current[1]||(this.current=e,this.gl.uniform2f(this.location,e[0],e[1]))}},s.c4=I,s.c5=function(e,s){var l=Math.sin(s),c=Math.cos(s);return e[0]=c,e[1]=l,e[2]=0,e[3]=-l,e[4]=c,e[5]=0,e[6]=0,e[7]=0,e[8]=1,e},s.c6=function(e,s,l){var c=s[0],d=s[1],p=s[2];return e[0]=c*l[0]+d*l[3]+p*l[6],e[1]=c*l[1]+d*l[4]+p*l[7],e[2]=c*l[2]+d*l[5]+p*l[8],e},s.c7=function(e,s,l,c,d,p,f){var m=1/(s-l),_=1/(c-d),g=1/(p-f);return e[0]=-2*m,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=-2*_,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=2*g,e[11]=0,e[12]=(s+l)*m,e[13]=(d+c)*_,e[14]=(f+p)*g,e[15]=1,e},s.c8=class extends wo{constructor(e,s){super(e,s),this.current=new Array}set(e){if(e!=this.current){this.current=e;const s=new Float32Array(4*e.length);for(let l=0;l25||c<0||c>=1||l<0||l>=1)},s.cE=function(e,s){return e[0]=s[0],e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=s[1],e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=s[2],e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e},s.cF=class extends aa{},s.cG=D_,s.cI=ct,s.cJ=function(e,s){ot.REGISTERED_PROTOCOLS[e]=s},s.cK=function(e){delete ot.REGISTERED_PROTOCOLS[e]},s.cL=function(e,s){const l={};for(let c=0;ce*jd))}let F=m?"center":c.get("text-justify").evaluate(d,{},e.canonical);const B="point"===c.get("symbol-placement")?c.get("text-max-width").evaluate(d,{},e.canonical)*jd:1/0,O=()=>{e.bucket.allowVerticalPlacement&&cc(p)&&(S.vertical=_p(I,e.glyphMap,e.glyphPositions,e.imagePositions,y,B,f,C,"left",P,R,s.az.vertical,!0,T,b))};if(!m&&L){const l=new Set;if("auto"===F)for(let e=0;e=this.maxEntries){const e=this.map.keys().next().value;this.map.delete(e)}this.map.set(e,s)}clear(){this.map.clear()}},s.cX=Vu,s.cY=Tc,s.cZ=Ff,s.c_=class{constructor(e){this._marks={start:[e.url,"start"].join("#"),end:[e.url,"end"].join("#"),measure:e.url.toString()},performance.mark(this._marks.start)}finish(){performance.mark(this._marks.end);let e=performance.getEntriesByName(this._marks.measure);return 0===e.length&&(performance.measure(this._marks.measure,this._marks.start,this._marks.end),e=performance.getEntriesByName(this._marks.measure),performance.clearMarks(this._marks.start),performance.clearMarks(this._marks.end),performance.clearMeasures(this._marks.measure)),e}},s.ca=class extends xa{},s.cb=Od,s.cc=class extends ba{},s.cd=iu,s.ce=function(e){return e<=1?1:Math.pow(2,Math.ceil(Math.log(e)/Math.LN2))},s.cf=tu,s.cg=function(e,s,l){var c=s[0],d=s[1],p=s[2],f=l[3]*c+l[7]*d+l[11]*p+l[15];return e[0]=(l[0]*c+l[4]*d+l[8]*p+l[12])/(f=f||1),e[1]=(l[1]*c+l[5]*d+l[9]*p+l[13])/f,e[2]=(l[2]*c+l[6]*d+l[10]*p+l[14])/f,e},s.ch=class extends oa{},s.ci=class extends Ta{},s.cj=function(e,s){return e[0]===s[0]&&e[1]===s[1]&&e[2]===s[2]&&e[3]===s[3]&&e[4]===s[4]&&e[5]===s[5]&&e[6]===s[6]&&e[7]===s[7]&&e[8]===s[8]&&e[9]===s[9]&&e[10]===s[10]&&e[11]===s[11]&&e[12]===s[12]&&e[13]===s[13]&&e[14]===s[14]&&e[15]===s[15]},s.ck=function(e,s){var l=e[0],c=e[1],d=e[2],p=e[3],f=e[4],m=e[5],_=e[6],g=e[7],y=e[8],b=e[9],T=e[10],S=e[11],I=e[12],C=e[13],R=e[14],L=e[15],F=s[0],B=s[1],O=s[2],j=s[3],G=s[4],U=s[5],q=s[6],Z=s[7],W=s[8],J=s[9],re=s[10],se=s[11],oe=s[12],le=s[13],ce=s[14],he=s[15];return Math.abs(l-F)<=P*Math.max(1,Math.abs(l),Math.abs(F))&&Math.abs(c-B)<=P*Math.max(1,Math.abs(c),Math.abs(B))&&Math.abs(d-O)<=P*Math.max(1,Math.abs(d),Math.abs(O))&&Math.abs(p-j)<=P*Math.max(1,Math.abs(p),Math.abs(j))&&Math.abs(f-G)<=P*Math.max(1,Math.abs(f),Math.abs(G))&&Math.abs(m-U)<=P*Math.max(1,Math.abs(m),Math.abs(U))&&Math.abs(_-q)<=P*Math.max(1,Math.abs(_),Math.abs(q))&&Math.abs(g-Z)<=P*Math.max(1,Math.abs(g),Math.abs(Z))&&Math.abs(y-W)<=P*Math.max(1,Math.abs(y),Math.abs(W))&&Math.abs(b-J)<=P*Math.max(1,Math.abs(b),Math.abs(J))&&Math.abs(T-re)<=P*Math.max(1,Math.abs(T),Math.abs(re))&&Math.abs(S-se)<=P*Math.max(1,Math.abs(S),Math.abs(se))&&Math.abs(I-oe)<=P*Math.max(1,Math.abs(I),Math.abs(oe))&&Math.abs(C-le)<=P*Math.max(1,Math.abs(C),Math.abs(le))&&Math.abs(R-ce)<=P*Math.max(1,Math.abs(R),Math.abs(ce))&&Math.abs(L-he)<=P*Math.max(1,Math.abs(L),Math.abs(he))},s.cl=function(e,s){return e[0]=s[0],e[1]=s[1],e[2]=s[2],e[3]=s[3],e[4]=s[4],e[5]=s[5],e[6]=s[6],e[7]=s[7],e[8]=s[8],e[9]=s[9],e[10]=s[10],e[11]=s[11],e[12]=s[12],e[13]=s[13],e[14]=s[14],e[15]=s[15],e},s.cm=e=>"symbol"===e.type,s.cn=e=>"circle"===e.type,s.co=e=>"heatmap"===e.type,s.cp=e=>"line"===e.type,s.cq=e=>"fill"===e.type,s.cr=e=>"fill-extrusion"===e.type,s.cs=e=>"hillshade"===e.type,s.ct=e=>"color-relief"===e.type,s.cu=e=>"background"===e.type,s.cv=e=>"custom"===e.type,s.cw=ue,s.cx=function(e,s,l){const c=re(s.x-l.x,s.y-l.y),d=re(e.x-l.x,e.y-l.y),p=Math.atan2(c[0]*d[1]-c[1]*d[0],function(e,s){return e[0]*s[0]+e[1]*s[1]}(c,d));return Ye(p)},s.cy=pe,s.cz=function(e,s){return tt[s]&&(e instanceof MouseEvent||e instanceof WheelEvent)},s.d=vt,s.d0=Pl,s.d1=d,s.d2=class{constructor(e,s){this.layers={[km]:this},this.name=km,this.version=s?s.version:1,this.extent=s?s.extent:4096,this.length=e.length,this.features=e}feature(e){return new Df(this.features[e],this.extent)}},s.d3=Vs,s.d4=xc,s.e=ge,s.f=e=>l(void 0,void 0,void 0,(function*(){if(0===e.byteLength)return createImageBitmap(new ImageData(1,1));const s=new Blob([new Uint8Array(e)],{type:"image/png"});try{return createImageBitmap(s)}catch(e){throw new Error(`Could not load image because of ${e.message}. Please make sure to use a supported image type such as PNG or JPEG. Note that SVGs are not supported.`)}})),s.g=at,s.h=e=>new Promise(((s,l)=>{const c=new Image;c.onload=()=>{s(c),URL.revokeObjectURL(c.src),c.onload=null,window.requestAnimationFrame((()=>{c.src=Ne}))},c.onerror=()=>l(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 d=new Blob([new Uint8Array(e)],{type:"image/png"});c.src=e.byteLength?URL.createObjectURL(d):Ne})),s.i=Ee,s.j=(e,s)=>yt(ge(e,{type:"json"}),s),s.k=gt,s.l=mt,s.m=yt,s.n=(e,s)=>yt(ge(e,{type:"arrayBuffer"}),s),s.o=function(e){return new Tc(e).readFields(up,[])},s.p=fp,s.q=function(e){return/[\u02EA\u02EB\u1100-\u11FF\u2E80-\u2FDF\u3000-\u30FF\u3105-\u312F\u3131-\u318E\u31A0-\u4DBF\u4E00-\uA48C\uA490-\uA4C6\uA960-\uA97C\uAC00-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFE10-\uFE1F\uFE30-\uFE4F\uFF00-\uFFEF]|\uD81B[\uDFE0-\uDFFF]|[\uD81C-\uD822\uD840-\uD868\uD86A-\uD86D\uD86F-\uD872\uD874-\uD879\uD880-\uD883\uD885-\uD88C][\uDC00-\uDFFF]|\uD823[\uDC00-\uDCD5\uDCFF-\uDD1E\uDD80-\uDDF2]|\uD82B[\uDFF0-\uDFFF]|\uD82C[\uDC00-\uDEFB]|\uD83C[\uDE00-\uDEFF]|\uD869[\uDC00-\uDEDF\uDF00-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEAD\uDEB0-\uDFFF]|\uD87A[\uDC00-\uDFE0\uDFF0-\uDFFF]|\uD87B[\uDC00-\uDE5D]|\uD87E[\uDC00-\uDE1D]|\uD884[\uDC00-\uDF4A\uDF50-\uDFFF]|\uD88D[\uDC00-\uDC79]/gim.test(String.fromCodePoint(e))},s.r=_l,s.s=$e,s.t=Hs,s.u=Tt,s.v=Ul,s.w=Se,s.x=Os,s.y=Zl,s.z=bc}));c("worker",["./shared"],(function(e){class t{constructor(e,s){this.keyCache={},e&&this.replace(e,s)}replace(e,s){this._layerConfigs={},this._layers={},this.update(e,[],s)}update(s,l,c){for(const l of s){this._layerConfigs[l.id]=l;const s=this._layers[l.id]=e.bT(l,c);s._featureFilter=e.aj(s.filter,c),this.keyCache[l.id]&&delete this.keyCache[l.id]}for(const e of l)delete this.keyCache[e],delete this._layerConfigs[e],delete this._layers[e];this.familiesBySource={};const d=e.cL(Object.values(this._layerConfigs),this.keyCache);for(const s of d){const l=s.map((e=>this._layers[e.id])),c=l[0];if(c.isHidden())continue;const d=c.source||"";let p=this.familiesBySource[d];p||(p=this.familiesBySource[d]={});const f=c.sourceLayer||e.ai;let m=p[f];m||(m=p[f]=[]),m.push(l)}}}class o{constructor(s){const l={},c=[];for(const e in s){const d=s[e],p=l[e]={};for(const e in d){const s=d[+e];if(!s||0===s.bitmap.width||0===s.bitmap.height)continue;const l={x:0,y:0,w:s.bitmap.width+2,h:s.bitmap.height+2};c.push(l),p[e]={rect:l,metrics:s.metrics}}}const{w:d,h:p}=e.p(c),f=new e.r({width:d||1,height:p||1});for(const c in s){const d=s[c];for(const s in d){const p=d[+s];if(!p||0===p.bitmap.width||0===p.bitmap.height)continue;const m=l[c][s].rect;e.r.copy(p.bitmap,f,{x:0,y:0},{x:m.x+1,y:m.y+1},p.bitmap)}}this.image=f,this.positions=l}}e.cM("GlyphAtlas",o);class i{constructor(s){this.tileID=new e.a2(s.tileID.overscaledZ,s.tileID.wrap,s.tileID.canonical.z,s.tileID.canonical.x,s.tileID.canonical.y),this.uid=s.uid,this.zoom=s.zoom,this.pixelRatio=s.pixelRatio,this.tileSize=s.tileSize,this.source=s.source,this.overscaling=this.tileID.overscaleFactor(),this.showCollisionBoxes=s.showCollisionBoxes,this.collectResourceTiming=!!s.collectResourceTiming,this.returnDependencies=!!s.returnDependencies,this.promoteId=s.promoteId,this.inFlightDependencies=[]}parse(l,c,d,p,f){return e._(this,void 0,void 0,(function*(){this.status="parsing",this.data=l,this.collisionBoxArray=new e.ag;const m=new e.cN(Object.keys(l.layers).sort()),_=new e.cO(this.tileID,this.promoteId);_.bucketLayerIDs=[];const g={},y={featureIndex:_,iconDependencies:{},patternDependencies:{},glyphDependencies:{},dashDependencies:{},availableImages:d,subdivisionGranularity:f},b=c.familiesBySource[this.source];for(const c in b){const p=l.layers[c];if(!p)continue;1===p.version&&e.w(`Vector tile source "${this.source}" layer "${c}" does not use vector tile spec v2 and therefore may have some rendering errors.`);const f=m.encode(c),T=[];for(let e=0;ee.id))))}}const T=e.bY(y.glyphDependencies,(e=>Object.keys(e).map(Number)));this.inFlightDependencies.forEach((e=>null==e?void 0:e.abort())),this.inFlightDependencies=[];let P=Promise.resolve({});if(Object.keys(T).length){const e=new AbortController;this.inFlightDependencies.push(e),P=p.sendAsync({type:"GG",data:{stacks:T,source:this.source,tileID:this.tileID,type:"glyphs"}},e)}const S=Object.keys(y.iconDependencies);let I=Promise.resolve({});if(S.length){const e=new AbortController;this.inFlightDependencies.push(e),I=p.sendAsync({type:"GI",data:{icons:S,source:this.source,tileID:this.tileID,type:"icons"}},e)}const C=Object.keys(y.patternDependencies);let R=Promise.resolve({});if(C.length){const e=new AbortController;this.inFlightDependencies.push(e),R=p.sendAsync({type:"GI",data:{icons:C,source:this.source,tileID:this.tileID,type:"patterns"}},e)}const L=y.dashDependencies;let F=Promise.resolve({});if(Object.keys(L).length){const e=new AbortController;this.inFlightDependencies.push(e),F=p.sendAsync({type:"GDA",data:{dashes:L}},e)}const[B,O,j,G]=yield Promise.all([P,I,R,F]),U=new o(B),q=new e.cP(O,j);for(const l in g){const c=g[l];c instanceof e.ah?(s(c.layers,this.zoom,d),e.cQ({bucket:c,glyphMap:B,glyphPositions:U.positions,imageMap:O,imagePositions:q.iconPositions,showCollisionBoxes:this.showCollisionBoxes,canonical:this.tileID.canonical,subdivisionGranularity:y.subdivisionGranularity})):c.hasDependencies&&(c instanceof e.cR||c instanceof e.cS||c instanceof e.cT)&&(s(c.layers,this.zoom,d),c.addFeatures(y,this.tileID.canonical,q.patternPositions,G))}return this.status="done",{buckets:Object.values(g).filter((e=>!e.isEmpty())),featureIndex:_,collisionBoxArray:this.collisionBoxArray,glyphAtlasImage:U.image,imageAtlas:q,dashPositions:G,glyphMap:this.returnDependencies?B:null,iconMap:this.returnDependencies?O:null,glyphPositions:this.returnDependencies?U.positions:null}}))}}function s(s,l,c){const d=new e.H(l);for(const e of s)e.recalculate(d,c)}class n{constructor(e,s,l,c,d){this.type=e,this.properties=l||{},this.extent=d,this.pointsArray=s,this.id=c}loadGeometry(){return this.pointsArray.map((s=>s.map((s=>new e.P(s.x,s.y)))))}}class r{constructor(e,s,l){this.version=2,this._myFeatures=e,this.name=s,this.length=e.length,this.extent=l}feature(e){return this._myFeatures[e]}}class a{constructor(){this.layers={}}addLayer(e){this.layers[e.name]=e}}function l(s){let l=e.cU(s);return 0===l.byteOffset&&l.byteLength===l.buffer.byteLength||(l=new Uint8Array(l)),{vectorTile:s,rawData:l.buffer}}function c(s,l,c){const{extent:d}=s,p=Math.pow(2,c.z-l.z),f=(c.x-l.x*p)*d,m=(c.y-l.y*p)*d,_=[];for(let l=0;l0&&y.addLayer(p)}const T=l(y);return this.overzoomedTileResultCache.set(_,T),T}reloadTile(s){return e._(this,void 0,void 0,(function*(){const l=s.uid;if(!this.loaded||!this.loaded[l])throw new Error("Should not be trying to reload a tile that was never loaded or has been removed");const c=this.loaded[l];if(c.showCollisionBoxes=s.showCollisionBoxes,"parsing"===c.status){const d=yield c.parse(c.vectorTile,this.layerIndex,this.availableImages,this.actor,s.subdivisionGranularity);let p;if(this.fetching[l]){const{rawTileData:c,cacheControl:f,resourceTiming:m}=this.fetching[l];delete this.fetching[l],p=e.e({rawTileData:c.slice(0),encoding:s.encoding},d,f,m)}else p=d;return p}if("done"===c.status&&c.vectorTile)return c.parse(c.vectorTile,this.layerIndex,this.availableImages,this.actor,s.subdivisionGranularity)}))}abortTile(s){return e._(this,void 0,void 0,(function*(){const e=this.loading,l=s.uid;e&&e[l]&&e[l].abort&&(e[l].abort.abort(),delete e[l])}))}removeTile(s){return e._(this,void 0,void 0,(function*(){this.loaded&&this.loaded[s.uid]&&delete this.loaded[s.uid]}))}}class u{constructor(){this.loaded={}}loadTile(s){return e._(this,void 0,void 0,(function*(){const{uid:l,encoding:c,rawImageData:d,redFactor:p,greenFactor:f,blueFactor:m,baseShift:_}=s,g=d.width+2,y=d.height+2,b=e.b(d)?new e.R({width:g,height:y},yield e.c$(d,-1,-1,g,y)):d,T=new e.d0(l,b,c,p,f,m,_);return this.loaded=this.loaded||{},this.loaded[l]=T,T}))}removeTile(e){const s=this.loaded,l=e.uid;s&&s[l]&&delete s[l]}}var d,p,f=function(){if(p)return d;function e(e,l){if(0!==e.length){s(e[0],l);for(var c=1;c=Math.abs(m)?l-_+m:m-_+l,l=_}l+c>=0!=!!s&&e.reverse()}return p=1,d=function s(l,c){var d,p=l&&l.type;if("FeatureCollection"===p)for(d=0;de},g=Math.fround||(y=new Float32Array(1),e=>(y[0]=+e,y[0]));var y;class x{constructor(e){this.options=Object.assign(Object.create(_),e),this.trees=new Array(this.options.maxZoom+1),this.stride=this.options.reduce?7:6,this.clusterProps=[]}load(e){const{log:s,minZoom:l,maxZoom:c}=this.options;s&&console.time("total time");const d=`prepare ${e.length} points`;s&&console.time(d),this.points=e;const p=[];for(let s=0;s=l;e--){const l=+Date.now();f=this.trees[e]=this._createTree(this._cluster(f,e)),s&&console.log("z%d: %d clusters in %dms",e,f.numItems,+Date.now()-l)}return s&&console.timeEnd("total time"),this}getClusters(e,s){let l=((e[0]+180)%360+360)%360-180;const c=Math.max(-90,Math.min(90,e[1]));let d=180===e[2]?180:((e[2]+180)%360+360)%360-180;const p=Math.max(-90,Math.min(90,e[3]));if(e[2]-e[0]>=360)l=-180,d=180;else if(l>d){const e=this.getClusters([l,c,180,p],s),f=this.getClusters([-180,c,d,p],s);return e.concat(f)}const f=this.trees[this._limitZoom(s)],m=f.range(P(l),S(p),P(d),S(c)),_=f.data,g=[];for(const e of m){const s=this.stride*e;g.push(_[s+5]>1?b(_,s,this.clusterProps):this.points[_[s+3]])}return g}getChildren(e){const s=this._getOriginId(e),l=this._getOriginZoom(e),c="No cluster with the specified id.",d=this.trees[l];if(!d)throw new Error(c);const p=d.data;if(s*this.stride>=p.length)throw new Error(c);const f=this.options.radius/(this.options.extent*Math.pow(2,l-1)),m=d.within(p[s*this.stride],p[s*this.stride+1],f),_=[];for(const s of m){const l=s*this.stride;p[l+4]===e&&_.push(p[l+5]>1?b(p,l,this.clusterProps):this.points[p[l+3]])}if(0===_.length)throw new Error(c);return _}getLeaves(e,s,l){const c=[];return this._appendLeaves(c,e,s=s||10,l=l||0,0),c}getTile(e,s,l){const c=this.trees[this._limitZoom(e)],d=Math.pow(2,e),{extent:p,radius:f}=this.options,m=f/p,_=(l-m)/d,g=(l+1+m)/d,y={features:[]};return this._addTileFeatures(c.range((s-m)/d,_,(s+1+m)/d,g),c.data,s,l,d,y),0===s&&this._addTileFeatures(c.range(1-m/d,_,1,g),c.data,d,l,d,y),s===d-1&&this._addTileFeatures(c.range(0,_,m/d,g),c.data,-1,l,d,y),y.features.length?y:null}getClusterExpansionZoom(e){let s=this._getOriginZoom(e)-1;for(;s<=this.options.maxZoom;){const l=this.getChildren(e);if(s++,1!==l.length)break;e=l[0].properties.cluster_id}return s}_appendLeaves(e,s,l,c,d){const p=this.getChildren(s);for(const s of p){const p=s.properties;if(p&&p.cluster?d+p.point_count<=c?d+=p.point_count:d=this._appendLeaves(e,p.cluster_id,l,c,d):d1;let _,g,y;if(m)_=T(s,e,this.clusterProps),g=s[e],y=s[e+1];else{const l=this.points[s[e+3]];_=l.properties;const[c,d]=l.geometry.coordinates;g=P(c),y=S(d)}const b={type:1,geometry:[[Math.round(this.options.extent*(g*d-l)),Math.round(this.options.extent*(y*d-c))]],tags:_};let I;I=m||this.options.generateId?s[e+3]:this.points[s[e+3]].id,void 0!==I&&(b.id=I),p.features.push(b)}}_limitZoom(e){return Math.max(this.options.minZoom,Math.min(Math.floor(+e),this.options.maxZoom+1))}_cluster(e,s){const{radius:l,extent:c,reduce:d,minPoints:p}=this.options,f=l/(c*Math.pow(2,s)),m=e.data,_=[],g=this.stride;for(let l=0;ls&&(P+=m[l+5])}if(P>T&&P>=p){let e,p=c*T,f=y*T,S=-1;const I=(l/g<<5)+(s+1)+this.points.length;for(const c of b){const _=c*g;if(m[_+2]<=s)continue;m[_+2]=s;const y=m[_+5];p+=m[_]*y,f+=m[_+1]*y,m[_+4]=I,d&&(e||(e=this._map(m,l,!0),S=this.clusterProps.length,this.clusterProps.push(e)),d(e,this._map(m,_)))}m[l+4]=I,_.push(p/P,f/P,1/0,I,-1,P),d&&_.push(S)}else{for(let e=0;e1)for(const e of b){const l=e*g;if(!(m[l+2]<=s)){m[l+2]=s;for(let e=0;e>5}_getOriginZoom(e){return(e-this.points.length)%32}_map(e,s,l){if(e[s+5]>1){const c=this.clusterProps[e[s+6]];return l?Object.assign({},c):c}const c=this.points[e[s+3]].properties,d=this.options.map(c);return l&&d===c?Object.assign({},d):d}}function b(e,s,l){return{type:"Feature",id:e[s+3],properties:T(e,s,l),geometry:{type:"Point",coordinates:[(c=e[s],360*(c-.5)),I(e[s+1])]}};var c}function T(e,s,l){const c=e[s+5],d=c>=1e4?`${Math.round(c/1e3)}k`:c>=1e3?Math.round(c/100)/10+"k":c,p=e[s+6],f=-1===p?{}:Object.assign({},l[p]);return Object.assign(f,{cluster:!0,cluster_id:e[s+3],point_count:c,point_count_abbreviated:d})}function P(e){return e/360+.5}function S(e){const s=Math.sin(e*Math.PI/180),l=.5-.25*Math.log((1+s)/(1-s))/Math.PI;return l<0?0:l>1?1:l}function I(e){const s=(180-360*e)*Math.PI/180;return 360*Math.atan(Math.exp(s))/Math.PI-90}function C(e,s,l,c){let d=c;const p=s+(l-s>>1);let f,m=l-s;const _=e[s],g=e[s+1],y=e[l],b=e[l+1];for(let c=s+3;cd)f=c,d=s;else if(s===d){const e=Math.abs(c-p);ec&&(f-s>3&&C(e,s,f,c),e[f+2]=d,l-f>3&&C(e,f,l,c))}function R(e,s,l,c,d,p){let f=d-l,m=p-c;if(0!==f||0!==m){const _=((e-l)*f+(s-c)*m)/(f*f+m*m);_>1?(l=d,c=p):_>0&&(l+=f*_,c+=m*_)}return f=e-l,m=s-c,f*f+m*m}function L(e,s,l,c){const d={id:null==e?null:e,type:s,geometry:l,tags:c,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0};if("Point"===s||"MultiPoint"===s||"LineString"===s)F(d,l);else if("Polygon"===s)F(d,l[0]);else if("MultiLineString"===s)for(const e of l)F(d,e);else if("MultiPolygon"===s)for(const e of l)F(d,e[0]);return d}function F(e,s){for(let l=0;l0&&(f+=c?(d*_-m*p)/2:Math.sqrt(Math.pow(m-d,2)+Math.pow(_-p,2))),d=m,p=_}const m=s.length-3;s[2]=1,C(s,0,m,l),s[m+2]=1,s.size=Math.abs(f),s.start=0,s.end=s.size}function G(e,s,l,c){for(let d=0;d1?1:l}function Z(e,s,l,c,d,p,f,m){if(c/=s,p>=(l/=s)&&f=c)return null;const _=[];for(const s of e){const e=s.geometry;let p=s.type;const f=0===d?s.minX:s.minY,g=0===d?s.maxX:s.maxY;if(f>=l&&g=c)continue;let y=[];if("Point"===p||"MultiPoint"===p)W(e,y,l,c,d);else if("LineString"===p)J(e,y,l,c,d,!1,m.lineMetrics);else if("MultiLineString"===p)se(e,y,l,c,d,!1);else if("Polygon"===p)se(e,y,l,c,d,!0);else if("MultiPolygon"===p)for(const s of e){const e=[];se(s,e,l,c,d,!0),e.length&&y.push(e)}if(y.length){if(m.lineMetrics&&"LineString"===p){for(const e of y)_.push(L(s.id,p,e,s.tags));continue}"LineString"!==p&&"MultiLineString"!==p||(1===y.length?(p="LineString",y=y[0]):p="MultiLineString"),"Point"!==p&&"MultiPoint"!==p||(p=3===y.length?"Point":"MultiPoint"),_.push(L(s.id,p,y,s.tags))}}return _.length?_:null}function W(e,s,l,c,d){for(let p=0;p=l&&f<=c&&oe(s,e[p],e[p+1],e[p+2])}}function J(e,s,l,c,d,p,f){let m=re(e);const _=0===d?le:ce;let g,y,b=e.start;for(let T=0;Tl&&(y=_(m,P,S,C,R,l),f&&(m.start=b+g*y)):L>c?F=l&&(y=_(m,P,S,C,R,l),B=!0),F>c&&L<=c&&(y=_(m,P,S,C,R,c),B=!0),!p&&B&&(f&&(m.end=b+g*y),s.push(m),m=re(e)),f&&(b+=g)}let T=e.length-3;const P=e[T],S=e[T+1],I=0===d?P:S;I>=l&&I<=c&&oe(m,P,S,e[T+2]),T=m.length-3,p&&T>=3&&(m[T]!==m[0]||m[T+1]!==m[1])&&oe(m,m[0],m[1],m[2]),m.length&&s.push(m)}function re(e){const s=[];return s.size=e.size,s.start=e.start,s.end=e.end,s}function se(e,s,l,c,d,p){for(const f of e)J(f,s,l,c,d,p,!1)}function oe(e,s,l,c){e.push(s,l,c)}function le(e,s,l,c,d,p){const f=(p-s)/(c-s);return oe(e,p,l+(d-l)*f,1),f}function ce(e,s,l,c,d,p){const f=(p-l)/(d-l);return oe(e,s+(c-s)*f,p,1),f}function he(e,s){const l=[];for(let c=0;c0&&s.size<(d?f:c))return void(l.numPoints+=s.length/3);const m=[];for(let e=0;ef)&&(l.numSimplified++,m.push(s[e],s[e+1])),l.numPoints++;d&&function(e,s){let l=0;for(let s=0,c=e.length,d=c-2;s0===s)for(let s=0,l=e.length;s24)throw new Error("maxZoom should be in the 0-24 range");if(s.promoteId&&s.generateId)throw new Error("promoteId and generateId cannot be used together.");let c=function(e,s){const l=[];if("FeatureCollection"===e.type)for(let c=0;c1&&console.time("creation"),T=this.tiles[b]=me(e,s,l,c,_),this.tileCoords.push({z:s,x:l,y:c}),g)){g>1&&(console.log("tile z%d-%d-%d (features: %d, points: %d, simplified: %d)",s,l,c,T.numFeatures,T.numPoints,T.numSimplified),console.timeEnd("creation"));const e=`z${s}`;this.stats[e]=(this.stats[e]||0)+1,this.total++}if(T.source=e,null==d){if(s===_.indexMaxZoom||T.numPoints<=_.indexMaxPoints)continue}else{if(s===_.maxZoom||s===d)continue;if(null!=d){const e=d-s;if(l!==p>>e||c!==f>>e)continue}}if(T.source=null,0===e.length)continue;g>1&&console.time("clipping");const P=.5*_.buffer/_.extent,S=.5-P,I=.5+P,C=1+P;let R=null,L=null,F=null,B=null,O=Z(e,y,l-P,l+I,0,T.minX,T.maxX,_),j=Z(e,y,l+S,l+C,0,T.minX,T.maxX,_);e=null,O&&(R=Z(O,y,c-P,c+I,1,T.minY,T.maxY,_),L=Z(O,y,c+S,c+C,1,T.minY,T.maxY,_),O=null),j&&(F=Z(j,y,c-P,c+I,1,T.minY,T.maxY,_),B=Z(j,y,c+S,c+C,1,T.minY,T.maxY,_),j=null),g>1&&console.timeEnd("clipping"),m.push(R||[],s+1,2*l,2*c),m.push(L||[],s+1,2*l,2*c+1),m.push(F||[],s+1,2*l+1,2*c),m.push(B||[],s+1,2*l+1,2*c+1)}}getTile(e,s,l){e=+e,s=+s,l=+l;const c=this.options,{extent:d,debug:p}=c;if(e<0||e>24)return null;const f=1<1&&console.log("drilling down to z%d-%d-%d",e,s,l);let _,g=e,y=s,b=l;for(;!_&&g>0;)g--,y>>=1,b>>=1,_=this.tiles[ve(g,y,b)];return _&&_.source?(p>1&&(console.log("found parent tile z%d-%d-%d",g,y,b),console.time("drilling down")),this.splitTile(_.source,g,y,b,e,s,l),p>1&&console.timeEnd("drilling down"),this.tiles[m]?pe(this.tiles[m],d):null):null}}function ve(e,s,l){return 32*((1<`${e.key}: ${e.message}`)).join(", "));const d=s.features.filter((e=>c.value.evaluate({zoom:0},e)));return this._toFeatureCollection(d)}_toFeatureCollection(e){return{type:"FeatureCollection",features:e}}removeSource(s){return e._(this,void 0,void 0,(function*(){this._pendingRequest&&this._pendingRequest.abort()}))}getClusterExpansionZoom(e){return this._geoJSONIndex.getClusterExpansionZoom(e.clusterId)}getClusterChildren(e){return this._geoJSONIndex.getChildren(e.clusterId)}getClusterLeaves(e){return this._geoJSONIndex.getLeaves(e.clusterId,e.limit,e.offset)}}function be(s,l){return l.cluster?new x(function({superclusterOptions:s,clusterProperties:l}){if(!l||!s)return s;const c={},d={},p={accumulated:null,zoom:0},f={properties:null},m=Object.keys(l);for(const s of m){const[p,f]=l[s],m=e.d3(f),_=e.d3("string"==typeof p?[p,["accumulated"],["get",s]]:p);c[s]=m.value,d[s]=_.value}return s.map=e=>{f.properties=e;const s={};for(const e of m)s[e]=c[e].evaluate(p,f);return s},s.reduce=(e,s)=>{f.properties=s;for(const s of m)p.accumulated=e[s],e[s]=d[s].evaluate(p,f)},s}(l)).load(s.features):function(e,s){return new V(e,s)}(s,l.geojsonVtOptions)}class te{constructor(s){this.self=s,this.actor=new e.L(s),this.layerIndexes={},this.availableImages={},this.workerSources={},this.demWorkerSources={},this.externalWorkerSourceTypes={},this.globalStates=new Map,this.self.registerWorkerSource=(e,s)=>{if(this.externalWorkerSourceTypes[e])throw new Error(`Worker source with name "${e}" already registered.`);this.externalWorkerSourceTypes[e]=s},this.self.addProtocol=e.cJ,this.self.removeProtocol=e.cK,this.self.registerRTLTextPlugin=s=>{e.d4.setMethods(s)},this.actor.registerMessageHandler("LDT",((e,s)=>this._getDEMWorkerSource(e,s.source).loadTile(s))),this.actor.registerMessageHandler("RDT",((s,l)=>e._(this,void 0,void 0,(function*(){this._getDEMWorkerSource(s,l.source).removeTile(l)})))),this.actor.registerMessageHandler("GCEZ",((s,l)=>e._(this,void 0,void 0,(function*(){return this._getWorkerSource(s,l.type,l.source).getClusterExpansionZoom(l)})))),this.actor.registerMessageHandler("GCC",((s,l)=>e._(this,void 0,void 0,(function*(){return this._getWorkerSource(s,l.type,l.source).getClusterChildren(l)})))),this.actor.registerMessageHandler("GCL",((s,l)=>e._(this,void 0,void 0,(function*(){return this._getWorkerSource(s,l.type,l.source).getClusterLeaves(l)})))),this.actor.registerMessageHandler("LD",((e,s)=>this._getWorkerSource(e,s.type,s.source).loadData(s))),this.actor.registerMessageHandler("GD",((e,s)=>this._getWorkerSource(e,s.type,s.source).getData())),this.actor.registerMessageHandler("LT",((e,s)=>this._getWorkerSource(e,s.type,s.source).loadTile(s))),this.actor.registerMessageHandler("RT",((e,s)=>this._getWorkerSource(e,s.type,s.source).reloadTile(s))),this.actor.registerMessageHandler("AT",((e,s)=>this._getWorkerSource(e,s.type,s.source).abortTile(s))),this.actor.registerMessageHandler("RMT",((e,s)=>this._getWorkerSource(e,s.type,s.source).removeTile(s))),this.actor.registerMessageHandler("RS",((s,l)=>e._(this,void 0,void 0,(function*(){if(!this.workerSources[s]||!this.workerSources[s][l.type]||!this.workerSources[s][l.type][l.source])return;const e=this.workerSources[s][l.type][l.source];delete this.workerSources[s][l.type][l.source],void 0!==e.removeSource&&e.removeSource(l)})))),this.actor.registerMessageHandler("RM",(s=>e._(this,void 0,void 0,(function*(){delete this.layerIndexes[s],delete this.availableImages[s],delete this.workerSources[s],delete this.demWorkerSources[s],this.globalStates.delete(s)})))),this.actor.registerMessageHandler("SR",((s,l)=>e._(this,void 0,void 0,(function*(){this.referrer=l})))),this.actor.registerMessageHandler("SRPS",((e,s)=>this._syncRTLPluginState(e,s))),this.actor.registerMessageHandler("IS",((s,l)=>e._(this,void 0,void 0,(function*(){this.self.importScripts(l)})))),this.actor.registerMessageHandler("SI",((e,s)=>this._setImages(e,s))),this.actor.registerMessageHandler("UL",((s,l)=>e._(this,void 0,void 0,(function*(){this._getLayerIndex(s).update(l.layers,l.removedIds,this._getGlobalState(s))})))),this.actor.registerMessageHandler("UGS",((s,l)=>e._(this,void 0,void 0,(function*(){const e=this._getGlobalState(s);for(const s in l)e[s]=l[s]})))),this.actor.registerMessageHandler("SL",((s,l)=>e._(this,void 0,void 0,(function*(){this._getLayerIndex(s).replace(l,this._getGlobalState(s))}))))}_getGlobalState(e){let s=this.globalStates.get(e);return s||(s={},this.globalStates.set(e,s)),s}_setImages(s,l){return e._(this,void 0,void 0,(function*(){this.availableImages[s]=l;for(const e in this.workerSources[s]){const c=this.workerSources[s][e];for(const e in c)c[e].availableImages=l}}))}_syncRTLPluginState(s,l){return e._(this,void 0,void 0,(function*(){return yield e.d4.syncState(l,this.self.importScripts)}))}_getAvailableImages(e){let s=this.availableImages[e];return s||(s=[]),s}_getLayerIndex(e){let s=this.layerIndexes[e];return s||(s=this.layerIndexes[e]=new t),s}_getWorkerSource(e,s,l){if(this.workerSources[e]||(this.workerSources[e]={}),this.workerSources[e][s]||(this.workerSources[e][s]={}),!this.workerSources[e][s][l]){const c={sendAsync:(s,l)=>(s.targetMapId=e,this.actor.sendAsync(s,l))};switch(s){case"vector":this.workerSources[e][s][l]=new h(c,this._getLayerIndex(e),this._getAvailableImages(e));break;case"geojson":this.workerSources[e][s][l]=new Q(c,this._getLayerIndex(e),this._getAvailableImages(e));break;default:this.workerSources[e][s][l]=new this.externalWorkerSourceTypes[s](c,this._getLayerIndex(e),this._getAvailableImages(e))}}return this.workerSources[e][s][l]}_getDEMWorkerSource(e,s){return this.demWorkerSources[e]||(this.demWorkerSources[e]={}),this.demWorkerSources[e][s]||(this.demWorkerSources[e][s]=new u),this.demWorkerSources[e][s]}}return e.i(self)&&(self.worker=new te(self)),te}));c("index",["exports","./shared"],(function(s,l){var c="5.16.0";function d(){var e=new l.A(4);return l.A!=Float32Array&&(e[1]=0,e[2]=0),e[0]=1,e[3]=1,e}let p,f,m;const _={frame(e,s,c){const d=requestAnimationFrame((e=>{p(),s(e)})),{unsubscribe:p}=l.s(e.signal,"abort",(()=>{p(),cancelAnimationFrame(d),c(new l.a(e.signal.reason))}),!1)},frameAsync(e){return new Promise(((s,l)=>{this.frame(e,s,l)}))},getImageData(e,s=0){return this.getImageCanvasContext(e).getImageData(-s,-s,e.width+2*s,e.height+2*s)},getImageCanvasContext(e){const s=window.document.createElement("canvas"),l=s.getContext("2d",{willReadFrequently:!0});if(!l)throw new Error("failed to create canvas 2d context");return s.width=e.width,s.height=e.height,l.drawImage(e,0,0,e.width,e.height),l},resolveURL:e=>(p||(p=document.createElement("a")),p.href=e,p.href),hardwareConcurrency:"undefined"!=typeof navigator&&navigator.hardwareConcurrency||4,get prefersReducedMotion(){return void 0!==m?m:!!matchMedia&&(null==f&&(f=matchMedia("(prefers-reduced-motion: reduce)")),f.matches)},set prefersReducedMotion(e){m=e}},g=new class{constructor(){this._realTime="undefined"!=typeof performance&&performance&&performance.now?performance.now.bind(performance):Date.now.bind(Date),this._frozenAt=null}getCurrentTime(){return null!==this._frozenAt?this._frozenAt:this._realTime()}setNow(e){this._frozenAt=e}restoreNow(){this._frozenAt=null}isFrozen(){return null!==this._frozenAt}};function y(){return g.getCurrentTime()}class h{static testProp(e){if(!h.docStyle)return e[0];for(let s=0;s{window.removeEventListener("click",h.suppressClickInternal,!0)}),0)}static getScale(e){const s=e.getBoundingClientRect();return{x:s.width/e.offsetWidth||1,y:s.height/e.offsetHeight||1,boundingClientRect:s}}static getPoint(e,s,c){const d=s.boundingClientRect;return new l.P((c.clientX-d.left)/s.x-e.clientLeft,(c.clientY-d.top)/s.y-e.clientTop)}static mousePos(e,s){const l=h.getScale(e);return h.getPoint(e,l,s)}static touchPos(e,s){const l=[],c=h.getScale(e);for(let d=0;d{T&&C(T),T=null,I=!0},P.onerror=()=>{S=!0,T=null},P.src="data:image/webp;base64,UklGRh4AAABXRUJQVlA4TBEAAAAvAQAAAAfQ//73v/+BiOh/AAA="),function(s){let c,d,p,f;s.resetRequestQueue=()=>{c=[],d=0,p=0,f={}},s.addThrottleControl=e=>{const s=p++;return f[s]=e,s},s.removeThrottleControl=e=>{delete f[e],_()},s.getImage=(e,s,d=!0)=>new Promise(((p,f)=>{b.supported&&(e.headers||(e.headers={}),e.headers.accept="image/webp,*/*"),l.e(e,{type:"image"}),c.push({abortController:s,requestParameters:e,supportImageRefresh:d,state:"queued",onError:e=>{f(e)},onSuccess:e=>{p(e)}}),_()}));const m=s=>l._(this||e,void 0,void 0,(function*(){s.state="running";const{requestParameters:e,supportImageRefresh:c,onError:p,onSuccess:f,abortController:m}=s,y=!1===c&&!l.i(self)&&!l.g(e.url)&&(!e.headers||Object.keys(e.headers).reduce(((e,s)=>e&&"accept"===s),!0));d++;const b=y?g(e,m):l.m(e,m);try{const e=yield b;delete s.abortController,s.state="completed",e.data instanceof HTMLImageElement||l.b(e.data)?f(e):e.data&&f({data:yield(T=e.data,"function"==typeof createImageBitmap?l.f(T):l.h(T)),cacheControl:e.cacheControl,expires:e.expires})}catch(e){delete s.abortController,p(e)}finally{d--,_()}var T})),_=()=>{const e=(()=>{for(const e of Object.keys(f))if(f[e]())return!0;return!1})()?l.c.MAX_PARALLEL_IMAGE_REQUESTS_PER_FRAME:l.c.MAX_PARALLEL_IMAGE_REQUESTS;for(let s=d;s0;s++){const e=c.shift();e.abortController.signal.aborted?s--:m(e)}},g=(e,s)=>new Promise(((c,d)=>{const p=new Image,f=e.url,m=e.credentials;m&&"include"===m?p.crossOrigin="use-credentials":(m&&"same-origin"===m||!l.d(f))&&(p.crossOrigin="anonymous"),s.signal.addEventListener("abort",(()=>{p.src="",d(new l.a(s.signal.reason))})),p.fetchPriority="high",p.onload=()=>{p.onerror=p.onload=null,c({data:p})},p.onerror=()=>{p.onerror=p.onload=null,s.signal.aborted||d(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."))},p.src=f}))}(R||(R={})),R.resetRequestQueue();class v{constructor(e){this._transformRequestFn=null!=e?e:null}transformRequest(e,s){return this._transformRequestFn&&this._transformRequestFn(e,s)||{url:e}}setTransformRequest(e){this._transformRequestFn=e}}function L(e){const s=[];if("string"==typeof e)s.push({id:"default",url:e});else if(e&&e.length>0){const l=[];for(const{id:c,url:d}of e){const e=`${c}${d}`;-1===l.indexOf(e)&&(l.push(e),s.push({id:c,url:d}))}}return s}function F(e,s,l){try{const c=new URL(e);return c.pathname+=`${s}${l}`,c.toString()}catch(s){throw new Error(`Invalid sprite URL "${e}", must be absolute. Modify style specification directly or use TransformStyleFunction to correct the issue dynamically`)}}function B(e){const{userImage:s}=e;return!!(s&&s.render&&s.render())&&(e.data.replace(new Uint8Array(s.data.buffer)),!0)}class w extends l.E{constructor(){super(),this.images={},this.updatedImages={},this.callbackDispatchedThisFrame={},this.loaded=!1,this.requestors=[],this.patterns={},this.atlasImage=new l.R({width:1,height:1}),this.dirty=!0}destroy(){this.atlasTexture&&(this.atlasTexture.destroy(),this.atlasTexture=null);for(const e of Object.keys(this.images))this.removeImage(e);this.patterns={},this.atlasImage=new l.R({width:1,height:1}),this.dirty=!0}isLoaded(){return this.loaded}setLoaded(e){if(this.loaded!==e&&(this.loaded=e,e)){for(const{ids:e,promiseResolve:s}of this.requestors)s(this._getImagesForIds(e));this.requestors=[]}}getImage(e){const s=this.images[e];if(s&&!s.data&&s.spriteData){const e=s.spriteData;s.data=new l.R({width:e.width,height:e.height},e.context.getImageData(e.x,e.y,e.width,e.height).data),s.spriteData=null}return s}addImage(e,s){if(this.images[e])throw new Error(`Image id ${e} already exist, use updateImage instead`);this._validate(e,s)&&(this.images[e]=s)}_validate(e,s){let c=!0;const d=s.data||s.spriteData;return this._validateStretch(s.stretchX,d&&d.width)||(this.fire(new l.k(new Error(`Image "${e}" has invalid "stretchX" value`))),c=!1),this._validateStretch(s.stretchY,d&&d.height)||(this.fire(new l.k(new Error(`Image "${e}" has invalid "stretchY" value`))),c=!1),this._validateContent(s.content,s)||(this.fire(new l.k(new Error(`Image "${e}" has invalid "content" value`))),c=!1),c}_validateStretch(e,s){if(!e)return!0;let l=0;for(const c of e){if(c[0]{let c=!0;if(!this.isLoaded())for(const s of e)this.images[s]||(c=!1);this.isLoaded()||c?s(this._getImagesForIds(e)):this.requestors.push({ids:e,promiseResolve:s})}))}_getImagesForIds(e){const s={};for(const c of e){let e=this.getImage(c);e||(this.fire(new l.l("styleimagemissing",{id:c})),e=this.getImage(c)),e?s[c]={data:e.data.clone(),pixelRatio:e.pixelRatio,sdf:e.sdf,version:e.version,stretchX:e.stretchX,stretchY:e.stretchY,content:e.content,textFitWidth:e.textFitWidth,textFitHeight:e.textFitHeight,hasRenderCallback:Boolean(e.userImage&&e.userImage.render)}:l.w(`Image "${c}" could not be loaded. Please make sure you have added the image with map.addImage() or a "sprite" property in your style. You can provide missing images by listening for the "styleimagemissing" map event.`)}return s}getPixelSize(){const{width:e,height:s}=this.atlasImage;return{width:e,height:s}}getPattern(e){const s=this.patterns[e],c=this.getImage(e);if(!c)return null;if(s&&s.position.version===c.version)return s.position;if(s)s.position.version=c.version;else{const s={w:c.data.width+2,h:c.data.height+2,x:0,y:0},d=new l.I(s,c);this.patterns[e]={bin:s,position:d}}return this._updatePatternAtlas(),this.patterns[e].position}bind(e){const s=e.gl;this.atlasTexture?this.dirty&&(this.atlasTexture.update(this.atlasImage),this.dirty=!1):this.atlasTexture=new l.T(e,this.atlasImage,s.RGBA),this.atlasTexture.bind(s.LINEAR,s.CLAMP_TO_EDGE)}_updatePatternAtlas(){const e=[];for(const s in this.patterns)e.push(this.patterns[s].bin);const{w:s,h:c}=l.p(e),d=this.atlasImage;d.resize({width:s||1,height:c||1});for(const e in this.patterns){const{bin:s}=this.patterns[e],c=s.x+1,p=s.y+1,f=this.getImage(e).data,m=f.width,_=f.height;l.R.copy(f,d,{x:0,y:0},{x:c,y:p},{width:m,height:_}),l.R.copy(f,d,{x:0,y:_-1},{x:c,y:p-1},{width:m,height:1}),l.R.copy(f,d,{x:0,y:0},{x:c,y:p+_},{width:m,height:1}),l.R.copy(f,d,{x:m-1,y:0},{x:c-1,y:p},{width:1,height:_}),l.R.copy(f,d,{x:0,y:0},{x:c+m,y:p},{width:1,height:_})}this.dirty=!0}beginFrame(){this.callbackDispatchedThisFrame={}}dispatchRenderCallbacks(e){for(const s of e){if(this.callbackDispatchedThisFrame[s])continue;this.callbackDispatchedThisFrame[s]=!0;const e=this.getImage(s);e||l.w(`Image with ID: "${s}" was not found`),B(e)&&this.updateImage(s,e)}}cloneImages(){const e={};for(const s in this.images){const l=this.images[s];e[s]=Object.assign(Object.assign({},l),{data:l.data?l.data.clone():null})}return e}}const O=1e20;function j(e,s,l,c,d,p,f,m,_){for(let g=s;g-1);_++,p[_]=m,f[_]=g,f[_+1]=O}for(let m=0,_=0;m/[-\w]+/.test(e)?e:`'${CSS.escape(e)}'`)).join(",");return new M.TinySDF({fontSize:48,buffer:6,radius:16,cutoff:.25,fontFamily:l,fontWeight:this._fontWeight(s[0]),fontStyle:this._fontStyle(s[0]),lang:this.lang})}_fontStyle(e){return/italic/i.test(e)?"italic":/oblique/i.test(e)?"oblique":"normal"}_fontWeight(e){const s={thin:100,hairline:100,"extra light":200,"ultra light":200,light:300,normal:400,regular:400,medium:500,semibold:600,demibold:600,bold:700,"extra bold":800,"ultra bold":800,black:900,heavy:900,"extra black":950,"ultra black":950};let l;for(const[c,d]of Object.entries(s))new RegExp(`\\b${c}\\b`,"i").test(e)&&(l=`${d}`);return l}destroy(){for(const e in this.entries){const s=this.entries[e];s.tinySDF&&(s.tinySDF=null),s.ideographTinySDF&&(s.ideographTinySDF=null),s.glyphs={},s.requests={},s.ranges={}}this.entries={}}}M.loadGlyphRange=function(s,c,d,p){return l._(this||e,void 0,void 0,(function*(){const e=256*c,f=e+255,m=p.transformRequest(d.replace("{fontstack}",s).replace("{range}",`${e}-${f}`),"Glyphs"),_=yield l.n(m,new AbortController);if(!_||!_.data)throw new Error(`Could not load glyph range. range: ${c}, ${e}-${f}`);const g={};for(const e of l.o(_.data))g[e.id]=e;return g}))},M.TinySDF=class{constructor({fontSize:e=24,buffer:s=3,radius:l=8,cutoff:c=.25,fontFamily:d="sans-serif",fontWeight:p="normal",fontStyle:f="normal",lang:m=null}={}){this.buffer=s,this.cutoff=c,this.radius=l,this.lang=m;const _=this.size=e+4*s,g=this._createCanvas(_),y=this.ctx=g.getContext("2d",{willReadFrequently:!0});y.font=`${f} ${p} ${e}px ${d}`,y.textBaseline="alphabetic",y.textAlign="left",y.fillStyle="black",this.gridOuter=new Float64Array(_*_),this.gridInner=new Float64Array(_*_),this.f=new Float64Array(_),this.z=new Float64Array(_+1),this.v=new Uint16Array(_)}_createCanvas(e){const s=document.createElement("canvas");return s.width=s.height=e,s}draw(e){const{width:s,actualBoundingBoxAscent:l,actualBoundingBoxDescent:c,actualBoundingBoxLeft:d,actualBoundingBoxRight:p}=this.ctx.measureText(e),f=Math.ceil(l),m=Math.max(0,Math.min(this.size-this.buffer,Math.ceil(p-d))),_=Math.min(this.size-this.buffer,f+Math.ceil(c)),g=m+2*this.buffer,y=_+2*this.buffer,b=Math.max(g*y,0),T=new Uint8ClampedArray(b),P={data:T,width:g,height:y,glyphWidth:m,glyphHeight:_,glyphTop:f,glyphLeft:0,glyphAdvance:s};if(0===m||0===_)return P;const{ctx:S,buffer:I,gridInner:C,gridOuter:R}=this;this.lang&&(S.lang=this.lang),S.clearRect(I,I,m,_),S.fillText(e,I,I+f);const L=S.getImageData(I,I,m,_);R.fill(O,0,b),C.fill(0,0,b);for(let e=0;e<_;e++)for(let s=0;s0?e*e:0,C[c]=e<0?e*e:0}}j(R,0,0,g,y,g,this.f,this.v,this.z),j(C,I,I,m,_,g,this.f,this.v,this.z);for(let e=0;e1&&(f=e[++p]);const _=Math.abs(m-f.left),g=Math.abs(m-f.right),y=Math.min(_,g);let b;const T=s/l*(c+1);if(f.isDash){const e=c-Math.abs(T);b=Math.sqrt(y*y+e*e)}else b=c-Math.sqrt(y*y+T*T);this.data[d+m]=Math.max(0,Math.min(255,b+128))}}}addRegularDash(e){for(let s=e.length-1;s>=0;--s){const l=e[s],c=e[s+1];l.zeroLength?e.splice(s,1):c&&c.isDash===l.isDash&&(c.left=l.left,e.splice(s,1))}const s=e[0],l=e[e.length-1];s.isDash===l.isDash&&(s.left=l.left-this.width,l.right=s.right+this.width);const c=this.width*this.nextRow;let d=0,p=e[d];for(let s=0;s1&&(p=e[++d]);const l=Math.abs(s-p.left),f=Math.abs(s-p.right),m=Math.min(l,f);this.data[c+s]=Math.max(0,Math.min(255,(p.isDash?m:-m)+128))}}addDash(e,s){const c=s?7:0,d=2*c+1;if(this.nextRow+d>this.height)return l.w("LineAtlas out of space"),null;let p=0;for(let s=0;s{e.terminate()})),this.workers=null)}isPreloaded(){return!!this.active[W]}numActive(){return Object.keys(this.active).length}}const J=Math.floor(_.hardwareConcurrency/2);let re,se;function oe(){return re||(re=new k),re}k.workerCount=l.K(globalThis)?Math.max(Math.min(J,3),1):1;class N{constructor(e,s){this.workerPool=e,this.actors=[],this.currentActor=0,this.id=s;const c=this.workerPool.acquire(s);for(let e=0;e{e.remove()})),this.actors=[],e&&this.workerPool.release(this.id)}registerMessageHandler(e,s){for(const l of this.actors)l.registerMessageHandler(e,s)}unregisterMessageHandler(e){for(const s of this.actors)s.unregisterMessageHandler(e)}}function le(){return se||(se=new N(oe(),l.M),se.registerMessageHandler("GR",((e,s,c)=>l.m(s,c)))),se}function ce(e,s){const c=l.N();return l.O(c,c,[1,1,0]),l.Q(c,c,[.5*e.width,.5*e.height,1]),e.calculatePosMatrix?l.S(c,c,e.calculatePosMatrix(s.toUnwrapped())):c}function he(e,s,l,c,d,p,f){var m;const _=function(e,s,l){if(e)for(const c of e){const e=s[c];if(e&&e.source===l&&"fill-extrusion"===e.type)return!0}else for(const e in s){const c=s[e];if(c.source===l&&"fill-extrusion"===c.type)return!0}return!1}(null!==(m=null==d?void 0:d.layers)&&void 0!==m?m:null,s,e.id),g=p.maxPitchScaleFactor(),y=e.tilesIn(c,g,_);y.sort(ue);const b=[];for(const c of y)b.push({wrappedTileID:c.tileID.wrapped().key,queryResults:c.tile.queryRenderedFeatures(s,l,e.getState(),c.queryGeometry,c.cameraQueryGeometry,c.scale,d,p,g,ce(p,c.tileID),f?(e,s)=>f(c.tileID,e,s):void 0)});return function(e,s){for(const l in e)for(const c of e[l])pe(c,s);return e}(function(e){const s={},l={};for(const c of e){const e=c.queryResults,d=c.wrappedTileID,p=l[d]=l[d]||{};for(const l in e){const c=e[l],d=p[l]=p[l]||{},f=s[l]=s[l]||[];for(const e of c)d[e.featureIndex]||(d[e.featureIndex]=!0,f.push(e))}}return s}(b),e)}function ue(e,s){const l=e.tileID,c=s.tileID;return l.overscaledZ-c.overscaledZ||l.canonical.y-c.canonical.y||l.wrap-c.wrap||l.canonical.x-c.canonical.x}function pe(e,s){const l=e.feature,c=s.getFeatureState(l.layer["source-layer"],l.id);l.source=l.layer.source,l.layer["source-layer"]&&(l.sourceLayer=l.layer["source-layer"]),l.state=c}function fe(s,c,d){return l._(this||e,void 0,void 0,(function*(){let e=s;if(s.url?e=(yield l.j(c.transformRequest(s.url,"Source"),d)).data:yield _.frameAsync(d),!e)return null;const p=l.U(l.e(e,s),["tiles","minzoom","maxzoom","attribution","bounds","scheme","tileSize","encoding"]);return"vector_layers"in e&&e.vector_layers&&(p.vectorLayerIds=e.vector_layers.map((e=>e.id))),p}))}class ${constructor(e,s){e&&(s?this.setSouthWest(e).setNorthEast(s):Array.isArray(e)&&(4===e.length?this.setSouthWest([e[0],e[1]]).setNorthEast([e[2],e[3]]):this.setSouthWest(e[0]).setNorthEast(e[1])))}setNorthEast(e){return this._ne=e instanceof l.V?new l.V(e.lng,e.lat):l.V.convert(e),this}setSouthWest(e){return this._sw=e instanceof l.V?new l.V(e.lng,e.lat):l.V.convert(e),this}extend(e){const s=this._sw,c=this._ne;let d,p;if(e instanceof l.V)d=e,p=e;else{if(!(e instanceof $))return Array.isArray(e)?4===e.length||e.every(Array.isArray)?this.extend($.convert(e)):this.extend(l.V.convert(e)):e&&("lng"in e||"lon"in e)&&"lat"in e?this.extend(l.V.convert(e)):this;if(d=e._sw,p=e._ne,!d||!p)return this}return s||c?(s.lng=Math.min(d.lng,s.lng),s.lat=Math.min(d.lat,s.lat),c.lng=Math.max(p.lng,c.lng),c.lat=Math.max(p.lat,c.lat)):(this._sw=new l.V(d.lng,d.lat),this._ne=new l.V(p.lng,p.lat)),this}getCenter(){return new l.V((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 l.V(this.getWest(),this.getNorth())}getSouthEast(){return new l.V(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(e){const{lng:s,lat:c}=l.V.convert(e);let d=this._sw.lng<=s&&s<=this._ne.lng;return this._sw.lng>this._ne.lng&&(d=this._sw.lng>=s&&s>=this._ne.lng),this._sw.lat<=c&&c<=this._ne.lat&&d}intersects(e){if(!((e=$.convert(e)).getNorth()>=this.getSouth()&&e.getSouth()<=this.getNorth()))return!1;const s=Math.abs(this.getEast()-this.getWest()),c=Math.abs(e.getEast()-e.getWest());if(s>=360||c>=360)return!0;const d=l.W(this.getWest(),-180,180),p=l.W(this.getEast(),-180,180),f=l.W(e.getWest(),-180,180),m=l.W(e.getEast(),-180,180),_=d>=p,g=f>=m;return!(!_||!g)||(_?m>=d||f<=p:g?p>=f||d<=m:f<=p&&m>=d)}static convert(e){return e instanceof $?e:e?new $(e):e}static fromLngLat(e,s=0){const c=360*s/40075017,d=c/Math.cos(Math.PI/180*e.lat);return new $(new l.V(e.lng-d,e.lat-c),new l.V(e.lng+d,e.lat+c))}adjustAntiMeridian(){const e=new l.V(this._sw.lng,this._sw.lat),s=new l.V(this._ne.lng,this._ne.lat);return new $(e,e.lng>s.lng?new l.V(s.lng+360,s.lat):s)}}class H{constructor(e,s,l){this.bounds=$.convert(this.validateBounds(e)),this.minzoom=s||0,this.maxzoom=l||24}validateBounds(e){return Array.isArray(e)&&4===e.length?[Math.max(-180,e[0]),Math.max(-90,e[1]),Math.min(180,e[2]),Math.min(90,e[3])]:[-180,-90,180,90]}contains(e){const s=Math.pow(2,e.z),c=Math.floor(l.Y(this.bounds.getWest())*s),d=Math.floor(l.X(this.bounds.getNorth())*s),p=Math.ceil(l.Y(this.bounds.getEast())*s),f=Math.ceil(l.X(this.bounds.getSouth())*s);return e.x>=c&&e.x=d&&e.y{this._options.tiles=e})),this}setUrl(e){return this.setSourceProperty((()=>{this.url=e,this._options.url=e})),this}onRemove(){this._tileJSONRequest&&(this._tileJSONRequest.abort(),this._tileJSONRequest=null)}serialize(){return l.e({},this._options)}loadTile(e){return l._(this,void 0,void 0,(function*(){const s=e.tileID.canonical.url(this.tiles,this.map.getPixelRatio(),this.scheme),l={request:this.map._requestManager.transformRequest(s,"Tile"),uid:e.uid,tileID:e.tileID,zoom:e.tileID.overscaledZ,tileSize:this.tileSize*e.tileID.overscaleFactor(),type:this.type,source:this.id,pixelRatio:this.map.getPixelRatio(),showCollisionBoxes:this.map.showCollisionBoxes,promoteId:this.promoteId,subdivisionGranularity:this.map.style.projection.subdivisionGranularity,encoding:this.encoding,overzoomParameters:this._getOverzoomParameters(e)};l.request.collectResourceTiming=this._collectResourceTiming;let c="RT";if(e.actor&&"expired"!==e.state){if("loading"===e.state)return new Promise(((s,l)=>{e.reloadPromise={resolve:s,reject:l}}))}else e.actor=this.dispatcher.getActor(),c="LT";e.abortController=new AbortController;try{const s=yield e.actor.sendAsync({type:c,data:l},e.abortController);if(delete e.abortController,e.aborted)return;this._afterTileLoadWorkerResponse(e,s)}catch(s){if(delete e.abortController,e.aborted)return;if(s&&404!==s.status)throw s;this._afterTileLoadWorkerResponse(e,null)}}))}_getOverzoomParameters(e){if(e.tileID.canonical.z<=this.maxzoom)return;if(void 0===this.map._zoomLevelsToOverscale)return;const s=e.tileID.scaledTo(this.maxzoom).canonical,l=s.url(this.tiles,this.map.getPixelRatio(),this.scheme);return{maxZoomTileID:s,overzoomRequest:this.map._requestManager.transformRequest(l,"Tile")}}_afterTileLoadWorkerResponse(e,s){if(s&&s.resourceTiming&&(e.resourceTiming=s.resourceTiming),s&&this.map._refreshExpiredTiles&&e.setExpiryData(s),e.loadVectorData(s,this.map.painter),e.reloadPromise){const s=e.reloadPromise;e.reloadPromise=null,this.loadTile(e).then(s.resolve).catch(s.reject)}}abortTile(e){return l._(this,void 0,void 0,(function*(){e.abortController&&(e.abortController.abort(),delete e.abortController),e.actor&&(yield e.actor.sendAsync({type:"AT",data:{uid:e.uid,type:this.type,source:this.id}}))}))}unloadTile(e){return l._(this,void 0,void 0,(function*(){e.unloadVectorData(),e.actor&&(yield e.actor.sendAsync({type:"RMT",data:{uid:e.uid,type:this.type,source:this.id}}))}))}hasTransition(){return!1}}class K extends l.E{constructor(e,s,c,d){super(),this.id=e,this.dispatcher=c,this.setEventedParent(d),this.type="raster",this.minzoom=0,this.maxzoom=22,this.roundZoom=!0,this.scheme="xyz",this.tileSize=512,this._loaded=!1,this._options=l.e({type:"raster"},s),l.e(this,l.U(s,["url","scheme","tileSize"]))}load(){return l._(this,arguments,void 0,(function*(e=!1){this._loaded=!1,this.fire(new l.l("dataloading",{dataType:"source"})),this._tileJSONRequest=new AbortController;try{const s=yield fe(this._options,this.map._requestManager,this._tileJSONRequest);this._tileJSONRequest=null,this._loaded=!0,s&&(l.e(this,s),s.bounds&&(this.tileBounds=new H(s.bounds,this.minzoom,this.maxzoom)),this.fire(new l.l("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new l.l("data",{dataType:"source",sourceDataType:"content",sourceDataChanged:e})))}catch(e){this._tileJSONRequest=null,this._loaded=!0,l.Z(e)||this.fire(new l.k(e))}}))}loaded(){return this._loaded}onAdd(e){this.map=e,this.load()}onRemove(){this._tileJSONRequest&&(this._tileJSONRequest.abort(),this._tileJSONRequest=null)}setSourceProperty(e){this._tileJSONRequest&&(this._tileJSONRequest.abort(),this._tileJSONRequest=null),e(),this.load(!0)}setTiles(e){return this.setSourceProperty((()=>{this._options.tiles=e})),this}setUrl(e){return this.setSourceProperty((()=>{this.url=e,this._options.url=e})),this}serialize(){return l.e({},this._options)}hasTile(e){return!this.tileBounds||this.tileBounds.contains(e.canonical)}loadTile(e){return l._(this,void 0,void 0,(function*(){const s=e.tileID.canonical.url(this.tiles,this.map.getPixelRatio(),this.scheme);e.abortController=new AbortController;try{const c=yield R.getImage(this.map._requestManager.transformRequest(s,"Tile"),e.abortController,this.map._refreshExpiredTiles);if(delete e.abortController,e.aborted)return void(e.state="unloaded");if(c&&c.data){this.map._refreshExpiredTiles&&(c.cacheControl||c.expires)&&e.setExpiryData({cacheControl:c.cacheControl,expires:c.expires});const s=this.map.painter.context,d=s.gl,p=c.data;e.texture=this.map.painter.getTileTexture(p.width),e.texture?e.texture.update(p,{useMipmap:!0}):(e.texture=new l.T(s,p,d.RGBA,{useMipmap:!0}),e.texture.bind(d.LINEAR,d.CLAMP_TO_EDGE,d.LINEAR_MIPMAP_NEAREST)),e.state="loaded"}}catch(s){if(delete e.abortController,e.aborted)e.state="unloaded";else if(s)throw e.state="errored",s}}))}abortTile(e){return l._(this,void 0,void 0,(function*(){e.abortController&&(e.abortController.abort(),delete e.abortController)}))}unloadTile(e){return l._(this,void 0,void 0,(function*(){e.texture&&this.map.painter.saveTileTexture(e.texture)}))}hasTransition(){return!1}}class Y extends K{constructor(e,s,c,d){super(e,s,c,d),this.type="raster-dem",this.maxzoom=22,this._options=l.e({type:"raster-dem"},s),this.encoding=s.encoding||"mapbox",this.redFactor=s.redFactor,this.greenFactor=s.greenFactor,this.blueFactor=s.blueFactor,this.baseShift=s.baseShift}loadTile(e){return l._(this,void 0,void 0,(function*(){const s=e.tileID.canonical.url(this.tiles,this.map.getPixelRatio(),this.scheme),c=this.map._requestManager.transformRequest(s,"Tile");e.neighboringTiles=this._getNeighboringTiles(e.tileID),e.abortController=new AbortController;try{const s=yield R.getImage(c,e.abortController,this.map._refreshExpiredTiles);if(delete e.abortController,e.aborted)return void(e.state="unloaded");if(s&&s.data){const c=s.data;this.map._refreshExpiredTiles&&(s.cacheControl||s.expires)&&e.setExpiryData({cacheControl:s.cacheControl,expires:s.expires});const d=l.b(c)&&l.$()?c:yield this.readImageNow(c),p={type:this.type,uid:e.uid,source:this.id,rawImageData:d,encoding:this.encoding,redFactor:this.redFactor,greenFactor:this.greenFactor,blueFactor:this.blueFactor,baseShift:this.baseShift};if(!e.actor||"expired"===e.state){e.actor=this.dispatcher.getActor();const s=yield e.actor.sendAsync({type:"LDT",data:p});e.dem=s,e.needsHillshadePrepare=!0,e.needsTerrainPrepare=!0,e.state="loaded"}}}catch(s){if(delete e.abortController,e.aborted)e.state="unloaded";else if(s)throw e.state="errored",s}}))}readImageNow(e){return l._(this,void 0,void 0,(function*(){if("undefined"!=typeof VideoFrame&&l.a0()){const s=e.width+2,c=e.height+2;try{return new l.R({width:s,height:c},yield l.a1(e,-1,-1,s,c))}catch(e){}}return _.getImageData(e,1)}))}_getNeighboringTiles(e){const s=e.canonical,c=Math.pow(2,s.z),d=(s.x-1+c)%c,p=0===s.x?e.wrap-1:e.wrap,f=(s.x+1+c)%c,m=s.x+1===c?e.wrap+1:e.wrap,_={};return _[new l.a2(e.overscaledZ,p,s.z,d,s.y).key]={backfilled:!1},_[new l.a2(e.overscaledZ,m,s.z,f,s.y).key]={backfilled:!1},s.y>0&&(_[new l.a2(e.overscaledZ,p,s.z,d,s.y-1).key]={backfilled:!1},_[new l.a2(e.overscaledZ,e.wrap,s.z,s.x,s.y-1).key]={backfilled:!1},_[new l.a2(e.overscaledZ,m,s.z,f,s.y-1).key]={backfilled:!1}),s.y+1e.coordinates)).flat(1/0):e.coordinates.flat(1/0)}function ge(e){const s=new $;let l;switch(e.type){case"FeatureCollection":l=e.features.map((e=>me(e.geometry))).flat(1/0);break;case"Feature":l=me(e.geometry);break;default:l=me(e)}if(0==l.length)return s;for(let e=0;e0&&l.e(m,{resourceTiming:f}),this.fire(new l.l("data",Object.assign(Object.assign({},m),{sourceDataType:"metadata"}))),this.fire(new l.l("data",Object.assign(Object.assign({},m),{sourceDataType:"content",shouldReloadTileOptions:p})))}catch(e){if(this._isUpdatingWorker=!1,this._removed)return void this.fire(new l.l("dataabort",{dataType:"source"}));this.fire(new l.k(e))}finally{this._hasPendingWorkerUpdate()&&this._updateWorkerData()}}))}_applyDiffToSource(e){if(!e)return;const s="string"==typeof this.promoteId?this.promoteId:void 0;if(!this._data.url&&!this._data.updateable){const e=l.a7(this._data.geojson,s);if(!e)throw new Error(`GeoJSONSource "${this.id}": GeoJSON data is not compatible with updateData`);this._data={updateable:e}}if(!this._data.updateable)return;const c=l.a8(this._data.updateable,e,s);return e.removeAll||this._options.cluster?void 0:c}_getShouldReloadTileOptions(e){if(e)return{affectedBounds:e.filter(Boolean).map((e=>ge(e)))}}shouldReloadTile(e,{affectedBounds:s}){if("loading"===e.state)return!0;if("unloaded"===e.state)return!1;const{buffer:c,extent:d}=this.workerOptions.geojsonVtOptions,p=function({x:e,y:s,z:c},d=0){const p=l.a3((e-d)/Math.pow(2,c)),f=l.a4((s+1+d)/Math.pow(2,c)),m=l.a3((e+1+d)/Math.pow(2,c)),_=l.a4((s-d)/Math.pow(2,c));return new $([p,f],[m,_])}(e.tileID.canonical,c/d);for(const e of s)if(p.intersects(e))return!0;return!1}loaded(){return!this._isUpdatingWorker&&!this._hasPendingWorkerUpdate()}loadTile(e){return l._(this,void 0,void 0,(function*(){const s=e.actor?"RT":"LT";e.actor=this.actor;const l={type:this.type,uid:e.uid,tileID:e.tileID,zoom:e.tileID.overscaledZ,maxZoom:this.maxzoom,tileSize:this.tileSize,source:this.id,pixelRatio:this.map.getPixelRatio(),showCollisionBoxes:this.map.showCollisionBoxes,promoteId:this.promoteId,subdivisionGranularity:this.map.style.projection.subdivisionGranularity};e.abortController=new AbortController;const c=yield this.actor.sendAsync({type:s,data:l},e.abortController);delete e.abortController,e.unloadVectorData(),e.aborted||e.loadVectorData(c,this.map.painter,"RT"===s)}))}abortTile(e){return l._(this,void 0,void 0,(function*(){e.abortController&&(e.abortController.abort(),delete e.abortController),e.aborted=!0}))}unloadTile(e){return l._(this,void 0,void 0,(function*(){e.unloadVectorData(),yield this.actor.sendAsync({type:"RMT",data:{uid:e.uid,type:this.type,source:this.id}})}))}onRemove(){this._removed=!0,this.actor.sendAsync({type:"RS",data:{type:this.type,source:this.id}})}serialize(){return l.e({},this._options,{type:this.type,data:this._data.updateable?{type:"FeatureCollection",features:Array.from(this._data.updateable.values())}:this._data.url||this._data.geojson})}hasTransition(){return!1}}class te extends l.E{constructor(e,s,l,c){super(),this.flippedWindingOrder=!1,this.id=e,this.dispatcher=l,this.coordinates=s.coordinates,this.type="image",this.minzoom=0,this.maxzoom=22,this.tileSize=512,this.tiles={},this._loaded=!1,this.setEventedParent(c),this.options=s}load(e){return l._(this,void 0,void 0,(function*(){this._loaded=!1,this.fire(new l.l("dataloading",{dataType:"source"})),this.url=this.options.url,this._request=new AbortController;try{const s=yield R.getImage(this.map._requestManager.transformRequest(this.url,"Image"),this._request);this._request=null,this._loaded=!0,s&&s.data&&(this.image=s.data,e&&(this.coordinates=e),this._finishLoading())}catch(e){this._request=null,this._loaded=!0,l.Z(e)||this.fire(new l.k(e))}}))}loaded(){return this._loaded}updateImage(e){return e.url?(this._request&&(this._request.abort(),this._request=null),this.options.url=e.url,this.load(e.coordinates).finally((()=>{this.texture=null})),this):this}_finishLoading(){this.map&&(this.setCoordinates(this.coordinates),this.fire(new l.l("data",{dataType:"source",sourceDataType:"metadata"})))}onAdd(e){this.map=e,this.load()}onRemove(){this._request&&(this._request.abort(),this._request=null)}setCoordinates(e){this.coordinates=e;const s=e.map(l.a9.fromLngLat);var c;return this.tileID=function(e){const s=l.aa.fromPoints(e),c=s.width(),d=s.height(),p=Math.max(c,d),f=Math.max(0,Math.floor(-Math.log(p)/Math.LN2)),m=Math.pow(2,f);return new l.ac(f,Math.floor((s.minX+s.maxX)/2*m),Math.floor((s.minY+s.maxY)/2*m))}(s),this.terrainTileRanges=this._getOverlappingTileRanges(s),this.minzoom=this.maxzoom=this.tileID.z,this.tileCoords=s.map((e=>this.tileID.getTilePoint(e)._round())),this.flippedWindingOrder=((c=this.tileCoords)[1].x-c[0].x)*(c[2].y-c[0].y)-(c[1].y-c[0].y)*(c[2].x-c[0].x)<0,this.fire(new l.l("data",{dataType:"source",sourceDataType:"content"})),this}prepare(){if(0===Object.keys(this.tiles).length||!this.image)return;const e=this.map.painter.context,s=e.gl;this.texture||(this.texture=new l.T(e,this.image,s.RGBA),this.texture.bind(s.LINEAR,s.CLAMP_TO_EDGE));let c=!1;for(const e in this.tiles){const s=this.tiles[e];"loaded"!==s.state&&(s.state="loaded",s.texture=this.texture,c=!0)}c&&this.fire(new l.l("data",{dataType:"source",sourceDataType:"idle",sourceId:this.id}))}loadTile(e){return l._(this,void 0,void 0,(function*(){this.tileID&&this.tileID.equals(e.tileID.canonical)?(this.tiles[String(e.tileID.wrap)]=e,e.buckets={}):e.state="errored"}))}serialize(){return{type:"image",url:this.options.url,coordinates:this.coordinates}}hasTransition(){return!1}_getOverlappingTileRanges(e){const{minX:s,minY:c,maxX:d,maxY:p}=l.aa.fromPoints(e),f={};for(let e=0;e<=l.ab;e++){const l=Math.pow(2,e),m=Math.floor(s*l),_=Math.floor(c*l),g=Math.floor(d*l),y=Math.floor(p*l),b=(m%l+l)%l,T=g%l,P=Math.floor(m/l),S=Math.floor(g/l);f[e]={minWrap:P,maxWrap:S,minTileXWrapped:b,maxTileXWrapped:T,minTileY:_,maxTileY:y}}return f}}class ie extends te{constructor(e,s,l,c){super(e,s,l,c),this.roundZoom=!0,this.type="video",this.options=s}load(){return l._(this,void 0,void 0,(function*(){this._loaded=!1;const e=this.options;this.urls=[];for(const s of e.urls)this.urls.push(this.map._requestManager.transformRequest(s,"Source").url);try{const e=yield l.ad(this.urls);if(this._loaded=!0,!e)return;this.video=e,this.video.loop=!0,this.video.addEventListener("playing",(()=>{this.map.triggerRepaint()})),this.map&&this.video.play(),this._finishLoading()}catch(e){this.fire(new l.k(e))}}))}pause(){this.video&&this.video.pause()}play(){this.video&&this.video.play()}seek(e){if(this.video){const s=this.video.seekable;es.end(0)?this.fire(new l.k(new l.ae(`sources.${this.id}`,null,`Playback for this video can be set only between the ${s.start(0)} and ${s.end(0)}-second mark.`))):this.video.currentTime=e}}getVideo(){return this.video}onAdd(e){this.map||(this.map=e,this.load(),this.video&&(this.video.play(),this.setCoordinates(this.coordinates)))}prepare(){if(0===Object.keys(this.tiles).length||this.video.readyState<2)return;const e=this.map.painter.context,s=e.gl;this.texture?this.video.paused||(this.texture.bind(s.LINEAR,s.CLAMP_TO_EDGE),s.texSubImage2D(s.TEXTURE_2D,0,0,0,s.RGBA,s.UNSIGNED_BYTE,this.video)):(this.texture=new l.T(e,this.video,s.RGBA),this.texture.bind(s.LINEAR,s.CLAMP_TO_EDGE));let c=!1;for(const e in this.tiles){const s=this.tiles[e];"loaded"!==s.state&&(s.state="loaded",s.texture=this.texture,c=!0)}c&&this.fire(new l.l("data",{dataType:"source",sourceDataType:"idle",sourceId:this.id}))}serialize(){return{type:"video",urls:this.urls,coordinates:this.coordinates}}hasTransition(){return this.video&&!this.video.paused}}class ae extends te{constructor(e,s,c,d){super(e,s,c,d),s.coordinates?Array.isArray(s.coordinates)&&4===s.coordinates.length&&!s.coordinates.some((e=>!Array.isArray(e)||2!==e.length||e.some((e=>"number"!=typeof e))))||this.fire(new l.k(new l.ae(`sources.${e}`,null,'"coordinates" property must be an array of 4 longitude/latitude array pairs'))):this.fire(new l.k(new l.ae(`sources.${e}`,null,'missing required property "coordinates"'))),s.animate&&"boolean"!=typeof s.animate&&this.fire(new l.k(new l.ae(`sources.${e}`,null,'optional "animate" property must be a boolean value'))),s.canvas?"string"==typeof s.canvas||s.canvas instanceof HTMLCanvasElement||this.fire(new l.k(new l.ae(`sources.${e}`,null,'"canvas" must be either a string representing the ID of the canvas element from which to read, or an HTMLCanvasElement instance'))):this.fire(new l.k(new l.ae(`sources.${e}`,null,'missing required property "canvas"'))),this.options=s,this.animate=void 0===s.animate||s.animate}load(){return l._(this,void 0,void 0,(function*(){this._loaded=!0,this.canvas||(this.canvas=this.options.canvas instanceof HTMLCanvasElement?this.options.canvas:document.getElementById(this.options.canvas)),this.width=this.canvas.width,this.height=this.canvas.height,this._hasInvalidDimensions()?this.fire(new l.k(new Error("Canvas dimensions cannot be less than or equal to zero."))):(this.play=function(){this._playing=!0,this.map.triggerRepaint()},this.pause=function(){this._playing&&(this.prepare(),this._playing=!1)},this._finishLoading())}))}getCanvas(){return this.canvas}onAdd(e){this.map=e,this.load(),this.canvas&&this.animate&&this.play()}onRemove(){this.pause()}prepare(){let e=!1;if(this.canvas.width!==this.width&&(this.width=this.canvas.width,e=!0),this.canvas.height!==this.height&&(this.height=this.canvas.height,e=!0),this._hasInvalidDimensions())return;if(0===Object.keys(this.tiles).length)return;const s=this.map.painter.context,c=s.gl;this.texture?(e||this._playing)&&this.texture.update(this.canvas,{premultiply:!0}):(this.texture=new l.T(s,this.canvas,c.RGBA,{premultiply:!0}),this.texture.bind(c.LINEAR,c.CLAMP_TO_EDGE));let d=!1;for(const e in this.tiles){const s=this.tiles[e];"loaded"!==s.state&&(s.state="loaded",s.texture=this.texture,d=!0)}d&&this.fire(new l.l("data",{dataType:"source",sourceDataType:"idle",sourceId:this.id}))}serialize(){return{type:"canvas",animate:this.animate,canvas:this.options.canvas,coordinates:this.coordinates}}hasTransition(){return this._playing}_hasInvalidDimensions(){for(const e of[this.canvas.width,this.canvas.height])if(isNaN(e)||e<=0)return!0;return!1}}const ye={},xe=e=>{switch(e){case"geojson":return ee;case"image":return te;case"raster":return K;case"raster-dem":return Y;case"vector":return X;case"video":return ie;case"canvas":return ae}return ye[e]},ve="RTLPluginLoaded";class ne extends l.E{constructor(){super(...arguments),this.status="unavailable",this.url=null,this.dispatcher=le()}_syncState(e){return this.status=e,this.dispatcher.broadcast("SRPS",{pluginStatus:e,pluginURL:this.url}).catch((e=>{throw this.status="error",e}))}getRTLTextPluginStatus(){return this.status}clearRTLTextPlugin(){this.status="unavailable",this.url=null}setRTLTextPlugin(e){return l._(this,arguments,void 0,(function*(e,s=!1){if(this.url)throw new Error("setRTLTextPlugin cannot be called multiple times.");if(this.url=_.resolveURL(e),!this.url)throw new Error(`requested url ${e} is invalid`);if("unavailable"===this.status){if(!s)return this._requestImport();this.status="deferred",this._syncState(this.status)}else if("requested"===this.status)return this._requestImport()}))}_requestImport(){return l._(this,void 0,void 0,(function*(){yield this._syncState("loading"),this.status="loaded",this.fire(new l.l(ve))}))}lazyLoad(){"unavailable"===this.status?this.status="requested":"deferred"===this.status&&this._requestImport()}}let be=null;function we(){return be||(be=new ne),be}var Se,Me;!function(e){e[e.Base=0]="Base",e[e.Parent=1]="Parent"}(Se||(Se={})),function(e){e[e.Departing=0]="Departing",e[e.Incoming=1]="Incoming"}(Me||(Me={}));class de{constructor(e,s){this.timeAdded=0,this.fadeEndTime=0,this.fadeOpacity=1,this.tileID=e,this.uid=l.af(),this.uses=0,this.tileSize=s,this.buckets={},this.expirationTime=null,this.queryPadding=0,this.hasSymbolBuckets=!1,this.hasRTLText=!1,this.dependencies={},this.rtt=[],this.rttCoords={},this.expiredRequestCount=0,this.state="loading"}isRenderable(e){return this.hasData()&&(!this.fadeEndTime||this.fadeOpacity>0)&&(e||!this.holdingForSymbolFade())}setCrossFadeLogic({fadingRole:e,fadingDirection:s,fadingParentID:l,fadeEndTime:c}){this.resetFadeLogic(),this.fadingRole=e,this.fadingDirection=s,this.fadingParentID=l,this.fadeEndTime=c}setSelfFadeLogic(e){this.resetFadeLogic(),this.selfFading=!0,this.fadeEndTime=e}resetFadeLogic(){this.fadingRole=null,this.fadingDirection=null,this.fadingParentID=null,this.selfFading=!1,this.timeAdded=y(),this.fadeEndTime=0,this.fadeOpacity=1}wasRequested(){return"errored"===this.state||"loaded"===this.state||"reloading"===this.state}clearTextures(e){this.demTexture&&e.saveTileTexture(this.demTexture),this.demTexture=null}loadVectorData(e,s,c){if(this.hasData()&&this.unloadVectorData(),this.state="loaded",e){e.featureIndex&&(this.latestFeatureIndex=e.featureIndex,e.rawTileData?(this.latestRawTileData=e.rawTileData,this.latestFeatureIndex.rawTileData=e.rawTileData,this.latestFeatureIndex.encoding=e.encoding):this.latestRawTileData&&(this.latestFeatureIndex.rawTileData=this.latestRawTileData,this.latestFeatureIndex.encoding=this.latestEncoding)),this.collisionBoxArray=e.collisionBoxArray,this.buckets=function(e,s){const l={};if(!s)return l;for(const c of e){const e=c.layerIds.map((e=>s.getLayer(e))).filter(Boolean);if(0!==e.length){c.layers=e,c.stateDependentLayerIds&&(c.stateDependentLayers=c.stateDependentLayerIds.map((s=>e.filter((e=>e.id===s))[0])));for(const s of e)l[s.id]=c}}return l}(e.buckets,null==s?void 0:s.style),this.hasSymbolBuckets=!1;for(const e in this.buckets){const s=this.buckets[e];if(s instanceof l.ah){if(this.hasSymbolBuckets=!0,!c)break;s.justReloaded=!0}}if(this.hasRTLText=!1,this.hasSymbolBuckets)for(const e in this.buckets){const s=this.buckets[e];if(s instanceof l.ah&&s.hasRTLText){this.hasRTLText=!0,we().lazyLoad();break}}this.queryPadding=0;for(const e in this.buckets){const l=this.buckets[e];this.queryPadding=Math.max(this.queryPadding,s.style.getLayer(e).queryRadius(l))}e.imageAtlas&&(this.imageAtlas=e.imageAtlas),e.glyphAtlasImage&&(this.glyphAtlasImage=e.glyphAtlasImage),this.dashPositions=e.dashPositions}else this.collisionBoxArray=new l.ag}unloadVectorData(){for(const e in this.buckets)this.buckets[e].destroy();this.buckets={},this.imageAtlasTexture&&this.imageAtlasTexture.destroy(),this.imageAtlas&&(this.imageAtlas=null),this.glyphAtlasTexture&&this.glyphAtlasTexture.destroy(),this.dashPositions&&(this.dashPositions=null),this.latestFeatureIndex=null,this.state="unloaded"}getBucket(e){return this.buckets[e.id]}upload(e){for(const s in this.buckets){const l=this.buckets[s];l.uploadPending()&&l.upload(e)}const s=e.gl;this.imageAtlas&&!this.imageAtlas.uploaded&&(this.imageAtlasTexture=new l.T(e,this.imageAtlas.image,s.RGBA),this.imageAtlas.uploaded=!0),this.glyphAtlasImage&&(this.glyphAtlasTexture=new l.T(e,this.glyphAtlasImage,s.ALPHA),this.glyphAtlasImage=null)}prepare(e){this.imageAtlas&&this.imageAtlas.patchUpdatedImages(e,this.imageAtlasTexture)}queryRenderedFeatures(e,s,l,c,d,p,f,m,_,g,y){return this.latestFeatureIndex&&this.latestFeatureIndex.rawTileData?this.latestFeatureIndex.query({queryGeometry:c,cameraQueryGeometry:d,scale:p,tileSize:this.tileSize,pixelPosMatrix:g,transform:m,params:f,queryPadding:this.queryPadding*_,getElevation:y},e,s,l):{}}querySourceFeatures(e,s){const c=this.latestFeatureIndex;if(!c||!c.rawTileData)return;const d=c.loadVTLayers(),p=s&&s.sourceLayer?s.sourceLayer:"",f=d[l.ai]||d[p];if(!f)return;const m=l.aj(null==s?void 0:s.filter,null==s?void 0:s.globalState),{z:_,x:g,y:y}=this.tileID.canonical,b={z:_,x:g,y:y};for(let s=0;se)l=!1;else if(s)if(this.expirationTime({zoom:0,x:0,y:0,wrap:e,fullyVisible:!1}),B=[],O=[];if(e.renderWorldCopies&&m.allowWorldCopies())for(let e=1;e<=3;e++)B.push(F(-e)),B.push(F(e));for(B.push(F(0));B.length>0;){const P=B.pop(),C=P.x,F=P.y;let j=P.fullyVisible;const G={x:C,y:F,z:P.zoom},U=m.getTileBoundingVolume(G,P.wrap,e.elevation,s);if(!j){const e=$e(c,U,d);if(0===e)continue;j=2===e}const q=m.distanceToTile2d(p.x,p.y,G,U);let Z=g;_&&(Z=(s.calculateTileZoom||et)(e.zoom+l.at(e.tileSize/s.tileSize),q,R,L,e.fov)),Z=(s.roundZoom?Math.round:Math.floor)(Z),Z=Math.max(0,Z);const W=Math.min(Z,b);if(P.wrap=m.getWrap(f,G,P.wrap),P.zoom>=W){if(P.zoom>1),wrap:P.wrap,fullyVisible:j})}return O.sort(((e,s)=>e.distanceSq-s.distanceSq)).map((e=>e.tileID))}const rt=l.aa.fromPoints([new l.P(0,0),new l.P(l.a5,l.a5)]);function ot(e){return"raster"===e||"image"===e||"video"===e}function at(e,s,l,c,d,p,f){if(!s.hasData())return!1;const{tileID:m,fadingRole:_,fadingDirection:g,fadingParentID:y}=s;if(_===Se.Base&&g===Me.Incoming&&y)return l[y.key]=y,!0;const b=Math.max(m.overscaledZ-d,p);for(let d=m.overscaledZ-1;d>=b;d--){const p=m.scaledTo(d),_=e.getLoadedTile(p);if(_)return s.setCrossFadeLogic({fadingRole:Se.Base,fadingDirection:Me.Incoming,fadingParentID:_.tileID,fadeEndTime:c+f}),_.setCrossFadeLogic({fadingRole:Se.Parent,fadingDirection:Me.Departing,fadeEndTime:c+f}),l[p.key]=p,!0}return!1}function ft(e,s,l,c,d,p){if(!s.hasData())return!1;const f=s.tileID.children(d);let m=_t(e,s,f,l,c,d,p);if(m)return!0;for(const _ of f)_t(e,s,_.children(d),l,c,d,p)&&(m=!0);return m}function _t(e,s,l,c,d,p,f){if(l[0].overscaledZ>=p)return!1;let m=!1;for(const p of l){const l=e.getLoadedTile(p);if(!l)continue;const{fadingRole:_,fadingDirection:g,fadingParentID:y}=l;_===Se.Base&&g===Me.Departing&&y||(l.setCrossFadeLogic({fadingRole:Se.Base,fadingDirection:Me.Departing,fadingParentID:s.tileID,fadeEndTime:d+f}),s.setCrossFadeLogic({fadingRole:Se.Parent,fadingDirection:Me.Incoming,fadeEndTime:d+f})),c[p.key]=p,m=!0}return m}function yt(e,s,l,c){const d=e.tileID;return!!e.selfFading||!e.hasData()&&!!s.has(d)&&(e.setSelfFadeLogic(l+c),!0)}function vt(e,s){var l;e.needsHillshadePrepare=!0,e.needsTerrainPrepare=!0;let c=s.tileID.canonical.x-e.tileID.canonical.x;const d=s.tileID.canonical.y-e.tileID.canonical.y,p=Math.pow(2,e.tileID.canonical.z),f=s.tileID.key;0===c&&0===d||Math.abs(d)>1||(Math.abs(c)>1&&(1===Math.abs(c+p)?c+=p:1===Math.abs(c-p)&&(c-=p)),s.dem&&e.dem&&(e.dem.backfillBorder(s.dem,c,d),(null===(l=e.neighboringTiles)||void 0===l?void 0:l[f])&&(e.neighboringTiles[f].backfilled=!0)))}class Le{constructor(){this._tiles={}}handleWrapJump(e){const s={};for(const l in this._tiles){const c=this._tiles[l];c.tileID=c.tileID.unwrapTo(c.tileID.wrap+e),s[c.tileID.key]=c}this._tiles=s}setFeatureState(e,s){for(const l in this._tiles)this._tiles[l].setFeatureState(e,s)}getAllTiles(){return Object.values(this._tiles)}getAllIds(e=!1){return e?Object.values(this._tiles).map((e=>e.tileID)).sort(l.aw).map((e=>e.key)):Object.keys(this._tiles)}getTileById(e){return this._tiles[e]}setTile(e,s){this._tiles[e]=s}deleteTileById(e){delete this._tiles[e]}getLoadedTile(e){const s=this.getTileById(e.key);return(null==s?void 0:s.hasData())?s:null}isIdRenderable(e,s=!1){var l;return null===(l=this.getTileById(e))||void 0===l?void 0:l.isRenderable(s)}getRenderableIds(e=0,s){const c=[];for(const e of this.getAllIds())this.isIdRenderable(e,s)&&c.push(this.getTileById(e));return s?c.sort(((s,c)=>{const d=s.tileID,p=c.tileID,f=new l.P(d.canonical.x,d.canonical.y)._rotate(-e),m=new l.P(p.canonical.x,p.canonical.y)._rotate(-e);return d.overscaledZ-p.overscaledZ||m.y-f.y||m.x-f.x})).map((e=>e.tileID.key)):c.map((e=>e.tileID)).sort(l.aw).map((e=>e.key))}}class ke extends l.E{constructor(e,s,c){super(),this.id=e,this.dispatcher=c,this.on("data",(e=>this._dataHandler(e))),this.on("dataloading",(()=>{this._sourceErrored=!1})),this.on("error",(()=>{this._sourceErrored=this._source.loaded()})),this._source=((e,s,l,c)=>{const d=new(xe(s.type))(e,s,l,c);if(d.id!==e)throw new Error(`Expected Source id to be ${e} instead of ${d.id}`);return d})(e,s,c,this),this._inViewTiles=new Le,this._outOfViewCache=new l.ax(0,(e=>this._unloadTile(e))),this._timers={},this._maxTileCacheSize=null,this._maxTileCacheZoomLevels=null,this._rasterFadeDuration=0,this._maxFadingAncestorLevels=5,this._state=new _e,this._didEmitContent=!1,this._updated=!1}onAdd(e){this.map=e,this._maxTileCacheSize=e?e._maxTileCacheSize:null,this._maxTileCacheZoomLevels=e?e._maxTileCacheZoomLevels:null,this._source&&this._source.onAdd&&this._source.onAdd(e)}onRemove(e){for(const e of this._inViewTiles.getAllTiles())e.unloadVectorData();this.clearTiles(),this._source&&this._source.onRemove&&this._source.onRemove(e),this._inViewTiles=new Le}loaded(){if(this._sourceErrored)return!0;if(!this._sourceLoaded)return!1;if(!this._source.loaded())return!1;if(!(void 0===this.used&&void 0===this.usedForTerrain||this.used||this.usedForTerrain))return!0;if(!this._updated)return!1;for(const e of this._inViewTiles.getAllTiles())if("loaded"!==e.state&&"errored"!==e.state)return!1;return!0}getSource(){return this._source}getState(){return this._state}pause(){this._paused=!0}resume(){if(!this._paused)return;const e=this._shouldReloadOnResume;this._paused=!1,this._shouldReloadOnResume=!1,e&&this.reload(),this.transform&&this.update(this.transform,this.terrain)}_loadTile(e,s,c){return l._(this,void 0,void 0,(function*(){try{yield this._source.loadTile(e),this._tileLoaded(e,s,c)}catch(s){e.state="errored",404!==s.status?this._source.fire(new l.k(s,{tile:e})):this.update(this.transform,this.terrain)}}))}_unloadTile(e){this._source.unloadTile&&this._source.unloadTile(e)}_abortTile(e){this._source.abortTile&&this._source.abortTile(e),this._source.fire(new l.l("dataabort",{tile:e,coord:e.tileID,dataType:"source"}))}serialize(){return this._source.serialize()}prepare(e){this._source.prepare&&this._source.prepare(),this._state.coalesceChanges(this._inViewTiles,this.map?this.map.painter:null);for(const s of this._inViewTiles.getAllTiles())s.upload(e),s.prepare(this.map.style.imageManager)}getIds(){return this._inViewTiles.getAllIds(!0)}getRenderableIds(e){var s;return this._inViewTiles.getRenderableIds(null===(s=this.transform)||void 0===s?void 0:s.bearingInRadians,e)}hasRenderableParent(e){const s=e.overscaledZ-1;if(s>=this._source.minzoom){const l=this.getLoadedTile(e.scaledTo(s));if(l)return this._inViewTiles.isIdRenderable(l.tileID.key)}return!1}reload(e,s=void 0){if(this._paused)this._shouldReloadOnResume=!0;else{this._outOfViewCache.reset();for(const l of this._inViewTiles.getAllIds()){const c=this._inViewTiles.getTileById(l);s&&!this._source.shouldReloadTile(c,s)||(e?this._reloadTile(l,"expired"):"errored"!==c.state&&this._reloadTile(l,"reloading"))}}}_reloadTile(e,s){return l._(this,void 0,void 0,(function*(){const l=this._inViewTiles.getTileById(e);l&&("loading"!==l.state&&(l.state=s),yield this._loadTile(l,e,s))}))}_tileLoaded(e,s,c){e.timeAdded=y(),e.selfFading&&(e.fadeEndTime=e.timeAdded+this._rasterFadeDuration),"expired"===c&&(e.refreshedUponExpiration=!0),this._setTileReloadTimer(s,e),"raster-dem"===this.getSource().type&&e.dem&&function(e,s){var l,c;const d=s.getRenderableIds();for(const p of d){if(!e.neighboringTiles||!e.neighboringTiles[p])continue;const d=s.getTileById(p);e.neighboringTiles[p].backfilled||vt(e,d),(null===(c=null===(l=d.neighboringTiles)||void 0===l?void 0:l[e.tileID.key])||void 0===c?void 0:c.backfilled)||vt(d,e)}}(e,this._inViewTiles),this._state.initializeTileState(e,this.map?this.map.painter:null),e.aborted||this._source.fire(new l.l("data",{dataType:"source",tile:e,coord:e.tileID}))}getTile(e){return this.getTileByID(e.key)}getTileByID(e){return this._inViewTiles.getTileById(e)}_retainLoadedChildren(e,s){const l=this._getLoadedDescendents(s),c=new Set;for(const d of s){const s=l[d.key];if(!(null==s?void 0:s.length)){c.add(d);continue}const p=d.overscaledZ+ke.maxOverzooming,f=s.filter((e=>e.tileID.overscaledZ<=p));if(!f.length){c.add(d);continue}const m=Math.min(...f.map((e=>e.tileID.overscaledZ))),_=f.filter((e=>e.tileID.overscaledZ===m)).map((e=>e.tileID));for(const s of _)e[s.key]=s;this._areDescendentsComplete(_,m,d.overscaledZ)||c.add(d)}return c}_getLoadedDescendents(e){var s;const l={};for(const c of this._inViewTiles.getAllTiles().filter((e=>e.hasData())))for(const d of e)c.tileID.isChildOf(d)&&(l[s=d.key]||(l[s]=[])).push(c);return l}_areDescendentsComplete(e,s,l){return 1===e.length&&e[0].isOverscaled()?e[0].overscaledZ===s:Math.pow(4,s-l)===e.length}getLoadedTile(e){return this._inViewTiles.getLoadedTile(e)}updateCacheSize(e){const s=Math.ceil(e.width/this._source.tileSize)+1,c=Math.ceil(e.height/this._source.tileSize)+1,d=Math.floor(s*c*(null===this._maxTileCacheZoomLevels?l.c.MAX_TILE_CACHE_ZOOM_LEVELS:this._maxTileCacheZoomLevels)),p="number"==typeof this._maxTileCacheSize?Math.min(this._maxTileCacheSize,d):d;this._outOfViewCache.setMaxSize(p)}handleWrapJump(e){const s=Math.round((e-(void 0===this._prevLng?e:this._prevLng))/360);this._prevLng=e,s&&(this._inViewTiles.handleWrapJump(s),this._resetTileReloadTimers())}update(e,s){if(!this._sourceLoaded||this._paused)return;let c;this.transform=e,this.terrain=s,this.updateCacheSize(e),this.handleWrapJump(this.transform.center.lng),this.used||this.usedForTerrain?this._source.tileID?c=e.getVisibleUnwrappedCoordinates(this._source.tileID).map((e=>new l.a2(e.canonical.z,e.wrap,e.canonical.z,e.canonical.x,e.canonical.y))):(c=it(e,{tileSize:this.usedForTerrain?this.tileSize:this._source.tileSize,minzoom:this._source.minzoom,maxzoom:"vector"===this._source.type&&void 0!==this.map._zoomLevelsToOverscale?e.maxZoom-this.map._zoomLevelsToOverscale:this._source.maxzoom,roundZoom:!this.usedForTerrain&&this._source.roundZoom,reparseOverscaled:this._source.reparseOverscaled,terrain:s,calculateTileZoom:this._source.calculateTileZoom}),this._source.hasTile&&(c=c.filter((e=>this._source.hasTile(e))))):c=[],this.usedForTerrain&&(c=this._addTerrainIdealTiles(c));const d=0===c.length&&!this._updated&&this._didEmitContent;this._updated=!0,d&&this.fire(new l.l("data",{sourceDataType:"idle",dataType:"source",sourceId:this.id}));const p=tt(e,this._source),f=this._updateRetainedTiles(c,p),m=ot(this._source.type);m&&this._rasterFadeDuration>0&&!s&&function(e,s,c,d,p,f,m){const _=y(),g=l.av(s);for(const l of s){const s=e.getTileById(l.key);s.fadingDirection!==Me.Departing&&0!==s.fadeOpacity||s.resetFadeLogic(),at(e,s,c,_,d,p,m)||ft(e,s,c,_,f,m)||yt(s,g,_,m)||s.resetFadeLogic()}}(this._inViewTiles,c,f,this._maxFadingAncestorLevels,this._source.minzoom,this._source.maxzoom,this._rasterFadeDuration),m?this._cleanUpRasterTiles(f):this._cleanUpVectorTiles(f)}_cleanUpRasterTiles(e){for(const s of this._inViewTiles.getAllIds())e[s]||this._removeTile(s)}_cleanUpVectorTiles(e){for(const s of this._inViewTiles.getAllIds()){const l=this._inViewTiles.getTileById(s);e[s]?l.clearSymbolFadeHold():l.hasSymbolBuckets?l.holdingForSymbolFade()?l.symbolFadeFinished()&&this._removeTile(s):l.setSymbolHoldDuration(this.map._fadeDuration):this._removeTile(s)}}_addTerrainIdealTiles(e){const s=[];for(const l of e)if(l.canonical.z>this._source.minzoom){const e=l.scaledTo(l.canonical.z-1);s.push(e);const c=l.scaledTo(Math.max(this._source.minzoom,Math.min(l.canonical.z,5)));s.push(c)}return e.concat(s)}releaseSymbolFadeTiles(){for(const e of this._inViewTiles.getAllIds())this._inViewTiles.getTileById(e).holdingForSymbolFade()&&this._removeTile(e)}_updateRetainedTiles(e,s){var l;const c=new Set;for(const s of e)this._addTile(s).hasData()||c.add(s);const d=e.reduce(((e,s)=>(e[s.key]=s,e)),{}),p=this._retainLoadedChildren(d,c),f={},m=Math.max(s-ke.maxUnderzooming,this._source.minzoom);for(const e of p){let s=this._inViewTiles.getTileById(e.key),c=null==s?void 0:s.wasRequested();for(let p=e.overscaledZ-1;p>=m;--p){const m=e.scaledTo(p);if(f[m.key])break;if(f[m.key]=!0,s=this.getTile(m),!s&&c&&(s=this._addTile(m)),s){const e=s.hasData();if((e||!(null===(l=this.map)||void 0===l?void 0:l.cancelPendingTileRequestsWhileZooming)||c)&&(d[m.key]=m),c=s.wasRequested(),e)break}}}return d}_addTile(e){let s=this._inViewTiles.getTileById(e.key);if(s)return s;s=this._outOfViewCache.getAndRemove(e),s&&(s.resetFadeLogic(),this._setTileReloadTimer(e.key,s),s.tileID=e,this._state.initializeTileState(s,this.map?this.map.painter:null));const c=s;return s||(s=new de(e,this._source.tileSize*e.overscaleFactor()),this._loadTile(s,e.key,s.state)),s.uses++,this._inViewTiles.setTile(e.key,s),c||this._source.fire(new l.l("dataloading",{tile:s,coord:s.tileID,dataType:"source"})),s}_setTileReloadTimer(e,s){this._clearTileReloadTimer(e);const l=s.getExpiryTimeout();l&&(this._timers[e]=setTimeout((()=>{this._reloadTile(e,"expired"),delete this._timers[e]}),l))}_clearTileReloadTimer(e){const s=this._timers[e];s&&(clearTimeout(s),delete this._timers[e])}_resetTileReloadTimers(){for(const e in this._timers)clearTimeout(this._timers[e]),delete this._timers[e];for(const e of this._inViewTiles.getAllIds()){const s=this._inViewTiles.getTileById(e);this._setTileReloadTimer(e,s)}}refreshTiles(e){for(const s of this._inViewTiles.getAllIds()){const l=this._inViewTiles.getTileById(s);(this._inViewTiles.isIdRenderable(s)||"errored"==l.state)&&e.some((e=>e.equals(l.tileID.canonical)))&&this._reloadTile(s,"expired")}}_removeTile(e){const s=this._inViewTiles.getTileById(e);s&&(s.uses--,this._inViewTiles.deleteTileById(e),this._clearTileReloadTimer(e),s.uses>0||(s.hasData()&&"reloading"!==s.state?this._outOfViewCache.add(s.tileID,s,s.getExpiryTimeout()):(s.aborted=!0,this._abortTile(s),this._unloadTile(s))))}_dataHandler(e){"source"===e.dataType&&("metadata"!==e.sourceDataType?"content"===e.sourceDataType&&this._sourceLoaded&&!this._paused&&(this.reload(e.sourceDataChanged,e.shouldReloadTileOptions),this.transform&&this.update(this.transform,this.terrain),this._didEmitContent=!0):this._sourceLoaded=!0)}clearTiles(){this._shouldReloadOnResume=!1,this._paused=!1;for(const e of this._inViewTiles.getAllIds())this._removeTile(e);this._outOfViewCache.reset()}tilesIn(e,s,c){const d=[],p=this.transform;if(!p)return d;const f=p.getCoveringTilesDetailsProvider().allowWorldCopies(),m=c?p.getCameraQueryGeometry(e):e,_=e=>p.screenPointToMercatorCoordinate(e,this.terrain),g=this.transformBbox(e,_,!f),y=this.transformBbox(m,_,!f),b=this.getIds(),T=l.aa.fromPoints(y);for(let e=0;ee.getTilePoint(new l.a9(s.x,s.y))));if(s.expandBy(P),s.intersects(rt)){const s=g.map((s=>e.getTilePoint(s))),l=y.map((s=>e.getTilePoint(s)));d.push({tile:c,tileID:f?e:e.unwrapTo(0),queryGeometry:s,cameraQueryGeometry:l,scale:_})}}}return d}transformBbox(e,s,c){let d=e.map(s);if(c){const c=l.aa.fromPoints(e);c.shrinkBy(.001*Math.min(c.width(),c.height()));const p=c.map(s);l.aa.fromPoints(d).covers(p)||(d=d.map((e=>e.x>.5?new l.a9(e.x-1,e.y,e.z):e)))}return d}getVisibleCoordinates(e){const s=this.getRenderableIds(e).map((e=>this._inViewTiles.getTileById(e).tileID));return this.transform&&this.transform.populateCache(s),s}hasTransition(){return!!this._source.hasTransition()||!(!ot(this._source.type)||!function(e,s){if(s<=0)return!1;const l=y();for(const s of e.getAllTiles())if(s.fadeEndTime>=l)return!0;return!1}(this._inViewTiles,this._rasterFadeDuration))}setRasterFadeDuration(e){this._rasterFadeDuration=e}setFeatureState(e,s,c){this._state.updateState(e=e||l.ai,s,c)}removeFeatureState(e,s,c){this._state.removeFeatureState(e=e||l.ai,s,c)}getFeatureState(e,s){return this._state.getState(e=e||l.ai,s)}setDependencies(e,s,l){const c=this._inViewTiles.getTileById(e);c&&c.setDependencies(s,l)}reloadTilesForDependencies(e,s){for(const l of this._inViewTiles.getAllIds())this._inViewTiles.getTileById(l).hasDependency(e,s)&&this._reloadTile(l,"reloading");this._outOfViewCache.filter((l=>!l.hasDependency(e,s)))}areTilesLoaded(){for(const e of this._inViewTiles.getAllTiles())if("loaded"!==e.state&&"errored"!==e.state)return!1;return!0}}ke.maxUnderzooming=10,ke.maxOverzooming=3;class Fe{constructor(e,s){this.reset(e,s)}reset(e,s){this.points=e||[],this._distances=[0];for(let e=1;e0?(d-f)/m:0;return this.points[p].mult(1-_).add(this.points[s].mult(_))}}function bt(e,s){let l=!0;return"always"===e||"never"!==e&&"never"!==s||(l=!1),l}class Oe{constructor(e,s,l){const c=this.boxCells=[],d=this.circleCells=[];this.xCellCount=Math.ceil(e/l),this.yCellCount=Math.ceil(s/l);for(let e=0;ethis.width||c<0||s>this.height)return[];const m=[];if(e<=0&&s<=0&&this.width<=l&&this.height<=c){if(d)return[{key:null,x1:e,y1:s,x2:l,y2:c}];for(let e=0;e0}hitTestCircle(e,s,l,c,d){const p=e-l,f=e+l,m=s-l,_=s+l;if(f<0||p>this.width||_<0||m>this.height)return!1;const g=[];return this._forEachCell(p,m,f,_,this._queryCellCircle,g,{hitTest:!0,overlapMode:c,circle:{x:e,y:s,radius:l},seenUids:{box:{},circle:{}}},d),g.length>0}_queryCell(e,s,l,c,d,p,f,m){const{seenUids:_,hitTest:g,overlapMode:y}=f,b=this.boxCells[d];if(null!==b){const d=this.bboxes;for(const f of b)if(!_.box[f]){_.box[f]=!0;const b=4*f,T=this.boxKeys[f];if(e<=d[b+2]&&s<=d[b+3]&&l>=d[b+0]&&c>=d[b+1]&&(!m||m(T))&&(!g||!bt(y,T.overlapMode))&&(p.push({key:T,x1:d[b],y1:d[b+1],x2:d[b+2],y2:d[b+3]}),g))return!0}}const T=this.circleCells[d];if(null!==T){const d=this.circles;for(const f of T)if(!_.circle[f]){_.circle[f]=!0;const b=3*f,T=this.circleKeys[f];if(this._circleAndRectCollide(d[b],d[b+1],d[b+2],e,s,l,c)&&(!m||m(T))&&(!g||!bt(y,T.overlapMode))){const e=d[b],s=d[b+1],l=d[b+2];if(p.push({key:T,x1:e-l,y1:s-l,x2:e+l,y2:s+l}),g)return!0}}}return!1}_queryCellCircle(e,s,l,c,d,p,f,m){const{circle:_,seenUids:g,overlapMode:y}=f,b=this.boxCells[d];if(null!==b){const e=this.bboxes;for(const s of b)if(!g.box[s]){g.box[s]=!0;const l=4*s,c=this.boxKeys[s];if(this._circleAndRectCollide(_.x,_.y,_.radius,e[l+0],e[l+1],e[l+2],e[l+3])&&(!m||m(c))&&!bt(y,c.overlapMode))return p.push(!0),!0}}const T=this.circleCells[d];if(null!==T){const e=this.circles;for(const s of T)if(!g.circle[s]){g.circle[s]=!0;const l=3*s,c=this.circleKeys[s];if(this._circlesCollide(e[l],e[l+1],e[l+2],_.x,_.y,_.radius)&&(!m||m(c))&&!bt(y,c.overlapMode))return p.push(!0),!0}}}_forEachCell(e,s,l,c,d,p,f,m){const _=this._convertToXCellCoord(e),g=this._convertToYCellCoord(s),y=this._convertToXCellCoord(l),b=this._convertToYCellCoord(c);for(let T=_;T<=y;T++)for(let _=g;_<=b;_++)if(d.call(this,e,s,l,c,this.xCellCount*_+T,p,f,m))return}_convertToXCellCoord(e){return Math.max(0,Math.min(this.xCellCount-1,Math.floor(e*this.xScale)))}_convertToYCellCoord(e){return Math.max(0,Math.min(this.yCellCount-1,Math.floor(e*this.yScale)))}_circlesCollide(e,s,l,c,d,p){const f=c-e,m=d-s,_=l+p;return _*_>f*f+m*m}_circleAndRectCollide(e,s,l,c,d,p,f){const m=(p-c)/2,_=Math.abs(e-(c+m));if(_>m+l)return!1;const g=(f-d)/2,y=Math.abs(s-(d+g));if(y>g+l)return!1;if(_<=m||y<=g)return!0;const b=_-m,T=y-g;return b*b+T*T<=l*l}}function wt(e,s,c){const p=l.N();if(!e){const{vecSouth:e,vecEast:l}=Mt(s),c=d();c[0]=l[0],c[1]=l[1],c[2]=e[0],c[3]=e[1],f=c,(T=(_=(m=c)[0])*(b=m[3])-(y=m[2])*(g=m[1]))&&(f[0]=b*(T=1/T),f[1]=-g*T,f[2]=-y*T,f[3]=_*T),p[0]=c[0],p[1]=c[1],p[4]=c[2],p[5]=c[3]}var f,m,_,g,y,b,T;return l.Q(p,p,[1/c,1/c,1]),p}function Tt(e,s,c,d){if(e){const e=l.N();if(!s){const{vecSouth:s,vecEast:l}=Mt(c);e[0]=l[0],e[1]=l[1],e[4]=s[0],e[5]=s[1]}return l.Q(e,e,[d,d,1]),e}return c.pixelsToClipSpaceMatrix}function Mt(e){const s=Math.cos(e.rollInRadians),c=Math.sin(e.rollInRadians),d=Math.cos(e.pitchInRadians),p=Math.cos(e.bearingInRadians),f=Math.sin(e.bearingInRadians),m=l.aC();m[0]=-p*d*c-f*s,m[1]=-f*d*c+p*s;const _=l.aD(m);_<1e-9?l.aE(m):l.aF(m,m,1/_);const g=l.aC();g[0]=p*d*s-f*c,g[1]=f*d*s+p*c;const y=l.aD(g);return y<1e-9?l.aE(g):l.aF(g,g,1/y),{vecEast:g,vecSouth:m}}function At(e,s,c,d){let p;d?(p=[e,s,d(e,s),1],l.aH(p,p,c)):(p=[e,s,0,1],mi(p,p,c));const f=p[3];return{point:new l.P(p[0]/f,p[1]/f),signedDistanceFromCamera:f,isOccluded:!1}}function Lt(e,s){return.5+e/s*.5}function Ft(e,s){return e.x>=-s[0]&&e.x<=s[0]&&e.y>=-s[1]&&e.y<=s[1]}function Ot(e,s,c,d,p,f,m,_,g,y,b,T,P){const S=c?e.textSizeData:e.iconSizeData,I=l.ay(S,s.transform.zoom),C=[256/s.width*2+1,256/s.height*2+1],R=c?e.text.dynamicLayoutVertexArray:e.icon.dynamicLayoutVertexArray;R.clear();const L=e.lineVertexArray,F=c?e.text.placedSymbolArray:e.icon.placedSymbolArray,B=s.transform.width/s.transform.height;let O=!1;for(let c=0;cMath.abs(c.x-s.x)*d?{useVertical:!0}:(e===l.az.vertical?s.yc.x)?{needsFlipping:!0}:null}function Ht(e){const{projectionContext:s,pitchedLabelPlaneMatrixInverse:c,symbol:d,fontSize:p,flip:f,keepUpright:m,glyphOffsetArray:_,dynamicLayoutVertexArray:g,aspectRatio:y,rotateToLine:b}=e,T=p/24,P=d.lineOffsetX*T,S=d.lineOffsetY*T;let I;if(d.numGlyphs>1){const e=d.glyphStartIndex+d.numGlyphs,l=d.lineStartIndex,p=d.lineStartIndex+d.lineLength,g=Gt(T,_,P,S,f,d,b,s);if(!g)return{notEnoughRoom:!0};const C=ri(g.first.point.x,g.first.point.y,s,c),R=ri(g.last.point.x,g.last.point.y,s,c);if(m&&!f){const e=Zt(d.writingMode,C,R,y);if(e)return e}I=[g.first];for(let c=d.glyphStartIndex+1;c0?m.point:Xt(s.tileAnchorPoint,f,e,1,s),g=ri(e.x,e.y,s,c),b=ri(_.x,_.y,s,c),T=Zt(d.writingMode,g,b,y);if(T)return T}const e=ui(T*_.getoffsetX(d.glyphStartIndex),P,S,f,d.segment,d.lineStartIndex,d.lineStartIndex+d.lineLength,s,b);if(!e||s.projectionCache.anyProjectionOccluded)return{notEnoughRoom:!0};I=[e]}for(const e of I)l.aG(g,e.point,e.angle);return{}}function Xt(e,s,l,c,d){const p=e.add(e.sub(s)._unit()),f=Jt(p.x,p.y,d).point,m=l.sub(f);return l.add(m._mult(c/m.mag()))}function Kt(e,s,c){const d=s.projectionCache;if(d.projections[e])return d.projections[e];const p=new l.P(s.lineVertexArray.getx(e),s.lineVertexArray.gety(e)),f=Jt(p.x,p.y,s);if(f.signedDistanceFromCamera>0)return d.projections[e]=f.point,d.anyProjectionOccluded=d.anyProjectionOccluded||f.isOccluded,f.point;const m=e-c.direction;return Xt(0===c.distanceFromAnchor?s.tileAnchorPoint:new l.P(s.lineVertexArray.getx(m),s.lineVertexArray.gety(m)),p,c.previousVertex,c.absOffsetX-c.distanceFromAnchor+1,s)}function Jt(e,s,l){const c=e+l.translation[0],d=s+l.translation[1];let p;return l.pitchWithMap?(p=At(c,d,l.pitchedLabelPlaneMatrix,l.getElevation),p.isOccluded=!1):(p=l.transform.projectTileCoordinates(c,d,l.unwrappedTileID,l.getElevation),p.point.x=(.5*p.point.x+.5)*l.width,p.point.y=(.5*-p.point.y+.5)*l.height),p}function ri(e,s,c,d){if(c.pitchWithMap){const p=[e,s,0,1];return l.aH(p,p,d),c.transform.projectTileCoordinates(p[0]/p[3],p[1]/p[3],c.unwrappedTileID,c.getElevation).point}return{x:e/c.width*2-1,y:1-s/c.height*2}}function ni(e,s,l){return l.transform.projectTileCoordinates(e,s,l.unwrappedTileID,l.getElevation)}function li(e,s,l){return e._unit()._perp()._mult(s*l)}function ci(e,s,c,d,p,f,m,_,g){if(_.projectionCache.offsets[e])return _.projectionCache.offsets[e];const y=c.add(s);if(e+g.direction=p)return _.projectionCache.offsets[e]=y,y;const b=Kt(e+g.direction,_,g),T=li(b.sub(c),m,g.direction),P=c.add(T),S=b.add(T);return _.projectionCache.offsets[e]=l.aI(f,y,P,S)||y,_.projectionCache.offsets[e]}function ui(e,s,l,c,d,p,f,m,_){const g=c?e-s:e+s;let y=g>0?1:-1,b=0;c&&(y*=-1,b=Math.PI),y<0&&(b+=Math.PI);let T,P=y>0?p+d:p+d+1;m.projectionCache.cachedAnchorPoint?T=m.projectionCache.cachedAnchorPoint:(T=Jt(m.tileAnchorPoint.x,m.tileAnchorPoint.y,m).point,m.projectionCache.cachedAnchorPoint=T);let S,I,C=T,R=T,L=0,F=0;const B=Math.abs(g),O=[];let j;for(;L+F<=B;){if(P+=y,P=f)return null;L+=F,R=C,I=S;const e={absOffsetX:B,direction:y,distanceFromAnchor:L,previousVertex:R};if(C=Kt(P,m,e),0===l)O.push(R),j=C.sub(R);else{let s;const c=C.sub(R);s=0===c.mag()?li(Kt(P+y,m,e).sub(C),l,y):li(c,l,y),I||(I=R.add(s)),S=ci(P,s,C,p,f,I,l,m,e),O.push(I),j=S.sub(I)}F=j.mag()}const G=j._mult((B-L)/F)._add(I||R),U=b+Math.atan2(C.y-R.y,C.x-R.x);return O.push(G),{point:G,angle:_?U:0,path:O}}const pi=new Float32Array([-1/0,-1/0,0,-1/0,-1/0,0,-1/0,-1/0,0,-1/0,-1/0,0]);function fi(e,s){for(let l=0;l=1;e--)P.push(f.path[e]);for(let e=1;ee.signedDistanceFromCamera<=0))?[]:e.map((e=>e.point))}let C=[];if(P.length>0){const e=P[0].clone(),s=P[0].clone();for(let l=1;l=c.x&&s.x<=d.x&&e.y>=c.y&&s.y<=d.y?[P]:s.xd.x||s.yd.y?[]:l.aJ([P],c.x,c.y,d.x,d.y)}for(const l of C){p.reset(l,.25*s);let c=0;c=p.length<=.5*s?1:Math.ceil(p.paddedLength/S)+1;for(let l=0;l{const l=At(e.x,e.y,c,s.getElevation),d=s.transform.projectTileCoordinates(l.point.x,l.point.y,s.unwrappedTileID,s.getElevation);return d.point.x=(.5*d.point.x+.5)*s.width,d.point.y=(.5*-d.point.y+.5)*s.height,d}))}(e,s);return function(e){let s=0,l=0,c=0,d=0;for(let p=0;pl&&(l=d,s=c));return e.slice(s,s+l)}(c)}queryRenderedSymbols(e){if(0===e.length||0===this.grid.keysLength()&&0===this.ignoredGrid.keysLength())return{};const s=[],c=new l.aa;for(const d of e){const e=new l.P(d.x+_i,d.y+_i);c.extend(e),s.push(e)}const{minX:d,minY:p,maxX:f,maxY:m}=c,_=this.grid.query(d,p,f,m).concat(this.ignoredGrid.query(d,p,f,m)),g={},y={};for(const e of _){const c=e.key;if(void 0===g[c.bucketInstanceId]&&(g[c.bucketInstanceId]={}),g[c.bucketInstanceId][c.featureIndex])continue;const d=[new l.P(e.x1,e.y1),new l.P(e.x2,e.y1),new l.P(e.x2,e.y2),new l.P(e.x1,e.y2)];l.aK(s,d)&&(g[c.bucketInstanceId][c.featureIndex]=!0,void 0===y[c.bucketInstanceId]&&(y[c.bucketInstanceId]=[]),y[c.bucketInstanceId].push(c.featureIndex))}return y}insertCollisionBox(e,s,l,c,d,p){(l?this.ignoredGrid:this.grid).insert({bucketInstanceId:c,featureIndex:d,collisionGroupID:p,overlapMode:s},e[0],e[1],e[2],e[3])}insertCollisionCircles(e,s,l,c,d,p){const f=l?this.ignoredGrid:this.grid,m={bucketInstanceId:c,featureIndex:d,collisionGroupID:p,overlapMode:s};for(let s=0;s=this.screenRightBoundary||c<_i||s>this.screenBottomBoundary}isInsideGrid(e,s,l,c){return l>=0&&e=0&&sthis.projectAndGetPerspectiveRatio(e.x,e.y,d,g,b)));re=e.some((e=>!e.isOccluded)),J=e.map((e=>new l.P(e.x,e.y)))}else re=!0;return{box:l.aL(J),allPointsOccluded:!re}}}class lt{constructor(e,s,l,c){this.opacity=e?Math.max(0,Math.min(1,e.opacity+(e.placed?s:-s))):c&&l?1:0,this.placed=l}isHidden(){return 0===this.opacity&&!this.placed}}class ct{constructor(e,s,l,c,d){this.text=new lt(e?e.text:null,s,l,d),this.icon=new lt(e?e.icon:null,s,c,d)}isHidden(){return this.text.isHidden()&&this.icon.isHidden()}}class ht{constructor(e,s,l){this.text=e,this.icon=s,this.skipFade=l}}class ut{constructor(e,s,l,c,d){this.bucketInstanceId=e,this.featureIndex=s,this.sourceLayerIndex=l,this.bucketIndex=c,this.tileID=d}}class dt{constructor(e){this.crossSourceCollisions=e,this.maxGroupID=0,this.collisionGroups={}}get(e){if(this.crossSourceCollisions)return{ID:0,predicate:null};if(!this.collisionGroups[e]){const s=++this.maxGroupID;this.collisionGroups[e]={ID:s,predicate:e=>e.collisionGroupID===s}}return this.collisionGroups[e]}}function gi(e,s,c,d,p){const{horizontalAlign:f,verticalAlign:m}=l.aS(e);return new l.P(-(f-.5)*s+d[0]*p,-(m-.5)*c+d[1]*p)}class pt{constructor(e,s,l,c,d){this.transform=e.clone(),this.terrain=s,this.collisionIndex=new nt(this.transform),this.placements={},this.opacities={},this.variableOffsets={},this.stale=!1,this.commitTime=0,this.fadeDuration=l,this.retainedQueryData={},this.collisionGroups=new dt(c),this.collisionCircleArrays={},this.collisionBoxArrays=new Map,this.prevPlacement=d,d&&(d.prevPlacement=void 0),this.placedOrientations={}}_getTerrainElevationFunc(e){const s=this.terrain;return s?(l,c)=>s.getElevation(e,l,c):null}getBucketParts(e,s,c,d){const p=c.getBucket(s),f=c.latestFeatureIndex;if(!p||!f||s.id!==p.layerIds[0])return;const m=c.collisionBoxArray,_=p.layers[0].layout,g=p.layers[0].paint,y=Math.pow(2,this.transform.zoom-c.tileID.overscaledZ),b=c.tileSize/l.a5,T=c.tileID.toUnwrapped(),P="map"===_.get("text-rotation-alignment"),S=l.aN(c,1,this.transform.zoom),I=l.aO(this.collisionIndex.transform,c,g.get("text-translate"),g.get("text-translate-anchor")),C=l.aO(this.collisionIndex.transform,c,g.get("icon-translate"),g.get("icon-translate-anchor")),R=wt(P,this.transform,S);this.retainedQueryData[p.bucketInstanceId]=new ut(p.bucketInstanceId,f,p.sourceLayerIndex,p.index,c.tileID);const L={bucket:p,layout:_,translationText:I,translationIcon:C,unwrappedTileID:T,pitchedLabelPlaneMatrix:R,scale:y,textPixelRatio:b,holdingForFade:c.holdingForSymbolFade(),collisionBoxArray:m,partiallyEvaluatedTextSize:l.ay(p.textSizeData,this.transform.zoom),collisionGroup:this.collisionGroups.get(p.sourceID)};if(d)for(const s of p.sortKeyRanges){const{sortKey:l,symbolInstanceStart:c,symbolInstanceEnd:d}=s;e.push({sortKey:l,symbolInstanceStart:c,symbolInstanceEnd:d,parameters:L})}else e.push({symbolInstanceStart:0,symbolInstanceEnd:p.symbolInstances.length,parameters:L})}attemptAnchorPlacement(e,s,c,d,p,f,m,_,g,y,b,T,P,S,I,C,R,L,F,B){const O=l.aP[e.textAnchor],j=[e.textOffset0,e.textOffset1],G=gi(O,c,d,j,p),U=this.collisionIndex.placeCollisionBox(s,T,_,g,y,m,f,C,b.predicate,F,G,B);if((!L||this.collisionIndex.placeCollisionBox(L,T,_,g,y,m,f,R,b.predicate,F,G,B).placeable)&&U.placeable){let e;if(this.prevPlacement&&this.prevPlacement.variableOffsets[P.crossTileID]&&this.prevPlacement.placements[P.crossTileID]&&this.prevPlacement.placements[P.crossTileID].text&&(e=this.prevPlacement.variableOffsets[P.crossTileID].anchor),0===P.crossTileID)throw new Error("symbolInstance.crossTileID can't be 0");return this.variableOffsets[P.crossTileID]={textOffset:j,width:c,height:d,anchor:O,textBoxScale:p,prevAnchor:e},this.markUsedJustification(S,O,P,I),S.allowVerticalPlacement&&(this.markUsedOrientation(S,I,P),this.placedOrientations[P.crossTileID]=I),{shift:G,placedGlyphBoxes:U}}}placeLayerBucketPart(e,s,c){const{bucket:d,layout:p,translationText:f,translationIcon:m,unwrappedTileID:_,pitchedLabelPlaneMatrix:g,textPixelRatio:y,holdingForFade:b,collisionBoxArray:T,partiallyEvaluatedTextSize:P,collisionGroup:S}=e.parameters,I=p.get("text-optional"),C=p.get("icon-optional"),R=l.aQ(p,"text-overlap","text-allow-overlap"),L="always"===R,F=l.aQ(p,"icon-overlap","icon-allow-overlap"),B="always"===F,O="map"===p.get("text-rotation-alignment"),j="map"===p.get("text-pitch-alignment"),G="none"!==p.get("icon-text-fit"),U="viewport-y"===p.get("symbol-z-order"),q=L&&(B||!d.hasIconData()||C),Z=B&&(L||!d.hasTextData()||I);!d.collisionArrays&&T&&d.deserializeCollisionBoxes(T);const W=this.retainedQueryData[d.bucketInstanceId].tileID,J=this._getTerrainElevationFunc(W),re=this.transform.getFastPathSimpleProjectionMatrix(W),se=(e,T,B)=>{var U,se;if(s[e.crossTileID])return;if(b)return void(this.placements[e.crossTileID]=new ht(!1,!1,!1));let oe=!1,le=!1,ce=!0,he=null,ue={box:null,placeable:!1,offscreen:null,occluded:!1},pe={placeable:!1},fe=null,me=null,ge=null,ye=0,xe=0,ve=0;T.textFeatureIndex?ye=T.textFeatureIndex:e.useRuntimeCollisionCircles&&(ye=e.featureIndex),T.verticalTextFeatureIndex&&(xe=T.verticalTextFeatureIndex);const be=T.textBox;if(be){const s=s=>{let c=l.az.horizontal;if(d.allowVerticalPlacement&&!s&&this.prevPlacement){const s=this.prevPlacement.placedOrientations[e.crossTileID];s&&(this.placedOrientations[e.crossTileID]=s,c=s,this.markUsedOrientation(d,c,e))}return c},p=(s,c)=>{if(d.allowVerticalPlacement&&e.numVerticalGlyphVertices>0&&T.verticalTextBox){for(const e of d.writingModes)if(e===l.az.vertical?(ue=c(),pe=ue):ue=s(),ue&&ue.placeable)break}else ue=s()},g=e.textAnchorOffsetStartIndex,b=e.textAnchorOffsetEndIndex;if(b===g){const c=(s,l)=>{const c=this.collisionIndex.placeCollisionBox(s,R,y,W,_,j,O,f,S.predicate,J,void 0,re);return c&&c.placeable&&(this.markUsedOrientation(d,l,e),this.placedOrientations[e.crossTileID]=l),c};p((()=>c(be,l.az.horizontal)),(()=>{const s=T.verticalTextBox;return d.allowVerticalPlacement&&e.numVerticalGlyphVertices>0&&s?c(s,l.az.vertical):{box:null,offscreen:null}})),s(ue&&ue.placeable)}else{let P=l.aP[null===(se=null===(U=this.prevPlacement)||void 0===U?void 0:U.variableOffsets[e.crossTileID])||void 0===se?void 0:se.anchor];const I=(s,l,p)=>{const T=s.x2-s.x1,I=s.y2-s.y1,C=e.textBoxScale,L=G&&"never"===F?l:null;let B=null,U="never"===R?1:2,q="never";P&&U++;for(let l=0;lI(be,T.iconBox,l.az.horizontal)),(()=>{const s=T.verticalTextBox;return d.allowVerticalPlacement&&(!ue||!ue.placeable)&&e.numVerticalGlyphVertices>0&&s?I(s,T.verticalIconBox,l.az.vertical):{box:null,occluded:!0,offscreen:null}})),ue&&(oe=ue.placeable,ce=ue.offscreen);const C=s(ue&&ue.placeable);if(!oe&&this.prevPlacement){const s=this.prevPlacement.variableOffsets[e.crossTileID];s&&(this.variableOffsets[e.crossTileID]=s,this.markUsedJustification(d,s.anchor,e,C))}}}if(fe=ue,oe=fe&&fe.placeable,ce=fe&&fe.offscreen,e.useRuntimeCollisionCircles&&e.centerJustifiedTextSymbolIndex>=0){const s=d.text.placedSymbolArray.get(e.centerJustifiedTextSymbolIndex),m=l.aA(d.textSizeData,P,s),y=p.get("text-padding");me=this.collisionIndex.placeCollisionCircles(R,s,d.lineVertexArray,d.glyphOffsetArray,m,_,g,c,j,S.predicate,e.collisionCircleDiameter,y,f,J),me.circles.length&&me.collisionDetected&&!c&&l.w("Collisions detected, but collision boxes are not shown"),oe=L||me.circles.length>0&&!me.collisionDetected,ce=ce&&me.offscreen}if(T.iconFeatureIndex&&(ve=T.iconFeatureIndex),T.iconBox){const e=e=>this.collisionIndex.placeCollisionBox(e,F,y,W,_,j,O,m,S.predicate,J,G&&he?he:void 0,re);pe&&pe.placeable&&T.verticalIconBox?(ge=e(T.verticalIconBox),le=ge.placeable):(ge=e(T.iconBox),le=ge.placeable),ce=ce&&ge.offscreen}const we=I||0===e.numHorizontalGlyphVertices&&0===e.numVerticalGlyphVertices,Se=C||0===e.numIconVertices;we||Se?Se?we||(le=le&&oe):oe=le&&oe:le=oe=le&&oe;const Me=le&&ge.placeable;if(oe&&fe.placeable&&this.collisionIndex.insertCollisionBox(fe.box,R,p.get("text-ignore-placement"),d.bucketInstanceId,pe&&pe.placeable&&xe?xe:ye,S.ID),Me&&this.collisionIndex.insertCollisionBox(ge.box,F,p.get("icon-ignore-placement"),d.bucketInstanceId,ve,S.ID),me&&oe&&this.collisionIndex.insertCollisionCircles(me.circles,R,p.get("text-ignore-placement"),d.bucketInstanceId,ye,S.ID),c&&this.storeCollisionData(d.bucketInstanceId,B,T,fe,ge,me),0===e.crossTileID)throw new Error("symbolInstance.crossTileID can't be 0");if(0===d.bucketInstanceId)throw new Error("bucket.bucketInstanceId can't be 0");this.placements[e.crossTileID]=new ht((oe||q)&&!(null==fe?void 0:fe.occluded),(le||Z)&&!(null==ge?void 0:ge.occluded),ce||d.justReloaded),s[e.crossTileID]=!0};if(U){if(0!==e.symbolInstanceStart)throw new Error("bucket.bucketInstanceId should be 0");const s=d.getSortedSymbolIndexes(-this.transform.bearingInRadians);for(let e=s.length-1;e>=0;--e){const l=s[e];se(d.symbolInstances.get(l),d.collisionArrays[l],l)}}else for(let s=e.symbolInstanceStart;s=0&&(e.text.placedSymbolArray.get(s).crossTileID=p>=0&&s!==p?0:c.crossTileID)}markUsedOrientation(e,s,c){const d=s===l.az.horizontal||s===l.az.horizontalOnly?s:0,p=s===l.az.vertical?s:0,f=[c.leftJustifiedTextSymbolIndex,c.centerJustifiedTextSymbolIndex,c.rightJustifiedTextSymbolIndex];for(const s of f)e.text.placedSymbolArray.get(s).placedOrientation=d;c.verticalPlacedTextSymbolIndex&&(e.text.placedSymbolArray.get(c.verticalPlacedTextSymbolIndex).placedOrientation=p)}commit(e){this.commitTime=e,this.zoomAtLastRecencyCheck=this.transform.zoom;const s=this.prevPlacement;let l=!1;this.prevZoomAdjustment=s?s.zoomAdjustment(this.transform.zoom):0;const c=s?s.symbolFadeChange(e):1,d=s?s.opacities:{},p=s?s.variableOffsets:{},f=s?s.placedOrientations:{};for(const e in this.placements){const s=this.placements[e],p=d[e];p?(this.opacities[e]=new ct(p,c,s.text,s.icon),l=l||s.text!==p.text.placed||s.icon!==p.icon.placed):(this.opacities[e]=new ct(null,c,s.text,s.icon,s.skipFade),l=l||s.text||s.icon)}for(const e in d){const s=d[e];if(!this.opacities[e]){const d=new ct(s,c,!1,!1);d.isHidden()||(this.opacities[e]=d,l=l||s.text.placed||s.icon.placed)}}for(const e in p)this.variableOffsets[e]||!this.opacities[e]||this.opacities[e].isHidden()||(this.variableOffsets[e]=p[e]);for(const e in f)this.placedOrientations[e]||!this.opacities[e]||this.opacities[e].isHidden()||(this.placedOrientations[e]=f[e]);if(s&&void 0===s.lastPlacementChangeTime)throw new Error("Last placement time for previous placement is not defined");l?this.lastPlacementChangeTime=e:"number"!=typeof this.lastPlacementChangeTime&&(this.lastPlacementChangeTime=s?s.lastPlacementChangeTime:e)}updateLayerOpacities(e,s){const l={};for(const c of s){const s=c.getBucket(e);s&&c.latestFeatureIndex&&e.id===s.layerIds[0]&&this.updateBucketOpacities(s,c.tileID,l,c.collisionBoxArray)}}updateBucketOpacities(e,s,c,d){e.hasTextData()&&(e.text.opacityVertexArray.clear(),e.text.hasVisibleVertices=!1),e.hasIconData()&&(e.icon.opacityVertexArray.clear(),e.icon.hasVisibleVertices=!1),e.hasIconCollisionBoxData()&&e.iconCollisionBox.collisionVertexArray.clear(),e.hasTextCollisionBoxData()&&e.textCollisionBox.collisionVertexArray.clear();const p=e.layers[0],f=p.layout,m=new ct(null,0,!1,!1,!0),_=f.get("text-allow-overlap"),g=f.get("icon-allow-overlap"),y=p._unevaluatedLayout.hasValue("text-variable-anchor")||p._unevaluatedLayout.hasValue("text-variable-anchor-offset"),b="map"===f.get("text-rotation-alignment"),T="map"===f.get("text-pitch-alignment"),P="none"!==f.get("icon-text-fit"),S=new ct(null,0,_&&(g||!e.hasIconData()||f.get("icon-optional")),g&&(_||!e.hasTextData()||f.get("text-optional")),!0);!e.collisionArrays&&d&&(e.hasIconCollisionBoxData()||e.hasTextCollisionBoxData())&&e.deserializeCollisionBoxes(d);const I=(e,s,l)=>{for(let c=0;c0,L=this.placedOrientations[d.crossTileID],F=L===l.az.vertical,B=L===l.az.horizontal||L===l.az.horizontalOnly;if(p>0||f>0){const s=Ai(g.text);I(e.text,p,F?Li:s),I(e.text,f,B?Li:s);const l=g.text.isHidden();[d.rightJustifiedTextSymbolIndex,d.centerJustifiedTextSymbolIndex,d.leftJustifiedTextSymbolIndex].forEach((s=>{s>=0&&(e.text.placedSymbolArray.get(s).hidden=l||F?1:0)})),d.verticalPlacedTextSymbolIndex>=0&&(e.text.placedSymbolArray.get(d.verticalPlacedTextSymbolIndex).hidden=l||B?1:0);const c=this.variableOffsets[d.crossTileID];c&&this.markUsedJustification(e,c.anchor,d,L);const m=this.placedOrientations[d.crossTileID];m&&(this.markUsedJustification(e,"left",d,m),this.markUsedOrientation(e,m,d))}if(R){const s=Ai(g.icon),l=!(P&&d.verticalPlacedIconSymbolIndex&&F);d.placedIconSymbolIndex>=0&&(I(e.icon,d.numIconVertices,l?s:Li),e.icon.placedSymbolArray.get(d.placedIconSymbolIndex).hidden=g.icon.isHidden()),d.verticalPlacedIconSymbolIndex>=0&&(I(e.icon,d.numVerticalIconVertices,l?Li:s),e.icon.placedSymbolArray.get(d.verticalPlacedIconSymbolIndex).hidden=g.icon.isHidden())}const O=C&&C.has(s)?C.get(s):{text:null,icon:null};if(e.hasIconCollisionBoxData()||e.hasTextCollisionBoxData()){const c=e.collisionArrays[s];if(c){let s=new l.P(0,0);if(c.textBox||c.verticalTextBox){let l=!0;if(y){const e=this.variableOffsets[_];e?(s=gi(e.anchor,e.width,e.height,e.textOffset,e.textBoxScale),b&&s._rotate(T?-this.transform.bearingInRadians:this.transform.bearingInRadians)):l=!1}if(c.textBox||c.verticalTextBox){let d;c.textBox&&(d=F),c.verticalTextBox&&(d=B),yi(e.textCollisionBox.collisionVertexArray,g.text.placed,!l||d,O.text,s.x,s.y)}}if(c.iconBox||c.verticalIconBox){const l=Boolean(!B&&c.verticalIconBox);let d;c.iconBox&&(d=l),c.verticalIconBox&&(d=!l),yi(e.iconCollisionBox.collisionVertexArray,g.icon.placed,d,O.icon,P?s.x:0,P?s.y:0)}}}}if(e.sortFeatures(-this.transform.bearingInRadians),this.retainedQueryData[e.bucketInstanceId]&&(this.retainedQueryData[e.bucketInstanceId].featureSortOrder=e.featureSortOrder),e.hasTextData()&&e.text.opacityVertexBuffer&&e.text.opacityVertexBuffer.updateData(e.text.opacityVertexArray),e.hasIconData()&&e.icon.opacityVertexBuffer&&e.icon.opacityVertexBuffer.updateData(e.icon.opacityVertexArray),e.hasIconCollisionBoxData()&&e.iconCollisionBox.collisionVertexBuffer&&e.iconCollisionBox.collisionVertexBuffer.updateData(e.iconCollisionBox.collisionVertexArray),e.hasTextCollisionBoxData()&&e.textCollisionBox.collisionVertexBuffer&&e.textCollisionBox.collisionVertexBuffer.updateData(e.textCollisionBox.collisionVertexArray),e.text.opacityVertexArray.length!==e.text.layoutVertexArray.length/4)throw new Error(`bucket.text.opacityVertexArray.length (= ${e.text.opacityVertexArray.length}) !== bucket.text.layoutVertexArray.length (= ${e.text.layoutVertexArray.length}) / 4`);if(e.icon.opacityVertexArray.length!==e.icon.layoutVertexArray.length/4)throw new Error(`bucket.icon.opacityVertexArray.length (= ${e.icon.opacityVertexArray.length}) !== bucket.icon.layoutVertexArray.length (= ${e.icon.layoutVertexArray.length}) / 4`);e.bucketInstanceId in this.collisionCircleArrays&&(e.collisionCircleArray=this.collisionCircleArrays[e.bucketInstanceId],delete this.collisionCircleArrays[e.bucketInstanceId])}symbolFadeChange(e){return 0===this.fadeDuration?1:(e-this.commitTime)/this.fadeDuration+this.prevZoomAdjustment}zoomAdjustment(e){return Math.max(0,(this.transform.zoom-e)/1.5)}hasTransitions(e){return this.stale||e-this.lastPlacementChangeTimee}setStale(){this.stale=!0}}function yi(e,s,l,c,d,p){c&&0!==c.length||(c=[0,0,0,0]);const f=c[0]-_i,m=c[1]-_i,_=c[2]-_i,g=c[3]-_i;e.emplaceBack(s?1:0,l?1:0,d||0,p||0,f,m),e.emplaceBack(s?1:0,l?1:0,d||0,p||0,_,m),e.emplaceBack(s?1:0,l?1:0,d||0,p||0,_,g),e.emplaceBack(s?1:0,l?1:0,d||0,p||0,f,g)}const xi=Math.pow(2,25),vi=Math.pow(2,24),bi=Math.pow(2,17),wi=Math.pow(2,16),Ii=Math.pow(2,9),Ei=Math.pow(2,8),Ci=Math.pow(2,1);function Ai(e){if(0===e.opacity&&!e.placed)return 0;if(1===e.opacity&&e.placed)return 4294967295;const s=e.placed?1:0,l=Math.floor(127*e.opacity);return l*xi+s*vi+l*bi+s*wi+l*Ii+s*Ei+l*Ci+s}const Li=0;class Ct{constructor(e){this._sortAcrossTiles="viewport-y"!==e.layout.get("symbol-z-order")&&!e.layout.get("symbol-sort-key").isConstant(),this._currentTileIndex=0,this._currentPartIndex=0,this._seenCrossTileIDs={},this._bucketParts=[]}continuePlacement(e,s,l,c,d){const p=this._bucketParts;for(;this._currentTileIndexe.sortKey-s.sortKey)));this._currentPartIndex!this._forceFullPlacement&&y()-c>2;for(;this._currentPlacementIndex>=0;){const c=s[e[this._currentPlacementIndex]],p=this.placement.collisionIndex.transform.zoom;if("symbol"===c.type&&(!c.minzoom||c.minzoom<=p)&&(!c.maxzoom||c.maxzoom>p)){if(this._inProgressLayer||(this._inProgressLayer=new Ct(c)),this._inProgressLayer.continuePlacement(l[c.source],this.placement,this._showCollisionBoxes,c,d))return;delete this._inProgressLayer}this._currentPlacementIndex--}this._done=!0}commit(e){return this.placement.commit(e),this.placement}}const Fi=512/l.a5/2;class Et{constructor(e,s,c){this.tileID=e,this.bucketInstanceId=c,this._symbolsByKey={};const d=new Map;for(let e=0;e({x:Math.floor(e.anchorX*Fi),y:Math.floor(e.anchorY*Fi)}))),crossTileIDs:s.map((e=>e.crossTileID))};if(c.positions.length>128){const e=new l.aT(c.positions.length,16,Uint16Array);for(const{x:s,y:l}of c.positions)e.add(s,l);e.finish(),delete c.positions,c.index=e}this._symbolsByKey[e]=c}}getScaledCoordinates(e,s){const{x:c,y:d,z:p}=this.tileID.canonical,{x:f,y:m,z:_}=s.canonical,g=Fi/Math.pow(2,_-p),y=(m*l.a5+e.anchorY)*g,b=d*l.a5*Fi;return{x:Math.floor((f*l.a5+e.anchorX)*g-c*l.a5*Fi),y:Math.floor(y-b)}}findMatches(e,s,l){const c=this.tileID.canonical.ze))}}class St{constructor(){this.maxCrossTileID=0}generate(){return++this.maxCrossTileID}}class zt{constructor(){this.indexes={},this.usedCrossTileIDs={},this.lng=0}handleWrapJump(e){const s=Math.round((e-this.lng)/360);if(0!==s)for(const e in this.indexes){const l=this.indexes[e],c={};for(const e in l){const d=l[e];d.tileID=d.tileID.unwrapTo(d.tileID.wrap+s),c[d.tileID.key]=d}this.indexes[e]=c}this.lng=e}addBucket(e,s,l){if(this.indexes[e.overscaledZ]&&this.indexes[e.overscaledZ][e.key]){if(this.indexes[e.overscaledZ][e.key].bucketInstanceId===s.bucketInstanceId)return!1;this.removeBucketCrossTileIDs(e.overscaledZ,this.indexes[e.overscaledZ][e.key])}for(let e=0;ee.overscaledZ)for(const l in d){const p=d[l];p.tileID.isChildOf(e)&&p.findMatches(s.symbolInstances,e,c)}else{const p=d[e.scaledTo(Number(l)).key];p&&p.findMatches(s.symbolInstances,e,c)}}for(let e=0;e{s[e]=!0}));for(const e in this.layerIndexes)s[e]||delete this.layerIndexes[e]}}var Oi="void main() {fragColor=vec4(1.0);}";const Vi={prelude:ji("#ifdef GL_ES\nprecision mediump float;\n#else\n#if !defined(lowp)\n#define lowp\n#endif\n#if !defined(mediump)\n#define mediump\n#endif\n#if !defined(highp)\n#define highp\n#endif\n#endif\nout highp vec4 fragColor;","#ifdef GL_ES\nprecision highp float;\n#else\n#if !defined(lowp)\n#define lowp\n#endif\n#if !defined(mediump)\n#define mediump\n#endif\n#if !defined(highp)\n#define highp\n#endif\n#endif\nvec2 unpack_float(const float packedValue) {int packedIntValue=int(packedValue);int v0=packedIntValue/256;return vec2(v0,packedIntValue-v0*256);}vec2 unpack_opacity(const float packedOpacity) {int intOpacity=int(packedOpacity)/2;return vec2(float(intOpacity)/127.0,mod(packedOpacity,2.0));}vec4 decode_color(const vec2 encodedColor) {return vec4(unpack_float(encodedColor[0])/255.0,unpack_float(encodedColor[1])/255.0\n);}float unpack_mix_vec2(const vec2 packedValue,const float t) {return mix(packedValue[0],packedValue[1],t);}vec4 unpack_mix_color(const vec4 packedColors,const float t) {vec4 minColor=decode_color(vec2(packedColors[0],packedColors[1]));vec4 maxColor=decode_color(vec2(packedColors[2],packedColors[3]));return mix(minColor,maxColor,t);}vec2 get_pattern_pos(const vec2 pixel_coord_upper,const vec2 pixel_coord_lower,const vec2 pattern_size,const float tile_units_to_pixels,const vec2 pos) {vec2 offset=mod(mod(mod(pixel_coord_upper,pattern_size)*256.0,pattern_size)*256.0+pixel_coord_lower,pattern_size);return (tile_units_to_pixels*pos+offset)/pattern_size;}mat3 rotationMatrixFromAxisAngle(vec3 u,float angle) {float c=cos(angle);float s=sin(angle);float c2=1.0-c;return mat3(u.x*u.x*c2+ c,u.x*u.y*c2-u.z*s,u.x*u.z*c2+u.y*s,u.y*u.x*c2+u.z*s,u.y*u.y*c2+ c,u.y*u.z*c2-u.x*s,u.z*u.x*c2-u.y*s,u.z*u.y*c2+u.x*s,u.z*u.z*c2+ c\n);}\n#ifdef TERRAIN3D\nuniform sampler2D u_terrain;uniform float u_terrain_dim;uniform mat4 u_terrain_matrix;uniform vec4 u_terrain_unpack;uniform float u_terrain_exaggeration;uniform highp sampler2D u_depth;\n#endif\nconst highp vec4 bitSh=vec4(256.*256.*256.,256.*256.,256.,1.);const highp vec4 bitShifts=vec4(1.)/bitSh;highp float unpack(highp vec4 color) {return dot(color,bitShifts);}highp float depthOpacity(vec3 frag) {\n#ifdef TERRAIN3D\nhighp float d=unpack(texture(u_depth,frag.xy*0.5+0.5))+0.0001-frag.z;return 1.0-max(0.0,min(1.0,-d*500.0));\n#else\nreturn 1.0;\n#endif\n}float calculate_visibility(vec4 pos) {\n#ifdef TERRAIN3D\nvec3 frag=pos.xyz/pos.w;highp float d=depthOpacity(frag);if (d > 0.95) return 1.0;return (d+depthOpacity(frag+vec3(0.0,0.01,0.0)))/2.0;\n#else\nreturn 1.0;\n#endif\n}float ele(vec2 pos) {\n#ifdef TERRAIN3D\nvec4 rgb=(texture(u_terrain,pos)*255.0)*u_terrain_unpack;return rgb.r+rgb.g+rgb.b-u_terrain_unpack.a;\n#else\nreturn 0.0;\n#endif\n}float get_elevation(vec2 pos) {\n#ifdef TERRAIN3D\n#ifdef GLOBE\nif ((pos.y <-32767.5) || (pos.y > 32766.5)) {return 0.0;}\n#endif\nvec2 coord=(u_terrain_matrix*vec4(pos,0.0,1.0)).xy*u_terrain_dim+1.0;vec2 f=fract(coord);vec2 c=(floor(coord)+0.5)/(u_terrain_dim+2.0);float d=1.0/(u_terrain_dim+2.0);float tl=ele(c);float tr=ele(c+vec2(d,0.0));float bl=ele(c+vec2(0.0,d));float br=ele(c+vec2(d,d));float elevation=mix(mix(tl,tr,f.x),mix(bl,br,f.x),f.y);return elevation*u_terrain_exaggeration;\n#else\nreturn 0.0;\n#endif\n}const float PI=3.141592653589793;uniform mat4 u_projection_matrix;"),projectionMercator:ji("","float projectLineThickness(float tileY) {return 1.0;}float projectCircleRadius(float tileY) {return 1.0;}vec4 projectTile(vec2 p) {vec4 result=u_projection_matrix*vec4(p,0.0,1.0);return result;}vec4 projectTile(vec2 p,vec2 rawPos) {vec4 result=u_projection_matrix*vec4(p,0.0,1.0);if (rawPos.y <-32767.5 || rawPos.y > 32766.5) {result.z=-10000000.0;}return result;}vec4 projectTileWithElevation(vec2 posInTile,float elevation) {return u_projection_matrix*vec4(posInTile,elevation,1.0);}vec4 projectTileFor3D(vec2 posInTile,float elevation) {return projectTileWithElevation(posInTile,elevation);}"),projectionGlobe:ji("","#define GLOBE_RADIUS 6371008.8\nuniform highp vec4 u_projection_tile_mercator_coords;uniform highp vec4 u_projection_clipping_plane;uniform highp float u_projection_transition;uniform mat4 u_projection_fallback_matrix;vec3 globeRotateVector(vec3 vec,vec2 angles) {vec3 axisRight=vec3(vec.z,0.0,-vec.x);vec3 axisUp=cross(axisRight,vec);axisRight=normalize(axisRight);axisUp=normalize(axisUp);vec2 t=tan(angles);return normalize(vec+axisRight*t.x+axisUp*t.y);}mat3 globeGetRotationMatrix(vec3 spherePos) {vec3 axisRight=vec3(spherePos.z,0.0,-spherePos.x);vec3 axisDown=cross(axisRight,spherePos);axisRight=normalize(axisRight);axisDown=normalize(axisDown);return mat3(axisRight,axisDown,spherePos\n);}float circumferenceRatioAtTileY(float tileY) {float mercator_pos_y=u_projection_tile_mercator_coords.y+u_projection_tile_mercator_coords.w*tileY;float spherical_y=2.0*atan(exp(PI-(mercator_pos_y*PI*2.0)))-PI*0.5;return cos(spherical_y);}float projectLineThickness(float tileY) {float thickness=1.0/circumferenceRatioAtTileY(tileY); \nif (u_projection_transition < 0.999) {return mix(1.0,thickness,u_projection_transition);} else {return thickness;}}vec3 projectToSphere(vec2 translatedPos,vec2 rawPos) {vec2 mercator_pos=u_projection_tile_mercator_coords.xy+u_projection_tile_mercator_coords.zw*translatedPos;vec2 spherical;spherical.x=mercator_pos.x*PI*2.0+PI;spherical.y=2.0*atan(exp(PI-(mercator_pos.y*PI*2.0)))-PI*0.5;float len=cos(spherical.y);vec3 pos=vec3(sin(spherical.x)*len,sin(spherical.y),cos(spherical.x)*len\n);if (rawPos.y <-32767.5) {pos=vec3(0.0,1.0,0.0);}if (rawPos.y > 32766.5) {pos=vec3(0.0,-1.0,0.0);}return pos;}vec3 projectToSphere(vec2 posInTile) {return projectToSphere(posInTile,vec2(0.0,0.0));}float globeComputeClippingZ(vec3 spherePos) {return (1.0-(dot(spherePos,u_projection_clipping_plane.xyz)+u_projection_clipping_plane.w));}vec4 interpolateProjection(vec2 posInTile,vec3 spherePos,float elevation) {vec3 elevatedPos=spherePos*(1.0+elevation/GLOBE_RADIUS);vec4 globePosition=u_projection_matrix*vec4(elevatedPos,1.0);globePosition.z=globeComputeClippingZ(elevatedPos)*globePosition.w;if (u_projection_transition > 0.999) {return globePosition;}vec4 flatPosition=u_projection_fallback_matrix*vec4(posInTile,elevation,1.0);const float z_globeness_threshold=0.2;vec4 result=globePosition;result.z=mix(0.0,globePosition.z,clamp((u_projection_transition-z_globeness_threshold)/(1.0-z_globeness_threshold),0.0,1.0));result.xyw=mix(flatPosition.xyw,globePosition.xyw,u_projection_transition);if ((posInTile.y <-32767.5) || (posInTile.y > 32766.5)) {result=globePosition;const float poles_hidden_anim_percentage=0.02;result.z=mix(globePosition.z,100.0,pow(max((1.0-u_projection_transition)/poles_hidden_anim_percentage,0.0),8.0));}return result;}vec4 interpolateProjectionFor3D(vec2 posInTile,vec3 spherePos,float elevation) {vec3 elevatedPos=spherePos*(1.0+elevation/GLOBE_RADIUS);vec4 globePosition=u_projection_matrix*vec4(elevatedPos,1.0);if (u_projection_transition > 0.999) {return globePosition;}vec4 fallbackPosition=u_projection_fallback_matrix*vec4(posInTile,elevation,1.0);return mix(fallbackPosition,globePosition,u_projection_transition);}vec4 projectTile(vec2 posInTile) {return interpolateProjection(posInTile,projectToSphere(posInTile),0.0);}vec4 projectTile(vec2 posInTile,vec2 rawPos) {return interpolateProjection(posInTile,projectToSphere(posInTile,rawPos),0.0);}vec4 projectTileWithElevation(vec2 posInTile,float elevation) {return interpolateProjection(posInTile,projectToSphere(posInTile),elevation);}vec4 projectTileFor3D(vec2 posInTile,float elevation) {vec3 spherePos=projectToSphere(posInTile,posInTile);return interpolateProjectionFor3D(posInTile,spherePos,elevation);}"),background:ji("uniform vec4 u_color;uniform float u_opacity;void main() {fragColor=u_color*u_opacity;\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","in vec2 a_pos;void main() {gl_Position=projectTile(a_pos);}"),backgroundPattern:ji("uniform vec2 u_pattern_tl_a;uniform vec2 u_pattern_br_a;uniform vec2 u_pattern_tl_b;uniform vec2 u_pattern_br_b;uniform vec2 u_texsize;uniform float u_mix;uniform float u_opacity;uniform sampler2D u_image;in vec2 v_pos_a;in vec2 v_pos_b;void main() {vec2 imagecoord=mod(v_pos_a,1.0);vec2 pos=mix(u_pattern_tl_a/u_texsize,u_pattern_br_a/u_texsize,imagecoord);vec4 color1=texture(u_image,pos);vec2 imagecoord_b=mod(v_pos_b,1.0);vec2 pos2=mix(u_pattern_tl_b/u_texsize,u_pattern_br_b/u_texsize,imagecoord_b);vec4 color2=texture(u_image,pos2);fragColor=mix(color1,color2,u_mix)*u_opacity;\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","uniform vec2 u_pattern_size_a;uniform vec2 u_pattern_size_b;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform float u_scale_a;uniform float u_scale_b;uniform float u_tile_units_to_pixels;in vec2 a_pos;out vec2 v_pos_a;out vec2 v_pos_b;void main() {gl_Position=projectTile(a_pos);v_pos_a=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,u_scale_a*u_pattern_size_a,u_tile_units_to_pixels,a_pos);v_pos_b=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,u_scale_b*u_pattern_size_b,u_tile_units_to_pixels,a_pos);}"),circle:ji("in vec3 v_data;in float v_visibility;\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define mediump float radius\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define highp vec4 stroke_color\n#pragma mapbox: define mediump float stroke_width\n#pragma mapbox: define lowp float stroke_opacity\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize mediump float radius\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize highp vec4 stroke_color\n#pragma mapbox: initialize mediump float stroke_width\n#pragma mapbox: initialize lowp float stroke_opacity\nvec2 extrude=v_data.xy;float extrude_length=length(extrude);float antialiased_blur=v_data.z;float opacity_t=smoothstep(0.0,antialiased_blur,extrude_length-1.0);float color_t=stroke_width < 0.01 ? 0.0 : smoothstep(antialiased_blur,0.0,extrude_length-radius/(radius+stroke_width));fragColor=v_visibility*opacity_t*mix(color*opacity,stroke_color*stroke_opacity,color_t);const float epsilon=0.5/255.0;if (fragColor.r < epsilon && fragColor.g < epsilon && fragColor.b < epsilon && fragColor.a < epsilon) {discard;}\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","uniform bool u_scale_with_map;uniform bool u_pitch_with_map;uniform vec2 u_extrude_scale;uniform highp float u_globe_extrude_scale;uniform lowp float u_device_pixel_ratio;uniform highp float u_camera_to_center_distance;uniform vec2 u_translate;in vec2 a_pos;out vec3 v_data;out float v_visibility;\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define mediump float radius\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define highp vec4 stroke_color\n#pragma mapbox: define mediump float stroke_width\n#pragma mapbox: define lowp float stroke_opacity\nvoid main(void) {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize mediump float radius\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize highp vec4 stroke_color\n#pragma mapbox: initialize mediump float stroke_width\n#pragma mapbox: initialize lowp float stroke_opacity\nvec2 pos_raw=a_pos+32768.0;vec2 extrude=vec2(mod(pos_raw,8.0)/7.0*2.0-1.0);vec2 circle_center=floor(pos_raw/8.0)+u_translate;float ele=get_elevation(circle_center);v_visibility=calculate_visibility(projectTileWithElevation(circle_center,ele));if (u_pitch_with_map) {\n#ifdef GLOBE\nvec3 center_vector=projectToSphere(circle_center);\n#endif\nfloat angle_scale=u_globe_extrude_scale;vec2 corner_position=circle_center;if (u_scale_with_map) {angle_scale*=(radius+stroke_width);corner_position+=extrude*u_extrude_scale*(radius+stroke_width);} else {\n#ifdef GLOBE\nvec4 projected_center=interpolateProjection(circle_center,center_vector,ele);\n#else\nvec4 projected_center=projectTileWithElevation(circle_center,ele);\n#endif\ncorner_position+=extrude*u_extrude_scale*(radius+stroke_width)*(projected_center.w/u_camera_to_center_distance);angle_scale*=(radius+stroke_width)*(projected_center.w/u_camera_to_center_distance);}\n#ifdef GLOBE\nvec2 angles=extrude*angle_scale;vec3 corner_vector=globeRotateVector(center_vector,angles);gl_Position=interpolateProjection(corner_position,corner_vector,ele);\n#else\ngl_Position=projectTileWithElevation(corner_position,ele);\n#endif\n} else {gl_Position=projectTileWithElevation(circle_center,ele);if (gl_Position.z/gl_Position.w > 1.0) {gl_Position.xy=vec2(10000.0);}if (u_scale_with_map) {gl_Position.xy+=extrude*(radius+stroke_width)*u_extrude_scale*u_camera_to_center_distance;} else {gl_Position.xy+=extrude*(radius+stroke_width)*u_extrude_scale*gl_Position.w;}}float antialiasblur=-max(1.0/u_device_pixel_ratio/(radius+stroke_width),blur);v_data=vec3(extrude.x,extrude.y,antialiasblur);}"),clippingMask:ji(Oi,"in vec2 a_pos;void main() {gl_Position=projectTile(a_pos);}"),heatmap:ji("uniform highp float u_intensity;in vec2 v_extrude;\n#pragma mapbox: define highp float weight\n#define GAUSS_COEF 0.3989422804014327\nvoid main() {\n#pragma mapbox: initialize highp float weight\nfloat d=-0.5*3.0*3.0*dot(v_extrude,v_extrude);float val=weight*u_intensity*GAUSS_COEF*exp(d);fragColor=vec4(val,1.0,1.0,1.0);\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","uniform float u_extrude_scale;uniform float u_opacity;uniform float u_intensity;uniform highp float u_globe_extrude_scale;in vec2 a_pos;out vec2 v_extrude;\n#pragma mapbox: define highp float weight\n#pragma mapbox: define mediump float radius\nconst highp float ZERO=1.0/255.0/16.0;\n#define GAUSS_COEF 0.3989422804014327\nvoid main(void) {\n#pragma mapbox: initialize highp float weight\n#pragma mapbox: initialize mediump float radius\nvec2 pos_raw=a_pos+32768.0;vec2 unscaled_extrude=vec2(mod(pos_raw,8.0)/7.0*2.0-1.0);float S=sqrt(-2.0*log(ZERO/weight/u_intensity/GAUSS_COEF))/3.0;v_extrude=S*unscaled_extrude;vec2 extrude=v_extrude*radius*u_extrude_scale;vec2 circle_center=floor(pos_raw/8.0);\n#ifdef GLOBE\nvec2 angles=v_extrude*radius*u_globe_extrude_scale;vec3 center_vector=projectToSphere(circle_center);vec3 corner_vector=globeRotateVector(center_vector,angles);gl_Position=interpolateProjection(circle_center+extrude,corner_vector,0.0);\n#else\ngl_Position=projectTileFor3D(circle_center+extrude,get_elevation(circle_center));\n#endif\n}"),heatmapTexture:ji("uniform sampler2D u_image;uniform sampler2D u_color_ramp;uniform float u_opacity;in vec2 v_pos;void main() {float t=texture(u_image,v_pos).r;vec4 color=texture(u_color_ramp,vec2(t,0.5));fragColor=color*u_opacity;\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(0.0);\n#endif\n}","uniform mat4 u_matrix;uniform vec2 u_world;in vec2 a_pos;out vec2 v_pos;void main() {gl_Position=u_matrix*vec4(a_pos*u_world,0,1);v_pos.x=a_pos.x;v_pos.y=1.0-a_pos.y;}"),collisionBox:ji("in float v_placed;in float v_notUsed;void main() {float alpha=0.5;fragColor=vec4(1.0,0.0,0.0,1.0)*alpha;if (v_placed > 0.5) {fragColor=vec4(0.0,0.0,1.0,0.5)*alpha;}if (v_notUsed > 0.5) {fragColor*=.1;}}","in vec2 a_anchor_pos;in vec2 a_placed;in vec2 a_box_real;uniform vec2 u_pixel_extrude_scale;out float v_placed;out float v_notUsed;void main() {gl_Position=projectTileWithElevation(a_anchor_pos,get_elevation(a_anchor_pos));gl_Position.xy=((a_box_real+0.5)*u_pixel_extrude_scale*2.0-1.0)*vec2(1.0,-1.0)*gl_Position.w;if (gl_Position.z/gl_Position.w < 1.1) {gl_Position.z=0.5;}v_placed=a_placed.x;v_notUsed=a_placed.y;}"),collisionCircle:ji("in float v_radius;in vec2 v_extrude;in float v_collision;void main() {float alpha=0.5;float stroke_radius=0.9;float distance_to_center=length(v_extrude);float distance_to_edge=abs(distance_to_center-v_radius);float opacity_t=smoothstep(-stroke_radius,0.0,-distance_to_edge);vec4 color=mix(vec4(0.0,0.0,1.0,0.5),vec4(1.0,0.0,0.0,1.0),v_collision);fragColor=color*alpha*opacity_t;}","in vec2 a_pos;in float a_radius;in vec2 a_flags;uniform vec2 u_viewport_size;out float v_radius;out vec2 v_extrude;out float v_collision;void main() {float radius=a_radius;float collision=a_flags.x;float vertexIdx=a_flags.y;vec2 quadVertexOffset=vec2(mix(-1.0,1.0,float(vertexIdx >=2.0)),mix(-1.0,1.0,float(vertexIdx >=1.0 && vertexIdx <=2.0)));vec2 quadVertexExtent=quadVertexOffset*radius;float padding_factor=1.2;v_radius=radius;v_extrude=quadVertexExtent*padding_factor;v_collision=collision;gl_Position=vec4((a_pos/u_viewport_size*2.0-1.0)*vec2(1.0,-1.0),0.0,1.0)+vec4(quadVertexExtent*padding_factor/u_viewport_size*2.0,0.0,0.0);}"),colorRelief:ji("#ifdef GL_ES\nprecision highp float;\n#endif\nuniform sampler2D u_image;uniform vec4 u_unpack;uniform sampler2D u_elevation_stops;uniform sampler2D u_color_stops;uniform int u_color_ramp_size;uniform float u_opacity;in vec2 v_pos;float getElevation(vec2 coord) {vec4 data=texture(u_image,coord)*255.0;data.a=-1.0;return dot(data,u_unpack);}float getElevationStop(int stop) {float x=(float(stop)+0.5)/float(u_color_ramp_size);vec4 data=texture(u_elevation_stops,vec2(x,0))*255.0;data.a=-1.0;return dot(data,u_unpack);}void main() {float el=getElevation(v_pos);int r=(u_color_ramp_size-1);int l=0;float el_l=getElevationStop(l);float el_r=getElevationStop(r);while(r-l > 1){int m=(r+l)/2;float el_m=getElevationStop(m);if(el < el_m){r=m;el_r=el_m;}else\n{l=m;el_l=el_m;}}float x=(float(l)+(el-el_l)/(el_r-el_l)+0.5)/float(u_color_ramp_size);fragColor=u_opacity*texture(u_color_stops,vec2(x,0));\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","uniform vec2 u_dimension;in vec2 a_pos;out vec2 v_pos;void main() {gl_Position=projectTile(a_pos,a_pos);highp vec2 epsilon=1.0/u_dimension;float scale=(u_dimension.x-2.0)/u_dimension.x;v_pos=(a_pos/8192.0)*scale+epsilon;if (a_pos.y <-32767.5) {v_pos.y=0.0;}if (a_pos.y > 32766.5) {v_pos.y=1.0;}}"),debug:ji("uniform highp vec4 u_color;uniform sampler2D u_overlay;in vec2 v_uv;void main() {vec4 overlay_color=texture(u_overlay,v_uv);fragColor=mix(u_color,overlay_color,overlay_color.a);}","in vec2 a_pos;out vec2 v_uv;uniform float u_overlay_scale;void main() {v_uv=a_pos/8192.0;gl_Position=projectTileWithElevation(a_pos*u_overlay_scale,get_elevation(a_pos));}"),depth:ji(Oi,"in vec2 a_pos;void main() {\n#ifdef GLOBE\ngl_Position=projectTileFor3D(a_pos,0.0);\n#else\ngl_Position=u_projection_matrix*vec4(a_pos,0.0,1.0);\n#endif\n}"),fill:ji("#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize lowp float opacity\nfragColor=color*opacity;\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","uniform vec2 u_fill_translate;in vec2 a_pos;\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize lowp float opacity\ngl_Position=projectTile(a_pos+u_fill_translate,a_pos);}"),fillOutline:ji("in vec2 v_pos;\n#ifdef GLOBE\nin float v_depth;\n#endif\n#pragma mapbox: define highp vec4 outline_color\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize highp vec4 outline_color\n#pragma mapbox: initialize lowp float opacity\nfloat dist=length(v_pos-gl_FragCoord.xy);float alpha=1.0-smoothstep(0.0,1.0,dist);fragColor=outline_color*(alpha*opacity);\n#ifdef GLOBE\nif (v_depth > 1.0) {discard;}\n#endif\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","uniform vec2 u_world;uniform vec2 u_fill_translate;in vec2 a_pos;out vec2 v_pos;\n#ifdef GLOBE\nout float v_depth;\n#endif\n#pragma mapbox: define highp vec4 outline_color\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize highp vec4 outline_color\n#pragma mapbox: initialize lowp float opacity\ngl_Position=projectTile(a_pos+u_fill_translate,a_pos);v_pos=(gl_Position.xy/gl_Position.w+1.0)/2.0*u_world;\n#ifdef GLOBE\nv_depth=gl_Position.z/gl_Position.w;\n#endif\n}"),fillOutlinePattern:ji("uniform vec2 u_texsize;uniform sampler2D u_image;uniform float u_fade;in vec2 v_pos_a;in vec2 v_pos_b;in vec2 v_pos;\n#ifdef GLOBE\nin float v_depth;\n#endif\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;vec2 imagecoord=mod(v_pos_a,1.0);vec2 pos=mix(pattern_tl_a/u_texsize,pattern_br_a/u_texsize,imagecoord);vec4 color1=texture(u_image,pos);vec2 imagecoord_b=mod(v_pos_b,1.0);vec2 pos2=mix(pattern_tl_b/u_texsize,pattern_br_b/u_texsize,imagecoord_b);vec4 color2=texture(u_image,pos2);float dist=length(v_pos-gl_FragCoord.xy);float alpha=1.0-smoothstep(0.0,1.0,dist);fragColor=mix(color1,color2,u_fade)*alpha*opacity;\n#ifdef GLOBE\nif (v_depth > 1.0) {discard;}\n#endif\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","uniform vec2 u_world;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform vec3 u_scale;uniform vec2 u_fill_translate;in vec2 a_pos;out vec2 v_pos_a;out vec2 v_pos_b;out vec2 v_pos;\n#ifdef GLOBE\nout float v_depth;\n#endif\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\n#pragma mapbox: define lowp float pixel_ratio_from\n#pragma mapbox: define lowp float pixel_ratio_to\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\n#pragma mapbox: initialize lowp float pixel_ratio_from\n#pragma mapbox: initialize lowp float pixel_ratio_to\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;float tileRatio=u_scale.x;float fromScale=u_scale.y;float toScale=u_scale.z;gl_Position=projectTile(a_pos+u_fill_translate,a_pos);vec2 display_size_a=(pattern_br_a-pattern_tl_a)/pixel_ratio_from;vec2 display_size_b=(pattern_br_b-pattern_tl_b)/pixel_ratio_to;v_pos_a=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,fromScale*display_size_a,tileRatio,a_pos);v_pos_b=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,toScale*display_size_b,tileRatio,a_pos);v_pos=(gl_Position.xy/gl_Position.w+1.0)/2.0*u_world;\n#ifdef GLOBE\nv_depth=gl_Position.z/gl_Position.w;\n#endif\n}"),fillPattern:ji("#ifdef GL_ES\nprecision highp float;\n#endif\nuniform vec2 u_texsize;uniform float u_fade;uniform sampler2D u_image;in vec2 v_pos_a;in vec2 v_pos_b;\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;vec2 imagecoord=mod(v_pos_a,1.0);vec2 pos=mix(pattern_tl_a/u_texsize,pattern_br_a/u_texsize,imagecoord);vec4 color1=texture(u_image,pos);vec2 imagecoord_b=mod(v_pos_b,1.0);vec2 pos2=mix(pattern_tl_b/u_texsize,pattern_br_b/u_texsize,imagecoord_b);vec4 color2=texture(u_image,pos2);fragColor=mix(color1,color2,u_fade)*opacity;\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform vec3 u_scale;uniform vec2 u_fill_translate;in vec2 a_pos;out vec2 v_pos_a;out vec2 v_pos_b;\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\n#pragma mapbox: define lowp float pixel_ratio_from\n#pragma mapbox: define lowp float pixel_ratio_to\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\n#pragma mapbox: initialize lowp float pixel_ratio_from\n#pragma mapbox: initialize lowp float pixel_ratio_to\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;float tileZoomRatio=u_scale.x;float fromScale=u_scale.y;float toScale=u_scale.z;vec2 display_size_a=(pattern_br_a-pattern_tl_a)/pixel_ratio_from;vec2 display_size_b=(pattern_br_b-pattern_tl_b)/pixel_ratio_to;gl_Position=projectTile(a_pos+u_fill_translate,a_pos);v_pos_a=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,fromScale*display_size_a,tileZoomRatio,a_pos);v_pos_b=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,toScale*display_size_b,tileZoomRatio,a_pos);}"),fillExtrusion:ji("in vec4 v_color;void main() {fragColor=v_color;\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","uniform vec3 u_lightcolor;uniform lowp vec3 u_lightpos;uniform lowp vec3 u_lightpos_globe;uniform lowp float u_lightintensity;uniform float u_vertical_gradient;uniform lowp float u_opacity;uniform vec2 u_fill_translate;in vec2 a_pos;in vec4 a_normal_ed;\n#ifdef TERRAIN3D\nin vec2 a_centroid;\n#endif\nout vec4 v_color;\n#pragma mapbox: define highp float base\n#pragma mapbox: define highp float height\n#pragma mapbox: define highp vec4 color\nvoid main() {\n#pragma mapbox: initialize highp float base\n#pragma mapbox: initialize highp float height\n#pragma mapbox: initialize highp vec4 color\nvec3 normal=a_normal_ed.xyz;\n#ifdef TERRAIN3D\nfloat height_terrain3d_offset=get_elevation(a_centroid);float base_terrain3d_offset=height_terrain3d_offset-(base > 0.0 ? 0.0 : 10.0);\n#else\nfloat height_terrain3d_offset=0.0;float base_terrain3d_offset=0.0;\n#endif\nbase=max(0.0,base)+base_terrain3d_offset;height=max(0.0,height)+height_terrain3d_offset;float t=mod(normal.x,2.0);float elevation=t > 0.0 ? height : base;vec2 posInTile=a_pos+u_fill_translate;\n#ifdef GLOBE\nvec3 spherePos=projectToSphere(posInTile,a_pos);gl_Position=interpolateProjectionFor3D(posInTile,spherePos,elevation);\n#else\ngl_Position=u_projection_matrix*vec4(posInTile,elevation,1.0);\n#endif\nfloat colorvalue=color.r*0.2126+color.g*0.7152+color.b*0.0722;v_color=vec4(0.0,0.0,0.0,1.0);vec4 ambientlight=vec4(0.03,0.03,0.03,1.0);color+=ambientlight;vec3 normalForLighting=normal/16384.0;float directional=clamp(dot(normalForLighting,u_lightpos),0.0,1.0);\n#ifdef GLOBE\nmat3 rotMatrix=globeGetRotationMatrix(spherePos);normalForLighting=rotMatrix*normalForLighting;directional=mix(directional,clamp(dot(normalForLighting,u_lightpos_globe),0.0,1.0),u_projection_transition);\n#endif\ndirectional=mix((1.0-u_lightintensity),max((1.0-colorvalue+u_lightintensity),1.0),directional);if (normal.y !=0.0) {directional*=((1.0-u_vertical_gradient)+(u_vertical_gradient*clamp((t+base)*pow(height/150.0,0.5),mix(0.7,0.98,1.0-u_lightintensity),1.0)));}v_color.r+=clamp(color.r*directional*u_lightcolor.r,mix(0.0,0.3,1.0-u_lightcolor.r),1.0);v_color.g+=clamp(color.g*directional*u_lightcolor.g,mix(0.0,0.3,1.0-u_lightcolor.g),1.0);v_color.b+=clamp(color.b*directional*u_lightcolor.b,mix(0.0,0.3,1.0-u_lightcolor.b),1.0);v_color*=u_opacity;}"),fillExtrusionPattern:ji("uniform vec2 u_texsize;uniform float u_fade;uniform sampler2D u_image;in vec2 v_pos_a;in vec2 v_pos_b;in vec4 v_lighting;\n#pragma mapbox: define lowp float base\n#pragma mapbox: define lowp float height\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\n#pragma mapbox: define lowp float pixel_ratio_from\n#pragma mapbox: define lowp float pixel_ratio_to\nvoid main() {\n#pragma mapbox: initialize lowp float base\n#pragma mapbox: initialize lowp float height\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\n#pragma mapbox: initialize lowp float pixel_ratio_from\n#pragma mapbox: initialize lowp float pixel_ratio_to\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;vec2 imagecoord=mod(v_pos_a,1.0);vec2 pos=mix(pattern_tl_a/u_texsize,pattern_br_a/u_texsize,imagecoord);vec4 color1=texture(u_image,pos);vec2 imagecoord_b=mod(v_pos_b,1.0);vec2 pos2=mix(pattern_tl_b/u_texsize,pattern_br_b/u_texsize,imagecoord_b);vec4 color2=texture(u_image,pos2);vec4 mixedColor=mix(color1,color2,u_fade);fragColor=mixedColor*v_lighting;\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform float u_height_factor;uniform vec3 u_scale;uniform float u_vertical_gradient;uniform lowp float u_opacity;uniform vec2 u_fill_translate;uniform vec3 u_lightcolor;uniform lowp vec3 u_lightpos;uniform lowp vec3 u_lightpos_globe;uniform lowp float u_lightintensity;in vec2 a_pos;in vec4 a_normal_ed;\n#ifdef TERRAIN3D\nin vec2 a_centroid;\n#endif\n#ifdef GLOBE\nout vec3 v_sphere_pos;\n#endif\nout vec2 v_pos_a;out vec2 v_pos_b;out vec4 v_lighting;\n#pragma mapbox: define lowp float base\n#pragma mapbox: define lowp float height\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\n#pragma mapbox: define lowp float pixel_ratio_from\n#pragma mapbox: define lowp float pixel_ratio_to\nvoid main() {\n#pragma mapbox: initialize lowp float base\n#pragma mapbox: initialize lowp float height\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\n#pragma mapbox: initialize lowp float pixel_ratio_from\n#pragma mapbox: initialize lowp float pixel_ratio_to\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;float tileRatio=u_scale.x;float fromScale=u_scale.y;float toScale=u_scale.z;vec3 normal=a_normal_ed.xyz;float edgedistance=a_normal_ed.w;vec2 display_size_a=(pattern_br_a-pattern_tl_a)/pixel_ratio_from;vec2 display_size_b=(pattern_br_b-pattern_tl_b)/pixel_ratio_to;\n#ifdef TERRAIN3D\nfloat height_terrain3d_offset=get_elevation(a_centroid);float base_terrain3d_offset=height_terrain3d_offset-(base > 0.0 ? 0.0 : 10.0);\n#else\nfloat height_terrain3d_offset=0.0;float base_terrain3d_offset=0.0;\n#endif\nbase=max(0.0,base)+base_terrain3d_offset;height=max(0.0,height)+height_terrain3d_offset;float t=mod(normal.x,2.0);float elevation=t > 0.0 ? height : base;vec2 posInTile=a_pos+u_fill_translate;\n#ifdef GLOBE\nvec3 spherePos=projectToSphere(posInTile,a_pos);vec3 elevatedPos=spherePos*(1.0+elevation/GLOBE_RADIUS);v_sphere_pos=elevatedPos;gl_Position=interpolateProjectionFor3D(posInTile,spherePos,elevation);\n#else\ngl_Position=u_projection_matrix*vec4(posInTile,elevation,1.0);\n#endif\nvec2 pos=normal.x==1.0 && normal.y==0.0 && normal.z==16384.0\n? a_pos\n: vec2(edgedistance,elevation*u_height_factor);v_pos_a=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,fromScale*display_size_a,tileRatio,pos);v_pos_b=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,toScale*display_size_b,tileRatio,pos);v_lighting=vec4(0.0,0.0,0.0,1.0);float directional=clamp(dot(normal/16383.0,u_lightpos),0.0,1.0);directional=mix((1.0-u_lightintensity),max((0.5+u_lightintensity),1.0),directional);if (normal.y !=0.0) {directional*=((1.0-u_vertical_gradient)+(u_vertical_gradient*clamp((t+base)*pow(height/150.0,0.5),mix(0.7,0.98,1.0-u_lightintensity),1.0)));}v_lighting.rgb+=clamp(directional*u_lightcolor,mix(vec3(0.0),vec3(0.3),1.0-u_lightcolor),vec3(1.0));v_lighting*=u_opacity;}"),hillshadePrepare:ji("#ifdef GL_ES\nprecision highp float;\n#endif\nuniform sampler2D u_image;in vec2 v_pos;uniform vec2 u_dimension;uniform float u_zoom;uniform vec4 u_unpack;float getElevation(vec2 coord,float bias) {vec4 data=texture(u_image,coord)*255.0;data.a=-1.0;return dot(data,u_unpack);}void main() {vec2 epsilon=1.0/u_dimension;float tileSize=u_dimension.x-2.0;float a=getElevation(v_pos+vec2(-epsilon.x,-epsilon.y),0.0);float b=getElevation(v_pos+vec2(0,-epsilon.y),0.0);float c=getElevation(v_pos+vec2(epsilon.x,-epsilon.y),0.0);float d=getElevation(v_pos+vec2(-epsilon.x,0),0.0);float e=getElevation(v_pos,0.0);float f=getElevation(v_pos+vec2(epsilon.x,0),0.0);float g=getElevation(v_pos+vec2(-epsilon.x,epsilon.y),0.0);float h=getElevation(v_pos+vec2(0,epsilon.y),0.0);float i=getElevation(v_pos+vec2(epsilon.x,epsilon.y),0.0);float exaggerationFactor=u_zoom < 2.0 ? 0.4 : u_zoom < 4.5 ? 0.35 : 0.3;float exaggeration=u_zoom < 15.0 ? (u_zoom-15.0)*exaggerationFactor : 0.0;vec2 deriv=vec2((c+f+f+i)-(a+d+d+g),(g+h+h+i)-(a+b+b+c))*tileSize/pow(2.0,exaggeration+(28.2562-u_zoom));fragColor=clamp(vec4(deriv.x/8.0+0.5,deriv.y/8.0+0.5,1.0,1.0),0.0,1.0);\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","uniform mat4 u_matrix;uniform vec2 u_dimension;in vec2 a_pos;in vec2 a_texture_pos;out vec2 v_pos;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);highp vec2 epsilon=1.0/u_dimension;float scale=(u_dimension.x-2.0)/u_dimension.x;v_pos=(a_texture_pos/8192.0)*scale+epsilon;}"),hillshade:ji("uniform sampler2D u_image;in vec2 v_pos;uniform vec2 u_latrange;uniform float u_exaggeration;uniform vec4 u_accent;uniform int u_method;uniform float u_altitudes[NUM_ILLUMINATION_SOURCES];uniform float u_azimuths[NUM_ILLUMINATION_SOURCES];uniform vec4 u_shadows[NUM_ILLUMINATION_SOURCES];uniform vec4 u_highlights[NUM_ILLUMINATION_SOURCES];\n#define PI 3.141592653589793\n#define STANDARD 0\n#define COMBINED 1\n#define IGOR 2\n#define MULTIDIRECTIONAL 3\n#define BASIC 4\nfloat get_aspect(vec2 deriv){return deriv.x !=0.0 ? atan(deriv.y,-deriv.x) : PI/2.0*(deriv.y > 0.0 ? 1.0 :-1.0);}void igor_hillshade(vec2 deriv){deriv=deriv*u_exaggeration*2.0;float aspect=get_aspect(deriv);float azimuth=u_azimuths[0]+PI;float slope_stength=atan(length(deriv))*2.0/PI;float aspect_strength=1.0-abs(mod((aspect+azimuth)/PI+0.5,2.0)-1.0);float shadow_strength=slope_stength*aspect_strength;float highlight_strength=slope_stength*(1.0-aspect_strength);fragColor=u_shadows[0]*shadow_strength+u_highlights[0]*highlight_strength;}void standard_hillshade(vec2 deriv){float azimuth=u_azimuths[0]+PI;float slope=atan(0.625*length(deriv));float aspect=get_aspect(deriv);float intensity=u_exaggeration;float base=1.875-intensity*1.75;float maxValue=0.5*PI;float scaledSlope=intensity !=0.5 ? ((pow(base,slope)-1.0)/(pow(base,maxValue)-1.0))*maxValue : slope;float accent=cos(scaledSlope);vec4 accent_color=(1.0-accent)*u_accent*clamp(intensity*2.0,0.0,1.0);float shade=abs(mod((aspect+azimuth)/PI+0.5,2.0)-1.0);vec4 shade_color=mix(u_shadows[0],u_highlights[0],shade)*sin(scaledSlope)*clamp(intensity*2.0,0.0,1.0);fragColor=accent_color*(1.0-shade_color.a)+shade_color;}void basic_hillshade(vec2 deriv){deriv=deriv*u_exaggeration*2.0;float azimuth=u_azimuths[0]+PI;float cos_az=cos(azimuth);float sin_az=sin(azimuth);float cos_alt=cos(u_altitudes[0]);float sin_alt=sin(u_altitudes[0]);float cang=(sin_alt-(deriv.y*cos_az*cos_alt-deriv.x*sin_az*cos_alt))/sqrt(1.0+dot(deriv,deriv));float shade=clamp(cang,0.0,1.0);if(shade > 0.5){fragColor=u_highlights[0]*(2.0*shade-1.0);}else\n{fragColor=u_shadows[0]*(1.0-2.0*shade);}}void multidirectional_hillshade(vec2 deriv){deriv=deriv*u_exaggeration*2.0;fragColor=vec4(0,0,0,0);for(int i=0; i < NUM_ILLUMINATION_SOURCES; i++){float cos_alt=cos(u_altitudes[i]);float sin_alt=sin(u_altitudes[i]);float cos_az=-cos(u_azimuths[i]);float sin_az=-sin(u_azimuths[i]);float cang=(sin_alt-(deriv.y*cos_az*cos_alt-deriv.x*sin_az*cos_alt))/sqrt(1.0+dot(deriv,deriv));float shade=clamp(cang,0.0,1.0);if(shade > 0.5){fragColor+=u_highlights[i]*(2.0*shade-1.0)/float(NUM_ILLUMINATION_SOURCES);}else\n{fragColor+=u_shadows[i]*(1.0-2.0*shade)/float(NUM_ILLUMINATION_SOURCES);}}}void combined_hillshade(vec2 deriv){deriv=deriv*u_exaggeration*2.0;float azimuth=u_azimuths[0]+PI;float cos_az=cos(azimuth);float sin_az=sin(azimuth);float cos_alt=cos(u_altitudes[0]);float sin_alt=sin(u_altitudes[0]);float cang=acos((sin_alt-(deriv.y*cos_az*cos_alt-deriv.x*sin_az*cos_alt))/sqrt(1.0+dot(deriv,deriv)));cang=clamp(cang,0.0,PI/2.0);float shade=cang*atan(length(deriv))*4.0/PI/PI;float highlight=(PI/2.0-cang)*atan(length(deriv))*4.0/PI/PI;fragColor=u_shadows[0]*shade+u_highlights[0]*highlight;}void main() {vec4 pixel=texture(u_image,v_pos);float scaleFactor=cos(radians((u_latrange[0]-u_latrange[1])*(1.0-v_pos.y)+u_latrange[1]));vec2 deriv=((pixel.rg*8.0)-4.0)/scaleFactor;if (u_method==BASIC) {basic_hillshade(deriv);} else if (u_method==COMBINED) {combined_hillshade(deriv);} else if (u_method==IGOR) {igor_hillshade(deriv);} else if (u_method==MULTIDIRECTIONAL) {multidirectional_hillshade(deriv);} else if (u_method==STANDARD) {standard_hillshade(deriv);} else {standard_hillshade(deriv);}\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","uniform mat4 u_matrix;in vec2 a_pos;out vec2 v_pos;void main() {gl_Position=projectTile(a_pos,a_pos);v_pos=a_pos/8192.0;if (a_pos.y <-32767.5) {v_pos.y=0.0;}if (a_pos.y > 32766.5) {v_pos.y=1.0;}}"),line:ji("uniform lowp float u_device_pixel_ratio;in vec2 v_width2;in vec2 v_normal;in float v_gamma_scale;\n#ifdef GLOBE\nin float v_depth;\n#endif\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\nfloat dist=length(v_normal)*v_width2.s;float blur2=(blur+1.0/u_device_pixel_ratio)*v_gamma_scale;float alpha=clamp(min(dist-(v_width2.t-blur2),v_width2.s-dist)/blur2,0.0,1.0);fragColor=color*(alpha*opacity);\n#ifdef GLOBE\nif (v_depth > 1.0) {discard;}\n#endif\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","\n#define scale 0.015873016\nin vec2 a_pos_normal;in vec4 a_data;uniform vec2 u_translation;uniform mediump float u_ratio;uniform vec2 u_units_to_pixels;uniform lowp float u_device_pixel_ratio;out vec2 v_normal;out vec2 v_width2;out float v_gamma_scale;out highp float v_linesofar;\n#ifdef GLOBE\nout float v_depth;\n#endif\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define mediump float gapwidth\n#pragma mapbox: define lowp float offset\n#pragma mapbox: define mediump float width\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump float gapwidth\n#pragma mapbox: initialize lowp float offset\n#pragma mapbox: initialize mediump float width\nfloat ANTIALIASING=1.0/u_device_pixel_ratio/2.0;vec2 a_extrude=a_data.xy-128.0;float a_direction=mod(a_data.z,4.0)-1.0;v_linesofar=(floor(a_data.z/4.0)+a_data.w*64.0)*2.0;vec2 pos=floor(a_pos_normal*0.5);mediump vec2 normal=a_pos_normal-2.0*pos;normal.y=normal.y*2.0-1.0;v_normal=normal;gapwidth=gapwidth/2.0;float halfwidth=width/2.0;offset=-1.0*offset;float inset=gapwidth+(gapwidth > 0.0 ? ANTIALIASING : 0.0);float outset=gapwidth+halfwidth*(gapwidth > 0.0 ? 2.0 : 1.0)+(halfwidth==0.0 ? 0.0 : ANTIALIASING);mediump vec2 dist=outset*a_extrude*scale;mediump float u=0.5*a_direction;mediump float t=1.0-abs(u);mediump vec2 offset2=offset*a_extrude*scale*normal.y*mat2(t,-u,u,t);float adjustedThickness=projectLineThickness(pos.y);vec4 projected_no_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation);vec4 projected_with_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation+dist/u_ratio*adjustedThickness);gl_Position=projected_with_extrude;\n#ifdef GLOBE\nv_depth=gl_Position.z/gl_Position.w;\n#endif\n#ifdef TERRAIN3D\nv_gamma_scale=1.0;\n#else\nfloat extrude_length_without_perspective=length(dist);float extrude_length_with_perspective=length((projected_with_extrude.xy-projected_no_extrude.xy)/projected_with_extrude.w*u_units_to_pixels);v_gamma_scale=extrude_length_without_perspective/extrude_length_with_perspective;\n#endif\nv_width2=vec2(outset,inset);}"),lineGradient:ji("uniform lowp float u_device_pixel_ratio;uniform sampler2D u_image;in vec2 v_width2;in vec2 v_normal;in float v_gamma_scale;in highp vec2 v_uv;\n#ifdef GLOBE\nin float v_depth;\n#endif\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\nfloat dist=length(v_normal)*v_width2.s;float blur2=(blur+1.0/u_device_pixel_ratio)*v_gamma_scale;float alpha=clamp(min(dist-(v_width2.t-blur2),v_width2.s-dist)/blur2,0.0,1.0);vec4 color=texture(u_image,v_uv);fragColor=color*(alpha*opacity);\n#ifdef GLOBE\nif (v_depth > 1.0) {discard;}\n#endif\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","\n#define scale 0.015873016\nin vec2 a_pos_normal;in vec4 a_data;in float a_uv_x;in float a_split_index;uniform vec2 u_translation;uniform mediump float u_ratio;uniform lowp float u_device_pixel_ratio;uniform vec2 u_units_to_pixels;uniform float u_image_height;out vec2 v_normal;out vec2 v_width2;out float v_gamma_scale;out highp vec2 v_uv;\n#ifdef GLOBE\nout float v_depth;\n#endif\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define mediump float gapwidth\n#pragma mapbox: define lowp float offset\n#pragma mapbox: define mediump float width\nvoid main() {\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump float gapwidth\n#pragma mapbox: initialize lowp float offset\n#pragma mapbox: initialize mediump float width\nfloat ANTIALIASING=1.0/u_device_pixel_ratio/2.0;vec2 a_extrude=a_data.xy-128.0;float a_direction=mod(a_data.z,4.0)-1.0;highp float texel_height=1.0/u_image_height;highp float half_texel_height=0.5*texel_height;v_uv=vec2(a_uv_x,a_split_index*texel_height-half_texel_height);vec2 pos=floor(a_pos_normal*0.5);mediump vec2 normal=a_pos_normal-2.0*pos;normal.y=normal.y*2.0-1.0;v_normal=normal;gapwidth=gapwidth/2.0;float halfwidth=width/2.0;offset=-1.0*offset;float inset=gapwidth+(gapwidth > 0.0 ? ANTIALIASING : 0.0);float outset=gapwidth+halfwidth*(gapwidth > 0.0 ? 2.0 : 1.0)+(halfwidth==0.0 ? 0.0 : ANTIALIASING);mediump vec2 dist=outset*a_extrude*scale;mediump float u=0.5*a_direction;mediump float t=1.0-abs(u);mediump vec2 offset2=offset*a_extrude*scale*normal.y*mat2(t,-u,u,t);float adjustedThickness=projectLineThickness(pos.y);vec4 projected_no_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation);vec4 projected_with_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation+dist/u_ratio*adjustedThickness);gl_Position=projected_with_extrude;\n#ifdef GLOBE\nv_depth=gl_Position.z/gl_Position.w;\n#endif\n#ifdef TERRAIN3D\nv_gamma_scale=1.0;\n#else\nfloat extrude_length_without_perspective=length(dist);float extrude_length_with_perspective=length((projected_with_extrude.xy-projected_no_extrude.xy)/projected_with_extrude.w*u_units_to_pixels);v_gamma_scale=extrude_length_without_perspective/extrude_length_with_perspective;\n#endif\nv_width2=vec2(outset,inset);}"),linePattern:ji("#ifdef GL_ES\nprecision highp float;\n#endif\nuniform lowp float u_device_pixel_ratio;uniform vec2 u_texsize;uniform float u_fade;uniform mediump vec3 u_scale;uniform sampler2D u_image;in vec2 v_normal;in vec2 v_width2;in float v_linesofar;in float v_gamma_scale;in float v_width;\n#ifdef GLOBE\nin float v_depth;\n#endif\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\n#pragma mapbox: define lowp float pixel_ratio_from\n#pragma mapbox: define lowp float pixel_ratio_to\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\n#pragma mapbox: initialize lowp float pixel_ratio_from\n#pragma mapbox: initialize lowp float pixel_ratio_to\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;float tileZoomRatio=u_scale.x;float fromScale=u_scale.y;float toScale=u_scale.z;vec2 display_size_a=(pattern_br_a-pattern_tl_a)/pixel_ratio_from;vec2 display_size_b=(pattern_br_b-pattern_tl_b)/pixel_ratio_to;vec2 pattern_size_a=vec2(display_size_a.x*fromScale/tileZoomRatio,display_size_a.y);vec2 pattern_size_b=vec2(display_size_b.x*toScale/tileZoomRatio,display_size_b.y);float aspect_a=display_size_a.y/v_width;float aspect_b=display_size_b.y/v_width;float dist=length(v_normal)*v_width2.s;float blur2=(blur+1.0/u_device_pixel_ratio)*v_gamma_scale;float alpha=clamp(min(dist-(v_width2.t-blur2),v_width2.s-dist)/blur2,0.0,1.0);float x_a=mod(v_linesofar/pattern_size_a.x*aspect_a,1.0);float x_b=mod(v_linesofar/pattern_size_b.x*aspect_b,1.0);float y=0.5*v_normal.y+0.5;vec2 texel_size=1.0/u_texsize;vec2 pos_a=mix(pattern_tl_a*texel_size-texel_size,pattern_br_a*texel_size+texel_size,vec2(x_a,y));vec2 pos_b=mix(pattern_tl_b*texel_size-texel_size,pattern_br_b*texel_size+texel_size,vec2(x_b,y));vec4 color=mix(texture(u_image,pos_a),texture(u_image,pos_b),u_fade);fragColor=color*alpha*opacity;\n#ifdef GLOBE\nif (v_depth > 1.0) {discard;}\n#endif\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","\n#define scale 0.015873016\n#define LINE_DISTANCE_SCALE 2.0\nin vec2 a_pos_normal;in vec4 a_data;uniform vec2 u_translation;uniform vec2 u_units_to_pixels;uniform mediump float u_ratio;uniform lowp float u_device_pixel_ratio;out vec2 v_normal;out vec2 v_width2;out float v_linesofar;out float v_gamma_scale;out float v_width;\n#ifdef GLOBE\nout float v_depth;\n#endif\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp float offset\n#pragma mapbox: define mediump float gapwidth\n#pragma mapbox: define mediump float width\n#pragma mapbox: define lowp float floorwidth\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\n#pragma mapbox: define lowp float pixel_ratio_from\n#pragma mapbox: define lowp float pixel_ratio_to\nvoid main() {\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize lowp float offset\n#pragma mapbox: initialize mediump float gapwidth\n#pragma mapbox: initialize mediump float width\n#pragma mapbox: initialize lowp float floorwidth\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\n#pragma mapbox: initialize lowp float pixel_ratio_from\n#pragma mapbox: initialize lowp float pixel_ratio_to\nfloat ANTIALIASING=1.0/u_device_pixel_ratio/2.0;vec2 a_extrude=a_data.xy-128.0;float a_direction=mod(a_data.z,4.0)-1.0;float a_linesofar=(floor(a_data.z/4.0)+a_data.w*64.0)*LINE_DISTANCE_SCALE;vec2 pos=floor(a_pos_normal*0.5);mediump vec2 normal=a_pos_normal-2.0*pos;normal.y=normal.y*2.0-1.0;v_normal=normal;gapwidth=gapwidth/2.0;float halfwidth=width/2.0;offset=-1.0*offset;float inset=gapwidth+(gapwidth > 0.0 ? ANTIALIASING : 0.0);float outset=gapwidth+halfwidth*(gapwidth > 0.0 ? 2.0 : 1.0)+(halfwidth==0.0 ? 0.0 : ANTIALIASING);mediump vec2 dist=outset*a_extrude*scale;mediump float u=0.5*a_direction;mediump float t=1.0-abs(u);mediump vec2 offset2=offset*a_extrude*scale*normal.y*mat2(t,-u,u,t);float adjustedThickness=projectLineThickness(pos.y);vec4 projected_no_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation);vec4 projected_with_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation+dist/u_ratio*adjustedThickness);gl_Position=projected_with_extrude;\n#ifdef GLOBE\nv_depth=gl_Position.z/gl_Position.w;\n#endif\n#ifdef TERRAIN3D\nv_gamma_scale=1.0;\n#else\nfloat extrude_length_without_perspective=length(dist);float extrude_length_with_perspective=length((projected_with_extrude.xy-projected_no_extrude.xy)/projected_with_extrude.w*u_units_to_pixels);v_gamma_scale=extrude_length_without_perspective/extrude_length_with_perspective;\n#endif\nv_linesofar=a_linesofar;v_width2=vec2(outset,inset);v_width=floorwidth;}"),lineSDF:ji("uniform lowp float u_device_pixel_ratio;uniform lowp float u_lineatlas_width;uniform sampler2D u_image;uniform float u_mix;in vec2 v_normal;in vec2 v_width2;in vec2 v_tex_a;in vec2 v_tex_b;in float v_gamma_scale;\n#ifdef GLOBE\nin float v_depth;\n#endif\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define mediump float width\n#pragma mapbox: define lowp float floorwidth\n#pragma mapbox: define mediump vec4 dasharray_from\n#pragma mapbox: define mediump vec4 dasharray_to\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump float width\n#pragma mapbox: initialize lowp float floorwidth\n#pragma mapbox: initialize mediump vec4 dasharray_from\n#pragma mapbox: initialize mediump vec4 dasharray_to\nfloat dist=length(v_normal)*v_width2.s;float blur2=(blur+1.0/u_device_pixel_ratio)*v_gamma_scale;float alpha=clamp(min(dist-(v_width2.t-blur2),v_width2.s-dist)/blur2,0.0,1.0);float sdfdist_a=texture(u_image,v_tex_a).a;float sdfdist_b=texture(u_image,v_tex_b).a;float sdfdist=mix(sdfdist_a,sdfdist_b,u_mix);float sdfgamma=(u_lineatlas_width/256.0/u_device_pixel_ratio)/min(dasharray_from.w,dasharray_to.w);alpha*=smoothstep(0.5-sdfgamma/floorwidth,0.5+sdfgamma/floorwidth,sdfdist);fragColor=color*(alpha*opacity);\n#ifdef GLOBE\nif (v_depth > 1.0) {discard;}\n#endif\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","\n#define scale 0.015873016\n#define LINE_DISTANCE_SCALE 2.0\nin vec2 a_pos_normal;in vec4 a_data;uniform vec2 u_translation;uniform mediump float u_ratio;uniform lowp float u_device_pixel_ratio;uniform vec2 u_units_to_pixels;uniform float u_tileratio;uniform float u_crossfade_from;uniform float u_crossfade_to;uniform float u_lineatlas_height;out vec2 v_normal;out vec2 v_width2;out vec2 v_tex_a;out vec2 v_tex_b;out float v_gamma_scale;\n#ifdef GLOBE\nout float v_depth;\n#endif\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define mediump float gapwidth\n#pragma mapbox: define lowp float offset\n#pragma mapbox: define mediump float width\n#pragma mapbox: define lowp float floorwidth\n#pragma mapbox: define mediump vec4 dasharray_from\n#pragma mapbox: define mediump vec4 dasharray_to\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump float gapwidth\n#pragma mapbox: initialize lowp float offset\n#pragma mapbox: initialize mediump float width\n#pragma mapbox: initialize lowp float floorwidth\n#pragma mapbox: initialize mediump vec4 dasharray_from\n#pragma mapbox: initialize mediump vec4 dasharray_to\nfloat ANTIALIASING=1.0/u_device_pixel_ratio/2.0;vec2 a_extrude=a_data.xy-128.0;float a_direction=mod(a_data.z,4.0)-1.0;float a_linesofar=(floor(a_data.z/4.0)+a_data.w*64.0)*LINE_DISTANCE_SCALE;vec2 pos=floor(a_pos_normal*0.5);mediump vec2 normal=a_pos_normal-2.0*pos;normal.y=normal.y*2.0-1.0;v_normal=normal;gapwidth=gapwidth/2.0;float halfwidth=width/2.0;offset=-1.0*offset;float inset=gapwidth+(gapwidth > 0.0 ? ANTIALIASING : 0.0);float outset=gapwidth+halfwidth*(gapwidth > 0.0 ? 2.0 : 1.0)+(halfwidth==0.0 ? 0.0 : ANTIALIASING);mediump vec2 dist=outset*a_extrude*scale;mediump float u=0.5*a_direction;mediump float t=1.0-abs(u);mediump vec2 offset2=offset*a_extrude*scale*normal.y*mat2(t,-u,u,t);float adjustedThickness=projectLineThickness(pos.y);vec4 projected_no_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation);vec4 projected_with_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation+dist/u_ratio*adjustedThickness);gl_Position=projected_with_extrude;\n#ifdef GLOBE\nv_depth=gl_Position.z/gl_Position.w;\n#endif\n#ifdef TERRAIN3D\nv_gamma_scale=1.0;\n#else\nfloat extrude_length_without_perspective=length(dist);float extrude_length_with_perspective=length((projected_with_extrude.xy-projected_no_extrude.xy)/projected_with_extrude.w*u_units_to_pixels);v_gamma_scale=extrude_length_without_perspective/extrude_length_with_perspective;\n#endif\nfloat u_patternscale_a_x=u_tileratio/dasharray_from.w/u_crossfade_from;float u_patternscale_a_y=-dasharray_from.z/2.0/u_lineatlas_height;float u_patternscale_b_x=u_tileratio/dasharray_to.w/u_crossfade_to;float u_patternscale_b_y=-dasharray_to.z/2.0/u_lineatlas_height;v_tex_a=vec2(a_linesofar*u_patternscale_a_x/floorwidth,normal.y*u_patternscale_a_y+(float(dasharray_from.y)+0.5)/u_lineatlas_height);v_tex_b=vec2(a_linesofar*u_patternscale_b_x/floorwidth,normal.y*u_patternscale_b_y+(float(dasharray_to.y)+0.5)/u_lineatlas_height);v_width2=vec2(outset,inset);}"),lineGradientSDF:ji("uniform lowp float u_device_pixel_ratio;uniform sampler2D u_image;uniform sampler2D u_image_dash;uniform float u_mix;uniform lowp float u_lineatlas_width;in vec2 v_normal;in vec2 v_width2;in vec2 v_tex_a;in vec2 v_tex_b;in float v_gamma_scale;in highp vec2 v_uv;\n#ifdef GLOBE\nin float v_depth;\n#endif\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define mediump float width\n#pragma mapbox: define lowp float floorwidth\n#pragma mapbox: define mediump vec4 dasharray_from\n#pragma mapbox: define mediump vec4 dasharray_to\nvoid main() {\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump float width\n#pragma mapbox: initialize lowp float floorwidth\n#pragma mapbox: initialize mediump vec4 dasharray_from\n#pragma mapbox: initialize mediump vec4 dasharray_to\nfloat dist=length(v_normal)*v_width2.s;float blur2=(blur+1.0/u_device_pixel_ratio)*v_gamma_scale;float alpha=clamp(min(dist-(v_width2.t-blur2),v_width2.s-dist)/blur2,0.0,1.0);vec4 color=texture(u_image,v_uv);float sdfdist_a=texture(u_image_dash,v_tex_a).a;float sdfdist_b=texture(u_image_dash,v_tex_b).a;float sdfdist=mix(sdfdist_a,sdfdist_b,u_mix);float sdfgamma=(u_lineatlas_width/256.0)/min(dasharray_from.w,dasharray_to.w);float dash_alpha=smoothstep(0.5-sdfgamma/floorwidth,0.5+sdfgamma/floorwidth,sdfdist);fragColor=color*(alpha*dash_alpha*opacity);\n#ifdef GLOBE\nif (v_depth > 1.0) {discard;}\n#endif\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","\n#define scale 0.015873016\n#define LINE_DISTANCE_SCALE 2.0\nin vec2 a_pos_normal;in vec4 a_data;in float a_uv_x;in float a_split_index;uniform vec2 u_translation;uniform mediump float u_ratio;uniform lowp float u_device_pixel_ratio;uniform vec2 u_units_to_pixels;uniform float u_image_height;uniform float u_tileratio;uniform float u_crossfade_from;uniform float u_crossfade_to;uniform float u_lineatlas_height;out vec2 v_normal;out vec2 v_width2;out float v_gamma_scale;out highp vec2 v_uv;out vec2 v_tex_a;out vec2 v_tex_b;\n#ifdef GLOBE\nout float v_depth;\n#endif\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define mediump float gapwidth\n#pragma mapbox: define lowp float offset\n#pragma mapbox: define mediump float width\n#pragma mapbox: define lowp float floorwidth\n#pragma mapbox: define mediump vec4 dasharray_from\n#pragma mapbox: define mediump vec4 dasharray_to\nvoid main() {\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump float gapwidth\n#pragma mapbox: initialize lowp float offset\n#pragma mapbox: initialize mediump float width\n#pragma mapbox: initialize lowp float floorwidth\n#pragma mapbox: initialize mediump vec4 dasharray_from\n#pragma mapbox: initialize mediump vec4 dasharray_to\nfloat ANTIALIASING=1.0/u_device_pixel_ratio/2.0;vec2 a_extrude=a_data.xy-128.0;float a_direction=mod(a_data.z,4.0)-1.0;float a_linesofar=(floor(a_data.z/4.0)+a_data.w*64.0)*LINE_DISTANCE_SCALE;float texel_height=1.0/u_image_height;float half_texel_height=0.5*texel_height;v_uv=vec2(a_uv_x,a_split_index*texel_height-half_texel_height);vec2 pos=floor(a_pos_normal*0.5);mediump vec2 normal=a_pos_normal-2.0*pos;normal.y=normal.y*2.0-1.0;v_normal=normal;gapwidth=gapwidth/2.0;float halfwidth=width/2.0;offset=-1.0*offset;float inset=gapwidth+(gapwidth > 0.0 ? ANTIALIASING : 0.0);float outset=gapwidth+halfwidth*(gapwidth > 0.0 ? 2.0 : 1.0)+(halfwidth==0.0 ? 0.0 : ANTIALIASING);mediump vec2 dist=outset*a_extrude*scale;mediump float u=0.5*a_direction;mediump float t=1.0-abs(u);mediump vec2 offset2=offset*a_extrude*scale*normal.y*mat2(t,-u,u,t);float adjustedThickness=projectLineThickness(pos.y);vec4 projected_no_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation);vec4 projected_with_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation+dist/u_ratio*adjustedThickness);gl_Position=projected_with_extrude;\n#ifdef GLOBE\nv_depth=gl_Position.z/gl_Position.w;\n#endif\n#ifdef TERRAIN3D\nv_gamma_scale=1.0;\n#else\nfloat extrude_length_without_perspective=length(dist);float extrude_length_with_perspective=length((projected_with_extrude.xy-projected_no_extrude.xy)/projected_with_extrude.w*u_units_to_pixels);v_gamma_scale=extrude_length_without_perspective/extrude_length_with_perspective;\n#endif\nfloat u_patternscale_a_x=u_tileratio/dasharray_from.w/u_crossfade_from;float u_patternscale_a_y=-dasharray_from.z/2.0/u_lineatlas_height;float u_patternscale_b_x=u_tileratio/dasharray_to.w/u_crossfade_to;float u_patternscale_b_y=-dasharray_to.z/2.0/u_lineatlas_height;v_tex_a=vec2(a_linesofar*u_patternscale_a_x/floorwidth,normal.y*u_patternscale_a_y+(float(dasharray_from.y)+0.5)/u_lineatlas_height);v_tex_b=vec2(a_linesofar*u_patternscale_b_x/floorwidth,normal.y*u_patternscale_b_y+(float(dasharray_to.y)+0.5)/u_lineatlas_height);v_width2=vec2(outset,inset);}"),raster:ji("uniform float u_fade_t;uniform float u_opacity;uniform sampler2D u_image0;uniform sampler2D u_image1;in vec2 v_pos0;in vec2 v_pos1;uniform float u_brightness_low;uniform float u_brightness_high;uniform float u_saturation_factor;uniform float u_contrast_factor;uniform vec3 u_spin_weights;void main() {vec4 color0=texture(u_image0,v_pos0);vec4 color1=texture(u_image1,v_pos1);if (color0.a > 0.0) {color0.rgb=color0.rgb/color0.a;}if (color1.a > 0.0) {color1.rgb=color1.rgb/color1.a;}vec4 color=mix(color0,color1,u_fade_t);color.a*=u_opacity;vec3 rgb=color.rgb;rgb=vec3(dot(rgb,u_spin_weights.xyz),dot(rgb,u_spin_weights.zxy),dot(rgb,u_spin_weights.yzx));float average=(color.r+color.g+color.b)/3.0;rgb+=(average-rgb)*u_saturation_factor;rgb=(rgb-0.5)*u_contrast_factor+0.5;vec3 u_high_vec=vec3(u_brightness_low,u_brightness_low,u_brightness_low);vec3 u_low_vec=vec3(u_brightness_high,u_brightness_high,u_brightness_high);fragColor=vec4(mix(u_high_vec,u_low_vec,rgb)*color.a,color.a);\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","uniform vec2 u_tl_parent;uniform float u_scale_parent;uniform float u_buffer_scale;uniform vec4 u_coords_top;uniform vec4 u_coords_bottom;in vec2 a_pos;out vec2 v_pos0;out vec2 v_pos1;void main() {vec2 fractionalPos=a_pos/8192.0;vec2 position=mix(mix(u_coords_top.xy,u_coords_top.zw,fractionalPos.x),mix(u_coords_bottom.xy,u_coords_bottom.zw,fractionalPos.x),fractionalPos.y);gl_Position=projectTile(position,position);v_pos0=((fractionalPos-0.5)/u_buffer_scale)+0.5;\n#ifdef GLOBE\nif (a_pos.y <-32767.5) {v_pos0.y=0.0;}if (a_pos.y > 32766.5) {v_pos0.y=1.0;}\n#endif\nv_pos1=(v_pos0*u_scale_parent)+u_tl_parent;}"),symbolIcon:ji("uniform sampler2D u_texture;in vec2 v_tex;in float v_fade_opacity;\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\nlowp float alpha=opacity*v_fade_opacity;fragColor=texture(u_texture,v_tex)*alpha;\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","in vec4 a_pos_offset;in vec4 a_data;in vec4 a_pixeloffset;in vec3 a_projected_pos;in float a_fade_opacity;uniform bool u_is_size_zoom_constant;uniform bool u_is_size_feature_constant;uniform highp float u_size_t;uniform highp float u_size;uniform highp float u_camera_to_center_distance;uniform highp float u_pitch;uniform bool u_rotate_symbol;uniform highp float u_aspect_ratio;uniform float u_fade_change;uniform mat4 u_label_plane_matrix;uniform mat4 u_coord_matrix;uniform bool u_is_text;uniform bool u_pitch_with_map;uniform vec2 u_texsize;uniform bool u_is_along_line;uniform bool u_is_variable_anchor;uniform vec2 u_translation;uniform float u_pitched_scale;out vec2 v_tex;out float v_fade_opacity;\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\nvec2 a_pos=a_pos_offset.xy;vec2 a_offset=a_pos_offset.zw;vec2 a_tex=a_data.xy;vec2 a_size=a_data.zw;float a_size_min=floor(a_size[0]*0.5);vec2 a_pxoffset=a_pixeloffset.xy;vec2 a_minFontScale=a_pixeloffset.zw/256.0;float ele=get_elevation(a_pos);highp float segment_angle=-a_projected_pos[2];float size;if (!u_is_size_zoom_constant && !u_is_size_feature_constant) {size=mix(a_size_min,a_size[1],u_size_t)/128.0;} else if (u_is_size_zoom_constant && !u_is_size_feature_constant) {size=a_size_min/128.0;} else {size=u_size;}vec2 translated_a_pos=a_pos+u_translation;vec4 projectedPoint=projectTileWithElevation(translated_a_pos,ele);highp float camera_to_anchor_distance=projectedPoint.w;highp float distance_ratio=u_pitch_with_map ?\ncamera_to_anchor_distance/u_camera_to_center_distance :\nu_camera_to_center_distance/camera_to_anchor_distance;highp float perspective_ratio=clamp(0.5+0.5*distance_ratio,0.0,4.0);size*=perspective_ratio;float fontScale=u_is_text ? size/24.0 : size;highp float symbol_rotation=0.0;if (u_rotate_symbol) {vec4 offsetProjectedPoint=projectTileWithElevation(translated_a_pos+vec2(1,0),ele);vec2 a=projectedPoint.xy/projectedPoint.w;vec2 b=offsetProjectedPoint.xy/offsetProjectedPoint.w;symbol_rotation=atan((b.y-a.y)/u_aspect_ratio,b.x-a.x);}highp float angle_sin=sin(segment_angle+symbol_rotation);highp float angle_cos=cos(segment_angle+symbol_rotation);mat2 rotation_matrix=mat2(angle_cos,-1.0*angle_sin,angle_sin,angle_cos);vec4 projected_pos;if (u_is_along_line || u_is_variable_anchor) {projected_pos=vec4(a_projected_pos.xy,ele,1.0);} else if (u_pitch_with_map) {projected_pos=u_label_plane_matrix*vec4(a_projected_pos.xy+u_translation,ele,1.0);} else {projected_pos=u_label_plane_matrix*projectTileWithElevation(a_projected_pos.xy+u_translation,ele);}float z=float(u_pitch_with_map)*projected_pos.z/projected_pos.w;float projectionScaling=1.0;\n#ifdef GLOBE\nif(u_pitch_with_map) {float anchor_pos_tile_y=(u_coord_matrix*vec4(projected_pos.xy/projected_pos.w,z,1.0)).y;projectionScaling=mix(projectionScaling,1.0/circumferenceRatioAtTileY(anchor_pos_tile_y)*u_pitched_scale,u_projection_transition);}\n#endif\nvec4 finalPos=u_coord_matrix*vec4(projected_pos.xy/projected_pos.w+rotation_matrix*(a_offset/32.0*max(a_minFontScale,fontScale)+a_pxoffset/16.0)*projectionScaling,z,1.0);if(u_pitch_with_map) {finalPos=projectTileWithElevation(finalPos.xy,finalPos.z);}gl_Position=finalPos;v_tex=a_tex/u_texsize;vec2 fade_opacity=unpack_opacity(a_fade_opacity);float fade_change=fade_opacity[1] > 0.5 ? u_fade_change :-u_fade_change;float visibility=calculate_visibility(projectedPoint);v_fade_opacity=max(0.0,min(visibility,fade_opacity[0]+fade_change));}"),symbolSDF:ji("#define SDF_PX 8.0\nuniform bool u_is_halo;uniform sampler2D u_texture;uniform highp float u_gamma_scale;uniform lowp float u_device_pixel_ratio;uniform bool u_is_text;in vec2 v_data0;in vec3 v_data1;\n#pragma mapbox: define highp vec4 fill_color\n#pragma mapbox: define highp vec4 halo_color\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp float halo_width\n#pragma mapbox: define lowp float halo_blur\nvoid main() {\n#pragma mapbox: initialize highp vec4 fill_color\n#pragma mapbox: initialize highp vec4 halo_color\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize lowp float halo_width\n#pragma mapbox: initialize lowp float halo_blur\nfloat EDGE_GAMMA=0.105/u_device_pixel_ratio;vec2 tex=v_data0.xy;float gamma_scale=v_data1.x;float size=v_data1.y;float fade_opacity=v_data1[2];float fontScale=u_is_text ? size/24.0 : size;lowp vec4 color=fill_color;highp float gamma=EDGE_GAMMA/(fontScale*u_gamma_scale);lowp float inner_edge=(256.0-64.0)/256.0;if (u_is_halo) {color=halo_color;gamma=(halo_blur*1.19/SDF_PX+EDGE_GAMMA)/(fontScale*u_gamma_scale);inner_edge=inner_edge+gamma*gamma_scale;}lowp float dist=texture(u_texture,tex).a;highp float gamma_scaled=gamma*gamma_scale;highp float alpha=smoothstep(inner_edge-gamma_scaled,inner_edge+gamma_scaled,dist);if (u_is_halo) {lowp float halo_edge=(6.0-halo_width/fontScale)/SDF_PX;alpha=min(smoothstep(halo_edge-gamma_scaled,halo_edge+gamma_scaled,dist),1.0-alpha);}fragColor=color*(alpha*opacity*fade_opacity);\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","in vec4 a_pos_offset;in vec4 a_data;in vec4 a_pixeloffset;in vec3 a_projected_pos;in float a_fade_opacity;uniform bool u_is_size_zoom_constant;uniform bool u_is_size_feature_constant;uniform highp float u_size_t;uniform highp float u_size;uniform mat4 u_label_plane_matrix;uniform mat4 u_coord_matrix;uniform bool u_is_text;uniform bool u_pitch_with_map;uniform bool u_is_along_line;uniform bool u_is_variable_anchor;uniform highp float u_pitch;uniform bool u_rotate_symbol;uniform highp float u_aspect_ratio;uniform highp float u_camera_to_center_distance;uniform float u_fade_change;uniform vec2 u_texsize;uniform vec2 u_translation;uniform float u_pitched_scale;out vec2 v_data0;out vec3 v_data1;\n#pragma mapbox: define highp vec4 fill_color\n#pragma mapbox: define highp vec4 halo_color\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp float halo_width\n#pragma mapbox: define lowp float halo_blur\nvoid main() {\n#pragma mapbox: initialize highp vec4 fill_color\n#pragma mapbox: initialize highp vec4 halo_color\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize lowp float halo_width\n#pragma mapbox: initialize lowp float halo_blur\nvec2 a_pos=a_pos_offset.xy;vec2 a_offset=a_pos_offset.zw;vec2 a_tex=a_data.xy;vec2 a_size=a_data.zw;float a_size_min=floor(a_size[0]*0.5);vec2 a_pxoffset=a_pixeloffset.xy;float ele=get_elevation(a_pos);highp float segment_angle=-a_projected_pos[2];float size;if (!u_is_size_zoom_constant && !u_is_size_feature_constant) {size=mix(a_size_min,a_size[1],u_size_t)/128.0;} else if (u_is_size_zoom_constant && !u_is_size_feature_constant) {size=a_size_min/128.0;} else {size=u_size;}vec2 translated_a_pos=a_pos+u_translation;vec4 projectedPoint=projectTileWithElevation(translated_a_pos,ele);highp float camera_to_anchor_distance=projectedPoint.w;highp float distance_ratio=u_pitch_with_map ?\ncamera_to_anchor_distance/u_camera_to_center_distance :\nu_camera_to_center_distance/camera_to_anchor_distance;highp float perspective_ratio=clamp(0.5+0.5*distance_ratio,0.0,4.0);size*=perspective_ratio;float fontScale=u_is_text ? size/24.0 : size;highp float symbol_rotation=0.0;if (u_rotate_symbol) {vec4 offsetProjectedPoint=projectTileWithElevation(translated_a_pos+vec2(1,0),ele);vec2 a=projectedPoint.xy/projectedPoint.w;vec2 b=offsetProjectedPoint.xy/offsetProjectedPoint.w;symbol_rotation=atan((b.y-a.y)/u_aspect_ratio,b.x-a.x);}highp float angle_sin=sin(segment_angle+symbol_rotation);highp float angle_cos=cos(segment_angle+symbol_rotation);mat2 rotation_matrix=mat2(angle_cos,-1.0*angle_sin,angle_sin,angle_cos);vec4 projected_pos;if (u_is_along_line || u_is_variable_anchor) {projected_pos=vec4(a_projected_pos.xy,ele,1.0);} else if (u_pitch_with_map) {projected_pos=u_label_plane_matrix*vec4(a_projected_pos.xy+u_translation,ele,1.0);} else {projected_pos=u_label_plane_matrix*projectTileWithElevation(a_projected_pos.xy+u_translation,ele);}float z=float(u_pitch_with_map)*projected_pos.z/projected_pos.w;float projectionScaling=1.0;\n#ifdef GLOBE\nif(u_pitch_with_map) {float anchor_pos_tile_y=(u_coord_matrix*vec4(projected_pos.xy/projected_pos.w,z,1.0)).y;projectionScaling=mix(projectionScaling,1.0/circumferenceRatioAtTileY(anchor_pos_tile_y)*u_pitched_scale,u_projection_transition);}\n#endif\nvec4 finalPos=u_coord_matrix*vec4(projected_pos.xy/projected_pos.w+rotation_matrix*(a_offset/32.0*fontScale+a_pxoffset)*projectionScaling,z,1.0);if(u_pitch_with_map) {finalPos=projectTileWithElevation(finalPos.xy,finalPos.z);}float gamma_scale=finalPos.w;gl_Position=finalPos;vec2 fade_opacity=unpack_opacity(a_fade_opacity);float visibility=calculate_visibility(projectedPoint);float fade_change=fade_opacity[1] > 0.5 ? u_fade_change :-u_fade_change;float interpolated_fade_opacity=max(0.0,min(visibility,fade_opacity[0]+fade_change));v_data0=a_tex/u_texsize;v_data1=vec3(gamma_scale,size,interpolated_fade_opacity);}"),symbolTextAndIcon:ji("#define SDF_PX 8.0\n#define SDF 1.0\n#define ICON 0.0\nuniform bool u_is_halo;uniform sampler2D u_texture;uniform sampler2D u_texture_icon;uniform highp float u_gamma_scale;uniform lowp float u_device_pixel_ratio;in vec4 v_data0;in vec4 v_data1;\n#pragma mapbox: define highp vec4 fill_color\n#pragma mapbox: define highp vec4 halo_color\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp float halo_width\n#pragma mapbox: define lowp float halo_blur\nvoid main() {\n#pragma mapbox: initialize highp vec4 fill_color\n#pragma mapbox: initialize highp vec4 halo_color\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize lowp float halo_width\n#pragma mapbox: initialize lowp float halo_blur\nfloat fade_opacity=v_data1[2];if (v_data1.w==ICON) {vec2 tex_icon=v_data0.zw;lowp float alpha=opacity*fade_opacity;fragColor=texture(u_texture_icon,tex_icon)*alpha;\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\nreturn;}vec2 tex=v_data0.xy;float EDGE_GAMMA=0.105/u_device_pixel_ratio;float gamma_scale=v_data1.x;float size=v_data1.y;float fontScale=size/24.0;lowp vec4 color=fill_color;highp float gamma=EDGE_GAMMA/(fontScale*u_gamma_scale);lowp float buff=(256.0-64.0)/256.0;if (u_is_halo) {color=halo_color;gamma=(halo_blur*1.19/SDF_PX+EDGE_GAMMA)/(fontScale*u_gamma_scale);buff=(6.0-halo_width/fontScale)/SDF_PX;}lowp float dist=texture(u_texture,tex).a;highp float gamma_scaled=gamma*gamma_scale;highp float alpha=smoothstep(buff-gamma_scaled,buff+gamma_scaled,dist);fragColor=color*(alpha*opacity*fade_opacity);\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","in vec4 a_pos_offset;in vec4 a_data;in vec3 a_projected_pos;in float a_fade_opacity;uniform bool u_is_size_zoom_constant;uniform bool u_is_size_feature_constant;uniform highp float u_size_t;uniform highp float u_size;uniform mat4 u_label_plane_matrix;uniform mat4 u_coord_matrix;uniform bool u_is_text;uniform bool u_pitch_with_map;uniform highp float u_pitch;uniform bool u_rotate_symbol;uniform highp float u_aspect_ratio;uniform highp float u_camera_to_center_distance;uniform float u_fade_change;uniform vec2 u_texsize;uniform vec2 u_texsize_icon;uniform bool u_is_along_line;uniform bool u_is_variable_anchor;uniform vec2 u_translation;uniform float u_pitched_scale;out vec4 v_data0;out vec4 v_data1;\n#pragma mapbox: define highp vec4 fill_color\n#pragma mapbox: define highp vec4 halo_color\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp float halo_width\n#pragma mapbox: define lowp float halo_blur\nvoid main() {\n#pragma mapbox: initialize highp vec4 fill_color\n#pragma mapbox: initialize highp vec4 halo_color\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize lowp float halo_width\n#pragma mapbox: initialize lowp float halo_blur\nvec2 a_pos=a_pos_offset.xy;vec2 a_offset=a_pos_offset.zw;vec2 a_tex=a_data.xy;vec2 a_size=a_data.zw;float a_size_min=floor(a_size[0]*0.5);float is_sdf=a_size[0]-2.0*a_size_min;float ele=get_elevation(a_pos);highp float segment_angle=-a_projected_pos[2];float size;if (!u_is_size_zoom_constant && !u_is_size_feature_constant) {size=mix(a_size_min,a_size[1],u_size_t)/128.0;} else if (u_is_size_zoom_constant && !u_is_size_feature_constant) {size=a_size_min/128.0;} else {size=u_size;}vec2 translated_a_pos=a_pos+u_translation;vec4 projectedPoint=projectTileWithElevation(translated_a_pos,ele);highp float camera_to_anchor_distance=projectedPoint.w;highp float distance_ratio=u_pitch_with_map ?\ncamera_to_anchor_distance/u_camera_to_center_distance :\nu_camera_to_center_distance/camera_to_anchor_distance;highp float perspective_ratio=clamp(0.5+0.5*distance_ratio,0.0,4.0);size*=perspective_ratio;float fontScale=size/24.0;highp float symbol_rotation=0.0;if (u_rotate_symbol) {vec4 offsetProjectedPoint=projectTileWithElevation(translated_a_pos+vec2(1,0),ele);vec2 a=projectedPoint.xy/projectedPoint.w;vec2 b=offsetProjectedPoint.xy/offsetProjectedPoint.w;symbol_rotation=atan((b.y-a.y)/u_aspect_ratio,b.x-a.x);}highp float angle_sin=sin(segment_angle+symbol_rotation);highp float angle_cos=cos(segment_angle+symbol_rotation);mat2 rotation_matrix=mat2(angle_cos,-1.0*angle_sin,angle_sin,angle_cos);vec4 projected_pos;if (u_is_along_line || u_is_variable_anchor) {projected_pos=vec4(a_projected_pos.xy,ele,1.0);} else if (u_pitch_with_map) {projected_pos=u_label_plane_matrix*vec4(a_projected_pos.xy+u_translation,ele,1.0);} else {projected_pos=u_label_plane_matrix*projectTileWithElevation(a_projected_pos.xy+u_translation,ele);}float z=float(u_pitch_with_map)*projected_pos.z/projected_pos.w;float projectionScaling=1.0;\n#ifdef GLOBE\nif(u_pitch_with_map && !u_is_along_line) {float anchor_pos_tile_y=(u_coord_matrix*vec4(projected_pos.xy/projected_pos.w,z,1.0)).y;projectionScaling=mix(projectionScaling,1.0/circumferenceRatioAtTileY(anchor_pos_tile_y)*u_pitched_scale,u_projection_transition);}\n#endif\nvec4 finalPos=u_coord_matrix*vec4(projected_pos.xy/projected_pos.w+rotation_matrix*(a_offset/32.0*fontScale)*projectionScaling,z,1.0);if(u_pitch_with_map) {finalPos=projectTileWithElevation(finalPos.xy,finalPos.z);}float gamma_scale=finalPos.w;gl_Position=finalPos;vec2 fade_opacity=unpack_opacity(a_fade_opacity);float visibility=calculate_visibility(projectedPoint);float fade_change=fade_opacity[1] > 0.5 ? u_fade_change :-u_fade_change;float interpolated_fade_opacity=max(0.0,min(visibility,fade_opacity[0]+fade_change));v_data0.xy=a_tex/u_texsize;v_data0.zw=a_tex/u_texsize_icon;v_data1=vec4(gamma_scale,size,interpolated_fade_opacity,is_sdf);}"),terrain:ji("uniform sampler2D u_texture;uniform vec4 u_fog_color;uniform vec4 u_horizon_color;uniform float u_fog_ground_blend;uniform float u_fog_ground_blend_opacity;uniform float u_horizon_fog_blend;uniform bool u_is_globe_mode;in vec2 v_texture_pos;in float v_fog_depth;const float gamma=2.2;vec4 gammaToLinear(vec4 color) {return pow(color,vec4(gamma));}vec4 linearToGamma(vec4 color) {return pow(color,vec4(1.0/gamma));}void main() {vec4 surface_color=texture(u_texture,vec2(v_texture_pos.x,1.0-v_texture_pos.y));if (!u_is_globe_mode && v_fog_depth > u_fog_ground_blend) {vec4 surface_color_linear=gammaToLinear(surface_color);float blend_color=smoothstep(0.0,1.0,max((v_fog_depth-u_horizon_fog_blend)/(1.0-u_horizon_fog_blend),0.0));vec4 fog_horizon_color_linear=mix(gammaToLinear(u_fog_color),gammaToLinear(u_horizon_color),blend_color);float factor_fog=max(v_fog_depth-u_fog_ground_blend,0.0)/(1.0-u_fog_ground_blend);fragColor=linearToGamma(mix(surface_color_linear,fog_horizon_color_linear,pow(factor_fog,2.0)*u_fog_ground_blend_opacity));} else {fragColor=surface_color;}}","in vec3 a_pos3d;uniform mat4 u_fog_matrix;uniform float u_ele_delta;out vec2 v_texture_pos;out float v_fog_depth;void main() {float ele=get_elevation(a_pos3d.xy);float ele_delta=a_pos3d.z==1.0 ? u_ele_delta : 0.0;v_texture_pos=a_pos3d.xy/8192.0;gl_Position=projectTileFor3D(a_pos3d.xy,get_elevation(a_pos3d.xy)-ele_delta);vec4 pos=u_fog_matrix*vec4(a_pos3d.xy,ele,1.0);v_fog_depth=pos.z/pos.w*0.5+0.5;}"),terrainDepth:ji("in float v_depth;const highp vec4 bitSh=vec4(256.*256.*256.,256.*256.,256.,1.);const highp vec4 bitMsk=vec4(0.,vec3(1./256.0));highp vec4 pack(highp float value) {highp vec4 comp=fract(value*bitSh);comp-=comp.xxyz*bitMsk;return comp;}void main() {fragColor=pack(v_depth);}","in vec3 a_pos3d;uniform float u_ele_delta;out float v_depth;void main() {float ele=get_elevation(a_pos3d.xy);float ele_delta=a_pos3d.z==1.0 ? u_ele_delta : 0.0;gl_Position=projectTileFor3D(a_pos3d.xy,ele-ele_delta);v_depth=gl_Position.z/gl_Position.w;}"),terrainCoords:ji("precision mediump float;uniform sampler2D u_texture;uniform float u_terrain_coords_id;in vec2 v_texture_pos;void main() {vec4 rgba=texture(u_texture,v_texture_pos);fragColor=vec4(rgba.r,rgba.g,rgba.b,u_terrain_coords_id);}","in vec3 a_pos3d;uniform float u_ele_delta;out vec2 v_texture_pos;void main() {float ele=get_elevation(a_pos3d.xy);float ele_delta=a_pos3d.z==1.0 ? u_ele_delta : 0.0;v_texture_pos=a_pos3d.xy/8192.0;gl_Position=projectTileFor3D(a_pos3d.xy,ele-ele_delta);}"),projectionErrorMeasurement:ji("in vec4 v_output_error_encoded;void main() {fragColor=v_output_error_encoded;}","in vec2 a_pos;uniform highp float u_input;uniform highp float u_output_expected;out vec4 v_output_error_encoded;void main() {float real_output=2.0*atan(exp(PI-(u_input*PI*2.0)))-PI*0.5;float error=real_output-u_output_expected;float abs_error=abs(error)*128.0;v_output_error_encoded.x=min(floor(abs_error*256.0),255.0)/255.0;abs_error-=v_output_error_encoded.x;v_output_error_encoded.y=min(floor(abs_error*65536.0),255.0)/255.0;abs_error-=v_output_error_encoded.x/255.0;v_output_error_encoded.z=min(floor(abs_error*16777216.0),255.0)/255.0;v_output_error_encoded.w=error >=0.0 ? 1.0 : 0.0;gl_Position=vec4(a_pos,0.0,1.0);}"),atmosphere:ji("#ifdef GL_ES\nprecision highp float;\n#endif\nin vec3 view_direction;uniform vec3 u_sun_pos;uniform vec3 u_globe_position;uniform float u_globe_radius;uniform float u_atmosphere_blend;/**Shader use from https:*Made some change to adapt to MapLibre Globe geometry*/const float PI=3.141592653589793;const int iSteps=5;const int jSteps=3;/*radius of the planet*/const float EARTH_RADIUS=6371e3;/*radius of the atmosphere*/const float ATMOS_RADIUS=6471e3;vec2 rsi(vec3 r0,vec3 rd,float sr) {float a=dot(rd,rd);float b=2.0*dot(rd,r0);float c=dot(r0,r0)-(sr*sr);float d=(b*b)-4.0*a*c;if (d < 0.0) return vec2(1e5,-1e5);return vec2((-b-sqrt(d))/(2.0*a),(-b+sqrt(d))/(2.0*a));}vec4 atmosphere(vec3 r,vec3 r0,vec3 pSun,float iSun,float rPlanet,float rAtmos,vec3 kRlh,float kMie,float shRlh,float shMie,float g) {pSun=normalize(pSun);r=normalize(r);vec2 p=rsi(r0,r,rAtmos);if (p.x > p.y) {return vec4(0.0,0.0,0.0,1.0);}if (p.x < 0.0) {p.x=0.0;}vec3 pos=r0+r*p.x;vec2 p2=rsi(r0,r,rPlanet);if (p2.x <=p2.y && p2.x > 0.0) {p.y=min(p.y,p2.x);}float iStepSize=(p.y-p.x)/float(iSteps);float iTime=p.x+iStepSize*0.5;vec3 totalRlh=vec3(0,0,0);vec3 totalMie=vec3(0,0,0);float iOdRlh=0.0;float iOdMie=0.0;float mu=dot(r,pSun);float mumu=mu*mu;float gg=g*g;float pRlh=3.0/(16.0*PI)*(1.0+mumu);float pMie=3.0/(8.0*PI)*((1.0-gg)*(mumu+1.0))/(pow(1.0+gg-2.0*mu*g,1.5)*(2.0+gg));for (int i=0; i < iSteps; i++) {vec3 iPos=r0+r*iTime;float iHeight=length(iPos)-rPlanet;float odStepRlh=exp(-iHeight/shRlh)*iStepSize;float odStepMie=exp(-iHeight/shMie)*iStepSize;iOdRlh+=odStepRlh;iOdMie+=odStepMie;float jStepSize=rsi(iPos,pSun,rAtmos).y/float(jSteps);float jTime=jStepSize*0.5;float jOdRlh=0.0;float jOdMie=0.0;for (int j=0; j < jSteps; j++) {vec3 jPos=iPos+pSun*jTime;float jHeight=length(jPos)-rPlanet;jOdRlh+=exp(-jHeight/shRlh)*jStepSize;jOdMie+=exp(-jHeight/shMie)*jStepSize;jTime+=jStepSize;}vec3 attn=exp(-(kMie*(iOdMie+jOdMie)+kRlh*(iOdRlh+jOdRlh)));totalRlh+=odStepRlh*attn;totalMie+=odStepMie*attn;iTime+=iStepSize;}float opacity=exp(-(length(kRlh)*length(totalRlh)+kMie*length(totalMie)));vec3 color=iSun*(pRlh*kRlh*totalRlh+pMie*kMie*totalMie);return vec4(color,opacity);}void main() {vec3 scale_camera_pos=-u_globe_position*EARTH_RADIUS/u_globe_radius;vec4 color=atmosphere(normalize(view_direction),scale_camera_pos,u_sun_pos,22.0,EARTH_RADIUS,ATMOS_RADIUS,vec3(5.5e-6,13.0e-6,22.4e-6),21e-6,8e3,1.2e3,0.758\n);color.rgb=1.0-exp(-1.0*color.rgb);color=pow(color,vec4(1.0/2.2));fragColor=vec4(color.rgb,1.0-color.a)*u_atmosphere_blend;}","in vec2 a_pos;uniform mat4 u_inv_proj_matrix;out vec3 view_direction;void main() {view_direction=(u_inv_proj_matrix*vec4(a_pos,0.0,1.0)).xyz;gl_Position=vec4(a_pos,0.0,1.0);}"),sky:ji("uniform vec4 u_sky_color;uniform vec4 u_horizon_color;uniform vec2 u_horizon;uniform vec2 u_horizon_normal;uniform float u_sky_horizon_blend;uniform float u_sky_blend;void main() {float x=gl_FragCoord.x;float y=gl_FragCoord.y;float blend=(y-u_horizon.y)*u_horizon_normal.y+(x-u_horizon.x)*u_horizon_normal.x;if (blend > 0.0) {if (blend < u_sky_horizon_blend) {fragColor=mix(u_sky_color,u_horizon_color,pow(1.0-blend/u_sky_horizon_blend,2.0));} else {fragColor=u_sky_color;}}fragColor=mix(fragColor,vec4(vec3(0.0),0.0),u_sky_blend);}","in vec2 a_pos;void main() {gl_Position=vec4(a_pos,1.0,1.0);}")};function ji(e,s){const l=/#pragma mapbox: ([\w]+) ([\w]+) ([\w]+) ([\w]+)/g,c=s.match(/in ([\w]+) ([\w]+)/g),d=e.match(/uniform ([\w]+) ([\w]+)([\s]*)([\w]*)/g),p=s.match(/uniform ([\w]+) ([\w]+)([\s]*)([\w]*)/g),f=p?p.concat(d):d,m={};return{fragmentSource:e=e.replace(l,((e,s,l,c,d)=>(m[d]=!0,"define"===s?`\n#ifndef HAS_UNIFORM_u_${d}\nin ${l} ${c} ${d};\n#else\nuniform ${l} ${c} u_${d};\n#endif\n`:`\n#ifdef HAS_UNIFORM_u_${d}\n ${l} ${c} ${d} = u_${d};\n#endif\n`))),vertexSource:s=s.replace(l,((e,s,l,c,d)=>{const p="float"===c?"vec2":"vec4",f=d.match(/color/)?"color":p;return m[d]?"define"===s?`\n#ifndef HAS_UNIFORM_u_${d}\nuniform lowp float u_${d}_t;\nin ${l} ${p} a_${d};\nout ${l} ${c} ${d};\n#else\nuniform ${l} ${c} u_${d};\n#endif\n`:"vec4"===f?`\n#ifndef HAS_UNIFORM_u_${d}\n ${d} = a_${d};\n#else\n ${l} ${c} ${d} = u_${d};\n#endif\n`:`\n#ifndef HAS_UNIFORM_u_${d}\n ${d} = unpack_mix_${f}(a_${d}, u_${d}_t);\n#else\n ${l} ${c} ${d} = u_${d};\n#endif\n`:"define"===s?`\n#ifndef HAS_UNIFORM_u_${d}\nuniform lowp float u_${d}_t;\nin ${l} ${p} a_${d};\n#else\nuniform ${l} ${c} u_${d};\n#endif\n`:"vec4"===f?`\n#ifndef HAS_UNIFORM_u_${d}\n ${l} ${c} ${d} = a_${d};\n#else\n ${l} ${c} ${d} = u_${d};\n#endif\n`:`\n#ifndef HAS_UNIFORM_u_${d}\n ${l} ${c} ${d} = unpack_mix_${f}(a_${d}, u_${d}_t);\n#else\n ${l} ${c} ${d} = u_${d};\n#endif\n`})),staticAttributes:c,staticUniforms:f}}class kt{constructor(e,s,l){this.vertexBuffer=e,this.indexBuffer=s,this.segments=l}destroy(){this.vertexBuffer.destroy(),this.indexBuffer.destroy(),this.segments.destroy(),this.vertexBuffer=null,this.indexBuffer=null,this.segments=null}}var Ni=l.aU([{name:"a_pos",type:"Int16",components:2}]);const Gi="#define PROJECTION_MERCATOR",Ui="mercator";class jt{constructor(){this._cachedMesh=null}get name(){return"mercator"}get useSubdivision(){return!1}get shaderVariantName(){return Ui}get shaderDefine(){return Gi}get shaderPreludeCode(){return Vi.projectionMercator}get vertexShaderPreludeCode(){return Vi.projectionMercator.vertexSource}get subdivisionGranularity(){return l.aV.noSubdivision}get useGlobeControls(){return!1}get transitionState(){return 0}get latitudeErrorCorrectionRadians(){return 0}destroy(){}updateGPUdependent(e){}getMeshFromTileID(e,s,c,d,p){if(this._cachedMesh)return this._cachedMesh;const f=new l.aW;f.emplaceBack(0,0),f.emplaceBack(l.a5,0),f.emplaceBack(0,l.a5),f.emplaceBack(l.a5,l.a5);const m=e.createVertexBuffer(f,Ni.members),_=l.aX.simpleSegment(0,0,4,2),g=new l.aY;g.emplaceBack(1,0,2),g.emplaceBack(1,2,3);const y=e.createIndexBuffer(g);return this._cachedMesh=new kt(m,y,_),this._cachedMesh}recalculate(){}hasTransition(){return!1}setErrorQueryLatitudeDegrees(e){}}class Nt{constructor(e=0,s=0,l=0,c=0){if(isNaN(e)||e<0||isNaN(s)||s<0||isNaN(l)||l<0||isNaN(c)||c<0)throw new Error("Invalid value for edge-insets, top, bottom, left and right must all be numbers");this.top=e,this.bottom=s,this.left=l,this.right=c}interpolate(e,s,c){return null!=s.top&&null!=e.top&&(this.top=l.G.number(e.top,s.top,c)),null!=s.bottom&&null!=e.bottom&&(this.bottom=l.G.number(e.bottom,s.bottom,c)),null!=s.left&&null!=e.left&&(this.left=l.G.number(e.left,s.left,c)),null!=s.right&&null!=e.right&&(this.right=l.G.number(e.right,s.right,c)),this}getCenter(e,s){const c=l.an((this.left+e-this.right)/2,0,e),d=l.an((this.top+s-this.bottom)/2,0,s);return new l.P(c,d)}equals(e){return this.top===e.top&&this.bottom===e.bottom&&this.left===e.left&&this.right===e.right}clone(){return new Nt(this.top,this.bottom,this.left,this.right)}toJSON(){return{top:this.top,bottom:this.bottom,left:this.left,right:this.right}}}function qi(e,s){if(!e.renderWorldCopies||e.lngRange)return;const l=s.lng-e.center.lng;s.lng+=l>180?-360:l<-180?360:0}function $i(e){return Math.max(0,Math.floor(e))}class Ut{constructor(e,s){var c;this.applyConstrain=(e,s)=>null!==this._constrainOverride?this._constrainOverride(e,s):this._callbacks.defaultConstrain(e,s),this._callbacks=e,this._tileSize=512,this._renderWorldCopies=void 0===(null==s?void 0:s.renderWorldCopies)||!!(null==s?void 0:s.renderWorldCopies),this._minZoom=(null==s?void 0:s.minZoom)||0,this._maxZoom=(null==s?void 0:s.maxZoom)||22,this._minPitch=null==(null==s?void 0:s.minPitch)?0:null==s?void 0:s.minPitch,this._maxPitch=null==(null==s?void 0:s.maxPitch)?60:null==s?void 0:s.maxPitch,this._constrainOverride=null!==(c=null==s?void 0:s.constrainOverride)&&void 0!==c?c:null,this.setMaxBounds(),this._width=0,this._height=0,this._center=new l.V(0,0),this._elevation=0,this._zoom=0,this._tileZoom=$i(this._zoom),this._scale=l.aq(this._zoom),this._bearingInRadians=0,this._fovInRadians=.6435011087932844,this._pitchInRadians=0,this._rollInRadians=0,this._unmodified=!0,this._edgeInsets=new Nt,this._minElevationForCurrentTile=0,this._autoCalculateNearFarZ=!0}apply(e,s,c){this._constrainOverride=e.constrainOverride,this._latRange=e.latRange,this._lngRange=e.lngRange,this._width=e.width,this._height=e.height,this._center=e.center,this._elevation=e.elevation,this._minElevationForCurrentTile=e.minElevationForCurrentTile,this._zoom=e.zoom,this._tileZoom=$i(this._zoom),this._scale=l.aq(this._zoom),this._bearingInRadians=e.bearingInRadians,this._fovInRadians=e.fovInRadians,this._pitchInRadians=e.pitchInRadians,this._rollInRadians=e.rollInRadians,this._unmodified=e.unmodified,this._edgeInsets=new Nt(e.padding.top,e.padding.bottom,e.padding.left,e.padding.right),this._minZoom=e.minZoom,this._maxZoom=e.maxZoom,this._minPitch=e.minPitch,this._maxPitch=e.maxPitch,this._renderWorldCopies=e.renderWorldCopies,this._cameraToCenterDistance=e.cameraToCenterDistance,this._nearZ=e.nearZ,this._farZ=e.farZ,this._autoCalculateNearFarZ=!c&&e.autoCalculateNearFarZ,s&&this.constrainInternal(),this._calcMatrices()}get pixelsToClipSpaceMatrix(){return this._pixelsToClipSpaceMatrix}get clipSpaceToPixelsMatrix(){return this._clipSpaceToPixelsMatrix}get minElevationForCurrentTile(){return this._minElevationForCurrentTile}setMinElevationForCurrentTile(e){this._minElevationForCurrentTile=e}get tileSize(){return this._tileSize}get tileZoom(){return this._tileZoom}get scale(){return this._scale}get width(){return this._width}get height(){return this._height}get bearingInRadians(){return this._bearingInRadians}get lngRange(){return this._lngRange}get latRange(){return this._latRange}get pixelsToGLUnits(){return this._pixelsToGLUnits}get minZoom(){return this._minZoom}setMinZoom(e){this._minZoom!==e&&(this._minZoom=e,this.setZoom(this.applyConstrain(this._center,this.zoom).zoom))}get maxZoom(){return this._maxZoom}setMaxZoom(e){this._maxZoom!==e&&(this._maxZoom=e,this.setZoom(this.applyConstrain(this._center,this.zoom).zoom))}get minPitch(){return this._minPitch}setMinPitch(e){this._minPitch!==e&&(this._minPitch=e,this.setPitch(Math.max(this.pitch,e)))}get maxPitch(){return this._maxPitch}setMaxPitch(e){this._maxPitch!==e&&(this._maxPitch=e,this.setPitch(Math.min(this.pitch,e)))}get renderWorldCopies(){return this._renderWorldCopies}setRenderWorldCopies(e){void 0===e?e=!0:null===e&&(e=!1),this._renderWorldCopies=e}get constrainOverride(){return this._constrainOverride}setConstrainOverride(e){void 0===e&&(e=null),this._constrainOverride!==e&&(this._constrainOverride=e,this.constrainInternal(),this._calcMatrices())}get worldSize(){return this._tileSize*this._scale}get centerOffset(){return this.centerPoint._sub(this.size._div(2))}get size(){return new l.P(this._width,this._height)}get bearing(){return this._bearingInRadians/Math.PI*180}setBearing(e){const s=l.W(e,-180,180)*Math.PI/180;var c,p,f,m,_,g,y,b,T;this._bearingInRadians!==s&&(this._unmodified=!1,this._bearingInRadians=s,this._calcMatrices(),this._rotationMatrix=d(),c=this._rotationMatrix,f=-this._bearingInRadians,m=(p=this._rotationMatrix)[0],_=p[1],g=p[2],y=p[3],b=Math.sin(f),T=Math.cos(f),c[0]=m*T+g*b,c[1]=_*T+y*b,c[2]=m*-b+g*T,c[3]=_*-b+y*T)}get rotationMatrix(){return this._rotationMatrix}get pitchInRadians(){return this._pitchInRadians}get pitch(){return this._pitchInRadians/Math.PI*180}setPitch(e){const s=l.an(e,this.minPitch,this.maxPitch)/180*Math.PI;this._pitchInRadians!==s&&(this._unmodified=!1,this._pitchInRadians=s,this._calcMatrices())}get rollInRadians(){return this._rollInRadians}get roll(){return this._rollInRadians/Math.PI*180}setRoll(e){const s=e/180*Math.PI;this._rollInRadians!==s&&(this._unmodified=!1,this._rollInRadians=s,this._calcMatrices())}get fovInRadians(){return this._fovInRadians}get fov(){return l.aZ(this._fovInRadians)}setFov(e){e=l.an(e,.1,150),this.fov!==e&&(this._unmodified=!1,this._fovInRadians=l.ap(e),this._calcMatrices())}get zoom(){return this._zoom}setZoom(e){const s=this.applyConstrain(this._center,e).zoom;this._zoom!==s&&(this._unmodified=!1,this._zoom=s,this._tileZoom=Math.max(0,Math.floor(s)),this._scale=l.aq(s),this.constrainInternal(),this._calcMatrices())}get center(){return this._center}setCenter(e){e.lat===this._center.lat&&e.lng===this._center.lng||(this._unmodified=!1,this._center=e,this.constrainInternal(),this._calcMatrices())}get elevation(){return this._elevation}setElevation(e){e!==this._elevation&&(this._elevation=e,this.constrainInternal(),this._calcMatrices())}get padding(){return this._edgeInsets.toJSON()}setPadding(e){this._edgeInsets.equals(e)||(this._unmodified=!1,this._edgeInsets.interpolate(this._edgeInsets,e,1),this._calcMatrices())}get centerPoint(){return this._edgeInsets.getCenter(this._width,this._height)}get pixelsPerMeter(){return this._pixelPerMeter}get unmodified(){return this._unmodified}get cameraToCenterDistance(){return this._cameraToCenterDistance}get nearZ(){return this._nearZ}get farZ(){return this._farZ}get autoCalculateNearFarZ(){return this._autoCalculateNearFarZ}overrideNearFarZ(e,s){this._autoCalculateNearFarZ=!1,this._nearZ=e,this._farZ=s,this._calcMatrices()}clearNearFarZOverride(){this._autoCalculateNearFarZ=!0,this._calcMatrices()}isPaddingEqual(e){return this._edgeInsets.equals(e)}interpolatePadding(e,s,l){this._unmodified=!1,this._edgeInsets.interpolate(e,s,l),this.constrainInternal(),this._calcMatrices()}resize(e,s,l=!0){this._width=e,this._height=s,l&&this.constrainInternal(),this._calcMatrices()}getMaxBounds(){return this._latRange&&2===this._latRange.length&&this._lngRange&&2===this._lngRange.length?new $([this._lngRange[0],this._latRange[0]],[this._lngRange[1],this._latRange[1]]):null}setMaxBounds(e){e?(this._lngRange=[e.getWest(),e.getEast()],this._latRange=[e.getSouth(),e.getNorth()],this.constrainInternal()):(this._lngRange=null,this._latRange=[-l.ao,l.ao])}getCameraQueryGeometry(e,s){if(1===s.length)return[s[0],e];{const{minX:c,minY:d,maxX:p,maxY:f}=l.aa.fromPoints(s).extend(e);return[new l.P(c,d),new l.P(p,d),new l.P(p,f),new l.P(c,f),new l.P(c,d)]}}constrainInternal(){if(!this.center||!this._width||!this._height||this._constraining)return;this._constraining=!0;const e=this._unmodified,{center:s,zoom:l}=this.applyConstrain(this.center,this.zoom);this.setCenter(s),this.setZoom(l),this._unmodified=e,this._constraining=!1}_calcMatrices(){if(this._width&&this._height){this._pixelsToGLUnits=[2/this._width,-2/this._height];let e=l.ar(new Float64Array(16));l.Q(e,e,[this._width/2,-this._height/2,1]),l.O(e,e,[1,-1,0]),this._clipSpaceToPixelsMatrix=e,e=l.ar(new Float64Array(16)),l.Q(e,e,[1,-1,1]),l.O(e,e,[-1,-1,0]),l.Q(e,e,[2/this._width,2/this._height,1]),this._pixelsToClipSpaceMatrix=e,this._cameraToCenterDistance=.5/Math.tan(this.fovInRadians/2)*this._height}this._callbacks.calcMatrices()}calculateCenterFromCameraLngLatAlt(e,s,c,d){const p=void 0!==c?c:this.bearing,f=d=void 0!==d?d:this.pitch,{distanceToCenter:m,clampedElevation:_}=this._distanceToCenterFromAltElevationPitch(s,this.elevation,f),{x:g,y:y}=qe(f,p),b=l.a9.fromLngLat(e,s);let T,P,S=l.a_(1,b.y),I=0;do{if(I+=1,I>10)break;P=m/S,T=new l.a9(b.x+g*P,b.y+y*P),S=1/T.meterInMercatorCoordinateUnits()}while(Math.abs(m-P*S)>1e-12);return{center:T.toLngLat(),elevation:_,zoom:l.at(this.height/2/Math.tan(this.fovInRadians/2)/P/this.tileSize)}}recalculateZoomAndCenter(e){if(this.elevation-e==0)return;const s=1/this.worldSize,c=l.as(1,this.center.lat)*this.worldSize,d=l.a9.fromLngLat(this.center,this.elevation),p=d.x/s,f=d.y/s,m=d.z/s,_=this.pitch,g=this.bearing,{x:y,y:b,z:T}=qe(_,g),P=this.cameraToCenterDistance,S=p+P*-y,I=f+P*-b,C=m+P*T,{distanceToCenter:R,clampedElevation:L}=this._distanceToCenterFromAltElevationPitch(C/c,e,_),F=R*c,B=new l.a9((S+y*F)*s,(I+b*F)*s,0).toLngLat(),O=l.as(1,B.lat),j=l.at(this.height/2/Math.tan(this.fovInRadians/2)/R/O/this.tileSize);this._elevation=L,this._center=B,this.setZoom(j)}_distanceToCenterFromAltElevationPitch(e,s,c){const d=-Math.cos(l.ap(c)),p=e-s;let f,m=s;return d*p>=0||Math.abs(d)<.1?(f=1e4,m=e+f*d):f=-p/d,{distanceToCenter:f,clampedElevation:m}}getCameraPoint(){const e=Math.tan(this.pitchInRadians)*(this.cameraToCenterDistance||1);return this.centerPoint.add(new l.P(e*Math.sin(this.rollInRadians),e*Math.cos(this.rollInRadians)))}getCameraAltitude(){return Math.cos(this.pitchInRadians)*this._cameraToCenterDistance/this._pixelPerMeter+this.elevation}getCameraLngLat(){const e=l.as(1,this.center.lat)*this.worldSize;return Ue(this.center,this.elevation,this.pitch,this.bearing,this.cameraToCenterDistance/e).toLngLat()}getMercatorTileCoordinates(e){if(!e)return[0,0,1,1];const s=e.canonical.z>=0?1<this.max[0]||e.aabb.min[1]>this.max[1]||e.aabb.min[2]>this.max[2]||e.aabb.max[0]0?(s+=e[c]*this.min[c],l+=e[c]*this.max[c]):(l+=e[c]*this.min[c],s+=e[c]*this.max[c]);return s>=0?2:l<0?0:1}}class qt{distanceToTile2d(e,s,l,c){const d=c.distanceX([e,s]),p=c.distanceY([e,s]);return Math.hypot(d,p)}getWrap(e,s,l){return l}getTileBoundingVolume(e,s,c,d){var p,f;let m=0,_=0;if(null==d?void 0:d.terrain){const g=new l.a2(e.z,s,e.z,e.x,e.y),y=d.terrain.getMinMaxElevation(g);m=null!==(p=y.minElevation)&&void 0!==p?p:Math.min(0,c),_=null!==(f=y.maxElevation)&&void 0!==f?f:Math.max(0,c)}const g=1<d}allowWorldCopies(){return!0}prepareNextFrame(){}}class Wt{constructor(e,s,l){this.points=e,this.planes=s,this.aabb=l}static fromInvProjectionMatrix(e,s=1,c=0,d,p){const f=p?[[6,5,4],[0,1,2],[0,3,7],[2,1,5],[3,2,6],[0,4,5]]:[[0,1,2],[6,5,4],[0,3,7],[2,1,5],[3,2,6],[0,4,5]],m=Math.pow(2,c),_=[[-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((c=>function(e,s,c,d){const p=l.aH([],e,s),f=1/p[3]/c*d;return l.b6(p,p,[f,f,1/p[3],f])}(c,e,s,m)));d&&function(e,s,c,d){const p=d?4:0,f=d?0:4;let m=0;const _=[],g=[];for(let s=0;s<4;s++){const c=l.b2([],e[s+f],e[s+p]),d=l.b7(c);l.a$(c,c,1/d),_.push(d),g.push(c)}for(let s=0;s<4;s++){const d=l.b8(e[s+p],g[s],c);m=null!==d&&d>=0?Math.max(m,d):Math.max(m,_[s])}const y=function(e,s){const c=l.b2([],e[s[0]],e[s[1]]),d=l.b2([],e[s[2]],e[s[1]]),p=[0,0,0,0];return l.b3(p,l.b4([],c,d)),p[3]=-l.b5(p,e[s[0]]),p}(e,s),b=function(e,s){const c=l.b9(e),d=l.ba([],e,1/c),p=l.b2([],s,l.a$([],d,l.b5(s,d))),f=l.b9(p);if(f>0){const e=Math.sqrt(1-d[3]*d[3]),c=l.a$([],d,-d[3]),m=l.b0([],c,l.a$([],p,e/f));return l.bb(s,m)}return null}(c,y);if(null!==b){const e=b/l.b5(g[0],y);m=Math.min(m,e)}for(let s=0;s<4;s++){const l=Math.min(m,_[s]);e[s+f]=[e[s+p][0]+g[s][0]*l,e[s+p][1]+g[s][1]*l,e[s+p][2]+g[s][2]*l,1]}}(_,f[0],d,p);const g=f.map((e=>{const s=l.b2([],_[e[0]],_[e[1]]),c=l.b2([],_[e[2]],_[e[1]]),d=l.b3([],l.b4([],s,c)),p=-l.b5(d,_[e[1]]);return d.concat(p)})),y=[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY],b=[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY];for(const e of _)for(let s=0;s<3;s++)y[s]=Math.min(y[s],e[s]),b[s]=Math.max(b[s],e[s]);return new Wt(_,g,new Vt(y,b))}}class $t{get pixelsToClipSpaceMatrix(){return this._helper.pixelsToClipSpaceMatrix}get clipSpaceToPixelsMatrix(){return this._helper.clipSpaceToPixelsMatrix}get pixelsToGLUnits(){return this._helper.pixelsToGLUnits}get centerOffset(){return this._helper.centerOffset}get size(){return this._helper.size}get rotationMatrix(){return this._helper.rotationMatrix}get centerPoint(){return this._helper.centerPoint}get pixelsPerMeter(){return this._helper.pixelsPerMeter}setMinZoom(e){this._helper.setMinZoom(e)}setMaxZoom(e){this._helper.setMaxZoom(e)}setMinPitch(e){this._helper.setMinPitch(e)}setMaxPitch(e){this._helper.setMaxPitch(e)}setRenderWorldCopies(e){this._helper.setRenderWorldCopies(e)}setBearing(e){this._helper.setBearing(e)}setPitch(e){this._helper.setPitch(e)}setRoll(e){this._helper.setRoll(e)}setFov(e){this._helper.setFov(e)}setZoom(e){this._helper.setZoom(e)}setCenter(e){this._helper.setCenter(e)}setElevation(e){this._helper.setElevation(e)}setMinElevationForCurrentTile(e){this._helper.setMinElevationForCurrentTile(e)}setPadding(e){this._helper.setPadding(e)}interpolatePadding(e,s,l){return this._helper.interpolatePadding(e,s,l)}isPaddingEqual(e){return this._helper.isPaddingEqual(e)}resize(e,s,l=!0){this._helper.resize(e,s,l)}getMaxBounds(){return this._helper.getMaxBounds()}setMaxBounds(e){this._helper.setMaxBounds(e)}setConstrainOverride(e){this._helper.setConstrainOverride(e)}overrideNearFarZ(e,s){this._helper.overrideNearFarZ(e,s)}clearNearFarZOverride(){this._helper.clearNearFarZOverride()}getCameraQueryGeometry(e){return this._helper.getCameraQueryGeometry(this.getCameraPoint(),e)}get tileSize(){return this._helper.tileSize}get tileZoom(){return this._helper.tileZoom}get scale(){return this._helper.scale}get worldSize(){return this._helper.worldSize}get width(){return this._helper.width}get height(){return this._helper.height}get lngRange(){return this._helper.lngRange}get latRange(){return this._helper.latRange}get minZoom(){return this._helper.minZoom}get maxZoom(){return this._helper.maxZoom}get zoom(){return this._helper.zoom}get center(){return this._helper.center}get minPitch(){return this._helper.minPitch}get maxPitch(){return this._helper.maxPitch}get pitch(){return this._helper.pitch}get pitchInRadians(){return this._helper.pitchInRadians}get roll(){return this._helper.roll}get rollInRadians(){return this._helper.rollInRadians}get bearing(){return this._helper.bearing}get bearingInRadians(){return this._helper.bearingInRadians}get fov(){return this._helper.fov}get fovInRadians(){return this._helper.fovInRadians}get elevation(){return this._helper.elevation}get minElevationForCurrentTile(){return this._helper.minElevationForCurrentTile}get padding(){return this._helper.padding}get unmodified(){return this._helper.unmodified}get renderWorldCopies(){return this._helper.renderWorldCopies}get cameraToCenterDistance(){return this._helper.cameraToCenterDistance}get constrainOverride(){return this._helper.constrainOverride}get nearZ(){return this._helper.nearZ}get farZ(){return this._helper.farZ}get autoCalculateNearFarZ(){return this._helper.autoCalculateNearFarZ}setTransitionState(e,s){}constructor(e){this._posMatrixCache=new Map,this._alignedPosMatrixCache=new Map,this._fogMatrixCacheF32=new Map,this.defaultConstrain=(e,s)=>{s=l.an(+s,this.minZoom,this.maxZoom);const c={center:new l.V(e.lng,e.lat),zoom:s};let d=this._helper._lngRange;if(!this._helper._renderWorldCopies&&null===d){const e=180-1e-10;d=[-e,e]}const p=this.tileSize*l.aq(c.zoom);let f=0,m=p,_=0,g=p,y=0,b=0;const{x:T,y:P}=this.size;if(this._helper._latRange){const e=this._helper._latRange;f=l.X(e[1])*p,m=l.X(e[0])*p,m-fm&&(R=m-e)}if(d){const e=(_+g)/2;let s=S;this._helper._renderWorldCopies&&(s=l.W(S,e-p/2,e+p/2));const c=T/2;s-c<_&&(C=_+c),s+c>g&&(C=g-c)}if(void 0!==C||void 0!==R){const e=new l.P(null!=C?C:S,null!=R?R:I);c.center=Ae(p,e).wrap()}return c},this.applyConstrain=(e,s)=>this._helper.applyConstrain(e,s),this._helper=new Ut({calcMatrices:()=>{this._calcMatrices()},defaultConstrain:(e,s)=>this.defaultConstrain(e,s)},e),this._coveringTilesDetailsProvider=new qt}clone(){const e=new $t;return e.apply(this,!1),e}apply(e,s,l){this._helper.apply(e,s,l)}get cameraPosition(){return this._cameraPosition}get projectionMatrix(){return this._projectionMatrix}get modelViewProjectionMatrix(){return this._viewProjMatrix}get inverseProjectionMatrix(){return this._invProjMatrix}get mercatorMatrix(){return this._mercatorMatrix}getVisibleUnwrappedCoordinates(e){const s=[new l.bc(0,e)];if(this._helper._renderWorldCopies){const c=this.screenPointToMercatorCoordinate(new l.P(0,0)),d=this.screenPointToMercatorCoordinate(new l.P(this._helper._width,0)),p=this.screenPointToMercatorCoordinate(new l.P(this._helper._width,this._helper._height)),f=this.screenPointToMercatorCoordinate(new l.P(0,this._helper._height)),m=Math.floor(Math.min(c.x,d.x,p.x,f.x)),_=Math.floor(Math.max(c.x,d.x,p.x,f.x)),g=1;for(let c=m-g;c<=_+g;c++)0!==c&&s.push(new l.bc(c,e))}return s}getCameraFrustum(){return Wt.fromInvProjectionMatrix(this._invViewProjMatrix,this.worldSize)}getClippingPlane(){return null}getCoveringTilesDetailsProvider(){return this._coveringTilesDetailsProvider}recalculateZoomAndCenter(e){const s=this.screenPointToLocation(this.centerPoint,e),l=e?e.getElevationForLngLatZoom(s,this._helper._tileZoom):0;this._helper.recalculateZoomAndCenter(l)}setLocationAtPoint(e,s){const c=l.as(this.elevation,this.center.lat),d=this.screenPointToMercatorCoordinateAtZ(s,c),p=this.screenPointToMercatorCoordinateAtZ(this.centerPoint,c),f=l.a9.fromLngLat(e),m=new l.a9(f.x-(d.x-p.x),f.y-(d.y-p.y));this.setCenter(null==m?void 0:m.toLngLat()),this._helper._renderWorldCopies&&this.setCenter(this.center.wrap())}locationToScreenPoint(e,s){return s?this.coordinatePoint(l.a9.fromLngLat(e),s.getElevationForLngLat(e,this),this._pixelMatrix3D):this.coordinatePoint(l.a9.fromLngLat(e))}screenPointToLocation(e,s){var l;return null===(l=this.screenPointToMercatorCoordinate(e,s))||void 0===l?void 0:l.toLngLat()}screenPointToMercatorCoordinate(e,s){if(s){const l=s.pointCoordinate(e);if(null!=l)return l}return this.screenPointToMercatorCoordinateAtZ(e)}screenPointToMercatorCoordinateAtZ(e,s){const c=s||0,d=[e.x,e.y,0,1],p=[e.x,e.y,1,1];l.aH(d,d,this._pixelMatrixInverse),l.aH(p,p,this._pixelMatrixInverse);const f=d[3],m=p[3],_=d[1]/f,g=p[1]/m,y=d[2]/f,b=p[2]/m,T=y===b?0:(c-y)/(b-y);return new l.a9(l.G.number(d[0]/f,p[0]/m,T)/this.worldSize,l.G.number(_,g,T)/this.worldSize,c)}coordinatePoint(e,s=0,c=this._pixelMatrix){const d=[e.x*this.worldSize,e.y*this.worldSize,s,1];return l.aH(d,d,c),new l.P(d[0]/d[3],d[1]/d[3])}getBounds(){const e=Math.max(0,this._helper._height/2-Ne(this));return(new $).extend(this.screenPointToLocation(new l.P(0,e))).extend(this.screenPointToLocation(new l.P(this._helper._width,e))).extend(this.screenPointToLocation(new l.P(this._helper._width,this._helper._height))).extend(this.screenPointToLocation(new l.P(0,this._helper._height)))}isPointOnMapSurface(e,s){return s?null!=s.pointCoordinate(e):e.y>this.height/2-Ne(this)}calculatePosMatrix(e,s=!1,c){var d;const p=null!==(d=e.key)&&void 0!==d?d:l.bd(e.wrap,e.canonical.z,e.canonical.z,e.canonical.x,e.canonical.y),f=s?this._alignedPosMatrixCache:this._posMatrixCache;if(f.has(p)){const e=f.get(p);return c?e.f32:e.f64}const m=Ge(e,this.worldSize);l.S(m,s?this._alignedProjMatrix:this._viewProjMatrix,m);const _={f64:m,f32:new Float32Array(m)};return f.set(p,_),c?_.f32:_.f64}calculateFogMatrix(e){const s=e.key,c=this._fogMatrixCacheF32;if(c.has(s))return c.get(s);const d=Ge(e,this.worldSize);return l.S(d,this._fogMatrix,d),c.set(s,new Float32Array(d)),c.get(s)}calculateCenterFromCameraLngLatAlt(e,s,l,c){return this._helper.calculateCenterFromCameraLngLatAlt(e,s,l,c)}_calculateNearFarZIfNeeded(e,s,c){if(!this._helper.autoCalculateNearFarZ)return;const d=Math.min(this.elevation,this.minElevationForCurrentTile,this.getCameraAltitude()-100),p=e-d*this._helper._pixelPerMeter/Math.cos(s),f=d<0?p:e,m=Math.PI/2+this.pitchInRadians,_=l.ap(this.fov)*(Math.abs(Math.cos(l.ap(this.roll)))*this.height+Math.abs(Math.sin(l.ap(this.roll)))*this.width)/this.height*(.5+c.y/this.height),g=Math.sin(_)*f/Math.sin(l.an(Math.PI-m-_,.01,Math.PI-.01)),y=Ne(this),b=Math.atan(y/this._helper.cameraToCenterDistance),T=l.ap(.75),P=b>T?2*b*(.5+c.y/(2*y)):T,S=Math.sin(P)*f/Math.sin(l.an(Math.PI-m-P,.01,Math.PI-.01)),I=Math.min(g,S);this._helper._farZ=1.01*(Math.cos(Math.PI/2-s)*I+f),this._helper._nearZ=this._helper._height/50}_calcMatrices(){if(!this._helper._height)return;const e=this.centerOffset,s=Ce(this.worldSize,this.center),c=s.x,d=s.y;this._helper._pixelPerMeter=l.as(1,this.center.lat)*this.worldSize;const p=l.ap(Math.min(this.pitch,Ee)),f=Math.max(this._helper.cameraToCenterDistance/2,this._helper.cameraToCenterDistance+this._helper._elevation*this._helper._pixelPerMeter/Math.cos(p));let m;this._calculateNearFarZIfNeeded(f,p,e),m=new Float64Array(16),l.be(m,this.fovInRadians,this._helper._width/this._helper._height,this._helper._nearZ,this._helper._farZ),this._invProjMatrix=new Float64Array(16),l.aB(this._invProjMatrix,m),m[8]=2*-e.x/this._helper._width,m[9]=2*e.y/this._helper._height,this._projectionMatrix=l.bf(m),l.Q(m,m,[1,-1,1]),l.O(m,m,[0,0,-this._helper.cameraToCenterDistance]),l.bg(m,m,-this.rollInRadians),l.bh(m,m,this.pitchInRadians),l.bg(m,m,-this.bearingInRadians),l.O(m,m,[-c,-d,0]),this._mercatorMatrix=l.Q([],m,[this.worldSize,this.worldSize,this.worldSize]),l.Q(m,m,[1,1,this._helper._pixelPerMeter]),this._pixelMatrix=l.S(new Float64Array(16),this.clipSpaceToPixelsMatrix,m),l.O(m,m,[0,0,-this.elevation]),this._viewProjMatrix=m,this._invViewProjMatrix=l.aB([],m);const _=[0,0,-1,1];l.aH(_,_,this._invViewProjMatrix),this._cameraPosition=[_[0]/_[3],_[1]/_[3],_[2]/_[3]],this._fogMatrix=new Float64Array(16),l.be(this._fogMatrix,this.fovInRadians,this.width/this.height,f,this._helper._farZ),this._fogMatrix[8]=2*-e.x/this.width,this._fogMatrix[9]=2*e.y/this.height,l.Q(this._fogMatrix,this._fogMatrix,[1,-1,1]),l.O(this._fogMatrix,this._fogMatrix,[0,0,-this.cameraToCenterDistance]),l.bg(this._fogMatrix,this._fogMatrix,-this.rollInRadians),l.bh(this._fogMatrix,this._fogMatrix,this.pitchInRadians),l.bg(this._fogMatrix,this._fogMatrix,-this.bearingInRadians),l.O(this._fogMatrix,this._fogMatrix,[-c,-d,0]),l.Q(this._fogMatrix,this._fogMatrix,[1,1,this._helper._pixelPerMeter]),l.O(this._fogMatrix,this._fogMatrix,[0,0,-this.elevation]),this._pixelMatrix3D=l.S(new Float64Array(16),this.clipSpaceToPixelsMatrix,m);const g=this._helper._width%2/2,y=this._helper._height%2/2,b=Math.cos(this.bearingInRadians),T=Math.sin(-this.bearingInRadians),P=c-Math.round(c)+b*g+T*y,S=d-Math.round(d)+b*y+T*g,I=new Float64Array(m);if(l.O(I,I,[P>.5?P-1:P,S>.5?S-1:S,0]),this._alignedProjMatrix=I,m=l.aB(new Float64Array(16),this._pixelMatrix),!m)throw new Error("failed to invert matrix");this._pixelMatrixInverse=m,this._clearMatrixCaches()}_clearMatrixCaches(){this._posMatrixCache.clear(),this._alignedPosMatrixCache.clear(),this._fogMatrixCacheF32.clear()}maxPitchScaleFactor(){if(!this._pixelMatrixInverse)return 1;const e=this.screenPointToMercatorCoordinate(new l.P(0,0)),s=[e.x*this.worldSize,e.y*this.worldSize,0,1];return l.aH(s,s,this._pixelMatrix)[3]/this._helper.cameraToCenterDistance}getCameraPoint(){return this._helper.getCameraPoint()}getCameraAltitude(){return this._helper.getCameraAltitude()}getCameraLngLat(){const e=l.as(1,this.center.lat)*this.worldSize;return Ue(this.center,this.elevation,this.pitch,this.bearing,this._helper.cameraToCenterDistance/e).toLngLat()}lngLatToCameraDepth(e,s){const c=l.a9.fromLngLat(e),d=[c.x*this.worldSize,c.y*this.worldSize,s,1];return l.aH(d,d,this._viewProjMatrix),d[2]/d[3]}getProjectionData(e){const{overscaledTileID:s,aligned:c,applyTerrainMatrix:d}=e,p=this._helper.getMercatorTileCoordinates(s),f=s?this.calculatePosMatrix(s,c,!0):null;let m;return m=s&&s.terrainRttPosMatrix32f&&d?s.terrainRttPosMatrix32f:f||l.bi(),{mainMatrix:m,tileMercatorCoords:p,clippingPlane:[0,0,0,0],projectionTransition:0,fallbackMatrix:m}}isLocationOccluded(e){return!1}getPixelScale(){return 1}getCircleRadiusCorrection(){return 1}getPitchedTextCorrection(e,s,l){return 1}transformLightDirection(e){return l.b1(e)}getRayDirectionFromPixel(e){throw new Error("Not implemented.")}projectTileCoordinates(e,s,c,d){const p=this.calculatePosMatrix(c);let f;d?(f=[e,s,d(e,s),1],l.aH(f,f,p)):(f=[e,s,0,1],mi(f,f,p));const m=f[3];return{point:new l.P(f[0]/m,f[1]/m),signedDistanceFromCamera:m,isOccluded:!1}}populateCache(e){for(const s of e)this.calculatePosMatrix(s)}getMatrixForModel(e,s){const c=l.a9.fromLngLat(e,s),d=c.meterInMercatorCoordinateUnits(),p=l.bj();return l.O(p,p,[c.x,c.y,c.z]),l.bg(p,p,Math.PI),l.bh(p,p,Math.PI/2),l.Q(p,p,[-d,d,d]),p}getProjectionDataForCustomLayer(e=!0){const s=new l.a2(0,0,0,0,0),c=this.getProjectionData({overscaledTileID:s,applyGlobeMatrix:e}),d=Ge(s,this.worldSize);l.S(d,this._viewProjMatrix,d),c.tileMercatorCoords=[0,0,1,1];const p=[l.a5,l.a5,this.worldSize/this._helper.pixelsPerMeter],f=l.bk();return l.Q(f,d,p),c.fallbackMatrix=f,c.mainMatrix=f,c}getFastPathSimpleProjectionMatrix(e){return this.calculatePosMatrix(e)}}function Wi(){l.w("Map cannot fit within canvas with the given bounds, padding, and/or offset.")}function Hi(e){if(e.useSlerp)if(e.k<1){const s=l.bl(e.startEulerAngles.roll,e.startEulerAngles.pitch,e.startEulerAngles.bearing),c=l.bl(e.endEulerAngles.roll,e.endEulerAngles.pitch,e.endEulerAngles.bearing),d=new Float64Array(4);l.bm(d,s,c,e.k);const p=l.bn(d);e.tr.setRoll(p.roll),e.tr.setPitch(p.pitch),e.tr.setBearing(p.bearing)}else e.tr.setRoll(e.endEulerAngles.roll),e.tr.setPitch(e.endEulerAngles.pitch),e.tr.setBearing(e.endEulerAngles.bearing);else e.tr.setRoll(l.G.number(e.startEulerAngles.roll,e.endEulerAngles.roll,e.k)),e.tr.setPitch(l.G.number(e.startEulerAngles.pitch,e.endEulerAngles.pitch,e.k)),e.tr.setBearing(l.G.number(e.startEulerAngles.bearing,e.endEulerAngles.bearing,e.k))}function Xi(e,s,c,d,p){const f=p.padding,m=Ce(p.worldSize,c.getNorthWest()),_=Ce(p.worldSize,c.getNorthEast()),g=Ce(p.worldSize,c.getSouthEast()),y=Ce(p.worldSize,c.getSouthWest()),b=l.ap(-d),T=m.rotate(b),P=_.rotate(b),S=g.rotate(b),I=y.rotate(b),C=new l.P(Math.max(T.x,P.x,I.x,S.x),Math.max(T.y,P.y,I.y,S.y)),R=new l.P(Math.min(T.x,P.x,I.x,S.x),Math.min(T.y,P.y,I.y,S.y)),L=C.sub(R),F=(p.width-(f.left+f.right+s.left+s.right))/L.x,B=(p.height-(f.top+f.bottom+s.top+s.bottom))/L.y;if(B<0||F<0)return void Wi();const O=Math.min(l.at(p.scale*Math.min(F,B)),e.maxZoom),j=l.P.convert(e.offset),G=new l.P((s.left-s.right)/2,(s.top-s.bottom)/2).rotate(l.ap(d)),U=j.add(G).mult(p.scale/l.aq(O));return{center:Ae(p.worldSize,m.add(g).div(2).sub(U)),zoom:O,bearing:d}}class Yt{get useGlobeControls(){return!1}handlePanInertia(e,s){const l=e.mag(),c=Math.abs(Ne(s));return{easingOffset:e.mult(Math.min(.75*c/l,1)),easingCenter:s.center}}handleMapControlsRollPitchBearingZoom(e,s){e.bearingDelta&&s.setBearing(s.bearing+e.bearingDelta),e.pitchDelta&&s.setPitch(s.pitch+e.pitchDelta),e.rollDelta&&s.setRoll(s.roll+e.rollDelta),e.zoomDelta&&s.setZoom(s.zoom+e.zoomDelta)}handleMapControlsPan(e,s,l){e.around.distSqr(s.centerPoint)<.01||s.setLocationAtPoint(l,e.around)}cameraForBoxAndBearing(e,s,l,c,d){return Xi(e,s,l,c,d)}handleJumpToCenterZoom(e,s){e.zoom!==(void 0!==s.zoom?+s.zoom:e.zoom)&&e.setZoom(+s.zoom),void 0!==s.center&&e.setCenter(l.V.convert(s.center))}handleEaseTo(e,s){const c=e.zoom,d=e.padding,p={roll:e.roll,pitch:e.pitch,bearing:e.bearing},f={roll:void 0===s.roll?e.roll:s.roll,pitch:void 0===s.pitch?e.pitch:s.pitch,bearing:void 0===s.bearing?e.bearing:s.bearing},m=void 0!==s.zoom,_=!e.isPaddingEqual(s.padding);let g=!1;const y=m?+s.zoom:e.zoom;let b=e.centerPoint.add(s.offsetAsPoint);const T=e.screenPointToLocation(b),{center:P,zoom:S}=e.applyConstrain(l.V.convert(s.center||T),null!=y?y:c);qi(e,P);const I=Ce(e.worldSize,T),C=Ce(e.worldSize,P).sub(I),R=l.aq(S-c);return g=S!==c,{easeFunc:m=>{if(g&&e.setZoom(l.G.number(c,S,m)),l.bo(p,f)||Hi({startEulerAngles:p,endEulerAngles:f,tr:e,k:m,useSlerp:p.roll!=f.roll}),_&&(e.interpolatePadding(d,s.padding,m),b=e.centerPoint.add(s.offsetAsPoint)),s.around)e.setLocationAtPoint(s.around,s.aroundPoint);else{const s=l.aq(e.zoom-c),d=S>c?Math.min(2,R):Math.max(.5,R),p=Math.pow(d,1-m),f=Ae(e.worldSize,I.add(C.mult(m*p)).mult(s));e.setLocationAtPoint(e.renderWorldCopies?f.wrap():f,b)}},isZooming:g,elevationCenter:P}}handleFlyTo(e,s){const c=void 0!==s.zoom,d=e.zoom,p=e.applyConstrain(l.V.convert(s.center||s.locationAtOffset),c?+s.zoom:d),f=p.center,m=p.zoom;qi(e,f);const _=Ce(e.worldSize,s.locationAtOffset),g=Ce(e.worldSize,f).sub(_),y=g.mag(),b=l.aq(m-d);let T;if(void 0!==s.minZoom){const c=Math.min(+s.minZoom,d,m),p=e.applyConstrain(f,c).zoom;T=l.aq(p-d)}return{easeFunc:(s,c,p,y)=>{e.setZoom(1===s?m:d+l.at(c));const b=1===s?f:Ae(e.worldSize,_.add(g.mult(p)).mult(c));e.setLocationAtPoint(e.renderWorldCopies?b.wrap():b,y)},scaleOfZoom:b,targetCenter:f,scaleOfMinZoom:T,pixelPathLength:y}}}class Qt{constructor(e,s,l){this.blendFunction=e,this.blendColor=s,this.mask=l}}Qt.Replace=[1,0],Qt.disabled=new Qt(Qt.Replace,l.bp.transparent,[!1,!1,!1,!1]),Qt.unblended=new Qt(Qt.Replace,l.bp.transparent,[!0,!0,!0,!0]),Qt.alphaBlended=new Qt([1,771],l.bp.transparent,[!0,!0,!0,!0]);const Yi=2305;class ei{constructor(e,s,l){this.enable=e,this.mode=s,this.frontFace=l}}ei.disabled=new ei(!1,1029,Yi),ei.backCCW=new ei(!0,1029,Yi),ei.frontCCW=new ei(!0,1028,Yi);class ti{constructor(e,s,l){this.func=e,this.mask=s,this.range=l}}ti.ReadOnly=!1,ti.ReadWrite=!0,ti.disabled=new ti(519,ti.ReadOnly,[0,1]);const Ki=7680;class ai{constructor(e,s,l,c,d,p){this.test=e,this.ref=s,this.mask=l,this.fail=c,this.depthFail=d,this.pass=p}}ai.disabled=new ai({func:519,mask:0},0,0,Ki,Ki,Ki);const Qi=new WeakMap;function Ji(e){var s;if(Qi.has(e))return Qi.get(e);{const l=null===(s=e.getParameter(e.VERSION))||void 0===s?void 0:s.startsWith("WebGL 2.0");return Qi.set(e,l),l}}class si{get awaitingQuery(){return!!this._readbackQueue}constructor(e){this._readbackWaitFrames=4,this._measureWaitFrames=6,this._texWidth=1,this._texHeight=1,this._measuredError=0,this._updateCount=0,this._lastReadbackFrame=-1e3,this._readbackQueue=null,this._cachedRenderContext=e;const s=e.context,c=s.gl;this._texFormat=c.RGBA,this._texType=c.UNSIGNED_BYTE;const d=new l.aW;d.emplaceBack(-1,-1),d.emplaceBack(2,-1),d.emplaceBack(-1,2);const p=new l.aY;p.emplaceBack(0,1,2),this._fullscreenTriangle=new kt(s.createVertexBuffer(d,Ni.members),s.createIndexBuffer(p),l.aX.simpleSegment(0,0,d.length,p.length)),this._resultBuffer=new Uint8Array(4),s.activeTexture.set(c.TEXTURE1);const f=c.createTexture();c.bindTexture(c.TEXTURE_2D,f),c.texParameteri(c.TEXTURE_2D,c.TEXTURE_WRAP_S,c.CLAMP_TO_EDGE),c.texParameteri(c.TEXTURE_2D,c.TEXTURE_WRAP_T,c.CLAMP_TO_EDGE),c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MIN_FILTER,c.NEAREST),c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MAG_FILTER,c.NEAREST),c.texImage2D(c.TEXTURE_2D,0,this._texFormat,this._texWidth,this._texHeight,0,this._texFormat,this._texType,null),this._fbo=s.createFramebuffer(this._texWidth,this._texHeight,!1,!1),this._fbo.colorAttachment.set(f),Ji(c)&&(this._pbo=c.createBuffer(),c.bindBuffer(c.PIXEL_PACK_BUFFER,this._pbo),c.bufferData(c.PIXEL_PACK_BUFFER,4,c.STREAM_READ),c.bindBuffer(c.PIXEL_PACK_BUFFER,null))}destroy(){const e=this._cachedRenderContext.context.gl;this._fullscreenTriangle.destroy(),this._fbo.destroy(),e.deleteBuffer(this._pbo),this._fullscreenTriangle=null,this._fbo=null,this._pbo=null,this._resultBuffer=null}updateErrorLoop(e,s){const l=this._updateCount;return this._readbackQueue?l>=this._readbackQueue.frameNumberIssued+this._readbackWaitFrames&&this._tryReadback():l>=this._lastReadbackFrame+this._measureWaitFrames&&this._renderErrorTexture(e,s),this._updateCount++,this._measuredError}_bindFramebuffer(){const e=this._cachedRenderContext.context,s=e.gl;e.activeTexture.set(s.TEXTURE1),s.bindTexture(s.TEXTURE_2D,this._fbo.colorAttachment.get()),e.bindFramebuffer.set(this._fbo.framebuffer)}_renderErrorTexture(e,s){const c=this._cachedRenderContext.context,d=c.gl;if(this._bindFramebuffer(),c.viewport.set([0,0,this._texWidth,this._texHeight]),c.clear({color:l.bp.transparent}),this._cachedRenderContext.useProgram("projectionErrorMeasurement").draw(c,d.TRIANGLES,ti.disabled,ai.disabled,Qt.unblended,ei.disabled,((e,s)=>({u_input:e,u_output_expected:s}))(e,s),null,null,"$clipping",this._fullscreenTriangle.vertexBuffer,this._fullscreenTriangle.indexBuffer,this._fullscreenTriangle.segments),this._pbo&&Ji(d)){d.bindBuffer(d.PIXEL_PACK_BUFFER,this._pbo),d.readBuffer(d.COLOR_ATTACHMENT0),d.readPixels(0,0,this._texWidth,this._texHeight,this._texFormat,this._texType,0),d.bindBuffer(d.PIXEL_PACK_BUFFER,null);const e=d.fenceSync(d.SYNC_GPU_COMMANDS_COMPLETE,0);d.flush(),this._readbackQueue={frameNumberIssued:this._updateCount,sync:e}}else this._readbackQueue={frameNumberIssued:this._updateCount,sync:null}}_tryReadback(){const e=this._cachedRenderContext.context.gl;if(this._pbo&&this._readbackQueue&&Ji(e)){const s=e.clientWaitSync(this._readbackQueue.sync,0,0);if(s===e.WAIT_FAILED)return l.w("WebGL2 clientWaitSync failed."),this._readbackQueue=null,void(this._lastReadbackFrame=this._updateCount);if(s===e.TIMEOUT_EXPIRED)return;e.bindBuffer(e.PIXEL_PACK_BUFFER,this._pbo),e.getBufferSubData(e.PIXEL_PACK_BUFFER,0,this._resultBuffer,0,4),e.bindBuffer(e.PIXEL_PACK_BUFFER,null)}else this._bindFramebuffer(),e.readPixels(0,0,this._texWidth,this._texHeight,this._texFormat,this._texType,this._resultBuffer);this._readbackQueue=null,this._measuredError=si._parseRGBA8float(this._resultBuffer),this._lastReadbackFrame=this._updateCount}static _parseRGBA8float(e){let s=0;return s+=e[0]/256,s+=e[1]/65536,s+=e[2]/16777216,e[3]<127&&(s=-s),s/128}}const lr=l.a5/128;function cr(e,s){const c=void 0!==e.granularity?Math.max(e.granularity,1):1,d=c+(e.generateBorders?2:0),p=c+(e.extendToNorthPole||e.generateBorders?1:0)+(e.extendToSouthPole||e.generateBorders?1:0),f=d+1,m=p+1,_=e.generateBorders?-1:0,g=e.generateBorders||e.extendToNorthPole?-1:0,y=c+(e.generateBorders?1:0),b=c+(e.generateBorders||e.extendToSouthPole?1:0),T=f*m,P=d*p*6,S=f*m>65536;if(S&&"16bit"===s)throw new Error("Granularity is too large and meshes would not fit inside 16 bit vertex indices.");const I=S||"32bit"===s,C=new Int16Array(2*T);let R=0;for(let s=g;s<=b;s++)for(let d=_;d<=y;d++){let p=d/c*l.a5;-1===d&&(p=-lr),d===c+1&&(p=l.a5+lr);let f=s/c*l.a5;-1===s&&(f=e.extendToNorthPole?l.br:-lr),s===c+1&&(f=e.extendToSouthPole?l.bs:l.a5+lr),C[R++]=p,C[R++]=f}const L=I?new Uint32Array(P):new Uint16Array(P);let F=0;for(let e=0;e0}get latitudeErrorCorrectionRadians(){return this._verticalPerspectiveProjection.latitudeErrorCorrectionRadians}get currentProjection(){return this.useGlobeRendering?this._verticalPerspectiveProjection:this._mercatorProjection}get name(){return"globe"}get useSubdivision(){return this.currentProjection.useSubdivision}get shaderVariantName(){return this.currentProjection.shaderVariantName}get shaderDefine(){return this.currentProjection.shaderDefine}get shaderPreludeCode(){return this.currentProjection.shaderPreludeCode}get vertexShaderPreludeCode(){return this.currentProjection.vertexShaderPreludeCode}get subdivisionGranularity(){return this.currentProjection.subdivisionGranularity}get useGlobeControls(){return this.transitionState>0}destroy(){this._mercatorProjection.destroy(),this._verticalPerspectiveProjection.destroy()}updateGPUdependent(e){this._mercatorProjection.updateGPUdependent(e),this._verticalPerspectiveProjection.updateGPUdependent(e)}getMeshFromTileID(e,s,l,c,d){return this.currentProjection.getMeshFromTileID(e,s,l,c,d)}setProjection(e){this._transitionable.setValue("type",(null==e?void 0:e.type)||"mercator")}updateTransitions(e){this._transitioning=this._transitionable.transitioned(e,this._transitioning)}hasTransition(){return this._transitioning.hasTransition()||this.currentProjection.hasTransition()}recalculate(e){this.properties=this._transitioning.possiblyEvaluate(e)}setErrorQueryLatitudeDegrees(e){this._verticalPerspectiveProjection.setErrorQueryLatitudeDegrees(e),this._mercatorProjection.setErrorQueryLatitudeDegrees(e)}}function dr(e){const s=gr(e.worldSize,e.center.lat);return 2*Math.PI*s}function pr(e,s,c,d,p){const f=1/(1<1e-6){const d=e[0]/c,p=Math.acos(e[2]/c),f=(d>0?p:-p)/Math.PI*180;return new l.V(l.W(f,-180,180),s)}return new l.V(0,s)}function xr(e){return Math.cos(e*Math.PI/180)}function vr(e,s){const c=xr(e),d=xr(s);return l.at(d/c)}function br(e,s){const c=e.rotate(s.bearingInRadians),d=s.zoom+vr(s.center.lat,0),p=l.bu(1/xr(s.center.lat),1/xr(Math.min(Math.abs(s.center.lat),60)),l.bx(d,7,3,0,1)),f=360/dr({worldSize:s.worldSize,center:{lat:s.center.lat}});return new l.V(s.center.lng-c.x*f*p,l.an(s.center.lat+c.y*f,-l.ao,l.ao))}function wr(e){const s=.5*e,l=Math.sin(s),c=Math.cos(s);return Math.log(l+c)-Math.log(c-l)}function Pr(e,s,c,d){const p=e.lat+c*d;if(Math.abs(c)>1){const f=(Math.sign(e.lat+c)!==Math.sign(e.lat)?-Math.abs(e.lat):Math.abs(e.lat))*Math.PI/180,m=Math.abs(e.lat+c)*Math.PI/180,_=wr(f+d*(m-f)),g=wr(f),y=wr(m);return new l.V(e.lng+s*((_-g)/(y-g)),p)}return new l.V(e.lng+s*d,p)}class Ti{constructor(e){this._cachePrevious=new Map,this._cache=new Map,this._hadAnyChanges=!1,this._boundingVolumeFactory=e}swapBuffers(){if(!this._hadAnyChanges)return;const e=this._cachePrevious;this._cachePrevious=this._cache,this._cache=e,this._cache.clear(),this._hadAnyChanges=!1}getTileBoundingVolume(e,s,l,c){const d=`${e.z}_${e.x}_${e.y}_${(null==c?void 0:c.terrain)?"t":""}`,p=this._cache.get(d);if(p)return p;const f=this._cachePrevious.get(d);if(f)return this._cache.set(d,f),f;const m=this._boundingVolumeFactory(e,s,l,c);return this._cache.set(d,m),this._hadAnyChanges=!0,m}}class Pi{constructor(e,s,l,c){this.min=l,this.max=c,this.points=e,this.planes=s}static fromAabb(e,s){const l=[];for(let c=0;c<8;c++)l.push([1&~c?e[0]:s[0],1==(c>>1&1)?s[1]:e[1],1==(c>>2&1)?s[2]:e[2]]);return new Pi(l,[[-1,0,0,s[0]],[1,0,0,-e[0]],[0,-1,0,s[1]],[0,1,0,-e[1]],[0,0,-1,s[2]],[0,0,1,-e[2]]],e,s)}static fromCenterSizeAngles(e,s,c){const d=l.bB([],c[0],c[1],c[2]),p=l.bC([],[s[0],0,0],d),f=l.bC([],[0,s[1],0],d),m=l.bC([],[0,0,s[2]],d),_=[...e],g=[...e];for(let s=0;s<8;s++)for(let l=0;l<3;l++){const c=e[l]+p[l]*(1&~s?-1:1)+f[l]*(1==(s>>1&1)?1:-1)+m[l]*(1==(s>>2&1)?1:-1);_[l]=Math.min(_[l],c),g[l]=Math.max(g[l],c)}const y=[];for(let s=0;s<8;s++){const c=[...e];l.b0(c,c,l.a$([],p,1&~s?-1:1)),l.b0(c,c,l.a$([],f,1==(s>>1&1)?1:-1)),l.b0(c,c,l.a$([],m,1==(s>>2&1)?1:-1)),y.push(c)}return new Pi(y,[[...p,-l.b5(p,y[0])],[...f,-l.b5(f,y[0])],[...m,-l.b5(m,y[0])],[-p[0],-p[1],-p[2],-l.b5(p,y[7])],[-f[0],-f[1],-f[2],-l.b5(f,y[7])],[-m[0],-m[1],-m[2],-l.b5(m,y[7])]],_,g)}intersectsFrustum(e){let s=!0;const l=this.points.length,c=this.planes.length,d=e.planes.length,p=e.points.length;for(let c=0;c=0&&p++}if(0===p)return 0;p=0&&c++}if(0===c)return 0}return 1}intersectsPlane(e){const s=this.points.length;let l=0;for(let c=0;c=0&&l++}return l===s?2:0===l?0:1}}function Sr(e,s,l){const c=e-s;return c<0?-c:Math.max(0,c-l)}function Cr(e,s,l,c,d){const p=e-l;let f;return f=p<0?Math.min(-p,1+p-d):p>1?Math.min(Math.max(p-d,0),1-p):0,Math.max(f,Sr(s,c,d))}class Mi{constructor(){this._boundingVolumeCache=new Ti(this._computeTileBoundingVolume)}prepareNextFrame(){this._boundingVolumeCache.swapBuffers()}distanceToTile2d(e,s,l,c){const d=1<4}allowWorldCopies(){return!1}getTileBoundingVolume(e,s,l,c){return this._boundingVolumeCache.getTileBoundingVolume(e,s,l,c)}_computeTileBoundingVolume(e,s,c,d){var p,f;let m=0,_=0;if(null==d?void 0:d.terrain){const g=new l.a2(e.z,s,e.z,e.x,e.y),y=d.terrain.getMinMaxElevation(g);m=null!==(p=y.minElevation)&&void 0!==p?p:Math.min(0,c),_=null!==(f=y.maxElevation)&&void 0!==f?f:Math.max(0,c)}if(m/=l.bE,_/=l.bE,m+=1,_+=1,e.z<=0)return Pi.fromAabb([-_,-_,-_],[_,_,_]);if(1===e.z)return Pi.fromAabb([0===e.x?-_:0,0===e.y?0:-_,-_],[0===e.x?0:_,0===e.y?_:0,_]);{const s=[pr(0,0,e.x,e.y,e.z),pr(l.a5,0,e.x,e.y,e.z),pr(l.a5,l.a5,e.x,e.y,e.z),pr(0,l.a5,e.x,e.y,e.z)],c=[];for(const e of s)c.push(l.a$([],e,_));if(_!==m)for(const e of s)c.push(l.a$([],e,m));0===e.y&&c.push([0,1,0]),e.y===(1<=(1<{const c=l.an(e.lat,-l.ao,l.ao),d=l.an(+s,this.minZoom+vr(0,c),this.maxZoom);return{center:new l.V(e.lng,c),zoom:d}},this.applyConstrain=(e,s)=>this._helper.applyConstrain(e,s),this._helper=new Ut({calcMatrices:()=>{this._calcMatrices()},defaultConstrain:(e,s)=>this.defaultConstrain(e,s)},e),this._coveringTilesDetailsProvider=new Mi}clone(){const e=new Si;return e.apply(this,!1),e}apply(e,s,l){this._globeLatitudeErrorCorrectionRadians=l||0,this._helper.apply(e,s)}get projectionMatrix(){return this._projectionMatrix}get modelViewProjectionMatrix(){return this._globeViewProjMatrixNoCorrection}get inverseProjectionMatrix(){return this._globeProjMatrixInverted}get cameraPosition(){const e=l.bz();return e[0]=this._cameraPosition[0],e[1]=this._cameraPosition[1],e[2]=this._cameraPosition[2],e}get cameraToCenterDistance(){return this._helper.cameraToCenterDistance}getProjectionData(e){const{overscaledTileID:s,applyGlobeMatrix:l}=e,c=this._helper.getMercatorTileCoordinates(s);return{mainMatrix:this._globeViewProjMatrix32f,tileMercatorCoords:c,clippingPlane:this._cachedClippingPlane,projectionTransition:l?1:0,fallbackMatrix:this._globeViewProjMatrix32f}}_computeClippingPlane(e){const s=this.pitchInRadians,c=this.cameraToCenterDistance/e,d=Math.sin(s)*c,p=Math.cos(s)*c+1,f=1/Math.sqrt(d*d+p*p)*1;let m=-d,_=p;const g=Math.sqrt(m*m+_*_);m/=g,_/=g;const y=[0,m,_];l.bG(y,y,[0,0,0],-this.bearingInRadians),l.bH(y,y,[0,0,0],-1*this.center.lat*Math.PI/180),l.bI(y,y,[0,0,0],this.center.lng*Math.PI/180);const b=1/l.b7(y);return l.a$(y,y,b),[...y,-f*b]}isLocationOccluded(e){return!this.isSurfacePointVisible(_r(e))}transformLightDirection(e){const s=this._helper._center.lng*Math.PI/180,c=this._helper._center.lat*Math.PI/180,d=Math.cos(c),p=[Math.sin(s)*d,Math.sin(c),Math.cos(s)*d],f=[p[2],0,-p[0]],m=[0,0,0];l.b4(m,f,p),l.b3(f,f),l.b3(m,m);const _=[0,0,0];return l.b3(_,[f[0]*e[0]+m[0]*e[1]+p[0]*e[2],f[1]*e[0]+m[1]*e[1]+p[1]*e[2],f[2]*e[0]+m[2]*e[1]+p[2]*e[2]]),_}getPixelScale(){return 1/Math.cos(this._helper._center.lat*Math.PI/180)}getCircleRadiusCorrection(){return Math.cos(this._helper._center.lat*Math.PI/180)}getPitchedTextCorrection(e,s,c){const d=function(e,s,c){const d=1/(1<p&&(p=s),c<_&&(_=c),c>m&&(m=c)}const y=[g.lng+f,g.lat+_,g.lng+p,g.lat+m];return this.isSurfacePointOnScreen([0,1,0])&&(y[3]=90,y[0]=-180,y[2]=180),this.isSurfacePointOnScreen([0,-1,0])&&(y[1]=-90,y[0]=-180,y[2]=180),new $(y)}calculateCenterFromCameraLngLatAlt(e,s,l,c){return this._helper.calculateCenterFromCameraLngLatAlt(e,s,l,c)}setLocationAtPoint(e,s){const c=_r(this.unprojectScreenPoint(s)),d=_r(e),p=l.bz();l.bL(p);const f=l.bz();l.bI(f,c,p,-this.center.lng*Math.PI/180),l.bH(f,f,p,this.center.lat*Math.PI/180);const m=d[0]*d[0]+d[2]*d[2],_=f[0]*f[0];if(m<_)return;const g=Math.sqrt(m-_),y=-g,b=l.bM(d[0],d[2],f[0],g),T=l.bM(d[0],d[2],f[0],y),P=l.bz();l.bI(P,d,p,-b);const S=l.bM(P[1],P[2],f[1],f[2]),I=l.bz();l.bI(I,d,p,-T);const C=l.bM(I[1],I[2],f[1],f[2]),R=.5*Math.PI,L=S>=-R&&S<=R,F=C>=-R&&C<=R;let B,O;if(L&&F){const e=this.center.lng*Math.PI/180,s=this.center.lat*Math.PI/180;l.bN(b,e)+l.bN(S,s)=0}isSurfacePointOnScreen(e){if(!this.isSurfacePointVisible(e))return!1;const s=l.bF();return l.aH(s,[...e,1],this._globeViewProjMatrixNoCorrection),s[0]/=s[3],s[1]/=s[3],s[2]/=s[3],s[0]>-1&&s[0]<1&&s[1]>-1&&s[1]<1&&s[2]>-1&&s[2]<1}rayPlanetIntersection(e,s){const c=l.b5(e,s),d=l.bz(),p=l.bz();l.a$(p,s,c),l.b2(d,e,p);const f=1-l.b5(d,d);if(f<0)return null;const m=l.b5(e,e)-1,_=-c+(c<0?1:-1)*Math.sqrt(f),g=m/_,y=_;return{tMin:Math.min(g,y),tMax:Math.max(g,y)}}unprojectScreenPoint(e){const s=this._cameraPosition,c=this.getRayDirectionFromPixel(e),d=this.rayPlanetIntersection(s,c);if(d){const e=l.bz();l.b0(e,s,[c[0]*d.tMin,c[1]*d.tMin,c[2]*d.tMin]);const p=l.bz();return l.b3(p,e),yr(p)}const p=this._cachedClippingPlane,f=p[0]*c[0]+p[1]*c[1]+p[2]*c[2],m=-l.bb(p,s)/f,_=l.bz();if(m>0)l.b0(_,s,[c[0]*m,c[1]*m,c[2]*m]);else{const e=l.bz();l.b0(e,s,[2*c[0],2*c[1],2*c[2]]);const d=l.bb(this._cachedClippingPlane,e);l.b2(_,e,[this._cachedClippingPlane[0]*d,this._cachedClippingPlane[1]*d,this._cachedClippingPlane[2]*d])}const g=function(e){const s=l.bz();return s[0]=e[0]*-e[3],s[1]=e[1]*-e[3],s[2]=e[2]*-e[3],{center:s,radius:Math.sqrt(1-e[3]*e[3])}}(p);return yr(function(e,s,c){const d=l.bz();l.b2(d,c,e);const p=l.bz();return l.bA(p,e,d,s/l.b9(d)),p}(g.center,g.radius,_))}getMatrixForModel(e,s){const c=l.V.convert(e),d=1/l.bE,p=l.bj();return l.bJ(p,p,c.lng/180*Math.PI),l.bh(p,p,-c.lat/180*Math.PI),l.O(p,p,[0,0,1+s/l.bE]),l.bh(p,p,.5*Math.PI),l.Q(p,p,[d,d,d]),p}getProjectionDataForCustomLayer(e=!0){const s=this.getProjectionData({overscaledTileID:new l.a2(0,0,0,0,0),applyGlobeMatrix:e});return s.tileMercatorCoords=[0,0,1,1],s}getFastPathSimpleProjectionMatrix(e){}}class zi{get pixelsToClipSpaceMatrix(){return this._helper.pixelsToClipSpaceMatrix}get clipSpaceToPixelsMatrix(){return this._helper.clipSpaceToPixelsMatrix}get pixelsToGLUnits(){return this._helper.pixelsToGLUnits}get centerOffset(){return this._helper.centerOffset}get size(){return this._helper.size}get rotationMatrix(){return this._helper.rotationMatrix}get centerPoint(){return this._helper.centerPoint}get pixelsPerMeter(){return this._helper.pixelsPerMeter}setMinZoom(e){this._helper.setMinZoom(e)}setMaxZoom(e){this._helper.setMaxZoom(e)}setMinPitch(e){this._helper.setMinPitch(e)}setMaxPitch(e){this._helper.setMaxPitch(e)}setRenderWorldCopies(e){this._helper.setRenderWorldCopies(e)}setBearing(e){this._helper.setBearing(e)}setPitch(e){this._helper.setPitch(e)}setRoll(e){this._helper.setRoll(e)}setFov(e){this._helper.setFov(e)}setZoom(e){this._helper.setZoom(e)}setCenter(e){this._helper.setCenter(e)}setElevation(e){this._helper.setElevation(e)}setMinElevationForCurrentTile(e){this._helper.setMinElevationForCurrentTile(e)}setPadding(e){this._helper.setPadding(e)}interpolatePadding(e,s,l){return this._helper.interpolatePadding(e,s,l)}isPaddingEqual(e){return this._helper.isPaddingEqual(e)}resize(e,s,l=!0){this._helper.resize(e,s,l)}getMaxBounds(){return this._helper.getMaxBounds()}setMaxBounds(e){this._helper.setMaxBounds(e)}setConstrainOverride(e){this._helper.setConstrainOverride(e)}overrideNearFarZ(e,s){this._helper.overrideNearFarZ(e,s)}clearNearFarZOverride(){this._helper.clearNearFarZOverride()}getCameraQueryGeometry(e){return this._helper.getCameraQueryGeometry(this.getCameraPoint(),e)}get tileSize(){return this._helper.tileSize}get tileZoom(){return this._helper.tileZoom}get scale(){return this._helper.scale}get worldSize(){return this._helper.worldSize}get width(){return this._helper.width}get height(){return this._helper.height}get lngRange(){return this._helper.lngRange}get latRange(){return this._helper.latRange}get minZoom(){return this._helper.minZoom}get maxZoom(){return this._helper.maxZoom}get zoom(){return this._helper.zoom}get center(){return this._helper.center}get minPitch(){return this._helper.minPitch}get maxPitch(){return this._helper.maxPitch}get pitch(){return this._helper.pitch}get pitchInRadians(){return this._helper.pitchInRadians}get roll(){return this._helper.roll}get rollInRadians(){return this._helper.rollInRadians}get bearing(){return this._helper.bearing}get bearingInRadians(){return this._helper.bearingInRadians}get fov(){return this._helper.fov}get fovInRadians(){return this._helper.fovInRadians}get elevation(){return this._helper.elevation}get minElevationForCurrentTile(){return this._helper.minElevationForCurrentTile}get padding(){return this._helper.padding}get unmodified(){return this._helper.unmodified}get renderWorldCopies(){return this._helper.renderWorldCopies}get cameraToCenterDistance(){return this._helper.cameraToCenterDistance}get constrainOverride(){return this._helper.constrainOverride}get nearZ(){return this._helper.nearZ}get farZ(){return this._helper.farZ}get autoCalculateNearFarZ(){return this._helper.autoCalculateNearFarZ}get isGlobeRendering(){return this._globeness>0}setTransitionState(e,s){this._globeness=e,this._globeLatitudeErrorCorrectionRadians=s,this._calcMatrices(),this._verticalPerspectiveTransform.getCoveringTilesDetailsProvider().prepareNextFrame(),this._mercatorTransform.getCoveringTilesDetailsProvider().prepareNextFrame()}get currentTransform(){return this.isGlobeRendering?this._verticalPerspectiveTransform:this._mercatorTransform}constructor(e){this._globeLatitudeErrorCorrectionRadians=0,this._globeness=1,this.defaultConstrain=(e,s)=>this.currentTransform.defaultConstrain(e,s),this.applyConstrain=(e,s)=>this._helper.applyConstrain(e,s),this._helper=new Ut({calcMatrices:()=>{this._calcMatrices()},defaultConstrain:(e,s)=>this.defaultConstrain(e,s)},e),this._globeness=1,this._mercatorTransform=new $t,this._verticalPerspectiveTransform=new Si}clone(){const e=new zi;return e._globeness=this._globeness,e._globeLatitudeErrorCorrectionRadians=this._globeLatitudeErrorCorrectionRadians,e.apply(this,!1),e}apply(e,s){this._helper.apply(e,s),this._mercatorTransform.apply(this,!1),this._verticalPerspectiveTransform.apply(this,!1,this._globeLatitudeErrorCorrectionRadians)}get projectionMatrix(){return this.currentTransform.projectionMatrix}get modelViewProjectionMatrix(){return this.currentTransform.modelViewProjectionMatrix}get inverseProjectionMatrix(){return this.currentTransform.inverseProjectionMatrix}get cameraPosition(){return this.currentTransform.cameraPosition}getProjectionData(e){const s=this._mercatorTransform.getProjectionData(e),l=this._verticalPerspectiveTransform.getProjectionData(e);return{mainMatrix:this.isGlobeRendering?l.mainMatrix:s.mainMatrix,clippingPlane:l.clippingPlane,tileMercatorCoords:l.tileMercatorCoords,projectionTransition:e.applyGlobeMatrix?this._globeness:0,fallbackMatrix:s.fallbackMatrix}}isLocationOccluded(e){return this.currentTransform.isLocationOccluded(e)}transformLightDirection(e){return this.currentTransform.transformLightDirection(e)}getPixelScale(){return l.bu(this._mercatorTransform.getPixelScale(),this._verticalPerspectiveTransform.getPixelScale(),this._globeness)}getCircleRadiusCorrection(){return l.bu(this._mercatorTransform.getCircleRadiusCorrection(),this._verticalPerspectiveTransform.getCircleRadiusCorrection(),this._globeness)}getPitchedTextCorrection(e,s,c){const d=this._mercatorTransform.getPitchedTextCorrection(e,s,c),p=this._verticalPerspectiveTransform.getPitchedTextCorrection(e,s,c);return l.bu(d,p,this._globeness)}projectTileCoordinates(e,s,l,c){return this.currentTransform.projectTileCoordinates(e,s,l,c)}_calcMatrices(){this._helper._width&&this._helper._height&&(this._verticalPerspectiveTransform.apply(this,!1,this._globeLatitudeErrorCorrectionRadians),this._helper._nearZ=this._verticalPerspectiveTransform.nearZ,this._helper._farZ=this._verticalPerspectiveTransform.farZ,this._mercatorTransform.apply(this,!0,this.isGlobeRendering),this._helper._nearZ=this._mercatorTransform.nearZ,this._helper._farZ=this._mercatorTransform.farZ)}calculateFogMatrix(e){return this.currentTransform.calculateFogMatrix(e)}getVisibleUnwrappedCoordinates(e){return this.currentTransform.getVisibleUnwrappedCoordinates(e)}getCameraFrustum(){return this.currentTransform.getCameraFrustum()}getClippingPlane(){return this.currentTransform.getClippingPlane()}getCoveringTilesDetailsProvider(){return this.currentTransform.getCoveringTilesDetailsProvider()}recalculateZoomAndCenter(e){this._mercatorTransform.recalculateZoomAndCenter(e),this._verticalPerspectiveTransform.recalculateZoomAndCenter(e)}maxPitchScaleFactor(){return this._mercatorTransform.maxPitchScaleFactor()}getCameraPoint(){return this._helper.getCameraPoint()}getCameraAltitude(){return this._helper.getCameraAltitude()}getCameraLngLat(){return this._helper.getCameraLngLat()}lngLatToCameraDepth(e,s){return this.currentTransform.lngLatToCameraDepth(e,s)}populateCache(e){this._mercatorTransform.populateCache(e),this._verticalPerspectiveTransform.populateCache(e)}getBounds(){return this.currentTransform.getBounds()}calculateCenterFromCameraLngLatAlt(e,s,l,c){return this._helper.calculateCenterFromCameraLngLatAlt(e,s,l,c)}setLocationAtPoint(e,s){if(!this.isGlobeRendering)return this._mercatorTransform.setLocationAtPoint(e,s),void this.apply(this._mercatorTransform,!1);this._verticalPerspectiveTransform.setLocationAtPoint(e,s),this.apply(this._verticalPerspectiveTransform,!1)}locationToScreenPoint(e,s){return this.currentTransform.locationToScreenPoint(e,s)}screenPointToMercatorCoordinate(e,s){return this.currentTransform.screenPointToMercatorCoordinate(e,s)}screenPointToLocation(e,s){return this.currentTransform.screenPointToLocation(e,s)}isPointOnMapSurface(e,s){return this.currentTransform.isPointOnMapSurface(e,s)}getRayDirectionFromPixel(e){return this._verticalPerspectiveTransform.getRayDirectionFromPixel(e)}getMatrixForModel(e,s){return this.currentTransform.getMatrixForModel(e,s)}getProjectionDataForCustomLayer(e=!0){const s=this._mercatorTransform.getProjectionDataForCustomLayer(e);if(!this.isGlobeRendering)return s;const l=this._verticalPerspectiveTransform.getProjectionDataForCustomLayer(e);return l.fallbackMatrix=s.mainMatrix,l}getFastPathSimpleProjectionMatrix(e){return this.currentTransform.getFastPathSimpleProjectionMatrix(e)}}class Ri{get useGlobeControls(){return!0}handlePanInertia(e,s){const c=br(e,s);return Math.abs(c.lng-s.center.lng)>180&&(c.lng=s.center.lng+179.5*Math.sign(c.lng-s.center.lng)),{easingCenter:c,easingOffset:new l.P(0,0)}}handleMapControlsRollPitchBearingZoom(e,s){const c=e.around,d=s.screenPointToLocation(c);e.bearingDelta&&s.setBearing(s.bearing+e.bearingDelta),e.pitchDelta&&s.setPitch(s.pitch+e.pitchDelta),e.rollDelta&&s.setRoll(s.roll+e.rollDelta);const p=s.zoom;e.zoomDelta&&s.setZoom(s.zoom+e.zoomDelta);const f=s.zoom-p;if(0===f)return;const m=l.bK(s.center.lng,d.lng),_=m/(Math.abs(m/180)+1),g=l.bK(s.center.lat,d.lat),y=s.getRayDirectionFromPixel(c),b=s.cameraPosition,T=-1*l.b5(b,y),P=l.bz();l.b0(P,b,[y[0]*T,y[1]*T,y[2]*T]);const S=l.b7(P)-1,I=Math.exp(.5*-Math.max(S-.3,0)),C=gr(s.worldSize,s.center.lat)/Math.min(s.width,s.height),R=l.bx(C,.9,.5,1,.25),L=(1-l.aq(-f))*Math.min(I,R),F=s.center.lat,B=s.zoom,O=new l.V(s.center.lng+_*L,l.an(s.center.lat+g*L,-l.ao,l.ao));s.setLocationAtPoint(d,c);const j=s.center,G=l.bx(Math.abs(m),45,85,0,1),U=l.bx(C,.75,.35,0,1),q=Math.pow(Math.max(G,U),.25),Z=l.bK(j.lng,O.lng),W=l.bK(j.lat,O.lat);s.setCenter(new l.V(j.lng+Z*q,j.lat+W*q).wrap()),s.setZoom(B+vr(F,s.center.lat))}handleMapControlsPan(e,s,l){if(!e.panDelta)return;const c=s.center.lat,d=s.zoom;s.setCenter(br(e.panDelta,s).wrap()),s.setZoom(d+vr(c,s.center.lat))}cameraForBoxAndBearing(e,s,c,d,p){const f=Xi(e,s,c,d,p),m=s.left/p.width*2-1,_=(p.width-s.right)/p.width*2-1,g=s.top/p.height*-2+1,y=(p.height-s.bottom)/p.height*-2+1,b=l.bK(c.getWest(),c.getEast())<0,T=b?c.getEast():c.getWest(),P=b?c.getWest():c.getEast(),S=Math.max(c.getNorth(),c.getSouth()),I=Math.min(c.getNorth(),c.getSouth()),C=T+.5*l.bK(T,P),R=S+.5*l.bK(S,I),L=p.clone();L.setCenter(f.center),L.setBearing(f.bearing),L.setPitch(0),L.setRoll(0),L.setZoom(f.zoom);const F=L.modelViewProjectionMatrix,B=[_r(c.getNorthWest()),_r(c.getNorthEast()),_r(c.getSouthWest()),_r(c.getSouthEast()),_r(new l.V(P,R)),_r(new l.V(T,R)),_r(new l.V(C,S)),_r(new l.V(C,I))],O=_r(f.center);let j=Number.POSITIVE_INFINITY;for(const e of B)m<0&&(j=Ri.getLesserNonNegativeNonNull(j,Ri.solveVectorScale(e,O,F,"x",m))),_>0&&(j=Ri.getLesserNonNegativeNonNull(j,Ri.solveVectorScale(e,O,F,"x",_))),g>0&&(j=Ri.getLesserNonNegativeNonNull(j,Ri.solveVectorScale(e,O,F,"y",g))),y<0&&(j=Ri.getLesserNonNegativeNonNull(j,Ri.solveVectorScale(e,O,F,"y",y)));if(Number.isFinite(j)&&0!==j)return f.zoom=L.zoom+l.at(j),f;Wi()}handleJumpToCenterZoom(e,s){const c=e.center.lat,d=e.applyConstrain(s.center?l.V.convert(s.center):e.center,e.zoom).center;e.setCenter(d.wrap());const p=void 0!==s.zoom?+s.zoom:e.zoom+vr(c,d.lat);e.zoom!==p&&e.setZoom(p)}handleEaseTo(e,s){const c=e.zoom,d=e.center,p=e.padding,f={roll:e.roll,pitch:e.pitch,bearing:e.bearing},m={roll:void 0===s.roll?e.roll:s.roll,pitch:void 0===s.pitch?e.pitch:s.pitch,bearing:void 0===s.bearing?e.bearing:s.bearing},_=void 0!==s.zoom,g=!e.isPaddingEqual(s.padding);let y=!1;const b=s.center?l.V.convert(s.center):d,T=e.applyConstrain(b,c).center;qi(e,T);const P=e.clone();P.setCenter(T),P.setZoom(_?+s.zoom:c+vr(d.lat,b.lat)),P.setBearing(s.bearing);const S=new l.P(l.an(e.centerPoint.x+s.offsetAsPoint.x,0,e.width),l.an(e.centerPoint.y+s.offsetAsPoint.y,0,e.height));P.setLocationAtPoint(T,S);const I=(s.offset&&s.offsetAsPoint.mag())>0?P.center:T,C=_?+s.zoom:c+vr(d.lat,I.lat),R=c+vr(d.lat,0),L=C+vr(I.lat,0),F=l.bK(d.lng,I.lng),B=l.bK(d.lat,I.lat),O=l.aq(L-R);return y=C!==c,{easeFunc:c=>{if(l.bo(f,m)||Hi({startEulerAngles:f,endEulerAngles:m,tr:e,k:c,useSlerp:f.roll!=m.roll}),g&&e.interpolatePadding(p,s.padding,c),s.around)l.w("Easing around a point is not supported under globe projection."),e.setLocationAtPoint(s.around,s.aroundPoint);else{const s=L>R?Math.min(2,O):Math.max(.5,O),l=Math.pow(s,1-c),p=Pr(d,F,B,c*l);e.setCenter(p.wrap())}if(y){const s=l.G.number(R,L,c)+vr(0,e.center.lat);e.setZoom(s)}},isZooming:y,elevationCenter:I}}handleFlyTo(e,s){const c=void 0!==s.zoom,d=e.center,p=e.zoom,f=e.padding,m=!e.isPaddingEqual(s.padding),_=e.applyConstrain(l.V.convert(s.center||s.locationAtOffset),p).center,g=c?+s.zoom:e.zoom+vr(e.center.lat,_.lat),y=e.clone();y.setCenter(_),y.setZoom(g),y.setBearing(s.bearing);const b=new l.P(l.an(e.centerPoint.x+s.offsetAsPoint.x,0,e.width),l.an(e.centerPoint.y+s.offsetAsPoint.y,0,e.height));y.setLocationAtPoint(_,b);const T=y.center;qi(e,T);const P=function(e,s,c){const d=_r(s),p=_r(c),f=l.b5(d,p),m=Math.acos(f),_=dr(e);return m/(2*Math.PI)*_}(e,d,T),S=p+vr(d.lat,0),I=g+vr(T.lat,0),C=l.aq(I-S);let R;if("number"==typeof s.minZoom){const c=+s.minZoom+vr(T.lat,0),d=Math.min(c,S,I)+vr(0,T.lat),p=e.applyConstrain(T,d).zoom+vr(T.lat,0);R=l.aq(p-S)}const L=l.bK(d.lng,T.lng),F=l.bK(d.lat,T.lat);return{easeFunc:(c,p,_,y)=>{const b=Pr(d,L,F,_);m&&e.interpolatePadding(f,s.padding,c);const P=1===c?T:b;e.setCenter(P.wrap());const I=S+l.at(p);e.setZoom(1===c?g:I+vr(0,P.lat))},scaleOfZoom:C,targetCenter:T,scaleOfMinZoom:R,pixelPathLength:P}}static solveVectorScale(e,s,l,c,d){const p="x"===c?[l[0],l[4],l[8],l[12]]:[l[1],l[5],l[9],l[13]],f=[l[3],l[7],l[11],l[15]],m=e[0]*p[0]+e[1]*p[1]+e[2]*p[2],_=e[0]*f[0]+e[1]*f[1]+e[2]*f[2],g=s[0]*p[0]+s[1]*p[1]+s[2]*p[2],y=s[0]*f[0]+s[1]*f[1]+s[2]*f[2];return g+d*_===m+d*y||f[3]*(m-g)+p[3]*(y-_)+m*y==g*_?null:(g+p[3]-d*y-d*f[3])/(g-m-d*y+d*_)}static getLesserNonNegativeNonNull(e,s){return null!==s&&s>=0&&sl.B(e,s&&s.filter((e=>"source.canvas"!==e.identifier))),zr=l.bO();class ki extends l.E{constructor(e,s={}){var c,d;super(),this._rtlPluginLoaded=()=>{for(const e in this.tileManagers){const s=this.tileManagers[e].getSource().type;"vector"!==s&&"geojson"!==s||this.tileManagers[e].reload()}},this.map=e,this.dispatcher=new N(oe(),e._getMapId()),this.dispatcher.registerMessageHandler("GG",((e,s)=>this.getGlyphs(e,s))),this.dispatcher.registerMessageHandler("GI",((e,s)=>this.getImages(e,s))),this.dispatcher.registerMessageHandler("GDA",((e,s)=>this.getDashes(e,s))),this.imageManager=new w,this.imageManager.setEventedParent(this);const p=(null===(c=e._container)||void 0===c?void 0:c.lang)||"undefined"!=typeof document&&(null===(d=document.documentElement)||void 0===d?void 0:d.lang)||void 0;this.glyphManager=new M(e._requestManager,s.localIdeographFontFamily,p),this.lineAtlas=new A(256,512),this.crossTileSymbolIndex=new Rt,this._setInitialValues(),this._resetUpdates(),this.dispatcher.broadcast("SR",l.bP()),we().on(ve,this._rtlPluginLoaded),this.on("data",(e=>{if("source"!==e.dataType||"metadata"!==e.sourceDataType)return;const s=this.tileManagers[e.sourceId];if(!s)return;const l=s.getSource();if(l&&l.vectorLayerIds)for(const e in this._layers){const s=this._layers[e];s.source===l.id&&this._validateLayer(s)}}))}_setInitialValues(){var e;this._spritesImagesIds={},this._layers={},this._order=[],this.tileManagers={},this.zoomHistory=new l.bQ,this._availableImages=[],this._globalState={},this._serializedLayers={},this.stylesheet=null,this.light=null,this.sky=null,this.projection&&(this.projection.destroy(),delete this.projection),this._loaded=!1,this._changed=!1,this._updatedLayers={},this._updatedSources={},this._changedImages={},this._glyphsDidChange=!1,this._updatedPaintProps={},this._layerOrderChanged=!1,this.crossTileSymbolIndex=new((null===(e=this.crossTileSymbolIndex)||void 0===e?void 0:e.constructor)||Object),this.pauseablePlacement=void 0,this.placement=void 0,this.z=0}setGlobalStateProperty(e,s){var c,d,p;this._checkLoaded();const f=null===s?null!==(p=null===(d=null===(c=this.stylesheet.state)||void 0===c?void 0:c[e])||void 0===d?void 0:d.default)&&void 0!==p?p:null:s;if(l.bR(f,this._globalState[e]))return this;this._globalState[e]=f,this._applyGlobalStateChanges([e])}getGlobalState(){return this._globalState}setGlobalState(e){this._checkLoaded();const s=[];for(const c in e)!l.bR(this._globalState[c],e[c].default)&&(s.push(c),this._globalState[c]=e[c].default);this._applyGlobalStateChanges(s)}_applyGlobalStateChanges(e){if(0===e.length)return;const s=new Set,l={};for(const c of e){l[c]=this._globalState[c];for(const e in this._layers){const l=this._layers[e],d=l.getLayoutAffectingGlobalStateRefs(),p=l.getPaintAffectingGlobalStateRefs(),f=l.getVisibilityAffectingGlobalStateRefs();if(d.has(c)&&s.add(l.source),p.has(c))for(const{name:e,value:s}of p.get(c))this._updatePaintProperty(l,e,s);(null==f?void 0:f.has(c))&&(l.recalculateVisibility(),this._updateLayer(l))}}this.dispatcher.broadcast("UGS",l);for(const e in this.tileManagers)s.has(e)&&(this._reloadSource(e),this._changed=!0)}loadURL(e,s={},c){this.fire(new l.l("dataloading",{dataType:"style"})),s.validate="boolean"!=typeof s.validate||s.validate;const d=this.map._requestManager.transformRequest(e,"Style");this._loadStyleRequest=new AbortController;const p=this._loadStyleRequest;l.j(d,this._loadStyleRequest).then((e=>{this._loadStyleRequest=null,this._load(e.data,s,c)})).catch((e=>{this._loadStyleRequest=null,e&&!p.signal.aborted&&this.fire(new l.k(e))}))}loadJSON(e,s={},c){this.fire(new l.l("dataloading",{dataType:"style"})),this._frameRequest=new AbortController,_.frameAsync(this._frameRequest).then((()=>{this._frameRequest=null,s.validate=!1!==s.validate,this._load(e,s,c)})).catch((()=>{}))}loadEmpty(){this.fire(new l.l("dataloading",{dataType:"style"})),this._load(zr,{validate:!1})}_load(e,s,c){var d,p;let f=s.transformStyle?s.transformStyle(c,e):e;if(!s.validate||!Dr(this,l.C(f))){f=Object.assign({},f),this._loaded=!0,this.stylesheet=f;for(const e in f.sources)this.addSource(e,f.sources[e],{validate:!1});f.sprite?this._loadSprite(f.sprite):this.imageManager.setLoaded(!0),this.glyphManager.setURL(f.glyphs),this._createLayers(),this.light=new z(this.stylesheet.light),this._setProjectionInternal((null===(d=this.stylesheet.projection)||void 0===d?void 0:d.type)||"mercator"),this.sky=new D(this.stylesheet.sky),this.map.setTerrain(null!==(p=this.stylesheet.terrain)&&void 0!==p?p:null),this.fire(new l.l("data",{dataType:"style"})),this.fire(new l.l("style.load"))}}_createLayers(){var e,s,c;const d=l.bS(this.stylesheet.layers);this.setGlobalState(null!==(e=this.stylesheet.state)&&void 0!==e?e:null),this.dispatcher.broadcast("SL",d),this._order=d.map((e=>e.id)),this._layers={},this._serializedLayers=null;for(const e of d){const d=l.bT(e,this._globalState);if(d.setEventedParent(this,{layer:{id:e.id}}),this._layers[e.id]=d,l.bU(d)&&this.tileManagers[d.source]){const l=null!==(c=null===(s=e.paint)||void 0===s?void 0:s["raster-fade-duration"])&&void 0!==c?c:d.paint.get("raster-fade-duration");this.tileManagers[d.source].setRasterFadeDuration(l)}}}_loadSprite(e,s=!1,c=void 0){this.imageManager.setLoaded(!1);const d=new AbortController;let p;this._spriteRequest=d,function(e,s,c,d){return l._(this,void 0,void 0,(function*(){const p=L(e),f=c>1?"@2x":"",m={},g={};for(const{id:e,url:c}of p){const p=s.transformRequest(F(c,f,".json"),"SpriteJSON");m[e]=l.j(p,d);const _=s.transformRequest(F(c,f,".png"),"SpriteImage");g[e]=R.getImage(_,d)}return yield Promise.all([...Object.values(m),...Object.values(g)]),function(e,s){return l._(this,void 0,void 0,(function*(){const l={};for(const c in e){l[c]={};const d=_.getImageCanvasContext((yield s[c]).data),p=(yield e[c]).data;for(const e in p){const{width:s,height:f,x:m,y:_,sdf:g,pixelRatio:y,stretchX:b,stretchY:T,content:P,textFitWidth:S,textFitHeight:I}=p[e];l[c][e]={data:null,pixelRatio:y,sdf:g,stretchX:b,stretchY:T,content:P,textFitWidth:S,textFitHeight:I,spriteData:{width:s,height:f,x:m,y:_,context:d}}}}return l}))}(m,g)}))}(e,this.map._requestManager,this.map.getPixelRatio(),this._spriteRequest).then((e=>{if(this._spriteRequest=null,e)for(const l in e){this._spritesImagesIds[l]=[];const c=this._spritesImagesIds[l]?this._spritesImagesIds[l].filter((s=>!(s in e))):[];for(const e of c)this.imageManager.removeImage(e),this._changedImages[e]=!0;for(const c in e[l]){const d="default"===l?c:`${l}:${c}`;this._spritesImagesIds[l].push(d),d in this.imageManager.images?this.imageManager.updateImage(d,e[l][c],!1):this.imageManager.addImage(d,e[l][c]),s&&(this._changedImages[d]=!0)}}})).catch((e=>{this._spriteRequest=null,p=e,d.signal.aborted||this.fire(new l.k(p))})).finally((()=>{this.imageManager.setLoaded(!0),this._availableImages=this.imageManager.listImages(),s&&(this._changed=!0),this.dispatcher.broadcast("SI",this._availableImages),this.fire(new l.l("data",{dataType:"style"})),c&&c(p)}))}_unloadSprite(){for(const e of Object.values(this._spritesImagesIds).flat())this.imageManager.removeImage(e),this._changedImages[e]=!0;this._spritesImagesIds={},this._availableImages=this.imageManager.listImages(),this._changed=!0,this.dispatcher.broadcast("SI",this._availableImages),this.fire(new l.l("data",{dataType:"style"}))}_validateLayer(e){const s=this.tileManagers[e.source];if(!s)return;const c=e.sourceLayer;if(!c)return;const d=s.getSource();("geojson"===d.type||d.vectorLayerIds&&-1===d.vectorLayerIds.indexOf(c))&&this.fire(new l.k(new Error(`Source layer "${c}" does not exist on source "${d.id}" as specified by style layer "${e.id}".`)))}loaded(){if(!this._loaded)return!1;if(Object.keys(this._updatedSources).length)return!1;for(const e in this.tileManagers)if(!this.tileManagers[e].loaded())return!1;return!!this.imageManager.isLoaded()}_serializeByIds(e,s=!1){const c=this._serializedAllLayers();if(!e||0===e.length)return Object.values(s?l.bV(c):c);const d=[];for(const p of e)if(c[p]){const e=s?l.bV(c[p]):c[p];d.push(e)}return d}_serializedAllLayers(){let e=this._serializedLayers;if(e)return e;e=this._serializedLayers={};const s=Object.keys(this._layers);for(const l of s){const s=this._layers[l];"custom"!==s.type&&(e[l]=s.serialize())}return e}hasTransitions(){var e,s,l;if(null===(e=this.light)||void 0===e?void 0:e.hasTransition())return!0;if(null===(s=this.sky)||void 0===s?void 0:s.hasTransition())return!0;if(null===(l=this.projection)||void 0===l?void 0:l.hasTransition())return!0;for(const e in this.tileManagers)if(this.tileManagers[e].hasTransition())return!0;for(const e in this._layers)if(this._layers[e].hasTransition())return!0;return!1}_checkLoaded(){if(!this._loaded)throw new Error("Style is not done loading.")}update(e){if(!this._loaded)return;const s=this._changed;if(s){const s=Object.keys(this._updatedLayers),l=Object.keys(this._removedLayers);(s.length||l.length)&&this._updateWorkerLayers(s,l);for(const e in this._updatedSources){const s=this._updatedSources[e];if("reload"===s)this._reloadSource(e);else{if("clear"!==s)throw new Error(`Invalid action ${s}`);this._clearSource(e)}}this._updateTilesForChangedImages(),this._updateTilesForChangedGlyphs();for(const s in this._updatedPaintProps)this._layers[s].updateTransitions(e);this.light.updateTransitions(e),this.sky.updateTransitions(e),this._resetUpdates()}const c={};for(const e in this.tileManagers){const s=this.tileManagers[e];c[e]=s.used,s.used=!1}for(const s of this._order){const l=this._layers[s];l.recalculate(e,this._availableImages),!l.isHidden(e.zoom)&&l.source&&(this.tileManagers[l.source].used=!0)}for(const e in c){const s=this.tileManagers[e];!!c[e]!=!!s.used&&s.fire(new l.l("data",{sourceDataType:"visibility",dataType:"source",sourceId:e}))}this.light.recalculate(e),this.sky.recalculate(e),this.projection.recalculate(e),this.z=e.zoom,s&&this.fire(new l.l("data",{dataType:"style"}))}_updateTilesForChangedImages(){const e=Object.keys(this._changedImages);if(e.length){for(const s in this.tileManagers)this.tileManagers[s].reloadTilesForDependencies(["icons","patterns"],e);this._changedImages={}}}_updateTilesForChangedGlyphs(){if(this._glyphsDidChange){for(const e in this.tileManagers)this.tileManagers[e].reloadTilesForDependencies(["glyphs"],[""]);this._glyphsDidChange=!1}}_updateWorkerLayers(e,s){this.dispatcher.broadcast("UL",{layers:this._serializeByIds(e,!1),removedIds:s})}_resetUpdates(){this._changed=!1,this._updatedLayers={},this._removedLayers={},this._updatedSources={},this._updatedPaintProps={},this._changedImages={},this._glyphsDidChange=!1}setState(e,s={}){var c;this._checkLoaded();const d=this.serialize();if(e=s.transformStyle?s.transformStyle(d,e):e,(null===(c=s.validate)||void 0===c||c)&&Dr(this,l.C(e)))return!1;(e=l.bV(e)).layers=l.bS(e.layers);const p=l.bW(d,e),f=this._getOperationsToPerform(p);if(f.unimplemented.length>0)throw new Error(`Unimplemented: ${f.unimplemented.join(", ")}.`);if(0===f.operations.length)return!1;for(const e of f.operations)e();return this.stylesheet=e,this._serializedLayers=null,this.fire(new l.l("style.load",{style:this})),!0}_getOperationsToPerform(e){const s=[],l=[];for(const c of e)switch(c.command){case"setCenter":case"setZoom":case"setBearing":case"setPitch":case"setRoll":continue;case"addLayer":s.push((()=>this.addLayer.apply(this,c.args)));break;case"removeLayer":s.push((()=>this.removeLayer.apply(this,c.args)));break;case"setPaintProperty":s.push((()=>this.setPaintProperty.apply(this,c.args)));break;case"setLayoutProperty":s.push((()=>this.setLayoutProperty.apply(this,c.args)));break;case"setFilter":s.push((()=>this.setFilter.apply(this,c.args)));break;case"addSource":s.push((()=>this.addSource.apply(this,c.args)));break;case"removeSource":s.push((()=>this.removeSource.apply(this,c.args)));break;case"setLayerZoomRange":s.push((()=>this.setLayerZoomRange.apply(this,c.args)));break;case"setLight":s.push((()=>this.setLight.apply(this,c.args)));break;case"setGeoJSONSourceData":s.push((()=>this.setGeoJSONSourceData.apply(this,c.args)));break;case"setGlyphs":s.push((()=>this.setGlyphs.apply(this,c.args)));break;case"setSprite":s.push((()=>this.setSprite.apply(this,c.args)));break;case"setTerrain":s.push((()=>this.map.setTerrain.apply(this,c.args)));break;case"setSky":s.push((()=>this.setSky.apply(this,c.args)));break;case"setProjection":this.setProjection.apply(this,c.args);break;case"setGlobalState":s.push((()=>this.setGlobalState.apply(this,c.args)));break;case"setTransition":s.push((()=>{}));break;default:l.push(c.command)}return{operations:s,unimplemented:l}}addImage(e,s){if(this.getImage(e))return this.fire(new l.k(new Error(`An image named "${e}" already exists.`)));this.imageManager.addImage(e,s),this._afterImageUpdated(e)}updateImage(e,s){this.imageManager.updateImage(e,s)}getImage(e){return this.imageManager.getImage(e)}removeImage(e){if(!this.getImage(e))return this.fire(new l.k(new Error(`An image named "${e}" does not exist.`)));this.imageManager.removeImage(e),this._afterImageUpdated(e)}_afterImageUpdated(e){this._availableImages=this.imageManager.listImages(),this._changedImages[e]=!0,this._changed=!0,this.dispatcher.broadcast("SI",this._availableImages),this.fire(new l.l("data",{dataType:"style"}))}listImages(){return this._checkLoaded(),this.imageManager.listImages()}addSource(e,s,c={}){if(this._checkLoaded(),void 0!==this.tileManagers[e])throw new Error(`Source "${e}" already exists.`);if(!s.type)throw new Error(`The type property must be defined, but only the following properties were given: ${Object.keys(s).join(", ")}.`);if(["vector","raster","geojson","video","image"].indexOf(s.type)>=0&&this._validate(l.C.source,`sources.${e}`,s,null,c))return;this.map&&this.map._collectResourceTiming&&(s.collectResourceTiming=!0);const d=this.tileManagers[e]=new ke(e,s,this.dispatcher);d.style=this,d.setEventedParent(this,(()=>({isSourceLoaded:d.loaded(),source:d.serialize(),sourceId:e}))),d.onAdd(this.map),this._changed=!0}removeSource(e){if(this._checkLoaded(),void 0===this.tileManagers[e])throw new Error("There is no source with this ID");for(const s in this._layers)if(this._layers[s].source===e)return this.fire(new l.k(new Error(`Source "${e}" cannot be removed while layer "${s}" is using it.`)));const s=this.tileManagers[e];delete this.tileManagers[e],delete this._updatedSources[e],s.fire(new l.l("data",{sourceDataType:"metadata",dataType:"source",sourceId:e})),s.setEventedParent(null),s.onRemove(this.map),this._changed=!0}setGeoJSONSourceData(e,s){if(this._checkLoaded(),void 0===this.tileManagers[e])throw new Error(`There is no source with this ID=${e}`);const l=this.tileManagers[e].getSource();if("geojson"!==l.type)throw new Error(`geojsonSource.type is ${l.type}, which is !== 'geojson`);l.setData(s),this._changed=!0}getSource(e){return this.tileManagers[e]&&this.tileManagers[e].getSource()}addLayer(e,s,c={}){this._checkLoaded();const d=e.id;if(this.getLayer(d))return void this.fire(new l.k(new Error(`Layer "${d}" already exists on this map.`)));let p;if("custom"===e.type){if(Dr(this,l.bX(e)))return;p=l.bT(e,this._globalState)}else{if("source"in e&&"object"==typeof e.source&&(this.addSource(d,e.source),e=l.bV(e),e=l.e(e,{source:d})),this._validate(l.C.layer,`layers.${d}`,e,{arrayIndex:-1},c))return;p=l.bT(e,this._globalState),this._validateLayer(p),p.setEventedParent(this,{layer:{id:d}})}const f=s?this._order.indexOf(s):this._order.length;if(s&&-1===f)this.fire(new l.k(new Error(`Cannot add layer "${d}" before non-existing layer "${s}".`)));else{if(this._order.splice(f,0,d),this._layerOrderChanged=!0,this._layers[d]=p,this._removedLayers[d]&&p.source&&"custom"!==p.type){const e=this._removedLayers[d];delete this._removedLayers[d],e.type!==p.type?this._updatedSources[p.source]="clear":(this._updatedSources[p.source]="reload",this.tileManagers[p.source].pause())}this._updateLayer(p),p.onAdd&&p.onAdd(this.map)}}moveLayer(e,s){if(this._checkLoaded(),this._changed=!0,!this._layers[e])return void this.fire(new l.k(new Error(`The layer '${e}' does not exist in the map's style and cannot be moved.`)));if(e===s)return;const c=this._order.indexOf(e);this._order.splice(c,1);const d=s?this._order.indexOf(s):this._order.length;s&&-1===d?this.fire(new l.k(new Error(`Cannot move layer "${e}" before non-existing layer "${s}".`))):(this._order.splice(d,0,e),this._layerOrderChanged=!0)}removeLayer(e){this._checkLoaded();const s=this._layers[e];if(!s)return void this.fire(new l.k(new Error(`Cannot remove non-existing layer "${e}".`)));s.setEventedParent(null);const c=this._order.indexOf(e);this._order.splice(c,1),this._layerOrderChanged=!0,this._changed=!0,this._removedLayers[e]=s,delete this._layers[e],this._serializedLayers&&delete this._serializedLayers[e],delete this._updatedLayers[e],delete this._updatedPaintProps[e],s.onRemove&&s.onRemove(this.map)}getLayer(e){return this._layers[e]}getLayersOrder(){return[...this._order]}hasLayer(e){return e in this._layers}setLayerZoomRange(e,s,c){this._checkLoaded();const d=this.getLayer(e);d?d.minzoom===s&&d.maxzoom===c||(null!=s&&(d.minzoom=s),null!=c&&(d.maxzoom=c),this._updateLayer(d)):this.fire(new l.k(new Error(`Cannot set the zoom range of non-existing layer "${e}".`)))}setFilter(e,s,c={}){this._checkLoaded();const d=this.getLayer(e);if(d){if(!l.bR(d.filter,s))return null==s?(d.setFilter(void 0),void this._updateLayer(d)):void(this._validate(l.C.filter,`layers.${d.id}.filter`,s,null,c)||(d.setFilter(l.bV(s)),this._updateLayer(d)))}else this.fire(new l.k(new Error(`Cannot filter non-existing layer "${e}".`)))}getFilter(e){return l.bV(this.getLayer(e).filter)}setLayoutProperty(e,s,c,d={}){this._checkLoaded();const p=this.getLayer(e);p?l.bR(p.getLayoutProperty(s),c)||(p.setLayoutProperty(s,c,d),this._updateLayer(p)):this.fire(new l.k(new Error(`Cannot style non-existing layer "${e}".`)))}getLayoutProperty(e,s){const c=this.getLayer(e);if(c)return c.getLayoutProperty(s);this.fire(new l.k(new Error(`Cannot get style of non-existing layer "${e}".`)))}setPaintProperty(e,s,c,d={}){this._checkLoaded();const p=this.getLayer(e);p?l.bR(p.getPaintProperty(s),c)||this._updatePaintProperty(p,s,c,d):this.fire(new l.k(new Error(`Cannot style non-existing layer "${e}".`)))}_updatePaintProperty(e,s,c,d={}){e.setPaintProperty(s,c,d)&&this._updateLayer(e),l.bU(e)&&"raster-fade-duration"===s&&this.tileManagers[e.source].setRasterFadeDuration(c),this._changed=!0,this._updatedPaintProps[e.id]=!0,this._serializedLayers=null}getPaintProperty(e,s){return this.getLayer(e).getPaintProperty(s)}setFeatureState(e,s){this._checkLoaded();const c=e.source,d=e.sourceLayer,p=this.tileManagers[c];if(void 0===p)return void this.fire(new l.k(new Error(`The source '${c}' does not exist in the map's style.`)));const f=p.getSource().type;"geojson"===f&&d?this.fire(new l.k(new Error("GeoJSON sources cannot have a sourceLayer parameter."))):"vector"!==f||d?(void 0===e.id&&this.fire(new l.k(new Error("The feature id parameter must be provided."))),p.setFeatureState(d,e.id,s)):this.fire(new l.k(new Error("The sourceLayer parameter must be provided for vector source types.")))}removeFeatureState(e,s){this._checkLoaded();const c=e.source,d=this.tileManagers[c];if(void 0===d)return void this.fire(new l.k(new Error(`The source '${c}' does not exist in the map's style.`)));const p=d.getSource().type,f="vector"===p?e.sourceLayer:void 0;"vector"!==p||f?s&&"string"!=typeof e.id&&"number"!=typeof e.id?this.fire(new l.k(new Error("A feature id is required to remove its specific state property."))):d.removeFeatureState(f,e.id,s):this.fire(new l.k(new Error("The sourceLayer parameter must be provided for vector source types.")))}getFeatureState(e){this._checkLoaded();const s=e.source,c=e.sourceLayer,d=this.tileManagers[s];if(void 0!==d)return"vector"!==d.getSource().type||c?(void 0===e.id&&this.fire(new l.k(new Error("The feature id parameter must be provided."))),d.getFeatureState(c,e.id)):void this.fire(new l.k(new Error("The sourceLayer parameter must be provided for vector source types.")));this.fire(new l.k(new Error(`The source '${s}' does not exist in the map's style.`)))}getTransition(){return l.e({duration:300,delay:0},this.stylesheet&&this.stylesheet.transition)}serialize(){if(!this._loaded)return;const e=l.bY(this.tileManagers,(e=>e.serialize())),s=this._serializeByIds(this._order,!0),c=this.map.getTerrain()||void 0,d=this.stylesheet;return l.bZ({version:d.version,name:d.name,metadata:d.metadata,light:d.light,sky:d.sky,center:d.center,zoom:d.zoom,bearing:d.bearing,pitch:d.pitch,sprite:d.sprite,glyphs:d.glyphs,transition:d.transition,projection:d.projection,sources:e,layers:s,terrain:c},(e=>void 0!==e))}_updateLayer(e){this._updatedLayers[e.id]=!0,e.source&&!this._updatedSources[e.source]&&"raster"!==this.tileManagers[e.source].getSource().type&&(this._updatedSources[e.source]="reload",this.tileManagers[e.source].pause()),this._serializedLayers=null,this._changed=!0}_flattenAndSortRenderedFeatures(e){const s=e=>"fill-extrusion"===this._layers[e].type,l={},c=[];for(let d=this._order.length-1;d>=0;d--){const p=this._order[d];if(s(p)){l[p]=d;for(const s of e){const e=s[p];if(e)for(const s of e)c.push(s)}}}c.sort(((e,s)=>s.intersectionZ-e.intersectionZ));const d=[];for(let p=this._order.length-1;p>=0;p--){const f=this._order[p];if(s(f))for(let e=c.length-1;e>=0;e--){const s=c[e].feature;if(l[s.layer.id]this.map.terrain.getElevation(e,s,l):void 0));return this.placement&&p.push(function(e,s,l,c,d,p,f){const m={},_=p.queryRenderedSymbols(c),g=[];for(const e of Object.keys(_).map(Number))g.push(f[e]);g.sort(ue);for(const l of g){const c=l.featureIndex.lookupSymbolFeatures(_[l.bucketInstanceId],s,l.bucketIndex,l.sourceLayerIndex,{filterSpec:d.filter,globalState:d.globalState},d.layers,d.availableImages,e);for(const e in c){const s=m[e]=m[e]||[],d=c[e];d.sort(((e,s)=>{const c=l.featureSortOrder;if(c){const l=c.indexOf(e.featureIndex);return c.indexOf(s.featureIndex)-l}return s.featureIndex-e.featureIndex}));for(const e of d)s.push(e)}}return function(e,s,l){for(const c in e)for(const d of e[c])pe(d,l[s[c].source]);return e}(m,e,l)}(this._layers,f,this.tileManagers,e,_,this.placement.collisionIndex,this.placement.retainedQueryData)),this._flattenAndSortRenderedFeatures(p)}querySourceFeatures(e,s){(null==s?void 0:s.filter)&&this._validate(l.C.filter,"querySourceFeatures.filter",s.filter,null,s);const c=this.tileManagers[e];return c?function(e,s){const l=e.getRenderableIds().map((s=>e.getTileByID(s))),c=[],d={};for(let e=0;ee.getTileByID(s))).sort(((e,s)=>s.tileID.overscaledZ-e.tileID.overscaledZ||(e.tileID.isLessThan(s.tileID)?-1:1)))}const c=this.crossTileSymbolIndex.addLayer(l,m[l.source],e.center.lng);p=p||c}if(this.crossTileSymbolIndex.pruneUnusedLayers(this._order),((d=d||this._layerOrderChanged||0===l)||!this.pauseablePlacement||this.pauseablePlacement.isDone()&&!this.placement.stillRecent(y(),e.zoom))&&(this.pauseablePlacement=new It(e,this.map.terrain,this._order,d,s,l,c,this.placement),this._layerOrderChanged=!1),this.pauseablePlacement.isDone()?this.placement.setStale():(this.pauseablePlacement.continuePlacement(this._order,this._layers,m),this.pauseablePlacement.isDone()&&(this.placement=this.pauseablePlacement.commit(y()),f=!0),p&&this.pauseablePlacement.placement.setStale()),f||p)for(const e of this._order){const s=this._layers[e];"symbol"===s.type&&this.placement.updateLayerOpacities(s,m[s.source])}return!this.pauseablePlacement.isDone()||this.placement.hasTransitions(y())}_releaseSymbolFadeTiles(){for(const e in this.tileManagers)this.tileManagers[e].releaseSymbolFadeTiles()}getImages(e,s){return l._(this,void 0,void 0,(function*(){const e=yield this.imageManager.getImages(s.icons);this._updateTilesForChangedImages();const l=this.tileManagers[s.source];return l&&l.setDependencies(s.tileID.key,s.type,s.icons),e}))}getGlyphs(e,s){return l._(this,void 0,void 0,(function*(){const e=yield this.glyphManager.getGlyphs(s.stacks),l=this.tileManagers[s.source];return l&&l.setDependencies(s.tileID.key,s.type,[""]),e}))}getGlyphsUrl(){return this.stylesheet.glyphs||null}setGlyphs(e,s={}){this._checkLoaded(),e&&this._validate(l.C.glyphs,"glyphs",e,null,s)||(this._glyphsDidChange=!0,this.stylesheet.glyphs=e,this.glyphManager.entries={},this.glyphManager.setURL(e))}getDashes(e,s){return l._(this,void 0,void 0,(function*(){const e={};for(const[l,c]of Object.entries(s.dashes))e[l]=this.lineAtlas.getDash(c.dasharray,c.round);return e}))}addSprite(e,s,c={},d){this._checkLoaded();const p=[{id:e,url:s}],f=[...L(this.stylesheet.sprite),...p];this._validate(l.C.sprite,"sprite",f,null,c)||(this.stylesheet.sprite=f,this._loadSprite(p,!0,d))}removeSprite(e){this._checkLoaded();const s=L(this.stylesheet.sprite);if(s.find((s=>s.id===e))){if(this._spritesImagesIds[e])for(const s of this._spritesImagesIds[e])this.imageManager.removeImage(s),this._changedImages[s]=!0;s.splice(s.findIndex((s=>s.id===e)),1),this.stylesheet.sprite=s.length>0?s:void 0,delete this._spritesImagesIds[e],this._availableImages=this.imageManager.listImages(),this._changed=!0,this.dispatcher.broadcast("SI",this._availableImages),this.fire(new l.l("data",{dataType:"style"}))}else this.fire(new l.k(new Error(`Sprite "${e}" doesn't exists on this map.`)))}getSprite(){return L(this.stylesheet.sprite)}setSprite(e,s={},c){this._checkLoaded(),e&&this._validate(l.C.sprite,"sprite",e,null,s)||(this.stylesheet.sprite=e,e?this._loadSprite(e,!0,c):(this._unloadSprite(),c&&c(null)))}destroy(){this._frameRequest&&(this._frameRequest.abort(),this._frameRequest=null),this._loadStyleRequest&&(this._loadStyleRequest.abort(),this._loadStyleRequest=null),this._spriteRequest&&(this._spriteRequest.abort(),this._spriteRequest=null);for(const e in this.tileManagers){const s=this.tileManagers[e];s.setEventedParent(null),s.onRemove(this.map)}this.tileManagers={},this.imageManager&&(this.imageManager.setEventedParent(null),this.imageManager.destroy(),this._availableImages=[],this._spritesImagesIds={}),this.glyphManager&&this.glyphManager.destroy();for(const e in this._layers){const s=this._layers[e];s.setEventedParent(null),s.onRemove&&s.onRemove(this.map)}this._setInitialValues(),this.setEventedParent(null),this.dispatcher.unregisterMessageHandler("GG"),this.dispatcher.unregisterMessageHandler("GI"),this.dispatcher.unregisterMessageHandler("GDA"),this.dispatcher.remove(!0),this._listeners={},this._oneTimeListeners={}}}var kr=l.aU([{name:"a_pos",type:"Int16",components:2},{name:"a_texture_pos",type:"Int16",components:2}]);class Bi{constructor(){this.boundProgram=null,this.boundLayoutVertexBuffer=null,this.boundPaintVertexBuffers=[],this.boundIndexBuffer=null,this.boundVertexOffset=null,this.boundDynamicVertexBuffer=null,this.vao=null}bind(e,s,l,c,d,p,f,m,_){this.context=e;let g=this.boundPaintVertexBuffers.length!==c.length;for(let e=0;!g&&e({u_texture:0,u_ele_delta:e,u_fog_matrix:s,u_fog_color:c?c.properties.get("fog-color"):l.bp.white,u_fog_ground_blend:c?c.properties.get("fog-ground-blend"):1,u_fog_ground_blend_opacity:p?0:c?c.calculateFogBlendOpacity(d):0,u_horizon_color:c?c.properties.get("horizon-color"):l.bp.white,u_horizon_fog_blend:c?c.properties.get("horizon-fog-blend"):1,u_is_globe_mode:p?1:0}),Lr={mainMatrix:"u_projection_matrix",tileMercatorCoords:"u_projection_tile_mercator_coords",clippingPlane:"u_projection_clipping_plane",projectionTransition:"u_projection_transition",fallbackMatrix:"u_projection_fallback_matrix"};function Br(e){const s=[];for(let l=0;l({u_depth:new l.b_(e,s.u_depth),u_terrain:new l.b_(e,s.u_terrain),u_terrain_dim:new l.bq(e,s.u_terrain_dim),u_terrain_matrix:new l.c0(e,s.u_terrain_matrix),u_terrain_unpack:new l.c1(e,s.u_terrain_unpack),u_terrain_exaggeration:new l.bq(e,s.u_terrain_exaggeration)}))(e,q),this.projectionUniforms=((e,s)=>({u_projection_matrix:new l.c0(e,s.u_projection_matrix),u_projection_tile_mercator_coords:new l.c1(e,s.u_projection_tile_mercator_coords),u_projection_clipping_plane:new l.c1(e,s.u_projection_clipping_plane),u_projection_transition:new l.bq(e,s.u_projection_transition),u_projection_fallback_matrix:new l.c0(e,s.u_projection_fallback_matrix)}))(e,q),this.binderUniforms=c?c.getUniforms(e,q):[]}draw(e,s,l,c,d,p,f,m,_,g,y,b,T,P,S,I,C,R,L){const F=e.gl;if(this.failedToCreate)return;if(e.program.set(this.program),e.setDepthMode(l),e.setStencilMode(c),e.setColorMode(d),e.setCullFace(p),m){e.activeTexture.set(F.TEXTURE2),F.bindTexture(F.TEXTURE_2D,m.depthTexture),e.activeTexture.set(F.TEXTURE3),F.bindTexture(F.TEXTURE_2D,m.texture);for(const e in this.terrainUniforms)this.terrainUniforms[e].set(m[e])}if(_)for(const e in _)this.projectionUniforms[Lr[e]].set(_[e]);if(f)for(const e in this.fixedUniforms)this.fixedUniforms[e].set(f[e]);I&&I.setUniforms(e,this.binderUniforms,P,{zoom:S});let B=0;switch(s){case F.LINES:B=2;break;case F.TRIANGLES:B=3;break;case F.LINE_STRIP:B=1}for(const l of T.get()){const c=l.vaos||(l.vaos={});(c[g]||(c[g]=new Bi)).bind(e,this,y,I?I.getPaintVertexBuffers():[],b,l.vertexOffset,C,R,L),F.drawElements(s,l.primitiveLength*B,F.UNSIGNED_SHORT,l.primitiveOffset*B*2)}}}function Or(e,s,c){const d=1/l.aN(c,1,s.transform.tileZoom),p=Math.pow(2,c.tileID.overscaledZ),f=c.tileSize*Math.pow(2,s.transform.tileZoom)/p,m=f*(c.tileID.canonical.x+c.tileID.wrap*p),_=f*c.tileID.canonical.y;return{u_image:0,u_texsize:c.imageAtlasTexture.size,u_scale:[d,e.fromScale,e.toScale],u_fade:e.t,u_pixel_coord_upper:[m>>16,_>>16],u_pixel_coord_lower:[65535&m,65535&_]}}const Vr=(e,s,c,d)=>{const p=e.style.light,f=p.properties.get("position"),m=[f.x,f.y,f.z],_=l.c4();"viewport"===p.properties.get("anchor")&&l.c5(_,e.transform.bearingInRadians),l.c6(m,m,_);const g=e.transform.transformLightDirection(m),y=p.properties.get("color");return{u_lightpos:m,u_lightpos_globe:g,u_lightintensity:p.properties.get("intensity"),u_lightcolor:[y.r,y.g,y.b],u_vertical_gradient:+s,u_opacity:c,u_fill_translate:d}},jr=(e,s,c,d,p,f,m)=>l.e(Vr(e,s,c,d),Or(f,e,m),{u_height_factor:-Math.pow(2,p.overscaledZ)/m.tileSize/8}),Nr=(e,s,c,d)=>l.e(Or(s,e,c),{u_fill_translate:d}),Gr=(e,s)=>({u_world:e,u_fill_translate:s}),Ur=(e,s,c,d,p)=>l.e(Nr(e,s,c,p),{u_world:d}),Zr=(e,s,c,d,p)=>{const f=e.transform;let m,_,g=0;if("map"===c.paint.get("circle-pitch-alignment")){const e=l.aN(s,1,f.zoom);m=!0,_=[e,e],g=e/(l.a5*Math.pow(2,s.tileID.overscaledZ))*2*Math.PI*p}else m=!1,_=f.pixelsToGLUnits;return{u_camera_to_center_distance:f.cameraToCenterDistance,u_scale_with_map:+("map"===c.paint.get("circle-pitch-scale")),u_pitch_with_map:+m,u_device_pixel_ratio:e.pixelRatio,u_extrude_scale:_,u_globe_extrude_scale:g,u_translate:d}},Wr=e=>({u_pixel_extrude_scale:[1/e.width,1/e.height]}),Xr=e=>({u_viewport_size:[e.width,e.height]}),Yr=(e,s=1)=>({u_color:e,u_overlay:0,u_overlay_scale:s}),Kr=(e,s,c,d)=>{const p=l.aN(e,1,s)/(l.a5*Math.pow(2,e.tileID.overscaledZ))*2*Math.PI*d;return{u_extrude_scale:l.aN(e,1,s),u_intensity:c,u_globe_extrude_scale:p}},Qr=(e,s,c,d)=>{const p=l.N();l.c7(p,0,e.width,e.height,0,0,1);const f=e.context.gl;return{u_matrix:p,u_world:[f.drawingBufferWidth,f.drawingBufferHeight],u_image:c,u_color_ramp:d,u_opacity:s.paint.get("heatmap-opacity")}},Jr=(e,s,l)=>{const c=l.paint.get("hillshade-accent-color");let d;switch(l.paint.get("hillshade-method")){case"basic":d=4;break;case"combined":d=1;break;case"igor":d=2;break;case"multidirectional":d=3;break;default:d=0}const p=l.getIlluminationProperties();for(let s=0;s{const c=s.stride,d=l.N();return l.c7(d,0,l.a5,-l.a5,0,0,1),l.O(d,d,[0,-l.a5,0]),{u_matrix:d,u_image:1,u_dimension:[c,c],u_zoom:e.overscaledZ,u_unpack:s.getUnpackVector()}};function tn(e,s){const c=Math.pow(2,s.canonical.z),d=s.canonical.y;return[new l.a9(0,d/c).toLngLat().lat,new l.a9(0,(d+1)/c).toLngLat().lat]}const rn=(e,s,l=0)=>({u_image:0,u_unpack:s.getUnpackVector(),u_dimension:[s.stride,s.stride],u_elevation_stops:1,u_color_stops:4,u_color_ramp_size:l,u_opacity:e.paint.get("color-relief-opacity")}),nn=(e,s,c,d)=>{const p=e.transform;return{u_translation:un(e,s,c),u_ratio:d/l.aN(s,1,p.zoom),u_device_pixel_ratio:e.pixelRatio,u_units_to_pixels:[1/p.pixelsToGLUnits[0],1/p.pixelsToGLUnits[1]]}},sn=(e,s,c,d,p)=>l.e(nn(e,s,c,d),{u_image:0,u_image_height:p}),an=(e,s,c,d,p)=>{const f=e.transform,m=hn(s,f);return{u_translation:un(e,s,c),u_texsize:s.imageAtlasTexture.size,u_ratio:d/l.aN(s,1,f.zoom),u_device_pixel_ratio:e.pixelRatio,u_image:0,u_scale:[m,p.fromScale,p.toScale],u_fade:p.t,u_units_to_pixels:[1/f.pixelsToGLUnits[0],1/f.pixelsToGLUnits[1]]}},ln=(e,s,c,d,p)=>{const f=hn(s,e.transform);return l.e(nn(e,s,c,d),{u_tileratio:f,u_crossfade_from:p.fromScale,u_crossfade_to:p.toScale,u_image:0,u_mix:p.t,u_lineatlas_width:e.lineAtlas.width,u_lineatlas_height:e.lineAtlas.height})},cn=(e,s,c,d,p,f)=>{const m=hn(s,e.transform);return l.e(nn(e,s,c,d),{u_image:0,u_image_height:f,u_tileratio:m,u_crossfade_from:p.fromScale,u_crossfade_to:p.toScale,u_image_dash:1,u_mix:p.t,u_lineatlas_width:e.lineAtlas.width,u_lineatlas_height:e.lineAtlas.height})};function hn(e,s){return 1/l.aN(e,1,s.tileZoom)}function un(e,s,c){return l.aO(e.transform,s,c.paint.get("line-translate"),c.paint.get("line-translate-anchor"))}const dn=(e,s,l,c,d)=>{return{u_tl_parent:e,u_scale_parent:s,u_buffer_scale:1,u_fade_t:l.mix,u_opacity:l.opacity*c.paint.get("raster-opacity"),u_image0:0,u_image1:1,u_brightness_low:c.paint.get("raster-brightness-min"),u_brightness_high:c.paint.get("raster-brightness-max"),u_saturation_factor:(f=c.paint.get("raster-saturation"),f>0?1-1/(1.001-f):-f),u_contrast_factor:(p=c.paint.get("raster-contrast"),p>0?1/(1-p):1+p),u_spin_weights:pn(c.paint.get("raster-hue-rotate")),u_coords_top:[d[0].x,d[0].y,d[1].x,d[1].y],u_coords_bottom:[d[3].x,d[3].y,d[2].x,d[2].y]};var p,f};function pn(e){e*=Math.PI/180;const s=Math.sin(e),l=Math.cos(e);return[(2*l+1)/3,(-Math.sqrt(3)*s-l+1)/3,(Math.sqrt(3)*s-l+1)/3]}const fn=(e,s,l,c,d,p,f,m,_,g,y,b,T)=>{const P=f.transform;return{u_is_size_zoom_constant:+("constant"===e||"source"===e),u_is_size_feature_constant:+("constant"===e||"camera"===e),u_size_t:s?s.uSizeT:0,u_size:s?s.uSize:0,u_camera_to_center_distance:P.cameraToCenterDistance,u_pitch:P.pitch/360*2*Math.PI,u_rotate_symbol:+l,u_aspect_ratio:P.width/P.height,u_fade_change:f.options.fadeDuration?f.symbolFadeChange:1,u_label_plane_matrix:m,u_coord_matrix:_,u_is_text:+y,u_pitch_with_map:+c,u_is_along_line:d,u_is_variable_anchor:p,u_texsize:b,u_texture:0,u_translation:g,u_pitched_scale:T}},mn=(e,s,c,d,p,f,m,_,g,y,b,T,P,S)=>{const I=m.transform;return l.e(fn(e,s,c,d,p,f,m,_,g,y,b,T,S),{u_gamma_scale:d?Math.cos(I.pitch*Math.PI/180)*I.cameraToCenterDistance:1,u_device_pixel_ratio:m.pixelRatio,u_is_halo:1})},_n=(e,s,c,d,p,f,m,_,g,y,b,T,P)=>l.e(mn(e,s,c,d,p,f,m,_,g,y,!0,b,0,P),{u_texsize_icon:T,u_texture_icon:1}),gn=(e,s)=>({u_opacity:e,u_color:s}),yn=(e,s,c,d,p)=>l.e(function(e,s,c,d){const p=c.imageManager.getPattern(e.from.toString()),f=c.imageManager.getPattern(e.to.toString()),{width:m,height:_}=c.imageManager.getPixelSize(),g=Math.pow(2,d.tileID.overscaledZ),y=d.tileSize*Math.pow(2,c.transform.tileZoom)/g,b=y*(d.tileID.canonical.x+d.tileID.wrap*g),T=y*d.tileID.canonical.y;return{u_image:0,u_pattern_tl_a:p.tl,u_pattern_br_a:p.br,u_pattern_tl_b:f.tl,u_pattern_br_b:f.br,u_texsize:[m,_],u_mix:s.t,u_pattern_size_a:p.displaySize,u_pattern_size_b:f.displaySize,u_scale_a:s.fromScale,u_scale_b:s.toScale,u_tile_units_to_pixels:1/l.aN(d,1,c.transform.tileZoom),u_pixel_coord_upper:[b>>16,T>>16],u_pixel_coord_lower:[65535&b,65535&T]}}(c,p,s,d),{u_opacity:e}),xn=(e,s)=>{},vn={fillExtrusion:(e,s)=>({u_lightpos:new l.c2(e,s.u_lightpos),u_lightpos_globe:new l.c2(e,s.u_lightpos_globe),u_lightintensity:new l.bq(e,s.u_lightintensity),u_lightcolor:new l.c2(e,s.u_lightcolor),u_vertical_gradient:new l.bq(e,s.u_vertical_gradient),u_opacity:new l.bq(e,s.u_opacity),u_fill_translate:new l.c3(e,s.u_fill_translate)}),fillExtrusionPattern:(e,s)=>({u_lightpos:new l.c2(e,s.u_lightpos),u_lightpos_globe:new l.c2(e,s.u_lightpos_globe),u_lightintensity:new l.bq(e,s.u_lightintensity),u_lightcolor:new l.c2(e,s.u_lightcolor),u_vertical_gradient:new l.bq(e,s.u_vertical_gradient),u_height_factor:new l.bq(e,s.u_height_factor),u_opacity:new l.bq(e,s.u_opacity),u_fill_translate:new l.c3(e,s.u_fill_translate),u_image:new l.b_(e,s.u_image),u_texsize:new l.c3(e,s.u_texsize),u_pixel_coord_upper:new l.c3(e,s.u_pixel_coord_upper),u_pixel_coord_lower:new l.c3(e,s.u_pixel_coord_lower),u_scale:new l.c2(e,s.u_scale),u_fade:new l.bq(e,s.u_fade)}),fill:(e,s)=>({u_fill_translate:new l.c3(e,s.u_fill_translate)}),fillPattern:(e,s)=>({u_image:new l.b_(e,s.u_image),u_texsize:new l.c3(e,s.u_texsize),u_pixel_coord_upper:new l.c3(e,s.u_pixel_coord_upper),u_pixel_coord_lower:new l.c3(e,s.u_pixel_coord_lower),u_scale:new l.c2(e,s.u_scale),u_fade:new l.bq(e,s.u_fade),u_fill_translate:new l.c3(e,s.u_fill_translate)}),fillOutline:(e,s)=>({u_world:new l.c3(e,s.u_world),u_fill_translate:new l.c3(e,s.u_fill_translate)}),fillOutlinePattern:(e,s)=>({u_world:new l.c3(e,s.u_world),u_image:new l.b_(e,s.u_image),u_texsize:new l.c3(e,s.u_texsize),u_pixel_coord_upper:new l.c3(e,s.u_pixel_coord_upper),u_pixel_coord_lower:new l.c3(e,s.u_pixel_coord_lower),u_scale:new l.c2(e,s.u_scale),u_fade:new l.bq(e,s.u_fade),u_fill_translate:new l.c3(e,s.u_fill_translate)}),circle:(e,s)=>({u_camera_to_center_distance:new l.bq(e,s.u_camera_to_center_distance),u_scale_with_map:new l.b_(e,s.u_scale_with_map),u_pitch_with_map:new l.b_(e,s.u_pitch_with_map),u_extrude_scale:new l.c3(e,s.u_extrude_scale),u_device_pixel_ratio:new l.bq(e,s.u_device_pixel_ratio),u_globe_extrude_scale:new l.bq(e,s.u_globe_extrude_scale),u_translate:new l.c3(e,s.u_translate)}),collisionBox:(e,s)=>({u_pixel_extrude_scale:new l.c3(e,s.u_pixel_extrude_scale)}),collisionCircle:(e,s)=>({u_viewport_size:new l.c3(e,s.u_viewport_size)}),debug:(e,s)=>({u_color:new l.b$(e,s.u_color),u_overlay:new l.b_(e,s.u_overlay),u_overlay_scale:new l.bq(e,s.u_overlay_scale)}),depth:xn,clippingMask:xn,heatmap:(e,s)=>({u_extrude_scale:new l.bq(e,s.u_extrude_scale),u_intensity:new l.bq(e,s.u_intensity),u_globe_extrude_scale:new l.bq(e,s.u_globe_extrude_scale)}),heatmapTexture:(e,s)=>({u_matrix:new l.c0(e,s.u_matrix),u_world:new l.c3(e,s.u_world),u_image:new l.b_(e,s.u_image),u_color_ramp:new l.b_(e,s.u_color_ramp),u_opacity:new l.bq(e,s.u_opacity)}),hillshade:(e,s)=>({u_image:new l.b_(e,s.u_image),u_latrange:new l.c3(e,s.u_latrange),u_exaggeration:new l.bq(e,s.u_exaggeration),u_altitudes:new l.c9(e,s.u_altitudes),u_azimuths:new l.c9(e,s.u_azimuths),u_accent:new l.b$(e,s.u_accent),u_method:new l.b_(e,s.u_method),u_shadows:new l.c8(e,s.u_shadows),u_highlights:new l.c8(e,s.u_highlights)}),hillshadePrepare:(e,s)=>({u_matrix:new l.c0(e,s.u_matrix),u_image:new l.b_(e,s.u_image),u_dimension:new l.c3(e,s.u_dimension),u_zoom:new l.bq(e,s.u_zoom),u_unpack:new l.c1(e,s.u_unpack)}),colorRelief:(e,s)=>({u_image:new l.b_(e,s.u_image),u_unpack:new l.c1(e,s.u_unpack),u_dimension:new l.c3(e,s.u_dimension),u_elevation_stops:new l.b_(e,s.u_elevation_stops),u_color_stops:new l.b_(e,s.u_color_stops),u_color_ramp_size:new l.b_(e,s.u_color_ramp_size),u_opacity:new l.bq(e,s.u_opacity)}),line:(e,s)=>({u_translation:new l.c3(e,s.u_translation),u_ratio:new l.bq(e,s.u_ratio),u_device_pixel_ratio:new l.bq(e,s.u_device_pixel_ratio),u_units_to_pixels:new l.c3(e,s.u_units_to_pixels)}),lineGradient:(e,s)=>({u_translation:new l.c3(e,s.u_translation),u_ratio:new l.bq(e,s.u_ratio),u_device_pixel_ratio:new l.bq(e,s.u_device_pixel_ratio),u_units_to_pixels:new l.c3(e,s.u_units_to_pixels),u_image:new l.b_(e,s.u_image),u_image_height:new l.bq(e,s.u_image_height)}),linePattern:(e,s)=>({u_translation:new l.c3(e,s.u_translation),u_texsize:new l.c3(e,s.u_texsize),u_ratio:new l.bq(e,s.u_ratio),u_device_pixel_ratio:new l.bq(e,s.u_device_pixel_ratio),u_image:new l.b_(e,s.u_image),u_units_to_pixels:new l.c3(e,s.u_units_to_pixels),u_scale:new l.c2(e,s.u_scale),u_fade:new l.bq(e,s.u_fade)}),lineSDF:(e,s)=>({u_translation:new l.c3(e,s.u_translation),u_ratio:new l.bq(e,s.u_ratio),u_device_pixel_ratio:new l.bq(e,s.u_device_pixel_ratio),u_units_to_pixels:new l.c3(e,s.u_units_to_pixels),u_image:new l.b_(e,s.u_image),u_mix:new l.bq(e,s.u_mix),u_tileratio:new l.bq(e,s.u_tileratio),u_crossfade_from:new l.bq(e,s.u_crossfade_from),u_crossfade_to:new l.bq(e,s.u_crossfade_to),u_lineatlas_width:new l.bq(e,s.u_lineatlas_width),u_lineatlas_height:new l.bq(e,s.u_lineatlas_height)}),lineGradientSDF:(e,s)=>({u_translation:new l.c3(e,s.u_translation),u_ratio:new l.bq(e,s.u_ratio),u_device_pixel_ratio:new l.bq(e,s.u_device_pixel_ratio),u_units_to_pixels:new l.c3(e,s.u_units_to_pixels),u_image:new l.b_(e,s.u_image),u_image_height:new l.bq(e,s.u_image_height),u_tileratio:new l.bq(e,s.u_tileratio),u_crossfade_from:new l.bq(e,s.u_crossfade_from),u_crossfade_to:new l.bq(e,s.u_crossfade_to),u_image_dash:new l.b_(e,s.u_image_dash),u_mix:new l.bq(e,s.u_mix),u_lineatlas_width:new l.bq(e,s.u_lineatlas_width),u_lineatlas_height:new l.bq(e,s.u_lineatlas_height)}),raster:(e,s)=>({u_tl_parent:new l.c3(e,s.u_tl_parent),u_scale_parent:new l.bq(e,s.u_scale_parent),u_buffer_scale:new l.bq(e,s.u_buffer_scale),u_fade_t:new l.bq(e,s.u_fade_t),u_opacity:new l.bq(e,s.u_opacity),u_image0:new l.b_(e,s.u_image0),u_image1:new l.b_(e,s.u_image1),u_brightness_low:new l.bq(e,s.u_brightness_low),u_brightness_high:new l.bq(e,s.u_brightness_high),u_saturation_factor:new l.bq(e,s.u_saturation_factor),u_contrast_factor:new l.bq(e,s.u_contrast_factor),u_spin_weights:new l.c2(e,s.u_spin_weights),u_coords_top:new l.c1(e,s.u_coords_top),u_coords_bottom:new l.c1(e,s.u_coords_bottom)}),symbolIcon:(e,s)=>({u_is_size_zoom_constant:new l.b_(e,s.u_is_size_zoom_constant),u_is_size_feature_constant:new l.b_(e,s.u_is_size_feature_constant),u_size_t:new l.bq(e,s.u_size_t),u_size:new l.bq(e,s.u_size),u_camera_to_center_distance:new l.bq(e,s.u_camera_to_center_distance),u_pitch:new l.bq(e,s.u_pitch),u_rotate_symbol:new l.b_(e,s.u_rotate_symbol),u_aspect_ratio:new l.bq(e,s.u_aspect_ratio),u_fade_change:new l.bq(e,s.u_fade_change),u_label_plane_matrix:new l.c0(e,s.u_label_plane_matrix),u_coord_matrix:new l.c0(e,s.u_coord_matrix),u_is_text:new l.b_(e,s.u_is_text),u_pitch_with_map:new l.b_(e,s.u_pitch_with_map),u_is_along_line:new l.b_(e,s.u_is_along_line),u_is_variable_anchor:new l.b_(e,s.u_is_variable_anchor),u_texsize:new l.c3(e,s.u_texsize),u_texture:new l.b_(e,s.u_texture),u_translation:new l.c3(e,s.u_translation),u_pitched_scale:new l.bq(e,s.u_pitched_scale)}),symbolSDF:(e,s)=>({u_is_size_zoom_constant:new l.b_(e,s.u_is_size_zoom_constant),u_is_size_feature_constant:new l.b_(e,s.u_is_size_feature_constant),u_size_t:new l.bq(e,s.u_size_t),u_size:new l.bq(e,s.u_size),u_camera_to_center_distance:new l.bq(e,s.u_camera_to_center_distance),u_pitch:new l.bq(e,s.u_pitch),u_rotate_symbol:new l.b_(e,s.u_rotate_symbol),u_aspect_ratio:new l.bq(e,s.u_aspect_ratio),u_fade_change:new l.bq(e,s.u_fade_change),u_label_plane_matrix:new l.c0(e,s.u_label_plane_matrix),u_coord_matrix:new l.c0(e,s.u_coord_matrix),u_is_text:new l.b_(e,s.u_is_text),u_pitch_with_map:new l.b_(e,s.u_pitch_with_map),u_is_along_line:new l.b_(e,s.u_is_along_line),u_is_variable_anchor:new l.b_(e,s.u_is_variable_anchor),u_texsize:new l.c3(e,s.u_texsize),u_texture:new l.b_(e,s.u_texture),u_gamma_scale:new l.bq(e,s.u_gamma_scale),u_device_pixel_ratio:new l.bq(e,s.u_device_pixel_ratio),u_is_halo:new l.b_(e,s.u_is_halo),u_translation:new l.c3(e,s.u_translation),u_pitched_scale:new l.bq(e,s.u_pitched_scale)}),symbolTextAndIcon:(e,s)=>({u_is_size_zoom_constant:new l.b_(e,s.u_is_size_zoom_constant),u_is_size_feature_constant:new l.b_(e,s.u_is_size_feature_constant),u_size_t:new l.bq(e,s.u_size_t),u_size:new l.bq(e,s.u_size),u_camera_to_center_distance:new l.bq(e,s.u_camera_to_center_distance),u_pitch:new l.bq(e,s.u_pitch),u_rotate_symbol:new l.b_(e,s.u_rotate_symbol),u_aspect_ratio:new l.bq(e,s.u_aspect_ratio),u_fade_change:new l.bq(e,s.u_fade_change),u_label_plane_matrix:new l.c0(e,s.u_label_plane_matrix),u_coord_matrix:new l.c0(e,s.u_coord_matrix),u_is_text:new l.b_(e,s.u_is_text),u_pitch_with_map:new l.b_(e,s.u_pitch_with_map),u_is_along_line:new l.b_(e,s.u_is_along_line),u_is_variable_anchor:new l.b_(e,s.u_is_variable_anchor),u_texsize:new l.c3(e,s.u_texsize),u_texsize_icon:new l.c3(e,s.u_texsize_icon),u_texture:new l.b_(e,s.u_texture),u_texture_icon:new l.b_(e,s.u_texture_icon),u_gamma_scale:new l.bq(e,s.u_gamma_scale),u_device_pixel_ratio:new l.bq(e,s.u_device_pixel_ratio),u_is_halo:new l.b_(e,s.u_is_halo),u_translation:new l.c3(e,s.u_translation),u_pitched_scale:new l.bq(e,s.u_pitched_scale)}),background:(e,s)=>({u_opacity:new l.bq(e,s.u_opacity),u_color:new l.b$(e,s.u_color)}),backgroundPattern:(e,s)=>({u_opacity:new l.bq(e,s.u_opacity),u_image:new l.b_(e,s.u_image),u_pattern_tl_a:new l.c3(e,s.u_pattern_tl_a),u_pattern_br_a:new l.c3(e,s.u_pattern_br_a),u_pattern_tl_b:new l.c3(e,s.u_pattern_tl_b),u_pattern_br_b:new l.c3(e,s.u_pattern_br_b),u_texsize:new l.c3(e,s.u_texsize),u_mix:new l.bq(e,s.u_mix),u_pattern_size_a:new l.c3(e,s.u_pattern_size_a),u_pattern_size_b:new l.c3(e,s.u_pattern_size_b),u_scale_a:new l.bq(e,s.u_scale_a),u_scale_b:new l.bq(e,s.u_scale_b),u_pixel_coord_upper:new l.c3(e,s.u_pixel_coord_upper),u_pixel_coord_lower:new l.c3(e,s.u_pixel_coord_lower),u_tile_units_to_pixels:new l.bq(e,s.u_tile_units_to_pixels)}),terrain:(e,s)=>({u_texture:new l.b_(e,s.u_texture),u_ele_delta:new l.bq(e,s.u_ele_delta),u_fog_matrix:new l.c0(e,s.u_fog_matrix),u_fog_color:new l.b$(e,s.u_fog_color),u_fog_ground_blend:new l.bq(e,s.u_fog_ground_blend),u_fog_ground_blend_opacity:new l.bq(e,s.u_fog_ground_blend_opacity),u_horizon_color:new l.b$(e,s.u_horizon_color),u_horizon_fog_blend:new l.bq(e,s.u_horizon_fog_blend),u_is_globe_mode:new l.bq(e,s.u_is_globe_mode)}),terrainDepth:(e,s)=>({u_ele_delta:new l.bq(e,s.u_ele_delta)}),terrainCoords:(e,s)=>({u_texture:new l.b_(e,s.u_texture),u_terrain_coords_id:new l.bq(e,s.u_terrain_coords_id),u_ele_delta:new l.bq(e,s.u_ele_delta)}),projectionErrorMeasurement:(e,s)=>({u_input:new l.bq(e,s.u_input),u_output_expected:new l.bq(e,s.u_output_expected)}),atmosphere:(e,s)=>({u_sun_pos:new l.c2(e,s.u_sun_pos),u_atmosphere_blend:new l.bq(e,s.u_atmosphere_blend),u_globe_position:new l.c2(e,s.u_globe_position),u_globe_radius:new l.bq(e,s.u_globe_radius),u_inv_proj_matrix:new l.c0(e,s.u_inv_proj_matrix)}),sky:(e,s)=>({u_sky_color:new l.b$(e,s.u_sky_color),u_horizon_color:new l.b$(e,s.u_horizon_color),u_horizon:new l.c3(e,s.u_horizon),u_horizon_normal:new l.c3(e,s.u_horizon_normal),u_sky_horizon_blend:new l.bq(e,s.u_sky_horizon_blend),u_sky_blend:new l.bq(e,s.u_sky_blend)})};class ba{constructor(e,s,l){this.context=e;const c=e.gl;this.buffer=c.createBuffer(),this.dynamicDraw=Boolean(l),this.context.unbindVAO(),e.bindElementBuffer.set(this.buffer),c.bufferData(c.ELEMENT_ARRAY_BUFFER,s.arrayBuffer,this.dynamicDraw?c.DYNAMIC_DRAW:c.STATIC_DRAW),this.dynamicDraw||delete s.arrayBuffer}bind(){this.context.bindElementBuffer.set(this.buffer)}updateData(e){const s=this.context.gl;if(!this.dynamicDraw)throw new Error("Attempted to update data while not in dynamic mode.");this.context.unbindVAO(),this.bind(),s.bufferSubData(s.ELEMENT_ARRAY_BUFFER,0,e.arrayBuffer)}destroy(){this.buffer&&(this.context.gl.deleteBuffer(this.buffer),delete this.buffer)}}const bn={Int8:"BYTE",Uint8:"UNSIGNED_BYTE",Int16:"SHORT",Uint16:"UNSIGNED_SHORT",Int32:"INT",Uint32:"UNSIGNED_INT",Float32:"FLOAT"};class wa{constructor(e,s,l,c){this.length=s.length,this.attributes=l,this.itemSize=s.bytesPerElement,this.dynamicDraw=c,this.context=e;const d=e.gl;this.buffer=d.createBuffer(),e.bindVertexBuffer.set(this.buffer),d.bufferData(d.ARRAY_BUFFER,s.arrayBuffer,this.dynamicDraw?d.DYNAMIC_DRAW:d.STATIC_DRAW),this.dynamicDraw||delete s.arrayBuffer}bind(){this.context.bindVertexBuffer.set(this.buffer)}updateData(e){if(e.length!==this.length)throw new Error(`Length of new data is ${e.length}, which doesn't match current length of ${this.length}`);const s=this.context.gl;this.bind(),s.bufferSubData(s.ARRAY_BUFFER,0,e.arrayBuffer)}enableAttributes(e,s){for(let l=0;l0&&(y.push({circleArray:C,circleOffset:T,coord:P}),b+=C.length/4,T=b),I&&g.draw(f,_.LINES,ti.disabled,ai.disabled,e.colorModeForRenderPass(),ei.disabled,Wr(e.transform),e.style.map.terrain&&e.style.map.terrain.getTerrainData(P),m.getProjectionData({overscaledTileID:P,applyGlobeMatrix:!0,applyTerrainMatrix:!0}),c.id,I.layoutVertexBuffer,I.indexBuffer,I.segments,null,e.transform.zoom,null,null,I.collisionVertexBuffer)}if(!p||!y.length)return;const P=e.useProgram("collisionCircle"),S=new l.ca;S.resize(4*b),S._trim();let I=0;for(const e of y)for(let s=0;s=0&&(C[R.associatedIconIndex]={shiftedAnchor:J,angle:re})}else fi(R.numGlyphs,S)}if(g){I.clear();const s=e.icon.placedSymbolArray;for(let e=0;ee.style.map.terrain.getElevation(_,s,l):null,l="map"===c.layout.get("text-rotation-alignment");Ot(g,e,p,me,ge,L,y,l,_.toUnwrapped(),C.width,C.height,xe,s)}const Se=p&&U||we,Me=F||Se?Sn:L?me:e.transform.clipSpaceToPixelsMatrix,Ee=S&&0!==c.paint.get(p?"text-halo-width":"icon-halo-width").constantOr(1);let Ce;Ce=S?g.iconsInText?_n(G.kind,re,B,L,F,Se,e,Me,ye,xe,oe,ue,Z):mn(G.kind,re,B,L,F,Se,e,Me,ye,xe,p,oe,0,Z):fn(G.kind,re,B,L,F,Se,e,Me,ye,xe,p,oe,Z);const Ae={program:J,buffers:b,uniformValues:Ce,projectionData:ve,atlasTexture:le,atlasTextureIcon:pe,atlasInterpolation:ce,atlasInterpolationIcon:he,isSDF:S,hasHalo:Ee};if(O&&g.canOverlap){j=!0;const e=b.segments.get();for(const s of e)q.push({segments:new l.aX([s]),sortKey:s.sortKey,state:Ae,terrainData:se})}else q.push({segments:b.segments,sortKey:0,state:Ae,terrainData:se})}j&&q.sort(((e,s)=>e.sortKey-s.sortKey));for(const s of q){const l=s.state;if(S.activeTexture.set(I.TEXTURE0),l.atlasTexture.bind(l.atlasInterpolation,I.CLAMP_TO_EDGE),l.atlasTextureIcon&&(S.activeTexture.set(I.TEXTURE1),l.atlasTextureIcon&&l.atlasTextureIcon.bind(l.atlasInterpolationIcon,I.CLAMP_TO_EDGE)),l.isSDF){const d=l.uniformValues;l.hasHalo&&(d.u_is_halo=1,kn(l.buffers,s.segments,c,e,l.program,G,b,T,d,l.projectionData,s.terrainData)),d.u_is_halo=0}kn(l.buffers,s.segments,c,e,l.program,G,b,T,l.uniformValues,l.projectionData,s.terrainData)}}function kn(e,s,l,c,d,p,f,m,_,g,y){const b=c.context;d.draw(b,b.gl.TRIANGLES,p,f,m,ei.backCCW,_,y,g,l.id,e.layoutVertexBuffer,e.indexBuffer,s,l.paint,c.transform.zoom,e.programConfigurations.get(l.id),e.dynamicLayoutVertexBuffer,e.opacityVertexBuffer)}function Rn(e,s,c,d,p){const f=e.context,m=f.gl,_=ai.disabled,g=new Qt([m.ONE,m.ONE],l.bp.transparent,[!0,!0,!0,!0]),y=s.getBucket(c);if(!y)return;const b=d.key;let T=c.heatmapFbos.get(b);T||(T=Bn(f,s.tileSize,s.tileSize),c.heatmapFbos.set(b,T)),f.bindFramebuffer.set(T.framebuffer),f.viewport.set([0,0,s.tileSize,s.tileSize]),f.clear({color:l.bp.transparent});const P=y.programConfigurations.get(c.id),S=e.useProgram("heatmap",P,!p),I=e.transform.getProjectionData({overscaledTileID:s.tileID,applyGlobeMatrix:!0,applyTerrainMatrix:!0}),C=e.style.map.terrain.getTerrainData(d);S.draw(f,m.TRIANGLES,ti.disabled,_,g,ei.disabled,Kr(s,e.transform.zoom,c.paint.get("heatmap-intensity"),1),C,I,c.id,y.layoutVertexBuffer,y.indexBuffer,y.segments,c.paint,e.transform.zoom,P)}function Ln(e,s,l,c,d){const p=e.context,f=p.gl,m=e.transform;p.setColorMode(e.colorModeForRenderPass());const _=On(p,s),g=l.key,y=s.heatmapFbos.get(g);if(!y)return;p.activeTexture.set(f.TEXTURE0),f.bindTexture(f.TEXTURE_2D,y.colorAttachment.get()),p.activeTexture.set(f.TEXTURE1),_.bind(f.LINEAR,f.CLAMP_TO_EDGE);const b=m.getProjectionData({overscaledTileID:l,applyTerrainMatrix:d,applyGlobeMatrix:!c});e.useProgram("heatmapTexture").draw(p,f.TRIANGLES,ti.disabled,ai.disabled,e.colorModeForRenderPass(),ei.disabled,Qr(e,s,0,1),null,b,s.id,e.rasterBoundsBuffer,e.quadTriangleIndexBuffer,e.rasterBoundsSegments,s.paint,m.zoom),y.destroy(),s.heatmapFbos.delete(g)}function Bn(e,s,l){var c,d;const p=e.gl,f=p.createTexture();p.bindTexture(p.TEXTURE_2D,f),p.texParameteri(p.TEXTURE_2D,p.TEXTURE_WRAP_S,p.CLAMP_TO_EDGE),p.texParameteri(p.TEXTURE_2D,p.TEXTURE_WRAP_T,p.CLAMP_TO_EDGE),p.texParameteri(p.TEXTURE_2D,p.TEXTURE_MIN_FILTER,p.LINEAR),p.texParameteri(p.TEXTURE_2D,p.TEXTURE_MAG_FILTER,p.LINEAR);const m=null!==(c=e.HALF_FLOAT)&&void 0!==c?c:p.UNSIGNED_BYTE,_=null!==(d=e.RGBA16F)&&void 0!==d?d:p.RGBA;p.texImage2D(p.TEXTURE_2D,0,_,s,l,0,p.RGBA,m,null);const g=e.createFramebuffer(s,l,!1,!1);return g.colorAttachment.set(f),g}function On(e,s){return s.colorRampTexture||(s.colorRampTexture=new l.T(e,s.colorRamp,e.gl.RGBA)),s.colorRampTexture}function Vn(e,s,c,d,p,f,m,_){let g=256;if(p.stepInterpolant){const d=s.getSource().maxzoom,p=m.canonical.z===d?Math.ceil(1<20&&T.texParameterf(T.TEXTURE_2D,b.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,b.extTextureFilterAnisotropicMax);const re=e.style.map.terrain&&e.style.map.terrain.getTerrainData(j),se=S.getProjectionData({overscaledTileID:j,aligned:R,applyGlobeMatrix:!g,applyTerrainMatrix:!0}),oe=dn(W,Z,J.fadeMix,l,m),le=I.getMeshFromTileID(b,j.canonical,p,f,"raster");P.draw(b,T.TRIANGLES,c,d?d[j.overscaledZ]:ai.disabled,C,_?ei.frontCCW:ei.backCCW,oe,re,se,l.id,le.vertexBuffer,le.indexBuffer,le.segments)}}function Kn(e,s,c,d){const p={parentTile:null,parentScaleBy:1,parentTopLeft:[0,0],fadeValues:{tileOpacity:1,parentTileOpacity:1,fadeMix:{opacity:1,mix:0}}};if(0===c||d)return p;if(e.fadingParentID){const d=s.getLoadedTile(e.fadingParentID);if(!d)return p;const f=Math.pow(2,d.tileID.overscaledZ-e.tileID.overscaledZ),m=[e.tileID.canonical.x*f%1,e.tileID.canonical.y*f%1],_=function(e,s,c){const d=y(),p=(d-s.timeAdded)/c,f=e.fadingDirection===Me.Incoming,m=l.an((d-e.timeAdded)/c,0,1),_=l.an(1-p,0,1),g=f?m:_;return{tileOpacity:g,parentTileOpacity:f?_:m,fadeMix:{opacity:1,mix:1-g}}}(e,d,c);return{parentTile:d,parentScaleBy:f,parentTopLeft:m,fadeValues:_}}if(e.selfFading){const s=function(e,s){const c=(y()-e.timeAdded)/s,d=l.an(c,0,1);return{tileOpacity:d,fadeMix:{opacity:d,mix:0}}}(e,c);return{parentTile:null,parentScaleBy:1,parentTopLeft:[0,0],fadeValues:s}}return p}const Qn=new l.bp(1,0,0,1),Jn=new l.bp(0,1,0,1),es=new l.bp(0,0,1,1),ns=new l.bp(1,0,1,1),ss=new l.bp(0,1,1,1);function ls(e,s,l,c){ds(e,0,s+l/2,e.transform.width,l,c)}function us(e,s,l,c){ds(e,s-l/2,0,l,e.transform.height,c)}function ds(e,s,l,c,d,p){const f=e.context,m=f.gl;m.enable(m.SCISSOR_TEST),m.scissor(s*e.pixelRatio,l*e.pixelRatio,c*e.pixelRatio,d*e.pixelRatio),f.clear({color:p}),m.disable(m.SCISSOR_TEST)}function ps(e,s,c){const d=e.context,p=d.gl,f=e.useProgram("debug"),m=ti.disabled,_=ai.disabled,g=e.colorModeForRenderPass(),y="$debug",b=e.style.map.terrain&&e.style.map.terrain.getTerrainData(c);d.activeTexture.set(p.TEXTURE0);const T=s.getTileByID(c.key).latestRawTileData,P=Math.floor((T&&T.byteLength||0)/1024),S=s.getTile(c).tileSize,I=512/Math.min(S,512)*(c.overscaledZ/e.transform.zoom)*.5;let C=c.canonical.toString();c.overscaledZ!==c.canonical.z&&(C+=` => ${c.overscaledZ}`),function(e,s){e.initDebugOverlayCanvas();const l=e.debugOverlayCanvas,c=e.context.gl,d=e.debugOverlayCanvas.getContext("2d");d.clearRect(0,0,l.width,l.height),d.shadowColor="white",d.shadowBlur=2,d.lineWidth=1.5,d.strokeStyle="white",d.textBaseline="top",d.font="bold 36px Open Sans, sans-serif",d.fillText(s,5,5),d.strokeText(s,5,5),e.debugOverlayTexture.update(l),e.debugOverlayTexture.bind(c.LINEAR,c.CLAMP_TO_EDGE)}(e,`${C} ${P}kB`);const R=e.transform.getProjectionData({overscaledTileID:c,applyGlobeMatrix:!0,applyTerrainMatrix:!0});f.draw(d,p.TRIANGLES,m,_,Qt.alphaBlended,ei.disabled,Yr(l.bp.transparent,I),null,R,y,e.debugBuffer,e.quadTriangleIndexBuffer,e.debugSegments),f.draw(d,p.LINE_STRIP,m,_,g,ei.disabled,Yr(l.bp.red),b,R,y,e.debugBuffer,e.tileBorderIndexBuffer,e.debugSegments)}function fs(e,s,l,c){const{isRenderingGlobe:d}=c,p=e.context,f=p.gl,m=e.transform,_=e.colorModeForRenderPass(),g=e.getDepthModeFor3D(),y=e.useProgram("terrain");p.bindFramebuffer.set(null),p.viewport.set([0,0,e.width,e.height]);for(const c of l){const l=s.getTerrainMesh(c.tileID),b=e.renderToTexture.getTexture(c),T=s.getTerrainData(c.tileID);p.activeTexture.set(f.TEXTURE0),f.bindTexture(f.TEXTURE_2D,b.texture);const P=s.getMeshFrameDelta(m.zoom),S=m.calculateFogMatrix(c.tileID.toUnwrapped()),I=Rr(P,S,e.style.sky,m.pitch,d),C=m.getProjectionData({overscaledTileID:c.tileID,applyTerrainMatrix:!1,applyGlobeMatrix:!0});y.draw(p,f.TRIANGLES,g,ai.disabled,_,ei.backCCW,I,T,C,"terrain",l.vertexBuffer,l.indexBuffer,l.segments)}}function _s(e,s){if(!s.mesh){const c=new l.aW;c.emplaceBack(-1,-1),c.emplaceBack(1,-1),c.emplaceBack(1,1),c.emplaceBack(-1,1);const d=new l.aY;d.emplaceBack(0,1,2),d.emplaceBack(0,2,3),s.mesh=new kt(e.createVertexBuffer(c,Ni.members),e.createIndexBuffer(d),l.aX.simpleSegment(0,0,c.length,d.length))}return s.mesh}class qr{constructor(e,s){this.context=new nr(e),this.transform=s,this._tileTextures={},this.terrainFacilitator={dirty:!0,matrix:l.ar(new Float64Array(16)),renderTime:0},this.setup(),this.numSublayers=ke.maxOverzooming+ke.maxUnderzooming+1,this.depthEpsilon=1/Math.pow(2,16),this.crossTileSymbolIndex=new Rt}resize(e,s,l){if(this.width=Math.floor(e*l),this.height=Math.floor(s*l),this.pixelRatio=l,this.context.viewport.set([0,0,this.width,this.height]),this.style)for(const e of this.style._order)this.style._layers[e].resize()}setup(){const e=this.context,s=new l.aW;s.emplaceBack(0,0),s.emplaceBack(l.a5,0),s.emplaceBack(0,l.a5),s.emplaceBack(l.a5,l.a5),this.tileExtentBuffer=e.createVertexBuffer(s,Ni.members),this.tileExtentSegments=l.aX.simpleSegment(0,0,4,2);const c=new l.aW;c.emplaceBack(0,0),c.emplaceBack(l.a5,0),c.emplaceBack(0,l.a5),c.emplaceBack(l.a5,l.a5),this.debugBuffer=e.createVertexBuffer(c,Ni.members),this.debugSegments=l.aX.simpleSegment(0,0,4,5);const d=new l.ch;d.emplaceBack(0,0,0,0),d.emplaceBack(l.a5,0,l.a5,0),d.emplaceBack(0,l.a5,0,l.a5),d.emplaceBack(l.a5,l.a5,l.a5,l.a5),this.rasterBoundsBuffer=e.createVertexBuffer(d,kr.members),this.rasterBoundsSegments=l.aX.simpleSegment(0,0,4,2);const p=new l.aW;p.emplaceBack(0,0),p.emplaceBack(l.a5,0),p.emplaceBack(0,l.a5),p.emplaceBack(l.a5,l.a5),this.rasterBoundsBufferPosOnly=e.createVertexBuffer(p,Ni.members),this.rasterBoundsSegmentsPosOnly=l.aX.simpleSegment(0,0,4,5);const f=new l.aW;f.emplaceBack(0,0),f.emplaceBack(1,0),f.emplaceBack(0,1),f.emplaceBack(1,1),this.viewportBuffer=e.createVertexBuffer(f,Ni.members),this.viewportSegments=l.aX.simpleSegment(0,0,4,2);const m=new l.ci;m.emplaceBack(0),m.emplaceBack(1),m.emplaceBack(3),m.emplaceBack(2),m.emplaceBack(0),this.tileBorderIndexBuffer=e.createIndexBuffer(m);const _=new l.aY;_.emplaceBack(1,0,2),_.emplaceBack(1,2,3),this.quadTriangleIndexBuffer=e.createIndexBuffer(_);const g=this.context.gl;this.stencilClearMode=new ai({func:g.ALWAYS,mask:0},0,255,g.ZERO,g.ZERO,g.ZERO),this.tileExtentMesh=new kt(this.tileExtentBuffer,this.quadTriangleIndexBuffer,this.tileExtentSegments)}clearStencil(){const e=this.context,s=e.gl;this.nextStencilID=1,this.currentStencilSource=void 0;const c=l.N();l.c7(c,0,this.width,this.height,0,0,1),l.Q(c,c,[s.drawingBufferWidth,s.drawingBufferHeight,0]);const d={mainMatrix:c,tileMercatorCoords:[0,0,1,1],clippingPlane:[0,0,0,0],projectionTransition:0,fallbackMatrix:c};this.useProgram("clippingMask",null,!0).draw(e,s.TRIANGLES,ti.disabled,this.stencilClearMode,Qt.disabled,ei.disabled,null,null,d,"$clipping",this.viewportBuffer,this.quadTriangleIndexBuffer,this.viewportSegments)}_renderTileClippingMasks(e,s,l){if(this.currentStencilSource===e.source||!e.isTileClipped()||!s||!s.length)return;this.currentStencilSource=e.source,this.nextStencilID+s.length>256&&this.clearStencil();const c=this.context;c.setColorMode(Qt.disabled),c.setDepthMode(ti.disabled);const d={};for(const e of s)d[e.key]=this.nextStencilID++;this._renderTileMasks(d,s,l,!0),this._renderTileMasks(d,s,l,!1),this._tileClippingMaskIDs=d}_renderTileMasks(e,s,l,c){const d=this.context,p=d.gl,f=this.style.projection,m=this.transform,_=this.useProgram("clippingMask");for(const g of s){const s=e[g.key],y=this.style.map.terrain&&this.style.map.terrain.getTerrainData(g),b=f.getMeshFromTileID(this.context,g.canonical,c,!0,"stencil"),T=m.getProjectionData({overscaledTileID:g,applyGlobeMatrix:!l,applyTerrainMatrix:!0});_.draw(d,p.TRIANGLES,ti.disabled,new ai({func:p.ALWAYS,mask:0},s,255,p.KEEP,p.KEEP,p.REPLACE),Qt.disabled,l?ei.disabled:ei.backCCW,null,y,T,"$clipping",b.vertexBuffer,b.indexBuffer,b.segments)}}_renderTilesDepthBuffer(){const e=this.context,s=e.gl,l=this.style.projection,c=this.transform,d=this.useProgram("depth"),p=this.getDepthModeFor3D(),f=it(c,{tileSize:c.tileSize});for(const m of f){const f=this.style.map.terrain&&this.style.map.terrain.getTerrainData(m),_=l.getMeshFromTileID(this.context,m.canonical,!0,!0,"raster"),g=c.getProjectionData({overscaledTileID:m,applyGlobeMatrix:!0,applyTerrainMatrix:!0});d.draw(e,s.TRIANGLES,p,ai.disabled,Qt.disabled,ei.backCCW,null,f,g,"$clipping",_.vertexBuffer,_.indexBuffer,_.segments)}}stencilModeFor3D(){this.currentStencilSource=void 0,this.nextStencilID+1>256&&this.clearStencil();const e=this.nextStencilID++,s=this.context.gl;return new ai({func:s.NOTEQUAL,mask:255},e,255,s.KEEP,s.KEEP,s.REPLACE)}stencilModeForClipping(e){const s=this.context.gl;return new ai({func:s.EQUAL,mask:255},this._tileClippingMaskIDs[e.key],0,s.KEEP,s.KEEP,s.REPLACE)}getStencilConfigForOverlapAndUpdateStencilID(e){const s=this.context.gl,l=e.sort(((e,s)=>s.overscaledZ-e.overscaledZ)),c=l[l.length-1].overscaledZ,d=l[0].overscaledZ-c+1;if(d>1){this.currentStencilSource=void 0,this.nextStencilID+d>256&&this.clearStencil();const e={};for(let l=0;ls.overscaledZ-e.overscaledZ)),c=l[l.length-1].overscaledZ,d=l[0].overscaledZ-c+1;if(this.clearStencil(),d>1){const e={},p={};for(let l=0;l0};for(const e in f){const s=f[e];s.used&&s.prepare(this.context),m[e]=s.getVisibleCoordinates(!1),_[e]=m[e].slice().reverse(),g[e]=s.getVisibleCoordinates(!0).reverse()}this.opaquePassCutoff=1/0;for(let e=0;ethis.useProgram(e)}),this.context.viewport.set([0,0,this.width,this.height]),this.context.bindFramebuffer.set(null),this.context.clear({color:s.showOverdrawInspector?l.bp.black:l.bp.transparent,depth:1}),this.clearStencil(),this.style.sky&&function(e,s){const l=e.context,c=l.gl,d=((e,s,l)=>{const c=Math.cos(s.rollInRadians),d=Math.sin(s.rollInRadians),p=Ne(s),f=s.getProjectionData({overscaledTileID:null,applyGlobeMatrix:!0,applyTerrainMatrix:!0}).projectionTransition;return{u_sky_color:e.properties.get("sky-color"),u_horizon_color:e.properties.get("horizon-color"),u_horizon:[(s.width/2-p*d)*l,(s.height/2+p*c)*l],u_horizon_normal:[-d,c],u_sky_horizon_blend:e.properties.get("sky-horizon-blend")*s.height/2*l,u_sky_blend:f}})(s,e.style.map.transform,e.pixelRatio),p=new ti(c.LEQUAL,ti.ReadWrite,[0,1]),f=ai.disabled,m=e.colorModeForRenderPass(),_=e.useProgram("sky"),g=_s(l,s);_.draw(l,c.TRIANGLES,p,f,m,ei.disabled,d,null,void 0,"sky",g.vertexBuffer,g.indexBuffer,g.segments)}(this,this.style.sky),this._showOverdrawInspector=s.showOverdrawInspector,this.depthRangeFor3D=[0,1-(e._order.length+2)*this.numSublayers*this.depthEpsilon],!this.renderToTexture)for(this.renderPass="opaque",this.currentLayer=p.length-1;this.currentLayer>=0;this.currentLayer--){const e=this.style._layers[p[this.currentLayer]],s=f[e.source],l=m[e.source];this._renderTileClippingMasks(e,l,!1),this.renderLayer(this,s,e,l,b)}this.renderPass="translucent";let T=!1;for(this.currentLayer=0;this.currentLayer({u_sun_pos:e,u_atmosphere_blend:s,u_globe_position:l,u_globe_radius:c,u_inv_proj_matrix:d}))(g,b,[S[0],S[1],S[2]],T,P),C=_s(d,s);f.draw(d,p.TRIANGLES,m,ai.disabled,Qt.alphaBlended,ei.disabled,I,null,null,"atmosphere",C.vertexBuffer,C.indexBuffer,C.segments)}(this,this.style.sky,this.style.light),this.options.showTileBoundaries){const e=function(e,s){let l=null;const c=Object.values(e._layers).flatMap((l=>l.source&&!l.isHidden(s)?[e.tileManagers[l.source]]:[])),d=c.filter((e=>"vector"===e.getSource().type)),p=c.filter((e=>"vector"!==e.getSource().type)),f=e=>{(!l||l.getSource().maxzoomf(e))),l||p.forEach((e=>f(e))),l}(this.style,this.transform.zoom);e&&function(e,s,l){for(let c=0;cb.getElevation(p,e,s):null;Cn(f,T,P,g,y,C,s,S,R,l.aO(y,e,m,_),p.toUnwrapped(),c)}}}(d,e,c,s,c.layout.get("text-rotation-alignment"),c.layout.get("text-pitch-alignment"),c.paint.get("text-translate"),c.paint.get("text-translate-anchor"),p),0!==c.paint.get("icon-opacity").constantOr(1)&&Dn(e,s,c,d,!1,c.paint.get("icon-translate"),c.paint.get("icon-translate-anchor"),c.layout.get("icon-rotation-alignment"),c.layout.get("icon-pitch-alignment"),c.layout.get("icon-keep-upright"),_,g,m),0!==c.paint.get("text-opacity").constantOr(1)&&Dn(e,s,c,d,!0,c.paint.get("text-translate"),c.paint.get("text-translate-anchor"),c.layout.get("text-rotation-alignment"),c.layout.get("text-pitch-alignment"),c.layout.get("text-keep-upright"),_,g,m),s.map.showCollisionBoxes&&(Pn(e,s,c,d,!0),Pn(e,s,c,d,!1))}(e,s,c,d,this.style.placement.variableOffsets,p):l.cn(c)?function(e,s,c,d,p){if("translucent"!==e.renderPass)return;const{isRenderingToTexture:f}=p,m=c.paint.get("circle-opacity"),_=c.paint.get("circle-stroke-width"),g=c.paint.get("circle-stroke-opacity"),y=!c.layout.get("circle-sort-key").isConstant();if(0===m.constantOr(1)&&(0===_.constantOr(1)||0===g.constantOr(1)))return;const b=e.context,T=b.gl,P=e.transform,S=e.getDepthModeForSublayer(0,ti.ReadOnly),I=ai.disabled,C=e.colorModeForRenderPass(),R=[],L=P.getCircleRadiusCorrection();for(let p=0;pe.sortKey-s.sortKey));for(const s of R){const{programConfiguration:l,program:d,layoutVertexBuffer:p,indexBuffer:f,uniformValues:m,terrainData:_,projectionData:g}=s.state;d.draw(b,T.TRIANGLES,S,I,C,ei.backCCW,m,_,g,c.id,p,f,s.segments,c.paint,e.transform.zoom,l)}}(e,s,c,d,p):l.co(c)?function(e,s,c,d,p){if(0===c.paint.get("heatmap-opacity"))return;const f=e.context,{isRenderingToTexture:m,isRenderingGlobe:_}=p;if(e.style.map.terrain){for(const l of d){const d=s.getTile(l);s.hasRenderableParent(l)||("offscreen"===e.renderPass?Rn(e,d,c,l,_):"translucent"===e.renderPass&&Ln(e,c,l,m,_))}f.viewport.set([0,0,e.width,e.height])}else"offscreen"===e.renderPass?function(e,s,c,d){const p=e.context,f=p.gl,m=e.transform,_=ai.disabled,g=new Qt([f.ONE,f.ONE],l.bp.transparent,[!0,!0,!0,!0]);(function(e,s,c){const d=e.gl;e.activeTexture.set(d.TEXTURE1),e.viewport.set([0,0,s.width/4,s.height/4]);let p=c.heatmapFbos.get(l.cd);p?(d.bindTexture(d.TEXTURE_2D,p.colorAttachment.get()),e.bindFramebuffer.set(p.framebuffer)):(p=Bn(e,s.width/4,s.height/4),c.heatmapFbos.set(l.cd,p))})(p,e,c),p.clear({color:l.bp.transparent});for(let l=0;l0?s.pop():null}isPatternMissing(e){if(!e)return!1;if(!e.from||!e.to)return!0;const s=this.imageManager.getPattern(e.from.toString()),l=this.imageManager.getPattern(e.to.toString());return!s||!l}useProgram(e,s,l=!1,c=[]){this.cache=this.cache||{};const d=!!this.style.map.terrain,p=this.style.projection,f=l?Vi.projectionMercator:p.shaderPreludeCode,m=l?Gi:p.shaderDefine,_=e+(s?s.cacheKey:"")+`/${l?Ui:p.shaderVariantName}`+(this._showOverdrawInspector?"/overdraw":"")+(d?"/terrain":"")+(c?`/${c.join("/")}`:"");return this.cache[_]||(this.cache[_]=new Zi(this.context,Vi[e],s,vn[e],this._showOverdrawInspector,d,f,m,c)),this.cache[_]}setCustomLayerDefaults(){this.context.unbindVAO(),this.context.cullFace.setDefault(),this.context.activeTexture.setDefault(),this.context.pixelStoreUnpack.setDefault(),this.context.pixelStoreUnpackPremultiplyAlpha.setDefault(),this.context.pixelStoreUnpackFlipY.setDefault()}setBaseState(){const e=this.context.gl;this.context.cullFace.set(!1),this.context.viewport.set([0,0,this.width,this.height]),this.context.blendEquation.set(e.FUNC_ADD)}initDebugOverlayCanvas(){null==this.debugOverlayCanvas&&(this.debugOverlayCanvas=document.createElement("canvas"),this.debugOverlayCanvas.width=512,this.debugOverlayCanvas.height=512,this.debugOverlayTexture=new l.T(this.context,this.debugOverlayCanvas,this.context.gl.RGBA))}destroy(){var e,s;if(this._tileTextures){for(const e in this._tileTextures){const s=this._tileTextures[e];if(s)for(const e of s)e.destroy()}this._tileTextures={}}if(this.tileExtentBuffer&&this.tileExtentBuffer.destroy(),this.debugBuffer&&this.debugBuffer.destroy(),this.rasterBoundsBuffer&&this.rasterBoundsBuffer.destroy(),this.rasterBoundsBufferPosOnly&&this.rasterBoundsBufferPosOnly.destroy(),this.viewportBuffer&&this.viewportBuffer.destroy(),this.tileBorderIndexBuffer&&this.tileBorderIndexBuffer.destroy(),this.quadTriangleIndexBuffer&&this.quadTriangleIndexBuffer.destroy(),this.tileExtentMesh&&(null===(e=this.tileExtentMesh.vertexBuffer)||void 0===e||e.destroy()),this.tileExtentMesh&&(null===(s=this.tileExtentMesh.indexBuffer)||void 0===s||s.destroy()),this.debugOverlayTexture&&this.debugOverlayTexture.destroy(),this.cache){for(const e in this.cache){const s=this.cache[e];s&&s.program&&this.context.gl.deleteProgram(s.program)}this.cache={}}this.context&&this.context.setDefault()}overLimit(){const{drawingBufferWidth:e,drawingBufferHeight:s}=this.context.gl;return this.width!==e||this.height!==s}}function gs(s,l){let c,d=!1,p=null,f=null;const m=()=>{p=null,d&&(s.apply(f,c),p=setTimeout(m,l),d=!1)};return(...s)=>(d=!0,f=this||e,c=s,p||m(),p)}class $r{constructor(e){this._getCurrentHash=()=>{const e=window.location.hash.replace("#","");if(this._hashName){let s;return e.split("&").map((e=>e.split("="))).forEach((e=>{e[0]===this._hashName&&(s=e)})),(s&&s[1]||"").split("/")}return e.split("/")},this._onHashChange=()=>{const e=this._getCurrentHash();if(!this._isValidHash(e))return!1;const s=this._map.dragRotate.isEnabled()&&this._map.touchZoomRotate.isEnabled()?+(e[3]||0):this._map.getBearing();return this._map.jumpTo({center:[+e[2],+e[1]],zoom:+e[0],bearing:s,pitch:+(e[4]||0)}),!0},this._updateHashUnthrottled=()=>{const e=window.location.href.replace(/(#.*)?$/,this.getHashString());window.history.replaceState(window.history.state,null,e)},this._removeHash=()=>{const e=this._getCurrentHash();if(0===e.length)return;const s=e.join("/");let l=s;l.split("&").length>0&&(l=l.split("&")[0]),this._hashName&&(l=`${this._hashName}=${s}`);let c=window.location.hash.replace(l,"");c.startsWith("#&")?c=c.slice(0,1)+c.slice(2):"#"===c&&(c="");let d=window.location.href.replace(/(#.+)?$/,c);d=d.replace("&&","&"),window.history.replaceState(window.history.state,null,d)},this._updateHash=gs(this._updateHashUnthrottled,300),this._hashName=e&&encodeURIComponent(e)}addTo(e){return this._map=e,addEventListener("hashchange",this._onHashChange,!1),this._map.on("moveend",this._updateHash),this}remove(){return removeEventListener("hashchange",this._onHashChange,!1),this._map.off("moveend",this._updateHash),clearTimeout(this._updateHash()),this._removeHash(),delete this._map,this}getHashString(e){const s=this._map.getCenter(),l=Math.round(100*this._map.getZoom())/100,c=Math.ceil((l*Math.LN2+Math.log(512/360/.5))/Math.LN10),d=Math.pow(10,c),p=Math.round(s.lng*d)/d,f=Math.round(s.lat*d)/d,m=this._map.getBearing(),_=this._map.getPitch();let g="";if(g+=e?`/${p}/${f}/${l}`:`${l}/${f}/${p}`,(m||_)&&(g+="/"+Math.round(10*m)/10),_&&(g+=`/${Math.round(_)}`),this._hashName){const e=this._hashName;let s=!1;const l=window.location.hash.slice(1).split("&").map((l=>{const c=l.split("=")[0];return c===e?(s=!0,`${c}=${g}`):l})).filter((e=>e));return s||l.push(`${e}=${g}`),`#${l.join("&")}`}return`#${g}`}_isValidHash(e){if(e.length<3||e.some(isNaN))return!1;try{new l.V(+e[2],+e[1])}catch(e){return!1}const s=+e[0],c=+(e[3]||0),d=+(e[4]||0);return s>=this._map.getMinZoom()&&s<=this._map.getMaxZoom()&&c>=-180&&c<=180&&d>=this._map.getMinPitch()&&d<=this._map.getMaxPitch()}}const ys={linearity:.3,easing:l.cw(0,0,.3,1)},vs=l.e({deceleration:2500,maxSpeed:1400},ys),bs=l.e({deceleration:20,maxSpeed:1400},ys),ws=l.e({deceleration:1e3,maxSpeed:360},ys),Ts=l.e({deceleration:1e3,maxSpeed:90},ys),Ss=l.e({deceleration:1e3,maxSpeed:360},ys);class eo{constructor(e){this._map=e,this.clear()}clear(){this._inertiaBuffer=[]}record(e){this._drainInertiaBuffer(),this._inertiaBuffer.push({time:y(),settings:e})}_drainInertiaBuffer(){const e=this._inertiaBuffer,s=y();for(;e.length>0&&s-e[0].time>160;)e.shift()}_onMoveEnd(e){if(this._drainInertiaBuffer(),this._inertiaBuffer.length<2)return;const s={zoom:0,bearing:0,pitch:0,roll:0,pan:new l.P(0,0),pinchAround:void 0,around:void 0};for(const{settings:e}of this._inertiaBuffer)s.zoom+=e.zoomDelta||0,s.bearing+=e.bearingDelta||0,s.pitch+=e.pitchDelta||0,s.roll+=e.rollDelta||0,e.panDelta&&s.pan._add(e.panDelta),e.around&&(s.around=e.around),e.pinchAround&&(s.pinchAround=e.pinchAround);const c=this._inertiaBuffer[this._inertiaBuffer.length-1].time-this._inertiaBuffer[0].time,d={};if(s.pan.mag()){const p=Is(s.pan.mag(),c,l.e({},vs,e||{})),f=s.pan.mult(p.amount/s.pan.mag()),m=this._map.cameraHelper.handlePanInertia(f,this._map.transform);d.center=m.easingCenter,d.offset=m.easingOffset,Ms(d,p)}if(s.zoom){const e=Is(s.zoom,c,bs);d.zoom=this._map.transform.zoom+e.amount,Ms(d,e)}if(s.bearing){const e=Is(s.bearing,c,ws);d.bearing=this._map.transform.bearing+l.an(e.amount,-179,179),Ms(d,e)}if(s.pitch){const e=Is(s.pitch,c,Ts);d.pitch=this._map.transform.pitch+e.amount,Ms(d,e)}if(s.roll){const e=Is(s.roll,c,Ss);d.roll=this._map.transform.roll+l.an(e.amount,-179,179),Ms(d,e)}if(d.zoom||d.bearing){const e=void 0===s.pinchAround?s.around:s.pinchAround;d.around=e?this._map.unproject(e):this._map.getCenter()}return this.clear(),l.e(d,{noMoveStart:!0})}}function Ms(e,s){(!e.duration||e.durations.unproject(e))),m=p.reduce(((e,s,l,c)=>e.add(s.div(c.length))),new l.P(0,0));super(e,{points:p,point:m,lngLats:f,lngLat:s.unproject(m),originalEvent:c}),this._defaultPrevented=!1}}class oo extends l.l{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(e,s,l){super(e,{originalEvent:l}),this._defaultPrevented=!1}}class so{constructor(e,s){this._map=e,this._clickTolerance=s.clickTolerance}reset(){delete this._mousedownPos}wheel(e){return this._firePreventable(new oo(e.type,this._map,e))}mousedown(e,s){return this._mousedownPos=s,this._firePreventable(new ao(e.type,this._map,e))}mouseup(e){this._map.fire(new ao(e.type,this._map,e))}click(e,s){this._mousedownPos&&this._mousedownPos.dist(s)>=this._clickTolerance||this._map.fire(new ao(e.type,this._map,e))}dblclick(e){return this._firePreventable(new ao(e.type,this._map,e))}mouseover(e){this._map.fire(new ao(e.type,this._map,e))}mouseout(e){this._map.fire(new ao(e.type,this._map,e))}touchstart(e){return this._firePreventable(new ro(e.type,this._map,e))}touchmove(e){this._map.fire(new ro(e.type,this._map,e))}touchend(e){this._map.fire(new ro(e.type,this._map,e))}touchcancel(e){this._map.fire(new ro(e.type,this._map,e))}_firePreventable(e){if(this._map.fire(e),e.defaultPrevented)return{}}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}}class no{constructor(e){this._map=e}reset(){this._delayContextMenu=!1,this._ignoreContextMenu=!0,delete this._contextMenuEvent}mousemove(e){this._map.fire(new ao(e.type,this._map,e))}mousedown(){this._delayContextMenu=!0,this._ignoreContextMenu=!1}mouseup(){this._delayContextMenu=!1,this._contextMenuEvent&&(this._map.fire(new ao("contextmenu",this._map,this._contextMenuEvent)),delete this._contextMenuEvent)}contextmenu(e){this._delayContextMenu?this._contextMenuEvent=e:this._ignoreContextMenu||this._map.fire(new ao(e.type,this._map,e)),this._map.listens("contextmenu")&&e.preventDefault()}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}}class lo{constructor(e){this._map=e}get transform(){return this._map._requestedCameraState||this._map.transform}get center(){return{lng:this.transform.center.lng,lat:this.transform.center.lat}}get zoom(){return this.transform.zoom}get pitch(){return this.transform.pitch}get bearing(){return this.transform.bearing}unproject(e){return this.transform.screenPointToLocation(l.P.convert(e),this._map.terrain)}}class co{constructor(e,s){this._map=e,this._tr=new lo(e),this._el=e.getCanvasContainer(),this._container=e.getContainer(),this._clickTolerance=s.clickTolerance||1}isEnabled(){return!!this._enabled}isActive(){return!!this._active}enable(){this.isEnabled()||(this._enabled=!0)}disable(){this.isEnabled()&&(this._enabled=!1)}mousedown(e,s){this.isEnabled()&&e.shiftKey&&0===e.button&&(h.disableDrag(),this._startPos=this._lastPos=s,this._active=!0)}mousemoveWindow(e,s){if(!this._active)return;const l=s;if(this._lastPos.equals(l)||!this._box&&l.dist(this._startPos)e.fitScreenCoordinates(c,d,this._tr.bearing,{linear:!0})};this._fireEvent("boxzoomcancel",e)}keydown(e){this._active&&27===e.keyCode&&(this.reset(),this._fireEvent("boxzoomcancel",e))}reset(){this._active=!1,this._container.classList.remove("maplibregl-crosshair"),this._box&&(h.remove(this._box),this._box=null),h.enableDrag(),delete this._startPos,delete this._lastPos}_fireEvent(e,s){return this._map.fire(new l.l(e,{originalEvent:s}))}}function Es(e,s){if(e.length!==s.length)throw new Error(`The number of touches and points are not equal - touches ${e.length}, points ${s.length}`);const l={};for(let c=0;cthis.numTouches)&&(this.aborted=!0),this.aborted||(void 0===this.startTime&&(this.startTime=e.timeStamp),c.length===this.numTouches&&(this.centroid=function(e){const s=new l.P(0,0);for(const l of e)s._add(l);return s.div(e.length)}(s),this.touches=Es(c,s)))}touchmove(e,s,l){if(this.aborted||!this.centroid)return;const c=Es(l,s);for(const e in this.touches){const s=c[e];(!s||s.dist(this.touches[e])>30)&&(this.aborted=!0)}}touchend(e,s,l){if((!this.centroid||e.timeStamp-this.startTime>500)&&(this.aborted=!0),0===l.length){const e=!this.aborted&&this.centroid;if(this.reset(),e)return e}}}class _o{constructor(e){this.singleTap=new uo(e),this.numTaps=e.numTaps,this.reset()}reset(){this.lastTime=1/0,delete this.lastTap,this.count=0,this.singleTap.reset()}touchstart(e,s,l){this.singleTap.touchstart(e,s,l)}touchmove(e,s,l){this.singleTap.touchmove(e,s,l)}touchend(e,s,l){const c=this.singleTap.touchend(e,s,l);if(c){const s=e.timeStamp-this.lastTime<500,l=!this.lastTap||this.lastTap.dist(c)<30;if(s&&l||this.reset(),this.count++,this.lastTime=e.timeStamp,this.lastTap=c,this.count===this.numTaps)return this.reset(),c}}}class po{constructor(e){this._tr=new lo(e),this._zoomIn=new _o({numTouches:1,numTaps:2}),this._zoomOut=new _o({numTouches:2,numTaps:1}),this.reset()}reset(){this._active=!1,this._zoomIn.reset(),this._zoomOut.reset()}touchstart(e,s,l){this._zoomIn.touchstart(e,s,l),this._zoomOut.touchstart(e,s,l)}touchmove(e,s,l){this._zoomIn.touchmove(e,s,l),this._zoomOut.touchmove(e,s,l)}touchend(e,s,l){const c=this._zoomIn.touchend(e,s,l),d=this._zoomOut.touchend(e,s,l),p=this._tr;return c?(this._active=!0,e.preventDefault(),setTimeout((()=>this.reset()),0),{cameraAnimation:s=>s.easeTo({duration:300,zoom:p.zoom+1,around:p.unproject(c)},{originalEvent:e})}):d?(this._active=!0,e.preventDefault(),setTimeout((()=>this.reset()),0),{cameraAnimation:s=>s.easeTo({duration:300,zoom:p.zoom-1,around:p.unproject(d)},{originalEvent:e})}):void 0}touchcancel(){this.reset()}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class mo{constructor(e){this._enabled=!!e.enable,this._moveStateManager=e.moveStateManager,this._clickTolerance=e.clickTolerance||1,this._moveFunction=e.move,this._activateOnStart=!!e.activateOnStart,e.assignEvents(this),this.reset()}reset(e){this._active=!1,this._moved=!1,delete this._lastPoint,this._moveStateManager.endMove(e)}_move(...e){const s=this._moveFunction(...e);if(s.bearingDelta||s.pitchDelta||s.rollDelta||s.around||s.panDelta)return this._active=!0,s}dragStart(e,s){this.isEnabled()&&!this._lastPoint&&this._moveStateManager.isValidStartEvent(e)&&(this._moveStateManager.startMove(e),this._lastPoint=Array.isArray(s)?s[0]:s,this._activateOnStart&&this._lastPoint&&(this._active=!0))}dragMove(e,s){if(!this.isEnabled())return;const l=this._lastPoint;if(!l)return;if(e.preventDefault(),!this._moveStateManager.isValidMoveEvent(e))return void this.reset(e);const c=Array.isArray(s)?s[0]:s;return!this._moved&&c.dist(l)!0}),s=new bo){this.mouseMoveStateManager=e,this.oneFingerTouchMoveStateManager=s}_executeRelevantHandler(e,s,l){return e instanceof MouseEvent?s(e):"undefined"!=typeof TouchEvent&&e instanceof TouchEvent?l(e):void 0}startMove(e){this._executeRelevantHandler(e,(e=>this.mouseMoveStateManager.startMove(e)),(e=>this.oneFingerTouchMoveStateManager.startMove(e)))}endMove(e){this._executeRelevantHandler(e,(e=>this.mouseMoveStateManager.endMove(e)),(e=>this.oneFingerTouchMoveStateManager.endMove(e)))}isValidStartEvent(e){return this._executeRelevantHandler(e,(e=>this.mouseMoveStateManager.isValidStartEvent(e)),(e=>this.oneFingerTouchMoveStateManager.isValidStartEvent(e)))}isValidMoveEvent(e){return this._executeRelevantHandler(e,(e=>this.mouseMoveStateManager.isValidMoveEvent(e)),(e=>this.oneFingerTouchMoveStateManager.isValidMoveEvent(e)))}isValidEndEvent(e){return this._executeRelevantHandler(e,(e=>this.mouseMoveStateManager.isValidEndEvent(e)),(e=>this.oneFingerTouchMoveStateManager.isValidEndEvent(e)))}}const ks=e=>{e.mousedown=e.dragStart,e.mousemoveWindow=e.dragMove,e.mouseup=e.dragEnd,e.contextmenu=e=>{e.preventDefault()}};class To{constructor(e,s){this._clickTolerance=e.clickTolerance||1,this._map=s,this.reset()}reset(){this._active=!1,this._touches={},this._sum=new l.P(0,0)}_shouldBePrevented(e){return e<(this._map.cooperativeGestures.isEnabled()?2:1)}touchstart(e,s,l){return this._calculateTransform(e,s,l)}touchmove(e,s,l){if(this._active){if(!this._shouldBePrevented(l.length))return e.preventDefault(),this._calculateTransform(e,s,l);this._map.cooperativeGestures.notifyGestureBlocked("touch_pan",e)}}touchend(e,s,l){this._calculateTransform(e,s,l),this._active&&this._shouldBePrevented(l.length)&&this.reset()}touchcancel(){this.reset()}_calculateTransform(e,s,c){c.length>0&&(this._active=!0);const d=Es(c,s),p=new l.P(0,0),f=new l.P(0,0);let m=0;for(const e in d){const s=d[e],l=this._touches[e];l&&(p._add(s),f._add(s.sub(l)),m++,d[e]=s)}if(this._touches=d,this._shouldBePrevented(m)||!f.mag())return;const _=f.div(m);return this._sum._add(_),this._sum.mag()Math.abs(e.x)}class Ro extends Po{constructor(e){super(),this._currentTouchCount=0,this._map=e}reset(){super.reset(),this._valid=void 0,delete this._firstMove,delete this._lastPoints}touchstart(e,s,l){super.touchstart(e,s,l),this._currentTouchCount=l.length}_start(e){this._lastPoints=e,Ws(e[0].sub(e[1]))&&(this._valid=!1)}_move(e,s,l){if(this._map.cooperativeGestures.isEnabled()&&this._currentTouchCount<3)return;const c=e[0].sub(this._lastPoints[0]),d=e[1].sub(this._lastPoints[1]);return this._valid=this.gestureBeginsVertically(c,d,l.timeStamp),this._valid?(this._lastPoints=e,this._active=!0,{pitchDelta:(c.y+d.y)/2*-.5}):void 0}gestureBeginsVertically(e,s,l){if(void 0!==this._valid)return this._valid;const c=e.mag()>=2,d=s.mag()>=2;if(!c&&!d)return;if(!c||!d)return void 0===this._firstMove&&(this._firstMove=l),l-this._firstMove<100&&void 0;const p=e.y>0==s.y>0;return Ws(e)&&Ws(s)&&p}}const Js={panStep:100,bearingStep:15,pitchStep:10};class Ao{constructor(e){this._tr=new lo(e);const s=Js;this._panStep=s.panStep,this._bearingStep=s.bearingStep,this._pitchStep=s.pitchStep,this._rotationDisabled=!1}reset(){this._active=!1}keydown(e){if(e.altKey||e.ctrlKey||e.metaKey)return;let s=0,l=0,c=0,d=0,p=0;switch(e.keyCode){case 61:case 107:case 171:case 187:s=1;break;case 189:case 109:case 173:s=-1;break;case 37:e.shiftKey?l=-1:(e.preventDefault(),d=-1);break;case 39:e.shiftKey?l=1:(e.preventDefault(),d=1);break;case 38:e.shiftKey?c=1:(e.preventDefault(),p=-1);break;case 40:e.shiftKey?c=-1:(e.preventDefault(),p=1);break;default:return}return this._rotationDisabled&&(l=0,c=0),{cameraAnimation:f=>{const m=this._tr;f.easeTo({duration:300,easeId:"keyboardHandler",easing:ho,zoom:s?Math.round(m.zoom)+s*(e.shiftKey?2:1):m.zoom,bearing:m.bearing+l*this._bearingStep,pitch:m.pitch+c*this._pitchStep,offset:[-d*this._panStep,-p*this._panStep],center:m.center},{originalEvent:e})}}}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}disableRotation(){this._rotationDisabled=!0}enableRotation(){this._rotationDisabled=!1}}function ho(e){return e*(2-e)}const fo=4.000244140625,vo=1/450;class Bo{constructor(e,s){this._onTimeout=e=>{this._type="wheel",this._delta-=this._lastValue,this._active||this._start(e)},this._map=e,this._tr=new lo(e),this._triggerRenderFrame=s,this._delta=0,this._defaultZoomRate=.01,this._wheelZoomRate=vo}setZoomRate(e){this._defaultZoomRate=e}setWheelZoomRate(e){this._wheelZoomRate=e}isEnabled(){return!!this._enabled}isActive(){return!!this._active||void 0!==this._finishTimeout}isZooming(){return!!this._zooming}enable(e){this.isEnabled()||(this._enabled=!0,this._aroundCenter=!!e&&"center"===e.around)}disable(){this.isEnabled()&&(this._enabled=!1)}_shouldBePrevented(e){return!!this._map.cooperativeGestures.isEnabled()&&!(e.ctrlKey||this._map.cooperativeGestures.isBypassed(e))}wheel(e){if(!this.isEnabled())return;if(this._shouldBePrevented(e))return void this._map.cooperativeGestures.notifyGestureBlocked("wheel_zoom",e);let s=e.deltaMode===WheelEvent.DOM_DELTA_LINE?40*e.deltaY:e.deltaY;const l=y(),c=l-(this._lastWheelEventTime||0);this._lastWheelEventTime=l,0!==s&&s%fo==0?this._type="wheel":0!==s&&Math.abs(s)<4?this._type="trackpad":c>400?(this._type=null,this._lastValue=s,this._timeout=setTimeout(this._onTimeout,40,e)):this._type||(this._type=Math.abs(c*s)<200?"trackpad":"wheel",this._timeout&&(clearTimeout(this._timeout),this._timeout=null,s+=this._lastValue)),e.shiftKey&&s&&(s/=4),this._type&&(this._lastWheelEvent=e,this._delta-=s,this._active||this._start(e)),e.preventDefault()}_start(e){if(!this._delta)return;this._frameId&&(this._frameId=null),this._active=!0,this.isZooming()||(this._zooming=!0),this._finishTimeout&&(clearTimeout(this._finishTimeout),delete this._finishTimeout);const s=h.mousePos(this._map.getCanvas(),e),c=this._tr;this._aroundPoint=this._aroundCenter?c.transform.locationToScreenPoint(l.V.convert(c.center)):s,this._frameId||(this._frameId=!0,this._triggerRenderFrame())}renderFrame(){if(!this._frameId)return;if(this._frameId=null,!this.isActive())return;const e=this._tr.transform;if("number"==typeof this._lastExpectedZoom){const s=e.zoom-this._lastExpectedZoom;"number"==typeof this._startZoom&&(this._startZoom+=s),"number"==typeof this._targetZoom&&(this._targetZoom+=s)}if(0!==this._delta){const s="wheel"===this._type&&Math.abs(this._delta)>fo?this._wheelZoomRate:this._defaultZoomRate;let c=2/(1+Math.exp(-Math.abs(this._delta*s)));this._delta<0&&0!==c&&(c=1/c);const d="number"!=typeof this._targetZoom?e.scale:l.aq(this._targetZoom);this._targetZoom=e.applyConstrain(e.getCameraLngLat(),l.at(d*c)).zoom,"wheel"===this._type&&(this._startZoom=e.zoom,this._easing=this._smoothOutEasing(200)),this._delta=0}const s="number"!=typeof this._targetZoom?e.zoom:this._targetZoom,c=this._startZoom,d=this._easing;let p,f=!1;if("wheel"===this._type&&c&&d){const e=y()-this._lastWheelEventTime,m=Math.min((e+5)/200,1),_=d(m);p=l.G.number(c,s,_),m<1?this._frameId||(this._frameId=!0):f=!0}else p=s,f=!0;return this._active=!0,f&&(this._active=!1,this._finishTimeout=setTimeout((()=>{this._zooming=!1,this._triggerRenderFrame(),delete this._targetZoom,delete this._lastExpectedZoom,delete this._finishTimeout}),200)),this._lastExpectedZoom=p,{noInertia:!0,needsRenderFrame:!f,zoomDelta:p-e.zoom,around:this._aroundPoint,originalEvent:this._lastWheelEvent}}_smoothOutEasing(e){let s=l.cy;if(this._prevEase){const e=this._prevEase,c=(y()-e.start)/e.duration,d=e.easing(c+.01)-e.easing(c),p=.27/Math.sqrt(d*d+1e-4)*.01,f=Math.sqrt(.0729-p*p);s=l.cw(p,f,.25,1)}return this._prevEase={start:y(),duration:e,easing:s},s}reset(){this._active=!1,this._zooming=!1,delete this._targetZoom,delete this._lastExpectedZoom,this._finishTimeout&&(clearTimeout(this._finishTimeout),delete this._finishTimeout)}}class Oo{constructor(e,s){this._clickZoom=e,this._tapZoom=s}enable(){this._clickZoom.enable(),this._tapZoom.enable()}disable(){this._clickZoom.disable(),this._tapZoom.disable()}isEnabled(){return this._clickZoom.isEnabled()&&this._tapZoom.isEnabled()}isActive(){return this._clickZoom.isActive()||this._tapZoom.isActive()}}class jo{constructor(e){this._tr=new lo(e),this.reset()}reset(){this._active=!1}dblclick(e,s){return e.preventDefault(),{cameraAnimation:l=>{l.easeTo({duration:300,zoom:this._tr.zoom+(e.shiftKey?-1:1),around:this._tr.unproject(s)},{originalEvent:e})}}}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class No{constructor(){this._tap=new _o({numTouches:1,numTaps:1}),this.reset()}reset(){this._active=!1,delete this._swipePoint,delete this._swipeTouch,delete this._tapTime,delete this._tapPoint,this._tap.reset()}touchstart(e,s,l){if(!this._swipePoint)if(this._tapTime){const c=s[0],d=e.timeStamp-this._tapTime<500,p=this._tapPoint.dist(c)<30;d&&p?l.length>0&&(this._swipePoint=c,this._swipeTouch=l[0].identifier):this.reset()}else this._tap.touchstart(e,s,l)}touchmove(e,s,l){if(this._tapTime){if(this._swipePoint){if(l[0].identifier!==this._swipeTouch)return;const c=s[0],d=c.y-this._swipePoint.y;return this._swipePoint=c,e.preventDefault(),this._active=!0,{zoomDelta:d/128}}}else this._tap.touchmove(e,s,l)}touchend(e,s,l){if(this._tapTime)this._swipePoint&&0===l.length&&this.reset();else{const c=this._tap.touchend(e,s,l);c&&(this._tapTime=e.timeStamp,this._tapPoint=c)}}touchcancel(){this.reset()}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class Zo{constructor(e,s,l){this._el=e,this._mousePan=s,this._touchPan=l}enable(e){this._inertiaOptions=e||{},this._mousePan.enable(),this._touchPan.enable(),this._el.classList.add("maplibregl-touch-drag-pan")}disable(){this._mousePan.disable(),this._touchPan.disable(),this._el.classList.remove("maplibregl-touch-drag-pan")}isEnabled(){return this._mousePan.isEnabled()&&this._touchPan.isEnabled()}isActive(){return this._mousePan.isActive()||this._touchPan.isActive()}}class Go{constructor(e,s,l,c){this._pitchWithRotate=e.pitchWithRotate,this._rollEnabled=e.rollEnabled,this._mouseRotate=s,this._mousePitch=l,this._mouseRoll=c}enable(){this._mouseRotate.enable(),this._pitchWithRotate&&this._mousePitch.enable(),this._rollEnabled&&this._mouseRoll.enable()}disable(){this._mouseRotate.disable(),this._mousePitch.disable(),this._mouseRoll.disable()}isEnabled(){return this._mouseRotate.isEnabled()&&(!this._pitchWithRotate||this._mousePitch.isEnabled())&&(!this._rollEnabled||this._mouseRoll.isEnabled())}isActive(){return this._mouseRotate.isActive()||this._mousePitch.isActive()||this._mouseRoll.isActive()}}class Uo{constructor(e,s,l,c){this._el=e,this._touchZoom=s,this._touchRotate=l,this._tapDragZoom=c,this._rotationDisabled=!1,this._enabled=!0}enable(e){this._touchZoom.enable(e),this._rotationDisabled||this._touchRotate.enable(e),this._tapDragZoom.enable(),this._el.classList.add("maplibregl-touch-zoom-rotate")}disable(){this._touchZoom.disable(),this._touchRotate.disable(),this._tapDragZoom.disable(),this._el.classList.remove("maplibregl-touch-zoom-rotate")}isEnabled(){return this._touchZoom.isEnabled()&&(this._rotationDisabled||this._touchRotate.isEnabled())&&this._tapDragZoom.isEnabled()}isActive(){return this._touchZoom.isActive()||this._touchRotate.isActive()||this._tapDragZoom.isActive()}disableRotation(){this._rotationDisabled=!0,this._touchRotate.disable()}enableRotation(){this._rotationDisabled=!1,this._touchZoom.isEnabled()&&this._touchRotate.enable()}}class Vo{constructor(e,s){this._bypassKey=-1!==navigator.userAgent.indexOf("Mac")?"metaKey":"ctrlKey",this._map=e,this._options=s,this._enabled=!1}isActive(){return!1}reset(){}_setupUI(){if(this._container)return;const e=this._map.getCanvasContainer();e.classList.add("maplibregl-cooperative-gestures"),this._container=h.create("div","maplibregl-cooperative-gesture-screen",e);let s=this._map._getUIString("CooperativeGesturesHandler.WindowsHelpText");"metaKey"===this._bypassKey&&(s=this._map._getUIString("CooperativeGesturesHandler.MacHelpText"));const l=this._map._getUIString("CooperativeGesturesHandler.MobileHelpText"),c=document.createElement("div");c.className="maplibregl-desktop-message",c.textContent=s,this._container.appendChild(c);const d=document.createElement("div");d.className="maplibregl-mobile-message",d.textContent=l,this._container.appendChild(d),this._container.setAttribute("aria-hidden","true")}_destroyUI(){this._container&&(h.remove(this._container),this._map.getCanvasContainer().classList.remove("maplibregl-cooperative-gestures")),delete this._container}enable(){this._setupUI(),this._enabled=!0}disable(){this._enabled=!1,this._destroyUI()}isEnabled(){return this._enabled}isBypassed(e){return e[this._bypassKey]}notifyGestureBlocked(e,s){this._enabled&&(this._map.fire(new l.l("cooperativegestureprevented",{gestureType:e,originalEvent:s})),this._container.classList.add("maplibregl-show"),setTimeout((()=>{this._container.classList.remove("maplibregl-show")}),100))}}const Eo=e=>e.zoom||e.drag||e.roll||e.pitch||e.rotate;class Wo extends l.l{}function Co(e){return e.panDelta&&e.panDelta.mag()||e.zoomDelta||e.bearingDelta||e.pitchDelta||e.rollDelta}class Ho{constructor(e,s){this.handleWindowEvent=e=>{this.handleEvent(e,`${e.type}Window`)},this.handleEvent=(e,s)=>{if("blur"===e.type)return void this.stop(!0);this._updatingCamera=!0;const c="renderFrame"===e.type?void 0:e,d={needsRenderFrame:!1},p={},f={};for(const{handlerName:m,handler:_,allowed:g}of this._handlers){if(!_.isEnabled())continue;let y;if(this._blockedByActive(f,g,m))_.reset();else if(_[s||e.type]){if(l.cz(e,s||e.type)){const l=h.mousePos(this._map.getCanvas(),e);y=_[s||e.type](e,l)}else if(l.cA(e,s||e.type)){const l=this._getMapTouches(e.touches),c=h.touchPos(this._map.getCanvas(),l);y=_[s||e.type](e,c,l)}else l.cB(s||e.type)||(y=_[s||e.type](e));this.mergeHandlerResult(d,p,y,m,c),y&&y.needsRenderFrame&&this._triggerRenderFrame()}(y||_.isActive())&&(f[m]=_)}const m={};for(const e in this._previousActiveHandlers)f[e]||(m[e]=c);this._previousActiveHandlers=f,(Object.keys(m).length||Co(d))&&(this._changes.push([d,p,m]),this._triggerRenderFrame()),(Object.keys(f).length||Co(d))&&this._map._stop(!0),this._updatingCamera=!1;const{cameraAnimation:_}=d;_&&(this._inertia.clear(),this._fireEvents({},{},!0),this._changes=[],_(this._map))},this._map=e,this._el=this._map.getCanvasContainer(),this._handlers=[],this._handlersById={},this._changes=[],this._inertia=new eo(e),this._bearingSnap=s.bearingSnap,this._previousActiveHandlers={},this._eventsInProgress={},this._addDefaultHandlers(s);const c=this._el;this._listeners=[[c,"touchstart",{passive:!0}],[c,"touchmove",{passive:!1}],[c,"touchend",void 0],[c,"touchcancel",void 0],[c,"mousedown",void 0],[c,"mousemove",void 0],[c,"mouseup",void 0],[document,"mousemove",{capture:!0}],[document,"mouseup",void 0],[c,"mouseover",void 0],[c,"mouseout",void 0],[c,"dblclick",void 0],[c,"click",void 0],[c,"keydown",{capture:!1}],[c,"keyup",void 0],[c,"wheel",{passive:!1}],[c,"contextmenu",void 0],[window,"blur",void 0]];for(const[e,s,l]of this._listeners)h.addEventListener(e,s,e===document?this.handleWindowEvent:this.handleEvent,l)}destroy(){for(const[e,s,l]of this._listeners)h.removeEventListener(e,s,e===document?this.handleWindowEvent:this.handleEvent,l)}_addDefaultHandlers(e){const s=this._map,c=s.getCanvasContainer();this._add("mapEvent",new so(s,e));const d=s.boxZoom=new co(s,e);this._add("boxZoom",d),e.interactive&&e.boxZoom&&d.enable();const p=s.cooperativeGestures=new Vo(s,e.cooperativeGestures);this._add("cooperativeGestures",p),e.cooperativeGestures&&p.enable();const f=new po(s),m=new jo(s);s.doubleClickZoom=new Oo(m,f),this._add("tapZoom",f),this._add("clickZoom",m),e.interactive&&e.doubleClickZoom&&s.doubleClickZoom.enable();const _=new No;this._add("tapDragZoom",_);const g=s.touchPitch=new Ro(s);this._add("touchPitch",g),e.interactive&&e.touchPitch&&s.touchPitch.enable(e.touchPitch);const y=()=>s.project(s.getCenter()),b=function({enable:e,clickTolerance:s,aroundCenter:c=!0,minPixelCenterThreshold:d=100,rotateDegreesPerPixelMoved:p=.8},f){const m=new xo({checkCorrectEvent:e=>0===h.mouseButton(e)&&e.ctrlKey||2===h.mouseButton(e)&&!e.ctrlKey});return new mo({clickTolerance:s,move:(e,s)=>{const m=f();if(c&&Math.abs(m.y-e.y)>d)return{bearingDelta:l.cx(new l.P(e.x,s.y),s,m)};let _=(s.x-e.x)*p;return c&&s.y0===h.mouseButton(e)&&e.ctrlKey||2===h.mouseButton(e)});return new mo({clickTolerance:s,move:(e,s)=>({pitchDelta:(s.y-e.y)*l}),moveStateManager:c,enable:e,assignEvents:ks})}(e),P=function({enable:e,clickTolerance:s,rollDegreesPerPixelMoved:l=.3},c){const d=new xo({checkCorrectEvent:e=>2===h.mouseButton(e)&&e.ctrlKey});return new mo({clickTolerance:s,move:(e,s)=>{const d=c();let p=(s.x-e.x)*l;return s.y0===h.mouseButton(e)&&!e.ctrlKey});return new mo({clickTolerance:s,move:(e,s)=>({around:s,panDelta:s.sub(e)}),activateOnStart:!0,moveStateManager:l,enable:e,assignEvents:ks})}(e),I=new To(e,s);s.dragPan=new Zo(c,S,I),this._add("mousePan",S),this._add("touchPan",I,["touchZoom","touchRotate"]),e.interactive&&e.dragPan&&s.dragPan.enable(e.dragPan);const C=new So,R=new Mo;s.touchZoomRotate=new Uo(c,R,C,_),this._add("touchRotate",C,["touchPan","touchZoom"]),this._add("touchZoom",R,["touchPan","touchRotate"]),e.interactive&&e.touchZoomRotate&&s.touchZoomRotate.enable(e.touchZoomRotate),this._add("blockableMapEvent",new no(s));const L=s.scrollZoom=new Bo(s,(()=>this._triggerRenderFrame()));this._add("scrollZoom",L,["mousePan"]),e.interactive&&e.scrollZoom&&s.scrollZoom.enable(e.scrollZoom);const F=s.keyboard=new Ao(s);this._add("keyboard",F),e.interactive&&e.keyboard&&s.keyboard.enable()}_add(e,s,l){this._handlers.push({handlerName:e,handler:s,allowed:l}),this._handlersById[e]=s}stop(e){if(!this._updatingCamera){for(const{handler:e}of this._handlers)e.reset();this._inertia.clear(),this._fireEvents({},{},e),this._changes=[]}}isActive(){for(const{handler:e}of this._handlers)if(e.isActive())return!0;return!1}isZooming(){return!!this._eventsInProgress.zoom||this._map.scrollZoom.isZooming()}isRotating(){return!!this._eventsInProgress.rotate}isMoving(){return Boolean(Eo(this._eventsInProgress))||this.isZooming()}_blockedByActive(e,s,l){for(const c in e)if(c!==l&&(!s||s.indexOf(c)<0))return!0;return!1}_getMapTouches(e){const s=[];for(const l of e)this._el.contains(l.target)&&s.push(l);return s}mergeHandlerResult(e,s,c,d,p){if(!c)return;l.e(e,c);const f={handlerName:d,originalEvent:c.originalEvent||p};void 0!==c.zoomDelta&&(s.zoom=f),void 0!==c.panDelta&&(s.drag=f),void 0!==c.rollDelta&&(s.roll=f),void 0!==c.pitchDelta&&(s.pitch=f),void 0!==c.bearingDelta&&(s.rotate=f)}_applyChanges(){const e={},s={},c={};for(const[d,p,f]of this._changes)d.panDelta&&(e.panDelta=(e.panDelta||new l.P(0,0))._add(d.panDelta)),d.zoomDelta&&(e.zoomDelta=(e.zoomDelta||0)+d.zoomDelta),d.bearingDelta&&(e.bearingDelta=(e.bearingDelta||0)+d.bearingDelta),d.pitchDelta&&(e.pitchDelta=(e.pitchDelta||0)+d.pitchDelta),d.rollDelta&&(e.rollDelta=(e.rollDelta||0)+d.rollDelta),void 0!==d.around&&(e.around=d.around),void 0!==d.pinchAround&&(e.pinchAround=d.pinchAround),d.noInertia&&(e.noInertia=d.noInertia),l.e(s,p),l.e(c,f);this._updateMapTransform(e,s,c),this._changes=[]}_updateMapTransform(e,s,l){const c=this._map,d=c._getTransformForUpdate(),p=c.terrain;if(!(Co(e)||p&&this._terrainMovement))return this._fireEvents(s,l,!0);c._stop(!0);let{panDelta:f,zoomDelta:m,bearingDelta:_,pitchDelta:g,rollDelta:y,around:b,pinchAround:T}=e;void 0!==T&&(b=T),b=b||c.transform.centerPoint,p&&!d.isPointOnMapSurface(b)&&(b=d.centerPoint);const P={panDelta:f,zoomDelta:m,rollDelta:y,pitchDelta:g,bearingDelta:_,around:b};this._map.cameraHelper.useGlobeControls&&!d.isPointOnMapSurface(b)&&(b=d.centerPoint);const S=b.distSqr(d.centerPoint)<.01?d.center:d.screenPointToLocation(f?b.sub(f):b);this._handleMapControls({terrain:p,tr:d,deltasForHelper:P,preZoomAroundLoc:S,combinedEventsInProgress:s,panDelta:f}),c._applyUpdatedTransform(d),this._map._update(),e.noInertia||this._inertia.record(e),this._fireEvents(s,l,!0)}_handleMapControls({terrain:e,tr:s,deltasForHelper:l,preZoomAroundLoc:c,combinedEventsInProgress:d,panDelta:p}){const f=this._map.cameraHelper;if(f.handleMapControlsRollPitchBearingZoom(l,s),e)return f.useGlobeControls?(this._terrainMovement||!d.drag&&!d.zoom||(this._terrainMovement=!0,this._map._elevationFreeze=!0),void f.handleMapControlsPan(l,s,c)):this._terrainMovement||!d.drag&&!d.zoom?void(d.drag&&this._terrainMovement&&p?s.setCenter(s.screenPointToLocation(s.centerPoint.sub(p))):f.handleMapControlsPan(l,s,c)):(this._terrainMovement=!0,this._map._elevationFreeze=!0,void f.handleMapControlsPan(l,s,c));f.handleMapControlsPan(l,s,c)}_fireEvents(e,s,c){const d=Eo(this._eventsInProgress),p=Eo(e),f={};for(const s in e){const{originalEvent:l}=e[s];this._eventsInProgress[s]||(f[`${s}start`]=l),this._eventsInProgress[s]=e[s]}!d&&p&&this._fireEvent("movestart",p.originalEvent);for(const e in f)this._fireEvent(e,f[e]);p&&this._fireEvent("move",p.originalEvent);for(const s in e){const{originalEvent:l}=e[s];this._fireEvent(s,l)}const m={};let g;for(const e in this._eventsInProgress){const{handlerName:l,originalEvent:c}=this._eventsInProgress[e];this._handlersById[l].isActive()||(delete this._eventsInProgress[e],g=s[l]||c,m[`${e}end`]=g)}for(const e in m)this._fireEvent(e,m[e]);const y=Eo(this._eventsInProgress),b=(d||p)&&!y;if(b&&this._terrainMovement){this._map._elevationFreeze=!1,this._terrainMovement=!1;const e=this._map._getTransformForUpdate();this._map.getCenterClampedToGround()&&e.recalculateZoomAndCenter(this._map.terrain),this._map._applyUpdatedTransform(e)}if(c&&b){this._updatingCamera=!0;const e=this._inertia._onMoveEnd(this._map.dragPan._inertiaOptions),s=e=>0!==e&&-this._bearingSnap{delete this._frameId,this.handleEvent(new Wo("renderFrame",{timeStamp:e})),this._applyChanges()}))}_triggerRenderFrame(){void 0===this._frameId&&(this._frameId=this._requestFrame())}}class Xo extends l.E{constructor(e,s,l){super(),this._renderFrameCallback=()=>{const e=Math.min((y()-this._easeStart)/this._easeOptions.duration,1);this._onEaseFrame(this._easeOptions.easing(e)),e<1&&this._easeFrameId?this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback):this.stop()},this._moving=!1,this._zooming=!1,this.transform=e,this._bearingSnap=l.bearingSnap,this.cameraHelper=s,this.on("moveend",(()=>{delete this._requestedCameraState}))}migrateProjection(e,s){e.apply(this.transform,!0),this.transform=e,this.cameraHelper=s}getCenter(){return new l.V(this.transform.center.lng,this.transform.center.lat)}setCenter(e,s){return this.jumpTo({center:e},s)}getCenterElevation(){return this.transform.elevation}setCenterElevation(e,s){return this.jumpTo({elevation:e},s),this}getCenterClampedToGround(){return this._centerClampedToGround}setCenterClampedToGround(e){this._centerClampedToGround=e}panBy(e,s,c){return e=l.P.convert(e).mult(-1),this.panTo(this.transform.center,l.e({offset:e},s),c)}panTo(e,s,c){return this.easeTo(l.e({center:e},s),c)}getZoom(){return this.transform.zoom}setZoom(e,s){return this.jumpTo({zoom:e},s),this}zoomTo(e,s,c){return this.easeTo(l.e({zoom:e},s),c)}zoomIn(e,s){return this.zoomTo(this.getZoom()+1,e,s),this}zoomOut(e,s){return this.zoomTo(this.getZoom()-1,e,s),this}getVerticalFieldOfView(){return this.transform.fov}setVerticalFieldOfView(e,s){return e!=this.transform.fov&&(this.transform.setFov(e),this.fire(new l.l("movestart",s)).fire(new l.l("move",s)).fire(new l.l("moveend",s))),this}getBearing(){return this.transform.bearing}setBearing(e,s){return this.jumpTo({bearing:e},s),this}getPadding(){return this.transform.padding}setPadding(e,s){return this.jumpTo({padding:e},s),this}rotateTo(e,s,c){return this.easeTo(l.e({bearing:e},s),c)}resetNorth(e,s){return this.rotateTo(0,l.e({duration:1e3},e),s),this}resetNorthPitch(e,s){return this.easeTo(l.e({bearing:0,pitch:0,roll:0,duration:1e3},e),s),this}snapToNorth(e,s){return Math.abs(this.getBearing()){C.easeFunc(l),this.terrain&&!e.freezeElevation&&this._updateElevation(l),this._applyUpdatedTransform(c),this._fireMoveEvents(s)}),(l=>{this.terrain&&e.freezeElevation&&this._finalizeElevation(),this._afterEase(s,l)}),e),this}_prepareEase(e,s,c={}){this._moving=!0,s||c.moving||this.fire(new l.l("movestart",e)),this._zooming&&!c.zooming&&this.fire(new l.l("zoomstart",e)),this._rotating&&!c.rotating&&this.fire(new l.l("rotatestart",e)),this._pitching&&!c.pitching&&this.fire(new l.l("pitchstart",e)),this._rolling&&!c.rolling&&this.fire(new l.l("rollstart",e))}_prepareElevation(e){this._elevationCenter=e,this._elevationStart=this.transform.elevation,this._elevationTarget=this.terrain.getElevationForLngLatZoom(e,this.transform.tileZoom),this._elevationFreeze=!0}_updateElevation(e){void 0!==this._elevationStart&&void 0!==this._elevationCenter||this._prepareElevation(this.transform.center),this.transform.setMinElevationForCurrentTile(this.terrain.getMinTileElevationForLngLatZoom(this._elevationCenter,this.transform.tileZoom));const s=this.terrain.getElevationForLngLatZoom(this._elevationCenter,this.transform.tileZoom);if(e<1&&s!==this._elevationTarget){const l=this._elevationTarget-this._elevationStart;this._elevationStart+=e*(l-(s-(l*e+this._elevationStart))/(1-e)),this._elevationTarget=s}this.transform.setElevation(l.G.number(this._elevationStart,this._elevationTarget,e))}_finalizeElevation(){this._elevationFreeze=!1,this.getCenterClampedToGround()&&this.transform.recalculateZoomAndCenter(this.terrain)}_getTransformForUpdate(){return this.transformCameraUpdate||this.terrain?(this._requestedCameraState||(this._requestedCameraState=this.transform.clone()),this._requestedCameraState):this.transform}_elevateCameraIfInsideTerrain(e){if(!this.terrain&&e.elevation>=0&&e.pitch<=90)return{};const s=e.getCameraLngLat(),l=e.getCameraAltitude(),c=this.terrain?this.terrain.getElevationForLngLatZoom(s,e.zoom):0;if(lthis._elevateCameraIfInsideTerrain(e))),this.transformCameraUpdate&&s.push((e=>this.transformCameraUpdate(e))),!s.length)return;const l=e.clone();for(const e of s){const s=l.clone(),{center:c,zoom:d,roll:p,pitch:f,bearing:m,elevation:_}=e(s);c&&s.setCenter(c),void 0!==_&&s.setElevation(_),void 0!==d&&s.setZoom(d),void 0!==p&&s.setRoll(p),void 0!==f&&s.setPitch(f),void 0!==m&&s.setBearing(m),l.apply(s,!1)}this.transform.apply(l,!1)}_fireMoveEvents(e){this.fire(new l.l("move",e)),this._zooming&&this.fire(new l.l("zoom",e)),this._rotating&&this.fire(new l.l("rotate",e)),this._pitching&&this.fire(new l.l("pitch",e)),this._rolling&&this.fire(new l.l("roll",e))}_afterEase(e,s){if(this._easeId&&s&&this._easeId===s)return;delete this._easeId;const c=this._zooming,d=this._rotating,p=this._pitching,f=this._rolling;this._moving=!1,this._zooming=!1,this._rotating=!1,this._pitching=!1,this._rolling=!1,this._padding=!1,c&&this.fire(new l.l("zoomend",e)),d&&this.fire(new l.l("rotateend",e)),p&&this.fire(new l.l("pitchend",e)),f&&this.fire(new l.l("rollend",e)),this.fire(new l.l("moveend",e))}flyTo(e,s){if(!e.essential&&_.prefersReducedMotion){const c=l.U(e,["center","zoom","bearing","pitch","roll","elevation","padding"]);return this.jumpTo(c,s)}this.stop(),e=l.e({offset:[0,0],speed:1.2,curve:1.42,easing:l.cy},e);const c=this._getTransformForUpdate(),d=c.bearing,p=c.pitch,f=c.roll,m=c.padding,g="bearing"in e?this._normalizeBearing(e.bearing,d):d,y="pitch"in e?+e.pitch:p,b="roll"in e?this._normalizeBearing(e.roll,f):f,T="padding"in e?e.padding:c.padding,P=l.P.convert(e.offset);let S=c.centerPoint.add(P);const I=c.screenPointToLocation(S),C=this.cameraHelper.handleFlyTo(c,{bearing:g,pitch:y,roll:b,padding:T,locationAtOffset:I,offsetAsPoint:P,center:e.center,minZoom:e.minZoom,zoom:e.zoom});let R=e.curve;const L=Math.max(c.width,c.height),F=L/C.scaleOfZoom,B=C.pixelPathLength;"number"==typeof C.scaleOfMinZoom&&(R=Math.sqrt(L/C.scaleOfMinZoom/B*2));const O=R*R;function j(e){const s=(F*F-L*L+(e?-1:1)*O*O*B*B)/(2*(e?F:L)*O*B);return Math.log(Math.sqrt(s*s+1)-s)}function G(e){return(Math.exp(e)-Math.exp(-e))/2}function U(e){return(Math.exp(e)+Math.exp(-e))/2}const q=j(!1);let Z=function(e){return U(q)/U(q+R*e)},W=function(e){return L*((U(q)*(G(s=q+R*e)/U(s))-G(q))/O)/B;var s},J=(j(!0)-q)/R;if(Math.abs(B)<2e-6||!isFinite(J)){if(Math.abs(L-F)<1e-6)return this.easeTo(e,s);const l=F0,Z=e=>Math.exp(l*R*e)}return e.duration="duration"in e?+e.duration:1e3*J/("screenSpeed"in e?+e.screenSpeed/R:+e.speed),e.maxDuration&&e.duration>e.maxDuration&&(e.duration=0),this._zooming=!0,this._rotating=d!==g,this._pitching=y!==p,this._rolling=b!==f,this._padding=!c.isPaddingEqual(T),this._prepareEase(s,!1),this.terrain&&this._prepareElevation(C.targetCenter),this._ease((_=>{const I=_*J,R=1/Z(I),L=W(I);this._rotating&&c.setBearing(l.G.number(d,g,_)),this._pitching&&c.setPitch(l.G.number(p,y,_)),this._rolling&&c.setRoll(l.G.number(f,b,_)),this._padding&&(c.interpolatePadding(m,T,_),S=c.centerPoint.add(P)),C.easeFunc(_,R,L,S),this.terrain&&!e.freezeElevation&&this._updateElevation(_),this._applyUpdatedTransform(c),this._fireMoveEvents(s)}),(()=>{this.terrain&&e.freezeElevation&&this._finalizeElevation(),this._afterEase(s)}),e),this}isEasing(){return!!this._easeFrameId}stop(){return this._stop()}_stop(e,s){var l;if(this._easeFrameId&&(this._cancelRenderFrame(this._easeFrameId),delete this._easeFrameId,delete this._onEaseFrame),this._onEaseEnd){const e=this._onEaseEnd;delete this._onEaseEnd,e.call(this,s)}return e||null===(l=this.handlers)||void 0===l||l.stop(!1),this}_ease(e,s,l){!1===l.animate||0===l.duration?(e(1),s()):(this._easeStart=y(),this._easeOptions=l,this._onEaseFrame=e,this._onEaseEnd=s,this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback))}_normalizeBearing(e,s){e=l.W(e,-180,180);const c=Math.abs(e-s);return Math.abs(e-360-s)MapLibre'};class Yo{constructor(e=ko){this._toggleAttribution=()=>{this._container.classList.contains("maplibregl-compact")&&(this._container.classList.contains("maplibregl-compact-show")?(this._container.setAttribute("open",""),this._container.classList.remove("maplibregl-compact-show")):(this._container.classList.add("maplibregl-compact-show"),this._container.removeAttribute("open")))},this._updateData=e=>{!e||"metadata"!==e.sourceDataType&&"visibility"!==e.sourceDataType&&"style"!==e.dataType&&"terrain"!==e.type||this._updateAttributions()},this._updateCompact=()=>{this._map.getCanvasContainer().offsetWidth<=640||this._compact?!1===this._compact?this._container.setAttribute("open",""):this._container.classList.contains("maplibregl-compact")||this._container.classList.contains("maplibregl-attrib-empty")||(this._container.setAttribute("open",""),this._container.classList.add("maplibregl-compact","maplibregl-compact-show")):(this._container.setAttribute("open",""),this._container.classList.contains("maplibregl-compact")&&this._container.classList.remove("maplibregl-compact","maplibregl-compact-show"))},this._updateCompactMinimize=()=>{this._container.classList.contains("maplibregl-compact")&&this._container.classList.contains("maplibregl-compact-show")&&this._container.classList.remove("maplibregl-compact-show")},this.options=e}getDefaultPosition(){return"bottom-right"}onAdd(e){return this._map=e,this._compact=this.options.compact,this._container=h.create("details","maplibregl-ctrl maplibregl-ctrl-attrib"),this._compactButton=h.create("summary","maplibregl-ctrl-attrib-button",this._container),this._compactButton.addEventListener("click",this._toggleAttribution),this._setElementTitle(this._compactButton,"ToggleAttribution"),this._innerContainer=h.create("div","maplibregl-ctrl-attrib-inner",this._container),this._updateAttributions(),this._updateCompact(),this._map.on("styledata",this._updateData),this._map.on("sourcedata",this._updateData),this._map.on("terrain",this._updateData),this._map.on("resize",this._updateCompact),this._map.on("drag",this._updateCompactMinimize),this._container}onRemove(){h.remove(this._container),this._map.off("styledata",this._updateData),this._map.off("sourcedata",this._updateData),this._map.off("terrain",this._updateData),this._map.off("resize",this._updateCompact),this._map.off("drag",this._updateCompactMinimize),this._map=void 0,this._compact=void 0,this._attribHTML=void 0}_setElementTitle(e,s){const l=this._map._getUIString(`AttributionControl.${s}`);e.title=l,e.setAttribute("aria-label",l)}_updateAttributions(){if(!this._map.style)return;let e=[];if(this.options.customAttribution&&(Array.isArray(this.options.customAttribution)?e=e.concat(this.options.customAttribution.map((e=>"string"!=typeof e?"":e))):"string"==typeof this.options.customAttribution&&e.push(this.options.customAttribution)),this._map.style.stylesheet){const e=this._map.style.stylesheet;this.styleOwner=e.owner,this.styleId=e.id}const s=this._map.style.tileManagers;for(const l in s){const c=s[l];if(c.used||c.usedForTerrain){const s=c.getSource();s.attribution&&e.indexOf(s.attribution)<0&&e.push(s.attribution)}}e=e.filter((e=>String(e).trim())),e.sort(((e,s)=>e.length-s.length)),e=e.filter(((s,l)=>{for(let c=l+1;c=0)return!1;return!0}));const l=e.join(" | ");l!==this._attribHTML&&(this._attribHTML=l,e.length?(this._innerContainer.innerHTML=h.sanitize(l),this._container.classList.remove("maplibregl-attrib-empty")):this._container.classList.add("maplibregl-attrib-empty"),this._updateCompact(),this._editLink=null)}}class Qo{constructor(e={}){this._updateCompact=()=>{const e=this._container.children;if(e.length){const s=e[0];this._map.getCanvasContainer().offsetWidth<=640||this._compact?!1!==this._compact&&s.classList.add("maplibregl-compact"):s.classList.remove("maplibregl-compact")}},this.options=e}getDefaultPosition(){return"bottom-left"}onAdd(e){this._map=e,this._compact=this.options&&this.options.compact,this._container=h.create("div","maplibregl-ctrl");const s=h.create("a","maplibregl-ctrl-logo");return s.target="_blank",s.rel="noopener nofollow",s.href="https://maplibre.org/",s.setAttribute("aria-label",this._map._getUIString("LogoControl.Title")),s.setAttribute("rel","noopener nofollow"),this._container.appendChild(s),this._container.style.display="block",this._map.on("resize",this._updateCompact),this._updateCompact(),this._container}onRemove(){h.remove(this._container),this._map.off("resize",this._updateCompact),this._map=void 0,this._compact=void 0}}class Jo{constructor(){this._queue=[],this._id=0,this._cleared=!1,this._currentlyRunning=!1}add(e){const s=++this._id;return this._queue.push({callback:e,id:s,cancelled:!1}),s}remove(e){const s=this._currentlyRunning,l=s?this._queue.concat(s):this._queue;for(const s of l)if(s.id===e)return void(s.cancelled=!0)}run(e=0){if(this._currentlyRunning)throw new Error("Attempting to run(), but is already running.");const s=this._currentlyRunning=this._queue;this._queue=[];for(const l of s)if(!l.cancelled&&(l.callback(e),this._cleared))break;this._cleared=!1,this._currentlyRunning=!1}clear(){this._currentlyRunning&&(this._cleared=!0),this._queue=[]}}var Lo=l.aU([{name:"a_pos3d",type:"Int16",components:3}]);class ts extends l.E{constructor(e){super(),this._lastTilesetChange=y(),this.tileManager=e,this._tiles={},this._renderableTilesKeys=[],this._sourceTileCache={},this.minzoom=0,this.maxzoom=22,this.deltaZoom=1,this.tileSize=e._source.tileSize*2**this.deltaZoom,e.usedForTerrain=!0,e.tileSize=this.tileSize}destruct(){this.tileManager.usedForTerrain=!1,this.tileManager.tileSize=null}getSource(){return this.tileManager._source}update(e,s){this.tileManager.update(e,s),this._renderableTilesKeys=[];const c={};for(const d of it(e,{tileSize:this.tileSize,minzoom:this.minzoom,maxzoom:this.maxzoom,reparseOverscaled:!1,terrain:s,calculateTileZoom:this.tileManager._source.calculateTileZoom}))c[d.key]=!0,this._renderableTilesKeys.push(d.key),this._tiles[d.key]||(d.terrainRttPosMatrix32f=new Float64Array(16),l.c7(d.terrainRttPosMatrix32f,0,l.a5,l.a5,0,0,1),this._tiles[d.key]=new de(d,this.tileSize),this._lastTilesetChange=y());for(const e in this._tiles)c[e]||delete this._tiles[e]}freeRtt(e){for(const s in this._tiles){const l=this._tiles[s];(!e||l.tileID.equals(e)||l.tileID.isChildOf(e)||e.isChildOf(l.tileID))&&(l.rtt=[])}}getRenderableTiles(){return this._renderableTilesKeys.map((e=>this.getTileByID(e)))}getTileByID(e){return this._tiles[e]}getTerrainCoords(e,s){return s?this._getTerrainCoordsForTileRanges(e,s):this._getTerrainCoordsForRegularTile(e)}_getTerrainCoordsForRegularTile(e){const s={};for(const c of this._renderableTilesKeys){const d=this._tiles[c].tileID,p=e.clone(),f=l.bk();if(d.canonical.equals(e.canonical))l.c7(f,0,l.a5,l.a5,0,0,1);else if(d.canonical.isChildOf(e.canonical)){const s=d.canonical.z-e.canonical.z,c=d.canonical.x-(d.canonical.x>>s<>s<>s;l.c7(f,0,m,m,0,0,1),l.O(f,f,[-c*m,-p*m,0])}else{if(!e.canonical.isChildOf(d.canonical))continue;{const s=e.canonical.z-d.canonical.z,c=e.canonical.x-(e.canonical.x>>s<>s<>s;l.c7(f,0,l.a5,l.a5,0,0,1),l.O(f,f,[c*m,p*m,0]),l.Q(f,f,[1/2**s,1/2**s,0])}}p.terrainRttPosMatrix32f=new Float32Array(f),s[c]=p}return s}_getTerrainCoordsForTileRanges(e,s){const c={};for(const d of this._renderableTilesKeys){const p=this._tiles[d].tileID;if(!this._isWithinTileRanges(p,s))continue;const f=e.clone(),m=l.bk();if(p.canonical.z===e.canonical.z){const s=e.canonical.x-p.canonical.x+e.wrap*(1<e.canonical.z){const s=p.canonical.z-e.canonical.z,c=p.canonical.x-(p.canonical.x>>s<>s<>s),_=e.canonical.y-(p.canonical.y>>s),g=l.a5>>s;l.c7(m,0,g,g,0,0,1),l.O(m,m,[-c*g+f*l.a5,-d*g+_*l.a5,0])}else{const s=e.canonical.z-p.canonical.z,c=e.canonical.x-(e.canonical.x>>s<>s<>s)-p.canonical.x,_=(e.canonical.y>>s)-p.canonical.y,g=l.a5<l.maxzoom&&(c=l.maxzoom),c=l.minzoom&&!(null==d?void 0:d.dem);)d=this.findTileInCaches(e.scaledTo(c--).key);return d}findTileInCaches(e){let s=this.tileManager.getTileByID(e);return s||(s=this.tileManager._outOfViewCache.getByKey(e),s)}anyTilesAfterTime(e=Date.now()){return this._lastTilesetChange>=e}_isWithinTileRanges(e,s){const l=s[e.canonical.z];return!!l&&(e.wrap>l.minWrap||e.wrap=l.minTileXWrapped&&e.canonical.x<=l.maxTileXWrapped&&e.canonical.y>=l.minTileY&&e.canonical.y<=l.maxTileY)}}class is{constructor(e,s,l){this._meshCache={},this.painter=e,this.tileManager=new ts(s),this.options=l,this.exaggeration="number"==typeof l.exaggeration?l.exaggeration:1,this.qualityFactor=2,this.meshSize=128,this._demMatrixCache={},this.coordsIndex=[],this._coordsTextureSize=1024}getDEMElevation(e,s,c,d=l.a5){var p;if(!(s>=0&&s=0&&cc&&(c=Math.min(e.canonical.z,this.tileManager.maxzoom));return this.getElevationForLngLatZoom(e,c)}getElevation(e,s,c,d=l.a5){return this.getDEMElevation(e,s,c,d)*this.exaggeration}getTerrainData(e){if(!this._emptyDemTexture){const e=this.painter.context,s=new l.R({width:1,height:1},new Uint8Array(4));this._emptyDepthTexture=new l.T(e,s,e.gl.RGBA,{premultiply:!1}),this._emptyDemUnpack=[0,0,0,0],this._emptyDemTexture=new l.T(e,new l.R({width:1,height:1}),e.gl.RGBA,{premultiply:!1}),this._emptyDemTexture.bind(e.gl.NEAREST,e.gl.CLAMP_TO_EDGE),this._emptyDemMatrix=l.ar([])}const s=this.tileManager.getSourceTile(e,!0);if(s&&s.dem&&(!s.demTexture||s.needsTerrainPrepare)){const e=this.painter.context;s.demTexture=this.painter.getTileTexture(s.dem.stride),s.demTexture?s.demTexture.update(s.dem.getPixels(),{premultiply:!1}):s.demTexture=new l.T(e,s.dem.getPixels(),e.gl.RGBA,{premultiply:!1}),s.demTexture.bind(e.gl.NEAREST,e.gl.CLAMP_TO_EDGE),s.needsTerrainPrepare=!1}const c=s&&s.toString()+s.tileID.key+e.key;if(c&&!this._demMatrixCache[c]){const c=this.tileManager.getSource().maxzoom;let d=e.canonical.z-s.tileID.canonical.z;e.overscaledZ>e.canonical.z&&(e.canonical.z>=c?d=e.canonical.z-c:l.w("cannot calculate elevation if elevation maxzoom > source.maxzoom"));const p=e.canonical.x-(e.canonical.x>>d<>d<>8<<4|e>>8,s[l+3]=0;const c=new l.R({width:this._coordsTextureSize,height:this._coordsTextureSize},new Uint8Array(s.buffer)),d=new l.T(e,c,e.gl.RGBA,{premultiply:!1});return d.bind(e.gl.NEAREST,e.gl.CLAMP_TO_EDGE),this._coordsTexture=d,d}pointCoordinate(e){this.painter.maybeDrawDepthAndCoords(!0);const s=new Uint8Array(4),c=this.painter.context,d=c.gl,p=Math.round(e.x*this.painter.pixelRatio/devicePixelRatio),f=Math.round(e.y*this.painter.pixelRatio/devicePixelRatio),m=Math.round(this.painter.height/devicePixelRatio);c.bindFramebuffer.set(this.getFramebuffer("coords").framebuffer),d.readPixels(p,m-f-1,1,1,d.RGBA,d.UNSIGNED_BYTE,s),c.bindFramebuffer.set(null);const _=s[0]+(s[2]>>4<<8),g=s[1]+((15&s[2])<<8),y=this.coordsIndex[255-s[3]],b=y&&this.tileManager.getTileByID(y);if(!b)return null;const T=this._coordsTextureSize,P=(1<0,d=c&&0===e.canonical.y,p=c&&e.canonical.y===(1<e.id!==s)),this._recentlyUsed.push(e.id)}stampObject(e){e.stamp=++this._stamp}getOrCreateFreeObject(){for(const e of this._recentlyUsed)if(!this._objects[e].inUse)return this._objects[e];if(this._objects.length>=this._size)throw new Error("No free RenderPool available, call freeAllObjects() required!");const e=this._createObject(this._objects.length);return this._objects.push(e),e}freeObject(e){e.inUse=!1}freeAllObjects(){for(const e of this._objects)this.freeObject(e)}isFull(){return!(this._objects.length!e.inUse))}}const qo={background:!0,fill:!0,line:!0,raster:!0,hillshade:!0,"color-relief":!0};class os{constructor(e,s){this.painter=e,this.terrain=s,this.pool=new as(e.context,30,s.tileManager.tileSize*s.qualityFactor)}destruct(){this.pool.destruct()}getTexture(e){return this.pool.getObjectForId(e.rtt[this._stacks.length-1].id).texture}prepareForRender(e,s){this._stacks=[],this._prevType=null,this._rttTiles=[],this._renderableTiles=this.terrain.tileManager.getRenderableTiles(),this._renderableLayerIds=e._order.filter((l=>!e._layers[l].isHidden(s))),this._coordsAscending={};for(const s in e.tileManagers){this._coordsAscending[s]={};const l=e.tileManagers[s].getVisibleCoordinates(),c=e.tileManagers[s].getSource(),d=c instanceof te?c.terrainTileRanges:null;for(const e of l){const l=this.terrain.tileManager.getTerrainCoords(e,d);for(const e in l)this._coordsAscending[s][e]||(this._coordsAscending[s][e]=[]),this._coordsAscending[s][e].push(l[e])}}this._coordsAscendingStr={};for(const s of e._order){const l=e._layers[s],c=l.source;if(qo[l.type]&&!this._coordsAscendingStr[c]){this._coordsAscendingStr[c]={};for(const e in this._coordsAscending[c])this._coordsAscendingStr[c][e]=this._coordsAscending[c][e].map((e=>e.key)).sort().join()}}for(const e of this._renderableTiles)for(const s in this._coordsAscendingStr){const l=this._coordsAscendingStr[s][e.tileID.key];l&&l!==e.rttCoords[s]&&(e.rtt=[])}}renderLayer(e,s){if(e.isHidden(this.painter.transform.zoom))return!1;const c=Object.assign(Object.assign({},s),{isRenderingToTexture:!0}),d=e.type,p=this.painter,f=this._renderableLayerIds[this._renderableLayerIds.length-1]===e.id;if(qo[d]&&(this._prevType&&qo[this._prevType]||this._stacks.push([]),this._prevType=d,this._stacks[this._stacks.length-1].push(e.id),!f))return!0;if(qo[this._prevType]||qo[d]&&f){this._prevType=d;const e=this._stacks.length-1,s=this._stacks[e]||[];for(const d of this._renderableTiles){if(this.pool.isFull()&&(fs(this.painter,this.terrain,this._rttTiles,c),this._rttTiles=[],this.pool.freeAllObjects()),this._rttTiles.push(d),d.rtt[e]){const s=this.pool.getObjectForId(d.rtt[e].id);if(s.stamp===d.rtt[e].stamp){this.pool.useObject(s);continue}}const f=this.pool.getOrCreateFreeObject();this.pool.useObject(f),this.pool.stampObject(f),d.rtt[e]={id:f.id,stamp:f.stamp},p.context.bindFramebuffer.set(f.fbo.framebuffer),p.context.clear({color:l.bp.transparent,stencil:0}),p.currentStencilSource=void 0;for(let e=0;e{this.startMove(e,h.mousePos(this.element,e)),h.addEventListener(window,"mousemove",this.mousemove),h.addEventListener(window,"mouseup",this.mouseup)},this.mousemove=e=>{this.move(e,h.mousePos(this.element,e))},this.mouseup=e=>{this._rotatePitchHandler.dragEnd(e),this.offTemp()},this.touchstart=e=>{1!==e.targetTouches.length?this.reset():(this._startPos=this._lastPos=h.touchPos(this.element,e.targetTouches)[0],this.startMove(e,this._startPos),h.addEventListener(window,"touchmove",this.touchmove,{passive:!1}),h.addEventListener(window,"touchend",this.touchend))},this.touchmove=e=>{1!==e.targetTouches.length?this.reset():(this._lastPos=h.touchPos(this.element,e.targetTouches)[0],this.move(e,this._lastPos))},this.touchend=e=>{0===e.targetTouches.length&&this._startPos&&this._lastPos&&this._startPos.dist(this._lastPos){this._rotatePitchHandler.reset(),delete this._startPos,delete this._lastPos,this.offTemp()},this._clickTolerance=10,this.element=s;const d=new yo;this._rotatePitchHandler=new mo({clickTolerance:3,move:(e,d)=>{const p=s.getBoundingClientRect(),f=new l.P((p.bottom-p.top)/2,(p.right-p.left)/2);return{bearingDelta:l.cx(new l.P(e.x,d.y),d,f),pitchDelta:c?-.5*(d.y-e.y):void 0}},moveStateManager:d,enable:!0,assignEvents:()=>{}}),this.map=e,h.addEventListener(s,"mousedown",this.mousedown),h.addEventListener(s,"touchstart",this.touchstart,{passive:!1}),h.addEventListener(s,"touchcancel",this.reset)}startMove(e,s){this._rotatePitchHandler.dragStart(e,s),h.disableDrag()}move(e,s){const l=this.map,{bearingDelta:c,pitchDelta:d}=this._rotatePitchHandler.dragMove(e,s)||{};c&&l.setBearing(l.getBearing()+c),d&&l.setPitch(l.getPitch()+d)}off(){const e=this.element;h.removeEventListener(e,"mousedown",this.mousedown),h.removeEventListener(e,"touchstart",this.touchstart,{passive:!1}),h.removeEventListener(window,"touchmove",this.touchmove,{passive:!1}),h.removeEventListener(window,"touchend",this.touchend),h.removeEventListener(e,"touchcancel",this.reset),this.offTemp()}offTemp(){h.enableDrag(),h.removeEventListener(window,"mousemove",this.mousemove),h.removeEventListener(window,"mouseup",this.mouseup),h.removeEventListener(window,"touchmove",this.touchmove,{passive:!1}),h.removeEventListener(window,"touchend",this.touchend)}}let na;function el(e,s,c,d=!1){if(d||!c.getCoveringTilesDetailsProvider().allowWorldCopies())return null==e?void 0:e.wrap();const p=new l.V(e.lng,e.lat);if(e=new l.V(e.lng,e.lat),s){const d=new l.V(e.lng-360,e.lat),p=new l.V(e.lng+360,e.lat),f=c.locationToScreenPoint(e).distSqr(s);c.locationToScreenPoint(d).distSqr(s)180;){const s=c.locationToScreenPoint(e);if(s.x>=0&&s.y>=0&&s.x<=c.width&&s.y<=c.height)break;e.lng>c.center.lng?e.lng-=360:e.lng+=360}return e.lng!==p.lng&&c.isPointOnMapSurface(c.locationToScreenPoint(e))?e:p}const tl={center:"translate(-50%,-50%)",top:"translate(-50%,0)","top-left":"translate(0,0)","top-right":"translate(-100%,0)",bottom:"translate(-50%,-100%)","bottom-left":"translate(0,-100%)","bottom-right":"translate(-100%,-100%)",left:"translate(0,-50%)",right:"translate(-100%,-50%)"};function il(e,s,l){const c=e.classList;for(const e in tl)c.remove(`maplibregl-${l}-anchor-${e}`);c.add(`maplibregl-${l}-anchor-${s}`)}class ms extends l.E{constructor(e){if(super(),this._onKeyPress=e=>{const s=e.code,l=e.charCode||e.keyCode;"Space"!==s&&"Enter"!==s&&32!==l&&13!==l||this.togglePopup()},this._onMapClick=e=>{const s=e.originalEvent.target,l=this._element;this._popup&&(s===l||l.contains(s))&&this.togglePopup()},this._update=e=>{if(!this._map)return;const s=this._map.loaded()&&!this._map.isMoving();("terrain"===(null==e?void 0:e.type)||"render"===(null==e?void 0:e.type)&&!s)&&this._map.once("render",this._update),this._lngLat=el(this._lngLat,this._flatPos,this._map.transform),this._flatPos=this._pos=this._map.project(this._lngLat)._add(this._offset),this._map.terrain&&(this._flatPos=this._map.transform.locationToScreenPoint(this._lngLat)._add(this._offset));let l="";"viewport"===this._rotationAlignment||"auto"===this._rotationAlignment?l=`rotateZ(${this._rotation}deg)`:"map"===this._rotationAlignment&&(l=`rotateZ(${this._rotation-this._map.getBearing()}deg)`);let c="";"viewport"===this._pitchAlignment||"auto"===this._pitchAlignment?c="rotateX(0deg)":"map"===this._pitchAlignment&&(c=`rotateX(${this._map.getPitch()}deg)`),this._subpixelPositioning||e&&"moveend"!==e.type||(this._pos=this._pos.round()),h.setTransform(this._element,`${tl[this._anchor]} translate(${this._pos.x}px, ${this._pos.y}px) ${c} ${l}`),_.frameAsync(new AbortController).then((()=>{this._updateOpacity(e&&"moveend"===e.type)})).catch((()=>{}))},this._onMove=e=>{if(!this._isDragging){const s=this._clickTolerance||this._map._clickTolerance;this._isDragging=e.point.dist(this._pointerdownPos)>=s}this._isDragging&&(this._pos=e.point.sub(this._positionDelta),this._lngLat=this._map.unproject(this._pos),this.setLngLat(this._lngLat),this._element.style.pointerEvents="none","pending"===this._state&&(this._state="active",this.fire(new l.l("dragstart"))),this.fire(new l.l("drag")))},this._onUp=()=>{this._element.style.pointerEvents="auto",this._positionDelta=null,this._pointerdownPos=null,this._isDragging=!1,this._map.off("mousemove",this._onMove),this._map.off("touchmove",this._onMove),"active"===this._state&&this.fire(new l.l("dragend")),this._state="inactive"},this._addDragHandler=e=>{this._element.contains(e.originalEvent.target)&&(e.preventDefault(),this._positionDelta=e.point.sub(this._pos).add(this._offset),this._pointerdownPos=e.point,this._state="pending",this._map.on("mousemove",this._onMove),this._map.on("touchmove",this._onMove),this._map.once("mouseup",this._onUp),this._map.once("touchend",this._onUp))},this._anchor=e&&e.anchor||"center",this._color=e&&e.color||"#3FB1CE",this._scale=e&&e.scale||1,this._draggable=e&&e.draggable||!1,this._clickTolerance=e&&e.clickTolerance||0,this._subpixelPositioning=e&&e.subpixelPositioning||!1,this._isDragging=!1,this._state="inactive",this._rotation=e&&e.rotation||0,this._rotationAlignment=e&&e.rotationAlignment||"auto",this._pitchAlignment=e&&e.pitchAlignment&&"auto"!==e.pitchAlignment?e.pitchAlignment:this._rotationAlignment,this.setOpacity(null==e?void 0:e.opacity,null==e?void 0:e.opacityWhenCovered),e&&e.element)this._element=e.element,this._offset=l.P.convert(e&&e.offset||[0,0]);else{this._defaultMarker=!0,this._element=h.create("div");const s=h.createNS("http://www.w3.org/2000/svg","svg"),c=41,d=27;s.setAttributeNS(null,"display","block"),s.setAttributeNS(null,"height",`${c}px`),s.setAttributeNS(null,"width",`${d}px`),s.setAttributeNS(null,"viewBox",`0 0 ${d} ${c}`);const p=h.createNS("http://www.w3.org/2000/svg","g");p.setAttributeNS(null,"stroke","none"),p.setAttributeNS(null,"stroke-width","1"),p.setAttributeNS(null,"fill","none"),p.setAttributeNS(null,"fill-rule","evenodd");const f=h.createNS("http://www.w3.org/2000/svg","g");f.setAttributeNS(null,"fill-rule","nonzero");const m=h.createNS("http://www.w3.org/2000/svg","g");m.setAttributeNS(null,"transform","translate(3.0, 29.0)"),m.setAttributeNS(null,"fill","#000000");const _=[{rx:"10.5",ry:"5.25002273"},{rx:"10.5",ry:"5.25002273"},{rx:"9.5",ry:"4.77275007"},{rx:"8.5",ry:"4.29549936"},{rx:"7.5",ry:"3.81822308"},{rx:"6.5",ry:"3.34094679"},{rx:"5.5",ry:"2.86367051"},{rx:"4.5",ry:"2.38636864"}];for(const e of _){const s=h.createNS("http://www.w3.org/2000/svg","ellipse");s.setAttributeNS(null,"opacity","0.04"),s.setAttributeNS(null,"cx","10.5"),s.setAttributeNS(null,"cy","5.80029008"),s.setAttributeNS(null,"rx",e.rx),s.setAttributeNS(null,"ry",e.ry),m.appendChild(s)}const g=h.createNS("http://www.w3.org/2000/svg","g");g.setAttributeNS(null,"fill",this._color);const y=h.createNS("http://www.w3.org/2000/svg","path");y.setAttributeNS(null,"d","M27,13.5 C27,19.074644 20.250001,27.000002 14.75,34.500002 C14.016665,35.500004 12.983335,35.500004 12.25,34.500002 C6.7499993,27.000002 0,19.222562 0,13.5 C0,6.0441559 6.0441559,0 13.5,0 C20.955844,0 27,6.0441559 27,13.5 Z"),g.appendChild(y);const b=h.createNS("http://www.w3.org/2000/svg","g");b.setAttributeNS(null,"opacity","0.25"),b.setAttributeNS(null,"fill","#000000");const T=h.createNS("http://www.w3.org/2000/svg","path");T.setAttributeNS(null,"d","M13.5,0 C6.0441559,0 0,6.0441559 0,13.5 C0,19.222562 6.7499993,27 12.25,34.5 C13,35.522727 14.016664,35.500004 14.75,34.5 C20.250001,27 27,19.074644 27,13.5 C27,6.0441559 20.955844,0 13.5,0 Z M13.5,1 C20.415404,1 26,6.584596 26,13.5 C26,15.898657 24.495584,19.181431 22.220703,22.738281 C19.945823,26.295132 16.705119,30.142167 13.943359,33.908203 C13.743445,34.180814 13.612715,34.322738 13.5,34.441406 C13.387285,34.322738 13.256555,34.180814 13.056641,33.908203 C10.284481,30.127985 7.4148684,26.314159 5.015625,22.773438 C2.6163816,19.232715 1,15.953538 1,13.5 C1,6.584596 6.584596,1 13.5,1 Z"),b.appendChild(T);const P=h.createNS("http://www.w3.org/2000/svg","g");P.setAttributeNS(null,"transform","translate(6.0, 7.0)"),P.setAttributeNS(null,"fill","#FFFFFF");const S=h.createNS("http://www.w3.org/2000/svg","g");S.setAttributeNS(null,"transform","translate(8.0, 8.0)");const I=h.createNS("http://www.w3.org/2000/svg","circle");I.setAttributeNS(null,"fill","#000000"),I.setAttributeNS(null,"opacity","0.25"),I.setAttributeNS(null,"cx","5.5"),I.setAttributeNS(null,"cy","5.5"),I.setAttributeNS(null,"r","5.4999962");const C=h.createNS("http://www.w3.org/2000/svg","circle");C.setAttributeNS(null,"fill","#FFFFFF"),C.setAttributeNS(null,"cx","5.5"),C.setAttributeNS(null,"cy","5.5"),C.setAttributeNS(null,"r","5.4999962"),S.appendChild(I),S.appendChild(C),f.appendChild(m),f.appendChild(g),f.appendChild(b),f.appendChild(P),f.appendChild(S),s.appendChild(f),s.setAttributeNS(null,"height",c*this._scale+"px"),s.setAttributeNS(null,"width",d*this._scale+"px"),this._element.appendChild(s),this._offset=l.P.convert(e&&e.offset||[0,-14])}if(this._element.classList.add("maplibregl-marker"),this._element.addEventListener("dragstart",(e=>{e.preventDefault()})),this._element.addEventListener("mousedown",(e=>{e.preventDefault()})),il(this._element,this._anchor,"marker"),e&&e.className)for(const s of e.className.split(" "))this._element.classList.add(s);this._popup=null}addTo(e){return this.remove(),this._map=e,this._element.hasAttribute("aria-label")||this._element.setAttribute("aria-label",e._getUIString("Marker.Title")),this._element.hasAttribute("role")||this._element.setAttribute("role","button"),e.getCanvasContainer().appendChild(this._element),e.on("move",this._update),e.on("moveend",this._update),e.on("terrain",this._update),e.on("projectiontransition",this._update),this.setDraggable(this._draggable),this._update(),this._map.on("click",this._onMapClick),this}remove(){return this._opacityTimeout&&(clearTimeout(this._opacityTimeout),delete this._opacityTimeout),this._map&&(this._map.off("click",this._onMapClick),this._map.off("move",this._update),this._map.off("moveend",this._update),this._map.off("terrain",this._update),this._map.off("projectiontransition",this._update),this._map.off("mousedown",this._addDragHandler),this._map.off("touchstart",this._addDragHandler),this._map.off("mouseup",this._onUp),this._map.off("touchend",this._onUp),this._map.off("mousemove",this._onMove),this._map.off("touchmove",this._onMove),delete this._map),h.remove(this._element),this._popup&&this._popup.remove(),this}getLngLat(){return this._lngLat}setLngLat(e){return this._lngLat=l.V.convert(e),this._pos=null,this._popup&&this._popup.setLngLat(this._lngLat),this._update(),this}getElement(){return this._element}setPopup(e){if(this._popup&&(this._popup.remove(),this._popup=null,this._element.removeEventListener("keypress",this._onKeyPress),this._originalTabIndex||this._element.removeAttribute("tabindex")),e){if(!("offset"in e.options)){const s=38.1,l=13.5,c=Math.abs(l)/Math.SQRT2;e.options.offset=this._defaultMarker?{top:[0,0],"top-left":[0,0],"top-right":[0,0],bottom:[0,-s],"bottom-left":[c,-1*(s-l+c)],"bottom-right":[-c,-1*(s-l+c)],left:[l,-1*(s-l)],right:[-l,-1*(s-l)]}:this._offset}this._popup=e,this._originalTabIndex=this._element.getAttribute("tabindex"),this._originalTabIndex||this._element.setAttribute("tabindex","0"),this._element.addEventListener("keypress",this._onKeyPress)}return this}setSubpixelPositioning(e){return this._subpixelPositioning=e,this}getPopup(){return this._popup}togglePopup(){const e=this._popup;return this._element.style.opacity===this._opacityWhenCovered?this:e?(e.isOpen()?e.remove():(e.setLngLat(this._lngLat),e.addTo(this._map)),this):this}_updateOpacity(e=!1){var s,c;const d=null===(s=this._map)||void 0===s?void 0:s.terrain,p=this._map.transform.isLocationOccluded(this._lngLat);if(!d||p){const e=p?this._opacityWhenCovered:this._opacity;return void(this._element.style.opacity!==e&&(this._element.style.opacity=e))}if(e)this._opacityTimeout=null;else{if(this._opacityTimeout)return;this._opacityTimeout=setTimeout((()=>{this._opacityTimeout=null}),100)}const f=this._map,m=f.terrain.depthAtPoint(this._pos),_=f.terrain.getElevationForLngLat(this._lngLat,f.transform);if(f.transform.lngLatToCameraDepth(this._lngLat,_)-m<.006)return void(this._element.style.opacity=this._opacity);const g=-this._offset.y/f.transform.pixelsPerMeter,y=Math.sin(f.getPitch()*Math.PI/180)*g,b=f.terrain.depthAtPoint(new l.P(this._pos.x,this._pos.y-this._offset.y)),T=f.transform.lngLatToCameraDepth(this._lngLat,_+y)-b>.006;(null===(c=this._popup)||void 0===c?void 0:c.isOpen())&&T&&this._popup.remove(),this._element.style.opacity=T?this._opacityWhenCovered:this._opacity}getOffset(){return this._offset}setOffset(e){return this._offset=l.P.convert(e),this._update(),this}addClassName(e){this._element.classList.add(e)}removeClassName(e){this._element.classList.remove(e)}toggleClassName(e){return this._element.classList.toggle(e)}setDraggable(e){return this._draggable=!!e,this._map&&(e?(this._map.on("mousedown",this._addDragHandler),this._map.on("touchstart",this._addDragHandler)):(this._map.off("mousedown",this._addDragHandler),this._map.off("touchstart",this._addDragHandler))),this}isDraggable(){return this._draggable}setRotation(e){return this._rotation=e||0,this._update(),this}getRotation(){return this._rotation}setRotationAlignment(e){return this._rotationAlignment=e||"auto",this._update(),this}getRotationAlignment(){return this._rotationAlignment}setPitchAlignment(e){return this._pitchAlignment=e&&"auto"!==e?e:this._rotationAlignment,this._update(),this}getPitchAlignment(){return this._pitchAlignment}setOpacity(e,s){return(void 0===this._opacity||void 0===e&&void 0===s)&&(this._opacity="1",this._opacityWhenCovered="0.2"),void 0!==e&&(this._opacity=e),void 0!==s&&(this._opacityWhenCovered=s),this._map&&this._updateOpacity(!0),this}}const rl={positionOptions:{enableHighAccuracy:!1,maximumAge:0,timeout:6e3},fitBoundsOptions:{maxZoom:15},trackUserLocation:!1,showAccuracyCircle:!0,showUserLocation:!0};let nl=0,sl=!1;const ol={maxWidth:100,unit:"metric"};function al(e,s,l){const c=l&&l.maxWidth||100,d=e._container.clientHeight/2,p=e._container.clientWidth/2,f=e.unproject([p-c/2,d]),m=e.unproject([p+c/2,d]),_=Math.round(e.project(m).x-e.project(f).x),g=Math.min(c,_,e._container.clientWidth),y=f.distanceTo(m);if(l&&"imperial"===l.unit){const l=3.2808*y;l>5280?ll(s,g,l/5280,e._getUIString("ScaleControl.Miles")):ll(s,g,l,e._getUIString("ScaleControl.Feet"))}else l&&"nautical"===l.unit?ll(s,g,y/1852,e._getUIString("ScaleControl.NauticalMiles")):y>=1e3?ll(s,g,y/1e3,e._getUIString("ScaleControl.Kilometers")):ll(s,g,y,e._getUIString("ScaleControl.Meters"))}function ll(e,s,l,c){const d=function(e){const s=Math.pow(10,`${Math.floor(e)}`.length-1);let l=e/s;return l=l>=10?10:l>=5?5:l>=3?3:l>=2?2:l>=1?1:function(e){const s=Math.pow(10,Math.ceil(-Math.log(e)/Math.LN10));return Math.round(e*s)/s}(l),s*l}(l);e.style.width=s*(d/l)+"px",e.innerHTML=`${d} ${c}`}const cl={closeButton:!0,closeOnClick:!0,focusAfterOpen:!0,className:"",maxWidth:"240px",subpixelPositioning:!1,locationOccludedOpacity:void 0,padding:void 0},hl=["a[href]","[tabindex]:not([tabindex='-1'])","[contenteditable]:not([contenteditable='false'])","button:not([disabled])","input:not([disabled])","select:not([disabled])","textarea:not([disabled])"].join(", ");function ul(e){if(e){if("number"==typeof e){const s=Math.round(Math.abs(e)/Math.SQRT2);return{center:new l.P(0,0),top:new l.P(0,e),"top-left":new l.P(s,s),"top-right":new l.P(-s,s),bottom:new l.P(0,-e),"bottom-left":new l.P(s,-s),"bottom-right":new l.P(-s,-s),left:new l.P(e,0),right:new l.P(-e,0)}}if(e instanceof l.P||Array.isArray(e)){const s=l.P.convert(e);return{center:s,top:s,"top-left":s,"top-right":s,bottom:s,"bottom-left":s,"bottom-right":s,left:s,right:s}}return{center:l.P.convert(e.center||[0,0]),top:l.P.convert(e.top||[0,0]),"top-left":l.P.convert(e["top-left"]||[0,0]),"top-right":l.P.convert(e["top-right"]||[0,0]),bottom:l.P.convert(e.bottom||[0,0]),"bottom-left":l.P.convert(e["bottom-left"]||[0,0]),"bottom-right":l.P.convert(e["bottom-right"]||[0,0]),left:l.P.convert(e.left||[0,0]),right:l.P.convert(e.right||[0,0])}}return ul(new l.P(0,0))}const dl=c;s.AJAXError=l.cI,s.Event=l.l,s.Evented=l.E,s.LngLat=l.V,s.MercatorCoordinate=l.a9,s.Point=l.P,s.addProtocol=l.cJ,s.config=l.c,s.removeProtocol=l.cK,s.AttributionControl=Yo,s.BoxZoomHandler=co,s.CanvasSource=ae,s.CooperativeGesturesHandler=Vo,s.DoubleClickZoomHandler=Oo,s.DragPanHandler=Zo,s.DragRotateHandler=Go,s.EdgeInsets=Nt,s.FullscreenControl=class extends l.E{constructor(e={}){super(),this._onFullscreenChange=()=>{var e;let s=window.document.fullscreenElement||window.document.mozFullScreenElement||window.document.webkitFullscreenElement||window.document.msFullscreenElement;for(;null===(e=null==s?void 0:s.shadowRoot)||void 0===e?void 0:e.fullscreenElement;)s=s.shadowRoot.fullscreenElement;s===this._container!==this._fullscreen&&this._handleFullscreenChange()},this._onClickFullscreen=()=>{this._isFullscreen()?this._exitFullscreen():this._requestFullscreen()},this._fullscreen=!1,e&&e.container&&(e.container instanceof HTMLElement?this._container=e.container:l.w("Full screen control 'container' must be a DOM element.")),"onfullscreenchange"in document?this._fullscreenchange="fullscreenchange":"onmozfullscreenchange"in document?this._fullscreenchange="mozfullscreenchange":"onwebkitfullscreenchange"in document?this._fullscreenchange="webkitfullscreenchange":"onmsfullscreenchange"in document&&(this._fullscreenchange="MSFullscreenChange")}onAdd(e){return this._map=e,this._container||(this._container=this._map.getContainer()),this._controlContainer=h.create("div","maplibregl-ctrl maplibregl-ctrl-group"),this._setupUI(),this._controlContainer}onRemove(){h.remove(this._controlContainer),this._map=null,window.document.removeEventListener(this._fullscreenchange,this._onFullscreenChange)}_setupUI(){const e=this._fullscreenButton=h.create("button","maplibregl-ctrl-fullscreen",this._controlContainer);h.create("span","maplibregl-ctrl-icon",e).setAttribute("aria-hidden","true"),e.type="button",this._updateTitle(),this._fullscreenButton.addEventListener("click",this._onClickFullscreen),window.document.addEventListener(this._fullscreenchange,this._onFullscreenChange)}_updateTitle(){const e=this._getTitle();this._fullscreenButton.setAttribute("aria-label",e),this._fullscreenButton.title=e}_getTitle(){return this._map._getUIString(this._isFullscreen()?"FullscreenControl.Exit":"FullscreenControl.Enter")}_isFullscreen(){return this._fullscreen}_handleFullscreenChange(){this._fullscreen=!this._fullscreen,this._fullscreenButton.classList.toggle("maplibregl-ctrl-shrink"),this._fullscreenButton.classList.toggle("maplibregl-ctrl-fullscreen"),this._updateTitle(),this._fullscreen?(this.fire(new l.l("fullscreenstart")),this._prevCooperativeGesturesEnabled=this._map.cooperativeGestures.isEnabled(),this._map.cooperativeGestures.disable()):(this.fire(new l.l("fullscreenend")),this._prevCooperativeGesturesEnabled&&this._map.cooperativeGestures.enable())}_exitFullscreen(){window.document.exitFullscreen?window.document.exitFullscreen():window.document.mozCancelFullScreen?window.document.mozCancelFullScreen():window.document.msExitFullscreen?window.document.msExitFullscreen():window.document.webkitCancelFullScreen?window.document.webkitCancelFullScreen():this._togglePseudoFullScreen()}_requestFullscreen(){this._container.requestFullscreen?this._container.requestFullscreen():this._container.mozRequestFullScreen?this._container.mozRequestFullScreen():this._container.msRequestFullscreen?this._container.msRequestFullscreen():this._container.webkitRequestFullscreen?this._container.webkitRequestFullscreen():this._togglePseudoFullScreen()}_togglePseudoFullScreen(){this._container.classList.toggle("maplibregl-pseudo-fullscreen"),this._handleFullscreenChange(),this._map.resize()}},s.GeoJSONSource=ee,s.GeolocateControl=class extends l.E{constructor(e){super(),this._onSuccess=e=>{if(this._map){if(this._isOutOfMapMaxBounds(e))return this._setErrorState(),this.fire(new l.l("outofmaxbounds",e)),this._updateMarker(),void this._finish();if(this.options.trackUserLocation)switch(this._lastKnownPosition=e,this._watchState){case"WAITING_ACTIVE":case"ACTIVE_LOCK":case"ACTIVE_ERROR":this._watchState="ACTIVE_LOCK",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active-error"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-active");break;case"BACKGROUND":case"BACKGROUND_ERROR":this._watchState="BACKGROUND",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background-error"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-background");break;default:throw new Error(`Unexpected watchState ${this._watchState}`)}this.options.showUserLocation&&"OFF"!==this._watchState&&this._updateMarker(e),this.options.trackUserLocation&&"ACTIVE_LOCK"!==this._watchState||this._updateCamera(e),this.options.showUserLocation&&this._dotElement.classList.remove("maplibregl-user-location-dot-stale"),this.fire(new l.l("geolocate",e)),this._finish()}},this._updateCamera=e=>{const s=new l.V(e.coords.longitude,e.coords.latitude),c=e.coords.accuracy,d=this._map.getBearing(),p=l.e({bearing:d},this.options.fitBoundsOptions),f=$.fromLngLat(s,c);this._map.fitBounds(f,p,{geolocateSource:!0})},this._updateMarker=e=>{if(e){const s=new l.V(e.coords.longitude,e.coords.latitude);this._accuracyCircleMarker.setLngLat(s).addTo(this._map),this._userLocationDotMarker.setLngLat(s).addTo(this._map),this._accuracy=e.coords.accuracy,this._updateCircleRadiusIfNeeded()}else this._userLocationDotMarker.remove(),this._accuracyCircleMarker.remove()},this._onUpdate=()=>{this._updateCircleRadiusIfNeeded()},this._onError=e=>{if(this._map){if(1===e.code){this._watchState="OFF",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active-error"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background-error"),this._geolocateButton.disabled=!0;const e=this._map._getUIString("GeolocateControl.LocationNotAvailable");this._geolocateButton.title=e,this._geolocateButton.setAttribute("aria-label",e),void 0!==this._geolocationWatchID&&this._clearWatch()}else{if(3===e.code&&sl)return;this._setErrorState()}"OFF"!==this._watchState&&this.options.showUserLocation&&this._dotElement.classList.add("maplibregl-user-location-dot-stale"),this.fire(new l.l("error",e)),this._finish()}},this._finish=()=>{this._timeoutId&&clearTimeout(this._timeoutId),this._timeoutId=void 0},this._setupUI=()=>{this._map&&(this._container.addEventListener("contextmenu",(e=>e.preventDefault())),this._geolocateButton=h.create("button","maplibregl-ctrl-geolocate",this._container),h.create("span","maplibregl-ctrl-icon",this._geolocateButton).setAttribute("aria-hidden","true"),this._geolocateButton.type="button",this._geolocateButton.disabled=!0)},this._finishSetupUI=e=>{if(this._map){if(!1===e){l.w("Geolocation support is not available so the GeolocateControl will be disabled.");const e=this._map._getUIString("GeolocateControl.LocationNotAvailable");this._geolocateButton.disabled=!0,this._geolocateButton.title=e,this._geolocateButton.setAttribute("aria-label",e)}else{const e=this._map._getUIString("GeolocateControl.FindMyLocation");this._geolocateButton.disabled=!1,this._geolocateButton.title=e,this._geolocateButton.setAttribute("aria-label",e)}this.options.trackUserLocation&&(this._geolocateButton.setAttribute("aria-pressed","false"),this._watchState="OFF"),this.options.showUserLocation&&(this._dotElement=h.create("div","maplibregl-user-location-dot"),this._userLocationDotMarker=new ms({element:this._dotElement}),this._circleElement=h.create("div","maplibregl-user-location-accuracy-circle"),this._accuracyCircleMarker=new ms({element:this._circleElement,pitchAlignment:"map"}),this.options.trackUserLocation&&(this._watchState="OFF"),this._map.on("zoom",this._onUpdate),this._map.on("move",this._onUpdate),this._map.on("rotate",this._onUpdate),this._map.on("pitch",this._onUpdate)),this._geolocateButton.addEventListener("click",(()=>this.trigger())),this._setup=!0,this.options.trackUserLocation&&this._map.on("movestart",(e=>{const s=(null==e?void 0:e[0])instanceof ResizeObserverEntry;e.geolocateSource||"ACTIVE_LOCK"!==this._watchState||s||this._map.isZooming()||(this._watchState="BACKGROUND",this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active"),this.fire(new l.l("trackuserlocationend")),this.fire(new l.l("userlocationlostfocus")))}))}},this.options=l.e({},rl,e)}onAdd(e){return this._map=e,this._container=h.create("div","maplibregl-ctrl maplibregl-ctrl-group"),this._setupUI(),function(){return l._(this,arguments,void 0,(function*(e=!1){if(void 0!==na&&!e)return na;if(void 0===window.navigator.permissions)return na=!!window.navigator.geolocation,na;try{const e=yield window.navigator.permissions.query({name:"geolocation"});na="denied"!==e.state}catch(e){na=!!window.navigator.geolocation}return na}))}().then((e=>this._finishSetupUI(e))),this._container}onRemove(){void 0!==this._geolocationWatchID&&(window.navigator.geolocation.clearWatch(this._geolocationWatchID),this._geolocationWatchID=void 0),this.options.showUserLocation&&this._userLocationDotMarker&&this._userLocationDotMarker.remove(),this.options.showAccuracyCircle&&this._accuracyCircleMarker&&this._accuracyCircleMarker.remove(),h.remove(this._container),this._map.off("zoom",this._onUpdate),this._map.off("move",this._onUpdate),this._map.off("rotate",this._onUpdate),this._map.off("pitch",this._onUpdate),this._map=void 0,nl=0,sl=!1}_isOutOfMapMaxBounds(e){const s=this._map.getMaxBounds(),l=e.coords;return s&&(l.longitudes.getEast()||l.latitudes.getNorth())}_setErrorState(){switch(this._watchState){case"WAITING_ACTIVE":this._watchState="ACTIVE_ERROR",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-active-error");break;case"ACTIVE_LOCK":this._watchState="ACTIVE_ERROR",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-active-error"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-waiting");break;case"BACKGROUND":this._watchState="BACKGROUND_ERROR",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-background-error"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-waiting");break;case"ACTIVE_ERROR":case"BACKGROUND_ERROR":case"OFF":case void 0:break;default:throw new Error(`Unexpected watchState ${this._watchState}`)}}_updateCircleRadiusIfNeeded(){const e=this._userLocationDotMarker.getLngLat();if(!(this.options.showUserLocation&&this.options.showAccuracyCircle&&this._accuracy&&e))return;const s=this._map.project(e),l=this._map.unproject([s.x+100,s.y]),c=e.distanceTo(l)/100,d=2*this._accuracy/c;this._circleElement.style.width=`${d.toFixed(2)}px`,this._circleElement.style.height=`${d.toFixed(2)}px`}trigger(){if(!this._setup)return l.w("Geolocate control triggered before added to a map"),!1;if(this.options.trackUserLocation){switch(this._watchState){case"OFF":this._watchState="WAITING_ACTIVE",this.fire(new l.l("trackuserlocationstart"));break;case"WAITING_ACTIVE":case"ACTIVE_LOCK":case"ACTIVE_ERROR":case"BACKGROUND_ERROR":nl--,sl=!1,this._watchState="OFF",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active-error"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background-error"),this.fire(new l.l("trackuserlocationend"));break;case"BACKGROUND":this._watchState="ACTIVE_LOCK",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background"),this._lastKnownPosition&&this._updateCamera(this._lastKnownPosition),this.fire(new l.l("trackuserlocationstart")),this.fire(new l.l("userlocationfocus"));break;default:throw new Error(`Unexpected watchState ${this._watchState}`)}switch(this._watchState){case"WAITING_ACTIVE":this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-active");break;case"ACTIVE_LOCK":this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-active");break;case"OFF":break;default:throw new Error(`Unexpected watchState ${this._watchState}`)}if("OFF"===this._watchState&&void 0!==this._geolocationWatchID)this._clearWatch();else if(void 0===this._geolocationWatchID){let e;this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.setAttribute("aria-pressed","true"),nl++,nl>1?(e={maximumAge:6e5,timeout:0},sl=!0):(e=this.options.positionOptions,sl=!1),this._geolocationWatchID=window.navigator.geolocation.watchPosition(this._onSuccess,this._onError,e)}}else window.navigator.geolocation.getCurrentPosition(this._onSuccess,this._onError,this.options.positionOptions),this._timeoutId=setTimeout(this._finish,1e4);return!0}_clearWatch(){window.navigator.geolocation.clearWatch(this._geolocationWatchID),this._geolocationWatchID=void 0,this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.setAttribute("aria-pressed","false"),this.options.showUserLocation&&this._updateMarker(null)}},s.GlobeControl=class{constructor(){this._toggleProjection=()=>{var e;const s=null===(e=this._map.getProjection())||void 0===e?void 0:e.type;this._map.setProjection("mercator"!==s&&s?{type:"mercator"}:{type:"globe"}),this._updateGlobeIcon()},this._updateGlobeIcon=()=>{var e;this._globeButton.classList.remove("maplibregl-ctrl-globe"),this._globeButton.classList.remove("maplibregl-ctrl-globe-enabled"),"globe"===(null===(e=this._map.getProjection())||void 0===e?void 0:e.type)?(this._globeButton.classList.add("maplibregl-ctrl-globe-enabled"),this._globeButton.title=this._map._getUIString("GlobeControl.Disable")):(this._globeButton.classList.add("maplibregl-ctrl-globe"),this._globeButton.title=this._map._getUIString("GlobeControl.Enable"))}}onAdd(e){return this._map=e,this._container=h.create("div","maplibregl-ctrl maplibregl-ctrl-group"),this._globeButton=h.create("button","maplibregl-ctrl-globe",this._container),h.create("span","maplibregl-ctrl-icon",this._globeButton).setAttribute("aria-hidden","true"),this._globeButton.type="button",this._globeButton.addEventListener("click",this._toggleProjection),this._updateGlobeIcon(),this._map.on("styledata",this._updateGlobeIcon),this._container}onRemove(){h.remove(this._container),this._map.off("styledata",this._updateGlobeIcon),this._globeButton.removeEventListener("click",this._toggleProjection),this._map=void 0}},s.Hash=$r,s.ImageSource=te,s.KeyboardHandler=Ao,s.LngLatBounds=$,s.LogoControl=Qo,s.Map=class extends Xo{constructor(e){var s,c;l.cG.mark(l.cH.create);const d=Object.assign(Object.assign(Object.assign({},ta),e),{canvasContextAttributes:Object.assign(Object.assign({},ta.canvasContextAttributes),e.canvasContextAttributes)});if(null!=d.minZoom&&null!=d.maxZoom&&d.minZoom>d.maxZoom)throw new Error("maxZoom must be greater than or equal to minZoom");if(null!=d.minPitch&&null!=d.maxPitch&&d.minPitch>d.maxPitch)throw new Error("maxPitch must be greater than or equal to minPitch");if(null!=d.minPitch&&d.minPitch<0)throw new Error("minPitch must be greater than or equal to 0");if(null!=d.maxPitch&&d.maxPitch>180)throw new Error("maxPitch must be less than or equal to 180");const p=new $t,f=new Yt;if(void 0!==d.minZoom&&p.setMinZoom(d.minZoom),void 0!==d.maxZoom&&p.setMaxZoom(d.maxZoom),void 0!==d.minPitch&&p.setMinPitch(d.minPitch),void 0!==d.maxPitch&&p.setMaxPitch(d.maxPitch),void 0!==d.renderWorldCopies&&p.setRenderWorldCopies(d.renderWorldCopies),null!==d.transformConstrain&&p.setConstrainOverride(d.transformConstrain),super(p,f,{bearingSnap:d.bearingSnap}),this._idleTriggered=!1,this._crossFadingFactor=1,this._renderTaskQueue=new Jo,this._controls=[],this._mapId=l.af(),this._lostContextStyle={style:null,images:null},this._contextLost=e=>{e.preventDefault(),this._frameRequest&&(this._frameRequest.abort(),this._frameRequest=null),this.painter.destroy();for(const e of Object.values(this.style._layers))if("custom"===e.type&&console.warn(`Custom layer with id '${e.id}' cannot be restored after WebGL context loss. You will need to re-add it manually after context restoration.`),e._listeners)for(const[s]of Object.entries(e._listeners))console.warn(`Custom layer with id '${e.id}' had event listeners for event '${s}' which cannot be restored after WebGL context loss. You will need to re-add them manually after context restoration.`);this._lostContextStyle=this._getStyleAndImages(),this.style.destroy(),this.style=null,this.fire(new l.l("webglcontextlost",{originalEvent:e}))},this._contextRestored=e=>{this._lostContextStyle.style&&this.setStyle(this._lostContextStyle.style,{diff:!1}),this._lostContextStyle.images&&(this.style.imageManager.images=this._lostContextStyle.images),this._lostContextStyle={style:null,images:null},this._setupPainter(),this.resize(),this._update(),this._resizeInternal(),this.fire(new l.l("webglcontextrestored",{originalEvent:e}))},this._onMapScroll=e=>{if(e.target===this._container)return this._container.scrollTop=0,this._container.scrollLeft=0,!1},this._onWindowOnline=()=>{this._update()},this._interactive=d.interactive,this._maxTileCacheSize=d.maxTileCacheSize,this._maxTileCacheZoomLevels=d.maxTileCacheZoomLevels,this._canvasContextAttributes=Object.assign({},d.canvasContextAttributes),this._trackResize=!0===d.trackResize,this._bearingSnap=d.bearingSnap,this._centerClampedToGround=d.centerClampedToGround,this._refreshExpiredTiles=!0===d.refreshExpiredTiles,this._fadeDuration=d.fadeDuration,this._crossSourceCollisions=!0===d.crossSourceCollisions,this._collectResourceTiming=!0===d.collectResourceTiming,this._locale=Object.assign(Object.assign({},$o),d.locale),this._clickTolerance=d.clickTolerance,this._overridePixelRatio=d.pixelRatio,this._maxCanvasSize=d.maxCanvasSize,this._zoomLevelsToOverscale=d.experimentalZoomLevelsToOverscale,this.transformCameraUpdate=d.transformCameraUpdate,this.transformConstrain=d.transformConstrain,this.cancelPendingTileRequestsWhileZooming=!0===d.cancelPendingTileRequestsWhileZooming,void 0!==d.reduceMotion&&(_.prefersReducedMotion=d.reduceMotion),this._imageQueueHandle=R.addThrottleControl((()=>this.isMoving())),this._requestManager=new v(d.transformRequest),"string"==typeof d.container){if(this._container=document.getElementById(d.container),!this._container)throw new Error(`Container '${d.container}' not found.`)}else{if(!(d.container instanceof HTMLElement))throw new Error("Invalid type: 'container' must be a String or HTMLElement.");this._container=d.container}if(d.maxBounds&&this.setMaxBounds(d.maxBounds),this._setupContainer(),this._setupPainter(),this.on("move",(()=>this._update(!1))),this.on("moveend",(()=>this._update(!1))),this.on("zoom",(()=>this._update(!0))),this.on("terrain",(()=>{this.painter.terrainFacilitator.dirty=!0,this._update(!0)})),this.once("idle",(()=>{this._idleTriggered=!0})),"undefined"!=typeof window){addEventListener("online",this._onWindowOnline,!1);let e=!1;const s=gs((e=>{this._trackResize&&!this._removed&&(this.resize(e),this.redraw())}),50);this._resizeObserver=new ResizeObserver((l=>{e?s(l):e=!0})),this._resizeObserver.observe(this._container)}this.handlers=new Ho(this,d),this._hash=d.hash&&new $r("string"==typeof d.hash&&d.hash||void 0).addTo(this),this._hash&&this._hash._onHashChange()||(this.jumpTo({center:d.center,elevation:d.elevation,zoom:d.zoom,bearing:d.bearing,pitch:d.pitch,roll:d.roll}),d.bounds&&(this.resize(),this.fitBounds(d.bounds,l.e({},d.fitBoundsOptions,{duration:0}))));const m="string"==typeof d.style||!("globe"===(null===(c=null===(s=d.style)||void 0===s?void 0:s.projection)||void 0===c?void 0:c.type));this.resize(null,m),this._localIdeographFontFamily=d.localIdeographFontFamily,this._validateStyle=d.validateStyle,d.style&&this.setStyle(d.style,{localIdeographFontFamily:d.localIdeographFontFamily}),d.attributionControl&&this.addControl(new Yo("boolean"==typeof d.attributionControl?void 0:d.attributionControl)),d.maplibreLogo&&this.addControl(new Qo,d.logoPosition),this.on("style.load",(()=>{if(m||this._resizeTransform(),this.transform.unmodified){const e=l.U(this.style.stylesheet,["center","zoom","bearing","pitch","roll"]);this.jumpTo(e)}})),this.on("data",(e=>{this._update("style"===e.dataType),this.fire(new l.l(`${e.dataType}data`,e))})),this.on("dataloading",(e=>{this.fire(new l.l(`${e.dataType}dataloading`,e))})),this.on("dataabort",(e=>{this.fire(new l.l("sourcedataabort",e))}))}_getMapId(){return this._mapId}setGlobalStateProperty(e,s){return this.style.setGlobalStateProperty(e,s),this._update(!0)}getGlobalState(){return this.style.getGlobalState()}addControl(e,s){if(void 0===s&&(s=e.getDefaultPosition?e.getDefaultPosition():"top-right"),!e||!e.onAdd)return this.fire(new l.k(new Error("Invalid argument to map.addControl(). Argument must be a control with onAdd and onRemove methods.")));const c=e.onAdd(this);this._controls.push(e);const d=this._controlPositions[s];return-1!==s.indexOf("bottom")?d.insertBefore(c,d.firstChild):d.appendChild(c),this}removeControl(e){if(!e||!e.onRemove)return this.fire(new l.k(new Error("Invalid argument to map.removeControl(). Argument must be a control with onAdd and onRemove methods.")));const s=this._controls.indexOf(e);return s>-1&&this._controls.splice(s,1),e.onRemove(this),this}hasControl(e){return this._controls.indexOf(e)>-1}coveringTiles(e){return it(this.transform,e)}calculateCameraOptionsFromTo(e,s,l,c){return null==c&&this.terrain&&(c=this.terrain.getElevationForLngLat(l,this.transform)),super.calculateCameraOptionsFromTo(e,s,l,c)}resize(e,s=!0){if(null!==this._lostContextStyle.style)return this;this._resizeInternal(s);const c=!this._moving;return c&&(this.stop(),this.fire(new l.l("movestart",e)).fire(new l.l("move",e))),this.fire(new l.l("resize",e)),c&&this.fire(new l.l("moveend",e)),this}_resizeInternal(e=!0){const[s,l]=this._containerDimensions(),c=this._getClampedPixelRatio(s,l);if(this._resizeCanvas(s,l,c),this.painter.resize(s,l,c),this.painter.overLimit()){const e=this.painter.context.gl;this._maxCanvasSize=[e.drawingBufferWidth,e.drawingBufferHeight];const c=this._getClampedPixelRatio(s,l);this._resizeCanvas(s,l,c),this.painter.resize(s,l,c)}this._resizeTransform(e)}_resizeTransform(e=!0){var s;const[l,c]=this._containerDimensions();this.transform.resize(l,c,e),null===(s=this._requestedCameraState)||void 0===s||s.resize(l,c,e)}_getClampedPixelRatio(e,s){const{0:l,1:c}=this._maxCanvasSize,d=this.getPixelRatio(),p=e*d,f=s*d;return Math.min(p>l?l/p:1,f>c?c/f:1)*d}getPixelRatio(){var e;return null!==(e=this._overridePixelRatio)&&void 0!==e?e:devicePixelRatio}setPixelRatio(e){this._overridePixelRatio=e,this.resize()}getBounds(){return this.transform.getBounds()}getMaxBounds(){return this.transform.getMaxBounds()}setMaxBounds(e){return this.transform.setMaxBounds($.convert(e)),this._update()}setMinZoom(e){if((e=null==e?-2:e)>=-2&&e<=this.transform.maxZoom){const s=this._getTransformForUpdate();return s.setMinZoom(e),this._applyUpdatedTransform(s),this._update(),this}throw new Error("minZoom must be between -2 and the current maxZoom, inclusive")}getMinZoom(){return this.transform.minZoom}setMaxZoom(e){if((e=null==e?22:e)>=this.transform.minZoom){const s=this._getTransformForUpdate();return s.setMaxZoom(e),this._applyUpdatedTransform(s),this._update(),this}throw new Error("maxZoom must be greater than the current minZoom")}getMaxZoom(){return this.transform.maxZoom}setMinPitch(e){if((e=null==e?0:e)<0)throw new Error("minPitch must be greater than or equal to 0");if(e>=0&&e<=this.transform.maxPitch)return this.transform.setMinPitch(e),this._update(),this.getPitch()180)throw new Error("maxPitch must be less than or equal to 180");if(e>=this.transform.minPitch)return this.transform.setMaxPitch(e),this._update(),this.getPitch()>e&&this.setPitch(e),this;throw new Error("maxPitch must be greater than the current minPitch")}getMaxPitch(){return this.transform.maxPitch}getRenderWorldCopies(){return this.transform.renderWorldCopies}setRenderWorldCopies(e){return this.transform.setRenderWorldCopies(e),this._update()}setTransformConstrain(e){return this.transform.setConstrainOverride(e),this._update()}project(e){return this.transform.locationToScreenPoint(l.V.convert(e),this.style&&this.terrain)}unproject(e){return this.transform.screenPointToLocation(l.P.convert(e),this.terrain)}isMoving(){var e;return this._moving||(null===(e=this.handlers)||void 0===e?void 0:e.isMoving())}isZooming(){var e;return this._zooming||(null===(e=this.handlers)||void 0===e?void 0:e.isZooming())}isRotating(){var e;return this._rotating||(null===(e=this.handlers)||void 0===e?void 0:e.isRotating())}_createDelegatedListener(e,s,l){if("mouseenter"===e||"mouseover"===e){let c=!1;const d=d=>{const p=s.filter((e=>this.getLayer(e))),f=0!==p.length?this.queryRenderedFeatures(d.point,{layers:p}):[];f.length?c||(c=!0,l.call(this,new ao(e,this,d.originalEvent,{features:f}))):c=!1};return{layers:s,listener:l,delegates:{mousemove:d,mouseout:()=>{c=!1}}}}if("mouseleave"===e||"mouseout"===e){let c=!1;const d=d=>{const p=s.filter((e=>this.getLayer(e)));(0!==p.length?this.queryRenderedFeatures(d.point,{layers:p}):[]).length?c=!0:c&&(c=!1,l.call(this,new ao(e,this,d.originalEvent)))},p=s=>{c&&(c=!1,l.call(this,new ao(e,this,s.originalEvent)))};return{layers:s,listener:l,delegates:{mousemove:d,mouseout:p}}}{const c=e=>{const c=s.filter((e=>this.getLayer(e))),d=0!==c.length?this.queryRenderedFeatures(e.point,{layers:c}):[];d.length&&(e.features=d,l.call(this,e),delete e.features)};return{layers:s,listener:l,delegates:{[e]:c}}}}_saveDelegatedListener(e,s){this._delegatedListeners=this._delegatedListeners||{},this._delegatedListeners[e]=this._delegatedListeners[e]||[],this._delegatedListeners[e].push(s)}_removeDelegatedListener(e,s,l){if(!this._delegatedListeners||!this._delegatedListeners[e])return;const c=this._delegatedListeners[e];for(let e=0;es.includes(e)))){for(const e in d.delegates)this.off(e,d.delegates[e]);return void c.splice(e,1)}}}on(e,s,l){if(void 0===l)return super.on(e,s);const c="string"==typeof s?[s]:s,d=this._createDelegatedListener(e,c,l);this._saveDelegatedListener(e,d);for(const e in d.delegates)this.on(e,d.delegates[e]);return{unsubscribe:()=>{this._removeDelegatedListener(e,c,l)}}}once(e,s,l){if(void 0===l)return super.once(e,s);const c="string"==typeof s?[s]:s,d=this._createDelegatedListener(e,c,l);for(const s in d.delegates){const p=d.delegates[s];d.delegates[s]=(...s)=>{this._removeDelegatedListener(e,c,l),p(...s)}}this._saveDelegatedListener(e,d);for(const e in d.delegates)this.once(e,d.delegates[e]);return this}off(e,s,l){return void 0===l?super.off(e,s):(this._removeDelegatedListener(e,"string"==typeof s?[s]:s,l),this)}queryRenderedFeatures(e,s){if(!this.style)return[];let c;const d=e instanceof l.P||Array.isArray(e),p=d?e:[[0,0],[this.transform.width,this.transform.height]];if(s=s||(d?{}:e)||{},p instanceof l.P||"number"==typeof p[0])c=[l.P.convert(p)];else{const e=l.P.convert(p[0]),s=l.P.convert(p[1]);c=[e,new l.P(s.x,e.y),s,new l.P(e.x,s.y),e]}return this.style.queryRenderedFeatures(c,s,this.transform)}querySourceFeatures(e,s){return this.style.querySourceFeatures(e,s)}setStyle(e,s){return!1!==(s=l.e({},{localIdeographFontFamily:this._localIdeographFontFamily,validate:this._validateStyle},s)).diff&&s.localIdeographFontFamily===this._localIdeographFontFamily&&this.style&&e?(this._diffStyle(e,s),this):(this._localIdeographFontFamily=s.localIdeographFontFamily,this._updateStyle(e,s))}setTransformRequest(e){return this._requestManager.setTransformRequest(e),this}_getUIString(e){const s=this._locale[e];if(null==s)throw new Error(`Missing UI string '${e}'`);return s}_updateStyle(e,s){var l,c;if(s.transformStyle&&this.style&&!this.style._loaded)return void this.style.once("style.load",(()=>this._updateStyle(e,s)));const d=this.style&&s.transformStyle?this.style.serialize():void 0;return this.style&&(this.style.setEventedParent(null),this.style._remove(!e)),e?(this.style=new ki(this,s||{}),this.style.setEventedParent(this,{style:this.style}),"string"==typeof e?this.style.loadURL(e,s,d):this.style.loadJSON(e,s,d),this):(null===(c=null===(l=this.style)||void 0===l?void 0:l.projection)||void 0===c||c.destroy(),delete this.style,this)}_lazyInitEmptyStyle(){this.style||(this.style=new ki(this,{}),this.style.setEventedParent(this,{style:this.style}),this.style.loadEmpty())}_diffStyle(e,s){if("string"==typeof e){const c=this._requestManager.transformRequest(e,"Style");l.j(c,new AbortController).then((e=>{this._updateDiff(e.data,s)})).catch((e=>{e&&this.fire(new l.k(e))}))}else"object"==typeof e&&this._updateDiff(e,s)}_updateDiff(e,s){try{this.style.setState(e,s)&&this._update(!0)}catch(c){l.w(`Unable to perform style diff: ${c.message||c.error||c}. Rebuilding the style from scratch.`),this._updateStyle(e,s)}}getStyle(){if(this.style)return this.style.serialize()}_getStyleAndImages(){return this.style?{style:this.style.serialize(),images:this.style.imageManager.cloneImages()}:{style:null,images:{}}}isStyleLoaded(){return this.style?this.style.loaded():l.w("There is no style added to the map.")}addSource(e,s){return this._lazyInitEmptyStyle(),this.style.addSource(e,s),this._update(!0)}isSourceLoaded(e){const s=this.style&&this.style.tileManagers[e];if(void 0!==s)return s.loaded();this.fire(new l.k(new Error(`There is no tile manager with ID '${e}'`)))}setTerrain(e){if(this.style._checkLoaded(),this._terrainDataCallback&&this.style.off("data",this._terrainDataCallback),e){const s=this.style.tileManagers[e.source];if(!s)throw new Error(`cannot load terrain, because there exists no source with ID: ${e.source}`);null===this.terrain&&s.reload();for(const s in this.style._layers){const c=this.style._layers[s];"hillshade"===c.type&&c.source===e.source&&l.w("You are using the same source for a hillshade layer and for 3D terrain. Please consider using two separate sources to improve rendering quality."),"color-relief"===c.type&&c.source===e.source&&l.w("You are using the same source for a color-relief layer and for 3D terrain. Please consider using two separate sources to improve rendering quality.")}this.terrain=new is(this.painter,s,e),this.painter.renderToTexture=new os(this.painter,this.terrain),this.transform.setMinElevationForCurrentTile(this.terrain.getMinTileElevationForLngLatZoom(this.transform.center,this.transform.tileZoom)),this.transform.setElevation(this.terrain.getElevationForLngLatZoom(this.transform.center,this.transform.tileZoom)),this._terrainDataCallback=s=>{var l;"style"===s.dataType?this.terrain.tileManager.freeRtt():"source"===s.dataType&&s.tile&&(s.sourceId!==e.source||this._elevationFreeze||(this.transform.setMinElevationForCurrentTile(this.terrain.getMinTileElevationForLngLatZoom(this.transform.center,this.transform.tileZoom)),this._centerClampedToGround&&this.transform.setElevation(this.terrain.getElevationForLngLatZoom(this.transform.center,this.transform.tileZoom))),"image"===(null===(l=s.source)||void 0===l?void 0:l.type)?this.terrain.tileManager.freeRtt():this.terrain.tileManager.freeRtt(s.tile.tileID))},this.style.on("data",this._terrainDataCallback)}else this.terrain&&this.terrain.tileManager.destruct(),this.terrain=null,this.painter.renderToTexture&&this.painter.renderToTexture.destruct(),this.painter.renderToTexture=null,this.transform.setMinElevationForCurrentTile(0),this._centerClampedToGround&&this.transform.setElevation(0);return this.fire(new l.l("terrain",{terrain:e})),this}getTerrain(){var e,s;return null!==(s=null===(e=this.terrain)||void 0===e?void 0:e.options)&&void 0!==s?s:null}areTilesLoaded(){const e=this.style&&this.style.tileManagers;for(const s of Object.values(e))if(!s.areTilesLoaded())return!1;return!0}removeSource(e){return this.style.removeSource(e),this._update(!0)}getSource(e){return this.style.getSource(e)}setSourceTileLodParams(e,s,l){if(l){const c=this.getSource(l);if(!c)throw new Error(`There is no source with ID "${l}", cannot set LOD parameters`);c.calculateTileZoom=Ye(Math.max(1,e),Math.max(1,s))}else for(const l in this.style.tileManagers)this.style.tileManagers[l].getSource().calculateTileZoom=Ye(Math.max(1,e),Math.max(1,s));return this._update(!0),this}refreshTiles(e,s){const c=this.style.tileManagers[e];if(!c)throw new Error(`There is no tile manager with ID "${e}", cannot refresh tile`);void 0===s?c.reload(!0):c.refreshTiles(s.map((e=>new l.ac(e.z,e.x,e.y))))}addImage(e,s,c={}){const{pixelRatio:d=1,sdf:p=!1,stretchX:f,stretchY:m,content:g,textFitWidth:y,textFitHeight:b}=c;if(this._lazyInitEmptyStyle(),!(s instanceof HTMLImageElement||l.b(s))){if(void 0===s.width||void 0===s.height)return this.fire(new l.k(new Error("Invalid arguments to map.addImage(). The second argument must be an `HTMLImageElement`, `ImageData`, `ImageBitmap`, or object with `width`, `height`, and `data` properties with the same format as `ImageData`")));{const{width:c,height:_,data:T}=s,P=s;return this.style.addImage(e,{data:new l.R({width:c,height:_},new Uint8Array(T)),pixelRatio:d,stretchX:f,stretchY:m,content:g,textFitWidth:y,textFitHeight:b,sdf:p,version:0,userImage:P}),P.onAdd&&P.onAdd(this,e),this}}{const{width:c,height:T,data:P}=_.getImageData(s);this.style.addImage(e,{data:new l.R({width:c,height:T},P),pixelRatio:d,stretchX:f,stretchY:m,content:g,textFitWidth:y,textFitHeight:b,sdf:p,version:0})}}updateImage(e,s){const c=this.style.getImage(e);if(!c)return this.fire(new l.k(new Error("The map has no image with that id. If you are adding a new image use `map.addImage(...)` instead.")));const d=s instanceof HTMLImageElement||l.b(s)?_.getImageData(s):s,{width:p,height:f,data:m}=d;if(void 0===p||void 0===f)return this.fire(new l.k(new Error("Invalid arguments to map.updateImage(). The second argument must be an `HTMLImageElement`, `ImageData`, `ImageBitmap`, or object with `width`, `height`, and `data` properties with the same format as `ImageData`")));if(p!==c.data.width||f!==c.data.height)return this.fire(new l.k(new Error("The width and height of the updated image must be that same as the previous version of the image")));const g=!(s instanceof HTMLImageElement||l.b(s));return c.data.replace(m,g),this.style.updateImage(e,c),this}getImage(e){return this.style.getImage(e)}hasImage(e){return e?!!this.style.getImage(e):(this.fire(new l.k(new Error("Missing required image id"))),!1)}removeImage(e){this.style.removeImage(e)}loadImage(e){return R.getImage(this._requestManager.transformRequest(e,"Image"),new AbortController)}listImages(){return this.style.listImages()}addLayer(e,s){return this._lazyInitEmptyStyle(),this.style.addLayer(e,s),this._update(!0)}moveLayer(e,s){return this.style.moveLayer(e,s),this._update(!0)}removeLayer(e){return this.style.removeLayer(e),this._update(!0)}getLayer(e){return this.style.getLayer(e)}getLayersOrder(){return this.style.getLayersOrder()}setLayerZoomRange(e,s,l){return this.style.setLayerZoomRange(e,s,l),this._update(!0)}setFilter(e,s,l={}){return this.style.setFilter(e,s,l),this._update(!0)}getFilter(e){return this.style.getFilter(e)}setPaintProperty(e,s,l,c={}){return this.style.setPaintProperty(e,s,l,c),this._update(!0)}getPaintProperty(e,s){return this.style.getPaintProperty(e,s)}setLayoutProperty(e,s,l,c={}){return this.style.setLayoutProperty(e,s,l,c),this._update(!0)}getLayoutProperty(e,s){return this.style.getLayoutProperty(e,s)}setGlyphs(e,s={}){return this._lazyInitEmptyStyle(),this.style.setGlyphs(e,s),this._update(!0)}getGlyphs(){return this.style.getGlyphsUrl()}addSprite(e,s,l={}){return this._lazyInitEmptyStyle(),this.style.addSprite(e,s,l,(e=>{e||this._update(!0)})),this}removeSprite(e){return this._lazyInitEmptyStyle(),this.style.removeSprite(e),this._update(!0)}getSprite(){return this.style.getSprite()}setSprite(e,s={}){return this._lazyInitEmptyStyle(),this.style.setSprite(e,s,(e=>{e||this._update(!0)})),this}setLight(e,s={}){return this._lazyInitEmptyStyle(),this.style.setLight(e,s),this._update(!0)}getLight(){return this.style.getLight()}setSky(e,s={}){return this._lazyInitEmptyStyle(),this.style.setSky(e,s),this._update(!0)}getSky(){return this.style.getSky()}setFeatureState(e,s){return this.style.setFeatureState(e,s),this._update()}removeFeatureState(e,s){return this.style.removeFeatureState(e,s),this._update()}getFeatureState(e){return this.style.getFeatureState(e)}getContainer(){return this._container}getCanvasContainer(){return this._canvasContainer}getCanvas(){return this._canvas}_containerDimensions(){let e=0,s=0;return this._container&&(e=this._container.clientWidth||400,s=this._container.clientHeight||300),[e,s]}_setupContainer(){const e=this._container;e.classList.add("maplibregl-map");const s=this._canvasContainer=h.create("div","maplibregl-canvas-container",e);this._interactive&&s.classList.add("maplibregl-interactive"),this._canvas=h.create("canvas","maplibregl-canvas",s),this._canvas.addEventListener("webglcontextlost",this._contextLost,!1),this._canvas.addEventListener("webglcontextrestored",this._contextRestored,!1),this._canvas.setAttribute("tabindex",this._interactive?"0":"-1"),this._canvas.setAttribute("aria-label",this._getUIString("Map.Title")),this._canvas.setAttribute("role","region");const l=this._containerDimensions(),c=this._getClampedPixelRatio(l[0],l[1]);this._resizeCanvas(l[0],l[1],c);const d=this._controlContainer=h.create("div","maplibregl-control-container",e),p=this._controlPositions={};["top-left","top-right","bottom-left","bottom-right"].forEach((e=>{p[e]=h.create("div",`maplibregl-ctrl-${e} `,d)})),this._container.addEventListener("scroll",this._onMapScroll,!1)}_resizeCanvas(e,s,l){this._canvas.width=Math.floor(l*e),this._canvas.height=Math.floor(l*s),this._canvas.style.width=`${e}px`,this._canvas.style.height=`${s}px`}_setupPainter(){const e=Object.assign(Object.assign({},this._canvasContextAttributes),{alpha:!0,depth:!0,stencil:!0,premultipliedAlpha:!0});let s=null;this._canvas.addEventListener("webglcontextcreationerror",(l=>{s={requestedAttributes:e},l&&(s.statusMessage=l.statusMessage,s.type=l.type)}),{once:!0});let l=null;if(l=this._canvasContextAttributes.contextType?this._canvas.getContext(this._canvasContextAttributes.contextType,e):this._canvas.getContext("webgl2",e)||this._canvas.getContext("webgl",e),!l){const e="Failed to initialize WebGL";throw s?(s.message=e,new Error(JSON.stringify(s))):new Error(e)}this.painter=new qr(l,this.transform),b.testSupport(l)}migrateProjection(e,s){super.migrateProjection(e,s),this.painter.transform=e,this.fire(new l.l("projectiontransition",{newProjection:this.style.projection.name}))}loaded(){return!this._styleDirty&&!this._sourcesDirty&&!!this.style&&this.style.loaded()}_update(e){return this.style&&this.style._loaded?(this._styleDirty=this._styleDirty||e,this._sourcesDirty=!0,this.triggerRepaint(),this):this}_requestRenderFrame(e){return this._update(),this._renderTaskQueue.add(e)}_cancelRenderFrame(e){this._renderTaskQueue.remove(e)}_render(e){var s,c,d,p,f;const m=this._idleTriggered?this._fadeDuration:0,_=(null===(s=this.style.projection)||void 0===s?void 0:s.transitionState)>0;if(this.painter.context.setDirty(),this.painter.setBaseState(),this._renderTaskQueue.run(e),this._removed)return;let g=!1;if(this.style&&this._styleDirty){this._styleDirty=!1;const e=this.transform.zoom,s=y();this.style.zoomHistory.update(e,s);const c=new l.H(e,{now:s,fadeDuration:m,zoomHistory:this.style.zoomHistory,transition:this.style.getTransition()}),d=c.crossFadingFactor();1===d&&d===this._crossFadingFactor||(g=!0,this._crossFadingFactor=d),this.style.update(c)}const b=(null===(c=this.style.projection)||void 0===c?void 0:c.transitionState)>0!==_;null===(d=this.style.projection)||void 0===d||d.setErrorQueryLatitudeDegrees(this.transform.center.lat),this.transform.setTransitionState(null===(p=this.style.projection)||void 0===p?void 0:p.transitionState,null===(f=this.style.projection)||void 0===f?void 0:f.latitudeErrorCorrectionRadians),this.style&&(this._sourcesDirty||b)&&(this._sourcesDirty=!1,this.style._updateSources(this.transform)),this.terrain?(this.terrain.tileManager.update(this.transform,this.terrain),this.transform.setMinElevationForCurrentTile(this.terrain.getMinTileElevationForLngLatZoom(this.transform.center,this.transform.tileZoom)),!this._elevationFreeze&&this._centerClampedToGround&&this.transform.setElevation(this.terrain.getElevationForLngLatZoom(this.transform.center,this.transform.tileZoom))):(this.transform.setMinElevationForCurrentTile(0),this._centerClampedToGround&&this.transform.setElevation(0)),this._placementDirty=this.style&&this.style._updatePlacement(this.transform,this.showCollisionBoxes,m,this._crossSourceCollisions,b),this.painter.render(this.style,{showTileBoundaries:this.showTileBoundaries,showOverdrawInspector:this._showOverdrawInspector,rotating:this.isRotating(),zooming:this.isZooming(),moving:this.isMoving(),fadeDuration:m,showPadding:this.showPadding}),this.fire(new l.l("render")),this.loaded()&&!this._loaded&&(this._loaded=!0,l.cG.mark(l.cH.load),this.fire(new l.l("load"))),this.style&&(this.style.hasTransitions()||g)&&(this._styleDirty=!0),this.style&&!this._placementDirty&&this.style._releaseSymbolFadeTiles();const T=this._sourcesDirty||this._styleDirty||this._placementDirty;return T||this._repaint?this.triggerRepaint():!this.isMoving()&&this.loaded()&&this.fire(new l.l("idle")),!this._loaded||this._fullyLoaded||T||(this._fullyLoaded=!0,l.cG.mark(l.cH.fullLoad)),this}redraw(){return this.style&&(this._frameRequest&&(this._frameRequest.abort(),this._frameRequest=null),this._render(0)),this}remove(){var e;this._hash&&this._hash.remove();for(const e of this._controls)e.onRemove(this);this._controls=[],this._frameRequest&&(this._frameRequest.abort(),this._frameRequest=null),this._renderTaskQueue.clear(),this.painter.destroy(),this.handlers.destroy(),delete this.handlers,this.setStyle(null),"undefined"!=typeof window&&removeEventListener("online",this._onWindowOnline,!1),R.removeThrottleControl(this._imageQueueHandle),null===(e=this._resizeObserver)||void 0===e||e.disconnect();const s=this.painter.context.gl.getExtension("WEBGL_lose_context");(null==s?void 0:s.loseContext)&&s.loseContext(),this._canvas.removeEventListener("webglcontextrestored",this._contextRestored,!1),this._canvas.removeEventListener("webglcontextlost",this._contextLost,!1),h.remove(this._canvasContainer),h.remove(this._controlContainer),this._container.removeEventListener("scroll",this._onMapScroll,!1),this._container.classList.remove("maplibregl-map"),l.cG.clearMetrics(),this._removed=!0,this.fire(new l.l("remove"))}triggerRepaint(){this.style&&!this._frameRequest&&(this._frameRequest=new AbortController,_.frame(this._frameRequest,(e=>{l.cG.frame(e),this._frameRequest=null;try{this._render(e)}catch(e){if(!l.Z(e)&&!function(e){return e.message===wn}(e))throw e}}),(()=>{})))}get showTileBoundaries(){return!!this._showTileBoundaries}set showTileBoundaries(e){this._showTileBoundaries!==e&&(this._showTileBoundaries=e,this._update())}get showPadding(){return!!this._showPadding}set showPadding(e){this._showPadding!==e&&(this._showPadding=e,this._update())}get showCollisionBoxes(){return!!this._showCollisionBoxes}set showCollisionBoxes(e){this._showCollisionBoxes!==e&&(this._showCollisionBoxes=e,e?this.style._generateCollisionBoxes():this._update())}get showOverdrawInspector(){return!!this._showOverdrawInspector}set showOverdrawInspector(e){this._showOverdrawInspector!==e&&(this._showOverdrawInspector=e,this._update())}get repaint(){return!!this._repaint}set repaint(e){this._repaint!==e&&(this._repaint=e,this.triggerRepaint())}get vertices(){return!!this._vertices}set vertices(e){this._vertices=e,this._update()}get version(){return Ko}getCameraTargetElevation(){return this.transform.elevation}getProjection(){return this.style.getProjection()}setProjection(e){return this._lazyInitEmptyStyle(),this.style.setProjection(e),this._update(!0)}},s.MapMouseEvent=ao,s.MapTouchEvent=ro,s.MapWheelEvent=oo,s.Marker=ms,s.NavigationControl=class{constructor(e){this._updateZoomButtons=()=>{const e=this._map.getZoom(),s=e===this._map.getMaxZoom(),l=e===this._map.getMinZoom();this._zoomInButton.disabled=s,this._zoomOutButton.disabled=l,this._zoomInButton.setAttribute("aria-disabled",s.toString()),this._zoomOutButton.setAttribute("aria-disabled",l.toString())},this._rotateCompassArrow=()=>{this._compassIcon.style.transform=this.options.visualizePitch&&this.options.visualizeRoll?`scale(${1/Math.pow(Math.cos(this._map.transform.pitchInRadians),.5)}) rotateZ(${-this._map.transform.roll}deg) rotateX(${this._map.transform.pitch}deg) rotateZ(${-this._map.transform.bearing}deg)`:this.options.visualizePitch?`scale(${1/Math.pow(Math.cos(this._map.transform.pitchInRadians),.5)}) rotateX(${this._map.transform.pitch}deg) rotateZ(${-this._map.transform.bearing}deg)`:this.options.visualizeRoll?`rotate(${-this._map.transform.bearing-this._map.transform.roll}deg)`:`rotate(${-this._map.transform.bearing}deg)`},this._setButtonTitle=(e,s)=>{const l=this._map._getUIString(`NavigationControl.${s}`);e.title=l,e.setAttribute("aria-label",l)},this.options=l.e({},ia,e),this._container=h.create("div","maplibregl-ctrl maplibregl-ctrl-group"),this._container.addEventListener("contextmenu",(e=>e.preventDefault())),this.options.showZoom&&(this._zoomInButton=this._createButton("maplibregl-ctrl-zoom-in",(e=>this._map.zoomIn({},{originalEvent:e}))),h.create("span","maplibregl-ctrl-icon",this._zoomInButton).setAttribute("aria-hidden","true"),this._zoomOutButton=this._createButton("maplibregl-ctrl-zoom-out",(e=>this._map.zoomOut({},{originalEvent:e}))),h.create("span","maplibregl-ctrl-icon",this._zoomOutButton).setAttribute("aria-hidden","true")),this.options.showCompass&&(this._compass=this._createButton("maplibregl-ctrl-compass",(e=>{this.options.visualizePitch?this._map.resetNorthPitch({},{originalEvent:e}):this._map.resetNorth({},{originalEvent:e})})),this._compassIcon=h.create("span","maplibregl-ctrl-icon",this._compass),this._compassIcon.setAttribute("aria-hidden","true"))}onAdd(e){return this._map=e,this.options.showZoom&&(this._setButtonTitle(this._zoomInButton,"ZoomIn"),this._setButtonTitle(this._zoomOutButton,"ZoomOut"),this._map.on("zoom",this._updateZoomButtons),this._updateZoomButtons()),this.options.showCompass&&(this._setButtonTitle(this._compass,"ResetBearing"),this.options.visualizePitch&&this._map.on("pitch",this._rotateCompassArrow),this.options.visualizeRoll&&this._map.on("roll",this._rotateCompassArrow),this._map.on("rotate",this._rotateCompassArrow),this._rotateCompassArrow(),this._handler=new hs(this._map,this._compass,this.options.visualizePitch)),this._container}onRemove(){h.remove(this._container),this.options.showZoom&&this._map.off("zoom",this._updateZoomButtons),this.options.showCompass&&(this.options.visualizePitch&&this._map.off("pitch",this._rotateCompassArrow),this.options.visualizeRoll&&this._map.off("roll",this._rotateCompassArrow),this._map.off("rotate",this._rotateCompassArrow),this._handler.off(),delete this._handler),delete this._map}_createButton(e,s){const l=h.create("button",e,this._container);return l.type="button",l.addEventListener("click",s),l}},s.Popup=class extends l.E{constructor(e){super(),this._updateOpacity=()=>{void 0!==this.options.locationOccludedOpacity&&(this._container.style.opacity=this._map.transform.isLocationOccluded(this.getLngLat())?`${this.options.locationOccludedOpacity}`:"")},this.remove=()=>(this._content&&h.remove(this._content),this._container&&(h.remove(this._container),delete this._container),this._map&&(this._map.off("move",this._update),this._map.off("move",this._onClose),this._map.off("click",this._onClose),this._map.off("remove",this.remove),this._map.off("mousemove",this._onMouseMove),this._map.off("mouseup",this._onMouseUp),this._map.off("drag",this._onDrag),this._map._canvasContainer.classList.remove("maplibregl-track-pointer"),delete this._map,this.fire(new l.l("close"))),this),this._onMouseUp=e=>{this._update(e.point)},this._onMouseMove=e=>{this._update(e.point)},this._onDrag=e=>{this._update(e.point)},this._update=e=>{if(!this._map||!this._lngLat&&!this._trackPointer||!this._content)return;if(!this._container){if(this._container=h.create("div","maplibregl-popup",this._map.getContainer()),this._tip=h.create("div","maplibregl-popup-tip",this._container),this._container.appendChild(this._content),this.options.className)for(const e of this.options.className.split(" "))this._container.classList.add(e);this._closeButton&&this._closeButton.setAttribute("aria-label",this._map._getUIString("Popup.Close")),this._trackPointer&&this._container.classList.add("maplibregl-popup-track-pointer")}if(this.options.maxWidth&&this._container.style.maxWidth!==this.options.maxWidth&&(this._container.style.maxWidth=this.options.maxWidth),this._lngLat=el(this._lngLat,this._flatPos,this._map.transform,this._trackPointer),this._trackPointer&&!e)return;const s=this._flatPos=this._pos=this._trackPointer&&e?e:this._map.project(this._lngLat);this._map.terrain&&(this._flatPos=this._trackPointer&&e?e:this._map.transform.locationToScreenPoint(this._lngLat));let l=this.options.anchor;const c=ul(this.options.offset);if(!l){const e=this._container.offsetWidth,d=this._container.offsetHeight,p=function(e){var s,l,c,d;return e?{top:null!==(s=e.top)&&void 0!==s?s:0,right:null!==(l=e.right)&&void 0!==l?l:0,bottom:null!==(c=e.bottom)&&void 0!==c?c:0,left:null!==(d=e.left)&&void 0!==d?d:0}:{top:0,right:0,bottom:0,left:0}}(this.options.padding);let f;f=s.y+c.bottom.ythis._map.transform.height-d-p.bottom?["bottom"]:[],s.xthis._map.transform.width-e/2-p.right&&f.push("right"),l=0===f.length?"bottom":f.join("-")}let d=s.add(c[l]);this.options.subpixelPositioning||(d=d.round()),h.setTransform(this._container,`${tl[l]} translate(${d.x}px,${d.y}px)`),il(this._container,l,"popup"),this._updateOpacity()},this._onClose=()=>{this.remove()},this.options=l.e(Object.create(cl),e)}addTo(e){return this._map&&this.remove(),this._map=e,this.options.closeOnClick&&this._map.on("click",this._onClose),this.options.closeOnMove&&this._map.on("move",this._onClose),this._map.on("remove",this.remove),this._update(),this._focusFirstElement(),this._trackPointer?(this._map.on("mousemove",this._onMouseMove),this._map.on("mouseup",this._onMouseUp),this._container&&this._container.classList.add("maplibregl-popup-track-pointer"),this._map._canvasContainer.classList.add("maplibregl-track-pointer")):this._map.on("move",this._update),this.fire(new l.l("open")),this}isOpen(){return!!this._map}getLngLat(){return this._lngLat}setLngLat(e){return this._lngLat=l.V.convert(e),this._pos=null,this._flatPos=null,this._trackPointer=!1,this._update(),this._map&&(this._map.on("move",this._update),this._map.off("mousemove",this._onMouseMove),this._container&&this._container.classList.remove("maplibregl-popup-track-pointer"),this._map._canvasContainer.classList.remove("maplibregl-track-pointer")),this}trackPointer(){return this._trackPointer=!0,this._pos=null,this._flatPos=null,this._update(),this._map&&(this._map.off("move",this._update),this._map.on("mousemove",this._onMouseMove),this._map.on("drag",this._onDrag),this._container&&this._container.classList.add("maplibregl-popup-track-pointer"),this._map._canvasContainer.classList.add("maplibregl-track-pointer")),this}getElement(){return this._container}setText(e){return this.setDOMContent(document.createTextNode(e))}setHTML(e){const s=document.createDocumentFragment(),l=document.createElement("body");let c;for(l.innerHTML=e;c=l.firstChild,c;)s.appendChild(c);return this.setDOMContent(s)}getMaxWidth(){var e;return null===(e=this._container)||void 0===e?void 0:e.style.maxWidth}setMaxWidth(e){return this.options.maxWidth=e,this._update(),this}setDOMContent(e){if(this._content)for(;this._content.hasChildNodes();)this._content.firstChild&&this._content.removeChild(this._content.firstChild);else this._content=h.create("div","maplibregl-popup-content",this._container);return this._content.appendChild(e),this._createCloseButton(),this._update(),this._focusFirstElement(),this}addClassName(e){return this._container&&this._container.classList.add(e),this}removeClassName(e){return this._container&&this._container.classList.remove(e),this}setOffset(e){return this.options.offset=e,this._update(),this}toggleClassName(e){if(this._container)return this._container.classList.toggle(e)}setSubpixelPositioning(e){this.options.subpixelPositioning=e}setPadding(e){this.options.padding=e,this._update()}_createCloseButton(){this.options.closeButton&&(this._closeButton=h.create("button","maplibregl-popup-close-button",this._content),this._closeButton.type="button",this._closeButton.innerHTML="×",this._closeButton.addEventListener("click",this._onClose))}_focusFirstElement(){if(!this.options.focusAfterOpen||!this._container)return;const e=this._container.querySelector(hl);e&&e.focus()}},s.RasterDEMTileSource=Y,s.RasterTileSource=K,s.ScaleControl=class{constructor(e){this._onMove=()=>{al(this._map,this._container,this.options)},this.setUnit=e=>{this.options.unit=e,al(this._map,this._container,this.options)},this.options=Object.assign(Object.assign({},ol),e)}getDefaultPosition(){return"bottom-left"}onAdd(e){return this._map=e,this._container=h.create("div","maplibregl-ctrl maplibregl-ctrl-scale",e.getContainer()),this._map.on("move",this._onMove),this._onMove(),this._container}onRemove(){h.remove(this._container),this._map.off("move",this._onMove),this._map=void 0}},s.ScrollZoomHandler=Bo,s.Style=ki,s.TerrainControl=class{constructor(e){this._toggleTerrain=()=>{this._map.getTerrain()?this._map.setTerrain(null):this._map.setTerrain(this.options),this._updateTerrainIcon()},this._updateTerrainIcon=()=>{this._terrainButton.classList.remove("maplibregl-ctrl-terrain"),this._terrainButton.classList.remove("maplibregl-ctrl-terrain-enabled"),this._map.terrain?(this._terrainButton.classList.add("maplibregl-ctrl-terrain-enabled"),this._terrainButton.title=this._map._getUIString("TerrainControl.Disable")):(this._terrainButton.classList.add("maplibregl-ctrl-terrain"),this._terrainButton.title=this._map._getUIString("TerrainControl.Enable"))},this.options=e}onAdd(e){return this._map=e,this._container=h.create("div","maplibregl-ctrl maplibregl-ctrl-group"),this._terrainButton=h.create("button","maplibregl-ctrl-terrain",this._container),h.create("span","maplibregl-ctrl-icon",this._terrainButton).setAttribute("aria-hidden","true"),this._terrainButton.type="button",this._terrainButton.addEventListener("click",this._toggleTerrain),this._updateTerrainIcon(),this._map.on("terrain",this._updateTerrainIcon),this._container}onRemove(){h.remove(this._container),this._map.off("terrain",this._updateTerrainIcon),this._map=void 0}},s.TwoFingersTouchPitchHandler=Ro,s.TwoFingersTouchRotateHandler=So,s.TwoFingersTouchZoomHandler=Mo,s.TwoFingersTouchZoomRotateHandler=Uo,s.VectorTileSource=X,s.VideoSource=ie,s.addSourceType=(e,s)=>l._(void 0,void 0,void 0,(function*(){if(xe(e))throw new Error(`A source type called "${e}" already exists.`);((e,s)=>{ye[e]=s})(e,s)})),s.clearPrewarmedResources=function(){const e=re;e&&(e.isPreloaded()&&1===e.numActive()?(e.release(W),re=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()"))},s.createTileMesh=cr,s.getMaxParallelImageRequests=function(){return l.c.MAX_PARALLEL_IMAGE_REQUESTS},s.getRTLTextPluginStatus=function(){return we().getRTLTextPluginStatus()},s.getVersion=function(){return dl},s.getWorkerCount=function(){return k.workerCount},s.getWorkerUrl=function(){return l.c.WORKER_URL},s.importScriptInWorkers=function(e){return le().broadcast("IS",e)},s.isTimeFrozen=function(){return g.isFrozen()},s.now=y,s.prewarm=function(){oe().acquire(W)},s.restoreNow=function(){g.restoreNow()},s.setMaxParallelImageRequests=function(e){l.c.MAX_PARALLEL_IMAGE_REQUESTS=e},s.setNow=function(e){g.setNow(e)},s.setRTLTextPlugin=function(e,s){return we().setRTLTextPlugin(e,s)},s.setWorkerCount=function(e){k.workerCount=e},s.setWorkerUrl=function(e){l.c.WORKER_URL=e}}));var d=s;return d}));var l=s;export{l as default};